incajs 0.0.3 → 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).
@@ -42,45 +42,53 @@ function s(e, t) {
42
42
  let r = i.idFor(e, t);
43
43
  r !== void 0 && (n().removeEventListener(e, t, r), i.release(r));
44
44
  }
45
+ function c(e) {
46
+ n().focusNode(e);
47
+ }
48
+ function l() {
49
+ n().blurNode();
50
+ }
45
51
  //#endregion
46
52
  //#region src/tree.mts
47
- function c() {
53
+ function u() {
48
54
  return n().rootNodeId();
49
55
  }
50
- function l(e) {
56
+ function d(e) {
51
57
  return n().createNode(e);
52
58
  }
53
- function u(e, t) {
59
+ function f(e, t) {
54
60
  n().appendChild(e, t);
55
61
  }
56
- function d(e, t, r) {
62
+ function p(e, t, r) {
57
63
  n().insertBefore(e, t, r);
58
64
  }
59
- function f(e, t) {
65
+ function m(e, t) {
60
66
  n().removeChild(e, t);
61
67
  }
62
- function p(e) {
68
+ function h(e) {
63
69
  a(n().destroyNode(e));
64
70
  }
65
- function m(e, t, r) {
71
+ function g(e, t, r) {
66
72
  n().setAttribute(e, t, r);
67
73
  }
68
- function h(e, t, r) {
74
+ function _(e, t, r) {
69
75
  n().setStyle(e, t, r);
70
76
  }
71
77
  //#endregion
72
- //#region src/index.mts
73
- var g = /* @__PURE__ */ t({
74
- appendChild: () => u,
75
- createNode: () => l,
76
- destroyNode: () => p,
77
- insertBefore: () => d,
78
- removeChild: () => f,
78
+ //#region src/rendererCore.mts
79
+ var v = /* @__PURE__ */ t({
80
+ appendChild: () => f,
81
+ blur: () => l,
82
+ createNode: () => d,
83
+ destroyNode: () => h,
84
+ focus: () => c,
85
+ insertBefore: () => p,
86
+ removeChild: () => m,
79
87
  removeEventListener: () => s,
80
- rootNodeId: () => c,
81
- setAttribute: () => m,
88
+ rootNodeId: () => u,
89
+ setAttribute: () => g,
82
90
  setEventListener: () => o,
83
- setStyle: () => h
91
+ setStyle: () => _
84
92
  });
85
93
  //#endregion
86
- export { d as a, m as c, o as d, p as i, h as l, u as n, f as o, l as r, c as s, g as t, s as u };
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 };
package/dist/events.d.mts CHANGED
@@ -12,8 +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. Only `"click"` is wired to a real native
16
- * input event today; other event names are accepted but 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.
17
18
  * @param nodeId - the node to listen on
18
19
  * @param event - the event name (e.g. `"click"`)
19
20
  * @param listener - called when the event fires
@@ -26,3 +27,17 @@ export declare function setEventListener(nodeId: NodeId, event: string, listener
26
27
  * @param event - the event name
27
28
  */
28
29
  export declare function removeEventListener(nodeId: NodeId, event: string): void;
30
+ /**
31
+ * Requests that `nodeId` become focused. Takes effect on the next frame,
32
+ * dispatching `"blur"`/`"focus"` for whatever actually changed — `nodeId`
33
+ * doesn't need a `"focus"`/`"blur"` listener registered for this to work,
34
+ * the same way `element.focus()` works on any focusable DOM element
35
+ * regardless of whether it's being listened to.
36
+ * @param nodeId - the node to focus
37
+ */
38
+ export declare function focus(nodeId: NodeId): void;
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.
42
+ */
43
+ export declare function blur(): void;
package/dist/index.d.mts CHANGED
@@ -1,3 +1 @@
1
- export { 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, i as r, l as i, n as a, o, r as s, s as c, u as l } from "./chunks/src-EeQFPfUI.js";
2
- export { a as appendChild, s as createNode, r as destroyNode, e as insertBefore, o as removeChild, l as removeEventListener, c as rootNodeId, t as setAttribute, n as setEventListener, i as setStyle };
package/dist/native.d.mts CHANGED
@@ -11,6 +11,8 @@ interface IncaNative {
11
11
  addEventListener(nodeId: NodeId, event: string, callbackId: CallbackId): void;
12
12
  removeEventListener(nodeId: NodeId, event: string, callbackId: CallbackId): boolean;
13
13
  destroyNode(nodeId: NodeId): CallbackId[];
14
+ focusNode(nodeId: NodeId): void;
15
+ blurNode(): void;
14
16
  }
15
17
  declare global {
16
18
  var __inca_native__: IncaNative;
@@ -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
@@ -48,8 +48,11 @@ export interface StyleProps {
48
48
  }
49
49
  /**
50
50
  * Signature of a callback registered via {@link setEventListener}. The
51
- * native host currently always calls it with exactly one argument, the
52
- * {@link NodeId} the event fired on — the type stays variadic so a future
53
- * event kind can add a richer payload without a breaking signature change.
51
+ * native host calls it with one argument, an object with `type` (the
52
+ * event's name), `target`/`currentTarget` (both the {@link NodeId} it fired
53
+ * on), `stopPropagation`/`stopImmediatePropagation`/`preventDefault`
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.
54
57
  */
55
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,9 +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"` is wired to real input by the native host today, other event
14
- * names 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.
15
15
  * - Everything else falls through to `core.setAttribute`, again skipping
16
16
  * a non-string/number/boolean value rather than passing it through.
17
17
  *
package/dist/vue.js CHANGED
@@ -1,7 +1,7 @@
1
- import { s as e, t } from "./chunks/src-EeQFPfUI.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,7 +1,7 @@
1
1
  {
2
2
  "name": "incajs",
3
- "version": "0.0.3",
4
- "description": "Incarnative.js — a GPU-native, Webview-free desktop application framework powered by GPUI and QuickJS. Framework-agnostic core, with first-class Vue 3 support via the incajs/vue subpath.",
3
+ "version": "0.0.5",
4
+ "description": "A GPU-native, Webview-free desktop app framework built on GPUI and QuickJS.",
5
5
  "keywords": [
6
6
  "cross-platform",
7
7
  "custom-renderer",