@simpreact/simpreact 0.0.5 → 0.0.7
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/LICENSE.txt +1 -1
- package/compat/context.d.ts +4 -4
- package/compat/context.js +3 -2
- package/compat/core.d.ts +4 -0
- package/compat/core.js +9 -5
- package/compat/dom.d.ts +4 -5
- package/compat/dom.js +3 -2
- package/compat/hooks.d.ts +16 -13
- package/compat/hooks.js +19 -15
- package/compat/index.d.ts +12 -9
- package/compat/index.js +3 -0
- package/compat/renderRuntime.d.ts +6 -0
- package/compat/renderRuntime.js +17 -0
- package/component/index.d.ts +16 -0
- package/component/index.js +164 -0
- package/context/index.d.ts +12 -5
- package/context/index.js +62 -57
- package/core/createElement.d.ts +29 -20
- package/core/createElement.js +159 -133
- package/core/hostAdapter.d.ts +8 -12
- package/core/hostAdapter.js +1 -4
- package/core/hostOperations.d.ts +5 -0
- package/core/hostOperations.js +15 -0
- package/core/index.d.ts +20 -6
- package/core/internal.d.ts +5 -0
- package/core/internal.js +5 -0
- package/core/lifecycleEventBus.d.ts +15 -6
- package/core/lifecycleEventBus.js +16 -2
- package/core/memo.d.ts +0 -2
- package/core/memo.js +1 -3
- package/core/mounting.d.ts +6 -9
- package/core/mounting.js +177 -86
- package/core/mountingChildren.d.ts +4 -0
- package/core/mountingChildren.js +47 -0
- package/core/patching.d.ts +7 -8
- package/core/patching.js +245 -252
- package/core/patchingChildren.d.ts +6 -0
- package/core/patchingChildren.js +343 -0
- package/core/portal.d.ts +1 -1
- package/core/portal.js +17 -7
- package/core/processStack.d.ts +106 -0
- package/core/processStack.js +75 -0
- package/core/ref.d.ts +4 -3
- package/core/rerender.d.ts +4 -14
- package/core/rerender.js +67 -112
- package/core/runtime.d.ts +17 -0
- package/core/runtime.js +2 -0
- package/core/unmounting.d.ts +6 -5
- package/core/unmounting.js +58 -57
- package/core/unmountingChildren.d.ts +4 -0
- package/core/unmountingChildren.js +23 -0
- package/core/utils.d.ts +11 -0
- package/core/utils.js +168 -0
- package/dom/attach-element-to-dom.d.ts +4 -3
- package/dom/attach-element-to-dom.js +12 -7
- package/dom/domAdapter.js +22 -25
- package/dom/events.d.ts +5 -5
- package/dom/events.js +33 -16
- package/dom/index.d.ts +16 -5
- package/dom/index.js +4 -3
- package/dom/props/controlled/index.d.ts +3 -3
- package/dom/props/controlled/index.js +8 -8
- package/dom/props/controlled/input.d.ts +3 -3
- package/dom/props/controlled/input.js +57 -34
- package/dom/props/controlled/select.d.ts +3 -3
- package/dom/props/controlled/select.js +39 -26
- package/dom/props/controlled/textarea.d.ts +3 -3
- package/dom/props/controlled/textarea.js +57 -34
- package/dom/props/dangerInnerHTML.d.ts +5 -5
- package/dom/props/dangerInnerHTML.js +10 -15
- package/dom/props/props.d.ts +4 -4
- package/dom/props/props.js +24 -21
- package/dom/render.d.ts +4 -5
- package/dom/render.js +38 -34
- package/hooks/index.d.ts +15 -13
- package/hooks/index.js +154 -157
- package/jsx-runtime/index.d.ts +2 -1
- package/package.json +9 -1
- package/shared/index.d.ts +10 -0
- package/shared/index.js +4 -7
- package/shared/utils.js +4 -4
- package/shared/EventBus.d.ts +0 -18
- package/shared/EventBus.js +0 -28
package/core/internal.d.ts
CHANGED
|
@@ -4,8 +4,13 @@ export * from './hostAdapter.js';
|
|
|
4
4
|
export * from './lifecycleEventBus.js';
|
|
5
5
|
export * from './memo.js';
|
|
6
6
|
export * from './mounting.js';
|
|
7
|
+
export * from './mountingChildren.js';
|
|
7
8
|
export * from './patching.js';
|
|
9
|
+
export * from './patchingChildren.js';
|
|
8
10
|
export * from './portal.js';
|
|
11
|
+
export * from './processStack.js';
|
|
9
12
|
export * from './ref.js';
|
|
10
13
|
export * from './rerender.js';
|
|
14
|
+
export * from './runtime.js';
|
|
11
15
|
export * from './unmounting.js';
|
|
16
|
+
export * from './unmountingChildren.js';
|
package/core/internal.js
CHANGED
|
@@ -4,8 +4,13 @@ export * from './hostAdapter.js';
|
|
|
4
4
|
export * from './lifecycleEventBus.js';
|
|
5
5
|
export * from './memo.js';
|
|
6
6
|
export * from './mounting.js';
|
|
7
|
+
export * from './mountingChildren.js';
|
|
7
8
|
export * from './patching.js';
|
|
9
|
+
export * from './patchingChildren.js';
|
|
8
10
|
export * from './portal.js';
|
|
11
|
+
export * from './processStack.js';
|
|
9
12
|
export * from './ref.js';
|
|
10
13
|
export * from './rerender.js';
|
|
14
|
+
export * from './runtime.js';
|
|
11
15
|
export * from './unmounting.js';
|
|
16
|
+
export * from './unmountingChildren.js';
|
|
@@ -1,30 +1,39 @@
|
|
|
1
|
-
import { EventBus } from '../shared/index.js';
|
|
2
1
|
import type { SimpElement } from './createElement.js';
|
|
2
|
+
import type { SimpRenderRuntime } from './runtime.js';
|
|
3
3
|
export type LifecycleEvent = {
|
|
4
4
|
type: 'beforeRender';
|
|
5
5
|
element: SimpElement;
|
|
6
|
-
|
|
6
|
+
renderRuntime: SimpRenderRuntime;
|
|
7
7
|
} | {
|
|
8
8
|
type: 'afterRender';
|
|
9
9
|
element: SimpElement;
|
|
10
|
-
|
|
10
|
+
renderRuntime: SimpRenderRuntime;
|
|
11
11
|
} | {
|
|
12
12
|
type: 'triedToRerender';
|
|
13
13
|
element: SimpElement;
|
|
14
|
+
renderRuntime: SimpRenderRuntime;
|
|
14
15
|
} | {
|
|
15
16
|
type: 'mounted';
|
|
16
17
|
element: SimpElement;
|
|
18
|
+
renderRuntime: SimpRenderRuntime;
|
|
17
19
|
} | {
|
|
18
20
|
type: 'updated';
|
|
19
21
|
element: SimpElement;
|
|
22
|
+
renderRuntime: SimpRenderRuntime;
|
|
20
23
|
} | {
|
|
21
24
|
type: 'unmounted';
|
|
22
25
|
element: SimpElement;
|
|
26
|
+
renderRuntime: SimpRenderRuntime;
|
|
23
27
|
} | {
|
|
24
28
|
type: 'errored';
|
|
25
29
|
element: SimpElement;
|
|
26
30
|
error: any;
|
|
27
|
-
|
|
31
|
+
handled: boolean;
|
|
32
|
+
renderRuntime: SimpRenderRuntime;
|
|
28
33
|
};
|
|
29
|
-
|
|
30
|
-
export declare const lifecycleEventBus:
|
|
34
|
+
type Subscriber = (event: LifecycleEvent) => boolean | void;
|
|
35
|
+
export declare const lifecycleEventBus: {
|
|
36
|
+
publish(event: LifecycleEvent): void;
|
|
37
|
+
subscribe(subscriber: Subscriber): () => void;
|
|
38
|
+
};
|
|
39
|
+
export {};
|
|
@@ -1,2 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
export const lifecycleEventBus =
|
|
1
|
+
const subscribers = [];
|
|
2
|
+
export const lifecycleEventBus = {
|
|
3
|
+
publish(event) {
|
|
4
|
+
for (const subscriber of subscribers) {
|
|
5
|
+
subscriber(event);
|
|
6
|
+
}
|
|
7
|
+
},
|
|
8
|
+
subscribe(subscriber) {
|
|
9
|
+
if (subscribers.indexOf(subscriber) === -1) {
|
|
10
|
+
subscribers.push(subscriber);
|
|
11
|
+
}
|
|
12
|
+
return () => {
|
|
13
|
+
subscribers.splice(subscribers.indexOf(subscriber), 1);
|
|
14
|
+
};
|
|
15
|
+
},
|
|
16
|
+
};
|
package/core/memo.d.ts
CHANGED
|
@@ -2,8 +2,6 @@ import { shallowEqual } from '../shared/index.js';
|
|
|
2
2
|
import type { FC, SimpNode } from './createElement.js';
|
|
3
3
|
export interface MemoizedComponent {
|
|
4
4
|
(props: any): SimpNode;
|
|
5
|
-
_isMemo: true;
|
|
6
|
-
_render: FC;
|
|
7
5
|
_compare: (prevProps: any, nextProps: any) => boolean;
|
|
8
6
|
}
|
|
9
7
|
export declare function memo(Component: FC, compare?: typeof shallowEqual): MemoizedComponent;
|
package/core/memo.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { shallowEqual } from '../shared/index.js';
|
|
2
2
|
export function memo(Component, compare = shallowEqual) {
|
|
3
3
|
const Memoized = (props => Component(props));
|
|
4
|
-
Memoized._isMemo = true;
|
|
5
|
-
Memoized._render = Component;
|
|
6
4
|
Memoized._compare = compare;
|
|
7
5
|
return Memoized;
|
|
8
6
|
}
|
|
9
7
|
export function isMemo(type) {
|
|
10
|
-
return type.
|
|
8
|
+
return !!type._compare;
|
|
11
9
|
}
|
package/core/mounting.d.ts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import type { Maybe, Nullable } from '../shared/index.js';
|
|
2
|
-
import type
|
|
3
|
-
import type
|
|
4
|
-
|
|
5
|
-
export declare function
|
|
6
|
-
export declare function
|
|
7
|
-
export declare function
|
|
8
|
-
export declare function mountFragment(element: SimpElement, parentReference: Nullable<HostReference>, nextReference: Nullable<HostReference>, context: unknown, hostNamespace: Maybe<string>): void;
|
|
9
|
-
export declare function mountArrayChildren(children: SimpElement[], reference: Nullable<HostReference>, nextReference: Nullable<HostReference>, context: unknown, parentElement: SimpElement, hostNamespace: Maybe<string>): void;
|
|
10
|
-
export declare function mountPortal(element: SimpElement, parentReference: Nullable<HostReference>, nextReference: Nullable<HostReference>, context: unknown): void;
|
|
2
|
+
import { type SimpElement } from './createElement.js';
|
|
3
|
+
import { type MountFrame, type MountFrameMeta } from './processStack.js';
|
|
4
|
+
import { type SimpRenderRuntime } from './runtime.js';
|
|
5
|
+
export declare function mount(element: SimpElement, parentReference: unknown, subtreeRightBoundary: Nullable<SimpElement>, context: unknown, hostNamespace: Maybe<string>, renderRuntime: SimpRenderRuntime): void;
|
|
6
|
+
export declare function _mount(frame: MountFrame): void;
|
|
7
|
+
export declare function _pushMountEnterFrame(element: SimpElement, meta: MountFrameMeta): void;
|
package/core/mounting.js
CHANGED
|
@@ -1,75 +1,110 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { createTextElement, normalizeRoot } from './createElement.js';
|
|
4
|
-
import { applyRef } from './ref.js';
|
|
1
|
+
import { createTextElement, normalizeRoot, SIMP_ELEMENT_CHILD_FLAG_TEXT, } from './createElement.js';
|
|
2
|
+
import { _pushHostOperationPlaceElement } from './hostOperations.js';
|
|
5
3
|
import { lifecycleEventBus } from './lifecycleEventBus.js';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
4
|
+
import { _pushMountChildrenFrame } from './mountingChildren.js';
|
|
5
|
+
import { MOUNT_ENTER, MOUNT_EXIT, processStack } from './processStack.js';
|
|
6
|
+
import { applyRef } from './ref.js';
|
|
7
|
+
import { MOUNTING_PHASE } from './runtime.js';
|
|
8
|
+
import { bitScanForwardIndex } from './utils.js';
|
|
9
|
+
const mountHandlers = [_mountHostElement, _mountFunctionalElement, _mountTextElement, _mountPortal, _mountFragment];
|
|
10
|
+
export function mount(element, parentReference, subtreeRightBoundary, context, hostNamespace, renderRuntime) {
|
|
11
|
+
if (renderRuntime.renderStack.length !== 0) {
|
|
12
|
+
throw new Error('Cannot mount while rendering.');
|
|
13
|
+
}
|
|
14
|
+
_pushMountEnterFrame(element, {
|
|
15
|
+
parentReference,
|
|
16
|
+
subtreeRightBoundary,
|
|
17
|
+
context,
|
|
18
|
+
hostNamespace,
|
|
19
|
+
renderRuntime,
|
|
20
|
+
placeHolderElement: null,
|
|
21
|
+
});
|
|
22
|
+
processStack(renderRuntime);
|
|
22
23
|
}
|
|
23
|
-
export function
|
|
24
|
-
|
|
25
|
-
if (parentReference) {
|
|
26
|
-
hostAdapter.insertOrAppend(parentReference, reference, nextReference);
|
|
27
|
-
}
|
|
24
|
+
export function _mount(frame) {
|
|
25
|
+
mountHandlers[bitScanForwardIndex(frame.node.flag)](frame);
|
|
28
26
|
}
|
|
29
|
-
export function
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
27
|
+
export function _pushMountEnterFrame(element, meta) {
|
|
28
|
+
meta.renderRuntime.renderStack.push({
|
|
29
|
+
node: element,
|
|
30
|
+
kind: MOUNT_ENTER,
|
|
31
|
+
meta,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
function _pushMountExitFrame(element, meta) {
|
|
35
|
+
meta.renderRuntime.renderStack.push({
|
|
36
|
+
node: element,
|
|
37
|
+
kind: MOUNT_EXIT,
|
|
38
|
+
meta,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
function _mountHostElement(frame) {
|
|
42
|
+
const element = frame.node;
|
|
43
|
+
const { parentReference, subtreeRightBoundary, context, hostNamespace, renderRuntime } = frame.meta;
|
|
44
|
+
if (frame.kind === MOUNT_EXIT) {
|
|
45
|
+
if (element.childFlag === SIMP_ELEMENT_CHILD_FLAG_TEXT) {
|
|
46
|
+
renderRuntime.hostAdapter.setTextContent(element.reference, element.props.children);
|
|
48
47
|
}
|
|
48
|
+
if (element.props) {
|
|
49
|
+
renderRuntime.hostAdapter.mountProps(element.reference, element, renderRuntime, hostNamespace);
|
|
50
|
+
}
|
|
51
|
+
if (element.className) {
|
|
52
|
+
renderRuntime.hostAdapter.setClassname(element.reference, element.className, hostNamespace);
|
|
53
|
+
}
|
|
54
|
+
if (parentReference) {
|
|
55
|
+
_pushHostOperationPlaceElement(element, {
|
|
56
|
+
renderRuntime,
|
|
57
|
+
subtreeRightBoundary,
|
|
58
|
+
parentReference,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
applyRef(element);
|
|
62
|
+
return;
|
|
49
63
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
64
|
+
const hostNamespaces = renderRuntime.hostAdapter.getHostNamespaces(element, hostNamespace);
|
|
65
|
+
const hostReference = (element.reference = renderRuntime.hostAdapter.createReference(element.type, hostNamespaces?.self));
|
|
66
|
+
renderRuntime.hostAdapter.attachElementToReference(element, hostReference, renderRuntime);
|
|
67
|
+
_pushMountExitFrame(element, {
|
|
68
|
+
renderRuntime,
|
|
69
|
+
hostNamespace: hostNamespaces?.self,
|
|
70
|
+
subtreeRightBoundary,
|
|
71
|
+
context,
|
|
72
|
+
parentReference,
|
|
73
|
+
placeHolderElement: null,
|
|
74
|
+
});
|
|
75
|
+
_pushMountChildrenFrame(element, {
|
|
76
|
+
renderRuntime,
|
|
77
|
+
hostNamespace: hostNamespaces?.children,
|
|
78
|
+
subtreeRightBoundary,
|
|
79
|
+
context,
|
|
80
|
+
parentReference: hostReference,
|
|
81
|
+
children: element.children,
|
|
82
|
+
});
|
|
57
83
|
}
|
|
58
|
-
|
|
84
|
+
function _mountFunctionalElement(frame) {
|
|
85
|
+
const element = frame.node;
|
|
86
|
+
const { parentReference, subtreeRightBoundary, context, hostNamespace, renderRuntime } = frame.meta;
|
|
87
|
+
if (frame.kind === MOUNT_EXIT) {
|
|
88
|
+
lifecycleEventBus.publish({ type: 'mounted', element, renderRuntime });
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
59
91
|
if (context) {
|
|
60
92
|
element.context = context;
|
|
61
93
|
}
|
|
62
94
|
if (element.unmounted) {
|
|
63
95
|
element.unmounted = false;
|
|
64
96
|
}
|
|
65
|
-
element.store = { latestElement:
|
|
97
|
+
element.store = { latestElement: null, hostNamespace: null, forceRerender: false };
|
|
98
|
+
element.store.latestElement = element;
|
|
66
99
|
if (hostNamespace) {
|
|
67
100
|
element.store.hostNamespace = hostNamespace;
|
|
68
101
|
}
|
|
69
|
-
// FC element always has Maybe<SimpElement> children due to normalization process.
|
|
102
|
+
// FC element always has Maybe<SimpElement> children due to a normalization process.
|
|
70
103
|
let children;
|
|
71
104
|
let triedToRerenderUnsubscribe;
|
|
72
105
|
try {
|
|
106
|
+
renderRuntime.renderPhase = MOUNTING_PHASE;
|
|
107
|
+
renderRuntime.currentRenderingFCElement = element;
|
|
73
108
|
let triedToRerender = false;
|
|
74
109
|
let rerenderCounter = 0;
|
|
75
110
|
triedToRerenderUnsubscribe = lifecycleEventBus.subscribe(event => {
|
|
@@ -82,47 +117,103 @@ export function mountFunctionalElement(element, parentReference, nextReference,
|
|
|
82
117
|
if (++rerenderCounter >= 25) {
|
|
83
118
|
throw new Error('Too many re-renders.');
|
|
84
119
|
}
|
|
85
|
-
lifecycleEventBus.publish({
|
|
86
|
-
|
|
87
|
-
|
|
120
|
+
lifecycleEventBus.publish({
|
|
121
|
+
type: 'beforeRender',
|
|
122
|
+
element,
|
|
123
|
+
renderRuntime,
|
|
124
|
+
});
|
|
125
|
+
children = renderRuntime.renderer(element.type, element, renderRuntime);
|
|
126
|
+
lifecycleEventBus.publish({
|
|
127
|
+
type: 'afterRender',
|
|
128
|
+
element,
|
|
129
|
+
renderRuntime,
|
|
130
|
+
});
|
|
88
131
|
} while (triedToRerender);
|
|
89
|
-
|
|
132
|
+
normalizeRoot(element, children, false);
|
|
133
|
+
children = element.children;
|
|
90
134
|
}
|
|
91
135
|
catch (error) {
|
|
92
|
-
|
|
136
|
+
const event = {
|
|
137
|
+
type: 'errored',
|
|
138
|
+
element,
|
|
139
|
+
error,
|
|
140
|
+
handled: false,
|
|
141
|
+
renderRuntime,
|
|
142
|
+
};
|
|
143
|
+
lifecycleEventBus.publish(event);
|
|
144
|
+
if (!event.handled) {
|
|
145
|
+
throw new Error('Error occurred during rendering a component', { cause: event.error });
|
|
146
|
+
}
|
|
93
147
|
return;
|
|
94
148
|
}
|
|
95
149
|
finally {
|
|
96
150
|
triedToRerenderUnsubscribe();
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
151
|
+
renderRuntime.renderPhase = null;
|
|
152
|
+
renderRuntime.currentRenderingFCElement = null;
|
|
153
|
+
}
|
|
154
|
+
_pushMountExitFrame(element, {
|
|
155
|
+
renderRuntime,
|
|
156
|
+
hostNamespace,
|
|
157
|
+
subtreeRightBoundary,
|
|
158
|
+
context,
|
|
159
|
+
parentReference,
|
|
160
|
+
placeHolderElement: null,
|
|
161
|
+
});
|
|
162
|
+
_pushMountChildrenFrame(element, {
|
|
163
|
+
renderRuntime,
|
|
164
|
+
hostNamespace,
|
|
165
|
+
children: children,
|
|
166
|
+
context: element.context,
|
|
167
|
+
parentReference,
|
|
168
|
+
subtreeRightBoundary,
|
|
169
|
+
});
|
|
103
170
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
mountArrayChildren(element.children, parentReference, nextReference, context, element, hostNamespace);
|
|
108
|
-
}
|
|
109
|
-
else if (element.children) {
|
|
110
|
-
element.children.parent = element;
|
|
111
|
-
mount(element.children, parentReference, nextReference, context, hostNamespace);
|
|
112
|
-
}
|
|
171
|
+
function _mountTextElement(frame) {
|
|
172
|
+
frame.node.reference = frame.meta.renderRuntime.hostAdapter.createTextReference(frame.node.children);
|
|
173
|
+
_pushHostOperationPlaceElement(frame.node, frame.meta);
|
|
113
174
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
export function mountPortal(element, parentReference, nextReference, context) {
|
|
121
|
-
if (element.children) {
|
|
122
|
-
element.children.parent = element;
|
|
123
|
-
mount(element.children, element.ref, null, context, hostAdapter.getHostNamespaces(element.children, undefined)?.self);
|
|
175
|
+
function _mountPortal(frame) {
|
|
176
|
+
const element = frame.node;
|
|
177
|
+
const { parentReference, subtreeRightBoundary, context, renderRuntime } = frame.meta;
|
|
178
|
+
if (frame.kind === MOUNT_EXIT) {
|
|
179
|
+
element.reference = frame.meta.placeHolderElement.reference;
|
|
180
|
+
return;
|
|
124
181
|
}
|
|
125
182
|
const placeHolderElement = createTextElement('');
|
|
126
|
-
|
|
127
|
-
|
|
183
|
+
_pushMountExitFrame(element, {
|
|
184
|
+
renderRuntime,
|
|
185
|
+
subtreeRightBoundary,
|
|
186
|
+
context: null,
|
|
187
|
+
parentReference: null,
|
|
188
|
+
hostNamespace: null,
|
|
189
|
+
placeHolderElement,
|
|
190
|
+
});
|
|
191
|
+
_pushMountChildrenFrame(element, {
|
|
192
|
+
renderRuntime,
|
|
193
|
+
hostNamespace: renderRuntime.hostAdapter.getHostNamespaces(element.children, undefined)?.self,
|
|
194
|
+
subtreeRightBoundary,
|
|
195
|
+
context,
|
|
196
|
+
parentReference: element.ref,
|
|
197
|
+
children: element.children,
|
|
198
|
+
});
|
|
199
|
+
_pushMountEnterFrame(placeHolderElement, {
|
|
200
|
+
renderRuntime,
|
|
201
|
+
subtreeRightBoundary,
|
|
202
|
+
context: null,
|
|
203
|
+
parentReference,
|
|
204
|
+
hostNamespace: null,
|
|
205
|
+
placeHolderElement: null,
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
function _mountFragment(frame) {
|
|
209
|
+
const element = frame.node;
|
|
210
|
+
const { parentReference, hostNamespace, context, renderRuntime, subtreeRightBoundary } = frame.meta;
|
|
211
|
+
_pushMountChildrenFrame(element, {
|
|
212
|
+
renderRuntime,
|
|
213
|
+
hostNamespace,
|
|
214
|
+
children: element.children,
|
|
215
|
+
parentReference,
|
|
216
|
+
context,
|
|
217
|
+
subtreeRightBoundary: subtreeRightBoundary,
|
|
218
|
+
});
|
|
128
219
|
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type SimpElement } from './createElement.js';
|
|
2
|
+
import { type MountChildrenFrame, type MountChildrenFrameMeta } from './processStack.js';
|
|
3
|
+
export declare function _pushMountChildrenFrame(parent: SimpElement, meta: MountChildrenFrameMeta): void;
|
|
4
|
+
export declare function _mountChildren(frame: MountChildrenFrame): void;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { SIMP_ELEMENT_CHILD_FLAG_ELEMENT, SIMP_ELEMENT_CHILD_FLAG_LIST } from './createElement.js';
|
|
2
|
+
import { _pushMountEnterFrame } from './mounting.js';
|
|
3
|
+
import { MOUNT_CHILDREN_ENTER } from './processStack.js';
|
|
4
|
+
import { isHostLike } from './utils.js';
|
|
5
|
+
export function _pushMountChildrenFrame(parent, meta) {
|
|
6
|
+
meta.renderRuntime.renderStack.push({
|
|
7
|
+
node: parent,
|
|
8
|
+
kind: MOUNT_CHILDREN_ENTER,
|
|
9
|
+
meta,
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
export function _mountChildren(frame) {
|
|
13
|
+
const parentElement = frame.node;
|
|
14
|
+
const { parentReference, hostNamespace, renderRuntime, context } = frame.meta;
|
|
15
|
+
const subtreeRightBoundary = isHostLike(parentElement.flag) ? null : frame.meta.subtreeRightBoundary;
|
|
16
|
+
switch (parentElement.childFlag) {
|
|
17
|
+
case SIMP_ELEMENT_CHILD_FLAG_ELEMENT: {
|
|
18
|
+
const children = frame.meta.children;
|
|
19
|
+
children.parent = parentElement;
|
|
20
|
+
_pushMountEnterFrame(children, {
|
|
21
|
+
renderRuntime,
|
|
22
|
+
hostNamespace,
|
|
23
|
+
subtreeRightBoundary,
|
|
24
|
+
context,
|
|
25
|
+
parentReference,
|
|
26
|
+
placeHolderElement: null,
|
|
27
|
+
});
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
case SIMP_ELEMENT_CHILD_FLAG_LIST: {
|
|
31
|
+
const children = frame.meta.children;
|
|
32
|
+
for (let i = children.length - 1; i >= 0; i--) {
|
|
33
|
+
const child = children[i];
|
|
34
|
+
child.parent = parentElement;
|
|
35
|
+
const rightSibling = children[child.index + 1] || subtreeRightBoundary;
|
|
36
|
+
_pushMountEnterFrame(child, {
|
|
37
|
+
renderRuntime,
|
|
38
|
+
parentReference,
|
|
39
|
+
context,
|
|
40
|
+
hostNamespace,
|
|
41
|
+
subtreeRightBoundary: rightSibling,
|
|
42
|
+
placeHolderElement: null,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
package/core/patching.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import type { Maybe, Nullable } from '../shared/index.js';
|
|
2
|
-
import type
|
|
3
|
-
import type
|
|
4
|
-
|
|
5
|
-
export declare function
|
|
6
|
-
export declare function
|
|
7
|
-
export declare function
|
|
8
|
-
export declare function
|
|
9
|
-
export declare function findHostReferenceFromElement(element: SimpElement): Nullable<HostReference>;
|
|
2
|
+
import { type SimpElement } from './createElement.js';
|
|
3
|
+
import { type PatchFrame, type PatchFrameMeta } from './processStack.js';
|
|
4
|
+
import { type SimpRenderRuntime } from './runtime.js';
|
|
5
|
+
export declare function patch(prevElement: SimpElement, nextElement: SimpElement, parentReference: unknown, subtreeRightBoundary: Nullable<SimpElement>, context: unknown, hostNamespace: Maybe<string>, renderRuntime: SimpRenderRuntime): void;
|
|
6
|
+
export declare function _pushPatchEnterFrame(element: SimpElement, meta: PatchFrameMeta): void;
|
|
7
|
+
export declare function _pushPatchExitFrame(element: SimpElement, meta: PatchFrameMeta): void;
|
|
8
|
+
export declare function _patch(frame: PatchFrame): void;
|