@supernovaio/prototyping-tooling 0.9.7-alpha.1 → 0.9.7-alpha.2
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/dist/build/index.js +30 -28
- package/dist/client/annotation/AnnotationOverlay.d.ts.map +1 -1
- package/dist/client/general/ForgeClient.d.ts +4 -0
- package/dist/client/general/ForgeClient.d.ts.map +1 -1
- package/dist/client/select-mode/SelectModeController.d.ts +0 -6
- package/dist/client/select-mode/SelectModeController.d.ts.map +1 -1
- package/dist/client.js +96 -112
- package/dist/debug-BuKzUOMn.js +13 -0
- package/dist/host.js +1 -1
- package/dist/index.js +2 -2
- package/dist/react.js +1 -1
- package/dist/{useDesignMode-VIipNUSj.js → useDesignMode--DcwfmhZ.js} +1 -1
- package/package.json +1 -1
- package/dist/debug-CLzmqn3R.js +0 -11
package/dist/build/index.js
CHANGED
|
@@ -5,33 +5,33 @@ import { relative as F } from "node:path";
|
|
|
5
5
|
const E = typeof y == "function" ? y : y.default, M = typeof S == "function" ? S : S.default;
|
|
6
6
|
function T(d) {
|
|
7
7
|
let r = 0;
|
|
8
|
-
for (let
|
|
9
|
-
const s = d.charCodeAt(
|
|
8
|
+
for (let f = 0; f < d.length; f++) {
|
|
9
|
+
const s = d.charCodeAt(f);
|
|
10
10
|
r = (r << 5) - r + s, r = r & r;
|
|
11
11
|
}
|
|
12
12
|
return Math.abs(r).toString(36).substring(0, 8);
|
|
13
13
|
}
|
|
14
|
-
function
|
|
15
|
-
const { prefix: r = "forge" } = d,
|
|
16
|
-
const
|
|
17
|
-
return `${r}-${
|
|
14
|
+
function k(d = {}) {
|
|
15
|
+
const { prefix: r = "forge" } = d, f = (s, i, u) => {
|
|
16
|
+
const o = T(`${s}:${i}:${u}`);
|
|
17
|
+
return `${r}-${o}-${i}-${u}`;
|
|
18
18
|
};
|
|
19
19
|
return { name: "forge-id-plugin", enforce: "pre", transform(s, i) {
|
|
20
20
|
if (!i.match(/\.(tsx?|jsx?)$/) || i.includes("node_modules"))
|
|
21
21
|
return null;
|
|
22
22
|
const u = F(process.cwd(), i).replace(/\\/g, "/");
|
|
23
23
|
try {
|
|
24
|
-
let
|
|
24
|
+
let o = function(e) {
|
|
25
25
|
const n = e.parent;
|
|
26
26
|
if (n.type === "VariableDeclarator" && n.id.type === "Identifier" && /^[A-Z]/.test(n.id.name))
|
|
27
27
|
return !0;
|
|
28
28
|
if (n.type === "CallExpression") {
|
|
29
29
|
const l = e.parentPath;
|
|
30
30
|
if (l) {
|
|
31
|
-
const
|
|
32
|
-
if (
|
|
31
|
+
const c = l.parent;
|
|
32
|
+
if (c.type === "VariableDeclarator" && c.id.type === "Identifier" && /^[A-Z]/.test(c.id.name) || c.type === "ExportDefaultDeclaration")
|
|
33
33
|
return !0;
|
|
34
|
-
if (
|
|
34
|
+
if (c.type === "CallExpression") {
|
|
35
35
|
const p = l.parentPath;
|
|
36
36
|
if (p) {
|
|
37
37
|
const t = p.parent;
|
|
@@ -43,54 +43,56 @@ function B(d = {}) {
|
|
|
43
43
|
}
|
|
44
44
|
return !1;
|
|
45
45
|
};
|
|
46
|
-
const x = P(s, { sourceType: "module", plugins: ["jsx", "typescript"] }),
|
|
47
|
-
let b = !1,
|
|
46
|
+
const x = P(s, { sourceType: "module", plugins: ["jsx", "typescript"] }), C = /* @__PURE__ */ new Set();
|
|
47
|
+
let b = !1, a = 0;
|
|
48
48
|
if (E(x, { FunctionDeclaration: { enter(e) {
|
|
49
|
-
e.node.id && /^[A-Z]/.test(e.node.id.name) &&
|
|
49
|
+
e.node.id && /^[A-Z]/.test(e.node.id.name) && a++;
|
|
50
50
|
}, exit(e) {
|
|
51
|
-
e.node.id && /^[A-Z]/.test(e.node.id.name) &&
|
|
51
|
+
e.node.id && /^[A-Z]/.test(e.node.id.name) && a--;
|
|
52
52
|
} }, ArrowFunctionExpression: { enter(e) {
|
|
53
|
-
|
|
53
|
+
o(e) && a++;
|
|
54
54
|
}, exit(e) {
|
|
55
|
-
|
|
55
|
+
o(e) && a--;
|
|
56
56
|
} }, FunctionExpression: { enter(e) {
|
|
57
|
-
|
|
57
|
+
o(e) && a++;
|
|
58
58
|
}, exit(e) {
|
|
59
|
-
|
|
59
|
+
o(e) && a--;
|
|
60
60
|
} }, JSXOpeningElement(e) {
|
|
61
61
|
if (e.node.name.type === "JSXIdentifier") {
|
|
62
62
|
const n = e.node.name.name, l = /^[A-Z]/.test(n);
|
|
63
63
|
if (n === "Fragment" || n === "React.Fragment" || (/* @__PURE__ */ new Set(["path", "circle", "rect", "line", "polyline", "polygon", "ellipse", "g", "defs", "clipPath", "mask", "use", "text", "tspan", "textPath", "image", "pattern", "linearGradient", "radialGradient", "stop", "filter", "feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feFlood", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "feSpecularLighting", "feTile", "feTurbulence", "marker", "symbol", "foreignObject", "desc", "title", "metadata"])).has(n))
|
|
64
64
|
return;
|
|
65
|
-
if (l &&
|
|
65
|
+
if (l && a > 0) {
|
|
66
66
|
const t = e.scope.getBinding(n);
|
|
67
|
-
if (t && t.scope.path.type !== "Program")
|
|
67
|
+
if (t && t.scope.path.type !== "Program") {
|
|
68
|
+
console.log(`[Plugin] Skipping ${n} - locally-scoped dynamic component inside definition`);
|
|
68
69
|
return;
|
|
70
|
+
}
|
|
69
71
|
}
|
|
70
72
|
if (!e.node.attributes.some((t) => t.type === "JSXAttribute" && t.name.type === "JSXIdentifier" && t.name.name === "data-forge-id")) {
|
|
71
73
|
const t = e.node.loc?.start;
|
|
72
74
|
if (!t) return;
|
|
73
75
|
const I = e.parent, m = I.type === "JSXElement" ? I.loc?.end : e.node.loc?.end;
|
|
74
76
|
if (!m) return;
|
|
75
|
-
const A =
|
|
76
|
-
if (
|
|
77
|
+
const A = f(i, t.line, t.column), v = { type: "JSXAttribute", name: { type: "JSXIdentifier", name: "data-forge-id" }, value: { type: "StringLiteral", value: A }, loc: e.node.loc }, $ = { type: "JSXAttribute", name: { type: "JSXIdentifier", name: "data-component" }, value: { type: "StringLiteral", value: n }, loc: e.node.loc }, h = { type: "JSXAttribute", name: { type: "JSXIdentifier", name: "data-source-pos" }, value: { type: "StringLiteral", value: `${u}:${t.line}:${t.column}:${m.line}:${m.column}` }, loc: e.node.loc }, J = !l && a > 0, X = e.node.attributes.some((g) => g.type === "JSXSpreadAttribute");
|
|
78
|
+
if (J && X) {
|
|
77
79
|
const g = e.node.attributes.findIndex((D) => D.type === "JSXSpreadAttribute");
|
|
78
|
-
e.node.attributes.splice(g, 0, v, h
|
|
80
|
+
e.node.attributes.splice(g, 0, v, $, h);
|
|
79
81
|
} else
|
|
80
|
-
e.node.attributes.push(v, h
|
|
81
|
-
|
|
82
|
+
e.node.attributes.push(v, $, h);
|
|
83
|
+
C.add(A), b = !0;
|
|
82
84
|
}
|
|
83
85
|
}
|
|
84
86
|
} }), b) {
|
|
85
87
|
const e = M(x, {}, s);
|
|
86
88
|
return { code: e.code, map: e.map };
|
|
87
89
|
}
|
|
88
|
-
} catch {
|
|
89
|
-
return null;
|
|
90
|
+
} catch (o) {
|
|
91
|
+
return o instanceof Error && console.warn(`Failed to parse ${i} for forge-id injection: ${o.message}`), null;
|
|
90
92
|
}
|
|
91
93
|
return null;
|
|
92
94
|
} };
|
|
93
95
|
}
|
|
94
96
|
export {
|
|
95
|
-
|
|
97
|
+
k as supernovaDesignPlugin
|
|
96
98
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnnotationOverlay.d.ts","sourceRoot":"","sources":["../../../src/client/annotation/AnnotationOverlay.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAEhE,OAAO,KAAK,EAAkB,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAA;AA6B1G;;;GAGG;AACH,qBAAa,iBAA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O,CAAC,YAAY;IAUpB,OAAO,CAAC,eAAe;CASxB"}
|
|
@@ -8,6 +8,7 @@ import type { ForgeClientOptions } from "./types.js";
|
|
|
8
8
|
* and AnnotationOverlay based on messages from the host.
|
|
9
9
|
*/
|
|
10
10
|
export declare class ForgeClient {
|
|
11
|
+
private static readonly ANNOTATION_CURSOR_LOCK_CLASS;
|
|
11
12
|
private static instance;
|
|
12
13
|
private messenger;
|
|
13
14
|
private readyIntervalId;
|
|
@@ -19,6 +20,7 @@ export declare class ForgeClient {
|
|
|
19
20
|
private annotationOverlay;
|
|
20
21
|
private selectController;
|
|
21
22
|
private designController;
|
|
23
|
+
private annotationCursorLockStyleEl;
|
|
22
24
|
private onError?;
|
|
23
25
|
private constructor();
|
|
24
26
|
/** Returns the singleton ForgeClient instance, creating it if necessary. */
|
|
@@ -31,6 +33,8 @@ export declare class ForgeClient {
|
|
|
31
33
|
private setSelectMode;
|
|
32
34
|
private setDesignMode;
|
|
33
35
|
private setAnnotationMode;
|
|
36
|
+
private enableAnnotationCursorLock;
|
|
37
|
+
private disableAnnotationCursorLock;
|
|
34
38
|
private handleSelectClick;
|
|
35
39
|
private handleDesignClick;
|
|
36
40
|
private sendReady;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ForgeClient.d.ts","sourceRoot":"","sources":["../../../src/client/general/ForgeClient.ts"],"names":[],"mappings":"AACA,OAAO,EAA+C,KAAK,qBAAqB,EAAE,MAAM,wBAAwB,CAAA;AAOhH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAEpD;;;;;;GAMG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAA2B;IAClD,OAAO,CAAC,SAAS,CAAiB;IAClC,OAAO,CAAC,eAAe,CAAsB;IAC7C,OAAO,CAAC,iBAAiB,CAAQ;IACjC,OAAO,CAAC,UAAU,CAAQ;IAC1B,OAAO,CAAC,UAAU,CAAQ;IAC1B,OAAO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O;IA4BP,4EAA4E;IAC5E,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,kBAAkB,GAAG,WAAW;IAO7D,6FAA6F;IAC7F,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAI5C,2FAA2F;IAC3F,kBAAkB,CAAC,WAAW,EAAE,qBAAqB,EAAE,GAAG,IAAI;IAS9D,OAAO,CAAC,oBAAoB;IA2F5B,OAAO,CAAC,aAAa;IAarB,OAAO,CAAC,aAAa;IAerB,OAAO,CAAC,iBAAiB;IAezB,OAAO,CAAC,0BAA0B;IAgBlC,OAAO,CAAC,2BAA2B;IASnC,OAAO,CAAC,iBAAiB;IAKzB,OAAO,CAAC,iBAAiB;IAOzB,OAAO,CAAC,SAAS;IAwBjB,OAAO,CAAC,uBAAuB;IAkB/B,OAAO,CAAC,mBAAmB;IAO3B,OAAO,CAAC,yBAAyB;CAkBlC"}
|
|
@@ -7,15 +7,11 @@ import type { SelectModeCallbacks } from "../general/types.js";
|
|
|
7
7
|
export declare class SelectModeController {
|
|
8
8
|
private messenger;
|
|
9
9
|
private callbacks;
|
|
10
|
-
private selectModeShield;
|
|
11
10
|
constructor(messenger: ParentMessenger, callbacks: SelectModeCallbacks);
|
|
12
11
|
/** Attaches capture-phase listeners for hover/click selection. */
|
|
13
12
|
enableListeners(): void;
|
|
14
13
|
/** Removes listeners and clears any active hover highlight. */
|
|
15
14
|
disableListeners(): void;
|
|
16
|
-
private attachSelectModeShieldIfNeeded;
|
|
17
|
-
private removeSelectModeShield;
|
|
18
|
-
private handleShieldWheel;
|
|
19
15
|
/** Clears the current hover highlight. */
|
|
20
16
|
clearHover(): void;
|
|
21
17
|
/**
|
|
@@ -30,8 +26,6 @@ export declare class SelectModeController {
|
|
|
30
26
|
private handleClick;
|
|
31
27
|
private resolveTarget;
|
|
32
28
|
private resolveElementFromPoint;
|
|
33
|
-
private findScrollableAncestor;
|
|
34
|
-
private canElementScroll;
|
|
35
29
|
private handleScroll;
|
|
36
30
|
}
|
|
37
31
|
//# sourceMappingURL=SelectModeController.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectModeController.d.ts","sourceRoot":"","sources":["../../../src/client/select-mode/SelectModeController.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAChE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAE9D;;;GAGG;AACH,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,SAAS,CAAiB;IAClC,OAAO,CAAC,SAAS,CAAqB;
|
|
1
|
+
{"version":3,"file":"SelectModeController.d.ts","sourceRoot":"","sources":["../../../src/client/select-mode/SelectModeController.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAChE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAE9D;;;GAGG;AACH,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,SAAS,CAAiB;IAClC,OAAO,CAAC,SAAS,CAAqB;gBAE1B,SAAS,EAAE,eAAe,EAAE,SAAS,EAAE,mBAAmB;IAKtE,kEAAkE;IAClE,eAAe,IAAI,IAAI;IAOvB,+DAA+D;IAC/D,gBAAgB,IAAI,IAAI;IAQxB,0CAA0C;IAC1C,UAAU,IAAI,IAAI;IAIlB;;;OAGG;IACH,4BAA4B,CAAC,OAAO,EAAE,WAAW,GAAG,WAAW;IAiB/D,yEAAyE;IACzE,qBAAqB,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI;IAShD,OAAO,CAAC,eAAe,CAgBtB;IAED,OAAO,CAAC,cAAc,CAGrB;IAED,OAAO,CAAC,WAAW,CAiBlB;IAED,OAAO,CAAC,aAAa;IAarB,OAAO,CAAC,uBAAuB;IAS/B,OAAO,CAAC,YAAY,CAInB;CACF"}
|
package/dist/client.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { b as $, c as X, R as Y, d as U, Z as x, C as v, M as
|
|
2
|
-
import { d as c } from "./debug-
|
|
1
|
+
import { b as $, c as X, R as Y, d as U, Z as x, C as v, M as A, B as R, e as B, P as G, i as W, a as V, T as P } from "./constants-DHvpLY46.js";
|
|
2
|
+
import { d as c } from "./debug-BuKzUOMn.js";
|
|
3
3
|
class j {
|
|
4
4
|
registry = /* @__PURE__ */ new Map();
|
|
5
5
|
register(e, t) {
|
|
@@ -23,7 +23,7 @@ class j {
|
|
|
23
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 })) : [];
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
function
|
|
26
|
+
function M(r) {
|
|
27
27
|
if (r.id)
|
|
28
28
|
return [`*[@id="${r.id}"]`];
|
|
29
29
|
const e = [];
|
|
@@ -41,39 +41,39 @@ function R(r) {
|
|
|
41
41
|
function I(r) {
|
|
42
42
|
return r.length === 1 && r[0].startsWith("*[@id=") ? `//${r[0]}` : "/" + r.join("/");
|
|
43
43
|
}
|
|
44
|
-
const u = { FunctionComponent: 0, ClassComponent: 1, IndeterminateComponent: 2, HostRoot: 3, HostPortal: 4, HostComponent: 5, HostText: 6, Fragment: 7, Mode: 8, ContextConsumer: 9, ContextProvider: 10, ForwardRef: 11, Profiler: 12, SuspenseComponent: 13, MemoComponent: 14, SimpleMemoComponent: 15, LazyComponent: 16, IncompleteClassComponent: 17, DehydratedFragment: 18, SuspenseListComponent: 19, ScopeComponent: 21, OffscreenComponent: 22, LegacyHiddenComponent: 23, CacheComponent: 24, TracingMarkerComponent: 25, HostHoistable: 26, HostSingleton: 27, IncompleteFunctionComponent: 28, Throw: 29, ViewTransitionComponent: 30, ActivityComponent: 31 },
|
|
45
|
-
let
|
|
46
|
-
function
|
|
44
|
+
const u = { FunctionComponent: 0, ClassComponent: 1, IndeterminateComponent: 2, HostRoot: 3, HostPortal: 4, HostComponent: 5, HostText: 6, Fragment: 7, Mode: 8, ContextConsumer: 9, ContextProvider: 10, ForwardRef: 11, Profiler: 12, SuspenseComponent: 13, MemoComponent: 14, SimpleMemoComponent: 15, LazyComponent: 16, IncompleteClassComponent: 17, DehydratedFragment: 18, SuspenseListComponent: 19, ScopeComponent: 21, OffscreenComponent: 22, LegacyHiddenComponent: 23, CacheComponent: 24, TracingMarkerComponent: 25, HostHoistable: 26, HostSingleton: 27, IncompleteFunctionComponent: 28, Throw: 29, ViewTransitionComponent: 30, ActivityComponent: 31 }, K = /* @__PURE__ */ new Set(["Component", "PureComponent", "Fragment", "Suspense", "Profiler", "StrictMode", "Routes", "Route", "Outlet", "Root", "ErrorBoundaryHandler", "HotReload", "Hot"]), z = [/Boundary$/, /BoundaryHandler$/, /Provider$/, /Consumer$/, /^(Inner|Outer)/, /Router$/, /^Client(Page|Segment|Root)/, /^Server(Root|Component|Render)/, /^RSC/, /Context$/, /^Hot(Reload)?$/, /^(Dev|React)(Overlay|Tools|Root)/, /Overlay$/, /Handler$/, /^With[A-Z]/, /Wrapper$/, /^Root$/];
|
|
45
|
+
let C = null;
|
|
46
|
+
function T(r) {
|
|
47
47
|
const e = (t) => t.some((n) => n.startsWith("__reactFiber$") || n.startsWith("__reactInternalInstance$") || n.startsWith("__reactProps$"));
|
|
48
48
|
return e(Object.keys(r)) || e(Object.getOwnPropertyNames(r));
|
|
49
49
|
}
|
|
50
50
|
function J() {
|
|
51
|
-
if (
|
|
51
|
+
if (C !== null) return C;
|
|
52
52
|
if (typeof document > "u") return !1;
|
|
53
|
-
if (document.body &&
|
|
54
|
-
return c("client", "Detected React on document.body"),
|
|
53
|
+
if (document.body && T(document.body))
|
|
54
|
+
return c("client", "Detected React on document.body"), C = !0, !0;
|
|
55
55
|
for (const e of Y) {
|
|
56
56
|
const t = document.querySelector(e);
|
|
57
57
|
if (t) {
|
|
58
|
-
if (
|
|
59
|
-
return c("client", "Detected React on", e),
|
|
58
|
+
if (T(t))
|
|
59
|
+
return c("client", "Detected React on", e), C = !0, !0;
|
|
60
60
|
for (const n of t.children)
|
|
61
|
-
if (
|
|
62
|
-
return c("client", "Detected React on child of", e),
|
|
61
|
+
if (T(n))
|
|
62
|
+
return c("client", "Detected React on child of", e), C = !0, !0;
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
if (document.body) {
|
|
66
66
|
for (const e of document.body.children)
|
|
67
|
-
if (
|
|
68
|
-
return c("client", "Detected React on body child:", e.tagName),
|
|
67
|
+
if (T(e))
|
|
68
|
+
return c("client", "Detected React on body child:", e.tagName), C = !0, !0;
|
|
69
69
|
}
|
|
70
70
|
const r = document.querySelectorAll("*");
|
|
71
71
|
for (const e of r) {
|
|
72
|
-
if (
|
|
73
|
-
return c("client", "Detected React on deep scan:", e.tagName),
|
|
72
|
+
if (T(e))
|
|
73
|
+
return c("client", "Detected React on deep scan:", e.tagName), C = !0, !0;
|
|
74
74
|
if (r.length > U) break;
|
|
75
75
|
}
|
|
76
|
-
return c("client", "React NOT detected on page"),
|
|
76
|
+
return c("client", "React NOT detected on page"), C = !1, !1;
|
|
77
77
|
}
|
|
78
78
|
function q(r) {
|
|
79
79
|
const e = Object.keys(r);
|
|
@@ -91,7 +91,7 @@ function q(r) {
|
|
|
91
91
|
});
|
|
92
92
|
return i && r[i] || null;
|
|
93
93
|
}
|
|
94
|
-
function
|
|
94
|
+
function b(r) {
|
|
95
95
|
return r ? r.displayName ? r.displayName : r.name ? r.name : null : null;
|
|
96
96
|
}
|
|
97
97
|
function Z(r) {
|
|
@@ -100,18 +100,18 @@ function Z(r) {
|
|
|
100
100
|
if (e === u.ForwardRef) {
|
|
101
101
|
const i = n;
|
|
102
102
|
if (i?.render) {
|
|
103
|
-
const s =
|
|
103
|
+
const s = b(i.render);
|
|
104
104
|
if (s) return s;
|
|
105
105
|
}
|
|
106
|
-
return i?.displayName ? i.displayName :
|
|
106
|
+
return i?.displayName ? i.displayName : b(t);
|
|
107
107
|
}
|
|
108
108
|
if (e === u.MemoComponent || e === u.SimpleMemoComponent) {
|
|
109
109
|
const i = n;
|
|
110
110
|
if (i?.type) {
|
|
111
|
-
const s =
|
|
111
|
+
const s = b(i.type);
|
|
112
112
|
if (s) return s;
|
|
113
113
|
}
|
|
114
|
-
return i?.displayName ? i.displayName :
|
|
114
|
+
return i?.displayName ? i.displayName : b(t);
|
|
115
115
|
}
|
|
116
116
|
if (e === u.ContextProvider) {
|
|
117
117
|
const i = t;
|
|
@@ -123,15 +123,15 @@ function Z(r) {
|
|
|
123
123
|
}
|
|
124
124
|
if (e === u.LazyComponent) {
|
|
125
125
|
const i = n;
|
|
126
|
-
return i?._status === 1 && i._result ?
|
|
126
|
+
return i?._status === 1 && i._result ? b(i._result) : null;
|
|
127
127
|
}
|
|
128
|
-
return e === u.IncompleteClassComponent || e === u.IncompleteFunctionComponent || e === u.FunctionComponent || e === u.ClassComponent || e === u.IndeterminateComponent ?
|
|
128
|
+
return e === u.IncompleteClassComponent || e === u.IncompleteFunctionComponent || e === u.FunctionComponent || e === u.ClassComponent || e === u.IndeterminateComponent ? b(t) : null;
|
|
129
129
|
}
|
|
130
130
|
function Q(r) {
|
|
131
131
|
return r.length <= 2 || r.length <= 3 && r === r.toLowerCase();
|
|
132
132
|
}
|
|
133
133
|
function ee(r) {
|
|
134
|
-
return !(
|
|
134
|
+
return !(K.has(r) || z.some((e) => e.test(r)));
|
|
135
135
|
}
|
|
136
136
|
function te(r, e = $, t = X) {
|
|
137
137
|
if (!J())
|
|
@@ -148,24 +148,24 @@ function te(r, e = $, t = X) {
|
|
|
148
148
|
}
|
|
149
149
|
return n.length === 0 ? { path: null, components: [] } : { path: n.slice().reverse().map((i) => `<${i}>`).join(" "), components: n };
|
|
150
150
|
}
|
|
151
|
-
let
|
|
151
|
+
let O = null;
|
|
152
152
|
function D(r, e, t, n = "solid") {
|
|
153
153
|
const o = document.createElement("div");
|
|
154
154
|
return Object.assign(o.style, { position: "fixed", left: `${r.left}px`, top: `${r.top}px`, width: `${r.width}px`, height: `${r.height}px`, border: `1px ${n} ${e}`, backgroundColor: t, pointerEvents: "none", zIndex: x.HOVER_OVERLAY, borderRadius: "2px" }), o;
|
|
155
155
|
}
|
|
156
156
|
function ne(r) {
|
|
157
|
-
|
|
157
|
+
L();
|
|
158
158
|
const e = r.getBoundingClientRect();
|
|
159
|
-
|
|
159
|
+
O = D(e, v.SELECT_OVERLAY_BORDER, v.SELECT_OVERLAY_BG), O.className = "forge-overlay", document.body.appendChild(O);
|
|
160
160
|
}
|
|
161
|
-
function
|
|
162
|
-
|
|
161
|
+
function L() {
|
|
162
|
+
O && (O.remove(), O = null);
|
|
163
163
|
}
|
|
164
164
|
let oe = 0;
|
|
165
165
|
function ie() {
|
|
166
166
|
return `ann-${Date.now()}-${++oe}`;
|
|
167
167
|
}
|
|
168
|
-
class
|
|
168
|
+
class S {
|
|
169
169
|
active = !1;
|
|
170
170
|
messenger;
|
|
171
171
|
hoverOverlay = null;
|
|
@@ -188,10 +188,10 @@ class T {
|
|
|
188
188
|
this.messenger = e, window.__forgeAnnotations = this, window.addEventListener("scroll", this.repositionAll, { capture: !0, passive: !0 }), window.addEventListener("resize", this.repositionAll, { passive: !0 });
|
|
189
189
|
}
|
|
190
190
|
activate() {
|
|
191
|
-
this.active || (this.active = !0, c("annotation", "Annotation mode activated"), this.addListeners(), this.setMarkersVisible(!0)
|
|
191
|
+
this.active || (this.active = !0, c("annotation", "Annotation mode activated"), this.addListeners(), this.setMarkersVisible(!0));
|
|
192
192
|
}
|
|
193
193
|
deactivate() {
|
|
194
|
-
this.active && (this.active = !1, c("annotation", "Annotation mode deactivated"), this.removeHoverOverlay(), this.clearAnnotationHighlights(), this.removeDragRect(), this.removeListeners(), this.setMarkersVisible(!1)
|
|
194
|
+
this.active && (this.active = !1, c("annotation", "Annotation mode deactivated"), this.removeHoverOverlay(), this.clearAnnotationHighlights(), this.removeDragRect(), this.removeListeners(), this.setMarkersVisible(!1));
|
|
195
195
|
}
|
|
196
196
|
selectDot(e) {
|
|
197
197
|
const t = this.dots.get(e);
|
|
@@ -236,10 +236,10 @@ class T {
|
|
|
236
236
|
const o = document.querySelectorAll(`[data-forge-id="${t}"]`);
|
|
237
237
|
o.length > 1 && (n = Array.from(o).indexOf(e));
|
|
238
238
|
}
|
|
239
|
-
return { xpath: I(
|
|
239
|
+
return { xpath: I(M(e)), forgeId: t, forgeIdIndex: n };
|
|
240
240
|
}
|
|
241
241
|
elementToInfo(e) {
|
|
242
|
-
return { elementTag: e.tagName.toLowerCase(), xpath:
|
|
242
|
+
return { elementTag: e.tagName.toLowerCase(), xpath: M(e), componentName: e.getAttribute("data-component") || void 0, componentPath: this.getComponentPath(e) || void 0, forgeId: e.getAttribute("data-forge-id") || void 0, forgeIdIndex: this.resolveForgeIdIndex(e), sourcePos: e.getAttribute("data-source-pos") || void 0 };
|
|
243
243
|
}
|
|
244
244
|
resolveForgeIdIndex(e) {
|
|
245
245
|
const t = e.getAttribute("data-forge-id");
|
|
@@ -251,11 +251,11 @@ class T {
|
|
|
251
251
|
if (!this.accumulationId) return;
|
|
252
252
|
const e = this.accumulationElements;
|
|
253
253
|
if (e.length === 0) {
|
|
254
|
-
this.messenger.send({ type: "ACCUMULATION_UPDATED", annotation: { id: this.accumulationId, dotX: 0, dotY: 0, mode: "single", elements: [], xpaths: [], elementTag: "" }, origin:
|
|
254
|
+
this.messenger.send({ type: "ACCUMULATION_UPDATED", annotation: { id: this.accumulationId, dotX: 0, dotY: 0, mode: "single", elements: [], xpaths: [], elementTag: "" }, origin: A });
|
|
255
255
|
return;
|
|
256
256
|
}
|
|
257
|
-
const n = e[e.length - 1].getBoundingClientRect(), o = n.left + n.width / 2, i = n.bottom, s = e.map((g) => this.elementToInfo(g)), a = e.map((g) => this.elementToLocator(g)), l = this.getAnchorRect(a), h = o - 2, d = i -
|
|
258
|
-
this.messenger.send({ type: "ACCUMULATION_UPDATED", annotation: { id: this.accumulationId, dotX: o, dotY: i, anchorOffset: m, mode: e.length > 1 ? "multi" : "single", elements: s, xpaths: s.map((g) => I(g.xpath)), elementTag: f.elementTag, componentName: f.componentName, componentPath: f.componentPath, forgeId: f.forgeId, sourcePos: f.sourcePos }, origin:
|
|
257
|
+
const n = e[e.length - 1].getBoundingClientRect(), o = n.left + n.width / 2, i = n.bottom, s = e.map((g) => this.elementToInfo(g)), a = e.map((g) => this.elementToLocator(g)), l = this.getAnchorRect(a), h = o - 2, d = i - R - 2, m = l && l.width > 0 && l.height > 0 ? { x: (h - l.left) / l.width, y: (d - l.top) / l.height } : { x: 0, y: 0 }, f = s[0];
|
|
258
|
+
this.messenger.send({ type: "ACCUMULATION_UPDATED", annotation: { id: this.accumulationId, dotX: o, dotY: i, anchorOffset: m, mode: e.length > 1 ? "multi" : "single", elements: s, xpaths: s.map((g) => I(g.xpath)), elementTag: f.elementTag, componentName: f.componentName, componentPath: f.componentPath, forgeId: f.forgeId, sourcePos: f.sourcePos }, origin: A });
|
|
259
259
|
}
|
|
260
260
|
removeDot(e) {
|
|
261
261
|
const t = this.dots.get(e);
|
|
@@ -424,12 +424,12 @@ class T {
|
|
|
424
424
|
this.dragHighlights = [];
|
|
425
425
|
}
|
|
426
426
|
createDot(e, t, n, o, i, s = []) {
|
|
427
|
-
const a = this.getAnchorRect(s), l = e - 2, h = t -
|
|
427
|
+
const a = this.getAnchorRect(s), l = e - 2, h = t - R - 2, d = a && a.width > 0 && a.height > 0 ? { rx: (l - a.left) / a.width, ry: (h - a.top) / a.height } : { rx: 0, ry: 0 };
|
|
428
428
|
this.createDotAtPosition(l, h, n, o, i, s, d);
|
|
429
429
|
}
|
|
430
430
|
createDotAtPosition(e, t, n, o, i, s, a) {
|
|
431
431
|
const l = document.createElement("div");
|
|
432
|
-
Object.assign(l.style, { position: "fixed", left: `${e}px`, top: `${t}px`, minWidth: `${B}px`, height: `${
|
|
432
|
+
Object.assign(l.style, { position: "fixed", left: `${e}px`, top: `${t}px`, minWidth: `${B}px`, height: `${R}px`, borderRadius: "50% 50% 50% 0", backgroundColor: "#FFFFFF", border: "1px solid #1A58D0", cursor: "pointer", zIndex: x.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", boxShadow: "0px 1px 3px -1px rgba(9, 18, 42, 0.06), 0px 1px 3px -3px rgba(9, 18, 42, 0.1)" }), l.textContent = String(i), l.className = "forge-annotation-dot", l.dataset.annotationId = o, l.addEventListener("mouseenter", () => {
|
|
433
433
|
l.style.transform = "scale(1.05)", this.removeHoverOverlay();
|
|
434
434
|
}), l.addEventListener("mouseleave", () => {
|
|
435
435
|
l.style.transform = "scale(1)";
|
|
@@ -438,7 +438,7 @@ class T {
|
|
|
438
438
|
const d = this.dots.get(o);
|
|
439
439
|
d && this.highlightAnnotationElements(d);
|
|
440
440
|
const m = l.getBoundingClientRect();
|
|
441
|
-
this.messenger.send({ type: "ANNOTATION_DOT_CLICKED", annotationId: o, dotX: m.left, dotY: m.bottom, origin:
|
|
441
|
+
this.messenger.send({ type: "ANNOTATION_DOT_CLICKED", annotationId: o, dotX: m.left, dotY: m.bottom, origin: A });
|
|
442
442
|
}), document.body.appendChild(l), this.dots.set(o, { id: o, element: l, mode: n, order: i, locators: s, anchorRatio: a });
|
|
443
443
|
}
|
|
444
444
|
updateOrders(e) {
|
|
@@ -488,8 +488,8 @@ class T {
|
|
|
488
488
|
if (!y || m.has(y) || g instanceof SVGElement && g.tagName.toLowerCase() !== "svg" || g.closest?.("svg") && g.tagName.toLowerCase() !== "svg") return;
|
|
489
489
|
const p = this.findTopmostWithSameForgeId(g);
|
|
490
490
|
if (m.has(p.getAttribute("data-forge-id") || "")) return;
|
|
491
|
-
const
|
|
492
|
-
|
|
491
|
+
const N = p.getBoundingClientRect();
|
|
492
|
+
N.right >= i && N.left <= a && N.bottom >= s && N.top <= l && (m.add(y), d.push(p));
|
|
493
493
|
}), this.dragScopeParent) {
|
|
494
494
|
const f = this.findForgeIdParent(this.dragScopeParent);
|
|
495
495
|
if (f)
|
|
@@ -516,7 +516,7 @@ class T {
|
|
|
516
516
|
}
|
|
517
517
|
if (e.buttons === 1) {
|
|
518
518
|
const n = e.clientX - this.dragStartX, o = e.clientY - this.dragStartY;
|
|
519
|
-
if (Math.abs(n) >
|
|
519
|
+
if (Math.abs(n) > S.DRAG_THRESHOLD || Math.abs(o) > S.DRAG_THRESHOLD) {
|
|
520
520
|
this.isDragging = !0;
|
|
521
521
|
return;
|
|
522
522
|
}
|
|
@@ -593,10 +593,10 @@ class T {
|
|
|
593
593
|
createAnnotationFromElements(e, t, n, o, i) {
|
|
594
594
|
const s = i || ie();
|
|
595
595
|
this.hoverSuppressed = !0, this.removeHoverOverlay();
|
|
596
|
-
const a = e.map((p) => this.elementToInfo(p)), l = a.map((p) => ({ xpath: I(p.xpath), forgeId: p.forgeId, forgeIdIndex: p.forgeIdIndex })), h = this.getAnchorRect(l), d = n - 2, m = o -
|
|
596
|
+
const a = e.map((p) => this.elementToInfo(p)), l = a.map((p) => ({ xpath: I(p.xpath), forgeId: p.forgeId, forgeIdIndex: p.forgeIdIndex })), h = this.getAnchorRect(l), d = n - 2, m = o - R - 2, f = h && h.width > 0 && h.height > 0 ? { x: (d - h.left) / h.width, y: (m - h.top) / h.height } : { x: 0, y: 0 };
|
|
597
597
|
this.pendingAnnotations.set(s, { dotX: n, dotY: o, mode: t, locators: l }), this.clearDragHighlights(), this.highlightLocators(l, t === "multi");
|
|
598
598
|
const g = a[0], y = { id: s, dotX: n, dotY: o, anchorOffset: f, mode: t, elements: a, xpaths: a.map((p) => I(p.xpath)), elementTag: g.elementTag, componentName: g.componentName, componentPath: g.componentPath, forgeId: g.forgeId, sourcePos: g.sourcePos };
|
|
599
|
-
c("annotation", "Annotation created (pending):", y), this.messenger.send({ type: "ANNOTATION_CREATED", annotation: y, origin:
|
|
599
|
+
c("annotation", "Annotation created (pending):", y), this.messenger.send({ type: "ANNOTATION_CREATED", annotation: y, origin: A });
|
|
600
600
|
}
|
|
601
601
|
handleDocumentLeave = () => {
|
|
602
602
|
this.removeHoverOverlay();
|
|
@@ -611,36 +611,17 @@ class T {
|
|
|
611
611
|
class se {
|
|
612
612
|
messenger;
|
|
613
613
|
callbacks;
|
|
614
|
-
selectModeShield = null;
|
|
615
614
|
constructor(e, t) {
|
|
616
615
|
this.messenger = e, this.callbacks = t;
|
|
617
616
|
}
|
|
618
617
|
enableListeners() {
|
|
619
|
-
|
|
618
|
+
document.addEventListener("mousemove", this.handleMouseOver, !0), document.addEventListener("click", this.handleClick, !0), document.addEventListener("mouseleave", this.handleMouseOut), document.addEventListener("scroll", this.handleScroll, !0);
|
|
620
619
|
}
|
|
621
620
|
disableListeners() {
|
|
622
|
-
|
|
623
|
-
}
|
|
624
|
-
attachSelectModeShieldIfNeeded() {
|
|
625
|
-
if (!this.callbacks.getSelectMode() || this.callbacks.getDesignMode() || this.selectModeShield) return;
|
|
626
|
-
const e = document.createElement("div");
|
|
627
|
-
Object.assign(e.style, { position: "fixed", top: "0", left: "0", width: "100%", height: "100%", backgroundColor: "transparent", pointerEvents: "auto", zIndex: "9998", cursor: "crosshair" }), e.className = "forge-select-mode-shield", e.addEventListener("wheel", this.handleShieldWheel, { passive: !1 }), document.body.appendChild(e), this.selectModeShield = e;
|
|
628
|
-
}
|
|
629
|
-
removeSelectModeShield() {
|
|
630
|
-
this.selectModeShield && (this.selectModeShield.removeEventListener("wheel", this.handleShieldWheel), this.selectModeShield.remove(), this.selectModeShield = null);
|
|
621
|
+
document.removeEventListener("mousemove", this.handleMouseOver, !0), document.removeEventListener("click", this.handleClick, !0), document.removeEventListener("mouseleave", this.handleMouseOut), document.removeEventListener("scroll", this.handleScroll, !0), this.clearHover();
|
|
631
622
|
}
|
|
632
|
-
handleShieldWheel = (e) => {
|
|
633
|
-
if (!this.callbacks.getSelectMode() || this.callbacks.getDesignMode()) return;
|
|
634
|
-
e.preventDefault();
|
|
635
|
-
const t = this.resolveElementFromPoint(e.clientX, e.clientY), n = t instanceof HTMLElement ? t : null, o = n ? this.findScrollableAncestor(n, e.deltaX, e.deltaY) : null;
|
|
636
|
-
if (o) {
|
|
637
|
-
o.scrollBy({ left: e.deltaX, top: e.deltaY, behavior: "auto" });
|
|
638
|
-
return;
|
|
639
|
-
}
|
|
640
|
-
window.scrollBy({ left: e.deltaX, top: e.deltaY, behavior: "auto" });
|
|
641
|
-
};
|
|
642
623
|
clearHover() {
|
|
643
|
-
|
|
624
|
+
L();
|
|
644
625
|
}
|
|
645
626
|
findTopmostElementWithSameId(e) {
|
|
646
627
|
const t = e.getAttribute("data-forge-id");
|
|
@@ -654,8 +635,8 @@ class se {
|
|
|
654
635
|
return o;
|
|
655
636
|
}
|
|
656
637
|
handleSelectModeClick(e) {
|
|
657
|
-
const t = I(
|
|
658
|
-
c("client", "Element clicked, XPath:", t), this.messenger.send({ type: "XPATH_REPORT", xpath: t, origin:
|
|
638
|
+
const t = I(M(e));
|
|
639
|
+
c("client", "Element clicked, XPath:", t), this.messenger.send({ type: "XPATH_REPORT", xpath: t, origin: A }), this.messenger.send({ type: "SELECT_MODE_DISABLED", origin: A });
|
|
659
640
|
}
|
|
660
641
|
handleMouseOver = (e) => {
|
|
661
642
|
if (!this.callbacks.getSelectMode() && !this.callbacks.getDesignMode() || this.callbacks.getHoverDisabled()) return;
|
|
@@ -668,13 +649,13 @@ class se {
|
|
|
668
649
|
}
|
|
669
650
|
};
|
|
670
651
|
handleMouseOut = (e) => {
|
|
671
|
-
!this.callbacks.getSelectMode() && !this.callbacks.getDesignMode() ||
|
|
652
|
+
!this.callbacks.getSelectMode() && !this.callbacks.getDesignMode() || L();
|
|
672
653
|
};
|
|
673
654
|
handleClick = (e) => {
|
|
674
655
|
if (!this.callbacks.getSelectMode() && !this.callbacks.getDesignMode()) return;
|
|
675
656
|
e.preventDefault(), e.stopPropagation();
|
|
676
657
|
const t = this.resolveTarget(e);
|
|
677
|
-
t && t !== document.body && t !== document.documentElement && (this.callbacks.getSelectMode() && this.callbacks.onSelectClick(t), this.callbacks.getDesignMode() && (
|
|
658
|
+
t && t !== document.body && t !== document.documentElement && (this.callbacks.getSelectMode() && this.callbacks.onSelectClick(t), this.callbacks.getDesignMode() && (L(), this.callbacks.onDesignClick(t)));
|
|
678
659
|
};
|
|
679
660
|
resolveTarget(e) {
|
|
680
661
|
const n = this.resolveElementFromPoint(e.clientX, e.clientY) ?? e.target;
|
|
@@ -683,35 +664,23 @@ class se {
|
|
|
683
664
|
resolveElementFromPoint(e, t) {
|
|
684
665
|
const n = document.elementsFromPoint(e, t);
|
|
685
666
|
for (const o of n)
|
|
686
|
-
if (!
|
|
667
|
+
if (!o.classList.contains("forge-overlay"))
|
|
687
668
|
return o;
|
|
688
669
|
return null;
|
|
689
670
|
}
|
|
690
|
-
findScrollableAncestor(e, t, n) {
|
|
691
|
-
let o = e;
|
|
692
|
-
for (; o && o !== document.body; ) {
|
|
693
|
-
if (this.canElementScroll(o, t, n)) return o;
|
|
694
|
-
o = o.parentElement;
|
|
695
|
-
}
|
|
696
|
-
return null;
|
|
697
|
-
}
|
|
698
|
-
canElementScroll(e, t, n) {
|
|
699
|
-
const o = window.getComputedStyle(e), i = (o.overflowY === "auto" || o.overflowY === "scroll" || o.overflowY === "overlay") && e.scrollHeight > e.clientHeight, s = (o.overflowX === "auto" || o.overflowX === "scroll" || o.overflowX === "overlay") && e.scrollWidth > e.clientWidth, a = i && (n < 0 && e.scrollTop > 0 || n > 0 && e.scrollTop + e.clientHeight < e.scrollHeight), l = s && (t < 0 && e.scrollLeft > 0 || t > 0 && e.scrollLeft + e.clientWidth < e.scrollWidth);
|
|
700
|
-
return a || l;
|
|
701
|
-
}
|
|
702
671
|
handleScroll = () => {
|
|
703
|
-
(this.callbacks.getSelectMode() || this.callbacks.getDesignMode()) &&
|
|
672
|
+
(this.callbacks.getSelectMode() || this.callbacks.getDesignMode()) && L();
|
|
704
673
|
};
|
|
705
674
|
}
|
|
706
|
-
let
|
|
675
|
+
let _ = null, H = null, w = null;
|
|
707
676
|
async function re() {
|
|
708
|
-
if (
|
|
677
|
+
if (_ && H && w) return;
|
|
709
678
|
const [r, e, t] = await Promise.all([import("@babel/parser"), import("@babel/traverse"), import("@babel/generator")]);
|
|
710
|
-
|
|
679
|
+
_ = r.parse;
|
|
711
680
|
const n = e.default;
|
|
712
681
|
H = typeof n == "function" ? n : n.default;
|
|
713
682
|
const o = t.default;
|
|
714
|
-
|
|
683
|
+
w = typeof o == "function" ? o : o.default;
|
|
715
684
|
}
|
|
716
685
|
function k(r) {
|
|
717
686
|
return typeof r == "boolean" ? { type: "JSXExpressionContainer", expression: { type: "BooleanLiteral", value: r, loc: null }, loc: null } : typeof r == "number" ? { type: "JSXExpressionContainer", expression: { type: "NumericLiteral", value: r, loc: null }, loc: null } : { type: "StringLiteral", value: String(r), loc: null };
|
|
@@ -722,8 +691,8 @@ function F(r, e, t) {
|
|
|
722
691
|
}
|
|
723
692
|
async function ae(r, e, t, n, o) {
|
|
724
693
|
try {
|
|
725
|
-
if (await re(), !
|
|
726
|
-
const i =
|
|
694
|
+
if (await re(), !_ || !H || !w) return r;
|
|
695
|
+
const i = _(r, { sourceType: "module", plugins: ["jsx", "typescript"] });
|
|
727
696
|
let s = !1;
|
|
728
697
|
const a = /* @__PURE__ */ new Map();
|
|
729
698
|
if (H(i, { JSXOpeningElement(l) {
|
|
@@ -742,7 +711,7 @@ async function ae(r, e, t, n, o) {
|
|
|
742
711
|
}
|
|
743
712
|
}
|
|
744
713
|
if (s)
|
|
745
|
-
return
|
|
714
|
+
return w(i, {}, r).code;
|
|
746
715
|
} catch (i) {
|
|
747
716
|
c("client", "Failed to parse/update AST:", i);
|
|
748
717
|
}
|
|
@@ -789,8 +758,8 @@ class he {
|
|
|
789
758
|
}
|
|
790
759
|
const n = this.selectController.findTopmostElementWithSameId(e), o = n.getAttribute("data-component"), i = n.getAttribute("data-source-pos"), s = o || n.tagName.toLowerCase();
|
|
791
760
|
this.clearSelection(), this.selectedElement = n, this.applyHighlight(n);
|
|
792
|
-
const a = n.textContent?.trim() || "", l = n.tagName.toLowerCase(), h = I(
|
|
793
|
-
c("client", "Element selected in design mode:", { forgeId: t, sourcePos: i, text: a, type: l, componentName: s, editableProps: d, propValues: m }), this.messenger.send({ type: "ELEMENT_SELECTED", forgeId: t, sourcePos: i || void 0, text: a, elementType: l, xpath: h, componentName: s, editableProps: d, propValues: m, origin:
|
|
761
|
+
const a = n.textContent?.trim() || "", l = n.tagName.toLowerCase(), h = I(M(n)), d = this.componentRegistry.getEditableProps(s), m = this.extractPropValues(n, d);
|
|
762
|
+
c("client", "Element selected in design mode:", { forgeId: t, sourcePos: i, text: a, type: l, componentName: s, editableProps: d, propValues: m }), this.messenger.send({ type: "ELEMENT_SELECTED", forgeId: t, sourcePos: i || void 0, text: a, elementType: l, xpath: h, componentName: s, editableProps: d, propValues: m, origin: A });
|
|
794
763
|
}
|
|
795
764
|
updateText(e, t) {
|
|
796
765
|
this.updateProperty(e, "children", t);
|
|
@@ -817,7 +786,7 @@ class he {
|
|
|
817
786
|
if (!l) return;
|
|
818
787
|
this.sourceCache.set(a, l);
|
|
819
788
|
const h = this.selectedElement?.getAttribute("data-source-pos") ?? null, d = await ae(l, e, t, n, h);
|
|
820
|
-
d !== l ? (this.sourceCache.set(a, d), c("client", `Updated source for ${a}`), await ce(a, d) && (c("client", `Source written to disk and HMR triggered for ${a}`), this.messenger.send({ type: "SOURCE_UPDATED", forgeId: e, source: d, filePath: a, origin:
|
|
789
|
+
d !== l ? (this.sourceCache.set(a, d), c("client", `Updated source for ${a}`), await ce(a, d) && (c("client", `Source written to disk and HMR triggered for ${a}`), this.messenger.send({ type: "SOURCE_UPDATED", forgeId: e, source: d, filePath: a, origin: A }))) : c("client", `No source changes detected for ${a}`);
|
|
821
790
|
}
|
|
822
791
|
applyHighlight(e) {
|
|
823
792
|
e.style.outline = `3px solid ${v.DESIGN_SELECTION_OUTLINE}`, e.style.outlineOffset = "2px";
|
|
@@ -847,7 +816,8 @@ class he {
|
|
|
847
816
|
return t ? e[t] : null;
|
|
848
817
|
}
|
|
849
818
|
}
|
|
850
|
-
class
|
|
819
|
+
class E {
|
|
820
|
+
static ANNOTATION_CURSOR_LOCK_CLASS = "forge-annotation-cursor-lock";
|
|
851
821
|
static instance = null;
|
|
852
822
|
messenger;
|
|
853
823
|
readyIntervalId = null;
|
|
@@ -859,25 +829,26 @@ class A {
|
|
|
859
829
|
annotationOverlay = null;
|
|
860
830
|
selectController;
|
|
861
831
|
designController;
|
|
832
|
+
annotationCursorLockStyleEl = null;
|
|
862
833
|
onError;
|
|
863
834
|
constructor(e) {
|
|
864
|
-
this.onError = e?.onError, c("client", "ForgeClient initialized"), this.messenger = new
|
|
835
|
+
this.onError = e?.onError, c("client", "ForgeClient initialized"), this.messenger = new G(), this.componentRegistry = new j(), this.selectController = new se(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 he(this.messenger, this.componentRegistry, this.selectController), this.setupMessageListener(), this.sendReady(), this.setupForgeIdPropagation(), window.__forgeClient = this;
|
|
865
836
|
}
|
|
866
837
|
static getInstance(e) {
|
|
867
|
-
return
|
|
838
|
+
return E.instance || (E.instance = new E(e)), E.instance;
|
|
868
839
|
}
|
|
869
840
|
enableAnnotationMode(e) {
|
|
870
841
|
this.setAnnotationMode(e);
|
|
871
842
|
}
|
|
872
843
|
restoreAnnotations(e) {
|
|
873
|
-
this.annotationOverlay || (this.annotationOverlay = new
|
|
844
|
+
this.annotationOverlay || (this.annotationOverlay = new S(this.messenger)), this.annotationOverlay.restoreDots(e);
|
|
874
845
|
}
|
|
875
846
|
setupMessageListener() {
|
|
876
847
|
c("client", "Setting up message listener..."), this.messenger.onMessage((e) => {
|
|
877
|
-
if (
|
|
848
|
+
if (W(e.data) || (this.isConnectedToHost || (this.isConnectedToHost = !0, this.readyIntervalId !== null && (window.clearInterval(this.readyIntervalId), this.readyIntervalId = null, c("client", "Host connection detected, stopped CHILD_READY retries"))), console.log("Received message from host:", { isConnectedToHost: this.isConnectedToHost }), !e.data || typeof e.data != "object" || !("origin" in e.data))) return;
|
|
878
849
|
const t = e.data;
|
|
879
850
|
if (t.origin === V) {
|
|
880
|
-
|
|
851
|
+
c("client", "Received message from host:", t);
|
|
881
852
|
try {
|
|
882
853
|
switch (t.type) {
|
|
883
854
|
case "ENABLE_SELECT_MODE":
|
|
@@ -923,7 +894,7 @@ class A {
|
|
|
923
894
|
this.annotationOverlay?.toggleMarkers();
|
|
924
895
|
break;
|
|
925
896
|
case "RESTORE_ANNOTATIONS":
|
|
926
|
-
this.annotationOverlay || (this.annotationOverlay = new
|
|
897
|
+
this.annotationOverlay || (this.annotationOverlay = new S(this.messenger)), this.annotationOverlay.restoreDots(t.annotations);
|
|
927
898
|
break;
|
|
928
899
|
case "PING":
|
|
929
900
|
c("client", "Received PING");
|
|
@@ -936,13 +907,26 @@ class A {
|
|
|
936
907
|
});
|
|
937
908
|
}
|
|
938
909
|
setSelectMode(e) {
|
|
939
|
-
this.selectMode !== e && (c("client", `Setting select mode to: ${e}`), this.selectMode = e, e ?
|
|
910
|
+
this.selectMode !== e && (c("client", `Setting select mode to: ${e}`), this.selectMode = e, e ? this.selectController.enableListeners() : (this.selectController.disableListeners(), this.selectController.clearHover()));
|
|
940
911
|
}
|
|
941
912
|
setDesignMode(e) {
|
|
942
|
-
this.designMode !== e && (c("client", `Setting design mode to: ${e}`), this.designMode = e, e ? (this.selectController.enableListeners(), this.hoverDisabled = !1
|
|
913
|
+
this.designMode !== e && (c("client", `Setting design mode to: ${e}`), this.designMode = e, e ? (this.selectController.enableListeners(), this.hoverDisabled = !1) : (this.selectController.disableListeners(), this.hoverDisabled = !1, this.selectController.clearHover()));
|
|
943
914
|
}
|
|
944
915
|
setAnnotationMode(e) {
|
|
945
|
-
e ? (this.annotationOverlay || (this.annotationOverlay = new
|
|
916
|
+
e ? (this.enableAnnotationCursorLock(), this.annotationOverlay || (this.annotationOverlay = new S(this.messenger)), this.setSelectMode(!1), this.setDesignMode(!1), this.annotationOverlay.activate()) : (this.annotationOverlay?.deactivate(), this.disableAnnotationCursorLock());
|
|
917
|
+
}
|
|
918
|
+
enableAnnotationCursorLock() {
|
|
919
|
+
if (document.documentElement.classList.add(E.ANNOTATION_CURSOR_LOCK_CLASS), this.annotationCursorLockStyleEl) return;
|
|
920
|
+
const e = document.createElement("style");
|
|
921
|
+
e.id = "forge-annotation-cursor-lock-style", e.textContent = `
|
|
922
|
+
html.${E.ANNOTATION_CURSOR_LOCK_CLASS},
|
|
923
|
+
html.${E.ANNOTATION_CURSOR_LOCK_CLASS} * {
|
|
924
|
+
cursor: crosshair !important;
|
|
925
|
+
}
|
|
926
|
+
`, (document.head ?? document.documentElement).appendChild(e), this.annotationCursorLockStyleEl = e;
|
|
927
|
+
}
|
|
928
|
+
disableAnnotationCursorLock() {
|
|
929
|
+
document.documentElement.classList.remove(E.ANNOTATION_CURSOR_LOCK_CLASS), this.annotationCursorLockStyleEl && (this.annotationCursorLockStyleEl.remove(), this.annotationCursorLockStyleEl = null);
|
|
946
930
|
}
|
|
947
931
|
handleSelectClick(e) {
|
|
948
932
|
this.selectController.handleSelectModeClick(e), this.setSelectMode(!1);
|
|
@@ -952,12 +936,12 @@ class A {
|
|
|
952
936
|
}
|
|
953
937
|
sendReady() {
|
|
954
938
|
c("client", "Scheduling CHILD_READY message..."), setTimeout(() => {
|
|
955
|
-
this.isConnectedToHost || (c("client", "Sending CHILD_READY message to parent"), this.messenger.send({ type: "CHILD_READY", origin:
|
|
939
|
+
this.isConnectedToHost || (c("client", "Sending CHILD_READY message to parent"), this.messenger.send({ type: "CHILD_READY", origin: A }), this.readyIntervalId === null && (this.readyIntervalId = window.setInterval(() => {
|
|
956
940
|
if (this.isConnectedToHost) {
|
|
957
941
|
this.readyIntervalId !== null && (window.clearInterval(this.readyIntervalId), this.readyIntervalId = null);
|
|
958
942
|
return;
|
|
959
943
|
}
|
|
960
|
-
c("client", "Retrying CHILD_READY message to parent"), this.messenger.send({ type: "CHILD_READY", origin:
|
|
944
|
+
c("client", "Retrying CHILD_READY message to parent"), this.messenger.send({ type: "CHILD_READY", origin: A });
|
|
961
945
|
}, P.CHILD_READY_RETRY_INTERVAL)));
|
|
962
946
|
}, P.CHILD_READY_DELAY);
|
|
963
947
|
}
|
|
@@ -988,8 +972,8 @@ class A {
|
|
|
988
972
|
}
|
|
989
973
|
}
|
|
990
974
|
}
|
|
991
|
-
|
|
975
|
+
E.getInstance();
|
|
992
976
|
export {
|
|
993
|
-
|
|
994
|
-
|
|
977
|
+
E as ForgeClient,
|
|
978
|
+
G as ParentMessenger
|
|
995
979
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
let n = !1;
|
|
2
|
+
function i(e = !0) {
|
|
3
|
+
n = e;
|
|
4
|
+
}
|
|
5
|
+
function l(e, ...t) {
|
|
6
|
+
if (!n) return;
|
|
7
|
+
const o = e === "client" ? "🔵" : e === "host" ? "🟡" : e === "annotation" ? "🟢" : "⚪", s = (/* @__PURE__ */ new Date()).toISOString().split("T")[1].slice(0, -1);
|
|
8
|
+
console.log(`[${s}] ${o} [${e.toUpperCase()}]`, ...t);
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
l as d,
|
|
12
|
+
i as e
|
|
13
|
+
};
|
package/dist/host.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ForgeHost as r } from "./host.js";
|
|
2
2
|
import { ForgeClient as t } from "./client.js";
|
|
3
|
-
import { a as S, u as m } from "./useDesignMode
|
|
4
|
-
import { e as p } from "./debug-
|
|
3
|
+
import { a as S, u as m } from "./useDesignMode--DcwfmhZ.js";
|
|
4
|
+
import { e as p } from "./debug-BuKzUOMn.js";
|
|
5
5
|
import { a as E, M as g } from "./constants-DHvpLY46.js";
|
|
6
6
|
export {
|
|
7
7
|
t as ForgeClient,
|
package/dist/react.js
CHANGED
package/package.json
CHANGED