@shoppexio/builder-contracts 0.1.2 → 0.1.4

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.
@@ -0,0 +1,11 @@
1
+ /**
2
+ * SSOT for iframe embed origins allowed in the Edge Block Engine CSP (frame-src)
3
+ * and for custom-embed postMessage trust in storefront-commerce (when registered).
4
+ */
5
+ export declare const EDGE_BLOCK_YOUTUBE_FRAME_ORIGINS: readonly ["https://www.youtube.com", "https://www.youtube-nocookie.com"];
6
+ /** Trusted origins for custom-embed resize postMessage (storefront-commerce). */
7
+ export declare const EDGE_BLOCK_CUSTOM_EMBED_TRUSTED_ORIGINS: readonly ["https://calendly.com", "https://substack.com", "https://shoppex.io"];
8
+ /** frame-src entries for custom embed blocks (includes Substack wildcard). */
9
+ export declare const EDGE_BLOCK_CUSTOM_EMBED_FRAME_SRC_ORIGINS: readonly ["https://calendly.com", "https://substack.com", "https://shoppex.io", "https://*.substack.com"];
10
+ export declare const EDGE_BLOCK_ALLOWED_FRAME_ORIGINS: readonly ["https://www.youtube.com", "https://www.youtube-nocookie.com", "https://calendly.com", "https://substack.com", "https://shoppex.io", "https://*.substack.com"];
11
+ //# sourceMappingURL=edge-block-engine-frame-origins.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"edge-block-engine-frame-origins.d.ts","sourceRoot":"","sources":["../src/edge-block-engine-frame-origins.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,gCAAgC,0EAGnC,CAAC;AAEX,iFAAiF;AACjF,eAAO,MAAM,uCAAuC,iFAI1C,CAAC;AAEX,8EAA8E;AAC9E,eAAO,MAAM,yCAAyC,2GAG5C,CAAC;AAEX,eAAO,MAAM,gCAAgC,0KAGnC,CAAC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * SSOT for iframe embed origins allowed in the Edge Block Engine CSP (frame-src)
3
+ * and for custom-embed postMessage trust in storefront-commerce (when registered).
4
+ */
5
+ export const EDGE_BLOCK_YOUTUBE_FRAME_ORIGINS = [
6
+ 'https://www.youtube.com',
7
+ 'https://www.youtube-nocookie.com',
8
+ ];
9
+ /** Trusted origins for custom-embed resize postMessage (storefront-commerce). */
10
+ export const EDGE_BLOCK_CUSTOM_EMBED_TRUSTED_ORIGINS = [
11
+ 'https://calendly.com',
12
+ 'https://substack.com',
13
+ 'https://shoppex.io',
14
+ ];
15
+ /** frame-src entries for custom embed blocks (includes Substack wildcard). */
16
+ export const EDGE_BLOCK_CUSTOM_EMBED_FRAME_SRC_ORIGINS = [
17
+ ...EDGE_BLOCK_CUSTOM_EMBED_TRUSTED_ORIGINS,
18
+ 'https://*.substack.com',
19
+ ];
20
+ export const EDGE_BLOCK_ALLOWED_FRAME_ORIGINS = [
21
+ ...EDGE_BLOCK_YOUTUBE_FRAME_ORIGINS,
22
+ ...EDGE_BLOCK_CUSTOM_EMBED_FRAME_SRC_ORIGINS,
23
+ ];
package/dist/fields.d.ts CHANGED
@@ -14,13 +14,13 @@ export declare const ListItemFieldTypeSchema: z.ZodEnum<{
14
14
  number: "number";
15
15
  boolean: "boolean";
16
16
  link: "link";
17
+ product: "product";
17
18
  text: "text";
18
19
  richtext: "richtext";
19
20
  image: "image";
20
21
  range: "range";
21
22
  select: "select";
22
23
  color: "color";
23
- product: "product";
24
24
  }>;
25
25
  export type ListItemFieldType = z.infer<typeof ListItemFieldTypeSchema>;
26
26
  export declare const ListItemFieldSchema: z.ZodObject<{
@@ -38,13 +38,13 @@ export declare const ListItemFieldSchema: z.ZodObject<{
38
38
  number: "number";
39
39
  boolean: "boolean";
40
40
  link: "link";
41
+ product: "product";
41
42
  text: "text";
42
43
  richtext: "richtext";
43
44
  image: "image";
44
45
  range: "range";
45
46
  select: "select";
46
47
  color: "color";
47
- product: "product";
48
48
  }>;
49
49
  options: z.ZodOptional<z.ZodArray<z.ZodObject<{
50
50
  label: z.ZodString;
@@ -266,13 +266,13 @@ export declare const BuilderFieldSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
266
266
  number: "number";
267
267
  boolean: "boolean";
268
268
  link: "link";
269
+ product: "product";
269
270
  text: "text";
270
271
  richtext: "richtext";
271
272
  image: "image";
272
273
  range: "range";
273
274
  select: "select";
274
275
  color: "color";
275
- product: "product";
276
276
  }>;
277
277
  options: z.ZodOptional<z.ZodArray<z.ZodObject<{
278
278
  label: z.ZodString;
@@ -495,13 +495,13 @@ export declare const BlockSettingsSchema: z.ZodRecord<z.ZodString, z.ZodDiscrimi
495
495
  number: "number";
496
496
  boolean: "boolean";
497
497
  link: "link";
498
+ product: "product";
498
499
  text: "text";
499
500
  richtext: "richtext";
500
501
  image: "image";
501
502
  range: "range";
502
503
  select: "select";
503
504
  color: "color";
504
- product: "product";
505
505
  }>;
506
506
  options: z.ZodOptional<z.ZodArray<z.ZodObject<{
507
507
  label: z.ZodString;
@@ -27,5 +27,6 @@ export declare function createBlockInstance(input: {
27
27
  export declare function createPageLayoutFromBlocks(blocks: BlockInstance[]): PageLayout;
28
28
  export declare function migrateLegacyBuilderSettings(input: LegacyBuilderSettingsInput, revision?: number): BuilderSettings;
29
29
  export declare function applyManifestDefaultLayout(settings: BuilderSettings, manifest: ThemeManifest): BuilderSettings;
30
+ export declare function mapLegacyNestedThemeTypographyToStyleSlots(theme: Record<string, unknown>, baseSlots?: StyleSlots): StyleSlots;
30
31
  export declare function mapLegacyTokenOverridesToStyleSlots(tokens: Record<string, unknown>): StyleSlots;
31
32
  //# sourceMappingURL=migrations.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"migrations.d.ts","sourceRoot":"","sources":["../src/migrations.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,eAAe,EAEpB,KAAK,UAAU,EAChB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,MAAM,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AAU,CAE9E;AAED,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,0BAA0B,EAAE,QAAQ,SAAI,GAAG,eAAe,CAoB7G;AAED,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,eAAe,EAAE,QAAQ,EAAE,aAAa,GAAG,eAAe,CAwB9G;AAED,wBAAgB,0CAA0C,CACxD,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,SAAS,GAAE,UAAe,GACzB,UAAU,CAkBZ;AAeD,wBAAgB,mCAAmC,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,UAAU,CAuC/F"}
@@ -69,6 +69,31 @@ export function applyManifestDefaultLayout(settings, manifest) {
69
69
  }
70
70
  return BuilderSettingsSchema.parse(next);
71
71
  }
72
+ export function mapLegacyNestedThemeTypographyToStyleSlots(theme, baseSlots = {}) {
73
+ const slots = { ...baseSlots };
74
+ const typography = theme.typography;
75
+ if (!isRecord(typography)) {
76
+ return slots;
77
+ }
78
+ const bodyFont = readLegacyTypographyString(typography, 'font_family', 'fontFamily');
79
+ const headingFont = readLegacyTypographyString(typography, 'heading_font', 'headingFont');
80
+ if (bodyFont && slots['theme.typography.font.family'] === undefined) {
81
+ slots['theme.typography.font.family'] = bodyFont;
82
+ }
83
+ if (headingFont && slots['theme.typography.heading.font'] === undefined) {
84
+ slots['theme.typography.heading.font'] = headingFont;
85
+ }
86
+ return slots;
87
+ }
88
+ function readLegacyTypographyString(typography, ...keys) {
89
+ for (const key of keys) {
90
+ const value = typography[key];
91
+ if (typeof value === 'string' && value.trim().length > 0) {
92
+ return value.trim();
93
+ }
94
+ }
95
+ return null;
96
+ }
72
97
  export function mapLegacyTokenOverridesToStyleSlots(tokens) {
73
98
  const slots = {};
74
99
  assignResponsiveNumber(tokens, slots, 'buttons.borderRadius', 'button.radius');
@@ -1,6 +1,15 @@
1
1
  import { type BuilderSettings } from './builder-settings.ts';
2
2
  type JsonRecord = Record<string, unknown>;
3
3
  export declare function extractPersistedBuilderSettings(input: unknown): BuilderSettings | null;
4
+ /**
5
+ * Single read boundary for builder v2 state: strict extract first, then legacy migration.
6
+ * Strips invalid keys such as nested `theme.typography` while preserving style_slots and pages.
7
+ */
8
+ export declare function coercePersistedBuilderSettings(input: unknown): BuilderSettings | null;
9
+ /**
10
+ * Coerces builder v2 fields for storefront export while preserving non-v2 siblings (seo, appearance, …).
11
+ */
12
+ export declare function exportCoercedBuilderSettingsBlob(builderSettingsBlob: unknown): JsonRecord | null;
4
13
  export declare function sanitizeBuilderSettingsState(settings: BuilderSettings): BuilderSettings;
5
14
  export declare function mergeBuilderSettingsIntoThemeSettings(currentSettings: unknown, builderSettings: BuilderSettings): JsonRecord;
6
15
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"persistence.d.ts","sourceRoot":"","sources":["../src/persistence.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,eAAe,EAErB,MAAM,uBAAuB,CAAC;AAE/B,KAAK,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAmB1C,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,OAAO,GAAG,eAAe,GAAG,IAAI,CAYtF;AAED,wBAAgB,4BAA4B,CAAC,QAAQ,EAAE,eAAe,GAAG,eAAe,CASvF;AAaD,wBAAgB,qCAAqC,CACnD,eAAe,EAAE,OAAO,EACxB,eAAe,EAAE,eAAe,GAC/B,UAAU,CAaZ"}
1
+ {"version":3,"file":"persistence.d.ts","sourceRoot":"","sources":["../src/persistence.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,eAAe,EAErB,MAAM,uBAAuB,CAAC;AAQ/B,KAAK,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAmB1C,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,OAAO,GAAG,eAAe,GAAG,IAAI,CAYtF;AA0BD;;;GAGG;AACH,wBAAgB,8BAA8B,CAAC,KAAK,EAAE,OAAO,GAAG,eAAe,GAAG,IAAI,CAkDrF;AAED;;GAEG;AACH,wBAAgB,gCAAgC,CAAC,mBAAmB,EAAE,OAAO,GAAG,UAAU,GAAG,IAAI,CAgBhG;AAED,wBAAgB,4BAA4B,CAAC,QAAQ,EAAE,eAAe,GAAG,eAAe,CASvF;AAaD,wBAAgB,qCAAqC,CACnD,eAAe,EAAE,OAAO,EACxB,eAAe,EAAE,eAAe,GAC/B,UAAU,CAgBZ"}
@@ -1,4 +1,5 @@
1
1
  import { BuilderSettingsSchema, } from "./builder-settings.js";
2
+ import { mapLegacyNestedThemeTypographyToStyleSlots, mapLegacyTokenOverridesToStyleSlots, migrateLegacyBuilderSettings, } from "./migrations.js";
2
3
  const RESERVED_THEME_CONTENT_KEYS = new Set(['layout']);
3
4
  function isRecord(value) {
4
5
  return typeof value === 'object' && value !== null && !Array.isArray(value);
@@ -24,6 +25,85 @@ export function extractPersistedBuilderSettings(input) {
24
25
  const parsedNested = BuilderSettingsSchema.safeParse(pickBuilderSettingsFields(input.builder_settings));
25
26
  return parsedNested.success ? sanitizeBuilderSettingsState(parsedNested.data) : null;
26
27
  }
28
+ function parseBuilderSettingsRevision(input) {
29
+ return typeof input === 'number' && Number.isInteger(input) && input >= 0 ? input : 0;
30
+ }
31
+ function unwrapBuilderSettingsRecord(input) {
32
+ if (!isRecord(input)) {
33
+ return null;
34
+ }
35
+ if (isRecord(input.builder_settings)) {
36
+ return input.builder_settings;
37
+ }
38
+ if ('version' in input || 'revision' in input || 'theme' in input) {
39
+ return input;
40
+ }
41
+ return null;
42
+ }
43
+ function readStyleSlotsRecord(theme) {
44
+ return isRecord(theme.style_slots) ? theme.style_slots : {};
45
+ }
46
+ /**
47
+ * Single read boundary for builder v2 state: strict extract first, then legacy migration.
48
+ * Strips invalid keys such as nested `theme.typography` while preserving style_slots and pages.
49
+ */
50
+ export function coercePersistedBuilderSettings(input) {
51
+ const extracted = extractPersistedBuilderSettings(input);
52
+ if (extracted) {
53
+ return extracted;
54
+ }
55
+ if (isRecord(input) && isRecord(input.builder_settings)) {
56
+ const nestedExtracted = extractPersistedBuilderSettings(input.builder_settings);
57
+ if (nestedExtracted) {
58
+ return nestedExtracted;
59
+ }
60
+ }
61
+ const blob = unwrapBuilderSettingsRecord(input);
62
+ if (!blob) {
63
+ return null;
64
+ }
65
+ const theme = isRecord(blob.theme) ? blob.theme : {};
66
+ const tokensOverride = isRecord(theme.tokens_override) ? theme.tokens_override : {};
67
+ const styleSlots = mapLegacyNestedThemeTypographyToStyleSlots(theme, {
68
+ ...mapLegacyTokenOverridesToStyleSlots(tokensOverride),
69
+ ...readStyleSlotsRecord(theme),
70
+ });
71
+ const migrated = migrateLegacyBuilderSettings({
72
+ theme: {
73
+ content: isRecord(theme.content) ? theme.content : {},
74
+ layout: isRecord(theme.layout) ? theme.layout : {},
75
+ tokens_override: tokensOverride,
76
+ style_slots: styleSlots,
77
+ },
78
+ }, parseBuilderSettingsRevision(blob.revision));
79
+ const merged = BuilderSettingsSchema.safeParse({
80
+ ...migrated,
81
+ theme: {
82
+ ...migrated.theme,
83
+ pages: Array.isArray(theme.pages) ? theme.pages : migrated.theme.pages,
84
+ terms: isRecord(theme.terms) ? theme.terms : migrated.theme.terms,
85
+ },
86
+ });
87
+ return merged.success ? sanitizeBuilderSettingsState(merged.data) : migrated;
88
+ }
89
+ /**
90
+ * Coerces builder v2 fields for storefront export while preserving non-v2 siblings (seo, appearance, …).
91
+ */
92
+ export function exportCoercedBuilderSettingsBlob(builderSettingsBlob) {
93
+ if (!isRecord(builderSettingsBlob)) {
94
+ return null;
95
+ }
96
+ const coerced = coercePersistedBuilderSettings(builderSettingsBlob);
97
+ if (!coerced) {
98
+ return null;
99
+ }
100
+ return {
101
+ ...builderSettingsBlob,
102
+ version: coerced.version,
103
+ revision: coerced.revision,
104
+ theme: coerced.theme,
105
+ };
106
+ }
27
107
  export function sanitizeBuilderSettingsState(settings) {
28
108
  const content = sanitizeThemeContent(settings.theme.content);
29
109
  return BuilderSettingsSchema.parse({
@@ -48,6 +128,9 @@ export function mergeBuilderSettingsIntoThemeSettings(currentSettings, builderSe
48
128
  const root = isRecord(currentSettings) ? { ...currentSettings } : {};
49
129
  const currentBuilderSettings = isRecord(root.builder_settings) ? root.builder_settings : {};
50
130
  const sanitizedBuilderSettings = sanitizeBuilderSettingsState(builderSettings);
131
+ root.version = sanitizedBuilderSettings.version;
132
+ root.revision = sanitizedBuilderSettings.revision;
133
+ root.theme = sanitizedBuilderSettings.theme;
51
134
  root.builder_settings = {
52
135
  ...currentBuilderSettings,
53
136
  version: sanitizedBuilderSettings.version,
@@ -66,6 +66,28 @@ export declare const PreviewApplyStateMessageSchema: z.ZodObject<{
66
66
  }, z.core.$strict>;
67
67
  }, z.core.$strict>;
68
68
  }, z.core.$strict>;
69
+ export declare const EdgeBlockRenderModeSchema: z.ZodLiteral<"edge-block-engine">;
70
+ export type EdgeBlockRenderMode = z.infer<typeof EdgeBlockRenderModeSchema>;
71
+ export declare const PreviewBlockHtmlPatchSchema: z.ZodObject<{
72
+ blockId: z.ZodString;
73
+ html: z.ZodString;
74
+ }, z.core.$strict>;
75
+ export type PreviewBlockHtmlPatch = z.infer<typeof PreviewBlockHtmlPatchSchema>;
76
+ export declare const PreviewApplyBlockHtmlMessageSchema: z.ZodObject<{
77
+ type: z.ZodLiteral<"APPLY_BLOCK_HTML">;
78
+ revision: z.ZodNumber;
79
+ pageId: z.ZodString;
80
+ sourceRevision: z.ZodString;
81
+ renderMode: z.ZodLiteral<"edge-block-engine">;
82
+ scope: z.ZodOptional<z.ZodEnum<{
83
+ page: "page";
84
+ block: "block";
85
+ }>>;
86
+ blocks: z.ZodArray<z.ZodObject<{
87
+ blockId: z.ZodString;
88
+ html: z.ZodString;
89
+ }, z.core.$strict>>;
90
+ }, z.core.$strict>;
69
91
  export declare const PreviewReloadMessageSchema: z.ZodObject<{
70
92
  type: z.ZodLiteral<"RELOAD">;
71
93
  revision: z.ZodNumber;
@@ -164,6 +186,20 @@ export declare const PreviewMessageSchema: z.ZodDiscriminatedUnion<[z.ZodObject<
164
186
  }, z.core.$strict>>;
165
187
  }, z.core.$strict>;
166
188
  }, z.core.$strict>;
189
+ }, z.core.$strict>, z.ZodObject<{
190
+ type: z.ZodLiteral<"APPLY_BLOCK_HTML">;
191
+ revision: z.ZodNumber;
192
+ pageId: z.ZodString;
193
+ sourceRevision: z.ZodString;
194
+ renderMode: z.ZodLiteral<"edge-block-engine">;
195
+ scope: z.ZodOptional<z.ZodEnum<{
196
+ page: "page";
197
+ block: "block";
198
+ }>>;
199
+ blocks: z.ZodArray<z.ZodObject<{
200
+ blockId: z.ZodString;
201
+ html: z.ZodString;
202
+ }, z.core.$strict>>;
167
203
  }, z.core.$strict>, z.ZodObject<{
168
204
  type: z.ZodLiteral<"RELOAD">;
169
205
  revision: z.ZodNumber;
@@ -209,14 +245,28 @@ export declare const PreviewBootstrapOkResponseSchema: z.ZodObject<{
209
245
  shopId: z.ZodString;
210
246
  artifactStale: z.ZodOptional<z.ZodBoolean>;
211
247
  }, z.core.$strict>;
248
+ export declare const PreviewReadyHealthSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
249
+ reactMounted: z.ZodLiteral<true>;
250
+ builderRuntimeProvider: z.ZodLiteral<true>;
251
+ protocolVersion: z.ZodLiteral<2>;
252
+ }, z.core.$strict>, z.ZodObject<{
253
+ edgeBlockEngine: z.ZodLiteral<true>;
254
+ blockHtmlReconcile: z.ZodLiteral<true>;
255
+ protocolVersion: z.ZodLiteral<3>;
256
+ }, z.core.$strict>], "protocolVersion">;
257
+ export type PreviewReadyHealth = z.infer<typeof PreviewReadyHealthSchema>;
212
258
  export declare const PreviewReadyResponseSchema: z.ZodObject<{
213
259
  type: z.ZodLiteral<"READY">;
214
260
  revision: z.ZodNumber;
215
- health: z.ZodOptional<z.ZodObject<{
261
+ health: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
216
262
  reactMounted: z.ZodLiteral<true>;
217
263
  builderRuntimeProvider: z.ZodLiteral<true>;
218
264
  protocolVersion: z.ZodLiteral<2>;
219
- }, z.core.$strict>>;
265
+ }, z.core.$strict>, z.ZodObject<{
266
+ edgeBlockEngine: z.ZodLiteral<true>;
267
+ blockHtmlReconcile: z.ZodLiteral<true>;
268
+ protocolVersion: z.ZodLiteral<3>;
269
+ }, z.core.$strict>], "protocolVersion">>;
220
270
  }, z.core.$strict>;
221
271
  export declare const PreviewAppliedResponseSchema: z.ZodObject<{
222
272
  type: z.ZodLiteral<"APPLIED">;
@@ -227,6 +277,30 @@ export declare const PreviewApplyFailedResponseSchema: z.ZodObject<{
227
277
  revision: z.ZodNumber;
228
278
  error: z.ZodString;
229
279
  }, z.core.$strict>;
280
+ export declare const PreviewBlockHtmlAppliedResponseSchema: z.ZodObject<{
281
+ type: z.ZodLiteral<"BLOCK_HTML_APPLIED">;
282
+ revision: z.ZodNumber;
283
+ pageId: z.ZodString;
284
+ sourceRevision: z.ZodString;
285
+ renderMode: z.ZodLiteral<"edge-block-engine">;
286
+ scope: z.ZodOptional<z.ZodEnum<{
287
+ page: "page";
288
+ block: "block";
289
+ }>>;
290
+ blocks: z.ZodArray<z.ZodObject<{
291
+ blockId: z.ZodString;
292
+ html: z.ZodString;
293
+ }, z.core.$strict>>;
294
+ }, z.core.$strict>;
295
+ export declare const PreviewBlockHtmlFailedResponseSchema: z.ZodObject<{
296
+ type: z.ZodLiteral<"BLOCK_HTML_FAILED">;
297
+ revision: z.ZodNumber;
298
+ pageId: z.ZodString;
299
+ sourceRevision: z.ZodOptional<z.ZodString>;
300
+ renderMode: z.ZodLiteral<"edge-block-engine">;
301
+ blockIds: z.ZodArray<z.ZodString>;
302
+ error: z.ZodString;
303
+ }, z.core.$strict>;
230
304
  export declare const PreviewElementClickedResponseSchema: z.ZodObject<{
231
305
  type: z.ZodLiteral<"ELEMENT_CLICKED">;
232
306
  revision: z.ZodOptional<z.ZodNumber>;
@@ -351,11 +425,15 @@ export declare const PreviewResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject
351
425
  }, z.core.$strict>, z.ZodObject<{
352
426
  type: z.ZodLiteral<"READY">;
353
427
  revision: z.ZodNumber;
354
- health: z.ZodOptional<z.ZodObject<{
428
+ health: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
355
429
  reactMounted: z.ZodLiteral<true>;
356
430
  builderRuntimeProvider: z.ZodLiteral<true>;
357
431
  protocolVersion: z.ZodLiteral<2>;
358
- }, z.core.$strict>>;
432
+ }, z.core.$strict>, z.ZodObject<{
433
+ edgeBlockEngine: z.ZodLiteral<true>;
434
+ blockHtmlReconcile: z.ZodLiteral<true>;
435
+ protocolVersion: z.ZodLiteral<3>;
436
+ }, z.core.$strict>], "protocolVersion">>;
359
437
  }, z.core.$strict>, z.ZodObject<{
360
438
  type: z.ZodLiteral<"APPLIED">;
361
439
  revision: z.ZodNumber;
@@ -363,6 +441,28 @@ export declare const PreviewResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject
363
441
  type: z.ZodLiteral<"APPLY_FAILED">;
364
442
  revision: z.ZodNumber;
365
443
  error: z.ZodString;
444
+ }, z.core.$strict>, z.ZodObject<{
445
+ type: z.ZodLiteral<"BLOCK_HTML_APPLIED">;
446
+ revision: z.ZodNumber;
447
+ pageId: z.ZodString;
448
+ sourceRevision: z.ZodString;
449
+ renderMode: z.ZodLiteral<"edge-block-engine">;
450
+ scope: z.ZodOptional<z.ZodEnum<{
451
+ page: "page";
452
+ block: "block";
453
+ }>>;
454
+ blocks: z.ZodArray<z.ZodObject<{
455
+ blockId: z.ZodString;
456
+ html: z.ZodString;
457
+ }, z.core.$strict>>;
458
+ }, z.core.$strict>, z.ZodObject<{
459
+ type: z.ZodLiteral<"BLOCK_HTML_FAILED">;
460
+ revision: z.ZodNumber;
461
+ pageId: z.ZodString;
462
+ sourceRevision: z.ZodOptional<z.ZodString>;
463
+ renderMode: z.ZodLiteral<"edge-block-engine">;
464
+ blockIds: z.ZodArray<z.ZodString>;
465
+ error: z.ZodString;
366
466
  }, z.core.$strict>, z.ZodObject<{
367
467
  type: z.ZodLiteral<"ELEMENT_CLICKED">;
368
468
  revision: z.ZodOptional<z.ZodNumber>;
@@ -1 +1 @@
1
- {"version":3,"file":"preview-protocol.d.ts","sourceRoot":"","sources":["../src/preview-protocol.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAG5B,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;kBAYxB,CAAC;AACZ,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAEtE,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAMhC,CAAC;AAEZ,eAAO,MAAM,0BAA0B;;;;;;;kBAM5B,CAAC;AAEZ,eAAO,MAAM,iCAAiC;;;;;;;;;;;;;;;;;;;;;kBAMnC,CAAC;AAEZ,eAAO,MAAM,gCAAgC;;kBAIlC,CAAC;AAEZ,eAAO,MAAM,qBAAqB;;;EAA8B,CAAC;AACjE,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEpE;;;;;GAKG;AACH,eAAO,MAAM,sCAAsC;;;;;;kBAKxC,CAAC;AAEZ,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4BAM/B,CAAC;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE,eAAO,MAAM,gCAAgC;;;;;;kBAQlC,CAAC;AAEZ,eAAO,MAAM,0BAA0B;;;;;;;;kBAa5B,CAAC;AAEZ,eAAO,MAAM,4BAA4B;;;kBAK9B,CAAC;AAEZ,eAAO,MAAM,g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AM,mCAAmC;;;;;;;;;;;;;;;;;;;;;kBAMrC,CAAC;AAEZ,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBA0B5B,CAAC;AAEZ;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB;;;;;kBAOnB,CAAC;AACZ,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE5D,eAAO,MAAM,8BAA8B;;;;;;;;;;kBAOhC,CAAC;AAEZ;;;;GAIG;AACH,eAAO,MAAM,kCAAkC;;;;;;;;;;kBAOpC,CAAC;AAEZ;;;;GAIG;AACH,eAAO,MAAM,qCAAqC;;;;;;kBAQvC,CAAC;AAEZ,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4BAYhC,CAAC;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC"}
@@ -20,6 +20,24 @@ export const PreviewApplyStateMessageSchema = z
20
20
  state: BuilderSettingsSchema,
21
21
  })
22
22
  .strict();
23
+ export const EdgeBlockRenderModeSchema = z.literal('edge-block-engine');
24
+ export const PreviewBlockHtmlPatchSchema = z
25
+ .object({
26
+ blockId: z.string().min(1),
27
+ html: z.string().min(1),
28
+ })
29
+ .strict();
30
+ export const PreviewApplyBlockHtmlMessageSchema = z
31
+ .object({
32
+ type: z.literal('APPLY_BLOCK_HTML'),
33
+ revision: z.number().int().nonnegative(),
34
+ pageId: z.string().min(1),
35
+ sourceRevision: z.string().min(1),
36
+ renderMode: EdgeBlockRenderModeSchema,
37
+ scope: z.enum(['block', 'page']).optional(),
38
+ blocks: z.array(PreviewBlockHtmlPatchSchema),
39
+ })
40
+ .strict();
23
41
  export const PreviewReloadMessageSchema = z
24
42
  .object({
25
43
  type: z.literal('RELOAD'),
@@ -54,6 +72,7 @@ export const PreviewSetInteractionModeMessageSchema = z
54
72
  .strict();
55
73
  export const PreviewMessageSchema = z.discriminatedUnion('type', [
56
74
  PreviewApplyStateMessageSchema,
75
+ PreviewApplyBlockHtmlMessageSchema,
57
76
  PreviewReloadMessageSchema,
58
77
  PreviewSelectElementMessageSchema,
59
78
  PreviewRequestReadyMessageSchema,
@@ -68,18 +87,27 @@ export const PreviewBootstrapOkResponseSchema = z
68
87
  artifactStale: z.boolean().optional(),
69
88
  })
70
89
  .strict();
71
- export const PreviewReadyResponseSchema = z
72
- .object({
73
- type: z.literal('READY'),
74
- revision: z.number().int().nonnegative(),
75
- health: z
90
+ export const PreviewReadyHealthSchema = z.discriminatedUnion('protocolVersion', [
91
+ z
76
92
  .object({
77
93
  reactMounted: z.literal(true),
78
94
  builderRuntimeProvider: z.literal(true),
79
95
  protocolVersion: z.literal(2),
80
96
  })
81
- .strict()
82
- .optional(),
97
+ .strict(),
98
+ z
99
+ .object({
100
+ edgeBlockEngine: z.literal(true),
101
+ blockHtmlReconcile: z.literal(true),
102
+ protocolVersion: z.literal(3),
103
+ })
104
+ .strict(),
105
+ ]);
106
+ export const PreviewReadyResponseSchema = z
107
+ .object({
108
+ type: z.literal('READY'),
109
+ revision: z.number().int().nonnegative(),
110
+ health: PreviewReadyHealthSchema.optional(),
83
111
  })
84
112
  .strict();
85
113
  export const PreviewAppliedResponseSchema = z
@@ -95,6 +123,28 @@ export const PreviewApplyFailedResponseSchema = z
95
123
  error: z.string().min(1),
96
124
  })
97
125
  .strict();
126
+ export const PreviewBlockHtmlAppliedResponseSchema = z
127
+ .object({
128
+ type: z.literal('BLOCK_HTML_APPLIED'),
129
+ revision: z.number().int().nonnegative(),
130
+ pageId: z.string().min(1),
131
+ sourceRevision: z.string().min(1),
132
+ renderMode: EdgeBlockRenderModeSchema,
133
+ scope: z.enum(['block', 'page']).optional(),
134
+ blocks: z.array(PreviewBlockHtmlPatchSchema),
135
+ })
136
+ .strict();
137
+ export const PreviewBlockHtmlFailedResponseSchema = z
138
+ .object({
139
+ type: z.literal('BLOCK_HTML_FAILED'),
140
+ revision: z.number().int().nonnegative(),
141
+ pageId: z.string().min(1),
142
+ sourceRevision: z.string().min(1).optional(),
143
+ renderMode: EdgeBlockRenderModeSchema,
144
+ blockIds: z.array(z.string().min(1)),
145
+ error: z.string().min(1),
146
+ })
147
+ .strict();
98
148
  export const PreviewElementClickedResponseSchema = z
99
149
  .object({
100
150
  type: z.literal('ELEMENT_CLICKED'),
@@ -183,6 +233,8 @@ export const PreviewResponseSchema = z.discriminatedUnion('type', [
183
233
  PreviewReadyResponseSchema,
184
234
  PreviewAppliedResponseSchema,
185
235
  PreviewApplyFailedResponseSchema,
236
+ PreviewBlockHtmlAppliedResponseSchema,
237
+ PreviewBlockHtmlFailedResponseSchema,
186
238
  PreviewElementClickedResponseSchema,
187
239
  PreviewErrorResponseSchema,
188
240
  PreviewBlockRectResponseSchema,
@@ -44,7 +44,7 @@ export function buildPlainInitialDataScript(initialData) {
44
44
  export function buildWrappedStorefrontInitialDataScript(serialized, deployedThemeEntryPathPattern) {
45
45
  return [
46
46
  '<!--shoppex-initial-data:start--><script>(function(){',
47
- 'if(typeof window!=="undefined"){var path=window.location.pathname||"";',
47
+ 'if(typeof window!=="undefined"){window.__SHOPPEX_DEPLOYED_THEME_ARTIFACT__=true;var path=window.location.pathname||"";',
48
48
  `if(${deployedThemeEntryPathPattern}.test(path)){window.__SHOPPEX_DEPLOYED_THEME_ARTIFACT_PATH__=path;window.history.replaceState(window.history.state,"","/"+window.location.search+window.location.hash);}}`,
49
49
  `window.__SHOPPEX_INITIAL__=${serialized};})();</script><!--shoppex-initial-data:end-->`,
50
50
  ].join('');
@@ -252,13 +252,13 @@ export declare const ManifestBlockSchema: z.ZodObject<{
252
252
  number: "number";
253
253
  boolean: "boolean";
254
254
  link: "link";
255
+ product: "product";
255
256
  text: "text";
256
257
  richtext: "richtext";
257
258
  image: "image";
258
259
  range: "range";
259
260
  select: "select";
260
261
  color: "color";
261
- product: "product";
262
262
  }>;
263
263
  options: z.ZodOptional<z.ZodArray<z.ZodObject<{
264
264
  label: z.ZodString;
@@ -585,13 +585,13 @@ export declare const ThemeManifestSchema: z.ZodObject<{
585
585
  number: "number";
586
586
  boolean: "boolean";
587
587
  link: "link";
588
+ product: "product";
588
589
  text: "text";
589
590
  richtext: "richtext";
590
591
  image: "image";
591
592
  range: "range";
592
593
  select: "select";
593
594
  color: "color";
594
- product: "product";
595
595
  }>;
596
596
  options: z.ZodOptional<z.ZodArray<z.ZodObject<{
597
597
  label: z.ZodString;
@@ -1,10 +1,15 @@
1
1
  export declare const PUBLIC_BUILDER_THEME_SCHEMES: readonly ["default", "classic", "nebula", "pulse", "phantom", "starlight", "apex", "vault", "clean-minimal"];
2
+ export type PublicBuilderThemeScheme = (typeof PUBLIC_BUILDER_THEME_SCHEMES)[number];
2
3
  export declare const STARTER_BUILDER_THEME_SCHEMES: readonly ["blank"];
4
+ export declare const THEME_STORE_DISABLED_SCHEMES: readonly ["vault", "nebula", "phantom", "clean-minimal"];
5
+ export declare const THEME_STORE_INSTALLABLE_SCHEMES: readonly ["default", "classic", "pulse", "starlight", "apex"];
3
6
  export declare const BUILDER_READY_THEME_SCHEMES: readonly ["blank", "default", "classic", "nebula", "pulse", "phantom", "starlight", "apex", "vault", "clean-minimal"];
4
- export type PublicBuilderThemeScheme = (typeof PUBLIC_BUILDER_THEME_SCHEMES)[number];
7
+ export type ThemeStoreInstallableScheme = (typeof THEME_STORE_INSTALLABLE_SCHEMES)[number];
5
8
  export type StarterBuilderThemeScheme = (typeof STARTER_BUILDER_THEME_SCHEMES)[number];
6
9
  export type BuilderReadyThemeScheme = (typeof BUILDER_READY_THEME_SCHEMES)[number];
7
10
  export declare function isPublicBuilderThemeScheme(value: string): value is PublicBuilderThemeScheme;
11
+ export declare function isThemeStoreDisabledScheme(value: string): boolean;
12
+ export declare function isThemeStoreInstallableScheme(value: string): value is ThemeStoreInstallableScheme;
8
13
  export declare function isStarterBuilderThemeScheme(value: string): value is StarterBuilderThemeScheme;
9
14
  export declare function isBuilderReadyThemeScheme(value: string): value is BuilderReadyThemeScheme;
10
15
  //# sourceMappingURL=theme-schemes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"theme-schemes.d.ts","sourceRoot":"","sources":["../src/theme-schemes.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,4BAA4B,8GAU/B,CAAC;AAEX,eAAO,MAAM,6BAA6B,oBAAqB,CAAC;AAEhE,eAAO,MAAM,2BAA2B,uHAG9B,CAAC;AAEX,MAAM,MAAM,wBAAwB,GAAG,CAAC,OAAO,4BAA4B,CAAC,CAAC,MAAM,CAAC,CAAC;AACrF,MAAM,MAAM,yBAAyB,GAAG,CAAC,OAAO,6BAA6B,CAAC,CAAC,MAAM,CAAC,CAAC;AACvF,MAAM,MAAM,uBAAuB,GAAG,CAAC,OAAO,2BAA2B,CAAC,CAAC,MAAM,CAAC,CAAC;AAEnF,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,wBAAwB,CAE3F;AAED,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,yBAAyB,CAE7F;AAED,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,uBAAuB,CAEzF"}
1
+ {"version":3,"file":"theme-schemes.d.ts","sourceRoot":"","sources":["../src/theme-schemes.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,4BAA4B,8GAU/B,CAAC;AAEX,MAAM,MAAM,wBAAwB,GAAG,CAAC,OAAO,4BAA4B,CAAC,CAAC,MAAM,CAAC,CAAC;AAErF,eAAO,MAAM,6BAA6B,oBAAqB,CAAC;AAEhE,eAAO,MAAM,4BAA4B,0DAKe,CAAC;AAIzD,eAAO,MAAM,+BAA+B,+DAMY,CAAC;AAEzD,eAAO,MAAM,2BAA2B,uHAG9B,CAAC;AAEX,MAAM,MAAM,2BAA2B,GAAG,CAAC,OAAO,+BAA+B,CAAC,CAAC,MAAM,CAAC,CAAC;AAC3F,MAAM,MAAM,yBAAyB,GAAG,CAAC,OAAO,6BAA6B,CAAC,CAAC,MAAM,CAAC,CAAC;AACvF,MAAM,MAAM,uBAAuB,GAAG,CAAC,OAAO,2BAA2B,CAAC,CAAC,MAAM,CAAC,CAAC;AAEnF,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,wBAAwB,CAE3F;AAED,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEjE;AAED,wBAAgB,6BAA6B,CAC3C,KAAK,EAAE,MAAM,GACZ,KAAK,IAAI,2BAA2B,CAEtC;AAED,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,yBAAyB,CAE7F;AAED,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,uBAAuB,CAEzF"}
@@ -10,6 +10,20 @@ export const PUBLIC_BUILDER_THEME_SCHEMES = [
10
10
  'clean-minimal',
11
11
  ];
12
12
  export const STARTER_BUILDER_THEME_SCHEMES = ['blank'];
13
+ export const THEME_STORE_DISABLED_SCHEMES = [
14
+ 'vault',
15
+ 'nebula',
16
+ 'phantom',
17
+ 'clean-minimal',
18
+ ];
19
+ const THEME_STORE_DISABLED_SCHEME_SET = new Set(THEME_STORE_DISABLED_SCHEMES);
20
+ export const THEME_STORE_INSTALLABLE_SCHEMES = [
21
+ 'default',
22
+ 'classic',
23
+ 'pulse',
24
+ 'starlight',
25
+ 'apex',
26
+ ];
13
27
  export const BUILDER_READY_THEME_SCHEMES = [
14
28
  ...STARTER_BUILDER_THEME_SCHEMES,
15
29
  ...PUBLIC_BUILDER_THEME_SCHEMES,
@@ -17,6 +31,12 @@ export const BUILDER_READY_THEME_SCHEMES = [
17
31
  export function isPublicBuilderThemeScheme(value) {
18
32
  return PUBLIC_BUILDER_THEME_SCHEMES.includes(value);
19
33
  }
34
+ export function isThemeStoreDisabledScheme(value) {
35
+ return THEME_STORE_DISABLED_SCHEME_SET.has(value);
36
+ }
37
+ export function isThemeStoreInstallableScheme(value) {
38
+ return THEME_STORE_INSTALLABLE_SCHEMES.includes(value);
39
+ }
20
40
  export function isStarterBuilderThemeScheme(value) {
21
41
  return STARTER_BUILDER_THEME_SCHEMES.includes(value);
22
42
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shoppexio/builder-contracts",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "Shared Builder v2 contracts for Shoppex dashboard, backend, preview runtime, and themes",
5
5
  "type": "module",
6
6
  "repository": {
@@ -37,6 +37,12 @@
37
37
  "import": "./dist/builder-settings.js",
38
38
  "default": "./dist/builder-settings.js"
39
39
  },
40
+ "./edge-block-engine-frame-origins": {
41
+ "bun": "./src/edge-block-engine-frame-origins.ts",
42
+ "types": "./dist/edge-block-engine-frame-origins.d.ts",
43
+ "import": "./dist/edge-block-engine-frame-origins.js",
44
+ "default": "./dist/edge-block-engine-frame-origins.js"
45
+ },
40
46
  "./events": {
41
47
  "bun": "./src/events.ts",
42
48
  "types": "./dist/events.d.ts",
@@ -13,6 +13,8 @@ import {
13
13
  createBlockInstance,
14
14
  createEmptyBuilderSettings,
15
15
  convertLegacyThemeManifest,
16
+ coercePersistedBuilderSettings,
17
+ exportCoercedBuilderSettingsBlob,
16
18
  extractPersistedBuilderSettings,
17
19
  canonicalizeBuilderSettingsForManifestWithReport,
18
20
  mergeBuilderSettingsIntoThemeSettings,
@@ -217,9 +219,105 @@ describe('@shoppex/builder-contracts', () => {
217
219
  expect((persisted.builder_settings as Record<string, unknown>).seo).toEqual({
218
220
  default_title: 'Keep this title',
219
221
  });
222
+ expect(persisted.version).toBe(settings.version);
223
+ expect(persisted.revision).toBe(settings.revision);
224
+ expect(persisted.theme).toEqual(settings.theme);
220
225
  expect(extractPersistedBuilderSettings(persisted)).toEqual(settings);
221
226
  });
222
227
 
228
+ test('updates stale root-level builder fields when publishing nested builder settings', () => {
229
+ const settings = createEmptyBuilderSettings(4);
230
+ settings.theme.layout.home = {
231
+ blocks: [
232
+ {
233
+ id: 'hero-1',
234
+ type: 'hero',
235
+ visible: true,
236
+ settings: { 'hero.title': 'Published title' },
237
+ },
238
+ ],
239
+ };
240
+
241
+ const persisted = mergeBuilderSettingsIntoThemeSettings({
242
+ version: 2,
243
+ revision: 1,
244
+ theme: {
245
+ content: {},
246
+ layout: {
247
+ home: {
248
+ blocks: [
249
+ {
250
+ id: 'hero-1',
251
+ type: 'hero',
252
+ visible: true,
253
+ settings: { 'hero.title': 'Old title' },
254
+ },
255
+ ],
256
+ },
257
+ },
258
+ style_slots: {},
259
+ pages: [],
260
+ terms: {},
261
+ },
262
+ builder_settings: {
263
+ seo: {
264
+ default_title: 'Keep this title',
265
+ },
266
+ },
267
+ }, settings);
268
+
269
+ expect(extractPersistedBuilderSettings(persisted)).toEqual(settings);
270
+ expect((persisted.builder_settings as Record<string, unknown>).seo).toEqual({
271
+ default_title: 'Keep this title',
272
+ });
273
+ });
274
+
275
+ test('coerces polluted v2 theme.typography into style_slots and strips invalid keys', () => {
276
+ const coerced = coercePersistedBuilderSettings({
277
+ version: 2,
278
+ revision: 9,
279
+ theme: {
280
+ content: {},
281
+ layout: {},
282
+ style_slots: {
283
+ 'theme.typography.font.family': 'Manrope, sans-serif',
284
+ },
285
+ typography: {
286
+ font_family: 'Legacy Body',
287
+ heading_font: 'Legacy Heading',
288
+ },
289
+ pages: [],
290
+ terms: {},
291
+ },
292
+ });
293
+
294
+ expect(coerced).not.toBeNull();
295
+ expect(coerced?.theme.style_slots['theme.typography.font.family']).toBe('Manrope, sans-serif');
296
+ expect(coerced?.theme.style_slots['theme.typography.heading.font']).toBe('Legacy Heading');
297
+ expect(coerced?.theme).not.toHaveProperty('typography');
298
+ expect(() => BuilderSettingsSchema.parse(coerced)).not.toThrow();
299
+ });
300
+
301
+ test('exportCoercedBuilderSettingsBlob preserves non-v2 siblings', () => {
302
+ const exported = exportCoercedBuilderSettingsBlob({
303
+ seo: { default_title: 'Keep this title' },
304
+ version: 2,
305
+ revision: 4,
306
+ theme: {
307
+ content: {},
308
+ layout: {},
309
+ style_slots: {},
310
+ typography: { font_family: 'Inter' },
311
+ pages: [],
312
+ terms: {},
313
+ },
314
+ });
315
+
316
+ expect(exported?.seo).toEqual({ default_title: 'Keep this title' });
317
+ expect(exported?.theme).not.toHaveProperty('typography');
318
+ expect(exported?.theme.style_slots['theme.typography.font.family']).toBe('Inter');
319
+ });
320
+
223
321
  test('removes reserved content keys from persisted builder v2 state', () => {
224
322
  const settings = BuilderSettingsSchema.parse({
225
323
  ...createEmptyBuilderSettings(5),
@@ -0,0 +1,26 @@
1
+ /**
2
+ * SSOT for iframe embed origins allowed in the Edge Block Engine CSP (frame-src)
3
+ * and for custom-embed postMessage trust in storefront-commerce (when registered).
4
+ */
5
+ export const EDGE_BLOCK_YOUTUBE_FRAME_ORIGINS = [
6
+ 'https://www.youtube.com',
7
+ 'https://www.youtube-nocookie.com',
8
+ ] as const;
9
+
10
+ /** Trusted origins for custom-embed resize postMessage (storefront-commerce). */
11
+ export const EDGE_BLOCK_CUSTOM_EMBED_TRUSTED_ORIGINS = [
12
+ 'https://calendly.com',
13
+ 'https://substack.com',
14
+ 'https://shoppex.io',
15
+ ] as const;
16
+
17
+ /** frame-src entries for custom embed blocks (includes Substack wildcard). */
18
+ export const EDGE_BLOCK_CUSTOM_EMBED_FRAME_SRC_ORIGINS = [
19
+ ...EDGE_BLOCK_CUSTOM_EMBED_TRUSTED_ORIGINS,
20
+ 'https://*.substack.com',
21
+ ] as const;
22
+
23
+ export const EDGE_BLOCK_ALLOWED_FRAME_ORIGINS = [
24
+ ...EDGE_BLOCK_YOUTUBE_FRAME_ORIGINS,
25
+ ...EDGE_BLOCK_CUSTOM_EMBED_FRAME_SRC_ORIGINS,
26
+ ] as const;
package/src/migrations.ts CHANGED
@@ -110,6 +110,42 @@ export function applyManifestDefaultLayout(settings: BuilderSettings, manifest:
110
110
  return BuilderSettingsSchema.parse(next);
111
111
  }
112
112
 
113
+ export function mapLegacyNestedThemeTypographyToStyleSlots(
114
+ theme: Record<string, unknown>,
115
+ baseSlots: StyleSlots = {},
116
+ ): StyleSlots {
117
+ const slots: StyleSlots = { ...baseSlots };
118
+ const typography = theme.typography;
119
+ if (!isRecord(typography)) {
120
+ return slots;
121
+ }
122
+
123
+ const bodyFont = readLegacyTypographyString(typography, 'font_family', 'fontFamily');
124
+ const headingFont = readLegacyTypographyString(typography, 'heading_font', 'headingFont');
125
+
126
+ if (bodyFont && slots['theme.typography.font.family'] === undefined) {
127
+ slots['theme.typography.font.family'] = bodyFont;
128
+ }
129
+ if (headingFont && slots['theme.typography.heading.font'] === undefined) {
130
+ slots['theme.typography.heading.font'] = headingFont;
131
+ }
132
+
133
+ return slots;
134
+ }
135
+
136
+ function readLegacyTypographyString(
137
+ typography: Record<string, unknown>,
138
+ ...keys: string[]
139
+ ): string | null {
140
+ for (const key of keys) {
141
+ const value = typography[key];
142
+ if (typeof value === 'string' && value.trim().length > 0) {
143
+ return value.trim();
144
+ }
145
+ }
146
+ return null;
147
+ }
148
+
113
149
  export function mapLegacyTokenOverridesToStyleSlots(tokens: Record<string, unknown>): StyleSlots {
114
150
  const slots: StyleSlots = {};
115
151
 
@@ -2,6 +2,12 @@ import {
2
2
  type BuilderSettings,
3
3
  BuilderSettingsSchema,
4
4
  } from './builder-settings.ts';
5
+ import {
6
+ mapLegacyNestedThemeTypographyToStyleSlots,
7
+ mapLegacyTokenOverridesToStyleSlots,
8
+ migrateLegacyBuilderSettings,
9
+ } from './migrations.ts';
10
+ import type { StyleSlots } from './style-slots.ts';
5
11
 
6
12
  type JsonRecord = Record<string, unknown>;
7
13
  const RESERVED_THEME_CONTENT_KEYS = new Set(['layout']);
@@ -36,6 +42,107 @@ export function extractPersistedBuilderSettings(input: unknown): BuilderSettings
36
42
  return parsedNested.success ? sanitizeBuilderSettingsState(parsedNested.data) : null;
37
43
  }
38
44
 
45
+ function parseBuilderSettingsRevision(input: unknown): number {
46
+ return typeof input === 'number' && Number.isInteger(input) && input >= 0 ? input : 0;
47
+ }
48
+
49
+ function unwrapBuilderSettingsRecord(input: unknown): JsonRecord | null {
50
+ if (!isRecord(input)) {
51
+ return null;
52
+ }
53
+
54
+ if (isRecord(input.builder_settings)) {
55
+ return input.builder_settings;
56
+ }
57
+
58
+ if ('version' in input || 'revision' in input || 'theme' in input) {
59
+ return input;
60
+ }
61
+
62
+ return null;
63
+ }
64
+
65
+ function readStyleSlotsRecord(theme: JsonRecord): StyleSlots {
66
+ return isRecord(theme.style_slots) ? theme.style_slots as StyleSlots : {};
67
+ }
68
+
69
+ /**
70
+ * Single read boundary for builder v2 state: strict extract first, then legacy migration.
71
+ * Strips invalid keys such as nested `theme.typography` while preserving style_slots and pages.
72
+ */
73
+ export function coercePersistedBuilderSettings(input: unknown): BuilderSettings | null {
74
+ const extracted = extractPersistedBuilderSettings(input);
75
+ if (extracted) {
76
+ return extracted;
77
+ }
78
+
79
+ if (isRecord(input) && isRecord(input.builder_settings)) {
80
+ const nestedExtracted = extractPersistedBuilderSettings(input.builder_settings);
81
+ if (nestedExtracted) {
82
+ return nestedExtracted;
83
+ }
84
+ }
85
+
86
+ const blob = unwrapBuilderSettingsRecord(input);
87
+ if (!blob) {
88
+ return null;
89
+ }
90
+
91
+ const theme = isRecord(blob.theme) ? blob.theme : {};
92
+ const tokensOverride = isRecord(theme.tokens_override) ? theme.tokens_override : {};
93
+ const styleSlots = mapLegacyNestedThemeTypographyToStyleSlots(
94
+ theme,
95
+ {
96
+ ...mapLegacyTokenOverridesToStyleSlots(tokensOverride),
97
+ ...readStyleSlotsRecord(theme),
98
+ },
99
+ );
100
+
101
+ const migrated = migrateLegacyBuilderSettings(
102
+ {
103
+ theme: {
104
+ content: isRecord(theme.content) ? theme.content : {},
105
+ layout: isRecord(theme.layout) ? theme.layout : {},
106
+ tokens_override: tokensOverride,
107
+ style_slots: styleSlots,
108
+ },
109
+ },
110
+ parseBuilderSettingsRevision(blob.revision),
111
+ );
112
+
113
+ const merged = BuilderSettingsSchema.safeParse({
114
+ ...migrated,
115
+ theme: {
116
+ ...migrated.theme,
117
+ pages: Array.isArray(theme.pages) ? theme.pages : migrated.theme.pages,
118
+ terms: isRecord(theme.terms) ? theme.terms : migrated.theme.terms,
119
+ },
120
+ });
121
+
122
+ return merged.success ? sanitizeBuilderSettingsState(merged.data) : migrated;
123
+ }
124
+
125
+ /**
126
+ * Coerces builder v2 fields for storefront export while preserving non-v2 siblings (seo, appearance, …).
127
+ */
128
+ export function exportCoercedBuilderSettingsBlob(builderSettingsBlob: unknown): JsonRecord | null {
129
+ if (!isRecord(builderSettingsBlob)) {
130
+ return null;
131
+ }
132
+
133
+ const coerced = coercePersistedBuilderSettings(builderSettingsBlob);
134
+ if (!coerced) {
135
+ return null;
136
+ }
137
+
138
+ return {
139
+ ...builderSettingsBlob,
140
+ version: coerced.version,
141
+ revision: coerced.revision,
142
+ theme: coerced.theme,
143
+ };
144
+ }
145
+
39
146
  export function sanitizeBuilderSettingsState(settings: BuilderSettings): BuilderSettings {
40
147
  const content = sanitizeThemeContent(settings.theme.content);
41
148
  return BuilderSettingsSchema.parse({
@@ -66,6 +173,9 @@ export function mergeBuilderSettingsIntoThemeSettings(
66
173
  const currentBuilderSettings = isRecord(root.builder_settings) ? root.builder_settings : {};
67
174
  const sanitizedBuilderSettings = sanitizeBuilderSettingsState(builderSettings);
68
175
 
176
+ root.version = sanitizedBuilderSettings.version;
177
+ root.revision = sanitizedBuilderSettings.revision;
178
+ root.theme = sanitizedBuilderSettings.theme;
69
179
  root.builder_settings = {
70
180
  ...currentBuilderSettings,
71
181
  version: sanitizedBuilderSettings.version,
@@ -5,6 +5,44 @@ import {
5
5
  } from './preview-protocol.ts';
6
6
 
7
7
  describe('PreviewMessageSchema', () => {
8
+ it('accepts v3 block HTML apply messages', () => {
9
+ const parsed = PreviewMessageSchema.parse({
10
+ type: 'APPLY_BLOCK_HTML',
11
+ revision: 12,
12
+ pageId: 'product',
13
+ sourceRevision: 'theme-source-12',
14
+ renderMode: 'edge-block-engine',
15
+ blocks: [
16
+ {
17
+ blockId: 'product-form-1',
18
+ html: '<section data-builder-block="product-form-1">Updated</section>',
19
+ },
20
+ ],
21
+ });
22
+
23
+ expect(parsed.type).toBe('APPLY_BLOCK_HTML');
24
+ if (parsed.type === 'APPLY_BLOCK_HTML') {
25
+ expect(parsed.blocks[0]?.blockId).toBe('product-form-1');
26
+ }
27
+ });
28
+
29
+ it('rejects v3 block HTML apply messages without sourceRevision', () => {
30
+ const result = PreviewMessageSchema.safeParse({
31
+ type: 'APPLY_BLOCK_HTML',
32
+ revision: 12,
33
+ pageId: 'product',
34
+ renderMode: 'edge-block-engine',
35
+ blocks: [
36
+ {
37
+ blockId: 'product-form-1',
38
+ html: '<section data-builder-block="product-form-1">Updated</section>',
39
+ },
40
+ ],
41
+ });
42
+
43
+ expect(result.success).toBe(false);
44
+ });
45
+
8
46
  it('accepts SET_INTERACTION_MODE with edit/preview', () => {
9
47
  for (const mode of ['edit', 'preview'] as const) {
10
48
  const parsed = PreviewMessageSchema.parse({
@@ -25,6 +63,58 @@ describe('PreviewMessageSchema', () => {
25
63
  });
26
64
 
27
65
  describe('PreviewResponseSchema', () => {
66
+ it('accepts READY health for edge block protocol v3', () => {
67
+ const parsed = PreviewResponseSchema.parse({
68
+ type: 'READY',
69
+ revision: 12,
70
+ health: {
71
+ edgeBlockEngine: true,
72
+ blockHtmlReconcile: true,
73
+ protocolVersion: 3,
74
+ },
75
+ });
76
+
77
+ expect(parsed.type).toBe('READY');
78
+ if (parsed.type === 'READY') {
79
+ expect(parsed.health?.protocolVersion).toBe(3);
80
+ }
81
+ });
82
+
83
+ it('accepts v3 block HTML applied responses', () => {
84
+ const parsed = PreviewResponseSchema.parse({
85
+ type: 'BLOCK_HTML_APPLIED',
86
+ revision: 12,
87
+ pageId: 'product',
88
+ sourceRevision: 'theme-source-12',
89
+ renderMode: 'edge-block-engine',
90
+ blocks: [
91
+ {
92
+ blockId: 'footer-1',
93
+ html: '<footer data-builder-block="footer-1">Secure delivery</footer>',
94
+ },
95
+ ],
96
+ });
97
+
98
+ expect(parsed.type).toBe('BLOCK_HTML_APPLIED');
99
+ if (parsed.type === 'BLOCK_HTML_APPLIED') {
100
+ expect(parsed.renderMode).toBe('edge-block-engine');
101
+ }
102
+ });
103
+
104
+ it('accepts v3 block HTML failed responses', () => {
105
+ const parsed = PreviewResponseSchema.parse({
106
+ type: 'BLOCK_HTML_FAILED',
107
+ revision: 12,
108
+ pageId: 'product',
109
+ sourceRevision: 'theme-source-12',
110
+ renderMode: 'edge-block-engine',
111
+ blockIds: ['footer-1'],
112
+ error: 'Rendered block root does not match block id.',
113
+ });
114
+
115
+ expect(parsed.type).toBe('BLOCK_HTML_FAILED');
116
+ });
117
+
28
118
  it('accepts BLOCK_RECT with rect', () => {
29
119
  const parsed = PreviewResponseSchema.parse({
30
120
  type: 'BLOCK_RECT',
@@ -24,6 +24,29 @@ export const PreviewApplyStateMessageSchema = z
24
24
  })
25
25
  .strict();
26
26
 
27
+ export const EdgeBlockRenderModeSchema = z.literal('edge-block-engine');
28
+ export type EdgeBlockRenderMode = z.infer<typeof EdgeBlockRenderModeSchema>;
29
+
30
+ export const PreviewBlockHtmlPatchSchema = z
31
+ .object({
32
+ blockId: z.string().min(1),
33
+ html: z.string().min(1),
34
+ })
35
+ .strict();
36
+ export type PreviewBlockHtmlPatch = z.infer<typeof PreviewBlockHtmlPatchSchema>;
37
+
38
+ export const PreviewApplyBlockHtmlMessageSchema = z
39
+ .object({
40
+ type: z.literal('APPLY_BLOCK_HTML'),
41
+ revision: z.number().int().nonnegative(),
42
+ pageId: z.string().min(1),
43
+ sourceRevision: z.string().min(1),
44
+ renderMode: EdgeBlockRenderModeSchema,
45
+ scope: z.enum(['block', 'page']).optional(),
46
+ blocks: z.array(PreviewBlockHtmlPatchSchema),
47
+ })
48
+ .strict();
49
+
27
50
  export const PreviewReloadMessageSchema = z
28
51
  .object({
29
52
  type: z.literal('RELOAD'),
@@ -64,6 +87,7 @@ export const PreviewSetInteractionModeMessageSchema = z
64
87
 
65
88
  export const PreviewMessageSchema = z.discriminatedUnion('type', [
66
89
  PreviewApplyStateMessageSchema,
90
+ PreviewApplyBlockHtmlMessageSchema,
67
91
  PreviewReloadMessageSchema,
68
92
  PreviewSelectElementMessageSchema,
69
93
  PreviewRequestReadyMessageSchema,
@@ -81,18 +105,29 @@ export const PreviewBootstrapOkResponseSchema = z
81
105
  })
82
106
  .strict();
83
107
 
108
+ export const PreviewReadyHealthSchema = z.discriminatedUnion('protocolVersion', [
109
+ z
110
+ .object({
111
+ reactMounted: z.literal(true),
112
+ builderRuntimeProvider: z.literal(true),
113
+ protocolVersion: z.literal(2),
114
+ })
115
+ .strict(),
116
+ z
117
+ .object({
118
+ edgeBlockEngine: z.literal(true),
119
+ blockHtmlReconcile: z.literal(true),
120
+ protocolVersion: z.literal(3),
121
+ })
122
+ .strict(),
123
+ ]);
124
+ export type PreviewReadyHealth = z.infer<typeof PreviewReadyHealthSchema>;
125
+
84
126
  export const PreviewReadyResponseSchema = z
85
127
  .object({
86
128
  type: z.literal('READY'),
87
129
  revision: z.number().int().nonnegative(),
88
- health: z
89
- .object({
90
- reactMounted: z.literal(true),
91
- builderRuntimeProvider: z.literal(true),
92
- protocolVersion: z.literal(2),
93
- })
94
- .strict()
95
- .optional(),
130
+ health: PreviewReadyHealthSchema.optional(),
96
131
  })
97
132
  .strict();
98
133
 
@@ -111,6 +146,30 @@ export const PreviewApplyFailedResponseSchema = z
111
146
  })
112
147
  .strict();
113
148
 
149
+ export const PreviewBlockHtmlAppliedResponseSchema = z
150
+ .object({
151
+ type: z.literal('BLOCK_HTML_APPLIED'),
152
+ revision: z.number().int().nonnegative(),
153
+ pageId: z.string().min(1),
154
+ sourceRevision: z.string().min(1),
155
+ renderMode: EdgeBlockRenderModeSchema,
156
+ scope: z.enum(['block', 'page']).optional(),
157
+ blocks: z.array(PreviewBlockHtmlPatchSchema),
158
+ })
159
+ .strict();
160
+
161
+ export const PreviewBlockHtmlFailedResponseSchema = z
162
+ .object({
163
+ type: z.literal('BLOCK_HTML_FAILED'),
164
+ revision: z.number().int().nonnegative(),
165
+ pageId: z.string().min(1),
166
+ sourceRevision: z.string().min(1).optional(),
167
+ renderMode: EdgeBlockRenderModeSchema,
168
+ blockIds: z.array(z.string().min(1)),
169
+ error: z.string().min(1),
170
+ })
171
+ .strict();
172
+
114
173
  export const PreviewElementClickedResponseSchema = z
115
174
  .object({
116
175
  type: z.literal('ELEMENT_CLICKED'),
@@ -206,6 +265,8 @@ export const PreviewResponseSchema = z.discriminatedUnion('type', [
206
265
  PreviewReadyResponseSchema,
207
266
  PreviewAppliedResponseSchema,
208
267
  PreviewApplyFailedResponseSchema,
268
+ PreviewBlockHtmlAppliedResponseSchema,
269
+ PreviewBlockHtmlFailedResponseSchema,
209
270
  PreviewElementClickedResponseSchema,
210
271
  PreviewErrorResponseSchema,
211
272
  PreviewBlockRectResponseSchema,
@@ -2,6 +2,7 @@ import { describe, expect, it } from 'bun:test';
2
2
  import {
3
3
  assertSingleInitialDataScript,
4
4
  buildPlainInitialDataScript,
5
+ buildWrappedStorefrontInitialDataScript,
5
6
  countInitialDataScripts,
6
7
  findInitialDataPayload,
7
8
  injectPreviewInitialData,
@@ -70,4 +71,11 @@ describe('storefront-initial-data-html', () => {
70
71
  const stripped = stripAllInitialDataScripts(`${wrapped}${legacy}`);
71
72
  expect(stripped).not.toContain('__SHOPPEX_INITIAL__');
72
73
  });
74
+
75
+ it('marks wrapped initial data as a deployed theme artifact on friendly storefront paths', () => {
76
+ const script = buildWrappedStorefrontInitialDataScript('{"store":{"slug":"demo-shop"}}', /^\/themes-live\//);
77
+
78
+ expect(script).toContain('window.__SHOPPEX_DEPLOYED_THEME_ARTIFACT__=true');
79
+ expect(script).toContain('window.__SHOPPEX_INITIAL__={"store":{"slug":"demo-shop"}}');
80
+ });
73
81
  });
@@ -66,7 +66,7 @@ export function buildWrappedStorefrontInitialDataScript(
66
66
  ): string {
67
67
  return [
68
68
  '<!--shoppex-initial-data:start--><script>(function(){',
69
- 'if(typeof window!=="undefined"){var path=window.location.pathname||"";',
69
+ 'if(typeof window!=="undefined"){window.__SHOPPEX_DEPLOYED_THEME_ARTIFACT__=true;var path=window.location.pathname||"";',
70
70
  `if(${deployedThemeEntryPathPattern}.test(path)){window.__SHOPPEX_DEPLOYED_THEME_ARTIFACT_PATH__=path;window.history.replaceState(window.history.state,"","/"+window.location.search+window.location.hash);}}`,
71
71
  `window.__SHOPPEX_INITIAL__=${serialized};})();</script><!--shoppex-initial-data:end-->`,
72
72
  ].join('');
@@ -10,14 +10,33 @@ export const PUBLIC_BUILDER_THEME_SCHEMES = [
10
10
  'clean-minimal',
11
11
  ] as const;
12
12
 
13
+ export type PublicBuilderThemeScheme = (typeof PUBLIC_BUILDER_THEME_SCHEMES)[number];
14
+
13
15
  export const STARTER_BUILDER_THEME_SCHEMES = ['blank'] as const;
14
16
 
17
+ export const THEME_STORE_DISABLED_SCHEMES = [
18
+ 'vault',
19
+ 'nebula',
20
+ 'phantom',
21
+ 'clean-minimal',
22
+ ] as const satisfies readonly PublicBuilderThemeScheme[];
23
+
24
+ const THEME_STORE_DISABLED_SCHEME_SET = new Set<string>(THEME_STORE_DISABLED_SCHEMES);
25
+
26
+ export const THEME_STORE_INSTALLABLE_SCHEMES = [
27
+ 'default',
28
+ 'classic',
29
+ 'pulse',
30
+ 'starlight',
31
+ 'apex',
32
+ ] as const satisfies readonly PublicBuilderThemeScheme[];
33
+
15
34
  export const BUILDER_READY_THEME_SCHEMES = [
16
35
  ...STARTER_BUILDER_THEME_SCHEMES,
17
36
  ...PUBLIC_BUILDER_THEME_SCHEMES,
18
37
  ] as const;
19
38
 
20
- export type PublicBuilderThemeScheme = (typeof PUBLIC_BUILDER_THEME_SCHEMES)[number];
39
+ export type ThemeStoreInstallableScheme = (typeof THEME_STORE_INSTALLABLE_SCHEMES)[number];
21
40
  export type StarterBuilderThemeScheme = (typeof STARTER_BUILDER_THEME_SCHEMES)[number];
22
41
  export type BuilderReadyThemeScheme = (typeof BUILDER_READY_THEME_SCHEMES)[number];
23
42
 
@@ -25,6 +44,16 @@ export function isPublicBuilderThemeScheme(value: string): value is PublicBuilde
25
44
  return (PUBLIC_BUILDER_THEME_SCHEMES as readonly string[]).includes(value);
26
45
  }
27
46
 
47
+ export function isThemeStoreDisabledScheme(value: string): boolean {
48
+ return THEME_STORE_DISABLED_SCHEME_SET.has(value);
49
+ }
50
+
51
+ export function isThemeStoreInstallableScheme(
52
+ value: string,
53
+ ): value is ThemeStoreInstallableScheme {
54
+ return (THEME_STORE_INSTALLABLE_SCHEMES as readonly string[]).includes(value);
55
+ }
56
+
28
57
  export function isStarterBuilderThemeScheme(value: string): value is StarterBuilderThemeScheme {
29
58
  return (STARTER_BUILDER_THEME_SCHEMES as readonly string[]).includes(value);
30
59
  }