@moonbase.sh/storefront-api 2.5.0 → 3.1.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/README.md +21 -0
- package/dist/index.cjs +634 -18
- package/dist/index.d.cts +8055 -8021
- package/dist/index.d.ts +8055 -8021
- package/dist/index.js +627 -18
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -99,6 +99,27 @@ while (page.hasMore && page.next) {
|
|
|
99
99
|
|
|
100
100
|
`client.storefront`, `client.identity`, `client.orders`, `client.vouchers`, `client.inventory`, `client.activationRequests`, `client.vendor`.
|
|
101
101
|
|
|
102
|
+
## Image renditions
|
|
103
|
+
|
|
104
|
+
Assets are stored once, at full size, and every product icon, bundle icon, logo and promotion
|
|
105
|
+
image arrives as a single URL. `ImageUtils` rewrites that URL to ask the CDN for a rendition
|
|
106
|
+
sized to where you're actually painting it, so a 96px icon costs 96px:
|
|
107
|
+
|
|
108
|
+
```ts
|
|
109
|
+
import { ImageUtils } from '@moonbase.sh/storefront-api'
|
|
110
|
+
|
|
111
|
+
// Fit inside a box — the natural choice for artwork of unknown shape.
|
|
112
|
+
ImageUtils.transform(product.iconUrl, { width: 96 })
|
|
113
|
+
// https://assets.moonbase.sh/_i/acme/…/icon.png?w=96
|
|
114
|
+
|
|
115
|
+
// Crop to fill an exact box, and hand retina screens the sharper one.
|
|
116
|
+
ImageUtils.srcSet(product.iconUrl, { width: 96, fit: 'cover' }, 1, 2)
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Widths are rounded up to the sizes the CDN serves, so two requests for the same visual size share
|
|
120
|
+
one cached rendition. A URL that isn't a Moonbase asset — a merchant's own artwork on their own
|
|
121
|
+
host — is returned untouched and logs a warning, since it will be served at full size.
|
|
122
|
+
|
|
102
123
|
## Token storage and logging
|
|
103
124
|
|
|
104
125
|
By default, credentials are stored in localStorage (or in-memory if localStorage is unavailable).
|