@spatial-elements/core 0.1.0-beta.1
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/LICENSE +373 -0
- package/README.md +17 -0
- package/dist/catalog/CarouselGlassCompositor.d.ts +24 -0
- package/dist/catalog/CarouselGlassCompositor.d.ts.map +1 -0
- package/dist/catalog/CarouselGlassCompositor.js +132 -0
- package/dist/catalog/CarouselGlassCompositor.js.map +1 -0
- package/dist/catalog/CatalogEndpointRegistry.d.ts +59 -0
- package/dist/catalog/CatalogEndpointRegistry.d.ts.map +1 -0
- package/dist/catalog/CatalogEndpointRegistry.js +187 -0
- package/dist/catalog/CatalogEndpointRegistry.js.map +1 -0
- package/dist/catalog/CatalogGeometryFade.d.ts +12 -0
- package/dist/catalog/CatalogGeometryFade.d.ts.map +1 -0
- package/dist/catalog/CatalogGeometryFade.js +67 -0
- package/dist/catalog/CatalogGeometryFade.js.map +1 -0
- package/dist/catalog/CatalogPreparation.d.ts +40 -0
- package/dist/catalog/CatalogPreparation.d.ts.map +1 -0
- package/dist/catalog/CatalogPreparation.js +141 -0
- package/dist/catalog/CatalogPreparation.js.map +1 -0
- package/dist/catalog/CatalogSections.d.ts +36 -0
- package/dist/catalog/CatalogSections.d.ts.map +1 -0
- package/dist/catalog/CatalogSections.js +51 -0
- package/dist/catalog/CatalogSections.js.map +1 -0
- package/dist/catalog/CatalogSpatialElementLayer.d.ts +149 -0
- package/dist/catalog/CatalogSpatialElementLayer.d.ts.map +1 -0
- package/dist/catalog/CatalogSpatialElementLayer.js +920 -0
- package/dist/catalog/CatalogSpatialElementLayer.js.map +1 -0
- package/dist/catalog/CatalogTransition.d.ts +93 -0
- package/dist/catalog/CatalogTransition.d.ts.map +1 -0
- package/dist/catalog/CatalogTransition.js +1299 -0
- package/dist/catalog/CatalogTransition.js.map +1 -0
- package/dist/catalog/EnvironmentCache.d.ts +30 -0
- package/dist/catalog/EnvironmentCache.d.ts.map +1 -0
- package/dist/catalog/EnvironmentCache.js +128 -0
- package/dist/catalog/EnvironmentCache.js.map +1 -0
- package/dist/catalog/PreparationGate.d.ts +10 -0
- package/dist/catalog/PreparationGate.d.ts.map +1 -0
- package/dist/catalog/PreparationGate.js +66 -0
- package/dist/catalog/PreparationGate.js.map +1 -0
- package/dist/catalog/PresentationLease.d.ts +16 -0
- package/dist/catalog/PresentationLease.d.ts.map +1 -0
- package/dist/catalog/PresentationLease.js +33 -0
- package/dist/catalog/PresentationLease.js.map +1 -0
- package/dist/catalog/SpatialGeometryCapture.d.ts +63 -0
- package/dist/catalog/SpatialGeometryCapture.d.ts.map +1 -0
- package/dist/catalog/SpatialGeometryCapture.js +158 -0
- package/dist/catalog/SpatialGeometryCapture.js.map +1 -0
- package/dist/catalog/assets/SpatialElementAssetManager.d.ts +92 -0
- package/dist/catalog/assets/SpatialElementAssetManager.d.ts.map +1 -0
- package/dist/catalog/assets/SpatialElementAssetManager.js +305 -0
- package/dist/catalog/assets/SpatialElementAssetManager.js.map +1 -0
- package/dist/catalog/assets/assetCosts.d.ts +4 -0
- package/dist/catalog/assets/assetCosts.d.ts.map +1 -0
- package/dist/catalog/assets/assetCosts.js +33 -0
- package/dist/catalog/assets/assetCosts.js.map +1 -0
- package/dist/catalog/assets/spatialElementAssetResources.d.ts +25 -0
- package/dist/catalog/assets/spatialElementAssetResources.d.ts.map +1 -0
- package/dist/catalog/assets/spatialElementAssetResources.js +100 -0
- package/dist/catalog/assets/spatialElementAssetResources.js.map +1 -0
- package/dist/catalog/carouselPanelProjection.d.ts +9 -0
- package/dist/catalog/carouselPanelProjection.d.ts.map +1 -0
- package/dist/catalog/carouselPanelProjection.js +33 -0
- package/dist/catalog/carouselPanelProjection.js.map +1 -0
- package/dist/catalog/carouselSelection.d.ts +7 -0
- package/dist/catalog/carouselSelection.d.ts.map +1 -0
- package/dist/catalog/carouselSelection.js +15 -0
- package/dist/catalog/carouselSelection.js.map +1 -0
- package/dist/catalog/catalogAction.d.ts +4 -0
- package/dist/catalog/catalogAction.d.ts.map +1 -0
- package/dist/catalog/catalogAction.js +9 -0
- package/dist/catalog/catalogAction.js.map +1 -0
- package/dist/catalog/catalogGeometryRequest.d.ts +13 -0
- package/dist/catalog/catalogGeometryRequest.d.ts.map +1 -0
- package/dist/catalog/catalogGeometryRequest.js +8 -0
- package/dist/catalog/catalogGeometryRequest.js.map +1 -0
- package/dist/catalog/catalogItems.d.ts +10 -0
- package/dist/catalog/catalogItems.d.ts.map +1 -0
- package/dist/catalog/catalogItems.js +23 -0
- package/dist/catalog/catalogItems.js.map +1 -0
- package/dist/catalog/catalogJourney.d.ts +38 -0
- package/dist/catalog/catalogJourney.d.ts.map +1 -0
- package/dist/catalog/catalogJourney.js +64 -0
- package/dist/catalog/catalogJourney.js.map +1 -0
- package/dist/catalog/catalogPage.d.ts +11 -0
- package/dist/catalog/catalogPage.d.ts.map +1 -0
- package/dist/catalog/catalogPage.js +2 -0
- package/dist/catalog/catalogPage.js.map +1 -0
- package/dist/catalog/catalogPose.d.ts +30 -0
- package/dist/catalog/catalogPose.d.ts.map +1 -0
- package/dist/catalog/catalogPose.js +35 -0
- package/dist/catalog/catalogPose.js.map +1 -0
- package/dist/catalog/catalogPresentation.d.ts +24 -0
- package/dist/catalog/catalogPresentation.d.ts.map +1 -0
- package/dist/catalog/catalogPresentation.js +56 -0
- package/dist/catalog/catalogPresentation.js.map +1 -0
- package/dist/catalog/catalogRecipes.d.ts +21 -0
- package/dist/catalog/catalogRecipes.d.ts.map +1 -0
- package/dist/catalog/catalogRecipes.js +84 -0
- package/dist/catalog/catalogRecipes.js.map +1 -0
- package/dist/catalog/catalogSurfaceCapture.d.ts +11 -0
- package/dist/catalog/catalogSurfaceCapture.d.ts.map +1 -0
- package/dist/catalog/catalogSurfaceCapture.js +11 -0
- package/dist/catalog/catalogSurfaceCapture.js.map +1 -0
- package/dist/catalog/catalogViewLink.d.ts +8 -0
- package/dist/catalog/catalogViewLink.d.ts.map +1 -0
- package/dist/catalog/catalogViewLink.js +37 -0
- package/dist/catalog/catalogViewLink.js.map +1 -0
- package/dist/catalog/rebasePresentation.d.ts +3 -0
- package/dist/catalog/rebasePresentation.d.ts.map +1 -0
- package/dist/catalog/rebasePresentation.js +26 -0
- package/dist/catalog/rebasePresentation.js.map +1 -0
- package/dist/catalog/spatialElementAssets.d.ts +158 -0
- package/dist/catalog/spatialElementAssets.d.ts.map +1 -0
- package/dist/catalog/spatialElementAssets.js +92 -0
- package/dist/catalog/spatialElementAssets.js.map +1 -0
- package/dist/catalog/spatialElementLodPair.d.ts +17 -0
- package/dist/catalog/spatialElementLodPair.d.ts.map +1 -0
- package/dist/catalog/spatialElementLodPair.js +5 -0
- package/dist/catalog/spatialElementLodPair.js.map +1 -0
- package/dist/catalog/transitionTiming.d.ts +15 -0
- package/dist/catalog/transitionTiming.d.ts.map +1 -0
- package/dist/catalog/transitionTiming.js +22 -0
- package/dist/catalog/transitionTiming.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/spatial-element/SpatialElementDockController.d.ts +101 -0
- package/dist/spatial-element/SpatialElementDockController.d.ts.map +1 -0
- package/dist/spatial-element/SpatialElementDockController.js +627 -0
- package/dist/spatial-element/SpatialElementDockController.js.map +1 -0
- package/dist/spatial-element/spatialElement.d.ts +28 -0
- package/dist/spatial-element/spatialElement.d.ts.map +1 -0
- package/dist/spatial-element/spatialElement.js +45 -0
- package/dist/spatial-element/spatialElement.js.map +1 -0
- package/dist/spatial-element/spatialElementDock.d.ts +43 -0
- package/dist/spatial-element/spatialElementDock.d.ts.map +1 -0
- package/dist/spatial-element/spatialElementDock.js +126 -0
- package/dist/spatial-element/spatialElementDock.js.map +1 -0
- package/dist/spatial-element/spatialElementSectionRegistry.d.ts +29 -0
- package/dist/spatial-element/spatialElementSectionRegistry.d.ts.map +1 -0
- package/dist/spatial-element/spatialElementSectionRegistry.js +67 -0
- package/dist/spatial-element/spatialElementSectionRegistry.js.map +1 -0
- package/dist/spatial-element/types.d.ts +165 -0
- package/dist/spatial-element/types.d.ts.map +1 -0
- package/dist/spatial-element/types.js +2 -0
- package/dist/spatial-element/types.js.map +1 -0
- package/dist/stage/LiquidGlassPanel.d.ts +55 -0
- package/dist/stage/LiquidGlassPanel.d.ts.map +1 -0
- package/dist/stage/LiquidGlassPanel.js +447 -0
- package/dist/stage/LiquidGlassPanel.js.map +1 -0
- package/dist/stage/MinimapBlurPipeline.d.ts +34 -0
- package/dist/stage/MinimapBlurPipeline.d.ts.map +1 -0
- package/dist/stage/MinimapBlurPipeline.js +147 -0
- package/dist/stage/MinimapBlurPipeline.js.map +1 -0
- package/dist/stage/MinimapController.d.ts +113 -0
- package/dist/stage/MinimapController.d.ts.map +1 -0
- package/dist/stage/MinimapController.js +803 -0
- package/dist/stage/MinimapController.js.map +1 -0
- package/dist/stage/OrbitControlsInterop.d.ts +8 -0
- package/dist/stage/OrbitControlsInterop.d.ts.map +1 -0
- package/dist/stage/OrbitControlsInterop.js +19 -0
- package/dist/stage/OrbitControlsInterop.js.map +1 -0
- package/dist/stage/PageBindingController.d.ts +41 -0
- package/dist/stage/PageBindingController.d.ts.map +1 -0
- package/dist/stage/PageBindingController.js +92 -0
- package/dist/stage/PageBindingController.js.map +1 -0
- package/dist/stage/PanelPresentationController.d.ts +92 -0
- package/dist/stage/PanelPresentationController.d.ts.map +1 -0
- package/dist/stage/PanelPresentationController.js +569 -0
- package/dist/stage/PanelPresentationController.js.map +1 -0
- package/dist/stage/PresentationReadiness.d.ts +30 -0
- package/dist/stage/PresentationReadiness.d.ts.map +1 -0
- package/dist/stage/PresentationReadiness.js +94 -0
- package/dist/stage/PresentationReadiness.js.map +1 -0
- package/dist/stage/SpaceMouseAdapter.d.ts +76 -0
- package/dist/stage/SpaceMouseAdapter.d.ts.map +1 -0
- package/dist/stage/SpaceMouseAdapter.js +197 -0
- package/dist/stage/SpaceMouseAdapter.js.map +1 -0
- package/dist/stage/SpatialElementInteractionController.d.ts +126 -0
- package/dist/stage/SpatialElementInteractionController.d.ts.map +1 -0
- package/dist/stage/SpatialElementInteractionController.js +581 -0
- package/dist/stage/SpatialElementInteractionController.js.map +1 -0
- package/dist/stage/SpatialElementPresentationController.d.ts +82 -0
- package/dist/stage/SpatialElementPresentationController.d.ts.map +1 -0
- package/dist/stage/SpatialElementPresentationController.js +372 -0
- package/dist/stage/SpatialElementPresentationController.js.map +1 -0
- package/dist/stage/SpatialElementRefinement.d.ts +26 -0
- package/dist/stage/SpatialElementRefinement.d.ts.map +1 -0
- package/dist/stage/SpatialElementRefinement.js +105 -0
- package/dist/stage/SpatialElementRefinement.js.map +1 -0
- package/dist/stage/StageExperience.d.ts +536 -0
- package/dist/stage/StageExperience.d.ts.map +1 -0
- package/dist/stage/StageExperience.js +2399 -0
- package/dist/stage/StageExperience.js.map +1 -0
- package/dist/stage/StagePanelLayout.d.ts +15 -0
- package/dist/stage/StagePanelLayout.d.ts.map +1 -0
- package/dist/stage/StagePanelLayout.js +20 -0
- package/dist/stage/StagePanelLayout.js.map +1 -0
- package/dist/stage/StagePanelRuntime.d.ts +20 -0
- package/dist/stage/StagePanelRuntime.d.ts.map +1 -0
- package/dist/stage/StagePanelRuntime.js +2 -0
- package/dist/stage/StagePanelRuntime.js.map +1 -0
- package/dist/stage/StageRenderPipeline.d.ts +179 -0
- package/dist/stage/StageRenderPipeline.d.ts.map +1 -0
- package/dist/stage/StageRenderPipeline.js +901 -0
- package/dist/stage/StageRenderPipeline.js.map +1 -0
- package/dist/stage/VirtualScrollController.d.ts +64 -0
- package/dist/stage/VirtualScrollController.d.ts.map +1 -0
- package/dist/stage/VirtualScrollController.js +329 -0
- package/dist/stage/VirtualScrollController.js.map +1 -0
- package/dist/stage/cssProjection.d.ts +18 -0
- package/dist/stage/cssProjection.d.ts.map +1 -0
- package/dist/stage/cssProjection.js +52 -0
- package/dist/stage/cssProjection.js.map +1 -0
- package/dist/stage/damping.d.ts +3 -0
- package/dist/stage/damping.d.ts.map +1 -0
- package/dist/stage/damping.js +8 -0
- package/dist/stage/damping.js.map +1 -0
- package/dist/stage/minimap/MinimapGeometry.d.ts +31 -0
- package/dist/stage/minimap/MinimapGeometry.d.ts.map +1 -0
- package/dist/stage/minimap/MinimapGeometry.js +163 -0
- package/dist/stage/minimap/MinimapGeometry.js.map +1 -0
- package/dist/stage/minimap/MinimapModel.d.ts +16 -0
- package/dist/stage/minimap/MinimapModel.d.ts.map +1 -0
- package/dist/stage/minimap/MinimapModel.js +51 -0
- package/dist/stage/minimap/MinimapModel.js.map +1 -0
- package/dist/stage/minimap/MinimapProjection.d.ts +41 -0
- package/dist/stage/minimap/MinimapProjection.d.ts.map +1 -0
- package/dist/stage/minimap/MinimapProjection.js +113 -0
- package/dist/stage/minimap/MinimapProjection.js.map +1 -0
- package/dist/stage/minimap/MinimapState.d.ts +102 -0
- package/dist/stage/minimap/MinimapState.d.ts.map +1 -0
- package/dist/stage/minimap/MinimapState.js +2 -0
- package/dist/stage/minimap/MinimapState.js.map +1 -0
- package/dist/stage/minimapMeasurement.d.ts +5 -0
- package/dist/stage/minimapMeasurement.d.ts.map +1 -0
- package/dist/stage/minimapMeasurement.js +11 -0
- package/dist/stage/minimapMeasurement.js.map +1 -0
- package/dist/stage/panelContext.d.ts +71 -0
- package/dist/stage/panelContext.d.ts.map +1 -0
- package/dist/stage/panelContext.js +6 -0
- package/dist/stage/panelContext.js.map +1 -0
- package/dist/stage/panelShadow.d.ts +20 -0
- package/dist/stage/panelShadow.d.ts.map +1 -0
- package/dist/stage/panelShadow.js +22 -0
- package/dist/stage/panelShadow.js.map +1 -0
- package/dist/stage/renderMeasurement.d.ts +3 -0
- package/dist/stage/renderMeasurement.d.ts.map +1 -0
- package/dist/stage/renderMeasurement.js +19 -0
- package/dist/stage/renderMeasurement.js.map +1 -0
- package/dist/stage/renderTargetInventory.d.ts +17 -0
- package/dist/stage/renderTargetInventory.d.ts.map +1 -0
- package/dist/stage/renderTargetInventory.js +27 -0
- package/dist/stage/renderTargetInventory.js.map +1 -0
- package/dist/stage/rendererState.d.ts +14 -0
- package/dist/stage/rendererState.d.ts.map +1 -0
- package/dist/stage/rendererState.js +35 -0
- package/dist/stage/rendererState.js.map +1 -0
- package/dist/stage/resolveStageProfile.d.ts +44 -0
- package/dist/stage/resolveStageProfile.d.ts.map +1 -0
- package/dist/stage/resolveStageProfile.js +30 -0
- package/dist/stage/resolveStageProfile.js.map +1 -0
- package/dist/stage/scrollAnimation.d.ts +10 -0
- package/dist/stage/scrollAnimation.d.ts.map +1 -0
- package/dist/stage/scrollAnimation.js +11 -0
- package/dist/stage/scrollAnimation.js.map +1 -0
- package/dist/stage/scrollFrame.d.ts +43 -0
- package/dist/stage/scrollFrame.d.ts.map +1 -0
- package/dist/stage/scrollFrame.js +232 -0
- package/dist/stage/scrollFrame.js.map +1 -0
- package/dist/stage/spatialElementFrame.d.ts +6 -0
- package/dist/stage/spatialElementFrame.d.ts.map +1 -0
- package/dist/stage/spatialElementFrame.js +22 -0
- package/dist/stage/spatialElementFrame.js.map +1 -0
- package/dist/stage/stageConstants.d.ts +85 -0
- package/dist/stage/stageConstants.d.ts.map +1 -0
- package/dist/stage/stageConstants.js +85 -0
- package/dist/stage/stageConstants.js.map +1 -0
- package/dist/stage/stageDom.d.ts +10 -0
- package/dist/stage/stageDom.d.ts.map +1 -0
- package/dist/stage/stageDom.js +22 -0
- package/dist/stage/stageDom.js.map +1 -0
- package/dist/stage/stageMath.d.ts +187 -0
- package/dist/stage/stageMath.d.ts.map +1 -0
- package/dist/stage/stageMath.js +344 -0
- package/dist/stage/stageMath.js.map +1 -0
- package/dist/stage/stageSceneUtils.d.ts +42 -0
- package/dist/stage/stageSceneUtils.d.ts.map +1 -0
- package/dist/stage/stageSceneUtils.js +154 -0
- package/dist/stage/stageSceneUtils.js.map +1 -0
- package/dist/stage/stageTypes.d.ts +189 -0
- package/dist/stage/stageTypes.d.ts.map +1 -0
- package/dist/stage/stageTypes.js +2 -0
- package/dist/stage/stageTypes.js.map +1 -0
- package/dist/stage/stageVisualTest.d.ts +92 -0
- package/dist/stage/stageVisualTest.d.ts.map +1 -0
- package/dist/stage/stageVisualTest.js +5 -0
- package/dist/stage/stageVisualTest.js.map +1 -0
- package/package.json +61 -0
|
@@ -0,0 +1,1299 @@
|
|
|
1
|
+
import { geometryEndpoint } from './catalogGeometryRequest.js';
|
|
2
|
+
import { resolveCatalogJourney, planCatalogParticipants } from './catalogJourney.js';
|
|
3
|
+
import { readCatalogViewContext } from './catalogViewLink.js';
|
|
4
|
+
import { captureCarouselElement } from './carouselPanelProjection.js';
|
|
5
|
+
import { PresentationLease } from './PresentationLease.js';
|
|
6
|
+
import { rebasePresentation } from './rebasePresentation.js';
|
|
7
|
+
import { getProjectiveCssMatrix3d } from '../stage/cssProjection.js';
|
|
8
|
+
import { catalogSharedKey } from './CatalogEndpointRegistry.js';
|
|
9
|
+
import { resolveCatalogIntent, selectCatalogRecipe } from './catalogRecipes.js';
|
|
10
|
+
export { catalogSharedKey } from './CatalogEndpointRegistry.js';
|
|
11
|
+
import { MOTION_DURATION as DURATION, transitionTiming } from './transitionTiming.js';
|
|
12
|
+
function isReturnRecipe(recipe) {
|
|
13
|
+
return recipe.source.startsWith('detail.');
|
|
14
|
+
}
|
|
15
|
+
function isRichRole(role) {
|
|
16
|
+
return role === 'features' || role === 'primary-action';
|
|
17
|
+
}
|
|
18
|
+
/** Full summaries retain authored row/icon layout; temporary controls never become interactive. */
|
|
19
|
+
function copyRichContent(target, source) {
|
|
20
|
+
const copy = source.cloneNode(true);
|
|
21
|
+
const originals = [source, ...source.querySelectorAll('*')];
|
|
22
|
+
const copies = [copy, ...copy.querySelectorAll('*')];
|
|
23
|
+
for (let index = 0; index < originals.length; index++) {
|
|
24
|
+
const style = getComputedStyle(originals[index]);
|
|
25
|
+
for (const property of style)
|
|
26
|
+
copies[index].style.setProperty(property, style.getPropertyValue(property));
|
|
27
|
+
copies[index].style.visibility = 'visible';
|
|
28
|
+
copies[index].removeAttribute('id');
|
|
29
|
+
for (const attribute of [...copies[index].attributes])
|
|
30
|
+
if (attribute.name.startsWith('data-'))
|
|
31
|
+
copies[index].removeAttribute(attribute.name);
|
|
32
|
+
}
|
|
33
|
+
Object.assign(copy.style, {
|
|
34
|
+
position: 'relative',
|
|
35
|
+
left: '0',
|
|
36
|
+
top: '0',
|
|
37
|
+
width: '100%',
|
|
38
|
+
height: '100%',
|
|
39
|
+
margin: '0',
|
|
40
|
+
transform: 'none',
|
|
41
|
+
pointerEvents: 'none'
|
|
42
|
+
});
|
|
43
|
+
copy.inert = true;
|
|
44
|
+
copy.setAttribute('aria-hidden', 'true');
|
|
45
|
+
target.append(copy);
|
|
46
|
+
}
|
|
47
|
+
/** Only the forward list-to-hero edge is part of the first vertical slice. */
|
|
48
|
+
export function resolveCatalogTransition(from, to, type) {
|
|
49
|
+
if (type === 'popstate' ||
|
|
50
|
+
to.hash ||
|
|
51
|
+
!from.pathname.replace(/\/$/, '').endsWith('/categories/list'))
|
|
52
|
+
return;
|
|
53
|
+
return selectCatalogRecipe(resolveCatalogIntent(from, to, type), 'list', 'hero')?.identity;
|
|
54
|
+
}
|
|
55
|
+
/** A stale animation completion cannot settle a newer navigation. */
|
|
56
|
+
export class CatalogTransitionSequence {
|
|
57
|
+
generation = 0;
|
|
58
|
+
current;
|
|
59
|
+
get active() {
|
|
60
|
+
return this.current !== undefined;
|
|
61
|
+
}
|
|
62
|
+
get phase() {
|
|
63
|
+
return this.current?.phase ?? 'idle';
|
|
64
|
+
}
|
|
65
|
+
begin() {
|
|
66
|
+
const token = ++this.generation;
|
|
67
|
+
this.current = { token, phase: 'captured' };
|
|
68
|
+
return token;
|
|
69
|
+
}
|
|
70
|
+
start(token) {
|
|
71
|
+
if (!this.current || this.current.token !== token || this.current.phase !== 'captured') {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
this.current.phase = 'animating';
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
isCurrent(token) {
|
|
78
|
+
return this.current?.token === token;
|
|
79
|
+
}
|
|
80
|
+
finish(token) {
|
|
81
|
+
if (!this.isCurrent(token))
|
|
82
|
+
return false;
|
|
83
|
+
this.current = undefined;
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
cancel() {
|
|
87
|
+
this.generation += 1;
|
|
88
|
+
this.current = undefined;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function hasSize(rect) {
|
|
92
|
+
return rect.width > 0 && rect.height > 0;
|
|
93
|
+
}
|
|
94
|
+
function intersectsViewport(element) {
|
|
95
|
+
const rect = element.getBoundingClientRect();
|
|
96
|
+
return (hasSize(rect) &&
|
|
97
|
+
rect.right > 0 &&
|
|
98
|
+
rect.bottom > 0 &&
|
|
99
|
+
rect.left < innerWidth &&
|
|
100
|
+
rect.top < innerHeight);
|
|
101
|
+
}
|
|
102
|
+
/** A partial endpoint needs an explicit clip representation; otherwise use semantic navigation. */
|
|
103
|
+
function fullyPresented(element) {
|
|
104
|
+
const rect = element.getBoundingClientRect();
|
|
105
|
+
if (!hasSize(rect) ||
|
|
106
|
+
rect.left < 0 ||
|
|
107
|
+
rect.top < 0 ||
|
|
108
|
+
rect.right > innerWidth ||
|
|
109
|
+
rect.bottom > innerHeight)
|
|
110
|
+
return false;
|
|
111
|
+
for (let ancestor = element.parentElement; ancestor; ancestor = ancestor.parentElement) {
|
|
112
|
+
const style = getComputedStyle(ancestor);
|
|
113
|
+
const clip = ancestor.getBoundingClientRect();
|
|
114
|
+
if (/(hidden|clip|scroll|auto)/.test(style.overflowX) &&
|
|
115
|
+
(rect.left < clip.left - 1 || rect.right > clip.right + 1))
|
|
116
|
+
return false;
|
|
117
|
+
if (/(hidden|clip|scroll|auto)/.test(style.overflowY) &&
|
|
118
|
+
(rect.top < clip.top - 1 || rect.bottom > clip.bottom + 1))
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
return true;
|
|
122
|
+
}
|
|
123
|
+
function visiblyPresented(element) {
|
|
124
|
+
const rect = element.getBoundingClientRect();
|
|
125
|
+
if (!hasSize(rect) || rect.bottom <= 0 || rect.top >= innerHeight)
|
|
126
|
+
return false;
|
|
127
|
+
for (let node = element; node; node = node.parentElement) {
|
|
128
|
+
const style = getComputedStyle(node);
|
|
129
|
+
if (style.visibility === 'hidden' || style.display === 'none' || Number(style.opacity) < 0.01)
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
return true;
|
|
133
|
+
}
|
|
134
|
+
function copyTypography(element, style) {
|
|
135
|
+
for (const property of [
|
|
136
|
+
'font-family',
|
|
137
|
+
'font-size',
|
|
138
|
+
'font-weight',
|
|
139
|
+
'font-style',
|
|
140
|
+
'line-height',
|
|
141
|
+
'letter-spacing',
|
|
142
|
+
'text-transform',
|
|
143
|
+
'text-align',
|
|
144
|
+
'white-space',
|
|
145
|
+
'overflow',
|
|
146
|
+
'text-overflow',
|
|
147
|
+
'color',
|
|
148
|
+
'text-shadow'
|
|
149
|
+
])
|
|
150
|
+
element.style.setProperty(property, style.getPropertyValue(property));
|
|
151
|
+
}
|
|
152
|
+
function preserveStyle(element, property, restore) {
|
|
153
|
+
const value = element.style.getPropertyValue(property);
|
|
154
|
+
const priority = element.style.getPropertyPriority(property);
|
|
155
|
+
const reset = () => {
|
|
156
|
+
if (value)
|
|
157
|
+
element.style.setProperty(property, value, priority);
|
|
158
|
+
else
|
|
159
|
+
element.style.removeProperty(property);
|
|
160
|
+
};
|
|
161
|
+
restore.push(reset);
|
|
162
|
+
return reset;
|
|
163
|
+
}
|
|
164
|
+
/** Owns decorative DOM only. Semantic pages and element geometry keep their respective owners. */
|
|
165
|
+
export class CatalogTransition {
|
|
166
|
+
root;
|
|
167
|
+
endpoints;
|
|
168
|
+
hooks;
|
|
169
|
+
sequence = new CatalogTransitionSequence();
|
|
170
|
+
captureState;
|
|
171
|
+
interrupt = () => this.cancel();
|
|
172
|
+
keydown = (event) => {
|
|
173
|
+
if (event.key === 'Escape')
|
|
174
|
+
this.cancel();
|
|
175
|
+
};
|
|
176
|
+
constructor(root, endpoints, hooks) {
|
|
177
|
+
this.root = root;
|
|
178
|
+
this.endpoints = endpoints;
|
|
179
|
+
this.hooks = hooks;
|
|
180
|
+
}
|
|
181
|
+
get active() {
|
|
182
|
+
return this.sequence.active;
|
|
183
|
+
}
|
|
184
|
+
/** Pause at the last submitted DOM/GPU frame while a compatible navigation resolves. */
|
|
185
|
+
supersede(destination) {
|
|
186
|
+
const capture = this.captureState;
|
|
187
|
+
const path = destination.pathname.replace(/\/$/, '');
|
|
188
|
+
const compatible = capture &&
|
|
189
|
+
destination.origin === location.origin &&
|
|
190
|
+
(Boolean(resolveCatalogIntent(new URL(`/${encodeURIComponent(capture.identity.brandId)}/elements/${encodeURIComponent(capture.identity.spatialElementId)}`, location.href), destination, 'link')) ||
|
|
191
|
+
path ===
|
|
192
|
+
`/${encodeURIComponent(capture.identity.brandId)}/elements/${encodeURIComponent(capture.identity.spatialElementId)}`);
|
|
193
|
+
if (!capture || !compatible) {
|
|
194
|
+
this.cancel();
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
cancelAnimationFrame(capture.frame);
|
|
198
|
+
// The old destination can unmount while the successor binds asynchronously.
|
|
199
|
+
// Its observer must not cancel the new owner when those old bounds disappear.
|
|
200
|
+
capture.layoutObserver?.disconnect();
|
|
201
|
+
capture.layoutObserver = undefined;
|
|
202
|
+
capture.suspendedPose = {
|
|
203
|
+
surface: capture.actors[0]?.element.getBoundingClientRect() ?? new DOMRect(),
|
|
204
|
+
geometry: this.hooks.geometryPoint?.() ?? null
|
|
205
|
+
};
|
|
206
|
+
capture.paused = true;
|
|
207
|
+
capture.resolve?.();
|
|
208
|
+
capture.resolve = undefined;
|
|
209
|
+
const reverse = /\/categories\/(?:list|carousel|mixed)$/.test(path);
|
|
210
|
+
if (capture.view ||
|
|
211
|
+
capture.retarget ||
|
|
212
|
+
reverse !== isReturnRecipe(capture.recipe) ||
|
|
213
|
+
destination.hash) {
|
|
214
|
+
if (!this.hooks.adoptGeometry?.({
|
|
215
|
+
spatialElementId: capture.identity.spatialElementId,
|
|
216
|
+
kind: reverse ? 'content' : destination.hash ? 'dock' : 'hero'
|
|
217
|
+
})) {
|
|
218
|
+
this.cancel();
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
capture.retarget = true;
|
|
222
|
+
const panelRect = capture.actors
|
|
223
|
+
.find((actor) => actor.role === 'summary-surface')
|
|
224
|
+
?.element.getBoundingClientRect();
|
|
225
|
+
if (panelRect)
|
|
226
|
+
for (const copy of capture.panelContent ?? []) {
|
|
227
|
+
const rect = copy.element.getBoundingClientRect();
|
|
228
|
+
const wrapper = rebasePresentation([copy.element], rect, 'summary-surface');
|
|
229
|
+
delete wrapper.dataset.catalogActorRole;
|
|
230
|
+
wrapper.dataset.catalogPanelContent = '';
|
|
231
|
+
capture.host.appendChild(wrapper);
|
|
232
|
+
const index = capture.exiting.indexOf(copy.element);
|
|
233
|
+
if (index >= 0)
|
|
234
|
+
capture.exiting[index] = wrapper;
|
|
235
|
+
else
|
|
236
|
+
capture.exiting.push(wrapper);
|
|
237
|
+
copy.element = wrapper;
|
|
238
|
+
copy.rect = rect;
|
|
239
|
+
copy.panel = panelRect;
|
|
240
|
+
copy.incoming = false;
|
|
241
|
+
}
|
|
242
|
+
const extra = [];
|
|
243
|
+
const opacity = Number(this.root.style.getPropertyValue('--catalog-shared-opacity')) || 0;
|
|
244
|
+
for (const actor of capture.actors) {
|
|
245
|
+
const rect = actor.element.getBoundingClientRect();
|
|
246
|
+
if (!actor.sourceOnly && opacity > 0) {
|
|
247
|
+
const real = this.endpoints.resolve({
|
|
248
|
+
...capture.identity,
|
|
249
|
+
slot: capture.recipe.targetShared,
|
|
250
|
+
role: actor.role
|
|
251
|
+
});
|
|
252
|
+
if (real) {
|
|
253
|
+
const bounds = (actor.role === 'summary-surface' ? this.hooks.resolveSurface(real) : real).getBoundingClientRect();
|
|
254
|
+
const copy = document.createElement('div');
|
|
255
|
+
copy.style.cssText = actor.element.style.cssText;
|
|
256
|
+
Object.assign(copy.style, {
|
|
257
|
+
left: `${bounds.left}px`,
|
|
258
|
+
top: `${bounds.top}px`,
|
|
259
|
+
width: `${bounds.width}px`,
|
|
260
|
+
height: `${bounds.height}px`,
|
|
261
|
+
transform: 'none',
|
|
262
|
+
clipPath: 'none',
|
|
263
|
+
opacity: String(opacity)
|
|
264
|
+
});
|
|
265
|
+
if (actor.role !== 'summary-surface') {
|
|
266
|
+
copy.textContent = real.textContent;
|
|
267
|
+
copyTypography(copy, getComputedStyle(real));
|
|
268
|
+
}
|
|
269
|
+
capture.host.appendChild(copy);
|
|
270
|
+
extra.push({
|
|
271
|
+
role: actor.role,
|
|
272
|
+
element: copy,
|
|
273
|
+
from: bounds,
|
|
274
|
+
fontSize: Number.parseFloat(getComputedStyle(real).fontSize),
|
|
275
|
+
sourceOnly: true,
|
|
276
|
+
baseOpacity: opacity
|
|
277
|
+
});
|
|
278
|
+
if (actor.role !== 'summary-surface') {
|
|
279
|
+
preserveStyle(real, 'visibility', capture.restore);
|
|
280
|
+
real.style.setProperty('visibility', 'hidden', 'important');
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
const layers = [actor.element, ...(actor.destinationCopy ? [actor.destinationCopy] : [])];
|
|
285
|
+
const wrapper = rebasePresentation(layers, rect, actor.role);
|
|
286
|
+
capture.host.appendChild(wrapper);
|
|
287
|
+
actor.fontSize *= rect.width / actor.from.width;
|
|
288
|
+
actor.element = wrapper;
|
|
289
|
+
actor.corners = undefined;
|
|
290
|
+
actor.from = rect;
|
|
291
|
+
actor.to = undefined;
|
|
292
|
+
actor.destinationCopy = undefined;
|
|
293
|
+
actor.rebased = true;
|
|
294
|
+
actor.baseOpacity = 1;
|
|
295
|
+
}
|
|
296
|
+
capture.actors.push(...extra);
|
|
297
|
+
// Retain visible secondary content before hiding its shared parent or awaiting route data.
|
|
298
|
+
const previousRecipe = capture.recipe;
|
|
299
|
+
capture.recipe = {
|
|
300
|
+
...previousRecipe,
|
|
301
|
+
source: this.root.querySelector('[data-catalog-list]') ? 'catalog.card' : 'detail.summary'
|
|
302
|
+
};
|
|
303
|
+
this.captureExitingContent(capture);
|
|
304
|
+
capture.recipe = previousRecipe;
|
|
305
|
+
const surface = this.endpoints.resolve({
|
|
306
|
+
...capture.identity,
|
|
307
|
+
slot: previousRecipe.targetShared,
|
|
308
|
+
role: 'summary-surface'
|
|
309
|
+
});
|
|
310
|
+
if (surface) {
|
|
311
|
+
preserveStyle(surface, 'visibility', capture.restore);
|
|
312
|
+
surface.style.setProperty('visibility', 'hidden', 'important');
|
|
313
|
+
}
|
|
314
|
+
for (const copy of capture.exiting)
|
|
315
|
+
copy.dataset.catalogBaseOpacity = copy.style.opacity || '1';
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
getOwnership() {
|
|
319
|
+
const capture = this.captureState;
|
|
320
|
+
return capture
|
|
321
|
+
? {
|
|
322
|
+
revision: capture.lease?.revision,
|
|
323
|
+
elapsed: capture.elapsed,
|
|
324
|
+
identity: capture.identity,
|
|
325
|
+
source: capture.recipe.source,
|
|
326
|
+
target: capture.recipe.targetShared,
|
|
327
|
+
suspendedPose: capture.suspendedPose
|
|
328
|
+
? {
|
|
329
|
+
surface: capture.suspendedPose.surface.toJSON(),
|
|
330
|
+
geometry: capture.suspendedPose.geometry
|
|
331
|
+
}
|
|
332
|
+
: null
|
|
333
|
+
}
|
|
334
|
+
: null;
|
|
335
|
+
}
|
|
336
|
+
matchesDestination(capture, destination) {
|
|
337
|
+
return (destination.origin === location.origin &&
|
|
338
|
+
!destination.hash &&
|
|
339
|
+
destination.pathname.replace(/\/$/, '') ===
|
|
340
|
+
`/${encodeURIComponent(capture.identity.brandId)}/elements/${encodeURIComponent(capture.identity.spatialElementId)}`);
|
|
341
|
+
}
|
|
342
|
+
createActor(identity, source, role, reverse) {
|
|
343
|
+
const paint = role === 'summary-surface' && reverse ? this.hooks.captureSurface?.(source) : undefined;
|
|
344
|
+
const projection = captureCarouselElement(source) ??
|
|
345
|
+
(role !== 'summary-surface' && reverse ? this.hooks.captureElement?.(source) : undefined);
|
|
346
|
+
const bounds = paint?.bounds ?? (role === 'summary-surface' ? this.hooks.resolveSurface(source) : source);
|
|
347
|
+
const from = bounds.getBoundingClientRect();
|
|
348
|
+
const style = getComputedStyle(role === 'summary-surface' && reverse ? bounds : source, role === 'summary-surface' && source.closest('[data-carousel-spatial-element]') ? '::before' : null);
|
|
349
|
+
const element = document.createElement('div');
|
|
350
|
+
element.dataset.catalogSharedKey = catalogSharedKey(identity, role);
|
|
351
|
+
element.dataset.catalogActorRole = role;
|
|
352
|
+
Object.assign(element.style, {
|
|
353
|
+
position: 'fixed',
|
|
354
|
+
left: `${from.left}px`,
|
|
355
|
+
top: `${from.top}px`,
|
|
356
|
+
width: `${from.width}px`,
|
|
357
|
+
height: `${from.height}px`,
|
|
358
|
+
margin: '0',
|
|
359
|
+
boxSizing: 'border-box',
|
|
360
|
+
pointerEvents: 'none',
|
|
361
|
+
transformOrigin: 'top left',
|
|
362
|
+
zIndex: role === 'summary-surface' ? '20' : '22',
|
|
363
|
+
willChange: 'transform, opacity'
|
|
364
|
+
});
|
|
365
|
+
if (role === 'summary-surface') {
|
|
366
|
+
Object.assign(element.style, {
|
|
367
|
+
background: paint?.background ?? style.backgroundColor,
|
|
368
|
+
border: paint?.border ?? style.border,
|
|
369
|
+
borderRadius: paint?.borderRadius ?? style.borderRadius,
|
|
370
|
+
boxShadow: paint?.boxShadow ?? style.boxShadow
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
else {
|
|
374
|
+
if (isRichRole(role))
|
|
375
|
+
copyRichContent(element, source);
|
|
376
|
+
else
|
|
377
|
+
element.textContent = source.textContent;
|
|
378
|
+
copyTypography(element, style);
|
|
379
|
+
Object.assign(element.style, {
|
|
380
|
+
fontFamily: style.fontFamily,
|
|
381
|
+
fontSize: style.fontSize,
|
|
382
|
+
fontWeight: style.fontWeight,
|
|
383
|
+
fontStyle: style.fontStyle,
|
|
384
|
+
lineHeight: style.lineHeight,
|
|
385
|
+
letterSpacing: style.letterSpacing,
|
|
386
|
+
textTransform: style.textTransform,
|
|
387
|
+
textAlign: style.textAlign,
|
|
388
|
+
color: style.color
|
|
389
|
+
});
|
|
390
|
+
}
|
|
391
|
+
const actor = {
|
|
392
|
+
semantic: source.dataset.catalogSemantic,
|
|
393
|
+
role,
|
|
394
|
+
element,
|
|
395
|
+
from,
|
|
396
|
+
fontSize: Number.parseFloat(style.fontSize),
|
|
397
|
+
corners: projection?.corners ?? paint?.corners,
|
|
398
|
+
layoutWidth: projection?.width,
|
|
399
|
+
layoutHeight: projection?.height
|
|
400
|
+
};
|
|
401
|
+
const corners = projection?.corners ?? paint?.corners;
|
|
402
|
+
if (corners) {
|
|
403
|
+
const local = corners.map((point) => ({
|
|
404
|
+
x: point.x - from.left,
|
|
405
|
+
y: point.y - from.top
|
|
406
|
+
}));
|
|
407
|
+
const width = projection?.width ?? from.width;
|
|
408
|
+
const height = projection?.height ?? from.height;
|
|
409
|
+
element.style.width = `${width}px`;
|
|
410
|
+
element.style.height = `${height}px`;
|
|
411
|
+
element.style.transform = getProjectiveCssMatrix3d(local, width, height) ?? '';
|
|
412
|
+
}
|
|
413
|
+
return actor;
|
|
414
|
+
}
|
|
415
|
+
contentEndpoints(brandId, requireSubmitted = true) {
|
|
416
|
+
return this.endpoints
|
|
417
|
+
.getContentEndpoints()
|
|
418
|
+
.filter((entry) => entry.address.brandId === brandId)
|
|
419
|
+
.map(({ address, element }) => {
|
|
420
|
+
let sectionId;
|
|
421
|
+
try {
|
|
422
|
+
sectionId = JSON.parse(address.occurrence ?? '[]')[0];
|
|
423
|
+
}
|
|
424
|
+
catch {
|
|
425
|
+
/* Legacy occurrence. */
|
|
426
|
+
}
|
|
427
|
+
return {
|
|
428
|
+
...address,
|
|
429
|
+
role: 'geometry',
|
|
430
|
+
sectionId,
|
|
431
|
+
order: Number(element.dataset.catalogOrder ?? 0),
|
|
432
|
+
eligible: address.slot === 'catalog.card' ? fullyPresented(element) : intersectsViewport(element),
|
|
433
|
+
prepared: !requireSubmitted || element.hasAttribute('data-catalog-model-ready'),
|
|
434
|
+
selected: address.slot === 'carousel.front',
|
|
435
|
+
focused: element.contains(document.activeElement)
|
|
436
|
+
};
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
capture(fromURL, toURL, type) {
|
|
440
|
+
const retained = this.captureState;
|
|
441
|
+
if (retained?.paused && retained.retarget) {
|
|
442
|
+
const journey = resolveCatalogJourney(fromURL, toURL, type);
|
|
443
|
+
if (journey?.kind === 'content-view') {
|
|
444
|
+
const context = type === 'popstate' ? {} : readCatalogViewContext(toURL);
|
|
445
|
+
const previousPairs = retained.view?.pairs ?? [];
|
|
446
|
+
const candidates = previousPairs.length
|
|
447
|
+
? previousPairs.map((pair) => pair.target)
|
|
448
|
+
: this.contentEndpoints(journey.brandId, false);
|
|
449
|
+
const source = candidates.find((p) => p.spatialElementId === retained.identity.spatialElementId && p.slot === retained.recipe.targetShared);
|
|
450
|
+
if (source && (!context.spatialElementId || context.spatialElementId === retained.identity.spatialElementId)) {
|
|
451
|
+
this.hooks.adoptContentParticipants?.(previousPairs);
|
|
452
|
+
retained.view = {
|
|
453
|
+
source,
|
|
454
|
+
sources: candidates.filter((p) => p.sectionId === source.sectionId),
|
|
455
|
+
context: {
|
|
456
|
+
...context,
|
|
457
|
+
spatialElementId: retained.identity.spatialElementId,
|
|
458
|
+
targetSection: journey.section ?? context.targetSection
|
|
459
|
+
}
|
|
460
|
+
};
|
|
461
|
+
retained.recipe = {
|
|
462
|
+
...retained.recipe,
|
|
463
|
+
source: source.slot,
|
|
464
|
+
id: source.slot === 'catalog.card' ? 'list-to-carousel' : 'carousel-to-list'
|
|
465
|
+
};
|
|
466
|
+
retained.owner = retained.lease.claim();
|
|
467
|
+
retained.token = this.sequence.begin();
|
|
468
|
+
retained.elapsed = 0;
|
|
469
|
+
retained.mode = undefined;
|
|
470
|
+
retained.backgroundPrepared = undefined;
|
|
471
|
+
retained.paused = false;
|
|
472
|
+
retained.retarget = false;
|
|
473
|
+
this.captureExitingContent(retained);
|
|
474
|
+
this.root.dataset.catalogDirection = 'return';
|
|
475
|
+
this.root.dataset.catalogRecipe = retained.recipe.id;
|
|
476
|
+
this.root.dataset.catalogOwnershipRevision = String(retained.lease.revision);
|
|
477
|
+
this.setPresentation({ active: true, exitOpacity: 1, enterOpacity: 0, sharedOpacity: 0 });
|
|
478
|
+
return false;
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
const intent = resolveCatalogIntent(fromURL, toURL, type);
|
|
482
|
+
const reverse = intent?.direction === 'detail-to-list';
|
|
483
|
+
const content = retained.recipe.source.startsWith('carousel.') ||
|
|
484
|
+
retained.recipe.targetShared.startsWith('carousel.')
|
|
485
|
+
? 'carousel'
|
|
486
|
+
: 'list';
|
|
487
|
+
const recipe = selectCatalogRecipe(intent, reverse ? (retained.recipe.targetShared === 'detail.dock' ? 'dock' : 'hero') : content, reverse ? content : 'hero');
|
|
488
|
+
if (recipe) {
|
|
489
|
+
retained.view = undefined;
|
|
490
|
+
this.hooks.adoptContentParticipants?.([]);
|
|
491
|
+
retained.owner = retained.lease.claim();
|
|
492
|
+
retained.token = this.sequence.begin();
|
|
493
|
+
retained.recipe = recipe;
|
|
494
|
+
retained.elapsed = 0;
|
|
495
|
+
retained.mode = undefined;
|
|
496
|
+
retained.backgroundPrepared = undefined;
|
|
497
|
+
retained.paused = false;
|
|
498
|
+
retained.retarget = false;
|
|
499
|
+
this.captureExitingContent(retained);
|
|
500
|
+
this.root.dataset.catalogDirection = reverse ? 'return' : 'forward';
|
|
501
|
+
this.root.dataset.catalogRecipe = recipe.id;
|
|
502
|
+
this.root.dataset.catalogOwnershipRevision = String(retained.lease.revision);
|
|
503
|
+
this.setPresentation({ active: true, exitOpacity: 1, enterOpacity: 0, sharedOpacity: 0 });
|
|
504
|
+
return false;
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
if (retained?.paused &&
|
|
508
|
+
retained.mode &&
|
|
509
|
+
type !== 'popstate' &&
|
|
510
|
+
this.matchesDestination(retained, toURL)) {
|
|
511
|
+
retained.token = this.sequence.begin();
|
|
512
|
+
retained.owner = retained.lease.claim();
|
|
513
|
+
this.root.dataset.catalogOwnershipRevision = String(retained.lease.revision);
|
|
514
|
+
return true;
|
|
515
|
+
}
|
|
516
|
+
this.cancel();
|
|
517
|
+
const journey = resolveCatalogJourney(fromURL, toURL, type);
|
|
518
|
+
const context = type === 'popstate' ? {} : readCatalogViewContext(toURL);
|
|
519
|
+
const inventory = journey?.kind === 'content-view' ? this.contentEndpoints(journey.brandId) : [];
|
|
520
|
+
const sourcePairs = planCatalogParticipants(inventory, inventory, {
|
|
521
|
+
spatialElementId: context.spatialElementId,
|
|
522
|
+
sourceSection: context.sourceSection,
|
|
523
|
+
sourceOccurrence: context.sourceOccurrence
|
|
524
|
+
}, 5);
|
|
525
|
+
const primary = sourcePairs[0];
|
|
526
|
+
const view = journey?.kind === 'content-view' && primary
|
|
527
|
+
? {
|
|
528
|
+
source: primary.source,
|
|
529
|
+
sources: sourcePairs.map((pair) => pair.source),
|
|
530
|
+
context: { ...context, targetSection: journey.section ?? context.targetSection }
|
|
531
|
+
}
|
|
532
|
+
: undefined;
|
|
533
|
+
if (journey?.kind === 'content-view' && !view)
|
|
534
|
+
return;
|
|
535
|
+
if (view)
|
|
536
|
+
this.endpoints.prefer(view.source.brandId, view.source.spatialElementId, view.source.occurrence, view.source.slot);
|
|
537
|
+
const intent = view
|
|
538
|
+
? {
|
|
539
|
+
identity: primary.identity,
|
|
540
|
+
direction: 'list-to-detail',
|
|
541
|
+
history: type === 'popstate',
|
|
542
|
+
target: 'hero'
|
|
543
|
+
}
|
|
544
|
+
: resolveCatalogIntent(fromURL, toURL, type);
|
|
545
|
+
const reverse = intent?.direction === 'detail-to-list';
|
|
546
|
+
const contentSlot = intent
|
|
547
|
+
? reverse
|
|
548
|
+
? this.endpoints.getPreferredContentSlot(intent.identity)
|
|
549
|
+
: this.endpoints.getContentSlot(intent.identity)
|
|
550
|
+
: undefined;
|
|
551
|
+
const composition = reverse && intent
|
|
552
|
+
? this.endpoints.getComposition(intent.identity)
|
|
553
|
+
: contentSlot?.startsWith('carousel.')
|
|
554
|
+
? 'carousel'
|
|
555
|
+
: contentSlot === 'catalog.card'
|
|
556
|
+
? 'list'
|
|
557
|
+
: 'unavailable';
|
|
558
|
+
const recipe = view
|
|
559
|
+
? {
|
|
560
|
+
id: view.source.slot === 'catalog.card' ? 'list-to-carousel' : 'carousel-to-list',
|
|
561
|
+
identity: primary.identity,
|
|
562
|
+
source: view.source.slot,
|
|
563
|
+
targetGeometry: view.source.slot === 'catalog.card' ? 'carousel.front' : 'catalog.card',
|
|
564
|
+
targetShared: view.source.slot === 'catalog.card' ? 'carousel.front' : 'catalog.card',
|
|
565
|
+
roles: ['summary-surface', 'eyebrow', 'title']
|
|
566
|
+
}
|
|
567
|
+
: selectCatalogRecipe(intent, composition, reverse ? (contentSlot?.startsWith('carousel.') ? 'carousel' : 'list') : 'hero');
|
|
568
|
+
if (recipe && !reverse && contentSlot === 'carousel.neighbour') {
|
|
569
|
+
recipe.source = contentSlot;
|
|
570
|
+
recipe.roles = [];
|
|
571
|
+
}
|
|
572
|
+
if (!recipe || matchMedia('(prefers-reduced-motion: reduce)').matches)
|
|
573
|
+
return;
|
|
574
|
+
const identity = recipe.identity;
|
|
575
|
+
const dock = recipe.source === 'detail.dock';
|
|
576
|
+
const source = { ...identity, slot: recipe.source };
|
|
577
|
+
const card = this.endpoints.resolve({
|
|
578
|
+
...source,
|
|
579
|
+
role: reverse ? 'summary-surface' : 'container'
|
|
580
|
+
});
|
|
581
|
+
if (!card ||
|
|
582
|
+
!this.endpoints.resolve({
|
|
583
|
+
...source,
|
|
584
|
+
slot: reverse && !dock ? 'detail.hero' : source.slot,
|
|
585
|
+
role: 'geometry'
|
|
586
|
+
}))
|
|
587
|
+
return;
|
|
588
|
+
if (reverse)
|
|
589
|
+
recipe.roles = recipe.roles.filter((role) => {
|
|
590
|
+
const element = this.endpoints.resolve({ ...source, role });
|
|
591
|
+
// During docking the hero remains the geometry source. Do not resurrect
|
|
592
|
+
// already clipped summary pieces just to retain their semantic roles.
|
|
593
|
+
return (element &&
|
|
594
|
+
visiblyPresented(element) &&
|
|
595
|
+
(composition !== 'intermediate' || fullyPresented(element)));
|
|
596
|
+
});
|
|
597
|
+
recipe.roles = recipe.roles.filter((role) => !isRichRole(role) || this.endpoints.resolve({ ...source, role }));
|
|
598
|
+
const sources = recipe.roles.map((role) => this.endpoints.resolve({ ...source, role }));
|
|
599
|
+
if (sources.some((element) => !element || !hasSize(element.getBoundingClientRect())))
|
|
600
|
+
return;
|
|
601
|
+
if (!reverse && !(composition === 'carousel' ? visiblyPresented(card) : fullyPresented(card)))
|
|
602
|
+
return;
|
|
603
|
+
if (reverse && sources.some((element) => element && !fullyPresented(element)))
|
|
604
|
+
return;
|
|
605
|
+
try {
|
|
606
|
+
const endpoint = geometryEndpoint({
|
|
607
|
+
...source,
|
|
608
|
+
slot: reverse && !dock ? 'detail.hero' : source.slot
|
|
609
|
+
});
|
|
610
|
+
if (view
|
|
611
|
+
? !this.hooks.captureContentGeometry?.(view.source, view.sources.slice(1))
|
|
612
|
+
: !this.hooks.captureGeometry(endpoint))
|
|
613
|
+
return;
|
|
614
|
+
const token = this.sequence.begin();
|
|
615
|
+
const host = document.createElement('div');
|
|
616
|
+
host.dataset.catalogTransitionActors = '';
|
|
617
|
+
host.setAttribute('aria-hidden', 'true');
|
|
618
|
+
host.inert = true;
|
|
619
|
+
// The host must not form a stacking context: surface < GPU overlay < text.
|
|
620
|
+
host.style.pointerEvents = 'none';
|
|
621
|
+
const capture = {
|
|
622
|
+
view,
|
|
623
|
+
captureShell: !reverse && (intent?.history || intent?.target === 'section'),
|
|
624
|
+
elapsed: 0,
|
|
625
|
+
token,
|
|
626
|
+
identity,
|
|
627
|
+
recipe,
|
|
628
|
+
host,
|
|
629
|
+
actors: [],
|
|
630
|
+
exiting: [],
|
|
631
|
+
restore: [],
|
|
632
|
+
frame: 0,
|
|
633
|
+
inert: new Map(),
|
|
634
|
+
timeout: setTimeout(() => {
|
|
635
|
+
if (this.captureState === capture)
|
|
636
|
+
this.cancel();
|
|
637
|
+
}, 5000)
|
|
638
|
+
};
|
|
639
|
+
this.captureState = capture;
|
|
640
|
+
capture.lease = new PresentationLease(capture, () => this.cleanup());
|
|
641
|
+
capture.owner = capture.lease.claim();
|
|
642
|
+
for (let index = 0; index < recipe.roles.length; index++) {
|
|
643
|
+
const actor = this.createActor(identity, sources[index], recipe.roles[index], reverse);
|
|
644
|
+
capture.actors.push(actor);
|
|
645
|
+
host.appendChild(actor.element);
|
|
646
|
+
}
|
|
647
|
+
if (capture.view && !capture.view.context.spatialElementId) {
|
|
648
|
+
capture.view.alternates = new Map();
|
|
649
|
+
for (const endpoint of capture.view.sources.slice(1)) {
|
|
650
|
+
const actors = [];
|
|
651
|
+
for (const role of ['summary-surface', 'eyebrow', 'title']) {
|
|
652
|
+
const element = this.endpoints.resolve({ ...endpoint, role });
|
|
653
|
+
if (element && visiblyPresented(element))
|
|
654
|
+
actors.push(this.createActor(endpoint, element, role, false));
|
|
655
|
+
}
|
|
656
|
+
capture.view.alternates.set(endpoint.occurrence, actors);
|
|
657
|
+
}
|
|
658
|
+
this.endpoints.prefer(identity.brandId, identity.spatialElementId, capture.view.source.occurrence, capture.view.source.slot);
|
|
659
|
+
}
|
|
660
|
+
document.body.appendChild(host);
|
|
661
|
+
if (reverse) {
|
|
662
|
+
for (const source of sources) {
|
|
663
|
+
if (source === card)
|
|
664
|
+
continue;
|
|
665
|
+
preserveStyle(source, 'visibility', capture.restore);
|
|
666
|
+
source.style.setProperty('visibility', 'hidden', 'important');
|
|
667
|
+
}
|
|
668
|
+
this.captureExitingContent(capture);
|
|
669
|
+
}
|
|
670
|
+
preserveStyle(card, 'visibility', capture.restore);
|
|
671
|
+
card.style.setProperty('visibility', 'hidden', 'important');
|
|
672
|
+
if (!reverse)
|
|
673
|
+
this.captureExitingContent(capture);
|
|
674
|
+
this.root.dataset.catalogDirection = reverse || view ? 'return' : 'forward';
|
|
675
|
+
this.setPresentation({ active: true, exitOpacity: 1, enterOpacity: 0, sharedOpacity: 0 });
|
|
676
|
+
this.root.dataset.catalogTransition = 'captured';
|
|
677
|
+
this.root.dataset.catalogRecipe = recipe.id;
|
|
678
|
+
this.root.dataset.catalogOwnershipRevision = String(capture.lease.revision);
|
|
679
|
+
this.lockParticipants(capture);
|
|
680
|
+
capture.observer = new MutationObserver(() => this.lockParticipants(capture));
|
|
681
|
+
capture.observer.observe(this.root, { childList: true, subtree: true });
|
|
682
|
+
window.addEventListener('resize', this.interrupt, { passive: true });
|
|
683
|
+
window.addEventListener('wheel', this.interrupt, { passive: true, capture: true });
|
|
684
|
+
window.addEventListener('touchmove', this.interrupt, { passive: true, capture: true });
|
|
685
|
+
window.addEventListener('keydown', this.keydown);
|
|
686
|
+
}
|
|
687
|
+
catch {
|
|
688
|
+
this.cancel();
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
/** Keep only decorative outgoing DOM; Kit can mount and measure the real destination now. */
|
|
692
|
+
captureExitingContent(capture) {
|
|
693
|
+
const selector = isReturnRecipe(capture.recipe)
|
|
694
|
+
? '[data-catalog-transition-dom="enter"], [data-catalog-transition-group="enter"], [data-catalog-secondary]'
|
|
695
|
+
: `[data-catalog-transition-dom="exit"]${capture.captureShell ? ', [data-catalog-shell]' : ''}`;
|
|
696
|
+
for (const source of this.root.querySelectorAll(selector)) {
|
|
697
|
+
if (source.parentElement?.closest(selector))
|
|
698
|
+
continue;
|
|
699
|
+
if (capture.actors.some((actor) => actor.role ===
|
|
700
|
+
source.closest('[data-catalog-rich-shared]')?.dataset.catalogRichShared))
|
|
701
|
+
continue;
|
|
702
|
+
const rect = source.getBoundingClientRect();
|
|
703
|
+
if (!hasSize(rect) || rect.bottom <= 0 || rect.top >= window.innerHeight)
|
|
704
|
+
continue;
|
|
705
|
+
if (!visiblyPresented(source))
|
|
706
|
+
continue;
|
|
707
|
+
const copy = source.cloneNode(true);
|
|
708
|
+
const style = getComputedStyle(source);
|
|
709
|
+
const originals = [source, ...source.querySelectorAll('*')];
|
|
710
|
+
const copies = [copy, ...copy.querySelectorAll('*')];
|
|
711
|
+
for (let index = 0; index < originals.length; index++) {
|
|
712
|
+
const computed = getComputedStyle(originals[index]);
|
|
713
|
+
for (const property of computed)
|
|
714
|
+
copies[index].style.setProperty(property, computed.getPropertyValue(property));
|
|
715
|
+
}
|
|
716
|
+
for (const element of [copy, ...copy.querySelectorAll('*')]) {
|
|
717
|
+
element.removeAttribute('id');
|
|
718
|
+
for (const attribute of [...element.attributes]) {
|
|
719
|
+
if (attribute.name.startsWith('data-') &&
|
|
720
|
+
attribute.name !== 'data-catalog-model-ready' &&
|
|
721
|
+
attribute.name !== 'data-catalog-poster' &&
|
|
722
|
+
![
|
|
723
|
+
'data-stage-panel-content',
|
|
724
|
+
'data-stage-panel-css-surface',
|
|
725
|
+
'data-stage-panel-render-mode',
|
|
726
|
+
'data-stage-panel-surface'
|
|
727
|
+
].includes(attribute.name))
|
|
728
|
+
element.removeAttribute(attribute.name);
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
for (let index = 0; index < originals.length; index++) {
|
|
732
|
+
const original = originals[index];
|
|
733
|
+
if (original.matches('[data-catalog-card], [data-carousel-spatial-element]'))
|
|
734
|
+
copies[index].dataset.catalogExitOccurrence = original.dataset.catalogOccurrence;
|
|
735
|
+
}
|
|
736
|
+
copy.dataset.catalogExitCopy = '';
|
|
737
|
+
copy.dataset.catalogBaseOpacity = style.opacity;
|
|
738
|
+
if (source.hasAttribute('data-catalog-shell'))
|
|
739
|
+
copy.dataset.catalogShellCopy = '';
|
|
740
|
+
copy.setAttribute('aria-hidden', 'true');
|
|
741
|
+
copy.inert = true;
|
|
742
|
+
Object.assign(copy.style, {
|
|
743
|
+
position: 'fixed',
|
|
744
|
+
left: `${rect.left}px`,
|
|
745
|
+
top: `${rect.top}px`,
|
|
746
|
+
width: `${rect.width}px`,
|
|
747
|
+
height: `${rect.height}px`,
|
|
748
|
+
margin: '0',
|
|
749
|
+
transform: 'none',
|
|
750
|
+
zIndex: source.hasAttribute('data-catalog-secondary') ? '22' : '2',
|
|
751
|
+
pointerEvents: 'none',
|
|
752
|
+
transition: 'none',
|
|
753
|
+
animation: 'none',
|
|
754
|
+
willChange: 'opacity'
|
|
755
|
+
});
|
|
756
|
+
const projection = this.hooks.captureElement?.(source);
|
|
757
|
+
if (projection) {
|
|
758
|
+
const corners = projection.corners.map((point) => ({
|
|
759
|
+
x: point.x - rect.left,
|
|
760
|
+
y: point.y - rect.top
|
|
761
|
+
}));
|
|
762
|
+
Object.assign(copy.style, {
|
|
763
|
+
width: `${projection.width}px`,
|
|
764
|
+
height: `${projection.height}px`,
|
|
765
|
+
transformOrigin: 'top left',
|
|
766
|
+
transform: getProjectiveCssMatrix3d(corners, projection.width, projection.height) ?? 'none'
|
|
767
|
+
});
|
|
768
|
+
}
|
|
769
|
+
this.root.appendChild(copy);
|
|
770
|
+
capture.exiting.push(copy);
|
|
771
|
+
const panel = capture.actors.find((actor) => actor.role === 'summary-surface');
|
|
772
|
+
if (panel && source.closest('[data-spatial-element-hero-panel-content]')) {
|
|
773
|
+
(capture.panelContent ??= []).push({
|
|
774
|
+
element: copy,
|
|
775
|
+
rect,
|
|
776
|
+
panel: panel.from,
|
|
777
|
+
incoming: false
|
|
778
|
+
});
|
|
779
|
+
}
|
|
780
|
+
preserveStyle(source, 'visibility', capture.restore);
|
|
781
|
+
source.style.setProperty('visibility', 'hidden', 'important');
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
lockParticipants(capture) {
|
|
785
|
+
if (!this.sequence.isCurrent(capture.token))
|
|
786
|
+
return;
|
|
787
|
+
for (const element of this.root.querySelectorAll('[data-catalog-transition-dom], [data-catalog-transition-group]')) {
|
|
788
|
+
if (capture.inert.has(element))
|
|
789
|
+
continue;
|
|
790
|
+
capture.inert.set(element, element.inert);
|
|
791
|
+
element.inert = true;
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
setPresentation(presentation) {
|
|
795
|
+
for (const channel of ['enter', 'exit', 'shared']) {
|
|
796
|
+
const value = presentation[`${channel}Opacity`];
|
|
797
|
+
if (presentation.active) {
|
|
798
|
+
this.root.style.setProperty(`--catalog-${channel}-opacity`, String(value));
|
|
799
|
+
}
|
|
800
|
+
else
|
|
801
|
+
this.root.style.removeProperty(`--catalog-${channel}-opacity`);
|
|
802
|
+
this.root.toggleAttribute(`data-catalog-${channel}-hidden`, presentation.active && value === 0);
|
|
803
|
+
}
|
|
804
|
+
for (const copy of this.captureState?.exiting ?? []) {
|
|
805
|
+
copy.style.opacity = String(copy.hasAttribute('data-catalog-shell-copy') &&
|
|
806
|
+
this.captureState?.recipe.targetGeometry !== 'detail.dock'
|
|
807
|
+
? 1
|
|
808
|
+
: presentation.exitOpacity * Number(copy.dataset.catalogBaseOpacity ?? 1));
|
|
809
|
+
}
|
|
810
|
+
this.hooks.setPresentation(presentation);
|
|
811
|
+
}
|
|
812
|
+
/** Call only after destination registration and scroll restoration have completed. */
|
|
813
|
+
async play() {
|
|
814
|
+
const capture = this.captureState;
|
|
815
|
+
if (!capture || !this.sequence.start(capture.token))
|
|
816
|
+
return;
|
|
817
|
+
try {
|
|
818
|
+
const reverse = Boolean(capture.view) || isReturnRecipe(capture.recipe);
|
|
819
|
+
if (capture.view) {
|
|
820
|
+
const pairs = planCatalogParticipants(capture.view.sources, this.contentEndpoints(capture.identity.brandId, false), capture.view.context, 5);
|
|
821
|
+
capture.view.pairs = pairs;
|
|
822
|
+
const pair = pairs[0];
|
|
823
|
+
if (!pair ||
|
|
824
|
+
pair.source.slot === pair.target.slot ||
|
|
825
|
+
(pair.source.slot.startsWith('carousel.') && pair.target.slot.startsWith('carousel.'))) {
|
|
826
|
+
this.cancel();
|
|
827
|
+
return;
|
|
828
|
+
}
|
|
829
|
+
if (pair.identity.spatialElementId !== capture.identity.spatialElementId) {
|
|
830
|
+
const actors = capture.view.alternates?.get(pair.source.occurrence);
|
|
831
|
+
if (!actors || !this.hooks.promoteContentParticipant?.(pair.source)) {
|
|
832
|
+
this.cancel();
|
|
833
|
+
return;
|
|
834
|
+
}
|
|
835
|
+
for (const actor of capture.actors)
|
|
836
|
+
capture.exiting.push(actor.element);
|
|
837
|
+
capture.actors = actors;
|
|
838
|
+
for (const actor of actors)
|
|
839
|
+
capture.host.appendChild(actor.element);
|
|
840
|
+
for (const element of capture.host.querySelectorAll('[data-catalog-exit-occurrence]'))
|
|
841
|
+
if (element.dataset.catalogExitOccurrence === pair.source.occurrence)
|
|
842
|
+
element.style.opacity = '0';
|
|
843
|
+
capture.identity = pair.identity;
|
|
844
|
+
capture.recipe.identity = pair.identity;
|
|
845
|
+
capture.recipe.source = pair.source.slot;
|
|
846
|
+
capture.recipe.roles = actors.map((actor) => actor.role);
|
|
847
|
+
capture.view.source = pair.source;
|
|
848
|
+
}
|
|
849
|
+
this.endpoints.prefer(pair.target.brandId, pair.target.spatialElementId, pair.target.occurrence, pair.target.slot);
|
|
850
|
+
capture.recipe.targetGeometry = capture.recipe.targetShared = pair.target.slot;
|
|
851
|
+
if (pair.target.slot === 'carousel.neighbour') {
|
|
852
|
+
for (const actor of capture.actors)
|
|
853
|
+
capture.exiting.push(actor.element);
|
|
854
|
+
capture.actors = [];
|
|
855
|
+
capture.recipe.roles = [];
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
else if (reverse) {
|
|
859
|
+
const slot = this.endpoints.getContentSlot(capture.identity);
|
|
860
|
+
if (!slot) {
|
|
861
|
+
this.cancel();
|
|
862
|
+
return;
|
|
863
|
+
}
|
|
864
|
+
capture.recipe = {
|
|
865
|
+
...capture.recipe,
|
|
866
|
+
id: slot.startsWith('carousel.')
|
|
867
|
+
? capture.recipe.source === 'detail.dock'
|
|
868
|
+
? 'dock-to-carousel'
|
|
869
|
+
: 'hero-to-carousel'
|
|
870
|
+
: capture.recipe.source === 'detail.dock'
|
|
871
|
+
? 'dock-to-list'
|
|
872
|
+
: 'hero-to-list',
|
|
873
|
+
targetGeometry: slot,
|
|
874
|
+
targetShared: slot
|
|
875
|
+
};
|
|
876
|
+
if (slot === 'carousel.neighbour') {
|
|
877
|
+
for (const actor of capture.actors) {
|
|
878
|
+
capture.exiting.push(actor.element);
|
|
879
|
+
actor.destinationCopy?.remove();
|
|
880
|
+
}
|
|
881
|
+
capture.actors = [];
|
|
882
|
+
capture.recipe.roles = [];
|
|
883
|
+
}
|
|
884
|
+
this.root.dataset.catalogRecipe = capture.recipe.id;
|
|
885
|
+
}
|
|
886
|
+
else {
|
|
887
|
+
const composition = this.endpoints.getComposition(capture.identity);
|
|
888
|
+
if (composition !== 'hero' && composition !== 'intermediate' && composition !== 'dock') {
|
|
889
|
+
this.cancel();
|
|
890
|
+
return;
|
|
891
|
+
}
|
|
892
|
+
capture.recipe = {
|
|
893
|
+
...capture.recipe,
|
|
894
|
+
id: composition === 'dock'
|
|
895
|
+
? capture.recipe.source.startsWith('carousel.')
|
|
896
|
+
? 'carousel-to-dock'
|
|
897
|
+
: 'list-to-dock'
|
|
898
|
+
: capture.recipe.source.startsWith('carousel.')
|
|
899
|
+
? 'carousel-to-hero'
|
|
900
|
+
: 'list-to-hero',
|
|
901
|
+
targetGeometry: composition === 'dock' ? 'detail.dock' : 'detail.hero',
|
|
902
|
+
targetShared: composition === 'dock' ? 'detail.dock' : 'detail.summary'
|
|
903
|
+
};
|
|
904
|
+
this.root.dataset.catalogRecipe = capture.recipe.id;
|
|
905
|
+
}
|
|
906
|
+
const page = this.root.querySelector('[data-spatial-element-root]');
|
|
907
|
+
if ((!reverse && page?.dataset.spatialElementId !== capture.identity.spatialElementId) ||
|
|
908
|
+
!this.endpoints.resolve({
|
|
909
|
+
...capture.identity,
|
|
910
|
+
slot: capture.recipe.targetGeometry,
|
|
911
|
+
role: 'geometry'
|
|
912
|
+
})) {
|
|
913
|
+
this.cancel();
|
|
914
|
+
return;
|
|
915
|
+
}
|
|
916
|
+
if (this.hooks.prepareDestination?.({
|
|
917
|
+
spatialElementId: capture.identity.spatialElementId,
|
|
918
|
+
kind: reverse ? 'content' : capture.recipe.targetGeometry === 'detail.dock' ? 'dock' : 'hero'
|
|
919
|
+
}) === false) {
|
|
920
|
+
this.cancel();
|
|
921
|
+
return;
|
|
922
|
+
}
|
|
923
|
+
if (capture.view) {
|
|
924
|
+
const prepared = this.hooks.prepareContentParticipants?.(capture.view.pairs ?? []) ?? [];
|
|
925
|
+
for (const pair of prepared) {
|
|
926
|
+
const geometry = this.endpoints.resolve({ ...pair.target, role: 'geometry' });
|
|
927
|
+
if (!geometry)
|
|
928
|
+
continue;
|
|
929
|
+
preserveStyle(geometry, 'visibility', capture.restore);
|
|
930
|
+
geometry.style.setProperty('visibility', 'hidden', 'important');
|
|
931
|
+
}
|
|
932
|
+
// Remove prepared target pixels before yielding to the first moving frame.
|
|
933
|
+
this.hooks.flushFrame();
|
|
934
|
+
}
|
|
935
|
+
if (reverse) {
|
|
936
|
+
const card = this.endpoints.resolve({
|
|
937
|
+
...capture.identity,
|
|
938
|
+
slot: capture.recipe.targetShared,
|
|
939
|
+
role: 'container'
|
|
940
|
+
});
|
|
941
|
+
if (!card ||
|
|
942
|
+
!(capture.recipe.targetShared.startsWith('carousel.')
|
|
943
|
+
? intersectsViewport(card)
|
|
944
|
+
: fullyPresented(card))) {
|
|
945
|
+
this.cancel();
|
|
946
|
+
return;
|
|
947
|
+
}
|
|
948
|
+
if (capture.actors.length) {
|
|
949
|
+
preserveStyle(card, 'visibility', capture.restore);
|
|
950
|
+
card.style.setProperty('visibility', 'hidden', 'important');
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
const measuredTargets = new Map();
|
|
954
|
+
const sharedTargets = new Set();
|
|
955
|
+
for (const actor of capture.actors) {
|
|
956
|
+
let target = this.endpoints.resolve({
|
|
957
|
+
...capture.identity,
|
|
958
|
+
slot: capture.recipe.targetShared,
|
|
959
|
+
role: actor.role
|
|
960
|
+
});
|
|
961
|
+
const missingRich = !target && isRichRole(actor.role);
|
|
962
|
+
if (missingRich) {
|
|
963
|
+
target = this.endpoints.resolve({
|
|
964
|
+
...capture.identity,
|
|
965
|
+
slot: capture.recipe.targetShared,
|
|
966
|
+
role: 'summary-surface'
|
|
967
|
+
});
|
|
968
|
+
actor.sourceOnly = true;
|
|
969
|
+
}
|
|
970
|
+
if (!target) {
|
|
971
|
+
this.cancel();
|
|
972
|
+
return;
|
|
973
|
+
}
|
|
974
|
+
const bounds = actor.role === 'summary-surface' ? this.hooks.resolveSurface(target) : target;
|
|
975
|
+
sharedTargets.add(target);
|
|
976
|
+
const targetRect = bounds.getBoundingClientRect();
|
|
977
|
+
if (capture.paused &&
|
|
978
|
+
actor.to &&
|
|
979
|
+
['x', 'y', 'width', 'height'].some((key) => Math.abs(targetRect[key] -
|
|
980
|
+
actor.to[key]) > 0.5)) {
|
|
981
|
+
this.cancel();
|
|
982
|
+
return;
|
|
983
|
+
}
|
|
984
|
+
actor.to = targetRect;
|
|
985
|
+
if (missingRich) {
|
|
986
|
+
const panel = capture.actors.find((item) => item.role === 'summary-surface');
|
|
987
|
+
const sx = targetRect.width / panel.from.width, sy = targetRect.height / panel.from.height;
|
|
988
|
+
actor.to = new DOMRect(targetRect.left + (actor.from.left - panel.from.left) * sx, targetRect.top + (actor.from.top - panel.from.top) * sy, actor.from.width * sx, actor.from.height * sy);
|
|
989
|
+
}
|
|
990
|
+
if (isRichRole(actor.role))
|
|
991
|
+
actor.element.dataset.catalogContentMatch =
|
|
992
|
+
actor.semantic && actor.semantic === target.dataset.catalogSemantic
|
|
993
|
+
? 'shared'
|
|
994
|
+
: 'replaced';
|
|
995
|
+
measuredTargets.set(bounds, targetRect);
|
|
996
|
+
if (!hasSize(actor.to)) {
|
|
997
|
+
this.cancel();
|
|
998
|
+
return;
|
|
999
|
+
}
|
|
1000
|
+
actor.fontScale =
|
|
1001
|
+
Number.parseFloat(getComputedStyle(target).fontSize) / actor.fontSize || 1;
|
|
1002
|
+
if (!actor.sourceOnly && !actor.destinationCopy) {
|
|
1003
|
+
// Keep both text layouts fixed. Crossfade their typography instead of stretching
|
|
1004
|
+
// the source line width beyond the destination panel or recomputing layout every frame.
|
|
1005
|
+
const copy = document.createElement('div');
|
|
1006
|
+
copy.style.cssText = actor.element.style.cssText;
|
|
1007
|
+
if (actor.role !== 'summary-surface') {
|
|
1008
|
+
if (isRichRole(actor.role))
|
|
1009
|
+
copyRichContent(copy, target);
|
|
1010
|
+
else
|
|
1011
|
+
copy.textContent = target.textContent;
|
|
1012
|
+
copyTypography(copy, getComputedStyle(target));
|
|
1013
|
+
}
|
|
1014
|
+
else {
|
|
1015
|
+
const paint = this.hooks.captureSurface?.(target);
|
|
1016
|
+
const style = getComputedStyle(target, target.closest('[data-carousel-spatial-element]') ? '::before' : null);
|
|
1017
|
+
Object.assign(copy.style, {
|
|
1018
|
+
background: paint?.background ?? style.backgroundColor,
|
|
1019
|
+
border: paint?.border ?? style.border,
|
|
1020
|
+
borderRadius: paint?.borderRadius ?? style.borderRadius,
|
|
1021
|
+
boxShadow: paint?.boxShadow ?? style.boxShadow
|
|
1022
|
+
});
|
|
1023
|
+
}
|
|
1024
|
+
copy.style.width = `${actor.to.width}px`;
|
|
1025
|
+
copy.style.height = `${actor.to.height}px`;
|
|
1026
|
+
copy.style.opacity = '0';
|
|
1027
|
+
copy.style.overflow = 'hidden';
|
|
1028
|
+
copy.dataset.catalogActorRole = actor.role;
|
|
1029
|
+
copy.dataset.catalogActorVariant = 'destination';
|
|
1030
|
+
capture.host.appendChild(copy);
|
|
1031
|
+
actor.destinationCopy = copy;
|
|
1032
|
+
}
|
|
1033
|
+
if (actor.role === 'summary-surface') {
|
|
1034
|
+
capture.content = target;
|
|
1035
|
+
if (!capture.panelContent?.some((entry) => entry.incoming)) {
|
|
1036
|
+
for (const source of target.querySelectorAll('[data-catalog-secondary]')) {
|
|
1037
|
+
if (capture.actors.some((actor) => actor.role ===
|
|
1038
|
+
source.closest('[data-catalog-rich-shared]')?.dataset
|
|
1039
|
+
.catalogRichShared))
|
|
1040
|
+
continue;
|
|
1041
|
+
const rect = source.getBoundingClientRect();
|
|
1042
|
+
const copy = source.cloneNode(true);
|
|
1043
|
+
const originals = [source, ...source.querySelectorAll('*')];
|
|
1044
|
+
const copies = [copy, ...copy.querySelectorAll('*')];
|
|
1045
|
+
for (let index = 0; index < originals.length; index++) {
|
|
1046
|
+
const style = getComputedStyle(originals[index]);
|
|
1047
|
+
for (const property of style)
|
|
1048
|
+
copies[index].style.setProperty(property, style.getPropertyValue(property));
|
|
1049
|
+
// The live destination is deliberately masked during binding.
|
|
1050
|
+
copies[index].style.visibility = 'visible';
|
|
1051
|
+
}
|
|
1052
|
+
for (const element of [copy, ...copy.querySelectorAll('*')]) {
|
|
1053
|
+
element.removeAttribute('id');
|
|
1054
|
+
for (const attribute of [...element.attributes])
|
|
1055
|
+
if (attribute.name.startsWith('data-'))
|
|
1056
|
+
element.removeAttribute(attribute.name);
|
|
1057
|
+
}
|
|
1058
|
+
copy.inert = true;
|
|
1059
|
+
copy.setAttribute('aria-hidden', 'true');
|
|
1060
|
+
copy.dataset.catalogPanelContent = '';
|
|
1061
|
+
Object.assign(copy.style, {
|
|
1062
|
+
position: 'fixed',
|
|
1063
|
+
left: '0',
|
|
1064
|
+
top: '0',
|
|
1065
|
+
width: `${rect.width}px`,
|
|
1066
|
+
height: `${rect.height}px`,
|
|
1067
|
+
margin: '0',
|
|
1068
|
+
transformOrigin: 'top left',
|
|
1069
|
+
opacity: '0',
|
|
1070
|
+
visibility: 'visible',
|
|
1071
|
+
zIndex: '22',
|
|
1072
|
+
pointerEvents: 'none',
|
|
1073
|
+
transition: 'none',
|
|
1074
|
+
animation: 'none'
|
|
1075
|
+
});
|
|
1076
|
+
capture.host.appendChild(copy);
|
|
1077
|
+
(capture.panelContent ??= []).push({
|
|
1078
|
+
element: copy,
|
|
1079
|
+
rect,
|
|
1080
|
+
panel: targetRect,
|
|
1081
|
+
incoming: true
|
|
1082
|
+
});
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
for (const target of sharedTargets) {
|
|
1088
|
+
preserveStyle(target, 'visibility', capture.restore);
|
|
1089
|
+
target.style.setProperty('visibility', 'hidden', 'important');
|
|
1090
|
+
}
|
|
1091
|
+
const content = capture.content;
|
|
1092
|
+
capture.layoutObserver?.disconnect();
|
|
1093
|
+
capture.layoutObserver = new ResizeObserver(() => {
|
|
1094
|
+
if (this.captureState !== capture || capture.paused)
|
|
1095
|
+
return;
|
|
1096
|
+
for (const [element, rect] of measuredTargets) {
|
|
1097
|
+
const current = element.getBoundingClientRect();
|
|
1098
|
+
if (Math.abs(current.width - rect.width) > 1 ||
|
|
1099
|
+
Math.abs(current.height - rect.height) > 1) {
|
|
1100
|
+
this.cancel();
|
|
1101
|
+
return;
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
});
|
|
1105
|
+
for (const element of measuredTargets.keys())
|
|
1106
|
+
capture.layoutObserver.observe(element);
|
|
1107
|
+
if (document.activeElement instanceof HTMLElement &&
|
|
1108
|
+
content?.contains(document.activeElement)) {
|
|
1109
|
+
capture.focus = document.activeElement;
|
|
1110
|
+
}
|
|
1111
|
+
this.lockParticipants(capture);
|
|
1112
|
+
this.root.dataset.catalogTransition = 'animating';
|
|
1113
|
+
if (matchMedia('(prefers-reduced-motion: reduce)').matches) {
|
|
1114
|
+
this.hooks.setGeometryProgress(1);
|
|
1115
|
+
this.settle(capture.token);
|
|
1116
|
+
return;
|
|
1117
|
+
}
|
|
1118
|
+
await new Promise((resolve) => {
|
|
1119
|
+
const mode = capture.mode ?? (reverse ? 'synchronous' : this.hooks.beginMotion?.()) ?? 'asynchronous';
|
|
1120
|
+
capture.mode = mode;
|
|
1121
|
+
capture.backgroundPrepared ??= !reverse && Boolean(this.hooks.backgroundPrepared?.());
|
|
1122
|
+
capture.paused = false;
|
|
1123
|
+
const owner = capture.owner;
|
|
1124
|
+
capture.resolve = resolve;
|
|
1125
|
+
let previous = performance.now();
|
|
1126
|
+
let elapsed = capture.elapsed;
|
|
1127
|
+
const frame = (now) => {
|
|
1128
|
+
if (!owner.isCurrent() || capture.paused)
|
|
1129
|
+
return;
|
|
1130
|
+
try {
|
|
1131
|
+
// A shader compilation or slow frame must not skip the entire content reveal.
|
|
1132
|
+
// The existing wall-clock timeout still bounds prolonged or hidden-page work.
|
|
1133
|
+
const nextElapsed = elapsed + Math.min(Math.max(now - previous, 0), 50);
|
|
1134
|
+
// Submit one complete destination-pose frame before background/High work.
|
|
1135
|
+
elapsed = elapsed < DURATION ? Math.min(nextElapsed, DURATION) : nextElapsed;
|
|
1136
|
+
capture.elapsed = elapsed;
|
|
1137
|
+
previous = now;
|
|
1138
|
+
const timing = transitionTiming(elapsed, mode, capture.backgroundPrepared);
|
|
1139
|
+
const progress = timing.motion;
|
|
1140
|
+
const enter = timing.enter;
|
|
1141
|
+
// Moving actors exclusively own shared surfaces/type until the final pose.
|
|
1142
|
+
for (const actor of capture.actors) {
|
|
1143
|
+
const target = actor.to;
|
|
1144
|
+
const scaleX = actor.role === 'summary-surface'
|
|
1145
|
+
? target.width / actor.from.width
|
|
1146
|
+
: actor.fontScale;
|
|
1147
|
+
const scaleY = actor.role === 'summary-surface'
|
|
1148
|
+
? target.height / actor.from.height
|
|
1149
|
+
: actor.fontScale;
|
|
1150
|
+
const x = (target.left - actor.from.left) * progress;
|
|
1151
|
+
const y = (target.top - actor.from.top) * progress;
|
|
1152
|
+
const currentScaleX = 1 + (scaleX - 1) * progress;
|
|
1153
|
+
actor.element.style.transform = `translate3d(${x}px, ${y}px, 0) scale(${currentScaleX}, ${1 + (scaleY - 1) * progress})`;
|
|
1154
|
+
let projectedCorners;
|
|
1155
|
+
if (actor.corners) {
|
|
1156
|
+
const ends = [
|
|
1157
|
+
{ x: target.left, y: target.top },
|
|
1158
|
+
{ x: target.right, y: target.top },
|
|
1159
|
+
{ x: target.right, y: target.bottom },
|
|
1160
|
+
{ x: target.left, y: target.bottom }
|
|
1161
|
+
];
|
|
1162
|
+
const corners = actor.corners.map((point, index) => ({
|
|
1163
|
+
x: point.x + (ends[index].x - point.x) * progress - actor.from.left,
|
|
1164
|
+
y: point.y + (ends[index].y - point.y) * progress - actor.from.top
|
|
1165
|
+
}));
|
|
1166
|
+
projectedCorners = corners;
|
|
1167
|
+
actor.element.style.transform =
|
|
1168
|
+
getProjectiveCssMatrix3d(corners, actor.layoutWidth ?? actor.from.width, actor.layoutHeight ?? actor.from.height) ?? actor.element.style.transform;
|
|
1169
|
+
}
|
|
1170
|
+
if (actor.destinationCopy) {
|
|
1171
|
+
const typography = actor.role === 'summary-surface'
|
|
1172
|
+
? transitionTiming(elapsed, 'synchronous').enter
|
|
1173
|
+
: Math.min(1, Math.max(0, (progress - 0.25) / 0.55));
|
|
1174
|
+
const destinationScale = 1 / actor.fontScale + (1 - 1 / actor.fontScale) * progress;
|
|
1175
|
+
const availableWidth = actor.from.width + (target.width - actor.from.width) * progress;
|
|
1176
|
+
const clippedWidth = Math.max(0, actor.from.width - availableWidth / currentScaleX);
|
|
1177
|
+
actor.element.style.clipPath = actor.corners
|
|
1178
|
+
? 'none'
|
|
1179
|
+
: `inset(0 ${clippedWidth}px 0 0)`;
|
|
1180
|
+
actor.element.style.opacity = String(1 - typography);
|
|
1181
|
+
actor.destinationCopy.style.transform =
|
|
1182
|
+
actor.role === 'summary-surface'
|
|
1183
|
+
? `translate3d(${x}px, ${y}px, 0) scale(${(actor.from.width + (target.width - actor.from.width) * progress) / target.width}, ${(actor.from.height + (target.height - actor.from.height) * progress) / target.height})`
|
|
1184
|
+
: `translate3d(${x}px, ${y}px, 0) scale(${destinationScale})`;
|
|
1185
|
+
actor.destinationCopy.style.opacity = String(typography);
|
|
1186
|
+
if (projectedCorners && actor.role === 'summary-surface') {
|
|
1187
|
+
actor.destinationCopy.style.transform =
|
|
1188
|
+
getProjectiveCssMatrix3d(projectedCorners, target.width, target.height) ??
|
|
1189
|
+
actor.destinationCopy.style.transform;
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
1192
|
+
else
|
|
1193
|
+
actor.element.style.opacity = String((actor.baseOpacity ?? 1) * (actor.sourceOnly ? 1 - progress : 1));
|
|
1194
|
+
}
|
|
1195
|
+
const panel = capture.actors.find((actor) => actor.role === 'summary-surface');
|
|
1196
|
+
if (panel?.to)
|
|
1197
|
+
for (const copy of capture.panelContent ?? []) {
|
|
1198
|
+
const width = panel.from.width + (panel.to.width - panel.from.width) * progress;
|
|
1199
|
+
const height = panel.from.height + (panel.to.height - panel.from.height) * progress;
|
|
1200
|
+
const sx = width / copy.panel.width, sy = height / copy.panel.height;
|
|
1201
|
+
const x = panel.from.left +
|
|
1202
|
+
(panel.to.left - panel.from.left) * progress +
|
|
1203
|
+
(copy.rect.left - copy.panel.left) * sx;
|
|
1204
|
+
const y = panel.from.top +
|
|
1205
|
+
(panel.to.top - panel.from.top) * progress +
|
|
1206
|
+
(copy.rect.top - copy.panel.top) * sy;
|
|
1207
|
+
copy.element.style.left = '0';
|
|
1208
|
+
copy.element.style.top = '0';
|
|
1209
|
+
copy.element.style.transform = `translate3d(${x}px, ${y}px, 0) scale(${sx}, ${sy})`;
|
|
1210
|
+
if (copy.incoming)
|
|
1211
|
+
copy.element.style.opacity = String(enter);
|
|
1212
|
+
}
|
|
1213
|
+
this.setPresentation({
|
|
1214
|
+
active: true,
|
|
1215
|
+
exitOpacity: timing.exit,
|
|
1216
|
+
enterOpacity: enter,
|
|
1217
|
+
sharedOpacity: 0,
|
|
1218
|
+
backgroundOpacity: timing.background,
|
|
1219
|
+
geometryOpacity: timing.geometry
|
|
1220
|
+
});
|
|
1221
|
+
this.hooks.setGeometryProgress(progress);
|
|
1222
|
+
this.hooks.flushFrame();
|
|
1223
|
+
if (timing.complete || matchMedia('(prefers-reduced-motion: reduce)').matches)
|
|
1224
|
+
this.settle(capture.token);
|
|
1225
|
+
else
|
|
1226
|
+
capture.frame = requestAnimationFrame(frame);
|
|
1227
|
+
}
|
|
1228
|
+
catch {
|
|
1229
|
+
this.cancel();
|
|
1230
|
+
}
|
|
1231
|
+
};
|
|
1232
|
+
capture.frame = requestAnimationFrame(frame);
|
|
1233
|
+
});
|
|
1234
|
+
}
|
|
1235
|
+
catch {
|
|
1236
|
+
this.cancel();
|
|
1237
|
+
}
|
|
1238
|
+
}
|
|
1239
|
+
cancel() {
|
|
1240
|
+
this.sequence.cancel();
|
|
1241
|
+
this.captureState?.owner?.release();
|
|
1242
|
+
}
|
|
1243
|
+
dispose() {
|
|
1244
|
+
this.cancel();
|
|
1245
|
+
}
|
|
1246
|
+
settle(token) {
|
|
1247
|
+
if (this.sequence.finish(token))
|
|
1248
|
+
this.captureState?.owner?.release();
|
|
1249
|
+
}
|
|
1250
|
+
cleanup() {
|
|
1251
|
+
const capture = this.captureState;
|
|
1252
|
+
this.captureState = undefined;
|
|
1253
|
+
delete this.root.dataset.catalogTransition;
|
|
1254
|
+
delete this.root.dataset.catalogRecipe;
|
|
1255
|
+
delete this.root.dataset.catalogOwnershipRevision;
|
|
1256
|
+
delete this.root.dataset.catalogDirection;
|
|
1257
|
+
window.removeEventListener('resize', this.interrupt);
|
|
1258
|
+
window.removeEventListener('wheel', this.interrupt, true);
|
|
1259
|
+
window.removeEventListener('touchmove', this.interrupt, true);
|
|
1260
|
+
window.removeEventListener('keydown', this.keydown);
|
|
1261
|
+
if (!capture)
|
|
1262
|
+
return;
|
|
1263
|
+
capture.observer?.disconnect();
|
|
1264
|
+
capture.layoutObserver?.disconnect();
|
|
1265
|
+
cancelAnimationFrame(capture.frame);
|
|
1266
|
+
clearTimeout(capture.timeout);
|
|
1267
|
+
capture.host.remove();
|
|
1268
|
+
for (const copy of capture.exiting)
|
|
1269
|
+
copy.remove();
|
|
1270
|
+
for (const restore of capture.restore.reverse())
|
|
1271
|
+
restore();
|
|
1272
|
+
for (const [element, inert] of capture.inert) {
|
|
1273
|
+
// Docking can change during route scroll restoration after this lock was acquired.
|
|
1274
|
+
// Preserve the controller's current semantic state instead of reviving a stale lock snapshot.
|
|
1275
|
+
const dock = element.matches('[data-spatial-element-sticky-header], [data-spatial-element-sticky-tabs]');
|
|
1276
|
+
element.inert = dock ? element.getAttribute('aria-hidden') === 'true' : inert;
|
|
1277
|
+
}
|
|
1278
|
+
if (capture.focus?.isConnected &&
|
|
1279
|
+
(document.activeElement === document.body ||
|
|
1280
|
+
capture.content?.contains(document.activeElement)))
|
|
1281
|
+
capture.focus.focus({ preventScroll: true });
|
|
1282
|
+
try {
|
|
1283
|
+
try {
|
|
1284
|
+
this.setPresentation({ active: false, enterOpacity: 1, exitOpacity: 1, sharedOpacity: 1 });
|
|
1285
|
+
}
|
|
1286
|
+
finally {
|
|
1287
|
+
this.hooks.finishGeometry();
|
|
1288
|
+
this.hooks.flushFrame();
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
catch {
|
|
1292
|
+
// A renderer failure cannot prevent DOM restoration or completion of navigation.
|
|
1293
|
+
}
|
|
1294
|
+
finally {
|
|
1295
|
+
capture.resolve?.();
|
|
1296
|
+
}
|
|
1297
|
+
}
|
|
1298
|
+
}
|
|
1299
|
+
//# sourceMappingURL=CatalogTransition.js.map
|