@farm.js/react 0.1.0-beta.37 → 0.1.0-beta.38

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/vite.cjs CHANGED
@@ -76,12 +76,9 @@ var COMPILER_RUNTIME_FEATURE_EXPORTS = {
76
76
  "keyed-rows-hinted": "keyedRowsHintedRuntimeFeature",
77
77
  "keyed-rows-append-only": "keyedRowsAppendOnlyRuntimeFeature",
78
78
  "keyed-rows-position-hinted": "keyedRowsPositionHintedRuntimeFeature",
79
- "keyed-rows-plain-position-hinted": "keyedRowsPlainPositionHintedRuntimeFeature",
80
79
  "keyed-rows-batch-position-hinted": "keyedRowsBatchPositionHintedRuntimeFeature",
81
80
  "keyed-rows-window-position-hinted": "keyedRowsWindowPositionHintedRuntimeFeature",
82
81
  "keyed-rows-reorder-hinted": "keyedRowsReorderHintedRuntimeFeature",
83
- "keyed-rows-plain-reorder-hinted": "keyedRowsPlainReorderHintedRuntimeFeature",
84
- "keyed-rows-plain-map-reorder-hinted": "keyedRowsPlainMapReorderHintedRuntimeFeature",
85
82
  "keyed-rows-map-reorder-hinted": "keyedRowsMapReorderHintedRuntimeFeature",
86
83
  "keyed-rows-all-hinted": "keyedRowsAllHintedRuntimeFeature",
87
84
  "keyed-rows-mapped-rolling-window-hinted": "keyedRowsMappedRollingWindowHintedRuntimeFeature",
@@ -188,12 +185,6 @@ function runtimeFeaturesForPlans(plans, keyedUpdateHints, keyedArrayFilterHints,
188
185
  features.add("keyed-rows-filter-only");
189
186
  } else if (keyedRowsFeature === "keyed-rows" && hintSuffix === "-prepend-hinted" && keyedTargetKinds.size === 0 && !keyedMapOrAppendHints) {
190
187
  features.add("keyed-rows-prepend-only");
191
- } else if (keyedRowsFeature === "keyed-rows" && hintSuffix === "-position-hinted" && keyedTargetKinds.size === 0) {
192
- features.add("keyed-rows-plain-position-hinted");
193
- } else if (keyedRowsFeature === "keyed-rows" && hintSuffix === "-reorder-hinted" && keyedTargetKinds.size === 0) {
194
- features.add("keyed-rows-plain-reorder-hinted");
195
- } else if (keyedRowsFeature === "keyed-rows" && hintSuffix === "-map-reorder-hinted" && keyedTargetKinds.size === 0) {
196
- features.add("keyed-rows-plain-map-reorder-hinted");
197
188
  } else if (keyedRowsFeature === "keyed-rows" && hintSuffix === "-filter-hinted" && keyedTargetKinds.size === 1 && keyedTargetKinds.has("identity")) {
198
189
  features.add(
199
190
  keyedMapOrAppendHints ? "keyed-rows-identity-filter-hinted" : "keyed-rows-identity-filter-only"
@@ -251,14 +242,6 @@ function collectStateDependencies(expression, statesByValue) {
251
242
  return [...dependencies].sort((left, right) => left - right);
252
243
  }
253
244
  function referencesIdentifier(expression, name) {
254
- let possible = false;
255
- core.types.traverseFast(expression, (node) => {
256
- if ((core.types.isIdentifier(node) || core.types.isJSXIdentifier(node)) && node.name === name) {
257
- possible = true;
258
- return core.types.traverseFast.stop;
259
- }
260
- });
261
- if (!possible) return false;
262
245
  let referenced = false;
263
246
  core.traverse(expressionFile(cloneExpression(expression)), {
264
247
  ReferencedIdentifier(path) {
@@ -338,10 +321,12 @@ function isPotentialKeyedMembershipCall(expression, reactiveByValue) {
338
321
  }
339
322
  function containsPotentialKeyedMembershipCall(expression, reactiveByValue) {
340
323
  let found = false;
341
- core.types.traverseFast(expression, (node) => {
342
- if (!core.types.isCallExpression(node) || !isPotentialKeyedMembershipCall(node, reactiveByValue)) return;
343
- found = true;
344
- return core.types.traverseFast.stop;
324
+ core.traverse(expressionFile(cloneExpression(expression)), {
325
+ CallExpression(path) {
326
+ if (!isPotentialKeyedMembershipCall(path.node, reactiveByValue)) return;
327
+ found = true;
328
+ path.stop();
329
+ }
345
330
  });
346
331
  return found;
347
332
  }
@@ -354,10 +339,12 @@ function isPotentialKeyedMapLookupCall(expression, reactiveByValue) {
354
339
  }
355
340
  function containsPotentialKeyedMapLookupCall(expression, reactiveByValue) {
356
341
  let found = false;
357
- core.types.traverseFast(expression, (node) => {
358
- if (!core.types.isCallExpression(node) || !isPotentialKeyedMapLookupCall(node, reactiveByValue)) return;
359
- found = true;
360
- return core.types.traverseFast.stop;
342
+ core.traverse(expressionFile(cloneExpression(expression)), {
343
+ CallExpression(path) {
344
+ if (!isPotentialKeyedMapLookupCall(path.node, reactiveByValue)) return;
345
+ found = true;
346
+ path.stop();
347
+ }
361
348
  });
362
349
  return found;
363
350
  }
@@ -434,15 +421,6 @@ function keyedMapLookupTarget(binding, keyCallback, renderCallback, reactiveByVa
434
421
  return valid && target && calls > 0 ? { dependency: target.index, value: core.types.identifier(target.valueName) } : void 0;
435
422
  }
436
423
  function collectReferencedLocals(expression, names) {
437
- if (names.size === 0) return [];
438
- let possible = false;
439
- core.types.traverseFast(expression, (node) => {
440
- if ((core.types.isIdentifier(node) || core.types.isJSXIdentifier(node)) && names.has(node.name)) {
441
- possible = true;
442
- return core.types.traverseFast.stop;
443
- }
444
- });
445
- if (!possible) return [];
446
424
  const references = /* @__PURE__ */ new Set();
447
425
  core.traverse(expressionFile(cloneExpression(expression)), {
448
426
  ReferencedIdentifier(path) {
@@ -454,7 +432,6 @@ function collectReferencedLocals(expression, names) {
454
432
  return [...references];
455
433
  }
456
434
  function rewriteDerivedAccess(expression, derivedByName) {
457
- if (derivedByName.size === 0) return cloneExpression(expression);
458
435
  const file = expressionFile(cloneExpression(expression));
459
436
  core.traverse(file, {
460
437
  ReferencedIdentifier(path) {
@@ -713,7 +690,7 @@ function keyedMapUpdatePipeline(expression, parameterName, safeGlobals) {
713
690
  return outerCallbacks.reverse();
714
691
  }
715
692
  function rewriteKeyedMapUpdateHints(root, hintedStateIndices, statesBySetter, helperIdentifier, safeGlobals) {
716
- if (hintedStateIndices.size === 0) return { root, count: 0 };
693
+ if (hintedStateIndices.size === 0) return { root: core.types.cloneNode(root, true), count: 0 };
717
694
  const file = expressionFile(core.types.cloneNode(root, true));
718
695
  let count = 0;
719
696
  core.traverse(file, {
@@ -767,7 +744,7 @@ function rewriteKeyedMapUpdateHints(root, hintedStateIndices, statesBySetter, he
767
744
  }
768
745
  path.node.arguments[0] = core.types.arrowFunctionExpression(
769
746
  [core.types.cloneNode(previous)],
770
- core.types.callExpression(core.types.cloneNode(helperIdentifier()), [
747
+ core.types.callExpression(core.types.cloneNode(helperIdentifier), [
771
748
  core.types.cloneNode(previous),
772
749
  core.types.arrowFunctionExpression(
773
750
  [core.types.cloneNode(pipelineValue), core.types.cloneNode(applyMap)],
@@ -785,7 +762,7 @@ function rewriteKeyedMapUpdateHints(root, hintedStateIndices, statesBySetter, he
785
762
  };
786
763
  }
787
764
  function rewriteKeyedArrayAppendHints(root, hintedStateIndices, statesBySetter, helperIdentifier, safeGlobals) {
788
- if (hintedStateIndices.size === 0) return { root, count: 0 };
765
+ if (hintedStateIndices.size === 0) return { root: core.types.cloneNode(root, true), count: 0 };
789
766
  const file = expressionFile(core.types.cloneNode(root, true));
790
767
  let count = 0;
791
768
  core.traverse(file, {
@@ -839,7 +816,7 @@ function rewriteKeyedArrayAppendHints(root, hintedStateIndices, statesBySetter,
839
816
  core.types.variableDeclarator(core.types.cloneNode(nextValue), core.types.cloneNode(updateExpression, true))
840
817
  ]),
841
818
  core.types.returnStatement(
842
- core.types.callExpression(core.types.cloneNode(helperIdentifier()), [
819
+ core.types.callExpression(core.types.cloneNode(helperIdentifier), [
843
820
  core.types.cloneNode(previous),
844
821
  core.types.cloneNode(nextValue)
845
822
  ])
@@ -857,7 +834,7 @@ function rewriteKeyedArrayAppendHints(root, hintedStateIndices, statesBySetter,
857
834
  }
858
835
  function rewriteKeyedArrayPrependHints(root, hintedStateIndices, statesBySetter, helperIdentifier, safeGlobals) {
859
836
  if (hintedStateIndices.size === 0) {
860
- return { root, count: 0, stateIndices: /* @__PURE__ */ new Set() };
837
+ return { root: core.types.cloneNode(root, true), count: 0, stateIndices: /* @__PURE__ */ new Set() };
861
838
  }
862
839
  const file = expressionFile(core.types.cloneNode(root, true));
863
840
  const stateIndices = /* @__PURE__ */ new Set();
@@ -915,7 +892,7 @@ function rewriteKeyedArrayPrependHints(root, hintedStateIndices, statesBySetter,
915
892
  core.types.variableDeclarator(core.types.cloneNode(nextValue), core.types.cloneNode(updateExpression, true))
916
893
  ]),
917
894
  core.types.returnStatement(
918
- core.types.callExpression(core.types.cloneNode(helperIdentifier()), [
895
+ core.types.callExpression(core.types.cloneNode(helperIdentifier), [
919
896
  core.types.cloneNode(previous),
920
897
  core.types.cloneNode(nextValue)
921
898
  ])
@@ -935,7 +912,7 @@ function rewriteKeyedArrayPrependHints(root, hintedStateIndices, statesBySetter,
935
912
  }
936
913
  function rewriteKeyedArrayRollingWindowHints(root, hintedStateIndices, statesBySetter, sliceHelperIdentifier, rollingWindowHelperIdentifier, safeGlobals) {
937
914
  if (hintedStateIndices.size === 0) {
938
- return { root, count: 0, stateIndices: /* @__PURE__ */ new Set() };
915
+ return { root: core.types.cloneNode(root, true), count: 0, stateIndices: /* @__PURE__ */ new Set() };
939
916
  }
940
917
  const file = expressionFile(core.types.cloneNode(root, true));
941
918
  const stateIndices = /* @__PURE__ */ new Set();
@@ -1006,7 +983,7 @@ function rewriteKeyedArrayRollingWindowHints(root, hintedStateIndices, statesByS
1006
983
  ),
1007
984
  core.types.variableDeclarator(
1008
985
  core.types.cloneNode(retained),
1009
- core.types.callExpression(core.types.cloneNode(sliceHelperIdentifier()), [
986
+ core.types.callExpression(core.types.cloneNode(sliceHelperIdentifier), [
1010
987
  core.types.cloneNode(previous),
1011
988
  core.types.cloneNode(sliceMethod),
1012
989
  core.types.cloneNode(retainedStart, true)
@@ -1015,7 +992,7 @@ function rewriteKeyedArrayRollingWindowHints(root, hintedStateIndices, statesByS
1015
992
  core.types.variableDeclarator(core.types.cloneNode(nextValue), core.types.arrayExpression(nextElements))
1016
993
  ]),
1017
994
  core.types.returnStatement(
1018
- core.types.callExpression(core.types.cloneNode(rollingWindowHelperIdentifier()), [
995
+ core.types.callExpression(core.types.cloneNode(rollingWindowHelperIdentifier), [
1019
996
  core.types.cloneNode(previous),
1020
997
  core.types.cloneNode(retained),
1021
998
  core.types.cloneNode(nextValue)
@@ -1054,7 +1031,7 @@ function validateKeyedArrayPositionExpression(expression, safeGlobals) {
1054
1031
  function rewriteKeyedArrayPositionHints(root, hintedStateIndices, statesBySetter, helperIdentifier, batchInsertHelperIdentifier, windowReplaceHelperIdentifier, safeGlobals) {
1055
1032
  if (hintedStateIndices.size === 0) {
1056
1033
  return {
1057
- root,
1034
+ root: core.types.cloneNode(root, true),
1058
1035
  count: 0,
1059
1036
  batchInsertCount: 0,
1060
1037
  windowReplaceCount: 0,
@@ -1114,18 +1091,18 @@ function rewriteKeyedArrayPositionHints(root, hintedStateIndices, statesBySetter
1114
1091
  )
1115
1092
  ]),
1116
1093
  core.types.returnStatement(
1117
- kind === "batch-insert" ? core.types.callExpression(core.types.cloneNode(batchInsertHelperIdentifier()), [
1094
+ kind === "batch-insert" ? core.types.callExpression(core.types.cloneNode(batchInsertHelperIdentifier), [
1118
1095
  core.types.cloneNode(previous),
1119
1096
  core.types.cloneNode(method),
1120
1097
  core.types.cloneNode(position, true),
1121
1098
  ...args.slice(2).map((argument) => core.types.cloneNode(argument, true))
1122
- ]) : kind === "window-replace" ? core.types.callExpression(core.types.cloneNode(windowReplaceHelperIdentifier()), [
1099
+ ]) : kind === "window-replace" ? core.types.callExpression(core.types.cloneNode(windowReplaceHelperIdentifier), [
1123
1100
  core.types.cloneNode(previous),
1124
1101
  core.types.cloneNode(method),
1125
1102
  core.types.cloneNode(position, true),
1126
1103
  core.types.cloneNode(args[1], true),
1127
1104
  ...args.slice(2).map((argument) => core.types.cloneNode(argument, true))
1128
- ]) : core.types.callExpression(core.types.cloneNode(helperIdentifier()), [
1105
+ ]) : core.types.callExpression(core.types.cloneNode(helperIdentifier), [
1129
1106
  core.types.cloneNode(previous),
1130
1107
  core.types.cloneNode(method),
1131
1108
  core.types.stringLiteral(kind),
@@ -1151,7 +1128,7 @@ function rewriteKeyedArrayPositionHints(root, hintedStateIndices, statesBySetter
1151
1128
  }
1152
1129
  function rewriteKeyedArrayReorderHints(root, hintedStateIndices, statesBySetter, helperIdentifier) {
1153
1130
  if (hintedStateIndices.size === 0) {
1154
- return { root, count: 0, stateIndices: /* @__PURE__ */ new Set() };
1131
+ return { root: core.types.cloneNode(root, true), count: 0, stateIndices: /* @__PURE__ */ new Set() };
1155
1132
  }
1156
1133
  const file = expressionFile(core.types.cloneNode(root, true));
1157
1134
  const stateIndices = /* @__PURE__ */ new Set();
@@ -1185,7 +1162,7 @@ function rewriteKeyedArrayReorderHints(root, hintedStateIndices, statesBySetter,
1185
1162
  )
1186
1163
  ]),
1187
1164
  core.types.returnStatement(
1188
- core.types.callExpression(core.types.cloneNode(helperIdentifier()), [
1165
+ core.types.callExpression(core.types.cloneNode(helperIdentifier), [
1189
1166
  core.types.cloneNode(previous),
1190
1167
  core.types.cloneNode(method)
1191
1168
  ])
@@ -1292,7 +1269,7 @@ function keyedArrayReorderPipeline(expression, parameterName, safeGlobals) {
1292
1269
  function rewriteKeyedArrayReorderPipelineHints(root, hintedStateIndices, statesBySetter, filterHelperIdentifier, mapHelperIdentifier, mapReorderHelperIdentifier, mappedStructuralHelperIdentifier, reorderHelperIdentifier, structuralReorderHelperIdentifier, sliceHelperIdentifier, sortHelperIdentifier, structuralSortHelperIdentifier, safeGlobals, allowMapPipelines) {
1293
1270
  if (hintedStateIndices.size === 0) {
1294
1271
  return {
1295
- root,
1272
+ root: core.types.cloneNode(root, true),
1296
1273
  filterCount: 0,
1297
1274
  mapCount: 0,
1298
1275
  mapReorderCount: 0,
@@ -1391,7 +1368,7 @@ function rewriteKeyedArrayReorderPipelineHints(root, hintedStateIndices, statesB
1391
1368
  core.types.variableDeclaration("const", [
1392
1369
  core.types.variableDeclarator(
1393
1370
  core.types.cloneNode(result2),
1394
- core.types.callExpression(core.types.cloneNode(mapHelperIdentifier()), [
1371
+ core.types.callExpression(core.types.cloneNode(mapHelperIdentifier), [
1395
1372
  core.types.cloneNode(value),
1396
1373
  core.types.arrowFunctionExpression(
1397
1374
  [core.types.cloneNode(pipelineValue), core.types.cloneNode(applyMap)],
@@ -1428,7 +1405,7 @@ function rewriteKeyedArrayReorderPipelineHints(root, hintedStateIndices, statesB
1428
1405
  core.types.variableDeclaration("const", [
1429
1406
  core.types.variableDeclarator(
1430
1407
  core.types.cloneNode(result),
1431
- core.types.callExpression(core.types.cloneNode(helper()), [
1408
+ core.types.callExpression(core.types.cloneNode(helper), [
1432
1409
  core.types.cloneNode(value),
1433
1410
  core.types.cloneNode(method),
1434
1411
  ...args
@@ -1454,9 +1431,7 @@ function rewriteKeyedArrayReorderPipelineHints(root, hintedStateIndices, statesB
1454
1431
  }
1455
1432
  statements.push(
1456
1433
  core.types.returnStatement(
1457
- terminalStructuralPipeline ? core.types.callExpression(core.types.cloneNode(mappedStructuralHelperIdentifier()), [
1458
- core.types.cloneNode(value)
1459
- ]) : core.types.cloneNode(value)
1434
+ terminalStructuralPipeline ? core.types.callExpression(core.types.cloneNode(mappedStructuralHelperIdentifier), [core.types.cloneNode(value)]) : core.types.cloneNode(value)
1460
1435
  )
1461
1436
  );
1462
1437
  if (terminalStructuralPipeline) terminalStructuralPipelineCount += 1;
@@ -1484,7 +1459,7 @@ function rewriteKeyedArrayReorderPipelineHints(root, hintedStateIndices, statesB
1484
1459
  };
1485
1460
  }
1486
1461
  function rewriteQueuedKeyedArrayReorderMapHints(root, statesBySetter, mapUpdateIdentifier, queuedMapPipelineIdentifier, mapReorderIdentifier, reorderIdentifier, sortIdentifier, structuralReorderIdentifier, structuralSortIdentifier, allowed) {
1487
- if (!allowed) return { root, mapCount: 0 };
1462
+ if (!allowed) return { root: core.types.cloneNode(root, true), mapCount: 0 };
1488
1463
  const file = expressionFile(core.types.cloneNode(root, true));
1489
1464
  let mapCount = 0;
1490
1465
  const containsHelperCall = (updater, helperNames) => {
@@ -1497,13 +1472,13 @@ function rewriteQueuedKeyedArrayReorderMapHints(root, statesBySetter, mapUpdateI
1497
1472
  return found;
1498
1473
  };
1499
1474
  const reorderHelperNames = /* @__PURE__ */ new Set([
1500
- mapReorderIdentifier().name,
1501
- reorderIdentifier().name,
1502
- sortIdentifier().name
1475
+ mapReorderIdentifier.name,
1476
+ reorderIdentifier.name,
1477
+ sortIdentifier.name
1503
1478
  ]);
1504
1479
  const structuralHelperNames = /* @__PURE__ */ new Set([
1505
- structuralReorderIdentifier().name,
1506
- structuralSortIdentifier().name
1480
+ structuralReorderIdentifier.name,
1481
+ structuralSortIdentifier.name
1507
1482
  ]);
1508
1483
  core.traverse(file, {
1509
1484
  BlockStatement(path) {
@@ -1530,7 +1505,7 @@ function rewriteQueuedKeyedArrayReorderMapHints(root, statesBySetter, mapUpdateI
1530
1505
  queuedReorderState = state.index;
1531
1506
  continue;
1532
1507
  }
1533
- if (queuedReorderState !== state.index || !core.types.isCallExpression(updater.body) || !core.types.isIdentifier(updater.body.callee, { name: mapUpdateIdentifier().name }) || updater.body.arguments.length !== 2) {
1508
+ if (queuedReorderState !== state.index || !core.types.isCallExpression(updater.body) || !core.types.isIdentifier(updater.body.callee, { name: mapUpdateIdentifier.name }) || updater.body.arguments.length !== 2) {
1534
1509
  queuedReorderState = void 0;
1535
1510
  continue;
1536
1511
  }
@@ -1550,7 +1525,7 @@ function rewriteQueuedKeyedArrayReorderMapHints(root, statesBySetter, mapUpdateI
1550
1525
  queuedReorderState = void 0;
1551
1526
  continue;
1552
1527
  }
1553
- updater.body.callee = core.types.cloneNode(queuedMapPipelineIdentifier());
1528
+ updater.body.callee = core.types.cloneNode(queuedMapPipelineIdentifier);
1554
1529
  mapCount += pipelineMapCount;
1555
1530
  }
1556
1531
  }
@@ -1561,7 +1536,7 @@ function rewriteQueuedKeyedArrayReorderMapHints(root, statesBySetter, mapUpdateI
1561
1536
  };
1562
1537
  }
1563
1538
  function countKeyedArrayMapPipeline(updater, mapUpdateIdentifier) {
1564
- if (!core.types.isCallExpression(updater.body) || !core.types.isIdentifier(updater.body.callee, { name: mapUpdateIdentifier().name }) || updater.body.arguments.length !== 2) {
1539
+ if (!core.types.isCallExpression(updater.body) || !core.types.isIdentifier(updater.body.callee, { name: mapUpdateIdentifier.name }) || updater.body.arguments.length !== 2) {
1565
1540
  return 0;
1566
1541
  }
1567
1542
  const pipeline = updater.body.arguments[1];
@@ -1580,7 +1555,7 @@ function countKeyedArrayMapPipeline(updater, mapUpdateIdentifier) {
1580
1555
  function rewriteQueuedKeyedArrayMappedStructuralHints(root, statesBySetter, mapUpdateIdentifier, queuedMapPipelineIdentifier, mappedStructuralIdentifier, filterIdentifier, sliceIdentifier, allowed) {
1581
1556
  if (!allowed) {
1582
1557
  return {
1583
- root,
1558
+ root: core.types.cloneNode(root, true),
1584
1559
  mapCount: 0,
1585
1560
  structuralCount: 0,
1586
1561
  stateIndices: /* @__PURE__ */ new Set()
@@ -1593,7 +1568,7 @@ function rewriteQueuedKeyedArrayMappedStructuralHints(root, statesBySetter, mapU
1593
1568
  const terminalStructuralReturn = (updater) => {
1594
1569
  if (!core.types.isBlockStatement(updater.body)) return void 0;
1595
1570
  const statement = updater.body.body.at(-1);
1596
- if (!core.types.isReturnStatement(statement) || !statement.argument || !core.types.isCallExpression(statement.argument) || !core.types.isIdentifier(statement.argument.callee) || statement.argument.callee.name !== filterIdentifier().name && statement.argument.callee.name !== sliceIdentifier().name) {
1571
+ if (!core.types.isReturnStatement(statement) || !statement.argument || !core.types.isCallExpression(statement.argument) || !core.types.isIdentifier(statement.argument.callee) || statement.argument.callee.name !== filterIdentifier.name && statement.argument.callee.name !== sliceIdentifier.name) {
1597
1572
  return void 0;
1598
1573
  }
1599
1574
  return statement;
@@ -1647,7 +1622,7 @@ function rewriteQueuedKeyedArrayMappedStructuralHints(root, statesBySetter, mapU
1647
1622
  }
1648
1623
  if (hasPendingMaps) {
1649
1624
  for (const candidate of pendingMaps) {
1650
- candidate.updater.body.callee = core.types.cloneNode(queuedMapPipelineIdentifier());
1625
+ candidate.updater.body.callee = core.types.cloneNode(queuedMapPipelineIdentifier);
1651
1626
  mapCount += candidate.count;
1652
1627
  }
1653
1628
  }
@@ -1657,7 +1632,7 @@ function rewriteQueuedKeyedArrayMappedStructuralHints(root, statesBySetter, mapU
1657
1632
  pendingMaps = [];
1658
1633
  continue;
1659
1634
  }
1660
- structuralReturn.argument = core.types.callExpression(core.types.cloneNode(mappedStructuralIdentifier()), [
1635
+ structuralReturn.argument = core.types.callExpression(core.types.cloneNode(mappedStructuralIdentifier), [
1661
1636
  core.types.cloneNode(structuralValue)
1662
1637
  ]);
1663
1638
  structuralCount += 1;
@@ -1677,7 +1652,7 @@ function rewriteQueuedKeyedArrayMappedStructuralHints(root, statesBySetter, mapU
1677
1652
  function rewriteQueuedKeyedArrayStructuralMapHints(root, statesBySetter, mapUpdateIdentifier, mapPipelineIdentifier, appendIdentifier, mappedStructuralAppendIdentifier, structuralAppendMapPipelineIdentifier, filterIdentifier, sliceIdentifier, mappedStructuralIdentifier, allowed) {
1678
1653
  if (!allowed) {
1679
1654
  return {
1680
- root,
1655
+ root: core.types.cloneNode(root, true),
1681
1656
  mapCount: 0,
1682
1657
  mappedStructuralAppendCount: 0,
1683
1658
  structuralAppendMapCount: 0,
@@ -1697,10 +1672,10 @@ function rewriteQueuedKeyedArrayStructuralMapHints(root, statesBySetter, mapUpda
1697
1672
  let mapped = false;
1698
1673
  core.types.traverseFast(statement.argument, (node) => {
1699
1674
  if (!found && core.types.isCallExpression(node) && core.types.isIdentifier(node.callee)) {
1700
- if (node.callee.name === filterIdentifier().name) found = "filter";
1701
- if (node.callee.name === sliceIdentifier().name) found = "slice";
1675
+ if (node.callee.name === filterIdentifier.name) found = "filter";
1676
+ if (node.callee.name === sliceIdentifier.name) found = "slice";
1702
1677
  }
1703
- if (!mapped && core.types.isCallExpression(node) && core.types.isIdentifier(node.callee, { name: mappedStructuralIdentifier().name })) {
1678
+ if (!mapped && core.types.isCallExpression(node) && core.types.isIdentifier(node.callee, { name: mappedStructuralIdentifier.name })) {
1704
1679
  mapped = true;
1705
1680
  }
1706
1681
  });
@@ -1749,7 +1724,7 @@ function rewriteQueuedKeyedArrayStructuralMapHints(root, statesBySetter, mapUpda
1749
1724
  }
1750
1725
  const appendCalls = [];
1751
1726
  core.types.traverseFast(updater.body, (node) => {
1752
- if (core.types.isCallExpression(node) && core.types.isIdentifier(node.callee, { name: appendIdentifier().name })) {
1727
+ if (core.types.isCallExpression(node) && core.types.isIdentifier(node.callee, { name: appendIdentifier.name })) {
1753
1728
  appendCalls.push(node);
1754
1729
  }
1755
1730
  });
@@ -1758,7 +1733,7 @@ function rewriteQueuedKeyedArrayStructuralMapHints(root, statesBySetter, mapUpda
1758
1733
  structuralAppendState = state.index;
1759
1734
  if (structuralMapState === state.index) {
1760
1735
  for (const call of appendCalls) {
1761
- call.callee = core.types.cloneNode(mappedStructuralAppendIdentifier());
1736
+ call.callee = core.types.cloneNode(mappedStructuralAppendIdentifier);
1762
1737
  }
1763
1738
  mappedStructuralAppendCount += appendCalls.length;
1764
1739
  }
@@ -1779,7 +1754,7 @@ function rewriteQueuedKeyedArrayStructuralMapHints(root, statesBySetter, mapUpda
1779
1754
  continue;
1780
1755
  }
1781
1756
  updater.body.callee = core.types.cloneNode(
1782
- structuralAppendState === state.index ? structuralAppendMapPipelineIdentifier() : mapPipelineIdentifier()
1757
+ structuralAppendState === state.index ? structuralAppendMapPipelineIdentifier : mapPipelineIdentifier
1783
1758
  );
1784
1759
  mapCount += pipelineMapCount;
1785
1760
  if (structuralAppendState === state.index) {
@@ -1801,7 +1776,7 @@ function rewriteQueuedKeyedArrayStructuralMapHints(root, statesBySetter, mapUpda
1801
1776
  function rewriteQueuedKeyedArrayStructuralPrependMapHints(root, statesBySetter, mapUpdateIdentifier, mapPipelineIdentifier, prependIdentifier, mappedStructuralPrependIdentifier, structuralPrependMapPipelineIdentifier, filterIdentifier, sliceIdentifier, mappedStructuralIdentifier, allowed) {
1802
1777
  if (!allowed) {
1803
1778
  return {
1804
- root,
1779
+ root: core.types.cloneNode(root, true),
1805
1780
  mapCount: 0,
1806
1781
  mappedStructuralPrependCount: 0,
1807
1782
  structuralPrependMapCount: 0,
@@ -1821,10 +1796,10 @@ function rewriteQueuedKeyedArrayStructuralPrependMapHints(root, statesBySetter,
1821
1796
  let mapped = false;
1822
1797
  core.types.traverseFast(statement.argument, (node) => {
1823
1798
  if (!found && core.types.isCallExpression(node) && core.types.isIdentifier(node.callee)) {
1824
- if (node.callee.name === filterIdentifier().name) found = "filter";
1825
- if (node.callee.name === sliceIdentifier().name) found = "slice";
1799
+ if (node.callee.name === filterIdentifier.name) found = "filter";
1800
+ if (node.callee.name === sliceIdentifier.name) found = "slice";
1826
1801
  }
1827
- if (!mapped && core.types.isCallExpression(node) && core.types.isIdentifier(node.callee, { name: mappedStructuralIdentifier().name })) {
1802
+ if (!mapped && core.types.isCallExpression(node) && core.types.isIdentifier(node.callee, { name: mappedStructuralIdentifier.name })) {
1828
1803
  mapped = true;
1829
1804
  }
1830
1805
  });
@@ -1873,7 +1848,7 @@ function rewriteQueuedKeyedArrayStructuralPrependMapHints(root, statesBySetter,
1873
1848
  }
1874
1849
  const prependCalls = [];
1875
1850
  core.types.traverseFast(updater.body, (node) => {
1876
- if (core.types.isCallExpression(node) && core.types.isIdentifier(node.callee, { name: prependIdentifier().name })) {
1851
+ if (core.types.isCallExpression(node) && core.types.isIdentifier(node.callee, { name: prependIdentifier.name })) {
1877
1852
  prependCalls.push(node);
1878
1853
  }
1879
1854
  });
@@ -1882,7 +1857,7 @@ function rewriteQueuedKeyedArrayStructuralPrependMapHints(root, statesBySetter,
1882
1857
  structuralPrependState = state.index;
1883
1858
  if (structuralMapState === state.index) {
1884
1859
  for (const call of prependCalls) {
1885
- call.callee = core.types.cloneNode(mappedStructuralPrependIdentifier());
1860
+ call.callee = core.types.cloneNode(mappedStructuralPrependIdentifier);
1886
1861
  }
1887
1862
  mappedStructuralPrependCount += prependCalls.length;
1888
1863
  }
@@ -1903,7 +1878,7 @@ function rewriteQueuedKeyedArrayStructuralPrependMapHints(root, statesBySetter,
1903
1878
  continue;
1904
1879
  }
1905
1880
  updater.body.callee = core.types.cloneNode(
1906
- structuralPrependState === state.index ? structuralPrependMapPipelineIdentifier() : mapPipelineIdentifier()
1881
+ structuralPrependState === state.index ? structuralPrependMapPipelineIdentifier : mapPipelineIdentifier
1907
1882
  );
1908
1883
  mapCount += pipelineMapCount;
1909
1884
  if (structuralPrependState === state.index) {
@@ -1927,7 +1902,7 @@ function rewriteQueuedKeyedArrayRollingWindowMapHints(root, statesBySetter, mapU
1927
1902
  return {
1928
1903
  chainedMapCount: 0,
1929
1904
  chainedRollingWindowCount: 0,
1930
- root,
1905
+ root: core.types.cloneNode(root, true),
1931
1906
  leadingMapCount: 0,
1932
1907
  mappedRollingWindowCount: 0,
1933
1908
  rollingWindowCount: 0,
@@ -1954,7 +1929,7 @@ function rewriteQueuedKeyedArrayRollingWindowMapHints(root, statesBySetter, mapU
1954
1929
  const rollingStep = (updater) => {
1955
1930
  if (!core.types.isBlockStatement(updater.body)) return void 0;
1956
1931
  const statement = updater.body.body.at(-1);
1957
- if (!core.types.isReturnStatement(statement) || !statement.argument || !core.types.isCallExpression(statement.argument) || !core.types.isIdentifier(statement.argument.callee, { name: rollingWindowIdentifier().name }) || statement.argument.arguments.length !== 3 || !core.types.isExpression(statement.argument.arguments[1]) || !core.types.isExpression(statement.argument.arguments[2])) {
1932
+ if (!core.types.isReturnStatement(statement) || !statement.argument || !core.types.isCallExpression(statement.argument) || !core.types.isIdentifier(statement.argument.callee, { name: rollingWindowIdentifier.name }) || statement.argument.arguments.length !== 3 || !core.types.isExpression(statement.argument.arguments[1]) || !core.types.isExpression(statement.argument.arguments[2])) {
1958
1933
  return void 0;
1959
1934
  }
1960
1935
  return { call: statement.argument };
@@ -1981,13 +1956,13 @@ function rewriteQueuedKeyedArrayRollingWindowMapHints(root, statesBySetter, mapU
1981
1956
  }
1982
1957
  for (const step of maps) {
1983
1958
  if (step.kind !== "map") continue;
1984
- step.value.updater.body.callee = core.types.cloneNode(rollingWindowMapPipelineIdentifier());
1959
+ step.value.updater.body.callee = core.types.cloneNode(rollingWindowMapPipelineIdentifier);
1985
1960
  chainedMapCount += step.value.count;
1986
1961
  }
1987
1962
  for (const index of rollingIndices) {
1988
1963
  const step = segment[index];
1989
1964
  if (step.kind === "rolling") {
1990
- step.value.call.callee = core.types.cloneNode(mappedRollingWindowIdentifier());
1965
+ step.value.call.callee = core.types.cloneNode(mappedRollingWindowIdentifier);
1991
1966
  }
1992
1967
  }
1993
1968
  chainedRollingWindowCount += rollingIndices.length;
@@ -2011,10 +1986,10 @@ function rewriteQueuedKeyedArrayRollingWindowMapHints(root, statesBySetter, mapU
2011
1986
  if (!core.types.isExpression(retained) || !core.types.isExpression(value)) return;
2012
1987
  const hasLeadingMaps = leadingMaps.length > 0;
2013
1988
  rolling.value.call.callee = core.types.cloneNode(
2014
- hasLeadingMaps ? mappedStructuralAppendIdentifier() : structuralAppendIdentifier()
1989
+ hasLeadingMaps ? mappedStructuralAppendIdentifier : structuralAppendIdentifier
2015
1990
  );
2016
1991
  rolling.value.call.arguments = [
2017
- hasLeadingMaps ? core.types.callExpression(core.types.cloneNode(mappedStructuralIdentifier()), [
1992
+ hasLeadingMaps ? core.types.callExpression(core.types.cloneNode(mappedStructuralIdentifier), [
2018
1993
  core.types.cloneNode(retained, true)
2019
1994
  ]) : core.types.cloneNode(retained, true),
2020
1995
  core.types.cloneNode(value, true)
@@ -2024,7 +1999,7 @@ function rewriteQueuedKeyedArrayRollingWindowMapHints(root, statesBySetter, mapU
2024
1999
  mappedRollingWindowCount += 1;
2025
2000
  for (const step of leadingMaps) {
2026
2001
  if (step.kind !== "map") continue;
2027
- step.value.updater.body.callee = core.types.cloneNode(queuedMapPipelineIdentifier());
2002
+ step.value.updater.body.callee = core.types.cloneNode(queuedMapPipelineIdentifier);
2028
2003
  leadingMapCount += step.value.count;
2029
2004
  }
2030
2005
  } else {
@@ -2032,7 +2007,7 @@ function rewriteQueuedKeyedArrayRollingWindowMapHints(root, statesBySetter, mapU
2032
2007
  }
2033
2008
  for (const step of trailingMaps) {
2034
2009
  if (step.kind !== "map") continue;
2035
- step.value.updater.body.callee = core.types.cloneNode(structuralAppendMapPipelineIdentifier());
2010
+ step.value.updater.body.callee = core.types.cloneNode(structuralAppendMapPipelineIdentifier);
2036
2011
  trailingMapCount += step.value.count;
2037
2012
  }
2038
2013
  segment = [];
@@ -2085,7 +2060,7 @@ function rewriteQueuedKeyedArrayRollingWindowMapHints(root, statesBySetter, mapU
2085
2060
  function rewriteQueuedKeyedArrayStructuralReorderHints(root, statesBySetter, filterIdentifier, sliceIdentifier, mapPipelineIdentifier, queuedMapPipelineIdentifier, mappedStructuralIdentifier, mapReorderIdentifier, reorderIdentifier, sortIdentifier, structuralReorderIdentifier, structuralSortIdentifier, allowed) {
2086
2061
  if (!allowed) {
2087
2062
  return {
2088
- root,
2063
+ root: core.types.cloneNode(root, true),
2089
2064
  reorderCount: 0,
2090
2065
  sortCount: 0,
2091
2066
  replacedMapReorderCount: 0,
@@ -2136,34 +2111,34 @@ function rewriteQueuedKeyedArrayStructuralReorderHints(root, statesBySetter, fil
2136
2111
  core.types.traverseFast(updater.body, (node) => {
2137
2112
  if (!core.types.isCallExpression(node) || !core.types.isIdentifier(node.callee)) return;
2138
2113
  const helperName = node.callee.name;
2139
- if (helperName === filterIdentifier().name || helperName === sliceIdentifier().name || helperName === mappedStructuralIdentifier().name) {
2114
+ if (helperName === filterIdentifier.name || helperName === sliceIdentifier.name || helperName === mappedStructuralIdentifier.name) {
2140
2115
  startsStructuralLineage = true;
2141
2116
  return;
2142
2117
  }
2143
- if (helperName === structuralReorderIdentifier().name || helperName === structuralSortIdentifier().name) {
2118
+ if (helperName === structuralReorderIdentifier.name || helperName === structuralSortIdentifier.name) {
2144
2119
  startsStructuralLineage = true;
2145
2120
  return;
2146
2121
  }
2147
- if (helperName === mapPipelineIdentifier().name) {
2122
+ if (helperName === mapPipelineIdentifier.name) {
2148
2123
  continuesStructuralLineage = true;
2149
2124
  return;
2150
2125
  }
2151
- if (helperName === queuedMapPipelineIdentifier().name) {
2126
+ if (helperName === queuedMapPipelineIdentifier.name) {
2152
2127
  continuesStructuralLineage = true;
2153
2128
  queuedMaps.push(node);
2154
2129
  return;
2155
2130
  }
2156
- if (helperName === reorderIdentifier().name) {
2131
+ if (helperName === reorderIdentifier.name) {
2157
2132
  continuesStructuralLineage = true;
2158
2133
  reorderCalls.push({ call: node, kind: "reverse", mapped: false });
2159
2134
  return;
2160
2135
  }
2161
- if (helperName === sortIdentifier().name) {
2136
+ if (helperName === sortIdentifier.name) {
2162
2137
  continuesStructuralLineage = true;
2163
2138
  reorderCalls.push({ call: node, kind: "sort", mapped: false });
2164
2139
  return;
2165
2140
  }
2166
- if (helperName === mapReorderIdentifier().name) {
2141
+ if (helperName === mapReorderIdentifier.name) {
2167
2142
  const method = node.arguments[1];
2168
2143
  const kind = core.types.isIdentifier(method) ? methodKinds.get(method.name) : void 0;
2169
2144
  if (!kind) {
@@ -2184,12 +2159,12 @@ function rewriteQueuedKeyedArrayStructuralReorderHints(root, statesBySetter, fil
2184
2159
  continue;
2185
2160
  }
2186
2161
  for (const call of queuedMaps) {
2187
- call.callee = core.types.cloneNode(mapPipelineIdentifier());
2162
+ call.callee = core.types.cloneNode(mapPipelineIdentifier);
2188
2163
  replacedQueuedMapCount += 1;
2189
2164
  }
2190
2165
  for (const { call, kind, mapped } of reorderCalls) {
2191
2166
  call.callee = core.types.cloneNode(
2192
- kind === "reverse" ? structuralReorderIdentifier() : structuralSortIdentifier()
2167
+ kind === "reverse" ? structuralReorderIdentifier : structuralSortIdentifier
2193
2168
  );
2194
2169
  if (kind === "reverse") {
2195
2170
  reorderCount += 1;
@@ -2215,7 +2190,7 @@ function rewriteQueuedKeyedArrayStructuralReorderHints(root, statesBySetter, fil
2215
2190
  function rewriteQueuedKeyedArrayMapReorderHints(root, statesBySetter, mapUpdateIdentifier, queuedMapPipelineIdentifier, mapReorderIdentifier, reorderIdentifier, sortIdentifier, structuralReorderIdentifier, structuralSortIdentifier, allowed) {
2216
2191
  if (!allowed) {
2217
2192
  return {
2218
- root,
2193
+ root: core.types.cloneNode(root, true),
2219
2194
  mapCount: 0,
2220
2195
  mapReorderCount: 0,
2221
2196
  mapSortCount: 0
@@ -2250,7 +2225,7 @@ function rewriteQueuedKeyedArrayMapReorderHints(root, statesBySetter, mapUpdateI
2250
2225
  pendingMaps = [];
2251
2226
  continue;
2252
2227
  }
2253
- if (core.types.isCallExpression(updater.body) && core.types.isIdentifier(updater.body.callee, { name: mapUpdateIdentifier().name }) && updater.body.arguments.length === 2) {
2228
+ if (core.types.isCallExpression(updater.body) && core.types.isIdentifier(updater.body.callee, { name: mapUpdateIdentifier.name }) && updater.body.arguments.length === 2) {
2254
2229
  const pipeline = updater.body.arguments[1];
2255
2230
  let pipelineMapCount = 0;
2256
2231
  if (core.types.isArrowFunctionExpression(pipeline) && pipeline.params.length === 2 && core.types.isIdentifier(pipeline.params[1])) {
@@ -2277,13 +2252,13 @@ function rewriteQueuedKeyedArrayMapReorderHints(root, statesBySetter, mapUpdateI
2277
2252
  let structural = false;
2278
2253
  core.types.traverseFast(updater.body, (node) => {
2279
2254
  if (!core.types.isCallExpression(node) || !core.types.isIdentifier(node.callee)) return;
2280
- if (node.callee.name === structuralReorderIdentifier().name || node.callee.name === structuralSortIdentifier().name) {
2255
+ if (node.callee.name === structuralReorderIdentifier.name || node.callee.name === structuralSortIdentifier.name) {
2281
2256
  structural = true;
2282
- } else if (node.callee.name === mapReorderIdentifier().name) {
2257
+ } else if (node.callee.name === mapReorderIdentifier.name) {
2283
2258
  containsMappedReorder = true;
2284
- } else if (node.callee.name === reorderIdentifier().name) {
2259
+ } else if (node.callee.name === reorderIdentifier.name) {
2285
2260
  reorderCalls.push({ call: node, kind: "reverse" });
2286
- } else if (node.callee.name === sortIdentifier().name) {
2261
+ } else if (node.callee.name === sortIdentifier.name) {
2287
2262
  reorderCalls.push({ call: node, kind: "sort" });
2288
2263
  }
2289
2264
  });
@@ -2305,12 +2280,12 @@ function rewriteQueuedKeyedArrayMapReorderHints(root, statesBySetter, mapUpdateI
2305
2280
  }
2306
2281
  if (hasPendingMaps) {
2307
2282
  for (const candidate of pendingMaps) {
2308
- candidate.updater.body.callee = core.types.cloneNode(queuedMapPipelineIdentifier());
2283
+ candidate.updater.body.callee = core.types.cloneNode(queuedMapPipelineIdentifier);
2309
2284
  mapCount += candidate.count;
2310
2285
  }
2311
2286
  }
2312
2287
  for (const { call, kind } of reorderCalls) {
2313
- call.callee = core.types.cloneNode(mapReorderIdentifier());
2288
+ call.callee = core.types.cloneNode(mapReorderIdentifier);
2314
2289
  if (kind === "reverse") mapReorderCount += 1;
2315
2290
  else mapSortCount += 1;
2316
2291
  }
@@ -2328,7 +2303,7 @@ function rewriteQueuedKeyedArrayMapReorderHints(root, statesBySetter, mapUpdateI
2328
2303
  }
2329
2304
  function rewriteKeyedArraySortHints(root, hintedStateIndices, statesBySetter, helperIdentifier, safeGlobals) {
2330
2305
  if (hintedStateIndices.size === 0) {
2331
- return { root, count: 0, stateIndices: /* @__PURE__ */ new Set() };
2306
+ return { root: core.types.cloneNode(root, true), count: 0, stateIndices: /* @__PURE__ */ new Set() };
2332
2307
  }
2333
2308
  const file = expressionFile(core.types.cloneNode(root, true));
2334
2309
  const stateIndices = /* @__PURE__ */ new Set();
@@ -2367,7 +2342,7 @@ function rewriteKeyedArraySortHints(root, hintedStateIndices, statesBySetter, he
2367
2342
  )
2368
2343
  ]),
2369
2344
  core.types.returnStatement(
2370
- core.types.callExpression(core.types.cloneNode(helperIdentifier()), [
2345
+ core.types.callExpression(core.types.cloneNode(helperIdentifier), [
2371
2346
  core.types.cloneNode(previous),
2372
2347
  core.types.cloneNode(method),
2373
2348
  ...comparator ? [core.types.cloneNode(comparator, true)] : []
@@ -2388,7 +2363,7 @@ function rewriteKeyedArraySortHints(root, hintedStateIndices, statesBySetter, he
2388
2363
  }
2389
2364
  function rewriteKeyedArraySliceHints(root, hintedStateIndices, statesBySetter, helperIdentifier, safeGlobals) {
2390
2365
  if (hintedStateIndices.size === 0) {
2391
- return { root, count: 0, stateIndices: /* @__PURE__ */ new Set() };
2366
+ return { root: core.types.cloneNode(root, true), count: 0, stateIndices: /* @__PURE__ */ new Set() };
2392
2367
  }
2393
2368
  const file = expressionFile(core.types.cloneNode(root, true));
2394
2369
  const stateIndices = /* @__PURE__ */ new Set();
@@ -2429,7 +2404,7 @@ function rewriteKeyedArraySliceHints(root, hintedStateIndices, statesBySetter, h
2429
2404
  )
2430
2405
  ]),
2431
2406
  core.types.returnStatement(
2432
- core.types.callExpression(core.types.cloneNode(helperIdentifier()), [
2407
+ core.types.callExpression(core.types.cloneNode(helperIdentifier), [
2433
2408
  core.types.cloneNode(previous),
2434
2409
  core.types.cloneNode(sliceMethod),
2435
2410
  ...bounds.map((bound) => core.types.cloneNode(bound, true))
@@ -2450,7 +2425,7 @@ function rewriteKeyedArraySliceHints(root, hintedStateIndices, statesBySetter, h
2450
2425
  }
2451
2426
  function rewriteKeyedArrayFilterHints(root, hintedStateIndices, statesBySetter, helperIdentifier, safeGlobals) {
2452
2427
  if (hintedStateIndices.size === 0) {
2453
- return { root, count: 0, stateIndices: /* @__PURE__ */ new Set() };
2428
+ return { root: core.types.cloneNode(root, true), count: 0, stateIndices: /* @__PURE__ */ new Set() };
2454
2429
  }
2455
2430
  const file = expressionFile(core.types.cloneNode(root, true));
2456
2431
  const stateIndices = /* @__PURE__ */ new Set();
@@ -2491,7 +2466,7 @@ function rewriteKeyedArrayFilterHints(root, hintedStateIndices, statesBySetter,
2491
2466
  )
2492
2467
  ]),
2493
2468
  core.types.returnStatement(
2494
- core.types.callExpression(core.types.cloneNode(helperIdentifier()), [
2469
+ core.types.callExpression(core.types.cloneNode(helperIdentifier), [
2495
2470
  core.types.cloneNode(previous),
2496
2471
  core.types.cloneNode(filterMethod),
2497
2472
  core.types.cloneNode(predicate, true)
@@ -2596,9 +2571,9 @@ function prepareKeyedCollectionUpdater(updater, kind, updateHelper, mutationHelp
2596
2571
  )
2597
2572
  ]),
2598
2573
  core.types.returnStatement(
2599
- core.types.callExpression(core.types.cloneNode(updateHelper()), [
2574
+ core.types.callExpression(core.types.cloneNode(updateHelper), [
2600
2575
  core.types.cloneNode(previous),
2601
- core.types.callExpression(core.types.cloneNode(mutationHelper()), [
2576
+ core.types.callExpression(core.types.cloneNode(mutationHelper), [
2602
2577
  core.types.cloneNode(collection),
2603
2578
  core.types.memberExpression(core.types.cloneNode(collection), core.types.cloneNode(updater.body.callee.property)),
2604
2579
  core.types.stringLiteral(operation),
@@ -2733,7 +2708,7 @@ function prepareKeyedCollectionUpdater(updater, kind, updateHelper, mutationHelp
2733
2708
  const operation = collectionMutationOperation(kind, callee.property.name);
2734
2709
  if (!collectionMutationArgumentsAreValid(operation, path.node.arguments)) return;
2735
2710
  path.replaceWith(
2736
- core.types.callExpression(core.types.cloneNode(mutationHelper()), [
2711
+ core.types.callExpression(core.types.cloneNode(mutationHelper), [
2737
2712
  core.types.cloneNode(callee.object),
2738
2713
  core.types.memberExpression(core.types.cloneNode(callee.object), core.types.cloneNode(callee.property)),
2739
2714
  core.types.stringLiteral(operation),
@@ -2744,7 +2719,7 @@ function prepareKeyedCollectionUpdater(updater, kind, updateHelper, mutationHelp
2744
2719
  },
2745
2720
  ReturnStatement(path) {
2746
2721
  if (path.getFunctionParent()?.node !== functionPath?.node || !path.node.argument) return;
2747
- path.node.argument = core.types.callExpression(core.types.cloneNode(updateHelper()), [
2722
+ path.node.argument = core.types.callExpression(core.types.cloneNode(updateHelper), [
2748
2723
  core.types.cloneNode(clonedPrevious),
2749
2724
  core.types.cloneNode(path.node.argument, true),
2750
2725
  core.types.stringLiteral(kind)
@@ -2755,7 +2730,7 @@ function prepareKeyedCollectionUpdater(updater, kind, updateHelper, mutationHelp
2755
2730
  return core.types.isArrowFunctionExpression(prepared) || core.types.isFunctionExpression(prepared) ? { updater: prepared, mutations } : void 0;
2756
2731
  }
2757
2732
  function rewriteKeyedCollectionUpdateHints(root, targetKinds, states, statesBySetter, updateHelper, mutationHelper, globalCollections) {
2758
- if (targetKinds.size === 0) return { root, count: 0 };
2733
+ if (targetKinds.size === 0) return { root: core.types.cloneNode(root, true), count: 0 };
2759
2734
  const file = expressionFile(core.types.cloneNode(root, true));
2760
2735
  let count = 0;
2761
2736
  for (const [stateIndex, kind] of targetKinds) {
@@ -3290,45 +3265,6 @@ function stabilizeDeferredEventCurrentTargets(root, compilerSetters) {
3290
3265
  const expression = file.program.body[0].expression;
3291
3266
  return core.types.isJSXElement(expression) ? expression : core.types.cloneNode(root, true);
3292
3267
  }
3293
- var FOREIGN_ELEMENT_NAMES = new Set(
3294
- [
3295
- "animate animateMotion animateTransform circle clipPath defs desc ellipse",
3296
- "feBlend feColorMatrix feComponentTransfer feComposite feConvolveMatrix",
3297
- "feDiffuseLighting feDisplacementMap feDistantLight feDropShadow feFlood",
3298
- "feFuncA feFuncB feFuncG feFuncR feGaussianBlur feImage feMerge feMergeNode",
3299
- "feMorphology feOffset fePointLight feSpecularLighting feSpotLight feTile",
3300
- "feTurbulence filter foreignObject g image line linearGradient marker mask",
3301
- "metadata mpath path pattern polygon polyline radialGradient rect set stop svg",
3302
- "switch symbol text textPath tspan use view",
3303
- "math maction menclose merror mfrac mi mmultiscripts mn mo mover mpadded",
3304
- "mphantom mprescripts mroot mrow ms mspace msqrt mstyle msub msubsup msup",
3305
- "mtable mtd mtext mtr munder munderover semantics annotation"
3306
- ].join(" ").split(" ")
3307
- );
3308
- function markForeignContent(programPath) {
3309
- let depth = 0;
3310
- programPath.traverse({
3311
- JSXElement: {
3312
- enter(path) {
3313
- if (depth > 0) path.node.extra = { ...path.node.extra, farmForeignContent: true };
3314
- const name = path.node.openingElement.name;
3315
- if (core.types.isJSXIdentifier(name) && (name.name === "svg" || name.name === "math")) depth++;
3316
- },
3317
- exit(path) {
3318
- const name = path.node.openingElement.name;
3319
- if (core.types.isJSXIdentifier(name) && (name.name === "svg" || name.name === "math")) depth--;
3320
- }
3321
- }
3322
- });
3323
- }
3324
- function isForeignContent(element) {
3325
- const name = element.openingElement.name;
3326
- return element.extra?.farmForeignContent === true || core.types.isJSXIdentifier(name) && FOREIGN_ELEMENT_NAMES.has(name.name);
3327
- }
3328
- function reactOwnedAttribute(name, attribute) {
3329
- if (name === "defaultValue" || name === "defaultChecked") return true;
3330
- return (name === "spellCheck" || name === "draggable") && !core.types.isStringLiteral(attribute.value);
3331
- }
3332
3268
  function analyzeKeyedRowTree(row, renderCallback, safeGlobals, compilerSetters, keyedTargetReactiveByValue) {
3333
3269
  if (renderCallback.async || renderCallback.generator || renderCallback.params.length < 1 || renderCallback.params.length > 2 || !core.types.isIdentifier(renderCallback.params[0]) || renderCallback.params[1] !== void 0 && !core.types.isIdentifier(renderCallback.params[1])) {
3334
3270
  return {
@@ -3348,11 +3284,7 @@ function analyzeKeyedRowTree(row, renderCallback, safeGlobals, compilerSetters,
3348
3284
  if (!core.types.isJSXIdentifier(tag) || !/^[a-z]/.test(tag.name)) {
3349
3285
  return "compiled keyed rows support host elements only";
3350
3286
  }
3351
- if (isForeignContent(element)) return "compiled keyed rows do not support SVG yet";
3352
- if (tag.name === "script") return "script elements require React ownership";
3353
- if (tag.name === "title" || tag.name === "meta") {
3354
- return "document metadata requires React ownership";
3355
- }
3287
+ if (tag.name === "svg") return "compiled keyed rows do not support SVG yet";
3356
3288
  const attributeNames = new Set(
3357
3289
  element.openingElement.attributes.filter((attribute) => core.types.isJSXAttribute(attribute)).map(jsxAttributeName).filter((name) => name !== void 0)
3358
3290
  );
@@ -3382,7 +3314,7 @@ function analyzeKeyedRowTree(row, renderCallback, safeGlobals, compilerSetters,
3382
3314
  }
3383
3315
  const name = jsxAttributeName(attribute);
3384
3316
  if (!name) return "compiled keyed rows do not support namespaced JSX attributes";
3385
- if (name === "ref" || name === "dangerouslySetInnerHTML" || reactOwnedAttribute(name, attribute)) {
3317
+ if (name === "ref" || name === "dangerouslySetInnerHTML") {
3386
3318
  return `compiled keyed row ${name} requires React ownership`;
3387
3319
  }
3388
3320
  if (name === "key") continue;
@@ -3750,11 +3682,7 @@ function analyzeHostConditionalTree(branch, safeGlobals, allowStaticEvents = fal
3750
3682
  if (!core.types.isJSXIdentifier(tag) || !/^[a-z]/.test(tag.name)) {
3751
3683
  return "compiler-owned conditionals support host elements only";
3752
3684
  }
3753
- if (isForeignContent(element)) return "compiler-owned conditionals do not support SVG yet";
3754
- if (tag.name === "script") return "script elements require React ownership";
3755
- if (tag.name === "title" || tag.name === "meta") {
3756
- return "document metadata requires React ownership";
3757
- }
3685
+ if (tag.name === "svg") return "compiler-owned conditionals do not support SVG yet";
3758
3686
  for (const attribute of element.openingElement.attributes) {
3759
3687
  if (core.types.isJSXSpreadAttribute(attribute)) {
3760
3688
  if (statefulOnly && !needsStaticBinding(attribute.argument)) continue;
@@ -3762,9 +3690,6 @@ function analyzeHostConditionalTree(branch, safeGlobals, allowStaticEvents = fal
3762
3690
  }
3763
3691
  const name = jsxAttributeName(attribute);
3764
3692
  if (!name) return "compiler-owned conditionals do not support namespaced JSX attributes";
3765
- if (reactOwnedAttribute(name, attribute)) {
3766
- return `compiler-owned conditional ${name} requires React ownership`;
3767
- }
3768
3693
  if (name === "ref" || name === "dangerouslySetInnerHTML" || name === "key") {
3769
3694
  if (statefulOnly && (!core.types.isJSXExpressionContainer(attribute.value) || core.types.isJSXEmptyExpression(attribute.value.expression) || !needsStaticBinding(attribute.value.expression))) {
3770
3695
  continue;
@@ -3877,22 +3802,13 @@ function analyzeRecursiveHostTree(branch, statesByValue, safeGlobals, listNames,
3877
3802
  if (!core.types.isJSXIdentifier(tag) || !/^[a-z]/.test(tag.name)) {
3878
3803
  return "recursive compiler-owned blocks support host elements only";
3879
3804
  }
3880
- if (isForeignContent(element)) {
3881
- return "recursive compiler-owned blocks do not support SVG yet";
3882
- }
3883
- if (tag.name === "script") return "script elements require React ownership";
3884
- if (tag.name === "title" || tag.name === "meta") {
3885
- return "document metadata requires React ownership";
3886
- }
3805
+ if (tag.name === "svg") return "recursive compiler-owned blocks do not support SVG yet";
3887
3806
  for (const attribute of element.openingElement.attributes) {
3888
3807
  if (core.types.isJSXSpreadAttribute(attribute)) {
3889
3808
  return "recursive compiler-owned blocks do not support JSX attribute spreads";
3890
3809
  }
3891
3810
  const name = jsxAttributeName(attribute);
3892
3811
  if (!name) return "recursive compiler-owned blocks do not support namespaced attributes";
3893
- if (reactOwnedAttribute(name, attribute)) {
3894
- return `recursive compiler-owned block ${name} requires React ownership`;
3895
- }
3896
3812
  if (name === "ref" || name === "dangerouslySetInnerHTML" || name === "key") {
3897
3813
  return `recursive compiler-owned block ${name} requires React ownership`;
3898
3814
  }
@@ -4253,7 +4169,7 @@ function analyzeCompilerOwnedKeyedRowHostBlocks(shape, statesByValue, safeGlobal
4253
4169
  }
4254
4170
  function analyzeHostConditionalContainer(container, statesByValue, safeGlobals, listNames, parent, allocateId) {
4255
4171
  const containerName = container.openingElement.name;
4256
- if (!core.types.isJSXIdentifier(containerName) || !/^[a-z]/.test(containerName.name) || isForeignContent(container)) {
4172
+ if (!core.types.isJSXIdentifier(containerName) || !/^[a-z]/.test(containerName.name) || containerName.name === "svg") {
4257
4173
  return void 0;
4258
4174
  }
4259
4175
  if (container.openingElement.attributes.some(
@@ -4318,7 +4234,7 @@ function analyzeHostConditionalContainer(container, statesByValue, safeGlobals,
4318
4234
  }
4319
4235
  function analyzeConditionalRangesContainer(container, statesByValue, safeGlobals, allowSingleRange, listNames, parent, allocateId) {
4320
4236
  const containerName = container.openingElement.name;
4321
- if (!core.types.isJSXIdentifier(containerName) || !/^[a-z]/.test(containerName.name) || isForeignContent(container) || container.openingElement.attributes.some(
4237
+ if (!core.types.isJSXIdentifier(containerName) || !/^[a-z]/.test(containerName.name) || containerName.name === "svg" || container.openingElement.attributes.some(
4322
4238
  (attribute) => core.types.isJSXSpreadAttribute(attribute) || core.types.isJSXAttribute(attribute) && core.types.isJSXIdentifier(attribute.name) && (attribute.name.name === "ref" || attribute.name.name === "dangerouslySetInnerHTML")
4323
4239
  )) {
4324
4240
  return void 0;
@@ -4414,7 +4330,7 @@ function analyzeConditionalRangesContainer(container, statesByValue, safeGlobals
4414
4330
  }
4415
4331
  function analyzeMixedRangesContainer(container, statesByValue, safeGlobals, listNames, parent, allocateId) {
4416
4332
  const containerName = container.openingElement.name;
4417
- if (!core.types.isJSXIdentifier(containerName) || !/^[a-z]/.test(containerName.name) || isForeignContent(container) || container.openingElement.attributes.some(
4333
+ if (!core.types.isJSXIdentifier(containerName) || !/^[a-z]/.test(containerName.name) || containerName.name === "svg" || container.openingElement.attributes.some(
4418
4334
  (attribute) => core.types.isJSXSpreadAttribute(attribute) || core.types.isJSXAttribute(attribute) && core.types.isJSXIdentifier(attribute.name) && (attribute.name.name === "ref" || attribute.name.name === "dangerouslySetInnerHTML")
4419
4335
  )) {
4420
4336
  return void 0;
@@ -4966,57 +4882,6 @@ function canCloneKeyedRows(plan) {
4966
4882
  };
4967
4883
  return cloneable(plan.row);
4968
4884
  }
4969
- function keyedRowBindingTargets(plan) {
4970
- if (!canCloneKeyedRows(plan)) return void 0;
4971
- const root = core.types.identifier("row");
4972
- const targets = /* @__PURE__ */ new Map([["", root]]);
4973
- const statements = [];
4974
- let independentReads = 0;
4975
- for (const binding of plan.bindings) {
4976
- const path = [];
4977
- for (const index of binding.path) {
4978
- independentReads += index + 1;
4979
- for (let sibling = 0; sibling <= index; sibling += 1) {
4980
- const key = [...path, sibling].join(".");
4981
- if (targets.has(key)) continue;
4982
- if (statements.length === 32) return void 0;
4983
- const parent = targets.get(
4984
- sibling === 0 ? path.join(".") : [...path, sibling - 1].join(".")
4985
- );
4986
- const target = core.types.identifier(`target${statements.length}`);
4987
- statements.push(
4988
- core.types.variableDeclaration("const", [
4989
- core.types.variableDeclarator(
4990
- target,
4991
- core.types.optionalMemberExpression(
4992
- parent,
4993
- core.types.identifier(sibling === 0 ? "firstElementChild" : "nextElementSibling"),
4994
- false,
4995
- true
4996
- )
4997
- )
4998
- ])
4999
- );
5000
- targets.set(key, target);
5001
- }
5002
- path.push(index);
5003
- }
5004
- }
5005
- if (statements.length >= independentReads) return void 0;
5006
- return core.types.arrowFunctionExpression(
5007
- [root],
5008
- core.types.blockStatement([
5009
- ...statements,
5010
- core.types.returnStatement(
5011
- core.types.arrayExpression(
5012
- plan.bindings.map(
5013
- (binding) => core.types.logicalExpression("??", targets.get(binding.path.join(".")), core.types.nullLiteral())
5014
- )
5015
- )
5016
- )
5017
- ])
5018
- );
5019
- }
5020
4885
  function keyedRowsBoundary(blockRuntime, plan, keyedMapUpdateHints, keyedArrayFilterHintedStateIndices, keyedArrayPrependHintedStateIndices, keyedArrayPositionHintedStateIndices, keyedArrayReorderHintedStateIndices) {
5021
4886
  const name = core.types.jsxMemberExpression(
5022
4887
  core.types.jsxIdentifier(blockRuntime.name),
@@ -5034,7 +4899,6 @@ function keyedRowsBoundary(blockRuntime, plan, keyedMapUpdateHints, keyedArrayFi
5034
4899
  ...plan.conditionals.map((conditional) => conditional.test)
5035
4900
  ]);
5036
4901
  const delegatedEvents = canDelegateKeyedRowEvents(plan);
5037
- const bindingTargets = keyedRowBindingTargets(plan);
5038
4902
  const renderSource = keyedRowsRenderSource(plan, eventFactory, conditionalFactory);
5039
4903
  const renderFactoryParameters = plan.conditionals.length > 0 ? [core.types.cloneNode(eventFactory), core.types.cloneNode(conditionalFactory)] : plan.events.length > 0 ? [core.types.cloneNode(eventFactory)] : [];
5040
4904
  return core.types.jsxElement(
@@ -5155,7 +5019,6 @@ function keyedRowsBoundary(blockRuntime, plan, keyedMapUpdateHints, keyedArrayFi
5155
5019
  core.types.jsxExpressionContainer(core.types.booleanLiteral(true))
5156
5020
  )
5157
5021
  ] : [],
5158
- ...bindingTargets ? [core.types.jsxAttribute(core.types.jsxIdentifier("targets"), core.types.jsxExpressionContainer(bindingTargets))] : [],
5159
5022
  ...canCloneKeyedRows(plan) ? [
5160
5023
  core.types.jsxAttribute(
5161
5024
  core.types.jsxIdentifier("cloneRows"),
@@ -6170,13 +6033,7 @@ function analyzeHostTree(root, statesByValue, safeGlobals, conditionalExpression
6170
6033
  }
6171
6034
  const expression = attribute.value.expression;
6172
6035
  const dependencies = collectStateDependencies(expression, statesByValue);
6173
- if (dependencies.length === 0) continue;
6174
- if (/^on[A-Z]/.test(name)) {
6175
- if (!core.types.isArrowFunctionExpression(expression) && !core.types.isFunctionExpression(expression)) {
6176
- return "stateful event handler selection requires React ownership";
6177
- }
6178
- continue;
6179
- }
6036
+ if (dependencies.length === 0 || /^on[A-Z]/.test(name)) continue;
6180
6037
  if (name === "style") {
6181
6038
  const reason2 = analyzeStyle(expression, path);
6182
6039
  if (reason2) return reason2;
@@ -7402,14 +7259,6 @@ function compileCandidate(candidate, createComponentIdentifier, keyedMapUpdateId
7402
7259
  appliedKeyedMapUpdateHints > 0 || appliedKeyedArrayAppendHints > 0,
7403
7260
  appliedKeyedArrayAppendHints > 0 && appliedKeyedMapUpdateHints === 0
7404
7261
  );
7405
- for (const feature of runtimeFeatures) {
7406
- if (!runtimeFeatureIdentifiers.has(feature)) {
7407
- runtimeFeatureIdentifiers.set(
7408
- feature,
7409
- path.scope.getProgramParent().generateUidIdentifier(COMPILER_RUNTIME_FEATURE_EXPORTS[feature])
7410
- );
7411
- }
7412
- }
7413
7262
  markShortCircuitBindings(analysis.bindings || []);
7414
7263
  assignStableBindingTargets(analysis.bindings || []);
7415
7264
  const stateParameter = path.scope.generateUidIdentifier("farmState");
@@ -7538,17 +7387,8 @@ function compileCandidate(candidate, createComponentIdentifier, keyedMapUpdateId
7538
7387
  for (const feature of runtimeFeatures) usedRuntimeFeatures.add(feature);
7539
7388
  return void 0;
7540
7389
  }
7541
- function collectCandidates(programPath, options, moduleSelected) {
7390
+ function collectCandidates(programPath) {
7542
7391
  const candidates = [];
7543
- function collect(name, path, statementPath) {
7544
- const functionDirectives = new Set(
7545
- core.types.isBlockStatement(path.node.body) ? directiveValues(path.node.body) : []
7546
- );
7547
- const explicitlySelected = moduleSelected || functionDirectives.has(options.directive);
7548
- if (functionDirectives.has("use no compiler")) return;
7549
- if (options.mode === "annotation" && !explicitlySelected) return;
7550
- candidates.push({ name, path, statementPath, explicitlySelected });
7551
- }
7552
7392
  programPath.traverse({
7553
7393
  FunctionDeclaration(path) {
7554
7394
  if (!path.node.id || !isComponentName(path.node.id.name)) return;
@@ -7556,7 +7396,11 @@ function collectCandidates(programPath, options, moduleSelected) {
7556
7396
  if (!parent.isProgram() && !parent.isExportNamedDeclaration() && !parent.isExportDefaultDeclaration()) {
7557
7397
  return;
7558
7398
  }
7559
- collect(path.node.id.name, path, parent.isProgram() ? path : parent);
7399
+ candidates.push({
7400
+ name: path.node.id.name,
7401
+ path,
7402
+ statementPath: parent.isProgram() ? path : parent
7403
+ });
7560
7404
  },
7561
7405
  VariableDeclarator(path) {
7562
7406
  if (!core.types.isIdentifier(path.node.id) || !isComponentName(path.node.id.name) || !core.types.isFunctionExpression(path.node.init) && !core.types.isArrowFunctionExpression(path.node.init)) {
@@ -7567,7 +7411,11 @@ function collectCandidates(programPath, options, moduleSelected) {
7567
7411
  if (!statement) return;
7568
7412
  const topLevel = statement.isProgram() ? declaration : statement.isExportNamedDeclaration() && statement.parentPath.isProgram() ? statement : null;
7569
7413
  if (!topLevel) return;
7570
- collect(path.node.id.name, path.get("init"), topLevel);
7414
+ candidates.push({
7415
+ name: path.node.id.name,
7416
+ path: path.get("init"),
7417
+ statementPath: topLevel
7418
+ });
7571
7419
  }
7572
7420
  });
7573
7421
  return candidates;
@@ -7614,7 +7462,6 @@ async function compileReactModule(code, id, options) {
7614
7462
  visitor: {
7615
7463
  Program(programPath) {
7616
7464
  const moduleDirectives = new Set(directiveValues(programPath.node));
7617
- markForeignContent(programPath);
7618
7465
  const useStateNames = /* @__PURE__ */ new Set();
7619
7466
  const reactNames = /* @__PURE__ */ new Set();
7620
7467
  const listNames = /* @__PURE__ */ new Set();
@@ -7637,85 +7484,97 @@ async function compileReactModule(code, id, options) {
7637
7484
  }
7638
7485
  }
7639
7486
  }
7640
- const candidates = collectCandidates(
7641
- programPath,
7642
- options,
7643
- moduleDirectives.has(options.directive)
7644
- );
7645
- if (candidates.length === 0) return;
7487
+ const candidates = collectCandidates(programPath);
7646
7488
  const createComponentIdentifier = programPath.scope.generateUidIdentifier("createCompiledComponent");
7647
- const createRefreshComponentIdentifier = programPath.scope.generateUidIdentifier("createRefreshComponent");
7648
- const createProductionComponentIdentifier = programPath.scope.generateUidIdentifier(
7649
- "createProductionComponent"
7489
+ const keyedMapUpdateIdentifier = programPath.scope.generateUidIdentifier(
7490
+ "createCompilerKeyedMapUpdate"
7650
7491
  );
7651
- const helperIdentifier = (name) => {
7652
- let identifier;
7653
- return () => identifier ?? (identifier = programPath.scope.generateUidIdentifier(name));
7654
- };
7655
- const keyedMapUpdateIdentifier = helperIdentifier("createCompilerKeyedMapUpdate");
7656
- const keyedArrayAppendIdentifier = helperIdentifier("createCompilerKeyedArrayAppend");
7657
- const keyedArrayFilterIdentifier = helperIdentifier("createCompilerKeyedArrayFilter");
7658
- const keyedArrayMapPipelineIdentifier = helperIdentifier(
7492
+ const keyedArrayAppendIdentifier = programPath.scope.generateUidIdentifier(
7493
+ "createCompilerKeyedArrayAppend"
7494
+ );
7495
+ const keyedArrayFilterIdentifier = programPath.scope.generateUidIdentifier(
7496
+ "createCompilerKeyedArrayFilter"
7497
+ );
7498
+ const keyedArrayMapPipelineIdentifier = programPath.scope.generateUidIdentifier(
7659
7499
  "createCompilerKeyedArrayMapPipeline"
7660
7500
  );
7661
- const keyedArrayMappedStructuralAppendIdentifier = helperIdentifier(
7501
+ const keyedArrayMappedStructuralAppendIdentifier = programPath.scope.generateUidIdentifier(
7662
7502
  "createCompilerKeyedArrayMappedStructuralAppend"
7663
7503
  );
7664
- const keyedArrayStructuralAppendMapPipelineIdentifier = helperIdentifier(
7504
+ const keyedArrayStructuralAppendMapPipelineIdentifier = programPath.scope.generateUidIdentifier(
7665
7505
  "createCompilerKeyedArrayStructuralAppendMapPipeline"
7666
7506
  );
7667
- const keyedArrayMappedStructuralPrependIdentifier = helperIdentifier(
7507
+ const keyedArrayMappedStructuralPrependIdentifier = programPath.scope.generateUidIdentifier(
7668
7508
  "createCompilerKeyedArrayMappedStructuralPrepend"
7669
7509
  );
7670
- const keyedArrayStructuralPrependMapPipelineIdentifier = helperIdentifier(
7510
+ const keyedArrayStructuralPrependMapPipelineIdentifier = programPath.scope.generateUidIdentifier(
7671
7511
  "createCompilerKeyedArrayStructuralPrependMapPipeline"
7672
7512
  );
7673
- const keyedArrayQueuedMapPipelineIdentifier = helperIdentifier(
7513
+ const keyedArrayQueuedMapPipelineIdentifier = programPath.scope.generateUidIdentifier(
7674
7514
  "createCompilerKeyedArrayQueuedMapPipeline"
7675
7515
  );
7676
- const keyedArrayRollingWindowMapPipelineIdentifier = helperIdentifier(
7516
+ const keyedArrayRollingWindowMapPipelineIdentifier = programPath.scope.generateUidIdentifier(
7677
7517
  "createCompilerKeyedArrayRollingWindowMapPipeline"
7678
7518
  );
7679
- const keyedArrayMappedRollingWindowIdentifier = helperIdentifier(
7519
+ const keyedArrayMappedRollingWindowIdentifier = programPath.scope.generateUidIdentifier(
7680
7520
  "createCompilerKeyedArrayMappedRollingWindow"
7681
7521
  );
7682
- const keyedArrayMapReorderIdentifier = helperIdentifier(
7522
+ const keyedArrayMapReorderIdentifier = programPath.scope.generateUidIdentifier(
7683
7523
  "createCompilerKeyedArrayMapReorder"
7684
7524
  );
7685
- const keyedArrayMappedStructuralIdentifier = helperIdentifier(
7525
+ const keyedArrayMappedStructuralIdentifier = programPath.scope.generateUidIdentifier(
7686
7526
  "finalizeCompilerKeyedArrayMappedStructuralUpdate"
7687
7527
  );
7688
- const keyedArrayPrependIdentifier = helperIdentifier("createCompilerKeyedArrayPrepend");
7689
- const keyedArrayPositionIdentifier = helperIdentifier(
7528
+ const keyedArrayPrependIdentifier = programPath.scope.generateUidIdentifier(
7529
+ "createCompilerKeyedArrayPrepend"
7530
+ );
7531
+ const keyedArrayPositionIdentifier = programPath.scope.generateUidIdentifier(
7690
7532
  "createCompilerKeyedArrayPositionUpdate"
7691
7533
  );
7692
- const keyedArrayBatchInsertIdentifier = helperIdentifier(
7534
+ const keyedArrayBatchInsertIdentifier = programPath.scope.generateUidIdentifier(
7693
7535
  "createCompilerKeyedArrayBatchInsert"
7694
7536
  );
7695
- const keyedArrayWindowReplaceIdentifier = helperIdentifier(
7537
+ const keyedArrayWindowReplaceIdentifier = programPath.scope.generateUidIdentifier(
7696
7538
  "createCompilerKeyedArrayWindowReplace"
7697
7539
  );
7698
- const keyedArrayReorderIdentifier = helperIdentifier("createCompilerKeyedArrayReorder");
7699
- const keyedArrayStructuralReorderIdentifier = helperIdentifier(
7540
+ const keyedArrayReorderIdentifier = programPath.scope.generateUidIdentifier(
7541
+ "createCompilerKeyedArrayReorder"
7542
+ );
7543
+ const keyedArrayStructuralReorderIdentifier = programPath.scope.generateUidIdentifier(
7700
7544
  "createCompilerKeyedArrayStructuralReorder"
7701
7545
  );
7702
- const keyedArraySortIdentifier = helperIdentifier("createCompilerKeyedArraySort");
7703
- const keyedArrayStructuralSortIdentifier = helperIdentifier(
7546
+ const keyedArraySortIdentifier = programPath.scope.generateUidIdentifier(
7547
+ "createCompilerKeyedArraySort"
7548
+ );
7549
+ const keyedArrayStructuralSortIdentifier = programPath.scope.generateUidIdentifier(
7704
7550
  "createCompilerKeyedArrayStructuralSort"
7705
7551
  );
7706
- const keyedArrayRollingWindowIdentifier = helperIdentifier(
7552
+ const keyedArrayRollingWindowIdentifier = programPath.scope.generateUidIdentifier(
7707
7553
  "createCompilerKeyedArrayRollingWindow"
7708
7554
  );
7709
- const keyedArraySliceIdentifier = helperIdentifier("createCompilerKeyedArraySlice");
7710
- const keyedCollectionUpdateIdentifier = helperIdentifier(
7555
+ const keyedArraySliceIdentifier = programPath.scope.generateUidIdentifier(
7556
+ "createCompilerKeyedArraySlice"
7557
+ );
7558
+ const keyedCollectionUpdateIdentifier = programPath.scope.generateUidIdentifier(
7711
7559
  "createCompilerKeyedCollectionUpdate"
7712
7560
  );
7713
- const keyedCollectionMutationIdentifier = helperIdentifier(
7561
+ const keyedCollectionMutationIdentifier = programPath.scope.generateUidIdentifier(
7714
7562
  "applyCompilerKeyedCollectionMutation"
7715
7563
  );
7716
- const runtimeFeatureIdentifiers = /* @__PURE__ */ new Map();
7564
+ const runtimeFeatureIdentifiers = new Map(
7565
+ Object.entries(COMPILER_RUNTIME_FEATURE_EXPORTS).map(([feature, exportName]) => [
7566
+ feature,
7567
+ programPath.scope.generateUidIdentifier(exportName)
7568
+ ])
7569
+ );
7717
7570
  const usedRuntimeFeatures = /* @__PURE__ */ new Set();
7718
7571
  for (const candidate of candidates) {
7572
+ const functionDirectives = new Set(
7573
+ core.types.isBlockStatement(candidate.path.node.body) ? directiveValues(candidate.path.node.body) : []
7574
+ );
7575
+ const explicitlySelected = moduleDirectives.has(options.directive) || functionDirectives.has(options.directive);
7576
+ if (functionDirectives.has("use no compiler")) continue;
7577
+ if (options.mode === "annotation" && !explicitlySelected) continue;
7719
7578
  const reason = compileCandidate(
7720
7579
  candidate,
7721
7580
  createComponentIdentifier,
@@ -7758,7 +7617,7 @@ async function compileReactModule(code, id, options) {
7758
7617
  diagnostics.push({
7759
7618
  component: candidate.name,
7760
7619
  reason,
7761
- selected: candidate.explicitlySelected
7620
+ selected: explicitlySelected
7762
7621
  });
7763
7622
  } else {
7764
7623
  compiled.push(candidate.name);
@@ -7771,103 +7630,83 @@ async function compileReactModule(code, id, options) {
7771
7630
  const hasKeyedArrayStructuralPrependHints = optimizationCounts.keyedArrayPrependHints > 0 && (optimizationCounts.keyedArrayFilterHints > 0 || optimizationCounts.keyedArraySliceHints > 0);
7772
7631
  const hasUnmappedKeyedArrayPrependHints = optimizationCounts.keyedArrayPrependHints > compilerUsage.keyedArrayMappedStructuralPrependHints;
7773
7632
  if (compiled.length > 0) {
7774
- programPath.unshiftContainer(
7775
- "body",
7776
- core.types.variableDeclaration("const", [
7777
- core.types.variableDeclarator(
7778
- core.types.cloneNode(createComponentIdentifier),
7779
- core.types.conditionalExpression(
7780
- core.types.memberExpression(
7781
- core.types.metaProperty(core.types.identifier("import"), core.types.identifier("meta")),
7782
- core.types.identifier("hot")
7783
- ),
7784
- core.types.cloneNode(createRefreshComponentIdentifier),
7785
- core.types.cloneNode(createProductionComponentIdentifier)
7786
- )
7787
- )
7788
- ])
7789
- );
7790
7633
  programPath.unshiftContainer(
7791
7634
  "body",
7792
7635
  core.types.importDeclaration(
7793
7636
  [
7794
7637
  core.types.importSpecifier(
7795
- createRefreshComponentIdentifier,
7638
+ createComponentIdentifier,
7796
7639
  core.types.identifier("createCompiledComponentWithFeatures")
7797
7640
  ),
7798
- core.types.importSpecifier(
7799
- createProductionComponentIdentifier,
7800
- core.types.identifier("createCompiledComponentWithoutRefresh")
7801
- ),
7802
7641
  ...optimizationCounts.keyedMapUpdateHints > compilerUsage.keyedArrayMapUpdateHints ? [
7803
7642
  core.types.importSpecifier(
7804
- keyedMapUpdateIdentifier(),
7643
+ keyedMapUpdateIdentifier,
7805
7644
  core.types.identifier("createCompilerKeyedMapUpdate")
7806
7645
  )
7807
7646
  ] : [],
7808
7647
  ...hasEagerKeyedArrayMapUpdateHints ? [
7809
7648
  core.types.importSpecifier(
7810
- keyedArrayMapPipelineIdentifier(),
7649
+ keyedArrayMapPipelineIdentifier,
7811
7650
  core.types.identifier("createCompilerKeyedArrayMapPipeline")
7812
7651
  )
7813
7652
  ] : [],
7814
7653
  ...compilerUsage.keyedArrayStructuralAppendMapHints > 0 ? [
7815
7654
  core.types.importSpecifier(
7816
- keyedArrayStructuralAppendMapPipelineIdentifier(),
7655
+ keyedArrayStructuralAppendMapPipelineIdentifier,
7817
7656
  core.types.identifier("createCompilerKeyedArrayStructuralAppendMapPipeline")
7818
7657
  )
7819
7658
  ] : [],
7820
7659
  ...compilerUsage.keyedArrayStructuralPrependMapHints > 0 ? [
7821
7660
  core.types.importSpecifier(
7822
- keyedArrayStructuralPrependMapPipelineIdentifier(),
7661
+ keyedArrayStructuralPrependMapPipelineIdentifier,
7823
7662
  core.types.identifier("createCompilerKeyedArrayStructuralPrependMapPipeline")
7824
7663
  )
7825
7664
  ] : [],
7826
7665
  ...hasKeyedArrayMapReorderHints ? [
7827
7666
  core.types.importSpecifier(
7828
- keyedArrayMapReorderIdentifier(),
7667
+ keyedArrayMapReorderIdentifier,
7829
7668
  core.types.identifier("createCompilerKeyedArrayMapReorder")
7830
7669
  )
7831
7670
  ] : [],
7832
7671
  ...compilerUsage.keyedArrayMappedStructuralHints > 0 ? [
7833
7672
  core.types.importSpecifier(
7834
- keyedArrayMappedStructuralIdentifier(),
7673
+ keyedArrayMappedStructuralIdentifier,
7835
7674
  core.types.identifier("finalizeCompilerKeyedArrayMappedStructuralUpdate")
7836
7675
  )
7837
7676
  ] : [],
7838
7677
  ...compilerUsage.keyedArrayMappedStructuralAppendHints > 0 || compilerUsage.keyedArrayMappedRollingWindowHints > compilerUsage.keyedArrayMappedRollingWindowChainHints ? [
7839
7678
  core.types.importSpecifier(
7840
- keyedArrayMappedStructuralAppendIdentifier(),
7679
+ keyedArrayMappedStructuralAppendIdentifier,
7841
7680
  core.types.identifier("createCompilerKeyedArrayMappedStructuralAppend")
7842
7681
  )
7843
7682
  ] : [],
7844
7683
  ...compilerUsage.keyedArrayMappedStructuralPrependHints > 0 ? [
7845
7684
  core.types.importSpecifier(
7846
- keyedArrayMappedStructuralPrependIdentifier(),
7685
+ keyedArrayMappedStructuralPrependIdentifier,
7847
7686
  core.types.identifier("createCompilerKeyedArrayMappedStructuralPrepend")
7848
7687
  )
7849
7688
  ] : [],
7850
7689
  ...compilerUsage.keyedArrayQueuedMapUpdateHints > 0 ? [
7851
7690
  core.types.importSpecifier(
7852
- keyedArrayQueuedMapPipelineIdentifier(),
7691
+ keyedArrayQueuedMapPipelineIdentifier,
7853
7692
  core.types.identifier("createCompilerKeyedArrayQueuedMapPipeline")
7854
7693
  )
7855
7694
  ] : [],
7856
7695
  ...compilerUsage.keyedArrayMappedRollingWindowChainHints > 0 ? [
7857
7696
  core.types.importSpecifier(
7858
- keyedArrayRollingWindowMapPipelineIdentifier(),
7697
+ keyedArrayRollingWindowMapPipelineIdentifier,
7859
7698
  core.types.identifier("createCompilerKeyedArrayRollingWindowMapPipeline")
7860
7699
  )
7861
7700
  ] : [],
7862
7701
  ...compilerUsage.keyedArrayMappedRollingWindowChainHints > 0 ? [
7863
7702
  core.types.importSpecifier(
7864
- keyedArrayMappedRollingWindowIdentifier(),
7703
+ keyedArrayMappedRollingWindowIdentifier,
7865
7704
  core.types.identifier("createCompilerKeyedArrayMappedRollingWindow")
7866
7705
  )
7867
7706
  ] : [],
7868
7707
  ...hasUnmappedKeyedArrayAppendHints || compilerUsage.keyedArrayStructuralRollingWindowHints > 0 ? [
7869
7708
  core.types.importSpecifier(
7870
- keyedArrayAppendIdentifier(),
7709
+ keyedArrayAppendIdentifier,
7871
7710
  core.types.identifier(
7872
7711
  hasKeyedArrayStructuralAppendHints ? "createCompilerKeyedArrayStructuralAppend" : "createCompilerKeyedArrayAppend"
7873
7712
  )
@@ -7875,13 +7714,13 @@ async function compileReactModule(code, id, options) {
7875
7714
  ] : [],
7876
7715
  ...optimizationCounts.keyedArrayFilterHints > 0 ? [
7877
7716
  core.types.importSpecifier(
7878
- keyedArrayFilterIdentifier(),
7717
+ keyedArrayFilterIdentifier,
7879
7718
  core.types.identifier("createCompilerKeyedArrayFilter")
7880
7719
  )
7881
7720
  ] : [],
7882
7721
  ...hasUnmappedKeyedArrayPrependHints ? [
7883
7722
  core.types.importSpecifier(
7884
- keyedArrayPrependIdentifier(),
7723
+ keyedArrayPrependIdentifier,
7885
7724
  core.types.identifier(
7886
7725
  hasKeyedArrayStructuralPrependHints ? "createCompilerKeyedArrayStructuralPrepend" : "createCompilerKeyedArrayPrepend"
7887
7726
  )
@@ -7889,65 +7728,65 @@ async function compileReactModule(code, id, options) {
7889
7728
  ] : [],
7890
7729
  ...optimizationCounts.keyedArrayPositionHints > compilerUsage.keyedArrayBatchInsertHints + compilerUsage.keyedArrayWindowReplaceHints ? [
7891
7730
  core.types.importSpecifier(
7892
- keyedArrayPositionIdentifier(),
7731
+ keyedArrayPositionIdentifier,
7893
7732
  core.types.identifier("createCompilerKeyedArrayPositionUpdate")
7894
7733
  )
7895
7734
  ] : [],
7896
7735
  ...compilerUsage.keyedArrayBatchInsertHints > 0 ? [
7897
7736
  core.types.importSpecifier(
7898
- keyedArrayBatchInsertIdentifier(),
7737
+ keyedArrayBatchInsertIdentifier,
7899
7738
  core.types.identifier("createCompilerKeyedArrayBatchInsert")
7900
7739
  )
7901
7740
  ] : [],
7902
7741
  ...compilerUsage.keyedArrayWindowReplaceHints > 0 ? [
7903
7742
  core.types.importSpecifier(
7904
- keyedArrayWindowReplaceIdentifier(),
7743
+ keyedArrayWindowReplaceIdentifier,
7905
7744
  core.types.identifier("createCompilerKeyedArrayWindowReplace")
7906
7745
  )
7907
7746
  ] : [],
7908
7747
  ...optimizationCounts.keyedArrayReorderHints > compilerUsage.keyedArrayStructuralReorderHints + compilerUsage.keyedArrayMapReorderHints ? [
7909
7748
  core.types.importSpecifier(
7910
- keyedArrayReorderIdentifier(),
7749
+ keyedArrayReorderIdentifier,
7911
7750
  core.types.identifier("createCompilerKeyedArrayReorder")
7912
7751
  )
7913
7752
  ] : [],
7914
7753
  ...compilerUsage.keyedArrayStructuralReorderHints > 0 ? [
7915
7754
  core.types.importSpecifier(
7916
- keyedArrayStructuralReorderIdentifier(),
7755
+ keyedArrayStructuralReorderIdentifier,
7917
7756
  core.types.identifier("createCompilerKeyedArrayStructuralReorder")
7918
7757
  )
7919
7758
  ] : [],
7920
7759
  ...optimizationCounts.keyedArraySortHints > compilerUsage.keyedArrayStructuralSortHints + compilerUsage.keyedArrayMapSortHints ? [
7921
7760
  core.types.importSpecifier(
7922
- keyedArraySortIdentifier(),
7761
+ keyedArraySortIdentifier,
7923
7762
  core.types.identifier("createCompilerKeyedArraySort")
7924
7763
  )
7925
7764
  ] : [],
7926
7765
  ...compilerUsage.keyedArrayStructuralSortHints > 0 ? [
7927
7766
  core.types.importSpecifier(
7928
- keyedArrayStructuralSortIdentifier(),
7767
+ keyedArrayStructuralSortIdentifier,
7929
7768
  core.types.identifier("createCompilerKeyedArrayStructuralSort")
7930
7769
  )
7931
7770
  ] : [],
7932
7771
  ...optimizationCounts.keyedArrayRollingWindowHints > compilerUsage.keyedArrayMappedRollingWindowHints + compilerUsage.keyedArrayStructuralRollingWindowHints ? [
7933
7772
  core.types.importSpecifier(
7934
- keyedArrayRollingWindowIdentifier(),
7773
+ keyedArrayRollingWindowIdentifier,
7935
7774
  core.types.identifier("createCompilerKeyedArrayRollingWindow")
7936
7775
  )
7937
7776
  ] : [],
7938
7777
  ...optimizationCounts.keyedArraySliceHints > 0 || optimizationCounts.keyedArrayRollingWindowHints > 0 ? [
7939
7778
  core.types.importSpecifier(
7940
- keyedArraySliceIdentifier(),
7779
+ keyedArraySliceIdentifier,
7941
7780
  core.types.identifier("createCompilerKeyedArraySlice")
7942
7781
  )
7943
7782
  ] : [],
7944
7783
  ...optimizationCounts.keyedCollectionUpdateHints > 0 ? [
7945
7784
  core.types.importSpecifier(
7946
- keyedCollectionUpdateIdentifier(),
7785
+ keyedCollectionUpdateIdentifier,
7947
7786
  core.types.identifier("createCompilerKeyedCollectionUpdate")
7948
7787
  ),
7949
7788
  core.types.importSpecifier(
7950
- keyedCollectionMutationIdentifier(),
7789
+ keyedCollectionMutationIdentifier,
7951
7790
  core.types.identifier("applyCompilerKeyedCollectionMutation")
7952
7791
  )
7953
7792
  ] : [],