@farm.js/react 0.1.0-beta.6 → 0.1.0-beta.8
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 +79 -13
- package/dist/compiler-runtime.cjs +713 -31
- package/dist/compiler-runtime.cjs.map +1 -1
- package/dist/compiler-runtime.d.mts +25 -3
- package/dist/compiler-runtime.d.ts +25 -3
- package/dist/compiler-runtime.mjs +695 -32
- package/dist/compiler-runtime.mjs.map +1 -1
- package/dist/vite.cjs +206 -15
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.mjs +206 -15
- package/dist/vite.mjs.map +1 -1
- package/package.json +2 -2
package/dist/vite.cjs
CHANGED
|
@@ -70,36 +70,52 @@ var COMPILER_RUNTIME_FEATURE_EXPORTS = {
|
|
|
70
70
|
"keyed-rows": "keyedRowsRuntimeFeature",
|
|
71
71
|
"keyed-rows-hinted": "keyedRowsHintedRuntimeFeature",
|
|
72
72
|
"keyed-rows-position-hinted": "keyedRowsPositionHintedRuntimeFeature",
|
|
73
|
+
"keyed-rows-batch-position-hinted": "keyedRowsBatchPositionHintedRuntimeFeature",
|
|
74
|
+
"keyed-rows-window-position-hinted": "keyedRowsWindowPositionHintedRuntimeFeature",
|
|
73
75
|
"keyed-rows-reorder-hinted": "keyedRowsReorderHintedRuntimeFeature",
|
|
74
76
|
"keyed-rows-all-hinted": "keyedRowsAllHintedRuntimeFeature",
|
|
75
77
|
"keyed-rows-every-hinted": "keyedRowsEveryHintedRuntimeFeature",
|
|
78
|
+
"keyed-rows-batch-every-hinted": "keyedRowsBatchEveryHintedRuntimeFeature",
|
|
79
|
+
"keyed-rows-window-every-hinted": "keyedRowsWindowEveryHintedRuntimeFeature",
|
|
76
80
|
"keyed-rows-filter-hinted": "keyedRowsFilterHintedRuntimeFeature",
|
|
77
81
|
"keyed-rows-prepend-hinted": "keyedRowsPrependHintedRuntimeFeature",
|
|
78
82
|
"keyed-rows-filter-prepend-hinted": "keyedRowsFilterPrependHintedRuntimeFeature",
|
|
79
83
|
"keyed-rows-conditional": "keyedRowsConditionalRuntimeFeature",
|
|
80
84
|
"keyed-rows-conditional-hinted": "keyedRowsConditionalHintedRuntimeFeature",
|
|
81
85
|
"keyed-rows-conditional-position-hinted": "keyedRowsConditionalPositionHintedRuntimeFeature",
|
|
86
|
+
"keyed-rows-conditional-batch-position-hinted": "keyedRowsConditionalBatchPositionHintedRuntimeFeature",
|
|
87
|
+
"keyed-rows-conditional-window-position-hinted": "keyedRowsConditionalWindowPositionHintedRuntimeFeature",
|
|
82
88
|
"keyed-rows-conditional-reorder-hinted": "keyedRowsConditionalReorderHintedRuntimeFeature",
|
|
83
89
|
"keyed-rows-conditional-all-hinted": "keyedRowsConditionalAllHintedRuntimeFeature",
|
|
84
90
|
"keyed-rows-conditional-every-hinted": "keyedRowsConditionalEveryHintedRuntimeFeature",
|
|
91
|
+
"keyed-rows-conditional-batch-every-hinted": "keyedRowsConditionalBatchEveryHintedRuntimeFeature",
|
|
92
|
+
"keyed-rows-conditional-window-every-hinted": "keyedRowsConditionalWindowEveryHintedRuntimeFeature",
|
|
85
93
|
"keyed-rows-conditional-filter-hinted": "keyedRowsConditionalFilterHintedRuntimeFeature",
|
|
86
94
|
"keyed-rows-conditional-prepend-hinted": "keyedRowsConditionalPrependHintedRuntimeFeature",
|
|
87
95
|
"keyed-rows-conditional-filter-prepend-hinted": "keyedRowsConditionalFilterPrependHintedRuntimeFeature",
|
|
88
96
|
"keyed-rows-host": "keyedRowsHostRuntimeFeature",
|
|
89
97
|
"keyed-rows-host-hinted": "keyedRowsHostHintedRuntimeFeature",
|
|
90
98
|
"keyed-rows-host-position-hinted": "keyedRowsHostPositionHintedRuntimeFeature",
|
|
99
|
+
"keyed-rows-host-batch-position-hinted": "keyedRowsHostBatchPositionHintedRuntimeFeature",
|
|
100
|
+
"keyed-rows-host-window-position-hinted": "keyedRowsHostWindowPositionHintedRuntimeFeature",
|
|
91
101
|
"keyed-rows-host-reorder-hinted": "keyedRowsHostReorderHintedRuntimeFeature",
|
|
92
102
|
"keyed-rows-host-all-hinted": "keyedRowsHostAllHintedRuntimeFeature",
|
|
93
103
|
"keyed-rows-host-every-hinted": "keyedRowsHostEveryHintedRuntimeFeature",
|
|
104
|
+
"keyed-rows-host-batch-every-hinted": "keyedRowsHostBatchEveryHintedRuntimeFeature",
|
|
105
|
+
"keyed-rows-host-window-every-hinted": "keyedRowsHostWindowEveryHintedRuntimeFeature",
|
|
94
106
|
"keyed-rows-host-filter-hinted": "keyedRowsHostFilterHintedRuntimeFeature",
|
|
95
107
|
"keyed-rows-host-prepend-hinted": "keyedRowsHostPrependHintedRuntimeFeature",
|
|
96
108
|
"keyed-rows-host-filter-prepend-hinted": "keyedRowsHostFilterPrependHintedRuntimeFeature",
|
|
97
109
|
"keyed-rows-complete": "keyedRowsCompleteRuntimeFeature",
|
|
98
110
|
"keyed-rows-complete-hinted": "keyedRowsCompleteHintedRuntimeFeature",
|
|
99
111
|
"keyed-rows-complete-position-hinted": "keyedRowsCompletePositionHintedRuntimeFeature",
|
|
112
|
+
"keyed-rows-complete-batch-position-hinted": "keyedRowsCompleteBatchPositionHintedRuntimeFeature",
|
|
113
|
+
"keyed-rows-complete-window-position-hinted": "keyedRowsCompleteWindowPositionHintedRuntimeFeature",
|
|
100
114
|
"keyed-rows-complete-reorder-hinted": "keyedRowsCompleteReorderHintedRuntimeFeature",
|
|
101
115
|
"keyed-rows-complete-all-hinted": "keyedRowsCompleteAllHintedRuntimeFeature",
|
|
102
116
|
"keyed-rows-complete-every-hinted": "keyedRowsCompleteEveryHintedRuntimeFeature",
|
|
117
|
+
"keyed-rows-complete-batch-every-hinted": "keyedRowsCompleteBatchEveryHintedRuntimeFeature",
|
|
118
|
+
"keyed-rows-complete-window-every-hinted": "keyedRowsCompleteWindowEveryHintedRuntimeFeature",
|
|
103
119
|
"keyed-rows-complete-filter-hinted": "keyedRowsCompleteFilterHintedRuntimeFeature",
|
|
104
120
|
"keyed-rows-complete-prepend-hinted": "keyedRowsCompletePrependHintedRuntimeFeature",
|
|
105
121
|
"keyed-rows-complete-filter-prepend-hinted": "keyedRowsCompleteFilterPrependHintedRuntimeFeature",
|
|
@@ -107,7 +123,7 @@ var COMPILER_RUNTIME_FEATURE_EXPORTS = {
|
|
|
107
123
|
"mixed-ranges": "mixedRangesRuntimeFeature",
|
|
108
124
|
component: "componentRuntimeFeature"
|
|
109
125
|
};
|
|
110
|
-
function runtimeFeaturesForPlans(plans, keyedMapUpdateHints, keyedArrayFilterHints, keyedArrayPrependHints, keyedArrayPositionHints, keyedArrayReorderHints, keyedArrayRollingWindowHints) {
|
|
126
|
+
function runtimeFeaturesForPlans(plans, keyedMapUpdateHints, keyedArrayFilterHints, keyedArrayPrependHints, keyedArrayPositionHints, keyedArrayBatchInsertHints, keyedArrayWindowReplaceHints, keyedArrayReorderHints, keyedArrayRollingWindowHints) {
|
|
111
127
|
const features = /* @__PURE__ */ new Set();
|
|
112
128
|
let keyedRowsHaveConditionals = false;
|
|
113
129
|
let keyedRowsHaveHostBlocks = false;
|
|
@@ -124,7 +140,7 @@ function runtimeFeaturesForPlans(plans, keyedMapUpdateHints, keyedArrayFilterHin
|
|
|
124
140
|
if (plans.some((plan) => plan.kind === "keyed-rows")) {
|
|
125
141
|
const keyedRowsFeature = keyedRowsHaveConditionals && keyedRowsHaveHostBlocks ? "keyed-rows-complete" : keyedRowsHaveConditionals ? "keyed-rows-conditional" : keyedRowsHaveHostBlocks ? "keyed-rows-host" : "keyed-rows";
|
|
126
142
|
const arrayRangeHints = keyedArrayRollingWindowHints || keyedArrayFilterHints || keyedArrayPrependHints;
|
|
127
|
-
const hintSuffix = keyedArrayPositionHints && (arrayRangeHints || keyedArrayReorderHints) || keyedArrayReorderHints && arrayRangeHints ? "-every-hinted" : keyedArrayRollingWindowHints ? "-all-hinted" : keyedArrayPositionHints ? "-position-hinted" : keyedArrayReorderHints ? "-reorder-hinted" : keyedArrayFilterHints && keyedArrayPrependHints ? "-filter-prepend-hinted" : keyedArrayFilterHints ? "-filter-hinted" : keyedArrayPrependHints ? "-prepend-hinted" : keyedMapUpdateHints ? "-hinted" : "";
|
|
143
|
+
const hintSuffix = keyedArrayWindowReplaceHints ? arrayRangeHints || keyedArrayReorderHints ? "-window-every-hinted" : "-window-position-hinted" : keyedArrayBatchInsertHints ? arrayRangeHints || keyedArrayReorderHints ? "-batch-every-hinted" : "-batch-position-hinted" : keyedArrayPositionHints && (arrayRangeHints || keyedArrayReorderHints) || keyedArrayReorderHints && arrayRangeHints ? "-every-hinted" : keyedArrayRollingWindowHints ? "-all-hinted" : keyedArrayPositionHints ? "-position-hinted" : keyedArrayReorderHints ? "-reorder-hinted" : keyedArrayFilterHints && keyedArrayPrependHints ? "-filter-prepend-hinted" : keyedArrayFilterHints ? "-filter-hinted" : keyedArrayPrependHints ? "-prepend-hinted" : keyedMapUpdateHints ? "-hinted" : "";
|
|
128
144
|
features.add(`${keyedRowsFeature}${hintSuffix}`);
|
|
129
145
|
}
|
|
130
146
|
return [...features].sort();
|
|
@@ -845,13 +861,28 @@ function staticSliceIndex(expression) {
|
|
|
845
861
|
}
|
|
846
862
|
return void 0;
|
|
847
863
|
}
|
|
848
|
-
function
|
|
864
|
+
function validateKeyedArrayPositionExpression(expression, safeGlobals) {
|
|
865
|
+
const isNumericLiteral = core.types.isNumericLiteral(expression) || core.types.isUnaryExpression(expression) && (expression.operator === "+" || expression.operator === "-") && core.types.isNumericLiteral(expression.argument);
|
|
866
|
+
if (isNumericLiteral && staticSliceIndex(expression) === void 0) {
|
|
867
|
+
return "non-safe-integer position literals";
|
|
868
|
+
}
|
|
869
|
+
return validateDerivedExpression(expression, safeGlobals);
|
|
870
|
+
}
|
|
871
|
+
function rewriteKeyedArrayPositionHints(root, hintedStateIndices, statesBySetter, helperIdentifier, batchInsertHelperIdentifier, windowReplaceHelperIdentifier, safeGlobals) {
|
|
849
872
|
if (hintedStateIndices.size === 0) {
|
|
850
|
-
return {
|
|
873
|
+
return {
|
|
874
|
+
root: core.types.cloneNode(root, true),
|
|
875
|
+
count: 0,
|
|
876
|
+
batchInsertCount: 0,
|
|
877
|
+
windowReplaceCount: 0,
|
|
878
|
+
stateIndices: /* @__PURE__ */ new Set()
|
|
879
|
+
};
|
|
851
880
|
}
|
|
852
881
|
const file = expressionFile(core.types.cloneNode(root, true));
|
|
853
882
|
const stateIndices = /* @__PURE__ */ new Set();
|
|
854
883
|
let count = 0;
|
|
884
|
+
let batchInsertCount = 0;
|
|
885
|
+
let windowReplaceCount = 0;
|
|
855
886
|
core.traverse(file, {
|
|
856
887
|
CallExpression(path) {
|
|
857
888
|
const callee = path.get("callee");
|
|
@@ -866,11 +897,17 @@ function rewriteKeyedArrayPositionHints(root, hintedStateIndices, statesBySetter
|
|
|
866
897
|
}
|
|
867
898
|
const methodName = updater.body.callee.property.name;
|
|
868
899
|
const args = updater.body.arguments;
|
|
869
|
-
const
|
|
870
|
-
|
|
871
|
-
const
|
|
872
|
-
const
|
|
873
|
-
if (
|
|
900
|
+
const toSplicedDeleteCount = methodName === "toSpliced" && args.length >= 2 && core.types.isNumericLiteral(args[1]) ? args[1].value : void 0;
|
|
901
|
+
const isBatchInsert = methodName === "toSpliced" && args.length >= 3 && core.types.isNumericLiteral(args[1], { value: 0 }) && (args.length > 3 || core.types.isSpreadElement(args[2]));
|
|
902
|
+
const isWindowReplace = methodName === "toSpliced" && args.length >= 3 && toSplicedDeleteCount !== void 0 && Number.isSafeInteger(toSplicedDeleteCount) && toSplicedDeleteCount > 0 && (toSplicedDeleteCount !== 1 || args.length > 3 || core.types.isSpreadElement(args[2]));
|
|
903
|
+
const kind = isBatchInsert ? "batch-insert" : isWindowReplace ? "window-replace" : methodName === "with" && args.length === 2 ? "replace" : methodName === "toSpliced" && args.length === 3 && core.types.isNumericLiteral(args[1], { value: 0 }) ? "insert" : methodName === "toSpliced" && args.length === 3 && core.types.isNumericLiteral(args[1], { value: 1 }) ? "replace" : args.length === 2 && toSplicedDeleteCount !== void 0 && Number.isSafeInteger(toSplicedDeleteCount) && toSplicedDeleteCount > 0 ? "remove" : void 0;
|
|
904
|
+
if (!kind || !core.types.isExpression(args[0])) return;
|
|
905
|
+
const position = args[0];
|
|
906
|
+
const incoming = kind === "batch-insert" || kind === "window-replace" ? args.slice(2) : [args.at(-1)];
|
|
907
|
+
if (validateKeyedArrayPositionExpression(position, safeGlobals) !== void 0 || kind !== "remove" && incoming.some((item) => {
|
|
908
|
+
const expression = core.types.isSpreadElement(item) ? item.argument : item;
|
|
909
|
+
return !expression || !core.types.isExpression(expression) || validateDerivedExpression(expression, safeGlobals) !== void 0;
|
|
910
|
+
})) {
|
|
874
911
|
return;
|
|
875
912
|
}
|
|
876
913
|
const previous = core.types.cloneNode(updater.params[0]);
|
|
@@ -887,7 +924,18 @@ function rewriteKeyedArrayPositionHints(root, hintedStateIndices, statesBySetter
|
|
|
887
924
|
)
|
|
888
925
|
]),
|
|
889
926
|
core.types.returnStatement(
|
|
890
|
-
core.types.callExpression(core.types.cloneNode(
|
|
927
|
+
kind === "batch-insert" ? core.types.callExpression(core.types.cloneNode(batchInsertHelperIdentifier), [
|
|
928
|
+
core.types.cloneNode(previous),
|
|
929
|
+
core.types.cloneNode(method),
|
|
930
|
+
core.types.cloneNode(position, true),
|
|
931
|
+
...args.slice(2).map((argument) => core.types.cloneNode(argument, true))
|
|
932
|
+
]) : kind === "window-replace" ? core.types.callExpression(core.types.cloneNode(windowReplaceHelperIdentifier), [
|
|
933
|
+
core.types.cloneNode(previous),
|
|
934
|
+
core.types.cloneNode(method),
|
|
935
|
+
core.types.cloneNode(position, true),
|
|
936
|
+
core.types.cloneNode(args[1], true),
|
|
937
|
+
...args.slice(2).map((argument) => core.types.cloneNode(argument, true))
|
|
938
|
+
]) : core.types.callExpression(core.types.cloneNode(helperIdentifier), [
|
|
891
939
|
core.types.cloneNode(previous),
|
|
892
940
|
core.types.cloneNode(method),
|
|
893
941
|
core.types.stringLiteral(kind),
|
|
@@ -897,6 +945,8 @@ function rewriteKeyedArrayPositionHints(root, hintedStateIndices, statesBySetter
|
|
|
897
945
|
])
|
|
898
946
|
);
|
|
899
947
|
count += 1;
|
|
948
|
+
if (kind === "batch-insert") batchInsertCount += 1;
|
|
949
|
+
if (kind === "window-replace") windowReplaceCount += 1;
|
|
900
950
|
stateIndices.add(state.index);
|
|
901
951
|
path.skip();
|
|
902
952
|
}
|
|
@@ -904,6 +954,8 @@ function rewriteKeyedArrayPositionHints(root, hintedStateIndices, statesBySetter
|
|
|
904
954
|
return {
|
|
905
955
|
root: file.program.body[0].expression,
|
|
906
956
|
count,
|
|
957
|
+
batchInsertCount,
|
|
958
|
+
windowReplaceCount,
|
|
907
959
|
stateIndices
|
|
908
960
|
};
|
|
909
961
|
}
|
|
@@ -956,6 +1008,61 @@ function rewriteKeyedArrayReorderHints(root, hintedStateIndices, statesBySetter,
|
|
|
956
1008
|
stateIndices
|
|
957
1009
|
};
|
|
958
1010
|
}
|
|
1011
|
+
function rewriteKeyedArraySortHints(root, hintedStateIndices, statesBySetter, helperIdentifier, safeGlobals) {
|
|
1012
|
+
if (hintedStateIndices.size === 0) {
|
|
1013
|
+
return { root: core.types.cloneNode(root, true), count: 0, stateIndices: /* @__PURE__ */ new Set() };
|
|
1014
|
+
}
|
|
1015
|
+
const file = expressionFile(core.types.cloneNode(root, true));
|
|
1016
|
+
const stateIndices = /* @__PURE__ */ new Set();
|
|
1017
|
+
let count = 0;
|
|
1018
|
+
core.traverse(file, {
|
|
1019
|
+
CallExpression(path) {
|
|
1020
|
+
const callee = path.get("callee");
|
|
1021
|
+
if (!callee.isIdentifier() || callee.scope.hasBinding(callee.node.name)) return;
|
|
1022
|
+
const state = statesBySetter.get(callee.node.name);
|
|
1023
|
+
if (!state || !hintedStateIndices.has(state.index) || path.node.arguments.length !== 1) {
|
|
1024
|
+
return;
|
|
1025
|
+
}
|
|
1026
|
+
const updater = path.node.arguments[0];
|
|
1027
|
+
if (!core.types.isArrowFunctionExpression(updater) || updater.async || updater.generator || updater.params.length !== 1 || !core.types.isIdentifier(updater.params[0]) || !core.types.isCallExpression(updater.body) || updater.body.arguments.length > 1 || !core.types.isMemberExpression(updater.body.callee) || updater.body.callee.computed || !core.types.isIdentifier(updater.body.callee.object, { name: updater.params[0].name }) || !core.types.isIdentifier(updater.body.callee.property, { name: "toSorted" })) {
|
|
1028
|
+
return;
|
|
1029
|
+
}
|
|
1030
|
+
const comparator = updater.body.arguments[0];
|
|
1031
|
+
if (comparator && !core.types.isArrowFunctionExpression(comparator) && !core.types.isFunctionExpression(comparator)) {
|
|
1032
|
+
return;
|
|
1033
|
+
}
|
|
1034
|
+
if (comparator && validateCollectionCallback(comparator, "toSorted", safeGlobals)) return;
|
|
1035
|
+
const previous = core.types.cloneNode(updater.params[0]);
|
|
1036
|
+
const method = path.scope.generateUidIdentifier("farmToSorted");
|
|
1037
|
+
path.node.arguments[0] = core.types.arrowFunctionExpression(
|
|
1038
|
+
[core.types.cloneNode(previous)],
|
|
1039
|
+
core.types.blockStatement([
|
|
1040
|
+
core.types.variableDeclaration("const", [
|
|
1041
|
+
core.types.variableDeclarator(
|
|
1042
|
+
core.types.cloneNode(method),
|
|
1043
|
+
core.types.memberExpression(core.types.cloneNode(previous), core.types.identifier("toSorted"))
|
|
1044
|
+
)
|
|
1045
|
+
]),
|
|
1046
|
+
core.types.returnStatement(
|
|
1047
|
+
core.types.callExpression(core.types.cloneNode(helperIdentifier), [
|
|
1048
|
+
core.types.cloneNode(previous),
|
|
1049
|
+
core.types.cloneNode(method),
|
|
1050
|
+
...comparator ? [core.types.cloneNode(comparator, true)] : []
|
|
1051
|
+
])
|
|
1052
|
+
)
|
|
1053
|
+
])
|
|
1054
|
+
);
|
|
1055
|
+
count += 1;
|
|
1056
|
+
stateIndices.add(state.index);
|
|
1057
|
+
path.skip();
|
|
1058
|
+
}
|
|
1059
|
+
});
|
|
1060
|
+
return {
|
|
1061
|
+
root: file.program.body[0].expression,
|
|
1062
|
+
count,
|
|
1063
|
+
stateIndices
|
|
1064
|
+
};
|
|
1065
|
+
}
|
|
959
1066
|
function rewriteKeyedArraySliceHints(root, hintedStateIndices, statesBySetter, helperIdentifier) {
|
|
960
1067
|
if (hintedStateIndices.size === 0) {
|
|
961
1068
|
return { root: core.types.cloneNode(root, true), count: 0, stateIndices: /* @__PURE__ */ new Set() };
|
|
@@ -4757,7 +4864,7 @@ function wrapperElement(definitionIdentifier, props) {
|
|
|
4757
4864
|
const attributes = props ? [core.types.jsxSpreadAttribute(core.types.cloneNode(props))] : [];
|
|
4758
4865
|
return core.types.jsxElement(core.types.jsxOpeningElement(name, attributes, true), null, [], true);
|
|
4759
4866
|
}
|
|
4760
|
-
function compileCandidate(candidate, createComponentIdentifier, keyedMapUpdateIdentifier, keyedArrayAppendIdentifier, keyedArrayFilterIdentifier, keyedArrayPrependIdentifier, keyedArrayPositionIdentifier, keyedArrayReorderIdentifier, keyedArrayRollingWindowIdentifier, keyedArraySliceIdentifier, keyedCollectionUpdateIdentifier, keyedCollectionMutationIdentifier, runtimeFeatureIdentifiers, usedRuntimeFeatures, optimizationCounts, useStateNames, reactNames, listNames, moduleId, reactivity) {
|
|
4867
|
+
function compileCandidate(candidate, createComponentIdentifier, keyedMapUpdateIdentifier, keyedArrayAppendIdentifier, keyedArrayFilterIdentifier, keyedArrayPrependIdentifier, keyedArrayPositionIdentifier, keyedArrayBatchInsertIdentifier, keyedArrayWindowReplaceIdentifier, keyedArrayReorderIdentifier, keyedArraySortIdentifier, keyedArrayRollingWindowIdentifier, keyedArraySliceIdentifier, keyedCollectionUpdateIdentifier, keyedCollectionMutationIdentifier, runtimeFeatureIdentifiers, usedRuntimeFeatures, optimizationCounts, compilerUsage, useStateNames, reactNames, listNames, moduleId, reactivity) {
|
|
4761
4868
|
const { path, name, statementPath } = candidate;
|
|
4762
4869
|
if (path.node.async || path.node.generator)
|
|
4763
4870
|
return "async and generator components are not supported";
|
|
@@ -5129,9 +5236,13 @@ function compileCandidate(candidate, createComponentIdentifier, keyedMapUpdateId
|
|
|
5129
5236
|
shiftedIndexIndependentStateIndices,
|
|
5130
5237
|
statesBySetter,
|
|
5131
5238
|
keyedArrayPositionIdentifier,
|
|
5239
|
+
keyedArrayBatchInsertIdentifier,
|
|
5240
|
+
keyedArrayWindowReplaceIdentifier,
|
|
5132
5241
|
safeGlobals
|
|
5133
5242
|
);
|
|
5134
5243
|
let appliedKeyedArrayPositionHints = 0;
|
|
5244
|
+
let appliedKeyedArrayBatchInsertHints = 0;
|
|
5245
|
+
let appliedKeyedArrayWindowReplaceHints = 0;
|
|
5135
5246
|
let appliedPositionHintedStateIndices = /* @__PURE__ */ new Set();
|
|
5136
5247
|
if (positionHintedRoot.count > 0) {
|
|
5137
5248
|
const hintedBlockAnalysis = analyzeComposableBlocks(
|
|
@@ -5155,8 +5266,12 @@ function compileCandidate(candidate, createComponentIdentifier, keyedMapUpdateId
|
|
|
5155
5266
|
blockAnalysis = hintedBlockAnalysis;
|
|
5156
5267
|
analysis = hintedAnalysis;
|
|
5157
5268
|
appliedKeyedArrayPositionHints = positionHintedRoot.count;
|
|
5269
|
+
appliedKeyedArrayBatchInsertHints = positionHintedRoot.batchInsertCount;
|
|
5270
|
+
appliedKeyedArrayWindowReplaceHints = positionHintedRoot.windowReplaceCount;
|
|
5158
5271
|
appliedPositionHintedStateIndices = positionHintedRoot.stateIndices;
|
|
5159
5272
|
optimizationCounts.keyedArrayPositionHints += positionHintedRoot.count;
|
|
5273
|
+
compilerUsage.keyedArrayBatchInsertHints += positionHintedRoot.batchInsertCount;
|
|
5274
|
+
compilerUsage.keyedArrayWindowReplaceHints += positionHintedRoot.windowReplaceCount;
|
|
5160
5275
|
}
|
|
5161
5276
|
}
|
|
5162
5277
|
const reorderHintedRoot = rewriteKeyedArrayReorderHints(
|
|
@@ -5193,6 +5308,41 @@ function compileCandidate(candidate, createComponentIdentifier, keyedMapUpdateId
|
|
|
5193
5308
|
optimizationCounts.keyedArrayReorderHints += reorderHintedRoot.count;
|
|
5194
5309
|
}
|
|
5195
5310
|
}
|
|
5311
|
+
const sortHintedRoot = rewriteKeyedArraySortHints(
|
|
5312
|
+
expandedReactiveRoot,
|
|
5313
|
+
shiftedIndexIndependentStateIndices,
|
|
5314
|
+
statesBySetter,
|
|
5315
|
+
keyedArraySortIdentifier,
|
|
5316
|
+
safeGlobals
|
|
5317
|
+
);
|
|
5318
|
+
let appliedKeyedArraySortHints = 0;
|
|
5319
|
+
let appliedSortHintedStateIndices = /* @__PURE__ */ new Set();
|
|
5320
|
+
if (sortHintedRoot.count > 0) {
|
|
5321
|
+
const hintedBlockAnalysis = analyzeComposableBlocks(
|
|
5322
|
+
sortHintedRoot.root,
|
|
5323
|
+
reactiveByValue,
|
|
5324
|
+
safeGlobals,
|
|
5325
|
+
listNames,
|
|
5326
|
+
allowedComponentNames
|
|
5327
|
+
);
|
|
5328
|
+
const hintedAnalysis = analyzeHostTree(
|
|
5329
|
+
sortHintedRoot.root,
|
|
5330
|
+
reactiveByValue,
|
|
5331
|
+
safeGlobals,
|
|
5332
|
+
hintedBlockAnalysis.conditionalExpressions || /* @__PURE__ */ new Set(),
|
|
5333
|
+
hintedBlockAnalysis.keyedExpressions || /* @__PURE__ */ new Set(),
|
|
5334
|
+
hintedBlockAnalysis.ownedElements || /* @__PURE__ */ new Set(),
|
|
5335
|
+
hintedBlockAnalysis.componentElements || /* @__PURE__ */ new Set()
|
|
5336
|
+
);
|
|
5337
|
+
if (!hintedBlockAnalysis.reason && !hintedAnalysis.reason) {
|
|
5338
|
+
expandedReactiveRoot = sortHintedRoot.root;
|
|
5339
|
+
blockAnalysis = hintedBlockAnalysis;
|
|
5340
|
+
analysis = hintedAnalysis;
|
|
5341
|
+
appliedKeyedArraySortHints = sortHintedRoot.count;
|
|
5342
|
+
appliedSortHintedStateIndices = sortHintedRoot.stateIndices;
|
|
5343
|
+
optimizationCounts.keyedArraySortHints += sortHintedRoot.count;
|
|
5344
|
+
}
|
|
5345
|
+
}
|
|
5196
5346
|
const sliceHintedRoot = rewriteKeyedArraySliceHints(
|
|
5197
5347
|
expandedReactiveRoot,
|
|
5198
5348
|
shiftedIndexIndependentStateIndices,
|
|
@@ -5327,7 +5477,7 @@ function compileCandidate(candidate, createComponentIdentifier, keyedMapUpdateId
|
|
|
5327
5477
|
(count, plan) => count + (plan.kind === "keyed-rows" ? plan.bindings.filter((binding) => binding.mapLookupTarget !== void 0).length : 0),
|
|
5328
5478
|
0
|
|
5329
5479
|
);
|
|
5330
|
-
const hasKeyedUpdateHints = appliedKeyedMapUpdateHints > 0 || appliedKeyedArrayAppendHints > 0 || appliedKeyedArrayFilterHints > 0 || appliedKeyedArrayPrependHints > 0 || appliedKeyedArrayPositionHints > 0 || appliedKeyedArrayReorderHints > 0 || appliedKeyedArrayRollingWindowHints > 0 || appliedKeyedArraySliceHints > 0;
|
|
5480
|
+
const hasKeyedUpdateHints = appliedKeyedMapUpdateHints > 0 || appliedKeyedArrayAppendHints > 0 || appliedKeyedArrayFilterHints > 0 || appliedKeyedArrayPrependHints > 0 || appliedKeyedArrayPositionHints > 0 || appliedKeyedArrayReorderHints > 0 || appliedKeyedArraySortHints > 0 || appliedKeyedArrayRollingWindowHints > 0 || appliedKeyedArraySliceHints > 0;
|
|
5331
5481
|
const hasKeyedArrayRemovalHints = appliedKeyedArrayFilterHints > 0 || appliedKeyedArrayRollingWindowHints > 0 || appliedKeyedArraySliceHints > 0;
|
|
5332
5482
|
const runtimeFeatures = runtimeFeaturesForPlans(
|
|
5333
5483
|
blockPlans,
|
|
@@ -5335,7 +5485,9 @@ function compileCandidate(candidate, createComponentIdentifier, keyedMapUpdateId
|
|
|
5335
5485
|
hasKeyedArrayRemovalHints,
|
|
5336
5486
|
appliedKeyedArrayPrependHints > 0,
|
|
5337
5487
|
appliedKeyedArrayPositionHints > 0,
|
|
5338
|
-
|
|
5488
|
+
appliedKeyedArrayBatchInsertHints > 0,
|
|
5489
|
+
appliedKeyedArrayWindowReplaceHints > 0,
|
|
5490
|
+
appliedKeyedArrayReorderHints > 0 || appliedKeyedArraySortHints > 0,
|
|
5339
5491
|
appliedKeyedArrayRollingWindowHints > 0
|
|
5340
5492
|
);
|
|
5341
5493
|
markShortCircuitBindings(analysis.bindings || []);
|
|
@@ -5364,7 +5516,7 @@ function compileCandidate(candidate, createComponentIdentifier, keyedMapUpdateId
|
|
|
5364
5516
|
appliedRemovalHintedStateIndices,
|
|
5365
5517
|
appliedPrependHintedStateIndices,
|
|
5366
5518
|
appliedPositionHintedStateIndices,
|
|
5367
|
-
appliedReorderHintedStateIndices
|
|
5519
|
+
/* @__PURE__ */ new Set([...appliedReorderHintedStateIndices, ...appliedSortHintedStateIndices])
|
|
5368
5520
|
);
|
|
5369
5521
|
const rewrittenRoot = rewriteStateAccess(
|
|
5370
5522
|
rootWithBlocks,
|
|
@@ -5508,6 +5660,7 @@ async function compileReactModule(code, id, options) {
|
|
|
5508
5660
|
keyedArrayPrependHints: 0,
|
|
5509
5661
|
keyedArrayPositionHints: 0,
|
|
5510
5662
|
keyedArrayReorderHints: 0,
|
|
5663
|
+
keyedArraySortHints: 0,
|
|
5511
5664
|
keyedArrayRollingWindowHints: 0,
|
|
5512
5665
|
keyedArraySliceHints: 0,
|
|
5513
5666
|
keyedCollectionUpdateHints: 0,
|
|
@@ -5516,6 +5669,10 @@ async function compileReactModule(code, id, options) {
|
|
|
5516
5669
|
keyedMembershipTargets: 0,
|
|
5517
5670
|
keyedMapUpdateHints: 0
|
|
5518
5671
|
};
|
|
5672
|
+
const compilerUsage = {
|
|
5673
|
+
keyedArrayBatchInsertHints: 0,
|
|
5674
|
+
keyedArrayWindowReplaceHints: 0
|
|
5675
|
+
};
|
|
5519
5676
|
const plugin = () => ({
|
|
5520
5677
|
name: "farm-react-aot",
|
|
5521
5678
|
visitor: {
|
|
@@ -5560,9 +5717,18 @@ async function compileReactModule(code, id, options) {
|
|
|
5560
5717
|
const keyedArrayPositionIdentifier = programPath.scope.generateUidIdentifier(
|
|
5561
5718
|
"createCompilerKeyedArrayPositionUpdate"
|
|
5562
5719
|
);
|
|
5720
|
+
const keyedArrayBatchInsertIdentifier = programPath.scope.generateUidIdentifier(
|
|
5721
|
+
"createCompilerKeyedArrayBatchInsert"
|
|
5722
|
+
);
|
|
5723
|
+
const keyedArrayWindowReplaceIdentifier = programPath.scope.generateUidIdentifier(
|
|
5724
|
+
"createCompilerKeyedArrayWindowReplace"
|
|
5725
|
+
);
|
|
5563
5726
|
const keyedArrayReorderIdentifier = programPath.scope.generateUidIdentifier(
|
|
5564
5727
|
"createCompilerKeyedArrayReorder"
|
|
5565
5728
|
);
|
|
5729
|
+
const keyedArraySortIdentifier = programPath.scope.generateUidIdentifier(
|
|
5730
|
+
"createCompilerKeyedArraySort"
|
|
5731
|
+
);
|
|
5566
5732
|
const keyedArrayRollingWindowIdentifier = programPath.scope.generateUidIdentifier(
|
|
5567
5733
|
"createCompilerKeyedArrayRollingWindow"
|
|
5568
5734
|
);
|
|
@@ -5597,7 +5763,10 @@ async function compileReactModule(code, id, options) {
|
|
|
5597
5763
|
keyedArrayFilterIdentifier,
|
|
5598
5764
|
keyedArrayPrependIdentifier,
|
|
5599
5765
|
keyedArrayPositionIdentifier,
|
|
5766
|
+
keyedArrayBatchInsertIdentifier,
|
|
5767
|
+
keyedArrayWindowReplaceIdentifier,
|
|
5600
5768
|
keyedArrayReorderIdentifier,
|
|
5769
|
+
keyedArraySortIdentifier,
|
|
5601
5770
|
keyedArrayRollingWindowIdentifier,
|
|
5602
5771
|
keyedArraySliceIdentifier,
|
|
5603
5772
|
keyedCollectionUpdateIdentifier,
|
|
@@ -5605,6 +5774,7 @@ async function compileReactModule(code, id, options) {
|
|
|
5605
5774
|
runtimeFeatureIdentifiers,
|
|
5606
5775
|
usedRuntimeFeatures,
|
|
5607
5776
|
optimizationCounts,
|
|
5777
|
+
compilerUsage,
|
|
5608
5778
|
useStateNames,
|
|
5609
5779
|
reactNames,
|
|
5610
5780
|
listNames,
|
|
@@ -5654,18 +5824,36 @@ async function compileReactModule(code, id, options) {
|
|
|
5654
5824
|
core.types.identifier("createCompilerKeyedArrayPrepend")
|
|
5655
5825
|
)
|
|
5656
5826
|
] : [],
|
|
5657
|
-
...optimizationCounts.keyedArrayPositionHints >
|
|
5827
|
+
...optimizationCounts.keyedArrayPositionHints > compilerUsage.keyedArrayBatchInsertHints + compilerUsage.keyedArrayWindowReplaceHints ? [
|
|
5658
5828
|
core.types.importSpecifier(
|
|
5659
5829
|
keyedArrayPositionIdentifier,
|
|
5660
5830
|
core.types.identifier("createCompilerKeyedArrayPositionUpdate")
|
|
5661
5831
|
)
|
|
5662
5832
|
] : [],
|
|
5833
|
+
...compilerUsage.keyedArrayBatchInsertHints > 0 ? [
|
|
5834
|
+
core.types.importSpecifier(
|
|
5835
|
+
keyedArrayBatchInsertIdentifier,
|
|
5836
|
+
core.types.identifier("createCompilerKeyedArrayBatchInsert")
|
|
5837
|
+
)
|
|
5838
|
+
] : [],
|
|
5839
|
+
...compilerUsage.keyedArrayWindowReplaceHints > 0 ? [
|
|
5840
|
+
core.types.importSpecifier(
|
|
5841
|
+
keyedArrayWindowReplaceIdentifier,
|
|
5842
|
+
core.types.identifier("createCompilerKeyedArrayWindowReplace")
|
|
5843
|
+
)
|
|
5844
|
+
] : [],
|
|
5663
5845
|
...optimizationCounts.keyedArrayReorderHints > 0 ? [
|
|
5664
5846
|
core.types.importSpecifier(
|
|
5665
5847
|
keyedArrayReorderIdentifier,
|
|
5666
5848
|
core.types.identifier("createCompilerKeyedArrayReorder")
|
|
5667
5849
|
)
|
|
5668
5850
|
] : [],
|
|
5851
|
+
...optimizationCounts.keyedArraySortHints > 0 ? [
|
|
5852
|
+
core.types.importSpecifier(
|
|
5853
|
+
keyedArraySortIdentifier,
|
|
5854
|
+
core.types.identifier("createCompilerKeyedArraySort")
|
|
5855
|
+
)
|
|
5856
|
+
] : [],
|
|
5669
5857
|
...optimizationCounts.keyedArrayRollingWindowHints > 0 ? [
|
|
5670
5858
|
core.types.importSpecifier(
|
|
5671
5859
|
keyedArrayRollingWindowIdentifier,
|
|
@@ -5741,6 +5929,7 @@ function createReactCompilerReport(projectRoot, observations) {
|
|
|
5741
5929
|
let keyedArrayPrependHints = 0;
|
|
5742
5930
|
let keyedArrayPositionHints = 0;
|
|
5743
5931
|
let keyedArrayReorderHints = 0;
|
|
5932
|
+
let keyedArraySortHints = 0;
|
|
5744
5933
|
let keyedArrayRollingWindowHints = 0;
|
|
5745
5934
|
let keyedArraySliceHints = 0;
|
|
5746
5935
|
let keyedCollectionUpdateHints = 0;
|
|
@@ -5757,6 +5946,7 @@ function createReactCompilerReport(projectRoot, observations) {
|
|
|
5757
5946
|
keyedArrayPrependHints += result.optimizations.keyedArrayPrependHints || 0;
|
|
5758
5947
|
keyedArrayPositionHints += result.optimizations.keyedArrayPositionHints || 0;
|
|
5759
5948
|
keyedArrayReorderHints += result.optimizations.keyedArrayReorderHints || 0;
|
|
5949
|
+
keyedArraySortHints += result.optimizations.keyedArraySortHints || 0;
|
|
5760
5950
|
keyedArrayRollingWindowHints += result.optimizations.keyedArrayRollingWindowHints || 0;
|
|
5761
5951
|
keyedArraySliceHints += result.optimizations.keyedArraySliceHints || 0;
|
|
5762
5952
|
keyedCollectionUpdateHints += result.optimizations.keyedCollectionUpdateHints || 0;
|
|
@@ -5789,6 +5979,7 @@ function createReactCompilerReport(projectRoot, observations) {
|
|
|
5789
5979
|
keyedArrayPrependHints,
|
|
5790
5980
|
keyedArrayPositionHints,
|
|
5791
5981
|
keyedArrayReorderHints,
|
|
5982
|
+
keyedArraySortHints,
|
|
5792
5983
|
keyedArrayRollingWindowHints,
|
|
5793
5984
|
keyedArraySliceHints,
|
|
5794
5985
|
keyedCollectionUpdateHints,
|