es-module-shims 2.6.0 → 2.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/README.md +6 -5
- package/dist/es-module-shims.debug.js +163 -161
- package/dist/es-module-shims.js +162 -160
- package/dist/es-module-shims.wasm.js +162 -160
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -14,6 +14,7 @@ The following modules features are polyfilled:
|
|
|
14
14
|
* [Import defer](#import-defer) via syntax stripping to allow usage in modern browsers with a polyfill fallback, when enabled.
|
|
15
15
|
* [TypeScript](#typescript-type-stripping) type stripping.
|
|
16
16
|
* [Hot Reloading](#hot-reloading) with a Vite-style `import.meta.hot` API.
|
|
17
|
+
* [Loader Hooks](#hooks) custom loader hooks for customizing module resolution and sources, including support for [virtual module sources](#source-hook).
|
|
17
18
|
|
|
18
19
|
When running in shim mode, module rewriting is applied for all users and custom [resolve](#resolve-hook) and [fetch](#fetch-hook) hooks can be implemented allowing for custom resolution and streaming in-browser transform workflows.
|
|
19
20
|
|
|
@@ -30,7 +31,7 @@ Because we are still using the native module loader the edge cases work out comp
|
|
|
30
31
|
Include ES Module Shims with a `async` attribute on the script, then include an import map and module scripts normally:
|
|
31
32
|
|
|
32
33
|
```html
|
|
33
|
-
<script async src="https://ga.jspm.io/npm:es-module-shims@2.6.
|
|
34
|
+
<script async src="https://ga.jspm.io/npm:es-module-shims@2.6.1/dist/es-module-shims.js"></script>
|
|
34
35
|
|
|
35
36
|
<!-- https://generator.jspm.io/#U2NhYGBkDM0rySzJSU1hKEpNTC5xMLTQM9Az0C1K1jMAAKFS5w0gAA -->
|
|
36
37
|
<script type="importmap">
|
|
@@ -215,7 +216,7 @@ Shim mode is an alternative to polyfill mode and doesn't rely on native modules
|
|
|
215
216
|
|
|
216
217
|
In shim mode, only the above `importmap-shim` and `module-shim` tags will be parsed and executed by ES Module Shims.
|
|
217
218
|
|
|
218
|
-
Shim mode also provides some additional features that aren't yet natively supported such as
|
|
219
|
+
Shim mode also provides some additional features that aren't yet natively supported such as [external import maps](#external-import-maps) with a `"src"` attribute and [reading current import map state](#reading-current-import-map-state), which can be useful in certain applications.
|
|
219
220
|
|
|
220
221
|
## Benchmarks
|
|
221
222
|
|
|
@@ -231,7 +232,7 @@ Benchmark summary:
|
|
|
231
232
|
|
|
232
233
|
### Browser Support
|
|
233
234
|
|
|
234
|
-
Works in all browsers with [
|
|
235
|
+
Works in all browsers with [ES module dynamic import support](https://caniuse.com/es6-module-dynamic-import).
|
|
235
236
|
|
|
236
237
|
Browser Compatibility on baseline ES modules support **with** ES Module Shims:
|
|
237
238
|
|
|
@@ -252,8 +253,8 @@ Browser compatibility **without** ES Module Shims:
|
|
|
252
253
|
| --------------------------------------------- | ------------------ | ------------------ | ------------------ |
|
|
253
254
|
| [modulepreload](#modulepreload) | 66+ | 115+ | 17.5+ |
|
|
254
255
|
| [Import Maps](#import-maps) | 89+ | 108+ | 16.4+ |
|
|
255
|
-
| [Import Map Integrity](#import-map-integrity) | 127+ |
|
|
256
|
-
| [Multiple Import Maps](#multiple-import-maps) | 135+ | :x: |
|
|
256
|
+
| [Import Map Integrity](#import-map-integrity) | 127+ | 138+ | 18+ |
|
|
257
|
+
| [Multiple Import Maps](#multiple-import-maps) | 135+ | :x: | 18.4+ |
|
|
257
258
|
| [JSON Modules](#json-modules) | 123+ | :x: | 17.2+ |
|
|
258
259
|
| [CSS Modules](#css-modules) | 123+ | :x: | :x: |
|
|
259
260
|
| [Wasm Modules](#wasm-modules) | Pending | :x: | :x: |
|
|
@@ -1,162 +1,162 @@
|
|
|
1
|
-
/** ES Module Shims @version 2.6.
|
|
1
|
+
/** ES Module Shims @version 2.6.1 */
|
|
2
2
|
(function () {
|
|
3
3
|
|
|
4
|
-
let invalidate;
|
|
5
|
-
const hotReload$1 = url => invalidate(new URL(url, baseUrl).href);
|
|
6
|
-
const initHotReload = () => {
|
|
7
|
-
let _importHook = importHook,
|
|
8
|
-
_resolveHook = resolveHook,
|
|
9
|
-
_metaHook = metaHook;
|
|
10
|
-
|
|
11
|
-
let defaultResolve;
|
|
12
|
-
let hotResolveHook = (id, parent, _defaultResolve) => {
|
|
13
|
-
if (!defaultResolve) defaultResolve = _defaultResolve;
|
|
14
|
-
const originalParent = stripVersion(parent);
|
|
15
|
-
const url = stripVersion(defaultResolve(id, originalParent));
|
|
16
|
-
const hotState = getHotState(url);
|
|
17
|
-
const parents = hotState.p;
|
|
18
|
-
if (!parents.includes(originalParent)) parents.push(originalParent);
|
|
19
|
-
return toVersioned(url, hotState);
|
|
20
|
-
};
|
|
21
|
-
const hotImportHook = (url, _, __, source, sourceType) => {
|
|
22
|
-
const hotState = getHotState(url);
|
|
23
|
-
hotState.e = typeof source === 'string' ? source : true;
|
|
24
|
-
hotState.t = sourceType;
|
|
25
|
-
};
|
|
26
|
-
const hotMetaHook = (metaObj, url) => (metaObj.hot = new Hot(url));
|
|
27
|
-
|
|
28
|
-
const Hot = class Hot {
|
|
29
|
-
constructor(url) {
|
|
30
|
-
this.data = getHotState((this.url = stripVersion(url))).d;
|
|
31
|
-
}
|
|
32
|
-
accept(deps, cb) {
|
|
33
|
-
if (typeof deps === 'function') {
|
|
34
|
-
cb = deps;
|
|
35
|
-
deps = null;
|
|
36
|
-
}
|
|
37
|
-
const hotState = getHotState(this.url);
|
|
38
|
-
if (!hotState.A) return;
|
|
39
|
-
(hotState.a = hotState.a || []).push([
|
|
40
|
-
typeof deps === 'string' ? defaultResolve(deps, this.url)
|
|
41
|
-
: deps ? deps.map(d => defaultResolve(d, this.url))
|
|
42
|
-
: null,
|
|
43
|
-
cb
|
|
44
|
-
]);
|
|
45
|
-
}
|
|
46
|
-
dispose(cb) {
|
|
47
|
-
getHotState(this.url).u = cb;
|
|
48
|
-
}
|
|
49
|
-
invalidate() {
|
|
50
|
-
const hotState = getHotState(this.url);
|
|
51
|
-
hotState.a = hotState.A = null;
|
|
52
|
-
const seen = [this.url];
|
|
53
|
-
hotState.p.forEach(p => invalidate(p, this.url, seen));
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
const versionedRegEx = /\?v=\d+$/;
|
|
58
|
-
const stripVersion = url => {
|
|
59
|
-
const versionMatch = url.match(versionedRegEx);
|
|
60
|
-
return versionMatch ? url.slice(0, -versionMatch[0].length) : url;
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
const toVersioned = (url, hotState) => {
|
|
64
|
-
const { v } = hotState;
|
|
65
|
-
return url + (v ? '?v=' + v : '');
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
let hotRegistry = {},
|
|
69
|
-
curInvalidationRoots = new Set(),
|
|
70
|
-
curInvalidationInterval;
|
|
71
|
-
const getHotState = url =>
|
|
72
|
-
hotRegistry[url] ||
|
|
73
|
-
(hotRegistry[url] = {
|
|
74
|
-
// version
|
|
75
|
-
v: 0,
|
|
76
|
-
// accept list ([deps, cb] pairs)
|
|
77
|
-
a: null,
|
|
78
|
-
// accepting acceptors
|
|
79
|
-
A: true,
|
|
80
|
-
// unload callback
|
|
81
|
-
u: null,
|
|
82
|
-
// entry point or inline script source
|
|
83
|
-
e: false,
|
|
84
|
-
// hot data
|
|
85
|
-
d: {},
|
|
86
|
-
// parents
|
|
87
|
-
p: [],
|
|
88
|
-
// source type
|
|
89
|
-
t: undefined
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
invalidate = (url, fromUrl, seen = []) => {
|
|
93
|
-
const hotState = hotRegistry[url];
|
|
94
|
-
if (!hotState || seen.includes(url)) return false;
|
|
95
|
-
seen.push(url);
|
|
96
|
-
console.info(`es-module-shims: hot reload ${url}`);
|
|
97
|
-
hotState.A = false;
|
|
98
|
-
if (
|
|
99
|
-
fromUrl &&
|
|
100
|
-
hotState.a &&
|
|
101
|
-
hotState.a.some(([d]) => d && (typeof d === 'string' ? d === fromUrl : d.includes(fromUrl)))
|
|
102
|
-
) {
|
|
103
|
-
curInvalidationRoots.add(fromUrl);
|
|
104
|
-
} else {
|
|
105
|
-
if (hotState.e || hotState.a) curInvalidationRoots.add(url);
|
|
106
|
-
hotState.v++;
|
|
107
|
-
if (!hotState.a) hotState.p.forEach(p => invalidate(p, url, seen));
|
|
108
|
-
}
|
|
109
|
-
if (!curInvalidationInterval) curInvalidationInterval = setTimeout(handleInvalidations, hotReloadInterval);
|
|
110
|
-
return true;
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
const handleInvalidations = () => {
|
|
114
|
-
curInvalidationInterval = null;
|
|
115
|
-
const earlyRoots = new Set();
|
|
116
|
-
for (const root of curInvalidationRoots) {
|
|
117
|
-
const hotState = hotRegistry[root];
|
|
118
|
-
topLevelLoad(
|
|
119
|
-
toVersioned(root, hotState),
|
|
120
|
-
baseUrl,
|
|
121
|
-
defaultFetchOpts,
|
|
122
|
-
typeof hotState.e === 'string' ? hotState.e : undefined,
|
|
123
|
-
false,
|
|
124
|
-
undefined,
|
|
125
|
-
hotState.t
|
|
126
|
-
).then(m => {
|
|
127
|
-
if (hotState.a) {
|
|
128
|
-
hotState.a.forEach(([d, c]) => d === null && !earlyRoots.has(c) && c(m));
|
|
129
|
-
// unload should be the latest unload handler from the just loaded module
|
|
130
|
-
if (hotState.u) {
|
|
131
|
-
hotState.u(hotState.d);
|
|
132
|
-
hotState.u = null;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
hotState.p.forEach(p => {
|
|
136
|
-
const hotState = hotRegistry[p];
|
|
137
|
-
if (hotState && hotState.a)
|
|
138
|
-
hotState.a.forEach(
|
|
139
|
-
async ([d, c]) =>
|
|
140
|
-
d &&
|
|
141
|
-
!earlyRoots.has(c) &&
|
|
142
|
-
(typeof d === 'string' ?
|
|
143
|
-
d === root && c(m)
|
|
144
|
-
: c(await Promise.all(d.map(d => (earlyRoots.push(c), importShim(toVersioned(d, getHotState(d))))))))
|
|
145
|
-
);
|
|
146
|
-
});
|
|
147
|
-
}, throwError);
|
|
148
|
-
}
|
|
149
|
-
curInvalidationRoots = new Set();
|
|
150
|
-
};
|
|
151
|
-
|
|
152
|
-
return [
|
|
153
|
-
_importHook ? chain(_importHook, hotImportHook) : hotImportHook,
|
|
154
|
-
_resolveHook ?
|
|
155
|
-
(id, parent, defaultResolve) =>
|
|
156
|
-
hotResolveHook(id, parent, (id, parent) => _resolveHook(id, parent, defaultResolve))
|
|
157
|
-
: hotResolveHook,
|
|
158
|
-
_metaHook ? chain(_metaHook, hotMetaHook) : hotMetaHook
|
|
159
|
-
];
|
|
4
|
+
let invalidate;
|
|
5
|
+
const hotReload$1 = url => invalidate(new URL(url, baseUrl).href);
|
|
6
|
+
const initHotReload = () => {
|
|
7
|
+
let _importHook = importHook,
|
|
8
|
+
_resolveHook = resolveHook,
|
|
9
|
+
_metaHook = metaHook;
|
|
10
|
+
|
|
11
|
+
let defaultResolve;
|
|
12
|
+
let hotResolveHook = (id, parent, _defaultResolve) => {
|
|
13
|
+
if (!defaultResolve) defaultResolve = _defaultResolve;
|
|
14
|
+
const originalParent = stripVersion(parent);
|
|
15
|
+
const url = stripVersion(defaultResolve(id, originalParent));
|
|
16
|
+
const hotState = getHotState(url);
|
|
17
|
+
const parents = hotState.p;
|
|
18
|
+
if (!parents.includes(originalParent)) parents.push(originalParent);
|
|
19
|
+
return toVersioned(url, hotState);
|
|
20
|
+
};
|
|
21
|
+
const hotImportHook = (url, _, __, source, sourceType) => {
|
|
22
|
+
const hotState = getHotState(url);
|
|
23
|
+
hotState.e = typeof source === 'string' ? source : true;
|
|
24
|
+
hotState.t = sourceType;
|
|
25
|
+
};
|
|
26
|
+
const hotMetaHook = (metaObj, url) => (metaObj.hot = new Hot(url));
|
|
27
|
+
|
|
28
|
+
const Hot = class Hot {
|
|
29
|
+
constructor(url) {
|
|
30
|
+
this.data = getHotState((this.url = stripVersion(url))).d;
|
|
31
|
+
}
|
|
32
|
+
accept(deps, cb) {
|
|
33
|
+
if (typeof deps === 'function') {
|
|
34
|
+
cb = deps;
|
|
35
|
+
deps = null;
|
|
36
|
+
}
|
|
37
|
+
const hotState = getHotState(this.url);
|
|
38
|
+
if (!hotState.A) return;
|
|
39
|
+
(hotState.a = hotState.a || []).push([
|
|
40
|
+
typeof deps === 'string' ? defaultResolve(deps, this.url)
|
|
41
|
+
: deps ? deps.map(d => defaultResolve(d, this.url))
|
|
42
|
+
: null,
|
|
43
|
+
cb
|
|
44
|
+
]);
|
|
45
|
+
}
|
|
46
|
+
dispose(cb) {
|
|
47
|
+
getHotState(this.url).u = cb;
|
|
48
|
+
}
|
|
49
|
+
invalidate() {
|
|
50
|
+
const hotState = getHotState(this.url);
|
|
51
|
+
hotState.a = hotState.A = null;
|
|
52
|
+
const seen = [this.url];
|
|
53
|
+
hotState.p.forEach(p => invalidate(p, this.url, seen));
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const versionedRegEx = /\?v=\d+$/;
|
|
58
|
+
const stripVersion = url => {
|
|
59
|
+
const versionMatch = url.match(versionedRegEx);
|
|
60
|
+
return versionMatch ? url.slice(0, -versionMatch[0].length) : url;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const toVersioned = (url, hotState) => {
|
|
64
|
+
const { v } = hotState;
|
|
65
|
+
return url + (v ? '?v=' + v : '');
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
let hotRegistry = {},
|
|
69
|
+
curInvalidationRoots = new Set(),
|
|
70
|
+
curInvalidationInterval;
|
|
71
|
+
const getHotState = url =>
|
|
72
|
+
hotRegistry[url] ||
|
|
73
|
+
(hotRegistry[url] = {
|
|
74
|
+
// version
|
|
75
|
+
v: 0,
|
|
76
|
+
// accept list ([deps, cb] pairs)
|
|
77
|
+
a: null,
|
|
78
|
+
// accepting acceptors
|
|
79
|
+
A: true,
|
|
80
|
+
// unload callback
|
|
81
|
+
u: null,
|
|
82
|
+
// entry point or inline script source
|
|
83
|
+
e: false,
|
|
84
|
+
// hot data
|
|
85
|
+
d: {},
|
|
86
|
+
// parents
|
|
87
|
+
p: [],
|
|
88
|
+
// source type
|
|
89
|
+
t: undefined
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
invalidate = (url, fromUrl, seen = []) => {
|
|
93
|
+
const hotState = hotRegistry[url];
|
|
94
|
+
if (!hotState || seen.includes(url)) return false;
|
|
95
|
+
seen.push(url);
|
|
96
|
+
console.info(`es-module-shims: hot reload ${url}`);
|
|
97
|
+
hotState.A = false;
|
|
98
|
+
if (
|
|
99
|
+
fromUrl &&
|
|
100
|
+
hotState.a &&
|
|
101
|
+
hotState.a.some(([d]) => d && (typeof d === 'string' ? d === fromUrl : d.includes(fromUrl)))
|
|
102
|
+
) {
|
|
103
|
+
curInvalidationRoots.add(fromUrl);
|
|
104
|
+
} else {
|
|
105
|
+
if (hotState.e || hotState.a) curInvalidationRoots.add(url);
|
|
106
|
+
hotState.v++;
|
|
107
|
+
if (!hotState.a) hotState.p.forEach(p => invalidate(p, url, seen));
|
|
108
|
+
}
|
|
109
|
+
if (!curInvalidationInterval) curInvalidationInterval = setTimeout(handleInvalidations, hotReloadInterval);
|
|
110
|
+
return true;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
const handleInvalidations = () => {
|
|
114
|
+
curInvalidationInterval = null;
|
|
115
|
+
const earlyRoots = new Set();
|
|
116
|
+
for (const root of curInvalidationRoots) {
|
|
117
|
+
const hotState = hotRegistry[root];
|
|
118
|
+
topLevelLoad(
|
|
119
|
+
toVersioned(root, hotState),
|
|
120
|
+
baseUrl,
|
|
121
|
+
defaultFetchOpts,
|
|
122
|
+
typeof hotState.e === 'string' ? hotState.e : undefined,
|
|
123
|
+
false,
|
|
124
|
+
undefined,
|
|
125
|
+
hotState.t
|
|
126
|
+
).then(m => {
|
|
127
|
+
if (hotState.a) {
|
|
128
|
+
hotState.a.forEach(([d, c]) => d === null && !earlyRoots.has(c) && c(m));
|
|
129
|
+
// unload should be the latest unload handler from the just loaded module
|
|
130
|
+
if (hotState.u) {
|
|
131
|
+
hotState.u(hotState.d);
|
|
132
|
+
hotState.u = null;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
hotState.p.forEach(p => {
|
|
136
|
+
const hotState = hotRegistry[p];
|
|
137
|
+
if (hotState && hotState.a)
|
|
138
|
+
hotState.a.forEach(
|
|
139
|
+
async ([d, c]) =>
|
|
140
|
+
d &&
|
|
141
|
+
!earlyRoots.has(c) &&
|
|
142
|
+
(typeof d === 'string' ?
|
|
143
|
+
d === root && c(m)
|
|
144
|
+
: c(await Promise.all(d.map(d => (earlyRoots.push(c), importShim(toVersioned(d, getHotState(d))))))))
|
|
145
|
+
);
|
|
146
|
+
});
|
|
147
|
+
}, throwError);
|
|
148
|
+
}
|
|
149
|
+
curInvalidationRoots = new Set();
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
return [
|
|
153
|
+
_importHook ? chain(_importHook, hotImportHook) : hotImportHook,
|
|
154
|
+
_resolveHook ?
|
|
155
|
+
(id, parent, defaultResolve) =>
|
|
156
|
+
hotResolveHook(id, parent, (id, parent) => _resolveHook(id, parent, defaultResolve))
|
|
157
|
+
: hotResolveHook,
|
|
158
|
+
_metaHook ? chain(_metaHook, hotMetaHook) : hotMetaHook
|
|
159
|
+
];
|
|
160
160
|
};
|
|
161
161
|
|
|
162
162
|
const hasDocument = typeof document !== 'undefined';
|
|
@@ -173,7 +173,7 @@
|
|
|
173
173
|
const esmsInitOptions = optionsScript ? JSON.parse(optionsScript.innerHTML) : {};
|
|
174
174
|
Object.assign(esmsInitOptions, self.esmsInitOptions || {});
|
|
175
175
|
|
|
176
|
-
const version = "2.6.
|
|
176
|
+
const version = "2.6.1";
|
|
177
177
|
|
|
178
178
|
const r$1 = esmsInitOptions.version;
|
|
179
179
|
if (self.importShim || (r$1 && r$1 !== version)) {
|
|
@@ -275,7 +275,8 @@
|
|
|
275
275
|
const dispatchError = error => self.dispatchEvent(Object.assign(new Event('error'), { error }));
|
|
276
276
|
|
|
277
277
|
const throwError = err => {
|
|
278
|
-
(self.reportError || dispatchError)(err)
|
|
278
|
+
(self.reportError || dispatchError)(err);
|
|
279
|
+
onerror(err);
|
|
279
280
|
};
|
|
280
281
|
|
|
281
282
|
const fromParent = parent => (parent ? ` imported from ${parent}` : '');
|
|
@@ -877,7 +878,7 @@
|
|
|
877
878
|
|
|
878
879
|
const revokeObjectURLs = registryKeys => {
|
|
879
880
|
let curIdx = 0;
|
|
880
|
-
const handler = self.requestIdleCallback || self.requestAnimationFrame;
|
|
881
|
+
const handler = self.requestIdleCallback || self.requestAnimationFrame || (fn => setTimeout(fn, 0));
|
|
881
882
|
handler(cleanup);
|
|
882
883
|
function cleanup() {
|
|
883
884
|
for (const key of registryKeys.slice(curIdx, (curIdx += 100))) {
|
|
@@ -944,7 +945,8 @@
|
|
|
944
945
|
|
|
945
946
|
// once all deps have loaded we can inline the dependency resolution blobs
|
|
946
947
|
// and define this blob
|
|
947
|
-
|
|
948
|
+
resolvedSource = '';
|
|
949
|
+
lastIndex = 0;
|
|
948
950
|
|
|
949
951
|
for (const { s: start, e: end, ss: statementStart, se: statementEnd, d: dynamicImportIndex, t, a } of imports) {
|
|
950
952
|
// source phase
|
package/dist/es-module-shims.js
CHANGED
|
@@ -1,161 +1,161 @@
|
|
|
1
|
-
/** ES Module Shims @version 2.6.
|
|
1
|
+
/** ES Module Shims @version 2.6.1 */
|
|
2
2
|
(function () {
|
|
3
3
|
|
|
4
|
-
let invalidate;
|
|
5
|
-
const hotReload$1 = url => invalidate(new URL(url, baseUrl).href);
|
|
6
|
-
const initHotReload = () => {
|
|
7
|
-
let _importHook = importHook,
|
|
8
|
-
_resolveHook = resolveHook,
|
|
9
|
-
_metaHook = metaHook;
|
|
10
|
-
|
|
11
|
-
let defaultResolve;
|
|
12
|
-
let hotResolveHook = (id, parent, _defaultResolve) => {
|
|
13
|
-
if (!defaultResolve) defaultResolve = _defaultResolve;
|
|
14
|
-
const originalParent = stripVersion(parent);
|
|
15
|
-
const url = stripVersion(defaultResolve(id, originalParent));
|
|
16
|
-
const hotState = getHotState(url);
|
|
17
|
-
const parents = hotState.p;
|
|
18
|
-
if (!parents.includes(originalParent)) parents.push(originalParent);
|
|
19
|
-
return toVersioned(url, hotState);
|
|
20
|
-
};
|
|
21
|
-
const hotImportHook = (url, _, __, source, sourceType) => {
|
|
22
|
-
const hotState = getHotState(url);
|
|
23
|
-
hotState.e = typeof source === 'string' ? source : true;
|
|
24
|
-
hotState.t = sourceType;
|
|
25
|
-
};
|
|
26
|
-
const hotMetaHook = (metaObj, url) => (metaObj.hot = new Hot(url));
|
|
27
|
-
|
|
28
|
-
const Hot = class Hot {
|
|
29
|
-
constructor(url) {
|
|
30
|
-
this.data = getHotState((this.url = stripVersion(url))).d;
|
|
31
|
-
}
|
|
32
|
-
accept(deps, cb) {
|
|
33
|
-
if (typeof deps === 'function') {
|
|
34
|
-
cb = deps;
|
|
35
|
-
deps = null;
|
|
36
|
-
}
|
|
37
|
-
const hotState = getHotState(this.url);
|
|
38
|
-
if (!hotState.A) return;
|
|
39
|
-
(hotState.a = hotState.a || []).push([
|
|
40
|
-
typeof deps === 'string' ? defaultResolve(deps, this.url)
|
|
41
|
-
: deps ? deps.map(d => defaultResolve(d, this.url))
|
|
42
|
-
: null,
|
|
43
|
-
cb
|
|
44
|
-
]);
|
|
45
|
-
}
|
|
46
|
-
dispose(cb) {
|
|
47
|
-
getHotState(this.url).u = cb;
|
|
48
|
-
}
|
|
49
|
-
invalidate() {
|
|
50
|
-
const hotState = getHotState(this.url);
|
|
51
|
-
hotState.a = hotState.A = null;
|
|
52
|
-
const seen = [this.url];
|
|
53
|
-
hotState.p.forEach(p => invalidate(p, this.url, seen));
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
const versionedRegEx = /\?v=\d+$/;
|
|
58
|
-
const stripVersion = url => {
|
|
59
|
-
const versionMatch = url.match(versionedRegEx);
|
|
60
|
-
return versionMatch ? url.slice(0, -versionMatch[0].length) : url;
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
const toVersioned = (url, hotState) => {
|
|
64
|
-
const { v } = hotState;
|
|
65
|
-
return url + (v ? '?v=' + v : '');
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
let hotRegistry = {},
|
|
69
|
-
curInvalidationRoots = new Set(),
|
|
70
|
-
curInvalidationInterval;
|
|
71
|
-
const getHotState = url =>
|
|
72
|
-
hotRegistry[url] ||
|
|
73
|
-
(hotRegistry[url] = {
|
|
74
|
-
// version
|
|
75
|
-
v: 0,
|
|
76
|
-
// accept list ([deps, cb] pairs)
|
|
77
|
-
a: null,
|
|
78
|
-
// accepting acceptors
|
|
79
|
-
A: true,
|
|
80
|
-
// unload callback
|
|
81
|
-
u: null,
|
|
82
|
-
// entry point or inline script source
|
|
83
|
-
e: false,
|
|
84
|
-
// hot data
|
|
85
|
-
d: {},
|
|
86
|
-
// parents
|
|
87
|
-
p: [],
|
|
88
|
-
// source type
|
|
89
|
-
t: undefined
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
invalidate = (url, fromUrl, seen = []) => {
|
|
93
|
-
const hotState = hotRegistry[url];
|
|
94
|
-
if (!hotState || seen.includes(url)) return false;
|
|
95
|
-
seen.push(url);
|
|
96
|
-
hotState.A = false;
|
|
97
|
-
if (
|
|
98
|
-
fromUrl &&
|
|
99
|
-
hotState.a &&
|
|
100
|
-
hotState.a.some(([d]) => d && (typeof d === 'string' ? d === fromUrl : d.includes(fromUrl)))
|
|
101
|
-
) {
|
|
102
|
-
curInvalidationRoots.add(fromUrl);
|
|
103
|
-
} else {
|
|
104
|
-
if (hotState.e || hotState.a) curInvalidationRoots.add(url);
|
|
105
|
-
hotState.v++;
|
|
106
|
-
if (!hotState.a) hotState.p.forEach(p => invalidate(p, url, seen));
|
|
107
|
-
}
|
|
108
|
-
if (!curInvalidationInterval) curInvalidationInterval = setTimeout(handleInvalidations, hotReloadInterval);
|
|
109
|
-
return true;
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
const handleInvalidations = () => {
|
|
113
|
-
curInvalidationInterval = null;
|
|
114
|
-
const earlyRoots = new Set();
|
|
115
|
-
for (const root of curInvalidationRoots) {
|
|
116
|
-
const hotState = hotRegistry[root];
|
|
117
|
-
topLevelLoad(
|
|
118
|
-
toVersioned(root, hotState),
|
|
119
|
-
baseUrl,
|
|
120
|
-
defaultFetchOpts,
|
|
121
|
-
typeof hotState.e === 'string' ? hotState.e : undefined,
|
|
122
|
-
false,
|
|
123
|
-
undefined,
|
|
124
|
-
hotState.t
|
|
125
|
-
).then(m => {
|
|
126
|
-
if (hotState.a) {
|
|
127
|
-
hotState.a.forEach(([d, c]) => d === null && !earlyRoots.has(c) && c(m));
|
|
128
|
-
// unload should be the latest unload handler from the just loaded module
|
|
129
|
-
if (hotState.u) {
|
|
130
|
-
hotState.u(hotState.d);
|
|
131
|
-
hotState.u = null;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
hotState.p.forEach(p => {
|
|
135
|
-
const hotState = hotRegistry[p];
|
|
136
|
-
if (hotState && hotState.a)
|
|
137
|
-
hotState.a.forEach(
|
|
138
|
-
async ([d, c]) =>
|
|
139
|
-
d &&
|
|
140
|
-
!earlyRoots.has(c) &&
|
|
141
|
-
(typeof d === 'string' ?
|
|
142
|
-
d === root && c(m)
|
|
143
|
-
: c(await Promise.all(d.map(d => (earlyRoots.push(c), importShim(toVersioned(d, getHotState(d))))))))
|
|
144
|
-
);
|
|
145
|
-
});
|
|
146
|
-
}, throwError);
|
|
147
|
-
}
|
|
148
|
-
curInvalidationRoots = new Set();
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
return [
|
|
152
|
-
_importHook ? chain(_importHook, hotImportHook) : hotImportHook,
|
|
153
|
-
_resolveHook ?
|
|
154
|
-
(id, parent, defaultResolve) =>
|
|
155
|
-
hotResolveHook(id, parent, (id, parent) => _resolveHook(id, parent, defaultResolve))
|
|
156
|
-
: hotResolveHook,
|
|
157
|
-
_metaHook ? chain(_metaHook, hotMetaHook) : hotMetaHook
|
|
158
|
-
];
|
|
4
|
+
let invalidate;
|
|
5
|
+
const hotReload$1 = url => invalidate(new URL(url, baseUrl).href);
|
|
6
|
+
const initHotReload = () => {
|
|
7
|
+
let _importHook = importHook,
|
|
8
|
+
_resolveHook = resolveHook,
|
|
9
|
+
_metaHook = metaHook;
|
|
10
|
+
|
|
11
|
+
let defaultResolve;
|
|
12
|
+
let hotResolveHook = (id, parent, _defaultResolve) => {
|
|
13
|
+
if (!defaultResolve) defaultResolve = _defaultResolve;
|
|
14
|
+
const originalParent = stripVersion(parent);
|
|
15
|
+
const url = stripVersion(defaultResolve(id, originalParent));
|
|
16
|
+
const hotState = getHotState(url);
|
|
17
|
+
const parents = hotState.p;
|
|
18
|
+
if (!parents.includes(originalParent)) parents.push(originalParent);
|
|
19
|
+
return toVersioned(url, hotState);
|
|
20
|
+
};
|
|
21
|
+
const hotImportHook = (url, _, __, source, sourceType) => {
|
|
22
|
+
const hotState = getHotState(url);
|
|
23
|
+
hotState.e = typeof source === 'string' ? source : true;
|
|
24
|
+
hotState.t = sourceType;
|
|
25
|
+
};
|
|
26
|
+
const hotMetaHook = (metaObj, url) => (metaObj.hot = new Hot(url));
|
|
27
|
+
|
|
28
|
+
const Hot = class Hot {
|
|
29
|
+
constructor(url) {
|
|
30
|
+
this.data = getHotState((this.url = stripVersion(url))).d;
|
|
31
|
+
}
|
|
32
|
+
accept(deps, cb) {
|
|
33
|
+
if (typeof deps === 'function') {
|
|
34
|
+
cb = deps;
|
|
35
|
+
deps = null;
|
|
36
|
+
}
|
|
37
|
+
const hotState = getHotState(this.url);
|
|
38
|
+
if (!hotState.A) return;
|
|
39
|
+
(hotState.a = hotState.a || []).push([
|
|
40
|
+
typeof deps === 'string' ? defaultResolve(deps, this.url)
|
|
41
|
+
: deps ? deps.map(d => defaultResolve(d, this.url))
|
|
42
|
+
: null,
|
|
43
|
+
cb
|
|
44
|
+
]);
|
|
45
|
+
}
|
|
46
|
+
dispose(cb) {
|
|
47
|
+
getHotState(this.url).u = cb;
|
|
48
|
+
}
|
|
49
|
+
invalidate() {
|
|
50
|
+
const hotState = getHotState(this.url);
|
|
51
|
+
hotState.a = hotState.A = null;
|
|
52
|
+
const seen = [this.url];
|
|
53
|
+
hotState.p.forEach(p => invalidate(p, this.url, seen));
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const versionedRegEx = /\?v=\d+$/;
|
|
58
|
+
const stripVersion = url => {
|
|
59
|
+
const versionMatch = url.match(versionedRegEx);
|
|
60
|
+
return versionMatch ? url.slice(0, -versionMatch[0].length) : url;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const toVersioned = (url, hotState) => {
|
|
64
|
+
const { v } = hotState;
|
|
65
|
+
return url + (v ? '?v=' + v : '');
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
let hotRegistry = {},
|
|
69
|
+
curInvalidationRoots = new Set(),
|
|
70
|
+
curInvalidationInterval;
|
|
71
|
+
const getHotState = url =>
|
|
72
|
+
hotRegistry[url] ||
|
|
73
|
+
(hotRegistry[url] = {
|
|
74
|
+
// version
|
|
75
|
+
v: 0,
|
|
76
|
+
// accept list ([deps, cb] pairs)
|
|
77
|
+
a: null,
|
|
78
|
+
// accepting acceptors
|
|
79
|
+
A: true,
|
|
80
|
+
// unload callback
|
|
81
|
+
u: null,
|
|
82
|
+
// entry point or inline script source
|
|
83
|
+
e: false,
|
|
84
|
+
// hot data
|
|
85
|
+
d: {},
|
|
86
|
+
// parents
|
|
87
|
+
p: [],
|
|
88
|
+
// source type
|
|
89
|
+
t: undefined
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
invalidate = (url, fromUrl, seen = []) => {
|
|
93
|
+
const hotState = hotRegistry[url];
|
|
94
|
+
if (!hotState || seen.includes(url)) return false;
|
|
95
|
+
seen.push(url);
|
|
96
|
+
hotState.A = false;
|
|
97
|
+
if (
|
|
98
|
+
fromUrl &&
|
|
99
|
+
hotState.a &&
|
|
100
|
+
hotState.a.some(([d]) => d && (typeof d === 'string' ? d === fromUrl : d.includes(fromUrl)))
|
|
101
|
+
) {
|
|
102
|
+
curInvalidationRoots.add(fromUrl);
|
|
103
|
+
} else {
|
|
104
|
+
if (hotState.e || hotState.a) curInvalidationRoots.add(url);
|
|
105
|
+
hotState.v++;
|
|
106
|
+
if (!hotState.a) hotState.p.forEach(p => invalidate(p, url, seen));
|
|
107
|
+
}
|
|
108
|
+
if (!curInvalidationInterval) curInvalidationInterval = setTimeout(handleInvalidations, hotReloadInterval);
|
|
109
|
+
return true;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
const handleInvalidations = () => {
|
|
113
|
+
curInvalidationInterval = null;
|
|
114
|
+
const earlyRoots = new Set();
|
|
115
|
+
for (const root of curInvalidationRoots) {
|
|
116
|
+
const hotState = hotRegistry[root];
|
|
117
|
+
topLevelLoad(
|
|
118
|
+
toVersioned(root, hotState),
|
|
119
|
+
baseUrl,
|
|
120
|
+
defaultFetchOpts,
|
|
121
|
+
typeof hotState.e === 'string' ? hotState.e : undefined,
|
|
122
|
+
false,
|
|
123
|
+
undefined,
|
|
124
|
+
hotState.t
|
|
125
|
+
).then(m => {
|
|
126
|
+
if (hotState.a) {
|
|
127
|
+
hotState.a.forEach(([d, c]) => d === null && !earlyRoots.has(c) && c(m));
|
|
128
|
+
// unload should be the latest unload handler from the just loaded module
|
|
129
|
+
if (hotState.u) {
|
|
130
|
+
hotState.u(hotState.d);
|
|
131
|
+
hotState.u = null;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
hotState.p.forEach(p => {
|
|
135
|
+
const hotState = hotRegistry[p];
|
|
136
|
+
if (hotState && hotState.a)
|
|
137
|
+
hotState.a.forEach(
|
|
138
|
+
async ([d, c]) =>
|
|
139
|
+
d &&
|
|
140
|
+
!earlyRoots.has(c) &&
|
|
141
|
+
(typeof d === 'string' ?
|
|
142
|
+
d === root && c(m)
|
|
143
|
+
: c(await Promise.all(d.map(d => (earlyRoots.push(c), importShim(toVersioned(d, getHotState(d))))))))
|
|
144
|
+
);
|
|
145
|
+
});
|
|
146
|
+
}, throwError);
|
|
147
|
+
}
|
|
148
|
+
curInvalidationRoots = new Set();
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
return [
|
|
152
|
+
_importHook ? chain(_importHook, hotImportHook) : hotImportHook,
|
|
153
|
+
_resolveHook ?
|
|
154
|
+
(id, parent, defaultResolve) =>
|
|
155
|
+
hotResolveHook(id, parent, (id, parent) => _resolveHook(id, parent, defaultResolve))
|
|
156
|
+
: hotResolveHook,
|
|
157
|
+
_metaHook ? chain(_metaHook, hotMetaHook) : hotMetaHook
|
|
158
|
+
];
|
|
159
159
|
};
|
|
160
160
|
|
|
161
161
|
const hasDocument = typeof document !== 'undefined';
|
|
@@ -172,7 +172,7 @@
|
|
|
172
172
|
const esmsInitOptions = optionsScript ? JSON.parse(optionsScript.innerHTML) : {};
|
|
173
173
|
Object.assign(esmsInitOptions, self.esmsInitOptions || {});
|
|
174
174
|
|
|
175
|
-
const version = "2.6.
|
|
175
|
+
const version = "2.6.1";
|
|
176
176
|
|
|
177
177
|
const r$1 = esmsInitOptions.version;
|
|
178
178
|
if (self.importShim || (r$1 && r$1 !== version)) {
|
|
@@ -271,7 +271,8 @@
|
|
|
271
271
|
const dispatchError = error => self.dispatchEvent(Object.assign(new Event('error'), { error }));
|
|
272
272
|
|
|
273
273
|
const throwError = err => {
|
|
274
|
-
(self.reportError || dispatchError)(err)
|
|
274
|
+
(self.reportError || dispatchError)(err);
|
|
275
|
+
onerror(err);
|
|
275
276
|
};
|
|
276
277
|
|
|
277
278
|
const fromParent = parent => (parent ? ` imported from ${parent}` : '');
|
|
@@ -861,7 +862,7 @@
|
|
|
861
862
|
|
|
862
863
|
const revokeObjectURLs = registryKeys => {
|
|
863
864
|
let curIdx = 0;
|
|
864
|
-
const handler = self.requestIdleCallback || self.requestAnimationFrame;
|
|
865
|
+
const handler = self.requestIdleCallback || self.requestAnimationFrame || (fn => setTimeout(fn, 0));
|
|
865
866
|
handler(cleanup);
|
|
866
867
|
function cleanup() {
|
|
867
868
|
for (const key of registryKeys.slice(curIdx, (curIdx += 100))) {
|
|
@@ -926,7 +927,8 @@
|
|
|
926
927
|
|
|
927
928
|
// once all deps have loaded we can inline the dependency resolution blobs
|
|
928
929
|
// and define this blob
|
|
929
|
-
|
|
930
|
+
resolvedSource = '';
|
|
931
|
+
lastIndex = 0;
|
|
930
932
|
|
|
931
933
|
for (const { s: start, e: end, ss: statementStart, se: statementEnd, d: dynamicImportIndex, t, a } of imports) {
|
|
932
934
|
// source phase
|
|
@@ -1,161 +1,161 @@
|
|
|
1
|
-
/** ES Module Shims Wasm @version 2.6.
|
|
1
|
+
/** ES Module Shims Wasm @version 2.6.1 */
|
|
2
2
|
(function () {
|
|
3
3
|
|
|
4
|
-
let invalidate;
|
|
5
|
-
const hotReload$1 = url => invalidate(new URL(url, baseUrl).href);
|
|
6
|
-
const initHotReload = () => {
|
|
7
|
-
let _importHook = importHook,
|
|
8
|
-
_resolveHook = resolveHook,
|
|
9
|
-
_metaHook = metaHook;
|
|
10
|
-
|
|
11
|
-
let defaultResolve;
|
|
12
|
-
let hotResolveHook = (id, parent, _defaultResolve) => {
|
|
13
|
-
if (!defaultResolve) defaultResolve = _defaultResolve;
|
|
14
|
-
const originalParent = stripVersion(parent);
|
|
15
|
-
const url = stripVersion(defaultResolve(id, originalParent));
|
|
16
|
-
const hotState = getHotState(url);
|
|
17
|
-
const parents = hotState.p;
|
|
18
|
-
if (!parents.includes(originalParent)) parents.push(originalParent);
|
|
19
|
-
return toVersioned(url, hotState);
|
|
20
|
-
};
|
|
21
|
-
const hotImportHook = (url, _, __, source, sourceType) => {
|
|
22
|
-
const hotState = getHotState(url);
|
|
23
|
-
hotState.e = typeof source === 'string' ? source : true;
|
|
24
|
-
hotState.t = sourceType;
|
|
25
|
-
};
|
|
26
|
-
const hotMetaHook = (metaObj, url) => (metaObj.hot = new Hot(url));
|
|
27
|
-
|
|
28
|
-
const Hot = class Hot {
|
|
29
|
-
constructor(url) {
|
|
30
|
-
this.data = getHotState((this.url = stripVersion(url))).d;
|
|
31
|
-
}
|
|
32
|
-
accept(deps, cb) {
|
|
33
|
-
if (typeof deps === 'function') {
|
|
34
|
-
cb = deps;
|
|
35
|
-
deps = null;
|
|
36
|
-
}
|
|
37
|
-
const hotState = getHotState(this.url);
|
|
38
|
-
if (!hotState.A) return;
|
|
39
|
-
(hotState.a = hotState.a || []).push([
|
|
40
|
-
typeof deps === 'string' ? defaultResolve(deps, this.url)
|
|
41
|
-
: deps ? deps.map(d => defaultResolve(d, this.url))
|
|
42
|
-
: null,
|
|
43
|
-
cb
|
|
44
|
-
]);
|
|
45
|
-
}
|
|
46
|
-
dispose(cb) {
|
|
47
|
-
getHotState(this.url).u = cb;
|
|
48
|
-
}
|
|
49
|
-
invalidate() {
|
|
50
|
-
const hotState = getHotState(this.url);
|
|
51
|
-
hotState.a = hotState.A = null;
|
|
52
|
-
const seen = [this.url];
|
|
53
|
-
hotState.p.forEach(p => invalidate(p, this.url, seen));
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
const versionedRegEx = /\?v=\d+$/;
|
|
58
|
-
const stripVersion = url => {
|
|
59
|
-
const versionMatch = url.match(versionedRegEx);
|
|
60
|
-
return versionMatch ? url.slice(0, -versionMatch[0].length) : url;
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
const toVersioned = (url, hotState) => {
|
|
64
|
-
const { v } = hotState;
|
|
65
|
-
return url + (v ? '?v=' + v : '');
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
let hotRegistry = {},
|
|
69
|
-
curInvalidationRoots = new Set(),
|
|
70
|
-
curInvalidationInterval;
|
|
71
|
-
const getHotState = url =>
|
|
72
|
-
hotRegistry[url] ||
|
|
73
|
-
(hotRegistry[url] = {
|
|
74
|
-
// version
|
|
75
|
-
v: 0,
|
|
76
|
-
// accept list ([deps, cb] pairs)
|
|
77
|
-
a: null,
|
|
78
|
-
// accepting acceptors
|
|
79
|
-
A: true,
|
|
80
|
-
// unload callback
|
|
81
|
-
u: null,
|
|
82
|
-
// entry point or inline script source
|
|
83
|
-
e: false,
|
|
84
|
-
// hot data
|
|
85
|
-
d: {},
|
|
86
|
-
// parents
|
|
87
|
-
p: [],
|
|
88
|
-
// source type
|
|
89
|
-
t: undefined
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
invalidate = (url, fromUrl, seen = []) => {
|
|
93
|
-
const hotState = hotRegistry[url];
|
|
94
|
-
if (!hotState || seen.includes(url)) return false;
|
|
95
|
-
seen.push(url);
|
|
96
|
-
hotState.A = false;
|
|
97
|
-
if (
|
|
98
|
-
fromUrl &&
|
|
99
|
-
hotState.a &&
|
|
100
|
-
hotState.a.some(([d]) => d && (typeof d === 'string' ? d === fromUrl : d.includes(fromUrl)))
|
|
101
|
-
) {
|
|
102
|
-
curInvalidationRoots.add(fromUrl);
|
|
103
|
-
} else {
|
|
104
|
-
if (hotState.e || hotState.a) curInvalidationRoots.add(url);
|
|
105
|
-
hotState.v++;
|
|
106
|
-
if (!hotState.a) hotState.p.forEach(p => invalidate(p, url, seen));
|
|
107
|
-
}
|
|
108
|
-
if (!curInvalidationInterval) curInvalidationInterval = setTimeout(handleInvalidations, hotReloadInterval);
|
|
109
|
-
return true;
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
const handleInvalidations = () => {
|
|
113
|
-
curInvalidationInterval = null;
|
|
114
|
-
const earlyRoots = new Set();
|
|
115
|
-
for (const root of curInvalidationRoots) {
|
|
116
|
-
const hotState = hotRegistry[root];
|
|
117
|
-
topLevelLoad(
|
|
118
|
-
toVersioned(root, hotState),
|
|
119
|
-
baseUrl,
|
|
120
|
-
defaultFetchOpts,
|
|
121
|
-
typeof hotState.e === 'string' ? hotState.e : undefined,
|
|
122
|
-
false,
|
|
123
|
-
undefined,
|
|
124
|
-
hotState.t
|
|
125
|
-
).then(m => {
|
|
126
|
-
if (hotState.a) {
|
|
127
|
-
hotState.a.forEach(([d, c]) => d === null && !earlyRoots.has(c) && c(m));
|
|
128
|
-
// unload should be the latest unload handler from the just loaded module
|
|
129
|
-
if (hotState.u) {
|
|
130
|
-
hotState.u(hotState.d);
|
|
131
|
-
hotState.u = null;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
hotState.p.forEach(p => {
|
|
135
|
-
const hotState = hotRegistry[p];
|
|
136
|
-
if (hotState && hotState.a)
|
|
137
|
-
hotState.a.forEach(
|
|
138
|
-
async ([d, c]) =>
|
|
139
|
-
d &&
|
|
140
|
-
!earlyRoots.has(c) &&
|
|
141
|
-
(typeof d === 'string' ?
|
|
142
|
-
d === root && c(m)
|
|
143
|
-
: c(await Promise.all(d.map(d => (earlyRoots.push(c), importShim(toVersioned(d, getHotState(d))))))))
|
|
144
|
-
);
|
|
145
|
-
});
|
|
146
|
-
}, throwError);
|
|
147
|
-
}
|
|
148
|
-
curInvalidationRoots = new Set();
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
return [
|
|
152
|
-
_importHook ? chain(_importHook, hotImportHook) : hotImportHook,
|
|
153
|
-
_resolveHook ?
|
|
154
|
-
(id, parent, defaultResolve) =>
|
|
155
|
-
hotResolveHook(id, parent, (id, parent) => _resolveHook(id, parent, defaultResolve))
|
|
156
|
-
: hotResolveHook,
|
|
157
|
-
_metaHook ? chain(_metaHook, hotMetaHook) : hotMetaHook
|
|
158
|
-
];
|
|
4
|
+
let invalidate;
|
|
5
|
+
const hotReload$1 = url => invalidate(new URL(url, baseUrl).href);
|
|
6
|
+
const initHotReload = () => {
|
|
7
|
+
let _importHook = importHook,
|
|
8
|
+
_resolveHook = resolveHook,
|
|
9
|
+
_metaHook = metaHook;
|
|
10
|
+
|
|
11
|
+
let defaultResolve;
|
|
12
|
+
let hotResolveHook = (id, parent, _defaultResolve) => {
|
|
13
|
+
if (!defaultResolve) defaultResolve = _defaultResolve;
|
|
14
|
+
const originalParent = stripVersion(parent);
|
|
15
|
+
const url = stripVersion(defaultResolve(id, originalParent));
|
|
16
|
+
const hotState = getHotState(url);
|
|
17
|
+
const parents = hotState.p;
|
|
18
|
+
if (!parents.includes(originalParent)) parents.push(originalParent);
|
|
19
|
+
return toVersioned(url, hotState);
|
|
20
|
+
};
|
|
21
|
+
const hotImportHook = (url, _, __, source, sourceType) => {
|
|
22
|
+
const hotState = getHotState(url);
|
|
23
|
+
hotState.e = typeof source === 'string' ? source : true;
|
|
24
|
+
hotState.t = sourceType;
|
|
25
|
+
};
|
|
26
|
+
const hotMetaHook = (metaObj, url) => (metaObj.hot = new Hot(url));
|
|
27
|
+
|
|
28
|
+
const Hot = class Hot {
|
|
29
|
+
constructor(url) {
|
|
30
|
+
this.data = getHotState((this.url = stripVersion(url))).d;
|
|
31
|
+
}
|
|
32
|
+
accept(deps, cb) {
|
|
33
|
+
if (typeof deps === 'function') {
|
|
34
|
+
cb = deps;
|
|
35
|
+
deps = null;
|
|
36
|
+
}
|
|
37
|
+
const hotState = getHotState(this.url);
|
|
38
|
+
if (!hotState.A) return;
|
|
39
|
+
(hotState.a = hotState.a || []).push([
|
|
40
|
+
typeof deps === 'string' ? defaultResolve(deps, this.url)
|
|
41
|
+
: deps ? deps.map(d => defaultResolve(d, this.url))
|
|
42
|
+
: null,
|
|
43
|
+
cb
|
|
44
|
+
]);
|
|
45
|
+
}
|
|
46
|
+
dispose(cb) {
|
|
47
|
+
getHotState(this.url).u = cb;
|
|
48
|
+
}
|
|
49
|
+
invalidate() {
|
|
50
|
+
const hotState = getHotState(this.url);
|
|
51
|
+
hotState.a = hotState.A = null;
|
|
52
|
+
const seen = [this.url];
|
|
53
|
+
hotState.p.forEach(p => invalidate(p, this.url, seen));
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const versionedRegEx = /\?v=\d+$/;
|
|
58
|
+
const stripVersion = url => {
|
|
59
|
+
const versionMatch = url.match(versionedRegEx);
|
|
60
|
+
return versionMatch ? url.slice(0, -versionMatch[0].length) : url;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const toVersioned = (url, hotState) => {
|
|
64
|
+
const { v } = hotState;
|
|
65
|
+
return url + (v ? '?v=' + v : '');
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
let hotRegistry = {},
|
|
69
|
+
curInvalidationRoots = new Set(),
|
|
70
|
+
curInvalidationInterval;
|
|
71
|
+
const getHotState = url =>
|
|
72
|
+
hotRegistry[url] ||
|
|
73
|
+
(hotRegistry[url] = {
|
|
74
|
+
// version
|
|
75
|
+
v: 0,
|
|
76
|
+
// accept list ([deps, cb] pairs)
|
|
77
|
+
a: null,
|
|
78
|
+
// accepting acceptors
|
|
79
|
+
A: true,
|
|
80
|
+
// unload callback
|
|
81
|
+
u: null,
|
|
82
|
+
// entry point or inline script source
|
|
83
|
+
e: false,
|
|
84
|
+
// hot data
|
|
85
|
+
d: {},
|
|
86
|
+
// parents
|
|
87
|
+
p: [],
|
|
88
|
+
// source type
|
|
89
|
+
t: undefined
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
invalidate = (url, fromUrl, seen = []) => {
|
|
93
|
+
const hotState = hotRegistry[url];
|
|
94
|
+
if (!hotState || seen.includes(url)) return false;
|
|
95
|
+
seen.push(url);
|
|
96
|
+
hotState.A = false;
|
|
97
|
+
if (
|
|
98
|
+
fromUrl &&
|
|
99
|
+
hotState.a &&
|
|
100
|
+
hotState.a.some(([d]) => d && (typeof d === 'string' ? d === fromUrl : d.includes(fromUrl)))
|
|
101
|
+
) {
|
|
102
|
+
curInvalidationRoots.add(fromUrl);
|
|
103
|
+
} else {
|
|
104
|
+
if (hotState.e || hotState.a) curInvalidationRoots.add(url);
|
|
105
|
+
hotState.v++;
|
|
106
|
+
if (!hotState.a) hotState.p.forEach(p => invalidate(p, url, seen));
|
|
107
|
+
}
|
|
108
|
+
if (!curInvalidationInterval) curInvalidationInterval = setTimeout(handleInvalidations, hotReloadInterval);
|
|
109
|
+
return true;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
const handleInvalidations = () => {
|
|
113
|
+
curInvalidationInterval = null;
|
|
114
|
+
const earlyRoots = new Set();
|
|
115
|
+
for (const root of curInvalidationRoots) {
|
|
116
|
+
const hotState = hotRegistry[root];
|
|
117
|
+
topLevelLoad(
|
|
118
|
+
toVersioned(root, hotState),
|
|
119
|
+
baseUrl,
|
|
120
|
+
defaultFetchOpts,
|
|
121
|
+
typeof hotState.e === 'string' ? hotState.e : undefined,
|
|
122
|
+
false,
|
|
123
|
+
undefined,
|
|
124
|
+
hotState.t
|
|
125
|
+
).then(m => {
|
|
126
|
+
if (hotState.a) {
|
|
127
|
+
hotState.a.forEach(([d, c]) => d === null && !earlyRoots.has(c) && c(m));
|
|
128
|
+
// unload should be the latest unload handler from the just loaded module
|
|
129
|
+
if (hotState.u) {
|
|
130
|
+
hotState.u(hotState.d);
|
|
131
|
+
hotState.u = null;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
hotState.p.forEach(p => {
|
|
135
|
+
const hotState = hotRegistry[p];
|
|
136
|
+
if (hotState && hotState.a)
|
|
137
|
+
hotState.a.forEach(
|
|
138
|
+
async ([d, c]) =>
|
|
139
|
+
d &&
|
|
140
|
+
!earlyRoots.has(c) &&
|
|
141
|
+
(typeof d === 'string' ?
|
|
142
|
+
d === root && c(m)
|
|
143
|
+
: c(await Promise.all(d.map(d => (earlyRoots.push(c), importShim(toVersioned(d, getHotState(d))))))))
|
|
144
|
+
);
|
|
145
|
+
});
|
|
146
|
+
}, throwError);
|
|
147
|
+
}
|
|
148
|
+
curInvalidationRoots = new Set();
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
return [
|
|
152
|
+
_importHook ? chain(_importHook, hotImportHook) : hotImportHook,
|
|
153
|
+
_resolveHook ?
|
|
154
|
+
(id, parent, defaultResolve) =>
|
|
155
|
+
hotResolveHook(id, parent, (id, parent) => _resolveHook(id, parent, defaultResolve))
|
|
156
|
+
: hotResolveHook,
|
|
157
|
+
_metaHook ? chain(_metaHook, hotMetaHook) : hotMetaHook
|
|
158
|
+
];
|
|
159
159
|
};
|
|
160
160
|
|
|
161
161
|
const hasDocument = typeof document !== 'undefined';
|
|
@@ -172,7 +172,7 @@
|
|
|
172
172
|
const esmsInitOptions = optionsScript ? JSON.parse(optionsScript.innerHTML) : {};
|
|
173
173
|
Object.assign(esmsInitOptions, self.esmsInitOptions || {});
|
|
174
174
|
|
|
175
|
-
const version = "2.6.
|
|
175
|
+
const version = "2.6.1";
|
|
176
176
|
|
|
177
177
|
const r = esmsInitOptions.version;
|
|
178
178
|
if (self.importShim || (r && r !== version)) {
|
|
@@ -271,7 +271,8 @@
|
|
|
271
271
|
const dispatchError = error => self.dispatchEvent(Object.assign(new Event('error'), { error }));
|
|
272
272
|
|
|
273
273
|
const throwError = err => {
|
|
274
|
-
(self.reportError || dispatchError)(err)
|
|
274
|
+
(self.reportError || dispatchError)(err);
|
|
275
|
+
onerror(err);
|
|
275
276
|
};
|
|
276
277
|
|
|
277
278
|
const fromParent = parent => (parent ? ` imported from ${parent}` : '');
|
|
@@ -861,7 +862,7 @@
|
|
|
861
862
|
|
|
862
863
|
const revokeObjectURLs = registryKeys => {
|
|
863
864
|
let curIdx = 0;
|
|
864
|
-
const handler = self.requestIdleCallback || self.requestAnimationFrame;
|
|
865
|
+
const handler = self.requestIdleCallback || self.requestAnimationFrame || (fn => setTimeout(fn, 0));
|
|
865
866
|
handler(cleanup);
|
|
866
867
|
function cleanup() {
|
|
867
868
|
for (const key of registryKeys.slice(curIdx, (curIdx += 100))) {
|
|
@@ -926,7 +927,8 @@
|
|
|
926
927
|
|
|
927
928
|
// once all deps have loaded we can inline the dependency resolution blobs
|
|
928
929
|
// and define this blob
|
|
929
|
-
|
|
930
|
+
resolvedSource = '';
|
|
931
|
+
lastIndex = 0;
|
|
930
932
|
|
|
931
933
|
for (const { s: start, e: end, ss: statementStart, se: statementEnd, d: dynamicImportIndex, t, a } of imports) {
|
|
932
934
|
// source phase
|