@wordpress/interactivity-router 2.25.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 +17 -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 +140 -38
- 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 +142 -38
- 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 +165 -45
- 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/tsconfig.tsbuildinfo +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["store","privateApis","getConfig","directivePrefix","getRegionRootFragment","initialVdom","toVdom","render","parseServerData","populateServerData","batch","navigationMode","pages","Map","getPagePath","url","u","URL","window","location","href","pathname","search","fetchPage","html","res","fetch","status","text","dom","DOMParser","parseFromString","regionsToVdom","e","vdom","regions","body","undefined","attrName","querySelectorAll","forEach","region","id","getAttribute","has","get","title","querySelector","innerText","initialData","renderRegions","page","document","fragment","forcePageReload","assign","Promise","addEventListener","pagePath","state","reload","set","resolve","navigatingTo","hasLoadedNavigationTextsData","navigationTexts","loading","loaded","actions","navigation","hasStarted","hasFinished","navigate","options","clientNavigationDisabled","loadingAnimation","screenReaderAnnouncement","timeout","prefetch","timeoutPromise","setTimeout","loadingTimeout","a11ySpeak","race","clearTimeout","config","history","replace","hash","scrollIntoView","force","messageKey","content","getElementById","textContent","parsed","JSON","parse","i18n","texts","message","then","speak"],"sources":["@wordpress/interactivity-router/src/index.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store, privateApis, getConfig } from '@wordpress/interactivity';\n\nconst {\n\tdirectivePrefix,\n\tgetRegionRootFragment,\n\tinitialVdom,\n\ttoVdom,\n\trender,\n\tparseServerData,\n\tpopulateServerData,\n\tbatch,\n} = privateApis(\n\t'I acknowledge that using private APIs means my theme or plugin will inevitably break in the next version of WordPress.'\n);\n\ninterface NavigateOptions {\n\tforce?: boolean;\n\thtml?: string;\n\treplace?: boolean;\n\ttimeout?: number;\n\tloadingAnimation?: boolean;\n\tscreenReaderAnnouncement?: boolean;\n}\n\ninterface PrefetchOptions {\n\tforce?: boolean;\n\thtml?: string;\n}\n\ninterface VdomParams {\n\tvdom?: typeof initialVdom;\n}\n\ninterface Page {\n\tregions: Record< string, any >;\n\ttitle: string;\n\tinitialData: any;\n}\n\ntype RegionsToVdom = ( dom: Document, params?: VdomParams ) => Promise< Page >;\n\n// Check if the navigation mode is full page or region based. The only supported\n// mode for now is 'regionBased'.\nconst navigationMode: 'regionBased' = 'regionBased';\n\n// The cache of visited and prefetched pages, stylesheets and scripts.\nconst pages = new Map< string, Promise< Page | false > >();\n\n// Helper to remove domain and hash from the URL. We are only interesting in\n// caching the path and the query.\nconst getPagePath = ( url: string ) => {\n\tconst u = new URL( url, window.location.href );\n\treturn u.pathname + u.search;\n};\n\n// Fetch a new page and convert it to a static virtual DOM.\nconst fetchPage = async ( url: string, { html }: { html: string } ) => {\n\ttry {\n\t\tif ( ! html ) {\n\t\t\tconst res = await window.fetch( url );\n\t\t\tif ( res.status !== 200 ) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\thtml = await res.text();\n\t\t}\n\t\tconst dom = new window.DOMParser().parseFromString( html, 'text/html' );\n\t\treturn regionsToVdom( dom );\n\t} catch ( e ) {\n\t\treturn false;\n\t}\n};\n\n// Return an object with VDOM trees of those HTML regions marked with a\n// `router-region` directive.\nconst regionsToVdom: RegionsToVdom = async ( dom, { vdom } = {} ) => {\n\tconst regions = { body: undefined };\n\tif ( navigationMode === 'regionBased' ) {\n\t\tconst attrName = `data-${ directivePrefix }-router-region`;\n\t\tdom.querySelectorAll( `[${ attrName }]` ).forEach( ( region ) => {\n\t\t\tconst id = region.getAttribute( attrName );\n\t\t\tregions[ id ] = vdom?.has( region )\n\t\t\t\t? vdom.get( region )\n\t\t\t\t: toVdom( region );\n\t\t} );\n\t}\n\tconst title = dom.querySelector( 'title' )?.innerText;\n\tconst initialData = parseServerData( dom );\n\treturn { regions, title, initialData };\n};\n\n// Render all interactive regions contained in the given page.\nconst renderRegions = async ( page: Page ) => {\n\tif ( navigationMode === 'regionBased' ) {\n\t\tconst attrName = `data-${ directivePrefix }-router-region`;\n\t\tbatch( () => {\n\t\t\tpopulateServerData( page.initialData );\n\t\t\tdocument\n\t\t\t\t.querySelectorAll( `[${ attrName }]` )\n\t\t\t\t.forEach( ( region ) => {\n\t\t\t\t\tconst id = region.getAttribute( attrName );\n\t\t\t\t\tconst fragment = getRegionRootFragment( region );\n\t\t\t\t\trender( page.regions[ id ], fragment );\n\t\t\t\t} );\n\t\t} );\n\t}\n\tif ( page.title ) {\n\t\tdocument.title = page.title;\n\t}\n};\n\n/**\n * Load the given page forcing a full page reload.\n *\n * The function returns a promise that won't resolve, useful to prevent any\n * potential feedback indicating that the navigation has finished while the new\n * page is being loaded.\n *\n * @param href The page href.\n * @return Promise that never resolves.\n */\nconst forcePageReload = ( href: string ) => {\n\twindow.location.assign( href );\n\treturn new Promise( () => {} );\n};\n\n// Listen to the back and forward buttons and restore the page if it's in the\n// cache.\nwindow.addEventListener( 'popstate', async () => {\n\tconst pagePath = getPagePath( window.location.href ); // Remove hash.\n\tconst page = pages.has( pagePath ) && ( await pages.get( pagePath ) );\n\tif ( page ) {\n\t\tawait renderRegions( page );\n\t\t// Update the URL in the state.\n\t\tstate.url = window.location.href;\n\t} else {\n\t\twindow.location.reload();\n\t}\n} );\n\n// Initialize the router and cache the initial page using the initial vDOM.\npages.set(\n\tgetPagePath( window.location.href ),\n\tPromise.resolve( regionsToVdom( document, { vdom: initialVdom } ) )\n);\n\n// Variable to store the current navigation.\nlet navigatingTo = '';\n\nlet hasLoadedNavigationTextsData = false;\nconst navigationTexts = {\n\tloading: 'Loading page, please wait.',\n\tloaded: 'Page Loaded.',\n};\n\ninterface Store {\n\tstate: {\n\t\turl: string;\n\t\tnavigation: {\n\t\t\thasStarted: boolean;\n\t\t\thasFinished: boolean;\n\t\t};\n\t};\n\tactions: {\n\t\tnavigate: ( href: string, options?: NavigateOptions ) => void;\n\t\tprefetch: ( url: string, options?: PrefetchOptions ) => void;\n\t};\n}\n\nexport const { state, actions } = store< Store >( 'core/router', {\n\tstate: {\n\t\turl: window.location.href,\n\t\tnavigation: {\n\t\t\thasStarted: false,\n\t\t\thasFinished: false,\n\t\t},\n\t},\n\tactions: {\n\t\t/**\n\t\t * Navigates to the specified page.\n\t\t *\n\t\t * This function normalizes the passed href, fetches the page HTML if\n\t\t * needed, and updates any interactive regions whose contents have\n\t\t * changed. It also creates a new entry in the browser session history.\n\t\t *\n\t\t * @param href The page href.\n\t\t * @param [options] Options object.\n\t\t * @param [options.force] If true, it forces re-fetching the URL.\n\t\t * @param [options.html] HTML string to be used instead of fetching the requested URL.\n\t\t * @param [options.replace] If true, it replaces the current entry in the browser session history.\n\t\t * @param [options.timeout] Time until the navigation is aborted, in milliseconds. Default is 10000.\n\t\t * @param [options.loadingAnimation] Whether an animation should be shown while navigating. Default to `true`.\n\t\t * @param [options.screenReaderAnnouncement] Whether a message for screen readers should be announced while navigating. Default to `true`.\n\t\t *\n\t\t * @return Promise that resolves once the navigation is completed or aborted.\n\t\t */\n\t\t*navigate( href: string, options: NavigateOptions = {} ) {\n\t\t\tconst { clientNavigationDisabled } = getConfig();\n\t\t\tif ( clientNavigationDisabled ) {\n\t\t\t\tyield forcePageReload( href );\n\t\t\t}\n\n\t\t\tconst pagePath = getPagePath( href );\n\t\t\tconst { navigation } = state;\n\t\t\tconst {\n\t\t\t\tloadingAnimation = true,\n\t\t\t\tscreenReaderAnnouncement = true,\n\t\t\t\ttimeout = 10000,\n\t\t\t} = options;\n\n\t\t\tnavigatingTo = href;\n\t\t\tactions.prefetch( pagePath, options );\n\n\t\t\t// Create a promise that resolves when the specified timeout ends.\n\t\t\t// The timeout value is 10 seconds by default.\n\t\t\tconst timeoutPromise = new Promise< void >( ( resolve ) =>\n\t\t\t\tsetTimeout( resolve, timeout )\n\t\t\t);\n\n\t\t\t// Don't update the navigation status immediately, wait 400 ms.\n\t\t\tconst loadingTimeout = setTimeout( () => {\n\t\t\t\tif ( navigatingTo !== href ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ( loadingAnimation ) {\n\t\t\t\t\tnavigation.hasStarted = true;\n\t\t\t\t\tnavigation.hasFinished = false;\n\t\t\t\t}\n\t\t\t\tif ( screenReaderAnnouncement ) {\n\t\t\t\t\ta11ySpeak( 'loading' );\n\t\t\t\t}\n\t\t\t}, 400 );\n\n\t\t\tconst page = yield Promise.race( [\n\t\t\t\tpages.get( pagePath ),\n\t\t\t\ttimeoutPromise,\n\t\t\t] );\n\n\t\t\t// Dismiss loading message if it hasn't been added yet.\n\t\t\tclearTimeout( loadingTimeout );\n\n\t\t\t// Once the page is fetched, the destination URL could have changed\n\t\t\t// (e.g., by clicking another link in the meantime). If so, bail\n\t\t\t// out, and let the newer execution to update the HTML.\n\t\t\tif ( navigatingTo !== href ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\tpage &&\n\t\t\t\t! page.initialData?.config?.[ 'core/router' ]\n\t\t\t\t\t?.clientNavigationDisabled\n\t\t\t) {\n\t\t\t\tyield renderRegions( page );\n\t\t\t\twindow.history[\n\t\t\t\t\toptions.replace ? 'replaceState' : 'pushState'\n\t\t\t\t]( {}, '', href );\n\n\t\t\t\t// Update the URL in the state.\n\t\t\t\tstate.url = href;\n\n\t\t\t\t// Update the navigation status once the the new page rendering\n\t\t\t\t// has been completed.\n\t\t\t\tif ( loadingAnimation ) {\n\t\t\t\t\tnavigation.hasStarted = false;\n\t\t\t\t\tnavigation.hasFinished = true;\n\t\t\t\t}\n\n\t\t\t\tif ( screenReaderAnnouncement ) {\n\t\t\t\t\ta11ySpeak( 'loaded' );\n\t\t\t\t}\n\n\t\t\t\t// Scroll to the anchor if exits in the link.\n\t\t\t\tconst { hash } = new URL( href, window.location.href );\n\t\t\t\tif ( hash ) {\n\t\t\t\t\tdocument.querySelector( hash )?.scrollIntoView();\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tyield forcePageReload( href );\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Prefetches the page with the passed URL.\n\t\t *\n\t\t * The function normalizes the URL and stores internally the fetch\n\t\t * promise, to avoid triggering a second fetch for an ongoing request.\n\t\t *\n\t\t * @param url The page URL.\n\t\t * @param [options] Options object.\n\t\t * @param [options.force] Force fetching the URL again.\n\t\t * @param [options.html] HTML string to be used instead of fetching the requested URL.\n\t\t */\n\t\tprefetch( url: string, options: PrefetchOptions = {} ) {\n\t\t\tconst { clientNavigationDisabled } = getConfig();\n\t\t\tif ( clientNavigationDisabled ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst pagePath = getPagePath( url );\n\t\t\tif ( options.force || ! pages.has( pagePath ) ) {\n\t\t\t\tpages.set(\n\t\t\t\t\tpagePath,\n\t\t\t\t\tfetchPage( pagePath, { html: options.html } )\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t},\n} );\n\n/**\n * Announces a message to screen readers.\n *\n * This is a wrapper around the `@wordpress/a11y` package's `speak` function. It handles importing\n * the package on demand and should be used instead of calling `ally.speak` direacly.\n *\n * @param messageKey The message to be announced by assistive technologies.\n */\nfunction a11ySpeak( messageKey: keyof typeof navigationTexts ) {\n\tif ( ! hasLoadedNavigationTextsData ) {\n\t\thasLoadedNavigationTextsData = true;\n\t\tconst content = document.getElementById(\n\t\t\t'wp-script-module-data-@wordpress/interactivity-router'\n\t\t)?.textContent;\n\t\tif ( content ) {\n\t\t\ttry {\n\t\t\t\tconst parsed = JSON.parse( content );\n\t\t\t\tif ( typeof parsed?.i18n?.loading === 'string' ) {\n\t\t\t\t\tnavigationTexts.loading = parsed.i18n.loading;\n\t\t\t\t}\n\t\t\t\tif ( typeof parsed?.i18n?.loaded === 'string' ) {\n\t\t\t\t\tnavigationTexts.loaded = parsed.i18n.loaded;\n\t\t\t\t}\n\t\t\t} catch {}\n\t\t} else {\n\t\t\t// Fallback to localized strings from Interactivity API state.\n\t\t\t// @todo This block is for Core < 6.7.0. Remove when support is dropped.\n\n\t\t\t// @ts-expect-error\n\t\t\tif ( state.navigation.texts?.loading ) {\n\t\t\t\t// @ts-expect-error\n\t\t\t\tnavigationTexts.loading = state.navigation.texts.loading;\n\t\t\t}\n\t\t\t// @ts-expect-error\n\t\t\tif ( state.navigation.texts?.loaded ) {\n\t\t\t\t// @ts-expect-error\n\t\t\t\tnavigationTexts.loaded = state.navigation.texts.loaded;\n\t\t\t}\n\t\t}\n\t}\n\n\tconst message = navigationTexts[ messageKey ];\n\n\timport( '@wordpress/a11y' ).then(\n\t\t( { speak } ) => speak( message ),\n\t\t// Ignore failures to load the a11y module.\n\t\t() => {}\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,KAAK,EAAEC,WAAW,EAAEC,SAAS,QAA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AAU,CAAC8B,KAAK,CAAChC,MAAM;MACvD;IACD;EACD;EAEA,MAAMiC,OAAO,GAAGnC,eAAe,CAAE0B,UAAU,CAAE;EAE7C,MAAM,CAAE,iBAAkB,CAAC,CAACU,IAAI,CAC/B,CAAE;IAAEC;EAAM,CAAC,KAAMA,KAAK,CAAEF,OAAQ,CAAC;EACjC;EACA,MAAM,CAAC,CACR,CAAC;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["store","privateApis","getConfig","preloadStyles","applyStyles","preloadScriptModules","importScriptModules","markScriptModuleAsResolved","directivePrefix","getRegionRootFragment","initialVdom","toVdom","render","parseServerData","populateServerData","batch","regionAttr","interactiveAttr","regionsSelector","pages","Map","getPagePath","url","u","URL","window","location","href","pathname","search","parseRegionAttribute","region","value","getAttribute","id","attachTo","JSON","parse","e","fetchPage","html","res","fetch","status","text","dom","DOMParser","parseFromString","preparePage","vdom","regions","regionsToAttach","querySelectorAll","forEach","has","get","title","querySelector","innerText","initialData","styles","scriptModules","Promise","all","renderPage","page","document","fragment","parent","props","type","elementType","createElement","appendChild","forcePageReload","assign","addEventListener","pagePath","state","reload","src","set","resolve","navigatingTo","hasLoadedNavigationTextsData","navigationTexts","loading","loaded","actions","navigation","hasStarted","hasFinished","navigate","options","clientNavigationDisabled","loadingAnimation","screenReaderAnnouncement","timeout","prefetch","timeoutPromise","setTimeout","loadingTimeout","a11ySpeak","race","clearTimeout","config","history","replace","hash","scrollIntoView","force","messageKey","content","getElementById","textContent","parsed","i18n","texts","message","then","speak"],"sources":["@wordpress/interactivity-router/src/index.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store, privateApis, getConfig } from '@wordpress/interactivity';\n\n/**\n * Internal dependencies\n */\nimport { preloadStyles, applyStyles, type StyleElement } from './assets/styles';\nimport {\n\tpreloadScriptModules,\n\timportScriptModules,\n\tmarkScriptModuleAsResolved,\n\ttype ScriptModuleLoad,\n} from './assets/script-modules';\n\nconst {\n\tdirectivePrefix,\n\tgetRegionRootFragment,\n\tinitialVdom,\n\ttoVdom,\n\trender,\n\tparseServerData,\n\tpopulateServerData,\n\tbatch,\n} = privateApis(\n\t'I acknowledge that using private APIs means my theme or plugin will inevitably break in the next version of WordPress.'\n);\n\nconst regionAttr = `data-${ directivePrefix }-router-region`;\nconst interactiveAttr = `data-${ directivePrefix }-interactive`;\nconst regionsSelector = `[${ interactiveAttr }][${ regionAttr }]:not([${ interactiveAttr }] [${ interactiveAttr }])`;\n\nexport interface NavigateOptions {\n\tforce?: boolean;\n\thtml?: string;\n\treplace?: boolean;\n\ttimeout?: number;\n\tloadingAnimation?: boolean;\n\tscreenReaderAnnouncement?: boolean;\n}\n\nexport interface PrefetchOptions {\n\tforce?: boolean;\n\thtml?: string;\n}\n\ninterface VdomParams {\n\tvdom?: typeof initialVdom;\n}\n\ninterface Page {\n\turl: string;\n\tregions: Record< string, any >;\n\tregionsToAttach: Record< string, string >;\n\tstyles: StyleElement[];\n\tscriptModules: ScriptModuleLoad[];\n\ttitle: string;\n\tinitialData: any;\n}\n\ntype PreparePage = (\n\turl: string,\n\tdom: Document,\n\tparams?: VdomParams\n) => Promise< Page >;\n\n// The cache of visited and prefetched pages, stylesheets and scripts.\nconst pages = new Map< string, Promise< Page | false > >();\n\n// Helper to remove domain and hash from the URL. We are only interesting in\n// caching the path and the query.\nconst getPagePath = ( url: string ) => {\n\tconst u = new URL( url, window.location.href );\n\treturn u.pathname + u.search;\n};\n\n/**\n * Parses the given region's directive.\n *\n * @param region Region element.\n * @return Data contained in the region directive value.\n */\nconst parseRegionAttribute = ( region: Element ) => {\n\tconst value = region.getAttribute( regionAttr );\n\ttry {\n\t\tconst { id, attachTo } = JSON.parse( value );\n\t\treturn { id, attachTo };\n\t} catch ( e ) {\n\t\treturn { id: value };\n\t}\n};\n\n/**\n * Fetches and prepares a page from a given URL.\n *\n * @param url The URL of the page to fetch.\n * @param options Options for the fetch operation.\n * @param options.html Optional HTML content. If provided, the function will use\n * this instead of fetching from the URL.\n * @return A Promise that resolves to the prepared page, or false if\n * there was an error during fetching or preparation.\n */\nconst fetchPage = async ( url: string, { html }: { html: string } ) => {\n\ttry {\n\t\tif ( ! html ) {\n\t\t\tconst res = await window.fetch( url );\n\t\t\tif ( res.status !== 200 ) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\thtml = await res.text();\n\t\t}\n\t\tconst dom = new window.DOMParser().parseFromString( html, 'text/html' );\n\t\treturn await preparePage( url, dom );\n\t} catch ( e ) {\n\t\treturn false;\n\t}\n};\n\n/**\n * Processes a DOM document to extract router regions and related resources.\n *\n * This function analyzes the provided DOM document and creates a virtual DOM\n * representation of all HTML regions marked with a `router-region` directive.\n * It also extracts and preloads associated styles and scripts to prepare for\n * rendering the page.\n *\n * @param url The URL associated with the page, used for asset\n * loading and caching.\n * @param dom The DOM document to process.\n * @param vdomParams Optional parameters for virtual DOM processing.\n * @param vdomParams.vdom An optional existing virtual DOM cache to check for\n * regions. If a region exists in this cache, it will be\n * reused instead of creating a new vDOM representation.\n * @return A Promise that resolves to a {@link Page} object\n * containing the virtual DOM for all router regions,\n * preloaded styles and scripts, page title, and initial\n * server-rendered data.\n */\nconst preparePage: PreparePage = async ( url, dom, { vdom } = {} ) => {\n\tconst regions = {};\n\tconst regionsToAttach = {};\n\tdom.querySelectorAll( regionsSelector ).forEach( ( region ) => {\n\t\tconst { id, attachTo } = parseRegionAttribute( region );\n\t\tregions[ id ] = vdom?.has( region )\n\t\t\t? vdom.get( region )\n\t\t\t: toVdom( region );\n\t\tif ( attachTo ) {\n\t\t\tregionsToAttach[ id ] = attachTo;\n\t\t}\n\t} );\n\n\tconst title = dom.querySelector( 'title' )?.innerText;\n\tconst initialData = parseServerData( dom );\n\n\t// Wait for styles and modules to be ready.\n\tconst [ styles, scriptModules ] = await Promise.all( [\n\t\tPromise.all( preloadStyles( dom, url ) ),\n\t\tPromise.all( preloadScriptModules( dom ) ),\n\t] );\n\n\treturn {\n\t\tregions,\n\t\tregionsToAttach,\n\t\tstyles,\n\t\tscriptModules,\n\t\ttitle,\n\t\tinitialData,\n\t\turl,\n\t};\n};\n\n/**\n * Renders a page by applying styles, populating server data, rendering regions,\n * and updating the document title.\n *\n * @param page The {@link Page} object to render.\n */\nconst renderPage = ( page: Page ) => {\n\tapplyStyles( page.styles );\n\n\t// Clone regionsToAttach.\n\tconst regionsToAttach = { ...page.regionsToAttach };\n\n\tbatch( () => {\n\t\tpopulateServerData( page.initialData );\n\t\tdocument.querySelectorAll( regionsSelector ).forEach( ( region ) => {\n\t\t\tconst { id } = parseRegionAttribute( region );\n\t\t\tconst fragment = getRegionRootFragment( region );\n\t\t\trender( page.regions[ id ], fragment );\n\t\t\t// If this is an attached region, remove it from the list.\n\t\t\tdelete regionsToAttach[ id ];\n\t\t} );\n\n\t\t// Render unattached regions.\n\t\tfor ( const id in regionsToAttach ) {\n\t\t\tconst parent = document.querySelector( regionsToAttach[ id ] );\n\n\t\t\t// Get the type from the vnode. If wrapped with Directives, get the\n\t\t\t// original type from `props.type`.\n\t\t\tconst { props, type } = page.regions[ id ];\n\t\t\tconst elementType = typeof type === 'function' ? props.type : type;\n\n\t\t\t// Create an element with the obtained type where the region will be\n\t\t\t// rendered. The type should match the one of the root vnode.\n\t\t\tconst region = document.createElement( elementType );\n\t\t\tparent.appendChild( region );\n\n\t\t\tconst fragment = getRegionRootFragment( region );\n\t\t\trender( page.regions[ id ], fragment );\n\t\t}\n\t} );\n\n\tif ( page.title ) {\n\t\tdocument.title = page.title;\n\t}\n};\n\n/**\n * Loads the given page forcing a full page reload.\n *\n * The function returns a promise that won't resolve, useful to prevent any\n * potential feedback indicating that the navigation has finished while the new\n * page is being loaded.\n *\n * @param href The page href.\n * @return Promise that never resolves.\n */\nconst forcePageReload = ( href: string ) => {\n\twindow.location.assign( href );\n\treturn new Promise( () => {} );\n};\n\n// Listen to the back and forward buttons and restore the page if it's in the\n// cache.\nwindow.addEventListener( 'popstate', async () => {\n\tconst pagePath = getPagePath( window.location.href ); // Remove hash.\n\tconst page = pages.has( pagePath ) && ( await pages.get( pagePath ) );\n\tif ( page ) {\n\t\trenderPage( page );\n\t\t// Update the URL in the state.\n\t\tstate.url = window.location.href;\n\t} else {\n\t\twindow.location.reload();\n\t}\n} );\n\n// Initialize the router and cache the initial page using the initial vDOM.\nwindow.document\n\t.querySelectorAll< HTMLScriptElement >( 'script[type=module][src]' )\n\t.forEach( ( { src } ) => markScriptModuleAsResolved( src ) );\npages.set(\n\tgetPagePath( window.location.href ),\n\tPromise.resolve(\n\t\tpreparePage( getPagePath( window.location.href ), document, {\n\t\t\tvdom: initialVdom,\n\t\t} )\n\t)\n);\n\n// Variable to store the current navigation.\nlet navigatingTo = '';\n\nlet hasLoadedNavigationTextsData = false;\nconst navigationTexts = {\n\tloading: 'Loading page, please wait.',\n\tloaded: 'Page Loaded.',\n};\n\ninterface Store {\n\tstate: {\n\t\turl: string;\n\t\tnavigation: {\n\t\t\thasStarted: boolean;\n\t\t\thasFinished: boolean;\n\t\t};\n\t};\n\tactions: {\n\t\tnavigate: (\n\t\t\thref: string,\n\t\t\toptions?: NavigateOptions\n\t\t) => Promise< void >;\n\t\tprefetch: ( url: string, options?: PrefetchOptions ) => Promise< void >;\n\t};\n}\n\nexport const { state, actions } = store< Store >( 'core/router', {\n\tstate: {\n\t\turl: window.location.href,\n\t\tnavigation: {\n\t\t\thasStarted: false,\n\t\t\thasFinished: false,\n\t\t},\n\t},\n\tactions: {\n\t\t/**\n\t\t * Navigates to the specified page.\n\t\t *\n\t\t * This function normalizes the passed href, fetches the page HTML if\n\t\t * needed, and updates any interactive regions whose contents have\n\t\t * changed. It also creates a new entry in the browser session history.\n\t\t *\n\t\t * @param href The page href.\n\t\t * @param [options] Options object.\n\t\t * @param [options.force] If true, it forces re-fetching the URL.\n\t\t * @param [options.html] HTML string to be used instead of fetching the requested URL.\n\t\t * @param [options.replace] If true, it replaces the current entry in the browser session history.\n\t\t * @param [options.timeout] Time until the navigation is aborted, in milliseconds. Default is 10000.\n\t\t * @param [options.loadingAnimation] Whether an animation should be shown while navigating. Default to `true`.\n\t\t * @param [options.screenReaderAnnouncement] Whether a message for screen readers should be announced while navigating. Default to `true`.\n\t\t *\n\t\t * @return Promise that resolves once the navigation is completed or aborted.\n\t\t */\n\t\t*navigate( href: string, options: NavigateOptions = {} ) {\n\t\t\tconst { clientNavigationDisabled } = getConfig();\n\t\t\tif ( clientNavigationDisabled ) {\n\t\t\t\tyield forcePageReload( href );\n\t\t\t}\n\n\t\t\tconst pagePath = getPagePath( href );\n\t\t\tconst { navigation } = state;\n\t\t\tconst {\n\t\t\t\tloadingAnimation = true,\n\t\t\t\tscreenReaderAnnouncement = true,\n\t\t\t\ttimeout = 10000,\n\t\t\t} = options;\n\n\t\t\tnavigatingTo = href;\n\t\t\tactions.prefetch( pagePath, options );\n\n\t\t\t// Create a promise that resolves when the specified timeout ends.\n\t\t\t// The timeout value is 10 seconds by default.\n\t\t\tconst timeoutPromise = new Promise< void >( ( resolve ) =>\n\t\t\t\tsetTimeout( resolve, timeout )\n\t\t\t);\n\n\t\t\t// Don't update the navigation status immediately, wait 400 ms.\n\t\t\tconst loadingTimeout = setTimeout( () => {\n\t\t\t\tif ( navigatingTo !== href ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ( loadingAnimation ) {\n\t\t\t\t\tnavigation.hasStarted = true;\n\t\t\t\t\tnavigation.hasFinished = false;\n\t\t\t\t}\n\t\t\t\tif ( screenReaderAnnouncement ) {\n\t\t\t\t\ta11ySpeak( 'loading' );\n\t\t\t\t}\n\t\t\t}, 400 );\n\n\t\t\tconst page = yield Promise.race( [\n\t\t\t\tpages.get( pagePath ),\n\t\t\t\ttimeoutPromise,\n\t\t\t] );\n\n\t\t\t// Dismiss loading message if it hasn't been added yet.\n\t\t\tclearTimeout( loadingTimeout );\n\n\t\t\t// Once the page is fetched, the destination URL could have changed\n\t\t\t// (e.g., by clicking another link in the meantime). If so, bail\n\t\t\t// out, and let the newer execution to update the HTML.\n\t\t\tif ( navigatingTo !== href ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\tpage &&\n\t\t\t\t! page.initialData?.config?.[ 'core/router' ]\n\t\t\t\t\t?.clientNavigationDisabled\n\t\t\t) {\n\t\t\t\tyield importScriptModules( page.scriptModules );\n\t\t\t\trenderPage( page );\n\t\t\t\twindow.history[\n\t\t\t\t\toptions.replace ? 'replaceState' : 'pushState'\n\t\t\t\t]( {}, '', href );\n\n\t\t\t\t// Update the URL in the state.\n\t\t\t\tstate.url = href;\n\n\t\t\t\t// Update the navigation status once the the new page rendering\n\t\t\t\t// has been completed.\n\t\t\t\tif ( loadingAnimation ) {\n\t\t\t\t\tnavigation.hasStarted = false;\n\t\t\t\t\tnavigation.hasFinished = true;\n\t\t\t\t}\n\n\t\t\t\tif ( screenReaderAnnouncement ) {\n\t\t\t\t\ta11ySpeak( 'loaded' );\n\t\t\t\t}\n\n\t\t\t\t// Scroll to the anchor if exits in the link.\n\t\t\t\tconst { hash } = new URL( href, window.location.href );\n\t\t\t\tif ( hash ) {\n\t\t\t\t\tdocument.querySelector( hash )?.scrollIntoView();\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tyield forcePageReload( href );\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Prefetches the page with the passed URL.\n\t\t *\n\t\t * The function normalizes the URL and stores internally the fetch\n\t\t * promise, to avoid triggering a second fetch for an ongoing request.\n\t\t *\n\t\t * @param url The page URL.\n\t\t * @param [options] Options object.\n\t\t * @param [options.force] Force fetching the URL again.\n\t\t * @param [options.html] HTML string to be used instead of fetching the requested URL.\n\t\t *\n\t\t * @return Promise that resolves once the page has been fetched.\n\t\t */\n\t\t*prefetch( url: string, options: PrefetchOptions = {} ) {\n\t\t\tconst { clientNavigationDisabled } = getConfig();\n\t\t\tif ( clientNavigationDisabled ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst pagePath = getPagePath( url );\n\t\t\tif ( options.force || ! pages.has( pagePath ) ) {\n\t\t\t\tpages.set(\n\t\t\t\t\tpagePath,\n\t\t\t\t\tfetchPage( pagePath, { html: options.html } )\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tyield pages.get( pagePath );\n\t\t},\n\t},\n} );\n\n/**\n * Announces a message to screen readers.\n *\n * This is a wrapper around the `@wordpress/a11y` package's `speak` function. It handles importing\n * the package on demand and should be used instead of calling `a11y.speak` directly.\n *\n * @param messageKey The message to be announced by assistive technologies.\n */\nfunction a11ySpeak( messageKey: keyof typeof navigationTexts ) {\n\tif ( ! hasLoadedNavigationTextsData ) {\n\t\thasLoadedNavigationTextsData = true;\n\t\tconst content = document.getElementById(\n\t\t\t'wp-script-module-data-@wordpress/interactivity-router'\n\t\t)?.textContent;\n\t\tif ( content ) {\n\t\t\ttry {\n\t\t\t\tconst parsed = JSON.parse( content );\n\t\t\t\tif ( typeof parsed?.i18n?.loading === 'string' ) {\n\t\t\t\t\tnavigationTexts.loading = parsed.i18n.loading;\n\t\t\t\t}\n\t\t\t\tif ( typeof parsed?.i18n?.loaded === 'string' ) {\n\t\t\t\t\tnavigationTexts.loaded = parsed.i18n.loaded;\n\t\t\t\t}\n\t\t\t} catch {}\n\t\t} else {\n\t\t\t// Fallback to localized strings from Interactivity API state.\n\t\t\t// @todo This block is for Core < 6.7.0. Remove when support is dropped.\n\n\t\t\t// @ts-expect-error\n\t\t\tif ( state.navigation.texts?.loading ) {\n\t\t\t\t// @ts-expect-error\n\t\t\t\tnavigationTexts.loading = state.navigation.texts.loading;\n\t\t\t}\n\t\t\t// @ts-expect-error\n\t\t\tif ( state.navigation.texts?.loaded ) {\n\t\t\t\t// @ts-expect-error\n\t\t\t\tnavigationTexts.loaded = state.navigation.texts.loaded;\n\t\t\t}\n\t\t}\n\t}\n\n\tconst message = navigationTexts[ messageKey ];\n\n\timport( '@wordpress/a11y' ).then(\n\t\t( { speak } ) => speak( message ),\n\t\t// Ignore failures to load the a11y module.\n\t\t() => {}\n\t);\n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AC,CACR,CAAC;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code is derived from the following projects:
|
|
3
|
+
*
|
|
4
|
+
* 1. dynamic-importmap (https://github.com/keller-mark/dynamic-importmap)
|
|
5
|
+
* 2. es-module-shims (https://github.com/guybedford/es-module-shims)
|
|
6
|
+
*
|
|
7
|
+
* The original implementation was created by Guy Bedford in es-module-shims,
|
|
8
|
+
* then adapted by Mark Keller in dynamic-importmap, and further modified
|
|
9
|
+
* for use in this project.
|
|
10
|
+
*
|
|
11
|
+
* Both projects are licensed under the MIT license.
|
|
12
|
+
*
|
|
13
|
+
* MIT License: https://opensource.org/licenses/MIT
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Internal dependencies
|
|
17
|
+
*/
|
|
18
|
+
import { type ModuleLoad } from './loader';
|
|
19
|
+
/**
|
|
20
|
+
* Fetches the passed module URL and return the corresponding `ModuleLoad`
|
|
21
|
+
* instance. If the passed URL does not point to a JS file, the function
|
|
22
|
+
* throws and error.
|
|
23
|
+
*
|
|
24
|
+
* @param url Module URL.
|
|
25
|
+
* @param fetchOpts Fetch init options.
|
|
26
|
+
* @param parent Parent module URL referencing this URL (if any).
|
|
27
|
+
* @return Promise with a `ModuleLoad` instance.
|
|
28
|
+
*/
|
|
29
|
+
export declare function fetchModule(url: string, fetchOpts: RequestInit, parent: string): Promise<ModuleLoad>;
|
|
30
|
+
//# sourceMappingURL=fetch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../../src/assets/dynamic-importmap/fetch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH;;GAEG;AACH,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AAQ3C;;;;;;;;;GASG;AACH,wBAAsB,WAAW,CAChC,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,WAAW,EACtB,MAAM,EAAE,MAAM,GACZ,OAAO,CAAE,UAAU,CAAE,CAiBvB"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code is derived from the following projects:
|
|
3
|
+
*
|
|
4
|
+
* 1. dynamic-importmap (https://github.com/keller-mark/dynamic-importmap)
|
|
5
|
+
* 2. es-module-shims (https://github.com/guybedford/es-module-shims)
|
|
6
|
+
*
|
|
7
|
+
* The original implementation was created by Guy Bedford in es-module-shims,
|
|
8
|
+
* then adapted by Mark Keller in dynamic-importmap, and further modified
|
|
9
|
+
* for use in this project.
|
|
10
|
+
*
|
|
11
|
+
* Both projects are licensed under the MIT license.
|
|
12
|
+
*
|
|
13
|
+
* MIT License: https://opensource.org/licenses/MIT
|
|
14
|
+
*/
|
|
15
|
+
type ImportMap = {
|
|
16
|
+
imports?: Record<string, string>;
|
|
17
|
+
scopes?: Record<string, Record<string, string>>;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Imports the module with the passed ID.
|
|
21
|
+
*
|
|
22
|
+
* The module is resolved against the internal dynamic import map,
|
|
23
|
+
* extended with the passed import map.
|
|
24
|
+
*
|
|
25
|
+
* @param id Module ID.
|
|
26
|
+
* @param importMapIn Import map.
|
|
27
|
+
* @return Resolved module.
|
|
28
|
+
*/
|
|
29
|
+
export declare function importWithMap<Module = unknown>(id: string, importMapIn: ImportMap): Promise<Module>;
|
|
30
|
+
/**
|
|
31
|
+
* Preloads the module with the passed ID along with its dependencies.
|
|
32
|
+
*
|
|
33
|
+
* The module is resolved against the internal dynamic import map,
|
|
34
|
+
* extended with the passed import map.
|
|
35
|
+
*
|
|
36
|
+
* @param id Module ID.
|
|
37
|
+
* @param importMapIn Import map.
|
|
38
|
+
* @return Resolved `ModuleLoad` instance.
|
|
39
|
+
*/
|
|
40
|
+
export declare function preloadWithMap(id: string, importMapIn: ImportMap): Promise<import("./loader").ModuleLoad>;
|
|
41
|
+
export { initialImportMap, importPreloadedModule, type ModuleLoad, } from './loader';
|
|
42
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/assets/dynamic-importmap/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAQH,KAAK,SAAS,GAAG;IAChB,OAAO,CAAC,EAAE,MAAM,CAAE,MAAM,EAAE,MAAM,CAAE,CAAC;IACnC,MAAM,CAAC,EAAE,MAAM,CAAE,MAAM,EAAE,MAAM,CAAE,MAAM,EAAE,MAAM,CAAE,CAAE,CAAC;CACpD,CAAC;AAsBF;;;;;;;;;GASG;AACH,wBAAsB,aAAa,CAAE,MAAM,GAAG,OAAO,EACpD,EAAE,EAAE,MAAM,EACV,WAAW,EAAE,SAAS,mBAItB;AAED;;;;;;;;;GASG;AACH,wBAAsB,cAAc,CAAE,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE,SAAS,0CAMvE;AAED,OAAO,EACN,gBAAgB,EAChB,qBAAqB,EACrB,KAAK,UAAU,GACf,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code is derived from the following projects:
|
|
3
|
+
*
|
|
4
|
+
* 1. dynamic-importmap (https://github.com/keller-mark/dynamic-importmap)
|
|
5
|
+
* 2. es-module-shims (https://github.com/guybedford/es-module-shims)
|
|
6
|
+
*
|
|
7
|
+
* The original implementation was created by Guy Bedford in es-module-shims,
|
|
8
|
+
* then adapted by Mark Keller in dynamic-importmap, and further modified
|
|
9
|
+
* for use in this project.
|
|
10
|
+
*
|
|
11
|
+
* Both projects are licensed under the MIT license.
|
|
12
|
+
*
|
|
13
|
+
* MIT License: https://opensource.org/licenses/MIT
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* External dependencies
|
|
17
|
+
*/
|
|
18
|
+
import * as lexer from 'es-module-lexer';
|
|
19
|
+
export interface ModuleLoad {
|
|
20
|
+
url?: string;
|
|
21
|
+
responseUrl?: string;
|
|
22
|
+
fetchPromise?: Promise<ModuleLoad>;
|
|
23
|
+
source?: string;
|
|
24
|
+
linkPromise?: Promise<void>;
|
|
25
|
+
analysis?: ReturnType<typeof lexer.parse>;
|
|
26
|
+
deps?: ModuleLoad[];
|
|
27
|
+
blobUrl?: string;
|
|
28
|
+
shellUrl?: string;
|
|
29
|
+
}
|
|
30
|
+
export declare const initPromise: Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* Data from the initial page's import map.
|
|
33
|
+
*
|
|
34
|
+
* Pages containing any of the imports present on the original page
|
|
35
|
+
* in their import maps should ignore them, as those imports would
|
|
36
|
+
* be handled natively.
|
|
37
|
+
*/
|
|
38
|
+
export declare const initialImportMap: any;
|
|
39
|
+
export declare const registry: {};
|
|
40
|
+
/**
|
|
41
|
+
* Resolves the passed module URL and fetches the corresponding module
|
|
42
|
+
* and their dependencies, returning a `ModuleLoad` object once all
|
|
43
|
+
* of them have been fetched.
|
|
44
|
+
*
|
|
45
|
+
* @param url Module URL.
|
|
46
|
+
* @param fetchOpts Fetch options.
|
|
47
|
+
* @return A promise with a `ModuleLoad` instance.
|
|
48
|
+
*/
|
|
49
|
+
export declare function preloadModule(url: string, fetchOpts?: RequestInit): Promise<ModuleLoad>;
|
|
50
|
+
/**
|
|
51
|
+
* Imports the module represented by the passed `ModuleLoad` instance.
|
|
52
|
+
*
|
|
53
|
+
* @param load The `ModuleLoad` instance representing the module.
|
|
54
|
+
* @return A promise with the imported module.
|
|
55
|
+
*/
|
|
56
|
+
export declare function importPreloadedModule<Module = unknown>(load: ModuleLoad): Promise<Module>;
|
|
57
|
+
/**
|
|
58
|
+
* Imports the module represented by the passed module URL.
|
|
59
|
+
*
|
|
60
|
+
* The module URL and all its dependencies are resolved using the
|
|
61
|
+
* current status of the internal dynamic import map.
|
|
62
|
+
*
|
|
63
|
+
* @param url Module URL.
|
|
64
|
+
* @param fetchOpts Fetch options.
|
|
65
|
+
* @return A promise with the imported module.
|
|
66
|
+
*/
|
|
67
|
+
export declare function topLevelLoad<Module = unknown>(url: string, fetchOpts?: RequestInit): Promise<Module>;
|
|
68
|
+
//# sourceMappingURL=loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../../src/assets/dynamic-importmap/loader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH;;GAEG;AACH,OAAO,KAAK,KAAK,MAAM,iBAAiB,CAAC;AAQzC,MAAM,WAAW,UAAU;IAC1B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,OAAO,CAAE,UAAU,CAAE,CAAC;IACrC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,OAAO,CAAE,IAAI,CAAE,CAAC;IAC9B,QAAQ,CAAC,EAAE,UAAU,CAAE,OAAO,KAAK,CAAC,KAAK,CAAE,CAAC;IAC5C,IAAI,CAAC,EAAE,UAAU,EAAE,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,WAAW,eAAa,CAAC;AAUtC;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,KAEC,CAAC;AAK/B,eAAO,MAAM,QAAQ,IAAK,CAAC;AAuP3B;;;;;;;;GAQG;AACH,wBAAsB,aAAa,CAClC,GAAG,EAAE,MAAM,EACX,SAAS,CAAC,EAAE,WAAW,GACrB,OAAO,CAAE,UAAU,CAAE,CASvB;AAED;;;;;GAKG;AACH,wBAAsB,qBAAqB,CAAE,MAAM,GAAG,OAAO,EAC5D,IAAI,EAAE,UAAU,GACd,OAAO,CAAE,MAAM,CAAE,CAOnB;AAED;;;;;;;;;GASG;AACH,wBAAsB,YAAY,CAAE,MAAM,GAAG,OAAO,EACnD,GAAG,EAAE,MAAM,EACX,SAAS,CAAC,EAAE,WAAW,GACrB,OAAO,CAAE,MAAM,CAAE,CAGnB"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code is derived from the following projects:
|
|
3
|
+
*
|
|
4
|
+
* 1. dynamic-importmap (https://github.com/keller-mark/dynamic-importmap)
|
|
5
|
+
* 2. es-module-shims (https://github.com/guybedford/es-module-shims)
|
|
6
|
+
*
|
|
7
|
+
* The original implementation was created by Guy Bedford in es-module-shims,
|
|
8
|
+
* then adapted by Mark Keller in dynamic-importmap, and further modified
|
|
9
|
+
* for use in this project.
|
|
10
|
+
*
|
|
11
|
+
* Both projects are licensed under the MIT license.
|
|
12
|
+
*
|
|
13
|
+
* MIT License: https://opensource.org/licenses/MIT
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Extends the internal dynamic import map with the passed one.
|
|
17
|
+
*
|
|
18
|
+
* @param importMapIn Import map.
|
|
19
|
+
* @param importMapIn.imports Imports declaration.
|
|
20
|
+
* @param importMapIn.scopes Scopes declaration.
|
|
21
|
+
*/
|
|
22
|
+
export declare function addImportMap(importMapIn: {
|
|
23
|
+
imports?: Record<string, string>;
|
|
24
|
+
scopes?: Record<string, any>;
|
|
25
|
+
}): void;
|
|
26
|
+
/**
|
|
27
|
+
* Resolves the URL of the passed module ID against the current internal
|
|
28
|
+
* dynamic import map.
|
|
29
|
+
*
|
|
30
|
+
* @param id Module ID.
|
|
31
|
+
* @param parentUrl Parent URL, in case the module ID is relative.
|
|
32
|
+
* @return Resolved module URL.
|
|
33
|
+
*/
|
|
34
|
+
export declare function resolve(id: string, parentUrl: string): string;
|
|
35
|
+
//# sourceMappingURL=resolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolver.d.ts","sourceRoot":"","sources":["../../../src/assets/dynamic-importmap/resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAyPH;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAE,WAAW,EAAE;IAC1C,OAAO,CAAC,EAAE,MAAM,CAAE,MAAM,EAAE,MAAM,CAAE,CAAC;IACnC,MAAM,CAAC,EAAE,MAAM,CAAE,MAAM,EAAE,GAAG,CAAE,CAAC;CAC/B,QAMA;AAED;;;;;;;GAOG;AACH,wBAAgB,OAAO,CAAE,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAI,MAAM,CAG/D"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { type ModuleLoad } from './dynamic-importmap';
|
|
5
|
+
/**
|
|
6
|
+
* Marks the specified module as natively resolved.
|
|
7
|
+
* @param url Script module URL.
|
|
8
|
+
*/
|
|
9
|
+
export declare const markScriptModuleAsResolved: (url: string) => void;
|
|
10
|
+
/**
|
|
11
|
+
* Resolves and fetches modules present in the passed document, using the
|
|
12
|
+
* document's import map to resolve them.
|
|
13
|
+
*
|
|
14
|
+
* @param doc Document containing the modules to preload.
|
|
15
|
+
* @return Array of promises that resolve to a `ScriptModuleLoad` instance.
|
|
16
|
+
*/
|
|
17
|
+
export declare const preloadScriptModules: (doc: Document) => Promise<ModuleLoad>[];
|
|
18
|
+
/**
|
|
19
|
+
* Imports modules respresented by the passed `ScriptModuleLoad` instances.
|
|
20
|
+
*
|
|
21
|
+
* @param modules Array of `MoudleLoad` instances.
|
|
22
|
+
* @return Promise that resolves once all modules are imported.
|
|
23
|
+
*/
|
|
24
|
+
export declare const importScriptModules: (modules: ScriptModuleLoad[]) => Promise<unknown[]>;
|
|
25
|
+
export type ScriptModuleLoad = ModuleLoad;
|
|
26
|
+
//# sourceMappingURL=script-modules.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"script-modules.d.ts","sourceRoot":"","sources":["../../src/assets/script-modules.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAIN,KAAK,UAAU,EACf,MAAM,qBAAqB,CAAC;AAQ7B;;;GAGG;AACH,eAAO,MAAM,0BAA0B,QAAU,MAAM,SAEtD,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,QAAU,QAAQ,0BA0BlD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,YAAc,gBAAgB,EAAE,uBACE,CAAC;AAEnE,MAAM,MAAM,gBAAgB,GAAG,UAAU,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculates the Shortest Common Supersequence (SCS) of two sequences.
|
|
3
|
+
*
|
|
4
|
+
* A supersequence is a sequence that contains both input sequences as subsequences.
|
|
5
|
+
* The shortest common supersequence is the shortest possible such sequence.
|
|
6
|
+
*
|
|
7
|
+
* This implementation uses dynamic programming with a time complexity of O(mn)
|
|
8
|
+
* and space complexity of O(mn), where m and n are the lengths of sequences X and Y.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* const seq1 = [1, 3, 5];
|
|
13
|
+
* const seq2 = [2, 3, 4];
|
|
14
|
+
* const scs = shortestCommonSupersequence(seq1, seq2); // [1, 2, 3, 4, 5]
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* @param X The first sequence.
|
|
18
|
+
* @param Y The second sequence.
|
|
19
|
+
* @param isEqual Optional equality function to compare elements.
|
|
20
|
+
* Defaults to strict equality (===).
|
|
21
|
+
* @return The shortest common supersequence of X and Y.
|
|
22
|
+
*/
|
|
23
|
+
export declare function shortestCommonSupersequence<E = unknown>(X: E[], Y: E[], isEqual?: (a: E, b: E) => boolean): E[];
|
|
24
|
+
//# sourceMappingURL=scs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scs.d.ts","sourceRoot":"","sources":["../../src/assets/scs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,2BAA2B,CAAE,CAAC,GAAG,OAAO,EACvD,CAAC,EAAE,CAAC,EAAE,EACN,CAAC,EAAE,CAAC,EAAE,EACN,OAAO,OAAQ,CAAC,KAAK,CAAC,YAAa,OAmCnC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
export type StyleElement = HTMLLinkElement | HTMLStyleElement;
|
|
2
|
+
/**
|
|
3
|
+
* Normalizes the passed style or link element, reverting the changes
|
|
4
|
+
* made by {@link prepareStylePromise|`prepareStylePromise`} to the
|
|
5
|
+
* `data-original-media` and `media`.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* The following elements should be normalized to the same element:
|
|
9
|
+
* ```html
|
|
10
|
+
* <link rel="stylesheet" src="./assets/styles.css">
|
|
11
|
+
* <link rel="stylesheet" src="./assets/styles.css" media="all">
|
|
12
|
+
* <link rel="stylesheet" src="./assets/styles.css" media="preload">
|
|
13
|
+
* <link rel="stylesheet" src="./assets/styles.css" media="preload" data-original-media="all">
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @param element `<style>` or `<link>` element.
|
|
17
|
+
* @return Normalized node.
|
|
18
|
+
*/
|
|
19
|
+
export declare const normalizeMedia: (element: StyleElement) => StyleElement;
|
|
20
|
+
/**
|
|
21
|
+
* Adds the minimum style elements from Y around those in X using a
|
|
22
|
+
* shortest common supersequence algorithm, returning a list of
|
|
23
|
+
* promises for all the elements in Y.
|
|
24
|
+
*
|
|
25
|
+
* If X is empty, it appends all elements in Y to the passed parent
|
|
26
|
+
* element or to `document.head` instead.
|
|
27
|
+
*
|
|
28
|
+
* The returned promises resolve once the corresponding style element
|
|
29
|
+
* is loaded and ready. Those elements that are also in X return a
|
|
30
|
+
* cached promise.
|
|
31
|
+
*
|
|
32
|
+
* The algorithm ensures that the final style elements present in the
|
|
33
|
+
* document (or the passed `parent` element) are in the correct order
|
|
34
|
+
* and they are included in either X or Y.
|
|
35
|
+
*
|
|
36
|
+
* @param X Base list of style elements.
|
|
37
|
+
* @param Y List of style elements.
|
|
38
|
+
* @param parent Optional parent element to append to the new style elements.
|
|
39
|
+
* @return List of promises that resolve once the elements in Y are ready.
|
|
40
|
+
*/
|
|
41
|
+
export declare function updateStylesWithSCS(X: StyleElement[], Y: StyleElement[], parent?: Element): any[];
|
|
42
|
+
/**
|
|
43
|
+
* Prepares all style elements contained in the passed document.
|
|
44
|
+
*
|
|
45
|
+
* This function calls {@link updateStylesWithSCS|`updateStylesWithSCS`}
|
|
46
|
+
* to insert only the minimum amount of style elements into the DOM, so
|
|
47
|
+
* those present in the passed document end up in the DOM while the order
|
|
48
|
+
* is respected.
|
|
49
|
+
*
|
|
50
|
+
* New appended style elements contain a `media=preload` attribute to
|
|
51
|
+
* make them effectively disabled until they are applied with the
|
|
52
|
+
* {@link applyStyles|`applyStyles`} function.
|
|
53
|
+
*
|
|
54
|
+
* @param doc Document instance.
|
|
55
|
+
* @param url URL for the passed document.
|
|
56
|
+
* @return A list of promises for each style element in the passed document.
|
|
57
|
+
*/
|
|
58
|
+
export declare const preloadStyles: (doc: Document, url: string) => Promise<StyleElement>[];
|
|
59
|
+
/**
|
|
60
|
+
* Traverses all style elements in the DOM, enabling only those included
|
|
61
|
+
* in the passed list and disabling the others.
|
|
62
|
+
*
|
|
63
|
+
* If the style element has the `data-original-media` attribute, the
|
|
64
|
+
* original `media` value is restored.
|
|
65
|
+
*
|
|
66
|
+
* @param styles List of style elements to apply.
|
|
67
|
+
*/
|
|
68
|
+
export declare const applyStyles: (styles: StyleElement[]) => void;
|
|
69
|
+
//# sourceMappingURL=styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../src/assets/styles.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,YAAY,GAAG,eAAe,GAAG,gBAAgB,CAAC;AAa9D;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,cAAc,YAAc,YAAY,KAAI,YAYxD,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,mBAAmB,CAClC,CAAC,EAAE,YAAY,EAAE,EACjB,CAAC,EAAE,YAAY,EAAE,EACjB,MAAM,GAAE,OAA8B,SAqDtC;AAiFD;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,aAAa,QACpB,QAAQ,OACR,MAAM,KACT,OAAO,CAAE,YAAY,CAAE,EAoBzB,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,WAAW,WAAa,YAAY,EAAE,SAclD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"full-page.d.ts","sourceRoot":"","sources":["../src/full-page.ts"],"names":[],"mappings":"AACA,QAAA,MAAM,WAAW,QAAU,iBAAiB,YASS,CAAC;AAGtD,QAAA,MAAM,YAAY,UAAY,UAAU,YAOf,CAAC"}
|
package/build-types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
interface NavigateOptions {
|
|
1
|
+
export interface NavigateOptions {
|
|
2
2
|
force?: boolean;
|
|
3
3
|
html?: string;
|
|
4
4
|
replace?: boolean;
|
|
@@ -6,7 +6,7 @@ interface NavigateOptions {
|
|
|
6
6
|
loadingAnimation?: boolean;
|
|
7
7
|
screenReaderAnnouncement?: boolean;
|
|
8
8
|
}
|
|
9
|
-
interface PrefetchOptions {
|
|
9
|
+
export interface PrefetchOptions {
|
|
10
10
|
force?: boolean;
|
|
11
11
|
html?: string;
|
|
12
12
|
}
|
|
@@ -17,8 +17,7 @@ export declare const state: {
|
|
|
17
17
|
hasFinished: boolean;
|
|
18
18
|
};
|
|
19
19
|
}, actions: {
|
|
20
|
-
navigate: (href: string, options?: NavigateOptions) => void
|
|
21
|
-
prefetch: (url: string, options?: PrefetchOptions) => void
|
|
20
|
+
navigate: (href: string, options?: NavigateOptions) => Promise<void>;
|
|
21
|
+
prefetch: (url: string, options?: PrefetchOptions) => Promise<void>;
|
|
22
22
|
};
|
|
23
|
-
export {};
|
|
24
23
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAiCA,MAAM,WAAW,eAAe;IAC/B,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,MAAM,WAAW,eAAe;IAC/B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACd;AAiPD,eAAO,MAAQ,KAAK;SAfb,MAAM;;oBAEE,OAAO;qBACN,OAAO;;GAYD,OAAO;cARjB,CACT,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,eAAe,KACrB,OAAO,CAAE,IAAI,CAAE;cACV,CAAE,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe,KAAM,OAAO,CAAE,IAAI,CAAE;CAqJtE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/interactivity-router",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.26.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",
|
|
@@ -25,14 +25,18 @@
|
|
|
25
25
|
"main": "build/index.js",
|
|
26
26
|
"module": "build-module/index.js",
|
|
27
27
|
"react-native": "src/index",
|
|
28
|
-
"wpScriptModuleExports":
|
|
28
|
+
"wpScriptModuleExports": {
|
|
29
|
+
".": "./build-module/index.js",
|
|
30
|
+
"./full-page": "./build-module/full-page.js"
|
|
31
|
+
},
|
|
29
32
|
"types": "build-types",
|
|
30
33
|
"dependencies": {
|
|
31
|
-
"@wordpress/a11y": "^4.
|
|
32
|
-
"@wordpress/interactivity": "^6.
|
|
34
|
+
"@wordpress/a11y": "^4.26.0",
|
|
35
|
+
"@wordpress/interactivity": "^6.26.0",
|
|
36
|
+
"es-module-lexer": "^1.5.4"
|
|
33
37
|
},
|
|
34
38
|
"publishConfig": {
|
|
35
39
|
"access": "public"
|
|
36
40
|
},
|
|
37
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "35e26942820d8237771af0c58e45b4303f0497f1"
|
|
38
42
|
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code is derived from the following projects:
|
|
3
|
+
*
|
|
4
|
+
* 1. dynamic-importmap (https://github.com/keller-mark/dynamic-importmap)
|
|
5
|
+
* 2. es-module-shims (https://github.com/guybedford/es-module-shims)
|
|
6
|
+
*
|
|
7
|
+
* The original implementation was created by Guy Bedford in es-module-shims,
|
|
8
|
+
* then adapted by Mark Keller in dynamic-importmap, and further modified
|
|
9
|
+
* for use in this project.
|
|
10
|
+
*
|
|
11
|
+
* Both projects are licensed under the MIT license.
|
|
12
|
+
*
|
|
13
|
+
* MIT License: https://opensource.org/licenses/MIT
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Internal dependencies
|
|
18
|
+
*/
|
|
19
|
+
import { type ModuleLoad } from './loader';
|
|
20
|
+
|
|
21
|
+
const fetching = ( url: string, parent?: string ) => {
|
|
22
|
+
return ` fetching ${ url }${ parent ? ` from ${ parent }` : '' }`;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const jsContentType = /^(text|application)\/(x-)?javascript(;|$)/;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Fetches the passed module URL and return the corresponding `ModuleLoad`
|
|
29
|
+
* instance. If the passed URL does not point to a JS file, the function
|
|
30
|
+
* throws and error.
|
|
31
|
+
*
|
|
32
|
+
* @param url Module URL.
|
|
33
|
+
* @param fetchOpts Fetch init options.
|
|
34
|
+
* @param parent Parent module URL referencing this URL (if any).
|
|
35
|
+
* @return Promise with a `ModuleLoad` instance.
|
|
36
|
+
*/
|
|
37
|
+
export async function fetchModule(
|
|
38
|
+
url: string,
|
|
39
|
+
fetchOpts: RequestInit,
|
|
40
|
+
parent: string
|
|
41
|
+
): Promise< ModuleLoad > {
|
|
42
|
+
let res: Response;
|
|
43
|
+
try {
|
|
44
|
+
res = await fetch( url, fetchOpts );
|
|
45
|
+
} catch ( e ) {
|
|
46
|
+
throw Error( `Network error${ fetching( url, parent ) }.` );
|
|
47
|
+
}
|
|
48
|
+
if ( ! res.ok ) {
|
|
49
|
+
throw Error( `Error ${ res.status }${ fetching( url, parent ) }.` );
|
|
50
|
+
}
|
|
51
|
+
const contentType = res.headers.get( 'content-type' );
|
|
52
|
+
if ( ! jsContentType.test( contentType ) ) {
|
|
53
|
+
throw Error(
|
|
54
|
+
`Bad Content-Type "${ contentType }"${ fetching( url, parent ) }.`
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
return { responseUrl: res.url, source: await res.text() };
|
|
58
|
+
}
|