incajs 0.0.20 → 0.0.22
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 +1 -1
- package/dist/callbacks.d.mts +9 -9
- package/dist/chunks/hooks-TbLjfN0c.js +417 -0
- package/dist/chunks/rendererCore-BUNTDvYu.js +110 -0
- package/dist/document.d.mts +11 -0
- package/dist/element/eventHandlers.d.mts +1 -1
- package/dist/element/handle.d.mts +14 -4
- package/dist/element/types.d.mts +22 -5
- package/dist/eventTarget.d.mts +5 -4
- package/dist/events.d.mts +49 -17
- package/dist/index.d.mts +2 -2
- package/dist/index.js +1 -3
- package/dist/native.d.mts +9 -4
- package/dist/rendererCore.d.mts +1 -1
- package/dist/rendererCore.js +3 -4
- package/dist/types.d.mts +235 -25
- package/dist/vue/nodeOps.d.mts +1 -1
- package/dist/vue/patchProp.d.mts +2 -2
- package/dist/vue.js +55 -56
- package/dist/window.d.mts +8 -8
- package/package.json +1 -1
- package/dist/chunks/handle-DdYIkUcm.js +0 -215
- package/dist/chunks/hooks-D1NFQN8Q.js +0 -205
- package/dist/chunks/rendererCore-NnTAUL80.js +0 -110
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ framework. No Chromium, no DOM: UI renders directly on the GPU via
|
|
|
12
12
|
|
|
13
13
|
## How it works
|
|
14
14
|
|
|
15
|
-
- The root `incajs` export is the `window`
|
|
15
|
+
- The root `incajs` export is the `window` and `document` event targets and
|
|
16
16
|
the public types.
|
|
17
17
|
- `incajs/vue` is a custom renderer mapping Vue 3's `createRenderer`
|
|
18
18
|
lifecycle onto the native host bridge. `createIncaApp(rootComponent,
|
package/dist/callbacks.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { HostCallback } from './native.mts';
|
|
2
|
-
import { CallbackId, EventListenerOrObject
|
|
1
|
+
import { EventTargetId, HostCallback } from './native.mts';
|
|
2
|
+
import { CallbackId, EventListenerOrObject } from './types.mts';
|
|
3
3
|
/**
|
|
4
4
|
* Records `callable` under `callbackId` at `globalThis.__inca_callbacks__`.
|
|
5
5
|
* @param group - the node, event and capture flag as one string, from {@link groupOf}
|
|
@@ -7,13 +7,13 @@ import { CallbackId, EventListenerOrObject, NodeId } from './types.mts';
|
|
|
7
7
|
* @param callbackId - the id the host returned for the registration
|
|
8
8
|
* @param callable - the function the host runs
|
|
9
9
|
*/
|
|
10
|
-
export declare function addCallback(group: string, listener: EventListenerOrObject<never>, callbackId: CallbackId, callable: HostCallback): void;
|
|
10
|
+
export declare function addCallback(group: string, listener: EventListenerOrObject<never, never>, callbackId: CallbackId, callable: HostCallback): void;
|
|
11
11
|
/**
|
|
12
12
|
* @param group - the node, event and capture flag as one string
|
|
13
13
|
* @param listener - the listener the caller registered
|
|
14
14
|
* @returns the id registered for the pair, or `undefined`
|
|
15
15
|
*/
|
|
16
|
-
export declare function callbackIdFor(group: string, listener: EventListenerOrObject<never>): CallbackId | undefined;
|
|
16
|
+
export declare function callbackIdFor(group: string, listener: EventListenerOrObject<never, never>): CallbackId | undefined;
|
|
17
17
|
/**
|
|
18
18
|
* Forgets `callbackId` and the listener it names. An id that was never
|
|
19
19
|
* registered, or was released already, changes nothing.
|
|
@@ -21,11 +21,11 @@ export declare function callbackIdFor(group: string, listener: EventListenerOrOb
|
|
|
21
21
|
*/
|
|
22
22
|
export declare function releaseCallback(callbackId: CallbackId): void;
|
|
23
23
|
/**
|
|
24
|
-
* The capture flag is part of the identity: the same
|
|
25
|
-
* can listen in both phases side by side.
|
|
26
|
-
* @param
|
|
24
|
+
* The capture flag is part of the identity: the same target, event and
|
|
25
|
+
* function can listen in both phases side by side.
|
|
26
|
+
* @param target - the event target (node id, "$document" or "$window")
|
|
27
27
|
* @param event - the event name
|
|
28
28
|
* @param capture - the capture flag of the registration
|
|
29
|
-
* @returns the
|
|
29
|
+
* @returns the target, event and capture flag as one string
|
|
30
30
|
*/
|
|
31
|
-
export declare const groupOf: (
|
|
31
|
+
export declare const groupOf: (target: EventTargetId, event: string, capture: boolean | undefined) => string;
|
|
@@ -0,0 +1,417 @@
|
|
|
1
|
+
//#region src/element/eventHandlers.mts
|
|
2
|
+
var e = /* @__PURE__ */ "auxclick.blur.click.contextmenu.dblclick.focus.gotpointercapture.keydown.keyup.lostpointercapture.mousedown.mouseenter.mouseleave.mousemove.mouseout.mouseover.mouseup.pointerdown.pointerenter.pointerleave.pointermove.pointerout.pointerover.pointerup.scroll.wheel".split(".");
|
|
3
|
+
function t(t, n) {
|
|
4
|
+
for (let r of e) {
|
|
5
|
+
let e = null, i = function(t) {
|
|
6
|
+
typeof e == "function" && Reflect.apply(e, this, [t]) === !1 && t.preventDefault();
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(t, `on${r}`, {
|
|
9
|
+
get: () => e,
|
|
10
|
+
set(a) {
|
|
11
|
+
n() || (e = typeof a == "function" || typeof a == "object" && a ? a : null, e === null ? t.removeEventListener(r, i) : t.addEventListener(r, i));
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
return t;
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region src/native.mts
|
|
19
|
+
function n() {
|
|
20
|
+
return globalThis.__inca_native__;
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region src/element/lifecycle.mts
|
|
24
|
+
var r = /* @__PURE__ */ new WeakSet();
|
|
25
|
+
function i(e, t) {
|
|
26
|
+
return r.add(e), Object.defineProperty(e, "__node_id", { value: t });
|
|
27
|
+
}
|
|
28
|
+
function a(e) {
|
|
29
|
+
return typeof e == "object" && !!e && r.has(e);
|
|
30
|
+
}
|
|
31
|
+
var o = /* @__PURE__ */ new Map(), s = new FinalizationRegistry((e) => {
|
|
32
|
+
o.get(e)?.deref() || o.delete(e);
|
|
33
|
+
});
|
|
34
|
+
function c(e) {
|
|
35
|
+
o.set(e.__node_id, new WeakRef(e)), s.register(e, e.__node_id);
|
|
36
|
+
}
|
|
37
|
+
function l(e) {
|
|
38
|
+
o.delete(e);
|
|
39
|
+
}
|
|
40
|
+
function u(e) {
|
|
41
|
+
return o.get(e)?.deref();
|
|
42
|
+
}
|
|
43
|
+
var d = /* @__PURE__ */ new WeakSet();
|
|
44
|
+
function f(e) {
|
|
45
|
+
return d.has(e);
|
|
46
|
+
}
|
|
47
|
+
function p(e) {
|
|
48
|
+
if (d.add(e), e.kind !== "text") {
|
|
49
|
+
l(e.__node_id);
|
|
50
|
+
for (let t of e.children) p(t);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function m(e) {
|
|
54
|
+
for (let t of e) {
|
|
55
|
+
let e = u(t);
|
|
56
|
+
e && p(e);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
var ee = new FinalizationRegistry((e) => n().releaseNode(e));
|
|
60
|
+
function te(e) {
|
|
61
|
+
ee.register(e, e.__node_id);
|
|
62
|
+
}
|
|
63
|
+
//#endregion
|
|
64
|
+
//#region src/callbacks.mts
|
|
65
|
+
var h = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Map(), _ = () => globalThis.__inca_callbacks__ ??= {};
|
|
66
|
+
function v(e, t, n, r) {
|
|
67
|
+
_()[n] = r;
|
|
68
|
+
let i = h.get(e);
|
|
69
|
+
i || h.set(e, i = /* @__PURE__ */ new Map()), i.set(t, n), g.set(n, {
|
|
70
|
+
group: e,
|
|
71
|
+
listener: t
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
function y(e, t) {
|
|
75
|
+
return h.get(e)?.get(t);
|
|
76
|
+
}
|
|
77
|
+
function b(e) {
|
|
78
|
+
delete _()[e];
|
|
79
|
+
let t = g.get(e);
|
|
80
|
+
if (t === void 0) return;
|
|
81
|
+
g.delete(e);
|
|
82
|
+
let n = h.get(t.group);
|
|
83
|
+
n?.delete(t.listener), n?.size === 0 && h.delete(t.group);
|
|
84
|
+
}
|
|
85
|
+
function x(e) {
|
|
86
|
+
for (let t of e) b(t);
|
|
87
|
+
}
|
|
88
|
+
var S = (e, t, n) => `${e}:${t}:${n === !0}`;
|
|
89
|
+
Object.defineProperty(globalThis, "__inca_released__", {
|
|
90
|
+
value: (e, t) => {
|
|
91
|
+
let n, r = !1;
|
|
92
|
+
for (let e of t) try {
|
|
93
|
+
x([e]);
|
|
94
|
+
} catch (e) {
|
|
95
|
+
r || (n = e), r = !0;
|
|
96
|
+
}
|
|
97
|
+
if (m(e), r) throw n;
|
|
98
|
+
},
|
|
99
|
+
configurable: !0
|
|
100
|
+
});
|
|
101
|
+
//#endregion
|
|
102
|
+
//#region src/events.mts
|
|
103
|
+
var C = 0;
|
|
104
|
+
function ne() {
|
|
105
|
+
return C;
|
|
106
|
+
}
|
|
107
|
+
function w(e) {
|
|
108
|
+
return (...t) => {
|
|
109
|
+
let n = t[0]?.eventId;
|
|
110
|
+
return typeof n == "number" && n > C && (C = n), e(...t);
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
function T(e, t, r, i = {}) {
|
|
114
|
+
if (r == null) return;
|
|
115
|
+
let a = S(e, t, i.capture);
|
|
116
|
+
if (y(a, r) !== void 0) return;
|
|
117
|
+
let o = (...e) => typeof r == "function" ? r.apply(e[0]?.currentTarget, e) : r.handleEvent.apply(r, e), s = i.once ? (...n) => (E(e, t, r, i), o(...n)) : o;
|
|
118
|
+
v(a, r, n().addEventListener(e, t, i.capture === !0, i.passive === !0), w(s));
|
|
119
|
+
}
|
|
120
|
+
function E(e, t, r, i = {}) {
|
|
121
|
+
if (r == null) return;
|
|
122
|
+
let a = y(S(e, t, i.capture), r);
|
|
123
|
+
a !== void 0 && (n().removeEventListener(e, t, a), b(a));
|
|
124
|
+
}
|
|
125
|
+
function D(e, t) {
|
|
126
|
+
return n().dispatchEvent(e, t);
|
|
127
|
+
}
|
|
128
|
+
function O(e) {
|
|
129
|
+
n().click(e);
|
|
130
|
+
}
|
|
131
|
+
function k(e, t) {
|
|
132
|
+
n().focusNode(e, t);
|
|
133
|
+
}
|
|
134
|
+
function A(e) {
|
|
135
|
+
n().blurNode(e);
|
|
136
|
+
}
|
|
137
|
+
function j(e, t) {
|
|
138
|
+
n().setPointerCapture(e, t);
|
|
139
|
+
}
|
|
140
|
+
function M(e, t) {
|
|
141
|
+
n().releasePointerCapture(e, t);
|
|
142
|
+
}
|
|
143
|
+
function N(e, t) {
|
|
144
|
+
return n().hasPointerCapture(e, t);
|
|
145
|
+
}
|
|
146
|
+
//#endregion
|
|
147
|
+
//#region src/eventTarget.mts
|
|
148
|
+
function P(e, t = []) {
|
|
149
|
+
let n = typeof e == "function" ? e : () => e;
|
|
150
|
+
return {
|
|
151
|
+
addEventListener(e, r, i) {
|
|
152
|
+
let a = typeof i == "boolean" ? { capture: i } : i ?? {};
|
|
153
|
+
T(n(), e, r, {
|
|
154
|
+
...a,
|
|
155
|
+
passive: a.passive ?? t.includes(e)
|
|
156
|
+
});
|
|
157
|
+
},
|
|
158
|
+
removeEventListener(e, t, r) {
|
|
159
|
+
let i = typeof r == "boolean" ? r : r?.capture;
|
|
160
|
+
E(n(), e, t, { capture: i });
|
|
161
|
+
},
|
|
162
|
+
dispatchEvent: (e) => D(n(), e)
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
//#endregion
|
|
166
|
+
//#region src/tree.mts
|
|
167
|
+
function F() {
|
|
168
|
+
return n().rootNodeId();
|
|
169
|
+
}
|
|
170
|
+
function re(e) {
|
|
171
|
+
return n().createNode(e);
|
|
172
|
+
}
|
|
173
|
+
function ie(e, t) {
|
|
174
|
+
n().appendChild(e, t);
|
|
175
|
+
}
|
|
176
|
+
function ae(e, t, r) {
|
|
177
|
+
n().insertBefore(e, t, r);
|
|
178
|
+
}
|
|
179
|
+
function oe(e, t) {
|
|
180
|
+
n().removeChild(e, t);
|
|
181
|
+
}
|
|
182
|
+
function se(e) {
|
|
183
|
+
x(n().destroyNode(e));
|
|
184
|
+
}
|
|
185
|
+
function ce(e) {
|
|
186
|
+
n().holdNode(e);
|
|
187
|
+
}
|
|
188
|
+
function le(e) {
|
|
189
|
+
n().releaseNode(e);
|
|
190
|
+
}
|
|
191
|
+
function I(e, t, r) {
|
|
192
|
+
n().setAttribute(e, t, r);
|
|
193
|
+
}
|
|
194
|
+
function L(e, t) {
|
|
195
|
+
return n().getAttribute(e, t);
|
|
196
|
+
}
|
|
197
|
+
function R(e) {
|
|
198
|
+
return n().layoutOf(e);
|
|
199
|
+
}
|
|
200
|
+
function z(e) {
|
|
201
|
+
return n().scrollOf(e);
|
|
202
|
+
}
|
|
203
|
+
function B(e, t, r) {
|
|
204
|
+
n().scrollNode(e, t, r);
|
|
205
|
+
}
|
|
206
|
+
function V(e, t, r) {
|
|
207
|
+
n().scrollIntoViewNode(e, t, r);
|
|
208
|
+
}
|
|
209
|
+
function H(e, t) {
|
|
210
|
+
n().removeAttribute(e, t);
|
|
211
|
+
}
|
|
212
|
+
function U(e, t, r) {
|
|
213
|
+
n().setStyle(e, t, r);
|
|
214
|
+
}
|
|
215
|
+
function ue(e, t) {
|
|
216
|
+
n().removeStyle(e, t);
|
|
217
|
+
}
|
|
218
|
+
function W() {
|
|
219
|
+
return n().focusedNode();
|
|
220
|
+
}
|
|
221
|
+
//#endregion
|
|
222
|
+
//#region src/element/geometry.mts
|
|
223
|
+
function G(e) {
|
|
224
|
+
return f(e) ? null : R(e.__node_id);
|
|
225
|
+
}
|
|
226
|
+
function K(e) {
|
|
227
|
+
let t = e.parent;
|
|
228
|
+
return !G(e) || !t || !G(t) ? null : t;
|
|
229
|
+
}
|
|
230
|
+
function q(e) {
|
|
231
|
+
let t = G(e);
|
|
232
|
+
if (!t) return {
|
|
233
|
+
left: 0,
|
|
234
|
+
top: 0
|
|
235
|
+
};
|
|
236
|
+
let n = K(e), r = n ? G(n) : null;
|
|
237
|
+
return {
|
|
238
|
+
left: Math.round(t[0] - (r ? r[0] + r[4] : 0) + t[5]) || 0,
|
|
239
|
+
top: Math.round(t[1] - (r ? r[1] + r[4] : 0) + t[6]) || 0
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
function J(e) {
|
|
243
|
+
let [t, n, r, i] = e ?? [
|
|
244
|
+
0,
|
|
245
|
+
0,
|
|
246
|
+
0,
|
|
247
|
+
0,
|
|
248
|
+
0
|
|
249
|
+
], a = {
|
|
250
|
+
x: t,
|
|
251
|
+
y: n,
|
|
252
|
+
width: r,
|
|
253
|
+
height: i,
|
|
254
|
+
top: n,
|
|
255
|
+
left: t,
|
|
256
|
+
right: t + r,
|
|
257
|
+
bottom: n + i
|
|
258
|
+
};
|
|
259
|
+
return {
|
|
260
|
+
...a,
|
|
261
|
+
toJSON: () => ({ ...a })
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
function de(e, t) {
|
|
265
|
+
let n = t === "button" ? 0 : -1;
|
|
266
|
+
if (typeof e != "string" && typeof e != "number") return n;
|
|
267
|
+
let r = /^[\t\n\f\r ]*([+-]?\d+)/.exec(String(e));
|
|
268
|
+
if (!r) return n;
|
|
269
|
+
let i = Number(r[1]) || 0;
|
|
270
|
+
return i >= -2147483648 && i <= 2147483647 ? i : n;
|
|
271
|
+
}
|
|
272
|
+
//#endregion
|
|
273
|
+
//#region src/element/scroll.mts
|
|
274
|
+
function Y(e, t, n) {
|
|
275
|
+
if (f(e)) return;
|
|
276
|
+
let [r, i] = t, [a, o] = typeof r == "object" ? [r?.left, r?.top] : [r, i], [s, c] = n ? z(e.__node_id) ?? [0, 0] : [0, 0], l = (e, t) => {
|
|
277
|
+
if (e === void 0) return null;
|
|
278
|
+
let r = Number(e);
|
|
279
|
+
return (n ? t : 0) + (Number.isFinite(r) ? r : 0);
|
|
280
|
+
};
|
|
281
|
+
B(e.__node_id, l(a, s), l(o, c));
|
|
282
|
+
}
|
|
283
|
+
function fe(e) {
|
|
284
|
+
let t = [
|
|
285
|
+
"start",
|
|
286
|
+
"center",
|
|
287
|
+
"end",
|
|
288
|
+
"nearest"
|
|
289
|
+
];
|
|
290
|
+
return typeof e == "object" && e ? {
|
|
291
|
+
block: t.includes(e.block ?? "") ? e.block : "start",
|
|
292
|
+
inline: t.includes(e.inline ?? "") ? e.inline : "nearest"
|
|
293
|
+
} : {
|
|
294
|
+
block: e === !1 ? "end" : "start",
|
|
295
|
+
inline: "nearest"
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
//#endregion
|
|
299
|
+
//#region src/element/handle.mts
|
|
300
|
+
function X(e, n, r, o = []) {
|
|
301
|
+
let s = P(() => e, o), l = () => f(u) ? null : z(e), u = t(i({
|
|
302
|
+
get id() {
|
|
303
|
+
return f(u) ? "" : String(L(e, "id") ?? "");
|
|
304
|
+
},
|
|
305
|
+
set id(t) {
|
|
306
|
+
f(u) || I(e, "id", String(t));
|
|
307
|
+
},
|
|
308
|
+
kind: n,
|
|
309
|
+
parent: null,
|
|
310
|
+
children: [],
|
|
311
|
+
focus: (t) => {
|
|
312
|
+
f(u) || k(e, !!t?.preventScroll);
|
|
313
|
+
},
|
|
314
|
+
blur: () => A(e),
|
|
315
|
+
click: () => {
|
|
316
|
+
f(u) || O(e);
|
|
317
|
+
},
|
|
318
|
+
setPointerCapture: (t) => j(e, t),
|
|
319
|
+
releasePointerCapture: (t) => M(e, t),
|
|
320
|
+
hasPointerCapture: (t) => N(e, t),
|
|
321
|
+
contains: (e) => {
|
|
322
|
+
if (e == null) return !1;
|
|
323
|
+
if (!a(e)) throw TypeError("the value is not a node. pass an element, a text node or null");
|
|
324
|
+
for (let t = e; t !== null; t = t.parent) if (t === u) return !0;
|
|
325
|
+
return !1;
|
|
326
|
+
},
|
|
327
|
+
addEventListener: (...e) => {
|
|
328
|
+
f(u) || s.addEventListener(...e);
|
|
329
|
+
},
|
|
330
|
+
removeEventListener: (...e) => {
|
|
331
|
+
f(u) || s.removeEventListener(...e);
|
|
332
|
+
},
|
|
333
|
+
dispatchEvent: (e) => f(u) || s.dispatchEvent(e),
|
|
334
|
+
get tabIndex() {
|
|
335
|
+
return de(f(u) ? null : L(e, "tabindex"), r ?? "");
|
|
336
|
+
},
|
|
337
|
+
set tabIndex(t) {
|
|
338
|
+
f(u) || I(e, "tabindex", t | 0);
|
|
339
|
+
},
|
|
340
|
+
getBoundingClientRect: () => J(G(u)),
|
|
341
|
+
get offsetWidth() {
|
|
342
|
+
return Math.round(G(u)?.[2] ?? 0);
|
|
343
|
+
},
|
|
344
|
+
get offsetHeight() {
|
|
345
|
+
return Math.round(G(u)?.[3] ?? 0);
|
|
346
|
+
},
|
|
347
|
+
get offsetLeft() {
|
|
348
|
+
return q(u).left;
|
|
349
|
+
},
|
|
350
|
+
get offsetTop() {
|
|
351
|
+
return q(u).top;
|
|
352
|
+
},
|
|
353
|
+
get offsetParent() {
|
|
354
|
+
return K(u);
|
|
355
|
+
},
|
|
356
|
+
get clientWidth() {
|
|
357
|
+
let e = G(u);
|
|
358
|
+
return e ? Math.max(0, Math.round(e[2] - 2 * e[4])) : 0;
|
|
359
|
+
},
|
|
360
|
+
get clientHeight() {
|
|
361
|
+
let e = G(u);
|
|
362
|
+
return e ? Math.max(0, Math.round(e[3] - 2 * e[4])) : 0;
|
|
363
|
+
},
|
|
364
|
+
get clientLeft() {
|
|
365
|
+
return Math.round(G(u)?.[4] ?? 0);
|
|
366
|
+
},
|
|
367
|
+
get clientTop() {
|
|
368
|
+
return Math.round(G(u)?.[4] ?? 0);
|
|
369
|
+
},
|
|
370
|
+
get scrollLeft() {
|
|
371
|
+
return l()?.[0] ?? 0;
|
|
372
|
+
},
|
|
373
|
+
set scrollLeft(e) {
|
|
374
|
+
Y(u, [e], !1);
|
|
375
|
+
},
|
|
376
|
+
get scrollTop() {
|
|
377
|
+
return l()?.[1] ?? 0;
|
|
378
|
+
},
|
|
379
|
+
set scrollTop(e) {
|
|
380
|
+
Y(u, [void 0, e], !1);
|
|
381
|
+
},
|
|
382
|
+
get scrollWidth() {
|
|
383
|
+
return u.clientWidth + Math.round(l()?.[2] ?? 0);
|
|
384
|
+
},
|
|
385
|
+
get scrollHeight() {
|
|
386
|
+
return u.clientHeight + Math.round(l()?.[3] ?? 0);
|
|
387
|
+
},
|
|
388
|
+
scrollTo: (...e) => Y(u, e, !1),
|
|
389
|
+
scrollBy: (...e) => Y(u, e, !0),
|
|
390
|
+
scrollIntoView: (t) => {
|
|
391
|
+
if (f(u)) return;
|
|
392
|
+
let { block: n, inline: r } = fe(t);
|
|
393
|
+
V(e, n, r);
|
|
394
|
+
}
|
|
395
|
+
}, e), () => f(u));
|
|
396
|
+
return n === "element" && c(u), u;
|
|
397
|
+
}
|
|
398
|
+
function pe() {
|
|
399
|
+
let e = W();
|
|
400
|
+
return e === null ? null : u(e) ?? null;
|
|
401
|
+
}
|
|
402
|
+
function Z() {
|
|
403
|
+
let e = F();
|
|
404
|
+
return u(e) ?? X(e, "element", void 0, ["wheel"]);
|
|
405
|
+
}
|
|
406
|
+
//#endregion
|
|
407
|
+
//#region src/document.mts
|
|
408
|
+
var Q = /* @__PURE__ */ Object.defineProperties(t(P("$document", ["wheel"]), () => !1), {
|
|
409
|
+
[Symbol.toStringTag]: { value: "Document" },
|
|
410
|
+
activeElement: { get: pe }
|
|
411
|
+
}), $ = /* @__PURE__ */ Object.defineProperty(t(P("$window", ["wheel"]), () => !1), Symbol.toStringTag, { value: "Window" });
|
|
412
|
+
Object.defineProperty(globalThis, "__inca_targets__", {
|
|
413
|
+
value: (e) => e.map((e) => e === "$document" ? Q : e === "$window" ? $ : u(e) ?? (e === F() ? Z() : null)),
|
|
414
|
+
configurable: !0
|
|
415
|
+
});
|
|
416
|
+
//#endregion
|
|
417
|
+
export { E as A, P as C, D, O as E, p as M, te as N, k as O, i as P, U as S, A as T, F as _, ie as a, z as b, W as c, ae as d, R as f, ue as g, oe as h, Z as i, f as j, ne as k, L as l, H as m, Q as n, re as o, le as p, X as r, se as s, $ as t, ce as u, V as v, T as w, I as x, B as y };
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { A as e, C as t, D as n, E as r, M as i, N as a, O as o, P as s, S as c, T as l, _ as u, a as d, b as f, c as p, d as m, f as h, g, h as _, i as v, j as y, k as b, l as x, m as S, o as C, p as w, r as T, s as E, t as D, u as O, v as k, w as A, x as j, y as M } from "./hooks-TbLjfN0c.js";
|
|
2
|
+
//#region \0rolldown/runtime.js
|
|
3
|
+
var N = Object.defineProperty, P = (e, t) => {
|
|
4
|
+
let n = {};
|
|
5
|
+
for (var r in e) N(n, r, {
|
|
6
|
+
get: e[r],
|
|
7
|
+
enumerable: !0
|
|
8
|
+
});
|
|
9
|
+
return t || N(n, Symbol.toStringTag, { value: "Module" }), n;
|
|
10
|
+
};
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region src/element/shadowTree.mts
|
|
13
|
+
function F(e) {
|
|
14
|
+
let t = C(e);
|
|
15
|
+
return T(t, "element", e);
|
|
16
|
+
}
|
|
17
|
+
function I(e) {
|
|
18
|
+
let t = C("text");
|
|
19
|
+
return j(t, "value", e), s({
|
|
20
|
+
kind: "text",
|
|
21
|
+
parent: null,
|
|
22
|
+
text: e
|
|
23
|
+
}, t);
|
|
24
|
+
}
|
|
25
|
+
function L() {
|
|
26
|
+
let e = C("div");
|
|
27
|
+
return c(e, "display", "none"), T(e, "comment");
|
|
28
|
+
}
|
|
29
|
+
function R(e, t) {
|
|
30
|
+
j(e.__node_id, "value", t), e.text = t;
|
|
31
|
+
}
|
|
32
|
+
function z(e, t) {
|
|
33
|
+
for (let t of e.children.splice(0)) E(t.__node_id), i(t), t.parent = null;
|
|
34
|
+
if (!t) return;
|
|
35
|
+
let n = I(t);
|
|
36
|
+
d(e.__node_id, n.__node_id), n.parent = e, e.children.push(n);
|
|
37
|
+
}
|
|
38
|
+
function B(e) {
|
|
39
|
+
let t = e.parent;
|
|
40
|
+
if (!t) return;
|
|
41
|
+
let n = t.children.indexOf(e);
|
|
42
|
+
n !== -1 && t.children.splice(n, 1), e.parent = null;
|
|
43
|
+
}
|
|
44
|
+
function V(e) {
|
|
45
|
+
e.parent && _(e.parent.__node_id, e.__node_id), B(e);
|
|
46
|
+
}
|
|
47
|
+
function H(e, t, n) {
|
|
48
|
+
if (n === e && e.parent === t) return;
|
|
49
|
+
V(e);
|
|
50
|
+
let r = n ? t.children.indexOf(n) : -1;
|
|
51
|
+
m(t.__node_id, e.__node_id, n && r !== -1 ? n.__node_id : null), r === -1 ? t.children.push(e) : t.children.splice(r, 0, e), e.parent = t;
|
|
52
|
+
}
|
|
53
|
+
function U(e) {
|
|
54
|
+
B(e), E(e.__node_id), i(e);
|
|
55
|
+
}
|
|
56
|
+
function W(e) {
|
|
57
|
+
return e.parent;
|
|
58
|
+
}
|
|
59
|
+
function G(e) {
|
|
60
|
+
let t = e.parent;
|
|
61
|
+
if (!t) return null;
|
|
62
|
+
let n = t.children.indexOf(e);
|
|
63
|
+
return t.children[n + 1] ?? null;
|
|
64
|
+
}
|
|
65
|
+
//#endregion
|
|
66
|
+
//#region src/rendererCore.mts
|
|
67
|
+
var K = /* @__PURE__ */ P({
|
|
68
|
+
addEventListener: () => A,
|
|
69
|
+
appendChild: () => d,
|
|
70
|
+
blur: () => l,
|
|
71
|
+
click: () => r,
|
|
72
|
+
createCommentNode: () => L,
|
|
73
|
+
createElementNode: () => F,
|
|
74
|
+
createEventTarget: () => t,
|
|
75
|
+
createIncaElement: () => T,
|
|
76
|
+
createNode: () => C,
|
|
77
|
+
createTextNode: () => I,
|
|
78
|
+
destroyNode: () => E,
|
|
79
|
+
dispatchEvent: () => n,
|
|
80
|
+
focus: () => o,
|
|
81
|
+
focusedNode: () => p,
|
|
82
|
+
getAttribute: () => x,
|
|
83
|
+
holdNode: () => O,
|
|
84
|
+
insert: () => H,
|
|
85
|
+
insertBefore: () => m,
|
|
86
|
+
isDestroyed: () => y,
|
|
87
|
+
latestEventId: () => b,
|
|
88
|
+
layoutOf: () => h,
|
|
89
|
+
nextSibling: () => G,
|
|
90
|
+
parentNode: () => W,
|
|
91
|
+
releaseNode: () => w,
|
|
92
|
+
releaseWhenCollected: () => a,
|
|
93
|
+
remove: () => U,
|
|
94
|
+
removeAttribute: () => S,
|
|
95
|
+
removeChild: () => _,
|
|
96
|
+
removeEventListener: () => e,
|
|
97
|
+
removeStyle: () => g,
|
|
98
|
+
rootElement: () => v,
|
|
99
|
+
rootNodeId: () => u,
|
|
100
|
+
scrollIntoViewNode: () => k,
|
|
101
|
+
scrollNode: () => M,
|
|
102
|
+
scrollOf: () => f,
|
|
103
|
+
setAttribute: () => j,
|
|
104
|
+
setElementText: () => z,
|
|
105
|
+
setStyle: () => c,
|
|
106
|
+
setText: () => R,
|
|
107
|
+
window: () => D
|
|
108
|
+
});
|
|
109
|
+
//#endregion
|
|
110
|
+
export { H as a, U as c, I as i, z as l, L as n, G as o, F as r, W as s, K as t, R as u };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { IncaDocument } from './types.mts';
|
|
2
|
+
/**
|
|
3
|
+
* The event target between the elements and `window`. An event at an element
|
|
4
|
+
* passes through it, and it is the next target after the mount container.
|
|
5
|
+
*
|
|
6
|
+
* It has the listener methods `addEventListener`, `removeEventListener` and
|
|
7
|
+
* `dispatchEvent`, the event handler properties such as `onkeydown`, and
|
|
8
|
+
* `activeElement`. A `wheel` listener is passive unless its options say
|
|
9
|
+
* `passive: false`.
|
|
10
|
+
*/
|
|
11
|
+
export declare const document: IncaDocument;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IncaEventTarget } from '../types.mts';
|
|
2
2
|
import { EventHandlers } from './types.mts';
|
|
3
3
|
/** The events whose handler property every element has. */
|
|
4
|
-
export declare const HANDLER_EVENTS: readonly ["auxclick", "blur", "click", "contextmenu", "dblclick", "focus", "keydown", "keyup", "mousedown", "mouseenter", "mouseleave", "mousemove", "mouseout", "mouseover", "mouseup", "scroll", "wheel"];
|
|
4
|
+
export declare const HANDLER_EVENTS: readonly ["auxclick", "blur", "click", "contextmenu", "dblclick", "focus", "gotpointercapture", "keydown", "keyup", "lostpointercapture", "mousedown", "mouseenter", "mouseleave", "mousemove", "mouseout", "mouseover", "mouseup", "pointerdown", "pointerenter", "pointerleave", "pointermove", "pointerout", "pointerover", "pointerup", "scroll", "wheel"];
|
|
5
5
|
/**
|
|
6
6
|
* Defines the event handler properties on `handle`. A value assigned while a property holds `null`
|
|
7
7
|
* registers a bubble listener through `handle.addEventListener`, and `null` removes it.
|
|
@@ -2,18 +2,28 @@ import { NodeId, TagName } from '../types.mts';
|
|
|
2
2
|
import { IncaElement } from './types.mts';
|
|
3
3
|
/**
|
|
4
4
|
* Builds the {@link IncaElement} handle for a native node: parentless,
|
|
5
|
-
* childless, with `id`, `focus()`, `blur()`, `click()`,
|
|
6
|
-
* listener methods of an event target, `tabIndex`,
|
|
7
|
-
* event handler properties, all driven through the
|
|
5
|
+
* childless, with `id`, `focus()`, `blur()`, `click()`, the pointer capture
|
|
6
|
+
* methods, `contains()`, the listener methods of an event target, `tabIndex`,
|
|
7
|
+
* the layout members and the event handler properties, all driven through the
|
|
8
|
+
* host.
|
|
8
9
|
* @param id - the native node's id
|
|
9
10
|
* @param kind - whether the node is an element or a comment stand-in
|
|
10
11
|
* @param tag - the node's element kind, if it has one; a `button` defaults to tab index `0`
|
|
12
|
+
* @param passiveByDefault - event names whose listeners are passive unless their options say
|
|
13
|
+
* `passive: false`
|
|
11
14
|
* @returns the new handle
|
|
12
15
|
*/
|
|
13
|
-
export declare function createIncaElement(id: NodeId, kind: IncaElement["kind"], tag?: TagName): IncaElement;
|
|
16
|
+
export declare function createIncaElement(id: NodeId, kind: IncaElement["kind"], tag?: TagName, passiveByDefault?: readonly string[]): IncaElement;
|
|
14
17
|
/**
|
|
15
18
|
* Returns the element that currently has focus. A `focus()` or `blur()` call
|
|
16
19
|
* takes effect for this function at once.
|
|
17
20
|
* @returns the focused element, or `null` when no element has focus
|
|
18
21
|
*/
|
|
19
22
|
export declare function activeElement(): IncaElement | null;
|
|
23
|
+
/**
|
|
24
|
+
* Returns the handle of the host's mount container, which stands between the app's elements and
|
|
25
|
+
* `document` in an event path. A live handle is reused, so a mount and an event see one object.
|
|
26
|
+
* A `wheel` listener on it is passive unless its options say `passive: false`.
|
|
27
|
+
* @returns the mount container's handle
|
|
28
|
+
*/
|
|
29
|
+
export declare function rootElement(): IncaElement;
|
package/dist/element/types.d.mts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { IncaEvent, IncaEventTarget } from '../types.mts';
|
|
1
|
+
import { IncaEvent, IncaEventMap, IncaEventTarget } from '../types.mts';
|
|
2
2
|
import { HANDLER_EVENTS } from './eventHandlers.mts';
|
|
3
3
|
import { RectLike } from './geometry.mts';
|
|
4
4
|
import { ScrollIntoViewOptions, ScrollOptions } from './scroll.mts';
|
|
5
|
-
/** A function an event handler property holds, called with
|
|
6
|
-
export type EventHandler = (this:
|
|
5
|
+
/** A function an event handler property holds, called with its target as `this` and the event. */
|
|
6
|
+
export type EventHandler<E = IncaEvent, T = IncaElement> = (this: T, event: E) => unknown;
|
|
7
7
|
/**
|
|
8
8
|
* The event handler properties, such as `onclick`, of the events the host dispatches, `focusin` and
|
|
9
9
|
* `focusout` excepted.
|
|
10
10
|
*/
|
|
11
|
-
export type EventHandlers = {
|
|
12
|
-
[K in (typeof HANDLER_EVENTS)[number] as `on${K}`]: EventHandler | object | null;
|
|
11
|
+
export type EventHandlers<T = IncaElement> = {
|
|
12
|
+
[K in (typeof HANDLER_EVENTS)[number] as `on${K}`]: EventHandler<IncaEventMap[K], T> | object | null;
|
|
13
13
|
};
|
|
14
14
|
/**
|
|
15
15
|
* A container node: either a real element or the hidden stand-in that
|
|
@@ -53,6 +53,23 @@ export interface IncaElement extends IncaEventTarget, EventHandlers {
|
|
|
53
53
|
* removed, the call does nothing.
|
|
54
54
|
*/
|
|
55
55
|
click(): void;
|
|
56
|
+
/**
|
|
57
|
+
* Captures the mouse pointer for this node while a button is held. Only `pointerId` 1 exists.
|
|
58
|
+
* @throws DOMException named `NotFoundError` for another `pointerId`
|
|
59
|
+
* @throws DOMException named `InvalidStateError` when the node is outside the mounted tree,
|
|
60
|
+
* also after it is removed
|
|
61
|
+
*/
|
|
62
|
+
setPointerCapture(pointerId: number): void;
|
|
63
|
+
/**
|
|
64
|
+
* Releases the capture this node requested. Does nothing when the node holds none.
|
|
65
|
+
* @throws DOMException named `NotFoundError` for a `pointerId` other than 1
|
|
66
|
+
*/
|
|
67
|
+
releasePointerCapture(pointerId: number): void;
|
|
68
|
+
/**
|
|
69
|
+
* Whether this node requested the capture and has not released it. `false` after the node is
|
|
70
|
+
* removed.
|
|
71
|
+
*/
|
|
72
|
+
hasPointerCapture(pointerId: number): boolean;
|
|
56
73
|
/**
|
|
57
74
|
* Whether `other` is this node or one of its descendants in the tree as
|
|
58
75
|
* rendered. `null` and `undefined` give `false`, and any other value that is
|
package/dist/eventTarget.d.mts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EventTargetId } from './native.mts';
|
|
2
|
+
import { IncaEventTarget } from './types.mts';
|
|
2
3
|
/**
|
|
3
|
-
* Builds the listener methods of an event target
|
|
4
|
-
* @param
|
|
4
|
+
* Builds the listener methods of an event target: a node, document or window.
|
|
5
|
+
* @param target - the target id, or a function that resolves it each time a method runs
|
|
5
6
|
* @param passiveByDefault - event names whose listeners are passive unless
|
|
6
7
|
* their options say `passive: false`
|
|
7
8
|
* @returns the target's `addEventListener`, `removeEventListener` and
|
|
8
9
|
* `dispatchEvent`
|
|
9
10
|
*/
|
|
10
|
-
export declare function createEventTarget(
|
|
11
|
+
export declare function createEventTarget(target: EventTargetId | (() => EventTargetId), passiveByDefault?: readonly string[]): IncaEventTarget;
|