@farm.js/react 0.1.0-beta.8 → 0.1.0-beta.9
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 +365 -62
- package/dist/compiler-runtime.cjs +2102 -241
- package/dist/compiler-runtime.cjs.map +1 -1
- package/dist/compiler-runtime.d.mts +50 -3
- package/dist/compiler-runtime.d.ts +50 -3
- package/dist/compiler-runtime.mjs +2074 -242
- package/dist/compiler-runtime.mjs.map +1 -1
- package/dist/vite.cjs +1546 -107
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.mjs +1548 -109
- package/dist/vite.mjs.map +1 -1
- package/package.json +5 -4
package/dist/vite.cjs
CHANGED
|
@@ -73,11 +73,16 @@ var COMPILER_RUNTIME_FEATURE_EXPORTS = {
|
|
|
73
73
|
"keyed-rows-batch-position-hinted": "keyedRowsBatchPositionHintedRuntimeFeature",
|
|
74
74
|
"keyed-rows-window-position-hinted": "keyedRowsWindowPositionHintedRuntimeFeature",
|
|
75
75
|
"keyed-rows-reorder-hinted": "keyedRowsReorderHintedRuntimeFeature",
|
|
76
|
+
"keyed-rows-map-reorder-hinted": "keyedRowsMapReorderHintedRuntimeFeature",
|
|
76
77
|
"keyed-rows-all-hinted": "keyedRowsAllHintedRuntimeFeature",
|
|
77
78
|
"keyed-rows-every-hinted": "keyedRowsEveryHintedRuntimeFeature",
|
|
78
79
|
"keyed-rows-batch-every-hinted": "keyedRowsBatchEveryHintedRuntimeFeature",
|
|
79
80
|
"keyed-rows-window-every-hinted": "keyedRowsWindowEveryHintedRuntimeFeature",
|
|
80
81
|
"keyed-rows-filter-hinted": "keyedRowsFilterHintedRuntimeFeature",
|
|
82
|
+
"keyed-rows-structural-append-hinted": "keyedRowsStructuralAppendHintedRuntimeFeature",
|
|
83
|
+
"keyed-rows-structural-append-map-hinted": "keyedRowsStructuralAppendMapHintedRuntimeFeature",
|
|
84
|
+
"keyed-rows-structural-prepend-hinted": "keyedRowsStructuralPrependHintedRuntimeFeature",
|
|
85
|
+
"keyed-rows-structural-prepend-map-hinted": "keyedRowsStructuralPrependMapHintedRuntimeFeature",
|
|
81
86
|
"keyed-rows-prepend-hinted": "keyedRowsPrependHintedRuntimeFeature",
|
|
82
87
|
"keyed-rows-filter-prepend-hinted": "keyedRowsFilterPrependHintedRuntimeFeature",
|
|
83
88
|
"keyed-rows-conditional": "keyedRowsConditionalRuntimeFeature",
|
|
@@ -91,6 +96,10 @@ var COMPILER_RUNTIME_FEATURE_EXPORTS = {
|
|
|
91
96
|
"keyed-rows-conditional-batch-every-hinted": "keyedRowsConditionalBatchEveryHintedRuntimeFeature",
|
|
92
97
|
"keyed-rows-conditional-window-every-hinted": "keyedRowsConditionalWindowEveryHintedRuntimeFeature",
|
|
93
98
|
"keyed-rows-conditional-filter-hinted": "keyedRowsConditionalFilterHintedRuntimeFeature",
|
|
99
|
+
"keyed-rows-conditional-structural-append-hinted": "keyedRowsConditionalStructuralAppendHintedRuntimeFeature",
|
|
100
|
+
"keyed-rows-conditional-structural-append-map-hinted": "keyedRowsConditionalStructuralAppendMapHintedRuntimeFeature",
|
|
101
|
+
"keyed-rows-conditional-structural-prepend-hinted": "keyedRowsConditionalStructuralPrependHintedRuntimeFeature",
|
|
102
|
+
"keyed-rows-conditional-structural-prepend-map-hinted": "keyedRowsConditionalStructuralPrependMapHintedRuntimeFeature",
|
|
94
103
|
"keyed-rows-conditional-prepend-hinted": "keyedRowsConditionalPrependHintedRuntimeFeature",
|
|
95
104
|
"keyed-rows-conditional-filter-prepend-hinted": "keyedRowsConditionalFilterPrependHintedRuntimeFeature",
|
|
96
105
|
"keyed-rows-host": "keyedRowsHostRuntimeFeature",
|
|
@@ -104,6 +113,10 @@ var COMPILER_RUNTIME_FEATURE_EXPORTS = {
|
|
|
104
113
|
"keyed-rows-host-batch-every-hinted": "keyedRowsHostBatchEveryHintedRuntimeFeature",
|
|
105
114
|
"keyed-rows-host-window-every-hinted": "keyedRowsHostWindowEveryHintedRuntimeFeature",
|
|
106
115
|
"keyed-rows-host-filter-hinted": "keyedRowsHostFilterHintedRuntimeFeature",
|
|
116
|
+
"keyed-rows-host-structural-append-hinted": "keyedRowsHostStructuralAppendHintedRuntimeFeature",
|
|
117
|
+
"keyed-rows-host-structural-append-map-hinted": "keyedRowsHostStructuralAppendMapHintedRuntimeFeature",
|
|
118
|
+
"keyed-rows-host-structural-prepend-hinted": "keyedRowsHostStructuralPrependHintedRuntimeFeature",
|
|
119
|
+
"keyed-rows-host-structural-prepend-map-hinted": "keyedRowsHostStructuralPrependMapHintedRuntimeFeature",
|
|
107
120
|
"keyed-rows-host-prepend-hinted": "keyedRowsHostPrependHintedRuntimeFeature",
|
|
108
121
|
"keyed-rows-host-filter-prepend-hinted": "keyedRowsHostFilterPrependHintedRuntimeFeature",
|
|
109
122
|
"keyed-rows-complete": "keyedRowsCompleteRuntimeFeature",
|
|
@@ -117,13 +130,17 @@ var COMPILER_RUNTIME_FEATURE_EXPORTS = {
|
|
|
117
130
|
"keyed-rows-complete-batch-every-hinted": "keyedRowsCompleteBatchEveryHintedRuntimeFeature",
|
|
118
131
|
"keyed-rows-complete-window-every-hinted": "keyedRowsCompleteWindowEveryHintedRuntimeFeature",
|
|
119
132
|
"keyed-rows-complete-filter-hinted": "keyedRowsCompleteFilterHintedRuntimeFeature",
|
|
133
|
+
"keyed-rows-complete-structural-append-hinted": "keyedRowsCompleteStructuralAppendHintedRuntimeFeature",
|
|
134
|
+
"keyed-rows-complete-structural-append-map-hinted": "keyedRowsCompleteStructuralAppendMapHintedRuntimeFeature",
|
|
135
|
+
"keyed-rows-complete-structural-prepend-hinted": "keyedRowsCompleteStructuralPrependHintedRuntimeFeature",
|
|
136
|
+
"keyed-rows-complete-structural-prepend-map-hinted": "keyedRowsCompleteStructuralPrependMapHintedRuntimeFeature",
|
|
120
137
|
"keyed-rows-complete-prepend-hinted": "keyedRowsCompletePrependHintedRuntimeFeature",
|
|
121
138
|
"keyed-rows-complete-filter-prepend-hinted": "keyedRowsCompleteFilterPrependHintedRuntimeFeature",
|
|
122
139
|
"keyed-ranges": "keyedRangesRuntimeFeature",
|
|
123
140
|
"mixed-ranges": "mixedRangesRuntimeFeature",
|
|
124
141
|
component: "componentRuntimeFeature"
|
|
125
142
|
};
|
|
126
|
-
function runtimeFeaturesForPlans(plans, keyedMapUpdateHints, keyedArrayFilterHints, keyedArrayPrependHints, keyedArrayPositionHints, keyedArrayBatchInsertHints, keyedArrayWindowReplaceHints, keyedArrayReorderHints, keyedArrayRollingWindowHints) {
|
|
143
|
+
function runtimeFeaturesForPlans(plans, keyedMapUpdateHints, keyedArrayFilterHints, keyedArrayStructuralAppendHints, keyedArrayStructuralAppendMapHints, keyedArrayPrependHints, keyedArrayStructuralPrependHints, keyedArrayStructuralPrependMapHints, keyedArrayPositionHints, keyedArrayBatchInsertHints, keyedArrayWindowReplaceHints, keyedArrayReorderHints, keyedArrayMapReorderHints, keyedArrayRollingWindowHints) {
|
|
127
144
|
const features = /* @__PURE__ */ new Set();
|
|
128
145
|
let keyedRowsHaveConditionals = false;
|
|
129
146
|
let keyedRowsHaveHostBlocks = false;
|
|
@@ -140,7 +157,8 @@ function runtimeFeaturesForPlans(plans, keyedMapUpdateHints, keyedArrayFilterHin
|
|
|
140
157
|
if (plans.some((plan) => plan.kind === "keyed-rows")) {
|
|
141
158
|
const keyedRowsFeature = keyedRowsHaveConditionals && keyedRowsHaveHostBlocks ? "keyed-rows-complete" : keyedRowsHaveConditionals ? "keyed-rows-conditional" : keyedRowsHaveHostBlocks ? "keyed-rows-host" : "keyed-rows";
|
|
142
159
|
const arrayRangeHints = keyedArrayRollingWindowHints || keyedArrayFilterHints || keyedArrayPrependHints;
|
|
143
|
-
const
|
|
160
|
+
const needsCombinedStructuralPrependRuntime = keyedArrayStructuralPrependHints && (keyedArrayStructuralAppendMapHints || keyedArrayStructuralAppendHints || keyedArrayWindowReplaceHints || keyedArrayBatchInsertHints || keyedArrayPositionHints || keyedArrayReorderHints || keyedArrayRollingWindowHints);
|
|
161
|
+
const hintSuffix = keyedArrayStructuralPrependMapHints ? "-structural-prepend-map-hinted" : needsCombinedStructuralPrependRuntime ? "-structural-prepend-hinted" : keyedArrayStructuralAppendMapHints ? "-structural-append-map-hinted" : keyedArrayStructuralAppendHints ? "-structural-append-hinted" : 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" : keyedArrayMapReorderHints && keyedRowsFeature === "keyed-rows" ? "-map-reorder-hinted" : keyedArrayReorderHints ? "-reorder-hinted" : keyedArrayFilterHints && keyedArrayPrependHints ? "-filter-prepend-hinted" : keyedArrayFilterHints ? "-filter-hinted" : keyedArrayPrependHints ? "-prepend-hinted" : keyedMapUpdateHints ? "-hinted" : "";
|
|
144
162
|
features.add(`${keyedRowsFeature}${hintSuffix}`);
|
|
145
163
|
}
|
|
146
164
|
return [...features].sort();
|
|
@@ -545,6 +563,22 @@ function isSafeKeyedMapResult(expression, item, safeGlobals) {
|
|
|
545
563
|
if (validateDerivedExpression(expression.test, safeGlobals)) return false;
|
|
546
564
|
return isUnchangedMapItem(expression.consequent, item) && isSafeKeyedMapReplacement(expression.alternate, item, safeGlobals) || isUnchangedMapItem(expression.alternate, item) && isSafeKeyedMapReplacement(expression.consequent, item, safeGlobals);
|
|
547
565
|
}
|
|
566
|
+
function keyedMapUpdatePipeline(expression, parameterName, safeGlobals) {
|
|
567
|
+
const outerCallbacks = [];
|
|
568
|
+
let current = expression;
|
|
569
|
+
while (core.types.isCallExpression(current) && current.arguments.length === 1 && core.types.isMemberExpression(current.callee) && !current.callee.computed && core.types.isIdentifier(current.callee.property, { name: "map" }) && core.types.isExpression(current.callee.object)) {
|
|
570
|
+
const callback = current.arguments[0];
|
|
571
|
+
if (!core.types.isArrowFunctionExpression(callback) || callback.async || callback.generator || callback.params.length === 0 || callback.params.length > 3 || callback.params.some((parameter) => !core.types.isIdentifier(parameter)) || !core.types.isExpression(callback.body) || !isSafeKeyedMapResult(callback.body, callback.params[0], safeGlobals)) {
|
|
572
|
+
return void 0;
|
|
573
|
+
}
|
|
574
|
+
outerCallbacks.push(callback);
|
|
575
|
+
current = current.callee.object;
|
|
576
|
+
}
|
|
577
|
+
if (!core.types.isIdentifier(current, { name: parameterName }) || outerCallbacks.length === 0) {
|
|
578
|
+
return void 0;
|
|
579
|
+
}
|
|
580
|
+
return outerCallbacks.reverse();
|
|
581
|
+
}
|
|
548
582
|
function rewriteKeyedMapUpdateHints(root, hintedStateIndices, statesBySetter, helperIdentifier, safeGlobals) {
|
|
549
583
|
if (hintedStateIndices.size === 0) return { root: core.types.cloneNode(root, true), count: 0 };
|
|
550
584
|
const file = expressionFile(core.types.cloneNode(root, true));
|
|
@@ -558,58 +592,50 @@ function rewriteKeyedMapUpdateHints(root, hintedStateIndices, statesBySetter, he
|
|
|
558
592
|
return;
|
|
559
593
|
}
|
|
560
594
|
const updater = path.node.arguments[0];
|
|
561
|
-
if (!core.types.isArrowFunctionExpression(updater) || updater.async || updater.generator || updater.params.length !== 1 || !core.types.isIdentifier(updater.params[0]) || !core.types.
|
|
562
|
-
name: updater.params[0].name
|
|
563
|
-
}) || !core.types.isIdentifier(updater.body.callee.property, { name: "map" })) {
|
|
564
|
-
return;
|
|
565
|
-
}
|
|
566
|
-
const callback = updater.body.arguments[0];
|
|
567
|
-
if (!core.types.isArrowFunctionExpression(callback) || callback.async || callback.generator || callback.params.length === 0 || callback.params.length > 3 || callback.params.some((parameter) => !core.types.isIdentifier(parameter)) || !core.types.isExpression(callback.body)) {
|
|
595
|
+
if (!core.types.isArrowFunctionExpression(updater) || updater.async || updater.generator || updater.params.length !== 1 || !core.types.isIdentifier(updater.params[0]) || !core.types.isExpression(updater.body)) {
|
|
568
596
|
return;
|
|
569
597
|
}
|
|
570
|
-
const
|
|
571
|
-
if (!
|
|
572
|
-
const changedIndices = path.scope.generateUidIdentifier("farmChangedIndices");
|
|
573
|
-
const mappedItem = path.scope.generateUidIdentifier("farmMappedItem");
|
|
574
|
-
const nextValue = path.scope.generateUidIdentifier("farmNextItems");
|
|
575
|
-
const index = core.types.isIdentifier(callback.params[1]) ? core.types.cloneNode(callback.params[1]) : path.scope.generateUidIdentifier("farmMapIndex");
|
|
576
|
-
const wrappedCallback = core.types.cloneNode(callback, true);
|
|
577
|
-
if (wrappedCallback.params.length === 1) wrappedCallback.params.push(core.types.cloneNode(index));
|
|
578
|
-
wrappedCallback.body = core.types.blockStatement([
|
|
579
|
-
core.types.variableDeclaration("const", [
|
|
580
|
-
core.types.variableDeclarator(core.types.cloneNode(mappedItem), core.types.cloneNode(callback.body, true))
|
|
581
|
-
]),
|
|
582
|
-
core.types.ifStatement(
|
|
583
|
-
core.types.binaryExpression("!==", core.types.cloneNode(mappedItem), core.types.cloneNode(item)),
|
|
584
|
-
core.types.expressionStatement(
|
|
585
|
-
core.types.callExpression(
|
|
586
|
-
core.types.memberExpression(core.types.cloneNode(changedIndices), core.types.identifier("push")),
|
|
587
|
-
[core.types.cloneNode(index)]
|
|
588
|
-
)
|
|
589
|
-
)
|
|
590
|
-
),
|
|
591
|
-
core.types.returnStatement(core.types.cloneNode(mappedItem))
|
|
592
|
-
]);
|
|
593
|
-
const mapCall = core.types.cloneNode(updater.body, true);
|
|
594
|
-
mapCall.arguments[0] = wrappedCallback;
|
|
598
|
+
const callbacks = keyedMapUpdatePipeline(updater.body, updater.params[0].name, safeGlobals);
|
|
599
|
+
if (!callbacks) return;
|
|
595
600
|
const previous = core.types.cloneNode(updater.params[0]);
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
601
|
+
const pipelineValue = path.scope.generateUidIdentifier("farmMapValue");
|
|
602
|
+
const applyMap = path.scope.generateUidIdentifier("farmApplyMap");
|
|
603
|
+
const statements = [];
|
|
604
|
+
let current = core.types.cloneNode(pipelineValue);
|
|
605
|
+
for (let index = 0; index < callbacks.length; index += 1) {
|
|
606
|
+
const method = path.scope.generateUidIdentifier(`farmMap${index + 1}`);
|
|
607
|
+
const nextValue = path.scope.generateUidIdentifier(`farmMappedItems${index + 1}`);
|
|
608
|
+
statements.push(
|
|
599
609
|
core.types.variableDeclaration("const", [
|
|
600
|
-
core.types.variableDeclarator(
|
|
610
|
+
core.types.variableDeclarator(
|
|
611
|
+
core.types.cloneNode(method),
|
|
612
|
+
core.types.memberExpression(core.types.cloneNode(current), core.types.identifier("map"))
|
|
613
|
+
)
|
|
601
614
|
]),
|
|
602
|
-
core.types.variableDeclaration("const", [
|
|
603
|
-
|
|
604
|
-
core.types.callExpression(core.types.cloneNode(helperIdentifier), [
|
|
605
|
-
core.types.cloneNode(previous),
|
|
615
|
+
core.types.variableDeclaration("const", [
|
|
616
|
+
core.types.variableDeclarator(
|
|
606
617
|
core.types.cloneNode(nextValue),
|
|
607
|
-
core.types.cloneNode(
|
|
608
|
-
|
|
618
|
+
core.types.callExpression(core.types.cloneNode(applyMap), [
|
|
619
|
+
core.types.cloneNode(current),
|
|
620
|
+
core.types.cloneNode(method),
|
|
621
|
+
core.types.cloneNode(callbacks[index], true)
|
|
622
|
+
])
|
|
623
|
+
)
|
|
624
|
+
])
|
|
625
|
+
);
|
|
626
|
+
current = nextValue;
|
|
627
|
+
}
|
|
628
|
+
path.node.arguments[0] = core.types.arrowFunctionExpression(
|
|
629
|
+
[core.types.cloneNode(previous)],
|
|
630
|
+
core.types.callExpression(core.types.cloneNode(helperIdentifier), [
|
|
631
|
+
core.types.cloneNode(previous),
|
|
632
|
+
core.types.arrowFunctionExpression(
|
|
633
|
+
[core.types.cloneNode(pipelineValue), core.types.cloneNode(applyMap)],
|
|
634
|
+
core.types.blockStatement([...statements, core.types.returnStatement(core.types.cloneNode(current))])
|
|
609
635
|
)
|
|
610
636
|
])
|
|
611
637
|
);
|
|
612
|
-
count +=
|
|
638
|
+
count += callbacks.length;
|
|
613
639
|
path.skip();
|
|
614
640
|
}
|
|
615
641
|
});
|
|
@@ -782,8 +808,10 @@ function rewriteKeyedArrayRollingWindowHints(root, hintedStateIndices, statesByS
|
|
|
782
808
|
}) || !core.types.isIdentifier(retainedSpread.argument.callee.property, { name: "slice" }) || !core.types.isExpression(retainedSpread.argument.arguments[0])) {
|
|
783
809
|
return;
|
|
784
810
|
}
|
|
785
|
-
const retainedStart =
|
|
786
|
-
if (retainedStart
|
|
811
|
+
const retainedStart = retainedSpread.argument.arguments[0];
|
|
812
|
+
if (validateKeyedArrayPositionExpression(retainedStart, safeGlobals) !== void 0 || staticSliceIndex(retainedStart) === 0) {
|
|
813
|
+
return;
|
|
814
|
+
}
|
|
787
815
|
const safeIncomingValue = (value) => {
|
|
788
816
|
if (core.types.isArrayExpression(value)) {
|
|
789
817
|
return value.elements.every(
|
|
@@ -826,7 +854,7 @@ function rewriteKeyedArrayRollingWindowHints(root, hintedStateIndices, statesByS
|
|
|
826
854
|
core.types.callExpression(core.types.cloneNode(sliceHelperIdentifier), [
|
|
827
855
|
core.types.cloneNode(previous),
|
|
828
856
|
core.types.cloneNode(sliceMethod),
|
|
829
|
-
core.types.
|
|
857
|
+
core.types.cloneNode(retainedStart, true)
|
|
830
858
|
])
|
|
831
859
|
),
|
|
832
860
|
core.types.variableDeclarator(core.types.cloneNode(nextValue), core.types.arrayExpression(nextElements))
|
|
@@ -897,14 +925,16 @@ function rewriteKeyedArrayPositionHints(root, hintedStateIndices, statesBySetter
|
|
|
897
925
|
}
|
|
898
926
|
const methodName = updater.body.callee.property.name;
|
|
899
927
|
const args = updater.body.arguments;
|
|
900
|
-
const
|
|
928
|
+
const deleteCountExpression = methodName === "toSpliced" && args.length >= 2 && core.types.isExpression(args[1]) ? args[1] : void 0;
|
|
929
|
+
const toSplicedDeleteCount = deleteCountExpression ? staticSliceIndex(deleteCountExpression) : void 0;
|
|
930
|
+
const hasRuntimeDeleteCount = deleteCountExpression !== void 0 && toSplicedDeleteCount === void 0 && validateKeyedArrayPositionExpression(deleteCountExpression, safeGlobals) === void 0;
|
|
901
931
|
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]));
|
|
932
|
+
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])) || hasRuntimeDeleteCount);
|
|
903
933
|
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
934
|
if (!kind || !core.types.isExpression(args[0])) return;
|
|
905
935
|
const position = args[0];
|
|
906
936
|
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) => {
|
|
937
|
+
if (validateKeyedArrayPositionExpression(position, safeGlobals) !== void 0 || kind === "window-replace" && (!deleteCountExpression || validateKeyedArrayPositionExpression(deleteCountExpression, safeGlobals) !== void 0) || kind !== "remove" && incoming.some((item) => {
|
|
908
938
|
const expression = core.types.isSpreadElement(item) ? item.argument : item;
|
|
909
939
|
return !expression || !core.types.isExpression(expression) || validateDerivedExpression(expression, safeGlobals) !== void 0;
|
|
910
940
|
})) {
|
|
@@ -978,34 +1008,976 @@ function rewriteKeyedArrayReorderHints(root, hintedStateIndices, statesBySetter,
|
|
|
978
1008
|
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 !== 0 || !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: "toReversed" })) {
|
|
979
1009
|
return;
|
|
980
1010
|
}
|
|
981
|
-
const previous = core.types.cloneNode(updater.params[0]);
|
|
982
|
-
const method = path.scope.generateUidIdentifier("farmToReversed");
|
|
983
|
-
path.node.arguments[0] = core.types.arrowFunctionExpression(
|
|
984
|
-
[core.types.cloneNode(previous)],
|
|
985
|
-
core.types.blockStatement([
|
|
986
|
-
core.types.variableDeclaration("const", [
|
|
987
|
-
core.types.variableDeclarator(
|
|
988
|
-
core.types.cloneNode(method),
|
|
989
|
-
core.types.memberExpression(core.types.cloneNode(previous), core.types.identifier("toReversed"))
|
|
990
|
-
)
|
|
991
|
-
]),
|
|
992
|
-
core.types.returnStatement(
|
|
993
|
-
core.types.callExpression(core.types.cloneNode(helperIdentifier), [
|
|
994
|
-
core.types.cloneNode(previous),
|
|
995
|
-
core.types.cloneNode(method)
|
|
996
|
-
])
|
|
997
|
-
)
|
|
998
|
-
])
|
|
999
|
-
);
|
|
1000
|
-
count += 1;
|
|
1001
|
-
stateIndices.add(state.index);
|
|
1002
|
-
path.skip();
|
|
1011
|
+
const previous = core.types.cloneNode(updater.params[0]);
|
|
1012
|
+
const method = path.scope.generateUidIdentifier("farmToReversed");
|
|
1013
|
+
path.node.arguments[0] = core.types.arrowFunctionExpression(
|
|
1014
|
+
[core.types.cloneNode(previous)],
|
|
1015
|
+
core.types.blockStatement([
|
|
1016
|
+
core.types.variableDeclaration("const", [
|
|
1017
|
+
core.types.variableDeclarator(
|
|
1018
|
+
core.types.cloneNode(method),
|
|
1019
|
+
core.types.memberExpression(core.types.cloneNode(previous), core.types.identifier("toReversed"))
|
|
1020
|
+
)
|
|
1021
|
+
]),
|
|
1022
|
+
core.types.returnStatement(
|
|
1023
|
+
core.types.callExpression(core.types.cloneNode(helperIdentifier), [
|
|
1024
|
+
core.types.cloneNode(previous),
|
|
1025
|
+
core.types.cloneNode(method)
|
|
1026
|
+
])
|
|
1027
|
+
)
|
|
1028
|
+
])
|
|
1029
|
+
);
|
|
1030
|
+
count += 1;
|
|
1031
|
+
stateIndices.add(state.index);
|
|
1032
|
+
path.skip();
|
|
1033
|
+
}
|
|
1034
|
+
});
|
|
1035
|
+
return {
|
|
1036
|
+
root: file.program.body[0].expression,
|
|
1037
|
+
count,
|
|
1038
|
+
stateIndices
|
|
1039
|
+
};
|
|
1040
|
+
}
|
|
1041
|
+
function keyedArrayReorderPipeline(expression, parameterName, safeGlobals) {
|
|
1042
|
+
const outerSteps = [];
|
|
1043
|
+
let current = expression;
|
|
1044
|
+
while (core.types.isCallExpression(current) && core.types.isMemberExpression(current.callee) && !current.callee.computed && core.types.isIdentifier(current.callee.property) && core.types.isExpression(current.callee.object)) {
|
|
1045
|
+
const methodName = current.callee.property.name;
|
|
1046
|
+
if (methodName === "map") {
|
|
1047
|
+
if (current.arguments.length !== 1) return void 0;
|
|
1048
|
+
const callback = current.arguments[0];
|
|
1049
|
+
if (!core.types.isArrowFunctionExpression(callback) || callback.async || callback.generator || callback.params.length === 0 || callback.params.length > 3 || callback.params.some((parameter) => !core.types.isIdentifier(parameter)) || !core.types.isExpression(callback.body) || !isSafeKeyedMapResult(callback.body, callback.params[0], safeGlobals)) {
|
|
1050
|
+
return void 0;
|
|
1051
|
+
}
|
|
1052
|
+
outerSteps.push({ callback, kind: "map" });
|
|
1053
|
+
} else if (methodName === "filter") {
|
|
1054
|
+
if (current.arguments.length !== 1) return void 0;
|
|
1055
|
+
const predicate = current.arguments[0];
|
|
1056
|
+
if (!core.types.isArrowFunctionExpression(predicate) || predicate.async || predicate.generator || predicate.params.length !== 1 || !core.types.isIdentifier(predicate.params[0]) || !core.types.isExpression(predicate.body) || validateDerivedExpression(predicate.body, safeGlobals)) {
|
|
1057
|
+
return void 0;
|
|
1058
|
+
}
|
|
1059
|
+
outerSteps.push({ kind: "filter", predicate });
|
|
1060
|
+
} else if (methodName === "slice") {
|
|
1061
|
+
if (current.arguments.length < 1 || current.arguments.length > 2) return void 0;
|
|
1062
|
+
const bounds = [];
|
|
1063
|
+
for (const argument of current.arguments) {
|
|
1064
|
+
if (!core.types.isExpression(argument)) return void 0;
|
|
1065
|
+
if (validateKeyedArrayPositionExpression(argument, safeGlobals) !== void 0) {
|
|
1066
|
+
return void 0;
|
|
1067
|
+
}
|
|
1068
|
+
bounds.push(argument);
|
|
1069
|
+
}
|
|
1070
|
+
if (bounds.length === 1 && staticSliceIndex(bounds[0]) === 0) return void 0;
|
|
1071
|
+
outerSteps.push({ bounds, kind: "slice" });
|
|
1072
|
+
} else if (methodName === "toReversed") {
|
|
1073
|
+
if (current.arguments.length !== 0) return void 0;
|
|
1074
|
+
outerSteps.push({ kind: "reverse" });
|
|
1075
|
+
} else if (methodName === "toSorted") {
|
|
1076
|
+
if (current.arguments.length > 1) return void 0;
|
|
1077
|
+
const comparator = current.arguments[0];
|
|
1078
|
+
if (comparator && !core.types.isArrowFunctionExpression(comparator) && !core.types.isFunctionExpression(comparator)) {
|
|
1079
|
+
return void 0;
|
|
1080
|
+
}
|
|
1081
|
+
if (comparator && validateCollectionCallback(comparator, "toSorted", safeGlobals)) {
|
|
1082
|
+
return void 0;
|
|
1083
|
+
}
|
|
1084
|
+
outerSteps.push({ kind: "sort", ...comparator ? { comparator } : {} });
|
|
1085
|
+
} else {
|
|
1086
|
+
return void 0;
|
|
1087
|
+
}
|
|
1088
|
+
current = current.callee.object;
|
|
1089
|
+
}
|
|
1090
|
+
if (!core.types.isIdentifier(current, { name: parameterName }) || outerSteps.length < 2) {
|
|
1091
|
+
return void 0;
|
|
1092
|
+
}
|
|
1093
|
+
const steps = outerSteps.reverse();
|
|
1094
|
+
let mapSteps = 0;
|
|
1095
|
+
let structuralSteps = 0;
|
|
1096
|
+
let reorderSteps = 0;
|
|
1097
|
+
let reachedReorder = false;
|
|
1098
|
+
for (const step of steps) {
|
|
1099
|
+
if (step.kind === "map") {
|
|
1100
|
+
if (reachedReorder && structuralSteps > 0) return void 0;
|
|
1101
|
+
mapSteps += 1;
|
|
1102
|
+
} else if (step.kind === "filter" || step.kind === "slice") {
|
|
1103
|
+
if (reachedReorder) return void 0;
|
|
1104
|
+
structuralSteps += 1;
|
|
1105
|
+
} else {
|
|
1106
|
+
reachedReorder = true;
|
|
1107
|
+
reorderSteps += 1;
|
|
1108
|
+
}
|
|
1109
|
+
}
|
|
1110
|
+
if (reorderSteps < 1) {
|
|
1111
|
+
return structuralSteps > 0 && mapSteps > 0 ? steps : void 0;
|
|
1112
|
+
}
|
|
1113
|
+
if (mapSteps > 0 && reorderSteps >= 1) return steps;
|
|
1114
|
+
if (structuralSteps < 1 && reorderSteps < 2) return void 0;
|
|
1115
|
+
return steps;
|
|
1116
|
+
}
|
|
1117
|
+
function rewriteKeyedArrayReorderPipelineHints(root, hintedStateIndices, statesBySetter, filterHelperIdentifier, mapHelperIdentifier, mapReorderHelperIdentifier, mappedStructuralHelperIdentifier, reorderHelperIdentifier, structuralReorderHelperIdentifier, sliceHelperIdentifier, sortHelperIdentifier, structuralSortHelperIdentifier, safeGlobals, allowMapPipelines) {
|
|
1118
|
+
if (hintedStateIndices.size === 0) {
|
|
1119
|
+
return {
|
|
1120
|
+
root: core.types.cloneNode(root, true),
|
|
1121
|
+
filterCount: 0,
|
|
1122
|
+
mapCount: 0,
|
|
1123
|
+
mapReorderCount: 0,
|
|
1124
|
+
mapSortCount: 0,
|
|
1125
|
+
reorderCount: 0,
|
|
1126
|
+
sliceCount: 0,
|
|
1127
|
+
sortCount: 0,
|
|
1128
|
+
structuralReorderCount: 0,
|
|
1129
|
+
terminalStructuralPipelineCount: 0,
|
|
1130
|
+
structuralSortCount: 0,
|
|
1131
|
+
stateIndices: /* @__PURE__ */ new Set()
|
|
1132
|
+
};
|
|
1133
|
+
}
|
|
1134
|
+
const file = expressionFile(core.types.cloneNode(root, true));
|
|
1135
|
+
const stateIndices = /* @__PURE__ */ new Set();
|
|
1136
|
+
let filterCount = 0;
|
|
1137
|
+
let mapCount = 0;
|
|
1138
|
+
let mapReorderCount = 0;
|
|
1139
|
+
let mapSortCount = 0;
|
|
1140
|
+
let reorderCount = 0;
|
|
1141
|
+
let sliceCount = 0;
|
|
1142
|
+
let sortCount = 0;
|
|
1143
|
+
let structuralReorderCount = 0;
|
|
1144
|
+
let terminalStructuralPipelineCount = 0;
|
|
1145
|
+
let structuralSortCount = 0;
|
|
1146
|
+
core.traverse(file, {
|
|
1147
|
+
CallExpression(path) {
|
|
1148
|
+
const callee = path.get("callee");
|
|
1149
|
+
if (!callee.isIdentifier() || callee.scope.hasBinding(callee.node.name)) return;
|
|
1150
|
+
const state = statesBySetter.get(callee.node.name);
|
|
1151
|
+
if (!state || !hintedStateIndices.has(state.index) || path.node.arguments.length !== 1) {
|
|
1152
|
+
return;
|
|
1153
|
+
}
|
|
1154
|
+
const updater = path.node.arguments[0];
|
|
1155
|
+
if (!core.types.isArrowFunctionExpression(updater) || updater.async || updater.generator || updater.params.length !== 1 || !core.types.isIdentifier(updater.params[0]) || !core.types.isExpression(updater.body)) {
|
|
1156
|
+
return;
|
|
1157
|
+
}
|
|
1158
|
+
const steps = keyedArrayReorderPipeline(updater.body, updater.params[0].name, safeGlobals);
|
|
1159
|
+
if (!steps) return;
|
|
1160
|
+
const structuralPipeline = steps.some(
|
|
1161
|
+
(step) => step.kind === "filter" || step.kind === "slice"
|
|
1162
|
+
);
|
|
1163
|
+
const mapPipeline = steps.some((step) => step.kind === "map");
|
|
1164
|
+
if (mapPipeline && !allowMapPipelines) return;
|
|
1165
|
+
const terminalStructuralPipeline = mapPipeline && structuralPipeline && steps.every((step) => step.kind !== "reverse" && step.kind !== "sort");
|
|
1166
|
+
const previous = core.types.cloneNode(updater.params[0]);
|
|
1167
|
+
const statements = [];
|
|
1168
|
+
let value = core.types.cloneNode(previous);
|
|
1169
|
+
let hasMappedLineage = false;
|
|
1170
|
+
for (let stepIndex = 0; stepIndex < steps.length; stepIndex += 1) {
|
|
1171
|
+
const step = steps[stepIndex];
|
|
1172
|
+
if (step.kind === "map") {
|
|
1173
|
+
let mapEnd = stepIndex + 1;
|
|
1174
|
+
while (steps[mapEnd]?.kind === "map") mapEnd += 1;
|
|
1175
|
+
if (mapEnd - stepIndex > 1) {
|
|
1176
|
+
const pipelineValue = path.scope.generateUidIdentifier("farmMapValue");
|
|
1177
|
+
const applyMap = path.scope.generateUidIdentifier("farmApplyMap");
|
|
1178
|
+
const pipelineStatements = [];
|
|
1179
|
+
let current = core.types.cloneNode(pipelineValue);
|
|
1180
|
+
for (let mapIndex = stepIndex; mapIndex < mapEnd; mapIndex += 1) {
|
|
1181
|
+
const mapStep = steps[mapIndex];
|
|
1182
|
+
if (mapStep.kind !== "map") break;
|
|
1183
|
+
const method2 = path.scope.generateUidIdentifier(`farmMap${mapIndex + 1}`);
|
|
1184
|
+
const result3 = path.scope.generateUidIdentifier(`farmMappedItems${mapIndex + 1}`);
|
|
1185
|
+
pipelineStatements.push(
|
|
1186
|
+
core.types.variableDeclaration("const", [
|
|
1187
|
+
core.types.variableDeclarator(
|
|
1188
|
+
core.types.cloneNode(method2),
|
|
1189
|
+
core.types.memberExpression(core.types.cloneNode(current), core.types.identifier("map"))
|
|
1190
|
+
)
|
|
1191
|
+
]),
|
|
1192
|
+
core.types.variableDeclaration("const", [
|
|
1193
|
+
core.types.variableDeclarator(
|
|
1194
|
+
core.types.cloneNode(result3),
|
|
1195
|
+
core.types.callExpression(core.types.cloneNode(applyMap), [
|
|
1196
|
+
core.types.cloneNode(current),
|
|
1197
|
+
core.types.cloneNode(method2),
|
|
1198
|
+
core.types.cloneNode(mapStep.callback, true)
|
|
1199
|
+
])
|
|
1200
|
+
)
|
|
1201
|
+
])
|
|
1202
|
+
);
|
|
1203
|
+
current = core.types.cloneNode(result3);
|
|
1204
|
+
}
|
|
1205
|
+
const result2 = path.scope.generateUidIdentifier("farmPipelineValue");
|
|
1206
|
+
statements.push(
|
|
1207
|
+
core.types.variableDeclaration("const", [
|
|
1208
|
+
core.types.variableDeclarator(
|
|
1209
|
+
core.types.cloneNode(result2),
|
|
1210
|
+
core.types.callExpression(core.types.cloneNode(mapHelperIdentifier), [
|
|
1211
|
+
core.types.cloneNode(value),
|
|
1212
|
+
core.types.arrowFunctionExpression(
|
|
1213
|
+
[core.types.cloneNode(pipelineValue), core.types.cloneNode(applyMap)],
|
|
1214
|
+
core.types.blockStatement([
|
|
1215
|
+
...pipelineStatements,
|
|
1216
|
+
core.types.returnStatement(core.types.cloneNode(current))
|
|
1217
|
+
])
|
|
1218
|
+
)
|
|
1219
|
+
])
|
|
1220
|
+
)
|
|
1221
|
+
])
|
|
1222
|
+
);
|
|
1223
|
+
value = core.types.cloneNode(result2);
|
|
1224
|
+
mapCount += mapEnd - stepIndex;
|
|
1225
|
+
hasMappedLineage = true;
|
|
1226
|
+
stepIndex = mapEnd - 1;
|
|
1227
|
+
continue;
|
|
1228
|
+
}
|
|
1229
|
+
}
|
|
1230
|
+
const methodName = step.kind === "map" ? "map" : step.kind === "filter" ? "filter" : step.kind === "slice" ? "slice" : step.kind === "reverse" ? "toReversed" : "toSorted";
|
|
1231
|
+
const method = path.scope.generateUidIdentifier(
|
|
1232
|
+
step.kind === "filter" ? "farmFilter" : step.kind === "map" ? "farmMap" : step.kind === "slice" ? "farmSlice" : step.kind === "reverse" ? "farmToReversed" : "farmToSorted"
|
|
1233
|
+
);
|
|
1234
|
+
const result = path.scope.generateUidIdentifier("farmPipelineValue");
|
|
1235
|
+
const helper = step.kind === "map" ? mapHelperIdentifier : step.kind === "filter" ? filterHelperIdentifier : step.kind === "slice" ? sliceHelperIdentifier : step.kind === "reverse" ? structuralPipeline ? structuralReorderHelperIdentifier : hasMappedLineage ? mapReorderHelperIdentifier : reorderHelperIdentifier : structuralPipeline ? structuralSortHelperIdentifier : hasMappedLineage ? mapReorderHelperIdentifier : sortHelperIdentifier;
|
|
1236
|
+
const args = step.kind === "map" ? [core.types.cloneNode(step.callback, true)] : step.kind === "filter" ? [core.types.cloneNode(step.predicate, true)] : step.kind === "slice" ? step.bounds.map((bound) => core.types.cloneNode(bound, true)) : step.kind === "sort" && step.comparator ? [core.types.cloneNode(step.comparator, true)] : [];
|
|
1237
|
+
statements.push(
|
|
1238
|
+
core.types.variableDeclaration("const", [
|
|
1239
|
+
core.types.variableDeclarator(
|
|
1240
|
+
core.types.cloneNode(method),
|
|
1241
|
+
core.types.memberExpression(core.types.cloneNode(value), core.types.identifier(methodName))
|
|
1242
|
+
)
|
|
1243
|
+
]),
|
|
1244
|
+
core.types.variableDeclaration("const", [
|
|
1245
|
+
core.types.variableDeclarator(
|
|
1246
|
+
core.types.cloneNode(result),
|
|
1247
|
+
core.types.callExpression(core.types.cloneNode(helper), [
|
|
1248
|
+
core.types.cloneNode(value),
|
|
1249
|
+
core.types.cloneNode(method),
|
|
1250
|
+
...args
|
|
1251
|
+
])
|
|
1252
|
+
)
|
|
1253
|
+
])
|
|
1254
|
+
);
|
|
1255
|
+
value = core.types.cloneNode(result);
|
|
1256
|
+
if (step.kind === "map") {
|
|
1257
|
+
mapCount += 1;
|
|
1258
|
+
hasMappedLineage = true;
|
|
1259
|
+
} else if (step.kind === "filter") filterCount += 1;
|
|
1260
|
+
else if (step.kind === "slice") sliceCount += 1;
|
|
1261
|
+
else if (step.kind === "reverse") {
|
|
1262
|
+
reorderCount += 1;
|
|
1263
|
+
if (hasMappedLineage && !structuralPipeline) mapReorderCount += 1;
|
|
1264
|
+
if (structuralPipeline) structuralReorderCount += 1;
|
|
1265
|
+
} else {
|
|
1266
|
+
sortCount += 1;
|
|
1267
|
+
if (hasMappedLineage && !structuralPipeline) mapSortCount += 1;
|
|
1268
|
+
if (structuralPipeline) structuralSortCount += 1;
|
|
1269
|
+
}
|
|
1270
|
+
}
|
|
1271
|
+
statements.push(
|
|
1272
|
+
core.types.returnStatement(
|
|
1273
|
+
terminalStructuralPipeline ? core.types.callExpression(core.types.cloneNode(mappedStructuralHelperIdentifier), [core.types.cloneNode(value)]) : core.types.cloneNode(value)
|
|
1274
|
+
)
|
|
1275
|
+
);
|
|
1276
|
+
if (terminalStructuralPipeline) terminalStructuralPipelineCount += 1;
|
|
1277
|
+
path.node.arguments[0] = core.types.arrowFunctionExpression(
|
|
1278
|
+
[core.types.cloneNode(previous)],
|
|
1279
|
+
core.types.blockStatement(statements)
|
|
1280
|
+
);
|
|
1281
|
+
stateIndices.add(state.index);
|
|
1282
|
+
path.skip();
|
|
1283
|
+
}
|
|
1284
|
+
});
|
|
1285
|
+
return {
|
|
1286
|
+
root: file.program.body[0].expression,
|
|
1287
|
+
filterCount,
|
|
1288
|
+
mapCount,
|
|
1289
|
+
mapReorderCount,
|
|
1290
|
+
mapSortCount,
|
|
1291
|
+
reorderCount,
|
|
1292
|
+
sliceCount,
|
|
1293
|
+
sortCount,
|
|
1294
|
+
structuralReorderCount,
|
|
1295
|
+
terminalStructuralPipelineCount,
|
|
1296
|
+
structuralSortCount,
|
|
1297
|
+
stateIndices
|
|
1298
|
+
};
|
|
1299
|
+
}
|
|
1300
|
+
function rewriteQueuedKeyedArrayReorderMapHints(root, statesBySetter, mapUpdateIdentifier, queuedMapPipelineIdentifier, mapReorderIdentifier, reorderIdentifier, sortIdentifier, structuralReorderIdentifier, structuralSortIdentifier, allowed) {
|
|
1301
|
+
if (!allowed) return { root: core.types.cloneNode(root, true), mapCount: 0 };
|
|
1302
|
+
const file = expressionFile(core.types.cloneNode(root, true));
|
|
1303
|
+
let mapCount = 0;
|
|
1304
|
+
const containsHelperCall = (updater, helperNames) => {
|
|
1305
|
+
let found = false;
|
|
1306
|
+
core.types.traverseFast(updater.body, (node) => {
|
|
1307
|
+
if (!found && core.types.isCallExpression(node) && core.types.isIdentifier(node.callee) && helperNames.has(node.callee.name)) {
|
|
1308
|
+
found = true;
|
|
1309
|
+
}
|
|
1310
|
+
});
|
|
1311
|
+
return found;
|
|
1312
|
+
};
|
|
1313
|
+
const reorderHelperNames = /* @__PURE__ */ new Set([
|
|
1314
|
+
mapReorderIdentifier.name,
|
|
1315
|
+
reorderIdentifier.name,
|
|
1316
|
+
sortIdentifier.name
|
|
1317
|
+
]);
|
|
1318
|
+
const structuralHelperNames = /* @__PURE__ */ new Set([
|
|
1319
|
+
structuralReorderIdentifier.name,
|
|
1320
|
+
structuralSortIdentifier.name
|
|
1321
|
+
]);
|
|
1322
|
+
core.traverse(file, {
|
|
1323
|
+
BlockStatement(path) {
|
|
1324
|
+
let queuedReorderState;
|
|
1325
|
+
const statements = path.get("body");
|
|
1326
|
+
for (const statementPath of statements) {
|
|
1327
|
+
const statement = statementPath.node;
|
|
1328
|
+
if (!core.types.isExpressionStatement(statement) || !core.types.isCallExpression(statement.expression)) {
|
|
1329
|
+
queuedReorderState = void 0;
|
|
1330
|
+
continue;
|
|
1331
|
+
}
|
|
1332
|
+
const setterCall = statement.expression;
|
|
1333
|
+
if (!core.types.isIdentifier(setterCall.callee) || statementPath.scope.hasBinding(setterCall.callee.name) || setterCall.arguments.length !== 1) {
|
|
1334
|
+
queuedReorderState = void 0;
|
|
1335
|
+
continue;
|
|
1336
|
+
}
|
|
1337
|
+
const state = statesBySetter.get(setterCall.callee.name);
|
|
1338
|
+
const updater = setterCall.arguments[0];
|
|
1339
|
+
if (!state || !core.types.isArrowFunctionExpression(updater) || updater.async || updater.generator || updater.params.length !== 1 || !core.types.isIdentifier(updater.params[0])) {
|
|
1340
|
+
queuedReorderState = void 0;
|
|
1341
|
+
continue;
|
|
1342
|
+
}
|
|
1343
|
+
if (containsHelperCall(updater, reorderHelperNames) && !containsHelperCall(updater, structuralHelperNames)) {
|
|
1344
|
+
queuedReorderState = state.index;
|
|
1345
|
+
continue;
|
|
1346
|
+
}
|
|
1347
|
+
if (queuedReorderState !== state.index || !core.types.isCallExpression(updater.body) || !core.types.isIdentifier(updater.body.callee, { name: mapUpdateIdentifier.name }) || updater.body.arguments.length !== 2) {
|
|
1348
|
+
queuedReorderState = void 0;
|
|
1349
|
+
continue;
|
|
1350
|
+
}
|
|
1351
|
+
const pipeline = updater.body.arguments[1];
|
|
1352
|
+
if (!core.types.isArrowFunctionExpression(pipeline) || pipeline.params.length !== 2 || !core.types.isIdentifier(pipeline.params[1])) {
|
|
1353
|
+
queuedReorderState = void 0;
|
|
1354
|
+
continue;
|
|
1355
|
+
}
|
|
1356
|
+
let pipelineMapCount = 0;
|
|
1357
|
+
const applyMapName = pipeline.params[1].name;
|
|
1358
|
+
core.types.traverseFast(pipeline.body, (node) => {
|
|
1359
|
+
if (core.types.isCallExpression(node) && core.types.isIdentifier(node.callee, { name: applyMapName })) {
|
|
1360
|
+
pipelineMapCount += 1;
|
|
1361
|
+
}
|
|
1362
|
+
});
|
|
1363
|
+
if (pipelineMapCount === 0) {
|
|
1364
|
+
queuedReorderState = void 0;
|
|
1365
|
+
continue;
|
|
1366
|
+
}
|
|
1367
|
+
updater.body.callee = core.types.cloneNode(queuedMapPipelineIdentifier);
|
|
1368
|
+
mapCount += pipelineMapCount;
|
|
1369
|
+
}
|
|
1370
|
+
}
|
|
1371
|
+
});
|
|
1372
|
+
return {
|
|
1373
|
+
root: file.program.body[0].expression,
|
|
1374
|
+
mapCount
|
|
1375
|
+
};
|
|
1376
|
+
}
|
|
1377
|
+
function countKeyedArrayMapPipeline(updater, mapUpdateIdentifier) {
|
|
1378
|
+
if (!core.types.isCallExpression(updater.body) || !core.types.isIdentifier(updater.body.callee, { name: mapUpdateIdentifier.name }) || updater.body.arguments.length !== 2) {
|
|
1379
|
+
return 0;
|
|
1380
|
+
}
|
|
1381
|
+
const pipeline = updater.body.arguments[1];
|
|
1382
|
+
if (!core.types.isArrowFunctionExpression(pipeline) || pipeline.params.length !== 2 || !core.types.isIdentifier(pipeline.params[1])) {
|
|
1383
|
+
return 0;
|
|
1384
|
+
}
|
|
1385
|
+
const applyMapName = pipeline.params[1].name;
|
|
1386
|
+
let count = 0;
|
|
1387
|
+
core.types.traverseFast(pipeline.body, (node) => {
|
|
1388
|
+
if (core.types.isCallExpression(node) && core.types.isIdentifier(node.callee, { name: applyMapName })) {
|
|
1389
|
+
count += 1;
|
|
1390
|
+
}
|
|
1391
|
+
});
|
|
1392
|
+
return count;
|
|
1393
|
+
}
|
|
1394
|
+
function rewriteQueuedKeyedArrayMappedStructuralHints(root, statesBySetter, mapUpdateIdentifier, queuedMapPipelineIdentifier, mappedStructuralIdentifier, filterIdentifier, sliceIdentifier, allowed) {
|
|
1395
|
+
if (!allowed) {
|
|
1396
|
+
return {
|
|
1397
|
+
root: core.types.cloneNode(root, true),
|
|
1398
|
+
mapCount: 0,
|
|
1399
|
+
structuralCount: 0,
|
|
1400
|
+
stateIndices: /* @__PURE__ */ new Set()
|
|
1401
|
+
};
|
|
1402
|
+
}
|
|
1403
|
+
const file = expressionFile(core.types.cloneNode(root, true));
|
|
1404
|
+
let mapCount = 0;
|
|
1405
|
+
let structuralCount = 0;
|
|
1406
|
+
const stateIndices = /* @__PURE__ */ new Set();
|
|
1407
|
+
const terminalStructuralReturn = (updater) => {
|
|
1408
|
+
if (!core.types.isBlockStatement(updater.body)) return void 0;
|
|
1409
|
+
const statement = updater.body.body.at(-1);
|
|
1410
|
+
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) {
|
|
1411
|
+
return void 0;
|
|
1412
|
+
}
|
|
1413
|
+
return statement;
|
|
1414
|
+
};
|
|
1415
|
+
core.traverse(file, {
|
|
1416
|
+
BlockStatement(path) {
|
|
1417
|
+
let mappedStructuralState;
|
|
1418
|
+
let pendingMaps = [];
|
|
1419
|
+
const statements = path.get("body");
|
|
1420
|
+
for (const statementPath of statements) {
|
|
1421
|
+
const statement = statementPath.node;
|
|
1422
|
+
if (!core.types.isExpressionStatement(statement) || !core.types.isCallExpression(statement.expression)) {
|
|
1423
|
+
mappedStructuralState = void 0;
|
|
1424
|
+
pendingMaps = [];
|
|
1425
|
+
continue;
|
|
1426
|
+
}
|
|
1427
|
+
const setterCall = statement.expression;
|
|
1428
|
+
if (!core.types.isIdentifier(setterCall.callee) || statementPath.scope.hasBinding(setterCall.callee.name) || setterCall.arguments.length !== 1) {
|
|
1429
|
+
mappedStructuralState = void 0;
|
|
1430
|
+
pendingMaps = [];
|
|
1431
|
+
continue;
|
|
1432
|
+
}
|
|
1433
|
+
const state = statesBySetter.get(setterCall.callee.name);
|
|
1434
|
+
const updater = setterCall.arguments[0];
|
|
1435
|
+
if (!state || !core.types.isArrowFunctionExpression(updater) || updater.async || updater.generator || updater.params.length !== 1 || !core.types.isIdentifier(updater.params[0])) {
|
|
1436
|
+
mappedStructuralState = void 0;
|
|
1437
|
+
pendingMaps = [];
|
|
1438
|
+
continue;
|
|
1439
|
+
}
|
|
1440
|
+
const pipelineMapCount = countKeyedArrayMapPipeline(updater, mapUpdateIdentifier);
|
|
1441
|
+
if (pipelineMapCount > 0) {
|
|
1442
|
+
if (mappedStructuralState !== void 0) {
|
|
1443
|
+
mappedStructuralState = void 0;
|
|
1444
|
+
pendingMaps = [];
|
|
1445
|
+
continue;
|
|
1446
|
+
}
|
|
1447
|
+
const candidate = {
|
|
1448
|
+
count: pipelineMapCount,
|
|
1449
|
+
stateIndex: state.index,
|
|
1450
|
+
updater
|
|
1451
|
+
};
|
|
1452
|
+
pendingMaps = pendingMaps[0]?.stateIndex === state.index ? [...pendingMaps, candidate] : [candidate];
|
|
1453
|
+
continue;
|
|
1454
|
+
}
|
|
1455
|
+
const structuralReturn = terminalStructuralReturn(updater);
|
|
1456
|
+
const hasPendingMaps = pendingMaps.length > 0 && pendingMaps[0].stateIndex === state.index;
|
|
1457
|
+
if (!structuralReturn || !hasPendingMaps && mappedStructuralState !== state.index) {
|
|
1458
|
+
mappedStructuralState = void 0;
|
|
1459
|
+
pendingMaps = [];
|
|
1460
|
+
continue;
|
|
1461
|
+
}
|
|
1462
|
+
if (hasPendingMaps) {
|
|
1463
|
+
for (const candidate of pendingMaps) {
|
|
1464
|
+
candidate.updater.body.callee = core.types.cloneNode(queuedMapPipelineIdentifier);
|
|
1465
|
+
mapCount += candidate.count;
|
|
1466
|
+
}
|
|
1467
|
+
}
|
|
1468
|
+
const structuralValue = structuralReturn.argument;
|
|
1469
|
+
if (!core.types.isExpression(structuralValue)) {
|
|
1470
|
+
mappedStructuralState = void 0;
|
|
1471
|
+
pendingMaps = [];
|
|
1472
|
+
continue;
|
|
1473
|
+
}
|
|
1474
|
+
structuralReturn.argument = core.types.callExpression(core.types.cloneNode(mappedStructuralIdentifier), [
|
|
1475
|
+
core.types.cloneNode(structuralValue)
|
|
1476
|
+
]);
|
|
1477
|
+
structuralCount += 1;
|
|
1478
|
+
stateIndices.add(state.index);
|
|
1479
|
+
mappedStructuralState = state.index;
|
|
1480
|
+
pendingMaps = [];
|
|
1481
|
+
}
|
|
1482
|
+
}
|
|
1483
|
+
});
|
|
1484
|
+
return {
|
|
1485
|
+
root: file.program.body[0].expression,
|
|
1486
|
+
mapCount,
|
|
1487
|
+
structuralCount,
|
|
1488
|
+
stateIndices
|
|
1489
|
+
};
|
|
1490
|
+
}
|
|
1491
|
+
function rewriteQueuedKeyedArrayStructuralMapHints(root, statesBySetter, mapUpdateIdentifier, mapPipelineIdentifier, appendIdentifier, mappedStructuralAppendIdentifier, structuralAppendMapPipelineIdentifier, filterIdentifier, sliceIdentifier, mappedStructuralIdentifier, allowed) {
|
|
1492
|
+
if (!allowed) {
|
|
1493
|
+
return {
|
|
1494
|
+
root: core.types.cloneNode(root, true),
|
|
1495
|
+
mapCount: 0,
|
|
1496
|
+
mappedStructuralAppendCount: 0,
|
|
1497
|
+
structuralAppendMapCount: 0,
|
|
1498
|
+
stateIndices: /* @__PURE__ */ new Set()
|
|
1499
|
+
};
|
|
1500
|
+
}
|
|
1501
|
+
const file = expressionFile(core.types.cloneNode(root, true));
|
|
1502
|
+
let mapCount = 0;
|
|
1503
|
+
let mappedStructuralAppendCount = 0;
|
|
1504
|
+
let structuralAppendMapCount = 0;
|
|
1505
|
+
const stateIndices = /* @__PURE__ */ new Set();
|
|
1506
|
+
const structuralUpdateKind = (updater) => {
|
|
1507
|
+
if (!core.types.isBlockStatement(updater.body)) return void 0;
|
|
1508
|
+
const statement = updater.body.body.at(-1);
|
|
1509
|
+
if (!core.types.isReturnStatement(statement) || !statement.argument) return void 0;
|
|
1510
|
+
let found;
|
|
1511
|
+
let mapped = false;
|
|
1512
|
+
core.types.traverseFast(statement.argument, (node) => {
|
|
1513
|
+
if (!found && core.types.isCallExpression(node) && core.types.isIdentifier(node.callee)) {
|
|
1514
|
+
if (node.callee.name === filterIdentifier.name) found = "filter";
|
|
1515
|
+
if (node.callee.name === sliceIdentifier.name) found = "slice";
|
|
1516
|
+
}
|
|
1517
|
+
if (!mapped && core.types.isCallExpression(node) && core.types.isIdentifier(node.callee, { name: mappedStructuralIdentifier.name })) {
|
|
1518
|
+
mapped = true;
|
|
1519
|
+
}
|
|
1520
|
+
});
|
|
1521
|
+
return found ? { kind: found, mapped } : void 0;
|
|
1522
|
+
};
|
|
1523
|
+
core.traverse(file, {
|
|
1524
|
+
BlockStatement(path) {
|
|
1525
|
+
let structuralState;
|
|
1526
|
+
let structuralAppendState;
|
|
1527
|
+
let structuralMapState;
|
|
1528
|
+
let structuralKind;
|
|
1529
|
+
const statements = path.get("body");
|
|
1530
|
+
for (const statementPath of statements) {
|
|
1531
|
+
const statement = statementPath.node;
|
|
1532
|
+
if (!core.types.isExpressionStatement(statement) || !core.types.isCallExpression(statement.expression)) {
|
|
1533
|
+
structuralState = void 0;
|
|
1534
|
+
structuralAppendState = void 0;
|
|
1535
|
+
structuralMapState = void 0;
|
|
1536
|
+
structuralKind = void 0;
|
|
1537
|
+
continue;
|
|
1538
|
+
}
|
|
1539
|
+
const setterCall = statement.expression;
|
|
1540
|
+
if (!core.types.isIdentifier(setterCall.callee) || statementPath.scope.hasBinding(setterCall.callee.name) || setterCall.arguments.length !== 1) {
|
|
1541
|
+
structuralState = void 0;
|
|
1542
|
+
structuralAppendState = void 0;
|
|
1543
|
+
structuralMapState = void 0;
|
|
1544
|
+
structuralKind = void 0;
|
|
1545
|
+
continue;
|
|
1546
|
+
}
|
|
1547
|
+
const state = statesBySetter.get(setterCall.callee.name);
|
|
1548
|
+
const updater = setterCall.arguments[0];
|
|
1549
|
+
if (!state || !core.types.isArrowFunctionExpression(updater) || updater.async || updater.generator || updater.params.length !== 1 || !core.types.isIdentifier(updater.params[0])) {
|
|
1550
|
+
structuralState = void 0;
|
|
1551
|
+
structuralAppendState = void 0;
|
|
1552
|
+
structuralMapState = void 0;
|
|
1553
|
+
structuralKind = void 0;
|
|
1554
|
+
continue;
|
|
1555
|
+
}
|
|
1556
|
+
const nextStructuralKind = structuralUpdateKind(updater);
|
|
1557
|
+
if (nextStructuralKind) {
|
|
1558
|
+
structuralState = state.index;
|
|
1559
|
+
structuralAppendState = void 0;
|
|
1560
|
+
structuralMapState = nextStructuralKind.mapped ? state.index : void 0;
|
|
1561
|
+
structuralKind = nextStructuralKind.kind;
|
|
1562
|
+
continue;
|
|
1563
|
+
}
|
|
1564
|
+
const appendCalls = [];
|
|
1565
|
+
core.types.traverseFast(updater.body, (node) => {
|
|
1566
|
+
if (core.types.isCallExpression(node) && core.types.isIdentifier(node.callee, { name: appendIdentifier.name })) {
|
|
1567
|
+
appendCalls.push(node);
|
|
1568
|
+
}
|
|
1569
|
+
});
|
|
1570
|
+
if (appendCalls.length > 0) {
|
|
1571
|
+
if (structuralState === state.index && structuralKind !== void 0) {
|
|
1572
|
+
structuralAppendState = state.index;
|
|
1573
|
+
if (structuralMapState === state.index) {
|
|
1574
|
+
for (const call of appendCalls) {
|
|
1575
|
+
call.callee = core.types.cloneNode(mappedStructuralAppendIdentifier);
|
|
1576
|
+
}
|
|
1577
|
+
mappedStructuralAppendCount += appendCalls.length;
|
|
1578
|
+
}
|
|
1579
|
+
} else {
|
|
1580
|
+
structuralState = void 0;
|
|
1581
|
+
structuralAppendState = void 0;
|
|
1582
|
+
structuralMapState = void 0;
|
|
1583
|
+
structuralKind = void 0;
|
|
1584
|
+
}
|
|
1585
|
+
continue;
|
|
1586
|
+
}
|
|
1587
|
+
const pipelineMapCount = countKeyedArrayMapPipeline(updater, mapUpdateIdentifier);
|
|
1588
|
+
if (structuralState !== state.index || pipelineMapCount === 0) {
|
|
1589
|
+
structuralState = void 0;
|
|
1590
|
+
structuralAppendState = void 0;
|
|
1591
|
+
structuralMapState = void 0;
|
|
1592
|
+
structuralKind = void 0;
|
|
1593
|
+
continue;
|
|
1594
|
+
}
|
|
1595
|
+
updater.body.callee = core.types.cloneNode(
|
|
1596
|
+
structuralAppendState === state.index ? structuralAppendMapPipelineIdentifier : mapPipelineIdentifier
|
|
1597
|
+
);
|
|
1598
|
+
mapCount += pipelineMapCount;
|
|
1599
|
+
if (structuralAppendState === state.index) {
|
|
1600
|
+
structuralAppendMapCount += pipelineMapCount;
|
|
1601
|
+
}
|
|
1602
|
+
structuralMapState = state.index;
|
|
1603
|
+
stateIndices.add(state.index);
|
|
1604
|
+
}
|
|
1605
|
+
}
|
|
1606
|
+
});
|
|
1607
|
+
return {
|
|
1608
|
+
root: file.program.body[0].expression,
|
|
1609
|
+
mapCount,
|
|
1610
|
+
mappedStructuralAppendCount,
|
|
1611
|
+
structuralAppendMapCount,
|
|
1612
|
+
stateIndices
|
|
1613
|
+
};
|
|
1614
|
+
}
|
|
1615
|
+
function rewriteQueuedKeyedArrayStructuralPrependMapHints(root, statesBySetter, mapUpdateIdentifier, mapPipelineIdentifier, prependIdentifier, mappedStructuralPrependIdentifier, structuralPrependMapPipelineIdentifier, filterIdentifier, sliceIdentifier, mappedStructuralIdentifier, allowed) {
|
|
1616
|
+
if (!allowed) {
|
|
1617
|
+
return {
|
|
1618
|
+
root: core.types.cloneNode(root, true),
|
|
1619
|
+
mapCount: 0,
|
|
1620
|
+
mappedStructuralPrependCount: 0,
|
|
1621
|
+
structuralPrependMapCount: 0,
|
|
1622
|
+
stateIndices: /* @__PURE__ */ new Set()
|
|
1623
|
+
};
|
|
1624
|
+
}
|
|
1625
|
+
const file = expressionFile(core.types.cloneNode(root, true));
|
|
1626
|
+
let mapCount = 0;
|
|
1627
|
+
let mappedStructuralPrependCount = 0;
|
|
1628
|
+
let structuralPrependMapCount = 0;
|
|
1629
|
+
const stateIndices = /* @__PURE__ */ new Set();
|
|
1630
|
+
const structuralUpdateKind = (updater) => {
|
|
1631
|
+
if (!core.types.isBlockStatement(updater.body)) return void 0;
|
|
1632
|
+
const statement = updater.body.body.at(-1);
|
|
1633
|
+
if (!core.types.isReturnStatement(statement) || !statement.argument) return void 0;
|
|
1634
|
+
let found;
|
|
1635
|
+
let mapped = false;
|
|
1636
|
+
core.types.traverseFast(statement.argument, (node) => {
|
|
1637
|
+
if (!found && core.types.isCallExpression(node) && core.types.isIdentifier(node.callee)) {
|
|
1638
|
+
if (node.callee.name === filterIdentifier.name) found = "filter";
|
|
1639
|
+
if (node.callee.name === sliceIdentifier.name) found = "slice";
|
|
1640
|
+
}
|
|
1641
|
+
if (!mapped && core.types.isCallExpression(node) && core.types.isIdentifier(node.callee, { name: mappedStructuralIdentifier.name })) {
|
|
1642
|
+
mapped = true;
|
|
1643
|
+
}
|
|
1644
|
+
});
|
|
1645
|
+
return found ? { kind: found, mapped } : void 0;
|
|
1646
|
+
};
|
|
1647
|
+
core.traverse(file, {
|
|
1648
|
+
BlockStatement(path) {
|
|
1649
|
+
let structuralState;
|
|
1650
|
+
let structuralPrependState;
|
|
1651
|
+
let structuralMapState;
|
|
1652
|
+
let structuralKind;
|
|
1653
|
+
const statements = path.get("body");
|
|
1654
|
+
for (const statementPath of statements) {
|
|
1655
|
+
const statement = statementPath.node;
|
|
1656
|
+
if (!core.types.isExpressionStatement(statement) || !core.types.isCallExpression(statement.expression)) {
|
|
1657
|
+
structuralState = void 0;
|
|
1658
|
+
structuralPrependState = void 0;
|
|
1659
|
+
structuralMapState = void 0;
|
|
1660
|
+
structuralKind = void 0;
|
|
1661
|
+
continue;
|
|
1662
|
+
}
|
|
1663
|
+
const setterCall = statement.expression;
|
|
1664
|
+
if (!core.types.isIdentifier(setterCall.callee) || statementPath.scope.hasBinding(setterCall.callee.name) || setterCall.arguments.length !== 1) {
|
|
1665
|
+
structuralState = void 0;
|
|
1666
|
+
structuralPrependState = void 0;
|
|
1667
|
+
structuralMapState = void 0;
|
|
1668
|
+
structuralKind = void 0;
|
|
1669
|
+
continue;
|
|
1670
|
+
}
|
|
1671
|
+
const state = statesBySetter.get(setterCall.callee.name);
|
|
1672
|
+
const updater = setterCall.arguments[0];
|
|
1673
|
+
if (!state || !core.types.isArrowFunctionExpression(updater) || updater.async || updater.generator || updater.params.length !== 1 || !core.types.isIdentifier(updater.params[0])) {
|
|
1674
|
+
structuralState = void 0;
|
|
1675
|
+
structuralPrependState = void 0;
|
|
1676
|
+
structuralMapState = void 0;
|
|
1677
|
+
structuralKind = void 0;
|
|
1678
|
+
continue;
|
|
1679
|
+
}
|
|
1680
|
+
const nextStructuralKind = structuralUpdateKind(updater);
|
|
1681
|
+
if (nextStructuralKind) {
|
|
1682
|
+
structuralState = state.index;
|
|
1683
|
+
structuralPrependState = void 0;
|
|
1684
|
+
structuralMapState = nextStructuralKind.mapped ? state.index : void 0;
|
|
1685
|
+
structuralKind = nextStructuralKind.kind;
|
|
1686
|
+
continue;
|
|
1687
|
+
}
|
|
1688
|
+
const prependCalls = [];
|
|
1689
|
+
core.types.traverseFast(updater.body, (node) => {
|
|
1690
|
+
if (core.types.isCallExpression(node) && core.types.isIdentifier(node.callee, { name: prependIdentifier.name })) {
|
|
1691
|
+
prependCalls.push(node);
|
|
1692
|
+
}
|
|
1693
|
+
});
|
|
1694
|
+
if (prependCalls.length > 0) {
|
|
1695
|
+
if (structuralState === state.index && structuralKind !== void 0) {
|
|
1696
|
+
structuralPrependState = state.index;
|
|
1697
|
+
if (structuralMapState === state.index) {
|
|
1698
|
+
for (const call of prependCalls) {
|
|
1699
|
+
call.callee = core.types.cloneNode(mappedStructuralPrependIdentifier);
|
|
1700
|
+
}
|
|
1701
|
+
mappedStructuralPrependCount += prependCalls.length;
|
|
1702
|
+
}
|
|
1703
|
+
} else {
|
|
1704
|
+
structuralState = void 0;
|
|
1705
|
+
structuralPrependState = void 0;
|
|
1706
|
+
structuralMapState = void 0;
|
|
1707
|
+
structuralKind = void 0;
|
|
1708
|
+
}
|
|
1709
|
+
continue;
|
|
1710
|
+
}
|
|
1711
|
+
const pipelineMapCount = countKeyedArrayMapPipeline(updater, mapUpdateIdentifier) || countKeyedArrayMapPipeline(updater, mapPipelineIdentifier);
|
|
1712
|
+
if (structuralState !== state.index || pipelineMapCount === 0) {
|
|
1713
|
+
structuralState = void 0;
|
|
1714
|
+
structuralPrependState = void 0;
|
|
1715
|
+
structuralMapState = void 0;
|
|
1716
|
+
structuralKind = void 0;
|
|
1717
|
+
continue;
|
|
1718
|
+
}
|
|
1719
|
+
updater.body.callee = core.types.cloneNode(
|
|
1720
|
+
structuralPrependState === state.index ? structuralPrependMapPipelineIdentifier : mapPipelineIdentifier
|
|
1721
|
+
);
|
|
1722
|
+
mapCount += pipelineMapCount;
|
|
1723
|
+
if (structuralPrependState === state.index) {
|
|
1724
|
+
structuralPrependMapCount += pipelineMapCount;
|
|
1725
|
+
}
|
|
1726
|
+
structuralMapState = state.index;
|
|
1727
|
+
stateIndices.add(state.index);
|
|
1728
|
+
}
|
|
1729
|
+
}
|
|
1730
|
+
});
|
|
1731
|
+
return {
|
|
1732
|
+
root: file.program.body[0].expression,
|
|
1733
|
+
mapCount,
|
|
1734
|
+
mappedStructuralPrependCount,
|
|
1735
|
+
structuralPrependMapCount,
|
|
1736
|
+
stateIndices
|
|
1737
|
+
};
|
|
1738
|
+
}
|
|
1739
|
+
function rewriteQueuedKeyedArrayStructuralReorderHints(root, statesBySetter, filterIdentifier, sliceIdentifier, mapPipelineIdentifier, queuedMapPipelineIdentifier, mappedStructuralIdentifier, mapReorderIdentifier, reorderIdentifier, sortIdentifier, structuralReorderIdentifier, structuralSortIdentifier, allowed) {
|
|
1740
|
+
if (!allowed) {
|
|
1741
|
+
return {
|
|
1742
|
+
root: core.types.cloneNode(root, true),
|
|
1743
|
+
reorderCount: 0,
|
|
1744
|
+
sortCount: 0,
|
|
1745
|
+
replacedMapReorderCount: 0,
|
|
1746
|
+
replacedMapSortCount: 0,
|
|
1747
|
+
replacedQueuedMapCount: 0
|
|
1748
|
+
};
|
|
1749
|
+
}
|
|
1750
|
+
const file = expressionFile(core.types.cloneNode(root, true));
|
|
1751
|
+
let reorderCount = 0;
|
|
1752
|
+
let sortCount = 0;
|
|
1753
|
+
let replacedMapReorderCount = 0;
|
|
1754
|
+
let replacedMapSortCount = 0;
|
|
1755
|
+
let replacedQueuedMapCount = 0;
|
|
1756
|
+
core.traverse(file, {
|
|
1757
|
+
BlockStatement(path) {
|
|
1758
|
+
let structuralState;
|
|
1759
|
+
const statements = path.get("body");
|
|
1760
|
+
for (const statementPath of statements) {
|
|
1761
|
+
const statement = statementPath.node;
|
|
1762
|
+
if (!core.types.isExpressionStatement(statement) || !core.types.isCallExpression(statement.expression)) {
|
|
1763
|
+
structuralState = void 0;
|
|
1764
|
+
continue;
|
|
1765
|
+
}
|
|
1766
|
+
const setterCall = statement.expression;
|
|
1767
|
+
if (!core.types.isIdentifier(setterCall.callee) || statementPath.scope.hasBinding(setterCall.callee.name) || setterCall.arguments.length !== 1) {
|
|
1768
|
+
structuralState = void 0;
|
|
1769
|
+
continue;
|
|
1770
|
+
}
|
|
1771
|
+
const state = statesBySetter.get(setterCall.callee.name);
|
|
1772
|
+
const updater = setterCall.arguments[0];
|
|
1773
|
+
if (!state || !core.types.isArrowFunctionExpression(updater) || updater.async || updater.generator || updater.params.length !== 1 || !core.types.isIdentifier(updater.params[0])) {
|
|
1774
|
+
structuralState = void 0;
|
|
1775
|
+
continue;
|
|
1776
|
+
}
|
|
1777
|
+
const methodKinds = /* @__PURE__ */ new Map();
|
|
1778
|
+
core.types.traverseFast(updater.body, (node) => {
|
|
1779
|
+
if (!core.types.isVariableDeclarator(node) || !core.types.isIdentifier(node.id) || !core.types.isMemberExpression(node.init) || node.init.computed || !core.types.isIdentifier(node.init.property)) {
|
|
1780
|
+
return;
|
|
1781
|
+
}
|
|
1782
|
+
if (node.init.property.name === "toReversed") methodKinds.set(node.id.name, "reverse");
|
|
1783
|
+
if (node.init.property.name === "toSorted") methodKinds.set(node.id.name, "sort");
|
|
1784
|
+
});
|
|
1785
|
+
let startsStructuralLineage = false;
|
|
1786
|
+
let continuesStructuralLineage = false;
|
|
1787
|
+
let unsupported = false;
|
|
1788
|
+
const queuedMaps = [];
|
|
1789
|
+
const reorderCalls = [];
|
|
1790
|
+
core.types.traverseFast(updater.body, (node) => {
|
|
1791
|
+
if (!core.types.isCallExpression(node) || !core.types.isIdentifier(node.callee)) return;
|
|
1792
|
+
const helperName = node.callee.name;
|
|
1793
|
+
if (helperName === filterIdentifier.name || helperName === sliceIdentifier.name || helperName === mappedStructuralIdentifier.name) {
|
|
1794
|
+
startsStructuralLineage = true;
|
|
1795
|
+
return;
|
|
1796
|
+
}
|
|
1797
|
+
if (helperName === structuralReorderIdentifier.name || helperName === structuralSortIdentifier.name) {
|
|
1798
|
+
startsStructuralLineage = true;
|
|
1799
|
+
return;
|
|
1800
|
+
}
|
|
1801
|
+
if (helperName === mapPipelineIdentifier.name) {
|
|
1802
|
+
continuesStructuralLineage = true;
|
|
1803
|
+
return;
|
|
1804
|
+
}
|
|
1805
|
+
if (helperName === queuedMapPipelineIdentifier.name) {
|
|
1806
|
+
continuesStructuralLineage = true;
|
|
1807
|
+
queuedMaps.push(node);
|
|
1808
|
+
return;
|
|
1809
|
+
}
|
|
1810
|
+
if (helperName === reorderIdentifier.name) {
|
|
1811
|
+
continuesStructuralLineage = true;
|
|
1812
|
+
reorderCalls.push({ call: node, kind: "reverse", mapped: false });
|
|
1813
|
+
return;
|
|
1814
|
+
}
|
|
1815
|
+
if (helperName === sortIdentifier.name) {
|
|
1816
|
+
continuesStructuralLineage = true;
|
|
1817
|
+
reorderCalls.push({ call: node, kind: "sort", mapped: false });
|
|
1818
|
+
return;
|
|
1819
|
+
}
|
|
1820
|
+
if (helperName === mapReorderIdentifier.name) {
|
|
1821
|
+
const method = node.arguments[1];
|
|
1822
|
+
const kind = core.types.isIdentifier(method) ? methodKinds.get(method.name) : void 0;
|
|
1823
|
+
if (!kind) {
|
|
1824
|
+
unsupported = true;
|
|
1825
|
+
return;
|
|
1826
|
+
}
|
|
1827
|
+
continuesStructuralLineage = true;
|
|
1828
|
+
reorderCalls.push({ call: node, kind, mapped: true });
|
|
1829
|
+
}
|
|
1830
|
+
});
|
|
1831
|
+
const hasStructuralLineage = startsStructuralLineage || structuralState === state.index;
|
|
1832
|
+
if (unsupported || !startsStructuralLineage && !continuesStructuralLineage) {
|
|
1833
|
+
structuralState = void 0;
|
|
1834
|
+
continue;
|
|
1835
|
+
}
|
|
1836
|
+
if (!hasStructuralLineage) {
|
|
1837
|
+
structuralState = void 0;
|
|
1838
|
+
continue;
|
|
1839
|
+
}
|
|
1840
|
+
for (const call of queuedMaps) {
|
|
1841
|
+
call.callee = core.types.cloneNode(mapPipelineIdentifier);
|
|
1842
|
+
replacedQueuedMapCount += 1;
|
|
1843
|
+
}
|
|
1844
|
+
for (const { call, kind, mapped } of reorderCalls) {
|
|
1845
|
+
call.callee = core.types.cloneNode(
|
|
1846
|
+
kind === "reverse" ? structuralReorderIdentifier : structuralSortIdentifier
|
|
1847
|
+
);
|
|
1848
|
+
if (kind === "reverse") {
|
|
1849
|
+
reorderCount += 1;
|
|
1850
|
+
if (mapped) replacedMapReorderCount += 1;
|
|
1851
|
+
} else {
|
|
1852
|
+
sortCount += 1;
|
|
1853
|
+
if (mapped) replacedMapSortCount += 1;
|
|
1854
|
+
}
|
|
1855
|
+
}
|
|
1856
|
+
structuralState = state.index;
|
|
1857
|
+
}
|
|
1858
|
+
}
|
|
1859
|
+
});
|
|
1860
|
+
return {
|
|
1861
|
+
root: file.program.body[0].expression,
|
|
1862
|
+
reorderCount,
|
|
1863
|
+
sortCount,
|
|
1864
|
+
replacedMapReorderCount,
|
|
1865
|
+
replacedMapSortCount,
|
|
1866
|
+
replacedQueuedMapCount
|
|
1867
|
+
};
|
|
1868
|
+
}
|
|
1869
|
+
function rewriteQueuedKeyedArrayMapReorderHints(root, statesBySetter, mapUpdateIdentifier, queuedMapPipelineIdentifier, mapReorderIdentifier, reorderIdentifier, sortIdentifier, structuralReorderIdentifier, structuralSortIdentifier, allowed) {
|
|
1870
|
+
if (!allowed) {
|
|
1871
|
+
return {
|
|
1872
|
+
root: core.types.cloneNode(root, true),
|
|
1873
|
+
mapCount: 0,
|
|
1874
|
+
mapReorderCount: 0,
|
|
1875
|
+
mapSortCount: 0
|
|
1876
|
+
};
|
|
1877
|
+
}
|
|
1878
|
+
const file = expressionFile(core.types.cloneNode(root, true));
|
|
1879
|
+
let mapCount = 0;
|
|
1880
|
+
let mapReorderCount = 0;
|
|
1881
|
+
let mapSortCount = 0;
|
|
1882
|
+
core.traverse(file, {
|
|
1883
|
+
BlockStatement(path) {
|
|
1884
|
+
let mappedReorderState;
|
|
1885
|
+
let pendingMaps = [];
|
|
1886
|
+
const statements = path.get("body");
|
|
1887
|
+
for (const statementPath of statements) {
|
|
1888
|
+
const statement = statementPath.node;
|
|
1889
|
+
if (!core.types.isExpressionStatement(statement) || !core.types.isCallExpression(statement.expression)) {
|
|
1890
|
+
mappedReorderState = void 0;
|
|
1891
|
+
pendingMaps = [];
|
|
1892
|
+
continue;
|
|
1893
|
+
}
|
|
1894
|
+
const setterCall = statement.expression;
|
|
1895
|
+
if (!core.types.isIdentifier(setterCall.callee) || statementPath.scope.hasBinding(setterCall.callee.name) || setterCall.arguments.length !== 1) {
|
|
1896
|
+
mappedReorderState = void 0;
|
|
1897
|
+
pendingMaps = [];
|
|
1898
|
+
continue;
|
|
1899
|
+
}
|
|
1900
|
+
const state = statesBySetter.get(setterCall.callee.name);
|
|
1901
|
+
const updater = setterCall.arguments[0];
|
|
1902
|
+
if (!state || !core.types.isArrowFunctionExpression(updater) || updater.async || updater.generator || updater.params.length !== 1 || !core.types.isIdentifier(updater.params[0])) {
|
|
1903
|
+
mappedReorderState = void 0;
|
|
1904
|
+
pendingMaps = [];
|
|
1905
|
+
continue;
|
|
1906
|
+
}
|
|
1907
|
+
if (core.types.isCallExpression(updater.body) && core.types.isIdentifier(updater.body.callee, { name: mapUpdateIdentifier.name }) && updater.body.arguments.length === 2) {
|
|
1908
|
+
const pipeline = updater.body.arguments[1];
|
|
1909
|
+
let pipelineMapCount = 0;
|
|
1910
|
+
if (core.types.isArrowFunctionExpression(pipeline) && pipeline.params.length === 2 && core.types.isIdentifier(pipeline.params[1])) {
|
|
1911
|
+
const applyMapName = pipeline.params[1].name;
|
|
1912
|
+
core.types.traverseFast(pipeline.body, (node) => {
|
|
1913
|
+
if (core.types.isCallExpression(node) && core.types.isIdentifier(node.callee, { name: applyMapName })) {
|
|
1914
|
+
pipelineMapCount += 1;
|
|
1915
|
+
}
|
|
1916
|
+
});
|
|
1917
|
+
}
|
|
1918
|
+
if (pipelineMapCount > 0) {
|
|
1919
|
+
const candidate = {
|
|
1920
|
+
count: pipelineMapCount,
|
|
1921
|
+
stateIndex: state.index,
|
|
1922
|
+
updater
|
|
1923
|
+
};
|
|
1924
|
+
pendingMaps = pendingMaps[0]?.stateIndex === state.index ? [...pendingMaps, candidate] : [candidate];
|
|
1925
|
+
if (mappedReorderState !== state.index) mappedReorderState = void 0;
|
|
1926
|
+
continue;
|
|
1927
|
+
}
|
|
1928
|
+
}
|
|
1929
|
+
let containsMappedReorder = false;
|
|
1930
|
+
const reorderCalls = [];
|
|
1931
|
+
let structural = false;
|
|
1932
|
+
core.types.traverseFast(updater.body, (node) => {
|
|
1933
|
+
if (!core.types.isCallExpression(node) || !core.types.isIdentifier(node.callee)) return;
|
|
1934
|
+
if (node.callee.name === structuralReorderIdentifier.name || node.callee.name === structuralSortIdentifier.name) {
|
|
1935
|
+
structural = true;
|
|
1936
|
+
} else if (node.callee.name === mapReorderIdentifier.name) {
|
|
1937
|
+
containsMappedReorder = true;
|
|
1938
|
+
} else if (node.callee.name === reorderIdentifier.name) {
|
|
1939
|
+
reorderCalls.push({ call: node, kind: "reverse" });
|
|
1940
|
+
} else if (node.callee.name === sortIdentifier.name) {
|
|
1941
|
+
reorderCalls.push({ call: node, kind: "sort" });
|
|
1942
|
+
}
|
|
1943
|
+
});
|
|
1944
|
+
if (structural) {
|
|
1945
|
+
mappedReorderState = void 0;
|
|
1946
|
+
pendingMaps = [];
|
|
1947
|
+
continue;
|
|
1948
|
+
}
|
|
1949
|
+
const hasPendingMaps = pendingMaps.length > 0 && pendingMaps[0].stateIndex === state.index;
|
|
1950
|
+
if (containsMappedReorder && reorderCalls.length === 0) {
|
|
1951
|
+
mappedReorderState = pendingMaps.length === 0 ? state.index : void 0;
|
|
1952
|
+
pendingMaps = [];
|
|
1953
|
+
continue;
|
|
1954
|
+
}
|
|
1955
|
+
if (containsMappedReorder || reorderCalls.length === 0 || !hasPendingMaps && mappedReorderState !== state.index) {
|
|
1956
|
+
mappedReorderState = void 0;
|
|
1957
|
+
pendingMaps = [];
|
|
1958
|
+
continue;
|
|
1959
|
+
}
|
|
1960
|
+
if (hasPendingMaps) {
|
|
1961
|
+
for (const candidate of pendingMaps) {
|
|
1962
|
+
candidate.updater.body.callee = core.types.cloneNode(queuedMapPipelineIdentifier);
|
|
1963
|
+
mapCount += candidate.count;
|
|
1964
|
+
}
|
|
1965
|
+
}
|
|
1966
|
+
for (const { call, kind } of reorderCalls) {
|
|
1967
|
+
call.callee = core.types.cloneNode(mapReorderIdentifier);
|
|
1968
|
+
if (kind === "reverse") mapReorderCount += 1;
|
|
1969
|
+
else mapSortCount += 1;
|
|
1970
|
+
}
|
|
1971
|
+
mappedReorderState = state.index;
|
|
1972
|
+
pendingMaps = [];
|
|
1973
|
+
}
|
|
1003
1974
|
}
|
|
1004
1975
|
});
|
|
1005
1976
|
return {
|
|
1006
1977
|
root: file.program.body[0].expression,
|
|
1007
|
-
|
|
1008
|
-
|
|
1978
|
+
mapCount,
|
|
1979
|
+
mapReorderCount,
|
|
1980
|
+
mapSortCount
|
|
1009
1981
|
};
|
|
1010
1982
|
}
|
|
1011
1983
|
function rewriteKeyedArraySortHints(root, hintedStateIndices, statesBySetter, helperIdentifier, safeGlobals) {
|
|
@@ -1063,7 +2035,7 @@ function rewriteKeyedArraySortHints(root, hintedStateIndices, statesBySetter, he
|
|
|
1063
2035
|
stateIndices
|
|
1064
2036
|
};
|
|
1065
2037
|
}
|
|
1066
|
-
function rewriteKeyedArraySliceHints(root, hintedStateIndices, statesBySetter, helperIdentifier) {
|
|
2038
|
+
function rewriteKeyedArraySliceHints(root, hintedStateIndices, statesBySetter, helperIdentifier, safeGlobals) {
|
|
1067
2039
|
if (hintedStateIndices.size === 0) {
|
|
1068
2040
|
return { root: core.types.cloneNode(root, true), count: 0, stateIndices: /* @__PURE__ */ new Set() };
|
|
1069
2041
|
}
|
|
@@ -1082,14 +2054,13 @@ function rewriteKeyedArraySliceHints(root, hintedStateIndices, statesBySetter, h
|
|
|
1082
2054
|
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 || updater.body.arguments.length > 2 || !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: "slice" })) {
|
|
1083
2055
|
return;
|
|
1084
2056
|
}
|
|
1085
|
-
const
|
|
2057
|
+
const bounds = [];
|
|
1086
2058
|
for (const argument of updater.body.arguments) {
|
|
1087
2059
|
if (!core.types.isExpression(argument)) return;
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
indexes.push(value);
|
|
2060
|
+
if (validateKeyedArrayPositionExpression(argument, safeGlobals) !== void 0) return;
|
|
2061
|
+
bounds.push(argument);
|
|
1091
2062
|
}
|
|
1092
|
-
if (
|
|
2063
|
+
if (bounds.length === 1 && staticSliceIndex(bounds[0]) === 0) return;
|
|
1093
2064
|
const previous = core.types.cloneNode(updater.params[0]);
|
|
1094
2065
|
const sliceMethod = path.scope.generateUidIdentifier("farmSlice");
|
|
1095
2066
|
path.node.arguments[0] = core.types.arrowFunctionExpression(
|
|
@@ -1105,7 +2076,7 @@ function rewriteKeyedArraySliceHints(root, hintedStateIndices, statesBySetter, h
|
|
|
1105
2076
|
core.types.callExpression(core.types.cloneNode(helperIdentifier), [
|
|
1106
2077
|
core.types.cloneNode(previous),
|
|
1107
2078
|
core.types.cloneNode(sliceMethod),
|
|
1108
|
-
...
|
|
2079
|
+
...bounds.map((bound) => core.types.cloneNode(bound, true))
|
|
1109
2080
|
])
|
|
1110
2081
|
)
|
|
1111
2082
|
])
|
|
@@ -4864,7 +5835,7 @@ function wrapperElement(definitionIdentifier, props) {
|
|
|
4864
5835
|
const attributes = props ? [core.types.jsxSpreadAttribute(core.types.cloneNode(props))] : [];
|
|
4865
5836
|
return core.types.jsxElement(core.types.jsxOpeningElement(name, attributes, true), null, [], true);
|
|
4866
5837
|
}
|
|
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) {
|
|
5838
|
+
function compileCandidate(candidate, createComponentIdentifier, keyedMapUpdateIdentifier, keyedArrayAppendIdentifier, keyedArrayFilterIdentifier, keyedArrayMapPipelineIdentifier, keyedArrayMappedStructuralAppendIdentifier, keyedArrayStructuralAppendMapPipelineIdentifier, keyedArrayMappedStructuralPrependIdentifier, keyedArrayStructuralPrependMapPipelineIdentifier, keyedArrayQueuedMapPipelineIdentifier, keyedArrayMapReorderIdentifier, keyedArrayMappedStructuralIdentifier, keyedArrayPrependIdentifier, keyedArrayPositionIdentifier, keyedArrayBatchInsertIdentifier, keyedArrayWindowReplaceIdentifier, keyedArrayReorderIdentifier, keyedArrayStructuralReorderIdentifier, keyedArraySortIdentifier, keyedArrayStructuralSortIdentifier, keyedArrayRollingWindowIdentifier, keyedArraySliceIdentifier, keyedCollectionUpdateIdentifier, keyedCollectionMutationIdentifier, runtimeFeatureIdentifiers, usedRuntimeFeatures, optimizationCounts, compilerUsage, useStateNames, reactNames, listNames, moduleId, reactivity) {
|
|
4868
5839
|
const { path, name, statementPath } = candidate;
|
|
4869
5840
|
if (path.node.async || path.node.generator)
|
|
4870
5841
|
return "async and generator components are not supported";
|
|
@@ -5274,14 +6245,80 @@ function compileCandidate(candidate, createComponentIdentifier, keyedMapUpdateId
|
|
|
5274
6245
|
compilerUsage.keyedArrayWindowReplaceHints += positionHintedRoot.windowReplaceCount;
|
|
5275
6246
|
}
|
|
5276
6247
|
}
|
|
6248
|
+
const allowKeyedArrayMapPipelines = (blockAnalysis.plans || []).every(
|
|
6249
|
+
(plan) => plan.kind !== "keyed-rows" || plan.conditionals.length === 0 && !plan.descriptorBlocks?.size
|
|
6250
|
+
);
|
|
6251
|
+
const reorderPipelineHintedRoot = rewriteKeyedArrayReorderPipelineHints(
|
|
6252
|
+
expandedReactiveRoot,
|
|
6253
|
+
shiftedIndexIndependentStateIndices,
|
|
6254
|
+
statesBySetter,
|
|
6255
|
+
keyedArrayFilterIdentifier,
|
|
6256
|
+
keyedArrayMapPipelineIdentifier,
|
|
6257
|
+
keyedArrayMapReorderIdentifier,
|
|
6258
|
+
keyedArrayMappedStructuralIdentifier,
|
|
6259
|
+
keyedArrayReorderIdentifier,
|
|
6260
|
+
keyedArrayStructuralReorderIdentifier,
|
|
6261
|
+
keyedArraySliceIdentifier,
|
|
6262
|
+
keyedArraySortIdentifier,
|
|
6263
|
+
keyedArrayStructuralSortIdentifier,
|
|
6264
|
+
safeGlobals,
|
|
6265
|
+
allowKeyedArrayMapPipelines
|
|
6266
|
+
);
|
|
6267
|
+
let appliedPipelineFilterHints = 0;
|
|
6268
|
+
let appliedPipelineMapHints = 0;
|
|
6269
|
+
let appliedPipelineReorderHints = 0;
|
|
6270
|
+
let appliedPipelineSliceHints = 0;
|
|
6271
|
+
let appliedPipelineSortHints = 0;
|
|
6272
|
+
let appliedPipelineHintedStateIndices = /* @__PURE__ */ new Set();
|
|
6273
|
+
if (reorderPipelineHintedRoot.filterCount > 0 || reorderPipelineHintedRoot.reorderCount > 0 || reorderPipelineHintedRoot.sliceCount > 0 || reorderPipelineHintedRoot.sortCount > 0) {
|
|
6274
|
+
const hintedBlockAnalysis = analyzeComposableBlocks(
|
|
6275
|
+
reorderPipelineHintedRoot.root,
|
|
6276
|
+
reactiveByValue,
|
|
6277
|
+
safeGlobals,
|
|
6278
|
+
listNames,
|
|
6279
|
+
allowedComponentNames
|
|
6280
|
+
);
|
|
6281
|
+
const hintedAnalysis = analyzeHostTree(
|
|
6282
|
+
reorderPipelineHintedRoot.root,
|
|
6283
|
+
reactiveByValue,
|
|
6284
|
+
safeGlobals,
|
|
6285
|
+
hintedBlockAnalysis.conditionalExpressions || /* @__PURE__ */ new Set(),
|
|
6286
|
+
hintedBlockAnalysis.keyedExpressions || /* @__PURE__ */ new Set(),
|
|
6287
|
+
hintedBlockAnalysis.ownedElements || /* @__PURE__ */ new Set(),
|
|
6288
|
+
hintedBlockAnalysis.componentElements || /* @__PURE__ */ new Set()
|
|
6289
|
+
);
|
|
6290
|
+
if (!hintedBlockAnalysis.reason && !hintedAnalysis.reason) {
|
|
6291
|
+
expandedReactiveRoot = reorderPipelineHintedRoot.root;
|
|
6292
|
+
blockAnalysis = hintedBlockAnalysis;
|
|
6293
|
+
analysis = hintedAnalysis;
|
|
6294
|
+
appliedPipelineFilterHints = reorderPipelineHintedRoot.filterCount;
|
|
6295
|
+
appliedPipelineMapHints = reorderPipelineHintedRoot.mapCount;
|
|
6296
|
+
appliedKeyedMapUpdateHints += reorderPipelineHintedRoot.mapCount;
|
|
6297
|
+
appliedPipelineReorderHints = reorderPipelineHintedRoot.reorderCount + reorderPipelineHintedRoot.terminalStructuralPipelineCount;
|
|
6298
|
+
appliedPipelineSliceHints = reorderPipelineHintedRoot.sliceCount;
|
|
6299
|
+
appliedPipelineSortHints = reorderPipelineHintedRoot.sortCount;
|
|
6300
|
+
appliedPipelineHintedStateIndices = reorderPipelineHintedRoot.stateIndices;
|
|
6301
|
+
optimizationCounts.keyedArrayFilterHints += reorderPipelineHintedRoot.filterCount;
|
|
6302
|
+
optimizationCounts.keyedMapUpdateHints += reorderPipelineHintedRoot.mapCount;
|
|
6303
|
+
optimizationCounts.keyedArrayReorderHints += reorderPipelineHintedRoot.reorderCount;
|
|
6304
|
+
optimizationCounts.keyedArraySliceHints += reorderPipelineHintedRoot.sliceCount;
|
|
6305
|
+
optimizationCounts.keyedArraySortHints += reorderPipelineHintedRoot.sortCount;
|
|
6306
|
+
compilerUsage.keyedArrayStructuralReorderHints += reorderPipelineHintedRoot.structuralReorderCount;
|
|
6307
|
+
compilerUsage.keyedArrayStructuralSortHints += reorderPipelineHintedRoot.structuralSortCount;
|
|
6308
|
+
compilerUsage.keyedArrayMapUpdateHints += reorderPipelineHintedRoot.mapCount;
|
|
6309
|
+
compilerUsage.keyedArrayMapReorderHints += reorderPipelineHintedRoot.mapReorderCount;
|
|
6310
|
+
compilerUsage.keyedArrayMapSortHints += reorderPipelineHintedRoot.mapSortCount;
|
|
6311
|
+
compilerUsage.keyedArrayMappedStructuralHints += reorderPipelineHintedRoot.terminalStructuralPipelineCount;
|
|
6312
|
+
}
|
|
6313
|
+
}
|
|
5277
6314
|
const reorderHintedRoot = rewriteKeyedArrayReorderHints(
|
|
5278
6315
|
expandedReactiveRoot,
|
|
5279
6316
|
shiftedIndexIndependentStateIndices,
|
|
5280
6317
|
statesBySetter,
|
|
5281
6318
|
keyedArrayReorderIdentifier
|
|
5282
6319
|
);
|
|
5283
|
-
let appliedKeyedArrayReorderHints =
|
|
5284
|
-
let appliedReorderHintedStateIndices =
|
|
6320
|
+
let appliedKeyedArrayReorderHints = appliedPipelineReorderHints;
|
|
6321
|
+
let appliedReorderHintedStateIndices = appliedPipelineHintedStateIndices;
|
|
5285
6322
|
if (reorderHintedRoot.count > 0) {
|
|
5286
6323
|
const hintedBlockAnalysis = analyzeComposableBlocks(
|
|
5287
6324
|
reorderHintedRoot.root,
|
|
@@ -5303,8 +6340,11 @@ function compileCandidate(candidate, createComponentIdentifier, keyedMapUpdateId
|
|
|
5303
6340
|
expandedReactiveRoot = reorderHintedRoot.root;
|
|
5304
6341
|
blockAnalysis = hintedBlockAnalysis;
|
|
5305
6342
|
analysis = hintedAnalysis;
|
|
5306
|
-
appliedKeyedArrayReorderHints
|
|
5307
|
-
appliedReorderHintedStateIndices =
|
|
6343
|
+
appliedKeyedArrayReorderHints += reorderHintedRoot.count;
|
|
6344
|
+
appliedReorderHintedStateIndices = /* @__PURE__ */ new Set([
|
|
6345
|
+
...appliedReorderHintedStateIndices,
|
|
6346
|
+
...reorderHintedRoot.stateIndices
|
|
6347
|
+
]);
|
|
5308
6348
|
optimizationCounts.keyedArrayReorderHints += reorderHintedRoot.count;
|
|
5309
6349
|
}
|
|
5310
6350
|
}
|
|
@@ -5315,8 +6355,8 @@ function compileCandidate(candidate, createComponentIdentifier, keyedMapUpdateId
|
|
|
5315
6355
|
keyedArraySortIdentifier,
|
|
5316
6356
|
safeGlobals
|
|
5317
6357
|
);
|
|
5318
|
-
let appliedKeyedArraySortHints =
|
|
5319
|
-
let appliedSortHintedStateIndices =
|
|
6358
|
+
let appliedKeyedArraySortHints = appliedPipelineSortHints;
|
|
6359
|
+
let appliedSortHintedStateIndices = appliedPipelineHintedStateIndices;
|
|
5320
6360
|
if (sortHintedRoot.count > 0) {
|
|
5321
6361
|
const hintedBlockAnalysis = analyzeComposableBlocks(
|
|
5322
6362
|
sortHintedRoot.root,
|
|
@@ -5338,8 +6378,11 @@ function compileCandidate(candidate, createComponentIdentifier, keyedMapUpdateId
|
|
|
5338
6378
|
expandedReactiveRoot = sortHintedRoot.root;
|
|
5339
6379
|
blockAnalysis = hintedBlockAnalysis;
|
|
5340
6380
|
analysis = hintedAnalysis;
|
|
5341
|
-
appliedKeyedArraySortHints
|
|
5342
|
-
appliedSortHintedStateIndices =
|
|
6381
|
+
appliedKeyedArraySortHints += sortHintedRoot.count;
|
|
6382
|
+
appliedSortHintedStateIndices = /* @__PURE__ */ new Set([
|
|
6383
|
+
...appliedSortHintedStateIndices,
|
|
6384
|
+
...sortHintedRoot.stateIndices
|
|
6385
|
+
]);
|
|
5343
6386
|
optimizationCounts.keyedArraySortHints += sortHintedRoot.count;
|
|
5344
6387
|
}
|
|
5345
6388
|
}
|
|
@@ -5347,10 +6390,11 @@ function compileCandidate(candidate, createComponentIdentifier, keyedMapUpdateId
|
|
|
5347
6390
|
expandedReactiveRoot,
|
|
5348
6391
|
shiftedIndexIndependentStateIndices,
|
|
5349
6392
|
statesBySetter,
|
|
5350
|
-
keyedArraySliceIdentifier
|
|
6393
|
+
keyedArraySliceIdentifier,
|
|
6394
|
+
safeGlobals
|
|
5351
6395
|
);
|
|
5352
|
-
let appliedKeyedArraySliceHints =
|
|
5353
|
-
let appliedSliceHintedStateIndices = /* @__PURE__ */ new Set();
|
|
6396
|
+
let appliedKeyedArraySliceHints = appliedPipelineSliceHints;
|
|
6397
|
+
let appliedSliceHintedStateIndices = appliedPipelineSliceHints > 0 ? appliedPipelineHintedStateIndices : /* @__PURE__ */ new Set();
|
|
5354
6398
|
if (sliceHintedRoot.count > 0) {
|
|
5355
6399
|
const hintedBlockAnalysis = analyzeComposableBlocks(
|
|
5356
6400
|
sliceHintedRoot.root,
|
|
@@ -5372,8 +6416,11 @@ function compileCandidate(candidate, createComponentIdentifier, keyedMapUpdateId
|
|
|
5372
6416
|
expandedReactiveRoot = sliceHintedRoot.root;
|
|
5373
6417
|
blockAnalysis = hintedBlockAnalysis;
|
|
5374
6418
|
analysis = hintedAnalysis;
|
|
5375
|
-
appliedKeyedArraySliceHints
|
|
5376
|
-
appliedSliceHintedStateIndices =
|
|
6419
|
+
appliedKeyedArraySliceHints += sliceHintedRoot.count;
|
|
6420
|
+
appliedSliceHintedStateIndices = /* @__PURE__ */ new Set([
|
|
6421
|
+
...appliedSliceHintedStateIndices,
|
|
6422
|
+
...sliceHintedRoot.stateIndices
|
|
6423
|
+
]);
|
|
5377
6424
|
optimizationCounts.keyedArraySliceHints += sliceHintedRoot.count;
|
|
5378
6425
|
}
|
|
5379
6426
|
}
|
|
@@ -5384,8 +6431,8 @@ function compileCandidate(candidate, createComponentIdentifier, keyedMapUpdateId
|
|
|
5384
6431
|
keyedArrayFilterIdentifier,
|
|
5385
6432
|
safeGlobals
|
|
5386
6433
|
);
|
|
5387
|
-
let appliedKeyedArrayFilterHints =
|
|
5388
|
-
let appliedFilterHintedStateIndices = /* @__PURE__ */ new Set();
|
|
6434
|
+
let appliedKeyedArrayFilterHints = appliedPipelineFilterHints;
|
|
6435
|
+
let appliedFilterHintedStateIndices = appliedPipelineFilterHints > 0 ? appliedPipelineHintedStateIndices : /* @__PURE__ */ new Set();
|
|
5389
6436
|
if (filterHintedRoot.count > 0) {
|
|
5390
6437
|
const hintedBlockAnalysis = analyzeComposableBlocks(
|
|
5391
6438
|
filterHintedRoot.root,
|
|
@@ -5407,11 +6454,243 @@ function compileCandidate(candidate, createComponentIdentifier, keyedMapUpdateId
|
|
|
5407
6454
|
expandedReactiveRoot = filterHintedRoot.root;
|
|
5408
6455
|
blockAnalysis = hintedBlockAnalysis;
|
|
5409
6456
|
analysis = hintedAnalysis;
|
|
5410
|
-
appliedKeyedArrayFilterHints
|
|
5411
|
-
appliedFilterHintedStateIndices =
|
|
6457
|
+
appliedKeyedArrayFilterHints += filterHintedRoot.count;
|
|
6458
|
+
appliedFilterHintedStateIndices = /* @__PURE__ */ new Set([
|
|
6459
|
+
...appliedFilterHintedStateIndices,
|
|
6460
|
+
...filterHintedRoot.stateIndices
|
|
6461
|
+
]);
|
|
5412
6462
|
optimizationCounts.keyedArrayFilterHints += filterHintedRoot.count;
|
|
5413
6463
|
}
|
|
5414
6464
|
}
|
|
6465
|
+
const queuedMappedStructuralHintedRoot = rewriteQueuedKeyedArrayMappedStructuralHints(
|
|
6466
|
+
expandedReactiveRoot,
|
|
6467
|
+
statesBySetter,
|
|
6468
|
+
keyedMapUpdateIdentifier,
|
|
6469
|
+
keyedArrayQueuedMapPipelineIdentifier,
|
|
6470
|
+
keyedArrayMappedStructuralIdentifier,
|
|
6471
|
+
keyedArrayFilterIdentifier,
|
|
6472
|
+
keyedArraySliceIdentifier,
|
|
6473
|
+
allowKeyedArrayMapPipelines
|
|
6474
|
+
);
|
|
6475
|
+
let appliedQueuedMappedStructuralHints = 0;
|
|
6476
|
+
if (queuedMappedStructuralHintedRoot.mapCount > 0 && queuedMappedStructuralHintedRoot.structuralCount > 0) {
|
|
6477
|
+
const hintedBlockAnalysis = analyzeComposableBlocks(
|
|
6478
|
+
queuedMappedStructuralHintedRoot.root,
|
|
6479
|
+
reactiveByValue,
|
|
6480
|
+
safeGlobals,
|
|
6481
|
+
listNames,
|
|
6482
|
+
allowedComponentNames
|
|
6483
|
+
);
|
|
6484
|
+
const hintedAnalysis = analyzeHostTree(
|
|
6485
|
+
queuedMappedStructuralHintedRoot.root,
|
|
6486
|
+
reactiveByValue,
|
|
6487
|
+
safeGlobals,
|
|
6488
|
+
hintedBlockAnalysis.conditionalExpressions || /* @__PURE__ */ new Set(),
|
|
6489
|
+
hintedBlockAnalysis.keyedExpressions || /* @__PURE__ */ new Set(),
|
|
6490
|
+
hintedBlockAnalysis.ownedElements || /* @__PURE__ */ new Set(),
|
|
6491
|
+
hintedBlockAnalysis.componentElements || /* @__PURE__ */ new Set()
|
|
6492
|
+
);
|
|
6493
|
+
if (!hintedBlockAnalysis.reason && !hintedAnalysis.reason) {
|
|
6494
|
+
expandedReactiveRoot = queuedMappedStructuralHintedRoot.root;
|
|
6495
|
+
blockAnalysis = hintedBlockAnalysis;
|
|
6496
|
+
analysis = hintedAnalysis;
|
|
6497
|
+
appliedQueuedMappedStructuralHints = queuedMappedStructuralHintedRoot.mapCount + queuedMappedStructuralHintedRoot.structuralCount;
|
|
6498
|
+
appliedKeyedArrayReorderHints += queuedMappedStructuralHintedRoot.structuralCount;
|
|
6499
|
+
appliedReorderHintedStateIndices = /* @__PURE__ */ new Set([
|
|
6500
|
+
...appliedReorderHintedStateIndices,
|
|
6501
|
+
...queuedMappedStructuralHintedRoot.stateIndices
|
|
6502
|
+
]);
|
|
6503
|
+
compilerUsage.keyedArrayMapUpdateHints += queuedMappedStructuralHintedRoot.mapCount;
|
|
6504
|
+
compilerUsage.keyedArrayQueuedMapUpdateHints += queuedMappedStructuralHintedRoot.mapCount;
|
|
6505
|
+
compilerUsage.keyedArrayMappedStructuralHints += queuedMappedStructuralHintedRoot.structuralCount;
|
|
6506
|
+
}
|
|
6507
|
+
}
|
|
6508
|
+
const queuedStructuralMapHintedRoot = rewriteQueuedKeyedArrayStructuralMapHints(
|
|
6509
|
+
expandedReactiveRoot,
|
|
6510
|
+
statesBySetter,
|
|
6511
|
+
keyedMapUpdateIdentifier,
|
|
6512
|
+
keyedArrayMapPipelineIdentifier,
|
|
6513
|
+
keyedArrayAppendIdentifier,
|
|
6514
|
+
keyedArrayMappedStructuralAppendIdentifier,
|
|
6515
|
+
keyedArrayStructuralAppendMapPipelineIdentifier,
|
|
6516
|
+
keyedArrayFilterIdentifier,
|
|
6517
|
+
keyedArraySliceIdentifier,
|
|
6518
|
+
keyedArrayMappedStructuralIdentifier,
|
|
6519
|
+
allowKeyedArrayMapPipelines
|
|
6520
|
+
);
|
|
6521
|
+
let appliedQueuedStructuralMapHints = 0;
|
|
6522
|
+
let appliedQueuedStructuralAppendMapHints = 0;
|
|
6523
|
+
if (queuedStructuralMapHintedRoot.mapCount > 0 || queuedStructuralMapHintedRoot.mappedStructuralAppendCount > 0) {
|
|
6524
|
+
const hintedBlockAnalysis = analyzeComposableBlocks(
|
|
6525
|
+
queuedStructuralMapHintedRoot.root,
|
|
6526
|
+
reactiveByValue,
|
|
6527
|
+
safeGlobals,
|
|
6528
|
+
listNames,
|
|
6529
|
+
allowedComponentNames
|
|
6530
|
+
);
|
|
6531
|
+
const hintedAnalysis = analyzeHostTree(
|
|
6532
|
+
queuedStructuralMapHintedRoot.root,
|
|
6533
|
+
reactiveByValue,
|
|
6534
|
+
safeGlobals,
|
|
6535
|
+
hintedBlockAnalysis.conditionalExpressions || /* @__PURE__ */ new Set(),
|
|
6536
|
+
hintedBlockAnalysis.keyedExpressions || /* @__PURE__ */ new Set(),
|
|
6537
|
+
hintedBlockAnalysis.ownedElements || /* @__PURE__ */ new Set(),
|
|
6538
|
+
hintedBlockAnalysis.componentElements || /* @__PURE__ */ new Set()
|
|
6539
|
+
);
|
|
6540
|
+
if (!hintedBlockAnalysis.reason && !hintedAnalysis.reason) {
|
|
6541
|
+
expandedReactiveRoot = queuedStructuralMapHintedRoot.root;
|
|
6542
|
+
blockAnalysis = hintedBlockAnalysis;
|
|
6543
|
+
analysis = hintedAnalysis;
|
|
6544
|
+
appliedQueuedStructuralMapHints = queuedStructuralMapHintedRoot.mapCount;
|
|
6545
|
+
appliedQueuedStructuralAppendMapHints = queuedStructuralMapHintedRoot.structuralAppendMapCount + queuedStructuralMapHintedRoot.mappedStructuralAppendCount;
|
|
6546
|
+
appliedKeyedArrayReorderHints += queuedStructuralMapHintedRoot.mapCount;
|
|
6547
|
+
appliedReorderHintedStateIndices = /* @__PURE__ */ new Set([
|
|
6548
|
+
...appliedReorderHintedStateIndices,
|
|
6549
|
+
...queuedStructuralMapHintedRoot.stateIndices
|
|
6550
|
+
]);
|
|
6551
|
+
compilerUsage.keyedArrayMapUpdateHints += queuedStructuralMapHintedRoot.mapCount;
|
|
6552
|
+
compilerUsage.keyedArrayMappedStructuralAppendHints += queuedStructuralMapHintedRoot.mappedStructuralAppendCount;
|
|
6553
|
+
compilerUsage.keyedArrayStructuralAppendMapHints += queuedStructuralMapHintedRoot.structuralAppendMapCount;
|
|
6554
|
+
}
|
|
6555
|
+
}
|
|
6556
|
+
const queuedStructuralPrependMapHintedRoot = rewriteQueuedKeyedArrayStructuralPrependMapHints(
|
|
6557
|
+
expandedReactiveRoot,
|
|
6558
|
+
statesBySetter,
|
|
6559
|
+
keyedMapUpdateIdentifier,
|
|
6560
|
+
keyedArrayMapPipelineIdentifier,
|
|
6561
|
+
keyedArrayPrependIdentifier,
|
|
6562
|
+
keyedArrayMappedStructuralPrependIdentifier,
|
|
6563
|
+
keyedArrayStructuralPrependMapPipelineIdentifier,
|
|
6564
|
+
keyedArrayFilterIdentifier,
|
|
6565
|
+
keyedArraySliceIdentifier,
|
|
6566
|
+
keyedArrayMappedStructuralIdentifier,
|
|
6567
|
+
allowKeyedArrayMapPipelines
|
|
6568
|
+
);
|
|
6569
|
+
let appliedQueuedStructuralPrependMapHints = 0;
|
|
6570
|
+
if (queuedStructuralPrependMapHintedRoot.structuralPrependMapCount > 0 || queuedStructuralPrependMapHintedRoot.mappedStructuralPrependCount > 0) {
|
|
6571
|
+
const hintedBlockAnalysis = analyzeComposableBlocks(
|
|
6572
|
+
queuedStructuralPrependMapHintedRoot.root,
|
|
6573
|
+
reactiveByValue,
|
|
6574
|
+
safeGlobals,
|
|
6575
|
+
listNames,
|
|
6576
|
+
allowedComponentNames
|
|
6577
|
+
);
|
|
6578
|
+
const hintedAnalysis = analyzeHostTree(
|
|
6579
|
+
queuedStructuralPrependMapHintedRoot.root,
|
|
6580
|
+
reactiveByValue,
|
|
6581
|
+
safeGlobals,
|
|
6582
|
+
hintedBlockAnalysis.conditionalExpressions || /* @__PURE__ */ new Set(),
|
|
6583
|
+
hintedBlockAnalysis.keyedExpressions || /* @__PURE__ */ new Set(),
|
|
6584
|
+
hintedBlockAnalysis.ownedElements || /* @__PURE__ */ new Set(),
|
|
6585
|
+
hintedBlockAnalysis.componentElements || /* @__PURE__ */ new Set()
|
|
6586
|
+
);
|
|
6587
|
+
if (!hintedBlockAnalysis.reason && !hintedAnalysis.reason) {
|
|
6588
|
+
expandedReactiveRoot = queuedStructuralPrependMapHintedRoot.root;
|
|
6589
|
+
blockAnalysis = hintedBlockAnalysis;
|
|
6590
|
+
analysis = hintedAnalysis;
|
|
6591
|
+
appliedQueuedStructuralPrependMapHints = queuedStructuralPrependMapHintedRoot.structuralPrependMapCount + queuedStructuralPrependMapHintedRoot.mappedStructuralPrependCount;
|
|
6592
|
+
compilerUsage.keyedArrayMappedStructuralPrependHints += queuedStructuralPrependMapHintedRoot.mappedStructuralPrependCount;
|
|
6593
|
+
compilerUsage.keyedArrayStructuralPrependMapHints += queuedStructuralPrependMapHintedRoot.structuralPrependMapCount;
|
|
6594
|
+
}
|
|
6595
|
+
}
|
|
6596
|
+
const queuedMapReorderHintedRoot = rewriteQueuedKeyedArrayMapReorderHints(
|
|
6597
|
+
expandedReactiveRoot,
|
|
6598
|
+
statesBySetter,
|
|
6599
|
+
keyedMapUpdateIdentifier,
|
|
6600
|
+
keyedArrayQueuedMapPipelineIdentifier,
|
|
6601
|
+
keyedArrayMapReorderIdentifier,
|
|
6602
|
+
keyedArrayReorderIdentifier,
|
|
6603
|
+
keyedArraySortIdentifier,
|
|
6604
|
+
keyedArrayStructuralReorderIdentifier,
|
|
6605
|
+
keyedArrayStructuralSortIdentifier,
|
|
6606
|
+
allowKeyedArrayMapPipelines
|
|
6607
|
+
);
|
|
6608
|
+
const queuedReorderMapHintedRoot = rewriteQueuedKeyedArrayReorderMapHints(
|
|
6609
|
+
queuedMapReorderHintedRoot.root,
|
|
6610
|
+
statesBySetter,
|
|
6611
|
+
keyedMapUpdateIdentifier,
|
|
6612
|
+
keyedArrayQueuedMapPipelineIdentifier,
|
|
6613
|
+
keyedArrayMapReorderIdentifier,
|
|
6614
|
+
keyedArrayReorderIdentifier,
|
|
6615
|
+
keyedArraySortIdentifier,
|
|
6616
|
+
keyedArrayStructuralReorderIdentifier,
|
|
6617
|
+
keyedArrayStructuralSortIdentifier,
|
|
6618
|
+
allowKeyedArrayMapPipelines
|
|
6619
|
+
);
|
|
6620
|
+
let appliedQueuedReorderMapHints = 0;
|
|
6621
|
+
const queuedMapCount = queuedMapReorderHintedRoot.mapCount + queuedReorderMapHintedRoot.mapCount;
|
|
6622
|
+
const queuedMapReorderCount = queuedMapReorderHintedRoot.mapReorderCount + queuedMapReorderHintedRoot.mapSortCount;
|
|
6623
|
+
if (queuedMapCount > 0 || queuedMapReorderCount > 0) {
|
|
6624
|
+
const hintedBlockAnalysis = analyzeComposableBlocks(
|
|
6625
|
+
queuedReorderMapHintedRoot.root,
|
|
6626
|
+
reactiveByValue,
|
|
6627
|
+
safeGlobals,
|
|
6628
|
+
listNames,
|
|
6629
|
+
allowedComponentNames
|
|
6630
|
+
);
|
|
6631
|
+
const hintedAnalysis = analyzeHostTree(
|
|
6632
|
+
queuedReorderMapHintedRoot.root,
|
|
6633
|
+
reactiveByValue,
|
|
6634
|
+
safeGlobals,
|
|
6635
|
+
hintedBlockAnalysis.conditionalExpressions || /* @__PURE__ */ new Set(),
|
|
6636
|
+
hintedBlockAnalysis.keyedExpressions || /* @__PURE__ */ new Set(),
|
|
6637
|
+
hintedBlockAnalysis.ownedElements || /* @__PURE__ */ new Set(),
|
|
6638
|
+
hintedBlockAnalysis.componentElements || /* @__PURE__ */ new Set()
|
|
6639
|
+
);
|
|
6640
|
+
if (!hintedBlockAnalysis.reason && !hintedAnalysis.reason) {
|
|
6641
|
+
expandedReactiveRoot = queuedReorderMapHintedRoot.root;
|
|
6642
|
+
blockAnalysis = hintedBlockAnalysis;
|
|
6643
|
+
analysis = hintedAnalysis;
|
|
6644
|
+
appliedQueuedReorderMapHints = queuedMapCount + queuedMapReorderCount;
|
|
6645
|
+
compilerUsage.keyedArrayMapUpdateHints += queuedMapCount;
|
|
6646
|
+
compilerUsage.keyedArrayQueuedMapUpdateHints += queuedMapCount;
|
|
6647
|
+
compilerUsage.keyedArrayMapReorderHints += queuedMapReorderHintedRoot.mapReorderCount;
|
|
6648
|
+
compilerUsage.keyedArrayMapSortHints += queuedMapReorderHintedRoot.mapSortCount;
|
|
6649
|
+
}
|
|
6650
|
+
}
|
|
6651
|
+
const queuedStructuralReorderHintedRoot = rewriteQueuedKeyedArrayStructuralReorderHints(
|
|
6652
|
+
expandedReactiveRoot,
|
|
6653
|
+
statesBySetter,
|
|
6654
|
+
keyedArrayFilterIdentifier,
|
|
6655
|
+
keyedArraySliceIdentifier,
|
|
6656
|
+
keyedArrayMapPipelineIdentifier,
|
|
6657
|
+
keyedArrayQueuedMapPipelineIdentifier,
|
|
6658
|
+
keyedArrayMappedStructuralIdentifier,
|
|
6659
|
+
keyedArrayMapReorderIdentifier,
|
|
6660
|
+
keyedArrayReorderIdentifier,
|
|
6661
|
+
keyedArraySortIdentifier,
|
|
6662
|
+
keyedArrayStructuralReorderIdentifier,
|
|
6663
|
+
keyedArrayStructuralSortIdentifier,
|
|
6664
|
+
allowKeyedArrayMapPipelines
|
|
6665
|
+
);
|
|
6666
|
+
if (queuedStructuralReorderHintedRoot.reorderCount > 0 || queuedStructuralReorderHintedRoot.sortCount > 0 || queuedStructuralReorderHintedRoot.replacedQueuedMapCount > 0) {
|
|
6667
|
+
const hintedBlockAnalysis = analyzeComposableBlocks(
|
|
6668
|
+
queuedStructuralReorderHintedRoot.root,
|
|
6669
|
+
reactiveByValue,
|
|
6670
|
+
safeGlobals,
|
|
6671
|
+
listNames,
|
|
6672
|
+
allowedComponentNames
|
|
6673
|
+
);
|
|
6674
|
+
const hintedAnalysis = analyzeHostTree(
|
|
6675
|
+
queuedStructuralReorderHintedRoot.root,
|
|
6676
|
+
reactiveByValue,
|
|
6677
|
+
safeGlobals,
|
|
6678
|
+
hintedBlockAnalysis.conditionalExpressions || /* @__PURE__ */ new Set(),
|
|
6679
|
+
hintedBlockAnalysis.keyedExpressions || /* @__PURE__ */ new Set(),
|
|
6680
|
+
hintedBlockAnalysis.ownedElements || /* @__PURE__ */ new Set(),
|
|
6681
|
+
hintedBlockAnalysis.componentElements || /* @__PURE__ */ new Set()
|
|
6682
|
+
);
|
|
6683
|
+
if (!hintedBlockAnalysis.reason && !hintedAnalysis.reason) {
|
|
6684
|
+
expandedReactiveRoot = queuedStructuralReorderHintedRoot.root;
|
|
6685
|
+
blockAnalysis = hintedBlockAnalysis;
|
|
6686
|
+
analysis = hintedAnalysis;
|
|
6687
|
+
compilerUsage.keyedArrayQueuedMapUpdateHints -= queuedStructuralReorderHintedRoot.replacedQueuedMapCount;
|
|
6688
|
+
compilerUsage.keyedArrayMapReorderHints -= queuedStructuralReorderHintedRoot.replacedMapReorderCount;
|
|
6689
|
+
compilerUsage.keyedArrayMapSortHints -= queuedStructuralReorderHintedRoot.replacedMapSortCount;
|
|
6690
|
+
compilerUsage.keyedArrayStructuralReorderHints += queuedStructuralReorderHintedRoot.reorderCount;
|
|
6691
|
+
compilerUsage.keyedArrayStructuralSortHints += queuedStructuralReorderHintedRoot.sortCount;
|
|
6692
|
+
}
|
|
6693
|
+
}
|
|
5415
6694
|
const keyedCollectionTargetKinds = /* @__PURE__ */ new Map();
|
|
5416
6695
|
const conflictingKeyedCollectionTargets = /* @__PURE__ */ new Set();
|
|
5417
6696
|
for (const plan of blockAnalysis.plans || []) {
|
|
@@ -5483,11 +6762,16 @@ function compileCandidate(candidate, createComponentIdentifier, keyedMapUpdateId
|
|
|
5483
6762
|
blockPlans,
|
|
5484
6763
|
hasKeyedUpdateHints,
|
|
5485
6764
|
hasKeyedArrayRemovalHints,
|
|
6765
|
+
appliedKeyedArrayAppendHints > 0 && (appliedKeyedArrayFilterHints > 0 || appliedKeyedArraySliceHints > 0),
|
|
6766
|
+
appliedQueuedStructuralAppendMapHints > 0,
|
|
5486
6767
|
appliedKeyedArrayPrependHints > 0,
|
|
6768
|
+
appliedKeyedArrayPrependHints > 0 && hasKeyedArrayRemovalHints,
|
|
6769
|
+
appliedQueuedStructuralPrependMapHints > 0,
|
|
5487
6770
|
appliedKeyedArrayPositionHints > 0,
|
|
5488
6771
|
appliedKeyedArrayBatchInsertHints > 0,
|
|
5489
6772
|
appliedKeyedArrayWindowReplaceHints > 0,
|
|
5490
6773
|
appliedKeyedArrayReorderHints > 0 || appliedKeyedArraySortHints > 0,
|
|
6774
|
+
appliedPipelineMapHints > 0 || appliedQueuedReorderMapHints > 0 || appliedQueuedMappedStructuralHints > 0 || appliedQueuedStructuralMapHints > 0,
|
|
5491
6775
|
appliedKeyedArrayRollingWindowHints > 0
|
|
5492
6776
|
);
|
|
5493
6777
|
markShortCircuitBindings(analysis.bindings || []);
|
|
@@ -5671,6 +6955,17 @@ async function compileReactModule(code, id, options) {
|
|
|
5671
6955
|
};
|
|
5672
6956
|
const compilerUsage = {
|
|
5673
6957
|
keyedArrayBatchInsertHints: 0,
|
|
6958
|
+
keyedArrayMapReorderHints: 0,
|
|
6959
|
+
keyedArrayMapSortHints: 0,
|
|
6960
|
+
keyedArrayMapUpdateHints: 0,
|
|
6961
|
+
keyedArrayMappedStructuralHints: 0,
|
|
6962
|
+
keyedArrayMappedStructuralAppendHints: 0,
|
|
6963
|
+
keyedArrayMappedStructuralPrependHints: 0,
|
|
6964
|
+
keyedArrayQueuedMapUpdateHints: 0,
|
|
6965
|
+
keyedArrayStructuralAppendMapHints: 0,
|
|
6966
|
+
keyedArrayStructuralPrependMapHints: 0,
|
|
6967
|
+
keyedArrayStructuralReorderHints: 0,
|
|
6968
|
+
keyedArrayStructuralSortHints: 0,
|
|
5674
6969
|
keyedArrayWindowReplaceHints: 0
|
|
5675
6970
|
};
|
|
5676
6971
|
const plugin = () => ({
|
|
@@ -5711,6 +7006,30 @@ async function compileReactModule(code, id, options) {
|
|
|
5711
7006
|
const keyedArrayFilterIdentifier = programPath.scope.generateUidIdentifier(
|
|
5712
7007
|
"createCompilerKeyedArrayFilter"
|
|
5713
7008
|
);
|
|
7009
|
+
const keyedArrayMapPipelineIdentifier = programPath.scope.generateUidIdentifier(
|
|
7010
|
+
"createCompilerKeyedArrayMapPipeline"
|
|
7011
|
+
);
|
|
7012
|
+
const keyedArrayMappedStructuralAppendIdentifier = programPath.scope.generateUidIdentifier(
|
|
7013
|
+
"createCompilerKeyedArrayMappedStructuralAppend"
|
|
7014
|
+
);
|
|
7015
|
+
const keyedArrayStructuralAppendMapPipelineIdentifier = programPath.scope.generateUidIdentifier(
|
|
7016
|
+
"createCompilerKeyedArrayStructuralAppendMapPipeline"
|
|
7017
|
+
);
|
|
7018
|
+
const keyedArrayMappedStructuralPrependIdentifier = programPath.scope.generateUidIdentifier(
|
|
7019
|
+
"createCompilerKeyedArrayMappedStructuralPrepend"
|
|
7020
|
+
);
|
|
7021
|
+
const keyedArrayStructuralPrependMapPipelineIdentifier = programPath.scope.generateUidIdentifier(
|
|
7022
|
+
"createCompilerKeyedArrayStructuralPrependMapPipeline"
|
|
7023
|
+
);
|
|
7024
|
+
const keyedArrayQueuedMapPipelineIdentifier = programPath.scope.generateUidIdentifier(
|
|
7025
|
+
"createCompilerKeyedArrayQueuedMapPipeline"
|
|
7026
|
+
);
|
|
7027
|
+
const keyedArrayMapReorderIdentifier = programPath.scope.generateUidIdentifier(
|
|
7028
|
+
"createCompilerKeyedArrayMapReorder"
|
|
7029
|
+
);
|
|
7030
|
+
const keyedArrayMappedStructuralIdentifier = programPath.scope.generateUidIdentifier(
|
|
7031
|
+
"finalizeCompilerKeyedArrayMappedStructuralUpdate"
|
|
7032
|
+
);
|
|
5714
7033
|
const keyedArrayPrependIdentifier = programPath.scope.generateUidIdentifier(
|
|
5715
7034
|
"createCompilerKeyedArrayPrepend"
|
|
5716
7035
|
);
|
|
@@ -5726,9 +7045,15 @@ async function compileReactModule(code, id, options) {
|
|
|
5726
7045
|
const keyedArrayReorderIdentifier = programPath.scope.generateUidIdentifier(
|
|
5727
7046
|
"createCompilerKeyedArrayReorder"
|
|
5728
7047
|
);
|
|
7048
|
+
const keyedArrayStructuralReorderIdentifier = programPath.scope.generateUidIdentifier(
|
|
7049
|
+
"createCompilerKeyedArrayStructuralReorder"
|
|
7050
|
+
);
|
|
5729
7051
|
const keyedArraySortIdentifier = programPath.scope.generateUidIdentifier(
|
|
5730
7052
|
"createCompilerKeyedArraySort"
|
|
5731
7053
|
);
|
|
7054
|
+
const keyedArrayStructuralSortIdentifier = programPath.scope.generateUidIdentifier(
|
|
7055
|
+
"createCompilerKeyedArrayStructuralSort"
|
|
7056
|
+
);
|
|
5732
7057
|
const keyedArrayRollingWindowIdentifier = programPath.scope.generateUidIdentifier(
|
|
5733
7058
|
"createCompilerKeyedArrayRollingWindow"
|
|
5734
7059
|
);
|
|
@@ -5761,12 +7086,22 @@ async function compileReactModule(code, id, options) {
|
|
|
5761
7086
|
keyedMapUpdateIdentifier,
|
|
5762
7087
|
keyedArrayAppendIdentifier,
|
|
5763
7088
|
keyedArrayFilterIdentifier,
|
|
7089
|
+
keyedArrayMapPipelineIdentifier,
|
|
7090
|
+
keyedArrayMappedStructuralAppendIdentifier,
|
|
7091
|
+
keyedArrayStructuralAppendMapPipelineIdentifier,
|
|
7092
|
+
keyedArrayMappedStructuralPrependIdentifier,
|
|
7093
|
+
keyedArrayStructuralPrependMapPipelineIdentifier,
|
|
7094
|
+
keyedArrayQueuedMapPipelineIdentifier,
|
|
7095
|
+
keyedArrayMapReorderIdentifier,
|
|
7096
|
+
keyedArrayMappedStructuralIdentifier,
|
|
5764
7097
|
keyedArrayPrependIdentifier,
|
|
5765
7098
|
keyedArrayPositionIdentifier,
|
|
5766
7099
|
keyedArrayBatchInsertIdentifier,
|
|
5767
7100
|
keyedArrayWindowReplaceIdentifier,
|
|
5768
7101
|
keyedArrayReorderIdentifier,
|
|
7102
|
+
keyedArrayStructuralReorderIdentifier,
|
|
5769
7103
|
keyedArraySortIdentifier,
|
|
7104
|
+
keyedArrayStructuralSortIdentifier,
|
|
5770
7105
|
keyedArrayRollingWindowIdentifier,
|
|
5771
7106
|
keyedArraySliceIdentifier,
|
|
5772
7107
|
keyedCollectionUpdateIdentifier,
|
|
@@ -5791,6 +7126,12 @@ async function compileReactModule(code, id, options) {
|
|
|
5791
7126
|
compiled.push(candidate.name);
|
|
5792
7127
|
}
|
|
5793
7128
|
}
|
|
7129
|
+
const hasEagerKeyedArrayMapUpdateHints = compilerUsage.keyedArrayMapUpdateHints > compilerUsage.keyedArrayQueuedMapUpdateHints + compilerUsage.keyedArrayStructuralAppendMapHints + compilerUsage.keyedArrayStructuralPrependMapHints;
|
|
7130
|
+
const hasKeyedArrayMapReorderHints = compilerUsage.keyedArrayMapReorderHints + compilerUsage.keyedArrayMapSortHints > 0;
|
|
7131
|
+
const hasKeyedArrayStructuralAppendHints = optimizationCounts.keyedArrayAppendHints > 0 && (optimizationCounts.keyedArrayFilterHints > 0 || optimizationCounts.keyedArraySliceHints > 0);
|
|
7132
|
+
const hasUnmappedKeyedArrayAppendHints = optimizationCounts.keyedArrayAppendHints > compilerUsage.keyedArrayMappedStructuralAppendHints;
|
|
7133
|
+
const hasKeyedArrayStructuralPrependHints = optimizationCounts.keyedArrayPrependHints > 0 && (optimizationCounts.keyedArrayFilterHints > 0 || optimizationCounts.keyedArraySliceHints > 0);
|
|
7134
|
+
const hasUnmappedKeyedArrayPrependHints = optimizationCounts.keyedArrayPrependHints > compilerUsage.keyedArrayMappedStructuralPrependHints;
|
|
5794
7135
|
if (compiled.length > 0) {
|
|
5795
7136
|
programPath.unshiftContainer(
|
|
5796
7137
|
"body",
|
|
@@ -5800,16 +7141,66 @@ async function compileReactModule(code, id, options) {
|
|
|
5800
7141
|
createComponentIdentifier,
|
|
5801
7142
|
core.types.identifier("createCompiledComponentWithFeatures")
|
|
5802
7143
|
),
|
|
5803
|
-
...optimizationCounts.keyedMapUpdateHints >
|
|
7144
|
+
...optimizationCounts.keyedMapUpdateHints > compilerUsage.keyedArrayMapUpdateHints ? [
|
|
5804
7145
|
core.types.importSpecifier(
|
|
5805
7146
|
keyedMapUpdateIdentifier,
|
|
5806
7147
|
core.types.identifier("createCompilerKeyedMapUpdate")
|
|
5807
7148
|
)
|
|
5808
7149
|
] : [],
|
|
5809
|
-
...
|
|
7150
|
+
...hasEagerKeyedArrayMapUpdateHints ? [
|
|
7151
|
+
core.types.importSpecifier(
|
|
7152
|
+
keyedArrayMapPipelineIdentifier,
|
|
7153
|
+
core.types.identifier("createCompilerKeyedArrayMapPipeline")
|
|
7154
|
+
)
|
|
7155
|
+
] : [],
|
|
7156
|
+
...compilerUsage.keyedArrayStructuralAppendMapHints > 0 ? [
|
|
7157
|
+
core.types.importSpecifier(
|
|
7158
|
+
keyedArrayStructuralAppendMapPipelineIdentifier,
|
|
7159
|
+
core.types.identifier("createCompilerKeyedArrayStructuralAppendMapPipeline")
|
|
7160
|
+
)
|
|
7161
|
+
] : [],
|
|
7162
|
+
...compilerUsage.keyedArrayStructuralPrependMapHints > 0 ? [
|
|
7163
|
+
core.types.importSpecifier(
|
|
7164
|
+
keyedArrayStructuralPrependMapPipelineIdentifier,
|
|
7165
|
+
core.types.identifier("createCompilerKeyedArrayStructuralPrependMapPipeline")
|
|
7166
|
+
)
|
|
7167
|
+
] : [],
|
|
7168
|
+
...hasKeyedArrayMapReorderHints ? [
|
|
7169
|
+
core.types.importSpecifier(
|
|
7170
|
+
keyedArrayMapReorderIdentifier,
|
|
7171
|
+
core.types.identifier("createCompilerKeyedArrayMapReorder")
|
|
7172
|
+
)
|
|
7173
|
+
] : [],
|
|
7174
|
+
...compilerUsage.keyedArrayMappedStructuralHints > 0 ? [
|
|
7175
|
+
core.types.importSpecifier(
|
|
7176
|
+
keyedArrayMappedStructuralIdentifier,
|
|
7177
|
+
core.types.identifier("finalizeCompilerKeyedArrayMappedStructuralUpdate")
|
|
7178
|
+
)
|
|
7179
|
+
] : [],
|
|
7180
|
+
...compilerUsage.keyedArrayMappedStructuralAppendHints > 0 ? [
|
|
7181
|
+
core.types.importSpecifier(
|
|
7182
|
+
keyedArrayMappedStructuralAppendIdentifier,
|
|
7183
|
+
core.types.identifier("createCompilerKeyedArrayMappedStructuralAppend")
|
|
7184
|
+
)
|
|
7185
|
+
] : [],
|
|
7186
|
+
...compilerUsage.keyedArrayMappedStructuralPrependHints > 0 ? [
|
|
7187
|
+
core.types.importSpecifier(
|
|
7188
|
+
keyedArrayMappedStructuralPrependIdentifier,
|
|
7189
|
+
core.types.identifier("createCompilerKeyedArrayMappedStructuralPrepend")
|
|
7190
|
+
)
|
|
7191
|
+
] : [],
|
|
7192
|
+
...compilerUsage.keyedArrayQueuedMapUpdateHints > 0 ? [
|
|
7193
|
+
core.types.importSpecifier(
|
|
7194
|
+
keyedArrayQueuedMapPipelineIdentifier,
|
|
7195
|
+
core.types.identifier("createCompilerKeyedArrayQueuedMapPipeline")
|
|
7196
|
+
)
|
|
7197
|
+
] : [],
|
|
7198
|
+
...hasUnmappedKeyedArrayAppendHints ? [
|
|
5810
7199
|
core.types.importSpecifier(
|
|
5811
7200
|
keyedArrayAppendIdentifier,
|
|
5812
|
-
core.types.identifier(
|
|
7201
|
+
core.types.identifier(
|
|
7202
|
+
hasKeyedArrayStructuralAppendHints ? "createCompilerKeyedArrayStructuralAppend" : "createCompilerKeyedArrayAppend"
|
|
7203
|
+
)
|
|
5813
7204
|
)
|
|
5814
7205
|
] : [],
|
|
5815
7206
|
...optimizationCounts.keyedArrayFilterHints > 0 ? [
|
|
@@ -5818,10 +7209,12 @@ async function compileReactModule(code, id, options) {
|
|
|
5818
7209
|
core.types.identifier("createCompilerKeyedArrayFilter")
|
|
5819
7210
|
)
|
|
5820
7211
|
] : [],
|
|
5821
|
-
...
|
|
7212
|
+
...hasUnmappedKeyedArrayPrependHints ? [
|
|
5822
7213
|
core.types.importSpecifier(
|
|
5823
7214
|
keyedArrayPrependIdentifier,
|
|
5824
|
-
core.types.identifier(
|
|
7215
|
+
core.types.identifier(
|
|
7216
|
+
hasKeyedArrayStructuralPrependHints ? "createCompilerKeyedArrayStructuralPrepend" : "createCompilerKeyedArrayPrepend"
|
|
7217
|
+
)
|
|
5825
7218
|
)
|
|
5826
7219
|
] : [],
|
|
5827
7220
|
...optimizationCounts.keyedArrayPositionHints > compilerUsage.keyedArrayBatchInsertHints + compilerUsage.keyedArrayWindowReplaceHints ? [
|
|
@@ -5842,18 +7235,30 @@ async function compileReactModule(code, id, options) {
|
|
|
5842
7235
|
core.types.identifier("createCompilerKeyedArrayWindowReplace")
|
|
5843
7236
|
)
|
|
5844
7237
|
] : [],
|
|
5845
|
-
...optimizationCounts.keyedArrayReorderHints >
|
|
7238
|
+
...optimizationCounts.keyedArrayReorderHints > compilerUsage.keyedArrayStructuralReorderHints + compilerUsage.keyedArrayMapReorderHints ? [
|
|
5846
7239
|
core.types.importSpecifier(
|
|
5847
7240
|
keyedArrayReorderIdentifier,
|
|
5848
7241
|
core.types.identifier("createCompilerKeyedArrayReorder")
|
|
5849
7242
|
)
|
|
5850
7243
|
] : [],
|
|
5851
|
-
...
|
|
7244
|
+
...compilerUsage.keyedArrayStructuralReorderHints > 0 ? [
|
|
7245
|
+
core.types.importSpecifier(
|
|
7246
|
+
keyedArrayStructuralReorderIdentifier,
|
|
7247
|
+
core.types.identifier("createCompilerKeyedArrayStructuralReorder")
|
|
7248
|
+
)
|
|
7249
|
+
] : [],
|
|
7250
|
+
...optimizationCounts.keyedArraySortHints > compilerUsage.keyedArrayStructuralSortHints + compilerUsage.keyedArrayMapSortHints ? [
|
|
5852
7251
|
core.types.importSpecifier(
|
|
5853
7252
|
keyedArraySortIdentifier,
|
|
5854
7253
|
core.types.identifier("createCompilerKeyedArraySort")
|
|
5855
7254
|
)
|
|
5856
7255
|
] : [],
|
|
7256
|
+
...compilerUsage.keyedArrayStructuralSortHints > 0 ? [
|
|
7257
|
+
core.types.importSpecifier(
|
|
7258
|
+
keyedArrayStructuralSortIdentifier,
|
|
7259
|
+
core.types.identifier("createCompilerKeyedArrayStructuralSort")
|
|
7260
|
+
)
|
|
7261
|
+
] : [],
|
|
5857
7262
|
...optimizationCounts.keyedArrayRollingWindowHints > 0 ? [
|
|
5858
7263
|
core.types.importSpecifier(
|
|
5859
7264
|
keyedArrayRollingWindowIdentifier,
|
|
@@ -5994,12 +7399,46 @@ function createReactCompilerReport(projectRoot, observations) {
|
|
|
5994
7399
|
}
|
|
5995
7400
|
async function writeReactCompilerReport(projectRoot, reportFile, observations) {
|
|
5996
7401
|
const outputPath = path.resolve(projectRoot, reportFile);
|
|
7402
|
+
await assertReportPathInsideProject(projectRoot, outputPath);
|
|
5997
7403
|
const report = createReactCompilerReport(projectRoot, observations);
|
|
5998
7404
|
await promises.mkdir(path.dirname(outputPath), { recursive: true });
|
|
5999
7405
|
await promises.writeFile(outputPath, `${JSON.stringify(report, null, 2)}
|
|
6000
7406
|
`, "utf8");
|
|
6001
7407
|
return outputPath;
|
|
6002
7408
|
}
|
|
7409
|
+
async function assertReportPathInsideProject(projectRoot, outputPath) {
|
|
7410
|
+
const realProjectRoot = await promises.realpath(projectRoot);
|
|
7411
|
+
let existingAncestor = outputPath;
|
|
7412
|
+
while (true) {
|
|
7413
|
+
try {
|
|
7414
|
+
existingAncestor = await promises.realpath(existingAncestor);
|
|
7415
|
+
break;
|
|
7416
|
+
} catch (error) {
|
|
7417
|
+
if (error.code !== "ENOENT") throw error;
|
|
7418
|
+
let existingEntry = false;
|
|
7419
|
+
try {
|
|
7420
|
+
await promises.lstat(existingAncestor);
|
|
7421
|
+
existingEntry = true;
|
|
7422
|
+
} catch (statError) {
|
|
7423
|
+
if (statError.code !== "ENOENT") throw statError;
|
|
7424
|
+
}
|
|
7425
|
+
if (existingEntry) {
|
|
7426
|
+
throw new Error(
|
|
7427
|
+
"The React compiler report file must stay inside the project root, including through symlinks."
|
|
7428
|
+
);
|
|
7429
|
+
}
|
|
7430
|
+
const parent = path.dirname(existingAncestor);
|
|
7431
|
+
if (parent === existingAncestor) throw error;
|
|
7432
|
+
existingAncestor = parent;
|
|
7433
|
+
}
|
|
7434
|
+
}
|
|
7435
|
+
const relativePath = path.relative(realProjectRoot, existingAncestor);
|
|
7436
|
+
if (relativePath === ".." || relativePath.startsWith(`..${path.sep}`) || path.isAbsolute(relativePath)) {
|
|
7437
|
+
throw new Error(
|
|
7438
|
+
"The React compiler report file must stay inside the project root, including through symlinks."
|
|
7439
|
+
);
|
|
7440
|
+
}
|
|
7441
|
+
}
|
|
6003
7442
|
|
|
6004
7443
|
// src/index.ts
|
|
6005
7444
|
var DEFAULT_COMPILER_DIRECTIVE = "use compiler";
|