@replohq/canopy-sdk 2.6.0 → 3.0.1
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/generated/consent.d.ts +2 -0
- package/_vendor/schemas/generated/selectModeIframeRpc.d.ts +8 -0
- 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 +25 -5
- package/_vendor/schemas/selectModeIframeRpc.mjs +12 -3
- 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 +1 -12
- 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,281 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { buildSelector } from "../descriptor/elementDescriptor";
|
|
3
|
-
import { getSourceLocationSiblingSelectors } from "./useSiblingResolution";
|
|
4
|
-
const OVERRIDE_REGISTRATION_TIMEOUT_MS = 15e3;
|
|
5
|
-
const SESSION_OUTCOME_RETENTION_MS = 6e4;
|
|
6
|
-
const OVERRIDE_ATTRIBUTE = "data-replo-select-overrides";
|
|
7
|
-
const OVERRIDE_REGISTRY_KEY = "reploSelectOverrideRegistryV2";
|
|
8
|
-
const SESSION_OUTCOME_REGISTRY_KEY = "reploSelectOverrideSessionOutcomesV2";
|
|
9
|
-
function getOverrideList() {
|
|
10
|
-
const existing = Reflect.get(window, OVERRIDE_REGISTRY_KEY);
|
|
11
|
-
if (Array.isArray(existing)) {
|
|
12
|
-
return existing;
|
|
13
|
-
}
|
|
14
|
-
const overrides = [];
|
|
15
|
-
Reflect.set(window, OVERRIDE_REGISTRY_KEY, overrides);
|
|
16
|
-
return overrides;
|
|
17
|
-
}
|
|
18
|
-
function setOverrideList(overrides) {
|
|
19
|
-
Reflect.set(window, OVERRIDE_REGISTRY_KEY, overrides);
|
|
20
|
-
}
|
|
21
|
-
function getSessionOutcomes() {
|
|
22
|
-
const existing = Reflect.get(window, SESSION_OUTCOME_REGISTRY_KEY);
|
|
23
|
-
if (existing instanceof Map) {
|
|
24
|
-
return existing;
|
|
25
|
-
}
|
|
26
|
-
const outcomes = /* @__PURE__ */ new Map();
|
|
27
|
-
Reflect.set(window, SESSION_OUTCOME_REGISTRY_KEY, outcomes);
|
|
28
|
-
return outcomes;
|
|
29
|
-
}
|
|
30
|
-
function getElementsForTargetMode({
|
|
31
|
-
element,
|
|
32
|
-
targetMode
|
|
33
|
-
}) {
|
|
34
|
-
if (targetMode === "primary") {
|
|
35
|
-
return [element];
|
|
36
|
-
}
|
|
37
|
-
return [
|
|
38
|
-
element,
|
|
39
|
-
...getSourceLocationSiblingSelectors({ element }).map((selector) => document.querySelector(selector)).filter((candidate) => {
|
|
40
|
-
return candidate instanceof HTMLElement;
|
|
41
|
-
})
|
|
42
|
-
];
|
|
43
|
-
}
|
|
44
|
-
function isImageSourcePayload({
|
|
45
|
-
element,
|
|
46
|
-
payload
|
|
47
|
-
}) {
|
|
48
|
-
return payload.kind === "attribute" && payload.name.toLowerCase() === "src" && element instanceof HTMLImageElement;
|
|
49
|
-
}
|
|
50
|
-
function getOriginalState({
|
|
51
|
-
element,
|
|
52
|
-
payload
|
|
53
|
-
}) {
|
|
54
|
-
if (payload.kind === "attribute") {
|
|
55
|
-
const names = isImageSourcePayload({ element, payload }) ? [payload.name, "srcset"] : [payload.name];
|
|
56
|
-
return {
|
|
57
|
-
kind: "attributes",
|
|
58
|
-
values: names.map((name) => ({
|
|
59
|
-
name,
|
|
60
|
-
value: element.getAttribute(name)
|
|
61
|
-
}))
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
if (payload.kind === "content") {
|
|
65
|
-
return { kind: "content", innerHTML: element.innerHTML };
|
|
66
|
-
}
|
|
67
|
-
return { kind: "css" };
|
|
68
|
-
}
|
|
69
|
-
function getStyleElement(token) {
|
|
70
|
-
return document.querySelector(
|
|
71
|
-
`style[data-replo-select-override="${token}"]`
|
|
72
|
-
);
|
|
73
|
-
}
|
|
74
|
-
function addToken(element, token) {
|
|
75
|
-
const tokens = new Set(
|
|
76
|
-
(element.getAttribute(OVERRIDE_ATTRIBUTE) ?? "").split(/\s+/).filter(Boolean)
|
|
77
|
-
);
|
|
78
|
-
tokens.add(token);
|
|
79
|
-
element.setAttribute(OVERRIDE_ATTRIBUTE, [...tokens].join(" "));
|
|
80
|
-
}
|
|
81
|
-
function removeToken(element, token) {
|
|
82
|
-
const tokens = (element.getAttribute(OVERRIDE_ATTRIBUTE) ?? "").split(/\s+/).filter((candidate) => candidate && candidate !== token);
|
|
83
|
-
if (tokens.length === 0) {
|
|
84
|
-
element.removeAttribute(OVERRIDE_ATTRIBUTE);
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
element.setAttribute(OVERRIDE_ATTRIBUTE, tokens.join(" "));
|
|
88
|
-
}
|
|
89
|
-
function applyPayload({
|
|
90
|
-
element,
|
|
91
|
-
payload,
|
|
92
|
-
token
|
|
93
|
-
}) {
|
|
94
|
-
if (payload.kind === "css") {
|
|
95
|
-
addToken(element, token);
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
if (payload.kind === "attribute") {
|
|
99
|
-
if (isImageSourcePayload({ element, payload })) {
|
|
100
|
-
element.removeAttribute("srcset");
|
|
101
|
-
}
|
|
102
|
-
element.setAttribute(payload.name, payload.value);
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
element.innerHTML = payload.innerHTML;
|
|
106
|
-
}
|
|
107
|
-
function restoreOriginalState({
|
|
108
|
-
element,
|
|
109
|
-
originalState
|
|
110
|
-
}) {
|
|
111
|
-
if (originalState.kind === "attributes") {
|
|
112
|
-
for (const { name, value } of originalState.values) {
|
|
113
|
-
if (value === null) {
|
|
114
|
-
element.removeAttribute(name);
|
|
115
|
-
} else {
|
|
116
|
-
element.setAttribute(name, value);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
if (originalState.kind === "content") {
|
|
122
|
-
element.innerHTML = originalState.innerHTML;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
function installCssRule(override) {
|
|
126
|
-
if (override.payload.kind !== "css") {
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
const style = document.createElement("style");
|
|
130
|
-
style.dataset.reploSelectOverride = override.token;
|
|
131
|
-
style.textContent = `[${OVERRIDE_ATTRIBUTE}~="${override.token}"] { ${override.payload.property}: ${override.payload.value ?? "revert"} !important; }`;
|
|
132
|
-
document.head.append(style);
|
|
133
|
-
}
|
|
134
|
-
function resolveTarget(target) {
|
|
135
|
-
if (target.element.isConnected) {
|
|
136
|
-
return target.element;
|
|
137
|
-
}
|
|
138
|
-
const replacement = document.querySelector(target.selector);
|
|
139
|
-
return replacement instanceof HTMLElement ? replacement : null;
|
|
140
|
-
}
|
|
141
|
-
function reapplyOverride({
|
|
142
|
-
override,
|
|
143
|
-
skipElement
|
|
144
|
-
}) {
|
|
145
|
-
for (const target of override.targets) {
|
|
146
|
-
const element = resolveTarget(target);
|
|
147
|
-
if (!element || skipElement && element.contains(skipElement)) {
|
|
148
|
-
continue;
|
|
149
|
-
}
|
|
150
|
-
if (element !== target.element) {
|
|
151
|
-
target.element = element;
|
|
152
|
-
target.originalState = getOriginalState({
|
|
153
|
-
element,
|
|
154
|
-
payload: override.payload
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
applyPayload({ element, payload: override.payload, token: override.token });
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
function removeOverride({
|
|
161
|
-
editId,
|
|
162
|
-
outcome
|
|
163
|
-
}) {
|
|
164
|
-
const override = getOverrideList().find(
|
|
165
|
-
(candidate) => candidate.editId === editId
|
|
166
|
-
);
|
|
167
|
-
if (!override) {
|
|
168
|
-
return;
|
|
169
|
-
}
|
|
170
|
-
clearTimeout(override.registrationTimeout);
|
|
171
|
-
getStyleElement(override.token)?.remove();
|
|
172
|
-
for (const target of override.targets) {
|
|
173
|
-
const element = resolveTarget(target);
|
|
174
|
-
if (!element) {
|
|
175
|
-
continue;
|
|
176
|
-
}
|
|
177
|
-
removeToken(element, override.token);
|
|
178
|
-
if (outcome === "failed") {
|
|
179
|
-
restoreOriginalState({
|
|
180
|
-
element,
|
|
181
|
-
originalState: target.originalState
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
setOverrideList(
|
|
186
|
-
getOverrideList().filter((candidate) => candidate.editId !== editId)
|
|
187
|
-
);
|
|
188
|
-
if (outcome === "failed") {
|
|
189
|
-
for (const remainingOverride of getOverrideList()) {
|
|
190
|
-
reapplyOverride({ override: remainingOverride, skipElement: null });
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
}
|
|
1
|
+
import { canopyTombstoneError } from "../../../lib/tombstone";
|
|
194
2
|
function useOptimisticOverrides() {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
targetMode
|
|
201
|
-
}) => {
|
|
202
|
-
const targetElement = document.querySelector(targetSelector);
|
|
203
|
-
if (!(targetElement instanceof HTMLElement)) {
|
|
204
|
-
return;
|
|
205
|
-
}
|
|
206
|
-
removeOverride({ editId, outcome: "failed" });
|
|
207
|
-
const elements = getElementsForTargetMode({
|
|
208
|
-
element: targetElement,
|
|
209
|
-
targetMode
|
|
210
|
-
});
|
|
211
|
-
const token = `override-${editId}`;
|
|
212
|
-
const override = {
|
|
213
|
-
editId,
|
|
214
|
-
payload,
|
|
215
|
-
registrationTimeout: window.setTimeout(() => {
|
|
216
|
-
removeOverride({ editId, outcome: "failed" });
|
|
217
|
-
}, OVERRIDE_REGISTRATION_TIMEOUT_MS),
|
|
218
|
-
sessionId: null,
|
|
219
|
-
state: "live",
|
|
220
|
-
targets: elements.map((element) => ({
|
|
221
|
-
element,
|
|
222
|
-
originalState: getOriginalState({ element, payload }),
|
|
223
|
-
selector: buildSelector(element)
|
|
224
|
-
})),
|
|
225
|
-
token
|
|
226
|
-
};
|
|
227
|
-
getOverrideList().push(override);
|
|
228
|
-
installCssRule(override);
|
|
229
|
-
reapplyOverride({ override, skipElement: null });
|
|
230
|
-
},
|
|
231
|
-
[]
|
|
232
|
-
);
|
|
233
|
-
const reapplyOverrides = useCallback(
|
|
234
|
-
({ skipElement }) => {
|
|
235
|
-
for (const override of getOverrideList()) {
|
|
236
|
-
reapplyOverride({ override, skipElement });
|
|
237
|
-
}
|
|
238
|
-
},
|
|
239
|
-
[]
|
|
240
|
-
);
|
|
241
|
-
const markCommitted = useCallback((editId, sessionId) => {
|
|
242
|
-
const override = getOverrideList().find((candidate) => {
|
|
243
|
-
return candidate.editId === editId;
|
|
244
|
-
});
|
|
245
|
-
if (!override) {
|
|
246
|
-
return;
|
|
247
|
-
}
|
|
248
|
-
clearTimeout(override.registrationTimeout);
|
|
249
|
-
override.sessionId = sessionId;
|
|
250
|
-
override.state = "fired";
|
|
251
|
-
const outcome = getSessionOutcomes().get(sessionId);
|
|
252
|
-
if (outcome) {
|
|
253
|
-
removeOverride({ editId, outcome });
|
|
254
|
-
}
|
|
255
|
-
}, []);
|
|
256
|
-
const resolveSessionOverrides = useCallback(
|
|
257
|
-
(sessionId, outcome) => {
|
|
258
|
-
getSessionOutcomes().set(sessionId, outcome);
|
|
259
|
-
window.setTimeout(() => {
|
|
260
|
-
getSessionOutcomes().delete(sessionId);
|
|
261
|
-
}, SESSION_OUTCOME_RETENTION_MS);
|
|
262
|
-
const editIds = getOverrideList().filter((override) => override.sessionId === sessionId).map((override) => override.editId);
|
|
263
|
-
for (const editId of editIds) {
|
|
264
|
-
removeOverride({ editId, outcome });
|
|
265
|
-
}
|
|
266
|
-
},
|
|
267
|
-
[]
|
|
268
|
-
);
|
|
269
|
-
const revertOverride = useCallback((editId) => {
|
|
270
|
-
removeOverride({ editId, outcome: "failed" });
|
|
271
|
-
}, []);
|
|
272
|
-
return {
|
|
273
|
-
applyOptimisticUpdate,
|
|
274
|
-
markCommitted,
|
|
275
|
-
reapplyOverrides,
|
|
276
|
-
resolveSessionOverrides,
|
|
277
|
-
revertOverride
|
|
278
|
-
};
|
|
3
|
+
throw canopyTombstoneError({
|
|
4
|
+
symbol: "useOptimisticOverrides",
|
|
5
|
+
subpath: "editor/select-mode/hooks/useOptimisticOverrides",
|
|
6
|
+
replacement: { kind: "sandbox-runtime" }
|
|
7
|
+
});
|
|
279
8
|
}
|
|
280
9
|
export {
|
|
281
10
|
useOptimisticOverrides
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../editor/select-mode/hooks/useOptimisticOverrides.ts"],
|
|
4
|
-
"sourcesContent": ["import type { SelectModeOptimisticUpdatePayload } from \"schemas/generated/selectMode\";\n\nimport { useCallback } from \"react\";\n\nimport { buildSelector } from \"../descriptor/elementDescriptor\";\nimport { getSourceLocationSiblingSelectors } from \"./useSiblingResolution\";\n\ntype OverrideTarget = {\n element: HTMLElement;\n originalState: OriginalPayloadState;\n selector: string;\n};\n\ntype OriginalPayloadState =\n | {\n kind: \"attributes\";\n values: { name: string; value: string | null }[];\n }\n | { kind: \"content\"; innerHTML: string }\n | { kind: \"css\" };\n\ntype IframeOverride = {\n editId: string;\n payload: SelectModeOptimisticUpdatePayload;\n registrationTimeout: number;\n sessionId: string | null;\n state: \"live\" | \"fired\";\n targets: OverrideTarget[];\n token: string;\n};\n\nconst OVERRIDE_REGISTRATION_TIMEOUT_MS = 15_000;\nconst SESSION_OUTCOME_RETENTION_MS = 60_000;\nconst OVERRIDE_ATTRIBUTE = \"data-replo-select-overrides\";\nconst OVERRIDE_REGISTRY_KEY = \"reploSelectOverrideRegistryV2\";\nconst SESSION_OUTCOME_REGISTRY_KEY = \"reploSelectOverrideSessionOutcomesV2\";\n\ntype SessionOutcome = \"persisted\" | \"failed\";\n\nfunction getOverrideList(): IframeOverride[] {\n const existing: unknown = Reflect.get(window, OVERRIDE_REGISTRY_KEY);\n if (Array.isArray(existing)) {\n return existing;\n }\n const overrides: IframeOverride[] = [];\n Reflect.set(window, OVERRIDE_REGISTRY_KEY, overrides);\n return overrides;\n}\n\nfunction setOverrideList(overrides: IframeOverride[]) {\n Reflect.set(window, OVERRIDE_REGISTRY_KEY, overrides);\n}\n\nfunction getSessionOutcomes(): Map<string, SessionOutcome> {\n const existing: unknown = Reflect.get(window, SESSION_OUTCOME_REGISTRY_KEY);\n if (existing instanceof Map) {\n return existing;\n }\n const outcomes = new Map<string, SessionOutcome>();\n Reflect.set(window, SESSION_OUTCOME_REGISTRY_KEY, outcomes);\n return outcomes;\n}\n\nfunction getElementsForTargetMode({\n element,\n targetMode,\n}: {\n element: HTMLElement;\n targetMode: \"primary\" | \"group\";\n}) {\n if (targetMode === \"primary\") {\n return [element];\n }\n\n return [\n element,\n ...getSourceLocationSiblingSelectors({ element })\n .map((selector) => document.querySelector(selector))\n .filter((candidate): candidate is HTMLElement => {\n return candidate instanceof HTMLElement;\n }),\n ];\n}\n\nfunction isImageSourcePayload({\n element,\n payload,\n}: {\n element: HTMLElement;\n payload: SelectModeOptimisticUpdatePayload;\n}) {\n return (\n payload.kind === \"attribute\" &&\n payload.name.toLowerCase() === \"src\" &&\n element instanceof HTMLImageElement\n );\n}\n\nfunction getOriginalState({\n element,\n payload,\n}: {\n element: HTMLElement;\n payload: SelectModeOptimisticUpdatePayload;\n}): OriginalPayloadState {\n if (payload.kind === \"attribute\") {\n const names = isImageSourcePayload({ element, payload })\n ? [payload.name, \"srcset\"]\n : [payload.name];\n return {\n kind: \"attributes\",\n values: names.map((name) => ({\n name,\n value: element.getAttribute(name),\n })),\n };\n }\n if (payload.kind === \"content\") {\n return { kind: \"content\", innerHTML: element.innerHTML };\n }\n return { kind: \"css\" };\n}\n\nfunction getStyleElement(token: string) {\n return document.querySelector<HTMLStyleElement>(\n `style[data-replo-select-override=\"${token}\"]`,\n );\n}\n\nfunction addToken(element: HTMLElement, token: string) {\n const tokens = new Set(\n (element.getAttribute(OVERRIDE_ATTRIBUTE) ?? \"\")\n .split(/\\s+/)\n .filter(Boolean),\n );\n tokens.add(token);\n element.setAttribute(OVERRIDE_ATTRIBUTE, [...tokens].join(\" \"));\n}\n\nfunction removeToken(element: HTMLElement, token: string) {\n const tokens = (element.getAttribute(OVERRIDE_ATTRIBUTE) ?? \"\")\n .split(/\\s+/)\n .filter((candidate) => candidate && candidate !== token);\n if (tokens.length === 0) {\n element.removeAttribute(OVERRIDE_ATTRIBUTE);\n return;\n }\n element.setAttribute(OVERRIDE_ATTRIBUTE, tokens.join(\" \"));\n}\n\nfunction applyPayload({\n element,\n payload,\n token,\n}: {\n element: HTMLElement;\n payload: SelectModeOptimisticUpdatePayload;\n token: string;\n}) {\n if (payload.kind === \"css\") {\n addToken(element, token);\n return;\n }\n if (payload.kind === \"attribute\") {\n if (isImageSourcePayload({ element, payload })) {\n element.removeAttribute(\"srcset\");\n }\n element.setAttribute(payload.name, payload.value);\n return;\n }\n element.innerHTML = payload.innerHTML;\n}\n\nfunction restoreOriginalState({\n element,\n originalState,\n}: {\n element: HTMLElement;\n originalState: OriginalPayloadState;\n}) {\n if (originalState.kind === \"attributes\") {\n for (const { name, value } of originalState.values) {\n if (value === null) {\n element.removeAttribute(name);\n } else {\n element.setAttribute(name, value);\n }\n }\n return;\n }\n if (originalState.kind === \"content\") {\n element.innerHTML = originalState.innerHTML;\n }\n}\n\nfunction installCssRule(override: IframeOverride) {\n if (override.payload.kind !== \"css\") {\n return;\n }\n const style = document.createElement(\"style\");\n style.dataset.reploSelectOverride = override.token;\n style.textContent = `[${OVERRIDE_ATTRIBUTE}~=\"${override.token}\"] { ${override.payload.property}: ${override.payload.value ?? \"revert\"} !important; }`;\n document.head.append(style);\n}\n\nfunction resolveTarget(target: OverrideTarget) {\n if (target.element.isConnected) {\n return target.element;\n }\n const replacement = document.querySelector(target.selector);\n return replacement instanceof HTMLElement ? replacement : null;\n}\n\nfunction reapplyOverride({\n override,\n skipElement,\n}: {\n override: IframeOverride;\n skipElement: HTMLElement | null;\n}) {\n for (const target of override.targets) {\n const element = resolveTarget(target);\n if (!element || (skipElement && element.contains(skipElement))) {\n continue;\n }\n if (element !== target.element) {\n target.element = element;\n target.originalState = getOriginalState({\n element,\n payload: override.payload,\n });\n }\n applyPayload({ element, payload: override.payload, token: override.token });\n }\n}\n\nfunction removeOverride({\n editId,\n outcome,\n}: {\n editId: string;\n outcome: SessionOutcome;\n}) {\n const override = getOverrideList().find(\n (candidate) => candidate.editId === editId,\n );\n if (!override) {\n return;\n }\n\n clearTimeout(override.registrationTimeout);\n getStyleElement(override.token)?.remove();\n for (const target of override.targets) {\n const element = resolveTarget(target);\n if (!element) {\n continue;\n }\n removeToken(element, override.token);\n if (outcome === \"failed\") {\n restoreOriginalState({\n element,\n originalState: target.originalState,\n });\n }\n }\n setOverrideList(\n getOverrideList().filter((candidate) => candidate.editId !== editId),\n );\n\n if (outcome === \"failed\") {\n for (const remainingOverride of getOverrideList()) {\n reapplyOverride({ override: remainingOverride, skipElement: null });\n }\n }\n}\n\nexport function useOptimisticOverrides() {\n const applyOptimisticUpdate = useCallback(\n ({\n editId,\n payload,\n targetSelector,\n targetMode,\n }: {\n editId: string;\n payload: SelectModeOptimisticUpdatePayload;\n targetSelector: string;\n targetMode: \"primary\" | \"group\";\n }) => {\n const targetElement = document.querySelector(targetSelector);\n if (!(targetElement instanceof HTMLElement)) {\n return;\n }\n\n removeOverride({ editId, outcome: \"failed\" });\n const elements = getElementsForTargetMode({\n element: targetElement,\n targetMode,\n });\n const token = `override-${editId}`;\n const override: IframeOverride = {\n editId,\n payload,\n registrationTimeout: window.setTimeout(() => {\n removeOverride({ editId, outcome: \"failed\" });\n }, OVERRIDE_REGISTRATION_TIMEOUT_MS),\n sessionId: null,\n state: \"live\",\n targets: elements.map((element) => ({\n element,\n originalState: getOriginalState({ element, payload }),\n selector: buildSelector(element),\n })),\n token,\n };\n getOverrideList().push(override);\n installCssRule(override);\n reapplyOverride({ override, skipElement: null });\n },\n [],\n );\n\n const reapplyOverrides = useCallback(\n ({ skipElement }: { skipElement: HTMLElement | null }) => {\n for (const override of getOverrideList()) {\n reapplyOverride({ override, skipElement });\n }\n },\n [],\n );\n\n const markCommitted = useCallback((editId: string, sessionId: string) => {\n const override = getOverrideList().find((candidate) => {\n return candidate.editId === editId;\n });\n if (!override) {\n return;\n }\n clearTimeout(override.registrationTimeout);\n override.sessionId = sessionId;\n override.state = \"fired\";\n const outcome = getSessionOutcomes().get(sessionId);\n if (outcome) {\n removeOverride({ editId, outcome });\n }\n }, []);\n\n const resolveSessionOverrides = useCallback(\n (sessionId: string, outcome: SessionOutcome) => {\n getSessionOutcomes().set(sessionId, outcome);\n window.setTimeout(() => {\n getSessionOutcomes().delete(sessionId);\n }, SESSION_OUTCOME_RETENTION_MS);\n const editIds = getOverrideList()\n .filter((override) => override.sessionId === sessionId)\n .map((override) => override.editId);\n for (const editId of editIds) {\n removeOverride({ editId, outcome });\n }\n },\n [],\n );\n\n const revertOverride = useCallback((editId: string) => {\n removeOverride({ editId, outcome: \"failed\" });\n }, []);\n\n return {\n applyOptimisticUpdate,\n markCommitted,\n reapplyOverrides,\n resolveSessionOverrides,\n revertOverride,\n };\n}\n"],
|
|
5
|
-
"mappings": "AAEA,SAAS,
|
|
4
|
+
"sourcesContent": ["import type { SelectModeOptimisticUpdatePayload } from \"schemas/generated/selectMode\";\n\nimport { canopyTombstoneError } from \"../../../lib/tombstone\";\n\ntype SessionOutcome = \"persisted\" | \"failed\";\n\n/** @deprecated Mount SandboxRuntime from @replohq/sandbox-runtime instead. */\nexport function useOptimisticOverrides(): {\n applyOptimisticUpdate: ({\n editId,\n payload,\n targetSelector,\n targetMode,\n }: {\n editId: string;\n payload: SelectModeOptimisticUpdatePayload;\n targetSelector: string;\n targetMode: \"primary\" | \"group\";\n }) => void;\n markCommitted: (editId: string, sessionId: string) => void;\n reapplyOverrides: ({\n skipElement,\n }: {\n skipElement: HTMLElement | null;\n }) => void;\n resolveSessionOverrides: (sessionId: string, outcome: SessionOutcome) => void;\n revertOverride: (editId: string) => void;\n} {\n throw canopyTombstoneError({\n symbol: \"useOptimisticOverrides\",\n subpath: \"editor/select-mode/hooks/useOptimisticOverrides\",\n replacement: { kind: \"sandbox-runtime\" },\n });\n}\n"],
|
|
5
|
+
"mappings": "AAEA,SAAS,4BAA4B;AAK9B,SAAS,yBAoBd;AACA,QAAM,qBAAqB;AAAA,IACzB,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,aAAa,EAAE,MAAM,kBAAkB;AAAA,EACzC,CAAC;AACH;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,24 +1,6 @@
|
|
|
1
1
|
import type { DisplayMode, SelectModeFormatCommand, SelectModeOptimisticUpdatePayload, SelectModeSelectionType } from "../../../_vendor/schemas/generated/selectMode";
|
|
2
|
-
/**
|
|
3
|
-
|
|
4
|
-
*
|
|
5
|
-
* Listens for Website Builder → canopy methods and applies them locally:
|
|
6
|
-
* - `setDisplayMode`: switch the iframe between `browse` and `selection`.
|
|
7
|
-
* - `setSelectionType`: declarative push of the parent's current
|
|
8
|
-
* selection type. The interesting transition is `* → "none"`, which
|
|
9
|
-
* tears down any in-iframe selection frame / in-progress drag — agent-ui
|
|
10
|
-
* drives it from `agentUiState.selectionType` so panel dismiss / submit
|
|
11
|
-
* flow through the same path as exiting selection mode entirely. The
|
|
12
|
-
* regression test in `EditorSelection.spec.tsx` covers the case where
|
|
13
|
-
* losing this used to lock the iframe out of further selections.
|
|
14
|
-
*
|
|
15
|
-
* Also fires `iframeReady` on mount so the parent knows it's safe to push
|
|
16
|
-
* the initial `setDisplayMode` — without this handshake the parent would
|
|
17
|
-
* race the iframe's mount and the first message could be lost.
|
|
18
|
-
*
|
|
19
|
-
* @author Kevin O'Connell 2026-04-17
|
|
20
|
-
*/
|
|
21
|
-
export declare function useParentMessaging({ applyOptimisticUpdate, markCommitted, resolveSessionOverrides, onEnterEditMode, onExitEditMode, onFormatCommand, revertOverride, setDisplayMode, setSelectionType, }: {
|
|
2
|
+
/** @deprecated Mount SandboxRuntime from @replohq/sandbox-runtime instead. */
|
|
3
|
+
export declare function useParentMessaging(_args: {
|
|
22
4
|
applyOptimisticUpdate?: (input: {
|
|
23
5
|
editId: string;
|
|
24
6
|
payload: SelectModeOptimisticUpdatePayload;
|
|
@@ -1,72 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
function useParentMessaging({
|
|
9
|
-
applyOptimisticUpdate,
|
|
10
|
-
markCommitted,
|
|
11
|
-
resolveSessionOverrides,
|
|
12
|
-
onEnterEditMode,
|
|
13
|
-
onExitEditMode,
|
|
14
|
-
onFormatCommand,
|
|
15
|
-
revertOverride,
|
|
16
|
-
setDisplayMode,
|
|
17
|
-
setSelectionType
|
|
18
|
-
}) {
|
|
19
|
-
useIframeRpcChannel(useMemo(() => getSelectModeIframeRpcChannel(), []));
|
|
20
|
-
useEffect(() => {
|
|
21
|
-
setSelectModeParentHandlers({
|
|
22
|
-
setDisplayMode: ({ displayMode }) => {
|
|
23
|
-
setDisplayMode(displayMode);
|
|
24
|
-
},
|
|
25
|
-
setSelectionType: ({ selectionType }) => {
|
|
26
|
-
setSelectionType(selectionType);
|
|
27
|
-
},
|
|
28
|
-
applyOptimisticUpdate: (message) => {
|
|
29
|
-
applyOptimisticUpdate?.({
|
|
30
|
-
editId: message.editId,
|
|
31
|
-
payload: message.payload,
|
|
32
|
-
targetSelector: message.targetSelector,
|
|
33
|
-
targetMode: message.targetMode
|
|
34
|
-
});
|
|
35
|
-
},
|
|
36
|
-
markCommitted: ({ editId, sessionId }) => {
|
|
37
|
-
markCommitted?.(editId, sessionId);
|
|
38
|
-
},
|
|
39
|
-
resolveSessionOverrides: ({ sessionId, outcome }) => {
|
|
40
|
-
resolveSessionOverrides?.(sessionId, outcome);
|
|
41
|
-
},
|
|
42
|
-
revertOverride: ({ editId }) => {
|
|
43
|
-
revertOverride?.(editId);
|
|
44
|
-
},
|
|
45
|
-
enterEditMode: () => {
|
|
46
|
-
onEnterEditMode?.();
|
|
47
|
-
},
|
|
48
|
-
exitEditMode: () => {
|
|
49
|
-
onExitEditMode?.();
|
|
50
|
-
},
|
|
51
|
-
formatCommand: ({ command }) => {
|
|
52
|
-
onFormatCommand?.(command);
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
getWebsiteBuilderRpc()?.iframeReady(void 0);
|
|
56
|
-
return () => {
|
|
57
|
-
setSelectModeParentHandlers(null);
|
|
58
|
-
};
|
|
59
|
-
}, [
|
|
60
|
-
applyOptimisticUpdate,
|
|
61
|
-
markCommitted,
|
|
62
|
-
resolveSessionOverrides,
|
|
63
|
-
onEnterEditMode,
|
|
64
|
-
onExitEditMode,
|
|
65
|
-
onFormatCommand,
|
|
66
|
-
revertOverride,
|
|
67
|
-
setDisplayMode,
|
|
68
|
-
setSelectionType
|
|
69
|
-
]);
|
|
1
|
+
import { canopyTombstoneError } from "../../../lib/tombstone";
|
|
2
|
+
function useParentMessaging(_args) {
|
|
3
|
+
throw canopyTombstoneError({
|
|
4
|
+
symbol: "useParentMessaging",
|
|
5
|
+
subpath: "editor/select-mode/hooks/useParentMessaging",
|
|
6
|
+
replacement: { kind: "sandbox-runtime" }
|
|
7
|
+
});
|
|
70
8
|
}
|
|
71
9
|
export {
|
|
72
10
|
useParentMessaging
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../editor/select-mode/hooks/useParentMessaging.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["/* oxlint-disable replo/no-void-return-type -- Tombstone declarations preserve exact return types for consumer compatibility. */\n\n// eslint-disable-next-line no-unused-vars -- This type edge keeps the vendored iframe RPC declaration reachable after tombstoning.\nimport type { useIframeRpcChannel } from \"replo-utils/react/use-iframe-rpc-channel\";\nimport type {\n DisplayMode,\n SelectModeFormatCommand,\n SelectModeOptimisticUpdatePayload,\n SelectModeSelectionType,\n} from \"schemas/generated/selectMode\";\n\nimport { canopyTombstoneError } from \"../../../lib/tombstone\";\n\n/** @deprecated Mount SandboxRuntime from @replohq/sandbox-runtime instead. */\nexport function useParentMessaging(_args: {\n applyOptimisticUpdate?: (input: {\n editId: string;\n payload: SelectModeOptimisticUpdatePayload;\n targetSelector: string;\n targetMode: \"primary\" | \"group\";\n }) => void;\n markCommitted?: (editId: string, sessionId: string) => void;\n resolveSessionOverrides?: (\n sessionId: string,\n outcome: \"persisted\" | \"failed\",\n ) => void;\n onEnterEditMode?: () => void;\n onExitEditMode?: () => void;\n onFormatCommand?: (command: SelectModeFormatCommand) => void;\n revertOverride?: (editId: string) => void;\n setDisplayMode: (displayMode: DisplayMode) => void;\n setSelectionType: (selectionType: SelectModeSelectionType) => void;\n}): void {\n throw canopyTombstoneError({\n symbol: \"useParentMessaging\",\n subpath: \"editor/select-mode/hooks/useParentMessaging\",\n replacement: { kind: \"sandbox-runtime\" },\n });\n}\n"],
|
|
5
|
+
"mappings": "AAWA,SAAS,4BAA4B;AAG9B,SAAS,mBAAmB,OAkB1B;AACP,QAAM,qBAAqB;AAAA,IACzB,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,aAAa,EAAE,MAAM,kBAAkB;AAAA,EACzC,CAAC;AACH;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { DisplayMode, SelectModeSelectionType } from "../../../_vendor/schemas/generated/selectMode";
|
|
2
2
|
import type { SelectModeInteractionSession } from "../selectModeSession";
|
|
3
|
+
/** @deprecated Mount SandboxRuntime from @replohq/sandbox-runtime instead. */
|
|
3
4
|
export declare function useSelectModeController(): {
|
|
4
5
|
displayMode: DisplayMode;
|
|
5
|
-
interactionSessionRef:
|
|
6
|
+
interactionSessionRef: React.RefObject<SelectModeInteractionSession>;
|
|
6
7
|
setDisplayMode: (nextDisplayMode: DisplayMode) => void;
|
|
7
8
|
setSelectionType: (selectionType: SelectModeSelectionType) => void;
|
|
8
9
|
};
|
|
@@ -1,44 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { displayModeStore, useDisplayMode } from "../displayModeStore";
|
|
3
|
-
import { getWebsiteBuilderRpc } from "../iframeRpcChannel";
|
|
4
|
-
import { hideSelectionFrame } from "../selectionFrame";
|
|
5
|
-
import { IDLE_SESSION } from "../selectModeSession";
|
|
6
|
-
function resetInteractionSession({
|
|
7
|
-
interactionSessionRef
|
|
8
|
-
}) {
|
|
9
|
-
const currentSession = interactionSessionRef.current;
|
|
10
|
-
if (currentSession.type === "drag" && currentSession.hasExceededThreshold) {
|
|
11
|
-
getWebsiteBuilderRpc()?.dragRectUpdated({
|
|
12
|
-
dragRect: null,
|
|
13
|
-
selectionRects: []
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
hideSelectionFrame();
|
|
17
|
-
interactionSessionRef.current = IDLE_SESSION;
|
|
18
|
-
}
|
|
1
|
+
import { canopyTombstoneError } from "../../../lib/tombstone";
|
|
19
2
|
function useSelectModeController() {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
resetInteractionSession({ interactionSessionRef });
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
[]
|
|
29
|
-
);
|
|
30
|
-
const setDisplayMode = useCallback((nextDisplayMode) => {
|
|
31
|
-
if (displayModeStore.getSnapshot() === "selection" && nextDisplayMode !== "selection") {
|
|
32
|
-
resetInteractionSession({ interactionSessionRef });
|
|
33
|
-
}
|
|
34
|
-
displayModeStore.setDisplayMode(nextDisplayMode);
|
|
35
|
-
}, []);
|
|
36
|
-
return {
|
|
37
|
-
displayMode,
|
|
38
|
-
interactionSessionRef,
|
|
39
|
-
setDisplayMode,
|
|
40
|
-
setSelectionType
|
|
41
|
-
};
|
|
3
|
+
throw canopyTombstoneError({
|
|
4
|
+
symbol: "useSelectModeController",
|
|
5
|
+
subpath: "editor/select-mode/hooks/useSelectModeController",
|
|
6
|
+
replacement: { kind: "sandbox-runtime" }
|
|
7
|
+
});
|
|
42
8
|
}
|
|
43
9
|
export {
|
|
44
10
|
useSelectModeController
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../editor/select-mode/hooks/useSelectModeController.ts"],
|
|
4
|
-
"sourcesContent": ["import type {\n DisplayMode,\n SelectModeSelectionType,\n} from \"schemas/generated/selectMode\";\nimport type { SelectModeInteractionSession } from \"../selectModeSession\";\n\nimport {
|
|
5
|
-
"mappings": "AAMA,SAAS,
|
|
4
|
+
"sourcesContent": ["import type {\n DisplayMode,\n SelectModeSelectionType,\n} from \"schemas/generated/selectMode\";\nimport type { SelectModeInteractionSession } from \"../selectModeSession\";\n\nimport { canopyTombstoneError } from \"../../../lib/tombstone\";\n\n/** @deprecated Mount SandboxRuntime from @replohq/sandbox-runtime instead. */\nexport function useSelectModeController(): {\n displayMode: DisplayMode;\n interactionSessionRef: React.RefObject<SelectModeInteractionSession>;\n setDisplayMode: (nextDisplayMode: DisplayMode) => void;\n setSelectionType: (selectionType: SelectModeSelectionType) => void;\n} {\n throw canopyTombstoneError({\n symbol: \"useSelectModeController\",\n subpath: \"editor/select-mode/hooks/useSelectModeController\",\n replacement: { kind: \"sandbox-runtime\" },\n });\n}\n"],
|
|
5
|
+
"mappings": "AAMA,SAAS,4BAA4B;AAG9B,SAAS,0BAKd;AACA,QAAM,qBAAqB;AAAA,IACzB,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,aAAa,EAAE,MAAM,kBAAkB;AAAA,EACzC,CAAC;AACH;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,22 +1,8 @@
|
|
|
1
1
|
import type { MutableRefObject } from "react";
|
|
2
2
|
import type { DisplayMode } from "../../../_vendor/schemas/generated/selectMode";
|
|
3
3
|
import type { SelectModeInteractionSession } from "../selectModeSession";
|
|
4
|
-
/**
|
|
5
|
-
|
|
6
|
-
* mode and reports its bounding rect to the parent so the parent can render
|
|
7
|
-
* the hover overlay.
|
|
8
|
-
*
|
|
9
|
-
* Two behaviors worth knowing about:
|
|
10
|
-
* - During an active drag we suppress hover updates; the drag overlay is
|
|
11
|
-
* the only highlight we want visible.
|
|
12
|
-
* - On scroll/wheel/resize we re-run the hover lookup from the last known
|
|
13
|
-
* pointer position (we use rAF to coalesce). Without this, scrolling
|
|
14
|
-
* over an already-hovered element wouldn't update the highlight to the
|
|
15
|
-
* new element actually under the cursor.
|
|
16
|
-
*
|
|
17
|
-
* @author Kevin O'Connell 2026-04-17
|
|
18
|
-
*/
|
|
19
|
-
export declare function useSelectionHover({ displayMode, interactionSessionRef, }: {
|
|
4
|
+
/** @deprecated Mount SandboxRuntime from @replohq/sandbox-runtime instead. */
|
|
5
|
+
export declare function useSelectionHover(_args: {
|
|
20
6
|
displayMode: DisplayMode;
|
|
21
7
|
interactionSessionRef: MutableRefObject<SelectModeInteractionSession>;
|
|
22
8
|
}): void;
|