incajs 0.0.16 → 0.0.17
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 +2 -1
- package/dist/callbacks.d.mts +0 -12
- package/dist/chunks/handle-SWQTonXe.js +180 -0
- package/dist/chunks/hooks-BgB7lzTv.js +201 -0
- package/dist/chunks/rendererCore-BWT8KFVJ.js +110 -0
- package/dist/element/geometry.d.mts +3 -7
- package/dist/element/handle.d.mts +5 -5
- package/dist/element/lifecycle.d.mts +16 -1
- package/dist/element/scroll.d.mts +1 -3
- package/dist/element/shadowTree.d.mts +10 -17
- package/dist/element/types.d.mts +16 -15
- package/dist/events.d.mts +3 -2
- package/dist/index.js +3 -6
- package/dist/native.d.mts +4 -0
- package/dist/rendererCore.d.mts +8 -6
- package/dist/rendererCore.js +4 -1
- package/dist/targets.d.mts +1 -0
- package/dist/tree.d.mts +22 -8
- package/dist/types.d.mts +15 -11
- package/dist/vue/createApp.d.mts +8 -9
- package/dist/vue/nodeOps.d.mts +11 -2
- package/dist/vue/patchProp.d.mts +1 -2
- package/dist/vue.js +75 -111
- package/dist/window.d.mts +7 -5
- package/package.json +6 -2
- package/dist/chunks/handle-B1h0qxex.js +0 -193
- package/dist/chunks/rendererCore-U_s1R1v7.js +0 -171
package/README.md
CHANGED
|
@@ -12,7 +12,8 @@ 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` event target and
|
|
15
|
+
- The root `incajs` export is the `window` event target, `activeElement` and
|
|
16
|
+
the public types.
|
|
16
17
|
- `incajs/vue` is a custom renderer mapping Vue 3's `createRenderer`
|
|
17
18
|
lifecycle onto the native host bridge. `createIncaApp(rootComponent,
|
|
18
19
|
rootProps?)` creates a Vue app whose root mounts against the host's
|
package/dist/callbacks.d.mts
CHANGED
|
@@ -20,13 +20,6 @@ export declare function callbackIdFor(group: string, listener: EventListenerOrOb
|
|
|
20
20
|
* @param callbackId - the id to drop
|
|
21
21
|
*/
|
|
22
22
|
export declare function releaseCallback(callbackId: CallbackId): void;
|
|
23
|
-
/**
|
|
24
|
-
* Drops the JS half of every registration in `callbackIds`. The native half
|
|
25
|
-
* is already gone by the time this runs: `destroyNode` takes both.
|
|
26
|
-
* @param callbackIds - ids the host reported as released
|
|
27
|
-
* @internal
|
|
28
|
-
*/
|
|
29
|
-
export declare function releaseCallbacks(callbackIds: readonly CallbackId[]): void;
|
|
30
23
|
/**
|
|
31
24
|
* The capture flag is part of the identity: the same node, event and function
|
|
32
25
|
* can listen in both phases side by side.
|
|
@@ -36,8 +29,3 @@ export declare function releaseCallbacks(callbackIds: readonly CallbackId[]): vo
|
|
|
36
29
|
* @returns the node, event and capture flag as one string
|
|
37
30
|
*/
|
|
38
31
|
export declare const groupOf: (nodeId: NodeId, event: string, capture: boolean | undefined) => string;
|
|
39
|
-
/**
|
|
40
|
-
* @returns how many `(nodeId, event, capture)` groups hold a registration
|
|
41
|
-
* @internal
|
|
42
|
-
*/
|
|
43
|
-
export declare function registeredGroupCount(): number;
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { A as e, C as t, M as n, O as r, P as i, S as a, T as o, _ as s, a as c, b as l, g as u, h as d, k as f, l as p, o as m, v as h } from "./hooks-BgB7lzTv.js";
|
|
2
|
+
//#region src/element/geometry.mts
|
|
3
|
+
function g(e) {
|
|
4
|
+
return f(e) ? null : p(e.__node_id);
|
|
5
|
+
}
|
|
6
|
+
function _(e) {
|
|
7
|
+
let t = e.parent;
|
|
8
|
+
return !g(e) || !t || !g(t) ? null : t;
|
|
9
|
+
}
|
|
10
|
+
function v(e) {
|
|
11
|
+
let t = g(e);
|
|
12
|
+
if (!t) return {
|
|
13
|
+
left: 0,
|
|
14
|
+
top: 0
|
|
15
|
+
};
|
|
16
|
+
let n = _(e), r = n ? g(n) : null;
|
|
17
|
+
return {
|
|
18
|
+
left: Math.round(t[0] - (r ? r[0] + r[4] : 0) + t[5]) || 0,
|
|
19
|
+
top: Math.round(t[1] - (r ? r[1] + r[4] : 0) + t[6]) || 0
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function y(e) {
|
|
23
|
+
let [t, n, r, i] = e ?? [
|
|
24
|
+
0,
|
|
25
|
+
0,
|
|
26
|
+
0,
|
|
27
|
+
0,
|
|
28
|
+
0
|
|
29
|
+
], a = {
|
|
30
|
+
x: t,
|
|
31
|
+
y: n,
|
|
32
|
+
width: r,
|
|
33
|
+
height: i,
|
|
34
|
+
top: n,
|
|
35
|
+
left: t,
|
|
36
|
+
right: t + r,
|
|
37
|
+
bottom: n + i
|
|
38
|
+
};
|
|
39
|
+
return {
|
|
40
|
+
...a,
|
|
41
|
+
toJSON: () => ({ ...a })
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function b(e, t) {
|
|
45
|
+
let n = t === "button" ? 0 : -1;
|
|
46
|
+
if (typeof e != "string" && typeof e != "number") return n;
|
|
47
|
+
let r = /^[\t\n\f\r ]*([+-]?\d+)/.exec(String(e));
|
|
48
|
+
if (!r) return n;
|
|
49
|
+
let i = Number(r[1]) || 0;
|
|
50
|
+
return i >= -2147483648 && i <= 2147483647 ? i : n;
|
|
51
|
+
}
|
|
52
|
+
//#endregion
|
|
53
|
+
//#region src/element/scroll.mts
|
|
54
|
+
function x(e, t, n) {
|
|
55
|
+
if (f(e)) return;
|
|
56
|
+
let [r, i] = t, [a, o] = typeof r == "object" ? [r?.left, r?.top] : [r, i], [c, l] = n ? s(e.__node_id) ?? [0, 0] : [0, 0], d = (e, t) => {
|
|
57
|
+
if (e === void 0) return null;
|
|
58
|
+
let r = Number(e);
|
|
59
|
+
return (n ? t : 0) + (Number.isFinite(r) ? r : 0);
|
|
60
|
+
};
|
|
61
|
+
u(e.__node_id, d(a, c), d(o, l));
|
|
62
|
+
}
|
|
63
|
+
function S(e) {
|
|
64
|
+
let t = [
|
|
65
|
+
"start",
|
|
66
|
+
"center",
|
|
67
|
+
"end",
|
|
68
|
+
"nearest"
|
|
69
|
+
];
|
|
70
|
+
return typeof e == "object" && e ? {
|
|
71
|
+
block: t.includes(e.block ?? "") ? e.block : "start",
|
|
72
|
+
inline: t.includes(e.inline ?? "") ? e.inline : "nearest"
|
|
73
|
+
} : {
|
|
74
|
+
block: e === !1 ? "end" : "start",
|
|
75
|
+
inline: "nearest"
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
//#endregion
|
|
79
|
+
//#region src/element/handle.mts
|
|
80
|
+
function C(r, c, u) {
|
|
81
|
+
let p = l(() => r), C = () => f(w) ? null : s(r), w = i({
|
|
82
|
+
get id() {
|
|
83
|
+
return f(w) ? "" : String(m(r, "id") ?? "");
|
|
84
|
+
},
|
|
85
|
+
set id(e) {
|
|
86
|
+
f(w) || h(r, "id", String(e));
|
|
87
|
+
},
|
|
88
|
+
kind: c,
|
|
89
|
+
parent: null,
|
|
90
|
+
children: [],
|
|
91
|
+
focus: (e) => {
|
|
92
|
+
if (f(w)) return;
|
|
93
|
+
let t = e?.preventScroll;
|
|
94
|
+
t === void 0 ? o(r) : o(r, !!t);
|
|
95
|
+
},
|
|
96
|
+
blur: () => a(r),
|
|
97
|
+
click: () => t(r),
|
|
98
|
+
contains: (t) => {
|
|
99
|
+
if (t == null) return !1;
|
|
100
|
+
if (!e(t)) throw TypeError("the value is not a node. pass an element, a text node or null");
|
|
101
|
+
for (let e = t; e !== null; e = e.parent) if (e === w) return !0;
|
|
102
|
+
return !1;
|
|
103
|
+
},
|
|
104
|
+
addEventListener: (...e) => {
|
|
105
|
+
f(w) || p.addEventListener(...e);
|
|
106
|
+
},
|
|
107
|
+
removeEventListener: (...e) => {
|
|
108
|
+
f(w) || p.removeEventListener(...e);
|
|
109
|
+
},
|
|
110
|
+
dispatchEvent: (e) => f(w) || p.dispatchEvent(e),
|
|
111
|
+
get tabIndex() {
|
|
112
|
+
return b(f(w) ? null : m(r, "tabindex"), u ?? "");
|
|
113
|
+
},
|
|
114
|
+
set tabIndex(e) {
|
|
115
|
+
f(w) || h(r, "tabindex", e | 0);
|
|
116
|
+
},
|
|
117
|
+
getBoundingClientRect: () => y(g(w)),
|
|
118
|
+
get offsetWidth() {
|
|
119
|
+
return Math.round(g(w)?.[2] ?? 0);
|
|
120
|
+
},
|
|
121
|
+
get offsetHeight() {
|
|
122
|
+
return Math.round(g(w)?.[3] ?? 0);
|
|
123
|
+
},
|
|
124
|
+
get offsetLeft() {
|
|
125
|
+
return v(w).left;
|
|
126
|
+
},
|
|
127
|
+
get offsetTop() {
|
|
128
|
+
return v(w).top;
|
|
129
|
+
},
|
|
130
|
+
get offsetParent() {
|
|
131
|
+
return _(w);
|
|
132
|
+
},
|
|
133
|
+
get clientWidth() {
|
|
134
|
+
let e = g(w);
|
|
135
|
+
return e ? Math.max(0, Math.round(e[2] - 2 * e[4])) : 0;
|
|
136
|
+
},
|
|
137
|
+
get clientHeight() {
|
|
138
|
+
let e = g(w);
|
|
139
|
+
return e ? Math.max(0, Math.round(e[3] - 2 * e[4])) : 0;
|
|
140
|
+
},
|
|
141
|
+
get clientLeft() {
|
|
142
|
+
return Math.round(g(w)?.[4] ?? 0);
|
|
143
|
+
},
|
|
144
|
+
get clientTop() {
|
|
145
|
+
return Math.round(g(w)?.[4] ?? 0);
|
|
146
|
+
},
|
|
147
|
+
get scrollLeft() {
|
|
148
|
+
return C()?.[0] ?? 0;
|
|
149
|
+
},
|
|
150
|
+
set scrollLeft(e) {
|
|
151
|
+
x(w, [e], !1);
|
|
152
|
+
},
|
|
153
|
+
get scrollTop() {
|
|
154
|
+
return C()?.[1] ?? 0;
|
|
155
|
+
},
|
|
156
|
+
set scrollTop(e) {
|
|
157
|
+
x(w, [void 0, e], !1);
|
|
158
|
+
},
|
|
159
|
+
get scrollWidth() {
|
|
160
|
+
return w.clientWidth + Math.round(C()?.[2] ?? 0);
|
|
161
|
+
},
|
|
162
|
+
get scrollHeight() {
|
|
163
|
+
return w.clientHeight + Math.round(C()?.[3] ?? 0);
|
|
164
|
+
},
|
|
165
|
+
scrollTo: (...e) => x(w, e, !1),
|
|
166
|
+
scrollBy: (...e) => x(w, e, !0),
|
|
167
|
+
scrollIntoView: (e) => {
|
|
168
|
+
if (f(w)) return;
|
|
169
|
+
let { block: t, inline: n } = S(e);
|
|
170
|
+
d(r, t, n);
|
|
171
|
+
}
|
|
172
|
+
}, r);
|
|
173
|
+
return c === "element" && n(w), w;
|
|
174
|
+
}
|
|
175
|
+
function w() {
|
|
176
|
+
let e = c();
|
|
177
|
+
return e === null ? null : r(e) ?? null;
|
|
178
|
+
}
|
|
179
|
+
//#endregion
|
|
180
|
+
export { C as n, w as t };
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
//#region src/native.mts
|
|
2
|
+
function e() {
|
|
3
|
+
return globalThis.__inca_native__;
|
|
4
|
+
}
|
|
5
|
+
//#endregion
|
|
6
|
+
//#region src/element/lifecycle.mts
|
|
7
|
+
var t = /* @__PURE__ */ new WeakSet();
|
|
8
|
+
function n(e, n) {
|
|
9
|
+
return t.add(e), Object.defineProperty(e, "__node_id", { value: n });
|
|
10
|
+
}
|
|
11
|
+
function r(e) {
|
|
12
|
+
return typeof e == "object" && !!e && t.has(e);
|
|
13
|
+
}
|
|
14
|
+
var i = /* @__PURE__ */ new Map(), a = new FinalizationRegistry((e) => {
|
|
15
|
+
i.get(e)?.deref() || i.delete(e);
|
|
16
|
+
});
|
|
17
|
+
function o(e) {
|
|
18
|
+
i.set(e.__node_id, new WeakRef(e)), a.register(e, e.__node_id);
|
|
19
|
+
}
|
|
20
|
+
function s(e) {
|
|
21
|
+
i.delete(e);
|
|
22
|
+
}
|
|
23
|
+
function c(e) {
|
|
24
|
+
return i.get(e)?.deref();
|
|
25
|
+
}
|
|
26
|
+
var l = /* @__PURE__ */ new WeakSet();
|
|
27
|
+
function u(e) {
|
|
28
|
+
return l.has(e);
|
|
29
|
+
}
|
|
30
|
+
function d(e) {
|
|
31
|
+
if (l.add(e), e.kind !== "text") {
|
|
32
|
+
s(e.__node_id);
|
|
33
|
+
for (let t of e.children) d(t);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function f(e) {
|
|
37
|
+
for (let t of e) {
|
|
38
|
+
let e = c(t);
|
|
39
|
+
e && d(e);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
var p = new FinalizationRegistry((t) => e().releaseNode(t));
|
|
43
|
+
function m(e) {
|
|
44
|
+
p.register(e, e.__node_id);
|
|
45
|
+
}
|
|
46
|
+
//#endregion
|
|
47
|
+
//#region src/callbacks.mts
|
|
48
|
+
var h = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Map(), _ = () => globalThis.__inca_callbacks__ ??= {};
|
|
49
|
+
function v(e, t, n, r) {
|
|
50
|
+
_()[n] = r;
|
|
51
|
+
let i = h.get(e);
|
|
52
|
+
i || h.set(e, i = /* @__PURE__ */ new Map()), i.set(t, n), g.set(n, {
|
|
53
|
+
group: e,
|
|
54
|
+
listener: t
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
function y(e, t) {
|
|
58
|
+
return h.get(e)?.get(t);
|
|
59
|
+
}
|
|
60
|
+
function b(e) {
|
|
61
|
+
delete _()[e];
|
|
62
|
+
let t = g.get(e);
|
|
63
|
+
if (t === void 0) return;
|
|
64
|
+
g.delete(e);
|
|
65
|
+
let n = h.get(t.group);
|
|
66
|
+
n?.delete(t.listener), n?.size === 0 && h.delete(t.group);
|
|
67
|
+
}
|
|
68
|
+
function x(e) {
|
|
69
|
+
for (let t of e) b(t);
|
|
70
|
+
}
|
|
71
|
+
var S = (e, t, n) => `${e}:${t}:${n === !0}`;
|
|
72
|
+
globalThis.__inca_released__ ??= (e, t) => {
|
|
73
|
+
let n, r = !1;
|
|
74
|
+
for (let e of t) try {
|
|
75
|
+
x([e]);
|
|
76
|
+
} catch (e) {
|
|
77
|
+
r || (n = e), r = !0;
|
|
78
|
+
}
|
|
79
|
+
if (f(e), r) throw n;
|
|
80
|
+
};
|
|
81
|
+
//#endregion
|
|
82
|
+
//#region src/events.mts
|
|
83
|
+
var C = 0;
|
|
84
|
+
function w() {
|
|
85
|
+
return C;
|
|
86
|
+
}
|
|
87
|
+
function T(e) {
|
|
88
|
+
return (...t) => {
|
|
89
|
+
let n = t[0]?.eventId;
|
|
90
|
+
return typeof n == "number" && n > C && (C = n), e(...t);
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
function E(t, n, r, i = {}) {
|
|
94
|
+
if (r == null) return;
|
|
95
|
+
let a = S(t, n, i.capture);
|
|
96
|
+
if (y(a, r) !== void 0) return;
|
|
97
|
+
let o = (...e) => typeof r == "function" ? r.apply(e[0]?.currentTarget, e) : r.handleEvent.apply(r, e), s = i.once ? (...e) => (D(t, n, r, i), o(...e)) : o;
|
|
98
|
+
v(a, r, e().addEventListener(t, n, i.capture === !0, i.passive === !0), T(s));
|
|
99
|
+
}
|
|
100
|
+
function D(t, n, r, i = {}) {
|
|
101
|
+
if (r == null) return;
|
|
102
|
+
let a = y(S(t, n, i.capture), r);
|
|
103
|
+
a !== void 0 && (e().removeEventListener(t, n, a), b(a));
|
|
104
|
+
}
|
|
105
|
+
function O(t, n) {
|
|
106
|
+
return e().dispatchEvent(t, n);
|
|
107
|
+
}
|
|
108
|
+
function k(t) {
|
|
109
|
+
e().click(t);
|
|
110
|
+
}
|
|
111
|
+
function A(t, n) {
|
|
112
|
+
n === void 0 ? e().focusNode(t) : e().focusNode(t, n);
|
|
113
|
+
}
|
|
114
|
+
function j(t) {
|
|
115
|
+
e().blurNode(t);
|
|
116
|
+
}
|
|
117
|
+
//#endregion
|
|
118
|
+
//#region src/eventTarget.mts
|
|
119
|
+
function M(e, t = []) {
|
|
120
|
+
return {
|
|
121
|
+
addEventListener(n, r, i) {
|
|
122
|
+
let a = typeof i == "boolean" ? { capture: i } : i ?? {};
|
|
123
|
+
E(e(), n, r, {
|
|
124
|
+
...a,
|
|
125
|
+
passive: a.passive ?? t.includes(n)
|
|
126
|
+
});
|
|
127
|
+
},
|
|
128
|
+
removeEventListener(t, n, r) {
|
|
129
|
+
let i = typeof r == "boolean" ? r : r?.capture;
|
|
130
|
+
D(e(), t, n, { capture: i });
|
|
131
|
+
},
|
|
132
|
+
dispatchEvent: (t) => O(e(), t)
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
//#endregion
|
|
136
|
+
//#region src/tree.mts
|
|
137
|
+
function N() {
|
|
138
|
+
return e().rootNodeId();
|
|
139
|
+
}
|
|
140
|
+
function P(t) {
|
|
141
|
+
return e().createNode(t);
|
|
142
|
+
}
|
|
143
|
+
function F(t, n) {
|
|
144
|
+
e().appendChild(t, n);
|
|
145
|
+
}
|
|
146
|
+
function I(t, n, r) {
|
|
147
|
+
e().insertBefore(t, n, r);
|
|
148
|
+
}
|
|
149
|
+
function L(t, n) {
|
|
150
|
+
e().removeChild(t, n);
|
|
151
|
+
}
|
|
152
|
+
function R(t) {
|
|
153
|
+
x(e().destroyNode(t));
|
|
154
|
+
}
|
|
155
|
+
function z(t) {
|
|
156
|
+
e().holdNode(t);
|
|
157
|
+
}
|
|
158
|
+
function B(t) {
|
|
159
|
+
e().releaseNode(t);
|
|
160
|
+
}
|
|
161
|
+
function V(t, n, r) {
|
|
162
|
+
e().setAttribute(t, n, r);
|
|
163
|
+
}
|
|
164
|
+
function H(t, n) {
|
|
165
|
+
return e().getAttribute(t, n);
|
|
166
|
+
}
|
|
167
|
+
function U(t) {
|
|
168
|
+
return e().layoutOf(t);
|
|
169
|
+
}
|
|
170
|
+
function W(t) {
|
|
171
|
+
return e().scrollOf(t);
|
|
172
|
+
}
|
|
173
|
+
function G(t, n, r) {
|
|
174
|
+
e().scrollNode(t, n, r);
|
|
175
|
+
}
|
|
176
|
+
function K(t, n, r) {
|
|
177
|
+
e().scrollIntoViewNode(t, n, r);
|
|
178
|
+
}
|
|
179
|
+
function q(t, n) {
|
|
180
|
+
e().removeAttribute(t, n);
|
|
181
|
+
}
|
|
182
|
+
function J(t, n, r) {
|
|
183
|
+
e().setStyle(t, n, r);
|
|
184
|
+
}
|
|
185
|
+
function Y(t, n) {
|
|
186
|
+
e().removeStyle(t, n);
|
|
187
|
+
}
|
|
188
|
+
function X() {
|
|
189
|
+
return e().focusedNode();
|
|
190
|
+
}
|
|
191
|
+
//#endregion
|
|
192
|
+
//#region src/window.mts
|
|
193
|
+
var Z = /* @__PURE__ */ Object.defineProperty(M(N, ["wheel"]), Symbol.toStringTag, { value: "Window" });
|
|
194
|
+
//#endregion
|
|
195
|
+
//#region src/targets.mts
|
|
196
|
+
globalThis.__inca_targets__ ??= (e) => {
|
|
197
|
+
let t = N();
|
|
198
|
+
return e.map((e) => e === t ? Z : c(e) ?? null);
|
|
199
|
+
};
|
|
200
|
+
//#endregion
|
|
201
|
+
export { r as A, k as C, D, w as E, o as M, m as N, c as O, n as P, j as S, A as T, W as _, X as a, M as b, I as c, q as d, L as f, G as g, K as h, R as i, d as j, u as k, U as l, N as m, F as n, H as o, Y as p, P as r, z as s, Z as t, B as u, V as v, O as w, E as x, J as y };
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { C as e, D as t, E as n, N as r, P as i, S as a, T as o, _ as s, a as c, b as l, c as u, d, f, g as p, h as m, i as h, j as g, k as _, l as v, m as y, n as b, o as x, p as S, r as C, s as w, t as T, u as E, v as D, w as O, x as k, y as A } from "./hooks-BgB7lzTv.js";
|
|
2
|
+
import { n as j } from "./handle-SWQTonXe.js";
|
|
3
|
+
//#region \0rolldown/runtime.js
|
|
4
|
+
var M = Object.defineProperty, N = (e, t) => {
|
|
5
|
+
let n = {};
|
|
6
|
+
for (var r in e) M(n, r, {
|
|
7
|
+
get: e[r],
|
|
8
|
+
enumerable: !0
|
|
9
|
+
});
|
|
10
|
+
return t || M(n, Symbol.toStringTag, { value: "Module" }), n;
|
|
11
|
+
};
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region src/element/shadowTree.mts
|
|
14
|
+
function P(e) {
|
|
15
|
+
let t = C(e);
|
|
16
|
+
return j(t, "element", e);
|
|
17
|
+
}
|
|
18
|
+
function F(e) {
|
|
19
|
+
let t = C("text");
|
|
20
|
+
return D(t, "value", e), i({
|
|
21
|
+
kind: "text",
|
|
22
|
+
parent: null,
|
|
23
|
+
text: e
|
|
24
|
+
}, t);
|
|
25
|
+
}
|
|
26
|
+
function I() {
|
|
27
|
+
let e = C("div");
|
|
28
|
+
return A(e, "display", "none"), j(e, "comment");
|
|
29
|
+
}
|
|
30
|
+
function L(e, t) {
|
|
31
|
+
D(e.__node_id, "value", t), e.text = t;
|
|
32
|
+
}
|
|
33
|
+
function R(e, t) {
|
|
34
|
+
for (let t of e.children.splice(0)) h(t.__node_id), g(t), t.parent = null;
|
|
35
|
+
if (!t) return;
|
|
36
|
+
let n = F(t);
|
|
37
|
+
b(e.__node_id, n.__node_id), n.parent = e, e.children.push(n);
|
|
38
|
+
}
|
|
39
|
+
function z(e) {
|
|
40
|
+
let t = e.parent;
|
|
41
|
+
if (!t) return;
|
|
42
|
+
let n = t.children.indexOf(e);
|
|
43
|
+
n !== -1 && t.children.splice(n, 1), e.parent = null;
|
|
44
|
+
}
|
|
45
|
+
function B(e) {
|
|
46
|
+
e.parent && f(e.parent.__node_id, e.__node_id), z(e);
|
|
47
|
+
}
|
|
48
|
+
function V(e, t, n) {
|
|
49
|
+
if (n === e && e.parent === t) return;
|
|
50
|
+
B(e);
|
|
51
|
+
let r = n ? t.children.indexOf(n) : -1;
|
|
52
|
+
u(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;
|
|
53
|
+
}
|
|
54
|
+
function H(e) {
|
|
55
|
+
z(e), h(e.__node_id), g(e);
|
|
56
|
+
}
|
|
57
|
+
function U(e) {
|
|
58
|
+
return e.parent;
|
|
59
|
+
}
|
|
60
|
+
function W(e) {
|
|
61
|
+
let t = e.parent;
|
|
62
|
+
if (!t) return null;
|
|
63
|
+
let n = t.children.indexOf(e);
|
|
64
|
+
return t.children[n + 1] ?? null;
|
|
65
|
+
}
|
|
66
|
+
//#endregion
|
|
67
|
+
//#region src/rendererCore.mts
|
|
68
|
+
var G = /* @__PURE__ */ N({
|
|
69
|
+
addEventListener: () => k,
|
|
70
|
+
appendChild: () => b,
|
|
71
|
+
blur: () => a,
|
|
72
|
+
click: () => e,
|
|
73
|
+
createCommentNode: () => I,
|
|
74
|
+
createElementNode: () => P,
|
|
75
|
+
createEventTarget: () => l,
|
|
76
|
+
createIncaElement: () => j,
|
|
77
|
+
createNode: () => C,
|
|
78
|
+
createTextNode: () => F,
|
|
79
|
+
destroyNode: () => h,
|
|
80
|
+
dispatchEvent: () => O,
|
|
81
|
+
focus: () => o,
|
|
82
|
+
focusedNode: () => c,
|
|
83
|
+
getAttribute: () => x,
|
|
84
|
+
holdNode: () => w,
|
|
85
|
+
insert: () => V,
|
|
86
|
+
insertBefore: () => u,
|
|
87
|
+
isDestroyed: () => _,
|
|
88
|
+
latestEventId: () => n,
|
|
89
|
+
layoutOf: () => v,
|
|
90
|
+
nextSibling: () => W,
|
|
91
|
+
parentNode: () => U,
|
|
92
|
+
releaseNode: () => E,
|
|
93
|
+
releaseWhenCollected: () => r,
|
|
94
|
+
remove: () => H,
|
|
95
|
+
removeAttribute: () => d,
|
|
96
|
+
removeChild: () => f,
|
|
97
|
+
removeEventListener: () => t,
|
|
98
|
+
removeStyle: () => S,
|
|
99
|
+
rootNodeId: () => y,
|
|
100
|
+
scrollIntoViewNode: () => m,
|
|
101
|
+
scrollNode: () => p,
|
|
102
|
+
scrollOf: () => s,
|
|
103
|
+
setAttribute: () => D,
|
|
104
|
+
setElementText: () => R,
|
|
105
|
+
setStyle: () => A,
|
|
106
|
+
setText: () => L,
|
|
107
|
+
window: () => T
|
|
108
|
+
});
|
|
109
|
+
//#endregion
|
|
110
|
+
export { V as a, H as c, F as i, R as l, I as n, W as o, P as r, U as s, G as t, L as u };
|
|
@@ -1,32 +1,28 @@
|
|
|
1
|
-
import { IncaCore } from '../rendererCore.mts';
|
|
2
1
|
import { IncaElement } from './types.mts';
|
|
3
2
|
/** `[x, y, width, height, border, scrollX, scrollY]` of a node's last drawn frame. */
|
|
4
3
|
export type LayoutBox = readonly [number, number, number, number, number, number, number];
|
|
5
4
|
/**
|
|
6
5
|
* Reads the box a node was last drawn at. A destroyed node, or one with no
|
|
7
6
|
* recorded box, yields `null`.
|
|
8
|
-
* @param core - the incajs bindings to read through
|
|
9
7
|
* @param el - the node to read
|
|
10
8
|
* @returns the box, or `null`
|
|
11
9
|
*/
|
|
12
|
-
export declare function layoutBox(
|
|
10
|
+
export declare function layoutBox(el: IncaElement): LayoutBox | null;
|
|
13
11
|
/**
|
|
14
12
|
* The parent a node's offsets are measured from. It is the parent when both
|
|
15
13
|
* the node and the parent have a recorded box.
|
|
16
|
-
* @param core - the incajs bindings to read through
|
|
17
14
|
* @param el - the node to query
|
|
18
15
|
* @returns the parent, or `null`
|
|
19
16
|
*/
|
|
20
|
-
export declare function offsetParentOf(
|
|
17
|
+
export declare function offsetParentOf(el: IncaElement): IncaElement | null;
|
|
21
18
|
/**
|
|
22
19
|
* Where a node sits inside the padding edge of its offset parent, rounded to
|
|
23
20
|
* whole pixels. A node with no offset parent is measured from the window
|
|
24
21
|
* origin.
|
|
25
|
-
* @param core - the incajs bindings to read through
|
|
26
22
|
* @param el - the node to measure
|
|
27
23
|
* @returns `left` and `top`; both `0` when the node has no recorded box
|
|
28
24
|
*/
|
|
29
|
-
export declare function offsetOf(
|
|
25
|
+
export declare function offsetOf(el: IncaElement): {
|
|
30
26
|
left: number;
|
|
31
27
|
top: number;
|
|
32
28
|
};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
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 `focus()`, `blur()`, `click()`, the
|
|
6
|
-
* event target, `tabIndex` and the layout members, all
|
|
7
|
-
*
|
|
5
|
+
* childless, with `id`, `focus()`, `blur()`, `click()`, `contains()`, the
|
|
6
|
+
* listener methods of an event target, `tabIndex` and the layout members, all
|
|
7
|
+
* driven through the host.
|
|
8
8
|
* @param id - the native node's id
|
|
9
9
|
* @param kind - whether the node is an element or a comment stand-in
|
|
10
10
|
* @param tag - the node's element kind, if it has one; a `button` defaults to tab index `0`
|
|
11
11
|
* @returns the new handle
|
|
12
12
|
*/
|
|
13
|
-
export declare function createIncaElement(
|
|
13
|
+
export declare function createIncaElement(id: NodeId, kind: IncaElement["kind"], tag?: TagName): IncaElement;
|
|
14
14
|
/**
|
|
15
15
|
* Returns the element that currently has focus. A `focus()` or `blur()` call
|
|
16
16
|
* takes effect for this function at once.
|
|
@@ -1,5 +1,20 @@
|
|
|
1
|
-
import { NodeId } from '../
|
|
1
|
+
import { NodeId } from '../types.mts';
|
|
2
2
|
import { IncaElement, IncaNode } from './types.mts';
|
|
3
|
+
/**
|
|
4
|
+
* Gives `handle` a read-only, non-enumerable `__node_id`.
|
|
5
|
+
* @param handle - the new handle
|
|
6
|
+
* @param id - the native node's id
|
|
7
|
+
* @returns `handle`
|
|
8
|
+
*/
|
|
9
|
+
export declare function withNodeId<T extends object>(handle: T, id: NodeId): T & {
|
|
10
|
+
readonly __node_id: NodeId;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Whether `value` is a node handle.
|
|
14
|
+
* @param value - the value to check
|
|
15
|
+
* @returns `true` for an element, a comment stand-in or a text handle
|
|
16
|
+
*/
|
|
17
|
+
export declare function isNode(value: unknown): value is IncaNode;
|
|
3
18
|
/**
|
|
4
19
|
* Records `element` under its id.
|
|
5
20
|
* @param element - the handle to record
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { IncaCore } from '../rendererCore.mts';
|
|
2
1
|
import { ScrollAlignment } from '../types.mts';
|
|
3
2
|
import { IncaElement } from './types.mts';
|
|
4
3
|
/** The options form of `scrollTo()` and `scrollBy()`. `behavior` is accepted and ignored. */
|
|
@@ -15,12 +14,11 @@ export type ScrollArgs = [left?: number, top?: number] | [options?: ScrollOption
|
|
|
15
14
|
/**
|
|
16
15
|
* Moves a node's scroll offset. An omitted axis keeps its offset, and a
|
|
17
16
|
* non-finite value counts as `0`. A destroyed node ignores the call.
|
|
18
|
-
* @param core - the incajs bindings to write through
|
|
19
17
|
* @param el - the node to scroll
|
|
20
18
|
* @param args - `(left, top)` or `{ left, top }`
|
|
21
19
|
* @param relative - `true` adds the values to the current offset
|
|
22
20
|
*/
|
|
23
|
-
export declare function scrollPosition(
|
|
21
|
+
export declare function scrollPosition(el: IncaElement, args: ScrollArgs, relative: boolean): void;
|
|
24
22
|
/** The options form of `scrollIntoView()`. `behavior` is accepted and ignored. */
|
|
25
23
|
export interface ScrollIntoViewOptions {
|
|
26
24
|
/** The vertical alignment. Defaults to `"start"`. */
|
|
@@ -1,62 +1,55 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TagName } from '../types.mts';
|
|
2
2
|
import { IncaElement, IncaNode, IncaText } from './types.mts';
|
|
3
3
|
/**
|
|
4
4
|
* Allocates a new element node for `tag`.
|
|
5
|
-
* @param core - the incajs bindings to drive the native tree through
|
|
6
5
|
* @param tag - the node's element kind
|
|
7
6
|
* @returns the new, parentless, childless element
|
|
8
7
|
*/
|
|
9
|
-
export declare function createElementNode(
|
|
8
|
+
export declare function createElementNode(tag: TagName): IncaElement;
|
|
10
9
|
/**
|
|
11
10
|
* Creates a text leaf.
|
|
12
|
-
* @param core - the incajs bindings to drive the native tree through
|
|
13
11
|
* @param text - the initial text content
|
|
14
12
|
* @returns the new text leaf
|
|
15
13
|
*/
|
|
16
|
-
export declare function createTextNode(
|
|
14
|
+
export declare function createTextNode(text: string): IncaText;
|
|
17
15
|
/**
|
|
18
16
|
* Creates the hidden container that stands in for a comment node, such as a
|
|
19
17
|
* placeholder for conditional content.
|
|
20
|
-
* @param core - the incajs bindings to drive the native tree through
|
|
21
18
|
* @returns the new hidden element
|
|
22
19
|
*/
|
|
23
|
-
export declare function createCommentNode(
|
|
20
|
+
export declare function createCommentNode(): IncaElement;
|
|
24
21
|
/**
|
|
25
22
|
* Updates a text leaf's content in place.
|
|
26
|
-
* @param core - the incajs bindings to drive the native tree through
|
|
27
23
|
* @param node - the text leaf to update
|
|
28
24
|
* @param text - the new text content
|
|
29
25
|
*/
|
|
30
|
-
export declare function setText(
|
|
26
|
+
export declare function setText(node: IncaText, text: string): void;
|
|
31
27
|
/**
|
|
32
28
|
* Replaces all of `el`'s children with at most a single text child holding
|
|
33
29
|
* `text`. An empty string leaves `el` childless.
|
|
34
|
-
* @param core - the incajs bindings to drive the native tree through
|
|
35
30
|
* @param el - the container whose children are replaced
|
|
36
31
|
* @param text - the new text content
|
|
37
32
|
*/
|
|
38
|
-
export declare function setElementText(
|
|
33
|
+
export declare function setElementText(el: IncaElement, text: string): void;
|
|
39
34
|
/**
|
|
40
35
|
* Attaches `child` to `parent`, before `anchor` or at the end when `anchor` is
|
|
41
36
|
* omitted or `null`. If `anchor` is `child` itself and `child` is already in
|
|
42
37
|
* `parent`, nothing changes. A `child` attached elsewhere is detached first,
|
|
43
38
|
* so a move keeps the node alive.
|
|
44
|
-
* @param core - the incajs bindings to drive the native tree through
|
|
45
39
|
* @param child - the node being attached
|
|
46
40
|
* @param parent - the new container
|
|
47
41
|
* @param anchor - the sibling to insert before, or omitted/`null` to append at the end
|
|
48
42
|
*/
|
|
49
|
-
export declare function insert(
|
|
43
|
+
export declare function insert(child: IncaNode, parent: IncaElement, anchor?: IncaNode | null): void;
|
|
50
44
|
/**
|
|
51
45
|
* Removes `child` for good: the native node, its whole subtree, and every
|
|
52
46
|
* event listener registered in it.
|
|
53
47
|
*
|
|
54
|
-
* A caller that removes a subtree calls this on its root alone,
|
|
55
|
-
*
|
|
56
|
-
* @param core - the incajs bindings to drive the native tree through
|
|
48
|
+
* A caller that removes a subtree calls this on its root alone, and the host
|
|
49
|
+
* frees the descendants with it.
|
|
57
50
|
* @param child - the node being removed
|
|
58
51
|
*/
|
|
59
|
-
export declare function remove(
|
|
52
|
+
export declare function remove(child: IncaNode): void;
|
|
60
53
|
/**
|
|
61
54
|
* Looks up the current parent.
|
|
62
55
|
* @param node - the node to query
|