@gtkx/react 0.1.34 → 0.1.35

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/dist/index.d.ts CHANGED
@@ -4,4 +4,3 @@ export { createPortal } from "./portal.js";
4
4
  export { reconciler } from "./reconciler.js";
5
5
  export { render } from "./render.js";
6
6
  export declare const quit: () => boolean;
7
- export declare const getApp: () => import("@gtkx/ffi/gtk").Application;
package/dist/index.js CHANGED
@@ -14,4 +14,3 @@ export const quit = () => {
14
14
  }
15
15
  return true;
16
16
  };
17
- export const getApp = () => reconciler.getApp();
@@ -1,4 +1,3 @@
1
- import type { Application } from "@gtkx/ffi/gtk";
2
1
  import * as Gtk from "@gtkx/ffi/gtk";
3
2
  import ReactReconciler from "react-reconciler";
4
3
  import type { Node } from "./node.js";
@@ -10,10 +9,7 @@ type FormInstance = never;
10
9
  type ReconcilerInstance = ReactReconciler.Reconciler<Container, Node, TextInstance, SuspenseInstance, FormInstance, PublicInstance>;
11
10
  declare class Reconciler {
12
11
  private instance;
13
- private app;
14
12
  constructor();
15
- getApp(): Application;
16
- setApp(app: Application): void;
17
13
  getInstance(): ReconcilerInstance;
18
14
  private createHostConfig;
19
15
  private createReconcilerContext;
@@ -1,22 +1,13 @@
1
+ import { getCurrentApp } from "@gtkx/ffi";
1
2
  import * as Gtk from "@gtkx/ffi/gtk";
2
3
  import React from "react";
3
4
  import ReactReconciler from "react-reconciler";
4
5
  import { createNode } from "./factory.js";
5
6
  class Reconciler {
6
7
  instance;
7
- app = null;
8
8
  constructor() {
9
9
  this.instance = ReactReconciler(this.createHostConfig());
10
10
  }
11
- getApp() {
12
- if (!this.app) {
13
- throw new Error("Tried to get GTK Application before it was set.");
14
- }
15
- return this.app;
16
- }
17
- setApp(app) {
18
- this.app = app;
19
- }
20
11
  getInstance() {
21
12
  return this.instance;
22
13
  }
@@ -30,15 +21,15 @@ class Reconciler {
30
21
  getRootHostContext: () => ({}),
31
22
  getChildHostContext: (parentHostContext) => parentHostContext,
32
23
  shouldSetTextContent: () => false,
33
- createInstance: (type, props) => createNode(type, props, this.getApp()),
34
- createTextInstance: (text) => createNode("Label.Root", { label: text }, this.getApp()),
24
+ createInstance: (type, props) => createNode(type, props, getCurrentApp()),
25
+ createTextInstance: (text) => createNode("Label.Root", { label: text }, getCurrentApp()),
35
26
  appendInitialChild: (parent, child) => parent.appendChild(child),
36
27
  finalizeInitialChildren: () => true,
37
28
  commitUpdate: (instance, _type, oldProps, newProps) => {
38
29
  instance.updateProps(oldProps, newProps);
39
30
  },
40
31
  commitMount: (instance) => {
41
- instance.mount(this.getApp());
32
+ instance.mount(getCurrentApp());
42
33
  },
43
34
  appendChild: (parent, child) => parent.appendChild(child),
44
35
  removeChild: (parent, child) => parent.removeChild(child),
@@ -81,7 +72,7 @@ class Reconciler {
81
72
  prepareScopeUpdate: () => { },
82
73
  getInstanceFromScope: () => null,
83
74
  detachDeletedInstance: (instance) => {
84
- instance.dispose(this.getApp());
75
+ instance.dispose(getCurrentApp());
85
76
  },
86
77
  resetFormInstance: () => { },
87
78
  requestPostPaintCallback: () => { },
@@ -102,9 +93,9 @@ class Reconciler {
102
93
  }
103
94
  createNodeFromContainer(container) {
104
95
  if (container instanceof Gtk.Widget) {
105
- return createNode(container.constructor.name, {}, this.getApp(), container);
96
+ return createNode(container.constructor.name, {}, getCurrentApp(), container);
106
97
  }
107
- return createNode("Application", {}, this.getApp(), container);
98
+ return createNode("Application", {}, getCurrentApp(), container);
108
99
  }
109
100
  }
110
101
  export const reconciler = new Reconciler();
package/dist/render.js CHANGED
@@ -4,7 +4,6 @@ export let container = null;
4
4
  export const render = (element, appId, flags) => {
5
5
  const app = start(appId, flags);
6
6
  const instance = reconciler.getInstance();
7
- reconciler.setApp(app);
8
7
  container = instance.createContainer(app, 0, null, false, null, "", (error, info) => {
9
8
  console.error("Uncaught error in GTKX application:", error, info);
10
9
  }, (_error, _info) => { }, (_error, _info) => { }, () => { }, null);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gtkx/react",
3
- "version": "0.1.34",
3
+ "version": "0.1.35",
4
4
  "description": "Build GTK4 desktop applications with React and TypeScript",
5
5
  "keywords": [
6
6
  "gtk",
@@ -36,10 +36,10 @@
36
36
  ],
37
37
  "dependencies": {
38
38
  "react-reconciler": "0.33.0",
39
- "@gtkx/ffi": "0.1.34"
39
+ "@gtkx/ffi": "0.1.35"
40
40
  },
41
41
  "devDependencies": {
42
- "@gtkx/gir": "0.1.34"
42
+ "@gtkx/gir": "0.1.35"
43
43
  },
44
44
  "peerDependencies": {
45
45
  "react": "^19"