@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
package/build/head.js
DELETED
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.updateHead = exports.headElements = exports.fetchHeadAssets = void 0;
|
|
7
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
8
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
9
|
-
/**
|
|
10
|
-
* The cache of prefetched stylesheets and scripts.
|
|
11
|
-
*/
|
|
12
|
-
const headElements = exports.headElements = new Map();
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Helper to update only the necessary tags in the head.
|
|
16
|
-
*
|
|
17
|
-
* @async
|
|
18
|
-
* @param newHead The head elements of the new page.
|
|
19
|
-
*/
|
|
20
|
-
const updateHead = async newHead => {
|
|
21
|
-
// Helper to get the tag id store in the cache.
|
|
22
|
-
const getTagId = tag => tag.id || tag.outerHTML;
|
|
23
|
-
|
|
24
|
-
// Map incoming head tags by their content.
|
|
25
|
-
const newHeadMap = new Map();
|
|
26
|
-
for (const child of newHead) {
|
|
27
|
-
newHeadMap.set(getTagId(child), child);
|
|
28
|
-
}
|
|
29
|
-
const toRemove = [];
|
|
30
|
-
|
|
31
|
-
// Detect nodes that should be added or removed.
|
|
32
|
-
for (const child of document.head.children) {
|
|
33
|
-
const id = getTagId(child);
|
|
34
|
-
// Always remove styles and links as they might change.
|
|
35
|
-
if (child.nodeName === 'LINK' || child.nodeName === 'STYLE') {
|
|
36
|
-
toRemove.push(child);
|
|
37
|
-
} else if (newHeadMap.has(id)) {
|
|
38
|
-
newHeadMap.delete(id);
|
|
39
|
-
} else if (child.nodeName !== 'SCRIPT' && child.nodeName !== 'META') {
|
|
40
|
-
toRemove.push(child);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
await Promise.all([...headElements.entries()].filter(([, {
|
|
44
|
-
tag
|
|
45
|
-
}]) => tag.nodeName === 'SCRIPT').map(async ([url]) => {
|
|
46
|
-
await (specifier => new Promise(r => r(`${specifier}`)).then(s => _interopRequireWildcard(require(s))))(/* webpackIgnore: true */url);
|
|
47
|
-
}));
|
|
48
|
-
|
|
49
|
-
// Prepare new assets.
|
|
50
|
-
const toAppend = [...newHeadMap.values()];
|
|
51
|
-
|
|
52
|
-
// Apply the changes.
|
|
53
|
-
toRemove.forEach(n => n.remove());
|
|
54
|
-
document.head.append(...toAppend);
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Fetches and processes head assets (stylesheets and scripts) from a specified document.
|
|
59
|
-
*
|
|
60
|
-
* @async
|
|
61
|
-
* @param doc The document from which to fetch head assets. It should support standard DOM querying methods.
|
|
62
|
-
*
|
|
63
|
-
* @return Returns an array of HTML elements representing the head assets.
|
|
64
|
-
*/
|
|
65
|
-
exports.updateHead = updateHead;
|
|
66
|
-
const fetchHeadAssets = async doc => {
|
|
67
|
-
const headTags = [];
|
|
68
|
-
|
|
69
|
-
// We only want to fetch module scripts because regular scripts (without
|
|
70
|
-
// `async` or `defer` attributes) can depend on the execution of other scripts.
|
|
71
|
-
// Scripts found in the head are blocking and must be executed in order.
|
|
72
|
-
const scripts = doc.querySelectorAll('script[type="module"][src]');
|
|
73
|
-
scripts.forEach(script => {
|
|
74
|
-
const src = script.getAttribute('src');
|
|
75
|
-
if (!headElements.has(src)) {
|
|
76
|
-
// add the <link> elements to prefetch the module scripts
|
|
77
|
-
const link = doc.createElement('link');
|
|
78
|
-
link.rel = 'modulepreload';
|
|
79
|
-
link.href = src;
|
|
80
|
-
document.head.append(link);
|
|
81
|
-
headElements.set(src, {
|
|
82
|
-
tag: script
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
const stylesheets = doc.querySelectorAll('link[rel=stylesheet]');
|
|
87
|
-
await Promise.all(Array.from(stylesheets).map(async tag => {
|
|
88
|
-
const href = tag.getAttribute('href');
|
|
89
|
-
if (!href) {
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
if (!headElements.has(href)) {
|
|
93
|
-
try {
|
|
94
|
-
const response = await fetch(href);
|
|
95
|
-
const text = await response.text();
|
|
96
|
-
headElements.set(href, {
|
|
97
|
-
tag,
|
|
98
|
-
text
|
|
99
|
-
});
|
|
100
|
-
} catch (e) {
|
|
101
|
-
// eslint-disable-next-line no-console
|
|
102
|
-
console.error(e);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
const headElement = headElements.get(href);
|
|
106
|
-
const styleElement = doc.createElement('style');
|
|
107
|
-
styleElement.textContent = headElement.text;
|
|
108
|
-
headTags.push(styleElement);
|
|
109
|
-
}));
|
|
110
|
-
return [doc.querySelector('title'), ...doc.querySelectorAll('style'), ...headTags];
|
|
111
|
-
};
|
|
112
|
-
exports.fetchHeadAssets = fetchHeadAssets;
|
|
113
|
-
//# sourceMappingURL=head.js.map
|
package/build/head.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["headElements","exports","Map","updateHead","newHead","getTagId","tag","id","outerHTML","newHeadMap","child","set","toRemove","document","head","children","nodeName","push","has","delete","Promise","all","entries","filter","map","url","specifier","r","then","s","_interopRequireWildcard","require","toAppend","values","forEach","n","remove","append","fetchHeadAssets","doc","headTags","scripts","querySelectorAll","script","src","getAttribute","link","createElement","rel","href","stylesheets","Array","from","response","fetch","text","e","console","error","headElement","get","styleElement","textContent","querySelector"],"sources":["@wordpress/interactivity-router/src/head.ts"],"sourcesContent":["/**\n * The cache of prefetched stylesheets and scripts.\n */\nexport const headElements = new Map<\n\tstring,\n\t{ tag: HTMLElement; text?: string }\n>();\n\n/**\n * Helper to update only the necessary tags in the head.\n *\n * @async\n * @param newHead The head elements of the new page.\n */\nexport const updateHead = async ( newHead: HTMLHeadElement[] ) => {\n\t// Helper to get the tag id store in the cache.\n\tconst getTagId = ( tag: Element ) => tag.id || tag.outerHTML;\n\n\t// Map incoming head tags by their content.\n\tconst newHeadMap = new Map< string, Element >();\n\tfor ( const child of newHead ) {\n\t\tnewHeadMap.set( getTagId( child ), child );\n\t}\n\n\tconst toRemove: Element[] = [];\n\n\t// Detect nodes that should be added or removed.\n\tfor ( const child of document.head.children ) {\n\t\tconst id = getTagId( child );\n\t\t// Always remove styles and links as they might change.\n\t\tif ( child.nodeName === 'LINK' || child.nodeName === 'STYLE' ) {\n\t\t\ttoRemove.push( child );\n\t\t} else if ( newHeadMap.has( id ) ) {\n\t\t\tnewHeadMap.delete( id );\n\t\t} else if ( child.nodeName !== 'SCRIPT' && child.nodeName !== 'META' ) {\n\t\t\ttoRemove.push( child );\n\t\t}\n\t}\n\n\tawait Promise.all(\n\t\t[ ...headElements.entries() ]\n\t\t\t.filter( ( [ , { tag } ] ) => tag.nodeName === 'SCRIPT' )\n\t\t\t.map( async ( [ url ] ) => {\n\t\t\t\tawait import( /* webpackIgnore: true */ url );\n\t\t\t} )\n\t);\n\n\t// Prepare new assets.\n\tconst toAppend = [ ...newHeadMap.values() ];\n\n\t// Apply the changes.\n\ttoRemove.forEach( ( n ) => n.remove() );\n\tdocument.head.append( ...toAppend );\n};\n\n/**\n * Fetches and processes head assets (stylesheets and scripts) from a specified document.\n *\n * @async\n * @param doc The document from which to fetch head assets. It should support standard DOM querying methods.\n *\n * @return Returns an array of HTML elements representing the head assets.\n */\nexport const fetchHeadAssets = async (\n\tdoc: Document\n): Promise< HTMLElement[] > => {\n\tconst headTags = [];\n\n\t// We only want to fetch module scripts because regular scripts (without\n\t// `async` or `defer` attributes) can depend on the execution of other scripts.\n\t// Scripts found in the head are blocking and must be executed in order.\n\tconst scripts = doc.querySelectorAll< HTMLScriptElement >(\n\t\t'script[type=\"module\"][src]'\n\t);\n\n\tscripts.forEach( ( script ) => {\n\t\tconst src = script.getAttribute( 'src' );\n\t\tif ( ! headElements.has( src ) ) {\n\t\t\t// add the <link> elements to prefetch the module scripts\n\t\t\tconst link = doc.createElement( 'link' );\n\t\t\tlink.rel = 'modulepreload';\n\t\t\tlink.href = src;\n\t\t\tdocument.head.append( link );\n\t\t\theadElements.set( src, { tag: script } );\n\t\t}\n\t} );\n\n\tconst stylesheets = doc.querySelectorAll< HTMLLinkElement >(\n\t\t'link[rel=stylesheet]'\n\t);\n\n\tawait Promise.all(\n\t\tArray.from( stylesheets ).map( async ( tag ) => {\n\t\t\tconst href = tag.getAttribute( 'href' );\n\t\t\tif ( ! href ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( ! headElements.has( href ) ) {\n\t\t\t\ttry {\n\t\t\t\t\tconst response = await fetch( href );\n\t\t\t\t\tconst text = await response.text();\n\t\t\t\t\theadElements.set( href, {\n\t\t\t\t\t\ttag,\n\t\t\t\t\t\ttext,\n\t\t\t\t\t} );\n\t\t\t\t} catch ( e ) {\n\t\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\t\tconsole.error( e );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst headElement = headElements.get( href );\n\t\t\tconst styleElement = doc.createElement( 'style' );\n\t\t\tstyleElement.textContent = headElement.text;\n\n\t\t\theadTags.push( styleElement );\n\t\t} )\n\t);\n\n\treturn [\n\t\tdoc.querySelector( 'title' ),\n\t\t...doc.querySelectorAll( 'style' ),\n\t\t...headTags,\n\t];\n};\n"],"mappings":";;;;;;;;AAAA;AACA;AACA;AACO,MAAMA,YAAY,GAAAC,OAAA,CAAAD,YAAA,GAAG,IAAIE,GAAG,CAGjC,CAAC;;AAEH;AACA;AACA;AACA;AACA;AACA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AY,CAAC,CAAC1B,GAAG,CAAE,MAAQlB,GAAG,IAAM;IAC/C,MAAM2C,IAAI,GAAG3C,GAAG,CAACuC,YAAY,CAAE,MAAO,CAAC;IACvC,IAAK,CAAEI,IAAI,EAAG;MACb;IACD;IAEA,IAAK,CAAEjD,YAAY,CAACkB,GAAG,CAAE+B,IAAK,CAAC,EAAG;MACjC,IAAI;QACH,MAAMI,QAAQ,GAAG,MAAMC,KAAK,CAAEL,IAAK,CAAC;QACpC,MAAMM,IAAI,GAAG,MAAMF,QAAQ,CAACE,IAAI,CAAC,CAAC;QAClCvD,YAAY,CAACW,GAAG,CAAEsC,IAAI,EAAE;UACvB3C,GAAG;UACHiD;QACD,CAAE,CAAC;MACJ,CAAC,CAAC,OAAQC,CAAC,EAAG;QACb;QACAC,OAAO,CAACC,KAAK,CAAEF,CAAE,CAAC;MACnB;IACD;IAEA,MAAMG,WAAW,GAAG3D,YAAY,CAAC4D,GAAG,CAAEX,IAAK,CAAC;IAC5C,MAAMY,YAAY,GAAGtB,GAAG,CAACQ,aAAa,CAAE,OAAQ,CAAC;IACjDc,YAAY,CAACC,WAAW,GAAGH,WAAW,CAACJ,IAAI;IAE3Cf,QAAQ,CAACvB,IAAI,CAAE4C,YAAa,CAAC;EAC9B,CAAE,CACH,CAAC;EAED,OAAO,CACNtB,GAAG,CAACwB,aAAa,CAAE,OAAQ,CAAC,EAC5B,GAAGxB,GAAG,CAACG,gBAAgB,CAAE,OAAQ,CAAC,EAClC,GAAGF,QAAQ,CACX;AACF,CAAC;AAACvC,OAAA,CAAAqC,eAAA,GAAAA,eAAA","ignoreList":[]}
|
package/build-module/head.js
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The cache of prefetched stylesheets and scripts.
|
|
3
|
-
*/
|
|
4
|
-
export const headElements = new Map();
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Helper to update only the necessary tags in the head.
|
|
8
|
-
*
|
|
9
|
-
* @async
|
|
10
|
-
* @param newHead The head elements of the new page.
|
|
11
|
-
*/
|
|
12
|
-
export const updateHead = async newHead => {
|
|
13
|
-
// Helper to get the tag id store in the cache.
|
|
14
|
-
const getTagId = tag => tag.id || tag.outerHTML;
|
|
15
|
-
|
|
16
|
-
// Map incoming head tags by their content.
|
|
17
|
-
const newHeadMap = new Map();
|
|
18
|
-
for (const child of newHead) {
|
|
19
|
-
newHeadMap.set(getTagId(child), child);
|
|
20
|
-
}
|
|
21
|
-
const toRemove = [];
|
|
22
|
-
|
|
23
|
-
// Detect nodes that should be added or removed.
|
|
24
|
-
for (const child of document.head.children) {
|
|
25
|
-
const id = getTagId(child);
|
|
26
|
-
// Always remove styles and links as they might change.
|
|
27
|
-
if (child.nodeName === 'LINK' || child.nodeName === 'STYLE') {
|
|
28
|
-
toRemove.push(child);
|
|
29
|
-
} else if (newHeadMap.has(id)) {
|
|
30
|
-
newHeadMap.delete(id);
|
|
31
|
-
} else if (child.nodeName !== 'SCRIPT' && child.nodeName !== 'META') {
|
|
32
|
-
toRemove.push(child);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
await Promise.all([...headElements.entries()].filter(([, {
|
|
36
|
-
tag
|
|
37
|
-
}]) => tag.nodeName === 'SCRIPT').map(async ([url]) => {
|
|
38
|
-
await import(/* webpackIgnore: true */url);
|
|
39
|
-
}));
|
|
40
|
-
|
|
41
|
-
// Prepare new assets.
|
|
42
|
-
const toAppend = [...newHeadMap.values()];
|
|
43
|
-
|
|
44
|
-
// Apply the changes.
|
|
45
|
-
toRemove.forEach(n => n.remove());
|
|
46
|
-
document.head.append(...toAppend);
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Fetches and processes head assets (stylesheets and scripts) from a specified document.
|
|
51
|
-
*
|
|
52
|
-
* @async
|
|
53
|
-
* @param doc The document from which to fetch head assets. It should support standard DOM querying methods.
|
|
54
|
-
*
|
|
55
|
-
* @return Returns an array of HTML elements representing the head assets.
|
|
56
|
-
*/
|
|
57
|
-
export const fetchHeadAssets = async doc => {
|
|
58
|
-
const headTags = [];
|
|
59
|
-
|
|
60
|
-
// We only want to fetch module scripts because regular scripts (without
|
|
61
|
-
// `async` or `defer` attributes) can depend on the execution of other scripts.
|
|
62
|
-
// Scripts found in the head are blocking and must be executed in order.
|
|
63
|
-
const scripts = doc.querySelectorAll('script[type="module"][src]');
|
|
64
|
-
scripts.forEach(script => {
|
|
65
|
-
const src = script.getAttribute('src');
|
|
66
|
-
if (!headElements.has(src)) {
|
|
67
|
-
// add the <link> elements to prefetch the module scripts
|
|
68
|
-
const link = doc.createElement('link');
|
|
69
|
-
link.rel = 'modulepreload';
|
|
70
|
-
link.href = src;
|
|
71
|
-
document.head.append(link);
|
|
72
|
-
headElements.set(src, {
|
|
73
|
-
tag: script
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
const stylesheets = doc.querySelectorAll('link[rel=stylesheet]');
|
|
78
|
-
await Promise.all(Array.from(stylesheets).map(async tag => {
|
|
79
|
-
const href = tag.getAttribute('href');
|
|
80
|
-
if (!href) {
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
if (!headElements.has(href)) {
|
|
84
|
-
try {
|
|
85
|
-
const response = await fetch(href);
|
|
86
|
-
const text = await response.text();
|
|
87
|
-
headElements.set(href, {
|
|
88
|
-
tag,
|
|
89
|
-
text
|
|
90
|
-
});
|
|
91
|
-
} catch (e) {
|
|
92
|
-
// eslint-disable-next-line no-console
|
|
93
|
-
console.error(e);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
const headElement = headElements.get(href);
|
|
97
|
-
const styleElement = doc.createElement('style');
|
|
98
|
-
styleElement.textContent = headElement.text;
|
|
99
|
-
headTags.push(styleElement);
|
|
100
|
-
}));
|
|
101
|
-
return [doc.querySelector('title'), ...doc.querySelectorAll('style'), ...headTags];
|
|
102
|
-
};
|
|
103
|
-
//# sourceMappingURL=head.js.map
|
package/build-module/head.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["headElements","Map","updateHead","newHead","getTagId","tag","id","outerHTML","newHeadMap","child","set","toRemove","document","head","children","nodeName","push","has","delete","Promise","all","entries","filter","map","url","toAppend","values","forEach","n","remove","append","fetchHeadAssets","doc","headTags","scripts","querySelectorAll","script","src","getAttribute","link","createElement","rel","href","stylesheets","Array","from","response","fetch","text","e","console","error","headElement","get","styleElement","textContent","querySelector"],"sources":["@wordpress/interactivity-router/src/head.ts"],"sourcesContent":["/**\n * The cache of prefetched stylesheets and scripts.\n */\nexport const headElements = new Map<\n\tstring,\n\t{ tag: HTMLElement; text?: string }\n>();\n\n/**\n * Helper to update only the necessary tags in the head.\n *\n * @async\n * @param newHead The head elements of the new page.\n */\nexport const updateHead = async ( newHead: HTMLHeadElement[] ) => {\n\t// Helper to get the tag id store in the cache.\n\tconst getTagId = ( tag: Element ) => tag.id || tag.outerHTML;\n\n\t// Map incoming head tags by their content.\n\tconst newHeadMap = new Map< string, Element >();\n\tfor ( const child of newHead ) {\n\t\tnewHeadMap.set( getTagId( child ), child );\n\t}\n\n\tconst toRemove: Element[] = [];\n\n\t// Detect nodes that should be added or removed.\n\tfor ( const child of document.head.children ) {\n\t\tconst id = getTagId( child );\n\t\t// Always remove styles and links as they might change.\n\t\tif ( child.nodeName === 'LINK' || child.nodeName === 'STYLE' ) {\n\t\t\ttoRemove.push( child );\n\t\t} else if ( newHeadMap.has( id ) ) {\n\t\t\tnewHeadMap.delete( id );\n\t\t} else if ( child.nodeName !== 'SCRIPT' && child.nodeName !== 'META' ) {\n\t\t\ttoRemove.push( child );\n\t\t}\n\t}\n\n\tawait Promise.all(\n\t\t[ ...headElements.entries() ]\n\t\t\t.filter( ( [ , { tag } ] ) => tag.nodeName === 'SCRIPT' )\n\t\t\t.map( async ( [ url ] ) => {\n\t\t\t\tawait import( /* webpackIgnore: true */ url );\n\t\t\t} )\n\t);\n\n\t// Prepare new assets.\n\tconst toAppend = [ ...newHeadMap.values() ];\n\n\t// Apply the changes.\n\ttoRemove.forEach( ( n ) => n.remove() );\n\tdocument.head.append( ...toAppend );\n};\n\n/**\n * Fetches and processes head assets (stylesheets and scripts) from a specified document.\n *\n * @async\n * @param doc The document from which to fetch head assets. It should support standard DOM querying methods.\n *\n * @return Returns an array of HTML elements representing the head assets.\n */\nexport const fetchHeadAssets = async (\n\tdoc: Document\n): Promise< HTMLElement[] > => {\n\tconst headTags = [];\n\n\t// We only want to fetch module scripts because regular scripts (without\n\t// `async` or `defer` attributes) can depend on the execution of other scripts.\n\t// Scripts found in the head are blocking and must be executed in order.\n\tconst scripts = doc.querySelectorAll< HTMLScriptElement >(\n\t\t'script[type=\"module\"][src]'\n\t);\n\n\tscripts.forEach( ( script ) => {\n\t\tconst src = script.getAttribute( 'src' );\n\t\tif ( ! headElements.has( src ) ) {\n\t\t\t// add the <link> elements to prefetch the module scripts\n\t\t\tconst link = doc.createElement( 'link' );\n\t\t\tlink.rel = 'modulepreload';\n\t\t\tlink.href = src;\n\t\t\tdocument.head.append( link );\n\t\t\theadElements.set( src, { tag: script } );\n\t\t}\n\t} );\n\n\tconst stylesheets = doc.querySelectorAll< HTMLLinkElement >(\n\t\t'link[rel=stylesheet]'\n\t);\n\n\tawait Promise.all(\n\t\tArray.from( stylesheets ).map( async ( tag ) => {\n\t\t\tconst href = tag.getAttribute( 'href' );\n\t\t\tif ( ! href ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( ! headElements.has( href ) ) {\n\t\t\t\ttry {\n\t\t\t\t\tconst response = await fetch( href );\n\t\t\t\t\tconst text = await response.text();\n\t\t\t\t\theadElements.set( href, {\n\t\t\t\t\t\ttag,\n\t\t\t\t\t\ttext,\n\t\t\t\t\t} );\n\t\t\t\t} catch ( e ) {\n\t\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\t\tconsole.error( e );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst headElement = headElements.get( href );\n\t\t\tconst styleElement = doc.createElement( 'style' );\n\t\t\tstyleElement.textContent = headElement.text;\n\n\t\t\theadTags.push( styleElement );\n\t\t} )\n\t);\n\n\treturn [\n\t\tdoc.querySelector( 'title' ),\n\t\t...doc.querySelectorAll( 'style' ),\n\t\t...headTags,\n\t];\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAO,MAAMA,YAAY,GAAG,IAAIC,GAAG,CAGjC,CAAC;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,UAAU,GAAG,MAAQC,OAA0B,IAAM;EACjE;EACA,MAAMC,QAAQ,GAAKC,GAAY,IAAMA,GAAG,CAACC,EAAE,IAAID,GAAG,CAACE,SAAS;;EAE5D;EACA,MAAMC,UAAU,GAAG,IAAIP,GAAG,CAAoB,CAAC;EAC/C,KAAM,MAAMQ,KAAK,IAAIN,OAAO,EAAG;IAC9BK,UAAU,CAACE,GAAG,CAAEN,QAAQ,CAAEK,KAAM,CAAC,EAAEA,KAAM,CAAC;EAC3C;EAEA,MAAME,QAAmB,GAAG,EAAE;;EAE9B;EACA,KAAM,MAAMF,KAAK,IAAIG,QAAQ,CAACC,IAAI,CAACC,QAAQ,EAAG;IAC7C,MAAMR,EAAE,GAAGF,QAAQ,CAAEK,KAAM,CAAC;IAC5B;IACA,IAAKA,KAAK,CAACM,QAAQ,KAAK,MAAM,IAAIN,KAAK,CAACM,QAAQ,KAAK,OAAO,EAAG;MAC9DJ,QAAQ,CAACK,IAAI,CAAEP,KAAM,CAAC;IACvB,CAAC,MAAM,IAAKD,UAAU,CAACS,GAAG,CAAEX,EAAG,CAAC,EAAG;MAClCE,UAAU,CAACU,MAAM,CAAEZ,EAAG,CAAC;IACxB,CAAC,MAAM,IAAKG,KAAK,CAACM,QAAQ,KAAK,QAAQ,IAAIN,KAAK,CAACM,QAAQ,KAAK,MAAM,EAAG;MACtEJ,QAAQ,CAACK,IAAI,CAAEP,KAAM,CAAC;IACvB;EACD;EAEA,MAAMU,OAAO,CA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AAE,CAAC;EAEH,MAAMO,WAAW,GAAGX,GAAG,CAACG,gBAAgB,CACvC,sBACD,CAAC;EAED,MAAMhB,OAAO,CAACC,GAAG,CAChBwB,KAAK,CAACC,IAAI,CAAEF,WAAY,CAAC,CAACpB,GAAG,CAAE,MAAQlB,GAAG,IAAM;IAC/C,MAAMqC,IAAI,GAAGrC,GAAG,CAACiC,YAAY,CAAE,MAAO,CAAC;IACvC,IAAK,CAAEI,IAAI,EAAG;MACb;IACD;IAEA,IAAK,CAAE1C,YAAY,CAACiB,GAAG,CAAEyB,IAAK,CAAC,EAAG;MACjC,IAAI;QACH,MAAMI,QAAQ,GAAG,MAAMC,KAAK,CAAEL,IAAK,CAAC;QACpC,MAAMM,IAAI,GAAG,MAAMF,QAAQ,CAACE,IAAI,CAAC,CAAC;QAClChD,YAAY,CAACU,GAAG,CAAEgC,IAAI,EAAE;UACvBrC,GAAG;UACH2C;QACD,CAAE,CAAC;MACJ,CAAC,CAAC,OAAQC,CAAC,EAAG;QACb;QACAC,OAAO,CAACC,KAAK,CAAEF,CAAE,CAAC;MACnB;IACD;IAEA,MAAMG,WAAW,GAAGpD,YAAY,CAACqD,GAAG,CAAEX,IAAK,CAAC;IAC5C,MAAMY,YAAY,GAAGtB,GAAG,CAACQ,aAAa,CAAE,OAAQ,CAAC;IACjDc,YAAY,CAACC,WAAW,GAAGH,WAAW,CAACJ,IAAI;IAE3Cf,QAAQ,CAACjB,IAAI,CAAEsC,YAAa,CAAC;EAC9B,CAAE,CACH,CAAC;EAED,OAAO,CACNtB,GAAG,CAACwB,aAAa,CAAE,OAAQ,CAAC,EAC5B,GAAGxB,GAAG,CAACG,gBAAgB,CAAE,OAAQ,CAAC,EAClC,GAAGF,QAAQ,CACX;AACF,CAAC","ignoreList":[]}
|
package/build-types/head.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The cache of prefetched stylesheets and scripts.
|
|
3
|
-
*/
|
|
4
|
-
export declare const headElements: Map<string, {
|
|
5
|
-
tag: HTMLElement;
|
|
6
|
-
text?: string;
|
|
7
|
-
}>;
|
|
8
|
-
/**
|
|
9
|
-
* Helper to update only the necessary tags in the head.
|
|
10
|
-
*
|
|
11
|
-
* @async
|
|
12
|
-
* @param newHead The head elements of the new page.
|
|
13
|
-
*/
|
|
14
|
-
export declare const updateHead: (newHead: HTMLHeadElement[]) => Promise<void>;
|
|
15
|
-
/**
|
|
16
|
-
* Fetches and processes head assets (stylesheets and scripts) from a specified document.
|
|
17
|
-
*
|
|
18
|
-
* @async
|
|
19
|
-
* @param doc The document from which to fetch head assets. It should support standard DOM querying methods.
|
|
20
|
-
*
|
|
21
|
-
* @return Returns an array of HTML elements representing the head assets.
|
|
22
|
-
*/
|
|
23
|
-
export declare const fetchHeadAssets: (doc: Document) => Promise<HTMLElement[]>;
|
|
24
|
-
//# sourceMappingURL=head.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"head.d.ts","sourceRoot":"","sources":["../src/head.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,YAAY;SAEjB,WAAW;WAAS,MAAM;EAC/B,CAAC;AAEJ;;;;;GAKG;AACH,eAAO,MAAM,UAAU,YAAoB,eAAe,EAAE,kBAuC3D,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,QACtB,QAAQ,KACX,OAAO,CAAE,WAAW,EAAE,CA4DxB,CAAC"}
|
package/src/head.ts
DELETED
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The cache of prefetched stylesheets and scripts.
|
|
3
|
-
*/
|
|
4
|
-
export const headElements = new Map<
|
|
5
|
-
string,
|
|
6
|
-
{ tag: HTMLElement; text?: string }
|
|
7
|
-
>();
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Helper to update only the necessary tags in the head.
|
|
11
|
-
*
|
|
12
|
-
* @async
|
|
13
|
-
* @param newHead The head elements of the new page.
|
|
14
|
-
*/
|
|
15
|
-
export const updateHead = async ( newHead: HTMLHeadElement[] ) => {
|
|
16
|
-
// Helper to get the tag id store in the cache.
|
|
17
|
-
const getTagId = ( tag: Element ) => tag.id || tag.outerHTML;
|
|
18
|
-
|
|
19
|
-
// Map incoming head tags by their content.
|
|
20
|
-
const newHeadMap = new Map< string, Element >();
|
|
21
|
-
for ( const child of newHead ) {
|
|
22
|
-
newHeadMap.set( getTagId( child ), child );
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const toRemove: Element[] = [];
|
|
26
|
-
|
|
27
|
-
// Detect nodes that should be added or removed.
|
|
28
|
-
for ( const child of document.head.children ) {
|
|
29
|
-
const id = getTagId( child );
|
|
30
|
-
// Always remove styles and links as they might change.
|
|
31
|
-
if ( child.nodeName === 'LINK' || child.nodeName === 'STYLE' ) {
|
|
32
|
-
toRemove.push( child );
|
|
33
|
-
} else if ( newHeadMap.has( id ) ) {
|
|
34
|
-
newHeadMap.delete( id );
|
|
35
|
-
} else if ( child.nodeName !== 'SCRIPT' && child.nodeName !== 'META' ) {
|
|
36
|
-
toRemove.push( child );
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
await Promise.all(
|
|
41
|
-
[ ...headElements.entries() ]
|
|
42
|
-
.filter( ( [ , { tag } ] ) => tag.nodeName === 'SCRIPT' )
|
|
43
|
-
.map( async ( [ url ] ) => {
|
|
44
|
-
await import( /* webpackIgnore: true */ url );
|
|
45
|
-
} )
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
// Prepare new assets.
|
|
49
|
-
const toAppend = [ ...newHeadMap.values() ];
|
|
50
|
-
|
|
51
|
-
// Apply the changes.
|
|
52
|
-
toRemove.forEach( ( n ) => n.remove() );
|
|
53
|
-
document.head.append( ...toAppend );
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Fetches and processes head assets (stylesheets and scripts) from a specified document.
|
|
58
|
-
*
|
|
59
|
-
* @async
|
|
60
|
-
* @param doc The document from which to fetch head assets. It should support standard DOM querying methods.
|
|
61
|
-
*
|
|
62
|
-
* @return Returns an array of HTML elements representing the head assets.
|
|
63
|
-
*/
|
|
64
|
-
export const fetchHeadAssets = async (
|
|
65
|
-
doc: Document
|
|
66
|
-
): Promise< HTMLElement[] > => {
|
|
67
|
-
const headTags = [];
|
|
68
|
-
|
|
69
|
-
// We only want to fetch module scripts because regular scripts (without
|
|
70
|
-
// `async` or `defer` attributes) can depend on the execution of other scripts.
|
|
71
|
-
// Scripts found in the head are blocking and must be executed in order.
|
|
72
|
-
const scripts = doc.querySelectorAll< HTMLScriptElement >(
|
|
73
|
-
'script[type="module"][src]'
|
|
74
|
-
);
|
|
75
|
-
|
|
76
|
-
scripts.forEach( ( script ) => {
|
|
77
|
-
const src = script.getAttribute( 'src' );
|
|
78
|
-
if ( ! headElements.has( src ) ) {
|
|
79
|
-
// add the <link> elements to prefetch the module scripts
|
|
80
|
-
const link = doc.createElement( 'link' );
|
|
81
|
-
link.rel = 'modulepreload';
|
|
82
|
-
link.href = src;
|
|
83
|
-
document.head.append( link );
|
|
84
|
-
headElements.set( src, { tag: script } );
|
|
85
|
-
}
|
|
86
|
-
} );
|
|
87
|
-
|
|
88
|
-
const stylesheets = doc.querySelectorAll< HTMLLinkElement >(
|
|
89
|
-
'link[rel=stylesheet]'
|
|
90
|
-
);
|
|
91
|
-
|
|
92
|
-
await Promise.all(
|
|
93
|
-
Array.from( stylesheets ).map( async ( tag ) => {
|
|
94
|
-
const href = tag.getAttribute( 'href' );
|
|
95
|
-
if ( ! href ) {
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
if ( ! headElements.has( href ) ) {
|
|
100
|
-
try {
|
|
101
|
-
const response = await fetch( href );
|
|
102
|
-
const text = await response.text();
|
|
103
|
-
headElements.set( href, {
|
|
104
|
-
tag,
|
|
105
|
-
text,
|
|
106
|
-
} );
|
|
107
|
-
} catch ( e ) {
|
|
108
|
-
// eslint-disable-next-line no-console
|
|
109
|
-
console.error( e );
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
const headElement = headElements.get( href );
|
|
114
|
-
const styleElement = doc.createElement( 'style' );
|
|
115
|
-
styleElement.textContent = headElement.text;
|
|
116
|
-
|
|
117
|
-
headTags.push( styleElement );
|
|
118
|
-
} )
|
|
119
|
-
);
|
|
120
|
-
|
|
121
|
-
return [
|
|
122
|
-
doc.querySelector( 'title' ),
|
|
123
|
-
...doc.querySelectorAll( 'style' ),
|
|
124
|
-
...headTags,
|
|
125
|
-
];
|
|
126
|
-
};
|
package/tsconfig.tsbuildinfo
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"fileNames":["../../node_modules/typescript/lib/lib.es5.d.ts","../../node_modules/typescript/lib/lib.es2015.d.ts","../../node_modules/typescript/lib/lib.es2016.d.ts","../../node_modules/typescript/lib/lib.es2017.d.ts","../../node_modules/typescript/lib/lib.es2018.d.ts","../../node_modules/typescript/lib/lib.es2019.d.ts","../../node_modules/typescript/lib/lib.es2020.d.ts","../../node_modules/typescript/lib/lib.es2021.d.ts","../../node_modules/typescript/lib/lib.es2022.d.ts","../../node_modules/typescript/lib/lib.es2023.d.ts","../../node_modules/typescript/lib/lib.es2024.d.ts","../../node_modules/typescript/lib/lib.esnext.d.ts","../../node_modules/typescript/lib/lib.dom.d.ts","../../node_modules/typescript/lib/lib.dom.iterable.d.ts","../../node_modules/typescript/lib/lib.es2015.core.d.ts","../../node_modules/typescript/lib/lib.es2015.collection.d.ts","../../node_modules/typescript/lib/lib.es2015.generator.d.ts","../../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../node_modules/typescript/lib/lib.es2015.promise.d.ts","../../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../node_modules/typescript/lib/lib.es2016.intl.d.ts","../../node_modules/typescript/lib/lib.es2017.arraybuffer.d.ts","../../node_modules/typescript/lib/lib.es2017.date.d.ts","../../node_modules/typescript/lib/lib.es2017.object.d.ts","../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2017.string.d.ts","../../node_modules/typescript/lib/lib.es2017.intl.d.ts","../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../node_modules/typescript/lib/lib.es2018.intl.d.ts","../../node_modules/typescript/lib/lib.es2018.promise.d.ts","../../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../node_modules/typescript/lib/lib.es2019.array.d.ts","../../node_modules/typescript/lib/lib.es2019.object.d.ts","../../node_modules/typescript/lib/lib.es2019.string.d.ts","../../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../node_modules/typescript/lib/lib.es2019.intl.d.ts","../../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../node_modules/typescript/lib/lib.es2020.date.d.ts","../../node_modules/typescript/lib/lib.es2020.promise.d.ts","../../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2020.string.d.ts","../../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../node_modules/typescript/lib/lib.es2020.intl.d.ts","../../node_modules/typescript/lib/lib.es2020.number.d.ts","../../node_modules/typescript/lib/lib.es2021.promise.d.ts","../../node_modules/typescript/lib/lib.es2021.string.d.ts","../../node_modules/typescript/lib/lib.es2021.weakref.d.ts","../../node_modules/typescript/lib/lib.es2021.intl.d.ts","../../node_modules/typescript/lib/lib.es2022.array.d.ts","../../node_modules/typescript/lib/lib.es2022.error.d.ts","../../node_modules/typescript/lib/lib.es2022.intl.d.ts","../../node_modules/typescript/lib/lib.es2022.object.d.ts","../../node_modules/typescript/lib/lib.es2022.string.d.ts","../../node_modules/typescript/lib/lib.es2022.regexp.d.ts","../../node_modules/typescript/lib/lib.es2023.array.d.ts","../../node_modules/typescript/lib/lib.es2023.collection.d.ts","../../node_modules/typescript/lib/lib.es2023.intl.d.ts","../../node_modules/typescript/lib/lib.es2024.arraybuffer.d.ts","../../node_modules/typescript/lib/lib.es2024.collection.d.ts","../../node_modules/typescript/lib/lib.es2024.object.d.ts","../../node_modules/typescript/lib/lib.es2024.promise.d.ts","../../node_modules/typescript/lib/lib.es2024.regexp.d.ts","../../node_modules/typescript/lib/lib.es2024.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2024.string.d.ts","../../node_modules/typescript/lib/lib.esnext.array.d.ts","../../node_modules/typescript/lib/lib.esnext.collection.d.ts","../../node_modules/typescript/lib/lib.esnext.intl.d.ts","../../node_modules/typescript/lib/lib.esnext.disposable.d.ts","../../node_modules/typescript/lib/lib.esnext.decorators.d.ts","../../node_modules/typescript/lib/lib.esnext.iterator.d.ts","../../node_modules/typescript/lib/lib.decorators.d.ts","../../node_modules/typescript/lib/lib.decorators.legacy.d.ts","./src/head.ts","../interactivity/build-types/store.d.ts","../../node_modules/preact/src/jsx.d.ts","../../node_modules/preact/src/index.d.ts","../interactivity/build-types/hooks.d.ts","../interactivity/build-types/scopes.d.ts","../../node_modules/preact/hooks/src/index.d.ts","../interactivity/build-types/utils.d.ts","../interactivity/build-types/index.d.ts","../a11y/build-types/shared/index.d.ts","../a11y/build-types/index.d.ts","./src/index.ts"],"fileIdsList":[[82],[81],[88],[79,87,89],[82,84],[80,84,85,86],[82,83],[85]],"fileInfos":[{"version":"e41c290ef7dd7dab3493e6cbe5909e0148edf4a8dad0271be08edec368a0f7b9","affectsGlobalScope":true,"impliedFormat":1},{"version":"45b7ab580deca34ae9729e97c13cfd999df04416a79116c3bfb483804f85ded4","impliedFormat":1},{"version":"3facaf05f0c5fc569c5649dd359892c98a85557e3e0c847964caeb67076f4d75","impliedFormat":1},{"version":"e44bb8bbac7f10ecc786703fe0a6a4b952189f908707980ba8f3c8975a760962","impliedFormat":1},{"version":"5e1c4c362065a6b95ff952c0eab010f04dcd2c3494e813b493ecfd4fcb9fc0d8","impliedFormat":1},{"version":"68d73b4a11549f9c0b7d352d10e91e5dca8faa3322bfb77b661839c42b1ddec7","impliedFormat":1},{"version":"5efce4fc3c29ea84e8928f97adec086e3dc876365e0982cc8479a07954a3efd4","impliedFormat":1},{"version":"feecb1be483ed332fad555aff858affd90a48ab19ba7272ee084704eb7167569","impliedFormat":1},{"version":"ee7bad0c15b58988daa84371e0b89d313b762ab83cb5b31b8a2d1162e8eb41c2","impliedFormat":1},{"version":"27bdc30a0e32783366a5abeda841bc22757c1797de8681bbe81fbc735eeb1c10","impliedFormat":1},{"version":"8fd575e12870e9944c7e1d62e1f5a73fcf23dd8d3a321f2a2c74c20d022283fe","impliedFormat":1},{"version":"e12a46ce14b817d4c9e6b2b478956452330bf00c9801b79de46f7a1815b5bd40","impliedFormat":1},{"version":"4fd3f3422b2d2a3dfd5cdd0f387b3a8ec45f006c6ea896a4cb41264c2100bb2c","affectsGlobalScope":true,"impliedFormat":1},{"version":"69e65d976bf166ce4a9e6f6c18f94d2424bf116e90837ace179610dbccad9b42","affectsGlobalScope":true,"impliedFormat":1},{"version":"c57796738e7f83dbc4b8e65132f11a377649c00dd3eee333f672b8f0a6bea671","affectsGlobalScope":true,"impliedFormat":1},{"version":"dc2df20b1bcdc8c2d34af4926e2c3ab15ffe1160a63e58b7e09833f616efff44","affectsGlobalScope":true,"impliedFormat":1},{"version":"515d0b7b9bea2e31ea4ec968e9edd2c39d3eebf4a2d5cbd04e88639819ae3b71","affectsGlobalScope":true,"impliedFormat":1},{"version":"62bb211266ee48b2d0edf0d8d1b191f0c24fc379a82bd4c1692a082c540bc6b1","affectsGlobalScope":true,"impliedFormat":1},{"version":"0dc1e7ceda9b8b9b455c3a2d67b0412feab00bd2f66656cd8850e8831b08b537","affectsGlobalScope":true,"impliedFormat":1},{"version":"ce691fb9e5c64efb9547083e4a34091bcbe5bdb41027e310ebba8f7d96a98671","affectsGlobalScope":true,"impliedFormat":1},{"version":"8d697a2a929a5fcb38b7a65594020fcef05ec1630804a33748829c5ff53640d0","affectsGlobalScope":true,"impliedFormat":1},{"version":"4ff2a353abf8a80ee399af572debb8faab2d33ad38c4b4474cff7f26e7653b8d","affectsGlobalScope":true,"impliedFormat":1},{"version":"936e80ad36a2ee83fc3caf008e7c4c5afe45b3cf3d5c24408f039c1d47bdc1df","affectsGlobalScope":true,"impliedFormat":1},{"version":"d15bea3d62cbbdb9797079416b8ac375ae99162a7fba5de2c6c505446486ac0a","affectsGlobalScope":true,"impliedFormat":1},{"version":"68d18b664c9d32a7336a70235958b8997ebc1c3b8505f4f1ae2b7e7753b87618","affectsGlobalScope":true,"impliedFormat":1},{"version":"eb3d66c8327153d8fa7dd03f9c58d351107fe824c79e9b56b462935176cdf12a","affectsGlobalScope":true,"impliedFormat":1},{"version":"38f0219c9e23c915ef9790ab1d680440d95419ad264816fa15009a8851e79119","affectsGlobalScope":true,"impliedFormat":1},{"version":"69ab18c3b76cd9b1be3d188eaf8bba06112ebbe2f47f6c322b5105a6fbc45a2e","affectsGlobalScope":true,"impliedFormat":1},{"version":"fef8cfad2e2dc5f5b3d97a6f4f2e92848eb1b88e897bb7318cef0e2820bceaab","affectsGlobalScope":true,"impliedFormat":1},{"version":"2f11ff796926e0832f9ae148008138ad583bd181899ab7dd768a2666700b1893","affectsGlobalScope":true,"impliedFormat":1},{"version":"4de680d5bb41c17f7f68e0419412ca23c98d5749dcaaea1896172f06435891fc","affectsGlobalScope":true,"impliedFormat":1},{"version":"954296b30da6d508a104a3a0b5d96b76495c709785c1d11610908e63481ee667","affectsGlobalScope":true,"impliedFormat":1},{"version":"ac9538681b19688c8eae65811b329d3744af679e0bdfa5d842d0e32524c73e1c","affectsGlobalScope":true,"impliedFormat":1},{"version":"0a969edff4bd52585473d24995c5ef223f6652d6ef46193309b3921d65dd4376","affectsGlobalScope":true,"impliedFormat":1},{"version":"9e9fbd7030c440b33d021da145d3232984c8bb7916f277e8ffd3dc2e3eae2bdb","affectsGlobalScope":true,"impliedFormat":1},{"version":"811ec78f7fefcabbda4bfa93b3eb67d9ae166ef95f9bff989d964061cbf81a0c","affectsGlobalScope":true,"impliedFormat":1},{"version":"717937616a17072082152a2ef351cb51f98802fb4b2fdabd32399843875974ca","affectsGlobalScope":true,"impliedFormat":1},{"version":"d7e7d9b7b50e5f22c915b525acc5a49a7a6584cf8f62d0569e557c5cfc4b2ac2","affectsGlobalScope":true,"impliedFormat":1},{"version":"71c37f4c9543f31dfced6c7840e068c5a5aacb7b89111a4364b1d5276b852557","affectsGlobalScope":true,"impliedFormat":1},{"version":"576711e016cf4f1804676043e6a0a5414252560eb57de9faceee34d79798c850","affectsGlobalScope":true,"impliedFormat":1},{"version":"89c1b1281ba7b8a96efc676b11b264de7a8374c5ea1e6617f11880a13fc56dc6","affectsGlobalScope":true,"impliedFormat":1},{"version":"74f7fa2d027d5b33eb0471c8e82a6c87216223181ec31247c357a3e8e2fddc5b","affectsGlobalScope":true,"impliedFormat":1},{"version":"f1e2a172204962276504466a6393426d2ca9c54894b1ad0a6c9dad867a65f876","affectsGlobalScope":true,"impliedFormat":1},{"version":"063600664504610fe3e99b717a1223f8b1900087fab0b4cad1496a114744f8df","affectsGlobalScope":true,"impliedFormat":1},{"version":"934019d7e3c81950f9a8426d093458b65d5aff2c7c1511233c0fd5b941e608ab","affectsGlobalScope":true,"impliedFormat":1},{"version":"52ada8e0b6e0482b728070b7639ee42e83a9b1c22d205992756fe020fd9f4a47","affectsGlobalScope":true,"impliedFormat":1},{"version":"3bdefe1bfd4d6dee0e26f928f93ccc128f1b64d5d501ff4a8cf3c6371200e5e6","affectsGlobalScope":true,"impliedFormat":1},{"version":"59fb2c069260b4ba00b5643b907ef5d5341b167e7d1dbf58dfd895658bda2867","affectsGlobalScope":true,"impliedFormat":1},{"version":"639e512c0dfc3fad96a84caad71b8834d66329a1f28dc95e3946c9b58176c73a","affectsGlobalScope":true,"impliedFormat":1},{"version":"368af93f74c9c932edd84c58883e736c9e3d53cec1fe24c0b0ff451f529ceab1","affectsGlobalScope":true,"impliedFormat":1},{"version":"af3dd424cf267428f30ccfc376f47a2c0114546b55c44d8c0f1d57d841e28d74","affectsGlobalScope":true,"impliedFormat":1},{"version":"995c005ab91a498455ea8dfb63aa9f83fa2ea793c3d8aa344be4a1678d06d399","affectsGlobalScope":true,"impliedFormat":1},{"version":"959d36cddf5e7d572a65045b876f2956c973a586da58e5d26cde519184fd9b8a","affectsGlobalScope":true,"impliedFormat":1},{"version":"965f36eae237dd74e6cca203a43e9ca801ce38824ead814728a2807b1910117d","affectsGlobalScope":true,"impliedFormat":1},{"version":"3925a6c820dcb1a06506c90b1577db1fdbf7705d65b62b99dce4be75c637e26b","affectsGlobalScope":true,"impliedFormat":1},{"version":"0a3d63ef2b853447ec4f749d3f368ce642264246e02911fcb1590d8c161b8005","affectsGlobalScope":true,"impliedFormat":1},{"version":"b5ce7a470bc3628408429040c4e3a53a27755022a32fd05e2cb694e7015386c7","affectsGlobalScope":true,"impliedFormat":1},{"version":"8444af78980e3b20b49324f4a16ba35024fef3ee069a0eb67616ea6ca821c47a","affectsGlobalScope":true,"impliedFormat":1},{"version":"3287d9d085fbd618c3971944b65b4be57859f5415f495b33a6adc994edd2f004","affectsGlobalScope":true,"impliedFormat":1},{"version":"b4b67b1a91182421f5df999988c690f14d813b9850b40acd06ed44691f6727ad","affectsGlobalScope":true,"impliedFormat":1},{"version":"bab26767638ab3557de12c900f0b91f710c7dc40ee9793d5a27d32c04f0bf646","affectsGlobalScope":true,"impliedFormat":1},{"version":"436aaf437562f276ec2ddbee2f2cdedac7664c1e4c1d2c36839ddd582eeb3d0a","affectsGlobalScope":true,"impliedFormat":1},{"version":"8e3c06ea092138bf9fa5e874a1fdbc9d54805d074bee1de31b99a11e2fec239d","affectsGlobalScope":true,"impliedFormat":1},{"version":"87dc0f382502f5bbce5129bdc0aea21e19a3abbc19259e0b43ae038a9fc4e326","affectsGlobalScope":true,"impliedFormat":1},{"version":"b1cb28af0c891c8c96b2d6b7be76bd394fddcfdb4709a20ba05a7c1605eea0f9","affectsGlobalScope":true,"impliedFormat":1},{"version":"2fef54945a13095fdb9b84f705f2b5994597640c46afeb2ce78352fab4cb3279","affectsGlobalScope":true,"impliedFormat":1},{"version":"ac77cb3e8c6d3565793eb90a8373ee8033146315a3dbead3bde8db5eaf5e5ec6","affectsGlobalScope":true,"impliedFormat":1},{"version":"56e4ed5aab5f5920980066a9409bfaf53e6d21d3f8d020c17e4de584d29600ad","affectsGlobalScope":true,"impliedFormat":1},{"version":"4ece9f17b3866cc077099c73f4983bddbcb1dc7ddb943227f1ec070f529dedd1","affectsGlobalScope":true,"impliedFormat":1},{"version":"0a6282c8827e4b9a95f4bf4f5c205673ada31b982f50572d27103df8ceb8013c","affectsGlobalScope":true,"impliedFormat":1},{"version":"1c9319a09485199c1f7b0498f2988d6d2249793ef67edda49d1e584746be9032","affectsGlobalScope":true,"impliedFormat":1},{"version":"e3a2a0cee0f03ffdde24d89660eba2685bfbdeae955a6c67e8c4c9fd28928eeb","affectsGlobalScope":true,"impliedFormat":1},{"version":"811c71eee4aa0ac5f7adf713323a5c41b0cf6c4e17367a34fbce379e12bbf0a4","affectsGlobalScope":true,"impliedFormat":1},{"version":"51ad4c928303041605b4d7ae32e0c1ee387d43a24cd6f1ebf4a2699e1076d4fa","affectsGlobalScope":true,"impliedFormat":1},{"version":"d4b1d2c51d058fc21ec2629fff7a76249dec2e36e12960ea056e3ef89174080f","affectsGlobalScope":true,"impliedFormat":1},{"version":"61d6a2092f48af66dbfb220e31eea8b10bc02b6932d6e529005fd2d7b3281290","affectsGlobalScope":true,"impliedFormat":1},{"version":"8e7f8264d0fb4c5339605a15daadb037bf238c10b654bb3eee14208f860a32ea","affectsGlobalScope":true,"impliedFormat":1},{"version":"782dec38049b92d4e85c1585fbea5474a219c6984a35b004963b00beb1aab538","affectsGlobalScope":true,"impliedFormat":1},{"version":"3baf94d12710eda67f87ec776b03bd0267990d8db31a044f766bec1128cacb24","signature":"64bb86deca70ca30d98f364dc728160353abef09db33943129118869a4ecb38a"},"35200cbd3643ecba3f1f95c20ded41a2749f22285063ffd6a137494de101840a",{"version":"fd40c454d56e1d14e60ce13f3bc60c7fdb9bc70c6ef9c7bfafec1f0eb5d8075b","impliedFormat":1},{"version":"155ced96d70533d95c481061e2691802fae7cfb96869d7c85ac8622f53b51cb7","impliedFormat":1},"683340462fafe67564ee08e79189582af632c6f2664eed7de3b18bfc3b67baa8","4b77de664157c408100eece72ad45f86ce995ea97c6d2165659a26eb558e2668",{"version":"fbc22df38ad21e518d0362b71669e8cc46b77018b096be6d26de1403b5c3f7c6","impliedFormat":1},{"version":"a6bb9b77925316a4d4d6956a4430465cceb36b735bbdb5c12992c9027f49685c","affectsGlobalScope":true},"6c76b25315f67becb8aa00d051292ab5ec0e91d709cdfcd59ee6672c3bc188ae","40cfbc59eaef297a6cbc6f871853e4b8bba4cdc2d12c3d8e73e21a28d8280162","3d7a81d5202f0ecb42a07bc4973e2094e291aefd583413f98b1cfdbb1d4e0816",{"version":"b6c2f0712730ebc7828fcfc3f31cd67ba4d01dbdad42df12e00ef8d6eec158d0","signature":"9f78ce079d21978b746d52f58c245a99df5e8aad36796317302939e210c9bb8d"}],"root":[79,90],"options":{"allowJs":true,"allowSyntheticDefaultImports":true,"checkJs":false,"composite":true,"declaration":true,"declarationDir":"./build-types","declarationMap":true,"emitDeclarationOnly":true,"esModuleInterop":false,"jsx":1,"module":99,"noFallthroughCasesInSwitch":true,"noImplicitReturns":true,"rootDir":"./src","skipDefaultLibCheck":true,"strict":false,"target":99},"referencedMap":[[85,1],[82,2],[81,1],[89,3],[90,4],[83,5],[87,6],[84,7],[86,8]],"latestChangedDtsFile":"./build-types/index.d.ts","version":"5.7.2"}
|