@vmz/core 0.2.5 → 0.2.6
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/dist/browser/client-nav.d.ts +5 -55
- package/dist/browser/client-nav.js +5 -769
- package/dist/browser/diagnostics/precision-trace.d.ts +47 -0
- package/dist/browser/diagnostics/precision-trace.js +86 -0
- package/dist/browser/dom/attributes.d.ts +5 -0
- package/dist/browser/dom/attributes.js +102 -0
- package/dist/browser/dom/component.d.ts +11 -0
- package/dist/browser/dom/component.js +255 -0
- package/dist/browser/dom/direct-api.d.ts +66 -0
- package/dist/browser/dom/direct-api.js +446 -0
- package/dist/browser/dom/lifecycle.d.ts +9 -0
- package/dist/browser/dom/lifecycle.js +161 -0
- package/dist/browser/dom/registry.d.ts +5 -0
- package/dist/browser/dom/registry.js +16 -0
- package/dist/browser/dom-core.d.ts +51 -249
- package/dist/browser/dom-core.js +51 -2521
- package/dist/browser/navigation/client-navigation.d.ts +44 -0
- package/dist/browser/navigation/client-navigation.js +277 -0
- package/dist/browser/navigation/extract-html.d.ts +1 -0
- package/dist/browser/navigation/extract-html.js +5 -0
- package/dist/browser/navigation/layout-retain.d.ts +3 -0
- package/dist/browser/navigation/layout-retain.js +34 -0
- package/dist/browser/navigation/locale-transition.d.ts +24 -0
- package/dist/browser/navigation/locale-transition.js +323 -0
- package/dist/browser/navigation/scroll-focus.d.ts +14 -0
- package/dist/browser/navigation/scroll-focus.js +87 -0
- package/dist/browser/reactivity/patch-scheduler.d.ts +12 -0
- package/dist/browser/reactivity/patch-scheduler.js +720 -0
- package/dist/browser/reactivity/write-barrier.d.ts +16 -0
- package/dist/browser/reactivity/write-barrier.js +546 -0
- package/dist/browser/resume/adopt.d.ts +1 -0
- package/dist/browser/resume/adopt.js +168 -0
- package/dist/browser/resume/hydrate.d.ts +4 -0
- package/dist/browser/resume/hydrate.js +107 -0
- package/dist/browser/resume/resume.d.ts +3 -0
- package/dist/browser/resume/resume.js +102 -0
- package/dist/faces/dom.browser.d.ts +2 -1
- package/dist/faces/dom.browser.js +2 -1
- package/dist/host/{deployment-registry.d.ts → deployment/deployment-registry.d.ts} +1 -1
- package/dist/host/{deployment-registry.js → deployment/deployment-registry.js} +1 -1
- package/dist/host/list-client-components.d.ts +2 -2
- package/dist/host/list-client-components.js +4 -4
- package/dist/host/{render-host.d.ts → render/render-host.d.ts} +2 -2
- package/dist/host/{render-host.js → render/render-host.js} +1 -1
- package/dist/host/{route-layout-chain.js → render/route-layout-chain.js} +1 -1
- package/dist/host/serve/bootstrap.d.ts +1 -0
- package/dist/host/serve/bootstrap.js +25 -0
- package/dist/host/serve/constants.d.ts +6 -0
- package/dist/host/serve/constants.js +6 -0
- package/dist/host/serve/hmr-dev.d.ts +34 -0
- package/dist/host/serve/hmr-dev.js +294 -0
- package/dist/host/serve/http.d.ts +1 -0
- package/dist/host/serve/http.js +124 -0
- package/dist/host/serve/locale-theme.d.ts +19 -0
- package/dist/host/serve/locale-theme.js +169 -0
- package/dist/host/serve/page-catalog.d.ts +14 -0
- package/dist/host/serve/page-catalog.js +105 -0
- package/dist/host/serve/page-render.d.ts +17 -0
- package/dist/host/serve/page-render.js +419 -0
- package/dist/host/serve/paths.d.ts +3 -0
- package/dist/host/serve/paths.js +74 -0
- package/dist/host/serve/route-catalog.d.ts +6 -0
- package/dist/host/serve/route-catalog.js +108 -0
- package/dist/host/serve/state.d.ts +30 -0
- package/dist/host/serve/state.js +36 -0
- package/dist/host/serve-host.d.ts +0 -17
- package/dist/host/serve-host.mjs +4 -1420
- package/dist/ssr/document.d.ts +2 -0
- package/dist/ssr/document.js +71 -0
- package/dist/ssr/dom-ssr.d.ts +10 -47
- package/dist/ssr/dom-ssr.js +10 -1284
- package/dist/ssr/render.d.ts +2 -0
- package/dist/ssr/render.js +78 -0
- package/dist/ssr/serialize.d.ts +3 -0
- package/dist/ssr/serialize.js +678 -0
- package/package.json +11 -11
- /package/dist/host/{route-layout-chain.d.ts → render/route-layout-chain.d.ts} +0 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export declare function installClientNavigation(opts?: Record<string, any>): {
|
|
2
|
+
ok: boolean;
|
|
3
|
+
reason: string;
|
|
4
|
+
transitionTo?: undefined;
|
|
5
|
+
transitionLocale?: undefined;
|
|
6
|
+
dispose?: undefined;
|
|
7
|
+
} | {
|
|
8
|
+
ok: boolean;
|
|
9
|
+
transitionTo: (url: string | URL, { replace, fromPop, softFail }?: Record<string, unknown>) => Promise<{
|
|
10
|
+
ok: boolean;
|
|
11
|
+
reason: string;
|
|
12
|
+
href?: undefined;
|
|
13
|
+
chunkId?: undefined;
|
|
14
|
+
retainedLayout?: undefined;
|
|
15
|
+
scrollMode?: undefined;
|
|
16
|
+
focusTarget?: undefined;
|
|
17
|
+
localeId?: undefined;
|
|
18
|
+
} | {
|
|
19
|
+
ok: boolean;
|
|
20
|
+
href: string;
|
|
21
|
+
chunkId: any;
|
|
22
|
+
retainedLayout: boolean;
|
|
23
|
+
scrollMode: string;
|
|
24
|
+
focusTarget: string;
|
|
25
|
+
localeId: string;
|
|
26
|
+
reason?: undefined;
|
|
27
|
+
}>;
|
|
28
|
+
transitionLocale: (toLocale: string, opts?: Record<string, unknown>) => Promise<{
|
|
29
|
+
status: string;
|
|
30
|
+
fromLocale: string;
|
|
31
|
+
toLocale: string;
|
|
32
|
+
reason: string;
|
|
33
|
+
} | {
|
|
34
|
+
status: string;
|
|
35
|
+
fromLocale: string;
|
|
36
|
+
toLocale: string;
|
|
37
|
+
reason: unknown;
|
|
38
|
+
href: string;
|
|
39
|
+
retainedLocale: string;
|
|
40
|
+
generation: number;
|
|
41
|
+
}>;
|
|
42
|
+
dispose(): void;
|
|
43
|
+
reason?: undefined;
|
|
44
|
+
};
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
import { extractAppHtml } from './extract-html.js';
|
|
2
|
+
import { applyAppAttrs, canRetainLayouts, parseLayoutChain } from './layout-retain.js';
|
|
3
|
+
import { applyLocaleRealization, createLocaleTransition } from './locale-transition.js';
|
|
4
|
+
import { createScrollFocus } from './scroll-focus.js';
|
|
5
|
+
export function installClientNavigation(opts = {}) {
|
|
6
|
+
const doc = opts.document || (typeof document !== 'undefined' ? document : null);
|
|
7
|
+
const win = typeof window !== 'undefined' ? window : null;
|
|
8
|
+
const hist = opts.history || win?.history;
|
|
9
|
+
const loc = opts.location || win?.location;
|
|
10
|
+
const fetchImplDefault = opts.fetchImpl || (typeof fetch === 'function' ? fetch.bind(globalThis) : null);
|
|
11
|
+
let fetchImpl = fetchImplDefault;
|
|
12
|
+
if (!doc || !hist || !loc || !fetchImpl) {
|
|
13
|
+
return { ok: false, reason: 'missing document/history/fetch' };
|
|
14
|
+
}
|
|
15
|
+
if (win && !win.__vmzBootId) {
|
|
16
|
+
win.__vmzBootId = `boot-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
17
|
+
}
|
|
18
|
+
if (win)
|
|
19
|
+
win.__vmzClientNavInstalled = true;
|
|
20
|
+
try {
|
|
21
|
+
if (hist && 'scrollRestoration' in hist)
|
|
22
|
+
hist.scrollRestoration = 'manual';
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
/* ignore */
|
|
26
|
+
}
|
|
27
|
+
let inflight = null;
|
|
28
|
+
let navigating = false;
|
|
29
|
+
const { saveScroll, restoreScroll, restoreFocus } = createScrollFocus({
|
|
30
|
+
document: doc,
|
|
31
|
+
window: win,
|
|
32
|
+
location: loc,
|
|
33
|
+
});
|
|
34
|
+
function destroyInst(inst) {
|
|
35
|
+
if (!inst)
|
|
36
|
+
return;
|
|
37
|
+
if (typeof opts.destroy === 'function')
|
|
38
|
+
opts.destroy(inst);
|
|
39
|
+
else if (win?.vmzDestroy)
|
|
40
|
+
win.vmzDestroy(inst);
|
|
41
|
+
}
|
|
42
|
+
async function loadDomFallback() {
|
|
43
|
+
return import(/* @vite-ignore */ '/dom.browser.js');
|
|
44
|
+
}
|
|
45
|
+
async function transitionTo(url, { replace = false, fromPop = false, softFail = false } = {}) {
|
|
46
|
+
const target = new URL(url, loc.href);
|
|
47
|
+
if (target.origin !== loc.origin) {
|
|
48
|
+
loc.assign(target.href);
|
|
49
|
+
return { ok: false, reason: 'cross-origin' };
|
|
50
|
+
}
|
|
51
|
+
if (!fromPop)
|
|
52
|
+
saveScroll();
|
|
53
|
+
if (inflight)
|
|
54
|
+
inflight.abort();
|
|
55
|
+
inflight = new AbortController();
|
|
56
|
+
const signal = inflight.signal;
|
|
57
|
+
navigating = true;
|
|
58
|
+
try {
|
|
59
|
+
const res = await fetchImpl(target.pathname + target.search, {
|
|
60
|
+
method: 'GET',
|
|
61
|
+
headers: { accept: 'text/html', 'x-vmz-client-nav': '1' },
|
|
62
|
+
signal,
|
|
63
|
+
});
|
|
64
|
+
if (!res.ok) {
|
|
65
|
+
if (!fromPop && !softFail)
|
|
66
|
+
loc.assign(target.href);
|
|
67
|
+
return { ok: false, reason: `http ${res.status}` };
|
|
68
|
+
}
|
|
69
|
+
const html = await res.text();
|
|
70
|
+
const nextApp = extractAppHtml(html, doc);
|
|
71
|
+
if (!nextApp) {
|
|
72
|
+
if (!fromPop && !softFail)
|
|
73
|
+
loc.assign(target.href);
|
|
74
|
+
return { ok: false, reason: 'missing #app in response' };
|
|
75
|
+
}
|
|
76
|
+
const root = doc.getElementById('app');
|
|
77
|
+
if (!root) {
|
|
78
|
+
if (!fromPop && !softFail)
|
|
79
|
+
loc.assign(target.href);
|
|
80
|
+
return { ok: false, reason: 'missing #app' };
|
|
81
|
+
}
|
|
82
|
+
const prevLayout = parseLayoutChain(root.getAttribute('data-vmz-layout'));
|
|
83
|
+
const nextLayout = parseLayoutChain(nextApp.getAttribute('data-vmz-layout'));
|
|
84
|
+
const retainLayouts = canRetainLayouts(root, prevLayout, nextLayout);
|
|
85
|
+
const chunkId = nextApp.getAttribute('data-vmz-page') || '';
|
|
86
|
+
let props = {};
|
|
87
|
+
try {
|
|
88
|
+
const raw = nextApp.getAttribute('data-vmz-props');
|
|
89
|
+
if (raw)
|
|
90
|
+
props = JSON.parse(raw);
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
/* ignore */
|
|
94
|
+
}
|
|
95
|
+
if (!fromPop) {
|
|
96
|
+
if (replace)
|
|
97
|
+
hist.replaceState({ vmzClientNav: true }, '', target.href);
|
|
98
|
+
else
|
|
99
|
+
hist.pushState({ vmzClientNav: true }, '', target.href);
|
|
100
|
+
}
|
|
101
|
+
const importChunk = opts.importPage || (async (id) => (await import(/* @vite-ignore */ `/${id}.client.js`)).default);
|
|
102
|
+
let liveRoot = root;
|
|
103
|
+
let retainedLayout = false;
|
|
104
|
+
applyLocaleRealization(doc, nextApp);
|
|
105
|
+
if (retainLayouts) {
|
|
106
|
+
applyAppAttrs(root, nextApp);
|
|
107
|
+
if (chunkId) {
|
|
108
|
+
const Page = await importChunk(chunkId);
|
|
109
|
+
let hydrateRoutePage = opts.hydrateRoutePage;
|
|
110
|
+
if (typeof hydrateRoutePage !== 'function') {
|
|
111
|
+
const dom = await loadDomFallback();
|
|
112
|
+
hydrateRoutePage = dom.hydrateRoutePage;
|
|
113
|
+
}
|
|
114
|
+
if (typeof hydrateRoutePage === 'function') {
|
|
115
|
+
await hydrateRoutePage(Page, root, props);
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
let hydrate = opts.hydrate;
|
|
119
|
+
if (typeof hydrate !== 'function') {
|
|
120
|
+
const dom = await loadDomFallback();
|
|
121
|
+
hydrate = dom.hydrate;
|
|
122
|
+
}
|
|
123
|
+
const pageHost = root.__vmzPageHost || root;
|
|
124
|
+
if (pageHost.__vmzInst)
|
|
125
|
+
destroyInst(pageHost.__vmzInst);
|
|
126
|
+
await hydrate(Page, pageHost, props);
|
|
127
|
+
root.__vmzPageHost = pageHost;
|
|
128
|
+
if (!root.__vmzLayoutInsts?.length)
|
|
129
|
+
root.__vmzInst = pageHost.__vmzInst;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
retainedLayout = true;
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
const prev = root.__vmzInst;
|
|
136
|
+
destroyInst(prev);
|
|
137
|
+
root.__vmzInst = null;
|
|
138
|
+
root.__vmzPageHost = null;
|
|
139
|
+
root.__vmzLayoutInsts = null;
|
|
140
|
+
root.outerHTML = nextApp.outerHTML;
|
|
141
|
+
const fresh = doc.getElementById('app');
|
|
142
|
+
if (!fresh)
|
|
143
|
+
return { ok: false, reason: 'swap lost #app' };
|
|
144
|
+
liveRoot = fresh;
|
|
145
|
+
if (chunkId) {
|
|
146
|
+
const Page = await importChunk(chunkId);
|
|
147
|
+
const layoutCtors = [];
|
|
148
|
+
for (const id of nextLayout) {
|
|
149
|
+
layoutCtors.push(await importChunk(id));
|
|
150
|
+
}
|
|
151
|
+
let hydrateRoute = opts.hydrateRoute;
|
|
152
|
+
if (typeof hydrateRoute !== 'function') {
|
|
153
|
+
const dom = await loadDomFallback();
|
|
154
|
+
hydrateRoute = dom.hydrateRoute;
|
|
155
|
+
}
|
|
156
|
+
if (typeof hydrateRoute === 'function') {
|
|
157
|
+
await hydrateRoute(Page, fresh, props, layoutCtors);
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
let hydrate = opts.hydrate;
|
|
161
|
+
if (typeof hydrate !== 'function') {
|
|
162
|
+
const dom = await loadDomFallback();
|
|
163
|
+
hydrate = dom.hydrate;
|
|
164
|
+
}
|
|
165
|
+
await hydrate(Page, fresh, props);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
const localeId = applyLocaleRealization(doc, liveRoot);
|
|
170
|
+
const focusTarget = restoreFocus(liveRoot, target);
|
|
171
|
+
if (win) {
|
|
172
|
+
win.__vmzClientNavCount = (win.__vmzClientNavCount || 0) + 1;
|
|
173
|
+
win.__vmzLastClientNav = {
|
|
174
|
+
href: target.pathname + target.search,
|
|
175
|
+
routeId: liveRoot?.getAttribute?.('data-vmz-route') || nextApp.getAttribute?.('data-vmz-route') || null,
|
|
176
|
+
chunkId,
|
|
177
|
+
bootId: win.__vmzBootId,
|
|
178
|
+
retainedLayout,
|
|
179
|
+
focusTarget,
|
|
180
|
+
localeId,
|
|
181
|
+
scrollMode: 'pending',
|
|
182
|
+
scrollY: null,
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
if (win && typeof win.requestAnimationFrame === 'function') {
|
|
186
|
+
await new Promise((resolve) => {
|
|
187
|
+
win.requestAnimationFrame(() => win.requestAnimationFrame(() => resolve()));
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
const scroll = await restoreScroll(target, Boolean(fromPop));
|
|
191
|
+
if (win && win.__vmzLastClientNav) {
|
|
192
|
+
win.__vmzLastClientNav.scrollMode = scroll.mode;
|
|
193
|
+
win.__vmzLastClientNav.scrollY = scroll.y;
|
|
194
|
+
}
|
|
195
|
+
return {
|
|
196
|
+
ok: true,
|
|
197
|
+
href: target.pathname + target.search,
|
|
198
|
+
chunkId,
|
|
199
|
+
retainedLayout,
|
|
200
|
+
scrollMode: scroll.mode,
|
|
201
|
+
focusTarget,
|
|
202
|
+
localeId,
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
finally {
|
|
206
|
+
navigating = false;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
const { transitionLocale, localizeClickHref } = createLocaleTransition({
|
|
210
|
+
document: doc,
|
|
211
|
+
window: win,
|
|
212
|
+
location: loc,
|
|
213
|
+
transitionTo,
|
|
214
|
+
});
|
|
215
|
+
function onClick(ev) {
|
|
216
|
+
if (navigating)
|
|
217
|
+
return;
|
|
218
|
+
if (ev.defaultPrevented)
|
|
219
|
+
return;
|
|
220
|
+
if (ev.button !== 0)
|
|
221
|
+
return;
|
|
222
|
+
if (ev.metaKey || ev.ctrlKey || ev.shiftKey || ev.altKey)
|
|
223
|
+
return;
|
|
224
|
+
const a = ev.target?.closest?.('a[data-vmz-route][href]');
|
|
225
|
+
if (!a)
|
|
226
|
+
return;
|
|
227
|
+
const href = a.getAttribute('href');
|
|
228
|
+
if (!href || href.startsWith('#') || /^(mailto|tel|javascript):/i.test(href))
|
|
229
|
+
return;
|
|
230
|
+
const u = new URL(href, loc.href);
|
|
231
|
+
if (u.origin !== loc.origin)
|
|
232
|
+
return;
|
|
233
|
+
if (a.hasAttribute('download') || a.getAttribute('target') === '_blank')
|
|
234
|
+
return;
|
|
235
|
+
ev.preventDefault();
|
|
236
|
+
const realized = localizeClickHref(u.pathname + u.search + u.hash, a.getAttribute('data-vmz-route'));
|
|
237
|
+
void transitionTo(realized, {
|
|
238
|
+
replace: a.getAttribute('data-vmz-replace') === 'true',
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
function onPopState() {
|
|
242
|
+
void transitionTo(loc.pathname + loc.search + loc.hash, { fromPop: true });
|
|
243
|
+
}
|
|
244
|
+
if (win) {
|
|
245
|
+
win.__vmzTransitionLocale = transitionLocale;
|
|
246
|
+
win.__vmzClientNavSetFetch = (fn) => {
|
|
247
|
+
fetchImpl = typeof fn === 'function' ? fn : fetchImplDefault;
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
doc.addEventListener('click', onClick);
|
|
251
|
+
win?.addEventListener?.('popstate', onPopState);
|
|
252
|
+
return {
|
|
253
|
+
ok: true,
|
|
254
|
+
transitionTo,
|
|
255
|
+
transitionLocale,
|
|
256
|
+
dispose() {
|
|
257
|
+
doc.removeEventListener('click', onClick);
|
|
258
|
+
win?.removeEventListener?.('popstate', onPopState);
|
|
259
|
+
if (win && win.__vmzTransitionLocale === transitionLocale) {
|
|
260
|
+
try {
|
|
261
|
+
delete win.__vmzTransitionLocale;
|
|
262
|
+
}
|
|
263
|
+
catch {
|
|
264
|
+
win.__vmzTransitionLocale = undefined;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
if (win) {
|
|
268
|
+
try {
|
|
269
|
+
delete win.__vmzClientNavSetFetch;
|
|
270
|
+
}
|
|
271
|
+
catch {
|
|
272
|
+
win.__vmzClientNavSetFetch = undefined;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
},
|
|
276
|
+
};
|
|
277
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function extractAppHtml(html: any, doc: any): any;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export function parseLayoutChain(raw) {
|
|
2
|
+
return String(raw || '')
|
|
3
|
+
.split(',')
|
|
4
|
+
.map((s) => s.trim())
|
|
5
|
+
.filter(Boolean);
|
|
6
|
+
}
|
|
7
|
+
function layoutChainsEqual(a, b) {
|
|
8
|
+
if (a.length !== b.length)
|
|
9
|
+
return false;
|
|
10
|
+
for (let i = 0; i < a.length; i++) {
|
|
11
|
+
if (a[i] !== b[i])
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
export function canRetainLayouts(root, prevLayout, nextLayout) {
|
|
17
|
+
if (!layoutChainsEqual(prevLayout, nextLayout))
|
|
18
|
+
return false;
|
|
19
|
+
if (!root.__vmzPageHost)
|
|
20
|
+
return false;
|
|
21
|
+
if (nextLayout.length === 0)
|
|
22
|
+
return true;
|
|
23
|
+
const insts = root.__vmzLayoutInsts;
|
|
24
|
+
return Array.isArray(insts) && insts.length === nextLayout.length;
|
|
25
|
+
}
|
|
26
|
+
export function applyAppAttrs(root, nextApp) {
|
|
27
|
+
for (const name of ['data-vmz-page', 'data-vmz-props', 'data-vmz-layout', 'data-vmz-route', 'data-vmz-locale', 'data-vmz-dir']) {
|
|
28
|
+
const v = nextApp.getAttribute(name);
|
|
29
|
+
if (v == null)
|
|
30
|
+
root.removeAttribute(name);
|
|
31
|
+
else
|
|
32
|
+
root.setAttribute(name, v);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare function applyLocaleRealization(doc: Document, root: Element | null): string;
|
|
2
|
+
export type LocaleTransitionEnv = {
|
|
3
|
+
document: Document;
|
|
4
|
+
window: Window | null;
|
|
5
|
+
location: Location;
|
|
6
|
+
transitionTo: (url: string | URL, opts?: Record<string, unknown>) => Promise<Record<string, unknown>>;
|
|
7
|
+
};
|
|
8
|
+
export declare function createLocaleTransition({ document: doc, window: win, location: loc, transitionTo }: LocaleTransitionEnv): {
|
|
9
|
+
transitionLocale: (toLocale: string, opts?: Record<string, unknown>) => Promise<{
|
|
10
|
+
status: string;
|
|
11
|
+
fromLocale: string;
|
|
12
|
+
toLocale: string;
|
|
13
|
+
reason: string;
|
|
14
|
+
} | {
|
|
15
|
+
status: string;
|
|
16
|
+
fromLocale: string;
|
|
17
|
+
toLocale: string;
|
|
18
|
+
reason: unknown;
|
|
19
|
+
href: string;
|
|
20
|
+
retainedLocale: string;
|
|
21
|
+
generation: number;
|
|
22
|
+
}>;
|
|
23
|
+
localizeClickHref: (href: string, routeId: string | null) => string;
|
|
24
|
+
};
|