@shoppexio/builder-contracts 0.1.0 → 0.1.1
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-contracts.test.js +71 -1
- package/dist/builder-settings.d.ts +9 -666
- package/dist/builder-settings.d.ts.map +1 -1
- package/dist/canonical-settings.d.ts +18 -0
- package/dist/canonical-settings.d.ts.map +1 -0
- package/dist/canonical-settings.js +106 -0
- package/dist/events.d.ts +35 -240
- package/dist/events.d.ts.map +1 -1
- package/dist/events.js +7 -0
- package/dist/fields.d.ts +169 -8
- package/dist/fields.d.ts.map +1 -1
- package/dist/fields.js +27 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -0
- package/dist/legacy-manifest.d.ts +11 -0
- package/dist/legacy-manifest.d.ts.map +1 -1
- package/dist/legacy-manifest.js +106 -16
- package/dist/migrations.d.ts.map +1 -1
- package/dist/migrations.js +50 -4
- package/dist/persistence.d.ts +7 -0
- package/dist/persistence.d.ts.map +1 -0
- package/dist/persistence.js +58 -0
- package/dist/preview-boot.d.ts +68 -0
- package/dist/preview-boot.d.ts.map +1 -0
- package/dist/preview-boot.js +36 -0
- package/dist/preview-protocol.d.ts +227 -459
- package/dist/preview-protocol.d.ts.map +1 -1
- package/dist/preview-protocol.js +112 -0
- package/dist/preview-session-resolve.d.ts +115 -0
- package/dist/preview-session-resolve.d.ts.map +1 -0
- package/dist/preview-session-resolve.js +25 -0
- package/dist/preview-trusted-origins.d.ts +4 -0
- package/dist/preview-trusted-origins.d.ts.map +1 -0
- package/dist/preview-trusted-origins.js +26 -0
- package/dist/storefront-initial-data-html.d.ts +17 -0
- package/dist/storefront-initial-data-html.d.ts.map +1 -0
- package/dist/storefront-initial-data-html.js +83 -0
- package/dist/style-slots.d.ts +49 -151
- package/dist/style-slots.d.ts.map +1 -1
- package/dist/style-slots.js +75 -29
- package/dist/theme-manifest.d.ts +229 -454
- package/dist/theme-manifest.d.ts.map +1 -1
- package/dist/theme-manifest.js +92 -0
- package/dist/theme-schemes.d.ts +10 -0
- package/dist/theme-schemes.d.ts.map +1 -0
- package/dist/theme-schemes.js +24 -0
- package/dist/validation.d.ts +1 -1
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +18 -9
- package/package.json +43 -1
- package/src/builder-contracts.test.ts +398 -3
- package/src/canonical-settings.ts +156 -0
- package/src/events.ts +8 -0
- package/src/fields.ts +30 -0
- package/src/index.ts +7 -0
- package/src/legacy-manifest.ts +107 -16
- package/src/migrations.ts +65 -4
- package/src/persistence.ts +77 -0
- package/src/preview-boot.ts +47 -0
- package/src/preview-protocol.test.ts +132 -0
- package/src/preview-protocol.ts +122 -0
- package/src/preview-session-resolve.ts +34 -0
- package/src/preview-trusted-origins.test.ts +24 -0
- package/src/preview-trusted-origins.ts +35 -0
- package/src/storefront-initial-data-html.test.ts +63 -0
- package/src/storefront-initial-data-html.ts +112 -0
- package/src/style-slots.ts +96 -31
- package/src/theme-manifest.ts +118 -1
- package/src/theme-schemes.ts +33 -0
- package/src/validation.ts +27 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"style-slots.d.ts","sourceRoot":"","sources":["../src/style-slots.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAE5B,eAAO,MAAM,gBAAgB;;;;;;EAA2C,CAAC;AACzE,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE1D,eAAO,MAAM,sBAAsB;;;;;;kBAQxB,CAAC;AACZ,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAEtE,eAAO,MAAM,sBAAsB;;;;;;kBAQxB,CAAC;AACZ,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAEtE,eAAO,MAA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E,CAAC;AAEjD,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;iBAA2D,CAAC;AAC1F,MAAM,MAAM,WAAW,GAAG,eAAe,GAAG,gBAAgB,CAAC;AAE7D,eAAO,MAAM,mBAAmB,8dAAgC,CAAC;AAEjE,eAAO,MAAM,yBAAyB;;;;;;;;;;;;8PAQpC,CAAC;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAE5E,MAAM,MAAM,cAAc,GACtB,KAAK,GACL,gBAAgB,GAChB,gBAAgB,GAChB,UAAU,GACV,MAAM,GACN,MAAM,GACN,OAAO,CAAC;AA6BZ,MAAM,MAAM,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC,CAAC;AAEtE,eAAO,MAAM,gBAAgB,EAoCrB,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;AAE9B,eAAO,MAAM,uBAAuB,mJAAmB,CAAC;AACxD,MAAM,MAAM,iBAAiB,GAAG,UAAU,CAAC;AAE3C,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,UAAU,CAE1D"}
|
package/dist/style-slots.js
CHANGED
|
@@ -32,7 +32,7 @@ export const FontWeightSchema = z.union([
|
|
|
32
32
|
z.literal(800),
|
|
33
33
|
z.literal(900),
|
|
34
34
|
]);
|
|
35
|
-
export const
|
|
35
|
+
export const CoreStyleSlotIdSchema = z.enum([
|
|
36
36
|
'button.radius',
|
|
37
37
|
'button.background',
|
|
38
38
|
'button.foreground',
|
|
@@ -58,35 +58,81 @@ export const StyleSlotIdSchema = z.enum([
|
|
|
58
58
|
'typography.heading.weight',
|
|
59
59
|
'typography.body.size',
|
|
60
60
|
]);
|
|
61
|
-
export const
|
|
61
|
+
export const ThemeStyleSlotIdSchema = z
|
|
62
|
+
.string()
|
|
63
|
+
.regex(/^theme\.[a-z0-9][a-z0-9._-]*$/, 'Expected a theme-scoped style slot id');
|
|
64
|
+
export const StyleSlotIdSchema = z.union([CoreStyleSlotIdSchema, ThemeStyleSlotIdSchema]);
|
|
65
|
+
export const CORE_STYLE_SLOT_IDS = CoreStyleSlotIdSchema.options;
|
|
66
|
+
export const ThemeStyleSlotValueSchema = z.union([
|
|
67
|
+
ColorSchema,
|
|
68
|
+
ResponsiveNumberSchema,
|
|
69
|
+
ResponsiveStringSchema,
|
|
70
|
+
FontWeightSchema,
|
|
71
|
+
z.string().min(1),
|
|
72
|
+
z.number().finite(),
|
|
73
|
+
z.boolean(),
|
|
74
|
+
]);
|
|
75
|
+
const CORE_STYLE_SLOT_SCHEMAS = {
|
|
76
|
+
'button.radius': ResponsiveNumberSchema,
|
|
77
|
+
'button.background': ColorSchema,
|
|
78
|
+
'button.foreground': ColorSchema,
|
|
79
|
+
'button.border': ColorSchema,
|
|
80
|
+
'button.font.weight': FontWeightSchema,
|
|
81
|
+
'input.radius': ResponsiveNumberSchema,
|
|
82
|
+
'input.height': ResponsiveNumberSchema,
|
|
83
|
+
'input.border': ColorSchema,
|
|
84
|
+
'input.background': ColorSchema,
|
|
85
|
+
'input.foreground': ColorSchema,
|
|
86
|
+
'card.radius': ResponsiveNumberSchema,
|
|
87
|
+
'card.background': ColorSchema,
|
|
88
|
+
'card.border': ColorSchema,
|
|
89
|
+
'section.padding.y': ResponsiveNumberSchema,
|
|
90
|
+
'section.padding.x': ResponsiveNumberSchema,
|
|
91
|
+
'container.width': ResponsiveNumberSchema,
|
|
92
|
+
'color.primary': ColorSchema,
|
|
93
|
+
'color.accent': ColorSchema,
|
|
94
|
+
'color.background': ColorSchema,
|
|
95
|
+
'color.foreground': ColorSchema,
|
|
96
|
+
'color.muted': ColorSchema,
|
|
97
|
+
'link.color': ColorSchema,
|
|
98
|
+
'typography.heading.weight': FontWeightSchema,
|
|
99
|
+
'typography.body.size': ResponsiveNumberSchema,
|
|
100
|
+
};
|
|
62
101
|
export const StyleSlotsSchema = z
|
|
63
|
-
.
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
102
|
+
.record(z.string().min(1), z.unknown())
|
|
103
|
+
.superRefine((slots, ctx) => {
|
|
104
|
+
for (const [slotId, value] of Object.entries(slots)) {
|
|
105
|
+
const coreSlotId = CoreStyleSlotIdSchema.safeParse(slotId);
|
|
106
|
+
if (coreSlotId.success) {
|
|
107
|
+
const parsedValue = CORE_STYLE_SLOT_SCHEMAS[coreSlotId.data].safeParse(value);
|
|
108
|
+
if (!parsedValue.success) {
|
|
109
|
+
ctx.addIssue({
|
|
110
|
+
code: 'custom',
|
|
111
|
+
path: [slotId],
|
|
112
|
+
message: `Invalid value for core style slot "${slotId}"`,
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
const themeSlotId = ThemeStyleSlotIdSchema.safeParse(slotId);
|
|
118
|
+
if (!themeSlotId.success) {
|
|
119
|
+
ctx.addIssue({
|
|
120
|
+
code: 'custom',
|
|
121
|
+
path: [slotId],
|
|
122
|
+
message: `Unknown style slot "${slotId}"`,
|
|
123
|
+
});
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
const parsedThemeValue = ThemeStyleSlotValueSchema.safeParse(value);
|
|
127
|
+
if (!parsedThemeValue.success) {
|
|
128
|
+
ctx.addIssue({
|
|
129
|
+
code: 'custom',
|
|
130
|
+
path: [slotId],
|
|
131
|
+
message: `Invalid value for theme style slot "${slotId}"`,
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
});
|
|
90
136
|
export const StyleSlotDefaultsSchema = StyleSlotsSchema;
|
|
91
137
|
export function parseStyleSlots(input) {
|
|
92
138
|
return StyleSlotsSchema.parse(input);
|