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

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.mjs CHANGED
@@ -765,7 +765,7 @@ function rewriteKeyedMapUpdateHints(root, hintedStateIndices, statesBySetter, he
765
765
  }
766
766
  path.node.arguments[0] = types.arrowFunctionExpression(
767
767
  [types.cloneNode(previous)],
768
- types.callExpression(types.cloneNode(helperIdentifier), [
768
+ types.callExpression(types.cloneNode(helperIdentifier()), [
769
769
  types.cloneNode(previous),
770
770
  types.arrowFunctionExpression(
771
771
  [types.cloneNode(pipelineValue), types.cloneNode(applyMap)],
@@ -837,7 +837,7 @@ function rewriteKeyedArrayAppendHints(root, hintedStateIndices, statesBySetter,
837
837
  types.variableDeclarator(types.cloneNode(nextValue), types.cloneNode(updateExpression, true))
838
838
  ]),
839
839
  types.returnStatement(
840
- types.callExpression(types.cloneNode(helperIdentifier), [
840
+ types.callExpression(types.cloneNode(helperIdentifier()), [
841
841
  types.cloneNode(previous),
842
842
  types.cloneNode(nextValue)
843
843
  ])
@@ -913,7 +913,7 @@ function rewriteKeyedArrayPrependHints(root, hintedStateIndices, statesBySetter,
913
913
  types.variableDeclarator(types.cloneNode(nextValue), types.cloneNode(updateExpression, true))
914
914
  ]),
915
915
  types.returnStatement(
916
- types.callExpression(types.cloneNode(helperIdentifier), [
916
+ types.callExpression(types.cloneNode(helperIdentifier()), [
917
917
  types.cloneNode(previous),
918
918
  types.cloneNode(nextValue)
919
919
  ])
@@ -1004,7 +1004,7 @@ function rewriteKeyedArrayRollingWindowHints(root, hintedStateIndices, statesByS
1004
1004
  ),
1005
1005
  types.variableDeclarator(
1006
1006
  types.cloneNode(retained),
1007
- types.callExpression(types.cloneNode(sliceHelperIdentifier), [
1007
+ types.callExpression(types.cloneNode(sliceHelperIdentifier()), [
1008
1008
  types.cloneNode(previous),
1009
1009
  types.cloneNode(sliceMethod),
1010
1010
  types.cloneNode(retainedStart, true)
@@ -1013,7 +1013,7 @@ function rewriteKeyedArrayRollingWindowHints(root, hintedStateIndices, statesByS
1013
1013
  types.variableDeclarator(types.cloneNode(nextValue), types.arrayExpression(nextElements))
1014
1014
  ]),
1015
1015
  types.returnStatement(
1016
- types.callExpression(types.cloneNode(rollingWindowHelperIdentifier), [
1016
+ types.callExpression(types.cloneNode(rollingWindowHelperIdentifier()), [
1017
1017
  types.cloneNode(previous),
1018
1018
  types.cloneNode(retained),
1019
1019
  types.cloneNode(nextValue)
@@ -1112,18 +1112,18 @@ function rewriteKeyedArrayPositionHints(root, hintedStateIndices, statesBySetter
1112
1112
  )
1113
1113
  ]),
1114
1114
  types.returnStatement(
1115
- kind === "batch-insert" ? types.callExpression(types.cloneNode(batchInsertHelperIdentifier), [
1115
+ kind === "batch-insert" ? types.callExpression(types.cloneNode(batchInsertHelperIdentifier()), [
1116
1116
  types.cloneNode(previous),
1117
1117
  types.cloneNode(method),
1118
1118
  types.cloneNode(position, true),
1119
1119
  ...args.slice(2).map((argument) => types.cloneNode(argument, true))
1120
- ]) : kind === "window-replace" ? types.callExpression(types.cloneNode(windowReplaceHelperIdentifier), [
1120
+ ]) : kind === "window-replace" ? types.callExpression(types.cloneNode(windowReplaceHelperIdentifier()), [
1121
1121
  types.cloneNode(previous),
1122
1122
  types.cloneNode(method),
1123
1123
  types.cloneNode(position, true),
1124
1124
  types.cloneNode(args[1], true),
1125
1125
  ...args.slice(2).map((argument) => types.cloneNode(argument, true))
1126
- ]) : types.callExpression(types.cloneNode(helperIdentifier), [
1126
+ ]) : types.callExpression(types.cloneNode(helperIdentifier()), [
1127
1127
  types.cloneNode(previous),
1128
1128
  types.cloneNode(method),
1129
1129
  types.stringLiteral(kind),
@@ -1183,7 +1183,7 @@ function rewriteKeyedArrayReorderHints(root, hintedStateIndices, statesBySetter,
1183
1183
  )
1184
1184
  ]),
1185
1185
  types.returnStatement(
1186
- types.callExpression(types.cloneNode(helperIdentifier), [
1186
+ types.callExpression(types.cloneNode(helperIdentifier()), [
1187
1187
  types.cloneNode(previous),
1188
1188
  types.cloneNode(method)
1189
1189
  ])
@@ -1389,7 +1389,7 @@ function rewriteKeyedArrayReorderPipelineHints(root, hintedStateIndices, statesB
1389
1389
  types.variableDeclaration("const", [
1390
1390
  types.variableDeclarator(
1391
1391
  types.cloneNode(result2),
1392
- types.callExpression(types.cloneNode(mapHelperIdentifier), [
1392
+ types.callExpression(types.cloneNode(mapHelperIdentifier()), [
1393
1393
  types.cloneNode(value),
1394
1394
  types.arrowFunctionExpression(
1395
1395
  [types.cloneNode(pipelineValue), types.cloneNode(applyMap)],
@@ -1426,7 +1426,7 @@ function rewriteKeyedArrayReorderPipelineHints(root, hintedStateIndices, statesB
1426
1426
  types.variableDeclaration("const", [
1427
1427
  types.variableDeclarator(
1428
1428
  types.cloneNode(result),
1429
- types.callExpression(types.cloneNode(helper), [
1429
+ types.callExpression(types.cloneNode(helper()), [
1430
1430
  types.cloneNode(value),
1431
1431
  types.cloneNode(method),
1432
1432
  ...args
@@ -1452,7 +1452,9 @@ function rewriteKeyedArrayReorderPipelineHints(root, hintedStateIndices, statesB
1452
1452
  }
1453
1453
  statements.push(
1454
1454
  types.returnStatement(
1455
- terminalStructuralPipeline ? types.callExpression(types.cloneNode(mappedStructuralHelperIdentifier), [types.cloneNode(value)]) : types.cloneNode(value)
1455
+ terminalStructuralPipeline ? types.callExpression(types.cloneNode(mappedStructuralHelperIdentifier()), [
1456
+ types.cloneNode(value)
1457
+ ]) : types.cloneNode(value)
1456
1458
  )
1457
1459
  );
1458
1460
  if (terminalStructuralPipeline) terminalStructuralPipelineCount += 1;
@@ -1493,13 +1495,13 @@ function rewriteQueuedKeyedArrayReorderMapHints(root, statesBySetter, mapUpdateI
1493
1495
  return found;
1494
1496
  };
1495
1497
  const reorderHelperNames = /* @__PURE__ */ new Set([
1496
- mapReorderIdentifier.name,
1497
- reorderIdentifier.name,
1498
- sortIdentifier.name
1498
+ mapReorderIdentifier().name,
1499
+ reorderIdentifier().name,
1500
+ sortIdentifier().name
1499
1501
  ]);
1500
1502
  const structuralHelperNames = /* @__PURE__ */ new Set([
1501
- structuralReorderIdentifier.name,
1502
- structuralSortIdentifier.name
1503
+ structuralReorderIdentifier().name,
1504
+ structuralSortIdentifier().name
1503
1505
  ]);
1504
1506
  traverse(file, {
1505
1507
  BlockStatement(path) {
@@ -1526,7 +1528,7 @@ function rewriteQueuedKeyedArrayReorderMapHints(root, statesBySetter, mapUpdateI
1526
1528
  queuedReorderState = state.index;
1527
1529
  continue;
1528
1530
  }
1529
- if (queuedReorderState !== state.index || !types.isCallExpression(updater.body) || !types.isIdentifier(updater.body.callee, { name: mapUpdateIdentifier.name }) || updater.body.arguments.length !== 2) {
1531
+ if (queuedReorderState !== state.index || !types.isCallExpression(updater.body) || !types.isIdentifier(updater.body.callee, { name: mapUpdateIdentifier().name }) || updater.body.arguments.length !== 2) {
1530
1532
  queuedReorderState = void 0;
1531
1533
  continue;
1532
1534
  }
@@ -1546,7 +1548,7 @@ function rewriteQueuedKeyedArrayReorderMapHints(root, statesBySetter, mapUpdateI
1546
1548
  queuedReorderState = void 0;
1547
1549
  continue;
1548
1550
  }
1549
- updater.body.callee = types.cloneNode(queuedMapPipelineIdentifier);
1551
+ updater.body.callee = types.cloneNode(queuedMapPipelineIdentifier());
1550
1552
  mapCount += pipelineMapCount;
1551
1553
  }
1552
1554
  }
@@ -1557,7 +1559,7 @@ function rewriteQueuedKeyedArrayReorderMapHints(root, statesBySetter, mapUpdateI
1557
1559
  };
1558
1560
  }
1559
1561
  function countKeyedArrayMapPipeline(updater, mapUpdateIdentifier) {
1560
- if (!types.isCallExpression(updater.body) || !types.isIdentifier(updater.body.callee, { name: mapUpdateIdentifier.name }) || updater.body.arguments.length !== 2) {
1562
+ if (!types.isCallExpression(updater.body) || !types.isIdentifier(updater.body.callee, { name: mapUpdateIdentifier().name }) || updater.body.arguments.length !== 2) {
1561
1563
  return 0;
1562
1564
  }
1563
1565
  const pipeline = updater.body.arguments[1];
@@ -1589,7 +1591,7 @@ function rewriteQueuedKeyedArrayMappedStructuralHints(root, statesBySetter, mapU
1589
1591
  const terminalStructuralReturn = (updater) => {
1590
1592
  if (!types.isBlockStatement(updater.body)) return void 0;
1591
1593
  const statement = updater.body.body.at(-1);
1592
- if (!types.isReturnStatement(statement) || !statement.argument || !types.isCallExpression(statement.argument) || !types.isIdentifier(statement.argument.callee) || statement.argument.callee.name !== filterIdentifier.name && statement.argument.callee.name !== sliceIdentifier.name) {
1594
+ if (!types.isReturnStatement(statement) || !statement.argument || !types.isCallExpression(statement.argument) || !types.isIdentifier(statement.argument.callee) || statement.argument.callee.name !== filterIdentifier().name && statement.argument.callee.name !== sliceIdentifier().name) {
1593
1595
  return void 0;
1594
1596
  }
1595
1597
  return statement;
@@ -1643,7 +1645,7 @@ function rewriteQueuedKeyedArrayMappedStructuralHints(root, statesBySetter, mapU
1643
1645
  }
1644
1646
  if (hasPendingMaps) {
1645
1647
  for (const candidate of pendingMaps) {
1646
- candidate.updater.body.callee = types.cloneNode(queuedMapPipelineIdentifier);
1648
+ candidate.updater.body.callee = types.cloneNode(queuedMapPipelineIdentifier());
1647
1649
  mapCount += candidate.count;
1648
1650
  }
1649
1651
  }
@@ -1653,7 +1655,7 @@ function rewriteQueuedKeyedArrayMappedStructuralHints(root, statesBySetter, mapU
1653
1655
  pendingMaps = [];
1654
1656
  continue;
1655
1657
  }
1656
- structuralReturn.argument = types.callExpression(types.cloneNode(mappedStructuralIdentifier), [
1658
+ structuralReturn.argument = types.callExpression(types.cloneNode(mappedStructuralIdentifier()), [
1657
1659
  types.cloneNode(structuralValue)
1658
1660
  ]);
1659
1661
  structuralCount += 1;
@@ -1693,10 +1695,10 @@ function rewriteQueuedKeyedArrayStructuralMapHints(root, statesBySetter, mapUpda
1693
1695
  let mapped = false;
1694
1696
  types.traverseFast(statement.argument, (node) => {
1695
1697
  if (!found && types.isCallExpression(node) && types.isIdentifier(node.callee)) {
1696
- if (node.callee.name === filterIdentifier.name) found = "filter";
1697
- if (node.callee.name === sliceIdentifier.name) found = "slice";
1698
+ if (node.callee.name === filterIdentifier().name) found = "filter";
1699
+ if (node.callee.name === sliceIdentifier().name) found = "slice";
1698
1700
  }
1699
- if (!mapped && types.isCallExpression(node) && types.isIdentifier(node.callee, { name: mappedStructuralIdentifier.name })) {
1701
+ if (!mapped && types.isCallExpression(node) && types.isIdentifier(node.callee, { name: mappedStructuralIdentifier().name })) {
1700
1702
  mapped = true;
1701
1703
  }
1702
1704
  });
@@ -1745,7 +1747,7 @@ function rewriteQueuedKeyedArrayStructuralMapHints(root, statesBySetter, mapUpda
1745
1747
  }
1746
1748
  const appendCalls = [];
1747
1749
  types.traverseFast(updater.body, (node) => {
1748
- if (types.isCallExpression(node) && types.isIdentifier(node.callee, { name: appendIdentifier.name })) {
1750
+ if (types.isCallExpression(node) && types.isIdentifier(node.callee, { name: appendIdentifier().name })) {
1749
1751
  appendCalls.push(node);
1750
1752
  }
1751
1753
  });
@@ -1754,7 +1756,7 @@ function rewriteQueuedKeyedArrayStructuralMapHints(root, statesBySetter, mapUpda
1754
1756
  structuralAppendState = state.index;
1755
1757
  if (structuralMapState === state.index) {
1756
1758
  for (const call of appendCalls) {
1757
- call.callee = types.cloneNode(mappedStructuralAppendIdentifier);
1759
+ call.callee = types.cloneNode(mappedStructuralAppendIdentifier());
1758
1760
  }
1759
1761
  mappedStructuralAppendCount += appendCalls.length;
1760
1762
  }
@@ -1775,7 +1777,7 @@ function rewriteQueuedKeyedArrayStructuralMapHints(root, statesBySetter, mapUpda
1775
1777
  continue;
1776
1778
  }
1777
1779
  updater.body.callee = types.cloneNode(
1778
- structuralAppendState === state.index ? structuralAppendMapPipelineIdentifier : mapPipelineIdentifier
1780
+ structuralAppendState === state.index ? structuralAppendMapPipelineIdentifier() : mapPipelineIdentifier()
1779
1781
  );
1780
1782
  mapCount += pipelineMapCount;
1781
1783
  if (structuralAppendState === state.index) {
@@ -1817,10 +1819,10 @@ function rewriteQueuedKeyedArrayStructuralPrependMapHints(root, statesBySetter,
1817
1819
  let mapped = false;
1818
1820
  types.traverseFast(statement.argument, (node) => {
1819
1821
  if (!found && types.isCallExpression(node) && types.isIdentifier(node.callee)) {
1820
- if (node.callee.name === filterIdentifier.name) found = "filter";
1821
- if (node.callee.name === sliceIdentifier.name) found = "slice";
1822
+ if (node.callee.name === filterIdentifier().name) found = "filter";
1823
+ if (node.callee.name === sliceIdentifier().name) found = "slice";
1822
1824
  }
1823
- if (!mapped && types.isCallExpression(node) && types.isIdentifier(node.callee, { name: mappedStructuralIdentifier.name })) {
1825
+ if (!mapped && types.isCallExpression(node) && types.isIdentifier(node.callee, { name: mappedStructuralIdentifier().name })) {
1824
1826
  mapped = true;
1825
1827
  }
1826
1828
  });
@@ -1869,7 +1871,7 @@ function rewriteQueuedKeyedArrayStructuralPrependMapHints(root, statesBySetter,
1869
1871
  }
1870
1872
  const prependCalls = [];
1871
1873
  types.traverseFast(updater.body, (node) => {
1872
- if (types.isCallExpression(node) && types.isIdentifier(node.callee, { name: prependIdentifier.name })) {
1874
+ if (types.isCallExpression(node) && types.isIdentifier(node.callee, { name: prependIdentifier().name })) {
1873
1875
  prependCalls.push(node);
1874
1876
  }
1875
1877
  });
@@ -1878,7 +1880,7 @@ function rewriteQueuedKeyedArrayStructuralPrependMapHints(root, statesBySetter,
1878
1880
  structuralPrependState = state.index;
1879
1881
  if (structuralMapState === state.index) {
1880
1882
  for (const call of prependCalls) {
1881
- call.callee = types.cloneNode(mappedStructuralPrependIdentifier);
1883
+ call.callee = types.cloneNode(mappedStructuralPrependIdentifier());
1882
1884
  }
1883
1885
  mappedStructuralPrependCount += prependCalls.length;
1884
1886
  }
@@ -1899,7 +1901,7 @@ function rewriteQueuedKeyedArrayStructuralPrependMapHints(root, statesBySetter,
1899
1901
  continue;
1900
1902
  }
1901
1903
  updater.body.callee = types.cloneNode(
1902
- structuralPrependState === state.index ? structuralPrependMapPipelineIdentifier : mapPipelineIdentifier
1904
+ structuralPrependState === state.index ? structuralPrependMapPipelineIdentifier() : mapPipelineIdentifier()
1903
1905
  );
1904
1906
  mapCount += pipelineMapCount;
1905
1907
  if (structuralPrependState === state.index) {
@@ -1950,7 +1952,7 @@ function rewriteQueuedKeyedArrayRollingWindowMapHints(root, statesBySetter, mapU
1950
1952
  const rollingStep = (updater) => {
1951
1953
  if (!types.isBlockStatement(updater.body)) return void 0;
1952
1954
  const statement = updater.body.body.at(-1);
1953
- if (!types.isReturnStatement(statement) || !statement.argument || !types.isCallExpression(statement.argument) || !types.isIdentifier(statement.argument.callee, { name: rollingWindowIdentifier.name }) || statement.argument.arguments.length !== 3 || !types.isExpression(statement.argument.arguments[1]) || !types.isExpression(statement.argument.arguments[2])) {
1955
+ if (!types.isReturnStatement(statement) || !statement.argument || !types.isCallExpression(statement.argument) || !types.isIdentifier(statement.argument.callee, { name: rollingWindowIdentifier().name }) || statement.argument.arguments.length !== 3 || !types.isExpression(statement.argument.arguments[1]) || !types.isExpression(statement.argument.arguments[2])) {
1954
1956
  return void 0;
1955
1957
  }
1956
1958
  return { call: statement.argument };
@@ -1977,13 +1979,13 @@ function rewriteQueuedKeyedArrayRollingWindowMapHints(root, statesBySetter, mapU
1977
1979
  }
1978
1980
  for (const step of maps) {
1979
1981
  if (step.kind !== "map") continue;
1980
- step.value.updater.body.callee = types.cloneNode(rollingWindowMapPipelineIdentifier);
1982
+ step.value.updater.body.callee = types.cloneNode(rollingWindowMapPipelineIdentifier());
1981
1983
  chainedMapCount += step.value.count;
1982
1984
  }
1983
1985
  for (const index of rollingIndices) {
1984
1986
  const step = segment[index];
1985
1987
  if (step.kind === "rolling") {
1986
- step.value.call.callee = types.cloneNode(mappedRollingWindowIdentifier);
1988
+ step.value.call.callee = types.cloneNode(mappedRollingWindowIdentifier());
1987
1989
  }
1988
1990
  }
1989
1991
  chainedRollingWindowCount += rollingIndices.length;
@@ -2007,10 +2009,10 @@ function rewriteQueuedKeyedArrayRollingWindowMapHints(root, statesBySetter, mapU
2007
2009
  if (!types.isExpression(retained) || !types.isExpression(value)) return;
2008
2010
  const hasLeadingMaps = leadingMaps.length > 0;
2009
2011
  rolling.value.call.callee = types.cloneNode(
2010
- hasLeadingMaps ? mappedStructuralAppendIdentifier : structuralAppendIdentifier
2012
+ hasLeadingMaps ? mappedStructuralAppendIdentifier() : structuralAppendIdentifier()
2011
2013
  );
2012
2014
  rolling.value.call.arguments = [
2013
- hasLeadingMaps ? types.callExpression(types.cloneNode(mappedStructuralIdentifier), [
2015
+ hasLeadingMaps ? types.callExpression(types.cloneNode(mappedStructuralIdentifier()), [
2014
2016
  types.cloneNode(retained, true)
2015
2017
  ]) : types.cloneNode(retained, true),
2016
2018
  types.cloneNode(value, true)
@@ -2020,7 +2022,7 @@ function rewriteQueuedKeyedArrayRollingWindowMapHints(root, statesBySetter, mapU
2020
2022
  mappedRollingWindowCount += 1;
2021
2023
  for (const step of leadingMaps) {
2022
2024
  if (step.kind !== "map") continue;
2023
- step.value.updater.body.callee = types.cloneNode(queuedMapPipelineIdentifier);
2025
+ step.value.updater.body.callee = types.cloneNode(queuedMapPipelineIdentifier());
2024
2026
  leadingMapCount += step.value.count;
2025
2027
  }
2026
2028
  } else {
@@ -2028,7 +2030,7 @@ function rewriteQueuedKeyedArrayRollingWindowMapHints(root, statesBySetter, mapU
2028
2030
  }
2029
2031
  for (const step of trailingMaps) {
2030
2032
  if (step.kind !== "map") continue;
2031
- step.value.updater.body.callee = types.cloneNode(structuralAppendMapPipelineIdentifier);
2033
+ step.value.updater.body.callee = types.cloneNode(structuralAppendMapPipelineIdentifier());
2032
2034
  trailingMapCount += step.value.count;
2033
2035
  }
2034
2036
  segment = [];
@@ -2132,34 +2134,34 @@ function rewriteQueuedKeyedArrayStructuralReorderHints(root, statesBySetter, fil
2132
2134
  types.traverseFast(updater.body, (node) => {
2133
2135
  if (!types.isCallExpression(node) || !types.isIdentifier(node.callee)) return;
2134
2136
  const helperName = node.callee.name;
2135
- if (helperName === filterIdentifier.name || helperName === sliceIdentifier.name || helperName === mappedStructuralIdentifier.name) {
2137
+ if (helperName === filterIdentifier().name || helperName === sliceIdentifier().name || helperName === mappedStructuralIdentifier().name) {
2136
2138
  startsStructuralLineage = true;
2137
2139
  return;
2138
2140
  }
2139
- if (helperName === structuralReorderIdentifier.name || helperName === structuralSortIdentifier.name) {
2141
+ if (helperName === structuralReorderIdentifier().name || helperName === structuralSortIdentifier().name) {
2140
2142
  startsStructuralLineage = true;
2141
2143
  return;
2142
2144
  }
2143
- if (helperName === mapPipelineIdentifier.name) {
2145
+ if (helperName === mapPipelineIdentifier().name) {
2144
2146
  continuesStructuralLineage = true;
2145
2147
  return;
2146
2148
  }
2147
- if (helperName === queuedMapPipelineIdentifier.name) {
2149
+ if (helperName === queuedMapPipelineIdentifier().name) {
2148
2150
  continuesStructuralLineage = true;
2149
2151
  queuedMaps.push(node);
2150
2152
  return;
2151
2153
  }
2152
- if (helperName === reorderIdentifier.name) {
2154
+ if (helperName === reorderIdentifier().name) {
2153
2155
  continuesStructuralLineage = true;
2154
2156
  reorderCalls.push({ call: node, kind: "reverse", mapped: false });
2155
2157
  return;
2156
2158
  }
2157
- if (helperName === sortIdentifier.name) {
2159
+ if (helperName === sortIdentifier().name) {
2158
2160
  continuesStructuralLineage = true;
2159
2161
  reorderCalls.push({ call: node, kind: "sort", mapped: false });
2160
2162
  return;
2161
2163
  }
2162
- if (helperName === mapReorderIdentifier.name) {
2164
+ if (helperName === mapReorderIdentifier().name) {
2163
2165
  const method = node.arguments[1];
2164
2166
  const kind = types.isIdentifier(method) ? methodKinds.get(method.name) : void 0;
2165
2167
  if (!kind) {
@@ -2180,12 +2182,12 @@ function rewriteQueuedKeyedArrayStructuralReorderHints(root, statesBySetter, fil
2180
2182
  continue;
2181
2183
  }
2182
2184
  for (const call of queuedMaps) {
2183
- call.callee = types.cloneNode(mapPipelineIdentifier);
2185
+ call.callee = types.cloneNode(mapPipelineIdentifier());
2184
2186
  replacedQueuedMapCount += 1;
2185
2187
  }
2186
2188
  for (const { call, kind, mapped } of reorderCalls) {
2187
2189
  call.callee = types.cloneNode(
2188
- kind === "reverse" ? structuralReorderIdentifier : structuralSortIdentifier
2190
+ kind === "reverse" ? structuralReorderIdentifier() : structuralSortIdentifier()
2189
2191
  );
2190
2192
  if (kind === "reverse") {
2191
2193
  reorderCount += 1;
@@ -2246,7 +2248,7 @@ function rewriteQueuedKeyedArrayMapReorderHints(root, statesBySetter, mapUpdateI
2246
2248
  pendingMaps = [];
2247
2249
  continue;
2248
2250
  }
2249
- if (types.isCallExpression(updater.body) && types.isIdentifier(updater.body.callee, { name: mapUpdateIdentifier.name }) && updater.body.arguments.length === 2) {
2251
+ if (types.isCallExpression(updater.body) && types.isIdentifier(updater.body.callee, { name: mapUpdateIdentifier().name }) && updater.body.arguments.length === 2) {
2250
2252
  const pipeline = updater.body.arguments[1];
2251
2253
  let pipelineMapCount = 0;
2252
2254
  if (types.isArrowFunctionExpression(pipeline) && pipeline.params.length === 2 && types.isIdentifier(pipeline.params[1])) {
@@ -2273,13 +2275,13 @@ function rewriteQueuedKeyedArrayMapReorderHints(root, statesBySetter, mapUpdateI
2273
2275
  let structural = false;
2274
2276
  types.traverseFast(updater.body, (node) => {
2275
2277
  if (!types.isCallExpression(node) || !types.isIdentifier(node.callee)) return;
2276
- if (node.callee.name === structuralReorderIdentifier.name || node.callee.name === structuralSortIdentifier.name) {
2278
+ if (node.callee.name === structuralReorderIdentifier().name || node.callee.name === structuralSortIdentifier().name) {
2277
2279
  structural = true;
2278
- } else if (node.callee.name === mapReorderIdentifier.name) {
2280
+ } else if (node.callee.name === mapReorderIdentifier().name) {
2279
2281
  containsMappedReorder = true;
2280
- } else if (node.callee.name === reorderIdentifier.name) {
2282
+ } else if (node.callee.name === reorderIdentifier().name) {
2281
2283
  reorderCalls.push({ call: node, kind: "reverse" });
2282
- } else if (node.callee.name === sortIdentifier.name) {
2284
+ } else if (node.callee.name === sortIdentifier().name) {
2283
2285
  reorderCalls.push({ call: node, kind: "sort" });
2284
2286
  }
2285
2287
  });
@@ -2301,12 +2303,12 @@ function rewriteQueuedKeyedArrayMapReorderHints(root, statesBySetter, mapUpdateI
2301
2303
  }
2302
2304
  if (hasPendingMaps) {
2303
2305
  for (const candidate of pendingMaps) {
2304
- candidate.updater.body.callee = types.cloneNode(queuedMapPipelineIdentifier);
2306
+ candidate.updater.body.callee = types.cloneNode(queuedMapPipelineIdentifier());
2305
2307
  mapCount += candidate.count;
2306
2308
  }
2307
2309
  }
2308
2310
  for (const { call, kind } of reorderCalls) {
2309
- call.callee = types.cloneNode(mapReorderIdentifier);
2311
+ call.callee = types.cloneNode(mapReorderIdentifier());
2310
2312
  if (kind === "reverse") mapReorderCount += 1;
2311
2313
  else mapSortCount += 1;
2312
2314
  }
@@ -2363,7 +2365,7 @@ function rewriteKeyedArraySortHints(root, hintedStateIndices, statesBySetter, he
2363
2365
  )
2364
2366
  ]),
2365
2367
  types.returnStatement(
2366
- types.callExpression(types.cloneNode(helperIdentifier), [
2368
+ types.callExpression(types.cloneNode(helperIdentifier()), [
2367
2369
  types.cloneNode(previous),
2368
2370
  types.cloneNode(method),
2369
2371
  ...comparator ? [types.cloneNode(comparator, true)] : []
@@ -2425,7 +2427,7 @@ function rewriteKeyedArraySliceHints(root, hintedStateIndices, statesBySetter, h
2425
2427
  )
2426
2428
  ]),
2427
2429
  types.returnStatement(
2428
- types.callExpression(types.cloneNode(helperIdentifier), [
2430
+ types.callExpression(types.cloneNode(helperIdentifier()), [
2429
2431
  types.cloneNode(previous),
2430
2432
  types.cloneNode(sliceMethod),
2431
2433
  ...bounds.map((bound) => types.cloneNode(bound, true))
@@ -2487,7 +2489,7 @@ function rewriteKeyedArrayFilterHints(root, hintedStateIndices, statesBySetter,
2487
2489
  )
2488
2490
  ]),
2489
2491
  types.returnStatement(
2490
- types.callExpression(types.cloneNode(helperIdentifier), [
2492
+ types.callExpression(types.cloneNode(helperIdentifier()), [
2491
2493
  types.cloneNode(previous),
2492
2494
  types.cloneNode(filterMethod),
2493
2495
  types.cloneNode(predicate, true)
@@ -2592,9 +2594,9 @@ function prepareKeyedCollectionUpdater(updater, kind, updateHelper, mutationHelp
2592
2594
  )
2593
2595
  ]),
2594
2596
  types.returnStatement(
2595
- types.callExpression(types.cloneNode(updateHelper), [
2597
+ types.callExpression(types.cloneNode(updateHelper()), [
2596
2598
  types.cloneNode(previous),
2597
- types.callExpression(types.cloneNode(mutationHelper), [
2599
+ types.callExpression(types.cloneNode(mutationHelper()), [
2598
2600
  types.cloneNode(collection),
2599
2601
  types.memberExpression(types.cloneNode(collection), types.cloneNode(updater.body.callee.property)),
2600
2602
  types.stringLiteral(operation),
@@ -2729,7 +2731,7 @@ function prepareKeyedCollectionUpdater(updater, kind, updateHelper, mutationHelp
2729
2731
  const operation = collectionMutationOperation(kind, callee.property.name);
2730
2732
  if (!collectionMutationArgumentsAreValid(operation, path.node.arguments)) return;
2731
2733
  path.replaceWith(
2732
- types.callExpression(types.cloneNode(mutationHelper), [
2734
+ types.callExpression(types.cloneNode(mutationHelper()), [
2733
2735
  types.cloneNode(callee.object),
2734
2736
  types.memberExpression(types.cloneNode(callee.object), types.cloneNode(callee.property)),
2735
2737
  types.stringLiteral(operation),
@@ -2740,7 +2742,7 @@ function prepareKeyedCollectionUpdater(updater, kind, updateHelper, mutationHelp
2740
2742
  },
2741
2743
  ReturnStatement(path) {
2742
2744
  if (path.getFunctionParent()?.node !== functionPath?.node || !path.node.argument) return;
2743
- path.node.argument = types.callExpression(types.cloneNode(updateHelper), [
2745
+ path.node.argument = types.callExpression(types.cloneNode(updateHelper()), [
2744
2746
  types.cloneNode(clonedPrevious),
2745
2747
  types.cloneNode(path.node.argument, true),
2746
2748
  types.stringLiteral(kind)
@@ -3286,7 +3288,6 @@ function stabilizeDeferredEventCurrentTargets(root, compilerSetters) {
3286
3288
  const expression = file.program.body[0].expression;
3287
3289
  return types.isJSXElement(expression) ? expression : types.cloneNode(root, true);
3288
3290
  }
3289
- var foreignContentElements = /* @__PURE__ */ new WeakSet();
3290
3291
  var FOREIGN_ELEMENT_NAMES = new Set(
3291
3292
  [
3292
3293
  "animate animateMotion animateTransform circle clipPath defs desc ellipse",
@@ -3303,21 +3304,24 @@ var FOREIGN_ELEMENT_NAMES = new Set(
3303
3304
  ].join(" ").split(" ")
3304
3305
  );
3305
3306
  function markForeignContent(programPath) {
3307
+ let depth = 0;
3306
3308
  programPath.traverse({
3307
- JSXElement(path) {
3308
- const name = path.node.openingElement.name;
3309
- if (!types.isJSXIdentifier(name) || name.name !== "svg" && name.name !== "math") return;
3310
- path.traverse({
3311
- JSXElement(inner) {
3312
- foreignContentElements.add(inner.node);
3313
- }
3314
- });
3309
+ JSXElement: {
3310
+ enter(path) {
3311
+ if (depth > 0) path.node.extra = { ...path.node.extra, farmForeignContent: true };
3312
+ const name = path.node.openingElement.name;
3313
+ if (types.isJSXIdentifier(name) && (name.name === "svg" || name.name === "math")) depth++;
3314
+ },
3315
+ exit(path) {
3316
+ const name = path.node.openingElement.name;
3317
+ if (types.isJSXIdentifier(name) && (name.name === "svg" || name.name === "math")) depth--;
3318
+ }
3315
3319
  }
3316
3320
  });
3317
3321
  }
3318
3322
  function isForeignContent(element) {
3319
3323
  const name = element.openingElement.name;
3320
- return foreignContentElements.has(element) || types.isJSXIdentifier(name) && FOREIGN_ELEMENT_NAMES.has(name.name);
3324
+ return element.extra?.farmForeignContent === true || types.isJSXIdentifier(name) && FOREIGN_ELEMENT_NAMES.has(name.name);
3321
3325
  }
3322
3326
  function reactOwnedAttribute(name, attribute) {
3323
3327
  if (name === "defaultValue" || name === "defaultChecked") return true;
@@ -3343,6 +3347,10 @@ function analyzeKeyedRowTree(row, renderCallback, safeGlobals, compilerSetters,
3343
3347
  return "compiled keyed rows support host elements only";
3344
3348
  }
3345
3349
  if (isForeignContent(element)) return "compiled keyed rows do not support SVG yet";
3350
+ if (tag.name === "script") return "script elements require React ownership";
3351
+ if (tag.name === "title" || tag.name === "meta") {
3352
+ return "document metadata requires React ownership";
3353
+ }
3346
3354
  const attributeNames = new Set(
3347
3355
  element.openingElement.attributes.filter((attribute) => types.isJSXAttribute(attribute)).map(jsxAttributeName).filter((name) => name !== void 0)
3348
3356
  );
@@ -3741,6 +3749,10 @@ function analyzeHostConditionalTree(branch, safeGlobals, allowStaticEvents = fal
3741
3749
  return "compiler-owned conditionals support host elements only";
3742
3750
  }
3743
3751
  if (isForeignContent(element)) return "compiler-owned conditionals do not support SVG yet";
3752
+ if (tag.name === "script") return "script elements require React ownership";
3753
+ if (tag.name === "title" || tag.name === "meta") {
3754
+ return "document metadata requires React ownership";
3755
+ }
3744
3756
  for (const attribute of element.openingElement.attributes) {
3745
3757
  if (types.isJSXSpreadAttribute(attribute)) {
3746
3758
  if (statefulOnly && !needsStaticBinding(attribute.argument)) continue;
@@ -3866,6 +3878,10 @@ function analyzeRecursiveHostTree(branch, statesByValue, safeGlobals, listNames,
3866
3878
  if (isForeignContent(element)) {
3867
3879
  return "recursive compiler-owned blocks do not support SVG yet";
3868
3880
  }
3881
+ if (tag.name === "script") return "script elements require React ownership";
3882
+ if (tag.name === "title" || tag.name === "meta") {
3883
+ return "document metadata requires React ownership";
3884
+ }
3869
3885
  for (const attribute of element.openingElement.attributes) {
3870
3886
  if (types.isJSXSpreadAttribute(attribute)) {
3871
3887
  return "recursive compiler-owned blocks do not support JSX attribute spreads";
@@ -6152,7 +6168,13 @@ function analyzeHostTree(root, statesByValue, safeGlobals, conditionalExpression
6152
6168
  }
6153
6169
  const expression = attribute.value.expression;
6154
6170
  const dependencies = collectStateDependencies(expression, statesByValue);
6155
- if (dependencies.length === 0 || /^on[A-Z]/.test(name)) continue;
6171
+ if (dependencies.length === 0) continue;
6172
+ if (/^on[A-Z]/.test(name)) {
6173
+ if (!types.isArrowFunctionExpression(expression) && !types.isFunctionExpression(expression)) {
6174
+ return "stateful event handler selection requires React ownership";
6175
+ }
6176
+ continue;
6177
+ }
6156
6178
  if (name === "style") {
6157
6179
  const reason2 = analyzeStyle(expression, path);
6158
6180
  if (reason2) return reason2;
@@ -7378,6 +7400,14 @@ function compileCandidate(candidate, createComponentIdentifier, keyedMapUpdateId
7378
7400
  appliedKeyedMapUpdateHints > 0 || appliedKeyedArrayAppendHints > 0,
7379
7401
  appliedKeyedArrayAppendHints > 0 && appliedKeyedMapUpdateHints === 0
7380
7402
  );
7403
+ for (const feature of runtimeFeatures) {
7404
+ if (!runtimeFeatureIdentifiers.has(feature)) {
7405
+ runtimeFeatureIdentifiers.set(
7406
+ feature,
7407
+ path.scope.getProgramParent().generateUidIdentifier(COMPILER_RUNTIME_FEATURE_EXPORTS[feature])
7408
+ );
7409
+ }
7410
+ }
7381
7411
  markShortCircuitBindings(analysis.bindings || []);
7382
7412
  assignStableBindingTargets(analysis.bindings || []);
7383
7413
  const stateParameter = path.scope.generateUidIdentifier("farmState");
@@ -7506,8 +7536,17 @@ function compileCandidate(candidate, createComponentIdentifier, keyedMapUpdateId
7506
7536
  for (const feature of runtimeFeatures) usedRuntimeFeatures.add(feature);
7507
7537
  return void 0;
7508
7538
  }
7509
- function collectCandidates(programPath) {
7539
+ function collectCandidates(programPath, options, moduleSelected) {
7510
7540
  const candidates = [];
7541
+ function collect(name, path, statementPath) {
7542
+ const functionDirectives = new Set(
7543
+ types.isBlockStatement(path.node.body) ? directiveValues(path.node.body) : []
7544
+ );
7545
+ const explicitlySelected = moduleSelected || functionDirectives.has(options.directive);
7546
+ if (functionDirectives.has("use no compiler")) return;
7547
+ if (options.mode === "annotation" && !explicitlySelected) return;
7548
+ candidates.push({ name, path, statementPath, explicitlySelected });
7549
+ }
7511
7550
  programPath.traverse({
7512
7551
  FunctionDeclaration(path) {
7513
7552
  if (!path.node.id || !isComponentName(path.node.id.name)) return;
@@ -7515,11 +7554,7 @@ function collectCandidates(programPath) {
7515
7554
  if (!parent.isProgram() && !parent.isExportNamedDeclaration() && !parent.isExportDefaultDeclaration()) {
7516
7555
  return;
7517
7556
  }
7518
- candidates.push({
7519
- name: path.node.id.name,
7520
- path,
7521
- statementPath: parent.isProgram() ? path : parent
7522
- });
7557
+ collect(path.node.id.name, path, parent.isProgram() ? path : parent);
7523
7558
  },
7524
7559
  VariableDeclarator(path) {
7525
7560
  if (!types.isIdentifier(path.node.id) || !isComponentName(path.node.id.name) || !types.isFunctionExpression(path.node.init) && !types.isArrowFunctionExpression(path.node.init)) {
@@ -7530,11 +7565,7 @@ function collectCandidates(programPath) {
7530
7565
  if (!statement) return;
7531
7566
  const topLevel = statement.isProgram() ? declaration : statement.isExportNamedDeclaration() && statement.parentPath.isProgram() ? statement : null;
7532
7567
  if (!topLevel) return;
7533
- candidates.push({
7534
- name: path.node.id.name,
7535
- path: path.get("init"),
7536
- statementPath: topLevel
7537
- });
7568
+ collect(path.node.id.name, path.get("init"), topLevel);
7538
7569
  }
7539
7570
  });
7540
7571
  return candidates;
@@ -7604,97 +7635,85 @@ async function compileReactModule(code, id, options) {
7604
7635
  }
7605
7636
  }
7606
7637
  }
7607
- const candidates = collectCandidates(programPath);
7608
- const createComponentIdentifier = programPath.scope.generateUidIdentifier("createCompiledComponent");
7609
- const keyedMapUpdateIdentifier = programPath.scope.generateUidIdentifier(
7610
- "createCompilerKeyedMapUpdate"
7611
- );
7612
- const keyedArrayAppendIdentifier = programPath.scope.generateUidIdentifier(
7613
- "createCompilerKeyedArrayAppend"
7638
+ const candidates = collectCandidates(
7639
+ programPath,
7640
+ options,
7641
+ moduleDirectives.has(options.directive)
7614
7642
  );
7615
- const keyedArrayFilterIdentifier = programPath.scope.generateUidIdentifier(
7616
- "createCompilerKeyedArrayFilter"
7643
+ if (candidates.length === 0) return;
7644
+ const createComponentIdentifier = programPath.scope.generateUidIdentifier("createCompiledComponent");
7645
+ const createRefreshComponentIdentifier = programPath.scope.generateUidIdentifier("createRefreshComponent");
7646
+ const createProductionComponentIdentifier = programPath.scope.generateUidIdentifier(
7647
+ "createProductionComponent"
7617
7648
  );
7618
- const keyedArrayMapPipelineIdentifier = programPath.scope.generateUidIdentifier(
7649
+ const helperIdentifier = (name) => {
7650
+ let identifier;
7651
+ return () => identifier ?? (identifier = programPath.scope.generateUidIdentifier(name));
7652
+ };
7653
+ const keyedMapUpdateIdentifier = helperIdentifier("createCompilerKeyedMapUpdate");
7654
+ const keyedArrayAppendIdentifier = helperIdentifier("createCompilerKeyedArrayAppend");
7655
+ const keyedArrayFilterIdentifier = helperIdentifier("createCompilerKeyedArrayFilter");
7656
+ const keyedArrayMapPipelineIdentifier = helperIdentifier(
7619
7657
  "createCompilerKeyedArrayMapPipeline"
7620
7658
  );
7621
- const keyedArrayMappedStructuralAppendIdentifier = programPath.scope.generateUidIdentifier(
7659
+ const keyedArrayMappedStructuralAppendIdentifier = helperIdentifier(
7622
7660
  "createCompilerKeyedArrayMappedStructuralAppend"
7623
7661
  );
7624
- const keyedArrayStructuralAppendMapPipelineIdentifier = programPath.scope.generateUidIdentifier(
7662
+ const keyedArrayStructuralAppendMapPipelineIdentifier = helperIdentifier(
7625
7663
  "createCompilerKeyedArrayStructuralAppendMapPipeline"
7626
7664
  );
7627
- const keyedArrayMappedStructuralPrependIdentifier = programPath.scope.generateUidIdentifier(
7665
+ const keyedArrayMappedStructuralPrependIdentifier = helperIdentifier(
7628
7666
  "createCompilerKeyedArrayMappedStructuralPrepend"
7629
7667
  );
7630
- const keyedArrayStructuralPrependMapPipelineIdentifier = programPath.scope.generateUidIdentifier(
7668
+ const keyedArrayStructuralPrependMapPipelineIdentifier = helperIdentifier(
7631
7669
  "createCompilerKeyedArrayStructuralPrependMapPipeline"
7632
7670
  );
7633
- const keyedArrayQueuedMapPipelineIdentifier = programPath.scope.generateUidIdentifier(
7671
+ const keyedArrayQueuedMapPipelineIdentifier = helperIdentifier(
7634
7672
  "createCompilerKeyedArrayQueuedMapPipeline"
7635
7673
  );
7636
- const keyedArrayRollingWindowMapPipelineIdentifier = programPath.scope.generateUidIdentifier(
7674
+ const keyedArrayRollingWindowMapPipelineIdentifier = helperIdentifier(
7637
7675
  "createCompilerKeyedArrayRollingWindowMapPipeline"
7638
7676
  );
7639
- const keyedArrayMappedRollingWindowIdentifier = programPath.scope.generateUidIdentifier(
7677
+ const keyedArrayMappedRollingWindowIdentifier = helperIdentifier(
7640
7678
  "createCompilerKeyedArrayMappedRollingWindow"
7641
7679
  );
7642
- const keyedArrayMapReorderIdentifier = programPath.scope.generateUidIdentifier(
7680
+ const keyedArrayMapReorderIdentifier = helperIdentifier(
7643
7681
  "createCompilerKeyedArrayMapReorder"
7644
7682
  );
7645
- const keyedArrayMappedStructuralIdentifier = programPath.scope.generateUidIdentifier(
7683
+ const keyedArrayMappedStructuralIdentifier = helperIdentifier(
7646
7684
  "finalizeCompilerKeyedArrayMappedStructuralUpdate"
7647
7685
  );
7648
- const keyedArrayPrependIdentifier = programPath.scope.generateUidIdentifier(
7649
- "createCompilerKeyedArrayPrepend"
7650
- );
7651
- const keyedArrayPositionIdentifier = programPath.scope.generateUidIdentifier(
7686
+ const keyedArrayPrependIdentifier = helperIdentifier("createCompilerKeyedArrayPrepend");
7687
+ const keyedArrayPositionIdentifier = helperIdentifier(
7652
7688
  "createCompilerKeyedArrayPositionUpdate"
7653
7689
  );
7654
- const keyedArrayBatchInsertIdentifier = programPath.scope.generateUidIdentifier(
7690
+ const keyedArrayBatchInsertIdentifier = helperIdentifier(
7655
7691
  "createCompilerKeyedArrayBatchInsert"
7656
7692
  );
7657
- const keyedArrayWindowReplaceIdentifier = programPath.scope.generateUidIdentifier(
7693
+ const keyedArrayWindowReplaceIdentifier = helperIdentifier(
7658
7694
  "createCompilerKeyedArrayWindowReplace"
7659
7695
  );
7660
- const keyedArrayReorderIdentifier = programPath.scope.generateUidIdentifier(
7661
- "createCompilerKeyedArrayReorder"
7662
- );
7663
- const keyedArrayStructuralReorderIdentifier = programPath.scope.generateUidIdentifier(
7696
+ const keyedArrayReorderIdentifier = helperIdentifier("createCompilerKeyedArrayReorder");
7697
+ const keyedArrayStructuralReorderIdentifier = helperIdentifier(
7664
7698
  "createCompilerKeyedArrayStructuralReorder"
7665
7699
  );
7666
- const keyedArraySortIdentifier = programPath.scope.generateUidIdentifier(
7667
- "createCompilerKeyedArraySort"
7668
- );
7669
- const keyedArrayStructuralSortIdentifier = programPath.scope.generateUidIdentifier(
7700
+ const keyedArraySortIdentifier = helperIdentifier("createCompilerKeyedArraySort");
7701
+ const keyedArrayStructuralSortIdentifier = helperIdentifier(
7670
7702
  "createCompilerKeyedArrayStructuralSort"
7671
7703
  );
7672
- const keyedArrayRollingWindowIdentifier = programPath.scope.generateUidIdentifier(
7704
+ const keyedArrayRollingWindowIdentifier = helperIdentifier(
7673
7705
  "createCompilerKeyedArrayRollingWindow"
7674
7706
  );
7675
- const keyedArraySliceIdentifier = programPath.scope.generateUidIdentifier(
7676
- "createCompilerKeyedArraySlice"
7677
- );
7678
- const keyedCollectionUpdateIdentifier = programPath.scope.generateUidIdentifier(
7707
+ const keyedArraySliceIdentifier = helperIdentifier("createCompilerKeyedArraySlice");
7708
+ const keyedCollectionUpdateIdentifier = helperIdentifier(
7679
7709
  "createCompilerKeyedCollectionUpdate"
7680
7710
  );
7681
- const keyedCollectionMutationIdentifier = programPath.scope.generateUidIdentifier(
7711
+ const keyedCollectionMutationIdentifier = helperIdentifier(
7682
7712
  "applyCompilerKeyedCollectionMutation"
7683
7713
  );
7684
- const runtimeFeatureIdentifiers = new Map(
7685
- Object.entries(COMPILER_RUNTIME_FEATURE_EXPORTS).map(([feature, exportName]) => [
7686
- feature,
7687
- programPath.scope.generateUidIdentifier(exportName)
7688
- ])
7689
- );
7714
+ const runtimeFeatureIdentifiers = /* @__PURE__ */ new Map();
7690
7715
  const usedRuntimeFeatures = /* @__PURE__ */ new Set();
7691
7716
  for (const candidate of candidates) {
7692
- const functionDirectives = new Set(
7693
- types.isBlockStatement(candidate.path.node.body) ? directiveValues(candidate.path.node.body) : []
7694
- );
7695
- const explicitlySelected = moduleDirectives.has(options.directive) || functionDirectives.has(options.directive);
7696
- if (functionDirectives.has("use no compiler")) continue;
7697
- if (options.mode === "annotation" && !explicitlySelected) continue;
7698
7717
  const reason = compileCandidate(
7699
7718
  candidate,
7700
7719
  createComponentIdentifier,
@@ -7737,7 +7756,7 @@ async function compileReactModule(code, id, options) {
7737
7756
  diagnostics.push({
7738
7757
  component: candidate.name,
7739
7758
  reason,
7740
- selected: explicitlySelected
7759
+ selected: candidate.explicitlySelected
7741
7760
  });
7742
7761
  } else {
7743
7762
  compiled.push(candidate.name);
@@ -7750,83 +7769,103 @@ async function compileReactModule(code, id, options) {
7750
7769
  const hasKeyedArrayStructuralPrependHints = optimizationCounts.keyedArrayPrependHints > 0 && (optimizationCounts.keyedArrayFilterHints > 0 || optimizationCounts.keyedArraySliceHints > 0);
7751
7770
  const hasUnmappedKeyedArrayPrependHints = optimizationCounts.keyedArrayPrependHints > compilerUsage.keyedArrayMappedStructuralPrependHints;
7752
7771
  if (compiled.length > 0) {
7772
+ programPath.unshiftContainer(
7773
+ "body",
7774
+ types.variableDeclaration("const", [
7775
+ types.variableDeclarator(
7776
+ types.cloneNode(createComponentIdentifier),
7777
+ types.conditionalExpression(
7778
+ types.memberExpression(
7779
+ types.metaProperty(types.identifier("import"), types.identifier("meta")),
7780
+ types.identifier("hot")
7781
+ ),
7782
+ types.cloneNode(createRefreshComponentIdentifier),
7783
+ types.cloneNode(createProductionComponentIdentifier)
7784
+ )
7785
+ )
7786
+ ])
7787
+ );
7753
7788
  programPath.unshiftContainer(
7754
7789
  "body",
7755
7790
  types.importDeclaration(
7756
7791
  [
7757
7792
  types.importSpecifier(
7758
- createComponentIdentifier,
7793
+ createRefreshComponentIdentifier,
7759
7794
  types.identifier("createCompiledComponentWithFeatures")
7760
7795
  ),
7796
+ types.importSpecifier(
7797
+ createProductionComponentIdentifier,
7798
+ types.identifier("createCompiledComponentWithoutRefresh")
7799
+ ),
7761
7800
  ...optimizationCounts.keyedMapUpdateHints > compilerUsage.keyedArrayMapUpdateHints ? [
7762
7801
  types.importSpecifier(
7763
- keyedMapUpdateIdentifier,
7802
+ keyedMapUpdateIdentifier(),
7764
7803
  types.identifier("createCompilerKeyedMapUpdate")
7765
7804
  )
7766
7805
  ] : [],
7767
7806
  ...hasEagerKeyedArrayMapUpdateHints ? [
7768
7807
  types.importSpecifier(
7769
- keyedArrayMapPipelineIdentifier,
7808
+ keyedArrayMapPipelineIdentifier(),
7770
7809
  types.identifier("createCompilerKeyedArrayMapPipeline")
7771
7810
  )
7772
7811
  ] : [],
7773
7812
  ...compilerUsage.keyedArrayStructuralAppendMapHints > 0 ? [
7774
7813
  types.importSpecifier(
7775
- keyedArrayStructuralAppendMapPipelineIdentifier,
7814
+ keyedArrayStructuralAppendMapPipelineIdentifier(),
7776
7815
  types.identifier("createCompilerKeyedArrayStructuralAppendMapPipeline")
7777
7816
  )
7778
7817
  ] : [],
7779
7818
  ...compilerUsage.keyedArrayStructuralPrependMapHints > 0 ? [
7780
7819
  types.importSpecifier(
7781
- keyedArrayStructuralPrependMapPipelineIdentifier,
7820
+ keyedArrayStructuralPrependMapPipelineIdentifier(),
7782
7821
  types.identifier("createCompilerKeyedArrayStructuralPrependMapPipeline")
7783
7822
  )
7784
7823
  ] : [],
7785
7824
  ...hasKeyedArrayMapReorderHints ? [
7786
7825
  types.importSpecifier(
7787
- keyedArrayMapReorderIdentifier,
7826
+ keyedArrayMapReorderIdentifier(),
7788
7827
  types.identifier("createCompilerKeyedArrayMapReorder")
7789
7828
  )
7790
7829
  ] : [],
7791
7830
  ...compilerUsage.keyedArrayMappedStructuralHints > 0 ? [
7792
7831
  types.importSpecifier(
7793
- keyedArrayMappedStructuralIdentifier,
7832
+ keyedArrayMappedStructuralIdentifier(),
7794
7833
  types.identifier("finalizeCompilerKeyedArrayMappedStructuralUpdate")
7795
7834
  )
7796
7835
  ] : [],
7797
7836
  ...compilerUsage.keyedArrayMappedStructuralAppendHints > 0 || compilerUsage.keyedArrayMappedRollingWindowHints > compilerUsage.keyedArrayMappedRollingWindowChainHints ? [
7798
7837
  types.importSpecifier(
7799
- keyedArrayMappedStructuralAppendIdentifier,
7838
+ keyedArrayMappedStructuralAppendIdentifier(),
7800
7839
  types.identifier("createCompilerKeyedArrayMappedStructuralAppend")
7801
7840
  )
7802
7841
  ] : [],
7803
7842
  ...compilerUsage.keyedArrayMappedStructuralPrependHints > 0 ? [
7804
7843
  types.importSpecifier(
7805
- keyedArrayMappedStructuralPrependIdentifier,
7844
+ keyedArrayMappedStructuralPrependIdentifier(),
7806
7845
  types.identifier("createCompilerKeyedArrayMappedStructuralPrepend")
7807
7846
  )
7808
7847
  ] : [],
7809
7848
  ...compilerUsage.keyedArrayQueuedMapUpdateHints > 0 ? [
7810
7849
  types.importSpecifier(
7811
- keyedArrayQueuedMapPipelineIdentifier,
7850
+ keyedArrayQueuedMapPipelineIdentifier(),
7812
7851
  types.identifier("createCompilerKeyedArrayQueuedMapPipeline")
7813
7852
  )
7814
7853
  ] : [],
7815
7854
  ...compilerUsage.keyedArrayMappedRollingWindowChainHints > 0 ? [
7816
7855
  types.importSpecifier(
7817
- keyedArrayRollingWindowMapPipelineIdentifier,
7856
+ keyedArrayRollingWindowMapPipelineIdentifier(),
7818
7857
  types.identifier("createCompilerKeyedArrayRollingWindowMapPipeline")
7819
7858
  )
7820
7859
  ] : [],
7821
7860
  ...compilerUsage.keyedArrayMappedRollingWindowChainHints > 0 ? [
7822
7861
  types.importSpecifier(
7823
- keyedArrayMappedRollingWindowIdentifier,
7862
+ keyedArrayMappedRollingWindowIdentifier(),
7824
7863
  types.identifier("createCompilerKeyedArrayMappedRollingWindow")
7825
7864
  )
7826
7865
  ] : [],
7827
7866
  ...hasUnmappedKeyedArrayAppendHints || compilerUsage.keyedArrayStructuralRollingWindowHints > 0 ? [
7828
7867
  types.importSpecifier(
7829
- keyedArrayAppendIdentifier,
7868
+ keyedArrayAppendIdentifier(),
7830
7869
  types.identifier(
7831
7870
  hasKeyedArrayStructuralAppendHints ? "createCompilerKeyedArrayStructuralAppend" : "createCompilerKeyedArrayAppend"
7832
7871
  )
@@ -7834,13 +7873,13 @@ async function compileReactModule(code, id, options) {
7834
7873
  ] : [],
7835
7874
  ...optimizationCounts.keyedArrayFilterHints > 0 ? [
7836
7875
  types.importSpecifier(
7837
- keyedArrayFilterIdentifier,
7876
+ keyedArrayFilterIdentifier(),
7838
7877
  types.identifier("createCompilerKeyedArrayFilter")
7839
7878
  )
7840
7879
  ] : [],
7841
7880
  ...hasUnmappedKeyedArrayPrependHints ? [
7842
7881
  types.importSpecifier(
7843
- keyedArrayPrependIdentifier,
7882
+ keyedArrayPrependIdentifier(),
7844
7883
  types.identifier(
7845
7884
  hasKeyedArrayStructuralPrependHints ? "createCompilerKeyedArrayStructuralPrepend" : "createCompilerKeyedArrayPrepend"
7846
7885
  )
@@ -7848,65 +7887,65 @@ async function compileReactModule(code, id, options) {
7848
7887
  ] : [],
7849
7888
  ...optimizationCounts.keyedArrayPositionHints > compilerUsage.keyedArrayBatchInsertHints + compilerUsage.keyedArrayWindowReplaceHints ? [
7850
7889
  types.importSpecifier(
7851
- keyedArrayPositionIdentifier,
7890
+ keyedArrayPositionIdentifier(),
7852
7891
  types.identifier("createCompilerKeyedArrayPositionUpdate")
7853
7892
  )
7854
7893
  ] : [],
7855
7894
  ...compilerUsage.keyedArrayBatchInsertHints > 0 ? [
7856
7895
  types.importSpecifier(
7857
- keyedArrayBatchInsertIdentifier,
7896
+ keyedArrayBatchInsertIdentifier(),
7858
7897
  types.identifier("createCompilerKeyedArrayBatchInsert")
7859
7898
  )
7860
7899
  ] : [],
7861
7900
  ...compilerUsage.keyedArrayWindowReplaceHints > 0 ? [
7862
7901
  types.importSpecifier(
7863
- keyedArrayWindowReplaceIdentifier,
7902
+ keyedArrayWindowReplaceIdentifier(),
7864
7903
  types.identifier("createCompilerKeyedArrayWindowReplace")
7865
7904
  )
7866
7905
  ] : [],
7867
7906
  ...optimizationCounts.keyedArrayReorderHints > compilerUsage.keyedArrayStructuralReorderHints + compilerUsage.keyedArrayMapReorderHints ? [
7868
7907
  types.importSpecifier(
7869
- keyedArrayReorderIdentifier,
7908
+ keyedArrayReorderIdentifier(),
7870
7909
  types.identifier("createCompilerKeyedArrayReorder")
7871
7910
  )
7872
7911
  ] : [],
7873
7912
  ...compilerUsage.keyedArrayStructuralReorderHints > 0 ? [
7874
7913
  types.importSpecifier(
7875
- keyedArrayStructuralReorderIdentifier,
7914
+ keyedArrayStructuralReorderIdentifier(),
7876
7915
  types.identifier("createCompilerKeyedArrayStructuralReorder")
7877
7916
  )
7878
7917
  ] : [],
7879
7918
  ...optimizationCounts.keyedArraySortHints > compilerUsage.keyedArrayStructuralSortHints + compilerUsage.keyedArrayMapSortHints ? [
7880
7919
  types.importSpecifier(
7881
- keyedArraySortIdentifier,
7920
+ keyedArraySortIdentifier(),
7882
7921
  types.identifier("createCompilerKeyedArraySort")
7883
7922
  )
7884
7923
  ] : [],
7885
7924
  ...compilerUsage.keyedArrayStructuralSortHints > 0 ? [
7886
7925
  types.importSpecifier(
7887
- keyedArrayStructuralSortIdentifier,
7926
+ keyedArrayStructuralSortIdentifier(),
7888
7927
  types.identifier("createCompilerKeyedArrayStructuralSort")
7889
7928
  )
7890
7929
  ] : [],
7891
7930
  ...optimizationCounts.keyedArrayRollingWindowHints > compilerUsage.keyedArrayMappedRollingWindowHints + compilerUsage.keyedArrayStructuralRollingWindowHints ? [
7892
7931
  types.importSpecifier(
7893
- keyedArrayRollingWindowIdentifier,
7932
+ keyedArrayRollingWindowIdentifier(),
7894
7933
  types.identifier("createCompilerKeyedArrayRollingWindow")
7895
7934
  )
7896
7935
  ] : [],
7897
7936
  ...optimizationCounts.keyedArraySliceHints > 0 || optimizationCounts.keyedArrayRollingWindowHints > 0 ? [
7898
7937
  types.importSpecifier(
7899
- keyedArraySliceIdentifier,
7938
+ keyedArraySliceIdentifier(),
7900
7939
  types.identifier("createCompilerKeyedArraySlice")
7901
7940
  )
7902
7941
  ] : [],
7903
7942
  ...optimizationCounts.keyedCollectionUpdateHints > 0 ? [
7904
7943
  types.importSpecifier(
7905
- keyedCollectionUpdateIdentifier,
7944
+ keyedCollectionUpdateIdentifier(),
7906
7945
  types.identifier("createCompilerKeyedCollectionUpdate")
7907
7946
  ),
7908
7947
  types.importSpecifier(
7909
- keyedCollectionMutationIdentifier,
7948
+ keyedCollectionMutationIdentifier(),
7910
7949
  types.identifier("applyCompilerKeyedCollectionMutation")
7911
7950
  )
7912
7951
  ] : [],