es-module-shims 1.7.1 → 1.7.2
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
CHANGED
|
@@ -29,7 +29,7 @@ Because we are still using the native module loader the edge cases work out comp
|
|
|
29
29
|
Include ES Module Shims with a `async` attribute on the script, then include an import map and module scripts normally:
|
|
30
30
|
|
|
31
31
|
```html
|
|
32
|
-
<script async src="https://ga.jspm.io/npm:es-module-shims@1.7.
|
|
32
|
+
<script async src="https://ga.jspm.io/npm:es-module-shims@1.7.2/dist/es-module-shims.js"></script>
|
|
33
33
|
|
|
34
34
|
<!-- https://generator.jspm.io/#U2NhYGBkDM0rySzJSU1hKEpNTC5xMLTQM9Az0C1K1jMAAKFS5w0gAA -->
|
|
35
35
|
<script type="importmap">
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* ES Module Shims DEBUG BUILD 1.7.
|
|
1
|
+
/* ES Module Shims DEBUG BUILD 1.7.2 */
|
|
2
2
|
(function () {
|
|
3
3
|
|
|
4
4
|
const hasWindow = typeof window !== 'undefined';
|
|
@@ -334,14 +334,14 @@
|
|
|
334
334
|
iframe.style.display = 'none';
|
|
335
335
|
iframe.setAttribute('nonce', nonce);
|
|
336
336
|
function cb ({ data }) {
|
|
337
|
-
|
|
338
|
-
if (
|
|
339
|
-
|
|
340
|
-
supportsImportMeta = data[1];
|
|
341
|
-
supportsCssAssertions = data[2];
|
|
342
|
-
supportsJsonAssertions = data[3];
|
|
337
|
+
const isFeatureDetectionMessage = Array.isArray(data) && data[0] === 'esms';
|
|
338
|
+
if (!isFeatureDetectionMessage) {
|
|
339
|
+
return;
|
|
343
340
|
}
|
|
344
|
-
|
|
341
|
+
supportsImportMaps = data[1];
|
|
342
|
+
supportsImportMeta = data[2];
|
|
343
|
+
supportsCssAssertions = data[3];
|
|
344
|
+
supportsJsonAssertions = data[4];
|
|
345
345
|
resolve();
|
|
346
346
|
document.head.removeChild(iframe);
|
|
347
347
|
window.removeEventListener('message', cb, false);
|
|
@@ -350,7 +350,7 @@
|
|
|
350
350
|
|
|
351
351
|
const importMapTest = `<script nonce=${nonce || ''}>b=(s,type='text/javascript')=>URL.createObjectURL(new Blob([s],{type}));document.head.appendChild(Object.assign(document.createElement('script'),{type:'importmap',nonce:"${nonce}",innerText:\`{"imports":{"x":"\${b('')}"}}\`}));Promise.all([${
|
|
352
352
|
supportsImportMaps ? 'true,true' : `'x',b('${importMetaCheck}')`}, ${cssModulesEnabled ? `b('${cssModulesCheck}'.replace('x',b('','text/css')))` : 'false'}, ${
|
|
353
|
-
jsonModulesEnabled ? `b('${jsonModulesCheck}'.replace('x',b('{}','text/json')))` : 'false'}].map(x =>typeof x==='string'?import(x).then(x =>!!x,()=>false):x)).then(a=>parent.postMessage(a,'*'))<${''}/script>`;
|
|
353
|
+
jsonModulesEnabled ? `b('${jsonModulesCheck}'.replace('x',b('{}','text/json')))` : 'false'}].map(x =>typeof x==='string'?import(x).then(x =>!!x,()=>false):x)).then(a=>parent.postMessage(['esms'].concat(a),'*'))<${''}/script>`;
|
|
354
354
|
|
|
355
355
|
// Safari will call onload eagerly on head injection, but we don't want the Wechat
|
|
356
356
|
// path to trigger before setting srcdoc, therefore we track the timing
|
package/dist/es-module-shims.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* ES Module Shims 1.7.
|
|
1
|
+
/* ES Module Shims 1.7.2 */
|
|
2
2
|
(function () {
|
|
3
3
|
|
|
4
4
|
const hasWindow = typeof window !== 'undefined';
|
|
@@ -333,13 +333,14 @@
|
|
|
333
333
|
iframe.style.display = 'none';
|
|
334
334
|
iframe.setAttribute('nonce', nonce);
|
|
335
335
|
function cb ({ data }) {
|
|
336
|
-
|
|
337
|
-
if (
|
|
338
|
-
|
|
339
|
-
supportsImportMeta = data[1];
|
|
340
|
-
supportsCssAssertions = data[2];
|
|
341
|
-
supportsJsonAssertions = data[3];
|
|
336
|
+
const isFeatureDetectionMessage = Array.isArray(data) && data[0] === 'esms';
|
|
337
|
+
if (!isFeatureDetectionMessage) {
|
|
338
|
+
return;
|
|
342
339
|
}
|
|
340
|
+
supportsImportMaps = data[1];
|
|
341
|
+
supportsImportMeta = data[2];
|
|
342
|
+
supportsCssAssertions = data[3];
|
|
343
|
+
supportsJsonAssertions = data[4];
|
|
343
344
|
resolve();
|
|
344
345
|
document.head.removeChild(iframe);
|
|
345
346
|
window.removeEventListener('message', cb, false);
|
|
@@ -348,7 +349,7 @@
|
|
|
348
349
|
|
|
349
350
|
const importMapTest = `<script nonce=${nonce || ''}>b=(s,type='text/javascript')=>URL.createObjectURL(new Blob([s],{type}));document.head.appendChild(Object.assign(document.createElement('script'),{type:'importmap',nonce:"${nonce}",innerText:\`{"imports":{"x":"\${b('')}"}}\`}));Promise.all([${
|
|
350
351
|
supportsImportMaps ? 'true,true' : `'x',b('${importMetaCheck}')`}, ${cssModulesEnabled ? `b('${cssModulesCheck}'.replace('x',b('','text/css')))` : 'false'}, ${
|
|
351
|
-
jsonModulesEnabled ? `b('${jsonModulesCheck}'.replace('x',b('{}','text/json')))` : 'false'}].map(x =>typeof x==='string'?import(x).then(x =>!!x,()=>false):x)).then(a=>parent.postMessage(a,'*'))<${''}/script>`;
|
|
352
|
+
jsonModulesEnabled ? `b('${jsonModulesCheck}'.replace('x',b('{}','text/json')))` : 'false'}].map(x =>typeof x==='string'?import(x).then(x =>!!x,()=>false):x)).then(a=>parent.postMessage(['esms'].concat(a),'*'))<${''}/script>`;
|
|
352
353
|
|
|
353
354
|
// Safari will call onload eagerly on head injection, but we don't want the Wechat
|
|
354
355
|
// path to trigger before setting srcdoc, therefore we track the timing
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* ES Module Shims Wasm 1.7.
|
|
1
|
+
/* ES Module Shims Wasm 1.7.2 */
|
|
2
2
|
(function () {
|
|
3
3
|
|
|
4
4
|
const hasWindow = typeof window !== 'undefined';
|
|
@@ -333,13 +333,14 @@
|
|
|
333
333
|
iframe.style.display = 'none';
|
|
334
334
|
iframe.setAttribute('nonce', nonce);
|
|
335
335
|
function cb ({ data }) {
|
|
336
|
-
|
|
337
|
-
if (
|
|
338
|
-
|
|
339
|
-
supportsImportMeta = data[1];
|
|
340
|
-
supportsCssAssertions = data[2];
|
|
341
|
-
supportsJsonAssertions = data[3];
|
|
336
|
+
const isFeatureDetectionMessage = Array.isArray(data) && data[0] === 'esms';
|
|
337
|
+
if (!isFeatureDetectionMessage) {
|
|
338
|
+
return;
|
|
342
339
|
}
|
|
340
|
+
supportsImportMaps = data[1];
|
|
341
|
+
supportsImportMeta = data[2];
|
|
342
|
+
supportsCssAssertions = data[3];
|
|
343
|
+
supportsJsonAssertions = data[4];
|
|
343
344
|
resolve();
|
|
344
345
|
document.head.removeChild(iframe);
|
|
345
346
|
window.removeEventListener('message', cb, false);
|
|
@@ -348,7 +349,7 @@
|
|
|
348
349
|
|
|
349
350
|
const importMapTest = `<script nonce=${nonce || ''}>b=(s,type='text/javascript')=>URL.createObjectURL(new Blob([s],{type}));document.head.appendChild(Object.assign(document.createElement('script'),{type:'importmap',nonce:"${nonce}",innerText:\`{"imports":{"x":"\${b('')}"}}\`}));Promise.all([${
|
|
350
351
|
supportsImportMaps ? 'true,true' : `'x',b('${importMetaCheck}')`}, ${cssModulesEnabled ? `b('${cssModulesCheck}'.replace('x',b('','text/css')))` : 'false'}, ${
|
|
351
|
-
jsonModulesEnabled ? `b('${jsonModulesCheck}'.replace('x',b('{}','text/json')))` : 'false'}].map(x =>typeof x==='string'?import(x).then(x =>!!x,()=>false):x)).then(a=>parent.postMessage(a,'*'))<${''}/script>`;
|
|
352
|
+
jsonModulesEnabled ? `b('${jsonModulesCheck}'.replace('x',b('{}','text/json')))` : 'false'}].map(x =>typeof x==='string'?import(x).then(x =>!!x,()=>false):x)).then(a=>parent.postMessage(['esms'].concat(a),'*'))<${''}/script>`;
|
|
352
353
|
|
|
353
354
|
// Safari will call onload eagerly on head injection, but we don't want the Wechat
|
|
354
355
|
// path to trigger before setting srcdoc, therefore we track the timing
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "es-module-shims",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.2",
|
|
4
4
|
"description": "Shims for the latest ES module features",
|
|
5
5
|
"main": "dist/es-module-shims.js",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": "./dist/es-module-shims.js",
|
|
8
|
+
"./debug": "./dist/es-module-shims.debug.js",
|
|
8
9
|
"./wasm": "./dist/es-module-shims.wasm.js"
|
|
9
10
|
},
|
|
10
11
|
"types": "index.d.ts",
|
|
@@ -1,898 +0,0 @@
|
|
|
1
|
-
/* ES Module Shims Wasm 1.6.3 */
|
|
2
|
-
(function () {
|
|
3
|
-
|
|
4
|
-
const hasWindow = typeof window !== 'undefined';
|
|
5
|
-
const hasDocument = typeof document !== 'undefined';
|
|
6
|
-
|
|
7
|
-
const noop = () => {};
|
|
8
|
-
|
|
9
|
-
const optionsScript = hasDocument ? document.querySelector('script[type=esms-options]') : undefined;
|
|
10
|
-
|
|
11
|
-
const esmsInitOptions = optionsScript ? JSON.parse(optionsScript.innerHTML) : {};
|
|
12
|
-
Object.assign(esmsInitOptions, self.esmsInitOptions || {});
|
|
13
|
-
|
|
14
|
-
let shimMode = hasDocument ? !!esmsInitOptions.shimMode : true;
|
|
15
|
-
|
|
16
|
-
const importHook = globalHook(shimMode && esmsInitOptions.onimport);
|
|
17
|
-
const resolveHook = globalHook(shimMode && esmsInitOptions.resolve);
|
|
18
|
-
let fetchHook = esmsInitOptions.fetch ? globalHook(esmsInitOptions.fetch) : fetch;
|
|
19
|
-
const metaHook = esmsInitOptions.meta ? globalHook(shimMode && esmsInitOptions.meta) : noop;
|
|
20
|
-
|
|
21
|
-
const mapOverrides = esmsInitOptions.mapOverrides;
|
|
22
|
-
|
|
23
|
-
let nonce = esmsInitOptions.nonce;
|
|
24
|
-
if (!nonce && hasDocument) {
|
|
25
|
-
const nonceElement = document.querySelector('script[nonce]');
|
|
26
|
-
if (nonceElement)
|
|
27
|
-
nonce = nonceElement.nonce || nonceElement.getAttribute('nonce');
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const onerror = globalHook(esmsInitOptions.onerror || noop);
|
|
31
|
-
const onpolyfill = esmsInitOptions.onpolyfill ? globalHook(esmsInitOptions.onpolyfill) : () => {
|
|
32
|
-
console.log('%c^^ Module TypeError above is polyfilled and can be ignored ^^', 'font-weight:900;color:#391');
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
const { revokeBlobURLs, noLoadEventRetriggers, enforceIntegrity } = esmsInitOptions;
|
|
36
|
-
|
|
37
|
-
function globalHook (name) {
|
|
38
|
-
return typeof name === 'string' ? self[name] : name;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const enable = Array.isArray(esmsInitOptions.polyfillEnable) ? esmsInitOptions.polyfillEnable : [];
|
|
42
|
-
const cssModulesEnabled = enable.includes('css-modules');
|
|
43
|
-
const jsonModulesEnabled = enable.includes('json-modules');
|
|
44
|
-
|
|
45
|
-
const edge = !navigator.userAgentData && !!navigator.userAgent.match(/Edge\/\d+\.\d+/);
|
|
46
|
-
|
|
47
|
-
const baseUrl = hasDocument
|
|
48
|
-
? document.baseURI
|
|
49
|
-
: `${location.protocol}//${location.host}${location.pathname.includes('/')
|
|
50
|
-
? location.pathname.slice(0, location.pathname.lastIndexOf('/') + 1)
|
|
51
|
-
: location.pathname}`;
|
|
52
|
-
|
|
53
|
-
const createBlob = (source, type = 'text/javascript') => URL.createObjectURL(new Blob([source], { type }));
|
|
54
|
-
let { skip } = esmsInitOptions;
|
|
55
|
-
if (Array.isArray(skip)) {
|
|
56
|
-
const l = skip.map(s => new URL(s, baseUrl).href);
|
|
57
|
-
skip = s => l.some(i => i[i.length - 1] === '/' && s.startsWith(i) || s === i);
|
|
58
|
-
}
|
|
59
|
-
else if (typeof skip === 'string') {
|
|
60
|
-
const r = new RegExp(skip);
|
|
61
|
-
skip = s => r.test(s);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const eoop = err => setTimeout(() => { throw err });
|
|
65
|
-
|
|
66
|
-
const throwError = err => { (self.reportError || hasWindow && window.safari && console.error || eoop)(err), void onerror(err); };
|
|
67
|
-
|
|
68
|
-
function fromParent (parent) {
|
|
69
|
-
return parent ? ` imported from ${parent}` : '';
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
let importMapSrcOrLazy = false;
|
|
73
|
-
|
|
74
|
-
function setImportMapSrcOrLazy () {
|
|
75
|
-
importMapSrcOrLazy = true;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// shim mode is determined on initialization, no late shim mode
|
|
79
|
-
if (!shimMode) {
|
|
80
|
-
if (document.querySelectorAll('script[type=module-shim],script[type=importmap-shim],link[rel=modulepreload-shim]').length) {
|
|
81
|
-
shimMode = true;
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
84
|
-
let seenScript = false;
|
|
85
|
-
for (const script of document.querySelectorAll('script[type=module],script[type=importmap]')) {
|
|
86
|
-
if (!seenScript) {
|
|
87
|
-
if (script.type === 'module' && !script.ep)
|
|
88
|
-
seenScript = true;
|
|
89
|
-
}
|
|
90
|
-
else if (script.type === 'importmap' && seenScript) {
|
|
91
|
-
importMapSrcOrLazy = true;
|
|
92
|
-
break;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
const backslashRegEx = /\\/g;
|
|
99
|
-
|
|
100
|
-
function isURL (url) {
|
|
101
|
-
if (url.indexOf(':') === -1) return false;
|
|
102
|
-
try {
|
|
103
|
-
new URL(url);
|
|
104
|
-
return true;
|
|
105
|
-
}
|
|
106
|
-
catch (_) {
|
|
107
|
-
return false;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
function resolveUrl (relUrl, parentUrl) {
|
|
112
|
-
return resolveIfNotPlainOrUrl(relUrl, parentUrl) || (isURL(relUrl) ? relUrl : resolveIfNotPlainOrUrl('./' + relUrl, parentUrl));
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
function resolveIfNotPlainOrUrl (relUrl, parentUrl) {
|
|
116
|
-
const hIdx = parentUrl.indexOf('#'), qIdx = parentUrl.indexOf('?');
|
|
117
|
-
if (hIdx + qIdx > -2)
|
|
118
|
-
parentUrl = parentUrl.slice(0, hIdx === -1 ? qIdx : qIdx === -1 || qIdx > hIdx ? hIdx : qIdx);
|
|
119
|
-
if (relUrl.indexOf('\\') !== -1)
|
|
120
|
-
relUrl = relUrl.replace(backslashRegEx, '/');
|
|
121
|
-
// protocol-relative
|
|
122
|
-
if (relUrl[0] === '/' && relUrl[1] === '/') {
|
|
123
|
-
return parentUrl.slice(0, parentUrl.indexOf(':') + 1) + relUrl;
|
|
124
|
-
}
|
|
125
|
-
// relative-url
|
|
126
|
-
else if (relUrl[0] === '.' && (relUrl[1] === '/' || relUrl[1] === '.' && (relUrl[2] === '/' || relUrl.length === 2 && (relUrl += '/')) ||
|
|
127
|
-
relUrl.length === 1 && (relUrl += '/')) ||
|
|
128
|
-
relUrl[0] === '/') {
|
|
129
|
-
const parentProtocol = parentUrl.slice(0, parentUrl.indexOf(':') + 1);
|
|
130
|
-
// Disabled, but these cases will give inconsistent results for deep backtracking
|
|
131
|
-
//if (parentUrl[parentProtocol.length] !== '/')
|
|
132
|
-
// throw new Error('Cannot resolve');
|
|
133
|
-
// read pathname from parent URL
|
|
134
|
-
// pathname taken to be part after leading "/"
|
|
135
|
-
let pathname;
|
|
136
|
-
if (parentUrl[parentProtocol.length + 1] === '/') {
|
|
137
|
-
// resolving to a :// so we need to read out the auth and host
|
|
138
|
-
if (parentProtocol !== 'file:') {
|
|
139
|
-
pathname = parentUrl.slice(parentProtocol.length + 2);
|
|
140
|
-
pathname = pathname.slice(pathname.indexOf('/') + 1);
|
|
141
|
-
}
|
|
142
|
-
else {
|
|
143
|
-
pathname = parentUrl.slice(8);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
else {
|
|
147
|
-
// resolving to :/ so pathname is the /... part
|
|
148
|
-
pathname = parentUrl.slice(parentProtocol.length + (parentUrl[parentProtocol.length] === '/'));
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
if (relUrl[0] === '/')
|
|
152
|
-
return parentUrl.slice(0, parentUrl.length - pathname.length - 1) + relUrl;
|
|
153
|
-
|
|
154
|
-
// join together and split for removal of .. and . segments
|
|
155
|
-
// looping the string instead of anything fancy for perf reasons
|
|
156
|
-
// '../../../../../z' resolved to 'x/y' is just 'z'
|
|
157
|
-
const segmented = pathname.slice(0, pathname.lastIndexOf('/') + 1) + relUrl;
|
|
158
|
-
|
|
159
|
-
const output = [];
|
|
160
|
-
let segmentIndex = -1;
|
|
161
|
-
for (let i = 0; i < segmented.length; i++) {
|
|
162
|
-
// busy reading a segment - only terminate on '/'
|
|
163
|
-
if (segmentIndex !== -1) {
|
|
164
|
-
if (segmented[i] === '/') {
|
|
165
|
-
output.push(segmented.slice(segmentIndex, i + 1));
|
|
166
|
-
segmentIndex = -1;
|
|
167
|
-
}
|
|
168
|
-
continue;
|
|
169
|
-
}
|
|
170
|
-
// new segment - check if it is relative
|
|
171
|
-
else if (segmented[i] === '.') {
|
|
172
|
-
// ../ segment
|
|
173
|
-
if (segmented[i + 1] === '.' && (segmented[i + 2] === '/' || i + 2 === segmented.length)) {
|
|
174
|
-
output.pop();
|
|
175
|
-
i += 2;
|
|
176
|
-
continue;
|
|
177
|
-
}
|
|
178
|
-
// ./ segment
|
|
179
|
-
else if (segmented[i + 1] === '/' || i + 1 === segmented.length) {
|
|
180
|
-
i += 1;
|
|
181
|
-
continue;
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
// it is the start of a new segment
|
|
185
|
-
while (segmented[i] === '/') i++;
|
|
186
|
-
segmentIndex = i;
|
|
187
|
-
}
|
|
188
|
-
// finish reading out the last segment
|
|
189
|
-
if (segmentIndex !== -1)
|
|
190
|
-
output.push(segmented.slice(segmentIndex));
|
|
191
|
-
return parentUrl.slice(0, parentUrl.length - pathname.length) + output.join('');
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
function resolveAndComposeImportMap (json, baseUrl, parentMap) {
|
|
196
|
-
const outMap = { imports: Object.assign({}, parentMap.imports), scopes: Object.assign({}, parentMap.scopes) };
|
|
197
|
-
|
|
198
|
-
if (json.imports)
|
|
199
|
-
resolveAndComposePackages(json.imports, outMap.imports, baseUrl, parentMap);
|
|
200
|
-
|
|
201
|
-
if (json.scopes)
|
|
202
|
-
for (let s in json.scopes) {
|
|
203
|
-
const resolvedScope = resolveUrl(s, baseUrl);
|
|
204
|
-
resolveAndComposePackages(json.scopes[s], outMap.scopes[resolvedScope] || (outMap.scopes[resolvedScope] = {}), baseUrl, parentMap);
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
return outMap;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
function getMatch (path, matchObj) {
|
|
211
|
-
if (matchObj[path])
|
|
212
|
-
return path;
|
|
213
|
-
let sepIndex = path.length;
|
|
214
|
-
do {
|
|
215
|
-
const segment = path.slice(0, sepIndex + 1);
|
|
216
|
-
if (segment in matchObj)
|
|
217
|
-
return segment;
|
|
218
|
-
} while ((sepIndex = path.lastIndexOf('/', sepIndex - 1)) !== -1)
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
function applyPackages (id, packages) {
|
|
222
|
-
const pkgName = getMatch(id, packages);
|
|
223
|
-
if (pkgName) {
|
|
224
|
-
const pkg = packages[pkgName];
|
|
225
|
-
if (pkg === null) return;
|
|
226
|
-
return pkg + id.slice(pkgName.length);
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
function resolveImportMap (importMap, resolvedOrPlain, parentUrl) {
|
|
232
|
-
let scopeUrl = parentUrl && getMatch(parentUrl, importMap.scopes);
|
|
233
|
-
while (scopeUrl) {
|
|
234
|
-
const packageResolution = applyPackages(resolvedOrPlain, importMap.scopes[scopeUrl]);
|
|
235
|
-
if (packageResolution)
|
|
236
|
-
return packageResolution;
|
|
237
|
-
scopeUrl = getMatch(scopeUrl.slice(0, scopeUrl.lastIndexOf('/')), importMap.scopes);
|
|
238
|
-
}
|
|
239
|
-
return applyPackages(resolvedOrPlain, importMap.imports) || resolvedOrPlain.indexOf(':') !== -1 && resolvedOrPlain;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
function resolveAndComposePackages (packages, outPackages, baseUrl, parentMap) {
|
|
243
|
-
for (let p in packages) {
|
|
244
|
-
const resolvedLhs = resolveIfNotPlainOrUrl(p, baseUrl) || p;
|
|
245
|
-
if ((!shimMode || !mapOverrides) && outPackages[resolvedLhs] && (outPackages[resolvedLhs] !== packages[resolvedLhs])) {
|
|
246
|
-
throw Error(`Rejected map override "${resolvedLhs}" from ${outPackages[resolvedLhs]} to ${packages[resolvedLhs]}.`);
|
|
247
|
-
}
|
|
248
|
-
let target = packages[p];
|
|
249
|
-
if (typeof target !== 'string')
|
|
250
|
-
continue;
|
|
251
|
-
const mapped = resolveImportMap(parentMap, resolveIfNotPlainOrUrl(target, baseUrl) || target, baseUrl);
|
|
252
|
-
if (mapped) {
|
|
253
|
-
outPackages[resolvedLhs] = mapped;
|
|
254
|
-
continue;
|
|
255
|
-
}
|
|
256
|
-
console.warn(`Mapping "${p}" -> "${packages[p]}" does not resolve`);
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
let dynamicImport = !hasDocument && (0, eval)('u=>import(u)');
|
|
261
|
-
|
|
262
|
-
let supportsDynamicImport;
|
|
263
|
-
|
|
264
|
-
const dynamicImportCheck = hasDocument && new Promise(resolve => {
|
|
265
|
-
const s = Object.assign(document.createElement('script'), {
|
|
266
|
-
src: createBlob('self._d=u=>import(u)'),
|
|
267
|
-
ep: true
|
|
268
|
-
});
|
|
269
|
-
s.setAttribute('nonce', nonce);
|
|
270
|
-
s.addEventListener('load', () => {
|
|
271
|
-
if (!(supportsDynamicImport = !!(dynamicImport = self._d))) {
|
|
272
|
-
let err;
|
|
273
|
-
window.addEventListener('error', _err => err = _err);
|
|
274
|
-
dynamicImport = (url, opts) => new Promise((resolve, reject) => {
|
|
275
|
-
const s = Object.assign(document.createElement('script'), {
|
|
276
|
-
type: 'module',
|
|
277
|
-
src: createBlob(`import*as m from'${url}';self._esmsi=m`)
|
|
278
|
-
});
|
|
279
|
-
err = undefined;
|
|
280
|
-
s.ep = true;
|
|
281
|
-
if (nonce)
|
|
282
|
-
s.setAttribute('nonce', nonce);
|
|
283
|
-
// Safari is unique in supporting module script error events
|
|
284
|
-
s.addEventListener('error', cb);
|
|
285
|
-
s.addEventListener('load', cb);
|
|
286
|
-
function cb (_err) {
|
|
287
|
-
document.head.removeChild(s);
|
|
288
|
-
if (self._esmsi) {
|
|
289
|
-
resolve(self._esmsi, baseUrl);
|
|
290
|
-
self._esmsi = undefined;
|
|
291
|
-
}
|
|
292
|
-
else {
|
|
293
|
-
reject(!(_err instanceof Event) && _err || err && err.error || new Error(`Error loading ${opts && opts.errUrl || url} (${s.src}).`));
|
|
294
|
-
err = undefined;
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
document.head.appendChild(s);
|
|
298
|
-
});
|
|
299
|
-
}
|
|
300
|
-
document.head.removeChild(s);
|
|
301
|
-
delete self._d;
|
|
302
|
-
resolve();
|
|
303
|
-
});
|
|
304
|
-
document.head.appendChild(s);
|
|
305
|
-
});
|
|
306
|
-
|
|
307
|
-
// support browsers without dynamic import support (eg Firefox 6x)
|
|
308
|
-
let supportsJsonAssertions = false;
|
|
309
|
-
let supportsCssAssertions = false;
|
|
310
|
-
|
|
311
|
-
let supportsImportMaps = hasDocument && HTMLScriptElement.supports ? HTMLScriptElement.supports('importmap') : false;
|
|
312
|
-
let supportsImportMeta = supportsImportMaps;
|
|
313
|
-
|
|
314
|
-
const importMetaCheck = 'import.meta';
|
|
315
|
-
const cssModulesCheck = `import"x"assert{type:"css"}`;
|
|
316
|
-
const jsonModulesCheck = `import"x"assert{type:"json"}`;
|
|
317
|
-
|
|
318
|
-
const featureDetectionPromise = Promise.resolve(dynamicImportCheck).then(() => {
|
|
319
|
-
if (!supportsDynamicImport || supportsImportMaps && !cssModulesEnabled && !jsonModulesEnabled)
|
|
320
|
-
return;
|
|
321
|
-
|
|
322
|
-
if (!hasDocument)
|
|
323
|
-
return Promise.all([
|
|
324
|
-
supportsImportMaps || dynamicImport(createBlob(importMetaCheck)).then(() => supportsImportMeta = true, noop),
|
|
325
|
-
cssModulesEnabled && dynamicImport(createBlob(cssModulesCheck.replace('x', createBlob('', 'text/css')))).then(() => supportsCssAssertions = true, noop),
|
|
326
|
-
jsonModulesEnabled && dynamicImport(createBlob(jsonModulescheck.replace('x', createBlob('{}', 'text/json')))).then(() => supportsJsonAssertions = true, noop),
|
|
327
|
-
]);
|
|
328
|
-
|
|
329
|
-
return new Promise(resolve => {
|
|
330
|
-
const iframe = document.createElement('iframe');
|
|
331
|
-
iframe.style.display = 'none';
|
|
332
|
-
iframe.setAttribute('nonce', nonce);
|
|
333
|
-
function cb ({ data: [a, b, c, d] }) {
|
|
334
|
-
supportsImportMaps = a;
|
|
335
|
-
supportsImportMeta = b;
|
|
336
|
-
supportsCssAssertions = c;
|
|
337
|
-
supportsJsonAssertions = d;
|
|
338
|
-
resolve();
|
|
339
|
-
document.head.removeChild(iframe);
|
|
340
|
-
window.removeEventListener('message', cb, false);
|
|
341
|
-
}
|
|
342
|
-
window.addEventListener('message', cb, false);
|
|
343
|
-
|
|
344
|
-
const importMapTest = `<script nonce=${nonce || ''}>b=(s,type='text/javascript')=>URL.createObjectURL(new Blob([s],{type}));document.head.appendChild(Object.assign(document.createElement('script'),{type:'importmap',nonce:"${nonce}",innerText:\`{"imports":{"x":"\${b('')}"}}\`}));Promise.all([${
|
|
345
|
-
supportsImportMaps ? 'true,true' : `'x',b('${importMetaCheck}')`}, ${cssModulesEnabled ? `b('${cssModulesCheck}'.replace('x',b('','text/css')))` : 'false'}, ${
|
|
346
|
-
jsonModulesEnabled ? `b('${jsonModulesCheck}'.replace('x',b('{}','text/json')))` : 'false'}].map(x =>typeof x==='string'?import(x).then(x =>!!x,()=>false):x)).then(a=>parent.postMessage(a,'*'))<${''}/script>`;
|
|
347
|
-
|
|
348
|
-
iframe.onload = () => {
|
|
349
|
-
// WeChat browser doesn't support setting srcdoc scripts
|
|
350
|
-
// But iframe sandboxes don't support contentDocument so we do this as a fallback
|
|
351
|
-
const doc = iframe.contentDocument;
|
|
352
|
-
if (doc && doc.head.childNodes.length === 0) {
|
|
353
|
-
const s = doc.createElement('script');
|
|
354
|
-
if (nonce)
|
|
355
|
-
s.setAttribute('nonce', nonce);
|
|
356
|
-
s.innerHTML = importMapTest.slice(15 + (nonce ? nonce.length : 0), -9);
|
|
357
|
-
doc.head.appendChild(s);
|
|
358
|
-
}
|
|
359
|
-
};
|
|
360
|
-
// WeChat browser requires append before setting srcdoc
|
|
361
|
-
document.head.appendChild(iframe);
|
|
362
|
-
// setting srcdoc is not supported in React native webviews on iOS
|
|
363
|
-
// setting src to a blob URL results in a navigation event in webviews
|
|
364
|
-
// document.write gives usability warnings
|
|
365
|
-
if ('srcdoc' in iframe)
|
|
366
|
-
iframe.srcdoc = importMapTest;
|
|
367
|
-
else
|
|
368
|
-
iframe.contentDocument.write(importMapTest);
|
|
369
|
-
});
|
|
370
|
-
});
|
|
371
|
-
|
|
372
|
-
/* es-module-lexer 1.1.0 */
|
|
373
|
-
const A=1===new Uint8Array(new Uint16Array([1]).buffer)[0];function parse(E,g="@"){if(!C)return init.then((()=>parse(E)));const I=E.length+1,K=(C.__heap_base.value||C.__heap_base)+4*I-C.memory.buffer.byteLength;K>0&&C.memory.grow(Math.ceil(K/65536));const k=C.sa(I-1);if((A?B:Q)(E,new Uint16Array(C.memory.buffer,k,I)),!C.parse())throw Object.assign(new Error(`Parse error ${g}:${E.slice(0,C.e()).split("\n").length}:${C.e()-E.lastIndexOf("\n",C.e()-1)}`),{idx:C.e()});const o=[],D=[];for(;C.ri();){const A=C.is(),Q=C.ie(),B=C.ai(),g=C.id(),I=C.ss(),K=C.se();let k;C.ip()&&(k=w(E.slice(-1===g?A-1:A,-1===g?Q+1:Q))),o.push({n:k,s:A,e:Q,ss:I,se:K,d:g,a:B});}for(;C.re();){const A=C.es(),Q=C.ee(),B=C.els(),g=C.ele(),I=E.slice(A,Q),K=I[0],k=B<0?void 0:E.slice(B,g),o=k?k[0]:"";D.push({s:A,e:Q,ls:B,le:g,n:'"'===K||"'"===K?w(I):I,ln:'"'===o||"'"===o?w(k):k});}function w(A){try{return (0,eval)(A)}catch(A){}}return [o,D,!!C.f()]}function Q(A,Q){const B=A.length;let C=0;for(;C<B;){const B=A.charCodeAt(C);Q[C++]=(255&B)<<8|B>>>8;}}function B(A,Q){const B=A.length;let C=0;for(;C<B;)Q[C]=A.charCodeAt(C++);}let C;const init=WebAssembly.compile((E="AGFzbQEAAAABKghgAX8Bf2AEf39/fwBgAAF/YAAAYAF/AGADf39/AX9gAn9/AX9gAn9/AAMtLAABAQICAgICAgICAgICAgICAgIAAwMDBAQAAAADAAAAAAMDBQYAAAcABgIFBAUBcAEBAQUDAQABBg8CfwFBsPIAC38AQbDyAAsHcBMGbWVtb3J5AgACc2EAAAFlAAMCaXMABAJpZQAFAnNzAAYCc2UABwJhaQAIAmlkAAkCaXAACgJlcwALAmVlAAwDZWxzAA0DZWxlAA4CcmkADwJyZQAQAWYAEQVwYXJzZQASC19faGVhcF9iYXNlAwEKsjssaAEBf0EAIAA2AvgJQQAoAtQJIgEgAEEBdGoiAEEAOwEAQQAgAEECaiIANgL8CUEAIAA2AoAKQQBBADYC2AlBAEEANgLoCUEAQQA2AuAJQQBBADYC3AlBAEEANgLwCUEAQQA2AuQJIAELnwEBA39BACgC6AkhBEEAQQAoAoAKIgU2AugJQQAgBDYC7AlBACAFQSBqNgKACiAEQRxqQdgJIAQbIAU2AgB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L5AECAEGACAvGAQAAeABwAG8AcgB0AG0AcABvAHIAdABlAHQAYQBmAHIAbwBtAHUAbgBjAHQAaQBvAG4AcwBzAGUAcgB0AHYAbwB5AGkAZQBkAGUAbABlAGMAbwBuAHQAaQBuAGkAbgBzAHQAYQBuAHQAeQBiAHIAZQBhAHIAZQB0AHUAcgBkAGUAYgB1AGcAZwBlAGEAdwBhAGkAdABoAHIAdwBoAGkAbABlAGYAbwByAGkAZgBjAGEAdABjAGYAaQBuAGEAbABsAGUAbABzAABByAkLEAEAAAACAAAAAAQAADA5AAA=","undefined"!=typeof Buffer?Buffer.from(E,"base64"):Uint8Array.from(atob(E),(A=>A.charCodeAt(0))))).then(WebAssembly.instantiate).then((({exports:A})=>{C=A;}));var E;
|
|
374
|
-
|
|
375
|
-
async function _resolve (id, parentUrl) {
|
|
376
|
-
const urlResolved = resolveIfNotPlainOrUrl(id, parentUrl);
|
|
377
|
-
return {
|
|
378
|
-
r: resolveImportMap(importMap, urlResolved || id, parentUrl) || throwUnresolved(id, parentUrl),
|
|
379
|
-
// b = bare specifier
|
|
380
|
-
b: !urlResolved && !isURL(id)
|
|
381
|
-
};
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
const resolve = resolveHook ? async (id, parentUrl) => {
|
|
385
|
-
let result = resolveHook(id, parentUrl, defaultResolve);
|
|
386
|
-
// will be deprecated in next major
|
|
387
|
-
if (result && result.then)
|
|
388
|
-
result = await result;
|
|
389
|
-
return result ? { r: result, b: !resolveIfNotPlainOrUrl(id, parentUrl) && !isURL(id) } : _resolve(id, parentUrl);
|
|
390
|
-
} : _resolve;
|
|
391
|
-
|
|
392
|
-
// importShim('mod');
|
|
393
|
-
// importShim('mod', { opts });
|
|
394
|
-
// importShim('mod', { opts }, parentUrl);
|
|
395
|
-
// importShim('mod', parentUrl);
|
|
396
|
-
async function importShim (id, ...args) {
|
|
397
|
-
// parentUrl if present will be the last argument
|
|
398
|
-
let parentUrl = args[args.length - 1];
|
|
399
|
-
if (typeof parentUrl !== 'string')
|
|
400
|
-
parentUrl = baseUrl;
|
|
401
|
-
// needed for shim check
|
|
402
|
-
await initPromise;
|
|
403
|
-
if (importHook) await importHook(id, typeof args[1] !== 'string' ? args[1] : {}, parentUrl);
|
|
404
|
-
if (acceptingImportMaps || shimMode || !baselinePassthrough) {
|
|
405
|
-
if (hasDocument)
|
|
406
|
-
processScriptsAndPreloads(true);
|
|
407
|
-
if (!shimMode)
|
|
408
|
-
acceptingImportMaps = false;
|
|
409
|
-
}
|
|
410
|
-
await importMapPromise;
|
|
411
|
-
return topLevelLoad((await resolve(id, parentUrl)).r, { credentials: 'same-origin' });
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
self.importShim = importShim;
|
|
415
|
-
|
|
416
|
-
function defaultResolve (id, parentUrl) {
|
|
417
|
-
return resolveImportMap(importMap, resolveIfNotPlainOrUrl(id, parentUrl) || id, parentUrl) || throwUnresolved(id, parentUrl);
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
function throwUnresolved (id, parentUrl) {
|
|
421
|
-
throw Error(`Unable to resolve specifier '${id}'${fromParent(parentUrl)}`);
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
const resolveSync = (id, parentUrl = baseUrl) => {
|
|
425
|
-
parentUrl = `${parentUrl}`;
|
|
426
|
-
const result = resolveHook && resolveHook(id, parentUrl, defaultResolve);
|
|
427
|
-
return result && !result.then ? result : defaultResolve(id, parentUrl);
|
|
428
|
-
};
|
|
429
|
-
|
|
430
|
-
function metaResolve (id, parentUrl = this.url) {
|
|
431
|
-
return resolveSync(id, parentUrl);
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
importShim.resolve = resolveSync;
|
|
435
|
-
importShim.getImportMap = () => JSON.parse(JSON.stringify(importMap));
|
|
436
|
-
importShim.addImportMap = importMapIn => {
|
|
437
|
-
if (!shimMode) throw new Error('Unsupported in polyfill mode.');
|
|
438
|
-
importMap = resolveAndComposeImportMap(importMapIn, baseUrl, importMap);
|
|
439
|
-
};
|
|
440
|
-
|
|
441
|
-
const registry = importShim._r = {};
|
|
442
|
-
|
|
443
|
-
async function loadAll (load, seen) {
|
|
444
|
-
if (load.b || seen[load.u])
|
|
445
|
-
return;
|
|
446
|
-
seen[load.u] = 1;
|
|
447
|
-
await load.L;
|
|
448
|
-
await Promise.all(load.d.map(dep => loadAll(dep, seen)));
|
|
449
|
-
if (!load.n)
|
|
450
|
-
load.n = load.d.some(dep => dep.n);
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
let importMap = { imports: {}, scopes: {} };
|
|
454
|
-
let baselinePassthrough;
|
|
455
|
-
|
|
456
|
-
const initPromise = featureDetectionPromise.then(() => {
|
|
457
|
-
baselinePassthrough = esmsInitOptions.polyfillEnable !== true && supportsDynamicImport && supportsImportMeta && supportsImportMaps && (!jsonModulesEnabled || supportsJsonAssertions) && (!cssModulesEnabled || supportsCssAssertions) && !importMapSrcOrLazy && !true;
|
|
458
|
-
if (hasDocument) {
|
|
459
|
-
if (!supportsImportMaps) {
|
|
460
|
-
const supports = HTMLScriptElement.supports || (type => type === 'classic' || type === 'module');
|
|
461
|
-
HTMLScriptElement.supports = type => type === 'importmap' || supports(type);
|
|
462
|
-
}
|
|
463
|
-
if (shimMode || !baselinePassthrough) {
|
|
464
|
-
new MutationObserver(mutations => {
|
|
465
|
-
for (const mutation of mutations) {
|
|
466
|
-
if (mutation.type !== 'childList') continue;
|
|
467
|
-
for (const node of mutation.addedNodes) {
|
|
468
|
-
if (node.tagName === 'SCRIPT') {
|
|
469
|
-
if (node.type === (shimMode ? 'module-shim' : 'module'))
|
|
470
|
-
processScript(node, true);
|
|
471
|
-
if (node.type === (shimMode ? 'importmap-shim' : 'importmap'))
|
|
472
|
-
processImportMap(node, true);
|
|
473
|
-
}
|
|
474
|
-
else if (node.tagName === 'LINK' && node.rel === (shimMode ? 'modulepreload-shim' : 'modulepreload')) {
|
|
475
|
-
processPreload(node);
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
}).observe(document, {childList: true, subtree: true});
|
|
480
|
-
processScriptsAndPreloads();
|
|
481
|
-
if (document.readyState === 'complete') {
|
|
482
|
-
readyStateCompleteCheck();
|
|
483
|
-
}
|
|
484
|
-
else {
|
|
485
|
-
async function readyListener() {
|
|
486
|
-
await initPromise;
|
|
487
|
-
processScriptsAndPreloads();
|
|
488
|
-
if (document.readyState === 'complete') {
|
|
489
|
-
readyStateCompleteCheck();
|
|
490
|
-
document.removeEventListener('readystatechange', readyListener);
|
|
491
|
-
}
|
|
492
|
-
}
|
|
493
|
-
document.addEventListener('readystatechange', readyListener);
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
|
-
}
|
|
497
|
-
return init;
|
|
498
|
-
});
|
|
499
|
-
let importMapPromise = initPromise;
|
|
500
|
-
let firstPolyfillLoad = true;
|
|
501
|
-
let acceptingImportMaps = true;
|
|
502
|
-
|
|
503
|
-
async function topLevelLoad (url, fetchOpts, source, nativelyLoaded, lastStaticLoadPromise) {
|
|
504
|
-
if (!shimMode)
|
|
505
|
-
acceptingImportMaps = false;
|
|
506
|
-
await initPromise;
|
|
507
|
-
await importMapPromise;
|
|
508
|
-
if (importHook) await importHook(url, typeof fetchOpts !== 'string' ? fetchOpts : {}, '');
|
|
509
|
-
// early analysis opt-out - no need to even fetch if we have feature support
|
|
510
|
-
if (!shimMode && baselinePassthrough) {
|
|
511
|
-
// for polyfill case, only dynamic import needs a return value here, and dynamic import will never pass nativelyLoaded
|
|
512
|
-
if (nativelyLoaded)
|
|
513
|
-
return null;
|
|
514
|
-
await lastStaticLoadPromise;
|
|
515
|
-
return dynamicImport(source ? createBlob(source) : url, { errUrl: url || source });
|
|
516
|
-
}
|
|
517
|
-
const load = getOrCreateLoad(url, fetchOpts, null, source);
|
|
518
|
-
const seen = {};
|
|
519
|
-
await loadAll(load, seen);
|
|
520
|
-
lastLoad = undefined;
|
|
521
|
-
resolveDeps(load, seen);
|
|
522
|
-
await lastStaticLoadPromise;
|
|
523
|
-
if (source && !shimMode && !load.n && !true) {
|
|
524
|
-
const module = await dynamicImport(createBlob(source), { errUrl: source });
|
|
525
|
-
if (revokeBlobURLs) revokeObjectURLs(Object.keys(seen));
|
|
526
|
-
return module;
|
|
527
|
-
}
|
|
528
|
-
if (firstPolyfillLoad && !shimMode && load.n && nativelyLoaded) {
|
|
529
|
-
onpolyfill();
|
|
530
|
-
firstPolyfillLoad = false;
|
|
531
|
-
}
|
|
532
|
-
const module = await dynamicImport(!shimMode && !load.n && nativelyLoaded ? load.u : load.b, { errUrl: load.u });
|
|
533
|
-
// if the top-level load is a shell, run its update function
|
|
534
|
-
if (load.s)
|
|
535
|
-
(await dynamicImport(load.s)).u$_(module);
|
|
536
|
-
if (revokeBlobURLs) revokeObjectURLs(Object.keys(seen));
|
|
537
|
-
// when tla is supported, this should return the tla promise as an actual handle
|
|
538
|
-
// so readystate can still correspond to the sync subgraph exec completions
|
|
539
|
-
return module;
|
|
540
|
-
}
|
|
541
|
-
|
|
542
|
-
function revokeObjectURLs(registryKeys) {
|
|
543
|
-
let batch = 0;
|
|
544
|
-
const keysLength = registryKeys.length;
|
|
545
|
-
const schedule = self.requestIdleCallback ? self.requestIdleCallback : self.requestAnimationFrame;
|
|
546
|
-
schedule(cleanup);
|
|
547
|
-
function cleanup() {
|
|
548
|
-
const batchStartIndex = batch * 100;
|
|
549
|
-
if (batchStartIndex > keysLength) return
|
|
550
|
-
for (const key of registryKeys.slice(batchStartIndex, batchStartIndex + 100)) {
|
|
551
|
-
const load = registry[key];
|
|
552
|
-
if (load) URL.revokeObjectURL(load.b);
|
|
553
|
-
}
|
|
554
|
-
batch++;
|
|
555
|
-
schedule(cleanup);
|
|
556
|
-
}
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
function urlJsString (url) {
|
|
560
|
-
return `'${url.replace(/'/g, "\\'")}'`;
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
let lastLoad;
|
|
564
|
-
function resolveDeps (load, seen) {
|
|
565
|
-
if (load.b || !seen[load.u])
|
|
566
|
-
return;
|
|
567
|
-
seen[load.u] = 0;
|
|
568
|
-
|
|
569
|
-
for (const dep of load.d)
|
|
570
|
-
resolveDeps(dep, seen);
|
|
571
|
-
|
|
572
|
-
const [imports, exports] = load.a;
|
|
573
|
-
|
|
574
|
-
// "execution"
|
|
575
|
-
const source = load.S;
|
|
576
|
-
|
|
577
|
-
// edge doesnt execute sibling in order, so we fix this up by ensuring all previous executions are explicit dependencies
|
|
578
|
-
let resolvedSource = edge && lastLoad ? `import '${lastLoad}';` : '';
|
|
579
|
-
|
|
580
|
-
if (!imports.length) {
|
|
581
|
-
resolvedSource += source;
|
|
582
|
-
}
|
|
583
|
-
else {
|
|
584
|
-
// once all deps have loaded we can inline the dependency resolution blobs
|
|
585
|
-
// and define this blob
|
|
586
|
-
let lastIndex = 0, depIndex = 0, dynamicImportEndStack = [];
|
|
587
|
-
function pushStringTo (originalIndex) {
|
|
588
|
-
while (dynamicImportEndStack[dynamicImportEndStack.length - 1] < originalIndex) {
|
|
589
|
-
const dynamicImportEnd = dynamicImportEndStack.pop();
|
|
590
|
-
resolvedSource += `${source.slice(lastIndex, dynamicImportEnd)}, ${urlJsString(load.r)}`;
|
|
591
|
-
lastIndex = dynamicImportEnd;
|
|
592
|
-
}
|
|
593
|
-
resolvedSource += source.slice(lastIndex, originalIndex);
|
|
594
|
-
lastIndex = originalIndex;
|
|
595
|
-
}
|
|
596
|
-
for (const { s: start, ss: statementStart, se: statementEnd, d: dynamicImportIndex } of imports) {
|
|
597
|
-
// dependency source replacements
|
|
598
|
-
if (dynamicImportIndex === -1) {
|
|
599
|
-
let depLoad = load.d[depIndex++], blobUrl = depLoad.b, cycleShell = !blobUrl;
|
|
600
|
-
if (cycleShell) {
|
|
601
|
-
// circular shell creation
|
|
602
|
-
if (!(blobUrl = depLoad.s)) {
|
|
603
|
-
blobUrl = depLoad.s = createBlob(`export function u$_(m){${
|
|
604
|
-
depLoad.a[1].map(({ s, e }, i) => {
|
|
605
|
-
const q = depLoad.S[s] === '"' || depLoad.S[s] === "'";
|
|
606
|
-
return `e$_${i}=m${q ? `[` : '.'}${depLoad.S.slice(s, e)}${q ? `]` : ''}`;
|
|
607
|
-
}).join(',')
|
|
608
|
-
}}${
|
|
609
|
-
depLoad.a[1].length ? `let ${depLoad.a[1].map((_, i) => `e$_${i}`).join(',')};` : ''
|
|
610
|
-
}export {${
|
|
611
|
-
depLoad.a[1].map(({ s, e }, i) => `e$_${i} as ${depLoad.S.slice(s, e)}`).join(',')
|
|
612
|
-
}}\n//# sourceURL=${depLoad.r}?cycle`);
|
|
613
|
-
}
|
|
614
|
-
}
|
|
615
|
-
|
|
616
|
-
pushStringTo(start - 1);
|
|
617
|
-
resolvedSource += `/*${source.slice(start - 1, statementEnd)}*/${urlJsString(blobUrl)}`;
|
|
618
|
-
|
|
619
|
-
// circular shell execution
|
|
620
|
-
if (!cycleShell && depLoad.s) {
|
|
621
|
-
resolvedSource += `;import*as m$_${depIndex} from'${depLoad.b}';import{u$_ as u$_${depIndex}}from'${depLoad.s}';u$_${depIndex}(m$_${depIndex})`;
|
|
622
|
-
depLoad.s = undefined;
|
|
623
|
-
}
|
|
624
|
-
lastIndex = statementEnd;
|
|
625
|
-
}
|
|
626
|
-
// import.meta
|
|
627
|
-
else if (dynamicImportIndex === -2) {
|
|
628
|
-
load.m = { url: load.r, resolve: metaResolve };
|
|
629
|
-
metaHook(load.m, load.u);
|
|
630
|
-
pushStringTo(start);
|
|
631
|
-
resolvedSource += `importShim._r[${urlJsString(load.u)}].m`;
|
|
632
|
-
lastIndex = statementEnd;
|
|
633
|
-
}
|
|
634
|
-
// dynamic import
|
|
635
|
-
else {
|
|
636
|
-
pushStringTo(statementStart + 6);
|
|
637
|
-
resolvedSource += `Shim(`;
|
|
638
|
-
dynamicImportEndStack.push(statementEnd - 1);
|
|
639
|
-
lastIndex = start;
|
|
640
|
-
}
|
|
641
|
-
}
|
|
642
|
-
|
|
643
|
-
// support progressive cycle binding updates (try statement avoids tdz errors)
|
|
644
|
-
if (load.s)
|
|
645
|
-
resolvedSource += `\n;import{u$_}from'${load.s}';try{u$_({${exports.filter(e => e.ln).map(({ s, e, ln }) => `${source.slice(s, e)}:${ln}`).join(',')}})}catch(_){};\n`;
|
|
646
|
-
|
|
647
|
-
pushStringTo(source.length);
|
|
648
|
-
}
|
|
649
|
-
|
|
650
|
-
let hasSourceURL = false;
|
|
651
|
-
resolvedSource = resolvedSource.replace(sourceMapURLRegEx, (match, isMapping, url) => (hasSourceURL = !isMapping, match.replace(url, () => new URL(url, load.r))));
|
|
652
|
-
if (!hasSourceURL)
|
|
653
|
-
resolvedSource += '\n//# sourceURL=' + load.r;
|
|
654
|
-
|
|
655
|
-
load.b = lastLoad = createBlob(resolvedSource);
|
|
656
|
-
load.S = undefined;
|
|
657
|
-
}
|
|
658
|
-
|
|
659
|
-
// ; and // trailer support added for Ruby on Rails 7 source maps compatibility
|
|
660
|
-
// https://github.com/guybedford/es-module-shims/issues/228
|
|
661
|
-
const sourceMapURLRegEx = /\n\/\/# source(Mapping)?URL=([^\n]+)\s*((;|\/\/[^#][^\n]*)\s*)*$/;
|
|
662
|
-
|
|
663
|
-
const jsContentType = /^(text|application)\/(x-)?javascript(;|$)/;
|
|
664
|
-
const jsonContentType = /^(text|application)\/json(;|$)/;
|
|
665
|
-
const cssContentType = /^(text|application)\/css(;|$)/;
|
|
666
|
-
|
|
667
|
-
const cssUrlRegEx = /url\(\s*(?:(["'])((?:\\.|[^\n\\"'])+)\1|((?:\\.|[^\s,"'()\\])+))\s*\)/g;
|
|
668
|
-
|
|
669
|
-
// restrict in-flight fetches to a pool of 100
|
|
670
|
-
let p = [];
|
|
671
|
-
let c = 0;
|
|
672
|
-
function pushFetchPool () {
|
|
673
|
-
if (++c > 100)
|
|
674
|
-
return new Promise(r => p.push(r));
|
|
675
|
-
}
|
|
676
|
-
function popFetchPool () {
|
|
677
|
-
c--;
|
|
678
|
-
if (p.length)
|
|
679
|
-
p.shift()();
|
|
680
|
-
}
|
|
681
|
-
|
|
682
|
-
async function doFetch (url, fetchOpts, parent) {
|
|
683
|
-
if (enforceIntegrity && !fetchOpts.integrity)
|
|
684
|
-
throw Error(`No integrity for ${url}${fromParent(parent)}.`);
|
|
685
|
-
const poolQueue = pushFetchPool();
|
|
686
|
-
if (poolQueue) await poolQueue;
|
|
687
|
-
try {
|
|
688
|
-
var res = await fetchHook(url, fetchOpts);
|
|
689
|
-
}
|
|
690
|
-
catch (e) {
|
|
691
|
-
e.message = `Unable to fetch ${url}${fromParent(parent)} - see network log for details.\n` + e.message;
|
|
692
|
-
throw e;
|
|
693
|
-
}
|
|
694
|
-
finally {
|
|
695
|
-
popFetchPool();
|
|
696
|
-
}
|
|
697
|
-
if (!res.ok)
|
|
698
|
-
throw Error(`${res.status} ${res.statusText} ${res.url}${fromParent(parent)}`);
|
|
699
|
-
return res;
|
|
700
|
-
}
|
|
701
|
-
|
|
702
|
-
async function fetchModule (url, fetchOpts, parent) {
|
|
703
|
-
const res = await doFetch(url, fetchOpts, parent);
|
|
704
|
-
const contentType = res.headers.get('content-type');
|
|
705
|
-
if (jsContentType.test(contentType))
|
|
706
|
-
return { r: res.url, s: await res.text(), t: 'js' };
|
|
707
|
-
else if (jsonContentType.test(contentType))
|
|
708
|
-
return { r: res.url, s: `export default ${await res.text()}`, t: 'json' };
|
|
709
|
-
else if (cssContentType.test(contentType)) {
|
|
710
|
-
return { r: res.url, s: `var s=new CSSStyleSheet();s.replaceSync(${
|
|
711
|
-
JSON.stringify((await res.text()).replace(cssUrlRegEx, (_match, quotes = '', relUrl1, relUrl2) => `url(${quotes}${resolveUrl(relUrl1 || relUrl2, url)}${quotes})`))
|
|
712
|
-
});export default s;`, t: 'css' };
|
|
713
|
-
}
|
|
714
|
-
else
|
|
715
|
-
throw Error(`Unsupported Content-Type "${contentType}" loading ${url}${fromParent(parent)}. Modules must be served with a valid MIME type like application/javascript.`);
|
|
716
|
-
}
|
|
717
|
-
|
|
718
|
-
function getOrCreateLoad (url, fetchOpts, parent, source) {
|
|
719
|
-
let load = registry[url];
|
|
720
|
-
if (load && !source)
|
|
721
|
-
return load;
|
|
722
|
-
|
|
723
|
-
load = {
|
|
724
|
-
// url
|
|
725
|
-
u: url,
|
|
726
|
-
// response url
|
|
727
|
-
r: source ? url : undefined,
|
|
728
|
-
// fetchPromise
|
|
729
|
-
f: undefined,
|
|
730
|
-
// source
|
|
731
|
-
S: undefined,
|
|
732
|
-
// linkPromise
|
|
733
|
-
L: undefined,
|
|
734
|
-
// analysis
|
|
735
|
-
a: undefined,
|
|
736
|
-
// deps
|
|
737
|
-
d: undefined,
|
|
738
|
-
// blobUrl
|
|
739
|
-
b: undefined,
|
|
740
|
-
// shellUrl
|
|
741
|
-
s: undefined,
|
|
742
|
-
// needsShim
|
|
743
|
-
n: false,
|
|
744
|
-
// type
|
|
745
|
-
t: null,
|
|
746
|
-
// meta
|
|
747
|
-
m: null
|
|
748
|
-
};
|
|
749
|
-
if (registry[url]) {
|
|
750
|
-
let i = 0;
|
|
751
|
-
while (registry[load.u + ++i]);
|
|
752
|
-
load.u += i;
|
|
753
|
-
}
|
|
754
|
-
registry[load.u] = load;
|
|
755
|
-
|
|
756
|
-
load.f = (async () => {
|
|
757
|
-
if (!source) {
|
|
758
|
-
// preload fetch options override fetch options (race)
|
|
759
|
-
let t;
|
|
760
|
-
({ r: load.r, s: source, t } = await (fetchCache[url] || fetchModule(url, fetchOpts, parent)));
|
|
761
|
-
if (t && !shimMode) {
|
|
762
|
-
if (t === 'css' && !cssModulesEnabled || t === 'json' && !jsonModulesEnabled)
|
|
763
|
-
throw Error(`${t}-modules require <script type="esms-options">{ "polyfillEnable": ["${t}-modules"] }<${''}/script>`);
|
|
764
|
-
if (t === 'css' && !supportsCssAssertions || t === 'json' && !supportsJsonAssertions)
|
|
765
|
-
load.n = true;
|
|
766
|
-
}
|
|
767
|
-
}
|
|
768
|
-
try {
|
|
769
|
-
load.a = parse(source, load.u);
|
|
770
|
-
}
|
|
771
|
-
catch (e) {
|
|
772
|
-
throwError(e);
|
|
773
|
-
load.a = [[], [], false];
|
|
774
|
-
}
|
|
775
|
-
load.S = source;
|
|
776
|
-
return load;
|
|
777
|
-
})();
|
|
778
|
-
|
|
779
|
-
load.L = load.f.then(async () => {
|
|
780
|
-
let childFetchOpts = fetchOpts;
|
|
781
|
-
load.d = (await Promise.all(load.a[0].map(async ({ n, d }) => {
|
|
782
|
-
if (d >= 0 && !supportsDynamicImport || d === -2 && !supportsImportMeta)
|
|
783
|
-
load.n = true;
|
|
784
|
-
if (d !== -1 || !n) return;
|
|
785
|
-
const { r, b } = await resolve(n, load.r || load.u);
|
|
786
|
-
if (b && (!supportsImportMaps || importMapSrcOrLazy))
|
|
787
|
-
load.n = true;
|
|
788
|
-
if (d !== -1) return;
|
|
789
|
-
if (skip && skip(r)) return { b: r };
|
|
790
|
-
if (childFetchOpts.integrity)
|
|
791
|
-
childFetchOpts = Object.assign({}, childFetchOpts, { integrity: undefined });
|
|
792
|
-
return getOrCreateLoad(r, childFetchOpts, load.r).f;
|
|
793
|
-
}))).filter(l => l);
|
|
794
|
-
});
|
|
795
|
-
|
|
796
|
-
return load;
|
|
797
|
-
}
|
|
798
|
-
|
|
799
|
-
function processScriptsAndPreloads (mapsOnly = false) {
|
|
800
|
-
if (!mapsOnly)
|
|
801
|
-
for (const link of document.querySelectorAll(shimMode ? 'link[rel=modulepreload-shim]' : 'link[rel=modulepreload]'))
|
|
802
|
-
processPreload(link);
|
|
803
|
-
for (const script of document.querySelectorAll(shimMode ? 'script[type=importmap-shim]' : 'script[type=importmap]'))
|
|
804
|
-
processImportMap(script);
|
|
805
|
-
if (!mapsOnly)
|
|
806
|
-
for (const script of document.querySelectorAll(shimMode ? 'script[type=module-shim]' : 'script[type=module]'))
|
|
807
|
-
processScript(script);
|
|
808
|
-
}
|
|
809
|
-
|
|
810
|
-
function getFetchOpts (script) {
|
|
811
|
-
const fetchOpts = {};
|
|
812
|
-
if (script.integrity)
|
|
813
|
-
fetchOpts.integrity = script.integrity;
|
|
814
|
-
if (script.referrerpolicy)
|
|
815
|
-
fetchOpts.referrerPolicy = script.referrerpolicy;
|
|
816
|
-
if (script.crossorigin === 'use-credentials')
|
|
817
|
-
fetchOpts.credentials = 'include';
|
|
818
|
-
else if (script.crossorigin === 'anonymous')
|
|
819
|
-
fetchOpts.credentials = 'omit';
|
|
820
|
-
else
|
|
821
|
-
fetchOpts.credentials = 'same-origin';
|
|
822
|
-
return fetchOpts;
|
|
823
|
-
}
|
|
824
|
-
|
|
825
|
-
let lastStaticLoadPromise = Promise.resolve();
|
|
826
|
-
|
|
827
|
-
let domContentLoadedCnt = 1;
|
|
828
|
-
function domContentLoadedCheck () {
|
|
829
|
-
if (--domContentLoadedCnt === 0 && !noLoadEventRetriggers)
|
|
830
|
-
document.dispatchEvent(new Event('DOMContentLoaded'));
|
|
831
|
-
}
|
|
832
|
-
// this should always trigger because we assume es-module-shims is itself a domcontentloaded requirement
|
|
833
|
-
if (hasDocument) {
|
|
834
|
-
document.addEventListener('DOMContentLoaded', async () => {
|
|
835
|
-
await initPromise;
|
|
836
|
-
if (shimMode || !baselinePassthrough)
|
|
837
|
-
domContentLoadedCheck();
|
|
838
|
-
});
|
|
839
|
-
}
|
|
840
|
-
|
|
841
|
-
let readyStateCompleteCnt = 1;
|
|
842
|
-
function readyStateCompleteCheck () {
|
|
843
|
-
if (--readyStateCompleteCnt === 0 && !noLoadEventRetriggers)
|
|
844
|
-
document.dispatchEvent(new Event('readystatechange'));
|
|
845
|
-
}
|
|
846
|
-
|
|
847
|
-
const hasNext = script => script.nextSibling || script.parentNode && hasNext(script.parentNode);
|
|
848
|
-
const epCheck = (script, ready) => script.ep || !ready && (!script.src && !script.innerHTML || !hasNext(script)) || script.getAttribute('noshim') !== null || !(script.ep = true);
|
|
849
|
-
|
|
850
|
-
function processImportMap (script, ready = readyStateCompleteCnt > 0) {
|
|
851
|
-
if (epCheck(script, ready)) return;
|
|
852
|
-
// we dont currently support multiple, external or dynamic imports maps in polyfill mode to match native
|
|
853
|
-
if (script.src) {
|
|
854
|
-
if (!shimMode)
|
|
855
|
-
return;
|
|
856
|
-
setImportMapSrcOrLazy();
|
|
857
|
-
}
|
|
858
|
-
if (acceptingImportMaps) {
|
|
859
|
-
importMapPromise = importMapPromise
|
|
860
|
-
.then(async () => {
|
|
861
|
-
importMap = resolveAndComposeImportMap(script.src ? await (await doFetch(script.src, getFetchOpts(script))).json() : JSON.parse(script.innerHTML), script.src || baseUrl, importMap);
|
|
862
|
-
})
|
|
863
|
-
.catch(e => {
|
|
864
|
-
console.log(e);
|
|
865
|
-
if (e instanceof SyntaxError)
|
|
866
|
-
e = new Error(`Unable to parse import map ${e.message} in: ${script.src || script.innerHTML}`);
|
|
867
|
-
throwError(e);
|
|
868
|
-
});
|
|
869
|
-
if (!shimMode)
|
|
870
|
-
acceptingImportMaps = false;
|
|
871
|
-
}
|
|
872
|
-
}
|
|
873
|
-
|
|
874
|
-
function processScript (script, ready = readyStateCompleteCnt > 0) {
|
|
875
|
-
if (epCheck(script, ready)) return;
|
|
876
|
-
// does this load block readystate complete
|
|
877
|
-
const isBlockingReadyScript = script.getAttribute('async') === null && readyStateCompleteCnt > 0;
|
|
878
|
-
// does this load block DOMContentLoaded
|
|
879
|
-
const isDomContentLoadedScript = domContentLoadedCnt > 0;
|
|
880
|
-
if (isBlockingReadyScript) readyStateCompleteCnt++;
|
|
881
|
-
if (isDomContentLoadedScript) domContentLoadedCnt++;
|
|
882
|
-
const loadPromise = topLevelLoad(script.src || baseUrl, getFetchOpts(script), !script.src && script.innerHTML, !shimMode, isBlockingReadyScript && lastStaticLoadPromise).catch(throwError);
|
|
883
|
-
if (isBlockingReadyScript)
|
|
884
|
-
lastStaticLoadPromise = loadPromise.then(readyStateCompleteCheck);
|
|
885
|
-
if (isDomContentLoadedScript)
|
|
886
|
-
loadPromise.then(domContentLoadedCheck);
|
|
887
|
-
}
|
|
888
|
-
|
|
889
|
-
const fetchCache = {};
|
|
890
|
-
function processPreload (link) {
|
|
891
|
-
if (link.ep) return;
|
|
892
|
-
link.ep = true;
|
|
893
|
-
if (fetchCache[link.href])
|
|
894
|
-
return;
|
|
895
|
-
fetchCache[link.href] = fetchModule(link.href, getFetchOpts(link));
|
|
896
|
-
}
|
|
897
|
-
|
|
898
|
-
})();
|