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
@@ -1,132 +1,29 @@
1
1
  import { RendererOptions } from '@vue/runtime-core';
2
- import { IncaCore, IncaEventTarget, NodeId } from '../rendererCore.mts';
3
- import { RectLike } from './rectOf.mts';
4
- import { ScrollIntoViewOptions } from './scrollIntoViewArgs.mts';
5
- import { ScrollOptions } from './scrollPosition.mts';
2
+ import { IncaCore, IncaElement, IncaNode } from '../rendererCore.mts';
6
3
  /**
7
- * A container host node: either a real element or the hidden stand-in
8
- * {@link NodeOps.createComment} uses. Also `@vue/runtime-core`'s
9
- * `HostElement` — the only host node type that can act as a parent.
10
- *
11
- * `inca`'s native tree has no parent pointers and no way to list a
12
- * node's children, so `parent`/`children` are maintained here as a
13
- * JS-side shadow of the tree, kept in sync by {@link NodeOps.insert}/
14
- * {@link NodeOps.remove}.
15
- *
16
- * After the node is removed, `addEventListener()` and `removeEventListener()`
17
- * ignore the call, and `dispatchEvent()` returns `true`.
4
+ * Marks `handle` so that Vue's `reactive()` and `ref()` keep the object itself.
5
+ * A template ref then holds the same object the application receives from
6
+ * `activeElement()`.
7
+ * @param handle - the node handle to mark
8
+ * @returns `handle`
18
9
  */
19
- export interface IncaElement extends IncaEventTarget {
20
- /**
21
- * The underlying native node's id — the only part of this object the native
22
- * tree itself knows about.
23
- */
24
- readonly id: NodeId;
25
- /**
26
- * `"comment"` for the hidden stand-in {@link NodeOps.createComment}
27
- * produces; `"element"` for every other container. Purely
28
- * informational — both render identically once created.
29
- */
30
- readonly kind: "element" | "comment";
31
- /** The current parent, or `null` if this node isn't attached to the tree. */
32
- parent: IncaElement | null;
33
- /** This node's children, in render order. */
34
- children: IncaNode[];
35
- /**
36
- * Focuses this node next frame. The node needs a `tabindex` attribute. A
37
- * `true` `preventScroll` keeps every scroll container where it is. After
38
- * the node is removed, the call does nothing.
39
- */
40
- focus(options?: {
41
- preventScroll?: boolean;
42
- }): void;
43
- /** Unfocuses this node next frame, if it is the focused one. */
44
- blur(): void;
45
- /**
46
- * Fires an untrusted `click` at this node. A disabled `button`, a node whose
47
- * own click is still running and an unknown node ignore the call.
48
- */
49
- click(): void;
50
- /**
51
- * Assigning sets the `tabindex` attribute to the value's integer part,
52
- * wrapped to 32 bits. Reading returns the `tabindex` attribute as an
53
- * integer, or `-1` (`0` for a `button`) when it is unset or invalid.
54
- * After the node is removed, reading gives that default and assigning does
55
- * nothing.
56
- */
57
- tabIndex: number;
58
- /**
59
- * The box this node was drawn at in the last frame, in window logical
60
- * pixels. A node created in the same task reads all zeros.
61
- */
62
- getBoundingClientRect(): RectLike;
63
- /** The box width from the last frame, rounded. `0` until a frame draws the node. */
64
- readonly offsetWidth: number;
65
- /** The box height from the last frame, rounded. `0` until a frame draws the node. */
66
- readonly offsetHeight: number;
67
- /** The box's left edge from the last frame, relative to {@link offsetParent}. Stays fixed while the parent scrolls. */
68
- readonly offsetLeft: number;
69
- /** The box's top edge from the last frame, relative to {@link offsetParent}. Stays fixed while the parent scrolls. */
70
- readonly offsetTop: number;
71
- /**
72
- * The parent, when this node and the parent both have a box from the last frame.
73
- * `null` when either lacks a box or there is no parent.
74
- */
75
- readonly offsetParent: IncaElement | null;
76
- /** The box width less both borders, rounded, at least `0`. */
77
- readonly clientWidth: number;
78
- /** The box height less both borders, rounded, at least `0`. */
79
- readonly clientHeight: number;
80
- /** The border width, rounded. */
81
- readonly clientLeft: number;
82
- /** The border width, rounded. */
83
- readonly clientTop: number;
84
- /** The horizontal scroll offset. Assigning moves it at once, and reads are clamped to the last frame's maximum. */
85
- scrollLeft: number;
86
- /** The vertical scroll offset. Assigning moves it at once, and reads are clamped to the last frame's maximum. */
87
- scrollTop: number;
88
- /** The content width: {@link clientWidth} plus the largest horizontal offset. */
89
- readonly scrollWidth: number;
90
- /** The content height: {@link clientHeight} plus the largest vertical offset. */
91
- readonly scrollHeight: number;
92
- /** Sets the offset to `(left, top)`, or to the options object's `left` and `top`. */
93
- scrollTo(left?: number, top?: number): void;
94
- scrollTo(options: ScrollOptions): void;
95
- /** Adds `(left, top)` to the offset, or the options object's `left` and `top`. */
96
- scrollBy(left?: number, top?: number): void;
97
- scrollBy(options: ScrollOptions): void;
98
- /**
99
- * Scrolls each scroll container around this node so the node shows. `true`
100
- * or no argument aligns to the start and `false` to the end. An options
101
- * object sets `block` (default `"start"`) and `inline` (default `"nearest"`);
102
- * `behavior` is accepted and ignored. After the node is removed, the call
103
- * does nothing.
104
- */
105
- scrollIntoView(arg?: boolean | ScrollIntoViewOptions): void;
106
- }
107
- /** A text leaf host node — `@vue/runtime-core`'s `HostNode` for text. */
108
- export interface IncaText {
109
- /** The underlying native node's id. */
110
- readonly id: NodeId;
111
- /** Discriminates this node within the {@link IncaNode} union. */
112
- readonly kind: "text";
113
- /** The current parent, or `null` if this node isn't attached to the tree. */
114
- parent: IncaElement | null;
115
- /**
116
- * The text content, mirroring what's been pushed to the native node via
117
- * {@link IncaCore.setAttribute}.
118
- */
119
- text: string;
120
- }
121
- /** Any host node {@link NodeOps} can produce: an element, comment, or text leaf. */
122
- export type IncaNode = IncaElement | IncaText;
10
+ export declare function skipReactive<T extends object>(handle: T): T;
123
11
  /** {@link createNodeOps}'s return shape. */
124
12
  export type NodeOps = Omit<RendererOptions<IncaNode, IncaElement>, "patchProp">;
125
13
  /**
126
14
  * `@vue/runtime-core`'s {@link RendererOptions}`<IncaNode, IncaElement>`,
127
- * minus `patchProp` — the host-node lifecycle half of `incajs/vue`'s custom
128
- * renderer, built entirely on the injected {@link IncaCore}, never on the
129
- * native bridge directly.
15
+ * minus `patchProp`. This is the host-node lifecycle half of `incajs/vue`'s custom
16
+ * renderer.
130
17
  * @param core - the incajs bindings to drive the native tree through
131
18
  */
132
19
  export declare function createNodeOps(core: IncaCore): NodeOps;
20
+ type Creators = Pick<NodeOps, "createElement" | "createText">;
21
+ /**
22
+ * The creators of `ops` that hold the node they create and release the hold
23
+ * once the returned handle is collected.
24
+ * @param core - the incajs bindings the holds go through
25
+ * @param ops - the creators to wrap
26
+ * @returns held versions of `createElement` and `createText`
27
+ */
28
+ export declare function createHeldNodeOps(core: IncaCore, ops: Creators): Creators;
29
+ export {};
@@ -1,8 +1,7 @@
1
1
  import { RendererOptions } from '@vue/runtime-core';
2
- import { IncaCore } from '../rendererCore.mts';
3
- import { IncaElement } from './nodeOps.mts';
2
+ import { IncaCore, IncaElement } from '../rendererCore.mts';
4
3
  /**
5
- * {@link RendererOptions.patchProp} — applies one changed `v-bind`/
4
+ * {@link RendererOptions.patchProp} applies one changed `v-bind`/
6
5
  * attribute/event prop to a host element.
7
6
  *
8
7
  * ### `style`
package/dist/vue.js CHANGED
@@ -1,294 +1,57 @@
1
- import { S as e, u as t } from "./chunks/tree-Ds0zSuJO.js";
2
- import { t as n } from "./rendererCore.js";
1
+ import { t as e } from "./chunks/rendererCore-BWT8KFVJ.js";
2
+ import { m as t } from "./chunks/hooks-BgB7lzTv.js";
3
+ import { n } from "./chunks/handle-SWQTonXe.js";
3
4
  import { ErrorCodes as r, callWithAsyncErrorHandling as i, createRenderer as a } from "@vue/runtime-core";
4
- //#region src/vue/elements.mts
5
- var o = /* @__PURE__ */ new Map(), s = new FinalizationRegistry((e) => {
6
- o.get(e)?.deref() || o.delete(e);
7
- });
8
- function c(e) {
9
- o.set(e.id, new WeakRef(e)), s.register(e, e.id);
10
- }
11
- function l(e) {
12
- o.delete(e);
13
- }
14
- function u(e) {
15
- return o.get(e)?.deref();
16
- }
17
- //#endregion
18
- //#region src/vue/destroyedNodes.mts
19
- var d = /* @__PURE__ */ new WeakSet();
20
- function f(e) {
21
- return d.has(e);
22
- }
23
- function p(e) {
24
- if (d.add(e), e.kind !== "text") {
25
- l(e.id);
26
- for (let t of e.children) p(t);
27
- }
28
- }
29
- //#endregion
30
- //#region src/vue/layoutBox.mts
31
- function m(e, t) {
32
- return f(t) ? null : e.layoutOf(t.id);
33
- }
34
- //#endregion
35
- //#region src/vue/offsetParent.mts
36
- function h(e, t) {
37
- let n = t.parent;
38
- return !m(e, t) || !n || !m(e, n) ? null : n;
39
- }
40
- //#endregion
41
- //#region src/vue/offsetOf.mts
42
- function g(e, t) {
43
- let n = m(e, t);
44
- if (!n) return {
45
- left: 0,
46
- top: 0
47
- };
48
- let r = h(e, t), i = r ? m(e, r) : null;
49
- return {
50
- left: Math.round(n[0] - (i ? i[0] + i[4] : 0) + n[5]) || 0,
51
- top: Math.round(n[1] - (i ? i[1] + i[4] : 0) + n[6]) || 0
52
- };
53
- }
54
- //#endregion
55
- //#region src/vue/rectOf.mts
56
- function _(e) {
57
- let [t, n, r, i] = e ?? [
58
- 0,
59
- 0,
60
- 0,
61
- 0,
62
- 0
63
- ], a = {
64
- x: t,
65
- y: n,
66
- width: r,
67
- height: i,
68
- top: n,
69
- left: t,
70
- right: t + r,
71
- bottom: n + i
72
- };
73
- return {
74
- ...a,
75
- toJSON: () => ({ ...a })
76
- };
77
- }
78
- //#endregion
79
- //#region src/vue/scrollIntoViewArgs.mts
80
- function v(e) {
81
- let t = [
82
- "start",
83
- "center",
84
- "end",
85
- "nearest"
86
- ];
87
- return typeof e == "object" && e ? {
88
- block: t.includes(e.block ?? "") ? e.block : "start",
89
- inline: t.includes(e.inline ?? "") ? e.inline : "nearest"
90
- } : {
91
- block: e === !1 ? "end" : "start",
92
- inline: "nearest"
93
- };
94
- }
95
- //#endregion
96
- //#region src/vue/scrollPosition.mts
97
- function y(e, t, n, r) {
98
- if (f(t)) return;
99
- let [i, a] = n, [o, s] = typeof i == "object" ? [i?.left, i?.top] : [i, a], [c, l] = r ? e.scrollOf(t.id) ?? [0, 0] : [0, 0], u = (e, t) => {
100
- if (e === void 0) return null;
101
- let n = Number(e);
102
- return (r ? t : 0) + (Number.isFinite(n) ? n : 0);
103
- };
104
- e.scrollNode(t.id, u(o, c), u(s, l));
105
- }
106
- //#endregion
107
- //#region src/vue/skipReactive.mts
108
- function b(e) {
5
+ //#region src/vue/nodeOps.mts
6
+ function o(e) {
109
7
  return Object.defineProperty(e, "__v_skip", { value: !0 }), e;
110
8
  }
111
- //#endregion
112
- //#region src/vue/tabIndexOf.mts
113
- function x(e, t) {
114
- let n = t === "button" ? 0 : -1;
115
- if (typeof e != "string" && typeof e != "number") return n;
116
- let r = /^[\t\n\f\r ]*([+-]?\d+)/.exec(String(e));
117
- if (!r) return n;
118
- let i = Number(r[1]) || 0;
119
- return i >= -2147483648 && i <= 2147483647 ? i : n;
120
- }
121
- //#endregion
122
- //#region src/vue/createElement.mts
123
- function S(e, t, n, r) {
124
- let i = e.createEventTarget(() => t), a = () => f(o) ? null : e.scrollOf(t), o = {
125
- id: t,
126
- kind: n,
127
- parent: null,
128
- children: [],
129
- focus: (n) => {
130
- if (f(o)) return;
131
- let r = n?.preventScroll;
132
- r === void 0 ? e.focus(t) : e.focus(t, !!r);
133
- },
134
- blur: () => e.blur(t),
135
- click: () => e.click(t),
136
- addEventListener: (...e) => {
137
- f(o) || i.addEventListener(...e);
138
- },
139
- removeEventListener: (...e) => {
140
- f(o) || i.removeEventListener(...e);
141
- },
142
- dispatchEvent: (e) => f(o) || i.dispatchEvent(e),
143
- get tabIndex() {
144
- return x(f(o) ? null : e.getAttribute(t, "tabindex"), r ?? "");
145
- },
146
- set tabIndex(n) {
147
- f(o) || e.setAttribute(t, "tabindex", n | 0);
148
- },
149
- getBoundingClientRect: () => _(m(e, o)),
150
- get offsetWidth() {
151
- return Math.round(m(e, o)?.[2] ?? 0);
152
- },
153
- get offsetHeight() {
154
- return Math.round(m(e, o)?.[3] ?? 0);
155
- },
156
- get offsetLeft() {
157
- return g(e, o).left;
158
- },
159
- get offsetTop() {
160
- return g(e, o).top;
161
- },
162
- get offsetParent() {
163
- return h(e, o);
164
- },
165
- get clientWidth() {
166
- let t = m(e, o);
167
- return t ? Math.max(0, Math.round(t[2] - 2 * t[4])) : 0;
168
- },
169
- get clientHeight() {
170
- let t = m(e, o);
171
- return t ? Math.max(0, Math.round(t[3] - 2 * t[4])) : 0;
172
- },
173
- get clientLeft() {
174
- return Math.round(m(e, o)?.[4] ?? 0);
175
- },
176
- get clientTop() {
177
- return Math.round(m(e, o)?.[4] ?? 0);
178
- },
179
- get scrollLeft() {
180
- return a()?.[0] ?? 0;
181
- },
182
- set scrollLeft(t) {
183
- y(e, o, [t], !1);
184
- },
185
- get scrollTop() {
186
- return a()?.[1] ?? 0;
187
- },
188
- set scrollTop(t) {
189
- y(e, o, [void 0, t], !1);
190
- },
191
- get scrollWidth() {
192
- return o.clientWidth + Math.round(a()?.[2] ?? 0);
193
- },
194
- get scrollHeight() {
195
- return o.clientHeight + Math.round(a()?.[3] ?? 0);
196
- },
197
- scrollTo: (...t) => y(e, o, t, !1),
198
- scrollBy: (...t) => y(e, o, t, !0),
199
- scrollIntoView: (n) => {
200
- if (f(o)) return;
201
- let { block: r, inline: i } = v(n);
202
- e.scrollIntoViewNode(t, r, i);
203
- }
9
+ function s(e) {
10
+ return {
11
+ createElement: (t) => o(e.createElementNode(t)),
12
+ createText: (t) => o(e.createTextNode(t)),
13
+ createComment: (t) => o(e.createCommentNode()),
14
+ setText: (t, n) => e.setText(t, n),
15
+ setElementText: (t, n) => e.setElementText(t, n),
16
+ insert: (t, n, r) => e.insert(t, n, r),
17
+ remove: (t) => e.remove(t),
18
+ parentNode: e.parentNode,
19
+ nextSibling: e.nextSibling
204
20
  };
205
- return n === "element" && c(o), b(o);
206
21
  }
207
- //#endregion
208
- //#region src/vue/nodeOps.mts
209
- function C(e) {
210
- function t(t) {
211
- let n = e.createNode("text");
212
- return e.setAttribute(n, "value", t), b({
213
- id: n,
214
- kind: "text",
215
- parent: null,
216
- text: t
217
- });
218
- }
219
- function n(e) {
220
- let t = e.parent;
221
- if (!t) return;
222
- let n = t.children.indexOf(e);
223
- n !== -1 && t.children.splice(n, 1), e.parent = null;
224
- }
225
- function r(t) {
226
- t.parent && e.removeChild(t.parent.id, t.id), n(t);
227
- }
22
+ function c(e, t) {
23
+ let n = (t) => (e.holdNode(t.__node_id), e.releaseWhenCollected(t), t), { createElement: r, createText: i } = t;
228
24
  return {
229
- createElement(t) {
230
- return S(e, e.createNode(t), "element", t);
231
- },
232
- createText: t,
233
- createComment(t) {
234
- let n = e.createNode("div");
235
- return e.setStyle(n, "display", "none"), S(e, n, "comment");
236
- },
237
- setText(t, n) {
238
- e.setAttribute(t.id, "value", n), t.text = n;
239
- },
240
- setElementText(n, r) {
241
- for (let t of n.children.splice(0)) e.destroyNode(t.id), p(t), t.parent = null;
242
- if (!r) return;
243
- let i = t(r);
244
- e.appendChild(n.id, i.id), i.parent = n, n.children.push(i);
245
- },
246
- insert(t, n, i) {
247
- if (i === t && t.parent === n) return;
248
- r(t);
249
- let a = i ? n.children.indexOf(i) : -1;
250
- e.insertBefore(n.id, t.id, i && a !== -1 ? i.id : null), a === -1 ? n.children.push(t) : n.children.splice(a, 0, t), t.parent = n;
251
- },
252
- remove(t) {
253
- n(t), e.destroyNode(t.id), p(t);
254
- },
255
- parentNode(e) {
256
- return e.parent;
257
- },
258
- nextSibling(e) {
259
- let t = e.parent;
260
- if (!t) return null;
261
- let n = t.children.indexOf(e);
262
- return t.children[n + 1] ?? null;
263
- }
25
+ createElement: (e) => n(r(e)),
26
+ createText: (e) => n(i(e))
264
27
  };
265
28
  }
266
29
  //#endregion
267
30
  //#region src/vue/patchProp.mts
268
- var w = (e) => /^on[^a-z]/.test(e) && !e.startsWith("onUpdate:"), T = /(?:Once|Passive|Capture)$/, E = /^on:?(?:Once|Passive|Capture)$/, D = (e) => e.replace(/\B([A-Z])/g, "-$1").toLowerCase();
269
- function O(e) {
31
+ var l = (e) => /^on[^a-z]/.test(e) && !e.startsWith("onUpdate:"), u = /(?:Once|Passive|Capture)$/, d = /^on:?(?:Once|Passive|Capture)$/, f = (e) => e.replace(/\B([A-Z])/g, "-$1").toLowerCase();
32
+ function p(e) {
270
33
  let t = e, n = {
271
34
  event: "",
272
35
  once: !1,
273
36
  capture: !1,
274
37
  passive: !1
275
38
  }, r;
276
- for (; (r = t.match(T)) && !E.test(t);) t = t.slice(0, -r[0].length), r[0] === "Once" ? n.once = !0 : r[0] === "Capture" ? n.capture = !0 : n.passive = !0;
277
- return n.event = t[2] === ":" ? t.slice(3) : D(t.slice(2)), n;
39
+ for (; (r = t.match(u)) && !d.test(t);) t = t.slice(0, -r[0].length), r[0] === "Once" ? n.once = !0 : r[0] === "Capture" ? n.capture = !0 : n.passive = !0;
40
+ return n.event = t[2] === ":" ? t.slice(3) : f(t.slice(2)), n;
278
41
  }
279
- var k = (e) => typeof e == "string" || typeof e == "number", A = /* @__PURE__ */ new WeakMap();
280
- function j(e, t, n) {
281
- let r = typeof n == "object" && n ? n : {}, i = A.get(t);
282
- i || A.set(t, i = /* @__PURE__ */ new Map());
42
+ var m = (e) => typeof e == "string" || typeof e == "number", h = /* @__PURE__ */ new WeakMap();
43
+ function g(e, t, n) {
44
+ let r = typeof n == "object" && n ? n : {}, i = h.get(t);
45
+ i || h.set(t, i = /* @__PURE__ */ new Map());
283
46
  let a = !1;
284
- for (let n of i.keys()) k(r[n]) || (e.removeStyle(t.id, n), i.delete(n), a = !0);
285
- for (let [n, o] of Object.entries(r)) k(o) && (a || i.get(n) !== o) && (e.setStyle(t.id, n, o), i.set(n, o));
47
+ for (let n of i.keys()) m(r[n]) || (e.removeStyle(t.__node_id, n), i.delete(n), a = !0);
48
+ for (let [n, o] of Object.entries(r)) m(o) && (a || i.get(n) !== o) && (e.setStyle(t.__node_id, n, o), i.set(n, o));
286
49
  }
287
- function M(e) {
50
+ function _(e) {
288
51
  let t = (Array.isArray(e) ? e : [e]).filter((e) => typeof e == "function");
289
52
  return t.length === 0 ? null : t;
290
53
  }
291
- function N(e, t) {
54
+ function v(e, t) {
292
55
  let n = e[0];
293
56
  if (typeof n != "object" || !n) return t(() => !1);
294
57
  let r = n.stopImmediatePropagation;
@@ -305,12 +68,12 @@ function N(e, t) {
305
68
  i ? n.stopImmediatePropagation = r : delete n.stopImmediatePropagation;
306
69
  }
307
70
  }
308
- var P = /* @__PURE__ */ new WeakMap(), F = ({ event: e, capture: t, passive: n }) => `${e}:${t === !0}:${n === !0}`;
309
- function I(e, t, n, r) {
71
+ var y = /* @__PURE__ */ new WeakMap(), b = ({ event: e, capture: t, passive: n }) => `${e}:${t === !0}:${n === !0}`;
72
+ function x(e, t, n, r) {
310
73
  let i = Array.from(r.slots.values()).some((e) => !e.fired);
311
- i && !r.registered ? (e.addEventListener(t.id, r.event, r.dispatcher, r.options), r.registered = !0) : !i && r.registered && (r.registered = !1, e.removeEventListener(t.id, r.event, r.dispatcher, r.options)), r.slots.size === 0 && P.get(t)?.delete(n);
74
+ i && !r.registered && !e.isDestroyed(t) ? (e.addEventListener(t.__node_id, r.event, r.dispatcher, r.options), r.registered = !0) : !i && r.registered && (r.registered = !1, e.removeEventListener(t.__node_id, r.event, r.dispatcher, r.options)), r.slots.size === 0 && y.get(t)?.delete(n);
312
75
  }
313
- function L(e, t, n, { event: a, capture: o, passive: s }) {
76
+ function S(e, t, n, { event: a, capture: o, passive: s }) {
314
77
  let c = {
315
78
  event: a,
316
79
  options: {
@@ -321,12 +84,12 @@ function L(e, t, n, { event: a, capture: o, passive: s }) {
321
84
  registered: !1,
322
85
  dispatcher: (...a) => {
323
86
  let o = [], s = a[0]?.eventId;
324
- N(a, (l) => {
87
+ v(a, (l) => {
325
88
  for (let u of Array.from(c.slots.keys())) {
326
89
  if (l()) break;
327
90
  let d = c.slots.get(u);
328
91
  if (d && !d.fired && !(typeof s == "number" && d.attachedAt >= s)) {
329
- d.once && (d.fired = !0, I(e, t, n, c));
92
+ d.once && (d.fired = !0, x(e, t, n, c));
330
93
  for (let e of d.handlers) {
331
94
  if (l()) break;
332
95
  try {
@@ -344,20 +107,20 @@ function L(e, t, n, { event: a, capture: o, passive: s }) {
344
107
  };
345
108
  return c;
346
109
  }
347
- function R(e, t, n, r) {
348
- let i = F(n), a = P.get(t)?.get(i);
349
- a?.slots.delete(r) && I(e, t, i, a);
110
+ function C(e, t, n, r) {
111
+ let i = b(n), a = y.get(t)?.get(i);
112
+ a?.slots.delete(r) && x(e, t, i, a);
350
113
  }
351
- function z(e, t, n, r, i) {
352
- let a = O(n), o = M(r);
114
+ function w(e, t, n, r, i) {
115
+ let a = p(n), o = _(r);
353
116
  if (!o) {
354
- R(e, t, a, n);
117
+ C(e, t, a, n);
355
118
  return;
356
119
  }
357
- let s = F(a), c = P.get(t);
358
- c || P.set(t, c = /* @__PURE__ */ new Map());
120
+ let s = b(a), c = y.get(t);
121
+ c || y.set(t, c = /* @__PURE__ */ new Map());
359
122
  let l = c.get(s);
360
- l || c.set(s, l = L(e, t, s, a));
123
+ l || c.set(s, l = S(e, t, s, a));
361
124
  let u = l.slots.get(n);
362
125
  if (u) u.handlers = o, u.instance = i;
363
126
  else {
@@ -369,36 +132,41 @@ function z(e, t, n, r, i) {
369
132
  fired: !1
370
133
  });
371
134
  try {
372
- I(e, t, s, l);
135
+ x(e, t, s, l);
373
136
  } catch (e) {
374
137
  throw l.slots.delete(n), l.slots.size === 0 && c.delete(s), e;
375
138
  }
376
139
  }
377
140
  }
378
- var B = /* @__PURE__ */ new Set([
141
+ var T = /* @__PURE__ */ new Set([
379
142
  "disabled",
380
143
  "hidden",
381
144
  "inert"
382
145
  ]);
383
- function V(e) {
146
+ function E(e) {
384
147
  return (t, n, r, i, a, o) => {
385
- n === "style" ? j(e, t, i) : w(n) ? z(e, t, n, i, o ?? null) : B.has(n) && i === !1 ? e.removeAttribute(t.id, n) : typeof i == "string" || typeof i == "number" || typeof i == "boolean" ? e.setAttribute(t.id, n, i) : i == null ? e.removeAttribute(t.id, n) : n.startsWith("onUpdate:") || e.setAttribute(t.id, n, String(i));
148
+ n === "style" ? g(e, t, i) : l(n) ? w(e, t, n, i, o ?? null) : T.has(n) && i === !1 ? e.removeAttribute(t.__node_id, n) : typeof i == "string" || typeof i == "number" || typeof i == "boolean" ? e.setAttribute(t.__node_id, n, i) : i == null ? e.removeAttribute(t.__node_id, n) : n.startsWith("onUpdate:") || e.setAttribute(t.__node_id, n, String(i));
386
149
  };
387
150
  }
388
151
  //#endregion
389
152
  //#region src/vue/createApp.mts
390
- function H(e, r) {
391
- let i = a({
392
- ...C(n),
393
- patchProp: V(n)
394
- }).createApp(e, r), o = i.mount.bind(i);
395
- return Object.assign(i, { mount: (e) => o(e ?? S(n, t(), "element")) });
396
- }
397
- //#endregion
398
- //#region src/vue/activeElement.mts
399
- function U() {
400
- let t = e();
401
- return t === null ? null : u(t) ?? null;
153
+ var D = /* @__PURE__ */ new Set();
154
+ function O(r, i) {
155
+ let l = {
156
+ ...s(e),
157
+ patchProp: E(e)
158
+ }, u = a(l);
159
+ Object.assign(l, c(e, l));
160
+ let d = u.createApp(r, i), f = d.mount.bind(d), p = d.unmount.bind(d);
161
+ return Object.assign(d, {
162
+ mount: (e) => {
163
+ let r = f(e ?? o(n(t(), "element")));
164
+ return D.add(d), r;
165
+ },
166
+ unmount: () => {
167
+ p(), D.delete(d);
168
+ }
169
+ });
402
170
  }
403
171
  //#endregion
404
- export { U as activeElement, H as createIncaApp };
172
+ export { O as createIncaApp };
package/dist/window.d.mts CHANGED
@@ -1,11 +1,13 @@
1
+ import { IncaEventTarget } from './types.mts';
1
2
  /**
2
- * The event target at the top of the app. Bubble listeners on it run for
3
- * every bubbling event, and capture listeners run for every event dispatched
4
- * in the app, including events that do not bubble. Key events reach it while
5
- * nothing is focused. A `wheel` listener is passive unless its options say
3
+ * The event target at the top of the app. Every event path ends at it.
4
+ * Bubble listeners on it run for every bubbling event, and capture listeners
5
+ * run for every event dispatched in the app, including events that do not
6
+ * bubble. Key events reach it while nothing is focused, with `window` as
7
+ * `target`. A `wheel` listener is passive unless its options say
6
8
  * `passive: false`.
7
9
  *
8
10
  * It has the listener methods `addEventListener`, `removeEventListener` and
9
11
  * `dispatchEvent`.
10
12
  */
11
- export declare const window: import('./types.mts').IncaEventTarget;
13
+ export declare const window: IncaEventTarget;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "incajs",
3
- "version": "0.0.15",
3
+ "version": "0.0.17",
4
4
  "description": "A GPU-native, Webview-free desktop app framework built on GPUI and QuickJS.",
5
5
  "keywords": [
6
6
  "cross-platform",
@@ -30,7 +30,11 @@
30
30
  "dist"
31
31
  ],
32
32
  "type": "module",
33
- "sideEffects": false,
33
+ "sideEffects": [
34
+ "src/callbacks.mts",
35
+ "src/targets.mts",
36
+ "dist/chunks/hooks-*.js"
37
+ ],
34
38
  "main": "./dist/index.js",
35
39
  "types": "./dist/index.d.mts",
36
40
  "exports": {