@supernovaio/prototyping-tooling 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/README.md +193 -0
  2. package/dist/build/index.d.ts +3 -0
  3. package/dist/build/index.d.ts.map +1 -0
  4. package/dist/build/index.js +96 -0
  5. package/dist/build/vite-plugin-forge-ids.d.ts +7 -0
  6. package/dist/build/vite-plugin-forge-ids.d.ts.map +1 -0
  7. package/dist/client/annotation/AnnotationOverlay.d.ts +86 -0
  8. package/dist/client/annotation/AnnotationOverlay.d.ts.map +1 -0
  9. package/dist/client/design-mode/DesignModeController.d.ts +35 -0
  10. package/dist/client/design-mode/DesignModeController.d.ts.map +1 -0
  11. package/dist/client/general/ComponentRegistry.d.ts +15 -0
  12. package/dist/client/general/ComponentRegistry.d.ts.map +1 -0
  13. package/dist/client/general/ForgeClient.d.ts +36 -0
  14. package/dist/client/general/ForgeClient.d.ts.map +1 -0
  15. package/dist/client/general/SourceCodeUpdater.d.ts +15 -0
  16. package/dist/client/general/SourceCodeUpdater.d.ts.map +1 -0
  17. package/dist/client/general/element-utils.d.ts +20 -0
  18. package/dist/client/general/element-utils.d.ts.map +1 -0
  19. package/dist/client/general/overlay.d.ts +9 -0
  20. package/dist/client/general/overlay.d.ts.map +1 -0
  21. package/dist/client/general/react-detection.d.ts +49 -0
  22. package/dist/client/general/react-detection.d.ts.map +1 -0
  23. package/dist/client/general/types.d.ts +26 -0
  24. package/dist/client/general/types.d.ts.map +1 -0
  25. package/dist/client/general/xpath.d.ts +3 -0
  26. package/dist/client/general/xpath.d.ts.map +1 -0
  27. package/dist/client/index.d.ts +6 -0
  28. package/dist/client/index.d.ts.map +1 -0
  29. package/dist/client/select-mode/SelectModeController.d.ts +31 -0
  30. package/dist/client/select-mode/SelectModeController.d.ts.map +1 -0
  31. package/dist/client.js +836 -0
  32. package/dist/constants-BXKWBfHg.js +55 -0
  33. package/dist/debug-CLzmqn3R.js +11 -0
  34. package/dist/host/ForgeHost.d.ts +57 -0
  35. package/dist/host/ForgeHost.d.ts.map +1 -0
  36. package/dist/host/index.d.ts +3 -0
  37. package/dist/host/index.d.ts.map +1 -0
  38. package/dist/host/types.d.ts +32 -0
  39. package/dist/host/types.d.ts.map +1 -0
  40. package/dist/host.js +142 -0
  41. package/dist/index.d.ts +12 -0
  42. package/dist/index.d.ts.map +1 -0
  43. package/dist/index.js +14 -0
  44. package/dist/react/index.d.ts +5 -0
  45. package/dist/react/index.d.ts.map +1 -0
  46. package/dist/react/useDesignMode.d.ts +12 -0
  47. package/dist/react/useDesignMode.d.ts.map +1 -0
  48. package/dist/react/useElementSelector.d.ts +12 -0
  49. package/dist/react/useElementSelector.d.ts.map +1 -0
  50. package/dist/react.js +5 -0
  51. package/dist/shared/constants.d.ts +27 -0
  52. package/dist/shared/constants.d.ts.map +1 -0
  53. package/dist/shared/debug.d.ts +4 -0
  54. package/dist/shared/debug.d.ts.map +1 -0
  55. package/dist/shared/events.d.ts +157 -0
  56. package/dist/shared/events.d.ts.map +1 -0
  57. package/dist/shared/messaging.d.ts +19 -0
  58. package/dist/shared/messaging.d.ts.map +1 -0
  59. package/dist/useDesignMode-VIipNUSj.js +68 -0
  60. package/package.json +69 -0
@@ -0,0 +1,55 @@
1
+ function o(n) {
2
+ if (n && typeof n == "object" && "source" in n) {
3
+ const e = n.source;
4
+ return typeof e == "string" && e.includes("react-devtools");
5
+ }
6
+ return !1;
7
+ }
8
+ class a {
9
+ targetWindow;
10
+ targetOrigin;
11
+ constructor(e, s = "*") {
12
+ this.targetWindow = e, this.targetOrigin = s;
13
+ }
14
+ send(e, s) {
15
+ this.targetWindow.postMessage(e, s || this.targetOrigin || "*");
16
+ }
17
+ onMessage(e) {
18
+ const s = (t) => {
19
+ e(t);
20
+ };
21
+ return window.addEventListener("message", s), () => {
22
+ window.removeEventListener("message", s);
23
+ };
24
+ }
25
+ }
26
+ class r {
27
+ send(e, s) {
28
+ window.parent && window.parent !== window && window.parent.postMessage(e, s || "*");
29
+ }
30
+ onMessage(e) {
31
+ const s = (t) => {
32
+ e(t);
33
+ };
34
+ return window.addEventListener("message", s), () => {
35
+ window.removeEventListener("message", s);
36
+ };
37
+ }
38
+ }
39
+ const E = "host", O = "sandbox", T = { HIT_TEST_OVERLAY: "9998", HOVER_OVERLAY: "9999", ANNOTATION_DOT: "10000", TOOLTIP: "10001" }, _ = { SELECT_OVERLAY_BORDER: "#1A58D0", SELECT_OVERLAY_BG: "#45ADFF17", DESIGN_SELECTION_OUTLINE: "#9333ea", ANNOTATION_SINGLE: "#1A58D0", ANNOTATION_MULTI: "#1A58D0", ANNOTATION_SINGLE_BG: "#45ADFF17", ANNOTATION_MULTI_BG: "#45ADFF17", DRAG_RECT_BG: "#45ADFF17" }, i = 20, A = 20, N = { CHILD_READY_DELAY: 1e3, CONNECTION_TIMEOUT: 5e3 }, c = ["#root", "#app", "#__next", "[data-reactroot]"], I = 200, d = 30, w = 6;
40
+ export {
41
+ i as B,
42
+ _ as C,
43
+ O as M,
44
+ r as P,
45
+ c as R,
46
+ N as T,
47
+ a as W,
48
+ T as Z,
49
+ E as a,
50
+ w as b,
51
+ d as c,
52
+ I as d,
53
+ A as e,
54
+ o as i
55
+ };
@@ -0,0 +1,11 @@
1
+ let t = !1;
2
+ function a(e = !0) {
3
+ t = e;
4
+ }
5
+ function g(e, ...n) {
6
+ t && (/* @__PURE__ */ new Date()).toISOString().split("T")[1].slice(0, -1);
7
+ }
8
+ export {
9
+ g as d,
10
+ a as e
11
+ };
@@ -0,0 +1,57 @@
1
+ import type { RestoreAnnotationData } from "../shared/events.js";
2
+ import type { ComponentDefinition } from "../shared/events.js";
3
+ import type { ConnectionStatus, HostEvents } from "./types.js";
4
+ /**
5
+ * Host-side controller that runs in the parent window.
6
+ * Manages the connection to the child iframe and provides
7
+ * methods to control modes (select, design, annotation) and
8
+ * listen for events from the child.
9
+ */
10
+ export declare class ForgeHost {
11
+ private iframe;
12
+ private messenger;
13
+ private status;
14
+ private eventHandlers;
15
+ private messageCleanup;
16
+ private readyCheckCleanup;
17
+ private componentRegistry;
18
+ constructor(iframe: HTMLIFrameElement);
19
+ /**
20
+ * Initiates the connection to the child iframe.
21
+ * Resolves when the child sends CHILD_READY. Rejects on timeout.
22
+ */
23
+ connect(): Promise<void>;
24
+ private finishConnection;
25
+ /** Toggles element-picking select mode in the child iframe. */
26
+ enableSelectMode(enabled: boolean): void;
27
+ /** Toggles design mode (element editing) in the child iframe. */
28
+ enableDesignMode(enabled: boolean): void;
29
+ /** Toggles annotation mode in the child iframe. */
30
+ enableAnnotationMode(enabled: boolean): void;
31
+ /** Deletes an annotation in the child iframe. */
32
+ deleteAnnotation(annotationId: string): void;
33
+ /** Confirms and numbers an annotation in the child iframe. */
34
+ keepAnnotation(annotationId: string, order: number): void;
35
+ /** Sends updated order numbers for all annotation badges. */
36
+ updateAnnotationOrders(orders: Record<string, number>): void;
37
+ /** Updates the text content of a forge element in the child. */
38
+ updateElementText(forgeId: string, text: string): void;
39
+ /** Toggles visibility of annotation marker badges in the child. */
40
+ toggleMarkers(): void;
41
+ /** Re-sends saved annotations to the child so it can recreate the dots. */
42
+ restoreAnnotations(annotations: RestoreAnnotationData[]): void;
43
+ /** Clears the current design-mode selection in the child. */
44
+ deselectElement(): void;
45
+ /** Registers component definitions received from the child. */
46
+ registerComponents(components: Record<string, ComponentDefinition>): void;
47
+ /** Updates a property on a forge element in the child. */
48
+ updateProperty(forgeId: string, propName: string, value: any): void;
49
+ /** Subscribes to a host event. Returns an unsubscribe function. */
50
+ on<K extends keyof HostEvents>(event: K, handler: HostEvents[K]): () => void;
51
+ private emit;
52
+ /** Returns the current connection status. */
53
+ getStatus(): ConnectionStatus;
54
+ /** Disconnects from the child iframe and cleans up listeners. */
55
+ disconnect(): void;
56
+ }
57
+ //# sourceMappingURL=ForgeHost.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ForgeHost.d.ts","sourceRoot":"","sources":["../../src/host/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AE,GAAG,IAAI;IAK9D,6DAA6D;IAC7D,eAAe,IAAI,IAAI;IAOvB,+DAA+D;IAC/D,kBAAkB,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,GAAG,IAAI;IAOzE,0DAA0D;IAC1D,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI;IAOnE,mEAAmE;IACnE,EAAE,CAAC,CAAC,SAAS,MAAM,UAAU,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI;IAU5E,OAAO,CAAC,IAAI;IASZ,6CAA6C;IAC7C,SAAS,IAAI,gBAAgB;IAI7B,iEAAiE;IACjE,UAAU,IAAI,IAAI;CAanB"}
@@ -0,0 +1,3 @@
1
+ export { ForgeHost } from "./ForgeHost.js";
2
+ export type { ConnectionStatus, HostEvents, PropWithName, ElementSelection } from "./types.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/host/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,YAAY,EAAE,gBAAgB,EAAE,UAAU,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA"}
@@ -0,0 +1,32 @@
1
+ import type { AnnotationData } from "../shared/events.js";
2
+ export type ConnectionStatus = "connecting" | "connected" | "disconnected";
3
+ export interface PropWithName {
4
+ name: string;
5
+ type: "text" | "enum" | "boolean" | "number" | "string";
6
+ options?: string[];
7
+ default?: any;
8
+ editable: boolean;
9
+ label?: string;
10
+ }
11
+ export interface ElementSelection {
12
+ forgeId: string;
13
+ sourcePos?: string;
14
+ text: string;
15
+ type: string;
16
+ xpath: string;
17
+ componentName: string;
18
+ editableProps: PropWithName[];
19
+ propValues: Record<string, any>;
20
+ }
21
+ export interface HostEvents {
22
+ "xpath-selected": (xpath: string) => void;
23
+ "select-mode-disabled": () => void;
24
+ "design-mode-disabled": () => void;
25
+ "element-selected": (selection: ElementSelection) => void;
26
+ "annotation-created": (annotation: AnnotationData) => void;
27
+ "annotation-dot-clicked": (annotationId: string, dotX: number, dotY: number) => void;
28
+ "source-updated": (forgeId: string, source: string, filePath: string) => void;
29
+ connected: () => void;
30
+ disconnected: () => void;
31
+ }
32
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/host/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAEzD,MAAM,MAAM,gBAAgB,GAAG,YAAY,GAAG,WAAW,GAAG,cAAc,CAAA;AAE1E,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAA;IACvD,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;IAClB,OAAO,CAAC,EAAE,GAAG,CAAA;IACb,QAAQ,EAAE,OAAO,CAAA;IACjB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,aAAa,EAAE,MAAM,CAAA;IACrB,aAAa,EAAE,YAAY,EAAE,CAAA;IAC7B,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;CAChC;AAED,MAAM,WAAW,UAAU;IACzB,gBAAgB,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IACzC,sBAAsB,EAAE,MAAM,IAAI,CAAA;IAClC,sBAAsB,EAAE,MAAM,IAAI,CAAA;IAClC,kBAAkB,EAAE,CAAC,SAAS,EAAE,gBAAgB,KAAK,IAAI,CAAA;IACzD,oBAAoB,EAAE,CAAC,UAAU,EAAE,cAAc,KAAK,IAAI,CAAA;IAC1D,wBAAwB,EAAE,CAAC,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IACpF,gBAAgB,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAA;IAC7E,SAAS,EAAE,MAAM,IAAI,CAAA;IACrB,YAAY,EAAE,MAAM,IAAI,CAAA;CACzB"}
package/dist/host.js ADDED
@@ -0,0 +1,142 @@
1
+ import { T as c, W as h, a as o, i as d, M as E } from "./constants-BXKWBfHg.js";
2
+ import { d as s } from "./debug-CLzmqn3R.js";
3
+ class p {
4
+ iframe;
5
+ messenger = null;
6
+ status = "disconnected";
7
+ eventHandlers = /* @__PURE__ */ new Map();
8
+ messageCleanup = null;
9
+ readyCheckCleanup = null;
10
+ componentRegistry = /* @__PURE__ */ new Map();
11
+ constructor(e) {
12
+ s("host", "ForgeHost created with iframe:", e), this.iframe = e, window.__forgeHost = this;
13
+ }
14
+ async connect() {
15
+ return s("host", "Starting connection process..."), new Promise((e, n) => {
16
+ this.status = "connecting";
17
+ const t = () => {
18
+ this.readyCheckCleanup && (this.readyCheckCleanup(), this.readyCheckCleanup = null);
19
+ }, r = (i) => {
20
+ if (!d(i.data) && (s("host", "Received message:", i.data, "from origin:", i.origin), i.data && typeof i.data == "object" && "type" in i.data)) {
21
+ const a = i.data;
22
+ a.origin === E && a.type === "CHILD_READY" && (s("host", "CHILD_READY received from sandbox, finishing connection"), t(), this.finishConnection(), e());
23
+ }
24
+ };
25
+ s("host", "Setting up message listener for CHILD_READY"), window.addEventListener("message", r), this.readyCheckCleanup = () => {
26
+ window.removeEventListener("message", r);
27
+ }, setTimeout(() => {
28
+ this.status === "connecting" && (s("host", "Connection timeout - child did not respond"), t(), this.status = "disconnected", n(new Error("Connection timeout - child app did not respond")));
29
+ }, c.CONNECTION_TIMEOUT);
30
+ });
31
+ }
32
+ finishConnection() {
33
+ s("host", "Finishing connection...");
34
+ const e = this.iframe.contentWindow;
35
+ if (!e)
36
+ throw new Error("Iframe contentWindow not available");
37
+ this.messenger = new h(e), this.status = "connected", s("host", "Sending initial PING to child"), this.messenger.send({ type: "PING", origin: o }), this.messageCleanup = this.messenger.onMessage((n) => {
38
+ if (d(n.data)) return;
39
+ const t = n.data;
40
+ if (!(!t || typeof t != "object" || !("origin" in t)))
41
+ switch (s("host", "Received message from child:", t), t.type) {
42
+ case "XPATH_REPORT":
43
+ s("host", "XPATH_REPORT received:", t.xpath), this.emit("xpath-selected", t.xpath);
44
+ break;
45
+ case "SELECT_MODE_DISABLED":
46
+ this.emit("select-mode-disabled");
47
+ break;
48
+ case "DESIGN_MODE_DISABLED":
49
+ this.emit("design-mode-disabled");
50
+ break;
51
+ case "ELEMENT_SELECTED": {
52
+ s("host", "ELEMENT_SELECTED received:", t);
53
+ const r = t.editableProps.map((i) => ({ name: i.name, type: i.type, options: i.options, default: i.default, editable: i.editable, label: i.label }));
54
+ this.emit("element-selected", { forgeId: t.forgeId, sourcePos: t.sourcePos, text: t.text, type: t.elementType, xpath: t.xpath, componentName: t.componentName, editableProps: r, propValues: t.propValues });
55
+ break;
56
+ }
57
+ case "REGISTER_COMPONENTS":
58
+ s("host", "REGISTER_COMPONENTS received"), this.registerComponents(t.components);
59
+ break;
60
+ case "ANNOTATION_CREATED":
61
+ s("host", "ANNOTATION_CREATED received:", t.annotation), this.emit("annotation-created", t.annotation);
62
+ break;
63
+ case "ANNOTATION_DOT_CLICKED":
64
+ this.emit("annotation-dot-clicked", t.annotationId, t.dotX, t.dotY);
65
+ break;
66
+ case "SOURCE_UPDATED":
67
+ s("host", "SOURCE_UPDATED received:", t.forgeId, t.filePath), this.emit("source-updated", t.forgeId, t.source, t.filePath);
68
+ break;
69
+ }
70
+ }), this.emit("connected"), s("host", "Connection complete");
71
+ }
72
+ enableSelectMode(e) {
73
+ if (!this.messenger || this.status !== "connected")
74
+ throw new Error("Not connected to child app");
75
+ s("host", `Sending ENABLE_SELECT_MODE: ${e}`), this.messenger.send({ type: "ENABLE_SELECT_MODE", enabled: e, origin: o });
76
+ }
77
+ enableDesignMode(e) {
78
+ if (!this.messenger || this.status !== "connected")
79
+ throw new Error("Not connected to child app");
80
+ s("host", `Sending ENABLE_DESIGN_MODE: ${e}`), this.messenger.send({ type: "ENABLE_DESIGN_MODE", enabled: e, origin: o });
81
+ }
82
+ enableAnnotationMode(e) {
83
+ if (!this.messenger || this.status !== "connected")
84
+ throw new Error("Not connected to child app");
85
+ s("host", `Sending ENABLE_ANNOTATION_MODE: ${e}`), this.messenger.send({ type: "ENABLE_ANNOTATION_MODE", enabled: e, origin: o });
86
+ }
87
+ deleteAnnotation(e) {
88
+ !this.messenger || this.status !== "connected" || this.messenger.send({ type: "ANNOTATION_DELETED", annotationId: e, origin: o });
89
+ }
90
+ keepAnnotation(e, n) {
91
+ !this.messenger || this.status !== "connected" || this.messenger.send({ type: "ANNOTATION_KEEP", annotationId: e, order: n, origin: o });
92
+ }
93
+ updateAnnotationOrders(e) {
94
+ !this.messenger || this.status !== "connected" || this.messenger.send({ type: "ANNOTATION_UPDATE_ORDERS", orders: e, origin: o });
95
+ }
96
+ updateElementText(e, n) {
97
+ if (!this.messenger || this.status !== "connected")
98
+ throw new Error("Not connected to child app");
99
+ this.messenger.send({ type: "UPDATE_TEXT", forgeId: e, text: n, origin: o });
100
+ }
101
+ toggleMarkers() {
102
+ !this.messenger || this.status !== "connected" || this.messenger.send({ type: "TOGGLE_MARKERS", origin: o });
103
+ }
104
+ restoreAnnotations(e) {
105
+ !this.messenger || this.status !== "connected" || this.messenger.send({ type: "RESTORE_ANNOTATIONS", annotations: e, origin: o });
106
+ }
107
+ deselectElement() {
108
+ if (!this.messenger || this.status !== "connected")
109
+ throw new Error("Not connected to child app");
110
+ this.messenger.send({ type: "DESELECT_ELEMENT", origin: o });
111
+ }
112
+ registerComponents(e) {
113
+ s("host", `Registering ${Object.keys(e).length} components`);
114
+ for (const [n, t] of Object.entries(e))
115
+ this.componentRegistry.set(n, t);
116
+ }
117
+ updateProperty(e, n, t) {
118
+ if (!this.messenger || this.status !== "connected")
119
+ throw new Error("Not connected to child app");
120
+ this.messenger.send({ type: "UPDATE_PROPERTY", forgeId: e, propName: n, value: t, origin: o });
121
+ }
122
+ on(e, n) {
123
+ return this.eventHandlers.has(e) || this.eventHandlers.set(e, /* @__PURE__ */ new Set()), this.eventHandlers.get(e).add(n), () => {
124
+ this.eventHandlers.get(e)?.delete(n);
125
+ };
126
+ }
127
+ emit(e, ...n) {
128
+ const t = this.eventHandlers.get(e);
129
+ t && t.forEach((r) => {
130
+ r(...n);
131
+ });
132
+ }
133
+ getStatus() {
134
+ return this.status;
135
+ }
136
+ disconnect() {
137
+ this.messageCleanup && (this.messageCleanup(), this.messageCleanup = null), this.readyCheckCleanup && (this.readyCheckCleanup(), this.readyCheckCleanup = null), this.messenger = null, this.status = "disconnected", this.emit("disconnected");
138
+ }
139
+ }
140
+ export {
141
+ p as ForgeHost
142
+ };
@@ -0,0 +1,12 @@
1
+ export { ForgeHost } from "./host/index.js";
2
+ export type { ConnectionStatus, HostEvents, PropWithName, ElementSelection } from "./host/types.js";
3
+ export { ForgeClient } from "./client/index.js";
4
+ export type { ForgeClientOptions, ForgeClientContext } from "./client/general/types.js";
5
+ export { useElementSelector } from "./react/index.js";
6
+ export { useDesignMode } from "./react/index.js";
7
+ export type { UseElementSelectorResult } from "./react/index.js";
8
+ export type { DesignModeHook } from "./react/index.js";
9
+ export type { HostToClientMessage, ClientToHostMessage, AnnotationData, AnnotationElementInfo, RestoreAnnotationData, PropDefinition, ComponentDefinition, } from "./shared/events.js";
10
+ export { enableDebug } from "./shared/debug.js";
11
+ export { MESSAGE_ORIGIN_SANDBOX, MESSAGE_ORIGIN_HOST } from "./shared/events.js";
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,YAAY,EAAE,gBAAgB,EAAE,UAAU,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAEnG,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,YAAY,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAA;AAEvF,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAChD,YAAY,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAA;AAChE,YAAY,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAEtD,YAAY,EACV,mBAAmB,EACnB,mBAAmB,EACnB,cAAc,EACd,qBAAqB,EACrB,qBAAqB,EACrB,cAAc,EACd,mBAAmB,GACpB,MAAM,oBAAoB,CAAA;AAE3B,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,14 @@
1
+ import { ForgeHost as r } from "./host.js";
2
+ import { ForgeClient as t } from "./client.js";
3
+ import { a as S, u as m } from "./useDesignMode-VIipNUSj.js";
4
+ import { e as p } from "./debug-CLzmqn3R.js";
5
+ import { a as E, M as g } from "./constants-BXKWBfHg.js";
6
+ export {
7
+ t as ForgeClient,
8
+ r as ForgeHost,
9
+ E as MESSAGE_ORIGIN_HOST,
10
+ g as MESSAGE_ORIGIN_SANDBOX,
11
+ p as enableDebug,
12
+ S as useDesignMode,
13
+ m as useElementSelector
14
+ };
@@ -0,0 +1,5 @@
1
+ export { useElementSelector } from "./useElementSelector.js";
2
+ export { useDesignMode } from "./useDesignMode.js";
3
+ export type { DesignModeHook } from "./useDesignMode.js";
4
+ export type { UseElementSelectorResult } from "./useElementSelector.js";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,YAAY,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACxD,YAAY,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAA"}
@@ -0,0 +1,12 @@
1
+ import type { ForgeHost } from "../host/ForgeHost.js";
2
+ import type { ElementSelection } from "../host/types.js";
3
+ export interface DesignModeHook {
4
+ designMode: boolean;
5
+ selectedElement: ElementSelection | null;
6
+ enableDesignMode: (enabled: boolean) => void;
7
+ updateText: (forgeId: string, text: string) => void;
8
+ updateProperty: (forgeId: string, propName: string, value: any) => void;
9
+ deselectElement: () => void;
10
+ }
11
+ export declare function useDesignMode(host: ForgeHost | null): DesignModeHook;
12
+ //# sourceMappingURL=useDesignMode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDesignMode.d.ts","sourceRoot":"","sources":["../../src/react/useDesignMode.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAExD,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,OAAO,CAAA;IACnB,eAAe,EAAE,gBAAgB,GAAG,IAAI,CAAA;IACxC,gBAAgB,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAA;IAC5C,UAAU,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IACnD,cAAc,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,IAAI,CAAA;IACvE,eAAe,EAAE,MAAM,IAAI,CAAA;CAC5B;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,SAAS,GAAG,IAAI,GAAG,cAAc,CAwEpE"}
@@ -0,0 +1,12 @@
1
+ import type { ForgeHost } from "../host/ForgeHost.js";
2
+ import type { ConnectionStatus } from "../host/types.js";
3
+ export interface UseElementSelectorResult {
4
+ selectMode: boolean;
5
+ connectionStatus: ConnectionStatus;
6
+ selectedXPath: string;
7
+ enableSelectMode: (enabled: boolean) => void;
8
+ clearXPath: () => void;
9
+ }
10
+ /** React hook for managing element-picking select mode via ForgeHost. */
11
+ export declare function useElementSelector(host: ForgeHost | null): UseElementSelectorResult;
12
+ //# sourceMappingURL=useElementSelector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useElementSelector.d.ts","sourceRoot":"","sources":["../../src/react/useElementSelector.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAGxD,MAAM,WAAW,wBAAwB;IACvC,UAAU,EAAE,OAAO,CAAA;IACnB,gBAAgB,EAAE,gBAAgB,CAAA;IAClC,aAAa,EAAE,MAAM,CAAA;IACrB,gBAAgB,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAA;IAC5C,UAAU,EAAE,MAAM,IAAI,CAAA;CACvB;AAED,yEAAyE;AACzE,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,SAAS,GAAG,IAAI,GAAG,wBAAwB,CAwEnF"}
package/dist/react.js ADDED
@@ -0,0 +1,5 @@
1
+ import { a as o, u as a } from "./useDesignMode-VIipNUSj.js";
2
+ export {
3
+ o as useDesignMode,
4
+ a as useElementSelector
5
+ };
@@ -0,0 +1,27 @@
1
+ export declare const Z_INDEX: {
2
+ readonly HIT_TEST_OVERLAY: "9998";
3
+ readonly HOVER_OVERLAY: "9999";
4
+ readonly ANNOTATION_DOT: "10000";
5
+ readonly TOOLTIP: "10001";
6
+ };
7
+ export declare const COLORS: {
8
+ readonly SELECT_OVERLAY_BORDER: "#1A58D0";
9
+ readonly SELECT_OVERLAY_BG: "#45ADFF17";
10
+ readonly DESIGN_SELECTION_OUTLINE: "#9333ea";
11
+ readonly ANNOTATION_SINGLE: "#1A58D0";
12
+ readonly ANNOTATION_MULTI: "#1A58D0";
13
+ readonly ANNOTATION_SINGLE_BG: "#45ADFF17";
14
+ readonly ANNOTATION_MULTI_BG: "#45ADFF17";
15
+ readonly DRAG_RECT_BG: "#45ADFF17";
16
+ };
17
+ export declare const BADGE_HEIGHT = 20;
18
+ export declare const BADGE_MIN_WIDTH = 20;
19
+ export declare const TIMEOUTS: {
20
+ readonly CHILD_READY_DELAY: 1000;
21
+ readonly CONNECTION_TIMEOUT: 5000;
22
+ };
23
+ export declare const REACT_ROOT_SELECTORS: string[];
24
+ export declare const MAX_ELEMENTS_SCAN = 200;
25
+ export declare const MAX_COMPONENT_DEPTH = 30;
26
+ export declare const MAX_COMPONENTS = 6;
27
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/shared/constants.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,OAAO;;;;;CAKV,CAAA;AAGV,eAAO,MAAM,MAAM;;;;;;;;;CAST,CAAA;AAGV,eAAO,MAAM,YAAY,KAAK,CAAA;AAC9B,eAAO,MAAM,eAAe,KAAK,CAAA;AAGjC,eAAO,MAAM,QAAQ;;;CAGX,CAAA;AAGV,eAAO,MAAM,oBAAoB,UAAmD,CAAA;AAGpF,eAAO,MAAM,iBAAiB,MAAM,CAAA;AACpC,eAAO,MAAM,mBAAmB,KAAK,CAAA;AACrC,eAAO,MAAM,cAAc,IAAI,CAAA"}
@@ -0,0 +1,4 @@
1
+ export declare function enableDebug(enabled?: boolean): void;
2
+ export declare function debugLog(category: "client" | "host" | "shared" | "annotation", ...args: unknown[]): void;
3
+ export declare function isDebugMode(): boolean;
4
+ //# sourceMappingURL=debug.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../../src/shared/debug.ts"],"names":[],"mappings":"AAEA,wBAAgB,WAAW,CAAC,OAAO,UAAO,GAAG,IAAI,CAEhD;AAED,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM,GAAG,QAAQ,GAAG,YAAY,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAMxG;AAED,wBAAgB,WAAW,IAAI,OAAO,CAErC"}
@@ -0,0 +1,157 @@
1
+ export declare const MESSAGE_ORIGIN_HOST: "host";
2
+ export declare const MESSAGE_ORIGIN_SANDBOX: "sandbox";
3
+ export type MessageOrigin = typeof MESSAGE_ORIGIN_HOST | typeof MESSAGE_ORIGIN_SANDBOX;
4
+ export type HostToClientMessage = {
5
+ type: "ENABLE_SELECT_MODE";
6
+ enabled: boolean;
7
+ origin: typeof MESSAGE_ORIGIN_HOST;
8
+ } | {
9
+ type: "ENABLE_DESIGN_MODE";
10
+ enabled: boolean;
11
+ origin: typeof MESSAGE_ORIGIN_HOST;
12
+ } | {
13
+ type: "ENABLE_ANNOTATION_MODE";
14
+ enabled: boolean;
15
+ origin: typeof MESSAGE_ORIGIN_HOST;
16
+ } | {
17
+ type: "ANNOTATION_KEEP";
18
+ annotationId: string;
19
+ order: number;
20
+ origin: typeof MESSAGE_ORIGIN_HOST;
21
+ } | {
22
+ type: "ANNOTATION_DELETED";
23
+ annotationId: string;
24
+ origin: typeof MESSAGE_ORIGIN_HOST;
25
+ } | {
26
+ type: "ANNOTATION_UPDATE_ORDERS";
27
+ orders: Record<string, number>;
28
+ origin: typeof MESSAGE_ORIGIN_HOST;
29
+ } | {
30
+ type: "UPDATE_TEXT";
31
+ forgeId: string;
32
+ text: string;
33
+ origin: typeof MESSAGE_ORIGIN_HOST;
34
+ } | {
35
+ type: "UPDATE_PROPERTY";
36
+ forgeId: string;
37
+ propName: string;
38
+ value: any;
39
+ origin: typeof MESSAGE_ORIGIN_HOST;
40
+ } | {
41
+ type: "DESELECT_ELEMENT";
42
+ origin: typeof MESSAGE_ORIGIN_HOST;
43
+ } | {
44
+ type: "TOGGLE_MARKERS";
45
+ origin: typeof MESSAGE_ORIGIN_HOST;
46
+ } | {
47
+ type: "RESTORE_ANNOTATIONS";
48
+ annotations: RestoreAnnotationData[];
49
+ origin: typeof MESSAGE_ORIGIN_HOST;
50
+ } | {
51
+ type: "PING";
52
+ origin: typeof MESSAGE_ORIGIN_HOST;
53
+ };
54
+ export interface AnnotationElementInfo {
55
+ elementTag: string;
56
+ xpath: string;
57
+ componentName?: string;
58
+ componentPath?: string;
59
+ forgeId?: string;
60
+ forgeIdIndex?: number;
61
+ sourcePos?: string;
62
+ }
63
+ export interface RestoreAnnotationData {
64
+ id: string;
65
+ dotX: number;
66
+ dotY: number;
67
+ /** Badge position as a ratio (0–1) of the anchor rect. Scales with element resize. */
68
+ anchorOffset?: {
69
+ x: number;
70
+ y: number;
71
+ };
72
+ mode: "single" | "multi";
73
+ order: number;
74
+ elements: AnnotationElementInfo[];
75
+ }
76
+ export interface AnnotationData {
77
+ id: string;
78
+ dotX: number;
79
+ dotY: number;
80
+ /** Badge position as a ratio (0–1) of the anchor rect. Persisted by the parent for restore. */
81
+ anchorOffset?: {
82
+ x: number;
83
+ y: number;
84
+ };
85
+ mode: "single" | "multi";
86
+ /** Per-element info for each selected element */
87
+ elements: AnnotationElementInfo[];
88
+ /** @deprecated Use elements[].xpath instead */
89
+ xpaths: string[];
90
+ elementTag: string;
91
+ componentName?: string;
92
+ componentPath?: string;
93
+ forgeId?: string;
94
+ sourcePos?: string;
95
+ }
96
+ export type ClientToHostMessage = {
97
+ type: "XPATH_REPORT";
98
+ xpath: string;
99
+ origin: typeof MESSAGE_ORIGIN_SANDBOX;
100
+ } | {
101
+ type: "SELECT_MODE_DISABLED";
102
+ origin: typeof MESSAGE_ORIGIN_SANDBOX;
103
+ } | {
104
+ type: "DESIGN_MODE_DISABLED";
105
+ origin: typeof MESSAGE_ORIGIN_SANDBOX;
106
+ } | {
107
+ type: "REGISTER_COMPONENTS";
108
+ components: Record<string, ComponentDefinition>;
109
+ origin: typeof MESSAGE_ORIGIN_SANDBOX;
110
+ } | {
111
+ type: "ELEMENT_SELECTED";
112
+ forgeId: string;
113
+ sourcePos?: string;
114
+ text: string;
115
+ elementType: string;
116
+ xpath: string;
117
+ componentName: string;
118
+ editableProps: PropDefinition[];
119
+ propValues: Record<string, any>;
120
+ origin: typeof MESSAGE_ORIGIN_SANDBOX;
121
+ } | {
122
+ type: "ANNOTATION_CREATED";
123
+ annotation: AnnotationData;
124
+ origin: typeof MESSAGE_ORIGIN_SANDBOX;
125
+ } | {
126
+ type: "ANNOTATION_DOT_CLICKED";
127
+ annotationId: string;
128
+ dotX: number;
129
+ dotY: number;
130
+ origin: typeof MESSAGE_ORIGIN_SANDBOX;
131
+ } | {
132
+ type: "SOURCE_UPDATED";
133
+ forgeId: string;
134
+ source: string;
135
+ filePath: string;
136
+ origin: typeof MESSAGE_ORIGIN_SANDBOX;
137
+ } | {
138
+ type: "CHILD_READY";
139
+ origin: typeof MESSAGE_ORIGIN_SANDBOX;
140
+ };
141
+ export interface PropDefinition {
142
+ name: string;
143
+ type: "text" | "enum" | "boolean" | "number" | "string";
144
+ options?: string[];
145
+ default?: any;
146
+ editable: boolean;
147
+ label?: string;
148
+ }
149
+ export interface ComponentDefinition {
150
+ props: Record<string, PropDefinition>;
151
+ }
152
+ export interface MessageEvent<T = HostToClientMessage | ClientToHostMessage> {
153
+ data: T;
154
+ source?: Window;
155
+ origin?: string;
156
+ }
157
+ //# sourceMappingURL=events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/shared/events.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,mBAAmB,EAAG,MAAe,CAAA;AAClD,eAAO,MAAM,sBAAsB,EAAG,SAAkB,CAAA;AAExD,MAAM,MAAM,aAAa,GAAG,OAAO,mBAAmB,GAAG,OAAO,sBAAsB,CAAA;AAItF,MAAM,MAAM,mBAAmB,GAC3B;IAAE,IAAI,EAAE,oBAAoB,CAAC;IAAC,OAAO,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,OAAO,mBAAmB,CAAA;CAAE,GACpF;IAAE,IAAI,EAAE,oBAAoB,CAAC;IAAC,OAAO,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,OAAO,mBAAmB,CAAA;CAAE,GACpF;IAAE,IAAI,EAAE,wBAAwB,CAAC;IAAC,OAAO,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,OAAO,mBAAmB,CAAA;CAAE,GACxF;IAAE,IAAI,EAAE,iBAAiB,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,OAAO,mBAAmB,CAAA;CAAE,GACpG;IAAE,IAAI,EAAE,oBAAoB,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,OAAO,mBAAmB,CAAA;CAAE,GACxF;IAAE,IAAI,EAAE,0BAA0B,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAAC,MAAM,EAAE,OAAO,mBAAmB,CAAA;CAAE,GACxG;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,OAAO,mBAAmB,C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essageEvent } from "./events.js";
2
+ /** Returns true if a postMessage payload comes from React DevTools and should be ignored. */
3
+ export declare function isDevToolsMessage(data: unknown): boolean;
4
+ export interface Messenger {
5
+ send(message: HostToClientMessage | ClientToHostMessage, targetOrigin?: string): void;
6
+ onMessage(handler: (event: MessageEvent) => void): () => void;
7
+ }
8
+ export declare class WindowMessenger implements Messenger {
9
+ private targetWindow;
10
+ private targetOrigin?;
11
+ constructor(targetWindow: Window, targetOrigin?: string);
12
+ send(message: HostToClientMessage | ClientToHostMessage, targetOrigin?: string): void;
13
+ onMessage(handler: (event: MessageEvent) => void): () => void;
14
+ }
15
+ export declare class ParentMessenger implements Messenger {
16
+ send(message: ClientToHostMessage, targetOrigin?: string): void;
17
+ onMessage(handler: (event: MessageEvent) => void): () => void;
18
+ }
19
+ //# sourceMappingURL=messaging.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messaging.d.ts","sourceRoot":"","sources":["../../src/shared/messaging.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAEzF,6FAA6F;AAC7F,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAMxD;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,CAAC,OAAO,EAAE,mBAAmB,GAAG,mBAAmB,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACrF,SAAS,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,GAAG,MAAM,IAAI,CAAA;CAC9D;AAED,qBAAa,eAAgB,YAAW,SAAS;IAC/C,OAAO,CAAC,YAAY,CAAQ;IAC5B,OAAO,CAAC,YAAY,CAAC,CAAQ;gBAEjB,YAAY,EAAE,MAAM,EAAE,YAAY,SAAM;IAKpD,IAAI,CAAC,OAAO,EAAE,mBAAmB,GAAG,mBAAmB,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI;IAIrF,SAAS,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,GAAG,MAAM,IAAI;CAS9D;AAED,qBAAa,eAAgB,YAAW,SAAS;IAC/C,IAAI,CAAC,OAAO,EAAE,mBAAmB,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI;IAM/D,SAAS,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,GAAG,MAAM,IAAI;CAS9D"}