@rspack-debug/test-tools 1.3.14
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/LICENSE +22 -0
- package/README.md +17 -0
- package/dist/case/builtin.d.ts +1 -0
- package/dist/case/builtin.js +39 -0
- package/dist/case/cache.d.ts +2 -0
- package/dist/case/cache.js +34 -0
- package/dist/case/compiler.d.ts +6 -0
- package/dist/case/compiler.js +17 -0
- package/dist/case/config.d.ts +3 -0
- package/dist/case/config.js +39 -0
- package/dist/case/defaults.d.ts +6 -0
- package/dist/case/defaults.js +39 -0
- package/dist/case/diagnostic.d.ts +1 -0
- package/dist/case/diagnostic.js +29 -0
- package/dist/case/diff.d.ts +3 -0
- package/dist/case/diff.js +126 -0
- package/dist/case/error.d.ts +6 -0
- package/dist/case/error.js +21 -0
- package/dist/case/hash.d.ts +3 -0
- package/dist/case/hash.js +30 -0
- package/dist/case/hook.d.ts +6 -0
- package/dist/case/hook.js +35 -0
- package/dist/case/hot-step.d.ts +2 -0
- package/dist/case/hot-step.js +32 -0
- package/dist/case/hot.d.ts +2 -0
- package/dist/case/hot.js +32 -0
- package/dist/case/index.d.ts +19 -0
- package/dist/case/index.js +35 -0
- package/dist/case/new-incremental.d.ts +6 -0
- package/dist/case/new-incremental.js +100 -0
- package/dist/case/normal.d.ts +1 -0
- package/dist/case/normal.js +29 -0
- package/dist/case/serial.d.ts +3 -0
- package/dist/case/serial.js +34 -0
- package/dist/case/stats-api.d.ts +6 -0
- package/dist/case/stats-api.js +21 -0
- package/dist/case/stats-output.d.ts +1 -0
- package/dist/case/stats-output.js +22 -0
- package/dist/case/treeshaking.d.ts +1 -0
- package/dist/case/treeshaking.js +23 -0
- package/dist/case/watch.d.ts +1 -0
- package/dist/case/watch.js +53 -0
- package/dist/compare/comparator.d.ts +17 -0
- package/dist/compare/comparator.js +52 -0
- package/dist/compare/compare.d.ts +17 -0
- package/dist/compare/compare.js +175 -0
- package/dist/compare/format-code.d.ts +16 -0
- package/dist/compare/format-code.js +239 -0
- package/dist/compare/index.d.ts +5 -0
- package/dist/compare/index.js +21 -0
- package/dist/compare/replace-module-argument.d.ts +1 -0
- package/dist/compare/replace-module-argument.js +8 -0
- package/dist/compare/replace-runtime-module-name.d.ts +1 -0
- package/dist/compare/replace-runtime-module-name.js +71 -0
- package/dist/compiler.d.ts +28 -0
- package/dist/compiler.js +111 -0
- package/dist/helper/directory.d.ts +12 -0
- package/dist/helper/directory.js +81 -0
- package/dist/helper/expect/diff.d.ts +3 -0
- package/dist/helper/expect/diff.js +21 -0
- package/dist/helper/expect/error.d.ts +5 -0
- package/dist/helper/expect/error.js +51 -0
- package/dist/helper/expect/placeholder.d.ts +1 -0
- package/dist/helper/expect/placeholder.js +41 -0
- package/dist/helper/expect/rspack.d.ts +3 -0
- package/dist/helper/expect/rspack.js +14 -0
- package/dist/helper/expect/to-be-typeof.d.ts +4 -0
- package/dist/helper/expect/to-be-typeof.js +12 -0
- package/dist/helper/expect/to-end-with.d.ts +4 -0
- package/dist/helper/expect/to-end-with.js +11 -0
- package/dist/helper/expect/to-match-file-snapshot.d.ts +23 -0
- package/dist/helper/expect/to-match-file-snapshot.js +108 -0
- package/dist/helper/hot-update/index.d.ts +1 -0
- package/dist/helper/hot-update/index.js +5 -0
- package/dist/helper/hot-update/loader.d.ts +1 -0
- package/dist/helper/hot-update/loader.js +32 -0
- package/dist/helper/hot-update/plugin.d.ts +17 -0
- package/dist/helper/hot-update/plugin.js +133 -0
- package/dist/helper/index.d.ts +7 -0
- package/dist/helper/index.js +23 -0
- package/dist/helper/legacy/EventSourceForNode.d.ts +8 -0
- package/dist/helper/legacy/EventSourceForNode.js +40 -0
- package/dist/helper/legacy/FakeDocument.d.ts +54 -0
- package/dist/helper/legacy/FakeDocument.js +278 -0
- package/dist/helper/legacy/asModule.d.ts +3 -0
- package/dist/helper/legacy/asModule.js +25 -0
- package/dist/helper/legacy/captureStdio.d.ts +8 -0
- package/dist/helper/legacy/captureStdio.js +32 -0
- package/dist/helper/legacy/checkArrayExpectation.d.ts +2 -0
- package/dist/helper/legacy/checkArrayExpectation.js +111 -0
- package/dist/helper/legacy/copyDiff.d.ts +2 -0
- package/dist/helper/legacy/copyDiff.js +33 -0
- package/dist/helper/legacy/createFakeWorker.d.ts +13 -0
- package/dist/helper/legacy/createFakeWorker.js +80 -0
- package/dist/helper/legacy/createLazyTestEnv.d.ts +10 -0
- package/dist/helper/legacy/createLazyTestEnv.js +116 -0
- package/dist/helper/legacy/createLogger.d.ts +23 -0
- package/dist/helper/legacy/createLogger.js +20 -0
- package/dist/helper/legacy/currentScript.d.ts +6 -0
- package/dist/helper/legacy/currentScript.js +8 -0
- package/dist/helper/legacy/fakeSystem.d.ts +9 -0
- package/dist/helper/legacy/fakeSystem.js +124 -0
- package/dist/helper/legacy/parseResource.d.ts +6 -0
- package/dist/helper/legacy/parseResource.js +15 -0
- package/dist/helper/legacy/supportsImportFn.d.ts +1 -0
- package/dist/helper/legacy/supportsImportFn.js +15 -0
- package/dist/helper/legacy/supportsWorker.d.ts +2 -0
- package/dist/helper/legacy/supportsWorker.js +17 -0
- package/dist/helper/legacy/urlToRelativePath.d.ts +2 -0
- package/dist/helper/legacy/urlToRelativePath.js +7 -0
- package/dist/helper/legacy/walkCssTokens.d.ts +40 -0
- package/dist/helper/legacy/walkCssTokens.js +761 -0
- package/dist/helper/legacy/warmup-webpack.d.ts +1 -0
- package/dist/helper/legacy/warmup-webpack.js +26 -0
- package/dist/helper/loaders/hot-update.d.ts +1 -0
- package/dist/helper/loaders/hot-update.js +40 -0
- package/dist/helper/parse-modules.d.ts +7 -0
- package/dist/helper/parse-modules.js +73 -0
- package/dist/helper/plugins/hot-update.d.ts +7 -0
- package/dist/helper/plugins/hot-update.js +40 -0
- package/dist/helper/plugins/index.d.ts +1 -0
- package/dist/helper/plugins/index.js +17 -0
- package/dist/helper/read-config-file.d.ts +2 -0
- package/dist/helper/read-config-file.js +13 -0
- package/dist/helper/serializers.d.ts +2 -0
- package/dist/helper/serializers.js +52 -0
- package/dist/helper/setup-env.d.ts +1 -0
- package/dist/helper/setup-env.js +80 -0
- package/dist/helper/setup-expect.d.ts +1 -0
- package/dist/helper/setup-expect.js +16 -0
- package/dist/helper/update-snapshot.d.ts +1 -0
- package/dist/helper/update-snapshot.js +6 -0
- package/dist/helper/util/checkSourceMap.d.ts +1 -0
- package/dist/helper/util/checkSourceMap.js +96 -0
- package/dist/helper/util/checkStats.d.ts +2 -0
- package/dist/helper/util/checkStats.js +43 -0
- package/dist/helper/util/currentWatchStep.d.ts +1 -0
- package/dist/helper/util/currentWatchStep.js +2 -0
- package/dist/helper/util/expectWarningFactory.d.ts +2 -0
- package/dist/helper/util/expectWarningFactory.js +21 -0
- package/dist/helper/util/filterUtil.d.ts +8 -0
- package/dist/helper/util/filterUtil.js +50 -0
- package/dist/helper/util/identifier.d.ts +76 -0
- package/dist/helper/util/identifier.js +339 -0
- package/dist/helper/util/replaceMitteDiagnostic.d.ts +2 -0
- package/dist/helper/util/replaceMitteDiagnostic.js +17 -0
- package/dist/helper/win.d.ts +1 -0
- package/dist/helper/win.js +10 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +28 -0
- package/dist/plugin/index.d.ts +4 -0
- package/dist/plugin/index.js +20 -0
- package/dist/plugin/lazy-compilation-test-plugin.d.ts +4 -0
- package/dist/plugin/lazy-compilation-test-plugin.js +67 -0
- package/dist/plugin/rspack-diff-config-plugin.d.ts +7 -0
- package/dist/plugin/rspack-diff-config-plugin.js +42 -0
- package/dist/plugin/webpack-diff-config-plugin.d.ts +7 -0
- package/dist/plugin/webpack-diff-config-plugin.js +41 -0
- package/dist/plugin/webpack-module-placeholder-plugin.d.ts +3 -0
- package/dist/plugin/webpack-module-placeholder-plugin.js +107 -0
- package/dist/processor/basic.d.ts +24 -0
- package/dist/processor/basic.js +146 -0
- package/dist/processor/builtin.d.ts +9 -0
- package/dist/processor/builtin.js +171 -0
- package/dist/processor/cache.d.ts +20 -0
- package/dist/processor/cache.js +127 -0
- package/dist/processor/config.d.ts +11 -0
- package/dist/processor/config.js +81 -0
- package/dist/processor/defaults.d.ts +30 -0
- package/dist/processor/defaults.js +72 -0
- package/dist/processor/diagnostic.d.ts +15 -0
- package/dist/processor/diagnostic.js +102 -0
- package/dist/processor/diff.d.ts +30 -0
- package/dist/processor/diff.js +140 -0
- package/dist/processor/error.d.ts +23 -0
- package/dist/processor/error.js +95 -0
- package/dist/processor/hash.d.ts +10 -0
- package/dist/processor/hash.js +63 -0
- package/dist/processor/hook.d.ts +44 -0
- package/dist/processor/hook.js +204 -0
- package/dist/processor/hot-new-incremental.d.ts +14 -0
- package/dist/processor/hot-new-incremental.js +43 -0
- package/dist/processor/hot-step.d.ts +18 -0
- package/dist/processor/hot-step.js +299 -0
- package/dist/processor/hot.d.ts +17 -0
- package/dist/processor/hot.js +138 -0
- package/dist/processor/index.d.ts +20 -0
- package/dist/processor/index.js +36 -0
- package/dist/processor/multi.d.ts +17 -0
- package/dist/processor/multi.js +73 -0
- package/dist/processor/normal.d.ts +12 -0
- package/dist/processor/normal.js +150 -0
- package/dist/processor/simple.d.ts +23 -0
- package/dist/processor/simple.js +49 -0
- package/dist/processor/snapshot.d.ts +12 -0
- package/dist/processor/snapshot.js +62 -0
- package/dist/processor/stats-api.d.ts +18 -0
- package/dist/processor/stats-api.js +48 -0
- package/dist/processor/stats.d.ts +18 -0
- package/dist/processor/stats.js +206 -0
- package/dist/processor/treeshaking.d.ts +10 -0
- package/dist/processor/treeshaking.js +33 -0
- package/dist/processor/watch.d.ts +29 -0
- package/dist/processor/watch.js +234 -0
- package/dist/reporter/diff-html.d.ts +15 -0
- package/dist/reporter/diff-html.js +69 -0
- package/dist/reporter/diff-stats.d.ts +24 -0
- package/dist/reporter/diff-stats.js +131 -0
- package/dist/reporter/index.d.ts +2 -0
- package/dist/reporter/index.js +18 -0
- package/dist/runner/basic.d.ts +10 -0
- package/dist/runner/basic.js +63 -0
- package/dist/runner/cache.d.ts +5 -0
- package/dist/runner/cache.js +90 -0
- package/dist/runner/hot-step.d.ts +5 -0
- package/dist/runner/hot-step.js +87 -0
- package/dist/runner/hot.d.ts +5 -0
- package/dist/runner/hot.js +83 -0
- package/dist/runner/index.d.ts +9 -0
- package/dist/runner/index.js +25 -0
- package/dist/runner/multiple.d.ts +11 -0
- package/dist/runner/multiple.js +38 -0
- package/dist/runner/normal.d.ts +5 -0
- package/dist/runner/normal.js +20 -0
- package/dist/runner/runner/basic.d.ts +30 -0
- package/dist/runner/runner/basic.js +107 -0
- package/dist/runner/runner/cjs.d.ts +14 -0
- package/dist/runner/runner/cjs.js +151 -0
- package/dist/runner/runner/esm.d.ts +7 -0
- package/dist/runner/runner/esm.js +125 -0
- package/dist/runner/runner/index.d.ts +8 -0
- package/dist/runner/runner/index.js +24 -0
- package/dist/runner/runner/normal.d.ts +9 -0
- package/dist/runner/runner/normal.js +23 -0
- package/dist/runner/runner/watch.d.ts +16 -0
- package/dist/runner/runner/watch.js +27 -0
- package/dist/runner/runner/web/fake.d.ts +18 -0
- package/dist/runner/runner/web/fake.js +143 -0
- package/dist/runner/runner/web/jsdom.d.ts +26 -0
- package/dist/runner/runner/web/jsdom.js +219 -0
- package/dist/runner/runner/web.d.ts +15 -0
- package/dist/runner/runner/web.js +32 -0
- package/dist/runner/type.d.ts +42 -0
- package/dist/runner/type.js +9 -0
- package/dist/runner/watch.d.ts +7 -0
- package/dist/runner/watch.js +60 -0
- package/dist/test/context.d.ts +26 -0
- package/dist/test/context.js +108 -0
- package/dist/test/creator.d.ts +46 -0
- package/dist/test/creator.js +310 -0
- package/dist/test/simple.d.ts +5 -0
- package/dist/test/simple.js +43 -0
- package/dist/test/tester.d.ts +17 -0
- package/dist/test/tester.js +88 -0
- package/dist/type.d.ts +168 -0
- package/dist/type.js +22 -0
- package/jest.d.ts +25 -0
- package/package.json +116 -0
- package/template/diff.bundle.css +1 -0
- package/template/diff.bundle.js +144 -0
- package/template/diff.html +14 -0
- package/template/editor.worker.js +1 -0
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// @ts-nocheck
|
|
3
|
+
module.exports = (globalTimeout = 2000, nameSuffix = "") => {
|
|
4
|
+
const state = global.JEST_STATE_SYMBOL;
|
|
5
|
+
let currentDescribeBlock;
|
|
6
|
+
let currentlyRunningTest;
|
|
7
|
+
let runTests = -1;
|
|
8
|
+
const disposables = [];
|
|
9
|
+
// this function allows to release memory in fn context
|
|
10
|
+
// manually, usually after the suite has been run.
|
|
11
|
+
const createDisposableFn = (fn, isTest) => {
|
|
12
|
+
if (!fn)
|
|
13
|
+
return null;
|
|
14
|
+
let rfn;
|
|
15
|
+
if (fn.length >= 1) {
|
|
16
|
+
rfn = done => {
|
|
17
|
+
fn((...args) => {
|
|
18
|
+
if (isTest)
|
|
19
|
+
runTests++;
|
|
20
|
+
done(...args);
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
rfn = () => {
|
|
26
|
+
const r = fn();
|
|
27
|
+
if (isTest)
|
|
28
|
+
runTests++;
|
|
29
|
+
return r;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
disposables.push(() => {
|
|
33
|
+
fn = null;
|
|
34
|
+
});
|
|
35
|
+
return rfn;
|
|
36
|
+
};
|
|
37
|
+
describe(nameSuffix ? `exported tests ${nameSuffix}` : "exported tests", () => {
|
|
38
|
+
// this must have a child to be handled correctly
|
|
39
|
+
it("should run the exported tests", () => {
|
|
40
|
+
runTests++;
|
|
41
|
+
});
|
|
42
|
+
afterAll(done => {
|
|
43
|
+
for (const dispose of disposables) {
|
|
44
|
+
dispose();
|
|
45
|
+
}
|
|
46
|
+
done();
|
|
47
|
+
});
|
|
48
|
+
currentDescribeBlock = state.currentDescribeBlock;
|
|
49
|
+
currentlyRunningTest = state.currentlyRunningTest;
|
|
50
|
+
});
|
|
51
|
+
let numberOfTests = 0;
|
|
52
|
+
const inSuite = fn => {
|
|
53
|
+
const { currentDescribeBlock: oldCurrentDescribeBlock, currentlyRunningTest: oldCurrentlyRunningTest, hasStarted: oldHasStarted } = state;
|
|
54
|
+
state.currentDescribeBlock = currentDescribeBlock;
|
|
55
|
+
state.currentlyRunningTest = currentlyRunningTest;
|
|
56
|
+
state.hasStarted = false;
|
|
57
|
+
try {
|
|
58
|
+
fn();
|
|
59
|
+
}
|
|
60
|
+
catch (e) {
|
|
61
|
+
// avoid leaking memory
|
|
62
|
+
e.stack;
|
|
63
|
+
throw e;
|
|
64
|
+
}
|
|
65
|
+
state.currentDescribeBlock = oldCurrentDescribeBlock;
|
|
66
|
+
state.currentlyRunningTest = oldCurrentlyRunningTest;
|
|
67
|
+
state.hasStarted = oldHasStarted;
|
|
68
|
+
};
|
|
69
|
+
const fixAsyncError = block => {
|
|
70
|
+
// By default jest leaks memory as it stores asyncError
|
|
71
|
+
// for each "it" call to track the origin test suite
|
|
72
|
+
// We want to evaluate this early here to avoid leaking memory
|
|
73
|
+
block.asyncError = {
|
|
74
|
+
stack: block.asyncError.stack
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
return {
|
|
78
|
+
setDefaultTimeout(time) {
|
|
79
|
+
globalTimeout = time;
|
|
80
|
+
},
|
|
81
|
+
getNumberOfTests() {
|
|
82
|
+
return numberOfTests;
|
|
83
|
+
},
|
|
84
|
+
it(...args) {
|
|
85
|
+
numberOfTests++;
|
|
86
|
+
if (runTests >= numberOfTests)
|
|
87
|
+
throw new Error("it called too late");
|
|
88
|
+
args[1] = createDisposableFn(args[1], true);
|
|
89
|
+
args[2] = args[2] || globalTimeout;
|
|
90
|
+
inSuite(() => {
|
|
91
|
+
it(...args);
|
|
92
|
+
fixAsyncError(currentDescribeBlock.tests[currentDescribeBlock.tests.length - 1]);
|
|
93
|
+
});
|
|
94
|
+
},
|
|
95
|
+
beforeEach(...args) {
|
|
96
|
+
if (runTests >= numberOfTests)
|
|
97
|
+
throw new Error("beforeEach called too late");
|
|
98
|
+
args[0] = createDisposableFn(args[0]);
|
|
99
|
+
inSuite(() => {
|
|
100
|
+
beforeEach(...args);
|
|
101
|
+
fixAsyncError(currentDescribeBlock.hooks[currentDescribeBlock.hooks.length - 1]);
|
|
102
|
+
});
|
|
103
|
+
},
|
|
104
|
+
afterEach(...args) {
|
|
105
|
+
if (runTests >= numberOfTests)
|
|
106
|
+
throw new Error("afterEach called too late");
|
|
107
|
+
args[0] = createDisposableFn(args[0]);
|
|
108
|
+
inSuite(() => {
|
|
109
|
+
afterEach(...args);
|
|
110
|
+
fixAsyncError(currentDescribeBlock.hooks[currentDescribeBlock.hooks.length - 1]);
|
|
111
|
+
});
|
|
112
|
+
},
|
|
113
|
+
expect,
|
|
114
|
+
jest
|
|
115
|
+
};
|
|
116
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
declare function _exports(appendTarget: any): {
|
|
2
|
+
log: (l: any) => any;
|
|
3
|
+
debug: (l: any) => any;
|
|
4
|
+
trace: (l: any) => any;
|
|
5
|
+
info: (l: any) => any;
|
|
6
|
+
warn: {
|
|
7
|
+
(...data: any[]): void;
|
|
8
|
+
(message?: any, ...optionalParams: any[]): void;
|
|
9
|
+
};
|
|
10
|
+
error: {
|
|
11
|
+
(...data: any[]): void;
|
|
12
|
+
(message?: any, ...optionalParams: any[]): void;
|
|
13
|
+
};
|
|
14
|
+
logTime: () => void;
|
|
15
|
+
group: () => void;
|
|
16
|
+
groupCollapsed: () => void;
|
|
17
|
+
groupEnd: () => void;
|
|
18
|
+
profile: () => void;
|
|
19
|
+
profileEnd: () => void;
|
|
20
|
+
clear: () => void;
|
|
21
|
+
status: () => void;
|
|
22
|
+
};
|
|
23
|
+
export = _exports;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// @ts-nocheck
|
|
3
|
+
module.exports = appendTarget => {
|
|
4
|
+
return {
|
|
5
|
+
log: l => appendTarget.push(l),
|
|
6
|
+
debug: l => appendTarget.push(l),
|
|
7
|
+
trace: l => appendTarget.push(l),
|
|
8
|
+
info: l => appendTarget.push(l),
|
|
9
|
+
warn: console.warn.bind(console),
|
|
10
|
+
error: console.error.bind(console),
|
|
11
|
+
logTime: () => { },
|
|
12
|
+
group: () => { },
|
|
13
|
+
groupCollapsed: () => { },
|
|
14
|
+
groupEnd: () => { },
|
|
15
|
+
profile: () => { },
|
|
16
|
+
profileEnd: () => { },
|
|
17
|
+
clear: () => { },
|
|
18
|
+
status: () => { }
|
|
19
|
+
};
|
|
20
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export function register(name: any, deps: any, fn: any): void;
|
|
2
|
+
export function set(name: any, exports: any): void;
|
|
3
|
+
export let registry: undefined;
|
|
4
|
+
export let _require: undefined;
|
|
5
|
+
export let _nextName: string;
|
|
6
|
+
export function setRequire(req: any): void;
|
|
7
|
+
export function init(modules: any): void;
|
|
8
|
+
export function execute(name: any): any;
|
|
9
|
+
export function ensureExecuted(name: any): any;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// @ts-nocheck
|
|
3
|
+
const System = {
|
|
4
|
+
register: (name, deps, fn) => {
|
|
5
|
+
if (!System.registry) {
|
|
6
|
+
throw new Error("System is no initialized");
|
|
7
|
+
}
|
|
8
|
+
if (typeof name !== "string") {
|
|
9
|
+
fn = deps;
|
|
10
|
+
deps = name;
|
|
11
|
+
name = System._nextName;
|
|
12
|
+
}
|
|
13
|
+
if (!Array.isArray(deps)) {
|
|
14
|
+
fn = deps;
|
|
15
|
+
deps = [];
|
|
16
|
+
}
|
|
17
|
+
const dynamicExport = result => {
|
|
18
|
+
if (System.registry[name] !== entry) {
|
|
19
|
+
throw new Error(`Module ${name} calls dynamicExport too late`);
|
|
20
|
+
}
|
|
21
|
+
entry.exports = result;
|
|
22
|
+
for (const mod of Object.keys(System.registry)) {
|
|
23
|
+
const m = System.registry[mod];
|
|
24
|
+
if (!m.deps)
|
|
25
|
+
continue;
|
|
26
|
+
for (let i = 0; i < m.deps.length; i++) {
|
|
27
|
+
const dep = m.deps[i];
|
|
28
|
+
if (dep !== name)
|
|
29
|
+
continue;
|
|
30
|
+
const setters = m.mod.setters[i];
|
|
31
|
+
setters(result);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
const systemContext = {
|
|
36
|
+
meta: {
|
|
37
|
+
url: `/${name}.js`
|
|
38
|
+
},
|
|
39
|
+
import() {
|
|
40
|
+
return Promise.resolve();
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
if (name in System.registry) {
|
|
44
|
+
throw new Error(`Module ${name} is already registered`);
|
|
45
|
+
}
|
|
46
|
+
const mod = fn(dynamicExport, systemContext);
|
|
47
|
+
if (deps.length > 0) {
|
|
48
|
+
if (!Array.isArray(mod.setters)) {
|
|
49
|
+
throw new Error(`Module ${name} must have setters, because it has dependencies`);
|
|
50
|
+
}
|
|
51
|
+
if (mod.setters.length !== deps.length) {
|
|
52
|
+
throw new Error(`Module ${name} has incorrect number of setters for the dependencies`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
const entry = {
|
|
56
|
+
name,
|
|
57
|
+
deps,
|
|
58
|
+
fn,
|
|
59
|
+
mod,
|
|
60
|
+
executed: false,
|
|
61
|
+
exports: undefined
|
|
62
|
+
};
|
|
63
|
+
System.registry[name] = entry;
|
|
64
|
+
},
|
|
65
|
+
set: (name, exports) => {
|
|
66
|
+
System.registry[name] = {
|
|
67
|
+
name,
|
|
68
|
+
executed: true,
|
|
69
|
+
exports
|
|
70
|
+
};
|
|
71
|
+
},
|
|
72
|
+
registry: undefined,
|
|
73
|
+
_require: undefined,
|
|
74
|
+
_nextName: "(anonym)",
|
|
75
|
+
setRequire: req => {
|
|
76
|
+
System._require = req;
|
|
77
|
+
},
|
|
78
|
+
init: modules => {
|
|
79
|
+
System.registry = {};
|
|
80
|
+
if (modules) {
|
|
81
|
+
for (const name of Object.keys(modules)) {
|
|
82
|
+
System.registry[name] = {
|
|
83
|
+
executed: true,
|
|
84
|
+
exports: modules[name]
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
execute: name => {
|
|
90
|
+
const m = System.registry[name];
|
|
91
|
+
if (!m)
|
|
92
|
+
throw new Error(`Module ${name} not registered`);
|
|
93
|
+
if (m.executed)
|
|
94
|
+
throw new Error(`Module ${name} was already executed`);
|
|
95
|
+
return System.ensureExecuted(name);
|
|
96
|
+
},
|
|
97
|
+
ensureExecuted: name => {
|
|
98
|
+
let m = System.registry[name];
|
|
99
|
+
if (!m && System._require) {
|
|
100
|
+
const oldName = System._nextName;
|
|
101
|
+
System._nextName = name;
|
|
102
|
+
System._require(name);
|
|
103
|
+
System._nextName = oldName;
|
|
104
|
+
m = System.registry[name];
|
|
105
|
+
}
|
|
106
|
+
if (!m) {
|
|
107
|
+
throw new Error(`Module ${name} not registered`);
|
|
108
|
+
}
|
|
109
|
+
if (!m.executed) {
|
|
110
|
+
m.executed = true;
|
|
111
|
+
for (let i = 0; i < m.deps.length; i++) {
|
|
112
|
+
const dep = m.deps[i];
|
|
113
|
+
const setters = m.mod.setters[i];
|
|
114
|
+
System.ensureExecuted(dep);
|
|
115
|
+
const { exports } = System.registry[dep];
|
|
116
|
+
if (exports !== undefined)
|
|
117
|
+
setters(exports);
|
|
118
|
+
}
|
|
119
|
+
m.mod.execute();
|
|
120
|
+
}
|
|
121
|
+
return m.exports;
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
module.exports = System;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// @ts-nocheck
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.parseResource = void 0;
|
|
5
|
+
const PATH_QUERY_FRAGMENT_REGEXP = /^((?:\u200b.|[^?#\u200b])*)(\?(?:\u200b.|[^#\u200b])*)?(#.*)?$/;
|
|
6
|
+
const parseResource = str => {
|
|
7
|
+
const match = PATH_QUERY_FRAGMENT_REGEXP.exec(str);
|
|
8
|
+
return {
|
|
9
|
+
resource: str,
|
|
10
|
+
path: match[1].replace(/\u200b(.)/g, "$1"),
|
|
11
|
+
query: match[2] ? match[2].replace(/\u200b(.)/g, "$1") : "",
|
|
12
|
+
fragment: match[3] || ""
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
exports.parseResource = parseResource;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function supportsImportFn(): boolean;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.supportsImportFn = supportsImportFn;
|
|
4
|
+
// @ts-nocheck
|
|
5
|
+
const nodeVersion = process.versions.node.split(".").map(Number);
|
|
6
|
+
function supportsImportFn() {
|
|
7
|
+
// Segmentation fault in vm with --experimental-vm-modules,
|
|
8
|
+
// which has not been resolved in node 16 yet.
|
|
9
|
+
// https://github.com/nodejs/node/issues/35889
|
|
10
|
+
if (nodeVersion[0] > 16) {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// @ts-nocheck
|
|
3
|
+
const nodeVersion = process.versions.node.split(".").map(Number);
|
|
4
|
+
module.exports = function supportsWorker() {
|
|
5
|
+
// Verify that in the current node version new Worker() accepts URL as the first parameter:
|
|
6
|
+
// https://nodejs.org/api/worker_threads.html#worker_threads_new_worker_filename_options
|
|
7
|
+
if (nodeVersion[0] >= 14) {
|
|
8
|
+
return true;
|
|
9
|
+
}
|
|
10
|
+
if (nodeVersion[0] === 13 && nodeVersion[1] >= 12) {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
if (nodeVersion[0] === 12 && nodeVersion[1] >= 17) {
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
return false;
|
|
17
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
declare namespace _exports {
|
|
2
|
+
export { CssTokenCallbacks, CharHandler };
|
|
3
|
+
}
|
|
4
|
+
declare function _exports(input: string, callbacks: CssTokenCallbacks): void;
|
|
5
|
+
declare namespace _exports {
|
|
6
|
+
export { isIdentStartCodePoint };
|
|
7
|
+
export function eatComments(input: string, pos: number): number;
|
|
8
|
+
export function eatWhitespace(input: string, pos: number): number;
|
|
9
|
+
export function eatWhitespaceAndComments(input: string, pos: number): number;
|
|
10
|
+
export function eatWhiteLine(input: string, pos: number): number;
|
|
11
|
+
}
|
|
12
|
+
export = _exports;
|
|
13
|
+
type CssTokenCallbacks = {
|
|
14
|
+
isSelector?: ((arg0: string, arg1: number) => boolean) | undefined;
|
|
15
|
+
url?: ((arg0: string, arg1: number, arg2: number, arg3: number, arg4: number) => number) | undefined;
|
|
16
|
+
string?: ((arg0: string, arg1: number, arg2: number) => number) | undefined;
|
|
17
|
+
leftParenthesis?: ((arg0: string, arg1: number, arg2: number) => number) | undefined;
|
|
18
|
+
rightParenthesis?: ((arg0: string, arg1: number, arg2: number) => number) | undefined;
|
|
19
|
+
pseudoFunction?: ((arg0: string, arg1: number, arg2: number) => number) | undefined;
|
|
20
|
+
function?: ((arg0: string, arg1: number, arg2: number) => number) | undefined;
|
|
21
|
+
pseudoClass?: ((arg0: string, arg1: number, arg2: number) => number) | undefined;
|
|
22
|
+
atKeyword?: ((arg0: string, arg1: number, arg2: number) => number) | undefined;
|
|
23
|
+
class?: ((arg0: string, arg1: number, arg2: number) => number) | undefined;
|
|
24
|
+
identifier?: ((arg0: string, arg1: number, arg2: number) => number) | undefined;
|
|
25
|
+
id?: ((arg0: string, arg1: number, arg2: number) => number) | undefined;
|
|
26
|
+
leftCurlyBracket?: ((arg0: string, arg1: number, arg2: number) => number) | undefined;
|
|
27
|
+
rightCurlyBracket?: ((arg0: string, arg1: number, arg2: number) => number) | undefined;
|
|
28
|
+
semicolon?: ((arg0: string, arg1: number, arg2: number) => number) | undefined;
|
|
29
|
+
comma?: ((arg0: string, arg1: number, arg2: number) => number) | undefined;
|
|
30
|
+
};
|
|
31
|
+
type CharHandler = (arg0: string, arg1: number, arg2: CssTokenCallbacks) => number;
|
|
32
|
+
/**
|
|
33
|
+
* ident-start code point
|
|
34
|
+
*
|
|
35
|
+
* A letter, a non-ASCII code point, or U+005F LOW LINE (_).
|
|
36
|
+
*
|
|
37
|
+
* @param {number} cc char code
|
|
38
|
+
* @returns {boolean} true, if cc is a start code point of an identifier
|
|
39
|
+
*/
|
|
40
|
+
declare function isIdentStartCodePoint(cc: number): boolean;
|