@decocms/blocks 8.2.3 → 8.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/dist/v8/builtins/lazy.d.ts +1 -1
- package/dist/v8/builtins/lazy.d.ts.map +1 -1
- package/dist/v8/builtins/lazy.js +1 -1
- package/dist/v8/builtins/lazy.js.map +1 -1
- package/dist/v8/builtins/multivariate.d.ts +12 -1
- package/dist/v8/builtins/multivariate.d.ts.map +1 -1
- package/dist/v8/builtins/multivariate.js +14 -2
- package/dist/v8/builtins/multivariate.js.map +1 -1
- package/dist/v8/cli/run.d.ts.map +1 -1
- package/dist/v8/cli/run.js +7 -3
- package/dist/v8/cli/run.js.map +1 -1
- package/dist/v8/cli/schema/index.d.ts +15 -1
- package/dist/v8/cli/schema/index.d.ts.map +1 -1
- package/dist/v8/cli/schema/index.js +96 -2
- package/dist/v8/cli/schema/index.js.map +1 -1
- package/dist/v8/cms.js +9 -1
- package/dist/v8/cms.js.map +1 -1
- package/dist/v8/draft.d.ts +2 -0
- package/dist/v8/draft.d.ts.map +1 -1
- package/dist/v8/draft.js +2 -1
- package/dist/v8/draft.js.map +1 -1
- package/dist/v8/image.d.ts +140 -0
- package/dist/v8/image.d.ts.map +1 -0
- package/dist/v8/image.js +226 -0
- package/dist/v8/image.js.map +1 -0
- package/dist/v8/preview/DraftBadge.d.ts +52 -0
- package/dist/v8/preview/DraftBadge.d.ts.map +1 -0
- package/dist/v8/preview/DraftBadge.js +167 -0
- package/dist/v8/preview/DraftBadge.js.map +1 -0
- package/dist/v8/preview/StudioBridge.d.ts +78 -0
- package/dist/v8/preview/StudioBridge.d.ts.map +1 -0
- package/dist/v8/preview/StudioBridge.js +137 -0
- package/dist/v8/preview/StudioBridge.js.map +1 -0
- package/dist/v8/preview/decoMark.d.ts +7 -0
- package/dist/v8/preview/decoMark.d.ts.map +1 -0
- package/dist/v8/preview/decoMark.js +7 -0
- package/dist/v8/preview/decoMark.js.map +1 -0
- package/dist/v8/preview/index.d.ts +14 -0
- package/dist/v8/preview/index.d.ts.map +1 -0
- package/dist/v8/preview/index.js +14 -0
- package/dist/v8/preview/index.js.map +1 -0
- package/dist/v8/remoteLoader.js +3 -3
- package/dist/v8/resolver.d.ts.map +1 -1
- package/dist/v8/resolver.js +36 -3
- package/dist/v8/resolver.js.map +1 -1
- package/dist/v8/types.d.ts +4 -3
- package/dist/v8/types.d.ts.map +1 -1
- package/package.json +11 -1
- package/src/v8/builtins/lazy.ts +1 -1
- package/src/v8/builtins/multivariate.ts +28 -11
- package/src/v8/cli/run.ts +7 -3
- package/src/v8/cli/schema/index.ts +114 -3
- package/src/v8/cms.ts +12 -1
- package/src/v8/draft.ts +2 -1
- package/src/v8/image.ts +325 -0
- package/src/v8/preview/DraftBadge.tsx +278 -0
- package/src/v8/preview/StudioBridge.ts +183 -0
- package/src/v8/preview/decoMark.ts +7 -0
- package/src/v8/preview/index.ts +18 -0
- package/src/v8/remoteLoader.ts +3 -3
- package/src/v8/resolver.ts +40 -3
- package/src/v8/types.ts +4 -3
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@decocms/blocks/image`: image URLs for the Deco image CDN, srcset and
|
|
3
|
+
* preload data.
|
|
4
|
+
*
|
|
5
|
+
* Pure functions: no React, no framework, no module state. A site builds one
|
|
6
|
+
* `ImageUrl` from the providers its images come from and passes it to the
|
|
7
|
+
* binding's components or image loader. v7's `registerImageCdnDomain` and
|
|
8
|
+
* `registerImageQuality` do not come back: they were module-wide state, the
|
|
9
|
+
* dual-instance hazard the package split removed; their values are
|
|
10
|
+
* `decoCdn`'s `domain` and `quality` options.
|
|
11
|
+
*
|
|
12
|
+
* Only the Deco CDN lives here. A commerce platform's own resize syntax is a
|
|
13
|
+
* provider in that platform's client package (`@decocms/apps-vtex/image`,
|
|
14
|
+
* `@decocms/apps-shopify/image`), listed before `decoCdn`.
|
|
15
|
+
*/
|
|
16
|
+
export type Fit = "contain" | "cover" | "fill";
|
|
17
|
+
/**
|
|
18
|
+
* A named tier ("low" | "medium" | "high" | "original", what the Deco image CDN
|
|
19
|
+
* accepts) or a number. The Deco CDN ignores numbers; a provider for another
|
|
20
|
+
* service says how it reads them.
|
|
21
|
+
*/
|
|
22
|
+
export type Quality = "low" | "medium" | "high" | "original" | number;
|
|
23
|
+
/** The Deco image CDN's quality tiers. */
|
|
24
|
+
export type QualityTier = "low" | "medium" | "high" | "original";
|
|
25
|
+
export interface ResizeOptions {
|
|
26
|
+
width: number;
|
|
27
|
+
height?: number;
|
|
28
|
+
fit?: Fit;
|
|
29
|
+
quality?: Quality;
|
|
30
|
+
}
|
|
31
|
+
export interface ImageProvider {
|
|
32
|
+
name: string;
|
|
33
|
+
/** Whether this provider handles `src` (what `ImageUrl.isOptimizable` reports). */
|
|
34
|
+
match(src: string): boolean;
|
|
35
|
+
/** The resized URL, or null to leave `src` to the next provider. */
|
|
36
|
+
format(src: string, o: ResizeOptions): string | null;
|
|
37
|
+
/** Hosts the formatted URLs point at, for CSP img-src and preconnect. */
|
|
38
|
+
hosts?: string[];
|
|
39
|
+
}
|
|
40
|
+
export interface ImageUrl {
|
|
41
|
+
/** The resized URL; "" for an empty src, data: URIs and unknown sources unchanged. */
|
|
42
|
+
(src: string, o: ResizeOptions): string;
|
|
43
|
+
/** Whether a provider handles `src` (false for "", data: URIs and unknown sources). */
|
|
44
|
+
isOptimizable(src: string): boolean;
|
|
45
|
+
hosts(): string[];
|
|
46
|
+
}
|
|
47
|
+
export interface DecoCdnOptions {
|
|
48
|
+
/** The CDN host. Default "assets.decocms.com"; "decoims.com", "deco-assets.edgedeco.com" also serve it. */
|
|
49
|
+
domain?: string;
|
|
50
|
+
/** Tier asked for when a call names none (a call's numeric quality is ignored). Default: none, the CDN's 60%. */
|
|
51
|
+
quality?: QualityTier;
|
|
52
|
+
/** Fit when a call names none. Default "cover", as v7's `getSrcSet` and `Image`. */
|
|
53
|
+
fit?: Fit;
|
|
54
|
+
/**
|
|
55
|
+
* Earlier CDN hosts whose URLs are re-served from `domain`. Default ["decoims.com"]
|
|
56
|
+
* on the Cloudflare CDNs, [] otherwise (the Azion CDNs fetch decoims.com URLs fine).
|
|
57
|
+
*/
|
|
58
|
+
legacyHosts?: string[];
|
|
59
|
+
/**
|
|
60
|
+
* The sources this provider resizes. "deco" (default): the Deco asset hosts,
|
|
61
|
+
* `domain` and `legacyHosts`; others pass through. "all": every non-empty,
|
|
62
|
+
* non-data: source, v7's behaviour (put the provider last). Or a predicate.
|
|
63
|
+
*/
|
|
64
|
+
sources?: "deco" | "all" | ((src: string) => boolean);
|
|
65
|
+
/**
|
|
66
|
+
* How the Deco asset hosts (assets.decocache.com, the S3 bucket) are removed
|
|
67
|
+
* from the source. "leading" (default, v7's `Image` since 7.71.4): only a
|
|
68
|
+
* host the source starts with. "anywhere" (older v7 `getOptimizedMediaUrl`
|
|
69
|
+
* copies): the first occurrence of each, wherever it is, so a source that
|
|
70
|
+
* merely contains an asset URL (`https://other.host/https://assets.decocache.com/…`)
|
|
71
|
+
* loses that part.
|
|
72
|
+
*/
|
|
73
|
+
stripAssetHosts?: "anywhere" | "leading";
|
|
74
|
+
/**
|
|
75
|
+
* Query layout. "src-last" (default, v7's `getOptimizedMediaUrl`):
|
|
76
|
+
* `?fit=&width=[&height=][&quality=]&src=<raw path>`. "quality-last" (what
|
|
77
|
+
* next/image loaders built on v7's helper emit): the same URL re-serialised,
|
|
78
|
+
* `?fit=&width=[&height=]&src=<form-encoded path>&quality=`. Both are served
|
|
79
|
+
* the same way; keep the one a site uses so the CDN cache stays warm.
|
|
80
|
+
*/
|
|
81
|
+
layout?: "src-last" | "quality-last";
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* The Deco image CDN (`https://<domain>/image?fit=&width=…&src=`). An
|
|
85
|
+
* already-resized Deco CDN URL (any of its hosts' `/image?…&src=`) that this
|
|
86
|
+
* provider resizes (see `sources`) is re-resized from its `src`; before, it
|
|
87
|
+
* became `src=image` or `src=<cdn>/image`, which the CDN cannot serve.
|
|
88
|
+
*/
|
|
89
|
+
export declare function decoCdn(o?: DecoCdnOptions): ImageProvider;
|
|
90
|
+
/**
|
|
91
|
+
* One URL builder for a site. Providers are tried in order: the first that
|
|
92
|
+
* matches `src` and returns a URL wins; unknown sources pass through unchanged.
|
|
93
|
+
*/
|
|
94
|
+
export declare function createImageUrl(o: {
|
|
95
|
+
providers: ImageProvider[];
|
|
96
|
+
}): ImageUrl;
|
|
97
|
+
export interface SrcSetOptions {
|
|
98
|
+
/**
|
|
99
|
+
* Base width for `factors`. Left out, each candidate is `NaN` wide, as v7's
|
|
100
|
+
* `getSrcSet` wrote it for an `Image` or `Source` without a width.
|
|
101
|
+
*/
|
|
102
|
+
width?: number;
|
|
103
|
+
/** Candidate widths; when given, `width` and `factors` are not used. */
|
|
104
|
+
widths?: number[];
|
|
105
|
+
/** Multipliers of `width` (truncated, as v7 did). Default [1, 2]. */
|
|
106
|
+
factors?: number[];
|
|
107
|
+
/** Base height for `factors`, scaled with the width. */
|
|
108
|
+
height?: number;
|
|
109
|
+
/** height / width, for a fixed frame: each candidate gets round(w * ratio). */
|
|
110
|
+
ratio?: number;
|
|
111
|
+
fit?: Fit;
|
|
112
|
+
quality?: Quality;
|
|
113
|
+
}
|
|
114
|
+
/** `"<url> <w>w, ..."`, or undefined for an empty src or no candidates (`widths: []`). */
|
|
115
|
+
export declare function srcSet(url: ImageUrl, src: string, o: SrcSetOptions): string | undefined;
|
|
116
|
+
/** Candidates of a srcset attribute (URLs with commas inside are kept whole). */
|
|
117
|
+
export declare function parseSrcSet(s: string): {
|
|
118
|
+
url: string;
|
|
119
|
+
w?: number;
|
|
120
|
+
x?: number;
|
|
121
|
+
}[];
|
|
122
|
+
export interface PreloadOptions extends SrcSetOptions {
|
|
123
|
+
width: number;
|
|
124
|
+
sizes?: string;
|
|
125
|
+
media?: string;
|
|
126
|
+
/** Default "high". */
|
|
127
|
+
fetchPriority?: "high" | "low" | "auto";
|
|
128
|
+
}
|
|
129
|
+
export interface PreloadLink {
|
|
130
|
+
rel: "preload";
|
|
131
|
+
as: "image";
|
|
132
|
+
href: string;
|
|
133
|
+
imageSrcSet?: string;
|
|
134
|
+
imageSizes?: string;
|
|
135
|
+
media?: string;
|
|
136
|
+
fetchPriority?: string;
|
|
137
|
+
}
|
|
138
|
+
/** The attributes of a `<link rel="preload" as="image">` for an LCP image. */
|
|
139
|
+
export declare function preloadLink(url: ImageUrl, src: string, o: PreloadOptions): PreloadLink;
|
|
140
|
+
//# sourceMappingURL=image.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../src/v8/image.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,MAAM,MAAM,GAAG,GAAG,SAAS,GAAG,OAAO,GAAG,MAAM,CAAC;AAE/C;;;;GAIG;AACH,MAAM,MAAM,OAAO,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,UAAU,GAAG,MAAM,CAAC;AAEtE,0CAA0C;AAC1C,MAAM,MAAM,WAAW,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,UAAU,CAAC;AAEjE,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,GAAG,CAAC;IACV,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,mFAAmF;IACnF,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IAC5B,oEAAoE;IACpE,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,aAAa,GAAG,MAAM,GAAG,IAAI,CAAC;IACrD,yEAAyE;IACzE,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;CAClB;AAED,MAAM,WAAW,QAAQ;I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,CAAC;CACnB;AAED,0FAA0F;AAC1F,wBAAgB,MAAM,CAAC,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,aAAa,GAAG,MAAM,GAAG,SAAS,CAoBvF;AAED,iFAAiF;AACjF,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,CAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,CAsBhF;AAED,MAAM,WAAW,cAAe,SAAQ,aAAa;IACnD,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,sBAAsB;IACtB,aAAa,CAAC,EAAE,MAAM,GAAG,KAAK,GAAG,MAAM,CAAC;CACzC;AAED,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,SAAS,CAAC;IACf,EAAE,EAAE,OAAO,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,8EAA8E;AAC9E,wBAAgB,WAAW,CAAC,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,cAAc,GAAG,WAAW,CActF"}
|
package/dist/v8/image.js
ADDED
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@decocms/blocks/image`: image URLs for the Deco image CDN, srcset and
|
|
3
|
+
* preload data.
|
|
4
|
+
*
|
|
5
|
+
* Pure functions: no React, no framework, no module state. A site builds one
|
|
6
|
+
* `ImageUrl` from the providers its images come from and passes it to the
|
|
7
|
+
* binding's components or image loader. v7's `registerImageCdnDomain` and
|
|
8
|
+
* `registerImageQuality` do not come back: they were module-wide state, the
|
|
9
|
+
* dual-instance hazard the package split removed; their values are
|
|
10
|
+
* `decoCdn`'s `domain` and `quality` options.
|
|
11
|
+
*
|
|
12
|
+
* Only the Deco CDN lives here. A commerce platform's own resize syntax is a
|
|
13
|
+
* provider in that platform's client package (`@decocms/apps-vtex/image`,
|
|
14
|
+
* `@decocms/apps-shopify/image`), listed before `decoCdn`.
|
|
15
|
+
*/
|
|
16
|
+
// ---------------------------------------------------------------------------
|
|
17
|
+
// Deco image CDN
|
|
18
|
+
// ---------------------------------------------------------------------------
|
|
19
|
+
const DECO_CACHE_URL = "https://assets.decocache.com/";
|
|
20
|
+
const DECO_S3_URL = "https://deco-sites-assets.s3.sa-east-1.amazonaws.com/";
|
|
21
|
+
const LEADING_ASSET_HOST = /^https:\/\/(?:assets\.decocache\.com|deco-sites-assets\.s3\.sa-east-1\.amazonaws\.com)\//;
|
|
22
|
+
/** Deco CDNs on Cloudflare: a decoims.com src= makes them fetch themselves (508), so it is stripped. */
|
|
23
|
+
const CLOUDFLARE_DECO_CDNS = new Set(["assets.decocms.com", "decoims.com"]);
|
|
24
|
+
/** Every host that serves the Deco image CDN's `/image?…&src=` endpoint. */
|
|
25
|
+
const DECO_IMAGE_HOSTS = [
|
|
26
|
+
"assets.decocms.com",
|
|
27
|
+
"decoims.com",
|
|
28
|
+
"deco-assets.edgedeco.com",
|
|
29
|
+
"deco-assets.decoazn.com",
|
|
30
|
+
];
|
|
31
|
+
/** Characters an unwrapped `src` cannot carry raw in the query this provider writes. */
|
|
32
|
+
const QUERY_UNSAFE = /[%&#+]/g;
|
|
33
|
+
function stripScheme(domain) {
|
|
34
|
+
return domain.replace(/^https?:\/\//, "").replace(/\/+$/, "");
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The `src` an already-resized Deco CDN URL (`https://<cdn>/image?…&src=…`)
|
|
38
|
+
* was made from, as the CDN reads it (query-decoded); null for any other URL.
|
|
39
|
+
*/
|
|
40
|
+
function decoImageSource(src, hosts) {
|
|
41
|
+
if (!/^https?:\/\//i.test(src) || !/\/image\?/i.test(src))
|
|
42
|
+
return null;
|
|
43
|
+
let url;
|
|
44
|
+
try {
|
|
45
|
+
url = new URL(src);
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
if (!hosts.has(url.hostname) || url.pathname !== "/image")
|
|
51
|
+
return null;
|
|
52
|
+
const inner = url.searchParams.get("src");
|
|
53
|
+
return inner ? inner : null;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* The Deco image CDN (`https://<domain>/image?fit=&width=…&src=`). An
|
|
57
|
+
* already-resized Deco CDN URL (any of its hosts' `/image?…&src=`) that this
|
|
58
|
+
* provider resizes (see `sources`) is re-resized from its `src`; before, it
|
|
59
|
+
* became `src=image` or `src=<cdn>/image`, which the CDN cannot serve.
|
|
60
|
+
*/
|
|
61
|
+
export function decoCdn(o = {}) {
|
|
62
|
+
const domain = stripScheme(o.domain ?? "assets.decocms.com");
|
|
63
|
+
const legacy = (o.legacyHosts ?? (CLOUDFLARE_DECO_CDNS.has(domain) ? ["decoims.com"] : []))
|
|
64
|
+
.map(stripScheme)
|
|
65
|
+
.filter((h) => h !== domain);
|
|
66
|
+
const decoPrefixes = [
|
|
67
|
+
`https://${domain}/`,
|
|
68
|
+
...legacy.map((h) => `https://${h}/`),
|
|
69
|
+
DECO_CACHE_URL,
|
|
70
|
+
DECO_S3_URL,
|
|
71
|
+
];
|
|
72
|
+
const sources = o.sources ?? "deco";
|
|
73
|
+
const layout = o.layout ?? "src-last";
|
|
74
|
+
const imageHosts = new Set([...DECO_IMAGE_HOSTS, domain, ...legacy]);
|
|
75
|
+
return {
|
|
76
|
+
name: "deco",
|
|
77
|
+
hosts: [domain],
|
|
78
|
+
match(src) {
|
|
79
|
+
if (typeof sources === "function")
|
|
80
|
+
return sources(src);
|
|
81
|
+
if (sources === "all")
|
|
82
|
+
return src.length > 0 && !src.startsWith("data:");
|
|
83
|
+
// Only the sources resized before fix 2: a Deco CDN URL this provider
|
|
84
|
+
// did not match (another CDN host, http, an uppercase host) still passes
|
|
85
|
+
// through unchanged, as it was served fine.
|
|
86
|
+
return decoPrefixes.some((p) => src.startsWith(p));
|
|
87
|
+
},
|
|
88
|
+
format(src, r) {
|
|
89
|
+
// An already-resized Deco CDN URL is re-resized from the src it was made
|
|
90
|
+
// from (nested ones too); before, `src=` got the CDN URL's own path
|
|
91
|
+
// ("image") and the CDN answered 404.
|
|
92
|
+
let unwrapped = false;
|
|
93
|
+
for (let inner = decoImageSource(src, imageHosts), i = 0; inner !== null && i < 8; i++) {
|
|
94
|
+
src = inner;
|
|
95
|
+
unwrapped = true;
|
|
96
|
+
inner = decoImageSource(src, imageHosts);
|
|
97
|
+
}
|
|
98
|
+
let source = (o.stripAssetHosts ?? "leading") === "leading"
|
|
99
|
+
? src.replace(LEADING_ASSET_HOST, "")
|
|
100
|
+
: src.replace(DECO_CACHE_URL, "").replace(DECO_S3_URL, "");
|
|
101
|
+
source = source.split("?")[0];
|
|
102
|
+
for (const host of [...legacy, domain]) {
|
|
103
|
+
if (source.startsWith(`https://${host}/`))
|
|
104
|
+
source = source.slice(host.length + 9);
|
|
105
|
+
}
|
|
106
|
+
if (unwrapped)
|
|
107
|
+
source = source.replace(QUERY_UNSAFE, encodeURIComponent);
|
|
108
|
+
const quality = typeof r.quality === "string" ? r.quality : o.quality;
|
|
109
|
+
const params = new URLSearchParams();
|
|
110
|
+
params.set("fit", r.fit ?? o.fit ?? "cover");
|
|
111
|
+
params.set("width", `${r.width}`);
|
|
112
|
+
if (r.height)
|
|
113
|
+
params.set("height", `${r.height}`);
|
|
114
|
+
if (layout === "src-last") {
|
|
115
|
+
if (quality)
|
|
116
|
+
params.set("quality", quality);
|
|
117
|
+
return `https://${domain}/image?${params}&src=${source}`;
|
|
118
|
+
}
|
|
119
|
+
const url = new URL(`https://${domain}/image?${params}&src=${source}`);
|
|
120
|
+
if (quality)
|
|
121
|
+
url.searchParams.set("quality", quality);
|
|
122
|
+
return url.toString();
|
|
123
|
+
},
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
// ---------------------------------------------------------------------------
|
|
127
|
+
// ImageUrl, srcset, preload
|
|
128
|
+
// ---------------------------------------------------------------------------
|
|
129
|
+
/**
|
|
130
|
+
* One URL builder for a site. Providers are tried in order: the first that
|
|
131
|
+
* matches `src` and returns a URL wins; unknown sources pass through unchanged.
|
|
132
|
+
*/
|
|
133
|
+
export function createImageUrl(o) {
|
|
134
|
+
const providers = [...o.providers];
|
|
135
|
+
const usable = (src) => typeof src === "string" && src.length > 0 && !src.startsWith("data:");
|
|
136
|
+
const url = ((src, r) => {
|
|
137
|
+
if (typeof src !== "string" || src.length === 0)
|
|
138
|
+
return "";
|
|
139
|
+
if (!usable(src))
|
|
140
|
+
return src;
|
|
141
|
+
for (const p of providers) {
|
|
142
|
+
if (!p.match(src))
|
|
143
|
+
continue;
|
|
144
|
+
const out = p.format(src, r);
|
|
145
|
+
if (out !== null)
|
|
146
|
+
return out;
|
|
147
|
+
}
|
|
148
|
+
return src;
|
|
149
|
+
});
|
|
150
|
+
url.isOptimizable = (src) => usable(src) && providers.some((p) => p.match(src));
|
|
151
|
+
url.hosts = () => [...new Set(providers.flatMap((p) => p.hosts ?? []))];
|
|
152
|
+
return url;
|
|
153
|
+
}
|
|
154
|
+
/** `"<url> <w>w, ..."`, or undefined for an empty src or no candidates (`widths: []`). */
|
|
155
|
+
export function srcSet(url, src, o) {
|
|
156
|
+
if (typeof src !== "string" || src.length === 0)
|
|
157
|
+
return undefined;
|
|
158
|
+
const sizes = o.widths
|
|
159
|
+
? o.widths.map((w) => ({ w, h: o.ratio ? Math.round(w * o.ratio) : undefined }))
|
|
160
|
+
: // No width: v7's NaN candidates (`width=NaN … NaNw`), kept byte for byte.
|
|
161
|
+
(o.factors ?? [1, 2]).map((f) => {
|
|
162
|
+
const w = Math.trunc(f * o.width);
|
|
163
|
+
const h = o.height
|
|
164
|
+
? Math.trunc(f * o.height)
|
|
165
|
+
: o.ratio
|
|
166
|
+
? Math.round(w * o.ratio)
|
|
167
|
+
: undefined;
|
|
168
|
+
return { w, h };
|
|
169
|
+
});
|
|
170
|
+
const entries = [];
|
|
171
|
+
for (const { w, h } of sizes) {
|
|
172
|
+
const href = url(src, { width: w, height: h, fit: o.fit, quality: o.quality });
|
|
173
|
+
if (href)
|
|
174
|
+
entries.push(`${href} ${w}w`);
|
|
175
|
+
}
|
|
176
|
+
return entries.length > 0 ? entries.join(", ") : undefined;
|
|
177
|
+
}
|
|
178
|
+
/** Candidates of a srcset attribute (URLs with commas inside are kept whole). */
|
|
179
|
+
export function parseSrcSet(s) {
|
|
180
|
+
const out = [];
|
|
181
|
+
let i = 0;
|
|
182
|
+
while (i < s.length) {
|
|
183
|
+
while (i < s.length && /[\s,]/.test(s[i]))
|
|
184
|
+
i++;
|
|
185
|
+
if (i >= s.length)
|
|
186
|
+
break;
|
|
187
|
+
let j = i;
|
|
188
|
+
while (j < s.length && !/\s/.test(s[j]))
|
|
189
|
+
j++;
|
|
190
|
+
let url = s.slice(i, j);
|
|
191
|
+
i = j;
|
|
192
|
+
let descriptor = "";
|
|
193
|
+
if (url.endsWith(","))
|
|
194
|
+
url = url.replace(/,+$/, "");
|
|
195
|
+
else {
|
|
196
|
+
while (i < s.length && s[i] !== ",")
|
|
197
|
+
descriptor += s[i++];
|
|
198
|
+
i++;
|
|
199
|
+
}
|
|
200
|
+
const entry = { url };
|
|
201
|
+
const d = /^(\d+(?:\.\d+)?)([wx])$/.exec(descriptor.trim());
|
|
202
|
+
if (d)
|
|
203
|
+
entry[d[2]] = Number(d[1]);
|
|
204
|
+
out.push(entry);
|
|
205
|
+
}
|
|
206
|
+
return out;
|
|
207
|
+
}
|
|
208
|
+
/** The attributes of a `<link rel="preload" as="image">` for an LCP image. */
|
|
209
|
+
export function preloadLink(url, src, o) {
|
|
210
|
+
const link = {
|
|
211
|
+
rel: "preload",
|
|
212
|
+
as: "image",
|
|
213
|
+
href: url(src, { width: o.width, height: o.height, fit: o.fit, quality: o.quality }),
|
|
214
|
+
};
|
|
215
|
+
const set = srcSet(url, src, o);
|
|
216
|
+
if (set) {
|
|
217
|
+
link.imageSrcSet = set;
|
|
218
|
+
if (o.sizes)
|
|
219
|
+
link.imageSizes = o.sizes;
|
|
220
|
+
}
|
|
221
|
+
if (o.media)
|
|
222
|
+
link.media = o.media;
|
|
223
|
+
link.fetchPriority = o.fetchPriority ?? "high";
|
|
224
|
+
return link;
|
|
225
|
+
}
|
|
226
|
+
//# sourceMappingURL=image.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image.js","sourceRoot":"","sources":["../../src/v8/image.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAuCH,8EAA8E;AAC9E,iBAAiB;AACjB,8EAA8E;AAE9E,MAAM,cAAc,GAAG,+BAA+B,CAAC;AACvD,MAAM,WAAW,GAAG,uDAAuD,CAAC;AAC5E,MAAM,kBAAkB,GACtB,0FAA0F,CAAC;AAC7F,wGAAwG;AACxG,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC,CAAC,oBAAoB,EAAE,aAAa,CAAC,CAAC,CAAC;AAC5E,4EAA4E;AAC5E,MAAM,gBAAgB,GAAG;IACvB,oBAAoB;IACpB,aAAa;IACb,0BAA0B;IAC1B,yBAAyB;CAC1B,CAAC;AACF,wFAAwF;AACxF,MAAM,YAAY,GAAG,SAAS,CAAC;AAuC/B,SAAS,WAAW,CAAC,MAAc;IACjC,OAAO,MAAM,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AAChE,CAAC;AAED;;;GAGG;AACH,SAAS,eAAe,CAAC,GAAW,EAAE,KAAkB;IACtD,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,CAA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AE,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC;IACzC,CAAC;IACD,IAAI,CAAC,CAAC,KAAK;QAAE,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC;IAClC,IAAI,CAAC,aAAa,GAAG,CAAC,CAAC,aAAa,IAAI,MAAM,CAAC;IAC/C,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The "Preview mode" badge: v7's `DraftPreviewBadge`, unchanged on screen.
|
|
3
|
+
*
|
|
4
|
+
* A draft preview keeps its pointer in a cookie, so after the first click the
|
|
5
|
+
* URL no longer shows `?__draft=` and a reviewer can mistake the draft for the
|
|
6
|
+
* live site. While a draft is bound, this badge floats over the page; clicking
|
|
7
|
+
* it offers the two things a reviewer needs: leave the preview, or copy a link
|
|
8
|
+
* to this exact draft version.
|
|
9
|
+
*
|
|
10
|
+
* - Renders nothing without a `pointer`, so a binding can mount it on every
|
|
11
|
+
* page and pass the request's draft pointer (or `null`).
|
|
12
|
+
* - Hidden inside a frame: Studio's site editor shows the draft in an iframe
|
|
13
|
+
* with its own chrome. A reviewer who opens a shared link in their own tab
|
|
14
|
+
* still sees it.
|
|
15
|
+
* - Starts hidden on the server and on the first client render, and shows only
|
|
16
|
+
* after an effect confirms the page isn't framed. Rendering it and hiding it
|
|
17
|
+
* later would flash it inside Studio and break hydration (the server has no
|
|
18
|
+
* `window`).
|
|
19
|
+
* - Inline styles and an inlined mark: no dependency on the site's CSS or
|
|
20
|
+
* assets.
|
|
21
|
+
*
|
|
22
|
+
* `"use client"`: it has state and effects. In Next.js a Server Component can
|
|
23
|
+
* render it directly.
|
|
24
|
+
*/
|
|
25
|
+
import { type ReactNode } from "react";
|
|
26
|
+
export interface DraftBadgeProps {
|
|
27
|
+
/**
|
|
28
|
+
* The draft pointer this page was rendered from (`cms.draftPointer`). The
|
|
29
|
+
* badge renders nothing when it's `null`, `undefined` or empty.
|
|
30
|
+
*/
|
|
31
|
+
pointer: string | null | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* Where "Exit preview" goes. Defaults to the current URL with
|
|
34
|
+
* `?__draft=off`, which clears the draft cookie.
|
|
35
|
+
*/
|
|
36
|
+
exitHref?: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* The link "Share preview" copies: the current URL with `?__draft=<pointer>`,
|
|
40
|
+
* so the recipient sees this exact draft version.
|
|
41
|
+
*/
|
|
42
|
+
export declare function buildShareUrl(href: string, pointer: string): string;
|
|
43
|
+
/** The current URL with `?__draft=off`: ends the preview and shows the published page. */
|
|
44
|
+
export declare function buildExitUrl(href: string): string;
|
|
45
|
+
/**
|
|
46
|
+
* Whether the page is in another page's frame (Studio's site editor). A
|
|
47
|
+
* reference comparison, so it never throws across origins. No `window` (the
|
|
48
|
+
* server) reads as not framed.
|
|
49
|
+
*/
|
|
50
|
+
export declare function isFramed(win?: typeof window | undefined): boolean;
|
|
51
|
+
export declare function DraftBadge({ pointer, exitHref }: DraftBadgeProps): ReactNode;
|
|
52
|
+
//# sourceMappingURL=DraftBadge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DraftBadge.d.ts","sourceRoot":"","sources":["../../../src/v8/preview/DraftBadge.tsx"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,EAAE,KAAK,SAAS,EAA4C,MAAM,OAAO,CAAC;AAIjF,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACnC;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAInE;AAED,0FAA0F;AAC1F,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAIjD;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,GAAG,GAAE,OAAO,MAAM,GAAG,SAA6B,GAAG,OAAO,CAEpF;AAiDD,wBAAgB,UAAU,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,eAAe,GAAG,SAAS,CAwH5E"}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
/**
|
|
4
|
+
* The "Preview mode" badge: v7's `DraftPreviewBadge`, unchanged on screen.
|
|
5
|
+
*
|
|
6
|
+
* A draft preview keeps its pointer in a cookie, so after the first click the
|
|
7
|
+
* URL no longer shows `?__draft=` and a reviewer can mistake the draft for the
|
|
8
|
+
* live site. While a draft is bound, this badge floats over the page; clicking
|
|
9
|
+
* it offers the two things a reviewer needs: leave the preview, or copy a link
|
|
10
|
+
* to this exact draft version.
|
|
11
|
+
*
|
|
12
|
+
* - Renders nothing without a `pointer`, so a binding can mount it on every
|
|
13
|
+
* page and pass the request's draft pointer (or `null`).
|
|
14
|
+
* - Hidden inside a frame: Studio's site editor shows the draft in an iframe
|
|
15
|
+
* with its own chrome. A reviewer who opens a shared link in their own tab
|
|
16
|
+
* still sees it.
|
|
17
|
+
* - Starts hidden on the server and on the first client render, and shows only
|
|
18
|
+
* after an effect confirms the page isn't framed. Rendering it and hiding it
|
|
19
|
+
* later would flash it inside Studio and break hydration (the server has no
|
|
20
|
+
* `window`).
|
|
21
|
+
* - Inline styles and an inlined mark: no dependency on the site's CSS or
|
|
22
|
+
* assets.
|
|
23
|
+
*
|
|
24
|
+
* `"use client"`: it has state and effects. In Next.js a Server Component can
|
|
25
|
+
* render it directly.
|
|
26
|
+
*/
|
|
27
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
28
|
+
import { DRAFT_PARAM } from "../draft.js";
|
|
29
|
+
import { DECO_MARK_DATA_URI } from "./decoMark.js";
|
|
30
|
+
/**
|
|
31
|
+
* The link "Share preview" copies: the current URL with `?__draft=<pointer>`,
|
|
32
|
+
* so the recipient sees this exact draft version.
|
|
33
|
+
*/
|
|
34
|
+
export function buildShareUrl(href, pointer) {
|
|
35
|
+
const url = new URL(href);
|
|
36
|
+
url.searchParams.set(DRAFT_PARAM, pointer);
|
|
37
|
+
return url.toString();
|
|
38
|
+
}
|
|
39
|
+
/** The current URL with `?__draft=off`: ends the preview and shows the published page. */
|
|
40
|
+
export function buildExitUrl(href) {
|
|
41
|
+
const url = new URL(href);
|
|
42
|
+
url.searchParams.set(DRAFT_PARAM, "off");
|
|
43
|
+
return url.toString();
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Whether the page is in another page's frame (Studio's site editor). A
|
|
47
|
+
* reference comparison, so it never throws across origins. No `window` (the
|
|
48
|
+
* server) reads as not framed.
|
|
49
|
+
*/
|
|
50
|
+
export function isFramed(win = globalThis.window) {
|
|
51
|
+
return typeof win !== "undefined" && win.top !== win;
|
|
52
|
+
}
|
|
53
|
+
const DECO_GREEN = "#0b3d1e";
|
|
54
|
+
/** The badge background, Deco lime; text sits on it in dark green. */
|
|
55
|
+
const DECO_LIME = "#d0ec1a";
|
|
56
|
+
/** Leaving preview: an arrow back to the published site. */
|
|
57
|
+
function ExitIcon() {
|
|
58
|
+
return (_jsxs("svg", { width: 14, height: 14, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [_jsx("path", { d: "M19 12H5" }), _jsx("path", { d: "M12 19l-7-7 7-7" })] }));
|
|
59
|
+
}
|
|
60
|
+
/** Sharing the draft: the three-node share glyph. */
|
|
61
|
+
function ShareIcon() {
|
|
62
|
+
return (_jsxs("svg", { width: 14, height: 14, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [_jsx("circle", { cx: 18, cy: 5, r: 3 }), _jsx("circle", { cx: 6, cy: 12, r: 3 }), _jsx("circle", { cx: 18, cy: 19, r: 3 }), _jsx("path", { d: "M8.59 13.51l6.83 3.98" }), _jsx("path", { d: "M15.41 6.51l-6.82 3.98" })] }));
|
|
63
|
+
}
|
|
64
|
+
export function DraftBadge({ pointer, exitHref }) {
|
|
65
|
+
const [open, setOpen] = useState(false);
|
|
66
|
+
const [copied, setCopied] = useState(false);
|
|
67
|
+
const [visible, setVisible] = useState(false);
|
|
68
|
+
const rootRef = useRef(null);
|
|
69
|
+
// The only place isFramed() runs: after mount, so the server render and the
|
|
70
|
+
// first client render agree (both hidden).
|
|
71
|
+
useEffect(() => {
|
|
72
|
+
if (!isFramed())
|
|
73
|
+
setVisible(true);
|
|
74
|
+
}, []);
|
|
75
|
+
// Close the menu on an outside click or Escape.
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
if (!open)
|
|
78
|
+
return;
|
|
79
|
+
const onPointerDown = (e) => {
|
|
80
|
+
if (rootRef.current && !rootRef.current.contains(e.target))
|
|
81
|
+
setOpen(false);
|
|
82
|
+
};
|
|
83
|
+
const onKeyDown = (e) => {
|
|
84
|
+
if (e.key === "Escape")
|
|
85
|
+
setOpen(false);
|
|
86
|
+
};
|
|
87
|
+
document.addEventListener("mousedown", onPointerDown);
|
|
88
|
+
document.addEventListener("keydown", onKeyDown);
|
|
89
|
+
return () => {
|
|
90
|
+
document.removeEventListener("mousedown", onPointerDown);
|
|
91
|
+
document.removeEventListener("keydown", onKeyDown);
|
|
92
|
+
};
|
|
93
|
+
}, [open]);
|
|
94
|
+
const exitPreview = useCallback(() => {
|
|
95
|
+
window.location.href = exitHref ?? buildExitUrl(window.location.href);
|
|
96
|
+
}, [exitHref]);
|
|
97
|
+
const sharePreviewLink = useCallback(async () => {
|
|
98
|
+
if (!pointer)
|
|
99
|
+
return;
|
|
100
|
+
const link = buildShareUrl(window.location.href, pointer);
|
|
101
|
+
try {
|
|
102
|
+
await navigator.clipboard.writeText(link);
|
|
103
|
+
setCopied(true);
|
|
104
|
+
window.setTimeout(() => setCopied(false), 2000);
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
// No clipboard (an insecure context, a denied permission): let the
|
|
108
|
+
// reviewer copy the link by hand.
|
|
109
|
+
window.prompt("Copy preview link:", link);
|
|
110
|
+
}
|
|
111
|
+
}, [pointer]);
|
|
112
|
+
if (!pointer || !visible)
|
|
113
|
+
return null;
|
|
114
|
+
return (_jsxs("div", { ref: rootRef, "data-deco-preview-badge": "", style: {
|
|
115
|
+
position: "fixed",
|
|
116
|
+
bottom: 16,
|
|
117
|
+
left: 16,
|
|
118
|
+
zIndex: 2147483647,
|
|
119
|
+
fontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif",
|
|
120
|
+
fontSize: 13,
|
|
121
|
+
lineHeight: 1.4,
|
|
122
|
+
}, children: [open ? (_jsxs("div", { role: "menu", style: {
|
|
123
|
+
position: "absolute",
|
|
124
|
+
bottom: "calc(100% + 8px)",
|
|
125
|
+
left: 0,
|
|
126
|
+
minWidth: 200,
|
|
127
|
+
background: "#fff",
|
|
128
|
+
color: "#1a1a1a",
|
|
129
|
+
borderRadius: 12,
|
|
130
|
+
boxShadow: "0 8px 30px rgba(0,0,0,0.18), 0 0 0 1px rgba(0,0,0,0.05)",
|
|
131
|
+
overflow: "hidden",
|
|
132
|
+
}, children: [_jsx(MenuItem, { onClick: exitPreview, label: "Exit preview", icon: _jsx(ExitIcon, {}) }), _jsx("div", { style: { height: 1, background: "rgba(0,0,0,0.07)" } }), _jsx(MenuItem, { onClick: sharePreviewLink, label: copied ? "Copied!" : "Share preview", icon: _jsx(ShareIcon, {}) })] })) : null, _jsxs("button", { type: "button", "aria-expanded": open, "aria-label": "Preview mode", onClick: () => setOpen((v) => !v), style: {
|
|
133
|
+
display: "inline-flex",
|
|
134
|
+
alignItems: "center",
|
|
135
|
+
gap: 8,
|
|
136
|
+
padding: "7px 12px 7px 8px",
|
|
137
|
+
background: DECO_LIME,
|
|
138
|
+
color: DECO_GREEN,
|
|
139
|
+
border: "none",
|
|
140
|
+
borderRadius: 9999,
|
|
141
|
+
cursor: "pointer",
|
|
142
|
+
fontSize: 13,
|
|
143
|
+
fontWeight: 600,
|
|
144
|
+
boxShadow: "0 4px 14px rgba(0,0,0,0.25)",
|
|
145
|
+
}, children: [_jsx("img", { src: DECO_MARK_DATA_URI, alt: "", width: 18, height: 18, style: { display: "block", borderRadius: 4 } }), _jsx("span", { children: "Preview mode" })] })] }));
|
|
146
|
+
}
|
|
147
|
+
function MenuItem({ onClick, label, icon, }) {
|
|
148
|
+
return (_jsxs("button", { type: "button", role: "menuitem", onClick: onClick, style: {
|
|
149
|
+
display: "flex",
|
|
150
|
+
alignItems: "center",
|
|
151
|
+
gap: 10,
|
|
152
|
+
width: "100%",
|
|
153
|
+
textAlign: "left",
|
|
154
|
+
padding: "10px 14px",
|
|
155
|
+
background: "transparent",
|
|
156
|
+
border: "none",
|
|
157
|
+
color: "inherit",
|
|
158
|
+
cursor: "pointer",
|
|
159
|
+
fontSize: 13,
|
|
160
|
+
whiteSpace: "nowrap",
|
|
161
|
+
}, onMouseEnter: (e) => {
|
|
162
|
+
e.currentTarget.style.background = "rgba(0,0,0,0.05)";
|
|
163
|
+
}, onMouseLeave: (e) => {
|
|
164
|
+
e.currentTarget.style.background = "transparent";
|
|
165
|
+
}, children: [_jsx("span", { style: { display: "inline-flex", flexShrink: 0, color: DECO_GREEN }, children: icon }), _jsx("span", { children: label })] }));
|
|
166
|
+
}
|
|
167
|
+
//# sourceMappingURL=DraftBadge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DraftBadge.js","sourceRoot":"","sources":["../../../src/v8/preview/DraftBadge.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,EAAkB,WAAW,EAAE,SAA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