@barefootjs/jsx 0.41.2 → 0.41.3
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/caller-value-reach.d.ts +57 -0
- package/dist/caller-value-reach.d.ts.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +877 -561
- package/dist/jsx-to-ir.d.ts.map +1 -1
- package/dist/static-literal.d.ts +21 -1
- package/dist/static-literal.d.ts.map +1 -1
- package/dist/types.d.ts +18 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/loop-branch-bare-expression-reactive-text.test.ts +212 -56
- package/src/__tests__/nested-loop-conditional.test.ts +16 -16
- package/src/__tests__/static-literal.test.ts +47 -2
- package/src/caller-value-reach.ts +436 -0
- package/src/index.ts +1 -1
- package/src/ir-to-client-js/collect-elements.ts +25 -46
- package/src/jsx-to-ir.ts +17 -0
- package/src/static-literal.ts +55 -1
- package/src/types.ts +18 -1
package/dist/index.js
CHANGED
|
@@ -205,7 +205,7 @@ function findTopLevelTemplateLiterals(code) {
|
|
|
205
205
|
}
|
|
206
206
|
|
|
207
207
|
// src/compiler.ts
|
|
208
|
-
import
|
|
208
|
+
import ts34 from "typescript";
|
|
209
209
|
|
|
210
210
|
// src/analyzer.ts
|
|
211
211
|
import ts24 from "typescript";
|
|
@@ -15031,7 +15031,7 @@ function validateObjectFactoryDestructure(ctx, pattern, callee, loc) {
|
|
|
15031
15031
|
}
|
|
15032
15032
|
|
|
15033
15033
|
// src/jsx-to-ir.ts
|
|
15034
|
-
import
|
|
15034
|
+
import ts29 from "typescript";
|
|
15035
15035
|
|
|
15036
15036
|
// src/children-nullish.ts
|
|
15037
15037
|
function fallbackChainParts(parsed, op) {
|
|
@@ -15131,6 +15131,38 @@ function evaluateStaticLiteral(expr, bindings) {
|
|
|
15131
15131
|
return null;
|
|
15132
15132
|
}
|
|
15133
15133
|
}
|
|
15134
|
+
function foldStaticBindings(expr, bindings) {
|
|
15135
|
+
if (bindings.size === 0)
|
|
15136
|
+
return expr;
|
|
15137
|
+
const folded = mapParsedExpr(expr, (e, enclosing) => {
|
|
15138
|
+
if (e.kind === "literal" || e.kind === "unsupported" || e.kind === "template-literal")
|
|
15139
|
+
return null;
|
|
15140
|
+
const visible = new Map([...bindings].filter(([name]) => !enclosing.has(name)));
|
|
15141
|
+
const free = freeIdentifiers(e);
|
|
15142
|
+
if (free === null || ![...free].some((name) => visible.has(name)))
|
|
15143
|
+
return null;
|
|
15144
|
+
const resolved = evaluateStaticLiteral(e, visible);
|
|
15145
|
+
return resolved === null ? null : scalarToLiteral(resolved.value);
|
|
15146
|
+
});
|
|
15147
|
+
const remaining = freeIdentifiers(folded);
|
|
15148
|
+
if (remaining === null || [...remaining].some((name) => bindings.has(name)))
|
|
15149
|
+
return null;
|
|
15150
|
+
return folded;
|
|
15151
|
+
}
|
|
15152
|
+
function scalarToLiteral(value) {
|
|
15153
|
+
if (value === null)
|
|
15154
|
+
return { kind: "literal", value: null, literalType: "null" };
|
|
15155
|
+
switch (typeof value) {
|
|
15156
|
+
case "string":
|
|
15157
|
+
return { kind: "literal", value, literalType: "string" };
|
|
15158
|
+
case "boolean":
|
|
15159
|
+
return { kind: "literal", value, literalType: "boolean" };
|
|
15160
|
+
case "number":
|
|
15161
|
+
return Number.isFinite(value) ? { kind: "literal", value, literalType: "number" } : null;
|
|
15162
|
+
default:
|
|
15163
|
+
return null;
|
|
15164
|
+
}
|
|
15165
|
+
}
|
|
15134
15166
|
function isFullyStaticLiteral(expr) {
|
|
15135
15167
|
return evaluateStaticLiteral(expr) !== null;
|
|
15136
15168
|
}
|
|
@@ -16907,6 +16939,278 @@ var toLocaleDatePlugin = {
|
|
|
16907
16939
|
// src/jsx-to-ir.ts
|
|
16908
16940
|
import { toHTMLAttrName, decodeEntities, BF_KEY as BF_KEY2, keyAttrName as keyAttrName2 } from "@barefootjs/shared";
|
|
16909
16941
|
|
|
16942
|
+
// src/caller-value-reach.ts
|
|
16943
|
+
import ts28 from "typescript";
|
|
16944
|
+
function hasCompleteMembers(source) {
|
|
16945
|
+
const file = ts28.createSourceFile("__members__.ts", source, ts28.ScriptTarget.Latest, false);
|
|
16946
|
+
const declaration = file.statements[0];
|
|
16947
|
+
if (!declaration || file.statements.length !== 1)
|
|
16948
|
+
return false;
|
|
16949
|
+
let members;
|
|
16950
|
+
if (ts28.isInterfaceDeclaration(declaration)) {
|
|
16951
|
+
if (declaration.heritageClauses?.length || declaration.typeParameters?.length)
|
|
16952
|
+
return false;
|
|
16953
|
+
members = declaration.members;
|
|
16954
|
+
} else if (ts28.isTypeAliasDeclaration(declaration) && ts28.isTypeLiteralNode(declaration.type)) {
|
|
16955
|
+
if (declaration.typeParameters?.length)
|
|
16956
|
+
return false;
|
|
16957
|
+
members = declaration.type.members;
|
|
16958
|
+
} else {
|
|
16959
|
+
return false;
|
|
16960
|
+
}
|
|
16961
|
+
return members.every(ts28.isPropertySignature);
|
|
16962
|
+
}
|
|
16963
|
+
function isDataOnlyType(type, analyzer, seen = new Set) {
|
|
16964
|
+
if (!type)
|
|
16965
|
+
return false;
|
|
16966
|
+
switch (type.kind) {
|
|
16967
|
+
case "primitive":
|
|
16968
|
+
return true;
|
|
16969
|
+
case "union":
|
|
16970
|
+
return (type.unionTypes ?? []).length > 0 && (type.unionTypes ?? []).every((t) => isDataOnlyType(t, analyzer, seen));
|
|
16971
|
+
case "array":
|
|
16972
|
+
return isDataOnlyType(type.elementType, analyzer, seen);
|
|
16973
|
+
case "function":
|
|
16974
|
+
return isDataOnlyType(type.returnType, analyzer, seen);
|
|
16975
|
+
case "object":
|
|
16976
|
+
return type.properties !== undefined && hasCompleteMembers(`type T = ${type.raw}`) && type.properties.every((p) => isDataOnlyType(p.type, analyzer, seen));
|
|
16977
|
+
case "interface": {
|
|
16978
|
+
if (seen.has(type.raw))
|
|
16979
|
+
return true;
|
|
16980
|
+
const named = analyzer.typeDefinitions.filter((d) => d.name === type.raw);
|
|
16981
|
+
const definition = named.length === 1 ? named[0] : undefined;
|
|
16982
|
+
if (!definition?.properties || !hasCompleteMembers(definition.definition))
|
|
16983
|
+
return false;
|
|
16984
|
+
const next = new Set(seen).add(type.raw);
|
|
16985
|
+
return definition.properties.every((p) => isDataOnlyType(p.type, analyzer, next));
|
|
16986
|
+
}
|
|
16987
|
+
case "unknown":
|
|
16988
|
+
return false;
|
|
16989
|
+
}
|
|
16990
|
+
}
|
|
16991
|
+
var reachCache = new WeakMap;
|
|
16992
|
+
function collectBindingNames2(name, out) {
|
|
16993
|
+
if (ts28.isIdentifier(name)) {
|
|
16994
|
+
out.push(name.text);
|
|
16995
|
+
return;
|
|
16996
|
+
}
|
|
16997
|
+
for (const element of name.elements) {
|
|
16998
|
+
if (!ts28.isOmittedExpression(element))
|
|
16999
|
+
collectBindingNames2(element.name, out);
|
|
17000
|
+
}
|
|
17001
|
+
}
|
|
17002
|
+
function isFunctionLike(node) {
|
|
17003
|
+
return ts28.isArrowFunction(node) || ts28.isFunctionExpression(node) || ts28.isFunctionDeclaration(node) || ts28.isMethodDeclaration(node) || ts28.isGetAccessorDeclaration(node) || ts28.isSetAccessorDeclaration(node) || ts28.isConstructorDeclaration(node);
|
|
17004
|
+
}
|
|
17005
|
+
function componentFunction(analyzer) {
|
|
17006
|
+
let node = analyzer.componentBodyBlock ?? analyzer.jsxReturn ?? undefined;
|
|
17007
|
+
while (node && !isFunctionLike(node))
|
|
17008
|
+
node = node.parent;
|
|
17009
|
+
return node ?? null;
|
|
17010
|
+
}
|
|
17011
|
+
function propTypeOf(key, byLocalName, analyzer) {
|
|
17012
|
+
const param = byLocalName ? analyzer.propsParams.find((p) => p.name === key && !p.isRest) : analyzer.propsParams.find((p) => (p.sourceName ?? p.name) === key && !p.isRest);
|
|
17013
|
+
return param?.declaredType ?? param?.type;
|
|
17014
|
+
}
|
|
17015
|
+
function readPropName(propsIdentifier) {
|
|
17016
|
+
let inner = propsIdentifier;
|
|
17017
|
+
let parent = inner.parent;
|
|
17018
|
+
while (parent && (ts28.isParenthesizedExpression(parent) || ts28.isNonNullExpression(parent) || ts28.isAsExpression(parent) || ts28.isSatisfiesExpression(parent))) {
|
|
17019
|
+
inner = parent;
|
|
17020
|
+
parent = parent.parent;
|
|
17021
|
+
}
|
|
17022
|
+
if (!parent)
|
|
17023
|
+
return null;
|
|
17024
|
+
if (ts28.isPropertyAccessExpression(parent) && parent.expression === inner)
|
|
17025
|
+
return parent.name.text;
|
|
17026
|
+
if (ts28.isElementAccessExpression(parent) && parent.expression === inner && ts28.isStringLiteralLike(parent.argumentExpression)) {
|
|
17027
|
+
return parent.argumentExpression.text;
|
|
17028
|
+
}
|
|
17029
|
+
return null;
|
|
17030
|
+
}
|
|
17031
|
+
function readsUnsafeName(node, reach, analyzer, resolveOuter) {
|
|
17032
|
+
const visit3 = (n, bound) => {
|
|
17033
|
+
if (ts28.isTypeNode(n))
|
|
17034
|
+
return false;
|
|
17035
|
+
if (ts28.isIdentifier(n)) {
|
|
17036
|
+
if (!isValueReferenceIdentifier(n) || bound.has(n.text))
|
|
17037
|
+
return false;
|
|
17038
|
+
const outer = resolveOuter(n.text);
|
|
17039
|
+
if (outer !== undefined)
|
|
17040
|
+
return outer;
|
|
17041
|
+
if (reach.propsObjects.has(n.text)) {
|
|
17042
|
+
const prop = readPropName(n);
|
|
17043
|
+
return prop === null || !isDataOnlyType(propTypeOf(prop, false, analyzer), analyzer);
|
|
17044
|
+
}
|
|
17045
|
+
return reach.unsafe.has(n.text);
|
|
17046
|
+
}
|
|
17047
|
+
let inner = bound;
|
|
17048
|
+
if (isFunctionLike(n) && n.parameters.length > 0) {
|
|
17049
|
+
const params = [];
|
|
17050
|
+
for (const p of n.parameters)
|
|
17051
|
+
collectBindingNames2(p.name, params);
|
|
17052
|
+
inner = new Set([...bound, ...params]);
|
|
17053
|
+
}
|
|
17054
|
+
return ts28.forEachChild(n, (child) => visit3(child, inner) || undefined) === true;
|
|
17055
|
+
};
|
|
17056
|
+
return visit3(node, new Set);
|
|
17057
|
+
}
|
|
17058
|
+
function collectStatementDeclarations(statement, declarations, functions, otherNames) {
|
|
17059
|
+
if (ts28.isFunctionDeclaration(statement)) {
|
|
17060
|
+
if (statement.name)
|
|
17061
|
+
functions.push(statement);
|
|
17062
|
+
return;
|
|
17063
|
+
}
|
|
17064
|
+
if (ts28.isClassDeclaration(statement)) {
|
|
17065
|
+
if (statement.name)
|
|
17066
|
+
otherNames.push(statement.name.text);
|
|
17067
|
+
return;
|
|
17068
|
+
}
|
|
17069
|
+
if (ts28.isVariableDeclaration(statement)) {
|
|
17070
|
+
declarations.push(statement);
|
|
17071
|
+
return;
|
|
17072
|
+
}
|
|
17073
|
+
if (ts28.isExpression(statement) || isFunctionLike(statement))
|
|
17074
|
+
return;
|
|
17075
|
+
ts28.forEachChild(statement, (child) => collectStatementDeclarations(child, declarations, functions, otherNames));
|
|
17076
|
+
}
|
|
17077
|
+
function classifyParameters(fn, analyzer, propsObjects, unsafe) {
|
|
17078
|
+
fn.parameters.forEach((param, index) => {
|
|
17079
|
+
if (index === 0 && ts28.isIdentifier(param.name)) {
|
|
17080
|
+
propsObjects.add(param.name.text);
|
|
17081
|
+
return;
|
|
17082
|
+
}
|
|
17083
|
+
if (index === 0 && ts28.isObjectBindingPattern(param.name)) {
|
|
17084
|
+
classifyPropsPattern(param.name, true, analyzer, unsafe, []);
|
|
17085
|
+
return;
|
|
17086
|
+
}
|
|
17087
|
+
const names = [];
|
|
17088
|
+
collectBindingNames2(param.name, names);
|
|
17089
|
+
for (const name of names)
|
|
17090
|
+
unsafe.add(name);
|
|
17091
|
+
});
|
|
17092
|
+
}
|
|
17093
|
+
function classifyPropsPattern(pattern, isParameter, analyzer, unsafe, pending) {
|
|
17094
|
+
for (const element of pattern.elements) {
|
|
17095
|
+
const names = [];
|
|
17096
|
+
collectBindingNames2(element.name, names);
|
|
17097
|
+
const key = element.propertyName ?? element.name;
|
|
17098
|
+
const plain = !element.dotDotDotToken && ts28.isIdentifier(element.name) && (ts28.isIdentifier(key) || ts28.isStringLiteralLike(key));
|
|
17099
|
+
const type = plain ? isParameter ? propTypeOf(element.name.text, true, analyzer) : propTypeOf(key.text, false, analyzer) : undefined;
|
|
17100
|
+
if (!plain || !isDataOnlyType(type, analyzer)) {
|
|
17101
|
+
for (const name of names)
|
|
17102
|
+
unsafe.add(name);
|
|
17103
|
+
} else if (element.initializer) {
|
|
17104
|
+
pending.push({ names, reads: element.initializer });
|
|
17105
|
+
}
|
|
17106
|
+
}
|
|
17107
|
+
}
|
|
17108
|
+
function declaredNames(declaration) {
|
|
17109
|
+
const names = [];
|
|
17110
|
+
collectBindingNames2(declaration.name, names);
|
|
17111
|
+
return names;
|
|
17112
|
+
}
|
|
17113
|
+
function analysableConsts(declarations, analyzer, unsafe) {
|
|
17114
|
+
const mutated = new Set(analyzer.localConstants.filter((c) => c.mutatedAfterDeclaration).map((c) => c.name));
|
|
17115
|
+
const consts = [];
|
|
17116
|
+
for (const declaration of declarations) {
|
|
17117
|
+
const names = declaredNames(declaration);
|
|
17118
|
+
const isConst = ts28.isVariableDeclarationList(declaration.parent) && (declaration.parent.flags & ts28.NodeFlags.Const) !== 0;
|
|
17119
|
+
if (isConst && declaration.initializer && !names.some((n) => mutated.has(n))) {
|
|
17120
|
+
consts.push(declaration);
|
|
17121
|
+
} else {
|
|
17122
|
+
for (const name of names)
|
|
17123
|
+
unsafe.add(name);
|
|
17124
|
+
}
|
|
17125
|
+
}
|
|
17126
|
+
return consts;
|
|
17127
|
+
}
|
|
17128
|
+
function isPropsObjectValue(init, propsObjects) {
|
|
17129
|
+
const value = unwrapJsxTransparent(init);
|
|
17130
|
+
return ts28.isIdentifier(value) && propsObjects.has(value.text);
|
|
17131
|
+
}
|
|
17132
|
+
function takePropsAliases(consts, propsObjects) {
|
|
17133
|
+
let rest = [...consts];
|
|
17134
|
+
for (let grew = true;grew; ) {
|
|
17135
|
+
grew = false;
|
|
17136
|
+
const next = [];
|
|
17137
|
+
for (const declaration of rest) {
|
|
17138
|
+
if (ts28.isIdentifier(declaration.name) && isPropsObjectValue(declaration.initializer, propsObjects)) {
|
|
17139
|
+
propsObjects.add(declaration.name.text);
|
|
17140
|
+
grew = true;
|
|
17141
|
+
} else {
|
|
17142
|
+
next.push(declaration);
|
|
17143
|
+
}
|
|
17144
|
+
}
|
|
17145
|
+
rest = next;
|
|
17146
|
+
}
|
|
17147
|
+
return rest;
|
|
17148
|
+
}
|
|
17149
|
+
function settleDeclarations(pending, reach, analyzer) {
|
|
17150
|
+
let open = [...pending];
|
|
17151
|
+
for (let changed = true;changed; ) {
|
|
17152
|
+
changed = false;
|
|
17153
|
+
const still = [];
|
|
17154
|
+
for (const declaration of open) {
|
|
17155
|
+
if (readsUnsafeName(declaration.reads, reach, analyzer, () => {
|
|
17156
|
+
return;
|
|
17157
|
+
})) {
|
|
17158
|
+
for (const name of declaration.names)
|
|
17159
|
+
reach.unsafe.add(name);
|
|
17160
|
+
changed = true;
|
|
17161
|
+
} else {
|
|
17162
|
+
still.push(declaration);
|
|
17163
|
+
}
|
|
17164
|
+
}
|
|
17165
|
+
open = still;
|
|
17166
|
+
}
|
|
17167
|
+
}
|
|
17168
|
+
function buildCallerReach(analyzer) {
|
|
17169
|
+
const fn = componentFunction(analyzer);
|
|
17170
|
+
if (!fn)
|
|
17171
|
+
return null;
|
|
17172
|
+
const propsObjects = new Set;
|
|
17173
|
+
const unsafe = new Set;
|
|
17174
|
+
const pending = [];
|
|
17175
|
+
classifyParameters(fn, analyzer, propsObjects, unsafe);
|
|
17176
|
+
const declarations = [];
|
|
17177
|
+
const functions = [];
|
|
17178
|
+
const otherNames = [];
|
|
17179
|
+
if (fn.body && ts28.isBlock(fn.body)) {
|
|
17180
|
+
for (const statement of fn.body.statements)
|
|
17181
|
+
collectStatementDeclarations(statement, declarations, functions, otherNames);
|
|
17182
|
+
}
|
|
17183
|
+
for (const name of otherNames)
|
|
17184
|
+
unsafe.add(name);
|
|
17185
|
+
for (const declaration of functions)
|
|
17186
|
+
pending.push({ names: [declaration.name.text], reads: declaration });
|
|
17187
|
+
const consts = takePropsAliases(analysableConsts(declarations, analyzer, unsafe), propsObjects);
|
|
17188
|
+
for (const declaration of consts) {
|
|
17189
|
+
const init = declaration.initializer;
|
|
17190
|
+
if (ts28.isObjectBindingPattern(declaration.name) && isPropsObjectValue(init, propsObjects)) {
|
|
17191
|
+
classifyPropsPattern(declaration.name, false, analyzer, unsafe, pending);
|
|
17192
|
+
} else {
|
|
17193
|
+
pending.push({ names: declaredNames(declaration), reads: init });
|
|
17194
|
+
}
|
|
17195
|
+
}
|
|
17196
|
+
const reach = { propsObjects, unsafe };
|
|
17197
|
+
settleDeclarations(pending, reach, analyzer);
|
|
17198
|
+
return reach;
|
|
17199
|
+
}
|
|
17200
|
+
function readsCallerValue(node, analyzer, rowName) {
|
|
17201
|
+
let reach = reachCache.get(analyzer);
|
|
17202
|
+
if (reach === undefined) {
|
|
17203
|
+
reach = buildCallerReach(analyzer);
|
|
17204
|
+
reachCache.set(analyzer, reach);
|
|
17205
|
+
}
|
|
17206
|
+
if (reach === null)
|
|
17207
|
+
return true;
|
|
17208
|
+
return readsUnsafeName(node, reach, analyzer, (name) => {
|
|
17209
|
+
const row = rowName(name);
|
|
17210
|
+
return row === undefined ? undefined : !row;
|
|
17211
|
+
});
|
|
17212
|
+
}
|
|
17213
|
+
|
|
16910
17214
|
// src/template-position-walk.ts
|
|
16911
17215
|
function walkTemplatePositions(root, visit3, scope) {
|
|
16912
17216
|
walkNode(root, scope ? (position) => visit3({ scope, ...position }) : visit3, scope);
|
|
@@ -17193,13 +17497,13 @@ function exprCallsReactiveGetters(expr, ctx) {
|
|
|
17193
17497
|
function visit3(n) {
|
|
17194
17498
|
if (found)
|
|
17195
17499
|
return;
|
|
17196
|
-
if (
|
|
17500
|
+
if (ts29.isCallExpression(n) && ts29.isIdentifier(n.expression)) {
|
|
17197
17501
|
if (names.has(n.expression.text)) {
|
|
17198
17502
|
found = true;
|
|
17199
17503
|
return;
|
|
17200
17504
|
}
|
|
17201
17505
|
}
|
|
17202
|
-
|
|
17506
|
+
ts29.forEachChild(n, visit3);
|
|
17203
17507
|
}
|
|
17204
17508
|
visit3(expr);
|
|
17205
17509
|
return found;
|
|
@@ -17226,11 +17530,11 @@ function exprReferencesModuleClientSignal(expr, ctx) {
|
|
|
17226
17530
|
function visit3(n) {
|
|
17227
17531
|
if (found)
|
|
17228
17532
|
return;
|
|
17229
|
-
if (
|
|
17533
|
+
if (ts29.isCallExpression(n) && ts29.isIdentifier(n.expression) && names.has(n.expression.text)) {
|
|
17230
17534
|
found = true;
|
|
17231
17535
|
return;
|
|
17232
17536
|
}
|
|
17233
|
-
|
|
17537
|
+
ts29.forEachChild(n, visit3);
|
|
17234
17538
|
}
|
|
17235
17539
|
visit3(expr);
|
|
17236
17540
|
return found;
|
|
@@ -17240,11 +17544,11 @@ function exprHasFunctionCalls(expr) {
|
|
|
17240
17544
|
function visit3(n) {
|
|
17241
17545
|
if (found)
|
|
17242
17546
|
return;
|
|
17243
|
-
if (
|
|
17547
|
+
if (ts29.isCallExpression(n)) {
|
|
17244
17548
|
found = true;
|
|
17245
17549
|
return;
|
|
17246
17550
|
}
|
|
17247
|
-
|
|
17551
|
+
ts29.forEachChild(n, visit3);
|
|
17248
17552
|
}
|
|
17249
17553
|
visit3(expr);
|
|
17250
17554
|
return found;
|
|
@@ -17281,10 +17585,10 @@ function lowerDateCalls(text, expr, ctx) {
|
|
|
17281
17585
|
return text;
|
|
17282
17586
|
const candidates2 = [];
|
|
17283
17587
|
function visit3(n) {
|
|
17284
|
-
if (
|
|
17588
|
+
if (ts29.isCallExpression(n) && n.arguments.length === 0 && ts29.isPropertyAccessExpression(n.expression) && !n.expression.questionDotToken && DATE_METHODS.has(n.expression.name.text)) {
|
|
17285
17589
|
candidates2.push(n);
|
|
17286
17590
|
}
|
|
17287
|
-
|
|
17591
|
+
ts29.forEachChild(n, visit3);
|
|
17288
17592
|
}
|
|
17289
17593
|
visit3(expr);
|
|
17290
17594
|
if (candidates2.length === 0)
|
|
@@ -17309,10 +17613,10 @@ function lowerToLocaleDateCalls(text, expr, ctx) {
|
|
|
17309
17613
|
return text;
|
|
17310
17614
|
const candidates2 = [];
|
|
17311
17615
|
function visit3(n) {
|
|
17312
|
-
if (
|
|
17616
|
+
if (ts29.isCallExpression(n) && n.arguments.length === 2 && ts29.isPropertyAccessExpression(n.expression) && !n.expression.questionDotToken && n.expression.name.text === "toLocaleDateString") {
|
|
17313
17617
|
candidates2.push(n);
|
|
17314
17618
|
}
|
|
17315
|
-
|
|
17619
|
+
ts29.forEachChild(n, visit3);
|
|
17316
17620
|
}
|
|
17317
17621
|
visit3(expr);
|
|
17318
17622
|
if (candidates2.length === 0)
|
|
@@ -17377,9 +17681,9 @@ function collectBranchLocalPropRefsViaSubstitution(node, ctx) {
|
|
|
17377
17681
|
return;
|
|
17378
17682
|
let acc;
|
|
17379
17683
|
function visit3(n, parent) {
|
|
17380
|
-
if (
|
|
17381
|
-
const isObjectKey = parent &&
|
|
17382
|
-
const isAccessName = parent &&
|
|
17684
|
+
if (ts29.isIdentifier(n) && propDepsMap.has(n.text)) {
|
|
17685
|
+
const isObjectKey = parent && ts29.isPropertyAssignment(parent) && parent.name === n;
|
|
17686
|
+
const isAccessName = parent && ts29.isPropertyAccessExpression(parent) && parent.name === n;
|
|
17383
17687
|
if (!isObjectKey && !isAccessName) {
|
|
17384
17688
|
const deps = propDepsMap.get(n.text);
|
|
17385
17689
|
if (deps && deps.size > 0) {
|
|
@@ -17390,7 +17694,7 @@ function collectBranchLocalPropRefsViaSubstitution(node, ctx) {
|
|
|
17390
17694
|
}
|
|
17391
17695
|
}
|
|
17392
17696
|
}
|
|
17393
|
-
|
|
17697
|
+
ts29.forEachChild(n, (child) => visit3(child, n));
|
|
17394
17698
|
}
|
|
17395
17699
|
visit3(node);
|
|
17396
17700
|
return acc;
|
|
@@ -17462,21 +17766,21 @@ function createTransformContext(analyzer) {
|
|
|
17462
17766
|
function buildComponentNamespaces(ctx) {
|
|
17463
17767
|
const result = new Map;
|
|
17464
17768
|
for (const stmt of ctx.sourceFile.statements) {
|
|
17465
|
-
if (!
|
|
17769
|
+
if (!ts29.isVariableStatement(stmt))
|
|
17466
17770
|
continue;
|
|
17467
17771
|
for (const decl of stmt.declarationList.declarations) {
|
|
17468
|
-
if (!decl.initializer || !
|
|
17772
|
+
if (!decl.initializer || !ts29.isIdentifier(decl.name))
|
|
17469
17773
|
continue;
|
|
17470
17774
|
let init = decl.initializer;
|
|
17471
|
-
while (
|
|
17775
|
+
while (ts29.isParenthesizedExpression(init))
|
|
17472
17776
|
init = init.expression;
|
|
17473
|
-
if (!
|
|
17777
|
+
if (!ts29.isObjectLiteralExpression(init))
|
|
17474
17778
|
continue;
|
|
17475
17779
|
const members = new Map;
|
|
17476
17780
|
for (const prop of init.properties) {
|
|
17477
|
-
if (
|
|
17781
|
+
if (ts29.isShorthandPropertyAssignment(prop)) {
|
|
17478
17782
|
members.set(prop.name.text, prop.name.text);
|
|
17479
|
-
} else if (
|
|
17783
|
+
} else if (ts29.isPropertyAssignment(prop) && (ts29.isIdentifier(prop.name) || ts29.isStringLiteral(prop.name)) && ts29.isIdentifier(prop.initializer)) {
|
|
17480
17784
|
members.set(prop.name.text, prop.initializer.text);
|
|
17481
17785
|
}
|
|
17482
17786
|
}
|
|
@@ -17488,11 +17792,11 @@ function buildComponentNamespaces(ctx) {
|
|
|
17488
17792
|
return result;
|
|
17489
17793
|
}
|
|
17490
17794
|
function resolveMemberExpressionTag(tagNode, ctx) {
|
|
17491
|
-
if (!
|
|
17795
|
+
if (!ts29.isPropertyAccessExpression(tagNode))
|
|
17492
17796
|
return null;
|
|
17493
|
-
if (!
|
|
17797
|
+
if (!ts29.isIdentifier(tagNode.expression))
|
|
17494
17798
|
return null;
|
|
17495
|
-
if (!
|
|
17799
|
+
if (!ts29.isIdentifier(tagNode.name))
|
|
17496
17800
|
return null;
|
|
17497
17801
|
if (!ctx._componentNamespaces) {
|
|
17498
17802
|
ctx._componentNamespaces = buildComponentNamespaces(ctx);
|
|
@@ -17643,6 +17947,14 @@ function isLoopRowPropRead(parsed, analyzer, scope) {
|
|
|
17643
17947
|
return !scope.isBound(parsed.name) && isPropValueBinding(parsed.name, analyzer);
|
|
17644
17948
|
return parsed.kind === "member" && parsed.object.kind === "identifier" && !scope.isBound(parsed.object.name) && isPropsValueMember(parsed, analyzer);
|
|
17645
17949
|
}
|
|
17950
|
+
function branchReadsCallerValue(node, ctx) {
|
|
17951
|
+
return readsCallerValue(node, ctx.analyzer, (name) => {
|
|
17952
|
+
const source = ctx.scope.lookup(name)?.binding.source;
|
|
17953
|
+
if (source === undefined)
|
|
17954
|
+
return;
|
|
17955
|
+
return source === "item" || source === "index" || source === "destructure";
|
|
17956
|
+
});
|
|
17957
|
+
}
|
|
17646
17958
|
function attachPropReadFlags(node, parsed, analyzer, scope) {
|
|
17647
17959
|
const childrenRead = childrenReadOf(parsed, analyzer, scope);
|
|
17648
17960
|
if (childrenRead)
|
|
@@ -17656,6 +17968,8 @@ function attachParsedAttrValues(node, parse2, parseValue, resolve2) {
|
|
|
17656
17968
|
for (const part of value.parts ?? []) {
|
|
17657
17969
|
if (part.type === "expression")
|
|
17658
17970
|
part.parsed = resolve2(part.parsed);
|
|
17971
|
+
else if (part.type === "ternary" && part.condition.trim())
|
|
17972
|
+
part.parsedCondition = parse2(part.condition.trim());
|
|
17659
17973
|
}
|
|
17660
17974
|
}
|
|
17661
17975
|
if (value.kind === "expression" || spreads && value.kind === "spread") {
|
|
@@ -17796,7 +18110,7 @@ function buildIRRoot(analyzer, ctx) {
|
|
|
17796
18110
|
if (!analyzer.jsxReturn)
|
|
17797
18111
|
return null;
|
|
17798
18112
|
const jsxReturn = analyzer.jsxReturn;
|
|
17799
|
-
if (
|
|
18113
|
+
if (ts29.isJsxElement(jsxReturn) || ts29.isJsxSelfClosingElement(jsxReturn) || ts29.isJsxFragment(jsxReturn)) {
|
|
17800
18114
|
const ir2 = transformNode(jsxReturn, ctx);
|
|
17801
18115
|
if (ir2 && needsScopeWrapper(ir2)) {
|
|
17802
18116
|
return wrapInScopeElement(ir2);
|
|
@@ -17806,7 +18120,7 @@ function buildIRRoot(analyzer, ctx) {
|
|
|
17806
18120
|
ctx.isRoot = false;
|
|
17807
18121
|
const ir = transformJsxExpression(jsxReturn, ctx);
|
|
17808
18122
|
if (ir === null) {
|
|
17809
|
-
if (
|
|
18123
|
+
if (ts29.isIdentifier(jsxReturn) && (analyzer.jsxConstants.has(jsxReturn.text) || analyzer.inlineableJsxConsts.has(jsxReturn.text))) {
|
|
17810
18124
|
analyzer.errors.push(createError(ErrorCodes.RETURN_VALUE_NOT_JSX, getSourceLocation(jsxReturn, analyzer.sourceFile, analyzer.filePath), {
|
|
17811
18125
|
message: `Component '${analyzer.componentName ?? "(unknown)"}' return value is not recognized ` + `as JSX — return the JSX expression directly instead of binding it to a local variable ` + `first (\`return ${jsxReturn.text}\` after \`const ${jsxReturn.text} = <jsx/>\` is not ` + `resolved at return position).`
|
|
17812
18126
|
}));
|
|
@@ -17858,22 +18172,22 @@ function wrapInScopeElement(node) {
|
|
|
17858
18172
|
};
|
|
17859
18173
|
}
|
|
17860
18174
|
function transformNode(node, ctx) {
|
|
17861
|
-
if (
|
|
18175
|
+
if (ts29.isJsxElement(node)) {
|
|
17862
18176
|
return transformJsxElement(node, ctx);
|
|
17863
18177
|
}
|
|
17864
|
-
if (
|
|
18178
|
+
if (ts29.isJsxSelfClosingElement(node)) {
|
|
17865
18179
|
return transformSelfClosingElement(node, ctx);
|
|
17866
18180
|
}
|
|
17867
|
-
if (
|
|
18181
|
+
if (ts29.isJsxFragment(node)) {
|
|
17868
18182
|
return transformFragment(node, ctx);
|
|
17869
18183
|
}
|
|
17870
|
-
if (
|
|
18184
|
+
if (ts29.isJsxText(node)) {
|
|
17871
18185
|
return transformText(node, ctx);
|
|
17872
18186
|
}
|
|
17873
|
-
if (
|
|
18187
|
+
if (ts29.isJsxExpression(node)) {
|
|
17874
18188
|
return transformExpression(node, ctx);
|
|
17875
18189
|
}
|
|
17876
|
-
if (
|
|
18190
|
+
if (ts29.isConditionalExpression(node)) {
|
|
17877
18191
|
return transformConditional(node, ctx);
|
|
17878
18192
|
}
|
|
17879
18193
|
return null;
|
|
@@ -18291,7 +18605,7 @@ function transformSelfClosingComponent(node, ctx, name) {
|
|
|
18291
18605
|
}
|
|
18292
18606
|
function isTransparentFragment(node, ctx) {
|
|
18293
18607
|
const children = node.children.filter((child2) => {
|
|
18294
|
-
if (
|
|
18608
|
+
if (ts29.isJsxText(child2)) {
|
|
18295
18609
|
return cleanJsxWhitespace(child2.text) !== "";
|
|
18296
18610
|
}
|
|
18297
18611
|
return true;
|
|
@@ -18299,7 +18613,7 @@ function isTransparentFragment(node, ctx) {
|
|
|
18299
18613
|
if (children.length !== 1)
|
|
18300
18614
|
return false;
|
|
18301
18615
|
const child = children[0];
|
|
18302
|
-
if (!
|
|
18616
|
+
if (!ts29.isJsxExpression(child))
|
|
18303
18617
|
return false;
|
|
18304
18618
|
if (!child.expression)
|
|
18305
18619
|
return false;
|
|
@@ -18367,7 +18681,7 @@ function transformChildren(children, ctx) {
|
|
|
18367
18681
|
const result = [];
|
|
18368
18682
|
for (let i = 0;i < children.length; i++) {
|
|
18369
18683
|
const child = children[i];
|
|
18370
|
-
if (
|
|
18684
|
+
if (ts29.isJsxExpression(child) && !child.expression) {
|
|
18371
18685
|
continue;
|
|
18372
18686
|
}
|
|
18373
18687
|
const transformed = transformNode(child, ctx);
|
|
@@ -18379,10 +18693,10 @@ function transformChildren(children, ctx) {
|
|
|
18379
18693
|
}
|
|
18380
18694
|
function isRenderNothingLiteral(expr, ctx) {
|
|
18381
18695
|
let e = expr;
|
|
18382
|
-
while (
|
|
18696
|
+
while (ts29.isParenthesizedExpression(e) || ts29.isAsExpression(e) || ts29.isSatisfiesExpression(e) || ts29.isNonNullExpression(e)) {
|
|
18383
18697
|
e = e.expression;
|
|
18384
18698
|
}
|
|
18385
|
-
return e.kind ===
|
|
18699
|
+
return e.kind === ts29.SyntaxKind.NullKeyword || e.kind === ts29.SyntaxKind.TrueKeyword || e.kind === ts29.SyntaxKind.FalseKeyword || ts29.isIdentifier(e) && e.text === "undefined" && !isNameBound("undefined", makeBindingEnv(ctx));
|
|
18386
18700
|
}
|
|
18387
18701
|
function transformText(node, ctx) {
|
|
18388
18702
|
const text = cleanJsxWhitespace(node.text);
|
|
@@ -18428,7 +18742,7 @@ function transformExpressionInner(expr, ctx, node, isClientOnly) {
|
|
|
18428
18742
|
return null;
|
|
18429
18743
|
}
|
|
18430
18744
|
checkBareSignalOrMemoIdentifier(expr, ctx, { renderedPosition: true });
|
|
18431
|
-
if (
|
|
18745
|
+
if (ts29.isIdentifier(expr)) {
|
|
18432
18746
|
const jsxNode = ctx.analyzer.jsxConstants.get(expr.text);
|
|
18433
18747
|
if (jsxNode) {
|
|
18434
18748
|
return transformNode(jsxNode, ctx);
|
|
@@ -18691,38 +19005,38 @@ function transformLogicalAnd(node, ctx) {
|
|
|
18691
19005
|
};
|
|
18692
19006
|
}
|
|
18693
19007
|
function containsJsxInExpression(node) {
|
|
18694
|
-
if (
|
|
19008
|
+
if (ts29.isJsxElement(node) || ts29.isJsxSelfClosingElement(node) || ts29.isJsxFragment(node)) {
|
|
18695
19009
|
return true;
|
|
18696
19010
|
}
|
|
18697
|
-
return
|
|
19011
|
+
return ts29.forEachChild(node, containsJsxInExpression) ?? false;
|
|
18698
19012
|
}
|
|
18699
19013
|
function callsJsxHelper(node, ctx) {
|
|
18700
19014
|
let found = false;
|
|
18701
19015
|
const visit3 = (n) => {
|
|
18702
19016
|
if (found)
|
|
18703
19017
|
return;
|
|
18704
|
-
if (
|
|
19018
|
+
if (ts29.isCallExpression(n) && ts29.isIdentifier(n.expression)) {
|
|
18705
19019
|
const name = n.expression.text;
|
|
18706
19020
|
if (ctx.analyzer.jsxFunctions.has(name) || ctx.analyzer.jsxMultiReturnFunctions.has(name)) {
|
|
18707
19021
|
found = true;
|
|
18708
19022
|
return;
|
|
18709
19023
|
}
|
|
18710
19024
|
}
|
|
18711
|
-
|
|
19025
|
+
ts29.forEachChild(n, visit3);
|
|
18712
19026
|
};
|
|
18713
19027
|
visit3(node);
|
|
18714
19028
|
return found;
|
|
18715
19029
|
}
|
|
18716
19030
|
function containsAwaitExpression(node) {
|
|
18717
|
-
if (
|
|
19031
|
+
if (ts29.isAwaitExpression(node))
|
|
18718
19032
|
return true;
|
|
18719
|
-
if (
|
|
19033
|
+
if (ts29.isFunctionDeclaration(node) || ts29.isFunctionExpression(node) || ts29.isArrowFunction(node))
|
|
18720
19034
|
return false;
|
|
18721
|
-
return
|
|
19035
|
+
return ts29.forEachChild(node, containsAwaitExpression) ?? false;
|
|
18722
19036
|
}
|
|
18723
19037
|
function transformNullishCoalescing(node, ctx) {
|
|
18724
19038
|
const leftText = ctx.getJS(node.left);
|
|
18725
|
-
const isNullish = node.operatorToken.kind ===
|
|
19039
|
+
const isNullish = node.operatorToken.kind === ts29.SyntaxKind.QuestionQuestionToken;
|
|
18726
19040
|
const condition = isNullish ? `${leftText} != null` : leftText;
|
|
18727
19041
|
const leftOrigin = {
|
|
18728
19042
|
phase: "tick",
|
|
@@ -18768,36 +19082,36 @@ function transformNullishCoalescing(node, ctx) {
|
|
|
18768
19082
|
}
|
|
18769
19083
|
function assertNever2(expr) {
|
|
18770
19084
|
const kind = expr?.kind;
|
|
18771
|
-
throw new Error(`transformJsxExpression: unhandled ts.SyntaxKind ${kind !== undefined ?
|
|
19085
|
+
throw new Error(`transformJsxExpression: unhandled ts.SyntaxKind ${kind !== undefined ? ts29.SyntaxKind[kind] : "unknown"} ` + `(kind=${kind}). Update spec/compiler.md Appendix A and the switch in jsx-to-ir.ts.`);
|
|
18772
19086
|
}
|
|
18773
19087
|
function transformJsxExpression(expr, ctx, isClientOnly = false) {
|
|
18774
19088
|
const node = expr;
|
|
18775
19089
|
switch (node.kind) {
|
|
18776
|
-
case
|
|
18777
|
-
case
|
|
18778
|
-
case
|
|
18779
|
-
case
|
|
18780
|
-
case
|
|
18781
|
-
case
|
|
19090
|
+
case ts29.SyntaxKind.ParenthesizedExpression:
|
|
19091
|
+
case ts29.SyntaxKind.AsExpression:
|
|
19092
|
+
case ts29.SyntaxKind.SatisfiesExpression:
|
|
19093
|
+
case ts29.SyntaxKind.NonNullExpression:
|
|
19094
|
+
case ts29.SyntaxKind.TypeAssertionExpression:
|
|
19095
|
+
case ts29.SyntaxKind.PartiallyEmittedExpression:
|
|
18782
19096
|
return transformJsxExpression(node.expression, ctx, isClientOnly);
|
|
18783
|
-
case
|
|
19097
|
+
case ts29.SyntaxKind.JsxElement:
|
|
18784
19098
|
return transformJsxElement(node, ctx);
|
|
18785
|
-
case
|
|
19099
|
+
case ts29.SyntaxKind.JsxFragment:
|
|
18786
19100
|
return transformFragment(node, ctx);
|
|
18787
|
-
case
|
|
19101
|
+
case ts29.SyntaxKind.JsxSelfClosingElement:
|
|
18788
19102
|
return transformSelfClosingElement(node, ctx);
|
|
18789
|
-
case
|
|
19103
|
+
case ts29.SyntaxKind.ConditionalExpression:
|
|
18790
19104
|
return transformConditional(node, ctx);
|
|
18791
|
-
case
|
|
18792
|
-
if (node.operatorToken.kind ===
|
|
19105
|
+
case ts29.SyntaxKind.BinaryExpression: {
|
|
19106
|
+
if (node.operatorToken.kind === ts29.SyntaxKind.AmpersandAmpersandToken) {
|
|
18793
19107
|
return transformLogicalAnd(node, ctx);
|
|
18794
19108
|
}
|
|
18795
|
-
if ((node.operatorToken.kind ===
|
|
19109
|
+
if ((node.operatorToken.kind === ts29.SyntaxKind.QuestionQuestionToken || node.operatorToken.kind === ts29.SyntaxKind.BarBarToken) && (containsJsxInExpression(node.right) || callsJsxHelper(node.right, ctx))) {
|
|
18796
19110
|
return transformNullishCoalescing(node, ctx);
|
|
18797
19111
|
}
|
|
18798
19112
|
return null;
|
|
18799
19113
|
}
|
|
18800
|
-
case
|
|
19114
|
+
case ts29.SyntaxKind.CallExpression: {
|
|
18801
19115
|
const mapMethod = getMapLikeMethod(node);
|
|
18802
19116
|
if (mapMethod) {
|
|
18803
19117
|
const mapResult = transformMapCall(node, ctx, isClientOnly, mapMethod);
|
|
@@ -18805,7 +19119,7 @@ function transformJsxExpression(expr, ctx, isClientOnly = false) {
|
|
|
18805
19119
|
return mapResult;
|
|
18806
19120
|
}
|
|
18807
19121
|
const callee = node.expression;
|
|
18808
|
-
if (
|
|
19122
|
+
if (ts29.isIdentifier(callee)) {
|
|
18809
19123
|
const jsxFunc = ctx.analyzer.jsxFunctions.get(callee.text);
|
|
18810
19124
|
if (jsxFunc) {
|
|
18811
19125
|
return transformJsxFunctionCall(node, jsxFunc, ctx, isClientOnly);
|
|
@@ -18817,39 +19131,39 @@ function transformJsxExpression(expr, ctx, isClientOnly = false) {
|
|
|
18817
19131
|
}
|
|
18818
19132
|
return null;
|
|
18819
19133
|
}
|
|
18820
|
-
case
|
|
18821
|
-
case
|
|
18822
|
-
case
|
|
18823
|
-
case
|
|
18824
|
-
case
|
|
18825
|
-
case
|
|
18826
|
-
case
|
|
18827
|
-
case
|
|
18828
|
-
case
|
|
18829
|
-
case
|
|
18830
|
-
case
|
|
18831
|
-
case
|
|
18832
|
-
case
|
|
18833
|
-
case
|
|
18834
|
-
case
|
|
18835
|
-
case
|
|
18836
|
-
case
|
|
18837
|
-
case
|
|
18838
|
-
case
|
|
18839
|
-
case
|
|
18840
|
-
case
|
|
18841
|
-
case
|
|
18842
|
-
case
|
|
18843
|
-
case
|
|
18844
|
-
case
|
|
18845
|
-
case
|
|
18846
|
-
case
|
|
18847
|
-
case
|
|
18848
|
-
case
|
|
18849
|
-
case
|
|
18850
|
-
case
|
|
19134
|
+
case ts29.SyntaxKind.Identifier:
|
|
19135
|
+
case ts29.SyntaxKind.StringLiteral:
|
|
19136
|
+
case ts29.SyntaxKind.NumericLiteral:
|
|
19137
|
+
case ts29.SyntaxKind.BigIntLiteral:
|
|
19138
|
+
case ts29.SyntaxKind.RegularExpressionLiteral:
|
|
19139
|
+
case ts29.SyntaxKind.NoSubstitutionTemplateLiteral:
|
|
19140
|
+
case ts29.SyntaxKind.TemplateExpression:
|
|
19141
|
+
case ts29.SyntaxKind.TaggedTemplateExpression:
|
|
19142
|
+
case ts29.SyntaxKind.TrueKeyword:
|
|
19143
|
+
case ts29.SyntaxKind.FalseKeyword:
|
|
19144
|
+
case ts29.SyntaxKind.NullKeyword:
|
|
19145
|
+
case ts29.SyntaxKind.ThisKeyword:
|
|
19146
|
+
case ts29.SyntaxKind.SuperKeyword:
|
|
19147
|
+
case ts29.SyntaxKind.ImportKeyword:
|
|
19148
|
+
case ts29.SyntaxKind.PropertyAccessExpression:
|
|
19149
|
+
case ts29.SyntaxKind.ElementAccessExpression:
|
|
19150
|
+
case ts29.SyntaxKind.PrefixUnaryExpression:
|
|
19151
|
+
case ts29.SyntaxKind.PostfixUnaryExpression:
|
|
19152
|
+
case ts29.SyntaxKind.TypeOfExpression:
|
|
19153
|
+
case ts29.SyntaxKind.VoidExpression:
|
|
19154
|
+
case ts29.SyntaxKind.DeleteExpression:
|
|
19155
|
+
case ts29.SyntaxKind.NewExpression:
|
|
19156
|
+
case ts29.SyntaxKind.ObjectLiteralExpression:
|
|
19157
|
+
case ts29.SyntaxKind.ArrowFunction:
|
|
19158
|
+
case ts29.SyntaxKind.FunctionExpression:
|
|
19159
|
+
case ts29.SyntaxKind.ClassExpression:
|
|
19160
|
+
case ts29.SyntaxKind.MetaProperty:
|
|
19161
|
+
case ts29.SyntaxKind.ExpressionWithTypeArguments:
|
|
19162
|
+
case ts29.SyntaxKind.CommaListExpression:
|
|
19163
|
+
case ts29.SyntaxKind.SyntheticExpression:
|
|
19164
|
+
case ts29.SyntaxKind.ArrayLiteralExpression:
|
|
18851
19165
|
return null;
|
|
18852
|
-
case
|
|
19166
|
+
case ts29.SyntaxKind.AwaitExpression:
|
|
18853
19167
|
ctx.analyzer.errors.push(createError(ErrorCodes.STAGE_AWAIT_IN_TEMPLATE, getSourceLocation(node, ctx.sourceFile, ctx.filePath)));
|
|
18854
19168
|
return {
|
|
18855
19169
|
type: "expression",
|
|
@@ -18860,16 +19174,16 @@ function transformJsxExpression(expr, ctx, isClientOnly = false) {
|
|
|
18860
19174
|
loc: getSourceLocation(node, ctx.sourceFile, ctx.filePath),
|
|
18861
19175
|
origin: { phase: "tick", scope: "template", effect: "pure", freeRefs: [] }
|
|
18862
19176
|
};
|
|
18863
|
-
case
|
|
19177
|
+
case ts29.SyntaxKind.YieldExpression:
|
|
18864
19178
|
return null;
|
|
18865
|
-
case
|
|
18866
|
-
case
|
|
18867
|
-
case
|
|
18868
|
-
case
|
|
18869
|
-
case
|
|
18870
|
-
case
|
|
18871
|
-
case
|
|
18872
|
-
case
|
|
19179
|
+
case ts29.SyntaxKind.SpreadElement:
|
|
19180
|
+
case ts29.SyntaxKind.OmittedExpression:
|
|
19181
|
+
case ts29.SyntaxKind.JsxExpression:
|
|
19182
|
+
case ts29.SyntaxKind.JsxOpeningElement:
|
|
19183
|
+
case ts29.SyntaxKind.JsxOpeningFragment:
|
|
19184
|
+
case ts29.SyntaxKind.JsxClosingFragment:
|
|
19185
|
+
case ts29.SyntaxKind.JsxAttributes:
|
|
19186
|
+
case ts29.SyntaxKind.MissingDeclaration:
|
|
18873
19187
|
return null;
|
|
18874
19188
|
default:
|
|
18875
19189
|
return assertNever2(node);
|
|
@@ -18901,12 +19215,13 @@ function transformConditionalBranch(node, ctx) {
|
|
|
18901
19215
|
slotId,
|
|
18902
19216
|
callsReactiveGetters: callsReactive || undefined,
|
|
18903
19217
|
hasFunctionCalls: hasCalls || undefined,
|
|
19218
|
+
...hasCalls && branchReadsCallerValue(node, ctx) && { readsCallerValue: true },
|
|
18904
19219
|
loc: getSourceLocation(node, ctx.sourceFile, ctx.filePath),
|
|
18905
19220
|
origin: branchOrigin
|
|
18906
19221
|
};
|
|
18907
19222
|
}
|
|
18908
19223
|
function getMapLikeMethod(node) {
|
|
18909
|
-
if (!
|
|
19224
|
+
if (!ts29.isPropertyAccessExpression(node.expression))
|
|
18910
19225
|
return null;
|
|
18911
19226
|
const name = node.expression.name.text;
|
|
18912
19227
|
if (name === "map")
|
|
@@ -18916,9 +19231,9 @@ function getMapLikeMethod(node) {
|
|
|
18916
19231
|
return null;
|
|
18917
19232
|
}
|
|
18918
19233
|
function isFilterCall(node) {
|
|
18919
|
-
if (!
|
|
19234
|
+
if (!ts29.isCallExpression(node))
|
|
18920
19235
|
return null;
|
|
18921
|
-
if (!
|
|
19236
|
+
if (!ts29.isPropertyAccessExpression(node.expression))
|
|
18922
19237
|
return null;
|
|
18923
19238
|
if (node.expression.name.text !== "filter")
|
|
18924
19239
|
return null;
|
|
@@ -18930,9 +19245,9 @@ function isFilterCall(node) {
|
|
|
18930
19245
|
};
|
|
18931
19246
|
}
|
|
18932
19247
|
function isSortCall(node) {
|
|
18933
|
-
if (!
|
|
19248
|
+
if (!ts29.isCallExpression(node))
|
|
18934
19249
|
return null;
|
|
18935
|
-
if (!
|
|
19250
|
+
if (!ts29.isPropertyAccessExpression(node.expression))
|
|
18936
19251
|
return null;
|
|
18937
19252
|
const methodName = node.expression.name.text;
|
|
18938
19253
|
if (methodName !== "sort" && methodName !== "toSorted")
|
|
@@ -18946,9 +19261,9 @@ function isSortCall(node) {
|
|
|
18946
19261
|
};
|
|
18947
19262
|
}
|
|
18948
19263
|
function isIteratorShapeCall(node) {
|
|
18949
|
-
if (!
|
|
19264
|
+
if (!ts29.isCallExpression(node))
|
|
18950
19265
|
return null;
|
|
18951
|
-
if (!
|
|
19266
|
+
if (!ts29.isPropertyAccessExpression(node.expression))
|
|
18952
19267
|
return null;
|
|
18953
19268
|
if (node.arguments.length !== 0)
|
|
18954
19269
|
return null;
|
|
@@ -18958,11 +19273,11 @@ function isIteratorShapeCall(node) {
|
|
|
18958
19273
|
return { array: node.expression.expression, shape: name };
|
|
18959
19274
|
}
|
|
18960
19275
|
function isObjectIteratorCall(node) {
|
|
18961
|
-
if (!
|
|
19276
|
+
if (!ts29.isCallExpression(node))
|
|
18962
19277
|
return null;
|
|
18963
|
-
if (!
|
|
19278
|
+
if (!ts29.isPropertyAccessExpression(node.expression))
|
|
18964
19279
|
return null;
|
|
18965
|
-
if (!
|
|
19280
|
+
if (!ts29.isIdentifier(node.expression.expression))
|
|
18966
19281
|
return null;
|
|
18967
19282
|
if (node.expression.expression.text !== "Object")
|
|
18968
19283
|
return null;
|
|
@@ -18987,7 +19302,7 @@ function extractSortComparator(callback, _method, ctx) {
|
|
|
18987
19302
|
` + `(reverse the operands for descending order).`
|
|
18988
19303
|
});
|
|
18989
19304
|
let resolvedNode = callback;
|
|
18990
|
-
if (
|
|
19305
|
+
if (ts29.isIdentifier(callback)) {
|
|
18991
19306
|
const resolved = resolveSortComparatorIdentifier(callback.text, ctx);
|
|
18992
19307
|
if (!resolved) {
|
|
18993
19308
|
return {
|
|
@@ -18997,7 +19312,7 @@ function extractSortComparator(callback, _method, ctx) {
|
|
|
18997
19312
|
}
|
|
18998
19313
|
resolvedNode = resolved;
|
|
18999
19314
|
}
|
|
19000
|
-
if (!
|
|
19315
|
+
if (!ts29.isArrowFunction(resolvedNode) && !ts29.isFunctionExpression(resolvedNode)) {
|
|
19001
19316
|
return {
|
|
19002
19317
|
result: null,
|
|
19003
19318
|
unsupportedReason: "Sort comparator must be an arrow function or function expression"
|
|
@@ -19024,11 +19339,11 @@ function resolveSortComparatorIdentifier(name, ctx) {
|
|
|
19024
19339
|
return null;
|
|
19025
19340
|
if (constInfo) {
|
|
19026
19341
|
const ast = parseConstInitializer(constInfo);
|
|
19027
|
-
return ast && (
|
|
19342
|
+
return ast && (ts29.isArrowFunction(ast) || ts29.isFunctionExpression(ast)) ? ast : null;
|
|
19028
19343
|
}
|
|
19029
19344
|
if (fnInfo) {
|
|
19030
19345
|
const ast = parseFunctionInfoAsExpr(fnInfo);
|
|
19031
|
-
return ast && (
|
|
19346
|
+
return ast && (ts29.isArrowFunction(ast) || ts29.isFunctionExpression(ast)) ? ast : null;
|
|
19032
19347
|
}
|
|
19033
19348
|
return null;
|
|
19034
19349
|
}
|
|
@@ -19039,11 +19354,11 @@ function resolveCallbackMethodFunctionReferenceIdentifier(name, analyzer) {
|
|
|
19039
19354
|
return null;
|
|
19040
19355
|
if (constInfo) {
|
|
19041
19356
|
const ast = parseConstInitializer(constInfo);
|
|
19042
|
-
return ast && (
|
|
19357
|
+
return ast && (ts29.isArrowFunction(ast) || ts29.isFunctionExpression(ast)) ? ast : null;
|
|
19043
19358
|
}
|
|
19044
19359
|
if (fnInfo) {
|
|
19045
19360
|
const ast = parseFunctionInfoAsExpr(fnInfo);
|
|
19046
|
-
return ast && (
|
|
19361
|
+
return ast && (ts29.isArrowFunction(ast) || ts29.isFunctionExpression(ast)) ? ast : null;
|
|
19047
19362
|
}
|
|
19048
19363
|
return null;
|
|
19049
19364
|
}
|
|
@@ -19102,13 +19417,13 @@ function resolveCallbackMethodFunctionReferences(expr, analyzer, bound) {
|
|
|
19102
19417
|
return visit3(expr, bound);
|
|
19103
19418
|
}
|
|
19104
19419
|
function extractFilterPredicate(callback, ctx) {
|
|
19105
|
-
if (!
|
|
19420
|
+
if (!ts29.isArrowFunction(callback))
|
|
19106
19421
|
return { result: null };
|
|
19107
19422
|
if (callback.parameters.length < 1)
|
|
19108
19423
|
return { result: null };
|
|
19109
19424
|
const firstParam = callback.parameters[0];
|
|
19110
|
-
if (!
|
|
19111
|
-
if (
|
|
19425
|
+
if (!ts29.isIdentifier(firstParam.name)) {
|
|
19426
|
+
if (ts29.isBlock(callback.body)) {
|
|
19112
19427
|
return {
|
|
19113
19428
|
result: null,
|
|
19114
19429
|
unsupportedReason: "Block body in a destructured filter param is not supported. Workaround: use an expression-body arrow, or add /* @client */."
|
|
@@ -19128,7 +19443,7 @@ function extractFilterPredicate(callback, ctx) {
|
|
|
19128
19443
|
return { result: null };
|
|
19129
19444
|
}
|
|
19130
19445
|
const param = firstParam.name.getText(ctx.sourceFile);
|
|
19131
|
-
if (
|
|
19446
|
+
if (ts29.isBlock(callback.body)) {
|
|
19132
19447
|
const raw2 = ctx.getJS(callback.body);
|
|
19133
19448
|
const statements = parseBlockBody(callback.body, ctx.sourceFile, (n) => ctx.getJS(n));
|
|
19134
19449
|
if (!statements) {
|
|
@@ -19163,7 +19478,7 @@ function withTemplatePredicate(result, callback, ctx) {
|
|
|
19163
19478
|
const savedScope = ctx.scope;
|
|
19164
19479
|
const params = new Set;
|
|
19165
19480
|
for (const p of callback.parameters)
|
|
19166
|
-
|
|
19481
|
+
collectBindingNames3(p.name, params);
|
|
19167
19482
|
ctx.scope = savedScope.enterCallback([...params]);
|
|
19168
19483
|
try {
|
|
19169
19484
|
const templateRaw = rewritePredicateBody(result.raw, callback.body, ctx);
|
|
@@ -19177,7 +19492,7 @@ function withTemplatePredicate(result, callback, ctx) {
|
|
|
19177
19492
|
}
|
|
19178
19493
|
var BLOCK_PREDICATE_HEAD = "() => ";
|
|
19179
19494
|
function rewritePredicateBody(raw, body, ctx) {
|
|
19180
|
-
if (!
|
|
19495
|
+
if (!ts29.isBlock(body))
|
|
19181
19496
|
return rewriteBarePropRefsStructural2(raw, body, ctx);
|
|
19182
19497
|
const rewritten = rewriteBarePropRefsStructural2(`${BLOCK_PREDICATE_HEAD}${raw}`, body, ctx);
|
|
19183
19498
|
if (rewritten === undefined || rewritten === null)
|
|
@@ -19190,7 +19505,7 @@ function unboundFilterParamReason(callback, predicate, ctx) {
|
|
|
19190
19505
|
return unbound === null ? undefined : unboundCallbackParamReason("filter", unbound);
|
|
19191
19506
|
}
|
|
19192
19507
|
function extractLoopParamBindings(pattern) {
|
|
19193
|
-
if (
|
|
19508
|
+
if (ts29.isIdentifier(pattern))
|
|
19194
19509
|
return null;
|
|
19195
19510
|
const bindings = [];
|
|
19196
19511
|
let unsupported = false;
|
|
@@ -19199,7 +19514,7 @@ function extractLoopParamBindings(pattern) {
|
|
|
19199
19514
|
return false;
|
|
19200
19515
|
for (let i = 0;i < key.length; ) {
|
|
19201
19516
|
const cp = key.codePointAt(i);
|
|
19202
|
-
const ok = i === 0 ?
|
|
19517
|
+
const ok = i === 0 ? ts29.isIdentifierStart(cp, ts29.ScriptTarget.Latest) : ts29.isIdentifierPart(cp, ts29.ScriptTarget.Latest);
|
|
19203
19518
|
if (!ok)
|
|
19204
19519
|
return false;
|
|
19205
19520
|
i += cp > 65535 ? 2 : 1;
|
|
@@ -19212,17 +19527,17 @@ function extractLoopParamBindings(pattern) {
|
|
|
19212
19527
|
const walk = (p, prefix, segments) => {
|
|
19213
19528
|
if (unsupported)
|
|
19214
19529
|
return;
|
|
19215
|
-
if (
|
|
19530
|
+
if (ts29.isArrayBindingPattern(p)) {
|
|
19216
19531
|
const elements2 = p.elements;
|
|
19217
19532
|
for (let index = 0;index < elements2.length; index++) {
|
|
19218
19533
|
if (unsupported)
|
|
19219
19534
|
return;
|
|
19220
19535
|
const el = elements2[index];
|
|
19221
|
-
if (
|
|
19536
|
+
if (ts29.isOmittedExpression(el))
|
|
19222
19537
|
continue;
|
|
19223
19538
|
if (el.dotDotDotToken) {
|
|
19224
19539
|
internalInvariant(index === elements2.length - 1, "extractLoopParamBindings: array rest token in non-final position (parser should reject)");
|
|
19225
|
-
internalInvariant(
|
|
19540
|
+
internalInvariant(ts29.isIdentifier(el.name), "extractLoopParamBindings: array rest target is not an identifier (parser should reject)");
|
|
19226
19541
|
bindings.push({
|
|
19227
19542
|
name: el.name.text,
|
|
19228
19543
|
path: prefix,
|
|
@@ -19233,7 +19548,7 @@ function extractLoopParamBindings(pattern) {
|
|
|
19233
19548
|
}
|
|
19234
19549
|
const path = `${prefix}[${index}]`;
|
|
19235
19550
|
const nextSegments = [...segments, { kind: "index", index }];
|
|
19236
|
-
if (
|
|
19551
|
+
if (ts29.isIdentifier(el.name)) {
|
|
19237
19552
|
bindings.push({ name: el.name.text, path, segments: nextSegments });
|
|
19238
19553
|
} else {
|
|
19239
19554
|
walk(el.name, path, nextSegments);
|
|
@@ -19249,7 +19564,7 @@ function extractLoopParamBindings(pattern) {
|
|
|
19249
19564
|
const el = elements[i];
|
|
19250
19565
|
if (el.dotDotDotToken) {
|
|
19251
19566
|
internalInvariant(i === elements.length - 1, "extractLoopParamBindings: object rest token in non-final position (parser should reject)");
|
|
19252
|
-
internalInvariant(
|
|
19567
|
+
internalInvariant(ts29.isIdentifier(el.name), "extractLoopParamBindings: object rest target is not an identifier (parser should reject)");
|
|
19253
19568
|
bindings.push({
|
|
19254
19569
|
name: el.name.text,
|
|
19255
19570
|
path: prefix,
|
|
@@ -19261,17 +19576,17 @@ function extractLoopParamBindings(pattern) {
|
|
|
19261
19576
|
let keyText = null;
|
|
19262
19577
|
if (el.propertyName) {
|
|
19263
19578
|
const pn = el.propertyName;
|
|
19264
|
-
if (
|
|
19579
|
+
if (ts29.isIdentifier(pn))
|
|
19265
19580
|
keyText = pn.text;
|
|
19266
|
-
else if (
|
|
19581
|
+
else if (ts29.isStringLiteral(pn))
|
|
19267
19582
|
keyText = pn.text;
|
|
19268
|
-
else if (
|
|
19583
|
+
else if (ts29.isNumericLiteral(pn))
|
|
19269
19584
|
keyText = pn.text;
|
|
19270
19585
|
else {
|
|
19271
19586
|
unsupported = true;
|
|
19272
19587
|
return;
|
|
19273
19588
|
}
|
|
19274
|
-
} else if (
|
|
19589
|
+
} else if (ts29.isIdentifier(el.name)) {
|
|
19275
19590
|
keyText = el.name.text;
|
|
19276
19591
|
} else {
|
|
19277
19592
|
unsupported = true;
|
|
@@ -19281,14 +19596,14 @@ function extractLoopParamBindings(pattern) {
|
|
|
19281
19596
|
collectedKeys.push({ key: keyText, isIdent: keyIsIdent });
|
|
19282
19597
|
const path = appendDotAccess(prefix, keyText);
|
|
19283
19598
|
const nextSegments = [...segments, { kind: "field", key: keyText, isIdent: keyIsIdent }];
|
|
19284
|
-
if (
|
|
19599
|
+
if (ts29.isIdentifier(el.name)) {
|
|
19285
19600
|
bindings.push({ name: el.name.text, path, segments: nextSegments });
|
|
19286
19601
|
} else {
|
|
19287
19602
|
walk(el.name, path, nextSegments);
|
|
19288
19603
|
}
|
|
19289
19604
|
}
|
|
19290
19605
|
};
|
|
19291
|
-
if (
|
|
19606
|
+
if (ts29.isArrayBindingPattern(pattern) || ts29.isObjectBindingPattern(pattern)) {
|
|
19292
19607
|
walk(pattern, "", []);
|
|
19293
19608
|
if (unsupported)
|
|
19294
19609
|
return { unsupported: true };
|
|
@@ -19298,7 +19613,7 @@ function extractLoopParamBindings(pattern) {
|
|
|
19298
19613
|
}
|
|
19299
19614
|
function findKeyJsxAttribute(opening) {
|
|
19300
19615
|
for (const prop of opening.attributes.properties) {
|
|
19301
|
-
if (
|
|
19616
|
+
if (ts29.isJsxAttribute(prop) && prop.name.getText() === "key") {
|
|
19302
19617
|
return prop;
|
|
19303
19618
|
}
|
|
19304
19619
|
}
|
|
@@ -19347,7 +19662,7 @@ function keyAttrValueToExpr(v) {
|
|
|
19347
19662
|
function normalizeKeyExpr(expr) {
|
|
19348
19663
|
let out = "";
|
|
19349
19664
|
for (const tok of iterateJsTokens(expr)) {
|
|
19350
|
-
if (tok.kind ===
|
|
19665
|
+
if (tok.kind === ts29.SyntaxKind.WhitespaceTrivia || tok.kind === ts29.SyntaxKind.NewLineTrivia) {
|
|
19351
19666
|
continue;
|
|
19352
19667
|
}
|
|
19353
19668
|
out += expr.slice(tok.pos, tok.end);
|
|
@@ -19359,13 +19674,13 @@ function conditionalHasExplicitNullishBranch(cond) {
|
|
|
19359
19674
|
}
|
|
19360
19675
|
function branchHasExplicitNullish(branch) {
|
|
19361
19676
|
let b = branch;
|
|
19362
|
-
while (
|
|
19677
|
+
while (ts29.isParenthesizedExpression(b))
|
|
19363
19678
|
b = b.expression;
|
|
19364
|
-
if (b.kind ===
|
|
19679
|
+
if (b.kind === ts29.SyntaxKind.NullKeyword)
|
|
19365
19680
|
return true;
|
|
19366
|
-
if (
|
|
19681
|
+
if (ts29.isIdentifier(b) && b.text === "undefined")
|
|
19367
19682
|
return true;
|
|
19368
|
-
if (
|
|
19683
|
+
if (ts29.isConditionalExpression(b))
|
|
19369
19684
|
return conditionalHasExplicitNullishBranch(b);
|
|
19370
19685
|
return false;
|
|
19371
19686
|
}
|
|
@@ -19374,26 +19689,26 @@ function classifyKeyProblem(keyAttr, checker) {
|
|
|
19374
19689
|
return "missing";
|
|
19375
19690
|
if (!keyAttr.initializer)
|
|
19376
19691
|
return "missing";
|
|
19377
|
-
if (
|
|
19692
|
+
if (ts29.isJsxExpression(keyAttr.initializer) && !keyAttr.initializer.expression) {
|
|
19378
19693
|
return "missing";
|
|
19379
19694
|
}
|
|
19380
19695
|
let expr;
|
|
19381
|
-
if (
|
|
19696
|
+
if (ts29.isStringLiteral(keyAttr.initializer)) {
|
|
19382
19697
|
return null;
|
|
19383
|
-
} else if (
|
|
19698
|
+
} else if (ts29.isJsxExpression(keyAttr.initializer)) {
|
|
19384
19699
|
expr = keyAttr.initializer.expression;
|
|
19385
19700
|
}
|
|
19386
19701
|
if (!expr)
|
|
19387
19702
|
return null;
|
|
19388
|
-
if (expr.kind ===
|
|
19703
|
+
if (expr.kind === ts29.SyntaxKind.NullKeyword)
|
|
19389
19704
|
return null;
|
|
19390
|
-
if (
|
|
19705
|
+
if (ts29.isIdentifier(expr) && expr.text === "undefined")
|
|
19391
19706
|
return null;
|
|
19392
|
-
if (
|
|
19707
|
+
if (ts29.isConditionalExpression(expr) && conditionalHasExplicitNullishBranch(expr))
|
|
19393
19708
|
return null;
|
|
19394
19709
|
if (checker) {
|
|
19395
19710
|
const type = checker.getTypeAtLocation(expr);
|
|
19396
|
-
const isNullable = type.isUnion() ? type.types.some((t) => (t.flags & (
|
|
19711
|
+
const isNullable = type.isUnion() ? type.types.some((t) => (t.flags & (ts29.TypeFlags.Null | ts29.TypeFlags.Undefined | ts29.TypeFlags.Void)) !== 0) : (type.flags & (ts29.TypeFlags.Null | ts29.TypeFlags.Undefined | ts29.TypeFlags.Void)) !== 0;
|
|
19397
19712
|
if (isNullable)
|
|
19398
19713
|
return "nullable-type";
|
|
19399
19714
|
}
|
|
@@ -19419,81 +19734,81 @@ function checkLoopKey(callback, ctx, isNested) {
|
|
|
19419
19734
|
ctx.analyzer.errors.push(createError(errorCode, getSourceLocation(locNode, ctx.sourceFile, ctx.filePath), { suggestion: { message: keyErrorSuggestion(problem) } }));
|
|
19420
19735
|
}
|
|
19421
19736
|
let body = callback.body;
|
|
19422
|
-
if (
|
|
19423
|
-
const ret = body.statements.find((s) =>
|
|
19737
|
+
if (ts29.isBlock(body)) {
|
|
19738
|
+
const ret = body.statements.find((s) => ts29.isReturnStatement(s) && s.expression != null);
|
|
19424
19739
|
if (!ret?.expression)
|
|
19425
19740
|
return;
|
|
19426
19741
|
body = ret.expression;
|
|
19427
19742
|
}
|
|
19428
|
-
while (
|
|
19743
|
+
while (ts29.isParenthesizedExpression(body))
|
|
19429
19744
|
body = body.expression;
|
|
19430
19745
|
function checkJsxOperand(node) {
|
|
19431
19746
|
let n = node;
|
|
19432
|
-
while (
|
|
19747
|
+
while (ts29.isParenthesizedExpression(n))
|
|
19433
19748
|
n = n.expression;
|
|
19434
|
-
if (
|
|
19749
|
+
if (ts29.isJsxElement(n))
|
|
19435
19750
|
checkOpening(n.openingElement);
|
|
19436
|
-
else if (
|
|
19751
|
+
else if (ts29.isJsxSelfClosingElement(n))
|
|
19437
19752
|
checkOpening(n);
|
|
19438
19753
|
}
|
|
19439
|
-
if (
|
|
19754
|
+
if (ts29.isConditionalExpression(body)) {
|
|
19440
19755
|
checkJsxOperand(body.whenTrue);
|
|
19441
19756
|
checkJsxOperand(body.whenFalse);
|
|
19442
19757
|
return;
|
|
19443
19758
|
}
|
|
19444
|
-
if (
|
|
19759
|
+
if (ts29.isBinaryExpression(body) && (body.operatorToken.kind === ts29.SyntaxKind.AmpersandAmpersandToken || body.operatorToken.kind === ts29.SyntaxKind.BarBarToken || body.operatorToken.kind === ts29.SyntaxKind.QuestionQuestionToken)) {
|
|
19445
19760
|
checkJsxOperand(body.left);
|
|
19446
19761
|
checkJsxOperand(body.right);
|
|
19447
19762
|
return;
|
|
19448
19763
|
}
|
|
19449
|
-
if (
|
|
19764
|
+
if (ts29.isJsxElement(body)) {
|
|
19450
19765
|
checkOpening(body.openingElement);
|
|
19451
19766
|
return;
|
|
19452
19767
|
}
|
|
19453
|
-
if (
|
|
19768
|
+
if (ts29.isJsxSelfClosingElement(body)) {
|
|
19454
19769
|
checkOpening(body);
|
|
19455
19770
|
return;
|
|
19456
19771
|
}
|
|
19457
19772
|
}
|
|
19458
19773
|
function flatMapProjectionCall(body) {
|
|
19459
19774
|
let expr;
|
|
19460
|
-
if (
|
|
19775
|
+
if (ts29.isBlock(body)) {
|
|
19461
19776
|
const real = body.statements;
|
|
19462
|
-
if (real.length !== 1 || !
|
|
19777
|
+
if (real.length !== 1 || !ts29.isReturnStatement(real[0]) || !real[0].expression)
|
|
19463
19778
|
return null;
|
|
19464
19779
|
expr = real[0].expression;
|
|
19465
19780
|
} else {
|
|
19466
19781
|
expr = body;
|
|
19467
19782
|
}
|
|
19468
|
-
while (
|
|
19783
|
+
while (ts29.isParenthesizedExpression(expr))
|
|
19469
19784
|
expr = expr.expression;
|
|
19470
|
-
if (!
|
|
19785
|
+
if (!ts29.isCallExpression(expr))
|
|
19471
19786
|
return null;
|
|
19472
19787
|
if (!getMapLikeMethod(expr))
|
|
19473
19788
|
return null;
|
|
19474
19789
|
const cb = expr.arguments[0];
|
|
19475
|
-
if (!cb || !
|
|
19790
|
+
if (!cb || !ts29.isArrowFunction(cb) && !ts29.isFunctionExpression(cb))
|
|
19476
19791
|
return null;
|
|
19477
19792
|
for (const p of cb.parameters) {
|
|
19478
|
-
if (!
|
|
19793
|
+
if (!ts29.isIdentifier(p.name))
|
|
19479
19794
|
return null;
|
|
19480
19795
|
}
|
|
19481
19796
|
let innerBody = cb.body;
|
|
19482
|
-
if (
|
|
19483
|
-
const ret = innerBody.statements.find((s) =>
|
|
19797
|
+
if (ts29.isBlock(innerBody)) {
|
|
19798
|
+
const ret = innerBody.statements.find((s) => ts29.isReturnStatement(s) && s.expression != null);
|
|
19484
19799
|
if (innerBody.statements.length !== 1 || !ret?.expression)
|
|
19485
19800
|
return null;
|
|
19486
19801
|
innerBody = ret.expression;
|
|
19487
19802
|
}
|
|
19488
|
-
while (
|
|
19803
|
+
while (ts29.isParenthesizedExpression(innerBody))
|
|
19489
19804
|
innerBody = innerBody.expression;
|
|
19490
19805
|
const isElementish = (n) => {
|
|
19491
19806
|
let m = n;
|
|
19492
|
-
while (
|
|
19807
|
+
while (ts29.isParenthesizedExpression(m))
|
|
19493
19808
|
m = m.expression;
|
|
19494
|
-
if (
|
|
19809
|
+
if (ts29.isJsxElement(m) || ts29.isJsxSelfClosingElement(m))
|
|
19495
19810
|
return leafIsWirelessElement(m);
|
|
19496
|
-
if (
|
|
19811
|
+
if (ts29.isConditionalExpression(m))
|
|
19497
19812
|
return isElementish(m.whenTrue) && isElementish(m.whenFalse);
|
|
19498
19813
|
return false;
|
|
19499
19814
|
};
|
|
@@ -19506,19 +19821,19 @@ function leafIsWirelessElement(el) {
|
|
|
19506
19821
|
const visit3 = (n) => {
|
|
19507
19822
|
if (!ok)
|
|
19508
19823
|
return;
|
|
19509
|
-
if (
|
|
19824
|
+
if (ts29.isJsxOpeningElement(n) || ts29.isJsxSelfClosingElement(n)) {
|
|
19510
19825
|
const tagNode = n.tagName;
|
|
19511
|
-
const isIntrinsic =
|
|
19826
|
+
const isIntrinsic = ts29.isIdentifier(tagNode) ? !/^[A-Z]/.test(tagNode.text) : ts29.isJsxNamespacedName(tagNode);
|
|
19512
19827
|
if (!isIntrinsic) {
|
|
19513
19828
|
ok = false;
|
|
19514
19829
|
return;
|
|
19515
19830
|
}
|
|
19516
19831
|
for (const attr of n.attributes.properties) {
|
|
19517
|
-
if (
|
|
19832
|
+
if (ts29.isJsxSpreadAttribute(attr)) {
|
|
19518
19833
|
ok = false;
|
|
19519
19834
|
return;
|
|
19520
19835
|
}
|
|
19521
|
-
if (
|
|
19836
|
+
if (ts29.isJsxAttribute(attr)) {
|
|
19522
19837
|
const name = attr.name.getText();
|
|
19523
19838
|
if (isEventHandlerName(name)) {
|
|
19524
19839
|
ok = false;
|
|
@@ -19527,11 +19842,11 @@ function leafIsWirelessElement(el) {
|
|
|
19527
19842
|
}
|
|
19528
19843
|
}
|
|
19529
19844
|
}
|
|
19530
|
-
if (
|
|
19845
|
+
if (ts29.isCallExpression(n) && getMapLikeMethod(n) && containsJsxInExpression(n)) {
|
|
19531
19846
|
ok = false;
|
|
19532
19847
|
return;
|
|
19533
19848
|
}
|
|
19534
|
-
|
|
19849
|
+
ts29.forEachChild(n, visit3);
|
|
19535
19850
|
};
|
|
19536
19851
|
visit3(el);
|
|
19537
19852
|
return ok;
|
|
@@ -19795,13 +20110,13 @@ function resolveLoopSource(node, ctx, isClientOnly) {
|
|
|
19795
20110
|
return plan;
|
|
19796
20111
|
}
|
|
19797
20112
|
function entriesTupleBindings(pattern) {
|
|
19798
|
-
const elements = pattern.elements.filter((el) => !
|
|
20113
|
+
const elements = pattern.elements.filter((el) => !ts29.isOmittedExpression(el));
|
|
19799
20114
|
if (elements.length !== 2)
|
|
19800
20115
|
return null;
|
|
19801
20116
|
const [first, second] = elements;
|
|
19802
|
-
if (!
|
|
20117
|
+
if (!ts29.isBindingElement(first) || !ts29.isIdentifier(first.name))
|
|
19803
20118
|
return null;
|
|
19804
|
-
if (!
|
|
20119
|
+
if (!ts29.isBindingElement(second) || !ts29.isIdentifier(second.name))
|
|
19805
20120
|
return null;
|
|
19806
20121
|
return { index: first.name.text, param: second.name.text, itemTypeNode: second.name };
|
|
19807
20122
|
}
|
|
@@ -19830,7 +20145,7 @@ function resolveLoopRowParams(callback, source, ctx) {
|
|
|
19830
20145
|
if (firstParam.type) {
|
|
19831
20146
|
row.paramType = firstParam.type.getText(ctx.sourceFile);
|
|
19832
20147
|
}
|
|
19833
|
-
const tuple = isEntriesShape &&
|
|
20148
|
+
const tuple = isEntriesShape && ts29.isArrayBindingPattern(firstParam.name) ? entriesTupleBindings(firstParam.name) : null;
|
|
19834
20149
|
if (tuple) {
|
|
19835
20150
|
row.index = tuple.index;
|
|
19836
20151
|
row.param = tuple.param;
|
|
@@ -19849,10 +20164,10 @@ function resolveLoopRowParams(callback, source, ctx) {
|
|
|
19849
20164
|
return row;
|
|
19850
20165
|
}
|
|
19851
20166
|
function transformRenderableLogicalBody(expr, ctx, isClientOnly) {
|
|
19852
|
-
if (!
|
|
20167
|
+
if (!ts29.isBinaryExpression(expr))
|
|
19853
20168
|
return [];
|
|
19854
20169
|
const op = expr.operatorToken.kind;
|
|
19855
|
-
if (op !==
|
|
20170
|
+
if (op !== ts29.SyntaxKind.AmpersandAmpersandToken && op !== ts29.SyntaxKind.BarBarToken && op !== ts29.SyntaxKind.QuestionQuestionToken) {
|
|
19856
20171
|
return [];
|
|
19857
20172
|
}
|
|
19858
20173
|
if (!containsJsxInExpression(expr) && !callsJsxHelper(expr, ctx))
|
|
@@ -19862,17 +20177,17 @@ function transformRenderableLogicalBody(expr, ctx, isClientOnly) {
|
|
|
19862
20177
|
}
|
|
19863
20178
|
function transformLoopExpressionBody(body, ctx, isClientOnly, method) {
|
|
19864
20179
|
let inner = body;
|
|
19865
|
-
while (
|
|
20180
|
+
while (ts29.isParenthesizedExpression(inner)) {
|
|
19866
20181
|
inner = inner.expression;
|
|
19867
20182
|
}
|
|
19868
|
-
if (
|
|
20183
|
+
if (ts29.isJsxElement(inner) || ts29.isJsxSelfClosingElement(inner) || ts29.isJsxFragment(inner)) {
|
|
19869
20184
|
const transformed = transformNode(inner, ctx);
|
|
19870
20185
|
return transformed ? [transformed] : [];
|
|
19871
20186
|
}
|
|
19872
|
-
if (
|
|
20187
|
+
if (ts29.isConditionalExpression(inner)) {
|
|
19873
20188
|
return [transformConditional(inner, ctx)];
|
|
19874
20189
|
}
|
|
19875
|
-
if (method === "flatMap" &&
|
|
20190
|
+
if (method === "flatMap" && ts29.isArrayLiteralExpression(inner)) {
|
|
19876
20191
|
return transformArrayLiteralChildren(inner, ctx);
|
|
19877
20192
|
}
|
|
19878
20193
|
return transformRenderableLogicalBody(inner, ctx, isClientOnly);
|
|
@@ -19982,11 +20297,11 @@ function lowerValuePreamble(body, returnStmt, ctx, isClientOnly) {
|
|
|
19982
20297
|
}
|
|
19983
20298
|
function lowerSingleReturnLoopBody(body, returnStmt, ctx, isClientOnly) {
|
|
19984
20299
|
let returnExpr = returnStmt.expression;
|
|
19985
|
-
while (
|
|
20300
|
+
while (ts29.isParenthesizedExpression(returnExpr)) {
|
|
19986
20301
|
returnExpr = returnExpr.expression;
|
|
19987
20302
|
}
|
|
19988
20303
|
let children = [];
|
|
19989
|
-
if (
|
|
20304
|
+
if (ts29.isJsxElement(returnExpr) || ts29.isJsxSelfClosingElement(returnExpr) || ts29.isJsxFragment(returnExpr)) {
|
|
19990
20305
|
const transformed = transformNode(returnExpr, ctx);
|
|
19991
20306
|
if (transformed) {
|
|
19992
20307
|
children = [transformed];
|
|
@@ -20003,7 +20318,7 @@ function transformLoopBlockBody(body, callback, row, savedScope, ctx, isClientOn
|
|
|
20003
20318
|
out.children = multi.children;
|
|
20004
20319
|
out.preamble = multi.preamble;
|
|
20005
20320
|
}
|
|
20006
|
-
const returnStmt = out.children.length === 0 ? body.statements.find((s) =>
|
|
20321
|
+
const returnStmt = out.children.length === 0 ? body.statements.find((s) => ts29.isReturnStatement(s) && s.expression != null) : undefined;
|
|
20007
20322
|
if (returnStmt) {
|
|
20008
20323
|
const single = withPreambleRowScope(ctx, savedScope, row, body, returnStmt, () => lowerSingleReturnLoopBody(body, returnStmt, ctx, isClientOnly));
|
|
20009
20324
|
out.children = single.children;
|
|
@@ -20027,7 +20342,7 @@ function applyFlatMapFallbacks(out, callback, ctx, isClientOnly, method) {
|
|
|
20027
20342
|
}
|
|
20028
20343
|
}
|
|
20029
20344
|
}
|
|
20030
|
-
if (out.children.length === 0 && !out.flatMapCallback && !
|
|
20345
|
+
if (out.children.length === 0 && !out.flatMapCallback && !ts29.isBlock(body)) {
|
|
20031
20346
|
out.flatMapCallback = buildFlatMapCallback(callback, body, ctx);
|
|
20032
20347
|
}
|
|
20033
20348
|
if (!out.flatMapCallback)
|
|
@@ -20055,13 +20370,13 @@ function withLoopRowScope(ctx, row, fn) {
|
|
|
20055
20370
|
}
|
|
20056
20371
|
function transformLoopCallbackBody(callback, row, savedScope, ctx, isClientOnly, method) {
|
|
20057
20372
|
const body = callback.body;
|
|
20058
|
-
const out =
|
|
20373
|
+
const out = ts29.isBlock(body) ? transformLoopBlockBody(body, callback, row, savedScope, ctx, isClientOnly, method) : { children: transformLoopExpressionBody(body, ctx, isClientOnly, method), preamble: undefined, flatMapCallback: undefined };
|
|
20059
20374
|
applyFlatMapFallbacks(out, callback, ctx, isClientOnly, method);
|
|
20060
20375
|
return out;
|
|
20061
20376
|
}
|
|
20062
20377
|
function refuseUnloweredJsxCallback(node, ctx, method, diagCountAtEntry) {
|
|
20063
20378
|
const cb = node.arguments[0];
|
|
20064
|
-
const cbBody = cb && (
|
|
20379
|
+
const cbBody = cb && (ts29.isArrowFunction(cb) || ts29.isFunctionExpression(cb)) ? cb.body : undefined;
|
|
20065
20380
|
if (!cbBody || !containsJsxInExpression(cbBody))
|
|
20066
20381
|
return;
|
|
20067
20382
|
if (ctx.analyzer.errors.length !== diagCountAtEntry)
|
|
@@ -20170,7 +20485,7 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
|
|
|
20170
20485
|
const depth = ctx.loopDepth;
|
|
20171
20486
|
const source = resolveLoopSource(node, ctx, isClientOnly);
|
|
20172
20487
|
const callback = node.arguments[0];
|
|
20173
|
-
if (!
|
|
20488
|
+
if (!ts29.isArrowFunction(callback)) {
|
|
20174
20489
|
refuseUnloweredJsxCallback(node, ctx, method, diagCountAtEntry);
|
|
20175
20490
|
return null;
|
|
20176
20491
|
}
|
|
@@ -20231,12 +20546,12 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
|
|
|
20231
20546
|
function transformArrayLiteralChildren(arrayLiteral, ctx) {
|
|
20232
20547
|
const children = [];
|
|
20233
20548
|
for (const element of arrayLiteral.elements) {
|
|
20234
|
-
if (
|
|
20549
|
+
if (ts29.isSpreadElement(element))
|
|
20235
20550
|
continue;
|
|
20236
20551
|
let inner = element;
|
|
20237
|
-
while (
|
|
20552
|
+
while (ts29.isParenthesizedExpression(inner))
|
|
20238
20553
|
inner = inner.expression;
|
|
20239
|
-
if (
|
|
20554
|
+
if (ts29.isJsxElement(inner) || ts29.isJsxSelfClosingElement(inner) || ts29.isJsxFragment(inner)) {
|
|
20240
20555
|
const transformed = transformNode(inner, ctx);
|
|
20241
20556
|
if (transformed)
|
|
20242
20557
|
children.push(transformed);
|
|
@@ -20245,7 +20560,7 @@ function transformArrayLiteralChildren(arrayLiteral, ctx) {
|
|
|
20245
20560
|
return children;
|
|
20246
20561
|
}
|
|
20247
20562
|
function containsJsx(node) {
|
|
20248
|
-
if (
|
|
20563
|
+
if (ts29.isJsxElement(node) || ts29.isJsxSelfClosingElement(node) || ts29.isJsxFragment(node))
|
|
20249
20564
|
return true;
|
|
20250
20565
|
let found = false;
|
|
20251
20566
|
node.forEachChild((child) => {
|
|
@@ -20262,12 +20577,12 @@ function buildFlatMapCallback(callback, body, ctx) {
|
|
|
20262
20577
|
const leafKeyAttrs = [];
|
|
20263
20578
|
let refusalNode;
|
|
20264
20579
|
const collectJsx = (n, underTemplate) => {
|
|
20265
|
-
if (
|
|
20580
|
+
if (ts29.isJsxElement(n) || ts29.isJsxSelfClosingElement(n) || ts29.isJsxFragment(n)) {
|
|
20266
20581
|
if (underTemplate)
|
|
20267
20582
|
refusalNode ??= n;
|
|
20268
20583
|
leafSpans.push({ start: n.getStart(ctx.sourceFile), end: n.getEnd() });
|
|
20269
|
-
if (!
|
|
20270
|
-
const keyAttr = findKeyJsxAttribute(
|
|
20584
|
+
if (!ts29.isJsxFragment(n)) {
|
|
20585
|
+
const keyAttr = findKeyJsxAttribute(ts29.isJsxElement(n) ? n.openingElement : n);
|
|
20271
20586
|
if (keyAttr)
|
|
20272
20587
|
leafKeyAttrs.push(keyAttr);
|
|
20273
20588
|
}
|
|
@@ -20275,7 +20590,7 @@ function buildFlatMapCallback(callback, body, ctx) {
|
|
|
20275
20590
|
leafIrs.push(ir ?? { type: "text", value: "", loc: getSourceLocation(n, ctx.sourceFile, ctx.filePath) });
|
|
20276
20591
|
return;
|
|
20277
20592
|
}
|
|
20278
|
-
const inTemplate = underTemplate ||
|
|
20593
|
+
const inTemplate = underTemplate || ts29.isTemplateExpression(n) || ts29.isTaggedTemplateExpression(n);
|
|
20279
20594
|
n.forEachChild((c) => collectJsx(c, inTemplate));
|
|
20280
20595
|
};
|
|
20281
20596
|
collectJsx(body, false);
|
|
@@ -20331,7 +20646,7 @@ function flatMapRawBodyWithLeafKeys(body, leafKeyAttrs, sourceFile) {
|
|
|
20331
20646
|
const bodyStart = body.getStart(sourceFile);
|
|
20332
20647
|
const insertions = leafKeyAttrs.map((attr) => {
|
|
20333
20648
|
const init = attr.initializer;
|
|
20334
|
-
const keyText = init === undefined ? "true" :
|
|
20649
|
+
const keyText = init === undefined ? "true" : ts29.isJsxExpression(init) ? init.expression?.getText(sourceFile) ?? "undefined" : init.getText(sourceFile);
|
|
20335
20650
|
return { at: attr.getEnd() - bodyStart, text: ` ${BF_KEY2}={String(${keyText})}` };
|
|
20336
20651
|
}).sort((a, b) => a.at - b.at);
|
|
20337
20652
|
let out = "";
|
|
@@ -20513,35 +20828,35 @@ function attrValueText(value) {
|
|
|
20513
20828
|
}
|
|
20514
20829
|
return out.join(" ");
|
|
20515
20830
|
}
|
|
20516
|
-
function
|
|
20517
|
-
if (
|
|
20831
|
+
function collectBindingNames3(name, out) {
|
|
20832
|
+
if (ts29.isIdentifier(name)) {
|
|
20518
20833
|
out.add(name.text);
|
|
20519
20834
|
return;
|
|
20520
20835
|
}
|
|
20521
20836
|
for (const el of name.elements) {
|
|
20522
|
-
if (
|
|
20523
|
-
|
|
20837
|
+
if (ts29.isBindingElement(el))
|
|
20838
|
+
collectBindingNames3(el.name, out);
|
|
20524
20839
|
}
|
|
20525
20840
|
}
|
|
20526
20841
|
function collectPreambleDeclaredNames(stmt, out) {
|
|
20527
|
-
if (
|
|
20842
|
+
if (ts29.isVariableStatement(stmt)) {
|
|
20528
20843
|
for (const decl of stmt.declarationList.declarations) {
|
|
20529
|
-
|
|
20844
|
+
collectBindingNames3(decl.name, out);
|
|
20530
20845
|
}
|
|
20531
|
-
} else if (
|
|
20846
|
+
} else if (ts29.isFunctionDeclaration(stmt) && stmt.name) {
|
|
20532
20847
|
out.add(stmt.name.text);
|
|
20533
20848
|
}
|
|
20534
20849
|
}
|
|
20535
20850
|
function computePreambleReactiveNames(statements, ctx) {
|
|
20536
20851
|
const reactiveNames = new Set;
|
|
20537
20852
|
for (const stmt of statements) {
|
|
20538
|
-
if (!
|
|
20853
|
+
if (!ts29.isVariableStatement(stmt))
|
|
20539
20854
|
continue;
|
|
20540
20855
|
for (const decl of stmt.declarationList.declarations) {
|
|
20541
20856
|
if (!decl.initializer)
|
|
20542
20857
|
continue;
|
|
20543
20858
|
const boundNames = new Set;
|
|
20544
|
-
|
|
20859
|
+
collectBindingNames3(decl.name, boundNames);
|
|
20545
20860
|
const initText = ctx.getJS(decl.initializer);
|
|
20546
20861
|
const initFreeRefs = extractFreeIdentifiersFromNode(decl.initializer);
|
|
20547
20862
|
const readsEarlierReactive = [...initFreeRefs].some((r) => reactiveNames.has(r));
|
|
@@ -20581,10 +20896,10 @@ function preambleFromValueStatements(statements, ctx, bodyStatements) {
|
|
|
20581
20896
|
function neutralPreambleDeclarations(statements, ctx, bodyStatements) {
|
|
20582
20897
|
const out = [];
|
|
20583
20898
|
for (const stmt of statements) {
|
|
20584
|
-
if (!
|
|
20899
|
+
if (!ts29.isVariableStatement(stmt))
|
|
20585
20900
|
return null;
|
|
20586
20901
|
for (const decl of stmt.declarationList.declarations) {
|
|
20587
|
-
if (!
|
|
20902
|
+
if (!ts29.isIdentifier(decl.name))
|
|
20588
20903
|
return null;
|
|
20589
20904
|
if (!decl.initializer)
|
|
20590
20905
|
return null;
|
|
@@ -20606,22 +20921,22 @@ function neutralPreambleDeclarations(statements, ctx, bodyStatements) {
|
|
|
20606
20921
|
return out;
|
|
20607
20922
|
}
|
|
20608
20923
|
function isFunctionLiteral(node) {
|
|
20609
|
-
return
|
|
20924
|
+
return ts29.isArrowFunction(node) || ts29.isFunctionExpression(node);
|
|
20610
20925
|
}
|
|
20611
20926
|
function everyReadIsEventHandlerPropValue(name, bodyStatements) {
|
|
20612
20927
|
const findDisallowedRead = (node) => {
|
|
20613
|
-
if (
|
|
20614
|
-
const isBindingName =
|
|
20615
|
-
const isPropertyName2 =
|
|
20928
|
+
if (ts29.isIdentifier(node) && node.text === name) {
|
|
20929
|
+
const isBindingName = ts29.isVariableDeclaration(node.parent) && node.parent.name === node;
|
|
20930
|
+
const isPropertyName2 = ts29.isPropertyAccessExpression(node.parent) && node.parent.name === node;
|
|
20616
20931
|
if (!isBindingName && !isPropertyName2) {
|
|
20617
20932
|
const jsxExpr = node.parent;
|
|
20618
20933
|
const attr = jsxExpr.parent;
|
|
20619
|
-
const isEventHandlerAttrValue =
|
|
20934
|
+
const isEventHandlerAttrValue = ts29.isJsxExpression(jsxExpr) && ts29.isJsxAttribute(attr) && attr.initializer === jsxExpr && ts29.isIdentifier(attr.name) && isEventHandlerName(attr.name.text);
|
|
20620
20935
|
if (!isEventHandlerAttrValue)
|
|
20621
20936
|
return true;
|
|
20622
20937
|
}
|
|
20623
20938
|
}
|
|
20624
|
-
return
|
|
20939
|
+
return ts29.forEachChild(node, findDisallowedRead);
|
|
20625
20940
|
};
|
|
20626
20941
|
return !bodyStatements.some(findDisallowedRead);
|
|
20627
20942
|
}
|
|
@@ -20642,11 +20957,11 @@ function buildPreambleSegments(statements, returnStmt, ctx) {
|
|
|
20642
20957
|
let refusalNode;
|
|
20643
20958
|
const recordBuilderTarget = (leaf, stmt) => {
|
|
20644
20959
|
for (let n = leaf.parent;n && n !== stmt.parent; n = n.parent) {
|
|
20645
|
-
if (
|
|
20960
|
+
if (ts29.isCallExpression(n) && ts29.isPropertyAccessExpression(n.expression) && (n.expression.name.text === "push" || n.expression.name.text === "unshift") && ts29.isIdentifier(n.expression.expression)) {
|
|
20646
20961
|
builders.add(n.expression.expression.text);
|
|
20647
20962
|
return;
|
|
20648
20963
|
}
|
|
20649
|
-
if (
|
|
20964
|
+
if (ts29.isVariableDeclaration(n) && ts29.isIdentifier(n.name)) {
|
|
20650
20965
|
builders.add(n.name.text);
|
|
20651
20966
|
return;
|
|
20652
20967
|
}
|
|
@@ -20659,7 +20974,7 @@ function buildPreambleSegments(statements, returnStmt, ctx) {
|
|
|
20659
20974
|
const leafSpans = [];
|
|
20660
20975
|
const leafIrs = [];
|
|
20661
20976
|
const collect = (n, underTemplate) => {
|
|
20662
|
-
if (
|
|
20977
|
+
if (ts29.isJsxElement(n) || ts29.isJsxSelfClosingElement(n) || ts29.isJsxFragment(n)) {
|
|
20663
20978
|
if (underTemplate)
|
|
20664
20979
|
refusalNode ??= n;
|
|
20665
20980
|
recordBuilderTarget(n, stmt);
|
|
@@ -20670,7 +20985,7 @@ function buildPreambleSegments(statements, returnStmt, ctx) {
|
|
|
20670
20985
|
leafIrs.push(ir ?? { type: "text", value: "", loc: getSourceLocation(n, ctx.sourceFile, ctx.filePath) });
|
|
20671
20986
|
return;
|
|
20672
20987
|
}
|
|
20673
|
-
const inTemplate = underTemplate ||
|
|
20988
|
+
const inTemplate = underTemplate || ts29.isTemplateExpression(n) || ts29.isTaggedTemplateExpression(n);
|
|
20674
20989
|
n.forEachChild((c) => collect(c, inTemplate));
|
|
20675
20990
|
};
|
|
20676
20991
|
collect(stmt, false);
|
|
@@ -20796,9 +21111,9 @@ function closedRestSpreadSource(attr, ctx) {
|
|
|
20796
21111
|
if (ctx.analyzer.restPropsExpandedKeys.length === 0 || !restName || ctx.scope.isBound(restName))
|
|
20797
21112
|
return null;
|
|
20798
21113
|
let expr = attr.expression;
|
|
20799
|
-
while (
|
|
21114
|
+
while (ts29.isParenthesizedExpression(expr))
|
|
20800
21115
|
expr = expr.expression;
|
|
20801
|
-
if (!
|
|
21116
|
+
if (!ts29.isIdentifier(expr) || !isRestBinding(expr.text, restName, ctx))
|
|
20802
21117
|
return null;
|
|
20803
21118
|
const source = ctx.analyzer.restPropsOmittedKeys && ctx.analyzer.propsObjectName ? ctx.analyzer.propsObjectName : restName;
|
|
20804
21119
|
return source !== restName && ctx.scope.isBound(source) ? null : source;
|
|
@@ -20818,9 +21133,9 @@ function refuseBodyRestSpreadUnderShadowedProps(attr, ctx) {
|
|
|
20818
21133
|
if (ctx.scope.isBound(restName) || !ctx.scope.isBound(propsName))
|
|
20819
21134
|
return false;
|
|
20820
21135
|
let expr = attr.expression;
|
|
20821
|
-
while (
|
|
21136
|
+
while (ts29.isParenthesizedExpression(expr))
|
|
20822
21137
|
expr = expr.expression;
|
|
20823
|
-
if (!
|
|
21138
|
+
if (!ts29.isIdentifier(expr) || !isRestBinding(expr.text, restName, ctx))
|
|
20824
21139
|
return false;
|
|
20825
21140
|
ctx.analyzer.errors.push({
|
|
20826
21141
|
code: "BF101",
|
|
@@ -20836,13 +21151,13 @@ function closedRestFallbacks(properties, entries, ctx) {
|
|
|
20836
21151
|
const dropped = new Set;
|
|
20837
21152
|
const lastWrite = new Map;
|
|
20838
21153
|
for (const attr of properties) {
|
|
20839
|
-
if (
|
|
21154
|
+
if (ts29.isJsxAttribute(attr)) {
|
|
20840
21155
|
const name = attr.name.getText(ctx.sourceFile);
|
|
20841
21156
|
if (name !== "ref" && name !== "key" && !isEventHandlerName(name))
|
|
20842
21157
|
lastWrite.set(name, { attr, value: attrValueFallback(attr, ctx) });
|
|
20843
21158
|
continue;
|
|
20844
21159
|
}
|
|
20845
|
-
if (!
|
|
21160
|
+
if (!ts29.isJsxSpreadAttribute(attr))
|
|
20846
21161
|
continue;
|
|
20847
21162
|
const constEntries = entries.get(attr);
|
|
20848
21163
|
const source = constEntries ? null : closedRestSpreadSource(attr, ctx);
|
|
@@ -20895,14 +21210,14 @@ function attrValueFallback(attr, ctx) {
|
|
|
20895
21210
|
const value = attr.initializer;
|
|
20896
21211
|
if (value === undefined)
|
|
20897
21212
|
return { text: "true", templateText: "true", freeIdentifiers: new Set };
|
|
20898
|
-
if (
|
|
21213
|
+
if (ts29.isStringLiteral(value)) {
|
|
20899
21214
|
const text = JSON.stringify(value.text);
|
|
20900
21215
|
return { text, templateText: text, freeIdentifiers: new Set };
|
|
20901
21216
|
}
|
|
20902
|
-
if (!
|
|
21217
|
+
if (!ts29.isJsxExpression(value) || value.expression === undefined)
|
|
20903
21218
|
return null;
|
|
20904
21219
|
const expr = unwrapTransparentTsWrappers(value.expression);
|
|
20905
|
-
if (
|
|
21220
|
+
if (ts29.isJsxElement(expr) || ts29.isJsxSelfClosingElement(expr) || ts29.isJsxFragment(expr))
|
|
20906
21221
|
return null;
|
|
20907
21222
|
return {
|
|
20908
21223
|
text: ctx.getJS(value.expression),
|
|
@@ -20915,7 +21230,7 @@ function staticSpreadPlan(attributes, ctx) {
|
|
|
20915
21230
|
const overridden = new Set;
|
|
20916
21231
|
const written = new Set;
|
|
20917
21232
|
for (const attr of [...attributes.properties].reverse()) {
|
|
20918
|
-
if (
|
|
21233
|
+
if (ts29.isJsxAttribute(attr)) {
|
|
20919
21234
|
const name = attr.name.getText(ctx.sourceFile);
|
|
20920
21235
|
if (written.has(name))
|
|
20921
21236
|
overridden.add(attr);
|
|
@@ -20929,49 +21244,49 @@ function staticSpreadPlan(attributes, ctx) {
|
|
|
20929
21244
|
for (const e of spread)
|
|
20930
21245
|
written.add(e.key);
|
|
20931
21246
|
}
|
|
20932
|
-
if ([...overridden].some((attr) => !
|
|
21247
|
+
if ([...overridden].some((attr) => !ts29.isJsxAttribute(attr) || !isEffectFreeAttrValue(attr.initializer))) {
|
|
20933
21248
|
return { properties: [...attributes.properties], entries: new Map };
|
|
20934
21249
|
}
|
|
20935
21250
|
return { properties: attributes.properties.filter((attr) => !overridden.has(attr)), entries };
|
|
20936
21251
|
}
|
|
20937
21252
|
function isEffectFreeAttrValue(value) {
|
|
20938
|
-
if (value === undefined ||
|
|
21253
|
+
if (value === undefined || ts29.isStringLiteral(value))
|
|
20939
21254
|
return true;
|
|
20940
|
-
if (!
|
|
21255
|
+
if (!ts29.isJsxExpression(value))
|
|
20941
21256
|
return false;
|
|
20942
21257
|
return value.expression === undefined || isEffectFreeExpression(value.expression);
|
|
20943
21258
|
}
|
|
20944
21259
|
function isReadOnlyAttrValue(value) {
|
|
20945
21260
|
if (isEffectFreeAttrValue(value))
|
|
20946
21261
|
return true;
|
|
20947
|
-
if (value === undefined || !
|
|
21262
|
+
if (value === undefined || !ts29.isJsxExpression(value) || value.expression === undefined)
|
|
20948
21263
|
return false;
|
|
20949
21264
|
let expr = value.expression;
|
|
20950
|
-
while (
|
|
21265
|
+
while (ts29.isParenthesizedExpression(expr) || ts29.isPropertyAccessExpression(expr))
|
|
20951
21266
|
expr = expr.expression;
|
|
20952
|
-
return
|
|
21267
|
+
return ts29.isIdentifier(expr);
|
|
20953
21268
|
}
|
|
20954
21269
|
function isEffectFreeExpression(expr) {
|
|
20955
|
-
if (
|
|
21270
|
+
if (ts29.isParenthesizedExpression(expr))
|
|
20956
21271
|
return isEffectFreeExpression(expr.expression);
|
|
20957
|
-
if (
|
|
21272
|
+
if (ts29.isStringLiteral(expr) || ts29.isNumericLiteral(expr) || ts29.isNoSubstitutionTemplateLiteral(expr) || ts29.isIdentifier(expr))
|
|
20958
21273
|
return true;
|
|
20959
|
-
if (expr.kind ===
|
|
21274
|
+
if (expr.kind === ts29.SyntaxKind.TrueKeyword || expr.kind === ts29.SyntaxKind.FalseKeyword || expr.kind === ts29.SyntaxKind.NullKeyword)
|
|
20960
21275
|
return true;
|
|
20961
|
-
if (
|
|
20962
|
-
return
|
|
21276
|
+
if (ts29.isPrefixUnaryExpression(expr) && expr.operator === ts29.SyntaxKind.MinusToken)
|
|
21277
|
+
return ts29.isNumericLiteral(expr.operand);
|
|
20963
21278
|
return false;
|
|
20964
21279
|
}
|
|
20965
21280
|
function expandStaticConstSpread(attr, ctx) {
|
|
20966
21281
|
const init = staticConstInitializerOf(attr.expression, ctx);
|
|
20967
|
-
if (!init || !
|
|
21282
|
+
if (!init || !ts29.isObjectLiteralExpression(init))
|
|
20968
21283
|
return null;
|
|
20969
21284
|
return staticObjectSpreadEntries(init);
|
|
20970
21285
|
}
|
|
20971
21286
|
function staticConstInitializerOf(expr, ctx) {
|
|
20972
|
-
while (
|
|
21287
|
+
while (ts29.isParenthesizedExpression(expr))
|
|
20973
21288
|
expr = expr.expression;
|
|
20974
|
-
if (!
|
|
21289
|
+
if (!ts29.isIdentifier(expr))
|
|
20975
21290
|
return null;
|
|
20976
21291
|
const name = expr.text;
|
|
20977
21292
|
const constant = resolveStaticConstBinding(name, ctx.analyzer.localConstants, (n) => ctx.scope.isBound(n));
|
|
@@ -20981,12 +21296,12 @@ function staticConstInitializerOf(expr, ctx) {
|
|
|
20981
21296
|
if (constant.isModule && componentScopeNames(ctx.analyzer).has(name))
|
|
20982
21297
|
return null;
|
|
20983
21298
|
const init = parseConstInitializer(constant);
|
|
20984
|
-
if (!init || !(
|
|
21299
|
+
if (!init || !(ts29.isObjectLiteralExpression(init) || ts29.isArrayLiteralExpression(init)))
|
|
20985
21300
|
return null;
|
|
20986
21301
|
return init;
|
|
20987
21302
|
}
|
|
20988
21303
|
function withStaticConstLiteral(value, attr, ctx) {
|
|
20989
|
-
if (value.kind !== "expression" || !attr.initializer || !
|
|
21304
|
+
if (value.kind !== "expression" || !attr.initializer || !ts29.isJsxExpression(attr.initializer) || !attr.initializer.expression)
|
|
20990
21305
|
return value;
|
|
20991
21306
|
const init = staticConstInitializerOf(attr.initializer.expression, ctx);
|
|
20992
21307
|
if (!init)
|
|
@@ -20999,9 +21314,9 @@ function withStaticConstLiteral(value, attr, ctx) {
|
|
|
20999
21314
|
function staticObjectSpreadEntries(init) {
|
|
21000
21315
|
const entries = new Map;
|
|
21001
21316
|
for (const prop of init.properties) {
|
|
21002
|
-
if (!
|
|
21317
|
+
if (!ts29.isPropertyAssignment(prop))
|
|
21003
21318
|
return null;
|
|
21004
|
-
const key =
|
|
21319
|
+
const key = ts29.isIdentifier(prop.name) || ts29.isStringLiteral(prop.name) ? prop.name.text : null;
|
|
21005
21320
|
if (key === null || key === "key" || key === "ref" || isEventHandlerName(key))
|
|
21006
21321
|
return null;
|
|
21007
21322
|
if (freeIdentifiers(tsNodeToParsedExpr(prop.initializer))?.size !== 0)
|
|
@@ -21015,9 +21330,9 @@ function spreadShadowsPropsObject(attr, ctx) {
|
|
|
21015
21330
|
if (propsName === null)
|
|
21016
21331
|
return false;
|
|
21017
21332
|
let expr = attr.expression;
|
|
21018
|
-
while (
|
|
21333
|
+
while (ts29.isParenthesizedExpression(expr))
|
|
21019
21334
|
expr = expr.expression;
|
|
21020
|
-
return
|
|
21335
|
+
return ts29.isIdentifier(expr) && expr.text === propsName && ctx.scope.isBound(propsName);
|
|
21021
21336
|
}
|
|
21022
21337
|
function callerBagOfSpread(value, ctx) {
|
|
21023
21338
|
const constants = constantValuesByName(ctx);
|
|
@@ -21031,13 +21346,13 @@ function callerBagOfSpread(value, ctx) {
|
|
|
21031
21346
|
return;
|
|
21032
21347
|
}
|
|
21033
21348
|
function attrFreeIdentifiers(attr) {
|
|
21034
|
-
if (!attr.initializer || !
|
|
21349
|
+
if (!attr.initializer || !ts29.isJsxExpression(attr.initializer) || !attr.initializer.expression) {
|
|
21035
21350
|
return;
|
|
21036
21351
|
}
|
|
21037
21352
|
return extractFreeIdentifiersFromNode(attr.initializer.expression);
|
|
21038
21353
|
}
|
|
21039
21354
|
function computeReactivityFlags(attr, ctx) {
|
|
21040
|
-
if (!attr.initializer || !
|
|
21355
|
+
if (!attr.initializer || !ts29.isJsxExpression(attr.initializer) || !attr.initializer.expression) {
|
|
21041
21356
|
return {};
|
|
21042
21357
|
}
|
|
21043
21358
|
const expr = attr.initializer.expression;
|
|
@@ -21047,7 +21362,7 @@ function computeReactivityFlags(attr, ctx) {
|
|
|
21047
21362
|
};
|
|
21048
21363
|
}
|
|
21049
21364
|
function eventHandlerText(handlerExpr, ctx) {
|
|
21050
|
-
const isSequence =
|
|
21365
|
+
const isSequence = ts29.isBinaryExpression(handlerExpr) && handlerExpr.operatorToken.kind === ts29.SyntaxKind.CommaToken;
|
|
21051
21366
|
return isSequence ? `(${ctx.getJS(handlerExpr)})` : ctx.getJS(handlerExpr);
|
|
21052
21367
|
}
|
|
21053
21368
|
function reportJsxBranchLocalInCallback(expr, ctx) {
|
|
@@ -21071,16 +21386,16 @@ function processAttributes(attributes, ctx) {
|
|
|
21071
21386
|
const spreadPlan = staticSpreadPlan(attributes, ctx);
|
|
21072
21387
|
const restPlan = closedRestFallbacks(spreadPlan.properties, spreadPlan.entries, ctx);
|
|
21073
21388
|
for (const attr of restPlan.properties) {
|
|
21074
|
-
if (
|
|
21389
|
+
if (ts29.isJsxSpreadAttribute(attr)) {
|
|
21075
21390
|
hasSpread = true;
|
|
21076
21391
|
attrs.push(...expandSpreadAttribute(attr, ctx, spreadPlan.entries.get(attr), restPlan.fallbacks.get(attr)));
|
|
21077
21392
|
continue;
|
|
21078
21393
|
}
|
|
21079
|
-
if (!
|
|
21394
|
+
if (!ts29.isJsxAttribute(attr))
|
|
21080
21395
|
continue;
|
|
21081
21396
|
const rawName = attr.name.getText(ctx.sourceFile);
|
|
21082
21397
|
if (rawName === "ref") {
|
|
21083
|
-
if (attr.initializer &&
|
|
21398
|
+
if (attr.initializer && ts29.isJsxExpression(attr.initializer) && attr.initializer.expression) {
|
|
21084
21399
|
reportJsxBranchLocalInCallback(attr.initializer.expression, ctx);
|
|
21085
21400
|
ref = ctx.getJS(attr.initializer.expression);
|
|
21086
21401
|
refExpr = attr.initializer.expression;
|
|
@@ -21088,7 +21403,7 @@ function processAttributes(attributes, ctx) {
|
|
|
21088
21403
|
continue;
|
|
21089
21404
|
}
|
|
21090
21405
|
if (isEventHandlerName(rawName)) {
|
|
21091
|
-
if (attr.initializer &&
|
|
21406
|
+
if (attr.initializer && ts29.isJsxExpression(attr.initializer) && attr.initializer.expression) {
|
|
21092
21407
|
const handlerExpr = attr.initializer.expression;
|
|
21093
21408
|
reportJsxBranchLocalInCallback(handlerExpr, ctx);
|
|
21094
21409
|
events.push({
|
|
@@ -21103,7 +21418,7 @@ function processAttributes(attributes, ctx) {
|
|
|
21103
21418
|
const name = toHTMLAttrName(rawName);
|
|
21104
21419
|
let value = getAttributeValue(attr, ctx);
|
|
21105
21420
|
let clientOnly;
|
|
21106
|
-
if (attr.initializer &&
|
|
21421
|
+
if (attr.initializer && ts29.isJsxExpression(attr.initializer) && attr.initializer.expression) {
|
|
21107
21422
|
if (value.kind === "expression" && value.templateExpr === undefined) {
|
|
21108
21423
|
const rewritten = rewriteBarePropRefs2(value.expr, attr.initializer.expression, ctx);
|
|
21109
21424
|
if (rewritten !== value.expr) {
|
|
@@ -21201,14 +21516,14 @@ function collectMountAttrWrites(body, param, ctx) {
|
|
|
21201
21516
|
const scan = (node) => {
|
|
21202
21517
|
let exits = false;
|
|
21203
21518
|
const visit3 = (n) => {
|
|
21204
|
-
if (
|
|
21519
|
+
if (ts29.isFunctionLike(n) || ts29.isClassLike(n))
|
|
21205
21520
|
return;
|
|
21206
|
-
if (
|
|
21521
|
+
if (ts29.isReturnStatement(n) || ts29.isThrowStatement(n))
|
|
21207
21522
|
exits = true;
|
|
21208
21523
|
const effect = matchRefAttrEffect(n, param);
|
|
21209
21524
|
if (effect?.kind === "remove")
|
|
21210
21525
|
live.delete(effect.name);
|
|
21211
|
-
|
|
21526
|
+
ts29.forEachChild(n, visit3);
|
|
21212
21527
|
};
|
|
21213
21528
|
visit3(node);
|
|
21214
21529
|
return exits;
|
|
@@ -21216,9 +21531,9 @@ function collectMountAttrWrites(body, param, ctx) {
|
|
|
21216
21531
|
const run = (fnBody, allowNested) => {
|
|
21217
21532
|
if (findScopeDeclaration(param, fnBody))
|
|
21218
21533
|
return true;
|
|
21219
|
-
const units =
|
|
21534
|
+
const units = ts29.isBlock(fnBody) ? fnBody.statements : [fnBody];
|
|
21220
21535
|
for (const unit of units) {
|
|
21221
|
-
const expr =
|
|
21536
|
+
const expr = ts29.isExpressionStatement(unit) ? unit.expression : ts29.isExpression(unit) ? unit : undefined;
|
|
21222
21537
|
const effect = expr && matchRefAttrEffect(expr, param);
|
|
21223
21538
|
if (effect) {
|
|
21224
21539
|
apply(effect);
|
|
@@ -21235,50 +21550,50 @@ function collectMountAttrWrites(body, param, ctx) {
|
|
|
21235
21550
|
}
|
|
21236
21551
|
function mountCallbackBody(expr, param, ctx) {
|
|
21237
21552
|
const call = unwrapTransparentTsWrappers(expr);
|
|
21238
|
-
if (!
|
|
21553
|
+
if (!ts29.isCallExpression(call) || !ts29.isIdentifier(call.expression))
|
|
21239
21554
|
return;
|
|
21240
21555
|
const primitive = clientValueImports(ctx).get(call.expression.text);
|
|
21241
21556
|
if (!primitive || !MOUNT_TIME_PRIMITIVES.has(primitive))
|
|
21242
21557
|
return;
|
|
21243
21558
|
const fn = call.arguments[0] && unwrapTransparentTsWrappers(call.arguments[0]);
|
|
21244
|
-
if (!fn || !(
|
|
21559
|
+
if (!fn || !(ts29.isArrowFunction(fn) || ts29.isFunctionExpression(fn)))
|
|
21245
21560
|
return;
|
|
21246
21561
|
if (fn.parameters.some((p) => bindingDeclares(p.name, param)))
|
|
21247
21562
|
return;
|
|
21248
21563
|
return fn.body;
|
|
21249
21564
|
}
|
|
21250
21565
|
function matchRefAttrEffect(node, param) {
|
|
21251
|
-
if (!
|
|
21566
|
+
if (!ts29.isExpression(node))
|
|
21252
21567
|
return;
|
|
21253
21568
|
const expr = unwrapTransparentTsWrappers(node);
|
|
21254
|
-
if (
|
|
21569
|
+
if (ts29.isCallExpression(expr)) {
|
|
21255
21570
|
const callee = expr.expression;
|
|
21256
|
-
if (!
|
|
21571
|
+
if (!ts29.isPropertyAccessExpression(callee))
|
|
21257
21572
|
return;
|
|
21258
21573
|
const kind = callee.name.text === "setAttribute" ? "set" : callee.name.text === "removeAttribute" ? "remove" : undefined;
|
|
21259
21574
|
const [nameArg] = expr.arguments;
|
|
21260
|
-
if (kind && nameArg &&
|
|
21575
|
+
if (kind && nameArg && ts29.isStringLiteralLike(nameArg) && isParamReference(callee.expression, param)) {
|
|
21261
21576
|
return { kind, name: nameArg.text.toLowerCase(), node: expr };
|
|
21262
21577
|
}
|
|
21263
21578
|
return;
|
|
21264
21579
|
}
|
|
21265
|
-
const target =
|
|
21580
|
+
const target = ts29.isBinaryExpression(expr) && expr.operatorToken.kind === ts29.SyntaxKind.EqualsToken ? { kind: "set", lhs: expr.left } : ts29.isDeleteExpression(expr) ? { kind: "remove", lhs: expr.expression } : undefined;
|
|
21266
21581
|
const name = target && datasetAttrName(target.lhs, param);
|
|
21267
21582
|
return name ? { kind: target.kind, name, node: expr } : undefined;
|
|
21268
21583
|
}
|
|
21269
21584
|
function datasetAttrName(target, param) {
|
|
21270
21585
|
const access = unwrapTransparentTsWrappers(target);
|
|
21271
|
-
const key =
|
|
21586
|
+
const key = ts29.isPropertyAccessExpression(access) ? access.name.text : ts29.isElementAccessExpression(access) && ts29.isStringLiteralLike(access.argumentExpression) ? access.argumentExpression.text : undefined;
|
|
21272
21587
|
if (key === undefined)
|
|
21273
21588
|
return;
|
|
21274
21589
|
const dataset = unwrapTransparentTsWrappers(access.expression);
|
|
21275
|
-
if (!
|
|
21590
|
+
if (!ts29.isPropertyAccessExpression(dataset) || dataset.name.text !== "dataset")
|
|
21276
21591
|
return;
|
|
21277
21592
|
return isParamReference(dataset.expression, param) ? datasetKeyToAttrName(key) : undefined;
|
|
21278
21593
|
}
|
|
21279
21594
|
function isParamReference(expr, param) {
|
|
21280
21595
|
const inner = unwrapTransparentTsWrappers(expr);
|
|
21281
|
-
return
|
|
21596
|
+
return ts29.isIdentifier(inner) && inner.text === param;
|
|
21282
21597
|
}
|
|
21283
21598
|
function datasetKeyToAttrName(key) {
|
|
21284
21599
|
let out = "data-";
|
|
@@ -21289,21 +21604,21 @@ function datasetKeyToAttrName(key) {
|
|
|
21289
21604
|
}
|
|
21290
21605
|
function resolveRefCallback(refExpr) {
|
|
21291
21606
|
const expr = unwrapTransparentTsWrappers(refExpr);
|
|
21292
|
-
if (
|
|
21607
|
+
if (ts29.isArrowFunction(expr) || ts29.isFunctionExpression(expr)) {
|
|
21293
21608
|
return { param: firstSimpleParamName(expr), body: expr.body, named: false };
|
|
21294
21609
|
}
|
|
21295
|
-
if (!
|
|
21610
|
+
if (!ts29.isIdentifier(expr))
|
|
21296
21611
|
return;
|
|
21297
21612
|
const callback = findNamedCallback(expr);
|
|
21298
21613
|
return callback && { ...callback, named: true };
|
|
21299
21614
|
}
|
|
21300
|
-
function
|
|
21301
|
-
return
|
|
21615
|
+
function isFunctionLike2(node) {
|
|
21616
|
+
return ts29.isArrowFunction(node) || ts29.isFunctionExpression(node) || ts29.isFunctionDeclaration(node);
|
|
21302
21617
|
}
|
|
21303
21618
|
function findEnclosingFunctionLike(node) {
|
|
21304
21619
|
let current = node.parent;
|
|
21305
21620
|
while (current) {
|
|
21306
|
-
if (
|
|
21621
|
+
if (isFunctionLike2(current))
|
|
21307
21622
|
return current;
|
|
21308
21623
|
current = current.parent;
|
|
21309
21624
|
}
|
|
@@ -21321,34 +21636,34 @@ function findNamedCallback(ident) {
|
|
|
21321
21636
|
return;
|
|
21322
21637
|
}
|
|
21323
21638
|
function localCallbackOf(decl) {
|
|
21324
|
-
if (
|
|
21639
|
+
if (ts29.isFunctionDeclaration(decl))
|
|
21325
21640
|
return decl.body && { param: firstSimpleParamName(decl), body: decl.body };
|
|
21326
|
-
const init =
|
|
21327
|
-
return init && (
|
|
21641
|
+
const init = ts29.isVariableDeclaration(decl) && ts29.isIdentifier(decl.name) && decl.initializer ? unwrapTransparentTsWrappers(decl.initializer) : undefined;
|
|
21642
|
+
return init && (ts29.isArrowFunction(init) || ts29.isFunctionExpression(init)) ? { param: firstSimpleParamName(init), body: init.body } : undefined;
|
|
21328
21643
|
}
|
|
21329
21644
|
function findScopeDeclaration(name, scopeBody) {
|
|
21330
21645
|
let found;
|
|
21331
21646
|
const visit3 = (node) => {
|
|
21332
21647
|
if (found)
|
|
21333
21648
|
return;
|
|
21334
|
-
if (
|
|
21649
|
+
if (ts29.isVariableDeclaration(node) && bindingDeclares(node.name, name)) {
|
|
21335
21650
|
found = node;
|
|
21336
21651
|
return;
|
|
21337
21652
|
}
|
|
21338
|
-
if ((
|
|
21653
|
+
if ((ts29.isFunctionDeclaration(node) && node.body || ts29.isClassDeclaration(node)) && node.name?.text === name) {
|
|
21339
21654
|
found = node;
|
|
21340
21655
|
return;
|
|
21341
21656
|
}
|
|
21342
|
-
if (
|
|
21657
|
+
if (ts29.isFunctionLike(node) || ts29.isClassLike(node))
|
|
21343
21658
|
return;
|
|
21344
|
-
|
|
21659
|
+
ts29.forEachChild(node, visit3);
|
|
21345
21660
|
};
|
|
21346
21661
|
visit3(scopeBody);
|
|
21347
21662
|
return found;
|
|
21348
21663
|
}
|
|
21349
21664
|
function bindingDeclares(binding, name) {
|
|
21350
21665
|
const names = new Set;
|
|
21351
|
-
|
|
21666
|
+
collectBindingNames3(binding, names);
|
|
21352
21667
|
return names.has(name);
|
|
21353
21668
|
}
|
|
21354
21669
|
function isSsrPortalRefCallback(callback) {
|
|
@@ -21356,96 +21671,96 @@ function isSsrPortalRefCallback(callback) {
|
|
|
21356
21671
|
}
|
|
21357
21672
|
function firstSimpleParamName(fn) {
|
|
21358
21673
|
const first = fn.parameters[0];
|
|
21359
|
-
return first &&
|
|
21674
|
+
return first && ts29.isIdentifier(first.name) ? first.name.text : undefined;
|
|
21360
21675
|
}
|
|
21361
21676
|
function containsSsrPortalPlacementCall(body, paramName) {
|
|
21362
21677
|
let found = false;
|
|
21363
21678
|
const visit3 = (node) => {
|
|
21364
21679
|
if (found)
|
|
21365
21680
|
return;
|
|
21366
|
-
if (
|
|
21681
|
+
if (ts29.isCallExpression(node) && isSsrPortalPlacementCall(node, paramName)) {
|
|
21367
21682
|
found = true;
|
|
21368
21683
|
return;
|
|
21369
21684
|
}
|
|
21370
|
-
|
|
21685
|
+
ts29.forEachChild(node, visit3);
|
|
21371
21686
|
};
|
|
21372
21687
|
visit3(body);
|
|
21373
21688
|
return found;
|
|
21374
21689
|
}
|
|
21375
21690
|
function isSsrPortalPlacementCall(call, paramName) {
|
|
21376
|
-
if (!
|
|
21691
|
+
if (!ts29.isIdentifier(call.expression) || call.expression.text !== "createPortal")
|
|
21377
21692
|
return false;
|
|
21378
21693
|
const [target, container, options] = call.arguments;
|
|
21379
|
-
if (!target || !
|
|
21694
|
+
if (!target || !ts29.isIdentifier(target) || target.text !== paramName)
|
|
21380
21695
|
return false;
|
|
21381
21696
|
if (!container || !isDocumentBodyAccess(container))
|
|
21382
21697
|
return false;
|
|
21383
|
-
if (!options || !
|
|
21698
|
+
if (!options || !ts29.isObjectLiteralExpression(options))
|
|
21384
21699
|
return false;
|
|
21385
21700
|
return options.properties.some((p) => {
|
|
21386
|
-
if (
|
|
21701
|
+
if (ts29.isShorthandPropertyAssignment(p))
|
|
21387
21702
|
return p.name.text === "ownerScope";
|
|
21388
|
-
if (
|
|
21703
|
+
if (ts29.isPropertyAssignment(p) && ts29.isIdentifier(p.name))
|
|
21389
21704
|
return p.name.text === "ownerScope";
|
|
21390
21705
|
return false;
|
|
21391
21706
|
});
|
|
21392
21707
|
}
|
|
21393
21708
|
function isDocumentBodyAccess(expr) {
|
|
21394
|
-
return
|
|
21709
|
+
return ts29.isPropertyAccessExpression(expr) && ts29.isIdentifier(expr.expression) && expr.expression.text === "document" && expr.name.text === "body";
|
|
21395
21710
|
}
|
|
21396
21711
|
function getAttributeValue(attr, ctx) {
|
|
21397
21712
|
if (!attr.initializer) {
|
|
21398
21713
|
return AttrValueOf.booleanAttr();
|
|
21399
21714
|
}
|
|
21400
|
-
if (
|
|
21715
|
+
if (ts29.isStringLiteral(attr.initializer)) {
|
|
21401
21716
|
return AttrValueOf.literal(decodeEntities(attr.initializer.text));
|
|
21402
21717
|
}
|
|
21403
|
-
if (
|
|
21718
|
+
if (ts29.isJsxExpression(attr.initializer) && attr.initializer.expression) {
|
|
21404
21719
|
let expr = attr.initializer.expression;
|
|
21405
|
-
if (
|
|
21720
|
+
if (ts29.isIdentifier(expr)) {
|
|
21406
21721
|
const branchInit = ctx._branchScopeVars?.get(expr.text);
|
|
21407
21722
|
if (branchInit && !initializerShapeContainsJsx(branchInit)) {
|
|
21408
21723
|
expr = branchInit;
|
|
21409
21724
|
}
|
|
21410
21725
|
}
|
|
21411
21726
|
expr = tryDesugarInterleaveTaggedTemplate(expr, ctx);
|
|
21412
|
-
if (
|
|
21727
|
+
if (ts29.isAwaitExpression(expr)) {
|
|
21413
21728
|
ctx.analyzer.errors.push(createError(ErrorCodes.STAGE_AWAIT_IN_TEMPLATE, getSourceLocation(expr, ctx.sourceFile, ctx.filePath)));
|
|
21414
21729
|
return AttrValueOf.expression("undefined");
|
|
21415
21730
|
}
|
|
21416
21731
|
checkBareSignalOrMemoIdentifier(expr, ctx, { renderedPosition: isRenderedElementAttribute(attr, ctx) });
|
|
21417
|
-
if (attr.name.getText(ctx.sourceFile) === "style" &&
|
|
21732
|
+
if (attr.name.getText(ctx.sourceFile) === "style" && ts29.isObjectLiteralExpression(expr)) {
|
|
21418
21733
|
const cssString = tryStaticStyleObjectToCss(expr);
|
|
21419
21734
|
if (cssString !== null) {
|
|
21420
21735
|
return AttrValueOf.literal(cssString);
|
|
21421
21736
|
}
|
|
21422
21737
|
}
|
|
21423
|
-
if (
|
|
21738
|
+
if (ts29.isTemplateExpression(expr)) {
|
|
21424
21739
|
const parts = parseTemplateLiteral(expr, ctx);
|
|
21425
21740
|
if (parts.some((p) => p.type === "ternary" || p.type === "lookup")) {
|
|
21426
21741
|
return AttrValueOf.template(parts);
|
|
21427
21742
|
}
|
|
21428
21743
|
}
|
|
21429
|
-
if (
|
|
21744
|
+
if (ts29.isElementAccessExpression(expr) && !ts29.isStringLiteralLike(expr.argumentExpression) && !ts29.isNumericLiteral(expr.argumentExpression)) {
|
|
21430
21745
|
const parts = tryResolveTemplateSpanFromConst(expr, ctx);
|
|
21431
21746
|
if (parts) {
|
|
21432
21747
|
return AttrValueOf.template(parts);
|
|
21433
21748
|
}
|
|
21434
21749
|
}
|
|
21435
|
-
if (
|
|
21750
|
+
if (ts29.isIdentifier(expr)) {
|
|
21436
21751
|
const resolved = tryResolveIdentifierAsTemplateLiteral(expr, ctx);
|
|
21437
21752
|
if (resolved) {
|
|
21438
21753
|
return AttrValueOf.template(resolved);
|
|
21439
21754
|
}
|
|
21440
21755
|
}
|
|
21441
|
-
if (
|
|
21756
|
+
if (ts29.isConditionalExpression(expr)) {
|
|
21442
21757
|
const ternary = parseTernary(expr, ctx);
|
|
21443
21758
|
if (ternary) {
|
|
21444
21759
|
return AttrValueOf.template([ternary]);
|
|
21445
21760
|
}
|
|
21446
21761
|
}
|
|
21447
|
-
if (
|
|
21448
|
-
if (
|
|
21762
|
+
if (ts29.isBinaryExpression(expr) && expr.operatorToken.kind === ts29.SyntaxKind.BarBarToken) {
|
|
21763
|
+
if (ts29.isIdentifier(expr.right) && expr.right.text === "undefined") {
|
|
21449
21764
|
const baseExpr = ctx.getJS(expr.left);
|
|
21450
21765
|
return AttrValueOf.expression(baseExpr, {
|
|
21451
21766
|
presenceOrUndefined: true,
|
|
@@ -21475,11 +21790,11 @@ function typedSourceBeside(node, js, ctx) {
|
|
|
21475
21790
|
function tryStaticStyleObjectToCss(expr) {
|
|
21476
21791
|
const parts = [];
|
|
21477
21792
|
for (const prop of expr.properties) {
|
|
21478
|
-
if (!
|
|
21793
|
+
if (!ts29.isPropertyAssignment(prop))
|
|
21479
21794
|
return null;
|
|
21480
|
-
if (!
|
|
21795
|
+
if (!ts29.isIdentifier(prop.name) && !ts29.isStringLiteral(prop.name))
|
|
21481
21796
|
return null;
|
|
21482
|
-
if (!
|
|
21797
|
+
if (!ts29.isStringLiteral(prop.initializer))
|
|
21483
21798
|
return null;
|
|
21484
21799
|
const key = cssKebabCase(prop.name.text);
|
|
21485
21800
|
parts.push(`${key}:${prop.initializer.text}`);
|
|
@@ -21492,7 +21807,7 @@ function parseTemplateLiteral(expr, ctx) {
|
|
|
21492
21807
|
parts.push({ type: "string", value: expr.head.text });
|
|
21493
21808
|
}
|
|
21494
21809
|
for (const span of expr.templateSpans) {
|
|
21495
|
-
if (
|
|
21810
|
+
if (ts29.isConditionalExpression(span.expression)) {
|
|
21496
21811
|
const ternary = parseTernary(span.expression, ctx);
|
|
21497
21812
|
if (ternary) {
|
|
21498
21813
|
parts.push(ternary);
|
|
@@ -21518,7 +21833,7 @@ function parseTemplateLiteral(expr, ctx) {
|
|
|
21518
21833
|
return parts;
|
|
21519
21834
|
}
|
|
21520
21835
|
function tryResolveTemplateSpanFromConst(expr, ctx) {
|
|
21521
|
-
if (
|
|
21836
|
+
if (ts29.isIdentifier(expr)) {
|
|
21522
21837
|
if (ctx.scope.isBound(expr.text))
|
|
21523
21838
|
return null;
|
|
21524
21839
|
const constInfo = findLocalConst(expr.text, ctx.analyzer);
|
|
@@ -21529,13 +21844,13 @@ function tryResolveTemplateSpanFromConst(expr, ctx) {
|
|
|
21529
21844
|
const ast = parseConstInitializer(constInfo);
|
|
21530
21845
|
if (!ast)
|
|
21531
21846
|
return null;
|
|
21532
|
-
if (
|
|
21847
|
+
if (ts29.isStringLiteral(ast) || ts29.isNoSubstitutionTemplateLiteral(ast)) {
|
|
21533
21848
|
return [{ type: "string", value: ast.text }];
|
|
21534
21849
|
}
|
|
21535
21850
|
return null;
|
|
21536
21851
|
}
|
|
21537
|
-
if (
|
|
21538
|
-
if (!
|
|
21852
|
+
if (ts29.isElementAccessExpression(expr)) {
|
|
21853
|
+
if (!ts29.isIdentifier(expr.expression))
|
|
21539
21854
|
return null;
|
|
21540
21855
|
if (ctx.scope.isBound(expr.expression.text))
|
|
21541
21856
|
return null;
|
|
@@ -21545,17 +21860,17 @@ function tryResolveTemplateSpanFromConst(expr, ctx) {
|
|
|
21545
21860
|
if (constInfo.mutatedAfterDeclaration)
|
|
21546
21861
|
return null;
|
|
21547
21862
|
const ast = parseConstInitializer(constInfo);
|
|
21548
|
-
if (!ast || !
|
|
21863
|
+
if (!ast || !ts29.isObjectLiteralExpression(ast))
|
|
21549
21864
|
return null;
|
|
21550
21865
|
const cases = {};
|
|
21551
21866
|
for (const prop of ast.properties) {
|
|
21552
|
-
if (!
|
|
21867
|
+
if (!ts29.isPropertyAssignment(prop))
|
|
21553
21868
|
return null;
|
|
21554
|
-
const keyName = prop.name && (
|
|
21869
|
+
const keyName = prop.name && (ts29.isStringLiteral(prop.name) || ts29.isIdentifier(prop.name)) ? prop.name.text : null;
|
|
21555
21870
|
if (!keyName)
|
|
21556
21871
|
return null;
|
|
21557
21872
|
const value = prop.initializer;
|
|
21558
|
-
if (
|
|
21873
|
+
if (ts29.isStringLiteral(value) || ts29.isNoSubstitutionTemplateLiteral(value)) {
|
|
21559
21874
|
cases[keyName] = value.text;
|
|
21560
21875
|
} else {
|
|
21561
21876
|
return null;
|
|
@@ -21602,17 +21917,17 @@ function hasDynamicTagBinding(name, sourceFile) {
|
|
|
21602
21917
|
const visit3 = (node) => {
|
|
21603
21918
|
if (found)
|
|
21604
21919
|
return;
|
|
21605
|
-
if (
|
|
21920
|
+
if (ts29.isVariableDeclaration(node) && ts29.isIdentifier(node.name) && node.name.text === name && node.initializer) {
|
|
21606
21921
|
let init = node.initializer;
|
|
21607
|
-
while (
|
|
21922
|
+
while (ts29.isAsExpression(init) || ts29.isSatisfiesExpression(init) || ts29.isParenthesizedExpression(init) || ts29.isNonNullExpression(init)) {
|
|
21608
21923
|
init = init.expression;
|
|
21609
21924
|
}
|
|
21610
|
-
if (
|
|
21925
|
+
if (ts29.isPropertyAccessExpression(init) && init.name.text === "tag") {
|
|
21611
21926
|
found = true;
|
|
21612
21927
|
return;
|
|
21613
21928
|
}
|
|
21614
21929
|
}
|
|
21615
|
-
|
|
21930
|
+
ts29.forEachChild(node, visit3);
|
|
21616
21931
|
};
|
|
21617
21932
|
visit3(sourceFile);
|
|
21618
21933
|
return found;
|
|
@@ -21628,13 +21943,13 @@ function tryResolveIdentifierAsTemplateLiteral(ident, ctx) {
|
|
|
21628
21943
|
const ast = parseConstInitializer(constInfo);
|
|
21629
21944
|
if (!ast)
|
|
21630
21945
|
return null;
|
|
21631
|
-
if (
|
|
21946
|
+
if (ts29.isNoSubstitutionTemplateLiteral(ast) || ts29.isStringLiteral(ast)) {
|
|
21632
21947
|
return [{ type: "string", value: ast.text }];
|
|
21633
21948
|
}
|
|
21634
|
-
if (
|
|
21949
|
+
if (ts29.isElementAccessExpression(ast) && !ts29.isStringLiteralLike(ast.argumentExpression) && !ts29.isNumericLiteral(ast.argumentExpression)) {
|
|
21635
21950
|
return tryResolveTemplateSpanFromConst(ast, ctx);
|
|
21636
21951
|
}
|
|
21637
|
-
if (!
|
|
21952
|
+
if (!ts29.isTemplateExpression(ast))
|
|
21638
21953
|
return null;
|
|
21639
21954
|
let resolvedAny = false;
|
|
21640
21955
|
const parts = [];
|
|
@@ -21673,14 +21988,14 @@ function parseConstInitializerImpl(c) {
|
|
|
21673
21988
|
if (!c.value)
|
|
21674
21989
|
return null;
|
|
21675
21990
|
const wrapped = `const __bf_resolve__ = (${c.value})`;
|
|
21676
|
-
const sf =
|
|
21991
|
+
const sf = ts29.createSourceFile("__bf_resolve.ts", wrapped, ts29.ScriptTarget.Latest, true, ts29.ScriptKind.TS);
|
|
21677
21992
|
const stmt = sf.statements[0];
|
|
21678
|
-
if (!stmt || !
|
|
21993
|
+
if (!stmt || !ts29.isVariableStatement(stmt))
|
|
21679
21994
|
return null;
|
|
21680
21995
|
const decl = stmt.declarationList.declarations[0];
|
|
21681
21996
|
if (!decl?.initializer)
|
|
21682
21997
|
return null;
|
|
21683
|
-
return
|
|
21998
|
+
return ts29.isParenthesizedExpression(decl.initializer) ? decl.initializer.expression : decl.initializer;
|
|
21684
21999
|
}
|
|
21685
22000
|
function astText(node) {
|
|
21686
22001
|
return node.getText(node.getSourceFile());
|
|
@@ -21700,9 +22015,9 @@ function parseFunctionInfoAsExprImpl(fn) {
|
|
|
21700
22015
|
const params = fn.typedParams !== undefined ? fn.typedParams : fn.params.map(formatParamWithType).join(", ");
|
|
21701
22016
|
const body = fn.typedBody ?? fn.body;
|
|
21702
22017
|
const wrapped = `const __bf_resolve_fn__ = function(${params}) ${body}`;
|
|
21703
|
-
const sf =
|
|
22018
|
+
const sf = ts29.createSourceFile("__bf_resolve_fn.ts", wrapped, ts29.ScriptTarget.Latest, true, ts29.ScriptKind.TS);
|
|
21704
22019
|
const stmt = sf.statements[0];
|
|
21705
|
-
if (!stmt || !
|
|
22020
|
+
if (!stmt || !ts29.isVariableStatement(stmt))
|
|
21706
22021
|
return null;
|
|
21707
22022
|
const decl = stmt.declarationList.declarations[0];
|
|
21708
22023
|
if (!decl?.initializer)
|
|
@@ -21710,9 +22025,9 @@ function parseFunctionInfoAsExprImpl(fn) {
|
|
|
21710
22025
|
return decl.initializer;
|
|
21711
22026
|
}
|
|
21712
22027
|
function tryDesugarInterleaveTaggedTemplate(expr, ctx) {
|
|
21713
|
-
if (!
|
|
22028
|
+
if (!ts29.isTaggedTemplateExpression(expr))
|
|
21714
22029
|
return expr;
|
|
21715
|
-
if (!
|
|
22030
|
+
if (!ts29.isIdentifier(expr.tag))
|
|
21716
22031
|
return expr;
|
|
21717
22032
|
const resolvedTag = resolveInterleaveTagIdentifier(expr.tag.text, ctx);
|
|
21718
22033
|
if (!resolvedTag)
|
|
@@ -21729,23 +22044,23 @@ function resolveInterleaveTagIdentifier(name, ctx) {
|
|
|
21729
22044
|
return null;
|
|
21730
22045
|
if (constInfo) {
|
|
21731
22046
|
const ast = parseConstInitializer(constInfo);
|
|
21732
|
-
return ast && (
|
|
22047
|
+
return ast && (ts29.isArrowFunction(ast) || ts29.isFunctionExpression(ast)) ? ast : null;
|
|
21733
22048
|
}
|
|
21734
22049
|
if (fnInfo) {
|
|
21735
22050
|
const ast = parseFunctionInfoAsExpr(fnInfo);
|
|
21736
|
-
return ast && (
|
|
22051
|
+
return ast && (ts29.isArrowFunction(ast) || ts29.isFunctionExpression(ast)) ? ast : null;
|
|
21737
22052
|
}
|
|
21738
22053
|
return null;
|
|
21739
22054
|
}
|
|
21740
22055
|
function isInterleaveTagFunction(fn) {
|
|
21741
|
-
if (!
|
|
22056
|
+
if (!ts29.isArrowFunction(fn) && !ts29.isFunctionExpression(fn))
|
|
21742
22057
|
return false;
|
|
21743
22058
|
if (fn.parameters.length !== 2)
|
|
21744
22059
|
return false;
|
|
21745
22060
|
const [partsParam, argsParam] = fn.parameters;
|
|
21746
|
-
if (!
|
|
22061
|
+
if (!ts29.isIdentifier(partsParam.name) || partsParam.dotDotDotToken)
|
|
21747
22062
|
return false;
|
|
21748
|
-
if (!
|
|
22063
|
+
if (!ts29.isIdentifier(argsParam.name) || !argsParam.dotDotDotToken)
|
|
21749
22064
|
return false;
|
|
21750
22065
|
const parsed = tsNodeToParsedExpr(fn);
|
|
21751
22066
|
if (parsed.kind !== "arrow")
|
|
@@ -21802,7 +22117,7 @@ function isInterleaveSpanExpr(expr, i, argsName) {
|
|
|
21802
22117
|
function buildUntaggedTemplateLiteral(node, ctx) {
|
|
21803
22118
|
const template = node.template;
|
|
21804
22119
|
let text;
|
|
21805
|
-
if (
|
|
22120
|
+
if (ts29.isNoSubstitutionTemplateLiteral(template)) {
|
|
21806
22121
|
text = "`" + (template.rawText ?? template.text) + "`";
|
|
21807
22122
|
} else {
|
|
21808
22123
|
let body = template.head.rawText ?? template.head.text;
|
|
@@ -21814,15 +22129,15 @@ function buildUntaggedTemplateLiteral(node, ctx) {
|
|
|
21814
22129
|
text = "`" + body + "`";
|
|
21815
22130
|
}
|
|
21816
22131
|
const wrapped = `const __bf_resolve_tagged__ = (${text})`;
|
|
21817
|
-
const sf =
|
|
22132
|
+
const sf = ts29.createSourceFile("__bf_resolve_tagged.tsx", wrapped, ts29.ScriptTarget.Latest, true, ts29.ScriptKind.TSX);
|
|
21818
22133
|
const stmt = sf.statements[0];
|
|
21819
|
-
if (!stmt || !
|
|
22134
|
+
if (!stmt || !ts29.isVariableStatement(stmt))
|
|
21820
22135
|
return null;
|
|
21821
22136
|
const decl = stmt.declarationList.declarations[0];
|
|
21822
22137
|
if (!decl?.initializer)
|
|
21823
22138
|
return null;
|
|
21824
|
-
const result =
|
|
21825
|
-
if (!
|
|
22139
|
+
const result = ts29.isParenthesizedExpression(decl.initializer) ? decl.initializer.expression : decl.initializer;
|
|
22140
|
+
if (!ts29.isTemplateExpression(result) && !ts29.isNoSubstitutionTemplateLiteral(result))
|
|
21826
22141
|
return null;
|
|
21827
22142
|
return result;
|
|
21828
22143
|
}
|
|
@@ -21842,39 +22157,39 @@ function parseTernary(expr, ctx) {
|
|
|
21842
22157
|
return null;
|
|
21843
22158
|
}
|
|
21844
22159
|
function getStringValue(node) {
|
|
21845
|
-
if (
|
|
22160
|
+
if (ts29.isStringLiteral(node)) {
|
|
21846
22161
|
return node.text;
|
|
21847
22162
|
}
|
|
21848
|
-
if (
|
|
22163
|
+
if (ts29.isNoSubstitutionTemplateLiteral(node)) {
|
|
21849
22164
|
return node.text;
|
|
21850
22165
|
}
|
|
21851
22166
|
return null;
|
|
21852
22167
|
}
|
|
21853
22168
|
function unwrapTransparentTsWrappers(node) {
|
|
21854
22169
|
let n = node;
|
|
21855
|
-
while (
|
|
22170
|
+
while (ts29.isParenthesizedExpression(n) || ts29.isAsExpression(n) || ts29.isSatisfiesExpression(n) || ts29.isNonNullExpression(n)) {
|
|
21856
22171
|
n = n.expression;
|
|
21857
22172
|
}
|
|
21858
22173
|
return n;
|
|
21859
22174
|
}
|
|
21860
22175
|
function expressionWrapsJsx(node) {
|
|
21861
22176
|
const n = unwrapTransparentTsWrappers(node);
|
|
21862
|
-
if (
|
|
22177
|
+
if (ts29.isJsxElement(n) || ts29.isJsxSelfClosingElement(n) || ts29.isJsxFragment(n))
|
|
21863
22178
|
return true;
|
|
21864
|
-
if (
|
|
22179
|
+
if (ts29.isConditionalExpression(n)) {
|
|
21865
22180
|
return expressionWrapsJsx(n.whenTrue) || expressionWrapsJsx(n.whenFalse);
|
|
21866
22181
|
}
|
|
21867
|
-
if (
|
|
21868
|
-
return n.elements.some((el) => expressionWrapsJsx(
|
|
22182
|
+
if (ts29.isArrayLiteralExpression(n)) {
|
|
22183
|
+
return n.elements.some((el) => expressionWrapsJsx(ts29.isSpreadElement(el) ? el.expression : el));
|
|
21869
22184
|
}
|
|
21870
22185
|
return false;
|
|
21871
22186
|
}
|
|
21872
22187
|
function reportNakedJsxWrapperProp(ctx, attr, propName, jsxExpr) {
|
|
21873
|
-
const shape =
|
|
22188
|
+
const shape = ts29.isConditionalExpression(jsxExpr) ? "a ternary" : "an array literal";
|
|
21874
22189
|
ctx.analyzer.errors.push(createError(ErrorCodes.UNSUPPORTED_JSX_PATTERN, getSourceLocation(attr, ctx.sourceFile, ctx.filePath), {
|
|
21875
22190
|
message: `Prop '${propName}' is ${shape} wrapping JSX (${jsxExpr.getText(ctx.sourceFile)}). ` + `This shape is not compiled — only a JSX element/fragment given DIRECTLY as the prop value is.`,
|
|
21876
22191
|
suggestion: {
|
|
21877
|
-
message:
|
|
22192
|
+
message: ts29.isConditionalExpression(jsxExpr) ? `Move the conditional out of the prop position: compute it in a local const and pass it as ` + `the component's children instead of a named prop ` + `(e.g. const ${propName} = ${jsxExpr.getText(ctx.sourceFile)}; <Comp>{${propName}}</Comp>). ` + `Wrapping the ternary in a fragment at the prop position ` + `(${propName}={<>{${jsxExpr.getText(ctx.sourceFile)}}</>}) is also a safe escape (#2702): the ` + `compiler brands each JSX branch individually, so the child's reactive prop getter unwraps it ` + `correctly instead of re-escaping it as text.` : `Move the array out of the prop position: compute it in a local const and pass it as the ` + `component's children instead of a named prop ` + `(e.g. const ${propName} = ${jsxExpr.getText(ctx.sourceFile)}; <Comp>{${propName}}</Comp>). ` + `Wrapping the array in a fragment at the prop position is NOT a safe escape here: it compiles, ` + `but flattens to more than one part, which the child's reactive prop getter has no branding ` + `contract for (a multi-part jsx-children shape, tracked separately from #2702's single-` + `conditional fix).`,
|
|
21878
22193
|
escape: [{ kind: "rewrite" }]
|
|
21879
22194
|
}
|
|
21880
22195
|
}));
|
|
@@ -21884,16 +22199,16 @@ function processComponentProps(attributes, ctx) {
|
|
|
21884
22199
|
const spreadPlan = staticSpreadPlan(attributes, ctx);
|
|
21885
22200
|
const restPlan = closedRestFallbacks(spreadPlan.properties, spreadPlan.entries, ctx);
|
|
21886
22201
|
for (const attr of restPlan.properties) {
|
|
21887
|
-
if (
|
|
22202
|
+
if (ts29.isJsxSpreadAttribute(attr)) {
|
|
21888
22203
|
props.push(...expandSpreadAttribute(attr, ctx, spreadPlan.entries.get(attr), restPlan.fallbacks.get(attr)).map(({ restExpandedKey: _restExpandedKey, restFallback: _restFallback, ...prop }) => markPropsObjectSpread(prop)));
|
|
21889
22204
|
continue;
|
|
21890
22205
|
}
|
|
21891
|
-
if (!
|
|
22206
|
+
if (!ts29.isJsxAttribute(attr))
|
|
21892
22207
|
continue;
|
|
21893
22208
|
const name = attr.name.getText(ctx.sourceFile);
|
|
21894
|
-
if (attr.initializer &&
|
|
22209
|
+
if (attr.initializer && ts29.isJsxExpression(attr.initializer) && attr.initializer.expression) {
|
|
21895
22210
|
const jsxExpr = unwrapTransparentTsWrappers(attr.initializer.expression);
|
|
21896
|
-
if (
|
|
22211
|
+
if (ts29.isJsxElement(jsxExpr) || ts29.isJsxSelfClosingElement(jsxExpr) || ts29.isJsxFragment(jsxExpr)) {
|
|
21897
22212
|
const prevInsideComponentChildren = ctx.insideComponentChildren;
|
|
21898
22213
|
ctx.insideComponentChildren = true;
|
|
21899
22214
|
const irNode = transformNode(jsxExpr, ctx);
|
|
@@ -21907,7 +22222,7 @@ function processComponentProps(attributes, ctx) {
|
|
|
21907
22222
|
continue;
|
|
21908
22223
|
}
|
|
21909
22224
|
}
|
|
21910
|
-
if ((
|
|
22225
|
+
if ((ts29.isConditionalExpression(jsxExpr) || ts29.isArrayLiteralExpression(jsxExpr)) && expressionWrapsJsx(jsxExpr)) {
|
|
21911
22226
|
reportNakedJsxWrapperProp(ctx, attr, name, jsxExpr);
|
|
21912
22227
|
continue;
|
|
21913
22228
|
}
|
|
@@ -21929,7 +22244,7 @@ function valueComponentProp(attr, name, ctx) {
|
|
|
21929
22244
|
value = AttrValueOf.booleanShorthand();
|
|
21930
22245
|
}
|
|
21931
22246
|
let clientOnly;
|
|
21932
|
-
if (attr.initializer &&
|
|
22247
|
+
if (attr.initializer && ts29.isJsxExpression(attr.initializer) && attr.initializer.expression) {
|
|
21933
22248
|
if (value.kind === "expression" && value.templateExpr === undefined) {
|
|
21934
22249
|
const rewritten = rewriteBarePropRefs2(value.expr, attr.initializer.expression, ctx);
|
|
21935
22250
|
if (rewritten !== value.expr) {
|
|
@@ -21974,7 +22289,7 @@ function checkBareSignalOrMemoIdentifier(expr, ctx, options) {
|
|
|
21974
22289
|
}
|
|
21975
22290
|
}));
|
|
21976
22291
|
};
|
|
21977
|
-
if (
|
|
22292
|
+
if (ts29.isIdentifier(expr)) {
|
|
21978
22293
|
const kind = reactiveNames.get(expr.text);
|
|
21979
22294
|
if (kind && !ctx.scope.isBound(expr.text))
|
|
21980
22295
|
report(expr, expr.text, kind);
|
|
@@ -21989,69 +22304,69 @@ function checkBareSignalOrMemoIdentifier(expr, ctx, options) {
|
|
|
21989
22304
|
return ctx.scope.isBound(name);
|
|
21990
22305
|
};
|
|
21991
22306
|
const visitBindingDefaults = (name, bound) => {
|
|
21992
|
-
if (
|
|
22307
|
+
if (ts29.isIdentifier(name)) {
|
|
21993
22308
|
bound.add(name.text);
|
|
21994
22309
|
return;
|
|
21995
22310
|
}
|
|
21996
22311
|
for (const el of name.elements) {
|
|
21997
|
-
if (
|
|
22312
|
+
if (ts29.isOmittedExpression(el))
|
|
21998
22313
|
continue;
|
|
21999
22314
|
if (el.initializer)
|
|
22000
22315
|
visit3(el.initializer);
|
|
22001
22316
|
visitBindingDefaults(el.name, bound);
|
|
22002
22317
|
}
|
|
22003
22318
|
};
|
|
22004
|
-
const
|
|
22005
|
-
if (
|
|
22319
|
+
const collectBindingNames4 = (name, out) => {
|
|
22320
|
+
if (ts29.isIdentifier(name))
|
|
22006
22321
|
out.add(name.text);
|
|
22007
|
-
else if (
|
|
22322
|
+
else if (ts29.isObjectBindingPattern(name)) {
|
|
22008
22323
|
for (const el of name.elements)
|
|
22009
|
-
|
|
22010
|
-
} else if (
|
|
22324
|
+
collectBindingNames4(el.name, out);
|
|
22325
|
+
} else if (ts29.isArrayBindingPattern(name)) {
|
|
22011
22326
|
for (const el of name.elements) {
|
|
22012
|
-
if (!
|
|
22013
|
-
|
|
22327
|
+
if (!ts29.isOmittedExpression(el))
|
|
22328
|
+
collectBindingNames4(el.name, out);
|
|
22014
22329
|
}
|
|
22015
22330
|
}
|
|
22016
22331
|
};
|
|
22017
22332
|
const collectBlockDeclarations = (block, out) => {
|
|
22018
22333
|
for (const stmt of block.statements) {
|
|
22019
|
-
if (
|
|
22334
|
+
if (ts29.isVariableStatement(stmt)) {
|
|
22020
22335
|
for (const decl of stmt.declarationList.declarations)
|
|
22021
|
-
|
|
22022
|
-
} else if (
|
|
22336
|
+
collectBindingNames4(decl.name, out);
|
|
22337
|
+
} else if (ts29.isFunctionDeclaration(stmt) && stmt.name) {
|
|
22023
22338
|
out.add(stmt.name.text);
|
|
22024
22339
|
}
|
|
22025
22340
|
}
|
|
22026
22341
|
};
|
|
22027
22342
|
function visit3(node) {
|
|
22028
|
-
if (
|
|
22343
|
+
if (ts29.isJsxElement(node) || ts29.isJsxSelfClosingElement(node) || ts29.isJsxFragment(node)) {
|
|
22029
22344
|
return;
|
|
22030
22345
|
}
|
|
22031
|
-
if (
|
|
22346
|
+
if (ts29.isTypeNode(node))
|
|
22032
22347
|
return;
|
|
22033
|
-
if (
|
|
22348
|
+
if (ts29.isCallExpression(node) && node.arguments.length === 0 && ts29.isIdentifier(node.expression)) {
|
|
22034
22349
|
return;
|
|
22035
22350
|
}
|
|
22036
|
-
if (
|
|
22351
|
+
if (ts29.isPropertyAccessExpression(node)) {
|
|
22037
22352
|
visit3(node.expression);
|
|
22038
22353
|
return;
|
|
22039
22354
|
}
|
|
22040
|
-
if (
|
|
22041
|
-
if (
|
|
22355
|
+
if (ts29.isPropertyAssignment(node)) {
|
|
22356
|
+
if (ts29.isComputedPropertyName(node.name))
|
|
22042
22357
|
visit3(node.name.expression);
|
|
22043
22358
|
visit3(node.initializer);
|
|
22044
22359
|
return;
|
|
22045
22360
|
}
|
|
22046
|
-
if (
|
|
22047
|
-
if (
|
|
22361
|
+
if (ts29.isShorthandPropertyAssignment(node)) {
|
|
22362
|
+
if (ts29.isIdentifier(node.name) && !isBound(node.name.text)) {
|
|
22048
22363
|
const kind = reactiveNames.get(node.name.text);
|
|
22049
22364
|
if (kind)
|
|
22050
22365
|
report(node.name, node.name.text, kind);
|
|
22051
22366
|
}
|
|
22052
22367
|
return;
|
|
22053
22368
|
}
|
|
22054
|
-
if (
|
|
22369
|
+
if (ts29.isArrowFunction(node) || ts29.isFunctionExpression(node)) {
|
|
22055
22370
|
const bound = new Set;
|
|
22056
22371
|
boundStack.push(bound);
|
|
22057
22372
|
for (const p of node.parameters) {
|
|
@@ -22059,14 +22374,14 @@ function checkBareSignalOrMemoIdentifier(expr, ctx, options) {
|
|
|
22059
22374
|
visit3(p.initializer);
|
|
22060
22375
|
visitBindingDefaults(p.name, bound);
|
|
22061
22376
|
}
|
|
22062
|
-
if (node.body &&
|
|
22377
|
+
if (node.body && ts29.isBlock(node.body))
|
|
22063
22378
|
collectBlockDeclarations(node.body, bound);
|
|
22064
22379
|
if (node.body)
|
|
22065
22380
|
visit3(node.body);
|
|
22066
22381
|
boundStack.pop();
|
|
22067
22382
|
return;
|
|
22068
22383
|
}
|
|
22069
|
-
if (
|
|
22384
|
+
if (ts29.isVariableDeclaration(node)) {
|
|
22070
22385
|
if (node.initializer)
|
|
22071
22386
|
visit3(node.initializer);
|
|
22072
22387
|
const declared = new Set;
|
|
@@ -22075,7 +22390,7 @@ function checkBareSignalOrMemoIdentifier(expr, ctx, options) {
|
|
|
22075
22390
|
boundStack.pop();
|
|
22076
22391
|
return;
|
|
22077
22392
|
}
|
|
22078
|
-
if (
|
|
22393
|
+
if (ts29.isIdentifier(node)) {
|
|
22079
22394
|
if (isBound(node.text))
|
|
22080
22395
|
return;
|
|
22081
22396
|
const kind = reactiveNames.get(node.text);
|
|
@@ -22083,15 +22398,15 @@ function checkBareSignalOrMemoIdentifier(expr, ctx, options) {
|
|
|
22083
22398
|
report(node, node.text, kind);
|
|
22084
22399
|
return;
|
|
22085
22400
|
}
|
|
22086
|
-
|
|
22401
|
+
ts29.forEachChild(node, visit3);
|
|
22087
22402
|
}
|
|
22088
22403
|
visit3(expr);
|
|
22089
22404
|
}
|
|
22090
22405
|
function isArrayExprDirectPropRef(arrayExpr, ctx) {
|
|
22091
|
-
if (
|
|
22406
|
+
if (ts29.isIdentifier(arrayExpr)) {
|
|
22092
22407
|
return resolveAliasOrigin(propAliasHopCandidates(ctx), arrayExpr.text, (name) => isDirectPropBindingName(name, ctx) ? true : null) === true;
|
|
22093
22408
|
}
|
|
22094
|
-
if (
|
|
22409
|
+
if (ts29.isPropertyAccessExpression(arrayExpr)) {
|
|
22095
22410
|
const root = rootIdentifierOf(arrayExpr.expression);
|
|
22096
22411
|
if (root !== null) {
|
|
22097
22412
|
return resolveAliasOrigin(propAliasHopCandidates(ctx), root, (name) => isDirectPropBindingName(name, ctx) ? true : null) === true;
|
|
@@ -22178,9 +22493,9 @@ function shouldAutoDeferReactiveBrand(expr, ctx) {
|
|
|
22178
22493
|
}
|
|
22179
22494
|
function isAsyncActionLeaf(leaf, ctx) {
|
|
22180
22495
|
let node = leaf;
|
|
22181
|
-
while (
|
|
22496
|
+
while (ts29.isCallExpression(node) || ts29.isPropertyAccessExpression(node))
|
|
22182
22497
|
node = node.expression;
|
|
22183
|
-
if (!
|
|
22498
|
+
if (!ts29.isIdentifier(node))
|
|
22184
22499
|
return false;
|
|
22185
22500
|
const name = node.text;
|
|
22186
22501
|
return ctx.analyzer.signals.some((s) => s.factory?.action === name);
|
|
@@ -22381,7 +22696,7 @@ function buildIfStatementChain(analyzer, ctx, opts) {
|
|
|
22381
22696
|
jsxBranchLocalNames.add(n);
|
|
22382
22697
|
}
|
|
22383
22698
|
for (const decl of condReturn.scopeVariables) {
|
|
22384
|
-
if (
|
|
22699
|
+
if (ts29.isIdentifier(decl.name) && decl.initializer) {
|
|
22385
22700
|
branchScopeVars.set(decl.name.text, decl.initializer);
|
|
22386
22701
|
if (initializerShapeContainsJsx(decl.initializer)) {
|
|
22387
22702
|
jsxBranchLocalNames.add(decl.name.text);
|
|
@@ -22451,7 +22766,7 @@ function buildIfStatementChain(analyzer, ctx, opts) {
|
|
|
22451
22766
|
}
|
|
22452
22767
|
const scopeVariables = [];
|
|
22453
22768
|
for (const decl of condReturn.scopeVariables) {
|
|
22454
|
-
if (
|
|
22769
|
+
if (ts29.isIdentifier(decl.name) && decl.initializer) {
|
|
22455
22770
|
const init = ctx.getJS(decl.initializer);
|
|
22456
22771
|
const typedInit = decl.initializer.getText(ctx.sourceFile);
|
|
22457
22772
|
scopeVariables.push({
|
|
@@ -23913,7 +24228,7 @@ function summarizeLoopChildBranch(node, ctx, siblingOffsets, loopParam, loopPara
|
|
|
23913
24228
|
events: collectConditionalBranchEvents(node),
|
|
23914
24229
|
refs: collectConditionalBranchRefs(node),
|
|
23915
24230
|
reactiveAttrs: collectLoopChildReactiveAttrs(node, ctx, loopParam, loopParamBindings, true, preambleNames, loopIndex),
|
|
23916
|
-
reactiveTexts: node.type === "expression" && node.
|
|
24231
|
+
reactiveTexts: node.type === "expression" && node.readsCallerValue ? [] : collectLoopChildReactiveTexts(node, ctx, loopParam, loopParamBindings, true, preambleNames, loopIndex)
|
|
23917
24232
|
};
|
|
23918
24233
|
}
|
|
23919
24234
|
|
|
@@ -23922,26 +24237,26 @@ var ROOT_SOURCE = null;
|
|
|
23922
24237
|
var BARE_IDENT_RE = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
|
|
23923
24238
|
function buildReferencesGraph(ctx, irRoot) {
|
|
23924
24239
|
const edges = [];
|
|
23925
|
-
const
|
|
24240
|
+
const declaredNames2 = new Set;
|
|
23926
24241
|
const propNames = new Set;
|
|
23927
24242
|
for (const c of ctx.localConstants)
|
|
23928
|
-
|
|
24243
|
+
declaredNames2.add(c.name);
|
|
23929
24244
|
for (const f of ctx.localFunctions)
|
|
23930
|
-
|
|
24245
|
+
declaredNames2.add(f.name);
|
|
23931
24246
|
for (const s of ctx.signals) {
|
|
23932
|
-
|
|
24247
|
+
declaredNames2.add(s.getter);
|
|
23933
24248
|
const second = signalSecondBinding(s);
|
|
23934
24249
|
if (second)
|
|
23935
|
-
|
|
24250
|
+
declaredNames2.add(second);
|
|
23936
24251
|
}
|
|
23937
24252
|
for (const m of ctx.memos)
|
|
23938
|
-
|
|
24253
|
+
declaredNames2.add(m.name);
|
|
23939
24254
|
for (const p of ctx.propsParams) {
|
|
23940
|
-
|
|
24255
|
+
declaredNames2.add(p.name);
|
|
23941
24256
|
propNames.add(p.name);
|
|
23942
24257
|
}
|
|
23943
24258
|
if (ctx.propsObjectName) {
|
|
23944
|
-
|
|
24259
|
+
declaredNames2.add(ctx.propsObjectName);
|
|
23945
24260
|
propNames.add(ctx.propsObjectName);
|
|
23946
24261
|
}
|
|
23947
24262
|
const addExprEdges = (from, expr, context) => {
|
|
@@ -24170,7 +24485,7 @@ function buildReferencesGraph(ctx, irRoot) {
|
|
|
24170
24485
|
}
|
|
24171
24486
|
}
|
|
24172
24487
|
addPropDefaultEdges(ctx, edges, propNames);
|
|
24173
|
-
return { edges, declaredNames, propNames };
|
|
24488
|
+
return { edges, declaredNames: declaredNames2, propNames };
|
|
24174
24489
|
}
|
|
24175
24490
|
function addPropDefaultEdges(ctx, edges, propNames) {
|
|
24176
24491
|
const bodyBound = componentBodyBindings(ctx);
|
|
@@ -24697,7 +25012,7 @@ function recordStageDiagnostics(c, decisions, errors) {
|
|
|
24697
25012
|
}
|
|
24698
25013
|
}
|
|
24699
25014
|
}
|
|
24700
|
-
function classifyConstantInitial(c,
|
|
25015
|
+
function classifyConstantInitial(c, declaredNames2, signalGetters, signalSetters, memoNames, env, getterAliases, constantScope) {
|
|
24701
25016
|
if (c.isJsx)
|
|
24702
25017
|
return { status: { kind: "jsx-inline" }, decisions: [] };
|
|
24703
25018
|
if (!c.value)
|
|
@@ -24719,7 +25034,7 @@ function classifyConstantInitial(c, declaredNames, signalGetters, signalSetters,
|
|
|
24719
25034
|
}
|
|
24720
25035
|
}
|
|
24721
25036
|
for (const id of freeIds) {
|
|
24722
|
-
if (JS_BUILTINS.has(id) ||
|
|
25037
|
+
if (JS_BUILTINS.has(id) || declaredNames2.has(id))
|
|
24723
25038
|
continue;
|
|
24724
25039
|
return { status: { kind: "external-name" }, decisions: [] };
|
|
24725
25040
|
}
|
|
@@ -26122,7 +26437,7 @@ function analyzeLazyConditional(cond, arms) {
|
|
|
26122
26437
|
}
|
|
26123
26438
|
|
|
26124
26439
|
// src/ir-to-client-js/control-flow/plan/lazy-preamble.ts
|
|
26125
|
-
import
|
|
26440
|
+
import ts30 from "typescript";
|
|
26126
26441
|
var NO_PREAMBLE = {
|
|
26127
26442
|
lazySafe: true,
|
|
26128
26443
|
facts: { declaredNames: new Set, freeNames: new Set }
|
|
@@ -26141,17 +26456,17 @@ function analyzeLazyPreamble(preamble, primableNames) {
|
|
|
26141
26456
|
const text = preambleAnalysisText(preamble);
|
|
26142
26457
|
if (text.trim().length === 0)
|
|
26143
26458
|
return NO_PREAMBLE;
|
|
26144
|
-
const
|
|
26145
|
-
const sf =
|
|
26459
|
+
const declaredNames2 = new Set;
|
|
26460
|
+
const sf = ts30.createSourceFile("__lazy_preamble__.ts", text, ts30.ScriptTarget.Latest, true, ts30.ScriptKind.TS);
|
|
26146
26461
|
for (const stmt of sf.statements) {
|
|
26147
|
-
if (!
|
|
26148
|
-
return NO2(`map-callback preamble has a non-declaration statement (${
|
|
26462
|
+
if (!ts30.isVariableStatement(stmt)) {
|
|
26463
|
+
return NO2(`map-callback preamble has a non-declaration statement (${ts30.SyntaxKind[stmt.kind]})`);
|
|
26149
26464
|
}
|
|
26150
|
-
const isConst = (stmt.declarationList.flags &
|
|
26465
|
+
const isConst = (stmt.declarationList.flags & ts30.NodeFlags.Const) !== 0;
|
|
26151
26466
|
if (!isConst)
|
|
26152
26467
|
return NO2("map-callback preamble declares a mutable binding (let/var)");
|
|
26153
26468
|
for (const decl of stmt.declarationList.declarations) {
|
|
26154
|
-
|
|
26469
|
+
collectBindingNames4(decl.name, declaredNames2);
|
|
26155
26470
|
if (!decl.initializer) {
|
|
26156
26471
|
return NO2("map-callback preamble has a declaration with no initializer");
|
|
26157
26472
|
}
|
|
@@ -26161,26 +26476,26 @@ function analyzeLazyPreamble(preamble, primableNames) {
|
|
|
26161
26476
|
}
|
|
26162
26477
|
}
|
|
26163
26478
|
}
|
|
26164
|
-
for (const name of
|
|
26479
|
+
for (const name of declaredNames2) {
|
|
26165
26480
|
if (primableNames.has(name)) {
|
|
26166
26481
|
return NO2(`map-callback preamble shadows the signal/memo getter '${name}'`);
|
|
26167
26482
|
}
|
|
26168
26483
|
}
|
|
26169
26484
|
const readNames2 = extractFreeIdentifiersFromStatementText(text);
|
|
26170
26485
|
const freeNames = new Set(readNames2);
|
|
26171
|
-
for (const declared of
|
|
26486
|
+
for (const declared of declaredNames2)
|
|
26172
26487
|
freeNames.delete(declared);
|
|
26173
|
-
return { lazySafe: true, facts: { declaredNames, freeNames } };
|
|
26488
|
+
return { lazySafe: true, facts: { declaredNames: declaredNames2, freeNames } };
|
|
26174
26489
|
}
|
|
26175
|
-
function
|
|
26176
|
-
if (
|
|
26490
|
+
function collectBindingNames4(name, out) {
|
|
26491
|
+
if (ts30.isIdentifier(name)) {
|
|
26177
26492
|
out.add(name.text);
|
|
26178
26493
|
return;
|
|
26179
26494
|
}
|
|
26180
26495
|
for (const element of name.elements) {
|
|
26181
|
-
if (
|
|
26496
|
+
if (ts30.isOmittedExpression(element))
|
|
26182
26497
|
continue;
|
|
26183
|
-
|
|
26498
|
+
collectBindingNames4(element.name, out);
|
|
26184
26499
|
}
|
|
26185
26500
|
}
|
|
26186
26501
|
function findImpureNode(root, primableNames) {
|
|
@@ -26188,56 +26503,56 @@ function findImpureNode(root, primableNames) {
|
|
|
26188
26503
|
const visit3 = (node) => {
|
|
26189
26504
|
if (found)
|
|
26190
26505
|
return;
|
|
26191
|
-
if (
|
|
26506
|
+
if (ts30.isCallExpression(node)) {
|
|
26192
26507
|
const callee = node.expression;
|
|
26193
|
-
const isSignalRead =
|
|
26508
|
+
const isSignalRead = ts30.isIdentifier(callee) && primableNames.has(callee.text) && node.arguments.length === 0 && node.questionDotToken === undefined;
|
|
26194
26509
|
if (!isSignalRead) {
|
|
26195
26510
|
found = `call to ${callee.getText(callee.getSourceFile())}`;
|
|
26196
26511
|
return;
|
|
26197
26512
|
}
|
|
26198
26513
|
}
|
|
26199
|
-
if (
|
|
26514
|
+
if (ts30.isNewExpression(node)) {
|
|
26200
26515
|
found = "new expression";
|
|
26201
26516
|
return;
|
|
26202
26517
|
}
|
|
26203
|
-
if (
|
|
26518
|
+
if (ts30.isTaggedTemplateExpression(node)) {
|
|
26204
26519
|
found = "tagged template";
|
|
26205
26520
|
return;
|
|
26206
26521
|
}
|
|
26207
|
-
if (
|
|
26522
|
+
if (ts30.isAwaitExpression(node)) {
|
|
26208
26523
|
found = "await";
|
|
26209
26524
|
return;
|
|
26210
26525
|
}
|
|
26211
|
-
if (
|
|
26526
|
+
if (ts30.isYieldExpression(node)) {
|
|
26212
26527
|
found = "yield";
|
|
26213
26528
|
return;
|
|
26214
26529
|
}
|
|
26215
|
-
if (
|
|
26530
|
+
if (ts30.isPrefixUnaryExpression(node) || ts30.isPostfixUnaryExpression(node)) {
|
|
26216
26531
|
const op = node.operator;
|
|
26217
|
-
if (op ===
|
|
26532
|
+
if (op === ts30.SyntaxKind.PlusPlusToken || op === ts30.SyntaxKind.MinusMinusToken) {
|
|
26218
26533
|
found = "increment/decrement";
|
|
26219
26534
|
return;
|
|
26220
26535
|
}
|
|
26221
26536
|
}
|
|
26222
|
-
if (
|
|
26537
|
+
if (ts30.isDeleteExpression(node)) {
|
|
26223
26538
|
found = "delete";
|
|
26224
26539
|
return;
|
|
26225
26540
|
}
|
|
26226
|
-
if (
|
|
26541
|
+
if (ts30.isFunctionExpression(node) || ts30.isArrowFunction(node) || ts30.isClassExpression(node)) {
|
|
26227
26542
|
found = "function or class expression";
|
|
26228
26543
|
return;
|
|
26229
26544
|
}
|
|
26230
|
-
if (
|
|
26545
|
+
if (ts30.isBinaryExpression(node) && isAssignmentOperator5(node.operatorToken.kind)) {
|
|
26231
26546
|
found = "assignment";
|
|
26232
26547
|
return;
|
|
26233
26548
|
}
|
|
26234
|
-
|
|
26549
|
+
ts30.forEachChild(node, visit3);
|
|
26235
26550
|
};
|
|
26236
26551
|
visit3(root);
|
|
26237
26552
|
return found;
|
|
26238
26553
|
}
|
|
26239
26554
|
function isAssignmentOperator5(kind) {
|
|
26240
|
-
return kind >=
|
|
26555
|
+
return kind >= ts30.SyntaxKind.FirstAssignment && kind <= ts30.SyntaxKind.LastAssignment;
|
|
26241
26556
|
}
|
|
26242
26557
|
|
|
26243
26558
|
// src/ir-to-client-js/control-flow/plan/lazy-row-eligibility.ts
|
|
@@ -27569,7 +27884,7 @@ function buildStaticPropsExpr(props) {
|
|
|
27569
27884
|
}
|
|
27570
27885
|
|
|
27571
27886
|
// src/ir-to-client-js/emit-reactive.ts
|
|
27572
|
-
import
|
|
27887
|
+
import ts31 from "typescript";
|
|
27573
27888
|
|
|
27574
27889
|
// src/ir-to-client-js/control-flow/stringify/claim-plan.ts
|
|
27575
27890
|
function rowTextSlotKind(text) {
|
|
@@ -27699,8 +28014,8 @@ function rewriteDestructuredPropsInExpr(expr, ctx) {
|
|
|
27699
28014
|
return `${PROPS_PARAM}.${localName}`;
|
|
27700
28015
|
return livePropReadExpr(prop, undefined, false);
|
|
27701
28016
|
};
|
|
27702
|
-
const sourceFile =
|
|
27703
|
-
)`,
|
|
28017
|
+
const sourceFile = ts31.createSourceFile("__bf_reactive_expr.ts", `(${expr}
|
|
28018
|
+
)`, ts31.ScriptTarget.Latest, true);
|
|
27704
28019
|
return rewriteBarePropRefs(expr, sourceFile, propNames, undefined, propAliases, replacementFor) ?? expr;
|
|
27705
28020
|
}
|
|
27706
28021
|
function getReactiveDateLoweringMatcher(ctx) {
|
|
@@ -27730,20 +28045,20 @@ function lowerToLocaleCallsInReactiveExpr(expr, matcher) {
|
|
|
27730
28045
|
return expr;
|
|
27731
28046
|
let sourceFile;
|
|
27732
28047
|
try {
|
|
27733
|
-
sourceFile =
|
|
28048
|
+
sourceFile = ts31.createSourceFile("__reactive_expr__.ts", `(${expr});`, ts31.ScriptTarget.Latest, true, ts31.ScriptKind.TS);
|
|
27734
28049
|
} catch {
|
|
27735
28050
|
return expr;
|
|
27736
28051
|
}
|
|
27737
28052
|
const stmt = sourceFile.statements[0];
|
|
27738
|
-
if (!stmt || !
|
|
28053
|
+
if (!stmt || !ts31.isExpressionStatement(stmt))
|
|
27739
28054
|
return expr;
|
|
27740
|
-
const root =
|
|
28055
|
+
const root = ts31.isParenthesizedExpression(stmt.expression) ? stmt.expression.expression : stmt.expression;
|
|
27741
28056
|
const candidates2 = [];
|
|
27742
28057
|
const visit3 = (n) => {
|
|
27743
|
-
if (
|
|
28058
|
+
if (ts31.isCallExpression(n) && n.arguments.length === 2 && ts31.isPropertyAccessExpression(n.expression) && !n.expression.questionDotToken && n.expression.name.text === "toLocaleDateString") {
|
|
27744
28059
|
candidates2.push(n);
|
|
27745
28060
|
}
|
|
27746
|
-
|
|
28061
|
+
ts31.forEachChild(n, visit3);
|
|
27747
28062
|
};
|
|
27748
28063
|
visit3(root);
|
|
27749
28064
|
if (candidates2.length === 0)
|
|
@@ -27779,20 +28094,20 @@ function lowerDateCallsInReactiveExpr(expr, matcher) {
|
|
|
27779
28094
|
return expr;
|
|
27780
28095
|
let sourceFile;
|
|
27781
28096
|
try {
|
|
27782
|
-
sourceFile =
|
|
28097
|
+
sourceFile = ts31.createSourceFile("__reactive_expr__.ts", `(${expr});`, ts31.ScriptTarget.Latest, true, ts31.ScriptKind.TS);
|
|
27783
28098
|
} catch {
|
|
27784
28099
|
return expr;
|
|
27785
28100
|
}
|
|
27786
28101
|
const stmt = sourceFile.statements[0];
|
|
27787
|
-
if (!stmt || !
|
|
28102
|
+
if (!stmt || !ts31.isExpressionStatement(stmt))
|
|
27788
28103
|
return expr;
|
|
27789
|
-
const root =
|
|
28104
|
+
const root = ts31.isParenthesizedExpression(stmt.expression) ? stmt.expression.expression : stmt.expression;
|
|
27790
28105
|
const candidates2 = [];
|
|
27791
28106
|
const visit3 = (n) => {
|
|
27792
|
-
if (
|
|
28107
|
+
if (ts31.isCallExpression(n) && n.arguments.length === 0 && ts31.isPropertyAccessExpression(n.expression) && !n.expression.questionDotToken && DATE_METHODS.has(n.expression.name.text)) {
|
|
27793
28108
|
candidates2.push(n);
|
|
27794
28109
|
}
|
|
27795
|
-
|
|
28110
|
+
ts31.forEachChild(n, visit3);
|
|
27796
28111
|
};
|
|
27797
28112
|
visit3(root);
|
|
27798
28113
|
if (candidates2.length === 0)
|
|
@@ -29441,11 +29756,11 @@ function indexBindingLine(handler, indexParam, indexExpr) {
|
|
|
29441
29756
|
return null;
|
|
29442
29757
|
return `const ${indexParam} = ${indexExpr}`;
|
|
29443
29758
|
}
|
|
29444
|
-
function preambleLineForHandler(mapPreamble,
|
|
29445
|
-
if (!mapPreamble ||
|
|
29759
|
+
function preambleLineForHandler(mapPreamble, declaredNames2, handler) {
|
|
29760
|
+
if (!mapPreamble || declaredNames2.length === 0)
|
|
29446
29761
|
return null;
|
|
29447
29762
|
const free = extractFreeIdentifiersFromText(handler);
|
|
29448
|
-
return
|
|
29763
|
+
return declaredNames2.some((name) => free.has(name)) ? mapPreamble : null;
|
|
29449
29764
|
}
|
|
29450
29765
|
function stringifyEventDelegation(lines, plan) {
|
|
29451
29766
|
const { containerVar, events, itemLookup, profileComponentName, ownHandlers, relayRowPortals } = plan;
|
|
@@ -30138,7 +30453,7 @@ var PHASES = [
|
|
|
30138
30453
|
];
|
|
30139
30454
|
|
|
30140
30455
|
// src/ir-to-client-js/rewrite-destructured-props.ts
|
|
30141
|
-
import
|
|
30456
|
+
import ts32 from "typescript";
|
|
30142
30457
|
function rewriteDestructuredPropReads(code, ctx, propUsage) {
|
|
30143
30458
|
return ctx.propsObjectName === null ? rewriteParamDestructuredReads(code, ctx, propUsage) : rewriteBodyAliasReads(code, ctx);
|
|
30144
30459
|
}
|
|
@@ -30195,22 +30510,22 @@ function rewriteBodyAliasReads(code, ctx) {
|
|
|
30195
30510
|
return code;
|
|
30196
30511
|
if (![...aliases.keys()].some((name) => identifierPattern(name).test(code)))
|
|
30197
30512
|
return code;
|
|
30198
|
-
const sourceFile =
|
|
30513
|
+
const sourceFile = ts32.createSourceFile("init-body.ts", code, ts32.ScriptTarget.Latest, true, ts32.ScriptKind.TS);
|
|
30199
30514
|
const spans = [];
|
|
30200
30515
|
const located = new Map;
|
|
30201
30516
|
for (const stmt of sourceFile.statements) {
|
|
30202
|
-
if (!
|
|
30517
|
+
if (!ts32.isFunctionDeclaration(stmt) || !stmt.name?.text.startsWith("init") || !stmt.body)
|
|
30203
30518
|
continue;
|
|
30204
30519
|
for (const inner of stmt.body.statements) {
|
|
30205
|
-
if (!
|
|
30520
|
+
if (!ts32.isVariableStatement(inner))
|
|
30206
30521
|
continue;
|
|
30207
|
-
if ((inner.declarationList.flags &
|
|
30522
|
+
if ((inner.declarationList.flags & ts32.NodeFlags.Const) === 0)
|
|
30208
30523
|
continue;
|
|
30209
30524
|
const decls = inner.declarationList.declarations;
|
|
30210
30525
|
if (decls.length !== 1)
|
|
30211
30526
|
continue;
|
|
30212
30527
|
const decl = decls[0];
|
|
30213
|
-
if (!
|
|
30528
|
+
if (!ts32.isIdentifier(decl.name) || !decl.initializer)
|
|
30214
30529
|
continue;
|
|
30215
30530
|
const alias = aliases.get(decl.name.text);
|
|
30216
30531
|
if (!alias)
|
|
@@ -30224,7 +30539,7 @@ function rewriteBodyAliasReads(code, ctx) {
|
|
|
30224
30539
|
key: alias.key,
|
|
30225
30540
|
defaultValue: parsedInit.fallback?.getText(sourceFile),
|
|
30226
30541
|
coalescesNull: parsedInit.coalescesNull,
|
|
30227
|
-
defaultContainsArrow: alias.defaultContainsArrow && !(parsedInit.fallback &&
|
|
30542
|
+
defaultContainsArrow: alias.defaultContainsArrow && !(parsedInit.fallback && ts32.isParenthesizedExpression(parsedInit.fallback)),
|
|
30228
30543
|
...bodyAliasDefaultParts(ctx, decl.name.text, alias.key)
|
|
30229
30544
|
});
|
|
30230
30545
|
spans.push([inner.getFullStart(), inner.getEnd()]);
|
|
@@ -30984,7 +31299,7 @@ function walkIR2(node, visitor) {
|
|
|
30984
31299
|
}
|
|
30985
31300
|
|
|
30986
31301
|
// src/preprocess-inline-jsx-callbacks.ts
|
|
30987
|
-
import
|
|
31302
|
+
import ts33 from "typescript";
|
|
30988
31303
|
var SYNTHETIC_PREFIX = "BFInlineJsxCallback";
|
|
30989
31304
|
var MAX_FIXPOINT_ITERATIONS = 16;
|
|
30990
31305
|
function preprocessInlineJsxCallbacks(source, filePath) {
|
|
@@ -31006,8 +31321,8 @@ function preprocessInlineJsxCallbacks(source, filePath) {
|
|
|
31006
31321
|
return { source: current, errors, syntheticNames };
|
|
31007
31322
|
}
|
|
31008
31323
|
function runSinglePass(source, filePath, startingCounter) {
|
|
31009
|
-
const sourceFile =
|
|
31010
|
-
const hasUseClient = sourceFile.statements.some((stmt) =>
|
|
31324
|
+
const sourceFile = ts33.createSourceFile(filePath, source, ts33.ScriptTarget.Latest, true, ts33.ScriptKind.TSX);
|
|
31325
|
+
const hasUseClient = sourceFile.statements.some((stmt) => ts33.isExpressionStatement(stmt) && ts33.isStringLiteral(stmt.expression) && isUseClientDirectiveText(stmt.expression.text));
|
|
31011
31326
|
if (!hasUseClient) {
|
|
31012
31327
|
return { source, errors: [], syntheticNames: [], counterAfter: startingCounter };
|
|
31013
31328
|
}
|
|
@@ -31029,22 +31344,22 @@ function runSinglePass(source, filePath, startingCounter) {
|
|
|
31029
31344
|
}
|
|
31030
31345
|
}
|
|
31031
31346
|
function visit3(node) {
|
|
31032
|
-
if (
|
|
31347
|
+
if (ts33.isJsxAttribute(node) && node.initializer && ts33.isJsxExpression(node.initializer) && node.initializer.expression) {
|
|
31033
31348
|
if (tryHandleArrowValue(node.initializer.expression)) {
|
|
31034
31349
|
return;
|
|
31035
31350
|
}
|
|
31036
31351
|
}
|
|
31037
|
-
if (
|
|
31352
|
+
if (ts33.isPropertyAssignment(node) && node.initializer) {
|
|
31038
31353
|
if (tryHandleArrowValue(node.initializer))
|
|
31039
31354
|
return;
|
|
31040
31355
|
}
|
|
31041
|
-
|
|
31356
|
+
ts33.forEachChild(node, visit3);
|
|
31042
31357
|
}
|
|
31043
31358
|
function tryHandleArrowValue(initializer) {
|
|
31044
31359
|
let expr = initializer;
|
|
31045
|
-
while (
|
|
31360
|
+
while (ts33.isParenthesizedExpression(expr))
|
|
31046
31361
|
expr = expr.expression;
|
|
31047
|
-
if (
|
|
31362
|
+
if (ts33.isArrowFunction(expr) && arrowBodyContainsJsx(expr)) {
|
|
31048
31363
|
return handleInlineArrow(expr);
|
|
31049
31364
|
}
|
|
31050
31365
|
return false;
|
|
@@ -31081,7 +31396,7 @@ function runSinglePass(source, filePath, startingCounter) {
|
|
|
31081
31396
|
replacements.push({ start: arrowStart, end: arrowEnd, text: name });
|
|
31082
31397
|
return true;
|
|
31083
31398
|
}
|
|
31084
|
-
|
|
31399
|
+
ts33.forEachChild(sourceFile, visit3);
|
|
31085
31400
|
if (replacements.length === 0) {
|
|
31086
31401
|
return { source, errors, syntheticNames, counterAfter: counter };
|
|
31087
31402
|
}
|
|
@@ -31104,11 +31419,11 @@ function errorMessageForCapture(captures) {
|
|
|
31104
31419
|
return `Inline JSX-returning arrow function captures non-module identifier(s): ` + `${captures.sort().join(", ")}. ` + `Extract the callback into a top-level '\\'use client\\'' component (e.g. ` + `\`function MyNode(n) { return <div/> }\` then \`renderNode={MyNode}\`) ` + `or pass captured values via component props.`;
|
|
31105
31420
|
}
|
|
31106
31421
|
function arrowBodyContainsJsx(arrow) {
|
|
31107
|
-
if (
|
|
31422
|
+
if (ts33.isBlock(arrow.body)) {
|
|
31108
31423
|
return blockReturnsJsx(arrow.body);
|
|
31109
31424
|
}
|
|
31110
31425
|
let body = arrow.body;
|
|
31111
|
-
while (
|
|
31426
|
+
while (ts33.isParenthesizedExpression(body))
|
|
31112
31427
|
body = body.expression;
|
|
31113
31428
|
return isJsxLike(body);
|
|
31114
31429
|
}
|
|
@@ -31117,41 +31432,41 @@ function blockReturnsJsx(block) {
|
|
|
31117
31432
|
function visit3(n) {
|
|
31118
31433
|
if (found)
|
|
31119
31434
|
return;
|
|
31120
|
-
if (
|
|
31435
|
+
if (ts33.isReturnStatement(n) && n.expression) {
|
|
31121
31436
|
let e = n.expression;
|
|
31122
|
-
while (
|
|
31437
|
+
while (ts33.isParenthesizedExpression(e))
|
|
31123
31438
|
e = e.expression;
|
|
31124
31439
|
if (isJsxLike(e)) {
|
|
31125
31440
|
found = true;
|
|
31126
31441
|
return;
|
|
31127
31442
|
}
|
|
31128
31443
|
}
|
|
31129
|
-
if (
|
|
31444
|
+
if (ts33.isArrowFunction(n) || ts33.isFunctionDeclaration(n) || ts33.isFunctionExpression(n))
|
|
31130
31445
|
return;
|
|
31131
|
-
|
|
31446
|
+
ts33.forEachChild(n, visit3);
|
|
31132
31447
|
}
|
|
31133
|
-
|
|
31448
|
+
ts33.forEachChild(block, visit3);
|
|
31134
31449
|
return found;
|
|
31135
31450
|
}
|
|
31136
31451
|
function isJsxLike(expr) {
|
|
31137
|
-
return
|
|
31452
|
+
return ts33.isJsxElement(expr) || ts33.isJsxSelfClosingElement(expr) || ts33.isJsxFragment(expr);
|
|
31138
31453
|
}
|
|
31139
31454
|
function collectArrowParamNames(arrow) {
|
|
31140
31455
|
const names = new Set;
|
|
31141
31456
|
for (const p of arrow.parameters)
|
|
31142
|
-
|
|
31457
|
+
collectBindingNames5(p.name, names);
|
|
31143
31458
|
return names;
|
|
31144
31459
|
}
|
|
31145
|
-
function
|
|
31460
|
+
function collectBindingNames5(name, out) {
|
|
31146
31461
|
const push = Array.isArray(out) ? (n) => out.push(n) : (n) => out.add(n);
|
|
31147
|
-
if (
|
|
31462
|
+
if (ts33.isIdentifier(name)) {
|
|
31148
31463
|
push(name.text);
|
|
31149
|
-
} else if (
|
|
31150
|
-
name.elements.forEach((el) =>
|
|
31151
|
-
} else if (
|
|
31464
|
+
} else if (ts33.isObjectBindingPattern(name)) {
|
|
31465
|
+
name.elements.forEach((el) => collectBindingNames5(el.name, out));
|
|
31466
|
+
} else if (ts33.isArrayBindingPattern(name)) {
|
|
31152
31467
|
name.elements.forEach((el) => {
|
|
31153
|
-
if (!
|
|
31154
|
-
|
|
31468
|
+
if (!ts33.isOmittedExpression(el))
|
|
31469
|
+
collectBindingNames5(el.name, out);
|
|
31155
31470
|
});
|
|
31156
31471
|
}
|
|
31157
31472
|
}
|
|
@@ -31160,12 +31475,12 @@ function collectFreeIdentifiers(arrow) {
|
|
|
31160
31475
|
const bound = [];
|
|
31161
31476
|
for (const p of arrow.parameters) {
|
|
31162
31477
|
const names = [];
|
|
31163
|
-
|
|
31478
|
+
collectBindingNames5(p.name, names);
|
|
31164
31479
|
bound.push(...names);
|
|
31165
31480
|
}
|
|
31166
31481
|
function pushBindings(name) {
|
|
31167
31482
|
const names = [];
|
|
31168
|
-
|
|
31483
|
+
collectBindingNames5(name, names);
|
|
31169
31484
|
bound.push(...names);
|
|
31170
31485
|
return names;
|
|
31171
31486
|
}
|
|
@@ -31177,48 +31492,48 @@ function collectFreeIdentifiers(arrow) {
|
|
|
31177
31492
|
return bound.includes(name);
|
|
31178
31493
|
}
|
|
31179
31494
|
function visit3(node) {
|
|
31180
|
-
if (
|
|
31495
|
+
if (ts33.isIdentifier(node)) {
|
|
31181
31496
|
const parent = node.parent;
|
|
31182
|
-
if (parent &&
|
|
31497
|
+
if (parent && ts33.isPropertyAccessExpression(parent) && parent.name === node)
|
|
31183
31498
|
return;
|
|
31184
|
-
if (parent &&
|
|
31499
|
+
if (parent && ts33.isPropertyAssignment(parent) && parent.name === node)
|
|
31185
31500
|
return;
|
|
31186
|
-
if (parent &&
|
|
31501
|
+
if (parent && ts33.isPropertySignature(parent) && parent.name === node)
|
|
31187
31502
|
return;
|
|
31188
|
-
if (parent &&
|
|
31503
|
+
if (parent && ts33.isPropertyDeclaration(parent) && parent.name === node)
|
|
31189
31504
|
return;
|
|
31190
|
-
if (parent &&
|
|
31505
|
+
if (parent && ts33.isMethodDeclaration(parent) && parent.name === node)
|
|
31191
31506
|
return;
|
|
31192
|
-
if (parent &&
|
|
31507
|
+
if (parent && ts33.isMethodSignature(parent) && parent.name === node)
|
|
31193
31508
|
return;
|
|
31194
|
-
if (parent &&
|
|
31509
|
+
if (parent && ts33.isGetAccessorDeclaration(parent) && parent.name === node)
|
|
31195
31510
|
return;
|
|
31196
|
-
if (parent &&
|
|
31511
|
+
if (parent && ts33.isSetAccessorDeclaration(parent) && parent.name === node)
|
|
31197
31512
|
return;
|
|
31198
|
-
if (parent &&
|
|
31513
|
+
if (parent && ts33.isEnumMember(parent) && parent.name === node)
|
|
31199
31514
|
return;
|
|
31200
|
-
if (parent &&
|
|
31515
|
+
if (parent && ts33.isBindingElement(parent) && parent.propertyName === node)
|
|
31201
31516
|
return;
|
|
31202
|
-
if (parent &&
|
|
31517
|
+
if (parent && ts33.isShorthandPropertyAssignment(parent) && parent.name === node) {
|
|
31203
31518
|
if (!isBound(node.text))
|
|
31204
31519
|
ids.add(node.text);
|
|
31205
31520
|
return;
|
|
31206
31521
|
}
|
|
31207
|
-
if (parent &&
|
|
31522
|
+
if (parent && ts33.isParameter(parent) && parent.name === node)
|
|
31208
31523
|
return;
|
|
31209
|
-
if (parent &&
|
|
31524
|
+
if (parent && ts33.isVariableDeclaration(parent) && parent.name === node)
|
|
31210
31525
|
return;
|
|
31211
|
-
if (parent &&
|
|
31526
|
+
if (parent && ts33.isFunctionDeclaration(parent) && parent.name === node)
|
|
31212
31527
|
return;
|
|
31213
|
-
if (parent &&
|
|
31528
|
+
if (parent && ts33.isClassDeclaration(parent) && parent.name === node)
|
|
31214
31529
|
return;
|
|
31215
|
-
if (parent &&
|
|
31530
|
+
if (parent && ts33.isJsxAttribute(parent) && parent.name === node)
|
|
31216
31531
|
return;
|
|
31217
|
-
if (parent &&
|
|
31532
|
+
if (parent && ts33.isJsxOpeningElement(parent) && parent.tagName === node) {
|
|
31218
31533
|
if (/^[a-z]/.test(node.text))
|
|
31219
31534
|
return;
|
|
31220
31535
|
}
|
|
31221
|
-
if (parent &&
|
|
31536
|
+
if (parent && ts33.isJsxClosingElement(parent) && parent.tagName === node) {
|
|
31222
31537
|
if (/^[a-z]/.test(node.text))
|
|
31223
31538
|
return;
|
|
31224
31539
|
}
|
|
@@ -31227,43 +31542,43 @@ function collectFreeIdentifiers(arrow) {
|
|
|
31227
31542
|
ids.add(node.text);
|
|
31228
31543
|
return;
|
|
31229
31544
|
}
|
|
31230
|
-
if (
|
|
31545
|
+
if (ts33.isVariableDeclaration(node)) {
|
|
31231
31546
|
const declared = pushBindings(node.name);
|
|
31232
31547
|
if (node.initializer)
|
|
31233
31548
|
visit3(node.initializer);
|
|
31234
31549
|
return;
|
|
31235
31550
|
}
|
|
31236
|
-
if (
|
|
31551
|
+
if (ts33.isFunctionDeclaration(node)) {
|
|
31237
31552
|
if (node.name)
|
|
31238
31553
|
bound.push(node.name.text);
|
|
31239
31554
|
visitInsideNewScope(node);
|
|
31240
31555
|
return;
|
|
31241
31556
|
}
|
|
31242
|
-
if (
|
|
31557
|
+
if (ts33.isClassDeclaration(node)) {
|
|
31243
31558
|
if (node.name)
|
|
31244
31559
|
bound.push(node.name.text);
|
|
31245
|
-
|
|
31560
|
+
ts33.forEachChild(node, visit3);
|
|
31246
31561
|
return;
|
|
31247
31562
|
}
|
|
31248
|
-
if (
|
|
31563
|
+
if (ts33.isArrowFunction(node) || ts33.isFunctionExpression(node)) {
|
|
31249
31564
|
visitInsideNewScope(node);
|
|
31250
31565
|
return;
|
|
31251
31566
|
}
|
|
31252
|
-
if (
|
|
31567
|
+
if (ts33.isCatchClause(node)) {
|
|
31253
31568
|
const before = bound.length;
|
|
31254
31569
|
if (node.variableDeclaration)
|
|
31255
31570
|
pushBindings(node.variableDeclaration.name);
|
|
31256
|
-
|
|
31571
|
+
ts33.forEachChild(node, visit3);
|
|
31257
31572
|
popN(bound.length - before);
|
|
31258
31573
|
return;
|
|
31259
31574
|
}
|
|
31260
|
-
if (
|
|
31575
|
+
if (ts33.isBlock(node)) {
|
|
31261
31576
|
const before = bound.length;
|
|
31262
|
-
|
|
31577
|
+
ts33.forEachChild(node, visit3);
|
|
31263
31578
|
popN(bound.length - before);
|
|
31264
31579
|
return;
|
|
31265
31580
|
}
|
|
31266
|
-
|
|
31581
|
+
ts33.forEachChild(node, visit3);
|
|
31267
31582
|
}
|
|
31268
31583
|
function visitInsideNewScope(fn) {
|
|
31269
31584
|
const before = bound.length;
|
|
@@ -31286,29 +31601,29 @@ function collectFreeIdentifiers(arrow) {
|
|
|
31286
31601
|
function collectModuleScopeNames(sourceFile) {
|
|
31287
31602
|
const names = new Set;
|
|
31288
31603
|
for (const stmt of sourceFile.statements) {
|
|
31289
|
-
if (
|
|
31604
|
+
if (ts33.isFunctionDeclaration(stmt) && stmt.name)
|
|
31290
31605
|
names.add(stmt.name.text);
|
|
31291
|
-
else if (
|
|
31606
|
+
else if (ts33.isClassDeclaration(stmt) && stmt.name)
|
|
31292
31607
|
names.add(stmt.name.text);
|
|
31293
|
-
else if (
|
|
31608
|
+
else if (ts33.isVariableStatement(stmt)) {
|
|
31294
31609
|
for (const decl of stmt.declarationList.declarations)
|
|
31295
|
-
|
|
31296
|
-
} else if (
|
|
31610
|
+
collectBindingNames5(decl.name, names);
|
|
31611
|
+
} else if (ts33.isImportDeclaration(stmt) && stmt.importClause) {
|
|
31297
31612
|
const ic = stmt.importClause;
|
|
31298
31613
|
if (ic.name)
|
|
31299
31614
|
names.add(ic.name.text);
|
|
31300
31615
|
if (ic.namedBindings) {
|
|
31301
|
-
if (
|
|
31616
|
+
if (ts33.isNamespaceImport(ic.namedBindings))
|
|
31302
31617
|
names.add(ic.namedBindings.name.text);
|
|
31303
31618
|
else
|
|
31304
31619
|
for (const e of ic.namedBindings.elements)
|
|
31305
31620
|
names.add(e.name.text);
|
|
31306
31621
|
}
|
|
31307
|
-
} else if (
|
|
31622
|
+
} else if (ts33.isTypeAliasDeclaration(stmt))
|
|
31308
31623
|
names.add(stmt.name.text);
|
|
31309
|
-
else if (
|
|
31624
|
+
else if (ts33.isInterfaceDeclaration(stmt))
|
|
31310
31625
|
names.add(stmt.name.text);
|
|
31311
|
-
else if (
|
|
31626
|
+
else if (ts33.isEnumDeclaration(stmt))
|
|
31312
31627
|
names.add(stmt.name.text);
|
|
31313
31628
|
}
|
|
31314
31629
|
return names;
|
|
@@ -31316,7 +31631,7 @@ function collectModuleScopeNames(sourceFile) {
|
|
|
31316
31631
|
function buildSyntheticDeclaration(name, arrow, sourceFile) {
|
|
31317
31632
|
const paramsText = arrow.parameters.length === 0 ? "" : arrow.parameters.map((p) => p.getText(sourceFile)).join(", ");
|
|
31318
31633
|
let bodyText;
|
|
31319
|
-
if (
|
|
31634
|
+
if (ts33.isBlock(arrow.body)) {
|
|
31320
31635
|
bodyText = arrow.body.getText(sourceFile);
|
|
31321
31636
|
} else {
|
|
31322
31637
|
const expr = arrow.body.getText(sourceFile);
|
|
@@ -31929,13 +32244,13 @@ function compileMultipleComponents(source, filePath, componentNames, options) {
|
|
|
31929
32244
|
if (entries.some((e) => e.componentIR.metadata.isClientComponent)) {
|
|
31930
32245
|
const topLevelNames = new Set;
|
|
31931
32246
|
{
|
|
31932
|
-
const sf =
|
|
32247
|
+
const sf = ts34.createSourceFile(filePath, source, ts34.ScriptTarget.Latest, true, ts34.ScriptKind.TSX);
|
|
31933
32248
|
for (const stmt of sf.statements) {
|
|
31934
|
-
if (
|
|
32249
|
+
if (ts34.isFunctionDeclaration(stmt) && stmt.name)
|
|
31935
32250
|
topLevelNames.add(stmt.name.text);
|
|
31936
|
-
else if (
|
|
32251
|
+
else if (ts34.isVariableStatement(stmt)) {
|
|
31937
32252
|
for (const d of stmt.declarationList.declarations) {
|
|
31938
|
-
if (
|
|
32253
|
+
if (ts34.isIdentifier(d.name))
|
|
31939
32254
|
topLevelNames.add(d.name.text);
|
|
31940
32255
|
}
|
|
31941
32256
|
}
|
|
@@ -31994,7 +32309,7 @@ function compileMultipleComponents(source, filePath, componentNames, options) {
|
|
|
31994
32309
|
const moduleStatementSeen = new Set;
|
|
31995
32310
|
const moduleStatementsOrdered = [];
|
|
31996
32311
|
const collectModuleStatements = (block) => {
|
|
31997
|
-
const sf =
|
|
32312
|
+
const sf = ts34.createSourceFile("__bf_module_decls.tsx", block, ts34.ScriptTarget.Latest, false, ts34.ScriptKind.TSX);
|
|
31998
32313
|
for (const stmt of sf.statements) {
|
|
31999
32314
|
const text = stmt.getText(sf);
|
|
32000
32315
|
if (moduleStatementSeen.has(text))
|
|
@@ -32414,7 +32729,7 @@ function isOpaqueLocalAccessorName(name, localConstants) {
|
|
|
32414
32729
|
return constant.parsed?.kind === "call";
|
|
32415
32730
|
}
|
|
32416
32731
|
// src/shared-program.ts
|
|
32417
|
-
import
|
|
32732
|
+
import ts35 from "typescript";
|
|
32418
32733
|
function commonParent(paths) {
|
|
32419
32734
|
if (paths.length === 0)
|
|
32420
32735
|
return process.cwd();
|
|
@@ -32435,10 +32750,10 @@ function commonParent(paths) {
|
|
|
32435
32750
|
function createProgramForCorpus(files, options = {}) {
|
|
32436
32751
|
const baseUrl = options.baseUrl ?? commonParent(files);
|
|
32437
32752
|
const compilerOptions = {
|
|
32438
|
-
target:
|
|
32439
|
-
module:
|
|
32440
|
-
moduleResolution:
|
|
32441
|
-
jsx:
|
|
32753
|
+
target: ts35.ScriptTarget.Latest,
|
|
32754
|
+
module: ts35.ModuleKind.ESNext,
|
|
32755
|
+
moduleResolution: ts35.ModuleResolutionKind.Bundler,
|
|
32756
|
+
jsx: ts35.JsxEmit.ReactJSX,
|
|
32442
32757
|
strict: true,
|
|
32443
32758
|
skipLibCheck: true,
|
|
32444
32759
|
noEmit: true,
|
|
@@ -32448,7 +32763,7 @@ function createProgramForCorpus(files, options = {}) {
|
|
|
32448
32763
|
...options.compilerOptions
|
|
32449
32764
|
};
|
|
32450
32765
|
const absolute = files.map((f) => path_default.resolve(f));
|
|
32451
|
-
return
|
|
32766
|
+
return ts35.createProgram(absolute, compilerOptions, undefined, options.oldProgram);
|
|
32452
32767
|
}
|
|
32453
32768
|
// src/adapters/interface.ts
|
|
32454
32769
|
class BaseAdapter {
|
|
@@ -35521,7 +35836,7 @@ class JsxAdapter extends BaseAdapter {
|
|
|
35521
35836
|
}
|
|
35522
35837
|
|
|
35523
35838
|
// src/adapters/template-imports.ts
|
|
35524
|
-
import
|
|
35839
|
+
import ts36 from "typescript";
|
|
35525
35840
|
var CLIENT_PACKAGE_SOURCES = new Set([
|
|
35526
35841
|
"@barefootjs/client",
|
|
35527
35842
|
"@barefootjs/client/runtime"
|
|
@@ -35571,18 +35886,18 @@ function specKey(s) {
|
|
|
35571
35886
|
function rewriteDynamicImportsInSource(sourceText, rewriteRelative) {
|
|
35572
35887
|
if (!sourceText.includes("import"))
|
|
35573
35888
|
return sourceText;
|
|
35574
|
-
const sf =
|
|
35889
|
+
const sf = ts36.createSourceFile("bf-template-fragment.tsx", sourceText, ts36.ScriptTarget.Latest, false, ts36.ScriptKind.TSX);
|
|
35575
35890
|
const edits = [];
|
|
35576
35891
|
const visit3 = (node) => {
|
|
35577
|
-
if (
|
|
35892
|
+
if (ts36.isCallExpression(node) && node.expression.kind === ts36.SyntaxKind.ImportKeyword && node.arguments.length > 0 && ts36.isStringLiteralLike(node.arguments[0])) {
|
|
35578
35893
|
collect(node.arguments[0]);
|
|
35579
35894
|
}
|
|
35580
|
-
if (
|
|
35895
|
+
if (ts36.isImportTypeNode(node) && ts36.isLiteralTypeNode(node.argument)) {
|
|
35581
35896
|
const literal = node.argument.literal;
|
|
35582
|
-
if (
|
|
35897
|
+
if (ts36.isStringLiteralLike(literal))
|
|
35583
35898
|
collect(literal);
|
|
35584
35899
|
}
|
|
35585
|
-
|
|
35900
|
+
ts36.forEachChild(node, visit3);
|
|
35586
35901
|
};
|
|
35587
35902
|
const collect = (literal) => {
|
|
35588
35903
|
const specifier = literal.text;
|
|
@@ -35597,7 +35912,7 @@ function rewriteDynamicImportsInSource(sourceText, rewriteRelative) {
|
|
|
35597
35912
|
text: `'${next}'`
|
|
35598
35913
|
});
|
|
35599
35914
|
};
|
|
35600
|
-
|
|
35915
|
+
ts36.forEachChild(sf, visit3);
|
|
35601
35916
|
if (edits.length === 0)
|
|
35602
35917
|
return sourceText;
|
|
35603
35918
|
let out = sourceText;
|
|
@@ -36805,7 +37120,7 @@ function renderFragmentScope(fragment, renderChildren, wrapScopeComment) {
|
|
|
36805
37120
|
return fragment.needsScopeComment ? wrapScopeComment(children) : children;
|
|
36806
37121
|
}
|
|
36807
37122
|
// src/combine-client-js.ts
|
|
36808
|
-
import
|
|
37123
|
+
import ts37 from "typescript";
|
|
36809
37124
|
var CHILD_PLACEHOLDER_RE = /import '\/\* @bf-child:(\w+) \*\/'/g;
|
|
36810
37125
|
function combineParentChildClientJs(files) {
|
|
36811
37126
|
const result = new Map;
|
|
@@ -36862,10 +37177,10 @@ function combineParentChildClientJs(files) {
|
|
|
36862
37177
|
return result;
|
|
36863
37178
|
}
|
|
36864
37179
|
function parseAndMerge(content, importsBySource, otherImports, codeSections) {
|
|
36865
|
-
const sourceFile =
|
|
37180
|
+
const sourceFile = ts37.createSourceFile("combine.js", content, ts37.ScriptTarget.Latest, false, ts37.ScriptKind.JS);
|
|
36866
37181
|
const importSpans = [];
|
|
36867
37182
|
for (const stmt of sourceFile.statements) {
|
|
36868
|
-
if (!
|
|
37183
|
+
if (!ts37.isImportDeclaration(stmt))
|
|
36869
37184
|
continue;
|
|
36870
37185
|
const start = stmt.getStart(sourceFile);
|
|
36871
37186
|
const end = stmt.getEnd();
|
|
@@ -36875,8 +37190,8 @@ function parseAndMerge(content, importsBySource, otherImports, codeSections) {
|
|
|
36875
37190
|
continue;
|
|
36876
37191
|
const clause = stmt.importClause;
|
|
36877
37192
|
const bindings = clause?.namedBindings;
|
|
36878
|
-
const specifier =
|
|
36879
|
-
if (clause && !clause.name && bindings &&
|
|
37193
|
+
const specifier = ts37.isStringLiteral(stmt.moduleSpecifier) ? stmt.moduleSpecifier.text : "";
|
|
37194
|
+
if (clause && !clause.name && bindings && ts37.isNamedImports(bindings)) {
|
|
36880
37195
|
if (!importsBySource.has(specifier)) {
|
|
36881
37196
|
importsBySource.set(specifier, new Set);
|
|
36882
37197
|
}
|
|
@@ -36904,7 +37219,7 @@ function parseAndMerge(content, importsBySource, otherImports, codeSections) {
|
|
|
36904
37219
|
}
|
|
36905
37220
|
}
|
|
36906
37221
|
// src/debug.ts
|
|
36907
|
-
import
|
|
37222
|
+
import ts38 from "typescript";
|
|
36908
37223
|
function buildComponentGraph(source, filePath, componentName) {
|
|
36909
37224
|
const ctx = analyzeComponent(source, filePath, componentName);
|
|
36910
37225
|
if (!ctx.jsxReturn) {
|
|
@@ -37119,7 +37434,7 @@ function bodyAccessorDeps(body, actions) {
|
|
|
37119
37434
|
return [];
|
|
37120
37435
|
const found = new Set;
|
|
37121
37436
|
const visit3 = (node) => {
|
|
37122
|
-
if (
|
|
37437
|
+
if (ts38.isExpression(node)) {
|
|
37123
37438
|
const parsed = tsNodeToParsedExpr(node);
|
|
37124
37439
|
if (!containsUnsupported(parsed)) {
|
|
37125
37440
|
for (const r of collectActionAccessorReads(parsed, actions))
|
|
@@ -37127,9 +37442,9 @@ function bodyAccessorDeps(body, actions) {
|
|
|
37127
37442
|
return;
|
|
37128
37443
|
}
|
|
37129
37444
|
}
|
|
37130
|
-
|
|
37445
|
+
ts38.forEachChild(node, visit3);
|
|
37131
37446
|
};
|
|
37132
|
-
visit3(
|
|
37447
|
+
visit3(ts38.createSourceFile("__body.tsx", `(${body})`, ts38.ScriptTarget.Latest, true, ts38.ScriptKind.TSX));
|
|
37133
37448
|
return [...found];
|
|
37134
37449
|
}
|
|
37135
37450
|
function containsUnsupported(expr) {
|
|
@@ -38388,16 +38703,16 @@ function truncateExpr(expr, max = 40) {
|
|
|
38388
38703
|
function collectPropMembers(expr, propsObjectName) {
|
|
38389
38704
|
let sf;
|
|
38390
38705
|
try {
|
|
38391
|
-
sf =
|
|
38706
|
+
sf = ts38.createSourceFile("__attr.tsx", `(${expr})`, ts38.ScriptTarget.Latest, true, ts38.ScriptKind.TSX);
|
|
38392
38707
|
} catch {
|
|
38393
38708
|
return [];
|
|
38394
38709
|
}
|
|
38395
38710
|
const members = new Set;
|
|
38396
38711
|
const visit3 = (n) => {
|
|
38397
|
-
if (
|
|
38712
|
+
if (ts38.isPropertyAccessExpression(n) && ts38.isIdentifier(n.expression) && n.expression.text === propsObjectName && n.name.text !== "children") {
|
|
38398
38713
|
members.add(n.name.text);
|
|
38399
38714
|
}
|
|
38400
|
-
|
|
38715
|
+
ts38.forEachChild(n, visit3);
|
|
38401
38716
|
};
|
|
38402
38717
|
visit3(sf);
|
|
38403
38718
|
return [...members];
|
|
@@ -38469,7 +38784,7 @@ function findSourceFile2(meta) {
|
|
|
38469
38784
|
return null;
|
|
38470
38785
|
}
|
|
38471
38786
|
// src/profiler.ts
|
|
38472
|
-
import
|
|
38787
|
+
import ts39 from "typescript";
|
|
38473
38788
|
var PROFILE_SCHEMA_VERSION = 1;
|
|
38474
38789
|
var DEFAULT_FANOUT_THRESHOLD = 8;
|
|
38475
38790
|
function buildStaticBudget(source, filePath, componentName, options = {}) {
|
|
@@ -38765,15 +39080,15 @@ function joinProfilerEvents(events, index) {
|
|
|
38765
39080
|
return { joined, unattributed, diagnostics };
|
|
38766
39081
|
}
|
|
38767
39082
|
function findUninstrumentedEffects(source, filePath, instrumentedLines) {
|
|
38768
|
-
const sf =
|
|
39083
|
+
const sf = ts39.createSourceFile(filePath, source, ts39.ScriptTarget.Latest, true, ts39.ScriptKind.TSX);
|
|
38769
39084
|
const out = [];
|
|
38770
39085
|
const visit3 = (node) => {
|
|
38771
|
-
if (
|
|
39086
|
+
if (ts39.isCallExpression(node) && ts39.isIdentifier(node.expression) && node.expression.text === "createEffect") {
|
|
38772
39087
|
const line = sf.getLineAndCharacterOfPosition(node.getStart(sf)).line + 1;
|
|
38773
39088
|
if (!instrumentedLines.has(line))
|
|
38774
39089
|
out.push({ file: filePath, line });
|
|
38775
39090
|
}
|
|
38776
|
-
|
|
39091
|
+
ts39.forEachChild(node, visit3);
|
|
38777
39092
|
};
|
|
38778
39093
|
visit3(sf);
|
|
38779
39094
|
out.sort((a, b) => a.line - b.line);
|
|
@@ -39081,13 +39396,13 @@ function assessBatchSafety(args) {
|
|
|
39081
39396
|
const signalGetters = new Set(args.graph.signals.map((s) => s.name));
|
|
39082
39397
|
let sf;
|
|
39083
39398
|
try {
|
|
39084
|
-
sf =
|
|
39399
|
+
sf = ts39.createSourceFile("__h.ts", `const __h = ${args.handler}`, ts39.ScriptTarget.Latest, true);
|
|
39085
39400
|
} catch {
|
|
39086
39401
|
return "unverified";
|
|
39087
39402
|
}
|
|
39088
39403
|
const calls = [];
|
|
39089
39404
|
const visit3 = (node) => {
|
|
39090
|
-
if (
|
|
39405
|
+
if (ts39.isCallExpression(node) && ts39.isIdentifier(node.expression)) {
|
|
39091
39406
|
const name = node.expression.text;
|
|
39092
39407
|
if (setters.has(name))
|
|
39093
39408
|
calls.push({ pos: node.getStart(sf), kind: "write" });
|
|
@@ -39096,7 +39411,7 @@ function assessBatchSafety(args) {
|
|
|
39096
39411
|
else if (!signalGetters.has(name) && !memoNames.has(name))
|
|
39097
39412
|
calls.push({ pos: node.getStart(sf), kind: "risky" });
|
|
39098
39413
|
}
|
|
39099
|
-
|
|
39414
|
+
ts39.forEachChild(node, visit3);
|
|
39100
39415
|
};
|
|
39101
39416
|
visit3(sf);
|
|
39102
39417
|
calls.sort((a, b) => a.pos - b.pos);
|
|
@@ -39956,6 +40271,7 @@ export {
|
|
|
39956
40271
|
formatComponentGraph,
|
|
39957
40272
|
formatBudgetDiff,
|
|
39958
40273
|
formatBatchAdvisor,
|
|
40274
|
+
foldStaticBindings,
|
|
39959
40275
|
foldNegatedNumberLiteral,
|
|
39960
40276
|
foldBlockToExpr,
|
|
39961
40277
|
findUninstrumentedEffects,
|