@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,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../editor/LinkInterceptor.tsx"],
|
|
4
|
-
"sourcesContent": ["\"use client\";\n\nimport {
|
|
5
|
-
"mappings": ";AAEA,SAAS,
|
|
4
|
+
"sourcesContent": ["\"use client\";\n\nimport { canopyTombstoneError } from \"../lib/tombstone\";\n\n/** @deprecated Mount SandboxRuntime from @replohq/sandbox-runtime instead. */\nexport default function LinkInterceptor(): null {\n throw canopyTombstoneError({\n symbol: \"LinkInterceptor\",\n subpath: \"editor/LinkInterceptor\",\n replacement: { kind: \"sandbox-runtime\" },\n });\n}\n"],
|
|
5
|
+
"mappings": ";AAEA,SAAS,4BAA4B;AAGtB,SAAR,kBAAyC;AAC9C,QAAM,qBAAqB;AAAA,IACzB,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,aAAa,EAAE,MAAM,kBAAkB;AAAA,EACzC,CAAC;AACH;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,90 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import
|
|
3
|
-
const RED_CHROME_SELECTOR = '[data-next-badge][data-error="true"], [data-nextjs-dialog]';
|
|
4
|
-
const BLOCKING_ERROR_SELECTOR = "[data-nextjs-dialog]";
|
|
5
|
-
const STATUS_LATCH_MS = 500;
|
|
2
|
+
import { canopyTombstoneError } from "../lib/tombstone";
|
|
6
3
|
function NextErrorReporter() {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const postNow = (status) => {
|
|
13
|
-
if (status === lastStatus) {
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
lastStatus = status;
|
|
17
|
-
window.parent.postMessage(
|
|
18
|
-
{
|
|
19
|
-
type: "replo:preview:status",
|
|
20
|
-
status,
|
|
21
|
-
route: window.location.pathname
|
|
22
|
-
},
|
|
23
|
-
"*"
|
|
24
|
-
);
|
|
25
|
-
};
|
|
26
|
-
const post = (status) => {
|
|
27
|
-
if (pendingPost) {
|
|
28
|
-
if (pendingPost.status === status) {
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
window.clearTimeout(pendingPost.timeoutId);
|
|
32
|
-
pendingPost = null;
|
|
33
|
-
}
|
|
34
|
-
if (status === lastStatus) {
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
if (lastStatus === null && status === "ok") {
|
|
38
|
-
postNow("ok");
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
const timeoutId = window.setTimeout(() => {
|
|
42
|
-
pendingPost = null;
|
|
43
|
-
postNow(status);
|
|
44
|
-
}, STATUS_LATCH_MS);
|
|
45
|
-
pendingPost = { status, timeoutId };
|
|
46
|
-
};
|
|
47
|
-
const syncOverlayState = () => {
|
|
48
|
-
const portal = document.getElementsByTagName("nextjs-portal")[0];
|
|
49
|
-
if (!(portal instanceof HTMLElement)) {
|
|
50
|
-
post("ok");
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
const root = portal.shadowRoot;
|
|
54
|
-
if (root && root !== observedRoot) {
|
|
55
|
-
shadowObserver?.disconnect();
|
|
56
|
-
shadowObserver = new MutationObserver(syncOverlayState);
|
|
57
|
-
shadowObserver.observe(root, {
|
|
58
|
-
childList: true,
|
|
59
|
-
subtree: true,
|
|
60
|
-
attributes: true,
|
|
61
|
-
attributeFilter: ["data-error"]
|
|
62
|
-
});
|
|
63
|
-
observedRoot = root;
|
|
64
|
-
}
|
|
65
|
-
portal.style.display = portal.shadowRoot?.querySelector(
|
|
66
|
-
RED_CHROME_SELECTOR
|
|
67
|
-
) ? "none" : "";
|
|
68
|
-
const hasBlockingError = Boolean(
|
|
69
|
-
portal.shadowRoot?.querySelector(BLOCKING_ERROR_SELECTOR)
|
|
70
|
-
);
|
|
71
|
-
post(hasBlockingError ? "error" : "ok");
|
|
72
|
-
};
|
|
73
|
-
const lightObserver = new MutationObserver(syncOverlayState);
|
|
74
|
-
lightObserver.observe(document.documentElement, {
|
|
75
|
-
childList: true,
|
|
76
|
-
subtree: true
|
|
77
|
-
});
|
|
78
|
-
syncOverlayState();
|
|
79
|
-
return () => {
|
|
80
|
-
lightObserver.disconnect();
|
|
81
|
-
shadowObserver?.disconnect();
|
|
82
|
-
if (pendingPost) {
|
|
83
|
-
window.clearTimeout(pendingPost.timeoutId);
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
}, []);
|
|
87
|
-
return null;
|
|
4
|
+
throw canopyTombstoneError({
|
|
5
|
+
symbol: "NextErrorReporter",
|
|
6
|
+
subpath: "editor/NextErrorReporter",
|
|
7
|
+
replacement: { kind: "sandbox-runtime" }
|
|
8
|
+
});
|
|
88
9
|
}
|
|
89
10
|
export {
|
|
90
11
|
NextErrorReporter
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../editor/NextErrorReporter.tsx"],
|
|
4
|
-
"sourcesContent": ["\"use client\";\n\nimport
|
|
5
|
-
"mappings": ";AAEA,
|
|
4
|
+
"sourcesContent": ["\"use client\";\n\nimport { canopyTombstoneError } from \"../lib/tombstone\";\n\n/** @deprecated Mount SandboxRuntime from @replohq/sandbox-runtime instead. */\nexport function NextErrorReporter(): null {\n throw canopyTombstoneError({\n symbol: \"NextErrorReporter\",\n subpath: \"editor/NextErrorReporter\",\n replacement: { kind: \"sandbox-runtime\" },\n });\n}\n"],
|
|
5
|
+
"mappings": ";AAEA,SAAS,4BAA4B;AAG9B,SAAS,oBAA0B;AACxC,QAAM,qBAAqB;AAAA,IACzB,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,aAAa,EAAE,MAAM,kBAAkB;AAAA,EACzC,CAAC;AACH;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
3
|
-
void import("./annotationController").then((module) => {
|
|
4
|
-
module.initAnnotationLayer();
|
|
5
|
-
});
|
|
6
|
-
}
|
|
2
|
+
import { canopyTombstoneError } from "../../lib/tombstone";
|
|
7
3
|
function AnnotationLayerMount() {
|
|
8
|
-
|
|
4
|
+
throw canopyTombstoneError({
|
|
5
|
+
symbol: "AnnotationLayerMount",
|
|
6
|
+
subpath: "editor/annotations/AnnotationLayerMount",
|
|
7
|
+
replacement: { kind: "sandbox-runtime" }
|
|
8
|
+
});
|
|
9
9
|
}
|
|
10
10
|
export {
|
|
11
11
|
AnnotationLayerMount
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../editor/annotations/AnnotationLayerMount.tsx"],
|
|
4
|
-
"sourcesContent": ["\"use client\";\n\
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["\"use client\";\n\nimport { canopyTombstoneError } from \"../../lib/tombstone\";\n\n/** @deprecated Mount SandboxRuntime from @replohq/sandbox-runtime instead. */\nexport function AnnotationLayerMount(): null {\n throw canopyTombstoneError({\n symbol: \"AnnotationLayerMount\",\n subpath: \"editor/annotations/AnnotationLayerMount\",\n replacement: { kind: \"sandbox-runtime\" },\n });\n}\n"],
|
|
5
|
+
"mappings": ";AAEA,SAAS,4BAA4B;AAG9B,SAAS,uBAA6B;AAC3C,QAAM,qBAAqB;AAAA,IACzB,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,aAAa,EAAE,MAAM,kBAAkB;AAAA,EACzC,CAAC;AACH;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,382 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
PAGE_ANNOTATIONS_PROTOCOL_VERSION,
|
|
4
|
-
pageAnnotationsParentMessageSchema
|
|
5
|
-
} from "../../_vendor/schemas/pageAnnotations.mjs";
|
|
6
|
-
import {
|
|
7
|
-
ANNOTATION_CONTAINER_ID,
|
|
8
|
-
clearAnnotationFrames,
|
|
9
|
-
getAnnotationBadgeViewportRect,
|
|
10
|
-
setActiveAnnotationBadge,
|
|
11
|
-
showAnnotationFrames
|
|
12
|
-
} from "../select-mode/annotationFrames";
|
|
13
|
-
import { getDocumentScrollOffset } from "../select-mode/interactions/selectionGeometry";
|
|
14
|
-
import { isAllowedEditorMessage, isAllowedEditorOrigin } from "./bridgeGate";
|
|
15
|
-
const CLUSTER_DISTANCE_PX = 24;
|
|
16
|
-
const CLUSTER_FAN_RADIUS_PX = 30;
|
|
17
|
-
const REMEASURE_DEBOUNCE_MS = 250;
|
|
18
|
-
const PAGE_TOP_STACK_X_PX = 20;
|
|
19
|
-
const PAGE_TOP_STACK_Y_PX = 20;
|
|
20
|
-
const PAGE_TOP_STACK_GAP_PX = 36;
|
|
21
|
-
const COLOR_HEX = {
|
|
22
|
-
red: "#ef196e",
|
|
23
|
-
purple: "#8b32a8",
|
|
24
|
-
amber: "#274ae2"
|
|
25
|
-
};
|
|
26
|
-
const COLOR_SEVERITY = [
|
|
27
|
-
"red",
|
|
28
|
-
"purple",
|
|
29
|
-
"amber"
|
|
30
|
-
];
|
|
31
|
-
let isInitialized = false;
|
|
32
|
-
let editorOrigin = null;
|
|
33
|
-
let markers = [];
|
|
34
|
-
let setId = null;
|
|
35
|
-
let expandedClusterId = null;
|
|
36
|
-
let activeMarkerId = null;
|
|
37
|
-
let remeasureFrameId = null;
|
|
38
|
-
let remeasureDebounceId = null;
|
|
39
|
-
let activeRectFrameId = null;
|
|
40
|
-
let observersActive = false;
|
|
41
|
-
let lastRenderSignature = null;
|
|
42
|
-
let resizeObserver = null;
|
|
43
|
-
let mutationObserver = null;
|
|
44
|
-
function postToEditor(message) {
|
|
45
|
-
if (editorOrigin === null) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
window.parent.postMessage(message, editorOrigin);
|
|
49
|
-
}
|
|
50
|
-
function hasFixedAncestor(element) {
|
|
51
|
-
let current = element;
|
|
52
|
-
while (current !== null && current !== document.documentElement) {
|
|
53
|
-
const position = getComputedStyle(current).position;
|
|
54
|
-
if (position === "fixed" || position === "sticky") {
|
|
55
|
-
return true;
|
|
56
|
-
}
|
|
57
|
-
current = current.parentElement;
|
|
58
|
-
}
|
|
59
|
-
return false;
|
|
60
|
-
}
|
|
61
|
-
function resolveMarkers() {
|
|
62
|
-
const resolved = [];
|
|
63
|
-
const unresolvedIds = [];
|
|
64
|
-
let pageTopSlot = 0;
|
|
65
|
-
for (const marker of markers) {
|
|
66
|
-
if (marker.placement === "pageTop") {
|
|
67
|
-
resolved.push({
|
|
68
|
-
marker,
|
|
69
|
-
element: null,
|
|
70
|
-
isFixed: false,
|
|
71
|
-
rect: {
|
|
72
|
-
x: PAGE_TOP_STACK_X_PX + pageTopSlot * PAGE_TOP_STACK_GAP_PX,
|
|
73
|
-
y: PAGE_TOP_STACK_Y_PX,
|
|
74
|
-
width: 0,
|
|
75
|
-
height: 0
|
|
76
|
-
},
|
|
77
|
-
// The editor owns numbering; rendering the wire number keeps dots in sync with the panel.
|
|
78
|
-
displayNumber: marker.number
|
|
79
|
-
});
|
|
80
|
-
pageTopSlot += 1;
|
|
81
|
-
continue;
|
|
82
|
-
}
|
|
83
|
-
let element = null;
|
|
84
|
-
try {
|
|
85
|
-
element = document.querySelector(marker.selector);
|
|
86
|
-
} catch {
|
|
87
|
-
}
|
|
88
|
-
const domRect = element?.getBoundingClientRect();
|
|
89
|
-
if (!element || !domRect || domRect.width === 0 && domRect.height === 0) {
|
|
90
|
-
unresolvedIds.push(marker.id);
|
|
91
|
-
continue;
|
|
92
|
-
}
|
|
93
|
-
const isFixed = hasFixedAncestor(element);
|
|
94
|
-
const scrollOffset = getDocumentScrollOffset();
|
|
95
|
-
resolved.push({
|
|
96
|
-
marker,
|
|
97
|
-
element,
|
|
98
|
-
isFixed,
|
|
99
|
-
// Fixed frames use viewport coords; absolute frames use page coords.
|
|
100
|
-
rect: {
|
|
101
|
-
x: domRect.x + (isFixed ? 0 : scrollOffset.left),
|
|
102
|
-
y: domRect.y + (isFixed ? 0 : scrollOffset.top),
|
|
103
|
-
width: domRect.width,
|
|
104
|
-
height: domRect.height
|
|
105
|
-
},
|
|
106
|
-
displayNumber: marker.number
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
return { resolved, unresolvedIds };
|
|
110
|
-
}
|
|
111
|
-
function clusterResolvedMarkers(resolved) {
|
|
112
|
-
const clusters = [];
|
|
113
|
-
for (const entry of resolved) {
|
|
114
|
-
const centerX = entry.rect.x + entry.rect.width / 2;
|
|
115
|
-
const centerY = entry.rect.y;
|
|
116
|
-
const host = clusters.find((cluster) => {
|
|
117
|
-
return cluster.isFixed === entry.isFixed && Math.hypot(cluster.centerX - centerX, cluster.centerY - centerY) < CLUSTER_DISTANCE_PX;
|
|
118
|
-
});
|
|
119
|
-
if (host) {
|
|
120
|
-
host.members.push(entry);
|
|
121
|
-
} else {
|
|
122
|
-
clusters.push({
|
|
123
|
-
id: entry.marker.id,
|
|
124
|
-
centerX,
|
|
125
|
-
centerY,
|
|
126
|
-
isFixed: entry.isFixed,
|
|
127
|
-
members: [entry]
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
return clusters;
|
|
132
|
-
}
|
|
133
|
-
function getMostSevereColorHex(members) {
|
|
134
|
-
const color = COLOR_SEVERITY.find((candidate) => {
|
|
135
|
-
return members.some((member) => member.marker.color === candidate);
|
|
136
|
-
}) ?? "amber";
|
|
137
|
-
return COLOR_HEX[color];
|
|
138
|
-
}
|
|
139
|
-
function activateMarker(id) {
|
|
140
|
-
activeMarkerId = id;
|
|
141
|
-
const viewportRect = getAnnotationBadgeViewportRect(id);
|
|
142
|
-
if (viewportRect) {
|
|
143
|
-
postToEditor({ type: "replo:annotations:clicked", id, viewportRect });
|
|
144
|
-
}
|
|
145
|
-
setActiveAnnotationBadge(id);
|
|
146
|
-
}
|
|
147
|
-
function buildMemberSpec({
|
|
148
|
-
member,
|
|
149
|
-
badgeCenter
|
|
150
|
-
}) {
|
|
151
|
-
const marker = member.marker;
|
|
152
|
-
return {
|
|
153
|
-
id: marker.id,
|
|
154
|
-
pageRect: member.rect,
|
|
155
|
-
badgeCenter,
|
|
156
|
-
positioning: member.isFixed ? "fixed" : "absolute",
|
|
157
|
-
colorHex: COLOR_HEX[marker.color],
|
|
158
|
-
badgeLabel: String(member.displayNumber),
|
|
159
|
-
badgeAriaLabel: `Page issue ${member.displayNumber}`,
|
|
160
|
-
isActive: activeMarkerId === marker.id,
|
|
161
|
-
onBadgeClick: () => activateMarker(marker.id)
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
function buildClusterSpecs(cluster) {
|
|
165
|
-
const [only] = cluster.members;
|
|
166
|
-
if (cluster.members.length === 1 && only) {
|
|
167
|
-
return [
|
|
168
|
-
buildMemberSpec({
|
|
169
|
-
member: only,
|
|
170
|
-
badgeCenter: { x: cluster.centerX, y: cluster.centerY }
|
|
171
|
-
})
|
|
172
|
-
];
|
|
173
|
-
}
|
|
174
|
-
const hub = {
|
|
175
|
-
x: cluster.centerX,
|
|
176
|
-
y: cluster.centerY,
|
|
177
|
-
width: 0,
|
|
178
|
-
height: 0
|
|
179
|
-
};
|
|
180
|
-
if (expandedClusterId !== cluster.id) {
|
|
181
|
-
return [
|
|
182
|
-
{
|
|
183
|
-
id: `cluster:${cluster.id}`,
|
|
184
|
-
pageRect: hub,
|
|
185
|
-
badgeCenter: { x: cluster.centerX, y: cluster.centerY },
|
|
186
|
-
positioning: cluster.isFixed ? "fixed" : "absolute",
|
|
187
|
-
colorHex: getMostSevereColorHex(cluster.members),
|
|
188
|
-
badgeLabel: String(cluster.members.length),
|
|
189
|
-
badgeAriaLabel: `${cluster.members.length} page issues near this element`,
|
|
190
|
-
isActive: false,
|
|
191
|
-
onBadgeClick: () => {
|
|
192
|
-
expandedClusterId = cluster.id;
|
|
193
|
-
render();
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
];
|
|
197
|
-
}
|
|
198
|
-
const memberSpecs = cluster.members.map((member, index) => {
|
|
199
|
-
const angle = index / cluster.members.length * 2 * Math.PI - Math.PI / 2;
|
|
200
|
-
return buildMemberSpec({
|
|
201
|
-
member,
|
|
202
|
-
badgeCenter: {
|
|
203
|
-
x: cluster.centerX + Math.cos(angle) * CLUSTER_FAN_RADIUS_PX,
|
|
204
|
-
y: cluster.centerY + Math.sin(angle) * CLUSTER_FAN_RADIUS_PX
|
|
205
|
-
}
|
|
206
|
-
});
|
|
207
|
-
});
|
|
208
|
-
return [
|
|
209
|
-
{
|
|
210
|
-
id: `cluster:${cluster.id}`,
|
|
211
|
-
pageRect: hub,
|
|
212
|
-
badgeCenter: { x: cluster.centerX, y: cluster.centerY },
|
|
213
|
-
positioning: cluster.isFixed ? "fixed" : "absolute",
|
|
214
|
-
colorHex: "#94a3b8",
|
|
215
|
-
badgeLabel: "\xD7",
|
|
216
|
-
badgeAriaLabel: "Collapse issue cluster",
|
|
217
|
-
isActive: false,
|
|
218
|
-
onBadgeClick: () => {
|
|
219
|
-
expandedClusterId = null;
|
|
220
|
-
render();
|
|
221
|
-
}
|
|
222
|
-
},
|
|
223
|
-
...memberSpecs
|
|
224
|
-
];
|
|
225
|
-
}
|
|
226
|
-
function render() {
|
|
227
|
-
if (markers.length === 0) {
|
|
228
|
-
lastRenderSignature = null;
|
|
229
|
-
clearAnnotationFrames();
|
|
230
|
-
syncObservers();
|
|
231
|
-
return;
|
|
232
|
-
}
|
|
233
|
-
const { resolved, unresolvedIds } = resolveMarkers();
|
|
234
|
-
if (activeMarkerId !== null && unresolvedIds.includes(activeMarkerId)) {
|
|
235
|
-
activeMarkerId = null;
|
|
236
|
-
}
|
|
237
|
-
const signature = [
|
|
238
|
-
resolved.map((entry) => {
|
|
239
|
-
return `${entry.marker.id}:${Math.round(entry.rect.x)},${Math.round(entry.rect.y)}`;
|
|
240
|
-
}).join("|"),
|
|
241
|
-
`active:${activeMarkerId ?? ""}`,
|
|
242
|
-
`expanded:${expandedClusterId ?? ""}`,
|
|
243
|
-
`unresolved:${unresolvedIds.join(",")}`
|
|
244
|
-
].join("#");
|
|
245
|
-
if (signature === lastRenderSignature) {
|
|
246
|
-
return;
|
|
247
|
-
}
|
|
248
|
-
lastRenderSignature = signature;
|
|
249
|
-
const frames = clusterResolvedMarkers(resolved).flatMap((cluster) => {
|
|
250
|
-
return buildClusterSpecs(cluster);
|
|
251
|
-
});
|
|
252
|
-
showAnnotationFrames({ frames });
|
|
253
|
-
if (setId !== null) {
|
|
254
|
-
postToEditor({
|
|
255
|
-
type: "replo:annotations:unresolved",
|
|
256
|
-
setId,
|
|
257
|
-
ids: unresolvedIds
|
|
258
|
-
});
|
|
259
|
-
}
|
|
260
|
-
syncObservers();
|
|
261
|
-
}
|
|
262
|
-
function scheduleRemeasure() {
|
|
263
|
-
remeasureFrameId ??= requestAnimationFrame(() => {
|
|
264
|
-
remeasureFrameId = null;
|
|
265
|
-
render();
|
|
266
|
-
});
|
|
267
|
-
}
|
|
268
|
-
function scheduleDebouncedRemeasure() {
|
|
269
|
-
if (remeasureDebounceId !== null) {
|
|
270
|
-
clearTimeout(remeasureDebounceId);
|
|
271
|
-
}
|
|
272
|
-
remeasureDebounceId = setTimeout(scheduleRemeasure, REMEASURE_DEBOUNCE_MS);
|
|
273
|
-
}
|
|
274
|
-
function handleScroll(event) {
|
|
275
|
-
if (event.target !== document) {
|
|
276
|
-
scheduleRemeasure();
|
|
277
|
-
}
|
|
278
|
-
if (activeMarkerId !== null) {
|
|
279
|
-
const id = activeMarkerId;
|
|
280
|
-
activeRectFrameId ??= requestAnimationFrame(() => {
|
|
281
|
-
activeRectFrameId = null;
|
|
282
|
-
const viewportRect = getAnnotationBadgeViewportRect(id);
|
|
283
|
-
if (viewportRect) {
|
|
284
|
-
postToEditor({
|
|
285
|
-
type: "replo:annotations:activeRect",
|
|
286
|
-
id,
|
|
287
|
-
viewportRect
|
|
288
|
-
});
|
|
289
|
-
}
|
|
290
|
-
});
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
function syncObservers() {
|
|
294
|
-
const shouldObserve = markers.length > 0;
|
|
295
|
-
if (shouldObserve === observersActive) {
|
|
296
|
-
return;
|
|
297
|
-
}
|
|
298
|
-
observersActive = shouldObserve;
|
|
299
|
-
if (shouldObserve) {
|
|
300
|
-
window.addEventListener("resize", scheduleRemeasure);
|
|
301
|
-
window.addEventListener("scroll", handleScroll, { capture: true });
|
|
302
|
-
if (typeof ResizeObserver !== "undefined") {
|
|
303
|
-
resizeObserver = new ResizeObserver(scheduleRemeasure);
|
|
304
|
-
resizeObserver.observe(document.body);
|
|
305
|
-
}
|
|
306
|
-
mutationObserver = new MutationObserver((records) => {
|
|
307
|
-
const container = document.getElementById(ANNOTATION_CONTAINER_ID);
|
|
308
|
-
const hasForeignMutation = records.some((record) => {
|
|
309
|
-
return !container || !container.contains(record.target);
|
|
310
|
-
});
|
|
311
|
-
if (hasForeignMutation) {
|
|
312
|
-
scheduleDebouncedRemeasure();
|
|
313
|
-
}
|
|
314
|
-
});
|
|
315
|
-
mutationObserver.observe(document.body, { childList: true, subtree: true });
|
|
316
|
-
} else {
|
|
317
|
-
window.removeEventListener("resize", scheduleRemeasure);
|
|
318
|
-
window.removeEventListener("scroll", handleScroll, { capture: true });
|
|
319
|
-
resizeObserver?.disconnect();
|
|
320
|
-
resizeObserver = null;
|
|
321
|
-
mutationObserver?.disconnect();
|
|
322
|
-
mutationObserver = null;
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
function handleMessage(event) {
|
|
326
|
-
if (!isAllowedEditorMessage(event)) {
|
|
327
|
-
return;
|
|
328
|
-
}
|
|
329
|
-
const parsed = pageAnnotationsParentMessageSchema.safeParse(event.data);
|
|
330
|
-
if (!parsed.success) {
|
|
331
|
-
return;
|
|
332
|
-
}
|
|
333
|
-
editorOrigin = event.origin;
|
|
334
|
-
exhaustiveSwitch(parsed.data)({
|
|
335
|
-
"replo:annotations:set": (message) => {
|
|
336
|
-
markers = message.markers;
|
|
337
|
-
setId = message.setId;
|
|
338
|
-
expandedClusterId = null;
|
|
339
|
-
activeMarkerId = null;
|
|
340
|
-
lastRenderSignature = null;
|
|
341
|
-
render();
|
|
342
|
-
},
|
|
343
|
-
"replo:annotations:clear": () => {
|
|
344
|
-
markers = [];
|
|
345
|
-
setId = null;
|
|
346
|
-
expandedClusterId = null;
|
|
347
|
-
activeMarkerId = null;
|
|
348
|
-
render();
|
|
349
|
-
},
|
|
350
|
-
"replo:annotations:requestReady": () => {
|
|
351
|
-
postToEditor({
|
|
352
|
-
type: "replo:annotations:ready",
|
|
353
|
-
protocolVersion: PAGE_ANNOTATIONS_PROTOCOL_VERSION
|
|
354
|
-
});
|
|
355
|
-
}
|
|
356
|
-
});
|
|
357
|
-
}
|
|
1
|
+
import { canopyTombstoneError } from "../../lib/tombstone";
|
|
358
2
|
function initAnnotationLayer() {
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
}
|
|
365
|
-
isInitialized = true;
|
|
366
|
-
window.addEventListener("message", handleMessage);
|
|
367
|
-
try {
|
|
368
|
-
const referrerOrigin = new URL(document.referrer).origin;
|
|
369
|
-
if (isAllowedEditorOrigin(referrerOrigin)) {
|
|
370
|
-
window.parent.postMessage(
|
|
371
|
-
{
|
|
372
|
-
type: "replo:annotations:ready",
|
|
373
|
-
protocolVersion: PAGE_ANNOTATIONS_PROTOCOL_VERSION
|
|
374
|
-
},
|
|
375
|
-
referrerOrigin
|
|
376
|
-
);
|
|
377
|
-
}
|
|
378
|
-
} catch {
|
|
379
|
-
}
|
|
3
|
+
throw canopyTombstoneError({
|
|
4
|
+
symbol: "initAnnotationLayer",
|
|
5
|
+
subpath: "editor/annotations/annotationController",
|
|
6
|
+
replacement: { kind: "sandbox-runtime" }
|
|
7
|
+
});
|
|
380
8
|
}
|
|
381
9
|
export {
|
|
382
10
|
initAnnotationLayer
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../editor/annotations/annotationController.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * In-iframe annotation controller: consumes declarative marker sets from the\n * editor bridge, resolves selectors against the live DOM, and drives the\n * shared annotation frame renderer. Scroll costs zero JavaScript (frames use\n * page coordinates); re-measure runs only on resize/mutation/container\n * scroll, batched per animation frame. Data-only protocol \u2014 the editor can\n * describe dots, never execute code.\n */\nimport type {\n PageAnnotationMarker,\n PageAnnotationsIframeMessage,\n} from \"schemas/generated/pageAnnotations\";\nimport type { AnnotationFrameSpec } from \"../select-mode/annotationFrames\";\n\nimport { exhaustiveSwitch } from \"replo-utils/lib/misc\";\nimport {\n PAGE_ANNOTATIONS_PROTOCOL_VERSION,\n pageAnnotationsParentMessageSchema,\n} from \"schemas/pageAnnotations\";\n\nimport {\n ANNOTATION_CONTAINER_ID,\n clearAnnotationFrames,\n getAnnotationBadgeViewportRect,\n setActiveAnnotationBadge,\n showAnnotationFrames,\n} from \"../select-mode/annotationFrames\";\nimport { getDocumentScrollOffset } from \"../select-mode/interactions/selectionGeometry\";\nimport { isAllowedEditorMessage, isAllowedEditorOrigin } from \"./bridgeGate\";\n\nconst CLUSTER_DISTANCE_PX = 24;\nconst CLUSTER_FAN_RADIUS_PX = 30;\nconst REMEASURE_DEBOUNCE_MS = 250;\n// Page-wide findings stack in a row near the top-left of the page and scroll\n// with it like any other annotation.\nconst PAGE_TOP_STACK_X_PX = 20;\nconst PAGE_TOP_STACK_Y_PX = 20;\nconst PAGE_TOP_STACK_GAP_PX = 36;\n\n// Replo brand palette (lattice --color-brand-*): the wire enum names stay\n// red/purple/amber but the rendered hues are brand magenta/purple/blue,\n// matching the editor-side dots and cards.\nconst COLOR_HEX: Record<PageAnnotationMarker[\"color\"], string> = {\n red: \"#ef196e\",\n purple: \"#8b32a8\",\n amber: \"#274ae2\",\n};\nconst COLOR_SEVERITY: PageAnnotationMarker[\"color\"][] = [\n \"red\",\n \"purple\",\n \"amber\",\n];\n\ninterface ResolvedMarker {\n marker: PageAnnotationMarker;\n element: Element | null;\n isFixed: boolean;\n rect: { x: number; y: number; width: number; height: number };\n // The editor-assigned wire number, rendered verbatim.\n displayNumber: number;\n}\n\ninterface MarkerCluster {\n id: string;\n centerX: number;\n centerY: number;\n isFixed: boolean;\n members: ResolvedMarker[];\n}\n\nlet isInitialized = false;\nlet editorOrigin: string | null = null;\nlet markers: PageAnnotationMarker[] = [];\nlet setId: string | null = null;\nlet expandedClusterId: string | null = null;\nlet activeMarkerId: string | null = null;\nlet remeasureFrameId: number | null = null;\nlet remeasureDebounceId: ReturnType<typeof setTimeout> | null = null;\nlet activeRectFrameId: number | null = null;\nlet observersActive = false;\nlet lastRenderSignature: string | null = null;\nlet resizeObserver: ResizeObserver | null = null;\nlet mutationObserver: MutationObserver | null = null;\n\nfunction postToEditor(message: PageAnnotationsIframeMessage) {\n if (editorOrigin === null) {\n return;\n }\n window.parent.postMessage(message, editorOrigin);\n}\n\nfunction hasFixedAncestor(element: Element): boolean {\n let current: Element | null = element;\n while (current !== null && current !== document.documentElement) {\n const position = getComputedStyle(current).position;\n if (position === \"fixed\" || position === \"sticky\") {\n return true;\n }\n current = current.parentElement;\n }\n return false;\n}\n\nfunction resolveMarkers(): {\n resolved: ResolvedMarker[];\n unresolvedIds: string[];\n} {\n const resolved: ResolvedMarker[] = [];\n const unresolvedIds: string[] = [];\n let pageTopSlot = 0;\n for (const marker of markers) {\n if (marker.placement === \"pageTop\") {\n // Page-wide finding: a fixed slot in the top-of-page stack, no selector.\n resolved.push({\n marker,\n element: null,\n isFixed: false,\n rect: {\n x: PAGE_TOP_STACK_X_PX + pageTopSlot * PAGE_TOP_STACK_GAP_PX,\n y: PAGE_TOP_STACK_Y_PX,\n width: 0,\n height: 0,\n },\n // The editor owns numbering; rendering the wire number keeps dots in sync with the panel.\n displayNumber: marker.number,\n });\n pageTopSlot += 1;\n continue;\n }\n let element: Element | null = null;\n try {\n element = document.querySelector(marker.selector);\n } catch {\n // Malformed selector \u2014 unresolved, never a throw.\n }\n const domRect = element?.getBoundingClientRect();\n if (!element || !domRect || (domRect.width === 0 && domRect.height === 0)) {\n unresolvedIds.push(marker.id);\n continue;\n }\n const isFixed = hasFixedAncestor(element);\n const scrollOffset = getDocumentScrollOffset();\n resolved.push({\n marker,\n element,\n isFixed,\n // Fixed frames use viewport coords; absolute frames use page coords.\n rect: {\n x: domRect.x + (isFixed ? 0 : scrollOffset.left),\n y: domRect.y + (isFixed ? 0 : scrollOffset.top),\n width: domRect.width,\n height: domRect.height,\n },\n displayNumber: marker.number,\n });\n }\n return { resolved, unresolvedIds };\n}\n\n// Greedy: a marker joins the first cluster whose badge anchor lies within\n// 24px; fixed and absolute markers never co-cluster (their coordinate spaces\n// diverge as soon as the page scrolls).\nfunction clusterResolvedMarkers(resolved: ResolvedMarker[]): MarkerCluster[] {\n const clusters: MarkerCluster[] = [];\n for (const entry of resolved) {\n const centerX = entry.rect.x + entry.rect.width / 2;\n const centerY = entry.rect.y;\n const host = clusters.find((cluster) => {\n return (\n cluster.isFixed === entry.isFixed &&\n Math.hypot(cluster.centerX - centerX, cluster.centerY - centerY) <\n CLUSTER_DISTANCE_PX\n );\n });\n if (host) {\n host.members.push(entry);\n } else {\n clusters.push({\n id: entry.marker.id,\n centerX,\n centerY,\n isFixed: entry.isFixed,\n members: [entry],\n });\n }\n }\n return clusters;\n}\n\nfunction getMostSevereColorHex(members: ResolvedMarker[]): string {\n const color =\n COLOR_SEVERITY.find((candidate) => {\n return members.some((member) => member.marker.color === candidate);\n }) ?? \"amber\";\n return COLOR_HEX[color];\n}\n\nfunction activateMarker(id: string) {\n activeMarkerId = id;\n const viewportRect = getAnnotationBadgeViewportRect(id);\n if (viewportRect) {\n postToEditor({ type: \"replo:annotations:clicked\", id, viewportRect });\n }\n // Style-only: a rebuild here would race the pointer sequence and swallow\n // the very click being handled.\n setActiveAnnotationBadge(id);\n}\n\nfunction buildMemberSpec({\n member,\n badgeCenter,\n}: {\n member: ResolvedMarker;\n badgeCenter: { x: number; y: number };\n}): AnnotationFrameSpec {\n const marker = member.marker;\n return {\n id: marker.id,\n pageRect: member.rect,\n badgeCenter,\n positioning: member.isFixed ? \"fixed\" : \"absolute\",\n colorHex: COLOR_HEX[marker.color],\n badgeLabel: String(member.displayNumber),\n badgeAriaLabel: `Page issue ${member.displayNumber}`,\n isActive: activeMarkerId === marker.id,\n onBadgeClick: () => activateMarker(marker.id),\n };\n}\n\nfunction buildClusterSpecs(cluster: MarkerCluster): AnnotationFrameSpec[] {\n const [only] = cluster.members;\n if (cluster.members.length === 1 && only) {\n return [\n buildMemberSpec({\n member: only,\n badgeCenter: { x: cluster.centerX, y: cluster.centerY },\n }),\n ];\n }\n const hub = {\n x: cluster.centerX,\n y: cluster.centerY,\n width: 0,\n height: 0,\n };\n if (expandedClusterId !== cluster.id) {\n return [\n {\n id: `cluster:${cluster.id}`,\n pageRect: hub,\n badgeCenter: { x: cluster.centerX, y: cluster.centerY },\n positioning: cluster.isFixed ? \"fixed\" : \"absolute\",\n colorHex: getMostSevereColorHex(cluster.members),\n badgeLabel: String(cluster.members.length),\n badgeAriaLabel: `${cluster.members.length} page issues near this element`,\n isActive: false,\n onBadgeClick: () => {\n expandedClusterId = cluster.id;\n render();\n },\n },\n ];\n }\n const memberSpecs = cluster.members.map((member, index) => {\n const angle = (index / cluster.members.length) * 2 * Math.PI - Math.PI / 2;\n return buildMemberSpec({\n member,\n badgeCenter: {\n x: cluster.centerX + Math.cos(angle) * CLUSTER_FAN_RADIUS_PX,\n y: cluster.centerY + Math.sin(angle) * CLUSTER_FAN_RADIUS_PX,\n },\n });\n });\n return [\n {\n id: `cluster:${cluster.id}`,\n pageRect: hub,\n badgeCenter: { x: cluster.centerX, y: cluster.centerY },\n positioning: cluster.isFixed ? \"fixed\" : \"absolute\",\n colorHex: \"#94a3b8\",\n badgeLabel: \"\u00D7\",\n badgeAriaLabel: \"Collapse issue cluster\",\n isActive: false,\n onBadgeClick: () => {\n expandedClusterId = null;\n render();\n },\n },\n ...memberSpecs,\n ];\n}\n\nfunction render() {\n if (markers.length === 0) {\n lastRenderSignature = null;\n clearAnnotationFrames();\n syncObservers();\n return;\n }\n const { resolved, unresolvedIds } = resolveMarkers();\n if (activeMarkerId !== null && unresolvedIds.includes(activeMarkerId)) {\n activeMarkerId = null;\n }\n // Rebuilding the node pool mid-pointer-sequence swallows clicks, so skip\n // renders whose output would be identical to what is already on screen.\n const signature = [\n resolved\n .map((entry) => {\n return `${entry.marker.id}:${Math.round(entry.rect.x)},${Math.round(entry.rect.y)}`;\n })\n .join(\"|\"),\n `active:${activeMarkerId ?? \"\"}`,\n `expanded:${expandedClusterId ?? \"\"}`,\n `unresolved:${unresolvedIds.join(\",\")}`,\n ].join(\"#\");\n if (signature === lastRenderSignature) {\n return;\n }\n lastRenderSignature = signature;\n const frames = clusterResolvedMarkers(resolved).flatMap((cluster) => {\n return buildClusterSpecs(cluster);\n });\n showAnnotationFrames({ frames });\n if (setId !== null) {\n postToEditor({\n type: \"replo:annotations:unresolved\",\n setId,\n ids: unresolvedIds,\n });\n }\n syncObservers();\n}\n\nfunction scheduleRemeasure() {\n remeasureFrameId ??= requestAnimationFrame(() => {\n remeasureFrameId = null;\n render();\n });\n}\n\nfunction scheduleDebouncedRemeasure() {\n if (remeasureDebounceId !== null) {\n clearTimeout(remeasureDebounceId);\n }\n remeasureDebounceId = setTimeout(scheduleRemeasure, REMEASURE_DEBOUNCE_MS);\n}\n\nfunction handleScroll(event: Event) {\n // Document scroll is free for absolute frames; scrolls of inner overflow\n // containers move elements relative to the page, so re-measure everything.\n if (event.target !== document) {\n scheduleRemeasure();\n }\n if (activeMarkerId !== null) {\n const id = activeMarkerId;\n activeRectFrameId ??= requestAnimationFrame(() => {\n activeRectFrameId = null;\n const viewportRect = getAnnotationBadgeViewportRect(id);\n if (viewportRect) {\n postToEditor({\n type: \"replo:annotations:activeRect\",\n id,\n viewportRect,\n });\n }\n });\n }\n}\n\nfunction syncObservers() {\n const shouldObserve = markers.length > 0;\n if (shouldObserve === observersActive) {\n return;\n }\n observersActive = shouldObserve;\n if (shouldObserve) {\n window.addEventListener(\"resize\", scheduleRemeasure);\n window.addEventListener(\"scroll\", handleScroll, { capture: true });\n if (typeof ResizeObserver !== \"undefined\") {\n resizeObserver = new ResizeObserver(scheduleRemeasure);\n resizeObserver.observe(document.body);\n }\n mutationObserver = new MutationObserver((records) => {\n // Rendering our own frames mutates body's subtree; reacting to that\n // would re-render forever. Only foreign mutations can move elements.\n const container = document.getElementById(ANNOTATION_CONTAINER_ID);\n const hasForeignMutation = records.some((record) => {\n return !container || !container.contains(record.target);\n });\n if (hasForeignMutation) {\n scheduleDebouncedRemeasure();\n }\n });\n mutationObserver.observe(document.body, { childList: true, subtree: true });\n } else {\n window.removeEventListener(\"resize\", scheduleRemeasure);\n window.removeEventListener(\"scroll\", handleScroll, { capture: true });\n resizeObserver?.disconnect();\n resizeObserver = null;\n mutationObserver?.disconnect();\n mutationObserver = null;\n }\n}\n\nfunction handleMessage(event: MessageEvent) {\n // Origin gate BEFORE any parsing \u2014 hostile embedders never reach the schema.\n if (!isAllowedEditorMessage(event)) {\n return;\n }\n const parsed = pageAnnotationsParentMessageSchema.safeParse(event.data);\n if (!parsed.success) {\n return;\n }\n editorOrigin = event.origin;\n exhaustiveSwitch(parsed.data)({\n \"replo:annotations:set\": (message) => {\n markers = message.markers;\n setId = message.setId;\n expandedClusterId = null;\n activeMarkerId = null;\n // A fresh set always paints (and re-posts unresolved), even if geometry\n // happens to match the previous render.\n lastRenderSignature = null;\n render();\n },\n \"replo:annotations:clear\": () => {\n markers = [];\n setId = null;\n expandedClusterId = null;\n activeMarkerId = null;\n render();\n },\n \"replo:annotations:requestReady\": () => {\n postToEditor({\n type: \"replo:annotations:ready\",\n protocolVersion: PAGE_ANNOTATIONS_PROTOCOL_VERSION,\n });\n },\n });\n}\n\nexport function initAnnotationLayer() {\n if (isInitialized || typeof window === \"undefined\") {\n return;\n }\n if (window.self === window.top) {\n return;\n }\n isInitialized = true;\n window.addEventListener(\"message\", handleMessage);\n // Announce on load for iframe-reload cases where the editor isn't polling;\n // the referrer origin is verified against the same allowlist first.\n try {\n const referrerOrigin = new URL(document.referrer).origin;\n if (isAllowedEditorOrigin(referrerOrigin)) {\n window.parent.postMessage(\n {\n type: \"replo:annotations:ready\",\n protocolVersion: PAGE_ANNOTATIONS_PROTOCOL_VERSION,\n },\n referrerOrigin,\n );\n }\n } catch {\n // No usable referrer \u2014 the editor's requestReady polling covers this.\n }\n}\n"],
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["/* oxlint-disable replo/no-void-return-type -- Tombstone declarations preserve exact return types for consumer compatibility. */\n// eslint-disable-next-line no-unused-vars -- This type edge keeps the vendored annotation declaration reachable after tombstoning.\nimport type { PageAnnotationMarker } from \"schemas/generated/pageAnnotations\";\n// eslint-disable-next-line no-unused-vars -- This type edge keeps the vendored annotation schema reachable after tombstoning.\nimport type { pageAnnotationsParentMessageSchema } from \"schemas/pageAnnotations\";\n\nimport { canopyTombstoneError } from \"../../lib/tombstone\";\n\n/** @deprecated Mount SandboxRuntime from @replohq/sandbox-runtime instead. */\nexport function initAnnotationLayer(): void {\n throw canopyTombstoneError({\n symbol: \"initAnnotationLayer\",\n subpath: \"editor/annotations/annotationController\",\n replacement: { kind: \"sandbox-runtime\" },\n });\n}\n"],
|
|
5
|
+
"mappings": "AAMA,SAAS,4BAA4B;AAG9B,SAAS,sBAA4B;AAC1C,QAAM,qBAAqB;AAAA,IACzB,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,aAAa,EAAE,MAAM,kBAAkB;AAAA,EACzC,CAAC;AACH;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|