@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/select-mode/annotationFrames.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["/* oxlint-disable replo/no-void-return-type -- Tombstone declarations preserve exact return types for consumer compatibility. */\nimport { canopyTombstoneError } from \"../../lib/tombstone\";\n\ninterface AnnotationRect {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\n/** @deprecated Mount SandboxRuntime from @replohq/sandbox-runtime instead. */\nexport const ANNOTATION_CONTAINER_ID = \"replo-annotation-frames\";\n\nexport interface AnnotationFrameSpec {\n id: string;\n pageRect: AnnotationRect;\n badgeCenter: {\n x: number;\n y: number;\n };\n // \"fixed\" for elements inside fixed/sticky ancestors: those don't translate\n // on scroll, so their frame must not either (coords are viewport coords).\n positioning: \"absolute\" | \"fixed\";\n colorHex: string;\n badgeLabel: string;\n badgeAriaLabel: string;\n isActive: boolean;\n onBadgeClick: () => void;\n}\n\n/** @deprecated Mount SandboxRuntime from @replohq/sandbox-runtime instead. */\nexport function setActiveAnnotationBadge(_id: string | null): void {\n throw canopyTombstoneError({\n symbol: \"setActiveAnnotationBadge\",\n subpath: \"editor/select-mode/annotationFrames\",\n replacement: { kind: \"sandbox-runtime\" },\n });\n}\n\n/** @deprecated Mount SandboxRuntime from @replohq/sandbox-runtime instead. */\nexport function getAnnotationBadgeViewportRect(\n _id: string,\n): AnnotationRect | null {\n throw canopyTombstoneError({\n symbol: \"getAnnotationBadgeViewportRect\",\n subpath: \"editor/select-mode/annotationFrames\",\n replacement: { kind: \"sandbox-runtime\" },\n });\n}\n\n/** @deprecated Mount SandboxRuntime from @replohq/sandbox-runtime instead. */\nexport function showAnnotationFrames(_args: {\n frames: AnnotationFrameSpec[];\n}): void {\n throw canopyTombstoneError({\n symbol: \"showAnnotationFrames\",\n subpath: \"editor/select-mode/annotationFrames\",\n replacement: { kind: \"sandbox-runtime\" },\n });\n}\n\n/** @deprecated Mount SandboxRuntime from @replohq/sandbox-runtime instead. */\nexport function clearAnnotationFrames(): void {\n throw canopyTombstoneError({\n symbol: \"clearAnnotationFrames\",\n subpath: \"editor/select-mode/annotationFrames\",\n replacement: { kind: \"sandbox-runtime\" },\n });\n}\n"],
|
|
5
|
+
"mappings": "AACA,SAAS,4BAA4B;AAU9B,MAAM,0BAA0B;AAoBhC,SAAS,yBAAyB,KAA0B;AACjE,QAAM,qBAAqB;AAAA,IACzB,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,aAAa,EAAE,MAAM,kBAAkB;AAAA,EACzC,CAAC;AACH;AAGO,SAAS,+BACd,KACuB;AACvB,QAAM,qBAAqB;AAAA,IACzB,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,aAAa,EAAE,MAAM,kBAAkB;AAAA,EACzC,CAAC;AACH;AAGO,SAAS,qBAAqB,OAE5B;AACP,QAAM,qBAAqB;AAAA,IACzB,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,aAAa,EAAE,MAAM,kBAAkB;AAAA,EACzC,CAAC;AACH;AAGO,SAAS,wBAA8B;AAC5C,QAAM,qBAAqB;AAAA,IACzB,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,aAAa,EAAE,MAAM,kBAAkB;AAAA,EACzC,CAAC;AACH;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,25 +1,10 @@
|
|
|
1
1
|
import type { SelectableData, SelectModeClickPosition } from "../../../_vendor/schemas/generated/selectMode";
|
|
2
|
-
/**
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
* Build a CSS selector path from `element` up to the document root. Stops
|
|
9
|
-
* (and short-circuits) at the first ancestor with an `id`. Used so the
|
|
10
|
-
* parent can identify the element later without holding a DOM reference.
|
|
11
|
-
*/
|
|
12
|
-
export declare function buildSelector(element: Element): string;
|
|
13
|
-
/**
|
|
14
|
-
* The single entrypoint for converting a DOM `Element` into the serialized
|
|
15
|
-
* `SelectedElement` payload that crosses the iframe<->parent boundary.
|
|
16
|
-
* Centralizes everything the parent (and downstream agent) need to know
|
|
17
|
-
* about a selection: identification, geometry, source location, and a
|
|
18
|
-
* style-inlined HTML snippet.
|
|
19
|
-
*
|
|
20
|
-
* @author Kevin O'Connell 2026-04-17
|
|
21
|
-
*/
|
|
22
|
-
export declare function buildElementDescriptor({ element, clickPosition, siblingSelectors, }: {
|
|
2
|
+
/** @deprecated Mount SandboxRuntime from @replohq/sandbox-runtime instead. */
|
|
3
|
+
export declare function getNearestSelectableElement(_element: Element): Element;
|
|
4
|
+
/** @deprecated Mount SandboxRuntime from @replohq/sandbox-runtime instead. */
|
|
5
|
+
export declare function buildSelector(_element: Element): string;
|
|
6
|
+
/** @deprecated Mount SandboxRuntime from @replohq/sandbox-runtime instead. */
|
|
7
|
+
export declare function buildElementDescriptor(_args: {
|
|
23
8
|
element: Element;
|
|
24
9
|
clickPosition: SelectModeClickPosition;
|
|
25
10
|
siblingSelectors?: string[];
|
|
@@ -1,197 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import { getElementBoundingRect } from "../interactions/selectionGeometry";
|
|
9
|
-
import { getDefinedStyles, getInheritedStyles } from "./styleExtraction";
|
|
10
|
-
function getNearestSelectableElement(element) {
|
|
11
|
-
const host = skipInlineTextMarkElements(element);
|
|
12
|
-
return host.closest(`[${SELECT_MODE_SELECTABLE_ATTRIBUTE}]`) ?? host;
|
|
1
|
+
import { canopyTombstoneError } from "../../../lib/tombstone";
|
|
2
|
+
function getNearestSelectableElement(_element) {
|
|
3
|
+
throw canopyTombstoneError({
|
|
4
|
+
symbol: "getNearestSelectableElement",
|
|
5
|
+
subpath: "editor/select-mode/descriptor/elementDescriptor",
|
|
6
|
+
replacement: { kind: "sandbox-runtime" }
|
|
7
|
+
});
|
|
13
8
|
}
|
|
14
|
-
function
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
const selectablePayload = readSelectablePayload(
|
|
22
|
-
selectableElement.getAttribute(SELECT_MODE_SELECTABLE_PAYLOAD_ATTRIBUTE)
|
|
23
|
-
);
|
|
24
|
-
if (!selectablePayload) {
|
|
25
|
-
return null;
|
|
26
|
-
}
|
|
27
|
-
return {
|
|
28
|
-
...selectablePayload,
|
|
29
|
-
rect: getElementBoundingRect(selectableElement)
|
|
30
|
-
};
|
|
9
|
+
function buildSelector(_element) {
|
|
10
|
+
throw canopyTombstoneError({
|
|
11
|
+
symbol: "buildSelector",
|
|
12
|
+
subpath: "editor/select-mode/descriptor/elementDescriptor",
|
|
13
|
+
replacement: { kind: "sandbox-runtime" }
|
|
14
|
+
});
|
|
31
15
|
}
|
|
32
|
-
function
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
const ariaLabel = element.getAttribute("aria-label");
|
|
40
|
-
if (ariaLabel) {
|
|
41
|
-
return `${tagName}: [${ariaLabel}]`;
|
|
42
|
-
}
|
|
43
|
-
if (tagName === "input") {
|
|
44
|
-
const inputType = element.type || "text";
|
|
45
|
-
const placeholder = element.getAttribute("placeholder");
|
|
46
|
-
return placeholder ? `input(${inputType}): "${placeholder}"` : `input(${inputType})`;
|
|
47
|
-
}
|
|
48
|
-
return tagName;
|
|
49
|
-
}
|
|
50
|
-
if (tagName === "a") {
|
|
51
|
-
const trimmedText2 = element.textContent?.trim();
|
|
52
|
-
if (trimmedText2) {
|
|
53
|
-
return `link: "${trimmedText2.slice(0, 60)}"`;
|
|
54
|
-
}
|
|
55
|
-
const href = element.getAttribute("href");
|
|
56
|
-
if (href) {
|
|
57
|
-
return `link: [${href.slice(0, 60)}]`;
|
|
58
|
-
}
|
|
59
|
-
return "link";
|
|
60
|
-
}
|
|
61
|
-
if (tagName === "img") {
|
|
62
|
-
const alt = element.alt;
|
|
63
|
-
if (alt) {
|
|
64
|
-
return `image: "${alt.slice(0, 60)}"`;
|
|
65
|
-
}
|
|
66
|
-
const src = element.src;
|
|
67
|
-
if (src) {
|
|
68
|
-
const filename = src.split("/").pop()?.split("?")[0] ?? src;
|
|
69
|
-
return `image: [${filename.slice(0, 40)}]`;
|
|
70
|
-
}
|
|
71
|
-
return "image";
|
|
72
|
-
}
|
|
73
|
-
if (/^h[1-6]$/.test(tagName)) {
|
|
74
|
-
const trimmedText2 = element.textContent?.trim();
|
|
75
|
-
return trimmedText2 ? `heading(${tagName}): "${trimmedText2.slice(0, 60)}"` : tagName;
|
|
76
|
-
}
|
|
77
|
-
if (["div", "main", "section", "article", "header", "footer", "nav"].includes(
|
|
78
|
-
tagName
|
|
79
|
-
)) {
|
|
80
|
-
const role2 = element.getAttribute("role");
|
|
81
|
-
if (role2) {
|
|
82
|
-
return role2;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
const trimmedText = element.textContent?.trim();
|
|
86
|
-
if (trimmedText && trimmedText.length < 120) {
|
|
87
|
-
const role2 = element.getAttribute("role");
|
|
88
|
-
const label = role2 ?? tagName;
|
|
89
|
-
return `${label}: "${trimmedText.slice(0, 60)}"`;
|
|
90
|
-
}
|
|
91
|
-
const role = element.getAttribute("role");
|
|
92
|
-
if (role) {
|
|
93
|
-
return role;
|
|
94
|
-
}
|
|
95
|
-
const className = element.className;
|
|
96
|
-
if (typeof className === "string" && className) {
|
|
97
|
-
const meaningfulClassName = className.split(/\s+/).find((classToken) => {
|
|
98
|
-
return !classToken.startsWith("_") && !classToken.match(/^[a-z]{1,2}\d/) && classToken.length > 2;
|
|
99
|
-
});
|
|
100
|
-
if (meaningfulClassName) {
|
|
101
|
-
return `${tagName}.${meaningfulClassName}`;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
return tagName;
|
|
105
|
-
}
|
|
106
|
-
function buildSelector(element) {
|
|
107
|
-
const parts = [];
|
|
108
|
-
let currentElement = element;
|
|
109
|
-
while (currentElement && currentElement !== document.documentElement) {
|
|
110
|
-
const tag = currentElement.tagName.toLowerCase();
|
|
111
|
-
const id = currentElement.id;
|
|
112
|
-
if (id) {
|
|
113
|
-
parts.unshift(`#${id}`);
|
|
114
|
-
break;
|
|
115
|
-
}
|
|
116
|
-
const parentElement = currentElement.parentElement;
|
|
117
|
-
if (parentElement) {
|
|
118
|
-
const currentTag = currentElement.tagName;
|
|
119
|
-
const siblings = Array.from(parentElement.children);
|
|
120
|
-
const siblingElementsWithSameTag = siblings.filter((sibling) => {
|
|
121
|
-
return sibling.tagName === currentTag;
|
|
122
|
-
});
|
|
123
|
-
if (siblingElementsWithSameTag.length > 1) {
|
|
124
|
-
const index = siblingElementsWithSameTag.indexOf(currentElement) + 1;
|
|
125
|
-
parts.unshift(`${tag}:nth-of-type(${index})`);
|
|
126
|
-
} else {
|
|
127
|
-
parts.unshift(tag);
|
|
128
|
-
}
|
|
129
|
-
} else {
|
|
130
|
-
parts.unshift(tag);
|
|
131
|
-
}
|
|
132
|
-
currentElement = parentElement;
|
|
133
|
-
}
|
|
134
|
-
return parts.join(" > ");
|
|
135
|
-
}
|
|
136
|
-
function getTextMetrics(element) {
|
|
137
|
-
const text = element.textContent?.trim();
|
|
138
|
-
if (!text) {
|
|
139
|
-
return null;
|
|
140
|
-
}
|
|
141
|
-
const style = window.getComputedStyle(element);
|
|
142
|
-
const parsedLineHeight = Number.parseFloat(style.lineHeight);
|
|
143
|
-
const computedLineHeight = Number.isNaN(parsedLineHeight) ? Number.parseFloat(style.fontSize) * 1.2 : parsedLineHeight;
|
|
144
|
-
try {
|
|
145
|
-
const range = document.createRange();
|
|
146
|
-
range.selectNodeContents(element);
|
|
147
|
-
const lineRects = Array.from(range.getClientRects()).filter((lineRect) => {
|
|
148
|
-
return lineRect.width > 0 && lineRect.height > 0;
|
|
149
|
-
});
|
|
150
|
-
let tightWidth = 0;
|
|
151
|
-
for (const lineRect of lineRects) {
|
|
152
|
-
tightWidth = Math.max(tightWidth, lineRect.width);
|
|
153
|
-
}
|
|
154
|
-
const lineCount = lineRects.length;
|
|
155
|
-
if (lineCount === 0) {
|
|
156
|
-
return null;
|
|
157
|
-
}
|
|
158
|
-
return {
|
|
159
|
-
tightWidth,
|
|
160
|
-
lineCount,
|
|
161
|
-
lineHeight: computedLineHeight
|
|
162
|
-
};
|
|
163
|
-
} catch {
|
|
164
|
-
return null;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
function buildElementDescriptor({
|
|
168
|
-
element,
|
|
169
|
-
clickPosition,
|
|
170
|
-
siblingSelectors = []
|
|
171
|
-
}) {
|
|
172
|
-
const selectableData = getSelectableDataFromElement(element);
|
|
173
|
-
if (selectableData) {
|
|
174
|
-
return selectableData;
|
|
175
|
-
}
|
|
176
|
-
const textMetrics = getTextMetrics(element);
|
|
177
|
-
const fiberChain = element instanceof HTMLElement ? getFiberChain(element) : [];
|
|
178
|
-
const sourceLocation = fiberChain[0]?.sourceLocation;
|
|
179
|
-
return {
|
|
180
|
-
kind: "react-element",
|
|
181
|
-
selector: buildSelector(element),
|
|
182
|
-
tagName: element.tagName.toLowerCase(),
|
|
183
|
-
elementType: identifyElement(element),
|
|
184
|
-
textContent: element.textContent?.trim()?.slice(0, 200) ?? null,
|
|
185
|
-
rect: getElementBoundingRect(element),
|
|
186
|
-
textMetrics,
|
|
187
|
-
outerHTML: element.outerHTML.slice(0, 4e3),
|
|
188
|
-
definedStyles: getDefinedStyles(element),
|
|
189
|
-
inheritedStyles: getInheritedStyles(element),
|
|
190
|
-
clickPosition,
|
|
191
|
-
sourceLocation,
|
|
192
|
-
fiberChain,
|
|
193
|
-
siblingSelectors
|
|
194
|
-
};
|
|
16
|
+
function buildElementDescriptor(_args) {
|
|
17
|
+
throw canopyTombstoneError({
|
|
18
|
+
symbol: "buildElementDescriptor",
|
|
19
|
+
subpath: "editor/select-mode/descriptor/elementDescriptor",
|
|
20
|
+
replacement: { kind: "sandbox-runtime" }
|
|
21
|
+
});
|
|
195
22
|
}
|
|
196
23
|
export {
|
|
197
24
|
buildElementDescriptor,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../editor/select-mode/descriptor/elementDescriptor.ts"],
|
|
4
|
-
"sourcesContent": ["import type {\n SelectableData,\n SelectModeClickPosition,\n
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": [
|
|
4
|
+
"sourcesContent": ["import type {\n SelectableData,\n SelectModeClickPosition,\n} from \"schemas/generated/selectMode\";\n\nimport { canopyTombstoneError } from \"../../../lib/tombstone\";\n\n/** @deprecated Mount SandboxRuntime from @replohq/sandbox-runtime instead. */\nexport function getNearestSelectableElement(_element: Element): Element {\n throw canopyTombstoneError({\n symbol: \"getNearestSelectableElement\",\n subpath: \"editor/select-mode/descriptor/elementDescriptor\",\n replacement: { kind: \"sandbox-runtime\" },\n });\n}\n\n/** @deprecated Mount SandboxRuntime from @replohq/sandbox-runtime instead. */\nexport function buildSelector(_element: Element): string {\n throw canopyTombstoneError({\n symbol: \"buildSelector\",\n subpath: \"editor/select-mode/descriptor/elementDescriptor\",\n replacement: { kind: \"sandbox-runtime\" },\n });\n}\n\n/** @deprecated Mount SandboxRuntime from @replohq/sandbox-runtime instead. */\nexport function buildElementDescriptor(_args: {\n element: Element;\n clickPosition: SelectModeClickPosition;\n siblingSelectors?: string[];\n}): SelectableData {\n throw canopyTombstoneError({\n symbol: \"buildElementDescriptor\",\n subpath: \"editor/select-mode/descriptor/elementDescriptor\",\n replacement: { kind: \"sandbox-runtime\" },\n });\n}\n"],
|
|
5
|
+
"mappings": "AAKA,SAAS,4BAA4B;AAG9B,SAAS,4BAA4B,UAA4B;AACtE,QAAM,qBAAqB;AAAA,IACzB,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,aAAa,EAAE,MAAM,kBAAkB;AAAA,EACzC,CAAC;AACH;AAGO,SAAS,cAAc,UAA2B;AACvD,QAAM,qBAAqB;AAAA,IACzB,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,aAAa,EAAE,MAAM,kBAAkB;AAAA,EACzC,CAAC;AACH;AAGO,SAAS,uBAAuB,OAIpB;AACjB,QAAM,qBAAqB;AAAA,IACzB,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,aAAa,EAAE,MAAM,kBAAkB;AAAA,EACzC,CAAC;AACH;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import type { SelectModeDefinedStyle } from "../../../_vendor/schemas/generated/selectMode";
|
|
2
|
-
|
|
3
|
-
export declare function
|
|
2
|
+
/** @deprecated Mount SandboxRuntime from @replohq/sandbox-runtime instead. */
|
|
3
|
+
export declare function getDefinedStyles(_element: Element): SelectModeDefinedStyle[];
|
|
4
|
+
/** @deprecated Mount SandboxRuntime from @replohq/sandbox-runtime instead. */
|
|
5
|
+
export declare function getInheritedStyles(_element: Element): Record<string, string>;
|
|
@@ -1,269 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
"line-height",
|
|
8
|
-
"letter-spacing",
|
|
9
|
-
"text-align"
|
|
10
|
-
];
|
|
11
|
-
const CONTROL_STYLE_PROPERTY_SET = new Set(CONTROL_STYLE_PROPERTIES);
|
|
12
|
-
function isControlStyleProperty(propertyName) {
|
|
13
|
-
return CONTROL_STYLE_PROPERTY_SET.has(propertyName);
|
|
14
|
-
}
|
|
15
|
-
function getEscapedClassName(className) {
|
|
16
|
-
return CSS.escape(className);
|
|
17
|
-
}
|
|
18
|
-
function getClassSelectorMatches({
|
|
19
|
-
selectorText,
|
|
20
|
-
classNames
|
|
21
|
-
}) {
|
|
22
|
-
const matches = [];
|
|
23
|
-
const selectorParts = selectorText.split(",").map((selectorPart) => {
|
|
24
|
-
return selectorPart.trim();
|
|
1
|
+
import { canopyTombstoneError } from "../../../lib/tombstone";
|
|
2
|
+
function getDefinedStyles(_element) {
|
|
3
|
+
throw canopyTombstoneError({
|
|
4
|
+
symbol: "getDefinedStyles",
|
|
5
|
+
subpath: "editor/select-mode/descriptor/styleExtraction",
|
|
6
|
+
replacement: { kind: "sandbox-runtime" }
|
|
25
7
|
});
|
|
26
|
-
for (const selectorPart of selectorParts) {
|
|
27
|
-
for (const className of classNames) {
|
|
28
|
-
const escapedClassName = getEscapedClassName(className);
|
|
29
|
-
const baseSelector = `.${escapedClassName}`;
|
|
30
|
-
if (selectorPart === baseSelector) {
|
|
31
|
-
matches.push({ className, pseudo: null });
|
|
32
|
-
continue;
|
|
33
|
-
}
|
|
34
|
-
if (!selectorPart.startsWith(`${baseSelector}:`)) {
|
|
35
|
-
continue;
|
|
36
|
-
}
|
|
37
|
-
const pseudo = selectorPart.slice(baseSelector.length);
|
|
38
|
-
const isSimplePseudoSelector = pseudo.startsWith(":") && !/[ >+~#[.]/.test(pseudo) && !pseudo.includes("::");
|
|
39
|
-
if (isSimplePseudoSelector) {
|
|
40
|
-
matches.push({ className, pseudo });
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return matches;
|
|
45
|
-
}
|
|
46
|
-
function getNestedAtRules({
|
|
47
|
-
rule,
|
|
48
|
-
activeAtRules
|
|
49
|
-
}) {
|
|
50
|
-
const nextAtRules = [...activeAtRules];
|
|
51
|
-
if (rule instanceof CSSMediaRule) {
|
|
52
|
-
nextAtRules.push({ type: "@media", text: rule.conditionText });
|
|
53
|
-
} else if (rule instanceof CSSSupportsRule) {
|
|
54
|
-
nextAtRules.push({ type: "@supports", text: rule.conditionText });
|
|
55
|
-
} else if (rule.constructor?.name === "CSSContainerRule" && "conditionText" in rule && typeof rule.conditionText === "string") {
|
|
56
|
-
nextAtRules.push({
|
|
57
|
-
type: "@container",
|
|
58
|
-
text: rule.conditionText
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
return nextAtRules;
|
|
62
|
-
}
|
|
63
|
-
function getNestedRuleList(rule) {
|
|
64
|
-
if (typeof CSSGroupingRule !== "undefined" && rule instanceof CSSGroupingRule) {
|
|
65
|
-
return rule.cssRules;
|
|
66
|
-
}
|
|
67
|
-
return null;
|
|
68
|
-
}
|
|
69
|
-
function getStyleVariant({
|
|
70
|
-
atRules,
|
|
71
|
-
pseudo
|
|
72
|
-
}) {
|
|
73
|
-
if (atRules.length === 0 && !pseudo) {
|
|
74
|
-
return null;
|
|
75
|
-
}
|
|
76
|
-
return { atRules, pseudo };
|
|
77
|
-
}
|
|
78
|
-
function getStyleVariantKey(variant) {
|
|
79
|
-
return variant ? JSON.stringify(variant) : "base";
|
|
80
|
-
}
|
|
81
|
-
function getDefinedStyleKey({
|
|
82
|
-
property,
|
|
83
|
-
variant
|
|
84
|
-
}) {
|
|
85
|
-
return `${property}:${getStyleVariantKey(variant)}`;
|
|
86
|
-
}
|
|
87
|
-
function getResolvedClassStyleValue({
|
|
88
|
-
className,
|
|
89
|
-
property,
|
|
90
|
-
raw,
|
|
91
|
-
variant
|
|
92
|
-
}) {
|
|
93
|
-
if (variant) {
|
|
94
|
-
return raw;
|
|
95
|
-
}
|
|
96
|
-
const temporaryElement = document.createElement("div");
|
|
97
|
-
temporaryElement.className = className;
|
|
98
|
-
document.body.append(temporaryElement);
|
|
99
|
-
const resolved = window.getComputedStyle(temporaryElement).getPropertyValue(property);
|
|
100
|
-
temporaryElement.remove();
|
|
101
|
-
return resolved.trim() || raw;
|
|
102
8
|
}
|
|
103
|
-
function
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
raw,
|
|
109
|
-
resolved
|
|
110
|
-
}) {
|
|
111
|
-
definedStylesByKey.set(getDefinedStyleKey({ property, variant }), {
|
|
112
|
-
property,
|
|
113
|
-
variant,
|
|
114
|
-
className,
|
|
115
|
-
raw,
|
|
116
|
-
resolved
|
|
9
|
+
function getInheritedStyles(_element) {
|
|
10
|
+
throw canopyTombstoneError({
|
|
11
|
+
symbol: "getInheritedStyles",
|
|
12
|
+
subpath: "editor/select-mode/descriptor/styleExtraction",
|
|
13
|
+
replacement: { kind: "sandbox-runtime" }
|
|
117
14
|
});
|
|
118
15
|
}
|
|
119
|
-
function addRuleDefinedStyles({
|
|
120
|
-
rule,
|
|
121
|
-
activeAtRules,
|
|
122
|
-
classNames,
|
|
123
|
-
definedStylesByKey
|
|
124
|
-
}) {
|
|
125
|
-
const selectorMatches = getClassSelectorMatches({
|
|
126
|
-
selectorText: rule.selectorText ?? "",
|
|
127
|
-
classNames
|
|
128
|
-
});
|
|
129
|
-
if (selectorMatches.length === 0) {
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
for (const selectorMatch of selectorMatches) {
|
|
133
|
-
const variant = getStyleVariant({
|
|
134
|
-
atRules: activeAtRules,
|
|
135
|
-
pseudo: selectorMatch.pseudo
|
|
136
|
-
});
|
|
137
|
-
for (let styleIndex = 0; styleIndex < rule.style.length; styleIndex += 1) {
|
|
138
|
-
const property = rule.style.item(styleIndex);
|
|
139
|
-
if (!property || !isControlStyleProperty(property)) {
|
|
140
|
-
continue;
|
|
141
|
-
}
|
|
142
|
-
const raw = rule.style.getPropertyValue(property).trim();
|
|
143
|
-
if (!raw) {
|
|
144
|
-
continue;
|
|
145
|
-
}
|
|
146
|
-
setDefinedStyle({
|
|
147
|
-
definedStylesByKey,
|
|
148
|
-
property,
|
|
149
|
-
variant,
|
|
150
|
-
className: selectorMatch.className,
|
|
151
|
-
raw,
|
|
152
|
-
resolved: getResolvedClassStyleValue({
|
|
153
|
-
className: selectorMatch.className,
|
|
154
|
-
property,
|
|
155
|
-
raw,
|
|
156
|
-
variant
|
|
157
|
-
})
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
function addStyleRulesRecursively({
|
|
163
|
-
ruleList,
|
|
164
|
-
activeAtRules,
|
|
165
|
-
classNames,
|
|
166
|
-
definedStylesByKey
|
|
167
|
-
}) {
|
|
168
|
-
for (const rule of Array.from(ruleList)) {
|
|
169
|
-
const nestedRuleList = getNestedRuleList(rule);
|
|
170
|
-
if (nestedRuleList) {
|
|
171
|
-
addStyleRulesRecursively({
|
|
172
|
-
ruleList: nestedRuleList,
|
|
173
|
-
activeAtRules: getNestedAtRules({ rule, activeAtRules }),
|
|
174
|
-
classNames,
|
|
175
|
-
definedStylesByKey
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
if (rule instanceof CSSStyleRule) {
|
|
179
|
-
addRuleDefinedStyles({
|
|
180
|
-
rule,
|
|
181
|
-
activeAtRules,
|
|
182
|
-
classNames,
|
|
183
|
-
definedStylesByKey
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
function addClassDefinedStyles({
|
|
189
|
-
element,
|
|
190
|
-
definedStylesByKey
|
|
191
|
-
}) {
|
|
192
|
-
const classNames = Array.from(
|
|
193
|
-
new Set([...element.classList].filter(Boolean))
|
|
194
|
-
);
|
|
195
|
-
if (classNames.length === 0) {
|
|
196
|
-
return;
|
|
197
|
-
}
|
|
198
|
-
for (const sheet of Array.from(document.styleSheets)) {
|
|
199
|
-
if (sheet.href) {
|
|
200
|
-
try {
|
|
201
|
-
const sheetUrl = new URL(sheet.href);
|
|
202
|
-
if (sheetUrl.origin !== window.location.origin) {
|
|
203
|
-
continue;
|
|
204
|
-
}
|
|
205
|
-
} catch (error) {
|
|
206
|
-
if (error instanceof TypeError) {
|
|
207
|
-
continue;
|
|
208
|
-
}
|
|
209
|
-
throw error;
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
try {
|
|
213
|
-
addStyleRulesRecursively({
|
|
214
|
-
ruleList: sheet.cssRules,
|
|
215
|
-
activeAtRules: [],
|
|
216
|
-
classNames,
|
|
217
|
-
definedStylesByKey
|
|
218
|
-
});
|
|
219
|
-
} catch (error) {
|
|
220
|
-
if (error instanceof DOMException && error.name === "SecurityError") {
|
|
221
|
-
continue;
|
|
222
|
-
}
|
|
223
|
-
throw error;
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
function addInlineDefinedStyles({
|
|
228
|
-
element,
|
|
229
|
-
definedStylesByKey
|
|
230
|
-
}) {
|
|
231
|
-
if (!(element instanceof HTMLElement)) {
|
|
232
|
-
return;
|
|
233
|
-
}
|
|
234
|
-
for (let styleIndex = 0; styleIndex < element.style.length; styleIndex += 1) {
|
|
235
|
-
const property = element.style.item(styleIndex);
|
|
236
|
-
if (!property || !isControlStyleProperty(property)) {
|
|
237
|
-
continue;
|
|
238
|
-
}
|
|
239
|
-
const raw = element.style.getPropertyValue(property).trim();
|
|
240
|
-
if (!raw) {
|
|
241
|
-
continue;
|
|
242
|
-
}
|
|
243
|
-
setDefinedStyle({
|
|
244
|
-
definedStylesByKey,
|
|
245
|
-
property,
|
|
246
|
-
variant: null,
|
|
247
|
-
className: null,
|
|
248
|
-
raw,
|
|
249
|
-
resolved: raw
|
|
250
|
-
});
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
function getDefinedStyles(element) {
|
|
254
|
-
const definedStylesByKey = /* @__PURE__ */ new Map();
|
|
255
|
-
addClassDefinedStyles({ element, definedStylesByKey });
|
|
256
|
-
addInlineDefinedStyles({ element, definedStylesByKey });
|
|
257
|
-
return Array.from(definedStylesByKey.values());
|
|
258
|
-
}
|
|
259
|
-
function getInheritedStyles(element) {
|
|
260
|
-
const computedStyle = window.getComputedStyle(element);
|
|
261
|
-
const inheritedStyles = {};
|
|
262
|
-
for (const property of CONTROL_STYLE_PROPERTIES) {
|
|
263
|
-
inheritedStyles[property] = computedStyle.getPropertyValue(property);
|
|
264
|
-
}
|
|
265
|
-
return inheritedStyles;
|
|
266
|
-
}
|
|
267
16
|
export {
|
|
268
17
|
getDefinedStyles,
|
|
269
18
|
getInheritedStyles
|