@replohq/canopy-sdk 2.5.0 → 3.0.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/fonts.mjs +1 -0
- package/_vendor/replo-utils/lib/geometry.mjs +2 -0
- package/_vendor/replo-utils/lib/json.mjs +1 -0
- package/_vendor/replo-utils/lib/misc.mjs +1 -0
- package/_vendor/replo-utils/lib/posthogReplay.mjs +2 -0
- package/_vendor/replo-utils/lib/url.mjs +1 -0
- package/_vendor/replo-utils/react/use-iframe-rpc-channel.mjs +1 -1
- package/_vendor/schemas/designLibrary.mjs +1 -1
- package/_vendor/schemas/iframeRpcChannel.mjs +2 -1
- package/_vendor/schemas/loaderKeys.d.ts +1 -1
- package/_vendor/schemas/loaderKeys.mjs +103 -23
- package/_vendor/schemas/money.mjs +1860 -3
- package/_vendor/schemas/pageAnnotations.mjs +1 -1
- package/_vendor/schemas/routing/match.mjs +1 -0
- package/_vendor/schemas/routing/rules.mjs +2 -1
- package/_vendor/schemas/selectMode.d.ts +4 -4
- package/_vendor/schemas/selectMode.mjs +1 -0
- package/_vendor/schemas/selectModeIframeRpc.d.ts +4 -4
- package/_vendor/schemas/selectModeIframeRpc.mjs +1 -0
- package/analytics/analytics-provider.d.ts +5 -10
- package/analytics/analytics-provider.js +14 -101
- package/analytics/analytics-provider.js.map +2 -2
- package/analytics/get-analytics-sinks.d.ts +2 -19
- package/analytics/get-analytics-sinks.js +9 -46
- package/analytics/get-analytics-sinks.js.map +2 -2
- package/analytics/hooks/use-product-viewed-analytics.d.ts +2 -6
- package/analytics/hooks/use-product-viewed-analytics.js +6 -28
- package/analytics/hooks/use-product-viewed-analytics.js.map +2 -2
- package/analytics/replo-first-party-pixel.d.ts +3 -12
- package/analytics/replo-first-party-pixel.js +8 -24
- package/analytics/replo-first-party-pixel.js.map +2 -2
- package/analytics/replo-pixel-script.d.ts +4 -10
- package/analytics/replo-pixel-script.js +9 -23
- package/analytics/replo-pixel-script.js.map +2 -2
- package/analytics/sinks/ga4-sink.d.ts +10 -9
- package/analytics/sinks/ga4-sink.js +99 -50
- package/analytics/sinks/ga4-sink.js.map +2 -2
- package/analytics/sinks/meta-sink.d.ts +5 -4
- package/analytics/sinks/meta-sink.js +82 -29
- package/analytics/sinks/meta-sink.js.map +2 -2
- package/analytics/sinks/pinterest-sink.d.ts +7 -6
- package/analytics/sinks/pinterest-sink.js +82 -49
- package/analytics/sinks/pinterest-sink.js.map +2 -2
- package/analytics/sinks/reddit-sink.d.ts +8 -7
- package/analytics/sinks/reddit-sink.js +82 -53
- package/analytics/sinks/reddit-sink.js.map +2 -2
- package/analytics/sinks/replo-sink.d.ts +9 -8
- package/analytics/sinks/replo-sink.js +89 -37
- package/analytics/sinks/replo-sink.js.map +2 -2
- package/analytics/sinks/snapchat-sink.d.ts +6 -5
- package/analytics/sinks/snapchat-sink.js +82 -40
- package/analytics/sinks/snapchat-sink.js.map +2 -2
- package/analytics/sinks/tiktok-sink.d.ts +8 -7
- package/analytics/sinks/tiktok-sink.js +82 -52
- package/analytics/sinks/tiktok-sink.js.map +2 -2
- package/analytics/sinks/window-sink.d.ts +11 -14
- package/analytics/sinks/window-sink.js +101 -28
- package/analytics/sinks/window-sink.js.map +2 -2
- package/analytics/utils/analytics-utils.d.ts +4 -2
- package/analytics/utils/analytics-utils.js +19 -123
- package/analytics/utils/analytics-utils.js.map +2 -2
- package/analytics/utils/navigation-tracker.d.ts +2 -1
- package/analytics/utils/navigation-tracker.js +37 -30
- package/analytics/utils/navigation-tracker.js.map +2 -2
- package/analytics/utils/shopify-funnel-gate.d.ts +2 -7
- package/analytics/utils/shopify-funnel-gate.js +8 -15
- package/analytics/utils/shopify-funnel-gate.js.map +2 -2
- package/cart/buy-now-action.d.ts +2 -9
- package/cart/buy-now-action.js +5 -97
- package/cart/buy-now-action.js.map +2 -2
- package/cart/cart-actions.d.ts +12 -56
- package/cart/cart-actions.js +88 -68
- package/cart/cart-actions.js.map +2 -2
- package/cart/cart-loader.d.ts +3 -9
- package/cart/cart-loader.js +14 -6
- package/cart/cart-loader.js.map +2 -2
- package/cart/cart-provider.d.ts +6 -58
- package/cart/cart-provider.js +13 -359
- package/cart/cart-provider.js.map +3 -3
- package/cart/cart-schema.d.ts +2 -1
- package/cart/cart-schema.js +12 -64
- package/cart/cart-schema.js.map +2 -2
- package/cart/cart-types.d.ts +1 -1
- package/cart/cart-types.js +5 -4
- package/cart/cart-types.js.map +2 -2
- package/cart/gateways/cart-constants.d.ts +1 -0
- package/cart/gateways/cart-constants.js.map +2 -2
- package/cart/gateways/cart-gateway.d.ts +1 -0
- package/cart/gateways/cart-gateway.js +13 -12
- package/cart/gateways/cart-gateway.js.map +2 -2
- package/cart/gateways/cookie-cart-gateway.d.ts +8 -11
- package/cart/gateways/cookie-cart-gateway.js +93 -97
- package/cart/gateways/cookie-cart-gateway.js.map +2 -2
- package/cart/gateways/default-cart-gateway.d.ts +10 -16
- package/cart/gateways/default-cart-gateway.js +13 -23
- package/cart/gateways/default-cart-gateway.js.map +2 -2
- package/cart/gateways/resolver-cart-gateway.d.ts +1 -0
- package/cart/gateways/resolver-cart-gateway.js +13 -102
- package/cart/gateways/resolver-cart-gateway.js.map +2 -2
- package/cart/gateways/stripe-cart-gateway.d.ts +10 -16
- package/cart/gateways/stripe-cart-gateway.js +13 -21
- package/cart/gateways/stripe-cart-gateway.js.map +2 -2
- package/cart/hooks/use-add-to-cart.d.ts +3 -47
- package/cart/hooks/use-add-to-cart.js +10 -115
- package/cart/hooks/use-add-to-cart.js.map +2 -2
- package/cart/hooks/use-buy-now.d.ts +1 -39
- package/cart/hooks/use-buy-now.js +5 -55
- package/cart/hooks/use-buy-now.js.map +2 -2
- package/cart/utils/cart-utils.d.ts +8 -35
- package/cart/utils/cart-utils.js +21 -35
- package/cart/utils/cart-utils.js.map +2 -2
- package/cart/utils/cookie-cart-persistence.d.ts +16 -41
- package/cart/utils/cookie-cart-persistence.js +38 -143
- package/cart/utils/cookie-cart-persistence.js.map +2 -2
- package/cart/utils/variant-to-cart-line.d.ts +12 -42
- package/cart/utils/variant-to-cart-line.js +31 -147
- package/cart/utils/variant-to-cart-line.js.map +2 -2
- package/chunk-UJCSKKID.mjs +27 -0
- package/{chunk-OFU2QEDR.mjs → chunk-ZZPQ3E7S.mjs} +50 -5
- package/consent/consent-action.d.ts +2 -1
- package/consent/consent-action.js +10 -20
- package/consent/consent-action.js.map +2 -2
- package/consent/consent-actions.d.ts +2 -13
- package/consent/consent-actions.js +9 -29
- package/consent/consent-actions.js.map +2 -2
- package/consent/consent-store.d.ts +9 -36
- package/consent/consent-store.js +12 -182
- package/consent/consent-store.js.map +2 -2
- package/consent/cookie.d.ts +9 -12
- package/consent/cookie.js +32 -64
- package/consent/cookie.js.map +2 -2
- package/consent/replo-scripts.d.ts +5 -18
- package/consent/replo-scripts.js +11 -94
- package/consent/replo-scripts.js.map +2 -2
- package/consent/script-registration-store.d.ts +6 -2
- package/consent/script-registration-store.js +33 -47
- package/consent/script-registration-store.js.map +2 -2
- package/consent/script-snippets.d.ts +4 -18
- package/consent/script-snippets.js +19 -127
- package/consent/script-snippets.js.map +2 -2
- package/consent/window-api.d.ts +4 -15
- package/consent/window-api.js +8 -63
- package/consent/window-api.js.map +2 -2
- package/editor/ClientErrorBoundary.d.ts +4 -10
- package/editor/ClientErrorBoundary.js +7 -55
- package/editor/ClientErrorBoundary.js.map +2 -2
- package/editor/DocumentReadyBeacon.d.ts +3 -1
- package/editor/DocumentReadyBeacon.js +6 -3
- package/editor/DocumentReadyBeacon.js.map +2 -2
- package/editor/LinkInterceptor.d.ts +1 -0
- package/editor/LinkInterceptor.js +6 -121
- package/editor/LinkInterceptor.js.map +2 -2
- package/editor/NextErrorReporter.d.ts +1 -0
- package/editor/NextErrorReporter.js +6 -85
- package/editor/NextErrorReporter.js.map +2 -2
- package/editor/annotations/AnnotationLayerMount.d.ts +1 -0
- package/editor/annotations/AnnotationLayerMount.js +6 -6
- package/editor/annotations/AnnotationLayerMount.js.map +2 -2
- package/editor/annotations/annotationController.d.ts +1 -0
- package/editor/annotations/annotationController.js +6 -378
- package/editor/annotations/annotationController.js.map +2 -2
- package/editor/annotations/bridgeGate.d.ts +4 -7
- package/editor/annotations/bridgeGate.js +13 -15
- package/editor/annotations/bridgeGate.js.map +2 -2
- package/editor/design-library-preview/DesignLibraryPreview.d.ts +1 -0
- package/editor/design-library-preview/DesignLibraryPreview.js +6 -86
- package/editor/design-library-preview/DesignLibraryPreview.js.map +2 -2
- package/editor/posthog-relay.d.ts +1 -10
- package/editor/posthog-relay.js +6 -65
- package/editor/posthog-relay.js.map +2 -2
- package/editor/select-mode/EditorSelection.d.ts +1 -23
- package/editor/select-mode/EditorSelection.js +5 -87
- package/editor/select-mode/EditorSelection.js.map +2 -2
- package/editor/select-mode/annotationFrames.d.ts +9 -9
- package/editor/select-mode/annotationFrames.js +22 -103
- package/editor/select-mode/annotationFrames.js.map +2 -2
- package/editor/select-mode/descriptor/elementDescriptor.d.ts +6 -21
- package/editor/select-mode/descriptor/elementDescriptor.js +19 -192
- package/editor/select-mode/descriptor/elementDescriptor.js.map +3 -3
- package/editor/select-mode/descriptor/styleExtraction.d.ts +4 -2
- package/editor/select-mode/descriptor/styleExtraction.js +11 -262
- package/editor/select-mode/descriptor/styleExtraction.js.map +2 -2
- package/editor/select-mode/displayModeStore.d.ts +2 -0
- package/editor/select-mode/displayModeStore.js +14 -39
- package/editor/select-mode/displayModeStore.js.map +2 -2
- package/editor/select-mode/fast-refresh-relay.d.ts +2 -1
- package/editor/select-mode/fast-refresh-relay.js +7 -28
- package/editor/select-mode/fast-refresh-relay.js.map +2 -2
- package/editor/select-mode/fiber.d.ts +14 -7
- package/editor/select-mode/fiber.js +40 -286
- package/editor/select-mode/fiber.js.map +2 -2
- package/editor/select-mode/hooks/useCrosshairCursor.d.ts +2 -9
- package/editor/select-mode/hooks/useCrosshairCursor.js +7 -15
- package/editor/select-mode/hooks/useCrosshairCursor.js.map +2 -2
- package/editor/select-mode/hooks/useEditModeStateMachine.d.ts +5 -3
- package/editor/select-mode/hooks/useEditModeStateMachine.js +13 -228
- package/editor/select-mode/hooks/useEditModeStateMachine.js.map +2 -2
- package/editor/select-mode/hooks/useOptimisticOverrides.d.ts +2 -1
- package/editor/select-mode/hooks/useOptimisticOverrides.js +6 -277
- package/editor/select-mode/hooks/useOptimisticOverrides.js.map +2 -2
- package/editor/select-mode/hooks/useParentMessaging.d.ts +2 -20
- package/editor/select-mode/hooks/useParentMessaging.js +7 -69
- package/editor/select-mode/hooks/useParentMessaging.js.map +2 -2
- package/editor/select-mode/hooks/useSelectModeController.d.ts +2 -1
- package/editor/select-mode/hooks/useSelectModeController.js +6 -40
- package/editor/select-mode/hooks/useSelectModeController.js.map +2 -2
- package/editor/select-mode/hooks/useSelectionHover.d.ts +2 -16
- package/editor/select-mode/hooks/useSelectionHover.js +7 -105
- package/editor/select-mode/hooks/useSelectionHover.js.map +2 -2
- package/editor/select-mode/hooks/useSelectionInteractions.d.ts +2 -26
- package/editor/select-mode/hooks/useSelectionInteractions.js +7 -348
- package/editor/select-mode/hooks/useSelectionInteractions.js.map +2 -2
- package/editor/select-mode/hooks/useSelectionScrollSync.d.ts +2 -22
- package/editor/select-mode/hooks/useSelectionScrollSync.js +7 -65
- package/editor/select-mode/hooks/useSelectionScrollSync.js.map +2 -2
- package/editor/select-mode/hooks/useSiblingResolution.d.ts +4 -2
- package/editor/select-mode/hooks/useSiblingResolution.js +13 -52
- package/editor/select-mode/hooks/useSiblingResolution.js.map +2 -2
- package/editor/select-mode/iframeRpcChannel.d.ts +10 -349
- package/editor/select-mode/iframeRpcChannel.js +23 -79
- package/editor/select-mode/iframeRpcChannel.js.map +2 -2
- package/editor/select-mode/inlineTextMarks.d.ts +4 -6
- package/editor/select-mode/inlineTextMarks.js +13 -18
- package/editor/select-mode/inlineTextMarks.js.map +2 -2
- package/editor/select-mode/interactions/selectionGeometry.d.ts +19 -61
- package/editor/select-mode/interactions/selectionGeometry.js +57 -165
- package/editor/select-mode/interactions/selectionGeometry.js.map +2 -2
- package/editor/select-mode/selectModeSession.d.ts +1 -0
- package/editor/select-mode/selectModeSession.js +6 -3
- package/editor/select-mode/selectModeSession.js.map +2 -2
- package/editor/select-mode/selectionFrame.d.ts +9 -60
- package/editor/select-mode/selectionFrame.js +28 -116
- package/editor/select-mode/selectionFrame.js.map +2 -2
- package/editor/select-mode/symbolicate.d.ts +2 -1
- package/editor/select-mode/symbolicate.js +7 -195
- package/editor/select-mode/symbolicate.js.map +2 -2
- package/editor/select-mode/tiptapInlineEditor.d.ts +15 -2
- package/editor/select-mode/tiptapInlineEditor.js +6 -114
- package/editor/select-mode/tiptapInlineEditor.js.map +2 -2
- package/env.d.ts +2 -1
- package/env.js +10 -37
- package/env.js.map +2 -2
- package/gateways/canopy-api.d.ts +15 -12
- package/gateways/canopy-api.js +122 -160
- package/gateways/canopy-api.js.map +2 -2
- package/hooks/use-client-value.d.ts +2 -10
- package/hooks/use-client-value.js +10 -7
- package/hooks/use-client-value.js.map +2 -2
- package/hooks/use-formatted-price.d.ts +1 -14
- package/hooks/use-formatted-price.js +6 -14
- package/hooks/use-formatted-price.js.map +2 -2
- package/lib/canopy-error.d.ts +2 -5
- package/lib/canopy-error.js +10 -14
- package/lib/canopy-error.js.map +2 -2
- package/lib/get-query-client.d.ts +2 -1
- package/lib/get-query-client.js +8 -27
- package/lib/get-query-client.js.map +2 -2
- package/lib/integration-utils.d.ts +1 -0
- package/lib/integration-utils.js +9 -3
- package/lib/integration-utils.js.map +2 -2
- package/lib/shopify-utils.d.ts +2 -10
- package/lib/shopify-utils.js +10 -2
- package/lib/shopify-utils.js.map +2 -2
- package/lib/tombstone.d.ts +21 -0
- package/lib/tombstone.js +99 -0
- package/lib/tombstone.js.map +7 -0
- package/lib/url-utils.d.ts +2 -4
- package/lib/url-utils.js +10 -3
- package/lib/url-utils.js.map +2 -2
- package/loaders/collection-loader.d.ts +3 -2
- package/loaders/collection-loader.js +5 -48
- package/loaders/collection-loader.js.map +2 -2
- package/loaders/collection-products-loader.d.ts +3 -2
- package/loaders/collection-products-loader.js +5 -51
- package/loaders/collection-products-loader.js.map +2 -2
- package/loaders/contentful-entries-loader.d.ts +3 -2
- package/loaders/contentful-entries-loader.js +5 -71
- package/loaders/contentful-entries-loader.js.map +2 -2
- package/loaders/contentful-entry-loader.d.ts +3 -2
- package/loaders/contentful-entry-loader.js +5 -53
- package/loaders/contentful-entry-loader.js.map +2 -2
- package/loaders/invoke-loader-action.d.ts +2 -8
- package/loaders/invoke-loader-action.js +13 -8
- package/loaders/invoke-loader-action.js.map +2 -2
- package/loaders/invoke-loader-server.d.ts +2 -14
- package/loaders/invoke-loader-server.js +12 -34
- package/loaders/invoke-loader-server.js.map +2 -2
- package/loaders/invoke-loader.d.ts +6 -12
- package/loaders/invoke-loader.js +27 -29
- package/loaders/invoke-loader.js.map +2 -2
- package/loaders/levanta-product-loader.d.ts +3 -2
- package/loaders/levanta-product-loader.js +5 -46
- package/loaders/levanta-product-loader.js.map +2 -2
- package/loaders/loader-error-boundary.d.ts +9 -15
- package/loaders/loader-error-boundary.js +50 -13
- package/loaders/loader-error-boundary.js.map +2 -2
- package/loaders/loader-keys.d.ts +4 -12
- package/loaders/loader-keys.js +6 -1
- package/loaders/loader-keys.js.map +2 -2
- package/loaders/loader-schemas.d.ts +142 -61
- package/loaders/loader-schemas.js +253 -90
- package/loaders/loader-schemas.js.map +2 -2
- package/loaders/metaobject-loader.d.ts +3 -2
- package/loaders/metaobject-loader.js +5 -47
- package/loaders/metaobject-loader.js.map +2 -2
- package/loaders/metaobjects-loader.d.ts +3 -2
- package/loaders/metaobjects-loader.js +5 -53
- package/loaders/metaobjects-loader.js.map +2 -2
- package/loaders/okendo-review-aggregate-loader.d.ts +9 -10
- package/loaders/okendo-review-aggregate-loader.js +5 -49
- package/loaders/okendo-review-aggregate-loader.js.map +2 -2
- package/loaders/okendo-reviews-loader.d.ts +8 -16
- package/loaders/okendo-reviews-loader.js +5 -47
- package/loaders/okendo-reviews-loader.js.map +2 -2
- package/loaders/prefetch-loaders.d.ts +4 -26
- package/loaders/prefetch-loaders.js +5 -40
- package/loaders/prefetch-loaders.js.map +2 -2
- package/loaders/preview-placeholder.d.ts +8 -22
- package/loaders/preview-placeholder.js +47 -209
- package/loaders/preview-placeholder.js.map +2 -2
- package/loaders/product-loader-args.d.ts +2 -11
- package/loaders/product-loader-args.js +6 -12
- package/loaders/product-loader-args.js.map +2 -2
- package/loaders/product-loader.d.ts +3 -2
- package/loaders/product-loader.js +5 -45
- package/loaders/product-loader.js.map +2 -2
- package/loaders/rebuy-recommendations-loader.d.ts +8 -157
- package/loaders/rebuy-recommendations-loader.js +5 -50
- package/loaders/rebuy-recommendations-loader.js.map +2 -2
- package/loaders/reviews-io-review-aggregate-loader.d.ts +5 -4
- package/loaders/reviews-io-review-aggregate-loader.js +5 -36
- package/loaders/reviews-io-review-aggregate-loader.js.map +2 -2
- package/loaders/reviews-io-reviews-loader.d.ts +5 -4
- package/loaders/reviews-io-reviews-loader.js +5 -58
- package/loaders/reviews-io-reviews-loader.js.map +2 -2
- package/loaders/smile-earning-rules-loader.d.ts +10 -11
- package/loaders/smile-earning-rules-loader.js +5 -37
- package/loaders/smile-earning-rules-loader.js.map +2 -2
- package/loaders/smile-rewards-loader.d.ts +10 -11
- package/loaders/smile-rewards-loader.js +5 -37
- package/loaders/smile-rewards-loader.js.map +2 -2
- package/loaders/smile-vip-tiers-loader.d.ts +9 -10
- package/loaders/smile-vip-tiers-loader.js +5 -36
- package/loaders/smile-vip-tiers-loader.js.map +2 -2
- package/loaders/statsig-experiment-loader.d.ts +3 -8
- package/loaders/statsig-experiment-loader.js +5 -74
- package/loaders/statsig-experiment-loader.js.map +2 -2
- package/loaders/vendor-loader-keys.d.ts +4 -0
- package/loaders/vendor-loader-keys.js +9 -0
- package/loaders/vendor-loader-keys.js.map +7 -0
- package/loaders/yotpo-review-aggregate-loader.d.ts +5 -4
- package/loaders/yotpo-review-aggregate-loader.js +5 -43
- package/loaders/yotpo-review-aggregate-loader.js.map +2 -2
- package/loaders/yotpo-reviews-loader.d.ts +5 -4
- package/loaders/yotpo-reviews-loader.js +5 -58
- package/loaders/yotpo-reviews-loader.js.map +2 -2
- package/money.d.ts +9 -9
- package/money.js +25 -6
- package/money.js.map +2 -2
- package/next/config.d.ts +3 -1
- package/next/config.js +11 -85
- package/next/config.js.map +2 -2
- package/next/image-loader.d.ts +2 -1
- package/next/image-loader.js +7 -47
- package/next/image-loader.js.map +2 -2
- package/next/open-next.d.ts +4 -2
- package/next/open-next.js +6 -19
- package/next/open-next.js.map +2 -2
- package/orders/order-status-schema.d.ts +28 -13
- package/orders/order-status-schema.js +45 -13
- package/orders/order-status-schema.js.map +2 -2
- package/orders/order-status.d.ts +2 -8
- package/orders/order-status.js +6 -36
- package/orders/order-status.js.map +2 -2
- package/package.json +2 -13
- package/providers/query-provider.d.ts +3 -1
- package/providers/query-provider.js +10 -6
- package/providers/query-provider.js.map +2 -2
- package/providers/replo-provider.d.ts +3 -1
- package/providers/replo-provider.js +6 -37
- package/providers/replo-provider.js.map +2 -2
- package/routing/evaluate.d.ts +3 -3
- package/routing/evaluate.js +5 -40
- package/routing/evaluate.js.map +2 -2
- package/routing/rules.d.ts +3 -11
- package/routing/rules.js +7 -1
- package/routing/rules.js.map +2 -2
|
@@ -1,131 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
body: `window.dataLayer = window.dataLayer || [];
|
|
12
|
-
function gtag(){dataLayer.push(arguments);}
|
|
13
|
-
gtag('js', new Date());
|
|
14
|
-
gtag('config', '${id}');`
|
|
15
|
-
}
|
|
16
|
-
]
|
|
17
|
-
},
|
|
18
|
-
GoogleTagManager: {
|
|
19
|
-
defaultConsent: ["analytics", "marketing"],
|
|
20
|
-
buildTags: (id) => [
|
|
21
|
-
{
|
|
22
|
-
kind: "inline",
|
|
23
|
-
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}');`
|
|
24
|
-
}
|
|
25
|
-
]
|
|
26
|
-
},
|
|
27
|
-
Meta: {
|
|
28
|
-
defaultConsent: ["marketing"],
|
|
29
|
-
buildTags: (id) => [
|
|
30
|
-
{
|
|
31
|
-
kind: "inline",
|
|
32
|
-
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');`
|
|
33
|
-
}
|
|
34
|
-
]
|
|
35
|
-
},
|
|
36
|
-
TikTok: {
|
|
37
|
-
defaultConsent: ["marketing"],
|
|
38
|
-
buildTags: (id) => [
|
|
39
|
-
{
|
|
40
|
-
kind: "inline",
|
|
41
|
-
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');`
|
|
42
|
-
}
|
|
43
|
-
]
|
|
44
|
-
},
|
|
45
|
-
Pinterest: {
|
|
46
|
-
defaultConsent: ["marketing"],
|
|
47
|
-
buildTags: (id) => [
|
|
48
|
-
{
|
|
49
|
-
kind: "inline",
|
|
50
|
-
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');`
|
|
51
|
-
}
|
|
52
|
-
]
|
|
53
|
-
},
|
|
54
|
-
Reddit: {
|
|
55
|
-
defaultConsent: ["marketing"],
|
|
56
|
-
buildTags: (id) => [
|
|
57
|
-
{
|
|
58
|
-
kind: "inline",
|
|
59
|
-
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');`
|
|
60
|
-
}
|
|
61
|
-
]
|
|
62
|
-
},
|
|
63
|
-
Snapchat: {
|
|
64
|
-
defaultConsent: ["marketing"],
|
|
65
|
-
buildTags: (id) => [
|
|
66
|
-
{
|
|
67
|
-
kind: "inline",
|
|
68
|
-
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');`
|
|
69
|
-
}
|
|
70
|
-
]
|
|
71
|
-
},
|
|
72
|
-
Hotjar: {
|
|
73
|
-
defaultConsent: ["analytics"],
|
|
74
|
-
buildTags: (id) => [
|
|
75
|
-
{
|
|
76
|
-
kind: "inline",
|
|
77
|
-
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=');`
|
|
78
|
-
}
|
|
79
|
-
]
|
|
80
|
-
},
|
|
81
|
-
MicrosoftClarity: {
|
|
82
|
-
defaultConsent: ["analytics"],
|
|
83
|
-
buildTags: (id) => [
|
|
84
|
-
{
|
|
85
|
-
kind: "inline",
|
|
86
|
-
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}");`
|
|
87
|
-
}
|
|
88
|
-
]
|
|
89
|
-
},
|
|
90
|
-
Contentsquare: {
|
|
91
|
-
defaultConsent: ["analytics"],
|
|
92
|
-
// The UXA tag is a single async external script keyed by the 13-char tag id;
|
|
93
|
-
// it bootstraps the Contentsquare `_uxa` queue itself once loaded.
|
|
94
|
-
buildTags: (id) => [
|
|
95
|
-
{
|
|
96
|
-
kind: "external",
|
|
97
|
-
src: `https://t.contentsquare.net/uxa/${id}.js`,
|
|
98
|
-
attributes: { async: "true" }
|
|
99
|
-
}
|
|
100
|
-
]
|
|
101
|
-
},
|
|
102
|
-
Segment: {
|
|
103
|
-
defaultConsent: ["analytics", "marketing"],
|
|
104
|
-
buildTags: (id) => [
|
|
105
|
-
{
|
|
106
|
-
kind: "inline",
|
|
107
|
-
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();}}();`
|
|
108
|
-
}
|
|
109
|
-
]
|
|
110
|
-
},
|
|
111
|
-
Northbeam: {
|
|
112
|
-
defaultConsent: ["analytics", "marketing"],
|
|
113
|
-
buildTags: (id) => [
|
|
114
|
-
{
|
|
115
|
-
kind: "inline",
|
|
116
|
-
body: `(function(){var t;(n=t=t||{}).A="identify",n.B="trackPageView",n.C="fireEmailCaptureEvent",n.D="fireCustomGoal",n.E="firePurchaseEvent",n.F="trackPageViewInitial",n.G="fireSlimPurchaseEvent",n.H="identifyCustomerId";var n="https://j.northbeam.io/ota-sp/${id}.js";function r(n){for(var e=[],t=1;t<arguments.length;t++)e[t-1]=arguments[t];i.push({fnName:n,args:e})}var e,i=[],a=((e={})[t.F]=function(n){r(t.F,n)},(a={_q:i})[t.A]=function(n,e){return r(t.A,n,e)},a[t.B]=function(){return r(t.B)},a[t.C]=function(n,e){return r(t.C,n,e)},a[t.D]=function(n,e){return r(t.D,n,e)},a[t.E]=function(n){return r(t.E,n)},a[t.G]=function(n){return r(t.G,n)},a[t.H]=function(n,e){return r(t.H,n,e)},Object.assign(function(n){for(var e=[],t=1;t<arguments.length;t++)e.push(arguments[t]);return r.apply(null,[n].concat(e))},a));window.Northbeam=a,(a=document.createElement("script")).async=!0,a.src=n,document.head.appendChild(a),e.trackPageViewInitial(window.location.href);})()`
|
|
117
|
-
}
|
|
118
|
-
]
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
function buildScriptTags({
|
|
122
|
-
type,
|
|
123
|
-
identifier
|
|
124
|
-
}) {
|
|
125
|
-
return PROVIDER_SNIPPETS[type].buildTags(identifier);
|
|
1
|
+
import { canopyTombstoneError } from "../lib/tombstone";
|
|
2
|
+
function buildScriptTags(_args) {
|
|
3
|
+
throw canopyTombstoneError({
|
|
4
|
+
symbol: "buildScriptTags",
|
|
5
|
+
subpath: "consent/script-snippets",
|
|
6
|
+
replacement: {
|
|
7
|
+
kind: "internal",
|
|
8
|
+
nearestPublicSubpaths: ["consent/consent-store", "consent/replo-scripts"]
|
|
9
|
+
}
|
|
10
|
+
});
|
|
126
11
|
}
|
|
127
|
-
function defaultConsentFor(
|
|
128
|
-
|
|
12
|
+
function defaultConsentFor(_type) {
|
|
13
|
+
throw canopyTombstoneError({
|
|
14
|
+
symbol: "defaultConsentFor",
|
|
15
|
+
subpath: "consent/script-snippets",
|
|
16
|
+
replacement: {
|
|
17
|
+
kind: "internal",
|
|
18
|
+
nearestPublicSubpaths: ["consent/consent-store", "consent/replo-scripts"]
|
|
19
|
+
}
|
|
20
|
+
});
|
|
129
21
|
}
|
|
130
22
|
export {
|
|
131
23
|
buildScriptTags,
|
|
@@ -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\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 Contentsquare: {\n defaultConsent: [\"analytics\"],\n // The UXA tag is a single async external script keyed by the 13-char tag id;\n // it bootstraps the Contentsquare `_uxa` queue itself once loaded.\n buildTags: (id) => [\n {\n kind: \"external\",\n src: `https://t.contentsquare.net/uxa/${id}.js`,\n attributes: { async: \"true\" },\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 Northbeam: {\n defaultConsent: [\"analytics\", \"marketing\"],\n buildTags: (id) => [\n {\n kind: \"inline\",\n body: `(function(){var t;(n=t=t||{}).A=\"identify\",n.B=\"trackPageView\",n.C=\"fireEmailCaptureEvent\",n.D=\"fireCustomGoal\",n.E=\"firePurchaseEvent\",n.F=\"trackPageViewInitial\",n.G=\"fireSlimPurchaseEvent\",n.H=\"identifyCustomerId\";var n=\"https://j.northbeam.io/ota-sp/${id}.js\";function r(n){for(var e=[],t=1;t<arguments.length;t++)e[t-1]=arguments[t];i.push({fnName:n,args:e})}var e,i=[],a=((e={})[t.F]=function(n){r(t.F,n)},(a={_q:i})[t.A]=function(n,e){return r(t.A,n,e)},a[t.B]=function(){return r(t.B)},a[t.C]=function(n,e){return r(t.C,n,e)},a[t.D]=function(n,e){return r(t.D,n,e)},a[t.E]=function(n){return r(t.E,n)},a[t.G]=function(n){return r(t.G,n)},a[t.H]=function(n,e){return r(t.H,n,e)},Object.assign(function(n){for(var e=[],t=1;t<arguments.length;t++)e.push(arguments[t]);return r.apply(null,[n].concat(e))},a));window.Northbeam=a,(a=document.createElement(\"script\")).async=!0,a.src=n,document.head.appendChild(a),e.trackPageViewInitial(window.location.href);})()`,\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": "
|
|
4
|
+
"sourcesContent": ["import type {\n ConsentCategory,\n ReploScriptType,\n ScriptTagDescriptor,\n} from \"schemas/generated/consent\";\n\nimport { canopyTombstoneError } from \"../lib/tombstone\";\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/** @deprecated Use a supported public @replohq/sdk API for this domain; buildScriptTags has no direct replacement. */\nexport function buildScriptTags(_args: {\n type: ProviderType;\n identifier: string;\n}): ScriptTagDescriptor[] {\n throw canopyTombstoneError({\n symbol: \"buildScriptTags\",\n subpath: \"consent/script-snippets\",\n replacement: {\n kind: \"internal\",\n nearestPublicSubpaths: [\"consent/consent-store\", \"consent/replo-scripts\"],\n },\n });\n}\n\n/** @deprecated Use a supported public @replohq/sdk API for this domain; defaultConsentFor has no direct replacement. */\nexport function defaultConsentFor(_type: ProviderType): ConsentCategory[] {\n throw canopyTombstoneError({\n symbol: \"defaultConsentFor\",\n subpath: \"consent/script-snippets\",\n replacement: {\n kind: \"internal\",\n nearestPublicSubpaths: [\"consent/consent-store\", \"consent/replo-scripts\"],\n },\n });\n}\n"],
|
|
5
|
+
"mappings": "AAMA,SAAS,4BAA4B;AAO9B,SAAS,gBAAgB,OAGN;AACxB,QAAM,qBAAqB;AAAA,IACzB,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,aAAa;AAAA,MACX,MAAM;AAAA,MACN,uBAAuB,CAAC,yBAAyB,uBAAuB;AAAA,IAC1E;AAAA,EACF,CAAC;AACH;AAGO,SAAS,kBAAkB,OAAwC;AACxE,QAAM,qBAAqB;AAAA,IACzB,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,aAAa;AAAA,MACX,MAAM;AAAA,MACN,uBAAuB,CAAC,yBAAyB,uBAAuB;AAAA,IAC1E;AAAA,EACF,CAAC;AACH;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/consent/window-api.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { ConsentCategory } from "../_vendor/schemas/generated/consent";
|
|
2
|
+
/** Shopify-style tri-state: declared-allowed, declared-denied, or undeclared. */
|
|
3
|
+
type ConsentSignal = "yes" | "no" | "";
|
|
2
4
|
/**
|
|
3
5
|
* Global, framework-agnostic consent API exposed on `window.Replo.customerPrivacy`,
|
|
4
6
|
* mirroring Shopify's Customer Privacy API surface so on-page (third-party)
|
|
@@ -9,8 +11,6 @@ import type { ConsentCategory } from "../_vendor/schemas/generated/consent";
|
|
|
9
11
|
* sites.
|
|
10
12
|
*/
|
|
11
13
|
type ToggleableCategory = Exclude<ConsentCategory, "necessary">;
|
|
12
|
-
/** Shopify-style tri-state: declared-allowed, declared-denied, or undeclared. */
|
|
13
|
-
type ConsentSignal = "yes" | "no" | "";
|
|
14
14
|
export interface ReploCustomerPrivacyApi {
|
|
15
15
|
/** Per-category declaration, or "" when the visitor has not decided. */
|
|
16
16
|
currentVisitorConsent(): Record<ToggleableCategory, ConsentSignal>;
|
|
@@ -23,19 +23,8 @@ export interface ReploCustomerPrivacyApi {
|
|
|
23
23
|
/** Update a subset of categories; runs the optional callback once persisted. */
|
|
24
24
|
setTrackingConsent(consent: Partial<Record<ToggleableCategory, boolean>>, callback?: () => void): void;
|
|
25
25
|
}
|
|
26
|
-
|
|
27
|
-
interface Window {
|
|
28
|
-
Replo?: {
|
|
29
|
-
customerPrivacy?: ReploCustomerPrivacyApi;
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
/** DOM event dispatched on `document` whenever consent changes. */
|
|
26
|
+
/** @deprecated Use a supported public @replohq/sdk API for this domain; CONSENT_CHANGE_EVENT remains only for primitive compatibility. */
|
|
34
27
|
export declare const CONSENT_CHANGE_EVENT = "visitorConsentCollected";
|
|
35
|
-
/**
|
|
36
|
-
* Installs `window.Replo.customerPrivacy` and dispatches `visitorConsentCollected`
|
|
37
|
-
* on `document` whenever consent changes. Idempotent; returns a teardown that
|
|
38
|
-
* removes the change subscription. Safe to call on the server (no-op).
|
|
39
|
-
*/
|
|
28
|
+
/** @deprecated Use a supported public @replohq/sdk API for this domain; installConsentWindowApi has no direct replacement. */
|
|
40
29
|
export declare function installConsentWindowApi(): () => void;
|
|
41
30
|
export {};
|
package/consent/window-api.js
CHANGED
|
@@ -1,70 +1,15 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
2
|
+
import { canopyTombstoneError } from "../lib/tombstone";
|
|
3
3
|
const CONSENT_CHANGE_EVENT = "visitorConsentCollected";
|
|
4
|
-
function isAllowed(category) {
|
|
5
|
-
return isConsentAllowed({
|
|
6
|
-
state: consentStore.getSnapshot(),
|
|
7
|
-
requiredConsent: [category]
|
|
8
|
-
});
|
|
9
|
-
}
|
|
10
|
-
function currentVisitorConsent() {
|
|
11
|
-
const state = consentStore.getSnapshot();
|
|
12
|
-
const signal = (category) => {
|
|
13
|
-
if (state.decidedAt === null) {
|
|
14
|
-
return "";
|
|
15
|
-
}
|
|
16
|
-
return state.categories[category] ? "yes" : "no";
|
|
17
|
-
};
|
|
18
|
-
return {
|
|
19
|
-
analytics: signal("analytics"),
|
|
20
|
-
marketing: signal("marketing"),
|
|
21
|
-
preferences: signal("preferences"),
|
|
22
|
-
sale_of_data: signal("sale_of_data")
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
const api = {
|
|
26
|
-
currentVisitorConsent,
|
|
27
|
-
analyticsProcessingAllowed: () => isAllowed("analytics"),
|
|
28
|
-
marketingAllowed: () => isAllowed("marketing"),
|
|
29
|
-
preferencesProcessingAllowed: () => isAllowed("preferences"),
|
|
30
|
-
saleOfDataAllowed: () => isAllowed("sale_of_data"),
|
|
31
|
-
shouldShowBanner: () => {
|
|
32
|
-
const state = consentStore.getSnapshot();
|
|
33
|
-
return state.mode !== "off" && state.decidedAt === null;
|
|
34
|
-
},
|
|
35
|
-
setTrackingConsent: (consent, callback) => {
|
|
36
|
-
consentStore.updateCategories({ next: consent });
|
|
37
|
-
callback?.();
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
function consentChangeDetail() {
|
|
41
|
-
return {
|
|
42
|
-
analyticsAllowed: isAllowed("analytics"),
|
|
43
|
-
marketingAllowed: isAllowed("marketing"),
|
|
44
|
-
preferencesAllowed: isAllowed("preferences"),
|
|
45
|
-
saleOfDataAllowed: isAllowed("sale_of_data")
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
let teardown = null;
|
|
49
4
|
function installConsentWindowApi() {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
window.Replo = { ...window.Replo, customerPrivacy: api };
|
|
58
|
-
const unsubscribe = consentStore.subscribe(() => {
|
|
59
|
-
document.dispatchEvent(
|
|
60
|
-
new CustomEvent(CONSENT_CHANGE_EVENT, { detail: consentChangeDetail() })
|
|
61
|
-
);
|
|
5
|
+
throw canopyTombstoneError({
|
|
6
|
+
symbol: "installConsentWindowApi",
|
|
7
|
+
subpath: "consent/window-api",
|
|
8
|
+
replacement: {
|
|
9
|
+
kind: "internal",
|
|
10
|
+
nearestPublicSubpaths: ["consent/consent-store", "consent/replo-scripts"]
|
|
11
|
+
}
|
|
62
12
|
});
|
|
63
|
-
teardown = () => {
|
|
64
|
-
unsubscribe();
|
|
65
|
-
teardown = null;
|
|
66
|
-
};
|
|
67
|
-
return teardown;
|
|
68
13
|
}
|
|
69
14
|
export {
|
|
70
15
|
CONSENT_CHANGE_EVENT,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../consent/window-api.ts"],
|
|
4
|
-
"sourcesContent": ["\"use client\";\n\nimport type { ConsentCategory } from \"schemas/generated/consent\";\n\nimport {
|
|
5
|
-
"mappings": ";AAIA,SAAS,
|
|
4
|
+
"sourcesContent": ["\"use client\";\n\nimport type { ConsentCategory } from \"schemas/generated/consent\";\n\nimport { canopyTombstoneError } from \"../lib/tombstone\";\n\n/** Shopify-style tri-state: declared-allowed, declared-denied, or undeclared. */\ntype ConsentSignal = \"yes\" | \"no\" | \"\";\n\n/**\n * Global, framework-agnostic consent API exposed on `window.Replo.customerPrivacy`,\n * mirroring Shopify's Customer Privacy API surface so on-page (third-party)\n * scripts can query consent and react to changes without importing canopy.\n *\n * It deliberately lives under our own `window.Replo` namespace rather than\n * `window.Shopify` to avoid colliding with Shopify's real API on Shopify-backed\n * sites.\n */\ntype ToggleableCategory = Exclude<ConsentCategory, \"necessary\">;\n\nexport interface ReploCustomerPrivacyApi {\n /** Per-category declaration, or \"\" when the visitor has not decided. */\n currentVisitorConsent(): Record<ToggleableCategory, ConsentSignal>;\n analyticsProcessingAllowed(): boolean;\n marketingAllowed(): boolean;\n preferencesProcessingAllowed(): boolean;\n saleOfDataAllowed(): boolean;\n /** Whether the consent banner should still be shown (mode on + undecided). */\n shouldShowBanner(): boolean;\n /** Update a subset of categories; runs the optional callback once persisted. */\n setTrackingConsent(\n consent: Partial<Record<ToggleableCategory, boolean>>,\n callback?: () => void,\n ): void;\n}\n\n/** @deprecated Use a supported public @replohq/sdk API for this domain; CONSENT_CHANGE_EVENT remains only for primitive compatibility. */\nexport const CONSENT_CHANGE_EVENT = \"visitorConsentCollected\";\n\n/** @deprecated Use a supported public @replohq/sdk API for this domain; installConsentWindowApi has no direct replacement. */\nexport function installConsentWindowApi(): () => void {\n throw canopyTombstoneError({\n symbol: \"installConsentWindowApi\",\n subpath: \"consent/window-api\",\n replacement: {\n kind: \"internal\",\n nearestPublicSubpaths: [\"consent/consent-store\", \"consent/replo-scripts\"],\n },\n });\n}\n"],
|
|
5
|
+
"mappings": ";AAIA,SAAS,4BAA4B;AAiC9B,MAAM,uBAAuB;AAG7B,SAAS,0BAAsC;AACpD,QAAM,qBAAqB;AAAA,IACzB,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,aAAa;AAAA,MACX,MAAM;AAAA,MACN,uBAAuB,CAAC,yBAAyB,uBAAuB;AAAA,IAC1E;AAAA,EACF,CAAC;AACH;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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.
|
|
9
|
-
*/
|
|
10
|
-
export declare function ClientErrorBoundary({ children }: React.PropsWithChildren): import("react/jsx-runtime").JSX.Element;
|
|
1
|
+
import type { ReactElement } from "react";
|
|
2
|
+
import type * as React from "react";
|
|
3
|
+
/** @deprecated Mount SandboxRuntime from @replohq/sandbox-runtime instead. */
|
|
4
|
+
export declare function ClientErrorBoundary(_args: React.PropsWithChildren): ReactElement;
|
|
@@ -1,59 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
return { didCatch: true };
|
|
10
|
-
}
|
|
11
|
-
componentDidCatch(error, info) {
|
|
12
|
-
this.props.onError?.(error, info);
|
|
13
|
-
}
|
|
14
|
-
render() {
|
|
15
|
-
if (this.state.didCatch) {
|
|
16
|
-
return /* @__PURE__ */ jsx(
|
|
17
|
-
"div",
|
|
18
|
-
{
|
|
19
|
-
style: {
|
|
20
|
-
position: "fixed",
|
|
21
|
-
inset: 0,
|
|
22
|
-
zIndex: 2147483646,
|
|
23
|
-
background: "#ffffff"
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
return this.props.children;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
function ClientErrorBoundary({ children }) {
|
|
32
|
-
const handleError = React.useCallback(
|
|
33
|
-
(error, errorInfo) => {
|
|
34
|
-
const errorObj = error instanceof Error ? error : new Error(String(error));
|
|
35
|
-
window.parent.postMessage(
|
|
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).
|
|
41
|
-
type: "replo-editor:client-error",
|
|
42
|
-
payload: {
|
|
43
|
-
pageRoute: window.location.pathname,
|
|
44
|
-
error: {
|
|
45
|
-
message: errorObj.message,
|
|
46
|
-
stack: errorObj.stack,
|
|
47
|
-
componentStack: errorInfo.componentStack
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
"*"
|
|
52
|
-
);
|
|
53
|
-
},
|
|
54
|
-
[]
|
|
55
|
-
);
|
|
56
|
-
return /* @__PURE__ */ jsx(ErrorBoundary, { onError: handleError, children });
|
|
2
|
+
import { canopyTombstoneError } from "../lib/tombstone";
|
|
3
|
+
function ClientErrorBoundary(_args) {
|
|
4
|
+
throw canopyTombstoneError({
|
|
5
|
+
symbol: "ClientErrorBoundary",
|
|
6
|
+
subpath: "editor/ClientErrorBoundary",
|
|
7
|
+
replacement: { kind: "sandbox-runtime" }
|
|
8
|
+
});
|
|
57
9
|
}
|
|
58
10
|
export {
|
|
59
11
|
ClientErrorBoundary
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../editor/ClientErrorBoundary.tsx"],
|
|
4
|
-
"sourcesContent": ["\"use client\";\n\nimport
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["\"use client\";\n\nimport type { ReactElement } from \"react\";\nimport type * as React from \"react\";\n\nimport { canopyTombstoneError } from \"../lib/tombstone\";\n\n/** @deprecated Mount SandboxRuntime from @replohq/sandbox-runtime instead. */\nexport function ClientErrorBoundary(\n _args: React.PropsWithChildren,\n): ReactElement {\n throw canopyTombstoneError({\n symbol: \"ClientErrorBoundary\",\n subpath: \"editor/ClientErrorBoundary\",\n replacement: { kind: \"sandbox-runtime\" },\n });\n}\n"],
|
|
5
|
+
"mappings": ";AAKA,SAAS,4BAA4B;AAG9B,SAAS,oBACd,OACc;AACd,QAAM,qBAAqB;AAAA,IACzB,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,aAAa,EAAE,MAAM,kBAAkB;AAAA,EACzC,CAAC;AACH;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
import type { ReactElement } from "react";
|
|
2
|
+
/** @deprecated Mount SandboxRuntime from @replohq/sandbox-runtime instead. */
|
|
3
|
+
export declare function DocumentReadyBeacon(): ReactElement;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
const BEACON_SCRIPT = `if (window.parent !== window) { window.parent.postMessage({ type: "replo:preview:status", status: "ok", phase: "document", route: window.location.pathname }, "*"); }`;
|
|
1
|
+
import { canopyTombstoneError } from "../lib/tombstone";
|
|
3
2
|
function DocumentReadyBeacon() {
|
|
4
|
-
|
|
3
|
+
throw canopyTombstoneError({
|
|
4
|
+
symbol: "DocumentReadyBeacon",
|
|
5
|
+
subpath: "editor/DocumentReadyBeacon",
|
|
6
|
+
replacement: { kind: "sandbox-runtime" }
|
|
7
|
+
});
|
|
5
8
|
}
|
|
6
9
|
export {
|
|
7
10
|
DocumentReadyBeacon
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../editor/DocumentReadyBeacon.tsx"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import type { ReactElement } from \"react\";\n\nimport { canopyTombstoneError } from \"../lib/tombstone\";\n\n/** @deprecated Mount SandboxRuntime from @replohq/sandbox-runtime instead. */\nexport function DocumentReadyBeacon(): ReactElement {\n throw canopyTombstoneError({\n symbol: \"DocumentReadyBeacon\",\n subpath: \"editor/DocumentReadyBeacon\",\n replacement: { kind: \"sandbox-runtime\" },\n });\n}\n"],
|
|
5
|
+
"mappings": "AAEA,SAAS,4BAA4B;AAG9B,SAAS,sBAAoC;AAClD,QAAM,qBAAqB;AAAA,IACzB,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,aAAa,EAAE,MAAM,kBAAkB;AAAA,EACzC,CAAC;AACH;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,126 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import { displayModeStore } from "./select-mode/displayModeStore";
|
|
4
|
-
function blockNavigation(event) {
|
|
5
|
-
event.preventDefault();
|
|
6
|
-
event.stopPropagation();
|
|
7
|
-
event.stopImmediatePropagation();
|
|
8
|
-
}
|
|
9
|
-
function isNavigationLike(value) {
|
|
10
|
-
if (typeof value !== "object" || value === null) {
|
|
11
|
-
return false;
|
|
12
|
-
}
|
|
13
|
-
return typeof Reflect.get(value, "addEventListener") === "function" && typeof Reflect.get(value, "removeEventListener") === "function";
|
|
14
|
-
}
|
|
15
|
-
function getWindowNavigation() {
|
|
16
|
-
const navigation = Reflect.get(window, "navigation");
|
|
17
|
-
return isNavigationLike(navigation) ? navigation : null;
|
|
18
|
-
}
|
|
19
|
-
function shouldInterceptNavigationForAgentPreview() {
|
|
20
|
-
if (typeof window === "undefined") {
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
if (window.parent === window) {
|
|
24
|
-
return false;
|
|
25
|
-
}
|
|
26
|
-
return new URLSearchParams(window.location.search).get("__reploAgentPreview") === "1";
|
|
27
|
-
}
|
|
28
|
-
function urlLeavesSandbox(rawUrl) {
|
|
29
|
-
try {
|
|
30
|
-
const resolved = typeof rawUrl === "string" ? new URL(rawUrl, window.location.href) : new URL(rawUrl.href, window.location.href);
|
|
31
|
-
return resolved.origin !== window.location.origin;
|
|
32
|
-
} catch {
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
2
|
+
import { canopyTombstoneError } from "../lib/tombstone";
|
|
36
3
|
function LinkInterceptor() {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const originalPushState = history.pushState;
|
|
43
|
-
const originalReplaceState = history.replaceState;
|
|
44
|
-
const navigation = getWindowNavigation();
|
|
45
|
-
window.open = function(url, target, features) {
|
|
46
|
-
if (url !== void 0 && url !== "" && urlLeavesSandbox(url) === true) {
|
|
47
|
-
return null;
|
|
48
|
-
}
|
|
49
|
-
return originalWindowOpen.call(window, url, target, features);
|
|
50
|
-
};
|
|
51
|
-
history.pushState = function(state, unused, url) {
|
|
52
|
-
if (url && urlLeavesSandbox(url) === true) {
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
return originalPushState.call(history, state, unused, url);
|
|
56
|
-
};
|
|
57
|
-
history.replaceState = function(state, unused, url) {
|
|
58
|
-
if (url && urlLeavesSandbox(url) === true) {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
return originalReplaceState.call(history, state, unused, url);
|
|
62
|
-
};
|
|
63
|
-
const handleNavigate = (event) => {
|
|
64
|
-
const destinationUrl = event.destination?.url;
|
|
65
|
-
if (destinationUrl === void 0 || destinationUrl === "" || urlLeavesSandbox(destinationUrl) !== true) {
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
event.preventDefault?.();
|
|
69
|
-
};
|
|
70
|
-
const handleClick = (event) => {
|
|
71
|
-
if (displayModeStore.getSnapshot() === "selection") {
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
const target = event.target;
|
|
75
|
-
if (!(target instanceof Element)) {
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
const link = target.closest("a[href]");
|
|
79
|
-
if (!(link instanceof HTMLAnchorElement)) {
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
const href = link.getAttribute("href");
|
|
83
|
-
if (!href) {
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
if (href.startsWith("#")) {
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
const linkTarget = link.getAttribute("target");
|
|
90
|
-
if (linkTarget && linkTarget !== "_self") {
|
|
91
|
-
blockNavigation(event);
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
if (urlLeavesSandbox(href) === true) {
|
|
95
|
-
blockNavigation(event);
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
event.preventDefault();
|
|
99
|
-
let route;
|
|
100
|
-
try {
|
|
101
|
-
route = new URL(href, window.location.href).pathname;
|
|
102
|
-
} catch {
|
|
103
|
-
route = href;
|
|
104
|
-
}
|
|
105
|
-
window.parent.postMessage(
|
|
106
|
-
{
|
|
107
|
-
type: "replo:navigate",
|
|
108
|
-
route
|
|
109
|
-
},
|
|
110
|
-
"*"
|
|
111
|
-
);
|
|
112
|
-
};
|
|
113
|
-
navigation?.addEventListener("navigate", handleNavigate);
|
|
114
|
-
document.addEventListener("click", handleClick, true);
|
|
115
|
-
return () => {
|
|
116
|
-
window.open = originalWindowOpen;
|
|
117
|
-
history.pushState = originalPushState;
|
|
118
|
-
history.replaceState = originalReplaceState;
|
|
119
|
-
navigation?.removeEventListener("navigate", handleNavigate);
|
|
120
|
-
document.removeEventListener("click", handleClick, true);
|
|
121
|
-
};
|
|
122
|
-
}, []);
|
|
123
|
-
return null;
|
|
4
|
+
throw canopyTombstoneError({
|
|
5
|
+
symbol: "LinkInterceptor",
|
|
6
|
+
subpath: "editor/LinkInterceptor",
|
|
7
|
+
replacement: { kind: "sandbox-runtime" }
|
|
8
|
+
});
|
|
124
9
|
}
|
|
125
10
|
export {
|
|
126
11
|
LinkInterceptor as default
|