@replohq/canopy-sdk 1.0.4 → 1.2.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.
@@ -1,4 +1,4 @@
1
- export type ReploScriptType = "GA4" | "GoogleTagManager" | "Meta" | "TikTok" | "Pinterest" | "Reddit" | "Snapchat" | "Hotjar" | "MicrosoftClarity" | "Segment" | "snippet" | "custom";
1
+ export type ReploScriptType = "GA4" | "GoogleTagManager" | "Meta" | "TikTok" | "Pinterest" | "Reddit" | "Snapchat" | "Hotjar" | "MicrosoftClarity" | "Segment" | "Northbeam" | "snippet" | "custom";
2
2
  export type ConsentCategory = "necessary" | "analytics" | "marketing" | "preferences" | "sale_of_data";
3
3
  export type ConsentMode = "off" | "simple" | "per-category";
4
4
  export type ScriptTagDescriptor = {
@@ -12,7 +12,7 @@ export type ScriptTagDescriptor = {
12
12
  body: string;
13
13
  };
14
14
  export type ReploScriptEntry = {
15
- type: "GA4" | "GoogleTagManager" | "Meta" | "TikTok" | "Pinterest" | "Reddit" | "Snapchat" | "Hotjar" | "MicrosoftClarity" | "Segment";
15
+ type: "GA4" | "GoogleTagManager" | "Meta" | "TikTok" | "Pinterest" | "Reddit" | "Snapchat" | "Hotjar" | "MicrosoftClarity" | "Segment" | "Northbeam";
16
16
  identifier: string;
17
17
  requiredConsent?: ConsentCategory[];
18
18
  } | {
@@ -0,0 +1,48 @@
1
+ export type PageAnnotationColor = "red" | "purple" | "amber";
2
+ export type PageAnnotationPlacement = "element" | "pageTop";
3
+ export type PageAnnotationMarker = {
4
+ id: string;
5
+ number: number;
6
+ color: PageAnnotationColor;
7
+ selector: string;
8
+ placement: PageAnnotationPlacement;
9
+ };
10
+ export type PageAnnotationViewportRect = {
11
+ x: number;
12
+ y: number;
13
+ width: number;
14
+ height: number;
15
+ };
16
+ export type PageAnnotationsSetMessage = {
17
+ type: "replo:annotations:set";
18
+ protocolVersion: 1;
19
+ setId: string;
20
+ markers: PageAnnotationMarker[];
21
+ };
22
+ export type PageAnnotationsClearMessage = {
23
+ type: "replo:annotations:clear";
24
+ };
25
+ export type PageAnnotationsRequestReadyMessage = {
26
+ type: "replo:annotations:requestReady";
27
+ };
28
+ export type PageAnnotationsParentMessage = PageAnnotationsSetMessage | PageAnnotationsClearMessage | PageAnnotationsRequestReadyMessage;
29
+ export type PageAnnotationsReadyMessage = {
30
+ type: "replo:annotations:ready";
31
+ protocolVersion: 1;
32
+ };
33
+ export type PageAnnotationsClickedMessage = {
34
+ type: "replo:annotations:clicked";
35
+ id: string;
36
+ viewportRect: PageAnnotationViewportRect;
37
+ };
38
+ export type PageAnnotationsActiveRectMessage = {
39
+ type: "replo:annotations:activeRect";
40
+ id: string;
41
+ viewportRect: PageAnnotationViewportRect;
42
+ };
43
+ export type PageAnnotationsUnresolvedMessage = {
44
+ type: "replo:annotations:unresolved";
45
+ setId: string;
46
+ ids: string[];
47
+ };
48
+ export type PageAnnotationsIframeMessage = PageAnnotationsReadyMessage | PageAnnotationsClickedMessage | PageAnnotationsActiveRectMessage | PageAnnotationsUnresolvedMessage;
@@ -0,0 +1,134 @@
1
+ import { z } from "zod";
2
+ export declare const PAGE_ANNOTATIONS_PROTOCOL_VERSION = 1;
3
+ export declare const pageAnnotationColorSchema: z.ZodEnum<{
4
+ red: "red";
5
+ purple: "purple";
6
+ amber: "amber";
7
+ }>;
8
+ export declare const pageAnnotationPlacementSchema: z.ZodEnum<{
9
+ element: "element";
10
+ pageTop: "pageTop";
11
+ }>;
12
+ export declare const pageAnnotationMarkerSchema: z.ZodObject<{
13
+ id: z.ZodString;
14
+ number: z.ZodNumber;
15
+ color: z.ZodEnum<{
16
+ red: "red";
17
+ purple: "purple";
18
+ amber: "amber";
19
+ }>;
20
+ selector: z.ZodString;
21
+ placement: z.ZodDefault<z.ZodEnum<{
22
+ element: "element";
23
+ pageTop: "pageTop";
24
+ }>>;
25
+ }, z.core.$strip>;
26
+ export declare const pageAnnotationViewportRectSchema: z.ZodObject<{
27
+ x: z.ZodNumber;
28
+ y: z.ZodNumber;
29
+ width: z.ZodNumber;
30
+ height: z.ZodNumber;
31
+ }, z.core.$strip>;
32
+ export declare const pageAnnotationsSetMessageSchema: z.ZodObject<{
33
+ type: z.ZodLiteral<"replo:annotations:set">;
34
+ protocolVersion: z.ZodLiteral<1>;
35
+ setId: z.ZodString;
36
+ markers: z.ZodArray<z.ZodObject<{
37
+ id: z.ZodString;
38
+ number: z.ZodNumber;
39
+ color: z.ZodEnum<{
40
+ red: "red";
41
+ purple: "purple";
42
+ amber: "amber";
43
+ }>;
44
+ selector: z.ZodString;
45
+ placement: z.ZodDefault<z.ZodEnum<{
46
+ element: "element";
47
+ pageTop: "pageTop";
48
+ }>>;
49
+ }, z.core.$strip>>;
50
+ }, z.core.$strip>;
51
+ export declare const pageAnnotationsClearMessageSchema: z.ZodObject<{
52
+ type: z.ZodLiteral<"replo:annotations:clear">;
53
+ }, z.core.$strip>;
54
+ export declare const pageAnnotationsRequestReadyMessageSchema: z.ZodObject<{
55
+ type: z.ZodLiteral<"replo:annotations:requestReady">;
56
+ }, z.core.$strip>;
57
+ export declare const pageAnnotationsParentMessageSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
58
+ type: z.ZodLiteral<"replo:annotations:set">;
59
+ protocolVersion: z.ZodLiteral<1>;
60
+ setId: z.ZodString;
61
+ markers: z.ZodArray<z.ZodObject<{
62
+ id: z.ZodString;
63
+ number: z.ZodNumber;
64
+ color: z.ZodEnum<{
65
+ red: "red";
66
+ purple: "purple";
67
+ amber: "amber";
68
+ }>;
69
+ selector: z.ZodString;
70
+ placement: z.ZodDefault<z.ZodEnum<{
71
+ element: "element";
72
+ pageTop: "pageTop";
73
+ }>>;
74
+ }, z.core.$strip>>;
75
+ }, z.core.$strip>, z.ZodObject<{
76
+ type: z.ZodLiteral<"replo:annotations:clear">;
77
+ }, z.core.$strip>, z.ZodObject<{
78
+ type: z.ZodLiteral<"replo:annotations:requestReady">;
79
+ }, z.core.$strip>], "type">;
80
+ export declare const pageAnnotationsReadyMessageSchema: z.ZodObject<{
81
+ type: z.ZodLiteral<"replo:annotations:ready">;
82
+ protocolVersion: z.ZodLiteral<1>;
83
+ }, z.core.$strip>;
84
+ export declare const pageAnnotationsClickedMessageSchema: z.ZodObject<{
85
+ type: z.ZodLiteral<"replo:annotations:clicked">;
86
+ id: z.ZodString;
87
+ viewportRect: z.ZodObject<{
88
+ x: z.ZodNumber;
89
+ y: z.ZodNumber;
90
+ width: z.ZodNumber;
91
+ height: z.ZodNumber;
92
+ }, z.core.$strip>;
93
+ }, z.core.$strip>;
94
+ export declare const pageAnnotationsActiveRectMessageSchema: z.ZodObject<{
95
+ type: z.ZodLiteral<"replo:annotations:activeRect">;
96
+ id: z.ZodString;
97
+ viewportRect: z.ZodObject<{
98
+ x: z.ZodNumber;
99
+ y: z.ZodNumber;
100
+ width: z.ZodNumber;
101
+ height: z.ZodNumber;
102
+ }, z.core.$strip>;
103
+ }, z.core.$strip>;
104
+ export declare const pageAnnotationsUnresolvedMessageSchema: z.ZodObject<{
105
+ type: z.ZodLiteral<"replo:annotations:unresolved">;
106
+ setId: z.ZodString;
107
+ ids: z.ZodArray<z.ZodString>;
108
+ }, z.core.$strip>;
109
+ export declare const pageAnnotationsIframeMessageSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
110
+ type: z.ZodLiteral<"replo:annotations:ready">;
111
+ protocolVersion: z.ZodLiteral<1>;
112
+ }, z.core.$strip>, z.ZodObject<{
113
+ type: z.ZodLiteral<"replo:annotations:clicked">;
114
+ id: z.ZodString;
115
+ viewportRect: z.ZodObject<{
116
+ x: z.ZodNumber;
117
+ y: z.ZodNumber;
118
+ width: z.ZodNumber;
119
+ height: z.ZodNumber;
120
+ }, z.core.$strip>;
121
+ }, z.core.$strip>, z.ZodObject<{
122
+ type: z.ZodLiteral<"replo:annotations:activeRect">;
123
+ id: z.ZodString;
124
+ viewportRect: z.ZodObject<{
125
+ x: z.ZodNumber;
126
+ y: z.ZodNumber;
127
+ width: z.ZodNumber;
128
+ height: z.ZodNumber;
129
+ }, z.core.$strip>;
130
+ }, z.core.$strip>, z.ZodObject<{
131
+ type: z.ZodLiteral<"replo:annotations:unresolved">;
132
+ setId: z.ZodString;
133
+ ids: z.ZodArray<z.ZodString>;
134
+ }, z.core.$strip>], "type">;
@@ -0,0 +1,61 @@
1
+ import { z } from 'zod';
2
+
3
+ // ../schemas/pageAnnotations.ts
4
+ var PAGE_ANNOTATIONS_PROTOCOL_VERSION = 1;
5
+ var pageAnnotationColorSchema = z.enum(["red", "purple", "amber"]).describe("PageAnnotationColor");
6
+ var pageAnnotationPlacementSchema = z.enum(["element", "pageTop"]).describe("PageAnnotationPlacement");
7
+ var pageAnnotationMarkerSchema = z.object({
8
+ id: z.string().min(1).max(256),
9
+ number: z.number().int().min(1).max(99),
10
+ color: pageAnnotationColorSchema,
11
+ selector: z.string().min(1).max(2e3),
12
+ // "pageTop" markers ignore the selector and stack near the top of the
13
+ // page (page-wide findings); "element" markers pin to their selector.
14
+ placement: pageAnnotationPlacementSchema.default("element")
15
+ }).describe("PageAnnotationMarker");
16
+ var pageAnnotationViewportRectSchema = z.object({
17
+ x: z.number(),
18
+ y: z.number(),
19
+ width: z.number(),
20
+ height: z.number()
21
+ }).describe("PageAnnotationViewportRect");
22
+ var pageAnnotationsSetMessageSchema = z.object({
23
+ type: z.literal("replo:annotations:set"),
24
+ protocolVersion: z.literal(PAGE_ANNOTATIONS_PROTOCOL_VERSION),
25
+ setId: z.string().min(1),
26
+ markers: z.array(pageAnnotationMarkerSchema).max(50)
27
+ }).describe("PageAnnotationsSetMessage");
28
+ var pageAnnotationsClearMessageSchema = z.object({ type: z.literal("replo:annotations:clear") }).describe("PageAnnotationsClearMessage");
29
+ var pageAnnotationsRequestReadyMessageSchema = z.object({ type: z.literal("replo:annotations:requestReady") }).describe("PageAnnotationsRequestReadyMessage");
30
+ var pageAnnotationsParentMessageSchema = z.discriminatedUnion("type", [
31
+ pageAnnotationsSetMessageSchema,
32
+ pageAnnotationsClearMessageSchema,
33
+ pageAnnotationsRequestReadyMessageSchema
34
+ ]).describe("PageAnnotationsParentMessage");
35
+ var pageAnnotationsReadyMessageSchema = z.object({
36
+ type: z.literal("replo:annotations:ready"),
37
+ protocolVersion: z.literal(PAGE_ANNOTATIONS_PROTOCOL_VERSION)
38
+ }).describe("PageAnnotationsReadyMessage");
39
+ var pageAnnotationsClickedMessageSchema = z.object({
40
+ type: z.literal("replo:annotations:clicked"),
41
+ id: z.string().min(1).max(256),
42
+ viewportRect: pageAnnotationViewportRectSchema
43
+ }).describe("PageAnnotationsClickedMessage");
44
+ var pageAnnotationsActiveRectMessageSchema = z.object({
45
+ type: z.literal("replo:annotations:activeRect"),
46
+ id: z.string().min(1).max(256),
47
+ viewportRect: pageAnnotationViewportRectSchema
48
+ }).describe("PageAnnotationsActiveRectMessage");
49
+ var pageAnnotationsUnresolvedMessageSchema = z.object({
50
+ type: z.literal("replo:annotations:unresolved"),
51
+ setId: z.string().min(1),
52
+ ids: z.array(z.string().min(1).max(256)).max(50)
53
+ }).describe("PageAnnotationsUnresolvedMessage");
54
+ var pageAnnotationsIframeMessageSchema = z.discriminatedUnion("type", [
55
+ pageAnnotationsReadyMessageSchema,
56
+ pageAnnotationsClickedMessageSchema,
57
+ pageAnnotationsActiveRectMessageSchema,
58
+ pageAnnotationsUnresolvedMessageSchema
59
+ ]).describe("PageAnnotationsIframeMessage");
60
+
61
+ export { PAGE_ANNOTATIONS_PROTOCOL_VERSION, pageAnnotationColorSchema, pageAnnotationMarkerSchema, pageAnnotationPlacementSchema, pageAnnotationViewportRectSchema, pageAnnotationsActiveRectMessageSchema, pageAnnotationsClearMessageSchema, pageAnnotationsClickedMessageSchema, pageAnnotationsIframeMessageSchema, pageAnnotationsParentMessageSchema, pageAnnotationsReadyMessageSchema, pageAnnotationsRequestReadyMessageSchema, pageAnnotationsSetMessageSchema, pageAnnotationsUnresolvedMessageSchema };
@@ -1,5 +1,5 @@
1
- import { exhaustiveSwitch } from '../../chunk-UWHM3FKU.mjs';
2
1
  import { parseJsonOrNull } from '../../chunk-VKO7P3ED.mjs';
2
+ import { exhaustiveSwitch } from '../../chunk-UWHM3FKU.mjs';
3
3
  import '../../chunk-ILGEM42C.mjs';
4
4
  import '../../chunk-FNTGY7I5.mjs';
5
5
  import { z } from 'zod';
@@ -95,6 +95,15 @@ gtag('config', '${id}');`
95
95
  body: `!function(){var i="analytics",analytics=window[i]=window[i]||[];if(!analytics.initialize)if(analytics.invoked)window.console&&console.error&&console.error("Segment snippet included twice.");else{analytics.invoked=!0;analytics.methods=["trackSubmit","trackClick","trackLink","trackForm","pageview","identify","reset","group","track","ready","alias","debug","page","screen","once","off","on","addSourceMiddleware","addIntegrationMiddleware","setAnonymousId","addDestinationMiddleware","register"];analytics.factory=function(e){return function(){var t=Array.prototype.slice.call(arguments);t.unshift(e);analytics.push(t);return analytics}};for(var e=0;e<analytics.methods.length;e++){var key=analytics.methods[e];analytics[key]=analytics.factory(key)}analytics.load=function(key,e){var t=document.createElement("script");t.type="text/javascript";t.async=!0;t.src="https://cdn.segment.com/analytics.js/v1/"+key+"/analytics.min.js";var n=document.getElementsByTagName("script")[0];n.parentNode.insertBefore(t,n);analytics._loadOptions=e};analytics._writeKey="${id}";analytics.SNIPPET_VERSION="5.2.0";analytics.load("${id}");analytics.page();}}();`
96
96
  }
97
97
  ]
98
+ },
99
+ Northbeam: {
100
+ defaultConsent: ["analytics", "marketing"],
101
+ buildTags: (id) => [
102
+ {
103
+ kind: "inline",
104
+ body: `(function(){var t;(n=t=t||{}).A="identify",n.B="trackPageView",n.C="fireEmailCaptureEvent",n.D="fireCustomGoal",n.E="firePurchaseEvent",n.F="trackPageViewInitial",n.G="fireSlimPurchaseEvent",n.H="identifyCustomerId";var n="https://j.northbeam.io/ota-sp/${id}.js";function r(n){for(var e=[],t=1;t<arguments.length;t++)e[t-1]=arguments[t];i.push({fnName:n,args:e})}var e,i=[],a=((e={})[t.F]=function(n){r(t.F,n)},(a={_q:i})[t.A]=function(n,e){return r(t.A,n,e)},a[t.B]=function(){return r(t.B)},a[t.C]=function(n,e){return r(t.C,n,e)},a[t.D]=function(n,e){return r(t.D,n,e)},a[t.E]=function(n){return r(t.E,n)},a[t.G]=function(n){return r(t.G,n)},a[t.H]=function(n,e){return r(t.H,n,e)},Object.assign(function(n){for(var e=[],t=1;t<arguments.length;t++)e.push(arguments[t]);return r.apply(null,[n].concat(e))},a));window.Northbeam=a,(a=document.createElement("script")).async=!0,a.src=n,document.head.appendChild(a),e.trackPageViewInitial(window.location.href);})()`
105
+ }
106
+ ]
98
107
  }
99
108
  };
100
109
  function buildScriptTags({
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../consent/script-snippets.ts"],
4
- "sourcesContent": ["import type {\n ConsentCategory,\n ReploScriptType,\n ScriptTagDescriptor,\n} from \"schemas/generated/consent\";\n\n// Identifier providers: those whose script the runtime synthesizes from an ID.\n// `snippet` (pasted whole) and `custom` carry their own bodies instead.\ntype ProviderType = Exclude<ReploScriptType, \"custom\" | \"snippet\">;\n\n/**\n * Runtime-safe per-provider data for the consent system. This is the subset of\n * the website-builder miniapp's `scriptConstants.ts` that must ship in the\n * customer site bundle: how to materialize each provider's script tags, and the\n * default consent category that gates it. Miniapp-only concerns (LLM detection\n * schemas, logos, marketing copy) intentionally stay in the miniapp.\n *\n * Unlike the miniapp's `buildSnippet`, which returns a JSX *string* for the\n * agent to paste into `layout.tsx`, this returns structured descriptors so the\n * runtime can inject real DOM nodes (inline `<script>` bodies set via React's\n * `dangerouslySetInnerHTML` never execute).\n */\ntype ProviderSnippet = {\n defaultConsent: ConsentCategory[];\n buildTags: (identifier: string) => ScriptTagDescriptor[];\n};\n\n/**\n * NOTE (Ryan, 2026-05-28, REPL-27515): `defaultConsent` is net-new,\n * legally-sensitive categorization that does not exist elsewhere in the repo.\n * These are conservative defaults a customer can override per entry via\n * `requiredConsent`; container/CDP providers that fan out to multiple vendors\n * (GTM, Segment) require the union of categories they can serve.\n */\nconst PROVIDER_SNIPPETS: Record<ProviderType, ProviderSnippet> = {\n GA4: {\n defaultConsent: [\"analytics\"],\n buildTags: (id) => [\n {\n kind: \"external\",\n src: `https://www.googletagmanager.com/gtag/js?id=${id}`,\n },\n {\n kind: \"inline\",\n body: `window.dataLayer = window.dataLayer || [];\\nfunction gtag(){dataLayer.push(arguments);}\\ngtag('js', new Date());\\ngtag('config', '${id}');`,\n },\n ],\n },\n GoogleTagManager: {\n defaultConsent: [\"analytics\", \"marketing\"],\n buildTags: (id) => [\n {\n kind: \"inline\",\n body: `(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);})(window,document,'script','dataLayer','${id}');`,\n },\n ],\n },\n Meta: {\n defaultConsent: [\"marketing\"],\n buildTags: (id) => [\n {\n kind: \"inline\",\n body: `!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,document,'script','https://connect.facebook.net/en_US/fbevents.js');fbq('init','${id}');fbq('track','PageView');`,\n },\n ],\n },\n TikTok: {\n defaultConsent: [\"marketing\"],\n buildTags: (id) => [\n {\n kind: \"inline\",\n body: `!function(w,d,t){w.TiktokAnalyticsObject=t;var ttq=w[t]=w[t]||[];ttq.methods=[\"page\",\"track\",\"identify\",\"instances\",\"debug\",\"on\",\"off\",\"once\",\"ready\",\"alias\",\"group\",\"enableCookie\",\"disableCookie\",\"holdConsent\",\"revokeConsent\",\"grantConsent\"],ttq.setAndDefer=function(t,e){t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}};for(var i=0;i<ttq.methods.length;i++)ttq.setAndDefer(ttq,ttq.methods[i]);ttq.instance=function(t){for(var e=ttq._i[t]||[],n=0;n<ttq.methods.length;n++)ttq.setAndDefer(e,ttq.methods[n]);return e};ttq.load=function(e,n){var r=\"https://analytics.tiktok.com/i18n/pixel/events.js\",o=n&&n.partner;ttq._i=ttq._i||{},ttq._i[e]=[],ttq._i[e]._u=r,ttq._t=ttq._t||{},ttq._t[e]=+new Date,ttq._o=ttq._o||{},ttq._o[e]=n||{};var a=document.createElement(\"script\");a.type=\"text/javascript\",a.async=!0,a.src=r+\"?sdkid=\"+e+\"&lib=\"+t;var s=document.getElementsByTagName(\"script\")[0];s.parentNode.insertBefore(a,s)};ttq.load('${id}');ttq.page();}(window,document,'ttq');`,\n },\n ],\n },\n Pinterest: {\n defaultConsent: [\"marketing\"],\n buildTags: (id) => [\n {\n kind: \"inline\",\n body: `!function(e){if(!window.pintrk){window.pintrk=function(){window.pintrk.queue.push(Array.prototype.slice.call(arguments))};var n=window.pintrk;n.queue=[],n.version=\"3.0\";var t=document.createElement(\"script\");t.async=!0,t.src=e;var r=document.getElementsByTagName(\"script\")[0];r.parentNode.insertBefore(t,r)}}(\"https://s.pinimg.com/ct/core.js\");pintrk('load','${id}');pintrk('page');`,\n },\n ],\n },\n Reddit: {\n defaultConsent: [\"marketing\"],\n buildTags: (id) => [\n {\n kind: \"inline\",\n body: `!function(w,d){if(!w.rdt){var p=w.rdt=function(){p.sendEvent?p.sendEvent.apply(p,arguments):p.callQueue.push(arguments)};p.callQueue=[];var t=d.createElement(\"script\");t.src=\"https://www.redditstatic.com/ads/pixel.js\",t.async=!0;var s=d.getElementsByTagName(\"script\")[0];s.parentNode.insertBefore(t,s)}}(window,document);rdt('init','${id}');rdt('track','PageVisit');`,\n },\n ],\n },\n Snapchat: {\n defaultConsent: [\"marketing\"],\n buildTags: (id) => [\n {\n kind: \"inline\",\n body: `(function(e,t,n){if(e.snaptr)return;var a=e.snaptr=function(){a.handleRequest?a.handleRequest.apply(a,arguments):a.queue.push(arguments)};a.queue=[];var s='script';var r=t.createElement(s);r.async=!0;r.src=n;var u=t.getElementsByTagName(s)[0];u.parentNode.insertBefore(r,u);})(window,document,'https://sc-static.net/scevent.min.js');snaptr('init','${id}',{});snaptr('track','PAGE_VIEW');`,\n },\n ],\n },\n Hotjar: {\n defaultConsent: [\"analytics\"],\n buildTags: (id) => [\n {\n kind: \"inline\",\n body: `(function(h,o,t,j,a,r){h.hj=h.hj||function(){(h.hj.q=h.hj.q||[]).push(arguments)};h._hjSettings={hjid:${id},hjsv:6};a=o.getElementsByTagName('head')[0];r=o.createElement('script');r.async=1;r.src=t+h._hjSettings.hjid+j+h._hjSettings.hjsv;a.appendChild(r);})(window,document,'https://static.hotjar.com/c/hotjar-','.js?sv=');`,\n },\n ],\n },\n MicrosoftClarity: {\n defaultConsent: [\"analytics\"],\n buildTags: (id) => [\n {\n kind: \"inline\",\n body: `(function(c,l,a,r,i,t,y){c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};t=l.createElement(r);t.async=1;t.src=\"https://www.clarity.ms/tag/\"+i;y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);})(window,document,\"clarity\",\"script\",\"${id}\");`,\n },\n ],\n },\n Segment: {\n defaultConsent: [\"analytics\", \"marketing\"],\n buildTags: (id) => [\n {\n kind: \"inline\",\n body: `!function(){var i=\"analytics\",analytics=window[i]=window[i]||[];if(!analytics.initialize)if(analytics.invoked)window.console&&console.error&&console.error(\"Segment snippet included twice.\");else{analytics.invoked=!0;analytics.methods=[\"trackSubmit\",\"trackClick\",\"trackLink\",\"trackForm\",\"pageview\",\"identify\",\"reset\",\"group\",\"track\",\"ready\",\"alias\",\"debug\",\"page\",\"screen\",\"once\",\"off\",\"on\",\"addSourceMiddleware\",\"addIntegrationMiddleware\",\"setAnonymousId\",\"addDestinationMiddleware\",\"register\"];analytics.factory=function(e){return function(){var t=Array.prototype.slice.call(arguments);t.unshift(e);analytics.push(t);return analytics}};for(var e=0;e<analytics.methods.length;e++){var key=analytics.methods[e];analytics[key]=analytics.factory(key)}analytics.load=function(key,e){var t=document.createElement(\"script\");t.type=\"text/javascript\";t.async=!0;t.src=\"https://cdn.segment.com/analytics.js/v1/\"+key+\"/analytics.min.js\";var n=document.getElementsByTagName(\"script\")[0];n.parentNode.insertBefore(t,n);analytics._loadOptions=e};analytics._writeKey=\"${id}\";analytics.SNIPPET_VERSION=\"5.2.0\";analytics.load(\"${id}\");analytics.page();}}();`,\n },\n ],\n },\n};\n\n/**\n * Snippet providers don't synthesize tags (the user pastes the provider-issued\n * snippet as the entry's `body`), but they still get a first-class default\n * consent categorization like identifier providers.\n */\n/**\n * Returns the structured tag descriptors for a named provider. A single provider\n * can produce multiple tags (e.g. GA4 = external loader + inline config), which\n * the runtime injects in order.\n */\nexport function buildScriptTags({\n type,\n identifier,\n}: {\n type: ProviderType;\n identifier: string;\n}): ScriptTagDescriptor[] {\n return PROVIDER_SNIPPETS[type].buildTags(identifier);\n}\n\n/**\n * The default consent categories that gate an identifier-provider script when an\n * entry does not specify `requiredConsent`. `snippet` and `custom` entries carry\n * `requiredConsent` explicitly (the runtime has no default for them), so this is\n * only consulted for identifier providers. Overridable per entry by the customer.\n */\nexport function defaultConsentFor(type: ProviderType): ConsentCategory[] {\n return PROVIDER_SNIPPETS[type].defaultConsent;\n}\n"],
5
- "mappings": "AAkCA,MAAM,oBAA2D;AAAA,EAC/D,KAAK;AAAA,IACH,gBAAgB,CAAC,WAAW;AAAA,IAC5B,WAAW,CAAC,OAAO;AAAA,MACjB;AAAA,QACE,MAAM;AAAA,QACN,KAAK,+CAA+C,EAAE;AAAA,MACxD;AAAA,MACA;AAAA,QACE,MAAM;AAAA,QACN,MAAM;AAAA;AAAA;AAAA,kBAAqI,EAAE;AAAA,MAC/I;AAAA,IACF;AAAA,EACF;AAAA,EACA,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kBAAkB;AAAA,IAChB,gBAAgB,CAAC,WAAW;AAAA,IAC5B,WAAW,CAAC,OAAO;AAAA,MACjB;AAAA,QACE,MAAM;AAAA,QACN,MAAM,iQAAiQ,EAAE;AAAA,MAC3Q;AAAA,IACF;AAAA,EACF;AAAA,EACA,SAAS;AAAA,IACP,gBAAgB,CAAC,aAAa,WAAW;AAAA,IACzC,WAAW,CAAC,OAAO;AAAA,MACjB;AAAA,QACE,MAAM;AAAA,QACN,MAAM,iiCAAiiC,EAAE,uDAAuD,EAAE;AAAA,MACpmC;AAAA,IACF;AAAA,EACF;AACF;AAYO,SAAS,gBAAgB;AAAA,EAC9B;AAAA,EACA;AACF,GAG0B;AACxB,SAAO,kBAAkB,IAAI,EAAE,UAAU,UAAU;AACrD;AAQO,SAAS,kBAAkB,MAAuC;AACvE,SAAO,kBAAkB,IAAI,EAAE;AACjC;",
4
+ "sourcesContent": ["import type {\n ConsentCategory,\n ReploScriptType,\n ScriptTagDescriptor,\n} from \"schemas/generated/consent\";\n\n// Identifier providers: those whose script the runtime synthesizes from an ID.\n// `snippet` (pasted whole) and `custom` carry their own bodies instead.\ntype ProviderType = Exclude<ReploScriptType, \"custom\" | \"snippet\">;\n\n/**\n * Runtime-safe per-provider data for the consent system. This is the subset of\n * the website-builder miniapp's `scriptConstants.ts` that must ship in the\n * customer site bundle: how to materialize each provider's script tags, and the\n * default consent category that gates it. Miniapp-only concerns (LLM detection\n * schemas, logos, marketing copy) intentionally stay in the miniapp.\n *\n * Unlike the miniapp's `buildSnippet`, which returns a JSX *string* for the\n * agent to paste into `layout.tsx`, this returns structured descriptors so the\n * runtime can inject real DOM nodes (inline `<script>` bodies set via React's\n * `dangerouslySetInnerHTML` never execute).\n */\ntype ProviderSnippet = {\n defaultConsent: ConsentCategory[];\n buildTags: (identifier: string) => ScriptTagDescriptor[];\n};\n\n/**\n * NOTE (Ryan, 2026-05-28, REPL-27515): `defaultConsent` is net-new,\n * legally-sensitive categorization that does not exist elsewhere in the repo.\n * These are conservative defaults a customer can override per entry via\n * `requiredConsent`; container/CDP providers that fan out to multiple vendors\n * (GTM, Segment) require the union of categories they can serve.\n */\nconst PROVIDER_SNIPPETS: Record<ProviderType, ProviderSnippet> = {\n GA4: {\n defaultConsent: [\"analytics\"],\n buildTags: (id) => [\n {\n kind: \"external\",\n src: `https://www.googletagmanager.com/gtag/js?id=${id}`,\n },\n {\n kind: \"inline\",\n body: `window.dataLayer = window.dataLayer || [];\\nfunction gtag(){dataLayer.push(arguments);}\\ngtag('js', new Date());\\ngtag('config', '${id}');`,\n },\n ],\n },\n GoogleTagManager: {\n defaultConsent: [\"analytics\", \"marketing\"],\n buildTags: (id) => [\n {\n kind: \"inline\",\n body: `(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);})(window,document,'script','dataLayer','${id}');`,\n },\n ],\n },\n Meta: {\n defaultConsent: [\"marketing\"],\n buildTags: (id) => [\n {\n kind: \"inline\",\n body: `!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,document,'script','https://connect.facebook.net/en_US/fbevents.js');fbq('init','${id}');fbq('track','PageView');`,\n },\n ],\n },\n TikTok: {\n defaultConsent: [\"marketing\"],\n buildTags: (id) => [\n {\n kind: \"inline\",\n body: `!function(w,d,t){w.TiktokAnalyticsObject=t;var ttq=w[t]=w[t]||[];ttq.methods=[\"page\",\"track\",\"identify\",\"instances\",\"debug\",\"on\",\"off\",\"once\",\"ready\",\"alias\",\"group\",\"enableCookie\",\"disableCookie\",\"holdConsent\",\"revokeConsent\",\"grantConsent\"],ttq.setAndDefer=function(t,e){t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}};for(var i=0;i<ttq.methods.length;i++)ttq.setAndDefer(ttq,ttq.methods[i]);ttq.instance=function(t){for(var e=ttq._i[t]||[],n=0;n<ttq.methods.length;n++)ttq.setAndDefer(e,ttq.methods[n]);return e};ttq.load=function(e,n){var r=\"https://analytics.tiktok.com/i18n/pixel/events.js\",o=n&&n.partner;ttq._i=ttq._i||{},ttq._i[e]=[],ttq._i[e]._u=r,ttq._t=ttq._t||{},ttq._t[e]=+new Date,ttq._o=ttq._o||{},ttq._o[e]=n||{};var a=document.createElement(\"script\");a.type=\"text/javascript\",a.async=!0,a.src=r+\"?sdkid=\"+e+\"&lib=\"+t;var s=document.getElementsByTagName(\"script\")[0];s.parentNode.insertBefore(a,s)};ttq.load('${id}');ttq.page();}(window,document,'ttq');`,\n },\n ],\n },\n Pinterest: {\n defaultConsent: [\"marketing\"],\n buildTags: (id) => [\n {\n kind: \"inline\",\n body: `!function(e){if(!window.pintrk){window.pintrk=function(){window.pintrk.queue.push(Array.prototype.slice.call(arguments))};var n=window.pintrk;n.queue=[],n.version=\"3.0\";var t=document.createElement(\"script\");t.async=!0,t.src=e;var r=document.getElementsByTagName(\"script\")[0];r.parentNode.insertBefore(t,r)}}(\"https://s.pinimg.com/ct/core.js\");pintrk('load','${id}');pintrk('page');`,\n },\n ],\n },\n Reddit: {\n defaultConsent: [\"marketing\"],\n buildTags: (id) => [\n {\n kind: \"inline\",\n body: `!function(w,d){if(!w.rdt){var p=w.rdt=function(){p.sendEvent?p.sendEvent.apply(p,arguments):p.callQueue.push(arguments)};p.callQueue=[];var t=d.createElement(\"script\");t.src=\"https://www.redditstatic.com/ads/pixel.js\",t.async=!0;var s=d.getElementsByTagName(\"script\")[0];s.parentNode.insertBefore(t,s)}}(window,document);rdt('init','${id}');rdt('track','PageVisit');`,\n },\n ],\n },\n Snapchat: {\n defaultConsent: [\"marketing\"],\n buildTags: (id) => [\n {\n kind: \"inline\",\n body: `(function(e,t,n){if(e.snaptr)return;var a=e.snaptr=function(){a.handleRequest?a.handleRequest.apply(a,arguments):a.queue.push(arguments)};a.queue=[];var s='script';var r=t.createElement(s);r.async=!0;r.src=n;var u=t.getElementsByTagName(s)[0];u.parentNode.insertBefore(r,u);})(window,document,'https://sc-static.net/scevent.min.js');snaptr('init','${id}',{});snaptr('track','PAGE_VIEW');`,\n },\n ],\n },\n Hotjar: {\n defaultConsent: [\"analytics\"],\n buildTags: (id) => [\n {\n kind: \"inline\",\n body: `(function(h,o,t,j,a,r){h.hj=h.hj||function(){(h.hj.q=h.hj.q||[]).push(arguments)};h._hjSettings={hjid:${id},hjsv:6};a=o.getElementsByTagName('head')[0];r=o.createElement('script');r.async=1;r.src=t+h._hjSettings.hjid+j+h._hjSettings.hjsv;a.appendChild(r);})(window,document,'https://static.hotjar.com/c/hotjar-','.js?sv=');`,\n },\n ],\n },\n MicrosoftClarity: {\n defaultConsent: [\"analytics\"],\n buildTags: (id) => [\n {\n kind: \"inline\",\n body: `(function(c,l,a,r,i,t,y){c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};t=l.createElement(r);t.async=1;t.src=\"https://www.clarity.ms/tag/\"+i;y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);})(window,document,\"clarity\",\"script\",\"${id}\");`,\n },\n ],\n },\n Segment: {\n defaultConsent: [\"analytics\", \"marketing\"],\n buildTags: (id) => [\n {\n kind: \"inline\",\n body: `!function(){var i=\"analytics\",analytics=window[i]=window[i]||[];if(!analytics.initialize)if(analytics.invoked)window.console&&console.error&&console.error(\"Segment snippet included twice.\");else{analytics.invoked=!0;analytics.methods=[\"trackSubmit\",\"trackClick\",\"trackLink\",\"trackForm\",\"pageview\",\"identify\",\"reset\",\"group\",\"track\",\"ready\",\"alias\",\"debug\",\"page\",\"screen\",\"once\",\"off\",\"on\",\"addSourceMiddleware\",\"addIntegrationMiddleware\",\"setAnonymousId\",\"addDestinationMiddleware\",\"register\"];analytics.factory=function(e){return function(){var t=Array.prototype.slice.call(arguments);t.unshift(e);analytics.push(t);return analytics}};for(var e=0;e<analytics.methods.length;e++){var key=analytics.methods[e];analytics[key]=analytics.factory(key)}analytics.load=function(key,e){var t=document.createElement(\"script\");t.type=\"text/javascript\";t.async=!0;t.src=\"https://cdn.segment.com/analytics.js/v1/\"+key+\"/analytics.min.js\";var n=document.getElementsByTagName(\"script\")[0];n.parentNode.insertBefore(t,n);analytics._loadOptions=e};analytics._writeKey=\"${id}\";analytics.SNIPPET_VERSION=\"5.2.0\";analytics.load(\"${id}\");analytics.page();}}();`,\n },\n ],\n },\n Northbeam: {\n defaultConsent: [\"analytics\", \"marketing\"],\n buildTags: (id) => [\n {\n kind: \"inline\",\n body: `(function(){var t;(n=t=t||{}).A=\"identify\",n.B=\"trackPageView\",n.C=\"fireEmailCaptureEvent\",n.D=\"fireCustomGoal\",n.E=\"firePurchaseEvent\",n.F=\"trackPageViewInitial\",n.G=\"fireSlimPurchaseEvent\",n.H=\"identifyCustomerId\";var n=\"https://j.northbeam.io/ota-sp/${id}.js\";function r(n){for(var e=[],t=1;t<arguments.length;t++)e[t-1]=arguments[t];i.push({fnName:n,args:e})}var e,i=[],a=((e={})[t.F]=function(n){r(t.F,n)},(a={_q:i})[t.A]=function(n,e){return r(t.A,n,e)},a[t.B]=function(){return r(t.B)},a[t.C]=function(n,e){return r(t.C,n,e)},a[t.D]=function(n,e){return r(t.D,n,e)},a[t.E]=function(n){return r(t.E,n)},a[t.G]=function(n){return r(t.G,n)},a[t.H]=function(n,e){return r(t.H,n,e)},Object.assign(function(n){for(var e=[],t=1;t<arguments.length;t++)e.push(arguments[t]);return r.apply(null,[n].concat(e))},a));window.Northbeam=a,(a=document.createElement(\"script\")).async=!0,a.src=n,document.head.appendChild(a),e.trackPageViewInitial(window.location.href);})()`,\n },\n ],\n },\n};\n\n/**\n * Snippet providers don't synthesize tags (the user pastes the provider-issued\n * snippet as the entry's `body`), but they still get a first-class default\n * consent categorization like identifier providers.\n */\n/**\n * Returns the structured tag descriptors for a named provider. A single provider\n * can produce multiple tags (e.g. GA4 = external loader + inline config), which\n * the runtime injects in order.\n */\nexport function buildScriptTags({\n type,\n identifier,\n}: {\n type: ProviderType;\n identifier: string;\n}): ScriptTagDescriptor[] {\n return PROVIDER_SNIPPETS[type].buildTags(identifier);\n}\n\n/**\n * The default consent categories that gate an identifier-provider script when an\n * entry does not specify `requiredConsent`. `snippet` and `custom` entries carry\n * `requiredConsent` explicitly (the runtime has no default for them), so this is\n * only consulted for identifier providers. Overridable per entry by the customer.\n */\nexport function defaultConsentFor(type: ProviderType): ConsentCategory[] {\n return PROVIDER_SNIPPETS[type].defaultConsent;\n}\n"],
5
+ "mappings": "AAkCA,MAAM,oBAA2D;AAAA,EAC/D,KAAK;AAAA,IACH,gBAAgB,CAAC,WAAW;AAAA,IAC5B,WAAW,CAAC,OAAO;AAAA,MACjB;AAAA,QACE,MAAM;AAAA,QACN,KAAK,+CAA+C,EAAE;AAAA,MACxD;AAAA,MACA;AAAA,QACE,MAAM;AAAA,QACN,MAAM;AAAA;AAAA;AAAA,kBAAqI,EAAE;AAAA,MAC/I;AAAA,IACF;AAAA,EACF;AAAA,EACA,kBAAkB;AAAA,IAChB,gBAAgB,CAAC,aAAa,WAAW;AAAA,IACzC,WAAW,CAAC,OAAO;AAAA,MACjB;AAAA,QACE,MAAM;AAAA,QACN,MAAM,sUAAsU,EAAE;AAAA,MAChV;AAAA,IACF;AAAA,EACF;AAAA,EACA,MAAM;AAAA,IACJ,gBAAgB,CAAC,WAAW;AAAA,IAC5B,WAAW,CAAC,OAAO;AAAA,MACjB;AAAA,QACE,MAAM;AAAA,QACN,MAAM,uYAAuY,EAAE;AAAA,MACjZ;AAAA,IACF;AAAA,EACF;AAAA,EACA,QAAQ;AAAA,IACN,gBAAgB,CAAC,WAAW;AAAA,IAC5B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aAAa,WAAW;AAAA,IACzC,WAAW,CAAC,OAAO;AAAA,MACjB;AAAA,QACE,MAAM;AAAA,QACN,MAAM,gQAAgQ,EAAE;AAAA,MAC1Q;AAAA,IACF;AAAA,EACF;AACF;AAYO,SAAS,gBAAgB;AAAA,EAC9B;AAAA,EACA;AACF,GAG0B;AACxB,SAAO,kBAAkB,IAAI,EAAE,UAAU,UAAU;AACrD;AAQO,SAAS,kBAAkB,MAAuC;AACvE,SAAO,kBAAkB,IAAI,EAAE;AACjC;",
6
6
  "names": []
7
7
  }
@@ -1,4 +1,4 @@
1
- export type ReploScriptType = "GA4" | "GoogleTagManager" | "Meta" | "TikTok" | "Pinterest" | "Reddit" | "Snapchat" | "Hotjar" | "MicrosoftClarity" | "Segment" | "snippet" | "custom";
1
+ export type ReploScriptType = "GA4" | "GoogleTagManager" | "Meta" | "TikTok" | "Pinterest" | "Reddit" | "Snapchat" | "Hotjar" | "MicrosoftClarity" | "Segment" | "Northbeam" | "snippet" | "custom";
2
2
  export type ConsentCategory = "necessary" | "analytics" | "marketing" | "preferences" | "sale_of_data";
3
3
  export type ConsentMode = "off" | "simple" | "per-category";
4
4
  declare module "react" {
@@ -17,7 +17,7 @@ export type ScriptTagDescriptor = {
17
17
  body: string;
18
18
  };
19
19
  export type ReploScriptEntry = {
20
- type: "GA4" | "GoogleTagManager" | "Meta" | "TikTok" | "Pinterest" | "Reddit" | "Snapchat" | "Hotjar" | "MicrosoftClarity" | "Segment";
20
+ type: "GA4" | "GoogleTagManager" | "Meta" | "TikTok" | "Pinterest" | "Reddit" | "Snapchat" | "Hotjar" | "MicrosoftClarity" | "Segment" | "Northbeam";
21
21
  identifier: string;
22
22
  requiredConsent?: ConsentCategory[];
23
23
  } | {
@@ -0,0 +1 @@
1
+ export declare function AnnotationLayerMount(): null;
@@ -0,0 +1,13 @@
1
+ "use client";
2
+ if (typeof window !== "undefined") {
3
+ void import("./annotationController").then((module) => {
4
+ module.initAnnotationLayer();
5
+ });
6
+ }
7
+ function AnnotationLayerMount() {
8
+ return null;
9
+ }
10
+ export {
11
+ AnnotationLayerMount
12
+ };
13
+ //# sourceMappingURL=AnnotationLayerMount.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../editor/annotations/AnnotationLayerMount.tsx"],
4
+ "sourcesContent": ["\"use client\";\n\n/**\n * Boots the vanilla annotation controller inside preview iframes. The chunk\n * loads (and this module-scope boot runs) only when the provider actually\n * renders the element, which it folds away on a NODE_ENV literal \u2014 so\n * annotation code never ships to published storefronts.\n */\nif (typeof window !== \"undefined\") {\n void import(\"./annotationController\").then((module) => {\n module.initAnnotationLayer();\n });\n}\n\nexport function AnnotationLayerMount() {\n return null;\n}\n"],
5
+ "mappings": ";AAQA,IAAI,OAAO,WAAW,aAAa;AACjC,OAAK,OAAO,wBAAwB,EAAE,KAAK,CAAC,WAAW;AACrD,WAAO,oBAAoB;AAAA,EAC7B,CAAC;AACH;AAEO,SAAS,uBAAuB;AACrC,SAAO;AACT;",
6
+ "names": []
7
+ }
@@ -0,0 +1 @@
1
+ export declare function initAnnotationLayer(): void;
@@ -0,0 +1,384 @@
1
+ import { exhaustiveSwitch } from "../../_vendor/replo-utils/lib/misc.mjs";
2
+ import {
3
+ PAGE_ANNOTATIONS_PROTOCOL_VERSION,
4
+ pageAnnotationsParentMessageSchema
5
+ } from "../../_vendor/schemas/pageAnnotations.mjs";
6
+ import {
7
+ ANNOTATION_CONTAINER_ID,
8
+ clearAnnotationFrames,
9
+ getAnnotationBadgeViewportRect,
10
+ setActiveAnnotationBadge,
11
+ showAnnotationFrames
12
+ } from "../select-mode/annotationFrames";
13
+ import { getDocumentScrollOffset } from "../select-mode/interactions/selectionGeometry";
14
+ import { isAllowedEditorMessage, isAllowedEditorOrigin } from "./bridgeGate";
15
+ const CLUSTER_DISTANCE_PX = 24;
16
+ const CLUSTER_FAN_RADIUS_PX = 30;
17
+ const REMEASURE_DEBOUNCE_MS = 250;
18
+ const PAGE_TOP_STACK_X_PX = 20;
19
+ const PAGE_TOP_STACK_Y_PX = 20;
20
+ const PAGE_TOP_STACK_GAP_PX = 36;
21
+ const COLOR_HEX = {
22
+ red: "#ef196e",
23
+ purple: "#8b32a8",
24
+ amber: "#274ae2"
25
+ };
26
+ const COLOR_SEVERITY = [
27
+ "red",
28
+ "purple",
29
+ "amber"
30
+ ];
31
+ let isInitialized = false;
32
+ let editorOrigin = null;
33
+ let markers = [];
34
+ let setId = null;
35
+ let expandedClusterId = null;
36
+ let activeMarkerId = null;
37
+ let remeasureFrameId = null;
38
+ let remeasureDebounceId = null;
39
+ let activeRectFrameId = null;
40
+ let observersActive = false;
41
+ let lastRenderSignature = null;
42
+ let resizeObserver = null;
43
+ let mutationObserver = null;
44
+ function postToEditor(message) {
45
+ if (editorOrigin === null) {
46
+ return;
47
+ }
48
+ window.parent.postMessage(message, editorOrigin);
49
+ }
50
+ function hasFixedAncestor(element) {
51
+ let current = element;
52
+ while (current !== null && current !== document.documentElement) {
53
+ const position = getComputedStyle(current).position;
54
+ if (position === "fixed" || position === "sticky") {
55
+ return true;
56
+ }
57
+ current = current.parentElement;
58
+ }
59
+ return false;
60
+ }
61
+ function resolveMarkers() {
62
+ const resolved = [];
63
+ const unresolvedIds = [];
64
+ let pageTopSlot = 0;
65
+ for (const marker of markers) {
66
+ if (marker.placement === "pageTop") {
67
+ resolved.push({
68
+ marker,
69
+ element: null,
70
+ isFixed: false,
71
+ rect: {
72
+ x: PAGE_TOP_STACK_X_PX + pageTopSlot * PAGE_TOP_STACK_GAP_PX,
73
+ y: PAGE_TOP_STACK_Y_PX,
74
+ width: 0,
75
+ height: 0
76
+ },
77
+ // The editor owns numbering; rendering the wire number keeps dots in sync with the panel.
78
+ displayNumber: marker.number
79
+ });
80
+ pageTopSlot += 1;
81
+ continue;
82
+ }
83
+ let element = null;
84
+ try {
85
+ element = document.querySelector(marker.selector);
86
+ } catch {
87
+ }
88
+ const domRect = element?.getBoundingClientRect();
89
+ if (!element || !domRect || domRect.width === 0 && domRect.height === 0) {
90
+ unresolvedIds.push(marker.id);
91
+ continue;
92
+ }
93
+ const isFixed = hasFixedAncestor(element);
94
+ const scrollOffset = getDocumentScrollOffset();
95
+ resolved.push({
96
+ marker,
97
+ element,
98
+ isFixed,
99
+ // Fixed frames use viewport coords; absolute frames use page coords.
100
+ rect: {
101
+ x: domRect.x + (isFixed ? 0 : scrollOffset.left),
102
+ y: domRect.y + (isFixed ? 0 : scrollOffset.top),
103
+ width: domRect.width,
104
+ height: domRect.height
105
+ },
106
+ displayNumber: marker.number
107
+ });
108
+ }
109
+ return { resolved, unresolvedIds };
110
+ }
111
+ function clusterResolvedMarkers(resolved) {
112
+ const clusters = [];
113
+ for (const entry of resolved) {
114
+ const centerX = entry.rect.x + entry.rect.width / 2;
115
+ const centerY = entry.rect.y;
116
+ const host = clusters.find((cluster) => {
117
+ return cluster.isFixed === entry.isFixed && Math.hypot(cluster.centerX - centerX, cluster.centerY - centerY) < CLUSTER_DISTANCE_PX;
118
+ });
119
+ if (host) {
120
+ host.members.push(entry);
121
+ } else {
122
+ clusters.push({
123
+ id: entry.marker.id,
124
+ centerX,
125
+ centerY,
126
+ isFixed: entry.isFixed,
127
+ members: [entry]
128
+ });
129
+ }
130
+ }
131
+ return clusters;
132
+ }
133
+ function getMostSevereColorHex(members) {
134
+ const color = COLOR_SEVERITY.find((candidate) => {
135
+ return members.some((member) => member.marker.color === candidate);
136
+ }) ?? "amber";
137
+ return COLOR_HEX[color];
138
+ }
139
+ function activateMarker(id) {
140
+ activeMarkerId = id;
141
+ const viewportRect = getAnnotationBadgeViewportRect(id);
142
+ if (viewportRect) {
143
+ postToEditor({ type: "replo:annotations:clicked", id, viewportRect });
144
+ }
145
+ setActiveAnnotationBadge(id);
146
+ }
147
+ function buildMemberSpec({
148
+ member,
149
+ badgeCenter
150
+ }) {
151
+ const { marker } = member;
152
+ return {
153
+ id: marker.id,
154
+ pageRect: member.rect,
155
+ badgeCenter,
156
+ positioning: member.isFixed ? "fixed" : "absolute",
157
+ colorHex: COLOR_HEX[marker.color],
158
+ badgeLabel: String(member.displayNumber),
159
+ badgeAriaLabel: `Page issue ${member.displayNumber}`,
160
+ isActive: activeMarkerId === marker.id,
161
+ onBadgeClick: () => activateMarker(marker.id)
162
+ };
163
+ }
164
+ function buildClusterSpecs(cluster) {
165
+ const [only] = cluster.members;
166
+ if (cluster.members.length === 1 && only) {
167
+ return [
168
+ buildMemberSpec({
169
+ member: only,
170
+ badgeCenter: { x: cluster.centerX, y: cluster.centerY }
171
+ })
172
+ ];
173
+ }
174
+ const hub = {
175
+ x: cluster.centerX,
176
+ y: cluster.centerY,
177
+ width: 0,
178
+ height: 0
179
+ };
180
+ if (expandedClusterId !== cluster.id) {
181
+ return [
182
+ {
183
+ id: `cluster:${cluster.id}`,
184
+ pageRect: hub,
185
+ badgeCenter: { x: cluster.centerX, y: cluster.centerY },
186
+ positioning: cluster.isFixed ? "fixed" : "absolute",
187
+ colorHex: getMostSevereColorHex(cluster.members),
188
+ badgeLabel: String(cluster.members.length),
189
+ badgeAriaLabel: `${cluster.members.length} page issues near this element`,
190
+ isActive: false,
191
+ onBadgeClick: () => {
192
+ expandedClusterId = cluster.id;
193
+ render();
194
+ }
195
+ }
196
+ ];
197
+ }
198
+ const memberSpecs = cluster.members.map((member, index) => {
199
+ const angle = index / cluster.members.length * 2 * Math.PI - Math.PI / 2;
200
+ return buildMemberSpec({
201
+ member,
202
+ badgeCenter: {
203
+ x: cluster.centerX + Math.cos(angle) * CLUSTER_FAN_RADIUS_PX,
204
+ y: cluster.centerY + Math.sin(angle) * CLUSTER_FAN_RADIUS_PX
205
+ }
206
+ });
207
+ });
208
+ return [
209
+ {
210
+ id: `cluster:${cluster.id}`,
211
+ pageRect: hub,
212
+ badgeCenter: { x: cluster.centerX, y: cluster.centerY },
213
+ positioning: cluster.isFixed ? "fixed" : "absolute",
214
+ colorHex: "#94a3b8",
215
+ badgeLabel: "\xD7",
216
+ badgeAriaLabel: "Collapse issue cluster",
217
+ isActive: false,
218
+ onBadgeClick: () => {
219
+ expandedClusterId = null;
220
+ render();
221
+ }
222
+ },
223
+ ...memberSpecs
224
+ ];
225
+ }
226
+ function render() {
227
+ if (markers.length === 0) {
228
+ lastRenderSignature = null;
229
+ clearAnnotationFrames();
230
+ syncObservers();
231
+ return;
232
+ }
233
+ const { resolved, unresolvedIds } = resolveMarkers();
234
+ if (activeMarkerId !== null && unresolvedIds.includes(activeMarkerId)) {
235
+ activeMarkerId = null;
236
+ }
237
+ const signature = [
238
+ resolved.map((entry) => {
239
+ return `${entry.marker.id}:${Math.round(entry.rect.x)},${Math.round(entry.rect.y)}`;
240
+ }).join("|"),
241
+ `active:${activeMarkerId ?? ""}`,
242
+ `expanded:${expandedClusterId ?? ""}`,
243
+ `unresolved:${unresolvedIds.join(",")}`
244
+ ].join("#");
245
+ if (signature === lastRenderSignature) {
246
+ return;
247
+ }
248
+ lastRenderSignature = signature;
249
+ const frames = clusterResolvedMarkers(resolved).flatMap((cluster) => {
250
+ return buildClusterSpecs(cluster);
251
+ });
252
+ showAnnotationFrames({ frames });
253
+ if (setId !== null) {
254
+ postToEditor({
255
+ type: "replo:annotations:unresolved",
256
+ setId,
257
+ ids: unresolvedIds
258
+ });
259
+ }
260
+ syncObservers();
261
+ }
262
+ function scheduleRemeasure() {
263
+ remeasureFrameId ??= requestAnimationFrame(() => {
264
+ remeasureFrameId = null;
265
+ render();
266
+ });
267
+ }
268
+ function scheduleDebouncedRemeasure() {
269
+ if (remeasureDebounceId !== null) {
270
+ clearTimeout(remeasureDebounceId);
271
+ }
272
+ remeasureDebounceId = setTimeout(scheduleRemeasure, REMEASURE_DEBOUNCE_MS);
273
+ }
274
+ function handleScroll(event) {
275
+ if (event.target !== document) {
276
+ scheduleRemeasure();
277
+ }
278
+ if (activeMarkerId !== null) {
279
+ const id = activeMarkerId;
280
+ activeRectFrameId ??= requestAnimationFrame(() => {
281
+ activeRectFrameId = null;
282
+ const viewportRect = getAnnotationBadgeViewportRect(id);
283
+ if (viewportRect) {
284
+ postToEditor({
285
+ type: "replo:annotations:activeRect",
286
+ id,
287
+ viewportRect
288
+ });
289
+ }
290
+ });
291
+ }
292
+ }
293
+ function syncObservers() {
294
+ const shouldObserve = markers.length > 0;
295
+ if (shouldObserve === observersActive) {
296
+ return;
297
+ }
298
+ observersActive = shouldObserve;
299
+ if (shouldObserve) {
300
+ window.addEventListener("resize", scheduleRemeasure);
301
+ window.addEventListener("scroll", handleScroll, { capture: true });
302
+ if (typeof ResizeObserver !== "undefined") {
303
+ resizeObserver = new ResizeObserver(scheduleRemeasure);
304
+ resizeObserver.observe(document.body);
305
+ }
306
+ mutationObserver = new MutationObserver((records) => {
307
+ const container = document.getElementById(ANNOTATION_CONTAINER_ID);
308
+ const hasForeignMutation = records.some((record) => {
309
+ return !container || !container.contains(record.target);
310
+ });
311
+ if (hasForeignMutation) {
312
+ scheduleDebouncedRemeasure();
313
+ }
314
+ });
315
+ mutationObserver.observe(document.body, { childList: true, subtree: true });
316
+ } else {
317
+ window.removeEventListener("resize", scheduleRemeasure);
318
+ window.removeEventListener("scroll", handleScroll, { capture: true });
319
+ resizeObserver?.disconnect();
320
+ resizeObserver = null;
321
+ mutationObserver?.disconnect();
322
+ mutationObserver = null;
323
+ }
324
+ }
325
+ function handleMessage(event) {
326
+ if (!isAllowedEditorMessage(event)) {
327
+ return;
328
+ }
329
+ const parsed = pageAnnotationsParentMessageSchema.safeParse(event.data);
330
+ if (!parsed.success) {
331
+ return;
332
+ }
333
+ editorOrigin = event.origin;
334
+ exhaustiveSwitch(parsed.data)({
335
+ "replo:annotations:set": (message) => {
336
+ markers = message.markers;
337
+ setId = message.setId;
338
+ expandedClusterId = null;
339
+ activeMarkerId = null;
340
+ lastRenderSignature = null;
341
+ render();
342
+ },
343
+ "replo:annotations:clear": () => {
344
+ markers = [];
345
+ setId = null;
346
+ expandedClusterId = null;
347
+ activeMarkerId = null;
348
+ render();
349
+ },
350
+ "replo:annotations:requestReady": () => {
351
+ postToEditor({
352
+ type: "replo:annotations:ready",
353
+ protocolVersion: PAGE_ANNOTATIONS_PROTOCOL_VERSION
354
+ });
355
+ }
356
+ });
357
+ }
358
+ function initAnnotationLayer() {
359
+ if (isInitialized || typeof window === "undefined") {
360
+ return;
361
+ }
362
+ if (window.self === window.top) {
363
+ return;
364
+ }
365
+ isInitialized = true;
366
+ window.addEventListener("message", handleMessage);
367
+ try {
368
+ const referrerOrigin = new URL(document.referrer).origin;
369
+ if (isAllowedEditorOrigin(referrerOrigin)) {
370
+ window.parent.postMessage(
371
+ {
372
+ type: "replo:annotations:ready",
373
+ protocolVersion: PAGE_ANNOTATIONS_PROTOCOL_VERSION
374
+ },
375
+ referrerOrigin
376
+ );
377
+ }
378
+ } catch {
379
+ }
380
+ }
381
+ export {
382
+ initAnnotationLayer
383
+ };
384
+ //# sourceMappingURL=annotationController.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../editor/annotations/annotationController.ts"],
4
+ "sourcesContent": ["/**\n * In-iframe annotation controller: consumes declarative marker sets from the\n * editor bridge, resolves selectors against the live DOM, and drives the\n * shared annotation frame renderer. Scroll costs zero JavaScript (frames use\n * page coordinates); re-measure runs only on resize/mutation/container\n * scroll, batched per animation frame. Data-only protocol \u2014 the editor can\n * describe dots, never execute code.\n */\nimport type {\n PageAnnotationMarker,\n PageAnnotationsIframeMessage,\n} from \"schemas/generated/pageAnnotations\";\nimport type { AnnotationFrameSpec } from \"../select-mode/annotationFrames\";\n\nimport { exhaustiveSwitch } from \"replo-utils/lib/misc\";\nimport {\n PAGE_ANNOTATIONS_PROTOCOL_VERSION,\n pageAnnotationsParentMessageSchema,\n} from \"schemas/pageAnnotations\";\n\nimport {\n ANNOTATION_CONTAINER_ID,\n clearAnnotationFrames,\n getAnnotationBadgeViewportRect,\n setActiveAnnotationBadge,\n showAnnotationFrames,\n} from \"../select-mode/annotationFrames\";\nimport { getDocumentScrollOffset } from \"../select-mode/interactions/selectionGeometry\";\nimport { isAllowedEditorMessage, isAllowedEditorOrigin } from \"./bridgeGate\";\n\nconst CLUSTER_DISTANCE_PX = 24;\nconst CLUSTER_FAN_RADIUS_PX = 30;\nconst REMEASURE_DEBOUNCE_MS = 250;\n// Page-wide findings stack in a row near the top-left of the page and scroll\n// with it like any other annotation.\nconst PAGE_TOP_STACK_X_PX = 20;\nconst PAGE_TOP_STACK_Y_PX = 20;\nconst PAGE_TOP_STACK_GAP_PX = 36;\n\n// Replo brand palette (lattice --color-brand-*): the wire enum names stay\n// red/purple/amber but the rendered hues are brand magenta/purple/blue,\n// matching the editor-side dots and cards.\nconst COLOR_HEX: Record<PageAnnotationMarker[\"color\"], string> = {\n red: \"#ef196e\",\n purple: \"#8b32a8\",\n amber: \"#274ae2\",\n};\nconst COLOR_SEVERITY: PageAnnotationMarker[\"color\"][] = [\n \"red\",\n \"purple\",\n \"amber\",\n];\n\ninterface ResolvedMarker {\n marker: PageAnnotationMarker;\n element: Element | null;\n isFixed: boolean;\n rect: { x: number; y: number; width: number; height: number };\n // The editor-assigned wire number, rendered verbatim.\n displayNumber: number;\n}\n\ninterface MarkerCluster {\n id: string;\n centerX: number;\n centerY: number;\n isFixed: boolean;\n members: ResolvedMarker[];\n}\n\nlet isInitialized = false;\nlet editorOrigin: string | null = null;\nlet markers: PageAnnotationMarker[] = [];\nlet setId: string | null = null;\nlet expandedClusterId: string | null = null;\nlet activeMarkerId: string | null = null;\nlet remeasureFrameId: number | null = null;\nlet remeasureDebounceId: ReturnType<typeof setTimeout> | null = null;\nlet activeRectFrameId: number | null = null;\nlet observersActive = false;\nlet lastRenderSignature: string | null = null;\nlet resizeObserver: ResizeObserver | null = null;\nlet mutationObserver: MutationObserver | null = null;\n\nfunction postToEditor(message: PageAnnotationsIframeMessage) {\n if (editorOrigin === null) {\n return;\n }\n window.parent.postMessage(message, editorOrigin);\n}\n\nfunction hasFixedAncestor(element: Element): boolean {\n let current: Element | null = element;\n while (current !== null && current !== document.documentElement) {\n const position = getComputedStyle(current).position;\n if (position === \"fixed\" || position === \"sticky\") {\n return true;\n }\n current = current.parentElement;\n }\n return false;\n}\n\nfunction resolveMarkers(): {\n resolved: ResolvedMarker[];\n unresolvedIds: string[];\n} {\n const resolved: ResolvedMarker[] = [];\n const unresolvedIds: string[] = [];\n let pageTopSlot = 0;\n for (const marker of markers) {\n if (marker.placement === \"pageTop\") {\n // Page-wide finding: a fixed slot in the top-of-page stack, no selector.\n resolved.push({\n marker,\n element: null,\n isFixed: false,\n rect: {\n x: PAGE_TOP_STACK_X_PX + pageTopSlot * PAGE_TOP_STACK_GAP_PX,\n y: PAGE_TOP_STACK_Y_PX,\n width: 0,\n height: 0,\n },\n // The editor owns numbering; rendering the wire number keeps dots in sync with the panel.\n displayNumber: marker.number,\n });\n pageTopSlot += 1;\n continue;\n }\n let element: Element | null = null;\n try {\n element = document.querySelector(marker.selector);\n } catch {\n // Malformed selector \u2014 unresolved, never a throw.\n }\n const domRect = element?.getBoundingClientRect();\n if (!element || !domRect || (domRect.width === 0 && domRect.height === 0)) {\n unresolvedIds.push(marker.id);\n continue;\n }\n const isFixed = hasFixedAncestor(element);\n const scrollOffset = getDocumentScrollOffset();\n resolved.push({\n marker,\n element,\n isFixed,\n // Fixed frames use viewport coords; absolute frames use page coords.\n rect: {\n x: domRect.x + (isFixed ? 0 : scrollOffset.left),\n y: domRect.y + (isFixed ? 0 : scrollOffset.top),\n width: domRect.width,\n height: domRect.height,\n },\n displayNumber: marker.number,\n });\n }\n return { resolved, unresolvedIds };\n}\n\n// Greedy: a marker joins the first cluster whose badge anchor lies within\n// 24px; fixed and absolute markers never co-cluster (their coordinate spaces\n// diverge as soon as the page scrolls).\nfunction clusterResolvedMarkers(resolved: ResolvedMarker[]): MarkerCluster[] {\n const clusters: MarkerCluster[] = [];\n for (const entry of resolved) {\n const centerX = entry.rect.x + entry.rect.width / 2;\n const centerY = entry.rect.y;\n const host = clusters.find((cluster) => {\n return (\n cluster.isFixed === entry.isFixed &&\n Math.hypot(cluster.centerX - centerX, cluster.centerY - centerY) <\n CLUSTER_DISTANCE_PX\n );\n });\n if (host) {\n host.members.push(entry);\n } else {\n clusters.push({\n id: entry.marker.id,\n centerX,\n centerY,\n isFixed: entry.isFixed,\n members: [entry],\n });\n }\n }\n return clusters;\n}\n\nfunction getMostSevereColorHex(members: ResolvedMarker[]): string {\n const color =\n COLOR_SEVERITY.find((candidate) => {\n return members.some((member) => member.marker.color === candidate);\n }) ?? \"amber\";\n return COLOR_HEX[color];\n}\n\nfunction activateMarker(id: string) {\n activeMarkerId = id;\n const viewportRect = getAnnotationBadgeViewportRect(id);\n if (viewportRect) {\n postToEditor({ type: \"replo:annotations:clicked\", id, viewportRect });\n }\n // Style-only: a rebuild here would race the pointer sequence and swallow\n // the very click being handled.\n setActiveAnnotationBadge(id);\n}\n\nfunction buildMemberSpec({\n member,\n badgeCenter,\n}: {\n member: ResolvedMarker;\n badgeCenter: { x: number; y: number };\n}): AnnotationFrameSpec {\n const { marker } = member;\n return {\n id: marker.id,\n pageRect: member.rect,\n badgeCenter,\n positioning: member.isFixed ? \"fixed\" : \"absolute\",\n colorHex: COLOR_HEX[marker.color],\n badgeLabel: String(member.displayNumber),\n badgeAriaLabel: `Page issue ${member.displayNumber}`,\n isActive: activeMarkerId === marker.id,\n onBadgeClick: () => activateMarker(marker.id),\n };\n}\n\nfunction buildClusterSpecs(cluster: MarkerCluster): AnnotationFrameSpec[] {\n const [only] = cluster.members;\n if (cluster.members.length === 1 && only) {\n return [\n buildMemberSpec({\n member: only,\n badgeCenter: { x: cluster.centerX, y: cluster.centerY },\n }),\n ];\n }\n const hub = {\n x: cluster.centerX,\n y: cluster.centerY,\n width: 0,\n height: 0,\n };\n if (expandedClusterId !== cluster.id) {\n return [\n {\n id: `cluster:${cluster.id}`,\n pageRect: hub,\n badgeCenter: { x: cluster.centerX, y: cluster.centerY },\n positioning: cluster.isFixed ? \"fixed\" : \"absolute\",\n colorHex: getMostSevereColorHex(cluster.members),\n badgeLabel: String(cluster.members.length),\n badgeAriaLabel: `${cluster.members.length} page issues near this element`,\n isActive: false,\n onBadgeClick: () => {\n expandedClusterId = cluster.id;\n render();\n },\n },\n ];\n }\n const memberSpecs = cluster.members.map((member, index) => {\n const angle = (index / cluster.members.length) * 2 * Math.PI - Math.PI / 2;\n return buildMemberSpec({\n member,\n badgeCenter: {\n x: cluster.centerX + Math.cos(angle) * CLUSTER_FAN_RADIUS_PX,\n y: cluster.centerY + Math.sin(angle) * CLUSTER_FAN_RADIUS_PX,\n },\n });\n });\n return [\n {\n id: `cluster:${cluster.id}`,\n pageRect: hub,\n badgeCenter: { x: cluster.centerX, y: cluster.centerY },\n positioning: cluster.isFixed ? \"fixed\" : \"absolute\",\n colorHex: \"#94a3b8\",\n badgeLabel: \"\u00D7\",\n badgeAriaLabel: \"Collapse issue cluster\",\n isActive: false,\n onBadgeClick: () => {\n expandedClusterId = null;\n render();\n },\n },\n ...memberSpecs,\n ];\n}\n\nfunction render() {\n if (markers.length === 0) {\n lastRenderSignature = null;\n clearAnnotationFrames();\n syncObservers();\n return;\n }\n const { resolved, unresolvedIds } = resolveMarkers();\n if (activeMarkerId !== null && unresolvedIds.includes(activeMarkerId)) {\n activeMarkerId = null;\n }\n // Rebuilding the node pool mid-pointer-sequence swallows clicks, so skip\n // renders whose output would be identical to what is already on screen.\n const signature = [\n resolved\n .map((entry) => {\n return `${entry.marker.id}:${Math.round(entry.rect.x)},${Math.round(entry.rect.y)}`;\n })\n .join(\"|\"),\n `active:${activeMarkerId ?? \"\"}`,\n `expanded:${expandedClusterId ?? \"\"}`,\n `unresolved:${unresolvedIds.join(\",\")}`,\n ].join(\"#\");\n if (signature === lastRenderSignature) {\n return;\n }\n lastRenderSignature = signature;\n const frames = clusterResolvedMarkers(resolved).flatMap((cluster) => {\n return buildClusterSpecs(cluster);\n });\n showAnnotationFrames({ frames });\n if (setId !== null) {\n postToEditor({\n type: \"replo:annotations:unresolved\",\n setId,\n ids: unresolvedIds,\n });\n }\n syncObservers();\n}\n\nfunction scheduleRemeasure() {\n remeasureFrameId ??= requestAnimationFrame(() => {\n remeasureFrameId = null;\n render();\n });\n}\n\nfunction scheduleDebouncedRemeasure() {\n if (remeasureDebounceId !== null) {\n clearTimeout(remeasureDebounceId);\n }\n remeasureDebounceId = setTimeout(scheduleRemeasure, REMEASURE_DEBOUNCE_MS);\n}\n\nfunction handleScroll(event: Event) {\n // Document scroll is free for absolute frames; scrolls of inner overflow\n // containers move elements relative to the page, so re-measure everything.\n if (event.target !== document) {\n scheduleRemeasure();\n }\n if (activeMarkerId !== null) {\n const id = activeMarkerId;\n activeRectFrameId ??= requestAnimationFrame(() => {\n activeRectFrameId = null;\n const viewportRect = getAnnotationBadgeViewportRect(id);\n if (viewportRect) {\n postToEditor({\n type: \"replo:annotations:activeRect\",\n id,\n viewportRect,\n });\n }\n });\n }\n}\n\nfunction syncObservers() {\n const shouldObserve = markers.length > 0;\n if (shouldObserve === observersActive) {\n return;\n }\n observersActive = shouldObserve;\n if (shouldObserve) {\n window.addEventListener(\"resize\", scheduleRemeasure);\n window.addEventListener(\"scroll\", handleScroll, { capture: true });\n if (typeof ResizeObserver !== \"undefined\") {\n resizeObserver = new ResizeObserver(scheduleRemeasure);\n resizeObserver.observe(document.body);\n }\n mutationObserver = new MutationObserver((records) => {\n // Rendering our own frames mutates body's subtree; reacting to that\n // would re-render forever. Only foreign mutations can move elements.\n const container = document.getElementById(ANNOTATION_CONTAINER_ID);\n const hasForeignMutation = records.some((record) => {\n return !container || !container.contains(record.target);\n });\n if (hasForeignMutation) {\n scheduleDebouncedRemeasure();\n }\n });\n mutationObserver.observe(document.body, { childList: true, subtree: true });\n } else {\n window.removeEventListener(\"resize\", scheduleRemeasure);\n window.removeEventListener(\"scroll\", handleScroll, { capture: true });\n resizeObserver?.disconnect();\n resizeObserver = null;\n mutationObserver?.disconnect();\n mutationObserver = null;\n }\n}\n\nfunction handleMessage(event: MessageEvent) {\n // Origin gate BEFORE any parsing \u2014 hostile embedders never reach the schema.\n if (!isAllowedEditorMessage(event)) {\n return;\n }\n const parsed = pageAnnotationsParentMessageSchema.safeParse(event.data);\n if (!parsed.success) {\n return;\n }\n editorOrigin = event.origin;\n exhaustiveSwitch(parsed.data)({\n \"replo:annotations:set\": (message) => {\n markers = message.markers;\n setId = message.setId;\n expandedClusterId = null;\n activeMarkerId = null;\n // A fresh set always paints (and re-posts unresolved), even if geometry\n // happens to match the previous render.\n lastRenderSignature = null;\n render();\n },\n \"replo:annotations:clear\": () => {\n markers = [];\n setId = null;\n expandedClusterId = null;\n activeMarkerId = null;\n render();\n },\n \"replo:annotations:requestReady\": () => {\n postToEditor({\n type: \"replo:annotations:ready\",\n protocolVersion: PAGE_ANNOTATIONS_PROTOCOL_VERSION,\n });\n },\n });\n}\n\nexport function initAnnotationLayer() {\n if (isInitialized || typeof window === \"undefined\") {\n return;\n }\n if (window.self === window.top) {\n return;\n }\n isInitialized = true;\n window.addEventListener(\"message\", handleMessage);\n // Announce on load for iframe-reload cases where the editor isn't polling;\n // the referrer origin is verified against the same allowlist first.\n try {\n const referrerOrigin = new URL(document.referrer).origin;\n if (isAllowedEditorOrigin(referrerOrigin)) {\n window.parent.postMessage(\n {\n type: \"replo:annotations:ready\",\n protocolVersion: PAGE_ANNOTATIONS_PROTOCOL_VERSION,\n },\n referrerOrigin,\n );\n }\n } catch {\n // No usable referrer \u2014 the editor's requestReady polling covers this.\n }\n}\n"],
5
+ "mappings": "AAcA,SAAS,wBAAwB;AACjC;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAEP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,+BAA+B;AACxC,SAAS,wBAAwB,6BAA6B;AAE9D,MAAM,sBAAsB;AAC5B,MAAM,wBAAwB;AAC9B,MAAM,wBAAwB;AAG9B,MAAM,sBAAsB;AAC5B,MAAM,sBAAsB;AAC5B,MAAM,wBAAwB;AAK9B,MAAM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aAAO;AAAA,IACT;AAAA,IACA,kCAAkC,MAAM;AACtC,mBAAa;AAAA,QACX,MAAM;AAAA,QACN,iBAAiB;AAAA,MACnB,CAAC;AAAA,IACH;AAAA,EACF,CAAC;AACH;AAEO,SAAS,sBAAsB;AACpC,MAAI,iBAAiB,OAAO,WAAW,aAAa;AAClD;AAAA,EACF;AACA,MAAI,OAAO,SAAS,OAAO,KAAK;AAC9B;AAAA,EACF;AACA,kBAAgB;AAChB,SAAO,iBAAiB,WAAW,aAAa;AAGhD,MAAI;AACF,UAAM,iBAAiB,IAAI,IAAI,SAAS,QAAQ,EAAE;AAClD,QAAI,sBAAsB,cAAc,GAAG;AACzC,aAAO,OAAO;AAAA,QACZ;AAAA,UACE,MAAM;AAAA,UACN,iBAAiB;AAAA,QACnB;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAAA,EACF,QAAQ;AAAA,EAER;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Origin gate for inbound editor-bridge messages, checked BEFORE any payload
3
+ * parsing. The select-mode bridge predates this and validates payload shape
4
+ * only; its hardening ticket is expected to adopt this helper.
5
+ */
6
+ export declare function isAllowedEditorOrigin(origin: string): boolean;
7
+ export declare function isAllowedEditorMessage(event: MessageEvent): boolean;
@@ -0,0 +1,22 @@
1
+ const ALLOWED_EDITOR_ORIGIN_PATTERNS = [
2
+ // Local dev editors (any port).
3
+ /^https?:\/\/localhost(?::\d+)?$/u,
4
+ // Hosted editors and miniapps; multi-label hosts like website-builder.apps.replo.app must pass.
5
+ /^https:\/\/(?:[a-z0-9-]+\.)*replo\.app$/u,
6
+ // Dev front-door tunnels (`https://replo-<alias>.ngrok.app`).
7
+ /^https:\/\/replo-[a-z0-9-]+\.ngrok\.app$/u
8
+ ];
9
+ function isAllowedEditorOrigin(origin) {
10
+ return ALLOWED_EDITOR_ORIGIN_PATTERNS.some((pattern) => pattern.test(origin));
11
+ }
12
+ function isAllowedEditorMessage(event) {
13
+ if (typeof window === "undefined" || window.self === window.top) {
14
+ return false;
15
+ }
16
+ return isAllowedEditorOrigin(event.origin);
17
+ }
18
+ export {
19
+ isAllowedEditorMessage,
20
+ isAllowedEditorOrigin
21
+ };
22
+ //# sourceMappingURL=bridgeGate.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../editor/annotations/bridgeGate.ts"],
4
+ "sourcesContent": ["/**\n * Origin gate for inbound editor-bridge messages, checked BEFORE any payload\n * parsing. The select-mode bridge predates this and validates payload shape\n * only; its hardening ticket is expected to adopt this helper.\n */\n\nconst ALLOWED_EDITOR_ORIGIN_PATTERNS = [\n // Local dev editors (any port).\n /^https?:\\/\\/localhost(?::\\d+)?$/u,\n // Hosted editors and miniapps; multi-label hosts like website-builder.apps.replo.app must pass.\n /^https:\\/\\/(?:[a-z0-9-]+\\.)*replo\\.app$/u,\n // Dev front-door tunnels (`https://replo-<alias>.ngrok.app`).\n /^https:\\/\\/replo-[a-z0-9-]+\\.ngrok\\.app$/u,\n];\n\nexport function isAllowedEditorOrigin(origin: string): boolean {\n return ALLOWED_EDITOR_ORIGIN_PATTERNS.some((pattern) => pattern.test(origin));\n}\n\nexport function isAllowedEditorMessage(event: MessageEvent): boolean {\n // A top-level page has no editor parent; only embedded previews qualify.\n if (typeof window === \"undefined\" || window.self === window.top) {\n return false;\n }\n return isAllowedEditorOrigin(event.origin);\n}\n"],
5
+ "mappings": "AAMA,MAAM,iCAAiC;AAAA;AAAA,EAErC;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AACF;AAEO,SAAS,sBAAsB,QAAyB;AAC7D,SAAO,+BAA+B,KAAK,CAAC,YAAY,QAAQ,KAAK,MAAM,CAAC;AAC9E;AAEO,SAAS,uBAAuB,OAA8B;AAEnE,MAAI,OAAO,WAAW,eAAe,OAAO,SAAS,OAAO,KAAK;AAC/D,WAAO;AAAA,EACT;AACA,SAAO,sBAAsB,MAAM,MAAM;AAC3C;",
6
+ "names": []
7
+ }
@@ -0,0 +1,33 @@
1
+ export declare const ANNOTATION_CONTAINER_ID = "replo-annotation-frames";
2
+ interface AnnotationRect {
3
+ x: number;
4
+ y: number;
5
+ width: number;
6
+ height: number;
7
+ }
8
+ export interface AnnotationFrameSpec {
9
+ id: string;
10
+ pageRect: AnnotationRect;
11
+ badgeCenter: {
12
+ x: number;
13
+ y: number;
14
+ };
15
+ positioning: "absolute" | "fixed";
16
+ colorHex: string;
17
+ badgeLabel: string;
18
+ badgeAriaLabel: string;
19
+ isActive: boolean;
20
+ onBadgeClick: () => void;
21
+ }
22
+ /**
23
+ * Style-only selection update: rebuilding the node pool mid-interaction would
24
+ * race the pointer sequence and swallow the click, so the active state never
25
+ * re-renders — it just retargets transforms on the existing nodes.
26
+ */
27
+ export declare function setActiveAnnotationBadge(id: string | null): void;
28
+ export declare function getAnnotationBadgeViewportRect(id: string): AnnotationRect | null;
29
+ export declare function showAnnotationFrames({ frames, }: {
30
+ frames: AnnotationFrameSpec[];
31
+ }): void;
32
+ export declare function clearAnnotationFrames(): void;
33
+ export {};
@@ -0,0 +1,119 @@
1
+ import { getOrCreateFramesLayerContainer } from "./selectionFrame";
2
+ const ANNOTATION_CONTAINER_ID = "replo-annotation-frames";
3
+ const ANNOTATION_FONT_STYLE_ID = "replo-annotation-font";
4
+ const BADGE_SIZE_PX = 30;
5
+ const EDITORIAL_ITALIC_FONT_URL = "https://assets.replocdn.com/PPEditorialNew-Italic.woff2";
6
+ const BADGE_FONT = 'italic 400 16px/1 "PP Editorial New", Georgia, "Times New Roman", serif';
7
+ function ensureBadgeFont() {
8
+ if (document.getElementById(ANNOTATION_FONT_STYLE_ID)) {
9
+ return;
10
+ }
11
+ const style = document.createElement("style");
12
+ style.id = ANNOTATION_FONT_STYLE_ID;
13
+ 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;}`;
14
+ document.head.append(style);
15
+ }
16
+ const badgeNodesById = /* @__PURE__ */ new Map();
17
+ let activeBadgeId = null;
18
+ function badgeRestingTransform(id) {
19
+ return id === activeBadgeId ? "scale(1.15)" : "scale(1)";
20
+ }
21
+ function setActiveAnnotationBadge(id) {
22
+ activeBadgeId = id;
23
+ for (const [badgeId, badge] of badgeNodesById) {
24
+ badge.style.transform = badgeRestingTransform(badgeId);
25
+ }
26
+ }
27
+ function getAnnotationBadgeViewportRect(id) {
28
+ const badge = badgeNodesById.get(id);
29
+ if (!badge?.isConnected) {
30
+ return null;
31
+ }
32
+ const rect = badge.getBoundingClientRect();
33
+ return { x: rect.x, y: rect.y, width: rect.width, height: rect.height };
34
+ }
35
+ function createFrameNode(spec) {
36
+ const frame = document.createElement("div");
37
+ frame.style.cssText = [
38
+ `position: ${spec.positioning}`,
39
+ `left: ${spec.pageRect.x}px`,
40
+ `top: ${spec.pageRect.y}px`,
41
+ "width: 0",
42
+ "height: 0",
43
+ "pointer-events: none",
44
+ "margin: 0",
45
+ "padding: 0"
46
+ ].join(";");
47
+ const badge = document.createElement("button");
48
+ badge.type = "button";
49
+ badge.setAttribute("aria-label", spec.badgeAriaLabel);
50
+ badge.textContent = spec.badgeLabel;
51
+ badge.style.cssText = [
52
+ "position: absolute",
53
+ `left: ${spec.badgeCenter.x - spec.pageRect.x - BADGE_SIZE_PX / 2}px`,
54
+ `top: ${spec.badgeCenter.y - spec.pageRect.y - BADGE_SIZE_PX / 2}px`,
55
+ `width: ${BADGE_SIZE_PX}px`,
56
+ `height: ${BADGE_SIZE_PX}px`,
57
+ "display: flex",
58
+ "align-items: center",
59
+ "justify-content: center",
60
+ "border: none",
61
+ "border-radius: 50%",
62
+ `background: ${spec.colorHex}`,
63
+ "color: #ffffff",
64
+ `font: ${BADGE_FONT}`,
65
+ "box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.9), 0 1px 3px rgba(0, 0, 0, 0.18)",
66
+ `transform: scale(${spec.isActive ? 1.15 : 1})`,
67
+ "transition: transform 120ms ease-out",
68
+ "cursor: pointer",
69
+ "pointer-events: auto",
70
+ "margin: 0",
71
+ "padding: 0 0 1px 0"
72
+ ].join(";");
73
+ badge.addEventListener("pointerdown", () => {
74
+ badge.style.transform = "scale(0.9)";
75
+ });
76
+ badge.addEventListener("pointerup", () => {
77
+ badge.style.transform = badgeRestingTransform(spec.id);
78
+ });
79
+ badge.addEventListener("pointerleave", () => {
80
+ badge.style.transform = badgeRestingTransform(spec.id);
81
+ });
82
+ badge.addEventListener("click", (event) => {
83
+ event.stopPropagation();
84
+ spec.onBadgeClick();
85
+ });
86
+ frame.append(badge);
87
+ badgeNodesById.set(spec.id, badge);
88
+ return frame;
89
+ }
90
+ function showAnnotationFrames({
91
+ frames
92
+ }) {
93
+ const container = getOrCreateFramesLayerContainer({
94
+ id: ANNOTATION_CONTAINER_ID,
95
+ zIndex: 2147483645
96
+ });
97
+ if (!container) {
98
+ return;
99
+ }
100
+ ensureBadgeFont();
101
+ activeBadgeId = frames.find((spec) => spec.isActive)?.id ?? null;
102
+ badgeNodesById.clear();
103
+ container.replaceChildren(...frames.map((spec) => createFrameNode(spec)));
104
+ }
105
+ function clearAnnotationFrames() {
106
+ badgeNodesById.clear();
107
+ if (typeof document === "undefined") {
108
+ return;
109
+ }
110
+ document.getElementById(ANNOTATION_CONTAINER_ID)?.replaceChildren();
111
+ }
112
+ export {
113
+ ANNOTATION_CONTAINER_ID,
114
+ clearAnnotationFrames,
115
+ getAnnotationBadgeViewportRect,
116
+ setActiveAnnotationBadge,
117
+ showAnnotationFrames
118
+ };
119
+ //# sourceMappingURL=annotationFrames.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 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,gBAA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,YAAY;AAAA,EAC1B,CAAC;AACD,QAAM,iBAAiB,aAAa,MAAM;AACxC,UAAM,MAAM,YAAY,sBAAsB,KAAK,EAAE;AAAA,EACvD,CAAC;AACD,QAAM,iBAAiB,gBAAgB,MAAM;AAC3C,UAAM,MAAM,YAAY,sBAAsB,KAAK,EAAE;AAAA,EACvD,CAAC;AACD,QAAM,iBAAiB,SAAS,CAAC,UAAU;AACzC,UAAM,gBAAgB;AACtB,SAAK,aAAa;AAAA,EACpB,CAAC;AAED,QAAM,OAAO,KAAK;AAClB,iBAAe,IAAI,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;",
6
+ "names": []
7
+ }
@@ -44,6 +44,15 @@ type SelectionFrameSpec = {
44
44
  * screen so the change is immediate, not deferred to the next redraw.
45
45
  */
46
46
  export declare function setSelectionFrameEditing(editing: boolean): void;
47
+ /**
48
+ * Shared body-level layer container for in-iframe editor overlays (selection
49
+ * frames, annotation frames). Zero-size and pointer-transparent so it never
50
+ * affects the page; children opt into pointer events individually.
51
+ */
52
+ export declare function getOrCreateFramesLayerContainer({ id, zIndex, }: {
53
+ id: string;
54
+ zIndex: number;
55
+ }): HTMLDivElement | null;
47
56
  /**
48
57
  * Position selection frames at the given *page* coordinates, one node per
49
58
  * spec. Page coords don't shift during scroll, so the caller is free to
@@ -30,11 +30,14 @@ function setSelectionFrameEditing(editing) {
30
30
  }
31
31
  }
32
32
  }
33
- function getOrCreateContainer() {
33
+ function getOrCreateFramesLayerContainer({
34
+ id,
35
+ zIndex
36
+ }) {
34
37
  if (typeof document === "undefined") {
35
38
  return null;
36
39
  }
37
- const existing = document.getElementById(FRAMES_CONTAINER_ID);
40
+ const existing = document.getElementById(id);
38
41
  if (existing instanceof HTMLDivElement) {
39
42
  return existing;
40
43
  }
@@ -42,7 +45,7 @@ function getOrCreateContainer() {
42
45
  return null;
43
46
  }
44
47
  const container = document.createElement("div");
45
- container.id = FRAMES_CONTAINER_ID;
48
+ container.id = id;
46
49
  container.setAttribute("aria-hidden", "true");
47
50
  container.style.cssText = [
48
51
  "position: absolute",
@@ -53,11 +56,17 @@ function getOrCreateContainer() {
53
56
  "margin: 0",
54
57
  "padding: 0",
55
58
  "pointer-events: none",
56
- "z-index: 2147483646"
59
+ `z-index: ${zIndex}`
57
60
  ].join(";");
58
61
  document.body.append(container);
59
62
  return container;
60
63
  }
64
+ function getOrCreateContainer() {
65
+ return getOrCreateFramesLayerContainer({
66
+ id: FRAMES_CONTAINER_ID,
67
+ zIndex: 2147483646
68
+ });
69
+ }
61
70
  function createFrameNode() {
62
71
  const frame = document.createElement("div");
63
72
  frame.setAttribute("aria-hidden", "true");
@@ -114,6 +123,7 @@ function hideSelectionFrame() {
114
123
  }
115
124
  }
116
125
  export {
126
+ getOrCreateFramesLayerContainer,
117
127
  hideSelectionFrame,
118
128
  setSelectionFrameEditing,
119
129
  showSelectionFrame,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../editor/select-mode/selectionFrame.ts"],
4
- "sourcesContent": ["/**\n * In-iframe selection frame renderer.\n *\n * Lives in the canopy iframe (not in agent-ui) because the previous\n * parent-side overlay had to be re-anchored on every scroll frame via\n * postMessage hop -> Zustand update -> React reconciliation, which\n * shows up as visible lag when the user scrolls quickly.\n *\n * By rendering directly inside the canopy iframe's document we get two\n * properties for free:\n *\n * 1. `position: absolute` + page coordinates means the document's own\n * scroll naturally translates the frames \u2014 zero JavaScript per\n * scroll frame, the browser composites them with the underlying page\n * content.\n * 2. No bridge serialization: the only cost when selection commits is\n * a handful of style writes on the frame nodes.\n *\n * A single click resolves to one frame; an area drag resolves to one\n * frame per captured element, so the renderer keeps a pool of nodes\n * under a shared container and reconciles it on each call (reusing\n * existing nodes when the count is stable, which keeps the single-frame\n * scroll-sync hot path a couple of style writes rather than a DOM churn).\n *\n * The canopy iframe loads a customer page and doesn't include lattice /\n * tailwind, so styling is intentionally vanilla inline CSS rather than\n * Tailwind classes.\n *\n * @author Kevin O'Connell 2026-05-26\n */\n\n// Matches `--color-fuchsia` (Tailwind v4 `fuchsia-600`) used by agent-ui\n// so the in-iframe frame is visually consistent with the rest of the\n// select-mode UI.\nconst FUCHSIA_HEX = \"#c026d3\";\n\n// Brighter fuchsia (`fuchsia-400`) used while a text block is being inline\n// edited, so the active edit target stands out from a plain selection.\nconst EDITING_FUCHSIA_HEX = \"#e879f9\";\n\nconst FRAMES_CONTAINER_ID = \"replo-select-mode-selection-frames\";\n\n// Whether an inline text edit is in progress. Module-level so every frame\n// redraw (including the scroll-sync hot path) picks up the brighter color\n// without threading the flag through each call.\nlet isEditing = false;\n\nfunction getFrameBorderHex(): string {\n return isEditing ? EDITING_FUCHSIA_HEX : FUCHSIA_HEX;\n}\n\ntype SelectionFrameVariant = \"element\" | \"area\";\n\ntype SelectionFramePageRect = {\n x: number;\n y: number;\n width: number;\n height: number;\n};\n\ntype SelectionFrameSpec = {\n pageRect: SelectionFramePageRect;\n variant: SelectionFrameVariant;\n};\n\nfunction applyVariantStyle({\n frame,\n variant,\n}: {\n frame: HTMLDivElement;\n variant: SelectionFrameVariant;\n}) {\n // Both variants use the same bright fuchsia border so a single click and\n // each member of an area selection read as equally \"selected\"; the area\n // members carry a faint fill so a cluster still reads as a group. While\n // inline editing, the border brightens to mark the active edit target.\n frame.style.border = `2px solid ${getFrameBorderHex()}`;\n frame.style.background =\n variant === \"area\" ? \"rgba(192, 38, 211, 0.08)\" : \"transparent\";\n}\n\n/**\n * Toggle the brighter inline-edit border and re-color any frames already on\n * screen so the change is immediate, not deferred to the next redraw.\n */\nexport function setSelectionFrameEditing(editing: boolean) {\n if (isEditing === editing) {\n return;\n }\n isEditing = editing;\n if (typeof document === \"undefined\") {\n return;\n }\n const container = document.getElementById(FRAMES_CONTAINER_ID);\n if (!(container instanceof HTMLDivElement)) {\n return;\n }\n for (const child of container.children) {\n if (child instanceof HTMLDivElement) {\n child.style.borderColor = getFrameBorderHex();\n }\n }\n}\n\nfunction getOrCreateContainer(): HTMLDivElement | null {\n if (typeof document === \"undefined\") {\n return null;\n }\n const existing = document.getElementById(FRAMES_CONTAINER_ID);\n if (existing instanceof HTMLDivElement) {\n return existing;\n }\n if (!document.body) {\n return null;\n }\n const container = document.createElement(\"div\");\n container.id = FRAMES_CONTAINER_ID;\n container.setAttribute(\"aria-hidden\", \"true\");\n container.style.cssText = [\n \"position: absolute\",\n \"top: 0\",\n \"left: 0\",\n \"width: 0\",\n \"height: 0\",\n \"margin: 0\",\n \"padding: 0\",\n \"pointer-events: none\",\n \"z-index: 2147483646\",\n ].join(\";\");\n document.body.append(container);\n return container;\n}\n\nfunction createFrameNode(): HTMLDivElement {\n const frame = document.createElement(\"div\");\n frame.setAttribute(\"aria-hidden\", \"true\");\n frame.style.cssText = [\n \"position: absolute\",\n \"top: 0\",\n \"left: 0\",\n \"box-sizing: border-box\",\n \"border-radius: 2px\",\n \"pointer-events: none\",\n \"margin: 0\",\n \"padding: 0\",\n ].join(\";\");\n return frame;\n}\n\n/**\n * Position selection frames at the given *page* coordinates, one node per\n * spec. Page coords don't shift during scroll, so the caller is free to\n * call this once at commit time and let the browser handle the rest of the\n * scroll lifetime. Reconciles the node pool against `frames.length` so a\n * repeated single-frame call (scroll sync) just repositions one node.\n *\n * @author Kevin O'Connell 2026-05-26\n */\nexport function showSelectionFrames({\n frames,\n}: {\n frames: SelectionFrameSpec[];\n}) {\n const container = getOrCreateContainer();\n if (!container) {\n return;\n }\n\n while (container.childElementCount > frames.length) {\n container.lastElementChild?.remove();\n }\n while (container.childElementCount < frames.length) {\n container.append(createFrameNode());\n }\n\n frames.forEach((spec, index) => {\n const frame = container.children[index];\n if (!(frame instanceof HTMLDivElement)) {\n return;\n }\n applyVariantStyle({ frame, variant: spec.variant });\n frame.style.left = `${spec.pageRect.x}px`;\n frame.style.top = `${spec.pageRect.y}px`;\n frame.style.width = `${spec.pageRect.width}px`;\n frame.style.height = `${spec.pageRect.height}px`;\n });\n}\n\n/**\n * Convenience wrapper for the single-frame (element click) case.\n *\n * @author Kevin O'Connell 2026-05-26\n */\nexport function showSelectionFrame({\n pageRect,\n variant,\n}: {\n pageRect: SelectionFramePageRect;\n variant: SelectionFrameVariant;\n}) {\n showSelectionFrames({ frames: [{ pageRect, variant }] });\n}\n\n/**\n * @author Kevin O'Connell 2026-05-26\n */\nexport function hideSelectionFrame() {\n if (typeof document === \"undefined\") {\n return;\n }\n const container = document.getElementById(FRAMES_CONTAINER_ID);\n if (container instanceof HTMLDivElement) {\n container.replaceChildren();\n }\n}\n"],
5
- "mappings": "AAkCA,MAAM,cAAc;AAIpB,MAAM,sBAAsB;AAE5B,MAAM,sBAAsB;AAK5B,IAAI,YAAY;AAEhB,SAAS,oBAA4B;AACnC,SAAO,YAAY,sBAAsB;AAC3C;AAgBA,SAAS,kBAAkB;AAAA,EACzB;AAAA,EACA;AACF,GAGG;AAKD,QAAM,MAAM,SAAS,aAAa,kBAAkB,CAAC;AACrD,QAAM,MAAM,aACV,YAAY,SAAS,6BAA6B;AACtD;AAMO,SAAS,yBAAyB,SAAkB;AACzD,MAAI,cAAc,SAAS;AACzB;AAAA,EACF;AACA,cAAY;AACZ,MAAI,OAAO,aAAa,aAAa;AACnC;AAAA,EACF;AACA,QAAM,YAAY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,MAAM,UAAU;AAC9B,UAAM,QAAQ,UAAU,SAAS,KAAK;AACtC,QAAI,EAAE,iBAAiB,iBAAiB;AACtC;AAAA,IACF;AACA,sBAAkB,EAAE,OAAO,SAAS,KAAK,QAAQ,CAAC;AAClD,UAAM,MAAM,OAAO,GAAG,KAAK,SAAS,CAAC;AACrC,UAAM,MAAM,MAAM,GAAG,KAAK,SAAS,CAAC;AACpC,UAAM,MAAM,QAAQ,GAAG,KAAK,SAAS,KAAK;AAC1C,UAAM,MAAM,SAAS,GAAG,KAAK,SAAS,MAAM;AAAA,EAC9C,CAAC;AACH;AAOO,SAAS,mBAAmB;AAAA,EACjC;AAAA,EACA;AACF,GAGG;AACD,sBAAoB,EAAE,QAAQ,CAAC,EAAE,UAAU,QAAQ,CAAC,EAAE,CAAC;AACzD;AAKO,SAAS,qBAAqB;AACnC,MAAI,OAAO,aAAa,aAAa;AACnC;AAAA,EACF;AACA,QAAM,YAAY,SAAS,eAAe,mBAAmB;AAC7D,MAAI,qBAAqB,gBAAgB;AACvC,cAAU,gBAAgB;AAAA,EAC5B;AACF;",
4
+ "sourcesContent": ["/**\n * In-iframe selection frame renderer.\n *\n * Lives in the canopy iframe (not in agent-ui) because the previous\n * parent-side overlay had to be re-anchored on every scroll frame via\n * postMessage hop -> Zustand update -> React reconciliation, which\n * shows up as visible lag when the user scrolls quickly.\n *\n * By rendering directly inside the canopy iframe's document we get two\n * properties for free:\n *\n * 1. `position: absolute` + page coordinates means the document's own\n * scroll naturally translates the frames \u2014 zero JavaScript per\n * scroll frame, the browser composites them with the underlying page\n * content.\n * 2. No bridge serialization: the only cost when selection commits is\n * a handful of style writes on the frame nodes.\n *\n * A single click resolves to one frame; an area drag resolves to one\n * frame per captured element, so the renderer keeps a pool of nodes\n * under a shared container and reconciles it on each call (reusing\n * existing nodes when the count is stable, which keeps the single-frame\n * scroll-sync hot path a couple of style writes rather than a DOM churn).\n *\n * The canopy iframe loads a customer page and doesn't include lattice /\n * tailwind, so styling is intentionally vanilla inline CSS rather than\n * Tailwind classes.\n *\n * @author Kevin O'Connell 2026-05-26\n */\n\n// Matches `--color-fuchsia` (Tailwind v4 `fuchsia-600`) used by agent-ui\n// so the in-iframe frame is visually consistent with the rest of the\n// select-mode UI.\nconst FUCHSIA_HEX = \"#c026d3\";\n\n// Brighter fuchsia (`fuchsia-400`) used while a text block is being inline\n// edited, so the active edit target stands out from a plain selection.\nconst EDITING_FUCHSIA_HEX = \"#e879f9\";\n\nconst FRAMES_CONTAINER_ID = \"replo-select-mode-selection-frames\";\n\n// Whether an inline text edit is in progress. Module-level so every frame\n// redraw (including the scroll-sync hot path) picks up the brighter color\n// without threading the flag through each call.\nlet isEditing = false;\n\nfunction getFrameBorderHex(): string {\n return isEditing ? EDITING_FUCHSIA_HEX : FUCHSIA_HEX;\n}\n\ntype SelectionFrameVariant = \"element\" | \"area\";\n\ntype SelectionFramePageRect = {\n x: number;\n y: number;\n width: number;\n height: number;\n};\n\ntype SelectionFrameSpec = {\n pageRect: SelectionFramePageRect;\n variant: SelectionFrameVariant;\n};\n\nfunction applyVariantStyle({\n frame,\n variant,\n}: {\n frame: HTMLDivElement;\n variant: SelectionFrameVariant;\n}) {\n // Both variants use the same bright fuchsia border so a single click and\n // each member of an area selection read as equally \"selected\"; the area\n // members carry a faint fill so a cluster still reads as a group. While\n // inline editing, the border brightens to mark the active edit target.\n frame.style.border = `2px solid ${getFrameBorderHex()}`;\n frame.style.background =\n variant === \"area\" ? \"rgba(192, 38, 211, 0.08)\" : \"transparent\";\n}\n\n/**\n * Toggle the brighter inline-edit border and re-color any frames already on\n * screen so the change is immediate, not deferred to the next redraw.\n */\nexport function setSelectionFrameEditing(editing: boolean) {\n if (isEditing === editing) {\n return;\n }\n isEditing = editing;\n if (typeof document === \"undefined\") {\n return;\n }\n const container = document.getElementById(FRAMES_CONTAINER_ID);\n if (!(container instanceof HTMLDivElement)) {\n return;\n }\n for (const child of container.children) {\n if (child instanceof HTMLDivElement) {\n child.style.borderColor = getFrameBorderHex();\n }\n }\n}\n\n/**\n * Shared body-level layer container for in-iframe editor overlays (selection\n * frames, annotation frames). Zero-size and pointer-transparent so it never\n * affects the page; children opt into pointer events individually.\n */\nexport function getOrCreateFramesLayerContainer({\n id,\n zIndex,\n}: {\n id: string;\n zIndex: number;\n}): HTMLDivElement | null {\n if (typeof document === \"undefined\") {\n return null;\n }\n const existing = document.getElementById(id);\n if (existing instanceof HTMLDivElement) {\n return existing;\n }\n if (!document.body) {\n return null;\n }\n const container = document.createElement(\"div\");\n container.id = id;\n container.setAttribute(\"aria-hidden\", \"true\");\n container.style.cssText = [\n \"position: absolute\",\n \"top: 0\",\n \"left: 0\",\n \"width: 0\",\n \"height: 0\",\n \"margin: 0\",\n \"padding: 0\",\n \"pointer-events: none\",\n `z-index: ${zIndex}`,\n ].join(\";\");\n document.body.append(container);\n return container;\n}\n\nfunction getOrCreateContainer(): HTMLDivElement | null {\n return getOrCreateFramesLayerContainer({\n id: FRAMES_CONTAINER_ID,\n zIndex: 2147483646,\n });\n}\n\nfunction createFrameNode(): HTMLDivElement {\n const frame = document.createElement(\"div\");\n frame.setAttribute(\"aria-hidden\", \"true\");\n frame.style.cssText = [\n \"position: absolute\",\n \"top: 0\",\n \"left: 0\",\n \"box-sizing: border-box\",\n \"border-radius: 2px\",\n \"pointer-events: none\",\n \"margin: 0\",\n \"padding: 0\",\n ].join(\";\");\n return frame;\n}\n\n/**\n * Position selection frames at the given *page* coordinates, one node per\n * spec. Page coords don't shift during scroll, so the caller is free to\n * call this once at commit time and let the browser handle the rest of the\n * scroll lifetime. Reconciles the node pool against `frames.length` so a\n * repeated single-frame call (scroll sync) just repositions one node.\n *\n * @author Kevin O'Connell 2026-05-26\n */\nexport function showSelectionFrames({\n frames,\n}: {\n frames: SelectionFrameSpec[];\n}) {\n const container = getOrCreateContainer();\n if (!container) {\n return;\n }\n\n while (container.childElementCount > frames.length) {\n container.lastElementChild?.remove();\n }\n while (container.childElementCount < frames.length) {\n container.append(createFrameNode());\n }\n\n frames.forEach((spec, index) => {\n const frame = container.children[index];\n if (!(frame instanceof HTMLDivElement)) {\n return;\n }\n applyVariantStyle({ frame, variant: spec.variant });\n frame.style.left = `${spec.pageRect.x}px`;\n frame.style.top = `${spec.pageRect.y}px`;\n frame.style.width = `${spec.pageRect.width}px`;\n frame.style.height = `${spec.pageRect.height}px`;\n });\n}\n\n/**\n * Convenience wrapper for the single-frame (element click) case.\n *\n * @author Kevin O'Connell 2026-05-26\n */\nexport function showSelectionFrame({\n pageRect,\n variant,\n}: {\n pageRect: SelectionFramePageRect;\n variant: SelectionFrameVariant;\n}) {\n showSelectionFrames({ frames: [{ pageRect, variant }] });\n}\n\n/**\n * @author Kevin O'Connell 2026-05-26\n */\nexport function hideSelectionFrame() {\n if (typeof document === \"undefined\") {\n return;\n }\n const container = document.getElementById(FRAMES_CONTAINER_ID);\n if (container instanceof HTMLDivElement) {\n container.replaceChildren();\n }\n}\n"],
5
+ "mappings": "AAkCA,MAAM,cAAc;AAIpB,MAAM,sBAAsB;AAE5B,MAAM,sBAAsB;AAK5B,IAAI,YAAY;AAEhB,SAAS,oBAA4B;AACnC,SAAO,YAAY,sBAAsB;AAC3C;AAgBA,SAAS,kBAAkB;AAAA,EACzB;AAAA,EACA;AACF,GAGG;AAKD,QAAM,MAAM,SAAS,aAAa,kBAAkB,CAAC;AACrD,QAAM,MAAM,aACV,YAAY,SAAS,6BAA6B;AACtD;AAMO,SAAS,yBAAyB,SAAkB;AACzD,MAAI,cAAc,SAAS;AACzB;AAAA,EACF;AACA,cAAY;AACZ,MAAI,OAAO,aAAa,aAAa;AACnC;AAAA,EACF;AACA,QAAM,YAAY,SAAS,eAAe,mBAAmB;AAC7D,MAAI,EAAE,qBAAqB,iBAAiB;AAC1C;AAAA,EACF;AACA,aAAW,SAAS,UAAU,UAAU;AACtC,QAAI,iBAAiB,gBAAgB;AACnC,YAAM,MAAM,cAAc,kBAAkB;AAAA,IAC9C;AAAA,EACF;AACF;AAOO,SA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,QAAI,EAAE,iBAAiB,iBAAiB;AACtC;AAAA,IACF;AACA,sBAAkB,EAAE,OAAO,SAAS,KAAK,QAAQ,CAAC;AAClD,UAAM,MAAM,OAAO,GAAG,KAAK,SAAS,CAAC;AACrC,UAAM,MAAM,MAAM,GAAG,KAAK,SAAS,CAAC;AACpC,UAAM,MAAM,QAAQ,GAAG,KAAK,SAAS,KAAK;AAC1C,UAAM,MAAM,SAAS,GAAG,KAAK,SAAS,MAAM;AAAA,EAC9C,CAAC;AACH;AAOO,SAAS,mBAAmB;AAAA,EACjC;AAAA,EACA;AACF,GAGG;AACD,sBAAoB,EAAE,QAAQ,CAAC,EAAE,UAAU,QAAQ,CAAC,EAAE,CAAC;AACzD;AAKO,SAAS,qBAAqB;AACnC,MAAI,OAAO,aAAa,aAAa;AACnC;AAAA,EACF;AACA,QAAM,YAAY,SAAS,eAAe,mBAAmB;AAC7D,MAAI,qBAAqB,gBAAgB;AACvC,cAAU,gBAAgB;AAAA,EAC5B;AACF;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@replohq/canopy-sdk",
3
- "version": "1.0.4",
3
+ "version": "1.2.0",
4
4
  "description": "Replo Canopy SDK — cart, analytics, data loaders, and editor runtime for agent-built Next.js sites.",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -2,6 +2,7 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
2
  import { AnalyticsProvider } from "../analytics/analytics-provider";
3
3
  import { ReploFirstPartyPixel } from "../analytics/replo-first-party-pixel";
4
4
  import { CartLoader } from "../cart/cart-loader";
5
+ import { AnnotationLayerMount } from "../editor/annotations/AnnotationLayerMount";
5
6
  import { ClientErrorBoundary } from "../editor/ClientErrorBoundary";
6
7
  import { DesignLibraryPreview } from "../editor/design-library-preview/DesignLibraryPreview";
7
8
  import { DocumentReadyBeacon } from "../editor/DocumentReadyBeacon";
@@ -28,6 +29,7 @@ async function ReploProvider({ children }) {
28
29
  /* @__PURE__ */ jsx(LinkInterceptor, {}),
29
30
  /* @__PURE__ */ jsx(PostHogRelay, {}),
30
31
  /* @__PURE__ */ jsx(EditorSelection, {}),
32
+ /* @__PURE__ */ jsx(AnnotationLayerMount, {}),
31
33
  /* @__PURE__ */ jsx(DesignLibraryPreview, {}),
32
34
  children
33
35
  ] })
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../providers/replo-provider.tsx"],
4
- "sourcesContent": ["import type { CheckoutProvider } from \"../lib/integration-utils\";\n\nimport { AnalyticsProvider } from \"../analytics/analytics-provider\";\nimport { ReploFirstPartyPixel } from \"../analytics/replo-first-party-pixel\";\nimport { CartLoader } from \"../cart/cart-loader\";\nimport { ClientErrorBoundary } from \"../editor/ClientErrorBoundary\";\nimport { DesignLibraryPreview } from \"../editor/design-library-preview/DesignLibraryPreview\";\nimport { DocumentReadyBeacon } from \"../editor/DocumentReadyBeacon\";\nimport LinkInterceptor from \"../editor/LinkInterceptor\";\nimport { NextErrorReporter } from \"../editor/NextErrorReporter\";\nimport PostHogRelay from \"../editor/posthog-relay\";\nimport { EditorSelection } from \"../editor/select-mode/EditorSelection\";\nimport { getCheckoutProvider } from \"../lib/integration-utils\";\nimport { QueryProvider } from \"./query-provider\";\n\nexport async function ReploProvider({ children }: React.PropsWithChildren) {\n // Server-resolved so the analytics layer can suppress checkout-funnel events\n // that Shopify's hosted checkout already reports. Defaults to \"none\" (events\n // fire) if the env can't be read, preserving prior behavior.\n let checkoutProvider: CheckoutProvider = \"none\";\n try {\n checkoutProvider = await getCheckoutProvider();\n } catch {\n checkoutProvider = \"none\";\n }\n\n // The editor only embeds dev servers (`next dev`), so editor-integration components render there only \u2014 production builds ship none of them and behave like plain Next apps.\n const isDevServer = process.env.NODE_ENV === \"development\";\n\n return (\n <QueryProvider>\n <AnalyticsProvider checkoutProvider={checkoutProvider}>\n <ReploFirstPartyPixel />\n {isDevServer && <DocumentReadyBeacon />}\n <CartLoader>\n {isDevServer ? (\n <>\n {/* NOTE (Max, 2026-06-08): Outside ClientErrorBoundary on purpose \u2014 when\n the boundary catches a runtime error it swaps its children for a\n neutral cover, which would unmount the reporter and freeze it in the\n error state. It must stay mounted to observe Next's overlay across\n error <-> recover. */}\n <NextErrorReporter />\n <ClientErrorBoundary>\n <LinkInterceptor />\n <PostHogRelay />\n <EditorSelection />\n <DesignLibraryPreview />\n {children}\n </ClientErrorBoundary>\n </>\n ) : (\n children\n )}\n </CartLoader>\n </AnalyticsProvider>\n </QueryProvider>\n );\n}\n"],
5
- "mappings": "AAgCQ,SAII,UAJJ,KAWM,YAXN;AA9BR,SAAS,yBAAyB;AAClC,SAAS,4BAA4B;AACrC,SAAS,kBAAkB;AAC3B,SAAS,2BAA2B;AACpC,SAAS,4BAA4B;AACrC,SAAS,2BAA2B;AACpC,OAAO,qBAAqB;AAC5B,SAAS,yBAAyB;AAClC,OAAO,kBAAkB;AACzB,SAAS,uBAAuB;AAChC,SAAS,2BAA2B;AACpC,SAAS,qBAAqB;AAE9B,eAAsB,cAAc,EAAE,SAAS,GAA4B;AAIzE,MAAI,mBAAqC;AACzC,MAAI;AACF,uBAAmB,MAAM,oBAAoB;AAAA,EAC/C,QAAQ;AACN,uBAAmB;AAAA,EACrB;AAGA,QAAM,cAAc,QAAQ,IAAI,aAAa;AAE7C,SACE,oBAAC,iBACC,+BAAC,qBAAkB,kBACjB;AAAA,wBAAC,wBAAqB;AAAA,IACrB,eAAe,oBAAC,uBAAoB;AAAA,IACrC,oBAAC,cACE,wBACC,iCAME;AAAA,0BAAC,qBAAkB;AAAA,MACnB,qBAAC,uBACC;AAAA,4BAAC,mBAAgB;AAAA,QACjB,oBAAC,gBAAa;AAAA,QACd,oBAAC,mBAAgB;AAAA,QACjB,oBAAC,wBAAqB;AAAA,QACrB;AAAA,SACH;AAAA,OACF,IAEA,UAEJ;AAAA,KACF,GACF;AAEJ;",
4
+ "sourcesContent": ["import type { CheckoutProvider } from \"../lib/integration-utils\";\n\nimport { AnalyticsProvider } from \"../analytics/analytics-provider\";\nimport { ReploFirstPartyPixel } from \"../analytics/replo-first-party-pixel\";\nimport { CartLoader } from \"../cart/cart-loader\";\nimport { AnnotationLayerMount } from \"../editor/annotations/AnnotationLayerMount\";\nimport { ClientErrorBoundary } from \"../editor/ClientErrorBoundary\";\nimport { DesignLibraryPreview } from \"../editor/design-library-preview/DesignLibraryPreview\";\nimport { DocumentReadyBeacon } from \"../editor/DocumentReadyBeacon\";\nimport LinkInterceptor from \"../editor/LinkInterceptor\";\nimport { NextErrorReporter } from \"../editor/NextErrorReporter\";\nimport PostHogRelay from \"../editor/posthog-relay\";\nimport { EditorSelection } from \"../editor/select-mode/EditorSelection\";\nimport { getCheckoutProvider } from \"../lib/integration-utils\";\nimport { QueryProvider } from \"./query-provider\";\n\nexport async function ReploProvider({ children }: React.PropsWithChildren) {\n // Server-resolved so the analytics layer can suppress checkout-funnel events\n // that Shopify's hosted checkout already reports. Defaults to \"none\" (events\n // fire) if the env can't be read, preserving prior behavior.\n let checkoutProvider: CheckoutProvider = \"none\";\n try {\n checkoutProvider = await getCheckoutProvider();\n } catch {\n checkoutProvider = \"none\";\n }\n\n // The editor only embeds dev servers (`next dev`), so editor-integration components render there only \u2014 production builds ship none of them and behave like plain Next apps.\n const isDevServer = process.env.NODE_ENV === \"development\";\n\n return (\n <QueryProvider>\n <AnalyticsProvider checkoutProvider={checkoutProvider}>\n <ReploFirstPartyPixel />\n {isDevServer && <DocumentReadyBeacon />}\n <CartLoader>\n {isDevServer ? (\n <>\n {/* NOTE (Max, 2026-06-08): Outside ClientErrorBoundary on purpose \u2014 when\n the boundary catches a runtime error it swaps its children for a\n neutral cover, which would unmount the reporter and freeze it in the\n error state. It must stay mounted to observe Next's overlay across\n error <-> recover. */}\n <NextErrorReporter />\n <ClientErrorBoundary>\n <LinkInterceptor />\n <PostHogRelay />\n <EditorSelection />\n <AnnotationLayerMount />\n <DesignLibraryPreview />\n {children}\n </ClientErrorBoundary>\n </>\n ) : (\n children\n )}\n </CartLoader>\n </AnalyticsProvider>\n </QueryProvider>\n );\n}\n"],
5
+ "mappings": "AAiCQ,SAII,UAJJ,KAWM,YAXN;AA/BR,SAAS,yBAAyB;AAClC,SAAS,4BAA4B;AACrC,SAAS,kBAAkB;AAC3B,SAAS,4BAA4B;AACrC,SAAS,2BAA2B;AACpC,SAAS,4BAA4B;AACrC,SAAS,2BAA2B;AACpC,OAAO,qBAAqB;AAC5B,SAAS,yBAAyB;AAClC,OAAO,kBAAkB;AACzB,SAAS,uBAAuB;AAChC,SAAS,2BAA2B;AACpC,SAAS,qBAAqB;AAE9B,eAAsB,cAAc,EAAE,SAAS,GAA4B;AAIzE,MAAI,mBAAqC;AACzC,MAAI;AACF,uBAAmB,MAAM,oBAAoB;AAAA,EAC/C,QAAQ;AACN,uBAAmB;AAAA,EACrB;AAGA,QAAM,cAAc,QAAQ,IAAI,aAAa;AAE7C,SACE,oBAAC,iBACC,+BAAC,qBAAkB,kBACjB;AAAA,wBAAC,wBAAqB;AAAA,IACrB,eAAe,oBAAC,uBAAoB;AAAA,IACrC,oBAAC,cACE,wBACC,iCAME;AAAA,0BAAC,qBAAkB;AAAA,MACnB,qBAAC,uBACC;AAAA,4BAAC,mBAAgB;AAAA,QACjB,oBAAC,gBAAa;AAAA,QACd,oBAAC,mBAAgB;AAAA,QACjB,oBAAC,wBAAqB;AAAA,QACtB,oBAAC,wBAAqB;AAAA,QACrB;AAAA,SACH;AAAA,OACF,IAEA,UAEJ;AAAA,KACF,GACF;AAEJ;",
6
6
  "names": []
7
7
  }