babel-plugin-essor 0.0.15-beta.1 → 0.0.15-beta.5
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/dist/index.cjs +329 -302
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +329 -302
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -19,7 +19,7 @@ var __spreadValues = (a2, b) => {
|
|
|
19
19
|
var __spreadProps = (a2, b) => __defProps(a2, __getOwnPropDescs(b));
|
|
20
20
|
|
|
21
21
|
// src/program.ts
|
|
22
|
-
import { types as
|
|
22
|
+
import { types as t4 } from "@babel/core";
|
|
23
23
|
|
|
24
24
|
// src/import.ts
|
|
25
25
|
import { types as t } from "@babel/core";
|
|
@@ -205,75 +205,31 @@ function createImport(path, imports, from) {
|
|
|
205
205
|
}
|
|
206
206
|
}
|
|
207
207
|
|
|
208
|
-
// src/
|
|
209
|
-
|
|
210
|
-
enter: (path, state) => {
|
|
211
|
-
const opts = __spreadValues(__spreadValues({}, DEFAULT_OPTIONS), state.opts);
|
|
212
|
-
const imports = createImportIdentifiers(path);
|
|
213
|
-
clearImport();
|
|
214
|
-
path.state = __spreadProps(__spreadValues({}, state), {
|
|
215
|
-
opts,
|
|
216
|
-
imports,
|
|
217
|
-
declarations: [],
|
|
218
|
-
// Collect template declarations during transformation
|
|
219
|
-
filename: state.filename,
|
|
220
|
-
events: /* @__PURE__ */ new Set()
|
|
221
|
-
// Track delegated events for optimization
|
|
222
|
-
});
|
|
223
|
-
},
|
|
224
|
-
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
225
|
-
exit: (path, state) => {
|
|
226
|
-
const pluginState = path.state;
|
|
227
|
-
const { imports, declarations, events } = pluginState;
|
|
228
|
-
const insertIndex = path.node.body.findIndex(
|
|
229
|
-
(node) => !t2.isImportDeclaration(node) && !t2.isExportDeclaration(node)
|
|
230
|
-
);
|
|
231
|
-
if (declarations == null ? void 0 : declarations.length) {
|
|
232
|
-
const templateDeclaration = t2.variableDeclaration("const", declarations);
|
|
233
|
-
if (insertIndex !== -1) {
|
|
234
|
-
path.node.body.splice(insertIndex, 0, templateDeclaration);
|
|
235
|
-
} else {
|
|
236
|
-
path.node.body.push(templateDeclaration);
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
if (events && events.size > 0) {
|
|
240
|
-
const eventsDeclaration = t2.expressionStatement(
|
|
241
|
-
t2.callExpression(imports.delegateEvents, [
|
|
242
|
-
t2.arrayExpression(Array.from(events).map((event) => t2.stringLiteral(event)))
|
|
243
|
-
])
|
|
244
|
-
);
|
|
245
|
-
addImport(importMap.delegateEvents);
|
|
246
|
-
path.node.body.push(eventsDeclaration);
|
|
247
|
-
}
|
|
248
|
-
createImport(path, imports, "essor");
|
|
249
|
-
}
|
|
250
|
-
};
|
|
251
|
-
|
|
252
|
-
// src/signals/props.ts
|
|
253
|
-
import { types as t4 } from "@babel/core";
|
|
208
|
+
// src/signals/symbol.ts
|
|
209
|
+
import { types as t3 } from "@babel/core";
|
|
254
210
|
|
|
255
211
|
// src/signals/utils.ts
|
|
256
|
-
import { types as
|
|
212
|
+
import { types as t2 } from "@babel/core";
|
|
257
213
|
function isValidPath(path) {
|
|
258
214
|
return !!(path && path.node);
|
|
259
215
|
}
|
|
260
216
|
function isJSXNode(node) {
|
|
261
|
-
return !!(node && (
|
|
217
|
+
return !!(node && (t2.isJSXElement(node) || t2.isJSXFragment(node)));
|
|
262
218
|
}
|
|
263
219
|
function mightReturnJSX(expr) {
|
|
264
220
|
if (isJSXNode(expr)) {
|
|
265
221
|
return true;
|
|
266
222
|
}
|
|
267
|
-
if (
|
|
223
|
+
if (t2.isConditionalExpression(expr)) {
|
|
268
224
|
return mightReturnJSX(expr.consequent) || mightReturnJSX(expr.alternate);
|
|
269
225
|
}
|
|
270
|
-
if (
|
|
226
|
+
if (t2.isLogicalExpression(expr)) {
|
|
271
227
|
return mightReturnJSX(expr.left) || mightReturnJSX(expr.right);
|
|
272
228
|
}
|
|
273
|
-
if (
|
|
229
|
+
if (t2.isSequenceExpression(expr)) {
|
|
274
230
|
return expr.expressions.some(mightReturnJSX);
|
|
275
231
|
}
|
|
276
|
-
if (
|
|
232
|
+
if (t2.isParenthesizedExpression(expr)) {
|
|
277
233
|
return mightReturnJSX(expr.expression);
|
|
278
234
|
}
|
|
279
235
|
return false;
|
|
@@ -283,7 +239,7 @@ function checkHasJSXReturn(path) {
|
|
|
283
239
|
try {
|
|
284
240
|
const body = path.get("body");
|
|
285
241
|
if (!isValidPath(body)) return false;
|
|
286
|
-
if (!
|
|
242
|
+
if (!t2.isBlockStatement(body.node)) {
|
|
287
243
|
return mightReturnJSX(body.node);
|
|
288
244
|
}
|
|
289
245
|
let hasJSX = false;
|
|
@@ -304,202 +260,22 @@ function checkHasJSXReturn(path) {
|
|
|
304
260
|
}
|
|
305
261
|
}
|
|
306
262
|
function isMemberAccessingProperty(node, propertyName) {
|
|
307
|
-
if (!node.computed &&
|
|
263
|
+
if (!node.computed && t2.isIdentifier(node.property) && node.property.name === propertyName) {
|
|
308
264
|
return true;
|
|
309
265
|
}
|
|
310
|
-
if (node.computed &&
|
|
266
|
+
if (node.computed && t2.isStringLiteral(node.property) && node.property.value === propertyName) {
|
|
311
267
|
return true;
|
|
312
268
|
}
|
|
313
269
|
return false;
|
|
314
270
|
}
|
|
315
271
|
|
|
316
|
-
// src/signals/props.ts
|
|
317
|
-
function transformProperty(path, properties, parentPath, defaultValues = {}) {
|
|
318
|
-
properties.forEach((property, index) => {
|
|
319
|
-
try {
|
|
320
|
-
if (!t4.isObjectProperty(property)) {
|
|
321
|
-
return;
|
|
322
|
-
}
|
|
323
|
-
if (!t4.isIdentifier(property.key)) {
|
|
324
|
-
if (true) {
|
|
325
|
-
ne("transformObjectProperties: Skipping computed property", { index });
|
|
326
|
-
}
|
|
327
|
-
return;
|
|
328
|
-
}
|
|
329
|
-
const keyName = property.key.name;
|
|
330
|
-
if (t4.isIdentifier(property.value)) {
|
|
331
|
-
path.scope.rename(property.value.name, `${parentPath}.${keyName}`);
|
|
332
|
-
} else if (t4.isAssignmentPattern(property.value)) {
|
|
333
|
-
if (t4.isIdentifier(property.value.left)) {
|
|
334
|
-
defaultValues[keyName] = property.value.right;
|
|
335
|
-
path.scope.rename(property.value.left.name, `${parentPath}.${keyName}`);
|
|
336
|
-
} else if (t4.isObjectPattern(property.value.left)) {
|
|
337
|
-
transformProperty(
|
|
338
|
-
path,
|
|
339
|
-
property.value.left.properties,
|
|
340
|
-
`${parentPath}.${keyName}`,
|
|
341
|
-
defaultValues
|
|
342
|
-
);
|
|
343
|
-
defaultValues[keyName] = property.value.right;
|
|
344
|
-
}
|
|
345
|
-
} else if (t4.isObjectPattern(property.value)) {
|
|
346
|
-
transformProperty(
|
|
347
|
-
path,
|
|
348
|
-
property.value.properties,
|
|
349
|
-
`${parentPath}.${keyName}`,
|
|
350
|
-
defaultValues
|
|
351
|
-
);
|
|
352
|
-
}
|
|
353
|
-
} catch (error) {
|
|
354
|
-
ne("transformProperty", `Failed to process property at index ${index}`, {
|
|
355
|
-
error: error instanceof Error ? error.message : String(error)
|
|
356
|
-
});
|
|
357
|
-
}
|
|
358
|
-
});
|
|
359
|
-
return defaultValues;
|
|
360
|
-
}
|
|
361
|
-
function buildRestVariableDeclaration(state, restName, parentPath, excludeProps) {
|
|
362
|
-
const validExcludeProps = excludeProps.filter(Boolean);
|
|
363
|
-
let init;
|
|
364
|
-
const pathParts = parentPath.split(".").filter((part) => part.length > 0);
|
|
365
|
-
let sourceObject = t4.identifier(pathParts[0] || "__props");
|
|
366
|
-
for (let i = 1; i < pathParts.length; i++) {
|
|
367
|
-
sourceObject = t4.memberExpression(sourceObject, t4.identifier(pathParts[i]));
|
|
368
|
-
}
|
|
369
|
-
if (validExcludeProps.length === 0) {
|
|
370
|
-
init = sourceObject;
|
|
371
|
-
} else {
|
|
372
|
-
init = t4.callExpression(state.imports.omitProps, [
|
|
373
|
-
sourceObject,
|
|
374
|
-
t4.arrayExpression(validExcludeProps.map((name) => t4.stringLiteral(name)))
|
|
375
|
-
]);
|
|
376
|
-
}
|
|
377
|
-
return t4.variableDeclaration("const", [t4.variableDeclarator(t4.identifier(restName), init)]);
|
|
378
|
-
}
|
|
379
|
-
function transformRestProperties(path, restProperties, notRestNames = [], nestedRestParams = []) {
|
|
380
|
-
if (!t4.isIdentifier(restProperties.argument)) {
|
|
381
|
-
return;
|
|
382
|
-
}
|
|
383
|
-
const restName = restProperties.argument.name;
|
|
384
|
-
if (notRestNames.length === 0 && nestedRestParams.length === 0) {
|
|
385
|
-
path.node.params[0] = t4.identifier(restName);
|
|
386
|
-
} else {
|
|
387
|
-
const restDeclarations = [];
|
|
388
|
-
if (nestedRestParams.length > 0) {
|
|
389
|
-
for (const nestedRest of nestedRestParams) {
|
|
390
|
-
const nestedRestDeclaration = buildRestVariableDeclaration(
|
|
391
|
-
path.state,
|
|
392
|
-
nestedRest.name,
|
|
393
|
-
nestedRest.parentPath,
|
|
394
|
-
nestedRest.excludeProps
|
|
395
|
-
);
|
|
396
|
-
restDeclarations.push(nestedRestDeclaration);
|
|
397
|
-
if (nestedRest.excludeProps.length > 0) {
|
|
398
|
-
addImport(importMap.omitProps);
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
if (restProperties) {
|
|
403
|
-
const restDeclaration = buildRestVariableDeclaration(
|
|
404
|
-
path.state,
|
|
405
|
-
restName,
|
|
406
|
-
TRANSFORM_PROPERTY_NAME,
|
|
407
|
-
notRestNames
|
|
408
|
-
);
|
|
409
|
-
restDeclarations.push(restDeclaration);
|
|
410
|
-
if (notRestNames.length) {
|
|
411
|
-
addImport(importMap.omitProps);
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
for (const declaration of restDeclarations) {
|
|
415
|
-
const body = path.node.body;
|
|
416
|
-
body.body.unshift(declaration);
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
function buildDefaultValueObject(defaultValues) {
|
|
421
|
-
if (!P(defaultValues)) {
|
|
422
|
-
return t4.objectExpression([]);
|
|
423
|
-
}
|
|
424
|
-
const properties = [];
|
|
425
|
-
for (const [key, value] of Object.entries(defaultValues)) {
|
|
426
|
-
if (!key) {
|
|
427
|
-
continue;
|
|
428
|
-
}
|
|
429
|
-
let propertyValue;
|
|
430
|
-
if (P(value) && !t4.isNode(value)) {
|
|
431
|
-
propertyValue = buildDefaultValueObject(value);
|
|
432
|
-
} else if (t4.isExpression(value)) {
|
|
433
|
-
propertyValue = value;
|
|
434
|
-
} else {
|
|
435
|
-
continue;
|
|
436
|
-
}
|
|
437
|
-
properties.push(t4.objectProperty(t4.identifier(key), propertyValue));
|
|
438
|
-
}
|
|
439
|
-
return t4.objectExpression(properties);
|
|
440
|
-
}
|
|
441
|
-
function buildDefaultValue(path, defaultValues) {
|
|
442
|
-
const propsParam = Object.keys(defaultValues).length > 0 ? t4.assignmentPattern(
|
|
443
|
-
t4.identifier(TRANSFORM_PROPERTY_NAME),
|
|
444
|
-
buildDefaultValueObject(defaultValues)
|
|
445
|
-
) : t4.identifier(TRANSFORM_PROPERTY_NAME);
|
|
446
|
-
path.node.params[0] = propsParam;
|
|
447
|
-
}
|
|
448
|
-
function transformProps(path) {
|
|
449
|
-
const firstParam = path.node.params[0];
|
|
450
|
-
if (!firstParam || !t4.isObjectPattern(firstParam) || !checkHasJSXReturn(path)) {
|
|
451
|
-
return;
|
|
452
|
-
}
|
|
453
|
-
const state = path.state;
|
|
454
|
-
const properties = firstParam.properties;
|
|
455
|
-
const signalPrefix = state.opts.symbol || "$";
|
|
456
|
-
const notRestProperties = properties.filter((prop) => !t4.isRestElement(prop));
|
|
457
|
-
const restProperties = properties.find((prop) => t4.isRestElement(prop));
|
|
458
|
-
const notRestNames = notRestProperties.map((prop) => t4.isIdentifier(prop.key) ? prop.key.name : null).filter((name) => name !== null);
|
|
459
|
-
if (true) {
|
|
460
|
-
if (notRestNames.some((name) => q(name, signalPrefix))) {
|
|
461
|
-
ne(
|
|
462
|
-
"transformProps",
|
|
463
|
-
"Property names cannot start with signal prefix",
|
|
464
|
-
notRestNames.filter((name) => q(name, signalPrefix))
|
|
465
|
-
);
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
if (notRestProperties.length) {
|
|
469
|
-
const defaultValues = transformProperty(path, notRestProperties, TRANSFORM_PROPERTY_NAME);
|
|
470
|
-
buildDefaultValue(path, defaultValues);
|
|
471
|
-
}
|
|
472
|
-
if (restProperties) {
|
|
473
|
-
transformRestProperties(path, restProperties, notRestNames);
|
|
474
|
-
}
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
// src/jsx/context.ts
|
|
478
|
-
var contextStack = [];
|
|
479
|
-
function getContext() {
|
|
480
|
-
if (!contextStack.length) {
|
|
481
|
-
throw new Error("No active context found. Ensure setContext has been called.");
|
|
482
|
-
}
|
|
483
|
-
return contextStack[contextStack.length - 1];
|
|
484
|
-
}
|
|
485
|
-
function setContext(context) {
|
|
486
|
-
contextStack.push(context);
|
|
487
|
-
}
|
|
488
|
-
function resetContext() {
|
|
489
|
-
contextStack.pop();
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
// src/jsx/client.ts
|
|
493
|
-
import { types as t8 } from "@babel/core";
|
|
494
|
-
|
|
495
272
|
// src/signals/symbol.ts
|
|
496
|
-
import { types as t5 } from "@babel/core";
|
|
497
273
|
function isSignal(name) {
|
|
498
274
|
return !!name && name.startsWith("$");
|
|
499
275
|
}
|
|
500
276
|
function replaceSymbol(path) {
|
|
501
277
|
const { init, id } = path.node;
|
|
502
|
-
if (!
|
|
278
|
+
if (!t3.isIdentifier(id)) {
|
|
503
279
|
return;
|
|
504
280
|
}
|
|
505
281
|
const variableName = id.name;
|
|
@@ -509,16 +285,16 @@ function replaceSymbol(path) {
|
|
|
509
285
|
if (isAlreadySignalCall(init)) {
|
|
510
286
|
return;
|
|
511
287
|
}
|
|
512
|
-
const isComputed = init && (
|
|
288
|
+
const isComputed = init && (t3.isFunctionExpression(init) || t3.isArrowFunctionExpression(init)) && path.parent.kind === "const";
|
|
513
289
|
const importName = isComputed ? "computed" : "signal";
|
|
514
290
|
const state = path.state;
|
|
515
291
|
const args = init ? [init] : [];
|
|
516
|
-
const newInit =
|
|
292
|
+
const newInit = t3.callExpression(t3.identifier(state.imports[importName].name), args);
|
|
517
293
|
addImport(importName);
|
|
518
294
|
path.node.init = newInit;
|
|
519
295
|
}
|
|
520
296
|
function isAlreadySignalCall(init) {
|
|
521
|
-
if (!init || !
|
|
297
|
+
if (!init || !t3.isCallExpression(init) || !t3.isIdentifier(init.callee)) {
|
|
522
298
|
return false;
|
|
523
299
|
}
|
|
524
300
|
const calleeName = init.callee.name;
|
|
@@ -538,7 +314,11 @@ function symbolIdentifier(path) {
|
|
|
538
314
|
if (isAlreadyValueAccess(path)) {
|
|
539
315
|
return;
|
|
540
316
|
}
|
|
541
|
-
path.
|
|
317
|
+
const parent = path.parent;
|
|
318
|
+
if (t3.isMemberExpression(parent) && parent.property === path.node) {
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
path.replaceWith(t3.memberExpression(t3.identifier(name), t3.identifier("value")));
|
|
542
322
|
}
|
|
543
323
|
function shouldProcessIdentifier(path, parentPath) {
|
|
544
324
|
if (!parentPath) {
|
|
@@ -546,38 +326,38 @@ function shouldProcessIdentifier(path, parentPath) {
|
|
|
546
326
|
}
|
|
547
327
|
const parent = parentPath.node;
|
|
548
328
|
const currentNode = path.node;
|
|
549
|
-
if (
|
|
329
|
+
if (t3.isVariableDeclarator(parent) || t3.isArrayPattern(parent) || t3.isObjectPattern(parent)) {
|
|
550
330
|
return false;
|
|
551
331
|
}
|
|
552
|
-
if (
|
|
332
|
+
if (t3.isImportSpecifier(parent) || t3.isImportDefaultSpecifier(parent) || t3.isImportNamespaceSpecifier(parent)) {
|
|
553
333
|
return false;
|
|
554
334
|
}
|
|
555
|
-
if (
|
|
335
|
+
if (t3.isFunctionDeclaration(parent) || t3.isFunctionExpression(parent) || t3.isArrowFunctionExpression(parent)) {
|
|
556
336
|
return false;
|
|
557
337
|
}
|
|
558
|
-
if (
|
|
338
|
+
if (t3.isClassDeclaration(parent) && parent.id === currentNode) {
|
|
559
339
|
return false;
|
|
560
340
|
}
|
|
561
|
-
if (
|
|
341
|
+
if (t3.isObjectMethod(parent) || t3.isClassMethod(parent)) {
|
|
562
342
|
return false;
|
|
563
343
|
}
|
|
564
|
-
if (
|
|
344
|
+
if (t3.isObjectProperty(parent) && parent.key === currentNode) {
|
|
565
345
|
return false;
|
|
566
346
|
}
|
|
567
|
-
if (
|
|
347
|
+
if (t3.isLabeledStatement(parent) && parent.label === currentNode) {
|
|
568
348
|
return false;
|
|
569
349
|
}
|
|
570
|
-
if ((
|
|
350
|
+
if ((t3.isBreakStatement(parent) || t3.isContinueStatement(parent)) && parent.label === currentNode) {
|
|
571
351
|
return false;
|
|
572
352
|
}
|
|
573
353
|
return true;
|
|
574
354
|
}
|
|
575
355
|
function isAlreadyValueAccess(path) {
|
|
576
356
|
const parent = path.parent;
|
|
577
|
-
if (
|
|
357
|
+
if (t3.isMemberExpression(parent) && parent.object === path.node) {
|
|
578
358
|
return isMemberAccessingProperty(parent, "value");
|
|
579
359
|
}
|
|
580
|
-
if (!
|
|
360
|
+
if (!t3.isParenthesizedExpression(parent) && !t3.isTSAsExpression(parent) && !t3.isTSNonNullExpression(parent)) {
|
|
581
361
|
return false;
|
|
582
362
|
}
|
|
583
363
|
const ancestorCheck = path.findParent((p) => {
|
|
@@ -594,7 +374,7 @@ function symbolAssignment(path) {
|
|
|
594
374
|
return;
|
|
595
375
|
}
|
|
596
376
|
const { left } = path.node;
|
|
597
|
-
if (!
|
|
377
|
+
if (!t3.isIdentifier(left)) {
|
|
598
378
|
return;
|
|
599
379
|
}
|
|
600
380
|
const name = left.name;
|
|
@@ -604,17 +384,17 @@ function symbolAssignment(path) {
|
|
|
604
384
|
if (isAlreadyValueAssignment(left)) {
|
|
605
385
|
return;
|
|
606
386
|
}
|
|
607
|
-
path.node.left =
|
|
387
|
+
path.node.left = t3.memberExpression(t3.identifier(name), t3.identifier("value"));
|
|
608
388
|
}
|
|
609
389
|
function isAlreadyValueAssignment(left) {
|
|
610
|
-
return
|
|
390
|
+
return t3.isMemberExpression(left) && isMemberAccessingProperty(left, "value");
|
|
611
391
|
}
|
|
612
392
|
function symbolUpdate(path) {
|
|
613
393
|
if (!isValidPath(path)) {
|
|
614
394
|
return;
|
|
615
395
|
}
|
|
616
396
|
const { argument } = path.node;
|
|
617
|
-
if (!
|
|
397
|
+
if (!t3.isIdentifier(argument)) {
|
|
618
398
|
return;
|
|
619
399
|
}
|
|
620
400
|
const name = argument.name;
|
|
@@ -624,10 +404,10 @@ function symbolUpdate(path) {
|
|
|
624
404
|
if (isAlreadyValueUpdate(argument)) {
|
|
625
405
|
return;
|
|
626
406
|
}
|
|
627
|
-
path.node.argument =
|
|
407
|
+
path.node.argument = t3.memberExpression(t3.identifier(name), t3.identifier("value"));
|
|
628
408
|
}
|
|
629
409
|
function isAlreadyValueUpdate(argument) {
|
|
630
|
-
return
|
|
410
|
+
return t3.isMemberExpression(argument) && isMemberAccessingProperty(argument, "value");
|
|
631
411
|
}
|
|
632
412
|
function symbolObjectPattern(path) {
|
|
633
413
|
if (!isValidPath(path)) {
|
|
@@ -639,9 +419,9 @@ function symbolObjectPattern(path) {
|
|
|
639
419
|
}
|
|
640
420
|
for (const property of properties) {
|
|
641
421
|
if (!property) continue;
|
|
642
|
-
if (
|
|
422
|
+
if (t3.isObjectProperty(property)) {
|
|
643
423
|
handleObjectProperty(property, path);
|
|
644
|
-
} else if (
|
|
424
|
+
} else if (t3.isRestElement(property)) {
|
|
645
425
|
handleRestElement(property, path);
|
|
646
426
|
}
|
|
647
427
|
}
|
|
@@ -651,34 +431,34 @@ function handleObjectProperty(property, parentPath) {
|
|
|
651
431
|
return;
|
|
652
432
|
}
|
|
653
433
|
const value = property.value;
|
|
654
|
-
if (
|
|
434
|
+
if (t3.isObjectPattern(value)) {
|
|
655
435
|
const mockPath = {
|
|
656
436
|
node: value,
|
|
657
437
|
state: parentPath.state,
|
|
658
438
|
parentPath
|
|
659
439
|
};
|
|
660
440
|
symbolObjectPattern(mockPath);
|
|
661
|
-
} else if (
|
|
441
|
+
} else if (t3.isArrayPattern(value)) {
|
|
662
442
|
const mockPath = {
|
|
663
443
|
node: value,
|
|
664
444
|
state: parentPath.state,
|
|
665
445
|
parentPath
|
|
666
446
|
};
|
|
667
447
|
symbolArrayPattern(mockPath);
|
|
668
|
-
} else if (
|
|
448
|
+
} else if (t3.isAssignmentPattern(value)) {
|
|
669
449
|
handleAssignmentPattern(value, parentPath);
|
|
670
450
|
}
|
|
671
451
|
}
|
|
672
452
|
function handleAssignmentPattern(pattern, parentPath) {
|
|
673
453
|
const left = pattern.left;
|
|
674
|
-
if (
|
|
454
|
+
if (t3.isObjectPattern(left)) {
|
|
675
455
|
const mockPath = {
|
|
676
456
|
node: left,
|
|
677
457
|
state: parentPath.state,
|
|
678
458
|
parentPath
|
|
679
459
|
};
|
|
680
460
|
symbolObjectPattern(mockPath);
|
|
681
|
-
} else if (
|
|
461
|
+
} else if (t3.isArrayPattern(left)) {
|
|
682
462
|
const mockPath = {
|
|
683
463
|
node: left,
|
|
684
464
|
state: parentPath.state,
|
|
@@ -692,14 +472,14 @@ function handleRestElement(restElement, parentPath) {
|
|
|
692
472
|
return;
|
|
693
473
|
}
|
|
694
474
|
const argument = restElement.argument;
|
|
695
|
-
if (
|
|
475
|
+
if (t3.isObjectPattern(argument)) {
|
|
696
476
|
const mockPath = {
|
|
697
477
|
node: argument,
|
|
698
478
|
state: parentPath.state,
|
|
699
479
|
parentPath
|
|
700
480
|
};
|
|
701
481
|
symbolObjectPattern(mockPath);
|
|
702
|
-
} else if (
|
|
482
|
+
} else if (t3.isArrayPattern(argument)) {
|
|
703
483
|
const mockPath = {
|
|
704
484
|
node: argument,
|
|
705
485
|
state: parentPath.state,
|
|
@@ -718,18 +498,18 @@ function symbolArrayPattern(path) {
|
|
|
718
498
|
}
|
|
719
499
|
for (const element of elements) {
|
|
720
500
|
if (!element) continue;
|
|
721
|
-
if (
|
|
501
|
+
if (t3.isAssignmentPattern(element)) {
|
|
722
502
|
handleAssignmentPattern(element, path);
|
|
723
|
-
} else if (
|
|
503
|
+
} else if (t3.isRestElement(element)) {
|
|
724
504
|
handleArrayRestElement(element, path);
|
|
725
|
-
} else if (
|
|
505
|
+
} else if (t3.isObjectPattern(element)) {
|
|
726
506
|
const mockPath = {
|
|
727
507
|
node: element,
|
|
728
508
|
state: path.state,
|
|
729
509
|
parentPath: path
|
|
730
510
|
};
|
|
731
511
|
symbolObjectPattern(mockPath);
|
|
732
|
-
} else if (
|
|
512
|
+
} else if (t3.isArrayPattern(element)) {
|
|
733
513
|
const mockPath = {
|
|
734
514
|
node: element,
|
|
735
515
|
state: path.state,
|
|
@@ -744,14 +524,14 @@ function handleArrayRestElement(restElement, parentPath) {
|
|
|
744
524
|
return;
|
|
745
525
|
}
|
|
746
526
|
const argument = restElement.argument;
|
|
747
|
-
if (
|
|
527
|
+
if (t3.isArrayPattern(argument)) {
|
|
748
528
|
const mockPath = {
|
|
749
529
|
node: argument,
|
|
750
530
|
state: parentPath.state,
|
|
751
531
|
parentPath
|
|
752
532
|
};
|
|
753
533
|
symbolArrayPattern(mockPath);
|
|
754
|
-
} else if (
|
|
534
|
+
} else if (t3.isObjectPattern(argument)) {
|
|
755
535
|
const mockPath = {
|
|
756
536
|
node: argument,
|
|
757
537
|
state: parentPath.state,
|
|
@@ -761,6 +541,251 @@ function handleArrayRestElement(restElement, parentPath) {
|
|
|
761
541
|
}
|
|
762
542
|
}
|
|
763
543
|
|
|
544
|
+
// src/program.ts
|
|
545
|
+
function withState(visitor, parentState) {
|
|
546
|
+
return (path) => {
|
|
547
|
+
path.state = parentState;
|
|
548
|
+
visitor(path);
|
|
549
|
+
};
|
|
550
|
+
}
|
|
551
|
+
var transformProgram = {
|
|
552
|
+
enter: (path, state) => {
|
|
553
|
+
const opts = __spreadValues(__spreadValues({}, DEFAULT_OPTIONS), state.opts);
|
|
554
|
+
const imports = createImportIdentifiers(path);
|
|
555
|
+
clearImport();
|
|
556
|
+
path.state = __spreadProps(__spreadValues({}, state), {
|
|
557
|
+
opts,
|
|
558
|
+
imports,
|
|
559
|
+
declarations: [],
|
|
560
|
+
// Collect template declarations during transformation
|
|
561
|
+
filename: state.filename,
|
|
562
|
+
events: /* @__PURE__ */ new Set()
|
|
563
|
+
// Track delegated events for optimization
|
|
564
|
+
});
|
|
565
|
+
const parentState = path.state;
|
|
566
|
+
path.traverse({
|
|
567
|
+
VariableDeclarator: withState(replaceSymbol, parentState),
|
|
568
|
+
// let $x = 0 → let $x = signal(0)
|
|
569
|
+
Identifier: withState(symbolIdentifier, parentState),
|
|
570
|
+
// $x → $x.value
|
|
571
|
+
AssignmentExpression: withState(symbolAssignment, parentState),
|
|
572
|
+
// $x = 1 → $x.value = 1
|
|
573
|
+
UpdateExpression: withState(symbolUpdate, parentState),
|
|
574
|
+
// $x++ → $x.value++
|
|
575
|
+
ObjectPattern: withState(symbolObjectPattern, parentState),
|
|
576
|
+
// { $x } → handle nested patterns
|
|
577
|
+
ArrayPattern: withState(symbolArrayPattern, parentState)
|
|
578
|
+
// [$x] → handle nested patterns
|
|
579
|
+
});
|
|
580
|
+
},
|
|
581
|
+
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
582
|
+
exit: (path, state) => {
|
|
583
|
+
const pluginState = path.state;
|
|
584
|
+
const { imports, declarations, events } = pluginState;
|
|
585
|
+
const insertIndex = path.node.body.findIndex(
|
|
586
|
+
(node) => !t4.isImportDeclaration(node) && !t4.isExportDeclaration(node)
|
|
587
|
+
);
|
|
588
|
+
if (declarations == null ? void 0 : declarations.length) {
|
|
589
|
+
const templateDeclaration = t4.variableDeclaration("const", declarations);
|
|
590
|
+
if (insertIndex !== -1) {
|
|
591
|
+
path.node.body.splice(insertIndex, 0, templateDeclaration);
|
|
592
|
+
} else {
|
|
593
|
+
path.node.body.push(templateDeclaration);
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
if (events && events.size > 0) {
|
|
597
|
+
const eventsDeclaration = t4.expressionStatement(
|
|
598
|
+
t4.callExpression(imports.delegateEvents, [
|
|
599
|
+
t4.arrayExpression(Array.from(events).map((event) => t4.stringLiteral(event)))
|
|
600
|
+
])
|
|
601
|
+
);
|
|
602
|
+
addImport(importMap.delegateEvents);
|
|
603
|
+
path.node.body.push(eventsDeclaration);
|
|
604
|
+
}
|
|
605
|
+
createImport(path, imports, "essor");
|
|
606
|
+
}
|
|
607
|
+
};
|
|
608
|
+
|
|
609
|
+
// src/signals/props.ts
|
|
610
|
+
import { types as t5 } from "@babel/core";
|
|
611
|
+
function transformProperty(path, properties, parentPath, defaultValues = {}) {
|
|
612
|
+
properties.forEach((property, index) => {
|
|
613
|
+
try {
|
|
614
|
+
if (!t5.isObjectProperty(property)) {
|
|
615
|
+
return;
|
|
616
|
+
}
|
|
617
|
+
if (!t5.isIdentifier(property.key)) {
|
|
618
|
+
if (true) {
|
|
619
|
+
ne("transformObjectProperties: Skipping computed property", { index });
|
|
620
|
+
}
|
|
621
|
+
return;
|
|
622
|
+
}
|
|
623
|
+
const keyName = property.key.name;
|
|
624
|
+
if (t5.isIdentifier(property.value)) {
|
|
625
|
+
path.scope.rename(property.value.name, `${parentPath}.${keyName}`);
|
|
626
|
+
} else if (t5.isAssignmentPattern(property.value)) {
|
|
627
|
+
if (t5.isIdentifier(property.value.left)) {
|
|
628
|
+
defaultValues[keyName] = property.value.right;
|
|
629
|
+
path.scope.rename(property.value.left.name, `${parentPath}.${keyName}`);
|
|
630
|
+
} else if (t5.isObjectPattern(property.value.left)) {
|
|
631
|
+
transformProperty(
|
|
632
|
+
path,
|
|
633
|
+
property.value.left.properties,
|
|
634
|
+
`${parentPath}.${keyName}`,
|
|
635
|
+
defaultValues
|
|
636
|
+
);
|
|
637
|
+
defaultValues[keyName] = property.value.right;
|
|
638
|
+
}
|
|
639
|
+
} else if (t5.isObjectPattern(property.value)) {
|
|
640
|
+
transformProperty(
|
|
641
|
+
path,
|
|
642
|
+
property.value.properties,
|
|
643
|
+
`${parentPath}.${keyName}`,
|
|
644
|
+
defaultValues
|
|
645
|
+
);
|
|
646
|
+
}
|
|
647
|
+
} catch (error) {
|
|
648
|
+
ne("transformProperty", `Failed to process property at index ${index}`, {
|
|
649
|
+
error: error instanceof Error ? error.message : String(error)
|
|
650
|
+
});
|
|
651
|
+
}
|
|
652
|
+
});
|
|
653
|
+
return defaultValues;
|
|
654
|
+
}
|
|
655
|
+
function buildRestVariableDeclaration(state, restName, parentPath, excludeProps) {
|
|
656
|
+
const validExcludeProps = excludeProps.filter(Boolean);
|
|
657
|
+
let init;
|
|
658
|
+
const pathParts = parentPath.split(".").filter((part) => part.length > 0);
|
|
659
|
+
let sourceObject = t5.identifier(pathParts[0] || "__props");
|
|
660
|
+
for (let i = 1; i < pathParts.length; i++) {
|
|
661
|
+
sourceObject = t5.memberExpression(sourceObject, t5.identifier(pathParts[i]));
|
|
662
|
+
}
|
|
663
|
+
if (validExcludeProps.length === 0) {
|
|
664
|
+
init = sourceObject;
|
|
665
|
+
} else {
|
|
666
|
+
init = t5.callExpression(state.imports.omitProps, [
|
|
667
|
+
sourceObject,
|
|
668
|
+
t5.arrayExpression(validExcludeProps.map((name) => t5.stringLiteral(name)))
|
|
669
|
+
]);
|
|
670
|
+
}
|
|
671
|
+
return t5.variableDeclaration("const", [t5.variableDeclarator(t5.identifier(restName), init)]);
|
|
672
|
+
}
|
|
673
|
+
function transformRestProperties(path, restProperties, notRestNames = [], nestedRestParams = []) {
|
|
674
|
+
if (!t5.isIdentifier(restProperties.argument)) {
|
|
675
|
+
return;
|
|
676
|
+
}
|
|
677
|
+
const restName = restProperties.argument.name;
|
|
678
|
+
if (notRestNames.length === 0 && nestedRestParams.length === 0) {
|
|
679
|
+
path.node.params[0] = t5.identifier(restName);
|
|
680
|
+
} else {
|
|
681
|
+
const restDeclarations = [];
|
|
682
|
+
if (nestedRestParams.length > 0) {
|
|
683
|
+
for (const nestedRest of nestedRestParams) {
|
|
684
|
+
const nestedRestDeclaration = buildRestVariableDeclaration(
|
|
685
|
+
path.state,
|
|
686
|
+
nestedRest.name,
|
|
687
|
+
nestedRest.parentPath,
|
|
688
|
+
nestedRest.excludeProps
|
|
689
|
+
);
|
|
690
|
+
restDeclarations.push(nestedRestDeclaration);
|
|
691
|
+
if (nestedRest.excludeProps.length > 0) {
|
|
692
|
+
addImport(importMap.omitProps);
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
if (restProperties) {
|
|
697
|
+
const restDeclaration = buildRestVariableDeclaration(
|
|
698
|
+
path.state,
|
|
699
|
+
restName,
|
|
700
|
+
TRANSFORM_PROPERTY_NAME,
|
|
701
|
+
notRestNames
|
|
702
|
+
);
|
|
703
|
+
restDeclarations.push(restDeclaration);
|
|
704
|
+
if (notRestNames.length) {
|
|
705
|
+
addImport(importMap.omitProps);
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
for (const declaration of restDeclarations) {
|
|
709
|
+
const body = path.node.body;
|
|
710
|
+
body.body.unshift(declaration);
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
function buildDefaultValueObject(defaultValues) {
|
|
715
|
+
if (!P(defaultValues)) {
|
|
716
|
+
return t5.objectExpression([]);
|
|
717
|
+
}
|
|
718
|
+
const properties = [];
|
|
719
|
+
for (const [key, value] of Object.entries(defaultValues)) {
|
|
720
|
+
if (!key) {
|
|
721
|
+
continue;
|
|
722
|
+
}
|
|
723
|
+
let propertyValue;
|
|
724
|
+
if (P(value) && !t5.isNode(value)) {
|
|
725
|
+
propertyValue = buildDefaultValueObject(value);
|
|
726
|
+
} else if (t5.isExpression(value)) {
|
|
727
|
+
propertyValue = value;
|
|
728
|
+
} else {
|
|
729
|
+
continue;
|
|
730
|
+
}
|
|
731
|
+
properties.push(t5.objectProperty(t5.identifier(key), propertyValue));
|
|
732
|
+
}
|
|
733
|
+
return t5.objectExpression(properties);
|
|
734
|
+
}
|
|
735
|
+
function buildDefaultValue(path, defaultValues) {
|
|
736
|
+
const propsParam = Object.keys(defaultValues).length > 0 ? t5.assignmentPattern(
|
|
737
|
+
t5.identifier(TRANSFORM_PROPERTY_NAME),
|
|
738
|
+
buildDefaultValueObject(defaultValues)
|
|
739
|
+
) : t5.identifier(TRANSFORM_PROPERTY_NAME);
|
|
740
|
+
path.node.params[0] = propsParam;
|
|
741
|
+
}
|
|
742
|
+
function transformProps(path) {
|
|
743
|
+
const firstParam = path.node.params[0];
|
|
744
|
+
if (!firstParam || !t5.isObjectPattern(firstParam) || !checkHasJSXReturn(path)) {
|
|
745
|
+
return;
|
|
746
|
+
}
|
|
747
|
+
const state = path.state;
|
|
748
|
+
const properties = firstParam.properties;
|
|
749
|
+
const signalPrefix = state.opts.symbol || "$";
|
|
750
|
+
const notRestProperties = properties.filter((prop) => !t5.isRestElement(prop));
|
|
751
|
+
const restProperties = properties.find((prop) => t5.isRestElement(prop));
|
|
752
|
+
const notRestNames = notRestProperties.map((prop) => t5.isIdentifier(prop.key) ? prop.key.name : null).filter((name) => name !== null);
|
|
753
|
+
if (true) {
|
|
754
|
+
if (notRestNames.some((name) => q(name, signalPrefix))) {
|
|
755
|
+
ne(
|
|
756
|
+
"transformProps",
|
|
757
|
+
"Property names cannot start with signal prefix",
|
|
758
|
+
notRestNames.filter((name) => q(name, signalPrefix))
|
|
759
|
+
);
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
if (notRestProperties.length) {
|
|
763
|
+
const defaultValues = transformProperty(path, notRestProperties, TRANSFORM_PROPERTY_NAME);
|
|
764
|
+
buildDefaultValue(path, defaultValues);
|
|
765
|
+
}
|
|
766
|
+
if (restProperties) {
|
|
767
|
+
transformRestProperties(path, restProperties, notRestNames);
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
// src/jsx/context.ts
|
|
772
|
+
var contextStack = [];
|
|
773
|
+
function getContext() {
|
|
774
|
+
if (!contextStack.length) {
|
|
775
|
+
throw new Error("No active context found. Ensure setContext has been called.");
|
|
776
|
+
}
|
|
777
|
+
return contextStack[contextStack.length - 1];
|
|
778
|
+
}
|
|
779
|
+
function setContext(context) {
|
|
780
|
+
contextStack.push(context);
|
|
781
|
+
}
|
|
782
|
+
function resetContext() {
|
|
783
|
+
contextStack.pop();
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
// src/jsx/client.ts
|
|
787
|
+
import { types as t8 } from "@babel/core";
|
|
788
|
+
|
|
764
789
|
// src/jsx/constants.ts
|
|
765
790
|
var CLASS_NAME = "class";
|
|
766
791
|
var STYLE_NAME = "style";
|
|
@@ -768,6 +793,7 @@ var EVENT_ATTR_NAME = "on";
|
|
|
768
793
|
var UPDATE_PREFIX = "update";
|
|
769
794
|
var FRAGMENT_NAME = "Fragment";
|
|
770
795
|
var CHILDREN_NAME = "children";
|
|
796
|
+
var REF_KEY = "ref";
|
|
771
797
|
var SPREAD_NAME = "_$spread$";
|
|
772
798
|
var CREATE_COMPONENT_NAME = "createComponent";
|
|
773
799
|
var BIND_REG = /^bind:.+/;
|
|
@@ -798,15 +824,17 @@ function isTreeNode(node) {
|
|
|
798
824
|
var treeIndex = 1;
|
|
799
825
|
function createTree(path, parentNode) {
|
|
800
826
|
const treeNode = createDefaultTree();
|
|
827
|
+
const tagName = getTagName(path.node);
|
|
828
|
+
treeNode.tag = tagName;
|
|
829
|
+
treeNode.type = determineNodeType(tagName);
|
|
830
|
+
treeNode.selfClosing = Ne(tagName);
|
|
801
831
|
if (parentNode) {
|
|
802
|
-
const
|
|
803
|
-
|
|
804
|
-
const isComponentOrFragment = isComponentName(getTagName(nodeInfo));
|
|
805
|
-
if (!isComponentOrFragment && !isBuiltInComponent) {
|
|
806
|
-
treeNode.index = ++treeIndex;
|
|
807
|
-
}
|
|
808
|
-
if (isBuiltInComponent) {
|
|
832
|
+
const parentIsComponent = parentNode.type === 1 /* COMPONENT */;
|
|
833
|
+
if (parentIsComponent) {
|
|
809
834
|
treeIndex = 1;
|
|
835
|
+
treeNode.index = treeIndex;
|
|
836
|
+
} else if (treeNode.type !== 1 /* COMPONENT */) {
|
|
837
|
+
treeNode.index = ++treeIndex;
|
|
810
838
|
}
|
|
811
839
|
treeNode.parentIndex = treeIndex;
|
|
812
840
|
} else {
|
|
@@ -822,10 +850,6 @@ function createTree(path, parentNode) {
|
|
|
822
850
|
return treeNode;
|
|
823
851
|
}
|
|
824
852
|
function processJSXElement(path, treeNode) {
|
|
825
|
-
const tagName = getTagName(path.node);
|
|
826
|
-
treeNode.tag = tagName;
|
|
827
|
-
treeNode.type = determineNodeType(tagName);
|
|
828
|
-
treeNode.selfClosing = Ne(tagName);
|
|
829
853
|
if (!path.isJSXFragment()) {
|
|
830
854
|
treeNode.props = processProps(path);
|
|
831
855
|
}
|
|
@@ -1465,7 +1489,7 @@ function transformJSXToClient(path, node) {
|
|
|
1465
1489
|
])
|
|
1466
1490
|
);
|
|
1467
1491
|
}
|
|
1468
|
-
if (dynamicCollection.children.length || dynamicCollection.props.length) {
|
|
1492
|
+
if (dynamicCollection.children.length || dynamicCollection.props.length || dynamicCollection.operations.length) {
|
|
1469
1493
|
addImport(importMap.mapNodes);
|
|
1470
1494
|
statements.push(
|
|
1471
1495
|
t8.variableDeclaration("const", [
|
|
@@ -1561,6 +1585,22 @@ function generateIndexMap({
|
|
|
1561
1585
|
}
|
|
1562
1586
|
return indexMap;
|
|
1563
1587
|
}
|
|
1588
|
+
function createRefStatement(nodesId, nodeIndex, value) {
|
|
1589
|
+
const elementRef = t8.memberExpression(nodesId, t8.numericLiteral(nodeIndex), true);
|
|
1590
|
+
const typeofCheck = t8.binaryExpression(
|
|
1591
|
+
"===",
|
|
1592
|
+
t8.unaryExpression("typeof", value),
|
|
1593
|
+
t8.stringLiteral("function")
|
|
1594
|
+
);
|
|
1595
|
+
const functionCall = t8.callExpression(value, [elementRef]);
|
|
1596
|
+
const assignmentExpr = t8.assignmentExpression(
|
|
1597
|
+
"=",
|
|
1598
|
+
t8.memberExpression(value, t8.identifier("value")),
|
|
1599
|
+
elementRef
|
|
1600
|
+
);
|
|
1601
|
+
const conditionalExpr = t8.conditionalExpression(typeofCheck, functionCall, assignmentExpr);
|
|
1602
|
+
return t8.expressionStatement(conditionalExpr);
|
|
1603
|
+
}
|
|
1564
1604
|
function createAttributeStatement(functionIdentifier, nodesId, nodeIndex, value, key) {
|
|
1565
1605
|
const args = [t8.memberExpression(nodesId, t8.numericLiteral(nodeIndex), true)];
|
|
1566
1606
|
if (key) {
|
|
@@ -1618,6 +1658,9 @@ function generateSpecificAttributeCode(attributeName, attributeValue, nodesId, n
|
|
|
1618
1658
|
createAttributeStatement(state.imports.setSpread, nodesId, nodeIndex, attributeValue)
|
|
1619
1659
|
);
|
|
1620
1660
|
break;
|
|
1661
|
+
case REF_KEY:
|
|
1662
|
+
statements.push(createRefStatement(nodesId, nodeIndex, attributeValue));
|
|
1663
|
+
break;
|
|
1621
1664
|
case STYLE_NAME:
|
|
1622
1665
|
addImport(importMap.patchStyle);
|
|
1623
1666
|
statements.push(
|
|
@@ -1768,10 +1811,7 @@ function generateDynamicPropsCode(dynamicProps, statements, state, nodesId, inde
|
|
|
1768
1811
|
function generateUnifiedMemoizedEffect(reactiveOperations, statements, state, nodesId, indexMap) {
|
|
1769
1812
|
addImport(importMap.memoEffect);
|
|
1770
1813
|
const variableDeclarations = reactiveOperations.map((op, index) => {
|
|
1771
|
-
|
|
1772
|
-
if (t8.isIdentifier(op.attrValue) && isSignal(op.attrValue.name)) {
|
|
1773
|
-
attrValue = t8.memberExpression(attrValue, t8.identifier("value"));
|
|
1774
|
-
}
|
|
1814
|
+
const attrValue = op.attrValue;
|
|
1775
1815
|
return t8.variableDeclarator(t8.identifier(`_v$${index}`), attrValue);
|
|
1776
1816
|
});
|
|
1777
1817
|
const updateStatements = reactiveOperations.map((op, index) => {
|
|
@@ -1941,7 +1981,7 @@ function processNodeDynamic(dynamicCollection, node, parentNode) {
|
|
|
1941
1981
|
if (node.props && Object.keys(node.props).length > 0) {
|
|
1942
1982
|
const currentProps = {};
|
|
1943
1983
|
for (const [attrName, attrValue] of Object.entries(node.props)) {
|
|
1944
|
-
const isReactive = t8.isNode(attrValue) && isDynamicExpression(attrValue) && !q(attrName, `${UPDATE_PREFIX}:`) && !q(attrName, EVENT_ATTR_NAME);
|
|
1984
|
+
const isReactive = t8.isNode(attrValue) && isDynamicExpression(attrValue) && !q(attrName, `${UPDATE_PREFIX}:`) && !q(attrName, EVENT_ATTR_NAME) && attrName !== REF_KEY;
|
|
1945
1985
|
if (q(attrName, `${UPDATE_PREFIX}:`)) {
|
|
1946
1986
|
const name = attrName.split(":")[1];
|
|
1947
1987
|
const setFunction = getSetFunctionForAttribute();
|
|
@@ -2263,19 +2303,6 @@ function index_default() {
|
|
|
2263
2303
|
// props
|
|
2264
2304
|
FunctionDeclaration: transformProps,
|
|
2265
2305
|
ArrowFunctionExpression: transformProps,
|
|
2266
|
-
// Symbol
|
|
2267
|
-
VariableDeclarator: replaceSymbol,
|
|
2268
|
-
// let $x = 0 → let $x = signal(0)
|
|
2269
|
-
Identifier: symbolIdentifier,
|
|
2270
|
-
// $x → $x.value
|
|
2271
|
-
AssignmentExpression: symbolAssignment,
|
|
2272
|
-
// $x = 1 → $x.value = 1
|
|
2273
|
-
UpdateExpression: symbolUpdate,
|
|
2274
|
-
// $x++ → $x.value++
|
|
2275
|
-
ObjectPattern: symbolObjectPattern,
|
|
2276
|
-
// { $x } → handle nested patterns
|
|
2277
|
-
ArrayPattern: symbolArrayPattern,
|
|
2278
|
-
// [$x] → handle nested patterns
|
|
2279
2306
|
// JSX
|
|
2280
2307
|
JSXElement: transformJSX,
|
|
2281
2308
|
JSXFragment: transformJSX
|