@replohq/canopy-sdk 1.3.2-beta.pr-24916.3.6f21cf4 → 1.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/env.js +12 -1
- package/env.js.map +2 -2
- package/package.json +5 -172
package/env.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { getCloudflareContext } from "@opennextjs/cloudflare";
|
|
2
2
|
import JSONC from "tiny-jsonc";
|
|
3
3
|
import { z } from "zod";
|
|
4
|
+
import { CanopyError } from "./lib/canopy-error";
|
|
4
5
|
const envSchema = z.object({
|
|
5
6
|
CANOPY_API_HOST: z.string().min(1),
|
|
6
7
|
PROJECT_ID: z.uuid(),
|
|
@@ -9,6 +10,8 @@ const envSchema = z.object({
|
|
|
9
10
|
CHECKOUT_PROVIDER: z.enum(["shopify", "stripe", "none"]).optional()
|
|
10
11
|
});
|
|
11
12
|
const wranglerConfigSchema = z.object({ vars: envSchema });
|
|
13
|
+
class MissingWranglerConfigError extends CanopyError {
|
|
14
|
+
}
|
|
12
15
|
const isDeployedWorker = () => {
|
|
13
16
|
return process.env.NODE_ENV === "production" && process.env.BUILD_ENV !== "build" && process.env.NEXT_PHASE !== "phase-production-build";
|
|
14
17
|
};
|
|
@@ -22,7 +25,15 @@ const getEnv = async () => {
|
|
|
22
25
|
/* webpackIgnore: true */
|
|
23
26
|
"node:fs"
|
|
24
27
|
);
|
|
25
|
-
|
|
28
|
+
let raw;
|
|
29
|
+
try {
|
|
30
|
+
raw = await fs.readFile(`${process.cwd()}/wrangler.jsonc`, "utf8");
|
|
31
|
+
} catch (error) {
|
|
32
|
+
throw new MissingWranglerConfigError({
|
|
33
|
+
message: `wrangler.jsonc not found in ${process.cwd()}. It holds this site's Replo project config (project id, API host) and is required to run outside the deployed worker. If this clone predates the committed config, open the site in Replo once \u2014 the dev server regenerates and commits it \u2014 then git pull.`,
|
|
34
|
+
cause: error
|
|
35
|
+
});
|
|
36
|
+
}
|
|
26
37
|
return wranglerConfigSchema.parse(JSONC.parse(raw)).vars;
|
|
27
38
|
};
|
|
28
39
|
export {
|
package/env.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../env.ts"],
|
|
4
|
-
"sourcesContent": ["import { getCloudflareContext } from \"@opennextjs/cloudflare\";\nimport JSONC from \"tiny-jsonc\";\nimport { z } from \"zod\";\n\ntype Env = {\n CANOPY_API_HOST: string;\n PROJECT_ID: string;\n\n // Base URL of analytics-fire (e.g. https://data.replo.app). Read server-side by\n // the consent action (`consent/consent-actions.ts`) to forward proof-of-consent\n // records. Optional: absent in environments where the audit pipeline isn't\n // wired (e.g. local dev), where consent recording simply no-ops.\n ANALYTICS_FIRE_API_URL?: string;\n\n // Base URL of the Replo first-party analytics pixel CDN (e.g.\n // https://pixel.replo.app). `<ReploFirstPartyPixel>` loads\n // `${REPLO_ANALYTICS_PIXEL_URL}/latest.js` into the page once analytics consent\n // is granted; the browser fetches it directly. Optional: absent when the pixel\n // isn't configured (e.g. lean local dev), where the pixel simply isn't injected.\n REPLO_ANALYTICS_PIXEL_URL?: string;\n\n CHECKOUT_PROVIDER?: \"shopify\" | \"stripe\" | \"none\";\n};\n\nconst envSchema = z.object({\n CANOPY_API_HOST: z.string().min(1),\n PROJECT_ID: z.uuid(),\n ANALYTICS_FIRE_API_URL: z.string().optional(),\n REPLO_ANALYTICS_PIXEL_URL: z.string().optional(),\n CHECKOUT_PROVIDER: z.enum([\"shopify\", \"stripe\", \"none\"]).optional(),\n});\n\nconst wranglerConfigSchema = z.object({ vars: envSchema });\n\n// NOTE (Cole, 2026-07-28, REPL-29501): outside the deployed worker, read wrangler.jsonc directly \u2014 concurrent workerd boots race on the shared .wrangler/state SQLite (SQLITE_BUSY).\nconst isDeployedWorker = () => {\n return (\n process.env.NODE_ENV === \"production\" &&\n process.env.BUILD_ENV !== \"build\" &&\n process.env.NEXT_PHASE !== \"phase-production-build\"\n );\n};\n\nexport const getEnv = async (): Promise<Env> => {\n if (isDeployedWorker()) {\n const { env } = await getCloudflareContext({ async: true });\n return envSchema.parse(env);\n }\n // NOTE (Cole, 2026-07-29, REPL-29501): client chunks bundle this module (integration-utils has client consumers). A static node:fs broke those chunks in 0.16.3, and a computed specifier fails Turbopack too (\"expression is too dynamic\") \u2014 only the ignore-annotated literal import compiles; postbuild.mjs asserts the annotation survives into dist.\n const { promises: fs }: typeof import(\"node:fs\") = await import(\n /* turbopackIgnore: true */ /* webpackIgnore: true */ \"node:fs\"\n );\n
|
|
5
|
-
"mappings": "AAAA,SAAS,4BAA4B;AACrC,OAAO,WAAW;AAClB,SAAS,SAAS;
|
|
4
|
+
"sourcesContent": ["import { getCloudflareContext } from \"@opennextjs/cloudflare\";\nimport JSONC from \"tiny-jsonc\";\nimport { z } from \"zod\";\n\nimport { CanopyError } from \"./lib/canopy-error\";\n\ntype Env = {\n CANOPY_API_HOST: string;\n PROJECT_ID: string;\n\n // Base URL of analytics-fire (e.g. https://data.replo.app). Read server-side by\n // the consent action (`consent/consent-actions.ts`) to forward proof-of-consent\n // records. Optional: absent in environments where the audit pipeline isn't\n // wired (e.g. local dev), where consent recording simply no-ops.\n ANALYTICS_FIRE_API_URL?: string;\n\n // Base URL of the Replo first-party analytics pixel CDN (e.g.\n // https://pixel.replo.app). `<ReploFirstPartyPixel>` loads\n // `${REPLO_ANALYTICS_PIXEL_URL}/latest.js` into the page once analytics consent\n // is granted; the browser fetches it directly. Optional: absent when the pixel\n // isn't configured (e.g. lean local dev), where the pixel simply isn't injected.\n REPLO_ANALYTICS_PIXEL_URL?: string;\n\n CHECKOUT_PROVIDER?: \"shopify\" | \"stripe\" | \"none\";\n};\n\nconst envSchema = z.object({\n CANOPY_API_HOST: z.string().min(1),\n PROJECT_ID: z.uuid(),\n ANALYTICS_FIRE_API_URL: z.string().optional(),\n REPLO_ANALYTICS_PIXEL_URL: z.string().optional(),\n CHECKOUT_PROVIDER: z.enum([\"shopify\", \"stripe\", \"none\"]).optional(),\n});\n\nconst wranglerConfigSchema = z.object({ vars: envSchema });\n\nclass MissingWranglerConfigError extends CanopyError {}\n\n// NOTE (Cole, 2026-07-28, REPL-29501): outside the deployed worker, read wrangler.jsonc directly \u2014 concurrent workerd boots race on the shared .wrangler/state SQLite (SQLITE_BUSY).\nconst isDeployedWorker = () => {\n return (\n process.env.NODE_ENV === \"production\" &&\n process.env.BUILD_ENV !== \"build\" &&\n process.env.NEXT_PHASE !== \"phase-production-build\"\n );\n};\n\nexport const getEnv = async (): Promise<Env> => {\n if (isDeployedWorker()) {\n const { env } = await getCloudflareContext({ async: true });\n return envSchema.parse(env);\n }\n // NOTE (Cole, 2026-07-29, REPL-29501): client chunks bundle this module (integration-utils has client consumers). A static node:fs broke those chunks in 0.16.3, and a computed specifier fails Turbopack too (\"expression is too dynamic\") \u2014 only the ignore-annotated literal import compiles; postbuild.mjs asserts the annotation survives into dist.\n const { promises: fs }: typeof import(\"node:fs\") = await import(\n /* turbopackIgnore: true */ /* webpackIgnore: true */ \"node:fs\"\n );\n let raw: string;\n try {\n raw = await fs.readFile(`${process.cwd()}/wrangler.jsonc`, \"utf8\");\n } catch (error) {\n throw new MissingWranglerConfigError({\n message:\n `wrangler.jsonc not found in ${process.cwd()}. It holds this site's Replo project config ` +\n `(project id, API host) and is required to run outside the deployed worker. ` +\n `If this clone predates the committed config, open the site in Replo once \u2014 the dev ` +\n `server regenerates and commits it \u2014 then git pull.`,\n cause: error,\n });\n }\n return wranglerConfigSchema.parse(JSONC.parse(raw)).vars;\n};\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,4BAA4B;AACrC,OAAO,WAAW;AAClB,SAAS,SAAS;AAElB,SAAS,mBAAmB;AAsB5B,MAAM,YAAY,EAAE,OAAO;AAAA,EACzB,iBAAiB,EAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EACjC,YAAY,EAAE,KAAK;AAAA,EACnB,wBAAwB,EAAE,OAAO,EAAE,SAAS;AAAA,EAC5C,2BAA2B,EAAE,OAAO,EAAE,SAAS;AAAA,EAC/C,mBAAmB,EAAE,KAAK,CAAC,WAAW,UAAU,MAAM,CAAC,EAAE,SAAS;AACpE,CAAC;AAED,MAAM,uBAAuB,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAEzD,MAAM,mCAAmC,YAAY;AAAC;AAGtD,MAAM,mBAAmB,MAAM;AAC7B,SACE,QAAQ,IAAI,aAAa,gBACzB,QAAQ,IAAI,cAAc,WAC1B,QAAQ,IAAI,eAAe;AAE/B;AAEO,MAAM,SAAS,YAA0B;AAC9C,MAAI,iBAAiB,GAAG;AACtB,UAAM,EAAE,IAAI,IAAI,MAAM,qBAAqB,EAAE,OAAO,KAAK,CAAC;AAC1D,WAAO,UAAU,MAAM,GAAG;AAAA,EAC5B;AAEA,QAAM,EAAE,UAAU,GAAG,IAA8B,MAAM;AAAA;AAAA;AAAA,IACD;AAAA,EACxD;AACA,MAAI;AACJ,MAAI;AACF,UAAM,MAAM,GAAG,SAAS,GAAG,QAAQ,IAAI,CAAC,mBAAmB,MAAM;AAAA,EACnE,SAAS,OAAO;AACd,UAAM,IAAI,2BAA2B;AAAA,MACnC,SACE,+BAA+B,QAAQ,IAAI,CAAC;AAAA,MAI9C,OAAO;AAAA,IACT,CAAC;AAAA,EACH;AACA,SAAO,qBAAqB,MAAM,MAAM,MAAM,GAAG,CAAC,EAAE;AACtD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,180 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@replohq/canopy-sdk",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.3",
|
|
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,
|
|
7
|
-
"exports": {
|
|
8
|
-
"./providers/replo-provider": {
|
|
9
|
-
"types": "./providers/replo-provider.d.ts",
|
|
10
|
-
"default": "./providers/replo-provider.js"
|
|
11
|
-
},
|
|
12
|
-
"./consent/replo-scripts": {
|
|
13
|
-
"types": "./consent/replo-scripts.d.ts",
|
|
14
|
-
"default": "./consent/replo-scripts.js"
|
|
15
|
-
},
|
|
16
|
-
"./consent/consent-store": {
|
|
17
|
-
"types": "./consent/consent-store.d.ts",
|
|
18
|
-
"default": "./consent/consent-store.js"
|
|
19
|
-
},
|
|
20
|
-
"./consent/types": {
|
|
21
|
-
"types": "./consent/types.d.ts",
|
|
22
|
-
"default": "./consent/types.js"
|
|
23
|
-
},
|
|
24
|
-
"./cart/cart-provider": {
|
|
25
|
-
"types": "./cart/cart-provider.d.ts",
|
|
26
|
-
"default": "./cart/cart-provider.js"
|
|
27
|
-
},
|
|
28
|
-
"./cart/hooks/use-add-to-cart": {
|
|
29
|
-
"types": "./cart/hooks/use-add-to-cart.d.ts",
|
|
30
|
-
"default": "./cart/hooks/use-add-to-cart.js"
|
|
31
|
-
},
|
|
32
|
-
"./cart/hooks/use-buy-now": {
|
|
33
|
-
"types": "./cart/hooks/use-buy-now.d.ts",
|
|
34
|
-
"default": "./cart/hooks/use-buy-now.js"
|
|
35
|
-
},
|
|
36
|
-
"./cart/cart-types": {
|
|
37
|
-
"types": "./cart/cart-types.d.ts",
|
|
38
|
-
"default": "./cart/cart-types.js"
|
|
39
|
-
},
|
|
40
|
-
"./cart/buy-now-action": {
|
|
41
|
-
"types": "./cart/buy-now-action.d.ts",
|
|
42
|
-
"default": "./cart/buy-now-action.js"
|
|
43
|
-
},
|
|
44
|
-
"./cart/utils/cart-utils": {
|
|
45
|
-
"types": "./cart/utils/cart-utils.d.ts",
|
|
46
|
-
"default": "./cart/utils/cart-utils.js"
|
|
47
|
-
},
|
|
48
|
-
"./cart/utils/cookie-cart-persistence": {
|
|
49
|
-
"types": "./cart/utils/cookie-cart-persistence.d.ts",
|
|
50
|
-
"default": "./cart/utils/cookie-cart-persistence.js"
|
|
51
|
-
},
|
|
52
|
-
"./cart/utils/variant-to-cart-line": {
|
|
53
|
-
"types": "./cart/utils/variant-to-cart-line.d.ts",
|
|
54
|
-
"default": "./cart/utils/variant-to-cart-line.js"
|
|
55
|
-
},
|
|
56
|
-
"./cart/gateways/cart-constants": {
|
|
57
|
-
"types": "./cart/gateways/cart-constants.d.ts",
|
|
58
|
-
"default": "./cart/gateways/cart-constants.js"
|
|
59
|
-
},
|
|
60
|
-
"./money": {
|
|
61
|
-
"types": "./money.d.ts",
|
|
62
|
-
"default": "./money.js"
|
|
63
|
-
},
|
|
64
|
-
"./hooks/use-formatted-price": {
|
|
65
|
-
"types": "./hooks/use-formatted-price.d.ts",
|
|
66
|
-
"default": "./hooks/use-formatted-price.js"
|
|
67
|
-
},
|
|
68
|
-
"./analytics/analytics-provider": {
|
|
69
|
-
"types": "./analytics/analytics-provider.d.ts",
|
|
70
|
-
"default": "./analytics/analytics-provider.js"
|
|
71
|
-
},
|
|
72
|
-
"./analytics/hooks/use-product-viewed-analytics": {
|
|
73
|
-
"types": "./analytics/hooks/use-product-viewed-analytics.d.ts",
|
|
74
|
-
"default": "./analytics/hooks/use-product-viewed-analytics.js"
|
|
75
|
-
},
|
|
76
|
-
"./loaders/collection-loader": {
|
|
77
|
-
"types": "./loaders/collection-loader.d.ts",
|
|
78
|
-
"default": "./loaders/collection-loader.js"
|
|
79
|
-
},
|
|
80
|
-
"./loaders/collection-products-loader": {
|
|
81
|
-
"types": "./loaders/collection-products-loader.d.ts",
|
|
82
|
-
"default": "./loaders/collection-products-loader.js"
|
|
83
|
-
},
|
|
84
|
-
"./loaders/contentful-entries-loader": {
|
|
85
|
-
"types": "./loaders/contentful-entries-loader.d.ts",
|
|
86
|
-
"default": "./loaders/contentful-entries-loader.js"
|
|
87
|
-
},
|
|
88
|
-
"./loaders/contentful-entry-loader": {
|
|
89
|
-
"types": "./loaders/contentful-entry-loader.d.ts",
|
|
90
|
-
"default": "./loaders/contentful-entry-loader.js"
|
|
91
|
-
},
|
|
92
|
-
"./loaders/levanta-product-loader": {
|
|
93
|
-
"types": "./loaders/levanta-product-loader.d.ts",
|
|
94
|
-
"default": "./loaders/levanta-product-loader.js"
|
|
95
|
-
},
|
|
96
|
-
"./loaders/okendo-review-aggregate-loader": {
|
|
97
|
-
"types": "./loaders/okendo-review-aggregate-loader.d.ts",
|
|
98
|
-
"default": "./loaders/okendo-review-aggregate-loader.js"
|
|
99
|
-
},
|
|
100
|
-
"./loaders/okendo-reviews-loader": {
|
|
101
|
-
"types": "./loaders/okendo-reviews-loader.d.ts",
|
|
102
|
-
"default": "./loaders/okendo-reviews-loader.js"
|
|
103
|
-
},
|
|
104
|
-
"./loaders/product-loader": {
|
|
105
|
-
"types": "./loaders/product-loader.d.ts",
|
|
106
|
-
"default": "./loaders/product-loader.js"
|
|
107
|
-
},
|
|
108
|
-
"./loaders/rebuy-recommendations-loader": {
|
|
109
|
-
"types": "./loaders/rebuy-recommendations-loader.d.ts",
|
|
110
|
-
"default": "./loaders/rebuy-recommendations-loader.js"
|
|
111
|
-
},
|
|
112
|
-
"./loaders/reviews-io-review-aggregate-loader": {
|
|
113
|
-
"types": "./loaders/reviews-io-review-aggregate-loader.d.ts",
|
|
114
|
-
"default": "./loaders/reviews-io-review-aggregate-loader.js"
|
|
115
|
-
},
|
|
116
|
-
"./loaders/reviews-io-reviews-loader": {
|
|
117
|
-
"types": "./loaders/reviews-io-reviews-loader.d.ts",
|
|
118
|
-
"default": "./loaders/reviews-io-reviews-loader.js"
|
|
119
|
-
},
|
|
120
|
-
"./loaders/smile-earning-rules-loader": {
|
|
121
|
-
"types": "./loaders/smile-earning-rules-loader.d.ts",
|
|
122
|
-
"default": "./loaders/smile-earning-rules-loader.js"
|
|
123
|
-
},
|
|
124
|
-
"./loaders/smile-rewards-loader": {
|
|
125
|
-
"types": "./loaders/smile-rewards-loader.d.ts",
|
|
126
|
-
"default": "./loaders/smile-rewards-loader.js"
|
|
127
|
-
},
|
|
128
|
-
"./loaders/smile-vip-tiers-loader": {
|
|
129
|
-
"types": "./loaders/smile-vip-tiers-loader.d.ts",
|
|
130
|
-
"default": "./loaders/smile-vip-tiers-loader.js"
|
|
131
|
-
},
|
|
132
|
-
"./loaders/statsig-experiment-loader": {
|
|
133
|
-
"types": "./loaders/statsig-experiment-loader.d.ts",
|
|
134
|
-
"default": "./loaders/statsig-experiment-loader.js"
|
|
135
|
-
},
|
|
136
|
-
"./loaders/yotpo-review-aggregate-loader": {
|
|
137
|
-
"types": "./loaders/yotpo-review-aggregate-loader.d.ts",
|
|
138
|
-
"default": "./loaders/yotpo-review-aggregate-loader.js"
|
|
139
|
-
},
|
|
140
|
-
"./loaders/yotpo-reviews-loader": {
|
|
141
|
-
"types": "./loaders/yotpo-reviews-loader.d.ts",
|
|
142
|
-
"default": "./loaders/yotpo-reviews-loader.js"
|
|
143
|
-
},
|
|
144
|
-
"./loaders/prefetch-loaders": {
|
|
145
|
-
"types": "./loaders/prefetch-loaders.d.ts",
|
|
146
|
-
"default": "./loaders/prefetch-loaders.js"
|
|
147
|
-
},
|
|
148
|
-
"./loaders/loader-keys": {
|
|
149
|
-
"types": "./loaders/loader-keys.d.ts",
|
|
150
|
-
"default": "./loaders/loader-keys.js"
|
|
151
|
-
},
|
|
152
|
-
"./loaders/loader-schemas": {
|
|
153
|
-
"types": "./loaders/loader-schemas.d.ts",
|
|
154
|
-
"default": "./loaders/loader-schemas.js"
|
|
155
|
-
},
|
|
156
|
-
"./loaders/product-loader-args": {
|
|
157
|
-
"types": "./loaders/product-loader-args.d.ts",
|
|
158
|
-
"default": "./loaders/product-loader-args.js"
|
|
159
|
-
},
|
|
160
|
-
"./next/config": {
|
|
161
|
-
"types": "./next/config.d.ts",
|
|
162
|
-
"default": "./next/config.js"
|
|
163
|
-
},
|
|
164
|
-
"./next/image-loader": {
|
|
165
|
-
"types": "./next/image-loader.d.ts",
|
|
166
|
-
"default": "./next/image-loader.js"
|
|
167
|
-
},
|
|
168
|
-
"./next/open-next": {
|
|
169
|
-
"types": "./next/open-next.d.ts",
|
|
170
|
-
"default": "./next/open-next.js"
|
|
171
|
-
},
|
|
172
|
-
"./_vendor/schemas/loaderKeys": {
|
|
173
|
-
"types": "./_vendor/schemas/loaderKeys.d.ts",
|
|
174
|
-
"default": "./_vendor/schemas/loaderKeys.mjs"
|
|
175
|
-
},
|
|
176
|
-
"./package.json": "./package.json"
|
|
177
|
-
},
|
|
178
7
|
"dependencies": {
|
|
179
8
|
"@tiptap/core": "^2.25.0",
|
|
180
9
|
"@tiptap/extension-bold": "^2.25.0",
|
|
@@ -198,6 +27,10 @@
|
|
|
198
27
|
"react": ">=18.2.0",
|
|
199
28
|
"react-dom": ">=18.2.0"
|
|
200
29
|
},
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"registry": "https://registry.npmjs.org/",
|
|
32
|
+
"access": "restricted"
|
|
33
|
+
},
|
|
201
34
|
"engines": {
|
|
202
35
|
"node": "22.x"
|
|
203
36
|
}
|