@sigil-dev/compiler 0.9.29 → 0.9.31
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/index.ts +6 -4
- package/package.json +1 -1
- package/src/babel/index.ts +763 -750
- package/src/babel/jsx/anchor-mount.ts +338 -333
- package/src/babel/jsx/children.ts +116 -116
- package/src/babel/jsx/element.ts +1040 -1034
- package/src/babel/jsx/fragment.ts +271 -271
- package/src/babel/jsx/keyed-list.ts +339 -339
- package/src/babel/jsx/utils.ts +356 -356
- package/src/babel/util/bind.ts +143 -143
- package/src/babel/util/css.ts +208 -208
- package/src/babel/util/dead-code.ts +94 -93
- package/src/babel/util/links.ts +101 -0
- package/src/babel/util/reactive-fns.ts +110 -110
- package/src/babel/util/runtime-names.ts +88 -0
- package/src/babel/util/state-imports.ts +122 -121
- package/src/babel/util/static-assertion.ts +51 -51
- package/src/babel/util/static-env.ts +84 -0
- package/src/vite/index.ts +61 -61
- package/test/bun-plugin.test.ts +45 -45
- package/test/context.test.ts +110 -102
- package/test/fixtures/stores/index.ts +2 -2
- package/test/hydration-analysis.test.ts +133 -133
- package/test/hydration.test.ts +315 -313
- package/test/jsx.test.ts +254 -254
- package/test/links.test.ts +57 -0
- package/test/reactive-helpers.test.ts +135 -135
- package/test/render-parity.test.ts +909 -907
- package/test/runtime-names.test.ts +60 -0
- package/test/scoped-css.test.ts +166 -166
- package/test/ssr-boolean-attrs.test.ts +56 -56
- package/test/ssr-raw-text.test.ts +68 -68
- package/test/ssr.test.ts +30 -0
- package/test/static-assertion.test.ts +123 -123
- package/test/static-env.test.ts +85 -0
- package/test/static-skip.test.ts +292 -292
- package/test/style-object.test.ts +36 -36
- package/test/tree-shaking.test.ts +122 -120
|
@@ -1,333 +1,338 @@
|
|
|
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
|
-
// let _prev = claimSlot(nodes, anchor): takes the SSR content up to the
|
|
38
|
-
// *matching* <!--/g--> (nested slots counted) out of the DOM and the pool,
|
|
39
|
-
// so the effect's first run replaces it instead of duplicating it
|
|
40
|
-
statements.push(
|
|
41
|
-
t.variableDeclaration("let", [
|
|
42
|
-
t.variableDeclarator(
|
|
43
|
-
t.identifier(prevVar),
|
|
44
|
-
t.callExpression(t.identifier("claimSlot"), [
|
|
45
|
-
t.identifier(nodesVar ?? "__nodes"),
|
|
46
|
-
t.identifier(anchorVar),
|
|
47
|
-
]),
|
|
48
|
-
),
|
|
49
|
-
]),
|
|
50
|
-
);
|
|
51
|
-
} else {
|
|
52
|
-
// const _anchor = document.createComment('')
|
|
53
|
-
statements.push(
|
|
54
|
-
t.variableDeclaration("const", [
|
|
55
|
-
t.variableDeclarator(
|
|
56
|
-
t.identifier(anchorVar),
|
|
57
|
-
t.callExpression(
|
|
58
|
-
t.memberExpression(
|
|
59
|
-
t.identifier("document"),
|
|
60
|
-
t.identifier("createComment"),
|
|
61
|
-
),
|
|
62
|
-
[t.stringLiteral("")],
|
|
63
|
-
),
|
|
64
|
-
),
|
|
65
|
-
]),
|
|
66
|
-
);
|
|
67
|
-
|
|
68
|
-
// parent.append(_anchor)
|
|
69
|
-
statements.push(
|
|
70
|
-
t.expressionStatement(
|
|
71
|
-
t.callExpression(
|
|
72
|
-
t.memberExpression(t.identifier(varName), t.identifier("append")),
|
|
73
|
-
[t.identifier(anchorVar)],
|
|
74
|
-
),
|
|
75
|
-
),
|
|
76
|
-
);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// let _prev = [] — already declared in hydrate block above
|
|
80
|
-
if (!hydrate) {
|
|
81
|
-
statements.push(
|
|
82
|
-
t.variableDeclaration("let", [
|
|
83
|
-
t.variableDeclarator(t.identifier(prevVar), t.arrayExpression([])),
|
|
84
|
-
]),
|
|
85
|
-
);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// typeof x === "function" ? x() : x — hydrate-mode component children are
|
|
89
|
-
// thunks, so a dynamic slot must call them instead of stringifying them.
|
|
90
|
-
const unwrapThunk = (name: string): t.Expression =>
|
|
91
|
-
t.conditionalExpression(
|
|
92
|
-
t.binaryExpression(
|
|
93
|
-
"===",
|
|
94
|
-
t.unaryExpression("typeof", t.identifier(name)),
|
|
95
|
-
t.stringLiteral("function"),
|
|
96
|
-
),
|
|
97
|
-
t.callExpression(t.identifier(name), []),
|
|
98
|
-
t.identifier(name),
|
|
99
|
-
);
|
|
100
|
-
|
|
101
|
-
// const _k = x.nodeType === 11 ? Array.from(x.childNodes) : [x]
|
|
102
|
-
// A fragment empties into the page when inserted, and cannot be removed
|
|
103
|
-
// itself: what must be removed later is the nodes it held.
|
|
104
|
-
const keepNodes = (name: string): t.Statement =>
|
|
105
|
-
t.variableDeclaration("const", [
|
|
106
|
-
t.variableDeclarator(
|
|
107
|
-
t.identifier("_k"),
|
|
108
|
-
t.conditionalExpression(
|
|
109
|
-
t.binaryExpression(
|
|
110
|
-
"===",
|
|
111
|
-
t.memberExpression(t.identifier(name), t.identifier("nodeType")),
|
|
112
|
-
t.numericLiteral(11),
|
|
113
|
-
),
|
|
114
|
-
t.callExpression(
|
|
115
|
-
t.memberExpression(t.identifier("Array"), t.identifier("from")),
|
|
116
|
-
[
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
t.
|
|
167
|
-
|
|
168
|
-
t.
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
t.
|
|
203
|
-
|
|
204
|
-
t.
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
),
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
),
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
t.
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
t.
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
]),
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
),
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
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
|
+
// let _prev = claimSlot(nodes, anchor): takes the SSR content up to the
|
|
38
|
+
// *matching* <!--/g--> (nested slots counted) out of the DOM and the pool,
|
|
39
|
+
// so the effect's first run replaces it instead of duplicating it
|
|
40
|
+
statements.push(
|
|
41
|
+
t.variableDeclaration("let", [
|
|
42
|
+
t.variableDeclarator(
|
|
43
|
+
t.identifier(prevVar),
|
|
44
|
+
t.callExpression(t.identifier("claimSlot"), [
|
|
45
|
+
t.identifier(nodesVar ?? "__nodes"),
|
|
46
|
+
t.identifier(anchorVar),
|
|
47
|
+
]),
|
|
48
|
+
),
|
|
49
|
+
]),
|
|
50
|
+
);
|
|
51
|
+
} else {
|
|
52
|
+
// const _anchor = document.createComment('')
|
|
53
|
+
statements.push(
|
|
54
|
+
t.variableDeclaration("const", [
|
|
55
|
+
t.variableDeclarator(
|
|
56
|
+
t.identifier(anchorVar),
|
|
57
|
+
t.callExpression(
|
|
58
|
+
t.memberExpression(
|
|
59
|
+
t.identifier("document"),
|
|
60
|
+
t.identifier("createComment"),
|
|
61
|
+
),
|
|
62
|
+
[t.stringLiteral("")],
|
|
63
|
+
),
|
|
64
|
+
),
|
|
65
|
+
]),
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
// parent.append(_anchor)
|
|
69
|
+
statements.push(
|
|
70
|
+
t.expressionStatement(
|
|
71
|
+
t.callExpression(
|
|
72
|
+
t.memberExpression(t.identifier(varName), t.identifier("append")),
|
|
73
|
+
[t.identifier(anchorVar)],
|
|
74
|
+
),
|
|
75
|
+
),
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// let _prev = [] — already declared in hydrate block above
|
|
80
|
+
if (!hydrate) {
|
|
81
|
+
statements.push(
|
|
82
|
+
t.variableDeclaration("let", [
|
|
83
|
+
t.variableDeclarator(t.identifier(prevVar), t.arrayExpression([])),
|
|
84
|
+
]),
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// typeof x === "function" ? x() : x — hydrate-mode component children are
|
|
89
|
+
// thunks, so a dynamic slot must call them instead of stringifying them.
|
|
90
|
+
const unwrapThunk = (name: string): t.Expression =>
|
|
91
|
+
t.conditionalExpression(
|
|
92
|
+
t.binaryExpression(
|
|
93
|
+
"===",
|
|
94
|
+
t.unaryExpression("typeof", t.identifier(name)),
|
|
95
|
+
t.stringLiteral("function"),
|
|
96
|
+
),
|
|
97
|
+
t.callExpression(t.identifier(name), []),
|
|
98
|
+
t.identifier(name),
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
// const _k = x.nodeType === 11 ? Array.from(x.childNodes) : [x]
|
|
102
|
+
// A fragment empties into the page when inserted, and cannot be removed
|
|
103
|
+
// itself: what must be removed later is the nodes it held.
|
|
104
|
+
const keepNodes = (name: string): t.Statement =>
|
|
105
|
+
t.variableDeclaration("const", [
|
|
106
|
+
t.variableDeclarator(
|
|
107
|
+
t.identifier("_k"),
|
|
108
|
+
t.conditionalExpression(
|
|
109
|
+
t.binaryExpression(
|
|
110
|
+
"===",
|
|
111
|
+
t.memberExpression(t.identifier(name), t.identifier("nodeType")),
|
|
112
|
+
t.numericLiteral(11),
|
|
113
|
+
),
|
|
114
|
+
t.callExpression(
|
|
115
|
+
t.memberExpression(t.identifier("Array"), t.identifier("from")),
|
|
116
|
+
[
|
|
117
|
+
t.memberExpression(
|
|
118
|
+
t.identifier(name),
|
|
119
|
+
t.identifier("childNodes"),
|
|
120
|
+
),
|
|
121
|
+
],
|
|
122
|
+
),
|
|
123
|
+
t.arrayExpression([t.identifier(name)]),
|
|
124
|
+
),
|
|
125
|
+
),
|
|
126
|
+
]);
|
|
127
|
+
const pushKept = (): t.Statement =>
|
|
128
|
+
t.expressionStatement(
|
|
129
|
+
t.callExpression(
|
|
130
|
+
t.memberExpression(t.identifier("_nodes"), t.identifier("push")),
|
|
131
|
+
[t.spreadElement(t.identifier("_k"))],
|
|
132
|
+
),
|
|
133
|
+
);
|
|
134
|
+
|
|
135
|
+
// function _mountFn(_v, _a) { ... }
|
|
136
|
+
const mountBody = t.blockStatement([
|
|
137
|
+
t.expressionStatement(
|
|
138
|
+
t.assignmentExpression("=", t.identifier("_v"), unwrapThunk("_v")),
|
|
139
|
+
),
|
|
140
|
+
t.variableDeclaration("const", [
|
|
141
|
+
t.variableDeclarator(t.identifier("_nodes"), t.arrayExpression([])),
|
|
142
|
+
]),
|
|
143
|
+
t.ifStatement(
|
|
144
|
+
t.callExpression(
|
|
145
|
+
t.memberExpression(t.identifier("Array"), t.identifier("isArray")),
|
|
146
|
+
[t.identifier("_v")],
|
|
147
|
+
),
|
|
148
|
+
t.blockStatement([
|
|
149
|
+
t.forOfStatement(
|
|
150
|
+
t.variableDeclaration("let", [
|
|
151
|
+
t.variableDeclarator(t.identifier("_item")),
|
|
152
|
+
]),
|
|
153
|
+
t.identifier("_v"),
|
|
154
|
+
t.blockStatement([
|
|
155
|
+
t.expressionStatement(
|
|
156
|
+
t.assignmentExpression(
|
|
157
|
+
"=",
|
|
158
|
+
t.identifier("_item"),
|
|
159
|
+
unwrapThunk("_item"),
|
|
160
|
+
),
|
|
161
|
+
),
|
|
162
|
+
t.variableDeclaration("const", [
|
|
163
|
+
t.variableDeclarator(
|
|
164
|
+
t.identifier("_n"),
|
|
165
|
+
t.conditionalExpression(
|
|
166
|
+
t.binaryExpression(
|
|
167
|
+
"instanceof",
|
|
168
|
+
t.identifier("_item"),
|
|
169
|
+
t.identifier("Node"),
|
|
170
|
+
),
|
|
171
|
+
t.identifier("_item"),
|
|
172
|
+
t.callExpression(
|
|
173
|
+
t.memberExpression(
|
|
174
|
+
t.identifier("document"),
|
|
175
|
+
t.identifier("createTextNode"),
|
|
176
|
+
),
|
|
177
|
+
[
|
|
178
|
+
t.callExpression(t.identifier("String"), [
|
|
179
|
+
t.logicalExpression(
|
|
180
|
+
"??",
|
|
181
|
+
t.identifier("_item"),
|
|
182
|
+
t.stringLiteral(""),
|
|
183
|
+
),
|
|
184
|
+
]),
|
|
185
|
+
],
|
|
186
|
+
),
|
|
187
|
+
),
|
|
188
|
+
),
|
|
189
|
+
]),
|
|
190
|
+
keepNodes("_n"),
|
|
191
|
+
t.expressionStatement(
|
|
192
|
+
t.callExpression(
|
|
193
|
+
t.memberExpression(t.identifier("_a"), t.identifier("before")),
|
|
194
|
+
[t.identifier("_n")],
|
|
195
|
+
),
|
|
196
|
+
),
|
|
197
|
+
pushKept(),
|
|
198
|
+
]),
|
|
199
|
+
),
|
|
200
|
+
]),
|
|
201
|
+
t.ifStatement(
|
|
202
|
+
t.binaryExpression(
|
|
203
|
+
"instanceof",
|
|
204
|
+
t.identifier("_v"),
|
|
205
|
+
t.identifier("Node"),
|
|
206
|
+
),
|
|
207
|
+
t.blockStatement([
|
|
208
|
+
keepNodes("_v"),
|
|
209
|
+
t.expressionStatement(
|
|
210
|
+
t.callExpression(
|
|
211
|
+
t.memberExpression(t.identifier("_a"), t.identifier("before")),
|
|
212
|
+
[t.identifier("_v")],
|
|
213
|
+
),
|
|
214
|
+
),
|
|
215
|
+
pushKept(),
|
|
216
|
+
]),
|
|
217
|
+
t.ifStatement(
|
|
218
|
+
t.logicalExpression(
|
|
219
|
+
"&&",
|
|
220
|
+
t.logicalExpression(
|
|
221
|
+
"&&",
|
|
222
|
+
t.binaryExpression("!=", t.identifier("_v"), t.nullLiteral()),
|
|
223
|
+
t.binaryExpression(
|
|
224
|
+
"!==",
|
|
225
|
+
t.identifier("_v"),
|
|
226
|
+
t.booleanLiteral(false),
|
|
227
|
+
),
|
|
228
|
+
),
|
|
229
|
+
t.binaryExpression(
|
|
230
|
+
"!==",
|
|
231
|
+
t.identifier("_v"),
|
|
232
|
+
t.booleanLiteral(true),
|
|
233
|
+
),
|
|
234
|
+
),
|
|
235
|
+
t.blockStatement([
|
|
236
|
+
t.variableDeclaration("const", [
|
|
237
|
+
t.variableDeclarator(
|
|
238
|
+
t.identifier("_n"),
|
|
239
|
+
t.callExpression(
|
|
240
|
+
t.memberExpression(
|
|
241
|
+
t.identifier("document"),
|
|
242
|
+
t.identifier("createTextNode"),
|
|
243
|
+
),
|
|
244
|
+
[
|
|
245
|
+
t.callExpression(t.identifier("String"), [
|
|
246
|
+
t.identifier("_v"),
|
|
247
|
+
]),
|
|
248
|
+
],
|
|
249
|
+
),
|
|
250
|
+
),
|
|
251
|
+
]),
|
|
252
|
+
t.expressionStatement(
|
|
253
|
+
t.callExpression(
|
|
254
|
+
t.memberExpression(t.identifier("_a"), t.identifier("before")),
|
|
255
|
+
[t.identifier("_n")],
|
|
256
|
+
),
|
|
257
|
+
),
|
|
258
|
+
t.expressionStatement(
|
|
259
|
+
t.callExpression(
|
|
260
|
+
t.memberExpression(
|
|
261
|
+
t.identifier("_nodes"),
|
|
262
|
+
t.identifier("push"),
|
|
263
|
+
),
|
|
264
|
+
[t.identifier("_n")],
|
|
265
|
+
),
|
|
266
|
+
),
|
|
267
|
+
]),
|
|
268
|
+
),
|
|
269
|
+
),
|
|
270
|
+
),
|
|
271
|
+
t.returnStatement(t.identifier("_nodes")),
|
|
272
|
+
]);
|
|
273
|
+
|
|
274
|
+
statements.push(
|
|
275
|
+
t.functionDeclaration(
|
|
276
|
+
t.identifier(mountFn),
|
|
277
|
+
[t.identifier("_v"), t.identifier("_a")],
|
|
278
|
+
mountBody,
|
|
279
|
+
),
|
|
280
|
+
);
|
|
281
|
+
|
|
282
|
+
const disposeVar = genId();
|
|
283
|
+
|
|
284
|
+
statements.push(
|
|
285
|
+
t.variableDeclaration("let", [
|
|
286
|
+
t.variableDeclarator(t.identifier(disposeVar), t.nullLiteral()),
|
|
287
|
+
]),
|
|
288
|
+
);
|
|
289
|
+
|
|
290
|
+
statements.push(
|
|
291
|
+
t.expressionStatement(
|
|
292
|
+
t.callExpression(t.identifier("createEffect"), [
|
|
293
|
+
t.arrowFunctionExpression(
|
|
294
|
+
[],
|
|
295
|
+
t.blockStatement([
|
|
296
|
+
t.expressionStatement(
|
|
297
|
+
t.optionalCallExpression(t.identifier(disposeVar), [], true),
|
|
298
|
+
),
|
|
299
|
+
t.forOfStatement(
|
|
300
|
+
t.variableDeclaration("const", [
|
|
301
|
+
t.variableDeclarator(t.identifier("_n")),
|
|
302
|
+
]),
|
|
303
|
+
t.identifier(prevVar),
|
|
304
|
+
t.expressionStatement(
|
|
305
|
+
t.callExpression(t.identifier("removeAnimated"), [
|
|
306
|
+
t.identifier("_n"),
|
|
307
|
+
]),
|
|
308
|
+
),
|
|
309
|
+
),
|
|
310
|
+
t.expressionStatement(
|
|
311
|
+
t.assignmentExpression(
|
|
312
|
+
"=",
|
|
313
|
+
t.identifier(disposeVar),
|
|
314
|
+
t.callExpression(t.identifier("withEffectScope"), [
|
|
315
|
+
t.arrowFunctionExpression(
|
|
316
|
+
[],
|
|
317
|
+
t.blockStatement([
|
|
318
|
+
t.expressionStatement(
|
|
319
|
+
t.assignmentExpression(
|
|
320
|
+
"=",
|
|
321
|
+
t.identifier(prevVar),
|
|
322
|
+
t.callExpression(t.identifier(mountFn), [
|
|
323
|
+
expr,
|
|
324
|
+
t.identifier(anchorVar),
|
|
325
|
+
]),
|
|
326
|
+
),
|
|
327
|
+
),
|
|
328
|
+
]),
|
|
329
|
+
),
|
|
330
|
+
]),
|
|
331
|
+
),
|
|
332
|
+
),
|
|
333
|
+
]),
|
|
334
|
+
),
|
|
335
|
+
]),
|
|
336
|
+
),
|
|
337
|
+
);
|
|
338
|
+
}
|