@farm.js/react 0.1.0-beta.31 → 0.1.0-beta.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client.d.mts +1 -0
- package/dist/client.d.ts +1 -0
- package/dist/compiler-runtime.cjs +70 -35
- package/dist/compiler-runtime.cjs.map +1 -1
- package/dist/compiler-runtime.d.mts +4 -1
- package/dist/compiler-runtime.d.ts +4 -1
- package/dist/compiler-runtime.mjs +70 -36
- package/dist/compiler-runtime.mjs.map +1 -1
- package/dist/server.d.mts +0 -1
- package/dist/server.d.ts +0 -1
- package/dist/vite.cjs +72 -12
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.mjs +72 -12
- package/dist/vite.mjs.map +1 -1
- package/package.json +3 -3
package/dist/server.d.mts
CHANGED
package/dist/server.d.ts
CHANGED
package/dist/vite.cjs
CHANGED
|
@@ -80,6 +80,7 @@ var COMPILER_RUNTIME_FEATURE_EXPORTS = {
|
|
|
80
80
|
"keyed-rows-window-position-hinted": "keyedRowsWindowPositionHintedRuntimeFeature",
|
|
81
81
|
"keyed-rows-reorder-hinted": "keyedRowsReorderHintedRuntimeFeature",
|
|
82
82
|
"keyed-rows-plain-reorder-hinted": "keyedRowsPlainReorderHintedRuntimeFeature",
|
|
83
|
+
"keyed-rows-plain-map-reorder-hinted": "keyedRowsPlainMapReorderHintedRuntimeFeature",
|
|
83
84
|
"keyed-rows-map-reorder-hinted": "keyedRowsMapReorderHintedRuntimeFeature",
|
|
84
85
|
"keyed-rows-all-hinted": "keyedRowsAllHintedRuntimeFeature",
|
|
85
86
|
"keyed-rows-mapped-rolling-window-hinted": "keyedRowsMappedRollingWindowHintedRuntimeFeature",
|
|
@@ -188,6 +189,8 @@ function runtimeFeaturesForPlans(plans, keyedUpdateHints, keyedArrayFilterHints,
|
|
|
188
189
|
features.add("keyed-rows-prepend-only");
|
|
189
190
|
} else if (keyedRowsFeature === "keyed-rows" && hintSuffix === "-reorder-hinted" && keyedTargetKinds.size === 0) {
|
|
190
191
|
features.add("keyed-rows-plain-reorder-hinted");
|
|
192
|
+
} else if (keyedRowsFeature === "keyed-rows" && hintSuffix === "-map-reorder-hinted" && keyedTargetKinds.size === 0) {
|
|
193
|
+
features.add("keyed-rows-plain-map-reorder-hinted");
|
|
191
194
|
} else if (keyedRowsFeature === "keyed-rows" && hintSuffix === "-filter-hinted" && keyedTargetKinds.size === 1 && keyedTargetKinds.has("identity")) {
|
|
192
195
|
features.add(
|
|
193
196
|
keyedMapOrAppendHints ? "keyed-rows-identity-filter-hinted" : "keyed-rows-identity-filter-only"
|
|
@@ -332,12 +335,10 @@ function isPotentialKeyedMembershipCall(expression, reactiveByValue) {
|
|
|
332
335
|
}
|
|
333
336
|
function containsPotentialKeyedMembershipCall(expression, reactiveByValue) {
|
|
334
337
|
let found = false;
|
|
335
|
-
core.
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
path.stop();
|
|
340
|
-
}
|
|
338
|
+
core.types.traverseFast(expression, (node) => {
|
|
339
|
+
if (!core.types.isCallExpression(node) || !isPotentialKeyedMembershipCall(node, reactiveByValue)) return;
|
|
340
|
+
found = true;
|
|
341
|
+
return core.types.traverseFast.stop;
|
|
341
342
|
});
|
|
342
343
|
return found;
|
|
343
344
|
}
|
|
@@ -350,12 +351,10 @@ function isPotentialKeyedMapLookupCall(expression, reactiveByValue) {
|
|
|
350
351
|
}
|
|
351
352
|
function containsPotentialKeyedMapLookupCall(expression, reactiveByValue) {
|
|
352
353
|
let found = false;
|
|
353
|
-
core.
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
path.stop();
|
|
358
|
-
}
|
|
354
|
+
core.types.traverseFast(expression, (node) => {
|
|
355
|
+
if (!core.types.isCallExpression(node) || !isPotentialKeyedMapLookupCall(node, reactiveByValue)) return;
|
|
356
|
+
found = true;
|
|
357
|
+
return core.types.traverseFast.stop;
|
|
359
358
|
});
|
|
360
359
|
return found;
|
|
361
360
|
}
|
|
@@ -433,6 +432,14 @@ function keyedMapLookupTarget(binding, keyCallback, renderCallback, reactiveByVa
|
|
|
433
432
|
}
|
|
434
433
|
function collectReferencedLocals(expression, names) {
|
|
435
434
|
if (names.size === 0) return [];
|
|
435
|
+
let possible = false;
|
|
436
|
+
core.types.traverseFast(expression, (node) => {
|
|
437
|
+
if ((core.types.isIdentifier(node) || core.types.isJSXIdentifier(node)) && names.has(node.name)) {
|
|
438
|
+
possible = true;
|
|
439
|
+
return core.types.traverseFast.stop;
|
|
440
|
+
}
|
|
441
|
+
});
|
|
442
|
+
if (!possible) return [];
|
|
436
443
|
const references = /* @__PURE__ */ new Set();
|
|
437
444
|
core.traverse(expressionFile(cloneExpression(expression)), {
|
|
438
445
|
ReferencedIdentifier(path) {
|
|
@@ -4895,6 +4902,57 @@ function canCloneKeyedRows(plan) {
|
|
|
4895
4902
|
};
|
|
4896
4903
|
return cloneable(plan.row);
|
|
4897
4904
|
}
|
|
4905
|
+
function keyedRowBindingTargets(plan) {
|
|
4906
|
+
if (!canCloneKeyedRows(plan)) return void 0;
|
|
4907
|
+
const root = core.types.identifier("row");
|
|
4908
|
+
const targets = /* @__PURE__ */ new Map([["", root]]);
|
|
4909
|
+
const statements = [];
|
|
4910
|
+
let independentReads = 0;
|
|
4911
|
+
for (const binding of plan.bindings) {
|
|
4912
|
+
const path = [];
|
|
4913
|
+
for (const index of binding.path) {
|
|
4914
|
+
independentReads += index + 1;
|
|
4915
|
+
for (let sibling = 0; sibling <= index; sibling += 1) {
|
|
4916
|
+
const key = [...path, sibling].join(".");
|
|
4917
|
+
if (targets.has(key)) continue;
|
|
4918
|
+
if (statements.length === 32) return void 0;
|
|
4919
|
+
const parent = targets.get(
|
|
4920
|
+
sibling === 0 ? path.join(".") : [...path, sibling - 1].join(".")
|
|
4921
|
+
);
|
|
4922
|
+
const target = core.types.identifier(`target${statements.length}`);
|
|
4923
|
+
statements.push(
|
|
4924
|
+
core.types.variableDeclaration("const", [
|
|
4925
|
+
core.types.variableDeclarator(
|
|
4926
|
+
target,
|
|
4927
|
+
core.types.optionalMemberExpression(
|
|
4928
|
+
parent,
|
|
4929
|
+
core.types.identifier(sibling === 0 ? "firstElementChild" : "nextElementSibling"),
|
|
4930
|
+
false,
|
|
4931
|
+
true
|
|
4932
|
+
)
|
|
4933
|
+
)
|
|
4934
|
+
])
|
|
4935
|
+
);
|
|
4936
|
+
targets.set(key, target);
|
|
4937
|
+
}
|
|
4938
|
+
path.push(index);
|
|
4939
|
+
}
|
|
4940
|
+
}
|
|
4941
|
+
if (statements.length >= independentReads) return void 0;
|
|
4942
|
+
return core.types.arrowFunctionExpression(
|
|
4943
|
+
[root],
|
|
4944
|
+
core.types.blockStatement([
|
|
4945
|
+
...statements,
|
|
4946
|
+
core.types.returnStatement(
|
|
4947
|
+
core.types.arrayExpression(
|
|
4948
|
+
plan.bindings.map(
|
|
4949
|
+
(binding) => core.types.logicalExpression("??", targets.get(binding.path.join(".")), core.types.nullLiteral())
|
|
4950
|
+
)
|
|
4951
|
+
)
|
|
4952
|
+
)
|
|
4953
|
+
])
|
|
4954
|
+
);
|
|
4955
|
+
}
|
|
4898
4956
|
function keyedRowsBoundary(blockRuntime, plan, keyedMapUpdateHints, keyedArrayFilterHintedStateIndices, keyedArrayPrependHintedStateIndices, keyedArrayPositionHintedStateIndices, keyedArrayReorderHintedStateIndices) {
|
|
4899
4957
|
const name = core.types.jsxMemberExpression(
|
|
4900
4958
|
core.types.jsxIdentifier(blockRuntime.name),
|
|
@@ -4912,6 +4970,7 @@ function keyedRowsBoundary(blockRuntime, plan, keyedMapUpdateHints, keyedArrayFi
|
|
|
4912
4970
|
...plan.conditionals.map((conditional) => conditional.test)
|
|
4913
4971
|
]);
|
|
4914
4972
|
const delegatedEvents = canDelegateKeyedRowEvents(plan);
|
|
4973
|
+
const bindingTargets = keyedRowBindingTargets(plan);
|
|
4915
4974
|
const renderSource = keyedRowsRenderSource(plan, eventFactory, conditionalFactory);
|
|
4916
4975
|
const renderFactoryParameters = plan.conditionals.length > 0 ? [core.types.cloneNode(eventFactory), core.types.cloneNode(conditionalFactory)] : plan.events.length > 0 ? [core.types.cloneNode(eventFactory)] : [];
|
|
4917
4976
|
return core.types.jsxElement(
|
|
@@ -5032,6 +5091,7 @@ function keyedRowsBoundary(blockRuntime, plan, keyedMapUpdateHints, keyedArrayFi
|
|
|
5032
5091
|
core.types.jsxExpressionContainer(core.types.booleanLiteral(true))
|
|
5033
5092
|
)
|
|
5034
5093
|
] : [],
|
|
5094
|
+
...bindingTargets ? [core.types.jsxAttribute(core.types.jsxIdentifier("targets"), core.types.jsxExpressionContainer(bindingTargets))] : [],
|
|
5035
5095
|
...canCloneKeyedRows(plan) ? [
|
|
5036
5096
|
core.types.jsxAttribute(
|
|
5037
5097
|
core.types.jsxIdentifier("cloneRows"),
|