@replohq/canopy-sdk 0.4.0 → 0.5.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.
Files changed (38) hide show
  1. package/_vendor/replo-utils/lib/errors.d.ts +1 -1
  2. package/_vendor/replo-utils/lib/{google-fonts.d.ts → fonts.d.ts} +25 -10
  3. package/_vendor/replo-utils/lib/fonts.mjs +78 -0
  4. package/_vendor/replo-utils/lib/misc.d.ts +17 -17
  5. package/_vendor/replo-utils/lib/misc.mjs +1 -1
  6. package/_vendor/replo-utils/lib/object.d.ts +3 -3
  7. package/_vendor/replo-utils/lib/parse.d.ts +1 -1
  8. package/_vendor/schemas/agentTools/customIntegrations/loaders/product.mjs +1 -1
  9. package/_vendor/schemas/designLibrary.d.ts +15 -0
  10. package/_vendor/schemas/designLibrary.mjs +11 -1
  11. package/_vendor/schemas/errors.mjs +1 -1
  12. package/_vendor/schemas/objectType.d.ts +2 -0
  13. package/_vendor/schemas/objectType.mjs +1 -1
  14. package/_vendor/schemas/registry.d.ts +96 -0
  15. package/_vendor/schemas/selectMode.mjs +1 -1
  16. package/analytics/utils/analytics-utils.d.ts +1 -1
  17. package/analytics/utils/analytics-utils.js.map +2 -2
  18. package/{chunk-7WEM5FUJ.mjs → chunk-77XUQJHY.mjs} +22 -2
  19. package/{chunk-XK2K3263.mjs → chunk-MSIQX4QA.mjs} +9 -7
  20. package/consent/consent-actions.d.ts +6 -0
  21. package/consent/consent-actions.js +1 -2
  22. package/consent/consent-actions.js.map +2 -2
  23. package/consent/consent-store.d.ts +19 -4
  24. package/consent/consent-store.js +32 -12
  25. package/consent/consent-store.js.map +2 -2
  26. package/consent/cookie.js +5 -10
  27. package/consent/cookie.js.map +2 -2
  28. package/consent/types.d.ts +5 -0
  29. package/consent/window-api.js +1 -1
  30. package/consent/window-api.js.map +2 -2
  31. package/editor/LinkInterceptor.js +5 -5
  32. package/editor/LinkInterceptor.js.map +2 -2
  33. package/editor/design-library-preview/DesignLibraryPreview.js +1 -1
  34. package/editor/design-library-preview/DesignLibraryPreview.js.map +1 -1
  35. package/hooks/use-client-value.d.ts +1 -1
  36. package/hooks/use-client-value.js.map +2 -2
  37. package/package.json +1 -1
  38. package/_vendor/replo-utils/lib/google-fonts.mjs +0 -28
@@ -1,4 +1,4 @@
1
- type ValueOfType<T> = T[keyof T];
1
+ type ValueOfType<ObjectType> = ObjectType[keyof ObjectType];
2
2
  /**
3
3
  * Mostly taken from
4
4
  * https://gist.githubusercontent.com/scokmen/f813c904ef79022e84ab2409574d1b45/raw/cd8709a2fccb005bb53e9bfb2461e07d40b4e8d8/HttpStatusCode.ts
@@ -17,18 +17,33 @@ export declare function quoteFontFamily(family: string): string;
17
17
  * "DM Sans" → "dmSans". The JS const name for a `next/font` declaration.
18
18
  */
19
19
  export declare function fontNameToVariableName(fontName: string): string;
20
- export interface NextFontDeclaration {
21
- /** Import name for `next/font/google`, e.g. "DM_Sans". */
22
- importName: string;
23
- /** JS const name, e.g. "dmSans". */
24
- variableName: string;
25
- /** CSS variable the import exposes, e.g. "--font-dm-sans". */
26
- cssVar: string;
27
- /** The full `const … = …({ … })` declaration. */
28
- declaration: string;
29
- }
30
20
  /**
31
21
  * Google Fonts CSS2 stylesheet URL for a family at the given weights (defaulting
32
22
  * to 400), with `display=swap`.
33
23
  */
34
24
  export declare function buildGoogleFontsCssUrl(family: string, weights?: number[]): string;
25
+ /**
26
+ * "Brand Sans-Bold.woff2" → { family: "Brand Sans Bold", mimeType: "font/woff2" }.
27
+ * The family is derived from the filename since Bedrock assets don't store one.
28
+ */
29
+ export declare function describeFontFile(fileName: string): {
30
+ family: string;
31
+ mimeType: string;
32
+ };
33
+ /**
34
+ * The `format(...)` keyword for an @font-face src, from a font file extension
35
+ * (Bedrock's `find` returns `fileExtension`, not a MIME type).
36
+ */
37
+ export declare function fontFormatFromExtension(extension: string): string;
38
+ /** The `format(...)` keyword for an @font-face src, from a font MIME type. */
39
+ export declare function fontFormatFromMimeType(mimeType: string): string;
40
+ /**
41
+ * The @font-face rule that makes a custom family renderable from its asset URL.
42
+ */
43
+ export declare function buildFontFaceCss({ family, faceUrl, format, weight, }: {
44
+ family: string;
45
+ faceUrl: string;
46
+ format: string;
47
+ weight?: number;
48
+ }): string;
49
+ export declare const escapeFontFamilyName: (fontFamily: string) => string;
@@ -0,0 +1,78 @@
1
+ // ../replo-utils/lib/fonts.ts
2
+ function slugifyFontFamily(family) {
3
+ return family.replace(/([a-z])([A-Z])/g, "$1-$2").split(/[\s_-]+/u).map((word) => word.toLowerCase()).join("-");
4
+ }
5
+ function fontNameToCssVariable(fontName) {
6
+ return `--font-${slugifyFontFamily(fontName)}`;
7
+ }
8
+ function quoteFontFamily(family) {
9
+ return /\s/u.test(family) ? `'${family}'` : family;
10
+ }
11
+ function fontNameToVariableName(fontName) {
12
+ const words = fontName.replace(/([a-z])([A-Z])/g, "$1 $2").split(/[\s_-]+/u);
13
+ return words.map((word, index) => {
14
+ return index === 0 ? word.toLowerCase() : word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();
15
+ }).join("");
16
+ }
17
+ function buildGoogleFontsCssUrl(family, weights) {
18
+ const requested = weights && weights.length > 0 ? Array.from(new Set(weights)) : [400];
19
+ const sortedWeights = requested.sort(
20
+ (leftWeight, rightWeight) => leftWeight - rightWeight
21
+ );
22
+ const familyParam = family.trim().replace(/\s+/gu, "+");
23
+ return `https://fonts.googleapis.com/css2?family=${familyParam}:wght@${sortedWeights.join(
24
+ ";"
25
+ )}&display=swap`;
26
+ }
27
+ var FONT_MIME_BY_EXTENSION = {
28
+ woff2: "font/woff2",
29
+ woff: "font/woff",
30
+ ttf: "font/ttf",
31
+ otf: "font/otf"
32
+ };
33
+ function describeFontFile(fileName) {
34
+ const lastDot = fileName.lastIndexOf(".");
35
+ const base = lastDot > 0 ? fileName.slice(0, lastDot) : fileName;
36
+ const extension = lastDot > 0 ? fileName.slice(lastDot + 1).toLowerCase() : "";
37
+ const family = base.replace(/[_-]+/gu, " ").replace(/\s+/gu, " ").trim() || "Custom font";
38
+ return {
39
+ family,
40
+ mimeType: FONT_MIME_BY_EXTENSION[extension] ?? "font/woff2"
41
+ };
42
+ }
43
+ function fontFormatFromExtension(extension) {
44
+ const normalized = extension.toLowerCase().replace(/^\./u, "");
45
+ if (normalized === "woff2") return "woff2";
46
+ if (normalized === "woff") return "woff";
47
+ if (normalized === "otf") return "opentype";
48
+ if (normalized === "ttf") return "truetype";
49
+ return "woff2";
50
+ }
51
+ function fontFormatFromMimeType(mimeType) {
52
+ const normalized = mimeType.toLowerCase();
53
+ if (normalized.includes("woff2")) return "woff2";
54
+ if (normalized.includes("woff")) return "woff";
55
+ if (normalized.includes("otf") || normalized.includes("opentype")) {
56
+ return "opentype";
57
+ }
58
+ if (normalized.includes("ttf") || normalized.includes("truetype")) {
59
+ return "truetype";
60
+ }
61
+ return "woff2";
62
+ }
63
+ function escapeCssString(value) {
64
+ return value.replace(/\\/gu, "\\\\").replace(/"/gu, '\\"');
65
+ }
66
+ function buildFontFaceCss({
67
+ family,
68
+ faceUrl,
69
+ format,
70
+ weight = 400
71
+ }) {
72
+ return `@font-face{font-family:"${escapeCssString(family)}";font-weight:${weight};font-style:normal;src:url("${escapeCssString(faceUrl)}") format("${escapeCssString(format)}");font-display:swap;}`;
73
+ }
74
+ var escapeFontFamilyName = (fontFamily) => {
75
+ return fontFamily.replace(/"/g, '\\"').replace(/'/g, "\\'");
76
+ };
77
+
78
+ export { buildFontFaceCss, buildGoogleFontsCssUrl, describeFontFile, escapeFontFamilyName, fontFormatFromExtension, fontFormatFromMimeType, fontNameToCssVariable, fontNameToVariableName, quoteFontFamily, slugifyFontFamily };
@@ -5,7 +5,7 @@ export { isFunction, isNumber, isString };
5
5
  /**
6
6
  * Checks if a value is neither `null` nor `undefined`.
7
7
  */
8
- export declare function isNotNullish<T>(value: T): value is Exclude<T, null | undefined>;
8
+ export declare function isNotNullish<ValueType>(value: ValueType): value is Exclude<ValueType, null | undefined>;
9
9
  /**
10
10
  * Checks if a value is either `null` or `undefined`.
11
11
  */
@@ -14,13 +14,13 @@ export declare function isRecord(value: unknown): value is Record<string, unknow
14
14
  export declare function stringValue(value: unknown): string | null;
15
15
  export declare function getFromRecordOrNull<RecordKey extends PropertyKey, RecordValue>(record: Record<RecordKey, RecordValue> | null | undefined, key: RecordKey | undefined | null): NonNullable<Record<RecordKey, RecordValue>[RecordKey]> | null;
16
16
  export declare function isPrimitive(value: unknown): value is string | number | boolean;
17
- type StructureRecord<A extends {
17
+ type StructureRecord<UnionType extends {
18
18
  type: string;
19
- }, R> = {
20
- [T in A as T["type"]]: R | ((value: T) => R);
19
+ }, ResultType> = {
20
+ [MemberType in UnionType as MemberType["type"]]: ResultType | ((value: MemberType) => ResultType);
21
21
  };
22
- type StructureRecordGeneric<A extends Record<K, string>, R, K extends keyof A> = {
23
- [T in A as T[K]]: R | ((value: T) => R);
22
+ type StructureRecordGeneric<UnionType extends Record<KeyType, string>, ResultType, KeyType extends keyof UnionType> = {
23
+ [MemberType in UnionType as MemberType[KeyType]]: ResultType | ((value: MemberType) => ResultType);
24
24
  };
25
25
  /**
26
26
  * @returns A function which can be used to create an exhaustive switch over all
@@ -61,26 +61,26 @@ type StructureRecordGeneric<A extends Record<K, string>, R, K extends keyof A> =
61
61
  *
62
62
  * Works well for many of our types, like ComponentActionType, Action, etc
63
63
  */
64
- export declare function exhaustiveSwitch<A extends {
64
+ export declare function exhaustiveSwitch<UnionType extends {
65
65
  type: string;
66
- }>(value: A): <R>(cases: StructureRecord<A, R>) => R;
67
- export declare function exhaustiveSwitch<A extends Record<K, string>, K extends keyof A>(value: A, key: K): <R>(cases: StructureRecordGeneric<A, R, K>) => R;
68
- type EmptyObject<T> = {
69
- [K in keyof T]?: never;
66
+ }>(value: UnionType): <ResultType>(cases: StructureRecord<UnionType, ResultType>) => ResultType;
67
+ export declare function exhaustiveSwitch<UnionType extends Record<KeyType, string>, KeyType extends keyof UnionType>(value: UnionType, key: KeyType): <ResultType>(cases: StructureRecordGeneric<UnionType, ResultType, KeyType>) => ResultType;
68
+ type EmptyObject<ValueType> = {
69
+ [KeyType in keyof ValueType]?: never;
70
70
  };
71
- type EmptyObjectOf<T> = EmptyObject<T> extends T ? EmptyObject<T> : never;
71
+ type EmptyObjectOf<ValueType> = EmptyObject<ValueType> extends ValueType ? EmptyObject<ValueType> : never;
72
72
  /**
73
73
  * The same as `isEmpty` from lodash, but with a few additional overloads for
74
74
  * stronger type-checking on empty arrays.
75
75
  */
76
76
  export declare function isEmpty(value: string): value is "";
77
- export declare function isEmpty<T extends any[]>(value: T | null | undefined): value is (T & []) | null | undefined;
78
- export declare function isEmpty<T extends ArrayLike<any>>(value: T | null | undefined): value is (T & {
77
+ export declare function isEmpty<ValueType extends any[]>(value: ValueType | null | undefined): value is (ValueType & []) | null | undefined;
78
+ export declare function isEmpty<ValueType extends ArrayLike<any>>(value: ValueType | null | undefined): value is (ValueType & {
79
79
  length: 0;
80
80
  }) | null | undefined;
81
81
  export declare function isEmpty(value: Map<any, any> | Set<any> | ArrayLike<any> | null | undefined): boolean;
82
82
  export declare function isEmpty(value: object): boolean;
83
- export declare function isEmpty<T extends object>(value: T | null | undefined): value is EmptyObjectOf<T> | null | undefined;
83
+ export declare function isEmpty<ValueType extends object>(value: ValueType | null | undefined): value is EmptyObjectOf<ValueType> | null | undefined;
84
84
  export declare function isEmpty(value?: any): boolean;
85
85
  export declare function noop(): void;
86
86
  export declare function preventDefault(event: {
@@ -103,13 +103,13 @@ export declare function invariant(condition: unknown, message: string | (() => s
103
103
  }): asserts condition;
104
104
  export declare const mergeReplacingObjects: (first: Object, second: Object) => void;
105
105
  export declare const mergeReplacingArrays: (first: Object, second: Object) => void;
106
- export declare const deepCloneAndMergeReplacingArrays: <T>(source: T, ...toMerge: Object[]) => T;
106
+ export declare const deepCloneAndMergeReplacingArrays: <ValueType>(source: ValueType, ...toMerge: Object[]) => ValueType;
107
107
  /**
108
108
  * hasOwnProperty with a type assertion. If this returns true, typescript knows that `obj`
109
109
  * has a property called `prop` from that point forward
110
110
  * https://fettblog.eu/typescript-hasownproperty/
111
111
  */
112
- export declare function hasOwnProperty<X extends {} | null | undefined, Y extends PropertyKey>(obj: X, prop: Y): obj is X & Record<Y, unknown>;
112
+ export declare function hasOwnProperty<ObjectType extends {} | null | undefined, KeyType extends PropertyKey>(obj: ObjectType, prop: KeyType): obj is ObjectType & Record<KeyType, unknown>;
113
113
  /**
114
114
  * Given a string | number param, converts it to a string, unless it's nullish
115
115
  * in which case it just returns it. Useful for times when you have string | number
@@ -1,2 +1,2 @@
1
- export { coerceNumberToString, deepCloneAndMergeReplacingArrays, errorMessage, exhaustiveSwitch, formatFileSize, getFromRecordOrNull, hasOwnProperty, invariant, isEmpty, isFunction_default as isFunction, isNotNullish, isNullish, isPrimitive, isRecord, mergeReplacingArrays, mergeReplacingObjects, noop, preventDefault, sleep, stringValue, warning } from '../../../chunk-XK2K3263.mjs';
1
+ export { coerceNumberToString, deepCloneAndMergeReplacingArrays, errorMessage, exhaustiveSwitch, formatFileSize, getFromRecordOrNull, hasOwnProperty, invariant, isEmpty, isFunction_default as isFunction, isNotNullish, isNullish, isPrimitive, isRecord, mergeReplacingArrays, mergeReplacingObjects, noop, preventDefault, sleep, stringValue, warning } from '../../../chunk-MSIQX4QA.mjs';
2
2
  export { isNumber_default as isNumber, isString_default as isString } from '../../../chunk-GV5FY7ZZ.mjs';
@@ -25,7 +25,7 @@ export declare const deepEqual: typeof dequalLite;
25
25
  * @param keysToOmit - Array of keys to omit from the result
26
26
  * @returns A new object without the specified keys
27
27
  */
28
- export declare function omit<T extends Record<string, any>, K extends keyof T>(obj: T, keysToOmit: K[]): Omit<T, K>;
29
- export declare function filterUndefined<T extends Record<string, unknown>>(data: T): Partial<T>;
30
- export declare function toNullableIfDefined<T>(value: T | undefined): T | null | undefined;
28
+ export declare function omit<ObjectType extends Record<string, any>, KeyType extends keyof ObjectType>(obj: ObjectType, keysToOmit: KeyType[]): Omit<ObjectType, KeyType>;
29
+ export declare function filterUndefined<ObjectType extends Record<string, unknown>>(data: ObjectType): Partial<ObjectType>;
30
+ export declare function toNullableIfDefined<ValueType>(value: ValueType | undefined): ValueType | null | undefined;
31
31
  export {};
@@ -4,7 +4,7 @@ import type { z } from "zod";
4
4
  * environmental variables that need to be access via the full object path, like
5
5
  * `process.env.COMMIT`.
6
6
  */
7
- export declare function parseOrDefault<T extends z.ZodType<any, any>>(value: string | undefined, schema: T, defaultValue: z.infer<T>): z.infer<T>;
7
+ export declare function parseOrDefault<SchemaType extends z.ZodType<any, any>>(value: string | undefined, schema: SchemaType, defaultValue: z.infer<SchemaType>): z.infer<SchemaType>;
8
8
  /**
9
9
  * Parse an arbitrary value using the zod schema, returning `null` on
10
10
  * failure. Use this for the common pattern of validating untrusted
@@ -1,4 +1,4 @@
1
- import { priceSchema, metafieldSchema, imageSchema, selectedOptionSchema, mediaSchema, productOptionSchema, productSchema } from '../../../../../chunk-7WEM5FUJ.mjs';
1
+ import { priceSchema, metafieldSchema, imageSchema, selectedOptionSchema, mediaSchema, productOptionSchema, productSchema } from '../../../../../chunk-77XUQJHY.mjs';
2
2
  import { sellingPlanGroupSchema } from '../../../../../chunk-4TZVNC3W.mjs';
3
3
  import { z } from 'zod';
4
4
 
@@ -326,6 +326,21 @@ export declare const globalsCssSnapshotSchema: z.ZodObject<{
326
326
  }, z.core.$strip>>;
327
327
  }, z.core.$strip>>;
328
328
  }, z.core.$strip>;
329
+ export declare const siteFontRoleSchema: z.ZodObject<{
330
+ role: z.ZodString;
331
+ family: z.ZodNullable<z.ZodString>;
332
+ cssVar: z.ZodNullable<z.ZodString>;
333
+ rawValue: z.ZodString;
334
+ }, z.core.$strip>;
335
+ export declare const siteFontsSnapshotSchema: z.ZodObject<{
336
+ roles: z.ZodArray<z.ZodObject<{
337
+ role: z.ZodString;
338
+ family: z.ZodNullable<z.ZodString>;
339
+ cssVar: z.ZodNullable<z.ZodString>;
340
+ rawValue: z.ZodString;
341
+ }, z.core.$strip>>;
342
+ defaultRole: z.ZodNullable<z.ZodString>;
343
+ }, z.core.$strip>;
329
344
  export declare const DESIGN_LIBRARY_PREVIEW_MESSAGE_TYPE = "replo:design-library:applyOverrides";
330
345
  export declare const designLibraryPreviewFontSchema: z.ZodObject<{
331
346
  family: z.ZodString;
@@ -99,6 +99,16 @@ var globalsCssScopeSchema = z.object({
99
99
  var globalsCssSnapshotSchema = z.object({
100
100
  scopes: z.array(globalsCssScopeSchema)
101
101
  }).describe("GlobalsCssSnapshot");
102
+ var siteFontRoleSchema = z.object({
103
+ role: z.string(),
104
+ family: z.string().nullable(),
105
+ cssVar: z.string().nullable(),
106
+ rawValue: z.string()
107
+ }).describe("SiteFontRole");
108
+ var siteFontsSnapshotSchema = z.object({
109
+ roles: z.array(siteFontRoleSchema),
110
+ defaultRole: z.string().nullable()
111
+ }).describe("SiteFontsSnapshot");
102
112
  var DESIGN_LIBRARY_PREVIEW_MESSAGE_TYPE = "replo:design-library:applyOverrides";
103
113
  var designLibraryPreviewFontSchema = z.object({
104
114
  family: z.string(),
@@ -113,4 +123,4 @@ var designLibraryPreviewMessageSchema = z.object({
113
123
  defaultFontCssVar: z.string().nullable()
114
124
  }).describe("DesignLibraryPreviewMessage");
115
125
 
116
- export { DESIGN_LIBRARY_PREVIEW_MESSAGE_TYPE, designLibraryPreviewFontSchema, designLibraryPreviewMessageSchema, designLibrarySavedStyleMetadataSchema, designLibrarySavedStylesSchema, designLibrarySchema, globalsCssScopeSchema, globalsCssSnapshotSchema, globalsCssTokenSchema, savedColorStyleSchema, savedTextStyleSchema };
126
+ export { DESIGN_LIBRARY_PREVIEW_MESSAGE_TYPE, designLibraryPreviewFontSchema, designLibraryPreviewMessageSchema, designLibrarySavedStyleMetadataSchema, designLibrarySavedStylesSchema, designLibrarySchema, globalsCssScopeSchema, globalsCssSnapshotSchema, globalsCssTokenSchema, savedColorStyleSchema, savedTextStyleSchema, siteFontRoleSchema, siteFontsSnapshotSchema };
@@ -1,4 +1,4 @@
1
- import { MapCache_default, exhaustiveSwitch, hasOwnProperty, identity_default, baseFor_default, keys_default, Stack_default, isLength_default, isIndex_default, isArguments_default, getTag_default, isBuffer_default, isTypedArray_default, eq_default, Uint8Array_default, getAllKeys_default, baseAssignValue_default } from '../../chunk-XK2K3263.mjs';
1
+ import { MapCache_default, exhaustiveSwitch, hasOwnProperty, identity_default, baseFor_default, keys_default, Stack_default, isLength_default, isIndex_default, isArguments_default, getTag_default, isBuffer_default, isTypedArray_default, eq_default, Uint8Array_default, getAllKeys_default, baseAssignValue_default } from '../../chunk-MSIQX4QA.mjs';
2
2
  import { Symbol_default, isArray_default, isObject_default, isObjectLike_default, baseGetTag_default } from '../../chunk-GV5FY7ZZ.mjs';
3
3
  import { z, ZodError } from 'zod';
4
4
 
@@ -332,6 +332,7 @@ export declare const registryItemSchema: z.ZodObject<{
332
332
  slug: z.ZodOptional<z.ZodString>;
333
333
  title: z.ZodOptional<z.ZodString>;
334
334
  type: z.ZodOptional<z.ZodEnum<{
335
+ product: "product";
335
336
  plan: "plan";
336
337
  site: "site";
337
338
  page: "page";
@@ -745,6 +746,7 @@ declare const OBJECT_TYPE_REGISTRY: {
745
746
  slug: z.ZodOptional<z.ZodString>;
746
747
  title: z.ZodOptional<z.ZodString>;
747
748
  type: z.ZodOptional<z.ZodEnum<{
749
+ product: "product";
748
750
  plan: "plan";
749
751
  site: "site";
750
752
  page: "page";
@@ -1,2 +1,2 @@
1
- export { assetSchema, collectionSchema, customerIoBroadcastSchema, customerIoCampaignSchema, customerIoSegmentSchema, externalVideoSchema, getObjectTypeDefinition, imageSchema, integrationSchema, intelligemsExperienceSchema, levantaAffiliateLinkSchema, levantaProductSchema, looxReviewSchema, mediaImageSchema, mediaSchema, metafieldSchema, okendoReviewSchema, optionValueSchema, optionValueSwatchSchema, opusClipSchema, opusCollectionSchema, opusProjectSchema, pageSchema, planSchema, previewImageSchema, priceSchema, productOptionSchema, productSchema, registryItemSchema, segmentSourceSchema, selectedOptionSchema, transformReploProductToCanonical, variantSchema, videoSchema, videoSourceSchema, vwoCampaignSchema } from '../../chunk-7WEM5FUJ.mjs';
1
+ export { assetSchema, collectionSchema, customerIoBroadcastSchema, customerIoCampaignSchema, customerIoSegmentSchema, externalVideoSchema, getObjectTypeDefinition, imageSchema, integrationSchema, intelligemsExperienceSchema, levantaAffiliateLinkSchema, levantaProductSchema, looxReviewSchema, mediaImageSchema, mediaSchema, metafieldSchema, okendoReviewSchema, optionValueSchema, optionValueSwatchSchema, opusClipSchema, opusCollectionSchema, opusProjectSchema, pageSchema, planSchema, previewImageSchema, priceSchema, productOptionSchema, productSchema, registryItemSchema, segmentSourceSchema, selectedOptionSchema, transformReploProductToCanonical, variantSchema, videoSchema, videoSourceSchema, vwoCampaignSchema } from '../../chunk-77XUQJHY.mjs';
2
2
  import '../../chunk-4TZVNC3W.mjs';
@@ -18,6 +18,7 @@ import { z } from "zod";
18
18
  * registry Worker does not host preview blobs anymore.
19
19
  */
20
20
  export declare const registryItemTypeSchema: z.ZodEnum<{
21
+ product: "product";
21
22
  plan: "plan";
22
23
  site: "site";
23
24
  page: "page";
@@ -54,6 +55,25 @@ export declare const skillRegistryItemMetadataSchema: z.ZodObject<{
54
55
  command: z.ZodOptional<z.ZodString>;
55
56
  tagline: z.ZodOptional<z.ZodString>;
56
57
  }, z.core.$strict>;
58
+ export declare const productRegistryItemMetadataSchema: z.ZodObject<{
59
+ provider: z.ZodString;
60
+ providerDisplayName: z.ZodString;
61
+ providerProductId: z.ZodString;
62
+ productType: z.ZodDefault<z.ZodNullable<z.ZodString>>;
63
+ productTypeName: z.ZodDefault<z.ZodNullable<z.ZodString>>;
64
+ categoryIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
65
+ defaultVariantId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
66
+ capabilities: z.ZodObject<{
67
+ mockupGeneration: z.ZodBoolean;
68
+ fileUpload: z.ZodBoolean;
69
+ productCreation: z.ZodBoolean;
70
+ orderFulfillment: z.ZodBoolean;
71
+ variantEditing: z.ZodBoolean;
72
+ }, z.core.$strict>;
73
+ techniques: z.ZodDefault<z.ZodArray<z.ZodString>>;
74
+ colors: z.ZodDefault<z.ZodArray<z.ZodString>>;
75
+ sizes: z.ZodDefault<z.ZodArray<z.ZodString>>;
76
+ }, z.core.$strict>;
57
77
  export declare const genericRegistryItemMetadataSchema: z.ZodUnion<readonly [z.ZodObject<{
58
78
  brandName: z.ZodOptional<z.ZodString>;
59
79
  brandDomain: z.ZodOptional<z.ZodString>;
@@ -74,12 +94,31 @@ export declare const genericRegistryItemMetadataSchema: z.ZodUnion<readonly [z.Z
74
94
  logoUrl: z.ZodOptional<z.ZodString>;
75
95
  faviconUrl: z.ZodOptional<z.ZodString>;
76
96
  tagline: z.ZodOptional<z.ZodString>;
97
+ }, z.core.$strict>, z.ZodObject<{
98
+ provider: z.ZodString;
99
+ providerDisplayName: z.ZodString;
100
+ providerProductId: z.ZodString;
101
+ productType: z.ZodDefault<z.ZodNullable<z.ZodString>>;
102
+ productTypeName: z.ZodDefault<z.ZodNullable<z.ZodString>>;
103
+ categoryIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
104
+ defaultVariantId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
105
+ capabilities: z.ZodObject<{
106
+ mockupGeneration: z.ZodBoolean;
107
+ fileUpload: z.ZodBoolean;
108
+ productCreation: z.ZodBoolean;
109
+ orderFulfillment: z.ZodBoolean;
110
+ variantEditing: z.ZodBoolean;
111
+ }, z.core.$strict>;
112
+ techniques: z.ZodDefault<z.ZodArray<z.ZodString>>;
113
+ colors: z.ZodDefault<z.ZodArray<z.ZodString>>;
114
+ sizes: z.ZodDefault<z.ZodArray<z.ZodString>>;
77
115
  }, z.core.$strict>]>;
78
116
  export declare const registryItemMetadataSchema: z.ZodObject<{
79
117
  id: z.ZodString;
80
118
  slug: z.ZodString;
81
119
  name: z.ZodString;
82
120
  type: z.ZodEnum<{
121
+ product: "product";
83
122
  plan: "plan";
84
123
  site: "site";
85
124
  page: "page";
@@ -107,6 +146,24 @@ export declare const registryItemMetadataSchema: z.ZodObject<{
107
146
  logoUrl: z.ZodOptional<z.ZodString>;
108
147
  faviconUrl: z.ZodOptional<z.ZodString>;
109
148
  tagline: z.ZodOptional<z.ZodString>;
149
+ }, z.core.$strict>, z.ZodObject<{
150
+ provider: z.ZodString;
151
+ providerDisplayName: z.ZodString;
152
+ providerProductId: z.ZodString;
153
+ productType: z.ZodDefault<z.ZodNullable<z.ZodString>>;
154
+ productTypeName: z.ZodDefault<z.ZodNullable<z.ZodString>>;
155
+ categoryIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
156
+ defaultVariantId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
157
+ capabilities: z.ZodObject<{
158
+ mockupGeneration: z.ZodBoolean;
159
+ fileUpload: z.ZodBoolean;
160
+ productCreation: z.ZodBoolean;
161
+ orderFulfillment: z.ZodBoolean;
162
+ variantEditing: z.ZodBoolean;
163
+ }, z.core.$strict>;
164
+ techniques: z.ZodDefault<z.ZodArray<z.ZodString>>;
165
+ colors: z.ZodDefault<z.ZodArray<z.ZodString>>;
166
+ sizes: z.ZodDefault<z.ZodArray<z.ZodString>>;
110
167
  }, z.core.$strict>]>>;
111
168
  projectId: z.ZodNullable<z.ZodString>;
112
169
  createdBy: z.ZodNullable<z.ZodString>;
@@ -127,6 +184,7 @@ export declare const registryListItemsResultSchema: z.ZodObject<{
127
184
  slug: z.ZodString;
128
185
  name: z.ZodString;
129
186
  type: z.ZodEnum<{
187
+ product: "product";
130
188
  plan: "plan";
131
189
  site: "site";
132
190
  page: "page";
@@ -154,6 +212,24 @@ export declare const registryListItemsResultSchema: z.ZodObject<{
154
212
  logoUrl: z.ZodOptional<z.ZodString>;
155
213
  faviconUrl: z.ZodOptional<z.ZodString>;
156
214
  tagline: z.ZodOptional<z.ZodString>;
215
+ }, z.core.$strict>, z.ZodObject<{
216
+ provider: z.ZodString;
217
+ providerDisplayName: z.ZodString;
218
+ providerProductId: z.ZodString;
219
+ productType: z.ZodDefault<z.ZodNullable<z.ZodString>>;
220
+ productTypeName: z.ZodDefault<z.ZodNullable<z.ZodString>>;
221
+ categoryIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
222
+ defaultVariantId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
223
+ capabilities: z.ZodObject<{
224
+ mockupGeneration: z.ZodBoolean;
225
+ fileUpload: z.ZodBoolean;
226
+ productCreation: z.ZodBoolean;
227
+ orderFulfillment: z.ZodBoolean;
228
+ variantEditing: z.ZodBoolean;
229
+ }, z.core.$strict>;
230
+ techniques: z.ZodDefault<z.ZodArray<z.ZodString>>;
231
+ colors: z.ZodDefault<z.ZodArray<z.ZodString>>;
232
+ sizes: z.ZodDefault<z.ZodArray<z.ZodString>>;
157
233
  }, z.core.$strict>]>>;
158
234
  projectId: z.ZodNullable<z.ZodString>;
159
235
  createdBy: z.ZodNullable<z.ZodString>;
@@ -181,6 +257,7 @@ export declare const registryItemDetailSchema: z.ZodObject<{
181
257
  slug: z.ZodString;
182
258
  name: z.ZodString;
183
259
  type: z.ZodEnum<{
260
+ product: "product";
184
261
  plan: "plan";
185
262
  site: "site";
186
263
  page: "page";
@@ -208,6 +285,24 @@ export declare const registryItemDetailSchema: z.ZodObject<{
208
285
  logoUrl: z.ZodOptional<z.ZodString>;
209
286
  faviconUrl: z.ZodOptional<z.ZodString>;
210
287
  tagline: z.ZodOptional<z.ZodString>;
288
+ }, z.core.$strict>, z.ZodObject<{
289
+ provider: z.ZodString;
290
+ providerDisplayName: z.ZodString;
291
+ providerProductId: z.ZodString;
292
+ productType: z.ZodDefault<z.ZodNullable<z.ZodString>>;
293
+ productTypeName: z.ZodDefault<z.ZodNullable<z.ZodString>>;
294
+ categoryIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
295
+ defaultVariantId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
296
+ capabilities: z.ZodObject<{
297
+ mockupGeneration: z.ZodBoolean;
298
+ fileUpload: z.ZodBoolean;
299
+ productCreation: z.ZodBoolean;
300
+ orderFulfillment: z.ZodBoolean;
301
+ variantEditing: z.ZodBoolean;
302
+ }, z.core.$strict>;
303
+ techniques: z.ZodDefault<z.ZodArray<z.ZodString>>;
304
+ colors: z.ZodDefault<z.ZodArray<z.ZodString>>;
305
+ sizes: z.ZodDefault<z.ZodArray<z.ZodString>>;
211
306
  }, z.core.$strict>]>>;
212
307
  projectId: z.ZodNullable<z.ZodString>;
213
308
  createdBy: z.ZodNullable<z.ZodString>;
@@ -228,6 +323,7 @@ export declare const registryItemContentSchema: z.ZodObject<{
228
323
  id: z.ZodString;
229
324
  slug: z.ZodString;
230
325
  type: z.ZodEnum<{
326
+ product: "product";
231
327
  plan: "plan";
232
328
  site: "site";
233
329
  page: "page";
@@ -1,5 +1,5 @@
1
1
  import { parseJsonOrNull } from '../../chunk-VKO7P3ED.mjs';
2
- import { exhaustiveSwitch } from '../../chunk-XK2K3263.mjs';
2
+ import { exhaustiveSwitch } from '../../chunk-MSIQX4QA.mjs';
3
3
  import '../../chunk-GV5FY7ZZ.mjs';
4
4
  import { z } from 'zod';
5
5
 
@@ -3,5 +3,5 @@ type MethodQueueOptions = {
3
3
  queueName?: string;
4
4
  onTimeout?: () => void;
5
5
  };
6
- export declare function createMethodQueue<T extends Record<string, (...args: any[]) => any>>(checkInstanceReady: () => T | null, options?: MethodQueueOptions): (method: keyof T, ...args: any[]) => void;
6
+ export declare function createMethodQueue<InstanceType extends Record<string, (...args: any[]) => any>>(checkInstanceReady: () => InstanceType | null, options?: MethodQueueOptions): (method: keyof InstanceType, ...args: any[]) => void;
7
7
  export {};
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../analytics/utils/analytics-utils.ts"],
4
- "sourcesContent": ["// oxlint-disable-next-line typescript/no-explicit-any -- legacy any, may or may not be needed\ntype QueuedEvent = { event: string; params: Record<string, any> };\n\nexport function createEventQueue(\n checkPixelReady: () => boolean,\n // oxlint-disable-next-line typescript/no-explicit-any -- legacy any, may or may not be needed\n sendEvent: (event: string, params: Record<string, any>) => void,\n pixelName: string,\n // oxlint-disable-next-line typescript/no-explicit-any -- legacy any, may or may not be needed\n): (event: string, params?: Record<string, any>) => void {\n const queue: QueuedEvent[] = [];\n let flushTimer: number | null = null;\n let timeoutTimer: number | null = null;\n let permanentlyDisabled = false;\n\n const cleanup = () => {\n if (flushTimer !== null) {\n window.clearInterval(flushTimer);\n flushTimer = null;\n }\n if (timeoutTimer !== null) {\n window.clearTimeout(timeoutTimer);\n timeoutTimer = null;\n }\n };\n\n const flush = () => {\n if (!checkPixelReady()) {\n return;\n }\n console.debug(\n `[analytics] flushing ${queue.length} queued events for ${pixelName}`,\n );\n try {\n queue.forEach(({ event, params }) => sendEvent(event, params));\n } finally {\n queue.length = 0;\n cleanup();\n }\n };\n\n const scheduleFlush = () => {\n if (typeof window === \"undefined\" || flushTimer !== null) {\n return;\n }\n\n flushTimer = window.setInterval(flush, 500);\n timeoutTimer = window.setTimeout(() => {\n queue.length = 0;\n permanentlyDisabled = true;\n console.debug(\n `Analytics queue timed out after 30 seconds for ${pixelName}`,\n );\n cleanup();\n }, 30_000);\n };\n\n // oxlint-disable-next-line typescript/no-explicit-any -- legacy any, may or may not be needed\n return (event: string, params: Record<string, any> = {}) => {\n if (permanentlyDisabled) {\n console.debug(\n `[analytics] ${pixelName} queue is disabled, dropping event`,\n event,\n );\n return;\n }\n\n if (checkPixelReady()) {\n sendEvent(event, params);\n } else {\n queue.push({ event, params });\n scheduleFlush();\n }\n };\n}\n\ntype MethodQueueOptions = {\n queueName?: string;\n onTimeout?: () => void;\n};\n\nexport function createMethodQueue<\n // oxlint-disable-next-line typescript/no-explicit-any -- legacy any, may or may not be needed\n T extends Record<string, (...args: any[]) => any>,\n>(\n checkInstanceReady: () => T | null,\n options?: MethodQueueOptions,\n // oxlint-disable-next-line typescript/no-explicit-any -- legacy any, may or may not be needed\n): (method: keyof T, ...args: any[]) => void {\n // oxlint-disable-next-line typescript/no-explicit-any -- legacy any, may or may not be needed\n const queue: { method: keyof T; args: any[] }[] = [];\n let flushTimer: number | null = null;\n let timeoutTimer: number | null = null;\n let permanentlyDisabled = false;\n const queueName = options?.queueName ?? \"method queue\";\n\n const cleanup = () => {\n if (flushTimer !== null) {\n window.clearInterval(flushTimer);\n flushTimer = null;\n }\n if (timeoutTimer !== null) {\n window.clearTimeout(timeoutTimer);\n timeoutTimer = null;\n }\n };\n\n const flush = () => {\n const instance = checkInstanceReady();\n if (!instance) {\n return;\n }\n try {\n queue.forEach(({ method, args }) => {\n const methodFunction = instance[method];\n if (typeof methodFunction === \"function\") {\n void methodFunction.apply(instance, args);\n }\n });\n } finally {\n queue.length = 0;\n cleanup();\n }\n };\n\n const scheduleFlush = () => {\n if (typeof window === \"undefined\" || flushTimer !== null) {\n return;\n }\n\n flushTimer = window.setInterval(flush, 500);\n timeoutTimer = window.setTimeout(() => {\n queue.length = 0;\n permanentlyDisabled = true;\n if (typeof window !== \"undefined\") {\n console.debug(\n `[analytics] ${queueName} timed out after 30 seconds and has been disabled`,\n );\n }\n options?.onTimeout?.();\n cleanup();\n }, 30_000);\n };\n\n // oxlint-disable-next-line typescript/no-explicit-any -- legacy any, may or may not be needed\n return (method: keyof T, ...args: any[]) => {\n if (permanentlyDisabled) {\n return;\n }\n\n const instance = checkInstanceReady();\n if (instance) {\n const methodFunction = instance[method];\n if (typeof methodFunction === \"function\") {\n void methodFunction.apply(instance, args);\n }\n } else {\n queue.push({ method, args });\n scheduleFlush();\n }\n };\n}\n"],
5
- "mappings": "AAGO,SAAS,iBACd,iBAEA,WACA,WAEuD;AACvD,QAAM,QAAuB,CAAC;AAC9B,MAAI,aAA4B;AAChC,MAAI,eAA8B;AAClC,MAAI,sBAAsB;AAE1B,QAAM,UAAU,MAAM;AACpB,QAAI,eAAe,MAAM;AACvB,aAAO,cAAc,UAAU;AAC/B,mBAAa;AAAA,IACf;AACA,QAAI,iBAAiB,MAAM;AACz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qBAAe;AAAA,IACjB;AAAA,EACF;AAEA,QAAM,QAAQ,MAAM;AAClB,UAAM,WAAW,mBAAmB;AACpC,QAAI,CAAC,UAAU;AACb;AAAA,IACF;AACA,QAAI;AACF,YAAM,QAAQ,CAAC,EAAE,QAAQ,KAAK,MAAM;AAClC,cAAM,iBAAiB,SAAS,MAAM;AACtC,YAAI,OAAO,mBAAmB,YAAY;AACxC,eAAK,eAAe,MAAM,UAAU,IAAI;AAAA,QAC1C;AAAA,MACF,CAAC;AAAA,IACH,UAAE;AACA,YAAM,SAAS;AACf,cAAQ;AAAA,IACV;AAAA,EACF;AAEA,QAAM,gBAAgB,MAAM;AAC1B,QAAI,OAAO,WAAW,eAAe,eAAe,MAAM;AACxD;AAAA,IACF;AAEA,iBAAa,OAAO,YAAY,OAAO,GAAG;AAC1C,mBAAe,OAAO,WAAW,MAAM;AACrC,YAAM,SAAS;AACf,4BAAsB;AACtB,UAAI,OAAO,WAAW,aAAa;AACjC,gBAAQ;AAAA,UACN,eAAe,SAAS;AAAA,QAC1B;AAAA,MACF;AACA,eAAS,YAAY;AACrB,cAAQ;AAAA,IACV,GAAG,GAAM;AAAA,EACX;AAGA,SAAO,CAAC,WAAoB,SAAgB;AAC1C,QAAI,qBAAqB;AACvB;AAAA,IACF;AAEA,UAAM,WAAW,mBAAmB;AACpC,QAAI,UAAU;AACZ,YAAM,iBAAiB,SAAS,MAAM;AACtC,UAAI,OAAO,mBAAmB,YAAY;AACxC,aAAK,eAAe,MAAM,UAAU,IAAI;AAAA,MAC1C;AAAA,IACF,OAAO;AACL,YAAM,KAAK,EAAE,QAAQ,KAAK,CAAC;AAC3B,oBAAc;AAAA,IAChB;AAAA,EACF;AACF;",
4
+ "sourcesContent": ["// oxlint-disable-next-line typescript/no-explicit-any -- legacy any, may or may not be needed\ntype QueuedEvent = { event: string; params: Record<string, any> };\n\nexport function createEventQueue(\n checkPixelReady: () => boolean,\n // oxlint-disable-next-line typescript/no-explicit-any -- legacy any, may or may not be needed\n sendEvent: (event: string, params: Record<string, any>) => void,\n pixelName: string,\n // oxlint-disable-next-line typescript/no-explicit-any -- legacy any, may or may not be needed\n): (event: string, params?: Record<string, any>) => void {\n const queue: QueuedEvent[] = [];\n let flushTimer: number | null = null;\n let timeoutTimer: number | null = null;\n let permanentlyDisabled = false;\n\n const cleanup = () => {\n if (flushTimer !== null) {\n window.clearInterval(flushTimer);\n flushTimer = null;\n }\n if (timeoutTimer !== null) {\n window.clearTimeout(timeoutTimer);\n timeoutTimer = null;\n }\n };\n\n const flush = () => {\n if (!checkPixelReady()) {\n return;\n }\n console.debug(\n `[analytics] flushing ${queue.length} queued events for ${pixelName}`,\n );\n try {\n queue.forEach(({ event, params }) => sendEvent(event, params));\n } finally {\n queue.length = 0;\n cleanup();\n }\n };\n\n const scheduleFlush = () => {\n if (typeof window === \"undefined\" || flushTimer !== null) {\n return;\n }\n\n flushTimer = window.setInterval(flush, 500);\n timeoutTimer = window.setTimeout(() => {\n queue.length = 0;\n permanentlyDisabled = true;\n console.debug(\n `Analytics queue timed out after 30 seconds for ${pixelName}`,\n );\n cleanup();\n }, 30_000);\n };\n\n // oxlint-disable-next-line typescript/no-explicit-any -- legacy any, may or may not be needed\n return (event: string, params: Record<string, any> = {}) => {\n if (permanentlyDisabled) {\n console.debug(\n `[analytics] ${pixelName} queue is disabled, dropping event`,\n event,\n );\n return;\n }\n\n if (checkPixelReady()) {\n sendEvent(event, params);\n } else {\n queue.push({ event, params });\n scheduleFlush();\n }\n };\n}\n\ntype MethodQueueOptions = {\n queueName?: string;\n onTimeout?: () => void;\n};\n\nexport function createMethodQueue<\n // oxlint-disable-next-line typescript/no-explicit-any -- legacy any, may or may not be needed\n InstanceType extends Record<string, (...args: any[]) => any>,\n>(\n checkInstanceReady: () => InstanceType | null,\n options?: MethodQueueOptions,\n // oxlint-disable-next-line typescript/no-explicit-any -- legacy any, may or may not be needed\n): (method: keyof InstanceType, ...args: any[]) => void {\n // oxlint-disable-next-line typescript/no-explicit-any -- legacy any, may or may not be needed\n const queue: { method: keyof InstanceType; args: any[] }[] = [];\n let flushTimer: number | null = null;\n let timeoutTimer: number | null = null;\n let permanentlyDisabled = false;\n const queueName = options?.queueName ?? \"method queue\";\n\n const cleanup = () => {\n if (flushTimer !== null) {\n window.clearInterval(flushTimer);\n flushTimer = null;\n }\n if (timeoutTimer !== null) {\n window.clearTimeout(timeoutTimer);\n timeoutTimer = null;\n }\n };\n\n const flush = () => {\n const instance = checkInstanceReady();\n if (!instance) {\n return;\n }\n try {\n queue.forEach(({ method, args }) => {\n const methodFunction = instance[method];\n if (typeof methodFunction === \"function\") {\n void methodFunction.apply(instance, args);\n }\n });\n } finally {\n queue.length = 0;\n cleanup();\n }\n };\n\n const scheduleFlush = () => {\n if (typeof window === \"undefined\" || flushTimer !== null) {\n return;\n }\n\n flushTimer = window.setInterval(flush, 500);\n timeoutTimer = window.setTimeout(() => {\n queue.length = 0;\n permanentlyDisabled = true;\n if (typeof window !== \"undefined\") {\n console.debug(\n `[analytics] ${queueName} timed out after 30 seconds and has been disabled`,\n );\n }\n options?.onTimeout?.();\n cleanup();\n }, 30_000);\n };\n\n // oxlint-disable-next-line typescript/no-explicit-any -- legacy any, may or may not be needed\n return (method: keyof InstanceType, ...args: any[]) => {\n if (permanentlyDisabled) {\n return;\n }\n\n const instance = checkInstanceReady();\n if (instance) {\n const methodFunction = instance[method];\n if (typeof methodFunction === \"function\") {\n void methodFunction.apply(instance, args);\n }\n } else {\n queue.push({ method, args });\n scheduleFlush();\n }\n };\n}\n"],
5
+ "mappings": "AAGO,SAAS,iBACd,iBAEA,WACA,WAEuD;AACvD,QAAM,QAAuB,CAAC;AAC9B,MAAI,aAA4B;AAChC,MAAI,eAA8B;AAClC,MAAI,sBAAsB;AAE1B,QAAM,UAAU,MAAM;AACpB,QAAI,eAAe,MAAM;AACvB,aAAO,cAAc,UAAU;AAC/B,mBAAa;AAAA,IACf;AACA,QAAI,iBAAiB,MAAM;AACzB,aAAO,aAAa,YA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jB;AAAA,EACF;AAEA,QAAM,QAAQ,MAAM;AAClB,UAAM,WAAW,mBAAmB;AACpC,QAAI,CAAC,UAAU;AACb;AAAA,IACF;AACA,QAAI;AACF,YAAM,QAAQ,CAAC,EAAE,QAAQ,KAAK,MAAM;AAClC,cAAM,iBAAiB,SAAS,MAAM;AACtC,YAAI,OAAO,mBAAmB,YAAY;AACxC,eAAK,eAAe,MAAM,UAAU,IAAI;AAAA,QAC1C;AAAA,MACF,CAAC;AAAA,IACH,UAAE;AACA,YAAM,SAAS;AACf,cAAQ;AAAA,IACV;AAAA,EACF;AAEA,QAAM,gBAAgB,MAAM;AAC1B,QAAI,OAAO,WAAW,eAAe,eAAe,MAAM;AACxD;AAAA,IACF;AAEA,iBAAa,OAAO,YAAY,OAAO,GAAG;AAC1C,mBAAe,OAAO,WAAW,MAAM;AACrC,YAAM,SAAS;AACf,4BAAsB;AACtB,UAAI,OAAO,WAAW,aAAa;AACjC,gBAAQ;AAAA,UACN,eAAe,SAAS;AAAA,QAC1B;AAAA,MACF;AACA,eAAS,YAAY;AACrB,cAAQ;AAAA,IACV,GAAG,GAAM;AAAA,EACX;AAGA,SAAO,CAAC,WAA+B,SAAgB;AACrD,QAAI,qBAAqB;AACvB;AAAA,IACF;AAEA,UAAM,WAAW,mBAAmB;AACpC,QAAI,UAAU;AACZ,YAAM,iBAAiB,SAAS,MAAM;AACtC,UAAI,OAAO,mBAAmB,YAAY;AACxC,aAAK,eAAe,MAAM,UAAU,IAAI;AAAA,MAC1C;AAAA,IACF,OAAO;AACL,YAAM,KAAK,EAAE,QAAQ,KAAK,CAAC;AAC3B,oBAAc;AAAA,IAChB;AAAA,EACF;AACF;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  import { sellingPlanGroupSchema } from './chunk-4TZVNC3W.mjs';
2
2
  import { z } from 'zod';
3
3
 
4
- var registryItemTypeSchema = z.enum(["site", "page", "section", "skill", "plan", "branding"]).describe("RegistryItemType");
4
+ var registryItemTypeSchema = z.enum(["site", "page", "section", "skill", "plan", "branding", "product"]).describe("RegistryItemType");
5
5
  z.object({
6
6
  sourceType: z.string().min(1).max(80),
7
7
  sourceKey: z.string().min(1).max(512)
@@ -24,12 +24,32 @@ var skillRegistryItemMetadataSchema = z.object({
24
24
  command: z.string().optional(),
25
25
  tagline: z.string().optional()
26
26
  }).strict().describe("SkillRegistryItemMetadata");
27
+ var productRegistryItemMetadataSchema = z.object({
28
+ provider: z.string(),
29
+ providerDisplayName: z.string(),
30
+ providerProductId: z.string(),
31
+ productType: z.string().nullable().default(null),
32
+ productTypeName: z.string().nullable().default(null),
33
+ categoryIds: z.array(z.string()).default([]),
34
+ defaultVariantId: z.string().nullable().optional(),
35
+ capabilities: z.object({
36
+ mockupGeneration: z.boolean(),
37
+ fileUpload: z.boolean(),
38
+ productCreation: z.boolean(),
39
+ orderFulfillment: z.boolean(),
40
+ variantEditing: z.boolean()
41
+ }).strict(),
42
+ techniques: z.array(z.string()).default([]),
43
+ colors: z.array(z.string()).default([]),
44
+ sizes: z.array(z.string()).default([])
45
+ }).strict().describe("ProductRegistryItemMetadata");
27
46
  var genericRegistryItemMetadataSchema = z.union([
28
47
  siteRegistryItemMetadataSchema,
29
48
  pageRegistryItemMetadataSchema,
30
49
  sectionRegistryItemMetadataSchema,
31
50
  skillRegistryItemMetadataSchema,
32
- brandingRegistryItemMetadataSchema
51
+ brandingRegistryItemMetadataSchema,
52
+ productRegistryItemMetadataSchema
33
53
  ]).describe("GenericRegistryItemMetadata");
34
54
  var registryItemMetadataSchema = z.object({
35
55
  id: z.string(),
@@ -1424,11 +1424,11 @@ function isPrimitive(value) {
1424
1424
  function exhaustiveSwitch(value, discriminantKey = "type") {
1425
1425
  return (cases) => {
1426
1426
  const discriminant = value[discriminantKey];
1427
- const f = cases[discriminant];
1428
- if (!isFunction_default(f)) {
1429
- return f;
1427
+ const caseHandler = cases[discriminant];
1428
+ if (!isFunction_default(caseHandler)) {
1429
+ return caseHandler;
1430
1430
  }
1431
- return f(value);
1431
+ return caseHandler(value);
1432
1432
  };
1433
1433
  }
1434
1434
  function isEmpty2(value) {
@@ -1466,12 +1466,14 @@ function invariant(condition, message, opts) {
1466
1466
  throw new Error(text);
1467
1467
  }
1468
1468
  var mergeReplacingObjects = (first, second) => {
1469
- mergeWith_default(first, second, (_a, b) => {
1470
- return isObject_default(b) && isEmpty2(b) ? b : void 0;
1469
+ mergeWith_default(first, second, (_first, value) => {
1470
+ return isObject_default(value) && isEmpty2(value) ? value : void 0;
1471
1471
  });
1472
1472
  };
1473
1473
  var mergeReplacingArrays = (first, second) => {
1474
- mergeWith_default(first, second, (_a, b) => isArray_default(b) ? b : void 0);
1474
+ mergeWith_default(first, second, (_first, value) => {
1475
+ return isArray_default(value) ? value : void 0;
1476
+ });
1475
1477
  };
1476
1478
  var deepCloneAndMergeReplacingArrays = (source, ...toMerge) => {
1477
1479
  const copy = cloneDeep_default(source);
@@ -19,4 +19,10 @@ export declare function recordConsentAction(decision: {
19
19
  categories: ConsentCategories;
20
20
  consentMode: ConsentMode;
21
21
  decidedAt: number;
22
+ /**
23
+ * Site-owned policy version declared by the consent caller (via
24
+ * `useConsent({ version })`); the site bumps it when the banner copy or
25
+ * category set changes.
26
+ */
27
+ policyVersion: number;
22
28
  }): Promise<void>;
@@ -1,7 +1,6 @@
1
1
  "use server";
2
2
  import { headers } from "next/headers";
3
3
  import { getEnv } from "../env";
4
- const CONSENT_POLICY_VERSION = 1;
5
4
  async function recordConsentAction(decision) {
6
5
  try {
7
6
  const { PROJECT_ID, ANALYTICS_FIRE_API_URL } = await getEnv();
@@ -16,7 +15,7 @@ async function recordConsentAction(decision) {
16
15
  action: decision.action,
17
16
  categories: decision.categories,
18
17
  consentMode: decision.consentMode,
19
- policyVersion: CONSENT_POLICY_VERSION
18
+ policyVersion: decision.policyVersion
20
19
  };
21
20
  await fetch(`${ANALYTICS_FIRE_API_URL}/api/v1/consent`, {
22
21
  method: "POST",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../consent/consent-actions.ts"],
4
- "sourcesContent": ["\"use server\";\n\nimport type {\n ConsentAction,\n ConsentMode,\n ConsentRecordRequest,\n} from \"schemas/generated/consent\";\nimport type { ConsentCategories } from \"./cookie\";\n\nimport { headers } from \"next/headers\";\n\nimport { getEnv } from \"../env\";\n\n// Bumped when the banner copy or category set changes. Lives here (server-side)\n// so the site layout never has to carry a policy version.\nconst CONSENT_POLICY_VERSION = 1;\n\n/**\n * Records a proof-of-consent decision by forwarding it to analytics-fire.\n *\n * Runs server-side \u2014 exactly like the cart's actions \u2014 so the browser never needs\n * the project id or the analytics-fire URL: both are read from the worker env\n * here via `getEnv()`. The visitor's user-agent / referrer / coarse geo come from\n * the incoming request headers and are forwarded so analytics-fire derives them\n * the same way it does for the legacy pixel.\n *\n * Best-effort and self-disabling: no-ops when analytics-fire isn't configured\n * (e.g. lean local dev) and never throws into the page.\n */\nexport async function recordConsentAction(decision: {\n consentId: string;\n action: ConsentAction;\n /** Full resulting consent state (all categories), not a diff. */\n categories: ConsentCategories;\n consentMode: ConsentMode;\n decidedAt: number;\n}) {\n // Best-effort and total: never reject (the caller fire-and-forgets it), even if\n // the Cloudflare env / request context is unavailable.\n try {\n const { PROJECT_ID, ANALYTICS_FIRE_API_URL } = await getEnv();\n if (!ANALYTICS_FIRE_API_URL) {\n return;\n }\n\n const incoming = await headers();\n const body: ConsentRecordRequest = {\n consentId: decision.consentId,\n projectId: PROJECT_ID,\n decidedAt: decision.decidedAt,\n action: decision.action,\n categories: decision.categories,\n consentMode: decision.consentMode,\n policyVersion: CONSENT_POLICY_VERSION,\n };\n\n await fetch(`${ANALYTICS_FIRE_API_URL}/api/v1/consent`, {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n \"user-agent\": incoming.get(\"user-agent\") ?? \"\",\n referer: incoming.get(\"referer\") ?? \"\",\n \"cf-ipcountry\": incoming.get(\"cf-ipcountry\") ?? \"\",\n },\n body: JSON.stringify(body),\n });\n } catch {\n // Consent logging must never surface an error in the page.\n }\n}\n"],
5
- "mappings": ";AASA,SAAS,eAAe;AAExB,SAAS,cAAc;AAIvB,MAAM,yBAAyB;AAc/B,eAAsB,oBAAoB,UAOvC;AAGD,MAAI;AACF,UAAM,EAAE,YAAY,uBAAuB,IAAI,MAAM,OAAO;AAC5D,QAAI,CAAC,wBAAwB;AAC3B;AAAA,IACF;AAEA,UAAM,WAAW,MAAM,QAAQ;AAC/B,UAAM,OAA6B;AAAA,MACjC,WAAW,SAAS;AAAA,MACpB,WAAW;AAAA,MACX,WAAW,SAAS;AAAA,MACpB,QAAQ,SAAS;AAAA,MACjB,YAAY,SAAS;AAAA,MACrB,aAAa,SAAS;AAAA,MACtB,eAAe;AAAA,IACjB;AAEA,UAAM,MAAM,GAAG,sBAAsB,mBAAmB;AAAA,MACtD,QAAQ;AAAA,MACR,SAAS;AAAA,QACP,gBAAgB;AAAA,QAChB,cAAc,SAAS,IAAI,YAAY,KAAK;AAAA,QAC5C,SAAS,SAAS,IAAI,SAAS,KAAK;AAAA,QACpC,gBAAgB,SAAS,IAAI,cAAc,KAAK;AAAA,MAClD;AAAA,MACA,MAAM,KAAK,UAAU,IAAI;AAAA,IAC3B,CAAC;AAAA,EACH,QAAQ;AAAA,EAER;AACF;",
4
+ "sourcesContent": ["\"use server\";\n\nimport type {\n ConsentAction,\n ConsentMode,\n ConsentRecordRequest,\n} from \"schemas/generated/consent\";\nimport type { ConsentCategories } from \"./cookie\";\n\nimport { headers } from \"next/headers\";\n\nimport { getEnv } from \"../env\";\n\n/**\n * Records a proof-of-consent decision by forwarding it to analytics-fire.\n *\n * Runs server-side \u2014 exactly like the cart's actions \u2014 so the browser never needs\n * the project id or the analytics-fire URL: both are read from the worker env\n * here via `getEnv()`. The visitor's user-agent / referrer / coarse geo come from\n * the incoming request headers and are forwarded so analytics-fire derives them\n * the same way it does for the legacy pixel.\n *\n * Best-effort and self-disabling: no-ops when analytics-fire isn't configured\n * (e.g. lean local dev) and never throws into the page.\n */\nexport async function recordConsentAction(decision: {\n consentId: string;\n action: ConsentAction;\n /** Full resulting consent state (all categories), not a diff. */\n categories: ConsentCategories;\n consentMode: ConsentMode;\n decidedAt: number;\n /**\n * Site-owned policy version declared by the consent caller (via\n * `useConsent({ version })`); the site bumps it when the banner copy or\n * category set changes.\n */\n policyVersion: number;\n}) {\n // Best-effort and total: never reject (the caller fire-and-forgets it), even if\n // the Cloudflare env / request context is unavailable.\n try {\n const { PROJECT_ID, ANALYTICS_FIRE_API_URL } = await getEnv();\n if (!ANALYTICS_FIRE_API_URL) {\n return;\n }\n\n const incoming = await headers();\n const body: ConsentRecordRequest = {\n consentId: decision.consentId,\n projectId: PROJECT_ID,\n decidedAt: decision.decidedAt,\n action: decision.action,\n categories: decision.categories,\n consentMode: decision.consentMode,\n policyVersion: decision.policyVersion,\n };\n\n await fetch(`${ANALYTICS_FIRE_API_URL}/api/v1/consent`, {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n \"user-agent\": incoming.get(\"user-agent\") ?? \"\",\n referer: incoming.get(\"referer\") ?? \"\",\n \"cf-ipcountry\": incoming.get(\"cf-ipcountry\") ?? \"\",\n },\n body: JSON.stringify(body),\n });\n } catch {\n // Consent logging must never surface an error in the page.\n }\n}\n"],
5
+ "mappings": ";AASA,SAAS,eAAe;AAExB,SAAS,cAAc;AAcvB,eAAsB,oBAAoB,UAavC;AAGD,MAAI;AACF,UAAM,EAAE,YAAY,uBAAuB,IAAI,MAAM,OAAO;AAC5D,QAAI,CAAC,wBAAwB;AAC3B;AAAA,IACF;AAEA,UAAM,WAAW,MAAM,QAAQ;AAC/B,UAAM,OAA6B;AAAA,MACjC,WAAW,SAAS;AAAA,MACpB,WAAW;AAAA,MACX,WAAW,SAAS;AAAA,MACpB,QAAQ,SAAS;AAAA,MACjB,YAAY,SAAS;AAAA,MACrB,aAAa,SAAS;AAAA,MACtB,eAAe,SAAS;AAAA,IAC1B;AAEA,UAAM,MAAM,GAAG,sBAAsB,mBAAmB;AAAA,MACtD,QAAQ;AAAA,MACR,SAAS;AAAA,QACP,gBAAgB;AAAA,QAChB,cAAc,SAAS,IAAI,YAAY,KAAK;AAAA,QAC5C,SAAS,SAAS,IAAI,SAAS,KAAK;AAAA,QACpC,gBAAgB,SAAS,IAAI,cAAc,KAAK;AAAA,MAClD;AAAA,MACA,MAAM,KAAK,UAAU,IAAI;AAAA,IAC3B,CAAC;AAAA,EACH,QAAQ;AAAA,EAER;AACF;",
6
6
  "names": []
7
7
  }
@@ -29,20 +29,35 @@ export declare const consentStore: {
29
29
  getServerSnapshot(): ConsentState;
30
30
  subscribe(listener: () => void): () => void;
31
31
  /** Grant every consent category. */
32
- accept(): void;
32
+ accept(options?: {
33
+ policyVersion?: number;
34
+ }): void;
33
35
  /** Deny every non-necessary category. */
34
- reject(): void;
36
+ reject(options?: {
37
+ policyVersion?: number;
38
+ }): void;
35
39
  /** Set a subset of categories, leaving the rest at their current value. */
36
- updateCategories(next: Partial<ConsentCategories>): void;
40
+ updateCategories({ next, policyVersion, }: {
41
+ next: Partial<ConsentCategories>;
42
+ policyVersion?: number;
43
+ }): void;
37
44
  /** Test-only: reset cached state so the next read recomputes. */
38
45
  reset(): void;
39
46
  };
47
+ export interface UseConsentOptions {
48
+ /**
49
+ * Site-owned consent policy version, stamped onto each proof-of-consent
50
+ * record so a decision can be tied to the exact banner the visitor saw.
51
+ * Bump it whenever the banner copy or category set changes. Defaults to 1.
52
+ */
53
+ version?: number;
54
+ }
40
55
  export interface UseConsentResult extends ConsentState {
41
56
  accept(): void;
42
57
  reject(): void;
43
58
  updateCategories(next: Partial<ConsentCategories>): void;
44
59
  }
45
- export declare function useConsent(): UseConsentResult;
60
+ export declare function useConsent(options?: UseConsentOptions): UseConsentResult;
46
61
  /**
47
62
  * Whether a script requiring `requiredConsent` is allowed to load right now.
48
63
  * `mode === "off"` always allows; otherwise every required category must be
@@ -33,6 +33,7 @@ function resolveMode() {
33
33
  const attribute = document.documentElement.dataset.reploConsentMode;
34
34
  return isConsentMode(attribute) ? attribute : "off";
35
35
  }
36
+ const DEFAULT_CONSENT_POLICY_VERSION = 1;
36
37
  function computeSnapshot() {
37
38
  if (typeof window === "undefined") {
38
39
  return SERVER_SNAPSHOT;
@@ -71,7 +72,10 @@ function notify() {
71
72
  listener();
72
73
  }
73
74
  }
74
- function commit(categories) {
75
+ function commit({
76
+ categories,
77
+ policyVersion = DEFAULT_CONSENT_POLICY_VERSION
78
+ }) {
75
79
  const previous = consentStore.getSnapshot();
76
80
  const decidedAt = Date.now();
77
81
  const consentId = previous.consentId ?? crypto.randomUUID();
@@ -101,7 +105,8 @@ function commit(categories) {
101
105
  action: deriveConsentAction({ previous, next: resultingCategories }),
102
106
  categories: resultingCategories,
103
107
  consentMode: previous.mode,
104
- decidedAt
108
+ decidedAt,
109
+ policyVersion
105
110
  }).finally(reloadIfDowngraded);
106
111
  } else {
107
112
  reloadIfDowngraded();
@@ -124,24 +129,37 @@ const consentStore = {
124
129
  };
125
130
  },
126
131
  /** Grant every consent category. */
127
- accept() {
128
- commit(GRANTED_CATEGORIES);
132
+ accept(options = {}) {
133
+ commit({
134
+ categories: GRANTED_CATEGORIES,
135
+ policyVersion: options.policyVersion
136
+ });
129
137
  },
130
138
  /** Deny every non-necessary category. */
131
- reject() {
132
- commit(DENIED_CATEGORIES);
139
+ reject(options = {}) {
140
+ commit({
141
+ categories: DENIED_CATEGORIES,
142
+ policyVersion: options.policyVersion
143
+ });
133
144
  },
134
145
  /** Set a subset of categories, leaving the rest at their current value. */
135
- updateCategories(next) {
146
+ updateCategories({
147
+ next,
148
+ policyVersion
149
+ }) {
136
150
  const current = consentStore.getSnapshot().categories;
137
- commit({ ...current, ...next, necessary: true });
151
+ commit({
152
+ categories: { ...current, ...next, necessary: true },
153
+ policyVersion
154
+ });
138
155
  },
139
156
  /** Test-only: reset cached state so the next read recomputes. */
140
157
  reset() {
141
158
  snapshot = null;
142
159
  }
143
160
  };
144
- function useConsent() {
161
+ function useConsent(options = {}) {
162
+ const policyVersion = options.version;
145
163
  const state = useSyncExternalStore(
146
164
  consentStore.subscribe,
147
165
  consentStore.getSnapshot,
@@ -149,9 +167,11 @@ function useConsent() {
149
167
  );
150
168
  return {
151
169
  ...state,
152
- accept: consentStore.accept,
153
- reject: consentStore.reject,
154
- updateCategories: consentStore.updateCategories
170
+ accept: () => consentStore.accept({ policyVersion }),
171
+ reject: () => consentStore.reject({ policyVersion }),
172
+ updateCategories: (next) => {
173
+ consentStore.updateCategories({ next, policyVersion });
174
+ }
155
175
  };
156
176
  }
157
177
  function isConsentAllowed({
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../consent/consent-store.ts"],
4
- "sourcesContent": ["\"use client\";\n\nimport type { ConsentCategory, ConsentMode } from \"schemas/generated/consent\";\nimport type { ConsentCategories } from \"./cookie\";\n\nimport { useSyncExternalStore } from \"react\";\n\nimport { deriveConsentAction } from \"./consent-action\";\nimport { recordConsentAction } from \"./consent-actions\";\nimport {\n CONSENT_COOKIE_MAX_AGE_SECONDS,\n CONSENT_COOKIE_NAME,\n DENIED_CATEGORIES,\n GRANTED_CATEGORIES,\n parseConsentCookie,\n serializeConsentCookieValue,\n} from \"./cookie\";\n\n/**\n * Framework-agnostic, cookie-backed consent store. Lives as a single module\n * singleton so `ReploScripts`, the site's consent banner, and `AnalyticsProvider`\n * all share the same state regardless of where they sit in the React tree \u2014 no\n * provider-ancestor relationship is required.\n *\n * Consent-dependent work (script injection, banner visibility) happens on the\n * client (effects / post-mount), so there is no SSR/hydration mismatch. The\n * client reads the (non-httpOnly) consent cookie directly, so no server seed is\n * needed. The whole-site `mode` comes from the `data-replo-consent-mode`\n * attribute on `<html>`.\n */\n\nexport interface ConsentState {\n mode: ConsentMode;\n categories: ConsentCategories;\n /** Epoch ms when the visitor last made a choice, or null if undecided. */\n decidedAt: number | null;\n /**\n * Persistent pseudonymous per-browser id linking a visitor's consent history.\n * Absent until the first `commit()` (and on legacy pre-id cookies, until the\n * next interaction lazily backfills it).\n */\n consentId?: string;\n}\n\n// The non-necessary categories a visitor can grant or revoke. `necessary` is\n// always granted and never toggled.\nconst TOGGLEABLE_CATEGORIES: Exclude<ConsentCategory, \"necessary\">[] = [\n \"analytics\",\n \"marketing\",\n \"preferences\",\n \"sale_of_data\",\n];\n\n// A stable reference for SSR / first hydration render. Consent-dependent DOM is\n// only produced on the client, so this constant never causes a mismatch.\nconst SERVER_SNAPSHOT: ConsentState = Object.freeze({\n mode: \"off\",\n categories: DENIED_CATEGORIES,\n decidedAt: null,\n});\n\nconst listeners = new Set<() => void>();\nlet snapshot: ConsentState | null = null;\n\nfunction isConsentMode(value: string | null | undefined): value is ConsentMode {\n return value === \"off\" || value === \"simple\" || value === \"per-category\";\n}\n\nfunction resolveMode(): ConsentMode {\n if (typeof window === \"undefined\") {\n return \"off\";\n }\n const attribute = document.documentElement.dataset.reploConsentMode;\n return isConsentMode(attribute) ? attribute : \"off\";\n}\n\nfunction computeSnapshot(): ConsentState {\n if (typeof window === \"undefined\") {\n return SERVER_SNAPSHOT;\n }\n\n const mode = resolveMode();\n\n const fromCookie = parseConsentCookie(document.cookie);\n if (fromCookie) {\n return {\n mode,\n categories: {\n necessary: true,\n analytics: fromCookie.categories.analytics,\n marketing: fromCookie.categories.marketing,\n preferences: fromCookie.categories.preferences,\n sale_of_data: fromCookie.categories.sale_of_data,\n },\n decidedAt: fromCookie.decidedAt,\n consentId: fromCookie.consentId,\n };\n }\n\n return { mode, categories: DENIED_CATEGORIES, decidedAt: null };\n}\n\nfunction writeCookie(\n categories: ConsentCategories,\n decidedAt: number,\n consentId: string,\n) {\n if (typeof document === \"undefined\") {\n return;\n }\n const value = serializeConsentCookieValue({\n categories,\n decidedAt,\n consentId,\n });\n document.cookie = `${CONSENT_COOKIE_NAME}=${value}; path=/; max-age=${CONSENT_COOKIE_MAX_AGE_SECONDS}; SameSite=Lax`;\n}\n\nfunction notify() {\n for (const listener of listeners) {\n listener();\n }\n}\n\nfunction commit(categories: ConsentCategories) {\n const previous = consentStore.getSnapshot();\n const decidedAt = Date.now();\n // Reuse the visitor's existing id, or mint one on the first decision (also\n // lazily backfills legacy pre-id cookies). `crypto.randomUUID` is available in\n // every browser we target and on the server (where commit() never runs).\n const consentId = previous.consentId ?? crypto.randomUUID();\n const resultingCategories: ConsentCategories = {\n ...categories,\n necessary: true,\n };\n writeCookie(categories, decidedAt, consentId);\n snapshot = {\n mode: previous.mode,\n categories: resultingCategories,\n decidedAt,\n consentId,\n };\n notify();\n\n // Revocation cannot unload an already-loaded vendor. If the visitor had\n // previously decided and is now turning a granted category off, reload so the\n // page renders without those scripts. Deferred until after the audit record is\n // sent so the reload doesn't cancel the in-flight server action.\n const wasDowngrade =\n previous.decidedAt !== null &&\n TOGGLEABLE_CATEGORIES.some((category) => {\n return previous.categories[category] && !categories[category];\n });\n const reloadIfDowngraded = () => {\n if (wasDowngrade && typeof window !== \"undefined\") {\n window.location.reload();\n }\n };\n\n // Proof-of-consent audit record (ungated by consent, but only on managed\n // sites). On `mode === \"off\"` there is no banner/consent UX, so a\n // `setTrackingConsent()` call from a third-party script would only produce\n // meaningless `consent_mode: \"off\"` noise \u2014 skip it. Egress runs through a\n // server action (like the cart) so the client never needs the project id or\n // analytics-fire URL.\n if (previous.mode !== \"off\") {\n void recordConsentAction({\n consentId,\n action: deriveConsentAction({ previous, next: resultingCategories }),\n categories: resultingCategories,\n consentMode: previous.mode,\n decidedAt,\n }).finally(reloadIfDowngraded);\n } else {\n reloadIfDowngraded();\n }\n}\n\nexport const consentStore = {\n getSnapshot(): ConsentState {\n if (!snapshot) {\n snapshot = computeSnapshot();\n }\n return snapshot;\n },\n getServerSnapshot(): ConsentState {\n return SERVER_SNAPSHOT;\n },\n subscribe(listener: () => void): () => void {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n },\n /** Grant every consent category. */\n accept() {\n commit(GRANTED_CATEGORIES);\n },\n /** Deny every non-necessary category. */\n reject() {\n commit(DENIED_CATEGORIES);\n },\n /** Set a subset of categories, leaving the rest at their current value. */\n updateCategories(next: Partial<ConsentCategories>) {\n const current = consentStore.getSnapshot().categories;\n commit({ ...current, ...next, necessary: true });\n },\n /** Test-only: reset cached state so the next read recomputes. */\n reset() {\n snapshot = null;\n },\n};\n\nexport interface UseConsentResult extends ConsentState {\n accept(): void;\n reject(): void;\n updateCategories(next: Partial<ConsentCategories>): void;\n}\n\nexport function useConsent(): UseConsentResult {\n const state = useSyncExternalStore(\n consentStore.subscribe,\n consentStore.getSnapshot,\n consentStore.getServerSnapshot,\n );\n return {\n ...state,\n accept: consentStore.accept,\n reject: consentStore.reject,\n updateCategories: consentStore.updateCategories,\n };\n}\n\n/**\n * Whether a script requiring `requiredConsent` is allowed to load right now.\n * `mode === \"off\"` always allows; otherwise every required category must be\n * granted. An empty requirement list is always allowed.\n */\nexport function isConsentAllowed({\n state,\n requiredConsent,\n}: {\n state: ConsentState;\n requiredConsent: ConsentCategory[];\n}): boolean {\n if (state.mode === \"off\") {\n return true;\n }\n if (requiredConsent.length === 0) {\n return true;\n }\n return requiredConsent.every((category) => state.categories[category]);\n}\n"],
5
- "mappings": ";AAKA,SAAS,4BAA4B;AAErC,SAAS,2BAA2B;AACpC,SAAS,2BAA2B;AACpC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AA8BP,MAAM,wBAAiE;AAAA,EACrE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAIA,MAAM,kBAAgC,OAAO,OAAO;AAAA,EAClD,MAAM;AAAA,EACN,YAAY;AAAA,EACZ,WAAW;AACb,CAAC;AAED,MAAM,YAAY,oBAAI,IAAgB;AACtC,IAAI,WAAgC;AAEpC,SAAS,cAAc,OAAwD;AAC7E,SAAO,UAAU,SAAS,UAAU,YAAY,UAAU;AAC5D;AAEA,SAAS,cAA2B;AAClC,MAAI,OAAO,WAAW,aAAa;AACjC,WAAO;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ACrB,kBAAkB,aAAa;AAAA,EACjC;AACF;AAOO,SAAS,iBAAiB;AAAA,EAC/B;AAAA,EACA;AACF,GAGY;AACV,MAAI,MAAM,SAAS,OAAO;AACxB,WAAO;AAAA,EACT;AACA,MAAI,gBAAgB,WAAW,GAAG;AAChC,WAAO;AAAA,EACT;AACA,SAAO,gBAAgB,MAAM,CAAC,aAAa,MAAM,WAAW,QAAQ,CAAC;AACvE;",
4
+ "sourcesContent": ["\"use client\";\n\nimport type { ConsentCategory, ConsentMode } from \"schemas/generated/consent\";\nimport type { ConsentCategories } from \"./cookie\";\n\nimport { useSyncExternalStore } from \"react\";\n\nimport { deriveConsentAction } from \"./consent-action\";\nimport { recordConsentAction } from \"./consent-actions\";\nimport {\n CONSENT_COOKIE_MAX_AGE_SECONDS,\n CONSENT_COOKIE_NAME,\n DENIED_CATEGORIES,\n GRANTED_CATEGORIES,\n parseConsentCookie,\n serializeConsentCookieValue,\n} from \"./cookie\";\n\n/**\n * Framework-agnostic, cookie-backed consent store. Lives as a single module\n * singleton so `ReploScripts`, the site's consent banner, and `AnalyticsProvider`\n * all share the same state regardless of where they sit in the React tree \u2014 no\n * provider-ancestor relationship is required.\n *\n * Consent-dependent work (script injection, banner visibility) happens on the\n * client (effects / post-mount), so there is no SSR/hydration mismatch. The\n * client reads the (non-httpOnly) consent cookie directly, so no server seed is\n * needed. The whole-site `mode` comes from the `data-replo-consent-mode`\n * attribute on `<html>`.\n */\n\nexport interface ConsentState {\n mode: ConsentMode;\n categories: ConsentCategories;\n /** Epoch ms when the visitor last made a choice, or null if undecided. */\n decidedAt: number | null;\n /**\n * Persistent pseudonymous per-browser id linking a visitor's consent history.\n * Absent until the first `commit()` (and on legacy pre-id cookies, until the\n * next interaction lazily backfills it).\n */\n consentId?: string;\n}\n\n// The non-necessary categories a visitor can grant or revoke. `necessary` is\n// always granted and never toggled.\nconst TOGGLEABLE_CATEGORIES: Exclude<ConsentCategory, \"necessary\">[] = [\n \"analytics\",\n \"marketing\",\n \"preferences\",\n \"sale_of_data\",\n];\n\n// A stable reference for SSR / first hydration render. Consent-dependent DOM is\n// only produced on the client, so this constant never causes a mismatch.\nconst SERVER_SNAPSHOT: ConsentState = Object.freeze({\n mode: \"off\",\n categories: DENIED_CATEGORIES,\n decidedAt: null,\n});\n\nconst listeners = new Set<() => void>();\nlet snapshot: ConsentState | null = null;\n\nfunction isConsentMode(value: string | null | undefined): value is ConsentMode {\n return value === \"off\" || value === \"simple\" || value === \"per-category\";\n}\n\nfunction resolveMode(): ConsentMode {\n if (typeof window === \"undefined\") {\n return \"off\";\n }\n const attribute = document.documentElement.dataset.reploConsentMode;\n return isConsentMode(attribute) ? attribute : \"off\";\n}\n\n// Used when the consent caller doesn't declare a policy version via\n// `useConsent({ version })` or the store method options.\nconst DEFAULT_CONSENT_POLICY_VERSION = 1;\n\nfunction computeSnapshot(): ConsentState {\n if (typeof window === \"undefined\") {\n return SERVER_SNAPSHOT;\n }\n\n const mode = resolveMode();\n\n const fromCookie = parseConsentCookie(document.cookie);\n if (fromCookie) {\n return {\n mode,\n categories: {\n necessary: true,\n analytics: fromCookie.categories.analytics,\n marketing: fromCookie.categories.marketing,\n preferences: fromCookie.categories.preferences,\n sale_of_data: fromCookie.categories.sale_of_data,\n },\n decidedAt: fromCookie.decidedAt,\n consentId: fromCookie.consentId,\n };\n }\n\n return { mode, categories: DENIED_CATEGORIES, decidedAt: null };\n}\n\nfunction writeCookie(\n categories: ConsentCategories,\n decidedAt: number,\n consentId: string,\n) {\n if (typeof document === \"undefined\") {\n return;\n }\n const value = serializeConsentCookieValue({\n categories,\n decidedAt,\n consentId,\n });\n document.cookie = `${CONSENT_COOKIE_NAME}=${value}; path=/; max-age=${CONSENT_COOKIE_MAX_AGE_SECONDS}; SameSite=Lax`;\n}\n\nfunction notify() {\n for (const listener of listeners) {\n listener();\n }\n}\n\nfunction commit({\n categories,\n policyVersion = DEFAULT_CONSENT_POLICY_VERSION,\n}: {\n categories: ConsentCategories;\n policyVersion?: number;\n}) {\n const previous = consentStore.getSnapshot();\n const decidedAt = Date.now();\n // Reuse the visitor's existing id, or mint one on the first decision (also\n // lazily backfills legacy pre-id cookies). `crypto.randomUUID` is available in\n // every browser we target and on the server (where commit() never runs).\n const consentId = previous.consentId ?? crypto.randomUUID();\n const resultingCategories: ConsentCategories = {\n ...categories,\n necessary: true,\n };\n writeCookie(categories, decidedAt, consentId);\n snapshot = {\n mode: previous.mode,\n categories: resultingCategories,\n decidedAt,\n consentId,\n };\n notify();\n\n // Revocation cannot unload an already-loaded vendor. If the visitor had\n // previously decided and is now turning a granted category off, reload so the\n // page renders without those scripts. Deferred until after the audit record is\n // sent so the reload doesn't cancel the in-flight server action.\n const wasDowngrade =\n previous.decidedAt !== null &&\n TOGGLEABLE_CATEGORIES.some((category) => {\n return previous.categories[category] && !categories[category];\n });\n const reloadIfDowngraded = () => {\n if (wasDowngrade && typeof window !== \"undefined\") {\n window.location.reload();\n }\n };\n\n // Proof-of-consent audit record (ungated by consent, but only on managed\n // sites). On `mode === \"off\"` there is no banner/consent UX, so a\n // `setTrackingConsent()` call from a third-party script would only produce\n // meaningless `consent_mode: \"off\"` noise \u2014 skip it. Egress runs through a\n // server action (like the cart) so the client never needs the project id or\n // analytics-fire URL.\n if (previous.mode !== \"off\") {\n void recordConsentAction({\n consentId,\n action: deriveConsentAction({ previous, next: resultingCategories }),\n categories: resultingCategories,\n consentMode: previous.mode,\n decidedAt,\n policyVersion,\n }).finally(reloadIfDowngraded);\n } else {\n reloadIfDowngraded();\n }\n}\n\nexport const consentStore = {\n getSnapshot(): ConsentState {\n if (!snapshot) {\n snapshot = computeSnapshot();\n }\n return snapshot;\n },\n getServerSnapshot(): ConsentState {\n return SERVER_SNAPSHOT;\n },\n subscribe(listener: () => void): () => void {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n },\n /** Grant every consent category. */\n accept(options: { policyVersion?: number } = {}) {\n commit({\n categories: GRANTED_CATEGORIES,\n policyVersion: options.policyVersion,\n });\n },\n /** Deny every non-necessary category. */\n reject(options: { policyVersion?: number } = {}) {\n commit({\n categories: DENIED_CATEGORIES,\n policyVersion: options.policyVersion,\n });\n },\n /** Set a subset of categories, leaving the rest at their current value. */\n updateCategories({\n next,\n policyVersion,\n }: {\n next: Partial<ConsentCategories>;\n policyVersion?: number;\n }) {\n const current = consentStore.getSnapshot().categories;\n commit({\n categories: { ...current, ...next, necessary: true },\n policyVersion,\n });\n },\n /** Test-only: reset cached state so the next read recomputes. */\n reset() {\n snapshot = null;\n },\n};\n\nexport interface UseConsentOptions {\n /**\n * Site-owned consent policy version, stamped onto each proof-of-consent\n * record so a decision can be tied to the exact banner the visitor saw.\n * Bump it whenever the banner copy or category set changes. Defaults to 1.\n */\n version?: number;\n}\n\nexport interface UseConsentResult extends ConsentState {\n accept(): void;\n reject(): void;\n updateCategories(next: Partial<ConsentCategories>): void;\n}\n\nexport function useConsent(options: UseConsentOptions = {}): UseConsentResult {\n const policyVersion = options.version;\n const state = useSyncExternalStore(\n consentStore.subscribe,\n consentStore.getSnapshot,\n consentStore.getServerSnapshot,\n );\n return {\n ...state,\n accept: () => consentStore.accept({ policyVersion }),\n reject: () => consentStore.reject({ policyVersion }),\n updateCategories: (next) => {\n consentStore.updateCategories({ next, policyVersion });\n },\n };\n}\n\n/**\n * Whether a script requiring `requiredConsent` is allowed to load right now.\n * `mode === \"off\"` always allows; otherwise every required category must be\n * granted. An empty requirement list is always allowed.\n */\nexport function isConsentAllowed({\n state,\n requiredConsent,\n}: {\n state: ConsentState;\n requiredConsent: ConsentCategory[];\n}): boolean {\n if (state.mode === \"off\") {\n return true;\n }\n if (requiredConsent.length === 0) {\n return true;\n }\n return requiredConsent.every((category) => state.categories[category]);\n}\n"],
5
+ "mappings": ";AAKA,SAAS,4BAA4B;AAErC,SAAS,2BAA2B;AACpC,SAAS,2BAA2B;AACpC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;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AAAA,MACZ,eAAe,QAAQ;AAAA,IACzB,CAAC;AAAA,EACH;AAAA;AAAA,EAEA,OAAO,UAAsC,CAAC,GAAG;AAC/C,WAAO;AAAA,MACL,YAAY;AAAA,MACZ,eAAe,QAAQ;AAAA,IACzB,CAAC;AAAA,EACH;AAAA;AAAA,EAEA,iBAAiB;AAAA,IACf;AAAA,IACA;AAAA,EACF,GAGG;AACD,UAAM,UAAU,aAAa,YAAY,EAAE;AAC3C,WAAO;AAAA,MACL,YAAY,EAAE,GAAG,SAAS,GAAG,MAAM,WAAW,KAAK;AAAA,MACnD;AAAA,IACF,CAAC;AAAA,EACH;AAAA;AAAA,EAEA,QAAQ;AACN,eAAW;AAAA,EACb;AACF;AAiBO,SAAS,WAAW,UAA6B,CAAC,GAAqB;AAC5E,QAAM,gBAAgB,QAAQ;AAC9B,QAAM,QAAQ;AAAA,IACZ,aAAa;AAAA,IACb,aAAa;AAAA,IACb,aAAa;AAAA,EACf;AACA,SAAO;AAAA,IACL,GAAG;AAAA,IACH,QAAQ,MAAM,aAAa,OAAO,EAAE,cAAc,CAAC;AAAA,IACnD,QAAQ,MAAM,aAAa,OAAO,EAAE,cAAc,CAAC;AAAA,IACnD,kBAAkB,CAAC,SAAS;AAC1B,mBAAa,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAAA,IACvD;AAAA,EACF;AACF;AAOO,SAAS,iBAAiB;AAAA,EAC/B;AAAA,EACA;AACF,GAGY;AACV,MAAI,MAAM,SAAS,OAAO;AACxB,WAAO;AAAA,EACT;AACA,MAAI,gBAAgB,WAAW,GAAG;AAChC,WAAO;AAAA,EACT;AACA,SAAO,gBAAgB,MAAM,CAAC,aAAa,MAAM,WAAW,QAAQ,CAAC;AACvE;",
6
6
  "names": []
7
7
  }
package/consent/cookie.js CHANGED
@@ -8,10 +8,10 @@ const persistedCookieSchema = z.object({
8
8
  decidedAt: z.number().optional(),
9
9
  consentId: z.string().optional(),
10
10
  categories: z.object({
11
- analytics: z.unknown().optional(),
12
- marketing: z.unknown().optional(),
13
- preferences: z.unknown().optional(),
14
- sale_of_data: z.unknown().optional()
11
+ analytics: z.boolean(),
12
+ marketing: z.boolean(),
13
+ preferences: z.boolean(),
14
+ sale_of_data: z.boolean()
15
15
  })
16
16
  });
17
17
  const DENIED_CATEGORIES = {
@@ -49,12 +49,7 @@ function parseConsentCookie(rawCookie) {
49
49
  version: CONSENT_COOKIE_VERSION,
50
50
  decidedAt: decidedAt ?? Date.now(),
51
51
  consentId,
52
- categories: {
53
- analytics: Boolean(categories.analytics),
54
- marketing: Boolean(categories.marketing),
55
- preferences: Boolean(categories.preferences),
56
- sale_of_data: Boolean(categories.sale_of_data)
57
- }
52
+ categories
58
53
  };
59
54
  }
60
55
  function serializeConsentCookieValue({
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../consent/cookie.ts"],
4
- "sourcesContent": ["import type { ConsentCategory } from \"schemas/generated/consent\";\n\nimport { parseJsonOrNull } from \"replo-utils/lib/json\";\nimport { z } from \"zod\";\n\n/**\n * Pure (non-React, framework-agnostic) consent cookie helpers used by the client\n * store (`consent-store.ts`).\n */\n\nexport const CONSENT_COOKIE_NAME = \"replo_consent\";\nexport const CONSENT_COOKIE_VERSION = 1;\nexport const CONSENT_COOKIE_MAX_AGE_SECONDS = 60 * 60 * 24 * 180; // 180 days\n\n// Validates the untrusted JSON cookie payload at the parse boundary. A stale\n// version (or any shape mismatch) fails `safeParse`, so the caller treats the\n// visitor as undecided and re-prompts.\n//\n// `consentId` is OPTIONAL on purpose: it was added after v1 shipped, and we must\n// NOT bump `CONSENT_COOKIE_VERSION` to introduce it. Bumping would fail this\n// `safeParse` for every existing cookie, re-showing the banner and dropping the\n// visitor's prior decision. Optional keeps v1 cookies valid; `commit()` lazily\n// backfills the id on the next interaction.\nconst persistedCookieSchema = z.object({\n version: z.literal(CONSENT_COOKIE_VERSION),\n decidedAt: z.number().optional(),\n consentId: z.string().optional(),\n categories: z.object({\n analytics: z.unknown().optional(),\n marketing: z.unknown().optional(),\n preferences: z.unknown().optional(),\n sale_of_data: z.unknown().optional(),\n }),\n});\n\nexport type ConsentCategories = Record<ConsentCategory, boolean>;\n\n/** Persisted cookie payload. `necessary` is always granted and never stored. */\nexport interface ConsentCookiePayload {\n version: number;\n decidedAt: number;\n /** Persistent pseudonymous per-browser id; absent on pre-id (legacy) cookies. */\n consentId?: string;\n categories: {\n analytics: boolean;\n marketing: boolean;\n preferences: boolean;\n sale_of_data: boolean;\n };\n}\n\nexport const DENIED_CATEGORIES: ConsentCategories = {\n necessary: true,\n analytics: false,\n marketing: false,\n preferences: false,\n sale_of_data: false,\n};\n\nexport const GRANTED_CATEGORIES: ConsentCategories = {\n necessary: true,\n analytics: true,\n marketing: true,\n preferences: true,\n sale_of_data: true,\n};\n\n/**\n * Parse a raw `document.cookie` (or a single cookie value) into a payload.\n * Returns null for missing, malformed, or stale-version cookies so callers\n * treat the visitor as undecided and re-prompt.\n */\nexport function parseConsentCookie(\n rawCookie: string | undefined,\n): ConsentCookiePayload | null {\n if (!rawCookie) {\n return null;\n }\n const match = rawCookie\n .split(\"; \")\n .find((entry) => entry.startsWith(`${CONSENT_COOKIE_NAME}=`));\n const encoded = match\n ? match.slice(CONSENT_COOKIE_NAME.length + 1)\n : rawCookie;\n\n // A tampered/corrupted cookie (bad percent-encoding) must not throw \u2014 that\n // would crash the client snapshot or the server seed read. Treat as undecided.\n let decoded: string;\n try {\n decoded = decodeURIComponent(encoded);\n } catch {\n return null;\n }\n\n const result = persistedCookieSchema.safeParse(parseJsonOrNull(decoded));\n if (!result.success) {\n return null;\n }\n const { decidedAt, categories, consentId } = result.data;\n\n return {\n version: CONSENT_COOKIE_VERSION,\n decidedAt: decidedAt ?? Date.now(),\n consentId,\n categories: {\n analytics: Boolean(categories.analytics),\n marketing: Boolean(categories.marketing),\n preferences: Boolean(categories.preferences),\n sale_of_data: Boolean(categories.sale_of_data),\n },\n };\n}\n\n/** Serialize categories into the JSON-encoded cookie value (not the full Set-Cookie line). */\nexport function serializeConsentCookieValue({\n categories,\n decidedAt,\n consentId,\n}: {\n categories: ConsentCategories;\n decidedAt: number;\n consentId?: string;\n}): string {\n const payload: ConsentCookiePayload = {\n version: CONSENT_COOKIE_VERSION,\n decidedAt,\n consentId,\n categories: {\n analytics: categories.analytics,\n marketing: categories.marketing,\n preferences: categories.preferences,\n sale_of_data: categories.sale_of_data,\n },\n };\n return encodeURIComponent(JSON.stringify(payload));\n}\n"],
5
- "mappings": "AAEA,SAAS,uBAAuB;AAChC,SAAS,SAAS;AAOX,MAAM,sBAAsB;AAC5B,MAAM,yBAAyB;AAC/B,MAAM,iCAAiC,KAAK,KAAK,KAAK;AAW7D,MAAM,wBAAwB,EAAE,OAAO;AAAA,EACrC,SAAS,EAAE,QAAQ,sBAAsB;AAAA,EACzC,WAAW,EAAE,OAAO,EAAE,SAAS;AAAA,EAC/B,WAAW,EAAE,OAAO,EAAE,SAAS;AAAA,EAC/B,YAAY,EAAE,OAAO;AAAA,IACnB,WAAW,EAAE,QAAQ,EAAE,SAAS;AAAA,IAChC,WAAW,EAAE,QAAQ,EAAE,SAAS;AAAA,IAChC,aAAa,EAAE,QAAQ,EAAE,SAAS;AAAA,IAClC,cAAc,EAAE,QAAQ,EAAE,SAAS;AAAA,EACrC,CAAC;AACH,CAAC;AAkBM,MAAM,oBAAuC;AAAA,EAClD,WAAW;AAAA,EACX,WAAW;AAAA,EACX,WAAW;AAAA,EACX,aAAa;AAAA,EACb,cAAc;AAChB;AAEO,MAAM,qBAAwC;AAAA,EACnD,WAAW;AAAA,EACX,WAAW;AAAA,EACX,WAAW;AAAA,EACX,aAAa;AAAA,EACb,cAAc;AAChB;AAOO,SAAS,mBACd,WAC6B;AAC7B,MAAI,CAAC,WAAW;AACd,WAAO;AAAA,EACT;AACA,QAAM,QAAQ,UACX,MAAM,IAAI,EACV,KAAK,CAAC,UAAU,MAAM,WAAW,GAAG,mBAAmB,GAAG,CAAC;AAC9D,QAAM,UAAU,QACZ,MAAM,MAAM,oBAAoB,SAAS,CAAC,IAC1C;AAIJ,MAAI;AACJ,MAAI;AACF,cAAU,mBAAmB,OAAO;AAAA,EACtC,QAAQ;AACN,WAAO;AAAA,EACT;AAEA,QAAM,SAAS,sBAAsB,UAAU,gBAAgB,OAAO,CAAC;AACvE,MAAI,CAAC,OAAO,SAAS;AACnB,WAAO;AAAA,EACT;AACA,QAAM,EAAE,WAAW,YAAY,UAAU,IAAI,OAAO;AAEpD,SAAO;AAAA,IACL,SAAS;AAAA,IACT,WAAW,aAAa,KAAK,IAAI;AAAA,IACjC;AAAA,IACA,YAAY;AAAA,MACV,WAAW,QAAQ,WAAW,SAAS;AAAA,MACvC,WAAW,QAAQ,WAAW,SAAS;AAAA,MACvC,aAAa,QAAQ,WAAW,WAAW;AAAA,MAC3C,cAAc,QAAQ,WAAW,YAAY;AAAA,IAC/C;AAAA,EACF;AACF;AAGO,SAAS,4BAA4B;AAAA,EAC1C;AAAA,EACA;AAAA,EACA;AACF,GAIW;AACT,QAAM,UAAgC;AAAA,IACpC,SAAS;AAAA,IACT;AAAA,IACA;AAAA,IACA,YAAY;AAAA,MACV,WAAW,WAAW;AAAA,MACtB,WAAW,WAAW;AAAA,MACtB,aAAa,WAAW;AAAA,MACxB,cAAc,WAAW;AAAA,IAC3B;AAAA,EACF;AACA,SAAO,mBAAmB,KAAK,UAAU,OAAO,CAAC;AACnD;",
4
+ "sourcesContent": ["import type { ConsentCategory } from \"schemas/generated/consent\";\n\nimport { parseJsonOrNull } from \"replo-utils/lib/json\";\nimport { z } from \"zod\";\n\n/**\n * Pure (non-React, framework-agnostic) consent cookie helpers used by the client\n * store (`consent-store.ts`).\n */\n\nexport const CONSENT_COOKIE_NAME = \"replo_consent\";\nexport const CONSENT_COOKIE_VERSION = 1;\nexport const CONSENT_COOKIE_MAX_AGE_SECONDS = 60 * 60 * 24 * 180; // 180 days\n\n// Validates the untrusted JSON cookie payload at the parse boundary. A stale\n// version (or any shape mismatch) fails `safeParse`, so the caller treats the\n// visitor as undecided and re-prompts.\n//\n// `consentId` is OPTIONAL on purpose: it was added after v1 shipped, and we must\n// NOT bump `CONSENT_COOKIE_VERSION` to introduce it. Bumping would fail this\n// `safeParse` for every existing cookie, re-showing the banner and dropping the\n// visitor's prior decision. Optional keeps v1 cookies valid; `commit()` lazily\n// backfills the id on the next interaction.\nconst persistedCookieSchema = z.object({\n version: z.literal(CONSENT_COOKIE_VERSION),\n decidedAt: z.number().optional(),\n consentId: z.string().optional(),\n categories: z.object({\n analytics: z.boolean(),\n marketing: z.boolean(),\n preferences: z.boolean(),\n sale_of_data: z.boolean(),\n }),\n});\n\nexport type ConsentCategories = Record<ConsentCategory, boolean>;\n\n/** Persisted cookie payload. `necessary` is always granted and never stored. */\nexport interface ConsentCookiePayload {\n version: number;\n decidedAt: number;\n /** Persistent pseudonymous per-browser id; absent on pre-id (legacy) cookies. */\n consentId?: string;\n categories: {\n analytics: boolean;\n marketing: boolean;\n preferences: boolean;\n sale_of_data: boolean;\n };\n}\n\nexport const DENIED_CATEGORIES: ConsentCategories = {\n necessary: true,\n analytics: false,\n marketing: false,\n preferences: false,\n sale_of_data: false,\n};\n\nexport const GRANTED_CATEGORIES: ConsentCategories = {\n necessary: true,\n analytics: true,\n marketing: true,\n preferences: true,\n sale_of_data: true,\n};\n\n/**\n * Parse a raw `document.cookie` (or a single cookie value) into a payload.\n * Returns null for missing, malformed, or stale-version cookies so callers\n * treat the visitor as undecided and re-prompt.\n */\nexport function parseConsentCookie(\n rawCookie: string | undefined,\n): ConsentCookiePayload | null {\n if (!rawCookie) {\n return null;\n }\n const match = rawCookie\n .split(\"; \")\n .find((entry) => entry.startsWith(`${CONSENT_COOKIE_NAME}=`));\n const encoded = match\n ? match.slice(CONSENT_COOKIE_NAME.length + 1)\n : rawCookie;\n\n // A tampered/corrupted cookie (bad percent-encoding) must not throw \u2014 that\n // would crash the client snapshot or the server seed read. Treat as undecided.\n let decoded: string;\n try {\n decoded = decodeURIComponent(encoded);\n } catch {\n return null;\n }\n\n const result = persistedCookieSchema.safeParse(parseJsonOrNull(decoded));\n if (!result.success) {\n return null;\n }\n const { decidedAt, categories, consentId } = result.data;\n\n return {\n version: CONSENT_COOKIE_VERSION,\n decidedAt: decidedAt ?? Date.now(),\n consentId,\n categories,\n };\n}\n\n/** Serialize categories into the JSON-encoded cookie value (not the full Set-Cookie line). */\nexport function serializeConsentCookieValue({\n categories,\n decidedAt,\n consentId,\n}: {\n categories: ConsentCategories;\n decidedAt: number;\n consentId?: string;\n}): string {\n const payload: ConsentCookiePayload = {\n version: CONSENT_COOKIE_VERSION,\n decidedAt,\n consentId,\n categories: {\n analytics: categories.analytics,\n marketing: categories.marketing,\n preferences: categories.preferences,\n sale_of_data: categories.sale_of_data,\n },\n };\n return encodeURIComponent(JSON.stringify(payload));\n}\n"],
5
+ "mappings": "AAEA,SAAS,uBAAuB;AAChC,SAAS,SAAS;AAOX,MAAM,sBAAsB;AAC5B,MAAM,yBAAyB;AAC/B,MAAM,iCAAiC,KAAK,KAAK,KAAK;AAW7D,MAAM,wBAAwB,EAAE,OAAO;AAAA,EACrC,SAAS,EAAE,QAAQ,sBAAsB;AAAA,EACzC,WAAW,EAAE,OAAO,EAAE,SAAS;AAAA,EAC/B,WAAW,EAAE,OAAO,EAAE,SAAS;AAAA,EAC/B,YAAY,EAAE,OAAO;AAAA,IACnB,WAAW,EAAE,QAAQ;AAAA,IACrB,WAAW,EAAE,QAAQ;AAAA,IACrB,aAAa,EAAE,QAAQ;AAAA,IACvB,cAAc,EAAE,QAAQ;AAAA,EAC1B,CAAC;AACH,CAAC;AAkBM,MAAM,oBAAuC;AAAA,EAClD,WAAW;AAAA,EACX,WAAW;AAAA,EACX,WAAW;AAAA,EACX,aAAa;AAAA,EACb,cAAc;AAChB;AAEO,MAAM,qBAAwC;AAAA,EACnD,WAAW;AAAA,EACX,WAAW;AAAA,EACX,WAAW;AAAA,EACX,aAAa;AAAA,EACb,cAAc;AAChB;AAOO,SAAS,mBACd,WAC6B;AAC7B,MAAI,CAAC,WAAW;AACd,WAAO;AAAA,EACT;AACA,QAAM,QAAQ,UACX,MAAM,IAAI,EACV,KAAK,CAAC,UAAU,MAAM,WAAW,GAAG,mBAAmB,GAAG,CAAC;AAC9D,QAAM,UAAU,QACZ,MAAM,MAAM,oBAAoB,SAAS,CAAC,IAC1C;AAIJ,MAAI;AACJ,MAAI;AACF,cAAU,mBAAmB,OAAO;AAAA,EACtC,QAAQ;AACN,WAAO;AAAA,EACT;AAEA,QAAM,SAAS,sBAAsB,UAAU,gBAAgB,OAAO,CAAC;AACvE,MAAI,CAAC,OAAO,SAAS;AACnB,WAAO;AAAA,EACT;AACA,QAAM,EAAE,WAAW,YAAY,UAAU,IAAI,OAAO;AAEpD,SAAO;AAAA,IACL,SAAS;AAAA,IACT,WAAW,aAAa,KAAK,IAAI;AAAA,IACjC;AAAA,IACA;AAAA,EACF;AACF;AAGO,SAAS,4BAA4B;AAAA,EAC1C;AAAA,EACA;AAAA,EACA;AACF,GAIW;AACT,QAAM,UAAgC;AAAA,IACpC,SAAS;AAAA,IACT;AAAA,IACA;AAAA,IACA,YAAY;AAAA,MACV,WAAW,WAAW;AAAA,MACtB,WAAW,WAAW;AAAA,MACtB,aAAa,WAAW;AAAA,MACxB,cAAc,WAAW;AAAA,IAC3B;AAAA,EACF;AACA,SAAO,mBAAmB,KAAK,UAAU,OAAO,CAAC;AACnD;",
6
6
  "names": []
7
7
  }
@@ -1,6 +1,11 @@
1
1
  export type ReploScriptType = "GA4" | "GoogleTagManager" | "Meta" | "TikTok" | "Pinterest" | "Reddit" | "Snapchat" | "Hotjar" | "MicrosoftClarity" | "Triplewhale" | "Segment" | "custom";
2
2
  export type ConsentCategory = "necessary" | "analytics" | "marketing" | "preferences" | "sale_of_data";
3
3
  export type ConsentMode = "off" | "simple" | "per-category";
4
+ declare module "react" {
5
+ interface HtmlHTMLAttributes<T> {
6
+ "data-replo-consent-mode"?: ConsentMode;
7
+ }
8
+ }
4
9
  export type ScriptTagDescriptor = {
5
10
  kind: "external";
6
11
  src: string;
@@ -33,7 +33,7 @@ const api = {
33
33
  return state.mode !== "off" && state.decidedAt === null;
34
34
  },
35
35
  setTrackingConsent: (consent, callback) => {
36
- consentStore.updateCategories(consent);
36
+ consentStore.updateCategories({ next: consent });
37
37
  callback?.();
38
38
  }
39
39
  };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../consent/window-api.ts"],
4
- "sourcesContent": ["\"use client\";\n\nimport type { ConsentCategory } from \"schemas/generated/consent\";\n\nimport { consentStore, isConsentAllowed } from \"./consent-store\";\n\n/**\n * Global, framework-agnostic consent API exposed on `window.Replo.customerPrivacy`,\n * mirroring Shopify's Customer Privacy API surface so on-page (third-party)\n * scripts can query consent and react to changes without importing canopy.\n *\n * It deliberately lives under our own `window.Replo` namespace rather than\n * `window.Shopify` to avoid colliding with Shopify's real API on Shopify-backed\n * sites.\n */\n\ntype ToggleableCategory = Exclude<ConsentCategory, \"necessary\">;\n\n/** Shopify-style tri-state: declared-allowed, declared-denied, or undeclared. */\ntype ConsentSignal = \"yes\" | \"no\" | \"\";\n\nexport interface ReploCustomerPrivacyApi {\n /** Per-category declaration, or \"\" when the visitor has not decided. */\n currentVisitorConsent(): Record<ToggleableCategory, ConsentSignal>;\n analyticsProcessingAllowed(): boolean;\n marketingAllowed(): boolean;\n preferencesProcessingAllowed(): boolean;\n saleOfDataAllowed(): boolean;\n /** Whether the consent banner should still be shown (mode on + undecided). */\n shouldShowBanner(): boolean;\n /** Update a subset of categories; runs the optional callback once persisted. */\n setTrackingConsent(\n consent: Partial<Record<ToggleableCategory, boolean>>,\n callback?: () => void,\n ): void;\n}\n\ndeclare global {\n interface Window {\n Replo?: { customerPrivacy?: ReploCustomerPrivacyApi };\n }\n}\n\n/** DOM event dispatched on `document` whenever consent changes. */\nexport const CONSENT_CHANGE_EVENT = \"visitorConsentCollected\";\n\nfunction isAllowed(category: ConsentCategory): boolean {\n return isConsentAllowed({\n state: consentStore.getSnapshot(),\n requiredConsent: [category],\n });\n}\n\nfunction currentVisitorConsent(): Record<ToggleableCategory, ConsentSignal> {\n const state = consentStore.getSnapshot();\n const signal = (category: ToggleableCategory): ConsentSignal => {\n if (state.decidedAt === null) {\n return \"\";\n }\n return state.categories[category] ? \"yes\" : \"no\";\n };\n return {\n analytics: signal(\"analytics\"),\n marketing: signal(\"marketing\"),\n preferences: signal(\"preferences\"),\n sale_of_data: signal(\"sale_of_data\"),\n };\n}\n\nconst api: ReploCustomerPrivacyApi = {\n currentVisitorConsent,\n analyticsProcessingAllowed: () => isAllowed(\"analytics\"),\n marketingAllowed: () => isAllowed(\"marketing\"),\n preferencesProcessingAllowed: () => isAllowed(\"preferences\"),\n saleOfDataAllowed: () => isAllowed(\"sale_of_data\"),\n shouldShowBanner: () => {\n const state = consentStore.getSnapshot();\n return state.mode !== \"off\" && state.decidedAt === null;\n },\n setTrackingConsent: (consent, callback) => {\n consentStore.updateCategories(consent);\n callback?.();\n },\n};\n\nfunction consentChangeDetail() {\n return {\n analyticsAllowed: isAllowed(\"analytics\"),\n marketingAllowed: isAllowed(\"marketing\"),\n preferencesAllowed: isAllowed(\"preferences\"),\n saleOfDataAllowed: isAllowed(\"sale_of_data\"),\n };\n}\n\nlet teardown: (() => void) | null = null;\n\n/**\n * Installs `window.Replo.customerPrivacy` and dispatches `visitorConsentCollected`\n * on `document` whenever consent changes. Idempotent; returns a teardown that\n * removes the change subscription. Safe to call on the server (no-op).\n */\nexport function installConsentWindowApi(): () => void {\n if (typeof window === \"undefined\") {\n return () => {\n // no-op on the server\n };\n }\n if (teardown) {\n return teardown;\n }\n window.Replo = { ...window.Replo, customerPrivacy: api };\n const unsubscribe = consentStore.subscribe(() => {\n document.dispatchEvent(\n new CustomEvent(CONSENT_CHANGE_EVENT, { detail: consentChangeDetail() }),\n );\n });\n teardown = () => {\n unsubscribe();\n teardown = null;\n };\n return teardown;\n}\n"],
5
- "mappings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U;AACZ,WAAO;AAAA,EACT;AACA,SAAO,QAAQ,EAAE,GAAG,OAAO,OAAO,iBAAiB,IAAI;AACvD,QAAM,cAAc,aAAa,UAAU,MAAM;AAC/C,aAAS;AAAA,MACP,IAAI,YAAY,sBAAsB,EAAE,QAAQ,oBAAoB,EAAE,CAAC;AAAA,IACzE;AAAA,EACF,CAAC;AACD,aAAW,MAAM;AACf,gBAAY;AACZ,eAAW;AAAA,EACb;AACA,SAAO;AACT;",
4
+ "sourcesContent": ["\"use client\";\n\nimport type { ConsentCategory } from \"schemas/generated/consent\";\n\nimport { consentStore, isConsentAllowed } from \"./consent-store\";\n\n/**\n * Global, framework-agnostic consent API exposed on `window.Replo.customerPrivacy`,\n * mirroring Shopify's Customer Privacy API surface so on-page (third-party)\n * scripts can query consent and react to changes without importing canopy.\n *\n * It deliberately lives under our own `window.Replo` namespace rather than\n * `window.Shopify` to avoid colliding with Shopify's real API on Shopify-backed\n * sites.\n */\n\ntype ToggleableCategory = Exclude<ConsentCategory, \"necessary\">;\n\n/** Shopify-style tri-state: declared-allowed, declared-denied, or undeclared. */\ntype ConsentSignal = \"yes\" | \"no\" | \"\";\n\nexport interface ReploCustomerPrivacyApi {\n /** Per-category declaration, or \"\" when the visitor has not decided. */\n currentVisitorConsent(): Record<ToggleableCategory, ConsentSignal>;\n analyticsProcessingAllowed(): boolean;\n marketingAllowed(): boolean;\n preferencesProcessingAllowed(): boolean;\n saleOfDataAllowed(): boolean;\n /** Whether the consent banner should still be shown (mode on + undecided). */\n shouldShowBanner(): boolean;\n /** Update a subset of categories; runs the optional callback once persisted. */\n setTrackingConsent(\n consent: Partial<Record<ToggleableCategory, boolean>>,\n callback?: () => void,\n ): void;\n}\n\ndeclare global {\n interface Window {\n Replo?: { customerPrivacy?: ReploCustomerPrivacyApi };\n }\n}\n\n/** DOM event dispatched on `document` whenever consent changes. */\nexport const CONSENT_CHANGE_EVENT = \"visitorConsentCollected\";\n\nfunction isAllowed(category: ConsentCategory): boolean {\n return isConsentAllowed({\n state: consentStore.getSnapshot(),\n requiredConsent: [category],\n });\n}\n\nfunction currentVisitorConsent(): Record<ToggleableCategory, ConsentSignal> {\n const state = consentStore.getSnapshot();\n const signal = (category: ToggleableCategory): ConsentSignal => {\n if (state.decidedAt === null) {\n return \"\";\n }\n return state.categories[category] ? \"yes\" : \"no\";\n };\n return {\n analytics: signal(\"analytics\"),\n marketing: signal(\"marketing\"),\n preferences: signal(\"preferences\"),\n sale_of_data: signal(\"sale_of_data\"),\n };\n}\n\nconst api: ReploCustomerPrivacyApi = {\n currentVisitorConsent,\n analyticsProcessingAllowed: () => isAllowed(\"analytics\"),\n marketingAllowed: () => isAllowed(\"marketing\"),\n preferencesProcessingAllowed: () => isAllowed(\"preferences\"),\n saleOfDataAllowed: () => isAllowed(\"sale_of_data\"),\n shouldShowBanner: () => {\n const state = consentStore.getSnapshot();\n return state.mode !== \"off\" && state.decidedAt === null;\n },\n setTrackingConsent: (consent, callback) => {\n consentStore.updateCategories({ next: consent });\n callback?.();\n },\n};\n\nfunction consentChangeDetail() {\n return {\n analyticsAllowed: isAllowed(\"analytics\"),\n marketingAllowed: isAllowed(\"marketing\"),\n preferencesAllowed: isAllowed(\"preferences\"),\n saleOfDataAllowed: isAllowed(\"sale_of_data\"),\n };\n}\n\nlet teardown: (() => void) | null = null;\n\n/**\n * Installs `window.Replo.customerPrivacy` and dispatches `visitorConsentCollected`\n * on `document` whenever consent changes. Idempotent; returns a teardown that\n * removes the change subscription. Safe to call on the server (no-op).\n */\nexport function installConsentWindowApi(): () => void {\n if (typeof window === \"undefined\") {\n return () => {\n // no-op on the server\n };\n }\n if (teardown) {\n return teardown;\n }\n window.Replo = { ...window.Replo, customerPrivacy: api };\n const unsubscribe = consentStore.subscribe(() => {\n document.dispatchEvent(\n new CustomEvent(CONSENT_CHANGE_EVENT, { detail: consentChangeDetail() }),\n );\n });\n teardown = () => {\n unsubscribe();\n teardown = null;\n };\n return teardown;\n}\n"],
5
+ "mappings": ";A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;AACA,MAAI,UAAU;AACZ,WAAO;AAAA,EACT;AACA,SAAO,QAAQ,EAAE,GAAG,OAAO,OAAO,iBAAiB,IAAI;AACvD,QAAM,cAAc,aAAa,UAAU,MAAM;AAC/C,aAAS;AAAA,MACP,IAAI,YAAY,sBAAsB,EAAE,QAAQ,oBAAoB,EAAE,CAAC;AAAA,IACzE;AAAA,EACF,CAAC;AACD,aAAW,MAAM;AACf,gBAAY;AACZ,eAAW;AAAA,EACb;AACA,SAAO;AACT;",
6
6
  "names": []
7
7
  }
@@ -66,8 +66,8 @@ function LinkInterceptor() {
66
66
  }
67
67
  event.preventDefault?.();
68
68
  };
69
- const handleClick = (e) => {
70
- const target = e.target;
69
+ const handleClick = (event) => {
70
+ const target = event.target;
71
71
  if (!(target instanceof Element)) {
72
72
  return;
73
73
  }
@@ -84,14 +84,14 @@ function LinkInterceptor() {
84
84
  }
85
85
  const linkTarget = link.getAttribute("target");
86
86
  if (linkTarget && linkTarget !== "_self") {
87
- blockNavigation(e);
87
+ blockNavigation(event);
88
88
  return;
89
89
  }
90
90
  if (urlLeavesSandbox(href) === true) {
91
- blockNavigation(e);
91
+ blockNavigation(event);
92
92
  return;
93
93
  }
94
- e.preventDefault();
94
+ event.preventDefault();
95
95
  let route;
96
96
  try {
97
97
  route = new URL(href, window.location.href).pathname;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../editor/LinkInterceptor.tsx"],
4
- "sourcesContent": ["\"use client\";\n\nimport { useEffect } from \"react\";\n\ntype NavigationNavigateEvent = {\n destination?: { url?: string };\n preventDefault?: () => void;\n};\n\ntype NavigationLike = {\n addEventListener: (\n type: \"navigate\",\n listener: (event: NavigationNavigateEvent) => void,\n ) => void;\n removeEventListener: (\n type: \"navigate\",\n listener: (event: NavigationNavigateEvent) => void,\n ) => void;\n};\n\nfunction blockNavigation(event: MouseEvent) {\n event.preventDefault();\n event.stopPropagation();\n event.stopImmediatePropagation();\n}\n\nfunction isNavigationLike(value: unknown): value is NavigationLike {\n if (typeof value !== \"object\" || value === null) {\n return false;\n }\n\n return (\n typeof Reflect.get(value, \"addEventListener\") === \"function\" &&\n typeof Reflect.get(value, \"removeEventListener\") === \"function\"\n );\n}\n\nfunction getWindowNavigation() {\n const navigation = Reflect.get(window, \"navigation\");\n return isNavigationLike(navigation) ? navigation : null;\n}\n\nfunction shouldInterceptNavigationForAgentPreview() {\n if (typeof window === \"undefined\") {\n return false;\n }\n\n if (window.parent === window) {\n return false;\n }\n\n return (\n new URLSearchParams(window.location.search).get(\"__reploAgentPreview\") ===\n \"1\"\n );\n}\n\nfunction urlLeavesSandbox(rawUrl: string | URL): boolean | null {\n try {\n const resolved =\n typeof rawUrl === \"string\"\n ? new URL(rawUrl, window.location.href)\n : new URL(rawUrl.href, window.location.href);\n return resolved.origin !== window.location.origin;\n } catch {\n return null;\n }\n}\n\nexport default function LinkInterceptor() {\n // eslint-disable-next-line replo/no-use-effect -- Browser navigation APIs must be patched at client runtime and restored when the interceptor unmounts.\n useEffect(() => {\n if (!shouldInterceptNavigationForAgentPreview()) {\n return;\n }\n\n const originalWindowOpen = window.open;\n const originalPushState = history.pushState;\n const originalReplaceState = history.replaceState;\n const navigation = getWindowNavigation();\n\n window.open = function (\n url?: string | URL,\n target?: string,\n features?: string,\n ) {\n if (url !== undefined && url !== \"\" && urlLeavesSandbox(url) === true) {\n return null;\n }\n\n return originalWindowOpen.call(window, url, target, features);\n };\n\n history.pushState = function (\n state: Parameters<History[\"pushState\"]>[0],\n unused: string,\n url?: string | URL | null,\n ) {\n if (url != null && url !== \"\" && urlLeavesSandbox(url) === true) {\n return;\n }\n\n return originalPushState.call(history, state, unused, url);\n };\n\n history.replaceState = function (\n state: Parameters<History[\"replaceState\"]>[0],\n unused: string,\n url?: string | URL | null,\n ) {\n if (url != null && url !== \"\" && urlLeavesSandbox(url) === true) {\n return;\n }\n\n return originalReplaceState.call(history, state, unused, url);\n };\n\n const handleNavigate = (event: NavigationNavigateEvent) => {\n const destinationUrl = event.destination?.url;\n if (\n destinationUrl === undefined ||\n destinationUrl === \"\" ||\n urlLeavesSandbox(destinationUrl) !== true\n ) {\n return;\n }\n\n event.preventDefault?.();\n };\n\n const handleClick = (e: MouseEvent) => {\n const target = e.target;\n\n if (!(target instanceof Element)) {\n return;\n }\n\n const link = target.closest(\"a[href]\");\n\n if (!(link instanceof HTMLAnchorElement)) {\n return;\n }\n\n const href = link.getAttribute(\"href\");\n if (!href) {\n return;\n }\n\n if (href.startsWith(\"#\")) {\n return;\n }\n\n const linkTarget = link.getAttribute(\"target\");\n if (linkTarget && linkTarget !== \"_self\") {\n blockNavigation(e);\n return;\n }\n\n if (urlLeavesSandbox(href) === true) {\n blockNavigation(e);\n return;\n }\n\n e.preventDefault();\n\n let route: string;\n try {\n route = new URL(href, window.location.href).pathname;\n } catch {\n route = href;\n }\n\n window.parent.postMessage(\n {\n type: \"replo:navigate\",\n route,\n },\n \"*\",\n );\n };\n\n navigation?.addEventListener(\"navigate\", handleNavigate);\n document.addEventListener(\"click\", handleClick, true);\n\n return () => {\n window.open = originalWindowOpen;\n history.pushState = originalPushState;\n history.replaceState = originalReplaceState;\n navigation?.removeEventListener(\"navigate\", handleNavigate);\n document.removeEventListener(\"click\", handleClick, true);\n };\n }, []);\n\n return null;\n}\n"],
5
- "mappings": ";AAEA,SAAS,iBAAiB;AAkB1B,SAAS,gBAAgB,OAAmB;AAC1C,QAAM,eAAe;AACrB,QAAM,gBAAgB;AACtB,QAAM,yBAAyB;AACjC;AAEA,SAAS,iBAAiB,OAAyC;AACjE,MAAI,OAAO,UAAU,YAAY,UAAU,MAAM;AAC/C,WAAO;AAAA,EACT;AAEA,SACE,OAAO,QAAQ,IAAI,OAAO,kBAAkB,MAAM,cAClD,OAAO,QAAQ,IAAI,OAAO,qBAAqB,MAAM;AAEzD;AAEA,SAAS,sBAAsB;AAC7B,QAAM,aAAa,QAAQ,IAAI,QAAQ,YAAY;AACnD,SAAO,iBAAiB,UAAU,IA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n\nimport { useEffect } from \"react\";\n\ntype NavigationNavigateEvent = {\n destination?: { url?: string };\n preventDefault?: () => void;\n};\n\ntype NavigationLike = {\n addEventListener: (\n type: \"navigate\",\n listener: (event: NavigationNavigateEvent) => void,\n ) => void;\n removeEventListener: (\n type: \"navigate\",\n listener: (event: NavigationNavigateEvent) => void,\n ) => void;\n};\n\nfunction blockNavigation(event: MouseEvent) {\n event.preventDefault();\n event.stopPropagation();\n event.stopImmediatePropagation();\n}\n\nfunction isNavigationLike(value: unknown): value is NavigationLike {\n if (typeof value !== \"object\" || value === null) {\n return false;\n }\n\n return (\n typeof Reflect.get(value, \"addEventListener\") === \"function\" &&\n typeof Reflect.get(value, \"removeEventListener\") === \"function\"\n );\n}\n\nfunction getWindowNavigation() {\n const navigation = Reflect.get(window, \"navigation\");\n return isNavigationLike(navigation) ? navigation : null;\n}\n\nfunction shouldInterceptNavigationForAgentPreview() {\n if (typeof window === \"undefined\") {\n return false;\n }\n\n if (window.parent === window) {\n return false;\n }\n\n return (\n new URLSearchParams(window.location.search).get(\"__reploAgentPreview\") ===\n \"1\"\n );\n}\n\nfunction urlLeavesSandbox(rawUrl: string | URL): boolean | null {\n try {\n const resolved =\n typeof rawUrl === \"string\"\n ? new URL(rawUrl, window.location.href)\n : new URL(rawUrl.href, window.location.href);\n return resolved.origin !== window.location.origin;\n } catch {\n return null;\n }\n}\n\nexport default function LinkInterceptor() {\n // eslint-disable-next-line replo/no-use-effect -- Browser navigation APIs must be patched at client runtime and restored when the interceptor unmounts.\n useEffect(() => {\n if (!shouldInterceptNavigationForAgentPreview()) {\n return;\n }\n\n const originalWindowOpen = window.open;\n const originalPushState = history.pushState;\n const originalReplaceState = history.replaceState;\n const navigation = getWindowNavigation();\n\n window.open = function (\n url?: string | URL,\n target?: string,\n features?: string,\n ) {\n if (url !== undefined && url !== \"\" && urlLeavesSandbox(url) === true) {\n return null;\n }\n\n return originalWindowOpen.call(window, url, target, features);\n };\n\n history.pushState = function (\n state: Parameters<History[\"pushState\"]>[0],\n unused: string,\n url?: string | URL | null,\n ) {\n if (url != null && url !== \"\" && urlLeavesSandbox(url) === true) {\n return;\n }\n\n return originalPushState.call(history, state, unused, url);\n };\n\n history.replaceState = function (\n state: Parameters<History[\"replaceState\"]>[0],\n unused: string,\n url?: string | URL | null,\n ) {\n if (url != null && url !== \"\" && urlLeavesSandbox(url) === true) {\n return;\n }\n\n return originalReplaceState.call(history, state, unused, url);\n };\n\n const handleNavigate = (event: NavigationNavigateEvent) => {\n const destinationUrl = event.destination?.url;\n if (\n destinationUrl === undefined ||\n destinationUrl === \"\" ||\n urlLeavesSandbox(destinationUrl) !== true\n ) {\n return;\n }\n\n event.preventDefault?.();\n };\n\n const handleClick = (event: MouseEvent) => {\n const target = event.target;\n\n if (!(target instanceof Element)) {\n return;\n }\n\n const link = target.closest(\"a[href]\");\n\n if (!(link instanceof HTMLAnchorElement)) {\n return;\n }\n\n const href = link.getAttribute(\"href\");\n if (!href) {\n return;\n }\n\n if (href.startsWith(\"#\")) {\n return;\n }\n\n const linkTarget = link.getAttribute(\"target\");\n if (linkTarget && linkTarget !== \"_self\") {\n blockNavigation(event);\n return;\n }\n\n if (urlLeavesSandbox(href) === true) {\n blockNavigation(event);\n return;\n }\n\n event.preventDefault();\n\n let route: string;\n try {\n route = new URL(href, window.location.href).pathname;\n } catch {\n route = href;\n }\n\n window.parent.postMessage(\n {\n type: \"replo:navigate\",\n route,\n },\n \"*\",\n );\n };\n\n navigation?.addEventListener(\"navigate\", handleNavigate);\n document.addEventListener(\"click\", handleClick, true);\n\n return () => {\n window.open = originalWindowOpen;\n history.pushState = originalPushState;\n history.replaceState = originalReplaceState;\n navigation?.removeEventListener(\"navigate\", handleNavigate);\n document.removeEventListener(\"click\", handleClick, true);\n };\n }, []);\n\n return null;\n}\n"],
5
+ "mappings": ";AAEA,SAAS,iBAAiB;AAkB1B,SAAS,gBAAgB,OAAmB;AAC1C,QAAM,eAAe;AACrB,QAAM,gBAAgB;AACtB,QA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ACF;AAEA,gBAAY,iBAAiB,YAAY,cAAc;AACvD,aAAS,iBAAiB,SAAS,aAAa,IAAI;AAEpD,WAAO,MAAM;AACX,aAAO,OAAO;AACd,cAAQ,YAAY;AACpB,cAAQ,eAAe;AACvB,kBAAY,oBAAoB,YAAY,cAAc;AAC1D,eAAS,oBAAoB,SAAS,aAAa,IAAI;AAAA,IACzD;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,SAAO;AACT;",
6
6
  "names": []
7
7
  }
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { useEffect, useRef } from "react";
3
- import { buildGoogleFontsCssUrl } from "../../_vendor/replo-utils/lib/google-fonts.mjs";
3
+ import { buildGoogleFontsCssUrl } from "../../_vendor/replo-utils/lib/fonts.mjs";
4
4
  import { designLibraryPreviewMessageSchema } from "../../_vendor/schemas/designLibrary.mjs";
5
5
  const FONT_LINK_DATA_KEY = "reploDesignLibraryFont";
6
6
  function escapeCssString(value) {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../editor/design-library-preview/DesignLibraryPreview.tsx"],
4
- "sourcesContent": ["\"use client\";\n\nimport { useEffect, useRef } from \"react\";\n\nimport { buildGoogleFontsCssUrl } from \"replo-utils/lib/google-fonts\";\nimport { designLibraryPreviewMessageSchema } from \"schemas/designLibrary\";\n\nconst FONT_LINK_DATA_KEY = \"reploDesignLibraryFont\";\n\nfunction escapeCssString(value: string): string {\n return value.replace(/\\\\/gu, \"\\\\\\\\\").replace(/'/gu, \"\\\\'\");\n}\n\nexport function DesignLibraryPreview() {\n // NOTE (Ben, 2026-06-03): The custom-property keys we set last time, so on the\n // next message we remove only the ones we own that the new override set drops.\n const ownedKeys = useRef<Set<string> | null>(null);\n // NOTE (Ben, 2026-06-05): The Google Font <link> hrefs we injected, keyed by\n // href so we de-dupe and remove only our own when the override set changes.\n const ownedFontLinks = useRef<Map<string, HTMLLinkElement> | null>(null);\n // NOTE (Ben, 2026-06-05): The @font-face <style> nodes for uploaded custom\n // fonts, keyed by family with the URL we injected, so we de-dupe, re-inject\n // when a family's asset URL changes (re-upload), and remove only our own when\n // the override set changes.\n const ownedFontFaces = useRef<Map<\n string,\n { url: string; style: HTMLStyleElement }\n > | null>(null);\n // NOTE (Ben, 2026-06-05): Whether we set the document default font-family, so\n // we can clear just that.\n const ownsDefaultFont = useRef(false);\n\n // eslint-disable-next-line replo/no-use-effect -- Subscribes to window message events from the parent editor.\n useEffect(() => {\n const handleMessage = (event: MessageEvent) => {\n const parsed = designLibraryPreviewMessageSchema.safeParse(event.data);\n if (!parsed.success) return;\n const { cssVars, fonts, defaultFontCssVar } = parsed.data;\n const root = document.documentElement;\n\n // --- CSS variable overrides (colors + font role vars) ---\n const nextVars: Record<string, string> = { ...cssVars };\n for (const font of fonts) {\n nextVars[font.cssVar] = `'${escapeCssString(font.family)}'`;\n }\n const owned = ownedKeys.current ?? new Set();\n for (const key of owned) {\n if (!(key in nextVars)) root.style.removeProperty(key);\n }\n ownedKeys.current = new Set(Object.keys(nextVars));\n for (const [key, value] of Object.entries(nextVars)) {\n root.style.setProperty(key, value);\n }\n\n // Custom uploaded fonts carry a faceUrl; Google fonts don't.\n const customFonts = fonts.filter((font) => Boolean(font.faceUrl));\n const googleFonts = fonts.filter((font) => !font.faceUrl);\n\n // --- Google Font stylesheets (<link> to the CDN) ---\n const links = ownedFontLinks.current ?? new Map();\n const nextHrefs = new Set(\n googleFonts.map((font) => buildGoogleFontsCssUrl(font.family)),\n );\n for (const [href, link] of links) {\n if (!nextHrefs.has(href)) {\n link.remove();\n links.delete(href);\n }\n }\n for (const href of nextHrefs) {\n if (links.has(href)) continue;\n const link = document.createElement(\"link\");\n link.rel = \"stylesheet\";\n link.href = href;\n link.dataset[FONT_LINK_DATA_KEY] = \"\";\n document.head.append(link);\n links.set(href, link);\n }\n ownedFontLinks.current = links;\n\n // --- Custom uploaded fonts (@font-face from the asset URL) ---\n const faces = ownedFontFaces.current ?? new Map();\n const nextFamilies = new Set(customFonts.map((font) => font.family));\n for (const [family, entry] of faces) {\n if (!nextFamilies.has(family)) {\n entry.style.remove();\n faces.delete(family);\n }\n }\n for (const font of customFonts) {\n if (!font.faceUrl) continue;\n const existing = faces.get(font.family);\n // Re-upload reuses the family but changes the asset URL; replace the\n // stale node rather than skipping it.\n if (existing?.url === font.faceUrl) continue;\n existing?.style.remove();\n const style = document.createElement(\"style\");\n style.dataset[FONT_LINK_DATA_KEY] = \"\";\n const format = font.format\n ? ` format('${escapeCssString(font.format)}')`\n : \"\";\n style.textContent = `@font-face{font-family:'${escapeCssString(font.family)}';font-weight:400;font-style:normal;src:url('${escapeCssString(font.faceUrl)}')${format};font-display:swap;}`;\n document.head.append(style);\n faces.set(font.family, { url: font.faceUrl, style });\n }\n ownedFontFaces.current = faces;\n\n // --- Document default font ---\n if (defaultFontCssVar) {\n root.style.setProperty(\"font-family\", `var(${defaultFontCssVar})`);\n ownsDefaultFont.current = true;\n } else if (ownsDefaultFont.current) {\n root.style.removeProperty(\"font-family\");\n ownsDefaultFont.current = false;\n }\n };\n window.addEventListener(\"message\", handleMessage);\n return () => {\n window.removeEventListener(\"message\", handleMessage);\n };\n }, []);\n\n return null;\n}\n"],
4
+ "sourcesContent": ["\"use client\";\n\nimport { useEffect, useRef } from \"react\";\n\nimport { buildGoogleFontsCssUrl } from \"replo-utils/lib/fonts\";\nimport { designLibraryPreviewMessageSchema } from \"schemas/designLibrary\";\n\nconst FONT_LINK_DATA_KEY = \"reploDesignLibraryFont\";\n\nfunction escapeCssString(value: string): string {\n return value.replace(/\\\\/gu, \"\\\\\\\\\").replace(/'/gu, \"\\\\'\");\n}\n\nexport function DesignLibraryPreview() {\n // NOTE (Ben, 2026-06-03): The custom-property keys we set last time, so on the\n // next message we remove only the ones we own that the new override set drops.\n const ownedKeys = useRef<Set<string> | null>(null);\n // NOTE (Ben, 2026-06-05): The Google Font <link> hrefs we injected, keyed by\n // href so we de-dupe and remove only our own when the override set changes.\n const ownedFontLinks = useRef<Map<string, HTMLLinkElement> | null>(null);\n // NOTE (Ben, 2026-06-05): The @font-face <style> nodes for uploaded custom\n // fonts, keyed by family with the URL we injected, so we de-dupe, re-inject\n // when a family's asset URL changes (re-upload), and remove only our own when\n // the override set changes.\n const ownedFontFaces = useRef<Map<\n string,\n { url: string; style: HTMLStyleElement }\n > | null>(null);\n // NOTE (Ben, 2026-06-05): Whether we set the document default font-family, so\n // we can clear just that.\n const ownsDefaultFont = useRef(false);\n\n // eslint-disable-next-line replo/no-use-effect -- Subscribes to window message events from the parent editor.\n useEffect(() => {\n const handleMessage = (event: MessageEvent) => {\n const parsed = designLibraryPreviewMessageSchema.safeParse(event.data);\n if (!parsed.success) return;\n const { cssVars, fonts, defaultFontCssVar } = parsed.data;\n const root = document.documentElement;\n\n // --- CSS variable overrides (colors + font role vars) ---\n const nextVars: Record<string, string> = { ...cssVars };\n for (const font of fonts) {\n nextVars[font.cssVar] = `'${escapeCssString(font.family)}'`;\n }\n const owned = ownedKeys.current ?? new Set();\n for (const key of owned) {\n if (!(key in nextVars)) root.style.removeProperty(key);\n }\n ownedKeys.current = new Set(Object.keys(nextVars));\n for (const [key, value] of Object.entries(nextVars)) {\n root.style.setProperty(key, value);\n }\n\n // Custom uploaded fonts carry a faceUrl; Google fonts don't.\n const customFonts = fonts.filter((font) => Boolean(font.faceUrl));\n const googleFonts = fonts.filter((font) => !font.faceUrl);\n\n // --- Google Font stylesheets (<link> to the CDN) ---\n const links = ownedFontLinks.current ?? new Map();\n const nextHrefs = new Set(\n googleFonts.map((font) => buildGoogleFontsCssUrl(font.family)),\n );\n for (const [href, link] of links) {\n if (!nextHrefs.has(href)) {\n link.remove();\n links.delete(href);\n }\n }\n for (const href of nextHrefs) {\n if (links.has(href)) continue;\n const link = document.createElement(\"link\");\n link.rel = \"stylesheet\";\n link.href = href;\n link.dataset[FONT_LINK_DATA_KEY] = \"\";\n document.head.append(link);\n links.set(href, link);\n }\n ownedFontLinks.current = links;\n\n // --- Custom uploaded fonts (@font-face from the asset URL) ---\n const faces = ownedFontFaces.current ?? new Map();\n const nextFamilies = new Set(customFonts.map((font) => font.family));\n for (const [family, entry] of faces) {\n if (!nextFamilies.has(family)) {\n entry.style.remove();\n faces.delete(family);\n }\n }\n for (const font of customFonts) {\n if (!font.faceUrl) continue;\n const existing = faces.get(font.family);\n // Re-upload reuses the family but changes the asset URL; replace the\n // stale node rather than skipping it.\n if (existing?.url === font.faceUrl) continue;\n existing?.style.remove();\n const style = document.createElement(\"style\");\n style.dataset[FONT_LINK_DATA_KEY] = \"\";\n const format = font.format\n ? ` format('${escapeCssString(font.format)}')`\n : \"\";\n style.textContent = `@font-face{font-family:'${escapeCssString(font.family)}';font-weight:400;font-style:normal;src:url('${escapeCssString(font.faceUrl)}')${format};font-display:swap;}`;\n document.head.append(style);\n faces.set(font.family, { url: font.faceUrl, style });\n }\n ownedFontFaces.current = faces;\n\n // --- Document default font ---\n if (defaultFontCssVar) {\n root.style.setProperty(\"font-family\", `var(${defaultFontCssVar})`);\n ownsDefaultFont.current = true;\n } else if (ownsDefaultFont.current) {\n root.style.removeProperty(\"font-family\");\n ownsDefaultFont.current = false;\n }\n };\n window.addEventListener(\"message\", handleMessage);\n return () => {\n window.removeEventListener(\"message\", handleMessage);\n };\n }, []);\n\n return null;\n}\n"],
5
5
  "mappings": ";AAEA,SAAS,WAAW,cAAc;AAElC,SAAS,8BAA8B;AACvC,SAAS,yCAAyC;AAElD,MAAM,qBAAqB;AAE3B,SAAS,gBAAgB,OAAuB;AAC9C,SAAO,MAAM,QAAQ,QAAQ,MAAM,EAAE,QAAQ,OAAO,KAAK;AAC3D;AAEO,SAAS,uBAAuB;AAGrC,QAAM,YAAY,OAA2B,IAAI;AAGjD,QAAM,iBAAiB,OAA4C,IAAI;AAKvE,QAAM,iBAAiB,OAGb,IAAI;AAGd,QAAM,kBAAkB,OAAO,KAAK;AAGpC,YAAU,MAAM;AACd,UAAM,gBAAgB,CAAC,UAAwB;AAC7C,YAAM,SAAS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useEffect doesn't have any dependencies - it's designed to only run once. So if you expect your read() function to return
8
8
  * different values through the lifecycle of the component, you should not use this hook.
9
9
  */
10
- export declare function useClientValue<T>(readValue: () => T, initialValue: T): T;
10
+ export declare function useClientValue<ValueType>(readValue: () => ValueType, initialValue: ValueType): ValueType;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../hooks/use-client-value.ts"],
4
- "sourcesContent": ["import * as React from \"react\";\n\n/**\n * NOTE (Max, 2025-09-15): This hook is to be used for values that aren't available on the server (such as window.location).\n *\n * This hook will use a dummy value both on the server & on hydration. Then,\n * after hydration, this useEffect will update the value to the actual value.\n *\n * The useEffect doesn't have any dependencies - it's designed to only run once. So if you expect your read() function to return\n * different values through the lifecycle of the component, you should not use this hook.\n */\n\nexport function useClientValue<T>(readValue: () => T, initialValue: T) {\n const [value, setValue] = React.useState<T>(initialValue);\n\n /* eslint-disable replo/no-use-effect -- Legacy effect - may or may not be necessary */\n React.useEffect(() => {\n setValue(readValue());\n }, []);\n /* eslint-enable replo/no-use-effect */\n return value;\n}\n"],
5
- "mappings": "AAAA,YAAY,WAAW;AAYhB,SAAS,eAAkB,WAAoB,cAAiB;AACrE,QAAM,CAAC,OAAO,QAAQ,IAAI,MAAM,SAAY,YAAY;AAGxD,QAAM,UAAU,MAAM;AACpB,aAAS,UAAU,CAAC;AAAA,EACtB,GAAG,CAAC,CAAC;AAEL,SAAO;AACT;",
4
+ "sourcesContent": ["import * as React from \"react\";\n\n/**\n * NOTE (Max, 2025-09-15): This hook is to be used for values that aren't available on the server (such as window.location).\n *\n * This hook will use a dummy value both on the server & on hydration. Then,\n * after hydration, this useEffect will update the value to the actual value.\n *\n * The useEffect doesn't have any dependencies - it's designed to only run once. So if you expect your read() function to return\n * different values through the lifecycle of the component, you should not use this hook.\n */\n\nexport function useClientValue<ValueType>(\n readValue: () => ValueType,\n initialValue: ValueType,\n) {\n const [value, setValue] = React.useState<ValueType>(initialValue);\n\n /* eslint-disable replo/no-use-effect -- Legacy effect - may or may not be necessary */\n React.useEffect(() => {\n setValue(readValue());\n }, []);\n /* eslint-enable replo/no-use-effect */\n return value;\n}\n"],
5
+ "mappings": "AAAA,YAAY,WAAW;AAYhB,SAAS,eACd,WACA,cACA;AACA,QAAM,CAAC,OAAO,QAAQ,IAAI,MAAM,SAAoB,YAAY;AAGhE,QAAM,UAAU,MAAM;AACpB,aAAS,UAAU,CAAC;AAAA,EACtB,GAAG,CAAC,CAAC;AAEL,SAAO;AACT;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@replohq/canopy-sdk",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "Replo Canopy SDK — cart, analytics, data loaders, and editor runtime for agent-built Next.js sites.",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -1,28 +0,0 @@
1
- // ../replo-utils/lib/google-fonts.ts
2
- function slugifyFontFamily(family) {
3
- return family.replace(/([a-z])([A-Z])/g, "$1-$2").split(/[\s_-]+/u).map((word) => word.toLowerCase()).join("-");
4
- }
5
- function fontNameToCssVariable(fontName) {
6
- return `--font-${slugifyFontFamily(fontName)}`;
7
- }
8
- function quoteFontFamily(family) {
9
- return /\s/u.test(family) ? `'${family}'` : family;
10
- }
11
- function fontNameToVariableName(fontName) {
12
- const words = fontName.replace(/([a-z])([A-Z])/g, "$1 $2").split(/[\s_-]+/u);
13
- return words.map((word, index) => {
14
- return index === 0 ? word.toLowerCase() : word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();
15
- }).join("");
16
- }
17
- function buildGoogleFontsCssUrl(family, weights) {
18
- const requested = weights && weights.length > 0 ? Array.from(new Set(weights)) : [400];
19
- const sortedWeights = requested.sort(
20
- (leftWeight, rightWeight) => leftWeight - rightWeight
21
- );
22
- const familyParam = family.trim().replace(/\s+/gu, "+");
23
- return `https://fonts.googleapis.com/css2?family=${familyParam}:wght@${sortedWeights.join(
24
- ";"
25
- )}&display=swap`;
26
- }
27
-
28
- export { buildGoogleFontsCssUrl, fontNameToCssVariable, fontNameToVariableName, quoteFontFamily, slugifyFontFamily };