@shoppexio/builder-contracts 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/builder-settings.d.ts +2 -0
- package/dist/builder-settings.d.ts.map +1 -1
- package/dist/builder-settings.js +2 -1
- package/dist/custom-pages.d.ts +15 -0
- package/dist/custom-pages.d.ts.map +1 -0
- package/dist/custom-pages.js +40 -0
- package/dist/dedicated-pages.d.ts +15 -0
- package/dist/dedicated-pages.d.ts.map +1 -0
- package/dist/dedicated-pages.js +142 -0
- package/dist/fields.d.ts +64 -6
- package/dist/fields.d.ts.map +1 -1
- package/dist/fields.js +4 -4
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/legacy-manifest.d.ts +7 -0
- package/dist/legacy-manifest.d.ts.map +1 -1
- package/dist/legacy-manifest.js +31 -6
- package/dist/migrations.d.ts +1 -0
- package/dist/migrations.d.ts.map +1 -1
- package/dist/migrations.js +30 -2
- package/dist/persistence.d.ts +9 -0
- package/dist/persistence.d.ts.map +1 -1
- package/dist/persistence.js +80 -0
- package/dist/preview-boot.d.ts +2 -2
- package/dist/preview-boot.d.ts.map +1 -1
- package/dist/preview-boot.js +3 -1
- package/dist/preview-protocol.d.ts +88 -4
- package/dist/preview-protocol.d.ts.map +1 -1
- package/dist/preview-protocol.js +57 -7
- package/dist/preview-session-resolve.d.ts +2 -2
- package/dist/preview-session-resolve.d.ts.map +1 -1
- package/dist/preview-session-resolve.js +2 -2
- package/dist/preview-trusted-origins.d.ts.map +1 -1
- package/dist/preview-trusted-origins.js +10 -8
- package/dist/storefront-initial-data-html.js +1 -1
- package/dist/storefront-typography-fonts.d.ts +18 -0
- package/dist/storefront-typography-fonts.d.ts.map +1 -0
- package/dist/storefront-typography-fonts.js +89 -0
- package/dist/style-slots.d.ts +2 -2
- package/dist/style-slots.d.ts.map +1 -1
- package/dist/style-slots.js +5 -3
- package/dist/theme-manifest.d.ts +60 -4
- package/dist/theme-manifest.d.ts.map +1 -1
- package/dist/theme-schemes.d.ts +2 -2
- package/dist/theme-schemes.d.ts.map +1 -1
- package/dist/theme-schemes.js +2 -0
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +6 -4
- package/package.json +1 -1
- package/src/builder-contracts.test.ts +66 -0
- package/src/builder-settings.ts +4 -1
- package/src/custom-pages.test.ts +74 -0
- package/src/custom-pages.ts +70 -0
- package/src/dedicated-pages.test.ts +88 -0
- package/src/dedicated-pages.ts +173 -0
- package/src/fields.ts +4 -4
- package/src/index.ts +3 -0
- package/src/legacy-manifest.ts +40 -7
- package/src/migrations.ts +41 -2
- package/src/persistence.ts +107 -0
- package/src/preview-boot.test.ts +72 -0
- package/src/preview-boot.ts +3 -1
- package/src/preview-protocol.test.ts +90 -0
- package/src/preview-protocol.ts +67 -8
- package/src/preview-session-resolve.test.ts +37 -0
- package/src/preview-session-resolve.ts +2 -2
- package/src/storefront-initial-data-html.test.ts +18 -0
- package/src/storefront-initial-data-html.ts +1 -1
- package/src/storefront-typography-fonts.test.ts +48 -0
- package/src/storefront-typography-fonts.ts +108 -0
- package/src/style-slots.ts +6 -3
- package/src/theme-schemes.ts +2 -0
- package/src/validation.ts +6 -4
- package/dist/builder-contracts.test.d.ts +0 -2
- package/dist/builder-contracts.test.d.ts.map +0 -1
- package/dist/builder-contracts.test.js +0 -431
|
@@ -179,5 +179,12 @@ export declare const LegacyThemeManifestSchema: z.ZodObject<{
|
|
|
179
179
|
}, z.core.$loose>;
|
|
180
180
|
export type LegacyThemeManifest = z.infer<typeof LegacyThemeManifestSchema>;
|
|
181
181
|
export declare function convertLegacyThemeManifest(input: unknown): ThemeManifest;
|
|
182
|
+
export type ThemePageBlockOrderPage = {
|
|
183
|
+
allowedBlocks?: string[];
|
|
184
|
+
defaultBlocks?: Array<{
|
|
185
|
+
type?: string;
|
|
186
|
+
}>;
|
|
187
|
+
};
|
|
188
|
+
export declare function getThemePageBlockOrderFromManifest(manifest: unknown, pageId: string): string[];
|
|
182
189
|
export {};
|
|
183
190
|
//# sourceMappingURL=legacy-manifest.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"legacy-manifest.d.ts","sourceRoot":"","sources":["../src/legacy-manifest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"legacy-manifest.d.ts","sourceRoot":"","sources":["../src/legacy-manifest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAG5B,OAAO,EAAuB,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAU9E,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;iBAarB,CAAC;AACjB,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAE1E,eAAO,MAAM,uBAAuB;;;;;iBAOpB,CAAC;AACjB,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAExE,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;iBASrB,CAAC;AACjB,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAE1E,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;iBASpB,CAAC;AACjB,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAExE,QAAA,MAAM,uBAAuB;;;;;;;;;;;iBAgBb,CAAC;AACjB,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAExE,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAyBtB,CAAC;AACjB,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAE5E,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,OAAO,GAAG,aAAa,CAoFxE;AAuND,MAAM,MAAM,uBAAuB,GAAG;IACpC,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,aAAa,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC1C,CAAC;AAqBF,wBAAgB,kCAAkC,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAW9F"}
|
package/dist/legacy-manifest.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as z from 'zod/v4';
|
|
2
|
+
import { createDedicatedPageBlockType } from "./dedicated-pages.js";
|
|
2
3
|
import { BuilderFieldSchema } from "./fields.js";
|
|
3
4
|
import { ThemeManifestSchema } from "./theme-manifest.js";
|
|
4
5
|
import { StyleSlotDefaultsSchema } from "./style-slots.js";
|
|
@@ -111,7 +112,7 @@ export function convertLegacyThemeManifest(input) {
|
|
|
111
112
|
},
|
|
112
113
|
]));
|
|
113
114
|
for (const page of legacy.builder.pages) {
|
|
114
|
-
const syntheticBlockType =
|
|
115
|
+
const syntheticBlockType = createDedicatedPageBlockType(page.id);
|
|
115
116
|
if ((page.fields?.length ?? 0) === 0 && (page.lists?.length ?? 0) === 0) {
|
|
116
117
|
continue;
|
|
117
118
|
}
|
|
@@ -140,7 +141,7 @@ export function convertLegacyThemeManifest(input) {
|
|
|
140
141
|
tags: legacy.tags,
|
|
141
142
|
hotfixPaths: legacy.hotfixPaths,
|
|
142
143
|
pages: Object.fromEntries(legacy.builder.pages.map((page) => {
|
|
143
|
-
const syntheticBlockType =
|
|
144
|
+
const syntheticBlockType = createDedicatedPageBlockType(page.id);
|
|
144
145
|
const hasSyntheticBlock = blocks[syntheticBlockType] !== undefined;
|
|
145
146
|
const allowedBlocks = page.blocks.length > 0
|
|
146
147
|
? page.blocks
|
|
@@ -176,10 +177,6 @@ function normalizeLegacyThemeId(rawId) {
|
|
|
176
177
|
}
|
|
177
178
|
return `legacy-${lowered || 'theme'}`;
|
|
178
179
|
}
|
|
179
|
-
function createSyntheticPageBlockType(pageId) {
|
|
180
|
-
const normalizedPageId = pageId.toLowerCase().replace(/[^a-z0-9\-_.]+/g, '-').replace(/^[-_.]+/, '');
|
|
181
|
-
return `page-${normalizedPageId || 'custom'}`;
|
|
182
|
-
}
|
|
183
180
|
function convertLegacyThemePresets(presets) {
|
|
184
181
|
return Object.fromEntries(presets.map((preset) => {
|
|
185
182
|
const styleSlots = StyleSlotDefaultsSchema.parse(preset.overrides?.style_slots ?? preset.overrides?.styleSlots ?? {});
|
|
@@ -360,3 +357,31 @@ function createListItemShape(kind) {
|
|
|
360
357
|
body: { type: 'richtext', label: 'Body' },
|
|
361
358
|
};
|
|
362
359
|
}
|
|
360
|
+
function resolveManifestPagesForBlockOrder(manifest) {
|
|
361
|
+
const canonical = ThemeManifestSchema.safeParse(manifest);
|
|
362
|
+
if (canonical.success) {
|
|
363
|
+
return canonical.data.pages;
|
|
364
|
+
}
|
|
365
|
+
try {
|
|
366
|
+
return convertLegacyThemeManifest(manifest).pages;
|
|
367
|
+
}
|
|
368
|
+
catch {
|
|
369
|
+
if (typeof manifest === 'object' && manifest !== null && 'pages' in manifest) {
|
|
370
|
+
const pages = manifest.pages;
|
|
371
|
+
if (typeof pages === 'object' && pages !== null && !Array.isArray(pages)) {
|
|
372
|
+
return pages;
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
return {};
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
export function getThemePageBlockOrderFromManifest(manifest, pageId) {
|
|
379
|
+
const page = resolveManifestPagesForBlockOrder(manifest)[pageId];
|
|
380
|
+
if (!page) {
|
|
381
|
+
return [];
|
|
382
|
+
}
|
|
383
|
+
const defaultBlockTypes = (Array.isArray(page.defaultBlocks) ? page.defaultBlocks : [])
|
|
384
|
+
.map((block) => (typeof block === 'object' && block !== null ? block.type : undefined))
|
|
385
|
+
.filter((blockType) => typeof blockType === 'string' && blockType.length > 0);
|
|
386
|
+
return defaultBlockTypes.length > 0 ? defaultBlockTypes : page.allowedBlocks ?? [];
|
|
387
|
+
}
|
package/dist/migrations.d.ts
CHANGED
|
@@ -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
|
package/dist/migrations.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrations.d.ts","sourceRoot":"","sources":["../src/migrations.ts"],"names":[],"mappings":"
|
|
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,MAAM,0BAA0B,GAAG;IACvC,KAAK,CAAC,EAAE;QACN,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAClC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACjC,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC1C,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACvC,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,wBAAgB,0BAA0B,CAAC,QAAQ,SAAI,GAAG,eAAe,CAYxE;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE;IACzC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,eAAe,CAAC,EAAE,UAAU,CAAC;CAC9B,GAAG,aAAa,CAShB;AAED,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,aAAa,EAAE,GAAG,UAAU,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"}
|
package/dist/migrations.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { migrateDedicatedPageContent, migrateDedicatedPageLayout } from "./dedicated-pages.js";
|
|
1
2
|
import { BUILDER_SETTINGS_VERSION, BuilderSettingsSchema, } from "./builder-settings.js";
|
|
2
3
|
import { sanitizeBuilderSettingsState } from "./persistence.js";
|
|
3
4
|
export function createEmptyBuilderSettings(revision = 0) {
|
|
@@ -32,12 +33,14 @@ export function migrateLegacyBuilderSettings(input, revision = 0) {
|
|
|
32
33
|
...mapLegacyTokenOverridesToStyleSlots(tokensOverride),
|
|
33
34
|
...(input.theme?.style_slots ?? {}),
|
|
34
35
|
};
|
|
36
|
+
const rawContent = input.theme?.content ?? {};
|
|
37
|
+
const rawLayout = input.theme?.layout ?? {};
|
|
35
38
|
return sanitizeBuilderSettingsState(BuilderSettingsSchema.parse({
|
|
36
39
|
version: BUILDER_SETTINGS_VERSION,
|
|
37
40
|
revision,
|
|
38
41
|
theme: {
|
|
39
|
-
content:
|
|
40
|
-
layout: normalizeLegacyLayout(
|
|
42
|
+
content: migrateDedicatedPageContent(rawContent),
|
|
43
|
+
layout: migrateDedicatedPageLayout(normalizeLegacyLayout(rawLayout)),
|
|
41
44
|
style_slots: styleSlots,
|
|
42
45
|
pages: [],
|
|
43
46
|
terms: {},
|
|
@@ -66,6 +69,31 @@ export function applyManifestDefaultLayout(settings, manifest) {
|
|
|
66
69
|
}
|
|
67
70
|
return BuilderSettingsSchema.parse(next);
|
|
68
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
|
+
}
|
|
69
97
|
export function mapLegacyTokenOverridesToStyleSlots(tokens) {
|
|
70
98
|
const slots = {};
|
|
71
99
|
assignResponsiveNumber(tokens, slots, 'buttons.borderRadius', 'button.radius');
|
package/dist/persistence.d.ts
CHANGED
|
@@ -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;
|
|
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,CAaZ"}
|
package/dist/persistence.js
CHANGED
|
@@ -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({
|
package/dist/preview-boot.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export declare const StorefrontSeedSchema: z.ZodObject<{
|
|
|
5
5
|
products: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
|
|
6
6
|
groups: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
|
|
7
7
|
pages: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
|
|
8
|
-
}, z.core.$
|
|
8
|
+
}, z.core.$loose>;
|
|
9
9
|
export type StorefrontSeed = z.infer<typeof StorefrontSeedSchema>;
|
|
10
10
|
export declare const PreviewBootPayloadSchema: z.ZodObject<{
|
|
11
11
|
shopId: z.ZodString;
|
|
@@ -59,7 +59,7 @@ export declare const PreviewBootPayloadSchema: z.ZodObject<{
|
|
|
59
59
|
products: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
|
|
60
60
|
groups: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
|
|
61
61
|
pages: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
|
|
62
|
-
}, z.core.$
|
|
62
|
+
}, z.core.$loose>;
|
|
63
63
|
artifactRevision: z.ZodOptional<z.ZodString>;
|
|
64
64
|
artifactStale: z.ZodOptional<z.ZodBoolean>;
|
|
65
65
|
}, z.core.$strict>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preview-boot.d.ts","sourceRoot":"","sources":["../src/preview-boot.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAG5B,eAAO,MAAM,yBAAyB,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"preview-boot.d.ts","sourceRoot":"","sources":["../src/preview-boot.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAG5B,eAAO,MAAM,yBAAyB,gCAAgC,CAAC;AAIvE,eAAO,MAAM,oBAAoB;;;;;iBAOjB,CAAC;AAEjB,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAS1B,CAAC;AAEZ,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAE1E,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,kBAAkB,GAC1B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAWzB"}
|
package/dist/preview-boot.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import * as z from 'zod/v4';
|
|
2
2
|
import { BuilderSettingsSchema } from "./builder-settings.js";
|
|
3
3
|
export const PREVIEW_BOOT_SIDECAR_PATH = '__shoppex/preview-boot.json';
|
|
4
|
+
// Artifact HTML seeds include catalog/menu fields beyond the documented minimum.
|
|
5
|
+
// Passthrough keeps them available to the theme runtime in preview boot.
|
|
4
6
|
export const StorefrontSeedSchema = z
|
|
5
7
|
.object({
|
|
6
8
|
store: z.record(z.string(), z.unknown()),
|
|
@@ -8,7 +10,7 @@ export const StorefrontSeedSchema = z
|
|
|
8
10
|
groups: z.array(z.unknown()).optional(),
|
|
9
11
|
pages: z.array(z.unknown()).optional(),
|
|
10
12
|
})
|
|
11
|
-
.
|
|
13
|
+
.passthrough();
|
|
12
14
|
export const PreviewBootPayloadSchema = z
|
|
13
15
|
.object({
|
|
14
16
|
shopId: z.string().min(1),
|
|
@@ -66,6 +66,24 @@ 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
|
+
blocks: z.ZodArray<z.ZodObject<{
|
|
83
|
+
blockId: z.ZodString;
|
|
84
|
+
html: z.ZodString;
|
|
85
|
+
}, z.core.$strict>>;
|
|
86
|
+
}, z.core.$strict>;
|
|
69
87
|
export declare const PreviewReloadMessageSchema: z.ZodObject<{
|
|
70
88
|
type: z.ZodLiteral<"RELOAD">;
|
|
71
89
|
revision: z.ZodNumber;
|
|
@@ -164,6 +182,16 @@ export declare const PreviewMessageSchema: z.ZodDiscriminatedUnion<[z.ZodObject<
|
|
|
164
182
|
}, z.core.$strict>>;
|
|
165
183
|
}, z.core.$strict>;
|
|
166
184
|
}, z.core.$strict>;
|
|
185
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
186
|
+
type: z.ZodLiteral<"APPLY_BLOCK_HTML">;
|
|
187
|
+
revision: z.ZodNumber;
|
|
188
|
+
pageId: z.ZodString;
|
|
189
|
+
sourceRevision: z.ZodString;
|
|
190
|
+
renderMode: z.ZodLiteral<"edge-block-engine">;
|
|
191
|
+
blocks: z.ZodArray<z.ZodObject<{
|
|
192
|
+
blockId: z.ZodString;
|
|
193
|
+
html: z.ZodString;
|
|
194
|
+
}, z.core.$strict>>;
|
|
167
195
|
}, z.core.$strict>, z.ZodObject<{
|
|
168
196
|
type: z.ZodLiteral<"RELOAD">;
|
|
169
197
|
revision: z.ZodNumber;
|
|
@@ -209,14 +237,28 @@ export declare const PreviewBootstrapOkResponseSchema: z.ZodObject<{
|
|
|
209
237
|
shopId: z.ZodString;
|
|
210
238
|
artifactStale: z.ZodOptional<z.ZodBoolean>;
|
|
211
239
|
}, z.core.$strict>;
|
|
240
|
+
export declare const PreviewReadyHealthSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
241
|
+
reactMounted: z.ZodLiteral<true>;
|
|
242
|
+
builderRuntimeProvider: z.ZodLiteral<true>;
|
|
243
|
+
protocolVersion: z.ZodLiteral<2>;
|
|
244
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
245
|
+
edgeBlockEngine: z.ZodLiteral<true>;
|
|
246
|
+
blockHtmlReconcile: z.ZodLiteral<true>;
|
|
247
|
+
protocolVersion: z.ZodLiteral<3>;
|
|
248
|
+
}, z.core.$strict>], "protocolVersion">;
|
|
249
|
+
export type PreviewReadyHealth = z.infer<typeof PreviewReadyHealthSchema>;
|
|
212
250
|
export declare const PreviewReadyResponseSchema: z.ZodObject<{
|
|
213
251
|
type: z.ZodLiteral<"READY">;
|
|
214
252
|
revision: z.ZodNumber;
|
|
215
|
-
health: z.ZodOptional<z.ZodObject<{
|
|
253
|
+
health: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
216
254
|
reactMounted: z.ZodLiteral<true>;
|
|
217
255
|
builderRuntimeProvider: z.ZodLiteral<true>;
|
|
218
256
|
protocolVersion: z.ZodLiteral<2>;
|
|
219
|
-
}, z.core.$strict
|
|
257
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
258
|
+
edgeBlockEngine: z.ZodLiteral<true>;
|
|
259
|
+
blockHtmlReconcile: z.ZodLiteral<true>;
|
|
260
|
+
protocolVersion: z.ZodLiteral<3>;
|
|
261
|
+
}, z.core.$strict>], "protocolVersion">>;
|
|
220
262
|
}, z.core.$strict>;
|
|
221
263
|
export declare const PreviewAppliedResponseSchema: z.ZodObject<{
|
|
222
264
|
type: z.ZodLiteral<"APPLIED">;
|
|
@@ -227,6 +269,26 @@ export declare const PreviewApplyFailedResponseSchema: z.ZodObject<{
|
|
|
227
269
|
revision: z.ZodNumber;
|
|
228
270
|
error: z.ZodString;
|
|
229
271
|
}, z.core.$strict>;
|
|
272
|
+
export declare const PreviewBlockHtmlAppliedResponseSchema: z.ZodObject<{
|
|
273
|
+
type: z.ZodLiteral<"BLOCK_HTML_APPLIED">;
|
|
274
|
+
revision: z.ZodNumber;
|
|
275
|
+
pageId: z.ZodString;
|
|
276
|
+
sourceRevision: z.ZodString;
|
|
277
|
+
renderMode: z.ZodLiteral<"edge-block-engine">;
|
|
278
|
+
blocks: z.ZodArray<z.ZodObject<{
|
|
279
|
+
blockId: z.ZodString;
|
|
280
|
+
html: z.ZodString;
|
|
281
|
+
}, z.core.$strict>>;
|
|
282
|
+
}, z.core.$strict>;
|
|
283
|
+
export declare const PreviewBlockHtmlFailedResponseSchema: z.ZodObject<{
|
|
284
|
+
type: z.ZodLiteral<"BLOCK_HTML_FAILED">;
|
|
285
|
+
revision: z.ZodNumber;
|
|
286
|
+
pageId: z.ZodString;
|
|
287
|
+
sourceRevision: z.ZodOptional<z.ZodString>;
|
|
288
|
+
renderMode: z.ZodLiteral<"edge-block-engine">;
|
|
289
|
+
blockIds: z.ZodArray<z.ZodString>;
|
|
290
|
+
error: z.ZodString;
|
|
291
|
+
}, z.core.$strict>;
|
|
230
292
|
export declare const PreviewElementClickedResponseSchema: z.ZodObject<{
|
|
231
293
|
type: z.ZodLiteral<"ELEMENT_CLICKED">;
|
|
232
294
|
revision: z.ZodOptional<z.ZodNumber>;
|
|
@@ -351,11 +413,15 @@ export declare const PreviewResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject
|
|
|
351
413
|
}, z.core.$strict>, z.ZodObject<{
|
|
352
414
|
type: z.ZodLiteral<"READY">;
|
|
353
415
|
revision: z.ZodNumber;
|
|
354
|
-
health: z.ZodOptional<z.ZodObject<{
|
|
416
|
+
health: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
355
417
|
reactMounted: z.ZodLiteral<true>;
|
|
356
418
|
builderRuntimeProvider: z.ZodLiteral<true>;
|
|
357
419
|
protocolVersion: z.ZodLiteral<2>;
|
|
358
|
-
}, z.core.$strict
|
|
420
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
421
|
+
edgeBlockEngine: z.ZodLiteral<true>;
|
|
422
|
+
blockHtmlReconcile: z.ZodLiteral<true>;
|
|
423
|
+
protocolVersion: z.ZodLiteral<3>;
|
|
424
|
+
}, z.core.$strict>], "protocolVersion">>;
|
|
359
425
|
}, z.core.$strict>, z.ZodObject<{
|
|
360
426
|
type: z.ZodLiteral<"APPLIED">;
|
|
361
427
|
revision: z.ZodNumber;
|
|
@@ -363,6 +429,24 @@ export declare const PreviewResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject
|
|
|
363
429
|
type: z.ZodLiteral<"APPLY_FAILED">;
|
|
364
430
|
revision: z.ZodNumber;
|
|
365
431
|
error: z.ZodString;
|
|
432
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
433
|
+
type: z.ZodLiteral<"BLOCK_HTML_APPLIED">;
|
|
434
|
+
revision: z.ZodNumber;
|
|
435
|
+
pageId: z.ZodString;
|
|
436
|
+
sourceRevision: z.ZodString;
|
|
437
|
+
renderMode: z.ZodLiteral<"edge-block-engine">;
|
|
438
|
+
blocks: z.ZodArray<z.ZodObject<{
|
|
439
|
+
blockId: z.ZodString;
|
|
440
|
+
html: z.ZodString;
|
|
441
|
+
}, z.core.$strict>>;
|
|
442
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
443
|
+
type: z.ZodLiteral<"BLOCK_HTML_FAILED">;
|
|
444
|
+
revision: z.ZodNumber;
|
|
445
|
+
pageId: z.ZodString;
|
|
446
|
+
sourceRevision: z.ZodOptional<z.ZodString>;
|
|
447
|
+
renderMode: z.ZodLiteral<"edge-block-engine">;
|
|
448
|
+
blockIds: z.ZodArray<z.ZodString>;
|
|
449
|
+
error: z.ZodString;
|
|
366
450
|
}, z.core.$strict>, z.ZodObject<{
|
|
367
451
|
type: z.ZodLiteral<"ELEMENT_CLICKED">;
|
|
368
452
|
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
|
|
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,yBAAyB,mCAAiC,CAAC;AACxE,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAE5E,eAAO,MAAM,2BAA2B;;;kBAK7B,CAAC;AACZ,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAEhF,eAAO,MAAM,kCAAkC;;;;;;;;;;kBASpC,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4BAO/B,CAAC;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE,eAAO,MAAM,gCAAgC;;;;;;kBAQlC,CAAC;AAEZ,eAAO,MAAM,wBAAwB;;;;;;;;uCAenC,CAAC;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAE1E,eAAO,MAAM,0BAA0B;;;;;;;;;;;;kBAM5B,CAAC;AAEZ,eAAO,MAAM,4BAA4B;;;kBAK9B,CAAC;AAEZ,eAAO,MAAM,gCAAgC;;;;kBAMlC,CAAC;AAEZ,eAAO,MAAM,qCAAqC;;;;;;;;;;kBASvC,CAAC;AAEZ,eAAO,MAAM,oCAAoC;;;;;;;;kBAUtC,CAAC;AAEZ,eAAO,MAAM,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"}
|
package/dist/preview-protocol.js
CHANGED
|
@@ -20,6 +20,23 @@ 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
|
+
blocks: z.array(PreviewBlockHtmlPatchSchema).min(1),
|
|
38
|
+
})
|
|
39
|
+
.strict();
|
|
23
40
|
export const PreviewReloadMessageSchema = z
|
|
24
41
|
.object({
|
|
25
42
|
type: z.literal('RELOAD'),
|
|
@@ -54,6 +71,7 @@ export const PreviewSetInteractionModeMessageSchema = z
|
|
|
54
71
|
.strict();
|
|
55
72
|
export const PreviewMessageSchema = z.discriminatedUnion('type', [
|
|
56
73
|
PreviewApplyStateMessageSchema,
|
|
74
|
+
PreviewApplyBlockHtmlMessageSchema,
|
|
57
75
|
PreviewReloadMessageSchema,
|
|
58
76
|
PreviewSelectElementMessageSchema,
|
|
59
77
|
PreviewRequestReadyMessageSchema,
|
|
@@ -68,18 +86,27 @@ export const PreviewBootstrapOkResponseSchema = z
|
|
|
68
86
|
artifactStale: z.boolean().optional(),
|
|
69
87
|
})
|
|
70
88
|
.strict();
|
|
71
|
-
export const
|
|
72
|
-
|
|
73
|
-
type: z.literal('READY'),
|
|
74
|
-
revision: z.number().int().nonnegative(),
|
|
75
|
-
health: z
|
|
89
|
+
export const PreviewReadyHealthSchema = z.discriminatedUnion('protocolVersion', [
|
|
90
|
+
z
|
|
76
91
|
.object({
|
|
77
92
|
reactMounted: z.literal(true),
|
|
78
93
|
builderRuntimeProvider: z.literal(true),
|
|
79
94
|
protocolVersion: z.literal(2),
|
|
80
95
|
})
|
|
81
|
-
.strict()
|
|
82
|
-
|
|
96
|
+
.strict(),
|
|
97
|
+
z
|
|
98
|
+
.object({
|
|
99
|
+
edgeBlockEngine: z.literal(true),
|
|
100
|
+
blockHtmlReconcile: z.literal(true),
|
|
101
|
+
protocolVersion: z.literal(3),
|
|
102
|
+
})
|
|
103
|
+
.strict(),
|
|
104
|
+
]);
|
|
105
|
+
export const PreviewReadyResponseSchema = z
|
|
106
|
+
.object({
|
|
107
|
+
type: z.literal('READY'),
|
|
108
|
+
revision: z.number().int().nonnegative(),
|
|
109
|
+
health: PreviewReadyHealthSchema.optional(),
|
|
83
110
|
})
|
|
84
111
|
.strict();
|
|
85
112
|
export const PreviewAppliedResponseSchema = z
|
|
@@ -95,6 +122,27 @@ export const PreviewApplyFailedResponseSchema = z
|
|
|
95
122
|
error: z.string().min(1),
|
|
96
123
|
})
|
|
97
124
|
.strict();
|
|
125
|
+
export const PreviewBlockHtmlAppliedResponseSchema = z
|
|
126
|
+
.object({
|
|
127
|
+
type: z.literal('BLOCK_HTML_APPLIED'),
|
|
128
|
+
revision: z.number().int().nonnegative(),
|
|
129
|
+
pageId: z.string().min(1),
|
|
130
|
+
sourceRevision: z.string().min(1),
|
|
131
|
+
renderMode: EdgeBlockRenderModeSchema,
|
|
132
|
+
blocks: z.array(PreviewBlockHtmlPatchSchema).min(1),
|
|
133
|
+
})
|
|
134
|
+
.strict();
|
|
135
|
+
export const PreviewBlockHtmlFailedResponseSchema = z
|
|
136
|
+
.object({
|
|
137
|
+
type: z.literal('BLOCK_HTML_FAILED'),
|
|
138
|
+
revision: z.number().int().nonnegative(),
|
|
139
|
+
pageId: z.string().min(1),
|
|
140
|
+
sourceRevision: z.string().min(1).optional(),
|
|
141
|
+
renderMode: EdgeBlockRenderModeSchema,
|
|
142
|
+
blockIds: z.array(z.string().min(1)).min(1),
|
|
143
|
+
error: z.string().min(1),
|
|
144
|
+
})
|
|
145
|
+
.strict();
|
|
98
146
|
export const PreviewElementClickedResponseSchema = z
|
|
99
147
|
.object({
|
|
100
148
|
type: z.literal('ELEMENT_CLICKED'),
|
|
@@ -183,6 +231,8 @@ export const PreviewResponseSchema = z.discriminatedUnion('type', [
|
|
|
183
231
|
PreviewReadyResponseSchema,
|
|
184
232
|
PreviewAppliedResponseSchema,
|
|
185
233
|
PreviewApplyFailedResponseSchema,
|
|
234
|
+
PreviewBlockHtmlAppliedResponseSchema,
|
|
235
|
+
PreviewBlockHtmlFailedResponseSchema,
|
|
186
236
|
PreviewElementClickedResponseSchema,
|
|
187
237
|
PreviewErrorResponseSchema,
|
|
188
238
|
PreviewBlockRectResponseSchema,
|
|
@@ -108,8 +108,8 @@ export declare const BuilderPreviewResolveResponseSchema: z.ZodObject<{
|
|
|
108
108
|
artifactStale: z.ZodOptional<z.ZodBoolean>;
|
|
109
109
|
sourceRevision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
110
110
|
}, z.core.$strict>>;
|
|
111
|
-
error: z.ZodNullable<z.ZodString
|
|
112
|
-
}, z.core.$
|
|
111
|
+
error: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
112
|
+
}, z.core.$strip>;
|
|
113
113
|
export type BuilderPreviewResolveResponse = z.infer<typeof BuilderPreviewResolveResponseSchema>;
|
|
114
114
|
export declare function parseBuilderPreviewResolveResponse(value: unknown): BuilderPreviewResolveResponse | null;
|
|
115
115
|
//# sourceMappingURL=preview-session-resolve.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preview-session-resolve.d.ts","sourceRoot":"","sources":["../src/preview-session-resolve.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAG5B,eAAO,MAAM,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAWjC,CAAC;AAEZ,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,+BAA+B,CAAC,CAAC;AAExF,eAAO,MAAM,mCAAmC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"preview-session-resolve.d.ts","sourceRoot":"","sources":["../src/preview-session-resolve.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAG5B,eAAO,MAAM,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAWjC,CAAC;AAEZ,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,+BAA+B,CAAC,CAAC;AAExF,eAAO,MAAM,mCAAmC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAMtC,CAAC;AAEX,MAAM,MAAM,6BAA6B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mCAAmC,CAAC,CAAC;AAEhG,wBAAgB,kCAAkC,CAChD,KAAK,EAAE,OAAO,GACb,6BAA6B,GAAG,IAAI,CAGtC"}
|
|
@@ -16,9 +16,9 @@ export const BuilderPreviewResolveResponseSchema = z
|
|
|
16
16
|
.object({
|
|
17
17
|
status: z.number(),
|
|
18
18
|
data: BuilderPreviewResolveDataSchema.nullable(),
|
|
19
|
-
error: z.string().nullable(),
|
|
19
|
+
error: z.string().nullable().optional(),
|
|
20
20
|
})
|
|
21
|
-
.
|
|
21
|
+
.strip();
|
|
22
22
|
export function parseBuilderPreviewResolveResponse(value) {
|
|
23
23
|
const parsed = BuilderPreviewResolveResponseSchema.safeParse(value);
|
|
24
24
|
return parsed.success ? parsed.data : null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preview-trusted-origins.d.ts","sourceRoot":"","sources":["../src/preview-trusted-origins.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,8BAA8B,iMAOjC,CAAC;AAEX,MAAM,MAAM,0BAA0B,GAAG,CAAC,OAAO,8BAA8B,CAAC,CAAC,MAAM,CAAC,CAAC;AAEzF,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,
|
|
1
|
+
{"version":3,"file":"preview-trusted-origins.d.ts","sourceRoot":"","sources":["../src/preview-trusted-origins.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,8BAA8B,iMAOjC,CAAC;AAEX,MAAM,MAAM,0BAA0B,GAAG,CAAC,OAAO,8BAA8B,CAAC,CAAC,MAAM,CAAC,CAAC;AAEzF,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAuBpE"}
|
|
@@ -11,14 +11,16 @@ export function isTrustedPreviewParentOrigin(origin) {
|
|
|
11
11
|
return true;
|
|
12
12
|
}
|
|
13
13
|
try {
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
14
|
+
const url = new URL(origin);
|
|
15
|
+
const hostname = url.hostname.toLowerCase();
|
|
16
|
+
const isHttp = url.protocol === 'http:' || url.protocol === 'https:';
|
|
17
|
+
return (isHttp
|
|
18
|
+
&& (hostname === 'dashboard.shoppex.test'
|
|
19
|
+
|| hostname === 'localhost'
|
|
20
|
+
|| hostname === '127.0.0.1'
|
|
21
|
+
|| hostname === '::1'
|
|
22
|
+
|| hostname === '[::1]'
|
|
23
|
+
|| hostname.endsWith('.localhost')));
|
|
22
24
|
}
|
|
23
25
|
catch {
|
|
24
26
|
return false;
|
|
@@ -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('');
|