@replohq/canopy-sdk 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (241) hide show
  1. package/_vendor/replo-utils/lib/errors.d.ts +83 -0
  2. package/_vendor/replo-utils/lib/json.d.ts +6 -0
  3. package/_vendor/replo-utils/lib/misc.d.ts +128 -0
  4. package/_vendor/replo-utils/lib/misc.mjs +1 -0
  5. package/_vendor/replo-utils/lib/object.d.ts +31 -0
  6. package/_vendor/replo-utils/lib/parse.d.ts +15 -0
  7. package/_vendor/schemas/agentTools/customIntegrations/loaders/levanta.d.ts +49 -0
  8. package/_vendor/schemas/agentTools/customIntegrations/loaders/levanta.mjs +36 -0
  9. package/_vendor/schemas/agentTools/customIntegrations/loaders/product.d.ts +334 -0
  10. package/_vendor/schemas/agentTools/customIntegrations/loaders/product.mjs +50 -0
  11. package/_vendor/schemas/cart.d.ts +198 -0
  12. package/_vendor/schemas/cart.mjs +83 -0
  13. package/_vendor/schemas/errors.d.ts +428 -0
  14. package/_vendor/schemas/errors.mjs +955 -0
  15. package/_vendor/schemas/generated/errors.d.ts +61 -0
  16. package/_vendor/schemas/generated/selectMode.d.ts +95 -0
  17. package/_vendor/schemas/generated/selectMode.mjs +1 -0
  18. package/_vendor/schemas/loaderKeys.d.ts +39 -0
  19. package/_vendor/schemas/loaderKeys.mjs +23 -0
  20. package/_vendor/schemas/objectType.d.ts +895 -0
  21. package/_vendor/schemas/objectType.mjs +2 -0
  22. package/_vendor/schemas/registry.d.ts +243 -0
  23. package/_vendor/schemas/sandboxFiles.d.ts +35 -0
  24. package/_vendor/schemas/selectMode.d.ts +507 -0
  25. package/_vendor/schemas/selectMode.mjs +194 -0
  26. package/_vendor/schemas/sellingPlan.d.ts +60 -0
  27. package/_vendor/schemas/sellingPlan.mjs +1 -0
  28. package/analytics/analytics-provider.d.ts +13 -0
  29. package/analytics/analytics-provider.js +104 -0
  30. package/analytics/analytics-provider.js.map +7 -0
  31. package/analytics/analytics-sink.d.ts +20 -0
  32. package/analytics/analytics-sink.js +1 -0
  33. package/analytics/analytics-sink.js.map +7 -0
  34. package/analytics/hooks/use-product-viewed-analytics.d.ts +23 -0
  35. package/analytics/hooks/use-product-viewed-analytics.js +34 -0
  36. package/analytics/hooks/use-product-viewed-analytics.js.map +7 -0
  37. package/analytics/sinks/ga4-sink.d.ts +15 -0
  38. package/analytics/sinks/ga4-sink.js +52 -0
  39. package/analytics/sinks/ga4-sink.js.map +7 -0
  40. package/analytics/sinks/meta-sink.d.ts +14 -0
  41. package/analytics/sinks/meta-sink.js +44 -0
  42. package/analytics/sinks/meta-sink.js.map +7 -0
  43. package/analytics/sinks/pinterest-sink.d.ts +14 -0
  44. package/analytics/sinks/pinterest-sink.js +76 -0
  45. package/analytics/sinks/pinterest-sink.js.map +7 -0
  46. package/analytics/sinks/reddit-sink.d.ts +14 -0
  47. package/analytics/sinks/reddit-sink.js +80 -0
  48. package/analytics/sinks/reddit-sink.js.map +7 -0
  49. package/analytics/sinks/replo-sink.d.ts +14 -0
  50. package/analytics/sinks/replo-sink.js +57 -0
  51. package/analytics/sinks/replo-sink.js.map +7 -0
  52. package/analytics/sinks/snapchat-sink.d.ts +14 -0
  53. package/analytics/sinks/snapchat-sink.js +67 -0
  54. package/analytics/sinks/snapchat-sink.js.map +7 -0
  55. package/analytics/sinks/tiktok-sink.d.ts +14 -0
  56. package/analytics/sinks/tiktok-sink.js +79 -0
  57. package/analytics/sinks/tiktok-sink.js.map +7 -0
  58. package/analytics/sinks/window-sink.d.ts +18 -0
  59. package/analytics/sinks/window-sink.js +46 -0
  60. package/analytics/sinks/window-sink.js.map +7 -0
  61. package/analytics/utils/analytics-utils.d.ts +7 -0
  62. package/analytics/utils/analytics-utils.js +130 -0
  63. package/analytics/utils/analytics-utils.js.map +7 -0
  64. package/analytics/utils/navigation-tracker.d.ts +16 -0
  65. package/analytics/utils/navigation-tracker.js +44 -0
  66. package/analytics/utils/navigation-tracker.js.map +7 -0
  67. package/cart/buy-now-action.d.ts +21 -0
  68. package/cart/buy-now-action.js +104 -0
  69. package/cart/buy-now-action.js.map +7 -0
  70. package/cart/cart-actions.d.ts +63 -0
  71. package/cart/cart-actions.js +90 -0
  72. package/cart/cart-actions.js.map +7 -0
  73. package/cart/cart-loader.d.ts +9 -0
  74. package/cart/cart-loader.js +11 -0
  75. package/cart/cart-loader.js.map +7 -0
  76. package/cart/cart-provider.d.ts +85 -0
  77. package/cart/cart-provider.js +358 -0
  78. package/cart/cart-provider.js.map +7 -0
  79. package/cart/cart-types.d.ts +154 -0
  80. package/cart/cart-types.js +16 -0
  81. package/cart/cart-types.js.map +7 -0
  82. package/cart/gateways/cart-gateway.d.ts +10 -0
  83. package/cart/gateways/cart-gateway.js +19 -0
  84. package/cart/gateways/cart-gateway.js.map +7 -0
  85. package/cart/gateways/cookie-cart-gateway.d.ts +28 -0
  86. package/cart/gateways/cookie-cart-gateway.js +109 -0
  87. package/cart/gateways/cookie-cart-gateway.js.map +7 -0
  88. package/cart/gateways/default-cart-gateway.d.ts +19 -0
  89. package/cart/gateways/default-cart-gateway.js +30 -0
  90. package/cart/gateways/default-cart-gateway.js.map +7 -0
  91. package/cart/gateways/resolver-cart-gateway.d.ts +2 -0
  92. package/cart/gateways/resolver-cart-gateway.js +106 -0
  93. package/cart/gateways/resolver-cart-gateway.js.map +7 -0
  94. package/cart/gateways/stripe-cart-gateway.d.ts +19 -0
  95. package/cart/gateways/stripe-cart-gateway.js +28 -0
  96. package/cart/gateways/stripe-cart-gateway.js.map +7 -0
  97. package/cart/gateways/stripe-constants.d.ts +1 -0
  98. package/cart/gateways/stripe-constants.js +5 -0
  99. package/cart/gateways/stripe-constants.js.map +7 -0
  100. package/cart/hooks/use-add-to-cart.d.ts +63 -0
  101. package/cart/hooks/use-add-to-cart.js +120 -0
  102. package/cart/hooks/use-add-to-cart.js.map +7 -0
  103. package/cart/hooks/use-buy-now.d.ts +49 -0
  104. package/cart/hooks/use-buy-now.js +62 -0
  105. package/cart/hooks/use-buy-now.js.map +7 -0
  106. package/cart/utils/cart-utils.d.ts +31 -0
  107. package/cart/utils/cart-utils.js +48 -0
  108. package/cart/utils/cart-utils.js.map +7 -0
  109. package/cart/utils/cookie-cart-persistence.d.ts +55 -0
  110. package/cart/utils/cookie-cart-persistence.js +153 -0
  111. package/cart/utils/cookie-cart-persistence.js.map +7 -0
  112. package/cart/utils/variant-to-cart-line.d.ts +124 -0
  113. package/cart/utils/variant-to-cart-line.js +202 -0
  114. package/cart/utils/variant-to-cart-line.js.map +7 -0
  115. package/chunk-46YU2W6T.mjs +538 -0
  116. package/chunk-4TZVNC3W.mjs +33 -0
  117. package/chunk-INHK6MYI.mjs +1598 -0
  118. package/editor/ClientErrorBoundary.d.ts +7 -0
  119. package/editor/ClientErrorBoundary.js +48 -0
  120. package/editor/ClientErrorBoundary.js.map +7 -0
  121. package/editor/LinkInterceptor.d.ts +1 -0
  122. package/editor/LinkInterceptor.js +124 -0
  123. package/editor/LinkInterceptor.js.map +7 -0
  124. package/editor/posthog-relay.d.ts +10 -0
  125. package/editor/posthog-relay.js +60 -0
  126. package/editor/posthog-relay.js.map +7 -0
  127. package/editor/select-mode/EditorSelection.d.ts +24 -0
  128. package/editor/select-mode/EditorSelection.js +34 -0
  129. package/editor/select-mode/EditorSelection.js.map +7 -0
  130. package/editor/select-mode/descriptor/elementDescriptor.d.ts +15 -0
  131. package/editor/select-mode/descriptor/elementDescriptor.js +213 -0
  132. package/editor/select-mode/descriptor/elementDescriptor.js.map +7 -0
  133. package/editor/select-mode/fiber.d.ts +52 -0
  134. package/editor/select-mode/fiber.js +269 -0
  135. package/editor/select-mode/fiber.js.map +7 -0
  136. package/editor/select-mode/hooks/useCrosshairCursor.d.ts +12 -0
  137. package/editor/select-mode/hooks/useCrosshairCursor.js +20 -0
  138. package/editor/select-mode/hooks/useCrosshairCursor.js.map +7 -0
  139. package/editor/select-mode/hooks/useParentMessaging.d.ts +24 -0
  140. package/editor/select-mode/hooks/useParentMessaging.js +33 -0
  141. package/editor/select-mode/hooks/useParentMessaging.js.map +7 -0
  142. package/editor/select-mode/hooks/useSelectModeController.d.ts +8 -0
  143. package/editor/select-mode/hooks/useSelectModeController.js +49 -0
  144. package/editor/select-mode/hooks/useSelectModeController.js.map +7 -0
  145. package/editor/select-mode/hooks/useSelectionHover.d.ts +22 -0
  146. package/editor/select-mode/hooks/useSelectionHover.js +98 -0
  147. package/editor/select-mode/hooks/useSelectionHover.js.map +7 -0
  148. package/editor/select-mode/hooks/useSelectionInteractions.d.ts +32 -0
  149. package/editor/select-mode/hooks/useSelectionInteractions.js +293 -0
  150. package/editor/select-mode/hooks/useSelectionInteractions.js.map +7 -0
  151. package/editor/select-mode/hooks/useSelectionScrollSync.d.ts +28 -0
  152. package/editor/select-mode/hooks/useSelectionScrollSync.js +77 -0
  153. package/editor/select-mode/hooks/useSelectionScrollSync.js.map +7 -0
  154. package/editor/select-mode/interactions/selectionGeometry.d.ts +80 -0
  155. package/editor/select-mode/interactions/selectionGeometry.js +160 -0
  156. package/editor/select-mode/interactions/selectionGeometry.js.map +7 -0
  157. package/editor/select-mode/selectModeSession.d.ts +21 -0
  158. package/editor/select-mode/selectModeSession.js +7 -0
  159. package/editor/select-mode/selectModeSession.js.map +7 -0
  160. package/editor/select-mode/selectionFrame.d.ts +48 -0
  161. package/editor/select-mode/selectionFrame.js +74 -0
  162. package/editor/select-mode/selectionFrame.js.map +7 -0
  163. package/editor/select-mode/symbolicate.d.ts +3 -0
  164. package/editor/select-mode/symbolicate.js +139 -0
  165. package/editor/select-mode/symbolicate.js.map +7 -0
  166. package/env.d.ts +13 -0
  167. package/env.js +20 -0
  168. package/env.js.map +7 -0
  169. package/gateways/canopy-api.d.ts +84 -0
  170. package/gateways/canopy-api.js +203 -0
  171. package/gateways/canopy-api.js.map +7 -0
  172. package/hooks/use-client-value.d.ts +10 -0
  173. package/hooks/use-client-value.js +12 -0
  174. package/hooks/use-client-value.js.map +7 -0
  175. package/hooks/use-formatted-price.d.ts +15 -0
  176. package/hooks/use-formatted-price.js +19 -0
  177. package/hooks/use-formatted-price.js.map +7 -0
  178. package/lib/get-query-client.d.ts +2 -0
  179. package/lib/get-query-client.js +34 -0
  180. package/lib/get-query-client.js.map +7 -0
  181. package/lib/integration-utils.d.ts +2 -0
  182. package/lib/integration-utils.js +9 -0
  183. package/lib/integration-utils.js.map +7 -0
  184. package/lib/shopify-utils.d.ts +16 -0
  185. package/lib/shopify-utils.js +11 -0
  186. package/lib/shopify-utils.js.map +7 -0
  187. package/lib/url-utils.d.ts +4 -0
  188. package/lib/url-utils.js +8 -0
  189. package/lib/url-utils.js.map +7 -0
  190. package/loaders/collection-loader.d.ts +11 -0
  191. package/loaders/collection-loader.js +53 -0
  192. package/loaders/collection-loader.js.map +7 -0
  193. package/loaders/collection-products-loader.d.ts +12 -0
  194. package/loaders/collection-products-loader.js +56 -0
  195. package/loaders/collection-products-loader.js.map +7 -0
  196. package/loaders/invoke-loader-action.d.ts +11 -0
  197. package/loaders/invoke-loader-action.js +14 -0
  198. package/loaders/invoke-loader-action.js.map +7 -0
  199. package/loaders/invoke-loader-server.d.ts +18 -0
  200. package/loaders/invoke-loader-server.js +35 -0
  201. package/loaders/invoke-loader-server.js.map +7 -0
  202. package/loaders/invoke-loader.d.ts +14 -0
  203. package/loaders/invoke-loader.js +36 -0
  204. package/loaders/invoke-loader.js.map +7 -0
  205. package/loaders/levanta-product-loader.d.ts +11 -0
  206. package/loaders/levanta-product-loader.js +53 -0
  207. package/loaders/levanta-product-loader.js.map +7 -0
  208. package/loaders/loader-error-boundary.d.ts +25 -0
  209. package/loaders/loader-error-boundary.js +24 -0
  210. package/loaders/loader-error-boundary.js.map +7 -0
  211. package/loaders/okendo-review-aggregate-loader.d.ts +17 -0
  212. package/loaders/okendo-review-aggregate-loader.js +56 -0
  213. package/loaders/okendo-review-aggregate-loader.js.map +7 -0
  214. package/loaders/okendo-reviews-loader.d.ts +23 -0
  215. package/loaders/okendo-reviews-loader.js +54 -0
  216. package/loaders/okendo-reviews-loader.js.map +7 -0
  217. package/loaders/prefetch-loaders.d.ts +33 -0
  218. package/loaders/prefetch-loaders.js +46 -0
  219. package/loaders/prefetch-loaders.js.map +7 -0
  220. package/loaders/product-loader.d.ts +11 -0
  221. package/loaders/product-loader.js +53 -0
  222. package/loaders/product-loader.js.map +7 -0
  223. package/loaders/rebuy-recommendations-loader.d.ts +159 -0
  224. package/loaders/rebuy-recommendations-loader.js +57 -0
  225. package/loaders/rebuy-recommendations-loader.js.map +7 -0
  226. package/loaders/smile-earning-rules-loader.d.ts +19 -0
  227. package/loaders/smile-earning-rules-loader.js +44 -0
  228. package/loaders/smile-earning-rules-loader.js.map +7 -0
  229. package/loaders/smile-rewards-loader.d.ts +19 -0
  230. package/loaders/smile-rewards-loader.js +44 -0
  231. package/loaders/smile-rewards-loader.js.map +7 -0
  232. package/loaders/smile-vip-tiers-loader.d.ts +18 -0
  233. package/loaders/smile-vip-tiers-loader.js +43 -0
  234. package/loaders/smile-vip-tiers-loader.js.map +7 -0
  235. package/package.json +29 -0
  236. package/providers/query-provider.d.ts +1 -0
  237. package/providers/query-provider.js +12 -0
  238. package/providers/query-provider.js.map +7 -0
  239. package/providers/replo-provider.d.ts +1 -0
  240. package/providers/replo-provider.js +20 -0
  241. package/providers/replo-provider.js.map +7 -0
@@ -0,0 +1,7 @@
1
+ import * as React from "react";
2
+ /**
3
+ * Client-side error boundary that catches React render errors and communicates
4
+ * them to the parent editor via postMessage. This enables error tracking for
5
+ * scaffold client-side errors in the opencode (Cloudflare) agent architecture.
6
+ */
7
+ export declare function ClientErrorBoundary({ children }: React.PropsWithChildren): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,48 @@
1
+ "use client";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import * as React from "react";
4
+ class ErrorBoundary extends React.Component {
5
+ state = {
6
+ didCatch: false,
7
+ error: null
8
+ };
9
+ static getDerivedStateFromError(error) {
10
+ return { didCatch: true, error };
11
+ }
12
+ componentDidCatch(error, info) {
13
+ this.props.onError?.(error, info);
14
+ }
15
+ render() {
16
+ if (this.state.didCatch) {
17
+ return null;
18
+ }
19
+ return this.props.children;
20
+ }
21
+ }
22
+ function ClientErrorBoundary({ children }) {
23
+ const handleError = React.useCallback(
24
+ (error, errorInfo) => {
25
+ const errorObj = error instanceof Error ? error : new Error(String(error));
26
+ window.parent.postMessage(
27
+ {
28
+ type: "replo-editor:client-error",
29
+ payload: {
30
+ pageRoute: window.location.pathname,
31
+ error: {
32
+ message: errorObj.message,
33
+ stack: errorObj.stack,
34
+ componentStack: errorInfo.componentStack
35
+ }
36
+ }
37
+ },
38
+ "*"
39
+ );
40
+ },
41
+ []
42
+ );
43
+ return /* @__PURE__ */ jsx(ErrorBoundary, { onError: handleError, children });
44
+ }
45
+ export {
46
+ ClientErrorBoundary
47
+ };
48
+ //# sourceMappingURL=ClientErrorBoundary.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../editor/ClientErrorBoundary.tsx"],
4
+ "sourcesContent": ["\"use client\";\n\nimport * as React from \"react\";\n\ninterface ErrorBoundaryState {\n didCatch: boolean;\n error: unknown;\n}\n\ntype ErrorBoundaryProps = React.PropsWithChildren<{\n onError?: (error: unknown, info: React.ErrorInfo) => void;\n}>;\n\nclass ErrorBoundary extends React.Component<\n ErrorBoundaryProps,\n ErrorBoundaryState\n> {\n state: ErrorBoundaryState = {\n didCatch: false,\n error: null,\n };\n\n static getDerivedStateFromError(error: unknown) {\n return { didCatch: true, error };\n }\n\n componentDidCatch(error: unknown, info: React.ErrorInfo) {\n this.props.onError?.(error, info);\n }\n\n render() {\n // Note (Nick, 2026-02-23, REPL-23283): When an error is caught, render nothing.\n // The error will be communicated to the parent editor via postMessage.\n if (this.state.didCatch) {\n return null;\n }\n return this.props.children;\n }\n}\n\n/**\n * Client-side error boundary that catches React render errors and communicates\n * them to the parent editor via postMessage. This enables error tracking for\n * scaffold client-side errors in the opencode (Cloudflare) agent architecture.\n */\nexport function ClientErrorBoundary({ children }: React.PropsWithChildren) {\n const handleError = React.useCallback(\n (error: unknown, errorInfo: React.ErrorInfo) => {\n const errorObj =\n error instanceof Error ? error : new Error(String(error));\n window.parent.postMessage(\n {\n type: \"replo-editor:client-error\",\n payload: {\n pageRoute: window.location.pathname,\n error: {\n message: errorObj.message,\n stack: errorObj.stack,\n componentStack: errorInfo.componentStack,\n },\n },\n },\n \"*\",\n );\n },\n [],\n );\n\n return <ErrorBoundary onError={handleError}>{children}</ErrorBoundary>;\n}\n"],
5
+ "mappings": ";AAoES;AAlET,YAAY,WAAW;AAWvB,MAAM,sBAAsB,MAAM,UAGhC;AAAA,EACA,QAA4B;AAAA,IAC1B,UAAU;AAAA,IACV,OAAO;AAAA,EACT;AAAA,EAEA,OAAO,yBAAyB,OAAgB;AAC9C,WAAO,EAAE,UAAU,MAAM,MAAM;AAAA,EACjC;AAAA,EAEA,kBAAkB,OAAgB,MAAuB;AACvD,SAAK,MAAM,UAAU,OAAO,IAAI;AAAA,EAClC;AAAA,EAEA,SAAS;AAGP,QAAI,KAAK,MAAM,UAAU;AACvB,aAAO;AAAA,IACT;AACA,WAAO,KAAK,MAAM;AAAA,EACpB;AACF;AAOO,SAAS,oBAAoB,EAAE,SAAS,GAA4B;AACzE,QAAM,cAAc,MAAM;AAAA,IACxB,CAAC,OAAgB,cAA+B;AAC9C,YAAM,WACJ,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,KAAK,CAAC;AAC1D,aAAO,OAAO;AAAA,QACZ;AAAA,UACE,MAAM;AAAA,UACN,SAAS;AAAA,YACP,WAAW,OAAO,SAAS;AAAA,YAC3B,OAAO;AAAA,cACL,SAAS,SAAS;AAAA,cAClB,OAAO,SAAS;AAAA,cAChB,gBAAgB,UAAU;AAAA,YAC5B;AAAA,UACF;AAAA,QACF;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAAA,IACA,CAAC;AAAA,EACH;AAEA,SAAO,oBAAC,iBAAc,SAAS,aAAc,UAAS;AACxD;",
6
+ "names": []
7
+ }
@@ -0,0 +1 @@
1
+ export default function LinkInterceptor(): null;
@@ -0,0 +1,124 @@
1
+ "use client";
2
+ import { useEffect } from "react";
3
+ function blockNavigation(event) {
4
+ event.preventDefault();
5
+ event.stopPropagation();
6
+ event.stopImmediatePropagation();
7
+ }
8
+ function isNavigationLike(value) {
9
+ if (typeof value !== "object" || value === null) {
10
+ return false;
11
+ }
12
+ return typeof Reflect.get(value, "addEventListener") === "function" && typeof Reflect.get(value, "removeEventListener") === "function";
13
+ }
14
+ function getWindowNavigation() {
15
+ const navigation = Reflect.get(window, "navigation");
16
+ return isNavigationLike(navigation) ? navigation : null;
17
+ }
18
+ function shouldInterceptNavigationForAgentPreview() {
19
+ if (typeof window === "undefined") {
20
+ return false;
21
+ }
22
+ if (window.parent === window) {
23
+ return false;
24
+ }
25
+ return new URLSearchParams(window.location.search).get("__reploAgentPreview") === "1";
26
+ }
27
+ function urlLeavesSandbox(rawUrl) {
28
+ try {
29
+ const resolved = typeof rawUrl === "string" ? new URL(rawUrl, window.location.href) : new URL(rawUrl.href, window.location.href);
30
+ return resolved.origin !== window.location.origin;
31
+ } catch {
32
+ return null;
33
+ }
34
+ }
35
+ function LinkInterceptor() {
36
+ useEffect(() => {
37
+ if (!shouldInterceptNavigationForAgentPreview()) {
38
+ return;
39
+ }
40
+ const originalWindowOpen = window.open;
41
+ const originalPushState = history.pushState;
42
+ const originalReplaceState = history.replaceState;
43
+ const navigation = getWindowNavigation();
44
+ window.open = function(url, target, features) {
45
+ if (url !== void 0 && url !== "" && urlLeavesSandbox(url) === true) {
46
+ return null;
47
+ }
48
+ return originalWindowOpen.call(window, url, target, features);
49
+ };
50
+ history.pushState = function(state, unused, url) {
51
+ if (url != null && url !== "" && urlLeavesSandbox(url) === true) {
52
+ return;
53
+ }
54
+ return originalPushState.call(history, state, unused, url);
55
+ };
56
+ history.replaceState = function(state, unused, url) {
57
+ if (url != null && url !== "" && urlLeavesSandbox(url) === true) {
58
+ return;
59
+ }
60
+ return originalReplaceState.call(history, state, unused, url);
61
+ };
62
+ const handleNavigate = (event) => {
63
+ const destinationUrl = event.destination?.url;
64
+ if (destinationUrl === void 0 || destinationUrl === "" || urlLeavesSandbox(destinationUrl) !== true) {
65
+ return;
66
+ }
67
+ event.preventDefault?.();
68
+ };
69
+ const handleClick = (e) => {
70
+ const target = e.target;
71
+ if (!(target instanceof Element)) {
72
+ return;
73
+ }
74
+ const link = target.closest("a[href]");
75
+ if (!(link instanceof HTMLAnchorElement)) {
76
+ return;
77
+ }
78
+ const href = link.getAttribute("href");
79
+ if (!href) {
80
+ return;
81
+ }
82
+ if (href.startsWith("#")) {
83
+ return;
84
+ }
85
+ const linkTarget = link.getAttribute("target");
86
+ if (linkTarget && linkTarget !== "_self") {
87
+ blockNavigation(e);
88
+ return;
89
+ }
90
+ if (urlLeavesSandbox(href) === true) {
91
+ blockNavigation(e);
92
+ return;
93
+ }
94
+ e.preventDefault();
95
+ let route;
96
+ try {
97
+ route = new URL(href, window.location.href).pathname;
98
+ } catch {
99
+ route = href;
100
+ }
101
+ window.parent.postMessage(
102
+ {
103
+ type: "replo:navigate",
104
+ route
105
+ },
106
+ "*"
107
+ );
108
+ };
109
+ navigation?.addEventListener("navigate", handleNavigate);
110
+ document.addEventListener("click", handleClick, true);
111
+ return () => {
112
+ window.open = originalWindowOpen;
113
+ history.pushState = originalPushState;
114
+ history.replaceState = originalReplaceState;
115
+ navigation?.removeEventListener("navigate", handleNavigate);
116
+ document.removeEventListener("click", handleClick, true);
117
+ };
118
+ }, []);
119
+ return null;
120
+ }
121
+ export {
122
+ LinkInterceptor as default
123
+ };
124
+ //# sourceMappingURL=LinkInterceptor.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../editor/LinkInterceptor.tsx"],
4
+ "sourcesContent": ["\"use client\";\n\nimport { useEffect } from \"react\";\n\ntype NavigationNavigateEvent = {\n destination?: { url?: string };\n preventDefault?: () => void;\n};\n\ntype NavigationLike = {\n addEventListener: (\n type: \"navigate\",\n listener: (event: NavigationNavigateEvent) => void,\n ) => void;\n removeEventListener: (\n type: \"navigate\",\n listener: (event: NavigationNavigateEvent) => void,\n ) => void;\n};\n\nfunction blockNavigation(event: MouseEvent) {\n event.preventDefault();\n event.stopPropagation();\n event.stopImmediatePropagation();\n}\n\nfunction isNavigationLike(value: unknown): value is NavigationLike {\n if (typeof value !== \"object\" || value === null) {\n return false;\n }\n\n return (\n typeof Reflect.get(value, \"addEventListener\") === \"function\" &&\n typeof Reflect.get(value, \"removeEventListener\") === \"function\"\n );\n}\n\nfunction getWindowNavigation() {\n const navigation = Reflect.get(window, \"navigation\");\n return isNavigationLike(navigation) ? navigation : null;\n}\n\nfunction shouldInterceptNavigationForAgentPreview() {\n if (typeof window === \"undefined\") {\n return false;\n }\n\n if (window.parent === window) {\n return false;\n }\n\n return (\n new URLSearchParams(window.location.search).get(\"__reploAgentPreview\") ===\n \"1\"\n );\n}\n\nfunction urlLeavesSandbox(rawUrl: string | URL): boolean | null {\n try {\n const resolved =\n typeof rawUrl === \"string\"\n ? new URL(rawUrl, window.location.href)\n : new URL(rawUrl.href, window.location.href);\n return resolved.origin !== window.location.origin;\n } catch {\n return null;\n }\n}\n\nexport default function LinkInterceptor() {\n // eslint-disable-next-line replo/no-use-effect -- Browser navigation APIs must be patched at client runtime and restored when the interceptor unmounts.\n useEffect(() => {\n if (!shouldInterceptNavigationForAgentPreview()) {\n return;\n }\n\n const originalWindowOpen = window.open;\n const originalPushState = history.pushState;\n const originalReplaceState = history.replaceState;\n const navigation = getWindowNavigation();\n\n window.open = function (\n url?: string | URL,\n target?: string,\n features?: string,\n ) {\n if (url !== undefined && url !== \"\" && urlLeavesSandbox(url) === true) {\n return null;\n }\n\n return originalWindowOpen.call(window, url, target, features);\n };\n\n history.pushState = function (\n state: Parameters<History[\"pushState\"]>[0],\n unused: string,\n url?: string | URL | null,\n ) {\n if (url != null && url !== \"\" && urlLeavesSandbox(url) === true) {\n return;\n }\n\n return originalPushState.call(history, state, unused, url);\n };\n\n history.replaceState = function (\n state: Parameters<History[\"replaceState\"]>[0],\n unused: string,\n url?: string | URL | null,\n ) {\n if (url != null && url !== \"\" && urlLeavesSandbox(url) === true) {\n return;\n }\n\n return originalReplaceState.call(history, state, unused, url);\n };\n\n const handleNavigate = (event: NavigationNavigateEvent) => {\n const destinationUrl = event.destination?.url;\n if (\n destinationUrl === undefined ||\n destinationUrl === \"\" ||\n urlLeavesSandbox(destinationUrl) !== true\n ) {\n return;\n }\n\n event.preventDefault?.();\n };\n\n const handleClick = (e: MouseEvent) => {\n const target = e.target;\n\n if (!(target instanceof Element)) {\n return;\n }\n\n const link = target.closest(\"a[href]\");\n\n if (!(link instanceof HTMLAnchorElement)) {\n return;\n }\n\n const href = link.getAttribute(\"href\");\n if (!href) {\n return;\n }\n\n if (href.startsWith(\"#\")) {\n return;\n }\n\n const linkTarget = link.getAttribute(\"target\");\n if (linkTarget && linkTarget !== \"_self\") {\n blockNavigation(e);\n return;\n }\n\n if (urlLeavesSandbox(href) === true) {\n blockNavigation(e);\n return;\n }\n\n e.preventDefault();\n\n let route: string;\n try {\n route = new URL(href, window.location.href).pathname;\n } catch {\n route = href;\n }\n\n window.parent.postMessage(\n {\n type: \"replo:navigate\",\n route,\n },\n \"*\",\n );\n };\n\n navigation?.addEventListener(\"navigate\", handleNavigate);\n document.addEventListener(\"click\", handleClick, true);\n\n return () => {\n window.open = originalWindowOpen;\n history.pushState = originalPushState;\n history.replaceState = originalReplaceState;\n navigation?.removeEventListener(\"navigate\", handleNavigate);\n document.removeEventListener(\"click\", handleClick, true);\n };\n }, []);\n\n return null;\n}\n"],
5
+ "mappings": ";AAEA,SAAS,iBAAiB;AAkB1B,SAAS,gBAAgB,OAAmB;AAC1C,QAAM,eAAe;AACrB,QAAM,gBAAgB;AACtB,QAAM,yBAAyB;AACjC;AAEA,SAAS,iBAAiB,OAAyC;AACj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S,iBAAiB,SAAS,aAAa,IAAI;AAEpD,WAAO,MAAM;AACX,aAAO,OAAO;AACd,cAAQ,YAAY;AACpB,cAAQ,eAAe;AACvB,kBAAY,oBAAoB,YAAY,cAAc;AAC1D,eAAS,oBAAoB,SAAS,aAAa,IAAI;AAAA,IACzD;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,SAAO;AACT;",
6
+ "names": []
7
+ }
@@ -0,0 +1,10 @@
1
+ interface PostHog {
2
+ init: (apiKey: string, config: Record<string, unknown>) => void;
3
+ }
4
+ declare global {
5
+ interface Window {
6
+ posthog?: PostHog;
7
+ }
8
+ }
9
+ export default function PostHogRelay(): null;
10
+ export {};
@@ -0,0 +1,60 @@
1
+ "use client";
2
+ import { useEffect } from "react";
3
+ const POSTHOG_API_KEY = "phc_dRETsj85vNkKrvQQszEFRBibH5kUF9l7rbjACuKPanZ";
4
+ const POSTHOG_API_HOST = "https://d99bbtllqsaif.cloudfront.net";
5
+ let initPromise = null;
6
+ function loadPostHogScript() {
7
+ return new Promise((resolve) => {
8
+ if (window.posthog) {
9
+ resolve();
10
+ return;
11
+ }
12
+ const script = document.createElement("script");
13
+ script.src = `${POSTHOG_API_HOST}/static/array.js`;
14
+ script.async = true;
15
+ script.addEventListener("load", () => resolve());
16
+ script.addEventListener("error", () => {
17
+ resolve();
18
+ console.warn("[PostHog Relay] Failed to load PostHog script");
19
+ });
20
+ document.head.append(script);
21
+ });
22
+ }
23
+ function initPostHogRelay() {
24
+ if (window.self === window.top) {
25
+ return Promise.resolve();
26
+ }
27
+ if (initPromise) {
28
+ return initPromise;
29
+ }
30
+ initPromise = (async () => {
31
+ await loadPostHogScript();
32
+ if (!window.posthog) {
33
+ initPromise = null;
34
+ console.warn("[PostHog Relay] PostHog not available after script load");
35
+ return;
36
+ }
37
+ window.posthog.init(POSTHOG_API_KEY, {
38
+ api_host: POSTHOG_API_HOST,
39
+ persistence: "localStorage",
40
+ autocapture: false,
41
+ capture_pageview: false,
42
+ session_recording: {
43
+ recordCrossOriginIframes: true,
44
+ // NOTE (Nick, 2026-02-02, REPL-23284): Disable canvas recording to prevent SecurityError on tainted canvases
45
+ captureCanvas: { recordCanvas: false }
46
+ }
47
+ });
48
+ })();
49
+ return initPromise;
50
+ }
51
+ function PostHogRelay() {
52
+ useEffect(() => {
53
+ void initPostHogRelay();
54
+ }, []);
55
+ return null;
56
+ }
57
+ export {
58
+ PostHogRelay as default
59
+ };
60
+ //# sourceMappingURL=posthog-relay.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../editor/posthog-relay.tsx"],
4
+ "sourcesContent": ["\"use client\";\n\n/**\n * PostHog Cross-Origin Iframe Relay\n *\n * Initializes PostHog inside the sandbox iframe as a \"relay\" - it captures DOM\n * mutations via rrweb and sends them to the parent window's PostHog instance\n * via postMessage, enabling session recordings to include iframe content.\n */\nimport { useEffect } from \"react\";\n\nconst POSTHOG_API_KEY = \"phc_dRETsj85vNkKrvQQszEFRBibH5kUF9l7rbjACuKPanZ\";\nconst POSTHOG_API_HOST = \"https://d99bbtllqsaif.cloudfront.net\";\n\ninterface PostHog {\n init: (apiKey: string, config: Record<string, unknown>) => void;\n}\n\ndeclare global {\n interface Window {\n posthog?: PostHog;\n }\n}\n\nlet initPromise: Promise<void> | null = null;\n\nfunction loadPostHogScript() {\n return new Promise<void>((resolve) => {\n if (window.posthog) {\n resolve();\n return;\n }\n\n const script = document.createElement(\"script\");\n script.src = `${POSTHOG_API_HOST}/static/array.js`;\n script.async = true;\n script.addEventListener(\"load\", () => resolve());\n script.addEventListener(\"error\", () => {\n resolve();\n console.warn(\"[PostHog Relay] Failed to load PostHog script\");\n });\n document.head.append(script);\n });\n}\n\nfunction initPostHogRelay() {\n if (window.self === window.top) {\n return Promise.resolve();\n }\n\n if (initPromise) {\n return initPromise;\n }\n\n initPromise = (async () => {\n await loadPostHogScript();\n\n if (!window.posthog) {\n initPromise = null;\n console.warn(\"[PostHog Relay] PostHog not available after script load\");\n return;\n }\n\n window.posthog.init(POSTHOG_API_KEY, {\n api_host: POSTHOG_API_HOST,\n persistence: \"localStorage\",\n autocapture: false,\n capture_pageview: false,\n session_recording: {\n recordCrossOriginIframes: true,\n // NOTE (Nick, 2026-02-02, REPL-23284): Disable canvas recording to prevent SecurityError on tainted canvases\n captureCanvas: { recordCanvas: false },\n },\n });\n })();\n\n return initPromise;\n}\n\nexport default function PostHogRelay() {\n // eslint-disable-next-line replo/no-use-effect -- Legacy effect - may or may not be necessary\n useEffect(() => {\n void initPostHogRelay();\n }, []);\n\n return null;\n}\n"],
5
+ "mappings": ";AASA,SAAS,iBAAiB;AAE1B,MAAM,kBAAkB;AACxB,MAAM,mBAAmB;AAYzB,IAAI,cAAoC;AAExC,SAAS,oBAAoB;AAC3B,SAAO,IAAI,QAAc,CAAC,YAAY;AACpC,QAAI,OAAO,SAAS;AAClB,cAAQ;AACR;AAAA,IACF;AAEA,UAAM,SAAS,SAAS,cAAc,QAAQ;AAC9C,WAAO,MAAM,GAAG,gBAAgB;AAChC,WAAO,QAAQ;AACf,WAAO,iBAAiB,QAAQ,MAAM,QAAQ,CAAC;AAC/C,WAAO,iBAAiB,SAAS,MAAM;AACrC,cAAQ;AACR,cAAQ,KAAK,+CAA+C;AAAA,IAC9D,CAAC;AACD,aAAS,KAAK,OAAO,MAAM;AAAA,EAC7B,CAAC;AACH;AAEA,SAAS,mBAAmB;AAC1B,MAAI,OAAO,SAAS,OAAO,KAAK;AAC9B,WAAO,QAAQ,QAAQ;AAAA,EACzB;AAEA,MAAI,aAAa;AACf,WAAO;AAAA,EACT;AAEA,iBAAe,YAAY;AACzB,UAAM,kBAAkB;AAExB,QAAI,CAAC,OAAO,SAAS;AACnB,oBAAc;AACd,cAAQ,KAAK,yDAAyD;AACtE;AAAA,IACF;AAEA,WAAO,QAAQ,KAAK,iBAAiB;AAAA,MACnC,UAAU;AAAA,MACV,aAAa;AAAA,MACb,aAAa;AAAA,MACb,kBAAkB;AAAA,MAClB,mBAAmB;AAAA,QACjB,0BAA0B;AAAA;AAAA,QAE1B,eAAe,EAAE,cAAc,MAAM;AAAA,MACvC;AAAA,IACF,CAAC;AAAA,EACH,GAAG;AAEH,SAAO;AACT;AAEe,SAAR,eAAgC;AAErC,YAAU,MAAM;AACd,SAAK,iBAAiB;AAAA,EACxB,GAAG,CAAC,CAAC;AAEL,SAAO;AACT;",
6
+ "names": []
7
+ }
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Mounts the iframe-side selectMode controller. This is a render-less
3
+ * component — every responsibility is delegated to a dedicated hook so each
4
+ * concern (parent messaging, cursor styling, pointer interactions, hover
5
+ * tracking, scroll syncing) can be read in isolation:
6
+ *
7
+ * - `useParentMessaging` — inbound messages from the parent (set mode,
8
+ * set selection type) + outbound `IFRAME_READY` handshake.
9
+ * - `useCrosshairCursor` — crosshair cursor + disable text/drag selection
10
+ * while in selection mode.
11
+ * - `useSelectionInteractions` — pointer-down / move / up state machine
12
+ * that produces `ELEMENT_SELECTED`, `AREA_SELECTED`, and live
13
+ * `DRAG_RECT_UPDATED` messages.
14
+ * - `useSelectionHover` — hover-element rect updates.
15
+ * - `useSelectionScrollSync` — keeps the parent overlay aligned with the
16
+ * selected element/area when the iframe scrolls.
17
+ *
18
+ * The `interactionSessionRef` is the single source of truth for the
19
+ * in-progress drag/selection — every hook reads/writes it via ref so we
20
+ * don't trigger React re-renders during interaction-heavy operations.
21
+ *
22
+ * @author Kevin O'Connell 2026-04-17
23
+ */
24
+ export declare function EditorSelection(): null;
@@ -0,0 +1,34 @@
1
+ "use client";
2
+ import { useCrosshairCursor } from "./hooks/useCrosshairCursor";
3
+ import { useParentMessaging } from "./hooks/useParentMessaging";
4
+ import { useSelectionHover } from "./hooks/useSelectionHover";
5
+ import { useSelectionInteractions } from "./hooks/useSelectionInteractions";
6
+ import { useSelectionScrollSync } from "./hooks/useSelectionScrollSync";
7
+ import { useSelectModeController } from "./hooks/useSelectModeController";
8
+ function EditorSelection() {
9
+ const {
10
+ displayMode,
11
+ interactionSessionRef,
12
+ setDisplayMode,
13
+ setSelectionType
14
+ } = useSelectModeController();
15
+ useParentMessaging({
16
+ setDisplayMode,
17
+ setSelectionType
18
+ });
19
+ useCrosshairCursor({ displayMode });
20
+ useSelectionInteractions({
21
+ displayMode,
22
+ interactionSessionRef
23
+ });
24
+ useSelectionHover({ displayMode, interactionSessionRef });
25
+ useSelectionScrollSync({
26
+ displayMode,
27
+ interactionSessionRef
28
+ });
29
+ return null;
30
+ }
31
+ export {
32
+ EditorSelection
33
+ };
34
+ //# sourceMappingURL=EditorSelection.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../editor/select-mode/EditorSelection.tsx"],
4
+ "sourcesContent": ["\"use client\";\n\nimport { useCrosshairCursor } from \"./hooks/useCrosshairCursor\";\nimport { useParentMessaging } from \"./hooks/useParentMessaging\";\nimport { useSelectionHover } from \"./hooks/useSelectionHover\";\nimport { useSelectionInteractions } from \"./hooks/useSelectionInteractions\";\nimport { useSelectionScrollSync } from \"./hooks/useSelectionScrollSync\";\nimport { useSelectModeController } from \"./hooks/useSelectModeController\";\n\n/**\n * Mounts the iframe-side selectMode controller. This is a render-less\n * component \u2014 every responsibility is delegated to a dedicated hook so each\n * concern (parent messaging, cursor styling, pointer interactions, hover\n * tracking, scroll syncing) can be read in isolation:\n *\n * - `useParentMessaging` \u2014 inbound messages from the parent (set mode,\n * set selection type) + outbound `IFRAME_READY` handshake.\n * - `useCrosshairCursor` \u2014 crosshair cursor + disable text/drag selection\n * while in selection mode.\n * - `useSelectionInteractions` \u2014 pointer-down / move / up state machine\n * that produces `ELEMENT_SELECTED`, `AREA_SELECTED`, and live\n * `DRAG_RECT_UPDATED` messages.\n * - `useSelectionHover` \u2014 hover-element rect updates.\n * - `useSelectionScrollSync` \u2014 keeps the parent overlay aligned with the\n * selected element/area when the iframe scrolls.\n *\n * The `interactionSessionRef` is the single source of truth for the\n * in-progress drag/selection \u2014 every hook reads/writes it via ref so we\n * don't trigger React re-renders during interaction-heavy operations.\n *\n * @author Kevin O'Connell 2026-04-17\n */\nexport function EditorSelection() {\n const {\n displayMode,\n interactionSessionRef,\n setDisplayMode,\n setSelectionType,\n } = useSelectModeController();\n\n useParentMessaging({\n setDisplayMode,\n setSelectionType,\n });\n useCrosshairCursor({ displayMode });\n useSelectionInteractions({\n displayMode,\n interactionSessionRef,\n });\n useSelectionHover({ displayMode, interactionSessionRef });\n useSelectionScrollSync({\n displayMode,\n interactionSessionRef,\n });\n\n return null;\n}\n"],
5
+ "mappings": ";AAEA,SAAS,0BAA0B;AACnC,SAAS,0BAA0B;AACnC,SAAS,yBAAyB;AAClC,SAAS,gCAAgC;AACzC,SAAS,8BAA8B;AACvC,SAAS,+BAA+B;AAyBjC,SAAS,kBAAkB;AAChC,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,wBAAwB;AAE5B,qBAAmB;AAAA,IACjB;AAAA,IACA;AAAA,EACF,CAAC;AACD,qBAAmB,EAAE,YAAY,CAAC;AAClC,2BAAyB;AAAA,IACvB;AAAA,IACA;AAAA,EACF,CAAC;AACD,oBAAkB,EAAE,aAAa,sBAAsB,CAAC;AACxD,yBAAuB;AAAA,IACrB;AAAA,IACA;AAAA,EACF,CAAC;AAED,SAAO;AACT;",
6
+ "names": []
7
+ }
@@ -0,0 +1,15 @@
1
+ import type { SelectableData, SelectModeClickPosition } from "../../../_vendor/schemas/generated/selectMode";
2
+ export declare function getNearestSelectableElement(element: Element): Element | null;
3
+ /**
4
+ * The single entrypoint for converting a DOM `Element` into the serialized
5
+ * `SelectedElement` payload that crosses the iframe<->parent boundary.
6
+ * Centralizes everything the parent (and downstream agent) need to know
7
+ * about a selection: identification, geometry, source location, and a
8
+ * style-inlined HTML snippet.
9
+ *
10
+ * @author Kevin O'Connell 2026-04-17
11
+ */
12
+ export declare function buildElementDescriptor({ element, clickPosition, }: {
13
+ element: Element;
14
+ clickPosition: SelectModeClickPosition;
15
+ }): SelectableData;
@@ -0,0 +1,213 @@
1
+ import {
2
+ readSelectablePayload,
3
+ SELECT_MODE_SELECTABLE_ATTRIBUTE,
4
+ SELECT_MODE_SELECTABLE_PAYLOAD_ATTRIBUTE
5
+ } from "../../../_vendor/schemas/selectMode.mjs";
6
+ import { getSourceLocation } from "../fiber";
7
+ import { getElementBoundingRect } from "../interactions/selectionGeometry";
8
+ function getNearestSelectableElement(element) {
9
+ return element.closest(`[${SELECT_MODE_SELECTABLE_ATTRIBUTE}]`);
10
+ }
11
+ function getSelectableDataFromElement(element) {
12
+ const selectableElement = getNearestSelectableElement(element);
13
+ if (!selectableElement) {
14
+ return null;
15
+ }
16
+ const selectablePayload = readSelectablePayload(
17
+ selectableElement.getAttribute(SELECT_MODE_SELECTABLE_PAYLOAD_ATTRIBUTE)
18
+ );
19
+ if (!selectablePayload) {
20
+ return null;
21
+ }
22
+ return {
23
+ ...selectablePayload,
24
+ rect: getElementBoundingRect(selectableElement)
25
+ };
26
+ }
27
+ function identifyElement(element) {
28
+ const tagName = element.tagName.toLowerCase();
29
+ if (tagName === "button" || element.getAttribute("role") === "button" || tagName === "input") {
30
+ const trimmedText2 = element.textContent?.trim();
31
+ if (trimmedText2) {
32
+ return `${tagName}: "${trimmedText2.slice(0, 60)}"`;
33
+ }
34
+ const ariaLabel = element.getAttribute("aria-label");
35
+ if (ariaLabel) {
36
+ return `${tagName}: [${ariaLabel}]`;
37
+ }
38
+ if (tagName === "input") {
39
+ const inputType = element.type || "text";
40
+ const placeholder = element.getAttribute("placeholder");
41
+ return placeholder ? `input(${inputType}): "${placeholder}"` : `input(${inputType})`;
42
+ }
43
+ return tagName;
44
+ }
45
+ if (tagName === "a") {
46
+ const trimmedText2 = element.textContent?.trim();
47
+ if (trimmedText2) {
48
+ return `link: "${trimmedText2.slice(0, 60)}"`;
49
+ }
50
+ const href = element.getAttribute("href");
51
+ if (href) {
52
+ return `link: [${href.slice(0, 60)}]`;
53
+ }
54
+ return "link";
55
+ }
56
+ if (tagName === "img") {
57
+ const alt = element.alt;
58
+ if (alt) {
59
+ return `image: "${alt.slice(0, 60)}"`;
60
+ }
61
+ const src = element.src;
62
+ if (src) {
63
+ const filename = src.split("/").pop()?.split("?")[0] ?? src;
64
+ return `image: [${filename.slice(0, 40)}]`;
65
+ }
66
+ return "image";
67
+ }
68
+ if (/^h[1-6]$/.test(tagName)) {
69
+ const trimmedText2 = element.textContent?.trim();
70
+ return trimmedText2 ? `heading(${tagName}): "${trimmedText2.slice(0, 60)}"` : tagName;
71
+ }
72
+ if (["div", "main", "section", "article", "header", "footer", "nav"].includes(
73
+ tagName
74
+ )) {
75
+ const role2 = element.getAttribute("role");
76
+ if (role2) {
77
+ return role2;
78
+ }
79
+ }
80
+ const trimmedText = element.textContent?.trim();
81
+ if (trimmedText && trimmedText.length < 120) {
82
+ const role2 = element.getAttribute("role");
83
+ const label = role2 ?? tagName;
84
+ return `${label}: "${trimmedText.slice(0, 60)}"`;
85
+ }
86
+ const role = element.getAttribute("role");
87
+ if (role) {
88
+ return role;
89
+ }
90
+ const className = element.className;
91
+ if (typeof className === "string" && className) {
92
+ const meaningfulClassName = className.split(/\s+/).find((classToken) => {
93
+ return !classToken.startsWith("_") && !classToken.match(/^[a-z]{1,2}\d/) && classToken.length > 2;
94
+ });
95
+ if (meaningfulClassName) {
96
+ return `${tagName}.${meaningfulClassName}`;
97
+ }
98
+ }
99
+ return tagName;
100
+ }
101
+ function buildSelector(element) {
102
+ const parts = [];
103
+ let currentElement = element;
104
+ while (currentElement && currentElement !== document.documentElement) {
105
+ const tag = currentElement.tagName.toLowerCase();
106
+ const id = currentElement.id;
107
+ if (id) {
108
+ parts.unshift(`#${id}`);
109
+ break;
110
+ }
111
+ const parentElement = currentElement.parentElement;
112
+ if (parentElement) {
113
+ const currentTag = currentElement.tagName;
114
+ const siblings = Array.from(parentElement.children);
115
+ const siblingElementsWithSameTag = siblings.filter((sibling) => {
116
+ return sibling.tagName === currentTag;
117
+ });
118
+ if (siblingElementsWithSameTag.length > 1) {
119
+ const index = siblingElementsWithSameTag.indexOf(currentElement) + 1;
120
+ parts.unshift(`${tag}:nth-of-type(${index})`);
121
+ } else {
122
+ parts.unshift(tag);
123
+ }
124
+ } else {
125
+ parts.unshift(tag);
126
+ }
127
+ currentElement = parentElement;
128
+ }
129
+ return parts.join(" > ");
130
+ }
131
+ function getTextMetrics(element) {
132
+ const text = element.textContent?.trim();
133
+ if (!text) {
134
+ return null;
135
+ }
136
+ const style = window.getComputedStyle(element);
137
+ const parsedLineHeight = Number.parseFloat(style.lineHeight);
138
+ const computedLineHeight = Number.isNaN(parsedLineHeight) ? Number.parseFloat(style.fontSize) * 1.2 : parsedLineHeight;
139
+ try {
140
+ const range = document.createRange();
141
+ range.selectNodeContents(element);
142
+ const lineRects = Array.from(range.getClientRects()).filter((lineRect) => {
143
+ return lineRect.width > 0 && lineRect.height > 0;
144
+ });
145
+ let tightWidth = 0;
146
+ for (const lineRect of lineRects) {
147
+ tightWidth = Math.max(tightWidth, lineRect.width);
148
+ }
149
+ const lineCount = lineRects.length;
150
+ if (lineCount === 0) {
151
+ return null;
152
+ }
153
+ return {
154
+ tightWidth,
155
+ lineCount,
156
+ lineHeight: computedLineHeight
157
+ };
158
+ } catch {
159
+ return null;
160
+ }
161
+ }
162
+ function serializeStyledElement(element) {
163
+ const clone = element.cloneNode(true);
164
+ const applyStylesRecursively = (sourceNode, clonedNode) => {
165
+ const computedStyle = window.getComputedStyle(sourceNode);
166
+ const styleText = Array.from(computedStyle).map((propertyName) => {
167
+ return `${propertyName}: ${computedStyle.getPropertyValue(propertyName)};`;
168
+ }).join(" ");
169
+ clonedNode.setAttribute("style", styleText);
170
+ const sourceChildren = Array.from(sourceNode.children);
171
+ const clonedChildren = Array.from(clonedNode.children);
172
+ for (let childIndex = 0; childIndex < sourceChildren.length; childIndex += 1) {
173
+ const sourceChild = sourceChildren[childIndex];
174
+ const clonedChild = clonedChildren[childIndex];
175
+ if (!sourceChild || !clonedChild) {
176
+ continue;
177
+ }
178
+ applyStylesRecursively(sourceChild, clonedChild);
179
+ }
180
+ };
181
+ if (clone instanceof Element) {
182
+ applyStylesRecursively(element, clone);
183
+ }
184
+ return clone instanceof Element ? clone.outerHTML : element.outerHTML;
185
+ }
186
+ function buildElementDescriptor({
187
+ element,
188
+ clickPosition
189
+ }) {
190
+ const selectableData = getSelectableDataFromElement(element);
191
+ if (selectableData) {
192
+ return selectableData;
193
+ }
194
+ const textMetrics = getTextMetrics(element);
195
+ const sourceLocation = element instanceof HTMLElement ? getSourceLocation(element) : void 0;
196
+ return {
197
+ kind: "react-element",
198
+ selector: buildSelector(element),
199
+ tagName: element.tagName.toLowerCase(),
200
+ elementType: identifyElement(element),
201
+ textContent: element.textContent?.trim()?.slice(0, 200) ?? null,
202
+ rect: getElementBoundingRect(element),
203
+ textMetrics,
204
+ outerHTML: serializeStyledElement(element).slice(0, 4e3),
205
+ clickPosition,
206
+ sourceLocation
207
+ };
208
+ }
209
+ export {
210
+ buildElementDescriptor,
211
+ getNearestSelectableElement
212
+ };
213
+ //# sourceMappingURL=elementDescriptor.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 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 { getSourceLocation } from \"../fiber\";\nimport { getElementBoundingRect } from \"../interactions/selectionGeometry\";\n\nexport function getNearestSelectableElement(element: Element): Element | null {\n return element.closest(`[${SELECT_MODE_SELECTABLE_ATTRIBUTE}]`);\n}\n\nfunction getSelectableDataFromElement(element: Element): SelectableData | null {\n const selectableElement = getNearestSelectableElement(element);\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 */\nfunction 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 * Serializes `element` (and descendants) to HTML with the *computed* styles\n * inlined onto every node. The agent uses this snippet as visual context\n * for the change request \u2014 bare `outerHTML` would include only the source\n * class names, which can't be resolved without the full Tailwind/CSS\n * stylesheet.\n *\n * The result is sliced to 4000 chars at the call site to bound prompt\n * size; that's enough for a single component but not a whole page.\n */\nfunction serializeStyledElement(element: Element): string {\n const clone = element.cloneNode(true);\n\n const applyStylesRecursively = (sourceNode: Element, clonedNode: Element) => {\n const computedStyle = window.getComputedStyle(sourceNode);\n const styleText = Array.from(computedStyle)\n .map((propertyName) => {\n return `${propertyName}: ${computedStyle.getPropertyValue(propertyName)};`;\n })\n .join(\" \");\n\n clonedNode.setAttribute(\"style\", styleText);\n\n const sourceChildren = Array.from(sourceNode.children);\n const clonedChildren = Array.from(clonedNode.children);\n for (\n let childIndex = 0;\n childIndex < sourceChildren.length;\n childIndex += 1\n ) {\n const sourceChild = sourceChildren[childIndex];\n const clonedChild = clonedChildren[childIndex];\n if (!sourceChild || !clonedChild) {\n continue;\n }\n\n applyStylesRecursively(sourceChild, clonedChild);\n }\n };\n\n if (clone instanceof Element) {\n applyStylesRecursively(element, clone);\n }\n\n return clone instanceof Element ? clone.outerHTML : element.outerHTML;\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}: {\n element: Element;\n clickPosition: SelectModeClickPosition;\n}): SelectableData {\n const selectableData = getSelectableDataFromElement(element);\n if (selectableData) {\n return selectableData;\n }\n\n const textMetrics = getTextMetrics(element);\n const sourceLocation =\n element instanceof HTMLElement ? getSourceLocation(element) : undefined;\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: serializeStyledElement(element).slice(0, 4000),\n clickPosition,\n sourceLocation,\n };\n}\n"],
5
+ "mappings": "AAMA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,yBAAyB;AAClC,SAAS,8BAA8B;AAEhC,SAAS,4BAA4B,SAAkC;AAC5E,SAAO,QAAQ,QAAQ,IAAI,gCAAgC,GAAG;AAChE;AAEA,SAAS,6BAA6B,SAAyC;AAC7E,QAAM,oBAAoB,4BAA4B,OAAO;AAC7D,MAAI,CAAC,mBAAmB;AACtB,WAAO;AAAA,EACT;AAEA,QAAM,oBAAoB;AAAA,IACxB,kBAAkB,aAAa,wCAAwC;AAAA,EACzE;AACA,MAAI,CAAC,mBAAmB;AAC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