incajs 0.0.9 → 0.0.10

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.
@@ -31,74 +31,84 @@ function r() {
31
31
  }
32
32
  };
33
33
  }
34
- var i = r();
35
- function a(e) {
34
+ var i = r(), a = 0;
35
+ function o() {
36
+ return a;
37
+ }
38
+ function s(e) {
39
+ return (...t) => {
40
+ let n = t[0]?.eventId;
41
+ return typeof n == "number" && n > a && (a = n), e(...t);
42
+ };
43
+ }
44
+ function c(e) {
36
45
  for (let t of e) i.release(t);
37
46
  }
38
- function o(e, t, r) {
39
- s(e, t);
40
- let a = i.add(e, t, r);
47
+ function l(e, t, r) {
48
+ u(e, t);
49
+ let a = i.add(e, t, s(r));
41
50
  try {
42
51
  n().addEventListener(e, t, a);
43
52
  } catch (e) {
44
53
  throw i.release(a), e;
45
54
  }
46
55
  }
47
- function s(e, t) {
56
+ function u(e, t) {
48
57
  let r = i.idFor(e, t);
49
58
  r !== void 0 && (n().removeEventListener(e, t, r), i.release(r));
50
59
  }
51
- function c(e) {
60
+ function d(e) {
52
61
  n().focusNode(e);
53
62
  }
54
- function l(e) {
63
+ function f(e) {
55
64
  n().blurNode(e);
56
65
  }
57
66
  //#endregion
58
67
  //#region src/tree.mts
59
- function u() {
68
+ function p() {
60
69
  return n().rootNodeId();
61
70
  }
62
- function d(e) {
71
+ function m(e) {
63
72
  return n().createNode(e);
64
73
  }
65
- function f(e, t) {
74
+ function h(e, t) {
66
75
  n().appendChild(e, t);
67
76
  }
68
- function p(e, t, r) {
77
+ function g(e, t, r) {
69
78
  n().insertBefore(e, t, r);
70
79
  }
71
- function m(e, t) {
80
+ function _(e, t) {
72
81
  n().removeChild(e, t);
73
82
  }
74
- function h(e) {
75
- a(n().destroyNode(e));
83
+ function v(e) {
84
+ c(n().destroyNode(e));
76
85
  }
77
- function g(e, t, r) {
86
+ function y(e, t, r) {
78
87
  n().setAttribute(e, t, r);
79
88
  }
80
- function _(e, t, r) {
89
+ function b(e, t, r) {
81
90
  n().setStyle(e, t, r);
82
91
  }
83
- function v(e, t) {
92
+ function x(e, t) {
84
93
  n().removeStyle(e, t);
85
94
  }
86
95
  //#endregion
87
96
  //#region src/rendererCore.mts
88
- var y = /* @__PURE__ */ t({
89
- appendChild: () => f,
90
- blur: () => l,
91
- createNode: () => d,
92
- destroyNode: () => h,
93
- focus: () => c,
94
- insertBefore: () => p,
95
- removeChild: () => m,
96
- removeEventListener: () => s,
97
- removeStyle: () => v,
98
- rootNodeId: () => u,
99
- setAttribute: () => g,
100
- setEventListener: () => o,
101
- setStyle: () => _
97
+ var S = /* @__PURE__ */ t({
98
+ appendChild: () => h,
99
+ blur: () => f,
100
+ createNode: () => m,
101
+ destroyNode: () => v,
102
+ focus: () => d,
103
+ insertBefore: () => g,
104
+ latestEventId: () => o,
105
+ removeChild: () => _,
106
+ removeEventListener: () => u,
107
+ removeStyle: () => x,
108
+ rootNodeId: () => p,
109
+ setAttribute: () => y,
110
+ setEventListener: () => l,
111
+ setStyle: () => b
102
112
  });
103
113
  //#endregion
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 };
114
+ export { g as a, p as c, f as d, d as f, l as h, v as i, y as l, u as m, h as n, _ as o, o as p, m as r, x as s, S as t, b as u };
package/dist/events.d.mts CHANGED
@@ -1,4 +1,10 @@
1
1
  import { CallbackId, EventListener, NodeId } from './types.mts';
2
+ /**
3
+ * @returns the `eventId` of the newest event any registered listener has
4
+ * received, or 0 before the first. Ids grow with each input event, and every
5
+ * node dispatch of one event carries the same id.
6
+ */
7
+ export declare function latestEventId(): number;
2
8
  /**
3
9
  * Drops the JS half of every registration in `callbackIds`. The native half
4
10
  * is already gone by the time this runs — `destroyNode` takes both.
@@ -1,4 +1,4 @@
1
- export { setEventListener, removeEventListener, focus, blur } from './events.mts';
1
+ export { setEventListener, removeEventListener, latestEventId, focus, blur } from './events.mts';
2
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
@@ -1,2 +1,2 @@
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 };
1
+ import { a as e, c as t, d as n, f as r, h as i, i as a, l as o, m as s, n as c, o as l, p as u, r as d, s as f, u as p } from "./chunks/rendererCore-CIXQ3Bp7.js";
2
+ export { c as appendChild, n as blur, d as createNode, a as destroyNode, r as focus, e as insertBefore, u as latestEventId, l as removeChild, s as removeEventListener, f as removeStyle, t as rootNodeId, o as setAttribute, i as setEventListener, p as setStyle };
package/dist/types.d.mts CHANGED
@@ -105,12 +105,17 @@ export interface StyleProps {
105
105
  max_height?: number | "auto";
106
106
  }
107
107
  /**
108
- * Signature of a callback registered via `setEventListener`. The
109
- * native host calls it with one argument, an object with `type` (the
110
- * event's name), `target`/`currentTarget` (both the {@link NodeId} it fired
111
- * on), `stopPropagation`/`stopImmediatePropagation`/`preventDefault`
112
- * methods, plus whatever fields that event kind carries — see
113
- * https://incajs.tom96da.com/reference/events for the full list of
114
- * wired event names and their fields.
108
+ * Signature of a callback registered via `setEventListener`.
109
+ *
110
+ * The native host calls it with one argument, an object with:
111
+ * - `type`: the event's name.
112
+ * - `target` and `currentTarget`: both the {@link NodeId} the event fired on.
113
+ * - `eventId`: a number that grows with each event and is the same on every
114
+ * node that event reaches.
115
+ * - `stopPropagation()`, `stopImmediatePropagation()` and `preventDefault()`.
116
+ * - the fields that event kind carries.
117
+ *
118
+ * See https://incajs.tom96da.com/reference/events for the full list of wired
119
+ * event names and their fields.
115
120
  */
116
121
  export type EventListener = (...args: unknown[]) => void;
@@ -3,33 +3,51 @@ import { IncaCore } from '../rendererCore.mts';
3
3
  import { IncaElement } from './nodeOps.mts';
4
4
  /**
5
5
  * {@link RendererOptions.patchProp} — applies one changed `v-bind`/
6
- * attribute/event prop to a host element:
6
+ * attribute/event prop to a host element.
7
7
  *
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.
13
- * - An `onXxx` key registers `nextValue` as a listener for `xxx`, taking a
14
- * function or an array of them, and unbinds that key's listener for
15
- * anything else. Each distinct key (`onClick`, `onClickOnce`) is its own
16
- * listener; they run in the order first registered, a re-patch keeps its
17
- * place, and the host sees one registration per element and event. A
18
- * `.once` listener that has fired stays spent until its key is removed.
19
- * `stopImmediatePropagation()` stops the listeners after it. A
20
- * trailing `Once`/`Passive`/`Capture` suffix (from Vue's `.once`/
21
- * `.passive`/`.capture` modifiers) is stripped first; `.once` really
22
- * removes the listener after it fires once, while `.passive`/`.capture`
23
- * bind as an ordinary listener with no native passive/capture-phase
24
- * support yet. See {@link EventListener} for which event names are wired
25
- * to real input by the native host today; other names are accepted but
26
- * never fire. An error a handler throws synchronously goes to the app's
27
- * `errorHandler` and `onErrorCaptured` hooks; with no `errorHandler` it is
28
- * also rethrown to the host's error report.
29
- * - Everything else falls through to `core.setAttribute`, again skipping
30
- * a non-string/number/boolean value rather than passing it through.
8
+ * ### `style`
9
+ *
10
+ * An object (per `:style="{...}"`) is diffed against the entries already
11
+ * sent for this element.
12
+ * - `core.setStyle` runs for each entry that is new or changed.
13
+ * - `core.removeStyle` runs for each sent entry that is now absent, `null`,
14
+ * or not a string/number.
15
+ * - A string or `null` `style` removes every entry.
16
+ *
17
+ * ### `onXxx`
18
+ *
19
+ * The key registers `nextValue` as a listener for `xxx`, taking a function
20
+ * or an array of them, and unbinds that key's listener for anything else.
21
+ * - Order: each distinct key (`onClick`, `onClickOnce`) is its own listener.
22
+ * They run in the order first registered, a re-patch keeps its place, and
23
+ * the host sees one registration per element and event.
24
+ * - Propagation: `stopImmediatePropagation()` stops the listeners after it.
25
+ * - Timing: a listener attached while an event is being handled first runs
26
+ * for the next event; events are told apart by the `eventId` the host puts
27
+ * on each one.
28
+ * - Modifiers: a trailing `Once`/`Passive`/`Capture` suffix (from Vue's
29
+ * `.once`/`.passive`/`.capture` modifiers) is stripped first. `.once`
30
+ * really removes the listener after it fires once, and a listener that has
31
+ * fired stays spent until its key is removed. `.passive`/`.capture` bind
32
+ * as an ordinary listener with no native passive/capture-phase support
33
+ * yet.
34
+ * - Event names: see {@link EventListener} for which names are wired to real
35
+ * input by the native host today; other names are accepted but never fire.
36
+ * - Errors: an error a handler throws, or a rejection of an async handler,
37
+ * goes to the `onErrorCaptured` hooks and the app's `errorHandler`. Every
38
+ * handler of an event runs even when an earlier one fails, until one calls
39
+ * `stopImmediatePropagation()`. An error that no hook or `errorHandler`
40
+ * takes is logged to the console in a production build, or raised to the
41
+ * host's error report when `throwUnhandledErrorInProduction` is set. A
42
+ * development build warns and raises it to the host's error report, once
43
+ * per failing handler.
44
+ *
45
+ * ### Other props
46
+ *
47
+ * Everything else falls through to `core.setAttribute`, again skipping a
48
+ * non-string/number/boolean value rather than passing it through. Removing
49
+ * any other prop (a `null`/`undefined` `nextValue`) leaves it as-is.
31
50
  *
32
- * Removing any other prop (a `null`/`undefined` `nextValue`) leaves it as-is.
33
51
  * @param core - the incajs bindings to drive the native tree through
34
52
  */
35
53
  export declare function createPatchProp(core: IncaCore): RendererOptions<unknown, IncaElement>["patchProp"];
package/dist/vue.js CHANGED
@@ -1,4 +1,4 @@
1
- import { c as e, d as t, f as n, t as r } from "./chunks/rendererCore-BmtunkdP.js";
1
+ import { c as e, d as t, f as n, t as r } from "./chunks/rendererCore-CIXQ3Bp7.js";
2
2
  import { ErrorCodes as i, callWithAsyncErrorHandling as a, createRenderer as o } from "@vue/runtime-core";
3
3
  //#region src/vue/nodeOps.mts
4
4
  function s(e) {
@@ -95,27 +95,11 @@ function p(e, t, n) {
95
95
  for (let n of i.keys()) d(r[n]) || (e.removeStyle(t.id, n), i.delete(n));
96
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));
97
97
  }
98
- var m = (e) => e != null && typeof e.then == "function";
99
- function h(e, t) {
100
- let n = (Array.isArray(e) ? e : [e]).filter((e) => typeof e == "function");
101
- return n.length === 0 ? null : (...e) => {
102
- let r;
103
- if (g(e, (o) => {
104
- let s = n.map((e) => (...n) => {
105
- if (!o()) try {
106
- let r = e(...n);
107
- return process.env.NODE_ENV === "production" && m(r) && r.then(void 0, (e) => {
108
- if (!t?.appContext.config.errorHandler) throw e;
109
- }), r;
110
- } catch (e) {
111
- throw r ??= { error: e }, e;
112
- }
113
- });
114
- a(s, t, i.NATIVE_EVENT_HANDLER, e);
115
- }), r && !t?.appContext.config.errorHandler) throw r.error;
116
- };
98
+ function m(e) {
99
+ let t = (Array.isArray(e) ? e : [e]).filter((e) => typeof e == "function");
100
+ return t.length === 0 ? null : t;
117
101
  }
118
- function g(e, t) {
102
+ function h(e, t) {
119
103
  let n = e[0];
120
104
  if (typeof n != "object" || !n) return t(() => !1);
121
105
  let r = n.stopImmediatePropagation;
@@ -132,76 +116,83 @@ function g(e, t) {
132
116
  i ? n.stopImmediatePropagation = r : delete n.stopImmediatePropagation;
133
117
  }
134
118
  }
135
- var _ = /* @__PURE__ */ new WeakMap();
136
- function v(e, t, n, r) {
119
+ var g = /* @__PURE__ */ new WeakMap();
120
+ function _(e, t, n, r) {
137
121
  let i = Array.from(r.slots.values()).some((e) => !e.fired);
138
- i && !r.registered ? (e.setEventListener(t.id, n, r.dispatcher), r.registered = !0) : !i && r.registered && (r.registered = !1, e.removeEventListener(t.id, n)), r.slots.size === 0 && _.get(t)?.delete(n);
122
+ i && !r.registered ? (e.setEventListener(t.id, n, r.dispatcher), r.registered = !0) : !i && r.registered && (r.registered = !1, e.removeEventListener(t.id, n)), r.slots.size === 0 && g.get(t)?.delete(n);
139
123
  }
140
- function y(e, t, n) {
124
+ function v(e, t, n) {
141
125
  let r = {
142
126
  slots: /* @__PURE__ */ new Map(),
143
127
  registered: !1,
144
- dispatcher: (...i) => {
145
- let a;
146
- if (g(i, (o) => {
147
- for (let s of Array.from(r.slots.keys())) {
148
- if (o()) break;
149
- let c = r.slots.get(s);
150
- if (c && !c.fired) {
151
- c.once && (c.fired = !0, v(e, t, n, r));
152
- try {
153
- c.listener(...i);
154
- } catch (e) {
155
- a ??= { error: e };
128
+ dispatcher: (...o) => {
129
+ let s = [], c = o[0]?.eventId;
130
+ h(o, (l) => {
131
+ for (let u of Array.from(r.slots.keys())) {
132
+ if (l()) break;
133
+ let d = r.slots.get(u);
134
+ if (d && !d.fired && !(typeof c == "number" && d.attachedAt >= c)) {
135
+ d.once && (d.fired = !0, _(e, t, n, r));
136
+ for (let e of d.handlers) {
137
+ if (l()) break;
138
+ try {
139
+ a(e, d.instance, i.NATIVE_EVENT_HANDLER, o);
140
+ } catch (e) {
141
+ s.push(e);
142
+ }
156
143
  }
157
144
  }
158
145
  }
159
- }), a) throw a.error;
146
+ });
147
+ for (let e of s.slice(1)) Promise.reject(e);
148
+ if (s.length > 0) throw s[0];
160
149
  }
161
150
  };
162
151
  return r;
163
152
  }
164
- function b(e, t, n, r) {
165
- let i = _.get(t)?.get(n);
166
- i?.slots.delete(r) && v(e, t, n, i);
153
+ function y(e, t, n, r) {
154
+ let i = g.get(t)?.get(n);
155
+ i?.slots.delete(r) && _(e, t, n, i);
167
156
  }
168
- function x(e, t, n, r, i) {
169
- let { event: a, once: o } = u(n), s = h(r, i);
157
+ function b(e, t, n, r, i) {
158
+ let { event: a, once: o } = u(n), s = m(r);
170
159
  if (!s) {
171
- b(e, t, a, n);
160
+ y(e, t, a, n);
172
161
  return;
173
162
  }
174
- let c = _.get(t);
175
- c || _.set(t, c = /* @__PURE__ */ new Map());
163
+ let c = g.get(t);
164
+ c || g.set(t, c = /* @__PURE__ */ new Map());
176
165
  let l = c.get(a);
177
- l || c.set(a, l = y(e, t, a));
166
+ l || c.set(a, l = v(e, t, a));
178
167
  let d = l.slots.get(n);
179
168
  if (d) {
180
- d.listener = s;
169
+ d.handlers = s, d.instance = i;
181
170
  return;
182
171
  }
183
172
  l.slots.set(n, {
184
- listener: s,
173
+ attachedAt: e.latestEventId(),
174
+ handlers: s,
175
+ instance: i,
185
176
  once: o,
186
177
  fired: !1
187
178
  });
188
179
  try {
189
- v(e, t, a, l);
180
+ _(e, t, a, l);
190
181
  } catch (e) {
191
182
  throw l.slots.delete(n), l.slots.size === 0 && c.delete(a), e;
192
183
  }
193
184
  }
194
- function S(e) {
185
+ function x(e) {
195
186
  return (t, n, r, i, a, o) => {
196
- n === "style" ? p(e, t, i) : c(n) ? x(e, t, n, i, o ?? null) : (typeof i == "string" || typeof i == "number" || typeof i == "boolean") && e.setAttribute(t.id, n, i);
187
+ n === "style" ? p(e, t, i) : c(n) ? b(e, t, n, i, o ?? null) : (typeof i == "string" || typeof i == "number" || typeof i == "boolean") && e.setAttribute(t.id, n, i);
197
188
  };
198
189
  }
199
190
  //#endregion
200
191
  //#region src/vue/createApp.mts
201
- function C(i, a) {
192
+ function S(i, a) {
202
193
  let c = o({
203
194
  ...s(r),
204
- patchProp: S(r)
195
+ patchProp: x(r)
205
196
  }).createApp(i, a), l = c.mount.bind(c);
206
197
  function u() {
207
198
  let r = e();
@@ -217,4 +208,4 @@ function C(i, a) {
217
208
  return Object.assign(c, { mount: (e) => l(e ?? u()) });
218
209
  }
219
210
  //#endregion
220
- export { C as createIncaApp };
211
+ export { S as createIncaApp };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "incajs",
3
- "version": "0.0.9",
3
+ "version": "0.0.10",
4
4
  "description": "A GPU-native, Webview-free desktop app framework built on GPUI and QuickJS.",
5
5
  "keywords": [
6
6
  "cross-platform",
@@ -60,7 +60,7 @@
60
60
  }
61
61
  },
62
62
  "engines": {
63
- "node": ">=22"
63
+ "node": ">=22.18"
64
64
  },
65
65
  "scripts": {
66
66
  "build": "vite build",