Skip to content
This repository was archived by the owner on Mar 18, 2025. It is now read-only.

Commit 2acccb1

Browse files
committed
fix: Remove references to React
1 parent 12b3a4a commit 2acccb1

File tree

2 files changed

+229
-1
lines changed

2 files changed

+229
-1
lines changed

src/dom/react-nodegui/src/components/config.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import { NodeWidget, Component } from "@nodegui/nodegui";
2-
import { Fiber } from "react-reconciler";
2+
// import { Fiber } from "react-reconciler";
33
import { AppContainer } from "../reconciler";
44

5+
type Fiber = any;
6+
57
type UpdatePayload = any;
68

79
export interface RNProps {}
Lines changed: 226 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,226 @@
1+
// import Reconciler from "react-reconciler";
2+
// import { NodeWidget, QSystemTrayIcon, NodeObject } from "@nodegui/nodegui";
3+
// import {
4+
// getComponentByTagName,
5+
// RNWidget,
6+
// RNProps,
7+
// RNComponent
8+
// } from "../components/config";
9+
10+
// export type AppContainer = Set<NodeWidget<any>>;
11+
export type AppContainer = any;
12+
13+
/*
14+
export const appContainer: AppContainer = new Set<NodeWidget<any>>();
15+
16+
const shouldIgnoreChild = (child: NodeObject<any>) =>
17+
child instanceof QSystemTrayIcon;
18+
19+
const HostConfig: Reconciler.HostConfig<
20+
string,
21+
RNProps,
22+
AppContainer,
23+
RNComponent,
24+
any,
25+
any,
26+
any,
27+
any,
28+
any,
29+
any,
30+
any,
31+
any
32+
> = {
33+
now: Date.now,
34+
getRootHostContext: function(nextRootInstance) {
35+
let context = {
36+
name: "rootnode"
37+
};
38+
return context;
39+
},
40+
getChildHostContext: function(parentContext, fiberType, rootInstance) {
41+
const { getContext } = getComponentByTagName(fiberType);
42+
return getContext(parentContext, rootInstance);
43+
},
44+
shouldSetTextContent: function(type, nextProps) {
45+
const { shouldSetTextContent } = getComponentByTagName(type);
46+
return shouldSetTextContent(nextProps);
47+
},
48+
createTextInstance: function(
49+
newText,
50+
rootContainerInstance,
51+
context,
52+
workInProgress
53+
) {
54+
// throw new Error(`Can't create text without <Text> for text: ${newText}`);
55+
console.warn(
56+
"createTextInstance called in reconciler when platform doesnt have host level text. "
57+
);
58+
console.warn(`Use <Text /> component to add the text: ${newText}`);
59+
},
60+
createInstance: function(
61+
type,
62+
newProps,
63+
rootContainerInstance,
64+
context,
65+
workInProgress
66+
) {
67+
const { createInstance } = getComponentByTagName(type);
68+
return createInstance(
69+
newProps,
70+
rootContainerInstance,
71+
context,
72+
workInProgress
73+
);
74+
},
75+
appendInitialChild: function (parent: RNWidget, child: NodeWidget<any>) {
76+
if (shouldIgnoreChild(child)) {
77+
return;
78+
}
79+
parent.appendInitialChild(child);
80+
},
81+
finalizeInitialChildren: function(
82+
instance,
83+
type,
84+
newProps,
85+
rootContainerInstance,
86+
context
87+
) {
88+
const { finalizeInitialChildren } = getComponentByTagName(type);
89+
return finalizeInitialChildren(
90+
instance,
91+
newProps,
92+
rootContainerInstance,
93+
context
94+
);
95+
},
96+
prepareForCommit: function(rootNode) {
97+
// noop
98+
},
99+
resetAfterCommit: function(rootNode) {
100+
// noop
101+
},
102+
commitMount: function(instance, type, newProps, internalInstanceHandle) {
103+
const { commitMount } = getComponentByTagName(type);
104+
return commitMount(instance, newProps, internalInstanceHandle);
105+
},
106+
appendChildToContainer: function(container, child: NodeWidget<any>) {
107+
container.add(child);
108+
},
109+
insertInContainerBefore: (container, child, beforeChild) => {
110+
container.add(child);
111+
},
112+
removeChildFromContainer: (container, child) => {
113+
container.delete(child);
114+
if (child.close) {
115+
child.close();
116+
}
117+
},
118+
prepareUpdate: function(
119+
instance,
120+
type,
121+
oldProps,
122+
newProps,
123+
rootContainerInstance,
124+
hostContext
125+
) {
126+
const { prepareUpdate } = getComponentByTagName(type);
127+
return prepareUpdate(
128+
instance,
129+
oldProps,
130+
newProps,
131+
rootContainerInstance,
132+
hostContext
133+
);
134+
},
135+
commitUpdate: function(
136+
instance,
137+
updatePayload,
138+
type,
139+
oldProps,
140+
newProps,
141+
finishedWork
142+
) {
143+
const { commitUpdate } = getComponentByTagName(type);
144+
return commitUpdate(
145+
instance,
146+
updatePayload,
147+
oldProps,
148+
newProps,
149+
finishedWork
150+
);
151+
},
152+
appendChild: (parent: RNWidget, child: NodeWidget<any>) => {
153+
if (shouldIgnoreChild(child)) {
154+
return;
155+
}
156+
parent.appendChild(child);
157+
},
158+
insertBefore: (
159+
parent: RNWidget,
160+
child: NodeWidget<any>,
161+
beforeChild: NodeWidget<any>
162+
) => {
163+
if (shouldIgnoreChild(child)) {
164+
return;
165+
}
166+
parent.insertBefore(child, beforeChild);
167+
},
168+
removeChild: (parent: RNWidget, child: NodeWidget<any>) => {
169+
if (!shouldIgnoreChild(child)) {
170+
parent.removeChild(child);
171+
}
172+
if (child.close) {
173+
child.close();
174+
}
175+
},
176+
commitTextUpdate: (textInstance, oldText, newText) => {
177+
//noop since we manage all text using Text component
178+
console.warn(
179+
"commitTextUpdate called when platform doesnt have host level text"
180+
);
181+
},
182+
resetTextContent: instance => {
183+
console.warn("resetTextContent in reconciler triggered!");
184+
// noop for now till we find when this method is triggered
185+
},
186+
supportsMutation: true,
187+
supportsPersistence: false,
188+
supportsHydration: false,
189+
getPublicInstance: instance => {
190+
//for supporting refs
191+
return instance;
192+
},
193+
shouldDeprioritizeSubtree: (type, props) => {
194+
// Use to deprioritize entire subtree based on props and types. For example if you dont need reconciler to calculate for hidden elements
195+
if ((props as any).visible === false) {
196+
return true;
197+
}
198+
return false;
199+
},
200+
//@ts-ignore
201+
hideInstance: (instance: NodeWidget<any>) => {
202+
instance.hide();
203+
},
204+
unhideInstance: (instance: NodeWidget<any>, Props: RNProps) => {
205+
instance.show();
206+
},
207+
hideTextInstance: (instance: any) => {
208+
// noop since we dont have any host text
209+
console.warn(
210+
"hideTextInstance called when platform doesnt have host level text"
211+
);
212+
},
213+
unhideTextInstance: (instance: NodeWidget<any>, Props: RNProps) => {
214+
// noop since we dont have any host text
215+
console.warn(
216+
"unhideTextInstance called when platform doesnt have host level text"
217+
);
218+
},
219+
scheduleTimeout: setTimeout,
220+
cancelTimeout: clearTimeout,
221+
noTimeout: -1,
222+
isPrimaryRenderer: true
223+
};
224+
225+
export default Reconciler(HostConfig);
226+
*/

0 commit comments

Comments
 (0)