@supernovaio/prototyping-tooling 0.9.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Matches elements by `data-forge-id`, or falls back to source position.
|
|
4
4
|
* Returns the updated source string, or the original source if no changes were made.
|
|
5
5
|
*/
|
|
6
|
-
export declare function updateSourceAST(source: string, forgeId: string, propName: string, newValue: any, fallbackSourcePos?: string | null): string
|
|
6
|
+
export declare function updateSourceAST(source: string, forgeId: string, propName: string, newValue: any, fallbackSourcePos?: string | null): Promise<string>;
|
|
7
7
|
/**
|
|
8
8
|
* Fetches source code from the dev server's read-source endpoint.
|
|
9
9
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SourceCodeUpdater.d.ts","sourceRoot":"","sources":["../../../src/client/general/SourceCodeUpdater.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SourceCodeUpdater.d.ts","sourceRoot":"","sources":["../../../src/client/general/SourceCodeUpdater.ts"],"names":[],"mappings":"AA2DA;;;;GAIG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,GAAG,EACb,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,GAChC,OAAO,CAAC,MAAM,CAAC,CAuDjB;AAED;;GAEG;AACH,wBAAsB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAW1E;AAED;;GAEG;AACH,wBAAsB,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAYpF"}
|
package/dist/client.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import { b as
|
|
1
|
+
import { b as $, c as X, R as Y, d as G, Z as S, C as f, B as w, e as B, M as C, P as W, i as V, a as j, T as U } from "./constants-BXKWBfHg.js";
|
|
2
2
|
import { d as c } from "./debug-CLzmqn3R.js";
|
|
3
|
-
import { parse as U } from "@babel/parser";
|
|
4
|
-
import x from "@babel/traverse";
|
|
5
|
-
import _ from "@babel/generator";
|
|
6
3
|
class z {
|
|
7
4
|
registry = /* @__PURE__ */ new Map();
|
|
8
5
|
register(e, t) {
|
|
@@ -26,7 +23,7 @@ class z {
|
|
|
26
23
|
return !t && n[e] && (t = this.registry.get(n[e])), t ? Object.entries(t.props).filter(([o, i]) => i.editable).map(([o, i]) => ({ name: o, type: i.type, options: i.options, default: i.default, editable: i.editable, label: i.label })) : [];
|
|
27
24
|
}
|
|
28
25
|
}
|
|
29
|
-
function
|
|
26
|
+
function P(a) {
|
|
30
27
|
if (a.id)
|
|
31
28
|
return `//*[@id="${a.id}"]`;
|
|
32
29
|
const e = [];
|
|
@@ -52,7 +49,7 @@ function q() {
|
|
|
52
49
|
if (typeof document > "u") return !1;
|
|
53
50
|
if (document.body && D(document.body))
|
|
54
51
|
return c("client", "Detected React on document.body"), O = !0, !0;
|
|
55
|
-
for (const e of
|
|
52
|
+
for (const e of Y) {
|
|
56
53
|
const t = document.querySelector(e);
|
|
57
54
|
if (t) {
|
|
58
55
|
if (D(t))
|
|
@@ -71,7 +68,7 @@ function q() {
|
|
|
71
68
|
for (const e of a) {
|
|
72
69
|
if (D(e))
|
|
73
70
|
return c("client", "Detected React on deep scan:", e.tagName), O = !0, !0;
|
|
74
|
-
if (a.length >
|
|
71
|
+
if (a.length > G) break;
|
|
75
72
|
}
|
|
76
73
|
return c("client", "React NOT detected on page"), O = !1, !1;
|
|
77
74
|
}
|
|
@@ -133,7 +130,7 @@ function ee(a) {
|
|
|
133
130
|
function te(a) {
|
|
134
131
|
return !(K.has(a) || J.some((e) => e.test(a)));
|
|
135
132
|
}
|
|
136
|
-
function ne(a, e =
|
|
133
|
+
function ne(a, e = $, t = X) {
|
|
137
134
|
if (!q())
|
|
138
135
|
return c("client", "isReactPage() = false"), { path: null, components: [] };
|
|
139
136
|
const n = [];
|
|
@@ -149,16 +146,16 @@ function ne(a, e = F, t = $) {
|
|
|
149
146
|
return n.length === 0 ? { path: null, components: [] } : { path: n.slice().reverse().map((i) => `<${i}>`).join(" "), components: n };
|
|
150
147
|
}
|
|
151
148
|
let I = null, E = null;
|
|
152
|
-
function
|
|
149
|
+
function M(a, e, t, n = "solid") {
|
|
153
150
|
const o = document.createElement("div");
|
|
154
151
|
return Object.assign(o.style, { position: "fixed", left: `${a.left}px`, top: `${a.top}px`, width: `${a.width}px`, height: `${a.height}px`, border: `1px ${n} ${e}`, backgroundColor: t, pointerEvents: "none", zIndex: S.HOVER_OVERLAY, borderRadius: "2px" }), o;
|
|
155
152
|
}
|
|
156
153
|
function oe(a) {
|
|
157
|
-
|
|
154
|
+
N();
|
|
158
155
|
const e = a.getBoundingClientRect();
|
|
159
|
-
I =
|
|
156
|
+
I = M(e, f.SELECT_OVERLAY_BORDER, f.SELECT_OVERLAY_BG), I.className = "forge-overlay", document.body.appendChild(I);
|
|
160
157
|
}
|
|
161
|
-
function
|
|
158
|
+
function N() {
|
|
162
159
|
I && (I.remove(), I = null);
|
|
163
160
|
}
|
|
164
161
|
function ie() {
|
|
@@ -245,7 +242,7 @@ class R {
|
|
|
245
242
|
showHoverOverlay(e, t, n) {
|
|
246
243
|
this.hoverOverlay && (this.hoverOverlay.remove(), this.hoverOverlay = null);
|
|
247
244
|
const o = e.getBoundingClientRect(), i = t === f.ANNOTATION_MULTI ? f.ANNOTATION_MULTI_BG : f.ANNOTATION_SINGLE_BG;
|
|
248
|
-
this.hoverOverlay =
|
|
245
|
+
this.hoverOverlay = M(o, t, i, "solid"), this.hoverOverlay.style.transition = "all 0.05s ease", this.hoverOverlay.className = "forge-annotation-hover", document.body.appendChild(this.hoverOverlay), this.showComponentTooltip(n || e, o);
|
|
249
246
|
}
|
|
250
247
|
removeHoverOverlay() {
|
|
251
248
|
this.hoverOverlay && (this.hoverOverlay.remove(), this.hoverOverlay = null), this.removeComponentTooltip();
|
|
@@ -280,12 +277,12 @@ class R {
|
|
|
280
277
|
if (i) {
|
|
281
278
|
const s = i.getBoundingClientRect();
|
|
282
279
|
n.push(s);
|
|
283
|
-
const r =
|
|
280
|
+
const r = M(s, f.ANNOTATION_SINGLE, f.ANNOTATION_SINGLE_BG, "solid");
|
|
284
281
|
r.className = "forge-annotation-highlight", document.body.appendChild(r), this.annotationHighlights.push(r);
|
|
285
282
|
}
|
|
286
283
|
}
|
|
287
284
|
if (t && n.length > 1) {
|
|
288
|
-
const o = Math.min(...n.map((h) => h.left)), i = Math.min(...n.map((h) => h.top)), s = Math.max(...n.map((h) => h.right)), r = Math.max(...n.map((h) => h.bottom)), l = new DOMRect(o, i, s - o, r - i), u =
|
|
285
|
+
const o = Math.min(...n.map((h) => h.left)), i = Math.min(...n.map((h) => h.top)), s = Math.max(...n.map((h) => h.right)), r = Math.max(...n.map((h) => h.bottom)), l = new DOMRect(o, i, s - o, r - i), u = M(l, f.ANNOTATION_SINGLE, "transparent", "dashed");
|
|
289
286
|
u.className = "forge-annotation-bounding-rect", document.body.appendChild(u), this.annotationHighlights.push(u);
|
|
290
287
|
}
|
|
291
288
|
}
|
|
@@ -343,7 +340,7 @@ class R {
|
|
|
343
340
|
showDragHighlights(e) {
|
|
344
341
|
this.clearDragHighlights();
|
|
345
342
|
for (const t of e) {
|
|
346
|
-
const n = t.getBoundingClientRect(), o =
|
|
343
|
+
const n = t.getBoundingClientRect(), o = M(n, f.ANNOTATION_MULTI, f.ANNOTATION_MULTI_BG, "solid");
|
|
347
344
|
o.className = "forge-annotation-drag-highlight", document.body.appendChild(o), this.dragHighlights.push(o);
|
|
348
345
|
}
|
|
349
346
|
}
|
|
@@ -352,12 +349,12 @@ class R {
|
|
|
352
349
|
this.dragHighlights = [];
|
|
353
350
|
}
|
|
354
351
|
createDot(e, t, n, o, i, s = []) {
|
|
355
|
-
const r = this.getAnchorRect(s), l = e - 2, u = t -
|
|
352
|
+
const r = this.getAnchorRect(s), l = e - 2, u = t - w - 2, h = r && r.width > 0 && r.height > 0 ? { rx: (l - r.left) / r.width, ry: (u - r.top) / r.height } : { rx: 0, ry: 0 };
|
|
356
353
|
this.createDotAtPosition(l, u, n, o, i, s, h);
|
|
357
354
|
}
|
|
358
355
|
createDotAtPosition(e, t, n, o, i, s, r) {
|
|
359
356
|
const l = document.createElement("div");
|
|
360
|
-
Object.assign(l.style, { position: "fixed", left: `${e}px`, top: `${t}px`, minWidth: `${
|
|
357
|
+
Object.assign(l.style, { position: "fixed", left: `${e}px`, top: `${t}px`, minWidth: `${B}px`, height: `${w}px`, borderRadius: "50% 50% 50% 0", backgroundColor: "#FFFFFF", border: "1px solid #1A58D0", cursor: "pointer", zIndex: S.ANNOTATION_DOT, transition: "transform 0.15s ease", display: this.markersVisible ? "flex" : "none", alignItems: "center", justifyContent: "center", padding: "0 4px", fontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif", fontSize: "11px", fontWeight: "700", color: "#1A58D0", lineHeight: "1", userSelect: "none" }), l.textContent = String(i), l.className = "forge-annotation-dot", l.dataset.annotationId = o, l.addEventListener("mouseenter", () => {
|
|
361
358
|
l.style.transform = "scale(1.05)", this.removeHoverOverlay(), this.hoverSuppressed = !0;
|
|
362
359
|
}), l.addEventListener("mouseleave", () => {
|
|
363
360
|
l.style.transform = "scale(1)";
|
|
@@ -501,11 +498,11 @@ class R {
|
|
|
501
498
|
const v = g.getAttribute("data-forge-id") || void 0;
|
|
502
499
|
let b;
|
|
503
500
|
if (v) {
|
|
504
|
-
const
|
|
505
|
-
|
|
501
|
+
const H = document.querySelectorAll(`[data-forge-id="${v}"]`);
|
|
502
|
+
H.length > 1 && (b = Array.from(H).indexOf(g));
|
|
506
503
|
}
|
|
507
|
-
return { elementTag: g.tagName.toLowerCase(), xpath:
|
|
508
|
-
}), r = s.map((g) => ({ xpath: g.xpath, forgeId: g.forgeId, forgeIdIndex: g.forgeIdIndex })), l = this.getAnchorRect(r), u = n - 2, h = o -
|
|
504
|
+
return { elementTag: g.tagName.toLowerCase(), xpath: P(g), componentName: g.getAttribute("data-component") || void 0, componentPath: this.getComponentPath(g) || void 0, forgeId: v, forgeIdIndex: b, sourcePos: g.getAttribute("data-source-pos") || void 0 };
|
|
505
|
+
}), r = s.map((g) => ({ xpath: g.xpath, forgeId: g.forgeId, forgeIdIndex: g.forgeIdIndex })), l = this.getAnchorRect(r), u = n - 2, h = o - w - 2, m = l && l.width > 0 && l.height > 0 ? { x: (u - l.left) / l.width, y: (h - l.top) / l.height } : { x: 0, y: 0 };
|
|
509
506
|
this.pendingAnnotations.set(i, { dotX: n, dotY: o, mode: t, locators: r }), this.clearDragHighlights(), this.highlightLocators(r, t === "multi");
|
|
510
507
|
const p = s[0], y = { id: i, dotX: n, dotY: o, anchorOffset: m, mode: t, elements: s, xpaths: s.map((g) => g.xpath), elementTag: p.elementTag, componentName: p.componentName, componentPath: p.componentPath, forgeId: p.forgeId, sourcePos: p.sourcePos };
|
|
511
508
|
c("annotation", "Annotation created (pending):", y), this.messenger.send({ type: "ANNOTATION_CREATED", annotation: y, origin: C });
|
|
@@ -535,7 +532,7 @@ class le {
|
|
|
535
532
|
this.hitTestOverlay && (this.hitTestOverlay.removeEventListener("mousemove", this.handleMouseOver), this.hitTestOverlay.removeEventListener("mouseout", this.handleMouseOut), this.hitTestOverlay.removeEventListener("click", this.handleClick)), document.removeEventListener("scroll", this.handleScroll, !0), se(), this.hitTestOverlay = null;
|
|
536
533
|
}
|
|
537
534
|
clearHover() {
|
|
538
|
-
this.hoveredElement = null,
|
|
535
|
+
this.hoveredElement = null, N();
|
|
539
536
|
}
|
|
540
537
|
findTopmostElementWithSameId(e) {
|
|
541
538
|
const t = e.getAttribute("data-forge-id");
|
|
@@ -549,7 +546,7 @@ class le {
|
|
|
549
546
|
return o;
|
|
550
547
|
}
|
|
551
548
|
handleSelectModeClick(e) {
|
|
552
|
-
const t =
|
|
549
|
+
const t = P(e);
|
|
553
550
|
c("client", "Element clicked, XPath:", t), this.messenger.send({ type: "XPATH_REPORT", xpath: t, origin: C }), this.messenger.send({ type: "SELECT_MODE_DISABLED", origin: C });
|
|
554
551
|
}
|
|
555
552
|
handleMouseOver = (e) => {
|
|
@@ -565,54 +562,64 @@ class le {
|
|
|
565
562
|
};
|
|
566
563
|
handleMouseOut = (e) => {
|
|
567
564
|
if (!this.callbacks.getSelectMode() && !this.callbacks.getDesignMode()) return;
|
|
568
|
-
e.target === this.hoveredElement && (this.hoveredElement = null,
|
|
565
|
+
e.target === this.hoveredElement && (this.hoveredElement = null, N());
|
|
569
566
|
};
|
|
570
567
|
handleClick = (e) => {
|
|
571
568
|
if (!this.callbacks.getSelectMode() && !this.callbacks.getDesignMode()) return;
|
|
572
569
|
e.preventDefault(), e.stopPropagation(), this.hitTestOverlay && (this.hitTestOverlay.style.pointerEvents = "none");
|
|
573
570
|
const t = document.elementFromPoint(e.clientX, e.clientY);
|
|
574
|
-
this.hitTestOverlay && (this.hitTestOverlay.style.pointerEvents = "auto"), t && t !== document.body && t !== document.documentElement && (this.callbacks.getSelectMode() && this.callbacks.onSelectClick(t), this.callbacks.getDesignMode() && (
|
|
571
|
+
this.hitTestOverlay && (this.hitTestOverlay.style.pointerEvents = "auto"), t && t !== document.body && t !== document.documentElement && (this.callbacks.getSelectMode() && this.callbacks.onSelectClick(t), this.callbacks.getDesignMode() && (N(), this.hoveredElement = null, this.callbacks.onDesignClick(t)));
|
|
575
572
|
};
|
|
576
573
|
handleScroll = () => {
|
|
577
|
-
(this.callbacks.getSelectMode() || this.callbacks.getDesignMode()) && (this.hoveredElement = null,
|
|
574
|
+
(this.callbacks.getSelectMode() || this.callbacks.getDesignMode()) && (this.hoveredElement = null, N());
|
|
578
575
|
};
|
|
579
576
|
}
|
|
580
|
-
|
|
581
|
-
function
|
|
577
|
+
let L = null, x = null, _ = null;
|
|
578
|
+
async function ce() {
|
|
579
|
+
if (L && x && _) return;
|
|
580
|
+
const [a, e, t] = await Promise.all([import("@babel/parser"), import("@babel/traverse"), import("@babel/generator")]);
|
|
581
|
+
L = a.parse;
|
|
582
|
+
const n = e.default;
|
|
583
|
+
x = typeof n == "function" ? n : n.default;
|
|
584
|
+
const o = t.default;
|
|
585
|
+
_ = typeof o == "function" ? o : o.default;
|
|
586
|
+
}
|
|
587
|
+
function k(a) {
|
|
582
588
|
return typeof a == "boolean" ? { type: "JSXExpressionContainer", expression: { type: "BooleanLiteral", value: a, loc: null }, loc: null } : typeof a == "number" ? { type: "JSXExpressionContainer", expression: { type: "NumericLiteral", value: a, loc: null }, loc: null } : { type: "StringLiteral", value: String(a), loc: null };
|
|
583
589
|
}
|
|
584
|
-
function
|
|
590
|
+
function F(a, e, t) {
|
|
585
591
|
const n = a.node.attributes.find((o) => o.type === "JSXAttribute" && o.name.type === "JSXIdentifier" && o.name.name === e);
|
|
586
|
-
return n && n.type === "JSXAttribute" ? (n.value =
|
|
592
|
+
return n && n.type === "JSXAttribute" ? (n.value = k(t), !0) : (a.node.attributes.push({ type: "JSXAttribute", name: { type: "JSXIdentifier", name: e }, value: k(t), loc: null }), !0);
|
|
587
593
|
}
|
|
588
|
-
function
|
|
594
|
+
async function he(a, e, t, n, o) {
|
|
589
595
|
try {
|
|
590
|
-
|
|
596
|
+
if (await ce(), !L || !x || !_) return a;
|
|
597
|
+
const i = L(a, { sourceType: "module", plugins: ["jsx", "typescript"] });
|
|
591
598
|
let s = !1;
|
|
592
599
|
const r = /* @__PURE__ */ new Map();
|
|
593
|
-
if (
|
|
600
|
+
if (x(i, { JSXOpeningElement(l) {
|
|
594
601
|
if (l.node.name.type !== "JSXIdentifier") return;
|
|
595
602
|
const u = l.node.loc;
|
|
596
603
|
if (!u) return;
|
|
597
604
|
const h = `${u.start.line}:${u.start.column}`;
|
|
598
605
|
r.set(h, l);
|
|
599
606
|
const m = l.node.attributes.find((p) => p.type === "JSXAttribute" && p.name.type === "JSXIdentifier" && p.name.name === "data-forge-id" && p.value?.type === "StringLiteral");
|
|
600
|
-
m && m.type === "JSXAttribute" && m.value.value === e && (s =
|
|
607
|
+
m && m.type === "JSXAttribute" && m.value.value === e && (s = F(l, t, n));
|
|
601
608
|
} }), !s && o) {
|
|
602
609
|
const l = o.split(":");
|
|
603
610
|
if (l.length >= 5) {
|
|
604
611
|
const u = `${l[l.length - 4]}:${l[l.length - 3]}`, h = r.get(u);
|
|
605
|
-
h && (s =
|
|
612
|
+
h && (s = F(h, t, n));
|
|
606
613
|
}
|
|
607
614
|
}
|
|
608
615
|
if (s)
|
|
609
|
-
return
|
|
616
|
+
return _(i, {}, a).code;
|
|
610
617
|
} catch (i) {
|
|
611
618
|
c("client", "Failed to parse/update AST:", i);
|
|
612
619
|
}
|
|
613
620
|
return a;
|
|
614
621
|
}
|
|
615
|
-
async function
|
|
622
|
+
async function de(a) {
|
|
616
623
|
try {
|
|
617
624
|
const e = await fetch(`/__forge-read-source?path=${a}`);
|
|
618
625
|
if (e.ok)
|
|
@@ -623,14 +630,14 @@ async function ue(a) {
|
|
|
623
630
|
}
|
|
624
631
|
return null;
|
|
625
632
|
}
|
|
626
|
-
async function
|
|
633
|
+
async function ue(a, e) {
|
|
627
634
|
try {
|
|
628
635
|
return await fetch("/__forge-update-source", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ filePath: a, source: e }) }), !0;
|
|
629
636
|
} catch (t) {
|
|
630
637
|
return c("client", "Failed to write source:", t), !1;
|
|
631
638
|
}
|
|
632
639
|
}
|
|
633
|
-
class
|
|
640
|
+
class ge {
|
|
634
641
|
messenger;
|
|
635
642
|
componentRegistry;
|
|
636
643
|
selectController;
|
|
@@ -653,7 +660,7 @@ class me {
|
|
|
653
660
|
}
|
|
654
661
|
const n = this.selectController.findTopmostElementWithSameId(e), o = n.getAttribute("data-component"), i = n.getAttribute("data-source-pos"), s = o || n.tagName.toLowerCase();
|
|
655
662
|
this.clearSelection(), this.selectedElement = n, this.applyHighlight(n);
|
|
656
|
-
const r = n.textContent?.trim() || "", l = n.tagName.toLowerCase(), u =
|
|
663
|
+
const r = n.textContent?.trim() || "", l = n.tagName.toLowerCase(), u = P(n), h = this.componentRegistry.getEditableProps(s), m = this.extractPropValues(n, h);
|
|
657
664
|
c("client", "Element selected in design mode:", { forgeId: t, sourcePos: i, text: r, type: l, componentName: s, editableProps: h, propValues: m }), this.messenger.send({ type: "ELEMENT_SELECTED", forgeId: t, sourcePos: i || void 0, text: r, elementType: l, xpath: u, componentName: s, editableProps: h, propValues: m, origin: C });
|
|
658
665
|
}
|
|
659
666
|
updateText(e, t) {
|
|
@@ -677,11 +684,11 @@ class me {
|
|
|
677
684
|
}
|
|
678
685
|
const r = s.slice(0, -4).join(":");
|
|
679
686
|
c("client", `Updating property ${t} = ${n} for ${e} in ${r}`), this.sourceCache.delete(r);
|
|
680
|
-
const l = await
|
|
687
|
+
const l = await de(r);
|
|
681
688
|
if (!l) return;
|
|
682
689
|
this.sourceCache.set(r, l);
|
|
683
|
-
const u = this.selectedElement?.getAttribute("data-source-pos") ?? null, h =
|
|
684
|
-
h !== l ? (this.sourceCache.set(r, h), c("client", `Updated source for ${r}`), await
|
|
690
|
+
const u = this.selectedElement?.getAttribute("data-source-pos") ?? null, h = await he(l, e, t, n, u);
|
|
691
|
+
h !== l ? (this.sourceCache.set(r, h), c("client", `Updated source for ${r}`), await ue(r, h) && (c("client", `Source written to disk and HMR triggered for ${r}`), this.messenger.send({ type: "SOURCE_UPDATED", forgeId: e, source: h, filePath: r, origin: C }))) : c("client", `No source changes detected for ${r}`);
|
|
685
692
|
}
|
|
686
693
|
applyHighlight(e) {
|
|
687
694
|
e.style.outline = `3px solid ${f.DESIGN_SELECTION_OUTLINE}`, e.style.outlineOffset = "2px";
|
|
@@ -723,7 +730,7 @@ class A {
|
|
|
723
730
|
designController;
|
|
724
731
|
onError;
|
|
725
732
|
constructor(e) {
|
|
726
|
-
this.onError = e?.onError, c("client", "ForgeClient initialized"), this.messenger = new
|
|
733
|
+
this.onError = e?.onError, c("client", "ForgeClient initialized"), this.messenger = new W(), this.componentRegistry = new z(), this.selectController = new le(this.messenger, { getSelectMode: () => this.selectMode, getDesignMode: () => this.designMode, getHoverDisabled: () => this.hoverDisabled, getSelectedDesignElement: () => this.designController.getSelectedElement(), onSelectClick: (t) => this.handleSelectClick(t), onDesignClick: (t) => this.handleDesignClick(t) }), this.designController = new ge(this.messenger, this.componentRegistry, this.selectController), this.setupMessageListener(), this.sendReady(), this.setupForgeIdPropagation(), window.__forgeClient = this;
|
|
727
734
|
}
|
|
728
735
|
static getInstance(e) {
|
|
729
736
|
return A.instance || (A.instance = new A(e)), A.instance;
|
|
@@ -733,9 +740,9 @@ class A {
|
|
|
733
740
|
}
|
|
734
741
|
setupMessageListener() {
|
|
735
742
|
c("client", "Setting up message listener..."), this.messenger.onMessage((e) => {
|
|
736
|
-
if (
|
|
743
|
+
if (V(e.data) || !e.data || typeof e.data != "object" || !("origin" in e.data)) return;
|
|
737
744
|
const t = e.data;
|
|
738
|
-
if (t.origin ===
|
|
745
|
+
if (t.origin === j) {
|
|
739
746
|
c("client", "Received message from host:", t);
|
|
740
747
|
try {
|
|
741
748
|
switch (t.type) {
|
|
@@ -800,7 +807,7 @@ class A {
|
|
|
800
807
|
sendReady() {
|
|
801
808
|
c("client", "Scheduling CHILD_READY message..."), setTimeout(() => {
|
|
802
809
|
c("client", "Sending CHILD_READY message to parent"), this.messenger.send({ type: "CHILD_READY", origin: C });
|
|
803
|
-
},
|
|
810
|
+
}, U.CHILD_READY_DELAY);
|
|
804
811
|
}
|
|
805
812
|
setupForgeIdPropagation() {
|
|
806
813
|
const e = () => {
|
|
@@ -832,5 +839,5 @@ class A {
|
|
|
832
839
|
A.getInstance();
|
|
833
840
|
export {
|
|
834
841
|
A as ForgeClient,
|
|
835
|
-
|
|
842
|
+
W as ParentMessenger
|
|
836
843
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@supernovaio/prototyping-tooling",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"description": "Prototyping Tooling — iframe communication bridge for design-to-code workflows",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -53,17 +53,27 @@
|
|
|
53
53
|
"vite": "^7.1.12"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"react": "^18.0.0 || ^19.0.0"
|
|
56
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
57
|
+
"@babel/generator": "^7.0.0",
|
|
58
|
+
"@babel/parser": "^7.0.0",
|
|
59
|
+
"@babel/traverse": "^7.0.0",
|
|
60
|
+
"@babel/types": "^7.0.0"
|
|
57
61
|
},
|
|
58
62
|
"peerDependenciesMeta": {
|
|
59
63
|
"react": {
|
|
60
64
|
"optional": true
|
|
65
|
+
},
|
|
66
|
+
"@babel/generator": {
|
|
67
|
+
"optional": true
|
|
68
|
+
},
|
|
69
|
+
"@babel/parser": {
|
|
70
|
+
"optional": true
|
|
71
|
+
},
|
|
72
|
+
"@babel/traverse": {
|
|
73
|
+
"optional": true
|
|
74
|
+
},
|
|
75
|
+
"@babel/types": {
|
|
76
|
+
"optional": true
|
|
61
77
|
}
|
|
62
|
-
},
|
|
63
|
-
"dependencies": {
|
|
64
|
-
"@babel/generator": "^7.28.5",
|
|
65
|
-
"@babel/parser": "^7.28.5",
|
|
66
|
-
"@babel/traverse": "^7.28.5",
|
|
67
|
-
"@babel/types": "^7.28.5"
|
|
68
78
|
}
|
|
69
79
|
}
|