@growth-labs/store 0.3.3 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -0
- package/README.md +8 -0
- package/dist/availability.d.ts +3 -13
- package/dist/availability.d.ts.map +1 -1
- package/dist/client.d.ts +59 -123
- package/dist/client.d.ts.map +1 -1
- package/dist/image.d.ts +5 -6
- package/dist/image.d.ts.map +1 -1
- package/dist/image.js +12 -8
- package/dist/image.js.map +1 -1
- package/dist/options.d.ts +34 -240
- package/dist/options.d.ts.map +1 -1
- package/dist/options.js +5 -5
- package/dist/options.js.map +1 -1
- package/dist/types.d.ts +88 -4858
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -1
- package/dist/types.js.map +1 -1
- package/dist/variant.js +1 -1
- package/dist/variant.js.map +1 -1
- package/package.json +2 -2
- package/src/components/CartDrawer.astro +1 -1
- package/src/components/CollectionCard.astro +1 -1
- package/src/components/ProductCard.astro +1 -1
- package/src/components/StoreCartPage.astro +3 -2
- package/src/image.ts +15 -9
- package/src/options.ts +5 -5
- package/src/types.ts +1 -1
- package/src/variant.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.4.0 — 2026-10-24
|
|
4
|
+
|
|
5
|
+
### Changed
|
|
6
|
+
|
|
7
|
+
- Move validation from zod 3 to zod 4. zod 3.25.76 is the last 3.x release and grype flags it High (GHSA-mrhx-c7xc-m3w5: validating oversized constrained collections can exhaust memory); the only fixed release is zod 4.6.6, so this package now depends on `zod` `^4.6.7`.
|
|
8
|
+
- Option validation behaves as before: `routes`, `imageTransform`, `telemetry` and `legal` still fill their nested defaults when omitted (`.prefault({})`). Fourthwall variant ids are still matched as 8-4-4-4-12 hex groups (`z.guid()`), not as strict RFC 4122 UUIDs, and the Fourthwall webhook and storefront payload schemas still pass unknown fields through. Only the text of validation error messages follows zod 4, and zod 4's `z.number()` now rejects `Infinity` and `.int()` rejects integers outside the safe range.
|
|
9
|
+
- `storeOptionsSchema` and the other exported schemas are zod 4 schemas; a consumer that extends them must import `zod` `^4.6.7`.
|
|
10
|
+
|
|
11
|
+
## 0.3.6
|
|
12
|
+
|
|
13
|
+
- Release responsive Fourthwall images from the corrected consumer gate, which
|
|
14
|
+
runs whole-workspace installs and suites on the heavy runner class.
|
|
15
|
+
|
|
16
|
+
## 0.3.5
|
|
17
|
+
|
|
18
|
+
- Release the responsive Fourthwall image defaults with consumer validation
|
|
19
|
+
that preserves the shared policy of separate compiler contexts.
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## 0.3.4
|
|
23
|
+
|
|
24
|
+
- Enable Cloudflare image transformations by default, including Fourthwall's
|
|
25
|
+
imgproxy host, so responsive candidates deliver their requested widths and
|
|
26
|
+
negotiate AVIF/WebP. Keep an explicit opt-out for preview hosts.
|
|
27
|
+
|
|
3
28
|
## 0.3.3
|
|
4
29
|
|
|
5
30
|
- Restore the product-detail related-products shelf using each site's curated
|
package/README.md
CHANGED
|
@@ -53,3 +53,11 @@ export const prerender = false
|
|
|
53
53
|
<StoreIndexPage />
|
|
54
54
|
</Base>
|
|
55
55
|
```
|
|
56
|
+
|
|
57
|
+
## Image transforms
|
|
58
|
+
|
|
59
|
+
Fourthwall images use Cloudflare Image Transformations by default, including
|
|
60
|
+
`imgproxy.fourthwall.dev` images. The custom-domain zone must allow the
|
|
61
|
+
Fourthwall image origins. Responsive candidates request their declared widths
|
|
62
|
+
with `format=auto` for browser format negotiation. Set
|
|
63
|
+
`imageTransform: { enabled: false }` for local or workers.dev previews.
|
package/dist/availability.d.ts
CHANGED
|
@@ -1,20 +1,10 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
export declare const FourthwallStockSchema: z.ZodDiscriminatedUnion<
|
|
2
|
+
export declare const FourthwallStockSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
3
3
|
type: z.ZodLiteral<"UNLIMITED">;
|
|
4
|
-
},
|
|
5
|
-
type: z.ZodLiteral<"UNLIMITED">;
|
|
6
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
7
|
-
type: z.ZodLiteral<"UNLIMITED">;
|
|
8
|
-
}, z.ZodTypeAny, "passthrough">>, z.ZodObject<{
|
|
9
|
-
type: z.ZodLiteral<"LIMITED">;
|
|
10
|
-
inStock: z.ZodNumber;
|
|
11
|
-
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
12
|
-
type: z.ZodLiteral<"LIMITED">;
|
|
13
|
-
inStock: z.ZodNumber;
|
|
14
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
4
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
15
5
|
type: z.ZodLiteral<"LIMITED">;
|
|
16
6
|
inStock: z.ZodNumber;
|
|
17
|
-
}, z.
|
|
7
|
+
}, z.core.$loose>], "type">;
|
|
18
8
|
export type FourthwallAvailabilityStatus = 'available' | 'unavailable' | 'unknown';
|
|
19
9
|
export interface FourthwallAvailability {
|
|
20
10
|
status: FourthwallAvailabilityStatus;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"availability.d.ts","sourceRoot":"","sources":["../src/availability.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,eAAO,MAAM,qBAAqB
|
|
1
|
+
{"version":3,"file":"availability.d.ts","sourceRoot":"","sources":["../src/availability.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,eAAO,MAAM,qBAAqB;;;;;2BAQhC,CAAA;AAEF,MAAM,MAAM,4BAA4B,GAAG,WAAW,GAAG,aAAa,GAAG,SAAS,CAAA;AAElF,MAAM,WAAW,sBAAsB;IACtC,MAAM,EAAE,4BAA4B,CAAA;IACpC,WAAW,EAAE,OAAO,CAAA;IACpB,iBAAiB,EAAE,4BAA4B,GAAG,+BAA+B,GAAG,IAAI,CAAA;CACxF;AAED,UAAU,2BAA2B;IACpC,EAAE,CAAC,EAAE,OAAO,CAAA;IACZ,KAAK,CAAC,EAAE,OAAO,CAAA;CACf;AAkBD,wBAAgB,6BAA6B,CAC5C,OAAO,EAAE,2BAA2B,GAClC,sBAAsB,CAqBxB"}
|
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { ZodTypeAny, z } from 'zod';
|
|
2
1
|
export interface FourthwallClientConfig {
|
|
3
2
|
/** Public storefront token (`ptkn_...`). Safe in browser. */
|
|
4
3
|
token: string;
|
|
@@ -28,8 +27,8 @@ export declare function createFourthwallClient(config: FourthwallClientConfig):
|
|
|
28
27
|
}): Promise<{
|
|
29
28
|
results: {
|
|
30
29
|
id: string;
|
|
31
|
-
name: string;
|
|
32
30
|
slug: string;
|
|
31
|
+
name: string;
|
|
33
32
|
description?: string | undefined;
|
|
34
33
|
}[];
|
|
35
34
|
paging: {
|
|
@@ -47,6 +46,7 @@ export declare function createFourthwallClient(config: FourthwallClientConfig):
|
|
|
47
46
|
results: {
|
|
48
47
|
id: string;
|
|
49
48
|
name: string;
|
|
49
|
+
slug: string;
|
|
50
50
|
images: {
|
|
51
51
|
url: string;
|
|
52
52
|
id?: string | undefined;
|
|
@@ -54,7 +54,6 @@ export declare function createFourthwallClient(config: FourthwallClientConfig):
|
|
|
54
54
|
width?: number | undefined;
|
|
55
55
|
height?: number | undefined;
|
|
56
56
|
}[];
|
|
57
|
-
slug: string;
|
|
58
57
|
variants: {
|
|
59
58
|
id: string;
|
|
60
59
|
unitPrice: {
|
|
@@ -72,26 +71,17 @@ export declare function createFourthwallClient(config: FourthwallClientConfig):
|
|
|
72
71
|
currency: string;
|
|
73
72
|
} | null | undefined;
|
|
74
73
|
stock?: unknown;
|
|
75
|
-
attributes?:
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
swatch: z.ZodOptional<z.ZodString>;
|
|
80
|
-
}, "strip", ZodTypeAny, {
|
|
74
|
+
attributes?: {
|
|
75
|
+
[x: string]: unknown;
|
|
76
|
+
description?: string | undefined;
|
|
77
|
+
color?: {
|
|
81
78
|
name?: string | undefined;
|
|
82
79
|
swatch?: string | undefined;
|
|
83
|
-
}
|
|
80
|
+
} | null | undefined;
|
|
81
|
+
size?: {
|
|
84
82
|
name?: string | undefined;
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
size: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
88
|
-
name: z.ZodOptional<z.ZodString>;
|
|
89
|
-
}, "strip", ZodTypeAny, {
|
|
90
|
-
name?: string | undefined;
|
|
91
|
-
}, {
|
|
92
|
-
name?: string | undefined;
|
|
93
|
-
}>>>;
|
|
94
|
-
}, ZodTypeAny, "passthrough"> | undefined;
|
|
83
|
+
} | null | undefined;
|
|
84
|
+
} | undefined;
|
|
95
85
|
images?: {
|
|
96
86
|
url: string;
|
|
97
87
|
id?: string | undefined;
|
|
@@ -123,6 +113,7 @@ export declare function createFourthwallClient(config: FourthwallClientConfig):
|
|
|
123
113
|
}): Promise<{
|
|
124
114
|
id: string;
|
|
125
115
|
name: string;
|
|
116
|
+
slug: string;
|
|
126
117
|
images: {
|
|
127
118
|
url: string;
|
|
128
119
|
id?: string | undefined;
|
|
@@ -130,7 +121,6 @@ export declare function createFourthwallClient(config: FourthwallClientConfig):
|
|
|
130
121
|
width?: number | undefined;
|
|
131
122
|
height?: number | undefined;
|
|
132
123
|
}[];
|
|
133
|
-
slug: string;
|
|
134
124
|
variants: {
|
|
135
125
|
id: string;
|
|
136
126
|
unitPrice: {
|
|
@@ -148,26 +138,17 @@ export declare function createFourthwallClient(config: FourthwallClientConfig):
|
|
|
148
138
|
currency: string;
|
|
149
139
|
} | null | undefined;
|
|
150
140
|
stock?: unknown;
|
|
151
|
-
attributes?:
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
swatch: z.ZodOptional<z.ZodString>;
|
|
156
|
-
}, "strip", ZodTypeAny, {
|
|
157
|
-
name?: string | undefined;
|
|
158
|
-
swatch?: string | undefined;
|
|
159
|
-
}, {
|
|
141
|
+
attributes?: {
|
|
142
|
+
[x: string]: unknown;
|
|
143
|
+
description?: string | undefined;
|
|
144
|
+
color?: {
|
|
160
145
|
name?: string | undefined;
|
|
161
146
|
swatch?: string | undefined;
|
|
162
|
-
}
|
|
163
|
-
size
|
|
164
|
-
name: z.ZodOptional<z.ZodString>;
|
|
165
|
-
}, "strip", ZodTypeAny, {
|
|
166
|
-
name?: string | undefined;
|
|
167
|
-
}, {
|
|
147
|
+
} | null | undefined;
|
|
148
|
+
size?: {
|
|
168
149
|
name?: string | undefined;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
150
|
+
} | null | undefined;
|
|
151
|
+
} | undefined;
|
|
171
152
|
images?: {
|
|
172
153
|
url: string;
|
|
173
154
|
id?: string | undefined;
|
|
@@ -210,26 +191,17 @@ export declare function createFourthwallClient(config: FourthwallClientConfig):
|
|
|
210
191
|
currency: string;
|
|
211
192
|
} | null | undefined;
|
|
212
193
|
stock?: unknown;
|
|
213
|
-
attributes?:
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
swatch: z.ZodOptional<z.ZodString>;
|
|
218
|
-
}, "strip", ZodTypeAny, {
|
|
219
|
-
name?: string | undefined;
|
|
220
|
-
swatch?: string | undefined;
|
|
221
|
-
}, {
|
|
194
|
+
attributes?: {
|
|
195
|
+
[x: string]: unknown;
|
|
196
|
+
description?: string | undefined;
|
|
197
|
+
color?: {
|
|
222
198
|
name?: string | undefined;
|
|
223
199
|
swatch?: string | undefined;
|
|
224
|
-
}
|
|
225
|
-
size
|
|
226
|
-
name: z.ZodOptional<z.ZodString>;
|
|
227
|
-
}, "strip", ZodTypeAny, {
|
|
200
|
+
} | null | undefined;
|
|
201
|
+
size?: {
|
|
228
202
|
name?: string | undefined;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
}>>>;
|
|
232
|
-
}, ZodTypeAny, "passthrough"> | undefined;
|
|
203
|
+
} | null | undefined;
|
|
204
|
+
} | undefined;
|
|
233
205
|
images?: {
|
|
234
206
|
url: string;
|
|
235
207
|
id?: string | undefined;
|
|
@@ -265,26 +237,17 @@ export declare function createFourthwallClient(config: FourthwallClientConfig):
|
|
|
265
237
|
currency: string;
|
|
266
238
|
} | null | undefined;
|
|
267
239
|
stock?: unknown;
|
|
268
|
-
attributes?:
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
swatch: z.ZodOptional<z.ZodString>;
|
|
273
|
-
}, "strip", ZodTypeAny, {
|
|
240
|
+
attributes?: {
|
|
241
|
+
[x: string]: unknown;
|
|
242
|
+
description?: string | undefined;
|
|
243
|
+
color?: {
|
|
274
244
|
name?: string | undefined;
|
|
275
245
|
swatch?: string | undefined;
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
swatch?: string | undefined;
|
|
279
|
-
}>>>;
|
|
280
|
-
size: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
281
|
-
name: z.ZodOptional<z.ZodString>;
|
|
282
|
-
}, "strip", ZodTypeAny, {
|
|
283
|
-
name?: string | undefined;
|
|
284
|
-
}, {
|
|
246
|
+
} | null | undefined;
|
|
247
|
+
size?: {
|
|
285
248
|
name?: string | undefined;
|
|
286
|
-
}
|
|
287
|
-
}
|
|
249
|
+
} | null | undefined;
|
|
250
|
+
} | undefined;
|
|
288
251
|
images?: {
|
|
289
252
|
url: string;
|
|
290
253
|
id?: string | undefined;
|
|
@@ -324,26 +287,17 @@ export declare function createFourthwallClient(config: FourthwallClientConfig):
|
|
|
324
287
|
currency: string;
|
|
325
288
|
} | null | undefined;
|
|
326
289
|
stock?: unknown;
|
|
327
|
-
attributes?:
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
swatch: z.ZodOptional<z.ZodString>;
|
|
332
|
-
}, "strip", ZodTypeAny, {
|
|
333
|
-
name?: string | undefined;
|
|
334
|
-
swatch?: string | undefined;
|
|
335
|
-
}, {
|
|
290
|
+
attributes?: {
|
|
291
|
+
[x: string]: unknown;
|
|
292
|
+
description?: string | undefined;
|
|
293
|
+
color?: {
|
|
336
294
|
name?: string | undefined;
|
|
337
295
|
swatch?: string | undefined;
|
|
338
|
-
}
|
|
339
|
-
size
|
|
340
|
-
name: z.ZodOptional<z.ZodString>;
|
|
341
|
-
}, "strip", ZodTypeAny, {
|
|
342
|
-
name?: string | undefined;
|
|
343
|
-
}, {
|
|
296
|
+
} | null | undefined;
|
|
297
|
+
size?: {
|
|
344
298
|
name?: string | undefined;
|
|
345
|
-
}
|
|
346
|
-
}
|
|
299
|
+
} | null | undefined;
|
|
300
|
+
} | undefined;
|
|
347
301
|
images?: {
|
|
348
302
|
url: string;
|
|
349
303
|
id?: string | undefined;
|
|
@@ -383,26 +337,17 @@ export declare function createFourthwallClient(config: FourthwallClientConfig):
|
|
|
383
337
|
currency: string;
|
|
384
338
|
} | null | undefined;
|
|
385
339
|
stock?: unknown;
|
|
386
|
-
attributes?:
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
swatch: z.ZodOptional<z.ZodString>;
|
|
391
|
-
}, "strip", ZodTypeAny, {
|
|
392
|
-
name?: string | undefined;
|
|
393
|
-
swatch?: string | undefined;
|
|
394
|
-
}, {
|
|
340
|
+
attributes?: {
|
|
341
|
+
[x: string]: unknown;
|
|
342
|
+
description?: string | undefined;
|
|
343
|
+
color?: {
|
|
395
344
|
name?: string | undefined;
|
|
396
345
|
swatch?: string | undefined;
|
|
397
|
-
}
|
|
398
|
-
size
|
|
399
|
-
name: z.ZodOptional<z.ZodString>;
|
|
400
|
-
}, "strip", ZodTypeAny, {
|
|
346
|
+
} | null | undefined;
|
|
347
|
+
size?: {
|
|
401
348
|
name?: string | undefined;
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
}>>>;
|
|
405
|
-
}, ZodTypeAny, "passthrough"> | undefined;
|
|
349
|
+
} | null | undefined;
|
|
350
|
+
} | undefined;
|
|
406
351
|
images?: {
|
|
407
352
|
url: string;
|
|
408
353
|
id?: string | undefined;
|
|
@@ -439,26 +384,17 @@ export declare function createFourthwallClient(config: FourthwallClientConfig):
|
|
|
439
384
|
currency: string;
|
|
440
385
|
} | null | undefined;
|
|
441
386
|
stock?: unknown;
|
|
442
|
-
attributes?:
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
swatch: z.ZodOptional<z.ZodString>;
|
|
447
|
-
}, "strip", ZodTypeAny, {
|
|
387
|
+
attributes?: {
|
|
388
|
+
[x: string]: unknown;
|
|
389
|
+
description?: string | undefined;
|
|
390
|
+
color?: {
|
|
448
391
|
name?: string | undefined;
|
|
449
392
|
swatch?: string | undefined;
|
|
450
|
-
}
|
|
393
|
+
} | null | undefined;
|
|
394
|
+
size?: {
|
|
451
395
|
name?: string | undefined;
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
size: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
455
|
-
name: z.ZodOptional<z.ZodString>;
|
|
456
|
-
}, "strip", ZodTypeAny, {
|
|
457
|
-
name?: string | undefined;
|
|
458
|
-
}, {
|
|
459
|
-
name?: string | undefined;
|
|
460
|
-
}>>>;
|
|
461
|
-
}, ZodTypeAny, "passthrough"> | undefined;
|
|
396
|
+
} | null | undefined;
|
|
397
|
+
} | undefined;
|
|
462
398
|
images?: {
|
|
463
399
|
url: string;
|
|
464
400
|
id?: string | undefined;
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAYA,MAAM,WAAW,sBAAsB;IACtC,6DAA6D;IAC7D,KAAK,EAAE,MAAM,CAAA;IACb,yEAAyE;IACzE,OA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B;QACpB,MAAM,EAAE,MAAM,CAAA;QACd,KAAK,EAAE,KAAK,CAAC;YAAE,SAAS,EAAE,MAAM,CAAC;YAAC,QAAQ,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;QACrD,QAAQ,CAAC,EAAE,MAAM,CAAA;KACjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IASD,wCAAwC;yBACnB;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,EAAE,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAS9E;AAED,MAAM,MAAM,gBAAgB,GAAG,UAAU,CAAC,OAAO,sBAAsB,CAAC,CAAA"}
|
package/dist/image.d.ts
CHANGED
|
@@ -2,12 +2,11 @@
|
|
|
2
2
|
* Route a remote image URL through Cloudflare Image Resizing.
|
|
3
3
|
*
|
|
4
4
|
* Uses the zone-local `/cdn-cgi/image/...` transform endpoint. Works on any
|
|
5
|
-
* custom domain whose zone
|
|
6
|
-
*
|
|
7
|
-
* unmodified.
|
|
5
|
+
* custom domain whose zone permits the Fourthwall image origins. Local and
|
|
6
|
+
* unsupported image URLs pass through unmodified.
|
|
8
7
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
8
|
+
* Enabled by default. Set `imageTransform.enabled: false` for local previews
|
|
9
|
+
* or workers.dev hosts, which do not support zone-local transformations.
|
|
11
10
|
*
|
|
12
11
|
* `format=auto` picks AVIF/WebP/JPEG based on the request's `Accept` header.
|
|
13
12
|
*/
|
|
@@ -17,7 +16,7 @@ export interface OptimizeFwImageOpts {
|
|
|
17
16
|
height?: number;
|
|
18
17
|
quality?: number;
|
|
19
18
|
fit?: 'cover' | 'contain' | 'scale-down' | 'crop' | 'pad';
|
|
20
|
-
/** From `StoreOptions.imageTransform`. Defaults to
|
|
19
|
+
/** From `StoreOptions.imageTransform`. Defaults to enabled. */
|
|
21
20
|
enabled?: boolean;
|
|
22
21
|
}
|
|
23
22
|
export declare function hasProductImages(product: Pick<FwProduct, 'images' | 'variants'>): boolean;
|
package/dist/image.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../src/image.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../src/image.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAE3C,MAAM,WAAW,mBAAmB;IACnC,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,GAAG,CAAC,EAAE,OAAO,GAAG,SAAS,GAAG,YAAY,GAAG,MAAM,GAAG,KAAK,CAAA;IACzD,+DAA+D;IAC/D,OAAO,CAAC,EAAE,OAAO,CAAA;CACjB;AAQD,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,SAAS,EAAE,QAAQ,GAAG,UAAU,CAAC,GAAG,OAAO,CAKzF;AAED,wBAAgB,eAAe,CAC9B,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAC9B,IAAI,EAAE,mBAAmB,GACvB,MAAM,GAAG,IAAI,CAuBf"}
|
package/dist/image.js
CHANGED
|
@@ -2,16 +2,19 @@
|
|
|
2
2
|
* Route a remote image URL through Cloudflare Image Resizing.
|
|
3
3
|
*
|
|
4
4
|
* Uses the zone-local `/cdn-cgi/image/...` transform endpoint. Works on any
|
|
5
|
-
* custom domain whose zone
|
|
6
|
-
*
|
|
7
|
-
* unmodified.
|
|
5
|
+
* custom domain whose zone permits the Fourthwall image origins. Local and
|
|
6
|
+
* unsupported image URLs pass through unmodified.
|
|
8
7
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
8
|
+
* Enabled by default. Set `imageTransform.enabled: false` for local previews
|
|
9
|
+
* or workers.dev hosts, which do not support zone-local transformations.
|
|
11
10
|
*
|
|
12
11
|
* `format=auto` picks AVIF/WebP/JPEG based on the request's `Accept` header.
|
|
13
12
|
*/
|
|
14
|
-
const TRANSFORMABLE_HOSTS = [
|
|
13
|
+
const TRANSFORMABLE_HOSTS = [
|
|
14
|
+
'cdn.fourthwall.com',
|
|
15
|
+
'imgproxy.fourthwall.dev',
|
|
16
|
+
'storage.googleapis.com',
|
|
17
|
+
];
|
|
15
18
|
export function hasProductImages(product) {
|
|
16
19
|
return (product.images.some((image) => Boolean(image.url.trim())) ||
|
|
17
20
|
product.variants.some((variant) => variant.images?.some((image) => Boolean(image.url.trim()))));
|
|
@@ -19,11 +22,12 @@ export function hasProductImages(product) {
|
|
|
19
22
|
export function optimizeFwImage(url, opts) {
|
|
20
23
|
if (!url)
|
|
21
24
|
return null;
|
|
22
|
-
if (
|
|
25
|
+
if (opts.enabled === false)
|
|
23
26
|
return url;
|
|
24
27
|
try {
|
|
25
28
|
const parsed = new URL(url);
|
|
26
|
-
if (!
|
|
29
|
+
if (!['https:', 'http:'].includes(parsed.protocol) ||
|
|
30
|
+
!TRANSFORMABLE_HOSTS.some((h) => parsed.hostname === h || parsed.hostname.endsWith(`.${h}`))) {
|
|
27
31
|
return url;
|
|
28
32
|
}
|
|
29
33
|
}
|
package/dist/image.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image.js","sourceRoot":"","sources":["../src/image.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"image.js","sourceRoot":"","sources":["../src/image.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAaH,MAAM,mBAAmB,GAAG;IAC3B,oBAAoB;IACpB,yBAAyB;IACzB,wBAAwB;CACxB,CAAA;AAED,MAAM,UAAU,gBAAgB,CAAC,OAA+C;IAC/E,OAAO,CACN,OAAO,CAAC,MAAM,CAAC,IAAI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