@forge/react 1.0.0 → 1.1.0-next.1
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/CHANGELOG.md +12 -0
- package/out/__test__/styles.test.d.ts +2 -0
- package/out/__test__/styles.test.d.ts.map +1 -0
- package/out/__test__/styles.test.js +88 -0
- package/out/components.d.ts +44 -0
- package/out/components.d.ts.map +1 -0
- package/out/components.js +45 -0
- package/out/index.d.ts +4 -0
- package/out/index.d.ts.map +1 -0
- package/out/index.js +7 -0
- package/out/reconciler.d.ts +5 -0
- package/out/reconciler.d.ts.map +1 -0
- package/out/reconciler.js +143 -0
- package/out/styles/index.d.ts +28 -0
- package/out/styles/index.d.ts.map +1 -0
- package/out/styles/index.js +152 -0
- package/out/types/components.d.ts +369 -0
- package/out/types/components.d.ts.map +1 -0
- package/out/types/components.js +2 -0
- package/out/types/effect.d.ts +57 -0
- package/out/types/effect.d.ts.map +1 -0
- package/out/types/effect.js +19 -0
- package/out/types/extension.d.ts +10 -0
- package/out/types/extension.d.ts.map +1 -0
- package/out/types/extension.js +2 -0
- package/out/types/forge.d.ts +146 -0
- package/out/types/forge.d.ts.map +1 -0
- package/out/types/forge.js +21 -0
- package/out/types/icons.d.ts +2 -0
- package/out/types/icons.d.ts.map +1 -0
- package/out/types/icons.js +2 -0
- package/out/types/index.d.ts +11 -0
- package/out/types/index.d.ts.map +1 -0
- package/out/types/index.js +27 -0
- package/out/types/legacy-effect.d.ts +40 -0
- package/out/types/legacy-effect.d.ts.map +1 -0
- package/out/types/legacy-effect.js +21 -0
- package/out/types/styles.d.ts +134 -0
- package/out/types/styles.d.ts.map +1 -0
- package/out/types/styles.js +2 -0
- package/package.json +3 -2
- package/tsconfig.tsbuildinfo +1078 -0
- package/src/globals.d.ts +0 -12
- package/src/index.ts +0 -1
- package/src/reconciler.ts +0 -219
- package/tsconfig.json +0 -9
package/src/globals.d.ts
DELETED
package/src/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { ForgeReconciler as default } from './reconciler';
|
package/src/reconciler.ts
DELETED
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-empty-function */
|
|
2
|
-
import Reconciler, { HostConfig } from 'react-reconciler';
|
|
3
|
-
import { DefaultEventPriority } from 'react-reconciler/constants';
|
|
4
|
-
import { v4 as uuid } from 'uuid';
|
|
5
|
-
|
|
6
|
-
type ElementType = string;
|
|
7
|
-
type ElementProps = { [key: string]: any };
|
|
8
|
-
|
|
9
|
-
interface ForgeDoc {
|
|
10
|
-
type: string;
|
|
11
|
-
props: { [key: string]: any };
|
|
12
|
-
children: ForgeDoc[];
|
|
13
|
-
key: string;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
// @ts-ignore
|
|
17
|
-
const callBridge = self.__bridge.callBridge;
|
|
18
|
-
|
|
19
|
-
const createElement = (type: ElementType, props: ElementProps = {}): ForgeDoc => {
|
|
20
|
-
const { children, ...restProps } = props;
|
|
21
|
-
return {
|
|
22
|
-
type,
|
|
23
|
-
children: [],
|
|
24
|
-
props: restProps,
|
|
25
|
-
key: uuid()
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const appendChild = (parent: ForgeDoc, child: ForgeDoc) => {
|
|
30
|
-
if (parent.children.includes(child)) {
|
|
31
|
-
const removeIndex = parent.children.indexOf(child);
|
|
32
|
-
parent.children.splice(removeIndex, 1);
|
|
33
|
-
}
|
|
34
|
-
parent.children.push(child);
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
const insertBefore = (parent: ForgeDoc, child: ForgeDoc, beforeChild: ForgeDoc) => {
|
|
38
|
-
const insertIndex = parent.children.indexOf(beforeChild);
|
|
39
|
-
if (parent.children.includes(child)) {
|
|
40
|
-
const removeIndex = parent.children.indexOf(child);
|
|
41
|
-
parent.children.splice(removeIndex, 1);
|
|
42
|
-
}
|
|
43
|
-
parent.children.splice(insertIndex, 0, child);
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
const hostConfig: HostConfig<
|
|
47
|
-
string, // Type
|
|
48
|
-
Record<string, any>, // Props
|
|
49
|
-
ForgeDoc, // Container
|
|
50
|
-
ForgeDoc, // Instance
|
|
51
|
-
ForgeDoc, // TextInstance
|
|
52
|
-
ForgeDoc, // SuspenseInstance
|
|
53
|
-
ForgeDoc, // HydratableInstance
|
|
54
|
-
ForgeDoc, // PublicInstance
|
|
55
|
-
any, // HostContext
|
|
56
|
-
any, // UpdatePayload,
|
|
57
|
-
any, // _ChildSet
|
|
58
|
-
any, // TimeoutHandle
|
|
59
|
-
any // NoTimeout
|
|
60
|
-
> = {
|
|
61
|
-
supportsMutation: true,
|
|
62
|
-
supportsPersistence: false,
|
|
63
|
-
noTimeout: -1,
|
|
64
|
-
isPrimaryRenderer: false,
|
|
65
|
-
supportsHydration: false,
|
|
66
|
-
|
|
67
|
-
resetAfterCommit(forgeDoc: ForgeDoc): void {
|
|
68
|
-
callBridge('reconcile', { forgeDoc });
|
|
69
|
-
},
|
|
70
|
-
|
|
71
|
-
createInstance(type: ElementType, props: ElementProps) {
|
|
72
|
-
const element = createElement(type, props);
|
|
73
|
-
return element;
|
|
74
|
-
},
|
|
75
|
-
|
|
76
|
-
createTextInstance(text: string): ForgeDoc {
|
|
77
|
-
return {
|
|
78
|
-
type: 'String',
|
|
79
|
-
children: [],
|
|
80
|
-
props: {
|
|
81
|
-
text
|
|
82
|
-
},
|
|
83
|
-
key: uuid()
|
|
84
|
-
};
|
|
85
|
-
},
|
|
86
|
-
|
|
87
|
-
appendInitialChild(parent: ForgeDoc, child: ForgeDoc): void {
|
|
88
|
-
appendChild(parent, child);
|
|
89
|
-
},
|
|
90
|
-
|
|
91
|
-
appendChild(parent: ForgeDoc, child: ForgeDoc): void {
|
|
92
|
-
appendChild(parent, child);
|
|
93
|
-
},
|
|
94
|
-
|
|
95
|
-
appendChildToContainer(container: ForgeDoc, child: ForgeDoc): void {
|
|
96
|
-
appendChild(container, child);
|
|
97
|
-
},
|
|
98
|
-
|
|
99
|
-
finalizeInitialChildren(): boolean {
|
|
100
|
-
return false;
|
|
101
|
-
},
|
|
102
|
-
|
|
103
|
-
prepareUpdate(instance: ForgeDoc, type: ElementType, oldProps: ElementProps, newProps: ElementProps): ElementProps {
|
|
104
|
-
instance.props = newProps;
|
|
105
|
-
return newProps;
|
|
106
|
-
},
|
|
107
|
-
|
|
108
|
-
shouldSetTextContent(): boolean {
|
|
109
|
-
return false;
|
|
110
|
-
},
|
|
111
|
-
|
|
112
|
-
getRootHostContext() {
|
|
113
|
-
return {};
|
|
114
|
-
},
|
|
115
|
-
|
|
116
|
-
getChildHostContext(parentContext, fiberType): null {
|
|
117
|
-
return null;
|
|
118
|
-
},
|
|
119
|
-
|
|
120
|
-
getPublicInstance(instance: ForgeDoc): ForgeDoc {
|
|
121
|
-
return instance;
|
|
122
|
-
},
|
|
123
|
-
|
|
124
|
-
prepareForCommit(): null {
|
|
125
|
-
return null;
|
|
126
|
-
},
|
|
127
|
-
|
|
128
|
-
preparePortalMount(): void {},
|
|
129
|
-
|
|
130
|
-
scheduleTimeout(fn: () => void, delay: number): any {
|
|
131
|
-
return setTimeout(fn, delay);
|
|
132
|
-
},
|
|
133
|
-
|
|
134
|
-
cancelTimeout(id): void {
|
|
135
|
-
clearTimeout(id);
|
|
136
|
-
},
|
|
137
|
-
|
|
138
|
-
insertBefore(parent: ForgeDoc, child: ForgeDoc, beforeChild: ForgeDoc): void {
|
|
139
|
-
insertBefore(parent, child, beforeChild);
|
|
140
|
-
},
|
|
141
|
-
|
|
142
|
-
insertInContainerBefore(container: ForgeDoc, child: ForgeDoc, beforeChild: ForgeDoc): void {
|
|
143
|
-
insertBefore(container, child, beforeChild);
|
|
144
|
-
},
|
|
145
|
-
|
|
146
|
-
removeChild(parent: ForgeDoc, child: ForgeDoc): void {
|
|
147
|
-
const removeIndex = parent.children.indexOf(child);
|
|
148
|
-
parent.children.splice(removeIndex, 1);
|
|
149
|
-
},
|
|
150
|
-
|
|
151
|
-
removeChildFromContainer(container: ForgeDoc, child: ForgeDoc): void {
|
|
152
|
-
const removeIndex = container.children.indexOf(child);
|
|
153
|
-
container.children.splice(removeIndex, 1);
|
|
154
|
-
},
|
|
155
|
-
|
|
156
|
-
resetTextContent(): void {},
|
|
157
|
-
|
|
158
|
-
commitTextUpdate(textInstance: ForgeDoc, oldText: string, newText: string): void {
|
|
159
|
-
textInstance.props.text = newText;
|
|
160
|
-
},
|
|
161
|
-
|
|
162
|
-
commitMount(): void {},
|
|
163
|
-
|
|
164
|
-
commitUpdate(): void {},
|
|
165
|
-
|
|
166
|
-
hideInstance(): void {},
|
|
167
|
-
|
|
168
|
-
hideTextInstance(): void {},
|
|
169
|
-
|
|
170
|
-
unhideInstance(): void {},
|
|
171
|
-
|
|
172
|
-
unhideTextInstance(): void {},
|
|
173
|
-
|
|
174
|
-
clearContainer(): void {},
|
|
175
|
-
|
|
176
|
-
detachDeletedInstance(instance: ForgeDoc): void {},
|
|
177
|
-
|
|
178
|
-
getCurrentEventPriority() {
|
|
179
|
-
return DefaultEventPriority;
|
|
180
|
-
},
|
|
181
|
-
|
|
182
|
-
getInstanceFromNode(): null {
|
|
183
|
-
return null;
|
|
184
|
-
},
|
|
185
|
-
|
|
186
|
-
beforeActiveInstanceBlur(): void {},
|
|
187
|
-
|
|
188
|
-
afterActiveInstanceBlur(): void {},
|
|
189
|
-
|
|
190
|
-
prepareScopeUpdate(): void {},
|
|
191
|
-
|
|
192
|
-
getInstanceFromScope(): null {
|
|
193
|
-
return null;
|
|
194
|
-
}
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
const reconciler = Reconciler(hostConfig);
|
|
198
|
-
|
|
199
|
-
export const ForgeReconciler = {
|
|
200
|
-
render: (element: any): void => {
|
|
201
|
-
const rootElement = createElement('Root');
|
|
202
|
-
const container = reconciler.createContainer(
|
|
203
|
-
rootElement,
|
|
204
|
-
0,
|
|
205
|
-
null,
|
|
206
|
-
false,
|
|
207
|
-
null,
|
|
208
|
-
'root',
|
|
209
|
-
(err: any) => {
|
|
210
|
-
// eslint-disable-next-line no-console
|
|
211
|
-
console.log(err);
|
|
212
|
-
},
|
|
213
|
-
null
|
|
214
|
-
);
|
|
215
|
-
reconciler.updateContainer(element, container, null, null);
|
|
216
|
-
}
|
|
217
|
-
};
|
|
218
|
-
|
|
219
|
-
export default ForgeReconciler;
|