@ms-cloudpack/esm-stub-utilities 0.5.2 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/browserEnvironment.cjs +53 -0
- package/lib/browserEnvironment.cjs.map +1 -0
- package/lib/browserEnvironment.d.cts +1 -0
- package/lib/createESMStub.js +4 -6
- package/lib/createESMStub.js.map +1 -1
- package/lib/runInSandbox.d.ts +11 -0
- package/lib/runInSandbox.js +172 -0
- package/lib/runInSandbox.js.map +1 -0
- package/lib/tsdoc-metadata.json +1 -1
- package/package.json +4 -3
- package/lib/initializeBrowserEnvironment.d.ts +0 -4
- package/lib/initializeBrowserEnvironment.js +0 -67
- package/lib/initializeBrowserEnvironment.js.map +0 -1
- package/lib/tryRequire.cjs +0 -13
- package/lib/tryRequire.cjs.map +0 -1
- package/lib/tryRequire.d.cts +0 -2
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// This file uses JS because it's loaded directly into the CJS sandbox environment
|
|
3
|
+
// (see runInSandbox.ts)
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
6
|
+
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
7
|
+
/* eslint-disable etc/no-deprecated */
|
|
8
|
+
const { JSDOM } = require('jsdom');
|
|
9
|
+
const btoa = require('btoa');
|
|
10
|
+
const atob = require('atob');
|
|
11
|
+
require('jsdom-global');
|
|
12
|
+
require('regenerator-runtime');
|
|
13
|
+
const dom = new JSDOM();
|
|
14
|
+
global.window = dom.window;
|
|
15
|
+
global.window.requestAnimationFrame = dom.window.setTimeout;
|
|
16
|
+
global.window.cancelAnimationFrame = dom.window.clearTimeout;
|
|
17
|
+
global.btoa = btoa;
|
|
18
|
+
global.atob = atob;
|
|
19
|
+
global.self = dom.window;
|
|
20
|
+
global.document = dom.window.document;
|
|
21
|
+
global.navigator = dom.window.navigator;
|
|
22
|
+
// Simulate WebSocket existence. (Needed for isomorphic-ws)
|
|
23
|
+
global.WebSocket = global.window.WebSocket = /** @type {*} */ (class WebSocket {
|
|
24
|
+
});
|
|
25
|
+
// Fake MessageChannel so scheduler won't hang the process by opening a channel.
|
|
26
|
+
global.MessageChannel = global.window.MessageChannel = class MessageChannel {
|
|
27
|
+
constructor() {
|
|
28
|
+
this.port1 = ({});
|
|
29
|
+
this.port2 = ({});
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
const createElement = dom.window.document.createElement.bind(dom.window.document);
|
|
33
|
+
// Mock out canvas.
|
|
34
|
+
global.document.createElement =
|
|
35
|
+
/** @type {*} */ (global.window).createElement =
|
|
36
|
+
/** @type {*} */ (global).createElement =
|
|
37
|
+
(/** @type {string} */ tagName, /** @type {ElementCreationOptions} */ options) => {
|
|
38
|
+
if (tagName === 'canvas') {
|
|
39
|
+
return /** @type {*} */ ({
|
|
40
|
+
getContext: () => ({
|
|
41
|
+
fillRect: () => {
|
|
42
|
+
/* no-op */
|
|
43
|
+
},
|
|
44
|
+
}),
|
|
45
|
+
measureText: () => ({}),
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
return createElement.apply(dom.window.document, [tagName, options]);
|
|
49
|
+
};
|
|
50
|
+
global.window.fetch = /** @type {*} */ (async () => {
|
|
51
|
+
/* no-op */
|
|
52
|
+
});
|
|
53
|
+
//# sourceMappingURL=browserEnvironment.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browserEnvironment.cjs","sourceRoot":"","sources":["../src/browserEnvironment.cjs"],"names":[],"mappings":";AAAA,kFAAkF;AAClF,wBAAwB;;AAExB,4DAA4D;AAC5D,uDAAuD;AACvD,sCAAsC;AACtC,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AACnC,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AAC7B,MAAM,IAA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CAAC,aAAa;QAC9C,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC,aAAa;YACrC,CAAC,qBAAqB,CAAC,OAAO,EAAE,qCAAqC,CAAC,OAAO,EAAE,EAAE;gBAC/E,IAAI,OAAO,KAAK,QAAQ,EAAE;oBACxB,OAAO,gBAAgB,CAAC,CAAC;wBACvB,UAAU,EAAE,GAAG,EAAE,CAAC,CAAC;4BACjB,QAAQ,EAAE,GAAG,EAAE;gCACb,WAAW;4BACb,CAAC;yBACF,CAAC;wBACF,WAAW,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC;qBACxB,CAAC,CAAC;iBACJ;gBAED,OAAO,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;YACtE,CAAC,CAAC;AAEN,MAAM,CAAC,MAAM,CAAC,KAAK,GAAG,gBAAgB,CAAC,CACrC,KAAK,IAAI,EAAE;IACT,WAAW;AACb,CAAC,CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/lib/createESMStub.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { slash } from '@ms-cloudpack/path-string-parsing';
|
|
2
1
|
import path from 'path';
|
|
3
|
-
import {
|
|
2
|
+
import { slash } from '@ms-cloudpack/path-string-parsing';
|
|
4
3
|
import { forbiddenExportNames } from './forbiddenExportNames.js';
|
|
5
|
-
import {
|
|
4
|
+
import { runInSandbox } from './runInSandbox.js';
|
|
6
5
|
/**
|
|
7
6
|
* Generates an ESM stub for CommonJS modules.
|
|
8
7
|
* @param entryPath - The full path to the CommonJS entry file.
|
|
@@ -13,9 +12,8 @@ import { tryRequire } from './tryRequire.cjs';
|
|
|
13
12
|
export async function createESMStub(entryPath, stubPath) {
|
|
14
13
|
const result = [];
|
|
15
14
|
const relativePath = './' + slash(path.relative(path.dirname(stubPath), entryPath));
|
|
16
|
-
//
|
|
17
|
-
await
|
|
18
|
-
const packageExport = tryRequire(entryPath);
|
|
15
|
+
// Run the entry point file in a sandbox to determine the exports
|
|
16
|
+
const packageExport = (await runInSandbox(entryPath));
|
|
19
17
|
if (packageExport !== undefined) {
|
|
20
18
|
const isExportObject = typeof packageExport === 'object';
|
|
21
19
|
const isExportFunction = typeof packageExport === 'function';
|
package/lib/createESMStub.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createESMStub.js","sourceRoot":"","sources":["../src/createESMStub.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"createESMStub.js","sourceRoot":"","sources":["../src/createESMStub.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,SAAiB,EAAE,QAAgB;IACrE,MAAM,MAAM,GAAG,EAAE,CAAC;IAClB,MAAM,YAAY,GAAG,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC;IAEpF,iEAAiE;IACjE,MAAM,aAAa,GAAG,CAAC,MAAM,YAAY,CAAC,SAAS,CAAC,CAA4B,CAAC;IAEjF,IAAI,aAAa,KAAK,SAAS,EAAE;QAC/B,MAAM,cAAc,GAAG,OAAO,aAAa,KAAK,QAAQ,CAAC;QACzD,MAAM,gBAAgB,GAAG,OAAO,aAAa,KAAK,UAAU,CAAC;QAE7D,IAAI,gBAAgB,IAAI,CAAC,cAAc,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,EAAE;YACzE,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BAAkB,aAAa,GAAG,CAAC,CAAC;SACjD;aAAM,IAAI,OAAO,aAAa,KAAK,QAAQ,EAAE;YAC5C,qBAAqB;YACrB,MAAM,CAAC,IAAI,CAAC,kBAAkB,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;SACjE;aAAM;YACL,iDAAiD;YACjD,MAAM,CAAC,IAAI,CAAC,+BAA+B,CAAC,CAAC;SAC9C;KACF;SAAM;QACL,uCAAuC;QACvC,MAAM,CAAC,IAAI,CAAC,WAAW,YAAY,IAAI,CAAC,CAAC;KAC1C;IAED,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC3B,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { NodeVM } from 'vm2';
|
|
2
|
+
/** Reset `vms` and `sandboxRoots` for testing */
|
|
3
|
+
export declare function _clearSandboxCaches(): void;
|
|
4
|
+
/** Get `vms` state for testing */
|
|
5
|
+
export declare function _getSandboxVms(): Record<string, NodeVM>;
|
|
6
|
+
/**
|
|
7
|
+
* Run a CommonJS file within a sandboxed environment.
|
|
8
|
+
* @param entryPath - Path to a CommonJS file to run in a sandbox (does not work with ESM files)
|
|
9
|
+
* @returns The module's exports
|
|
10
|
+
*/
|
|
11
|
+
export declare function runInSandbox(entryPath: string): Promise<unknown>;
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { builtinModules } from 'module';
|
|
4
|
+
import { fileURLToPath } from 'url';
|
|
5
|
+
import { NodeVM, VMError } from 'vm2';
|
|
6
|
+
import { findPackageRoot } from '@ms-cloudpack/path-utilities';
|
|
7
|
+
const filename = fileURLToPath(import.meta.url);
|
|
8
|
+
const dirname = path.dirname(filename);
|
|
9
|
+
const browserEnvSetup = path.join(dirname, 'browserEnvironment.cjs');
|
|
10
|
+
/** Allow the sandbox to load these built-in modules */
|
|
11
|
+
// ('events' and 'stream' export classes which other things extend and can't be proxied)
|
|
12
|
+
const allowedBuiltins = ['events', 'path', 'stream', 'url', 'util'];
|
|
13
|
+
/** Built-in modules provided by vm2 */
|
|
14
|
+
const includedBuiltins = ['buffer'];
|
|
15
|
+
/** Empty mocks of all built-in modules that aren't allowed (to ensure that requires succeed) */
|
|
16
|
+
const mockBuiltins = Object.fromEntries(builtinModules.filter((m) => !allowedBuiltins.includes(m) && !includedBuiltins.includes(m)).map((m) => [m, {}]));
|
|
17
|
+
/** Mapping from sandbox root to VM */
|
|
18
|
+
const vms = {};
|
|
19
|
+
/** Mapping from directory to sandbox root */
|
|
20
|
+
const sandboxRoots = {};
|
|
21
|
+
/** Sandbox root for this file and other cloudpack-related files */
|
|
22
|
+
let cloudpackSandboxRoot = '';
|
|
23
|
+
/** Reset `vms` and `sandboxRoots` for testing */
|
|
24
|
+
export function _clearSandboxCaches() {
|
|
25
|
+
Object.keys(vms).forEach((k) => delete vms[k]);
|
|
26
|
+
Object.keys(sandboxRoots).forEach((k) => delete sandboxRoots[k]);
|
|
27
|
+
}
|
|
28
|
+
/** Get `vms` state for testing */
|
|
29
|
+
export function _getSandboxVms() {
|
|
30
|
+
return vms;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Try to figure out a root directory where the sandbox should be allowed to require files from.
|
|
34
|
+
* This prefers the git root if found, falling back to package root or parent directory.
|
|
35
|
+
*
|
|
36
|
+
* (This is very likely overly permissive and might be good to restrict in the future.)
|
|
37
|
+
*/
|
|
38
|
+
function findSandboxRoot(filePath) {
|
|
39
|
+
const root = path.parse(filePath).root;
|
|
40
|
+
let dir = path.dirname(filePath);
|
|
41
|
+
if (!sandboxRoots[dir]) {
|
|
42
|
+
// try to find a git root first
|
|
43
|
+
while (dir !== root && !fs.existsSync(path.join(dir, '.git'))) {
|
|
44
|
+
dir = path.dirname(dir);
|
|
45
|
+
}
|
|
46
|
+
if (dir === root) {
|
|
47
|
+
// fallback: package root
|
|
48
|
+
dir = findPackageRoot(filePath);
|
|
49
|
+
if (!dir) {
|
|
50
|
+
// final fallback: parent directory
|
|
51
|
+
dir = path.dirname(filePath);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
sandboxRoots[dir] = dir;
|
|
55
|
+
}
|
|
56
|
+
return sandboxRoots[dir];
|
|
57
|
+
}
|
|
58
|
+
function handleError(action, err, sandboxRoot) {
|
|
59
|
+
const message = err.message || String(err);
|
|
60
|
+
const stack = err.stack?.split(/\r?\n/g) || [];
|
|
61
|
+
// instanceof checks don't work with errors from code run within the sandbox, but name is preserved
|
|
62
|
+
const errorName = err.name;
|
|
63
|
+
const newMessage = [`Error ${action}:`, message];
|
|
64
|
+
if (stack.length && err instanceof VMError && err.message.includes('Cannot find module')) {
|
|
65
|
+
newMessage.push('', 'Ensure that this file exists on disk. If it exists, this may be a bug with the choice of `root` ' +
|
|
66
|
+
'(allowed parent directories) settings in @ms-cloudpack/esm-stub-utilities runInSandbox.', `- Root for file being stubbed: ${sandboxRoot}`, `- Root for cloudpack files: ${cloudpackSandboxRoot}`);
|
|
67
|
+
// Find the actual line which caused the error
|
|
68
|
+
const errorLines = stack.filter((line) => line.trim().startsWith('at') && !line.includes('vm2'));
|
|
69
|
+
if (errorLines.length) {
|
|
70
|
+
newMessage.push('', 'Code that may have required this module:', ...errorLines);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
else if (errorName === 'TypeError') {
|
|
74
|
+
newMessage.push('', 'If the code was referencing a built-in global or a property of a Node built-in module, ' +
|
|
75
|
+
'this error may be caused by a missing mock or other issue with the sandbox environment ' +
|
|
76
|
+
'configured in @ms-cloudpack/esm-stub-utilities runInSandbox.');
|
|
77
|
+
}
|
|
78
|
+
else if (errorName === 'SyntaxError' &&
|
|
79
|
+
(/Unexpected token '(import|export)'/.test(message) ||
|
|
80
|
+
message.includes(`'import' and 'export' may appear only with`))) {
|
|
81
|
+
newMessage.push('', "It appears you're trying to load an ES module, which is not currently supported in the sandbox. " +
|
|
82
|
+
'If this module is loaded at startup within a CommonJS file, please file an issue with cloudpack. ');
|
|
83
|
+
}
|
|
84
|
+
if (stack.length) {
|
|
85
|
+
newMessage.push('', 'Original stack:', ...stack.slice(1));
|
|
86
|
+
}
|
|
87
|
+
throw new Error(newMessage.join('\n'));
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Run a CommonJS file within a sandboxed environment.
|
|
91
|
+
* @param entryPath - Path to a CommonJS file to run in a sandbox (does not work with ESM files)
|
|
92
|
+
* @returns The module's exports
|
|
93
|
+
*/
|
|
94
|
+
// eslint-disable-next-line @typescript-eslint/require-await -- using async to catch async errors
|
|
95
|
+
export async function runInSandbox(entryPath) {
|
|
96
|
+
if (!path.isAbsolute(entryPath)) {
|
|
97
|
+
throw new Error('Entry path must be absolute. Received: ' + entryPath);
|
|
98
|
+
}
|
|
99
|
+
if (!fs.existsSync(entryPath)) {
|
|
100
|
+
throw new Error('Entry path does not exist: ' + entryPath);
|
|
101
|
+
}
|
|
102
|
+
// Allow code in the sandbox to require files under the requested file's package root,
|
|
103
|
+
// or under its directory if it's not in a package.
|
|
104
|
+
const sandboxRoot = findSandboxRoot(entryPath);
|
|
105
|
+
if (!vms[sandboxRoot]) {
|
|
106
|
+
if (!cloudpackSandboxRoot) {
|
|
107
|
+
cloudpackSandboxRoot = findSandboxRoot(filename);
|
|
108
|
+
}
|
|
109
|
+
console.log('esm-stub-utilities: Creating sandbox for ' + sandboxRoot);
|
|
110
|
+
try {
|
|
111
|
+
vms[sandboxRoot] = new NodeVM({
|
|
112
|
+
// disable console logging instead of passing through to the host console
|
|
113
|
+
console: 'off',
|
|
114
|
+
// look for these import extensions (mjs is not included because this doesn't support loading ESM)
|
|
115
|
+
sourceExtensions: ['js', 'cjs'],
|
|
116
|
+
// use a commonjs module wrapper
|
|
117
|
+
wrapper: 'commonjs',
|
|
118
|
+
require: {
|
|
119
|
+
// allow local and dependency modules to be required under here
|
|
120
|
+
root: [cloudpackSandboxRoot, sandboxRoot],
|
|
121
|
+
// load, compile, and require modules in the sandbox (instead of requiring in the host)
|
|
122
|
+
context: 'sandbox',
|
|
123
|
+
// allowed built-in modules
|
|
124
|
+
builtin: allowedBuiltins,
|
|
125
|
+
// allow loading "external" modules under the given roots
|
|
126
|
+
external: true,
|
|
127
|
+
// simulate the browser at startup (can throw errors)
|
|
128
|
+
import: [browserEnvSetup],
|
|
129
|
+
// mock these modules so they can be successfully required
|
|
130
|
+
mock: {
|
|
131
|
+
...mockBuiltins,
|
|
132
|
+
// some modules reference these built-ins during their setup
|
|
133
|
+
perf_hooks: {
|
|
134
|
+
performance: { now: () => Date.now() },
|
|
135
|
+
},
|
|
136
|
+
vm: {
|
|
137
|
+
isContext: () => false,
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
sandbox: {
|
|
142
|
+
// these are normally available in the global context (and are referenced by some modules)
|
|
143
|
+
// but for some reason are not passed through by vm2
|
|
144
|
+
TextEncoder,
|
|
145
|
+
TextDecoder,
|
|
146
|
+
},
|
|
147
|
+
env: {
|
|
148
|
+
// prevent debug from accessing process.stderr
|
|
149
|
+
DEBUG_COLORS: 0,
|
|
150
|
+
},
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
catch (err) {
|
|
154
|
+
handleError(`initializing sandbox for ${sandboxRoot} (to create stub of ${entryPath})`, err, sandboxRoot);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
const onError = (err) => {
|
|
158
|
+
handleError(`running ${entryPath} in sandbox (to create stub)`, err, sandboxRoot);
|
|
159
|
+
};
|
|
160
|
+
process.on('uncaughtException', onError);
|
|
161
|
+
try {
|
|
162
|
+
const cjsFile = fs.readFileSync(entryPath, 'utf8');
|
|
163
|
+
return vms[sandboxRoot].run(cjsFile, { filename: entryPath });
|
|
164
|
+
}
|
|
165
|
+
catch (err) {
|
|
166
|
+
onError(err);
|
|
167
|
+
}
|
|
168
|
+
finally {
|
|
169
|
+
process.off('uncaughtException', onError);
|
|
170
|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AAC,CAAC;KACd;YAAS;QACR,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,OAAO,CAAC,CAAC;KAC3C;AACH,CAAC"}
|
package/lib/tsdoc-metadata.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ms-cloudpack/esm-stub-utilities",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "Generates ESM stubs for CommonJS entry files.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -13,13 +13,14 @@
|
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@ms-cloudpack/path-utilities": "^2.1.
|
|
16
|
+
"@ms-cloudpack/path-utilities": "^2.1.1",
|
|
17
17
|
"@ms-cloudpack/path-string-parsing": "^1.0.1",
|
|
18
18
|
"atob": "^2.1.2",
|
|
19
19
|
"btoa": "^1.2.1",
|
|
20
20
|
"jsdom-global": "^3.0.2",
|
|
21
21
|
"jsdom": "^21.1.0",
|
|
22
|
-
"regenerator-runtime": "^0.13.9"
|
|
22
|
+
"regenerator-runtime": "^0.13.9",
|
|
23
|
+
"vm2": "^3.9.13"
|
|
23
24
|
},
|
|
24
25
|
"devDependencies": {
|
|
25
26
|
"@ms-cloudpack/eslint-config-base": "*",
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
3
|
-
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
|
4
|
-
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
5
|
-
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
|
6
|
-
let hasInitialized = false;
|
|
7
|
-
/**
|
|
8
|
-
* Initializes a browser environment (e.g. by setting up the global `window` in a node environment).
|
|
9
|
-
*/
|
|
10
|
-
export async function initializeBrowserEnvironment() {
|
|
11
|
-
if (!hasInitialized) {
|
|
12
|
-
hasInitialized = true;
|
|
13
|
-
if (typeof window === 'undefined' && typeof global !== 'undefined') {
|
|
14
|
-
const { JSDOM } = await import('jsdom');
|
|
15
|
-
const btoa = await import('btoa');
|
|
16
|
-
const atob = await import('atob');
|
|
17
|
-
await import('jsdom-global');
|
|
18
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
19
|
-
// @ts-ignore
|
|
20
|
-
await import('regenerator-runtime');
|
|
21
|
-
const dom = new JSDOM();
|
|
22
|
-
const globalThis = global;
|
|
23
|
-
globalThis.window = dom.window;
|
|
24
|
-
globalThis.window.requestAnimationFrame = dom.window.setTimeout;
|
|
25
|
-
globalThis.window.cancelAnimationFrame = dom.window.clearTimeout;
|
|
26
|
-
globalThis.btoa = btoa;
|
|
27
|
-
globalThis.atob = atob;
|
|
28
|
-
globalThis.self = dom.window;
|
|
29
|
-
globalThis.document = dom.window.document;
|
|
30
|
-
globalThis.navigator = dom.window.navigator;
|
|
31
|
-
// Simulate WebSocket existence. (Needed for isomorphic-ws)
|
|
32
|
-
globalThis.WebSocket = globalThis.window.WebSocket = function () {
|
|
33
|
-
/* noop */
|
|
34
|
-
};
|
|
35
|
-
// Fake MessageChannel so scheduler won't hang the process by opening a channel.
|
|
36
|
-
globalThis.MessageChannel = globalThis.window.MessageChannel = class MessageChannel {
|
|
37
|
-
constructor() {
|
|
38
|
-
this.port1 = {};
|
|
39
|
-
this.port2 = {};
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
// eslint-disable-next-line etc/no-deprecated
|
|
43
|
-
const createElement = dom.window.document.createElement.bind(dom.window.document);
|
|
44
|
-
// Mock out canvas.
|
|
45
|
-
globalThis.document.createElement =
|
|
46
|
-
globalThis.window.createElement =
|
|
47
|
-
globalThis.createElement =
|
|
48
|
-
(tagName, ...args) => {
|
|
49
|
-
if (tagName === 'canvas') {
|
|
50
|
-
return {
|
|
51
|
-
getContext: () => ({
|
|
52
|
-
fillRect: () => {
|
|
53
|
-
/* no-op */
|
|
54
|
-
},
|
|
55
|
-
}),
|
|
56
|
-
measureText: () => ({}),
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
return createElement.apply(dom.window.document, [tagName, ...args]);
|
|
60
|
-
};
|
|
61
|
-
globalThis.window.fetch = async () => {
|
|
62
|
-
/* no-op */
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
//# sourceMappingURL=initializeBrowserEnvironment.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"initializeBrowserEnvironment.js","sourceRoot":"","sources":["../src/initializeBrowserEnvironment.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,4DAA4D;AAC5D,sDAAsD;AACtD,+DAA+D;AAC/D,wDAAwD;AACxD,IAAI,cAAc,GAAG,KAAK,CAAC;AAE3B;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,4BAA4B;IAChD,IAAI,CAAC,cAAc,EAAE;QACnB,cAAc,GAAG,IAAI,CAAC;QACtB,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;YAClE,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,CAAC;YACxC,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,CAAC;YAClC,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,CAAC;YAElC,MAAM,MAAM,CAAC,cAAc,CAAC,CAAC;YAE7B,6DAA6D;YAC7D,aAAa;YACb,MAAM,MAAM,CAAC,qBAAqB,CAAC,CAAC;YAEpC,MAAM,GAAG,GAAG,IAAI,KAAK,EAAE,CAAC;YACxB,MAAM,UAAU,GAAG,MAAa,CAAC;YAEjC,UAAU,CAAC,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC;YAC/B,UAAU,CAA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AAC,EAAE,CAAC;iCACxB,CAAC;6BACH;4BAED,OAAQ,aAAqB,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC;wBAC/E,CAAC,CAAC;YAEN,UAAU,CAAC,MAAM,CAAC,KAAK,GAAG,KAAK,IAAI,EAAE;gBACnC,WAAW;YACb,CAAC,CAAC;SACH;KACF;AACH,CAAC"}
|
package/lib/tryRequire.cjs
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/**
|
|
4
|
-
* Requires a CommonJS entry file. We need to call require to ensure the cjs module is
|
|
5
|
-
* parsed and we aren't redirected to an esm via exports maps.
|
|
6
|
-
*/
|
|
7
|
-
module.exports = {
|
|
8
|
-
/** @param {string} modulePath */
|
|
9
|
-
tryRequire(modulePath) {
|
|
10
|
-
return /** @type {unknown} */ (require(modulePath));
|
|
11
|
-
},
|
|
12
|
-
};
|
|
13
|
-
//# sourceMappingURL=tryRequire.cjs.map
|
package/lib/tryRequire.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tryRequire.cjs","sourceRoot":"","sources":["../src/tryRequire.cjs"],"names":[],"mappings":";;AAAA;;;GAGG;AACH,MAAM,CAAC,OAAO,GAAG;IACf,iCAAiC;IACjC,UAAU,CAAC,UAAU;QACnB,OAAO,sBAAsB,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC;IACtD,CAAC;CACF,CAAC"}
|
package/lib/tryRequire.d.cts
DELETED