@farm.js/react 0.1.0-beta.36 → 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/README.md +28 -0
- package/dist/compiler-runtime.cjs +90 -106
- package/dist/compiler-runtime.cjs.map +1 -1
- package/dist/compiler-runtime.mjs +90 -106
- package/dist/compiler-runtime.mjs.map +1 -1
- package/dist/vite.cjs +168 -155
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.mjs +168 -155
- package/dist/vite.mjs.map +1 -1
- package/package.json +3 -3
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), [
|
|
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)
|
|
@@ -3345,6 +3347,10 @@ function analyzeKeyedRowTree(row, renderCallback, safeGlobals, compilerSetters,
|
|
|
3345
3347
|
return "compiled keyed rows support host elements only";
|
|
3346
3348
|
}
|
|
3347
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
|
+
}
|
|
3348
3354
|
const attributeNames = new Set(
|
|
3349
3355
|
element.openingElement.attributes.filter((attribute) => types.isJSXAttribute(attribute)).map(jsxAttributeName).filter((name) => name !== void 0)
|
|
3350
3356
|
);
|
|
@@ -3743,6 +3749,10 @@ function analyzeHostConditionalTree(branch, safeGlobals, allowStaticEvents = fal
|
|
|
3743
3749
|
return "compiler-owned conditionals support host elements only";
|
|
3744
3750
|
}
|
|
3745
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
|
+
}
|
|
3746
3756
|
for (const attribute of element.openingElement.attributes) {
|
|
3747
3757
|
if (types.isJSXSpreadAttribute(attribute)) {
|
|
3748
3758
|
if (statefulOnly && !needsStaticBinding(attribute.argument)) continue;
|
|
@@ -3868,6 +3878,10 @@ function analyzeRecursiveHostTree(branch, statesByValue, safeGlobals, listNames,
|
|
|
3868
3878
|
if (isForeignContent(element)) {
|
|
3869
3879
|
return "recursive compiler-owned blocks do not support SVG yet";
|
|
3870
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
|
+
}
|
|
3871
3885
|
for (const attribute of element.openingElement.attributes) {
|
|
3872
3886
|
if (types.isJSXSpreadAttribute(attribute)) {
|
|
3873
3887
|
return "recursive compiler-owned blocks do not support JSX attribute spreads";
|
|
@@ -6154,7 +6168,13 @@ function analyzeHostTree(root, statesByValue, safeGlobals, conditionalExpression
|
|
|
6154
6168
|
}
|
|
6155
6169
|
const expression = attribute.value.expression;
|
|
6156
6170
|
const dependencies = collectStateDependencies(expression, statesByValue);
|
|
6157
|
-
if (dependencies.length === 0
|
|
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
|
+
}
|
|
6158
6178
|
if (name === "style") {
|
|
6159
6179
|
const reason2 = analyzeStyle(expression, path);
|
|
6160
6180
|
if (reason2) return reason2;
|
|
@@ -7380,6 +7400,14 @@ function compileCandidate(candidate, createComponentIdentifier, keyedMapUpdateId
|
|
|
7380
7400
|
appliedKeyedMapUpdateHints > 0 || appliedKeyedArrayAppendHints > 0,
|
|
7381
7401
|
appliedKeyedArrayAppendHints > 0 && appliedKeyedMapUpdateHints === 0
|
|
7382
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
|
+
}
|
|
7383
7411
|
markShortCircuitBindings(analysis.bindings || []);
|
|
7384
7412
|
assignStableBindingTargets(analysis.bindings || []);
|
|
7385
7413
|
const stateParameter = path.scope.generateUidIdentifier("farmState");
|
|
@@ -7508,8 +7536,17 @@ function compileCandidate(candidate, createComponentIdentifier, keyedMapUpdateId
|
|
|
7508
7536
|
for (const feature of runtimeFeatures) usedRuntimeFeatures.add(feature);
|
|
7509
7537
|
return void 0;
|
|
7510
7538
|
}
|
|
7511
|
-
function collectCandidates(programPath) {
|
|
7539
|
+
function collectCandidates(programPath, options, moduleSelected) {
|
|
7512
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
|
+
}
|
|
7513
7550
|
programPath.traverse({
|
|
7514
7551
|
FunctionDeclaration(path) {
|
|
7515
7552
|
if (!path.node.id || !isComponentName(path.node.id.name)) return;
|
|
@@ -7517,11 +7554,7 @@ function collectCandidates(programPath) {
|
|
|
7517
7554
|
if (!parent.isProgram() && !parent.isExportNamedDeclaration() && !parent.isExportDefaultDeclaration()) {
|
|
7518
7555
|
return;
|
|
7519
7556
|
}
|
|
7520
|
-
|
|
7521
|
-
name: path.node.id.name,
|
|
7522
|
-
path,
|
|
7523
|
-
statementPath: parent.isProgram() ? path : parent
|
|
7524
|
-
});
|
|
7557
|
+
collect(path.node.id.name, path, parent.isProgram() ? path : parent);
|
|
7525
7558
|
},
|
|
7526
7559
|
VariableDeclarator(path) {
|
|
7527
7560
|
if (!types.isIdentifier(path.node.id) || !isComponentName(path.node.id.name) || !types.isFunctionExpression(path.node.init) && !types.isArrowFunctionExpression(path.node.init)) {
|
|
@@ -7532,11 +7565,7 @@ function collectCandidates(programPath) {
|
|
|
7532
7565
|
if (!statement) return;
|
|
7533
7566
|
const topLevel = statement.isProgram() ? declaration : statement.isExportNamedDeclaration() && statement.parentPath.isProgram() ? statement : null;
|
|
7534
7567
|
if (!topLevel) return;
|
|
7535
|
-
|
|
7536
|
-
name: path.node.id.name,
|
|
7537
|
-
path: path.get("init"),
|
|
7538
|
-
statementPath: topLevel
|
|
7539
|
-
});
|
|
7568
|
+
collect(path.node.id.name, path.get("init"), topLevel);
|
|
7540
7569
|
}
|
|
7541
7570
|
});
|
|
7542
7571
|
return candidates;
|
|
@@ -7606,101 +7635,85 @@ async function compileReactModule(code, id, options) {
|
|
|
7606
7635
|
}
|
|
7607
7636
|
}
|
|
7608
7637
|
}
|
|
7609
|
-
const candidates = collectCandidates(
|
|
7638
|
+
const candidates = collectCandidates(
|
|
7639
|
+
programPath,
|
|
7640
|
+
options,
|
|
7641
|
+
moduleDirectives.has(options.directive)
|
|
7642
|
+
);
|
|
7643
|
+
if (candidates.length === 0) return;
|
|
7610
7644
|
const createComponentIdentifier = programPath.scope.generateUidIdentifier("createCompiledComponent");
|
|
7611
7645
|
const createRefreshComponentIdentifier = programPath.scope.generateUidIdentifier("createRefreshComponent");
|
|
7612
7646
|
const createProductionComponentIdentifier = programPath.scope.generateUidIdentifier(
|
|
7613
7647
|
"createProductionComponent"
|
|
7614
7648
|
);
|
|
7615
|
-
const
|
|
7616
|
-
|
|
7617
|
-
|
|
7618
|
-
|
|
7619
|
-
|
|
7620
|
-
);
|
|
7621
|
-
const keyedArrayFilterIdentifier =
|
|
7622
|
-
|
|
7623
|
-
);
|
|
7624
|
-
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(
|
|
7625
7657
|
"createCompilerKeyedArrayMapPipeline"
|
|
7626
7658
|
);
|
|
7627
|
-
const keyedArrayMappedStructuralAppendIdentifier =
|
|
7659
|
+
const keyedArrayMappedStructuralAppendIdentifier = helperIdentifier(
|
|
7628
7660
|
"createCompilerKeyedArrayMappedStructuralAppend"
|
|
7629
7661
|
);
|
|
7630
|
-
const keyedArrayStructuralAppendMapPipelineIdentifier =
|
|
7662
|
+
const keyedArrayStructuralAppendMapPipelineIdentifier = helperIdentifier(
|
|
7631
7663
|
"createCompilerKeyedArrayStructuralAppendMapPipeline"
|
|
7632
7664
|
);
|
|
7633
|
-
const keyedArrayMappedStructuralPrependIdentifier =
|
|
7665
|
+
const keyedArrayMappedStructuralPrependIdentifier = helperIdentifier(
|
|
7634
7666
|
"createCompilerKeyedArrayMappedStructuralPrepend"
|
|
7635
7667
|
);
|
|
7636
|
-
const keyedArrayStructuralPrependMapPipelineIdentifier =
|
|
7668
|
+
const keyedArrayStructuralPrependMapPipelineIdentifier = helperIdentifier(
|
|
7637
7669
|
"createCompilerKeyedArrayStructuralPrependMapPipeline"
|
|
7638
7670
|
);
|
|
7639
|
-
const keyedArrayQueuedMapPipelineIdentifier =
|
|
7671
|
+
const keyedArrayQueuedMapPipelineIdentifier = helperIdentifier(
|
|
7640
7672
|
"createCompilerKeyedArrayQueuedMapPipeline"
|
|
7641
7673
|
);
|
|
7642
|
-
const keyedArrayRollingWindowMapPipelineIdentifier =
|
|
7674
|
+
const keyedArrayRollingWindowMapPipelineIdentifier = helperIdentifier(
|
|
7643
7675
|
"createCompilerKeyedArrayRollingWindowMapPipeline"
|
|
7644
7676
|
);
|
|
7645
|
-
const keyedArrayMappedRollingWindowIdentifier =
|
|
7677
|
+
const keyedArrayMappedRollingWindowIdentifier = helperIdentifier(
|
|
7646
7678
|
"createCompilerKeyedArrayMappedRollingWindow"
|
|
7647
7679
|
);
|
|
7648
|
-
const keyedArrayMapReorderIdentifier =
|
|
7680
|
+
const keyedArrayMapReorderIdentifier = helperIdentifier(
|
|
7649
7681
|
"createCompilerKeyedArrayMapReorder"
|
|
7650
7682
|
);
|
|
7651
|
-
const keyedArrayMappedStructuralIdentifier =
|
|
7683
|
+
const keyedArrayMappedStructuralIdentifier = helperIdentifier(
|
|
7652
7684
|
"finalizeCompilerKeyedArrayMappedStructuralUpdate"
|
|
7653
7685
|
);
|
|
7654
|
-
const keyedArrayPrependIdentifier =
|
|
7655
|
-
|
|
7656
|
-
);
|
|
7657
|
-
const keyedArrayPositionIdentifier = programPath.scope.generateUidIdentifier(
|
|
7686
|
+
const keyedArrayPrependIdentifier = helperIdentifier("createCompilerKeyedArrayPrepend");
|
|
7687
|
+
const keyedArrayPositionIdentifier = helperIdentifier(
|
|
7658
7688
|
"createCompilerKeyedArrayPositionUpdate"
|
|
7659
7689
|
);
|
|
7660
|
-
const keyedArrayBatchInsertIdentifier =
|
|
7690
|
+
const keyedArrayBatchInsertIdentifier = helperIdentifier(
|
|
7661
7691
|
"createCompilerKeyedArrayBatchInsert"
|
|
7662
7692
|
);
|
|
7663
|
-
const keyedArrayWindowReplaceIdentifier =
|
|
7693
|
+
const keyedArrayWindowReplaceIdentifier = helperIdentifier(
|
|
7664
7694
|
"createCompilerKeyedArrayWindowReplace"
|
|
7665
7695
|
);
|
|
7666
|
-
const keyedArrayReorderIdentifier =
|
|
7667
|
-
|
|
7668
|
-
);
|
|
7669
|
-
const keyedArrayStructuralReorderIdentifier = programPath.scope.generateUidIdentifier(
|
|
7696
|
+
const keyedArrayReorderIdentifier = helperIdentifier("createCompilerKeyedArrayReorder");
|
|
7697
|
+
const keyedArrayStructuralReorderIdentifier = helperIdentifier(
|
|
7670
7698
|
"createCompilerKeyedArrayStructuralReorder"
|
|
7671
7699
|
);
|
|
7672
|
-
const keyedArraySortIdentifier =
|
|
7673
|
-
|
|
7674
|
-
);
|
|
7675
|
-
const keyedArrayStructuralSortIdentifier = programPath.scope.generateUidIdentifier(
|
|
7700
|
+
const keyedArraySortIdentifier = helperIdentifier("createCompilerKeyedArraySort");
|
|
7701
|
+
const keyedArrayStructuralSortIdentifier = helperIdentifier(
|
|
7676
7702
|
"createCompilerKeyedArrayStructuralSort"
|
|
7677
7703
|
);
|
|
7678
|
-
const keyedArrayRollingWindowIdentifier =
|
|
7704
|
+
const keyedArrayRollingWindowIdentifier = helperIdentifier(
|
|
7679
7705
|
"createCompilerKeyedArrayRollingWindow"
|
|
7680
7706
|
);
|
|
7681
|
-
const keyedArraySliceIdentifier =
|
|
7682
|
-
|
|
7683
|
-
);
|
|
7684
|
-
const keyedCollectionUpdateIdentifier = programPath.scope.generateUidIdentifier(
|
|
7707
|
+
const keyedArraySliceIdentifier = helperIdentifier("createCompilerKeyedArraySlice");
|
|
7708
|
+
const keyedCollectionUpdateIdentifier = helperIdentifier(
|
|
7685
7709
|
"createCompilerKeyedCollectionUpdate"
|
|
7686
7710
|
);
|
|
7687
|
-
const keyedCollectionMutationIdentifier =
|
|
7711
|
+
const keyedCollectionMutationIdentifier = helperIdentifier(
|
|
7688
7712
|
"applyCompilerKeyedCollectionMutation"
|
|
7689
7713
|
);
|
|
7690
|
-
const runtimeFeatureIdentifiers = new Map(
|
|
7691
|
-
Object.entries(COMPILER_RUNTIME_FEATURE_EXPORTS).map(([feature, exportName]) => [
|
|
7692
|
-
feature,
|
|
7693
|
-
programPath.scope.generateUidIdentifier(exportName)
|
|
7694
|
-
])
|
|
7695
|
-
);
|
|
7714
|
+
const runtimeFeatureIdentifiers = /* @__PURE__ */ new Map();
|
|
7696
7715
|
const usedRuntimeFeatures = /* @__PURE__ */ new Set();
|
|
7697
7716
|
for (const candidate of candidates) {
|
|
7698
|
-
const functionDirectives = new Set(
|
|
7699
|
-
types.isBlockStatement(candidate.path.node.body) ? directiveValues(candidate.path.node.body) : []
|
|
7700
|
-
);
|
|
7701
|
-
const explicitlySelected = moduleDirectives.has(options.directive) || functionDirectives.has(options.directive);
|
|
7702
|
-
if (functionDirectives.has("use no compiler")) continue;
|
|
7703
|
-
if (options.mode === "annotation" && !explicitlySelected) continue;
|
|
7704
7717
|
const reason = compileCandidate(
|
|
7705
7718
|
candidate,
|
|
7706
7719
|
createComponentIdentifier,
|
|
@@ -7743,7 +7756,7 @@ async function compileReactModule(code, id, options) {
|
|
|
7743
7756
|
diagnostics.push({
|
|
7744
7757
|
component: candidate.name,
|
|
7745
7758
|
reason,
|
|
7746
|
-
selected: explicitlySelected
|
|
7759
|
+
selected: candidate.explicitlySelected
|
|
7747
7760
|
});
|
|
7748
7761
|
} else {
|
|
7749
7762
|
compiled.push(candidate.name);
|
|
@@ -7786,73 +7799,73 @@ async function compileReactModule(code, id, options) {
|
|
|
7786
7799
|
),
|
|
7787
7800
|
...optimizationCounts.keyedMapUpdateHints > compilerUsage.keyedArrayMapUpdateHints ? [
|
|
7788
7801
|
types.importSpecifier(
|
|
7789
|
-
keyedMapUpdateIdentifier,
|
|
7802
|
+
keyedMapUpdateIdentifier(),
|
|
7790
7803
|
types.identifier("createCompilerKeyedMapUpdate")
|
|
7791
7804
|
)
|
|
7792
7805
|
] : [],
|
|
7793
7806
|
...hasEagerKeyedArrayMapUpdateHints ? [
|
|
7794
7807
|
types.importSpecifier(
|
|
7795
|
-
keyedArrayMapPipelineIdentifier,
|
|
7808
|
+
keyedArrayMapPipelineIdentifier(),
|
|
7796
7809
|
types.identifier("createCompilerKeyedArrayMapPipeline")
|
|
7797
7810
|
)
|
|
7798
7811
|
] : [],
|
|
7799
7812
|
...compilerUsage.keyedArrayStructuralAppendMapHints > 0 ? [
|
|
7800
7813
|
types.importSpecifier(
|
|
7801
|
-
keyedArrayStructuralAppendMapPipelineIdentifier,
|
|
7814
|
+
keyedArrayStructuralAppendMapPipelineIdentifier(),
|
|
7802
7815
|
types.identifier("createCompilerKeyedArrayStructuralAppendMapPipeline")
|
|
7803
7816
|
)
|
|
7804
7817
|
] : [],
|
|
7805
7818
|
...compilerUsage.keyedArrayStructuralPrependMapHints > 0 ? [
|
|
7806
7819
|
types.importSpecifier(
|
|
7807
|
-
keyedArrayStructuralPrependMapPipelineIdentifier,
|
|
7820
|
+
keyedArrayStructuralPrependMapPipelineIdentifier(),
|
|
7808
7821
|
types.identifier("createCompilerKeyedArrayStructuralPrependMapPipeline")
|
|
7809
7822
|
)
|
|
7810
7823
|
] : [],
|
|
7811
7824
|
...hasKeyedArrayMapReorderHints ? [
|
|
7812
7825
|
types.importSpecifier(
|
|
7813
|
-
keyedArrayMapReorderIdentifier,
|
|
7826
|
+
keyedArrayMapReorderIdentifier(),
|
|
7814
7827
|
types.identifier("createCompilerKeyedArrayMapReorder")
|
|
7815
7828
|
)
|
|
7816
7829
|
] : [],
|
|
7817
7830
|
...compilerUsage.keyedArrayMappedStructuralHints > 0 ? [
|
|
7818
7831
|
types.importSpecifier(
|
|
7819
|
-
keyedArrayMappedStructuralIdentifier,
|
|
7832
|
+
keyedArrayMappedStructuralIdentifier(),
|
|
7820
7833
|
types.identifier("finalizeCompilerKeyedArrayMappedStructuralUpdate")
|
|
7821
7834
|
)
|
|
7822
7835
|
] : [],
|
|
7823
7836
|
...compilerUsage.keyedArrayMappedStructuralAppendHints > 0 || compilerUsage.keyedArrayMappedRollingWindowHints > compilerUsage.keyedArrayMappedRollingWindowChainHints ? [
|
|
7824
7837
|
types.importSpecifier(
|
|
7825
|
-
keyedArrayMappedStructuralAppendIdentifier,
|
|
7838
|
+
keyedArrayMappedStructuralAppendIdentifier(),
|
|
7826
7839
|
types.identifier("createCompilerKeyedArrayMappedStructuralAppend")
|
|
7827
7840
|
)
|
|
7828
7841
|
] : [],
|
|
7829
7842
|
...compilerUsage.keyedArrayMappedStructuralPrependHints > 0 ? [
|
|
7830
7843
|
types.importSpecifier(
|
|
7831
|
-
keyedArrayMappedStructuralPrependIdentifier,
|
|
7844
|
+
keyedArrayMappedStructuralPrependIdentifier(),
|
|
7832
7845
|
types.identifier("createCompilerKeyedArrayMappedStructuralPrepend")
|
|
7833
7846
|
)
|
|
7834
7847
|
] : [],
|
|
7835
7848
|
...compilerUsage.keyedArrayQueuedMapUpdateHints > 0 ? [
|
|
7836
7849
|
types.importSpecifier(
|
|
7837
|
-
keyedArrayQueuedMapPipelineIdentifier,
|
|
7850
|
+
keyedArrayQueuedMapPipelineIdentifier(),
|
|
7838
7851
|
types.identifier("createCompilerKeyedArrayQueuedMapPipeline")
|
|
7839
7852
|
)
|
|
7840
7853
|
] : [],
|
|
7841
7854
|
...compilerUsage.keyedArrayMappedRollingWindowChainHints > 0 ? [
|
|
7842
7855
|
types.importSpecifier(
|
|
7843
|
-
keyedArrayRollingWindowMapPipelineIdentifier,
|
|
7856
|
+
keyedArrayRollingWindowMapPipelineIdentifier(),
|
|
7844
7857
|
types.identifier("createCompilerKeyedArrayRollingWindowMapPipeline")
|
|
7845
7858
|
)
|
|
7846
7859
|
] : [],
|
|
7847
7860
|
...compilerUsage.keyedArrayMappedRollingWindowChainHints > 0 ? [
|
|
7848
7861
|
types.importSpecifier(
|
|
7849
|
-
keyedArrayMappedRollingWindowIdentifier,
|
|
7862
|
+
keyedArrayMappedRollingWindowIdentifier(),
|
|
7850
7863
|
types.identifier("createCompilerKeyedArrayMappedRollingWindow")
|
|
7851
7864
|
)
|
|
7852
7865
|
] : [],
|
|
7853
7866
|
...hasUnmappedKeyedArrayAppendHints || compilerUsage.keyedArrayStructuralRollingWindowHints > 0 ? [
|
|
7854
7867
|
types.importSpecifier(
|
|
7855
|
-
keyedArrayAppendIdentifier,
|
|
7868
|
+
keyedArrayAppendIdentifier(),
|
|
7856
7869
|
types.identifier(
|
|
7857
7870
|
hasKeyedArrayStructuralAppendHints ? "createCompilerKeyedArrayStructuralAppend" : "createCompilerKeyedArrayAppend"
|
|
7858
7871
|
)
|
|
@@ -7860,13 +7873,13 @@ async function compileReactModule(code, id, options) {
|
|
|
7860
7873
|
] : [],
|
|
7861
7874
|
...optimizationCounts.keyedArrayFilterHints > 0 ? [
|
|
7862
7875
|
types.importSpecifier(
|
|
7863
|
-
keyedArrayFilterIdentifier,
|
|
7876
|
+
keyedArrayFilterIdentifier(),
|
|
7864
7877
|
types.identifier("createCompilerKeyedArrayFilter")
|
|
7865
7878
|
)
|
|
7866
7879
|
] : [],
|
|
7867
7880
|
...hasUnmappedKeyedArrayPrependHints ? [
|
|
7868
7881
|
types.importSpecifier(
|
|
7869
|
-
keyedArrayPrependIdentifier,
|
|
7882
|
+
keyedArrayPrependIdentifier(),
|
|
7870
7883
|
types.identifier(
|
|
7871
7884
|
hasKeyedArrayStructuralPrependHints ? "createCompilerKeyedArrayStructuralPrepend" : "createCompilerKeyedArrayPrepend"
|
|
7872
7885
|
)
|
|
@@ -7874,65 +7887,65 @@ async function compileReactModule(code, id, options) {
|
|
|
7874
7887
|
] : [],
|
|
7875
7888
|
...optimizationCounts.keyedArrayPositionHints > compilerUsage.keyedArrayBatchInsertHints + compilerUsage.keyedArrayWindowReplaceHints ? [
|
|
7876
7889
|
types.importSpecifier(
|
|
7877
|
-
keyedArrayPositionIdentifier,
|
|
7890
|
+
keyedArrayPositionIdentifier(),
|
|
7878
7891
|
types.identifier("createCompilerKeyedArrayPositionUpdate")
|
|
7879
7892
|
)
|
|
7880
7893
|
] : [],
|
|
7881
7894
|
...compilerUsage.keyedArrayBatchInsertHints > 0 ? [
|
|
7882
7895
|
types.importSpecifier(
|
|
7883
|
-
keyedArrayBatchInsertIdentifier,
|
|
7896
|
+
keyedArrayBatchInsertIdentifier(),
|
|
7884
7897
|
types.identifier("createCompilerKeyedArrayBatchInsert")
|
|
7885
7898
|
)
|
|
7886
7899
|
] : [],
|
|
7887
7900
|
...compilerUsage.keyedArrayWindowReplaceHints > 0 ? [
|
|
7888
7901
|
types.importSpecifier(
|
|
7889
|
-
keyedArrayWindowReplaceIdentifier,
|
|
7902
|
+
keyedArrayWindowReplaceIdentifier(),
|
|
7890
7903
|
types.identifier("createCompilerKeyedArrayWindowReplace")
|
|
7891
7904
|
)
|
|
7892
7905
|
] : [],
|
|
7893
7906
|
...optimizationCounts.keyedArrayReorderHints > compilerUsage.keyedArrayStructuralReorderHints + compilerUsage.keyedArrayMapReorderHints ? [
|
|
7894
7907
|
types.importSpecifier(
|
|
7895
|
-
keyedArrayReorderIdentifier,
|
|
7908
|
+
keyedArrayReorderIdentifier(),
|
|
7896
7909
|
types.identifier("createCompilerKeyedArrayReorder")
|
|
7897
7910
|
)
|
|
7898
7911
|
] : [],
|
|
7899
7912
|
...compilerUsage.keyedArrayStructuralReorderHints > 0 ? [
|
|
7900
7913
|
types.importSpecifier(
|
|
7901
|
-
keyedArrayStructuralReorderIdentifier,
|
|
7914
|
+
keyedArrayStructuralReorderIdentifier(),
|
|
7902
7915
|
types.identifier("createCompilerKeyedArrayStructuralReorder")
|
|
7903
7916
|
)
|
|
7904
7917
|
] : [],
|
|
7905
7918
|
...optimizationCounts.keyedArraySortHints > compilerUsage.keyedArrayStructuralSortHints + compilerUsage.keyedArrayMapSortHints ? [
|
|
7906
7919
|
types.importSpecifier(
|
|
7907
|
-
keyedArraySortIdentifier,
|
|
7920
|
+
keyedArraySortIdentifier(),
|
|
7908
7921
|
types.identifier("createCompilerKeyedArraySort")
|
|
7909
7922
|
)
|
|
7910
7923
|
] : [],
|
|
7911
7924
|
...compilerUsage.keyedArrayStructuralSortHints > 0 ? [
|
|
7912
7925
|
types.importSpecifier(
|
|
7913
|
-
keyedArrayStructuralSortIdentifier,
|
|
7926
|
+
keyedArrayStructuralSortIdentifier(),
|
|
7914
7927
|
types.identifier("createCompilerKeyedArrayStructuralSort")
|
|
7915
7928
|
)
|
|
7916
7929
|
] : [],
|
|
7917
7930
|
...optimizationCounts.keyedArrayRollingWindowHints > compilerUsage.keyedArrayMappedRollingWindowHints + compilerUsage.keyedArrayStructuralRollingWindowHints ? [
|
|
7918
7931
|
types.importSpecifier(
|
|
7919
|
-
keyedArrayRollingWindowIdentifier,
|
|
7932
|
+
keyedArrayRollingWindowIdentifier(),
|
|
7920
7933
|
types.identifier("createCompilerKeyedArrayRollingWindow")
|
|
7921
7934
|
)
|
|
7922
7935
|
] : [],
|
|
7923
7936
|
...optimizationCounts.keyedArraySliceHints > 0 || optimizationCounts.keyedArrayRollingWindowHints > 0 ? [
|
|
7924
7937
|
types.importSpecifier(
|
|
7925
|
-
keyedArraySliceIdentifier,
|
|
7938
|
+
keyedArraySliceIdentifier(),
|
|
7926
7939
|
types.identifier("createCompilerKeyedArraySlice")
|
|
7927
7940
|
)
|
|
7928
7941
|
] : [],
|
|
7929
7942
|
...optimizationCounts.keyedCollectionUpdateHints > 0 ? [
|
|
7930
7943
|
types.importSpecifier(
|
|
7931
|
-
keyedCollectionUpdateIdentifier,
|
|
7944
|
+
keyedCollectionUpdateIdentifier(),
|
|
7932
7945
|
types.identifier("createCompilerKeyedCollectionUpdate")
|
|
7933
7946
|
),
|
|
7934
7947
|
types.importSpecifier(
|
|
7935
|
-
keyedCollectionMutationIdentifier,
|
|
7948
|
+
keyedCollectionMutationIdentifier(),
|
|
7936
7949
|
types.identifier("applyCompilerKeyedCollectionMutation")
|
|
7937
7950
|
)
|
|
7938
7951
|
] : [],
|