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

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