Skip to content

Commit 2229817

Browse files
committed
fix(build): remove globalthis deps
@emnapi/core & @emnapi/runtime deps are temporary until the tooling deps are fixed. napi-rs/napi-rs#3174
1 parent 3aff1e3 commit 2229817

4 files changed

Lines changed: 21 additions & 113 deletions

File tree

Sources/macros.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* The name change is so we do not get eaten by babel-plugin-macros.
44
*/
55
import DeepEqual from 'fast-deep-equal';
6-
import vtk, { vtkGlobal } from './vtk';
6+
import vtk from './vtk';
77
import ClassHierarchy from './Common/Core/ClassHierarchy';
88

99
let globalMTime = 0;
@@ -42,14 +42,17 @@ consoleMethods.forEach((methodName) => {
4242
fakeConsole[methodName] = noOp;
4343
});
4444

45-
vtkGlobal.console = console.hasOwnProperty('log') ? console : fakeConsole;
45+
const resolvedConsole =
46+
globalThis.console && globalThis.console.hasOwnProperty('log')
47+
? globalThis.console
48+
: fakeConsole;
4649

4750
const loggerFunctions = {
4851
debug: noOp, // Don't print debug by default
49-
error: vtkGlobal.console.error || noOp,
50-
info: vtkGlobal.console.info || noOp,
51-
log: vtkGlobal.console.log || noOp,
52-
warn: vtkGlobal.console.warn || noOp,
52+
error: resolvedConsole.error || noOp,
53+
info: resolvedConsole.info || noOp,
54+
log: resolvedConsole.log || noOp,
55+
warn: resolvedConsole.warn || noOp,
5356
};
5457

5558
export function setLoggerFunction(name, fn) {

Sources/vtk.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
import globalThisShim from 'globalthis';
2-
3-
export const vtkGlobal = globalThisShim(); // returns native globalThis if compliant
4-
51
const factoryMapping = {
62
vtkObject: () => null,
73
};
@@ -14,15 +10,15 @@ export default function vtk(obj) {
1410
return obj;
1511
}
1612
if (!obj.vtkClass) {
17-
if (vtkGlobal.console && vtkGlobal.console.error) {
18-
vtkGlobal.console.error('Invalid VTK object');
13+
if (globalThis.console && globalThis.console.error) {
14+
globalThis.console.error('Invalid VTK object');
1915
}
2016
return null;
2117
}
2218
const constructor = factoryMapping[obj.vtkClass];
2319
if (!constructor) {
24-
if (vtkGlobal.console && vtkGlobal.console.error) {
25-
vtkGlobal.console.error(
20+
if (globalThis.console && globalThis.console.error) {
21+
globalThis.console.error(
2622
`No vtk class found for Object of type ${obj.vtkClass}`
2723
);
2824
}

package-lock.json

Lines changed: 6 additions & 98 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
"fast-deep-equal": "3.1.3",
3737
"fflate": "0.7.3",
3838
"gl-matrix": "3.4.3",
39-
"globalthis": "1.0.3",
4039
"seedrandom": "3.0.5",
4140
"shelljs": "0.8.5",
4241
"spark-md5": "3.0.2",
@@ -47,6 +46,8 @@
4746
"devDependencies": {
4847
"@commitlint/cli": "19.7.1",
4948
"@commitlint/config-conventional": "19.7.1",
49+
"@emnapi/core": "1.10.0",
50+
"@emnapi/runtime": "1.10.0",
5051
"@mapbox/node-pre-gyp": "1.0.9",
5152
"@rolldown/plugin-node-polyfills": "1.0.3",
5253
"@types/node": "22.13.1",

0 commit comments

Comments
 (0)