@contentful/experiences-svelte 0.10.0 → 0.11.0

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.
@@ -39,14 +39,6 @@ const payload = (title) => ({
39
39
  },
40
40
  ],
41
41
  sys: { type: 'Experience' },
42
- viewports: [
43
- {
44
- displayName: 'Default',
45
- id: 'default',
46
- previewSize: '1024px',
47
- query: '*',
48
- },
49
- ],
50
42
  });
51
43
  const previewSessionOptions = {
52
44
  environmentId: 'environment-id',
@@ -1,13 +1,7 @@
1
1
  import { render } from '@testing-library/svelte';
2
2
  import { describe, expect, it } from 'vitest';
3
3
  import LivePreviewPlanProbe from './test-fixtures/LivePreviewPlanProbe.svelte';
4
- const payload = {
5
- nodes: [],
6
- sys: { type: 'Experience' },
7
- viewports: [{ displayName: 'Default', id: 'default', previewSize: '1024px', query: '*' }],
8
- };
9
4
  const initialPlan = {
10
- fallbackViewportIndex: 0,
11
5
  nodes: [
12
6
  {
13
7
  nodeId: 'initial',
@@ -16,7 +10,6 @@ const initialPlan = {
16
10
  slots: {},
17
11
  },
18
12
  ],
19
- viewports: payload.viewports,
20
13
  metadata: {},
21
14
  debug: false,
22
15
  diagnostics: [],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/experiences-svelte",
3
- "version": "0.10.0",
3
+ "version": "0.11.0",
4
4
  "description": "Svelte adapter for Contentful Experiences — Server and Client renderers over a PortableRenderPlan",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -35,10 +35,10 @@
35
35
  "check": "svelte-check --tsconfig ./tsconfig.json"
36
36
  },
37
37
  "dependencies": {
38
- "@contentful/experiences-client": "0.8.0",
39
- "@contentful/experiences-sdk-core": "0.11.0",
40
- "@contentful/experiences-design": "0.11.0",
41
- "@contentful/experiences-live-preview": "0.5.0"
38
+ "@contentful/experiences-client": "0.9.0",
39
+ "@contentful/experiences-sdk-core": "0.12.0",
40
+ "@contentful/experiences-design": "0.12.0",
41
+ "@contentful/experiences-live-preview": "0.6.0"
42
42
  },
43
43
  "peerDependencies": {
44
44
  "svelte": "^5.55.7"
@@ -1,23 +0,0 @@
1
- import type { ViewportDef } from '@contentful/experiences-sdk-core';
2
- /**
3
- * @deprecated Viewports are being removed from the Experiences APIs, with no
4
- * direct replacement — use CSS media queries or `window.matchMedia` instead.
5
- * Will not be removed before 2026-10-06.
6
- */
7
- export interface UseActiveViewportResult {
8
- readonly activeViewportIndex: number;
9
- }
10
- /**
11
- * Returns a reactive object whose `activeViewportIndex` updates as the
12
- * window's matched media queries change. Mounts listeners via `$effect`
13
- * and tears them down automatically when the calling component unmounts.
14
- *
15
- * Must be called at the top level of a `.svelte` component or a function
16
- * that's itself called during component setup (because of `$effect`).
17
- *
18
- * @deprecated Viewports are being removed from the Experiences APIs, with no
19
- * direct replacement — use CSS media queries or `window.matchMedia` instead.
20
- * Will not be removed before 2026-10-06.
21
- */
22
- export declare function useActiveViewport(viewports: ViewportDef[], initialViewportId?: string): UseActiveViewportResult;
23
- //# sourceMappingURL=use-active-viewport.svelte.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-active-viewport.svelte.d.ts","sourceRoot":"","sources":["../src/use-active-viewport.svelte.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAGpE;;;;GAIG;AACH,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,mBAAmB,EAAE,MAAM,CAAC;CACtC;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,WAAW,EAAE,EACxB,iBAAiB,CAAC,EAAE,MAAM,GACzB,uBAAuB,CAiDzB"}
@@ -1,66 +0,0 @@
1
- /*
2
- * Reactive viewport-matcher rune.
3
- *
4
- * "Active viewport" = the last-matching media query in the ordered viewports
5
- * list. With desktop-first ordering (`*`, `<992px`, `<576px`), the narrowest
6
- * matching query wins. With mobile-first ordering, the widest wins. Either
7
- * way: the last `findLastIndex` of `mediaQueryMatches[i] === true`.
8
- *
9
- * Pass `initialViewportId` (typically derived from User-Agent on the server)
10
- * to seed the first render so SSR + client agree on viewport before
11
- * window.matchMedia takes over.
12
- */
13
- import { createMediaQueryMatchers, getViewportIndex } from '@contentful/experiences-design';
14
- /**
15
- * Returns a reactive object whose `activeViewportIndex` updates as the
16
- * window's matched media queries change. Mounts listeners via `$effect`
17
- * and tears them down automatically when the calling component unmounts.
18
- *
19
- * Must be called at the top level of a `.svelte` component or a function
20
- * that's itself called during component setup (because of `$effect`).
21
- *
22
- * @deprecated Viewports are being removed from the Experiences APIs, with no
23
- * direct replacement — use CSS media queries or `window.matchMedia` instead.
24
- * Will not be removed before 2026-10-06.
25
- */
26
- export function useActiveViewport(viewports, initialViewportId) {
27
- const initialIndex = getViewportIndex(viewports, initialViewportId);
28
- const [, initialMatches] = createMediaQueryMatchers(viewports);
29
- let matches = $state(initialMatches);
30
- let activeViewportIndex = $state(initialIndex);
31
- $effect(() => {
32
- const [matchers] = createMediaQueryMatchers(viewports);
33
- // Sync once on mount in case the initial seed was server-side.
34
- matches = matchers.reduce((acc, { index, signal }) => {
35
- acc[index] = signal.matches;
36
- return acc;
37
- }, [...initialMatches]);
38
- const listeners = matchers.map(({ index, signal }) => {
39
- const onChange = () => {
40
- const next = [...matches];
41
- next[index] = signal.matches;
42
- matches = next;
43
- };
44
- signal.addEventListener('change', onChange);
45
- return onChange;
46
- });
47
- return () => {
48
- listeners.forEach((listener, i) => {
49
- const matcher = matchers[i];
50
- if (matcher)
51
- matcher.signal.removeEventListener('change', listener);
52
- });
53
- };
54
- });
55
- $effect(() => {
56
- const currentIndex = matches.findLastIndex((isMatch) => isMatch);
57
- if (currentIndex !== -1 && currentIndex !== activeViewportIndex) {
58
- activeViewportIndex = currentIndex;
59
- }
60
- });
61
- return {
62
- get activeViewportIndex() {
63
- return activeViewportIndex;
64
- },
65
- };
66
- }