@farm.js/react 0.1.0-beta.30 → 0.1.0-beta.32
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/compiler-runtime.cjs +33 -18
- package/dist/compiler-runtime.cjs.map +1 -1
- package/dist/compiler-runtime.d.mts +2 -0
- package/dist/compiler-runtime.d.ts +2 -0
- package/dist/compiler-runtime.mjs +33 -18
- package/dist/compiler-runtime.mjs.map +1 -1
- package/dist/vite.cjs +69 -12
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.mjs +69 -12
- package/dist/vite.mjs.map +1 -1
- package/package.json +2 -2
package/dist/vite.mjs
CHANGED
|
@@ -330,12 +330,10 @@ function isPotentialKeyedMembershipCall(expression, reactiveByValue) {
|
|
|
330
330
|
}
|
|
331
331
|
function containsPotentialKeyedMembershipCall(expression, reactiveByValue) {
|
|
332
332
|
let found = false;
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
path.stop();
|
|
338
|
-
}
|
|
333
|
+
types.traverseFast(expression, (node) => {
|
|
334
|
+
if (!types.isCallExpression(node) || !isPotentialKeyedMembershipCall(node, reactiveByValue)) return;
|
|
335
|
+
found = true;
|
|
336
|
+
return types.traverseFast.stop;
|
|
339
337
|
});
|
|
340
338
|
return found;
|
|
341
339
|
}
|
|
@@ -348,12 +346,10 @@ function isPotentialKeyedMapLookupCall(expression, reactiveByValue) {
|
|
|
348
346
|
}
|
|
349
347
|
function containsPotentialKeyedMapLookupCall(expression, reactiveByValue) {
|
|
350
348
|
let found = false;
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
path.stop();
|
|
356
|
-
}
|
|
349
|
+
types.traverseFast(expression, (node) => {
|
|
350
|
+
if (!types.isCallExpression(node) || !isPotentialKeyedMapLookupCall(node, reactiveByValue)) return;
|
|
351
|
+
found = true;
|
|
352
|
+
return types.traverseFast.stop;
|
|
357
353
|
});
|
|
358
354
|
return found;
|
|
359
355
|
}
|
|
@@ -431,6 +427,14 @@ function keyedMapLookupTarget(binding, keyCallback, renderCallback, reactiveByVa
|
|
|
431
427
|
}
|
|
432
428
|
function collectReferencedLocals(expression, names) {
|
|
433
429
|
if (names.size === 0) return [];
|
|
430
|
+
let possible = false;
|
|
431
|
+
types.traverseFast(expression, (node) => {
|
|
432
|
+
if ((types.isIdentifier(node) || types.isJSXIdentifier(node)) && names.has(node.name)) {
|
|
433
|
+
possible = true;
|
|
434
|
+
return types.traverseFast.stop;
|
|
435
|
+
}
|
|
436
|
+
});
|
|
437
|
+
if (!possible) return [];
|
|
434
438
|
const references = /* @__PURE__ */ new Set();
|
|
435
439
|
traverse(expressionFile(cloneExpression(expression)), {
|
|
436
440
|
ReferencedIdentifier(path) {
|
|
@@ -4893,6 +4897,57 @@ function canCloneKeyedRows(plan) {
|
|
|
4893
4897
|
};
|
|
4894
4898
|
return cloneable(plan.row);
|
|
4895
4899
|
}
|
|
4900
|
+
function keyedRowBindingTargets(plan) {
|
|
4901
|
+
if (!canCloneKeyedRows(plan)) return void 0;
|
|
4902
|
+
const root = types.identifier("row");
|
|
4903
|
+
const targets = /* @__PURE__ */ new Map([["", root]]);
|
|
4904
|
+
const statements = [];
|
|
4905
|
+
let independentReads = 0;
|
|
4906
|
+
for (const binding of plan.bindings) {
|
|
4907
|
+
const path = [];
|
|
4908
|
+
for (const index of binding.path) {
|
|
4909
|
+
independentReads += index + 1;
|
|
4910
|
+
for (let sibling = 0; sibling <= index; sibling += 1) {
|
|
4911
|
+
const key = [...path, sibling].join(".");
|
|
4912
|
+
if (targets.has(key)) continue;
|
|
4913
|
+
if (statements.length === 32) return void 0;
|
|
4914
|
+
const parent = targets.get(
|
|
4915
|
+
sibling === 0 ? path.join(".") : [...path, sibling - 1].join(".")
|
|
4916
|
+
);
|
|
4917
|
+
const target = types.identifier(`target${statements.length}`);
|
|
4918
|
+
statements.push(
|
|
4919
|
+
types.variableDeclaration("const", [
|
|
4920
|
+
types.variableDeclarator(
|
|
4921
|
+
target,
|
|
4922
|
+
types.optionalMemberExpression(
|
|
4923
|
+
parent,
|
|
4924
|
+
types.identifier(sibling === 0 ? "firstElementChild" : "nextElementSibling"),
|
|
4925
|
+
false,
|
|
4926
|
+
true
|
|
4927
|
+
)
|
|
4928
|
+
)
|
|
4929
|
+
])
|
|
4930
|
+
);
|
|
4931
|
+
targets.set(key, target);
|
|
4932
|
+
}
|
|
4933
|
+
path.push(index);
|
|
4934
|
+
}
|
|
4935
|
+
}
|
|
4936
|
+
if (statements.length >= independentReads) return void 0;
|
|
4937
|
+
return types.arrowFunctionExpression(
|
|
4938
|
+
[root],
|
|
4939
|
+
types.blockStatement([
|
|
4940
|
+
...statements,
|
|
4941
|
+
types.returnStatement(
|
|
4942
|
+
types.arrayExpression(
|
|
4943
|
+
plan.bindings.map(
|
|
4944
|
+
(binding) => types.logicalExpression("??", targets.get(binding.path.join(".")), types.nullLiteral())
|
|
4945
|
+
)
|
|
4946
|
+
)
|
|
4947
|
+
)
|
|
4948
|
+
])
|
|
4949
|
+
);
|
|
4950
|
+
}
|
|
4896
4951
|
function keyedRowsBoundary(blockRuntime, plan, keyedMapUpdateHints, keyedArrayFilterHintedStateIndices, keyedArrayPrependHintedStateIndices, keyedArrayPositionHintedStateIndices, keyedArrayReorderHintedStateIndices) {
|
|
4897
4952
|
const name = types.jsxMemberExpression(
|
|
4898
4953
|
types.jsxIdentifier(blockRuntime.name),
|
|
@@ -4910,6 +4965,7 @@ function keyedRowsBoundary(blockRuntime, plan, keyedMapUpdateHints, keyedArrayFi
|
|
|
4910
4965
|
...plan.conditionals.map((conditional) => conditional.test)
|
|
4911
4966
|
]);
|
|
4912
4967
|
const delegatedEvents = canDelegateKeyedRowEvents(plan);
|
|
4968
|
+
const bindingTargets = keyedRowBindingTargets(plan);
|
|
4913
4969
|
const renderSource = keyedRowsRenderSource(plan, eventFactory, conditionalFactory);
|
|
4914
4970
|
const renderFactoryParameters = plan.conditionals.length > 0 ? [types.cloneNode(eventFactory), types.cloneNode(conditionalFactory)] : plan.events.length > 0 ? [types.cloneNode(eventFactory)] : [];
|
|
4915
4971
|
return types.jsxElement(
|
|
@@ -5030,6 +5086,7 @@ function keyedRowsBoundary(blockRuntime, plan, keyedMapUpdateHints, keyedArrayFi
|
|
|
5030
5086
|
types.jsxExpressionContainer(types.booleanLiteral(true))
|
|
5031
5087
|
)
|
|
5032
5088
|
] : [],
|
|
5089
|
+
...bindingTargets ? [types.jsxAttribute(types.jsxIdentifier("targets"), types.jsxExpressionContainer(bindingTargets))] : [],
|
|
5033
5090
|
...canCloneKeyedRows(plan) ? [
|
|
5034
5091
|
types.jsxAttribute(
|
|
5035
5092
|
types.jsxIdentifier("cloneRows"),
|