platform-types 1.10.686 → 1.10.688
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MAX_STOREFRONT_ASSETS = exports.STOREFRONT_ASSET_VARIANTS = void 0;
|
|
3
|
+
exports.MAX_STOREFRONT_ASSETS = exports.STOREFRONT_ASSET_VARIANT_FIT = exports.STOREFRONT_ASSET_VARIANTS = void 0;
|
|
4
4
|
const storefrontDesign_ts_1 = require("./storefrontDesign.js");
|
|
5
5
|
exports.STOREFRONT_ASSET_VARIANTS = [
|
|
6
6
|
'original',
|
|
@@ -9,6 +9,31 @@ exports.STOREFRONT_ASSET_VARIANTS = [
|
|
|
9
9
|
'800x800',
|
|
10
10
|
'1200x1200',
|
|
11
11
|
'1600x1600',
|
|
12
|
+
'1200x630',
|
|
13
|
+
'192x192',
|
|
14
|
+
'512x512',
|
|
12
15
|
];
|
|
16
|
+
/**
|
|
17
|
+
* How each variant is rendered from the stored original. `original` is the
|
|
18
|
+
* stored image unchanged in size. `inside` is a thumbnail: it fits inside the
|
|
19
|
+
* box keeping its aspect and never enlarges, so a small original comes back at
|
|
20
|
+
* its own size. `1200x630` is `cover`: an EXACT-size crop for share images
|
|
21
|
+
* (`og:image`), enlarged when the original is smaller. `192x192` and `512x512`
|
|
22
|
+
* are `contain`: EXACT-size icons (favicon, PWA manifest), not thumbnails —
|
|
23
|
+
* the whole original is scaled to fit and the rest of the square is padded
|
|
24
|
+
* transparent, so nothing is cropped; they are always PNG, or WebP when the
|
|
25
|
+
* client accepts it, because a JPEG cannot carry the transparent padding.
|
|
26
|
+
*/
|
|
27
|
+
exports.STOREFRONT_ASSET_VARIANT_FIT = {
|
|
28
|
+
original: 'original',
|
|
29
|
+
'200x200': 'inside',
|
|
30
|
+
'400x400': 'inside',
|
|
31
|
+
'800x800': 'inside',
|
|
32
|
+
'1200x1200': 'inside',
|
|
33
|
+
'1600x1600': 'inside',
|
|
34
|
+
'1200x630': 'cover',
|
|
35
|
+
'192x192': 'contain',
|
|
36
|
+
'512x512': 'contain',
|
|
37
|
+
};
|
|
13
38
|
/** The active-asset cap, the same value as `STOREFRONT_DESIGN_LIMITS.activeImages` by construction. */
|
|
14
39
|
exports.MAX_STOREFRONT_ASSETS = storefrontDesign_ts_1.STOREFRONT_DESIGN_LIMITS.activeImages;
|
|
@@ -7,6 +7,8 @@ exports.parseStorefrontPreviewMessage = parseStorefrontPreviewMessage;
|
|
|
7
7
|
exports.acceptStorefrontPreviewMessage = acceptStorefrontPreviewMessage;
|
|
8
8
|
exports.STOREFRONT_DESIGN_LIMITS = {
|
|
9
9
|
customPages: 20,
|
|
10
|
+
pageAliases: 20,
|
|
11
|
+
pageAliasMetadataBytes: 64 * 1024,
|
|
10
12
|
sectionsPerPage: 10,
|
|
11
13
|
productCountMin: 4,
|
|
12
14
|
productCountMax: 24,
|
|
@@ -166,10 +168,28 @@ const previewRecord = (value) => value !== null &&
|
|
|
166
168
|
typeof value === 'object' &&
|
|
167
169
|
!Array.isArray(value) &&
|
|
168
170
|
(Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null);
|
|
171
|
+
// UTF-8 length without TextEncoder: the contracts compile with no DOM or Node lib, so a
|
|
172
|
+
// runtime global here breaks every program that type-checks them. A lone surrogate
|
|
173
|
+
// counts 3, as TextEncoder's U+FFFD replacement does.
|
|
174
|
+
function previewUtf8Bytes(text) {
|
|
175
|
+
let bytes = 0;
|
|
176
|
+
for (const char of text) {
|
|
177
|
+
const code = char.codePointAt(0) ?? 0;
|
|
178
|
+
if (code < 0x80)
|
|
179
|
+
bytes += 1;
|
|
180
|
+
else if (code < 0x800)
|
|
181
|
+
bytes += 2;
|
|
182
|
+
else if (code < 0x10000)
|
|
183
|
+
bytes += 3;
|
|
184
|
+
else
|
|
185
|
+
bytes += 4;
|
|
186
|
+
}
|
|
187
|
+
return bytes;
|
|
188
|
+
}
|
|
169
189
|
function previewWithinBytes(value, maximum) {
|
|
170
190
|
try {
|
|
171
191
|
const serialized = JSON.stringify(value);
|
|
172
|
-
return serialized !== undefined &&
|
|
192
|
+
return serialized !== undefined && previewUtf8Bytes(serialized) <= maximum;
|
|
173
193
|
}
|
|
174
194
|
catch {
|
|
175
195
|
return false;
|
|
@@ -1,4 +1,26 @@
|
|
|
1
|
-
export declare const STOREFRONT_ASSET_VARIANTS: readonly ["original", "200x200", "400x400", "800x800", "1200x1200", "1600x1600"];
|
|
1
|
+
export declare const STOREFRONT_ASSET_VARIANTS: readonly ["original", "200x200", "400x400", "800x800", "1200x1200", "1600x1600", "1200x630", "192x192", "512x512"];
|
|
2
|
+
/**
|
|
3
|
+
* How each variant is rendered from the stored original. `original` is the
|
|
4
|
+
* stored image unchanged in size. `inside` is a thumbnail: it fits inside the
|
|
5
|
+
* box keeping its aspect and never enlarges, so a small original comes back at
|
|
6
|
+
* its own size. `1200x630` is `cover`: an EXACT-size crop for share images
|
|
7
|
+
* (`og:image`), enlarged when the original is smaller. `192x192` and `512x512`
|
|
8
|
+
* are `contain`: EXACT-size icons (favicon, PWA manifest), not thumbnails —
|
|
9
|
+
* the whole original is scaled to fit and the rest of the square is padded
|
|
10
|
+
* transparent, so nothing is cropped; they are always PNG, or WebP when the
|
|
11
|
+
* client accepts it, because a JPEG cannot carry the transparent padding.
|
|
12
|
+
*/
|
|
13
|
+
export declare const STOREFRONT_ASSET_VARIANT_FIT: {
|
|
14
|
+
readonly original: "original";
|
|
15
|
+
readonly '200x200': "inside";
|
|
16
|
+
readonly '400x400': "inside";
|
|
17
|
+
readonly '800x800': "inside";
|
|
18
|
+
readonly '1200x1200': "inside";
|
|
19
|
+
readonly '1600x1600': "inside";
|
|
20
|
+
readonly '1200x630': "cover";
|
|
21
|
+
readonly '192x192': "contain";
|
|
22
|
+
readonly '512x512': "contain";
|
|
23
|
+
};
|
|
2
24
|
/** The active-asset cap, the same value as `STOREFRONT_DESIGN_LIMITS.activeImages` by construction. */
|
|
3
25
|
export declare const MAX_STOREFRONT_ASSETS: 200;
|
|
4
26
|
declare global {
|
package/dist/storefrontAssets.js
CHANGED
|
@@ -6,6 +6,31 @@ export const STOREFRONT_ASSET_VARIANTS = [
|
|
|
6
6
|
'800x800',
|
|
7
7
|
'1200x1200',
|
|
8
8
|
'1600x1600',
|
|
9
|
+
'1200x630',
|
|
10
|
+
'192x192',
|
|
11
|
+
'512x512',
|
|
9
12
|
];
|
|
13
|
+
/**
|
|
14
|
+
* How each variant is rendered from the stored original. `original` is the
|
|
15
|
+
* stored image unchanged in size. `inside` is a thumbnail: it fits inside the
|
|
16
|
+
* box keeping its aspect and never enlarges, so a small original comes back at
|
|
17
|
+
* its own size. `1200x630` is `cover`: an EXACT-size crop for share images
|
|
18
|
+
* (`og:image`), enlarged when the original is smaller. `192x192` and `512x512`
|
|
19
|
+
* are `contain`: EXACT-size icons (favicon, PWA manifest), not thumbnails —
|
|
20
|
+
* the whole original is scaled to fit and the rest of the square is padded
|
|
21
|
+
* transparent, so nothing is cropped; they are always PNG, or WebP when the
|
|
22
|
+
* client accepts it, because a JPEG cannot carry the transparent padding.
|
|
23
|
+
*/
|
|
24
|
+
export const STOREFRONT_ASSET_VARIANT_FIT = {
|
|
25
|
+
original: 'original',
|
|
26
|
+
'200x200': 'inside',
|
|
27
|
+
'400x400': 'inside',
|
|
28
|
+
'800x800': 'inside',
|
|
29
|
+
'1200x1200': 'inside',
|
|
30
|
+
'1600x1600': 'inside',
|
|
31
|
+
'1200x630': 'cover',
|
|
32
|
+
'192x192': 'contain',
|
|
33
|
+
'512x512': 'contain',
|
|
34
|
+
};
|
|
10
35
|
/** The active-asset cap, the same value as `STOREFRONT_DESIGN_LIMITS.activeImages` by construction. */
|
|
11
36
|
export const MAX_STOREFRONT_ASSETS = STOREFRONT_DESIGN_LIMITS.activeImages;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { StorefrontThemeWarning } from './storefrontTheme.ts';
|
|
2
2
|
export declare const STOREFRONT_DESIGN_LIMITS: {
|
|
3
3
|
readonly customPages: 20;
|
|
4
|
+
readonly pageAliases: 20;
|
|
5
|
+
readonly pageAliasMetadataBytes: number;
|
|
4
6
|
readonly sectionsPerPage: 10;
|
|
5
7
|
readonly productCountMin: 4;
|
|
6
8
|
readonly productCountMax: 24;
|
|
@@ -180,7 +182,12 @@ declare global {
|
|
|
180
182
|
content: StorefrontDesignSectionContent[K];
|
|
181
183
|
};
|
|
182
184
|
}[StorefrontDesignSectionType];
|
|
185
|
+
interface StorefrontDesignPublicationMetadata {
|
|
186
|
+
pageAliases: Record<string, string[]>;
|
|
187
|
+
pageSlugs: Record<string, string>;
|
|
188
|
+
}
|
|
183
189
|
interface StorefrontDesignSeo {
|
|
190
|
+
noindex?: boolean;
|
|
184
191
|
title?: string;
|
|
185
192
|
description?: string;
|
|
186
193
|
image?: StorefrontDesignImagePlacement;
|
|
@@ -213,6 +220,7 @@ declare global {
|
|
|
213
220
|
links: StorefrontDesignMenuLink[];
|
|
214
221
|
}
|
|
215
222
|
interface StorefrontContactHours {
|
|
223
|
+
/** `days` are ISO 8601 weekdays, 1 = Monday … 7 = Sunday (unique per row); `opens` is before `closes`. */
|
|
216
224
|
rows: {
|
|
217
225
|
days: number[];
|
|
218
226
|
opens: string;
|
|
@@ -310,7 +318,8 @@ declare global {
|
|
|
310
318
|
seo: StorefrontDesignSeo;
|
|
311
319
|
literalOverrides: Record<string, string>;
|
|
312
320
|
}
|
|
313
|
-
|
|
321
|
+
/** `TOO_LARGE` at path `''` means the whole stored draft would exceed its row budget, not one field. */
|
|
322
|
+
type StorefrontDesignFieldErrorCode = 'INVALID' | 'REQUIRED' | 'UNKNOWN_KEY' | 'DUPLICATE' | 'RESERVED_SLUG' | 'ALIAS_CONFLICT' | 'ALIAS_LIMIT' | 'DANGLING_REFERENCE' | 'MAPPING_CONFLICT' | 'TOO_LARGE';
|
|
314
323
|
interface StorefrontDesignFieldError {
|
|
315
324
|
path: string;
|
|
316
325
|
code: StorefrontDesignFieldErrorCode;
|
|
@@ -359,6 +368,10 @@ declare global {
|
|
|
359
368
|
interface StorefrontDesignPreviewInput {
|
|
360
369
|
draftRevision: string;
|
|
361
370
|
}
|
|
371
|
+
/**
|
|
372
|
+
* GET draft answers a baseline built without copying the legacy logo, while POST init copies it,
|
|
373
|
+
* so `document.branding.logo` can differ between them: clients rebase onto init's document.
|
|
374
|
+
*/
|
|
362
375
|
interface StorefrontDesignBaselineResult {
|
|
363
376
|
draftRevision: null;
|
|
364
377
|
publishedRevision: null;
|
package/dist/storefrontDesign.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export const STOREFRONT_DESIGN_LIMITS = {
|
|
2
2
|
customPages: 20,
|
|
3
|
+
pageAliases: 20,
|
|
4
|
+
pageAliasMetadataBytes: 64 * 1024,
|
|
3
5
|
sectionsPerPage: 10,
|
|
4
6
|
productCountMin: 4,
|
|
5
7
|
productCountMax: 24,
|
|
@@ -159,10 +161,28 @@ const previewRecord = (value) => value !== null &&
|
|
|
159
161
|
typeof value === 'object' &&
|
|
160
162
|
!Array.isArray(value) &&
|
|
161
163
|
(Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null);
|
|
164
|
+
// UTF-8 length without TextEncoder: the contracts compile with no DOM or Node lib, so a
|
|
165
|
+
// runtime global here breaks every program that type-checks them. A lone surrogate
|
|
166
|
+
// counts 3, as TextEncoder's U+FFFD replacement does.
|
|
167
|
+
function previewUtf8Bytes(text) {
|
|
168
|
+
let bytes = 0;
|
|
169
|
+
for (const char of text) {
|
|
170
|
+
const code = char.codePointAt(0) ?? 0;
|
|
171
|
+
if (code < 0x80)
|
|
172
|
+
bytes += 1;
|
|
173
|
+
else if (code < 0x800)
|
|
174
|
+
bytes += 2;
|
|
175
|
+
else if (code < 0x10000)
|
|
176
|
+
bytes += 3;
|
|
177
|
+
else
|
|
178
|
+
bytes += 4;
|
|
179
|
+
}
|
|
180
|
+
return bytes;
|
|
181
|
+
}
|
|
162
182
|
function previewWithinBytes(value, maximum) {
|
|
163
183
|
try {
|
|
164
184
|
const serialized = JSON.stringify(value);
|
|
165
|
-
return serialized !== undefined &&
|
|
185
|
+
return serialized !== undefined && previewUtf8Bytes(serialized) <= maximum;
|
|
166
186
|
}
|
|
167
187
|
catch {
|
|
168
188
|
return false;
|