@simpreact/simpreact 0.0.6 → 0.0.8
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/compat/context.d.ts +4 -5
- package/compat/context.js +3 -3
- package/compat/core.d.ts +28 -27
- package/compat/core.js +8 -7
- package/compat/dom.d.ts +5 -5
- package/compat/dom.js +5 -5
- package/compat/hooks.d.ts +7 -8
- package/compat/hooks.js +3 -3
- package/compat/index.d.ts +100 -43
- package/compat/index.js +3 -0
- package/compat/jsx-runtime.d.ts +7 -7
- package/compat/jsx-runtime.js +4 -4
- package/compat/renderRuntime.d.ts +4 -0
- package/compat/renderRuntime.js +3 -0
- package/component/index.d.ts +6 -7
- package/context/index.d.ts +5 -5
- package/context/index.js +1 -1
- package/core/index.d.ts +17 -19
- package/core/index.js +3 -2
- package/core/internal.d.ts +2 -0
- package/core/internal.js +2 -0
- package/core/mounting.d.ts +1 -2
- package/core/mounting.js +50 -101
- package/core/mountingChildren.d.ts +4 -0
- package/core/mountingChildren.js +47 -0
- package/core/patching.d.ts +1 -1
- package/core/patching.js +54 -44
- package/core/patchingChildren.d.ts +3 -3
- package/core/patchingChildren.js +104 -91
- package/core/processStack.d.ts +53 -16
- package/core/processStack.js +23 -11
- package/core/unmounting.d.ts +4 -8
- package/core/unmounting.js +45 -85
- package/core/unmountingChildren.d.ts +4 -0
- package/core/unmountingChildren.js +23 -0
- package/core/utils.d.ts +3 -2
- package/core/utils.js +28 -3
- package/dom/index.d.ts +4 -5
- package/dom/props/dangerInnerHTML.d.ts +5 -5
- package/dom/props/dangerInnerHTML.js +10 -16
- package/dom/props/props.js +5 -5
- package/hooks/index.d.ts +12 -10
- package/hooks/index.js +1 -0
- package/package.json +1 -1
- package/shared/index.d.ts +10 -6
package/core/patchingChildren.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import { SIMP_ELEMENT_CHILD_FLAG_ELEMENT, SIMP_ELEMENT_CHILD_FLAG_LIST, SIMP_ELEMENT_CHILD_FLAG_TEXT,
|
|
1
|
+
import { SIMP_ELEMENT_CHILD_FLAG_ELEMENT, SIMP_ELEMENT_CHILD_FLAG_LIST, SIMP_ELEMENT_CHILD_FLAG_TEXT, } from './createElement.js';
|
|
2
2
|
import { _pushHostOperationPlaceElement } from './hostOperations.js';
|
|
3
|
-
import {
|
|
3
|
+
import { _pushMountEnterFrame } from './mounting.js';
|
|
4
|
+
import { _pushMountChildrenFrame } from './mountingChildren.js';
|
|
4
5
|
import { _pushPatchEnterFrame } from './patching.js';
|
|
5
|
-
import { PATCH_CHILDREN, PATCH_KEYED_CHILDREN } from './processStack.js';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
6
|
+
import { PATCH_CHILDREN, PATCH_KEYED_CHILDREN, } from './processStack.js';
|
|
7
|
+
import { _pushUnmountEnterFrame } from './unmounting.js';
|
|
8
|
+
import { _pushUnmountChildrenFrame } from './unmountingChildren.js';
|
|
9
|
+
import { _clearElementHostReference, getLongestIncreasingSubsequenceIndexes, isHostLike } from './utils.js';
|
|
10
|
+
export function _pushPatchChildrenFrame(parent, meta) {
|
|
9
11
|
meta.renderRuntime.renderStack.push({
|
|
10
|
-
node:
|
|
12
|
+
node: parent,
|
|
11
13
|
kind: PATCH_CHILDREN,
|
|
12
14
|
meta,
|
|
13
15
|
});
|
|
@@ -20,119 +22,122 @@ export function _pushPatchKeyedChildrenFrame(element, meta) {
|
|
|
20
22
|
});
|
|
21
23
|
}
|
|
22
24
|
export function _patchChildren(frame) {
|
|
23
|
-
const
|
|
24
|
-
const { renderRuntime,
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
let nextChildren = nextElement.children;
|
|
28
|
-
let prevChildren = prevElement.children;
|
|
29
|
-
switch (prevChildFlag) {
|
|
25
|
+
const parentElement = frame.node;
|
|
26
|
+
const { renderRuntime, parentReference, context, hostNamespace, nextChildren, prevChildren, prevParentChildFlag, nextParentChildFlag, prevParentElement, } = frame.meta;
|
|
27
|
+
const subtreeRightBoundary = isHostLike(parentElement.flag) ? null : frame.meta.subtreeRightBoundary;
|
|
28
|
+
switch (prevParentChildFlag) {
|
|
30
29
|
case SIMP_ELEMENT_CHILD_FLAG_LIST: {
|
|
31
|
-
switch (
|
|
30
|
+
switch (nextParentChildFlag) {
|
|
32
31
|
case SIMP_ELEMENT_CHILD_FLAG_LIST: {
|
|
33
32
|
for (const child of nextChildren) {
|
|
34
|
-
child.parent =
|
|
33
|
+
child.parent = parentElement;
|
|
35
34
|
}
|
|
36
|
-
_pushPatchKeyedChildrenFrame(
|
|
37
|
-
|
|
35
|
+
_pushPatchKeyedChildrenFrame(parentElement, {
|
|
36
|
+
prevChildren,
|
|
37
|
+
nextChildren,
|
|
38
|
+
subtreeRightBoundary,
|
|
39
|
+
prevParentChildFlag,
|
|
40
|
+
nextParentChildFlag,
|
|
38
41
|
context,
|
|
39
42
|
parentReference,
|
|
40
|
-
rightSibling,
|
|
41
43
|
hostNamespace,
|
|
42
|
-
placeHolderElement,
|
|
43
44
|
renderRuntime,
|
|
45
|
+
prevParentElement,
|
|
44
46
|
});
|
|
45
47
|
break;
|
|
46
48
|
}
|
|
47
49
|
case SIMP_ELEMENT_CHILD_FLAG_ELEMENT: {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
parentReference,
|
|
56
|
-
rightSibling,
|
|
50
|
+
nextChildren.parent = parentElement;
|
|
51
|
+
_pushPatchKeyedChildrenFrame(parentElement, {
|
|
52
|
+
prevChildren,
|
|
53
|
+
nextChildren,
|
|
54
|
+
subtreeRightBoundary,
|
|
55
|
+
prevParentChildFlag,
|
|
56
|
+
nextParentChildFlag,
|
|
57
57
|
context,
|
|
58
|
+
parentReference,
|
|
58
59
|
hostNamespace,
|
|
59
60
|
renderRuntime,
|
|
60
|
-
|
|
61
|
+
prevParentElement,
|
|
61
62
|
});
|
|
62
|
-
_pushUnmountArrayChildrenFrame(prevElement, renderRuntime);
|
|
63
63
|
break;
|
|
64
64
|
}
|
|
65
65
|
case SIMP_ELEMENT_CHILD_FLAG_TEXT: {
|
|
66
|
-
|
|
67
|
-
renderRuntime.hostAdapter.setTextContent(parentReference,
|
|
66
|
+
_pushUnmountChildrenFrame(prevParentElement, frame.meta);
|
|
67
|
+
renderRuntime.hostAdapter.setTextContent(parentReference, parentElement.props?.children);
|
|
68
68
|
break;
|
|
69
69
|
}
|
|
70
70
|
default: {
|
|
71
|
-
|
|
71
|
+
_pushUnmountChildrenFrame(prevParentElement, frame.meta);
|
|
72
72
|
renderRuntime.hostAdapter.clearNode(parentReference);
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
break;
|
|
76
76
|
}
|
|
77
77
|
case SIMP_ELEMENT_CHILD_FLAG_ELEMENT: {
|
|
78
|
-
switch (
|
|
78
|
+
switch (nextParentChildFlag) {
|
|
79
79
|
case SIMP_ELEMENT_CHILD_FLAG_LIST: {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
80
|
+
for (const child of nextChildren) {
|
|
81
|
+
child.parent = parentElement;
|
|
82
|
+
}
|
|
83
|
+
_pushPatchKeyedChildrenFrame(parentElement, {
|
|
84
|
+
prevChildren,
|
|
85
|
+
nextChildren,
|
|
86
|
+
subtreeRightBoundary,
|
|
87
|
+
prevParentChildFlag,
|
|
88
|
+
nextParentChildFlag,
|
|
85
89
|
context,
|
|
90
|
+
parentReference,
|
|
86
91
|
hostNamespace,
|
|
87
|
-
|
|
92
|
+
renderRuntime,
|
|
93
|
+
prevParentElement,
|
|
88
94
|
});
|
|
89
|
-
_clearElementHostReference(prevChildren, parentReference, renderRuntime);
|
|
90
95
|
break;
|
|
91
96
|
}
|
|
92
97
|
case SIMP_ELEMENT_CHILD_FLAG_ELEMENT: {
|
|
93
|
-
nextChildren.parent =
|
|
98
|
+
nextChildren.parent = parentElement;
|
|
94
99
|
_pushPatchEnterFrame(nextChildren, {
|
|
95
100
|
prevElement: prevChildren,
|
|
96
101
|
parentReference,
|
|
97
102
|
renderRuntime,
|
|
98
|
-
|
|
103
|
+
subtreeRightBoundary: subtreeRightBoundary,
|
|
99
104
|
context,
|
|
100
105
|
hostNamespace,
|
|
101
|
-
placeHolderElement: null,
|
|
102
106
|
});
|
|
103
107
|
break;
|
|
104
108
|
}
|
|
105
109
|
case SIMP_ELEMENT_CHILD_FLAG_TEXT: {
|
|
106
|
-
|
|
107
|
-
renderRuntime.hostAdapter.setTextContent(parentReference,
|
|
110
|
+
_pushUnmountChildrenFrame(prevParentElement, frame.meta);
|
|
111
|
+
renderRuntime.hostAdapter.setTextContent(parentReference, parentElement.props?.children);
|
|
108
112
|
break;
|
|
109
113
|
}
|
|
110
114
|
default: {
|
|
111
|
-
|
|
115
|
+
_clearElementHostReference(prevChildren, parentReference, renderRuntime);
|
|
116
|
+
_pushUnmountEnterFrame(prevChildren, frame.meta);
|
|
112
117
|
}
|
|
113
118
|
}
|
|
114
119
|
break;
|
|
115
120
|
}
|
|
116
121
|
case SIMP_ELEMENT_CHILD_FLAG_TEXT: {
|
|
117
|
-
switch (
|
|
122
|
+
switch (nextParentChildFlag) {
|
|
118
123
|
case SIMP_ELEMENT_CHILD_FLAG_LIST: {
|
|
119
124
|
renderRuntime.hostAdapter.clearNode(parentReference);
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
renderRuntime,
|
|
123
|
-
rightSibling,
|
|
125
|
+
_pushMountChildrenFrame(parentElement, {
|
|
126
|
+
children: parentElement.children,
|
|
124
127
|
context,
|
|
125
128
|
hostNamespace,
|
|
126
|
-
|
|
129
|
+
renderRuntime,
|
|
130
|
+
subtreeRightBoundary,
|
|
131
|
+
parentReference,
|
|
127
132
|
});
|
|
128
133
|
break;
|
|
129
134
|
}
|
|
130
135
|
case SIMP_ELEMENT_CHILD_FLAG_ELEMENT: {
|
|
131
136
|
renderRuntime.hostAdapter.clearNode(parentReference);
|
|
132
|
-
nextChildren.parent =
|
|
137
|
+
nextChildren.parent = parentElement;
|
|
133
138
|
_pushMountEnterFrame(nextChildren, {
|
|
134
139
|
parentReference,
|
|
135
|
-
|
|
140
|
+
subtreeRightBoundary: subtreeRightBoundary,
|
|
136
141
|
context,
|
|
137
142
|
hostNamespace,
|
|
138
143
|
renderRuntime,
|
|
@@ -141,8 +146,8 @@ export function _patchChildren(frame) {
|
|
|
141
146
|
break;
|
|
142
147
|
}
|
|
143
148
|
case SIMP_ELEMENT_CHILD_FLAG_TEXT: {
|
|
144
|
-
prevChildren =
|
|
145
|
-
nextChildren =
|
|
149
|
+
const prevChildren = prevParentElement.props?.children;
|
|
150
|
+
const nextChildren = parentElement.props?.children;
|
|
146
151
|
if (prevChildren !== nextChildren) {
|
|
147
152
|
renderRuntime.hostAdapter.setTextContent(parentReference, nextChildren, true);
|
|
148
153
|
}
|
|
@@ -151,44 +156,43 @@ export function _patchChildren(frame) {
|
|
|
151
156
|
break;
|
|
152
157
|
}
|
|
153
158
|
default: {
|
|
154
|
-
switch (
|
|
159
|
+
switch (nextParentChildFlag) {
|
|
155
160
|
case SIMP_ELEMENT_CHILD_FLAG_LIST: {
|
|
156
|
-
|
|
161
|
+
_pushMountChildrenFrame(parentElement, {
|
|
157
162
|
parentReference,
|
|
158
|
-
|
|
163
|
+
subtreeRightBoundary,
|
|
159
164
|
context,
|
|
160
165
|
hostNamespace,
|
|
161
166
|
renderRuntime,
|
|
162
|
-
|
|
167
|
+
children: parentElement.children,
|
|
163
168
|
});
|
|
164
169
|
break;
|
|
165
170
|
}
|
|
166
171
|
case SIMP_ELEMENT_CHILD_FLAG_ELEMENT: {
|
|
167
|
-
nextChildren.parent =
|
|
172
|
+
nextChildren.parent = parentElement;
|
|
168
173
|
_pushMountEnterFrame(nextChildren, {
|
|
169
174
|
parentReference,
|
|
170
|
-
rightSibling,
|
|
171
175
|
context,
|
|
172
176
|
hostNamespace,
|
|
173
177
|
renderRuntime,
|
|
174
178
|
placeHolderElement: null,
|
|
179
|
+
subtreeRightBoundary: subtreeRightBoundary,
|
|
175
180
|
});
|
|
176
181
|
break;
|
|
177
182
|
}
|
|
178
183
|
case SIMP_ELEMENT_CHILD_FLAG_TEXT: {
|
|
179
|
-
renderRuntime.hostAdapter.setTextContent(parentReference,
|
|
184
|
+
renderRuntime.hostAdapter.setTextContent(parentReference, parentElement.props?.children);
|
|
180
185
|
}
|
|
181
186
|
}
|
|
182
187
|
}
|
|
183
188
|
}
|
|
184
189
|
}
|
|
185
190
|
export function _patchKeyedChildren(frame) {
|
|
186
|
-
const {
|
|
187
|
-
const
|
|
188
|
-
const
|
|
189
|
-
const
|
|
190
|
-
const
|
|
191
|
-
const prevLen = prevChildren.length;
|
|
191
|
+
const { parentReference, subtreeRightBoundary, context, hostNamespace, renderRuntime } = frame.meta;
|
|
192
|
+
const nextChildren = frame.meta.nextChildren;
|
|
193
|
+
const prevChildren = frame.meta.prevChildren;
|
|
194
|
+
const nextLen = Array.isArray(nextChildren) ? nextChildren.length : 1;
|
|
195
|
+
const prevLen = Array.isArray(prevChildren) ? prevChildren.length : 1;
|
|
192
196
|
const base = {
|
|
193
197
|
parentReference,
|
|
194
198
|
renderRuntime,
|
|
@@ -197,7 +201,7 @@ export function _patchKeyedChildren(frame) {
|
|
|
197
201
|
placeHolderElement: null,
|
|
198
202
|
};
|
|
199
203
|
const getRightSibling = (child) => {
|
|
200
|
-
return nextChildren
|
|
204
|
+
return child.index + 1 < nextLen ? getChild(nextChildren, child.index + 1) : subtreeRightBoundary;
|
|
201
205
|
};
|
|
202
206
|
let prevStart = 0;
|
|
203
207
|
let nextStart = 0;
|
|
@@ -205,41 +209,45 @@ export function _patchKeyedChildren(frame) {
|
|
|
205
209
|
let nextEnd = nextLen - 1;
|
|
206
210
|
while (prevStart <= prevEnd &&
|
|
207
211
|
nextStart <= nextEnd &&
|
|
208
|
-
prevChildren
|
|
212
|
+
getChild(prevChildren, prevStart).key === getChild(nextChildren, nextStart).key) {
|
|
209
213
|
prevStart++;
|
|
210
214
|
nextStart++;
|
|
211
215
|
}
|
|
212
|
-
while (prevStart <= prevEnd &&
|
|
216
|
+
while (prevStart <= prevEnd &&
|
|
217
|
+
nextStart <= nextEnd &&
|
|
218
|
+
getChild(prevChildren, prevEnd).key === getChild(nextChildren, nextEnd).key) {
|
|
213
219
|
prevEnd--;
|
|
214
220
|
nextEnd--;
|
|
215
221
|
}
|
|
216
222
|
const pushPrefixPatches = () => {
|
|
217
223
|
for (let i = 0; i < nextStart; i++) {
|
|
218
|
-
const nextChild = nextChildren
|
|
219
|
-
const prevChild = prevChildren
|
|
224
|
+
const nextChild = getChild(nextChildren, i);
|
|
225
|
+
const prevChild = getChild(prevChildren, nextChild.index);
|
|
220
226
|
_pushPatchEnterFrame(nextChild, {
|
|
221
227
|
...base,
|
|
222
228
|
prevElement: prevChild,
|
|
223
|
-
|
|
229
|
+
subtreeRightBoundary: getRightSibling(nextChild),
|
|
224
230
|
});
|
|
225
231
|
}
|
|
226
232
|
};
|
|
227
233
|
const pushSuffixPatches = () => {
|
|
228
234
|
const delta = nextLen - prevLen;
|
|
229
235
|
for (let i = nextEnd + 1; i < nextLen; i++) {
|
|
230
|
-
const nextChild = nextChildren
|
|
231
|
-
const prevChild = prevChildren
|
|
236
|
+
const nextChild = getChild(nextChildren, i);
|
|
237
|
+
const prevChild = getChild(prevChildren, nextChild.index - delta);
|
|
232
238
|
_pushPatchEnterFrame(nextChild, {
|
|
233
239
|
...base,
|
|
234
240
|
prevElement: prevChild,
|
|
235
|
-
|
|
241
|
+
subtreeRightBoundary: getRightSibling(nextChild),
|
|
236
242
|
});
|
|
237
243
|
}
|
|
238
244
|
};
|
|
239
245
|
if (nextStart > nextEnd) {
|
|
240
246
|
pushPrefixPatches();
|
|
241
247
|
for (let i = prevStart; i <= prevEnd; i++) {
|
|
242
|
-
|
|
248
|
+
const child = getChild(prevChildren, i);
|
|
249
|
+
_clearElementHostReference(child, parentReference, renderRuntime);
|
|
250
|
+
_pushUnmountEnterFrame(child, frame.meta);
|
|
243
251
|
}
|
|
244
252
|
pushSuffixPatches();
|
|
245
253
|
return;
|
|
@@ -247,10 +255,10 @@ export function _patchKeyedChildren(frame) {
|
|
|
247
255
|
if (prevStart > prevEnd) {
|
|
248
256
|
pushPrefixPatches();
|
|
249
257
|
for (let i = nextStart; i <= nextEnd; i++) {
|
|
250
|
-
const nextChild = nextChildren
|
|
258
|
+
const nextChild = getChild(nextChildren, i);
|
|
251
259
|
_pushMountEnterFrame(nextChild, {
|
|
252
260
|
...base,
|
|
253
|
-
|
|
261
|
+
subtreeRightBoundary: getRightSibling(nextChild),
|
|
254
262
|
});
|
|
255
263
|
}
|
|
256
264
|
pushSuffixPatches();
|
|
@@ -258,7 +266,7 @@ export function _patchKeyedChildren(frame) {
|
|
|
258
266
|
}
|
|
259
267
|
const keyToPrevChild = new Map();
|
|
260
268
|
for (let i = prevStart; i <= prevEnd; i++) {
|
|
261
|
-
const prevChild = prevChildren
|
|
269
|
+
const prevChild = getChild(prevChildren, i);
|
|
262
270
|
const key = prevChild.key;
|
|
263
271
|
if (key != null) {
|
|
264
272
|
keyToPrevChild.set(key, prevChild);
|
|
@@ -269,7 +277,7 @@ export function _patchKeyedChildren(frame) {
|
|
|
269
277
|
let moved = false;
|
|
270
278
|
let maxPrevIndexSoFar = -1;
|
|
271
279
|
for (let i = nextStart; i <= nextEnd; i++) {
|
|
272
|
-
const nextChild = nextChildren
|
|
280
|
+
const nextChild = getChild(nextChildren, i);
|
|
273
281
|
const prevChild = keyToPrevChild.get(nextChild.key);
|
|
274
282
|
if (prevChild != null) {
|
|
275
283
|
const prevIndex = prevChild.index;
|
|
@@ -292,23 +300,25 @@ export function _patchKeyedChildren(frame) {
|
|
|
292
300
|
}
|
|
293
301
|
for (let i = prevStart; i <= prevEnd; i++) {
|
|
294
302
|
if (!matchedPrev[i - prevStart]) {
|
|
295
|
-
|
|
303
|
+
const child = getChild(prevChildren, i);
|
|
304
|
+
_clearElementHostReference(child, parentReference, renderRuntime);
|
|
305
|
+
_pushUnmountEnterFrame(child, frame.meta);
|
|
296
306
|
}
|
|
297
307
|
}
|
|
298
308
|
const stableNewIndexes = moved ? getLongestIncreasingSubsequenceIndexes(newIndexToOldIndex) : new Int32Array(0);
|
|
299
309
|
let stableCursor = 0;
|
|
300
310
|
for (let i = nextStart; i <= nextEnd; i++) {
|
|
301
|
-
const nextChild = nextChildren
|
|
311
|
+
const nextChild = getChild(nextChildren, i);
|
|
302
312
|
const newIndex = nextChild.index - nextStart;
|
|
303
313
|
const oldIndex = newIndexToOldIndex[newIndex];
|
|
304
314
|
if (oldIndex === 0) {
|
|
305
315
|
_pushMountEnterFrame(nextChild, {
|
|
306
316
|
...base,
|
|
307
|
-
|
|
317
|
+
subtreeRightBoundary: getRightSibling(nextChild),
|
|
308
318
|
});
|
|
309
319
|
continue;
|
|
310
320
|
}
|
|
311
|
-
const prevChild = prevChildren
|
|
321
|
+
const prevChild = getChild(prevChildren, oldIndex - 1);
|
|
312
322
|
const isStable = moved && stableNewIndexes[stableCursor] === newIndex;
|
|
313
323
|
if (isStable) {
|
|
314
324
|
stableCursor++;
|
|
@@ -317,14 +327,17 @@ export function _patchKeyedChildren(frame) {
|
|
|
317
327
|
_pushHostOperationPlaceElement(nextChild, {
|
|
318
328
|
parentReference,
|
|
319
329
|
renderRuntime,
|
|
320
|
-
|
|
330
|
+
subtreeRightBoundary: getRightSibling(nextChild),
|
|
321
331
|
});
|
|
322
332
|
}
|
|
323
333
|
_pushPatchEnterFrame(nextChild, {
|
|
324
334
|
...base,
|
|
325
335
|
prevElement: prevChild,
|
|
326
|
-
|
|
336
|
+
subtreeRightBoundary: null,
|
|
327
337
|
});
|
|
328
338
|
}
|
|
329
339
|
pushSuffixPatches();
|
|
330
340
|
}
|
|
341
|
+
function getChild(children, index) {
|
|
342
|
+
return Array.isArray(children) ? children[index] : children;
|
|
343
|
+
}
|
package/core/processStack.d.ts
CHANGED
|
@@ -1,33 +1,60 @@
|
|
|
1
|
-
import type { Maybe, Nullable } from '../shared/index.js';
|
|
1
|
+
import type { Many, Maybe, Nullable } from '../shared/index.js';
|
|
2
2
|
import type { SimpElement } from './createElement.js';
|
|
3
3
|
import type { SimpRenderRuntime } from './runtime.js';
|
|
4
|
-
export declare const MOUNT_ENTER =
|
|
5
|
-
export declare const MOUNT_EXIT =
|
|
6
|
-
export declare const
|
|
7
|
-
export declare const
|
|
8
|
-
export declare const
|
|
9
|
-
export declare const
|
|
10
|
-
export declare const
|
|
11
|
-
export declare const
|
|
12
|
-
export declare const
|
|
13
|
-
export declare const
|
|
4
|
+
export declare const MOUNT_ENTER = 10;
|
|
5
|
+
export declare const MOUNT_EXIT = 11;
|
|
6
|
+
export declare const MOUNT_CHILDREN_ENTER = 12;
|
|
7
|
+
export declare const PATCH_ENTER = 20;
|
|
8
|
+
export declare const PATCH_EXIT = 21;
|
|
9
|
+
export declare const PATCH_CHILDREN = 22;
|
|
10
|
+
export declare const PATCH_KEYED_CHILDREN = 24;
|
|
11
|
+
export declare const UNMOUNT_ENTER = 30;
|
|
12
|
+
export declare const UNMOUNT_EXIT = 31;
|
|
13
|
+
export declare const UNMOUNT_CHILDREN_ENTER = 32;
|
|
14
|
+
export declare const HOST_OPS_PLACE_ELEMENT_BEFORE_ANCHOR = 40;
|
|
15
|
+
export declare const HOST_OPS_REPLACE_CHILD = 42;
|
|
14
16
|
export interface MountFrameMeta {
|
|
15
17
|
parentReference: unknown;
|
|
16
|
-
|
|
18
|
+
subtreeRightBoundary: Nullable<SimpElement>;
|
|
17
19
|
context: unknown;
|
|
18
20
|
hostNamespace: Maybe<string>;
|
|
19
21
|
renderRuntime: SimpRenderRuntime;
|
|
20
22
|
placeHolderElement: Nullable<SimpElement>;
|
|
21
23
|
}
|
|
22
|
-
export interface
|
|
24
|
+
export interface MountChildrenFrameMeta {
|
|
25
|
+
children: Nullable<Many<SimpElement>>;
|
|
26
|
+
parentReference: unknown;
|
|
27
|
+
subtreeRightBoundary: Nullable<SimpElement>;
|
|
28
|
+
context: unknown;
|
|
29
|
+
hostNamespace: Maybe<string>;
|
|
30
|
+
renderRuntime: SimpRenderRuntime;
|
|
31
|
+
}
|
|
32
|
+
export interface PatchFrameMeta {
|
|
33
|
+
parentReference: unknown;
|
|
34
|
+
subtreeRightBoundary: Nullable<SimpElement>;
|
|
35
|
+
context: unknown;
|
|
36
|
+
hostNamespace: Maybe<string>;
|
|
37
|
+
renderRuntime: SimpRenderRuntime;
|
|
23
38
|
prevElement: SimpElement;
|
|
24
39
|
}
|
|
40
|
+
export interface PatchChildrenFrameMeta {
|
|
41
|
+
parentReference: unknown;
|
|
42
|
+
subtreeRightBoundary: Nullable<SimpElement>;
|
|
43
|
+
context: unknown;
|
|
44
|
+
hostNamespace: Maybe<string>;
|
|
45
|
+
renderRuntime: SimpRenderRuntime;
|
|
46
|
+
nextChildren: Nullable<Many<SimpElement>>;
|
|
47
|
+
prevChildren: Nullable<Many<SimpElement>>;
|
|
48
|
+
prevParentChildFlag: number;
|
|
49
|
+
nextParentChildFlag: number;
|
|
50
|
+
prevParentElement: SimpElement;
|
|
51
|
+
}
|
|
25
52
|
export interface UnmountFrameMeta {
|
|
26
53
|
renderRuntime: SimpRenderRuntime;
|
|
27
54
|
}
|
|
28
55
|
export interface PlaceElementFrameMeta {
|
|
29
56
|
parentReference: unknown;
|
|
30
|
-
|
|
57
|
+
subtreeRightBoundary: Nullable<SimpElement>;
|
|
31
58
|
renderRuntime: SimpRenderRuntime;
|
|
32
59
|
}
|
|
33
60
|
export interface ReplaceElementFrameMeta {
|
|
@@ -39,6 +66,11 @@ export interface MountFrame {
|
|
|
39
66
|
kind: typeof MOUNT_ENTER | typeof MOUNT_EXIT;
|
|
40
67
|
meta: MountFrameMeta;
|
|
41
68
|
}
|
|
69
|
+
export interface MountChildrenFrame {
|
|
70
|
+
node: SimpElement;
|
|
71
|
+
kind: typeof MOUNT_CHILDREN_ENTER;
|
|
72
|
+
meta: MountChildrenFrameMeta;
|
|
73
|
+
}
|
|
42
74
|
export interface PatchFrame {
|
|
43
75
|
node: SimpElement;
|
|
44
76
|
kind: typeof PATCH_ENTER | typeof PATCH_EXIT;
|
|
@@ -47,13 +79,18 @@ export interface PatchFrame {
|
|
|
47
79
|
export interface PatchChildrenFrame {
|
|
48
80
|
node: SimpElement;
|
|
49
81
|
kind: typeof PATCH_CHILDREN | typeof PATCH_KEYED_CHILDREN;
|
|
50
|
-
meta:
|
|
82
|
+
meta: PatchChildrenFrameMeta;
|
|
51
83
|
}
|
|
52
84
|
export interface UnmountFrame {
|
|
53
85
|
node: SimpElement;
|
|
54
86
|
kind: typeof UNMOUNT_ENTER | typeof UNMOUNT_EXIT;
|
|
55
87
|
meta: UnmountFrameMeta;
|
|
56
88
|
}
|
|
89
|
+
export interface UnmountChildrenFrame {
|
|
90
|
+
node: SimpElement;
|
|
91
|
+
kind: typeof UNMOUNT_CHILDREN_ENTER;
|
|
92
|
+
meta: UnmountFrameMeta;
|
|
93
|
+
}
|
|
57
94
|
export interface PlaceElementFrame {
|
|
58
95
|
node: SimpElement;
|
|
59
96
|
kind: typeof HOST_OPS_PLACE_ELEMENT_BEFORE_ANCHOR;
|
|
@@ -64,6 +101,6 @@ export interface ReplaceElementFrame {
|
|
|
64
101
|
kind: typeof HOST_OPS_REPLACE_CHILD;
|
|
65
102
|
meta: ReplaceElementFrameMeta;
|
|
66
103
|
}
|
|
67
|
-
export type SimpRenderFrame = MountFrame | PatchFrame | PatchChildrenFrame | UnmountFrame | PlaceElementFrame | ReplaceElementFrame;
|
|
104
|
+
export type SimpRenderFrame = MountFrame | MountChildrenFrame | PatchFrame | PatchChildrenFrame | UnmountFrame | UnmountChildrenFrame | PlaceElementFrame | ReplaceElementFrame;
|
|
68
105
|
export type SimpRenderStack = SimpRenderFrame[];
|
|
69
106
|
export declare function processStack(renderRuntime: SimpRenderRuntime): void;
|
package/core/processStack.js
CHANGED
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
import { _mount } from './mounting.js';
|
|
2
|
+
import { _mountChildren } from './mountingChildren.js';
|
|
2
3
|
import { _patch } from './patching.js';
|
|
3
4
|
import { _patchChildren, _patchKeyedChildren } from './patchingChildren.js';
|
|
4
5
|
import { _unmount } from './unmounting.js';
|
|
6
|
+
import { _unmountChildren } from './unmountingChildren.js';
|
|
5
7
|
import { placeElementBeforeAnchor, resolveAnchorReference } from './utils.js';
|
|
6
|
-
export const MOUNT_ENTER =
|
|
7
|
-
export const MOUNT_EXIT =
|
|
8
|
-
export const
|
|
9
|
-
export const
|
|
10
|
-
export const
|
|
11
|
-
export const
|
|
12
|
-
export const
|
|
13
|
-
export const
|
|
14
|
-
export const
|
|
15
|
-
export const
|
|
8
|
+
export const MOUNT_ENTER = 10;
|
|
9
|
+
export const MOUNT_EXIT = 11;
|
|
10
|
+
export const MOUNT_CHILDREN_ENTER = 12;
|
|
11
|
+
export const PATCH_ENTER = 20;
|
|
12
|
+
export const PATCH_EXIT = 21;
|
|
13
|
+
export const PATCH_CHILDREN = 22;
|
|
14
|
+
export const PATCH_KEYED_CHILDREN = 24;
|
|
15
|
+
export const UNMOUNT_ENTER = 30;
|
|
16
|
+
export const UNMOUNT_EXIT = 31;
|
|
17
|
+
export const UNMOUNT_CHILDREN_ENTER = 32;
|
|
18
|
+
export const HOST_OPS_PLACE_ELEMENT_BEFORE_ANCHOR = 40;
|
|
19
|
+
export const HOST_OPS_REPLACE_CHILD = 42;
|
|
16
20
|
export function processStack(renderRuntime) {
|
|
17
21
|
const stack = renderRuntime.renderStack;
|
|
18
22
|
while (stack.length > 0) {
|
|
@@ -22,6 +26,10 @@ export function processStack(renderRuntime) {
|
|
|
22
26
|
_mount(frame);
|
|
23
27
|
break;
|
|
24
28
|
}
|
|
29
|
+
case MOUNT_CHILDREN_ENTER: {
|
|
30
|
+
_mountChildren(frame);
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
25
33
|
case MOUNT_EXIT: {
|
|
26
34
|
_mount(frame);
|
|
27
35
|
break;
|
|
@@ -50,8 +58,12 @@ export function processStack(renderRuntime) {
|
|
|
50
58
|
_unmount(frame);
|
|
51
59
|
break;
|
|
52
60
|
}
|
|
61
|
+
case UNMOUNT_CHILDREN_ENTER: {
|
|
62
|
+
_unmountChildren(frame);
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
53
65
|
case HOST_OPS_PLACE_ELEMENT_BEFORE_ANCHOR: {
|
|
54
|
-
const anchor = resolveAnchorReference(frame.meta.
|
|
66
|
+
const anchor = resolveAnchorReference(frame.meta.subtreeRightBoundary);
|
|
55
67
|
placeElementBeforeAnchor(frame.node, anchor, frame.meta.parentReference, renderRuntime);
|
|
56
68
|
break;
|
|
57
69
|
}
|
package/core/unmounting.d.ts
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import { type
|
|
3
|
-
import { type UnmountFrame } from './processStack.js';
|
|
1
|
+
import type { SimpElement } from './createElement.js';
|
|
2
|
+
import { type UnmountFrame, type UnmountFrameMeta } from './processStack.js';
|
|
4
3
|
import type { SimpRenderRuntime } from './runtime.js';
|
|
5
4
|
export declare function unmount(element: SimpElement, renderRuntime: SimpRenderRuntime): void;
|
|
6
5
|
export declare function _unmount(frame: UnmountFrame): void;
|
|
7
|
-
export declare function _pushUnmountEnterFrame(element: SimpElement,
|
|
8
|
-
export declare function _pushUnmountExitFrame(element: SimpElement,
|
|
9
|
-
export declare function _pushUnmountArrayChildrenFrame(element: SimpElement, renderRuntime: SimpRenderRuntime): void;
|
|
10
|
-
export declare function _clearElementHostReference(element: Maybe<SimpElement>, parentHostReference: unknown, renderRuntime: SimpRenderRuntime): void;
|
|
11
|
-
export declare function _remove(element: SimpElement, parentReference: unknown, renderRuntime: SimpRenderRuntime): void;
|
|
6
|
+
export declare function _pushUnmountEnterFrame(element: SimpElement, meta: UnmountFrameMeta): void;
|
|
7
|
+
export declare function _pushUnmountExitFrame(element: SimpElement, meta: UnmountFrameMeta): void;
|