@omnipad/vue 0.1.1-alpha.0 → 0.1.1-alpha.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.
- package/dist/omnipad-vue.mjs +191 -666
- package/dist/omnipad-vue.umd.js +1 -1
- package/package.json +2 -2
package/dist/omnipad-vue.mjs
CHANGED
|
@@ -1,560 +1,85 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
/** Area responsible for receiving signals and simulating DOM events */
|
|
7
|
-
TARGET_ZONE: "target-zone",
|
|
8
|
-
// --- Widgets ---
|
|
9
|
-
/** Simulates a physical keyboard key press */
|
|
10
|
-
KEYBOARD_BUTTON: "keyboard-button",
|
|
11
|
-
/** The top-level managed container */
|
|
12
|
-
ROOT_LAYER: "root-layer"
|
|
13
|
-
}, f = {
|
|
14
|
-
KEYDOWN: "keydown",
|
|
15
|
-
KEYUP: "keyup",
|
|
16
|
-
POINTER: "pointer",
|
|
17
|
-
POINTERMOVE: "pointermove",
|
|
18
|
-
POINTERDOWN: "pointerdown",
|
|
19
|
-
POINTERUP: "pointerup",
|
|
20
|
-
MOUSE: "mouse",
|
|
21
|
-
MOUSEMOVE: "mousemove",
|
|
22
|
-
MOUSEDOWN: "mousedown",
|
|
23
|
-
MOUSEUP: "mouseup",
|
|
24
|
-
CLICK: "click"
|
|
25
|
-
}, W = {
|
|
26
|
-
/** The key used to propagate Parent IDs through the component tree */
|
|
27
|
-
PARENT_ID_KEY: "omnipad-parent-id-link"
|
|
28
|
-
}, X = (e, t = 2) => {
|
|
29
|
-
const n = Math.pow(10, t);
|
|
30
|
-
return Math.round(e * n) / n;
|
|
31
|
-
}, A = (e, t) => X(e * t / 100), z = (e, t) => t === 0 ? 0 : X(e * 100 / t), H = (e, t) => {
|
|
32
|
-
let n = document.elementFromPoint(e, t);
|
|
33
|
-
for (; n && n.shadowRoot; ) {
|
|
34
|
-
const i = n.shadowRoot.elementFromPoint(e, t);
|
|
35
|
-
if (!i || i === n) break;
|
|
36
|
-
n = i;
|
|
37
|
-
}
|
|
38
|
-
return n;
|
|
39
|
-
}, J = () => {
|
|
40
|
-
let e = document.activeElement;
|
|
41
|
-
for (; e && e.shadowRoot && e.shadowRoot.activeElement; )
|
|
42
|
-
e = e.shadowRoot.activeElement;
|
|
43
|
-
return e;
|
|
44
|
-
}, Ee = (e) => {
|
|
45
|
-
J() !== e && (e.hasAttribute("tabindex") || e.setAttribute("tabindex", "-1"), e.focus());
|
|
46
|
-
}, Pe = (e, t) => {
|
|
47
|
-
const n = new KeyboardEvent(e, {
|
|
48
|
-
...t,
|
|
49
|
-
which: t.keyCode,
|
|
50
|
-
// Support for legacy Flash engines
|
|
51
|
-
bubbles: !0,
|
|
52
|
-
cancelable: !0,
|
|
53
|
-
view: window
|
|
54
|
-
});
|
|
55
|
-
window.dispatchEvent(n);
|
|
56
|
-
}, be = (e, t, n, i = {}) => {
|
|
57
|
-
const o = H(t, n);
|
|
58
|
-
if (!o) return;
|
|
59
|
-
const s = {
|
|
60
|
-
bubbles: !0,
|
|
61
|
-
cancelable: !0,
|
|
62
|
-
composed: !0,
|
|
63
|
-
// Crucial for piercing Shadow DOM boundaries
|
|
64
|
-
clientX: t,
|
|
65
|
-
clientY: n,
|
|
66
|
-
view: window,
|
|
67
|
-
...i
|
|
68
|
-
};
|
|
69
|
-
if (e.startsWith("pointer")) {
|
|
70
|
-
o.dispatchEvent(
|
|
71
|
-
new PointerEvent(e, {
|
|
72
|
-
isPrimary: !0,
|
|
73
|
-
pointerId: 1,
|
|
74
|
-
pointerType: "mouse",
|
|
75
|
-
// Emulate mouse behavior for Flash MouseOver/Down logic
|
|
76
|
-
...s
|
|
77
|
-
})
|
|
78
|
-
);
|
|
79
|
-
const r = e.replace("pointer", "mouse");
|
|
80
|
-
o.dispatchEvent(new MouseEvent(r, s));
|
|
81
|
-
} else
|
|
82
|
-
o.dispatchEvent(new MouseEvent(e, s));
|
|
83
|
-
}, Ie = (e = "omnipad") => {
|
|
84
|
-
const t = Date.now().toString(36), n = Math.random().toString(36).substring(2, 6);
|
|
85
|
-
return `${e}-${t}-${n}`;
|
|
86
|
-
}, V = (e) => {
|
|
87
|
-
if (!e) return {};
|
|
88
|
-
const t = {};
|
|
89
|
-
t.position = "absolute", ["left", "top", "right", "bottom", "width", "height"].forEach((o) => {
|
|
90
|
-
const s = e[o];
|
|
91
|
-
s !== void 0 && (t[o] = typeof s == "number" ? `${s}px` : s);
|
|
92
|
-
}), e.zIndex !== void 0 && (t.zIndex = e.zIndex);
|
|
93
|
-
const i = {
|
|
94
|
-
"top-left": "translate(0, 0)",
|
|
95
|
-
"top-center": "translate(-50%, 0)",
|
|
96
|
-
"top-right": "translate(-100%, 0)",
|
|
97
|
-
"center-left": "translate(0, -50%)",
|
|
98
|
-
center: "translate(-50%, -50%)",
|
|
99
|
-
"center-right": "translate(-100%, -50%)",
|
|
100
|
-
"bottom-left": "translate(0, -100%)",
|
|
101
|
-
"bottom-center": "translate(-50%, -100%)",
|
|
102
|
-
"bottom-right": "translate(-100%, -100%)"
|
|
103
|
-
};
|
|
104
|
-
return e.anchor && (t.transform = i[e.anchor]), t;
|
|
105
|
-
}, _e = class {
|
|
106
|
-
constructor() {
|
|
107
|
-
g(this, "listeners", /* @__PURE__ */ new Set());
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Registers a callback function to be executed whenever data is emitted.
|
|
111
|
-
*
|
|
112
|
-
* @param fn - The callback function.
|
|
113
|
-
* @returns A function that, when called, unsubscribes the listener.
|
|
114
|
-
*/
|
|
115
|
-
subscribe(e) {
|
|
116
|
-
return this.listeners.add(e), () => this.listeners.delete(e);
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Broadcasts the provided data to all registered listeners.
|
|
120
|
-
* Each listener is executed within a try-catch block to ensure that
|
|
121
|
-
* an error in one subscriber doesn't prevent others from receiving the signal.
|
|
122
|
-
*
|
|
123
|
-
* @param data - The payload to be sent to all subscribers.
|
|
124
|
-
*/
|
|
125
|
-
emit(e) {
|
|
126
|
-
this.listeners.forEach((t) => {
|
|
127
|
-
try {
|
|
128
|
-
t(e);
|
|
129
|
-
} catch (n) {
|
|
130
|
-
console.error("[OmniPad-Core] Emitter callback error:", n);
|
|
131
|
-
}
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Removes all listeners and clears the subscription set.
|
|
136
|
-
* Essential for preventing memory leaks when an Entity is destroyed.
|
|
137
|
-
*/
|
|
138
|
-
clear() {
|
|
139
|
-
this.listeners.clear();
|
|
140
|
-
}
|
|
141
|
-
}, R = class {
|
|
142
|
-
constructor(e, t, n, i) {
|
|
143
|
-
g(this, "uid"), g(this, "type"), g(this, "config"), g(this, "state"), g(this, "rect", null), g(this, "stateEmitter", new _e()), this.uid = e, this.type = t, this.config = n, this.state = i;
|
|
144
|
-
}
|
|
145
|
-
// --- IObservable Implementation ---
|
|
146
|
-
subscribe(e) {
|
|
147
|
-
return e(this.state), this.stateEmitter.subscribe(e);
|
|
148
|
-
}
|
|
149
|
-
// --- State Management ---
|
|
150
|
-
/**
|
|
151
|
-
* Updates the internal state and notifies all subscribers.
|
|
152
|
-
*
|
|
153
|
-
* @param partialState - Partial object containing updated state values.
|
|
154
|
-
*/
|
|
155
|
-
setState(e) {
|
|
156
|
-
this.state = { ...this.state, ...e }, this.stateEmitter.emit(this.state);
|
|
157
|
-
}
|
|
158
|
-
// --- Lifecycle ---
|
|
159
|
-
destroy() {
|
|
160
|
-
this.reset(), this.stateEmitter.clear(), Z.getInstance().unregister(this.uid);
|
|
161
|
-
}
|
|
162
|
-
updateRect(e) {
|
|
163
|
-
this.rect = e;
|
|
164
|
-
}
|
|
165
|
-
updateConfig(e) {
|
|
166
|
-
this.config = { ...this.config, ...e }, this.stateEmitter.emit(this.state);
|
|
167
|
-
}
|
|
168
|
-
getState() {
|
|
169
|
-
return this.state;
|
|
170
|
-
}
|
|
171
|
-
getConfig() {
|
|
172
|
-
return this.config;
|
|
173
|
-
}
|
|
174
|
-
}, B = /* @__PURE__ */ Symbol.for("omnipad.registry.instance"), Z = class Q {
|
|
175
|
-
/**
|
|
176
|
-
* Private constructor to enforce singleton pattern.
|
|
177
|
-
*/
|
|
178
|
-
constructor() {
|
|
179
|
-
g(this, "entities", /* @__PURE__ */ new Map());
|
|
180
|
-
}
|
|
181
|
-
/**
|
|
182
|
-
* Retrieves the global instance of the Registry.
|
|
183
|
-
* Uses globalThis to ensure the instance is unique even if the library is loaded multiple times.
|
|
184
|
-
*/
|
|
185
|
-
static getInstance() {
|
|
186
|
-
const t = globalThis;
|
|
187
|
-
return t[B] || (t[B] = new Q()), t[B];
|
|
188
|
-
}
|
|
189
|
-
register(t) {
|
|
190
|
-
if (!t.uid) {
|
|
191
|
-
console.warn("[OmniPad-Core] Registry: Attempted to register entity without UID.", t);
|
|
192
|
-
return;
|
|
193
|
-
}
|
|
194
|
-
this.entities.has(t.uid), this.entities.set(t.uid, t);
|
|
195
|
-
}
|
|
196
|
-
unregister(t) {
|
|
197
|
-
this.entities.has(t) && this.entities.delete(t);
|
|
198
|
-
}
|
|
199
|
-
getEntity(t) {
|
|
200
|
-
return this.entities.get(t);
|
|
201
|
-
}
|
|
202
|
-
getAllEntities() {
|
|
203
|
-
return Array.from(this.entities.values());
|
|
204
|
-
}
|
|
205
|
-
getEntitiesByRoot(t) {
|
|
206
|
-
const n = this.getAllEntities();
|
|
207
|
-
if (!t) return n;
|
|
208
|
-
if (!this.entities.get(t))
|
|
209
|
-
return console.warn(`[OmniPad-Core] Registry: Root entity ${t} not found.`), [];
|
|
210
|
-
const o = /* @__PURE__ */ new Map();
|
|
211
|
-
n.forEach((c) => {
|
|
212
|
-
if (c instanceof R) {
|
|
213
|
-
const l = c.getConfig();
|
|
214
|
-
l.parentId && (o.has(l.parentId) || o.set(l.parentId, []), o.get(l.parentId).push(c));
|
|
215
|
-
}
|
|
216
|
-
});
|
|
217
|
-
const s = [], r = [t], a = /* @__PURE__ */ new Set();
|
|
218
|
-
for (; r.length > 0; ) {
|
|
219
|
-
const c = r.shift();
|
|
220
|
-
if (a.has(c)) continue;
|
|
221
|
-
a.add(c);
|
|
222
|
-
const l = this.entities.get(c);
|
|
223
|
-
if (l) {
|
|
224
|
-
s.push(l);
|
|
225
|
-
const u = o.get(c);
|
|
226
|
-
u && u.forEach((m) => r.push(m.uid));
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
return s;
|
|
230
|
-
}
|
|
231
|
-
destroyByRoot(t) {
|
|
232
|
-
const n = this.getEntitiesByRoot(t);
|
|
233
|
-
for (let i = n.length - 1; i >= 0; i--) {
|
|
234
|
-
const o = n[i];
|
|
235
|
-
try {
|
|
236
|
-
o.destroy();
|
|
237
|
-
} catch (s) {
|
|
238
|
-
console.error(`[OmniPad-Core] Error during destroyByRoot at ${o.uid}:`, s);
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
clear() {
|
|
243
|
-
this.entities.clear();
|
|
244
|
-
}
|
|
245
|
-
resetAll() {
|
|
246
|
-
this.entities.forEach((t) => {
|
|
247
|
-
"reset" in t && t.reset();
|
|
248
|
-
});
|
|
249
|
-
}
|
|
250
|
-
debugGetSnapshot() {
|
|
251
|
-
return new Map(this.entities);
|
|
252
|
-
}
|
|
253
|
-
}, Te = {
|
|
254
|
-
isDynamicActive: !1,
|
|
255
|
-
dynamicPointerId: null,
|
|
256
|
-
dynamicPosition: { x: 0, y: 0 }
|
|
257
|
-
}, Re = class extends R {
|
|
258
|
-
constructor(e, t) {
|
|
259
|
-
super(e, v.INPUT_ZONE, t, Te);
|
|
260
|
-
}
|
|
261
|
-
onPointerDown(e) {
|
|
262
|
-
if (this.state.isDynamicActive || e.target !== e.currentTarget) return;
|
|
263
|
-
e.cancelable && e.preventDefault();
|
|
264
|
-
const t = this.calculateRelativePosition(e.clientX, e.clientY);
|
|
265
|
-
this.setState({
|
|
266
|
-
isDynamicActive: !0,
|
|
267
|
-
dynamicPointerId: e.pointerId,
|
|
268
|
-
dynamicPosition: t
|
|
269
|
-
});
|
|
270
|
-
}
|
|
271
|
-
onPointerMove(e) {
|
|
272
|
-
!this.state.isDynamicActive || (e.pointerId, this.state.dynamicPointerId);
|
|
273
|
-
}
|
|
274
|
-
onPointerUp(e) {
|
|
275
|
-
this.handleRelease(e);
|
|
276
|
-
}
|
|
277
|
-
onPointerCancel(e) {
|
|
278
|
-
this.handleRelease(e);
|
|
279
|
-
}
|
|
280
|
-
/**
|
|
281
|
-
* Internal helper to handle pointer release and cleanup.
|
|
282
|
-
*/
|
|
283
|
-
handleRelease(e) {
|
|
284
|
-
if (e.pointerId === this.state.dynamicPointerId) {
|
|
285
|
-
try {
|
|
286
|
-
e.currentTarget.releasePointerCapture(e.pointerId);
|
|
287
|
-
} catch {
|
|
288
|
-
}
|
|
289
|
-
this.setState({
|
|
290
|
-
isDynamicActive: !1,
|
|
291
|
-
dynamicPointerId: null
|
|
292
|
-
});
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
// --- Helper Calculations ---
|
|
296
|
-
/**
|
|
297
|
-
* Converts viewport pixels to percentage coordinates relative to the zone.
|
|
298
|
-
*/
|
|
299
|
-
calculateRelativePosition(e, t) {
|
|
300
|
-
return this.rect ? {
|
|
301
|
-
x: z(e - this.rect.left, this.rect.width),
|
|
302
|
-
y: z(t - this.rect.top, this.rect.height)
|
|
303
|
-
} : { x: 0, y: 0 };
|
|
304
|
-
}
|
|
305
|
-
/**
|
|
306
|
-
* Whether the interceptor layer should be enabled.
|
|
307
|
-
*/
|
|
308
|
-
get isInterceptorRequired() {
|
|
309
|
-
return !!(this.config.dynamicWidgetId || this.config.preventFocusLoss);
|
|
310
|
-
}
|
|
311
|
-
reset() {
|
|
312
|
-
this.setState({
|
|
313
|
-
isDynamicActive: !1,
|
|
314
|
-
dynamicPointerId: null
|
|
315
|
-
});
|
|
316
|
-
}
|
|
317
|
-
}, F = {
|
|
318
|
-
isActive: !1,
|
|
319
|
-
isPressed: !1,
|
|
320
|
-
pointerId: null,
|
|
321
|
-
value: 0
|
|
322
|
-
}, we = class extends R {
|
|
323
|
-
/**
|
|
324
|
-
* Creates an instance of KeyboardButtonCore.
|
|
325
|
-
*
|
|
326
|
-
* @param uid - The unique entity ID.
|
|
327
|
-
* @param config - The flat configuration object for the button.
|
|
328
|
-
*/
|
|
329
|
-
constructor(e, t) {
|
|
330
|
-
super(e, v.KEYBOARD_BUTTON, t, F);
|
|
331
|
-
}
|
|
332
|
-
// --- IPointerHandler Implementation ---
|
|
333
|
-
onPointerDown(e) {
|
|
334
|
-
e.cancelable && e.preventDefault(), e.target.setPointerCapture(e.pointerId), this.setState({
|
|
335
|
-
isActive: !0,
|
|
336
|
-
isPressed: !0,
|
|
337
|
-
pointerId: e.pointerId
|
|
338
|
-
}), this.sendInputSignal(f.KEYDOWN);
|
|
339
|
-
}
|
|
340
|
-
onPointerUp(e) {
|
|
341
|
-
e.cancelable && e.preventDefault(), this.handleRelease(e);
|
|
342
|
-
}
|
|
343
|
-
onPointerCancel(e) {
|
|
344
|
-
this.handleRelease(e);
|
|
345
|
-
}
|
|
346
|
-
onPointerMove(e) {
|
|
347
|
-
e.cancelable && e.preventDefault();
|
|
348
|
-
}
|
|
349
|
-
// --- Internal Logic ---
|
|
350
|
-
/**
|
|
351
|
-
* Common logic for releasing the button state.
|
|
352
|
-
*
|
|
353
|
-
* @param e - The pointer event that triggered the release.
|
|
354
|
-
*/
|
|
355
|
-
handleRelease(e) {
|
|
356
|
-
this.state.pointerId === e.pointerId && (e.target.hasPointerCapture(e.pointerId) && e.target.releasePointerCapture(e.pointerId), this.setState(F), this.sendInputSignal(f.KEYUP));
|
|
357
|
-
}
|
|
358
|
-
/**
|
|
359
|
-
* Dispatches input signals to the registered target stage.
|
|
360
|
-
*
|
|
361
|
-
* @param type - The action type (keydown or keyup).
|
|
362
|
-
*/
|
|
363
|
-
sendInputSignal(e) {
|
|
364
|
-
const t = this.config.targetStageId;
|
|
365
|
-
if (!t) return;
|
|
366
|
-
const n = Z.getInstance().getEntity(t);
|
|
367
|
-
if (n && typeof n.handleSignal == "function") {
|
|
368
|
-
const i = {
|
|
369
|
-
targetStageId: t,
|
|
370
|
-
type: e,
|
|
371
|
-
payload: {
|
|
372
|
-
key: this.config.mapping.key,
|
|
373
|
-
code: this.config.mapping.code,
|
|
374
|
-
keyCode: this.config.mapping.keyCode
|
|
375
|
-
}
|
|
376
|
-
};
|
|
377
|
-
n.handleSignal(i);
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
// --- IResettable Implementation ---
|
|
381
|
-
reset() {
|
|
382
|
-
this.state.isPressed && this.sendInputSignal(f.KEYUP), this.setState(F);
|
|
383
|
-
}
|
|
384
|
-
}, Oe = {
|
|
385
|
-
isHighlighted: !1
|
|
386
|
-
}, Se = class extends R {
|
|
387
|
-
constructor(e, t) {
|
|
388
|
-
super(e, v.ROOT_LAYER, t, Oe);
|
|
389
|
-
}
|
|
390
|
-
reset() {
|
|
391
|
-
}
|
|
392
|
-
}, Ne = {
|
|
393
|
-
position: { x: 50, y: 50 },
|
|
394
|
-
isVisible: !1,
|
|
395
|
-
isPointerDown: !1,
|
|
396
|
-
isFocusReturning: !1
|
|
397
|
-
}, Ae = class extends R {
|
|
398
|
-
constructor(e, t) {
|
|
399
|
-
super(e, v.TARGET_ZONE, t, Ne), g(this, "hideTimer", null), g(this, "focusFeedbackTimer", null);
|
|
400
|
-
}
|
|
401
|
-
// --- ISignalReceiver Implementation ---
|
|
402
|
-
handleSignal(e) {
|
|
403
|
-
const { type: t, payload: n } = e;
|
|
404
|
-
switch (this.ensureFocus(), t) {
|
|
405
|
-
case f.KEYDOWN:
|
|
406
|
-
case f.KEYUP:
|
|
407
|
-
Pe(t, n);
|
|
408
|
-
break;
|
|
409
|
-
case f.MOUSEMOVE:
|
|
410
|
-
n.point && (this.updateCursorPosition(n.point), this.config.cursorEnabled && this.showCursor(), this.executeMouseAction(f.POINTERMOVE, n));
|
|
411
|
-
break;
|
|
412
|
-
case f.MOUSEDOWN:
|
|
413
|
-
case f.MOUSEUP:
|
|
414
|
-
case f.CLICK:
|
|
415
|
-
this.config.cursorEnabled && this.showCursor(), this.executeMouseAction(
|
|
416
|
-
t.startsWith(f.MOUSE) ? t.replace(f.MOUSE, f.POINTER) : t,
|
|
417
|
-
n
|
|
418
|
-
);
|
|
419
|
-
break;
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
// --- Mouse & Pointer Simulation ---
|
|
423
|
-
/**
|
|
424
|
-
* Calculates pixel coordinates and dispatches simulated pointer events to the deepest element.
|
|
425
|
-
*
|
|
426
|
-
* @param pointerType - The specific pointer event type (e.g., pointermove, pointerdown).
|
|
427
|
-
* @param payload - Data containing point coordinates or button info.
|
|
428
|
-
*/
|
|
429
|
-
executeMouseAction(e, t) {
|
|
430
|
-
if (!this.rect) return;
|
|
431
|
-
e === f.POINTERDOWN && this.setState({ isPointerDown: !0 }), e === f.POINTERUP && this.setState({ isPointerDown: !1 });
|
|
432
|
-
const n = t.point || this.state.position, i = this.rect.left + A(n.x, this.rect.width), o = this.rect.top + A(n.y, this.rect.height);
|
|
433
|
-
be(e, i, o, {
|
|
434
|
-
button: t.button ?? 0,
|
|
435
|
-
buttons: this.state.isPointerDown ? 1 : 0
|
|
436
|
-
});
|
|
437
|
-
}
|
|
438
|
-
// --- Focus Management ---
|
|
439
|
-
/**
|
|
440
|
-
* Checks if the target element under the virtual cursor has focus, and reclaims it if lost.
|
|
441
|
-
*/
|
|
442
|
-
ensureFocus() {
|
|
443
|
-
if (!this.rect) return;
|
|
444
|
-
const e = this.rect.left + A(this.state.position.x, this.rect.width), t = this.rect.top + A(this.state.position.y, this.rect.height), n = H(e, t);
|
|
445
|
-
n && J() !== n && (Ee(n), this.triggerFocusFeedback());
|
|
446
|
-
}
|
|
447
|
-
/**
|
|
448
|
-
* Activates a temporary visual feedback state to indicate a focus-reclaim event.
|
|
449
|
-
*/
|
|
450
|
-
triggerFocusFeedback() {
|
|
451
|
-
this.setState({ isFocusReturning: !0 }), this.focusFeedbackTimer && clearTimeout(this.focusFeedbackTimer), this.focusFeedbackTimer = setTimeout(() => this.setState({ isFocusReturning: !1 }), 500);
|
|
452
|
-
}
|
|
453
|
-
// --- Cursor State Helpers ---
|
|
454
|
-
/**
|
|
455
|
-
* Updates the internal virtual cursor coordinates.
|
|
456
|
-
*/
|
|
457
|
-
updateCursorPosition(e) {
|
|
458
|
-
this.setState({ position: { ...e } });
|
|
459
|
-
}
|
|
460
|
-
/**
|
|
461
|
-
* Makes the virtual cursor visible and sets a timeout for auto-hiding.
|
|
462
|
-
*/
|
|
463
|
-
showCursor() {
|
|
464
|
-
this.setState({ isVisible: !0 }), this.hideTimer && clearTimeout(this.hideTimer), this.config.cursorAutoDelay && this.config.cursorAutoDelay > 0 && (this.hideTimer = setTimeout(
|
|
465
|
-
() => this.setState({ isVisible: !1 }),
|
|
466
|
-
this.config.cursorAutoDelay
|
|
467
|
-
));
|
|
468
|
-
}
|
|
469
|
-
// --- IResettable Implementation ---
|
|
470
|
-
reset() {
|
|
471
|
-
this.state.isPointerDown && this.executeMouseAction(f.POINTERUP, {}), this.hideTimer && clearTimeout(this.hideTimer), this.focusFeedbackTimer && clearTimeout(this.focusFeedbackTimer), this.setState({
|
|
472
|
-
isVisible: !1,
|
|
473
|
-
isPointerDown: !1,
|
|
474
|
-
isFocusReturning: !1
|
|
475
|
-
});
|
|
476
|
-
}
|
|
477
|
-
};
|
|
478
|
-
const q = {};
|
|
479
|
-
function x(e, t) {
|
|
480
|
-
q[e] = t;
|
|
1
|
+
import { Registry as W, CONTEXT as V, generateUID as j, TYPES as _, resolveLayoutStyle as A, InputZoneCore as G, RootLayerCore as X, TargetZoneCore as H, KeyboardButtonCore as J } from "@omnipad/core";
|
|
2
|
+
import { defineComponent as g, h as Q, shallowRef as q, ref as E, onMounted as ee, onUnmounted as te, openBlock as d, createElementBlock as p, Fragment as ne, renderList as oe, createBlock as $, resolveDynamicComponent as k, unref as u, renderSlot as C, inject as ie, computed as f, provide as ae, useSlots as re, watch as le, nextTick as se, normalizeStyle as b, createVNode as x, withCtx as U, createElementVNode as L, createCommentVNode as I, Transition as ue, normalizeClass as Z, toDisplayString as ce } from "vue";
|
|
3
|
+
const z = {};
|
|
4
|
+
function O(n, t) {
|
|
5
|
+
z[n] = t;
|
|
481
6
|
}
|
|
482
|
-
function
|
|
483
|
-
const t =
|
|
484
|
-
return t ||
|
|
485
|
-
render: () =>
|
|
7
|
+
function K(n) {
|
|
8
|
+
const t = z[n];
|
|
9
|
+
return t || g({
|
|
10
|
+
render: () => Q("div", { style: "color:red" }, `[Unknown: ${n}]`)
|
|
486
11
|
});
|
|
487
12
|
}
|
|
488
|
-
function
|
|
489
|
-
const t =
|
|
490
|
-
|
|
13
|
+
function B(n) {
|
|
14
|
+
const t = q(), r = E(), e = E(null), a = (o) => {
|
|
15
|
+
r.value = o;
|
|
491
16
|
};
|
|
492
|
-
let
|
|
493
|
-
return
|
|
494
|
-
const
|
|
495
|
-
t.value =
|
|
496
|
-
let
|
|
497
|
-
|
|
498
|
-
for (const
|
|
499
|
-
|
|
500
|
-
}),
|
|
501
|
-
}),
|
|
502
|
-
|
|
17
|
+
let i = null;
|
|
18
|
+
return ee(() => {
|
|
19
|
+
const o = n();
|
|
20
|
+
t.value = o, W.getInstance().register(o), "subscribe" in o && o.subscribe(a);
|
|
21
|
+
let l = null;
|
|
22
|
+
e.value && (e.value instanceof Element ? l = e.value : e.value.$el instanceof Element && (l = e.value.$el)), l && "updateRect" in o && (i = new ResizeObserver((y) => {
|
|
23
|
+
for (const v of y)
|
|
24
|
+
o.updateRect(v.target.getBoundingClientRect());
|
|
25
|
+
}), i.observe(l), o.updateRect(l.getBoundingClientRect()));
|
|
26
|
+
}), te(() => {
|
|
27
|
+
i && i.disconnect(), t.value && t.value.destroy();
|
|
503
28
|
}), {
|
|
504
29
|
core: t,
|
|
505
|
-
state:
|
|
506
|
-
elementRef:
|
|
30
|
+
state: r,
|
|
31
|
+
elementRef: e
|
|
507
32
|
};
|
|
508
33
|
}
|
|
509
|
-
const
|
|
34
|
+
const de = { class: "omnipad-virtual-layer-base omnipad-prevent" }, ve = /* @__PURE__ */ g({
|
|
510
35
|
__name: "VirtualLayerBase",
|
|
511
36
|
props: {
|
|
512
37
|
nodes: {}
|
|
513
38
|
},
|
|
514
|
-
setup(
|
|
515
|
-
return (t,
|
|
516
|
-
(
|
|
517
|
-
key:
|
|
518
|
-
"tree-node":
|
|
39
|
+
setup(n) {
|
|
40
|
+
return (t, r) => (d(), p("div", de, [
|
|
41
|
+
(d(!0), p(ne, null, oe(n.nodes || [], (e) => (d(), $(k(u(K)(e.type)), {
|
|
42
|
+
key: e.uid,
|
|
43
|
+
"tree-node": e
|
|
519
44
|
}, null, 8, ["tree-node"]))), 128)),
|
|
520
|
-
|
|
45
|
+
C(t.$slots, "default", {}, void 0, !0)
|
|
521
46
|
]));
|
|
522
47
|
}
|
|
523
|
-
}),
|
|
524
|
-
const
|
|
525
|
-
for (const [
|
|
526
|
-
|
|
527
|
-
return
|
|
528
|
-
},
|
|
529
|
-
function
|
|
530
|
-
const
|
|
531
|
-
|
|
532
|
-
`[OmniPad-Validation] Type mismatch! Component expected "${
|
|
48
|
+
}), N = (n, t) => {
|
|
49
|
+
const r = n.__vccOpts || n;
|
|
50
|
+
for (const [e, a] of t)
|
|
51
|
+
r[e] = a;
|
|
52
|
+
return r;
|
|
53
|
+
}, Y = /* @__PURE__ */ N(ve, [["__scopeId", "data-v-6f1860f6"]]);
|
|
54
|
+
function D(n, t, r = {}) {
|
|
55
|
+
const e = t.treeNode, a = e && e.type === n ? e : void 0;
|
|
56
|
+
e && e.type !== n && console.warn(
|
|
57
|
+
`[OmniPad-Validation] Type mismatch! Component expected "${n}", but received "${e.type}". Config ignored.`
|
|
533
58
|
);
|
|
534
|
-
const
|
|
535
|
-
|
|
536
|
-
const
|
|
537
|
-
const
|
|
538
|
-
Object.entries(t).filter(([m,
|
|
59
|
+
const i = ie(V.PARENT_ID_KEY, E(void 0)), o = f(() => t.parentId || a?.config?.parentId || i.value), l = f(() => t.widgetId || a?.uid || j(n));
|
|
60
|
+
ae(V.PARENT_ID_KEY, l);
|
|
61
|
+
const y = f(() => {
|
|
62
|
+
const v = a?.config || {}, c = Object.fromEntries(
|
|
63
|
+
Object.entries(t).filter(([m, w]) => w !== void 0 && m !== "treeNode" && m !== "widgetId")
|
|
539
64
|
);
|
|
540
65
|
return {
|
|
541
|
-
...
|
|
542
|
-
...
|
|
543
|
-
...
|
|
544
|
-
id:
|
|
545
|
-
type:
|
|
546
|
-
parentId:
|
|
66
|
+
...r,
|
|
67
|
+
...v,
|
|
68
|
+
...c,
|
|
69
|
+
id: l.value,
|
|
70
|
+
type: n,
|
|
71
|
+
parentId: o.value,
|
|
547
72
|
// 特殊处理 Layout:深度合并,确保即便只传了 { width: 100 } 也不丢失原来的 left/top
|
|
548
73
|
layout: {
|
|
549
|
-
...
|
|
550
|
-
...
|
|
551
|
-
...
|
|
74
|
+
...r.layout || {},
|
|
75
|
+
...v.layout || {},
|
|
76
|
+
...c.layout || {}
|
|
552
77
|
}
|
|
553
78
|
};
|
|
554
79
|
});
|
|
555
|
-
return { uid:
|
|
80
|
+
return { uid: l, config: y };
|
|
556
81
|
}
|
|
557
|
-
const
|
|
82
|
+
const fe = ["id"], pe = /* @__PURE__ */ g({
|
|
558
83
|
__name: "InputZone",
|
|
559
84
|
props: {
|
|
560
85
|
treeNode: {},
|
|
@@ -562,113 +87,113 @@ const ke = ["id"], xe = /* @__PURE__ */ P({
|
|
|
562
87
|
layout: {},
|
|
563
88
|
preventFocusLoss: {}
|
|
564
89
|
},
|
|
565
|
-
setup(
|
|
566
|
-
const t =
|
|
567
|
-
() => new
|
|
568
|
-
),
|
|
569
|
-
const
|
|
570
|
-
return t.treeNode?.children?.filter((
|
|
571
|
-
}),
|
|
572
|
-
const
|
|
573
|
-
(
|
|
574
|
-
),
|
|
575
|
-
return
|
|
576
|
-
`[OmniPad-Validation] InputZone ${
|
|
577
|
-
),
|
|
578
|
-
`[OmniPad-Validation] InputZone ${
|
|
90
|
+
setup(n) {
|
|
91
|
+
const t = n, r = re(), e = E(null), { uid: a, config: i } = D(_.INPUT_ZONE, t), { core: o, state: l, elementRef: y } = B(
|
|
92
|
+
() => new G(a.value, i.value)
|
|
93
|
+
), v = f(() => {
|
|
94
|
+
const s = t.treeNode?.config?.dynamicWidgetId;
|
|
95
|
+
return t.treeNode?.children?.filter((P) => P.uid !== s) || [];
|
|
96
|
+
}), c = f(() => {
|
|
97
|
+
const P = (r.dynamicWidget?.() || []).filter((h) => !(h.type === Comment || h.type === Text)), R = t.treeNode?.children?.find(
|
|
98
|
+
(h) => h.uid === t.treeNode?.config?.dynamicWidgetId
|
|
99
|
+
), S = P.length > 0;
|
|
100
|
+
return P.length > 1 && console.error(
|
|
101
|
+
`[OmniPad-Validation] InputZone ${a.value} has multiple dynamic widgets in slot. Only the first one will be activated.`
|
|
102
|
+
), S && R && console.warn(
|
|
103
|
+
`[OmniPad-Validation] InputZone ${a.value} has both Slot and Config dynamic widgets. Config ignored.`
|
|
579
104
|
), {
|
|
580
|
-
nodeToRender:
|
|
581
|
-
isFromSlot:
|
|
105
|
+
nodeToRender: S ? P[0] : R || null,
|
|
106
|
+
isFromSlot: S
|
|
582
107
|
};
|
|
583
108
|
});
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
(
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
dynamicWidgetId:
|
|
109
|
+
le(
|
|
110
|
+
e,
|
|
111
|
+
(s) => {
|
|
112
|
+
se(() => {
|
|
113
|
+
s && s?.uid && o.value?.updateConfig({
|
|
114
|
+
dynamicWidgetId: s.uid
|
|
590
115
|
});
|
|
591
116
|
});
|
|
592
117
|
},
|
|
593
118
|
{ immediate: !0 }
|
|
594
119
|
);
|
|
595
|
-
const m =
|
|
120
|
+
const m = f(() => A(i.value.layout)), w = f(() => l.value?.isDynamicActive ? {
|
|
596
121
|
position: "absolute",
|
|
597
|
-
left: `${
|
|
598
|
-
top: `${
|
|
122
|
+
left: `${l.value.dynamicPosition.x}%`,
|
|
123
|
+
top: `${l.value.dynamicPosition.y}%`,
|
|
599
124
|
zIndex: 100,
|
|
600
125
|
pointerEvents: "auto"
|
|
601
|
-
} : { display: "none" }),
|
|
602
|
-
|
|
603
|
-
},
|
|
604
|
-
|
|
605
|
-
},
|
|
606
|
-
|
|
126
|
+
} : { display: "none" }), F = (s) => {
|
|
127
|
+
o.value && (o.value.onPointerDown(s), l.value?.isDynamicActive && e.value && typeof e.value.onPointerDown == "function" && e.value.onPointerDown(s));
|
|
128
|
+
}, M = (s) => {
|
|
129
|
+
o.value && (o.value.onPointerMove(s), l.value?.isDynamicActive && e.value && typeof e.value.onPointerMove == "function" && e.value.onPointerMove(s));
|
|
130
|
+
}, T = (s) => {
|
|
131
|
+
l.value?.isDynamicActive && e.value && typeof e.value.onPointerUp == "function" && e.value.onPointerUp(s), o.value && o.value.onPointerUp(s);
|
|
607
132
|
};
|
|
608
|
-
return (
|
|
609
|
-
id:
|
|
133
|
+
return (s, P) => (d(), p("div", {
|
|
134
|
+
id: u(a),
|
|
610
135
|
ref_key: "elementRef",
|
|
611
|
-
ref:
|
|
136
|
+
ref: y,
|
|
612
137
|
class: "omnipad-input-zone omnipad-prevent",
|
|
613
|
-
style:
|
|
138
|
+
style: b(m.value)
|
|
614
139
|
}, [
|
|
615
|
-
|
|
616
|
-
default:
|
|
617
|
-
|
|
140
|
+
x(Y, { nodes: v.value }, {
|
|
141
|
+
default: U(() => [
|
|
142
|
+
C(s.$slots, "default", {}, void 0, !0)
|
|
618
143
|
]),
|
|
619
144
|
_: 3
|
|
620
145
|
}, 8, ["nodes"]),
|
|
621
|
-
|
|
146
|
+
u(o)?.isInterceptorRequired ? (d(), p("div", {
|
|
622
147
|
key: 0,
|
|
623
148
|
class: "omnipad-input-zone-trigger",
|
|
624
|
-
onPointerdown:
|
|
625
|
-
onPointermove:
|
|
626
|
-
onPointerup:
|
|
627
|
-
onPointercancel:
|
|
628
|
-
onLostpointercapture:
|
|
629
|
-
onPointerleave:
|
|
149
|
+
onPointerdown: F,
|
|
150
|
+
onPointermove: M,
|
|
151
|
+
onPointerup: T,
|
|
152
|
+
onPointercancel: T,
|
|
153
|
+
onLostpointercapture: T,
|
|
154
|
+
onPointerleave: T
|
|
630
155
|
}, [
|
|
631
|
-
|
|
156
|
+
L("div", {
|
|
632
157
|
class: "dynamic-widget-mount",
|
|
633
|
-
style:
|
|
158
|
+
style: b(w.value)
|
|
634
159
|
}, [
|
|
635
|
-
|
|
160
|
+
c.value.isFromSlot ? (d(), $(k(c.value.nodeToRender), {
|
|
636
161
|
key: 0,
|
|
637
|
-
ref: (
|
|
638
|
-
}, null, 512)) :
|
|
162
|
+
ref: (R) => e.value = R
|
|
163
|
+
}, null, 512)) : c.value.nodeToRender ? (d(), $(k(u(K)(c.value.nodeToRender.type)), {
|
|
639
164
|
key: 1,
|
|
640
|
-
ref: (
|
|
641
|
-
"tree-node":
|
|
642
|
-
}, null, 8, ["tree-node"])) :
|
|
165
|
+
ref: (R) => e.value = R,
|
|
166
|
+
"tree-node": c.value.nodeToRender
|
|
167
|
+
}, null, 8, ["tree-node"])) : I("", !0)
|
|
643
168
|
], 4)
|
|
644
|
-
], 32)) :
|
|
645
|
-
], 12,
|
|
169
|
+
], 32)) : I("", !0)
|
|
170
|
+
], 12, fe));
|
|
646
171
|
}
|
|
647
|
-
}),
|
|
172
|
+
}), ye = /* @__PURE__ */ N(pe, [["__scopeId", "data-v-02669919"]]), me = ["id"], _e = /* @__PURE__ */ g({
|
|
648
173
|
__name: "RootLayer",
|
|
649
174
|
props: {
|
|
650
175
|
treeNode: {},
|
|
651
176
|
widgetId: {}
|
|
652
177
|
},
|
|
653
|
-
setup(
|
|
654
|
-
const t =
|
|
655
|
-
return (
|
|
656
|
-
id:
|
|
178
|
+
setup(n) {
|
|
179
|
+
const t = n, { uid: r, config: e } = D(_.ROOT_LAYER, t), { elementRef: a } = B(() => new X(r.value, e.value));
|
|
180
|
+
return (i, o) => (d(), p("div", {
|
|
181
|
+
id: u(r),
|
|
657
182
|
ref_key: "elementRef",
|
|
658
|
-
ref:
|
|
183
|
+
ref: a,
|
|
659
184
|
class: "omnipad-virtual-layer"
|
|
660
185
|
}, [
|
|
661
|
-
|
|
662
|
-
nodes:
|
|
186
|
+
x(Y, {
|
|
187
|
+
nodes: n.treeNode?.children || []
|
|
663
188
|
}, {
|
|
664
|
-
default:
|
|
665
|
-
|
|
189
|
+
default: U(() => [
|
|
190
|
+
C(i.$slots, "default", {}, void 0, !0)
|
|
666
191
|
]),
|
|
667
192
|
_: 3
|
|
668
193
|
}, 8, ["nodes"])
|
|
669
|
-
], 8,
|
|
194
|
+
], 8, me));
|
|
670
195
|
}
|
|
671
|
-
}),
|
|
196
|
+
}), ge = /* @__PURE__ */ N(_e, [["__scopeId", "data-v-a509fd6e"]]), Pe = ["id"], Re = /* @__PURE__ */ g({
|
|
672
197
|
__name: "TargetZone",
|
|
673
198
|
props: {
|
|
674
199
|
treeNode: {},
|
|
@@ -677,70 +202,70 @@ const ke = ["id"], xe = /* @__PURE__ */ P({
|
|
|
677
202
|
cursorAutoDelay: {},
|
|
678
203
|
layout: {}
|
|
679
204
|
},
|
|
680
|
-
setup(
|
|
681
|
-
const t =
|
|
205
|
+
setup(n) {
|
|
206
|
+
const t = n, r = {
|
|
682
207
|
cursorAutoDelay: 2500
|
|
683
|
-
}, { uid:
|
|
684
|
-
() => new
|
|
685
|
-
),
|
|
686
|
-
left: `${
|
|
687
|
-
top: `${
|
|
688
|
-
opacity:
|
|
208
|
+
}, { uid: e, config: a } = D(_.TARGET_ZONE, t, r), { state: i, elementRef: o } = B(
|
|
209
|
+
() => new H(e.value, a.value)
|
|
210
|
+
), l = f(() => A(a.value.layout)), y = f(() => i.value ? {
|
|
211
|
+
left: `${i.value.position.x}%`,
|
|
212
|
+
top: `${i.value.position.y}%`,
|
|
213
|
+
opacity: i.value.isVisible ? 1 : 0
|
|
689
214
|
} : { display: "none" });
|
|
690
|
-
return (
|
|
691
|
-
id:
|
|
215
|
+
return (v, c) => (d(), p("div", {
|
|
216
|
+
id: u(e),
|
|
692
217
|
ref_key: "elementRef",
|
|
693
|
-
ref:
|
|
218
|
+
ref: o,
|
|
694
219
|
class: "omnipad-target-zone",
|
|
695
|
-
style:
|
|
220
|
+
style: b(l.value)
|
|
696
221
|
}, [
|
|
697
|
-
|
|
698
|
-
default:
|
|
699
|
-
|
|
222
|
+
x(ue, { name: "pulse" }, {
|
|
223
|
+
default: U(() => [
|
|
224
|
+
u(i)?.isFocusReturning ? (d(), p("div", {
|
|
700
225
|
key: 0,
|
|
701
226
|
class: "focus-feedback-ring",
|
|
702
|
-
style:
|
|
703
|
-
left: `${
|
|
704
|
-
top: `${
|
|
227
|
+
style: b({
|
|
228
|
+
left: `${u(i).position.x}%`,
|
|
229
|
+
top: `${u(i).position.y}%`
|
|
705
230
|
})
|
|
706
|
-
}, null, 4)) :
|
|
231
|
+
}, null, 4)) : I("", !0)
|
|
707
232
|
]),
|
|
708
233
|
_: 1
|
|
709
234
|
}),
|
|
710
|
-
|
|
235
|
+
u(a).cursorEnabled ? (d(), p("div", {
|
|
711
236
|
key: 0,
|
|
712
237
|
class: "omnipad-virtual-cursor",
|
|
713
|
-
style:
|
|
238
|
+
style: b(y.value)
|
|
714
239
|
}, [
|
|
715
|
-
|
|
716
|
-
class:
|
|
240
|
+
L("div", {
|
|
241
|
+
class: Z(["cursor-dot", { "is-down": u(i)?.isPointerDown }])
|
|
717
242
|
}, null, 2)
|
|
718
|
-
], 4)) :
|
|
719
|
-
], 12,
|
|
243
|
+
], 4)) : I("", !0)
|
|
244
|
+
], 12, Pe));
|
|
720
245
|
}
|
|
721
|
-
}),
|
|
246
|
+
}), be = /* @__PURE__ */ N(Re, [["__scopeId", "data-v-b9d49b97"]]), Ie = {
|
|
722
247
|
key: 0,
|
|
723
248
|
class: "omnipad-button-label"
|
|
724
|
-
},
|
|
249
|
+
}, Ne = /* @__PURE__ */ g({
|
|
725
250
|
__name: "VirtualButtonBase",
|
|
726
251
|
props: {
|
|
727
252
|
layout: {},
|
|
728
253
|
isActive: { type: Boolean },
|
|
729
254
|
label: {}
|
|
730
255
|
},
|
|
731
|
-
setup(
|
|
732
|
-
const t =
|
|
733
|
-
return (
|
|
734
|
-
class:
|
|
735
|
-
style:
|
|
256
|
+
setup(n) {
|
|
257
|
+
const t = n, r = f(() => t.layout ? A(t.layout) : {});
|
|
258
|
+
return (e, a) => (d(), p("div", {
|
|
259
|
+
class: Z(["omnipad-button-base", { "omnipad-is-active": n.isActive }]),
|
|
260
|
+
style: b(r.value),
|
|
736
261
|
tabindex: "-1"
|
|
737
262
|
}, [
|
|
738
|
-
|
|
739
|
-
|
|
263
|
+
C(e.$slots, "default", {}, () => [
|
|
264
|
+
n.label ? (d(), p("span", Ie, ce(n.label), 1)) : I("", !0)
|
|
740
265
|
], !0)
|
|
741
266
|
], 6));
|
|
742
267
|
}
|
|
743
|
-
}),
|
|
268
|
+
}), we = /* @__PURE__ */ N(Ne, [["__scopeId", "data-v-6cbe805c"]]), Te = /* @__PURE__ */ g({
|
|
744
269
|
__name: "VirtualKeyboardButton",
|
|
745
270
|
props: {
|
|
746
271
|
treeNode: {},
|
|
@@ -750,42 +275,42 @@ const ke = ["id"], xe = /* @__PURE__ */ P({
|
|
|
750
275
|
mapping: {},
|
|
751
276
|
layout: {}
|
|
752
277
|
},
|
|
753
|
-
setup(
|
|
754
|
-
const
|
|
278
|
+
setup(n, { expose: t }) {
|
|
279
|
+
const r = n, e = {
|
|
755
280
|
label: "BTN"
|
|
756
|
-
}, { uid:
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
), { core:
|
|
761
|
-
() => new
|
|
762
|
-
),
|
|
281
|
+
}, { uid: a, config: i } = D(
|
|
282
|
+
_.KEYBOARD_BUTTON,
|
|
283
|
+
r,
|
|
284
|
+
e
|
|
285
|
+
), { core: o, state: l, elementRef: y } = B(
|
|
286
|
+
() => new J(a.value, i.value)
|
|
287
|
+
), v = (m) => o.value?.onPointerDown(m), c = (m) => o.value?.onPointerUp(m);
|
|
763
288
|
return t({
|
|
764
|
-
uid:
|
|
765
|
-
onPointerDown:
|
|
766
|
-
onPointerUp:
|
|
767
|
-
}), (m,
|
|
768
|
-
id:
|
|
289
|
+
uid: a,
|
|
290
|
+
onPointerDown: v,
|
|
291
|
+
onPointerUp: c
|
|
292
|
+
}), (m, w) => (d(), $(we, {
|
|
293
|
+
id: u(a),
|
|
769
294
|
ref_key: "elementRef",
|
|
770
|
-
ref:
|
|
771
|
-
layout:
|
|
772
|
-
label:
|
|
773
|
-
"is-active":
|
|
774
|
-
onPointerdown:
|
|
775
|
-
onPointerup:
|
|
776
|
-
onPointercancel:
|
|
777
|
-
onLostpointercapture:
|
|
295
|
+
ref: y,
|
|
296
|
+
layout: u(i).layout,
|
|
297
|
+
label: u(i).label,
|
|
298
|
+
"is-active": u(l)?.isPressed,
|
|
299
|
+
onPointerdown: v,
|
|
300
|
+
onPointerup: c,
|
|
301
|
+
onPointercancel: c,
|
|
302
|
+
onLostpointercapture: c
|
|
778
303
|
}, null, 8, ["id", "layout", "label", "is-active"]));
|
|
779
304
|
}
|
|
780
305
|
});
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
306
|
+
O(_.INPUT_ZONE, ye);
|
|
307
|
+
O(_.ROOT_LAYER, ge);
|
|
308
|
+
O(_.TARGET_ZONE, be);
|
|
309
|
+
O(_.KEYBOARD_BUTTON, Te);
|
|
785
310
|
export {
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
311
|
+
ye as InputZone,
|
|
312
|
+
ge as RootLayer,
|
|
313
|
+
be as TargetZone,
|
|
314
|
+
Te as VirtualKeyboardButton,
|
|
315
|
+
O as registerComponent
|
|
791
316
|
};
|
package/dist/omnipad-vue.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(m,n){typeof exports=="object"&&typeof module<"u"?n(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],n):(m=typeof globalThis<"u"?globalThis:m||self,n(m.OmnipadVue={},m.Vue))})(this,(function(m,n){"use strict";var G=Object.defineProperty,j=(e,t,o)=>t in e?G(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,y=(e,t,o)=>j(e,typeof t!="symbol"?t+"":t,o),h={INPUT_ZONE:"input-zone",TARGET_ZONE:"target-zone",KEYBOARD_BUTTON:"keyboard-button",ROOT_LAYER:"root-layer"},p={KEYDOWN:"keydown",KEYUP:"keyup",POINTER:"pointer",POINTERMOVE:"pointermove",POINTERDOWN:"pointerdown",POINTERUP:"pointerup",MOUSE:"mouse",MOUSEMOVE:"mousemove",MOUSEDOWN:"mousedown",MOUSEUP:"mouseup",CLICK:"click"},B={PARENT_ID_KEY:"omnipad-parent-id-link"},U=(e,t=2)=>{const o=Math.pow(10,t);return Math.round(e*o)/o},T=(e,t)=>U(e*t/100),$=(e,t)=>t===0?0:U(e*100/t),x=(e,t)=>{let o=document.elementFromPoint(e,t);for(;o&&o.shadowRoot;){const i=o.shadowRoot.elementFromPoint(e,t);if(!i||i===o)break;o=i}return o},M=()=>{let e=document.activeElement;for(;e&&e.shadowRoot&&e.shadowRoot.activeElement;)e=e.shadowRoot.activeElement;return e},X=e=>{M()!==e&&(e.hasAttribute("tabindex")||e.setAttribute("tabindex","-1"),e.focus())},H=(e,t)=>{const o=new KeyboardEvent(e,{...t,which:t.keyCode,bubbles:!0,cancelable:!0,view:window});window.dispatchEvent(o)},q=(e,t,o,i={})=>{const r=x(t,o);if(!r)return;const s={bubbles:!0,cancelable:!0,composed:!0,clientX:t,clientY:o,view:window,...i};if(e.startsWith("pointer")){r.dispatchEvent(new PointerEvent(e,{isPrimary:!0,pointerId:1,pointerType:"mouse",...s}));const a=e.replace("pointer","mouse");r.dispatchEvent(new MouseEvent(a,s))}else r.dispatchEvent(new MouseEvent(e,s))},J=(e="omnipad")=>{const t=Date.now().toString(36),o=Math.random().toString(36).substring(2,6);return`${e}-${t}-${o}`},N=e=>{if(!e)return{};const t={};t.position="absolute",["left","top","right","bottom","width","height"].forEach(r=>{const s=e[r];s!==void 0&&(t[r]=typeof s=="number"?`${s}px`:s)}),e.zIndex!==void 0&&(t.zIndex=e.zIndex);const i={"top-left":"translate(0, 0)","top-center":"translate(-50%, 0)","top-right":"translate(-100%, 0)","center-left":"translate(0, -50%)",center:"translate(-50%, -50%)","center-right":"translate(-100%, -50%)","bottom-left":"translate(0, -100%)","bottom-center":"translate(-50%, -100%)","bottom-right":"translate(-100%, -100%)"};return e.anchor&&(t.transform=i[e.anchor]),t},Q=class{constructor(){y(this,"listeners",new Set)}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}emit(e){this.listeners.forEach(t=>{try{t(e)}catch(o){console.error("[OmniPad-Core] Emitter callback error:",o)}})}clear(){this.listeners.clear()}},b=class{constructor(e,t,o,i){y(this,"uid"),y(this,"type"),y(this,"config"),y(this,"state"),y(this,"rect",null),y(this,"stateEmitter",new Q),this.uid=e,this.type=t,this.config=o,this.state=i}subscribe(e){return e(this.state),this.stateEmitter.subscribe(e)}setState(e){this.state={...this.state,...e},this.stateEmitter.emit(this.state)}destroy(){this.reset(),this.stateEmitter.clear(),k.getInstance().unregister(this.uid)}updateRect(e){this.rect=e}updateConfig(e){this.config={...this.config,...e},this.stateEmitter.emit(this.state)}getState(){return this.state}getConfig(){return this.config}},C=Symbol.for("omnipad.registry.instance"),k=class W{constructor(){y(this,"entities",new Map)}static getInstance(){const t=globalThis;return t[C]||(t[C]=new W),t[C]}register(t){if(!t.uid){console.warn("[OmniPad-Core] Registry: Attempted to register entity without UID.",t);return}this.entities.has(t.uid),this.entities.set(t.uid,t)}unregister(t){this.entities.has(t)&&this.entities.delete(t)}getEntity(t){return this.entities.get(t)}getAllEntities(){return Array.from(this.entities.values())}getEntitiesByRoot(t){const o=this.getAllEntities();if(!t)return o;if(!this.entities.get(t))return console.warn(`[OmniPad-Core] Registry: Root entity ${t} not found.`),[];const r=new Map;o.forEach(l=>{if(l instanceof b){const d=l.getConfig();d.parentId&&(r.has(d.parentId)||r.set(d.parentId,[]),r.get(d.parentId).push(l))}});const s=[],a=[t],c=new Set;for(;a.length>0;){const l=a.shift();if(c.has(l))continue;c.add(l);const d=this.entities.get(l);if(d){s.push(d);const u=r.get(l);u&&u.forEach(g=>a.push(g.uid))}}return s}destroyByRoot(t){const o=this.getEntitiesByRoot(t);for(let i=o.length-1;i>=0;i--){const r=o[i];try{r.destroy()}catch(s){console.error(`[OmniPad-Core] Error during destroyByRoot at ${r.uid}:`,s)}}}clear(){this.entities.clear()}resetAll(){this.entities.forEach(t=>{"reset"in t&&t.reset()})}debugGetSnapshot(){return new Map(this.entities)}},ee={isDynamicActive:!1,dynamicPointerId:null,dynamicPosition:{x:0,y:0}},te=class extends b{constructor(e,t){super(e,h.INPUT_ZONE,t,ee)}onPointerDown(e){if(this.state.isDynamicActive||e.target!==e.currentTarget)return;e.cancelable&&e.preventDefault();const t=this.calculateRelativePosition(e.clientX,e.clientY);this.setState({isDynamicActive:!0,dynamicPointerId:e.pointerId,dynamicPosition:t})}onPointerMove(e){!this.state.isDynamicActive||(e.pointerId,this.state.dynamicPointerId)}onPointerUp(e){this.handleRelease(e)}onPointerCancel(e){this.handleRelease(e)}handleRelease(e){if(e.pointerId===this.state.dynamicPointerId){try{e.currentTarget.releasePointerCapture(e.pointerId)}catch{}this.setState({isDynamicActive:!1,dynamicPointerId:null})}}calculateRelativePosition(e,t){return this.rect?{x:$(e-this.rect.left,this.rect.width),y:$(t-this.rect.top,this.rect.height)}:{x:0,y:0}}get isInterceptorRequired(){return!!(this.config.dynamicWidgetId||this.config.preventFocusLoss)}reset(){this.setState({isDynamicActive:!1,dynamicPointerId:null})}},A={isActive:!1,isPressed:!1,pointerId:null,value:0},ne=class extends b{constructor(e,t){super(e,h.KEYBOARD_BUTTON,t,A)}onPointerDown(e){e.cancelable&&e.preventDefault(),e.target.setPointerCapture(e.pointerId),this.setState({isActive:!0,isPressed:!0,pointerId:e.pointerId}),this.sendInputSignal(p.KEYDOWN)}onPointerUp(e){e.cancelable&&e.preventDefault(),this.handleRelease(e)}onPointerCancel(e){this.handleRelease(e)}onPointerMove(e){e.cancelable&&e.preventDefault()}handleRelease(e){this.state.pointerId===e.pointerId&&(e.target.hasPointerCapture(e.pointerId)&&e.target.releasePointerCapture(e.pointerId),this.setState(A),this.sendInputSignal(p.KEYUP))}sendInputSignal(e){const t=this.config.targetStageId;if(!t)return;const o=k.getInstance().getEntity(t);if(o&&typeof o.handleSignal=="function"){const i={targetStageId:t,type:e,payload:{key:this.config.mapping.key,code:this.config.mapping.code,keyCode:this.config.mapping.keyCode}};o.handleSignal(i)}}reset(){this.state.isPressed&&this.sendInputSignal(p.KEYUP),this.setState(A)}},oe={isHighlighted:!1},ie=class extends b{constructor(e,t){super(e,h.ROOT_LAYER,t,oe)}reset(){}},re={position:{x:50,y:50},isVisible:!1,isPointerDown:!1,isFocusReturning:!1},se=class extends b{constructor(e,t){super(e,h.TARGET_ZONE,t,re),y(this,"hideTimer",null),y(this,"focusFeedbackTimer",null)}handleSignal(e){const{type:t,payload:o}=e;switch(this.ensureFocus(),t){case p.KEYDOWN:case p.KEYUP:H(t,o);break;case p.MOUSEMOVE:o.point&&(this.updateCursorPosition(o.point),this.config.cursorEnabled&&this.showCursor(),this.executeMouseAction(p.POINTERMOVE,o));break;case p.MOUSEDOWN:case p.MOUSEUP:case p.CLICK:this.config.cursorEnabled&&this.showCursor(),this.executeMouseAction(t.startsWith(p.MOUSE)?t.replace(p.MOUSE,p.POINTER):t,o);break}}executeMouseAction(e,t){if(!this.rect)return;e===p.POINTERDOWN&&this.setState({isPointerDown:!0}),e===p.POINTERUP&&this.setState({isPointerDown:!1});const o=t.point||this.state.position,i=this.rect.left+T(o.x,this.rect.width),r=this.rect.top+T(o.y,this.rect.height);q(e,i,r,{button:t.button??0,buttons:this.state.isPointerDown?1:0})}ensureFocus(){if(!this.rect)return;const e=this.rect.left+T(this.state.position.x,this.rect.width),t=this.rect.top+T(this.state.position.y,this.rect.height),o=x(e,t);o&&M()!==o&&(X(o),this.triggerFocusFeedback())}triggerFocusFeedback(){this.setState({isFocusReturning:!0}),this.focusFeedbackTimer&&clearTimeout(this.focusFeedbackTimer),this.focusFeedbackTimer=setTimeout(()=>this.setState({isFocusReturning:!1}),500)}updateCursorPosition(e){this.setState({position:{...e}})}showCursor(){this.setState({isVisible:!0}),this.hideTimer&&clearTimeout(this.hideTimer),this.config.cursorAutoDelay&&this.config.cursorAutoDelay>0&&(this.hideTimer=setTimeout(()=>this.setState({isVisible:!1}),this.config.cursorAutoDelay))}reset(){this.state.isPointerDown&&this.executeMouseAction(p.POINTERUP,{}),this.hideTimer&&clearTimeout(this.hideTimer),this.focusFeedbackTimer&&clearTimeout(this.focusFeedbackTimer),this.setState({isVisible:!1,isPointerDown:!1,isFocusReturning:!1})}};const V={};function I(e,t){V[e]=t}function F(e){const t=V[e];return t||n.defineComponent({render:()=>n.h("div",{style:"color:red"},`[Unknown: ${e}]`)})}function v(e){const t=n.shallowRef(),o=n.ref(),i=n.ref(null),r=a=>{o.value=a};let s=null;return n.onMounted(()=>{const a=e();t.value=a,k.getInstance().register(a),"subscribe"in a&&a.subscribe(r);let c=null;i.value&&(i.value instanceof Element?c=i.value:i.value.$el instanceof Element&&(c=i.value.$el)),c&&"updateRect"in a&&(s=new ResizeObserver(l=>{for(const d of l)a.updateRect(d.target.getBoundingClientRect())}),s.observe(c),a.updateRect(c.getBoundingClientRect()))}),n.onUnmounted(()=>{s&&s.disconnect(),t.value&&t.value.destroy()}),{core:t,state:o,elementRef:i}}const ae={class:"omnipad-virtual-layer-base omnipad-prevent"},ce=n.defineComponent({__name:"VirtualLayerBase",props:{nodes:{}},setup(e){return(t,o)=>(n.openBlock(),n.createElementBlock("div",ae,[(n.openBlock(!0),n.createElementBlock(n.Fragment,null,n.renderList(e.nodes||[],i=>(n.openBlock(),n.createBlock(n.resolveDynamicComponent(n.unref(F)(i.type)),{key:i.uid,"tree-node":i},null,8,["tree-node"]))),128)),n.renderSlot(t.$slots,"default",{},void 0,!0)]))}}),_=(e,t)=>{const o=e.__vccOpts||e;for(const[i,r]of t)o[i]=r;return o},L=_(ce,[["__scopeId","data-v-6f1860f6"]]);function R(e,t,o={}){const i=t.treeNode,r=i&&i.type===e?i:void 0;i&&i.type!==e&&console.warn(`[OmniPad-Validation] Type mismatch! Component expected "${e}", but received "${i.type}". Config ignored.`);const s=n.inject(B.PARENT_ID_KEY,n.ref(void 0)),a=n.computed(()=>t.parentId||r?.config?.parentId||s.value),c=n.computed(()=>t.widgetId||r?.uid||J(e));n.provide(B.PARENT_ID_KEY,c);const l=n.computed(()=>{const d=r?.config||{},u=Object.fromEntries(Object.entries(t).filter(([g,w])=>w!==void 0&&g!=="treeNode"&&g!=="widgetId"));return{...o,...d,...u,id:c.value,type:e,parentId:a.value,layout:{...o.layout||{},...d.layout||{},...u.layout||{}}}});return{uid:c,config:l}}const le=["id"],Y=_(n.defineComponent({__name:"InputZone",props:{treeNode:{},widgetId:{},layout:{},preventFocusLoss:{}},setup(e){const t=e,o=n.useSlots(),i=n.ref(null),{uid:r,config:s}=R(h.INPUT_ZONE,t),{core:a,state:c,elementRef:l}=v(()=>new te(r.value,s.value)),d=n.computed(()=>{const f=t.treeNode?.config?.dynamicWidgetId;return t.treeNode?.children?.filter(E=>E.uid!==f)||[]}),u=n.computed(()=>{const E=(o.dynamicWidget?.()||[]).filter(O=>!(O.type===Comment||O.type===Text)),P=t.treeNode?.children?.find(O=>O.uid===t.treeNode?.config?.dynamicWidgetId),D=E.length>0;return E.length>1&&console.error(`[OmniPad-Validation] InputZone ${r.value} has multiple dynamic widgets in slot. Only the first one will be activated.`),D&&P&&console.warn(`[OmniPad-Validation] InputZone ${r.value} has both Slot and Config dynamic widgets. Config ignored.`),{nodeToRender:D?E[0]:P||null,isFromSlot:D}});n.watch(i,f=>{n.nextTick(()=>{f&&f?.uid&&a.value?.updateConfig({dynamicWidgetId:f.uid})})},{immediate:!0});const g=n.computed(()=>N(s.value.layout)),w=n.computed(()=>c.value?.isDynamicActive?{position:"absolute",left:`${c.value.dynamicPosition.x}%`,top:`${c.value.dynamicPosition.y}%`,zIndex:100,pointerEvents:"auto"}:{display:"none"}),he=f=>{a.value&&(a.value.onPointerDown(f),c.value?.isDynamicActive&&i.value&&typeof i.value.onPointerDown=="function"&&i.value.onPointerDown(f))},me=f=>{a.value&&(a.value.onPointerMove(f),c.value?.isDynamicActive&&i.value&&typeof i.value.onPointerMove=="function"&&i.value.onPointerMove(f))},S=f=>{c.value?.isDynamicActive&&i.value&&typeof i.value.onPointerUp=="function"&&i.value.onPointerUp(f),a.value&&a.value.onPointerUp(f)};return(f,E)=>(n.openBlock(),n.createElementBlock("div",{id:n.unref(r),ref_key:"elementRef",ref:l,class:"omnipad-input-zone omnipad-prevent",style:n.normalizeStyle(g.value)},[n.createVNode(L,{nodes:d.value},{default:n.withCtx(()=>[n.renderSlot(f.$slots,"default",{},void 0,!0)]),_:3},8,["nodes"]),n.unref(a)?.isInterceptorRequired?(n.openBlock(),n.createElementBlock("div",{key:0,class:"omnipad-input-zone-trigger",onPointerdown:he,onPointermove:me,onPointerup:S,onPointercancel:S,onLostpointercapture:S,onPointerleave:S},[n.createElementVNode("div",{class:"dynamic-widget-mount",style:n.normalizeStyle(w.value)},[u.value.isFromSlot?(n.openBlock(),n.createBlock(n.resolveDynamicComponent(u.value.nodeToRender),{key:0,ref:P=>i.value=P},null,512)):u.value.nodeToRender?(n.openBlock(),n.createBlock(n.resolveDynamicComponent(n.unref(F)(u.value.nodeToRender.type)),{key:1,ref:P=>i.value=P,"tree-node":u.value.nodeToRender},null,8,["tree-node"])):n.createCommentVNode("",!0)],4)],32)):n.createCommentVNode("",!0)],12,le))}}),[["__scopeId","data-v-02669919"]]),de=["id"],K=_(n.defineComponent({__name:"RootLayer",props:{treeNode:{},widgetId:{}},setup(e){const t=e,{uid:o,config:i}=R(h.ROOT_LAYER,t),{elementRef:r}=v(()=>new ie(o.value,i.value));return(s,a)=>(n.openBlock(),n.createElementBlock("div",{id:n.unref(o),ref_key:"elementRef",ref:r,class:"omnipad-virtual-layer"},[n.createVNode(L,{nodes:e.treeNode?.children||[]},{default:n.withCtx(()=>[n.renderSlot(s.$slots,"default",{},void 0,!0)]),_:3},8,["nodes"])],8,de))}}),[["__scopeId","data-v-a509fd6e"]]),ue=["id"],z=_(n.defineComponent({__name:"TargetZone",props:{treeNode:{},widgetId:{},cursorEnabled:{type:Boolean},cursorAutoDelay:{},layout:{}},setup(e){const t=e,o={cursorAutoDelay:2500},{uid:i,config:r}=R(h.TARGET_ZONE,t,o),{state:s,elementRef:a}=v(()=>new se(i.value,r.value)),c=n.computed(()=>N(r.value.layout)),l=n.computed(()=>s.value?{left:`${s.value.position.x}%`,top:`${s.value.position.y}%`,opacity:s.value.isVisible?1:0}:{display:"none"});return(d,u)=>(n.openBlock(),n.createElementBlock("div",{id:n.unref(i),ref_key:"elementRef",ref:a,class:"omnipad-target-zone",style:n.normalizeStyle(c.value)},[n.createVNode(n.Transition,{name:"pulse"},{default:n.withCtx(()=>[n.unref(s)?.isFocusReturning?(n.openBlock(),n.createElementBlock("div",{key:0,class:"focus-feedback-ring",style:n.normalizeStyle({left:`${n.unref(s).position.x}%`,top:`${n.unref(s).position.y}%`})},null,4)):n.createCommentVNode("",!0)]),_:1}),n.unref(r).cursorEnabled?(n.openBlock(),n.createElementBlock("div",{key:0,class:"omnipad-virtual-cursor",style:n.normalizeStyle(l.value)},[n.createElementVNode("div",{class:n.normalizeClass(["cursor-dot",{"is-down":n.unref(s)?.isPointerDown}])},null,2)],4)):n.createCommentVNode("",!0)],12,ue))}}),[["__scopeId","data-v-b9d49b97"]]),fe={key:0,class:"omnipad-button-label"},pe=_(n.defineComponent({__name:"VirtualButtonBase",props:{layout:{},isActive:{type:Boolean},label:{}},setup(e){const t=e,o=n.computed(()=>t.layout?N(t.layout):{});return(i,r)=>(n.openBlock(),n.createElementBlock("div",{class:n.normalizeClass(["omnipad-button-base",{"omnipad-is-active":e.isActive}]),style:n.normalizeStyle(o.value),tabindex:"-1"},[n.renderSlot(i.$slots,"default",{},()=>[e.label?(n.openBlock(),n.createElementBlock("span",fe,n.toDisplayString(e.label),1)):n.createCommentVNode("",!0)],!0)],6))}}),[["__scopeId","data-v-6cbe805c"]]),Z=n.defineComponent({__name:"VirtualKeyboardButton",props:{treeNode:{},widgetId:{},label:{},targetStageId:{},mapping:{},layout:{}},setup(e,{expose:t}){const o=e,i={label:"BTN"},{uid:r,config:s}=R(h.KEYBOARD_BUTTON,o,i),{core:a,state:c,elementRef:l}=v(()=>new ne(r.value,s.value)),d=g=>a.value?.onPointerDown(g),u=g=>a.value?.onPointerUp(g);return t({uid:r,onPointerDown:d,onPointerUp:u}),(g,w)=>(n.openBlock(),n.createBlock(pe,{id:n.unref(r),ref_key:"elementRef",ref:l,layout:n.unref(s).layout,label:n.unref(s).label,"is-active":n.unref(c)?.isPressed,onPointerdown:d,onPointerup:u,onPointercancel:u,onLostpointercapture:u},null,8,["id","layout","label","is-active"]))}});I(h.INPUT_ZONE,Y),I(h.ROOT_LAYER,K),I(h.TARGET_ZONE,z),I(h.KEYBOARD_BUTTON,Z),m.InputZone=Y,m.RootLayer=K,m.TargetZone=z,m.VirtualKeyboardButton=Z,m.registerComponent=I,Object.defineProperty(m,Symbol.toStringTag,{value:"Module"})}));
|
|
1
|
+
(function(f,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("@omnipad/core"),require("vue")):typeof define=="function"&&define.amd?define(["exports","@omnipad/core","vue"],a):(f=typeof globalThis<"u"?globalThis:f||self,a(f.OmnipadVue={},f.OmniPadCore,f.Vue))})(this,(function(f,a,e){"use strict";const b={};function P(o,n){b[o]=n}function S(o){const n=b[o];return n||e.defineComponent({render:()=>e.h("div",{style:"color:red"},`[Unknown: ${o}]`)})}function E(o){const n=e.shallowRef(),c=e.ref(),t=e.ref(null),l=i=>{c.value=i};let r=null;return e.onMounted(()=>{const i=o();n.value=i,a.Registry.getInstance().register(i),"subscribe"in i&&i.subscribe(l);let s=null;t.value&&(t.value instanceof Element?s=t.value:t.value.$el instanceof Element&&(s=t.value.$el)),s&&"updateRect"in i&&(r=new ResizeObserver(m=>{for(const p of m)i.updateRect(p.target.getBoundingClientRect())}),r.observe(s),i.updateRect(s.getBoundingClientRect()))}),e.onUnmounted(()=>{r&&r.disconnect(),n.value&&n.value.destroy()}),{core:n,state:c,elementRef:t}}const v={class:"omnipad-virtual-layer-base omnipad-prevent"},D=e.defineComponent({__name:"VirtualLayerBase",props:{nodes:{}},setup(o){return(n,c)=>(e.openBlock(),e.createElementBlock("div",v,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.nodes||[],t=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(e.unref(S)(t.type)),{key:t.uid,"tree-node":t},null,8,["tree-node"]))),128)),e.renderSlot(n.$slots,"default",{},void 0,!0)]))}}),B=(o,n)=>{const c=o.__vccOpts||o;for(const[t,l]of n)c[t]=l;return c},I=B(D,[["__scopeId","data-v-6f1860f6"]]);function C(o,n,c={}){const t=n.treeNode,l=t&&t.type===o?t:void 0;t&&t.type!==o&&console.warn(`[OmniPad-Validation] Type mismatch! Component expected "${o}", but received "${t.type}". Config ignored.`);const r=e.inject(a.CONTEXT.PARENT_ID_KEY,e.ref(void 0)),i=e.computed(()=>n.parentId||l?.config?.parentId||r.value),s=e.computed(()=>n.widgetId||l?.uid||a.generateUID(o));e.provide(a.CONTEXT.PARENT_ID_KEY,s);const m=e.computed(()=>{const p=l?.config||{},u=Object.fromEntries(Object.entries(n).filter(([y,k])=>k!==void 0&&y!=="treeNode"&&y!=="widgetId"));return{...c,...p,...u,id:s.value,type:o,parentId:i.value,layout:{...c.layout||{},...p.layout||{},...u.layout||{}}}});return{uid:s,config:m}}const V=["id"],$=B(e.defineComponent({__name:"InputZone",props:{treeNode:{},widgetId:{},layout:{},preventFocusLoss:{}},setup(o){const n=o,c=e.useSlots(),t=e.ref(null),{uid:l,config:r}=C(a.TYPES.INPUT_ZONE,n),{core:i,state:s,elementRef:m}=E(()=>new a.InputZoneCore(l.value,r.value)),p=e.computed(()=>{const d=n.treeNode?.config?.dynamicWidgetId;return n.treeNode?.children?.filter(_=>_.uid!==d)||[]}),u=e.computed(()=>{const _=(c.dynamicWidget?.()||[]).filter(N=>!(N.type===Comment||N.type===Text)),g=n.treeNode?.children?.find(N=>N.uid===n.treeNode?.config?.dynamicWidgetId),R=_.length>0;return _.length>1&&console.error(`[OmniPad-Validation] InputZone ${l.value} has multiple dynamic widgets in slot. Only the first one will be activated.`),R&&g&&console.warn(`[OmniPad-Validation] InputZone ${l.value} has both Slot and Config dynamic widgets. Config ignored.`),{nodeToRender:R?_[0]:g||null,isFromSlot:R}});e.watch(t,d=>{e.nextTick(()=>{d&&d?.uid&&i.value?.updateConfig({dynamicWidgetId:d.uid})})},{immediate:!0});const y=e.computed(()=>a.resolveLayoutStyle(r.value.layout)),k=e.computed(()=>s.value?.isDynamicActive?{position:"absolute",left:`${s.value.dynamicPosition.x}%`,top:`${s.value.dynamicPosition.y}%`,zIndex:100,pointerEvents:"auto"}:{display:"none"}),U=d=>{i.value&&(i.value.onPointerDown(d),s.value?.isDynamicActive&&t.value&&typeof t.value.onPointerDown=="function"&&t.value.onPointerDown(d))},Y=d=>{i.value&&(i.value.onPointerMove(d),s.value?.isDynamicActive&&t.value&&typeof t.value.onPointerMove=="function"&&t.value.onPointerMove(d))},T=d=>{s.value?.isDynamicActive&&t.value&&typeof t.value.onPointerUp=="function"&&t.value.onPointerUp(d),i.value&&i.value.onPointerUp(d)};return(d,_)=>(e.openBlock(),e.createElementBlock("div",{id:e.unref(l),ref_key:"elementRef",ref:m,class:"omnipad-input-zone omnipad-prevent",style:e.normalizeStyle(y.value)},[e.createVNode(I,{nodes:p.value},{default:e.withCtx(()=>[e.renderSlot(d.$slots,"default",{},void 0,!0)]),_:3},8,["nodes"]),e.unref(i)?.isInterceptorRequired?(e.openBlock(),e.createElementBlock("div",{key:0,class:"omnipad-input-zone-trigger",onPointerdown:U,onPointermove:Y,onPointerup:T,onPointercancel:T,onLostpointercapture:T,onPointerleave:T},[e.createElementVNode("div",{class:"dynamic-widget-mount",style:e.normalizeStyle(k.value)},[u.value.isFromSlot?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(u.value.nodeToRender),{key:0,ref:g=>t.value=g},null,512)):u.value.nodeToRender?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(e.unref(S)(u.value.nodeToRender.type)),{key:1,ref:g=>t.value=g,"tree-node":u.value.nodeToRender},null,8,["tree-node"])):e.createCommentVNode("",!0)],4)],32)):e.createCommentVNode("",!0)],12,V))}}),[["__scopeId","data-v-02669919"]]),A=["id"],h=B(e.defineComponent({__name:"RootLayer",props:{treeNode:{},widgetId:{}},setup(o){const n=o,{uid:c,config:t}=C(a.TYPES.ROOT_LAYER,n),{elementRef:l}=E(()=>new a.RootLayerCore(c.value,t.value));return(r,i)=>(e.openBlock(),e.createElementBlock("div",{id:e.unref(c),ref_key:"elementRef",ref:l,class:"omnipad-virtual-layer"},[e.createVNode(I,{nodes:o.treeNode?.children||[]},{default:e.withCtx(()=>[e.renderSlot(r.$slots,"default",{},void 0,!0)]),_:3},8,["nodes"])],8,A))}}),[["__scopeId","data-v-a509fd6e"]]),L=["id"],w=B(e.defineComponent({__name:"TargetZone",props:{treeNode:{},widgetId:{},cursorEnabled:{type:Boolean},cursorAutoDelay:{},layout:{}},setup(o){const n=o,c={cursorAutoDelay:2500},{uid:t,config:l}=C(a.TYPES.TARGET_ZONE,n,c),{state:r,elementRef:i}=E(()=>new a.TargetZoneCore(t.value,l.value)),s=e.computed(()=>a.resolveLayoutStyle(l.value.layout)),m=e.computed(()=>r.value?{left:`${r.value.position.x}%`,top:`${r.value.position.y}%`,opacity:r.value.isVisible?1:0}:{display:"none"});return(p,u)=>(e.openBlock(),e.createElementBlock("div",{id:e.unref(t),ref_key:"elementRef",ref:i,class:"omnipad-target-zone",style:e.normalizeStyle(s.value)},[e.createVNode(e.Transition,{name:"pulse"},{default:e.withCtx(()=>[e.unref(r)?.isFocusReturning?(e.openBlock(),e.createElementBlock("div",{key:0,class:"focus-feedback-ring",style:e.normalizeStyle({left:`${e.unref(r).position.x}%`,top:`${e.unref(r).position.y}%`})},null,4)):e.createCommentVNode("",!0)]),_:1}),e.unref(l).cursorEnabled?(e.openBlock(),e.createElementBlock("div",{key:0,class:"omnipad-virtual-cursor",style:e.normalizeStyle(m.value)},[e.createElementVNode("div",{class:e.normalizeClass(["cursor-dot",{"is-down":e.unref(r)?.isPointerDown}])},null,2)],4)):e.createCommentVNode("",!0)],12,L))}}),[["__scopeId","data-v-b9d49b97"]]),x={key:0,class:"omnipad-button-label"},z=B(e.defineComponent({__name:"VirtualButtonBase",props:{layout:{},isActive:{type:Boolean},label:{}},setup(o){const n=o,c=e.computed(()=>n.layout?a.resolveLayoutStyle(n.layout):{});return(t,l)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["omnipad-button-base",{"omnipad-is-active":o.isActive}]),style:e.normalizeStyle(c.value),tabindex:"-1"},[e.renderSlot(t.$slots,"default",{},()=>[o.label?(e.openBlock(),e.createElementBlock("span",x,e.toDisplayString(o.label),1)):e.createCommentVNode("",!0)],!0)],6))}}),[["__scopeId","data-v-6cbe805c"]]),O=e.defineComponent({__name:"VirtualKeyboardButton",props:{treeNode:{},widgetId:{},label:{},targetStageId:{},mapping:{},layout:{}},setup(o,{expose:n}){const c=o,t={label:"BTN"},{uid:l,config:r}=C(a.TYPES.KEYBOARD_BUTTON,c,t),{core:i,state:s,elementRef:m}=E(()=>new a.KeyboardButtonCore(l.value,r.value)),p=y=>i.value?.onPointerDown(y),u=y=>i.value?.onPointerUp(y);return n({uid:l,onPointerDown:p,onPointerUp:u}),(y,k)=>(e.openBlock(),e.createBlock(z,{id:e.unref(l),ref_key:"elementRef",ref:m,layout:e.unref(r).layout,label:e.unref(r).label,"is-active":e.unref(s)?.isPressed,onPointerdown:p,onPointerup:u,onPointercancel:u,onLostpointercapture:u},null,8,["id","layout","label","is-active"]))}});P(a.TYPES.INPUT_ZONE,$),P(a.TYPES.ROOT_LAYER,h),P(a.TYPES.TARGET_ZONE,w),P(a.TYPES.KEYBOARD_BUTTON,O),f.InputZone=$,f.RootLayer=h,f.TargetZone=w,f.VirtualKeyboardButton=O,f.registerComponent=P,Object.defineProperty(f,Symbol.toStringTag,{value:"Module"})}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@omnipad/vue",
|
|
3
|
-
"version": "0.1.1-alpha.
|
|
3
|
+
"version": "0.1.1-alpha.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./dist/omnipad-vue.umd.js",
|
|
6
6
|
"module": "./dist/omnipad-vue.mjs",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"vue": "^3.5.27"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@omnipad/core": "0.1.1-alpha.
|
|
30
|
+
"@omnipad/core": "0.1.1-alpha.1"
|
|
31
31
|
},
|
|
32
32
|
"publishConfig": {
|
|
33
33
|
"access": "public",
|