incajs 0.0.8 → 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
@@ -7,4 +7,4 @@ export { appendChild, createNode, destroyNode, insertBefore, removeChild, rootNo
7
7
  * Also the seam a renderer's own tests mock against, in place of a real
8
8
  * `globalThis.__inca_native__`.
9
9
  */
10
- export type IncaCore = typeof import("./rendererCore.mts");
10
+ export type IncaCore = typeof import('./rendererCore.mts');
@@ -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://tom96da.github.io/incajs/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,28 +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 the listener for `xxx`, taking a
14
- * function or an array of them, and unbinds `xxx` for anything else. A
15
- * trailing `Once`/`Passive`/`Capture` suffix (from Vue's `.once`/
16
- * `.passive`/`.capture` modifiers) is stripped first; `.once` really
17
- * removes the listener after it fires once, while `.passive`/`.capture`
18
- * bind as an ordinary listener with no native passive/capture-phase
19
- * support yet. See {@link EventListener} for which event names are wired
20
- * to real input by the native host today; other names are accepted but
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.
24
- * - Everything else falls through to `core.setAttribute`, again skipping
25
- * 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.
26
50
  *
27
- * Removing any other prop (a `null`/`undefined` `nextValue`) leaves it as-is.
28
51
  * @param core - the incajs bindings to drive the native tree through
29
52
  */
30
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,54 +95,104 @@ 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 = (() => {
98
+ function m(e) {
99
+ let t = (Array.isArray(e) ? e : [e]).filter((e) => typeof e == "function");
100
+ return t.length === 0 ? null : t;
101
+ }
102
+ function h(e, t) {
103
+ let n = e[0];
104
+ if (typeof n != "object" || !n) return t(() => !1);
105
+ let r = n.stopImmediatePropagation;
106
+ if (typeof r != "function") return t(() => !1);
107
+ let i = Object.hasOwn(n, "stopImmediatePropagation"), a = !1;
99
108
  try {
100
- return process.env.NODE_ENV === "production";
109
+ n.stopImmediatePropagation = (...e) => (a = !0, r.apply(n, e));
101
110
  } catch {
102
- return !1;
111
+ return t(() => !1);
112
+ }
113
+ try {
114
+ t(() => a);
115
+ } finally {
116
+ i ? n.stopImmediatePropagation = r : delete n.stopImmediatePropagation;
103
117
  }
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;
118
+ }
119
+ var g = /* @__PURE__ */ new WeakMap();
120
+ function _(e, t, n, r) {
121
+ let i = Array.from(r.slots.values()).some((e) => !e.fired);
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);
123
+ }
124
+ function v(e, t, n) {
125
+ let r = {
126
+ slots: /* @__PURE__ */ new Map(),
127
+ registered: !1,
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
+ }
143
+ }
144
+ }
145
+ }
146
+ });
147
+ for (let e of s.slice(1)) Promise.reject(e);
148
+ if (s.length > 0) throw s[0];
149
+ }
119
150
  };
151
+ return r;
152
+ }
153
+ function y(e, t, n, r) {
154
+ let i = g.get(t)?.get(n);
155
+ i?.slots.delete(r) && _(e, t, n, i);
120
156
  }
121
- function _(e, t, n, r, i) {
122
- let { event: a, once: o } = u(n), s = g(r, i);
157
+ function b(e, t, n, r, i) {
158
+ let { event: a, once: o } = u(n), s = m(r);
123
159
  if (!s) {
124
- e.removeEventListener(t.id, a);
160
+ y(e, t, a, n);
125
161
  return;
126
162
  }
127
- if (!o) {
128
- e.setEventListener(t.id, a, s);
163
+ let c = g.get(t);
164
+ c || g.set(t, c = /* @__PURE__ */ new Map());
165
+ let l = c.get(a);
166
+ l || c.set(a, l = v(e, t, a));
167
+ let d = l.slots.get(n);
168
+ if (d) {
169
+ d.handlers = s, d.instance = i;
129
170
  return;
130
171
  }
131
- e.setEventListener(t.id, a, (...n) => {
132
- e.removeEventListener(t.id, a), s(...n);
172
+ l.slots.set(n, {
173
+ attachedAt: e.latestEventId(),
174
+ handlers: s,
175
+ instance: i,
176
+ once: o,
177
+ fired: !1
133
178
  });
179
+ try {
180
+ _(e, t, a, l);
181
+ } catch (e) {
182
+ throw l.slots.delete(n), l.slots.size === 0 && c.delete(a), e;
183
+ }
134
184
  }
135
- function v(e) {
185
+ function x(e) {
136
186
  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);
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);
138
188
  };
139
189
  }
140
190
  //#endregion
141
191
  //#region src/vue/createApp.mts
142
- function y(i, a) {
192
+ function S(i, a) {
143
193
  let c = o({
144
194
  ...s(r),
145
- patchProp: v(r)
195
+ patchProp: x(r)
146
196
  }).createApp(i, a), l = c.mount.bind(c);
147
197
  function u() {
148
198
  let r = e();
@@ -158,4 +208,4 @@ function y(i, a) {
158
208
  return Object.assign(c, { mount: (e) => l(e ?? u()) });
159
209
  }
160
210
  //#endregion
161
- export { y 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.8",
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",
@@ -19,7 +19,7 @@
19
19
  "vue3",
20
20
  "webview-free"
21
21
  ],
22
- "homepage": "https://tom96da.github.io/incajs/",
22
+ "homepage": "https://incajs.tom96da.com/",
23
23
  "license": "(MIT OR Apache-2.0)",
24
24
  "repository": {
25
25
  "type": "git",
@@ -48,8 +48,8 @@
48
48
  },
49
49
  "devDependencies": {
50
50
  "@vue/runtime-core": "^3.5.43",
51
- "oxfmt": "^0.68.0",
52
- "oxlint": "^1.83.0"
51
+ "oxfmt": "^0.71.0",
52
+ "oxlint": "^1.86.0"
53
53
  },
54
54
  "peerDependencies": {
55
55
  "@vue/runtime-core": "^3.5.43"
@@ -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",