incajs 0.0.5 → 0.0.6

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.
package/README.md CHANGED
@@ -8,15 +8,18 @@ SPDX-License-Identifier: MIT OR Apache-2.0
8
8
  **Incarnative.js** — a GPU-native, Webview-free desktop application
9
9
  framework. No Chromium, no DOM: UI renders directly on the GPU via
10
10
  [GPUI](https://www.gpui.rs/), driven by an embedded QuickJS runtime
11
- ([`rquickjs`](https://github.com/DelSkayn/rquickjs)) with sub-second
12
- startup.
11
+ ([`rquickjs`](https://github.com/DelSkayn/rquickjs)).
13
12
 
14
13
  ## How it works
15
14
 
16
- - `incajs` is a thin, typed wrapper around the native host bridge
17
- - Vue 3 support is a custom renderer mapping Vue's `createRenderer`
18
- lifecycle onto those calls
15
+ - The root `incajs` export is types only.
16
+ - `incajs/vue` is a custom renderer mapping Vue 3's `createRenderer`
17
+ lifecycle onto the native host bridge. `createIncaApp(rootComponent,
18
+ rootProps?)` creates a Vue app whose root mounts against the host's
19
+ own root container instead of a DOM element; `app.mount()` with no
20
+ argument targets it, and `app.unmount`, `app.use`, etc. behave exactly
21
+ as `@vue/runtime-core` documents them.
19
22
  - `@vue/runtime-core` is an optional peer dependency, needed only when
20
- you use it
23
+ you use `incajs/vue`.
21
24
 
22
25
  Part of [tom96da/incajs](https://github.com/tom96da/incajs).
package/dist/events.d.mts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { CallbackId, EventListener, NodeId } from './types.mts';
2
2
  /**
3
3
  * Drops the JS half of every registration in `callbackIds`. The native half
4
- * is already gone by the time this runs — {@link destroyNode} takes both.
4
+ * is already gone by the time this runs — `destroyNode` takes both.
5
5
  * @param callbackIds - ids the host reported as released
6
6
  * @internal
7
7
  */
@@ -1,8 +1,8 @@
1
1
  export { setEventListener, removeEventListener, focus, blur } from './events.mts';
2
2
  export { appendChild, createNode, destroyNode, insertBefore, removeChild, rootNodeId, setAttribute, setStyle, } from './tree.mts';
3
3
  /**
4
- * The subset of `incajs`'s own API a custom renderer (`incajs/vue`, and any
5
- * future framework adapter alongside it) drives the native tree through.
4
+ * The tree/event primitives a custom renderer (`incajs/vue`) drives the
5
+ * native tree through.
6
6
  *
7
7
  * Also the seam a renderer's own tests mock against, in place of a real
8
8
  * `globalThis.__inca_native__`.
package/dist/types.d.mts CHANGED
@@ -1,11 +1,21 @@
1
- /** Stable handle to a node in the native retained tree, returned by {@link createNode} and used in every later call that touches that node. */
1
+ /**
2
+ * Stable handle to a node in the native retained tree, returned by `createNode`
3
+ * and used in every later call that touches that node.
4
+ */
2
5
  export type NodeId = number;
3
- /** Id assigned to one registered event listener. Managed internally by {@link setEventListener}/{@link removeEventListener}/{@link destroyNode} — callers never see or pass one directly. */
6
+ /**
7
+ * Id assigned to one registered event listener. Managed internally by
8
+ * `setEventListener`/`removeEventListener`/`destroyNode` — callers never see or
9
+ * pass one directly.
10
+ */
4
11
  export type CallbackId = number;
5
- /** A value {@link setAttribute}/{@link setStyle} can take. Anything else raises a catchable exception rather than being silently coerced. */
12
+ /**
13
+ * A value `setAttribute`/`setStyle` can take. Anything else raises a catchable
14
+ * exception rather than being silently coerced.
15
+ */
6
16
  export type AttributeValue = string | number | boolean;
7
17
  /**
8
- * Element kind passed to {@link createNode}. `"text"` is the only tag with
18
+ * Element kind passed to `createNode`. `"text"` is the only tag with
9
19
  * dedicated rendering behavior — a leaf that renders its `"value"`
10
20
  * attribute's string content. Any other string is a generic styled
11
21
  * container; the `string & {}` half of this type keeps `"text"`'s
@@ -13,7 +23,7 @@ export type AttributeValue = string | number | boolean;
13
23
  */
14
24
  export type TagName = "text" | (string & {});
15
25
  /**
16
- * Style properties recognized by {@link setStyle}'s typed overload. A
26
+ * Style properties recognized by `setStyle`'s typed overload. A
17
27
  * deliberately incomplete, v1 layout/paint vocabulary — an unrecognized key
18
28
  * or a value shape that doesn't parse (e.g. a malformed enum string) is
19
29
  * ignored by the renderer rather than applied or thrown.
@@ -47,7 +57,7 @@ export interface StyleProps {
47
57
  text_size?: number;
48
58
  }
49
59
  /**
50
- * Signature of a callback registered via {@link setEventListener}. The
60
+ * Signature of a callback registered via `setEventListener`. The
51
61
  * native host calls it with one argument, an object with `type` (the
52
62
  * event's name), `target`/`currentTarget` (both the {@link NodeId} it fired
53
63
  * on), `stopPropagation`/`stopImmediatePropagation`/`preventDefault`
@@ -40,7 +40,10 @@ export interface IncaText {
40
40
  readonly kind: "text";
41
41
  /** The current parent, or `null` if this node isn't attached to the tree. */
42
42
  parent: IncaElement | null;
43
- /** The text content, mirroring what's been pushed to the native node via {@link setAttribute}. */
43
+ /**
44
+ * The text content, mirroring what's been pushed to the native node via
45
+ * {@link IncaCore.setAttribute}.
46
+ */
44
47
  text: string;
45
48
  }
46
49
  /** Any host node {@link NodeOps} can produce: an element, comment, or text leaf. */
@@ -49,9 +52,9 @@ export type IncaNode = IncaElement | IncaText;
49
52
  export type NodeOps = Omit<RendererOptions<IncaNode, IncaElement>, "patchProp">;
50
53
  /**
51
54
  * `@vue/runtime-core`'s {@link RendererOptions}`<IncaNode, IncaElement>`,
52
- * minus `patchProp` (see `./patchProp.mts`) — the host-node lifecycle half
53
- * of `incajs/vue`'s custom renderer, built entirely on the injected
54
- * {@link IncaCore}, never on the native bridge directly.
55
+ * minus `patchProp` — the host-node lifecycle half of `incajs/vue`'s custom
56
+ * renderer, built entirely on the injected {@link IncaCore}, never on the
57
+ * native bridge directly.
55
58
  * @param core - the incajs bindings to drive the native tree through
56
59
  */
57
60
  export declare function createNodeOps(core: IncaCore): NodeOps;
@@ -9,9 +9,14 @@ import { IncaElement } from './nodeOps.mts';
9
9
  * `core.setStyle` call per entry; an entry whose value isn't a
10
10
  * string/number is skipped.
11
11
  * - An `onXxx` key registers `nextValue` as the listener for `xxx`, taking a
12
- * function or an array of them, and unbinds `xxx` for anything else — see
13
- * {@link EventListener} for which event names are wired to real input by
14
- * the native host today; other names are accepted but never fire.
12
+ * function or an array of them, and unbinds `xxx` for anything else. A
13
+ * trailing `Once`/`Passive`/`Capture` suffix (from Vue's `.once`/
14
+ * `.passive`/`.capture` modifiers) is stripped first; `.once` really
15
+ * removes the listener after it fires once, while `.passive`/`.capture`
16
+ * bind as an ordinary listener with no native passive/capture-phase
17
+ * support yet. See {@link EventListener} for which event names are wired
18
+ * to real input by the native host today; other names are accepted but
19
+ * never fire.
15
20
  * - Everything else falls through to `core.setAttribute`, again skipping
16
21
  * a non-string/number/boolean value rather than passing it through.
17
22
  *
package/dist/vue.js CHANGED
@@ -78,11 +78,19 @@ function a(e) {
78
78
  }
79
79
  //#endregion
80
80
  //#region src/vue/patchProp.mts
81
- var o = (e) => /^on[A-Z]/.test(e);
82
- function s(e, t, n) {
81
+ var o = (e) => /^on[A-Z]/.test(e), s = /(?:Once|Passive|Capture)$/;
82
+ function c(e) {
83
+ 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
+ return {
86
+ event: t.slice(2).toLowerCase(),
87
+ once: n
88
+ };
89
+ }
90
+ function l(e, t, n) {
83
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);
84
92
  }
85
- function c(e) {
93
+ function u(e) {
86
94
  if (typeof e == "function") return e;
87
95
  if (!Array.isArray(e)) return null;
88
96
  let t = e.filter((e) => typeof e == "function");
@@ -90,23 +98,33 @@ function c(e) {
90
98
  for (let n of t) n(...e);
91
99
  };
92
100
  }
93
- function l(e, t, n, r) {
94
- let i = n.slice(2).toLowerCase(), a = c(r);
95
- a ? e.setEventListener(t.id, i, a) : e.removeEventListener(t.id, i);
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);
105
+ return;
106
+ }
107
+ if (!a) {
108
+ e.setEventListener(t.id, i, o);
109
+ return;
110
+ }
111
+ e.setEventListener(t.id, i, (...n) => {
112
+ e.removeEventListener(t.id, i), o(...n);
113
+ });
96
114
  }
97
- function u(e) {
115
+ function f(e) {
98
116
  return (t, n, r, i) => {
99
- n === "style" ? s(e, t, i) : o(n) ? l(e, t, n, i) : (typeof i == "string" || typeof i == "number" || typeof i == "boolean") && e.setAttribute(t.id, n, 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);
100
118
  };
101
119
  }
102
120
  //#endregion
103
121
  //#region src/vue/createApp.mts
104
- function d(o, s) {
122
+ function p(o, s) {
105
123
  let c = i({
106
124
  ...a(n),
107
- patchProp: u(n)
125
+ patchProp: f(n)
108
126
  }).createApp(o, s), l = c.mount.bind(c);
109
- function d() {
127
+ function u() {
110
128
  let n = t();
111
129
  return {
112
130
  id: n,
@@ -117,7 +135,7 @@ function d(o, s) {
117
135
  blur: () => r()
118
136
  };
119
137
  }
120
- return Object.assign(c, { mount: (e) => l(e ?? d()) });
138
+ return Object.assign(c, { mount: (e) => l(e ?? u()) });
121
139
  }
122
140
  //#endregion
123
- export { d as createIncaApp };
141
+ export { p as createIncaApp };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "incajs",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "description": "A GPU-native, Webview-free desktop app framework built on GPUI and QuickJS.",
5
5
  "keywords": [
6
6
  "cross-platform",