@spatial-elements/sveltekit 0.1.0-beta.2 → 1.0.0-beta.3

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 (29) hide show
  1. package/README.md +9 -3
  2. package/dist/catalog/catalogNavigation.js +3 -2
  3. package/dist/spatial-element/BrandStageShell.svelte +12 -12
  4. package/dist/spatial-element/BrandStageShell.svelte.d.ts +8 -4
  5. package/dist/spatial-element/CarouselSection.svelte +5 -0
  6. package/dist/spatial-element/CarouselSection.svelte.d.ts +5 -0
  7. package/dist/spatial-element/CarouselSpatialElement.svelte +2 -2
  8. package/dist/spatial-element/ContentPage.svelte +11 -1
  9. package/dist/spatial-element/ContentPage.svelte.d.ts +7 -3
  10. package/dist/spatial-element/ListSection.svelte +11 -3
  11. package/dist/spatial-element/ListSection.svelte.d.ts +5 -3
  12. package/dist/spatial-element/SpatialElementCard.svelte +2 -2
  13. package/dist/spatial-element/SpatialElementMediaRail.svelte +1 -1
  14. package/dist/spatial-element/SpatialElementMediaRail.svelte.d.ts +1 -1
  15. package/dist/spatial-element/SpatialElementPage.svelte +16 -7
  16. package/dist/spatial-element/SpatialElementPage.svelte.d.ts +5 -3
  17. package/dist/spatial-element/SpatialElementStickyHeader.svelte +42 -37
  18. package/dist/spatial-element/SpatialElementStickyHeader.svelte.d.ts +2 -1
  19. package/dist/spatial-element/SpatialElementSummaryPanel.svelte +52 -50
  20. package/dist/spatial-element/SpatialElementSummaryPanel.svelte.d.ts +1 -1
  21. package/dist/spatial-element/SpatialListPage.svelte +4 -1
  22. package/dist/spatial-element/SpatialListPage.svelte.d.ts +2 -0
  23. package/dist/spatial-element/index.d.ts +4 -1
  24. package/dist/spatial-element/index.js +2 -0
  25. package/dist/spatial-element/spatialPageContext.d.ts +4 -0
  26. package/dist/spatial-element/spatialPageContext.js +9 -0
  27. package/dist/stage/Stage.svelte +82 -13
  28. package/dist/stage/Stage.svelte.d.ts +5 -1
  29. package/package.json +4 -4
package/README.md CHANGED
@@ -6,17 +6,23 @@ See the [authoring guide](https://github.com/LauridBergjohann/spatial-elements/b
6
6
 
7
7
  Beta API; MPL-2.0; see LICENSE.
8
8
 
9
+ Read the [getting-started tutorial](https://github.com/LauridBergjohann/spatial-elements/blob/main/docs/getting-started.md), [API reference](https://github.com/LauridBergjohann/spatial-elements/blob/main/docs/api.md) and [configuration migration](https://github.com/LauridBergjohann/spatial-elements/blob/main/docs/configuration-migration.md).
10
+
11
+ Element content and required `geometry: { low, high }` belong in `SpatialElementData`; shared appearance belongs in `SpatialTheme`. Use `createSpatialTheme({ id, name })` for defaults. The SvelteKit shell needs only the theme; pages register their own data. These docs target version `1.0.0-beta.3` and newer.
12
+
9
13
  Installation:
10
14
 
11
15
  ~~~sh
12
- npm install @spatial-elements/sveltekit@beta
16
+ npm install @spatial-elements/sveltekit@latest
13
17
  ~~~
14
18
 
15
19
  Requires Node.js 22.12+ tooling. Use in an existing Svelte 5 / SvelteKit 2 application.
16
20
 
17
21
  A visible “Built with Spatial Elements” link is appreciated, but not required. This does not replace your obligations under the MPL-2.0 license.
18
22
 
19
- Three.js is a required peer dependency (^0.185.1), shared with the application and other adapters.
23
+ Three.js is a required peer dependency (^0.186.1), shared with the application and other adapters.
20
24
  Modern npm installs it automatically. If the application imports Three.js directly, declare it
21
- explicitly with `npm install three@^0.185.1`. Do not bypass incompatible peer ranges with
25
+ explicitly with `npm install three@^0.186.1`. Do not bypass incompatible peer ranges with
22
26
  `--legacy-peer-deps`. Other package managers may require explicit peer installation.
27
+
28
+ Category lighting is explicit: pass `hdr="/assets/category.hdr"` to `ContentPage` (also `SpatialListPage`). It is never inferred from an element. Identical geometry URLs share one cached fetch/decode.
@@ -1,3 +1,4 @@
1
+ import { getSpatialElementScene, hasSpatialElementScene } from '@spatial-elements/core/spatial-element/spatialElementScene';
1
2
  import { getContext } from 'svelte';
2
3
  import { resolve } from '$app/paths';
3
4
  import { navigating } from '$app/state';
@@ -12,8 +13,8 @@ export function useCatalogNavigation() {
12
13
  pending: () => navigating.to?.url,
13
14
  prepare(spatialElement) {
14
15
  void preloadData(href(spatialElement.href)).catch(() => { });
15
- if (spatialElement.stage)
16
- stage?.prefetchSpatialElement?.(spatialElement.stage);
16
+ if (hasSpatialElementScene(spatialElement))
17
+ stage?.prefetchSpatialElement?.(getSpatialElementScene(spatialElement));
17
18
  }
18
19
  };
19
20
  }
@@ -1,19 +1,23 @@
1
1
  <script lang="ts">
2
2
  import type { Snippet } from 'svelte';
3
3
  import Stage from '../stage/Stage.svelte';
4
- import type { CatalogPage } from '@spatial-elements/core/catalog/catalogPage';
4
+ import type { StageRenderSettings } from '@spatial-elements/core';
5
5
  import { getCssPanelBoxShadow, resolvePanelShadowStrength } from '@spatial-elements/core/stage/panelShadow';
6
6
  import { provideSpatialTheme } from './brandContext.js';
7
- import type { SpatialTheme, SpatialStageConfig } from '@spatial-elements/core/spatial-element/types';
7
+ import type { SpatialTheme } from '@spatial-elements/core/spatial-element/types';
8
8
 
9
9
  interface Props {
10
+ /** Shared appearance and namespace. Use createSpatialTheme for defaults. */
10
11
  theme: SpatialTheme;
11
- stage: SpatialStageConfig;
12
- catalog?: CatalogPage;
12
+ /** Optional GPU resolution budget; defaults to DPR 1 and 2,073,600 pixels. */
13
+ renderSettings?: StageRenderSettings;
14
+ /** Draco decoder directory, including trailing slash. Default: /assets/draco/gltf/; the host must serve the files. */
15
+ dracoDecoderPath?: string;
16
+ /** Layout contents. ContentPage and SpatialElementPage register their own data. */
13
17
  children?: Snippet;
14
18
  }
15
19
 
16
- let { theme, stage, catalog, children }: Props = $props();
20
+ let { theme, renderSettings, dracoDecoderPath, children }: Props = $props();
17
21
 
18
22
  provideSpatialTheme(() => theme);
19
23
 
@@ -77,14 +81,10 @@
77
81
 
78
82
  <div class="brand-stage-shell" style={brandStyle}>
79
83
  <Stage
80
- {catalog}
81
- background={stage.background}
84
+ brandId={theme.id}
85
+ {renderSettings}
86
+ {dracoDecoderPath}
82
87
  pageBackground={theme.background}
83
- hdr={stage.hdr}
84
- glb={stage.glb}
85
- lodPair={stage.lodPair}
86
- model={stage.model}
87
- camera={stage.camera}
88
88
  interactionTheme={theme.interactionTheme}
89
89
  ariaLabel={`${theme.name} spatialElement stage`}
90
90
  >
@@ -1,10 +1,14 @@
1
1
  import type { Snippet } from 'svelte';
2
- import type { CatalogPage } from '@spatial-elements/core/catalog/catalogPage';
3
- import type { SpatialTheme, SpatialStageConfig } from '@spatial-elements/core/spatial-element/types';
2
+ import type { StageRenderSettings } from '@spatial-elements/core';
3
+ import type { SpatialTheme } from '@spatial-elements/core/spatial-element/types';
4
4
  interface Props {
5
+ /** Shared appearance and namespace. Use createSpatialTheme for defaults. */
5
6
  theme: SpatialTheme;
6
- stage: SpatialStageConfig;
7
- catalog?: CatalogPage;
7
+ /** Optional GPU resolution budget; defaults to DPR 1 and 2,073,600 pixels. */
8
+ renderSettings?: StageRenderSettings;
9
+ /** Draco decoder directory, including trailing slash. Default: /assets/draco/gltf/; the host must serve the files. */
10
+ dracoDecoderPath?: string;
11
+ /** Layout contents. ContentPage and SpatialElementPage register their own data. */
8
12
  children?: Snippet;
9
13
  }
10
14
  declare const BrandStageShell: import("svelte").Component<Props, {}, "">;
@@ -19,10 +19,15 @@
19
19
  initialItemKey,
20
20
  onselectionchange
21
21
  }: {
22
+ /** Unique page-local anchor, heading and optional CSS appearance overrides. */
22
23
  section: SpatialElementSectionDefinition;
24
+ /** Project element documents with getSpatialListItems; assets register automatically. */
23
25
  list: SpatialListItem[];
26
+ /** Arc radius (default 0.48 of width) and depth (default 700 CSS-world pixels). */
24
27
  presentation?: CarouselPresentation;
28
+ /** Initially selected itemKey (or element ID); defaults to the first item. */
25
29
  initialItemKey?: string;
30
+ /** Reports selection changes; URL and application state remain host-owned. */
26
31
  onselectionchange?: (selection: { itemKey: string; spatialElementId: string }) => void;
27
32
  } = $props();
28
33
  const sections = getContext<CatalogSections | undefined>(CATALOG_SECTIONS);
@@ -1,10 +1,15 @@
1
1
  import type { CarouselPresentation } from '@spatial-elements/core/catalog/catalogPose';
2
2
  import type { SpatialListItem, SpatialElementSectionDefinition } from '@spatial-elements/core/spatial-element/types';
3
3
  type $$ComponentProps = {
4
+ /** Unique page-local anchor, heading and optional CSS appearance overrides. */
4
5
  section: SpatialElementSectionDefinition;
6
+ /** Project element documents with getSpatialListItems; assets register automatically. */
5
7
  list: SpatialListItem[];
8
+ /** Arc radius (default 0.48 of width) and depth (default 700 CSS-world pixels). */
6
9
  presentation?: CarouselPresentation;
10
+ /** Initially selected itemKey (or element ID); defaults to the first item. */
7
11
  initialItemKey?: string;
12
+ /** Reports selection changes; URL and application state remain host-owned. */
8
13
  onselectionchange?: (selection: {
9
14
  itemKey: string;
10
15
  spatialElementId: string;
@@ -127,9 +127,9 @@
127
127
  ? `left:${(pose.x - 0.19 * Math.cos(pose.yaw)) * 100}%;top:${pose.y * 100}%;width:${pose.size * 100}%;max-width:${pose.size * 480}px;z-index:${Math.round(1300 + pose.depth)}`
128
128
  : undefined}
129
129
  >
130
- {#if spatialElement.stage?.fallbackImage}<img
130
+ {#if spatialElement.fallbackImage}<img
131
131
  draggable="false"
132
- src={spatialElement.stage.fallbackImage}
132
+ src={spatialElement.fallbackImage}
133
133
  alt={`${brand.name} ${spatialElement.title}`}
134
134
  width="320"
135
135
  height="320"
@@ -4,13 +4,23 @@
4
4
  import type { ContentPageData } from '@spatial-elements/core/spatial-element/types';
5
5
  import { useSpatialTheme } from './brandContext.js';
6
6
  import SpatialElementBreadcrumbs from './SpatialElementBreadcrumbs.svelte';
7
+ import { registerSpatialPage } from './spatialPageContext.js';
7
8
  import {
8
9
  SPATIAL_ELEMENT_SECTION_REGISTRY_KEY,
9
10
  SpatialElementSectionRegistry,
10
11
  SECTION_PAGE_KIND
11
12
  } from '@spatial-elements/core/spatial-element/spatialElementSectionRegistry';
12
- let { page, children }: { page: ContentPageData; children?: Snippet } = $props();
13
+ interface Props {
14
+ /** Explicit HDR used to light this page's shared 3D scene; never inferred from an element. */
15
+ hdr: string;
16
+ /** Category metadata. Only title is required; pageTitle defaults to title. */
17
+ page: ContentPageData;
18
+ /** ListSection, CarouselSection and ordinary Section children. */
19
+ children?: Snippet;
20
+ }
21
+ let { page, hdr, children }: Props = $props();
13
22
  const brand = useSpatialTheme();
23
+ registerSpatialPage(() => ({ kind: 'content', hdr }));
14
24
  setContext(SPATIAL_ELEMENT_SECTION_REGISTRY_KEY, new SpatialElementSectionRegistry());
15
25
  setContext(SECTION_PAGE_KIND, 'content');
16
26
  </script>
@@ -1,9 +1,13 @@
1
1
  import type { Snippet } from 'svelte';
2
2
  import type { ContentPageData } from '@spatial-elements/core/spatial-element/types';
3
- type $$ComponentProps = {
3
+ interface Props {
4
+ /** Explicit HDR used to light this page's shared 3D scene; never inferred from an element. */
5
+ hdr: string;
6
+ /** Category metadata. Only title is required; pageTitle defaults to title. */
4
7
  page: ContentPageData;
8
+ /** ListSection, CarouselSection and ordinary Section children. */
5
9
  children?: Snippet;
6
- };
7
- declare const ContentPage: import("svelte").Component<$$ComponentProps, {}, "">;
10
+ }
11
+ declare const ContentPage: import("svelte").Component<Props, {}, "">;
8
12
  type ContentPage = ReturnType<typeof ContentPage>;
9
13
  export default ContentPage;
@@ -1,9 +1,17 @@
1
1
  <script lang="ts">
2
2
  import Section from './Section.svelte';
3
3
  import SpatialElementCard from './SpatialElementCard.svelte';
4
- import type { SpatialListItem, SpatialElementSectionDefinition } from '@spatial-elements/core/spatial-element/types';
5
- let { section, list }: { section: SpatialElementSectionDefinition; list: SpatialListItem[] } =
6
- $props();
4
+ import type {
5
+ SpatialListItem,
6
+ SpatialElementSectionDefinition
7
+ } from '@spatial-elements/core/spatial-element/types';
8
+ interface Props {
9
+ /** Unique page-local anchor, heading and optional CSS appearance overrides. */
10
+ section: SpatialElementSectionDefinition;
11
+ /** Project element documents with getSpatialListItems; assets register automatically. */
12
+ list: SpatialListItem[];
13
+ }
14
+ let { section, list }: Props = $props();
7
15
  </script>
8
16
 
9
17
  <Section {section} presentation="list">
@@ -1,8 +1,10 @@
1
1
  import type { SpatialListItem, SpatialElementSectionDefinition } from '@spatial-elements/core/spatial-element/types';
2
- type $$ComponentProps = {
2
+ interface Props {
3
+ /** Unique page-local anchor, heading and optional CSS appearance overrides. */
3
4
  section: SpatialElementSectionDefinition;
5
+ /** Project element documents with getSpatialListItems; assets register automatically. */
4
6
  list: SpatialListItem[];
5
- };
6
- declare const ListSection: import("svelte").Component<$$ComponentProps, {}, "">;
7
+ }
8
+ declare const ListSection: import("svelte").Component<Props, {}, "">;
7
9
  type ListSection = ReturnType<typeof ListSection>;
8
10
  export default ListSection;
@@ -108,13 +108,13 @@
108
108
  data-spatial-element-id={spatialElement.id}
109
109
  data-catalog-slot="catalog.card"
110
110
  >
111
- {#if spatialElement.stage?.fallbackImage}
111
+ {#if spatialElement.fallbackImage}
112
112
  <img
113
113
  class="catalog-poster"
114
114
  data-catalog-poster
115
115
  loading="lazy"
116
116
  decoding="async"
117
- src={spatialElement.stage.fallbackImage}
117
+ src={spatialElement.fallbackImage}
118
118
  alt={`${brand.name} ${spatialElement.title}`}
119
119
  />
120
120
  {/if}
@@ -1,7 +1,7 @@
1
1
  <script lang="ts">
2
2
  import Panel from '../stage/Panel.svelte';
3
3
  import { useSpatialTheme } from './brandContext.js';
4
- import type { SpatialElementData } from '@spatial-elements/core/spatial-element/types';
4
+ import type { ResolvedSpatialElementData as SpatialElementData } from '@spatial-elements/core/spatial-element/spatialElement';
5
5
 
6
6
  let { spatialElement }: { spatialElement: SpatialElementData } = $props();
7
7
  const theme = useSpatialTheme();
@@ -1,4 +1,4 @@
1
- import type { SpatialElementData } from '@spatial-elements/core/spatial-element/types';
1
+ import type { ResolvedSpatialElementData as SpatialElementData } from '@spatial-elements/core/spatial-element/spatialElement';
2
2
  type $$ComponentProps = {
3
3
  spatialElement: SpatialElementData;
4
4
  };
@@ -21,6 +21,8 @@
21
21
  import { SpatialElementDockController } from '@spatial-elements/core/spatial-element/SpatialElementDockController';
22
22
  import { SPATIAL_ELEMENT_SECTION_REGISTRY_KEY, SpatialElementSectionRegistry } from '@spatial-elements/core/spatial-element/spatialElementSectionRegistry';
23
23
  import type { SpatialElementData, SpatialElementSectionNavigationItem } from '@spatial-elements/core/spatial-element/types';
24
+ import { resolveSpatialElementData } from '@spatial-elements/core/spatial-element/spatialElement';
25
+ import { registerSpatialPage } from './spatialPageContext.js';
24
26
 
25
27
  const SPATIAL_ELEMENT_OVERVIEW_SECTION = {
26
28
  id: 'overview',
@@ -29,8 +31,18 @@
29
31
  // Switch while the next panel enters the upper reading area, before it reaches the sticky tabs.
30
32
  const SPATIAL_ELEMENT_SECTION_ACTIVATION_VIEWPORT_RATIO = 0.25;
31
33
 
32
- let { spatialElement, children }: { spatialElement: SpatialElementData; children?: Snippet } = $props();
34
+ interface Props {
35
+ /** Complete element document from this page's load function. Registers assets with the enclosing shell. */
36
+ spatialElement: SpatialElementData;
37
+ /** Detail sections; Section components automatically populate the tab navigation. */
38
+ children?: Snippet;
39
+ }
40
+ let { spatialElement: element, children }: Props = $props();
33
41
  const brand = useSpatialTheme();
42
+ const spatialElement = $derived(resolveSpatialElementData(element, brand.id));
43
+ // During route teardown Kit can clear the outgoing page's data before unmount.
44
+ // Read raw assets here, so the parent stage never evaluates outgoing DOM-derived content.
45
+ registerSpatialPage(() => element ? { kind: 'detail', element } : { kind: 'content', hdr: '' });
34
46
  const endpoints = getContext<CatalogEndpointRegistry | undefined>(CATALOG_ENDPOINTS);
35
47
  let sections = $state<SpatialElementSectionNavigationItem[]>([]);
36
48
  let activeSectionId = $state<string | undefined>(SPATIAL_ELEMENT_OVERVIEW_SECTION.id);
@@ -137,10 +149,7 @@
137
149
  data-brand-id={spatialElement.brandId}
138
150
  >
139
151
  <SpatialElementBreadcrumbs
140
- items={spatialElement.breadcrumbs.map((item) => ({
141
- ...item,
142
- href: item.href ?? `/${brand.id}/categories/list`
143
- }))}
152
+ items={spatialElement.breadcrumbs}
144
153
  />
145
154
  <SpatialElementStickyHeader {activeSectionId} {spatialElement} sections={navigationSections} />
146
155
 
@@ -164,9 +173,9 @@
164
173
  data-catalog-geometry
165
174
  data-spatial-element-id={spatialElement.id}
166
175
  data-catalog-slot="detail.hero"
167
- fallbackSrc={spatialElement.stage.fallbackImage}
176
+ fallbackSrc={spatialElement.fallbackImage}
168
177
  fallbackAlt={`${brand.name} ${spatialElement.title}`}
169
- aria-hidden={spatialElement.stage.fallbackImage ? undefined : 'true'}
178
+ aria-hidden={spatialElement.fallbackImage ? undefined : 'true'}
170
179
  />
171
180
 
172
181
  <SpatialElementSummaryPanel {spatialElement} />
@@ -1,9 +1,11 @@
1
1
  import type { Snippet } from 'svelte';
2
2
  import type { SpatialElementData } from '@spatial-elements/core/spatial-element/types';
3
- type $$ComponentProps = {
3
+ interface Props {
4
+ /** Complete element document from this page's load function. Registers assets with the enclosing shell. */
4
5
  spatialElement: SpatialElementData;
6
+ /** Detail sections; Section components automatically populate the tab navigation. */
5
7
  children?: Snippet;
6
- };
7
- declare const SpatialElementPage: import("svelte").Component<$$ComponentProps, {}, "">;
8
+ }
9
+ declare const SpatialElementPage: import("svelte").Component<Props, {}, "">;
8
10
  type SpatialElementPage = ReturnType<typeof SpatialElementPage>;
9
11
  export default SpatialElementPage;
@@ -1,10 +1,11 @@
1
1
  <script lang="ts">
2
+ import type { ResolvedSpatialElementData as SpatialElementData } from '@spatial-elements/core/spatial-element/spatialElement';
2
3
  import { catalogActionSemantic } from '@spatial-elements/core/catalog/catalogAction';
3
4
  import { ShoppingCart } from 'lucide-svelte';
4
5
  import SpatialElementTabList from './SpatialElementTabList.svelte';
5
6
  import { createCatalogEndpointAction } from '../catalog/catalogEndpointAction.js';
6
7
  const catalogEndpoint = createCatalogEndpointAction();
7
- import type { SpatialElementData, SpatialElementSectionNavigationItem } from '@spatial-elements/core/spatial-element/types';
8
+ import type { SpatialElementSectionNavigationItem } from '@spatial-elements/core/spatial-element/types';
8
9
 
9
10
  let {
10
11
  activeSectionId,
@@ -77,39 +78,41 @@
77
78
  </p>
78
79
  </div>
79
80
 
80
- {#if spatialElement.action.href}
81
- <a
82
- class="sticky-header-action"
83
- use:catalogEndpoint={{
84
- brandId: spatialElement.brandId,
85
- spatialElementId: spatialElement.id,
86
- slot: 'detail.dock',
87
- role: 'primary-action'
88
- }}
89
- data-catalog-rich-shared="primary-action"
90
- data-catalog-semantic={catalogActionSemantic(spatialElement.action)}
91
- href={spatialElement.action.href}
92
- rel="external"
93
- aria-label={spatialElement.action.ariaLabel}
94
- >
95
- <ShoppingCart size={29} strokeWidth={2} aria-hidden="true" />
96
- </a>
97
- {:else}
98
- <button
99
- use:catalogEndpoint={{
100
- brandId: spatialElement.brandId,
101
- spatialElementId: spatialElement.id,
102
- slot: 'detail.dock',
103
- role: 'primary-action'
104
- }}
105
- data-catalog-rich-shared="primary-action"
106
- data-catalog-semantic={catalogActionSemantic(spatialElement.action)}
107
- class="sticky-header-action"
108
- type="button"
109
- aria-label={spatialElement.action.ariaLabel}
110
- >
111
- <ShoppingCart size={29} strokeWidth={2} aria-hidden="true" />
112
- </button>
81
+ {#if spatialElement.action}
82
+ {#if spatialElement.action.href}
83
+ <a
84
+ class="sticky-header-action"
85
+ use:catalogEndpoint={{
86
+ brandId: spatialElement.brandId,
87
+ spatialElementId: spatialElement.id,
88
+ slot: 'detail.dock',
89
+ role: 'primary-action'
90
+ }}
91
+ data-catalog-rich-shared="primary-action"
92
+ data-catalog-semantic={catalogActionSemantic(spatialElement.action)}
93
+ href={spatialElement.action.href}
94
+ rel="external"
95
+ aria-label={spatialElement.action.ariaLabel}
96
+ >
97
+ <ShoppingCart size={29} strokeWidth={2} aria-hidden="true" />
98
+ </a>
99
+ {:else}
100
+ <button
101
+ use:catalogEndpoint={{
102
+ brandId: spatialElement.brandId,
103
+ spatialElementId: spatialElement.id,
104
+ slot: 'detail.dock',
105
+ role: 'primary-action'
106
+ }}
107
+ data-catalog-rich-shared="primary-action"
108
+ data-catalog-semantic={catalogActionSemantic(spatialElement.action)}
109
+ class="sticky-header-action"
110
+ type="button"
111
+ aria-label={spatialElement.action.ariaLabel}
112
+ >
113
+ <ShoppingCart size={29} strokeWidth={2} aria-hidden="true" />
114
+ </button>
115
+ {/if}
113
116
  {/if}
114
117
  </div>
115
118
 
@@ -185,8 +188,9 @@
185
188
  height: 52px;
186
189
  padding: 0;
187
190
  border: 0;
188
- border-radius: var(--spatial-element-tabs-dock-top-radius) var(--spatial-element-tabs-dock-top-radius)
189
- var(--spatial-element-tabs-dock-bottom-radius) var(--spatial-element-tabs-dock-bottom-radius);
191
+ border-radius: var(--spatial-element-tabs-dock-top-radius)
192
+ var(--spatial-element-tabs-dock-top-radius) var(--spatial-element-tabs-dock-bottom-radius)
193
+ var(--spatial-element-tabs-dock-bottom-radius);
190
194
  overflow: clip;
191
195
  opacity: 0;
192
196
  visibility: hidden;
@@ -209,7 +213,8 @@
209
213
  .spatial-element-sticky-header::before,
210
214
  .spatial-element-sticky-tabs::before {
211
215
  background: rgb(
212
- var(--spatial-element-docked-panel-tint-rgb) / var(--spatial-element-docked-panel-tint-opacity)
216
+ var(--spatial-element-docked-panel-tint-rgb) /
217
+ var(--spatial-element-docked-panel-tint-opacity)
213
218
  );
214
219
  box-shadow: inset 0 0 0 1px
215
220
  rgb(0 0 0 / calc(var(--spatial-element-docked-panel-shadow-strength) * 0.18));
@@ -1,4 +1,5 @@
1
- import type { SpatialElementData, SpatialElementSectionNavigationItem } from '@spatial-elements/core/spatial-element/types';
1
+ import type { ResolvedSpatialElementData as SpatialElementData } from '@spatial-elements/core/spatial-element/spatialElement';
2
+ import type { SpatialElementSectionNavigationItem } from '@spatial-elements/core/spatial-element/types';
2
3
  type $$ComponentProps = {
3
4
  activeSectionId?: string;
4
5
  spatialElement: SpatialElementData;
@@ -3,7 +3,7 @@
3
3
  import { ShoppingCart } from 'lucide-svelte';
4
4
  import Panel from '../stage/Panel.svelte';
5
5
  import { useSpatialTheme } from './brandContext.js';
6
- import type { SpatialElementData } from '@spatial-elements/core/spatial-element/types';
6
+ import type { ResolvedSpatialElementData as SpatialElementData } from '@spatial-elements/core/spatial-element/spatialElement';
7
7
  import { createCatalogEndpointAction } from '../catalog/catalogEndpointAction.js';
8
8
 
9
9
  let { spatialElement }: { spatialElement: SpatialElementData } = $props();
@@ -82,55 +82,57 @@
82
82
  {/each}
83
83
  </ul>
84
84
 
85
- {#if spatialElement.action.href}
86
- <a
87
- use:catalogEndpoint={{
88
- brandId: theme.id,
89
- spatialElementId: spatialElement.id,
90
- slot: 'detail.summary',
91
- role: 'primary-action'
92
- }}
93
- data-catalog-rich-shared="primary-action"
94
- data-catalog-semantic={catalogActionSemantic(spatialElement.action)}
95
- class="spatial-element-action spatial-element-action-expanded"
96
- href={spatialElement.action.href}
97
- rel="external"
98
- aria-label={spatialElement.action.ariaLabel}
99
- >
100
- <span class="spatial-element-action-surface" data-catalog-secondary>
101
- <ShoppingCart
102
- class="spatial-element-action-icon"
103
- size={27}
104
- strokeWidth={2}
105
- aria-hidden="true"
106
- />
107
- <span class="spatial-element-action-label">{spatialElement.action.label}</span>
108
- </span>
109
- </a>
110
- {:else}
111
- <button
112
- use:catalogEndpoint={{
113
- brandId: theme.id,
114
- spatialElementId: spatialElement.id,
115
- slot: 'detail.summary',
116
- role: 'primary-action'
117
- }}
118
- data-catalog-rich-shared="primary-action"
119
- data-catalog-semantic={catalogActionSemantic(spatialElement.action)}
120
- class="spatial-element-action spatial-element-action-expanded"
121
- type="button"
122
- aria-label={spatialElement.action.ariaLabel}
123
- >
124
- <span class="spatial-element-action-surface" data-catalog-secondary>
125
- <ShoppingCart
126
- class="spatial-element-action-icon"
127
- size={27}
128
- strokeWidth={2}
129
- aria-hidden="true"
130
- />
131
- <span class="spatial-element-action-label">{spatialElement.action.label}</span>
132
- </span>
133
- </button>
85
+ {#if spatialElement.action}
86
+ {#if spatialElement.action.href}
87
+ <a
88
+ use:catalogEndpoint={{
89
+ brandId: theme.id,
90
+ spatialElementId: spatialElement.id,
91
+ slot: 'detail.summary',
92
+ role: 'primary-action'
93
+ }}
94
+ data-catalog-rich-shared="primary-action"
95
+ data-catalog-semantic={catalogActionSemantic(spatialElement.action)}
96
+ class="spatial-element-action spatial-element-action-expanded"
97
+ href={spatialElement.action.href}
98
+ rel="external"
99
+ aria-label={spatialElement.action.ariaLabel}
100
+ >
101
+ <span class="spatial-element-action-surface" data-catalog-secondary>
102
+ <ShoppingCart
103
+ class="spatial-element-action-icon"
104
+ size={27}
105
+ strokeWidth={2}
106
+ aria-hidden="true"
107
+ />
108
+ <span class="spatial-element-action-label">{spatialElement.action.label}</span>
109
+ </span>
110
+ </a>
111
+ {:else}
112
+ <button
113
+ use:catalogEndpoint={{
114
+ brandId: theme.id,
115
+ spatialElementId: spatialElement.id,
116
+ slot: 'detail.summary',
117
+ role: 'primary-action'
118
+ }}
119
+ data-catalog-rich-shared="primary-action"
120
+ data-catalog-semantic={catalogActionSemantic(spatialElement.action)}
121
+ class="spatial-element-action spatial-element-action-expanded"
122
+ type="button"
123
+ aria-label={spatialElement.action.ariaLabel}
124
+ >
125
+ <span class="spatial-element-action-surface" data-catalog-secondary>
126
+ <ShoppingCart
127
+ class="spatial-element-action-icon"
128
+ size={27}
129
+ strokeWidth={2}
130
+ aria-hidden="true"
131
+ />
132
+ <span class="spatial-element-action-label">{spatialElement.action.label}</span>
133
+ </span>
134
+ </button>
135
+ {/if}
134
136
  {/if}
135
137
  </div>
136
138
  </Panel>
@@ -1,4 +1,4 @@
1
- import type { SpatialElementData } from '@spatial-elements/core/spatial-element/types';
1
+ import type { ResolvedSpatialElementData as SpatialElementData } from '@spatial-elements/core/spatial-element/spatialElement';
2
2
  type $$ComponentProps = {
3
3
  spatialElement: SpatialElementData;
4
4
  };
@@ -6,16 +6,19 @@
6
6
  import type { SpatialListItem, ContentPageData } from '@spatial-elements/core/spatial-element/types';
7
7
  let {
8
8
  spatialElements,
9
+ hdr,
9
10
  sectionLink,
10
11
  ...page
11
12
  }: ContentPageData & {
13
+ /** Explicit environment for the collection. */
14
+ hdr: string;
12
15
  spatialElements: SpatialListItem[];
13
16
  sectionLink?: { href: string; label: string };
14
17
  } = $props();
15
18
  const { href } = useCatalogNavigation();
16
19
  </script>
17
20
 
18
- <ContentPage {page}>
21
+ <ContentPage {page} {hdr}>
19
22
  <ListSection section={{ id: 'elements', title: 'Elements' }} list={spatialElements} />
20
23
  {#if sectionLink}<Section section={{ id: 'more', title: 'More information' }}
21
24
  ><a href={href(sectionLink.href)}>{sectionLink.label}</a></Section
@@ -1,5 +1,7 @@
1
1
  import type { SpatialListItem, ContentPageData } from '@spatial-elements/core/spatial-element/types';
2
2
  type $$ComponentProps = ContentPageData & {
3
+ /** Explicit environment for the collection. */
4
+ hdr: string;
3
5
  spatialElements: SpatialListItem[];
4
6
  sectionLink?: {
5
7
  href: string;
@@ -3,9 +3,12 @@ export { default as SpatialElementPage } from './SpatialElementPage.svelte';
3
3
  export { default as SpatialListPage } from './SpatialListPage.svelte';
4
4
  export { default as Section } from './Section.svelte';
5
5
  export { findSpatialElement, getSpatialListItems } from '@spatial-elements/core/spatial-element/spatialElement';
6
- export type { SpatialElementAction, SpatialTheme, SpatialElementBreadcrumb, SpatialElementData, SpatialDockedPanelTheme, SpatialElementFeature, SpatialElementMediaItem, SpatialMinimapTheme, SpatialListItem, SpatialElementSectionDefinition, SpatialElementSectionNavigationItem, SpatialElementSectionStyle, SpatialSectionTheme, SpatialStageConfig } from '@spatial-elements/core/spatial-element/types';
6
+ export type { SpatialElementAction, SpatialTheme, SpatialElementBreadcrumb, SpatialElementData, SpatialDockedPanelTheme, SpatialElementFeature, SpatialElementMediaItem, SpatialMinimapTheme, SpatialListItem, SpatialElementSectionDefinition, SpatialElementSectionNavigationItem, SpatialElementSectionStyle, SpatialSectionTheme } from '@spatial-elements/core/spatial-element/types';
7
7
  export { default as ContentPage } from './ContentPage.svelte';
8
8
  export { default as CarouselSection } from './CarouselSection.svelte';
9
9
  export { default as ListSection } from './ListSection.svelte';
10
10
  export type { ContentPageData } from '@spatial-elements/core/spatial-element/types';
11
11
  export type { CarouselPresentation } from '@spatial-elements/core/catalog/catalogPose';
12
+ export { createSpatialTheme, type SpatialThemeOptions } from '@spatial-elements/core/spatial-element/spatialTheme';
13
+ export type { StageRenderSettings, BackgroundSettings, StageModelSettings, StageCameraSettings } from '@spatial-elements/core/stage/stageTypes';
14
+ export { geometryFromLodPair, type SpatialElementGeometry } from '@spatial-elements/core/spatial-element/spatialElementGeometry';
@@ -6,3 +6,5 @@ export { findSpatialElement, getSpatialListItems } from '@spatial-elements/core/
6
6
  export { default as ContentPage } from './ContentPage.svelte';
7
7
  export { default as CarouselSection } from './CarouselSection.svelte';
8
8
  export { default as ListSection } from './ListSection.svelte';
9
+ export { createSpatialTheme } from '@spatial-elements/core/spatial-element/spatialTheme';
10
+ export { geometryFromLodPair } from '@spatial-elements/core/spatial-element/spatialElementGeometry';
@@ -0,0 +1,4 @@
1
+ import type { SpatialPage } from '@spatial-elements/core/catalog/SpatialPageRegistry';
2
+ export declare const SPATIAL_PAGE: unique symbol;
3
+ /** Register at mount: SSR renders the semantic page directly, GPU ownership starts in the browser. */
4
+ export declare function registerSpatialPage(read: () => SpatialPage): void;
@@ -0,0 +1,9 @@
1
+ import { getContext, onMount } from 'svelte';
2
+ export const SPATIAL_PAGE = Symbol('spatial-page');
3
+ /** Register at mount: SSR renders the semantic page directly, GPU ownership starts in the browser. */
4
+ export function registerSpatialPage(read) {
5
+ const pages = getContext(SPATIAL_PAGE);
6
+ if (!pages)
7
+ throw new Error('Spatial pages must be rendered inside BrandStageShell or Stage.');
8
+ onMount(() => pages.register(read));
9
+ }
@@ -9,21 +9,41 @@
9
9
  StageInteractionTheme,
10
10
  StageModelSettings,
11
11
  StagePanelTarget,
12
+ StageRenderSettings,
12
13
  StageVisualTestView,
13
14
  StageViewportTarget,
14
15
  StageZoomFocusState
15
16
  } from '@spatial-elements/core/stage/StageExperience';
16
- import { isStageVisualTestMode, type StageVisualTestController } from '@spatial-elements/core/stage/stageVisualTest';
17
+ import {
18
+ isStageVisualTestMode,
19
+ type StageVisualTestController
20
+ } from '@spatial-elements/core/stage/stageVisualTest';
21
+ import { resolveStageRenderSettings } from '@spatial-elements/core/stage/renderSettings';
17
22
  import { VirtualScrollController } from '@spatial-elements/core/stage/VirtualScrollController';
18
23
  import ScrollNavigationBridge from '../catalog/ScrollNavigationBridge.svelte';
19
24
  import { CatalogTransition } from '@spatial-elements/core/catalog/CatalogTransition';
20
- import { CATALOG_ENDPOINTS, CatalogEndpointRegistry } from '@spatial-elements/core/catalog/CatalogEndpointRegistry';
25
+ import {
26
+ CATALOG_ENDPOINTS,
27
+ CatalogEndpointRegistry
28
+ } from '@spatial-elements/core/catalog/CatalogEndpointRegistry';
21
29
  import '../catalog/catalogTransition.css';
22
30
  import { createStageSpatialElementAssetManifest } from '@spatial-elements/core/catalog/spatialElementAssets';
23
31
  import { CATALOG_ITEMS, CatalogItems } from '@spatial-elements/core/catalog/catalogItems';
24
- import { CATALOG_SECTIONS, CatalogSections } from '@spatial-elements/core/catalog/CatalogSections';
32
+ import {
33
+ CATALOG_SECTIONS,
34
+ CatalogSections
35
+ } from '@spatial-elements/core/catalog/CatalogSections';
25
36
  import type { SpatialListItem } from '@spatial-elements/core/spatial-element/types';
26
37
  import type { CatalogPage } from '@spatial-elements/core/catalog/catalogPage';
38
+ import {
39
+ SpatialPageRegistry,
40
+ type SpatialPage
41
+ } from '@spatial-elements/core/catalog/SpatialPageRegistry';
42
+ import {
43
+ getSpatialElementScene,
44
+ hasSpatialElementScene
45
+ } from '@spatial-elements/core/spatial-element/spatialElementScene';
46
+ import { SPATIAL_PAGE } from '../spatial-element/spatialPageContext.js';
27
47
  import type { OnNavigate } from '@sveltejs/kit';
28
48
  import {
29
49
  STAGE_CONTEXT_KEY,
@@ -33,6 +53,9 @@
33
53
  } from '@spatial-elements/core/stage/panelContext';
34
54
 
35
55
  interface Props {
56
+ /** Namespace for automatic ContentPage/SpatialElementPage registration. Supplied by BrandStageShell. */
57
+ brandId?: string;
58
+ renderSettings?: StageRenderSettings;
36
59
  dracoDecoderPath?: string;
37
60
  ariaLabel?: string;
38
61
  background?: BackgroundSettings;
@@ -43,31 +66,64 @@
43
66
  model?: StageModelSettings;
44
67
  camera?: StageCameraSettings;
45
68
  interactionTheme?: Partial<StageInteractionTheme>;
69
+ /** @deprecated Low-level manual adapter. BrandStageShell manages catalog state from its pages. */
46
70
  catalog?: CatalogPage;
47
71
  children?: Snippet;
48
72
  }
49
73
 
50
74
  let {
75
+ brandId,
51
76
  ariaLabel = 'WebGPU 3D stage',
77
+ renderSettings,
52
78
  dracoDecoderPath,
53
79
  pageBackground = '#ffffff',
54
- background,
55
- hdr,
56
- glb,
57
- lodPair,
58
- model,
59
- camera,
80
+ background: standaloneBackground,
81
+ hdr: standaloneHdr,
82
+ glb: standaloneGlb,
83
+ lodPair: standaloneLodPair,
84
+ model: standaloneModel,
85
+ camera: standaloneCamera,
60
86
  interactionTheme,
61
- catalog,
87
+ catalog: explicitCatalog,
62
88
  children
63
89
  }: Props = $props();
64
90
 
91
+ let readPage = $state.raw<(() => SpatialPage) | undefined>();
92
+ setContext(
93
+ SPATIAL_PAGE,
94
+ new SpatialPageRegistry((read) => {
95
+ readPage = read;
96
+ })
97
+ );
98
+ const activePage = $derived(readPage?.());
99
+ const activeElement = $derived(activePage?.kind === 'detail' ? activePage.element : undefined);
100
+ const activeScene = $derived(activeElement ? getSpatialElementScene(activeElement) : undefined);
101
+ const catalog = $derived<CatalogPage | undefined>(
102
+ brandId
103
+ ? {
104
+ brandId,
105
+ view: activeElement ? 'detail' : 'content',
106
+ spatialElementId: activeElement?.id,
107
+ spatialElementStage: activeScene,
108
+ spatialElements: []
109
+ }
110
+ : explicitCatalog
111
+ );
65
112
  let displayedSpatialElements = $state<SpatialListItem[]>([]);
66
113
  setContext(CATALOG_ITEMS, new CatalogItems((items) => (displayedSpatialElements = items)));
67
114
  setContext(CATALOG_SECTIONS, new CatalogSections());
68
115
  const catalogSpatialElements = $derived(
69
116
  displayedSpatialElements.length ? displayedSpatialElements : (catalog?.spatialElements ?? [])
70
117
  );
118
+ const background = $derived(brandId ? activeElement?.background : standaloneBackground);
119
+ const hdr = $derived(brandId
120
+ ? (activePage?.kind === 'content' ? activePage.hdr : activeScene?.hdr ?? '')
121
+ : standaloneHdr);
122
+ const glb = $derived(brandId ? (activeScene?.glb ?? '') : standaloneGlb);
123
+ const lodPair = $derived(brandId ? activeScene?.lodPair : standaloneLodPair);
124
+ const model = $derived(brandId ? activeElement?.model : standaloneModel);
125
+ const camera = $derived(brandId ? activeElement?.camera : standaloneCamera);
126
+
71
127
  const registeredPanels: StagePanelRegistration[] = [];
72
128
  const catalogEndpoints = new CatalogEndpointRegistry();
73
129
  setContext(CATALOG_ENDPOINTS, catalogEndpoints);
@@ -102,6 +158,7 @@
102
158
  let retainedPageSignature: string | undefined;
103
159
  const pageSignature = () =>
104
160
  JSON.stringify([
161
+ renderSettings,
105
162
  pageBackground,
106
163
  background,
107
164
  hdr,
@@ -190,6 +247,7 @@
190
247
  const panels = getPanelTargets();
191
248
  const viewport = getViewportTarget();
192
249
  const instance = new StageExperience(stage, {
250
+ renderSettings,
193
251
  dracoDecoderPath,
194
252
  catalog: Boolean(catalog),
195
253
  heroIsPresented: () =>
@@ -292,14 +350,22 @@
292
350
  function registerSpatialElements() {
293
351
  if (!catalog || !experience) return;
294
352
  for (const spatialElement of catalogSpatialElements) {
295
- if (spatialElement.stage)
353
+ if (hasSpatialElementScene(spatialElement))
296
354
  experience.spatialElements.setManifest(
297
- createStageSpatialElementAssetManifest(catalog.brandId, spatialElement.id, spatialElement.stage)
355
+ createStageSpatialElementAssetManifest(
356
+ catalog.brandId,
357
+ spatialElement.id,
358
+ getSpatialElementScene(spatialElement)
359
+ )
298
360
  );
299
361
  }
300
362
  if (catalog.spatialElementId && catalog.spatialElementStage) {
301
363
  experience.spatialElements.setManifest(
302
- createStageSpatialElementAssetManifest(catalog.brandId, catalog.spatialElementId, catalog.spatialElementStage)
364
+ createStageSpatialElementAssetManifest(
365
+ catalog.brandId,
366
+ catalog.spatialElementId,
367
+ catalog.spatialElementStage
368
+ )
303
369
  );
304
370
  }
305
371
  }
@@ -362,6 +428,7 @@
362
428
  ? experience.setCatalogSpatialElements(catalog.brandId, catalogSpatialElements)
363
429
  : undefined;
364
430
  await experience.updatePage({
431
+ renderSettings,
365
432
  catalog: Boolean(catalog),
366
433
  heroIsPresented: () =>
367
434
  !catalog?.spatialElementId ||
@@ -499,6 +566,8 @@
499
566
  },
500
567
  getRenderTargetStats: () =>
501
568
  experience?.getVisualTestRenderTargetStats() ?? {
569
+ pixelRatio: 0,
570
+ renderSettings: resolveStageRenderSettings(renderSettings),
502
571
  liveTargets: 0,
503
572
  targets: [],
504
573
  canvases: [],
@@ -1,9 +1,12 @@
1
1
  import type { SpatialElementLodPair } from '@spatial-elements/core/catalog/spatialElementLodPair';
2
2
  import type { Snippet } from 'svelte';
3
- import type { BackgroundSettings, StageCameraSettings, StageInteractionTheme, StageModelSettings } from '@spatial-elements/core/stage/StageExperience';
3
+ import type { BackgroundSettings, StageCameraSettings, StageInteractionTheme, StageModelSettings, StageRenderSettings } from '@spatial-elements/core/stage/StageExperience';
4
4
  import '../catalog/catalogTransition.css';
5
5
  import type { CatalogPage } from '@spatial-elements/core/catalog/catalogPage';
6
6
  interface Props {
7
+ /** Namespace for automatic ContentPage/SpatialElementPage registration. Supplied by BrandStageShell. */
8
+ brandId?: string;
9
+ renderSettings?: StageRenderSettings;
7
10
  dracoDecoderPath?: string;
8
11
  ariaLabel?: string;
9
12
  background?: BackgroundSettings;
@@ -14,6 +17,7 @@ interface Props {
14
17
  model?: StageModelSettings;
15
18
  camera?: StageCameraSettings;
16
19
  interactionTheme?: Partial<StageInteractionTheme>;
20
+ /** @deprecated Low-level manual adapter. BrandStageShell manages catalog state from its pages. */
17
21
  catalog?: CatalogPage;
18
22
  children?: Snippet;
19
23
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spatial-elements/sveltekit",
3
- "version": "0.1.0-beta.2",
3
+ "version": "1.0.0-beta.3",
4
4
  "description": "SvelteKit components and navigation for Spatial Elements.",
5
5
  "license": "MPL-2.0",
6
6
  "type": "module",
@@ -39,17 +39,17 @@
39
39
  "prepack": "npm run build"
40
40
  },
41
41
  "dependencies": {
42
- "@spatial-elements/core": "0.1.0-beta.2",
42
+ "@spatial-elements/core": "1.0.0-beta.3",
43
43
  "lucide-svelte": "^1.0.1"
44
44
  },
45
45
  "peerDependencies": {
46
46
  "svelte": "^5.56.4",
47
47
  "@sveltejs/kit": "^2.70.3",
48
- "three": "^0.185.1"
48
+ "three": "^0.186.1"
49
49
  },
50
50
  "publishConfig": {
51
51
  "access": "public",
52
- "tag": "beta",
52
+ "tag": "latest",
53
53
  "registry": "https://registry.npmjs.org/"
54
54
  }
55
55
  }