@replohq/canopy-sdk 3.0.0 → 3.0.2

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.
@@ -10,6 +10,7 @@ export type ScriptTagDescriptor = {
10
10
  } | {
11
11
  kind: "inline";
12
12
  body: string;
13
+ module?: boolean;
13
14
  };
14
15
  export type ReploScriptEntry = {
15
16
  type: "GA4" | "GoogleTagManager" | "Meta" | "TikTok" | "Pinterest" | "Reddit" | "Snapchat" | "Hotjar" | "MicrosoftClarity" | "Contentsquare" | "Segment" | "Northbeam";
@@ -19,6 +20,7 @@ export type ReploScriptEntry = {
19
20
  type: "snippet";
20
21
  id: string;
21
22
  body: string;
23
+ module?: boolean;
22
24
  requiredConsent: ConsentCategory[];
23
25
  } | {
24
26
  type: "custom";
@@ -1,4 +1,11 @@
1
1
  import type { DisplayMode, SelectModeSelectionType, SelectModeOptimisticUpdatePayload, SelectModeFormatCommand, SelectableData, SelectModeBoundingRect, SelectModeClickPosition, SelectModeSelectionRect, SelectModeTiptapActiveMarks } from "./selectMode";
2
+ export type IframeRuntimeBuildMetadata = {
3
+ packageName: string;
4
+ version: string;
5
+ branch: string | null;
6
+ commit: string | null;
7
+ builtAt: string | null;
8
+ };
2
9
  export type SelectModeParentMessage = {
3
10
  method: "setDisplayMode";
4
11
  data: {
@@ -46,6 +53,7 @@ export type SelectModeParentMessage = {
46
53
  };
47
54
  export type SelectModeIframeMessage = {
48
55
  method: "iframeReady";
56
+ data?: IframeRuntimeBuildMetadata;
49
57
  } | {
50
58
  method: "elementSelected";
51
59
  data: {
@@ -1,8 +1,8 @@
1
1
  import '../../chunk-UJCSKKID.mjs';
2
2
 
3
3
  // lib/tombstone.ts
4
- var migrationCommand = `pnpm add @replohq/sdk@latest @replohq/sandbox-runtime@latest && pnpm remove canopy-sdk
5
- (if package.json lists "@replohq/canopy-sdk" instead of the "canopy-sdk" alias, run: pnpm remove @replohq/canopy-sdk)`;
4
+ var migrationCommand = `pnpm add --ignore-workspace @replohq/sdk@latest @replohq/sandbox-runtime@latest && pnpm remove --ignore-workspace canopy-sdk
5
+ (if package.json lists "@replohq/canopy-sdk" instead of the "canopy-sdk" alias, run: pnpm remove --ignore-workspace @replohq/canopy-sdk)`;
6
6
  var providerComposition = `import { ReploProvider } from "@replohq/sdk/providers/replo-provider";
7
7
  import { SandboxRuntime } from "@replohq/sandbox-runtime";
8
8
 
@@ -2,6 +2,13 @@ import type { SelectModeIframeMessage, SelectModeParentMessage } from "./generat
2
2
  import { z } from "zod";
3
3
  export declare const SELECT_MODE_IFRAME_RPC_CHANNEL_ID: "replo:select-mode-iframe-rpc";
4
4
  export declare const SELECT_MODE_IFRAME_RPC_CHANNEL_VERSION: 1;
5
+ export declare const iframeRuntimeBuildMetadataSchema: z.ZodObject<{
6
+ packageName: z.ZodString;
7
+ version: z.ZodString;
8
+ branch: z.ZodNullable<z.ZodString>;
9
+ commit: z.ZodNullable<z.ZodString>;
10
+ builtAt: z.ZodNullable<z.ZodString>;
11
+ }, z.core.$strip>;
5
12
  export declare const websiteBuilderToCanopyMethodConfig: {
6
13
  symbolicateSelectedElement: {
7
14
  inputSchema: z.ZodObject<{
@@ -280,7 +287,13 @@ export declare const canopyToWebsiteBuilderMethodConfig: {
280
287
  timeoutMs: number;
281
288
  };
282
289
  iframeReady: {
283
- inputSchema: z.ZodUndefined;
290
+ inputSchema: z.ZodOptional<z.ZodObject<{
291
+ packageName: z.ZodString;
292
+ version: z.ZodString;
293
+ branch: z.ZodNullable<z.ZodString>;
294
+ commit: z.ZodNullable<z.ZodString>;
295
+ builtAt: z.ZodNullable<z.ZodString>;
296
+ }, z.core.$strip>>;
284
297
  outputSchema: z.ZodVoid;
285
298
  };
286
299
  elementSelected: {
@@ -629,6 +642,13 @@ export declare const selectModeParentMessageSchema: z.ZodDiscriminatedUnion<[z.Z
629
642
  }, z.core.$strip>], "method">;
630
643
  export declare const selectModeIframeMessageSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
631
644
  method: z.ZodLiteral<"iframeReady">;
645
+ data: z.ZodOptional<z.ZodObject<{
646
+ packageName: z.ZodString;
647
+ version: z.ZodString;
648
+ branch: z.ZodNullable<z.ZodString>;
649
+ commit: z.ZodNullable<z.ZodString>;
650
+ builtAt: z.ZodNullable<z.ZodString>;
651
+ }, z.core.$strip>>;
632
652
  }, z.core.$strip>, z.ZodObject<{
633
653
  method: z.ZodLiteral<"elementSelected">;
634
654
  data: z.ZodObject<{
@@ -8,6 +8,13 @@ import { z } from 'zod';
8
8
 
9
9
  var SELECT_MODE_IFRAME_RPC_CHANNEL_ID = "replo:select-mode-iframe-rpc";
10
10
  var SELECT_MODE_IFRAME_RPC_CHANNEL_VERSION = 1;
11
+ var iframeRuntimeBuildMetadataSchema = z.object({
12
+ packageName: z.string(),
13
+ version: z.string(),
14
+ branch: z.string().nullable(),
15
+ commit: z.string().nullable(),
16
+ builtAt: z.string().nullable()
17
+ }).describe("IframeRuntimeBuildMetadata");
11
18
  var websiteBuilderToCanopyMethodConfig = {
12
19
  symbolicateSelectedElement: {
13
20
  inputSchema: selectedElementSchema,
@@ -81,7 +88,7 @@ var canopyToWebsiteBuilderMethodConfig = {
81
88
  timeoutMs: 5e3
82
89
  },
83
90
  iframeReady: {
84
- inputSchema: z.undefined(),
91
+ inputSchema: iframeRuntimeBuildMetadataSchema.optional(),
85
92
  outputSchema: z.void()
86
93
  },
87
94
  elementSelected: {
@@ -184,7 +191,8 @@ var selectModeParentMessageSchema = z.discriminatedUnion("method", [
184
191
  ]).describe("SelectModeParentMessage");
185
192
  var selectModeIframeMessageSchema = z.discriminatedUnion("method", [
186
193
  z.object({
187
- method: z.literal("iframeReady")
194
+ method: z.literal("iframeReady"),
195
+ data: iframeRuntimeBuildMetadataSchema.optional()
188
196
  }),
189
197
  z.object({
190
198
  method: z.literal("elementSelected"),
@@ -223,4 +231,4 @@ var selectModeIframeMessageSchema = z.discriminatedUnion("method", [
223
231
  })
224
232
  ]).describe("SelectModeIframeMessage");
225
233
 
226
- export { SELECT_MODE_IFRAME_RPC_CHANNEL_ID, SELECT_MODE_IFRAME_RPC_CHANNEL_VERSION, canopyToWebsiteBuilderMethodConfig, selectModeIframeMessageSchema, selectModeParentMessageSchema, websiteBuilderToCanopyMethodConfig };
234
+ export { SELECT_MODE_IFRAME_RPC_CHANNEL_ID, SELECT_MODE_IFRAME_RPC_CHANNEL_VERSION, canopyToWebsiteBuilderMethodConfig, iframeRuntimeBuildMetadataSchema, selectModeIframeMessageSchema, selectModeParentMessageSchema, websiteBuilderToCanopyMethodConfig };
package/lib/tombstone.js CHANGED
@@ -1,5 +1,5 @@
1
- const migrationCommand = `pnpm add @replohq/sdk@latest @replohq/sandbox-runtime@latest && pnpm remove canopy-sdk
2
- (if package.json lists "@replohq/canopy-sdk" instead of the "canopy-sdk" alias, run: pnpm remove @replohq/canopy-sdk)`;
1
+ const migrationCommand = `pnpm add --ignore-workspace @replohq/sdk@latest @replohq/sandbox-runtime@latest && pnpm remove --ignore-workspace canopy-sdk
2
+ (if package.json lists "@replohq/canopy-sdk" instead of the "canopy-sdk" alias, run: pnpm remove --ignore-workspace @replohq/canopy-sdk)`;
3
3
  const providerComposition = `import { ReploProvider } from "@replohq/sdk/providers/replo-provider";
4
4
  import { SandboxRuntime } from "@replohq/sandbox-runtime";
5
5
 
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../lib/tombstone.ts"],
4
- "sourcesContent": ["type PublicSdkReplacement = {\n kind: \"public-sdk\";\n replacementImport?: string;\n};\n\ntype SandboxRuntimeReplacement = {\n kind: \"sandbox-runtime\";\n};\n\ntype InternalReplacement = {\n kind: \"internal\";\n nearestPublicSubpaths: readonly string[];\n};\n\ntype TombstoneReplacement =\n | PublicSdkReplacement\n | SandboxRuntimeReplacement\n | InternalReplacement;\n\ntype TombstoneLocation = {\n symbol: string;\n subpath: string;\n replacement?: TombstoneReplacement;\n replacementImport?: string;\n};\n\nconst migrationCommand = `pnpm add @replohq/sdk@latest @replohq/sandbox-runtime@latest && pnpm remove canopy-sdk\n(if package.json lists \"@replohq/canopy-sdk\" instead of the \"canopy-sdk\" alias, run: pnpm remove @replohq/canopy-sdk)`;\n\nconst providerComposition = `import { ReploProvider } from \"@replohq/sdk/providers/replo-provider\";\nimport { SandboxRuntime } from \"@replohq/sandbox-runtime\";\n\nexport default function RootLayout({\n children,\n}: Readonly<{\n children: React.ReactNode;\n}>) {\n return (\n <html>\n <body>\n <ReploProvider>\n <SandboxRuntime>{children}</SandboxRuntime>\n </ReploProvider>\n </body>\n </html>\n );\n}`;\n\nconst migrationRule = `For storefront imports the migration is mechanical: every public canopy-sdk/<subpath> or @replohq/canopy-sdk/<subpath> import becomes @replohq/sdk/<subpath>. Editor/select-mode functionality is not imported directly: SandboxRuntime from @replohq/sandbox-runtime provides it automatically once mounted.`;\n\nfunction reploProviderTombstoneError(): Error {\n return new Error(`ReploProvider was removed from @replohq/canopy-sdk v3, the final, fully deprecated release.\n\nReplace the single legacy provider with ReploProvider from @replohq/sdk/providers/replo-provider wrapping SandboxRuntime from @replohq/sandbox-runtime, with SandboxRuntime nested inside ReploProvider:\n\n${providerComposition}\n\nInstall the replacements and remove the deprecated package:\n${migrationCommand}\n\n${migrationRule}`);\n}\n\nfunction sandboxRuntimeMigration({ symbol }: { symbol: string }): string {\n return `${symbol} was editor/select-mode functionality. It now ships inside @replohq/sandbox-runtime and is not directly importable.\n\nMount SandboxRuntime from @replohq/sandbox-runtime inside ReploProvider from @replohq/sdk in the root layout; SandboxRuntime provides this functionality automatically:\n\n${providerComposition}\n\nThen delete this import and any /editor route code that used it.`;\n}\n\nfunction internalMigration({\n nearestPublicSubpaths,\n}: InternalReplacement): string {\n const publicApis = nearestPublicSubpaths\n .map((subpath) => `- @replohq/sdk/${subpath}`)\n .join(\"\\n\");\n\n return `This was an internal module with no direct public replacement.\n\nUse the nearest supported public API for this domain:\n${publicApis}`;\n}\n\nexport function canopyTombstoneError({\n symbol,\n subpath,\n replacement,\n replacementImport,\n}: TombstoneLocation): Error {\n if (symbol === \"ReploProvider\") {\n return reploProviderTombstoneError();\n }\n\n const resolvedReplacement = replacement ?? {\n kind: \"public-sdk\",\n replacementImport,\n };\n const migration = (() => {\n switch (resolvedReplacement.kind) {\n case \"public-sdk\":\n return `Use the replacement export:\n${\n resolvedReplacement.replacementImport ??\n `import { ${symbol} } from \"@replohq/sdk/${subpath}\";`\n}`;\n case \"sandbox-runtime\":\n return sandboxRuntimeMigration({ symbol });\n case \"internal\":\n return internalMigration(resolvedReplacement);\n }\n })();\n\n return new Error(`${symbol} was removed from @replohq/canopy-sdk v3, the final, fully deprecated release.\n\n${migration}\n\nInstall the replacements and remove the deprecated package:\n${migrationCommand}\n\n${migrationRule}`);\n}\n\nexport function canopyTombstoneObject<ExportType>(\n location: TombstoneLocation,\n): ExportType {\n const throwTombstoneError = (): never => {\n throw canopyTombstoneError(location);\n };\n\n // eslint-disable-next-line replo/no-as-cast -- Proxy traps cannot retain an arbitrary public object type without the mandated boundary cast.\n return new Proxy(throwTombstoneError, {\n apply: throwTombstoneError,\n get: throwTombstoneError,\n has: throwTombstoneError,\n }) as unknown as ExportType;\n}\n"],
4
+ "sourcesContent": ["type PublicSdkReplacement = {\n kind: \"public-sdk\";\n replacementImport?: string;\n};\n\ntype SandboxRuntimeReplacement = {\n kind: \"sandbox-runtime\";\n};\n\ntype InternalReplacement = {\n kind: \"internal\";\n nearestPublicSubpaths: readonly string[];\n};\n\ntype TombstoneReplacement =\n | PublicSdkReplacement\n | SandboxRuntimeReplacement\n | InternalReplacement;\n\ntype TombstoneLocation = {\n symbol: string;\n subpath: string;\n replacement?: TombstoneReplacement;\n replacementImport?: string;\n};\n\nconst migrationCommand = `pnpm add --ignore-workspace @replohq/sdk@latest @replohq/sandbox-runtime@latest && pnpm remove --ignore-workspace canopy-sdk\n(if package.json lists \"@replohq/canopy-sdk\" instead of the \"canopy-sdk\" alias, run: pnpm remove --ignore-workspace @replohq/canopy-sdk)`;\n\nconst providerComposition = `import { ReploProvider } from \"@replohq/sdk/providers/replo-provider\";\nimport { SandboxRuntime } from \"@replohq/sandbox-runtime\";\n\nexport default function RootLayout({\n children,\n}: Readonly<{\n children: React.ReactNode;\n}>) {\n return (\n <html>\n <body>\n <ReploProvider>\n <SandboxRuntime>{children}</SandboxRuntime>\n </ReploProvider>\n </body>\n </html>\n );\n}`;\n\nconst migrationRule = `For storefront imports the migration is mechanical: every public canopy-sdk/<subpath> or @replohq/canopy-sdk/<subpath> import becomes @replohq/sdk/<subpath>. Editor/select-mode functionality is not imported directly: SandboxRuntime from @replohq/sandbox-runtime provides it automatically once mounted.`;\n\nfunction reploProviderTombstoneError(): Error {\n return new Error(`ReploProvider was removed from @replohq/canopy-sdk v3, the final, fully deprecated release.\n\nReplace the single legacy provider with ReploProvider from @replohq/sdk/providers/replo-provider wrapping SandboxRuntime from @replohq/sandbox-runtime, with SandboxRuntime nested inside ReploProvider:\n\n${providerComposition}\n\nInstall the replacements and remove the deprecated package:\n${migrationCommand}\n\n${migrationRule}`);\n}\n\nfunction sandboxRuntimeMigration({ symbol }: { symbol: string }): string {\n return `${symbol} was editor/select-mode functionality. It now ships inside @replohq/sandbox-runtime and is not directly importable.\n\nMount SandboxRuntime from @replohq/sandbox-runtime inside ReploProvider from @replohq/sdk in the root layout; SandboxRuntime provides this functionality automatically:\n\n${providerComposition}\n\nThen delete this import and any /editor route code that used it.`;\n}\n\nfunction internalMigration({\n nearestPublicSubpaths,\n}: InternalReplacement): string {\n const publicApis = nearestPublicSubpaths\n .map((subpath) => `- @replohq/sdk/${subpath}`)\n .join(\"\\n\");\n\n return `This was an internal module with no direct public replacement.\n\nUse the nearest supported public API for this domain:\n${publicApis}`;\n}\n\nexport function canopyTombstoneError({\n symbol,\n subpath,\n replacement,\n replacementImport,\n}: TombstoneLocation): Error {\n if (symbol === \"ReploProvider\") {\n return reploProviderTombstoneError();\n }\n\n const resolvedReplacement = replacement ?? {\n kind: \"public-sdk\",\n replacementImport,\n };\n const migration = (() => {\n switch (resolvedReplacement.kind) {\n case \"public-sdk\":\n return `Use the replacement export:\n${\n resolvedReplacement.replacementImport ??\n `import { ${symbol} } from \"@replohq/sdk/${subpath}\";`\n}`;\n case \"sandbox-runtime\":\n return sandboxRuntimeMigration({ symbol });\n case \"internal\":\n return internalMigration(resolvedReplacement);\n }\n })();\n\n return new Error(`${symbol} was removed from @replohq/canopy-sdk v3, the final, fully deprecated release.\n\n${migration}\n\nInstall the replacements and remove the deprecated package:\n${migrationCommand}\n\n${migrationRule}`);\n}\n\nexport function canopyTombstoneObject<ExportType>(\n location: TombstoneLocation,\n): ExportType {\n const throwTombstoneError = (): never => {\n throw canopyTombstoneError(location);\n };\n\n // eslint-disable-next-line replo/no-as-cast -- Proxy traps cannot retain an arbitrary public object type without the mandated boundary cast.\n return new Proxy(throwTombstoneError, {\n apply: throwTombstoneError,\n get: throwTombstoneError,\n has: throwTombstoneError,\n }) as unknown as ExportType;\n}\n"],
5
5
  "mappings": "AA0BA,MAAM,mBAAmB;AAAA;AAGzB,MAAM,sBAAsB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAmB5B,MAAM,gBAAgB;AAEtB,SAAS,8BAAqC;AAC5C,SAAO,IAAI,MAAM;AAAA;AAAA;AAAA;AAAA,EAIjB,mBAAmB;AAAA;AAAA;AAAA,EAGnB,gBAAgB;AAAA;AAAA,EAEhB,aAAa,EAAE;AACjB;AAEA,SAAS,wBAAwB,EAAE,OAAO,GAA+B;AACvE,SAAO,GAAG,MAAM;AAAA;AAAA;AAAA;AAAA,EAIhB,mBAAmB;AAAA;AAAA;AAGrB;AAEA,SAAS,kBAAkB;AAAA,EACzB;AACF,GAAgC;AAC9B,QAAM,aAAa,sBAChB,IAAI,CAAC,YAAY,kBAAkB,OAAO,EAAE,EAC5C,KAAK,IAAI;AAEZ,SAAO;AAAA;AAAA;AAAA,EAGP,UAAU;AACZ;AAEO,SAAS,qBAAqB;AAAA,EACnC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAA6B;AAC3B,MAAI,WAAW,iBAAiB;AAC9B,WAAO,4BAA4B;AAAA,EACrC;AAEA,QAAM,sBAAsB,eAAe;AAAA,IACzC,MAAM;AAAA,IACN;AAAA,EACF;AACA,QAAM,aAAa,MAAM;AACvB,YAAQ,oBAAoB,MAAM;AAAA,MAChC,KAAK;AACH,eAAO;AAAA,EAEb,oBAAoB,qBACpB,YAAY,MAAM,yBAAyB,OAAO,IACpD;AAAA,MACM,KAAK;AACH,eAAO,wBAAwB,EAAE,OAAO,CAAC;AAAA,MAC3C,KAAK;AACH,eAAO,kBAAkB,mBAAmB;AAAA,IAChD;AAAA,EACF,GAAG;AAEH,SAAO,IAAI,MAAM,GAAG,MAAM;AAAA;AAAA,EAE1B,SAAS;AAAA;AAAA;AAAA,EAGT,gBAAgB;AAAA;AAAA,EAEhB,aAAa,EAAE;AACjB;AAEO,SAAS,sBACd,UACY;AACZ,QAAM,sBAAsB,MAAa;AACvC,UAAM,qBAAqB,QAAQ;AAAA,EACrC;AAGA,SAAO,IAAI,MAAM,qBAAqB;AAAA,IACpC,OAAO;AAAA,IACP,KAAK;AAAA,IACL,KAAK;AAAA,EACP,CAAC;AACH;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@replohq/canopy-sdk",
3
- "version": "3.0.0",
3
+ "version": "3.0.2",
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,
@@ -211,6 +211,11 @@
211
211
  "react": ">=18.2.0",
212
212
  "react-dom": ">=18.2.0"
213
213
  },
214
+ "repository": {
215
+ "type": "git",
216
+ "url": "git+https://github.com/replohq/andytown.git",
217
+ "directory": "packages/canopy-sdk"
218
+ },
214
219
  "publishConfig": {
215
220
  "registry": "https://registry.npmjs.org/",
216
221
  "access": "public"