@replohq/canopy-sdk 0.5.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/_vendor/replo-utils/lib/geometry.d.ts +18 -0
- package/_vendor/replo-utils/lib/geometry.mjs +9 -0
- package/_vendor/schemas/agentTools/customIntegrations/loaders/product.mjs +1 -1
- package/_vendor/schemas/errors.d.ts +1 -1
- package/_vendor/schemas/errors.mjs +6 -2
- package/_vendor/schemas/generated/consent.d.ts +7 -2
- package/_vendor/schemas/generated/selectMode.d.ts +8 -2
- package/_vendor/schemas/objectType.mjs +1 -1
- package/_vendor/schemas/registry.d.ts +179 -9
- package/_vendor/schemas/selectMode.d.ts +41 -2
- package/_vendor/schemas/selectMode.mjs +12 -3
- package/analytics/analytics-provider.d.ts +4 -1
- package/analytics/analytics-provider.js +13 -3
- package/analytics/analytics-provider.js.map +2 -2
- package/analytics/get-analytics-sinks.d.ts +3 -1
- package/analytics/get-analytics-sinks.js +8 -2
- package/analytics/get-analytics-sinks.js.map +2 -2
- package/analytics/sinks/ga4-sink.js +10 -2
- package/analytics/sinks/ga4-sink.js.map +2 -2
- package/analytics/sinks/meta-sink.d.ts +1 -1
- package/analytics/sinks/meta-sink.js +16 -4
- package/analytics/sinks/meta-sink.js.map +2 -2
- package/analytics/utils/shopify-funnel-gate.d.ts +8 -0
- package/analytics/utils/shopify-funnel-gate.js +22 -0
- package/analytics/utils/shopify-funnel-gate.js.map +7 -0
- package/{chunk-77XUQJHY.mjs → chunk-ZBNFOPGP.mjs} +83 -1
- package/consent/replo-scripts.js +11 -2
- package/consent/replo-scripts.js.map +2 -2
- package/consent/script-snippets.d.ts +11 -6
- package/consent/script-snippets.js +0 -12
- package/consent/script-snippets.js.map +2 -2
- package/consent/types.d.ts +7 -2
- package/editor/ClientErrorBoundary.d.ts +6 -3
- package/editor/ClientErrorBoundary.js +18 -5
- package/editor/ClientErrorBoundary.js.map +2 -2
- package/editor/NextErrorReporter.d.ts +1 -0
- package/editor/NextErrorReporter.js +63 -0
- package/editor/NextErrorReporter.js.map +7 -0
- package/editor/select-mode/hooks/useSelectModeController.js +2 -1
- package/editor/select-mode/hooks/useSelectModeController.js.map +2 -2
- package/editor/select-mode/hooks/useSelectionInteractions.d.ts +3 -3
- package/editor/select-mode/hooks/useSelectionInteractions.js +54 -16
- package/editor/select-mode/hooks/useSelectionInteractions.js.map +2 -2
- package/editor/select-mode/interactions/selectionGeometry.d.ts +37 -12
- package/editor/select-mode/interactions/selectionGeometry.js +52 -24
- package/editor/select-mode/interactions/selectionGeometry.js.map +2 -2
- package/editor/select-mode/selectionFrame.d.ts +26 -7
- package/editor/select-mode/selectionFrame.js +58 -34
- package/editor/select-mode/selectionFrame.js.map +2 -2
- package/editor/select-mode/symbolicate.js +32 -1
- package/editor/select-mode/symbolicate.js.map +2 -2
- package/next/config.d.ts +4 -0
- package/next/config.js +86 -0
- package/next/config.js.map +7 -0
- package/next/image-loader.d.ts +2 -0
- package/next/image-loader.js +16 -0
- package/next/image-loader.js.map +7 -0
- package/next/open-next.d.ts +2 -0
- package/next/open-next.js +24 -0
- package/next/open-next.js.map +7 -0
- package/package.json +1 -1
- package/providers/replo-provider.d.ts +1 -1
- package/providers/replo-provider.js +20 -9
- package/providers/replo-provider.js.map +2 -2
|
@@ -28,10 +28,18 @@ class GA4Sink {
|
|
|
28
28
|
this.send("select_content", data);
|
|
29
29
|
}
|
|
30
30
|
async productViewed({ data }) {
|
|
31
|
-
this.send("view_item",
|
|
31
|
+
this.send("view_item", {
|
|
32
|
+
value: data.price,
|
|
33
|
+
currency: data.currency,
|
|
34
|
+
...data
|
|
35
|
+
});
|
|
32
36
|
}
|
|
33
37
|
async addToCart({ data }) {
|
|
34
|
-
this.send("add_to_cart",
|
|
38
|
+
this.send("add_to_cart", {
|
|
39
|
+
value: data.price,
|
|
40
|
+
currency: data.currency,
|
|
41
|
+
...data
|
|
42
|
+
});
|
|
35
43
|
}
|
|
36
44
|
async removeFromCart({ data }) {
|
|
37
45
|
this.send("remove_from_cart", data);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../analytics/sinks/ga4-sink.ts"],
|
|
4
|
-
"sourcesContent": ["import type {\n AnalyticsSink,\n DataPayload,\n PurchasePayload,\n} from \"../analytics-sink\";\nimport type { PageMetadata } from \"../utils/navigation-tracker\";\n\nimport { createEventQueue } from \"../utils/analytics-utils\";\n\nexport class GA4Sink implements AnalyticsSink {\n // oxlint-disable-next-line typescript/no-explicit-any -- legacy any, may or may not be needed\n private send: (event: string, params?: Record<string, any>) => void;\n\n constructor() {\n this.send = createEventQueue(\n // Legacy cast - may or may not be necessary\n // oxlint-disable-next-line replo/no-as-cast, typescript/no-explicit-any -- legacy any/cast, may or may not be needed\n () => typeof window !== \"undefined\" && Boolean((window as any).gtag),\n (event, params) => {\n // Legacy cast - may or may not be necessary\n // oxlint-disable-next-line replo/no-as-cast, typescript/no-explicit-any -- legacy any/cast, may or may not be needed\n const gtag = (window as any).gtag;\n gtag(\"event\", event, params);\n },\n \"GA4\",\n );\n }\n\n async pageView(metadata?: PageMetadata) {\n const params = metadata\n ? {\n page_title: metadata.title,\n page_location: metadata.url,\n }\n : {};\n this.send(\"page_view\", params);\n }\n\n async purchase({ amount, currency, data }: PurchasePayload) {\n this.send(\"purchase\", { value: amount, currency, ...data });\n }\n\n async click({ data }: DataPayload) {\n this.send(\"select_content\", data);\n }\n\n async productViewed({ data }: DataPayload) {\n this.send(\"view_item\", data);\n }\n\n async addToCart({ data }: DataPayload) {\n this.send(\"add_to_cart\", data);\n }\n\n async removeFromCart({ data }: DataPayload) {\n this.send(\"remove_from_cart\", data);\n }\n\n async viewCart({ data }: DataPayload) {\n this.send(\"view_cart\", data);\n }\n\n async startCheckout({ data }: DataPayload) {\n this.send(\"begin_checkout\", data);\n }\n\n async viewCollection({ data }: DataPayload) {\n this.send(\"view_item_list\", data);\n }\n}\n"],
|
|
5
|
-
"mappings": "AAOA,SAAS,wBAAwB;AAE1B,MAAM,QAAiC;AAAA;AAAA,EAEpC;AAAA,EAER,cAAc;AACZ,SAAK,OAAO;AAAA;AAAA;AAAA,MAGV,MAAM,OAAO,WAAW,eAAe,QAAS,OAAe,IAAI;AAAA,MACnE,CAAC,OAAO,WAAW;AAGjB,cAAM,OAAQ,OAAe;AAC7B,aAAK,SAAS,OAAO,MAAM;AAAA,MAC7B;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAAA,EAEA,MAAM,SAAS,UAAyB;AACtC,UAAM,SAAS,WACX;AAAA,MACE,YAAY,SAAS;AAAA,MACrB,eAAe,SAAS;AAAA,IAC1B,IACA,CAAC;AACL,SAAK,KAAK,aAAa,MAAM;AAAA,EAC/B;AAAA,EAEA,MAAM,SAAS,EAAE,QAAQ,UAAU,KAAK,GAAoB;AAC1D,SAAK,KAAK,YAAY,EAAE,OAAO,QAAQ,UAAU,GAAG,KAAK,CAAC;AAAA,EAC5D;AAAA,EAEA,MAAM,MAAM,EAAE,KAAK,GAAgB;AACjC,SAAK,KAAK,kBAAkB,IAAI;AAAA,EAClC;AAAA,EAEA,MAAM,cAAc,EAAE,KAAK,GAAgB;AACzC,SAAK,KAAK,aAAa,
|
|
4
|
+
"sourcesContent": ["import type {\n AnalyticsSink,\n DataPayload,\n PurchasePayload,\n} from \"../analytics-sink\";\nimport type { PageMetadata } from \"../utils/navigation-tracker\";\n\nimport { createEventQueue } from \"../utils/analytics-utils\";\n\nexport class GA4Sink implements AnalyticsSink {\n // oxlint-disable-next-line typescript/no-explicit-any -- legacy any, may or may not be needed\n private send: (event: string, params?: Record<string, any>) => void;\n\n constructor() {\n this.send = createEventQueue(\n // Legacy cast - may or may not be necessary\n // oxlint-disable-next-line replo/no-as-cast, typescript/no-explicit-any -- legacy any/cast, may or may not be needed\n () => typeof window !== \"undefined\" && Boolean((window as any).gtag),\n (event, params) => {\n // Legacy cast - may or may not be necessary\n // oxlint-disable-next-line replo/no-as-cast, typescript/no-explicit-any -- legacy any/cast, may or may not be needed\n const gtag = (window as any).gtag;\n gtag(\"event\", event, params);\n },\n \"GA4\",\n );\n }\n\n async pageView(metadata?: PageMetadata) {\n const params = metadata\n ? {\n page_title: metadata.title,\n page_location: metadata.url,\n }\n : {};\n this.send(\"page_view\", params);\n }\n\n async purchase({ amount, currency, data }: PurchasePayload) {\n this.send(\"purchase\", { value: amount, currency, ...data });\n }\n\n async click({ data }: DataPayload) {\n this.send(\"select_content\", data);\n }\n\n async productViewed({ data }: DataPayload) {\n this.send(\"view_item\", {\n value: data.price,\n currency: data.currency,\n ...data,\n });\n }\n\n async addToCart({ data }: DataPayload) {\n this.send(\"add_to_cart\", {\n value: data.price,\n currency: data.currency,\n ...data,\n });\n }\n\n async removeFromCart({ data }: DataPayload) {\n this.send(\"remove_from_cart\", data);\n }\n\n async viewCart({ data }: DataPayload) {\n this.send(\"view_cart\", data);\n }\n\n async startCheckout({ data }: DataPayload) {\n this.send(\"begin_checkout\", data);\n }\n\n async viewCollection({ data }: DataPayload) {\n this.send(\"view_item_list\", data);\n }\n}\n"],
|
|
5
|
+
"mappings": "AAOA,SAAS,wBAAwB;AAE1B,MAAM,QAAiC;AAAA;AAAA,EAEpC;AAAA,EAER,cAAc;AACZ,SAAK,OAAO;AAAA;AAAA;AAAA,MAGV,MAAM,OAAO,WAAW,eAAe,QAAS,OAAe,IAAI;AAAA,MACnE,CAAC,OAAO,WAAW;AAGjB,cAAM,OAAQ,OAAe;AAC7B,aAAK,SAAS,OAAO,MAAM;AAAA,MAC7B;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAAA,EAEA,MAAM,SAAS,UAAyB;AACtC,UAAM,SAAS,WACX;AAAA,MACE,YAAY,SAAS;AAAA,MACrB,eAAe,SAAS;AAAA,IAC1B,IACA,CAAC;AACL,SAAK,KAAK,aAAa,MAAM;AAAA,EAC/B;AAAA,EAEA,MAAM,SAAS,EAAE,QAAQ,UAAU,KAAK,GAAoB;AAC1D,SAAK,KAAK,YAAY,EAAE,OAAO,QAAQ,UAAU,GAAG,KAAK,CAAC;AAAA,EAC5D;AAAA,EAEA,MAAM,MAAM,EAAE,KAAK,GAAgB;AACjC,SAAK,KAAK,kBAAkB,IAAI;AAAA,EAClC;AAAA,EAEA,MAAM,cAAc,EAAE,KAAK,GAAgB;AACzC,SAAK,KAAK,aAAa;AAAA,MACrB,OAAO,KAAK;AAAA,MACZ,UAAU,KAAK;AAAA,MACf,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,UAAU,EAAE,KAAK,GAAgB;AACrC,SAAK,KAAK,eAAe;AAAA,MACvB,OAAO,KAAK;AAAA,MACZ,UAAU,KAAK;AAAA,MACf,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,eAAe,EAAE,KAAK,GAAgB;AAC1C,SAAK,KAAK,oBAAoB,IAAI;AAAA,EACpC;AAAA,EAEA,MAAM,SAAS,EAAE,KAAK,GAAgB;AACpC,SAAK,KAAK,aAAa,IAAI;AAAA,EAC7B;AAAA,EAEA,MAAM,cAAc,EAAE,KAAK,GAAgB;AACzC,SAAK,KAAK,kBAAkB,IAAI;AAAA,EAClC;AAAA,EAEA,MAAM,eAAe,EAAE,KAAK,GAAgB;AAC1C,SAAK,KAAK,kBAAkB,IAAI;AAAA,EAClC;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -9,6 +9,6 @@ export declare class MetaSink implements AnalyticsSink {
|
|
|
9
9
|
addToCart({ data }: DataPayload): Promise<void>;
|
|
10
10
|
removeFromCart(): Promise<void>;
|
|
11
11
|
viewCart(): Promise<void>;
|
|
12
|
-
startCheckout(): Promise<void>;
|
|
12
|
+
startCheckout({ data }: DataPayload): Promise<void>;
|
|
13
13
|
viewCollection(): Promise<void>;
|
|
14
14
|
}
|
|
@@ -23,17 +23,29 @@ class MetaSink {
|
|
|
23
23
|
async click() {
|
|
24
24
|
}
|
|
25
25
|
async productViewed({ data }) {
|
|
26
|
-
this.track("ViewContent",
|
|
26
|
+
this.track("ViewContent", {
|
|
27
|
+
value: data.price,
|
|
28
|
+
currency: data.currency,
|
|
29
|
+
...data
|
|
30
|
+
});
|
|
27
31
|
}
|
|
28
32
|
async addToCart({ data }) {
|
|
29
|
-
this.track("AddToCart",
|
|
33
|
+
this.track("AddToCart", {
|
|
34
|
+
value: data.price,
|
|
35
|
+
currency: data.currency,
|
|
36
|
+
...data
|
|
37
|
+
});
|
|
30
38
|
}
|
|
31
39
|
async removeFromCart() {
|
|
32
40
|
}
|
|
33
41
|
async viewCart() {
|
|
34
42
|
}
|
|
35
|
-
async startCheckout() {
|
|
36
|
-
this.track("InitiateCheckout"
|
|
43
|
+
async startCheckout({ data }) {
|
|
44
|
+
this.track("InitiateCheckout", {
|
|
45
|
+
value: data.totalPrice?.amount,
|
|
46
|
+
currency: data.currencyCode,
|
|
47
|
+
...data
|
|
48
|
+
});
|
|
37
49
|
}
|
|
38
50
|
async viewCollection() {
|
|
39
51
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../analytics/sinks/meta-sink.ts"],
|
|
4
|
-
"sourcesContent": ["import type {\n AnalyticsSink,\n DataPayload,\n PurchasePayload,\n} from \"../analytics-sink\";\n\nimport { createEventQueue } from \"../utils/analytics-utils\";\n\nexport class MetaSink implements AnalyticsSink {\n // oxlint-disable-next-line typescript/no-explicit-any -- legacy any, may or may not be needed\n private track: (event: string, params?: Record<string, any>) => void;\n\n constructor() {\n this.track = createEventQueue(\n // Legacy cast - may or may not be necessary\n // oxlint-disable-next-line replo/no-as-cast, typescript/no-explicit-any -- legacy any/cast, may or may not be needed\n () => typeof window !== \"undefined\" && Boolean((window as any).fbq),\n (event, params) => {\n // Legacy cast - may or may not be necessary\n // oxlint-disable-next-line replo/no-as-cast, typescript/no-explicit-any -- legacy any/cast, may or may not be needed\n const fbq = (window as any).fbq;\n fbq(\"track\", event, params);\n },\n \"Meta\",\n );\n }\n\n async pageView() {\n this.track(\"PageView\");\n }\n\n async purchase({ amount, currency, data }: PurchasePayload) {\n this.track(\"Purchase\", { value: amount, currency, ...data });\n }\n\n async click() {\n // No direct equivalent in Meta\n }\n\n async productViewed({ data }: DataPayload) {\n this.track(\"ViewContent\", data);\n }\n\n async addToCart({ data }: DataPayload) {\n this.track(\"AddToCart\", data);\n }\n\n async removeFromCart() {\n // No direct equivalent in Meta\n }\n\n async viewCart() {\n // No direct equivalent in Meta\n }\n\n async startCheckout() {\n this.track(\"InitiateCheckout\");\n }\n\n async viewCollection() {\n // No direct equivalent in Meta\n }\n}\n"],
|
|
5
|
-
"mappings": "AAMA,SAAS,wBAAwB;AAE1B,MAAM,SAAkC;AAAA;AAAA,EAErC;AAAA,EAER,cAAc;AACZ,SAAK,QAAQ;AAAA;AAAA;AAAA,MAGX,MAAM,OAAO,WAAW,eAAe,QAAS,OAAe,GAAG;AAAA,MAClE,CAAC,OAAO,WAAW;AAGjB,cAAM,MAAO,OAAe;AAC5B,YAAI,SAAS,OAAO,MAAM;AAAA,MAC5B;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAAA,EAEA,MAAM,WAAW;AACf,SAAK,MAAM,UAAU;AAAA,EACvB;AAAA,EAEA,MAAM,SAAS,EAAE,QAAQ,UAAU,KAAK,GAAoB;AAC1D,SAAK,MAAM,YAAY,EAAE,OAAO,QAAQ,UAAU,GAAG,KAAK,CAAC;AAAA,EAC7D;AAAA,EAEA,MAAM,QAAQ;AAAA,EAEd;AAAA,EAEA,MAAM,cAAc,EAAE,KAAK,GAAgB;AACzC,SAAK,MAAM,eAAe,
|
|
4
|
+
"sourcesContent": ["import type {\n AnalyticsSink,\n DataPayload,\n PurchasePayload,\n} from \"../analytics-sink\";\n\nimport { createEventQueue } from \"../utils/analytics-utils\";\n\nexport class MetaSink implements AnalyticsSink {\n // oxlint-disable-next-line typescript/no-explicit-any -- legacy any, may or may not be needed\n private track: (event: string, params?: Record<string, any>) => void;\n\n constructor() {\n this.track = createEventQueue(\n // Legacy cast - may or may not be necessary\n // oxlint-disable-next-line replo/no-as-cast, typescript/no-explicit-any -- legacy any/cast, may or may not be needed\n () => typeof window !== \"undefined\" && Boolean((window as any).fbq),\n (event, params) => {\n // Legacy cast - may or may not be necessary\n // oxlint-disable-next-line replo/no-as-cast, typescript/no-explicit-any -- legacy any/cast, may or may not be needed\n const fbq = (window as any).fbq;\n fbq(\"track\", event, params);\n },\n \"Meta\",\n );\n }\n\n async pageView() {\n this.track(\"PageView\");\n }\n\n async purchase({ amount, currency, data }: PurchasePayload) {\n this.track(\"Purchase\", { value: amount, currency, ...data });\n }\n\n async click() {\n // No direct equivalent in Meta\n }\n\n async productViewed({ data }: DataPayload) {\n this.track(\"ViewContent\", {\n value: data.price,\n currency: data.currency,\n ...data,\n });\n }\n\n async addToCart({ data }: DataPayload) {\n this.track(\"AddToCart\", {\n value: data.price,\n currency: data.currency,\n ...data,\n });\n }\n\n async removeFromCart() {\n // No direct equivalent in Meta\n }\n\n async viewCart() {\n // No direct equivalent in Meta\n }\n\n async startCheckout({ data }: DataPayload) {\n this.track(\"InitiateCheckout\", {\n value: data.totalPrice?.amount,\n currency: data.currencyCode,\n ...data,\n });\n }\n\n async viewCollection() {\n // No direct equivalent in Meta\n }\n}\n"],
|
|
5
|
+
"mappings": "AAMA,SAAS,wBAAwB;AAE1B,MAAM,SAAkC;AAAA;AAAA,EAErC;AAAA,EAER,cAAc;AACZ,SAAK,QAAQ;AAAA;AAAA;AAAA,MAGX,MAAM,OAAO,WAAW,eAAe,QAAS,OAAe,GAAG;AAAA,MAClE,CAAC,OAAO,WAAW;AAGjB,cAAM,MAAO,OAAe;AAC5B,YAAI,SAAS,OAAO,MAAM;AAAA,MAC5B;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAAA,EAEA,MAAM,WAAW;AACf,SAAK,MAAM,UAAU;AAAA,EACvB;AAAA,EAEA,MAAM,SAAS,EAAE,QAAQ,UAAU,KAAK,GAAoB;AAC1D,SAAK,MAAM,YAAY,EAAE,OAAO,QAAQ,UAAU,GAAG,KAAK,CAAC;AAAA,EAC7D;AAAA,EAEA,MAAM,QAAQ;AAAA,EAEd;AAAA,EAEA,MAAM,cAAc,EAAE,KAAK,GAAgB;AACzC,SAAK,MAAM,eAAe;AAAA,MACxB,OAAO,KAAK;AAAA,MACZ,UAAU,KAAK;AAAA,MACf,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,UAAU,EAAE,KAAK,GAAgB;AACrC,SAAK,MAAM,aAAa;AAAA,MACtB,OAAO,KAAK;AAAA,MACZ,UAAU,KAAK;AAAA,MACf,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,iBAAiB;AAAA,EAEvB;AAAA,EAEA,MAAM,WAAW;AAAA,EAEjB;AAAA,EAEA,MAAM,cAAc,EAAE,KAAK,GAAgB;AACzC,SAAK,MAAM,oBAAoB;AAAA,MAC7B,OAAO,KAAK,YAAY;AAAA,MACxB,UAAU,KAAK;AAAA,MACf,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,iBAAiB;AAAA,EAEvB;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { AnalyticsSink } from "../analytics-sink";
|
|
2
|
+
/**
|
|
3
|
+
* Wraps a third-party ad-pixel sink so checkout-funnel events Shopify owns
|
|
4
|
+
* become no-ops; every other event passes through untouched. Apply only to
|
|
5
|
+
* third-party pixel sinks — never to the first-party `ReploSink` (the
|
|
6
|
+
* storefront's own record) or the local `WindowSink` event bus.
|
|
7
|
+
*/
|
|
8
|
+
export declare function gateShopifyOwnedFunnelEvents(sink: AnalyticsSink): AnalyticsSink;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const SHOPIFY_OWNED_FUNNEL_EVENTS = [
|
|
2
|
+
"startCheckout",
|
|
3
|
+
"purchase"
|
|
4
|
+
];
|
|
5
|
+
const shopifyOwnedFunnelEvents = new Set(
|
|
6
|
+
SHOPIFY_OWNED_FUNNEL_EVENTS
|
|
7
|
+
);
|
|
8
|
+
function gateShopifyOwnedFunnelEvents(sink) {
|
|
9
|
+
return new Proxy(sink, {
|
|
10
|
+
get(target, property, receiver) {
|
|
11
|
+
if (typeof property === "string" && shopifyOwnedFunnelEvents.has(property)) {
|
|
12
|
+
return async () => {
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
return Reflect.get(target, property, receiver);
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
export {
|
|
20
|
+
gateShopifyOwnedFunnelEvents
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=shopify-funnel-gate.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../analytics/utils/shopify-funnel-gate.ts"],
|
|
4
|
+
"sourcesContent": ["import type { AnalyticsSink } from \"../analytics-sink\";\n\n/**\n * Checkout-funnel events that Shopify's hosted checkout already reports to ad\n * platforms server-side (via native sales channels / Customer Events / CAPI).\n * When checkout is Shopify-hosted, a third-party pixel firing these from the\n * storefront double-counts against Shopify's copy \u2014 the storefront and the\n * Shopify checkout are different origins, so there is no shared event_id to\n * deduplicate against. `startCheckout` is the one fired today; `purchase` is\n * listed so the gate covers it automatically if the storefront ever emits it.\n */\nconst SHOPIFY_OWNED_FUNNEL_EVENTS = [\n \"startCheckout\",\n \"purchase\",\n] as const satisfies readonly (keyof AnalyticsSink)[];\n\nconst shopifyOwnedFunnelEvents: ReadonlySet<string> = new Set(\n SHOPIFY_OWNED_FUNNEL_EVENTS,\n);\n\n/**\n * Wraps a third-party ad-pixel sink so checkout-funnel events Shopify owns\n * become no-ops; every other event passes through untouched. Apply only to\n * third-party pixel sinks \u2014 never to the first-party `ReploSink` (the\n * storefront's own record) or the local `WindowSink` event bus.\n */\nexport function gateShopifyOwnedFunnelEvents(\n sink: AnalyticsSink,\n): AnalyticsSink {\n return new Proxy(sink, {\n get(target, property, receiver) {\n if (\n typeof property === \"string\" &&\n shopifyOwnedFunnelEvents.has(property)\n ) {\n return async () => {};\n }\n return Reflect.get(target, property, receiver);\n },\n });\n}\n"],
|
|
5
|
+
"mappings": "AAWA,MAAM,8BAA8B;AAAA,EAClC;AAAA,EACA;AACF;AAEA,MAAM,2BAAgD,IAAI;AAAA,EACxD;AACF;AAQO,SAAS,6BACd,MACe;AACf,SAAO,IAAI,MAAM,MAAM;AAAA,IACrB,IAAI,QAAQ,UAAU,UAAU;AAC9B,UACE,OAAO,aAAa,YACpB,yBAAyB,IAAI,QAAQ,GACrC;AACA,eAAO,YAAY;AAAA,QAAC;AAAA,MACtB;AACA,aAAO,QAAQ,IAAI,QAAQ,UAAU,QAAQ;AAAA,IAC/C;AAAA,EACF,CAAC;AACH;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -2,6 +2,12 @@ import { sellingPlanGroupSchema } from './chunk-4TZVNC3W.mjs';
|
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
|
|
4
4
|
var registryItemTypeSchema = z.enum(["site", "page", "section", "skill", "plan", "branding", "product"]).describe("RegistryItemType");
|
|
5
|
+
var registryItemVisibilitySchema = z.enum(["public", "unlisted"]).describe("RegistryItemVisibility");
|
|
6
|
+
var registrySlugSchema = z.string().min(1).max(120).regex(/^[\da-z][\d_a-z-]*$/);
|
|
7
|
+
var registryItemIdSchema = z.string().uuid();
|
|
8
|
+
var registryContentFilesSchema = z.record(z.string().min(1), z.string()).refine((files) => Object.keys(files).length > 0, {
|
|
9
|
+
message: "Registry item content must include at least one file"
|
|
10
|
+
});
|
|
5
11
|
z.object({
|
|
6
12
|
sourceType: z.string().min(1).max(80),
|
|
7
13
|
sourceKey: z.string().min(1).max(512)
|
|
@@ -80,9 +86,15 @@ z.object({
|
|
|
80
86
|
z.object({
|
|
81
87
|
tags: z.array(z.string())
|
|
82
88
|
}).describe("RegistryItemTagsResult");
|
|
83
|
-
registryItemMetadataSchema.extend({
|
|
89
|
+
var registryItemDetailSchema = registryItemMetadataSchema.extend({
|
|
84
90
|
previewHtml: z.string().nullable()
|
|
85
91
|
}).describe("RegistryItemDetail");
|
|
92
|
+
z.object({
|
|
93
|
+
item: registryItemDetailSchema.extend({
|
|
94
|
+
projectId: z.null(),
|
|
95
|
+
createdBy: z.null()
|
|
96
|
+
})
|
|
97
|
+
}).describe("RegistryItemPreviewResult");
|
|
86
98
|
z.object({
|
|
87
99
|
meta: z.object({
|
|
88
100
|
id: z.string(),
|
|
@@ -94,6 +106,76 @@ z.object({
|
|
|
94
106
|
files: z.record(z.string(), z.string()),
|
|
95
107
|
dependencies: z.array(z.string())
|
|
96
108
|
}).describe("RegistryItemContent");
|
|
109
|
+
z.object({
|
|
110
|
+
id: z.string().uuid(),
|
|
111
|
+
slug: z.string().min(1),
|
|
112
|
+
name: z.string().min(1),
|
|
113
|
+
type: registryItemTypeSchema,
|
|
114
|
+
projectId: z.string().min(1).nullable(),
|
|
115
|
+
createdBy: z.string().min(1).nullable(),
|
|
116
|
+
description: z.string().nullable(),
|
|
117
|
+
visibility: z.string(),
|
|
118
|
+
tags: z.array(z.string()),
|
|
119
|
+
category: z.string().nullable(),
|
|
120
|
+
sourceType: z.string().nullable().default(null),
|
|
121
|
+
sourceKey: z.string().nullable().default(null),
|
|
122
|
+
shortLink: z.string().nullable().default(null),
|
|
123
|
+
previewUrls: z.array(z.string()),
|
|
124
|
+
previewHtml: z.string().nullable(),
|
|
125
|
+
metadata: z.record(z.string(), z.unknown()).nullable(),
|
|
126
|
+
files: registryContentFilesSchema,
|
|
127
|
+
dependencies: z.array(z.string()),
|
|
128
|
+
embeddingText: z.string(),
|
|
129
|
+
embedding: z.array(z.number()),
|
|
130
|
+
createdAt: z.string().min(1),
|
|
131
|
+
updatedAt: z.string().min(1)
|
|
132
|
+
}).describe("RegistryItemDocument");
|
|
133
|
+
z.object({
|
|
134
|
+
item: z.object({
|
|
135
|
+
id: registryItemIdSchema,
|
|
136
|
+
slug: registrySlugSchema,
|
|
137
|
+
name: z.string().min(1),
|
|
138
|
+
type: registryItemTypeSchema,
|
|
139
|
+
projectId: z.string().min(1).nullable().default(null),
|
|
140
|
+
createdBy: z.string().min(1).nullable().default(null),
|
|
141
|
+
sourceType: z.string().min(1).max(80).nullable().default(null),
|
|
142
|
+
sourceKey: z.string().min(1).max(512).nullable().default(null),
|
|
143
|
+
description: z.string().nullable().default(null),
|
|
144
|
+
metadata: z.record(z.string(), z.unknown()).nullable().default(null),
|
|
145
|
+
visibility: registryItemVisibilitySchema.default("public"),
|
|
146
|
+
tags: z.array(z.string()).default([]),
|
|
147
|
+
category: z.string().nullable().default(null),
|
|
148
|
+
previewUrls: z.array(z.string()).default([]),
|
|
149
|
+
previewHtml: z.string().nullable().default(null),
|
|
150
|
+
files: registryContentFilesSchema,
|
|
151
|
+
dependencies: z.array(z.string()).default([])
|
|
152
|
+
})
|
|
153
|
+
}).describe("RegistryCreateItemInput");
|
|
154
|
+
z.object({
|
|
155
|
+
created: z.object({
|
|
156
|
+
id: registryItemIdSchema,
|
|
157
|
+
type: registryItemTypeSchema,
|
|
158
|
+
slug: registrySlugSchema,
|
|
159
|
+
sourceType: z.string().nullable(),
|
|
160
|
+
sourceKey: z.string().nullable(),
|
|
161
|
+
url: z.string().url().describe(
|
|
162
|
+
"Canonical public-facing URL for the new registry item. The skill returns this to the user immediately so they can share / preview without waiting on verification."
|
|
163
|
+
),
|
|
164
|
+
shareUrl: z.string().url().nullable()
|
|
165
|
+
})
|
|
166
|
+
}).describe("RegistryCreateItemOutput");
|
|
167
|
+
z.object({
|
|
168
|
+
name: z.string().min(1),
|
|
169
|
+
description: z.string().nullable().optional(),
|
|
170
|
+
metadata: z.record(z.string(), z.unknown()).nullable().optional(),
|
|
171
|
+
visibility: registryItemVisibilitySchema.optional(),
|
|
172
|
+
tags: z.array(z.string()).optional(),
|
|
173
|
+
category: z.string().nullable().optional(),
|
|
174
|
+
previewUrls: z.array(z.string()).optional(),
|
|
175
|
+
previewHtml: z.string().nullable().optional(),
|
|
176
|
+
files: registryContentFilesSchema,
|
|
177
|
+
dependencies: z.array(z.string()).optional()
|
|
178
|
+
}).describe("RegistryCatalogUpsertInput");
|
|
97
179
|
z.object({
|
|
98
180
|
appName: z.string(),
|
|
99
181
|
filepath: z.string(),
|
package/consent/replo-scripts.js
CHANGED
|
@@ -6,10 +6,16 @@ import { registerScript, unregisterScript } from "./script-registration-store";
|
|
|
6
6
|
import { buildScriptTags, defaultConsentFor } from "./script-snippets";
|
|
7
7
|
import { installConsentWindowApi } from "./window-api";
|
|
8
8
|
function scriptId(entry) {
|
|
9
|
-
|
|
9
|
+
if (entry.type === "custom") {
|
|
10
|
+
return `custom:${entry.id}`;
|
|
11
|
+
}
|
|
12
|
+
if (entry.type === "snippet") {
|
|
13
|
+
return `snippet:${entry.id}`;
|
|
14
|
+
}
|
|
15
|
+
return `${entry.type}:${entry.identifier}`;
|
|
10
16
|
}
|
|
11
17
|
function requiredConsentFor(entry) {
|
|
12
|
-
if (entry.type === "custom") {
|
|
18
|
+
if (entry.type === "custom" || entry.type === "snippet") {
|
|
13
19
|
return entry.requiredConsent;
|
|
14
20
|
}
|
|
15
21
|
return entry.requiredConsent ?? defaultConsentFor(entry.type);
|
|
@@ -24,6 +30,9 @@ function descriptorsFor(entry) {
|
|
|
24
30
|
}
|
|
25
31
|
return [];
|
|
26
32
|
}
|
|
33
|
+
if (entry.type === "snippet") {
|
|
34
|
+
return [{ kind: "inline", body: entry.body }];
|
|
35
|
+
}
|
|
27
36
|
return buildScriptTags({ type: entry.type, identifier: entry.identifier });
|
|
28
37
|
}
|
|
29
38
|
function InjectedScript({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../consent/replo-scripts.tsx"],
|
|
4
|
-
"sourcesContent": ["\"use client\";\n\nimport type {\n ConsentCategory,\n ReploScriptEntry,\n ScriptTagDescriptor,\n} from \"schemas/generated/consent\";\n\nimport { useEffect } from \"react\";\n\nimport { isConsentAllowed, useConsent } from \"./consent-store\";\nimport { registerScript, unregisterScript } from \"./script-registration-store\";\nimport { buildScriptTags, defaultConsentFor } from \"./script-snippets\";\nimport { installConsentWindowApi } from \"./window-api\";\n\n
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["\"use client\";\n\nimport type {\n ConsentCategory,\n ReploScriptEntry,\n ScriptTagDescriptor,\n} from \"schemas/generated/consent\";\n\nimport { useEffect } from \"react\";\n\nimport { isConsentAllowed, useConsent } from \"./consent-store\";\nimport { registerScript, unregisterScript } from \"./script-registration-store\";\nimport { buildScriptTags, defaultConsentFor } from \"./script-snippets\";\nimport { installConsentWindowApi } from \"./window-api\";\n\n/**\n * Stable identity for an entry, used as React key and DOM dedupe key. `snippet`\n * and `custom` entries key on their `id`; identifier providers on type+id.\n */\nfunction scriptId(entry: ReploScriptEntry): string {\n if (entry.type === \"custom\") {\n return `custom:${entry.id}`;\n }\n if (entry.type === \"snippet\") {\n return `snippet:${entry.id}`;\n }\n return `${entry.type}:${entry.identifier}`;\n}\n\nfunction requiredConsentFor(entry: ReploScriptEntry): ConsentCategory[] {\n if (entry.type === \"custom\" || entry.type === \"snippet\") {\n return entry.requiredConsent;\n }\n return entry.requiredConsent ?? defaultConsentFor(entry.type);\n}\n\n/**\n * Resolves an entry to the concrete tags to inject. An identifier provider may\n * resolve to multiple tags (GA4 = external loader + inline config); a `snippet`\n * entry injects its pasted body inline; a `custom` entry is a single external\n * `src` or inline `body`.\n */\nfunction descriptorsFor(entry: ReploScriptEntry): ScriptTagDescriptor[] {\n if (entry.type === \"custom\") {\n if (entry.src) {\n return [{ kind: \"external\", src: entry.src }];\n }\n if (entry.body) {\n return [{ kind: \"inline\", body: entry.body }];\n }\n return [];\n }\n if (entry.type === \"snippet\") {\n return [{ kind: \"inline\", body: entry.body }];\n }\n return buildScriptTags({ type: entry.type, identifier: entry.identifier });\n}\n\n/**\n * Injects the resolved tags into `document.head` once a caller has decided\n * consent allows it. Reused both for author-managed `ReploScripts` entries and\n * for the implicit Replo first-party pixel.\n *\n * DOM insertion (not JSX) is required because inline `<script>` bodies set via\n * React's `dangerouslySetInnerHTML` never execute. Each node is tagged with\n * `data-replo-script-id` (plus a per-tag index) so re-renders and React Strict\n * Mode double-invokes do not double-inject.\n */\nexport function InjectedScript({\n baseId,\n descriptors,\n}: {\n baseId: string;\n descriptors: ScriptTagDescriptor[];\n}) {\n // Re-inject only when the resolved tags actually change.\n const injectionKey = `${baseId}|${JSON.stringify(descriptors)}`;\n\n // eslint-disable-next-line replo/no-use-effect -- script injection is a DOM side effect that must run after mount and on consent changes\n useEffect(() => {\n if (typeof document === \"undefined\") {\n return;\n }\n const createdNodes: HTMLScriptElement[] = [];\n descriptors.forEach((descriptor, index) => {\n const nodeId = `${baseId}#${index}`;\n const existing = document.querySelector(\n `script[data-replo-script-id=\"${nodeId}\"]`,\n );\n if (existing) {\n return;\n }\n const scriptElement = document.createElement(\"script\");\n scriptElement.dataset.reploScriptId = nodeId;\n if (descriptor.kind === \"external\") {\n scriptElement.src = descriptor.src;\n scriptElement.async = true;\n for (const [attributeName, attributeValue] of Object.entries(\n descriptor.attributes ?? {},\n )) {\n scriptElement.setAttribute(attributeName, attributeValue);\n }\n } else {\n scriptElement.textContent = descriptor.body;\n }\n document.head.append(scriptElement);\n createdNodes.push(scriptElement);\n });\n\n return () => {\n // Removing the node does not unload an already-loaded vendor (see the plan's\n // revocation note); full teardown is a reload triggered by the banner. This\n // cleanup keeps the DOM tidy and prevents duplicates across remounts.\n for (const node of createdNodes) {\n node.remove();\n }\n };\n }, [injectionKey]);\n\n return null;\n}\n\nfunction ManagedScript({ entry }: { entry: ReploScriptEntry }) {\n const consent = useConsent();\n const requiredConsent = requiredConsentFor(entry);\n const id = scriptId(entry);\n const consentKey = requiredConsent.join(\",\");\n\n // eslint-disable-next-line replo/no-use-effect -- register/unregister with the singleton so the analytics provider can gate sinks by what's on the page\n useEffect(() => {\n registerScript({ id, type: entry.type, requiredConsent });\n return () => unregisterScript(id);\n }, [id, entry.type, consentKey]);\n\n if (!isConsentAllowed({ state: consent, requiredConsent })) {\n return null;\n }\n return <InjectedScript baseId={id} descriptors={descriptorsFor(entry)} />;\n}\n\n/**\n * The single registry component for all managed tracking scripts on the site.\n * Authored once in `app/layout.tsx`; the agent/miniapp only edit the `scripts`\n * array. Each entry registers itself and is gated + injected per consent.\n */\nexport function ReploScripts({ scripts }: { scripts: ReploScriptEntry[] }) {\n // eslint-disable-next-line replo/no-use-effect -- install the window.Replo.customerPrivacy API + change event once the consent runtime mounts\n useEffect(() => installConsentWindowApi(), []);\n\n return (\n <>\n {scripts.map((entry) => (\n <ManagedScript key={scriptId(entry)} entry={entry} />\n ))}\n </>\n );\n}\n"],
|
|
5
|
+
"mappings": ";AAyIS,SAaL,UAbK;AAjIT,SAAS,iBAAiB;AAE1B,SAAS,kBAAkB,kBAAkB;AAC7C,SAAS,gBAAgB,wBAAwB;AACjD,SAAS,iBAAiB,yBAAyB;AACnD,SAAS,+BAA+B;AAMxC,SAAS,SAAS,OAAiC;AACjD,MAAI,MAAM,SAAS,UAAU;AAC3B,WAAO,UAAU,MAAM,EAAE;AAAA,EAC3B;AACA,MAAI,MAAM,SAAS,WAAW;AAC5B,WAAO,WAAW,MAAM,EAAE;AAAA,EAC5B;AACA,SAAO,GAAG,MAAM,IAAI,IAAI,MAAM,UAAU;AAC1C;AAEA,SAAS,mBAAmB,OAA4C;AACtE,MAAI,MAAM,SAAS,YAAY,MAAM,SAAS,WAAW;AACvD,WAAO,MAAM;AAAA,EACf;AACA,SAAO,MAAM,mBAAmB,kBAAkB,MAAM,IAAI;AAC9D;AAQA,SAAS,eAAe,OAAgD;AACtE,MAAI,MAAM,SAAS,UAAU;AAC3B,QAAI,MAAM,KAAK;AACb,aAAO,CAAC,EAAE,MAAM,YAAY,KAAK,MAAM,IAAI,CAAC;AAAA,IAC9C;AACA,QAAI,MAAM,MAAM;AACd,aAAO,CAAC,EAAE,MAAM,UAAU,MAAM,MAAM,KAAK,CAAC;AAAA,IAC9C;AACA,WAAO,CAAC;AAAA,EACV;AACA,MAAI,MAAM,SAAS,WAAW;AAC5B,WAAO,CAAC,EAAE,MAAM,UAAU,MAAM,MAAM,KAAK,CAAC;AAAA,EAC9C;AACA,SAAO,gBAAgB,EAAE,MAAM,MAAM,MAAM,YAAY,MAAM,WAAW,CAAC;AAC3E;AAYO,SAAS,eAAe;AAAA,EAC7B;AAAA,EACA;AACF,GAGG;AAED,QAAM,eAAe,GAAG,MAAM,IAAI,KAAK,UAAU,WAAW,CAAC;AAG7D,YAAU,MAAM;AACd,QAAI,OAAO,aAAa,aAAa;AACnC;AAAA,IACF;AACA,UAAM,eAAoC,CAAC;AAC3C,gBAAY,QAAQ,CAAC,YAAY,UAAU;AACzC,YAAM,SAAS,GAAG,MAAM,IAAI,KAAK;AACjC,YAAM,WAAW,SAAS;AAAA,QACxB,gCAAgC,MAAM;AAAA,MACxC;AACA,UAAI,UAAU;AACZ;AAAA,MACF;AACA,YAAM,gBAAgB,SAAS,cAAc,QAAQ;AACrD,oBAAc,QAAQ,gBAAgB;AACtC,UAAI,WAAW,SAAS,YAAY;AAClC,sBAAc,MAAM,WAAW;AAC/B,sBAAc,QAAQ;AACtB,mBAAW,CAAC,eAAe,cAAc,KAAK,OAAO;AAAA,UACnD,WAAW,cAAc,CAAC;AAAA,QAC5B,GAAG;AACD,wBAAc,aAAa,eAAe,cAAc;AAAA,QAC1D;AAAA,MACF,OAAO;AACL,sBAAc,cAAc,WAAW;AAAA,MACzC;AACA,eAAS,KAAK,OAAO,aAAa;AAClC,mBAAa,KAAK,aAAa;AAAA,IACjC,CAAC;AAED,WAAO,MAAM;AAIX,iBAAW,QAAQ,cAAc;AAC/B,aAAK,OAAO;AAAA,MACd;AAAA,IACF;AAAA,EACF,GAAG,CAAC,YAAY,CAAC;AAEjB,SAAO;AACT;AAEA,SAAS,cAAc,EAAE,MAAM,GAAgC;AAC7D,QAAM,UAAU,WAAW;AAC3B,QAAM,kBAAkB,mBAAmB,KAAK;AAChD,QAAM,KAAK,SAAS,KAAK;AACzB,QAAM,aAAa,gBAAgB,KAAK,GAAG;AAG3C,YAAU,MAAM;AACd,mBAAe,EAAE,IAAI,MAAM,MAAM,MAAM,gBAAgB,CAAC;AACxD,WAAO,MAAM,iBAAiB,EAAE;AAAA,EAClC,GAAG,CAAC,IAAI,MAAM,MAAM,UAAU,CAAC;AAE/B,MAAI,CAAC,iBAAiB,EAAE,OAAO,SAAS,gBAAgB,CAAC,GAAG;AAC1D,WAAO;AAAA,EACT;AACA,SAAO,oBAAC,kBAAe,QAAQ,IAAI,aAAa,eAAe,KAAK,GAAG;AACzE;AAOO,SAAS,aAAa,EAAE,QAAQ,GAAoC;AAEzE,YAAU,MAAM,wBAAwB,GAAG,CAAC,CAAC;AAE7C,SACE,gCACG,kBAAQ,IAAI,CAAC,UACZ,oBAAC,iBAAoC,SAAjB,SAAS,KAAK,CAAiB,CACpD,GACH;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import type { ConsentCategory, ReploScriptType, ScriptTagDescriptor } from "../_vendor/schemas/generated/consent";
|
|
2
|
-
type ProviderType = Exclude<ReploScriptType, "custom">;
|
|
2
|
+
type ProviderType = Exclude<ReploScriptType, "custom" | "snippet">;
|
|
3
|
+
/**
|
|
4
|
+
* Snippet providers don't synthesize tags (the user pastes the provider-issued
|
|
5
|
+
* snippet as the entry's `body`), but they still get a first-class default
|
|
6
|
+
* consent categorization like identifier providers.
|
|
7
|
+
*/
|
|
3
8
|
/**
|
|
4
9
|
* Returns the structured tag descriptors for a named provider. A single provider
|
|
5
10
|
* can produce multiple tags (e.g. GA4 = external loader + inline config), which
|
|
@@ -10,10 +15,10 @@ export declare function buildScriptTags({ type, identifier, }: {
|
|
|
10
15
|
identifier: string;
|
|
11
16
|
}): ScriptTagDescriptor[];
|
|
12
17
|
/**
|
|
13
|
-
* The default consent categories that gate
|
|
14
|
-
* specify `requiredConsent`.
|
|
15
|
-
* `
|
|
16
|
-
* Overridable per entry by the customer.
|
|
18
|
+
* The default consent categories that gate an identifier-provider script when an
|
|
19
|
+
* entry does not specify `requiredConsent`. `snippet` and `custom` entries carry
|
|
20
|
+
* `requiredConsent` explicitly (the runtime has no default for them), so this is
|
|
21
|
+
* only consulted for identifier providers. Overridable per entry by the customer.
|
|
17
22
|
*/
|
|
18
|
-
export declare function defaultConsentFor(type:
|
|
23
|
+
export declare function defaultConsentFor(type: ProviderType): ConsentCategory[];
|
|
19
24
|
export {};
|
|
@@ -87,15 +87,6 @@ gtag('config', '${id}');`
|
|
|
87
87
|
}
|
|
88
88
|
]
|
|
89
89
|
},
|
|
90
|
-
Triplewhale: {
|
|
91
|
-
defaultConsent: ["analytics", "marketing"],
|
|
92
|
-
buildTags: (id) => [
|
|
93
|
-
{
|
|
94
|
-
kind: "external",
|
|
95
|
-
src: `https://api.triplewhale.com/pixel/${id}`
|
|
96
|
-
}
|
|
97
|
-
]
|
|
98
|
-
},
|
|
99
90
|
Segment: {
|
|
100
91
|
defaultConsent: ["analytics", "marketing"],
|
|
101
92
|
buildTags: (id) => [
|
|
@@ -113,9 +104,6 @@ function buildScriptTags({
|
|
|
113
104
|
return PROVIDER_SNIPPETS[type].buildTags(identifier);
|
|
114
105
|
}
|
|
115
106
|
function defaultConsentFor(type) {
|
|
116
|
-
if (type === "custom") {
|
|
117
|
-
return [];
|
|
118
|
-
}
|
|
119
107
|
return PROVIDER_SNIPPETS[type].defaultConsent;
|
|
120
108
|
}
|
|
121
109
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../consent/script-snippets.ts"],
|
|
4
|
-
"sourcesContent": ["import type {\n ConsentCategory,\n ReploScriptType,\n ScriptTagDescriptor,\n} from \"schemas/generated/consent\";\n\ntype ProviderType = Exclude<ReploScriptType, \"custom\">;\n\n/**\n * Runtime-safe per-provider data for the consent system. This is the subset of\n * the website-builder miniapp's `scriptConstants.ts` that must ship in the\n * customer site bundle: how to materialize each provider's script tags, and the\n * default consent category that gates it. Miniapp-only concerns (LLM detection\n * schemas, logos, marketing copy) intentionally stay in the miniapp.\n *\n * Unlike the miniapp's `buildSnippet`, which returns a JSX *string* for the\n * agent to paste into `layout.tsx`, this returns structured descriptors so the\n * runtime can inject real DOM nodes (inline `<script>` bodies set via React's\n * `dangerouslySetInnerHTML` never execute).\n */\ntype ProviderSnippet = {\n defaultConsent: ConsentCategory[];\n buildTags: (identifier: string) => ScriptTagDescriptor[];\n};\n\n/**\n * NOTE (Ryan, 2026-05-28, REPL-27515): `defaultConsent` is net-new,\n * legally-sensitive categorization that does not exist elsewhere in the repo.\n * These are conservative defaults a customer can override per entry via\n * `requiredConsent`; container/CDP providers that fan out to multiple vendors\n * (GTM, Segment
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import type {\n ConsentCategory,\n ReploScriptType,\n ScriptTagDescriptor,\n} from \"schemas/generated/consent\";\n\n// Identifier providers: those whose script the runtime synthesizes from an ID.\n// `snippet` (pasted whole) and `custom` carry their own bodies instead.\ntype ProviderType = Exclude<ReploScriptType, \"custom\" | \"snippet\">;\n\n/**\n * Runtime-safe per-provider data for the consent system. This is the subset of\n * the website-builder miniapp's `scriptConstants.ts` that must ship in the\n * customer site bundle: how to materialize each provider's script tags, and the\n * default consent category that gates it. Miniapp-only concerns (LLM detection\n * schemas, logos, marketing copy) intentionally stay in the miniapp.\n *\n * Unlike the miniapp's `buildSnippet`, which returns a JSX *string* for the\n * agent to paste into `layout.tsx`, this returns structured descriptors so the\n * runtime can inject real DOM nodes (inline `<script>` bodies set via React's\n * `dangerouslySetInnerHTML` never execute).\n */\ntype ProviderSnippet = {\n defaultConsent: ConsentCategory[];\n buildTags: (identifier: string) => ScriptTagDescriptor[];\n};\n\n/**\n * NOTE (Ryan, 2026-05-28, REPL-27515): `defaultConsent` is net-new,\n * legally-sensitive categorization that does not exist elsewhere in the repo.\n * These are conservative defaults a customer can override per entry via\n * `requiredConsent`; container/CDP providers that fan out to multiple vendors\n * (GTM, Segment) require the union of categories they can serve.\n */\nconst PROVIDER_SNIPPETS: Record<ProviderType, ProviderSnippet> = {\n GA4: {\n defaultConsent: [\"analytics\"],\n buildTags: (id) => [\n {\n kind: \"external\",\n src: `https://www.googletagmanager.com/gtag/js?id=${id}`,\n },\n {\n kind: \"inline\",\n body: `window.dataLayer = window.dataLayer || [];\\nfunction gtag(){dataLayer.push(arguments);}\\ngtag('js', new Date());\\ngtag('config', '${id}');`,\n },\n ],\n },\n GoogleTagManager: {\n defaultConsent: [\"analytics\", \"marketing\"],\n buildTags: (id) => [\n {\n kind: \"inline\",\n body: `(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);})(window,document,'script','dataLayer','${id}');`,\n },\n ],\n },\n Meta: {\n defaultConsent: [\"marketing\"],\n buildTags: (id) => [\n {\n kind: \"inline\",\n body: `!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,document,'script','https://connect.facebook.net/en_US/fbevents.js');fbq('init','${id}');fbq('track','PageView');`,\n },\n ],\n },\n TikTok: {\n defaultConsent: [\"marketing\"],\n buildTags: (id) => [\n {\n kind: \"inline\",\n body: `!function(w,d,t){w.TiktokAnalyticsObject=t;var ttq=w[t]=w[t]||[];ttq.methods=[\"page\",\"track\",\"identify\",\"instances\",\"debug\",\"on\",\"off\",\"once\",\"ready\",\"alias\",\"group\",\"enableCookie\",\"disableCookie\",\"holdConsent\",\"revokeConsent\",\"grantConsent\"],ttq.setAndDefer=function(t,e){t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}};for(var i=0;i<ttq.methods.length;i++)ttq.setAndDefer(ttq,ttq.methods[i]);ttq.instance=function(t){for(var e=ttq._i[t]||[],n=0;n<ttq.methods.length;n++)ttq.setAndDefer(e,ttq.methods[n]);return e};ttq.load=function(e,n){var r=\"https://analytics.tiktok.com/i18n/pixel/events.js\",o=n&&n.partner;ttq._i=ttq._i||{},ttq._i[e]=[],ttq._i[e]._u=r,ttq._t=ttq._t||{},ttq._t[e]=+new Date,ttq._o=ttq._o||{},ttq._o[e]=n||{};var a=document.createElement(\"script\");a.type=\"text/javascript\",a.async=!0,a.src=r+\"?sdkid=\"+e+\"&lib=\"+t;var s=document.getElementsByTagName(\"script\")[0];s.parentNode.insertBefore(a,s)};ttq.load('${id}');ttq.page();}(window,document,'ttq');`,\n },\n ],\n },\n Pinterest: {\n defaultConsent: [\"marketing\"],\n buildTags: (id) => [\n {\n kind: \"inline\",\n body: `!function(e){if(!window.pintrk){window.pintrk=function(){window.pintrk.queue.push(Array.prototype.slice.call(arguments))};var n=window.pintrk;n.queue=[],n.version=\"3.0\";var t=document.createElement(\"script\");t.async=!0,t.src=e;var r=document.getElementsByTagName(\"script\")[0];r.parentNode.insertBefore(t,r)}}(\"https://s.pinimg.com/ct/core.js\");pintrk('load','${id}');pintrk('page');`,\n },\n ],\n },\n Reddit: {\n defaultConsent: [\"marketing\"],\n buildTags: (id) => [\n {\n kind: \"inline\",\n body: `!function(w,d){if(!w.rdt){var p=w.rdt=function(){p.sendEvent?p.sendEvent.apply(p,arguments):p.callQueue.push(arguments)};p.callQueue=[];var t=d.createElement(\"script\");t.src=\"https://www.redditstatic.com/ads/pixel.js\",t.async=!0;var s=d.getElementsByTagName(\"script\")[0];s.parentNode.insertBefore(t,s)}}(window,document);rdt('init','${id}');rdt('track','PageVisit');`,\n },\n ],\n },\n Snapchat: {\n defaultConsent: [\"marketing\"],\n buildTags: (id) => [\n {\n kind: \"inline\",\n body: `(function(e,t,n){if(e.snaptr)return;var a=e.snaptr=function(){a.handleRequest?a.handleRequest.apply(a,arguments):a.queue.push(arguments)};a.queue=[];var s='script';var r=t.createElement(s);r.async=!0;r.src=n;var u=t.getElementsByTagName(s)[0];u.parentNode.insertBefore(r,u);})(window,document,'https://sc-static.net/scevent.min.js');snaptr('init','${id}',{});snaptr('track','PAGE_VIEW');`,\n },\n ],\n },\n Hotjar: {\n defaultConsent: [\"analytics\"],\n buildTags: (id) => [\n {\n kind: \"inline\",\n body: `(function(h,o,t,j,a,r){h.hj=h.hj||function(){(h.hj.q=h.hj.q||[]).push(arguments)};h._hjSettings={hjid:${id},hjsv:6};a=o.getElementsByTagName('head')[0];r=o.createElement('script');r.async=1;r.src=t+h._hjSettings.hjid+j+h._hjSettings.hjsv;a.appendChild(r);})(window,document,'https://static.hotjar.com/c/hotjar-','.js?sv=');`,\n },\n ],\n },\n MicrosoftClarity: {\n defaultConsent: [\"analytics\"],\n buildTags: (id) => [\n {\n kind: \"inline\",\n body: `(function(c,l,a,r,i,t,y){c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};t=l.createElement(r);t.async=1;t.src=\"https://www.clarity.ms/tag/\"+i;y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);})(window,document,\"clarity\",\"script\",\"${id}\");`,\n },\n ],\n },\n Segment: {\n defaultConsent: [\"analytics\", \"marketing\"],\n buildTags: (id) => [\n {\n kind: \"inline\",\n body: `!function(){var i=\"analytics\",analytics=window[i]=window[i]||[];if(!analytics.initialize)if(analytics.invoked)window.console&&console.error&&console.error(\"Segment snippet included twice.\");else{analytics.invoked=!0;analytics.methods=[\"trackSubmit\",\"trackClick\",\"trackLink\",\"trackForm\",\"pageview\",\"identify\",\"reset\",\"group\",\"track\",\"ready\",\"alias\",\"debug\",\"page\",\"screen\",\"once\",\"off\",\"on\",\"addSourceMiddleware\",\"addIntegrationMiddleware\",\"setAnonymousId\",\"addDestinationMiddleware\",\"register\"];analytics.factory=function(e){return function(){var t=Array.prototype.slice.call(arguments);t.unshift(e);analytics.push(t);return analytics}};for(var e=0;e<analytics.methods.length;e++){var key=analytics.methods[e];analytics[key]=analytics.factory(key)}analytics.load=function(key,e){var t=document.createElement(\"script\");t.type=\"text/javascript\";t.async=!0;t.src=\"https://cdn.segment.com/analytics.js/v1/\"+key+\"/analytics.min.js\";var n=document.getElementsByTagName(\"script\")[0];n.parentNode.insertBefore(t,n);analytics._loadOptions=e};analytics._writeKey=\"${id}\";analytics.SNIPPET_VERSION=\"5.2.0\";analytics.load(\"${id}\");analytics.page();}}();`,\n },\n ],\n },\n};\n\n/**\n * Snippet providers don't synthesize tags (the user pastes the provider-issued\n * snippet as the entry's `body`), but they still get a first-class default\n * consent categorization like identifier providers.\n */\n/**\n * Returns the structured tag descriptors for a named provider. A single provider\n * can produce multiple tags (e.g. GA4 = external loader + inline config), which\n * the runtime injects in order.\n */\nexport function buildScriptTags({\n type,\n identifier,\n}: {\n type: ProviderType;\n identifier: string;\n}): ScriptTagDescriptor[] {\n return PROVIDER_SNIPPETS[type].buildTags(identifier);\n}\n\n/**\n * The default consent categories that gate an identifier-provider script when an\n * entry does not specify `requiredConsent`. `snippet` and `custom` entries carry\n * `requiredConsent` explicitly (the runtime has no default for them), so this is\n * only consulted for identifier providers. Overridable per entry by the customer.\n */\nexport function defaultConsentFor(type: ProviderType): ConsentCategory[] {\n return PROVIDER_SNIPPETS[type].defaultConsent;\n}\n"],
|
|
5
|
+
"mappings": "AAkCA,MAAM,oBAA2D;AAAA,EAC/D,KAAK;AAAA,IACH,gBAAgB,CAAC,WAAW;AAAA,IAC5B,WAAW,CAAC,OAAO;AAAA,MACjB;AAAA,QACE,MAAM;AAAA,QACN,KAAK,+CAA+C,EAAE;AAAA,MACxD;AAAA,MACA;AAAA,QACE,MAAM;AAAA,QACN,MAAM;AAAA;AAAA;AAAA,kBAAqI,EAAE;AAAA,MAC/I;AAAA,IACF;AAAA,EACF;AAAA,EACA,kBAAkB;AAAA,IAChB,gBAAgB,CAAC,aAAa,WAAW;AAAA,IACzC,WAAW,CAAC,OAAO;AAAA,MACjB;AAAA,QACE,MAAM;AAAA,QACN,MAAM,sUAAsU,EAAE;AAAA,MAChV;AAAA,IACF;AAAA,EACF;AAAA,EACA,MAAM;AAAA,IACJ,gBAAgB,CAAC,WAAW;AAAA,IAC5B,WAAW,CAAC,OAAO;AAAA,MACjB;AAAA,QACE,MAAM;AAAA,QACN,MAAM,uYAAuY,EAAE;AAAA,MACjZ;AAAA,IACF;AAAA,EACF;AAAA,EACA,QAAQ;AAAA,IACN,gBAAgB,CAAC,WAAW;AAAA,IAC5B,WAAW,CAAC,OAAO;AAAA,MACjB;AAAA,QACE,MAAM;AAAA,QACN,MAAM,+7BAA+7B,EAAE;AAAA,MACz8B;AAAA,IACF;AAAA,EACF;AAAA,EACA,WAAW;AAAA,IACT,gBAAgB,CAAC,WAAW;AAAA,IAC5B,WAAW,CAAC,OAAO;AAAA,MACjB;AAAA,QACE,MAAM;AAAA,QACN,MAAM,0WAA0W,EAAE;AAAA,MACpX;AAAA,IACF;AAAA,EACF;AAAA,EACA,QAAQ;AAAA,IACN,gBAAgB,CAAC,WAAW;AAAA,IAC5B,WAAW,CAAC,OAAO;AAAA,MACjB;AAAA,QACE,MAAM;AAAA,QACN,MAAM,gVAAgV,EAAE;AAAA,MAC1V;AAAA,IACF;AAAA,EACF;AAAA,EACA,UAAU;AAAA,IACR,gBAAgB,CAAC,WAAW;AAAA,IAC5B,WAAW,CAAC,OAAO;AAAA,MACjB;AAAA,QACE,MAAM;AAAA,QACN,MAAM,+VAA+V,EAAE;AAAA,MACzW;AAAA,IACF;AAAA,EACF;AAAA,EACA,QAAQ;AAAA,IACN,gBAAgB,CAAC,WAAW;AAAA,IAC5B,WAAW,CAAC,OAAO;AAAA,MACjB;AAAA,QACE,MAAM;AAAA,QACN,MAAM,yGAAyG,EAAE;AAAA,MACnH;AAAA,IACF;AAAA,EACF;AAAA,EACA,kBAAkB;AAAA,IAChB,gBAAgB,CAAC,WAAW;AAAA,IAC5B,WAAW,CAAC,OAAO;AAAA,MACjB;AAAA,QACE,MAAM;AAAA,QACN,MAAM,iQAAiQ,EAAE;AAAA,MAC3Q;AAAA,IACF;AAAA,EACF;AAAA,EACA,SAAS;AAAA,IACP,gBAAgB,CAAC,aAAa,WAAW;AAAA,IACzC,WAAW,CAAC,OAAO;AAAA,MACjB;AAAA,QACE,MAAM;AAAA,QACN,MAAM,iiCAAiiC,EAAE,uDAAuD,EAAE;AAAA,MACpmC;AAAA,IACF;AAAA,EACF;AACF;AAYO,SAAS,gBAAgB;AAAA,EAC9B;AAAA,EACA;AACF,GAG0B;AACxB,SAAO,kBAAkB,IAAI,EAAE,UAAU,UAAU;AACrD;AAQO,SAAS,kBAAkB,MAAuC;AACvE,SAAO,kBAAkB,IAAI,EAAE;AACjC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/consent/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type ReploScriptType = "GA4" | "GoogleTagManager" | "Meta" | "TikTok" | "Pinterest" | "Reddit" | "Snapchat" | "Hotjar" | "MicrosoftClarity" | "
|
|
1
|
+
export type ReploScriptType = "GA4" | "GoogleTagManager" | "Meta" | "TikTok" | "Pinterest" | "Reddit" | "Snapchat" | "Hotjar" | "MicrosoftClarity" | "Segment" | "snippet" | "custom";
|
|
2
2
|
export type ConsentCategory = "necessary" | "analytics" | "marketing" | "preferences" | "sale_of_data";
|
|
3
3
|
export type ConsentMode = "off" | "simple" | "per-category";
|
|
4
4
|
declare module "react" {
|
|
@@ -17,9 +17,14 @@ export type ScriptTagDescriptor = {
|
|
|
17
17
|
body: string;
|
|
18
18
|
};
|
|
19
19
|
export type ReploScriptEntry = {
|
|
20
|
-
type: "GA4" | "GoogleTagManager" | "Meta" | "TikTok" | "Pinterest" | "Reddit" | "Snapchat" | "Hotjar" | "MicrosoftClarity" | "
|
|
20
|
+
type: "GA4" | "GoogleTagManager" | "Meta" | "TikTok" | "Pinterest" | "Reddit" | "Snapchat" | "Hotjar" | "MicrosoftClarity" | "Segment";
|
|
21
21
|
identifier: string;
|
|
22
22
|
requiredConsent?: ConsentCategory[];
|
|
23
|
+
} | {
|
|
24
|
+
type: "snippet";
|
|
25
|
+
id: string;
|
|
26
|
+
body: string;
|
|
27
|
+
requiredConsent: ConsentCategory[];
|
|
23
28
|
} | {
|
|
24
29
|
type: "custom";
|
|
25
30
|
id: string;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
/**
|
|
3
|
-
* Client-side error boundary
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* NOTE (Max, 2026-06-10): Client-side error boundary. On a caught render error it
|
|
4
|
+
* (1) reports the error to the parent editor via postMessage (so it can get reported to Sentry)
|
|
5
|
+
* and (2) renders a neutral cover instead of going blank, so the preview never flashes the broken
|
|
6
|
+
* page while the agent fixes it. The editor decides what to show on top (loading
|
|
7
|
+
* vs. an actionable error screen); the embedder reloads the iframe once the error
|
|
8
|
+
* clears.
|
|
6
9
|
*/
|
|
7
10
|
export declare function ClientErrorBoundary({ children }: React.PropsWithChildren): import("react/jsx-runtime").JSX.Element;
|
|
@@ -3,18 +3,27 @@ import { jsx } from "react/jsx-runtime";
|
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
class ErrorBoundary extends React.Component {
|
|
5
5
|
state = {
|
|
6
|
-
didCatch: false
|
|
7
|
-
error: null
|
|
6
|
+
didCatch: false
|
|
8
7
|
};
|
|
9
|
-
static getDerivedStateFromError(
|
|
10
|
-
return { didCatch: true
|
|
8
|
+
static getDerivedStateFromError() {
|
|
9
|
+
return { didCatch: true };
|
|
11
10
|
}
|
|
12
11
|
componentDidCatch(error, info) {
|
|
13
12
|
this.props.onError?.(error, info);
|
|
14
13
|
}
|
|
15
14
|
render() {
|
|
16
15
|
if (this.state.didCatch) {
|
|
17
|
-
return
|
|
16
|
+
return /* @__PURE__ */ jsx(
|
|
17
|
+
"div",
|
|
18
|
+
{
|
|
19
|
+
style: {
|
|
20
|
+
position: "fixed",
|
|
21
|
+
inset: 0,
|
|
22
|
+
zIndex: 2147483646,
|
|
23
|
+
background: "#ffffff"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
);
|
|
18
27
|
}
|
|
19
28
|
return this.props.children;
|
|
20
29
|
}
|
|
@@ -25,6 +34,10 @@ function ClientErrorBoundary({ children }) {
|
|
|
25
34
|
const errorObj = error instanceof Error ? error : new Error(String(error));
|
|
26
35
|
window.parent.postMessage(
|
|
27
36
|
{
|
|
37
|
+
// TODO (Max, 2026-06-11, REPL-27851): When adding Sentry to miniapps, I'll ensure we listen to this message
|
|
38
|
+
// and send it to Sentry. I'm not a fan of having 2 separate post messages for reporting errors (the 'error' post message in NextErrorReporter, and this one).
|
|
39
|
+
// But there's no way for the NextErrorReporter to get the actual error object, so we'll
|
|
40
|
+
// need a separate postMessage (this one, with an updated name).
|
|
28
41
|
type: "replo-editor:client-error",
|
|
29
42
|
payload: {
|
|
30
43
|
pageRoute: window.location.pathname,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../editor/ClientErrorBoundary.tsx"],
|
|
4
|
-
"sourcesContent": ["\"use client\";\n\nimport * as React from \"react\";\n\ninterface ErrorBoundaryState {\n didCatch: boolean;\n
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["\"use client\";\n\nimport * as React from \"react\";\n\ninterface ErrorBoundaryState {\n didCatch: boolean;\n}\n\ntype ErrorBoundaryProps = React.PropsWithChildren<{\n onError?: (error: unknown, info: React.ErrorInfo) => void;\n}>;\n\nclass ErrorBoundary extends React.Component<\n ErrorBoundaryProps,\n ErrorBoundaryState\n> {\n state: ErrorBoundaryState = {\n didCatch: false,\n };\n\n static getDerivedStateFromError(): ErrorBoundaryState {\n return { didCatch: true };\n }\n\n componentDidCatch(error: unknown, info: React.ErrorInfo) {\n this.props.onError?.(error, info);\n }\n\n render() {\n if (this.state.didCatch) {\n /**\n * NOTE (Max, 2026-06-10): When there's any error that hits this Error boundary,\n * we render this neutral cover.\n * getDerivedStateFromError() runs in the render phase, before commit, so this cover\n * is what hits the DOM immediately when the error is caught.\n * The editor lays its own loading / error UI on top (driven by NextErrorReporter's\n * status postMessage).\n * This div has a plain light neutral color, close enough to the editor's\n * loading animation. If we returned null, it'd show a cover with the site's default color (e.g. black),\n * which makes the transition less smooth between canopy-sdk showing this cover, and the iframe embedder\n * receiving the post message telling it to show some loading animation.\n *\n * I'm really unsatisfied with this approach: there's no apparent flicker only because the editor's loading animation\n * when receiving the post message has the same color as this neutral cover... Alternative would be for\n * this error boundary to show the loading animation itself (instead of the embedder) but that's even more weird...\n */\n return (\n <div\n style={{\n position: \"fixed\",\n inset: 0,\n zIndex: 2147483646,\n background: \"#ffffff\",\n }}\n />\n );\n }\n return this.props.children;\n }\n}\n\n/**\n * NOTE (Max, 2026-06-10): Client-side error boundary. On a caught render error it\n * (1) reports the error to the parent editor via postMessage (so it can get reported to Sentry)\n * and (2) renders a neutral cover instead of going blank, so the preview never flashes the broken\n * page while the agent fixes it. The editor decides what to show on top (loading\n * vs. an actionable error screen); the embedder reloads the iframe once the error\n * clears.\n */\nexport function ClientErrorBoundary({ children }: React.PropsWithChildren) {\n const handleError = React.useCallback(\n (error: unknown, errorInfo: React.ErrorInfo) => {\n const errorObj =\n error instanceof Error ? error : new Error(String(error));\n window.parent.postMessage(\n {\n // TODO (Max, 2026-06-11, REPL-27851): When adding Sentry to miniapps, I'll ensure we listen to this message\n // and send it to Sentry. I'm not a fan of having 2 separate post messages for reporting errors (the 'error' post message in NextErrorReporter, and this one).\n // But there's no way for the NextErrorReporter to get the actual error object, so we'll\n // need a separate postMessage (this one, with an updated name).\n type: \"replo-editor:client-error\",\n payload: {\n pageRoute: window.location.pathname,\n error: {\n message: errorObj.message,\n stack: errorObj.stack,\n componentStack: errorInfo.componentStack,\n },\n },\n },\n \"*\",\n );\n },\n [],\n );\n\n return <ErrorBoundary onError={handleError}>{children}</ErrorBoundary>;\n}\n"],
|
|
5
|
+
"mappings": ";AA+CQ;AA7CR,YAAY,WAAW;AAUvB,MAAM,sBAAsB,MAAM,UAGhC;AAAA,EACA,QAA4B;AAAA,IAC1B,UAAU;AAAA,EACZ;AAAA,EAEA,OAAO,2BAA+C;AACpD,WAAO,EAAE,UAAU,KAAK;AAAA,EAC1B;AAAA,EAEA,kBAAkB,OAAgB,MAAuB;AACvD,SAAK,MAAM,UAAU,OAAO,IAAI;AAAA,EAClC;AAAA,EAEA,SAAS;AACP,QAAI,KAAK,MAAM,UAAU;AAiBvB,aACE;AAAA,QAAC;AAAA;AAAA,UACC,OAAO;AAAA,YACL,UAAU;AAAA,YACV,OAAO;AAAA,YACP,QAAQ;AAAA,YACR,YAAY;AAAA,UACd;AAAA;AAAA,MACF;AAAA,IAEJ;AACA,WAAO,KAAK,MAAM;AAAA,EACpB;AACF;AAUO,SAAS,oBAAoB,EAAE,SAAS,GAA4B;AACzE,QAAM,cAAc,MAAM;AAAA,IACxB,CAAC,OAAgB,cAA+B;AAC9C,YAAM,WACJ,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,KAAK,CAAC;AAC1D,aAAO,OAAO;AAAA,QACZ;AAAA;AAAA;AAAA;AAAA;AAAA,UAKE,MAAM;AAAA,UACN,SAAS;AAAA,YACP,WAAW,OAAO,SAAS;AAAA,YAC3B,OAAO;AAAA,cACL,SAAS,SAAS;AAAA,cAClB,OAAO,SAAS;AAAA,cAChB,gBAAgB,UAAU;AAAA,YAC5B;AAAA,UACF;AAAA,QACF;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAAA,IACA,CAAC;AAAA,EACH;AAEA,SAAO,oBAAC,iBAAc,SAAS,aAAc,UAAS;AACxD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function NextErrorReporter(): null;
|