@forge/react 8.0.1-next.0 → 8.0.2-next.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/CHANGELOG.md +14 -0
- package/out/__test__/reconciler.test.js +73 -32
- package/out/__test__/reconcilerTestRenderer.d.ts +1 -1
- package/out/__test__/reconcilerTestRenderer.d.ts.map +1 -1
- package/out/__test__/table.test.js +8 -10
- package/out/__test__/testUtils.d.ts +13 -0
- package/out/__test__/testUtils.d.ts.map +1 -0
- package/out/__test__/testUtils.js +30 -0
- package/out/reconciler.d.ts +23 -19
- package/out/reconciler.d.ts.map +1 -1
- package/out/reconciler.js +15 -15
- package/out/types/components.d.ts +38 -38
- 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/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 +5 -2
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @forge/react
|
|
2
2
|
|
|
3
|
+
## 8.0.2-next.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [f48e6d8]
|
|
8
|
+
- @forge/ui@1.9.2-next.0
|
|
9
|
+
|
|
10
|
+
## 8.0.1
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies [732c136]
|
|
15
|
+
- @forge/ui@1.9.1
|
|
16
|
+
|
|
3
17
|
## 8.0.1-next.0
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -1,20 +1,58 @@
|
|
|
1
1
|
"use strict";
|
|
2
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.__importStar(require("react"));
|
|
3
6
|
const reconciler_1 = require("../reconciler");
|
|
4
|
-
const
|
|
7
|
+
const reconcilerTestRenderer_1 = tslib_1.__importDefault(require("./reconcilerTestRenderer"));
|
|
8
|
+
const components_1 = require("../components");
|
|
9
|
+
const get_1 = tslib_1.__importDefault(require("lodash/get"));
|
|
10
|
+
const testUtils_1 = require("./testUtils");
|
|
11
|
+
const emptyForgeDoc = (0, reconciler_1.createElement)({ type: 'root', props: {}, reconciliationCount: 0 });
|
|
12
|
+
const ButtonWithStatus = () => {
|
|
13
|
+
const [bool, setBool] = (0, react_1.useState)(true);
|
|
14
|
+
const appearance = bool ? 'inprogress' : 'success';
|
|
15
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(components_1.Button, Object.assign({ onClick: () => setBool(!bool) }, { children: "Click me!" })), (0, jsx_runtime_1.jsx)(components_1.Text, { children: (0, jsx_runtime_1.jsx)(components_1.StatusLozenge, Object.assign({ appearance: appearance }, { children: appearance })) })] }));
|
|
16
|
+
};
|
|
17
|
+
describe('Reconciliation counting', () => {
|
|
18
|
+
let bridgeCalls = [];
|
|
19
|
+
beforeAll(async () => {
|
|
20
|
+
bridgeCalls = (0, testUtils_1.setupBridge)();
|
|
21
|
+
const Test = () => {
|
|
22
|
+
return ((0, jsx_runtime_1.jsxs)(react_1.default.Fragment, { children: [(0, jsx_runtime_1.jsx)(ButtonWithStatus, {}), (0, jsx_runtime_1.jsx)(ButtonWithStatus, {})] }));
|
|
23
|
+
};
|
|
24
|
+
await reconcilerTestRenderer_1.default.create((0, jsx_runtime_1.jsx)(Test, {}));
|
|
25
|
+
});
|
|
26
|
+
it('initial reconcilation output is correct', () => {
|
|
27
|
+
const forgeDoc = (0, testUtils_1.getLastBridgeCallForgeDoc)(bridgeCalls);
|
|
28
|
+
expect(forgeDoc).toHaveProperty('forgeDoc.reconciliationCount', 1);
|
|
29
|
+
expect(forgeDoc).toHaveProperty('forgeDoc.children[0].props.onClick');
|
|
30
|
+
expect(forgeDoc).toHaveProperty('forgeDoc.children[0].reconciliationCount', 0);
|
|
31
|
+
expect(forgeDoc).toHaveProperty('forgeDoc.children[0].type', 'Button');
|
|
32
|
+
expect(forgeDoc).toHaveProperty('forgeDoc.children[2].type', 'Button');
|
|
33
|
+
});
|
|
34
|
+
it('calling the button click handler triggers reconciliation', () => {
|
|
35
|
+
const forgeDoc = (0, testUtils_1.getLastBridgeCallForgeDoc)(bridgeCalls);
|
|
36
|
+
const onClick = (0, get_1.default)(forgeDoc, 'forgeDoc.children[0].props.onClick');
|
|
37
|
+
if (onClick !== undefined) {
|
|
38
|
+
onClick();
|
|
39
|
+
const forgeDoc = (0, testUtils_1.getLastBridgeCallForgeDoc)(bridgeCalls);
|
|
40
|
+
expect(forgeDoc).toHaveProperty('forgeDoc.reconciliationCount', 2);
|
|
41
|
+
expect(forgeDoc).toHaveProperty('forgeDoc.children[0].reconciliationCount', 2);
|
|
42
|
+
expect(forgeDoc).toHaveProperty('forgeDoc.children[2].reconciliationCount', 0);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
});
|
|
5
46
|
describe('hostConfig used functions', () => {
|
|
47
|
+
let bridgeCalls = [];
|
|
48
|
+
beforeAll(async () => {
|
|
49
|
+
bridgeCalls = (0, testUtils_1.setupBridge)();
|
|
50
|
+
});
|
|
6
51
|
it('resetAfterCommit should call bridge', () => {
|
|
7
|
-
|
|
8
|
-
global['self'] = {
|
|
9
|
-
__bridge: {
|
|
10
|
-
callBridge: (cmd, data) => {
|
|
11
|
-
output = data;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
const testDoc = (0, reconciler_1.createElement)('root');
|
|
52
|
+
const testDoc = (0, reconciler_1.createElement)({ type: 'root', props: {}, reconciliationCount: 0 });
|
|
16
53
|
reconciler_1.hostConfig.resetAfterCommit(testDoc);
|
|
17
|
-
|
|
54
|
+
const forgeDoc = (0, testUtils_1.getLastBridgeCallForgeDoc)(bridgeCalls);
|
|
55
|
+
expect(forgeDoc).toEqual({
|
|
18
56
|
forgeDoc: testDoc
|
|
19
57
|
});
|
|
20
58
|
});
|
|
@@ -29,11 +67,12 @@ describe('hostConfig used functions', () => {
|
|
|
29
67
|
props: {
|
|
30
68
|
test: true
|
|
31
69
|
},
|
|
32
|
-
key: expect.any(String)
|
|
70
|
+
key: expect.any(String),
|
|
71
|
+
reconciliationCount: 0
|
|
33
72
|
}));
|
|
34
73
|
});
|
|
35
74
|
it('createTextInstance returns ForgeDoc with UUID', () => {
|
|
36
|
-
const testDoc = (0, reconciler_1.createElement)('root');
|
|
75
|
+
const testDoc = (0, reconciler_1.createElement)({ type: 'root', props: {}, reconciliationCount: 0 });
|
|
37
76
|
const textInstance = reconciler_1.hostConfig.createTextInstance('test', testDoc, null, null);
|
|
38
77
|
expect(textInstance).toEqual(expect.objectContaining({
|
|
39
78
|
type: 'String',
|
|
@@ -41,12 +80,13 @@ describe('hostConfig used functions', () => {
|
|
|
41
80
|
props: {
|
|
42
81
|
text: 'test'
|
|
43
82
|
},
|
|
44
|
-
key: expect.any(String)
|
|
83
|
+
key: expect.any(String),
|
|
84
|
+
reconciliationCount: 0
|
|
45
85
|
}));
|
|
46
86
|
});
|
|
47
87
|
it('appendInitialChild adds child to empty children array', () => {
|
|
48
|
-
const parent = (0, reconciler_1.createElement)('parent');
|
|
49
|
-
const child = (0, reconciler_1.createElement)('child');
|
|
88
|
+
const parent = (0, reconciler_1.createElement)({ type: 'parent', props: {}, reconciliationCount: 0 });
|
|
89
|
+
const child = (0, reconciler_1.createElement)({ type: 'child', props: {}, reconciliationCount: 0 });
|
|
50
90
|
expect(parent).toHaveProperty('children', []);
|
|
51
91
|
reconciler_1.hostConfig.appendInitialChild(parent, child);
|
|
52
92
|
expect(parent).toHaveProperty('children', [child]);
|
|
@@ -54,8 +94,8 @@ describe('hostConfig used functions', () => {
|
|
|
54
94
|
it('appendChild does not append same child twice', () => {
|
|
55
95
|
expect(reconciler_1.hostConfig).toHaveProperty('appendChild');
|
|
56
96
|
if (reconciler_1.hostConfig.appendChild !== undefined) {
|
|
57
|
-
const parent = (0, reconciler_1.createElement)('parent');
|
|
58
|
-
const child = (0, reconciler_1.createElement)('child');
|
|
97
|
+
const parent = (0, reconciler_1.createElement)({ type: 'parent', props: {}, reconciliationCount: 0 });
|
|
98
|
+
const child = (0, reconciler_1.createElement)({ type: 'child', props: {}, reconciliationCount: 0 });
|
|
59
99
|
expect(parent).toHaveProperty('children', []);
|
|
60
100
|
reconciler_1.hostConfig.appendChild(parent, child);
|
|
61
101
|
expect(parent).toHaveProperty('children', [child]);
|
|
@@ -66,8 +106,8 @@ describe('hostConfig used functions', () => {
|
|
|
66
106
|
it('appendChildToContainer', () => {
|
|
67
107
|
expect(reconciler_1.hostConfig).toHaveProperty('appendChildToContainer');
|
|
68
108
|
if (reconciler_1.hostConfig.appendChildToContainer !== undefined) {
|
|
69
|
-
const parent = (0, reconciler_1.createElement)('parent');
|
|
70
|
-
const child = (0, reconciler_1.createElement)('child');
|
|
109
|
+
const parent = (0, reconciler_1.createElement)({ type: 'parent', props: {}, reconciliationCount: 0 });
|
|
110
|
+
const child = (0, reconciler_1.createElement)({ type: 'child', props: {}, reconciliationCount: 0 });
|
|
71
111
|
expect(parent).toHaveProperty('children', []);
|
|
72
112
|
reconciler_1.hostConfig.appendChildToContainer(parent, child);
|
|
73
113
|
expect(parent).toHaveProperty('children', [child]);
|
|
@@ -77,13 +117,14 @@ describe('hostConfig used functions', () => {
|
|
|
77
117
|
expect(reconciler_1.hostConfig.finalizeInitialChildren(emptyForgeDoc, 'test', {}, emptyForgeDoc, null)).toBe(false);
|
|
78
118
|
});
|
|
79
119
|
it('prepareUpdate should set new props as props on instance', () => {
|
|
80
|
-
const instance = (0, reconciler_1.createElement)('test', { oldProps: true });
|
|
120
|
+
const instance = (0, reconciler_1.createElement)({ type: 'test', props: { oldProps: true }, reconciliationCount: 0 });
|
|
81
121
|
const newProps = {
|
|
82
122
|
updated: true
|
|
83
123
|
};
|
|
84
124
|
expect(reconciler_1.hostConfig.prepareUpdate(instance, 'test', {}, newProps, emptyForgeDoc, null)).toBe(newProps);
|
|
85
125
|
expect(instance).not.toHaveProperty('oldProps');
|
|
86
126
|
expect(instance).toHaveProperty('props', newProps);
|
|
127
|
+
expect(instance).toHaveProperty('reconciliationCount', 1);
|
|
87
128
|
});
|
|
88
129
|
it('shouldSetTextContent returns false', () => {
|
|
89
130
|
expect(reconciler_1.hostConfig.shouldSetTextContent('test', {})).toBe(false);
|
|
@@ -91,9 +132,9 @@ describe('hostConfig used functions', () => {
|
|
|
91
132
|
it('insertBefore reorders children', () => {
|
|
92
133
|
expect(reconciler_1.hostConfig).toHaveProperty('insertBefore');
|
|
93
134
|
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');
|
|
135
|
+
const parent = (0, reconciler_1.createElement)({ type: 'parent', props: {}, reconciliationCount: 0 });
|
|
136
|
+
const child1 = (0, reconciler_1.createElement)({ type: 'child1', props: {}, reconciliationCount: 0 });
|
|
137
|
+
const child2 = (0, reconciler_1.createElement)({ type: 'child2', props: {}, reconciliationCount: 0 });
|
|
97
138
|
reconciler_1.hostConfig.appendInitialChild(parent, child1);
|
|
98
139
|
expect(parent).toHaveProperty('children', [child1]);
|
|
99
140
|
reconciler_1.hostConfig.insertBefore(parent, child2, child1);
|
|
@@ -103,9 +144,9 @@ describe('hostConfig used functions', () => {
|
|
|
103
144
|
it('insertInContainerBefore reorders children when child being inserted exists', () => {
|
|
104
145
|
expect(reconciler_1.hostConfig).toHaveProperty('insertInContainerBefore');
|
|
105
146
|
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');
|
|
147
|
+
const parent = (0, reconciler_1.createElement)({ type: 'parent', props: {}, reconciliationCount: 0 });
|
|
148
|
+
const child1 = (0, reconciler_1.createElement)({ type: 'child1', props: {}, reconciliationCount: 0 });
|
|
149
|
+
const child2 = (0, reconciler_1.createElement)({ type: 'child2', props: {}, reconciliationCount: 0 });
|
|
109
150
|
reconciler_1.hostConfig.appendInitialChild(parent, child1);
|
|
110
151
|
reconciler_1.hostConfig.appendInitialChild(parent, child2);
|
|
111
152
|
expect(parent).toHaveProperty('children', [child1, child2]);
|
|
@@ -116,8 +157,8 @@ describe('hostConfig used functions', () => {
|
|
|
116
157
|
it('removeChild removes child', () => {
|
|
117
158
|
expect(reconciler_1.hostConfig).toHaveProperty('removeChild');
|
|
118
159
|
if (reconciler_1.hostConfig.removeChild !== undefined) {
|
|
119
|
-
const parent = (0, reconciler_1.createElement)('parent');
|
|
120
|
-
const child = (0, reconciler_1.createElement)('child');
|
|
160
|
+
const parent = (0, reconciler_1.createElement)({ type: 'parent', props: {}, reconciliationCount: 0 });
|
|
161
|
+
const child = (0, reconciler_1.createElement)({ type: 'child', props: {}, reconciliationCount: 0 });
|
|
121
162
|
expect(parent).toHaveProperty('children', []);
|
|
122
163
|
reconciler_1.hostConfig.appendInitialChild(parent, child);
|
|
123
164
|
expect(parent).toHaveProperty('children', [child]);
|
|
@@ -128,8 +169,8 @@ describe('hostConfig used functions', () => {
|
|
|
128
169
|
it('removeChildFromContainer removes child', () => {
|
|
129
170
|
expect(reconciler_1.hostConfig).toHaveProperty('removeChildFromContainer');
|
|
130
171
|
if (reconciler_1.hostConfig.removeChildFromContainer !== undefined) {
|
|
131
|
-
const parent = (0, reconciler_1.createElement)('parent');
|
|
132
|
-
const child = (0, reconciler_1.createElement)('child');
|
|
172
|
+
const parent = (0, reconciler_1.createElement)({ type: 'parent', props: {}, reconciliationCount: 0 });
|
|
173
|
+
const child = (0, reconciler_1.createElement)({ type: 'child', props: {}, reconciliationCount: 0 });
|
|
133
174
|
expect(parent).toHaveProperty('children', []);
|
|
134
175
|
reconciler_1.hostConfig.appendInitialChild(parent, child);
|
|
135
176
|
expect(parent).toHaveProperty('children', [child]);
|
|
@@ -140,7 +181,7 @@ describe('hostConfig used functions', () => {
|
|
|
140
181
|
it('commitTextUpdate should update instance props', () => {
|
|
141
182
|
expect(reconciler_1.hostConfig).toHaveProperty('commitTextUpdate');
|
|
142
183
|
if (reconciler_1.hostConfig.commitTextUpdate !== undefined) {
|
|
143
|
-
const testDoc = (0, reconciler_1.createElement)('root');
|
|
184
|
+
const testDoc = (0, reconciler_1.createElement)({ type: 'root', props: {}, reconciliationCount: 0 });
|
|
144
185
|
const textInstance = reconciler_1.hostConfig.createTextInstance('test', testDoc, null, null);
|
|
145
186
|
reconciler_1.hostConfig.commitTextUpdate(textInstance, '', 'updated');
|
|
146
187
|
expect(textInstance).toEqual(expect.objectContaining({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
|
|
2
|
+
type Act = (cb: () => Promise<any>) => Promise<any>;
|
|
3
3
|
export declare const create: (element: React.ReactNode) => Promise<{
|
|
4
4
|
update(newElement: React.ReactNode): Promise<void>;
|
|
5
5
|
}>;
|
|
@@ -1 +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,
|
|
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"}
|
|
@@ -5,21 +5,19 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
5
5
|
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
6
|
const components_1 = require("../components");
|
|
7
7
|
const reconcilerTestRenderer_1 = tslib_1.__importDefault(require("./reconcilerTestRenderer"));
|
|
8
|
+
const testUtils_1 = require("./testUtils");
|
|
8
9
|
describe('reconciled output', () => {
|
|
10
|
+
let bridgeCalls = [];
|
|
11
|
+
beforeAll(async () => {
|
|
12
|
+
bridgeCalls = (0, testUtils_1.setupBridge)();
|
|
13
|
+
});
|
|
9
14
|
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
15
|
const Test = () => {
|
|
19
16
|
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
17
|
};
|
|
21
18
|
await reconcilerTestRenderer_1.default.create((0, jsx_runtime_1.jsx)(Test, {}));
|
|
22
|
-
|
|
23
|
-
expect(
|
|
19
|
+
const forgeDoc = (0, testUtils_1.getLastBridgeCallForgeDoc)(bridgeCalls);
|
|
20
|
+
expect(forgeDoc).toHaveProperty('forgeDoc.type', 'Root');
|
|
21
|
+
expect(forgeDoc).toHaveProperty('forgeDoc.children[0].type', 'Table');
|
|
24
22
|
});
|
|
25
23
|
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ForgeDoc } from '../types';
|
|
2
|
+
export type BridgeCall = {
|
|
3
|
+
cmd: string;
|
|
4
|
+
data: ForgeDoc;
|
|
5
|
+
};
|
|
6
|
+
type SetupBridge = () => BridgeCall[];
|
|
7
|
+
type GetLastBridgeCall = (bridgeCalls: BridgeCall[]) => BridgeCall | null;
|
|
8
|
+
type GetLastBridgeCallForgeDoc = (bridgeCalls: BridgeCall[]) => ForgeDoc | null;
|
|
9
|
+
export declare const setupBridge: SetupBridge;
|
|
10
|
+
export declare const getLastBridgeCall: GetLastBridgeCall;
|
|
11
|
+
export declare const getLastBridgeCallForgeDoc: GetLastBridgeCallForgeDoc;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=testUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testUtils.d.ts","sourceRoot":"","sources":["../../src/__test__/testUtils.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpC,MAAM,MAAM,UAAU,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAC;AACzD,KAAK,WAAW,GAAG,MAAM,UAAU,EAAE,CAAC;AAEtC,KAAK,iBAAiB,GAAG,CAAC,WAAW,EAAE,UAAU,EAAE,KAAK,UAAU,GAAG,IAAI,CAAC;AAC1E,KAAK,yBAAyB,GAAG,CAAC,WAAW,EAAE,UAAU,EAAE,KAAK,QAAQ,GAAG,IAAI,CAAC;AAMhF,eAAO,MAAM,WAAW,EAAE,WAWzB,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,iBAK/B,CAAC;AAEF,eAAO,MAAM,yBAAyB,EAAE,yBAMvC,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getLastBridgeCallForgeDoc = exports.getLastBridgeCall = exports.setupBridge = void 0;
|
|
4
|
+
const setupBridge = () => {
|
|
5
|
+
const bridgeCalls = [];
|
|
6
|
+
global['self'] = {
|
|
7
|
+
__bridge: {
|
|
8
|
+
callBridge: (cmd, data) => {
|
|
9
|
+
bridgeCalls.push({ cmd, data });
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
return bridgeCalls;
|
|
14
|
+
};
|
|
15
|
+
exports.setupBridge = setupBridge;
|
|
16
|
+
const getLastBridgeCall = (bridgeCalls) => {
|
|
17
|
+
if (bridgeCalls.length === 0) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
return bridgeCalls[bridgeCalls.length - 1];
|
|
21
|
+
};
|
|
22
|
+
exports.getLastBridgeCall = getLastBridgeCall;
|
|
23
|
+
const getLastBridgeCallForgeDoc = (bridgeCalls) => {
|
|
24
|
+
const lastBridgeCall = (0, exports.getLastBridgeCall)(bridgeCalls);
|
|
25
|
+
if (lastBridgeCall === null) {
|
|
26
|
+
return lastBridgeCall;
|
|
27
|
+
}
|
|
28
|
+
return lastBridgeCall.data;
|
|
29
|
+
};
|
|
30
|
+
exports.getLastBridgeCallForgeDoc = getLastBridgeCallForgeDoc;
|
package/out/reconciler.d.ts
CHANGED
|
@@ -1,36 +1,40 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
3
|
import { HostConfig } from 'react-reconciler';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
[key: string]: any;
|
|
7
|
-
};
|
|
4
|
+
type ElementType = string;
|
|
5
|
+
type ElementProps = InstanceProps;
|
|
8
6
|
export interface ForgeDoc {
|
|
9
7
|
type: ElementType;
|
|
10
8
|
props: ElementProps;
|
|
11
9
|
children: ForgeDoc[];
|
|
12
10
|
key: string;
|
|
11
|
+
reconciliationCount: number;
|
|
13
12
|
}
|
|
14
|
-
export
|
|
13
|
+
export type CallBridge = (cmd: string, data: {
|
|
15
14
|
forgeDoc: ForgeDoc;
|
|
16
15
|
}) => void;
|
|
17
16
|
export declare const callBridge: CallBridge;
|
|
18
|
-
export
|
|
17
|
+
export type CreateElement = (args: {
|
|
18
|
+
type: ElementType;
|
|
19
|
+
props: InstanceProps;
|
|
20
|
+
reconciliationCount: number;
|
|
21
|
+
}) => ForgeDoc;
|
|
22
|
+
export declare const createElement: CreateElement;
|
|
19
23
|
export declare const appendChild: (parent: ForgeDoc, child: ForgeDoc) => void;
|
|
20
24
|
export declare const insertBefore: (parent: ForgeDoc, child: ForgeDoc, beforeChild: ForgeDoc) => void;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
25
|
+
type HostConfigType = string;
|
|
26
|
+
type InstanceProps = Record<string, any>;
|
|
27
|
+
type Container = ForgeDoc;
|
|
28
|
+
type Instance = ForgeDoc;
|
|
29
|
+
type TextInstance = ForgeDoc;
|
|
30
|
+
type SuspenseInstance = ForgeDoc;
|
|
31
|
+
type HydratableInstance = ForgeDoc;
|
|
32
|
+
type PublicInstance = ForgeDoc;
|
|
33
|
+
type HostContext = any;
|
|
34
|
+
type UpdatePayload = any;
|
|
35
|
+
type ChildSet = any;
|
|
36
|
+
type TimeoutHandle = ReturnType<typeof setTimeout>;
|
|
37
|
+
type NoTimeout = -1;
|
|
34
38
|
export declare const hostConfig: HostConfig<HostConfigType, InstanceProps, Container, Instance, TextInstance, SuspenseInstance, HydratableInstance, PublicInstance, HostContext, UpdatePayload, ChildSet, TimeoutHandle, NoTimeout>;
|
|
35
39
|
export declare const ForgeReconciler: {
|
|
36
40
|
render: (element: ReactNode) => void;
|
package/out/reconciler.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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,
|
|
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;AAC1B,KAAK,YAAY,GAAG,aAAa,CAAC;AAElC,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,WAAW,CAAC;IAClB,KAAK,EAAE,YAAY,CAAC;IACpB,QAAQ,EAAE,QAAQ,EAAE,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,mBAAmB,EAAE,MAAM,CAAC;CAC7B;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,MAAM,MAAM,aAAa,GAAG,CAAC,IAAI,EAAE;IACjC,IAAI,EAAE,WAAW,CAAC;IAClB,KAAK,EAAE,aAAa,CAAC;IACrB,mBAAmB,EAAE,MAAM,CAAC;CAC7B,KAAK,QAAQ,CAAC;AAEf,eAAO,MAAM,aAAa,EAAE,aAU3B,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,CA+JV,CAAC;AAIF,eAAO,MAAM,eAAe;sBACR,SAAS;CAiB5B,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
package/out/reconciler.js
CHANGED
|
@@ -10,13 +10,14 @@ const callBridge = function (cmd, data) {
|
|
|
10
10
|
(_a = self === null || self === void 0 ? void 0 : self.__bridge) === null || _a === void 0 ? void 0 : _a.callBridge(cmd, data);
|
|
11
11
|
};
|
|
12
12
|
exports.callBridge = callBridge;
|
|
13
|
-
const createElement = (type, props = {}) => {
|
|
13
|
+
const createElement = ({ type, props = {}, reconciliationCount }) => {
|
|
14
14
|
const { children } = props, restProps = tslib_1.__rest(props, ["children"]);
|
|
15
15
|
return {
|
|
16
16
|
type,
|
|
17
17
|
children: [],
|
|
18
18
|
props: restProps,
|
|
19
|
-
key: (0, uuid_1.v4)()
|
|
19
|
+
key: (0, uuid_1.v4)(),
|
|
20
|
+
reconciliationCount
|
|
20
21
|
};
|
|
21
22
|
};
|
|
22
23
|
exports.createElement = createElement;
|
|
@@ -44,21 +45,18 @@ exports.hostConfig = {
|
|
|
44
45
|
isPrimaryRenderer: false,
|
|
45
46
|
supportsHydration: false,
|
|
46
47
|
resetAfterCommit(containerInfo) {
|
|
48
|
+
containerInfo.reconciliationCount = containerInfo.reconciliationCount + 1;
|
|
47
49
|
(0, exports.callBridge)('reconcile', { forgeDoc: containerInfo });
|
|
48
50
|
},
|
|
49
|
-
createInstance(type, instanceProps) {
|
|
50
|
-
const
|
|
51
|
+
createInstance(type, instanceProps, rootContainer) {
|
|
52
|
+
const { reconciliationCount } = rootContainer;
|
|
53
|
+
const element = (0, exports.createElement)({ type, props: instanceProps, reconciliationCount });
|
|
51
54
|
return element;
|
|
52
55
|
},
|
|
53
|
-
createTextInstance(text) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
props: {
|
|
58
|
-
text
|
|
59
|
-
},
|
|
60
|
-
key: (0, uuid_1.v4)()
|
|
61
|
-
};
|
|
56
|
+
createTextInstance(text, rootContainer) {
|
|
57
|
+
const { reconciliationCount } = rootContainer;
|
|
58
|
+
const element = (0, exports.createElement)({ type: 'String', props: { text }, reconciliationCount });
|
|
59
|
+
return element;
|
|
62
60
|
},
|
|
63
61
|
appendInitialChild(parentInstance, child) {
|
|
64
62
|
(0, exports.appendChild)(parentInstance, child);
|
|
@@ -72,7 +70,9 @@ exports.hostConfig = {
|
|
|
72
70
|
finalizeInitialChildren() {
|
|
73
71
|
return false;
|
|
74
72
|
},
|
|
75
|
-
prepareUpdate(instance, type, oldProps, newProps) {
|
|
73
|
+
prepareUpdate(instance, type, oldProps, newProps, rootContainer) {
|
|
74
|
+
const { reconciliationCount } = rootContainer;
|
|
75
|
+
instance.reconciliationCount = reconciliationCount + 1;
|
|
76
76
|
instance.props = newProps;
|
|
77
77
|
return newProps;
|
|
78
78
|
},
|
|
@@ -140,7 +140,7 @@ exports.hostConfig = {
|
|
|
140
140
|
const reconciler = (0, react_reconciler_1.default)(exports.hostConfig);
|
|
141
141
|
exports.ForgeReconciler = {
|
|
142
142
|
render: (element) => {
|
|
143
|
-
const rootElement = (0, exports.createElement)('Root');
|
|
143
|
+
const rootElement = (0, exports.createElement)({ type: 'Root', props: {}, reconciliationCount: 0 });
|
|
144
144
|
const container = reconciler.createContainer(rootElement, 0, null, false, null, 'root', (err) => {
|
|
145
145
|
console.log(err);
|
|
146
146
|
}, null);
|