@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.
- package/CHANGELOG.md +141 -0
- package/README.md +7 -10
- package/dist/ClientExperienceRenderer.svelte +4 -36
- package/dist/ClientExperienceRenderer.svelte.d.ts.map +1 -1
- package/dist/DebugExperience.svelte +3 -3
- package/dist/DebugExperience.test.js +0 -14
- package/dist/NodeRenderer.svelte +2 -17
- package/dist/NodeRenderer.svelte.d.ts.map +1 -1
- package/dist/NodeRenderer.test.js +2 -6
- package/dist/NodesRenderer.svelte +1 -2
- package/dist/ServerExperienceRenderer.svelte +2 -25
- package/dist/ServerExperienceRenderer.svelte.d.ts.map +1 -1
- package/dist/component-props.d.ts +0 -1
- package/dist/component-props.d.ts.map +1 -1
- package/dist/context.d.ts +1 -1
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +2 -3
- package/dist/debug-panel-coverage.ssr.test.js +0 -2
- package/dist/debug-panel-coverage.test.js +1 -9
- package/dist/get-design-values.d.ts +3 -3
- package/dist/get-design-values.js +3 -3
- package/dist/index.d.ts +2 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -3
- package/dist/nodes-renderer.ssr.test.js +0 -6
- package/dist/server-renderer.test.js +18 -145
- package/dist/types.d.ts +2 -2
- package/dist/use-experience-plan.test.js +0 -10
- package/dist/use-live-preview-experience.test.js +0 -8
- package/dist/use-live-preview.test.js +0 -7
- package/package.json +5 -5
- package/dist/use-active-viewport.svelte.d.ts +0 -23
- package/dist/use-active-viewport.svelte.d.ts.map +0 -1
- package/dist/use-active-viewport.svelte.js +0 -66
|
@@ -25,7 +25,6 @@ import ButtonFixture from './test-fixtures/ButtonFixture.svelte';
|
|
|
25
25
|
async function flushMicrotasks() {
|
|
26
26
|
await new Promise((resolve) => queueMicrotask(resolve));
|
|
27
27
|
}
|
|
28
|
-
const VIEWPORTS = [{ id: 'desktop', query: '*', displayName: 'Desktop', previewSize: '100%' }];
|
|
29
28
|
function componentNode(typeId, rest = {}) {
|
|
30
29
|
return {
|
|
31
30
|
component: {
|
|
@@ -42,7 +41,7 @@ describe('debug panel — end-to-end coverage of every non-happy-path failure mo
|
|
|
42
41
|
it('malformed-payload: a non-array nodes field', async () => {
|
|
43
42
|
const warn = vi.spyOn(console, 'warn').mockImplementation(() => { });
|
|
44
43
|
try {
|
|
45
|
-
const plan = await resolveExperience({
|
|
44
|
+
const plan = await resolveExperience({ nodes: 'not-an-array' }, { components: {} });
|
|
46
45
|
const { container } = render(ServerExperienceRenderer, {
|
|
47
46
|
props: { experience: plan, config: { components: {} }, debug: true },
|
|
48
47
|
});
|
|
@@ -57,7 +56,6 @@ describe('debug panel — end-to-end coverage of every non-happy-path failure mo
|
|
|
57
56
|
const warn = vi.spyOn(console, 'warn').mockImplementation(() => { });
|
|
58
57
|
try {
|
|
59
58
|
const payload = {
|
|
60
|
-
viewports: VIEWPORTS,
|
|
61
59
|
nodes: [
|
|
62
60
|
componentNode('contentful-container', {
|
|
63
61
|
id: 'page',
|
|
@@ -81,7 +79,6 @@ describe('debug panel — end-to-end coverage of every non-happy-path failure mo
|
|
|
81
79
|
const warn = vi.spyOn(console, 'warn').mockImplementation(() => { });
|
|
82
80
|
try {
|
|
83
81
|
const payload = {
|
|
84
|
-
viewports: VIEWPORTS,
|
|
85
82
|
nodes: [{ pattern: {} }, componentNode('button', { id: 'b' })],
|
|
86
83
|
};
|
|
87
84
|
const config = { components: { button: ButtonFixture } };
|
|
@@ -100,7 +97,6 @@ describe('debug panel — end-to-end coverage of every non-happy-path failure mo
|
|
|
100
97
|
const warn = vi.spyOn(console, 'warn').mockImplementation(() => { });
|
|
101
98
|
try {
|
|
102
99
|
const payload = {
|
|
103
|
-
viewports: VIEWPORTS,
|
|
104
100
|
nodes: [componentNode('button', { id: 'b' })],
|
|
105
101
|
};
|
|
106
102
|
const config = {
|
|
@@ -131,7 +127,6 @@ describe('debug panel — end-to-end coverage of every non-happy-path failure mo
|
|
|
131
127
|
const warn = vi.spyOn(console, 'warn').mockImplementation(() => { });
|
|
132
128
|
try {
|
|
133
129
|
const payload = {
|
|
134
|
-
viewports: VIEWPORTS,
|
|
135
130
|
nodes: [
|
|
136
131
|
componentNode('button', {
|
|
137
132
|
id: 'b',
|
|
@@ -159,7 +154,6 @@ describe('debug panel — end-to-end coverage of every non-happy-path failure mo
|
|
|
159
154
|
const warn = vi.spyOn(console, 'warn').mockImplementation(() => { });
|
|
160
155
|
try {
|
|
161
156
|
const payload = {
|
|
162
|
-
viewports: VIEWPORTS,
|
|
163
157
|
nodes: [componentNode('missing', { id: 'm' })],
|
|
164
158
|
};
|
|
165
159
|
const config = { components: {} };
|
|
@@ -178,7 +172,6 @@ describe('debug panel — end-to-end coverage of every non-happy-path failure mo
|
|
|
178
172
|
const warn = vi.spyOn(console, 'warn').mockImplementation(() => { });
|
|
179
173
|
try {
|
|
180
174
|
const payload = {
|
|
181
|
-
viewports: VIEWPORTS,
|
|
182
175
|
nodes: [
|
|
183
176
|
{
|
|
184
177
|
experienceTemplate: {
|
|
@@ -208,7 +201,6 @@ describe('debug panel — end-to-end coverage of every non-happy-path failure mo
|
|
|
208
201
|
const warn = vi.spyOn(console, 'warn').mockImplementation(() => { });
|
|
209
202
|
try {
|
|
210
203
|
const payload = {
|
|
211
|
-
viewports: VIEWPORTS,
|
|
212
204
|
nodes: [componentNode('broken', { id: 'b' })],
|
|
213
205
|
};
|
|
214
206
|
const config = { components: { broken: BrokenFixture } };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Read the current node's resolved design values
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* Read the current node's token-resolved design values. Returns `{}` when
|
|
3
|
+
* there's no design in scope. Read it inside a `$derived` to stay current
|
|
4
|
+
* across plan changes.
|
|
5
5
|
*
|
|
6
6
|
* Pass a type argument to shape the bag:
|
|
7
7
|
*
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { getResolvedDesign } from './context.js';
|
|
2
2
|
/**
|
|
3
|
-
* Read the current node's resolved design values
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* Read the current node's token-resolved design values. Returns `{}` when
|
|
4
|
+
* there's no design in scope. Read it inside a `$derived` to stay current
|
|
5
|
+
* across plan changes.
|
|
6
6
|
*
|
|
7
7
|
* Pass a type argument to shape the bag:
|
|
8
8
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -5,8 +5,6 @@ export { default as MissingComponent } from './MissingComponent.svelte';
|
|
|
5
5
|
export { default as ComponentError } from './ComponentError.svelte';
|
|
6
6
|
export { default as DebugExperience } from './DebugExperience.svelte';
|
|
7
7
|
export { default as NodesRenderer } from './NodesRenderer.svelte';
|
|
8
|
-
export { useActiveViewport } from './use-active-viewport.svelte.js';
|
|
9
|
-
export type { UseActiveViewportResult } from './use-active-viewport.svelte.js';
|
|
10
8
|
export { useLivePreviewExperience } from './use-live-preview-experience.svelte.js';
|
|
11
9
|
export type { UseLivePreviewExperienceOptions, UseLivePreviewExperienceResult, } from './use-live-preview-experience.svelte.js';
|
|
12
10
|
export { useLivePreview } from './use-live-preview.svelte.js';
|
|
@@ -26,8 +24,8 @@ export { resolveExperience } from '@contentful/experiences-sdk-core';
|
|
|
26
24
|
export type { ResolverConfig, ResolveExperienceOptions } from '@contentful/experiences-sdk-core';
|
|
27
25
|
export { DEFAULT_PAGE_PROPERTIES, EventBuilder } from '@contentful/experiences-client';
|
|
28
26
|
export type { ClickBuilderArgs, EventBuilderConfig, FlagViewBuilderArgs, HoverBuilderArgs, IdentifyBuilderArgs, InteractionBuilderArgsBase, PageViewBuilderArgs, TrackBuilderArgs, UniversalEventBuilderArgs, ViewBuilderArgs, } from '@contentful/experiences-client';
|
|
29
|
-
export type { ComponentNode, ComponentRef, DesignPropValue, DesignToken, ExperienceContext, ExperienceNode, ExperiencePayload, ExperienceSourceMap, ExperienceSys, ExperienceTemplateNode, ExperienceTemplateRef, ManualDesignValue, PortableRegistration, PortableRenderNode, PortableRenderPlan, ResolveContext,
|
|
30
|
-
export { CSS_PROPERTIES,
|
|
27
|
+
export type { ComponentNode, ComponentRef, DesignPropValue, DesignToken, ExperienceContext, ExperienceNode, ExperiencePayload, ExperienceSourceMap, ExperienceSys, ExperienceTemplateNode, ExperienceTemplateRef, ManualDesignValue, PortableRegistration, PortableRenderNode, PortableRenderPlan, ResolveContext, } from '@contentful/experiences-sdk-core';
|
|
28
|
+
export { CSS_PROPERTIES, isCssProperty, toCssKey } from '@contentful/experiences-design';
|
|
31
29
|
export { ANONYMOUS_ID_COOKIE, ContentfulViewDelivery, ContentfulViewDeliveryClient, DELIVERY_HOST, ExperienceFetchError, NotFoundError, PREVIEW_HOST, createClient, fetchExperience, readSourceMap, toExperiencePayload, toExperiencePayloadFromDestination, } from '@contentful/experiences-client';
|
|
32
30
|
export type { ByDestinationNodeIdExperienceOptions, ByDestinationPathExperienceOptions, ByIdExperienceOptions, ClientOptions, CreateClientOptions, DestinationRedirectResult, ExperienceOptions, ExperienceResponse, ResolveOptions, } from '@contentful/experiences-client';
|
|
33
31
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,OAAO,IAAI,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AACxF,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AAClF,OAAO,EAAE,OAAO,IAAI,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AACxF,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AACxE,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAKtE,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAElE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"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"}
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Public API surface for `@contentful/experiences-svelte`.
|
|
3
3
|
*
|
|
4
4
|
* Customers add ONLY this package to their app's dependencies. Everything
|
|
5
|
-
* needed to render an Experience — types, the resolver,
|
|
5
|
+
* needed to render an Experience — types, the resolver, design utilities,
|
|
6
6
|
* the renderer components, the authoring helpers — is re-exported from here.
|
|
7
7
|
* The internal `@contentful/experiences-sdk-core` and
|
|
8
8
|
* `@contentful/experiences-design` packages are workspace-only implementation
|
|
@@ -22,7 +22,6 @@ export { default as DebugExperience } from './DebugExperience.svelte';
|
|
|
22
22
|
// advanced customers can render a slot's raw nodes themselves instead:
|
|
23
23
|
// e.g. `<NodesRenderer nodes={contentful.slots.header as PortableRenderNode[]} ... />`.
|
|
24
24
|
export { default as NodesRenderer } from './NodesRenderer.svelte';
|
|
25
|
-
export { useActiveViewport } from './use-active-viewport.svelte.js';
|
|
26
25
|
export { useLivePreviewExperience } from './use-live-preview-experience.svelte.js';
|
|
27
26
|
export { useLivePreview } from './use-live-preview.svelte.js';
|
|
28
27
|
export { useExperiencePlan } from './use-experience-plan.svelte.js';
|
|
@@ -38,6 +37,6 @@ export { resolveExperience } from '@contentful/experiences-sdk-core';
|
|
|
38
37
|
// ─── Event builder (re-exported from client) ──────────────────────────────
|
|
39
38
|
export { DEFAULT_PAGE_PROPERTIES, EventBuilder } from '@contentful/experiences-client';
|
|
40
39
|
// ─── Design utilities (re-exported from design) ───────────────────────────
|
|
41
|
-
export { CSS_PROPERTIES,
|
|
40
|
+
export { CSS_PROPERTIES, isCssProperty, toCssKey } from '@contentful/experiences-design';
|
|
42
41
|
// ─── Delivery client + fetchExperience ────────────────────────────────────
|
|
43
42
|
export { ANONYMOUS_ID_COOKIE, ContentfulViewDelivery, ContentfulViewDeliveryClient, DELIVERY_HOST, ExperienceFetchError, NotFoundError, PREVIEW_HOST, createClient, fetchExperience, readSourceMap, toExperiencePayload, toExperiencePayloadFromDestination, } from '@contentful/experiences-client';
|
|
@@ -19,7 +19,6 @@ import BrokenFixture from './test-fixtures/BrokenFixture.svelte';
|
|
|
19
19
|
import ButtonFixture from './test-fixtures/ButtonFixture.svelte';
|
|
20
20
|
import ContainerFixture from './test-fixtures/ContainerFixture.svelte';
|
|
21
21
|
import ExperienceTemplateFixture from './test-fixtures/ExperienceTemplateFixture.svelte';
|
|
22
|
-
const VIEWPORTS = [{ id: 'desktop', query: '*', displayName: 'Desktop', previewSize: '100%' }];
|
|
23
22
|
const componentNode = (typeId, rest = {}) => ({
|
|
24
23
|
component: {
|
|
25
24
|
sys: {
|
|
@@ -62,7 +61,6 @@ const renderPlan = async (payload) => {
|
|
|
62
61
|
describe('NodesRenderer — SSR (server-compiled output)', () => {
|
|
63
62
|
it('renders a component node’s slot children', async () => {
|
|
64
63
|
const html = await renderPlan({
|
|
65
|
-
viewports: VIEWPORTS,
|
|
66
64
|
nodes: [
|
|
67
65
|
componentNode('contentful-container', {
|
|
68
66
|
id: 'container',
|
|
@@ -77,7 +75,6 @@ describe('NodesRenderer — SSR (server-compiled output)', () => {
|
|
|
77
75
|
});
|
|
78
76
|
it('renders a coded Experience Template node’s named `content` slot', async () => {
|
|
79
77
|
const html = await renderPlan({
|
|
80
|
-
viewports: VIEWPORTS,
|
|
81
78
|
nodes: [
|
|
82
79
|
experienceTemplateNode('page', {
|
|
83
80
|
id: 'tpl',
|
|
@@ -95,7 +92,6 @@ describe('NodesRenderer — SSR (server-compiled output)', () => {
|
|
|
95
92
|
});
|
|
96
93
|
it('renders deeply nested slot children', async () => {
|
|
97
94
|
const html = await renderPlan({
|
|
98
|
-
viewports: VIEWPORTS,
|
|
99
95
|
nodes: [
|
|
100
96
|
experienceTemplateNode('page', {
|
|
101
97
|
id: 'tpl',
|
|
@@ -118,7 +114,6 @@ describe('NodesRenderer — SSR (server-compiled output)', () => {
|
|
|
118
114
|
});
|
|
119
115
|
it('renders a composite experience unwrapped', async () => {
|
|
120
116
|
const html = await renderPlan({
|
|
121
|
-
viewports: VIEWPORTS,
|
|
122
117
|
nodes: [button('Alone')],
|
|
123
118
|
});
|
|
124
119
|
expect(html).toContain('Alone');
|
|
@@ -141,7 +136,6 @@ describe('NodesRenderer — SSR component-render-error (the documented gap)', ()
|
|
|
141
136
|
};
|
|
142
137
|
it('has no recovery path under svelte/server — no graceful fallback markup is produced', async () => {
|
|
143
138
|
const payload = {
|
|
144
|
-
viewports: VIEWPORTS,
|
|
145
139
|
nodes: [componentNode('broken', { id: 'b' }), button('sibling')],
|
|
146
140
|
};
|
|
147
141
|
const plan = await resolveExperience(payload, brokenConfig);
|
|
@@ -12,16 +12,7 @@ import ExperienceTemplateFixture from './test-fixtures/ExperienceTemplateFixture
|
|
|
12
12
|
import WrappingContainerFixture from './test-fixtures/WrappingContainerFixture.svelte';
|
|
13
13
|
import { captureSink } from './test-fixtures/capture-sink.js';
|
|
14
14
|
import { toCss } from './design-utils.js';
|
|
15
|
-
const VIEWPORTS = [
|
|
16
|
-
{ id: 'desktop', query: '*', displayName: 'Desktop', previewSize: '100%' },
|
|
17
|
-
{ id: 'tablet', query: '<992px', displayName: 'Tablet', previewSize: '100%' },
|
|
18
|
-
{ id: 'mobile', query: '<576px', displayName: 'Mobile', previewSize: '100%' },
|
|
19
|
-
];
|
|
20
15
|
const m = (value) => ({ type: 'ManualDesignValue', value });
|
|
21
|
-
const vbv = (values) => ({
|
|
22
|
-
type: 'ValuesByViewport',
|
|
23
|
-
values,
|
|
24
|
-
});
|
|
25
16
|
const dt = (value) => ({ type: 'DesignToken', value });
|
|
26
17
|
function componentNode(typeId, rest = {}) {
|
|
27
18
|
return {
|
|
@@ -78,13 +69,12 @@ const config = {
|
|
|
78
69
|
},
|
|
79
70
|
};
|
|
80
71
|
const payload = {
|
|
81
|
-
viewports: VIEWPORTS,
|
|
82
72
|
nodes: [
|
|
83
73
|
componentNode('contentful-container', {
|
|
84
74
|
id: 'page',
|
|
85
75
|
contentProperties: {},
|
|
86
76
|
designProperties: {
|
|
87
|
-
cfPadding:
|
|
77
|
+
cfPadding: m('40px'),
|
|
88
78
|
},
|
|
89
79
|
slots: {
|
|
90
80
|
children: [
|
|
@@ -92,18 +82,14 @@ const payload = {
|
|
|
92
82
|
id: 'heading',
|
|
93
83
|
contentProperties: { text: 'Build faster' },
|
|
94
84
|
designProperties: {
|
|
95
|
-
cfFontSize:
|
|
85
|
+
cfFontSize: m('32px'),
|
|
96
86
|
},
|
|
97
87
|
}),
|
|
98
88
|
componentNode('contentful-button', {
|
|
99
89
|
id: 'btn',
|
|
100
90
|
contentProperties: { label: 'Get started' },
|
|
101
91
|
designProperties: {
|
|
102
|
-
cfBackgroundColor:
|
|
103
|
-
desktop: m('#4f39f6'),
|
|
104
|
-
tablet: m('#ff0000'),
|
|
105
|
-
mobile: m('#00aa00'),
|
|
106
|
-
}),
|
|
92
|
+
cfBackgroundColor: m('#4f39f6'),
|
|
107
93
|
},
|
|
108
94
|
}),
|
|
109
95
|
],
|
|
@@ -112,7 +98,7 @@ const payload = {
|
|
|
112
98
|
],
|
|
113
99
|
};
|
|
114
100
|
describe('ServerExperienceRenderer', () => {
|
|
115
|
-
it('renders a nested experience with
|
|
101
|
+
it('renders a nested experience with design props', async () => {
|
|
116
102
|
const plan = await resolveExperience(payload, config);
|
|
117
103
|
const { container } = render(ServerExperienceRenderer, {
|
|
118
104
|
props: { experience: plan, config },
|
|
@@ -124,25 +110,6 @@ describe('ServerExperienceRenderer', () => {
|
|
|
124
110
|
expect(html).toContain('Build faster');
|
|
125
111
|
expect(html).toContain('Get started');
|
|
126
112
|
});
|
|
127
|
-
it('honors initialViewportId when resolving design props', async () => {
|
|
128
|
-
const plan = await resolveExperience(payload, config);
|
|
129
|
-
const { container } = render(ServerExperienceRenderer, {
|
|
130
|
-
props: { experience: plan, config, initialViewportId: 'mobile' },
|
|
131
|
-
});
|
|
132
|
-
const html = container.innerHTML;
|
|
133
|
-
expect(html).toContain('data-padding="12px"');
|
|
134
|
-
expect(html).toContain('data-font-size="20px"');
|
|
135
|
-
expect(html).toContain('data-bg="#00aa00"');
|
|
136
|
-
});
|
|
137
|
-
it('cascades design values when the active viewport has none', async () => {
|
|
138
|
-
const plan = await resolveExperience(payload, config);
|
|
139
|
-
const { container } = render(ServerExperienceRenderer, {
|
|
140
|
-
props: { experience: plan, config, initialViewportId: 'tablet' },
|
|
141
|
-
});
|
|
142
|
-
const html = container.innerHTML;
|
|
143
|
-
expect(html).toContain('data-font-size="32px"'); // cascaded from desktop
|
|
144
|
-
expect(html).toContain('data-bg="#ff0000"'); // tablet-specific
|
|
145
|
-
});
|
|
146
113
|
it('renders nothing meaningful when plan is null/undefined', () => {
|
|
147
114
|
const { container: nullContainer } = render(ServerExperienceRenderer, {
|
|
148
115
|
props: { experience: null, config },
|
|
@@ -153,40 +120,12 @@ describe('ServerExperienceRenderer', () => {
|
|
|
153
120
|
});
|
|
154
121
|
expect(undefContainer.querySelector('*')).toBeNull();
|
|
155
122
|
});
|
|
156
|
-
it('exposes the active viewport on render context (defaults to viewport[0])', async () => {
|
|
157
|
-
const captureConfig = { components: { capture: CapturingComponent } };
|
|
158
|
-
const plan = await resolveExperience({ viewports: VIEWPORTS, nodes: [componentNode('capture')] }, captureConfig);
|
|
159
|
-
render(ServerExperienceRenderer, {
|
|
160
|
-
props: { experience: plan, config: captureConfig },
|
|
161
|
-
});
|
|
162
|
-
expect(captureSink.length).toBe(1);
|
|
163
|
-
const ctx = captureSink[0].experience;
|
|
164
|
-
expect(ctx.activeViewportIndex).toBe(0);
|
|
165
|
-
expect(ctx.activeViewport).toBe(VIEWPORTS[0]);
|
|
166
|
-
expect(ctx.viewports).toBe(VIEWPORTS);
|
|
167
|
-
});
|
|
168
|
-
it('honors initialViewportId when computing the active viewport', async () => {
|
|
169
|
-
const captureConfig = { components: { capture: CapturingComponent } };
|
|
170
|
-
const plan = await resolveExperience({ viewports: VIEWPORTS, nodes: [componentNode('capture')] }, captureConfig);
|
|
171
|
-
render(ServerExperienceRenderer, {
|
|
172
|
-
props: {
|
|
173
|
-
experience: plan,
|
|
174
|
-
config: captureConfig,
|
|
175
|
-
initialViewportId: 'mobile',
|
|
176
|
-
},
|
|
177
|
-
});
|
|
178
|
-
const ctx = captureSink[0].experience;
|
|
179
|
-
expect(ctx.activeViewportIndex).toBe(2);
|
|
180
|
-
expect(ctx.activeViewport).toBe(VIEWPORTS[2]);
|
|
181
|
-
});
|
|
182
123
|
it('renders missing-component fallback in debug mode', () => {
|
|
183
124
|
const warn = vi.spyOn(console, 'warn').mockImplementation(() => { });
|
|
184
125
|
const justContainer = {
|
|
185
126
|
components: { 'contentful-container': ContainerFixture },
|
|
186
127
|
};
|
|
187
128
|
const planWithMissing = {
|
|
188
|
-
viewports: VIEWPORTS,
|
|
189
|
-
fallbackViewportIndex: 0,
|
|
190
129
|
metadata: {},
|
|
191
130
|
debug: false,
|
|
192
131
|
diagnostics: [],
|
|
@@ -224,7 +163,7 @@ describe('ServerExperienceRenderer', () => {
|
|
|
224
163
|
});
|
|
225
164
|
it('auto-mounts DebugExperience only when debug is on', async () => {
|
|
226
165
|
const captureConfig = { components: { capture: CapturingComponent } };
|
|
227
|
-
const plan = await resolveExperience({
|
|
166
|
+
const plan = await resolveExperience({ nodes: [componentNode('capture', { id: 'c' })] }, captureConfig);
|
|
228
167
|
const { container: off } = render(ServerExperienceRenderer, {
|
|
229
168
|
props: { experience: plan, config: captureConfig },
|
|
230
169
|
});
|
|
@@ -237,7 +176,7 @@ describe('ServerExperienceRenderer', () => {
|
|
|
237
176
|
});
|
|
238
177
|
it('threads top-level metadata into getExperience()', async () => {
|
|
239
178
|
const captureConfig = { components: { capture: CapturingComponent } };
|
|
240
|
-
const plan = await resolveExperience({
|
|
179
|
+
const plan = await resolveExperience({ nodes: [componentNode('capture', { id: 'c' })] }, captureConfig);
|
|
241
180
|
render(ServerExperienceRenderer, {
|
|
242
181
|
props: { experience: plan, config: captureConfig, metadata: { slug: 'home' } },
|
|
243
182
|
});
|
|
@@ -253,7 +192,6 @@ describe('ServerExperienceRenderer', () => {
|
|
|
253
192
|
},
|
|
254
193
|
};
|
|
255
194
|
const plan = await resolveExperience({
|
|
256
|
-
viewports: VIEWPORTS,
|
|
257
195
|
nodes: [
|
|
258
196
|
componentNode('item', {
|
|
259
197
|
id: 'i',
|
|
@@ -277,7 +215,6 @@ describe('ServerExperienceRenderer', () => {
|
|
|
277
215
|
},
|
|
278
216
|
};
|
|
279
217
|
const plan = await resolveExperience({
|
|
280
|
-
viewports: VIEWPORTS,
|
|
281
218
|
nodes: [
|
|
282
219
|
componentNode('item', {
|
|
283
220
|
id: 'i',
|
|
@@ -300,8 +237,6 @@ describe('ServerExperienceRenderer', () => {
|
|
|
300
237
|
},
|
|
301
238
|
};
|
|
302
239
|
const planWithResolved = {
|
|
303
|
-
viewports: VIEWPORTS,
|
|
304
|
-
fallbackViewportIndex: 0,
|
|
305
240
|
metadata: {},
|
|
306
241
|
debug: false,
|
|
307
242
|
diagnostics: [],
|
|
@@ -335,7 +270,6 @@ describe('ServerExperienceRenderer', () => {
|
|
|
335
270
|
// prop — the fixture renders it, so the child only appears if that holds.
|
|
336
271
|
const tplPayload = {
|
|
337
272
|
sys: sysWithExperienceTemplate('page'),
|
|
338
|
-
viewports: VIEWPORTS,
|
|
339
273
|
nodes: [
|
|
340
274
|
experienceTemplateNode('page', {
|
|
341
275
|
id: 'tpl',
|
|
@@ -363,7 +297,6 @@ describe('ServerExperienceRenderer', () => {
|
|
|
363
297
|
};
|
|
364
298
|
const plan = await resolveExperience({
|
|
365
299
|
sys: sysWithExperienceTemplate('hero'),
|
|
366
|
-
viewports: VIEWPORTS,
|
|
367
300
|
nodes: [
|
|
368
301
|
componentNode('item', { id: 'a', contentProperties: { value: 'one' } }),
|
|
369
302
|
componentNode('item', { id: 'b', contentProperties: { value: 'two' } }),
|
|
@@ -382,7 +315,6 @@ describe('ServerExperienceRenderer', () => {
|
|
|
382
315
|
const warn = vi.spyOn(console, 'warn').mockImplementation(() => { });
|
|
383
316
|
const cfg = { components: { item: PrecedenceFixture } };
|
|
384
317
|
const tplPayload = {
|
|
385
|
-
viewports: VIEWPORTS,
|
|
386
318
|
nodes: [
|
|
387
319
|
experienceTemplateNode('missing-experienceTemplate', {
|
|
388
320
|
id: 'tpl',
|
|
@@ -409,7 +341,6 @@ describe('ServerExperienceRenderer', () => {
|
|
|
409
341
|
});
|
|
410
342
|
describe('ServerExperienceRenderer — slot children as an array', () => {
|
|
411
343
|
const childrenPayload = () => ({
|
|
412
|
-
viewports: VIEWPORTS,
|
|
413
344
|
nodes: [
|
|
414
345
|
componentNode('contentful-container', {
|
|
415
346
|
id: 'c',
|
|
@@ -458,7 +389,7 @@ describe('ServerExperienceRenderer — slot children as an array', () => {
|
|
|
458
389
|
const cfg = {
|
|
459
390
|
components: { 'contentful-container': WrappingContainerFixture },
|
|
460
391
|
};
|
|
461
|
-
const plan = await resolveExperience({
|
|
392
|
+
const plan = await resolveExperience({ nodes: [componentNode('contentful-container', { id: 'c' })] }, cfg);
|
|
462
393
|
const { container } = render(ServerExperienceRenderer, {
|
|
463
394
|
props: { experience: plan, config: cfg },
|
|
464
395
|
});
|
|
@@ -471,7 +402,6 @@ describe('ServerExperienceRenderer — bare-component registrations', () => {
|
|
|
471
402
|
it('accepts a bare Svelte component as a registry entry', async () => {
|
|
472
403
|
const cfg = { components: { item: PrecedenceFixture } };
|
|
473
404
|
const plan = await resolveExperience({
|
|
474
|
-
viewports: VIEWPORTS,
|
|
475
405
|
nodes: [componentNode('item', { id: 'b', contentProperties: { value: 'hi' } })],
|
|
476
406
|
}, cfg);
|
|
477
407
|
const { container } = render(ServerExperienceRenderer, {
|
|
@@ -482,7 +412,6 @@ describe('ServerExperienceRenderer — bare-component registrations', () => {
|
|
|
482
412
|
it('does NOT spread experience/contentful as props onto components', async () => {
|
|
483
413
|
const cfg = { components: { capture: CapturingComponent } };
|
|
484
414
|
const plan = await resolveExperience({
|
|
485
|
-
viewports: VIEWPORTS,
|
|
486
415
|
nodes: [
|
|
487
416
|
componentNode('capture', {
|
|
488
417
|
id: 'c',
|
|
@@ -506,12 +435,11 @@ describe('ServerExperienceRenderer — getContentfulComponent()', () => {
|
|
|
506
435
|
it('exposes the raw Contentful payload to descendants', async () => {
|
|
507
436
|
const cfg = { components: { capture: CapturingComponent } };
|
|
508
437
|
const plan = await resolveExperience({
|
|
509
|
-
viewports: VIEWPORTS,
|
|
510
438
|
nodes: [
|
|
511
439
|
componentNode('capture', {
|
|
512
440
|
id: 'btn-1',
|
|
513
441
|
contentProperties: { label: 'Buy now' },
|
|
514
|
-
designProperties: { cfPadding:
|
|
442
|
+
designProperties: { cfPadding: m('40px') },
|
|
515
443
|
}),
|
|
516
444
|
],
|
|
517
445
|
}, cfg);
|
|
@@ -523,7 +451,7 @@ describe('ServerExperienceRenderer — getContentfulComponent()', () => {
|
|
|
523
451
|
componentId: 'capture',
|
|
524
452
|
nodeId: 'btn-1',
|
|
525
453
|
content: { label: 'Buy now' },
|
|
526
|
-
design: { cfPadding:
|
|
454
|
+
design: { cfPadding: m('40px') },
|
|
527
455
|
resolved: undefined,
|
|
528
456
|
});
|
|
529
457
|
});
|
|
@@ -536,7 +464,7 @@ describe('ServerExperienceRenderer — getContentfulComponent()', () => {
|
|
|
536
464
|
},
|
|
537
465
|
},
|
|
538
466
|
};
|
|
539
|
-
const plan = await resolveExperience({
|
|
467
|
+
const plan = await resolveExperience({ nodes: [componentNode('capture', { id: 'i' })] }, cfg);
|
|
540
468
|
render(ServerExperienceRenderer, {
|
|
541
469
|
props: { experience: plan, config: cfg },
|
|
542
470
|
});
|
|
@@ -550,7 +478,6 @@ describe('ServerExperienceRenderer — resolveToken', () => {
|
|
|
550
478
|
resolveToken: (ref) => (ref.value === 'color/surface/hero' ? '#4f39f6' : undefined),
|
|
551
479
|
};
|
|
552
480
|
const plan = await resolveExperience({
|
|
553
|
-
viewports: VIEWPORTS,
|
|
554
481
|
nodes: [
|
|
555
482
|
componentNode('contentful-button', {
|
|
556
483
|
id: 'b',
|
|
@@ -572,7 +499,6 @@ describe('ServerExperienceRenderer — resolveToken', () => {
|
|
|
572
499
|
resolveToken: () => undefined,
|
|
573
500
|
};
|
|
574
501
|
const plan = await resolveExperience({
|
|
575
|
-
viewports: VIEWPORTS,
|
|
576
502
|
nodes: [
|
|
577
503
|
componentNode('contentful-button', {
|
|
578
504
|
id: 'b',
|
|
@@ -592,7 +518,6 @@ describe('ServerExperienceRenderer — resolveToken', () => {
|
|
|
592
518
|
it('leaves token values untouched when no resolver is supplied (backward-compatible)', async () => {
|
|
593
519
|
const cfg = { components: { 'contentful-button': ButtonFixture } };
|
|
594
520
|
const plan = await resolveExperience({
|
|
595
|
-
viewports: VIEWPORTS,
|
|
596
521
|
nodes: [
|
|
597
522
|
componentNode('contentful-button', {
|
|
598
523
|
id: 'b',
|
|
@@ -617,7 +542,6 @@ describe('ServerExperienceRenderer — resolveToken', () => {
|
|
|
617
542
|
};
|
|
618
543
|
const tplPayload = {
|
|
619
544
|
sys: sysWithExperienceTemplate('page'),
|
|
620
|
-
viewports: VIEWPORTS,
|
|
621
545
|
nodes: [
|
|
622
546
|
experienceTemplateNode('page', {
|
|
623
547
|
id: 'tpl',
|
|
@@ -629,10 +553,8 @@ describe('ServerExperienceRenderer — resolveToken', () => {
|
|
|
629
553
|
],
|
|
630
554
|
};
|
|
631
555
|
const plan = await resolveExperience(tplPayload, tplConfig);
|
|
632
|
-
// Render at a non-fallback viewport (mobile ≠ fallback index 0) so the
|
|
633
|
-
// adapter recomputes from the raw design and runs resolveToken itself.
|
|
634
556
|
const { container } = render(ServerExperienceRenderer, {
|
|
635
|
-
props: { experience: plan, config: tplConfig
|
|
557
|
+
props: { experience: plan, config: tplConfig },
|
|
636
558
|
});
|
|
637
559
|
expect(container.innerHTML).toContain('data-bg="#111827"');
|
|
638
560
|
});
|
|
@@ -641,7 +563,6 @@ describe('ServerExperienceRenderer — design values auto-fill props', () => {
|
|
|
641
563
|
it('spreads resolved design values onto component props by their raw key', async () => {
|
|
642
564
|
const cfg = { components: { capture: CapturingComponent } };
|
|
643
565
|
const plan = await resolveExperience({
|
|
644
|
-
viewports: VIEWPORTS,
|
|
645
566
|
nodes: [
|
|
646
567
|
componentNode('capture', {
|
|
647
568
|
id: 'p',
|
|
@@ -668,7 +589,6 @@ describe('ServerExperienceRenderer — design values auto-fill props', () => {
|
|
|
668
589
|
it('lets content override design on a key collision (content wins)', async () => {
|
|
669
590
|
const cfg = { components: { capture: CapturingComponent } };
|
|
670
591
|
const plan = await resolveExperience({
|
|
671
|
-
viewports: VIEWPORTS,
|
|
672
592
|
nodes: [
|
|
673
593
|
componentNode('capture', {
|
|
674
594
|
id: 'p',
|
|
@@ -691,7 +611,6 @@ describe('ServerExperienceRenderer — getDesignValues()', () => {
|
|
|
691
611
|
resolveToken: (ref) => (ref.value === 'brand/primary' ? '#4f39f6' : undefined),
|
|
692
612
|
};
|
|
693
613
|
const plan = await resolveExperience({
|
|
694
|
-
viewports: VIEWPORTS,
|
|
695
614
|
nodes: [
|
|
696
615
|
componentNode('capture', {
|
|
697
616
|
id: 'p',
|
|
@@ -708,67 +627,22 @@ describe('ServerExperienceRenderer — getDesignValues()', () => {
|
|
|
708
627
|
cfPadding: '24px',
|
|
709
628
|
});
|
|
710
629
|
});
|
|
711
|
-
it('
|
|
630
|
+
it('returns design values when reading design values', async () => {
|
|
712
631
|
const cfg = { components: { capture: CapturingComponent } };
|
|
713
632
|
const plan = await resolveExperience({
|
|
714
|
-
viewports: VIEWPORTS,
|
|
715
633
|
nodes: [
|
|
716
634
|
componentNode('capture', {
|
|
717
635
|
id: 'p',
|
|
718
|
-
designProperties: {
|
|
719
|
-
cfPadding: vbv({ desktop: m('40px'), mobile: m('12px') }),
|
|
720
|
-
},
|
|
636
|
+
designProperties: { cfPadding: m('40px') },
|
|
721
637
|
}),
|
|
722
638
|
],
|
|
723
639
|
}, cfg);
|
|
724
|
-
render(ServerExperienceRenderer, {
|
|
725
|
-
|
|
726
|
-
});
|
|
727
|
-
expect(captureSink[0].designValues).toEqual({ cfPadding: '12px' });
|
|
728
|
-
});
|
|
729
|
-
});
|
|
730
|
-
describe('ServerExperienceRenderer — server pre-resolved design values', () => {
|
|
731
|
-
const probePayload = {
|
|
732
|
-
viewports: VIEWPORTS,
|
|
733
|
-
nodes: [
|
|
734
|
-
componentNode('contentful-container', {
|
|
735
|
-
id: 'p',
|
|
736
|
-
designProperties: { cfPadding: vbv({ desktop: m('40px'), mobile: m('12px') }) },
|
|
737
|
-
}),
|
|
738
|
-
],
|
|
739
|
-
};
|
|
740
|
-
it('consumes props.design as-is when the active viewport equals the fallback', async () => {
|
|
741
|
-
const plan = await resolveExperience(probePayload, config, { initialViewportId: 'mobile' });
|
|
742
|
-
// Tamper the precomputed values with a sentinel the cascade could never produce.
|
|
743
|
-
plan.nodes[0].props.design = { cfPadding: 'SENTINEL' };
|
|
744
|
-
const { container } = render(ServerExperienceRenderer, {
|
|
745
|
-
props: { experience: plan, config, initialViewportId: 'mobile' },
|
|
746
|
-
});
|
|
747
|
-
expect(container.innerHTML).toContain('data-padding="SENTINEL"');
|
|
748
|
-
});
|
|
749
|
-
it('recomputes from raw design properties when the active viewport differs from the fallback', async () => {
|
|
750
|
-
const plan = await resolveExperience(probePayload, config, { initialViewportId: 'mobile' });
|
|
751
|
-
plan.nodes[0].props.design = { cfPadding: 'SENTINEL' };
|
|
752
|
-
// Active viewport (desktop, idx 0) ≠ fallback (mobile, idx 2) → recompute.
|
|
753
|
-
const { container } = render(ServerExperienceRenderer, {
|
|
754
|
-
props: { experience: plan, config, initialViewportId: 'desktop' },
|
|
755
|
-
});
|
|
756
|
-
expect(container.innerHTML).toContain('data-padding="40px"');
|
|
757
|
-
expect(container.innerHTML).not.toContain('SENTINEL');
|
|
758
|
-
});
|
|
759
|
-
it('recomputes when the active viewport differs from the default fallback (viewport[0])', async () => {
|
|
760
|
-
const plan = await resolveExperience(probePayload, config);
|
|
761
|
-
// No fallback configured → pre-resolved against viewport[0] (desktop, idx 0).
|
|
762
|
-
expect(plan.fallbackViewportIndex).toBe(0);
|
|
763
|
-
// Active viewport is mobile (idx 2) ≠ fallback (idx 0) → recompute to 12px.
|
|
764
|
-
const { container } = render(ServerExperienceRenderer, {
|
|
765
|
-
props: { experience: plan, config, initialViewportId: 'mobile' },
|
|
766
|
-
});
|
|
767
|
-
expect(container.innerHTML).toContain('data-padding="12px"');
|
|
640
|
+
render(ServerExperienceRenderer, { props: { experience: plan, config: cfg } });
|
|
641
|
+
expect(captureSink[0].designValues).toEqual({ cfPadding: '40px' });
|
|
768
642
|
});
|
|
769
643
|
});
|
|
770
|
-
describe('ServerExperienceRenderer —
|
|
771
|
-
it('renders
|
|
644
|
+
describe('ServerExperienceRenderer — design values', () => {
|
|
645
|
+
it('renders resolved design values', async () => {
|
|
772
646
|
const cfg = { components: { heading: HeadingFixture } };
|
|
773
647
|
const plan = await resolveExperience({
|
|
774
648
|
nodes: [
|
|
@@ -778,7 +652,6 @@ describe('ServerExperienceRenderer — absent payload.viewports', () => {
|
|
|
778
652
|
}),
|
|
779
653
|
],
|
|
780
654
|
}, cfg);
|
|
781
|
-
expect(plan.viewports).toEqual([]);
|
|
782
655
|
const { container } = render(ServerExperienceRenderer, {
|
|
783
656
|
props: { experience: plan, config: cfg },
|
|
784
657
|
});
|
|
@@ -821,7 +694,7 @@ describe('ServerExperienceRenderer — render context carried on the plan', () =
|
|
|
821
694
|
captureSink.splice(0);
|
|
822
695
|
});
|
|
823
696
|
const captureConfig = { components: { capture: CapturingComponent } };
|
|
824
|
-
const buildPlan = (opts) => resolveExperience({
|
|
697
|
+
const buildPlan = (opts) => resolveExperience({ nodes: [componentNode('capture', { id: 'c' })] }, captureConfig, opts);
|
|
825
698
|
it('reads metadata off the plan without it being passed to the renderer', async () => {
|
|
826
699
|
const plan = await buildPlan({ metadata: { slug: 'home', locale: 'en-US' } });
|
|
827
700
|
render(ServerExperienceRenderer, { props: { experience: plan, config: captureConfig } });
|
package/dist/types.d.ts
CHANGED
|
@@ -10,8 +10,8 @@ export type { ResolveContext, ResolveToken };
|
|
|
10
10
|
* re-rendering a slot's nodes yourself through the exported `<NodesRenderer />`.
|
|
11
11
|
*
|
|
12
12
|
* Design properties stay in their **raw discriminated form** here (the same
|
|
13
|
-
* shape `ctx.design` carries inside `resolveData`).
|
|
14
|
-
*
|
|
13
|
+
* shape `ctx.design` carries inside `resolveData`). Token-resolved values are
|
|
14
|
+
* what `getDesignValues()` returns.
|
|
15
15
|
*/
|
|
16
16
|
export interface ContentfulComponent {
|
|
17
17
|
componentId: string;
|
|
@@ -17,17 +17,8 @@ const payload = (title) => ({
|
|
|
17
17
|
},
|
|
18
18
|
],
|
|
19
19
|
sys: { type: 'Experience' },
|
|
20
|
-
viewports: [
|
|
21
|
-
{
|
|
22
|
-
displayName: 'Default',
|
|
23
|
-
id: 'default',
|
|
24
|
-
previewSize: '1024px',
|
|
25
|
-
query: '*',
|
|
26
|
-
},
|
|
27
|
-
],
|
|
28
20
|
});
|
|
29
21
|
const initialPlan = {
|
|
30
|
-
fallbackViewportIndex: 0,
|
|
31
22
|
nodes: [
|
|
32
23
|
{
|
|
33
24
|
nodeId: 'initial',
|
|
@@ -36,7 +27,6 @@ const initialPlan = {
|
|
|
36
27
|
slots: {},
|
|
37
28
|
},
|
|
38
29
|
],
|
|
39
|
-
viewports: payload('initial').viewports,
|
|
40
30
|
metadata: {},
|
|
41
31
|
debug: false,
|
|
42
32
|
diagnostics: [],
|