@replohq/canopy-sdk 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { priceSchema, metafieldSchema, imageSchema, selectedOptionSchema, mediaSchema, productOptionSchema, productSchema } from '../../../../../chunk-46YU2W6T.mjs';
1
+ import { priceSchema, metafieldSchema, imageSchema, selectedOptionSchema, mediaSchema, productOptionSchema, productSchema } from '../../../../../chunk-7WEM5FUJ.mjs';
2
2
  import { sellingPlanGroupSchema } from '../../../../../chunk-4TZVNC3W.mjs';
3
3
  import { z } from 'zod';
4
4
 
@@ -330,6 +330,8 @@ export declare const DESIGN_LIBRARY_PREVIEW_MESSAGE_TYPE = "replo:design-library
330
330
  export declare const designLibraryPreviewFontSchema: z.ZodObject<{
331
331
  family: z.ZodString;
332
332
  cssVar: z.ZodString;
333
+ faceUrl: z.ZodOptional<z.ZodString>;
334
+ format: z.ZodOptional<z.ZodString>;
333
335
  }, z.core.$strip>;
334
336
  export declare const designLibraryPreviewMessageSchema: z.ZodObject<{
335
337
  type: z.ZodLiteral<"replo:design-library:applyOverrides">;
@@ -337,6 +339,8 @@ export declare const designLibraryPreviewMessageSchema: z.ZodObject<{
337
339
  fonts: z.ZodArray<z.ZodObject<{
338
340
  family: z.ZodString;
339
341
  cssVar: z.ZodString;
342
+ faceUrl: z.ZodOptional<z.ZodString>;
343
+ format: z.ZodOptional<z.ZodString>;
340
344
  }, z.core.$strip>>;
341
345
  defaultFontCssVar: z.ZodNullable<z.ZodString>;
342
346
  }, z.core.$strip>;
@@ -102,7 +102,9 @@ var globalsCssSnapshotSchema = z.object({
102
102
  var DESIGN_LIBRARY_PREVIEW_MESSAGE_TYPE = "replo:design-library:applyOverrides";
103
103
  var designLibraryPreviewFontSchema = z.object({
104
104
  family: z.string(),
105
- cssVar: z.string()
105
+ cssVar: z.string(),
106
+ faceUrl: z.string().optional(),
107
+ format: z.string().optional()
106
108
  }).describe("DesignLibraryPreviewFont");
107
109
  var designLibraryPreviewMessageSchema = z.object({
108
110
  type: z.literal(DESIGN_LIBRARY_PREVIEW_MESSAGE_TYPE),
@@ -400,6 +400,29 @@ export declare const intelligemsExperienceSchema: z.ZodObject<{
400
400
  category: z.ZodOptional<z.ZodString>;
401
401
  status: z.ZodOptional<z.ZodString>;
402
402
  }, z.core.$strip>;
403
+ export declare const customerIoSegmentSchema: z.ZodObject<{
404
+ id: z.ZodString;
405
+ name: z.ZodOptional<z.ZodString>;
406
+ description: z.ZodOptional<z.ZodString>;
407
+ type: z.ZodOptional<z.ZodString>;
408
+ }, z.core.$strip>;
409
+ export declare const customerIoCampaignSchema: z.ZodObject<{
410
+ id: z.ZodString;
411
+ name: z.ZodOptional<z.ZodString>;
412
+ type: z.ZodOptional<z.ZodString>;
413
+ active: z.ZodOptional<z.ZodBoolean>;
414
+ }, z.core.$strip>;
415
+ export declare const customerIoBroadcastSchema: z.ZodObject<{
416
+ id: z.ZodString;
417
+ name: z.ZodOptional<z.ZodString>;
418
+ active: z.ZodOptional<z.ZodBoolean>;
419
+ }, z.core.$strip>;
420
+ export declare const vwoCampaignSchema: z.ZodObject<{
421
+ id: z.ZodString;
422
+ name: z.ZodOptional<z.ZodString>;
423
+ type: z.ZodOptional<z.ZodString>;
424
+ status: z.ZodOptional<z.ZodString>;
425
+ }, z.core.$strip>;
403
426
  export declare const okendoReviewSchema: z.ZodObject<{
404
427
  id: z.ZodString;
405
428
  title: z.ZodOptional<z.ZodString>;
@@ -410,6 +433,16 @@ export declare const okendoReviewSchema: z.ZodObject<{
410
433
  dateCreated: z.ZodOptional<z.ZodString>;
411
434
  status: z.ZodOptional<z.ZodString>;
412
435
  }, z.core.$strip>;
436
+ export declare const looxReviewSchema: z.ZodObject<{
437
+ id: z.ZodString;
438
+ title: z.ZodOptional<z.ZodString>;
439
+ body: z.ZodOptional<z.ZodString>;
440
+ rating: z.ZodOptional<z.ZodNumber>;
441
+ productName: z.ZodOptional<z.ZodString>;
442
+ reviewerName: z.ZodOptional<z.ZodString>;
443
+ dateCreated: z.ZodOptional<z.ZodString>;
444
+ status: z.ZodOptional<z.ZodString>;
445
+ }, z.core.$strip>;
413
446
  export declare const planSchema: z.ZodObject<{
414
447
  id: z.ZodString;
415
448
  name: z.ZodOptional<z.ZodString>;
@@ -800,6 +833,61 @@ declare const OBJECT_TYPE_REGISTRY: {
800
833
  }, z.core.$strip>;
801
834
  mentionable: true;
802
835
  };
836
+ customerIoSegment: {
837
+ type: string;
838
+ displayName: string;
839
+ identifiers: {
840
+ primaryId: string;
841
+ };
842
+ canonicalSchema: z.ZodObject<{
843
+ id: z.ZodString;
844
+ name: z.ZodOptional<z.ZodString>;
845
+ description: z.ZodOptional<z.ZodString>;
846
+ type: z.ZodOptional<z.ZodString>;
847
+ }, z.core.$strip>;
848
+ mentionable: true;
849
+ };
850
+ customerIoCampaign: {
851
+ type: string;
852
+ displayName: string;
853
+ identifiers: {
854
+ primaryId: string;
855
+ };
856
+ canonicalSchema: z.ZodObject<{
857
+ id: z.ZodString;
858
+ name: z.ZodOptional<z.ZodString>;
859
+ type: z.ZodOptional<z.ZodString>;
860
+ active: z.ZodOptional<z.ZodBoolean>;
861
+ }, z.core.$strip>;
862
+ mentionable: true;
863
+ };
864
+ customerIoBroadcast: {
865
+ type: string;
866
+ displayName: string;
867
+ identifiers: {
868
+ primaryId: string;
869
+ };
870
+ canonicalSchema: z.ZodObject<{
871
+ id: z.ZodString;
872
+ name: z.ZodOptional<z.ZodString>;
873
+ active: z.ZodOptional<z.ZodBoolean>;
874
+ }, z.core.$strip>;
875
+ mentionable: true;
876
+ };
877
+ vwoCampaign: {
878
+ type: string;
879
+ displayName: string;
880
+ identifiers: {
881
+ primaryId: string;
882
+ };
883
+ canonicalSchema: z.ZodObject<{
884
+ id: z.ZodString;
885
+ name: z.ZodOptional<z.ZodString>;
886
+ type: z.ZodOptional<z.ZodString>;
887
+ status: z.ZodOptional<z.ZodString>;
888
+ }, z.core.$strip>;
889
+ mentionable: true;
890
+ };
803
891
  levantaProduct: {
804
892
  type: string;
805
893
  displayName: string;
@@ -844,6 +932,24 @@ declare const OBJECT_TYPE_REGISTRY: {
844
932
  }, z.core.$strip>;
845
933
  mentionable: true;
846
934
  };
935
+ looxReview: {
936
+ type: string;
937
+ displayName: string;
938
+ identifiers: {
939
+ primaryId: string;
940
+ };
941
+ canonicalSchema: z.ZodObject<{
942
+ id: z.ZodString;
943
+ title: z.ZodOptional<z.ZodString>;
944
+ body: z.ZodOptional<z.ZodString>;
945
+ rating: z.ZodOptional<z.ZodNumber>;
946
+ productName: z.ZodOptional<z.ZodString>;
947
+ reviewerName: z.ZodOptional<z.ZodString>;
948
+ dateCreated: z.ZodOptional<z.ZodString>;
949
+ status: z.ZodOptional<z.ZodString>;
950
+ }, z.core.$strip>;
951
+ mentionable: true;
952
+ };
847
953
  plan: {
848
954
  type: string;
849
955
  displayName: string;
@@ -1,2 +1,2 @@
1
- export { assetSchema, collectionSchema, externalVideoSchema, getObjectTypeDefinition, imageSchema, integrationSchema, intelligemsExperienceSchema, levantaAffiliateLinkSchema, levantaProductSchema, mediaImageSchema, mediaSchema, metafieldSchema, okendoReviewSchema, optionValueSchema, optionValueSwatchSchema, opusClipSchema, opusCollectionSchema, opusProjectSchema, pageSchema, planSchema, previewImageSchema, priceSchema, productOptionSchema, productSchema, registryItemSchema, segmentSourceSchema, selectedOptionSchema, transformReploProductToCanonical, variantSchema, videoSchema, videoSourceSchema } from '../../chunk-46YU2W6T.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-7WEM5FUJ.mjs';
2
2
  import '../../chunk-4TZVNC3W.mjs';
@@ -299,6 +299,29 @@ var intelligemsExperienceSchema = z.object({
299
299
  category: z.string().optional(),
300
300
  status: z.string().optional()
301
301
  }).describe("IntelligemsExperience");
302
+ var customerIoSegmentSchema = z.object({
303
+ id: z.string().describe("customerIoSegment primaryId"),
304
+ name: z.string().optional(),
305
+ description: z.string().optional(),
306
+ type: z.string().optional()
307
+ }).describe("CustomerIoSegment");
308
+ var customerIoCampaignSchema = z.object({
309
+ id: z.string().describe("customerIoCampaign primaryId"),
310
+ name: z.string().optional(),
311
+ type: z.string().optional(),
312
+ active: z.boolean().optional()
313
+ }).describe("CustomerIoCampaign");
314
+ var customerIoBroadcastSchema = z.object({
315
+ id: z.string().describe("customerIoBroadcast primaryId"),
316
+ name: z.string().optional(),
317
+ active: z.boolean().optional()
318
+ }).describe("CustomerIoBroadcast");
319
+ var vwoCampaignSchema = z.object({
320
+ id: z.string(),
321
+ name: z.string().optional(),
322
+ type: z.string().optional(),
323
+ status: z.string().optional()
324
+ }).describe("VwoCampaign");
302
325
  var okendoReviewSchema = z.object({
303
326
  id: z.string(),
304
327
  title: z.string().optional(),
@@ -309,6 +332,16 @@ var okendoReviewSchema = z.object({
309
332
  dateCreated: z.string().optional(),
310
333
  status: z.string().optional()
311
334
  }).describe("OkendoReview");
335
+ var looxReviewSchema = z.object({
336
+ id: z.string(),
337
+ title: z.string().optional(),
338
+ body: z.string().optional(),
339
+ rating: z.number().optional(),
340
+ productName: z.string().optional(),
341
+ reviewerName: z.string().optional(),
342
+ dateCreated: z.string().optional(),
343
+ status: z.string().optional()
344
+ }).describe("LooxReview");
312
345
  var planSchema = z.object({
313
346
  id: z.string(),
314
347
  name: z.string().optional(),
@@ -435,6 +468,42 @@ var OBJECT_TYPE_REGISTRY = {
435
468
  canonicalSchema: intelligemsExperienceSchema,
436
469
  mentionable: true
437
470
  },
471
+ customerIoSegment: {
472
+ type: "customerIoSegment",
473
+ displayName: "Customer.io Segment",
474
+ identifiers: {
475
+ primaryId: "id"
476
+ },
477
+ canonicalSchema: customerIoSegmentSchema,
478
+ mentionable: true
479
+ },
480
+ customerIoCampaign: {
481
+ type: "customerIoCampaign",
482
+ displayName: "Customer.io Campaign",
483
+ identifiers: {
484
+ primaryId: "id"
485
+ },
486
+ canonicalSchema: customerIoCampaignSchema,
487
+ mentionable: true
488
+ },
489
+ customerIoBroadcast: {
490
+ type: "customerIoBroadcast",
491
+ displayName: "Customer.io Broadcast",
492
+ identifiers: {
493
+ primaryId: "id"
494
+ },
495
+ canonicalSchema: customerIoBroadcastSchema,
496
+ mentionable: true
497
+ },
498
+ vwoCampaign: {
499
+ type: "vwoCampaign",
500
+ displayName: "VWO Campaign",
501
+ identifiers: {
502
+ primaryId: "id"
503
+ },
504
+ canonicalSchema: vwoCampaignSchema,
505
+ mentionable: true
506
+ },
438
507
  levantaProduct: {
439
508
  type: "levantaProduct",
440
509
  displayName: "Levanta Product",
@@ -453,6 +522,15 @@ var OBJECT_TYPE_REGISTRY = {
453
522
  canonicalSchema: okendoReviewSchema,
454
523
  mentionable: true
455
524
  },
525
+ looxReview: {
526
+ type: "looxReview",
527
+ displayName: "Loox Review",
528
+ identifiers: {
529
+ primaryId: "id"
530
+ },
531
+ canonicalSchema: looxReviewSchema,
532
+ mentionable: true
533
+ },
456
534
  plan: {
457
535
  type: "plan",
458
536
  displayName: "Plan",
@@ -535,4 +613,4 @@ function transformReploProductToCanonical(product) {
535
613
  };
536
614
  }
537
615
 
538
- export { assetSchema, collectionSchema, externalVideoSchema, getObjectTypeDefinition, imageSchema, integrationSchema, intelligemsExperienceSchema, levantaAffiliateLinkSchema, levantaProductSchema, mediaImageSchema, mediaSchema, metafieldSchema, okendoReviewSchema, optionValueSchema, optionValueSwatchSchema, opusClipSchema, opusCollectionSchema, opusProjectSchema, pageSchema, planSchema, previewImageSchema, priceSchema, productOptionSchema, productSchema, registryItemSchema, segmentSourceSchema, selectedOptionSchema, transformReploProductToCanonical, variantSchema, videoSchema, videoSourceSchema };
616
+ 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 };
@@ -3,9 +3,13 @@ import { useEffect, useRef } from "react";
3
3
  import { buildGoogleFontsCssUrl } from "../../_vendor/replo-utils/lib/google-fonts.mjs";
4
4
  import { designLibraryPreviewMessageSchema } from "../../_vendor/schemas/designLibrary.mjs";
5
5
  const FONT_LINK_DATA_KEY = "reploDesignLibraryFont";
6
+ function escapeCssString(value) {
7
+ return value.replace(/\\/gu, "\\\\").replace(/'/gu, "\\'");
8
+ }
6
9
  function DesignLibraryPreview() {
7
10
  const ownedKeys = useRef(null);
8
11
  const ownedFontLinks = useRef(null);
12
+ const ownedFontFaces = useRef(null);
9
13
  const ownsDefaultFont = useRef(false);
10
14
  useEffect(() => {
11
15
  const handleMessage = (event) => {
@@ -15,7 +19,7 @@ function DesignLibraryPreview() {
15
19
  const root = document.documentElement;
16
20
  const nextVars = { ...cssVars };
17
21
  for (const font of fonts) {
18
- nextVars[font.cssVar] = `'${font.family}'`;
22
+ nextVars[font.cssVar] = `'${escapeCssString(font.family)}'`;
19
23
  }
20
24
  const owned = ownedKeys.current ?? /* @__PURE__ */ new Set();
21
25
  for (const key of owned) {
@@ -25,9 +29,11 @@ function DesignLibraryPreview() {
25
29
  for (const [key, value] of Object.entries(nextVars)) {
26
30
  root.style.setProperty(key, value);
27
31
  }
32
+ const customFonts = fonts.filter((font) => Boolean(font.faceUrl));
33
+ const googleFonts = fonts.filter((font) => !font.faceUrl);
28
34
  const links = ownedFontLinks.current ?? /* @__PURE__ */ new Map();
29
35
  const nextHrefs = new Set(
30
- fonts.map((font) => buildGoogleFontsCssUrl(font.family))
36
+ googleFonts.map((font) => buildGoogleFontsCssUrl(font.family))
31
37
  );
32
38
  for (const [href, link] of links) {
33
39
  if (!nextHrefs.has(href)) {
@@ -45,6 +51,27 @@ function DesignLibraryPreview() {
45
51
  links.set(href, link);
46
52
  }
47
53
  ownedFontLinks.current = links;
54
+ const faces = ownedFontFaces.current ?? /* @__PURE__ */ new Map();
55
+ const nextFamilies = new Set(customFonts.map((font) => font.family));
56
+ for (const [family, entry] of faces) {
57
+ if (!nextFamilies.has(family)) {
58
+ entry.style.remove();
59
+ faces.delete(family);
60
+ }
61
+ }
62
+ for (const font of customFonts) {
63
+ if (!font.faceUrl) continue;
64
+ const existing = faces.get(font.family);
65
+ if (existing?.url === font.faceUrl) continue;
66
+ existing?.style.remove();
67
+ const style = document.createElement("style");
68
+ style.dataset[FONT_LINK_DATA_KEY] = "";
69
+ const format = font.format ? ` format('${escapeCssString(font.format)}')` : "";
70
+ style.textContent = `@font-face{font-family:'${escapeCssString(font.family)}';font-weight:400;font-style:normal;src:url('${escapeCssString(font.faceUrl)}')${format};font-display:swap;}`;
71
+ document.head.append(style);
72
+ faces.set(font.family, { url: font.faceUrl, style });
73
+ }
74
+ ownedFontFaces.current = faces;
48
75
  if (defaultFontCssVar) {
49
76
  root.style.setProperty("font-family", `var(${defaultFontCssVar})`);
50
77
  ownsDefaultFont.current = true;
@@ -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\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): 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] = `'${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 // --- Google Font stylesheets ---\n const links = ownedFontLinks.current ?? new Map();\n const nextHrefs = new Set(\n fonts.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 // --- 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
- "mappings": ";AAEA,SAAS,WAAW,cAAc;AAElC,SAAS,8BAA8B;AACvC,SAAS,yCAAyC;AAElD,MAAM,qBAAqB;AAEpB,SAAS,uBAAuB;AAGrC,QAAM,YAAY,OAA2B,IAAI;AAGjD,QAAM,iBAAiB,OAA4C,IAAI;AAGvE,QAAM,kBAAkB,OAAO,KAAK;AAGpC,YAAU,MAAM;AACd,UAAM,gBAAgB,CAAC,UAAwB;AAC7C,YAAM,SAAS,kCAAkC,UAAU,MAAM,IAAI;AACrE,UAAI,CAAC,OAAO,QAAS;AACrB,YAAM,EAAE,SAAS,OAAO,kBAAkB,IAAI,OAAO;AACrD,YAAM,OAAO,SAAS;AAGtB,YAAM,WAAmC,EAAE,GAAG,QAAQ;AACtD,iBAAW,QAAQ,OAAO;AACxB,iBAAS,KAAK,MAAM,IAAI,IAAI,KAAK,MAAM;AAAA,MACzC;AACA,YAAM,QAAQ,UAAU,WAAW,oBAAI,IAAI;AAC3C,iBAAW,OAAO,OAAO;AACvB,YAAI,EAAE,OAAO,UAAW,MAAK,MAAM,eAAe,GAAG;AAAA,MACvD;AACA,gBAAU,UAAU,IAAI,IAAI,OAAO,KAAK,QAAQ,CAAC;AACjD,iBAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,QAAQ,GAAG;AACnD,aAAK,MAAM,YAAY,KAAK,KAAK;AAAA,MACnC;AAGA,YAAM,QAAQ,eAAe,WAAW,oBAAI,IAAI;AAChD,YAAM,YAAY,IAAI;AAAA,QACpB,MAAM,IAAI,CAAC,SAAS,uBAAuB,KAAK,MAAM,CAAC;AAAA,MACzD;AACA,iBAAW,CAAC,MAAM,IAAI,KAAK,OAAO;AAChC,YAAI,CAAC,UAAU,IAAI,IAAI,GAAG;AACxB,eAAK,OAAO;AACZ,gBAAM,OAAO,IAAI;AAAA,QACnB;AAAA,MACF;AACA,iBAAW,QAAQ,WAAW;AAC5B,YAAI,MAAM,IAAI,IAAI,EAAG;AACrB,cAAM,OAAO,SAAS,cAAc,MAAM;AAC1C,aAAK,MAAM;AACX,aAAK,OAAO;AACZ,aAAK,QAAQ,kBAAkB,IAAI;AACnC,iBAAS,KAAK,OAAO,IAAI;AACzB,cAAM,IAAI,MAAM,IAAI;AAAA,MACtB;AACA,qBAAe,UAAU;AAGzB,UAAI,mBAAmB;AACrB,aAAK,MAAM,YAAY,eAAe,OAAO,iBAAiB,GAAG;AACjE,wBAAgB,UAAU;AAAA,MAC5B,WAAW,gBAAgB,SAAS;AAClC,aAAK,MAAM,eAAe,aAAa;AACvC,wBAAgB,UAAU;AAAA,MAC5B;AAAA,IACF;AACA,WAAO,iBAAiB,WAAW,aAAa;AAChD,WAAO,MAAM;AACX,aAAO,oBAAoB,WAAW,aAAa;AAAA,IACrD;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,SAAO;AACT;",
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"],
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,MA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ACT;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@replohq/canopy-sdk",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
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,