@wordpress/interactivity-router 2.24.0 → 2.26.0
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/CHANGELOG.md +19 -0
- package/README.md +22 -0
- package/build/assets/dynamic-importmap/fetch.js +60 -0
- package/build/assets/dynamic-importmap/fetch.js.map +1 -0
- package/build/assets/dynamic-importmap/index.js +91 -0
- package/build/assets/dynamic-importmap/index.js.map +1 -0
- package/build/assets/dynamic-importmap/loader.js +286 -0
- package/build/assets/dynamic-importmap/loader.js.map +1 -0
- package/build/assets/dynamic-importmap/resolver.js +220 -0
- package/build/assets/dynamic-importmap/resolver.js.map +1 -0
- package/build/assets/script-modules.js +64 -0
- package/build/assets/script-modules.js.map +1 -0
- package/build/assets/scs.js +62 -0
- package/build/assets/scs.js.map +1 -0
- package/build/assets/styles.js +246 -0
- package/build/assets/styles.js.map +1 -0
- package/build/full-page.js +43 -0
- package/build/full-page.js.map +1 -0
- package/build/index.js +141 -112
- package/build/index.js.map +1 -1
- package/build-module/assets/dynamic-importmap/fetch.js +54 -0
- package/build-module/assets/dynamic-importmap/fetch.js.map +1 -0
- package/build-module/assets/dynamic-importmap/index.js +72 -0
- package/build-module/assets/dynamic-importmap/index.js.map +1 -0
- package/build-module/assets/dynamic-importmap/loader.js +279 -0
- package/build-module/assets/dynamic-importmap/loader.js.map +1 -0
- package/build-module/assets/dynamic-importmap/resolver.js +213 -0
- package/build-module/assets/dynamic-importmap/resolver.js.map +1 -0
- package/build-module/assets/script-modules.js +55 -0
- package/build-module/assets/script-modules.js.map +1 -0
- package/build-module/assets/scs.js +56 -0
- package/build-module/assets/scs.js.map +1 -0
- package/build-module/assets/styles.js +235 -0
- package/build-module/assets/styles.js.map +1 -0
- package/build-module/full-page.js +39 -0
- package/build-module/full-page.js.map +1 -0
- package/build-module/index.js +138 -107
- package/build-module/index.js.map +1 -1
- package/build-types/assets/dynamic-importmap/fetch.d.ts +30 -0
- package/build-types/assets/dynamic-importmap/fetch.d.ts.map +1 -0
- package/build-types/assets/dynamic-importmap/index.d.ts +42 -0
- package/build-types/assets/dynamic-importmap/index.d.ts.map +1 -0
- package/build-types/assets/dynamic-importmap/loader.d.ts +68 -0
- package/build-types/assets/dynamic-importmap/loader.d.ts.map +1 -0
- package/build-types/assets/dynamic-importmap/resolver.d.ts +35 -0
- package/build-types/assets/dynamic-importmap/resolver.d.ts.map +1 -0
- package/build-types/assets/script-modules.d.ts +26 -0
- package/build-types/assets/script-modules.d.ts.map +1 -0
- package/build-types/assets/scs.d.ts +24 -0
- package/build-types/assets/scs.d.ts.map +1 -0
- package/build-types/assets/styles.d.ts +69 -0
- package/build-types/assets/styles.d.ts.map +1 -0
- package/build-types/full-page.d.ts +3 -0
- package/build-types/full-page.d.ts.map +1 -0
- package/build-types/index.d.ts +4 -5
- package/build-types/index.d.ts.map +1 -1
- package/package.json +9 -5
- package/src/assets/dynamic-importmap/fetch.ts +58 -0
- package/src/assets/dynamic-importmap/index.ts +87 -0
- package/src/assets/dynamic-importmap/loader.ts +366 -0
- package/src/assets/dynamic-importmap/resolver.ts +292 -0
- package/src/assets/script-modules.ts +69 -0
- package/src/assets/scs.ts +61 -0
- package/src/assets/styles.ts +272 -0
- package/src/assets/test/scs.test.ts +367 -0
- package/src/assets/test/styles.test.ts +758 -0
- package/src/full-page.ts +53 -0
- package/src/index.ts +160 -135
- package/tsconfig.full-page.json +12 -0
- package/tsconfig.full-page.tsbuildinfo +1 -0
- package/tsconfig.json +9 -4
- package/tsconfig.main.json +21 -0
- package/tsconfig.main.tsbuildinfo +1 -0
- package/build/head.js +0 -113
- package/build/head.js.map +0 -1
- package/build-module/head.js +0 -103
- package/build-module/head.js.map +0 -1
- package/build-types/head.d.ts +0 -24
- package/build-types/head.d.ts.map +0 -1
- package/src/head.ts +0 -126
- package/tsconfig.tsbuildinfo +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["fetching","url","parent","jsContentType","fetchModule","fetchOpts","res","fetch","e","Error","ok","status","contentType","headers","get","test","responseUrl","source","text"],"sources":["@wordpress/interactivity-router/src/assets/dynamic-importmap/fetch.ts"],"sourcesContent":["/**\n * This code is derived from the following projects:\n *\n * 1. dynamic-importmap (https://github.com/keller-mark/dynamic-importmap)\n * 2. es-module-shims (https://github.com/guybedford/es-module-shims)\n *\n * The original implementation was created by Guy Bedford in es-module-shims,\n * then adapted by Mark Keller in dynamic-importmap, and further modified\n * for use in this project.\n *\n * Both projects are licensed under the MIT license.\n *\n * MIT License: https://opensource.org/licenses/MIT\n */\n\n/**\n * Internal dependencies\n */\nimport { type ModuleLoad } from './loader';\n\nconst fetching = ( url: string, parent?: string ) => {\n\treturn ` fetching ${ url }${ parent ? ` from ${ parent }` : '' }`;\n};\n\nconst jsContentType = /^(text|application)\\/(x-)?javascript(;|$)/;\n\n/**\n * Fetches the passed module URL and return the corresponding `ModuleLoad`\n * instance. If the passed URL does not point to a JS file, the function\n * throws and error.\n *\n * @param url Module URL.\n * @param fetchOpts Fetch init options.\n * @param parent Parent module URL referencing this URL (if any).\n * @return Promise with a `ModuleLoad` instance.\n */\nexport async function fetchModule(\n\turl: string,\n\tfetchOpts: RequestInit,\n\tparent: string\n): Promise< ModuleLoad > {\n\tlet res: Response;\n\ttry {\n\t\tres = await fetch( url, fetchOpts );\n\t} catch ( e ) {\n\t\tthrow Error( `Network error${ fetching( url, parent ) }.` );\n\t}\n\tif ( ! res.ok ) {\n\t\tthrow Error( `Error ${ res.status }${ fetching( url, parent ) }.` );\n\t}\n\tconst contentType = res.headers.get( 'content-type' );\n\tif ( ! jsContentType.test( contentType ) ) {\n\t\tthrow Error(\n\t\t\t`Bad Content-Type \"${ contentType }\"${ fetching( url, parent ) }.`\n\t\t);\n\t}\n\treturn { responseUrl: res.url, source: await res.text() };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAGA,MAAMA,QAAQ,GAAGA,CAAEC,GAAW,EAAEC,MAAe,KAAM;EACpD,OAAO,aAAcD,GAAG,GAAKC,MAAM,GAAG,SAAUA,MAAM,EAAG,GAAG,EAAE,EAAG;AAClE,CAAC;AAED,MAAMC,aAAa,GAAG,2CAA2C;;AAEjE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,WAAWA,CAChCH,GAAW,EACXI,SAAsB,EACtBH,MAAc,EACU;EACxB,IAAII,GAAa;EACjB,IAAI;IACHA,GAAG,GAAG,MAAMC,KAAK,CAAEN,GAAG,EAAEI,SAAU,CAAC;EACpC,CAAC,CAAC,OAAQG,CAAC,EAAG;IACb,MAAMC,KAAK,CAAE,gBAAiBT,QAAQ,CAAEC,GAAG,EAAEC,MAAO,CAAC,GAAK,CAAC;EAC5D;EACA,IAAK,CAAEI,GAAG,CAACI,EAAE,EAAG;IACf,MAAMD,KAAK,CAAE,SAAUH,GAAG,CAACK,MAAM,GAAKX,QAAQ,CAAEC,GAAG,EAAEC,MAAO,CAAC,GAAK,CAAC;EACpE;EACA,MAAMU,WAAW,GAAGN,GAAG,CAACO,OAAO,CAACC,GAAG,CAAE,cAAe,CAAC;EACrD,IAAK,CAAEX,aAAa,CAACY,IAAI,CAAEH,WAAY,CAAC,EAAG;IAC1C,MAAMH,KAAK,CACV,qBAAsBG,WAAW,IAAMZ,QAAQ,CAAEC,GAAG,EAAEC,MAAO,CAAC,GAC/D,CAAC;EACF;EACA,OAAO;IAAEc,WAAW,EAAEV,GAAG,CAACL,GAAG;IAAEgB,MAAM,EAAE,MAAMX,GAAG,CAACY,IAAI,CAAC;EAAE,CAAC;AAC1D","ignoreList":[]}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code is derived from the following projects:
|
|
3
|
+
*
|
|
4
|
+
* 1. dynamic-importmap (https://github.com/keller-mark/dynamic-importmap)
|
|
5
|
+
* 2. es-module-shims (https://github.com/guybedford/es-module-shims)
|
|
6
|
+
*
|
|
7
|
+
* The original implementation was created by Guy Bedford in es-module-shims,
|
|
8
|
+
* then adapted by Mark Keller in dynamic-importmap, and further modified
|
|
9
|
+
* for use in this project.
|
|
10
|
+
*
|
|
11
|
+
* Both projects are licensed under the MIT license.
|
|
12
|
+
*
|
|
13
|
+
* MIT License: https://opensource.org/licenses/MIT
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Internal dependencies
|
|
18
|
+
*/
|
|
19
|
+
import { addImportMap, resolve } from './resolver';
|
|
20
|
+
import { initPromise, topLevelLoad, preloadModule } from './loader';
|
|
21
|
+
// TODO: check if this baseURI should change per document, and so
|
|
22
|
+
// it need to be passed as a parameter to methods like `importWithMap`
|
|
23
|
+
// and `preloadWithMap`.
|
|
24
|
+
const baseUrl = document.baseURI;
|
|
25
|
+
const pageBaseUrl = baseUrl;
|
|
26
|
+
Object.defineProperty(self, 'wpInteractivityRouterImport', {
|
|
27
|
+
value: importShim,
|
|
28
|
+
writable: false,
|
|
29
|
+
enumerable: false,
|
|
30
|
+
configurable: false
|
|
31
|
+
});
|
|
32
|
+
async function importShim(id) {
|
|
33
|
+
await initPromise;
|
|
34
|
+
return topLevelLoad(resolve(id, pageBaseUrl), {
|
|
35
|
+
credentials: 'same-origin'
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Imports the module with the passed ID.
|
|
41
|
+
*
|
|
42
|
+
* The module is resolved against the internal dynamic import map,
|
|
43
|
+
* extended with the passed import map.
|
|
44
|
+
*
|
|
45
|
+
* @param id Module ID.
|
|
46
|
+
* @param importMapIn Import map.
|
|
47
|
+
* @return Resolved module.
|
|
48
|
+
*/
|
|
49
|
+
export async function importWithMap(id, importMapIn) {
|
|
50
|
+
addImportMap(importMapIn);
|
|
51
|
+
return importShim(id);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Preloads the module with the passed ID along with its dependencies.
|
|
56
|
+
*
|
|
57
|
+
* The module is resolved against the internal dynamic import map,
|
|
58
|
+
* extended with the passed import map.
|
|
59
|
+
*
|
|
60
|
+
* @param id Module ID.
|
|
61
|
+
* @param importMapIn Import map.
|
|
62
|
+
* @return Resolved `ModuleLoad` instance.
|
|
63
|
+
*/
|
|
64
|
+
export async function preloadWithMap(id, importMapIn) {
|
|
65
|
+
addImportMap(importMapIn);
|
|
66
|
+
await initPromise;
|
|
67
|
+
return preloadModule(resolve(id, pageBaseUrl), {
|
|
68
|
+
credentials: 'same-origin'
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
export { initialImportMap, importPreloadedModule } from './loader';
|
|
72
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["addImportMap","resolve","initPromise","topLevelLoad","preloadModule","baseUrl","document","baseURI","pageBaseUrl","Object","defineProperty","self","value","importShim","writable","enumerable","configurable","id","credentials","importWithMap","importMapIn","preloadWithMap","initialImportMap","importPreloadedModule"],"sources":["@wordpress/interactivity-router/src/assets/dynamic-importmap/index.ts"],"sourcesContent":["/**\n * This code is derived from the following projects:\n *\n * 1. dynamic-importmap (https://github.com/keller-mark/dynamic-importmap)\n * 2. es-module-shims (https://github.com/guybedford/es-module-shims)\n *\n * The original implementation was created by Guy Bedford in es-module-shims,\n * then adapted by Mark Keller in dynamic-importmap, and further modified\n * for use in this project.\n *\n * Both projects are licensed under the MIT license.\n *\n * MIT License: https://opensource.org/licenses/MIT\n */\n\n/**\n * Internal dependencies\n */\nimport { addImportMap, resolve } from './resolver';\nimport { initPromise, topLevelLoad, preloadModule } from './loader';\n\ntype ImportMap = {\n\timports?: Record< string, string >;\n\tscopes?: Record< string, Record< string, string > >;\n};\n\n// TODO: check if this baseURI should change per document, and so\n// it need to be passed as a parameter to methods like `importWithMap`\n// and `preloadWithMap`.\nconst baseUrl = document.baseURI;\nconst pageBaseUrl = baseUrl;\n\nObject.defineProperty( self, 'wpInteractivityRouterImport', {\n\tvalue: importShim,\n\twritable: false,\n\tenumerable: false,\n\tconfigurable: false,\n} );\n\nasync function importShim< Module = unknown >( id: string ) {\n\tawait initPromise;\n\treturn topLevelLoad< Module >( resolve( id, pageBaseUrl ), {\n\t\tcredentials: 'same-origin',\n\t} );\n}\n\n/**\n * Imports the module with the passed ID.\n *\n * The module is resolved against the internal dynamic import map,\n * extended with the passed import map.\n *\n * @param id Module ID.\n * @param importMapIn Import map.\n * @return Resolved module.\n */\nexport async function importWithMap< Module = unknown >(\n\tid: string,\n\timportMapIn: ImportMap\n) {\n\taddImportMap( importMapIn );\n\treturn importShim< Module >( id );\n}\n\n/**\n * Preloads the module with the passed ID along with its dependencies.\n *\n * The module is resolved against the internal dynamic import map,\n * extended with the passed import map.\n *\n * @param id Module ID.\n * @param importMapIn Import map.\n * @return Resolved `ModuleLoad` instance.\n */\nexport async function preloadWithMap( id: string, importMapIn: ImportMap ) {\n\taddImportMap( importMapIn );\n\tawait initPromise;\n\treturn preloadModule( resolve( id, pageBaseUrl ), {\n\t\tcredentials: 'same-origin',\n\t} );\n}\n\nexport {\n\tinitialImportMap,\n\timportPreloadedModule,\n\ttype ModuleLoad,\n} from './loader';\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,SAASA,YAAY,EAAEC,OAAO,QAAQ,YAAY;AAClD,SAASC,WAAW,EAAEC,YAAY,EAAEC,aAAa,QAAQ,UAAU;AAOnE;AACA;AACA;AACA,MAAMC,OAAO,GAAGC,QAAQ,CAACC,OAAO;AAChC,MAAMC,WAAW,GAAGH,OAAO;AAE3BI,MAAM,CAACC,cAAc,CAAEC,IAAI,EAAE,6BAA6B,EAAE;EAC3DC,KAAK,EAAEC,UAAU;EACjBC,QAAQ,EAAE,KAAK;EACfC,UAAU,EAAE,KAAK;EACjBC,YAAY,EAAE;AACf,CAAE,CAAC;AAEH,eAAeH,UAAUA,CAAsBI,EAAU,EAAG;EAC3D,MAAMf,WAAW;EACjB,OAAOC,YAAY,CAAYF,OAAO,CAAEgB,EAAE,EAAET,WAAY,CAAC,EAAE;IAC1DU,WAAW,EAAE;EACd,CAAE,CAAC;AACJ;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,aAAaA,CAClCF,EAAU,EACVG,WAAsB,EACrB;EACDpB,YAAY,CAAEoB,WAAY,CAAC;EAC3B,OAAOP,UAAU,CAAYI,EAAG,CAAC;AAClC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeI,cAAcA,CAAEJ,EAAU,EAAEG,WAAsB,EAAG;EAC1EpB,YAAY,CAAEoB,WAAY,CAAC;EAC3B,MAAMlB,WAAW;EACjB,OAAOE,aAAa,CAAEH,OAAO,CAAEgB,EAAE,EAAET,WAAY,CAAC,EAAE;IACjDU,WAAW,EAAE;EACd,CAAE,CAAC;AACJ;AAEA,SACCI,gBAAgB,EAChBC,qBAAqB,QAEf,UAAU","ignoreList":[]}
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
/* wp:polyfill */
|
|
2
|
+
/**
|
|
3
|
+
* This code is derived from the following projects:
|
|
4
|
+
*
|
|
5
|
+
* 1. dynamic-importmap (https://github.com/keller-mark/dynamic-importmap)
|
|
6
|
+
* 2. es-module-shims (https://github.com/guybedford/es-module-shims)
|
|
7
|
+
*
|
|
8
|
+
* The original implementation was created by Guy Bedford in es-module-shims,
|
|
9
|
+
* then adapted by Mark Keller in dynamic-importmap, and further modified
|
|
10
|
+
* for use in this project.
|
|
11
|
+
*
|
|
12
|
+
* Both projects are licensed under the MIT license.
|
|
13
|
+
*
|
|
14
|
+
* MIT License: https://opensource.org/licenses/MIT
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* External dependencies
|
|
19
|
+
*/
|
|
20
|
+
import * as lexer from 'es-module-lexer';
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Internal dependencies
|
|
24
|
+
*/
|
|
25
|
+
import { fetchModule } from './fetch';
|
|
26
|
+
import { resolve } from './resolver';
|
|
27
|
+
export const initPromise = lexer.init;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Script element containing the initial page's import map.
|
|
31
|
+
*/
|
|
32
|
+
const initialImportMapElement = window.document.querySelector('script#wp-importmap[type=importmap]');
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Data from the initial page's import map.
|
|
36
|
+
*
|
|
37
|
+
* Pages containing any of the imports present on the original page
|
|
38
|
+
* in their import maps should ignore them, as those imports would
|
|
39
|
+
* be handled natively.
|
|
40
|
+
*/
|
|
41
|
+
export const initialImportMap = initialImportMapElement ? JSON.parse(initialImportMapElement.text) : {
|
|
42
|
+
imports: {},
|
|
43
|
+
scopes: {}
|
|
44
|
+
};
|
|
45
|
+
const skip = id => Object.keys(initialImportMap.imports).includes(id);
|
|
46
|
+
const fetchCache = {};
|
|
47
|
+
export const registry = {};
|
|
48
|
+
|
|
49
|
+
// Init registry with importamp content.
|
|
50
|
+
Object.keys(initialImportMap.imports).forEach(id => {
|
|
51
|
+
registry[id] = {
|
|
52
|
+
blobUrl: id
|
|
53
|
+
};
|
|
54
|
+
});
|
|
55
|
+
async function loadAll(load, seen) {
|
|
56
|
+
if (load.blobUrl || seen[load.url]) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
seen[load.url] = 1;
|
|
60
|
+
await load.linkPromise;
|
|
61
|
+
await Promise.all(load.deps.map(dep => loadAll(dep, seen)));
|
|
62
|
+
}
|
|
63
|
+
function urlJsString(url) {
|
|
64
|
+
return `'${url.replace(/'/g, "\\'")}'`;
|
|
65
|
+
}
|
|
66
|
+
const createBlob = (source, type = 'text/javascript') => URL.createObjectURL(new Blob([source], {
|
|
67
|
+
type
|
|
68
|
+
}));
|
|
69
|
+
function resolveDeps(load, seen) {
|
|
70
|
+
if (load.blobUrl || !seen[load.url]) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
seen[load.url] = 0;
|
|
74
|
+
for (const dep of load.deps) {
|
|
75
|
+
resolveDeps(dep, seen);
|
|
76
|
+
}
|
|
77
|
+
const [imports, exports] = load.analysis;
|
|
78
|
+
const source = load.source;
|
|
79
|
+
let resolvedSource = '';
|
|
80
|
+
if (!imports.length) {
|
|
81
|
+
resolvedSource += source;
|
|
82
|
+
} else {
|
|
83
|
+
let lastIndex = 0;
|
|
84
|
+
let depIndex = 0;
|
|
85
|
+
const dynamicImportEndStack = [];
|
|
86
|
+
function pushStringTo(originalIndex) {
|
|
87
|
+
while (dynamicImportEndStack.length && dynamicImportEndStack[dynamicImportEndStack.length - 1] < originalIndex) {
|
|
88
|
+
const dynamicImportEnd = dynamicImportEndStack.pop();
|
|
89
|
+
resolvedSource += `${source.slice(lastIndex, dynamicImportEnd)}, ${urlJsString(load.responseUrl)}`;
|
|
90
|
+
lastIndex = dynamicImportEnd;
|
|
91
|
+
}
|
|
92
|
+
resolvedSource += source.slice(lastIndex, originalIndex);
|
|
93
|
+
lastIndex = originalIndex;
|
|
94
|
+
}
|
|
95
|
+
for (const {
|
|
96
|
+
s: start,
|
|
97
|
+
ss: statementStart,
|
|
98
|
+
se: statementEnd,
|
|
99
|
+
d: dynamicImportIndex
|
|
100
|
+
} of imports) {
|
|
101
|
+
// static import
|
|
102
|
+
if (dynamicImportIndex === -1) {
|
|
103
|
+
const depLoad = load.deps[depIndex++];
|
|
104
|
+
let blobUrl = depLoad.blobUrl;
|
|
105
|
+
const cycleShell = !blobUrl;
|
|
106
|
+
if (cycleShell) {
|
|
107
|
+
// Circular shell creation
|
|
108
|
+
if (!(blobUrl = depLoad.shellUrl)) {
|
|
109
|
+
blobUrl = depLoad.shellUrl = createBlob(`export function u$_(m){${depLoad.analysis[1].map(({
|
|
110
|
+
s,
|
|
111
|
+
e
|
|
112
|
+
}, i) => {
|
|
113
|
+
const q = depLoad.source[s] === '"' || depLoad.source[s] === "'";
|
|
114
|
+
return `e$_${i}=m${q ? `[` : '.'}${depLoad.source.slice(s, e)}${q ? `]` : ''}`;
|
|
115
|
+
}).join(',')}}${depLoad.analysis[1].length ? `let ${depLoad.analysis[1].map((_, i) => `e$_${i}`).join(',')};` : ''}export {${depLoad.analysis[1].map(({
|
|
116
|
+
s,
|
|
117
|
+
e
|
|
118
|
+
}, i) => `e$_${i} as ${depLoad.source.slice(s, e)}`).join(',')}}\n//# sourceURL=${depLoad.responseUrl}?cycle`);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
pushStringTo(start - 1);
|
|
122
|
+
resolvedSource += `/*${source.slice(start - 1, statementEnd)}*/${urlJsString(blobUrl)}`;
|
|
123
|
+
|
|
124
|
+
// circular shell execution
|
|
125
|
+
if (!cycleShell && depLoad.shellUrl) {
|
|
126
|
+
resolvedSource += `;import*as m$_${depIndex} from'${depLoad.blobUrl}';import{u$_ as u$_${depIndex}}from'${depLoad.shellUrl}';u$_${depIndex}(m$_${depIndex})`;
|
|
127
|
+
depLoad.shellUrl = undefined;
|
|
128
|
+
}
|
|
129
|
+
lastIndex = statementEnd;
|
|
130
|
+
}
|
|
131
|
+
// import.meta
|
|
132
|
+
else if (dynamicImportIndex === -2) {
|
|
133
|
+
throw Error('The import.meta property is not supported.');
|
|
134
|
+
}
|
|
135
|
+
// dynamic import
|
|
136
|
+
else {
|
|
137
|
+
pushStringTo(statementStart);
|
|
138
|
+
resolvedSource += `wpInteractivityRouterImport(`;
|
|
139
|
+
dynamicImportEndStack.push(statementEnd - 1);
|
|
140
|
+
lastIndex = start;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// progressive cycle binding updates
|
|
145
|
+
if (load.shellUrl) {
|
|
146
|
+
resolvedSource += `\n;import{u$_}from'${load.shellUrl}';try{u$_({${exports.filter(e => e.ln).map(({
|
|
147
|
+
s,
|
|
148
|
+
e,
|
|
149
|
+
ln
|
|
150
|
+
}) => `${source.slice(s, e)}:${ln}`).join(',')}})}catch(_){};\n`;
|
|
151
|
+
}
|
|
152
|
+
pushStringTo(source.length);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// ensure we have a proper sourceURL
|
|
156
|
+
let hasSourceURL = false;
|
|
157
|
+
resolvedSource = resolvedSource.replace(sourceMapURLRegEx, (match, isMapping, url) => {
|
|
158
|
+
hasSourceURL = !isMapping;
|
|
159
|
+
return match.replace(url, () => new URL(url, load.responseUrl).toString());
|
|
160
|
+
});
|
|
161
|
+
if (!hasSourceURL) {
|
|
162
|
+
resolvedSource += '\n//# sourceURL=' + load.responseUrl;
|
|
163
|
+
}
|
|
164
|
+
load.blobUrl = createBlob(resolvedSource);
|
|
165
|
+
load.source = undefined; // free memory
|
|
166
|
+
}
|
|
167
|
+
const sourceMapURLRegEx = /\n\/\/# source(Mapping)?URL=([^\n]+)\s*((;|\/\/[^#][^\n]*)\s*)*$/;
|
|
168
|
+
function getOrCreateLoad(url, fetchOpts, parent) {
|
|
169
|
+
let load = registry[url];
|
|
170
|
+
if (load) {
|
|
171
|
+
return load;
|
|
172
|
+
}
|
|
173
|
+
load = {
|
|
174
|
+
url
|
|
175
|
+
};
|
|
176
|
+
if (registry[url]) {
|
|
177
|
+
// If there's a naming conflict, keep incrementing until unique
|
|
178
|
+
let i = 0;
|
|
179
|
+
while (registry[load.url + ++i]) {
|
|
180
|
+
/* no-op */
|
|
181
|
+
}
|
|
182
|
+
load.url += i;
|
|
183
|
+
}
|
|
184
|
+
registry[load.url] = load;
|
|
185
|
+
load.fetchPromise = (async () => {
|
|
186
|
+
let source;
|
|
187
|
+
({
|
|
188
|
+
responseUrl: load.responseUrl,
|
|
189
|
+
source: source
|
|
190
|
+
} = await (fetchCache[url] || fetchModule(url, fetchOpts, parent)));
|
|
191
|
+
try {
|
|
192
|
+
load.analysis = lexer.parse(source, load.url);
|
|
193
|
+
} catch (e) {
|
|
194
|
+
// eslint-disable-next-line no-console
|
|
195
|
+
console.error(e);
|
|
196
|
+
load.analysis = [[], [], false, false];
|
|
197
|
+
}
|
|
198
|
+
load.source = source;
|
|
199
|
+
return load;
|
|
200
|
+
})();
|
|
201
|
+
load.linkPromise = load.fetchPromise.then(async () => {
|
|
202
|
+
let childFetchOpts = fetchOpts;
|
|
203
|
+
load.deps = (await Promise.all(load.analysis[0].map(async ({
|
|
204
|
+
n,
|
|
205
|
+
d
|
|
206
|
+
}) => {
|
|
207
|
+
if (d !== -1 || !n) {
|
|
208
|
+
return undefined;
|
|
209
|
+
}
|
|
210
|
+
const responseUrl = resolve(n, load.responseUrl || load.url);
|
|
211
|
+
if (skip && skip(responseUrl)) {
|
|
212
|
+
return {
|
|
213
|
+
blobUrl: responseUrl
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
// remove integrity for child fetches
|
|
217
|
+
if (childFetchOpts.integrity) {
|
|
218
|
+
childFetchOpts = {
|
|
219
|
+
...childFetchOpts,
|
|
220
|
+
integrity: undefined
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
return getOrCreateLoad(responseUrl, childFetchOpts, load.responseUrl).fetchPromise;
|
|
224
|
+
}))).filter(l => l);
|
|
225
|
+
});
|
|
226
|
+
return load;
|
|
227
|
+
}
|
|
228
|
+
const dynamicImport = u => import(/* webpackIgnore: true */u);
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Resolves the passed module URL and fetches the corresponding module
|
|
232
|
+
* and their dependencies, returning a `ModuleLoad` object once all
|
|
233
|
+
* of them have been fetched.
|
|
234
|
+
*
|
|
235
|
+
* @param url Module URL.
|
|
236
|
+
* @param fetchOpts Fetch options.
|
|
237
|
+
* @return A promise with a `ModuleLoad` instance.
|
|
238
|
+
*/
|
|
239
|
+
export async function preloadModule(url, fetchOpts) {
|
|
240
|
+
await initPromise;
|
|
241
|
+
const load = getOrCreateLoad(url, fetchOpts, null);
|
|
242
|
+
const seen = {};
|
|
243
|
+
await loadAll(load, seen);
|
|
244
|
+
resolveDeps(load, seen);
|
|
245
|
+
// microtask scheduling – can help ensure Blob is fully ready
|
|
246
|
+
await Promise.resolve();
|
|
247
|
+
return load;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Imports the module represented by the passed `ModuleLoad` instance.
|
|
252
|
+
*
|
|
253
|
+
* @param load The `ModuleLoad` instance representing the module.
|
|
254
|
+
* @return A promise with the imported module.
|
|
255
|
+
*/
|
|
256
|
+
export async function importPreloadedModule(load) {
|
|
257
|
+
const module = await dynamicImport(load.blobUrl);
|
|
258
|
+
// if the preloaded module ended up with a shell (circular refs), finalize it
|
|
259
|
+
if (load.shellUrl) {
|
|
260
|
+
(await dynamicImport(load.shellUrl)).u$_(module);
|
|
261
|
+
}
|
|
262
|
+
return module;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Imports the module represented by the passed module URL.
|
|
267
|
+
*
|
|
268
|
+
* The module URL and all its dependencies are resolved using the
|
|
269
|
+
* current status of the internal dynamic import map.
|
|
270
|
+
*
|
|
271
|
+
* @param url Module URL.
|
|
272
|
+
* @param fetchOpts Fetch options.
|
|
273
|
+
* @return A promise with the imported module.
|
|
274
|
+
*/
|
|
275
|
+
export async function topLevelLoad(url, fetchOpts) {
|
|
276
|
+
const load = await preloadModule(url, fetchOpts);
|
|
277
|
+
return importPreloadedModule(load);
|
|
278
|
+
}
|
|
279
|
+
//# sourceMappingURL=loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["lexer","fetchModule","resolve","initPromise","init","initialImportMapElement","window","document","querySelector","initialImportMap","JSON","parse","text","imports","scopes","skip","id","Object","keys","includes","fetchCache","registry","forEach","blobUrl","loadAll","load","seen","url","linkPromise","Promise","all","deps","map","dep","urlJsString","replace","createBlob","source","type","URL","createObjectURL","Blob","resolveDeps","exports","analysis","resolvedSource","length","lastIndex","depIndex","dynamicImportEndStack","pushStringTo","originalIndex","dynamicImportEnd","pop","slice","responseUrl","s","start","ss","statementStart","se","statementEnd","d","dynamicImportIndex","depLoad","cycleShell","shellUrl","e","i","q","join","_","undefined","Error","push","filter","ln","hasSourceURL","sourceMapURLRegEx","match","isMapping","toString","getOrCreateLoad","fetchOpts","parent","fetchPromise","console","error","then","childFetchOpts","n","integrity","l","dynamicImport","u","preloadModule","importPreloadedModule","module","u$_","topLevelLoad"],"sources":["@wordpress/interactivity-router/src/assets/dynamic-importmap/loader.ts"],"sourcesContent":["/**\n * This code is derived from the following projects:\n *\n * 1. dynamic-importmap (https://github.com/keller-mark/dynamic-importmap)\n * 2. es-module-shims (https://github.com/guybedford/es-module-shims)\n *\n * The original implementation was created by Guy Bedford in es-module-shims,\n * then adapted by Mark Keller in dynamic-importmap, and further modified\n * for use in this project.\n *\n * Both projects are licensed under the MIT license.\n *\n * MIT License: https://opensource.org/licenses/MIT\n */\n\n/**\n * External dependencies\n */\nimport * as lexer from 'es-module-lexer';\n\n/**\n * Internal dependencies\n */\nimport { fetchModule } from './fetch';\nimport { resolve } from './resolver';\n\nexport interface ModuleLoad {\n\turl?: string; // original URL\n\tresponseUrl?: string; // response url\n\tfetchPromise?: Promise< ModuleLoad >; // fetch promise\n\tsource?: string; // source code\n\tlinkPromise?: Promise< void >; // link-promise (dependency fetch)\n\tanalysis?: ReturnType< typeof lexer.parse >; // analysis ([ imports, exports, ... ])\n\tdeps?: ModuleLoad[]; // deps\n\tblobUrl?: string; // blobUrl\n\tshellUrl?: string; // shellUrl for circular references\n}\n\nexport const initPromise = lexer.init;\n\n/**\n * Script element containing the initial page's import map.\n */\nconst initialImportMapElement =\n\twindow.document.querySelector< HTMLScriptElement >(\n\t\t'script#wp-importmap[type=importmap]'\n\t);\n\n/**\n * Data from the initial page's import map.\n *\n * Pages containing any of the imports present on the original page\n * in their import maps should ignore them, as those imports would\n * be handled natively.\n */\nexport const initialImportMap = initialImportMapElement\n\t? JSON.parse( initialImportMapElement.text )\n\t: { imports: {}, scopes: {} };\n\nconst skip = ( id ) => Object.keys( initialImportMap.imports ).includes( id );\n\nconst fetchCache: Record< string, Promise< ModuleLoad > > = {};\nexport const registry = {};\n\n// Init registry with importamp content.\nObject.keys( initialImportMap.imports ).forEach( ( id ) => {\n\tregistry[ id ] = {\n\t\tblobUrl: id,\n\t};\n} );\n\nasync function loadAll( load: ModuleLoad, seen: Record< string, any > ) {\n\tif ( load.blobUrl || seen[ load.url ] ) {\n\t\treturn;\n\t}\n\tseen[ load.url ] = 1;\n\tawait load.linkPromise;\n\tawait Promise.all( load.deps.map( ( dep ) => loadAll( dep, seen ) ) );\n}\n\nfunction urlJsString( url: string ) {\n\treturn `'${ url.replace( /'/g, \"\\\\'\" ) }'`;\n}\n\nconst createBlob = ( source: string, type = 'text/javascript' ) =>\n\tURL.createObjectURL( new Blob( [ source ], { type } ) );\n\nfunction resolveDeps( load: ModuleLoad, seen: Record< string, any > ) {\n\tif ( load.blobUrl || ! seen[ load.url ] ) {\n\t\treturn;\n\t}\n\tseen[ load.url ] = 0;\n\n\tfor ( const dep of load.deps ) {\n\t\tresolveDeps( dep, seen );\n\t}\n\n\tconst [ imports, exports ] = load.analysis;\n\tconst source = load.source;\n\n\tlet resolvedSource = '';\n\n\tif ( ! imports.length ) {\n\t\tresolvedSource += source;\n\t} else {\n\t\tlet lastIndex = 0;\n\t\tlet depIndex = 0;\n\t\tconst dynamicImportEndStack = [];\n\n\t\tfunction pushStringTo( originalIndex: number ) {\n\t\t\twhile (\n\t\t\t\tdynamicImportEndStack.length &&\n\t\t\t\tdynamicImportEndStack[ dynamicImportEndStack.length - 1 ] <\n\t\t\t\t\toriginalIndex\n\t\t\t) {\n\t\t\t\tconst dynamicImportEnd = dynamicImportEndStack.pop();\n\t\t\t\tresolvedSource += `${ source.slice(\n\t\t\t\t\tlastIndex,\n\t\t\t\t\tdynamicImportEnd\n\t\t\t\t) }, ${ urlJsString( load.responseUrl ) }`;\n\t\t\t\tlastIndex = dynamicImportEnd;\n\t\t\t}\n\t\t\tresolvedSource += source.slice( lastIndex, originalIndex );\n\t\t\tlastIndex = originalIndex;\n\t\t}\n\n\t\tfor ( const {\n\t\t\ts: start,\n\t\t\tss: statementStart,\n\t\t\tse: statementEnd,\n\t\t\td: dynamicImportIndex,\n\t\t} of imports ) {\n\t\t\t// static import\n\t\t\tif ( dynamicImportIndex === -1 ) {\n\t\t\t\tconst depLoad = load.deps[ depIndex++ ];\n\t\t\t\tlet blobUrl = depLoad.blobUrl;\n\t\t\t\tconst cycleShell = ! blobUrl;\n\t\t\t\tif ( cycleShell ) {\n\t\t\t\t\t// Circular shell creation\n\t\t\t\t\tif ( ! ( blobUrl = depLoad.shellUrl ) ) {\n\t\t\t\t\t\tblobUrl = depLoad.shellUrl = createBlob(\n\t\t\t\t\t\t\t`export function u$_(m){${ depLoad.analysis[ 1 ]\n\t\t\t\t\t\t\t\t.map( ( { s, e }, i ) => {\n\t\t\t\t\t\t\t\t\tconst q =\n\t\t\t\t\t\t\t\t\t\tdepLoad.source[ s ] === '\"' ||\n\t\t\t\t\t\t\t\t\t\tdepLoad.source[ s ] === \"'\";\n\t\t\t\t\t\t\t\t\treturn `e$_${ i }=m${\n\t\t\t\t\t\t\t\t\t\tq ? `[` : '.'\n\t\t\t\t\t\t\t\t\t}${ depLoad.source.slice( s, e ) }${\n\t\t\t\t\t\t\t\t\t\tq ? `]` : ''\n\t\t\t\t\t\t\t\t\t}`;\n\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t\t.join( ',' ) }}${\n\t\t\t\t\t\t\t\tdepLoad.analysis[ 1 ].length\n\t\t\t\t\t\t\t\t\t? `let ${ depLoad.analysis[ 1 ]\n\t\t\t\t\t\t\t\t\t\t\t.map( ( _, i ) => `e$_${ i }` )\n\t\t\t\t\t\t\t\t\t\t\t.join( ',' ) };`\n\t\t\t\t\t\t\t\t\t: ''\n\t\t\t\t\t\t\t}export {${ depLoad.analysis[ 1 ]\n\t\t\t\t\t\t\t\t.map(\n\t\t\t\t\t\t\t\t\t( { s, e }, i ) =>\n\t\t\t\t\t\t\t\t\t\t`e$_${ i } as ${ depLoad.source.slice(\n\t\t\t\t\t\t\t\t\t\t\ts,\n\t\t\t\t\t\t\t\t\t\t\te\n\t\t\t\t\t\t\t\t\t\t) }`\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t.join( ',' ) }}\\n//# sourceURL=${\n\t\t\t\t\t\t\t\tdepLoad.responseUrl\n\t\t\t\t\t\t\t}?cycle`\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tpushStringTo( start - 1 );\n\t\t\t\tresolvedSource += `/*${ source.slice(\n\t\t\t\t\tstart - 1,\n\t\t\t\t\tstatementEnd\n\t\t\t\t) }*/${ urlJsString( blobUrl ) }`;\n\n\t\t\t\t// circular shell execution\n\t\t\t\tif ( ! cycleShell && depLoad.shellUrl ) {\n\t\t\t\t\tresolvedSource += `;import*as m$_${ depIndex } from'${ depLoad.blobUrl }';import{u$_ as u$_${ depIndex }}from'${ depLoad.shellUrl }';u$_${ depIndex }(m$_${ depIndex })`;\n\t\t\t\t\tdepLoad.shellUrl = undefined;\n\t\t\t\t}\n\t\t\t\tlastIndex = statementEnd;\n\t\t\t}\n\t\t\t// import.meta\n\t\t\telse if ( dynamicImportIndex === -2 ) {\n\t\t\t\tthrow Error( 'The import.meta property is not supported.' );\n\t\t\t}\n\t\t\t// dynamic import\n\t\t\telse {\n\t\t\t\tpushStringTo( statementStart );\n\t\t\t\tresolvedSource += `wpInteractivityRouterImport(`;\n\t\t\t\tdynamicImportEndStack.push( statementEnd - 1 );\n\t\t\t\tlastIndex = start;\n\t\t\t}\n\t\t}\n\n\t\t// progressive cycle binding updates\n\t\tif ( load.shellUrl ) {\n\t\t\tresolvedSource += `\\n;import{u$_}from'${\n\t\t\t\tload.shellUrl\n\t\t\t}';try{u$_({${ exports\n\t\t\t\t.filter( ( e ) => e.ln )\n\t\t\t\t.map( ( { s, e, ln } ) => `${ source.slice( s, e ) }:${ ln }` )\n\t\t\t\t.join( ',' ) }})}catch(_){};\\n`;\n\t\t}\n\n\t\tpushStringTo( source.length );\n\t}\n\n\t// ensure we have a proper sourceURL\n\tlet hasSourceURL = false;\n\tresolvedSource = resolvedSource.replace(\n\t\tsourceMapURLRegEx,\n\t\t( match, isMapping, url ) => {\n\t\t\thasSourceURL = ! isMapping;\n\t\t\treturn match.replace( url, () =>\n\t\t\t\tnew URL( url, load.responseUrl ).toString()\n\t\t\t);\n\t\t}\n\t);\n\tif ( ! hasSourceURL ) {\n\t\tresolvedSource += '\\n//# sourceURL=' + load.responseUrl;\n\t}\n\n\tload.blobUrl = createBlob( resolvedSource );\n\tload.source = undefined; // free memory\n}\n\nconst sourceMapURLRegEx =\n\t/\\n\\/\\/# source(Mapping)?URL=([^\\n]+)\\s*((;|\\/\\/[^#][^\\n]*)\\s*)*$/;\n\nfunction getOrCreateLoad(\n\turl: string,\n\tfetchOpts: RequestInit,\n\tparent: string\n): ModuleLoad {\n\tlet load: ModuleLoad = registry[ url ];\n\tif ( load ) {\n\t\treturn load;\n\t}\n\n\tload = { url };\n\n\tif ( registry[ url ] ) {\n\t\t// If there's a naming conflict, keep incrementing until unique\n\t\tlet i = 0;\n\t\twhile ( registry[ load.url + ++i ] ) {\n\t\t\t/* no-op */\n\t\t}\n\t\tload.url += i;\n\t}\n\tregistry[ load.url ] = load;\n\n\tload.fetchPromise = ( async () => {\n\t\tlet source;\n\t\t( { responseUrl: load.responseUrl, source: source } =\n\t\t\tawait ( fetchCache[ url ] ||\n\t\t\t\tfetchModule( url, fetchOpts, parent ) ) );\n\t\ttry {\n\t\t\tload.analysis = lexer.parse( source, load.url );\n\t\t} catch ( e ) {\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.error( e );\n\t\t\tload.analysis = [ [], [], false, false ];\n\t\t}\n\t\tload.source = source;\n\t\treturn load;\n\t} )();\n\n\tload.linkPromise = load.fetchPromise.then( async () => {\n\t\tlet childFetchOpts = fetchOpts;\n\t\tload.deps = (\n\t\t\tawait Promise.all(\n\t\t\t\tload.analysis[ 0 ].map( async ( { n, d } ) => {\n\t\t\t\t\tif ( d !== -1 || ! n ) {\n\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t}\n\t\t\t\t\tconst responseUrl = resolve(\n\t\t\t\t\t\tn,\n\t\t\t\t\t\tload.responseUrl || load.url\n\t\t\t\t\t);\n\t\t\t\t\tif ( skip && skip( responseUrl ) ) {\n\t\t\t\t\t\treturn { blobUrl: responseUrl } as ModuleLoad;\n\t\t\t\t\t}\n\t\t\t\t\t// remove integrity for child fetches\n\t\t\t\t\tif ( childFetchOpts.integrity ) {\n\t\t\t\t\t\tchildFetchOpts = {\n\t\t\t\t\t\t\t...childFetchOpts,\n\t\t\t\t\t\t\tintegrity: undefined,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\treturn getOrCreateLoad(\n\t\t\t\t\t\tresponseUrl,\n\t\t\t\t\t\tchildFetchOpts,\n\t\t\t\t\t\tload.responseUrl\n\t\t\t\t\t).fetchPromise;\n\t\t\t\t} )\n\t\t\t)\n\t\t).filter( ( l ) => l );\n\t} );\n\n\treturn load;\n}\n\nconst dynamicImport = ( u: string ) => import( /* webpackIgnore: true */ u );\n\n/**\n * Resolves the passed module URL and fetches the corresponding module\n * and their dependencies, returning a `ModuleLoad` object once all\n * of them have been fetched.\n *\n * @param url Module URL.\n * @param fetchOpts Fetch options.\n * @return A promise with a `ModuleLoad` instance.\n */\nexport async function preloadModule(\n\turl: string,\n\tfetchOpts?: RequestInit\n): Promise< ModuleLoad > {\n\tawait initPromise;\n\tconst load = getOrCreateLoad( url, fetchOpts, null );\n\tconst seen = {};\n\tawait loadAll( load, seen );\n\tresolveDeps( load, seen );\n\t// microtask scheduling – can help ensure Blob is fully ready\n\tawait Promise.resolve();\n\treturn load;\n}\n\n/**\n * Imports the module represented by the passed `ModuleLoad` instance.\n *\n * @param load The `ModuleLoad` instance representing the module.\n * @return A promise with the imported module.\n */\nexport async function importPreloadedModule< Module = unknown >(\n\tload: ModuleLoad\n): Promise< Module > {\n\tconst module = await dynamicImport( load.blobUrl );\n\t// if the preloaded module ended up with a shell (circular refs), finalize it\n\tif ( load.shellUrl ) {\n\t\t( await dynamicImport( load.shellUrl ) ).u$_( module );\n\t}\n\treturn module;\n}\n\n/**\n * Imports the module represented by the passed module URL.\n *\n * The module URL and all its dependencies are resolved using the\n * current status of the internal dynamic import map.\n *\n * @param url Module URL.\n * @param fetchOpts Fetch options.\n * @return A promise with the imported module.\n */\nexport async function topLevelLoad< Module = unknown >(\n\turl: string,\n\tfetchOpts?: RequestInit\n): Promise< Module > {\n\tconst load = await preloadModule( url, fetchOpts );\n\treturn importPreloadedModule< Module >( load );\n}\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,OAAO,KAAKA,KAAK,MAAM,iBAAiB;;AAExC;AACA;AACA;AACA,SAASC,WAAW,QAAQ,SAAS;AACrC,SAASC,OAAO,QAAQ,YAAY;AAcpC,OAAO,MAAMC,WAAW,GAAGH,KAAK,CAACI,IAAI;;AAErC;AACA;AACA;AACA,MAAMC,uBAAuB,GAC5BC,MAAM,CAACC,QAAQ,CAACC,aAAa,CAC5B,qCACD,CAAC;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,gBAAgB,GAAGJ,uBAAuB,GACpDK,IAAI,CAACC,KAAK,CAAEN,uBAAuB,CAACO,IAAK,CAAC,GAC1C;EAAEC,OAAO,EAAE,CAAC,CAAC;EAAEC,MAAM,EAAE,CAAC;AAAE,CAAC;AAE9B,MAAMC,IAAI,GAAKC,EAAE,IAAMC,MAAM,CAACC,IAAI,CAAET,gBAAgB,CAACI,OAAQ,CAAC,CAACM,QAAQ,CAAEH,EAAG,CAAC;AAE7E,MAAMI,UAAmD,GAAG,CAAC,CAAC;AAC9D,OAAO,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ACvB,CAAE,CAAC;EAEH,OAAOnE,IAAI;AACZ;AAEA,MAAMoE,aAAa,GAAKC,CAAS,IAAM,MAAM,CAAE,yBAA0BA,CAAE,CAAC;;AAE5E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,aAAaA,CAClCpE,GAAW,EACXwD,SAAuB,EACC;EACxB,MAAMhF,WAAW;EACjB,MAAMsB,IAAI,GAAGyD,eAAe,CAAEvD,GAAG,EAAEwD,SAAS,EAAE,IAAK,CAAC;EACpD,MAAMzD,IAAI,GAAG,CAAC,CAAC;EACf,MAAMF,OAAO,CAAEC,IAAI,EAAEC,IAAK,CAAC;EAC3BgB,WAAW,CAAEjB,IAAI,EAAEC,IAAK,CAAC;EACzB;EACA,MAAMG,OAAO,CAAC3B,OAAO,CAAC,CAAC;EACvB,OAAOuB,IAAI;AACZ;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeuE,qBAAqBA,CAC1CvE,IAAgB,EACI;EACpB,MAAMwE,MAAM,GAAG,MAAMJ,aAAa,CAAEpE,IAAI,CAACF,OAAQ,CAAC;EAClD;EACA,IAAKE,IAAI,CAACyC,QAAQ,EAAG;IACpB,CAAE,MAAM2B,aAAa,CAAEpE,IAAI,CAACyC,QAAS,CAAC,EAAGgC,GAAG,CAAED,MAAO,CAAC;EACvD;EACA,OAAOA,MAAM;AACd;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeE,YAAYA,CACjCxE,GAAW,EACXwD,SAAuB,EACH;EACpB,MAAM1D,IAAI,GAAG,MAAMsE,aAAa,CAAEpE,GAAG,EAAEwD,SAAU,CAAC;EAClD,OAAOa,qBAAqB,CAAYvE,IAAK,CAAC;AAC/C","ignoreList":[]}
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
/* wp:polyfill */
|
|
2
|
+
/**
|
|
3
|
+
* This code is derived from the following projects:
|
|
4
|
+
*
|
|
5
|
+
* 1. dynamic-importmap (https://github.com/keller-mark/dynamic-importmap)
|
|
6
|
+
* 2. es-module-shims (https://github.com/guybedford/es-module-shims)
|
|
7
|
+
*
|
|
8
|
+
* The original implementation was created by Guy Bedford in es-module-shims,
|
|
9
|
+
* then adapted by Mark Keller in dynamic-importmap, and further modified
|
|
10
|
+
* for use in this project.
|
|
11
|
+
*
|
|
12
|
+
* Both projects are licensed under the MIT license.
|
|
13
|
+
*
|
|
14
|
+
* MIT License: https://opensource.org/licenses/MIT
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
const backslashRegEx = /\\/g;
|
|
18
|
+
function isURL(url) {
|
|
19
|
+
if (url.indexOf(':') === -1) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
try {
|
|
23
|
+
new URL(url);
|
|
24
|
+
return true;
|
|
25
|
+
} catch (_) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function resolveIfNotPlainOrUrl(relUrl, parentUrl) {
|
|
30
|
+
const hIdx = parentUrl.indexOf('#'),
|
|
31
|
+
qIdx = parentUrl.indexOf('?');
|
|
32
|
+
if (hIdx + qIdx > -2) {
|
|
33
|
+
parentUrl = parentUrl.slice(0,
|
|
34
|
+
// eslint-disable-next-line no-nested-ternary
|
|
35
|
+
hIdx === -1 ? qIdx : qIdx === -1 || qIdx > hIdx ? hIdx : qIdx);
|
|
36
|
+
}
|
|
37
|
+
if (relUrl.indexOf('\\') !== -1) {
|
|
38
|
+
relUrl = relUrl.replace(backslashRegEx, '/');
|
|
39
|
+
}
|
|
40
|
+
// protocol-relative
|
|
41
|
+
if (relUrl[0] === '/' && relUrl[1] === '/') {
|
|
42
|
+
return parentUrl.slice(0, parentUrl.indexOf(':') + 1) + relUrl;
|
|
43
|
+
}
|
|
44
|
+
// relative-url
|
|
45
|
+
else if (relUrl[0] === '.' && (relUrl[1] === '/' || relUrl[1] === '.' && (relUrl[2] === '/' || relUrl.length === 2 && (relUrl += '/')) || relUrl.length === 1 && (relUrl += '/')) || relUrl[0] === '/') {
|
|
46
|
+
const parentProtocol = parentUrl.slice(0, parentUrl.indexOf(':') + 1);
|
|
47
|
+
// Disabled, but these cases will give inconsistent results for deep backtracking
|
|
48
|
+
//if (parentUrl[parentProtocol.length] !== '/')
|
|
49
|
+
// throw new Error('Cannot resolve');
|
|
50
|
+
// read pathname from parent URL
|
|
51
|
+
// pathname taken to be part after leading "/"
|
|
52
|
+
let pathname;
|
|
53
|
+
if (parentUrl[parentProtocol.length + 1] === '/') {
|
|
54
|
+
// resolving to a :// so we need to read out the auth and host
|
|
55
|
+
if (parentProtocol !== 'file:') {
|
|
56
|
+
pathname = parentUrl.slice(parentProtocol.length + 2);
|
|
57
|
+
pathname = pathname.slice(pathname.indexOf('/') + 1);
|
|
58
|
+
} else {
|
|
59
|
+
pathname = parentUrl.slice(8);
|
|
60
|
+
}
|
|
61
|
+
} else {
|
|
62
|
+
// resolving to :/ so pathname is the /... part
|
|
63
|
+
pathname = parentUrl.slice(parentProtocol.length + (parentUrl[parentProtocol.length] === '/'));
|
|
64
|
+
}
|
|
65
|
+
if (relUrl[0] === '/') {
|
|
66
|
+
return parentUrl.slice(0, parentUrl.length - pathname.length - 1) + relUrl;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// join together and split for removal of .. and . segments
|
|
70
|
+
// looping the string instead of anything fancy for perf reasons
|
|
71
|
+
// '../../../../../z' resolved to 'x/y' is just 'z'
|
|
72
|
+
const segmented = pathname.slice(0, pathname.lastIndexOf('/') + 1) + relUrl;
|
|
73
|
+
const output = [];
|
|
74
|
+
let segmentIndex = -1;
|
|
75
|
+
for (let i = 0; i < segmented.length; i++) {
|
|
76
|
+
// busy reading a segment - only terminate on '/'
|
|
77
|
+
if (segmentIndex !== -1) {
|
|
78
|
+
if (segmented[i] === '/') {
|
|
79
|
+
output.push(segmented.slice(segmentIndex, i + 1));
|
|
80
|
+
segmentIndex = -1;
|
|
81
|
+
}
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
// new segment - check if it is relative
|
|
85
|
+
else if (segmented[i] === '.') {
|
|
86
|
+
// ../ segment
|
|
87
|
+
if (segmented[i + 1] === '.' && (segmented[i + 2] === '/' || i + 2 === segmented.length)) {
|
|
88
|
+
output.pop();
|
|
89
|
+
i += 2;
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
// ./ segment
|
|
93
|
+
else if (segmented[i + 1] === '/' || i + 1 === segmented.length) {
|
|
94
|
+
i += 1;
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
// it is the start of a new segment
|
|
99
|
+
while (segmented[i] === '/') {
|
|
100
|
+
i++;
|
|
101
|
+
}
|
|
102
|
+
segmentIndex = i;
|
|
103
|
+
}
|
|
104
|
+
// finish reading out the last segment
|
|
105
|
+
if (segmentIndex !== -1) {
|
|
106
|
+
output.push(segmented.slice(segmentIndex));
|
|
107
|
+
}
|
|
108
|
+
return parentUrl.slice(0, parentUrl.length - pathname.length) + output.join('');
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
function resolveUrl(relUrl, parentUrl) {
|
|
112
|
+
return resolveIfNotPlainOrUrl(relUrl, parentUrl) || (isURL(relUrl) ? relUrl : resolveIfNotPlainOrUrl('./' + relUrl, parentUrl));
|
|
113
|
+
}
|
|
114
|
+
function getMatch(path, matchObj) {
|
|
115
|
+
if (matchObj[path]) {
|
|
116
|
+
return path;
|
|
117
|
+
}
|
|
118
|
+
let sepIndex = path.length;
|
|
119
|
+
do {
|
|
120
|
+
const segment = path.slice(0, sepIndex + 1);
|
|
121
|
+
if (segment in matchObj) {
|
|
122
|
+
return segment;
|
|
123
|
+
}
|
|
124
|
+
} while ((sepIndex = path.lastIndexOf('/', sepIndex - 1)) !== -1);
|
|
125
|
+
}
|
|
126
|
+
function applyPackages(id, packages) {
|
|
127
|
+
const pkgName = getMatch(id, packages);
|
|
128
|
+
if (pkgName) {
|
|
129
|
+
const pkg = packages[pkgName];
|
|
130
|
+
if (pkg === null) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
return pkg + id.slice(pkgName.length);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
function resolveImportMap(importMap, resolvedOrPlain, parentUrl) {
|
|
137
|
+
let scopeUrl = parentUrl && getMatch(parentUrl, importMap.scopes);
|
|
138
|
+
while (scopeUrl) {
|
|
139
|
+
const packageResolution = applyPackages(resolvedOrPlain, importMap.scopes[scopeUrl]);
|
|
140
|
+
if (packageResolution) {
|
|
141
|
+
return packageResolution;
|
|
142
|
+
}
|
|
143
|
+
scopeUrl = getMatch(scopeUrl.slice(0, scopeUrl.lastIndexOf('/')), importMap.scopes);
|
|
144
|
+
}
|
|
145
|
+
return applyPackages(resolvedOrPlain, importMap.imports) || resolvedOrPlain.indexOf(':') !== -1 && resolvedOrPlain;
|
|
146
|
+
}
|
|
147
|
+
function resolveAndComposePackages(packages, outPackages, baseUrl, parentMap) {
|
|
148
|
+
for (const p in packages) {
|
|
149
|
+
const resolvedLhs = resolveIfNotPlainOrUrl(p, baseUrl) || p;
|
|
150
|
+
const target = packages[p];
|
|
151
|
+
if (typeof target !== 'string') {
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
const mapped = resolveImportMap(parentMap, resolveIfNotPlainOrUrl(target, baseUrl) || target, baseUrl);
|
|
155
|
+
if (mapped) {
|
|
156
|
+
outPackages[resolvedLhs] = mapped;
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
// console.warn(
|
|
160
|
+
// `Mapping "${ p }" -> "${ packages[ p ] }" does not resolve`
|
|
161
|
+
// );
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
function resolveAndComposeImportMap(json, baseUrl, parentMap) {
|
|
165
|
+
const outMap = {
|
|
166
|
+
imports: Object.assign({}, parentMap.imports),
|
|
167
|
+
scopes: Object.assign({}, parentMap.scopes)
|
|
168
|
+
};
|
|
169
|
+
if (json.imports) {
|
|
170
|
+
resolveAndComposePackages(json.imports, outMap.imports, baseUrl, parentMap);
|
|
171
|
+
}
|
|
172
|
+
if (json.scopes) {
|
|
173
|
+
for (const s in json.scopes) {
|
|
174
|
+
const resolvedScope = resolveUrl(s, baseUrl);
|
|
175
|
+
resolveAndComposePackages(json.scopes[s], outMap.scopes[resolvedScope] || (outMap.scopes[resolvedScope] = {}), baseUrl, parentMap);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return outMap;
|
|
179
|
+
}
|
|
180
|
+
let importMap = {
|
|
181
|
+
imports: {},
|
|
182
|
+
scopes: {}
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
// TODO: check if this baseURI should change per document, and so
|
|
186
|
+
// it need to be passed as a parameter to methods like `resolve`.
|
|
187
|
+
const baseUrl = document.baseURI;
|
|
188
|
+
const pageBaseUrl = baseUrl;
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Extends the internal dynamic import map with the passed one.
|
|
192
|
+
*
|
|
193
|
+
* @param importMapIn Import map.
|
|
194
|
+
* @param importMapIn.imports Imports declaration.
|
|
195
|
+
* @param importMapIn.scopes Scopes declaration.
|
|
196
|
+
*/
|
|
197
|
+
export function addImportMap(importMapIn) {
|
|
198
|
+
importMap = resolveAndComposeImportMap(importMapIn, pageBaseUrl, importMap);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Resolves the URL of the passed module ID against the current internal
|
|
203
|
+
* dynamic import map.
|
|
204
|
+
*
|
|
205
|
+
* @param id Module ID.
|
|
206
|
+
* @param parentUrl Parent URL, in case the module ID is relative.
|
|
207
|
+
* @return Resolved module URL.
|
|
208
|
+
*/
|
|
209
|
+
export function resolve(id, parentUrl) {
|
|
210
|
+
const urlResolved = resolveIfNotPlainOrUrl(id, parentUrl);
|
|
211
|
+
return resolveImportMap(importMap, urlResolved || id, parentUrl) || id;
|
|
212
|
+
}
|
|
213
|
+
//# sourceMappingURL=resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["backslashRegEx","isURL","url","indexOf","URL","_","resolveIfNotPlainOrUrl","relUrl","parentUrl","hIdx","qIdx","slice","replace","length","parentProtocol","pathname","segmented","lastIndexOf","output","segmentIndex","i","push","pop","join","resolveUrl","getMatch","path","matchObj","sepIndex","segment","applyPackages","id","packages","pkgName","pkg","resolveImportMap","importMap","resolvedOrPlain","scopeUrl","scopes","packageResolution","imports","resolveAndComposePackages","outPackages","baseUrl","parentMap","p","resolvedLhs","target","mapped","resolveAndComposeImportMap","json","outMap","Object","assign","s","resolvedScope","document","baseURI","pageBaseUrl","addImportMap","importMapIn","resolve","urlResolved"],"sources":["@wordpress/interactivity-router/src/assets/dynamic-importmap/resolver.ts"],"sourcesContent":["/**\n * This code is derived from the following projects:\n *\n * 1. dynamic-importmap (https://github.com/keller-mark/dynamic-importmap)\n * 2. es-module-shims (https://github.com/guybedford/es-module-shims)\n *\n * The original implementation was created by Guy Bedford in es-module-shims,\n * then adapted by Mark Keller in dynamic-importmap, and further modified\n * for use in this project.\n *\n * Both projects are licensed under the MIT license.\n *\n * MIT License: https://opensource.org/licenses/MIT\n */\n\nconst backslashRegEx = /\\\\/g;\n\nfunction isURL( url: string ) {\n\tif ( url.indexOf( ':' ) === -1 ) {\n\t\treturn false;\n\t}\n\ttry {\n\t\tnew URL( url );\n\t\treturn true;\n\t} catch ( _ ) {\n\t\treturn false;\n\t}\n}\n\nfunction resolveIfNotPlainOrUrl( relUrl, parentUrl ) {\n\tconst hIdx = parentUrl.indexOf( '#' ),\n\t\tqIdx = parentUrl.indexOf( '?' );\n\tif ( hIdx + qIdx > -2 ) {\n\t\tparentUrl = parentUrl.slice(\n\t\t\t0,\n\t\t\t// eslint-disable-next-line no-nested-ternary\n\t\t\thIdx === -1 ? qIdx : qIdx === -1 || qIdx > hIdx ? hIdx : qIdx\n\t\t);\n\t}\n\tif ( relUrl.indexOf( '\\\\' ) !== -1 ) {\n\t\trelUrl = relUrl.replace( backslashRegEx, '/' );\n\t}\n\t// protocol-relative\n\tif ( relUrl[ 0 ] === '/' && relUrl[ 1 ] === '/' ) {\n\t\treturn parentUrl.slice( 0, parentUrl.indexOf( ':' ) + 1 ) + relUrl;\n\t}\n\t// relative-url\n\telse if (\n\t\t( relUrl[ 0 ] === '.' &&\n\t\t\t( relUrl[ 1 ] === '/' ||\n\t\t\t\t( relUrl[ 1 ] === '.' &&\n\t\t\t\t\t( relUrl[ 2 ] === '/' ||\n\t\t\t\t\t\t( relUrl.length === 2 && ( relUrl += '/' ) ) ) ) ||\n\t\t\t\t( relUrl.length === 1 && ( relUrl += '/' ) ) ) ) ||\n\t\trelUrl[ 0 ] === '/'\n\t) {\n\t\tconst parentProtocol = parentUrl.slice(\n\t\t\t0,\n\t\t\tparentUrl.indexOf( ':' ) + 1\n\t\t);\n\t\t// Disabled, but these cases will give inconsistent results for deep backtracking\n\t\t//if (parentUrl[parentProtocol.length] !== '/')\n\t\t// throw new Error('Cannot resolve');\n\t\t// read pathname from parent URL\n\t\t// pathname taken to be part after leading \"/\"\n\t\tlet pathname;\n\t\tif ( parentUrl[ parentProtocol.length + 1 ] === '/' ) {\n\t\t\t// resolving to a :// so we need to read out the auth and host\n\t\t\tif ( parentProtocol !== 'file:' ) {\n\t\t\t\tpathname = parentUrl.slice( parentProtocol.length + 2 );\n\t\t\t\tpathname = pathname.slice( pathname.indexOf( '/' ) + 1 );\n\t\t\t} else {\n\t\t\t\tpathname = parentUrl.slice( 8 );\n\t\t\t}\n\t\t} else {\n\t\t\t// resolving to :/ so pathname is the /... part\n\t\t\tpathname = parentUrl.slice(\n\t\t\t\tparentProtocol.length +\n\t\t\t\t\t( parentUrl[ parentProtocol.length ] === '/' )\n\t\t\t);\n\t\t}\n\n\t\tif ( relUrl[ 0 ] === '/' ) {\n\t\t\treturn (\n\t\t\t\tparentUrl.slice( 0, parentUrl.length - pathname.length - 1 ) +\n\t\t\t\trelUrl\n\t\t\t);\n\t\t}\n\n\t\t// join together and split for removal of .. and . segments\n\t\t// looping the string instead of anything fancy for perf reasons\n\t\t// '../../../../../z' resolved to 'x/y' is just 'z'\n\t\tconst segmented =\n\t\t\tpathname.slice( 0, pathname.lastIndexOf( '/' ) + 1 ) + relUrl;\n\n\t\tconst output = [];\n\t\tlet segmentIndex = -1;\n\t\tfor ( let i = 0; i < segmented.length; i++ ) {\n\t\t\t// busy reading a segment - only terminate on '/'\n\t\t\tif ( segmentIndex !== -1 ) {\n\t\t\t\tif ( segmented[ i ] === '/' ) {\n\t\t\t\t\toutput.push( segmented.slice( segmentIndex, i + 1 ) );\n\t\t\t\t\tsegmentIndex = -1;\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t// new segment - check if it is relative\n\t\t\telse if ( segmented[ i ] === '.' ) {\n\t\t\t\t// ../ segment\n\t\t\t\tif (\n\t\t\t\t\tsegmented[ i + 1 ] === '.' &&\n\t\t\t\t\t( segmented[ i + 2 ] === '/' || i + 2 === segmented.length )\n\t\t\t\t) {\n\t\t\t\t\toutput.pop();\n\t\t\t\t\ti += 2;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\t// ./ segment\n\t\t\t\telse if (\n\t\t\t\t\tsegmented[ i + 1 ] === '/' ||\n\t\t\t\t\ti + 1 === segmented.length\n\t\t\t\t) {\n\t\t\t\t\ti += 1;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// it is the start of a new segment\n\t\t\twhile ( segmented[ i ] === '/' ) {\n\t\t\t\ti++;\n\t\t\t}\n\t\t\tsegmentIndex = i;\n\t\t}\n\t\t// finish reading out the last segment\n\t\tif ( segmentIndex !== -1 ) {\n\t\t\toutput.push( segmented.slice( segmentIndex ) );\n\t\t}\n\t\treturn (\n\t\t\tparentUrl.slice( 0, parentUrl.length - pathname.length ) +\n\t\t\toutput.join( '' )\n\t\t);\n\t}\n}\n\nfunction resolveUrl( relUrl, parentUrl ) {\n\treturn (\n\t\tresolveIfNotPlainOrUrl( relUrl, parentUrl ) ||\n\t\t( isURL( relUrl )\n\t\t\t? relUrl\n\t\t\t: resolveIfNotPlainOrUrl( './' + relUrl, parentUrl ) )\n\t);\n}\n\nfunction getMatch( path, matchObj ) {\n\tif ( matchObj[ path ] ) {\n\t\treturn path;\n\t}\n\tlet sepIndex = path.length;\n\tdo {\n\t\tconst segment = path.slice( 0, sepIndex + 1 );\n\t\tif ( segment in matchObj ) {\n\t\t\treturn segment;\n\t\t}\n\t} while ( ( sepIndex = path.lastIndexOf( '/', sepIndex - 1 ) ) !== -1 );\n}\n\nfunction applyPackages( id, packages ) {\n\tconst pkgName = getMatch( id, packages );\n\tif ( pkgName ) {\n\t\tconst pkg = packages[ pkgName ];\n\t\tif ( pkg === null ) {\n\t\t\treturn;\n\t\t}\n\t\treturn pkg + id.slice( pkgName.length );\n\t}\n}\n\nfunction resolveImportMap( importMap, resolvedOrPlain, parentUrl ) {\n\tlet scopeUrl = parentUrl && getMatch( parentUrl, importMap.scopes );\n\twhile ( scopeUrl ) {\n\t\tconst packageResolution = applyPackages(\n\t\t\tresolvedOrPlain,\n\t\t\timportMap.scopes[ scopeUrl ]\n\t\t);\n\t\tif ( packageResolution ) {\n\t\t\treturn packageResolution;\n\t\t}\n\t\tscopeUrl = getMatch(\n\t\t\tscopeUrl.slice( 0, scopeUrl.lastIndexOf( '/' ) ),\n\t\t\timportMap.scopes\n\t\t);\n\t}\n\treturn (\n\t\tapplyPackages( resolvedOrPlain, importMap.imports ) ||\n\t\t( resolvedOrPlain.indexOf( ':' ) !== -1 && resolvedOrPlain )\n\t);\n}\n\nfunction resolveAndComposePackages(\n\tpackages,\n\toutPackages,\n\tbaseUrl,\n\tparentMap\n) {\n\tfor ( const p in packages ) {\n\t\tconst resolvedLhs = resolveIfNotPlainOrUrl( p, baseUrl ) || p;\n\t\tconst target = packages[ p ];\n\t\tif ( typeof target !== 'string' ) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst mapped = resolveImportMap(\n\t\t\tparentMap,\n\t\t\tresolveIfNotPlainOrUrl( target, baseUrl ) || target,\n\t\t\tbaseUrl\n\t\t);\n\t\tif ( mapped ) {\n\t\t\toutPackages[ resolvedLhs ] = mapped;\n\t\t\tcontinue;\n\t\t}\n\t\t// console.warn(\n\t\t// \t`Mapping \"${ p }\" -> \"${ packages[ p ] }\" does not resolve`\n\t\t// );\n\t}\n}\n\nfunction resolveAndComposeImportMap( json, baseUrl, parentMap ) {\n\tconst outMap = {\n\t\timports: Object.assign( {}, parentMap.imports ),\n\t\tscopes: Object.assign( {}, parentMap.scopes ),\n\t};\n\n\tif ( json.imports ) {\n\t\tresolveAndComposePackages(\n\t\t\tjson.imports,\n\t\t\toutMap.imports,\n\t\t\tbaseUrl,\n\t\t\tparentMap\n\t\t);\n\t}\n\n\tif ( json.scopes ) {\n\t\tfor ( const s in json.scopes ) {\n\t\t\tconst resolvedScope = resolveUrl( s, baseUrl );\n\t\t\tresolveAndComposePackages(\n\t\t\t\tjson.scopes[ s ],\n\t\t\t\toutMap.scopes[ resolvedScope ] ||\n\t\t\t\t\t( outMap.scopes[ resolvedScope ] = {} ),\n\t\t\t\tbaseUrl,\n\t\t\t\tparentMap\n\t\t\t);\n\t\t}\n\t}\n\n\treturn outMap;\n}\n\nlet importMap = { imports: {}, scopes: {} };\n\n// TODO: check if this baseURI should change per document, and so\n// it need to be passed as a parameter to methods like `resolve`.\nconst baseUrl = document.baseURI;\nconst pageBaseUrl = baseUrl;\n\n/**\n * Extends the internal dynamic import map with the passed one.\n *\n * @param importMapIn Import map.\n * @param importMapIn.imports Imports declaration.\n * @param importMapIn.scopes Scopes declaration.\n */\nexport function addImportMap( importMapIn: {\n\timports?: Record< string, string >;\n\tscopes?: Record< string, any >;\n} ) {\n\timportMap = resolveAndComposeImportMap(\n\t\timportMapIn,\n\t\tpageBaseUrl,\n\t\timportMap\n\t);\n}\n\n/**\n * Resolves the URL of the passed module ID against the current internal\n * dynamic import map.\n *\n * @param id Module ID.\n * @param parentUrl Parent URL, in case the module ID is relative.\n * @return Resolved module URL.\n */\nexport function resolve( id: string, parentUrl: string ): string {\n\tconst urlResolved = resolveIfNotPlainOrUrl( id, parentUrl );\n\treturn resolveImportMap( importMap, urlResolved || id, parentUrl ) || id;\n}\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,MAAMA,cAAc,GAAG,KAAK;AAE5B,SAASC,KAAKA,CAAEC,GAAW,EAAG;EAC7B,IAAKA,GAAG,CAACC,OAAO,CAAE,GAAI,CAAC,KAAK,CAAC,CAAC,EAAG;IAChC,OAAO,KAAK;EACb;EACA,IAAI;IACH,IAAIC,GAAG,CAAEF,GAAI,CAAC;IACd,OAAO,IAAI;EACZ,CAAC,CAAC,OAAQG,CAAC,EAAG;IACb,OAAO,KAAK;EACb;AACD;AAEA,SAASC,sBAAsBA,CAAEC,MAAM,EAAEC,SAAS,EAAG;EACpD,MAAMC,IAAI,GAAGD,SAAS,CAACL,OAAO,CAAE,GAAI,CAAC;IACpCO,IAAI,GAAGF,SAAS,CAACL,OAAO,CAAE,GAAI,CAAC;EAChC,IAAKM,IAAI,GAAGC,IAAI,GAAG,CAAC,CAAC,EAAG;IACvBF,SAAS,GAAGA,SAAS,CAACG,KAAK,CAC1B,CAAC;IACD;IACAF,IAAI,KAAK,CAAC,CAAC,GAAGC,IAAI,GAAGA,IAAI,KAAK,CAAC,CAAC,IAAIA,IAAI,GAAGD,IAAI,GAAGA,IAAI,GAAGC,IAC1D,CAAC;EACF;EACA,IAAKH,MAAM,CAACJ,OAAO,CAAE,IAAK,CAAC,KAAK,CAAC,CAAC,EAAG;IACpCI,MAAM,GAAGA,MAAM,CAACK,OAAO,CAAEZ,cAAc,EAAE,GAAI,CAAC;EAC/C;EACA;EACA,IAAKO,MAAM,CAAE,CAAC,CAAE,KAAK,GAAG,IAAIA,MAAM,CAAE,CAAC,CAAE,KAAK,GAAG,E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