incajs 0.0.4 → 0.0.5

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
@@ -11,19 +11,12 @@ framework. No Chromium, no DOM: UI renders directly on the GPU via
11
11
  ([`rquickjs`](https://github.com/DelSkayn/rquickjs)) with sub-second
12
12
  startup.
13
13
 
14
- ## Features
15
-
16
- - Framework-agnostic core, with first-class Vue 3 support via the
17
- `incajs/vue` subpath (`@vue/runtime-core` is an optional peer
18
- dependency — only needed if you import `incajs/vue`)
19
- - Direct GPU rendering — no Chromium, no DOM
20
- - Embedded QuickJS runtime for sub-second startup and a minimal memory
21
- footprint
22
-
23
14
  ## How it works
24
15
 
25
- `incajs` is a thin, typed wrapper around the native host bridge.
26
- `incajs/vue` is a custom renderer mapping Vue's `createRenderer`
27
- lifecycle onto those calls.
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
19
+ - `@vue/runtime-core` is an optional peer dependency, needed only when
20
+ you use it
28
21
 
29
22
  Part of [tom96da/incajs](https://github.com/tom96da/incajs).
@@ -75,7 +75,7 @@ function _(e, t, r) {
75
75
  n().setStyle(e, t, r);
76
76
  }
77
77
  //#endregion
78
- //#region src/index.mts
78
+ //#region src/rendererCore.mts
79
79
  var v = /* @__PURE__ */ t({
80
80
  appendChild: () => f,
81
81
  blur: () => l,
package/dist/events.d.mts CHANGED
@@ -12,10 +12,9 @@ export declare function releaseCallbacks(callbackIds: readonly CallbackId[]): vo
12
12
  *
13
13
  * The host holds a list per `(nodeId, event)` and dispatches to all of it;
14
14
  * this wrapper keeps one, the way a framework adapter composes its own
15
- * handlers into a single callback. `"click"`/`"mousedown"`/`"mouseup"`/
16
- * `"mousemove"`/`"wheel"`/`"mouseenter"`/`"mouseleave"`/`"focus"`/`"blur"`
17
- * are wired to real native input today; other event names are accepted but
18
- * never fire.
15
+ * handlers into a single callback. See {@link EventListener} for which
16
+ * event names are wired to real native input today; other names are
17
+ * accepted but never fire.
19
18
  * @param nodeId - the node to listen on
20
19
  * @param event - the event name (e.g. `"click"`)
21
20
  * @param listener - called when the event fires
package/dist/index.d.mts CHANGED
@@ -1,3 +1 @@
1
- export { blur, focus, removeEventListener, setEventListener } from './events.mts';
2
- export { appendChild, createNode, destroyNode, insertBefore, removeChild, rootNodeId, setAttribute, setStyle, } from './tree.mts';
3
1
  export type { AttributeValue, CallbackId, EventListener, NodeId, StyleProps, TagName, } from './types.mts';
package/dist/index.js CHANGED
@@ -1,2 +0,0 @@
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/src-SeArA65c.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,10 +1,10 @@
1
+ export { setEventListener, removeEventListener, focus, blur } from './events.mts';
2
+ export { appendChild, createNode, destroyNode, insertBefore, removeChild, rootNodeId, setAttribute, setStyle, } from './tree.mts';
1
3
  /**
2
4
  * The subset of `incajs`'s own API a custom renderer (`incajs/vue`, and any
3
- * future framework adapter alongside it) drives the native tree through —
4
- * derived from `index.mts`'s real exports, so this contract can't drift out
5
- * of sync with them.
5
+ * future framework adapter alongside it) drives the 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__`.
9
9
  */
10
- export type IncaCore = Pick<typeof import("./index.mts"), "rootNodeId" | "createNode" | "appendChild" | "insertBefore" | "removeChild" | "destroyNode" | "setAttribute" | "setStyle" | "setEventListener" | "removeEventListener">;
10
+ export type IncaCore = typeof import("./rendererCore.mts");
@@ -0,0 +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 };
package/dist/types.d.mts CHANGED
@@ -51,21 +51,8 @@ export interface StyleProps {
51
51
  * native host calls it with one argument, an object with `type` (the
52
52
  * event's name), `target`/`currentTarget` (both the {@link NodeId} it fired
53
53
  * on), `stopPropagation`/`stopImmediatePropagation`/`preventDefault`
54
- * methods, plus whatever fields that event kind carries.
55
- *
56
- * `"mousedown"`/`"mouseup"`/`"mousemove"`/`"mouseenter"`/`"mouseleave"`
57
- * carry `clientX`, `clientY`, `button`, `buttons`, `detail`, and
58
- * `ctrlKey`/`shiftKey`/`altKey`/`metaKey`, DOM-`MouseEvent`-named.
59
- * `"wheel"` carries those same fields plus `deltaX`/`deltaY`/`deltaZ`/
60
- * `deltaMode`, DOM-`WheelEvent`-named (`deltaMode` is `0` or `1`; `deltaZ`
61
- * is always `0`). `"keydown"`/`"keyup"` carry `key`, `repeat`, and
62
- * `ctrlKey`/`shiftKey`/`altKey`/`metaKey`, DOM-`KeyboardEvent`-named, and
63
- * fire on whichever node is currently focused, bubbling to its ancestors;
64
- * with nothing focused, neither reaches any node. `"click"`/`"focus"`/
65
- * `"blur"` carry none of their own.
66
- *
67
- * An element already under the pointer when it mounts gets a
68
- * `"mouseenter"` the first time its hover state is checked, with no
69
- * pointer movement involved.
54
+ * methods, plus whatever fields that event kind carries — see
55
+ * https://tom96da.github.io/incajs/reference/events for the full list of
56
+ * wired event names and their fields.
70
57
  */
71
58
  export type EventListener = (...args: unknown[]) => void;
@@ -3,23 +3,34 @@ import { IncaCore } from '../rendererCore.mts';
3
3
  import { NodeId } from '../types.mts';
4
4
  /**
5
5
  * A container host node: either a real element or the hidden stand-in
6
- * {@link nodeOps.createComment} uses. Also `@vue/runtime-core`'s
6
+ * {@link NodeOps.createComment} uses. Also `@vue/runtime-core`'s
7
7
  * `HostElement` — the only host node type that can act as a parent.
8
8
  *
9
9
  * `inca`'s native tree has no parent pointers and no way to list a
10
10
  * node's children, so `parent`/`children` are maintained here as a
11
- * JS-side shadow of the tree, kept in sync by {@link nodeOps.insert}/
12
- * {@link nodeOps.remove}.
11
+ * JS-side shadow of the tree, kept in sync by {@link NodeOps.insert}/
12
+ * {@link NodeOps.remove}.
13
13
  */
14
14
  export interface IncaElement {
15
- /** The underlying native node's id — the only part of this object the native tree itself knows about. */
15
+ /**
16
+ * The underlying native node's id — the only part of this object the native
17
+ * tree itself knows about.
18
+ */
16
19
  readonly id: NodeId;
17
- /** `"comment"` for the hidden stand-in {@link nodeOps.createComment} produces; `"element"` for every other container. Purely informational — both render identically once created. */
20
+ /**
21
+ * `"comment"` for the hidden stand-in {@link NodeOps.createComment}
22
+ * produces; `"element"` for every other container. Purely
23
+ * informational — both render identically once created.
24
+ */
18
25
  readonly kind: "element" | "comment";
19
26
  /** The current parent, or `null` if this node isn't attached to the tree. */
20
27
  parent: IncaElement | null;
21
28
  /** This node's children, in render order. */
22
29
  children: IncaNode[];
30
+ /** Focuses this node next frame. */
31
+ focus(): void;
32
+ /** Unfocuses whatever's focused, next frame. */
33
+ blur(): void;
23
34
  }
24
35
  /** A text leaf host node — `@vue/runtime-core`'s `HostNode` for text. */
25
36
  export interface IncaText {
@@ -32,8 +43,10 @@ export interface IncaText {
32
43
  /** The text content, mirroring what's been pushed to the native node via {@link setAttribute}. */
33
44
  text: string;
34
45
  }
35
- /** Any host node {@link nodeOps} can produce: an element, comment, or text leaf. */
46
+ /** Any host node {@link NodeOps} can produce: an element, comment, or text leaf. */
36
47
  export type IncaNode = IncaElement | IncaText;
48
+ /** {@link createNodeOps}'s return shape. */
49
+ export type NodeOps = Omit<RendererOptions<IncaNode, IncaElement>, "patchProp">;
37
50
  /**
38
51
  * `@vue/runtime-core`'s {@link RendererOptions}`<IncaNode, IncaElement>`,
39
52
  * minus `patchProp` (see `./patchProp.mts`) — the host-node lifecycle half
@@ -41,4 +54,4 @@ export type IncaNode = IncaElement | IncaText;
41
54
  * {@link IncaCore}, never on the native bridge directly.
42
55
  * @param core - the incajs bindings to drive the native tree through
43
56
  */
44
- export declare function createNodeOps(core: IncaCore): Omit<RendererOptions<IncaNode, IncaElement>, "patchProp">;
57
+ export declare function createNodeOps(core: IncaCore): NodeOps;
@@ -9,11 +9,9 @@ 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 — only
13
- * `"click"`/`"mousedown"`/`"mouseup"`/`"mousemove"`/`"wheel"`/
14
- * `"mouseenter"`/`"mouseleave"`/`"focus"`/`"blur"`/`"keydown"`/`"keyup"`
15
- * are wired to real input by the native host today, other event names
16
- * are accepted but never fire.
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.
17
15
  * - Everything else falls through to `core.setAttribute`, again skipping
18
16
  * a non-string/number/boolean value rather than passing it through.
19
17
  *
package/dist/vue.js CHANGED
@@ -1,7 +1,7 @@
1
- import { s as e, t } from "./chunks/src-SeArA65c.js";
2
- import { createRenderer as n } from "@vue/runtime-core";
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";
3
3
  //#region src/vue/nodeOps.mts
4
- function r(e) {
4
+ function a(e) {
5
5
  function t(t) {
6
6
  let n = e.createNode("text");
7
7
  return e.setAttribute(n, "value", t), {
@@ -20,13 +20,21 @@ function r(e) {
20
20
  function r(t) {
21
21
  t.parent && e.removeChild(t.parent.id, t.id), n(t);
22
22
  }
23
+ function i(t) {
24
+ return {
25
+ focus: () => e.focus(t),
26
+ blur: () => e.blur()
27
+ };
28
+ }
23
29
  return {
24
30
  createElement(t) {
31
+ let n = e.createNode(t);
25
32
  return {
26
- id: e.createNode(t),
33
+ id: n,
27
34
  kind: "element",
28
35
  parent: null,
29
- children: []
36
+ children: [],
37
+ ...i(n)
30
38
  };
31
39
  },
32
40
  createText: t,
@@ -36,7 +44,8 @@ function r(e) {
36
44
  id: n,
37
45
  kind: "comment",
38
46
  parent: null,
39
- children: []
47
+ children: [],
48
+ ...i(n)
40
49
  };
41
50
  },
42
51
  setText(t, n) {
@@ -69,11 +78,11 @@ function r(e) {
69
78
  }
70
79
  //#endregion
71
80
  //#region src/vue/patchProp.mts
72
- var i = (e) => /^on[A-Z]/.test(e);
73
- function a(e, t, n) {
81
+ var o = (e) => /^on[A-Z]/.test(e);
82
+ function s(e, t, n) {
74
83
  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);
75
84
  }
76
- function o(e) {
85
+ function c(e) {
77
86
  if (typeof e == "function") return e;
78
87
  if (!Array.isArray(e)) return null;
79
88
  let t = e.filter((e) => typeof e == "function");
@@ -81,28 +90,34 @@ function o(e) {
81
90
  for (let n of t) n(...e);
82
91
  };
83
92
  }
84
- function s(e, t, n, r) {
85
- let i = n.slice(2).toLowerCase(), a = o(r);
93
+ function l(e, t, n, r) {
94
+ let i = n.slice(2).toLowerCase(), a = c(r);
86
95
  a ? e.setEventListener(t.id, i, a) : e.removeEventListener(t.id, i);
87
96
  }
88
- function c(e) {
89
- return (t, n, r, o) => {
90
- n === "style" ? a(e, t, o) : i(n) ? s(e, t, n, o) : (typeof o == "string" || typeof o == "number" || typeof o == "boolean") && e.setAttribute(t.id, n, o);
97
+ function u(e) {
98
+ 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);
91
100
  };
92
101
  }
93
102
  //#endregion
94
103
  //#region src/vue/createApp.mts
95
- function l(i, a) {
96
- let o = n({
97
- ...r(t),
98
- patchProp: c(t)
99
- }).createApp(i, a), s = o.mount.bind(o);
100
- return Object.assign(o, { mount: (t) => s(t ?? {
101
- id: e(),
102
- kind: "element",
103
- parent: null,
104
- children: []
105
- }) });
104
+ function d(o, s) {
105
+ let c = i({
106
+ ...a(n),
107
+ patchProp: u(n)
108
+ }).createApp(o, s), l = c.mount.bind(c);
109
+ function d() {
110
+ let n = t();
111
+ return {
112
+ id: n,
113
+ kind: "element",
114
+ parent: null,
115
+ children: [],
116
+ focus: () => e(n),
117
+ blur: () => r()
118
+ };
119
+ }
120
+ return Object.assign(c, { mount: (e) => l(e ?? d()) });
106
121
  }
107
122
  //#endregion
108
- export { l as createIncaApp };
123
+ export { d as createIncaApp };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "incajs",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "description": "A GPU-native, Webview-free desktop app framework built on GPUI and QuickJS.",
5
5
  "keywords": [
6
6
  "cross-platform",