@forge/react 8.0.0 → 8.0.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 +14 -0
- package/out/__test__/reconciler.test.d.ts +2 -0
- package/out/__test__/reconciler.test.d.ts.map +1 -0
- package/out/__test__/reconciler.test.js +224 -0
- package/out/__test__/reconcilerTestRenderer.d.ts +13 -0
- package/out/__test__/reconcilerTestRenderer.d.ts.map +1 -0
- package/out/__test__/reconcilerTestRenderer.js +18 -0
- package/out/__test__/table.test.d.ts +2 -0
- package/out/__test__/table.test.d.ts.map +1 -0
- package/out/__test__/table.test.js +25 -0
- package/out/reconciler.d.ts +35 -1
- package/out/reconciler.d.ts.map +1 -1
- package/out/reconciler.js +25 -19
- package/out/types/components.d.ts +55 -29
- package/out/types/components.d.ts.map +1 -1
- package/out/types/effect.d.ts +5 -5
- package/out/types/effect.d.ts.map +1 -1
- package/out/types/forge.d.ts +6 -6
- package/out/types/forge.d.ts.map +1 -1
- package/out/types/icons.d.ts +1 -1
- package/out/types/icons.d.ts.map +1 -1
- package/out/types/index.d.ts +1 -1
- package/out/types/index.d.ts.map +1 -1
- package/out/types/legacy-effect.d.ts +3 -3
- package/out/types/legacy-effect.d.ts.map +1 -1
- package/out/types/styles.d.ts +30 -30
- package/out/types/styles.d.ts.map +1 -1
- package/package.json +4 -2
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @forge/react
|
|
2
2
|
|
|
3
|
+
## 8.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [732c136]
|
|
8
|
+
- @forge/ui@1.9.1
|
|
9
|
+
|
|
10
|
+
## 8.0.1-next.0
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies [732c136a]
|
|
15
|
+
- @forge/ui@1.9.1-next.0
|
|
16
|
+
|
|
3
17
|
## 8.0.0
|
|
4
18
|
|
|
5
19
|
### Major Changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reconciler.test.d.ts","sourceRoot":"","sources":["../../src/__test__/reconciler.test.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const reconciler_1 = require("../reconciler");
|
|
4
|
+
const emptyForgeDoc = (0, reconciler_1.createElement)('root');
|
|
5
|
+
describe('hostConfig used functions', () => {
|
|
6
|
+
it('resetAfterCommit should call bridge', () => {
|
|
7
|
+
let output;
|
|
8
|
+
global['self'] = {
|
|
9
|
+
__bridge: {
|
|
10
|
+
callBridge: (cmd, data) => {
|
|
11
|
+
output = data;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
const testDoc = (0, reconciler_1.createElement)('root');
|
|
16
|
+
reconciler_1.hostConfig.resetAfterCommit(testDoc);
|
|
17
|
+
expect(output).toEqual({
|
|
18
|
+
forgeDoc: testDoc
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
it('createInstance returns empty ForgeDoc', () => {
|
|
22
|
+
const testProps = {
|
|
23
|
+
test: true
|
|
24
|
+
};
|
|
25
|
+
const instance = reconciler_1.hostConfig.createInstance('test', testProps, emptyForgeDoc, null, null);
|
|
26
|
+
expect(instance).toEqual(expect.objectContaining({
|
|
27
|
+
type: 'test',
|
|
28
|
+
children: [],
|
|
29
|
+
props: {
|
|
30
|
+
test: true
|
|
31
|
+
},
|
|
32
|
+
key: expect.any(String)
|
|
33
|
+
}));
|
|
34
|
+
});
|
|
35
|
+
it('createTextInstance returns ForgeDoc with UUID', () => {
|
|
36
|
+
const testDoc = (0, reconciler_1.createElement)('root');
|
|
37
|
+
const textInstance = reconciler_1.hostConfig.createTextInstance('test', testDoc, null, null);
|
|
38
|
+
expect(textInstance).toEqual(expect.objectContaining({
|
|
39
|
+
type: 'String',
|
|
40
|
+
children: [],
|
|
41
|
+
props: {
|
|
42
|
+
text: 'test'
|
|
43
|
+
},
|
|
44
|
+
key: expect.any(String)
|
|
45
|
+
}));
|
|
46
|
+
});
|
|
47
|
+
it('appendInitialChild adds child to empty children array', () => {
|
|
48
|
+
const parent = (0, reconciler_1.createElement)('parent');
|
|
49
|
+
const child = (0, reconciler_1.createElement)('child');
|
|
50
|
+
expect(parent).toHaveProperty('children', []);
|
|
51
|
+
reconciler_1.hostConfig.appendInitialChild(parent, child);
|
|
52
|
+
expect(parent).toHaveProperty('children', [child]);
|
|
53
|
+
});
|
|
54
|
+
it('appendChild does not append same child twice', () => {
|
|
55
|
+
expect(reconciler_1.hostConfig).toHaveProperty('appendChild');
|
|
56
|
+
if (reconciler_1.hostConfig.appendChild !== undefined) {
|
|
57
|
+
const parent = (0, reconciler_1.createElement)('parent');
|
|
58
|
+
const child = (0, reconciler_1.createElement)('child');
|
|
59
|
+
expect(parent).toHaveProperty('children', []);
|
|
60
|
+
reconciler_1.hostConfig.appendChild(parent, child);
|
|
61
|
+
expect(parent).toHaveProperty('children', [child]);
|
|
62
|
+
reconciler_1.hostConfig.appendChild(parent, child);
|
|
63
|
+
expect(parent).toHaveProperty('children', [child]);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
it('appendChildToContainer', () => {
|
|
67
|
+
expect(reconciler_1.hostConfig).toHaveProperty('appendChildToContainer');
|
|
68
|
+
if (reconciler_1.hostConfig.appendChildToContainer !== undefined) {
|
|
69
|
+
const parent = (0, reconciler_1.createElement)('parent');
|
|
70
|
+
const child = (0, reconciler_1.createElement)('child');
|
|
71
|
+
expect(parent).toHaveProperty('children', []);
|
|
72
|
+
reconciler_1.hostConfig.appendChildToContainer(parent, child);
|
|
73
|
+
expect(parent).toHaveProperty('children', [child]);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
it('finalizeInitialChildren returns false', () => {
|
|
77
|
+
expect(reconciler_1.hostConfig.finalizeInitialChildren(emptyForgeDoc, 'test', {}, emptyForgeDoc, null)).toBe(false);
|
|
78
|
+
});
|
|
79
|
+
it('prepareUpdate should set new props as props on instance', () => {
|
|
80
|
+
const instance = (0, reconciler_1.createElement)('test', { oldProps: true });
|
|
81
|
+
const newProps = {
|
|
82
|
+
updated: true
|
|
83
|
+
};
|
|
84
|
+
expect(reconciler_1.hostConfig.prepareUpdate(instance, 'test', {}, newProps, emptyForgeDoc, null)).toBe(newProps);
|
|
85
|
+
expect(instance).not.toHaveProperty('oldProps');
|
|
86
|
+
expect(instance).toHaveProperty('props', newProps);
|
|
87
|
+
});
|
|
88
|
+
it('shouldSetTextContent returns false', () => {
|
|
89
|
+
expect(reconciler_1.hostConfig.shouldSetTextContent('test', {})).toBe(false);
|
|
90
|
+
});
|
|
91
|
+
it('insertBefore reorders children', () => {
|
|
92
|
+
expect(reconciler_1.hostConfig).toHaveProperty('insertBefore');
|
|
93
|
+
if (reconciler_1.hostConfig.insertBefore !== undefined) {
|
|
94
|
+
const parent = (0, reconciler_1.createElement)('parent');
|
|
95
|
+
const child1 = (0, reconciler_1.createElement)('child1');
|
|
96
|
+
const child2 = (0, reconciler_1.createElement)('child2');
|
|
97
|
+
reconciler_1.hostConfig.appendInitialChild(parent, child1);
|
|
98
|
+
expect(parent).toHaveProperty('children', [child1]);
|
|
99
|
+
reconciler_1.hostConfig.insertBefore(parent, child2, child1);
|
|
100
|
+
expect(parent).toHaveProperty('children', [child2, child1]);
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
it('insertInContainerBefore reorders children when child being inserted exists', () => {
|
|
104
|
+
expect(reconciler_1.hostConfig).toHaveProperty('insertInContainerBefore');
|
|
105
|
+
if (reconciler_1.hostConfig.insertInContainerBefore !== undefined) {
|
|
106
|
+
const parent = (0, reconciler_1.createElement)('parent');
|
|
107
|
+
const child1 = (0, reconciler_1.createElement)('child1');
|
|
108
|
+
const child2 = (0, reconciler_1.createElement)('child2');
|
|
109
|
+
reconciler_1.hostConfig.appendInitialChild(parent, child1);
|
|
110
|
+
reconciler_1.hostConfig.appendInitialChild(parent, child2);
|
|
111
|
+
expect(parent).toHaveProperty('children', [child1, child2]);
|
|
112
|
+
reconciler_1.hostConfig.insertInContainerBefore(parent, child2, child1);
|
|
113
|
+
expect(parent).toHaveProperty('children', [child2, child1]);
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
it('removeChild removes child', () => {
|
|
117
|
+
expect(reconciler_1.hostConfig).toHaveProperty('removeChild');
|
|
118
|
+
if (reconciler_1.hostConfig.removeChild !== undefined) {
|
|
119
|
+
const parent = (0, reconciler_1.createElement)('parent');
|
|
120
|
+
const child = (0, reconciler_1.createElement)('child');
|
|
121
|
+
expect(parent).toHaveProperty('children', []);
|
|
122
|
+
reconciler_1.hostConfig.appendInitialChild(parent, child);
|
|
123
|
+
expect(parent).toHaveProperty('children', [child]);
|
|
124
|
+
reconciler_1.hostConfig.removeChild(parent, child);
|
|
125
|
+
expect(parent).toHaveProperty('children', []);
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
it('removeChildFromContainer removes child', () => {
|
|
129
|
+
expect(reconciler_1.hostConfig).toHaveProperty('removeChildFromContainer');
|
|
130
|
+
if (reconciler_1.hostConfig.removeChildFromContainer !== undefined) {
|
|
131
|
+
const parent = (0, reconciler_1.createElement)('parent');
|
|
132
|
+
const child = (0, reconciler_1.createElement)('child');
|
|
133
|
+
expect(parent).toHaveProperty('children', []);
|
|
134
|
+
reconciler_1.hostConfig.appendInitialChild(parent, child);
|
|
135
|
+
expect(parent).toHaveProperty('children', [child]);
|
|
136
|
+
reconciler_1.hostConfig.removeChildFromContainer(parent, child);
|
|
137
|
+
expect(parent).toHaveProperty('children', []);
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
it('commitTextUpdate should update instance props', () => {
|
|
141
|
+
expect(reconciler_1.hostConfig).toHaveProperty('commitTextUpdate');
|
|
142
|
+
if (reconciler_1.hostConfig.commitTextUpdate !== undefined) {
|
|
143
|
+
const testDoc = (0, reconciler_1.createElement)('root');
|
|
144
|
+
const textInstance = reconciler_1.hostConfig.createTextInstance('test', testDoc, null, null);
|
|
145
|
+
reconciler_1.hostConfig.commitTextUpdate(textInstance, '', 'updated');
|
|
146
|
+
expect(textInstance).toEqual(expect.objectContaining({
|
|
147
|
+
type: 'String',
|
|
148
|
+
children: [],
|
|
149
|
+
props: {
|
|
150
|
+
text: 'updated'
|
|
151
|
+
},
|
|
152
|
+
key: expect.any(String)
|
|
153
|
+
}));
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
describe('hostConfig unused functions', () => {
|
|
158
|
+
it('should return empty object from getRootHostContext', () => {
|
|
159
|
+
expect(reconciler_1.hostConfig.getRootHostContext(emptyForgeDoc)).toEqual({});
|
|
160
|
+
});
|
|
161
|
+
it('should return null from getChildHostContext', () => {
|
|
162
|
+
expect(reconciler_1.hostConfig.getChildHostContext(null, 'test', emptyForgeDoc)).toBeNull();
|
|
163
|
+
});
|
|
164
|
+
it('should return supplied value to getPublicInstance', () => {
|
|
165
|
+
expect(reconciler_1.hostConfig.getPublicInstance(emptyForgeDoc)).toBe(emptyForgeDoc);
|
|
166
|
+
});
|
|
167
|
+
it('should return null from prepareForCommit', () => {
|
|
168
|
+
expect(reconciler_1.hostConfig.prepareForCommit(emptyForgeDoc)).toBeNull();
|
|
169
|
+
});
|
|
170
|
+
it('should return undefined from preparePortalMount', () => {
|
|
171
|
+
expect(reconciler_1.hostConfig.preparePortalMount(emptyForgeDoc)).toBeUndefined();
|
|
172
|
+
});
|
|
173
|
+
it('should return undefined from resetTextContent', () => {
|
|
174
|
+
if (reconciler_1.hostConfig.resetTextContent !== undefined) {
|
|
175
|
+
expect(reconciler_1.hostConfig.resetTextContent(emptyForgeDoc)).toBeUndefined();
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
it('should return undefined from commitMount', () => {
|
|
179
|
+
if (reconciler_1.hostConfig.commitMount !== undefined) {
|
|
180
|
+
expect(reconciler_1.hostConfig.commitMount(emptyForgeDoc, 'test', {}, null)).toBeUndefined();
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
it('should return undefined from commitUpdate', () => {
|
|
184
|
+
if (reconciler_1.hostConfig.commitUpdate !== undefined) {
|
|
185
|
+
expect(reconciler_1.hostConfig.commitUpdate(emptyForgeDoc, {}, 'test', {}, {}, null)).toBeUndefined();
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
it('should return undefined from hideInstance', () => {
|
|
189
|
+
if (reconciler_1.hostConfig.hideInstance !== undefined) {
|
|
190
|
+
expect(reconciler_1.hostConfig.hideInstance(emptyForgeDoc)).toBeUndefined();
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
it('should return undefined from unhideTextInstance', () => {
|
|
194
|
+
if (reconciler_1.hostConfig.unhideTextInstance !== undefined) {
|
|
195
|
+
expect(reconciler_1.hostConfig.unhideTextInstance(emptyForgeDoc, 'Test')).toBeUndefined();
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
it('should return undefined from clearContainer', () => {
|
|
199
|
+
if (reconciler_1.hostConfig.clearContainer !== undefined) {
|
|
200
|
+
expect(reconciler_1.hostConfig.clearContainer(emptyForgeDoc)).toBeUndefined();
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
it('should return undefined from detachDeletedInstance', () => {
|
|
204
|
+
expect(reconciler_1.hostConfig.detachDeletedInstance(emptyForgeDoc)).toBeUndefined();
|
|
205
|
+
});
|
|
206
|
+
it('should return undefined from getCurrentEventPriority', () => {
|
|
207
|
+
expect(reconciler_1.hostConfig.getCurrentEventPriority()).toBe(16);
|
|
208
|
+
});
|
|
209
|
+
it('should return null from getInstanceFromNode', () => {
|
|
210
|
+
expect(reconciler_1.hostConfig.getInstanceFromNode(null)).toBeNull();
|
|
211
|
+
});
|
|
212
|
+
it('should return undefined from beforeActiveInstanceBlur', () => {
|
|
213
|
+
expect(reconciler_1.hostConfig.beforeActiveInstanceBlur()).toBeUndefined();
|
|
214
|
+
});
|
|
215
|
+
it('should return undefined from afterActiveInstanceBlur', () => {
|
|
216
|
+
expect(reconciler_1.hostConfig.afterActiveInstanceBlur()).toBeUndefined();
|
|
217
|
+
});
|
|
218
|
+
it('should return undefined from prepareScopeUpdate', () => {
|
|
219
|
+
expect(reconciler_1.hostConfig.prepareScopeUpdate(null, null)).toBeUndefined();
|
|
220
|
+
});
|
|
221
|
+
it('should return null from getInstanceFromScope', () => {
|
|
222
|
+
expect(reconciler_1.hostConfig.getInstanceFromScope(null)).toBeNull();
|
|
223
|
+
});
|
|
224
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
type Act = (cb: () => Promise<any>) => Promise<any>;
|
|
3
|
+
export declare const create: (element: React.ReactNode) => Promise<{
|
|
4
|
+
update(newElement: React.ReactNode): Promise<void>;
|
|
5
|
+
}>;
|
|
6
|
+
declare const _default: {
|
|
7
|
+
create: (element: React.ReactNode) => Promise<{
|
|
8
|
+
update(newElement: React.ReactNode): Promise<void>;
|
|
9
|
+
}>;
|
|
10
|
+
act: Act;
|
|
11
|
+
};
|
|
12
|
+
export default _default;
|
|
13
|
+
//# sourceMappingURL=reconcilerTestRenderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reconcilerTestRenderer.d.ts","sourceRoot":"","sources":["../../src/__test__/reconcilerTestRenderer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAQ/B,KAAK,GAAG,GAAG,CAAC,EAAE,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;AAIpD,eAAO,MAAM,MAAM,YAAmB,MAAM,SAAS;uBAGxB,MAAM,SAAS;EAI3C,CAAC;;;;;;;AAEF,wBAA+B"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.create = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const React = tslib_1.__importStar(require("react"));
|
|
6
|
+
const reconciler_1 = require("../reconciler");
|
|
7
|
+
const _act = React.unstable_act;
|
|
8
|
+
const act = _act;
|
|
9
|
+
const create = async (element) => {
|
|
10
|
+
await act(async () => reconciler_1.ForgeReconciler.render(element));
|
|
11
|
+
return {
|
|
12
|
+
async update(newElement) {
|
|
13
|
+
await act(async () => reconciler_1.ForgeReconciler.render(newElement));
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
exports.create = create;
|
|
18
|
+
exports.default = { create: exports.create, act };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table.test.d.ts","sourceRoot":"","sources":["../../src/__test__/table.test.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
|
+
const components_1 = require("../components");
|
|
7
|
+
const reconcilerTestRenderer_1 = tslib_1.__importDefault(require("./reconcilerTestRenderer"));
|
|
8
|
+
describe('reconciled output', () => {
|
|
9
|
+
it('renders legacy Table ForgeDoc', async () => {
|
|
10
|
+
let output = undefined;
|
|
11
|
+
global['self'] = {
|
|
12
|
+
__bridge: {
|
|
13
|
+
callBridge: (cmd, data) => {
|
|
14
|
+
output = data;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
const Test = () => {
|
|
19
|
+
return ((0, jsx_runtime_1.jsx)(react_1.default.Fragment, { children: (0, jsx_runtime_1.jsxs)(components_1.Table, Object.assign({ rowsPerPage: 2 }, { children: [(0, jsx_runtime_1.jsxs)(components_1.Head, { children: [(0, jsx_runtime_1.jsx)(components_1.Cell, { children: (0, jsx_runtime_1.jsx)(components_1.Text, { children: "Issue Key" }) }), (0, jsx_runtime_1.jsx)(components_1.Cell, { children: (0, jsx_runtime_1.jsx)(components_1.Text, { children: "Status" }) })] }), (0, jsx_runtime_1.jsxs)(components_1.Row, { children: [(0, jsx_runtime_1.jsx)(components_1.Cell, { children: (0, jsx_runtime_1.jsx)(components_1.Text, { children: "XEN-1" }) }), (0, jsx_runtime_1.jsx)(components_1.Cell, { children: (0, jsx_runtime_1.jsx)(components_1.Text, { children: "In Progress" }) })] }), (0, jsx_runtime_1.jsxs)(components_1.Row, { children: [(0, jsx_runtime_1.jsx)(components_1.Cell, { children: (0, jsx_runtime_1.jsx)(components_1.Text, { children: "XEN-2" }) }), (0, jsx_runtime_1.jsx)(components_1.Cell, { children: (0, jsx_runtime_1.jsx)(components_1.Text, { children: "To Do" }) })] }), (0, jsx_runtime_1.jsxs)(components_1.Row, { children: [(0, jsx_runtime_1.jsx)(components_1.Cell, { children: (0, jsx_runtime_1.jsx)(components_1.Text, { children: "XEN-3" }) }), (0, jsx_runtime_1.jsx)(components_1.Cell, { children: (0, jsx_runtime_1.jsx)(components_1.Text, { children: "Done" }) })] }), (0, jsx_runtime_1.jsxs)(components_1.Row, { children: [(0, jsx_runtime_1.jsx)(components_1.Cell, { children: (0, jsx_runtime_1.jsx)(components_1.Text, { children: "XEN-4" }) }), (0, jsx_runtime_1.jsx)(components_1.Cell, { children: (0, jsx_runtime_1.jsx)(components_1.Text, { children: "In Progress" }) })] }), (0, jsx_runtime_1.jsxs)(components_1.Row, { children: [(0, jsx_runtime_1.jsx)(components_1.Cell, { children: (0, jsx_runtime_1.jsx)(components_1.Text, { children: "XEN-5" }) }), (0, jsx_runtime_1.jsx)(components_1.Cell, { children: (0, jsx_runtime_1.jsx)(components_1.Text, { children: "Cancelled" }) })] })] })) }));
|
|
20
|
+
};
|
|
21
|
+
await reconcilerTestRenderer_1.default.create((0, jsx_runtime_1.jsx)(Test, {}));
|
|
22
|
+
expect(output).toHaveProperty('forgeDoc.type', 'Root');
|
|
23
|
+
expect(output).toHaveProperty('forgeDoc.children[0].type', 'Table');
|
|
24
|
+
});
|
|
25
|
+
});
|
package/out/reconciler.d.ts
CHANGED
|
@@ -1,5 +1,39 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { HostConfig } from 'react-reconciler';
|
|
4
|
+
type ElementType = string;
|
|
5
|
+
type ElementProps = {
|
|
6
|
+
[key: string]: any;
|
|
7
|
+
};
|
|
8
|
+
export interface ForgeDoc {
|
|
9
|
+
type: ElementType;
|
|
10
|
+
props: ElementProps;
|
|
11
|
+
children: ForgeDoc[];
|
|
12
|
+
key: string;
|
|
13
|
+
}
|
|
14
|
+
export type CallBridge = (cmd: string, data: {
|
|
15
|
+
forgeDoc: ForgeDoc;
|
|
16
|
+
}) => void;
|
|
17
|
+
export declare const callBridge: CallBridge;
|
|
18
|
+
export declare const createElement: (type: ElementType, props?: ElementProps) => ForgeDoc;
|
|
19
|
+
export declare const appendChild: (parent: ForgeDoc, child: ForgeDoc) => void;
|
|
20
|
+
export declare const insertBefore: (parent: ForgeDoc, child: ForgeDoc, beforeChild: ForgeDoc) => void;
|
|
21
|
+
type HostConfigType = string;
|
|
22
|
+
type InstanceProps = Record<string, any>;
|
|
23
|
+
type Container = ForgeDoc;
|
|
24
|
+
type Instance = ForgeDoc;
|
|
25
|
+
type TextInstance = ForgeDoc;
|
|
26
|
+
type SuspenseInstance = ForgeDoc;
|
|
27
|
+
type HydratableInstance = ForgeDoc;
|
|
28
|
+
type PublicInstance = ForgeDoc;
|
|
29
|
+
type HostContext = any;
|
|
30
|
+
type UpdatePayload = any;
|
|
31
|
+
type ChildSet = any;
|
|
32
|
+
type TimeoutHandle = ReturnType<typeof setTimeout>;
|
|
33
|
+
type NoTimeout = -1;
|
|
34
|
+
export declare const hostConfig: HostConfig<HostConfigType, InstanceProps, Container, Instance, TextInstance, SuspenseInstance, HydratableInstance, PublicInstance, HostContext, UpdatePayload, ChildSet, TimeoutHandle, NoTimeout>;
|
|
1
35
|
export declare const ForgeReconciler: {
|
|
2
|
-
render: (element:
|
|
36
|
+
render: (element: ReactNode) => void;
|
|
3
37
|
};
|
|
4
38
|
export default ForgeReconciler;
|
|
5
39
|
//# sourceMappingURL=reconciler.d.ts.map
|
package/out/reconciler.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reconciler.d.ts","sourceRoot":"","sources":["../src/reconciler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"reconciler.d.ts","sourceRoot":"","sources":["../src/reconciler.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAmB,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAI1D,KAAK,WAAW,GAAG,MAAM,CAAC;AAE1B,KAAK,YAAY,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,CAAC;AAE3C,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,WAAW,CAAC;IAClB,KAAK,EAAE,YAAY,CAAC;IACpB,QAAQ,EAAE,QAAQ,EAAE,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,MAAM,UAAU,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE;IAAE,QAAQ,EAAE,QAAQ,CAAA;CAAE,KAAK,IAAI,CAAC;AAC7E,eAAO,MAAM,UAAU,EAAE,UAGxB,CAAC;AAEF,eAAO,MAAM,aAAa,SAAU,WAAW,UAAS,YAAY,KAAQ,QAS3E,CAAC;AAEF,eAAO,MAAM,WAAW,WAAY,QAAQ,SAAS,QAAQ,SAM5D,CAAC;AAEF,eAAO,MAAM,YAAY,WAAY,QAAQ,SAAS,QAAQ,eAAe,QAAQ,SAOpF,CAAC;AAEF,KAAK,cAAc,GAAG,MAAM,CAAC;AAE7B,KAAK,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AACzC,KAAK,SAAS,GAAG,QAAQ,CAAC;AAC1B,KAAK,QAAQ,GAAG,QAAQ,CAAC;AACzB,KAAK,YAAY,GAAG,QAAQ,CAAC;AAC7B,KAAK,gBAAgB,GAAG,QAAQ,CAAC;AACjC,KAAK,kBAAkB,GAAG,QAAQ,CAAC;AACnC,KAAK,cAAc,GAAG,QAAQ,CAAC;AAE/B,KAAK,WAAW,GAAG,GAAG,CAAC;AAEvB,KAAK,aAAa,GAAG,GAAG,CAAC;AAEzB,KAAK,QAAQ,GAAG,GAAG,CAAC;AACpB,KAAK,aAAa,GAAG,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC;AACnD,KAAK,SAAS,GAAG,CAAC,CAAC,CAAC;AAEpB,eAAO,MAAM,UAAU,EAAE,UAAU,CACjC,cAAc,EACd,aAAa,EACb,SAAS,EACT,QAAQ,EACR,YAAY,EACZ,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,EACd,WAAW,EACX,aAAa,EACb,QAAQ,EACR,aAAa,EACb,SAAS,CAqJV,CAAC;AAIF,eAAO,MAAM,eAAe;sBACR,SAAS;CAiB5B,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
package/out/reconciler.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var _a;
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.ForgeReconciler = void 0;
|
|
3
|
+
exports.ForgeReconciler = exports.hostConfig = exports.insertBefore = exports.appendChild = exports.createElement = exports.callBridge = void 0;
|
|
5
4
|
const tslib_1 = require("tslib");
|
|
6
5
|
const react_reconciler_1 = tslib_1.__importDefault(require("react-reconciler"));
|
|
7
6
|
const constants_1 = require("react-reconciler/constants");
|
|
8
7
|
const uuid_1 = require("uuid");
|
|
9
|
-
const callBridge = (
|
|
8
|
+
const callBridge = function (cmd, data) {
|
|
9
|
+
var _a;
|
|
10
|
+
(_a = self === null || self === void 0 ? void 0 : self.__bridge) === null || _a === void 0 ? void 0 : _a.callBridge(cmd, data);
|
|
11
|
+
};
|
|
12
|
+
exports.callBridge = callBridge;
|
|
10
13
|
const createElement = (type, props = {}) => {
|
|
11
14
|
const { children } = props, restProps = tslib_1.__rest(props, ["children"]);
|
|
12
15
|
return {
|
|
@@ -16,6 +19,7 @@ const createElement = (type, props = {}) => {
|
|
|
16
19
|
key: (0, uuid_1.v4)()
|
|
17
20
|
};
|
|
18
21
|
};
|
|
22
|
+
exports.createElement = createElement;
|
|
19
23
|
const appendChild = (parent, child) => {
|
|
20
24
|
if (parent.children.includes(child)) {
|
|
21
25
|
const removeIndex = parent.children.indexOf(child);
|
|
@@ -23,6 +27,7 @@ const appendChild = (parent, child) => {
|
|
|
23
27
|
}
|
|
24
28
|
parent.children.push(child);
|
|
25
29
|
};
|
|
30
|
+
exports.appendChild = appendChild;
|
|
26
31
|
const insertBefore = (parent, child, beforeChild) => {
|
|
27
32
|
const insertIndex = parent.children.indexOf(beforeChild);
|
|
28
33
|
if (parent.children.includes(child)) {
|
|
@@ -31,17 +36,18 @@ const insertBefore = (parent, child, beforeChild) => {
|
|
|
31
36
|
}
|
|
32
37
|
parent.children.splice(insertIndex, 0, child);
|
|
33
38
|
};
|
|
34
|
-
|
|
39
|
+
exports.insertBefore = insertBefore;
|
|
40
|
+
exports.hostConfig = {
|
|
35
41
|
supportsMutation: true,
|
|
36
42
|
supportsPersistence: false,
|
|
37
43
|
noTimeout: -1,
|
|
38
44
|
isPrimaryRenderer: false,
|
|
39
45
|
supportsHydration: false,
|
|
40
|
-
resetAfterCommit(
|
|
41
|
-
callBridge('reconcile', { forgeDoc });
|
|
46
|
+
resetAfterCommit(containerInfo) {
|
|
47
|
+
(0, exports.callBridge)('reconcile', { forgeDoc: containerInfo });
|
|
42
48
|
},
|
|
43
|
-
createInstance(type,
|
|
44
|
-
const element = createElement(type,
|
|
49
|
+
createInstance(type, instanceProps) {
|
|
50
|
+
const element = (0, exports.createElement)(type, instanceProps);
|
|
45
51
|
return element;
|
|
46
52
|
},
|
|
47
53
|
createTextInstance(text) {
|
|
@@ -54,14 +60,14 @@ const hostConfig = {
|
|
|
54
60
|
key: (0, uuid_1.v4)()
|
|
55
61
|
};
|
|
56
62
|
},
|
|
57
|
-
appendInitialChild(
|
|
58
|
-
appendChild(
|
|
63
|
+
appendInitialChild(parentInstance, child) {
|
|
64
|
+
(0, exports.appendChild)(parentInstance, child);
|
|
59
65
|
},
|
|
60
66
|
appendChild(parent, child) {
|
|
61
|
-
appendChild(parent, child);
|
|
67
|
+
(0, exports.appendChild)(parent, child);
|
|
62
68
|
},
|
|
63
69
|
appendChildToContainer(container, child) {
|
|
64
|
-
appendChild(container, child);
|
|
70
|
+
(0, exports.appendChild)(container, child);
|
|
65
71
|
},
|
|
66
72
|
finalizeInitialChildren() {
|
|
67
73
|
return false;
|
|
@@ -76,7 +82,7 @@ const hostConfig = {
|
|
|
76
82
|
getRootHostContext() {
|
|
77
83
|
return {};
|
|
78
84
|
},
|
|
79
|
-
getChildHostContext(
|
|
85
|
+
getChildHostContext() {
|
|
80
86
|
return null;
|
|
81
87
|
},
|
|
82
88
|
getPublicInstance(instance) {
|
|
@@ -92,11 +98,11 @@ const hostConfig = {
|
|
|
92
98
|
cancelTimeout(id) {
|
|
93
99
|
clearTimeout(id);
|
|
94
100
|
},
|
|
95
|
-
insertBefore(
|
|
96
|
-
insertBefore(
|
|
101
|
+
insertBefore(parentInstance, child, beforeChild) {
|
|
102
|
+
(0, exports.insertBefore)(parentInstance, child, beforeChild);
|
|
97
103
|
},
|
|
98
104
|
insertInContainerBefore(container, child, beforeChild) {
|
|
99
|
-
insertBefore(container, child, beforeChild);
|
|
105
|
+
(0, exports.insertBefore)(container, child, beforeChild);
|
|
100
106
|
},
|
|
101
107
|
removeChild(parent, child) {
|
|
102
108
|
const removeIndex = parent.children.indexOf(child);
|
|
@@ -117,7 +123,7 @@ const hostConfig = {
|
|
|
117
123
|
unhideInstance() { },
|
|
118
124
|
unhideTextInstance() { },
|
|
119
125
|
clearContainer() { },
|
|
120
|
-
detachDeletedInstance(
|
|
126
|
+
detachDeletedInstance() { },
|
|
121
127
|
getCurrentEventPriority() {
|
|
122
128
|
return constants_1.DefaultEventPriority;
|
|
123
129
|
},
|
|
@@ -131,10 +137,10 @@ const hostConfig = {
|
|
|
131
137
|
return null;
|
|
132
138
|
}
|
|
133
139
|
};
|
|
134
|
-
const reconciler = (0, react_reconciler_1.default)(hostConfig);
|
|
140
|
+
const reconciler = (0, react_reconciler_1.default)(exports.hostConfig);
|
|
135
141
|
exports.ForgeReconciler = {
|
|
136
142
|
render: (element) => {
|
|
137
|
-
const rootElement = createElement('Root');
|
|
143
|
+
const rootElement = (0, exports.createElement)('Root');
|
|
138
144
|
const container = reconciler.createContainer(rootElement, 0, null, false, null, 'root', (err) => {
|
|
139
145
|
console.log(err);
|
|
140
146
|
}, null);
|