incajs 0.0.15 → 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.
Files changed (40) hide show
  1. package/README.md +3 -2
  2. package/dist/callbacks.d.mts +31 -0
  3. package/dist/chunks/handle-SWQTonXe.js +180 -0
  4. package/dist/chunks/hooks-BgB7lzTv.js +201 -0
  5. package/dist/chunks/rendererCore-BWT8KFVJ.js +110 -0
  6. package/dist/element/geometry.d.mts +61 -0
  7. package/dist/element/handle.d.mts +19 -0
  8. package/dist/element/lifecycle.d.mts +51 -0
  9. package/dist/{vue/scrollIntoViewArgs.d.mts → element/scroll.d.mts} +20 -0
  10. package/dist/element/shadowTree.d.mts +64 -0
  11. package/dist/element/types.d.mts +120 -0
  12. package/dist/events.d.mts +5 -20
  13. package/dist/index.d.mts +4 -0
  14. package/dist/index.js +3 -5
  15. package/dist/native.d.mts +9 -2
  16. package/dist/rendererCore.d.mts +10 -8
  17. package/dist/rendererCore.js +4 -37
  18. package/dist/targets.d.mts +1 -0
  19. package/dist/tree.d.mts +28 -9
  20. package/dist/types.d.mts +18 -15
  21. package/dist/vue/createApp.d.mts +8 -9
  22. package/dist/vue/index.d.mts +0 -6
  23. package/dist/vue/nodeOps.d.mts +19 -122
  24. package/dist/vue/patchProp.d.mts +2 -3
  25. package/dist/vue.js +69 -301
  26. package/dist/window.d.mts +7 -5
  27. package/package.json +6 -2
  28. package/dist/chunks/tree-Ds0zSuJO.js +0 -143
  29. package/dist/vue/activeElement.d.mts +0 -7
  30. package/dist/vue/createElement.d.mts +0 -13
  31. package/dist/vue/destroyedNodes.d.mts +0 -13
  32. package/dist/vue/elements.d.mts +0 -24
  33. package/dist/vue/layoutBox.d.mts +0 -12
  34. package/dist/vue/offsetOf.d.mts +0 -14
  35. package/dist/vue/offsetParent.d.mts +0 -10
  36. package/dist/vue/rectOf.d.mts +0 -25
  37. package/dist/vue/scrollPosition.d.mts +0 -22
  38. package/dist/vue/skipReactive.d.mts +0 -8
  39. package/dist/vue/tabIndexOf.d.mts +0 -9
  40. /package/dist/{createEventTarget.d.mts → eventTarget.d.mts} +0 -0
package/README.md CHANGED
@@ -5,14 +5,15 @@ SPDX-License-Identifier: MIT OR Apache-2.0
5
5
 
6
6
  # incajs
7
7
 
8
- **Incarnative.js** — a GPU-native, Webview-free desktop application
8
+ **Incarnative.js** is a GPU-native, Webview-free desktop application
9
9
  framework. No Chromium, no DOM: UI renders directly on the GPU via
10
10
  [GPUI](https://www.gpui.rs/), driven by an embedded QuickJS runtime
11
11
  ([`rquickjs`](https://github.com/DelSkayn/rquickjs)).
12
12
 
13
13
  ## How it works
14
14
 
15
- - The root `incajs` export is the `window` event target and the public types.
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
@@ -0,0 +1,31 @@
1
+ import { HostCallback } from './native.mts';
2
+ import { CallbackId, EventListenerOrObject, NodeId } from './types.mts';
3
+ /**
4
+ * Records `callable` under `callbackId` at `globalThis.__inca_callbacks__`.
5
+ * @param group - the node, event and capture flag as one string, from {@link groupOf}
6
+ * @param listener - the listener the caller registered, which identifies the registration
7
+ * @param callbackId - the id the host returned for the registration
8
+ * @param callable - the function the host runs
9
+ */
10
+ export declare function addCallback(group: string, listener: EventListenerOrObject, callbackId: CallbackId, callable: HostCallback): void;
11
+ /**
12
+ * @param group - the node, event and capture flag as one string
13
+ * @param listener - the listener the caller registered
14
+ * @returns the id registered for the pair, or `undefined`
15
+ */
16
+ export declare function callbackIdFor(group: string, listener: EventListenerOrObject): CallbackId | undefined;
17
+ /**
18
+ * Forgets `callbackId` and the listener it names. An id that was never
19
+ * registered, or was released already, changes nothing.
20
+ * @param callbackId - the id to drop
21
+ */
22
+ export declare function releaseCallback(callbackId: CallbackId): void;
23
+ /**
24
+ * The capture flag is part of the identity: the same node, event and function
25
+ * can listen in both phases side by side.
26
+ * @param nodeId - the node listened on
27
+ * @param event - the event name
28
+ * @param capture - the capture flag of the registration
29
+ * @returns the node, event and capture flag as one string
30
+ */
31
+ export declare const groupOf: (nodeId: NodeId, event: string, capture: boolean | undefined) => string;
@@ -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 };
@@ -0,0 +1,61 @@
1
+ import { IncaElement } from './types.mts';
2
+ /** `[x, y, width, height, border, scrollX, scrollY]` of a node's last drawn frame. */
3
+ export type LayoutBox = readonly [number, number, number, number, number, number, number];
4
+ /**
5
+ * Reads the box a node was last drawn at. A destroyed node, or one with no
6
+ * recorded box, yields `null`.
7
+ * @param el - the node to read
8
+ * @returns the box, or `null`
9
+ */
10
+ export declare function layoutBox(el: IncaElement): LayoutBox | null;
11
+ /**
12
+ * The parent a node's offsets are measured from. It is the parent when both
13
+ * the node and the parent have a recorded box.
14
+ * @param el - the node to query
15
+ * @returns the parent, or `null`
16
+ */
17
+ export declare function offsetParentOf(el: IncaElement): IncaElement | null;
18
+ /**
19
+ * Where a node sits inside the padding edge of its offset parent, rounded to
20
+ * whole pixels. A node with no offset parent is measured from the window
21
+ * origin.
22
+ * @param el - the node to measure
23
+ * @returns `left` and `top`; both `0` when the node has no recorded box
24
+ */
25
+ export declare function offsetOf(el: IncaElement): {
26
+ left: number;
27
+ top: number;
28
+ };
29
+ /** The plain values of a {@link RectLike}, as `toJSON` returns them. */
30
+ export interface RectValues {
31
+ readonly x: number;
32
+ readonly y: number;
33
+ readonly width: number;
34
+ readonly height: number;
35
+ readonly top: number;
36
+ readonly left: number;
37
+ readonly right: number;
38
+ readonly bottom: number;
39
+ }
40
+ /**
41
+ * A rectangle with its position, its size and its four edges. `toJSON()` returns
42
+ * the plain values.
43
+ */
44
+ export interface RectLike extends RectValues {
45
+ toJSON(): RectValues;
46
+ }
47
+ /**
48
+ * Builds a rect from a node's box. Values stay unrounded.
49
+ * @param layout - the box from {@link LayoutBox}, or `null` for no record
50
+ * @returns the rect; all zeros for `null`
51
+ */
52
+ export declare function rectOf(layout: LayoutBox | null): RectLike;
53
+ /**
54
+ * Reads a `tabindex` attribute value as the element's tab index. A value that
55
+ * is missing, not a string or number, has no leading integer, or falls outside
56
+ * the 32-bit signed range yields the default.
57
+ * @param value - the stored `tabindex` attribute, or `null` if unset
58
+ * @param kind - the element kind; `"button"` defaults to `0`, any other kind to `-1`
59
+ * @returns the parsed tab index, or the default
60
+ */
61
+ export declare function tabIndexOf(value: string | number | boolean | null, kind: string): number;
@@ -0,0 +1,19 @@
1
+ import { NodeId, TagName } from '../types.mts';
2
+ import { IncaElement } from './types.mts';
3
+ /**
4
+ * Builds the {@link IncaElement} handle for a native node: parentless,
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
+ * @param id - the native node's id
9
+ * @param kind - whether the node is an element or a comment stand-in
10
+ * @param tag - the node's element kind, if it has one; a `button` defaults to tab index `0`
11
+ * @returns the new handle
12
+ */
13
+ export declare function createIncaElement(id: NodeId, kind: IncaElement["kind"], tag?: TagName): IncaElement;
14
+ /**
15
+ * Returns the element that currently has focus. A `focus()` or `blur()` call
16
+ * takes effect for this function at once.
17
+ * @returns the focused element, or `null` when no element has focus
18
+ */
19
+ export declare function activeElement(): IncaElement | null;
@@ -0,0 +1,51 @@
1
+ import { NodeId } from '../types.mts';
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;
18
+ /**
19
+ * Records `element` under its id.
20
+ * @param element - the handle to record
21
+ */
22
+ export declare function registerElement(element: IncaElement): void;
23
+ /**
24
+ * Drops the record of a native node.
25
+ * @param id - the native node's id
26
+ */
27
+ export declare function unregisterElement(id: NodeId): void;
28
+ /**
29
+ * Counts the recorded nodes, including those whose handle is already collected
30
+ * and waits for the registry to drop it.
31
+ * @returns the number of records
32
+ */
33
+ export declare function recordedCount(): number;
34
+ /**
35
+ * Looks up the live handle of a native node.
36
+ * @param id - the native node's id
37
+ * @returns the handle, or `undefined` when none is live
38
+ */
39
+ export declare function elementOf(id: NodeId): IncaElement | undefined;
40
+ /**
41
+ * Whether the host freed `node` with its subtree.
42
+ * @param node - the handle to check
43
+ * @returns `true` after {@link markDestroyed} reached `node`
44
+ */
45
+ export declare function isDestroyed(node: IncaNode): boolean;
46
+ /**
47
+ * Records that the host freed `node` and every descendant of it, and drops
48
+ * their element handles from the registry.
49
+ * @param node - the root of the freed subtree
50
+ */
51
+ export declare function markDestroyed(node: IncaNode): void;
@@ -1,4 +1,24 @@
1
1
  import { ScrollAlignment } from '../types.mts';
2
+ import { IncaElement } from './types.mts';
3
+ /** The options form of `scrollTo()` and `scrollBy()`. `behavior` is accepted and ignored. */
4
+ export interface ScrollOptions {
5
+ /** The horizontal offset. Omit to keep the current one. */
6
+ left?: number;
7
+ /** The vertical offset. Omit to keep the current one. */
8
+ top?: number;
9
+ /** `behavior` is ignored; every scroll applies at once. */
10
+ behavior?: "auto" | "instant" | "smooth";
11
+ }
12
+ /** Either `(left, top)` or an options object. */
13
+ export type ScrollArgs = [left?: number, top?: number] | [options?: ScrollOptions];
14
+ /**
15
+ * Moves a node's scroll offset. An omitted axis keeps its offset, and a
16
+ * non-finite value counts as `0`. A destroyed node ignores the call.
17
+ * @param el - the node to scroll
18
+ * @param args - `(left, top)` or `{ left, top }`
19
+ * @param relative - `true` adds the values to the current offset
20
+ */
21
+ export declare function scrollPosition(el: IncaElement, args: ScrollArgs, relative: boolean): void;
2
22
  /** The options form of `scrollIntoView()`. `behavior` is accepted and ignored. */
3
23
  export interface ScrollIntoViewOptions {
4
24
  /** The vertical alignment. Defaults to `"start"`. */