@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.
- package/README.md +193 -0
- package/dist/build/index.d.ts +3 -0
- package/dist/build/index.d.ts.map +1 -0
- package/dist/build/index.js +96 -0
- package/dist/build/vite-plugin-forge-ids.d.ts +7 -0
- package/dist/build/vite-plugin-forge-ids.d.ts.map +1 -0
- package/dist/client/annotation/AnnotationOverlay.d.ts +86 -0
- package/dist/client/annotation/AnnotationOverlay.d.ts.map +1 -0
- package/dist/client/design-mode/DesignModeController.d.ts +35 -0
- package/dist/client/design-mode/DesignModeController.d.ts.map +1 -0
- package/dist/client/general/ComponentRegistry.d.ts +15 -0
- package/dist/client/general/ComponentRegistry.d.ts.map +1 -0
- package/dist/client/general/ForgeClient.d.ts +36 -0
- package/dist/client/general/ForgeClient.d.ts.map +1 -0
- package/dist/client/general/SourceCodeUpdater.d.ts +15 -0
- package/dist/client/general/SourceCodeUpdater.d.ts.map +1 -0
- package/dist/client/general/element-utils.d.ts +20 -0
- package/dist/client/general/element-utils.d.ts.map +1 -0
- package/dist/client/general/overlay.d.ts +9 -0
- package/dist/client/general/overlay.d.ts.map +1 -0
- package/dist/client/general/react-detection.d.ts +49 -0
- package/dist/client/general/react-detection.d.ts.map +1 -0
- package/dist/client/general/types.d.ts +26 -0
- package/dist/client/general/types.d.ts.map +1 -0
- package/dist/client/general/xpath.d.ts +3 -0
- package/dist/client/general/xpath.d.ts.map +1 -0
- package/dist/client/index.d.ts +6 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/select-mode/SelectModeController.d.ts +31 -0
- package/dist/client/select-mode/SelectModeController.d.ts.map +1 -0
- package/dist/client.js +836 -0
- package/dist/constants-BXKWBfHg.js +55 -0
- package/dist/debug-CLzmqn3R.js +11 -0
- package/dist/host/ForgeHost.d.ts +57 -0
- package/dist/host/ForgeHost.d.ts.map +1 -0
- package/dist/host/index.d.ts +3 -0
- package/dist/host/index.d.ts.map +1 -0
- package/dist/host/types.d.ts +32 -0
- package/dist/host/types.d.ts.map +1 -0
- package/dist/host.js +142 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/react/index.d.ts +5 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/useDesignMode.d.ts +12 -0
- package/dist/react/useDesignMode.d.ts.map +1 -0
- package/dist/react/useElementSelector.d.ts +12 -0
- package/dist/react/useElementSelector.d.ts.map +1 -0
- package/dist/react.js +5 -0
- package/dist/shared/constants.d.ts +27 -0
- package/dist/shared/constants.d.ts.map +1 -0
- package/dist/shared/debug.d.ts +4 -0
- package/dist/shared/debug.d.ts.map +1 -0
- package/dist/shared/events.d.ts +157 -0
- package/dist/shared/events.d.ts.map +1 -0
- package/dist/shared/messaging.d.ts +19 -0
- package/dist/shared/messaging.d.ts.map +1 -0
- package/dist/useDesignMode-VIipNUSj.js +68 -0
- package/package.json +69 -0
package/README.md
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
# @supernovaio/prototyping-tooling
|
|
2
|
+
|
|
3
|
+
Communication bridge for iframe-based design-to-code prototyping workflows. Enables a **host** (parent window) to control and interact with a **client** (child iframe) for element selection, design-mode editing, annotations, and live source-code updates.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @supernovaio/prototyping-tooling
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Entry Points
|
|
12
|
+
|
|
13
|
+
| Import path | Side | Description |
|
|
14
|
+
|---|---|---|
|
|
15
|
+
| `@supernovaio/prototyping-tooling/host` | Parent | `ForgeHost` — connects to the iframe, sends commands, receives events |
|
|
16
|
+
| `@supernovaio/prototyping-tooling/client` | Child | `ForgeClient` — auto-initializes, handles messages, manages overlays |
|
|
17
|
+
| `@supernovaio/prototyping-tooling/react` | Parent | React hooks: `useElementSelector`, `useDesignMode` |
|
|
18
|
+
| `@supernovaio/prototyping-tooling/build` | Build | Vite plugin that injects `data-forge-id` attributes into JSX |
|
|
19
|
+
| `@supernovaio/prototyping-tooling` | Either | Shared types, debug utilities, message constants |
|
|
20
|
+
|
|
21
|
+
## Quick Start
|
|
22
|
+
|
|
23
|
+
### Parent (host) app
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
import { ForgeHost } from '@supernovaio/prototyping-tooling/host'
|
|
27
|
+
|
|
28
|
+
const iframe = document.querySelector('iframe')!
|
|
29
|
+
const host = new ForgeHost(iframe)
|
|
30
|
+
|
|
31
|
+
await host.connect()
|
|
32
|
+
|
|
33
|
+
host.on('element-selected', (selection) => {
|
|
34
|
+
console.log('Selected:', selection.componentName, selection.forgeId)
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
host.enableDesignMode(true)
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Child (client) app
|
|
41
|
+
|
|
42
|
+
```typescript
|
|
43
|
+
// Importing the client auto-initializes it
|
|
44
|
+
import '@supernovaio/prototyping-tooling/client'
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Vite plugin (child build)
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
// vite.config.ts
|
|
51
|
+
import { supernovaDesignPlugin } from '@supernovaio/prototyping-tooling/build'
|
|
52
|
+
|
|
53
|
+
export default defineConfig({
|
|
54
|
+
plugins: [react(), supernovaDesignPlugin()],
|
|
55
|
+
})
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## API Reference
|
|
59
|
+
|
|
60
|
+
### `ForgeHost` (host)
|
|
61
|
+
|
|
62
|
+
| Method | Description |
|
|
63
|
+
|---|---|
|
|
64
|
+
| `connect()` | Connects to the child iframe. Resolves on `CHILD_READY`. |
|
|
65
|
+
| `enableSelectMode(enabled)` | Toggles XPath element-picking mode |
|
|
66
|
+
| `enableDesignMode(enabled)` | Toggles design mode (click to select, edit props) |
|
|
67
|
+
| `enableAnnotationMode(enabled)` | Toggles annotation mode (click/drag to annotate) |
|
|
68
|
+
| `updateElementText(forgeId, text)` | Updates text content of a forge element |
|
|
69
|
+
| `updateProperty(forgeId, prop, value)` | Updates any property via Babel AST |
|
|
70
|
+
| `deselectElement()` | Clears the design-mode selection |
|
|
71
|
+
| `deleteAnnotation(id)` | Removes an annotation dot |
|
|
72
|
+
| `keepAnnotation(id, order)` | Confirms and numbers an annotation |
|
|
73
|
+
| `updateAnnotationOrders(orders)` | Bulk-updates annotation order numbers |
|
|
74
|
+
| `toggleMarkers()` | Toggles visibility of annotation marker badges |
|
|
75
|
+
| `restoreAnnotations(annotations)` | Re-sends saved annotations to the child to recreate dots after reconnect |
|
|
76
|
+
| `registerComponents(components)` | Sends component definitions to the child |
|
|
77
|
+
| `on(event, handler)` | Subscribes to events; returns unsubscribe fn |
|
|
78
|
+
| `getStatus()` | Returns `'connecting' \| 'connected' \| 'disconnected'` |
|
|
79
|
+
| `disconnect()` | Cleans up listeners and resets state |
|
|
80
|
+
|
|
81
|
+
#### Events
|
|
82
|
+
|
|
83
|
+
| Event | Payload |
|
|
84
|
+
|---|---|
|
|
85
|
+
| `connected` | — |
|
|
86
|
+
| `disconnected` | — |
|
|
87
|
+
| `xpath-selected` | `xpath: string` |
|
|
88
|
+
| `select-mode-disabled` | — |
|
|
89
|
+
| `design-mode-disabled` | — |
|
|
90
|
+
| `element-selected` | `ElementSelection` |
|
|
91
|
+
| `annotation-created` | `AnnotationData` |
|
|
92
|
+
| `annotation-dot-clicked` | `annotationId, dotX, dotY` |
|
|
93
|
+
| `source-updated` | `forgeId, source, filePath` |
|
|
94
|
+
|
|
95
|
+
### `ForgeClient` (client)
|
|
96
|
+
|
|
97
|
+
Singleton that auto-initializes on import. Access via `ForgeClient.getInstance()`.
|
|
98
|
+
|
|
99
|
+
Accepts an optional `ForgeClientOptions` with an `onError` callback for error handling.
|
|
100
|
+
|
|
101
|
+
The client also exposes a public `enableAnnotationMode(enabled)` method for console-driven testing (see [Console Access](#console-access)).
|
|
102
|
+
|
|
103
|
+
### React Hooks
|
|
104
|
+
|
|
105
|
+
#### `useElementSelector(host)`
|
|
106
|
+
|
|
107
|
+
Returns `{ selectMode, connectionStatus, selectedXPath, enableSelectMode, clearXPath }`.
|
|
108
|
+
|
|
109
|
+
#### `useDesignMode(host)`
|
|
110
|
+
|
|
111
|
+
Returns `{ designMode, selectedElement, enableDesignMode, updateText, updateProperty, deselectElement }`.
|
|
112
|
+
|
|
113
|
+
### Annotations
|
|
114
|
+
|
|
115
|
+
Annotation badges are anchored to their associated elements. When the page scrolls or the window resizes, badges automatically reposition to follow their elements.
|
|
116
|
+
|
|
117
|
+
**Forge ID generation** is deterministic — IDs are derived from `filePath + line + column`, so the same source position always produces the same ID across rebuilds. Elements rendered inside loops (`.map()`) share the same forge-id; the system disambiguates them using a `forgeIdIndex`.
|
|
118
|
+
|
|
119
|
+
**Restoring annotations** — the parent can call `host.restoreAnnotations(annotations)` after reconnecting to the child (e.g., after HMR reload) to recreate all annotation dots. The child resolves elements by `data-forge-id` first, falling back to XPath.
|
|
120
|
+
|
|
121
|
+
### Keyboard Shortcuts
|
|
122
|
+
|
|
123
|
+
The plugin does **not** handle keyboard events. The consuming parent application is responsible for binding its own shortcuts and calling the appropriate `ForgeHost` methods. Example implementation:
|
|
124
|
+
|
|
125
|
+
```typescript
|
|
126
|
+
useEffect(() => {
|
|
127
|
+
const handleKeyDown = (e: KeyboardEvent) => {
|
|
128
|
+
// Cmd/Ctrl + Shift + F → toggle annotation mode
|
|
129
|
+
if (e.shiftKey && (e.metaKey || e.ctrlKey) && e.key.toLowerCase() === 'f') {
|
|
130
|
+
e.preventDefault()
|
|
131
|
+
host.enableAnnotationMode(!annotationMode)
|
|
132
|
+
}
|
|
133
|
+
// Escape → close popup
|
|
134
|
+
if (e.key === 'Escape') {
|
|
135
|
+
closePopup()
|
|
136
|
+
}
|
|
137
|
+
// H → toggle annotation markers (skip when typing)
|
|
138
|
+
if (e.key.toLowerCase() === 'h' && !e.metaKey && !e.ctrlKey && !e.shiftKey && !e.altKey) {
|
|
139
|
+
const tag = (e.target as HTMLElement)?.tagName?.toLowerCase()
|
|
140
|
+
if (tag === 'input' || tag === 'textarea') return
|
|
141
|
+
host.toggleMarkers()
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
window.addEventListener('keydown', handleKeyDown)
|
|
145
|
+
return () => window.removeEventListener('keydown', handleKeyDown)
|
|
146
|
+
}, [host, annotationMode])
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### Console Access
|
|
150
|
+
|
|
151
|
+
Both `ForgeHost` and `ForgeClient` expose themselves on the `window` for console-driven testing:
|
|
152
|
+
|
|
153
|
+
```javascript
|
|
154
|
+
// From the parent page's console:
|
|
155
|
+
__forgeHost.enableAnnotationMode(true) // activate annotation mode
|
|
156
|
+
__forgeHost.enableAnnotationMode(false) // deactivate
|
|
157
|
+
__forgeHost.toggleMarkers() // toggle marker visibility
|
|
158
|
+
__forgeHost.restoreAnnotations([...]) // restore saved annotations
|
|
159
|
+
|
|
160
|
+
// From the child iframe's console (switch iframe context in DevTools):
|
|
161
|
+
__forgeClient.enableAnnotationMode(true)
|
|
162
|
+
__forgeAnnotations.toggleMarkers()
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### Debug
|
|
166
|
+
|
|
167
|
+
```typescript
|
|
168
|
+
import { enableDebug } from '@supernovaio/prototyping-tooling'
|
|
169
|
+
|
|
170
|
+
enableDebug(true) // Turns on timestamped console output
|
|
171
|
+
enableDebug(false) // Silences all library logging
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## Architecture
|
|
175
|
+
|
|
176
|
+
```
|
|
177
|
+
src/
|
|
178
|
+
├── shared/ Constants, debug, events, messaging
|
|
179
|
+
├── client/
|
|
180
|
+
│ ├── general/ ForgeClient orchestrator, SourceCodeUpdater, types
|
|
181
|
+
│ ├── annotation/ AnnotationOverlay
|
|
182
|
+
│ ├── select-mode/ SelectModeController
|
|
183
|
+
│ └── design-mode/ DesignModeController
|
|
184
|
+
├── host/ ForgeHost, types
|
|
185
|
+
├── react/ useElementSelector, useDesignMode
|
|
186
|
+
└── build/ Vite plugin (supernovaDesignPlugin)
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
See [INTEGRATION.md](./INTEGRATION.md) for a detailed integration guide.
|
|
190
|
+
|
|
191
|
+
## License
|
|
192
|
+
|
|
193
|
+
MIT
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/build/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;AAClE,YAAY,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAA"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { parse as P } from "@babel/parser";
|
|
2
|
+
import y from "@babel/traverse";
|
|
3
|
+
import S from "@babel/generator";
|
|
4
|
+
import { relative as F } from "node:path";
|
|
5
|
+
const E = typeof y == "function" ? y : y.default, M = typeof S == "function" ? S : S.default;
|
|
6
|
+
function T(d) {
|
|
7
|
+
let r = 0;
|
|
8
|
+
for (let c = 0; c < d.length; c++) {
|
|
9
|
+
const s = d.charCodeAt(c);
|
|
10
|
+
r = (r << 5) - r + s, r = r & r;
|
|
11
|
+
}
|
|
12
|
+
return Math.abs(r).toString(36).substring(0, 8);
|
|
13
|
+
}
|
|
14
|
+
function B(d = {}) {
|
|
15
|
+
const { prefix: r = "forge" } = d, c = (s, i, u) => {
|
|
16
|
+
const a = T(`${s}:${i}:${u}`);
|
|
17
|
+
return `${r}-${a}-${i}-${u}`;
|
|
18
|
+
};
|
|
19
|
+
return { name: "forge-id-plugin", enforce: "pre", transform(s, i) {
|
|
20
|
+
if (!i.match(/\.(tsx?|jsx?)$/) || i.includes("node_modules"))
|
|
21
|
+
return null;
|
|
22
|
+
const u = F(process.cwd(), i).replace(/\\/g, "/");
|
|
23
|
+
try {
|
|
24
|
+
let a = function(e) {
|
|
25
|
+
const n = e.parent;
|
|
26
|
+
if (n.type === "VariableDeclarator" && n.id.type === "Identifier" && /^[A-Z]/.test(n.id.name))
|
|
27
|
+
return !0;
|
|
28
|
+
if (n.type === "CallExpression") {
|
|
29
|
+
const l = e.parentPath;
|
|
30
|
+
if (l) {
|
|
31
|
+
const f = l.parent;
|
|
32
|
+
if (f.type === "VariableDeclarator" && f.id.type === "Identifier" && /^[A-Z]/.test(f.id.name) || f.type === "ExportDefaultDeclaration")
|
|
33
|
+
return !0;
|
|
34
|
+
if (f.type === "CallExpression") {
|
|
35
|
+
const p = l.parentPath;
|
|
36
|
+
if (p) {
|
|
37
|
+
const t = p.parent;
|
|
38
|
+
if (t.type === "VariableDeclarator" && t.id.type === "Identifier" && /^[A-Z]/.test(t.id.name))
|
|
39
|
+
return !0;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return !1;
|
|
45
|
+
};
|
|
46
|
+
const x = P(s, { sourceType: "module", plugins: ["jsx", "typescript"] }), J = /* @__PURE__ */ new Set();
|
|
47
|
+
let b = !1, o = 0;
|
|
48
|
+
if (E(x, { FunctionDeclaration: { enter(e) {
|
|
49
|
+
e.node.id && /^[A-Z]/.test(e.node.id.name) && o++;
|
|
50
|
+
}, exit(e) {
|
|
51
|
+
e.node.id && /^[A-Z]/.test(e.node.id.name) && o--;
|
|
52
|
+
} }, ArrowFunctionExpression: { enter(e) {
|
|
53
|
+
a(e) && o++;
|
|
54
|
+
}, exit(e) {
|
|
55
|
+
a(e) && o--;
|
|
56
|
+
} }, FunctionExpression: { enter(e) {
|
|
57
|
+
a(e) && o++;
|
|
58
|
+
}, exit(e) {
|
|
59
|
+
a(e) && o--;
|
|
60
|
+
} }, JSXOpeningElement(e) {
|
|
61
|
+
if (e.node.name.type === "JSXIdentifier") {
|
|
62
|
+
const n = e.node.name.name, l = /^[A-Z]/.test(n);
|
|
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
|
+
return;
|
|
65
|
+
if (l && o > 0) {
|
|
66
|
+
const t = e.scope.getBinding(n);
|
|
67
|
+
if (t && t.scope.path.type !== "Program")
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
if (!e.node.attributes.some((t) => t.type === "JSXAttribute" && t.name.type === "JSXIdentifier" && t.name.name === "data-forge-id")) {
|
|
71
|
+
const t = e.node.loc?.start;
|
|
72
|
+
if (!t) return;
|
|
73
|
+
const I = e.parent, m = I.type === "JSXElement" ? I.loc?.end : e.node.loc?.end;
|
|
74
|
+
if (!m) return;
|
|
75
|
+
const A = c(i, t.line, t.column), v = { type: "JSXAttribute", name: { type: "JSXIdentifier", name: "data-forge-id" }, value: { type: "StringLiteral", value: A }, loc: e.node.loc }, h = { type: "JSXAttribute", name: { type: "JSXIdentifier", name: "data-component" }, value: { type: "StringLiteral", value: n }, loc: e.node.loc }, C = { 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 }, X = !l && o > 0, $ = e.node.attributes.some((g) => g.type === "JSXSpreadAttribute");
|
|
76
|
+
if (X && $) {
|
|
77
|
+
const g = e.node.attributes.findIndex((D) => D.type === "JSXSpreadAttribute");
|
|
78
|
+
e.node.attributes.splice(g, 0, v, h, C);
|
|
79
|
+
} else
|
|
80
|
+
e.node.attributes.push(v, h, C);
|
|
81
|
+
J.add(A), b = !0;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
} }), b) {
|
|
85
|
+
const e = M(x, {}, s);
|
|
86
|
+
return { code: e.code, map: e.map };
|
|
87
|
+
}
|
|
88
|
+
} catch {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
return null;
|
|
92
|
+
} };
|
|
93
|
+
}
|
|
94
|
+
export {
|
|
95
|
+
B as supernovaDesignPlugin
|
|
96
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Plugin } from "vite";
|
|
2
|
+
export interface ForgeIdPluginOptions {
|
|
3
|
+
/** Prefix for forge IDs, defaults to 'forge' */
|
|
4
|
+
prefix?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function supernovaDesignPlugin(options?: ForgeIdPluginOptions): Plugin;
|
|
7
|
+
//# sourceMappingURL=vite-plugin-forge-ids.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite-plugin-forge-ids.d.ts","sourceRoot":"","sources":["../../src/build/vite-plugin-forge-ids.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAW7B,MAAM,WAAW,oBAAoB;IACnC,gDAAgD;IAChD,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAaD,wBAAgB,qBAAqB,CAAC,OAAO,GAAE,oBAAyB,GAAG,MAAM,CAuRhF"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { ParentMessenger } from "../../shared/messaging.js";
|
|
2
|
+
import type { RestoreAnnotationData } from "../../shared/events.js";
|
|
3
|
+
/**
|
|
4
|
+
* Full-screen overlay for creating and managing annotations.
|
|
5
|
+
* Supports single-click (one element) and shift+drag (multi-element) selection.
|
|
6
|
+
*/
|
|
7
|
+
export declare class AnnotationOverlay {
|
|
8
|
+
private active;
|
|
9
|
+
private messenger;
|
|
10
|
+
private hoverOverlay;
|
|
11
|
+
private componentTooltip;
|
|
12
|
+
private hitTestOverlay;
|
|
13
|
+
private dragRect;
|
|
14
|
+
private dragHighlights;
|
|
15
|
+
private annotationHighlights;
|
|
16
|
+
private dots;
|
|
17
|
+
private isDragging;
|
|
18
|
+
private dragStartX;
|
|
19
|
+
private dragStartY;
|
|
20
|
+
private dragScopeParent;
|
|
21
|
+
private hoverSuppressed;
|
|
22
|
+
private activeHighlightDotId;
|
|
23
|
+
constructor(messenger: ParentMessenger);
|
|
24
|
+
/** Activates annotation mode: creates overlays and starts listening for events. */
|
|
25
|
+
activate(): void;
|
|
26
|
+
/** Deactivates annotation mode and cleans up overlays. */
|
|
27
|
+
deactivate(): void;
|
|
28
|
+
/** Removes a single annotation dot by ID. */
|
|
29
|
+
removeDot(annotationId: string): void;
|
|
30
|
+
/** Removes all annotation dots from the overlay. */
|
|
31
|
+
removeAllDots(): void;
|
|
32
|
+
/** Recreates dots from annotation data sent by the host. */
|
|
33
|
+
restoreDots(annotations: RestoreAnnotationData[]): void;
|
|
34
|
+
private markersVisible;
|
|
35
|
+
/** Toggles visibility of all annotation marker badges. */
|
|
36
|
+
toggleMarkers(): void;
|
|
37
|
+
/** Explicitly sets marker badge visibility. */
|
|
38
|
+
setMarkersVisible(visible: boolean): void;
|
|
39
|
+
/** Repositions all badge dots and visible highlights to follow their anchored elements. */
|
|
40
|
+
private repositionAll;
|
|
41
|
+
private createHitTestOverlay;
|
|
42
|
+
private removeHitTestOverlay;
|
|
43
|
+
private showHoverOverlay;
|
|
44
|
+
private removeHoverOverlay;
|
|
45
|
+
private highlightAnnotationElements;
|
|
46
|
+
private applySelectedStyle;
|
|
47
|
+
private applyDefaultStyle;
|
|
48
|
+
private resolveLocator;
|
|
49
|
+
private highlightLocators;
|
|
50
|
+
private clearAnnotationHighlights;
|
|
51
|
+
/** Computes the bounding rect encompassing all elements referenced by locators. */
|
|
52
|
+
private getAnchorRect;
|
|
53
|
+
private getComponentPath;
|
|
54
|
+
private showComponentTooltip;
|
|
55
|
+
private removeComponentTooltip;
|
|
56
|
+
private showDragRect;
|
|
57
|
+
private removeDragRect;
|
|
58
|
+
private showDragHighlights;
|
|
59
|
+
private clearDragHighlights;
|
|
60
|
+
private createDot;
|
|
61
|
+
private createDotAtPosition;
|
|
62
|
+
/** Updates the displayed order numbers on all badges. */
|
|
63
|
+
updateOrders(orders: Record<string, number>): void;
|
|
64
|
+
private elementAtPoint;
|
|
65
|
+
private escapeToSvgRoot;
|
|
66
|
+
private findTopmostWithSameForgeId;
|
|
67
|
+
private findForgeIdParent;
|
|
68
|
+
private elementsInRect;
|
|
69
|
+
private handleMouseMove;
|
|
70
|
+
private static DRAG_THRESHOLD;
|
|
71
|
+
private handleMouseDown;
|
|
72
|
+
private handleMouseUp;
|
|
73
|
+
private handleClick;
|
|
74
|
+
private handleKeyDown;
|
|
75
|
+
private handleKeyUp;
|
|
76
|
+
private pendingAnnotations;
|
|
77
|
+
/** Called by ForgeClient when the host confirms an annotation. */
|
|
78
|
+
confirmDot(annotationId: string, order: number): void;
|
|
79
|
+
/** Called by ForgeClient when the host cancels/deletes a pending annotation. */
|
|
80
|
+
cancelPending(annotationId: string): void;
|
|
81
|
+
private createAnnotationFromElements;
|
|
82
|
+
private handleDocumentLeave;
|
|
83
|
+
private addListeners;
|
|
84
|
+
private removeListeners;
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=AnnotationOverlay.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AnnotationOverlay.d.ts","sourceRoot":"","sources":["../../../src/client/annotation/AnnotationOverlay.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { ParentMessenger } from "../../shared/messaging.js";
|
|
2
|
+
import type { ComponentRegistry } from "../general/ComponentRegistry.js";
|
|
3
|
+
import type { SelectModeController } from "../select-mode/SelectModeController.js";
|
|
4
|
+
/**
|
|
5
|
+
* Manages design-mode interactions: element selection, prop extraction,
|
|
6
|
+
* visual highlighting, and source code updates via Babel AST.
|
|
7
|
+
*/
|
|
8
|
+
export declare class DesignModeController {
|
|
9
|
+
private messenger;
|
|
10
|
+
private componentRegistry;
|
|
11
|
+
private selectController;
|
|
12
|
+
private selectedElement;
|
|
13
|
+
private sourceCache;
|
|
14
|
+
constructor(messenger: ParentMessenger, componentRegistry: ComponentRegistry, selectController: SelectModeController);
|
|
15
|
+
getSelectedElement(): HTMLElement | null;
|
|
16
|
+
/** Removes the purple outline from the currently selected element. */
|
|
17
|
+
clearSelection(): void;
|
|
18
|
+
/**
|
|
19
|
+
* Handles a design-mode click on a target element.
|
|
20
|
+
* Selects the element, extracts props, and notifies the host.
|
|
21
|
+
*/
|
|
22
|
+
handleClick(target: HTMLElement): void;
|
|
23
|
+
/** Updates the text content (children) of a forge element via source AST. */
|
|
24
|
+
updateText(forgeId: string, newText: string): void;
|
|
25
|
+
/**
|
|
26
|
+
* Updates a property on a forge element by modifying the source AST,
|
|
27
|
+
* writing back to the dev server, and triggering HMR.
|
|
28
|
+
*/
|
|
29
|
+
updateProperty(forgeId: string, propName: string, newValue: any): Promise<void>;
|
|
30
|
+
private applyHighlight;
|
|
31
|
+
private removeHighlight;
|
|
32
|
+
private extractPropValues;
|
|
33
|
+
private getFiberFromElement;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=DesignModeController.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DesignModeController.d.ts","sourceRoot":"","sources":["../../../src/client/design-mode/DesignModeController.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAChE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAA;AACxE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wCAAwC,CAAA;AAElF;;;GAGG;AACH,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,SAAS,CAAiB;IAClC,OAAO,CAAC,iBAAiB,CAAmB;IAC5C,OAAO,CAAC,gBAAgB,CAAsB;IAC9C,OAAO,CAAC,eAAe,CAA2B;IAClD,OAAO,CAAC,WAAW,CAA4B;gBAG7C,SAAS,EAAE,eAAe,EAC1B,iBAAiB,EAAE,iBAAiB,EACpC,gBAAgB,EAAE,oBAAoB;IAOxC,kBAAkB,IAAI,WAAW,GAAG,IAAI;IAIxC,sEAAsE;IACtE,cAAc,IAAI,IAAI;IAOtB;;;OAGG;IACH,WAAW,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI;IAwCtC,6EAA6E;IAC7E,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI;IAIlD;;;OAGG;IACG,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IAmDrF,OAAO,CAAC,cAAc;IAKtB,OAAO,CAAC,eAAe;IAKvB,OAAO,CAAC,iBAAiB;IA4BzB,OAAO,CAAC,mBAAmB;CAM5B"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type PropDefinition = import("../../shared/events.js").PropDefinition;
|
|
2
|
+
export type ComponentDefinition = import("../../shared/events.js").ComponentDefinition;
|
|
3
|
+
export declare class ComponentRegistry {
|
|
4
|
+
private registry;
|
|
5
|
+
/** Registers a single component definition by name. */
|
|
6
|
+
register(name: string, definition: ComponentDefinition): void;
|
|
7
|
+
/** Registers multiple component definitions from a record. */
|
|
8
|
+
registerAll(definitions: Record<string, ComponentDefinition>): void;
|
|
9
|
+
/**
|
|
10
|
+
* Returns editable prop definitions for a component.
|
|
11
|
+
* Tries exact match, then case-insensitive, then HTML element mapping.
|
|
12
|
+
*/
|
|
13
|
+
getEditableProps(componentName: string): PropDefinition[];
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=ComponentRegistry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ComponentRegistry.d.ts","sourceRoot":"","sources":["../../../src/client/general/ComponentRegistry.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GAAG,OAAO,wBAAwB,EAAE,cAAc,CAAA;AAC5E,MAAM,MAAM,mBAAmB,GAAG,OAAO,wBAAwB,EAAE,mBAAmB,CAAA;AAEtF,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,QAAQ,CAAyC;IAEzD,uDAAuD;IACvD,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,mBAAmB,GAAG,IAAI;IAI7D,8DAA8D;IAC9D,WAAW,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,GAAG,IAAI;IAMnE;;;OAGG;IACH,gBAAgB,CAAC,aAAa,EAAE,MAAM,GAAG,cAAc,EAAE;CA+B1D"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { ForgeClientOptions } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Core client-side orchestrator that runs inside the child iframe.
|
|
4
|
+
* Singleton — use `ForgeClient.getInstance()` to access.
|
|
5
|
+
*
|
|
6
|
+
* Coordinates between SelectModeController, DesignModeController,
|
|
7
|
+
* and AnnotationOverlay based on messages from the host.
|
|
8
|
+
*/
|
|
9
|
+
export declare class ForgeClient {
|
|
10
|
+
private static instance;
|
|
11
|
+
private messenger;
|
|
12
|
+
private selectMode;
|
|
13
|
+
private designMode;
|
|
14
|
+
private hoverDisabled;
|
|
15
|
+
private componentRegistry;
|
|
16
|
+
private annotationOverlay;
|
|
17
|
+
private selectController;
|
|
18
|
+
private designController;
|
|
19
|
+
private onError?;
|
|
20
|
+
private constructor();
|
|
21
|
+
/** Returns the singleton ForgeClient instance, creating it if necessary. */
|
|
22
|
+
static getInstance(options?: ForgeClientOptions): ForgeClient;
|
|
23
|
+
/** Enables or disables annotation mode. Useful for console-driven testing without a host. */
|
|
24
|
+
enableAnnotationMode(enabled: boolean): void;
|
|
25
|
+
private setupMessageListener;
|
|
26
|
+
private setSelectMode;
|
|
27
|
+
private setDesignMode;
|
|
28
|
+
private setAnnotationMode;
|
|
29
|
+
private handleSelectClick;
|
|
30
|
+
private handleDesignClick;
|
|
31
|
+
private sendReady;
|
|
32
|
+
private setupForgeIdPropagation;
|
|
33
|
+
private getFiberFromElement;
|
|
34
|
+
private propagateForgeIdFromFiber;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=ForgeClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ForgeClient.d.ts","sourceRoot":"","sources":["../../../src/client/general/ForgeClient.ts"],"names":[],"mappings":"AAQA,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,UAAU,CAAQ;IAC1B,OAAO,CAAC,UAAU,CAAQ;IAC1B,OAAO,CAAC,aAAa,CAAQ;IAC7B,OAAO,CAAC,iBAAiB,CAAmB;IAC5C,OAAO,CAAC,iBAAiB,CAAiC;IAC1D,OAAO,CAAC,gBAAgB,CAAsB;IAC9C,OAAO,CAAC,gBAAgB,CAAsB;IAC9C,OAAO,CAAC,OAAO,CAAC,CAAwB;IAExC,OAAO;IA4BP,4EAA4E;IAC5E,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,kBAAkB,GAAG,WAAW;IAO7D,6FAA6F;IAC7F,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAM5C,OAAO,CAAC,oBAAoB;IAgE5B,OAAO,CAAC,aAAa;IAerB,OAAO,CAAC,aAAa;IAiBrB,OAAO,CAAC,iBAAiB;IAezB,OAAO,CAAC,iBAAiB;IAKzB,OAAO,CAAC,iBAAiB;IAOzB,OAAO,CAAC,SAAS;IAQjB,OAAO,CAAC,uBAAuB;IAkB/B,OAAO,CAAC,mBAAmB;IAO3B,OAAO,CAAC,yBAAyB;CAkBlC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Updates a JSX element's property in the source code using Babel AST traversal.
|
|
3
|
+
* Matches elements by `data-forge-id`, or falls back to source position.
|
|
4
|
+
* Returns the updated source string, or the original source if no changes were made.
|
|
5
|
+
*/
|
|
6
|
+
export declare function updateSourceAST(source: string, forgeId: string, propName: string, newValue: any, fallbackSourcePos?: string | null): string;
|
|
7
|
+
/**
|
|
8
|
+
* Fetches source code from the dev server's read-source endpoint.
|
|
9
|
+
*/
|
|
10
|
+
export declare function fetchSource(filePath: string): Promise<string | null>;
|
|
11
|
+
/**
|
|
12
|
+
* Writes updated source code back to the dev server, triggering HMR.
|
|
13
|
+
*/
|
|
14
|
+
export declare function writeSource(filePath: string, source: string): Promise<boolean>;
|
|
15
|
+
//# sourceMappingURL=SourceCodeUpdater.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SourceCodeUpdater.d.ts","sourceRoot":"","sources":["../../../src/client/general/SourceCodeUpdater.ts"],"names":[],"mappings":"AA8CA;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,GAAG,EACb,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,GAChC,MAAM,CAqDR;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"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gets the parent element, crossing shadow DOM boundaries.
|
|
3
|
+
*/
|
|
4
|
+
export declare function getParentElement(element: Element): Element | null;
|
|
5
|
+
/**
|
|
6
|
+
* Finds the closest ancestor matching a selector, crossing shadow DOM boundaries.
|
|
7
|
+
*/
|
|
8
|
+
export declare function closestCrossingShadow(element: Element, selector: string): Element | null;
|
|
9
|
+
/**
|
|
10
|
+
* Gets a readable CSS-selector-like path for an element (e.g., "article > section > p").
|
|
11
|
+
*/
|
|
12
|
+
export declare function getElementPath(target: HTMLElement, maxDepth?: number): string;
|
|
13
|
+
/**
|
|
14
|
+
* Identifies an element and returns a human-readable name + path.
|
|
15
|
+
*/
|
|
16
|
+
export declare function identifyElement(target: HTMLElement): {
|
|
17
|
+
name: string;
|
|
18
|
+
path: string;
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=element-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"element-utils.d.ts","sourceRoot":"","sources":["../../../src/client/general/element-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,GAAG,IAAI,CAKjE;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI,CAOxF;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,WAAW,EAAE,QAAQ,SAAI,GAAG,MAAM,CAgCxE;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,WAAW,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CA+FnF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Creates a positioned overlay div suitable for element highlighting. */
|
|
2
|
+
export declare function createOverlayElement(rect: DOMRect, borderColor: string, bgColor: string, borderStyle?: "solid" | "dashed"): HTMLDivElement;
|
|
3
|
+
/** Shows a blue selection overlay around the given element. */
|
|
4
|
+
export declare function showOverlay(element: HTMLElement): void;
|
|
5
|
+
export declare function removeOverlay(): void;
|
|
6
|
+
/** Returns the full-screen hit-test overlay (creates if needed). */
|
|
7
|
+
export declare function createHitTestOverlay(): HTMLDivElement;
|
|
8
|
+
export declare function removeHitTestOverlay(): void;
|
|
9
|
+
//# sourceMappingURL=overlay.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"overlay.d.ts","sourceRoot":"","sources":["../../../src/client/general/overlay.ts"],"names":[],"mappings":"AAKA,0EAA0E;AAC1E,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,OAAO,EACb,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,EACf,WAAW,GAAE,OAAO,GAAG,QAAkB,GACxC,cAAc,CAehB;AAED,+DAA+D;AAC/D,wBAAgB,WAAW,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,CAMtD;AAED,wBAAgB,aAAa,IAAI,IAAI,CAKpC;AAED,oEAAoE;AACpE,wBAAgB,oBAAoB,IAAI,cAAc,CAkBrD;AAED,wBAAgB,oBAAoB,IAAI,IAAI,CAK3C"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
interface ComponentType {
|
|
2
|
+
name?: string;
|
|
3
|
+
displayName?: string;
|
|
4
|
+
render?: {
|
|
5
|
+
name?: string;
|
|
6
|
+
displayName?: string;
|
|
7
|
+
};
|
|
8
|
+
type?: ComponentType;
|
|
9
|
+
_context?: {
|
|
10
|
+
displayName?: string;
|
|
11
|
+
};
|
|
12
|
+
_status?: number;
|
|
13
|
+
_result?: ComponentType;
|
|
14
|
+
$$typeof?: symbol;
|
|
15
|
+
prototype?: {
|
|
16
|
+
isReactComponent?: boolean;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
interface ReactFiber {
|
|
20
|
+
tag: number;
|
|
21
|
+
type: ComponentType | string | null;
|
|
22
|
+
elementType: ComponentType | null;
|
|
23
|
+
return: ReactFiber | null;
|
|
24
|
+
child?: ReactFiber | null;
|
|
25
|
+
sibling?: ReactFiber | null;
|
|
26
|
+
_debugSource?: {
|
|
27
|
+
fileName: string;
|
|
28
|
+
lineNumber: number;
|
|
29
|
+
columnNumber?: number;
|
|
30
|
+
};
|
|
31
|
+
_debugOwner?: ReactFiber;
|
|
32
|
+
memoizedProps?: Record<string, unknown>;
|
|
33
|
+
stateNode?: unknown;
|
|
34
|
+
}
|
|
35
|
+
/** Detects whether the current page is a React application. */
|
|
36
|
+
export declare function isReactPage(): boolean;
|
|
37
|
+
/** Extracts the React fiber node from a DOM element. Works with React 16.8+ through 19.x. */
|
|
38
|
+
export declare function getFiberFromElement(element: HTMLElement): ReactFiber | null;
|
|
39
|
+
export interface ReactComponentInfo {
|
|
40
|
+
path: string | null;
|
|
41
|
+
components: string[];
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Walks up the React fiber tree from a DOM element and collects component names.
|
|
45
|
+
* Returns an info object with the component path and individual names.
|
|
46
|
+
*/
|
|
47
|
+
export declare function getReactComponentName(element: HTMLElement, maxComponents?: number, maxDepth?: number): ReactComponentInfo;
|
|
48
|
+
export {};
|
|
49
|
+
//# sourceMappingURL=react-detection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react-detection.d.ts","sourceRoot":"","sources":["../../../src/client/general/react-detection.ts"],"names":[],"mappings":"AAKA,UAAU,aAAa;IACrB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,MAAM,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;IAChD,IAAI,CAAC,EAAE,aAAa,CAAA;IACpB,QAAQ,CAAC,EAAE;QAAE,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;IACnC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,aAAa,CAAA;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,SAAS,CAAC,EAAE;QAAE,gBAAgB,CAAC,EAAE,OAAO,CAAA;KAAE,CAAA;CAC3C;AAED,UAAU,UAAU;IAClB,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,aAAa,GAAG,MAAM,GAAG,IAAI,CAAA;IACnC,WAAW,EAAE,aAAa,GAAG,IAAI,CAAA;IACjC,MAAM,EAAE,UAAU,GAAG,IAAI,CAAA;IACzB,KAAK,CAAC,EAAE,UAAU,GAAG,IAAI,CAAA;IACzB,OAAO,CAAC,EAAE,UAAU,GAAG,IAAI,CAAA;IAC3B,YAAY,CAAC,EAAE;QACb,QAAQ,EAAE,MAAM,CAAA;QAChB,UAAU,EAAE,MAAM,CAAA;QAClB,YAAY,CAAC,EAAE,MAAM,CAAA;KACtB,CAAA;IACD,WAAW,CAAC,EAAE,UAAU,CAAA;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACvC,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB;AAmED,+DAA+D;AAC/D,wBAAgB,WAAW,IAAI,OAAO,CAmDrC;AAID,6FAA6F;AAC7F,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,WAAW,GAAG,UAAU,GAAG,IAAI,CA0B3E;AA0FD,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,UAAU,EAAE,MAAM,EAAE,CAAA;CACrB;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,WAAW,EACpB,aAAa,SAAiB,EAC9B,QAAQ,SAAsB,GAC7B,kBAAkB,CAoCpB"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ParentMessenger } from "../../shared/messaging.js";
|
|
2
|
+
import type { ComponentRegistry } from "./ComponentRegistry.js";
|
|
3
|
+
import type { AnnotationOverlay } from "../annotation/AnnotationOverlay.js";
|
|
4
|
+
/** Options for ForgeClient initialization. */
|
|
5
|
+
export interface ForgeClientOptions {
|
|
6
|
+
/** Called when an internal error occurs in the client. */
|
|
7
|
+
onError?: (error: Error) => void;
|
|
8
|
+
}
|
|
9
|
+
/** Shared context passed to controllers by ForgeClient. */
|
|
10
|
+
export interface ForgeClientContext {
|
|
11
|
+
messenger: ParentMessenger;
|
|
12
|
+
componentRegistry: ComponentRegistry;
|
|
13
|
+
annotationOverlay: AnnotationOverlay | null;
|
|
14
|
+
getSelectMode(): boolean;
|
|
15
|
+
getDesignMode(): boolean;
|
|
16
|
+
}
|
|
17
|
+
/** Callbacks required by SelectModeController to coordinate with ForgeClient. */
|
|
18
|
+
export interface SelectModeCallbacks {
|
|
19
|
+
getSelectMode(): boolean;
|
|
20
|
+
getDesignMode(): boolean;
|
|
21
|
+
getHoverDisabled(): boolean;
|
|
22
|
+
getSelectedDesignElement(): HTMLElement | null;
|
|
23
|
+
onSelectClick(target: HTMLElement): void;
|
|
24
|
+
onDesignClick(target: HTMLElement): void;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/client/general/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAChE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC/D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAA;AAE3E,8CAA8C;AAC9C,MAAM,WAAW,kBAAkB;IACjC,0DAA0D;IAC1D,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAA;CACjC;AAED,2DAA2D;AAC3D,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,eAAe,CAAA;IAC1B,iBAAiB,EAAE,iBAAiB,CAAA;IACpC,iBAAiB,EAAE,iBAAiB,GAAG,IAAI,CAAA;IAC3C,aAAa,IAAI,OAAO,CAAA;IACxB,aAAa,IAAI,OAAO,CAAA;CACzB;AAED,iFAAiF;AACjF,MAAM,WAAW,mBAAmB;IAClC,aAAa,IAAI,OAAO,CAAA;IACxB,aAAa,IAAI,OAAO,CAAA;IACxB,gBAAgB,IAAI,OAAO,CAAA;IAC3B,wBAAwB,IAAI,WAAW,GAAG,IAAI,CAAA;IAC9C,aAAa,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,CAAA;IACxC,aAAa,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,CAAA;CACzC"}
|