@wordpress/interactivity-router 2.14.0 → 2.15.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.
@@ -0,0 +1,2 @@
1
+ export declare const generateCSSStyleSheets: (doc: Document, baseUrl?: string) => Promise<CSSStyleSheet>[];
2
+ //# sourceMappingURL=styles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../src/assets/styles.ts"],"names":[],"mappings":"AAmEA,eAAO,MAAM,sBAAsB,QAC7B,QAAQ,YACJ,MAAM,KACb,OAAO,CAAE,aAAa,CAAE,EAQzB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAuBA,UAAU,eAAe;IACxB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,wBAAwB,CAAC,EAAE,OAAO,CAAC;CACnC;AAED,UAAU,eAAe;IACxB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACd;AAyMD,eAAO,MAAQ,KAAK;SAbb,MAAM;;mBAEC,OAAO;oBACN,OAAO;qBACN,OAAO;;GASD,OAAO;cALjB,CAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe,KAAM,IAAI;cACnD,CAAE,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe,KAAM,IAAI;CAmJ3D,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAuBA,UAAU,eAAe;IACxB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,wBAAwB,CAAC,EAAE,OAAO,CAAC;CACnC;AAED,UAAU,eAAe;IACxB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACd;AAoND,eAAO,MAAQ,KAAK;SAbb,MAAM;;mBAEC,OAAO;oBACN,OAAO;qBACN,OAAO;;GASD,OAAO;cALjB,CAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe,KAAM,IAAI;cACnD,CAAE,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe,KAAM,IAAI;CAmJ3D,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/interactivity-router",
3
- "version": "2.14.0",
3
+ "version": "2.15.0",
4
4
  "description": "Package that exposes state and actions from the `core/router` store, part of the Interactivity API.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -28,11 +28,11 @@
28
28
  "wpScriptModuleExports": "./build-module/index.js",
29
29
  "types": "build-types",
30
30
  "dependencies": {
31
- "@wordpress/a11y": "*",
32
- "@wordpress/interactivity": "*"
31
+ "@wordpress/a11y": "^4.15.0",
32
+ "@wordpress/interactivity": "^6.15.0"
33
33
  },
34
34
  "publishConfig": {
35
35
  "access": "public"
36
36
  },
37
- "gitHead": "b432c18934c9db866b6dba7d37517a4e97d642e3"
37
+ "gitHead": "75a65eb8ffc168a92042544052f46d080a71ea45"
38
38
  }
@@ -0,0 +1,79 @@
1
+ const cssUrlRegEx =
2
+ /url\(\s*(?:(["'])((?:\\.|[^\n\\"'])+)\1|((?:\\.|[^\s,"'()\\])+))\s*\)/g;
3
+
4
+ const resolveUrl = ( relativeUrl: string, baseUrl: string ) => {
5
+ try {
6
+ return new URL( relativeUrl, baseUrl ).toString();
7
+ } catch ( e ) {
8
+ return relativeUrl;
9
+ }
10
+ };
11
+
12
+ const withAbsoluteUrls = ( cssText: string, baseUrl: string ) =>
13
+ cssText.replace(
14
+ cssUrlRegEx,
15
+ ( _match, quotes = '', relUrl1, relUrl2 ) =>
16
+ `url(${ quotes }${ resolveUrl(
17
+ relUrl1 || relUrl2,
18
+ baseUrl
19
+ ) }${ quotes })`
20
+ );
21
+
22
+ const styleSheetCache = new Map< string, Promise< CSSStyleSheet > >();
23
+
24
+ const getCachedSheet = async (
25
+ sheetId: string,
26
+ factory: () => Promise< CSSStyleSheet >
27
+ ) => {
28
+ if ( ! styleSheetCache.has( sheetId ) ) {
29
+ styleSheetCache.set( sheetId, factory() );
30
+ }
31
+ return styleSheetCache.get( sheetId );
32
+ };
33
+
34
+ const sheetFromLink = async (
35
+ { id, href, sheet: elementSheet }: HTMLLinkElement,
36
+ baseUrl: string
37
+ ) => {
38
+ const sheetId = id || href;
39
+ const sheetUrl = resolveUrl( href, baseUrl );
40
+
41
+ if ( elementSheet ) {
42
+ return getCachedSheet( sheetId, () => {
43
+ const sheet = new CSSStyleSheet();
44
+ for ( const { cssText } of elementSheet.cssRules ) {
45
+ sheet.insertRule( withAbsoluteUrls( cssText, sheetUrl ) );
46
+ }
47
+ return Promise.resolve( sheet );
48
+ } );
49
+ }
50
+ return getCachedSheet( sheetId, async () => {
51
+ const response = await fetch( href );
52
+ const text = await response.text();
53
+ const sheet = new CSSStyleSheet();
54
+ await sheet.replace( withAbsoluteUrls( text, sheetUrl ) );
55
+ return sheet;
56
+ } );
57
+ };
58
+
59
+ const sheetFromStyle = async ( { textContent }: HTMLStyleElement ) => {
60
+ const sheetId = textContent;
61
+ return getCachedSheet( sheetId, async () => {
62
+ const sheet = new CSSStyleSheet();
63
+ await sheet.replace( textContent );
64
+ return sheet;
65
+ } );
66
+ };
67
+
68
+ export const generateCSSStyleSheets = (
69
+ doc: Document,
70
+ baseUrl: string = ( doc.location || window.location ).href
71
+ ): Promise< CSSStyleSheet >[] =>
72
+ [ ...doc.querySelectorAll( 'style,link[rel=stylesheet]' ) ].map(
73
+ ( element ) => {
74
+ if ( 'LINK' === element.nodeName ) {
75
+ return sheetFromLink( element as HTMLLinkElement, baseUrl );
76
+ }
77
+ return sheetFromStyle( element as HTMLStyleElement );
78
+ }
79
+ );
package/src/index.ts CHANGED
@@ -6,7 +6,7 @@ import { store, privateApis, getConfig } from '@wordpress/interactivity';
6
6
  /**
7
7
  * Internal dependencies
8
8
  */
9
- import { fetchHeadAssets, updateHead, headElements } from './head';
9
+ import { generateCSSStyleSheets } from './assets/styles';
10
10
 
11
11
  const {
12
12
  directivePrefix,
@@ -37,16 +37,18 @@ interface PrefetchOptions {
37
37
 
38
38
  interface VdomParams {
39
39
  vdom?: typeof initialVdom;
40
+ baseUrl?: string;
40
41
  }
41
42
 
42
43
  interface Page {
43
44
  regions: Record< string, any >;
44
- head: HTMLHeadElement[];
45
+ styles: Promise< CSSStyleSheet >[];
46
+ scriptModules: string[];
45
47
  title: string;
46
48
  initialData: any;
47
49
  }
48
50
 
49
- type RegionsToVdom = ( dom: Document, params?: VdomParams ) => Promise< Page >;
51
+ type RegionsToVdom = ( dom: Document, params?: VdomParams ) => Page;
50
52
 
51
53
  // Check if the navigation mode is full page or region based.
52
54
  const navigationMode: 'regionBased' | 'fullPage' =
@@ -73,7 +75,7 @@ const fetchPage = async ( url: string, { html }: { html: string } ) => {
73
75
  html = await res.text();
74
76
  }
75
77
  const dom = new window.DOMParser().parseFromString( html, 'text/html' );
76
- return regionsToVdom( dom );
78
+ return regionsToVdom( dom, { baseUrl: url } );
77
79
  } catch ( e ) {
78
80
  return false;
79
81
  }
@@ -81,12 +83,17 @@ const fetchPage = async ( url: string, { html }: { html: string } ) => {
81
83
 
82
84
  // Return an object with VDOM trees of those HTML regions marked with a
83
85
  // `router-region` directive.
84
- const regionsToVdom: RegionsToVdom = async ( dom, { vdom } = {} ) => {
86
+ const regionsToVdom: RegionsToVdom = ( dom, { vdom, baseUrl } = {} ) => {
85
87
  const regions = { body: undefined };
86
- let head: HTMLElement[];
88
+ const styles = generateCSSStyleSheets( dom, baseUrl );
89
+ const scriptModules = [
90
+ ...dom.querySelectorAll< HTMLScriptElement >(
91
+ 'script[type=module][src]'
92
+ ),
93
+ ].map( ( s ) => s.src );
94
+
87
95
  if ( globalThis.IS_GUTENBERG_PLUGIN ) {
88
96
  if ( navigationMode === 'fullPage' ) {
89
- head = await fetchHeadAssets( dom );
90
97
  regions.body = vdom
91
98
  ? vdom.get( document.body )
92
99
  : toVdom( dom.body );
@@ -103,15 +110,28 @@ const regionsToVdom: RegionsToVdom = async ( dom, { vdom } = {} ) => {
103
110
  }
104
111
  const title = dom.querySelector( 'title' )?.innerText;
105
112
  const initialData = parseServerData( dom );
106
- return { regions, head, title, initialData };
113
+ return { regions, styles, scriptModules, title, initialData };
107
114
  };
108
115
 
109
116
  // Render all interactive regions contained in the given page.
110
117
  const renderRegions = async ( page: Page ) => {
118
+ // Wait for styles and modules to be ready.
119
+ await Promise.all( [
120
+ ...page.styles,
121
+ ...page.scriptModules.map(
122
+ ( src ) => import( /* webpackIgnore: true */ src )
123
+ ),
124
+ ] );
125
+ // Replace style sheets.
126
+ const sheets = await Promise.all( page.styles );
127
+ window.document
128
+ .querySelectorAll( 'style,link[rel=stylesheet]' )
129
+ .forEach( ( element ) => element.remove() );
130
+ window.document.adoptedStyleSheets = sheets;
131
+
111
132
  if ( globalThis.IS_GUTENBERG_PLUGIN ) {
112
133
  if ( navigationMode === 'fullPage' ) {
113
- // Once this code is tested and more mature, the head should be updated for region based navigation as well.
114
- await updateHead( page.head );
134
+ // Update HTML.
115
135
  const fragment = getRegionRootFragment( document.body );
116
136
  batch( () => {
117
137
  populateServerData( page.initialData );
@@ -169,23 +189,14 @@ window.addEventListener( 'popstate', async () => {
169
189
  // Initialize the router and cache the initial page using the initial vDOM.
170
190
  // Once this code is tested and more mature, the head should be updated for
171
191
  // region based navigation as well.
172
- if ( globalThis.IS_GUTENBERG_PLUGIN ) {
173
- if ( navigationMode === 'fullPage' ) {
174
- // Cache the scripts. Has to be called before fetching the assets.
175
- [].map.call(
176
- document.querySelectorAll( 'script[type="module"][src]' ),
177
- ( script ) => {
178
- headElements.set( script.getAttribute( 'src' ), {
179
- tag: script,
180
- } );
181
- }
182
- );
183
- await fetchHeadAssets( document );
184
- }
185
- }
186
192
  pages.set(
187
193
  getPagePath( window.location.href ),
188
- Promise.resolve( regionsToVdom( document, { vdom: initialVdom } ) )
194
+ Promise.resolve(
195
+ regionsToVdom( document, {
196
+ vdom: initialVdom,
197
+ baseUrl: window.location.href,
198
+ } )
199
+ )
189
200
  );
190
201
 
191
202
  // Check if the link is valid for client-side navigation.
package/tsconfig.json CHANGED
@@ -2,11 +2,8 @@
2
2
  "$schema": "https://json.schemastore.org/tsconfig.json",
3
3
  "extends": "../../tsconfig.base.json",
4
4
  "compilerOptions": {
5
- "rootDir": "src",
6
- "declarationDir": "build-types",
7
5
  "checkJs": false,
8
6
  "strict": false
9
7
  },
10
- "references": [ { "path": "../a11y" }, { "path": "../interactivity" } ],
11
- "include": [ "src/**/*" ]
8
+ "references": [ { "path": "../a11y" }, { "path": "../interactivity" } ]
12
9
  }
@@ -1 +1 @@
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"},"69f13876e392e388986ac410bf390e366289d441749272434c5af9bf74d3a26c",{"version":"fd40c454d56e1d14e60ce13f3bc60c7fdb9bc70c6ef9c7bfafec1f0eb5d8075b","impliedFormat":1},{"version":"155ced96d70533d95c481061e2691802fae7cfb96869d7c85ac8622f53b51cb7","impliedFormat":1},"aa0bb56ffb502ea9f5ccdfee28da9ddcc1a5958e376fb34059a593e65420d76f","3f6aec309abf78b3c614cd291c1338c87af8bd0a4bf7287ccb5f987bae33724b",{"version":"fbc22df38ad21e518d0362b71669e8cc46b77018b096be6d26de1403b5c3f7c6","impliedFormat":1},{"version":"a04bc5fc388a5da69f70c6e0cd1b5aa6bbfeae9338dd1c6c81466236bf4c9d1e","affectsGlobalScope":true},"77b39f45a829c695432cd2544d0420e1b8e3a907907eb3b5dd4cb0917f00f1df","40cfbc59eaef297a6cbc6f871853e4b8bba4cdc2d12c3d8e73e21a28d8280162","3d7a81d5202f0ecb42a07bc4973e2094e291aefd583413f98b1cfdbb1d4e0816",{"version":"8e3533435daa7e79c9ea3395ad487f99e0144e029c536e656c8cfa39a59f8d40","signature":"20c909aa9a7b55aff3379a7de311655042c086b40a772104ea2b9153384150fb"}],"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"}
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","../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","./src/assets/styles.ts","../a11y/build-types/shared/index.d.ts","../a11y/build-types/index.d.ts","./src/index.ts"],"fileIdsList":[[81],[80],[88],[86,87,89],[81,83],[79,83,84,85],[81,82],[84]],"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},"69f13876e392e388986ac410bf390e366289d441749272434c5af9bf74d3a26c",{"version":"fd40c454d56e1d14e60ce13f3bc60c7fdb9bc70c6ef9c7bfafec1f0eb5d8075b","impliedFormat":1},{"version":"155ced96d70533d95c481061e2691802fae7cfb96869d7c85ac8622f53b51cb7","impliedFormat":1},"683340462fafe67564ee08e79189582af632c6f2664eed7de3b18bfc3b67baa8","3f6aec309abf78b3c614cd291c1338c87af8bd0a4bf7287ccb5f987bae33724b",{"version":"fbc22df38ad21e518d0362b71669e8cc46b77018b096be6d26de1403b5c3f7c6","impliedFormat":1},{"version":"a04bc5fc388a5da69f70c6e0cd1b5aa6bbfeae9338dd1c6c81466236bf4c9d1e","affectsGlobalScope":true},"77b39f45a829c695432cd2544d0420e1b8e3a907907eb3b5dd4cb0917f00f1df",{"version":"dd410bd231bce5767f9bef6d4ad4479eb0e4a76dc370ba5e6fc740edb83092bc","signature":"cdb035ffd7e94a0b5f53cc837f7018f8e5f34f176ef9603d86c15bfa3e2f37fd"},"40cfbc59eaef297a6cbc6f871853e4b8bba4cdc2d12c3d8e73e21a28d8280162","3d7a81d5202f0ecb42a07bc4973e2094e291aefd583413f98b1cfdbb1d4e0816",{"version":"00b3f72af8fc8273fb8163d69467104f3643b39d89143d58b1f3f678f64ea8a4","signature":"20c909aa9a7b55aff3379a7de311655042c086b40a772104ea2b9153384150fb"}],"root":[87,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":[[84,1],[81,2],[80,1],[89,3],[90,4],[82,5],[86,6],[83,7],[85,8]],"latestChangedDtsFile":"./build-types/index.d.ts","version":"5.7.2"}
package/build/head.js DELETED
@@ -1,114 +0,0 @@
1
- /* wp:polyfill */
2
- "use strict";
3
-
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.updateHead = exports.headElements = exports.fetchHeadAssets = void 0;
8
- 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); }
9
- 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; }
10
- /**
11
- * The cache of prefetched stylesheets and scripts.
12
- */
13
- const headElements = exports.headElements = new Map();
14
-
15
- /**
16
- * Helper to update only the necessary tags in the head.
17
- *
18
- * @async
19
- * @param newHead The head elements of the new page.
20
- */
21
- const updateHead = async newHead => {
22
- // Helper to get the tag id store in the cache.
23
- const getTagId = tag => tag.id || tag.outerHTML;
24
-
25
- // Map incoming head tags by their content.
26
- const newHeadMap = new Map();
27
- for (const child of newHead) {
28
- newHeadMap.set(getTagId(child), child);
29
- }
30
- const toRemove = [];
31
-
32
- // Detect nodes that should be added or removed.
33
- for (const child of document.head.children) {
34
- const id = getTagId(child);
35
- // Always remove styles and links as they might change.
36
- if (child.nodeName === 'LINK' || child.nodeName === 'STYLE') {
37
- toRemove.push(child);
38
- } else if (newHeadMap.has(id)) {
39
- newHeadMap.delete(id);
40
- } else if (child.nodeName !== 'SCRIPT' && child.nodeName !== 'META') {
41
- toRemove.push(child);
42
- }
43
- }
44
- await Promise.all([...headElements.entries()].filter(([, {
45
- tag
46
- }]) => tag.nodeName === 'SCRIPT').map(async ([url]) => {
47
- await (specifier => new Promise(r => r(`${specifier}`)).then(s => _interopRequireWildcard(require(s))))(/* webpackIgnore: true */url);
48
- }));
49
-
50
- // Prepare new assets.
51
- const toAppend = [...newHeadMap.values()];
52
-
53
- // Apply the changes.
54
- toRemove.forEach(n => n.remove());
55
- document.head.append(...toAppend);
56
- };
57
-
58
- /**
59
- * Fetches and processes head assets (stylesheets and scripts) from a specified document.
60
- *
61
- * @async
62
- * @param doc The document from which to fetch head assets. It should support standard DOM querying methods.
63
- *
64
- * @return Returns an array of HTML elements representing the head assets.
65
- */
66
- exports.updateHead = updateHead;
67
- const fetchHeadAssets = async doc => {
68
- const headTags = [];
69
-
70
- // We only want to fetch module scripts because regular scripts (without
71
- // `async` or `defer` attributes) can depend on the execution of other scripts.
72
- // Scripts found in the head are blocking and must be executed in order.
73
- const scripts = doc.querySelectorAll('script[type="module"][src]');
74
- scripts.forEach(script => {
75
- const src = script.getAttribute('src');
76
- if (!headElements.has(src)) {
77
- // add the <link> elements to prefetch the module scripts
78
- const link = doc.createElement('link');
79
- link.rel = 'modulepreload';
80
- link.href = src;
81
- document.head.append(link);
82
- headElements.set(src, {
83
- tag: script
84
- });
85
- }
86
- });
87
- const stylesheets = doc.querySelectorAll('link[rel=stylesheet]');
88
- await Promise.all(Array.from(stylesheets).map(async tag => {
89
- const href = tag.getAttribute('href');
90
- if (!href) {
91
- return;
92
- }
93
- if (!headElements.has(href)) {
94
- try {
95
- const response = await fetch(href);
96
- const text = await response.text();
97
- headElements.set(href, {
98
- tag,
99
- text
100
- });
101
- } catch (e) {
102
- // eslint-disable-next-line no-console
103
- console.error(e);
104
- }
105
- }
106
- const headElement = headElements.get(href);
107
- const styleElement = doc.createElement('style');
108
- styleElement.textContent = headElement.text;
109
- headTags.push(styleElement);
110
- }));
111
- return [doc.querySelector('title'), ...doc.querySelectorAll('style'), ...headTags];
112
- };
113
- exports.fetchHeadAssets = fetchHeadAssets;
114
- //# 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\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 @@
1
- /* wp:polyfill */
2
- /**
3
- * The cache of prefetched stylesheets and scripts.
4
- */
5
- export const headElements = new Map();
6
-
7
- /**
8
- * Helper to update only the necessary tags in the head.
9
- *
10
- * @async
11
- * @param newHead The head elements of the new page.
12
- */
13
- export const updateHead = async newHead => {
14
- // Helper to get the tag id store in the cache.
15
- const getTagId = tag => tag.id || tag.outerHTML;
16
-
17
- // Map incoming head tags by their content.
18
- const newHeadMap = new Map();
19
- for (const child of newHead) {
20
- newHeadMap.set(getTagId(child), child);
21
- }
22
- const toRemove = [];
23
-
24
- // Detect nodes that should be added or removed.
25
- for (const child of document.head.children) {
26
- const id = getTagId(child);
27
- // Always remove styles and links as they might change.
28
- if (child.nodeName === 'LINK' || child.nodeName === 'STYLE') {
29
- toRemove.push(child);
30
- } else if (newHeadMap.has(id)) {
31
- newHeadMap.delete(id);
32
- } else if (child.nodeName !== 'SCRIPT' && child.nodeName !== 'META') {
33
- toRemove.push(child);
34
- }
35
- }
36
- await Promise.all([...headElements.entries()].filter(([, {
37
- tag
38
- }]) => tag.nodeName === 'SCRIPT').map(async ([url]) => {
39
- await import(/* webpackIgnore: true */url);
40
- }));
41
-
42
- // Prepare new assets.
43
- const toAppend = [...newHeadMap.values()];
44
-
45
- // Apply the changes.
46
- toRemove.forEach(n => n.remove());
47
- document.head.append(...toAppend);
48
- };
49
-
50
- /**
51
- * Fetches and processes head assets (stylesheets and scripts) from a specified document.
52
- *
53
- * @async
54
- * @param doc The document from which to fetch head assets. It should support standard DOM querying methods.
55
- *
56
- * @return Returns an array of HTML elements representing the head assets.
57
- */
58
- export const fetchHeadAssets = async doc => {
59
- const headTags = [];
60
-
61
- // We only want to fetch module scripts because regular scripts (without
62
- // `async` or `defer` attributes) can depend on the execution of other scripts.
63
- // Scripts found in the head are blocking and must be executed in order.
64
- const scripts = doc.querySelectorAll('script[type="module"][src]');
65
- scripts.forEach(script => {
66
- const src = script.getAttribute('src');
67
- if (!headElements.has(src)) {
68
- // add the <link> elements to prefetch the module scripts
69
- const link = doc.createElement('link');
70
- link.rel = 'modulepreload';
71
- link.href = src;
72
- document.head.append(link);
73
- headElements.set(src, {
74
- tag: script
75
- });
76
- }
77
- });
78
- const stylesheets = doc.querySelectorAll('link[rel=stylesheet]');
79
- await Promise.all(Array.from(stylesheets).map(async tag => {
80
- const href = tag.getAttribute('href');
81
- if (!href) {
82
- return;
83
- }
84
- if (!headElements.has(href)) {
85
- try {
86
- const response = await fetch(href);
87
- const text = await response.text();
88
- headElements.set(href, {
89
- tag,
90
- text
91
- });
92
- } catch (e) {
93
- // eslint-disable-next-line no-console
94
- console.error(e);
95
- }
96
- }
97
- const headElement = headElements.get(href);
98
- const styleElement = doc.createElement('style');
99
- styleElement.textContent = headElement.text;
100
- headTags.push(styleElement);
101
- }));
102
- return [doc.querySelector('title'), ...doc.querySelectorAll('style'), ...headTags];
103
- };
104
- //# sourceMappingURL=head.js.map
@@ -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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G,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":[]}
@@ -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"}