@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.cjs
CHANGED
|
@@ -767,7 +767,7 @@ function rewriteKeyedMapUpdateHints(root, hintedStateIndices, statesBySetter, he
|
|
|
767
767
|
}
|
|
768
768
|
path.node.arguments[0] = core.types.arrowFunctionExpression(
|
|
769
769
|
[core.types.cloneNode(previous)],
|
|
770
|
-
core.types.callExpression(core.types.cloneNode(helperIdentifier), [
|
|
770
|
+
core.types.callExpression(core.types.cloneNode(helperIdentifier()), [
|
|
771
771
|
core.types.cloneNode(previous),
|
|
772
772
|
core.types.arrowFunctionExpression(
|
|
773
773
|
[core.types.cloneNode(pipelineValue), core.types.cloneNode(applyMap)],
|
|
@@ -839,7 +839,7 @@ function rewriteKeyedArrayAppendHints(root, hintedStateIndices, statesBySetter,
|
|
|
839
839
|
core.types.variableDeclarator(core.types.cloneNode(nextValue), core.types.cloneNode(updateExpression, true))
|
|
840
840
|
]),
|
|
841
841
|
core.types.returnStatement(
|
|
842
|
-
core.types.callExpression(core.types.cloneNode(helperIdentifier), [
|
|
842
|
+
core.types.callExpression(core.types.cloneNode(helperIdentifier()), [
|
|
843
843
|
core.types.cloneNode(previous),
|
|
844
844
|
core.types.cloneNode(nextValue)
|
|
845
845
|
])
|
|
@@ -915,7 +915,7 @@ function rewriteKeyedArrayPrependHints(root, hintedStateIndices, statesBySetter,
|
|
|
915
915
|
core.types.variableDeclarator(core.types.cloneNode(nextValue), core.types.cloneNode(updateExpression, true))
|
|
916
916
|
]),
|
|
917
917
|
core.types.returnStatement(
|
|
918
|
-
core.types.callExpression(core.types.cloneNode(helperIdentifier), [
|
|
918
|
+
core.types.callExpression(core.types.cloneNode(helperIdentifier()), [
|
|
919
919
|
core.types.cloneNode(previous),
|
|
920
920
|
core.types.cloneNode(nextValue)
|
|
921
921
|
])
|
|
@@ -1006,7 +1006,7 @@ function rewriteKeyedArrayRollingWindowHints(root, hintedStateIndices, statesByS
|
|
|
1006
1006
|
),
|
|
1007
1007
|
core.types.variableDeclarator(
|
|
1008
1008
|
core.types.cloneNode(retained),
|
|
1009
|
-
core.types.callExpression(core.types.cloneNode(sliceHelperIdentifier), [
|
|
1009
|
+
core.types.callExpression(core.types.cloneNode(sliceHelperIdentifier()), [
|
|
1010
1010
|
core.types.cloneNode(previous),
|
|
1011
1011
|
core.types.cloneNode(sliceMethod),
|
|
1012
1012
|
core.types.cloneNode(retainedStart, true)
|
|
@@ -1015,7 +1015,7 @@ function rewriteKeyedArrayRollingWindowHints(root, hintedStateIndices, statesByS
|
|
|
1015
1015
|
core.types.variableDeclarator(core.types.cloneNode(nextValue), core.types.arrayExpression(nextElements))
|
|
1016
1016
|
]),
|
|
1017
1017
|
core.types.returnStatement(
|
|
1018
|
-
core.types.callExpression(core.types.cloneNode(rollingWindowHelperIdentifier), [
|
|
1018
|
+
core.types.callExpression(core.types.cloneNode(rollingWindowHelperIdentifier()), [
|
|
1019
1019
|
core.types.cloneNode(previous),
|
|
1020
1020
|
core.types.cloneNode(retained),
|
|
1021
1021
|
core.types.cloneNode(nextValue)
|
|
@@ -1114,18 +1114,18 @@ function rewriteKeyedArrayPositionHints(root, hintedStateIndices, statesBySetter
|
|
|
1114
1114
|
)
|
|
1115
1115
|
]),
|
|
1116
1116
|
core.types.returnStatement(
|
|
1117
|
-
kind === "batch-insert" ? core.types.callExpression(core.types.cloneNode(batchInsertHelperIdentifier), [
|
|
1117
|
+
kind === "batch-insert" ? core.types.callExpression(core.types.cloneNode(batchInsertHelperIdentifier()), [
|
|
1118
1118
|
core.types.cloneNode(previous),
|
|
1119
1119
|
core.types.cloneNode(method),
|
|
1120
1120
|
core.types.cloneNode(position, true),
|
|
1121
1121
|
...args.slice(2).map((argument) => core.types.cloneNode(argument, true))
|
|
1122
|
-
]) : kind === "window-replace" ? core.types.callExpression(core.types.cloneNode(windowReplaceHelperIdentifier), [
|
|
1122
|
+
]) : kind === "window-replace" ? core.types.callExpression(core.types.cloneNode(windowReplaceHelperIdentifier()), [
|
|
1123
1123
|
core.types.cloneNode(previous),
|
|
1124
1124
|
core.types.cloneNode(method),
|
|
1125
1125
|
core.types.cloneNode(position, true),
|
|
1126
1126
|
core.types.cloneNode(args[1], true),
|
|
1127
1127
|
...args.slice(2).map((argument) => core.types.cloneNode(argument, true))
|
|
1128
|
-
]) : core.types.callExpression(core.types.cloneNode(helperIdentifier), [
|
|
1128
|
+
]) : core.types.callExpression(core.types.cloneNode(helperIdentifier()), [
|
|
1129
1129
|
core.types.cloneNode(previous),
|
|
1130
1130
|
core.types.cloneNode(method),
|
|
1131
1131
|
core.types.stringLiteral(kind),
|
|
@@ -1185,7 +1185,7 @@ function rewriteKeyedArrayReorderHints(root, hintedStateIndices, statesBySetter,
|
|
|
1185
1185
|
)
|
|
1186
1186
|
]),
|
|
1187
1187
|
core.types.returnStatement(
|
|
1188
|
-
core.types.callExpression(core.types.cloneNode(helperIdentifier), [
|
|
1188
|
+
core.types.callExpression(core.types.cloneNode(helperIdentifier()), [
|
|
1189
1189
|
core.types.cloneNode(previous),
|
|
1190
1190
|
core.types.cloneNode(method)
|
|
1191
1191
|
])
|
|
@@ -1391,7 +1391,7 @@ function rewriteKeyedArrayReorderPipelineHints(root, hintedStateIndices, statesB
|
|
|
1391
1391
|
core.types.variableDeclaration("const", [
|
|
1392
1392
|
core.types.variableDeclarator(
|
|
1393
1393
|
core.types.cloneNode(result2),
|
|
1394
|
-
core.types.callExpression(core.types.cloneNode(mapHelperIdentifier), [
|
|
1394
|
+
core.types.callExpression(core.types.cloneNode(mapHelperIdentifier()), [
|
|
1395
1395
|
core.types.cloneNode(value),
|
|
1396
1396
|
core.types.arrowFunctionExpression(
|
|
1397
1397
|
[core.types.cloneNode(pipelineValue), core.types.cloneNode(applyMap)],
|
|
@@ -1428,7 +1428,7 @@ function rewriteKeyedArrayReorderPipelineHints(root, hintedStateIndices, statesB
|
|
|
1428
1428
|
core.types.variableDeclaration("const", [
|
|
1429
1429
|
core.types.variableDeclarator(
|
|
1430
1430
|
core.types.cloneNode(result),
|
|
1431
|
-
core.types.callExpression(core.types.cloneNode(helper), [
|
|
1431
|
+
core.types.callExpression(core.types.cloneNode(helper()), [
|
|
1432
1432
|
core.types.cloneNode(value),
|
|
1433
1433
|
core.types.cloneNode(method),
|
|
1434
1434
|
...args
|
|
@@ -1454,7 +1454,9 @@ function rewriteKeyedArrayReorderPipelineHints(root, hintedStateIndices, statesB
|
|
|
1454
1454
|
}
|
|
1455
1455
|
statements.push(
|
|
1456
1456
|
core.types.returnStatement(
|
|
1457
|
-
terminalStructuralPipeline ? core.types.callExpression(core.types.cloneNode(mappedStructuralHelperIdentifier), [
|
|
1457
|
+
terminalStructuralPipeline ? core.types.callExpression(core.types.cloneNode(mappedStructuralHelperIdentifier()), [
|
|
1458
|
+
core.types.cloneNode(value)
|
|
1459
|
+
]) : core.types.cloneNode(value)
|
|
1458
1460
|
)
|
|
1459
1461
|
);
|
|
1460
1462
|
if (terminalStructuralPipeline) terminalStructuralPipelineCount += 1;
|
|
@@ -1495,13 +1497,13 @@ function rewriteQueuedKeyedArrayReorderMapHints(root, statesBySetter, mapUpdateI
|
|
|
1495
1497
|
return found;
|
|
1496
1498
|
};
|
|
1497
1499
|
const reorderHelperNames = /* @__PURE__ */ new Set([
|
|
1498
|
-
mapReorderIdentifier.name,
|
|
1499
|
-
reorderIdentifier.name,
|
|
1500
|
-
sortIdentifier.name
|
|
1500
|
+
mapReorderIdentifier().name,
|
|
1501
|
+
reorderIdentifier().name,
|
|
1502
|
+
sortIdentifier().name
|
|
1501
1503
|
]);
|
|
1502
1504
|
const structuralHelperNames = /* @__PURE__ */ new Set([
|
|
1503
|
-
structuralReorderIdentifier.name,
|
|
1504
|
-
structuralSortIdentifier.name
|
|
1505
|
+
structuralReorderIdentifier().name,
|
|
1506
|
+
structuralSortIdentifier().name
|
|
1505
1507
|
]);
|
|
1506
1508
|
core.traverse(file, {
|
|
1507
1509
|
BlockStatement(path) {
|
|
@@ -1528,7 +1530,7 @@ function rewriteQueuedKeyedArrayReorderMapHints(root, statesBySetter, mapUpdateI
|
|
|
1528
1530
|
queuedReorderState = state.index;
|
|
1529
1531
|
continue;
|
|
1530
1532
|
}
|
|
1531
|
-
if (queuedReorderState !== state.index || !core.types.isCallExpression(updater.body) || !core.types.isIdentifier(updater.body.callee, { name: mapUpdateIdentifier.name }) || updater.body.arguments.length !== 2) {
|
|
1533
|
+
if (queuedReorderState !== state.index || !core.types.isCallExpression(updater.body) || !core.types.isIdentifier(updater.body.callee, { name: mapUpdateIdentifier().name }) || updater.body.arguments.length !== 2) {
|
|
1532
1534
|
queuedReorderState = void 0;
|
|
1533
1535
|
continue;
|
|
1534
1536
|
}
|
|
@@ -1548,7 +1550,7 @@ function rewriteQueuedKeyedArrayReorderMapHints(root, statesBySetter, mapUpdateI
|
|
|
1548
1550
|
queuedReorderState = void 0;
|
|
1549
1551
|
continue;
|
|
1550
1552
|
}
|
|
1551
|
-
updater.body.callee = core.types.cloneNode(queuedMapPipelineIdentifier);
|
|
1553
|
+
updater.body.callee = core.types.cloneNode(queuedMapPipelineIdentifier());
|
|
1552
1554
|
mapCount += pipelineMapCount;
|
|
1553
1555
|
}
|
|
1554
1556
|
}
|
|
@@ -1559,7 +1561,7 @@ function rewriteQueuedKeyedArrayReorderMapHints(root, statesBySetter, mapUpdateI
|
|
|
1559
1561
|
};
|
|
1560
1562
|
}
|
|
1561
1563
|
function countKeyedArrayMapPipeline(updater, mapUpdateIdentifier) {
|
|
1562
|
-
if (!core.types.isCallExpression(updater.body) || !core.types.isIdentifier(updater.body.callee, { name: mapUpdateIdentifier.name }) || updater.body.arguments.length !== 2) {
|
|
1564
|
+
if (!core.types.isCallExpression(updater.body) || !core.types.isIdentifier(updater.body.callee, { name: mapUpdateIdentifier().name }) || updater.body.arguments.length !== 2) {
|
|
1563
1565
|
return 0;
|
|
1564
1566
|
}
|
|
1565
1567
|
const pipeline = updater.body.arguments[1];
|
|
@@ -1591,7 +1593,7 @@ function rewriteQueuedKeyedArrayMappedStructuralHints(root, statesBySetter, mapU
|
|
|
1591
1593
|
const terminalStructuralReturn = (updater) => {
|
|
1592
1594
|
if (!core.types.isBlockStatement(updater.body)) return void 0;
|
|
1593
1595
|
const statement = updater.body.body.at(-1);
|
|
1594
|
-
if (!core.types.isReturnStatement(statement) || !statement.argument || !core.types.isCallExpression(statement.argument) || !core.types.isIdentifier(statement.argument.callee) || statement.argument.callee.name !== filterIdentifier.name && statement.argument.callee.name !== sliceIdentifier.name) {
|
|
1596
|
+
if (!core.types.isReturnStatement(statement) || !statement.argument || !core.types.isCallExpression(statement.argument) || !core.types.isIdentifier(statement.argument.callee) || statement.argument.callee.name !== filterIdentifier().name && statement.argument.callee.name !== sliceIdentifier().name) {
|
|
1595
1597
|
return void 0;
|
|
1596
1598
|
}
|
|
1597
1599
|
return statement;
|
|
@@ -1645,7 +1647,7 @@ function rewriteQueuedKeyedArrayMappedStructuralHints(root, statesBySetter, mapU
|
|
|
1645
1647
|
}
|
|
1646
1648
|
if (hasPendingMaps) {
|
|
1647
1649
|
for (const candidate of pendingMaps) {
|
|
1648
|
-
candidate.updater.body.callee = core.types.cloneNode(queuedMapPipelineIdentifier);
|
|
1650
|
+
candidate.updater.body.callee = core.types.cloneNode(queuedMapPipelineIdentifier());
|
|
1649
1651
|
mapCount += candidate.count;
|
|
1650
1652
|
}
|
|
1651
1653
|
}
|
|
@@ -1655,7 +1657,7 @@ function rewriteQueuedKeyedArrayMappedStructuralHints(root, statesBySetter, mapU
|
|
|
1655
1657
|
pendingMaps = [];
|
|
1656
1658
|
continue;
|
|
1657
1659
|
}
|
|
1658
|
-
structuralReturn.argument = core.types.callExpression(core.types.cloneNode(mappedStructuralIdentifier), [
|
|
1660
|
+
structuralReturn.argument = core.types.callExpression(core.types.cloneNode(mappedStructuralIdentifier()), [
|
|
1659
1661
|
core.types.cloneNode(structuralValue)
|
|
1660
1662
|
]);
|
|
1661
1663
|
structuralCount += 1;
|
|
@@ -1695,10 +1697,10 @@ function rewriteQueuedKeyedArrayStructuralMapHints(root, statesBySetter, mapUpda
|
|
|
1695
1697
|
let mapped = false;
|
|
1696
1698
|
core.types.traverseFast(statement.argument, (node) => {
|
|
1697
1699
|
if (!found && core.types.isCallExpression(node) && core.types.isIdentifier(node.callee)) {
|
|
1698
|
-
if (node.callee.name === filterIdentifier.name) found = "filter";
|
|
1699
|
-
if (node.callee.name === sliceIdentifier.name) found = "slice";
|
|
1700
|
+
if (node.callee.name === filterIdentifier().name) found = "filter";
|
|
1701
|
+
if (node.callee.name === sliceIdentifier().name) found = "slice";
|
|
1700
1702
|
}
|
|
1701
|
-
if (!mapped && core.types.isCallExpression(node) && core.types.isIdentifier(node.callee, { name: mappedStructuralIdentifier.name })) {
|
|
1703
|
+
if (!mapped && core.types.isCallExpression(node) && core.types.isIdentifier(node.callee, { name: mappedStructuralIdentifier().name })) {
|
|
1702
1704
|
mapped = true;
|
|
1703
1705
|
}
|
|
1704
1706
|
});
|
|
@@ -1747,7 +1749,7 @@ function rewriteQueuedKeyedArrayStructuralMapHints(root, statesBySetter, mapUpda
|
|
|
1747
1749
|
}
|
|
1748
1750
|
const appendCalls = [];
|
|
1749
1751
|
core.types.traverseFast(updater.body, (node) => {
|
|
1750
|
-
if (core.types.isCallExpression(node) && core.types.isIdentifier(node.callee, { name: appendIdentifier.name })) {
|
|
1752
|
+
if (core.types.isCallExpression(node) && core.types.isIdentifier(node.callee, { name: appendIdentifier().name })) {
|
|
1751
1753
|
appendCalls.push(node);
|
|
1752
1754
|
}
|
|
1753
1755
|
});
|
|
@@ -1756,7 +1758,7 @@ function rewriteQueuedKeyedArrayStructuralMapHints(root, statesBySetter, mapUpda
|
|
|
1756
1758
|
structuralAppendState = state.index;
|
|
1757
1759
|
if (structuralMapState === state.index) {
|
|
1758
1760
|
for (const call of appendCalls) {
|
|
1759
|
-
call.callee = core.types.cloneNode(mappedStructuralAppendIdentifier);
|
|
1761
|
+
call.callee = core.types.cloneNode(mappedStructuralAppendIdentifier());
|
|
1760
1762
|
}
|
|
1761
1763
|
mappedStructuralAppendCount += appendCalls.length;
|
|
1762
1764
|
}
|
|
@@ -1777,7 +1779,7 @@ function rewriteQueuedKeyedArrayStructuralMapHints(root, statesBySetter, mapUpda
|
|
|
1777
1779
|
continue;
|
|
1778
1780
|
}
|
|
1779
1781
|
updater.body.callee = core.types.cloneNode(
|
|
1780
|
-
structuralAppendState === state.index ? structuralAppendMapPipelineIdentifier : mapPipelineIdentifier
|
|
1782
|
+
structuralAppendState === state.index ? structuralAppendMapPipelineIdentifier() : mapPipelineIdentifier()
|
|
1781
1783
|
);
|
|
1782
1784
|
mapCount += pipelineMapCount;
|
|
1783
1785
|
if (structuralAppendState === state.index) {
|
|
@@ -1819,10 +1821,10 @@ function rewriteQueuedKeyedArrayStructuralPrependMapHints(root, statesBySetter,
|
|
|
1819
1821
|
let mapped = false;
|
|
1820
1822
|
core.types.traverseFast(statement.argument, (node) => {
|
|
1821
1823
|
if (!found && core.types.isCallExpression(node) && core.types.isIdentifier(node.callee)) {
|
|
1822
|
-
if (node.callee.name === filterIdentifier.name) found = "filter";
|
|
1823
|
-
if (node.callee.name === sliceIdentifier.name) found = "slice";
|
|
1824
|
+
if (node.callee.name === filterIdentifier().name) found = "filter";
|
|
1825
|
+
if (node.callee.name === sliceIdentifier().name) found = "slice";
|
|
1824
1826
|
}
|
|
1825
|
-
if (!mapped && core.types.isCallExpression(node) && core.types.isIdentifier(node.callee, { name: mappedStructuralIdentifier.name })) {
|
|
1827
|
+
if (!mapped && core.types.isCallExpression(node) && core.types.isIdentifier(node.callee, { name: mappedStructuralIdentifier().name })) {
|
|
1826
1828
|
mapped = true;
|
|
1827
1829
|
}
|
|
1828
1830
|
});
|
|
@@ -1871,7 +1873,7 @@ function rewriteQueuedKeyedArrayStructuralPrependMapHints(root, statesBySetter,
|
|
|
1871
1873
|
}
|
|
1872
1874
|
const prependCalls = [];
|
|
1873
1875
|
core.types.traverseFast(updater.body, (node) => {
|
|
1874
|
-
if (core.types.isCallExpression(node) && core.types.isIdentifier(node.callee, { name: prependIdentifier.name })) {
|
|
1876
|
+
if (core.types.isCallExpression(node) && core.types.isIdentifier(node.callee, { name: prependIdentifier().name })) {
|
|
1875
1877
|
prependCalls.push(node);
|
|
1876
1878
|
}
|
|
1877
1879
|
});
|
|
@@ -1880,7 +1882,7 @@ function rewriteQueuedKeyedArrayStructuralPrependMapHints(root, statesBySetter,
|
|
|
1880
1882
|
structuralPrependState = state.index;
|
|
1881
1883
|
if (structuralMapState === state.index) {
|
|
1882
1884
|
for (const call of prependCalls) {
|
|
1883
|
-
call.callee = core.types.cloneNode(mappedStructuralPrependIdentifier);
|
|
1885
|
+
call.callee = core.types.cloneNode(mappedStructuralPrependIdentifier());
|
|
1884
1886
|
}
|
|
1885
1887
|
mappedStructuralPrependCount += prependCalls.length;
|
|
1886
1888
|
}
|
|
@@ -1901,7 +1903,7 @@ function rewriteQueuedKeyedArrayStructuralPrependMapHints(root, statesBySetter,
|
|
|
1901
1903
|
continue;
|
|
1902
1904
|
}
|
|
1903
1905
|
updater.body.callee = core.types.cloneNode(
|
|
1904
|
-
structuralPrependState === state.index ? structuralPrependMapPipelineIdentifier : mapPipelineIdentifier
|
|
1906
|
+
structuralPrependState === state.index ? structuralPrependMapPipelineIdentifier() : mapPipelineIdentifier()
|
|
1905
1907
|
);
|
|
1906
1908
|
mapCount += pipelineMapCount;
|
|
1907
1909
|
if (structuralPrependState === state.index) {
|
|
@@ -1952,7 +1954,7 @@ function rewriteQueuedKeyedArrayRollingWindowMapHints(root, statesBySetter, mapU
|
|
|
1952
1954
|
const rollingStep = (updater) => {
|
|
1953
1955
|
if (!core.types.isBlockStatement(updater.body)) return void 0;
|
|
1954
1956
|
const statement = updater.body.body.at(-1);
|
|
1955
|
-
if (!core.types.isReturnStatement(statement) || !statement.argument || !core.types.isCallExpression(statement.argument) || !core.types.isIdentifier(statement.argument.callee, { name: rollingWindowIdentifier.name }) || statement.argument.arguments.length !== 3 || !core.types.isExpression(statement.argument.arguments[1]) || !core.types.isExpression(statement.argument.arguments[2])) {
|
|
1957
|
+
if (!core.types.isReturnStatement(statement) || !statement.argument || !core.types.isCallExpression(statement.argument) || !core.types.isIdentifier(statement.argument.callee, { name: rollingWindowIdentifier().name }) || statement.argument.arguments.length !== 3 || !core.types.isExpression(statement.argument.arguments[1]) || !core.types.isExpression(statement.argument.arguments[2])) {
|
|
1956
1958
|
return void 0;
|
|
1957
1959
|
}
|
|
1958
1960
|
return { call: statement.argument };
|
|
@@ -1979,13 +1981,13 @@ function rewriteQueuedKeyedArrayRollingWindowMapHints(root, statesBySetter, mapU
|
|
|
1979
1981
|
}
|
|
1980
1982
|
for (const step of maps) {
|
|
1981
1983
|
if (step.kind !== "map") continue;
|
|
1982
|
-
step.value.updater.body.callee = core.types.cloneNode(rollingWindowMapPipelineIdentifier);
|
|
1984
|
+
step.value.updater.body.callee = core.types.cloneNode(rollingWindowMapPipelineIdentifier());
|
|
1983
1985
|
chainedMapCount += step.value.count;
|
|
1984
1986
|
}
|
|
1985
1987
|
for (const index of rollingIndices) {
|
|
1986
1988
|
const step = segment[index];
|
|
1987
1989
|
if (step.kind === "rolling") {
|
|
1988
|
-
step.value.call.callee = core.types.cloneNode(mappedRollingWindowIdentifier);
|
|
1990
|
+
step.value.call.callee = core.types.cloneNode(mappedRollingWindowIdentifier());
|
|
1989
1991
|
}
|
|
1990
1992
|
}
|
|
1991
1993
|
chainedRollingWindowCount += rollingIndices.length;
|
|
@@ -2009,10 +2011,10 @@ function rewriteQueuedKeyedArrayRollingWindowMapHints(root, statesBySetter, mapU
|
|
|
2009
2011
|
if (!core.types.isExpression(retained) || !core.types.isExpression(value)) return;
|
|
2010
2012
|
const hasLeadingMaps = leadingMaps.length > 0;
|
|
2011
2013
|
rolling.value.call.callee = core.types.cloneNode(
|
|
2012
|
-
hasLeadingMaps ? mappedStructuralAppendIdentifier : structuralAppendIdentifier
|
|
2014
|
+
hasLeadingMaps ? mappedStructuralAppendIdentifier() : structuralAppendIdentifier()
|
|
2013
2015
|
);
|
|
2014
2016
|
rolling.value.call.arguments = [
|
|
2015
|
-
hasLeadingMaps ? core.types.callExpression(core.types.cloneNode(mappedStructuralIdentifier), [
|
|
2017
|
+
hasLeadingMaps ? core.types.callExpression(core.types.cloneNode(mappedStructuralIdentifier()), [
|
|
2016
2018
|
core.types.cloneNode(retained, true)
|
|
2017
2019
|
]) : core.types.cloneNode(retained, true),
|
|
2018
2020
|
core.types.cloneNode(value, true)
|
|
@@ -2022,7 +2024,7 @@ function rewriteQueuedKeyedArrayRollingWindowMapHints(root, statesBySetter, mapU
|
|
|
2022
2024
|
mappedRollingWindowCount += 1;
|
|
2023
2025
|
for (const step of leadingMaps) {
|
|
2024
2026
|
if (step.kind !== "map") continue;
|
|
2025
|
-
step.value.updater.body.callee = core.types.cloneNode(queuedMapPipelineIdentifier);
|
|
2027
|
+
step.value.updater.body.callee = core.types.cloneNode(queuedMapPipelineIdentifier());
|
|
2026
2028
|
leadingMapCount += step.value.count;
|
|
2027
2029
|
}
|
|
2028
2030
|
} else {
|
|
@@ -2030,7 +2032,7 @@ function rewriteQueuedKeyedArrayRollingWindowMapHints(root, statesBySetter, mapU
|
|
|
2030
2032
|
}
|
|
2031
2033
|
for (const step of trailingMaps) {
|
|
2032
2034
|
if (step.kind !== "map") continue;
|
|
2033
|
-
step.value.updater.body.callee = core.types.cloneNode(structuralAppendMapPipelineIdentifier);
|
|
2035
|
+
step.value.updater.body.callee = core.types.cloneNode(structuralAppendMapPipelineIdentifier());
|
|
2034
2036
|
trailingMapCount += step.value.count;
|
|
2035
2037
|
}
|
|
2036
2038
|
segment = [];
|
|
@@ -2134,34 +2136,34 @@ function rewriteQueuedKeyedArrayStructuralReorderHints(root, statesBySetter, fil
|
|
|
2134
2136
|
core.types.traverseFast(updater.body, (node) => {
|
|
2135
2137
|
if (!core.types.isCallExpression(node) || !core.types.isIdentifier(node.callee)) return;
|
|
2136
2138
|
const helperName = node.callee.name;
|
|
2137
|
-
if (helperName === filterIdentifier.name || helperName === sliceIdentifier.name || helperName === mappedStructuralIdentifier.name) {
|
|
2139
|
+
if (helperName === filterIdentifier().name || helperName === sliceIdentifier().name || helperName === mappedStructuralIdentifier().name) {
|
|
2138
2140
|
startsStructuralLineage = true;
|
|
2139
2141
|
return;
|
|
2140
2142
|
}
|
|
2141
|
-
if (helperName === structuralReorderIdentifier.name || helperName === structuralSortIdentifier.name) {
|
|
2143
|
+
if (helperName === structuralReorderIdentifier().name || helperName === structuralSortIdentifier().name) {
|
|
2142
2144
|
startsStructuralLineage = true;
|
|
2143
2145
|
return;
|
|
2144
2146
|
}
|
|
2145
|
-
if (helperName === mapPipelineIdentifier.name) {
|
|
2147
|
+
if (helperName === mapPipelineIdentifier().name) {
|
|
2146
2148
|
continuesStructuralLineage = true;
|
|
2147
2149
|
return;
|
|
2148
2150
|
}
|
|
2149
|
-
if (helperName === queuedMapPipelineIdentifier.name) {
|
|
2151
|
+
if (helperName === queuedMapPipelineIdentifier().name) {
|
|
2150
2152
|
continuesStructuralLineage = true;
|
|
2151
2153
|
queuedMaps.push(node);
|
|
2152
2154
|
return;
|
|
2153
2155
|
}
|
|
2154
|
-
if (helperName === reorderIdentifier.name) {
|
|
2156
|
+
if (helperName === reorderIdentifier().name) {
|
|
2155
2157
|
continuesStructuralLineage = true;
|
|
2156
2158
|
reorderCalls.push({ call: node, kind: "reverse", mapped: false });
|
|
2157
2159
|
return;
|
|
2158
2160
|
}
|
|
2159
|
-
if (helperName === sortIdentifier.name) {
|
|
2161
|
+
if (helperName === sortIdentifier().name) {
|
|
2160
2162
|
continuesStructuralLineage = true;
|
|
2161
2163
|
reorderCalls.push({ call: node, kind: "sort", mapped: false });
|
|
2162
2164
|
return;
|
|
2163
2165
|
}
|
|
2164
|
-
if (helperName === mapReorderIdentifier.name) {
|
|
2166
|
+
if (helperName === mapReorderIdentifier().name) {
|
|
2165
2167
|
const method = node.arguments[1];
|
|
2166
2168
|
const kind = core.types.isIdentifier(method) ? methodKinds.get(method.name) : void 0;
|
|
2167
2169
|
if (!kind) {
|
|
@@ -2182,12 +2184,12 @@ function rewriteQueuedKeyedArrayStructuralReorderHints(root, statesBySetter, fil
|
|
|
2182
2184
|
continue;
|
|
2183
2185
|
}
|
|
2184
2186
|
for (const call of queuedMaps) {
|
|
2185
|
-
call.callee = core.types.cloneNode(mapPipelineIdentifier);
|
|
2187
|
+
call.callee = core.types.cloneNode(mapPipelineIdentifier());
|
|
2186
2188
|
replacedQueuedMapCount += 1;
|
|
2187
2189
|
}
|
|
2188
2190
|
for (const { call, kind, mapped } of reorderCalls) {
|
|
2189
2191
|
call.callee = core.types.cloneNode(
|
|
2190
|
-
kind === "reverse" ? structuralReorderIdentifier : structuralSortIdentifier
|
|
2192
|
+
kind === "reverse" ? structuralReorderIdentifier() : structuralSortIdentifier()
|
|
2191
2193
|
);
|
|
2192
2194
|
if (kind === "reverse") {
|
|
2193
2195
|
reorderCount += 1;
|
|
@@ -2248,7 +2250,7 @@ function rewriteQueuedKeyedArrayMapReorderHints(root, statesBySetter, mapUpdateI
|
|
|
2248
2250
|
pendingMaps = [];
|
|
2249
2251
|
continue;
|
|
2250
2252
|
}
|
|
2251
|
-
if (core.types.isCallExpression(updater.body) && core.types.isIdentifier(updater.body.callee, { name: mapUpdateIdentifier.name }) && updater.body.arguments.length === 2) {
|
|
2253
|
+
if (core.types.isCallExpression(updater.body) && core.types.isIdentifier(updater.body.callee, { name: mapUpdateIdentifier().name }) && updater.body.arguments.length === 2) {
|
|
2252
2254
|
const pipeline = updater.body.arguments[1];
|
|
2253
2255
|
let pipelineMapCount = 0;
|
|
2254
2256
|
if (core.types.isArrowFunctionExpression(pipeline) && pipeline.params.length === 2 && core.types.isIdentifier(pipeline.params[1])) {
|
|
@@ -2275,13 +2277,13 @@ function rewriteQueuedKeyedArrayMapReorderHints(root, statesBySetter, mapUpdateI
|
|
|
2275
2277
|
let structural = false;
|
|
2276
2278
|
core.types.traverseFast(updater.body, (node) => {
|
|
2277
2279
|
if (!core.types.isCallExpression(node) || !core.types.isIdentifier(node.callee)) return;
|
|
2278
|
-
if (node.callee.name === structuralReorderIdentifier.name || node.callee.name === structuralSortIdentifier.name) {
|
|
2280
|
+
if (node.callee.name === structuralReorderIdentifier().name || node.callee.name === structuralSortIdentifier().name) {
|
|
2279
2281
|
structural = true;
|
|
2280
|
-
} else if (node.callee.name === mapReorderIdentifier.name) {
|
|
2282
|
+
} else if (node.callee.name === mapReorderIdentifier().name) {
|
|
2281
2283
|
containsMappedReorder = true;
|
|
2282
|
-
} else if (node.callee.name === reorderIdentifier.name) {
|
|
2284
|
+
} else if (node.callee.name === reorderIdentifier().name) {
|
|
2283
2285
|
reorderCalls.push({ call: node, kind: "reverse" });
|
|
2284
|
-
} else if (node.callee.name === sortIdentifier.name) {
|
|
2286
|
+
} else if (node.callee.name === sortIdentifier().name) {
|
|
2285
2287
|
reorderCalls.push({ call: node, kind: "sort" });
|
|
2286
2288
|
}
|
|
2287
2289
|
});
|
|
@@ -2303,12 +2305,12 @@ function rewriteQueuedKeyedArrayMapReorderHints(root, statesBySetter, mapUpdateI
|
|
|
2303
2305
|
}
|
|
2304
2306
|
if (hasPendingMaps) {
|
|
2305
2307
|
for (const candidate of pendingMaps) {
|
|
2306
|
-
candidate.updater.body.callee = core.types.cloneNode(queuedMapPipelineIdentifier);
|
|
2308
|
+
candidate.updater.body.callee = core.types.cloneNode(queuedMapPipelineIdentifier());
|
|
2307
2309
|
mapCount += candidate.count;
|
|
2308
2310
|
}
|
|
2309
2311
|
}
|
|
2310
2312
|
for (const { call, kind } of reorderCalls) {
|
|
2311
|
-
call.callee = core.types.cloneNode(mapReorderIdentifier);
|
|
2313
|
+
call.callee = core.types.cloneNode(mapReorderIdentifier());
|
|
2312
2314
|
if (kind === "reverse") mapReorderCount += 1;
|
|
2313
2315
|
else mapSortCount += 1;
|
|
2314
2316
|
}
|
|
@@ -2365,7 +2367,7 @@ function rewriteKeyedArraySortHints(root, hintedStateIndices, statesBySetter, he
|
|
|
2365
2367
|
)
|
|
2366
2368
|
]),
|
|
2367
2369
|
core.types.returnStatement(
|
|
2368
|
-
core.types.callExpression(core.types.cloneNode(helperIdentifier), [
|
|
2370
|
+
core.types.callExpression(core.types.cloneNode(helperIdentifier()), [
|
|
2369
2371
|
core.types.cloneNode(previous),
|
|
2370
2372
|
core.types.cloneNode(method),
|
|
2371
2373
|
...comparator ? [core.types.cloneNode(comparator, true)] : []
|
|
@@ -2427,7 +2429,7 @@ function rewriteKeyedArraySliceHints(root, hintedStateIndices, statesBySetter, h
|
|
|
2427
2429
|
)
|
|
2428
2430
|
]),
|
|
2429
2431
|
core.types.returnStatement(
|
|
2430
|
-
core.types.callExpression(core.types.cloneNode(helperIdentifier), [
|
|
2432
|
+
core.types.callExpression(core.types.cloneNode(helperIdentifier()), [
|
|
2431
2433
|
core.types.cloneNode(previous),
|
|
2432
2434
|
core.types.cloneNode(sliceMethod),
|
|
2433
2435
|
...bounds.map((bound) => core.types.cloneNode(bound, true))
|
|
@@ -2489,7 +2491,7 @@ function rewriteKeyedArrayFilterHints(root, hintedStateIndices, statesBySetter,
|
|
|
2489
2491
|
)
|
|
2490
2492
|
]),
|
|
2491
2493
|
core.types.returnStatement(
|
|
2492
|
-
core.types.callExpression(core.types.cloneNode(helperIdentifier), [
|
|
2494
|
+
core.types.callExpression(core.types.cloneNode(helperIdentifier()), [
|
|
2493
2495
|
core.types.cloneNode(previous),
|
|
2494
2496
|
core.types.cloneNode(filterMethod),
|
|
2495
2497
|
core.types.cloneNode(predicate, true)
|
|
@@ -2594,9 +2596,9 @@ function prepareKeyedCollectionUpdater(updater, kind, updateHelper, mutationHelp
|
|
|
2594
2596
|
)
|
|
2595
2597
|
]),
|
|
2596
2598
|
core.types.returnStatement(
|
|
2597
|
-
core.types.callExpression(core.types.cloneNode(updateHelper), [
|
|
2599
|
+
core.types.callExpression(core.types.cloneNode(updateHelper()), [
|
|
2598
2600
|
core.types.cloneNode(previous),
|
|
2599
|
-
core.types.callExpression(core.types.cloneNode(mutationHelper), [
|
|
2601
|
+
core.types.callExpression(core.types.cloneNode(mutationHelper()), [
|
|
2600
2602
|
core.types.cloneNode(collection),
|
|
2601
2603
|
core.types.memberExpression(core.types.cloneNode(collection), core.types.cloneNode(updater.body.callee.property)),
|
|
2602
2604
|
core.types.stringLiteral(operation),
|
|
@@ -2731,7 +2733,7 @@ function prepareKeyedCollectionUpdater(updater, kind, updateHelper, mutationHelp
|
|
|
2731
2733
|
const operation = collectionMutationOperation(kind, callee.property.name);
|
|
2732
2734
|
if (!collectionMutationArgumentsAreValid(operation, path.node.arguments)) return;
|
|
2733
2735
|
path.replaceWith(
|
|
2734
|
-
core.types.callExpression(core.types.cloneNode(mutationHelper), [
|
|
2736
|
+
core.types.callExpression(core.types.cloneNode(mutationHelper()), [
|
|
2735
2737
|
core.types.cloneNode(callee.object),
|
|
2736
2738
|
core.types.memberExpression(core.types.cloneNode(callee.object), core.types.cloneNode(callee.property)),
|
|
2737
2739
|
core.types.stringLiteral(operation),
|
|
@@ -2742,7 +2744,7 @@ function prepareKeyedCollectionUpdater(updater, kind, updateHelper, mutationHelp
|
|
|
2742
2744
|
},
|
|
2743
2745
|
ReturnStatement(path) {
|
|
2744
2746
|
if (path.getFunctionParent()?.node !== functionPath?.node || !path.node.argument) return;
|
|
2745
|
-
path.node.argument = core.types.callExpression(core.types.cloneNode(updateHelper), [
|
|
2747
|
+
path.node.argument = core.types.callExpression(core.types.cloneNode(updateHelper()), [
|
|
2746
2748
|
core.types.cloneNode(clonedPrevious),
|
|
2747
2749
|
core.types.cloneNode(path.node.argument, true),
|
|
2748
2750
|
core.types.stringLiteral(kind)
|
|
@@ -3347,6 +3349,10 @@ function analyzeKeyedRowTree(row, renderCallback, safeGlobals, compilerSetters,
|
|
|
3347
3349
|
return "compiled keyed rows support host elements only";
|
|
3348
3350
|
}
|
|
3349
3351
|
if (isForeignContent(element)) return "compiled keyed rows do not support SVG yet";
|
|
3352
|
+
if (tag.name === "script") return "script elements require React ownership";
|
|
3353
|
+
if (tag.name === "title" || tag.name === "meta") {
|
|
3354
|
+
return "document metadata requires React ownership";
|
|
3355
|
+
}
|
|
3350
3356
|
const attributeNames = new Set(
|
|
3351
3357
|
element.openingElement.attributes.filter((attribute) => core.types.isJSXAttribute(attribute)).map(jsxAttributeName).filter((name) => name !== void 0)
|
|
3352
3358
|
);
|
|
@@ -3745,6 +3751,10 @@ function analyzeHostConditionalTree(branch, safeGlobals, allowStaticEvents = fal
|
|
|
3745
3751
|
return "compiler-owned conditionals support host elements only";
|
|
3746
3752
|
}
|
|
3747
3753
|
if (isForeignContent(element)) return "compiler-owned conditionals do not support SVG yet";
|
|
3754
|
+
if (tag.name === "script") return "script elements require React ownership";
|
|
3755
|
+
if (tag.name === "title" || tag.name === "meta") {
|
|
3756
|
+
return "document metadata requires React ownership";
|
|
3757
|
+
}
|
|
3748
3758
|
for (const attribute of element.openingElement.attributes) {
|
|
3749
3759
|
if (core.types.isJSXSpreadAttribute(attribute)) {
|
|
3750
3760
|
if (statefulOnly && !needsStaticBinding(attribute.argument)) continue;
|
|
@@ -3870,6 +3880,10 @@ function analyzeRecursiveHostTree(branch, statesByValue, safeGlobals, listNames,
|
|
|
3870
3880
|
if (isForeignContent(element)) {
|
|
3871
3881
|
return "recursive compiler-owned blocks do not support SVG yet";
|
|
3872
3882
|
}
|
|
3883
|
+
if (tag.name === "script") return "script elements require React ownership";
|
|
3884
|
+
if (tag.name === "title" || tag.name === "meta") {
|
|
3885
|
+
return "document metadata requires React ownership";
|
|
3886
|
+
}
|
|
3873
3887
|
for (const attribute of element.openingElement.attributes) {
|
|
3874
3888
|
if (core.types.isJSXSpreadAttribute(attribute)) {
|
|
3875
3889
|
return "recursive compiler-owned blocks do not support JSX attribute spreads";
|
|
@@ -6156,7 +6170,13 @@ function analyzeHostTree(root, statesByValue, safeGlobals, conditionalExpression
|
|
|
6156
6170
|
}
|
|
6157
6171
|
const expression = attribute.value.expression;
|
|
6158
6172
|
const dependencies = collectStateDependencies(expression, statesByValue);
|
|
6159
|
-
if (dependencies.length === 0
|
|
6173
|
+
if (dependencies.length === 0) continue;
|
|
6174
|
+
if (/^on[A-Z]/.test(name)) {
|
|
6175
|
+
if (!core.types.isArrowFunctionExpression(expression) && !core.types.isFunctionExpression(expression)) {
|
|
6176
|
+
return "stateful event handler selection requires React ownership";
|
|
6177
|
+
}
|
|
6178
|
+
continue;
|
|
6179
|
+
}
|
|
6160
6180
|
if (name === "style") {
|
|
6161
6181
|
const reason2 = analyzeStyle(expression, path);
|
|
6162
6182
|
if (reason2) return reason2;
|
|
@@ -7382,6 +7402,14 @@ function compileCandidate(candidate, createComponentIdentifier, keyedMapUpdateId
|
|
|
7382
7402
|
appliedKeyedMapUpdateHints > 0 || appliedKeyedArrayAppendHints > 0,
|
|
7383
7403
|
appliedKeyedArrayAppendHints > 0 && appliedKeyedMapUpdateHints === 0
|
|
7384
7404
|
);
|
|
7405
|
+
for (const feature of runtimeFeatures) {
|
|
7406
|
+
if (!runtimeFeatureIdentifiers.has(feature)) {
|
|
7407
|
+
runtimeFeatureIdentifiers.set(
|
|
7408
|
+
feature,
|
|
7409
|
+
path.scope.getProgramParent().generateUidIdentifier(COMPILER_RUNTIME_FEATURE_EXPORTS[feature])
|
|
7410
|
+
);
|
|
7411
|
+
}
|
|
7412
|
+
}
|
|
7385
7413
|
markShortCircuitBindings(analysis.bindings || []);
|
|
7386
7414
|
assignStableBindingTargets(analysis.bindings || []);
|
|
7387
7415
|
const stateParameter = path.scope.generateUidIdentifier("farmState");
|
|
@@ -7510,8 +7538,17 @@ function compileCandidate(candidate, createComponentIdentifier, keyedMapUpdateId
|
|
|
7510
7538
|
for (const feature of runtimeFeatures) usedRuntimeFeatures.add(feature);
|
|
7511
7539
|
return void 0;
|
|
7512
7540
|
}
|
|
7513
|
-
function collectCandidates(programPath) {
|
|
7541
|
+
function collectCandidates(programPath, options, moduleSelected) {
|
|
7514
7542
|
const candidates = [];
|
|
7543
|
+
function collect(name, path, statementPath) {
|
|
7544
|
+
const functionDirectives = new Set(
|
|
7545
|
+
core.types.isBlockStatement(path.node.body) ? directiveValues(path.node.body) : []
|
|
7546
|
+
);
|
|
7547
|
+
const explicitlySelected = moduleSelected || functionDirectives.has(options.directive);
|
|
7548
|
+
if (functionDirectives.has("use no compiler")) return;
|
|
7549
|
+
if (options.mode === "annotation" && !explicitlySelected) return;
|
|
7550
|
+
candidates.push({ name, path, statementPath, explicitlySelected });
|
|
7551
|
+
}
|
|
7515
7552
|
programPath.traverse({
|
|
7516
7553
|
FunctionDeclaration(path) {
|
|
7517
7554
|
if (!path.node.id || !isComponentName(path.node.id.name)) return;
|
|
@@ -7519,11 +7556,7 @@ function collectCandidates(programPath) {
|
|
|
7519
7556
|
if (!parent.isProgram() && !parent.isExportNamedDeclaration() && !parent.isExportDefaultDeclaration()) {
|
|
7520
7557
|
return;
|
|
7521
7558
|
}
|
|
7522
|
-
|
|
7523
|
-
name: path.node.id.name,
|
|
7524
|
-
path,
|
|
7525
|
-
statementPath: parent.isProgram() ? path : parent
|
|
7526
|
-
});
|
|
7559
|
+
collect(path.node.id.name, path, parent.isProgram() ? path : parent);
|
|
7527
7560
|
},
|
|
7528
7561
|
VariableDeclarator(path) {
|
|
7529
7562
|
if (!core.types.isIdentifier(path.node.id) || !isComponentName(path.node.id.name) || !core.types.isFunctionExpression(path.node.init) && !core.types.isArrowFunctionExpression(path.node.init)) {
|
|
@@ -7534,11 +7567,7 @@ function collectCandidates(programPath) {
|
|
|
7534
7567
|
if (!statement) return;
|
|
7535
7568
|
const topLevel = statement.isProgram() ? declaration : statement.isExportNamedDeclaration() && statement.parentPath.isProgram() ? statement : null;
|
|
7536
7569
|
if (!topLevel) return;
|
|
7537
|
-
|
|
7538
|
-
name: path.node.id.name,
|
|
7539
|
-
path: path.get("init"),
|
|
7540
|
-
statementPath: topLevel
|
|
7541
|
-
});
|
|
7570
|
+
collect(path.node.id.name, path.get("init"), topLevel);
|
|
7542
7571
|
}
|
|
7543
7572
|
});
|
|
7544
7573
|
return candidates;
|
|
@@ -7608,101 +7637,85 @@ async function compileReactModule(code, id, options) {
|
|
|
7608
7637
|
}
|
|
7609
7638
|
}
|
|
7610
7639
|
}
|
|
7611
|
-
const candidates = collectCandidates(
|
|
7640
|
+
const candidates = collectCandidates(
|
|
7641
|
+
programPath,
|
|
7642
|
+
options,
|
|
7643
|
+
moduleDirectives.has(options.directive)
|
|
7644
|
+
);
|
|
7645
|
+
if (candidates.length === 0) return;
|
|
7612
7646
|
const createComponentIdentifier = programPath.scope.generateUidIdentifier("createCompiledComponent");
|
|
7613
7647
|
const createRefreshComponentIdentifier = programPath.scope.generateUidIdentifier("createRefreshComponent");
|
|
7614
7648
|
const createProductionComponentIdentifier = programPath.scope.generateUidIdentifier(
|
|
7615
7649
|
"createProductionComponent"
|
|
7616
7650
|
);
|
|
7617
|
-
const
|
|
7618
|
-
|
|
7619
|
-
|
|
7620
|
-
|
|
7621
|
-
|
|
7622
|
-
);
|
|
7623
|
-
const keyedArrayFilterIdentifier =
|
|
7624
|
-
|
|
7625
|
-
);
|
|
7626
|
-
const keyedArrayMapPipelineIdentifier = programPath.scope.generateUidIdentifier(
|
|
7651
|
+
const helperIdentifier = (name) => {
|
|
7652
|
+
let identifier;
|
|
7653
|
+
return () => identifier ?? (identifier = programPath.scope.generateUidIdentifier(name));
|
|
7654
|
+
};
|
|
7655
|
+
const keyedMapUpdateIdentifier = helperIdentifier("createCompilerKeyedMapUpdate");
|
|
7656
|
+
const keyedArrayAppendIdentifier = helperIdentifier("createCompilerKeyedArrayAppend");
|
|
7657
|
+
const keyedArrayFilterIdentifier = helperIdentifier("createCompilerKeyedArrayFilter");
|
|
7658
|
+
const keyedArrayMapPipelineIdentifier = helperIdentifier(
|
|
7627
7659
|
"createCompilerKeyedArrayMapPipeline"
|
|
7628
7660
|
);
|
|
7629
|
-
const keyedArrayMappedStructuralAppendIdentifier =
|
|
7661
|
+
const keyedArrayMappedStructuralAppendIdentifier = helperIdentifier(
|
|
7630
7662
|
"createCompilerKeyedArrayMappedStructuralAppend"
|
|
7631
7663
|
);
|
|
7632
|
-
const keyedArrayStructuralAppendMapPipelineIdentifier =
|
|
7664
|
+
const keyedArrayStructuralAppendMapPipelineIdentifier = helperIdentifier(
|
|
7633
7665
|
"createCompilerKeyedArrayStructuralAppendMapPipeline"
|
|
7634
7666
|
);
|
|
7635
|
-
const keyedArrayMappedStructuralPrependIdentifier =
|
|
7667
|
+
const keyedArrayMappedStructuralPrependIdentifier = helperIdentifier(
|
|
7636
7668
|
"createCompilerKeyedArrayMappedStructuralPrepend"
|
|
7637
7669
|
);
|
|
7638
|
-
const keyedArrayStructuralPrependMapPipelineIdentifier =
|
|
7670
|
+
const keyedArrayStructuralPrependMapPipelineIdentifier = helperIdentifier(
|
|
7639
7671
|
"createCompilerKeyedArrayStructuralPrependMapPipeline"
|
|
7640
7672
|
);
|
|
7641
|
-
const keyedArrayQueuedMapPipelineIdentifier =
|
|
7673
|
+
const keyedArrayQueuedMapPipelineIdentifier = helperIdentifier(
|
|
7642
7674
|
"createCompilerKeyedArrayQueuedMapPipeline"
|
|
7643
7675
|
);
|
|
7644
|
-
const keyedArrayRollingWindowMapPipelineIdentifier =
|
|
7676
|
+
const keyedArrayRollingWindowMapPipelineIdentifier = helperIdentifier(
|
|
7645
7677
|
"createCompilerKeyedArrayRollingWindowMapPipeline"
|
|
7646
7678
|
);
|
|
7647
|
-
const keyedArrayMappedRollingWindowIdentifier =
|
|
7679
|
+
const keyedArrayMappedRollingWindowIdentifier = helperIdentifier(
|
|
7648
7680
|
"createCompilerKeyedArrayMappedRollingWindow"
|
|
7649
7681
|
);
|
|
7650
|
-
const keyedArrayMapReorderIdentifier =
|
|
7682
|
+
const keyedArrayMapReorderIdentifier = helperIdentifier(
|
|
7651
7683
|
"createCompilerKeyedArrayMapReorder"
|
|
7652
7684
|
);
|
|
7653
|
-
const keyedArrayMappedStructuralIdentifier =
|
|
7685
|
+
const keyedArrayMappedStructuralIdentifier = helperIdentifier(
|
|
7654
7686
|
"finalizeCompilerKeyedArrayMappedStructuralUpdate"
|
|
7655
7687
|
);
|
|
7656
|
-
const keyedArrayPrependIdentifier =
|
|
7657
|
-
|
|
7658
|
-
);
|
|
7659
|
-
const keyedArrayPositionIdentifier = programPath.scope.generateUidIdentifier(
|
|
7688
|
+
const keyedArrayPrependIdentifier = helperIdentifier("createCompilerKeyedArrayPrepend");
|
|
7689
|
+
const keyedArrayPositionIdentifier = helperIdentifier(
|
|
7660
7690
|
"createCompilerKeyedArrayPositionUpdate"
|
|
7661
7691
|
);
|
|
7662
|
-
const keyedArrayBatchInsertIdentifier =
|
|
7692
|
+
const keyedArrayBatchInsertIdentifier = helperIdentifier(
|
|
7663
7693
|
"createCompilerKeyedArrayBatchInsert"
|
|
7664
7694
|
);
|
|
7665
|
-
const keyedArrayWindowReplaceIdentifier =
|
|
7695
|
+
const keyedArrayWindowReplaceIdentifier = helperIdentifier(
|
|
7666
7696
|
"createCompilerKeyedArrayWindowReplace"
|
|
7667
7697
|
);
|
|
7668
|
-
const keyedArrayReorderIdentifier =
|
|
7669
|
-
|
|
7670
|
-
);
|
|
7671
|
-
const keyedArrayStructuralReorderIdentifier = programPath.scope.generateUidIdentifier(
|
|
7698
|
+
const keyedArrayReorderIdentifier = helperIdentifier("createCompilerKeyedArrayReorder");
|
|
7699
|
+
const keyedArrayStructuralReorderIdentifier = helperIdentifier(
|
|
7672
7700
|
"createCompilerKeyedArrayStructuralReorder"
|
|
7673
7701
|
);
|
|
7674
|
-
const keyedArraySortIdentifier =
|
|
7675
|
-
|
|
7676
|
-
);
|
|
7677
|
-
const keyedArrayStructuralSortIdentifier = programPath.scope.generateUidIdentifier(
|
|
7702
|
+
const keyedArraySortIdentifier = helperIdentifier("createCompilerKeyedArraySort");
|
|
7703
|
+
const keyedArrayStructuralSortIdentifier = helperIdentifier(
|
|
7678
7704
|
"createCompilerKeyedArrayStructuralSort"
|
|
7679
7705
|
);
|
|
7680
|
-
const keyedArrayRollingWindowIdentifier =
|
|
7706
|
+
const keyedArrayRollingWindowIdentifier = helperIdentifier(
|
|
7681
7707
|
"createCompilerKeyedArrayRollingWindow"
|
|
7682
7708
|
);
|
|
7683
|
-
const keyedArraySliceIdentifier =
|
|
7684
|
-
|
|
7685
|
-
);
|
|
7686
|
-
const keyedCollectionUpdateIdentifier = programPath.scope.generateUidIdentifier(
|
|
7709
|
+
const keyedArraySliceIdentifier = helperIdentifier("createCompilerKeyedArraySlice");
|
|
7710
|
+
const keyedCollectionUpdateIdentifier = helperIdentifier(
|
|
7687
7711
|
"createCompilerKeyedCollectionUpdate"
|
|
7688
7712
|
);
|
|
7689
|
-
const keyedCollectionMutationIdentifier =
|
|
7713
|
+
const keyedCollectionMutationIdentifier = helperIdentifier(
|
|
7690
7714
|
"applyCompilerKeyedCollectionMutation"
|
|
7691
7715
|
);
|
|
7692
|
-
const runtimeFeatureIdentifiers = new Map(
|
|
7693
|
-
Object.entries(COMPILER_RUNTIME_FEATURE_EXPORTS).map(([feature, exportName]) => [
|
|
7694
|
-
feature,
|
|
7695
|
-
programPath.scope.generateUidIdentifier(exportName)
|
|
7696
|
-
])
|
|
7697
|
-
);
|
|
7716
|
+
const runtimeFeatureIdentifiers = /* @__PURE__ */ new Map();
|
|
7698
7717
|
const usedRuntimeFeatures = /* @__PURE__ */ new Set();
|
|
7699
7718
|
for (const candidate of candidates) {
|
|
7700
|
-
const functionDirectives = new Set(
|
|
7701
|
-
core.types.isBlockStatement(candidate.path.node.body) ? directiveValues(candidate.path.node.body) : []
|
|
7702
|
-
);
|
|
7703
|
-
const explicitlySelected = moduleDirectives.has(options.directive) || functionDirectives.has(options.directive);
|
|
7704
|
-
if (functionDirectives.has("use no compiler")) continue;
|
|
7705
|
-
if (options.mode === "annotation" && !explicitlySelected) continue;
|
|
7706
7719
|
const reason = compileCandidate(
|
|
7707
7720
|
candidate,
|
|
7708
7721
|
createComponentIdentifier,
|
|
@@ -7745,7 +7758,7 @@ async function compileReactModule(code, id, options) {
|
|
|
7745
7758
|
diagnostics.push({
|
|
7746
7759
|
component: candidate.name,
|
|
7747
7760
|
reason,
|
|
7748
|
-
selected: explicitlySelected
|
|
7761
|
+
selected: candidate.explicitlySelected
|
|
7749
7762
|
});
|
|
7750
7763
|
} else {
|
|
7751
7764
|
compiled.push(candidate.name);
|
|
@@ -7788,73 +7801,73 @@ async function compileReactModule(code, id, options) {
|
|
|
7788
7801
|
),
|
|
7789
7802
|
...optimizationCounts.keyedMapUpdateHints > compilerUsage.keyedArrayMapUpdateHints ? [
|
|
7790
7803
|
core.types.importSpecifier(
|
|
7791
|
-
keyedMapUpdateIdentifier,
|
|
7804
|
+
keyedMapUpdateIdentifier(),
|
|
7792
7805
|
core.types.identifier("createCompilerKeyedMapUpdate")
|
|
7793
7806
|
)
|
|
7794
7807
|
] : [],
|
|
7795
7808
|
...hasEagerKeyedArrayMapUpdateHints ? [
|
|
7796
7809
|
core.types.importSpecifier(
|
|
7797
|
-
keyedArrayMapPipelineIdentifier,
|
|
7810
|
+
keyedArrayMapPipelineIdentifier(),
|
|
7798
7811
|
core.types.identifier("createCompilerKeyedArrayMapPipeline")
|
|
7799
7812
|
)
|
|
7800
7813
|
] : [],
|
|
7801
7814
|
...compilerUsage.keyedArrayStructuralAppendMapHints > 0 ? [
|
|
7802
7815
|
core.types.importSpecifier(
|
|
7803
|
-
keyedArrayStructuralAppendMapPipelineIdentifier,
|
|
7816
|
+
keyedArrayStructuralAppendMapPipelineIdentifier(),
|
|
7804
7817
|
core.types.identifier("createCompilerKeyedArrayStructuralAppendMapPipeline")
|
|
7805
7818
|
)
|
|
7806
7819
|
] : [],
|
|
7807
7820
|
...compilerUsage.keyedArrayStructuralPrependMapHints > 0 ? [
|
|
7808
7821
|
core.types.importSpecifier(
|
|
7809
|
-
keyedArrayStructuralPrependMapPipelineIdentifier,
|
|
7822
|
+
keyedArrayStructuralPrependMapPipelineIdentifier(),
|
|
7810
7823
|
core.types.identifier("createCompilerKeyedArrayStructuralPrependMapPipeline")
|
|
7811
7824
|
)
|
|
7812
7825
|
] : [],
|
|
7813
7826
|
...hasKeyedArrayMapReorderHints ? [
|
|
7814
7827
|
core.types.importSpecifier(
|
|
7815
|
-
keyedArrayMapReorderIdentifier,
|
|
7828
|
+
keyedArrayMapReorderIdentifier(),
|
|
7816
7829
|
core.types.identifier("createCompilerKeyedArrayMapReorder")
|
|
7817
7830
|
)
|
|
7818
7831
|
] : [],
|
|
7819
7832
|
...compilerUsage.keyedArrayMappedStructuralHints > 0 ? [
|
|
7820
7833
|
core.types.importSpecifier(
|
|
7821
|
-
keyedArrayMappedStructuralIdentifier,
|
|
7834
|
+
keyedArrayMappedStructuralIdentifier(),
|
|
7822
7835
|
core.types.identifier("finalizeCompilerKeyedArrayMappedStructuralUpdate")
|
|
7823
7836
|
)
|
|
7824
7837
|
] : [],
|
|
7825
7838
|
...compilerUsage.keyedArrayMappedStructuralAppendHints > 0 || compilerUsage.keyedArrayMappedRollingWindowHints > compilerUsage.keyedArrayMappedRollingWindowChainHints ? [
|
|
7826
7839
|
core.types.importSpecifier(
|
|
7827
|
-
keyedArrayMappedStructuralAppendIdentifier,
|
|
7840
|
+
keyedArrayMappedStructuralAppendIdentifier(),
|
|
7828
7841
|
core.types.identifier("createCompilerKeyedArrayMappedStructuralAppend")
|
|
7829
7842
|
)
|
|
7830
7843
|
] : [],
|
|
7831
7844
|
...compilerUsage.keyedArrayMappedStructuralPrependHints > 0 ? [
|
|
7832
7845
|
core.types.importSpecifier(
|
|
7833
|
-
keyedArrayMappedStructuralPrependIdentifier,
|
|
7846
|
+
keyedArrayMappedStructuralPrependIdentifier(),
|
|
7834
7847
|
core.types.identifier("createCompilerKeyedArrayMappedStructuralPrepend")
|
|
7835
7848
|
)
|
|
7836
7849
|
] : [],
|
|
7837
7850
|
...compilerUsage.keyedArrayQueuedMapUpdateHints > 0 ? [
|
|
7838
7851
|
core.types.importSpecifier(
|
|
7839
|
-
keyedArrayQueuedMapPipelineIdentifier,
|
|
7852
|
+
keyedArrayQueuedMapPipelineIdentifier(),
|
|
7840
7853
|
core.types.identifier("createCompilerKeyedArrayQueuedMapPipeline")
|
|
7841
7854
|
)
|
|
7842
7855
|
] : [],
|
|
7843
7856
|
...compilerUsage.keyedArrayMappedRollingWindowChainHints > 0 ? [
|
|
7844
7857
|
core.types.importSpecifier(
|
|
7845
|
-
keyedArrayRollingWindowMapPipelineIdentifier,
|
|
7858
|
+
keyedArrayRollingWindowMapPipelineIdentifier(),
|
|
7846
7859
|
core.types.identifier("createCompilerKeyedArrayRollingWindowMapPipeline")
|
|
7847
7860
|
)
|
|
7848
7861
|
] : [],
|
|
7849
7862
|
...compilerUsage.keyedArrayMappedRollingWindowChainHints > 0 ? [
|
|
7850
7863
|
core.types.importSpecifier(
|
|
7851
|
-
keyedArrayMappedRollingWindowIdentifier,
|
|
7864
|
+
keyedArrayMappedRollingWindowIdentifier(),
|
|
7852
7865
|
core.types.identifier("createCompilerKeyedArrayMappedRollingWindow")
|
|
7853
7866
|
)
|
|
7854
7867
|
] : [],
|
|
7855
7868
|
...hasUnmappedKeyedArrayAppendHints || compilerUsage.keyedArrayStructuralRollingWindowHints > 0 ? [
|
|
7856
7869
|
core.types.importSpecifier(
|
|
7857
|
-
keyedArrayAppendIdentifier,
|
|
7870
|
+
keyedArrayAppendIdentifier(),
|
|
7858
7871
|
core.types.identifier(
|
|
7859
7872
|
hasKeyedArrayStructuralAppendHints ? "createCompilerKeyedArrayStructuralAppend" : "createCompilerKeyedArrayAppend"
|
|
7860
7873
|
)
|
|
@@ -7862,13 +7875,13 @@ async function compileReactModule(code, id, options) {
|
|
|
7862
7875
|
] : [],
|
|
7863
7876
|
...optimizationCounts.keyedArrayFilterHints > 0 ? [
|
|
7864
7877
|
core.types.importSpecifier(
|
|
7865
|
-
keyedArrayFilterIdentifier,
|
|
7878
|
+
keyedArrayFilterIdentifier(),
|
|
7866
7879
|
core.types.identifier("createCompilerKeyedArrayFilter")
|
|
7867
7880
|
)
|
|
7868
7881
|
] : [],
|
|
7869
7882
|
...hasUnmappedKeyedArrayPrependHints ? [
|
|
7870
7883
|
core.types.importSpecifier(
|
|
7871
|
-
keyedArrayPrependIdentifier,
|
|
7884
|
+
keyedArrayPrependIdentifier(),
|
|
7872
7885
|
core.types.identifier(
|
|
7873
7886
|
hasKeyedArrayStructuralPrependHints ? "createCompilerKeyedArrayStructuralPrepend" : "createCompilerKeyedArrayPrepend"
|
|
7874
7887
|
)
|
|
@@ -7876,65 +7889,65 @@ async function compileReactModule(code, id, options) {
|
|
|
7876
7889
|
] : [],
|
|
7877
7890
|
...optimizationCounts.keyedArrayPositionHints > compilerUsage.keyedArrayBatchInsertHints + compilerUsage.keyedArrayWindowReplaceHints ? [
|
|
7878
7891
|
core.types.importSpecifier(
|
|
7879
|
-
keyedArrayPositionIdentifier,
|
|
7892
|
+
keyedArrayPositionIdentifier(),
|
|
7880
7893
|
core.types.identifier("createCompilerKeyedArrayPositionUpdate")
|
|
7881
7894
|
)
|
|
7882
7895
|
] : [],
|
|
7883
7896
|
...compilerUsage.keyedArrayBatchInsertHints > 0 ? [
|
|
7884
7897
|
core.types.importSpecifier(
|
|
7885
|
-
keyedArrayBatchInsertIdentifier,
|
|
7898
|
+
keyedArrayBatchInsertIdentifier(),
|
|
7886
7899
|
core.types.identifier("createCompilerKeyedArrayBatchInsert")
|
|
7887
7900
|
)
|
|
7888
7901
|
] : [],
|
|
7889
7902
|
...compilerUsage.keyedArrayWindowReplaceHints > 0 ? [
|
|
7890
7903
|
core.types.importSpecifier(
|
|
7891
|
-
keyedArrayWindowReplaceIdentifier,
|
|
7904
|
+
keyedArrayWindowReplaceIdentifier(),
|
|
7892
7905
|
core.types.identifier("createCompilerKeyedArrayWindowReplace")
|
|
7893
7906
|
)
|
|
7894
7907
|
] : [],
|
|
7895
7908
|
...optimizationCounts.keyedArrayReorderHints > compilerUsage.keyedArrayStructuralReorderHints + compilerUsage.keyedArrayMapReorderHints ? [
|
|
7896
7909
|
core.types.importSpecifier(
|
|
7897
|
-
keyedArrayReorderIdentifier,
|
|
7910
|
+
keyedArrayReorderIdentifier(),
|
|
7898
7911
|
core.types.identifier("createCompilerKeyedArrayReorder")
|
|
7899
7912
|
)
|
|
7900
7913
|
] : [],
|
|
7901
7914
|
...compilerUsage.keyedArrayStructuralReorderHints > 0 ? [
|
|
7902
7915
|
core.types.importSpecifier(
|
|
7903
|
-
keyedArrayStructuralReorderIdentifier,
|
|
7916
|
+
keyedArrayStructuralReorderIdentifier(),
|
|
7904
7917
|
core.types.identifier("createCompilerKeyedArrayStructuralReorder")
|
|
7905
7918
|
)
|
|
7906
7919
|
] : [],
|
|
7907
7920
|
...optimizationCounts.keyedArraySortHints > compilerUsage.keyedArrayStructuralSortHints + compilerUsage.keyedArrayMapSortHints ? [
|
|
7908
7921
|
core.types.importSpecifier(
|
|
7909
|
-
keyedArraySortIdentifier,
|
|
7922
|
+
keyedArraySortIdentifier(),
|
|
7910
7923
|
core.types.identifier("createCompilerKeyedArraySort")
|
|
7911
7924
|
)
|
|
7912
7925
|
] : [],
|
|
7913
7926
|
...compilerUsage.keyedArrayStructuralSortHints > 0 ? [
|
|
7914
7927
|
core.types.importSpecifier(
|
|
7915
|
-
keyedArrayStructuralSortIdentifier,
|
|
7928
|
+
keyedArrayStructuralSortIdentifier(),
|
|
7916
7929
|
core.types.identifier("createCompilerKeyedArrayStructuralSort")
|
|
7917
7930
|
)
|
|
7918
7931
|
] : [],
|
|
7919
7932
|
...optimizationCounts.keyedArrayRollingWindowHints > compilerUsage.keyedArrayMappedRollingWindowHints + compilerUsage.keyedArrayStructuralRollingWindowHints ? [
|
|
7920
7933
|
core.types.importSpecifier(
|
|
7921
|
-
keyedArrayRollingWindowIdentifier,
|
|
7934
|
+
keyedArrayRollingWindowIdentifier(),
|
|
7922
7935
|
core.types.identifier("createCompilerKeyedArrayRollingWindow")
|
|
7923
7936
|
)
|
|
7924
7937
|
] : [],
|
|
7925
7938
|
...optimizationCounts.keyedArraySliceHints > 0 || optimizationCounts.keyedArrayRollingWindowHints > 0 ? [
|
|
7926
7939
|
core.types.importSpecifier(
|
|
7927
|
-
keyedArraySliceIdentifier,
|
|
7940
|
+
keyedArraySliceIdentifier(),
|
|
7928
7941
|
core.types.identifier("createCompilerKeyedArraySlice")
|
|
7929
7942
|
)
|
|
7930
7943
|
] : [],
|
|
7931
7944
|
...optimizationCounts.keyedCollectionUpdateHints > 0 ? [
|
|
7932
7945
|
core.types.importSpecifier(
|
|
7933
|
-
keyedCollectionUpdateIdentifier,
|
|
7946
|
+
keyedCollectionUpdateIdentifier(),
|
|
7934
7947
|
core.types.identifier("createCompilerKeyedCollectionUpdate")
|
|
7935
7948
|
),
|
|
7936
7949
|
core.types.importSpecifier(
|
|
7937
|
-
keyedCollectionMutationIdentifier,
|
|
7950
|
+
keyedCollectionMutationIdentifier(),
|
|
7938
7951
|
core.types.identifier("applyCompilerKeyedCollectionMutation")
|
|
7939
7952
|
)
|
|
7940
7953
|
] : [],
|