@wordpress/interactivity-router 2.31.1-next.f56bd8138.0 → 2.32.1-next.47f435fc9.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 +4 -0
- package/build/assets/dynamic-importmap/fetch.js +32 -43
- package/build/assets/dynamic-importmap/fetch.js.map +7 -1
- package/build/assets/dynamic-importmap/index.js +43 -73
- package/build/assets/dynamic-importmap/index.js.map +7 -1
- package/build/assets/dynamic-importmap/loader.js +139 -172
- package/build/assets/dynamic-importmap/loader.js.map +7 -1
- package/build/assets/dynamic-importmap/resolver.js +99 -112
- package/build/assets/dynamic-importmap/resolver.js.map +7 -1
- package/build/assets/script-modules.js +46 -58
- package/build/assets/script-modules.js.map +7 -1
- package/build/assets/scs.js +30 -39
- package/build/assets/scs.js.map +7 -1
- package/build/assets/styles.js +81 -171
- package/build/assets/styles.js.map +7 -1
- package/build/full-page.js +43 -36
- package/build/full-page.js.map +7 -1
- package/build/index.js +180 -243
- package/build/index.js.map +7 -1
- package/build-module/assets/dynamic-importmap/fetch.js +11 -39
- package/build-module/assets/dynamic-importmap/fetch.js.map +7 -1
- package/build-module/assets/dynamic-importmap/index.js +18 -52
- package/build-module/assets/dynamic-importmap/index.js.map +7 -1
- package/build-module/assets/dynamic-importmap/loader.js +101 -165
- package/build-module/assets/dynamic-importmap/loader.js.map +7 -1
- package/build-module/assets/dynamic-importmap/resolver.js +78 -108
- package/build-module/assets/dynamic-importmap/resolver.js.map +7 -1
- package/build-module/assets/script-modules.js +25 -49
- package/build-module/assets/script-modules.js.map +7 -1
- package/build-module/assets/scs.js +9 -35
- package/build-module/assets/scs.js.map +7 -1
- package/build-module/assets/styles.js +58 -163
- package/build-module/assets/styles.js.map +7 -1
- package/build-module/full-page.js +21 -32
- package/build-module/full-page.js.map +7 -1
- package/build-module/index.js +149 -235
- package/build-module/index.js.map +7 -1
- package/build-types/index.d.ts.map +1 -1
- package/package.json +12 -4
- package/src/index.ts +106 -26
- package/tsconfig.main.tsbuildinfo +1 -1
package/build-module/index.js
CHANGED
|
@@ -1,74 +1,57 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
* Internal dependencies
|
|
9
|
-
*/
|
|
10
|
-
import { preloadStyles, applyStyles } from './assets/styles';
|
|
11
|
-
import { preloadScriptModules, importScriptModules, markScriptModuleAsResolved } from './assets/script-modules';
|
|
1
|
+
import { store, privateApis, getConfig } from "@wordpress/interactivity";
|
|
2
|
+
import { preloadStyles, applyStyles } from "./assets/styles";
|
|
3
|
+
import {
|
|
4
|
+
preloadScriptModules,
|
|
5
|
+
importScriptModules,
|
|
6
|
+
markScriptModuleAsResolved
|
|
7
|
+
} from "./assets/script-modules";
|
|
12
8
|
const {
|
|
13
|
-
directivePrefix,
|
|
14
9
|
getRegionRootFragment,
|
|
15
10
|
initialVdom,
|
|
16
11
|
toVdom,
|
|
17
12
|
render,
|
|
18
13
|
parseServerData,
|
|
19
14
|
populateServerData,
|
|
20
|
-
batch
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const getPagePath = url => {
|
|
15
|
+
batch,
|
|
16
|
+
routerRegions,
|
|
17
|
+
cloneElement
|
|
18
|
+
} = privateApis(
|
|
19
|
+
"I acknowledge that using private APIs means my theme or plugin will inevitably break in the next version of WordPress."
|
|
20
|
+
);
|
|
21
|
+
const regionAttr = `data-wp-router-region`;
|
|
22
|
+
const interactiveAttr = `data-wp-interactive`;
|
|
23
|
+
const regionsSelector = `[${interactiveAttr}][${regionAttr}], [${interactiveAttr}] [${interactiveAttr}][${regionAttr}]`;
|
|
24
|
+
const pages = /* @__PURE__ */ new Map();
|
|
25
|
+
const getPagePath = (url) => {
|
|
31
26
|
const u = new URL(url, window.location.href);
|
|
32
27
|
return u.pathname + u.search;
|
|
33
28
|
};
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Parses the given region's directive.
|
|
37
|
-
*
|
|
38
|
-
* @param region Region element.
|
|
39
|
-
* @return Data contained in the region directive value.
|
|
40
|
-
*/
|
|
41
|
-
const parseRegionAttribute = region => {
|
|
29
|
+
const parseRegionAttribute = (region) => {
|
|
42
30
|
const value = region.getAttribute(regionAttr);
|
|
43
31
|
try {
|
|
44
|
-
const {
|
|
45
|
-
|
|
46
|
-
attachTo
|
|
47
|
-
} = JSON.parse(value);
|
|
48
|
-
return {
|
|
49
|
-
id,
|
|
50
|
-
attachTo
|
|
51
|
-
};
|
|
32
|
+
const { id, attachTo } = JSON.parse(value);
|
|
33
|
+
return { id, attachTo };
|
|
52
34
|
} catch (e) {
|
|
53
|
-
return {
|
|
54
|
-
id: value
|
|
55
|
-
};
|
|
35
|
+
return { id: value };
|
|
56
36
|
}
|
|
57
37
|
};
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
38
|
+
const cloneRouterRegionContent = (vdom) => {
|
|
39
|
+
if (!vdom) {
|
|
40
|
+
return vdom;
|
|
41
|
+
}
|
|
42
|
+
const allPriorityLevels = vdom.props.priorityLevels;
|
|
43
|
+
const routerRegionLevel = allPriorityLevels.findIndex(
|
|
44
|
+
(level) => level.includes("router-region")
|
|
45
|
+
);
|
|
46
|
+
const priorityLevels = routerRegionLevel !== -1 ? allPriorityLevels.slice(routerRegionLevel + 1) : allPriorityLevels;
|
|
47
|
+
return priorityLevels.length > 0 ? cloneElement(vdom, {
|
|
48
|
+
...vdom.props,
|
|
49
|
+
priorityLevels
|
|
50
|
+
}) : vdom.props.element;
|
|
51
|
+
};
|
|
52
|
+
const regionsToAttachByParent = /* @__PURE__ */ new WeakMap();
|
|
53
|
+
const rootFragmentsByParent = /* @__PURE__ */ new WeakMap();
|
|
54
|
+
const fetchPage = async (url, { html }) => {
|
|
72
55
|
try {
|
|
73
56
|
if (!html) {
|
|
74
57
|
const res = await window.fetch(url);
|
|
@@ -77,56 +60,33 @@ const fetchPage = async (url, {
|
|
|
77
60
|
}
|
|
78
61
|
html = await res.text();
|
|
79
62
|
}
|
|
80
|
-
const dom = new window.DOMParser().parseFromString(html,
|
|
63
|
+
const dom = new window.DOMParser().parseFromString(html, "text/html");
|
|
81
64
|
return await preparePage(url, dom);
|
|
82
65
|
} catch (e) {
|
|
83
66
|
return false;
|
|
84
67
|
}
|
|
85
68
|
};
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
* Processes a DOM document to extract router regions and related resources.
|
|
89
|
-
*
|
|
90
|
-
* This function analyzes the provided DOM document and creates a virtual DOM
|
|
91
|
-
* representation of all HTML regions marked with a `router-region` directive.
|
|
92
|
-
* It also extracts and preloads associated styles and scripts to prepare for
|
|
93
|
-
* rendering the page.
|
|
94
|
-
*
|
|
95
|
-
* @param url The URL associated with the page, used for asset
|
|
96
|
-
* loading and caching.
|
|
97
|
-
* @param dom The DOM document to process.
|
|
98
|
-
* @param vdomParams Optional parameters for virtual DOM processing.
|
|
99
|
-
* @param vdomParams.vdom An optional existing virtual DOM cache to check for
|
|
100
|
-
* regions. If a region exists in this cache, it will be
|
|
101
|
-
* reused instead of creating a new vDOM representation.
|
|
102
|
-
* @return A Promise that resolves to a {@link Page} object
|
|
103
|
-
* containing the virtual DOM for all router regions,
|
|
104
|
-
* preloaded styles and scripts, page title, and initial
|
|
105
|
-
* server-rendered data.
|
|
106
|
-
*/
|
|
107
|
-
const preparePage = async (url, dom, {
|
|
108
|
-
vdom
|
|
109
|
-
} = {}) => {
|
|
110
|
-
// Remove all noscript elements as they're irrelevant when request is served via router.
|
|
111
|
-
// This prevents browsers from extracting styles from noscript tags.
|
|
112
|
-
dom.querySelectorAll('noscript').forEach(el => el.remove());
|
|
69
|
+
const preparePage = async (url, dom, { vdom } = {}) => {
|
|
70
|
+
dom.querySelectorAll("noscript").forEach((el) => el.remove());
|
|
113
71
|
const regions = {};
|
|
114
72
|
const regionsToAttach = {};
|
|
115
|
-
dom.querySelectorAll(regionsSelector).forEach(region => {
|
|
116
|
-
const {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
|
|
73
|
+
dom.querySelectorAll(regionsSelector).forEach((region) => {
|
|
74
|
+
const { id, attachTo } = parseRegionAttribute(region);
|
|
75
|
+
if (region.parentElement.closest(`[${regionAttr}]`)) {
|
|
76
|
+
regions[id] = void 0;
|
|
77
|
+
} else {
|
|
78
|
+
regions[id] = vdom?.has(region) ? vdom.get(region) : toVdom(region);
|
|
79
|
+
}
|
|
121
80
|
if (attachTo) {
|
|
122
81
|
regionsToAttach[id] = attachTo;
|
|
123
82
|
}
|
|
124
83
|
});
|
|
125
|
-
const title = dom.querySelector(
|
|
84
|
+
const title = dom.querySelector("title")?.innerText;
|
|
126
85
|
const initialData = parseServerData(dom);
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
86
|
+
const [styles, scriptModules] = await Promise.all([
|
|
87
|
+
Promise.all(preloadStyles(dom, url)),
|
|
88
|
+
Promise.all(preloadScriptModules(dom))
|
|
89
|
+
]);
|
|
130
90
|
return {
|
|
131
91
|
regions,
|
|
132
92
|
regionsToAttach,
|
|
@@ -137,105 +97,87 @@ const preparePage = async (url, dom, {
|
|
|
137
97
|
url
|
|
138
98
|
};
|
|
139
99
|
};
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* Renders a page by applying styles, populating server data, rendering regions,
|
|
143
|
-
* and updating the document title.
|
|
144
|
-
*
|
|
145
|
-
* @param page The {@link Page} object to render.
|
|
146
|
-
*/
|
|
147
|
-
const renderPage = page => {
|
|
100
|
+
const renderPage = (page) => {
|
|
148
101
|
applyStyles(page.styles);
|
|
149
|
-
|
|
150
|
-
// Clone regionsToAttach.
|
|
151
|
-
const regionsToAttach = {
|
|
152
|
-
...page.regionsToAttach
|
|
153
|
-
};
|
|
102
|
+
const regionsToAttach = { ...page.regionsToAttach };
|
|
154
103
|
batch(() => {
|
|
155
104
|
populateServerData(page.initialData);
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
id
|
|
159
|
-
} = parseRegionAttribute(region);
|
|
160
|
-
const fragment = getRegionRootFragment(region);
|
|
161
|
-
render(page.regions[id], fragment);
|
|
162
|
-
// If this is an attached region, remove it from the list.
|
|
163
|
-
delete regionsToAttach[id];
|
|
105
|
+
routerRegions.forEach((signal) => {
|
|
106
|
+
signal.value = null;
|
|
164
107
|
});
|
|
165
|
-
|
|
166
|
-
// Render unattached regions.
|
|
108
|
+
const parentsToUpdate = /* @__PURE__ */ new Set();
|
|
167
109
|
for (const id in regionsToAttach) {
|
|
168
110
|
const parent = document.querySelector(regionsToAttach[id]);
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
const
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
111
|
+
if (!regionsToAttachByParent.has(parent)) {
|
|
112
|
+
regionsToAttachByParent.set(parent, []);
|
|
113
|
+
}
|
|
114
|
+
const regions = regionsToAttachByParent.get(parent);
|
|
115
|
+
if (!regions.includes(id)) {
|
|
116
|
+
regions.push(id);
|
|
117
|
+
parentsToUpdate.add(parent);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
for (const id in page.regions) {
|
|
121
|
+
if (routerRegions.has(id)) {
|
|
122
|
+
routerRegions.get(id).value = cloneRouterRegionContent(
|
|
123
|
+
page.regions[id]
|
|
124
|
+
);
|
|
125
|
+
}
|
|
184
126
|
}
|
|
127
|
+
parentsToUpdate.forEach((parent) => {
|
|
128
|
+
const ids = regionsToAttachByParent.get(parent);
|
|
129
|
+
const vdoms = ids.map((id) => page.regions[id]);
|
|
130
|
+
if (!rootFragmentsByParent.has(parent)) {
|
|
131
|
+
const regions = vdoms.map(({ props, type }) => {
|
|
132
|
+
const elementType = typeof type === "function" ? props.type : type;
|
|
133
|
+
const region = document.createElement(elementType);
|
|
134
|
+
parent.appendChild(region);
|
|
135
|
+
return region;
|
|
136
|
+
});
|
|
137
|
+
rootFragmentsByParent.set(
|
|
138
|
+
parent,
|
|
139
|
+
getRegionRootFragment(regions)
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
const fragment = rootFragmentsByParent.get(parent);
|
|
143
|
+
render(vdoms, fragment);
|
|
144
|
+
});
|
|
185
145
|
});
|
|
186
146
|
if (page.title) {
|
|
187
147
|
document.title = page.title;
|
|
188
148
|
}
|
|
189
149
|
};
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* Loads the given page forcing a full page reload.
|
|
193
|
-
*
|
|
194
|
-
* The function returns a promise that won't resolve, useful to prevent any
|
|
195
|
-
* potential feedback indicating that the navigation has finished while the new
|
|
196
|
-
* page is being loaded.
|
|
197
|
-
*
|
|
198
|
-
* @param href The page href.
|
|
199
|
-
* @return Promise that never resolves.
|
|
200
|
-
*/
|
|
201
|
-
const forcePageReload = href => {
|
|
150
|
+
const forcePageReload = (href) => {
|
|
202
151
|
window.location.assign(href);
|
|
203
|
-
return new Promise(() => {
|
|
152
|
+
return new Promise(() => {
|
|
153
|
+
});
|
|
204
154
|
};
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
window.addEventListener('popstate', async () => {
|
|
209
|
-
const pagePath = getPagePath(window.location.href); // Remove hash.
|
|
210
|
-
const page = pages.has(pagePath) && (await pages.get(pagePath));
|
|
155
|
+
window.addEventListener("popstate", async () => {
|
|
156
|
+
const pagePath = getPagePath(window.location.href);
|
|
157
|
+
const page = pages.has(pagePath) && await pages.get(pagePath);
|
|
211
158
|
if (page) {
|
|
212
159
|
renderPage(page);
|
|
213
|
-
// Update the URL in the state.
|
|
214
160
|
state.url = window.location.href;
|
|
215
161
|
} else {
|
|
216
162
|
window.location.reload();
|
|
217
163
|
}
|
|
218
164
|
});
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
window.
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
let navigatingTo = '';
|
|
165
|
+
window.document.querySelectorAll("script[type=module][src]").forEach(({ src }) => markScriptModuleAsResolved(src));
|
|
166
|
+
pages.set(
|
|
167
|
+
getPagePath(window.location.href),
|
|
168
|
+
Promise.resolve(
|
|
169
|
+
preparePage(getPagePath(window.location.href), document, {
|
|
170
|
+
vdom: initialVdom
|
|
171
|
+
})
|
|
172
|
+
)
|
|
173
|
+
);
|
|
174
|
+
let navigatingTo = "";
|
|
230
175
|
let hasLoadedNavigationTextsData = false;
|
|
231
176
|
const navigationTexts = {
|
|
232
|
-
loading:
|
|
233
|
-
loaded:
|
|
177
|
+
loading: "Loading page, please wait.",
|
|
178
|
+
loaded: "Page Loaded."
|
|
234
179
|
};
|
|
235
|
-
|
|
236
|
-
state,
|
|
237
|
-
actions
|
|
238
|
-
} = store('core/router', {
|
|
180
|
+
const { state, actions } = store("core/router", {
|
|
239
181
|
state: {
|
|
240
182
|
url: window.location.href,
|
|
241
183
|
navigation: {
|
|
@@ -263,29 +205,22 @@ export const {
|
|
|
263
205
|
* @return Promise that resolves once the navigation is completed or aborted.
|
|
264
206
|
*/
|
|
265
207
|
*navigate(href, options = {}) {
|
|
266
|
-
const {
|
|
267
|
-
clientNavigationDisabled
|
|
268
|
-
} = getConfig();
|
|
208
|
+
const { clientNavigationDisabled } = getConfig();
|
|
269
209
|
if (clientNavigationDisabled) {
|
|
270
210
|
yield forcePageReload(href);
|
|
271
211
|
}
|
|
272
212
|
const pagePath = getPagePath(href);
|
|
273
|
-
const {
|
|
274
|
-
navigation
|
|
275
|
-
} = state;
|
|
213
|
+
const { navigation } = state;
|
|
276
214
|
const {
|
|
277
215
|
loadingAnimation = true,
|
|
278
216
|
screenReaderAnnouncement = true,
|
|
279
|
-
timeout =
|
|
217
|
+
timeout = 1e4
|
|
280
218
|
} = options;
|
|
281
219
|
navigatingTo = href;
|
|
282
220
|
actions.prefetch(pagePath, options);
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
const timeoutPromise = new Promise(resolve => setTimeout(resolve, timeout));
|
|
287
|
-
|
|
288
|
-
// Don't update the navigation status immediately, wait 400 ms.
|
|
221
|
+
const timeoutPromise = new Promise(
|
|
222
|
+
(resolve) => setTimeout(resolve, timeout)
|
|
223
|
+
);
|
|
289
224
|
const loadingTimeout = setTimeout(() => {
|
|
290
225
|
if (navigatingTo !== href) {
|
|
291
226
|
return;
|
|
@@ -295,42 +230,30 @@ export const {
|
|
|
295
230
|
navigation.hasFinished = false;
|
|
296
231
|
}
|
|
297
232
|
if (screenReaderAnnouncement) {
|
|
298
|
-
a11ySpeak(
|
|
233
|
+
a11ySpeak("loading");
|
|
299
234
|
}
|
|
300
235
|
}, 400);
|
|
301
|
-
const page = yield Promise.race([
|
|
302
|
-
|
|
303
|
-
|
|
236
|
+
const page = yield Promise.race([
|
|
237
|
+
pages.get(pagePath),
|
|
238
|
+
timeoutPromise
|
|
239
|
+
]);
|
|
304
240
|
clearTimeout(loadingTimeout);
|
|
305
|
-
|
|
306
|
-
// Once the page is fetched, the destination URL could have changed
|
|
307
|
-
// (e.g., by clicking another link in the meantime). If so, bail
|
|
308
|
-
// out, and let the newer execution to update the HTML.
|
|
309
241
|
if (navigatingTo !== href) {
|
|
310
242
|
return;
|
|
311
243
|
}
|
|
312
|
-
if (page && !page.initialData?.config?.[
|
|
244
|
+
if (page && !page.initialData?.config?.["core/router"]?.clientNavigationDisabled) {
|
|
313
245
|
yield importScriptModules(page.scriptModules);
|
|
314
246
|
renderPage(page);
|
|
315
|
-
window.history[options.replace ?
|
|
316
|
-
|
|
317
|
-
// Update the URL in the state.
|
|
247
|
+
window.history[options.replace ? "replaceState" : "pushState"]({}, "", href);
|
|
318
248
|
state.url = href;
|
|
319
|
-
|
|
320
|
-
// Update the navigation status once the the new page rendering
|
|
321
|
-
// has been completed.
|
|
322
249
|
if (loadingAnimation) {
|
|
323
250
|
navigation.hasStarted = false;
|
|
324
251
|
navigation.hasFinished = true;
|
|
325
252
|
}
|
|
326
253
|
if (screenReaderAnnouncement) {
|
|
327
|
-
a11ySpeak(
|
|
254
|
+
a11ySpeak("loaded");
|
|
328
255
|
}
|
|
329
|
-
|
|
330
|
-
// Scroll to the anchor if exits in the link.
|
|
331
|
-
const {
|
|
332
|
-
hash
|
|
333
|
-
} = new URL(href, window.location.href);
|
|
256
|
+
const { hash } = new URL(href, window.location.href);
|
|
334
257
|
if (hash) {
|
|
335
258
|
document.querySelector(hash)?.scrollIntoView();
|
|
336
259
|
}
|
|
@@ -352,66 +275,57 @@ export const {
|
|
|
352
275
|
* @return Promise that resolves once the page has been fetched.
|
|
353
276
|
*/
|
|
354
277
|
*prefetch(url, options = {}) {
|
|
355
|
-
const {
|
|
356
|
-
clientNavigationDisabled
|
|
357
|
-
} = getConfig();
|
|
278
|
+
const { clientNavigationDisabled } = getConfig();
|
|
358
279
|
if (clientNavigationDisabled) {
|
|
359
280
|
return;
|
|
360
281
|
}
|
|
361
282
|
const pagePath = getPagePath(url);
|
|
362
283
|
if (options.force || !pages.has(pagePath)) {
|
|
363
|
-
pages.set(
|
|
364
|
-
|
|
365
|
-
|
|
284
|
+
pages.set(
|
|
285
|
+
pagePath,
|
|
286
|
+
fetchPage(pagePath, { html: options.html })
|
|
287
|
+
);
|
|
366
288
|
}
|
|
367
289
|
yield pages.get(pagePath);
|
|
368
290
|
}
|
|
369
291
|
}
|
|
370
292
|
});
|
|
371
|
-
|
|
372
|
-
/**
|
|
373
|
-
* Announces a message to screen readers.
|
|
374
|
-
*
|
|
375
|
-
* This is a wrapper around the `@wordpress/a11y` package's `speak` function. It handles importing
|
|
376
|
-
* the package on demand and should be used instead of calling `a11y.speak` directly.
|
|
377
|
-
*
|
|
378
|
-
* @param messageKey The message to be announced by assistive technologies.
|
|
379
|
-
*/
|
|
380
293
|
function a11ySpeak(messageKey) {
|
|
381
294
|
if (!hasLoadedNavigationTextsData) {
|
|
382
295
|
hasLoadedNavigationTextsData = true;
|
|
383
|
-
const content = document.getElementById(
|
|
296
|
+
const content = document.getElementById(
|
|
297
|
+
"wp-script-module-data-@wordpress/interactivity-router"
|
|
298
|
+
)?.textContent;
|
|
384
299
|
if (content) {
|
|
385
300
|
try {
|
|
386
301
|
const parsed = JSON.parse(content);
|
|
387
|
-
if (typeof parsed?.i18n?.loading ===
|
|
302
|
+
if (typeof parsed?.i18n?.loading === "string") {
|
|
388
303
|
navigationTexts.loading = parsed.i18n.loading;
|
|
389
304
|
}
|
|
390
|
-
if (typeof parsed?.i18n?.loaded ===
|
|
305
|
+
if (typeof parsed?.i18n?.loaded === "string") {
|
|
391
306
|
navigationTexts.loaded = parsed.i18n.loaded;
|
|
392
307
|
}
|
|
393
|
-
} catch {
|
|
308
|
+
} catch {
|
|
309
|
+
}
|
|
394
310
|
} else {
|
|
395
|
-
// Fallback to localized strings from Interactivity API state.
|
|
396
|
-
// @todo This block is for Core < 6.7.0. Remove when support is dropped.
|
|
397
|
-
|
|
398
|
-
// @ts-expect-error
|
|
399
311
|
if (state.navigation.texts?.loading) {
|
|
400
|
-
// @ts-expect-error
|
|
401
312
|
navigationTexts.loading = state.navigation.texts.loading;
|
|
402
313
|
}
|
|
403
|
-
// @ts-expect-error
|
|
404
314
|
if (state.navigation.texts?.loaded) {
|
|
405
|
-
// @ts-expect-error
|
|
406
315
|
navigationTexts.loaded = state.navigation.texts.loaded;
|
|
407
316
|
}
|
|
408
317
|
}
|
|
409
318
|
}
|
|
410
319
|
const message = navigationTexts[messageKey];
|
|
411
|
-
import(
|
|
412
|
-
speak
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
320
|
+
import("@wordpress/a11y").then(
|
|
321
|
+
({ speak }) => speak(message),
|
|
322
|
+
// Ignore failures to load the a11y module.
|
|
323
|
+
() => {
|
|
324
|
+
}
|
|
325
|
+
);
|
|
416
326
|
}
|
|
417
|
-
|
|
327
|
+
export {
|
|
328
|
+
actions,
|
|
329
|
+
state
|
|
330
|
+
};
|
|
331
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1,7 @@
|
|
|
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","querySelectorAll","forEach","el","remove","regions","regionsToAttach","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\t// Remove all noscript elements as they're irrelevant when request is served via router.\n\t// This prevents browsers from extracting styles from noscript tags.\n\tdom.querySelectorAll( 'noscript' ).forEach( ( el ) => el.remove() );\n\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}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,KAAK,EAAEC,WAAW,EAAEC,SAAS,QAAQ,0BAA0B;;AAExE;AACA;AACA;AACA,SAASC,aAAa,EAAEC,WAAW,QAA2B,iBAAiB;AAC/E,SACCC,oBAAoB,EACpBC,mBAAmB,EACnBC,0BAA0B,QAEpB,yBAAyB;AAEhC,MAAM;EACLC,eAAe;EACfC,qBAAqB;EACrBC,WAAW;EACXC,MAAM;EACNC,MAAM;EACNC,eAAe;EACfC,kBAAkB;EAClBC;AACD,CAAC,GAAGd,WAAW,CACd,wHACD,CAAC;AAED,MAAMe,UAAU,GAAG,QAASR,eAAe,gBAAiB;AAC5D,MAAMS,eAAe,GAAG,QAAST,eAAe,cAAe;AAC/D,MAAMU,eAAe,GAAG,IAAKD,eAAe,KAAOD,UAAU,UAAYC,eAAe,MAAQA,eAAe,IAAK;AAoCpH;AACA,MAAME,KAAK,GAAG,IAAIC,GAAG,CAAoC,CAAC;;AAE1D;AACA;AACA,MAAMC,WAAW,GAAKC,GAAW,IAAM;EACtC,MAAMC,CAAC,GAAG,IAAIC,GAAG,CAAEF,GAAG,EAAEG,MAAM,CAACC,QAAQ,CAACC,IAAK,CAAC;EAC9C,OAAOJ,CAAC,CAACK,QAAQ,GAAGL,CAAC,CAACM,MAAM;AAC7B,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,oBAAoB,GAAKC,MAAe,IAAM;EACnD,MAAMC,KAAK,GAAGD,MAAM,CAACE,YAAY,CAAEjB,UAAW,CAAC;EAC/C,IAAI;IACH,MAAM;MAAEkB,EAAE;MAAEC;IAAS,CAAC,GAAGC,IAAI,CAACC,KAAK,CAAEL,KAAM,CAAC;IAC5C,OAAO;MAAEE,EAAE;MAAEC;IAAS,CAAC;EAC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GAAGT,KAAK,CAACW,UAAU,CAAC4B,KAAK,CAAC9B,MAAM;MACvD;IACD;EACD;EAEA,MAAM+B,OAAO,GAAGjC,eAAe,CAAE0B,UAAU,CAAE;EAE7C,MAAM,CAAE,iBAAkB,CAAC,CAACQ,IAAI,CAC/B,CAAE;IAAEC;EAAM,CAAC,KAAMA,KAAK,CAAEF,OAAQ,CAAC;EACjC;EACA,MAAM,CAAC,CACR,CAAC;AACF","ignoreList":[]}
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/index.ts"],
|
|
4
|
+
"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\tgetRegionRootFragment,\n\tinitialVdom,\n\ttoVdom,\n\trender,\n\tparseServerData,\n\tpopulateServerData,\n\tbatch,\n\trouterRegions,\n\tcloneElement,\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-wp-router-region`;\nconst interactiveAttr = `data-wp-interactive`;\nconst regionsSelector = `[${ interactiveAttr }][${ regionAttr }], [${ interactiveAttr }] [${ interactiveAttr }][${ regionAttr }]`;\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 * Clones the content of the router region vDOM passed as argument.\n *\n * The function creates a new VNode instance removing all priority levels up to\n * the one containing the router-region directive, which should have evaluated\n * in advance.\n *\n * @param vdom A router region's VNode.\n * @return The VNode for the passed router region's content.\n */\nconst cloneRouterRegionContent = ( vdom: any ) => {\n\tif ( ! vdom ) {\n\t\treturn vdom;\n\t}\n\tconst allPriorityLevels: string[][] = vdom.props.priorityLevels;\n\tconst routerRegionLevel = allPriorityLevels.findIndex( ( level ) =>\n\t\tlevel.includes( 'router-region' )\n\t);\n\tconst priorityLevels =\n\t\trouterRegionLevel !== -1\n\t\t\t? allPriorityLevels.slice( routerRegionLevel + 1 )\n\t\t\t: allPriorityLevels;\n\n\treturn priorityLevels.length > 0\n\t\t? cloneElement( vdom, {\n\t\t\t\t...vdom.props,\n\t\t\t\tpriorityLevels,\n\t\t } )\n\t\t: vdom.props.element;\n};\n\n/**\n * IDs of router regions with an `attachTo` property pointing to the same parent\n * element.\n */\nconst regionsToAttachByParent = new WeakMap< Element, string[] >();\n\n/**\n * Map of root fragments by parent element, used to render router regions with\n * the `attachTo` property. Those elements with the same parent are rendered\n * together in the corresponding root fragment.\n */\nconst rootFragmentsByParent = new WeakMap< Element, any >();\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\t// Remove all noscript elements as they're irrelevant when request is served via router.\n\t// This prevents browsers from extracting styles from noscript tags.\n\tdom.querySelectorAll( 'noscript' ).forEach( ( el ) => el.remove() );\n\n\tconst regions = {};\n\tconst regionsToAttach = {};\n\tdom.querySelectorAll( regionsSelector ).forEach( ( region ) => {\n\t\tconst { id, attachTo } = parseRegionAttribute( region );\n\n\t\tif ( region.parentElement.closest( `[${ regionAttr }]` ) ) {\n\t\t\tregions[ id ] = undefined;\n\t\t} else {\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\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\t// Update server data.\n\t\tpopulateServerData( page.initialData );\n\n\t\t// Reset all router regions before setting the actual values.\n\t\t( routerRegions as Map< string, any > ).forEach( ( signal ) => {\n\t\t\tsignal.value = null;\n\t\t} );\n\n\t\t//Init regions with attachTo that don't exist yet.\n\t\tconst parentsToUpdate = new Set< Element >();\n\t\tfor ( const id in regionsToAttach ) {\n\t\t\tconst parent = document.querySelector( regionsToAttach[ id ] );\n\t\t\tif ( ! regionsToAttachByParent.has( parent ) ) {\n\t\t\t\tregionsToAttachByParent.set( parent, [] );\n\t\t\t}\n\t\t\tconst regions = regionsToAttachByParent.get( parent );\n\t\t\tif ( ! regions.includes( id ) ) {\n\t\t\t\tregions.push( id );\n\t\t\t\tparentsToUpdate.add( parent );\n\t\t\t}\n\t\t}\n\n\t\t//Update all existing regions.\n\t\tfor ( const id in page.regions ) {\n\t\t\tif ( routerRegions.has( id ) ) {\n\t\t\t\trouterRegions.get( id ).value = cloneRouterRegionContent(\n\t\t\t\t\tpage.regions[ id ]\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\t// Render regions attached to the same parent in the same fragment.\n\t\tparentsToUpdate.forEach( ( parent ) => {\n\t\t\tconst ids = regionsToAttachByParent.get( parent );\n\t\t\tconst vdoms = ids.map( ( id ) => page.regions[ id ] );\n\n\t\t\tif ( ! rootFragmentsByParent.has( parent ) ) {\n\t\t\t\tconst regions = vdoms.map( ( { props, type } ) => {\n\t\t\t\t\tconst elementType =\n\t\t\t\t\t\ttypeof type === 'function' ? props.type : type;\n\n\t\t\t\t\t// Create an element with the obtained type where the region will be\n\t\t\t\t\t// rendered. The type should match the one of the root vnode.\n\t\t\t\t\tconst region = document.createElement( elementType );\n\t\t\t\t\tparent.appendChild( region );\n\t\t\t\t\treturn region;\n\t\t\t\t} );\n\t\t\t\trootFragmentsByParent.set(\n\t\t\t\t\tparent,\n\t\t\t\t\tgetRegionRootFragment( regions )\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst fragment = rootFragmentsByParent.get( parent );\n\t\t\trender( vdoms, 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}\n"],
|
|
5
|
+
"mappings": "AAGA,SAAS,OAAO,aAAa,iBAAiB;AAK9C,SAAS,eAAe,mBAAsC;AAC9D;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OAEM;AAEP,MAAM;AAAA,EACL;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,E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