incajs 0.0.15 → 0.0.16
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 +43 -0
- package/dist/chunks/handle-B1h0qxex.js +193 -0
- package/dist/chunks/rendererCore-U_s1R1v7.js +171 -0
- package/dist/element/geometry.d.mts +65 -0
- package/dist/{vue/createElement.d.mts → element/handle.d.mts} +7 -1
- package/dist/{vue/elements.d.mts → element/lifecycle.d.mts} +13 -1
- package/dist/{vue/scrollPosition.d.mts → element/scroll.d.mts} +23 -1
- package/dist/element/shadowTree.d.mts +71 -0
- package/dist/element/types.d.mts +119 -0
- package/dist/events.d.mts +2 -18
- package/dist/index.d.mts +4 -0
- package/dist/index.js +4 -3
- package/dist/native.d.mts +5 -2
- package/dist/rendererCore.d.mts +3 -3
- package/dist/rendererCore.js +1 -37
- package/dist/tree.d.mts +11 -6
- package/dist/types.d.mts +3 -4
- package/dist/vue/createApp.d.mts +1 -1
- package/dist/vue/index.d.mts +0 -6
- package/dist/vue/nodeOps.d.mts +10 -122
- package/dist/vue/patchProp.d.mts +2 -2
- package/dist/vue.js +97 -293
- package/package.json +1 -1
- package/dist/chunks/tree-Ds0zSuJO.js +0 -143
- package/dist/vue/activeElement.d.mts +0 -7
- package/dist/vue/destroyedNodes.d.mts +0 -13
- package/dist/vue/layoutBox.d.mts +0 -12
- package/dist/vue/offsetOf.d.mts +0 -14
- package/dist/vue/offsetParent.d.mts +0 -10
- package/dist/vue/rectOf.d.mts +0 -25
- package/dist/vue/scrollIntoViewArgs.d.mts +0 -22
- package/dist/vue/skipReactive.d.mts +0 -8
- package/dist/vue/tabIndexOf.d.mts +0 -9
- /package/dist/{createEventTarget.d.mts → eventTarget.d.mts} +0 -0
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@ SPDX-License-Identifier: MIT OR Apache-2.0
|
|
|
5
5
|
|
|
6
6
|
# incajs
|
|
7
7
|
|
|
8
|
-
**Incarnative.js**
|
|
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)).
|
|
@@ -0,0 +1,43 @@
|
|
|
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
|
+
* 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
|
+
/**
|
|
31
|
+
* The capture flag is part of the identity: the same node, event and function
|
|
32
|
+
* can listen in both phases side by side.
|
|
33
|
+
* @param nodeId - the node listened on
|
|
34
|
+
* @param event - the event name
|
|
35
|
+
* @param capture - the capture flag of the registration
|
|
36
|
+
* @returns the node, event and capture flag as one string
|
|
37
|
+
*/
|
|
38
|
+
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,193 @@
|
|
|
1
|
+
import { a as e } from "./rendererCore-U_s1R1v7.js";
|
|
2
|
+
//#region src/element/lifecycle.mts
|
|
3
|
+
var t = /* @__PURE__ */ new Map(), n = new FinalizationRegistry((e) => {
|
|
4
|
+
t.get(e)?.deref() || t.delete(e);
|
|
5
|
+
});
|
|
6
|
+
function r(e) {
|
|
7
|
+
t.set(e.id, new WeakRef(e)), n.register(e, e.id);
|
|
8
|
+
}
|
|
9
|
+
function i(e) {
|
|
10
|
+
t.delete(e);
|
|
11
|
+
}
|
|
12
|
+
function a(e) {
|
|
13
|
+
return t.get(e)?.deref();
|
|
14
|
+
}
|
|
15
|
+
var o = /* @__PURE__ */ new WeakSet();
|
|
16
|
+
function s(e) {
|
|
17
|
+
return o.has(e);
|
|
18
|
+
}
|
|
19
|
+
function c(e) {
|
|
20
|
+
if (o.add(e), e.kind !== "text") {
|
|
21
|
+
i(e.id);
|
|
22
|
+
for (let t of e.children) c(t);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region src/element/geometry.mts
|
|
27
|
+
function l(e, t) {
|
|
28
|
+
return s(t) ? null : e.layoutOf(t.id);
|
|
29
|
+
}
|
|
30
|
+
function u(e, t) {
|
|
31
|
+
let n = t.parent;
|
|
32
|
+
return !l(e, t) || !n || !l(e, n) ? null : n;
|
|
33
|
+
}
|
|
34
|
+
function d(e, t) {
|
|
35
|
+
let n = l(e, t);
|
|
36
|
+
if (!n) return {
|
|
37
|
+
left: 0,
|
|
38
|
+
top: 0
|
|
39
|
+
};
|
|
40
|
+
let r = u(e, t), i = r ? l(e, r) : null;
|
|
41
|
+
return {
|
|
42
|
+
left: Math.round(n[0] - (i ? i[0] + i[4] : 0) + n[5]) || 0,
|
|
43
|
+
top: Math.round(n[1] - (i ? i[1] + i[4] : 0) + n[6]) || 0
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function f(e) {
|
|
47
|
+
let [t, n, r, i] = e ?? [
|
|
48
|
+
0,
|
|
49
|
+
0,
|
|
50
|
+
0,
|
|
51
|
+
0,
|
|
52
|
+
0
|
|
53
|
+
], a = {
|
|
54
|
+
x: t,
|
|
55
|
+
y: n,
|
|
56
|
+
width: r,
|
|
57
|
+
height: i,
|
|
58
|
+
top: n,
|
|
59
|
+
left: t,
|
|
60
|
+
right: t + r,
|
|
61
|
+
bottom: n + i
|
|
62
|
+
};
|
|
63
|
+
return {
|
|
64
|
+
...a,
|
|
65
|
+
toJSON: () => ({ ...a })
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
function p(e, t) {
|
|
69
|
+
let n = t === "button" ? 0 : -1;
|
|
70
|
+
if (typeof e != "string" && typeof e != "number") return n;
|
|
71
|
+
let r = /^[\t\n\f\r ]*([+-]?\d+)/.exec(String(e));
|
|
72
|
+
if (!r) return n;
|
|
73
|
+
let i = Number(r[1]) || 0;
|
|
74
|
+
return i >= -2147483648 && i <= 2147483647 ? i : n;
|
|
75
|
+
}
|
|
76
|
+
//#endregion
|
|
77
|
+
//#region src/element/scroll.mts
|
|
78
|
+
function m(e, t, n, r) {
|
|
79
|
+
if (s(t)) return;
|
|
80
|
+
let [i, a] = n, [o, c] = typeof i == "object" ? [i?.left, i?.top] : [i, a], [l, u] = r ? e.scrollOf(t.id) ?? [0, 0] : [0, 0], d = (e, t) => {
|
|
81
|
+
if (e === void 0) return null;
|
|
82
|
+
let n = Number(e);
|
|
83
|
+
return (r ? t : 0) + (Number.isFinite(n) ? n : 0);
|
|
84
|
+
};
|
|
85
|
+
e.scrollNode(t.id, d(o, l), d(c, u));
|
|
86
|
+
}
|
|
87
|
+
function h(e) {
|
|
88
|
+
let t = [
|
|
89
|
+
"start",
|
|
90
|
+
"center",
|
|
91
|
+
"end",
|
|
92
|
+
"nearest"
|
|
93
|
+
];
|
|
94
|
+
return typeof e == "object" && e ? {
|
|
95
|
+
block: t.includes(e.block ?? "") ? e.block : "start",
|
|
96
|
+
inline: t.includes(e.inline ?? "") ? e.inline : "nearest"
|
|
97
|
+
} : {
|
|
98
|
+
block: e === !1 ? "end" : "start",
|
|
99
|
+
inline: "nearest"
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
//#endregion
|
|
103
|
+
//#region src/element/handle.mts
|
|
104
|
+
function g(e, t, n, i) {
|
|
105
|
+
let a = e.createEventTarget(() => t), o = () => s(c) ? null : e.scrollOf(t), c = {
|
|
106
|
+
id: t,
|
|
107
|
+
kind: n,
|
|
108
|
+
parent: null,
|
|
109
|
+
children: [],
|
|
110
|
+
focus: (n) => {
|
|
111
|
+
if (s(c)) return;
|
|
112
|
+
let r = n?.preventScroll;
|
|
113
|
+
r === void 0 ? e.focus(t) : e.focus(t, !!r);
|
|
114
|
+
},
|
|
115
|
+
blur: () => e.blur(t),
|
|
116
|
+
click: () => e.click(t),
|
|
117
|
+
addEventListener: (...e) => {
|
|
118
|
+
s(c) || a.addEventListener(...e);
|
|
119
|
+
},
|
|
120
|
+
removeEventListener: (...e) => {
|
|
121
|
+
s(c) || a.removeEventListener(...e);
|
|
122
|
+
},
|
|
123
|
+
dispatchEvent: (e) => s(c) || a.dispatchEvent(e),
|
|
124
|
+
get tabIndex() {
|
|
125
|
+
return p(s(c) ? null : e.getAttribute(t, "tabindex"), i ?? "");
|
|
126
|
+
},
|
|
127
|
+
set tabIndex(n) {
|
|
128
|
+
s(c) || e.setAttribute(t, "tabindex", n | 0);
|
|
129
|
+
},
|
|
130
|
+
getBoundingClientRect: () => f(l(e, c)),
|
|
131
|
+
get offsetWidth() {
|
|
132
|
+
return Math.round(l(e, c)?.[2] ?? 0);
|
|
133
|
+
},
|
|
134
|
+
get offsetHeight() {
|
|
135
|
+
return Math.round(l(e, c)?.[3] ?? 0);
|
|
136
|
+
},
|
|
137
|
+
get offsetLeft() {
|
|
138
|
+
return d(e, c).left;
|
|
139
|
+
},
|
|
140
|
+
get offsetTop() {
|
|
141
|
+
return d(e, c).top;
|
|
142
|
+
},
|
|
143
|
+
get offsetParent() {
|
|
144
|
+
return u(e, c);
|
|
145
|
+
},
|
|
146
|
+
get clientWidth() {
|
|
147
|
+
let t = l(e, c);
|
|
148
|
+
return t ? Math.max(0, Math.round(t[2] - 2 * t[4])) : 0;
|
|
149
|
+
},
|
|
150
|
+
get clientHeight() {
|
|
151
|
+
let t = l(e, c);
|
|
152
|
+
return t ? Math.max(0, Math.round(t[3] - 2 * t[4])) : 0;
|
|
153
|
+
},
|
|
154
|
+
get clientLeft() {
|
|
155
|
+
return Math.round(l(e, c)?.[4] ?? 0);
|
|
156
|
+
},
|
|
157
|
+
get clientTop() {
|
|
158
|
+
return Math.round(l(e, c)?.[4] ?? 0);
|
|
159
|
+
},
|
|
160
|
+
get scrollLeft() {
|
|
161
|
+
return o()?.[0] ?? 0;
|
|
162
|
+
},
|
|
163
|
+
set scrollLeft(t) {
|
|
164
|
+
m(e, c, [t], !1);
|
|
165
|
+
},
|
|
166
|
+
get scrollTop() {
|
|
167
|
+
return o()?.[1] ?? 0;
|
|
168
|
+
},
|
|
169
|
+
set scrollTop(t) {
|
|
170
|
+
m(e, c, [void 0, t], !1);
|
|
171
|
+
},
|
|
172
|
+
get scrollWidth() {
|
|
173
|
+
return c.clientWidth + Math.round(o()?.[2] ?? 0);
|
|
174
|
+
},
|
|
175
|
+
get scrollHeight() {
|
|
176
|
+
return c.clientHeight + Math.round(o()?.[3] ?? 0);
|
|
177
|
+
},
|
|
178
|
+
scrollTo: (...t) => m(e, c, t, !1),
|
|
179
|
+
scrollBy: (...t) => m(e, c, t, !0),
|
|
180
|
+
scrollIntoView: (n) => {
|
|
181
|
+
if (s(c)) return;
|
|
182
|
+
let { block: r, inline: i } = h(n);
|
|
183
|
+
e.scrollIntoViewNode(t, r, i);
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
return n === "element" && r(c), c;
|
|
187
|
+
}
|
|
188
|
+
function _() {
|
|
189
|
+
let t = e();
|
|
190
|
+
return t === null ? null : a(t) ?? null;
|
|
191
|
+
}
|
|
192
|
+
//#endregion
|
|
193
|
+
export { g as n, c as r, _ as t };
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var e = Object.defineProperty, t = (t, n) => {
|
|
3
|
+
let r = {};
|
|
4
|
+
for (var i in t) e(r, i, {
|
|
5
|
+
get: t[i],
|
|
6
|
+
enumerable: !0
|
|
7
|
+
});
|
|
8
|
+
return n || e(r, Symbol.toStringTag, { value: "Module" }), r;
|
|
9
|
+
}, n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), i = () => globalThis.__inca_callbacks__ ??= {};
|
|
10
|
+
function a(e, t, a, o) {
|
|
11
|
+
i()[a] = o;
|
|
12
|
+
let s = n.get(e);
|
|
13
|
+
s || n.set(e, s = /* @__PURE__ */ new Map()), s.set(t, a), r.set(a, {
|
|
14
|
+
group: e,
|
|
15
|
+
listener: t
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
function o(e, t) {
|
|
19
|
+
return n.get(e)?.get(t);
|
|
20
|
+
}
|
|
21
|
+
function s(e) {
|
|
22
|
+
delete i()[e];
|
|
23
|
+
let t = r.get(e);
|
|
24
|
+
if (t === void 0) return;
|
|
25
|
+
r.delete(e);
|
|
26
|
+
let a = n.get(t.group);
|
|
27
|
+
a?.delete(t.listener), a?.size === 0 && n.delete(t.group);
|
|
28
|
+
}
|
|
29
|
+
function c(e) {
|
|
30
|
+
for (let t of e) s(t);
|
|
31
|
+
}
|
|
32
|
+
var l = (e, t, n) => `${e}:${t}:${n === !0}`;
|
|
33
|
+
//#endregion
|
|
34
|
+
//#region src/native.mts
|
|
35
|
+
function u() {
|
|
36
|
+
return globalThis.__inca_native__;
|
|
37
|
+
}
|
|
38
|
+
//#endregion
|
|
39
|
+
//#region src/events.mts
|
|
40
|
+
var d = 0;
|
|
41
|
+
function f() {
|
|
42
|
+
return d;
|
|
43
|
+
}
|
|
44
|
+
function p(e) {
|
|
45
|
+
return (...t) => {
|
|
46
|
+
let n = t[0]?.eventId;
|
|
47
|
+
return typeof n == "number" && n > d && (d = n), e(...t);
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function m(e, t, n, r = {}) {
|
|
51
|
+
if (n == null) return;
|
|
52
|
+
let i = l(e, t, r.capture);
|
|
53
|
+
if (o(i, n) !== void 0) return;
|
|
54
|
+
let s = (...e) => typeof n == "function" ? n(...e) : n.handleEvent.apply(n, e), c = r.once ? (...i) => (h(e, t, n, r), s(...i)) : s;
|
|
55
|
+
a(i, n, u().addEventListener(e, t, r.capture === !0, r.passive === !0), p(c));
|
|
56
|
+
}
|
|
57
|
+
function h(e, t, n, r = {}) {
|
|
58
|
+
if (n == null) return;
|
|
59
|
+
let i = o(l(e, t, r.capture), n);
|
|
60
|
+
i !== void 0 && (u().removeEventListener(e, t, i), s(i));
|
|
61
|
+
}
|
|
62
|
+
function g(e, t) {
|
|
63
|
+
return u().dispatchEvent(e, t);
|
|
64
|
+
}
|
|
65
|
+
function _(e) {
|
|
66
|
+
u().click(e);
|
|
67
|
+
}
|
|
68
|
+
function v(e, t) {
|
|
69
|
+
t === void 0 ? u().focusNode(e) : u().focusNode(e, t);
|
|
70
|
+
}
|
|
71
|
+
function y(e) {
|
|
72
|
+
u().blurNode(e);
|
|
73
|
+
}
|
|
74
|
+
//#endregion
|
|
75
|
+
//#region src/eventTarget.mts
|
|
76
|
+
function b(e, t = []) {
|
|
77
|
+
return {
|
|
78
|
+
addEventListener(n, r, i) {
|
|
79
|
+
let a = typeof i == "boolean" ? { capture: i } : i ?? {};
|
|
80
|
+
m(e(), n, r, {
|
|
81
|
+
...a,
|
|
82
|
+
passive: a.passive ?? t.includes(n)
|
|
83
|
+
});
|
|
84
|
+
},
|
|
85
|
+
removeEventListener(t, n, r) {
|
|
86
|
+
let i = typeof r == "boolean" ? r : r?.capture;
|
|
87
|
+
h(e(), t, n, { capture: i });
|
|
88
|
+
},
|
|
89
|
+
dispatchEvent: (t) => g(e(), t)
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
//#endregion
|
|
93
|
+
//#region src/tree.mts
|
|
94
|
+
function x() {
|
|
95
|
+
return u().rootNodeId();
|
|
96
|
+
}
|
|
97
|
+
function S(e) {
|
|
98
|
+
return u().createNode(e);
|
|
99
|
+
}
|
|
100
|
+
function C(e, t) {
|
|
101
|
+
u().appendChild(e, t);
|
|
102
|
+
}
|
|
103
|
+
function w(e, t, n) {
|
|
104
|
+
u().insertBefore(e, t, n);
|
|
105
|
+
}
|
|
106
|
+
function T(e, t) {
|
|
107
|
+
u().removeChild(e, t);
|
|
108
|
+
}
|
|
109
|
+
function E(e) {
|
|
110
|
+
c(u().destroyNode(e));
|
|
111
|
+
}
|
|
112
|
+
function D(e, t, n) {
|
|
113
|
+
u().setAttribute(e, t, n);
|
|
114
|
+
}
|
|
115
|
+
function O(e, t) {
|
|
116
|
+
return u().getAttribute(e, t);
|
|
117
|
+
}
|
|
118
|
+
function k(e) {
|
|
119
|
+
return u().layoutOf(e);
|
|
120
|
+
}
|
|
121
|
+
function A(e) {
|
|
122
|
+
return u().scrollOf(e);
|
|
123
|
+
}
|
|
124
|
+
function j(e, t, n) {
|
|
125
|
+
u().scrollNode(e, t, n);
|
|
126
|
+
}
|
|
127
|
+
function M(e, t, n) {
|
|
128
|
+
u().scrollIntoViewNode(e, t, n);
|
|
129
|
+
}
|
|
130
|
+
function N(e, t) {
|
|
131
|
+
u().removeAttribute(e, t);
|
|
132
|
+
}
|
|
133
|
+
function P(e, t, n) {
|
|
134
|
+
u().setStyle(e, t, n);
|
|
135
|
+
}
|
|
136
|
+
function F(e, t) {
|
|
137
|
+
u().removeStyle(e, t);
|
|
138
|
+
}
|
|
139
|
+
function I() {
|
|
140
|
+
return u().focusedNode();
|
|
141
|
+
}
|
|
142
|
+
//#endregion
|
|
143
|
+
//#region src/rendererCore.mts
|
|
144
|
+
var L = /* @__PURE__ */ t({
|
|
145
|
+
addEventListener: () => m,
|
|
146
|
+
appendChild: () => C,
|
|
147
|
+
blur: () => y,
|
|
148
|
+
click: () => _,
|
|
149
|
+
createEventTarget: () => b,
|
|
150
|
+
createNode: () => S,
|
|
151
|
+
destroyNode: () => E,
|
|
152
|
+
dispatchEvent: () => g,
|
|
153
|
+
focus: () => v,
|
|
154
|
+
focusedNode: () => I,
|
|
155
|
+
getAttribute: () => O,
|
|
156
|
+
insertBefore: () => w,
|
|
157
|
+
latestEventId: () => f,
|
|
158
|
+
layoutOf: () => k,
|
|
159
|
+
removeAttribute: () => N,
|
|
160
|
+
removeChild: () => T,
|
|
161
|
+
removeEventListener: () => h,
|
|
162
|
+
removeStyle: () => F,
|
|
163
|
+
rootNodeId: () => x,
|
|
164
|
+
scrollIntoViewNode: () => M,
|
|
165
|
+
scrollNode: () => j,
|
|
166
|
+
scrollOf: () => A,
|
|
167
|
+
setAttribute: () => D,
|
|
168
|
+
setStyle: () => P
|
|
169
|
+
});
|
|
170
|
+
//#endregion
|
|
171
|
+
export { v as C, g as S, h as T, P as _, I as a, y as b, k as c, F as d, x as f, D as g, A as h, E as i, N as l, j as m, C as n, O as o, M as p, S as r, w as s, L as t, T as u, b as v, f as w, _ as x, m as y };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { IncaCore } from '../rendererCore.mts';
|
|
2
|
+
import { IncaElement } from './types.mts';
|
|
3
|
+
/** `[x, y, width, height, border, scrollX, scrollY]` of a node's last drawn frame. */
|
|
4
|
+
export type LayoutBox = readonly [number, number, number, number, number, number, number];
|
|
5
|
+
/**
|
|
6
|
+
* Reads the box a node was last drawn at. A destroyed node, or one with no
|
|
7
|
+
* recorded box, yields `null`.
|
|
8
|
+
* @param core - the incajs bindings to read through
|
|
9
|
+
* @param el - the node to read
|
|
10
|
+
* @returns the box, or `null`
|
|
11
|
+
*/
|
|
12
|
+
export declare function layoutBox(core: IncaCore, el: IncaElement): LayoutBox | null;
|
|
13
|
+
/**
|
|
14
|
+
* The parent a node's offsets are measured from. It is the parent when both
|
|
15
|
+
* the node and the parent have a recorded box.
|
|
16
|
+
* @param core - the incajs bindings to read through
|
|
17
|
+
* @param el - the node to query
|
|
18
|
+
* @returns the parent, or `null`
|
|
19
|
+
*/
|
|
20
|
+
export declare function offsetParentOf(core: IncaCore, el: IncaElement): IncaElement | null;
|
|
21
|
+
/**
|
|
22
|
+
* Where a node sits inside the padding edge of its offset parent, rounded to
|
|
23
|
+
* whole pixels. A node with no offset parent is measured from the window
|
|
24
|
+
* origin.
|
|
25
|
+
* @param core - the incajs bindings to read through
|
|
26
|
+
* @param el - the node to measure
|
|
27
|
+
* @returns `left` and `top`; both `0` when the node has no recorded box
|
|
28
|
+
*/
|
|
29
|
+
export declare function offsetOf(core: IncaCore, el: IncaElement): {
|
|
30
|
+
left: number;
|
|
31
|
+
top: number;
|
|
32
|
+
};
|
|
33
|
+
/** The plain values of a {@link RectLike}, as `toJSON` returns them. */
|
|
34
|
+
export interface RectValues {
|
|
35
|
+
readonly x: number;
|
|
36
|
+
readonly y: number;
|
|
37
|
+
readonly width: number;
|
|
38
|
+
readonly height: number;
|
|
39
|
+
readonly top: number;
|
|
40
|
+
readonly left: number;
|
|
41
|
+
readonly right: number;
|
|
42
|
+
readonly bottom: number;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* A rectangle with its position, its size and its four edges. `toJSON()` returns
|
|
46
|
+
* the plain values.
|
|
47
|
+
*/
|
|
48
|
+
export interface RectLike extends RectValues {
|
|
49
|
+
toJSON(): RectValues;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Builds a rect from a node's box. Values stay unrounded.
|
|
53
|
+
* @param layout - the box from {@link LayoutBox}, or `null` for no record
|
|
54
|
+
* @returns the rect; all zeros for `null`
|
|
55
|
+
*/
|
|
56
|
+
export declare function rectOf(layout: LayoutBox | null): RectLike;
|
|
57
|
+
/**
|
|
58
|
+
* Reads a `tabindex` attribute value as the element's tab index. A value that
|
|
59
|
+
* is missing, not a string or number, has no leading integer, or falls outside
|
|
60
|
+
* the 32-bit signed range yields the default.
|
|
61
|
+
* @param value - the stored `tabindex` attribute, or `null` if unset
|
|
62
|
+
* @param kind - the element kind; `"button"` defaults to `0`, any other kind to `-1`
|
|
63
|
+
* @returns the parsed tab index, or the default
|
|
64
|
+
*/
|
|
65
|
+
export declare function tabIndexOf(value: string | number | boolean | null, kind: string): number;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IncaCore, NodeId, TagName } from '../rendererCore.mts';
|
|
2
|
-
import { IncaElement } from './
|
|
2
|
+
import { IncaElement } from './types.mts';
|
|
3
3
|
/**
|
|
4
4
|
* Builds the {@link IncaElement} handle for a native node: parentless,
|
|
5
5
|
* childless, with `focus()`, `blur()`, `click()`, the listener methods of an
|
|
@@ -11,3 +11,9 @@ import { IncaElement } from './nodeOps.mts';
|
|
|
11
11
|
* @returns the new handle
|
|
12
12
|
*/
|
|
13
13
|
export declare function createIncaElement(core: IncaCore, 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;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NodeId } from '../rendererCore.mts';
|
|
2
|
-
import { IncaElement } from './
|
|
2
|
+
import { IncaElement, IncaNode } from './types.mts';
|
|
3
3
|
/**
|
|
4
4
|
* Records `element` under its id.
|
|
5
5
|
* @param element - the handle to record
|
|
@@ -22,3 +22,15 @@ export declare function recordedCount(): number;
|
|
|
22
22
|
* @returns the handle, or `undefined` when none is live
|
|
23
23
|
*/
|
|
24
24
|
export declare function elementOf(id: NodeId): IncaElement | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Whether the host freed `node` with its subtree.
|
|
27
|
+
* @param node - the handle to check
|
|
28
|
+
* @returns `true` after {@link markDestroyed} reached `node`
|
|
29
|
+
*/
|
|
30
|
+
export declare function isDestroyed(node: IncaNode): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Records that the host freed `node` and every descendant of it, and drops
|
|
33
|
+
* their element handles from the registry.
|
|
34
|
+
* @param node - the root of the freed subtree
|
|
35
|
+
*/
|
|
36
|
+
export declare function markDestroyed(node: IncaNode): void;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { IncaCore } from '../rendererCore.mts';
|
|
2
|
-
import {
|
|
2
|
+
import { ScrollAlignment } from '../types.mts';
|
|
3
|
+
import { IncaElement } from './types.mts';
|
|
3
4
|
/** The options form of `scrollTo()` and `scrollBy()`. `behavior` is accepted and ignored. */
|
|
4
5
|
export interface ScrollOptions {
|
|
5
6
|
/** The horizontal offset. Omit to keep the current one. */
|
|
@@ -20,3 +21,24 @@ export type ScrollArgs = [left?: number, top?: number] | [options?: ScrollOption
|
|
|
20
21
|
* @param relative - `true` adds the values to the current offset
|
|
21
22
|
*/
|
|
22
23
|
export declare function scrollPosition(core: IncaCore, el: IncaElement, args: ScrollArgs, relative: boolean): void;
|
|
24
|
+
/** The options form of `scrollIntoView()`. `behavior` is accepted and ignored. */
|
|
25
|
+
export interface ScrollIntoViewOptions {
|
|
26
|
+
/** The vertical alignment. Defaults to `"start"`. */
|
|
27
|
+
block?: ScrollAlignment;
|
|
28
|
+
/** The horizontal alignment. Defaults to `"nearest"`. */
|
|
29
|
+
inline?: ScrollAlignment;
|
|
30
|
+
/** `behavior` is ignored; every scroll applies at once. */
|
|
31
|
+
behavior?: "auto" | "instant" | "smooth";
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Turns `scrollIntoView()`'s argument into the alignment pair. `true` or no
|
|
35
|
+
* argument aligns to the start, `false` to the end, and an options object
|
|
36
|
+
* takes each axis from its own key. An unknown string falls back to that
|
|
37
|
+
* axis's default.
|
|
38
|
+
* @param arg - the boolean or options object the caller passed
|
|
39
|
+
* @returns the `block` and `inline` alignments to send to the host
|
|
40
|
+
*/
|
|
41
|
+
export declare function scrollIntoViewArgs(arg?: boolean | ScrollIntoViewOptions): {
|
|
42
|
+
block: ScrollAlignment;
|
|
43
|
+
inline: ScrollAlignment;
|
|
44
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { IncaCore, TagName } from '../rendererCore.mts';
|
|
2
|
+
import { IncaElement, IncaNode, IncaText } from './types.mts';
|
|
3
|
+
/**
|
|
4
|
+
* Allocates a new element node for `tag`.
|
|
5
|
+
* @param core - the incajs bindings to drive the native tree through
|
|
6
|
+
* @param tag - the node's element kind
|
|
7
|
+
* @returns the new, parentless, childless element
|
|
8
|
+
*/
|
|
9
|
+
export declare function createElementNode(core: IncaCore, tag: TagName): IncaElement;
|
|
10
|
+
/**
|
|
11
|
+
* Creates a text leaf.
|
|
12
|
+
* @param core - the incajs bindings to drive the native tree through
|
|
13
|
+
* @param text - the initial text content
|
|
14
|
+
* @returns the new text leaf
|
|
15
|
+
*/
|
|
16
|
+
export declare function createTextNode(core: IncaCore, text: string): IncaText;
|
|
17
|
+
/**
|
|
18
|
+
* Creates the hidden container that stands in for a comment node, such as a
|
|
19
|
+
* placeholder for conditional content.
|
|
20
|
+
* @param core - the incajs bindings to drive the native tree through
|
|
21
|
+
* @returns the new hidden element
|
|
22
|
+
*/
|
|
23
|
+
export declare function createCommentNode(core: IncaCore): IncaElement;
|
|
24
|
+
/**
|
|
25
|
+
* Updates a text leaf's content in place.
|
|
26
|
+
* @param core - the incajs bindings to drive the native tree through
|
|
27
|
+
* @param node - the text leaf to update
|
|
28
|
+
* @param text - the new text content
|
|
29
|
+
*/
|
|
30
|
+
export declare function setText(core: IncaCore, node: IncaText, text: string): void;
|
|
31
|
+
/**
|
|
32
|
+
* Replaces all of `el`'s children with at most a single text child holding
|
|
33
|
+
* `text`. An empty string leaves `el` childless.
|
|
34
|
+
* @param core - the incajs bindings to drive the native tree through
|
|
35
|
+
* @param el - the container whose children are replaced
|
|
36
|
+
* @param text - the new text content
|
|
37
|
+
*/
|
|
38
|
+
export declare function setElementText(core: IncaCore, el: IncaElement, text: string): void;
|
|
39
|
+
/**
|
|
40
|
+
* Attaches `child` to `parent`, before `anchor` or at the end when `anchor` is
|
|
41
|
+
* omitted or `null`. If `anchor` is `child` itself and `child` is already in
|
|
42
|
+
* `parent`, nothing changes. A `child` attached elsewhere is detached first,
|
|
43
|
+
* so a move keeps the node alive.
|
|
44
|
+
* @param core - the incajs bindings to drive the native tree through
|
|
45
|
+
* @param child - the node being attached
|
|
46
|
+
* @param parent - the new container
|
|
47
|
+
* @param anchor - the sibling to insert before, or omitted/`null` to append at the end
|
|
48
|
+
*/
|
|
49
|
+
export declare function insert(core: IncaCore, child: IncaNode, parent: IncaElement, anchor?: IncaNode | null): void;
|
|
50
|
+
/**
|
|
51
|
+
* Removes `child` for good: the native node, its whole subtree, and every
|
|
52
|
+
* event listener registered in it.
|
|
53
|
+
*
|
|
54
|
+
* A caller that removes a subtree calls this on its root alone, so a node's
|
|
55
|
+
* descendants are freed here or nowhere.
|
|
56
|
+
* @param core - the incajs bindings to drive the native tree through
|
|
57
|
+
* @param child - the node being removed
|
|
58
|
+
*/
|
|
59
|
+
export declare function remove(core: IncaCore, child: IncaNode): void;
|
|
60
|
+
/**
|
|
61
|
+
* Looks up the current parent.
|
|
62
|
+
* @param node - the node to query
|
|
63
|
+
* @returns the current parent, or `null` if it isn't attached
|
|
64
|
+
*/
|
|
65
|
+
export declare function parentNode(node: IncaNode): IncaElement | null;
|
|
66
|
+
/**
|
|
67
|
+
* Looks up the next sibling.
|
|
68
|
+
* @param node - the node to query
|
|
69
|
+
* @returns the sibling immediately after `node` in its parent's children, or `null` if there is none (or `node` isn't attached)
|
|
70
|
+
*/
|
|
71
|
+
export declare function nextSibling(node: IncaNode): IncaNode | null;
|