@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.
Files changed (83) hide show
  1. package/LICENSE.txt +1 -1
  2. package/compat/context.d.ts +4 -4
  3. package/compat/context.js +3 -2
  4. package/compat/core.d.ts +4 -0
  5. package/compat/core.js +9 -5
  6. package/compat/dom.d.ts +4 -5
  7. package/compat/dom.js +3 -2
  8. package/compat/hooks.d.ts +16 -13
  9. package/compat/hooks.js +19 -15
  10. package/compat/index.d.ts +12 -9
  11. package/compat/index.js +3 -0
  12. package/compat/renderRuntime.d.ts +6 -0
  13. package/compat/renderRuntime.js +17 -0
  14. package/component/index.d.ts +16 -0
  15. package/component/index.js +164 -0
  16. package/context/index.d.ts +12 -5
  17. package/context/index.js +62 -57
  18. package/core/createElement.d.ts +29 -20
  19. package/core/createElement.js +159 -133
  20. package/core/hostAdapter.d.ts +8 -12
  21. package/core/hostAdapter.js +1 -4
  22. package/core/hostOperations.d.ts +5 -0
  23. package/core/hostOperations.js +15 -0
  24. package/core/index.d.ts +20 -6
  25. package/core/internal.d.ts +5 -0
  26. package/core/internal.js +5 -0
  27. package/core/lifecycleEventBus.d.ts +15 -6
  28. package/core/lifecycleEventBus.js +16 -2
  29. package/core/memo.d.ts +0 -2
  30. package/core/memo.js +1 -3
  31. package/core/mounting.d.ts +6 -9
  32. package/core/mounting.js +177 -86
  33. package/core/mountingChildren.d.ts +4 -0
  34. package/core/mountingChildren.js +47 -0
  35. package/core/patching.d.ts +7 -8
  36. package/core/patching.js +245 -252
  37. package/core/patchingChildren.d.ts +6 -0
  38. package/core/patchingChildren.js +343 -0
  39. package/core/portal.d.ts +1 -1
  40. package/core/portal.js +17 -7
  41. package/core/processStack.d.ts +106 -0
  42. package/core/processStack.js +75 -0
  43. package/core/ref.d.ts +4 -3
  44. package/core/rerender.d.ts +4 -14
  45. package/core/rerender.js +67 -112
  46. package/core/runtime.d.ts +17 -0
  47. package/core/runtime.js +2 -0
  48. package/core/unmounting.d.ts +6 -5
  49. package/core/unmounting.js +58 -57
  50. package/core/unmountingChildren.d.ts +4 -0
  51. package/core/unmountingChildren.js +23 -0
  52. package/core/utils.d.ts +11 -0
  53. package/core/utils.js +168 -0
  54. package/dom/attach-element-to-dom.d.ts +4 -3
  55. package/dom/attach-element-to-dom.js +12 -7
  56. package/dom/domAdapter.js +22 -25
  57. package/dom/events.d.ts +5 -5
  58. package/dom/events.js +33 -16
  59. package/dom/index.d.ts +16 -5
  60. package/dom/index.js +4 -3
  61. package/dom/props/controlled/index.d.ts +3 -3
  62. package/dom/props/controlled/index.js +8 -8
  63. package/dom/props/controlled/input.d.ts +3 -3
  64. package/dom/props/controlled/input.js +57 -34
  65. package/dom/props/controlled/select.d.ts +3 -3
  66. package/dom/props/controlled/select.js +39 -26
  67. package/dom/props/controlled/textarea.d.ts +3 -3
  68. package/dom/props/controlled/textarea.js +57 -34
  69. package/dom/props/dangerInnerHTML.d.ts +5 -5
  70. package/dom/props/dangerInnerHTML.js +10 -15
  71. package/dom/props/props.d.ts +4 -4
  72. package/dom/props/props.js +24 -21
  73. package/dom/render.d.ts +4 -5
  74. package/dom/render.js +38 -34
  75. package/hooks/index.d.ts +15 -13
  76. package/hooks/index.js +154 -157
  77. package/jsx-runtime/index.d.ts +2 -1
  78. package/package.json +9 -1
  79. package/shared/index.d.ts +10 -0
  80. package/shared/index.js +4 -7
  81. package/shared/utils.js +4 -4
  82. package/shared/EventBus.d.ts +0 -18
  83. package/shared/EventBus.js +0 -28
@@ -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
- phase: 'mounting' | 'updating';
6
+ renderRuntime: SimpRenderRuntime;
7
7
  } | {
8
8
  type: 'afterRender';
9
9
  element: SimpElement;
10
- phase: 'mounting' | 'updating';
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
- phase: 'mounting' | 'updating';
31
+ handled: boolean;
32
+ renderRuntime: SimpRenderRuntime;
28
33
  };
29
- export type LifecycleEventBus = EventBus<LifecycleEvent>;
30
- export declare const lifecycleEventBus: EventBus<LifecycleEvent>;
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
- import { EventBus } from '../shared/index.js';
2
- export const lifecycleEventBus = new EventBus();
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._isMemo;
8
+ return !!type._compare;
11
9
  }
@@ -1,10 +1,7 @@
1
1
  import type { Maybe, Nullable } from '../shared/index.js';
2
- import type { HostReference } from './hostAdapter.js';
3
- import type { SimpElement } from './createElement.js';
4
- export declare function mount(element: SimpElement, parentReference: Nullable<HostReference>, nextReference: Nullable<HostReference>, context: unknown, hostNamespace: Maybe<string>): void;
5
- export declare function mountTextElement(element: SimpElement, parentReference: Nullable<HostReference>, nextReference: Nullable<HostReference>): void;
6
- export declare function mountHostElement(element: SimpElement, parentReference: Nullable<HostReference>, nextReference: Nullable<HostReference>, context: unknown, hostNamespace: Maybe<string>): void;
7
- export declare function mountFunctionalElement(element: SimpElement, parentReference: Nullable<HostReference>, nextReference: Nullable<HostReference>, context: unknown, hostNamespace: Maybe<string>): void;
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 { emptyObject } from '../shared/index.js';
2
- import { hostAdapter } from './hostAdapter.js';
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
- export function mount(element, parentReference, nextReference, context, hostNamespace) {
7
- if (element.flag === 'TEXT') {
8
- mountTextElement(element, parentReference, nextReference);
9
- }
10
- else if (element.flag === 'HOST') {
11
- mountHostElement(element, parentReference, nextReference, context, hostNamespace);
12
- }
13
- else if (element.flag === 'FC') {
14
- mountFunctionalElement(element, parentReference, nextReference, context, hostNamespace);
15
- }
16
- else if (element.flag === 'FRAGMENT') {
17
- mountFragment(element, parentReference, nextReference, context, hostNamespace);
18
- }
19
- else {
20
- mountPortal(element, parentReference, nextReference, context);
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 mountTextElement(element, parentReference, nextReference) {
24
- const reference = (element.reference = hostAdapter.createTextReference(element.children));
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 mountHostElement(element, parentReference, nextReference, context, hostNamespace) {
30
- const hostNamespaces = hostAdapter.getHostNamespaces(element, hostNamespace);
31
- hostNamespace = hostNamespaces?.self;
32
- const hostReference = (element.reference = hostAdapter.createReference(element.type, hostNamespace));
33
- hostAdapter.attachElementToReference(element, hostReference);
34
- // HOST element always has Maybe<Many<SimpElement>> children due to normalization process.
35
- const children = element.children;
36
- if (Array.isArray(children)) {
37
- mountArrayChildren(children, hostReference, null, context, element, hostNamespaces?.children);
38
- }
39
- else if (children) {
40
- children.parent = element;
41
- mount(children, hostReference, null, context, hostNamespaces?.children);
42
- }
43
- if (element.props) {
44
- hostAdapter.mountProps(hostReference, element, hostNamespace);
45
- // HOST elements can have either children elements or string children in the props due to normalization.
46
- if (typeof element.props.children === 'string') {
47
- hostAdapter.setTextContent(hostReference, element.props.children);
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
- if (element.className) {
51
- hostAdapter.setClassname(hostReference, element.className, hostNamespace);
52
- }
53
- if (parentReference) {
54
- hostAdapter.insertOrAppend(parentReference, hostReference, nextReference);
55
- }
56
- applyRef(element);
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
- export function mountFunctionalElement(element, parentReference, nextReference, context, hostNamespace) {
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: element };
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({ type: 'beforeRender', element, phase: 'mounting' });
86
- children = element.type(element.props || emptyObject);
87
- lifecycleEventBus.publish({ type: 'afterRender', element, phase: 'mounting' });
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
- children = normalizeRoot(children, false);
132
+ normalizeRoot(element, children, false);
133
+ children = element.children;
90
134
  }
91
135
  catch (error) {
92
- lifecycleEventBus.publish({ type: 'errored', element, error, phase: 'mounting' });
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
- if (children) {
99
- children.parent = element;
100
- mount((element.children = children), parentReference, nextReference, element.context, hostNamespace);
101
- }
102
- lifecycleEventBus.publish({ type: 'mounted', element });
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
- export function mountFragment(element, parentReference, nextReference, context, hostNamespace) {
105
- // FRAGMENT element always has Maybe<Many<SimpElement>> children due to normalization process.
106
- if (Array.isArray(element.children)) {
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
- export function mountArrayChildren(children, reference, nextReference, context, parentElement, hostNamespace) {
115
- for (const child of children) {
116
- child.parent = parentElement;
117
- mount(child, reference, nextReference, context, hostNamespace);
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
- mountTextElement(placeHolderElement, parentReference, nextReference);
127
- element.reference = placeHolderElement.reference;
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
+ }
@@ -1,9 +1,8 @@
1
1
  import type { Maybe, Nullable } from '../shared/index.js';
2
- import type { SimpElement } from './createElement.js';
3
- import type { HostReference } from './hostAdapter.js';
4
- export declare function patch(prevElement: SimpElement, nextElement: SimpElement, parentReference: HostReference, nextReference: Nullable<HostReference>, context: unknown, hostNamespace: Maybe<string>): void;
5
- export declare function patchPortal(prevElement: SimpElement, nextElement: SimpElement, context: unknown): void;
6
- export declare function updateFunctionalComponent(element: SimpElement, parentReference: HostReference, nextReference: Nullable<HostReference>, context: unknown, hostNamespace: Maybe<string>): void;
7
- export declare function patchKeyedChildren(prevChildren: SimpElement[], nextChildren: SimpElement[], parentReference: HostReference, nextReference: Nullable<HostReference>, context: unknown, hostNamespace: Maybe<string>): void;
8
- export declare function findParentReferenceFromElement(element: SimpElement): Nullable<HostReference>;
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;