@barefootjs/jsx 0.35.3 → 0.35.5
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/analyzer.d.ts.map +1 -1
- package/dist/debug.d.ts +33 -3
- package/dist/debug.d.ts.map +1 -1
- package/dist/index.js +267 -73
- package/dist/ir-to-client-js/collect-elements.d.ts.map +1 -1
- package/dist/ir-to-client-js/compute-inlinability.d.ts +8 -0
- package/dist/ir-to-client-js/compute-inlinability.d.ts.map +1 -1
- package/dist/ir-to-client-js/generate-init.d.ts.map +1 -1
- package/dist/ir-to-client-js/imports.d.ts +2 -2
- package/dist/ir-to-client-js/imports.d.ts.map +1 -1
- package/dist/ir-to-client-js/prop-handling.d.ts.map +1 -1
- package/dist/ir-to-client-js/types.d.ts +25 -0
- package/dist/ir-to-client-js/types.d.ts.map +1 -1
- package/dist/ir-to-client-js/utils.d.ts +12 -1
- package/dist/ir-to-client-js/utils.d.ts.map +1 -1
- package/dist/types.d.ts +31 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/debug.test.ts +246 -0
- package/src/__tests__/issue-2897-static-loop-conditional.test.ts +340 -0
- package/src/__tests__/issue-2910-mutated-const-not-inlined.test.ts +118 -0
- package/src/__tests__/issue-2910-own-scope-id-emission.test.ts +64 -0
- package/src/__tests__/lazy-conditional.test.ts +1 -0
- package/src/analyzer.ts +157 -22
- package/src/debug.ts +214 -84
- package/src/ir-to-client-js/collect-elements.ts +83 -3
- package/src/ir-to-client-js/compute-inlinability.ts +8 -1
- package/src/ir-to-client-js/emit-registration.ts +2 -2
- package/src/ir-to-client-js/generate-init.ts +16 -2
- package/src/ir-to-client-js/imports.ts +6 -0
- package/src/ir-to-client-js/index.ts +6 -0
- package/src/ir-to-client-js/prop-handling.ts +9 -0
- package/src/ir-to-client-js/types.ts +37 -1
- package/src/ir-to-client-js/utils.ts +15 -1
- package/src/jsx-to-ir.ts +14 -0
- package/src/types.ts +31 -0
package/dist/index.js
CHANGED
|
@@ -2449,6 +2449,9 @@ import {
|
|
|
2449
2449
|
keyAttrName as sharedKeyAttrName
|
|
2450
2450
|
} from "@barefootjs/shared";
|
|
2451
2451
|
var PROPS_PARAM = "_p";
|
|
2452
|
+
function isCommentScopedRoot(root) {
|
|
2453
|
+
return root.type === "fragment" && !!root.needsScopeComment || root.type === "component";
|
|
2454
|
+
}
|
|
2452
2455
|
var keyAttrName = sharedKeyAttrName;
|
|
2453
2456
|
function mapArrayKeyArgs(bfIdArg, keyed, loopDepth) {
|
|
2454
2457
|
if (!keyed || loopDepth <= 0)
|
|
@@ -7288,6 +7291,7 @@ function collectInitStatement(node, ctx) {
|
|
|
7288
7291
|
loc: getSourceLocation(node, ctx.sourceFile, ctx.filePath),
|
|
7289
7292
|
freeIdentifiers: extractFreeIdentifiersFromNode(node),
|
|
7290
7293
|
assignedIdentifiers: extractAssignedIdentifiersFromNode(node),
|
|
7294
|
+
mutatedIdentifiers: extractMutatedIdentifiersFromNode(node),
|
|
7291
7295
|
origin: { phase: "hydrate", scope: "init", effect: "pure" },
|
|
7292
7296
|
needsLeadingSemi: leadsWithAsiHazard(body)
|
|
7293
7297
|
});
|
|
@@ -7347,11 +7351,8 @@ function extractAssignedIdentifiersFromNode(node) {
|
|
|
7347
7351
|
if (ts11.isArrowFunction(n) || ts11.isFunctionExpression(n) || ts11.isFunctionDeclaration(n) || ts11.isMethodDeclaration(n) || ts11.isGetAccessorDeclaration(n) || ts11.isSetAccessorDeclaration(n) || ts11.isConstructorDeclaration(n)) {
|
|
7348
7352
|
return;
|
|
7349
7353
|
}
|
|
7350
|
-
if (ts11.isBinaryExpression(n)) {
|
|
7351
|
-
|
|
7352
|
-
if (op === ts11.SyntaxKind.EqualsToken || op === ts11.SyntaxKind.PlusEqualsToken || op === ts11.SyntaxKind.MinusEqualsToken || op === ts11.SyntaxKind.AsteriskEqualsToken || op === ts11.SyntaxKind.SlashEqualsToken || op === ts11.SyntaxKind.PercentEqualsToken || op === ts11.SyntaxKind.AsteriskAsteriskEqualsToken || op === ts11.SyntaxKind.AmpersandEqualsToken || op === ts11.SyntaxKind.BarEqualsToken || op === ts11.SyntaxKind.CaretEqualsToken || op === ts11.SyntaxKind.LessThanLessThanEqualsToken || op === ts11.SyntaxKind.GreaterThanGreaterThanEqualsToken || op === ts11.SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken || op === ts11.SyntaxKind.AmpersandAmpersandEqualsToken || op === ts11.SyntaxKind.BarBarEqualsToken || op === ts11.SyntaxKind.QuestionQuestionEqualsToken) {
|
|
7353
|
-
addFromTarget(n.left);
|
|
7354
|
-
}
|
|
7354
|
+
if (ts11.isBinaryExpression(n) && isAssignmentOperator(n.operatorToken.kind)) {
|
|
7355
|
+
addFromTarget(n.left);
|
|
7355
7356
|
}
|
|
7356
7357
|
if (ts11.isPrefixUnaryExpression(n) || ts11.isPostfixUnaryExpression(n)) {
|
|
7357
7358
|
if (n.operator === ts11.SyntaxKind.PlusPlusToken || n.operator === ts11.SyntaxKind.MinusMinusToken) {
|
|
@@ -7366,6 +7367,87 @@ function extractAssignedIdentifiersFromNode(node) {
|
|
|
7366
7367
|
ids.delete(name);
|
|
7367
7368
|
return ids;
|
|
7368
7369
|
}
|
|
7370
|
+
var MUTATING_METHOD_NAMES = new Set([
|
|
7371
|
+
"push",
|
|
7372
|
+
"pop",
|
|
7373
|
+
"shift",
|
|
7374
|
+
"unshift",
|
|
7375
|
+
"splice",
|
|
7376
|
+
"sort",
|
|
7377
|
+
"reverse",
|
|
7378
|
+
"fill",
|
|
7379
|
+
"copyWithin",
|
|
7380
|
+
"set",
|
|
7381
|
+
"add",
|
|
7382
|
+
"delete",
|
|
7383
|
+
"clear"
|
|
7384
|
+
]);
|
|
7385
|
+
function extractMutatedIdentifiersFromNode(node) {
|
|
7386
|
+
const ids = new Set;
|
|
7387
|
+
function rootIdentifierOf(expr) {
|
|
7388
|
+
let current = expr;
|
|
7389
|
+
while (true) {
|
|
7390
|
+
if (ts11.isIdentifier(current))
|
|
7391
|
+
return current.text;
|
|
7392
|
+
if (ts11.isParenthesizedExpression(current)) {
|
|
7393
|
+
current = current.expression;
|
|
7394
|
+
continue;
|
|
7395
|
+
}
|
|
7396
|
+
if (ts11.isNonNullExpression(current)) {
|
|
7397
|
+
current = current.expression;
|
|
7398
|
+
continue;
|
|
7399
|
+
}
|
|
7400
|
+
if (ts11.isPropertyAccessExpression(current)) {
|
|
7401
|
+
current = current.expression;
|
|
7402
|
+
continue;
|
|
7403
|
+
}
|
|
7404
|
+
if (ts11.isElementAccessExpression(current)) {
|
|
7405
|
+
current = current.expression;
|
|
7406
|
+
continue;
|
|
7407
|
+
}
|
|
7408
|
+
return null;
|
|
7409
|
+
}
|
|
7410
|
+
}
|
|
7411
|
+
function visit2(n) {
|
|
7412
|
+
if (ts11.isArrowFunction(n) || ts11.isFunctionExpression(n) || ts11.isFunctionDeclaration(n) || ts11.isMethodDeclaration(n) || ts11.isGetAccessorDeclaration(n) || ts11.isSetAccessorDeclaration(n) || ts11.isConstructorDeclaration(n)) {
|
|
7413
|
+
return;
|
|
7414
|
+
}
|
|
7415
|
+
if (ts11.isBinaryExpression(n) && isAssignmentOperator(n.operatorToken.kind)) {
|
|
7416
|
+
if (ts11.isPropertyAccessExpression(n.left) || ts11.isElementAccessExpression(n.left)) {
|
|
7417
|
+
const root = rootIdentifierOf(n.left);
|
|
7418
|
+
if (root)
|
|
7419
|
+
ids.add(root);
|
|
7420
|
+
}
|
|
7421
|
+
} else if (ts11.isPrefixUnaryExpression(n) || ts11.isPostfixUnaryExpression(n)) {
|
|
7422
|
+
const isIncDec = n.operator === ts11.SyntaxKind.PlusPlusToken || n.operator === ts11.SyntaxKind.MinusMinusToken;
|
|
7423
|
+
if (isIncDec && (ts11.isPropertyAccessExpression(n.operand) || ts11.isElementAccessExpression(n.operand))) {
|
|
7424
|
+
const root = rootIdentifierOf(n.operand);
|
|
7425
|
+
if (root)
|
|
7426
|
+
ids.add(root);
|
|
7427
|
+
}
|
|
7428
|
+
} else if (ts11.isCallExpression(n)) {
|
|
7429
|
+
const callee = n.expression;
|
|
7430
|
+
if (ts11.isPropertyAccessExpression(callee)) {
|
|
7431
|
+
const methodName = callee.name.text;
|
|
7432
|
+
if (MUTATING_METHOD_NAMES.has(methodName)) {
|
|
7433
|
+
const root = rootIdentifierOf(callee.expression);
|
|
7434
|
+
if (root)
|
|
7435
|
+
ids.add(root);
|
|
7436
|
+
} else if (methodName === "assign" && ts11.isIdentifier(callee.expression) && callee.expression.text === "Object" && n.arguments.length > 0) {
|
|
7437
|
+
const root = rootIdentifierOf(n.arguments[0]);
|
|
7438
|
+
if (root)
|
|
7439
|
+
ids.add(root);
|
|
7440
|
+
}
|
|
7441
|
+
}
|
|
7442
|
+
}
|
|
7443
|
+
ts11.forEachChild(n, visit2);
|
|
7444
|
+
}
|
|
7445
|
+
visit2(node);
|
|
7446
|
+
return ids;
|
|
7447
|
+
}
|
|
7448
|
+
function isAssignmentOperator(kind) {
|
|
7449
|
+
return kind === ts11.SyntaxKind.EqualsToken || kind === ts11.SyntaxKind.PlusEqualsToken || kind === ts11.SyntaxKind.MinusEqualsToken || kind === ts11.SyntaxKind.AsteriskEqualsToken || kind === ts11.SyntaxKind.SlashEqualsToken || kind === ts11.SyntaxKind.PercentEqualsToken || kind === ts11.SyntaxKind.AsteriskAsteriskEqualsToken || kind === ts11.SyntaxKind.AmpersandEqualsToken || kind === ts11.SyntaxKind.BarEqualsToken || kind === ts11.SyntaxKind.CaretEqualsToken || kind === ts11.SyntaxKind.LessThanLessThanEqualsToken || kind === ts11.SyntaxKind.GreaterThanGreaterThanEqualsToken || kind === ts11.SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken || kind === ts11.SyntaxKind.AmpersandAmpersandEqualsToken || kind === ts11.SyntaxKind.BarBarEqualsToken || kind === ts11.SyntaxKind.QuestionQuestionEqualsToken;
|
|
7450
|
+
}
|
|
7369
7451
|
function collectLocalDeclarations(root) {
|
|
7370
7452
|
const names = new Set;
|
|
7371
7453
|
function addBindingName(name) {
|
|
@@ -8523,6 +8605,7 @@ function validateContext(ctx) {
|
|
|
8523
8605
|
}));
|
|
8524
8606
|
}
|
|
8525
8607
|
}
|
|
8608
|
+
markMutatedConstants(ctx);
|
|
8526
8609
|
validateInitStatementReferences(ctx);
|
|
8527
8610
|
validateReactiveFactoryCalls(ctx);
|
|
8528
8611
|
validateNamespaceQualifiedPrimitives(ctx);
|
|
@@ -8686,6 +8769,25 @@ function fileHasUseClientDirective(filePath) {
|
|
|
8686
8769
|
visit2(sf);
|
|
8687
8770
|
return found;
|
|
8688
8771
|
}
|
|
8772
|
+
function markMutatedConstants(ctx) {
|
|
8773
|
+
if (ctx.initStatements.length === 0 || ctx.localConstants.length === 0)
|
|
8774
|
+
return;
|
|
8775
|
+
const mutatedNames = new Set;
|
|
8776
|
+
for (const stmt of ctx.initStatements) {
|
|
8777
|
+
if (stmt.mutatedIdentifiers)
|
|
8778
|
+
for (const name of stmt.mutatedIdentifiers)
|
|
8779
|
+
mutatedNames.add(name);
|
|
8780
|
+
if (stmt.assignedIdentifiers)
|
|
8781
|
+
for (const name of stmt.assignedIdentifiers)
|
|
8782
|
+
mutatedNames.add(name);
|
|
8783
|
+
}
|
|
8784
|
+
if (mutatedNames.size === 0)
|
|
8785
|
+
return;
|
|
8786
|
+
for (const constant of ctx.localConstants) {
|
|
8787
|
+
if (mutatedNames.has(constant.name))
|
|
8788
|
+
constant.mutatedAfterDeclaration = true;
|
|
8789
|
+
}
|
|
8790
|
+
}
|
|
8689
8791
|
function validateInitStatementReferences(ctx) {
|
|
8690
8792
|
if (ctx.initStatements.length === 0)
|
|
8691
8793
|
return;
|
|
@@ -10068,7 +10170,7 @@ function findAssignedNames(bodyText, candidates) {
|
|
|
10068
10170
|
}
|
|
10069
10171
|
};
|
|
10070
10172
|
const visit2 = (node) => {
|
|
10071
|
-
if (ts12.isBinaryExpression(node) &&
|
|
10173
|
+
if (ts12.isBinaryExpression(node) && isAssignmentOperator2(node.operatorToken.kind)) {
|
|
10072
10174
|
record(node.left);
|
|
10073
10175
|
} else if ((ts12.isPrefixUnaryExpression(node) || ts12.isPostfixUnaryExpression(node)) && (node.operator === ts12.SyntaxKind.PlusPlusToken || node.operator === ts12.SyntaxKind.MinusMinusToken)) {
|
|
10074
10176
|
record(node.operand);
|
|
@@ -10097,7 +10199,7 @@ function closeOverWritersOfMutableBindings(primaryRefs, declarations, mutableNam
|
|
|
10097
10199
|
}
|
|
10098
10200
|
return reachable;
|
|
10099
10201
|
}
|
|
10100
|
-
function
|
|
10202
|
+
function isAssignmentOperator2(kind) {
|
|
10101
10203
|
return kind >= ts12.SyntaxKind.FirstAssignment && kind <= ts12.SyntaxKind.LastAssignment;
|
|
10102
10204
|
}
|
|
10103
10205
|
function extractFunctionParams(value) {
|
|
@@ -14135,6 +14237,8 @@ function tryResolveTemplateSpanFromConst(expr, ctx) {
|
|
|
14135
14237
|
const constInfo = findLocalConst(expr.text, ctx.analyzer);
|
|
14136
14238
|
if (!constInfo)
|
|
14137
14239
|
return null;
|
|
14240
|
+
if (constInfo.mutatedAfterDeclaration)
|
|
14241
|
+
return null;
|
|
14138
14242
|
const ast = parseConstInitializer(constInfo);
|
|
14139
14243
|
if (!ast)
|
|
14140
14244
|
return null;
|
|
@@ -14151,6 +14255,8 @@ function tryResolveTemplateSpanFromConst(expr, ctx) {
|
|
|
14151
14255
|
const constInfo = findLocalConst(expr.expression.text, ctx.analyzer);
|
|
14152
14256
|
if (!constInfo)
|
|
14153
14257
|
return null;
|
|
14258
|
+
if (constInfo.mutatedAfterDeclaration)
|
|
14259
|
+
return null;
|
|
14154
14260
|
const ast = parseConstInitializer(constInfo);
|
|
14155
14261
|
if (!ast || !ts14.isObjectLiteralExpression(ast))
|
|
14156
14262
|
return null;
|
|
@@ -14230,6 +14336,8 @@ function tryResolveIdentifierAsTemplateLiteral(ident, ctx) {
|
|
|
14230
14336
|
const constInfo = findLocalConst(ident.text, ctx.analyzer);
|
|
14231
14337
|
if (!constInfo)
|
|
14232
14338
|
return null;
|
|
14339
|
+
if (constInfo.mutatedAfterDeclaration)
|
|
14340
|
+
return null;
|
|
14233
14341
|
const ast = parseConstInitializer(constInfo);
|
|
14234
14342
|
if (!ast)
|
|
14235
14343
|
return null;
|
|
@@ -15103,6 +15211,8 @@ function expandDynamicPropValue(value, ctx, scope) {
|
|
|
15103
15211
|
if (scope?.isBound(trimmedValue))
|
|
15104
15212
|
return value;
|
|
15105
15213
|
const constant = ctx.localConstants.find((c) => c.name === trimmedValue);
|
|
15214
|
+
if (constant?.mutatedAfterDeclaration)
|
|
15215
|
+
return value;
|
|
15106
15216
|
if (constant && constant.value) {
|
|
15107
15217
|
return constant.value;
|
|
15108
15218
|
}
|
|
@@ -15115,6 +15225,8 @@ function expandConstantForReactivity(expr, ctx, originalFreeIds, scope) {
|
|
|
15115
15225
|
if (scope?.isBound(trimmedValue))
|
|
15116
15226
|
return { expr, freeIds: originalFreeIds };
|
|
15117
15227
|
const constant = ctx.localConstants.find((c) => c.name === trimmedValue);
|
|
15228
|
+
if (constant?.mutatedAfterDeclaration)
|
|
15229
|
+
return { expr, freeIds: originalFreeIds };
|
|
15118
15230
|
if (constant && constant.value) {
|
|
15119
15231
|
return { expr: constant.value, freeIds: constant.freeIdentifiers };
|
|
15120
15232
|
}
|
|
@@ -16051,7 +16163,12 @@ function collectElements(node, ctx, siblingOffsets, insideConditional = false) {
|
|
|
16051
16163
|
}
|
|
16052
16164
|
}
|
|
16053
16165
|
}
|
|
16054
|
-
const { useElementReconciliation, innerLoops } = projectionInner ? { useElementReconciliation: false, innerLoops: undefined } : decideLoopRendering(l, siblingOffsets, ctx);
|
|
16166
|
+
const { useElementReconciliation: reconciliationBase, innerLoops } = projectionInner ? { useElementReconciliation: false, innerLoops: undefined } : decideLoopRendering(l, siblingOffsets, ctx);
|
|
16167
|
+
const staticRowHasConditional = !projectionInner && l.isStaticArray && !l.childComponent && bindings.conditionals.some((c) => c.reactiveBeyondLoopScope);
|
|
16168
|
+
const staticInnerLoopHasConditional = !projectionInner && l.isStaticArray && !l.childComponent && (innerLoops ?? []).some((il) => il.bindings.conditionals.some((c) => c.reactiveBeyondLoopScope));
|
|
16169
|
+
const hasInnerStructure = (l.nestedComponents?.length ?? 0) > 0 || (innerLoops?.length ?? 0) > 0;
|
|
16170
|
+
const useElementReconciliation = reconciliationBase || staticInnerLoopHasConditional || staticRowHasConditional && hasInnerStructure;
|
|
16171
|
+
const clientIsStaticArray = l.isStaticArray && !staticRowHasConditional && !staticInnerLoopHasConditional;
|
|
16055
16172
|
let template = "";
|
|
16056
16173
|
let templateIndexed;
|
|
16057
16174
|
let staticItemTemplate;
|
|
@@ -16105,7 +16222,7 @@ function collectElements(node, ctx, siblingOffsets, insideConditional = false) {
|
|
|
16105
16222
|
bindings,
|
|
16106
16223
|
childComponent: l.childComponent,
|
|
16107
16224
|
nestedComponents: l.nestedComponents,
|
|
16108
|
-
isStaticArray:
|
|
16225
|
+
isStaticArray: clientIsStaticArray,
|
|
16109
16226
|
useElementReconciliation,
|
|
16110
16227
|
innerLoops: useElementReconciliation || l.isStaticArray && innerLoops?.length ? innerLoops : undefined,
|
|
16111
16228
|
offset: resolveLoopOffset(siblingOffsets.get(l)),
|
|
@@ -16416,6 +16533,7 @@ function collectLoopChildConditionals(node, ctx, siblingOffsets, loopParam, loop
|
|
|
16416
16533
|
const readsPreamble = preambleNames !== undefined && preambleNames.size > 0 && anyNameIn(expanded.freeIds ?? extractFreeIdentifiersFromText(expanded.expr), preambleNames);
|
|
16417
16534
|
if (!readsPreamble && classifyReactivity(expanded.expr, ctx, scope, expanded.freeIds).kind === "none")
|
|
16418
16535
|
return;
|
|
16536
|
+
const reactiveBeyondLoopScope = n.reactive || readsPreamble || needsEffectWrapper(expanded.expr, ctx, expanded.freeIds);
|
|
16419
16537
|
const loopParamsForCond = loopParams ?? (loopParam ? [{ param: loopParam, bindings: loopParamBindings, index: loopIndex }] : undefined);
|
|
16420
16538
|
const whenTrueHtml = irToHtmlTemplate(n.whenTrue, undefined, 0, loopParamsForCond, "__slots");
|
|
16421
16539
|
const whenFalseHtml = irToHtmlTemplate(n.whenFalse, undefined, 0, loopParamsForCond, "__slots");
|
|
@@ -16427,7 +16545,8 @@ function collectLoopChildConditionals(node, ctx, siblingOffsets, loopParam, loop
|
|
|
16427
16545
|
whenTrue: summarizeLoopChildBranch(n.whenTrue, ctx, siblingOffsets, loopParam, loopParamBindings, preambleNames, loopIndex),
|
|
16428
16546
|
whenFalse: summarizeLoopChildBranch(n.whenFalse, ctx, siblingOffsets, loopParam, loopParamBindings, preambleNames, loopIndex),
|
|
16429
16547
|
...expanded.freeIds !== undefined && { conditionFreeIdentifiers: expanded.freeIds },
|
|
16430
|
-
...readsPreamble && { readsPreamble: true }
|
|
16548
|
+
...readsPreamble && { readsPreamble: true },
|
|
16549
|
+
reactiveBeyondLoopScope
|
|
16431
16550
|
});
|
|
16432
16551
|
}
|
|
16433
16552
|
});
|
|
@@ -17019,7 +17138,8 @@ var RUNTIME_IMPORT_CANDIDATES = [
|
|
|
17019
17138
|
"beginTurn",
|
|
17020
17139
|
"endTurn",
|
|
17021
17140
|
"date",
|
|
17022
|
-
"formatDate"
|
|
17141
|
+
"formatDate",
|
|
17142
|
+
"ownScopeId"
|
|
17023
17143
|
];
|
|
17024
17144
|
var RUNTIME_MODULE = "@barefootjs/client/runtime";
|
|
17025
17145
|
var IMPORT_PLACEHOLDER = "/* __BAREFOOTJS_DOM_IMPORTS__ */";
|
|
@@ -17762,7 +17882,7 @@ function populateCsrInlinable(ctx, relocateEnv, getterAliases) {
|
|
|
17762
17882
|
propsObjectName: baseEnv.propsObjectName
|
|
17763
17883
|
});
|
|
17764
17884
|
for (const c of ctx.localConstants) {
|
|
17765
|
-
if (c.isJsx || !c.value || c.containsArrow || c.systemConstructKind || getterAliases.has(c.name)) {
|
|
17885
|
+
if (c.isJsx || !c.value || c.containsArrow || c.systemConstructKind || c.mutatedAfterDeclaration || getterAliases.has(c.name)) {
|
|
17766
17886
|
ctx.csrInlinable.set(c.name, null);
|
|
17767
17887
|
finalised.add(c.name);
|
|
17768
17888
|
}
|
|
@@ -17896,6 +18016,8 @@ function classifyConstantInitial(c, declaredNames, signalGetters, signalSetters,
|
|
|
17896
18016
|
return { status: { kind: "jsx-inline" }, decisions: [] };
|
|
17897
18017
|
if (!c.value)
|
|
17898
18018
|
return { status: { kind: "placeholder-let" }, decisions: [] };
|
|
18019
|
+
if (c.mutatedAfterDeclaration)
|
|
18020
|
+
return { status: { kind: "mutated-after-declaration" }, decisions: [] };
|
|
17899
18021
|
if (c.containsArrow)
|
|
17900
18022
|
return { status: { kind: "arrow-literal" }, decisions: [] };
|
|
17901
18023
|
if (c.systemConstructKind)
|
|
@@ -18057,7 +18179,7 @@ function emitRegistrationAndHydration(lines, ctx, _ir, graph, inlinability) {
|
|
|
18057
18179
|
const { inlinableConstants, unsafeLocalNames } = inlinability ?? buildInlinableConstants(ctx, graph, _ir.root);
|
|
18058
18180
|
const restSpreadNames = resolveRestSpreadNames(ctx);
|
|
18059
18181
|
const isFragmentRoot = _ir.root.type === "fragment" && !!_ir.root.needsScopeComment;
|
|
18060
|
-
const isCommentScope =
|
|
18182
|
+
const isCommentScope = isCommentScopedRoot(_ir.root);
|
|
18061
18183
|
const defParts = [`init: init${name}`];
|
|
18062
18184
|
if (canGenerateStaticTemplate(_ir.root, propNamesForStaticCheck, inlinableConstants, unsafeLocalNames)) {
|
|
18063
18185
|
const markupSlotIds = markupSlotIdsOf(ctx);
|
|
@@ -21836,7 +21958,7 @@ function findImpureNode(root, primableNames) {
|
|
|
21836
21958
|
found = "function or class expression";
|
|
21837
21959
|
return;
|
|
21838
21960
|
}
|
|
21839
|
-
if (ts21.isBinaryExpression(node) &&
|
|
21961
|
+
if (ts21.isBinaryExpression(node) && isAssignmentOperator3(node.operatorToken.kind)) {
|
|
21840
21962
|
found = "assignment";
|
|
21841
21963
|
return;
|
|
21842
21964
|
}
|
|
@@ -21845,7 +21967,7 @@ function findImpureNode(root, primableNames) {
|
|
|
21845
21967
|
visit3(root);
|
|
21846
21968
|
return found;
|
|
21847
21969
|
}
|
|
21848
|
-
function
|
|
21970
|
+
function isAssignmentOperator3(kind) {
|
|
21849
21971
|
return kind >= ts21.SyntaxKind.FirstAssignment && kind <= ts21.SyntaxKind.LastAssignment;
|
|
21850
21972
|
}
|
|
21851
21973
|
|
|
@@ -23227,7 +23349,7 @@ function generateInitFunction(ir, ctx, siblingComponents, localImportPrefixes) {
|
|
|
23227
23349
|
lines.push(MODULE_CONSTANTS_PLACEHOLDER);
|
|
23228
23350
|
lines.push(`export function init${name}(__scope, ${PROPS_PARAM} = {}) {`);
|
|
23229
23351
|
lines.push(` if (!__scope) return`);
|
|
23230
|
-
lines.push(` const __scopeId = __scope.getAttribute('${BF_SCOPE3}')`);
|
|
23352
|
+
lines.push(isCommentScopedRoot(ir.root) ? ` const __scopeId = ownScopeId(__scope)` : ` const __scopeId = __scope.getAttribute('${BF_SCOPE3}')`);
|
|
23231
23353
|
lines.push("");
|
|
23232
23354
|
const graph = buildReferencesGraph(ctx, ir.root);
|
|
23233
23355
|
const classification = classifyLocalDeclarations(ctx, graph);
|
|
@@ -23541,6 +23663,8 @@ function hasInitScopeOnlyConstant(ctx) {
|
|
|
23541
23663
|
continue;
|
|
23542
23664
|
if (!c.value)
|
|
23543
23665
|
continue;
|
|
23666
|
+
if (c.mutatedAfterDeclaration)
|
|
23667
|
+
return true;
|
|
23544
23668
|
if (!isInlinableInTemplate(c.value, env).ok)
|
|
23545
23669
|
return true;
|
|
23546
23670
|
}
|
|
@@ -27373,6 +27497,7 @@ function buildComponentGraph(source, filePath, componentName) {
|
|
|
27373
27497
|
signals: [],
|
|
27374
27498
|
memos: [],
|
|
27375
27499
|
effects: [],
|
|
27500
|
+
props: [],
|
|
27376
27501
|
domBindings: []
|
|
27377
27502
|
};
|
|
27378
27503
|
}
|
|
@@ -27384,6 +27509,7 @@ function buildComponentGraph(source, filePath, componentName) {
|
|
|
27384
27509
|
signals: [],
|
|
27385
27510
|
memos: [],
|
|
27386
27511
|
effects: [],
|
|
27512
|
+
props: [],
|
|
27387
27513
|
domBindings: []
|
|
27388
27514
|
};
|
|
27389
27515
|
}
|
|
@@ -27404,45 +27530,58 @@ function buildGraphFromIR(ir) {
|
|
|
27404
27530
|
const signalSetters = new Map(meta.signals.filter((s) => s.setter).map((s) => [s.setter, s.getter]));
|
|
27405
27531
|
const destructuredPropNames = new Set(meta.propsParams.map((p) => p.name).filter((n) => n !== "children"));
|
|
27406
27532
|
const propsObjectName = meta.propsObjectName;
|
|
27533
|
+
const propMemberDep = (member) => `${propsObjectName}.${member}`;
|
|
27407
27534
|
const constByName = new Map(meta.localConstants.map((c) => [c.name, c]));
|
|
27408
|
-
const
|
|
27535
|
+
const constPropDeps = new Map;
|
|
27409
27536
|
{
|
|
27410
27537
|
const onStack = new Set;
|
|
27411
|
-
const
|
|
27412
|
-
|
|
27413
|
-
|
|
27538
|
+
const propDepsOfConst = (name) => {
|
|
27539
|
+
const cached = constPropDeps.get(name);
|
|
27540
|
+
if (cached)
|
|
27541
|
+
return cached;
|
|
27414
27542
|
const c = constByName.get(name);
|
|
27415
27543
|
if (!c?.freeIdentifiers || onStack.has(name))
|
|
27416
|
-
return
|
|
27544
|
+
return [];
|
|
27417
27545
|
onStack.add(name);
|
|
27418
|
-
|
|
27546
|
+
const out = new Set;
|
|
27419
27547
|
for (const free of c.freeIdentifiers) {
|
|
27420
|
-
if (destructuredPropNames.has(free)
|
|
27421
|
-
|
|
27422
|
-
|
|
27423
|
-
|
|
27548
|
+
if (destructuredPropNames.has(free))
|
|
27549
|
+
out.add(free);
|
|
27550
|
+
for (const dep of propDepsOfConst(free))
|
|
27551
|
+
out.add(dep);
|
|
27552
|
+
}
|
|
27553
|
+
if (propsObjectName && c.value !== undefined && c.freeIdentifiers.has(propsObjectName)) {
|
|
27554
|
+
for (const member of collectPropMembers(c.value, propsObjectName))
|
|
27555
|
+
out.add(propMemberDep(member));
|
|
27424
27556
|
}
|
|
27425
27557
|
onStack.delete(name);
|
|
27426
|
-
|
|
27427
|
-
|
|
27428
|
-
return
|
|
27558
|
+
const deps = [...out];
|
|
27559
|
+
constPropDeps.set(name, deps);
|
|
27560
|
+
return deps;
|
|
27429
27561
|
};
|
|
27430
27562
|
for (const c of meta.localConstants)
|
|
27431
|
-
|
|
27563
|
+
propDepsOfConst(c.name);
|
|
27432
27564
|
}
|
|
27433
|
-
const
|
|
27565
|
+
const propDepsOf = (expr, freeIds, isShadowed) => {
|
|
27566
|
+
const out = new Set;
|
|
27567
|
+
const reads = (name) => !isShadowed?.(name) && (freeIds ? freeIds.has(name) : tokenContainsIdent(expr, name));
|
|
27434
27568
|
for (const name of destructuredPropNames) {
|
|
27435
|
-
if (
|
|
27436
|
-
|
|
27569
|
+
if (reads(name))
|
|
27570
|
+
out.add(name);
|
|
27437
27571
|
}
|
|
27438
|
-
for (const name of
|
|
27439
|
-
if (
|
|
27440
|
-
|
|
27572
|
+
for (const [name, deps] of constPropDeps) {
|
|
27573
|
+
if (deps.length > 0 && reads(name))
|
|
27574
|
+
for (const dep of deps)
|
|
27575
|
+
out.add(dep);
|
|
27576
|
+
}
|
|
27577
|
+
if (propsObjectName && !isShadowed?.(propsObjectName)) {
|
|
27578
|
+
for (const member of collectPropMembers(expr, propsObjectName))
|
|
27579
|
+
out.add(propMemberDep(member));
|
|
27441
27580
|
}
|
|
27442
|
-
return
|
|
27581
|
+
return [...out];
|
|
27443
27582
|
};
|
|
27444
27583
|
const domBindings = [];
|
|
27445
|
-
collectDomBindings(ir.root, domBindings, signalGetters, memoNames, undefined, BindingScope.EMPTY,
|
|
27584
|
+
collectDomBindings(ir.root, domBindings, signalGetters, memoNames, undefined, BindingScope.EMPTY, propDepsOf);
|
|
27446
27585
|
const signalConsumers = new Map;
|
|
27447
27586
|
for (const s of meta.signals)
|
|
27448
27587
|
signalConsumers.set(s.getter, []);
|
|
@@ -27481,6 +27620,21 @@ function buildGraphFromIR(ir) {
|
|
|
27481
27620
|
memoConsumers.get(dep)?.push(`memo:${memo.name}`);
|
|
27482
27621
|
}
|
|
27483
27622
|
}
|
|
27623
|
+
const propConsumers = new Map;
|
|
27624
|
+
for (const dom of domBindings) {
|
|
27625
|
+
if (dom.type === "event")
|
|
27626
|
+
continue;
|
|
27627
|
+
for (const dep of dom.deps) {
|
|
27628
|
+
if (signalGetters.has(dep) || memoNames.has(dep))
|
|
27629
|
+
continue;
|
|
27630
|
+
let consumers = propConsumers.get(dep);
|
|
27631
|
+
if (!consumers) {
|
|
27632
|
+
consumers = [];
|
|
27633
|
+
propConsumers.set(dep, consumers);
|
|
27634
|
+
}
|
|
27635
|
+
consumers.push(`dom:${dom.label}`);
|
|
27636
|
+
}
|
|
27637
|
+
}
|
|
27484
27638
|
const signals = meta.signals.map((s) => ({
|
|
27485
27639
|
kind: "signal",
|
|
27486
27640
|
name: s.getter,
|
|
@@ -27504,12 +27658,18 @@ function buildGraphFromIR(ir) {
|
|
|
27504
27658
|
body: e.body,
|
|
27505
27659
|
loc: { file: e.loc.file, line: e.loc.start.line }
|
|
27506
27660
|
}));
|
|
27661
|
+
const props = [...propConsumers].map(([name, consumers]) => ({
|
|
27662
|
+
kind: "prop",
|
|
27663
|
+
name,
|
|
27664
|
+
consumers
|
|
27665
|
+
}));
|
|
27507
27666
|
return {
|
|
27508
27667
|
componentName: meta.componentName,
|
|
27509
27668
|
sourceFile: findSourceFile2(meta) ?? "",
|
|
27510
27669
|
signals,
|
|
27511
27670
|
memos,
|
|
27512
27671
|
effects,
|
|
27672
|
+
props,
|
|
27513
27673
|
domBindings
|
|
27514
27674
|
};
|
|
27515
27675
|
}
|
|
@@ -28005,13 +28165,18 @@ function formatLoopSummary(summary) {
|
|
|
28005
28165
|
}
|
|
28006
28166
|
function traceUpdatePath(graph, targetName) {
|
|
28007
28167
|
const signal = graph.signals.find((s) => s.name === targetName);
|
|
28168
|
+
if (signal)
|
|
28169
|
+
return { target: targetName, kind: "signal", dependents: traceConsumers(signal.consumers, graph) };
|
|
28008
28170
|
const memo = graph.memos.find((m) => m.name === targetName);
|
|
28009
|
-
if (
|
|
28010
|
-
return
|
|
28011
|
-
const
|
|
28012
|
-
|
|
28013
|
-
|
|
28014
|
-
return
|
|
28171
|
+
if (memo)
|
|
28172
|
+
return { target: targetName, kind: "memo", dependents: traceConsumers(memo.consumers, graph) };
|
|
28173
|
+
const prop = graph.props.find((p) => p.name === targetName);
|
|
28174
|
+
if (prop)
|
|
28175
|
+
return { target: targetName, kind: "prop", dependents: traceConsumers(prop.consumers, graph) };
|
|
28176
|
+
return null;
|
|
28177
|
+
}
|
|
28178
|
+
function traceConsumers(consumers, graph) {
|
|
28179
|
+
return consumers.map((consumer) => buildUpdateEntry(consumer, graph, new Set));
|
|
28015
28180
|
}
|
|
28016
28181
|
function buildUpdateEntry(consumer, graph, visited) {
|
|
28017
28182
|
if (visited.has(consumer)) {
|
|
@@ -28090,6 +28255,10 @@ function buildWhyUpdate(source, filePath, bindingLabel, componentName) {
|
|
|
28090
28255
|
deps.push({ name, kind: "memo", dependsOn: memo.deps, changedBy: [] });
|
|
28091
28256
|
for (const dep of memo.deps)
|
|
28092
28257
|
traceDep(dep);
|
|
28258
|
+
return;
|
|
28259
|
+
}
|
|
28260
|
+
if (graph.props.some((p) => p.name === name)) {
|
|
28261
|
+
deps.push({ name, kind: "prop", dependsOn: [], changedBy: [] });
|
|
28093
28262
|
}
|
|
28094
28263
|
}
|
|
28095
28264
|
for (const dep of binding.deps)
|
|
@@ -28120,6 +28289,9 @@ function formatWhyUpdate(result) {
|
|
|
28120
28289
|
lines.push(`${dep.name} depends on:`);
|
|
28121
28290
|
for (const d of dep.dependsOn)
|
|
28122
28291
|
lines.push(` ${d}`);
|
|
28292
|
+
} else if (dep.kind === "prop") {
|
|
28293
|
+
lines.push(`${dep.name} changes from:`);
|
|
28294
|
+
lines.push(" (prop — the parent component passes a new value)");
|
|
28123
28295
|
} else {
|
|
28124
28296
|
lines.push(`${dep.name} changes from:`);
|
|
28125
28297
|
if (dep.changedBy.length === 0) {
|
|
@@ -28157,6 +28329,12 @@ function formatComponentGraph(graph) {
|
|
|
28157
28329
|
lines.push(` ${e.label}${depStr}`);
|
|
28158
28330
|
}
|
|
28159
28331
|
}
|
|
28332
|
+
if (graph.props.length > 0) {
|
|
28333
|
+
lines.push(` props:`);
|
|
28334
|
+
for (const p of graph.props) {
|
|
28335
|
+
lines.push(` ${p.name}`);
|
|
28336
|
+
}
|
|
28337
|
+
}
|
|
28160
28338
|
if (graph.domBindings.length > 0) {
|
|
28161
28339
|
lines.push(` dom bindings:`);
|
|
28162
28340
|
for (const d of graph.domBindings) {
|
|
@@ -28184,7 +28362,7 @@ function formatComponentGraph(graph) {
|
|
|
28184
28362
|
}
|
|
28185
28363
|
}
|
|
28186
28364
|
}
|
|
28187
|
-
if (graph.signals.length > 0 || graph.memos.length > 0) {
|
|
28365
|
+
if (graph.signals.length > 0 || graph.memos.length > 0 || graph.props.length > 0) {
|
|
28188
28366
|
lines.push(` dependency graph:`);
|
|
28189
28367
|
for (const s of graph.signals) {
|
|
28190
28368
|
for (const consumer of s.consumers) {
|
|
@@ -28196,6 +28374,11 @@ function formatComponentGraph(graph) {
|
|
|
28196
28374
|
lines.push(` ${m.name} -> ${consumer}`);
|
|
28197
28375
|
}
|
|
28198
28376
|
}
|
|
28377
|
+
for (const p of graph.props) {
|
|
28378
|
+
for (const consumer of p.consumers) {
|
|
28379
|
+
lines.push(` ${p.name} -> ${consumer}`);
|
|
28380
|
+
}
|
|
28381
|
+
}
|
|
28199
28382
|
}
|
|
28200
28383
|
return lines.join(`
|
|
28201
28384
|
`);
|
|
@@ -28246,6 +28429,10 @@ function graphToJSON(graph) {
|
|
|
28246
28429
|
body: e.body,
|
|
28247
28430
|
loc: e.loc
|
|
28248
28431
|
})),
|
|
28432
|
+
props: graph.props.map((p) => ({
|
|
28433
|
+
name: p.name,
|
|
28434
|
+
consumers: p.consumers
|
|
28435
|
+
})),
|
|
28249
28436
|
domBindings: graph.domBindings.map((d) => ({
|
|
28250
28437
|
label: d.label,
|
|
28251
28438
|
slotId: d.slotId,
|
|
@@ -28468,8 +28655,9 @@ function inferWrapReasonForAttrLike(hasStringReactive, hasPropsRef, flags) {
|
|
|
28468
28655
|
const decision = decideWrapFromAstFlags(flags);
|
|
28469
28656
|
return decision.wrap ? decision.reason : undefined;
|
|
28470
28657
|
}
|
|
28471
|
-
function collectDomBindings(node, bindings, signalGetters, memoNames, parentTag, scope = BindingScope.EMPTY,
|
|
28658
|
+
function collectDomBindings(node, bindings, signalGetters, memoNames, parentTag, scope = BindingScope.EMPTY, propDepsOf = () => []) {
|
|
28472
28659
|
const boundNames = scope.valueBoundNames();
|
|
28660
|
+
const isShadowed = scope.asShadowPredicate();
|
|
28473
28661
|
const setSomeIn = (names, other) => {
|
|
28474
28662
|
for (const n of names)
|
|
28475
28663
|
if (other.has(n))
|
|
@@ -28478,6 +28666,7 @@ function collectDomBindings(node, bindings, signalGetters, memoNames, parentTag,
|
|
|
28478
28666
|
};
|
|
28479
28667
|
const exprReadsLoopParam = (n) => boundNames.size > 0 && (n.origin?.freeRefs?.some((r) => boundNames.has(r.name)) ?? false);
|
|
28480
28668
|
const attrReadsLoopParam = (free) => boundNames.size > 0 && free !== undefined && setSomeIn(boundNames, free);
|
|
28669
|
+
const freeIdsOf = (origin) => origin?.freeRefs ? new Set(origin.freeRefs.map((r) => r.name)) : undefined;
|
|
28481
28670
|
switch (node.type) {
|
|
28482
28671
|
case "element": {
|
|
28483
28672
|
for (const attr of node.attrs) {
|
|
@@ -28488,16 +28677,17 @@ function collectDomBindings(node, bindings, signalGetters, memoNames, parentTag,
|
|
|
28488
28677
|
const expr = attrValueToString2(attr.value);
|
|
28489
28678
|
if (!expr)
|
|
28490
28679
|
continue;
|
|
28491
|
-
const
|
|
28492
|
-
const isReactive =
|
|
28493
|
-
const
|
|
28680
|
+
const signalDeps = extractReactiveDeps(expr, signalGetters, memoNames);
|
|
28681
|
+
const isReactive = signalDeps.length > 0 || attrReadsLoopParam(attr.freeIdentifiers);
|
|
28682
|
+
const propDeps = propDepsOf(expr, attr.freeIdentifiers, isShadowed);
|
|
28683
|
+
const hasPropsRef = propDeps.length > 0;
|
|
28494
28684
|
const wrapReason = inferWrapReasonForAttrLike(isReactive, hasPropsRef, attr);
|
|
28495
28685
|
if (wrapReason) {
|
|
28496
28686
|
bindings.push({
|
|
28497
28687
|
kind: "dom",
|
|
28498
28688
|
label: attr.name,
|
|
28499
28689
|
slotId: node.slotId ?? "?",
|
|
28500
|
-
deps,
|
|
28690
|
+
deps: [...signalDeps, ...propDeps],
|
|
28501
28691
|
type: "attribute",
|
|
28502
28692
|
classification: isReactive || hasPropsRef ? "reactive" : "fallback",
|
|
28503
28693
|
expression: expr,
|
|
@@ -28520,7 +28710,7 @@ function collectDomBindings(node, bindings, signalGetters, memoNames, parentTag,
|
|
|
28520
28710
|
});
|
|
28521
28711
|
}
|
|
28522
28712
|
for (const child of node.children) {
|
|
28523
|
-
collectDomBindings(child, bindings, signalGetters, memoNames, node.tag, scope,
|
|
28713
|
+
collectDomBindings(child, bindings, signalGetters, memoNames, node.tag, scope, propDepsOf);
|
|
28524
28714
|
}
|
|
28525
28715
|
break;
|
|
28526
28716
|
}
|
|
@@ -28528,7 +28718,10 @@ function collectDomBindings(node, bindings, signalGetters, memoNames, parentTag,
|
|
|
28528
28718
|
const decision = decideWrapFromAstFlags(node);
|
|
28529
28719
|
const loopReactive = exprReadsLoopParam(node);
|
|
28530
28720
|
if ((decision.wrap || loopReactive) && node.slotId) {
|
|
28531
|
-
const deps =
|
|
28721
|
+
const deps = [
|
|
28722
|
+
...extractReactiveDeps(node.expr, signalGetters, memoNames),
|
|
28723
|
+
...propDepsOf(node.expr, freeIdsOf(node.origin), isShadowed)
|
|
28724
|
+
];
|
|
28532
28725
|
const preview = parentTag ? `<${parentTag}>{${truncateExpr(node.expr)}}</${parentTag}>` : `{${truncateExpr(node.expr)}}`;
|
|
28533
28726
|
bindings.push({
|
|
28534
28727
|
kind: "dom",
|
|
@@ -28549,7 +28742,10 @@ function collectDomBindings(node, bindings, signalGetters, memoNames, parentTag,
|
|
|
28549
28742
|
const decision = decideWrapFromAstFlags(node);
|
|
28550
28743
|
const loopReactive = boundNames.size > 0 && (node.origin?.freeRefs?.some((r) => boundNames.has(r.name)) ?? false);
|
|
28551
28744
|
if ((decision.wrap || loopReactive) && node.slotId) {
|
|
28552
|
-
const deps =
|
|
28745
|
+
const deps = [
|
|
28746
|
+
...extractReactiveDeps(node.condition, signalGetters, memoNames),
|
|
28747
|
+
...propDepsOf(node.condition, freeIdsOf(node.origin), isShadowed)
|
|
28748
|
+
];
|
|
28553
28749
|
bindings.push({
|
|
28554
28750
|
kind: "dom",
|
|
28555
28751
|
label: `conditional "${node.slotId}"`,
|
|
@@ -28563,8 +28759,8 @@ function collectDomBindings(node, bindings, signalGetters, memoNames, parentTag,
|
|
|
28563
28759
|
jsxPreview: `{${truncateExpr(node.condition)} ? ... : ...}`
|
|
28564
28760
|
});
|
|
28565
28761
|
}
|
|
28566
|
-
collectDomBindings(node.whenTrue, bindings, signalGetters, memoNames, parentTag, scope,
|
|
28567
|
-
collectDomBindings(node.whenFalse, bindings, signalGetters, memoNames, parentTag, scope,
|
|
28762
|
+
collectDomBindings(node.whenTrue, bindings, signalGetters, memoNames, parentTag, scope, propDepsOf);
|
|
28763
|
+
collectDomBindings(node.whenFalse, bindings, signalGetters, memoNames, parentTag, scope, propDepsOf);
|
|
28568
28764
|
break;
|
|
28569
28765
|
}
|
|
28570
28766
|
case "loop": {
|
|
@@ -28591,7 +28787,7 @@ function collectDomBindings(node, bindings, signalGetters, memoNames, parentTag,
|
|
|
28591
28787
|
}
|
|
28592
28788
|
const childScope = scope.enterLoopRow(node);
|
|
28593
28789
|
for (const child of node.children) {
|
|
28594
|
-
collectDomBindings(child, bindings, signalGetters, memoNames, parentTag, childScope,
|
|
28790
|
+
collectDomBindings(child, bindings, signalGetters, memoNames, parentTag, childScope, propDepsOf);
|
|
28595
28791
|
}
|
|
28596
28792
|
break;
|
|
28597
28793
|
}
|
|
@@ -28604,16 +28800,17 @@ function collectDomBindings(node, bindings, signalGetters, memoNames, parentTag,
|
|
|
28604
28800
|
const propValue = attrValueToString2(prop.value) ?? "";
|
|
28605
28801
|
if (!propValue)
|
|
28606
28802
|
continue;
|
|
28607
|
-
const
|
|
28608
|
-
const
|
|
28609
|
-
const
|
|
28610
|
-
const
|
|
28803
|
+
const signalDeps = extractReactiveDeps(propValue, signalGetters, memoNames);
|
|
28804
|
+
const propDeps = propDepsOf(propValue, prop.freeIdentifiers, isShadowed);
|
|
28805
|
+
const hasPropsRef = propDeps.length > 0;
|
|
28806
|
+
const isReactive = signalDeps.length > 0 || hasPropsRef;
|
|
28807
|
+
const wrapReason = inferWrapReasonForAttrLike(signalDeps.length > 0, hasPropsRef, prop);
|
|
28611
28808
|
if (wrapReason) {
|
|
28612
28809
|
bindings.push({
|
|
28613
28810
|
kind: "dom",
|
|
28614
28811
|
label: `${node.name}.${prop.name}`,
|
|
28615
28812
|
slotId: node.slotId ?? "?",
|
|
28616
|
-
deps,
|
|
28813
|
+
deps: [...signalDeps, ...propDeps],
|
|
28617
28814
|
type: "attribute",
|
|
28618
28815
|
classification: isReactive ? "reactive" : "fallback",
|
|
28619
28816
|
expression: propValue,
|
|
@@ -28624,21 +28821,21 @@ function collectDomBindings(node, bindings, signalGetters, memoNames, parentTag,
|
|
|
28624
28821
|
}
|
|
28625
28822
|
}
|
|
28626
28823
|
for (const child of node.children) {
|
|
28627
|
-
collectDomBindings(child, bindings, signalGetters, memoNames, parentTag, scope,
|
|
28824
|
+
collectDomBindings(child, bindings, signalGetters, memoNames, parentTag, scope, propDepsOf);
|
|
28628
28825
|
}
|
|
28629
28826
|
break;
|
|
28630
28827
|
}
|
|
28631
28828
|
case "fragment":
|
|
28632
28829
|
case "provider": {
|
|
28633
28830
|
for (const child of node.children) {
|
|
28634
|
-
collectDomBindings(child, bindings, signalGetters, memoNames, parentTag, scope,
|
|
28831
|
+
collectDomBindings(child, bindings, signalGetters, memoNames, parentTag, scope, propDepsOf);
|
|
28635
28832
|
}
|
|
28636
28833
|
break;
|
|
28637
28834
|
}
|
|
28638
28835
|
case "if-statement": {
|
|
28639
|
-
collectDomBindings(node.consequent, bindings, signalGetters, memoNames, parentTag, scope,
|
|
28836
|
+
collectDomBindings(node.consequent, bindings, signalGetters, memoNames, parentTag, scope, propDepsOf);
|
|
28640
28837
|
if (node.alternate) {
|
|
28641
|
-
collectDomBindings(node.alternate, bindings, signalGetters, memoNames, parentTag, scope,
|
|
28838
|
+
collectDomBindings(node.alternate, bindings, signalGetters, memoNames, parentTag, scope, propDepsOf);
|
|
28642
28839
|
}
|
|
28643
28840
|
break;
|
|
28644
28841
|
}
|
|
@@ -28648,25 +28845,22 @@ function truncateExpr(expr, max = 40) {
|
|
|
28648
28845
|
const s = expr.replace(/\s+/g, " ").trim();
|
|
28649
28846
|
return s.length > max ? s.slice(0, max - 1) + "…" : s;
|
|
28650
28847
|
}
|
|
28651
|
-
function
|
|
28848
|
+
function collectPropMembers(expr, propsObjectName) {
|
|
28652
28849
|
let sf;
|
|
28653
28850
|
try {
|
|
28654
28851
|
sf = ts29.createSourceFile("__attr.tsx", `(${expr})`, ts29.ScriptTarget.Latest, true, ts29.ScriptKind.TSX);
|
|
28655
28852
|
} catch {
|
|
28656
|
-
return
|
|
28853
|
+
return [];
|
|
28657
28854
|
}
|
|
28658
|
-
|
|
28855
|
+
const members = new Set;
|
|
28659
28856
|
const visit3 = (n) => {
|
|
28660
|
-
if (found)
|
|
28661
|
-
return;
|
|
28662
28857
|
if (ts29.isPropertyAccessExpression(n) && ts29.isIdentifier(n.expression) && n.expression.text === propsObjectName && n.name.text !== "children") {
|
|
28663
|
-
|
|
28664
|
-
return;
|
|
28858
|
+
members.add(n.name.text);
|
|
28665
28859
|
}
|
|
28666
28860
|
ts29.forEachChild(n, visit3);
|
|
28667
28861
|
};
|
|
28668
28862
|
visit3(sf);
|
|
28669
|
-
return
|
|
28863
|
+
return [...members];
|
|
28670
28864
|
}
|
|
28671
28865
|
function attrValueToString2(value) {
|
|
28672
28866
|
switch (value.kind) {
|