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,143 +0,0 @@
1
- //#region src/native.mts
2
- function e() {
3
- return globalThis.__inca_native__;
4
- }
5
- //#endregion
6
- //#region src/events.mts
7
- function t() {
8
- let e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map(), n = 0, r = () => globalThis.__inca_callbacks__ ??= {};
9
- return {
10
- add(i, a, o) {
11
- let s = n++;
12
- r()[s] = o;
13
- let c = e.get(i);
14
- return c || e.set(i, c = /* @__PURE__ */ new Map()), c.set(a, s), t.set(s, {
15
- group: i,
16
- listener: a
17
- }), s;
18
- },
19
- idFor(t, n) {
20
- return e.get(t)?.get(n);
21
- },
22
- release(n) {
23
- delete r()[n];
24
- let i = t.get(n);
25
- if (i === void 0) return;
26
- t.delete(n);
27
- let a = e.get(i.group);
28
- a?.delete(i.listener), a?.size === 0 && e.delete(i.group);
29
- },
30
- groupCount: () => e.size
31
- };
32
- }
33
- var n = t(), r = (e, t, n) => `${e}:${t}:${n === !0}`, i = 0;
34
- function a() {
35
- return i;
36
- }
37
- function o(e) {
38
- return (...t) => {
39
- let n = t[0]?.eventId;
40
- return typeof n == "number" && n > i && (i = n), e(...t);
41
- };
42
- }
43
- function s(e) {
44
- for (let t of e) n.release(t);
45
- }
46
- function c(t, i, a, s = {}) {
47
- if (a == null) return;
48
- let c = r(t, i, s.capture);
49
- if (n.idFor(c, a) !== void 0) return;
50
- let u = (...e) => typeof a == "function" ? a(...e) : a.handleEvent.apply(a, e), d = s.once ? (...e) => (l(t, i, a, s), u(...e)) : u, f = n.add(c, a, o(d));
51
- try {
52
- e().addEventListener(t, i, f, s.capture === !0, s.passive === !0);
53
- } catch (e) {
54
- throw n.release(f), e;
55
- }
56
- }
57
- function l(t, i, a, o = {}) {
58
- if (a == null) return;
59
- let s = n.idFor(r(t, i, o.capture), a);
60
- s !== void 0 && (e().removeEventListener(t, i, s), n.release(s));
61
- }
62
- function u(t, n) {
63
- return e().dispatchEvent(t, n);
64
- }
65
- function d(t) {
66
- e().click(t);
67
- }
68
- function f(t, n) {
69
- n === void 0 ? e().focusNode(t) : e().focusNode(t, n);
70
- }
71
- function p(t) {
72
- e().blurNode(t);
73
- }
74
- function m() {
75
- return e().focusedNode();
76
- }
77
- //#endregion
78
- //#region src/createEventTarget.mts
79
- function h(e, t = []) {
80
- return {
81
- addEventListener(n, r, i) {
82
- let a = typeof i == "boolean" ? { capture: i } : i ?? {};
83
- c(e(), n, r, {
84
- ...a,
85
- passive: a.passive ?? t.includes(n)
86
- });
87
- },
88
- removeEventListener(t, n, r) {
89
- let i = typeof r == "boolean" ? r : r?.capture;
90
- l(e(), t, n, { capture: i });
91
- },
92
- dispatchEvent: (t) => u(e(), t)
93
- };
94
- }
95
- //#endregion
96
- //#region src/tree.mts
97
- function g() {
98
- return e().rootNodeId();
99
- }
100
- function _(t) {
101
- return e().createNode(t);
102
- }
103
- function v(t, n) {
104
- e().appendChild(t, n);
105
- }
106
- function y(t, n, r) {
107
- e().insertBefore(t, n, r);
108
- }
109
- function b(t, n) {
110
- e().removeChild(t, n);
111
- }
112
- function x(t) {
113
- s(e().destroyNode(t));
114
- }
115
- function S(t, n, r) {
116
- e().setAttribute(t, n, r);
117
- }
118
- function C(t, n) {
119
- return e().getAttribute(t, n);
120
- }
121
- function w(t) {
122
- return e().layoutOf(t);
123
- }
124
- function T(t) {
125
- return e().scrollOf(t);
126
- }
127
- function E(t, n, r) {
128
- e().scrollNode(t, n, r);
129
- }
130
- function D(t, n, r) {
131
- e().scrollIntoViewNode(t, n, r);
132
- }
133
- function O(t, n) {
134
- e().removeAttribute(t, n);
135
- }
136
- function k(t, n, r) {
137
- e().setStyle(t, n, r);
138
- }
139
- function A(t, n) {
140
- e().removeStyle(t, n);
141
- }
142
- //#endregion
143
- export { a as C, m as S, c as _, y as a, u as b, b as c, D as d, E as f, h as g, k as h, C as i, A as l, S as m, _ as n, w as o, T as p, x as r, O as s, v as t, g as u, p as v, l as w, f as x, d as y };
@@ -1,7 +0,0 @@
1
- import { IncaElement } from './nodeOps.mts';
2
- /**
3
- * Returns the element that currently has focus. A `focus()` or `blur()` call
4
- * takes effect for this function at once.
5
- * @returns the focused element, or `null` when no element has focus
6
- */
7
- export declare function activeElement(): IncaElement | null;
@@ -1,13 +0,0 @@
1
- import { IncaCore, NodeId, TagName } from '../rendererCore.mts';
2
- import { IncaElement } from './nodeOps.mts';
3
- /**
4
- * Builds the {@link IncaElement} handle for a native node: parentless,
5
- * childless, with `focus()`, `blur()`, `click()`, the listener methods of an
6
- * event target, `tabIndex` and the layout members, all driven through `core`.
7
- * @param core - the incajs bindings the handle drives
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(core: IncaCore, id: NodeId, kind: IncaElement["kind"], tag?: TagName): IncaElement;
@@ -1,13 +0,0 @@
1
- import { IncaNode } from './nodeOps.mts';
2
- /**
3
- * Whether the host freed `node` with its subtree.
4
- * @param node - the handle to check
5
- * @returns `true` after {@link markDestroyed} reached `node`
6
- */
7
- export declare function isDestroyed(node: IncaNode): boolean;
8
- /**
9
- * Records that the host freed `node` and every descendant of it, and drops
10
- * their element handles from the registry.
11
- * @param node - the root of the freed subtree
12
- */
13
- export declare function markDestroyed(node: IncaNode): void;
@@ -1,24 +0,0 @@
1
- import { NodeId } from '../rendererCore.mts';
2
- import { IncaElement } from './nodeOps.mts';
3
- /**
4
- * Records `element` under its id.
5
- * @param element - the handle to record
6
- */
7
- export declare function registerElement(element: IncaElement): void;
8
- /**
9
- * Drops the record of a native node.
10
- * @param id - the native node's id
11
- */
12
- export declare function unregisterElement(id: NodeId): void;
13
- /**
14
- * Counts the recorded nodes, including those whose handle is already collected
15
- * and waits for the registry to drop it.
16
- * @returns the number of records
17
- */
18
- export declare function recordedCount(): number;
19
- /**
20
- * Looks up the live handle of a native node.
21
- * @param id - the native node's id
22
- * @returns the handle, or `undefined` when none is live
23
- */
24
- export declare function elementOf(id: NodeId): IncaElement | undefined;
@@ -1,12 +0,0 @@
1
- import { IncaCore } from '../rendererCore.mts';
2
- import { IncaElement } from './nodeOps.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;
@@ -1,14 +0,0 @@
1
- import { IncaCore } from '../rendererCore.mts';
2
- import { IncaElement } from './nodeOps.mts';
3
- /**
4
- * Where a node sits inside the padding edge of its offset parent, rounded to
5
- * whole pixels. A node with no offset parent is measured from the window
6
- * origin.
7
- * @param core - the incajs bindings to read through
8
- * @param el - the node to measure
9
- * @returns `left` and `top`; both `0` when the node has no recorded box
10
- */
11
- export declare function offsetOf(core: IncaCore, el: IncaElement): {
12
- left: number;
13
- top: number;
14
- };
@@ -1,10 +0,0 @@
1
- import { IncaCore } from '../rendererCore.mts';
2
- import { IncaElement } from './nodeOps.mts';
3
- /**
4
- * The parent a node's offsets are measured from. It is the parent when both
5
- * the node and the parent have a recorded box.
6
- * @param core - the incajs bindings to read through
7
- * @param el - the node to query
8
- * @returns the parent, or `null`
9
- */
10
- export declare function offsetParentOf(core: IncaCore, el: IncaElement): IncaElement | null;
@@ -1,25 +0,0 @@
1
- import { LayoutBox } from './layoutBox.mts';
2
- /** The plain values of a {@link RectLike}, as `toJSON` returns them. */
3
- export interface RectValues {
4
- readonly x: number;
5
- readonly y: number;
6
- readonly width: number;
7
- readonly height: number;
8
- readonly top: number;
9
- readonly left: number;
10
- readonly right: number;
11
- readonly bottom: number;
12
- }
13
- /**
14
- * A rectangle with its position, its size and its four edges. `toJSON()` returns
15
- * the plain values.
16
- */
17
- export interface RectLike extends RectValues {
18
- toJSON(): RectValues;
19
- }
20
- /**
21
- * Builds a rect from a node's box. Values stay unrounded.
22
- * @param layout - the box from {@link LayoutBox}, or `null` for no record
23
- * @returns the rect; all zeros for `null`
24
- */
25
- export declare function rectOf(layout: LayoutBox | null): RectLike;
@@ -1,22 +0,0 @@
1
- import { IncaCore } from '../rendererCore.mts';
2
- import { IncaElement } from './nodeOps.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 core - the incajs bindings to write through
18
- * @param el - the node to scroll
19
- * @param args - `(left, top)` or `{ left, top }`
20
- * @param relative - `true` adds the values to the current offset
21
- */
22
- export declare function scrollPosition(core: IncaCore, el: IncaElement, args: ScrollArgs, relative: boolean): void;
@@ -1,8 +0,0 @@
1
- /**
2
- * Marks `handle` so that Vue's `reactive()` and `ref()` keep the object itself.
3
- * A template ref then holds the same object the application receives from
4
- * `activeElement()`.
5
- * @param handle - the node handle to mark
6
- * @returns `handle`
7
- */
8
- export declare function skipReactive<T extends object>(handle: T): T;
@@ -1,9 +0,0 @@
1
- /**
2
- * Reads a `tabindex` attribute value as the element's tab index. A value that
3
- * is missing, not a string or number, has no leading integer, or falls outside
4
- * the 32-bit signed range yields the default.
5
- * @param value - the stored `tabindex` attribute, or `null` if unset
6
- * @param kind - the element kind; `"button"` defaults to `0`, any other kind to `-1`
7
- * @returns the parsed tab index, or the default
8
- */
9
- export declare function tabIndexOf(value: string | number | boolean | null, kind: string): number;