@gtkx/react 0.9.3 → 0.10.0
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 +55 -67
- package/dist/errors.d.ts +3 -3
- package/dist/errors.js +8 -8
- package/dist/factory.d.ts +3 -5
- package/dist/factory.js +18 -71
- package/dist/fiber-root.d.ts +1 -1
- package/dist/fiber-root.js +1 -2
- package/dist/generated/internal.d.ts +3 -6
- package/dist/generated/internal.js +10386 -13577
- package/dist/generated/jsx.d.ts +2325 -2219
- package/dist/generated/jsx.js +1339 -1574
- package/dist/generated/registry.d.ts +4 -0
- package/dist/generated/registry.js +13 -0
- package/dist/host-config.d.ts +7 -4
- package/dist/host-config.js +53 -18
- package/dist/index.d.ts +2 -22
- package/dist/index.js +2 -40
- package/dist/jsx.d.ts +719 -0
- package/dist/jsx.js +392 -0
- package/dist/node.d.ts +15 -32
- package/dist/node.js +20 -240
- package/dist/nodes/action-row-child.d.ts +21 -0
- package/dist/nodes/action-row-child.js +69 -0
- package/dist/nodes/action-row.js +33 -0
- package/dist/nodes/application.d.ts +1 -0
- package/dist/nodes/application.js +38 -0
- package/dist/nodes/autowrapped.d.ts +1 -0
- package/dist/nodes/autowrapped.js +109 -0
- package/dist/nodes/column-view-column.d.ts +16 -0
- package/dist/nodes/column-view-column.js +54 -0
- package/dist/nodes/column-view.d.ts +0 -59
- package/dist/nodes/column-view.js +107 -226
- package/dist/nodes/fixed-child.d.ts +1 -0
- package/dist/nodes/fixed-child.js +45 -0
- package/dist/nodes/grid-child.d.ts +1 -0
- package/dist/nodes/grid-child.js +54 -0
- package/dist/nodes/index.d.ts +34 -0
- package/dist/nodes/index.js +34 -0
- package/dist/nodes/internal/list-item-renderer.d.ts +18 -0
- package/dist/nodes/internal/list-item-renderer.js +67 -0
- package/dist/nodes/internal/list-store.d.ts +16 -0
- package/dist/nodes/internal/list-store.js +69 -0
- package/dist/nodes/internal/predicates.d.ts +26 -0
- package/dist/nodes/internal/predicates.js +36 -0
- package/dist/nodes/internal/signal-store.d.ts +9 -0
- package/dist/nodes/internal/signal-store.js +54 -0
- package/dist/nodes/internal/simple-list-store.d.ts +14 -0
- package/dist/nodes/internal/simple-list-store.js +60 -0
- package/dist/nodes/internal/tree-list-item-renderer.d.ts +18 -0
- package/dist/nodes/internal/tree-list-item-renderer.js +90 -0
- package/dist/nodes/internal/tree-store.d.ts +28 -0
- package/dist/nodes/internal/tree-store.js +153 -0
- package/dist/nodes/internal/utils.d.ts +3 -0
- package/dist/nodes/internal/utils.js +20 -0
- package/dist/nodes/list-item.d.ts +12 -0
- package/dist/nodes/list-item.js +24 -0
- package/dist/nodes/list-view.d.ts +0 -22
- package/dist/nodes/list-view.js +45 -38
- package/dist/nodes/menu.d.ts +6 -106
- package/dist/nodes/menu.js +16 -268
- package/dist/nodes/models/list.d.ts +24 -0
- package/dist/nodes/models/list.js +102 -0
- package/dist/nodes/models/menu.d.ts +45 -0
- package/dist/nodes/models/menu.js +265 -0
- package/dist/nodes/models/tree-list.d.ts +28 -0
- package/dist/nodes/models/tree-list.js +141 -0
- package/dist/nodes/navigation-page.d.ts +21 -0
- package/dist/nodes/navigation-page.js +95 -0
- package/dist/nodes/navigation-view.d.ts +1 -0
- package/dist/nodes/navigation-view.js +29 -0
- package/dist/nodes/notebook-page-tab.d.ts +15 -0
- package/dist/nodes/notebook-page-tab.js +42 -0
- package/dist/nodes/notebook-page.d.ts +23 -0
- package/dist/nodes/notebook-page.js +106 -0
- package/dist/nodes/notebook.d.ts +0 -32
- package/dist/nodes/notebook.js +20 -113
- package/dist/nodes/overlay-child.d.ts +1 -0
- package/dist/nodes/overlay-child.js +30 -0
- package/dist/nodes/pack-child.d.ts +21 -0
- package/dist/nodes/pack-child.js +68 -0
- package/dist/nodes/pack.d.ts +1 -0
- package/dist/nodes/pack.js +33 -0
- package/dist/nodes/popover-menu.d.ts +1 -0
- package/dist/nodes/popover-menu.js +58 -0
- package/dist/nodes/simple-list-item.d.ts +9 -0
- package/dist/nodes/simple-list-item.js +9 -0
- package/dist/nodes/simple-list-view.d.ts +1 -0
- package/dist/nodes/simple-list-view.js +75 -0
- package/dist/nodes/slot.d.ts +18 -10
- package/dist/nodes/slot.js +83 -51
- package/dist/nodes/stack-page.d.ts +1 -0
- package/dist/nodes/stack-page.js +80 -0
- package/dist/nodes/stack.d.ts +1 -22
- package/dist/nodes/stack.js +21 -60
- package/dist/nodes/toast-overlay.d.ts +1 -0
- package/dist/nodes/toast-overlay.js +35 -0
- package/dist/nodes/toast.d.ts +17 -0
- package/dist/nodes/toast.js +77 -0
- package/dist/nodes/toolbar-child.d.ts +9 -0
- package/dist/nodes/toolbar-child.js +33 -0
- package/dist/nodes/toolbar.d.ts +1 -0
- package/dist/nodes/toolbar.js +42 -0
- package/dist/nodes/tree-list-item.d.ts +20 -0
- package/dist/nodes/tree-list-item.js +102 -0
- package/dist/nodes/tree-list-view.d.ts +1 -0
- package/dist/nodes/tree-list-view.js +57 -0
- package/dist/nodes/virtual.d.ts +13 -0
- package/dist/nodes/virtual.js +21 -0
- package/dist/nodes/widget.d.ts +17 -3
- package/dist/nodes/widget.js +258 -2
- package/dist/nodes/window.d.ts +1 -12
- package/dist/nodes/window.js +66 -27
- package/dist/portal.d.ts +18 -13
- package/dist/portal.js +17 -14
- package/dist/reconciler.d.ts +0 -4
- package/dist/reconciler.js +1 -9
- package/dist/registry.d.ts +8 -0
- package/dist/registry.js +5 -0
- package/dist/render.d.ts +108 -12
- package/dist/render.js +140 -16
- package/dist/scheduler.d.ts +4 -0
- package/dist/scheduler.js +10 -0
- package/dist/types.d.ts +3 -136
- package/package.json +6 -6
- package/dist/batch.d.ts +0 -5
- package/dist/batch.js +0 -31
- package/dist/codegen/jsx-generator.d.ts +0 -56
- package/dist/codegen/jsx-generator.js +0 -959
- package/dist/containers.d.ts +0 -58
- package/dist/nodes/about-dialog.d.ts +0 -8
- package/dist/nodes/about-dialog.js +0 -16
- package/dist/nodes/action-bar.d.ts +0 -5
- package/dist/nodes/action-bar.js +0 -6
- package/dist/nodes/combo-row.d.ts +0 -5
- package/dist/nodes/combo-row.js +0 -6
- package/dist/nodes/drop-down.d.ts +0 -9
- package/dist/nodes/drop-down.js +0 -12
- package/dist/nodes/flow-box.d.ts +0 -10
- package/dist/nodes/flow-box.js +0 -41
- package/dist/nodes/grid.d.ts +0 -30
- package/dist/nodes/grid.js +0 -84
- package/dist/nodes/header-bar.d.ts +0 -43
- package/dist/nodes/header-bar.js +0 -116
- package/dist/nodes/indexed-child-container.d.ts +0 -16
- package/dist/nodes/indexed-child-container.js +0 -22
- package/dist/nodes/list-box.d.ts +0 -10
- package/dist/nodes/list-box.js +0 -48
- package/dist/nodes/list-item-factory.d.ts +0 -19
- package/dist/nodes/list-item-factory.js +0 -58
- package/dist/nodes/overlay.d.ts +0 -11
- package/dist/nodes/overlay.js +0 -50
- package/dist/nodes/paged-stack.d.ts +0 -31
- package/dist/nodes/paged-stack.js +0 -95
- package/dist/nodes/root.d.ts +0 -8
- package/dist/nodes/root.js +0 -13
- package/dist/nodes/selectable-list.d.ts +0 -45
- package/dist/nodes/selectable-list.js +0 -260
- package/dist/nodes/stack-page-props.d.ts +0 -11
- package/dist/nodes/stack-page-props.js +0 -23
- package/dist/nodes/string-list-container.d.ts +0 -34
- package/dist/nodes/string-list-container.js +0 -118
- package/dist/nodes/string-list-item.d.ts +0 -19
- package/dist/nodes/string-list-item.js +0 -50
- package/dist/nodes/string-list-store.d.ts +0 -13
- package/dist/nodes/string-list-store.js +0 -44
- package/dist/nodes/text-view.d.ts +0 -8
- package/dist/nodes/text-view.js +0 -16
- package/dist/nodes/toggle-button.d.ts +0 -14
- package/dist/nodes/toggle-button.js +0 -39
- package/dist/nodes/toolbar-view.d.ts +0 -14
- package/dist/nodes/toolbar-view.js +0 -78
- package/dist/nodes/view-stack.d.ts +0 -9
- package/dist/nodes/view-stack.js +0 -28
- package/dist/nodes/virtual-item.d.ts +0 -19
- package/dist/nodes/virtual-item.js +0 -48
- package/dist/nodes/virtual-slot.d.ts +0 -25
- package/dist/nodes/virtual-slot.js +0 -57
- package/dist/predicates.d.ts +0 -29
- package/dist/predicates.js +0 -37
- package/dist/props.d.ts +0 -7
- package/dist/props.js +0 -12
- /package/dist/{containers.js → nodes/action-row.d.ts} +0 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Generated namespace registry for widget class resolution. */
|
|
2
|
+
import * as Adw from "@gtkx/ffi/adw";
|
|
3
|
+
import * as Gtk from "@gtkx/ffi/gtk";
|
|
4
|
+
import * as GtkSource from "@gtkx/ffi/gtksource";
|
|
5
|
+
import * as Vte from "@gtkx/ffi/vte";
|
|
6
|
+
import * as WebKit from "@gtkx/ffi/webkit";
|
|
7
|
+
export const NAMESPACE_REGISTRY = [
|
|
8
|
+
["GtkSource", GtkSource],
|
|
9
|
+
["WebKit", WebKit],
|
|
10
|
+
["Adw", Adw],
|
|
11
|
+
["Gtk", Gtk],
|
|
12
|
+
["Vte", Vte],
|
|
13
|
+
];
|
package/dist/host-config.d.ts
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import type * as Gtk from "@gtkx/ffi/gtk";
|
|
2
2
|
import type ReactReconciler from "react-reconciler";
|
|
3
|
-
import { type Props, type ROOT_NODE_CONTAINER } from "./factory.js";
|
|
4
3
|
import type { Node } from "./node.js";
|
|
5
|
-
type Container
|
|
4
|
+
import type { Container, Props } from "./types.js";
|
|
5
|
+
declare global {
|
|
6
|
+
var __GTKX_CONTAINER_NODE_CACHE__: Map<number, Node> | undefined;
|
|
7
|
+
}
|
|
8
|
+
export declare const isCommitting: () => boolean;
|
|
6
9
|
type TextInstance = Node;
|
|
7
10
|
type SuspenseInstance = never;
|
|
8
11
|
type HydratableInstance = never;
|
|
9
|
-
type PublicInstance = Gtk.Widget;
|
|
12
|
+
type PublicInstance = Gtk.Widget | Gtk.Application;
|
|
10
13
|
type HostContext = Record<string, never>;
|
|
11
14
|
type ChildSet = never;
|
|
12
15
|
type TimeoutHandle = number;
|
|
@@ -15,5 +18,5 @@ type TransitionStatus = number;
|
|
|
15
18
|
type FormInstance = never;
|
|
16
19
|
type HostConfig = ReactReconciler.HostConfig<string, Props, Container, Node, TextInstance, SuspenseInstance, HydratableInstance, FormInstance, PublicInstance, HostContext, ChildSet, TimeoutHandle, NoTimeout, TransitionStatus>;
|
|
17
20
|
export type ReconcilerInstance = ReactReconciler.Reconciler<Container, Node, TextInstance, SuspenseInstance, FormInstance, PublicInstance>;
|
|
18
|
-
export declare function createHostConfig(
|
|
21
|
+
export declare function createHostConfig(): HostConfig;
|
|
19
22
|
export {};
|
package/dist/host-config.js
CHANGED
|
@@ -1,8 +1,24 @@
|
|
|
1
|
-
import { beginBatch, endBatch } from "@gtkx/ffi";
|
|
1
|
+
import { beginBatch, endBatch, getObjectId } from "@gtkx/ffi";
|
|
2
2
|
import React from "react";
|
|
3
|
-
import { beginCommit, endCommit } from "./batch.js";
|
|
4
3
|
import { createNode } from "./factory.js";
|
|
5
|
-
|
|
4
|
+
import { flushAfterCommit } from "./scheduler.js";
|
|
5
|
+
if (!globalThis.__GTKX_CONTAINER_NODE_CACHE__) {
|
|
6
|
+
globalThis.__GTKX_CONTAINER_NODE_CACHE__ = new Map();
|
|
7
|
+
}
|
|
8
|
+
let committing = false;
|
|
9
|
+
export const isCommitting = () => committing;
|
|
10
|
+
const containerNodeCache = globalThis.__GTKX_CONTAINER_NODE_CACHE__;
|
|
11
|
+
const getOrCreateContainerNode = (container) => {
|
|
12
|
+
const id = getObjectId(container.id);
|
|
13
|
+
let node = containerNodeCache.get(id);
|
|
14
|
+
if (!node) {
|
|
15
|
+
const type = container.constructor.glibTypeName;
|
|
16
|
+
node = createNode(type, {}, container, container);
|
|
17
|
+
containerNodeCache.set(id, node);
|
|
18
|
+
}
|
|
19
|
+
return node;
|
|
20
|
+
};
|
|
21
|
+
export function createHostConfig() {
|
|
6
22
|
return {
|
|
7
23
|
supportsMutation: true,
|
|
8
24
|
supportsPersistence: false,
|
|
@@ -12,39 +28,58 @@ export function createHostConfig(createNodeFromContainer) {
|
|
|
12
28
|
getRootHostContext: () => ({}),
|
|
13
29
|
getChildHostContext: (parentHostContext) => parentHostContext,
|
|
14
30
|
shouldSetTextContent: () => false,
|
|
15
|
-
createInstance: (type, props) =>
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
31
|
+
createInstance: (type, props, rootContainer) => {
|
|
32
|
+
return createNode(type, props, undefined, rootContainer);
|
|
33
|
+
},
|
|
34
|
+
createTextInstance: (text, rootContainer) => {
|
|
35
|
+
const props = { label: text };
|
|
36
|
+
const node = createNode("GtkLabel", props, undefined, rootContainer);
|
|
37
|
+
node.updateProps(null, props);
|
|
38
|
+
return node;
|
|
39
|
+
},
|
|
40
|
+
appendInitialChild: (parent, child) => {
|
|
41
|
+
parent.appendChild(child);
|
|
42
|
+
},
|
|
43
|
+
finalizeInitialChildren: (instance, _type, props) => {
|
|
44
|
+
instance.updateProps(null, props);
|
|
45
|
+
return true;
|
|
46
|
+
},
|
|
19
47
|
commitUpdate: (instance, _type, oldProps, newProps) => {
|
|
20
48
|
instance.updateProps(oldProps, newProps);
|
|
21
49
|
},
|
|
22
|
-
commitMount: (instance) => {
|
|
50
|
+
commitMount: (instance, _type) => {
|
|
23
51
|
instance.mount();
|
|
24
52
|
},
|
|
25
|
-
appendChild: (parent, child) =>
|
|
26
|
-
|
|
27
|
-
|
|
53
|
+
appendChild: (parent, child) => {
|
|
54
|
+
parent.appendChild(child);
|
|
55
|
+
},
|
|
56
|
+
removeChild: (parent, child) => {
|
|
57
|
+
parent.removeChild(child);
|
|
58
|
+
},
|
|
59
|
+
insertBefore: (parent, child, beforeChild) => {
|
|
60
|
+
parent.insertBefore(child, beforeChild);
|
|
61
|
+
},
|
|
28
62
|
removeChildFromContainer: (container, child) => {
|
|
29
|
-
const parent =
|
|
63
|
+
const parent = getOrCreateContainerNode(container);
|
|
30
64
|
parent.removeChild(child);
|
|
31
65
|
},
|
|
32
66
|
appendChildToContainer: (container, child) => {
|
|
33
|
-
const parent =
|
|
67
|
+
const parent = getOrCreateContainerNode(container);
|
|
34
68
|
parent.appendChild(child);
|
|
35
69
|
},
|
|
36
70
|
insertInContainerBefore: (container, child, beforeChild) => {
|
|
37
|
-
const parent =
|
|
71
|
+
const parent = getOrCreateContainerNode(container);
|
|
38
72
|
parent.insertBefore(child, beforeChild);
|
|
39
73
|
},
|
|
40
74
|
prepareForCommit: () => {
|
|
75
|
+
committing = true;
|
|
41
76
|
beginBatch();
|
|
42
|
-
beginCommit();
|
|
43
77
|
return null;
|
|
44
78
|
},
|
|
45
79
|
resetAfterCommit: () => {
|
|
46
|
-
endCommit();
|
|
47
80
|
endBatch();
|
|
81
|
+
flushAfterCommit();
|
|
82
|
+
committing = false;
|
|
48
83
|
},
|
|
49
84
|
commitTextUpdate: (textInstance, oldText, newText) => {
|
|
50
85
|
textInstance.updateProps({ label: oldText }, { label: newText });
|
|
@@ -58,7 +93,7 @@ export function createHostConfig(createNodeFromContainer) {
|
|
|
58
93
|
cancelTimeout: (id) => {
|
|
59
94
|
clearTimeout(id);
|
|
60
95
|
},
|
|
61
|
-
getPublicInstance: (instance) => instance.
|
|
96
|
+
getPublicInstance: (instance) => instance.container,
|
|
62
97
|
getCurrentUpdatePriority: () => 2,
|
|
63
98
|
setCurrentUpdatePriority: () => { },
|
|
64
99
|
resolveUpdatePriority: () => 2,
|
|
@@ -69,7 +104,7 @@ export function createHostConfig(createNodeFromContainer) {
|
|
|
69
104
|
afterActiveInstanceBlur: () => { },
|
|
70
105
|
prepareScopeUpdate: () => { },
|
|
71
106
|
getInstanceFromScope: () => null,
|
|
72
|
-
detachDeletedInstance: () =>
|
|
107
|
+
detachDeletedInstance: (instance) => instance.unmount(),
|
|
73
108
|
resetFormInstance: () => { },
|
|
74
109
|
requestPostPaintCallback: () => { },
|
|
75
110
|
shouldAttemptEagerTransition: () => false,
|
package/dist/index.d.ts
CHANGED
|
@@ -1,24 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* @private Internal symbol used to identify the root container node.
|
|
3
|
-
* This is an internal API used only by @gtkx/testing. Do not use directly.
|
|
4
|
-
*/
|
|
5
|
-
export { ROOT_NODE_CONTAINER } from "./factory.js";
|
|
6
|
-
export * from "./generated/jsx.js";
|
|
1
|
+
export * from "./jsx.js";
|
|
7
2
|
export { createPortal } from "./portal.js";
|
|
8
3
|
export { reconciler } from "./reconciler.js";
|
|
9
|
-
export { render } from "./render.js";
|
|
10
|
-
import type { ReactNode } from "react";
|
|
11
|
-
/**
|
|
12
|
-
* Updates the React tree without restarting the GTK application.
|
|
13
|
-
* Used for hot module replacement (HMR) during development.
|
|
14
|
-
*
|
|
15
|
-
* @param element - The new root React element to render
|
|
16
|
-
* @throws Error if called before render()
|
|
17
|
-
*/
|
|
18
|
-
export declare const update: (element: ReactNode) => void;
|
|
19
|
-
/**
|
|
20
|
-
* Quits the GTK application and cleans up resources.
|
|
21
|
-
* Unmounts the React tree and stops the GTK main loop.
|
|
22
|
-
* @returns Always returns true (useful for signal handlers)
|
|
23
|
-
*/
|
|
24
|
-
export declare const quit: () => boolean;
|
|
4
|
+
export { ApplicationContext, quit, render, setHotReloading, update, useApplication } from "./render.js";
|
package/dist/index.js
CHANGED
|
@@ -1,42 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* @private Internal symbol used to identify the root container node.
|
|
3
|
-
* This is an internal API used only by @gtkx/testing. Do not use directly.
|
|
4
|
-
*/
|
|
5
|
-
export { ROOT_NODE_CONTAINER } from "./factory.js";
|
|
6
|
-
export * from "./generated/jsx.js";
|
|
1
|
+
export * from "./jsx.js";
|
|
7
2
|
export { createPortal } from "./portal.js";
|
|
8
3
|
export { reconciler } from "./reconciler.js";
|
|
9
|
-
export { render } from "./render.js";
|
|
10
|
-
import { stop } from "@gtkx/ffi";
|
|
11
|
-
import { reconciler } from "./reconciler.js";
|
|
12
|
-
import { getContainer } from "./render.js";
|
|
13
|
-
/**
|
|
14
|
-
* Updates the React tree without restarting the GTK application.
|
|
15
|
-
* Used for hot module replacement (HMR) during development.
|
|
16
|
-
*
|
|
17
|
-
* @param element - The new root React element to render
|
|
18
|
-
* @throws Error if called before render()
|
|
19
|
-
*/
|
|
20
|
-
export const update = (element) => {
|
|
21
|
-
const container = getContainer();
|
|
22
|
-
if (!container) {
|
|
23
|
-
throw new Error("Cannot update before render() is called");
|
|
24
|
-
}
|
|
25
|
-
reconciler.getInstance().updateContainer(element, container, null, () => { });
|
|
26
|
-
};
|
|
27
|
-
/**
|
|
28
|
-
* Quits the GTK application and cleans up resources.
|
|
29
|
-
* Unmounts the React tree and stops the GTK main loop.
|
|
30
|
-
* @returns Always returns true (useful for signal handlers)
|
|
31
|
-
*/
|
|
32
|
-
export const quit = () => {
|
|
33
|
-
const container = getContainer();
|
|
34
|
-
if (container) {
|
|
35
|
-
reconciler.getInstance().updateContainer(null, container, null, () => {
|
|
36
|
-
setTimeout(() => {
|
|
37
|
-
stop();
|
|
38
|
-
}, 0);
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
return true;
|
|
42
|
-
};
|
|
4
|
+
export { ApplicationContext, quit, render, setHotReloading, update, useApplication } from "./render.js";
|