@sigil-dev/compiler 0.9.6 → 0.9.10

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.
@@ -1,408 +1,408 @@
1
- import { types as t } from "@babel/core";
2
-
3
- /**
4
- * Mount dynamic (non-primitive, non-keyed) content using an anchor comment node.
5
- * Generates a mount function that handles arrays, Nodes, and primitive values,
6
- * plus a createEffect that diffs by removing previous nodes and re-mounting.
7
- * In hydrate mode, claims the comment from the pool instead of creating.
8
- */
9
- export function buildAnchorMount(
10
- varName: string,
11
- expr: t.Expression,
12
- statements: t.Statement[],
13
- genId: () => string,
14
- hydrate?: boolean,
15
- nodesVar?: string,
16
- parentVar?: string,
17
- ): void {
18
- const anchorVar = genId();
19
- const prevVar = genId();
20
- const mountFn = genId();
21
-
22
- if (hydrate) {
23
- // Claim opening <!--g--> delimiter as anchor from pool
24
- const args: t.Expression[] = [
25
- t.identifier(nodesVar ?? "__nodes"),
26
- t.stringLiteral("g"),
27
- ];
28
- if (parentVar) args.push(t.identifier(parentVar));
29
- statements.push(
30
- t.variableDeclaration("const", [
31
- t.variableDeclarator(
32
- t.identifier(anchorVar),
33
- t.callExpression(t.identifier("claimComment"), args),
34
- ),
35
- ]),
36
- );
37
- // Consume closing <!--/g--> delimiter from pool
38
- const closeArgs: t.Expression[] = [
39
- t.identifier(nodesVar ?? "__nodes"),
40
- t.stringLiteral("/g"),
41
- ];
42
- if (parentVar) closeArgs.push(t.identifier(parentVar));
43
- statements.push(
44
- t.expressionStatement(
45
- t.callExpression(t.identifier("claimComment"), closeArgs),
46
- ),
47
- );
48
- // Collect and remove SSR content between <!--g--> and <!--/g-->
49
- // so the effect doesn't duplicate it on first run.
50
- // Generates: let _prev = []; { let _n = anchor.nextSibling; while (_n) {
51
- // const _cur = _n; _n = _n.nextSibling;
52
- // if (_cur instanceof Comment && _cur.data === "/g") { _cur.remove(); break; }
53
- // _cur.remove(); _prev.push(_cur); } }
54
- const nextVar = genId();
55
- const curVar = genId();
56
- statements.push(
57
- t.variableDeclaration("let", [
58
- t.variableDeclarator(t.identifier(prevVar), t.arrayExpression([])),
59
- ]),
60
- );
61
- statements.push(
62
- t.blockStatement([
63
- // let _n = anchor.nextSibling
64
- t.variableDeclaration("let", [
65
- t.variableDeclarator(
66
- t.identifier(nextVar),
67
- t.memberExpression(
68
- t.identifier(anchorVar),
69
- t.identifier("nextSibling"),
70
- ),
71
- ),
72
- ]),
73
- // while (_n) { ... }
74
- t.whileStatement(
75
- t.identifier(nextVar),
76
- t.blockStatement([
77
- // const _cur = _n
78
- t.variableDeclaration("const", [
79
- t.variableDeclarator(t.identifier(curVar), t.identifier(nextVar)),
80
- ]),
81
- // _n = _n.nextSibling
82
- t.expressionStatement(
83
- t.assignmentExpression(
84
- "=",
85
- t.identifier(nextVar),
86
- t.memberExpression(
87
- t.identifier(curVar),
88
- t.identifier("nextSibling"),
89
- ),
90
- ),
91
- ),
92
- // if (_cur instanceof Comment && _cur.data === "/g") { _cur.remove(); break; }
93
- t.ifStatement(
94
- t.logicalExpression(
95
- "&&",
96
- t.binaryExpression(
97
- "instanceof",
98
- t.identifier(curVar),
99
- t.identifier("Comment"),
100
- ),
101
- t.binaryExpression(
102
- "===",
103
- t.memberExpression(
104
- t.identifier(curVar),
105
- t.identifier("data"),
106
- ),
107
- t.stringLiteral("/g"),
108
- ),
109
- ),
110
- t.blockStatement([
111
- t.expressionStatement(
112
- t.callExpression(
113
- t.memberExpression(
114
- t.identifier(curVar),
115
- t.identifier("remove"),
116
- ),
117
- [],
118
- ),
119
- ),
120
- t.breakStatement(),
121
- ]),
122
- ),
123
- // _cur.remove()
124
- t.expressionStatement(
125
- t.callExpression(
126
- t.memberExpression(
127
- t.identifier(curVar),
128
- t.identifier("remove"),
129
- ),
130
- [],
131
- ),
132
- ),
133
- // _prev.push(_cur)
134
- t.expressionStatement(
135
- t.callExpression(
136
- t.memberExpression(t.identifier(prevVar), t.identifier("push")),
137
- [t.identifier(curVar)],
138
- ),
139
- ),
140
- ]),
141
- ),
142
- ]),
143
- );
144
- } else {
145
- // const _anchor = document.createComment('')
146
- statements.push(
147
- t.variableDeclaration("const", [
148
- t.variableDeclarator(
149
- t.identifier(anchorVar),
150
- t.callExpression(
151
- t.memberExpression(
152
- t.identifier("document"),
153
- t.identifier("createComment"),
154
- ),
155
- [t.stringLiteral("")],
156
- ),
157
- ),
158
- ]),
159
- );
160
-
161
- // parent.append(_anchor)
162
- statements.push(
163
- t.expressionStatement(
164
- t.callExpression(
165
- t.memberExpression(t.identifier(varName), t.identifier("append")),
166
- [t.identifier(anchorVar)],
167
- ),
168
- ),
169
- );
170
- }
171
-
172
- // let _prev = [] — already declared in hydrate block above
173
- if (!hydrate) {
174
- statements.push(
175
- t.variableDeclaration("let", [
176
- t.variableDeclarator(t.identifier(prevVar), t.arrayExpression([])),
177
- ]),
178
- );
179
- }
180
-
181
- // typeof x === "function" ? x() : x — hydrate-mode component children are
182
- // thunks, so a dynamic slot must call them instead of stringifying them.
183
- const unwrapThunk = (name: string): t.Expression =>
184
- t.conditionalExpression(
185
- t.binaryExpression(
186
- "===",
187
- t.unaryExpression("typeof", t.identifier(name)),
188
- t.stringLiteral("function"),
189
- ),
190
- t.callExpression(t.identifier(name), []),
191
- t.identifier(name),
192
- );
193
-
194
- // function _mountFn(_v, _a) { ... }
195
- const mountBody = t.blockStatement([
196
- t.expressionStatement(
197
- t.assignmentExpression("=", t.identifier("_v"), unwrapThunk("_v")),
198
- ),
199
- t.variableDeclaration("const", [
200
- t.variableDeclarator(t.identifier("_nodes"), t.arrayExpression([])),
201
- ]),
202
- t.ifStatement(
203
- t.callExpression(
204
- t.memberExpression(t.identifier("Array"), t.identifier("isArray")),
205
- [t.identifier("_v")],
206
- ),
207
- t.blockStatement([
208
- t.forOfStatement(
209
- t.variableDeclaration("let", [
210
- t.variableDeclarator(t.identifier("_item")),
211
- ]),
212
- t.identifier("_v"),
213
- t.blockStatement([
214
- t.expressionStatement(
215
- t.assignmentExpression(
216
- "=",
217
- t.identifier("_item"),
218
- unwrapThunk("_item"),
219
- ),
220
- ),
221
- t.variableDeclaration("const", [
222
- t.variableDeclarator(
223
- t.identifier("_n"),
224
- t.conditionalExpression(
225
- t.binaryExpression(
226
- "instanceof",
227
- t.identifier("_item"),
228
- t.identifier("Node"),
229
- ),
230
- t.identifier("_item"),
231
- t.callExpression(
232
- t.memberExpression(
233
- t.identifier("document"),
234
- t.identifier("createTextNode"),
235
- ),
236
- [
237
- t.callExpression(t.identifier("String"), [
238
- t.logicalExpression(
239
- "??",
240
- t.identifier("_item"),
241
- t.stringLiteral(""),
242
- ),
243
- ]),
244
- ],
245
- ),
246
- ),
247
- ),
248
- ]),
249
- t.expressionStatement(
250
- t.callExpression(
251
- t.memberExpression(t.identifier("_a"), t.identifier("before")),
252
- [t.identifier("_n")],
253
- ),
254
- ),
255
- t.expressionStatement(
256
- t.callExpression(
257
- t.memberExpression(
258
- t.identifier("_nodes"),
259
- t.identifier("push"),
260
- ),
261
- [t.identifier("_n")],
262
- ),
263
- ),
264
- ]),
265
- ),
266
- ]),
267
- t.ifStatement(
268
- t.binaryExpression(
269
- "instanceof",
270
- t.identifier("_v"),
271
- t.identifier("Node"),
272
- ),
273
- t.blockStatement([
274
- t.expressionStatement(
275
- t.callExpression(
276
- t.memberExpression(t.identifier("_a"), t.identifier("before")),
277
- [t.identifier("_v")],
278
- ),
279
- ),
280
- t.expressionStatement(
281
- t.callExpression(
282
- t.memberExpression(t.identifier("_nodes"), t.identifier("push")),
283
- [t.identifier("_v")],
284
- ),
285
- ),
286
- ]),
287
- t.ifStatement(
288
- t.logicalExpression(
289
- "&&",
290
- t.logicalExpression(
291
- "&&",
292
- t.binaryExpression("!=", t.identifier("_v"), t.nullLiteral()),
293
- t.binaryExpression(
294
- "!==",
295
- t.identifier("_v"),
296
- t.booleanLiteral(false),
297
- ),
298
- ),
299
- t.binaryExpression(
300
- "!==",
301
- t.identifier("_v"),
302
- t.booleanLiteral(true),
303
- ),
304
- ),
305
- t.blockStatement([
306
- t.variableDeclaration("const", [
307
- t.variableDeclarator(
308
- t.identifier("_n"),
309
- t.callExpression(
310
- t.memberExpression(
311
- t.identifier("document"),
312
- t.identifier("createTextNode"),
313
- ),
314
- [
315
- t.callExpression(t.identifier("String"), [
316
- t.identifier("_v"),
317
- ]),
318
- ],
319
- ),
320
- ),
321
- ]),
322
- t.expressionStatement(
323
- t.callExpression(
324
- t.memberExpression(t.identifier("_a"), t.identifier("before")),
325
- [t.identifier("_n")],
326
- ),
327
- ),
328
- t.expressionStatement(
329
- t.callExpression(
330
- t.memberExpression(
331
- t.identifier("_nodes"),
332
- t.identifier("push"),
333
- ),
334
- [t.identifier("_n")],
335
- ),
336
- ),
337
- ]),
338
- ),
339
- ),
340
- ),
341
- t.returnStatement(t.identifier("_nodes")),
342
- ]);
343
-
344
- statements.push(
345
- t.functionDeclaration(
346
- t.identifier(mountFn),
347
- [t.identifier("_v"), t.identifier("_a")],
348
- mountBody,
349
- ),
350
- );
351
-
352
- const disposeVar = genId();
353
-
354
- statements.push(
355
- t.variableDeclaration("let", [
356
- t.variableDeclarator(t.identifier(disposeVar), t.nullLiteral()),
357
- ]),
358
- );
359
-
360
- statements.push(
361
- t.expressionStatement(
362
- t.callExpression(t.identifier("createEffect"), [
363
- t.arrowFunctionExpression(
364
- [],
365
- t.blockStatement([
366
- t.expressionStatement(
367
- t.optionalCallExpression(t.identifier(disposeVar), [], true),
368
- ),
369
- t.forOfStatement(
370
- t.variableDeclaration("const", [
371
- t.variableDeclarator(t.identifier("_n")),
372
- ]),
373
- t.identifier(prevVar),
374
- t.expressionStatement(
375
- t.callExpression(t.identifier("removeAnimated"), [
376
- t.identifier("_n"),
377
- ]),
378
- ),
379
- ),
380
- t.expressionStatement(
381
- t.assignmentExpression(
382
- "=",
383
- t.identifier(disposeVar),
384
- t.callExpression(t.identifier("withEffectScope"), [
385
- t.arrowFunctionExpression(
386
- [],
387
- t.blockStatement([
388
- t.expressionStatement(
389
- t.assignmentExpression(
390
- "=",
391
- t.identifier(prevVar),
392
- t.callExpression(t.identifier(mountFn), [
393
- expr,
394
- t.identifier(anchorVar),
395
- ]),
396
- ),
397
- ),
398
- ]),
399
- ),
400
- ]),
401
- ),
402
- ),
403
- ]),
404
- ),
405
- ]),
406
- ),
407
- );
408
- }
1
+ import { types as t } from "@babel/core";
2
+
3
+ /**
4
+ * Mount dynamic (non-primitive, non-keyed) content using an anchor comment node.
5
+ * Generates a mount function that handles arrays, Nodes, and primitive values,
6
+ * plus a createEffect that diffs by removing previous nodes and re-mounting.
7
+ * In hydrate mode, claims the comment from the pool instead of creating.
8
+ */
9
+ export function buildAnchorMount(
10
+ varName: string,
11
+ expr: t.Expression,
12
+ statements: t.Statement[],
13
+ genId: () => string,
14
+ hydrate?: boolean,
15
+ nodesVar?: string,
16
+ parentVar?: string,
17
+ ): void {
18
+ const anchorVar = genId();
19
+ const prevVar = genId();
20
+ const mountFn = genId();
21
+
22
+ if (hydrate) {
23
+ // Claim opening <!--g--> delimiter as anchor from pool
24
+ const args: t.Expression[] = [
25
+ t.identifier(nodesVar ?? "__nodes"),
26
+ t.stringLiteral("g"),
27
+ ];
28
+ if (parentVar) args.push(t.identifier(parentVar));
29
+ statements.push(
30
+ t.variableDeclaration("const", [
31
+ t.variableDeclarator(
32
+ t.identifier(anchorVar),
33
+ t.callExpression(t.identifier("claimComment"), args),
34
+ ),
35
+ ]),
36
+ );
37
+ // Consume closing <!--/g--> delimiter from pool
38
+ const closeArgs: t.Expression[] = [
39
+ t.identifier(nodesVar ?? "__nodes"),
40
+ t.stringLiteral("/g"),
41
+ ];
42
+ if (parentVar) closeArgs.push(t.identifier(parentVar));
43
+ statements.push(
44
+ t.expressionStatement(
45
+ t.callExpression(t.identifier("claimComment"), closeArgs),
46
+ ),
47
+ );
48
+ // Collect and remove SSR content between <!--g--> and <!--/g-->
49
+ // so the effect doesn't duplicate it on first run.
50
+ // Generates: let _prev = []; { let _n = anchor.nextSibling; while (_n) {
51
+ // const _cur = _n; _n = _n.nextSibling;
52
+ // if (_cur instanceof Comment && _cur.data === "/g") { _cur.remove(); break; }
53
+ // _cur.remove(); _prev.push(_cur); } }
54
+ const nextVar = genId();
55
+ const curVar = genId();
56
+ statements.push(
57
+ t.variableDeclaration("let", [
58
+ t.variableDeclarator(t.identifier(prevVar), t.arrayExpression([])),
59
+ ]),
60
+ );
61
+ statements.push(
62
+ t.blockStatement([
63
+ // let _n = anchor.nextSibling
64
+ t.variableDeclaration("let", [
65
+ t.variableDeclarator(
66
+ t.identifier(nextVar),
67
+ t.memberExpression(
68
+ t.identifier(anchorVar),
69
+ t.identifier("nextSibling"),
70
+ ),
71
+ ),
72
+ ]),
73
+ // while (_n) { ... }
74
+ t.whileStatement(
75
+ t.identifier(nextVar),
76
+ t.blockStatement([
77
+ // const _cur = _n
78
+ t.variableDeclaration("const", [
79
+ t.variableDeclarator(t.identifier(curVar), t.identifier(nextVar)),
80
+ ]),
81
+ // _n = _n.nextSibling
82
+ t.expressionStatement(
83
+ t.assignmentExpression(
84
+ "=",
85
+ t.identifier(nextVar),
86
+ t.memberExpression(
87
+ t.identifier(curVar),
88
+ t.identifier("nextSibling"),
89
+ ),
90
+ ),
91
+ ),
92
+ // if (_cur instanceof Comment && _cur.data === "/g") { _cur.remove(); break; }
93
+ t.ifStatement(
94
+ t.logicalExpression(
95
+ "&&",
96
+ t.binaryExpression(
97
+ "instanceof",
98
+ t.identifier(curVar),
99
+ t.identifier("Comment"),
100
+ ),
101
+ t.binaryExpression(
102
+ "===",
103
+ t.memberExpression(
104
+ t.identifier(curVar),
105
+ t.identifier("data"),
106
+ ),
107
+ t.stringLiteral("/g"),
108
+ ),
109
+ ),
110
+ t.blockStatement([
111
+ t.expressionStatement(
112
+ t.callExpression(
113
+ t.memberExpression(
114
+ t.identifier(curVar),
115
+ t.identifier("remove"),
116
+ ),
117
+ [],
118
+ ),
119
+ ),
120
+ t.breakStatement(),
121
+ ]),
122
+ ),
123
+ // _cur.remove()
124
+ t.expressionStatement(
125
+ t.callExpression(
126
+ t.memberExpression(
127
+ t.identifier(curVar),
128
+ t.identifier("remove"),
129
+ ),
130
+ [],
131
+ ),
132
+ ),
133
+ // _prev.push(_cur)
134
+ t.expressionStatement(
135
+ t.callExpression(
136
+ t.memberExpression(t.identifier(prevVar), t.identifier("push")),
137
+ [t.identifier(curVar)],
138
+ ),
139
+ ),
140
+ ]),
141
+ ),
142
+ ]),
143
+ );
144
+ } else {
145
+ // const _anchor = document.createComment('')
146
+ statements.push(
147
+ t.variableDeclaration("const", [
148
+ t.variableDeclarator(
149
+ t.identifier(anchorVar),
150
+ t.callExpression(
151
+ t.memberExpression(
152
+ t.identifier("document"),
153
+ t.identifier("createComment"),
154
+ ),
155
+ [t.stringLiteral("")],
156
+ ),
157
+ ),
158
+ ]),
159
+ );
160
+
161
+ // parent.append(_anchor)
162
+ statements.push(
163
+ t.expressionStatement(
164
+ t.callExpression(
165
+ t.memberExpression(t.identifier(varName), t.identifier("append")),
166
+ [t.identifier(anchorVar)],
167
+ ),
168
+ ),
169
+ );
170
+ }
171
+
172
+ // let _prev = [] — already declared in hydrate block above
173
+ if (!hydrate) {
174
+ statements.push(
175
+ t.variableDeclaration("let", [
176
+ t.variableDeclarator(t.identifier(prevVar), t.arrayExpression([])),
177
+ ]),
178
+ );
179
+ }
180
+
181
+ // typeof x === "function" ? x() : x — hydrate-mode component children are
182
+ // thunks, so a dynamic slot must call them instead of stringifying them.
183
+ const unwrapThunk = (name: string): t.Expression =>
184
+ t.conditionalExpression(
185
+ t.binaryExpression(
186
+ "===",
187
+ t.unaryExpression("typeof", t.identifier(name)),
188
+ t.stringLiteral("function"),
189
+ ),
190
+ t.callExpression(t.identifier(name), []),
191
+ t.identifier(name),
192
+ );
193
+
194
+ // function _mountFn(_v, _a) { ... }
195
+ const mountBody = t.blockStatement([
196
+ t.expressionStatement(
197
+ t.assignmentExpression("=", t.identifier("_v"), unwrapThunk("_v")),
198
+ ),
199
+ t.variableDeclaration("const", [
200
+ t.variableDeclarator(t.identifier("_nodes"), t.arrayExpression([])),
201
+ ]),
202
+ t.ifStatement(
203
+ t.callExpression(
204
+ t.memberExpression(t.identifier("Array"), t.identifier("isArray")),
205
+ [t.identifier("_v")],
206
+ ),
207
+ t.blockStatement([
208
+ t.forOfStatement(
209
+ t.variableDeclaration("let", [
210
+ t.variableDeclarator(t.identifier("_item")),
211
+ ]),
212
+ t.identifier("_v"),
213
+ t.blockStatement([
214
+ t.expressionStatement(
215
+ t.assignmentExpression(
216
+ "=",
217
+ t.identifier("_item"),
218
+ unwrapThunk("_item"),
219
+ ),
220
+ ),
221
+ t.variableDeclaration("const", [
222
+ t.variableDeclarator(
223
+ t.identifier("_n"),
224
+ t.conditionalExpression(
225
+ t.binaryExpression(
226
+ "instanceof",
227
+ t.identifier("_item"),
228
+ t.identifier("Node"),
229
+ ),
230
+ t.identifier("_item"),
231
+ t.callExpression(
232
+ t.memberExpression(
233
+ t.identifier("document"),
234
+ t.identifier("createTextNode"),
235
+ ),
236
+ [
237
+ t.callExpression(t.identifier("String"), [
238
+ t.logicalExpression(
239
+ "??",
240
+ t.identifier("_item"),
241
+ t.stringLiteral(""),
242
+ ),
243
+ ]),
244
+ ],
245
+ ),
246
+ ),
247
+ ),
248
+ ]),
249
+ t.expressionStatement(
250
+ t.callExpression(
251
+ t.memberExpression(t.identifier("_a"), t.identifier("before")),
252
+ [t.identifier("_n")],
253
+ ),
254
+ ),
255
+ t.expressionStatement(
256
+ t.callExpression(
257
+ t.memberExpression(
258
+ t.identifier("_nodes"),
259
+ t.identifier("push"),
260
+ ),
261
+ [t.identifier("_n")],
262
+ ),
263
+ ),
264
+ ]),
265
+ ),
266
+ ]),
267
+ t.ifStatement(
268
+ t.binaryExpression(
269
+ "instanceof",
270
+ t.identifier("_v"),
271
+ t.identifier("Node"),
272
+ ),
273
+ t.blockStatement([
274
+ t.expressionStatement(
275
+ t.callExpression(
276
+ t.memberExpression(t.identifier("_a"), t.identifier("before")),
277
+ [t.identifier("_v")],
278
+ ),
279
+ ),
280
+ t.expressionStatement(
281
+ t.callExpression(
282
+ t.memberExpression(t.identifier("_nodes"), t.identifier("push")),
283
+ [t.identifier("_v")],
284
+ ),
285
+ ),
286
+ ]),
287
+ t.ifStatement(
288
+ t.logicalExpression(
289
+ "&&",
290
+ t.logicalExpression(
291
+ "&&",
292
+ t.binaryExpression("!=", t.identifier("_v"), t.nullLiteral()),
293
+ t.binaryExpression(
294
+ "!==",
295
+ t.identifier("_v"),
296
+ t.booleanLiteral(false),
297
+ ),
298
+ ),
299
+ t.binaryExpression(
300
+ "!==",
301
+ t.identifier("_v"),
302
+ t.booleanLiteral(true),
303
+ ),
304
+ ),
305
+ t.blockStatement([
306
+ t.variableDeclaration("const", [
307
+ t.variableDeclarator(
308
+ t.identifier("_n"),
309
+ t.callExpression(
310
+ t.memberExpression(
311
+ t.identifier("document"),
312
+ t.identifier("createTextNode"),
313
+ ),
314
+ [
315
+ t.callExpression(t.identifier("String"), [
316
+ t.identifier("_v"),
317
+ ]),
318
+ ],
319
+ ),
320
+ ),
321
+ ]),
322
+ t.expressionStatement(
323
+ t.callExpression(
324
+ t.memberExpression(t.identifier("_a"), t.identifier("before")),
325
+ [t.identifier("_n")],
326
+ ),
327
+ ),
328
+ t.expressionStatement(
329
+ t.callExpression(
330
+ t.memberExpression(
331
+ t.identifier("_nodes"),
332
+ t.identifier("push"),
333
+ ),
334
+ [t.identifier("_n")],
335
+ ),
336
+ ),
337
+ ]),
338
+ ),
339
+ ),
340
+ ),
341
+ t.returnStatement(t.identifier("_nodes")),
342
+ ]);
343
+
344
+ statements.push(
345
+ t.functionDeclaration(
346
+ t.identifier(mountFn),
347
+ [t.identifier("_v"), t.identifier("_a")],
348
+ mountBody,
349
+ ),
350
+ );
351
+
352
+ const disposeVar = genId();
353
+
354
+ statements.push(
355
+ t.variableDeclaration("let", [
356
+ t.variableDeclarator(t.identifier(disposeVar), t.nullLiteral()),
357
+ ]),
358
+ );
359
+
360
+ statements.push(
361
+ t.expressionStatement(
362
+ t.callExpression(t.identifier("createEffect"), [
363
+ t.arrowFunctionExpression(
364
+ [],
365
+ t.blockStatement([
366
+ t.expressionStatement(
367
+ t.optionalCallExpression(t.identifier(disposeVar), [], true),
368
+ ),
369
+ t.forOfStatement(
370
+ t.variableDeclaration("const", [
371
+ t.variableDeclarator(t.identifier("_n")),
372
+ ]),
373
+ t.identifier(prevVar),
374
+ t.expressionStatement(
375
+ t.callExpression(t.identifier("removeAnimated"), [
376
+ t.identifier("_n"),
377
+ ]),
378
+ ),
379
+ ),
380
+ t.expressionStatement(
381
+ t.assignmentExpression(
382
+ "=",
383
+ t.identifier(disposeVar),
384
+ t.callExpression(t.identifier("withEffectScope"), [
385
+ t.arrowFunctionExpression(
386
+ [],
387
+ t.blockStatement([
388
+ t.expressionStatement(
389
+ t.assignmentExpression(
390
+ "=",
391
+ t.identifier(prevVar),
392
+ t.callExpression(t.identifier(mountFn), [
393
+ expr,
394
+ t.identifier(anchorVar),
395
+ ]),
396
+ ),
397
+ ),
398
+ ]),
399
+ ),
400
+ ]),
401
+ ),
402
+ ),
403
+ ]),
404
+ ),
405
+ ]),
406
+ ),
407
+ );
408
+ }