@spatial-elements/core 1.0.0-beta.6 → 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.
Files changed (244) hide show
  1. package/dist/catalog/CarouselDeviceCamera.d.ts +20 -0
  2. package/dist/catalog/CarouselDeviceCamera.d.ts.map +1 -0
  3. package/dist/catalog/CarouselDeviceCamera.js +58 -0
  4. package/dist/catalog/CarouselDeviceCamera.js.map +1 -0
  5. package/dist/catalog/CarouselGlassCompositor.d.ts +8 -2
  6. package/dist/catalog/CarouselGlassCompositor.d.ts.map +1 -1
  7. package/dist/catalog/CarouselGlassCompositor.js +69 -12
  8. package/dist/catalog/CarouselGlassCompositor.js.map +1 -1
  9. package/dist/catalog/CarouselGround.d.ts +22 -1
  10. package/dist/catalog/CarouselGround.d.ts.map +1 -1
  11. package/dist/catalog/CarouselGround.js +185 -24
  12. package/dist/catalog/CarouselGround.js.map +1 -1
  13. package/dist/catalog/CatalogDepthBlur.d.ts +20 -1
  14. package/dist/catalog/CatalogDepthBlur.d.ts.map +1 -1
  15. package/dist/catalog/CatalogDepthBlur.js +126 -23
  16. package/dist/catalog/CatalogDepthBlur.js.map +1 -1
  17. package/dist/catalog/CatalogGeometryFade.d.ts +5 -1
  18. package/dist/catalog/CatalogGeometryFade.d.ts.map +1 -1
  19. package/dist/catalog/CatalogGeometryFade.js +39 -7
  20. package/dist/catalog/CatalogGeometryFade.js.map +1 -1
  21. package/dist/catalog/CatalogModelOutline.d.ts +3 -1
  22. package/dist/catalog/CatalogModelOutline.d.ts.map +1 -1
  23. package/dist/catalog/CatalogModelOutline.js +11 -2
  24. package/dist/catalog/CatalogModelOutline.js.map +1 -1
  25. package/dist/catalog/CatalogPreparation.d.ts.map +1 -1
  26. package/dist/catalog/CatalogPreparation.js +8 -6
  27. package/dist/catalog/CatalogPreparation.js.map +1 -1
  28. package/dist/catalog/CatalogSpatialElementLayer.d.ts +144 -3
  29. package/dist/catalog/CatalogSpatialElementLayer.d.ts.map +1 -1
  30. package/dist/catalog/CatalogSpatialElementLayer.js +554 -103
  31. package/dist/catalog/CatalogSpatialElementLayer.js.map +1 -1
  32. package/dist/catalog/CatalogTransition.d.ts +4 -0
  33. package/dist/catalog/CatalogTransition.d.ts.map +1 -1
  34. package/dist/catalog/CatalogTransition.js +109 -27
  35. package/dist/catalog/CatalogTransition.js.map +1 -1
  36. package/dist/catalog/CatalogWarmOutputContext.d.ts +39 -0
  37. package/dist/catalog/CatalogWarmOutputContext.d.ts.map +1 -0
  38. package/dist/catalog/CatalogWarmOutputContext.js +159 -0
  39. package/dist/catalog/CatalogWarmOutputContext.js.map +1 -0
  40. package/dist/catalog/EarlyNavigationCoordinator.d.ts +35 -0
  41. package/dist/catalog/EarlyNavigationCoordinator.d.ts.map +1 -0
  42. package/dist/catalog/EarlyNavigationCoordinator.js +103 -0
  43. package/dist/catalog/EarlyNavigationCoordinator.js.map +1 -0
  44. package/dist/catalog/NavigationFeedback.d.ts +12 -0
  45. package/dist/catalog/NavigationFeedback.d.ts.map +1 -0
  46. package/dist/catalog/NavigationFeedback.js +40 -0
  47. package/dist/catalog/NavigationFeedback.js.map +1 -0
  48. package/dist/catalog/PreparationGate.d.ts +4 -0
  49. package/dist/catalog/PreparationGate.d.ts.map +1 -1
  50. package/dist/catalog/PreparationGate.js +1 -0
  51. package/dist/catalog/PreparationGate.js.map +1 -1
  52. package/dist/catalog/SourceDomClipping.d.ts +8 -0
  53. package/dist/catalog/SourceDomClipping.d.ts.map +1 -0
  54. package/dist/catalog/SourceDomClipping.js +74 -0
  55. package/dist/catalog/SourceDomClipping.js.map +1 -0
  56. package/dist/catalog/SourceDomMotion.d.ts +28 -0
  57. package/dist/catalog/SourceDomMotion.d.ts.map +1 -0
  58. package/dist/catalog/SourceDomMotion.js +111 -0
  59. package/dist/catalog/SourceDomMotion.js.map +1 -0
  60. package/dist/catalog/SpatialPageRegistry.d.ts +1 -0
  61. package/dist/catalog/SpatialPageRegistry.d.ts.map +1 -1
  62. package/dist/catalog/SpatialPageRegistry.js.map +1 -1
  63. package/dist/catalog/StagedCatalogTransition.d.ts +74 -0
  64. package/dist/catalog/StagedCatalogTransition.d.ts.map +1 -0
  65. package/dist/catalog/StagedCatalogTransition.js +270 -0
  66. package/dist/catalog/StagedCatalogTransition.js.map +1 -0
  67. package/dist/catalog/cardProjection.d.ts +31 -0
  68. package/dist/catalog/cardProjection.d.ts.map +1 -1
  69. package/dist/catalog/cardProjection.js +63 -4
  70. package/dist/catalog/cardProjection.js.map +1 -1
  71. package/dist/catalog/carouselPanelProjection.d.ts.map +1 -1
  72. package/dist/catalog/carouselPanelProjection.js +48 -11
  73. package/dist/catalog/carouselPanelProjection.js.map +1 -1
  74. package/dist/catalog/catalogActivationFocus.d.ts +5 -0
  75. package/dist/catalog/catalogActivationFocus.d.ts.map +1 -0
  76. package/dist/catalog/catalogActivationFocus.js +39 -0
  77. package/dist/catalog/catalogActivationFocus.js.map +1 -0
  78. package/dist/catalog/catalogJourney.d.ts +2 -0
  79. package/dist/catalog/catalogJourney.d.ts.map +1 -1
  80. package/dist/catalog/catalogJourney.js.map +1 -1
  81. package/dist/catalog/catalogPose.d.ts +18 -0
  82. package/dist/catalog/catalogPose.d.ts.map +1 -1
  83. package/dist/catalog/catalogPose.js +26 -5
  84. package/dist/catalog/catalogPose.js.map +1 -1
  85. package/dist/catalog/catalogTransitionViewport.d.ts +9 -0
  86. package/dist/catalog/catalogTransitionViewport.d.ts.map +1 -0
  87. package/dist/catalog/catalogTransitionViewport.js +13 -0
  88. package/dist/catalog/catalogTransitionViewport.js.map +1 -0
  89. package/dist/catalog/catalogViewLink.d.ts +2 -0
  90. package/dist/catalog/catalogViewLink.d.ts.map +1 -1
  91. package/dist/catalog/catalogViewLink.js +10 -2
  92. package/dist/catalog/catalogViewLink.js.map +1 -1
  93. package/dist/catalog/deviceYaw.d.ts +21 -0
  94. package/dist/catalog/deviceYaw.d.ts.map +1 -0
  95. package/dist/catalog/deviceYaw.js +87 -0
  96. package/dist/catalog/deviceYaw.js.map +1 -0
  97. package/dist/catalog/listDeviceOrientation.d.ts +17 -0
  98. package/dist/catalog/listDeviceOrientation.d.ts.map +1 -0
  99. package/dist/catalog/listDeviceOrientation.js +262 -0
  100. package/dist/catalog/listDeviceOrientation.js.map +1 -0
  101. package/dist/catalog/stagedDetailGeometry.d.ts +37 -0
  102. package/dist/catalog/stagedDetailGeometry.d.ts.map +1 -0
  103. package/dist/catalog/stagedDetailGeometry.js +55 -0
  104. package/dist/catalog/stagedDetailGeometry.js.map +1 -0
  105. package/dist/catalog/stagedDockGeometry.d.ts +66 -0
  106. package/dist/catalog/stagedDockGeometry.d.ts.map +1 -0
  107. package/dist/catalog/stagedDockGeometry.js +66 -0
  108. package/dist/catalog/stagedDockGeometry.js.map +1 -0
  109. package/dist/index.d.ts +2 -1
  110. package/dist/index.d.ts.map +1 -1
  111. package/dist/index.js +2 -1
  112. package/dist/index.js.map +1 -1
  113. package/dist/spatial-element/ResponsiveViewportMetrics.d.ts +18 -0
  114. package/dist/spatial-element/ResponsiveViewportMetrics.d.ts.map +1 -0
  115. package/dist/spatial-element/ResponsiveViewportMetrics.js +68 -0
  116. package/dist/spatial-element/ResponsiveViewportMetrics.js.map +1 -0
  117. package/dist/spatial-element/SectionSurfaceRegistry.d.ts +24 -0
  118. package/dist/spatial-element/SectionSurfaceRegistry.d.ts.map +1 -0
  119. package/dist/spatial-element/SectionSurfaceRegistry.js +48 -0
  120. package/dist/spatial-element/SectionSurfaceRegistry.js.map +1 -0
  121. package/dist/spatial-element/SpatialElementDockController.d.ts +19 -9
  122. package/dist/spatial-element/SpatialElementDockController.d.ts.map +1 -1
  123. package/dist/spatial-element/SpatialElementDockController.js +189 -93
  124. package/dist/spatial-element/SpatialElementDockController.js.map +1 -1
  125. package/dist/spatial-element/SpatialElementPaneController.d.ts +67 -0
  126. package/dist/spatial-element/SpatialElementPaneController.d.ts.map +1 -0
  127. package/dist/spatial-element/SpatialElementPaneController.js +245 -0
  128. package/dist/spatial-element/SpatialElementPaneController.js.map +1 -0
  129. package/dist/spatial-element/activeDetailSection.d.ts +8 -0
  130. package/dist/spatial-element/activeDetailSection.d.ts.map +1 -0
  131. package/dist/spatial-element/activeDetailSection.js +19 -0
  132. package/dist/spatial-element/activeDetailSection.js.map +1 -0
  133. package/dist/spatial-element/layoutTokens.json +53 -0
  134. package/dist/spatial-element/responsiveLayout.d.ts +1389 -0
  135. package/dist/spatial-element/responsiveLayout.d.ts.map +1 -0
  136. package/dist/spatial-element/responsiveLayout.js +265 -0
  137. package/dist/spatial-element/responsiveLayout.js.map +1 -0
  138. package/dist/spatial-element/sectionBackground.d.ts +29 -0
  139. package/dist/spatial-element/sectionBackground.d.ts.map +1 -0
  140. package/dist/spatial-element/sectionBackground.js +66 -0
  141. package/dist/spatial-element/sectionBackground.js.map +1 -0
  142. package/dist/spatial-element/spatialElement.d.ts +1 -0
  143. package/dist/spatial-element/spatialElement.d.ts.map +1 -1
  144. package/dist/spatial-element/spatialElement.js +1 -0
  145. package/dist/spatial-element/spatialElement.js.map +1 -1
  146. package/dist/spatial-element/spatialElementDock.d.ts +15 -0
  147. package/dist/spatial-element/spatialElementDock.d.ts.map +1 -1
  148. package/dist/spatial-element/spatialElementDock.js +22 -0
  149. package/dist/spatial-element/spatialElementDock.js.map +1 -1
  150. package/dist/spatial-element/spatialElementMedia.d.ts +16 -0
  151. package/dist/spatial-element/spatialElementMedia.d.ts.map +1 -0
  152. package/dist/spatial-element/spatialElementMedia.js +29 -0
  153. package/dist/spatial-element/spatialElementMedia.js.map +1 -0
  154. package/dist/spatial-element/spatialTheme.d.ts +12 -1
  155. package/dist/spatial-element/spatialTheme.d.ts.map +1 -1
  156. package/dist/spatial-element/spatialTheme.js +30 -1
  157. package/dist/spatial-element/spatialTheme.js.map +1 -1
  158. package/dist/spatial-element/types.d.ts +50 -2
  159. package/dist/spatial-element/types.d.ts.map +1 -1
  160. package/dist/spatial-element/types.js.map +1 -1
  161. package/dist/stage/BackgroundLayerOutput.d.ts +76 -0
  162. package/dist/stage/BackgroundLayerOutput.d.ts.map +1 -0
  163. package/dist/stage/BackgroundLayerOutput.js +333 -0
  164. package/dist/stage/BackgroundLayerOutput.js.map +1 -0
  165. package/dist/stage/DeviceGeometryMotion.d.ts +13 -0
  166. package/dist/stage/DeviceGeometryMotion.d.ts.map +1 -0
  167. package/dist/stage/DeviceGeometryMotion.js +37 -0
  168. package/dist/stage/DeviceGeometryMotion.js.map +1 -0
  169. package/dist/stage/LiquidGlassPanel.d.ts +3 -0
  170. package/dist/stage/LiquidGlassPanel.d.ts.map +1 -1
  171. package/dist/stage/LiquidGlassPanel.js +27 -2
  172. package/dist/stage/LiquidGlassPanel.js.map +1 -1
  173. package/dist/stage/MinimapController.d.ts +1 -0
  174. package/dist/stage/MinimapController.d.ts.map +1 -1
  175. package/dist/stage/MinimapController.js +35 -47
  176. package/dist/stage/MinimapController.js.map +1 -1
  177. package/dist/stage/PageBindingController.d.ts +4 -0
  178. package/dist/stage/PageBindingController.d.ts.map +1 -1
  179. package/dist/stage/PageBindingController.js +12 -4
  180. package/dist/stage/PageBindingController.js.map +1 -1
  181. package/dist/stage/PanelPresentationController.d.ts +17 -0
  182. package/dist/stage/PanelPresentationController.d.ts.map +1 -1
  183. package/dist/stage/PanelPresentationController.js +83 -22
  184. package/dist/stage/PanelPresentationController.js.map +1 -1
  185. package/dist/stage/SpatialElementInteractionController.d.ts +7 -0
  186. package/dist/stage/SpatialElementInteractionController.d.ts.map +1 -1
  187. package/dist/stage/SpatialElementInteractionController.js +9 -0
  188. package/dist/stage/SpatialElementInteractionController.js.map +1 -1
  189. package/dist/stage/SpatialElementPresentationController.d.ts +14 -2
  190. package/dist/stage/SpatialElementPresentationController.d.ts.map +1 -1
  191. package/dist/stage/SpatialElementPresentationController.js +47 -2
  192. package/dist/stage/SpatialElementPresentationController.js.map +1 -1
  193. package/dist/stage/SpatialElementRefinement.d.ts +34 -1
  194. package/dist/stage/SpatialElementRefinement.d.ts.map +1 -1
  195. package/dist/stage/SpatialElementRefinement.js +175 -37
  196. package/dist/stage/SpatialElementRefinement.js.map +1 -1
  197. package/dist/stage/StageExperience.d.ts +183 -5
  198. package/dist/stage/StageExperience.d.ts.map +1 -1
  199. package/dist/stage/StageExperience.js +421 -57
  200. package/dist/stage/StageExperience.js.map +1 -1
  201. package/dist/stage/StageRenderPipeline.d.ts +76 -1
  202. package/dist/stage/StageRenderPipeline.d.ts.map +1 -1
  203. package/dist/stage/StageRenderPipeline.js +424 -47
  204. package/dist/stage/StageRenderPipeline.js.map +1 -1
  205. package/dist/stage/VirtualScrollController.d.ts +7 -0
  206. package/dist/stage/VirtualScrollController.d.ts.map +1 -1
  207. package/dist/stage/VirtualScrollController.js +57 -4
  208. package/dist/stage/VirtualScrollController.js.map +1 -1
  209. package/dist/stage/minimap/MinimapModel.d.ts +2 -1
  210. package/dist/stage/minimap/MinimapModel.d.ts.map +1 -1
  211. package/dist/stage/minimap/MinimapModel.js +34 -4
  212. package/dist/stage/minimap/MinimapModel.js.map +1 -1
  213. package/dist/stage/minimap/MinimapModelGeometry.d.ts +21 -0
  214. package/dist/stage/minimap/MinimapModelGeometry.d.ts.map +1 -0
  215. package/dist/stage/minimap/MinimapModelGeometry.js +68 -0
  216. package/dist/stage/minimap/MinimapModelGeometry.js.map +1 -0
  217. package/dist/stage/minimap/MinimapState.d.ts +3 -8
  218. package/dist/stage/minimap/MinimapState.d.ts.map +1 -1
  219. package/dist/stage/minimap/MinimapState.js.map +1 -1
  220. package/dist/stage/panelContext.d.ts +7 -0
  221. package/dist/stage/panelContext.d.ts.map +1 -1
  222. package/dist/stage/panelContext.js.map +1 -1
  223. package/dist/stage/rendererState.d.ts +2 -0
  224. package/dist/stage/rendererState.d.ts.map +1 -1
  225. package/dist/stage/rendererState.js +13 -0
  226. package/dist/stage/rendererState.js.map +1 -1
  227. package/dist/stage/sceneEndpointEligibility.d.ts +20 -0
  228. package/dist/stage/sceneEndpointEligibility.d.ts.map +1 -0
  229. package/dist/stage/sceneEndpointEligibility.js +363 -0
  230. package/dist/stage/sceneEndpointEligibility.js.map +1 -0
  231. package/dist/stage/stageDom.d.ts.map +1 -1
  232. package/dist/stage/stageDom.js +6 -1
  233. package/dist/stage/stageDom.js.map +1 -1
  234. package/dist/stage/stageMath.d.ts +3 -3
  235. package/dist/stage/stageMath.d.ts.map +1 -1
  236. package/dist/stage/stageMath.js +11 -10
  237. package/dist/stage/stageMath.js.map +1 -1
  238. package/dist/stage/stageTypes.d.ts +8 -1
  239. package/dist/stage/stageTypes.d.ts.map +1 -1
  240. package/dist/stage/stageTypes.js.map +1 -1
  241. package/dist/stage/stageVisualTest.d.ts +19 -0
  242. package/dist/stage/stageVisualTest.d.ts.map +1 -1
  243. package/dist/stage/stageVisualTest.js.map +1 -1
  244. package/package.json +1 -1
@@ -1,8 +1,39 @@
1
1
  import type { CssProjectionQuad } from '../stage/cssProjection.js';
2
+ interface ProjectivePoint {
3
+ x: number;
4
+ y: number;
5
+ z: number;
6
+ w: number;
7
+ }
8
+ /**
9
+ * Recover subpixel layout offsets without flattening the CSS perspective plane.
10
+ * offsetLeft/Top round to integer CSS pixels; a centered flex child need not.
11
+ * For each extremal corner, screenPosition = numerator / homogeneousW. Moving
12
+ * its local origin gives two linear equations after multiplying by homogeneousW.
13
+ * Re-evaluate extrema because a perspective translation can change the corner.
14
+ * @internal
15
+ */
16
+ export declare function refineProjectedLayoutOffset(parent: ArrayLike<number>, localCorners: readonly ProjectivePoint[], target: {
17
+ left: number;
18
+ top: number;
19
+ }, initial: {
20
+ x: number;
21
+ y: number;
22
+ }): {
23
+ x: number;
24
+ y: number;
25
+ };
2
26
  /** Keep the card's tilted, raised text in its original layout when navigation takes over. */
3
27
  export declare function captureCardElement(element: HTMLElement): {
4
28
  width: number;
5
29
  height: number;
6
30
  corners: CssProjectionQuad;
7
31
  } | undefined;
32
+ /** Capture a nested element relative to a known planar root (also used after a live-root transfer). */
33
+ export declare function captureElementPlane(element: HTMLElement, card: HTMLElement): {
34
+ width: number;
35
+ height: number;
36
+ corners: CssProjectionQuad;
37
+ } | undefined;
38
+ export {};
8
39
  //# sourceMappingURL=cardProjection.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cardProjection.d.ts","sourceRoot":"","sources":["../../src/catalog/cardProjection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AA4BnE,6FAA6F;AAC7F,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,WAAW;;;;cAsBtD"}
1
+ {"version":3,"file":"cardProjection.d.ts","sourceRoot":"","sources":["../../src/catalog/cardProjection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AA4BnE,UAAU,eAAe;IAAG,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE;AAExE;;;;;;;GAOG;AACH,wBAAgB,2BAA2B,CAC1C,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,EACzB,YAAY,EAAE,SAAS,eAAe,EAAE,EACxC,MAAM,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,EACrC,OAAO,EAAE;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE;OAAnB,MAAM;OAAK,MAAM;EAkC/B;AAED,6FAA6F;AAC7F,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,WAAW;;;;cAItD;AAED,uGAAuG;AACvG,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,WAAW;;;;cA8B1E"}
@@ -21,19 +21,68 @@ function project(matrix, width, height) {
21
21
  return { x: point.x / point.w, y: point.y / point.w };
22
22
  });
23
23
  }
24
+ /**
25
+ * Recover subpixel layout offsets without flattening the CSS perspective plane.
26
+ * offsetLeft/Top round to integer CSS pixels; a centered flex child need not.
27
+ * For each extremal corner, screenPosition = numerator / homogeneousW. Moving
28
+ * its local origin gives two linear equations after multiplying by homogeneousW.
29
+ * Re-evaluate extrema because a perspective translation can change the corner.
30
+ * @internal
31
+ */
32
+ export function refineProjectedLayoutOffset(parent, localCorners, target, initial) {
33
+ const bases = localCorners.map(point => ({
34
+ x: parent[0] * point.x + parent[4] * point.y + parent[8] * point.z + parent[12] * point.w,
35
+ y: parent[1] * point.x + parent[5] * point.y + parent[9] * point.z + parent[13] * point.w,
36
+ w: parent[3] * point.x + parent[7] * point.y + parent[11] * point.z + parent[15] * point.w,
37
+ localW: point.w
38
+ }));
39
+ let offset = initial;
40
+ for (let iteration = 0; iteration < 4; iteration++) {
41
+ const projected = bases.map(point => {
42
+ const w = point.w + (parent[3] * offset.x + parent[7] * offset.y) * point.localW;
43
+ return {
44
+ x: (point.x + (parent[0] * offset.x + parent[4] * offset.y) * point.localW) / w,
45
+ y: (point.y + (parent[1] * offset.x + parent[5] * offset.y) * point.localW) / w
46
+ };
47
+ });
48
+ const left = bases[projected.reduce((index, point, next) => point.x < projected[index].x ? next : index, 0)];
49
+ const top = bases[projected.reduce((index, point, next) => point.y < projected[index].y ? next : index, 0)];
50
+ if (!left || !top)
51
+ return initial;
52
+ const a = (parent[0] - target.left * parent[3]) * left.localW;
53
+ const b = (parent[4] - target.left * parent[7]) * left.localW;
54
+ const c = (parent[1] - target.top * parent[3]) * top.localW;
55
+ const d = (parent[5] - target.top * parent[7]) * top.localW;
56
+ const rx = target.left * left.w - left.x;
57
+ const ry = target.top * top.w - top.y;
58
+ const determinant = a * d - b * c;
59
+ if (!Number.isFinite(determinant) || Math.abs(determinant) < 1e-10)
60
+ return initial;
61
+ const next = { x: (rx * d - b * ry) / determinant, y: (a * ry - rx * c) / determinant };
62
+ if (!Number.isFinite(next.x) || !Number.isFinite(next.y))
63
+ return initial;
64
+ if (Math.abs(next.x - offset.x) + Math.abs(next.y - offset.y) < 1e-7)
65
+ return next;
66
+ offset = next;
67
+ }
68
+ return offset;
69
+ }
24
70
  /** Keep the card's tilted, raised text in its original layout when navigation takes over. */
25
71
  export function captureCardElement(element) {
26
72
  const card = element.closest('[data-catalog-card]');
27
73
  if (!card)
28
74
  return;
75
+ return captureElementPlane(element, card);
76
+ }
77
+ /** Capture a nested element relative to a known planar root (also used after a live-root transfer). */
78
+ export function captureElementPlane(element, card) {
29
79
  const { width, height } = borderBox(element);
30
80
  const cardSize = borderBox(card);
31
81
  if (!width || !height || !cardSize.width || !cardSize.height)
32
82
  return;
33
- let matrix = new DOMMatrix();
83
+ const chain = [];
34
84
  for (let node = element; node !== card;) {
35
- matrix = new DOMMatrix().translate(node.offsetLeft, node.offsetTop)
36
- .multiply(localTransform(node)).multiply(matrix);
85
+ chain.push(node);
37
86
  const parent = node.offsetParent;
38
87
  if (!(parent instanceof HTMLElement) || (parent !== card && !card.contains(parent)))
39
88
  return;
@@ -44,7 +93,17 @@ export function captureCardElement(element) {
44
93
  const rect = card.getBoundingClientRect();
45
94
  const x = rect.left - Math.min(...cardCorners.map((point) => point.x));
46
95
  const y = rect.top - Math.min(...cardCorners.map((point) => point.y));
47
- const corners = project(cardMatrix.multiply(matrix), width, height)
96
+ let matrix = cardMatrix;
97
+ for (const node of chain.reverse()) {
98
+ const local = localTransform(node);
99
+ const size = borderBox(node);
100
+ const measured = node.getBoundingClientRect();
101
+ const localCorners = [[0, 0], [size.width, 0], [size.width, size.height], [0, size.height]]
102
+ .map(([cx, cy]) => local.transformPoint(new DOMPoint(cx, cy)));
103
+ const offset = refineProjectedLayoutOffset(matrix.toFloat64Array(), localCorners, { left: measured.left - x, top: measured.top - y }, { x: node.offsetLeft, y: node.offsetTop });
104
+ matrix = matrix.translate(offset.x, offset.y).multiply(local);
105
+ }
106
+ const corners = project(matrix, width, height)
48
107
  .map((point) => ({ x: point.x + x, y: point.y + y }));
49
108
  return { width, height, corners };
50
109
  }
@@ -1 +1 @@
1
- {"version":3,"file":"cardProjection.js","sourceRoot":"","sources":["../../src/catalog/cardProjection.ts"],"names":[],"mappings":"AAEA,SAAS,SAAS,CAAC,OAAoB;IACtC,MAAM,KAAK,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACxC,MAAM,EAAE,GAAG,CAAC,QAAgB,EAAE,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC;IAC1F,OAAO;QACN,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,SAAS,KAAK,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC3D,EAAE,CAAC,cAAc,CAAC,GAAG,EAAE,CAAC,eAAe,CAAC,GAAG,EAAE,CAAC,mBAAmB,CAAC,GAAG,EAAE,CAAC,oBAAoB,CAAC,CAAC;QAC/F,MAAM,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,SAAS,KAAK,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC7D,EAAE,CAAC,aAAa,CAAC,GAAG,EAAE,CAAC,gBAAgB,CAAC,GAAG,EAAE,CAAC,kBAAkB,CAAC,GAAG,EAAE,CAAC,qBAAqB,CAAC,CAAC;KAC/F,CAAC;AACH,CAAC;AAED,SAAS,cAAc,CAAC,OAAoB;IAC3C,MAAM,KAAK,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACxC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,eAAe,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IAC9E,OAAO,IAAI,SAAS,EAAE,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;SAC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AAE,CAAC,EAAE,KAAK,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAiC,CAAC;IACvF,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;AACnC,CAAC","sourcesContent":["import type { CssProjectionQuad } from '../stage/cssProjection.js';\n\nfunction borderBox(element: HTMLElement) {\n\tconst style = getComputedStyle(element);\n\tconst px = (property: string) => Number.parseFloat(style.getPropertyValue(property)) || 0;\n\treturn {\n\t\twidth: px('width') + (style.boxSizing === 'border-box' ? 0 :\n\t\t\tpx('padding-left') + px('padding-right') + px('border-left-width') + px('border-right-width')),\n\t\theight: px('height') + (style.boxSizing === 'border-box' ? 0 :\n\t\t\tpx('padding-top') + px('padding-bottom') + px('border-top-width') + px('border-bottom-width'))\n\t};\n}\n\nfunction localTransform(element: HTMLElement) {\n\tconst style = getComputedStyle(element);\n\tconst [x, y, z = 0] = style.transformOrigin.split(' ').map(Number.parseFloat);\n\treturn new DOMMatrix().translate(x, y, z)\n\t\t.multiply(new DOMMatrix(style.transform === 'none' ? undefined : style.transform))\n\t\t.translate(-x, -y, -z);\n}\n\nfunction project(matrix: DOMMatrix, width: number, height: number): CssProjectionQuad {\n\treturn [[0, 0], [width, 0], [width, height], [0, height]].map(([x, y]) => {\n\t\tconst point = matrix.transformPoint(new DOMPoint(x, y));\n\t\treturn { x: point.x / point.w, y: point.y / point.w };\n\t}) as unknown as CssProjectionQuad;\n}\n\n/** Keep the card's tilted, raised text in its original layout when navigation takes over. */\nexport function captureCardElement(element: HTMLElement) {\n\tconst card = element.closest<HTMLElement>('[data-catalog-card]');\n\tif (!card) return;\n\tconst { width, height } = borderBox(element);\n\tconst cardSize = borderBox(card);\n\tif (!width || !height || !cardSize.width || !cardSize.height) return;\n\tlet matrix = new DOMMatrix();\n\tfor (let node = element; node !== card;) {\n\t\tmatrix = new DOMMatrix().translate(node.offsetLeft, node.offsetTop)\n\t\t\t.multiply(localTransform(node)).multiply(matrix);\n\t\tconst parent: Element | null = node.offsetParent;\n\t\tif (!(parent instanceof HTMLElement) || (parent !== card && !card.contains(parent))) return;\n\t\tnode = parent;\n\t}\n\tconst cardMatrix = localTransform(card);\n\tconst cardCorners = project(cardMatrix, cardSize.width, cardSize.height);\n\tconst rect = card.getBoundingClientRect();\n\tconst x = rect.left - Math.min(...cardCorners.map((point) => point.x));\n\tconst y = rect.top - Math.min(...cardCorners.map((point) => point.y));\n\tconst corners = project(cardMatrix.multiply(matrix), width, height)\n\t\t.map((point) => ({ x: point.x + x, y: point.y + y })) as unknown as CssProjectionQuad;\n\treturn { width, height, corners };\n}\n"]}
1
+ {"version":3,"file":"cardProjection.js","sourceRoot":"","sources":["../../src/catalog/cardProjection.ts"],"names":[],"mappings":"AAEA,SAAS,SAAS,CAAC,OAAoB;IACtC,MAAM,KAAK,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACxC,MAAM,EAAE,GAAG,CAAC,QAAgB,EAAE,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC;IAC1F,OAAO;QACN,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,SAAS,KAAK,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC3D,EAAE,CAAC,cAAc,CAAC,GAAG,EAAE,CAAC,eAAe,CAAC,GAAG,EAAE,CAAC,mBAAmB,CAAC,GAAG,EAAE,CAAC,oBAAoB,CAAC,CAAC;QAC/F,MAAM,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,SAAS,KAAK,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC7D,EAAE,CAAC,aAAa,CAAC,GAAG,EAAE,CAAC,gBAAgB,CAAC,GAAG,EAAE,CAAC,kBAAkB,CAAC,GAAG,EAAE,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,CAAC,IAAI,GAAG,CAAC,EAAE,GAAG,EAAE,QAAQ,CAAC,GAAG,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC;QAChG,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC/D,CAAC;IACD,MAAM,OAAO,GAAG,OAAO,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC;SAC5C,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAiC,CAAC;IACvF,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;AACnC,CAAC","sourcesContent":["import type { CssProjectionQuad } from '../stage/cssProjection.js';\n\nfunction borderBox(element: HTMLElement) {\n\tconst style = getComputedStyle(element);\n\tconst px = (property: string) => Number.parseFloat(style.getPropertyValue(property)) || 0;\n\treturn {\n\t\twidth: px('width') + (style.boxSizing === 'border-box' ? 0 :\n\t\t\tpx('padding-left') + px('padding-right') + px('border-left-width') + px('border-right-width')),\n\t\theight: px('height') + (style.boxSizing === 'border-box' ? 0 :\n\t\t\tpx('padding-top') + px('padding-bottom') + px('border-top-width') + px('border-bottom-width'))\n\t};\n}\n\nfunction localTransform(element: HTMLElement) {\n\tconst style = getComputedStyle(element);\n\tconst [x, y, z = 0] = style.transformOrigin.split(' ').map(Number.parseFloat);\n\treturn new DOMMatrix().translate(x, y, z)\n\t\t.multiply(new DOMMatrix(style.transform === 'none' ? undefined : style.transform))\n\t\t.translate(-x, -y, -z);\n}\n\nfunction project(matrix: DOMMatrix, width: number, height: number): CssProjectionQuad {\n\treturn [[0, 0], [width, 0], [width, height], [0, height]].map(([x, y]) => {\n\t\tconst point = matrix.transformPoint(new DOMPoint(x, y));\n\t\treturn { x: point.x / point.w, y: point.y / point.w };\n\t}) as unknown as CssProjectionQuad;\n}\n\ninterface ProjectivePoint { x: number; y: number; z: number; w: number }\n\n/**\n * Recover subpixel layout offsets without flattening the CSS perspective plane.\n * offsetLeft/Top round to integer CSS pixels; a centered flex child need not.\n * For each extremal corner, screenPosition = numerator / homogeneousW. Moving\n * its local origin gives two linear equations after multiplying by homogeneousW.\n * Re-evaluate extrema because a perspective translation can change the corner.\n * @internal\n */\nexport function refineProjectedLayoutOffset(\n\tparent: ArrayLike<number>,\n\tlocalCorners: readonly ProjectivePoint[],\n\ttarget: { left: number; top: number },\n\tinitial: { x: number; y: number }\n) {\n\tconst bases = localCorners.map(point => ({\n\t\tx: parent[0] * point.x + parent[4] * point.y + parent[8] * point.z + parent[12] * point.w,\n\t\ty: parent[1] * point.x + parent[5] * point.y + parent[9] * point.z + parent[13] * point.w,\n\t\tw: parent[3] * point.x + parent[7] * point.y + parent[11] * point.z + parent[15] * point.w,\n\t\tlocalW: point.w\n\t}));\n\tlet offset = initial;\n\tfor (let iteration = 0; iteration < 4; iteration++) {\n\t\tconst projected = bases.map(point => {\n\t\t\tconst w = point.w + (parent[3] * offset.x + parent[7] * offset.y) * point.localW;\n\t\t\treturn {\n\t\t\t\tx: (point.x + (parent[0] * offset.x + parent[4] * offset.y) * point.localW) / w,\n\t\t\t\ty: (point.y + (parent[1] * offset.x + parent[5] * offset.y) * point.localW) / w\n\t\t\t};\n\t\t});\n\t\tconst left = bases[projected.reduce((index, point, next) => point.x < projected[index].x ? next : index, 0)];\n\t\tconst top = bases[projected.reduce((index, point, next) => point.y < projected[index].y ? next : index, 0)];\n\t\tif (!left || !top) return initial;\n\t\tconst a = (parent[0] - target.left * parent[3]) * left.localW;\n\t\tconst b = (parent[4] - target.left * parent[7]) * left.localW;\n\t\tconst c = (parent[1] - target.top * parent[3]) * top.localW;\n\t\tconst d = (parent[5] - target.top * parent[7]) * top.localW;\n\t\tconst rx = target.left * left.w - left.x;\n\t\tconst ry = target.top * top.w - top.y;\n\t\tconst determinant = a * d - b * c;\n\t\tif (!Number.isFinite(determinant) || Math.abs(determinant) < 1e-10) return initial;\n\t\tconst next = { x: (rx * d - b * ry) / determinant, y: (a * ry - rx * c) / determinant };\n\t\tif (!Number.isFinite(next.x) || !Number.isFinite(next.y)) return initial;\n\t\tif (Math.abs(next.x - offset.x) + Math.abs(next.y - offset.y) < 1e-7) return next;\n\t\toffset = next;\n\t}\n\treturn offset;\n}\n\n/** Keep the card's tilted, raised text in its original layout when navigation takes over. */\nexport function captureCardElement(element: HTMLElement) {\n\tconst card = element.closest<HTMLElement>('[data-catalog-card]');\n\tif (!card) return;\n\treturn captureElementPlane(element, card);\n}\n\n/** Capture a nested element relative to a known planar root (also used after a live-root transfer). */\nexport function captureElementPlane(element: HTMLElement, card: HTMLElement) {\n\tconst { width, height } = borderBox(element);\n\tconst cardSize = borderBox(card);\n\tif (!width || !height || !cardSize.width || !cardSize.height) return;\n\tconst chain: HTMLElement[] = [];\n\tfor (let node = element; node !== card;) {\n\t\tchain.push(node);\n\t\tconst parent: Element | null = node.offsetParent;\n\t\tif (!(parent instanceof HTMLElement) || (parent !== card && !card.contains(parent))) return;\n\t\tnode = parent;\n\t}\n\tconst cardMatrix = localTransform(card);\n\tconst cardCorners = project(cardMatrix, cardSize.width, cardSize.height);\n\tconst rect = card.getBoundingClientRect();\n\tconst x = rect.left - Math.min(...cardCorners.map((point) => point.x));\n\tconst y = rect.top - Math.min(...cardCorners.map((point) => point.y));\n\tlet matrix = cardMatrix;\n\tfor (const node of chain.reverse()) {\n\t\tconst local = localTransform(node);\n\t\tconst size = borderBox(node);\n\t\tconst measured = node.getBoundingClientRect();\n\t\tconst localCorners = [[0, 0], [size.width, 0], [size.width, size.height], [0, size.height]]\n\t\t\t.map(([cx, cy]) => local.transformPoint(new DOMPoint(cx, cy)));\n\t\tconst offset = refineProjectedLayoutOffset(matrix.toFloat64Array(), localCorners,\n\t\t\t{ left: measured.left - x, top: measured.top - y }, { x: node.offsetLeft, y: node.offsetTop });\n\t\tmatrix = matrix.translate(offset.x, offset.y).multiply(local);\n\t}\n\tconst corners = project(matrix, width, height)\n\t\t.map((point) => ({ x: point.x + x, y: point.y + y })) as unknown as CssProjectionQuad;\n\treturn { width, height, corners };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"carouselPanelProjection.d.ts","sourceRoot":"","sources":["../../src/catalog/carouselPanelProjection.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,KAAK,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAO7F,kFAAkF;AAClF,wBAAgB,mBAAmB,CAClC,KAAK,EAAE,WAAW,EAClB,OAAO,EAAE,iBAAiB,EAC1B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,QAGd;AAED,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,WAAW;aAb/C,iBAAiB;WAAS,MAAM;YAAU,MAAM;cAkC3D"}
1
+ {"version":3,"file":"carouselPanelProjection.d.ts","sourceRoot":"","sources":["../../src/catalog/carouselPanelProjection.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,KAAK,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAQ7F,kFAAkF;AAClF,wBAAgB,mBAAmB,CAClC,KAAK,EAAE,WAAW,EAClB,OAAO,EAAE,iBAAiB,EAC1B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,QAGd;AAED,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,WAAW;;;;cA2D1D"}
@@ -1,4 +1,5 @@
1
1
  import { getProjectiveCssMatrix3d } from '../stage/cssProjection.js';
2
+ import { refineProjectedLayoutOffset } from './cardProjection.js';
2
3
  const frames = new WeakMap();
3
4
  /** The last submitted frame survives page teardown without retaining the page. */
4
5
  export function recordCarouselPanel(panel, corners, width, height) {
@@ -9,21 +10,57 @@ export function captureCarouselElement(element) {
9
10
  const frame = panel && frames.get(panel);
10
11
  if (!panel || !frame)
11
12
  return undefined;
12
- if (element === panel)
13
- return frame;
14
- // Shared summary roles are direct children. Never guess a nested content transform.
15
- if (element.offsetParent !== panel)
16
- return undefined;
17
13
  const projection = getProjectiveCssMatrix3d(frame.corners, frame.width, frame.height);
18
14
  if (!projection)
19
15
  return undefined;
20
- const matrix = new DOMMatrix(projection);
21
- const { offsetLeft: x, offsetTop: y, offsetWidth: width, offsetHeight: height } = element;
16
+ const borderBox = (node) => {
17
+ const style = getComputedStyle(node);
18
+ const px = (name) => Number.parseFloat(style.getPropertyValue(name)) || 0;
19
+ return { width: px('width') + (style.boxSizing === 'border-box' ? 0 : px('padding-left') + px('padding-right') + px('border-left-width') + px('border-right-width')),
20
+ height: px('height') + (style.boxSizing === 'border-box' ? 0 : px('padding-top') + px('padding-bottom') + px('border-top-width') + px('border-bottom-width')) };
21
+ };
22
+ const chain = [];
23
+ for (let node = element; node !== panel;) {
24
+ chain.push(node);
25
+ const parent = node.offsetParent;
26
+ if (!(parent instanceof HTMLElement) || parent !== panel && !panel.contains(parent))
27
+ return undefined;
28
+ node = parent;
29
+ }
30
+ let matrix = new DOMMatrix(projection);
31
+ const panelSize = borderBox(panel);
32
+ const projectedPanel = [[0, 0], [panelSize.width, 0], [panelSize.width, panelSize.height], [0, panelSize.height]]
33
+ .map(([x, y]) => matrix.transformPoint(new DOMPoint(x, y)));
34
+ const panelRect = panel.getBoundingClientRect();
35
+ // Native document movement can precede the next submitted GPU frame. Keep the
36
+ // cached projective plane but rebase its translation to the current source DOM.
37
+ matrix = new DOMMatrix().translate(panelRect.left - Math.min(...projectedPanel.map(point => point.x / point.w)), panelRect.top - Math.min(...projectedPanel.map(point => point.y / point.w))).multiply(matrix);
38
+ // The persistent island/query wrappers can introduce positioned and scrolling
39
+ // ancestors. Resolve each actual local plane, retaining fractional CSS sizes.
40
+ for (const node of chain.reverse()) {
41
+ const style = getComputedStyle(node);
42
+ if ([style.translate, style.rotate, style.scale].some(value => value && value !== 'none'))
43
+ return undefined;
44
+ const [x, y, z = 0] = style.transformOrigin.split(' ').map(Number.parseFloat);
45
+ if (![x, y, z].every(Number.isFinite))
46
+ return undefined;
47
+ const local = new DOMMatrix().translate(x, y, z)
48
+ .multiply(new DOMMatrix(style.transform === 'none' ? undefined : style.transform)).translate(-x, -y, -z);
49
+ const size = borderBox(node);
50
+ const measured = node.getBoundingClientRect();
51
+ const localCorners = [[0, 0], [size.width, 0], [size.width, size.height], [0, size.height]]
52
+ .map(([cx, cy]) => local.transformPoint(new DOMPoint(cx, cy)));
53
+ const offset = refineProjectedLayoutOffset(matrix.toFloat64Array(), localCorners, { left: measured.left, top: measured.top }, { x: node.offsetLeft, y: node.offsetTop });
54
+ matrix = matrix.translate(offset.x, offset.y).multiply(local);
55
+ }
56
+ const { width, height } = borderBox(element);
57
+ if (!width || !height)
58
+ return undefined;
22
59
  const corners = [
23
- [x, y],
24
- [x + width, y],
25
- [x + width, y + height],
26
- [x, y + height]
60
+ [0, 0],
61
+ [width, 0],
62
+ [width, height],
63
+ [0, height]
27
64
  ].map(([x, y]) => {
28
65
  const point = matrix.transformPoint(new DOMPoint(x, y));
29
66
  return { x: point.x / point.w, y: point.y / point.w };
@@ -1 +1 @@
1
- {"version":3,"file":"carouselPanelProjection.js","sourceRoot":"","sources":["../../src/catalog/carouselPanelProjection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAA0B,MAAM,2BAA2B,CAAC;AAE7F,MAAM,MAAM,GAAG,IAAI,OAAO,EAGvB,CAAC;AAEJ,kFAAkF;AAClF,MAAM,UAAU,mBAAmB,CAClC,KAAkB,EAClB,OAA0B,EAC1B,KAAa,EACb,MAAc;IAEd,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;AAC/C,CAAC;AAED,MAAM,UAAU,sBAAsB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AC,CAAC,EAAE,CAAC;IACvD,CAAC,CAAiC,CAAC;IACnC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;AACnC,CAAC","sourcesContent":["import { getProjectiveCssMatrix3d, type CssProjectionQuad } from '../stage/cssProjection.js';\n\nconst frames = new WeakMap<\n\tHTMLElement,\n\t{ corners: CssProjectionQuad; width: number; height: number }\n>();\n\n/** The last submitted frame survives page teardown without retaining the page. */\nexport function recordCarouselPanel(\n\tpanel: HTMLElement,\n\tcorners: CssProjectionQuad,\n\twidth: number,\n\theight: number\n) {\n\tframes.set(panel, { corners, width, height });\n}\n\nexport function captureCarouselElement(element: HTMLElement) {\n\tconst panel = element.closest<HTMLElement>('[data-carousel-spatial-element] .summary');\n\tconst frame = panel && frames.get(panel);\n\tif (!panel || !frame) return undefined;\n\tif (element === panel) return frame;\n\t// Shared summary roles are direct children. Never guess a nested content transform.\n\tif (element.offsetParent !== panel) return undefined;\n\tconst projection = getProjectiveCssMatrix3d(frame.corners, frame.width, frame.height);\n\tif (!projection) return undefined;\n\tconst matrix = new DOMMatrix(projection);\n\tconst { offsetLeft: x, offsetTop: y, offsetWidth: width, offsetHeight: height } = element;\n\tconst corners = [\n\t\t[x, y],\n\t\t[x + width, y],\n\t\t[x + width, y + height],\n\t\t[x, y + height]\n\t].map(([x, y]) => {\n\t\tconst point = matrix.transformPoint(new DOMPoint(x, y));\n\t\treturn { x: point.x / point.w, y: point.y / point.w };\n\t}) as unknown as CssProjectionQuad;\n\treturn { corners, width, height };\n}\n"]}
1
+ {"version":3,"file":"carouselPanelProjection.js","sourceRoot":"","sources":["../../src/catalog/carouselPanelProjection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAA0B,MAAM,2BAA2B,CAAC;AAC7F,OAAO,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CAAC;AAElE,MAAM,MAAM,GAAG,IAAI,OAAO,EAGvB,CAAC;AAEJ,kFAAkF;AAClF,MAAM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EAAE,MAAM,CAAC;KACX,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE;QAChB,MAAM,KAAK,GAAG,MAAM,CAAC,cAAc,CAAC,IAAI,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QACxD,OAAO,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,EAAE,CAAC;IACvD,CAAC,CAAiC,CAAC;IACnC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;AACnC,CAAC","sourcesContent":["import { getProjectiveCssMatrix3d, type CssProjectionQuad } from '../stage/cssProjection.js';\nimport { refineProjectedLayoutOffset } from './cardProjection.js';\n\nconst frames = new WeakMap<\n\tHTMLElement,\n\t{ corners: CssProjectionQuad; width: number; height: number }\n>();\n\n/** The last submitted frame survives page teardown without retaining the page. */\nexport function recordCarouselPanel(\n\tpanel: HTMLElement,\n\tcorners: CssProjectionQuad,\n\twidth: number,\n\theight: number\n) {\n\tframes.set(panel, { corners, width, height });\n}\n\nexport function captureCarouselElement(element: HTMLElement) {\n\tconst panel = element.closest<HTMLElement>('[data-carousel-spatial-element] .summary');\n\tconst frame = panel && frames.get(panel);\n\tif (!panel || !frame) return undefined;\n\tconst projection = getProjectiveCssMatrix3d(frame.corners, frame.width, frame.height);\n\tif (!projection) return undefined;\n\tconst borderBox = (node: HTMLElement) => {\n\t\tconst style = getComputedStyle(node);\n\t\tconst px = (name: string) => Number.parseFloat(style.getPropertyValue(name)) || 0;\n\t\treturn { width: px('width') + (style.boxSizing === 'border-box' ? 0 : px('padding-left') + px('padding-right') + px('border-left-width') + px('border-right-width')),\n\t\t\theight: px('height') + (style.boxSizing === 'border-box' ? 0 : px('padding-top') + px('padding-bottom') + px('border-top-width') + px('border-bottom-width')) };\n\t};\n\tconst chain: HTMLElement[] = [];\n\tfor (let node = element; node !== panel;) {\n\t\tchain.push(node);\n\t\tconst parent: Element | null = node.offsetParent;\n\t\tif (!(parent instanceof HTMLElement) || parent !== panel && !panel.contains(parent)) return undefined;\n\t\tnode = parent;\n\t}\n\tlet matrix = new DOMMatrix(projection);\n\tconst panelSize = borderBox(panel);\n\tconst projectedPanel = [[0, 0], [panelSize.width, 0], [panelSize.width, panelSize.height], [0, panelSize.height]]\n\t\t.map(([x, y]) => matrix.transformPoint(new DOMPoint(x, y)));\n\tconst panelRect = panel.getBoundingClientRect();\n\t// Native document movement can precede the next submitted GPU frame. Keep the\n\t// cached projective plane but rebase its translation to the current source DOM.\n\tmatrix = new DOMMatrix().translate(\n\t\tpanelRect.left - Math.min(...projectedPanel.map(point => point.x / point.w)),\n\t\tpanelRect.top - Math.min(...projectedPanel.map(point => point.y / point.w))\n\t).multiply(matrix);\n\t// The persistent island/query wrappers can introduce positioned and scrolling\n\t// ancestors. Resolve each actual local plane, retaining fractional CSS sizes.\n\tfor (const node of chain.reverse()) {\n\t\tconst style = getComputedStyle(node);\n\t\tif ([style.translate, style.rotate, style.scale].some(value => value && value !== 'none')) return undefined;\n\t\tconst [x, y, z = 0] = style.transformOrigin.split(' ').map(Number.parseFloat);\n\t\tif (![x, y, z].every(Number.isFinite)) return undefined;\n\t\tconst local = new DOMMatrix().translate(x, y, z)\n\t\t\t.multiply(new DOMMatrix(style.transform === 'none' ? undefined : style.transform)).translate(-x, -y, -z);\n\t\tconst size = borderBox(node);\n\t\tconst measured = node.getBoundingClientRect();\n\t\tconst localCorners = [[0, 0], [size.width, 0], [size.width, size.height], [0, size.height]]\n\t\t\t.map(([cx, cy]) => local.transformPoint(new DOMPoint(cx, cy)));\n\t\tconst offset = refineProjectedLayoutOffset(matrix.toFloat64Array(), localCorners,\n\t\t\t{ left: measured.left, top: measured.top }, { x: node.offsetLeft, y: node.offsetTop });\n\t\tmatrix = matrix.translate(offset.x, offset.y).multiply(local);\n\t}\n\tconst { width, height } = borderBox(element);\n\tif (!width || !height) return undefined;\n\tconst corners = [\n\t\t[0, 0],\n\t\t[width, 0],\n\t\t[width, height],\n\t\t[0, height]\n\t].map(([x, y]) => {\n\t\tconst point = matrix.transformPoint(new DOMPoint(x, y));\n\t\treturn { x: point.x / point.w, y: point.y / point.w };\n\t}) as unknown as CssProjectionQuad;\n\treturn { corners, width, height };\n}\n"]}
@@ -0,0 +1,5 @@
1
+ /** Keep native focus immediate while identifying only its activation-owned GPU work. */
2
+ export declare function focusCatalogLink(anchor: HTMLAnchorElement, event: MouseEvent): void;
3
+ /** Unrelated or reentrant focus changes retain their ordinary immediate invalidation. */
4
+ export declare function isCatalogActivationFocus(event: FocusEvent): boolean;
5
+ //# sourceMappingURL=catalogActivationFocus.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalogActivationFocus.d.ts","sourceRoot":"","sources":["../../src/catalog/catalogActivationFocus.ts"],"names":[],"mappings":"AAwBA,wFAAwF;AACxF,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,iBAAiB,EAAE,KAAK,EAAE,UAAU,GAAG,IAAI,CAMnF;AAED,yFAAyF;AACzF,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAKnE"}
@@ -0,0 +1,39 @@
1
+ // The scope exists only while our own synchronous focus() dispatches its events.
2
+ // It neither classifies trusted input nor claims that a router accepted the click.
3
+ let activationFocus;
4
+ function ordinaryLinkActivation(anchor, event) {
5
+ if (event.defaultPrevented || event.button !== 0 || event.metaKey || event.ctrlKey ||
6
+ event.shiftKey || event.altKey || anchor.getAttribute('role') === 'button' ||
7
+ anchor.hasAttribute('download') || anchor.target || anchor.relList.contains('external') ||
8
+ anchor.closest('[data-sveltekit-keepfocus], [data-sveltekit-noscroll], [data-sveltekit-replacestate], [data-sveltekit-reload]'))
9
+ return false;
10
+ try {
11
+ const current = new URL(anchor.ownerDocument.URL);
12
+ const destination = new URL(anchor.href, anchor.ownerDocument.baseURI);
13
+ return destination.origin === current.origin && destination.pathname !== current.pathname &&
14
+ (destination.protocol === 'http:' || destination.protocol === 'https:');
15
+ }
16
+ catch {
17
+ return false;
18
+ }
19
+ }
20
+ /** Keep native focus immediate while identifying only its activation-owned GPU work. */
21
+ export function focusCatalogLink(anchor, event) {
22
+ const preceding = activationFocus;
23
+ activationFocus = ordinaryLinkActivation(anchor, event)
24
+ ? { anchor, previous: anchor.ownerDocument.activeElement } : undefined;
25
+ try {
26
+ anchor.focus({ preventScroll: true });
27
+ }
28
+ finally {
29
+ activationFocus = preceding;
30
+ }
31
+ }
32
+ /** Unrelated or reentrant focus changes retain their ordinary immediate invalidation. */
33
+ export function isCatalogActivationFocus(event) {
34
+ const scope = activationFocus;
35
+ return Boolean(scope && (event.type === 'focusin'
36
+ ? event.target === scope.anchor
37
+ : event.type === 'focusout' && event.target === scope.previous && event.relatedTarget === scope.anchor));
38
+ }
39
+ //# sourceMappingURL=catalogActivationFocus.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalogActivationFocus.js","sourceRoot":"","sources":["../../src/catalog/catalogActivationFocus.ts"],"names":[],"mappings":"AAKA,iFAAiF;AACjF,mFAAmF;AACnF,IAAI,eAA4C,CAAC;AAEjD,SAAS,sBAAsB,CAAC,MAAyB,EAAE,KAAiB;IAC3E,IAAI,KAAK,CAAC,gBAAgB,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,OAAO;QACjF,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,MAAM,IAAI,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,KAAK,QAAQ;QAC1E,MAAM,CAAC,YAAY,CAAC,UAAU,CAAC,IAAI,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC;QACvF,MAAM,CAAC,OAAO,CAAC,+GAA+G,CAAC;QAAE,OAAO,KAAK,CAAC;IAC/I,IAAI,CA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Q,IAAI,KAAK,CAAC,aAAa,KAAK,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;AAC3G,CAAC","sourcesContent":["interface ActivationFocus {\n\tanchor: HTMLAnchorElement;\n\tprevious: Element | null;\n}\n\n// The scope exists only while our own synchronous focus() dispatches its events.\n// It neither classifies trusted input nor claims that a router accepted the click.\nlet activationFocus: ActivationFocus | undefined;\n\nfunction ordinaryLinkActivation(anchor: HTMLAnchorElement, event: MouseEvent): boolean {\n\tif (event.defaultPrevented || event.button !== 0 || event.metaKey || event.ctrlKey ||\n\t\tevent.shiftKey || event.altKey || anchor.getAttribute('role') === 'button' ||\n\t\tanchor.hasAttribute('download') || anchor.target || anchor.relList.contains('external') ||\n\t\tanchor.closest('[data-sveltekit-keepfocus], [data-sveltekit-noscroll], [data-sveltekit-replacestate], [data-sveltekit-reload]')) return false;\n\ttry {\n\t\tconst current = new URL(anchor.ownerDocument.URL);\n\t\tconst destination = new URL(anchor.href, anchor.ownerDocument.baseURI);\n\t\treturn destination.origin === current.origin && destination.pathname !== current.pathname &&\n\t\t\t(destination.protocol === 'http:' || destination.protocol === 'https:');\n\t} catch {\n\t\treturn false;\n\t}\n}\n\n/** Keep native focus immediate while identifying only its activation-owned GPU work. */\nexport function focusCatalogLink(anchor: HTMLAnchorElement, event: MouseEvent): void {\n\tconst preceding = activationFocus;\n\tactivationFocus = ordinaryLinkActivation(anchor, event)\n\t\t? { anchor, previous: anchor.ownerDocument.activeElement } : undefined;\n\ttry { anchor.focus({ preventScroll: true }); }\n\tfinally { activationFocus = preceding; }\n}\n\n/** Unrelated or reentrant focus changes retain their ordinary immediate invalidation. */\nexport function isCatalogActivationFocus(event: FocusEvent): boolean {\n\tconst scope = activationFocus;\n\treturn Boolean(scope && (event.type === 'focusin'\n\t\t? event.target === scope.anchor\n\t\t: event.type === 'focusout' && event.target === scope.previous && event.relatedTarget === scope.anchor));\n}\n"]}
@@ -7,6 +7,8 @@ export interface CatalogViewContext {
7
7
  targetSection?: string;
8
8
  sourceOccurrence?: string;
9
9
  targetOccurrence?: string;
10
+ /** Explicit detail endpoint contract; unknown fragment positions keep ordinary navigation. */
11
+ targetPresentation?: 'hero' | 'dock';
10
12
  }
11
13
  export type CatalogJourney = {
12
14
  kind: 'spatialElement';
@@ -1 +1 @@
1
- {"version":3,"file":"catalogJourney.d.ts","sourceRoot":"","sources":["../../src/catalog/catalogJourney.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC5F,OAAO,EAAwB,KAAK,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAEzF,6EAA6E;AAC7E,MAAM,WAAW,kBAAkB;IAClC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,MAAM,cAAc,GACvB;IAAE,IAAI,EAAE,gBAAgB,CAAC;IAAC,MAAM,EAAE,uBAAuB,CAAA;CAAE,GAC3D;IAAE,IAAI,EAAE,cAAc,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAEjF,wBAAgB,qBAAqB,CACpC,IAAI,EAAE,GAAG,EACT,EAAE,EAAE,GAAG,EACP,IAAI,EAAE,MAAM,GACV,cAAc,GAAG,SAAS,CAqB5B;AAED,MAAM,WAAW,0BAA2B,SAAQ,sBAAsB;IACzE,IAAI,EAAE,UAAU,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6DAA6D;IAC7D,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;IAClB,QAA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AAM,OAAO,GAAG,OAAO,CAAC,gBAAgB;QACvC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,gBAAgB,KAAK,OAAO,CAAC,gBAAgB,CAAC;QAC7E,CAAC,CAAC,SAAS,CAAC,MAAM,KAAK,CAAC;YACvB,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;YACd,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAClE,IAAI,CAAC,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC;QAAE,OAAO,EAAE,CAAC;IAChE,OAAO;QACN,OAAO;QACP,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;KACrF,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAC5C,CAAC","sourcesContent":["import type { CatalogEndpointAddress, CatalogIdentity } from './CatalogEndpointRegistry.js';\nimport { resolveCatalogIntent, type CatalogNavigationIntent } from './catalogRecipes.js';\n\n/** Optional enhancement on an ordinary anchor; URLs remain authoritative. */\nexport interface CatalogViewContext {\n\tspatialElementId?: string;\n\tsourceSection?: string;\n\ttargetSection?: string;\n\tsourceOccurrence?: string;\n\ttargetOccurrence?: string;\n}\n\nexport type CatalogJourney =\n\t| { kind: 'spatialElement'; intent: CatalogNavigationIntent }\n\t| { kind: 'content-view'; brandId: string; history: boolean; section?: string };\n\nexport function resolveCatalogJourney(\n\tfrom: URL,\n\tto: URL,\n\ttype: string\n): CatalogJourney | undefined {\n\tconst intent = resolveCatalogIntent(from, to, type);\n\tif (intent) return { kind: 'spatialElement', intent };\n\tif (from.origin !== to.origin || (from.pathname === to.pathname && from.search === to.search))\n\t\treturn;\n\tconst pattern = /^\\/([^/]+)\\/categories\\/(?:list|carousel|mixed)\\/?$/;\n\tconst source = pattern.exec(from.pathname),\n\t\ttarget = pattern.exec(to.pathname);\n\tif (!source || !target) return;\n\ttry {\n\t\tconst brandId = decodeURIComponent(source[1]);\n\t\tif (brandId !== decodeURIComponent(target[1])) return;\n\t\treturn {\n\t\t\tkind: 'content-view',\n\t\t\tbrandId,\n\t\t\thistory: type === 'popstate',\n\t\t\tsection: to.hash ? decodeURIComponent(to.hash.slice(1)) : undefined\n\t\t};\n\t} catch {\n\t\treturn;\n\t}\n}\n\nexport interface CatalogParticipantEndpoint extends CatalogEndpointAddress {\n\trole: 'geometry';\n\tsectionId?: string;\n\t/** Explicit authored order, never DOM registration order. */\n\torder: number;\n\teligible: boolean;\n\tprepared: boolean;\n\tselected?: boolean;\n\tfocused?: boolean;\n}\n\nexport interface CatalogParticipantPair {\n\tidentity: CatalogIdentity;\n\tsource: CatalogParticipantEndpoint;\n\ttarget: CatalogParticipantEndpoint;\n}\n\n/** Pure, frozen pairing. Ambiguous occurrences never borrow another element's panel. */\nexport function planCatalogParticipants(\n\tsources: readonly CatalogParticipantEndpoint[],\n\ttargets: readonly CatalogParticipantEndpoint[],\n\tcontext: CatalogViewContext = {},\n\tlimit = 5\n): CatalogParticipantPair[] {\n\tconst source = sources.filter(\n\t\t(p) =>\n\t\t\tp.eligible &&\n\t\t\tp.prepared &&\n\t\t\t(!context.sourceSection || p.sectionId === context.sourceSection) &&\n\t\t\t(!context.sourceOccurrence || p.occurrence === context.sourceOccurrence)\n\t);\n\tconst target = targets.filter(\n\t\t(p) =>\n\t\t\tp.eligible &&\n\t\t\tp.prepared &&\n\t\t\t(!context.targetSection || p.sectionId === context.targetSection) &&\n\t\t\t(!context.targetOccurrence || p.occurrence === context.targetOccurrence)\n\t);\n\tconst key = (p: CatalogIdentity) => JSON.stringify([p.brandId, p.spatialElementId]);\n\tconst pairs: CatalogParticipantPair[] = [];\n\tfor (const p of source) {\n\t\tif (source.filter((other) => key(other) === key(p)).length !== 1) continue;\n\t\tconst matches = target.filter((other) => key(other) === key(p));\n\t\tif (matches.length !== 1) continue;\n\t\tpairs.push({\n\t\t\tidentity: { brandId: p.brandId, spatialElementId: p.spatialElementId },\n\t\t\tsource: { ...p },\n\t\t\ttarget: { ...matches[0] }\n\t\t});\n\t}\n\tconst activated = pairs.filter((p) => p.source.selected || p.source.focused);\n\tconst primary = context.spatialElementId\n\t\t? pairs.find((p) => p.identity.spatialElementId === context.spatialElementId)\n\t\t: activated.length === 1\n\t\t\t? activated[0]\n\t\t\t: [...pairs].sort((a, b) => a.source.order - b.source.order)[0];\n\tif (!primary || !Number.isFinite(limit) || limit < 1) return [];\n\treturn [\n\t\tprimary,\n\t\t...pairs.filter((p) => p !== primary).sort((a, b) => a.source.order - b.source.order)\n\t].slice(0, Math.min(5, Math.floor(limit)));\n}\n"]}
1
+ {"version":3,"file":"catalogJourney.js","sourceRoot":"","sources":["../../src/catalog/catalogJourney.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAgC,MAAM,qBAAqB,CAAC;AAiBzF,MAAM,UAAU,qBAAqB,CACpC,IAAS,EACT,EAAO,EACP,IAAY;IAEZ,MAAM,MAAM,GAAG,oBAAoB,CAAC,IAAI,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC;IACpD,IAAI,MAAM;QAAE,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,MAAM,EAAE,CAAC;IACtD,IAAI,IAAI,CAAC,MAAM,KAAK,EA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ACD,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,IAAI,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAC7E,MAAM,OAAO,GAAG,OAAO,CAAC,gBAAgB;QACvC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,gBAAgB,KAAK,OAAO,CAAC,gBAAgB,CAAC;QAC7E,CAAC,CAAC,SAAS,CAAC,MAAM,KAAK,CAAC;YACvB,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;YACd,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAClE,IAAI,CAAC,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC;QAAE,OAAO,EAAE,CAAC;IAChE,OAAO;QACN,OAAO;QACP,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;KACrF,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAC5C,CAAC","sourcesContent":["import type { CatalogEndpointAddress, CatalogIdentity } from './CatalogEndpointRegistry.js';\nimport { resolveCatalogIntent, type CatalogNavigationIntent } from './catalogRecipes.js';\n\n/** Optional enhancement on an ordinary anchor; URLs remain authoritative. */\nexport interface CatalogViewContext {\n\tspatialElementId?: string;\n\tsourceSection?: string;\n\ttargetSection?: string;\n\tsourceOccurrence?: string;\n\ttargetOccurrence?: string;\n\t/** Explicit detail endpoint contract; unknown fragment positions keep ordinary navigation. */\n\ttargetPresentation?: 'hero' | 'dock';\n}\n\nexport type CatalogJourney =\n\t| { kind: 'spatialElement'; intent: CatalogNavigationIntent }\n\t| { kind: 'content-view'; brandId: string; history: boolean; section?: string };\n\nexport function resolveCatalogJourney(\n\tfrom: URL,\n\tto: URL,\n\ttype: string\n): CatalogJourney | undefined {\n\tconst intent = resolveCatalogIntent(from, to, type);\n\tif (intent) return { kind: 'spatialElement', intent };\n\tif (from.origin !== to.origin || (from.pathname === to.pathname && from.search === to.search))\n\t\treturn;\n\tconst pattern = /^\\/([^/]+)\\/categories\\/(?:list|carousel|mixed)\\/?$/;\n\tconst source = pattern.exec(from.pathname),\n\t\ttarget = pattern.exec(to.pathname);\n\tif (!source || !target) return;\n\ttry {\n\t\tconst brandId = decodeURIComponent(source[1]);\n\t\tif (brandId !== decodeURIComponent(target[1])) return;\n\t\treturn {\n\t\t\tkind: 'content-view',\n\t\t\tbrandId,\n\t\t\thistory: type === 'popstate',\n\t\t\tsection: to.hash ? decodeURIComponent(to.hash.slice(1)) : undefined\n\t\t};\n\t} catch {\n\t\treturn;\n\t}\n}\n\nexport interface CatalogParticipantEndpoint extends CatalogEndpointAddress {\n\trole: 'geometry';\n\tsectionId?: string;\n\t/** Explicit authored order, never DOM registration order. */\n\torder: number;\n\teligible: boolean;\n\tprepared: boolean;\n\tselected?: boolean;\n\tfocused?: boolean;\n}\n\nexport interface CatalogParticipantPair {\n\tidentity: CatalogIdentity;\n\tsource: CatalogParticipantEndpoint;\n\ttarget: CatalogParticipantEndpoint;\n}\n\n/** Pure, frozen pairing. Ambiguous occurrences never borrow another element's panel. */\nexport function planCatalogParticipants(\n\tsources: readonly CatalogParticipantEndpoint[],\n\ttargets: readonly CatalogParticipantEndpoint[],\n\tcontext: CatalogViewContext = {},\n\tlimit = 5\n): CatalogParticipantPair[] {\n\tconst source = sources.filter(\n\t\t(p) =>\n\t\t\tp.eligible &&\n\t\t\tp.prepared &&\n\t\t\t(!context.sourceSection || p.sectionId === context.sourceSection) &&\n\t\t\t(!context.sourceOccurrence || p.occurrence === context.sourceOccurrence)\n\t);\n\tconst target = targets.filter(\n\t\t(p) =>\n\t\t\tp.eligible &&\n\t\t\tp.prepared &&\n\t\t\t(!context.targetSection || p.sectionId === context.targetSection) &&\n\t\t\t(!context.targetOccurrence || p.occurrence === context.targetOccurrence)\n\t);\n\tconst key = (p: CatalogIdentity) => JSON.stringify([p.brandId, p.spatialElementId]);\n\tconst pairs: CatalogParticipantPair[] = [];\n\tfor (const p of source) {\n\t\tif (source.filter((other) => key(other) === key(p)).length !== 1) continue;\n\t\tconst matches = target.filter((other) => key(other) === key(p));\n\t\tif (matches.length !== 1) continue;\n\t\tpairs.push({\n\t\t\tidentity: { brandId: p.brandId, spatialElementId: p.spatialElementId },\n\t\t\tsource: { ...p },\n\t\t\ttarget: { ...matches[0] }\n\t\t});\n\t}\n\tconst activated = pairs.filter((p) => p.source.selected || p.source.focused);\n\tconst primary = context.spatialElementId\n\t\t? pairs.find((p) => p.identity.spatialElementId === context.spatialElementId)\n\t\t: activated.length === 1\n\t\t\t? activated[0]\n\t\t\t: [...pairs].sort((a, b) => a.source.order - b.source.order)[0];\n\tif (!primary || !Number.isFinite(limit) || limit < 1) return [];\n\treturn [\n\t\tprimary,\n\t\t...pairs.filter((p) => p !== primary).sort((a, b) => a.source.order - b.source.order)\n\t].slice(0, Math.min(5, Math.floor(limit)));\n}\n"]}
@@ -1,3 +1,14 @@
1
+ import { type CarouselLayoutInput, type LayoutRect } from '../spatial-element/responsiveLayout.js';
2
+ export interface CarouselFraming {
3
+ compact: boolean;
4
+ fit: LayoutRect;
5
+ summary: {
6
+ x: number;
7
+ width: number;
8
+ anchorY: number;
9
+ alignment: 'center' | 'end';
10
+ };
11
+ }
1
12
  /** Section-local screen framing, independent of assets and camera ownership. */
2
13
  export interface CatalogPose {
3
14
  x: number;
@@ -17,6 +28,7 @@ export interface CatalogPose {
17
28
  y: number;
18
29
  pitch: number;
19
30
  };
31
+ framing?: CarouselFraming;
20
32
  }
21
33
  export interface CatalogPoseProvider {
22
34
  kind: 'carousel';
@@ -35,7 +47,13 @@ export interface CarouselLayout {
35
47
  height: number;
36
48
  left: number;
37
49
  viewportWidth: number;
50
+ framing?: CarouselFraming;
38
51
  }
52
+ /** Convert predictable viewport rules to the existing section-local scene clock. */
53
+ export declare function resolveCarouselPoseLayout(input: CarouselLayoutInput, ring: {
54
+ width: number;
55
+ left: number;
56
+ }): CarouselLayout;
39
57
  export interface CarouselEmphasis {
40
58
  advance: number;
41
59
  panel: number;
@@ -1 +1 @@
1
- {"version":3,"file":"catalogPose.d.ts","sourceRoot":"","sources":["../../src/catalog/catalogPose.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,MAAM,WAAW,WAAW;IAC3B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,OAAO,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,mFAAmF;IACnF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,iGAAiG;IACjG,KAAK,CAAC,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;CAChD;AAED,MAAM,WAAW,mBAAmB;IACnC,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,IAAI,WAAW,CAAC;CACpB;AAED,2EAA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Q,mBAA0D;AAClE,qEAAqE;AACrE,KAAK,SAAI,GACP,WAAW,CAkBb;AAED,eAAO,MAAM,oBAAoB,yBAAyB,CAAC"}
@@ -1,3 +1,22 @@
1
+ import { resolveCarouselLayout, spatialLayoutTokens } from '../spatial-element/responsiveLayout.js';
2
+ /** Convert predictable viewport rules to the existing section-local scene clock. */
3
+ export function resolveCarouselPoseLayout(input, ring) {
4
+ const resolved = resolveCarouselLayout(input);
5
+ const compact = resolved.summary.placement === 'compact';
6
+ const titleHeight = compact ? spatialLayoutTokens.carousel.compactEyebrowHeight : 0;
7
+ const ringTop = resolved.mediaFit.y - titleHeight;
8
+ return {
9
+ width: ring.width, height: resolved.mediaFit.height + titleHeight,
10
+ left: ring.left, viewportWidth: resolved.base.layoutWidth,
11
+ framing: {
12
+ compact,
13
+ fit: { ...resolved.mediaFit, x: resolved.mediaFit.x - ring.left, y: titleHeight },
14
+ summary: { x: resolved.summary.x - ring.left, width: resolved.summary.width,
15
+ anchorY: compact ? titleHeight : resolved.summary.anchor.y - ringTop,
16
+ alignment: compact ? 'end' : 'center' }
17
+ }
18
+ };
19
+ }
1
20
  const defaultLayout = { width: 1320, height: 560, left: 60, viewportWidth: 1440 };
2
21
  export function carouselEmphasis(distance) {
3
22
  return { advance: Math.max(0, 1 - distance * distance) ** 2,
@@ -22,8 +41,9 @@ export class CarouselDragEmphasis {
22
41
  }
23
42
  }
24
43
  function framing(distance, presentation, layout, emphasis = carouselEmphasis(distance)) {
25
- const compact = layout.width < 700;
26
- const frame = Math.min(layout.width, compact ? 360 : layout.height);
44
+ const compact = layout.framing?.compact ?? layout.viewportWidth < spatialLayoutTokens.layoutMinWidths.m;
45
+ const fit = layout.framing?.fit;
46
+ const frame = fit ? Math.min(fit.width, fit.height) : Math.min(layout.width, compact ? 360 : layout.height);
27
47
  const spacing = Number.isFinite(presentation.radius)
28
48
  ? Math.max(0.2, Math.min(0.7, presentation.radius)) : 0.48;
29
49
  const depth = Number.isFinite(presentation.depth)
@@ -48,7 +68,7 @@ function framing(distance, presentation, layout, emphasis = carouselEmphasis(dis
48
68
  pitch
49
69
  };
50
70
  const scale = 2500 / (2500 - z);
51
- const anchor = layout.left + layout.width * (compact ? 0.5 : 0.31);
71
+ const anchor = layout.left + (fit ? fit.x + fit.width / 2 : layout.width * (compact ? 0.5 : 0.31));
52
72
  const center = layout.viewportWidth / 2 + (anchor - layout.viewportWidth / 2 + orbit.x) * scale;
53
73
  const offset = center - anchor;
54
74
  const extent = frame * 0.82 * scale * 0.6;
@@ -74,11 +94,12 @@ focus = 1) {
74
94
  const { offset, scale, center, extent, orbit, z, angle, arcOpacity } = framing(distance, presentation, layout, emphasis);
75
95
  const edge = Math.max(0, Math.min(1, (center + extent) / 48, (layout.viewportWidth - center + extent) / 48)) * arcOpacity;
76
96
  return {
77
- x: 0.5 + offset / Math.max(1, layout.width),
78
- y: 0.54 - orbit.y * scale / Math.max(1, layout.height),
97
+ x: (layout.framing ? layout.framing.fit.x + layout.framing.fit.width / 2 : layout.width * 0.5) / Math.max(1, layout.width) + offset / Math.max(1, layout.width),
98
+ y: (layout.framing ? layout.framing.fit.y + layout.framing.fit.height / 2 : layout.height * 0.54) / Math.max(1, layout.height) - orbit.y * scale / Math.max(1, layout.height),
79
99
  size: 0.82 * scale,
80
100
  depth: z,
81
101
  orbit,
102
+ ...(layout.framing ? { framing: layout.framing } : {}),
82
103
  yaw: angle,
83
104
  visible: edge > 0,
84
105
  front: Math.abs(distance) <= 0.5,
@@ -1 +1 @@
1
- {"version":3,"file":"catalogPose.js","sourceRoot":"","sources":["../../src/catalog/catalogPose.ts"],"names":[],"mappings":"AAsCA,MAAM,aAAa,GAAmB,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC;AAIlG,MAAM,UAAU,gBAAgB,CAAC,QAAgB;IAChD,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,GAAG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C;IAC1H,OAAO;QACN,CAAC,EAAE,GAAG,GAAG,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC;QAC3C,CAAC,EAAE,IAAI,GAAG,KAAK,CAAC,CAAC,GAAG,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC;QACtD,IAAI,EAAE,IAAI,GAAG,KAAK;QAClB,KAAK,EAAE,CAAC;QACR,KAAK;QACL,GAAG,EAAE,KAAK;QACV,OAAO,EAAE,IAAI,GAAG,CAAC;QACjB,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,GAAG;QAChC,YAAY,EAAE,QAAQ,CAAC,KAAK;QAC5B,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,IAAI,GAAG,GAAG,GAAG,CAAC,GAAG,KAAK;QAC9E,OAAO,EAAE,IAAI;KACb,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,oBAAoB,GAAG,sBAAsB,CAAC","sourcesContent":["/** Section-local screen framing, independent of assets and camera ownership. */\nexport interface CatalogPose {\n\tx: number;\n\ty: number;\n\tsize: number;\n\tdepth: number;\n\tyaw: number;\n\tvisible: boolean;\n\tfront: boolean;\n\tpanelOpacity: number;\n\t/** CSS-pixel defocus; zero at the selected seat and continuous during dragging. */\n\tblur?: number;\n\topacity: number;\n\t/** Camera-space offsets from the shared section origin; no per-item perspective compensation. */\n\torbit?: { x: number; y: number; pitch: number };\n}\n\nexport interface CatalogPoseProvider {\n\tkind: 'carousel';\n\tread(): CatalogPose;\n}\n\n/** Presentation controls, never asset scale, URL or renderer ownership. */\nexport interface CarouselPresentation {\n\t/** Horizontal spacing multiplier, normalized around the default 0.48. */\n\tradius?: number;\n\t/** Turntable depth control in CSS-world pixels (default 700). */\n\tdepth?: number;\n}\n\n/** Cached section metrics, shared by DOM hit targets, posters and GPU poses. */\nexport interface CarouselLayout {\n\twidth: number;\n\theight: number;\n\tleft: number;\n\tviewportWidth: number;\n}\n\nconst defaultLayout: CarouselLayout = { width: 1320, height: 560, left: 60, viewportWidth: 1440 };\n\nexport interface CarouselEmphasis { advance: number; panel: number }\n\nexport function carouselEmphasis(distance: number): CarouselEmphasis {\n\treturn { advance: Math.max(0, 1 - distance * distance) ** 2,\n\t\tpanel: Math.max(0, 1 - Math.abs(distance)) ** 2 };\n}\n\n/** A gesture can only withdraw its initial presentation, never select passing seats. */\nexport class CarouselDragEmphasis {\n\tprivate travel = 0;\n\tconstructor(private readonly phase: number, private readonly initial: readonly CarouselEmphasis[]) {}\n\tmove(phase: number): CarouselEmphasis[] {\n\t\tthis.travel = Math.max(this.travel, Math.abs(phase - this.phase));\n\t\tconst remaining = carouselEmphasis(this.travel);\n\t\treturn this.initial.map(value => ({\n\t\t\tadvance: value.advance * remaining.advance,\n\t\t\tpanel: value.panel * remaining.panel\n\t\t}));\n\t}\n}\n\nfunction framing(distance: number, presentation: CarouselPresentation, layout: CarouselLayout,\n\temphasis = carouselEmphasis(distance)) {\n\tconst compact = layout.width < 700;\n\tconst frame = Math.min(layout.width, compact ? 360 : layout.height);\n\tconst spacing = Number.isFinite(presentation.radius)\n\t\t? Math.max(0.2, Math.min(0.7, presentation.radius!)) : 0.48;\n\tconst depth = Number.isFinite(presentation.depth)\n\t\t? Math.max(0, Math.min(1200, presentation.depth!)) : 700;\n\t// A larger, shallower turntable: keep useful seat spacing by reducing the\n\t// angle between products rather than packing the same angle onto a larger ring.\n\tconst radius = frame * (compact ? 2.2 : 3.4) * spacing / 0.48 * (0.75 + depth / 2800);\n\tconst step = 0.4;\n\tconst travel = Math.abs(distance);\n\t// Only the front arc is presented. Never wrap a long catalog onto occupied seats.\n\tconst angle = Math.max(-1.35, Math.min(1.35, distance * step));\n\tconst pitch = 10 * Math.PI / 180;\n\tconst pull = frame * 1.25;\n\t// Smooth at both the selected seat and the point where it rejoins the ring.\n\tconst advance = pull * emphasis.advance;\n\tconst recession = radius * (1 - Math.cos(angle)) + pull - advance;\n\tconst z = -recession * Math.cos(pitch);\n\t// Selection changes depth only; every seat retains its horizontal position.\n\tconst orbit = {\n\t\tx: radius * Math.sin(angle),\n\t\ty: recession * Math.sin(pitch),\n\t\tpitch\n\t};\n\tconst scale = 2500 / (2500 - z);\n\tconst anchor = layout.left + layout.width * (compact ? 0.5 : 0.31);\n\tconst center = layout.viewportWidth / 2 + (anchor - layout.viewportWidth / 2 + orbit.x) * scale;\n\tconst offset = center - anchor;\n\tconst extent = frame * 0.82 * scale * 0.6;\n\tconst seats = compact ? 1.49 : 3.24;\n\tconst arcOpacity = Math.max(0, Math.min(1, (seats - travel) / 0.38));\n\treturn { offset, scale, center, extent, orbit, z, angle, arcOpacity, seats };\n}\n\nexport function carouselDistance(index: number, phase: number, count: number) {\n\treturn count > 1 ? index - phase : 0;\n}\n\n/** Prepare only the viewport and a small margin, including fractional drag movement. */\nexport function carouselResident(index: number, phase: number, count: number,\n\tpresentation: CarouselPresentation = {}, layout: CarouselLayout = defaultLayout) {\n\tconst distance = carouselDistance(index, phase, count);\n\tconst { seats } = framing(distance, presentation, layout);\n\t// Include the neighbouring animation window before the front arc enters view.\n\treturn Math.abs(distance) < seats + 1;\n}\n\n/** A shared circular turntable, tilted toward the viewer, with a smooth foreground advance. */\nexport function carouselPose(\n\tindex: number,\n\tphase: number,\n\tcount: number,\n\tpresentation: CarouselPresentation = {},\n\tlayout: CarouselLayout = defaultLayout,\n\temphasis = carouselEmphasis(carouselDistance(index, phase, count)),\n\t/** Shared foreground focus: zero keeps the whole turntable sharp. */\n\tfocus = 1\n): CatalogPose {\n\tconst distance = carouselDistance(index, phase, count);\n\tconst { offset, scale, center, extent, orbit, z, angle, arcOpacity } = framing(distance, presentation, layout, emphasis);\n\tconst edge = Math.max(0, Math.min(1, (center + extent) / 48, (layout.viewportWidth - center + extent) / 48)) * arcOpacity;\n\treturn {\n\t\tx: 0.5 + offset / Math.max(1, layout.width),\n\t\ty: 0.54 - orbit.y * scale / Math.max(1, layout.height),\n\t\tsize: 0.82 * scale,\n\t\tdepth: z,\n\t\torbit,\n\t\tyaw: angle,\n\t\tvisible: edge > 0,\n\t\tfront: Math.abs(distance) <= 0.5,\n\t\tpanelOpacity: emphasis.panel,\n\t\tblur: Math.min(5, Math.max(0, Math.abs(distance) - 0.15) ** 1.4 * 2.2) * focus,\n\t\topacity: edge\n\t};\n}\n\nexport const CATALOG_POSE_CHANGED = 'catalog-pose-changed';\n"]}
1
+ {"version":3,"file":"catalogPose.js","sourceRoot":"","sources":["../../src/catalog/catalogPose.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAA6C,MAAM,wCAAwC,CAAC;AAgD/I,oFAAoF;AACpF,MAAM,UAAU,yBAAyB,CAAC,KAA0B,EAAE,IAAqC;IAC1G,MAAM,QAAQ,GAAG,qBAAqB,CAAC,KAAK,CAAC,CAAC;IAC9C,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC,SAAS,KAAK,SAAS,CAAC;IACzD,MAAM,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,mBAAmB,CAAC,QAAQ,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC;IACpF,MAAM,OAAO,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC,GAAG,WAAW,CAAC;IAClD,OAAO;QACN,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,WAAW;QACjE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,aAAa,EAAE,QAAQ,CAAC,IAAI,CAAC,WAAW;QACzD,OAAO,EAAE;YACR,OAAO;YACP,GAAG,EAAE,EAAE,GAAG,QAAQ,CAAC,QAAQ,EAAE,CAAC,EAA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spatialLayoutTokens, type CarouselLayoutInput, type LayoutRect } from '../spatial-element/responsiveLayout.js';\n\nexport interface CarouselFraming {\n\tcompact: boolean;\n\tfit: LayoutRect;\n\tsummary: { x: number; width: number; anchorY: number; alignment: 'center' | 'end' };\n}\n\n/** Section-local screen framing, independent of assets and camera ownership. */\nexport interface CatalogPose {\n\tx: number;\n\ty: number;\n\tsize: number;\n\tdepth: number;\n\tyaw: number;\n\tvisible: boolean;\n\tfront: boolean;\n\tpanelOpacity: number;\n\t/** CSS-pixel defocus; zero at the selected seat and continuous during dragging. */\n\tblur?: number;\n\topacity: number;\n\t/** Camera-space offsets from the shared section origin; no per-item perspective compensation. */\n\torbit?: { x: number; y: number; pitch: number };\n\tframing?: CarouselFraming;\n}\n\nexport interface CatalogPoseProvider {\n\tkind: 'carousel';\n\tread(): CatalogPose;\n}\n\n/** Presentation controls, never asset scale, URL or renderer ownership. */\nexport interface CarouselPresentation {\n\t/** Horizontal spacing multiplier, normalized around the default 0.48. */\n\tradius?: number;\n\t/** Turntable depth control in CSS-world pixels (default 700). */\n\tdepth?: number;\n}\n\n/** Cached section metrics, shared by DOM hit targets, posters and GPU poses. */\nexport interface CarouselLayout {\n\twidth: number;\n\theight: number;\n\tleft: number;\n\tviewportWidth: number;\n\tframing?: CarouselFraming;\n}\n\n/** Convert predictable viewport rules to the existing section-local scene clock. */\nexport function resolveCarouselPoseLayout(input: CarouselLayoutInput, ring: { width: number; left: number }): CarouselLayout {\n\tconst resolved = resolveCarouselLayout(input);\n\tconst compact = resolved.summary.placement === 'compact';\n\tconst titleHeight = compact ? spatialLayoutTokens.carousel.compactEyebrowHeight : 0;\n\tconst ringTop = resolved.mediaFit.y - titleHeight;\n\treturn {\n\t\twidth: ring.width, height: resolved.mediaFit.height + titleHeight,\n\t\tleft: ring.left, viewportWidth: resolved.base.layoutWidth,\n\t\tframing: {\n\t\t\tcompact,\n\t\t\tfit: { ...resolved.mediaFit, x: resolved.mediaFit.x - ring.left, y: titleHeight },\n\t\t\tsummary: { x: resolved.summary.x - ring.left, width: resolved.summary.width,\n\t\t\t\tanchorY: compact ? titleHeight : resolved.summary.anchor.y - ringTop,\n\t\t\t\talignment: compact ? 'end' : 'center' }\n\t\t}\n\t};\n}\n\nconst defaultLayout: CarouselLayout = { width: 1320, height: 560, left: 60, viewportWidth: 1440 };\n\nexport interface CarouselEmphasis { advance: number; panel: number }\n\nexport function carouselEmphasis(distance: number): CarouselEmphasis {\n\treturn { advance: Math.max(0, 1 - distance * distance) ** 2,\n\t\tpanel: Math.max(0, 1 - Math.abs(distance)) ** 2 };\n}\n\n/** A gesture can only withdraw its initial presentation, never select passing seats. */\nexport class CarouselDragEmphasis {\n\tprivate travel = 0;\n\tconstructor(private readonly phase: number, private readonly initial: readonly CarouselEmphasis[]) {}\n\tmove(phase: number): CarouselEmphasis[] {\n\t\tthis.travel = Math.max(this.travel, Math.abs(phase - this.phase));\n\t\tconst remaining = carouselEmphasis(this.travel);\n\t\treturn this.initial.map(value => ({\n\t\t\tadvance: value.advance * remaining.advance,\n\t\t\tpanel: value.panel * remaining.panel\n\t\t}));\n\t}\n}\n\nfunction framing(distance: number, presentation: CarouselPresentation, layout: CarouselLayout,\n\temphasis = carouselEmphasis(distance)) {\n\tconst compact = layout.framing?.compact ?? layout.viewportWidth < spatialLayoutTokens.layoutMinWidths.m;\n\tconst fit = layout.framing?.fit;\n\tconst frame = fit ? Math.min(fit.width, fit.height) : Math.min(layout.width, compact ? 360 : layout.height);\n\tconst spacing = Number.isFinite(presentation.radius)\n\t\t? Math.max(0.2, Math.min(0.7, presentation.radius!)) : 0.48;\n\tconst depth = Number.isFinite(presentation.depth)\n\t\t? Math.max(0, Math.min(1200, presentation.depth!)) : 700;\n\t// A larger, shallower turntable: keep useful seat spacing by reducing the\n\t// angle between products rather than packing the same angle onto a larger ring.\n\tconst radius = frame * (compact ? 2.2 : 3.4) * spacing / 0.48 * (0.75 + depth / 2800);\n\tconst step = 0.4;\n\tconst travel = Math.abs(distance);\n\t// Only the front arc is presented. Never wrap a long catalog onto occupied seats.\n\tconst angle = Math.max(-1.35, Math.min(1.35, distance * step));\n\tconst pitch = 10 * Math.PI / 180;\n\tconst pull = frame * 1.25;\n\t// Smooth at both the selected seat and the point where it rejoins the ring.\n\tconst advance = pull * emphasis.advance;\n\tconst recession = radius * (1 - Math.cos(angle)) + pull - advance;\n\tconst z = -recession * Math.cos(pitch);\n\t// Selection changes depth only; every seat retains its horizontal position.\n\tconst orbit = {\n\t\tx: radius * Math.sin(angle),\n\t\ty: recession * Math.sin(pitch),\n\t\tpitch\n\t};\n\tconst scale = 2500 / (2500 - z);\n\tconst anchor = layout.left + (fit ? fit.x + fit.width / 2 : layout.width * (compact ? 0.5 : 0.31));\n\tconst center = layout.viewportWidth / 2 + (anchor - layout.viewportWidth / 2 + orbit.x) * scale;\n\tconst offset = center - anchor;\n\tconst extent = frame * 0.82 * scale * 0.6;\n\tconst seats = compact ? 1.49 : 3.24;\n\tconst arcOpacity = Math.max(0, Math.min(1, (seats - travel) / 0.38));\n\treturn { offset, scale, center, extent, orbit, z, angle, arcOpacity, seats };\n}\n\nexport function carouselDistance(index: number, phase: number, count: number) {\n\treturn count > 1 ? index - phase : 0;\n}\n\n/** Prepare only the viewport and a small margin, including fractional drag movement. */\nexport function carouselResident(index: number, phase: number, count: number,\n\tpresentation: CarouselPresentation = {}, layout: CarouselLayout = defaultLayout) {\n\tconst distance = carouselDistance(index, phase, count);\n\tconst { seats } = framing(distance, presentation, layout);\n\t// Include the neighbouring animation window before the front arc enters view.\n\treturn Math.abs(distance) < seats + 1;\n}\n\n/** A shared circular turntable, tilted toward the viewer, with a smooth foreground advance. */\nexport function carouselPose(\n\tindex: number,\n\tphase: number,\n\tcount: number,\n\tpresentation: CarouselPresentation = {},\n\tlayout: CarouselLayout = defaultLayout,\n\temphasis = carouselEmphasis(carouselDistance(index, phase, count)),\n\t/** Shared foreground focus: zero keeps the whole turntable sharp. */\n\tfocus = 1\n): CatalogPose {\n\tconst distance = carouselDistance(index, phase, count);\n\tconst { offset, scale, center, extent, orbit, z, angle, arcOpacity } = framing(distance, presentation, layout, emphasis);\n\tconst edge = Math.max(0, Math.min(1, (center + extent) / 48, (layout.viewportWidth - center + extent) / 48)) * arcOpacity;\n\treturn {\n\t\tx: (layout.framing ? layout.framing.fit.x + layout.framing.fit.width / 2 : layout.width * 0.5) / Math.max(1, layout.width) + offset / Math.max(1, layout.width),\n\t\ty: (layout.framing ? layout.framing.fit.y + layout.framing.fit.height / 2 : layout.height * 0.54) / Math.max(1, layout.height) - orbit.y * scale / Math.max(1, layout.height),\n\t\tsize: 0.82 * scale,\n\t\tdepth: z,\n\t\torbit,\n\t\t...(layout.framing ? { framing: layout.framing } : {}),\n\t\tyaw: angle,\n\t\tvisible: edge > 0,\n\t\tfront: Math.abs(distance) <= 0.5,\n\t\tpanelOpacity: emphasis.panel,\n\t\tblur: Math.min(5, Math.max(0, Math.abs(distance) - 0.15) ** 1.4 * 2.2) * focus,\n\t\topacity: edge\n\t};\n}\n\nexport const CATALOG_POSE_CHANGED = 'catalog-pose-changed';\n"]}
@@ -0,0 +1,9 @@
1
+ /** Match the stable layout space used by detail endpoints, not mobile browser chrome. */
2
+ export interface CatalogTransitionViewport {
3
+ width: number;
4
+ height: number;
5
+ pixelRatio: number;
6
+ }
7
+ export declare function readCatalogTransitionViewport(): CatalogTransitionViewport;
8
+ export declare function catalogTransitionViewportChanged(before: CatalogTransitionViewport, after: CatalogTransitionViewport): boolean;
9
+ //# sourceMappingURL=catalogTransitionViewport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalogTransitionViewport.d.ts","sourceRoot":"","sources":["../../src/catalog/catalogTransitionViewport.ts"],"names":[],"mappings":"AAAA,yFAAyF;AACzF,MAAM,WAAW,yBAAyB;IACzC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,6BAA6B,IAAI,yBAAyB,CAOzE;AAED,wBAAgB,gCAAgC,CAAC,MAAM,EAAE,yBAAyB,EAAE,KAAK,EAAE,yBAAyB,WAGnH"}