@replohq/canopy-sdk 1.1.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/_vendor/schemas/generated/pageAnnotations.d.ts +48 -0
- package/_vendor/schemas/generated/pageAnnotations.mjs +1 -0
- package/_vendor/schemas/loaderKeys.mjs +2 -0
- package/_vendor/schemas/pageAnnotations.d.ts +134 -0
- package/_vendor/schemas/pageAnnotations.mjs +61 -0
- package/_vendor/schemas/selectMode.mjs +1 -1
- package/editor/annotations/AnnotationLayerMount.d.ts +1 -0
- package/editor/annotations/AnnotationLayerMount.js +13 -0
- package/editor/annotations/AnnotationLayerMount.js.map +7 -0
- package/editor/annotations/annotationController.d.ts +1 -0
- package/editor/annotations/annotationController.js +384 -0
- package/editor/annotations/annotationController.js.map +7 -0
- package/editor/annotations/bridgeGate.d.ts +7 -0
- package/editor/annotations/bridgeGate.js +22 -0
- package/editor/annotations/bridgeGate.js.map +7 -0
- package/editor/select-mode/annotationFrames.d.ts +33 -0
- package/editor/select-mode/annotationFrames.js +119 -0
- package/editor/select-mode/annotationFrames.js.map +7 -0
- package/editor/select-mode/selectionFrame.d.ts +9 -0
- package/editor/select-mode/selectionFrame.js +14 -4
- package/editor/select-mode/selectionFrame.js.map +2 -2
- package/loaders/loader-keys.d.ts +2 -0
- package/loaders/loader-keys.js +2 -0
- package/loaders/loader-keys.js.map +2 -2
- package/loaders/loader-schemas.d.ts +30 -0
- package/loaders/loader-schemas.js +23 -0
- package/loaders/loader-schemas.js.map +2 -2
- package/loaders/reviews-io-review-aggregate-loader.d.ts +12 -0
- package/loaders/reviews-io-review-aggregate-loader.js +43 -0
- package/loaders/reviews-io-review-aggregate-loader.js.map +7 -0
- package/loaders/reviews-io-reviews-loader.d.ts +14 -0
- package/loaders/reviews-io-reviews-loader.js +65 -0
- package/loaders/reviews-io-reviews-loader.js.map +7 -0
- package/package.json +1 -1
- package/providers/replo-provider.js +2 -0
- package/providers/replo-provider.js.map +2 -2
|
@@ -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,YAA2D;AAAA,EAC/D,KAAK;AAAA,EACL,QAAQ;AAAA,EACR,OAAO;AACT;AACA,MAAM,iBAAkD;AAAA,EACtD;AAAA,EACA;AAAA,EACA;AACF;AAmBA,IAAI,gBAAgB;AACpB,IAAI,eAA8B;AAClC,IAAI,UAAkC,CAAC;AACvC,IAAI,QAAuB;AAC3B,IAAI,oBAAmC;AACvC,IAAI,iBAAgC;AACpC,IAAI,mBAAkC;AACtC,IAAI,sBAA4D;AAChE,IAAI,oBAAmC;AACvC,IAAI,kBAAkB;AACtB,IAAI,sBAAqC;AACzC,IAAI,iBAAwC;AAC5C,IAAI,mBAA4C;AAEhD,SAAS,aAAa,SAAuC;AAC3D,MAAI,iBAAiB,MAAM;AACzB;AAAA,EACF;AACA,SAAO,OAAO,YAAY,SA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AA,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,gBAAgB;AAC7C,UAAM,MAAM,YAAY,sBAAsB,OAAO;AAAA,EACvD;AACF;AAEO,SAAS,+BACd,IACuB;AACvB,QAAM,QAAQ,eAAe,IAAI,EAAE;AACnC,MAAI,CAAC,OAAO,aAAa;AACvB,WAAO;AAAA,EACT;AACA,QAAM,OAAO,MAAM,sBAAsB;AACzC,SAAO,EAAE,GAAG,KAAK,GAAG,GAAG,KAAK,GAAG,OAAO,KAAK,OAA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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
|
|
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(
|
|
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 =
|
|
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
|
-
|
|
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\
|
|
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;
|
|
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,sBAA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[]
|
|
7
7
|
}
|
package/loaders/loader-keys.d.ts
CHANGED
|
@@ -23,6 +23,8 @@ export declare const DATA_LOADER_KEYS: {
|
|
|
23
23
|
readonly SMILE_IO_REWARDS: "smile_io.rewards";
|
|
24
24
|
readonly YOTPO_PRODUCT_REVIEWS: "yotpo.product_reviews";
|
|
25
25
|
readonly YOTPO_PRODUCT_REVIEW_AGGREGATE: "yotpo.product_review_aggregate";
|
|
26
|
+
readonly REVIEWS_IO_PRODUCT_REVIEWS: "reviews_io.product_reviews";
|
|
27
|
+
readonly REVIEWS_IO_PRODUCT_REVIEW_AGGREGATE: "reviews_io.product_review_aggregate";
|
|
26
28
|
readonly STATSIG_EXPERIMENT: "statsig.experiment";
|
|
27
29
|
readonly CONTENTFUL_ENTRY: "contentful.entry";
|
|
28
30
|
readonly CONTENTFUL_ENTRIES: "contentful.entries";
|
package/loaders/loader-keys.js
CHANGED
|
@@ -12,6 +12,8 @@ const DATA_LOADER_KEYS = {
|
|
|
12
12
|
SMILE_IO_REWARDS: "smile_io.rewards",
|
|
13
13
|
YOTPO_PRODUCT_REVIEWS: "yotpo.product_reviews",
|
|
14
14
|
YOTPO_PRODUCT_REVIEW_AGGREGATE: "yotpo.product_review_aggregate",
|
|
15
|
+
REVIEWS_IO_PRODUCT_REVIEWS: "reviews_io.product_reviews",
|
|
16
|
+
REVIEWS_IO_PRODUCT_REVIEW_AGGREGATE: "reviews_io.product_review_aggregate",
|
|
15
17
|
STATSIG_EXPERIMENT: "statsig.experiment",
|
|
16
18
|
CONTENTFUL_ENTRY: "contentful.entry",
|
|
17
19
|
CONTENTFUL_ENTRIES: "contentful.entries"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../loaders/loader-keys.ts"],
|
|
4
|
-
"sourcesContent": ["// NOTE (Ryan, 2026-07-23, REPL-27611): Canonical loader-key constants for the\n// published-page surface. canopy-sdk owns this copy so nothing shipped to a\n// generated site imports from `schemas`. The backend keeps its own copy in\n// `schemas/loaderKeys.ts` (consumed by the integration registry + tool\n// metadata, which cannot depend on canopy-sdk without a cycle); the two are\n// kept in lockstep by the drift guard in `loader-keys.spec.ts`.\n\n/**\n * Shared data-loader key constants. Loader components and prefetch queries\n * import from here so the strings are never duplicated across a generated site.\n *\n * These keys serve double duty: they identify which backend loader to invoke\n * AND are used as React Query cache key prefixes. Loader components internally\n * construct queryKey as `[loaderKey, args]`.\n *\n * Naming convention: `<integration>.<objectType>` or\n * `<integration>.<objectType>_<qualifier>`.\n */\nexport const DATA_LOADER_KEYS = {\n SHOPIFY_PRODUCT: \"shopify_storefront.product\",\n SHOPIFY_COLLECTION: \"shopify_storefront.collection\",\n SHOPIFY_COLLECTION_PRODUCTS: \"shopify_storefront.collection_products\",\n REPLO_PRODUCT: \"replo_products.product\",\n OKENDO_PRODUCT_REVIEWS: \"okendo.product_reviews\",\n OKENDO_PRODUCT_REVIEW_AGGREGATE: \"okendo.product_review_aggregate\",\n REBUY_RECOMMENDATIONS: \"rebuy.recommendations\",\n LEVANTA_PRODUCT: \"levanta_products.product\",\n SMILE_IO_VIP_TIERS: \"smile_io.vip_tiers\",\n SMILE_IO_EARNING_RULES: \"smile_io.earning_rules\",\n SMILE_IO_REWARDS: \"smile_io.rewards\",\n YOTPO_PRODUCT_REVIEWS: \"yotpo.product_reviews\",\n YOTPO_PRODUCT_REVIEW_AGGREGATE: \"yotpo.product_review_aggregate\",\n STATSIG_EXPERIMENT: \"statsig.experiment\",\n CONTENTFUL_ENTRY: \"contentful.entry\",\n CONTENTFUL_ENTRIES: \"contentful.entries\",\n} as const;\n\nexport type DataLoaderKey =\n (typeof DATA_LOADER_KEYS)[keyof typeof DATA_LOADER_KEYS];\n"],
|
|
5
|
-
"mappings": "AAkBO,MAAM,mBAAmB;AAAA,EAC9B,iBAAiB;AAAA,EACjB,oBAAoB;AAAA,EACpB,6BAA6B;AAAA,EAC7B,eAAe;AAAA,EACf,wBAAwB;AAAA,EACxB,iCAAiC;AAAA,EACjC,uBAAuB;AAAA,EACvB,iBAAiB;AAAA,EACjB,oBAAoB;AAAA,EACpB,wBAAwB;AAAA,EACxB,kBAAkB;AAAA,EAClB,uBAAuB;AAAA,EACvB,gCAAgC;AAAA,EAChC,oBAAoB;AAAA,EACpB,kBAAkB;AAAA,EAClB,oBAAoB;AACtB;",
|
|
4
|
+
"sourcesContent": ["// NOTE (Ryan, 2026-07-23, REPL-27611): Canonical loader-key constants for the\n// published-page surface. canopy-sdk owns this copy so nothing shipped to a\n// generated site imports from `schemas`. The backend keeps its own copy in\n// `schemas/loaderKeys.ts` (consumed by the integration registry + tool\n// metadata, which cannot depend on canopy-sdk without a cycle); the two are\n// kept in lockstep by the drift guard in `loader-keys.spec.ts`.\n\n/**\n * Shared data-loader key constants. Loader components and prefetch queries\n * import from here so the strings are never duplicated across a generated site.\n *\n * These keys serve double duty: they identify which backend loader to invoke\n * AND are used as React Query cache key prefixes. Loader components internally\n * construct queryKey as `[loaderKey, args]`.\n *\n * Naming convention: `<integration>.<objectType>` or\n * `<integration>.<objectType>_<qualifier>`.\n */\nexport const DATA_LOADER_KEYS = {\n SHOPIFY_PRODUCT: \"shopify_storefront.product\",\n SHOPIFY_COLLECTION: \"shopify_storefront.collection\",\n SHOPIFY_COLLECTION_PRODUCTS: \"shopify_storefront.collection_products\",\n REPLO_PRODUCT: \"replo_products.product\",\n OKENDO_PRODUCT_REVIEWS: \"okendo.product_reviews\",\n OKENDO_PRODUCT_REVIEW_AGGREGATE: \"okendo.product_review_aggregate\",\n REBUY_RECOMMENDATIONS: \"rebuy.recommendations\",\n LEVANTA_PRODUCT: \"levanta_products.product\",\n SMILE_IO_VIP_TIERS: \"smile_io.vip_tiers\",\n SMILE_IO_EARNING_RULES: \"smile_io.earning_rules\",\n SMILE_IO_REWARDS: \"smile_io.rewards\",\n YOTPO_PRODUCT_REVIEWS: \"yotpo.product_reviews\",\n YOTPO_PRODUCT_REVIEW_AGGREGATE: \"yotpo.product_review_aggregate\",\n REVIEWS_IO_PRODUCT_REVIEWS: \"reviews_io.product_reviews\",\n REVIEWS_IO_PRODUCT_REVIEW_AGGREGATE: \"reviews_io.product_review_aggregate\",\n STATSIG_EXPERIMENT: \"statsig.experiment\",\n CONTENTFUL_ENTRY: \"contentful.entry\",\n CONTENTFUL_ENTRIES: \"contentful.entries\",\n} as const;\n\nexport type DataLoaderKey =\n (typeof DATA_LOADER_KEYS)[keyof typeof DATA_LOADER_KEYS];\n"],
|
|
5
|
+
"mappings": "AAkBO,MAAM,mBAAmB;AAAA,EAC9B,iBAAiB;AAAA,EACjB,oBAAoB;AAAA,EACpB,6BAA6B;AAAA,EAC7B,eAAe;AAAA,EACf,wBAAwB;AAAA,EACxB,iCAAiC;AAAA,EACjC,uBAAuB;AAAA,EACvB,iBAAiB;AAAA,EACjB,oBAAoB;AAAA,EACpB,wBAAwB;AAAA,EACxB,kBAAkB;AAAA,EAClB,uBAAuB;AAAA,EACvB,gCAAgC;AAAA,EAChC,4BAA4B;AAAA,EAC5B,qCAAqC;AAAA,EACrC,oBAAoB;AAAA,EACpB,kBAAkB;AAAA,EAClB,oBAAoB;AACtB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -765,6 +765,36 @@ export declare const yotpoProductReviewAggregateLoaderOutputSchema: z.ZodObject<
|
|
|
765
765
|
totalReviews: z.ZodNumber;
|
|
766
766
|
starDistribution: z.ZodRecord<z.ZodString, z.ZodNumber>;
|
|
767
767
|
}, z.core.$strip>;
|
|
768
|
+
export declare const reviewsIoReviewLoaderItemSchema: z.ZodObject<{
|
|
769
|
+
id: z.ZodString;
|
|
770
|
+
title: z.ZodNullable<z.ZodString>;
|
|
771
|
+
body: z.ZodNullable<z.ZodString>;
|
|
772
|
+
rating: z.ZodNullable<z.ZodNumber>;
|
|
773
|
+
createdAt: z.ZodNullable<z.ZodString>;
|
|
774
|
+
verifiedBuyer: z.ZodBoolean;
|
|
775
|
+
reviewerName: z.ZodNullable<z.ZodString>;
|
|
776
|
+
productName: z.ZodNullable<z.ZodString>;
|
|
777
|
+
sku: z.ZodNullable<z.ZodString>;
|
|
778
|
+
}, z.core.$strip>;
|
|
779
|
+
export declare const reviewsIoProductReviewsLoaderOutputSchema: z.ZodObject<{
|
|
780
|
+
reviews: z.ZodArray<z.ZodObject<{
|
|
781
|
+
id: z.ZodString;
|
|
782
|
+
title: z.ZodNullable<z.ZodString>;
|
|
783
|
+
body: z.ZodNullable<z.ZodString>;
|
|
784
|
+
rating: z.ZodNullable<z.ZodNumber>;
|
|
785
|
+
createdAt: z.ZodNullable<z.ZodString>;
|
|
786
|
+
verifiedBuyer: z.ZodBoolean;
|
|
787
|
+
reviewerName: z.ZodNullable<z.ZodString>;
|
|
788
|
+
productName: z.ZodNullable<z.ZodString>;
|
|
789
|
+
sku: z.ZodNullable<z.ZodString>;
|
|
790
|
+
}, z.core.$strip>>;
|
|
791
|
+
reviewCount: z.ZodNumber;
|
|
792
|
+
reviewAverageValue: z.ZodNumber;
|
|
793
|
+
}, z.core.$strip>;
|
|
794
|
+
export declare const reviewsIoProductReviewAggregateLoaderOutputSchema: z.ZodObject<{
|
|
795
|
+
reviewCount: z.ZodNumber;
|
|
796
|
+
reviewAverageValue: z.ZodNumber;
|
|
797
|
+
}, z.core.$strip>;
|
|
768
798
|
export declare const statsigExperimentLoaderOutputSchema: z.ZodObject<{
|
|
769
799
|
experimentName: z.ZodString;
|
|
770
800
|
groupName: z.ZodNullable<z.ZodString>;
|
|
@@ -228,6 +228,26 @@ const yotpoProductReviewAggregateLoaderOutputSchema = z.object({
|
|
|
228
228
|
totalReviews: z.number(),
|
|
229
229
|
starDistribution: z.record(z.string(), z.number())
|
|
230
230
|
});
|
|
231
|
+
const reviewsIoReviewLoaderItemSchema = z.object({
|
|
232
|
+
id: z.string(),
|
|
233
|
+
title: z.string().nullable(),
|
|
234
|
+
body: z.string().nullable(),
|
|
235
|
+
rating: z.number().nullable(),
|
|
236
|
+
createdAt: z.string().nullable(),
|
|
237
|
+
verifiedBuyer: z.boolean(),
|
|
238
|
+
reviewerName: z.string().nullable(),
|
|
239
|
+
productName: z.string().nullable(),
|
|
240
|
+
sku: z.string().nullable()
|
|
241
|
+
});
|
|
242
|
+
const reviewsIoProductReviewsLoaderOutputSchema = z.object({
|
|
243
|
+
reviews: z.array(reviewsIoReviewLoaderItemSchema),
|
|
244
|
+
reviewCount: z.number(),
|
|
245
|
+
reviewAverageValue: z.number()
|
|
246
|
+
});
|
|
247
|
+
const reviewsIoProductReviewAggregateLoaderOutputSchema = z.object({
|
|
248
|
+
reviewCount: z.number(),
|
|
249
|
+
reviewAverageValue: z.number()
|
|
250
|
+
});
|
|
231
251
|
const statsigExperimentLoaderOutputSchema = z.object({
|
|
232
252
|
experimentName: z.string(),
|
|
233
253
|
groupName: z.string().nullable().describe("The assigned variant group name (e.g. Control, Test)."),
|
|
@@ -290,6 +310,9 @@ export {
|
|
|
290
310
|
priceSchema,
|
|
291
311
|
productOptionSchema,
|
|
292
312
|
productSchema,
|
|
313
|
+
reviewsIoProductReviewAggregateLoaderOutputSchema,
|
|
314
|
+
reviewsIoProductReviewsLoaderOutputSchema,
|
|
315
|
+
reviewsIoReviewLoaderItemSchema,
|
|
293
316
|
selectedOptionSchema,
|
|
294
317
|
sellingPlanGroupSchema,
|
|
295
318
|
sellingPlanOptionValueSchema,
|