@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.
Files changed (389) hide show
  1. package/_vendor/replo-utils/lib/fonts.mjs +1 -0
  2. package/_vendor/replo-utils/lib/geometry.mjs +2 -0
  3. package/_vendor/replo-utils/lib/json.mjs +1 -0
  4. package/_vendor/replo-utils/lib/misc.mjs +1 -0
  5. package/_vendor/replo-utils/lib/posthogReplay.mjs +2 -0
  6. package/_vendor/replo-utils/lib/url.mjs +1 -0
  7. package/_vendor/replo-utils/react/use-iframe-rpc-channel.mjs +1 -1
  8. package/_vendor/schemas/designLibrary.mjs +1 -1
  9. package/_vendor/schemas/generated/consent.d.ts +2 -0
  10. package/_vendor/schemas/generated/selectModeIframeRpc.d.ts +8 -0
  11. package/_vendor/schemas/iframeRpcChannel.mjs +2 -1
  12. package/_vendor/schemas/loaderKeys.d.ts +1 -1
  13. package/_vendor/schemas/loaderKeys.mjs +103 -23
  14. package/_vendor/schemas/money.mjs +1860 -3
  15. package/_vendor/schemas/pageAnnotations.mjs +1 -1
  16. package/_vendor/schemas/routing/match.mjs +1 -0
  17. package/_vendor/schemas/routing/rules.mjs +2 -1
  18. package/_vendor/schemas/selectMode.d.ts +4 -4
  19. package/_vendor/schemas/selectMode.mjs +1 -0
  20. package/_vendor/schemas/selectModeIframeRpc.d.ts +25 -5
  21. package/_vendor/schemas/selectModeIframeRpc.mjs +12 -3
  22. package/analytics/analytics-provider.d.ts +5 -10
  23. package/analytics/analytics-provider.js +14 -101
  24. package/analytics/analytics-provider.js.map +2 -2
  25. package/analytics/get-analytics-sinks.d.ts +2 -19
  26. package/analytics/get-analytics-sinks.js +9 -46
  27. package/analytics/get-analytics-sinks.js.map +2 -2
  28. package/analytics/hooks/use-product-viewed-analytics.d.ts +2 -6
  29. package/analytics/hooks/use-product-viewed-analytics.js +6 -28
  30. package/analytics/hooks/use-product-viewed-analytics.js.map +2 -2
  31. package/analytics/replo-first-party-pixel.d.ts +3 -12
  32. package/analytics/replo-first-party-pixel.js +8 -24
  33. package/analytics/replo-first-party-pixel.js.map +2 -2
  34. package/analytics/replo-pixel-script.d.ts +4 -10
  35. package/analytics/replo-pixel-script.js +9 -23
  36. package/analytics/replo-pixel-script.js.map +2 -2
  37. package/analytics/sinks/ga4-sink.d.ts +10 -9
  38. package/analytics/sinks/ga4-sink.js +99 -50
  39. package/analytics/sinks/ga4-sink.js.map +2 -2
  40. package/analytics/sinks/meta-sink.d.ts +5 -4
  41. package/analytics/sinks/meta-sink.js +82 -29
  42. package/analytics/sinks/meta-sink.js.map +2 -2
  43. package/analytics/sinks/pinterest-sink.d.ts +7 -6
  44. package/analytics/sinks/pinterest-sink.js +82 -49
  45. package/analytics/sinks/pinterest-sink.js.map +2 -2
  46. package/analytics/sinks/reddit-sink.d.ts +8 -7
  47. package/analytics/sinks/reddit-sink.js +82 -53
  48. package/analytics/sinks/reddit-sink.js.map +2 -2
  49. package/analytics/sinks/replo-sink.d.ts +9 -8
  50. package/analytics/sinks/replo-sink.js +89 -37
  51. package/analytics/sinks/replo-sink.js.map +2 -2
  52. package/analytics/sinks/snapchat-sink.d.ts +6 -5
  53. package/analytics/sinks/snapchat-sink.js +82 -40
  54. package/analytics/sinks/snapchat-sink.js.map +2 -2
  55. package/analytics/sinks/tiktok-sink.d.ts +8 -7
  56. package/analytics/sinks/tiktok-sink.js +82 -52
  57. package/analytics/sinks/tiktok-sink.js.map +2 -2
  58. package/analytics/sinks/window-sink.d.ts +11 -14
  59. package/analytics/sinks/window-sink.js +101 -28
  60. package/analytics/sinks/window-sink.js.map +2 -2
  61. package/analytics/utils/analytics-utils.d.ts +4 -2
  62. package/analytics/utils/analytics-utils.js +19 -123
  63. package/analytics/utils/analytics-utils.js.map +2 -2
  64. package/analytics/utils/navigation-tracker.d.ts +2 -1
  65. package/analytics/utils/navigation-tracker.js +37 -30
  66. package/analytics/utils/navigation-tracker.js.map +2 -2
  67. package/analytics/utils/shopify-funnel-gate.d.ts +2 -7
  68. package/analytics/utils/shopify-funnel-gate.js +8 -15
  69. package/analytics/utils/shopify-funnel-gate.js.map +2 -2
  70. package/cart/buy-now-action.d.ts +2 -9
  71. package/cart/buy-now-action.js +5 -97
  72. package/cart/buy-now-action.js.map +2 -2
  73. package/cart/cart-actions.d.ts +12 -56
  74. package/cart/cart-actions.js +88 -68
  75. package/cart/cart-actions.js.map +2 -2
  76. package/cart/cart-loader.d.ts +3 -9
  77. package/cart/cart-loader.js +14 -6
  78. package/cart/cart-loader.js.map +2 -2
  79. package/cart/cart-provider.d.ts +6 -58
  80. package/cart/cart-provider.js +13 -359
  81. package/cart/cart-provider.js.map +3 -3
  82. package/cart/cart-schema.d.ts +2 -1
  83. package/cart/cart-schema.js +12 -64
  84. package/cart/cart-schema.js.map +2 -2
  85. package/cart/cart-types.d.ts +1 -1
  86. package/cart/cart-types.js +5 -4
  87. package/cart/cart-types.js.map +2 -2
  88. package/cart/gateways/cart-constants.d.ts +1 -0
  89. package/cart/gateways/cart-constants.js.map +2 -2
  90. package/cart/gateways/cart-gateway.d.ts +1 -0
  91. package/cart/gateways/cart-gateway.js +13 -12
  92. package/cart/gateways/cart-gateway.js.map +2 -2
  93. package/cart/gateways/cookie-cart-gateway.d.ts +8 -11
  94. package/cart/gateways/cookie-cart-gateway.js +93 -97
  95. package/cart/gateways/cookie-cart-gateway.js.map +2 -2
  96. package/cart/gateways/default-cart-gateway.d.ts +10 -16
  97. package/cart/gateways/default-cart-gateway.js +13 -23
  98. package/cart/gateways/default-cart-gateway.js.map +2 -2
  99. package/cart/gateways/resolver-cart-gateway.d.ts +1 -0
  100. package/cart/gateways/resolver-cart-gateway.js +13 -102
  101. package/cart/gateways/resolver-cart-gateway.js.map +2 -2
  102. package/cart/gateways/stripe-cart-gateway.d.ts +10 -16
  103. package/cart/gateways/stripe-cart-gateway.js +13 -21
  104. package/cart/gateways/stripe-cart-gateway.js.map +2 -2
  105. package/cart/hooks/use-add-to-cart.d.ts +3 -47
  106. package/cart/hooks/use-add-to-cart.js +10 -115
  107. package/cart/hooks/use-add-to-cart.js.map +2 -2
  108. package/cart/hooks/use-buy-now.d.ts +1 -39
  109. package/cart/hooks/use-buy-now.js +5 -55
  110. package/cart/hooks/use-buy-now.js.map +2 -2
  111. package/cart/utils/cart-utils.d.ts +8 -35
  112. package/cart/utils/cart-utils.js +21 -35
  113. package/cart/utils/cart-utils.js.map +2 -2
  114. package/cart/utils/cookie-cart-persistence.d.ts +16 -41
  115. package/cart/utils/cookie-cart-persistence.js +38 -143
  116. package/cart/utils/cookie-cart-persistence.js.map +2 -2
  117. package/cart/utils/variant-to-cart-line.d.ts +12 -42
  118. package/cart/utils/variant-to-cart-line.js +31 -147
  119. package/cart/utils/variant-to-cart-line.js.map +2 -2
  120. package/chunk-UJCSKKID.mjs +27 -0
  121. package/{chunk-OFU2QEDR.mjs → chunk-ZZPQ3E7S.mjs} +50 -5
  122. package/consent/consent-action.d.ts +2 -1
  123. package/consent/consent-action.js +10 -20
  124. package/consent/consent-action.js.map +2 -2
  125. package/consent/consent-actions.d.ts +2 -13
  126. package/consent/consent-actions.js +9 -29
  127. package/consent/consent-actions.js.map +2 -2
  128. package/consent/consent-store.d.ts +9 -36
  129. package/consent/consent-store.js +12 -182
  130. package/consent/consent-store.js.map +2 -2
  131. package/consent/cookie.d.ts +9 -12
  132. package/consent/cookie.js +32 -64
  133. package/consent/cookie.js.map +2 -2
  134. package/consent/replo-scripts.d.ts +5 -18
  135. package/consent/replo-scripts.js +11 -94
  136. package/consent/replo-scripts.js.map +2 -2
  137. package/consent/script-registration-store.d.ts +6 -2
  138. package/consent/script-registration-store.js +33 -47
  139. package/consent/script-registration-store.js.map +2 -2
  140. package/consent/script-snippets.d.ts +4 -18
  141. package/consent/script-snippets.js +19 -127
  142. package/consent/script-snippets.js.map +2 -2
  143. package/consent/window-api.d.ts +4 -15
  144. package/consent/window-api.js +8 -63
  145. package/consent/window-api.js.map +2 -2
  146. package/editor/ClientErrorBoundary.d.ts +4 -10
  147. package/editor/ClientErrorBoundary.js +7 -55
  148. package/editor/ClientErrorBoundary.js.map +2 -2
  149. package/editor/DocumentReadyBeacon.d.ts +3 -1
  150. package/editor/DocumentReadyBeacon.js +6 -3
  151. package/editor/DocumentReadyBeacon.js.map +2 -2
  152. package/editor/LinkInterceptor.d.ts +1 -0
  153. package/editor/LinkInterceptor.js +6 -121
  154. package/editor/LinkInterceptor.js.map +2 -2
  155. package/editor/NextErrorReporter.d.ts +1 -0
  156. package/editor/NextErrorReporter.js +6 -85
  157. package/editor/NextErrorReporter.js.map +2 -2
  158. package/editor/annotations/AnnotationLayerMount.d.ts +1 -0
  159. package/editor/annotations/AnnotationLayerMount.js +6 -6
  160. package/editor/annotations/AnnotationLayerMount.js.map +2 -2
  161. package/editor/annotations/annotationController.d.ts +1 -0
  162. package/editor/annotations/annotationController.js +6 -378
  163. package/editor/annotations/annotationController.js.map +2 -2
  164. package/editor/annotations/bridgeGate.d.ts +4 -7
  165. package/editor/annotations/bridgeGate.js +13 -15
  166. package/editor/annotations/bridgeGate.js.map +2 -2
  167. package/editor/design-library-preview/DesignLibraryPreview.d.ts +1 -0
  168. package/editor/design-library-preview/DesignLibraryPreview.js +6 -86
  169. package/editor/design-library-preview/DesignLibraryPreview.js.map +2 -2
  170. package/editor/posthog-relay.d.ts +1 -10
  171. package/editor/posthog-relay.js +6 -65
  172. package/editor/posthog-relay.js.map +2 -2
  173. package/editor/select-mode/EditorSelection.d.ts +1 -23
  174. package/editor/select-mode/EditorSelection.js +5 -87
  175. package/editor/select-mode/EditorSelection.js.map +2 -2
  176. package/editor/select-mode/annotationFrames.d.ts +9 -9
  177. package/editor/select-mode/annotationFrames.js +22 -103
  178. package/editor/select-mode/annotationFrames.js.map +2 -2
  179. package/editor/select-mode/descriptor/elementDescriptor.d.ts +6 -21
  180. package/editor/select-mode/descriptor/elementDescriptor.js +19 -192
  181. package/editor/select-mode/descriptor/elementDescriptor.js.map +3 -3
  182. package/editor/select-mode/descriptor/styleExtraction.d.ts +4 -2
  183. package/editor/select-mode/descriptor/styleExtraction.js +11 -262
  184. package/editor/select-mode/descriptor/styleExtraction.js.map +2 -2
  185. package/editor/select-mode/displayModeStore.d.ts +2 -0
  186. package/editor/select-mode/displayModeStore.js +14 -39
  187. package/editor/select-mode/displayModeStore.js.map +2 -2
  188. package/editor/select-mode/fast-refresh-relay.d.ts +2 -1
  189. package/editor/select-mode/fast-refresh-relay.js +7 -28
  190. package/editor/select-mode/fast-refresh-relay.js.map +2 -2
  191. package/editor/select-mode/fiber.d.ts +14 -7
  192. package/editor/select-mode/fiber.js +40 -286
  193. package/editor/select-mode/fiber.js.map +2 -2
  194. package/editor/select-mode/hooks/useCrosshairCursor.d.ts +2 -9
  195. package/editor/select-mode/hooks/useCrosshairCursor.js +7 -15
  196. package/editor/select-mode/hooks/useCrosshairCursor.js.map +2 -2
  197. package/editor/select-mode/hooks/useEditModeStateMachine.d.ts +5 -3
  198. package/editor/select-mode/hooks/useEditModeStateMachine.js +13 -228
  199. package/editor/select-mode/hooks/useEditModeStateMachine.js.map +2 -2
  200. package/editor/select-mode/hooks/useOptimisticOverrides.d.ts +2 -1
  201. package/editor/select-mode/hooks/useOptimisticOverrides.js +6 -277
  202. package/editor/select-mode/hooks/useOptimisticOverrides.js.map +2 -2
  203. package/editor/select-mode/hooks/useParentMessaging.d.ts +2 -20
  204. package/editor/select-mode/hooks/useParentMessaging.js +7 -69
  205. package/editor/select-mode/hooks/useParentMessaging.js.map +2 -2
  206. package/editor/select-mode/hooks/useSelectModeController.d.ts +2 -1
  207. package/editor/select-mode/hooks/useSelectModeController.js +6 -40
  208. package/editor/select-mode/hooks/useSelectModeController.js.map +2 -2
  209. package/editor/select-mode/hooks/useSelectionHover.d.ts +2 -16
  210. package/editor/select-mode/hooks/useSelectionHover.js +7 -105
  211. package/editor/select-mode/hooks/useSelectionHover.js.map +2 -2
  212. package/editor/select-mode/hooks/useSelectionInteractions.d.ts +2 -26
  213. package/editor/select-mode/hooks/useSelectionInteractions.js +7 -348
  214. package/editor/select-mode/hooks/useSelectionInteractions.js.map +2 -2
  215. package/editor/select-mode/hooks/useSelectionScrollSync.d.ts +2 -22
  216. package/editor/select-mode/hooks/useSelectionScrollSync.js +7 -65
  217. package/editor/select-mode/hooks/useSelectionScrollSync.js.map +2 -2
  218. package/editor/select-mode/hooks/useSiblingResolution.d.ts +4 -2
  219. package/editor/select-mode/hooks/useSiblingResolution.js +13 -52
  220. package/editor/select-mode/hooks/useSiblingResolution.js.map +2 -2
  221. package/editor/select-mode/iframeRpcChannel.d.ts +10 -349
  222. package/editor/select-mode/iframeRpcChannel.js +23 -79
  223. package/editor/select-mode/iframeRpcChannel.js.map +2 -2
  224. package/editor/select-mode/inlineTextMarks.d.ts +4 -6
  225. package/editor/select-mode/inlineTextMarks.js +13 -18
  226. package/editor/select-mode/inlineTextMarks.js.map +2 -2
  227. package/editor/select-mode/interactions/selectionGeometry.d.ts +19 -61
  228. package/editor/select-mode/interactions/selectionGeometry.js +57 -165
  229. package/editor/select-mode/interactions/selectionGeometry.js.map +2 -2
  230. package/editor/select-mode/selectModeSession.d.ts +1 -0
  231. package/editor/select-mode/selectModeSession.js +6 -3
  232. package/editor/select-mode/selectModeSession.js.map +2 -2
  233. package/editor/select-mode/selectionFrame.d.ts +9 -60
  234. package/editor/select-mode/selectionFrame.js +28 -116
  235. package/editor/select-mode/selectionFrame.js.map +2 -2
  236. package/editor/select-mode/symbolicate.d.ts +2 -1
  237. package/editor/select-mode/symbolicate.js +7 -195
  238. package/editor/select-mode/symbolicate.js.map +2 -2
  239. package/editor/select-mode/tiptapInlineEditor.d.ts +15 -2
  240. package/editor/select-mode/tiptapInlineEditor.js +6 -114
  241. package/editor/select-mode/tiptapInlineEditor.js.map +2 -2
  242. package/env.d.ts +2 -1
  243. package/env.js +10 -37
  244. package/env.js.map +2 -2
  245. package/gateways/canopy-api.d.ts +15 -12
  246. package/gateways/canopy-api.js +122 -160
  247. package/gateways/canopy-api.js.map +2 -2
  248. package/hooks/use-client-value.d.ts +2 -10
  249. package/hooks/use-client-value.js +10 -7
  250. package/hooks/use-client-value.js.map +2 -2
  251. package/hooks/use-formatted-price.d.ts +1 -14
  252. package/hooks/use-formatted-price.js +6 -14
  253. package/hooks/use-formatted-price.js.map +2 -2
  254. package/lib/canopy-error.d.ts +2 -5
  255. package/lib/canopy-error.js +10 -14
  256. package/lib/canopy-error.js.map +2 -2
  257. package/lib/get-query-client.d.ts +2 -1
  258. package/lib/get-query-client.js +8 -27
  259. package/lib/get-query-client.js.map +2 -2
  260. package/lib/integration-utils.d.ts +1 -0
  261. package/lib/integration-utils.js +9 -3
  262. package/lib/integration-utils.js.map +2 -2
  263. package/lib/shopify-utils.d.ts +2 -10
  264. package/lib/shopify-utils.js +10 -2
  265. package/lib/shopify-utils.js.map +2 -2
  266. package/lib/tombstone.d.ts +21 -0
  267. package/lib/tombstone.js +99 -0
  268. package/lib/tombstone.js.map +7 -0
  269. package/lib/url-utils.d.ts +2 -4
  270. package/lib/url-utils.js +10 -3
  271. package/lib/url-utils.js.map +2 -2
  272. package/loaders/collection-loader.d.ts +3 -2
  273. package/loaders/collection-loader.js +5 -48
  274. package/loaders/collection-loader.js.map +2 -2
  275. package/loaders/collection-products-loader.d.ts +3 -2
  276. package/loaders/collection-products-loader.js +5 -51
  277. package/loaders/collection-products-loader.js.map +2 -2
  278. package/loaders/contentful-entries-loader.d.ts +3 -2
  279. package/loaders/contentful-entries-loader.js +5 -71
  280. package/loaders/contentful-entries-loader.js.map +2 -2
  281. package/loaders/contentful-entry-loader.d.ts +3 -2
  282. package/loaders/contentful-entry-loader.js +5 -53
  283. package/loaders/contentful-entry-loader.js.map +2 -2
  284. package/loaders/invoke-loader-action.d.ts +2 -8
  285. package/loaders/invoke-loader-action.js +13 -8
  286. package/loaders/invoke-loader-action.js.map +2 -2
  287. package/loaders/invoke-loader-server.d.ts +2 -14
  288. package/loaders/invoke-loader-server.js +12 -34
  289. package/loaders/invoke-loader-server.js.map +2 -2
  290. package/loaders/invoke-loader.d.ts +6 -12
  291. package/loaders/invoke-loader.js +27 -29
  292. package/loaders/invoke-loader.js.map +2 -2
  293. package/loaders/levanta-product-loader.d.ts +3 -2
  294. package/loaders/levanta-product-loader.js +5 -46
  295. package/loaders/levanta-product-loader.js.map +2 -2
  296. package/loaders/loader-error-boundary.d.ts +9 -15
  297. package/loaders/loader-error-boundary.js +50 -13
  298. package/loaders/loader-error-boundary.js.map +2 -2
  299. package/loaders/loader-keys.d.ts +4 -12
  300. package/loaders/loader-keys.js +6 -1
  301. package/loaders/loader-keys.js.map +2 -2
  302. package/loaders/loader-schemas.d.ts +142 -61
  303. package/loaders/loader-schemas.js +253 -90
  304. package/loaders/loader-schemas.js.map +2 -2
  305. package/loaders/metaobject-loader.d.ts +3 -2
  306. package/loaders/metaobject-loader.js +5 -47
  307. package/loaders/metaobject-loader.js.map +2 -2
  308. package/loaders/metaobjects-loader.d.ts +3 -2
  309. package/loaders/metaobjects-loader.js +5 -53
  310. package/loaders/metaobjects-loader.js.map +2 -2
  311. package/loaders/okendo-review-aggregate-loader.d.ts +9 -10
  312. package/loaders/okendo-review-aggregate-loader.js +5 -49
  313. package/loaders/okendo-review-aggregate-loader.js.map +2 -2
  314. package/loaders/okendo-reviews-loader.d.ts +8 -16
  315. package/loaders/okendo-reviews-loader.js +5 -47
  316. package/loaders/okendo-reviews-loader.js.map +2 -2
  317. package/loaders/prefetch-loaders.d.ts +4 -26
  318. package/loaders/prefetch-loaders.js +5 -40
  319. package/loaders/prefetch-loaders.js.map +2 -2
  320. package/loaders/preview-placeholder.d.ts +8 -22
  321. package/loaders/preview-placeholder.js +47 -209
  322. package/loaders/preview-placeholder.js.map +2 -2
  323. package/loaders/product-loader-args.d.ts +2 -11
  324. package/loaders/product-loader-args.js +6 -12
  325. package/loaders/product-loader-args.js.map +2 -2
  326. package/loaders/product-loader.d.ts +3 -2
  327. package/loaders/product-loader.js +5 -45
  328. package/loaders/product-loader.js.map +2 -2
  329. package/loaders/rebuy-recommendations-loader.d.ts +8 -157
  330. package/loaders/rebuy-recommendations-loader.js +5 -50
  331. package/loaders/rebuy-recommendations-loader.js.map +2 -2
  332. package/loaders/reviews-io-review-aggregate-loader.d.ts +5 -4
  333. package/loaders/reviews-io-review-aggregate-loader.js +5 -36
  334. package/loaders/reviews-io-review-aggregate-loader.js.map +2 -2
  335. package/loaders/reviews-io-reviews-loader.d.ts +5 -4
  336. package/loaders/reviews-io-reviews-loader.js +5 -58
  337. package/loaders/reviews-io-reviews-loader.js.map +2 -2
  338. package/loaders/smile-earning-rules-loader.d.ts +10 -11
  339. package/loaders/smile-earning-rules-loader.js +5 -37
  340. package/loaders/smile-earning-rules-loader.js.map +2 -2
  341. package/loaders/smile-rewards-loader.d.ts +10 -11
  342. package/loaders/smile-rewards-loader.js +5 -37
  343. package/loaders/smile-rewards-loader.js.map +2 -2
  344. package/loaders/smile-vip-tiers-loader.d.ts +9 -10
  345. package/loaders/smile-vip-tiers-loader.js +5 -36
  346. package/loaders/smile-vip-tiers-loader.js.map +2 -2
  347. package/loaders/statsig-experiment-loader.d.ts +3 -8
  348. package/loaders/statsig-experiment-loader.js +5 -74
  349. package/loaders/statsig-experiment-loader.js.map +2 -2
  350. package/loaders/vendor-loader-keys.d.ts +4 -0
  351. package/loaders/vendor-loader-keys.js +9 -0
  352. package/loaders/vendor-loader-keys.js.map +7 -0
  353. package/loaders/yotpo-review-aggregate-loader.d.ts +5 -4
  354. package/loaders/yotpo-review-aggregate-loader.js +5 -43
  355. package/loaders/yotpo-review-aggregate-loader.js.map +2 -2
  356. package/loaders/yotpo-reviews-loader.d.ts +5 -4
  357. package/loaders/yotpo-reviews-loader.js +5 -58
  358. package/loaders/yotpo-reviews-loader.js.map +2 -2
  359. package/money.d.ts +9 -9
  360. package/money.js +25 -6
  361. package/money.js.map +2 -2
  362. package/next/config.d.ts +3 -1
  363. package/next/config.js +11 -85
  364. package/next/config.js.map +2 -2
  365. package/next/image-loader.d.ts +2 -1
  366. package/next/image-loader.js +7 -47
  367. package/next/image-loader.js.map +2 -2
  368. package/next/open-next.d.ts +4 -2
  369. package/next/open-next.js +6 -19
  370. package/next/open-next.js.map +2 -2
  371. package/orders/order-status-schema.d.ts +28 -13
  372. package/orders/order-status-schema.js +45 -13
  373. package/orders/order-status-schema.js.map +2 -2
  374. package/orders/order-status.d.ts +2 -8
  375. package/orders/order-status.js +6 -36
  376. package/orders/order-status.js.map +2 -2
  377. package/package.json +1 -12
  378. package/providers/query-provider.d.ts +3 -1
  379. package/providers/query-provider.js +10 -6
  380. package/providers/query-provider.js.map +2 -2
  381. package/providers/replo-provider.d.ts +3 -1
  382. package/providers/replo-provider.js +6 -37
  383. package/providers/replo-provider.js.map +2 -2
  384. package/routing/evaluate.d.ts +3 -3
  385. package/routing/evaluate.js +5 -40
  386. package/routing/evaluate.js.map +2 -2
  387. package/routing/rules.d.ts +3 -11
  388. package/routing/rules.js +7 -1
  389. 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": ["/**\n * In-iframe annotation frame renderer \u2014 `selectionFrame`'s sibling surface.\n *\n * Same architecture and reasons as selection frames (see selectionFrame.ts):\n * page-coordinate `position: absolute` nodes in a body-level container, so\n * document scroll translates them with zero JavaScript per scroll frame, and\n * styling is vanilla inline CSS because customer pages have no tailwind.\n *\n * An annotation frame is an invisible positioning box over the annotated\n * element carrying a numbered badge dot \u2014 the dot is the entire visual.\n * Unlike selection frames these rebuild wholesale on each call: re-renders\n * happen on set/re-measure (rare), never per scroll, so pooling buys nothing.\n */\nimport { getOrCreateFramesLayerContainer } from \"./selectionFrame\";\n\nexport const ANNOTATION_CONTAINER_ID = \"replo-annotation-frames\";\nconst ANNOTATION_FONT_STYLE_ID = \"replo-annotation-font\";\nconst BADGE_SIZE_PX = 30;\n// The badge numerals use the same PP Editorial the editor brand uses, served\n// from the CDN asset the editor already loads \u2014 no font bytes ship in canopy,\n// and this layer only exists in dev previews. `swap` degrades to Georgia.\nconst EDITORIAL_ITALIC_FONT_URL =\n \"https://assets.replocdn.com/PPEditorialNew-Italic.woff2\";\nconst BADGE_FONT =\n 'italic 400 16px/1 \"PP Editorial New\", Georgia, \"Times New Roman\", serif';\n\nfunction ensureBadgeFont() {\n if (document.getElementById(ANNOTATION_FONT_STYLE_ID)) {\n return;\n }\n const style = document.createElement(\"style\");\n style.id = ANNOTATION_FONT_STYLE_ID;\n style.textContent = `@font-face{font-family:\"PP Editorial New\";src:url(\"${EDITORIAL_ITALIC_FONT_URL}\") format(\"woff2\");font-weight:normal;font-style:italic;font-display:swap;}`;\n document.head.append(style);\n}\n\ninterface AnnotationRect {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\nexport interface AnnotationFrameSpec {\n id: string;\n pageRect: AnnotationRect;\n badgeCenter: { x: number; y: number };\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\nconst badgeNodesById = new Map<string, HTMLButtonElement>();\nlet activeBadgeId: string | null = null;\n\nfunction badgeRestingTransform(id: string): string {\n return id === activeBadgeId ? \"scale(1.15)\" : \"scale(1)\";\n}\n\n/**\n * Style-only selection update: rebuilding the node pool mid-interaction would\n * race the pointer sequence and swallow the click, so the active state never\n * re-renders \u2014 it just retargets transforms on the existing nodes.\n */\nexport function setActiveAnnotationBadge(id: string | null) {\n activeBadgeId = id;\n for (const [badgeId, badge] of badgeNodesById) {\n badge.style.transform = badgeRestingTransform(badgeId);\n }\n}\n\nexport function getAnnotationBadgeViewportRect(\n id: string,\n): AnnotationRect | null {\n const badge = badgeNodesById.get(id);\n if (!badge?.isConnected) {\n return null;\n }\n const rect = badge.getBoundingClientRect();\n return { x: rect.x, y: rect.y, width: rect.width, height: rect.height };\n}\n\nfunction createFrameNode(spec: AnnotationFrameSpec): HTMLDivElement {\n const frame = document.createElement(\"div\");\n frame.style.cssText = [\n `position: ${spec.positioning}`,\n `left: ${spec.pageRect.x}px`,\n `top: ${spec.pageRect.y}px`,\n \"width: 0\",\n \"height: 0\",\n \"pointer-events: none\",\n \"margin: 0\",\n \"padding: 0\",\n ].join(\";\");\n\n const badge = document.createElement(\"button\");\n badge.type = \"button\";\n badge.setAttribute(\"aria-label\", spec.badgeAriaLabel);\n badge.textContent = spec.badgeLabel;\n badge.style.cssText = [\n \"position: absolute\",\n `left: ${spec.badgeCenter.x - spec.pageRect.x - BADGE_SIZE_PX / 2}px`,\n `top: ${spec.badgeCenter.y - spec.pageRect.y - BADGE_SIZE_PX / 2}px`,\n `width: ${BADGE_SIZE_PX}px`,\n `height: ${BADGE_SIZE_PX}px`,\n \"display: flex\",\n \"align-items: center\",\n \"justify-content: center\",\n \"border: none\",\n \"border-radius: 50%\",\n `background: ${spec.colorHex}`,\n \"color: #ffffff\",\n `font: ${BADGE_FONT}`,\n \"box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.9), 0 1px 3px rgba(0, 0, 0, 0.18)\",\n `transform: scale(${spec.isActive ? 1.15 : 1})`,\n \"transition: transform 120ms ease-out\",\n \"cursor: pointer\",\n \"pointer-events: auto\",\n \"margin: 0\",\n \"padding: 0 0 1px 0\",\n ].join(\";\");\n badge.addEventListener(\"pointerdown\", () => {\n badge.style.transform = \"scale(0.9)\";\n });\n badge.addEventListener(\"pointerup\", () => {\n badge.style.transform = badgeRestingTransform(spec.id);\n });\n badge.addEventListener(\"pointerleave\", () => {\n badge.style.transform = badgeRestingTransform(spec.id);\n });\n badge.addEventListener(\"click\", (event) => {\n event.stopPropagation();\n spec.onBadgeClick();\n });\n\n frame.append(badge);\n badgeNodesById.set(spec.id, badge);\n return frame;\n}\n\nexport function showAnnotationFrames({\n frames,\n}: {\n frames: AnnotationFrameSpec[];\n}) {\n const container = getOrCreateFramesLayerContainer({\n id: ANNOTATION_CONTAINER_ID,\n zIndex: 2147483645,\n });\n if (!container) {\n return;\n }\n ensureBadgeFont();\n activeBadgeId = frames.find((spec) => spec.isActive)?.id ?? null;\n badgeNodesById.clear();\n container.replaceChildren(...frames.map((spec) => createFrameNode(spec)));\n}\n\nexport function clearAnnotationFrames() {\n badgeNodesById.clear();\n if (typeof document === \"undefined\") {\n return;\n }\n document.getElementById(ANNOTATION_CONTAINER_ID)?.replaceChildren();\n}\n"],
5
- "mappings": "AAaA,SAAS,uCAAuC;AAEzC,MAAM,0BAA0B;AACvC,MAAM,2BAA2B;AACjC,MAAM,gBAAgB;AAItB,MAAM,4BACJ;AACF,MAAM,aACJ;AAEF,SAAS,kBAAkB;AACzB,MAAI,SAAS,eAAe,wBAAwB,GAAG;AACrD;AAAA,EACF;AACA,QAAM,QAAQ,SAAS,cAAc,OAAO;AAC5C,QAAM,KAAK;AACX,QAAM,cAAc,sDAAsD,yBAAyB;AACnG,WAAS,KAAK,OAAO,KAAK;AAC5B;AAuBA,MAAM,iBAAiB,oBAAI,IAA+B;AAC1D,IAAI,gBAA+B;AAEnC,SAAS,sBAAsB,IAAoB;AACjD,SAAO,OAAO,gBAAgB,gBAAgB;AAChD;AAOO,SAAS,yBAAyB,IAAmB;AAC1D,kBAAgB;AAChB,aAAW,CAAC,SAAS,KAAK,KAAK,gBAAgB;AAC7C,UAAM,MAAM,YAAY,sBAAsB,OAAO;AAAA,EACvD;AACF;AAEO,SAAS,+BACd,IACuB;AACvB,QAAM,QAAQ,eAAe,IAAI,EAAE;AACnC,MAAI,CAAC,OAAO,aAAa;AACvB,WAAO;AAAA,EACT;AACA,QAAM,OAAO,MAAM,sBAAsB;AACzC,SAAO,EAAE,GAAG,KAAK,GAAG,GAAG,KAAK,GAAG,OAAO,KAAK,OAAO,QAAQ,KAAK,OAAO;AACxE;AAEA,SAAS,gBAAgB,MAA2C;AAClE,QAAM,QAAQ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AAI,KAAK,IAAI,KAAK;AACjC,SAAO;AACT;AAEO,SAAS,qBAAqB;AAAA,EACnC;AACF,GAEG;AACD,QAAM,YAAY,gCAAgC;AAAA,IAChD,IAAI;AAAA,IACJ,QAAQ;AAAA,EACV,CAAC;AACD,MAAI,CAAC,WAAW;AACd;AAAA,EACF;AACA,kBAAgB;AAChB,kBAAgB,OAAO,KAAK,CAAC,SAAS,KAAK,QAAQ,GAAG,MAAM;AAC5D,iBAAe,MAAM;AACrB,YAAU,gBAAgB,GAAG,OAAO,IAAI,CAAC,SAAS,gBAAgB,IAAI,CAAC,CAAC;AAC1E;AAEO,SAAS,wBAAwB;AACtC,iBAAe,MAAM;AACrB,MAAI,OAAO,aAAa,aAAa;AACnC;AAAA,EACF;AACA,WAAS,eAAe,uBAAuB,GAAG,gBAAgB;AACpE;",
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
- * Element that should own a click/hover selection: skip TipTap/inline JSX
4
- * mark wrappers, then prefer an explicit selectable boundary when present.
5
- */
6
- export declare function getNearestSelectableElement(element: Element): Element;
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
- readSelectablePayload,
3
- SELECT_MODE_SELECTABLE_ATTRIBUTE,
4
- SELECT_MODE_SELECTABLE_PAYLOAD_ATTRIBUTE
5
- } from "../../../_vendor/schemas/selectMode.mjs";
6
- import { getFiberChain } from "../fiber";
7
- import { skipInlineTextMarkElements } from "../inlineTextMarks";
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 getSelectableDataFromElement(element) {
15
- const selectableElement = element.closest(
16
- `[${SELECT_MODE_SELECTABLE_ATTRIBUTE}]`
17
- );
18
- if (!selectableElement) {
19
- return null;
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 identifyElement(element) {
33
- const tagName = element.tagName.toLowerCase();
34
- if (tagName === "button" || element.getAttribute("role") === "button" || tagName === "input") {
35
- const trimmedText2 = element.textContent?.trim();
36
- if (trimmedText2) {
37
- return `${tagName}: "${trimmedText2.slice(0, 60)}"`;
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 SelectModeTextMetrics,\n} from \"schemas/generated/selectMode\";\n\nimport {\n readSelectablePayload,\n SELECT_MODE_SELECTABLE_ATTRIBUTE,\n SELECT_MODE_SELECTABLE_PAYLOAD_ATTRIBUTE,\n} from \"schemas/selectMode\";\n\nimport { getFiberChain } from \"../fiber\";\nimport { skipInlineTextMarkElements } from \"../inlineTextMarks\";\nimport { getElementBoundingRect } from \"../interactions/selectionGeometry\";\nimport { getDefinedStyles, getInheritedStyles } from \"./styleExtraction\";\n\n/**\n * Element that should own a click/hover selection: skip TipTap/inline JSX\n * mark wrappers, then prefer an explicit selectable boundary when present.\n */\nexport function getNearestSelectableElement(element: Element): Element {\n const host = skipInlineTextMarkElements(element);\n return host.closest(`[${SELECT_MODE_SELECTABLE_ATTRIBUTE}]`) ?? host;\n}\n\nfunction getSelectableDataFromElement(element: Element): SelectableData | null {\n const selectableElement = element.closest(\n `[${SELECT_MODE_SELECTABLE_ATTRIBUTE}]`,\n );\n if (!selectableElement) {\n return null;\n }\n\n const selectablePayload = readSelectablePayload(\n selectableElement.getAttribute(SELECT_MODE_SELECTABLE_PAYLOAD_ATTRIBUTE),\n );\n if (!selectablePayload) {\n return null;\n }\n\n return {\n ...selectablePayload,\n rect: getElementBoundingRect(selectableElement),\n };\n}\n\n/**\n * Produce a short human-readable label for an element (used in chat tokens\n * and prompt context). Tag-aware so a `<button>` reads as `button: \"Save\"`\n * rather than just `button` \u2014 that extra detail is what lets the agent\n * resolve \"the save button\" without us having to send a screenshot.\n */\nfunction identifyElement(element: Element): string {\n const tagName = element.tagName.toLowerCase();\n\n if (\n tagName === \"button\" ||\n element.getAttribute(\"role\") === \"button\" ||\n tagName === \"input\"\n ) {\n const trimmedText = element.textContent?.trim();\n if (trimmedText) {\n return `${tagName}: \"${trimmedText.slice(0, 60)}\"`;\n }\n const ariaLabel = element.getAttribute(\"aria-label\");\n if (ariaLabel) {\n return `${tagName}: [${ariaLabel}]`;\n }\n if (tagName === \"input\") {\n // Legacy cast - may or may not be necessary\n // eslint-disable-next-line replo/no-as-cast\n const inputType = (element as HTMLInputElement).type || \"text\";\n const placeholder = element.getAttribute(\"placeholder\");\n return placeholder\n ? `input(${inputType}): \"${placeholder}\"`\n : `input(${inputType})`;\n }\n return tagName;\n }\n\n if (tagName === \"a\") {\n const trimmedText = element.textContent?.trim();\n if (trimmedText) {\n return `link: \"${trimmedText.slice(0, 60)}\"`;\n }\n const href = element.getAttribute(\"href\");\n if (href) {\n return `link: [${href.slice(0, 60)}]`;\n }\n return \"link\";\n }\n\n if (tagName === \"img\") {\n // Legacy cast - may or may not be necessary\n // eslint-disable-next-line replo/no-as-cast\n const alt = (element as HTMLImageElement).alt;\n if (alt) {\n return `image: \"${alt.slice(0, 60)}\"`;\n }\n // Legacy cast - may or may not be necessary\n // eslint-disable-next-line replo/no-as-cast\n const src = (element as HTMLImageElement).src;\n if (src) {\n const filename = src.split(\"/\").pop()?.split(\"?\")[0] ?? src;\n return `image: [${filename.slice(0, 40)}]`;\n }\n return \"image\";\n }\n\n if (/^h[1-6]$/.test(tagName)) {\n const trimmedText = element.textContent?.trim();\n return trimmedText\n ? `heading(${tagName}): \"${trimmedText.slice(0, 60)}\"`\n : tagName;\n }\n\n if (\n [\"div\", \"main\", \"section\", \"article\", \"header\", \"footer\", \"nav\"].includes(\n tagName,\n )\n ) {\n const role = element.getAttribute(\"role\");\n if (role) {\n return role;\n }\n }\n\n const trimmedText = element.textContent?.trim();\n if (trimmedText && trimmedText.length < 120) {\n const role = element.getAttribute(\"role\");\n const label = role ?? tagName;\n return `${label}: \"${trimmedText.slice(0, 60)}\"`;\n }\n\n const role = element.getAttribute(\"role\");\n if (role) {\n return role;\n }\n\n const className = element.className;\n if (typeof className === \"string\" && className) {\n const meaningfulClassName = className.split(/\\s+/).find((classToken) => {\n return (\n !classToken.startsWith(\"_\") &&\n !classToken.match(/^[a-z]{1,2}\\d/) &&\n classToken.length > 2\n );\n });\n if (meaningfulClassName) {\n return `${tagName}.${meaningfulClassName}`;\n }\n }\n\n return tagName;\n}\n\n/**\n * Build a CSS selector path from `element` up to the document root. Stops\n * (and short-circuits) at the first ancestor with an `id`. Used so the\n * parent can identify the element later without holding a DOM reference.\n */\nexport function buildSelector(element: Element): string {\n const parts: string[] = [];\n let currentElement: Element | null = element;\n\n while (currentElement && currentElement !== document.documentElement) {\n const tag = currentElement.tagName.toLowerCase();\n const id = currentElement.id;\n\n if (id) {\n parts.unshift(`#${id}`);\n break;\n }\n\n const parentElement: Element | null = currentElement.parentElement;\n if (parentElement) {\n const currentTag = currentElement.tagName;\n // Legacy cast - may or may not be necessary\n // eslint-disable-next-line replo/no-as-cast\n const siblings = Array.from(parentElement.children) as Element[];\n const siblingElementsWithSameTag = siblings.filter((sibling) => {\n return sibling.tagName === currentTag;\n });\n if (siblingElementsWithSameTag.length > 1) {\n const index = siblingElementsWithSameTag.indexOf(currentElement) + 1;\n parts.unshift(`${tag}:nth-of-type(${index})`);\n } else {\n parts.unshift(tag);\n }\n } else {\n parts.unshift(tag);\n }\n\n currentElement = parentElement;\n }\n\n return parts.join(\" > \");\n}\n\n/**\n * Measures the actual rendered text inside `element` \u2014 the tightest width\n * the text occupies, the line count, and the line height. We return this\n * alongside the element's bounding rect so the parent panel can position\n * itself relative to the *text* (not the element box) for text-heavy\n * elements like headings and paragraphs.\n */\nfunction getTextMetrics(element: Element): SelectModeTextMetrics | null {\n const text = element.textContent?.trim();\n if (!text) {\n return null;\n }\n\n const style = window.getComputedStyle(element);\n const parsedLineHeight = Number.parseFloat(style.lineHeight);\n const computedLineHeight = Number.isNaN(parsedLineHeight)\n ? Number.parseFloat(style.fontSize) * 1.2\n : parsedLineHeight;\n\n try {\n const range = document.createRange();\n range.selectNodeContents(element);\n\n const lineRects = Array.from(range.getClientRects()).filter((lineRect) => {\n return lineRect.width > 0 && lineRect.height > 0;\n });\n\n let tightWidth = 0;\n for (const lineRect of lineRects) {\n tightWidth = Math.max(tightWidth, lineRect.width);\n }\n\n const lineCount = lineRects.length;\n if (lineCount === 0) {\n return null;\n }\n\n return {\n tightWidth,\n lineCount,\n lineHeight: computedLineHeight,\n };\n } catch {\n return null;\n }\n}\n\n/**\n * The single entrypoint for converting a DOM `Element` into the serialized\n * `SelectedElement` payload that crosses the iframe<->parent boundary.\n * Centralizes everything the parent (and downstream agent) need to know\n * about a selection: identification, geometry, source location, and a\n * style-inlined HTML snippet.\n *\n * @author Kevin O'Connell 2026-04-17\n */\nexport function buildElementDescriptor({\n element,\n clickPosition,\n siblingSelectors = [],\n}: {\n element: Element;\n clickPosition: SelectModeClickPosition;\n siblingSelectors?: string[];\n}): SelectableData {\n const selectableData = getSelectableDataFromElement(element);\n if (selectableData) {\n return selectableData;\n }\n\n const textMetrics = getTextMetrics(element);\n const fiberChain =\n element instanceof HTMLElement ? getFiberChain(element) : [];\n const sourceLocation = fiberChain[0]?.sourceLocation;\n\n return {\n kind: \"react-element\",\n selector: buildSelector(element),\n tagName: element.tagName.toLowerCase(),\n elementType: identifyElement(element),\n textContent: element.textContent?.trim()?.slice(0, 200) ?? null,\n rect: getElementBoundingRect(element),\n textMetrics,\n outerHTML: element.outerHTML.slice(0, 4000),\n definedStyles: getDefinedStyles(element),\n inheritedStyles: getInheritedStyles(element),\n clickPosition,\n sourceLocation,\n fiberChain,\n siblingSelectors,\n };\n}\n"],
5
- "mappings": "AAMA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,qBAAqB;AAC9B,SAAS,kCAAkC;AAC3C,SAAS,8BAA8B;AACvC,SA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M,mBAAmB,OAAO;AAEhC,UAAM,YAAY,MAAM,KAAK,MAAM,eAAe,CAAC,EAAE,OAAO,CAAC,aAAa;AACxE,aAAO,SAAS,QAAQ,KAAK,SAAS,SAAS;AAAA,IACjD,CAAC;AAED,QAAI,aAAa;AACjB,eAAW,YAAY,WAAW;AAChC,mBAAa,KAAK,IAAI,YAAY,SAAS,KAAK;AAAA,IAClD;AAEA,UAAM,YAAY,UAAU;AAC5B,QAAI,cAAc,GAAG;AACnB,aAAO;AAAA,IACT;AAEA,WAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA,YAAY;AAAA,IACd;AAAA,EACF,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAWO,SAAS,uBAAuB;AAAA,EACrC;AAAA,EACA;AAAA,EACA,mBAAmB,CAAC;AACtB,GAImB;AACjB,QAAM,iBAAiB,6BAA6B,OAAO;AAC3D,MAAI,gBAAgB;AAClB,WAAO;AAAA,EACT;AAEA,QAAM,cAAc,eAAe,OAAO;AAC1C,QAAM,aACJ,mBAAmB,cAAc,cAAc,OAAO,IAAI,CAAC;AAC7D,QAAM,iBAAiB,WAAW,CAAC,GAAG;AAEtC,SAAO;AAAA,IACL,MAAM;AAAA,IACN,UAAU,cAAc,OAAO;AAAA,IAC/B,SAAS,QAAQ,QAAQ,YAAY;AAAA,IACrC,aAAa,gBAAgB,OAAO;AAAA,IACpC,aAAa,QAAQ,aAAa,KAAK,GAAG,MAAM,GAAG,GAAG,KAAK;AAAA,IAC3D,MAAM,uBAAuB,OAAO;AAAA,IACpC;AAAA,IACA,WAAW,QAAQ,UAAU,MAAM,GAAG,GAAI;AAAA,IAC1C,eAAe,iBAAiB,OAAO;AAAA,IACvC,iBAAiB,mBAAmB,OAAO;AAAA,IAC3C;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;",
6
- "names": ["trimmedText", "role"]
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
- export declare function getDefinedStyles(element: Element): SelectModeDefinedStyle[];
3
- export declare function getInheritedStyles(element: Element): Record<string, string>;
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
- const CONTROL_STYLE_PROPERTIES = [
2
- "color",
3
- "background-color",
4
- "font-family",
5
- "font-size",
6
- "font-weight",
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 setDefinedStyle({
104
- definedStylesByKey,
105
- property,
106
- variant,
107
- className,
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