@growth-labs/store 0.3.3 → 0.3.6
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 +17 -0
- package/README.md +8 -0
- 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.js +1 -1
- package/dist/options.js.map +1 -1
- package/package.json +1 -1
- 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 +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.3.6
|
|
4
|
+
|
|
5
|
+
- Release responsive Fourthwall images from the corrected consumer gate, which
|
|
6
|
+
runs whole-workspace installs and suites on the heavy runner class.
|
|
7
|
+
|
|
8
|
+
## 0.3.5
|
|
9
|
+
|
|
10
|
+
- Release the responsive Fourthwall image defaults with consumer validation
|
|
11
|
+
that preserves the shared policy of separate compiler contexts.
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## 0.3.4
|
|
15
|
+
|
|
16
|
+
- Enable Cloudflare image transformations by default, including Fourthwall's
|
|
17
|
+
imgproxy host, so responsive candidates deliver their requested widths and
|
|
18
|
+
negotiate AVIF/WebP. Keep an explicit opt-out for preview hosts.
|
|
19
|
+
|
|
3
20
|
## 0.3.3
|
|
4
21
|
|
|
5
22
|
- 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/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,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;QACzD,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAC9F,CAAA;AACF,CAAC;AAED,MAAM,UAAU,eAAe,CAC9B,GAA8B,EAC9B,IAAyB;IAEzB,IAAI,CAAC,GAAG;QAAE,OAAO,IAAI,CAAA;IACrB,IAAI,IAAI,CAAC,OAAO,KAAK,KAAK;QAAE,OAAO,GAAG,CAAA;IACtC,IAAI,CAAC;QACJ,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAA;QAC3B,IACC,CAAC,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC;YAC9C,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,KAAK,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,EAC3F,CAAC;YACF,OAAO,GAAG,CAAA;QACX,CAAC;IACF,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,GAAG,CAAA;IACX,CAAC;IAED,MAAM,MAAM,GAAa;QACxB,SAAS,IAAI,CAAC,KAAK,EAAE;QACrB,WAAW,IAAI,CAAC,OAAO,IAAI,EAAE,EAAE;QAC/B,OAAO,IAAI,CAAC,GAAG,IAAI,OAAO,EAAE;QAC5B,aAAa;KACb,CAAA;IACD,IAAI,IAAI,CAAC,MAAM;QAAE,MAAM,CAAC,IAAI,CAAC,UAAU,IAAI,CAAC,MAAM,EAAE,CAAC,CAAA;IACrD,OAAO,kBAAkB,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,EAAE,CAAA;AACnD,CAAC"}
|
package/dist/options.js
CHANGED
package/dist/options.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.js","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAAC;IACtC,MAAM,EAA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AAC,OAAO,CAAC,IAAI,CAAC;QACnC,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,WAAW,CAAC;QAC3C,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;QACpC,gGAAgG;QAChG,mBAAmB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;KAC3D,CAAC;SACD,OAAO,CAAC,EAAE,CAAC;CACb,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG,sBAAsB,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IAChF,GAAG,OAAO;IACV,SAAS,EAAE;QACV,GAAG,OAAO,CAAC,SAAS;QACpB,MAAM,EAAE,OAAO,CAAC,SAAS,CAAC,MAAM,IAAI,OAAO,CAAC,UAAU;KACtD;CACD,CAAC,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -14,7 +14,7 @@ interface Props {
|
|
|
14
14
|
fourthwallShopUrl?: string
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
const { checkoutPath = '/api/store/checkout', imageTransformEnabled =
|
|
17
|
+
const { checkoutPath = '/api/store/checkout', imageTransformEnabled = true, cartPath = '/store/cart/', fourthwallShopUrl } = Astro.props
|
|
18
18
|
|
|
19
19
|
const fwEnv = cloudflareEnv as FwEnv
|
|
20
20
|
const token = fwEnv?.PUBLIC_FW_STOREFRONT_TOKEN ?? ''
|
|
@@ -13,7 +13,7 @@ interface Props {
|
|
|
13
13
|
basePath?: string
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
const { product, href, priority = false, imageTransformEnabled =
|
|
16
|
+
const { product, href, priority = false, imageTransformEnabled = true, basePath = '/store' } = Astro.props
|
|
17
17
|
const linkHref = href ?? `${basePath}/${product.slug}/`
|
|
18
18
|
const colorOptions = getProductCardColorOptions(product)
|
|
19
19
|
const initialOption = colorOptions[0] ?? null
|
|
@@ -40,7 +40,7 @@ const currency = env?.PUBLIC_FW_DEFAULT_CURRENCY ?? config.defaultCurrency
|
|
|
40
40
|
Checkout isn't open for this store yet.
|
|
41
41
|
</p>
|
|
42
42
|
) : (
|
|
43
|
-
<div id="fw-cart-page" data-fw-token={token} data-fw-currency={currency} data-checkout-path={config.routes.checkoutPath}>
|
|
43
|
+
<div id="fw-cart-page" data-fw-token={token} data-fw-currency={currency} data-checkout-path={config.routes.checkoutPath} data-image-transform={String(config.imageTransform.enabled)}>
|
|
44
44
|
<p id="fw-cart-page-empty" class="text-[var(--muted-foreground)]">
|
|
45
45
|
Your cart is empty. <a class="underline" href={storePath}>Browse the store</a>.
|
|
46
46
|
</p>
|
|
@@ -91,6 +91,7 @@ const currency = env?.PUBLIC_FW_DEFAULT_CURRENCY ?? config.defaultCurrency
|
|
|
91
91
|
const token = page?.getAttribute('data-fw-token') ?? ''
|
|
92
92
|
const currency = page?.getAttribute('data-fw-currency') ?? 'USD'
|
|
93
93
|
const checkoutPath = page?.getAttribute('data-checkout-path') ?? '/api/store/checkout'
|
|
94
|
+
const imageTransformEnabled = page?.getAttribute('data-image-transform') === 'true'
|
|
94
95
|
if (token) cart.init({ token, currency })
|
|
95
96
|
|
|
96
97
|
function formatMoney(cents: number, cur: string): string {
|
|
@@ -121,7 +122,7 @@ const currency = env?.PUBLIC_FW_DEFAULT_CURRENCY ?? config.defaultCurrency
|
|
|
121
122
|
contents.classList.remove('hidden')
|
|
122
123
|
linesEl.innerHTML = snap.items
|
|
123
124
|
.map((item) => {
|
|
124
|
-
const optSrc = optimizeFwImage(item.imageUrl, { width: 224 }) ?? item.imageUrl
|
|
125
|
+
const optSrc = optimizeFwImage(item.imageUrl, { width: 224, enabled: imageTransformEnabled }) ?? item.imageUrl
|
|
125
126
|
const img = item.imageUrl
|
|
126
127
|
? `<img src="${optSrc}" alt="" loading="lazy" decoding="async" class="h-28 w-28 object-cover" />`
|
|
127
128
|
: `<div class="h-28 w-28 bg-[var(--muted)]"></div>`
|
package/src/image.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
|
*/
|
|
@@ -19,11 +18,15 @@ export interface OptimizeFwImageOpts {
|
|
|
19
18
|
height?: number
|
|
20
19
|
quality?: number
|
|
21
20
|
fit?: 'cover' | 'contain' | 'scale-down' | 'crop' | 'pad'
|
|
22
|
-
/** From `StoreOptions.imageTransform`. Defaults to
|
|
21
|
+
/** From `StoreOptions.imageTransform`. Defaults to enabled. */
|
|
23
22
|
enabled?: boolean
|
|
24
23
|
}
|
|
25
24
|
|
|
26
|
-
const TRANSFORMABLE_HOSTS = [
|
|
25
|
+
const TRANSFORMABLE_HOSTS = [
|
|
26
|
+
'cdn.fourthwall.com',
|
|
27
|
+
'imgproxy.fourthwall.dev',
|
|
28
|
+
'storage.googleapis.com',
|
|
29
|
+
]
|
|
27
30
|
|
|
28
31
|
export function hasProductImages(product: Pick<FwProduct, 'images' | 'variants'>): boolean {
|
|
29
32
|
return (
|
|
@@ -37,10 +40,13 @@ export function optimizeFwImage(
|
|
|
37
40
|
opts: OptimizeFwImageOpts,
|
|
38
41
|
): string | null {
|
|
39
42
|
if (!url) return null
|
|
40
|
-
if (
|
|
43
|
+
if (opts.enabled === false) return url
|
|
41
44
|
try {
|
|
42
45
|
const parsed = new URL(url)
|
|
43
|
-
if (
|
|
46
|
+
if (
|
|
47
|
+
!['https:', 'http:'].includes(parsed.protocol) ||
|
|
48
|
+
!TRANSFORMABLE_HOSTS.some((h) => parsed.hostname === h || parsed.hostname.endsWith(`.${h}`))
|
|
49
|
+
) {
|
|
44
50
|
return url
|
|
45
51
|
}
|
|
46
52
|
} catch {
|