incajs 0.0.6 → 0.0.8

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.
@@ -36,7 +36,13 @@ function a(e) {
36
36
  for (let t of e) i.release(t);
37
37
  }
38
38
  function o(e, t, r) {
39
- s(e, t), n().addEventListener(e, t, i.add(e, t, r));
39
+ s(e, t);
40
+ let a = i.add(e, t, r);
41
+ try {
42
+ n().addEventListener(e, t, a);
43
+ } catch (e) {
44
+ throw i.release(a), e;
45
+ }
40
46
  }
41
47
  function s(e, t) {
42
48
  let r = i.idFor(e, t);
@@ -45,8 +51,8 @@ function s(e, t) {
45
51
  function c(e) {
46
52
  n().focusNode(e);
47
53
  }
48
- function l() {
49
- n().blurNode();
54
+ function l(e) {
55
+ n().blurNode(e);
50
56
  }
51
57
  //#endregion
52
58
  //#region src/tree.mts
@@ -74,9 +80,12 @@ function g(e, t, r) {
74
80
  function _(e, t, r) {
75
81
  n().setStyle(e, t, r);
76
82
  }
83
+ function v(e, t) {
84
+ n().removeStyle(e, t);
85
+ }
77
86
  //#endregion
78
87
  //#region src/rendererCore.mts
79
- var v = /* @__PURE__ */ t({
88
+ var y = /* @__PURE__ */ t({
80
89
  appendChild: () => f,
81
90
  blur: () => l,
82
91
  createNode: () => d,
@@ -85,10 +94,11 @@ var v = /* @__PURE__ */ t({
85
94
  insertBefore: () => p,
86
95
  removeChild: () => m,
87
96
  removeEventListener: () => s,
97
+ removeStyle: () => v,
88
98
  rootNodeId: () => u,
89
99
  setAttribute: () => g,
90
100
  setEventListener: () => o,
91
101
  setStyle: () => _
92
102
  });
93
103
  //#endregion
94
- export { p as a, g as c, c as d, s as f, h as i, _ as l, f as n, m as o, o as p, d as r, u as s, v as t, l as u };
104
+ export { p as a, u as c, l as d, c as f, h as i, g as l, o as m, f as n, m as o, s as p, d as r, v as s, y as t, _ as u };
package/dist/events.d.mts CHANGED
@@ -37,7 +37,9 @@ export declare function removeEventListener(nodeId: NodeId, event: string): void
37
37
  */
38
38
  export declare function focus(nodeId: NodeId): void;
39
39
  /**
40
- * Requests that whatever is focused become unfocused. Takes effect on the
41
- * next frame; a no-op if nothing is focused when it runs.
40
+ * Requests that `nodeId` become unfocused, the way `element.blur()` does.
41
+ * Takes effect on the next frame; a no-op if `nodeId` isn't the focused node
42
+ * when it runs.
43
+ * @param nodeId - the node to unfocus
42
44
  */
43
- export declare function blur(): void;
45
+ export declare function blur(nodeId: NodeId): void;
package/dist/native.d.mts CHANGED
@@ -8,11 +8,12 @@ interface IncaNative {
8
8
  removeChild(parentId: NodeId, childId: NodeId): void;
9
9
  setAttribute(nodeId: NodeId, key: string, value: AttributeValue): void;
10
10
  setStyle(nodeId: NodeId, key: string, value: AttributeValue): void;
11
+ removeStyle(nodeId: NodeId, key: string): void;
11
12
  addEventListener(nodeId: NodeId, event: string, callbackId: CallbackId): void;
12
13
  removeEventListener(nodeId: NodeId, event: string, callbackId: CallbackId): boolean;
13
14
  destroyNode(nodeId: NodeId): CallbackId[];
14
15
  focusNode(nodeId: NodeId): void;
15
- blurNode(): void;
16
+ blurNode(nodeId: NodeId): void;
16
17
  }
17
18
  declare global {
18
19
  var __inca_native__: IncaNative;
@@ -1,5 +1,5 @@
1
1
  export { setEventListener, removeEventListener, focus, blur } from './events.mts';
2
- export { appendChild, createNode, destroyNode, insertBefore, removeChild, rootNodeId, setAttribute, setStyle, } from './tree.mts';
2
+ export { appendChild, createNode, destroyNode, insertBefore, removeChild, rootNodeId, setAttribute, setStyle, removeStyle, } from './tree.mts';
3
3
  /**
4
4
  * The tree/event primitives a custom renderer (`incajs/vue`) drives the
5
5
  * native tree through.
@@ -1,2 +1,2 @@
1
- import { a as e, c as t, d as n, f as r, i, l as a, n as o, o as s, p as c, r as l, s as u, u as d } from "./chunks/rendererCore-Kxb_fevG.js";
2
- export { o as appendChild, d as blur, l as createNode, i as destroyNode, n as focus, e as insertBefore, s as removeChild, r as removeEventListener, u as rootNodeId, t as setAttribute, c as setEventListener, a as setStyle };
1
+ import { a as e, c as t, d as n, f as r, i, l as a, m as o, n as s, o as c, p as l, r as u, s as d, u as f } from "./chunks/rendererCore-BmtunkdP.js";
2
+ export { s as appendChild, n as blur, u as createNode, i as destroyNode, r as focus, e as insertBefore, c as removeChild, l as removeEventListener, d as removeStyle, t as rootNodeId, a as setAttribute, o as setEventListener, f as setStyle };
package/dist/tree.d.mts CHANGED
@@ -69,3 +69,10 @@ export declare function setAttribute(nodeId: NodeId, key: string, value: Attribu
69
69
  */
70
70
  export declare function setStyle<K extends keyof StyleProps>(nodeId: NodeId, key: K, value: NonNullable<StyleProps[K]>): void;
71
71
  export declare function setStyle(nodeId: NodeId, key: string, value: AttributeValue): void;
72
+ /**
73
+ * Removes a style property from `nodeId`, so it renders as if never set.
74
+ * Removing a property that isn't set does nothing.
75
+ * @param nodeId - the node to update
76
+ * @param key - the style property name
77
+ */
78
+ export declare function removeStyle(nodeId: NodeId, key: string): void;
package/dist/types.d.mts CHANGED
@@ -16,8 +16,8 @@ export type CallbackId = number;
16
16
  export type AttributeValue = string | number | boolean;
17
17
  /**
18
18
  * Element kind passed to `createNode`. `"text"` is the only tag with
19
- * dedicated rendering behavior — a leaf that renders its `"value"`
20
- * attribute's string content. Any other string is a generic styled
19
+ * dedicated rendering behavior — it renders its `"value"` attribute followed
20
+ * by its descendants' text. Any other string is a generic styled
21
21
  * container; the `string & {}` half of this type keeps `"text"`'s
22
22
  * autocomplete while still accepting an arbitrary tag name.
23
23
  */
@@ -55,6 +55,54 @@ export interface StyleProps {
55
55
  corner_radius?: number;
56
56
  /** Font size in px for this container's own text. Cascades to descendant text leaves, same as {@link StyleProps.text_color}. */
57
57
  text_size?: number;
58
+ /** Overflow on both axes; `"scroll"` (alias `"auto"`) makes the container scroll with the wheel. Overridden per axis by {@link StyleProps.overflow_x}/{@link StyleProps.overflow_y}. */
59
+ overflow?: "visible" | "hidden" | "scroll" | "auto";
60
+ /** Horizontal overflow; wins over {@link StyleProps.overflow}. */
61
+ overflow_x?: "visible" | "hidden" | "scroll" | "auto";
62
+ /** Vertical overflow; wins over {@link StyleProps.overflow}. */
63
+ overflow_y?: "visible" | "hidden" | "scroll" | "auto";
64
+ /** Inner spacing in px (`>= 0`) on all four sides. Overridden per axis by {@link StyleProps.padding_x}/{@link StyleProps.padding_y} and per side by the `padding_*` side keys. */
65
+ padding?: number;
66
+ /** Horizontal inner spacing in px (`>= 0`); wins over {@link StyleProps.padding}. */
67
+ padding_x?: number;
68
+ /** Vertical inner spacing in px (`>= 0`); wins over {@link StyleProps.padding}. */
69
+ padding_y?: number;
70
+ /** Top inner spacing in px (`>= 0`); wins over {@link StyleProps.padding_y}. */
71
+ padding_top?: number;
72
+ /** Right inner spacing in px (`>= 0`); wins over {@link StyleProps.padding_x}. */
73
+ padding_right?: number;
74
+ /** Bottom inner spacing in px (`>= 0`); wins over {@link StyleProps.padding_y}. */
75
+ padding_bottom?: number;
76
+ /** Left inner spacing in px (`>= 0`); wins over {@link StyleProps.padding_x}. */
77
+ padding_left?: number;
78
+ /** Outer spacing in px (negative allowed) or `"auto"` on all four sides. Overridden per axis by {@link StyleProps.margin_x}/{@link StyleProps.margin_y} and per side by the `margin_*` side keys. */
79
+ margin?: number | "auto";
80
+ /** Horizontal outer spacing; wins over {@link StyleProps.margin}. */
81
+ margin_x?: number | "auto";
82
+ /** Vertical outer spacing; wins over {@link StyleProps.margin}. */
83
+ margin_y?: number | "auto";
84
+ /** Top outer spacing; wins over {@link StyleProps.margin_y}. */
85
+ margin_top?: number | "auto";
86
+ /** Right outer spacing; wins over {@link StyleProps.margin_x}. */
87
+ margin_right?: number | "auto";
88
+ /** Bottom outer spacing; wins over {@link StyleProps.margin_y}. */
89
+ margin_bottom?: number | "auto";
90
+ /** Left outer spacing; wins over {@link StyleProps.margin_x}. */
91
+ margin_left?: number | "auto";
92
+ /** Share (`>= 0`) of the free space in the parent's main axis this node takes. */
93
+ flex_grow?: number;
94
+ /** Share (`>= 0`) of the overflow in the parent's main axis this node gives up. */
95
+ flex_shrink?: number;
96
+ /** Opacity from `0` to `1`, applied to this node and its descendants; values outside are clamped. */
97
+ opacity?: number;
98
+ /** Minimum width in px, or `"auto"` for the default minimum. */
99
+ min_width?: number | "auto";
100
+ /** Minimum height in px, or `"auto"` for the default minimum. */
101
+ min_height?: number | "auto";
102
+ /** Maximum width in px, or `"auto"` for no limit. */
103
+ max_width?: number | "auto";
104
+ /** Maximum height in px, or `"auto"` for no limit. */
105
+ max_height?: number | "auto";
58
106
  }
59
107
  /**
60
108
  * Signature of a callback registered via `setEventListener`. The
@@ -29,7 +29,7 @@ export interface IncaElement {
29
29
  children: IncaNode[];
30
30
  /** Focuses this node next frame. */
31
31
  focus(): void;
32
- /** Unfocuses whatever's focused, next frame. */
32
+ /** Unfocuses this node next frame, if it is the focused one. */
33
33
  blur(): void;
34
34
  }
35
35
  /** A text leaf host node — `@vue/runtime-core`'s `HostNode` for text. */
@@ -5,9 +5,11 @@ import { IncaElement } from './nodeOps.mts';
5
5
  * {@link RendererOptions.patchProp} — applies one changed `v-bind`/
6
6
  * attribute/event prop to a host element:
7
7
  *
8
- * - `style` (an object, per `:style="{...}"`) fans out to one
9
- * `core.setStyle` call per entry; an entry whose value isn't a
10
- * string/number is skipped.
8
+ * - `style` (an object, per `:style="{...}"`) is diffed against the entries
9
+ * already sent for this element. `core.setStyle` runs for each entry that
10
+ * is new or changed. `core.removeStyle` runs for each sent entry that is now
11
+ * absent, `null`, or not a string/number. A string or `null` `style`
12
+ * removes every entry.
11
13
  * - An `onXxx` key registers `nextValue` as the listener for `xxx`, taking a
12
14
  * function or an array of them, and unbinds `xxx` for anything else. A
13
15
  * trailing `Once`/`Passive`/`Capture` suffix (from Vue's `.once`/
@@ -16,12 +18,13 @@ import { IncaElement } from './nodeOps.mts';
16
18
  * bind as an ordinary listener with no native passive/capture-phase
17
19
  * support yet. See {@link EventListener} for which event names are wired
18
20
  * to real input by the native host today; other names are accepted but
19
- * never fire.
21
+ * never fire. An error a handler throws synchronously goes to the app's
22
+ * `errorHandler` and `onErrorCaptured` hooks; with no `errorHandler` it is
23
+ * also rethrown to the host's error report.
20
24
  * - Everything else falls through to `core.setAttribute`, again skipping
21
25
  * a non-string/number/boolean value rather than passing it through.
22
26
  *
23
- * There is no native "unset" call, so a prop that's removed entirely (a
24
- * `null`/`undefined` `nextValue`) is left as-is rather than cleared.
27
+ * Removing any other prop (a `null`/`undefined` `nextValue`) leaves it as-is.
25
28
  * @param core - the incajs bindings to drive the native tree through
26
29
  */
27
30
  export declare function createPatchProp(core: IncaCore): RendererOptions<unknown, IncaElement>["patchProp"];
package/dist/vue.js CHANGED
@@ -1,7 +1,7 @@
1
- import { d as e, s as t, t as n, u as r } from "./chunks/rendererCore-Kxb_fevG.js";
2
- import { createRenderer as i } from "@vue/runtime-core";
1
+ import { c as e, d as t, f as n, t as r } from "./chunks/rendererCore-BmtunkdP.js";
2
+ import { ErrorCodes as i, callWithAsyncErrorHandling as a, createRenderer as o } from "@vue/runtime-core";
3
3
  //#region src/vue/nodeOps.mts
4
- function a(e) {
4
+ function s(e) {
5
5
  function t(t) {
6
6
  let n = e.createNode("text");
7
7
  return e.setAttribute(n, "value", t), {
@@ -23,7 +23,7 @@ function a(e) {
23
23
  function i(t) {
24
24
  return {
25
25
  focus: () => e.focus(t),
26
- blur: () => e.blur()
26
+ blur: () => e.blur(t)
27
27
  };
28
28
  }
29
29
  return {
@@ -58,6 +58,7 @@ function a(e) {
58
58
  e.appendChild(n.id, i.id), i.parent = n, n.children.push(i);
59
59
  },
60
60
  insert(t, n, i) {
61
+ if (i === t && t.parent === n) return;
61
62
  r(t);
62
63
  let a = i ? n.children.indexOf(i) : -1;
63
64
  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;
@@ -78,64 +79,83 @@ function a(e) {
78
79
  }
79
80
  //#endregion
80
81
  //#region src/vue/patchProp.mts
81
- var o = (e) => /^on[A-Z]/.test(e), s = /(?:Once|Passive|Capture)$/;
82
- function c(e) {
82
+ var c = (e) => /^on[A-Z]/.test(e), l = /(?:Once|Passive|Capture)$/;
83
+ function u(e) {
83
84
  let t = e, n = !1, r;
84
- for (; r = t.match(s);) t = t.slice(0, -r[0].length), r[0] === "Once" && (n = !0);
85
+ for (; r = t.match(l);) t = t.slice(0, -r[0].length), r[0] === "Once" && (n = !0);
85
86
  return {
86
87
  event: t.slice(2).toLowerCase(),
87
88
  once: n
88
89
  };
89
90
  }
90
- function l(e, t, n) {
91
- if (typeof n == "object" && n) for (let [r, i] of Object.entries(n)) (typeof i == "string" || typeof i == "number") && e.setStyle(t.id, r, i);
91
+ var d = (e) => typeof e == "string" || typeof e == "number", f = /* @__PURE__ */ new WeakMap();
92
+ function p(e, t, n) {
93
+ let r = typeof n == "object" && n ? n : {}, i = f.get(t);
94
+ i || f.set(t, i = /* @__PURE__ */ new Map());
95
+ for (let n of i.keys()) d(r[n]) || (e.removeStyle(t.id, n), i.delete(n));
96
+ for (let [n, a] of Object.entries(r)) d(a) && i.get(n) !== a && (e.setStyle(t.id, n, a), i.set(n, a));
92
97
  }
93
- function u(e) {
94
- if (typeof e == "function") return e;
95
- if (!Array.isArray(e)) return null;
96
- let t = e.filter((e) => typeof e == "function");
97
- return t.length === 0 ? null : (...e) => {
98
- for (let n of t) n(...e);
98
+ var m = (() => {
99
+ try {
100
+ return process.env.NODE_ENV === "production";
101
+ } catch {
102
+ return !1;
103
+ }
104
+ })(), h = (e) => e != null && typeof e.then == "function";
105
+ function g(e, t) {
106
+ let n = (Array.isArray(e) ? e : [e]).filter((e) => typeof e == "function");
107
+ return n.length === 0 ? null : (...e) => {
108
+ let r, o = n.map((e) => (...n) => {
109
+ try {
110
+ let r = e(...n);
111
+ return m && h(r) && r.then(void 0, (e) => {
112
+ if (!t?.appContext.config.errorHandler) throw e;
113
+ }), r;
114
+ } catch (e) {
115
+ throw r ??= { error: e }, e;
116
+ }
117
+ });
118
+ if (a(o, t, i.NATIVE_EVENT_HANDLER, e), r && !t?.appContext.config.errorHandler) throw r.error;
99
119
  };
100
120
  }
101
- function d(e, t, n, r) {
102
- let { event: i, once: a } = c(n), o = u(r);
103
- if (!o) {
104
- e.removeEventListener(t.id, i);
121
+ function _(e, t, n, r, i) {
122
+ let { event: a, once: o } = u(n), s = g(r, i);
123
+ if (!s) {
124
+ e.removeEventListener(t.id, a);
105
125
  return;
106
126
  }
107
- if (!a) {
108
- e.setEventListener(t.id, i, o);
127
+ if (!o) {
128
+ e.setEventListener(t.id, a, s);
109
129
  return;
110
130
  }
111
- e.setEventListener(t.id, i, (...n) => {
112
- e.removeEventListener(t.id, i), o(...n);
131
+ e.setEventListener(t.id, a, (...n) => {
132
+ e.removeEventListener(t.id, a), s(...n);
113
133
  });
114
134
  }
115
- function f(e) {
116
- return (t, n, r, i) => {
117
- n === "style" ? l(e, t, i) : o(n) ? d(e, t, n, i) : (typeof i == "string" || typeof i == "number" || typeof i == "boolean") && e.setAttribute(t.id, n, i);
135
+ function v(e) {
136
+ return (t, n, r, i, a, o) => {
137
+ n === "style" ? p(e, t, i) : c(n) ? _(e, t, n, i, o ?? null) : (typeof i == "string" || typeof i == "number" || typeof i == "boolean") && e.setAttribute(t.id, n, i);
118
138
  };
119
139
  }
120
140
  //#endregion
121
141
  //#region src/vue/createApp.mts
122
- function p(o, s) {
123
- let c = i({
124
- ...a(n),
125
- patchProp: f(n)
126
- }).createApp(o, s), l = c.mount.bind(c);
142
+ function y(i, a) {
143
+ let c = o({
144
+ ...s(r),
145
+ patchProp: v(r)
146
+ }).createApp(i, a), l = c.mount.bind(c);
127
147
  function u() {
128
- let n = t();
148
+ let r = e();
129
149
  return {
130
- id: n,
150
+ id: r,
131
151
  kind: "element",
132
152
  parent: null,
133
153
  children: [],
134
- focus: () => e(n),
135
- blur: () => r()
154
+ focus: () => n(r),
155
+ blur: () => t(r)
136
156
  };
137
157
  }
138
158
  return Object.assign(c, { mount: (e) => l(e ?? u()) });
139
159
  }
140
160
  //#endregion
141
- export { p as createIncaApp };
161
+ export { y as createIncaApp };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "incajs",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "description": "A GPU-native, Webview-free desktop app framework built on GPUI and QuickJS.",
5
5
  "keywords": [
6
6
  "cross-platform",