@spatial-elements/sveltekit 1.0.0-beta.7 → 1.0.0-beta.8
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/catalog/ScrollNavigationBridge.svelte +170 -45
- package/dist/catalog/ScrollNavigationBridge.svelte.d.ts +9 -2
- package/dist/catalog/catalogSummaryTransfer.d.ts +16 -0
- package/dist/catalog/catalogSummaryTransfer.js +79 -0
- package/dist/catalog/catalogTransition.css +46 -3
- package/dist/catalog/interruptedPresentation.d.ts +10 -0
- package/dist/catalog/interruptedPresentation.js +29 -0
- package/dist/catalog/presentationCleanup.d.ts +4 -0
- package/dist/catalog/presentationCleanup.js +20 -0
- package/dist/catalog/stagedCatalogNavigation.d.ts +44 -0
- package/dist/catalog/stagedCatalogNavigation.js +403 -0
- package/dist/catalog/stagedDomReveal.d.ts +8 -0
- package/dist/catalog/stagedDomReveal.js +76 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/spatial-element/BrandStageShell.svelte +13 -2
- package/dist/spatial-element/BrandStageShell.svelte.d.ts +8 -0
- package/dist/spatial-element/CarouselSection.svelte +35 -21
- package/dist/spatial-element/CarouselSpatialElement.svelte +49 -115
- package/dist/spatial-element/ContentBlock.svelte +53 -0
- package/dist/spatial-element/ContentBlock.svelte.d.ts +11 -0
- package/dist/spatial-element/ContentGrid.svelte +28 -0
- package/dist/spatial-element/ContentGrid.svelte.d.ts +10 -0
- package/dist/spatial-element/ContentPage.svelte +28 -20
- package/dist/spatial-element/ContentPage.svelte.d.ts +3 -0
- package/dist/spatial-element/ListSection.svelte +11 -5
- package/dist/spatial-element/ListSection.svelte.d.ts +5 -0
- package/dist/spatial-element/PointerHint.svelte +3 -1
- package/dist/spatial-element/Section.svelte +51 -40
- package/dist/spatial-element/Section.svelte.d.ts +1 -0
- package/dist/spatial-element/SectionSurfaceGroup.svelte +34 -0
- package/dist/spatial-element/SectionSurfaceGroup.svelte.d.ts +7 -0
- package/dist/spatial-element/SpatialCardPresentation.svelte +378 -0
- package/dist/spatial-element/SpatialCardPresentation.svelte.d.ts +13 -0
- package/dist/spatial-element/SpatialCardSlot.svelte +33 -0
- package/dist/spatial-element/SpatialCardSlot.svelte.d.ts +8 -0
- package/dist/spatial-element/SpatialElementBreadcrumbs.svelte +20 -12
- package/dist/spatial-element/SpatialElementBreadcrumbs.svelte.d.ts +1 -0
- package/dist/spatial-element/SpatialElementCard.svelte +19 -318
- package/dist/spatial-element/SpatialElementCard.svelte.d.ts +3 -0
- package/dist/spatial-element/SpatialElementHelp.svelte +21 -15
- package/dist/spatial-element/SpatialElementHelp.svelte.d.ts +4 -1
- package/dist/spatial-element/SpatialElementMediaRail.svelte +75 -21
- package/dist/spatial-element/SpatialElementMediaRail.svelte.d.ts +3 -0
- package/dist/spatial-element/SpatialElementNativeMedia.svelte +36 -0
- package/dist/spatial-element/SpatialElementNativeMedia.svelte.d.ts +9 -0
- package/dist/spatial-element/SpatialElementPage.svelte +127 -68
- package/dist/spatial-element/SpatialElementPage.svelte.d.ts +1 -0
- package/dist/spatial-element/SpatialElementStickyHeader.svelte +36 -69
- package/dist/spatial-element/SpatialElementStickyHeader.svelte.d.ts +1 -0
- package/dist/spatial-element/SpatialElementSummaryContent.svelte +14 -11
- package/dist/spatial-element/SpatialElementSummaryPanel.svelte +29 -20
- package/dist/spatial-element/SpatialElementSummaryPanel.svelte.d.ts +1 -0
- package/dist/spatial-element/SpatialElementTabList.svelte +19 -3
- package/dist/spatial-element/SpatialElementTabs.svelte +56 -16
- package/dist/spatial-element/SpatialElementTabs.svelte.d.ts +1 -0
- package/dist/spatial-element/SpatialElementViewToggle.svelte +5 -4
- package/dist/spatial-element/SpatialIconButton.svelte +4 -2
- package/dist/spatial-element/SpatialNavigationShell.svelte +129 -0
- package/dist/spatial-element/SpatialNavigationShell.svelte.d.ts +10 -0
- package/dist/spatial-element/SpatialSummaryHost.svelte +19 -0
- package/dist/spatial-element/SpatialSummaryHost.svelte.d.ts +9 -0
- package/dist/spatial-element/SpatialSummaryRoot.svelte +78 -0
- package/dist/spatial-element/SpatialSummaryRoot.svelte.d.ts +8 -0
- package/dist/spatial-element/SpatialSummarySlot.svelte +39 -0
- package/dist/spatial-element/SpatialSummarySlot.svelte.d.ts +9 -0
- package/dist/spatial-element/SpatialViewIcon.svelte +29 -0
- package/dist/spatial-element/SpatialViewIcon.svelte.d.ts +6 -0
- package/dist/spatial-element/cardAppearanceFreeze.d.ts +5 -0
- package/dist/spatial-element/cardAppearanceFreeze.js +72 -0
- package/dist/spatial-element/index.d.ts +6 -2
- package/dist/spatial-element/index.js +3 -1
- package/dist/spatial-element/layout.generated.css +455 -0
- package/dist/spatial-element/presentationBoxFreeze.d.ts +8 -0
- package/dist/spatial-element/presentationBoxFreeze.js +35 -0
- package/dist/spatial-element/spatialPresentationOwner.d.ts +6 -0
- package/dist/spatial-element/spatialPresentationOwner.js +2 -0
- package/dist/spatial-element/spatialSummary.d.ts +37 -0
- package/dist/spatial-element/spatialSummary.js +1 -0
- package/dist/spatial-element/spatialSummaryHost.svelte.d.ts +60 -0
- package/dist/spatial-element/spatialSummaryHost.svelte.js +233 -0
- package/dist/spatial-element/spatialThemeStyle.js +10 -4
- package/dist/stage/ButtonGroup.svelte +1 -1
- package/dist/stage/Panel.svelte +16 -4
- package/dist/stage/Stage.svelte +180 -26
- package/package.json +2 -2
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { readCatalogViewContext } from '@spatial-elements/core/catalog/catalogViewLink';
|
|
2
|
+
import { readCatalogLinkContext, readCatalogViewContext } from '@spatial-elements/core/catalog/catalogViewLink';
|
|
3
|
+
import {
|
|
4
|
+
EarlyNavigationCoordinator,
|
|
5
|
+
type EarlyNavigationCancelReason,
|
|
6
|
+
type EarlyNavigationHandle
|
|
7
|
+
} from '@spatial-elements/core/catalog/EarlyNavigationCoordinator';
|
|
3
8
|
import {
|
|
4
9
|
afterNavigate,
|
|
5
10
|
beforeNavigate,
|
|
6
11
|
disableScrollHandling,
|
|
12
|
+
goto,
|
|
7
13
|
onNavigate,
|
|
14
|
+
preloadData,
|
|
8
15
|
pushState,
|
|
9
16
|
replaceState
|
|
10
17
|
} from '$app/navigation';
|
|
11
18
|
import { navigating, page } from '$app/state';
|
|
12
|
-
import type { OnNavigate } from '@sveltejs/kit';
|
|
13
|
-
import { getContext, onDestroy, tick } from 'svelte';
|
|
19
|
+
import type { BeforeNavigate, OnNavigate } from '@sveltejs/kit';
|
|
20
|
+
import { getContext, onDestroy, onMount, tick } from 'svelte';
|
|
14
21
|
import { CATALOG_ENDPOINTS, type CatalogEndpointRegistry } from '@spatial-elements/core/catalog/CatalogEndpointRegistry';
|
|
15
22
|
import {
|
|
16
23
|
CATALOG_SECTIONS,
|
|
@@ -23,6 +30,7 @@
|
|
|
23
30
|
} from '@spatial-elements/core/stage/VirtualScrollController';
|
|
24
31
|
import { subscribeStageScrollFrame, syncStageScrollToNative } from '@spatial-elements/core/stage/scrollFrame';
|
|
25
32
|
import { resolveCatalogIntent } from '@spatial-elements/core/catalog/catalogRecipes';
|
|
33
|
+
import { catalogTransitionViewportChanged, readCatalogTransitionViewport } from '@spatial-elements/core/catalog/catalogTransitionViewport';
|
|
26
34
|
|
|
27
35
|
interface EntryState {
|
|
28
36
|
id: string;
|
|
@@ -31,14 +39,20 @@
|
|
|
31
39
|
|
|
32
40
|
interface Props {
|
|
33
41
|
controller?: VirtualScrollController;
|
|
34
|
-
|
|
42
|
+
onStart?: () => void;
|
|
43
|
+
/** Starts only a source-only transition whose destination is already known. */
|
|
44
|
+
onEarlyStart?: (navigation: BeforeNavigate) => EarlyNavigationHandle | undefined;
|
|
45
|
+
/** Must retain the outgoing presentation before returning; never hold Kit's commit. */
|
|
46
|
+
onCapture?: (navigation: OnNavigate) => undefined;
|
|
35
47
|
onInterrupt?: () => void;
|
|
48
|
+
/** Cancel only a still-owned visual handoff after route commit; retain destination binding. */
|
|
49
|
+
onInterruptCommitted?: (reason: EarlyNavigationCancelReason) => boolean;
|
|
36
50
|
onSupersede?: (destination: URL) => void;
|
|
37
51
|
onRestored?: (navigation: OnNavigate) => void | Promise<void>;
|
|
38
52
|
handlesNavigation?: (navigation: OnNavigate) => boolean;
|
|
39
53
|
}
|
|
40
54
|
|
|
41
|
-
let { controller, onCapture, onInterrupt, onSupersede, onRestored, handlesNavigation }: Props =
|
|
55
|
+
let { controller, onStart, onEarlyStart, onCapture, onInterrupt, onInterruptCommitted, onSupersede, onRestored, handlesNavigation }: Props =
|
|
42
56
|
$props();
|
|
43
57
|
const endpoints = getContext<CatalogEndpointRegistry | undefined>(CATALOG_ENDPOINTS);
|
|
44
58
|
const sections = getContext<CatalogSections | undefined>(CATALOG_SECTIONS);
|
|
@@ -51,10 +65,44 @@
|
|
|
51
65
|
}
|
|
52
66
|
});
|
|
53
67
|
onDestroy(() => disconnectSections?.());
|
|
54
|
-
const PREPARATION_LIMIT_MS = 500;
|
|
55
68
|
let generation = 0;
|
|
56
69
|
let pendingNavigation = false;
|
|
57
70
|
let focusRevision = 0;
|
|
71
|
+
let earlyReplayComplete: Promise<void> | undefined;
|
|
72
|
+
// Kit invokes beforeNavigate after the click dispatch has finished. The DOM
|
|
73
|
+
// event's composedPath is empty by then, so remember its original anchor now.
|
|
74
|
+
const earlyAnchors = new WeakMap<Event, HTMLAnchorElement>();
|
|
75
|
+
const earlyNavigation = new EarlyNavigationCoordinator({
|
|
76
|
+
preload: async (destination, signal) => {
|
|
77
|
+
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
78
|
+
let abort: (() => void) | undefined;
|
|
79
|
+
try {
|
|
80
|
+
return await Promise.race([
|
|
81
|
+
preloadData(destination),
|
|
82
|
+
new Promise<never>((_resolve, reject) => {
|
|
83
|
+
abort = () => reject(new Error('Early navigation interrupted'));
|
|
84
|
+
if (signal.aborted) abort();
|
|
85
|
+
else signal.addEventListener('abort', abort, { once: true });
|
|
86
|
+
timer = setTimeout(() => reject(new Error('Early navigation preload deadline')), 15_000);
|
|
87
|
+
})
|
|
88
|
+
]);
|
|
89
|
+
} finally {
|
|
90
|
+
if (timer !== undefined) clearTimeout(timer);
|
|
91
|
+
if (abort) signal.removeEventListener('abort', abort);
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
// The absolute destination already includes Kit's configured base path.
|
|
95
|
+
// eslint-disable-next-line svelte/no-navigation-without-resolve
|
|
96
|
+
navigate: async (destination) => {
|
|
97
|
+
const url = new URL(destination);
|
|
98
|
+
if (url.origin !== location.origin && (url.protocol === 'https:' || url.protocol === 'http:')) {
|
|
99
|
+
location.assign(url.href);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
// eslint-disable-next-line svelte/no-navigation-without-resolve
|
|
103
|
+
await goto(destination);
|
|
104
|
+
}
|
|
105
|
+
});
|
|
58
106
|
// This imperative history cache must not subscribe effects to per-frame position writes.
|
|
59
107
|
// eslint-disable-next-line svelte/prefer-svelte-reactivity
|
|
60
108
|
const entryPositions = new Map<string, { x: number; y: number }>();
|
|
@@ -63,7 +111,8 @@
|
|
|
63
111
|
controller: VirtualScrollController;
|
|
64
112
|
token: object;
|
|
65
113
|
complete?: Promise<void>;
|
|
66
|
-
|
|
114
|
+
committed: boolean;
|
|
115
|
+
interrupted: boolean;
|
|
67
116
|
}
|
|
68
117
|
| undefined;
|
|
69
118
|
let initial = $state<{ target: ScrollRestoreTarget; url: string }>();
|
|
@@ -92,11 +141,12 @@
|
|
|
92
141
|
if (entryPositions.size > 100) entryPositions.delete(entryPositions.keys().next().value!);
|
|
93
142
|
}
|
|
94
143
|
|
|
95
|
-
function stopActive(destination?: URL) {
|
|
144
|
+
function stopActive(destination?: URL, reason: EarlyNavigationCancelReason = 'superseded') {
|
|
96
145
|
generation += 1;
|
|
146
|
+
earlyNavigation.cancel(reason);
|
|
147
|
+
earlyReplayComplete = undefined;
|
|
97
148
|
if (active) {
|
|
98
149
|
active.controller.endNavigation(active.token);
|
|
99
|
-
active.releasePreparation?.();
|
|
100
150
|
}
|
|
101
151
|
active = undefined;
|
|
102
152
|
pendingNavigation = false;
|
|
@@ -109,6 +159,38 @@
|
|
|
109
159
|
} else interruptVisuals();
|
|
110
160
|
}
|
|
111
161
|
|
|
162
|
+
function supportsEarlyStart(navigation: BeforeNavigate): boolean {
|
|
163
|
+
if (!onEarlyStart || navigation.type !== 'link' || navigation.willUnload ||
|
|
164
|
+
!navigation.from || !navigation.to?.route.id ||
|
|
165
|
+
navigation.to.url.origin !== navigation.from.url.origin ||
|
|
166
|
+
navigation.to.url.pathname === navigation.from.url.pathname) return false;
|
|
167
|
+
// Kit's BeforeNavigate does not expose the resolved link options. Keep
|
|
168
|
+
// explicitly authored focus/scroll/history policies on the ordinary path.
|
|
169
|
+
const anchor = earlyAnchors.get(navigation.event);
|
|
170
|
+
// An author can declare a complete Dock endpoint. Arbitrary hashes still
|
|
171
|
+
// need destination DOM, including short pages where native scrolling clamps.
|
|
172
|
+
if (navigation.to.url.hash && navigation.to.url.hash !== '#overview' &&
|
|
173
|
+
readCatalogLinkContext(anchor, navigation.to.url).targetPresentation !== 'dock') return false;
|
|
174
|
+
return anchor instanceof HTMLAnchorElement && !anchor.closest(
|
|
175
|
+
'[data-sveltekit-keepfocus], [data-sveltekit-noscroll], [data-sveltekit-replacestate], [data-sveltekit-reload]'
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function interruptInput(reason: EarlyNavigationCancelReason) {
|
|
180
|
+
const binding = active;
|
|
181
|
+
if (binding?.committed) {
|
|
182
|
+
// goto may already be complete while its real source is still held for
|
|
183
|
+
// destination binding/reveal. Do not invalidate that binding generation:
|
|
184
|
+
// there is no successor navigation which could finish the current page.
|
|
185
|
+
if (binding.interrupted || !onInterruptCommitted?.(reason)) return;
|
|
186
|
+
binding.interrupted = true;
|
|
187
|
+
focusRevision += 1;
|
|
188
|
+
binding.controller.endNavigation(binding.token);
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
if (earlyNavigation.pending) stopActive(undefined, reason);
|
|
192
|
+
}
|
|
193
|
+
|
|
112
194
|
function interruptVisuals() {
|
|
113
195
|
try {
|
|
114
196
|
onInterrupt?.();
|
|
@@ -188,9 +270,34 @@
|
|
|
188
270
|
}
|
|
189
271
|
|
|
190
272
|
beforeNavigate((navigation) => {
|
|
273
|
+
// The single permitted replay continues the existing visual ownership.
|
|
274
|
+
// It must not run stopActive, onSupersede, or the generic feedback again.
|
|
275
|
+
if (navigation.to && earlyNavigation.acceptReplay(navigation.to.url.href)) {
|
|
276
|
+
earlyReplayComplete = navigation.complete;
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
191
279
|
if (!pendingNavigation) rememberPosition();
|
|
192
|
-
stopActive(navigation.to?.url);
|
|
280
|
+
stopActive(navigation.to?.url, navigation.type === 'popstate' ? 'history' : navigation.willUnload ? 'leave' : 'superseded');
|
|
193
281
|
pendingNavigation = true;
|
|
282
|
+
if (supportsEarlyStart(navigation)) {
|
|
283
|
+
let handle: EarlyNavigationHandle | undefined;
|
|
284
|
+
try { handle = onEarlyStart?.(navigation); }
|
|
285
|
+
catch { interruptVisuals(); }
|
|
286
|
+
if (handle) {
|
|
287
|
+
navigation.cancel();
|
|
288
|
+
// Rejecting the original navigation is intentional. Its completion
|
|
289
|
+
// must never cancel the independently owned source movement.
|
|
290
|
+
void navigation.complete.catch(() => {});
|
|
291
|
+
const epoch = generation;
|
|
292
|
+
void earlyNavigation.start(navigation.to!.url.href, handle).finally(() => {
|
|
293
|
+
if (epoch === generation && !active) pendingNavigation = false;
|
|
294
|
+
});
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
if (controller?.active && !navigation.willUnload && navigation.to && navigation.from &&
|
|
299
|
+
navigation.from.url.pathname !== navigation.to.url.pathname &&
|
|
300
|
+
navigation.from.url.pathname.split('/')[1] === navigation.to.url.pathname.split('/')[1]) onStart?.();
|
|
194
301
|
const epoch = generation;
|
|
195
302
|
void navigation.complete
|
|
196
303
|
.catch(() => {})
|
|
@@ -201,15 +308,49 @@
|
|
|
201
308
|
}
|
|
202
309
|
});
|
|
203
310
|
});
|
|
204
|
-
onDestroy(() => stopActive());
|
|
311
|
+
onDestroy(() => stopActive(undefined, 'destroyed'));
|
|
312
|
+
onMount(() => {
|
|
313
|
+
const rememberAnchor = (event: MouseEvent) => {
|
|
314
|
+
const anchor = event.composedPath().find((node) => node instanceof HTMLAnchorElement);
|
|
315
|
+
if (anchor instanceof HTMLAnchorElement) earlyAnchors.set(event, anchor);
|
|
316
|
+
};
|
|
317
|
+
const interrupt = () => interruptInput('interaction');
|
|
318
|
+
const keydown = (event: KeyboardEvent) => { if (event.key === 'Escape') interrupt(); };
|
|
319
|
+
let viewport = readCatalogTransitionViewport();
|
|
320
|
+
const resize = () => {
|
|
321
|
+
const current = readCatalogTransitionViewport();
|
|
322
|
+
const changed = catalogTransitionViewportChanged(viewport, current);
|
|
323
|
+
viewport = current;
|
|
324
|
+
if (changed) interruptInput('resize');
|
|
325
|
+
};
|
|
326
|
+
window.addEventListener('keydown', keydown);
|
|
327
|
+
window.addEventListener('wheel', interrupt, { passive: true });
|
|
328
|
+
window.addEventListener('touchmove', interrupt, { passive: true });
|
|
329
|
+
window.addEventListener('resize', resize);
|
|
330
|
+
document.addEventListener('click', rememberAnchor, true);
|
|
331
|
+
return () => {
|
|
332
|
+
window.removeEventListener('keydown', keydown);
|
|
333
|
+
window.removeEventListener('wheel', interrupt);
|
|
334
|
+
window.removeEventListener('touchmove', interrupt);
|
|
335
|
+
window.removeEventListener('resize', resize);
|
|
336
|
+
document.removeEventListener('click', rememberAnchor, true);
|
|
337
|
+
};
|
|
338
|
+
});
|
|
205
339
|
|
|
206
340
|
$effect(() => {
|
|
207
341
|
const complete = navigating.complete;
|
|
342
|
+
if (complete && earlyReplayComplete && complete !== earlyReplayComplete && earlyNavigation.pending) {
|
|
343
|
+
stopActive(navigating.to?.url);
|
|
344
|
+
pendingNavigation = true;
|
|
345
|
+
}
|
|
208
346
|
// Kit skips beforeNavigate while another navigation is already in progress.
|
|
209
347
|
// The public completion identity still changes when that operation is superseded.
|
|
210
348
|
if (!complete || !active?.complete || complete === active.complete) return;
|
|
211
349
|
stopActive(navigating.to?.url);
|
|
212
350
|
pendingNavigation = true;
|
|
351
|
+
if (controller?.active && navigating.to && navigating.from &&
|
|
352
|
+
navigating.from.url.pathname !== navigating.to.url.pathname &&
|
|
353
|
+
navigating.from.url.pathname.split('/')[1] === navigating.to.url.pathname.split('/')[1]) onStart?.();
|
|
213
354
|
const epoch = generation;
|
|
214
355
|
void complete
|
|
215
356
|
.catch(() => {})
|
|
@@ -218,7 +359,7 @@
|
|
|
218
359
|
});
|
|
219
360
|
});
|
|
220
361
|
|
|
221
|
-
onNavigate(
|
|
362
|
+
onNavigate((navigation) => {
|
|
222
363
|
const destination = navigation.to;
|
|
223
364
|
if (!destination) return;
|
|
224
365
|
const owner = controller;
|
|
@@ -235,49 +376,33 @@
|
|
|
235
376
|
const token = {};
|
|
236
377
|
const epoch = ++generation;
|
|
237
378
|
owner.beginNavigation(token);
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
}
|
|
242
|
-
active =
|
|
243
|
-
let preparationTimer: ReturnType<typeof setTimeout> | undefined;
|
|
379
|
+
const binding: NonNullable<typeof active> = {
|
|
380
|
+
controller: owner, token, complete: navigation.complete,
|
|
381
|
+
committed: false, interrupted: false
|
|
382
|
+
};
|
|
383
|
+
active = binding;
|
|
244
384
|
try {
|
|
245
|
-
|
|
246
|
-
if (preparation) {
|
|
247
|
-
const prepared = await Promise.race([
|
|
248
|
-
Promise.resolve(preparation).then(() => true),
|
|
249
|
-
interrupted,
|
|
250
|
-
new Promise<boolean>((resolve) => {
|
|
251
|
-
preparationTimer = setTimeout(() => resolve(false), PREPARATION_LIMIT_MS);
|
|
252
|
-
})
|
|
253
|
-
]);
|
|
254
|
-
if (!prepared) {
|
|
255
|
-
if (epoch !== generation) return;
|
|
256
|
-
interruptVisuals();
|
|
257
|
-
}
|
|
258
|
-
}
|
|
385
|
+
onCapture?.(navigation);
|
|
259
386
|
} catch {
|
|
260
387
|
if (epoch !== generation) return;
|
|
261
388
|
interruptVisuals();
|
|
262
|
-
} finally {
|
|
263
|
-
if (preparationTimer !== undefined) clearTimeout(preparationTimer);
|
|
264
|
-
if (active?.token === token) active.releasePreparation = undefined;
|
|
265
389
|
}
|
|
266
390
|
if (epoch !== generation || !owner.active) return;
|
|
267
|
-
//
|
|
268
|
-
// restores the committed page
|
|
391
|
+
// Source ownership is secured in this call stack. Return no promise to Kit:
|
|
392
|
+
// a visual failure still restores the committed page through the same owner.
|
|
269
393
|
disableScrollHandling();
|
|
270
394
|
|
|
271
395
|
// Do not return this promise: SvelteKit must commit before it can complete.
|
|
272
396
|
void navigation.complete
|
|
273
397
|
.then(async () => {
|
|
398
|
+
binding.committed = true;
|
|
274
399
|
await tick();
|
|
275
400
|
// Kit queues fragment focus/history work after committing the page. Its
|
|
276
401
|
// scroll correction must finish before our sole destination restoration.
|
|
277
402
|
// A microtask/tick alone runs before that queued task (Kit 2.69.2).
|
|
278
403
|
if (destination.url.hash) await new Promise<void>((resolve) => setTimeout(resolve, 0));
|
|
279
404
|
if (epoch !== generation || !owner.active) return;
|
|
280
|
-
sections?.restore();
|
|
405
|
+
if (!binding.interrupted) sections?.restore();
|
|
281
406
|
let requestedSection = viewContext.targetSection;
|
|
282
407
|
if (destination.url.hash) {
|
|
283
408
|
try {
|
|
@@ -286,7 +411,7 @@
|
|
|
286
411
|
requestedSection = undefined;
|
|
287
412
|
}
|
|
288
413
|
}
|
|
289
|
-
if (navigation.type !== 'popstate' && requestedSection && viewContext.spatialElementId)
|
|
414
|
+
if (!binding.interrupted && navigation.type !== 'popstate' && requestedSection && viewContext.spatialElementId)
|
|
290
415
|
sections?.selectForView(requestedSection, viewContext.spatialElementId);
|
|
291
416
|
await tick();
|
|
292
417
|
if (epoch !== generation || !owner.active) return;
|
|
@@ -295,15 +420,15 @@
|
|
|
295
420
|
// Our bounded cache belongs to public page.state entry IDs, never URLs.
|
|
296
421
|
const saved =
|
|
297
422
|
navigation.type === 'popstate' ? entryPositions.get(entryState()?.id ?? '') : undefined;
|
|
298
|
-
const restored = owner.restoreTarget(saved ?? target, token);
|
|
299
|
-
if (!restored) syncStageScrollToNative();
|
|
423
|
+
const restored = binding.interrupted ? undefined : owner.restoreTarget(saved ?? target, token);
|
|
424
|
+
if (!restored && !binding.interrupted) syncStageScrollToNative();
|
|
300
425
|
ensureEntry();
|
|
301
426
|
const revision = focusRevision;
|
|
302
|
-
endpoints?.restoreFocus(entryState()?.focus);
|
|
427
|
+
if (!binding.interrupted) endpoints?.restoreFocus(entryState()?.focus);
|
|
303
428
|
const origin = sections?.getOrigin();
|
|
304
|
-
endpoints?.restoreOrigin(origin);
|
|
429
|
+
if (!binding.interrupted) endpoints?.restoreOrigin(origin);
|
|
305
430
|
await onRestored?.(navigation);
|
|
306
|
-
if (restored && epoch === generation && owner.active && revision === focusRevision) {
|
|
431
|
+
if (!binding.interrupted && restored && epoch === generation && owner.active && revision === focusRevision) {
|
|
307
432
|
focusDestination(navigation);
|
|
308
433
|
}
|
|
309
434
|
})
|
|
@@ -377,7 +502,7 @@
|
|
|
377
502
|
const token = {};
|
|
378
503
|
const epoch = generation;
|
|
379
504
|
owner.beginNavigation(token);
|
|
380
|
-
active = { controller: owner, token };
|
|
505
|
+
active = { controller: owner, token, committed: true, interrupted: false };
|
|
381
506
|
void tick()
|
|
382
507
|
.then(() => {
|
|
383
508
|
if (epoch !== generation || !owner.active || location.href !== start.url) return;
|
|
@@ -1,9 +1,16 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type EarlyNavigationCancelReason, type EarlyNavigationHandle } from '@spatial-elements/core/catalog/EarlyNavigationCoordinator';
|
|
2
|
+
import type { BeforeNavigate, OnNavigate } from '@sveltejs/kit';
|
|
2
3
|
import type { VirtualScrollController } from '@spatial-elements/core/stage/VirtualScrollController';
|
|
3
4
|
interface Props {
|
|
4
5
|
controller?: VirtualScrollController;
|
|
5
|
-
|
|
6
|
+
onStart?: () => void;
|
|
7
|
+
/** Starts only a source-only transition whose destination is already known. */
|
|
8
|
+
onEarlyStart?: (navigation: BeforeNavigate) => EarlyNavigationHandle | undefined;
|
|
9
|
+
/** Must retain the outgoing presentation before returning; never hold Kit's commit. */
|
|
10
|
+
onCapture?: (navigation: OnNavigate) => undefined;
|
|
6
11
|
onInterrupt?: () => void;
|
|
12
|
+
/** Cancel only a still-owned visual handoff after route commit; retain destination binding. */
|
|
13
|
+
onInterruptCommitted?: (reason: EarlyNavigationCancelReason) => boolean;
|
|
7
14
|
onSupersede?: (destination: URL) => void;
|
|
8
15
|
onRestored?: (navigation: OnNavigate) => void | Promise<void>;
|
|
9
16
|
handlesNavigation?: (navigation: OnNavigate) => boolean;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { CatalogEndpointRegistry } from '@spatial-elements/core/catalog/CatalogEndpointRegistry';
|
|
2
|
+
import type { SpatialSummaryHostController } from '../spatial-element/spatialSummaryHost.svelte.js';
|
|
3
|
+
/** Semantic ownership must survive routing even if motion is declined or interrupted. */
|
|
4
|
+
export declare function prepareCatalogSummaryTransfer(options: {
|
|
5
|
+
from: URL;
|
|
6
|
+
to: URL;
|
|
7
|
+
type: string;
|
|
8
|
+
endpoints: CatalogEndpointRegistry;
|
|
9
|
+
host: SpatialSummaryHostController;
|
|
10
|
+
}): {
|
|
11
|
+
/** Call after decorative snapshots have captured the still-mounted source. */
|
|
12
|
+
hold(): void;
|
|
13
|
+
/** Call after route placement, before the destination's panel/GPU measurement. */
|
|
14
|
+
adopt(): HTMLElement | undefined;
|
|
15
|
+
cancel(): void;
|
|
16
|
+
} | undefined;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { resolveCatalogIntent } from '@spatial-elements/core/catalog/catalogRecipes';
|
|
2
|
+
/** Semantic ownership must survive routing even if motion is declined or interrupted. */
|
|
3
|
+
export function prepareCatalogSummaryTransfer(options) {
|
|
4
|
+
const { endpoints, host } = options;
|
|
5
|
+
const intent = resolveCatalogIntent(options.from, options.to, options.type);
|
|
6
|
+
if (!intent)
|
|
7
|
+
return;
|
|
8
|
+
const returning = intent.direction === 'detail-to-list';
|
|
9
|
+
const contentSlot = returning
|
|
10
|
+
? endpoints.getPreferredContentSlot(intent.identity)
|
|
11
|
+
: endpoints.getContentSlot(intent.identity);
|
|
12
|
+
if (contentSlot !== 'carousel.front')
|
|
13
|
+
return;
|
|
14
|
+
const sourceSlot = returning ? 'detail.summary' : 'carousel.front';
|
|
15
|
+
const targetSlot = returning ? 'carousel.front' : 'detail.summary';
|
|
16
|
+
const surface = endpoints.resolve({ ...intent.identity, slot: sourceSlot, role: 'summary-surface' });
|
|
17
|
+
const retained = surface && host.retainByElement(surface);
|
|
18
|
+
if (!retained || retained.record.kind !== 'summary') {
|
|
19
|
+
retained?.restore() || retained?.release();
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const root = retained.record.root;
|
|
23
|
+
// Legacy transition snapshots hide source roles. The same nodes become the
|
|
24
|
+
// destination, so those temporary source visibility changes cannot travel.
|
|
25
|
+
const visibility = [root, ...root.querySelectorAll('*')].map(element => ({
|
|
26
|
+
element, value: element.style.getPropertyValue('visibility'), priority: element.style.getPropertyPriority('visibility')
|
|
27
|
+
}));
|
|
28
|
+
let holding;
|
|
29
|
+
let finished = false;
|
|
30
|
+
const clean = (restore) => {
|
|
31
|
+
if (finished)
|
|
32
|
+
return;
|
|
33
|
+
finished = true;
|
|
34
|
+
try {
|
|
35
|
+
if (!restore || !retained.restore())
|
|
36
|
+
retained.release();
|
|
37
|
+
}
|
|
38
|
+
finally {
|
|
39
|
+
holding?.remove();
|
|
40
|
+
holding = undefined;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
return {
|
|
44
|
+
/** Call after decorative snapshots have captured the still-mounted source. */
|
|
45
|
+
hold() {
|
|
46
|
+
if (finished || holding)
|
|
47
|
+
return;
|
|
48
|
+
holding = document.createElement('div');
|
|
49
|
+
holding.hidden = true;
|
|
50
|
+
holding.inert = true;
|
|
51
|
+
holding.dataset.spatialSummaryTransfer = '';
|
|
52
|
+
document.body.append(holding);
|
|
53
|
+
retained.hold(holding);
|
|
54
|
+
for (const { element, value, priority } of visibility) {
|
|
55
|
+
if (value)
|
|
56
|
+
element.style.setProperty('visibility', value, priority);
|
|
57
|
+
else
|
|
58
|
+
element.style.removeProperty('visibility');
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
/** Call after route placement, before the destination's panel/GPU measurement. */
|
|
62
|
+
adopt() {
|
|
63
|
+
if (finished)
|
|
64
|
+
return;
|
|
65
|
+
try {
|
|
66
|
+
const destination = endpoints.resolve({ ...intent.identity, slot: targetSlot, role: 'summary-surface' });
|
|
67
|
+
const slot = destination?.querySelector('[data-spatial-summary-slot]');
|
|
68
|
+
if (!slot || !retained.adopt(slot))
|
|
69
|
+
return;
|
|
70
|
+
retained.unfreeze();
|
|
71
|
+
return slot;
|
|
72
|
+
}
|
|
73
|
+
finally {
|
|
74
|
+
clean(true);
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
cancel() { clean(true); }
|
|
78
|
+
};
|
|
79
|
+
}
|
|
@@ -1,4 +1,30 @@
|
|
|
1
1
|
/* Loaded by the persistent stage before any destination page can mount. */
|
|
2
|
+
/* No initial-value: outside a staged reveal the guaranteed-invalid value keeps
|
|
3
|
+
the existing transition formula as the var() fallback. Do not inherit this
|
|
4
|
+
channel through text/content subtrees or another custom-property alias. */
|
|
5
|
+
@property --catalog-reveal-opacity {
|
|
6
|
+
syntax: '*';
|
|
7
|
+
inherits: false;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.stage-navigation-feedback {
|
|
11
|
+
position: fixed;
|
|
12
|
+
inset: 0 0 auto;
|
|
13
|
+
height: 3px;
|
|
14
|
+
z-index: 2147483647;
|
|
15
|
+
pointer-events: none;
|
|
16
|
+
background: var(--spatial-element-accent, #6688cc);
|
|
17
|
+
transform: scaleX(0.18);
|
|
18
|
+
transform-origin: left;
|
|
19
|
+
animation: stage-navigation-progress 6s cubic-bezier(0.12, 0.7, 0.1, 1) forwards;
|
|
20
|
+
}
|
|
21
|
+
@keyframes stage-navigation-progress {
|
|
22
|
+
to { transform: scaleX(0.9); }
|
|
23
|
+
}
|
|
24
|
+
@media (prefers-reduced-motion: reduce) {
|
|
25
|
+
.stage-navigation-feedback { animation: none; transform: none; }
|
|
26
|
+
}
|
|
27
|
+
|
|
2
28
|
.stage [data-catalog-transition-group='enter'] {
|
|
3
29
|
--stage-transition-opacity: var(--catalog-enter-opacity, 1);
|
|
4
30
|
}
|
|
@@ -9,7 +35,7 @@
|
|
|
9
35
|
|
|
10
36
|
.stage [data-catalog-transition-dom='enter'] {
|
|
11
37
|
--catalog-content-opacity: var(--catalog-enter-opacity, 1);
|
|
12
|
-
opacity: var(--catalog-content-opacity);
|
|
38
|
+
opacity: var(--catalog-reveal-opacity, var(--catalog-content-opacity));
|
|
13
39
|
}
|
|
14
40
|
|
|
15
41
|
.stage [data-catalog-transition-dom='exit'] {
|
|
@@ -35,13 +61,13 @@
|
|
|
35
61
|
.stage:is(
|
|
36
62
|
[data-catalog-recipe='list-to-dock'],
|
|
37
63
|
[data-catalog-recipe='carousel-to-dock']
|
|
38
|
-
)[data-catalog-transition]
|
|
64
|
+
)[data-catalog-transition]:not([data-catalog-staged-phase='revealing']):not([data-catalog-staged-phase='committing'])
|
|
39
65
|
[data-spatial-element-sticky-header]::before {
|
|
40
66
|
opacity: 0 !important;
|
|
41
67
|
}
|
|
42
68
|
|
|
43
69
|
.stage[data-catalog-transition] [data-catalog-transition-dom][data-stage-dom-content] {
|
|
44
|
-
opacity: calc(var(--stage-dom-opacity, 1) * var(--catalog-content-opacity, 1));
|
|
70
|
+
opacity: calc(var(--stage-dom-opacity, 1) * var(--catalog-reveal-opacity, var(--catalog-content-opacity, 1)));
|
|
45
71
|
}
|
|
46
72
|
|
|
47
73
|
/* Gate the initial paint before panel registration and renderer binding. */
|
|
@@ -51,6 +77,23 @@
|
|
|
51
77
|
visibility: hidden !important;
|
|
52
78
|
}
|
|
53
79
|
|
|
80
|
+
/* The source is stationary in its independent hold. Rasterize real destination
|
|
81
|
+
DOM now, before its fade: visibility:hidden/opacity:0 postpones the browser's
|
|
82
|
+
rounded-rectangle/path shader preparation until the first visible frame.
|
|
83
|
+
The persistent menu keeps its explicit full opacity below; canvas and held
|
|
84
|
+
source content do not use these incoming DOM variables. */
|
|
85
|
+
.stage[data-catalog-staged-phase='held'] {
|
|
86
|
+
--catalog-enter-opacity: 0.001 !important;
|
|
87
|
+
--catalog-shared-opacity: 0.001 !important;
|
|
88
|
+
}
|
|
89
|
+
.stage[data-catalog-staged-phase='held'] :is(
|
|
90
|
+
[data-catalog-transition-dom='enter'],
|
|
91
|
+
[data-catalog-transition-group='enter'],
|
|
92
|
+
[data-catalog-transition-group='shared']
|
|
93
|
+
) {
|
|
94
|
+
visibility: visible !important;
|
|
95
|
+
}
|
|
96
|
+
|
|
54
97
|
.stage[data-catalog-transition] [data-catalog-transition-dom],
|
|
55
98
|
.stage[data-catalog-transition] [data-catalog-transition-dom] *,
|
|
56
99
|
.stage[data-catalog-transition] [data-catalog-transition-group],
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface InterruptedCatalogPresentation {
|
|
2
|
+
finished: Promise<void>;
|
|
3
|
+
cancel(): void;
|
|
4
|
+
}
|
|
5
|
+
/** Keep semantic ownership beyond a cancelled visual overlay, never beyond its route. */
|
|
6
|
+
export declare function finishInterruptedPresentation(options: {
|
|
7
|
+
settle(): Promise<void>;
|
|
8
|
+
adopt(): HTMLElement;
|
|
9
|
+
release(): unknown;
|
|
10
|
+
}): InterruptedCatalogPresentation;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/** Keep semantic ownership beyond a cancelled visual overlay, never beyond its route. */
|
|
2
|
+
export function finishInterruptedPresentation(options) {
|
|
3
|
+
let cancelled = false, released = false;
|
|
4
|
+
const release = () => {
|
|
5
|
+
if (released)
|
|
6
|
+
return;
|
|
7
|
+
released = true;
|
|
8
|
+
options.release();
|
|
9
|
+
};
|
|
10
|
+
const finished = (async () => {
|
|
11
|
+
try {
|
|
12
|
+
await options.settle();
|
|
13
|
+
if (cancelled)
|
|
14
|
+
return;
|
|
15
|
+
const slot = options.adopt();
|
|
16
|
+
await options.settle();
|
|
17
|
+
if (cancelled)
|
|
18
|
+
return;
|
|
19
|
+
slot.dispatchEvent(new Event('spatial-summary-measure'));
|
|
20
|
+
await options.settle();
|
|
21
|
+
}
|
|
22
|
+
finally {
|
|
23
|
+
release();
|
|
24
|
+
}
|
|
25
|
+
})();
|
|
26
|
+
// Destination model loading can still be pending before Stage joins this task.
|
|
27
|
+
void finished.catch(() => { });
|
|
28
|
+
return { finished, cancel() { cancelled = true; release(); } };
|
|
29
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Release independent presentation owners even if another owner fails to clean up.
|
|
2
|
+
* DOM/registry release stays synchronous; asynchronous component teardown is observed.
|
|
3
|
+
*/
|
|
4
|
+
export declare function releasePresentationResources(message: string, cleanups: readonly (() => unknown)[]): void;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** Release independent presentation owners even if another owner fails to clean up.
|
|
2
|
+
* DOM/registry release stays synchronous; asynchronous component teardown is observed.
|
|
3
|
+
*/
|
|
4
|
+
export function releasePresentationResources(message, cleanups) {
|
|
5
|
+
const failures = [];
|
|
6
|
+
for (const cleanup of cleanups) {
|
|
7
|
+
try {
|
|
8
|
+
const pending = cleanup();
|
|
9
|
+
if (pending && typeof pending.then === 'function') {
|
|
10
|
+
void Promise.resolve(pending).catch(error => { console.error(message, error); });
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
failures.push(error);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
// A diagnostic must not precede release of the remaining synchronous owners.
|
|
18
|
+
for (const error of failures)
|
|
19
|
+
console.error(message, error);
|
|
20
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { BeforeNavigate } from '@sveltejs/kit';
|
|
2
|
+
import type { StageExperience } from '@spatial-elements/core/stage/StageExperience';
|
|
3
|
+
import type { CatalogEndpointRegistry } from '@spatial-elements/core/catalog/CatalogEndpointRegistry';
|
|
4
|
+
import type { EarlyNavigationCancelReason } from '@spatial-elements/core/catalog/EarlyNavigationCoordinator';
|
|
5
|
+
import { type ResponsiveLayoutInput } from '@spatial-elements/core/spatial-element/responsiveLayout';
|
|
6
|
+
import type { SpatialSummaryHostController } from '../spatial-element/spatialSummaryHost.svelte.js';
|
|
7
|
+
import type { SpatialListItem } from '@spatial-elements/core/spatial-element/types';
|
|
8
|
+
import { type InterruptedCatalogPresentation } from './interruptedPresentation.js';
|
|
9
|
+
export type { InterruptedCatalogPresentation } from './interruptedPresentation.js';
|
|
10
|
+
/** Source ownership stays in the persistent shell; Kit only replaces its placement. */
|
|
11
|
+
export declare function startStagedCatalogNavigation(options: {
|
|
12
|
+
root: HTMLElement;
|
|
13
|
+
navigation: BeforeNavigate;
|
|
14
|
+
endpoints: CatalogEndpointRegistry;
|
|
15
|
+
host: SpatialSummaryHostController;
|
|
16
|
+
experience: StageExperience;
|
|
17
|
+
metrics: ResponsiveLayoutInput;
|
|
18
|
+
items: readonly SpatialListItem[];
|
|
19
|
+
diagnostics?: boolean;
|
|
20
|
+
onFinish(): void;
|
|
21
|
+
}): {
|
|
22
|
+
handle: import("@spatial-elements/core/catalog/EarlyNavigationCoordinator").EarlyNavigationHandle;
|
|
23
|
+
destination: string;
|
|
24
|
+
readonly phase: import("@spatial-elements/core/catalog/StagedCatalogTransition").StagedCatalogTransitionPhase;
|
|
25
|
+
readonly timings: {
|
|
26
|
+
started: number;
|
|
27
|
+
entered: number;
|
|
28
|
+
captured: number;
|
|
29
|
+
prepared: number;
|
|
30
|
+
firstMotion: number;
|
|
31
|
+
firstSubmitted: number;
|
|
32
|
+
motionEnded: number;
|
|
33
|
+
holdStarted: number;
|
|
34
|
+
held: number;
|
|
35
|
+
committed: number;
|
|
36
|
+
revealStarted: number;
|
|
37
|
+
revealEnded: number;
|
|
38
|
+
revealed: number;
|
|
39
|
+
};
|
|
40
|
+
commit(): void;
|
|
41
|
+
cancel(reason?: EarlyNavigationCancelReason): void;
|
|
42
|
+
cancelCommitted(reason: EarlyNavigationCancelReason): InterruptedCatalogPresentation | undefined;
|
|
43
|
+
reveal(rebind: () => void): Promise<void>;
|
|
44
|
+
} | undefined;
|