@barefootjs/test 0.31.4 → 0.31.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +423 -323
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -187288,7 +187288,7 @@ Additional information: BADCLIENT: Bad error code, ${badCode} not found in range
|
|
|
187288
187288
|
});
|
|
187289
187289
|
|
|
187290
187290
|
// ../jsx/src/compiler.ts
|
|
187291
|
-
var
|
|
187291
|
+
var import_typescript24 = __toESM(require_typescript(), 1);
|
|
187292
187292
|
|
|
187293
187293
|
// ../jsx/src/analyzer.ts
|
|
187294
187294
|
var import_typescript9 = __toESM(require_typescript(), 1);
|
|
@@ -193639,7 +193639,7 @@ function validateObjectFactoryDestructure(ctx, pattern, callee, loc) {
|
|
|
193639
193639
|
}
|
|
193640
193640
|
|
|
193641
193641
|
// ../jsx/src/jsx-to-ir.ts
|
|
193642
|
-
var
|
|
193642
|
+
var import_typescript13 = __toESM(require_typescript(), 1);
|
|
193643
193643
|
|
|
193644
193644
|
// ../jsx/src/types.ts
|
|
193645
193645
|
var SCOPE_FORBIDDEN = {
|
|
@@ -193715,6 +193715,7 @@ var AttrValueOf = {
|
|
|
193715
193715
|
};
|
|
193716
193716
|
|
|
193717
193717
|
// ../jsx/src/module-exports.ts
|
|
193718
|
+
var import_typescript10 = __toESM(require_typescript(), 1);
|
|
193718
193719
|
function formatParamWithType(p) {
|
|
193719
193720
|
const rest = p.isRest ? "..." : "";
|
|
193720
193721
|
const optional = p.optional ? "?" : "";
|
|
@@ -193745,6 +193746,49 @@ function findReachableNames(primaryRefs, declarations) {
|
|
|
193745
193746
|
}
|
|
193746
193747
|
return reachable;
|
|
193747
193748
|
}
|
|
193749
|
+
function findAssignedNames(bodyText, candidates) {
|
|
193750
|
+
const assigned = new Set;
|
|
193751
|
+
if (candidates.size === 0)
|
|
193752
|
+
return assigned;
|
|
193753
|
+
const sf = import_typescript10.default.createSourceFile("bf-assignment-scan.tsx", bodyText, import_typescript10.default.ScriptTarget.Latest, false, import_typescript10.default.ScriptKind.TSX);
|
|
193754
|
+
const record = (target) => {
|
|
193755
|
+
if (import_typescript10.default.isIdentifier(target) && candidates.has(target.text)) {
|
|
193756
|
+
assigned.add(target.text);
|
|
193757
|
+
}
|
|
193758
|
+
};
|
|
193759
|
+
const visit2 = (node) => {
|
|
193760
|
+
if (import_typescript10.default.isBinaryExpression(node) && isAssignmentOperator(node.operatorToken.kind)) {
|
|
193761
|
+
record(node.left);
|
|
193762
|
+
} else if ((import_typescript10.default.isPrefixUnaryExpression(node) || import_typescript10.default.isPostfixUnaryExpression(node)) && (node.operator === import_typescript10.default.SyntaxKind.PlusPlusToken || node.operator === import_typescript10.default.SyntaxKind.MinusMinusToken)) {
|
|
193763
|
+
record(node.operand);
|
|
193764
|
+
}
|
|
193765
|
+
import_typescript10.default.forEachChild(node, visit2);
|
|
193766
|
+
};
|
|
193767
|
+
import_typescript10.default.forEachChild(sf, visit2);
|
|
193768
|
+
return assigned;
|
|
193769
|
+
}
|
|
193770
|
+
function closeOverWritersOfMutableBindings(primaryRefs, declarations, mutableNames) {
|
|
193771
|
+
let reachable = findReachableNames(primaryRefs, declarations);
|
|
193772
|
+
if (mutableNames.size === 0)
|
|
193773
|
+
return reachable;
|
|
193774
|
+
let seedText = primaryRefs;
|
|
193775
|
+
for (let round = 0;round <= declarations.length; round++) {
|
|
193776
|
+
const survivingMutables = new Set([...reachable].filter((name) => mutableNames.has(name)));
|
|
193777
|
+
if (survivingMutables.size === 0)
|
|
193778
|
+
return reachable;
|
|
193779
|
+
const added = declarations.filter((d) => !reachable.has(d.name)).filter((d) => findAssignedNames(d.body, survivingMutables).size > 0).map((d) => d.name);
|
|
193780
|
+
if (added.length === 0)
|
|
193781
|
+
return reachable;
|
|
193782
|
+
seedText += `
|
|
193783
|
+
` + added.join(`
|
|
193784
|
+
`);
|
|
193785
|
+
reachable = findReachableNames(seedText, declarations);
|
|
193786
|
+
}
|
|
193787
|
+
return reachable;
|
|
193788
|
+
}
|
|
193789
|
+
function isAssignmentOperator(kind) {
|
|
193790
|
+
return kind >= import_typescript10.default.SyntaxKind.FirstAssignment && kind <= import_typescript10.default.SyntaxKind.LastAssignment;
|
|
193791
|
+
}
|
|
193748
193792
|
|
|
193749
193793
|
// ../jsx/src/builtins.ts
|
|
193750
193794
|
var CLIENT_BUILTIN_SOURCE = "@barefootjs/client";
|
|
@@ -193753,7 +193797,7 @@ function isClientBuiltinName(name) {
|
|
|
193753
193797
|
}
|
|
193754
193798
|
|
|
193755
193799
|
// ../jsx/src/reactivity-checker.ts
|
|
193756
|
-
var
|
|
193800
|
+
var import_typescript11 = __toESM(require_typescript(), 1);
|
|
193757
193801
|
var REACTIVE_BRAND = "__reactive";
|
|
193758
193802
|
function queryType(checker, node) {
|
|
193759
193803
|
incrementCounter("typeCheckerQueries");
|
|
@@ -193771,7 +193815,7 @@ function safeGetText(node) {
|
|
|
193771
193815
|
}
|
|
193772
193816
|
}
|
|
193773
193817
|
function analyze(node, checker) {
|
|
193774
|
-
if (
|
|
193818
|
+
if (import_typescript11.default.isPropertyAccessExpression(node)) {
|
|
193775
193819
|
try {
|
|
193776
193820
|
const type2 = queryType(checker, node);
|
|
193777
193821
|
if (isReactiveType(type2)) {
|
|
@@ -193795,7 +193839,7 @@ function analyze(node, checker) {
|
|
|
193795
193839
|
}
|
|
193796
193840
|
return NOT_REACTIVE;
|
|
193797
193841
|
}
|
|
193798
|
-
if (
|
|
193842
|
+
if (import_typescript11.default.isIdentifier(node)) {
|
|
193799
193843
|
try {
|
|
193800
193844
|
const type2 = queryType(checker, node);
|
|
193801
193845
|
if (isReactiveType(type2)) {
|
|
@@ -193807,7 +193851,7 @@ function analyze(node, checker) {
|
|
|
193807
193851
|
} catch {}
|
|
193808
193852
|
return NOT_REACTIVE;
|
|
193809
193853
|
}
|
|
193810
|
-
if (
|
|
193854
|
+
if (import_typescript11.default.isCallExpression(node)) {
|
|
193811
193855
|
try {
|
|
193812
193856
|
const calleeType = queryType(checker, node.expression);
|
|
193813
193857
|
if (isReactiveType(calleeType)) {
|
|
@@ -193820,7 +193864,7 @@ function analyze(node, checker) {
|
|
|
193820
193864
|
}
|
|
193821
193865
|
let foundChild;
|
|
193822
193866
|
let foundChildText = "";
|
|
193823
|
-
|
|
193867
|
+
import_typescript11.default.forEachChild(node, (child) => {
|
|
193824
193868
|
if (foundChild?.isReactive)
|
|
193825
193869
|
return;
|
|
193826
193870
|
const result = analyze(child, checker);
|
|
@@ -193849,7 +193893,7 @@ function containsReactiveExpression(node, checker) {
|
|
|
193849
193893
|
}
|
|
193850
193894
|
|
|
193851
193895
|
// ../jsx/src/free-refs.ts
|
|
193852
|
-
var
|
|
193896
|
+
var import_typescript12 = __toESM(require_typescript(), 1);
|
|
193853
193897
|
var _bindingMapCache = new WeakMap;
|
|
193854
193898
|
function buildBindingMap(env) {
|
|
193855
193899
|
const cached = _bindingMapCache.get(env);
|
|
@@ -193887,8 +193931,8 @@ function buildBindingMap(env) {
|
|
|
193887
193931
|
for (const m of env.memos) {
|
|
193888
193932
|
map.set(m.name, "memo-getter");
|
|
193889
193933
|
}
|
|
193890
|
-
if (env.
|
|
193891
|
-
for (const name of env.
|
|
193934
|
+
if (env.loopValueBoundNames) {
|
|
193935
|
+
for (const name of env.loopValueBoundNames)
|
|
193892
193936
|
map.set(name, "render-item");
|
|
193893
193937
|
}
|
|
193894
193938
|
_bindingMapCache.set(env, map);
|
|
@@ -193917,20 +193961,20 @@ function defaultBindingScope(kind) {
|
|
|
193917
193961
|
function collectIdentifiers2(node) {
|
|
193918
193962
|
const out = [];
|
|
193919
193963
|
const visit2 = (n, parent) => {
|
|
193920
|
-
if (
|
|
193921
|
-
if (parent &&
|
|
193964
|
+
if (import_typescript12.default.isIdentifier(n)) {
|
|
193965
|
+
if (parent && import_typescript12.default.isPropertyAccessExpression(parent) && parent.name === n)
|
|
193922
193966
|
return;
|
|
193923
|
-
if (parent &&
|
|
193967
|
+
if (parent && import_typescript12.default.isPropertyAssignment(parent) && parent.name === n)
|
|
193924
193968
|
return;
|
|
193925
|
-
if (parent && (
|
|
193969
|
+
if (parent && (import_typescript12.default.isJsxOpeningElement(parent) || import_typescript12.default.isJsxClosingElement(parent) || import_typescript12.default.isJsxSelfClosingElement(parent)) && parent.tagName === n) {
|
|
193926
193970
|
return;
|
|
193927
193971
|
}
|
|
193928
|
-
if (parent &&
|
|
193972
|
+
if (parent && import_typescript12.default.isJsxAttribute(parent) && parent.name === n)
|
|
193929
193973
|
return;
|
|
193930
193974
|
out.push(n);
|
|
193931
193975
|
return;
|
|
193932
193976
|
}
|
|
193933
|
-
|
|
193977
|
+
import_typescript12.default.forEachChild(n, (child) => visit2(child, n));
|
|
193934
193978
|
};
|
|
193935
193979
|
visit2(node);
|
|
193936
193980
|
return out;
|
|
@@ -193939,7 +193983,7 @@ function collectReactiveBrandRefs(node, checker) {
|
|
|
193939
193983
|
const out = [];
|
|
193940
193984
|
const seen = new Set;
|
|
193941
193985
|
const visit2 = (n) => {
|
|
193942
|
-
if (
|
|
193986
|
+
if (import_typescript12.default.isPropertyAccessExpression(n)) {
|
|
193943
193987
|
try {
|
|
193944
193988
|
const type2 = checker.getTypeAtLocation(n);
|
|
193945
193989
|
if (isReactiveType(type2)) {
|
|
@@ -193957,7 +194001,7 @@ function collectReactiveBrandRefs(node, checker) {
|
|
|
193957
194001
|
incrementCounter("freeRefsTypeLookupFailures");
|
|
193958
194002
|
}
|
|
193959
194003
|
}
|
|
193960
|
-
|
|
194004
|
+
import_typescript12.default.forEachChild(n, visit2);
|
|
193961
194005
|
};
|
|
193962
194006
|
visit2(node);
|
|
193963
194007
|
return out;
|
|
@@ -193967,14 +194011,14 @@ function resolveConstantInitializerRefs(c, env, visited) {
|
|
|
193967
194011
|
return [];
|
|
193968
194012
|
if (c.containsArrow)
|
|
193969
194013
|
return [];
|
|
193970
|
-
const sf =
|
|
194014
|
+
const sf = import_typescript12.default.createSourceFile("__const_init.ts", `const __probe = (${c.value});`, import_typescript12.default.ScriptTarget.Latest, true);
|
|
193971
194015
|
const stmt = sf.statements[0];
|
|
193972
|
-
if (!stmt || !
|
|
194016
|
+
if (!stmt || !import_typescript12.default.isVariableStatement(stmt))
|
|
193973
194017
|
return [];
|
|
193974
194018
|
const decl = stmt.declarationList.declarations[0];
|
|
193975
194019
|
if (!decl || !decl.initializer)
|
|
193976
194020
|
return [];
|
|
193977
|
-
const expr =
|
|
194021
|
+
const expr = import_typescript12.default.isParenthesizedExpression(decl.initializer) ? decl.initializer.expression : decl.initializer;
|
|
193978
194022
|
return resolveFreeRefsInternal(expr, env, visited);
|
|
193979
194023
|
}
|
|
193980
194024
|
function resolveFreeRefsInternal(node, env, visited) {
|
|
@@ -193986,7 +194030,7 @@ function resolveFreeRefsInternal(node, env, visited) {
|
|
|
193986
194030
|
const name = ident.text;
|
|
193987
194031
|
if (env.propsObjectName === name) {
|
|
193988
194032
|
const parent = ident.parent;
|
|
193989
|
-
if (parent &&
|
|
194033
|
+
if (parent && import_typescript12.default.isPropertyAccessExpression(parent) && parent.expression === ident && parent.name.text === "children") {
|
|
193990
194034
|
continue;
|
|
193991
194035
|
}
|
|
193992
194036
|
}
|
|
@@ -194414,13 +194458,13 @@ function exprCallsReactiveGetters(expr, ctx) {
|
|
|
194414
194458
|
function visit2(n) {
|
|
194415
194459
|
if (found)
|
|
194416
194460
|
return;
|
|
194417
|
-
if (
|
|
194461
|
+
if (import_typescript13.default.isCallExpression(n) && import_typescript13.default.isIdentifier(n.expression)) {
|
|
194418
194462
|
if (names.has(n.expression.text)) {
|
|
194419
194463
|
found = true;
|
|
194420
194464
|
return;
|
|
194421
194465
|
}
|
|
194422
194466
|
}
|
|
194423
|
-
|
|
194467
|
+
import_typescript13.default.forEachChild(n, visit2);
|
|
194424
194468
|
}
|
|
194425
194469
|
visit2(expr);
|
|
194426
194470
|
return found;
|
|
@@ -194447,11 +194491,11 @@ function exprReferencesModuleClientSignal(expr, ctx) {
|
|
|
194447
194491
|
function visit2(n) {
|
|
194448
194492
|
if (found)
|
|
194449
194493
|
return;
|
|
194450
|
-
if (
|
|
194494
|
+
if (import_typescript13.default.isCallExpression(n) && import_typescript13.default.isIdentifier(n.expression) && names.has(n.expression.text)) {
|
|
194451
194495
|
found = true;
|
|
194452
194496
|
return;
|
|
194453
194497
|
}
|
|
194454
|
-
|
|
194498
|
+
import_typescript13.default.forEachChild(n, visit2);
|
|
194455
194499
|
}
|
|
194456
194500
|
visit2(expr);
|
|
194457
194501
|
return found;
|
|
@@ -194461,11 +194505,11 @@ function exprHasFunctionCalls(expr) {
|
|
|
194461
194505
|
function visit2(n) {
|
|
194462
194506
|
if (found)
|
|
194463
194507
|
return;
|
|
194464
|
-
if (
|
|
194508
|
+
if (import_typescript13.default.isCallExpression(n)) {
|
|
194465
194509
|
found = true;
|
|
194466
194510
|
return;
|
|
194467
194511
|
}
|
|
194468
|
-
|
|
194512
|
+
import_typescript13.default.forEachChild(n, visit2);
|
|
194469
194513
|
}
|
|
194470
194514
|
visit2(expr);
|
|
194471
194515
|
return found;
|
|
@@ -194502,10 +194546,10 @@ function lowerDateCalls(text, expr, ctx) {
|
|
|
194502
194546
|
return text;
|
|
194503
194547
|
const candidates = [];
|
|
194504
194548
|
function visit2(n) {
|
|
194505
|
-
if (
|
|
194549
|
+
if (import_typescript13.default.isCallExpression(n) && n.arguments.length === 0 && import_typescript13.default.isPropertyAccessExpression(n.expression) && !n.expression.questionDotToken && DATE_METHODS.has(n.expression.name.text)) {
|
|
194506
194550
|
candidates.push(n);
|
|
194507
194551
|
}
|
|
194508
|
-
|
|
194552
|
+
import_typescript13.default.forEachChild(n, visit2);
|
|
194509
194553
|
}
|
|
194510
194554
|
visit2(expr);
|
|
194511
194555
|
if (candidates.length === 0)
|
|
@@ -194530,10 +194574,10 @@ function lowerToLocaleDateCalls(text, expr, ctx) {
|
|
|
194530
194574
|
return text;
|
|
194531
194575
|
const candidates = [];
|
|
194532
194576
|
function visit2(n) {
|
|
194533
|
-
if (
|
|
194577
|
+
if (import_typescript13.default.isCallExpression(n) && n.arguments.length === 2 && import_typescript13.default.isPropertyAccessExpression(n.expression) && !n.expression.questionDotToken && n.expression.name.text === "toLocaleDateString") {
|
|
194534
194578
|
candidates.push(n);
|
|
194535
194579
|
}
|
|
194536
|
-
|
|
194580
|
+
import_typescript13.default.forEachChild(n, visit2);
|
|
194537
194581
|
}
|
|
194538
194582
|
visit2(expr);
|
|
194539
194583
|
if (candidates.length === 0)
|
|
@@ -194587,10 +194631,10 @@ function collectBranchLocalPropRefsViaSubstitution(node, ctx) {
|
|
|
194587
194631
|
return;
|
|
194588
194632
|
let acc;
|
|
194589
194633
|
function visit2(n, parent) {
|
|
194590
|
-
if (
|
|
194591
|
-
const isObjectKey = parent &&
|
|
194592
|
-
const isShorthand = parent &&
|
|
194593
|
-
const isAccessName = parent &&
|
|
194634
|
+
if (import_typescript13.default.isIdentifier(n) && propDepsMap.has(n.text)) {
|
|
194635
|
+
const isObjectKey = parent && import_typescript13.default.isPropertyAssignment(parent) && parent.name === n;
|
|
194636
|
+
const isShorthand = parent && import_typescript13.default.isShorthandPropertyAssignment(parent) && parent.name === n;
|
|
194637
|
+
const isAccessName = parent && import_typescript13.default.isPropertyAccessExpression(parent) && parent.name === n;
|
|
194594
194638
|
if (!isObjectKey && !isShorthand && !isAccessName) {
|
|
194595
194639
|
const deps = propDepsMap.get(n.text);
|
|
194596
194640
|
if (deps && deps.size > 0) {
|
|
@@ -194601,7 +194645,7 @@ function collectBranchLocalPropRefsViaSubstitution(node, ctx) {
|
|
|
194601
194645
|
}
|
|
194602
194646
|
}
|
|
194603
194647
|
}
|
|
194604
|
-
|
|
194648
|
+
import_typescript13.default.forEachChild(n, (child) => visit2(child, n));
|
|
194605
194649
|
}
|
|
194606
194650
|
visit2(node);
|
|
194607
194651
|
return acc;
|
|
@@ -194677,21 +194721,21 @@ function createTransformContext(analyzer) {
|
|
|
194677
194721
|
function buildComponentNamespaces(ctx) {
|
|
194678
194722
|
const result = new Map;
|
|
194679
194723
|
for (const stmt of ctx.sourceFile.statements) {
|
|
194680
|
-
if (!
|
|
194724
|
+
if (!import_typescript13.default.isVariableStatement(stmt))
|
|
194681
194725
|
continue;
|
|
194682
194726
|
for (const decl of stmt.declarationList.declarations) {
|
|
194683
|
-
if (!decl.initializer || !
|
|
194727
|
+
if (!decl.initializer || !import_typescript13.default.isIdentifier(decl.name))
|
|
194684
194728
|
continue;
|
|
194685
194729
|
let init = decl.initializer;
|
|
194686
|
-
while (
|
|
194730
|
+
while (import_typescript13.default.isParenthesizedExpression(init))
|
|
194687
194731
|
init = init.expression;
|
|
194688
|
-
if (!
|
|
194732
|
+
if (!import_typescript13.default.isObjectLiteralExpression(init))
|
|
194689
194733
|
continue;
|
|
194690
194734
|
const members = new Map;
|
|
194691
194735
|
for (const prop of init.properties) {
|
|
194692
|
-
if (
|
|
194736
|
+
if (import_typescript13.default.isShorthandPropertyAssignment(prop)) {
|
|
194693
194737
|
members.set(prop.name.text, prop.name.text);
|
|
194694
|
-
} else if (
|
|
194738
|
+
} else if (import_typescript13.default.isPropertyAssignment(prop) && (import_typescript13.default.isIdentifier(prop.name) || import_typescript13.default.isStringLiteral(prop.name)) && import_typescript13.default.isIdentifier(prop.initializer)) {
|
|
194695
194739
|
members.set(prop.name.text, prop.initializer.text);
|
|
194696
194740
|
}
|
|
194697
194741
|
}
|
|
@@ -194703,11 +194747,11 @@ function buildComponentNamespaces(ctx) {
|
|
|
194703
194747
|
return result;
|
|
194704
194748
|
}
|
|
194705
194749
|
function resolveMemberExpressionTag(tagNode, ctx) {
|
|
194706
|
-
if (!
|
|
194750
|
+
if (!import_typescript13.default.isPropertyAccessExpression(tagNode))
|
|
194707
194751
|
return null;
|
|
194708
|
-
if (!
|
|
194752
|
+
if (!import_typescript13.default.isIdentifier(tagNode.expression))
|
|
194709
194753
|
return null;
|
|
194710
|
-
if (!
|
|
194754
|
+
if (!import_typescript13.default.isIdentifier(tagNode.name))
|
|
194711
194755
|
return null;
|
|
194712
194756
|
if (!ctx._componentNamespaces) {
|
|
194713
194757
|
ctx._componentNamespaces = buildComponentNamespaces(ctx);
|
|
@@ -194740,7 +194784,7 @@ function makeBindingEnv(ctx) {
|
|
|
194740
194784
|
localFunctions: a.localFunctions,
|
|
194741
194785
|
imports: a.imports,
|
|
194742
194786
|
ambientGlobals: a.ambientGlobals,
|
|
194743
|
-
|
|
194787
|
+
loopValueBoundNames: boundNames,
|
|
194744
194788
|
checker: a.checker
|
|
194745
194789
|
};
|
|
194746
194790
|
ctx._bindingEnv = env;
|
|
@@ -194864,7 +194908,7 @@ function buildIRRoot(analyzer) {
|
|
|
194864
194908
|
return null;
|
|
194865
194909
|
const ctx = createTransformContext(analyzer);
|
|
194866
194910
|
const jsxReturn = analyzer.jsxReturn;
|
|
194867
|
-
if (
|
|
194911
|
+
if (import_typescript13.default.isJsxElement(jsxReturn) || import_typescript13.default.isJsxSelfClosingElement(jsxReturn) || import_typescript13.default.isJsxFragment(jsxReturn)) {
|
|
194868
194912
|
const ir2 = transformNode(jsxReturn, ctx);
|
|
194869
194913
|
if (ir2 && needsScopeWrapper(ir2)) {
|
|
194870
194914
|
return wrapInScopeElement(ir2);
|
|
@@ -194920,22 +194964,22 @@ function wrapInScopeElement(node) {
|
|
|
194920
194964
|
};
|
|
194921
194965
|
}
|
|
194922
194966
|
function transformNode(node, ctx) {
|
|
194923
|
-
if (
|
|
194967
|
+
if (import_typescript13.default.isJsxElement(node)) {
|
|
194924
194968
|
return transformJsxElement(node, ctx);
|
|
194925
194969
|
}
|
|
194926
|
-
if (
|
|
194970
|
+
if (import_typescript13.default.isJsxSelfClosingElement(node)) {
|
|
194927
194971
|
return transformSelfClosingElement(node, ctx);
|
|
194928
194972
|
}
|
|
194929
|
-
if (
|
|
194973
|
+
if (import_typescript13.default.isJsxFragment(node)) {
|
|
194930
194974
|
return transformFragment(node, ctx);
|
|
194931
194975
|
}
|
|
194932
|
-
if (
|
|
194976
|
+
if (import_typescript13.default.isJsxText(node)) {
|
|
194933
194977
|
return transformText(node, ctx);
|
|
194934
194978
|
}
|
|
194935
|
-
if (
|
|
194979
|
+
if (import_typescript13.default.isJsxExpression(node)) {
|
|
194936
194980
|
return transformExpression(node, ctx);
|
|
194937
194981
|
}
|
|
194938
|
-
if (
|
|
194982
|
+
if (import_typescript13.default.isConditionalExpression(node)) {
|
|
194939
194983
|
return transformConditional(node, ctx);
|
|
194940
194984
|
}
|
|
194941
194985
|
return null;
|
|
@@ -195292,7 +195336,7 @@ function transformSelfClosingComponent(node, ctx, name) {
|
|
|
195292
195336
|
}
|
|
195293
195337
|
function isTransparentFragment(node, ctx) {
|
|
195294
195338
|
const children = node.children.filter((child2) => {
|
|
195295
|
-
if (
|
|
195339
|
+
if (import_typescript13.default.isJsxText(child2)) {
|
|
195296
195340
|
return child2.text.trim() !== "";
|
|
195297
195341
|
}
|
|
195298
195342
|
return true;
|
|
@@ -195300,7 +195344,7 @@ function isTransparentFragment(node, ctx) {
|
|
|
195300
195344
|
if (children.length !== 1)
|
|
195301
195345
|
return false;
|
|
195302
195346
|
const child = children[0];
|
|
195303
|
-
if (!
|
|
195347
|
+
if (!import_typescript13.default.isJsxExpression(child))
|
|
195304
195348
|
return false;
|
|
195305
195349
|
if (!child.expression)
|
|
195306
195350
|
return false;
|
|
@@ -195344,7 +195388,7 @@ function transformChildren(children, ctx) {
|
|
|
195344
195388
|
const result = [];
|
|
195345
195389
|
for (let i2 = 0;i2 < children.length; i2++) {
|
|
195346
195390
|
const child = children[i2];
|
|
195347
|
-
if (
|
|
195391
|
+
if (import_typescript13.default.isJsxExpression(child) && !child.expression) {
|
|
195348
195392
|
continue;
|
|
195349
195393
|
}
|
|
195350
195394
|
const transformed = transformNode(child, ctx);
|
|
@@ -195359,10 +195403,10 @@ function transformChildren(children, ctx) {
|
|
|
195359
195403
|
}
|
|
195360
195404
|
function isRenderNothingLiteral(expr, ctx) {
|
|
195361
195405
|
let e = expr;
|
|
195362
|
-
while (
|
|
195406
|
+
while (import_typescript13.default.isParenthesizedExpression(e) || import_typescript13.default.isAsExpression(e) || import_typescript13.default.isSatisfiesExpression(e) || import_typescript13.default.isNonNullExpression(e)) {
|
|
195363
195407
|
e = e.expression;
|
|
195364
195408
|
}
|
|
195365
|
-
return e.kind ===
|
|
195409
|
+
return e.kind === import_typescript13.default.SyntaxKind.NullKeyword || e.kind === import_typescript13.default.SyntaxKind.TrueKeyword || e.kind === import_typescript13.default.SyntaxKind.FalseKeyword || import_typescript13.default.isIdentifier(e) && e.text === "undefined" && !isNameBound("undefined", makeBindingEnv(ctx));
|
|
195366
195410
|
}
|
|
195367
195411
|
function transformText(node, ctx) {
|
|
195368
195412
|
const text = node.text.replace(/\s+/g, " ");
|
|
@@ -195388,7 +195432,7 @@ function transformExpressionInner(expr, ctx, node, isClientOnly) {
|
|
|
195388
195432
|
return null;
|
|
195389
195433
|
}
|
|
195390
195434
|
checkBareSignalOrMemoIdentifier(expr, ctx);
|
|
195391
|
-
if (
|
|
195435
|
+
if (import_typescript13.default.isIdentifier(expr)) {
|
|
195392
195436
|
const jsxNode = ctx.analyzer.jsxConstants.get(expr.text);
|
|
195393
195437
|
if (jsxNode) {
|
|
195394
195438
|
return transformNode(jsxNode, ctx);
|
|
@@ -195667,38 +195711,38 @@ function transformLogicalAnd(node, ctx) {
|
|
|
195667
195711
|
};
|
|
195668
195712
|
}
|
|
195669
195713
|
function containsJsxInExpression(node) {
|
|
195670
|
-
if (
|
|
195714
|
+
if (import_typescript13.default.isJsxElement(node) || import_typescript13.default.isJsxSelfClosingElement(node) || import_typescript13.default.isJsxFragment(node)) {
|
|
195671
195715
|
return true;
|
|
195672
195716
|
}
|
|
195673
|
-
return
|
|
195717
|
+
return import_typescript13.default.forEachChild(node, containsJsxInExpression) ?? false;
|
|
195674
195718
|
}
|
|
195675
195719
|
function callsJsxHelper(node, ctx) {
|
|
195676
195720
|
let found = false;
|
|
195677
195721
|
const visit2 = (n) => {
|
|
195678
195722
|
if (found)
|
|
195679
195723
|
return;
|
|
195680
|
-
if (
|
|
195724
|
+
if (import_typescript13.default.isCallExpression(n) && import_typescript13.default.isIdentifier(n.expression)) {
|
|
195681
195725
|
const name = n.expression.text;
|
|
195682
195726
|
if (ctx.analyzer.jsxFunctions.has(name) || ctx.analyzer.jsxMultiReturnFunctions.has(name)) {
|
|
195683
195727
|
found = true;
|
|
195684
195728
|
return;
|
|
195685
195729
|
}
|
|
195686
195730
|
}
|
|
195687
|
-
|
|
195731
|
+
import_typescript13.default.forEachChild(n, visit2);
|
|
195688
195732
|
};
|
|
195689
195733
|
visit2(node);
|
|
195690
195734
|
return found;
|
|
195691
195735
|
}
|
|
195692
195736
|
function containsAwaitExpression(node) {
|
|
195693
|
-
if (
|
|
195737
|
+
if (import_typescript13.default.isAwaitExpression(node))
|
|
195694
195738
|
return true;
|
|
195695
|
-
if (
|
|
195739
|
+
if (import_typescript13.default.isFunctionDeclaration(node) || import_typescript13.default.isFunctionExpression(node) || import_typescript13.default.isArrowFunction(node))
|
|
195696
195740
|
return false;
|
|
195697
|
-
return
|
|
195741
|
+
return import_typescript13.default.forEachChild(node, containsAwaitExpression) ?? false;
|
|
195698
195742
|
}
|
|
195699
195743
|
function transformNullishCoalescing(node, ctx) {
|
|
195700
195744
|
const leftText = ctx.getJS(node.left);
|
|
195701
|
-
const isNullish = node.operatorToken.kind ===
|
|
195745
|
+
const isNullish = node.operatorToken.kind === import_typescript13.default.SyntaxKind.QuestionQuestionToken;
|
|
195702
195746
|
const condition = isNullish ? `${leftText} != null` : leftText;
|
|
195703
195747
|
const leftOrigin = {
|
|
195704
195748
|
phase: "tick",
|
|
@@ -195744,36 +195788,36 @@ function transformNullishCoalescing(node, ctx) {
|
|
|
195744
195788
|
}
|
|
195745
195789
|
function assertNever2(expr) {
|
|
195746
195790
|
const kind = expr?.kind;
|
|
195747
|
-
throw new Error(`transformJsxExpression: unhandled ts.SyntaxKind ${kind !== undefined ?
|
|
195791
|
+
throw new Error(`transformJsxExpression: unhandled ts.SyntaxKind ${kind !== undefined ? import_typescript13.default.SyntaxKind[kind] : "unknown"} ` + `(kind=${kind}). Update spec/compiler.md Appendix A and the switch in jsx-to-ir.ts.`);
|
|
195748
195792
|
}
|
|
195749
195793
|
function transformJsxExpression(expr, ctx, isClientOnly = false) {
|
|
195750
195794
|
const node = expr;
|
|
195751
195795
|
switch (node.kind) {
|
|
195752
|
-
case
|
|
195753
|
-
case
|
|
195754
|
-
case
|
|
195755
|
-
case
|
|
195756
|
-
case
|
|
195757
|
-
case
|
|
195796
|
+
case import_typescript13.default.SyntaxKind.ParenthesizedExpression:
|
|
195797
|
+
case import_typescript13.default.SyntaxKind.AsExpression:
|
|
195798
|
+
case import_typescript13.default.SyntaxKind.SatisfiesExpression:
|
|
195799
|
+
case import_typescript13.default.SyntaxKind.NonNullExpression:
|
|
195800
|
+
case import_typescript13.default.SyntaxKind.TypeAssertionExpression:
|
|
195801
|
+
case import_typescript13.default.SyntaxKind.PartiallyEmittedExpression:
|
|
195758
195802
|
return transformJsxExpression(node.expression, ctx, isClientOnly);
|
|
195759
|
-
case
|
|
195803
|
+
case import_typescript13.default.SyntaxKind.JsxElement:
|
|
195760
195804
|
return transformJsxElement(node, ctx);
|
|
195761
|
-
case
|
|
195805
|
+
case import_typescript13.default.SyntaxKind.JsxFragment:
|
|
195762
195806
|
return transformFragment(node, ctx);
|
|
195763
|
-
case
|
|
195807
|
+
case import_typescript13.default.SyntaxKind.JsxSelfClosingElement:
|
|
195764
195808
|
return transformSelfClosingElement(node, ctx);
|
|
195765
|
-
case
|
|
195809
|
+
case import_typescript13.default.SyntaxKind.ConditionalExpression:
|
|
195766
195810
|
return transformConditional(node, ctx);
|
|
195767
|
-
case
|
|
195768
|
-
if (node.operatorToken.kind ===
|
|
195811
|
+
case import_typescript13.default.SyntaxKind.BinaryExpression: {
|
|
195812
|
+
if (node.operatorToken.kind === import_typescript13.default.SyntaxKind.AmpersandAmpersandToken) {
|
|
195769
195813
|
return transformLogicalAnd(node, ctx);
|
|
195770
195814
|
}
|
|
195771
|
-
if ((node.operatorToken.kind ===
|
|
195815
|
+
if ((node.operatorToken.kind === import_typescript13.default.SyntaxKind.QuestionQuestionToken || node.operatorToken.kind === import_typescript13.default.SyntaxKind.BarBarToken) && (containsJsxInExpression(node.right) || callsJsxHelper(node.right, ctx))) {
|
|
195772
195816
|
return transformNullishCoalescing(node, ctx);
|
|
195773
195817
|
}
|
|
195774
195818
|
return null;
|
|
195775
195819
|
}
|
|
195776
|
-
case
|
|
195820
|
+
case import_typescript13.default.SyntaxKind.CallExpression: {
|
|
195777
195821
|
const mapMethod = getMapLikeMethod(node);
|
|
195778
195822
|
if (mapMethod) {
|
|
195779
195823
|
const mapResult = transformMapCall(node, ctx, isClientOnly, mapMethod);
|
|
@@ -195781,7 +195825,7 @@ function transformJsxExpression(expr, ctx, isClientOnly = false) {
|
|
|
195781
195825
|
return mapResult;
|
|
195782
195826
|
}
|
|
195783
195827
|
const callee = node.expression;
|
|
195784
|
-
if (
|
|
195828
|
+
if (import_typescript13.default.isIdentifier(callee)) {
|
|
195785
195829
|
const jsxFunc = ctx.analyzer.jsxFunctions.get(callee.text);
|
|
195786
195830
|
if (jsxFunc) {
|
|
195787
195831
|
return transformJsxFunctionCall(node, jsxFunc, ctx, isClientOnly);
|
|
@@ -195793,39 +195837,39 @@ function transformJsxExpression(expr, ctx, isClientOnly = false) {
|
|
|
195793
195837
|
}
|
|
195794
195838
|
return null;
|
|
195795
195839
|
}
|
|
195796
|
-
case
|
|
195797
|
-
case
|
|
195798
|
-
case
|
|
195799
|
-
case
|
|
195800
|
-
case
|
|
195801
|
-
case
|
|
195802
|
-
case
|
|
195803
|
-
case
|
|
195804
|
-
case
|
|
195805
|
-
case
|
|
195806
|
-
case
|
|
195807
|
-
case
|
|
195808
|
-
case
|
|
195809
|
-
case
|
|
195810
|
-
case
|
|
195811
|
-
case
|
|
195812
|
-
case
|
|
195813
|
-
case
|
|
195814
|
-
case
|
|
195815
|
-
case
|
|
195816
|
-
case
|
|
195817
|
-
case
|
|
195818
|
-
case
|
|
195819
|
-
case
|
|
195820
|
-
case
|
|
195821
|
-
case
|
|
195822
|
-
case
|
|
195823
|
-
case
|
|
195824
|
-
case
|
|
195825
|
-
case
|
|
195826
|
-
case
|
|
195840
|
+
case import_typescript13.default.SyntaxKind.Identifier:
|
|
195841
|
+
case import_typescript13.default.SyntaxKind.StringLiteral:
|
|
195842
|
+
case import_typescript13.default.SyntaxKind.NumericLiteral:
|
|
195843
|
+
case import_typescript13.default.SyntaxKind.BigIntLiteral:
|
|
195844
|
+
case import_typescript13.default.SyntaxKind.RegularExpressionLiteral:
|
|
195845
|
+
case import_typescript13.default.SyntaxKind.NoSubstitutionTemplateLiteral:
|
|
195846
|
+
case import_typescript13.default.SyntaxKind.TemplateExpression:
|
|
195847
|
+
case import_typescript13.default.SyntaxKind.TaggedTemplateExpression:
|
|
195848
|
+
case import_typescript13.default.SyntaxKind.TrueKeyword:
|
|
195849
|
+
case import_typescript13.default.SyntaxKind.FalseKeyword:
|
|
195850
|
+
case import_typescript13.default.SyntaxKind.NullKeyword:
|
|
195851
|
+
case import_typescript13.default.SyntaxKind.ThisKeyword:
|
|
195852
|
+
case import_typescript13.default.SyntaxKind.SuperKeyword:
|
|
195853
|
+
case import_typescript13.default.SyntaxKind.ImportKeyword:
|
|
195854
|
+
case import_typescript13.default.SyntaxKind.PropertyAccessExpression:
|
|
195855
|
+
case import_typescript13.default.SyntaxKind.ElementAccessExpression:
|
|
195856
|
+
case import_typescript13.default.SyntaxKind.PrefixUnaryExpression:
|
|
195857
|
+
case import_typescript13.default.SyntaxKind.PostfixUnaryExpression:
|
|
195858
|
+
case import_typescript13.default.SyntaxKind.TypeOfExpression:
|
|
195859
|
+
case import_typescript13.default.SyntaxKind.VoidExpression:
|
|
195860
|
+
case import_typescript13.default.SyntaxKind.DeleteExpression:
|
|
195861
|
+
case import_typescript13.default.SyntaxKind.NewExpression:
|
|
195862
|
+
case import_typescript13.default.SyntaxKind.ObjectLiteralExpression:
|
|
195863
|
+
case import_typescript13.default.SyntaxKind.ArrowFunction:
|
|
195864
|
+
case import_typescript13.default.SyntaxKind.FunctionExpression:
|
|
195865
|
+
case import_typescript13.default.SyntaxKind.ClassExpression:
|
|
195866
|
+
case import_typescript13.default.SyntaxKind.MetaProperty:
|
|
195867
|
+
case import_typescript13.default.SyntaxKind.ExpressionWithTypeArguments:
|
|
195868
|
+
case import_typescript13.default.SyntaxKind.CommaListExpression:
|
|
195869
|
+
case import_typescript13.default.SyntaxKind.SyntheticExpression:
|
|
195870
|
+
case import_typescript13.default.SyntaxKind.ArrayLiteralExpression:
|
|
195827
195871
|
return null;
|
|
195828
|
-
case
|
|
195872
|
+
case import_typescript13.default.SyntaxKind.AwaitExpression:
|
|
195829
195873
|
ctx.analyzer.errors.push(createError(ErrorCodes.STAGE_AWAIT_IN_TEMPLATE, getSourceLocation(node, ctx.sourceFile, ctx.filePath)));
|
|
195830
195874
|
return {
|
|
195831
195875
|
type: "expression",
|
|
@@ -195836,16 +195880,16 @@ function transformJsxExpression(expr, ctx, isClientOnly = false) {
|
|
|
195836
195880
|
loc: getSourceLocation(node, ctx.sourceFile, ctx.filePath),
|
|
195837
195881
|
origin: { phase: "tick", scope: "template", effect: "pure", freeRefs: [] }
|
|
195838
195882
|
};
|
|
195839
|
-
case
|
|
195883
|
+
case import_typescript13.default.SyntaxKind.YieldExpression:
|
|
195840
195884
|
return null;
|
|
195841
|
-
case
|
|
195842
|
-
case
|
|
195843
|
-
case
|
|
195844
|
-
case
|
|
195845
|
-
case
|
|
195846
|
-
case
|
|
195847
|
-
case
|
|
195848
|
-
case
|
|
195885
|
+
case import_typescript13.default.SyntaxKind.SpreadElement:
|
|
195886
|
+
case import_typescript13.default.SyntaxKind.OmittedExpression:
|
|
195887
|
+
case import_typescript13.default.SyntaxKind.JsxExpression:
|
|
195888
|
+
case import_typescript13.default.SyntaxKind.JsxOpeningElement:
|
|
195889
|
+
case import_typescript13.default.SyntaxKind.JsxOpeningFragment:
|
|
195890
|
+
case import_typescript13.default.SyntaxKind.JsxClosingFragment:
|
|
195891
|
+
case import_typescript13.default.SyntaxKind.JsxAttributes:
|
|
195892
|
+
case import_typescript13.default.SyntaxKind.MissingDeclaration:
|
|
195849
195893
|
return null;
|
|
195850
195894
|
default:
|
|
195851
195895
|
return assertNever2(node);
|
|
@@ -195882,7 +195926,7 @@ function transformConditionalBranch(node, ctx) {
|
|
|
195882
195926
|
};
|
|
195883
195927
|
}
|
|
195884
195928
|
function getMapLikeMethod(node) {
|
|
195885
|
-
if (!
|
|
195929
|
+
if (!import_typescript13.default.isPropertyAccessExpression(node.expression))
|
|
195886
195930
|
return null;
|
|
195887
195931
|
const name = node.expression.name.text;
|
|
195888
195932
|
if (name === "map")
|
|
@@ -195892,9 +195936,9 @@ function getMapLikeMethod(node) {
|
|
|
195892
195936
|
return null;
|
|
195893
195937
|
}
|
|
195894
195938
|
function isFilterCall(node) {
|
|
195895
|
-
if (!
|
|
195939
|
+
if (!import_typescript13.default.isCallExpression(node))
|
|
195896
195940
|
return null;
|
|
195897
|
-
if (!
|
|
195941
|
+
if (!import_typescript13.default.isPropertyAccessExpression(node.expression))
|
|
195898
195942
|
return null;
|
|
195899
195943
|
if (node.expression.name.text !== "filter")
|
|
195900
195944
|
return null;
|
|
@@ -195906,9 +195950,9 @@ function isFilterCall(node) {
|
|
|
195906
195950
|
};
|
|
195907
195951
|
}
|
|
195908
195952
|
function isSortCall(node) {
|
|
195909
|
-
if (!
|
|
195953
|
+
if (!import_typescript13.default.isCallExpression(node))
|
|
195910
195954
|
return null;
|
|
195911
|
-
if (!
|
|
195955
|
+
if (!import_typescript13.default.isPropertyAccessExpression(node.expression))
|
|
195912
195956
|
return null;
|
|
195913
195957
|
const methodName = node.expression.name.text;
|
|
195914
195958
|
if (methodName !== "sort" && methodName !== "toSorted")
|
|
@@ -195922,9 +195966,9 @@ function isSortCall(node) {
|
|
|
195922
195966
|
};
|
|
195923
195967
|
}
|
|
195924
195968
|
function isIteratorShapeCall(node) {
|
|
195925
|
-
if (!
|
|
195969
|
+
if (!import_typescript13.default.isCallExpression(node))
|
|
195926
195970
|
return null;
|
|
195927
|
-
if (!
|
|
195971
|
+
if (!import_typescript13.default.isPropertyAccessExpression(node.expression))
|
|
195928
195972
|
return null;
|
|
195929
195973
|
if (node.arguments.length !== 0)
|
|
195930
195974
|
return null;
|
|
@@ -195934,11 +195978,11 @@ function isIteratorShapeCall(node) {
|
|
|
195934
195978
|
return { array: node.expression.expression, shape: name };
|
|
195935
195979
|
}
|
|
195936
195980
|
function isObjectIteratorCall(node) {
|
|
195937
|
-
if (!
|
|
195981
|
+
if (!import_typescript13.default.isCallExpression(node))
|
|
195938
195982
|
return null;
|
|
195939
|
-
if (!
|
|
195983
|
+
if (!import_typescript13.default.isPropertyAccessExpression(node.expression))
|
|
195940
195984
|
return null;
|
|
195941
|
-
if (!
|
|
195985
|
+
if (!import_typescript13.default.isIdentifier(node.expression.expression))
|
|
195942
195986
|
return null;
|
|
195943
195987
|
if (node.expression.expression.text !== "Object")
|
|
195944
195988
|
return null;
|
|
@@ -195963,7 +196007,7 @@ function extractSortComparator(callback, _method, ctx) {
|
|
|
195963
196007
|
` + `(reverse the operands for descending order).`
|
|
195964
196008
|
});
|
|
195965
196009
|
let resolvedNode = callback;
|
|
195966
|
-
if (
|
|
196010
|
+
if (import_typescript13.default.isIdentifier(callback)) {
|
|
195967
196011
|
const resolved = resolveSortComparatorIdentifier(callback.text, ctx);
|
|
195968
196012
|
if (!resolved) {
|
|
195969
196013
|
return {
|
|
@@ -195973,7 +196017,7 @@ function extractSortComparator(callback, _method, ctx) {
|
|
|
195973
196017
|
}
|
|
195974
196018
|
resolvedNode = resolved;
|
|
195975
196019
|
}
|
|
195976
|
-
if (!
|
|
196020
|
+
if (!import_typescript13.default.isArrowFunction(resolvedNode) && !import_typescript13.default.isFunctionExpression(resolvedNode)) {
|
|
195977
196021
|
return {
|
|
195978
196022
|
result: null,
|
|
195979
196023
|
unsupportedReason: "Sort comparator must be an arrow function or function expression"
|
|
@@ -196000,11 +196044,11 @@ function resolveSortComparatorIdentifier(name, ctx) {
|
|
|
196000
196044
|
return null;
|
|
196001
196045
|
if (constInfo) {
|
|
196002
196046
|
const ast = parseConstInitializer(constInfo);
|
|
196003
|
-
return ast && (
|
|
196047
|
+
return ast && (import_typescript13.default.isArrowFunction(ast) || import_typescript13.default.isFunctionExpression(ast)) ? ast : null;
|
|
196004
196048
|
}
|
|
196005
196049
|
if (fnInfo) {
|
|
196006
196050
|
const ast = parseFunctionInfoAsExpr(fnInfo);
|
|
196007
|
-
return ast && (
|
|
196051
|
+
return ast && (import_typescript13.default.isArrowFunction(ast) || import_typescript13.default.isFunctionExpression(ast)) ? ast : null;
|
|
196008
196052
|
}
|
|
196009
196053
|
return null;
|
|
196010
196054
|
}
|
|
@@ -196015,11 +196059,11 @@ function resolveCallbackMethodFunctionReferenceIdentifier(name, analyzer) {
|
|
|
196015
196059
|
return null;
|
|
196016
196060
|
if (constInfo) {
|
|
196017
196061
|
const ast = parseConstInitializer(constInfo);
|
|
196018
|
-
return ast && (
|
|
196062
|
+
return ast && (import_typescript13.default.isArrowFunction(ast) || import_typescript13.default.isFunctionExpression(ast)) ? ast : null;
|
|
196019
196063
|
}
|
|
196020
196064
|
if (fnInfo) {
|
|
196021
196065
|
const ast = parseFunctionInfoAsExpr(fnInfo);
|
|
196022
|
-
return ast && (
|
|
196066
|
+
return ast && (import_typescript13.default.isArrowFunction(ast) || import_typescript13.default.isFunctionExpression(ast)) ? ast : null;
|
|
196023
196067
|
}
|
|
196024
196068
|
return null;
|
|
196025
196069
|
}
|
|
@@ -196075,13 +196119,13 @@ function resolveCallbackMethodFunctionReferences(expr, analyzer, bound = EMPTY_B
|
|
|
196075
196119
|
return visit2(expr, bound);
|
|
196076
196120
|
}
|
|
196077
196121
|
function extractFilterPredicate(callback, ctx) {
|
|
196078
|
-
if (!
|
|
196122
|
+
if (!import_typescript13.default.isArrowFunction(callback))
|
|
196079
196123
|
return { result: null };
|
|
196080
196124
|
if (callback.parameters.length < 1)
|
|
196081
196125
|
return { result: null };
|
|
196082
196126
|
const firstParam = callback.parameters[0];
|
|
196083
|
-
if (!
|
|
196084
|
-
if (
|
|
196127
|
+
if (!import_typescript13.default.isIdentifier(firstParam.name)) {
|
|
196128
|
+
if (import_typescript13.default.isBlock(callback.body)) {
|
|
196085
196129
|
return {
|
|
196086
196130
|
result: null,
|
|
196087
196131
|
unsupportedReason: "Block body in a destructured filter param is not supported. Workaround: use an expression-body arrow, or add /* @client */."
|
|
@@ -196101,7 +196145,7 @@ function extractFilterPredicate(callback, ctx) {
|
|
|
196101
196145
|
return { result: null };
|
|
196102
196146
|
}
|
|
196103
196147
|
const param = firstParam.name.getText(ctx.sourceFile);
|
|
196104
|
-
if (
|
|
196148
|
+
if (import_typescript13.default.isBlock(callback.body)) {
|
|
196105
196149
|
const raw2 = ctx.getJS(callback.body);
|
|
196106
196150
|
const statements = parseBlockBody(callback.body, ctx.sourceFile, (n) => ctx.getJS(n));
|
|
196107
196151
|
if (!statements) {
|
|
@@ -196127,7 +196171,7 @@ function extractFilterPredicate(callback, ctx) {
|
|
|
196127
196171
|
return { result: { param, predicate, raw } };
|
|
196128
196172
|
}
|
|
196129
196173
|
function extractLoopParamBindings(pattern) {
|
|
196130
|
-
if (
|
|
196174
|
+
if (import_typescript13.default.isIdentifier(pattern))
|
|
196131
196175
|
return null;
|
|
196132
196176
|
const bindings = [];
|
|
196133
196177
|
let unsupported = false;
|
|
@@ -196136,7 +196180,7 @@ function extractLoopParamBindings(pattern) {
|
|
|
196136
196180
|
return false;
|
|
196137
196181
|
for (let i2 = 0;i2 < key.length; ) {
|
|
196138
196182
|
const cp = key.codePointAt(i2);
|
|
196139
|
-
const ok = i2 === 0 ?
|
|
196183
|
+
const ok = i2 === 0 ? import_typescript13.default.isIdentifierStart(cp, import_typescript13.default.ScriptTarget.Latest) : import_typescript13.default.isIdentifierPart(cp, import_typescript13.default.ScriptTarget.Latest);
|
|
196140
196184
|
if (!ok)
|
|
196141
196185
|
return false;
|
|
196142
196186
|
i2 += cp > 65535 ? 2 : 1;
|
|
@@ -196149,17 +196193,17 @@ function extractLoopParamBindings(pattern) {
|
|
|
196149
196193
|
const walk = (p, prefix, segments) => {
|
|
196150
196194
|
if (unsupported)
|
|
196151
196195
|
return;
|
|
196152
|
-
if (
|
|
196196
|
+
if (import_typescript13.default.isArrayBindingPattern(p)) {
|
|
196153
196197
|
const elements2 = p.elements;
|
|
196154
196198
|
for (let index = 0;index < elements2.length; index++) {
|
|
196155
196199
|
if (unsupported)
|
|
196156
196200
|
return;
|
|
196157
196201
|
const el = elements2[index];
|
|
196158
|
-
if (
|
|
196202
|
+
if (import_typescript13.default.isOmittedExpression(el))
|
|
196159
196203
|
continue;
|
|
196160
196204
|
if (el.dotDotDotToken) {
|
|
196161
196205
|
internalInvariant(index === elements2.length - 1, "extractLoopParamBindings: array rest token in non-final position (parser should reject)");
|
|
196162
|
-
internalInvariant(
|
|
196206
|
+
internalInvariant(import_typescript13.default.isIdentifier(el.name), "extractLoopParamBindings: array rest target is not an identifier (parser should reject)");
|
|
196163
196207
|
bindings.push({
|
|
196164
196208
|
name: el.name.text,
|
|
196165
196209
|
path: prefix,
|
|
@@ -196170,7 +196214,7 @@ function extractLoopParamBindings(pattern) {
|
|
|
196170
196214
|
}
|
|
196171
196215
|
const path = `${prefix}[${index}]`;
|
|
196172
196216
|
const nextSegments = [...segments, { kind: "index", index }];
|
|
196173
|
-
if (
|
|
196217
|
+
if (import_typescript13.default.isIdentifier(el.name)) {
|
|
196174
196218
|
bindings.push({ name: el.name.text, path, segments: nextSegments });
|
|
196175
196219
|
} else {
|
|
196176
196220
|
walk(el.name, path, nextSegments);
|
|
@@ -196186,7 +196230,7 @@ function extractLoopParamBindings(pattern) {
|
|
|
196186
196230
|
const el = elements[i2];
|
|
196187
196231
|
if (el.dotDotDotToken) {
|
|
196188
196232
|
internalInvariant(i2 === elements.length - 1, "extractLoopParamBindings: object rest token in non-final position (parser should reject)");
|
|
196189
|
-
internalInvariant(
|
|
196233
|
+
internalInvariant(import_typescript13.default.isIdentifier(el.name), "extractLoopParamBindings: object rest target is not an identifier (parser should reject)");
|
|
196190
196234
|
bindings.push({
|
|
196191
196235
|
name: el.name.text,
|
|
196192
196236
|
path: prefix,
|
|
@@ -196198,17 +196242,17 @@ function extractLoopParamBindings(pattern) {
|
|
|
196198
196242
|
let keyText = null;
|
|
196199
196243
|
if (el.propertyName) {
|
|
196200
196244
|
const pn = el.propertyName;
|
|
196201
|
-
if (
|
|
196245
|
+
if (import_typescript13.default.isIdentifier(pn))
|
|
196202
196246
|
keyText = pn.text;
|
|
196203
|
-
else if (
|
|
196247
|
+
else if (import_typescript13.default.isStringLiteral(pn))
|
|
196204
196248
|
keyText = pn.text;
|
|
196205
|
-
else if (
|
|
196249
|
+
else if (import_typescript13.default.isNumericLiteral(pn))
|
|
196206
196250
|
keyText = pn.text;
|
|
196207
196251
|
else {
|
|
196208
196252
|
unsupported = true;
|
|
196209
196253
|
return;
|
|
196210
196254
|
}
|
|
196211
|
-
} else if (
|
|
196255
|
+
} else if (import_typescript13.default.isIdentifier(el.name)) {
|
|
196212
196256
|
keyText = el.name.text;
|
|
196213
196257
|
} else {
|
|
196214
196258
|
unsupported = true;
|
|
@@ -196218,14 +196262,14 @@ function extractLoopParamBindings(pattern) {
|
|
|
196218
196262
|
collectedKeys.push({ key: keyText, isIdent: keyIsIdent });
|
|
196219
196263
|
const path = appendDotAccess(prefix, keyText);
|
|
196220
196264
|
const nextSegments = [...segments, { kind: "field", key: keyText, isIdent: keyIsIdent }];
|
|
196221
|
-
if (
|
|
196265
|
+
if (import_typescript13.default.isIdentifier(el.name)) {
|
|
196222
196266
|
bindings.push({ name: el.name.text, path, segments: nextSegments });
|
|
196223
196267
|
} else {
|
|
196224
196268
|
walk(el.name, path, nextSegments);
|
|
196225
196269
|
}
|
|
196226
196270
|
}
|
|
196227
196271
|
};
|
|
196228
|
-
if (
|
|
196272
|
+
if (import_typescript13.default.isArrayBindingPattern(pattern) || import_typescript13.default.isObjectBindingPattern(pattern)) {
|
|
196229
196273
|
walk(pattern, "", []);
|
|
196230
196274
|
if (unsupported)
|
|
196231
196275
|
return { unsupported: true };
|
|
@@ -196235,7 +196279,7 @@ function extractLoopParamBindings(pattern) {
|
|
|
196235
196279
|
}
|
|
196236
196280
|
function findKeyJsxAttribute(opening) {
|
|
196237
196281
|
for (const prop of opening.attributes.properties) {
|
|
196238
|
-
if (
|
|
196282
|
+
if (import_typescript13.default.isJsxAttribute(prop) && prop.name.getText() === "key") {
|
|
196239
196283
|
return prop;
|
|
196240
196284
|
}
|
|
196241
196285
|
}
|
|
@@ -196280,7 +196324,7 @@ function keyAttrValueToExpr(v) {
|
|
|
196280
196324
|
function normalizeKeyExpr(expr) {
|
|
196281
196325
|
let out = "";
|
|
196282
196326
|
for (const tok of iterateJsTokens(expr)) {
|
|
196283
|
-
if (tok.kind ===
|
|
196327
|
+
if (tok.kind === import_typescript13.default.SyntaxKind.WhitespaceTrivia || tok.kind === import_typescript13.default.SyntaxKind.NewLineTrivia) {
|
|
196284
196328
|
continue;
|
|
196285
196329
|
}
|
|
196286
196330
|
out += expr.slice(tok.pos, tok.end);
|
|
@@ -196292,13 +196336,13 @@ function conditionalHasExplicitNullishBranch(cond) {
|
|
|
196292
196336
|
}
|
|
196293
196337
|
function branchHasExplicitNullish(branch) {
|
|
196294
196338
|
let b = branch;
|
|
196295
|
-
while (
|
|
196339
|
+
while (import_typescript13.default.isParenthesizedExpression(b))
|
|
196296
196340
|
b = b.expression;
|
|
196297
|
-
if (b.kind ===
|
|
196341
|
+
if (b.kind === import_typescript13.default.SyntaxKind.NullKeyword)
|
|
196298
196342
|
return true;
|
|
196299
|
-
if (
|
|
196343
|
+
if (import_typescript13.default.isIdentifier(b) && b.text === "undefined")
|
|
196300
196344
|
return true;
|
|
196301
|
-
if (
|
|
196345
|
+
if (import_typescript13.default.isConditionalExpression(b))
|
|
196302
196346
|
return conditionalHasExplicitNullishBranch(b);
|
|
196303
196347
|
return false;
|
|
196304
196348
|
}
|
|
@@ -196307,26 +196351,26 @@ function classifyKeyProblem(keyAttr, checker) {
|
|
|
196307
196351
|
return "missing";
|
|
196308
196352
|
if (!keyAttr.initializer)
|
|
196309
196353
|
return "missing";
|
|
196310
|
-
if (
|
|
196354
|
+
if (import_typescript13.default.isJsxExpression(keyAttr.initializer) && !keyAttr.initializer.expression) {
|
|
196311
196355
|
return "missing";
|
|
196312
196356
|
}
|
|
196313
196357
|
let expr;
|
|
196314
|
-
if (
|
|
196358
|
+
if (import_typescript13.default.isStringLiteral(keyAttr.initializer)) {
|
|
196315
196359
|
return null;
|
|
196316
|
-
} else if (
|
|
196360
|
+
} else if (import_typescript13.default.isJsxExpression(keyAttr.initializer)) {
|
|
196317
196361
|
expr = keyAttr.initializer.expression;
|
|
196318
196362
|
}
|
|
196319
196363
|
if (!expr)
|
|
196320
196364
|
return null;
|
|
196321
|
-
if (expr.kind ===
|
|
196365
|
+
if (expr.kind === import_typescript13.default.SyntaxKind.NullKeyword)
|
|
196322
196366
|
return null;
|
|
196323
|
-
if (
|
|
196367
|
+
if (import_typescript13.default.isIdentifier(expr) && expr.text === "undefined")
|
|
196324
196368
|
return null;
|
|
196325
|
-
if (
|
|
196369
|
+
if (import_typescript13.default.isConditionalExpression(expr) && conditionalHasExplicitNullishBranch(expr))
|
|
196326
196370
|
return null;
|
|
196327
196371
|
if (checker) {
|
|
196328
196372
|
const type2 = checker.getTypeAtLocation(expr);
|
|
196329
|
-
const isNullable = type2.isUnion() ? type2.types.some((t) => (t.flags & (
|
|
196373
|
+
const isNullable = type2.isUnion() ? type2.types.some((t) => (t.flags & (import_typescript13.default.TypeFlags.Null | import_typescript13.default.TypeFlags.Undefined | import_typescript13.default.TypeFlags.Void)) !== 0) : (type2.flags & (import_typescript13.default.TypeFlags.Null | import_typescript13.default.TypeFlags.Undefined | import_typescript13.default.TypeFlags.Void)) !== 0;
|
|
196330
196374
|
if (isNullable)
|
|
196331
196375
|
return "nullable-type";
|
|
196332
196376
|
}
|
|
@@ -196352,81 +196396,81 @@ function checkLoopKey(callback, ctx, isNested) {
|
|
|
196352
196396
|
ctx.analyzer.errors.push(createError(errorCode, getSourceLocation(locNode, ctx.sourceFile, ctx.filePath), { suggestion: { message: keyErrorSuggestion(problem) } }));
|
|
196353
196397
|
}
|
|
196354
196398
|
let body = callback.body;
|
|
196355
|
-
if (
|
|
196356
|
-
const ret = body.statements.find((s) =>
|
|
196399
|
+
if (import_typescript13.default.isBlock(body)) {
|
|
196400
|
+
const ret = body.statements.find((s) => import_typescript13.default.isReturnStatement(s) && s.expression != null);
|
|
196357
196401
|
if (!ret?.expression)
|
|
196358
196402
|
return;
|
|
196359
196403
|
body = ret.expression;
|
|
196360
196404
|
}
|
|
196361
|
-
while (
|
|
196405
|
+
while (import_typescript13.default.isParenthesizedExpression(body))
|
|
196362
196406
|
body = body.expression;
|
|
196363
196407
|
function checkJsxOperand(node) {
|
|
196364
196408
|
let n = node;
|
|
196365
|
-
while (
|
|
196409
|
+
while (import_typescript13.default.isParenthesizedExpression(n))
|
|
196366
196410
|
n = n.expression;
|
|
196367
|
-
if (
|
|
196411
|
+
if (import_typescript13.default.isJsxElement(n))
|
|
196368
196412
|
checkOpening(n.openingElement);
|
|
196369
|
-
else if (
|
|
196413
|
+
else if (import_typescript13.default.isJsxSelfClosingElement(n))
|
|
196370
196414
|
checkOpening(n);
|
|
196371
196415
|
}
|
|
196372
|
-
if (
|
|
196416
|
+
if (import_typescript13.default.isConditionalExpression(body)) {
|
|
196373
196417
|
checkJsxOperand(body.whenTrue);
|
|
196374
196418
|
checkJsxOperand(body.whenFalse);
|
|
196375
196419
|
return;
|
|
196376
196420
|
}
|
|
196377
|
-
if (
|
|
196421
|
+
if (import_typescript13.default.isBinaryExpression(body) && (body.operatorToken.kind === import_typescript13.default.SyntaxKind.AmpersandAmpersandToken || body.operatorToken.kind === import_typescript13.default.SyntaxKind.BarBarToken || body.operatorToken.kind === import_typescript13.default.SyntaxKind.QuestionQuestionToken)) {
|
|
196378
196422
|
checkJsxOperand(body.left);
|
|
196379
196423
|
checkJsxOperand(body.right);
|
|
196380
196424
|
return;
|
|
196381
196425
|
}
|
|
196382
|
-
if (
|
|
196426
|
+
if (import_typescript13.default.isJsxElement(body)) {
|
|
196383
196427
|
checkOpening(body.openingElement);
|
|
196384
196428
|
return;
|
|
196385
196429
|
}
|
|
196386
|
-
if (
|
|
196430
|
+
if (import_typescript13.default.isJsxSelfClosingElement(body)) {
|
|
196387
196431
|
checkOpening(body);
|
|
196388
196432
|
return;
|
|
196389
196433
|
}
|
|
196390
196434
|
}
|
|
196391
196435
|
function flatMapProjectionCall(body) {
|
|
196392
196436
|
let expr;
|
|
196393
|
-
if (
|
|
196437
|
+
if (import_typescript13.default.isBlock(body)) {
|
|
196394
196438
|
const real = body.statements;
|
|
196395
|
-
if (real.length !== 1 || !
|
|
196439
|
+
if (real.length !== 1 || !import_typescript13.default.isReturnStatement(real[0]) || !real[0].expression)
|
|
196396
196440
|
return null;
|
|
196397
196441
|
expr = real[0].expression;
|
|
196398
196442
|
} else {
|
|
196399
196443
|
expr = body;
|
|
196400
196444
|
}
|
|
196401
|
-
while (
|
|
196445
|
+
while (import_typescript13.default.isParenthesizedExpression(expr))
|
|
196402
196446
|
expr = expr.expression;
|
|
196403
|
-
if (!
|
|
196447
|
+
if (!import_typescript13.default.isCallExpression(expr))
|
|
196404
196448
|
return null;
|
|
196405
196449
|
if (!getMapLikeMethod(expr))
|
|
196406
196450
|
return null;
|
|
196407
196451
|
const cb = expr.arguments[0];
|
|
196408
|
-
if (!cb || !
|
|
196452
|
+
if (!cb || !import_typescript13.default.isArrowFunction(cb) && !import_typescript13.default.isFunctionExpression(cb))
|
|
196409
196453
|
return null;
|
|
196410
196454
|
for (const p of cb.parameters) {
|
|
196411
|
-
if (!
|
|
196455
|
+
if (!import_typescript13.default.isIdentifier(p.name))
|
|
196412
196456
|
return null;
|
|
196413
196457
|
}
|
|
196414
196458
|
let innerBody = cb.body;
|
|
196415
|
-
if (
|
|
196416
|
-
const ret = innerBody.statements.find((s) =>
|
|
196459
|
+
if (import_typescript13.default.isBlock(innerBody)) {
|
|
196460
|
+
const ret = innerBody.statements.find((s) => import_typescript13.default.isReturnStatement(s) && s.expression != null);
|
|
196417
196461
|
if (innerBody.statements.length !== 1 || !ret?.expression)
|
|
196418
196462
|
return null;
|
|
196419
196463
|
innerBody = ret.expression;
|
|
196420
196464
|
}
|
|
196421
|
-
while (
|
|
196465
|
+
while (import_typescript13.default.isParenthesizedExpression(innerBody))
|
|
196422
196466
|
innerBody = innerBody.expression;
|
|
196423
196467
|
const isElementish = (n) => {
|
|
196424
196468
|
let m = n;
|
|
196425
|
-
while (
|
|
196469
|
+
while (import_typescript13.default.isParenthesizedExpression(m))
|
|
196426
196470
|
m = m.expression;
|
|
196427
|
-
if (
|
|
196471
|
+
if (import_typescript13.default.isJsxElement(m) || import_typescript13.default.isJsxSelfClosingElement(m))
|
|
196428
196472
|
return leafIsWirelessElement(m);
|
|
196429
|
-
if (
|
|
196473
|
+
if (import_typescript13.default.isConditionalExpression(m))
|
|
196430
196474
|
return isElementish(m.whenTrue) && isElementish(m.whenFalse);
|
|
196431
196475
|
return false;
|
|
196432
196476
|
};
|
|
@@ -196439,19 +196483,19 @@ function leafIsWirelessElement(el) {
|
|
|
196439
196483
|
const visit2 = (n) => {
|
|
196440
196484
|
if (!ok)
|
|
196441
196485
|
return;
|
|
196442
|
-
if (
|
|
196486
|
+
if (import_typescript13.default.isJsxOpeningElement(n) || import_typescript13.default.isJsxSelfClosingElement(n)) {
|
|
196443
196487
|
const tagNode = n.tagName;
|
|
196444
|
-
const isIntrinsic =
|
|
196488
|
+
const isIntrinsic = import_typescript13.default.isIdentifier(tagNode) ? !/^[A-Z]/.test(tagNode.text) : import_typescript13.default.isJsxNamespacedName(tagNode);
|
|
196445
196489
|
if (!isIntrinsic) {
|
|
196446
196490
|
ok = false;
|
|
196447
196491
|
return;
|
|
196448
196492
|
}
|
|
196449
196493
|
for (const attr of n.attributes.properties) {
|
|
196450
|
-
if (
|
|
196494
|
+
if (import_typescript13.default.isJsxSpreadAttribute(attr)) {
|
|
196451
196495
|
ok = false;
|
|
196452
196496
|
return;
|
|
196453
196497
|
}
|
|
196454
|
-
if (
|
|
196498
|
+
if (import_typescript13.default.isJsxAttribute(attr)) {
|
|
196455
196499
|
const name = attr.name.getText();
|
|
196456
196500
|
if (/^on[A-Z]/.test(name)) {
|
|
196457
196501
|
ok = false;
|
|
@@ -196460,11 +196504,11 @@ function leafIsWirelessElement(el) {
|
|
|
196460
196504
|
}
|
|
196461
196505
|
}
|
|
196462
196506
|
}
|
|
196463
|
-
if (
|
|
196507
|
+
if (import_typescript13.default.isCallExpression(n) && getMapLikeMethod(n) && containsJsxInExpression(n)) {
|
|
196464
196508
|
ok = false;
|
|
196465
196509
|
return;
|
|
196466
196510
|
}
|
|
196467
|
-
|
|
196511
|
+
import_typescript13.default.forEachChild(n, visit2);
|
|
196468
196512
|
};
|
|
196469
196513
|
visit2(el);
|
|
196470
196514
|
return ok;
|
|
@@ -196644,7 +196688,7 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
|
|
|
196644
196688
|
let children = [];
|
|
196645
196689
|
let paramBindings;
|
|
196646
196690
|
let flatMapCallback;
|
|
196647
|
-
if (
|
|
196691
|
+
if (import_typescript13.default.isArrowFunction(callback)) {
|
|
196648
196692
|
if (callback.parameters.length > 0) {
|
|
196649
196693
|
const firstParam = callback.parameters[0];
|
|
196650
196694
|
param = firstParam.name.getText(ctx.sourceFile);
|
|
@@ -196652,9 +196696,9 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
|
|
|
196652
196696
|
paramType = firstParam.type.getText(ctx.sourceFile);
|
|
196653
196697
|
}
|
|
196654
196698
|
const isEntriesShape = iterationShape === "entries" || objectIteration === "entries";
|
|
196655
|
-
if (isEntriesShape &&
|
|
196656
|
-
const elements = firstParam.name.elements.filter((el) => !
|
|
196657
|
-
if (elements.length === 2 &&
|
|
196699
|
+
if (isEntriesShape && import_typescript13.default.isArrayBindingPattern(firstParam.name)) {
|
|
196700
|
+
const elements = firstParam.name.elements.filter((el) => !import_typescript13.default.isOmittedExpression(el));
|
|
196701
|
+
if (elements.length === 2 && import_typescript13.default.isBindingElement(elements[0]) && import_typescript13.default.isIdentifier(elements[0].name) && import_typescript13.default.isBindingElement(elements[1]) && import_typescript13.default.isIdentifier(elements[1].name)) {
|
|
196658
196702
|
index = elements[0].name.text;
|
|
196659
196703
|
param = elements[1].name.text;
|
|
196660
196704
|
} else {
|
|
@@ -196685,10 +196729,10 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
|
|
|
196685
196729
|
ctx.scope = ctx.scope.enterLoopRow({ param, index, paramBindings });
|
|
196686
196730
|
ctx.loopDepth++;
|
|
196687
196731
|
const tryTransformRenderableBody = (expr) => {
|
|
196688
|
-
if (!
|
|
196732
|
+
if (!import_typescript13.default.isBinaryExpression(expr))
|
|
196689
196733
|
return;
|
|
196690
196734
|
const op = expr.operatorToken.kind;
|
|
196691
|
-
if (op !==
|
|
196735
|
+
if (op !== import_typescript13.default.SyntaxKind.AmpersandAmpersandToken && op !== import_typescript13.default.SyntaxKind.BarBarToken && op !== import_typescript13.default.SyntaxKind.QuestionQuestionToken) {
|
|
196692
196736
|
return;
|
|
196693
196737
|
}
|
|
196694
196738
|
if (!containsJsxInExpression(expr) && !callsJsxHelper(expr, ctx))
|
|
@@ -196698,33 +196742,33 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
|
|
|
196698
196742
|
children = [transformed];
|
|
196699
196743
|
};
|
|
196700
196744
|
const body = callback.body;
|
|
196701
|
-
if (
|
|
196745
|
+
if (import_typescript13.default.isJsxElement(body) || import_typescript13.default.isJsxSelfClosingElement(body) || import_typescript13.default.isJsxFragment(body)) {
|
|
196702
196746
|
const transformed = transformNode(body, ctx);
|
|
196703
196747
|
if (transformed) {
|
|
196704
196748
|
children = [transformed];
|
|
196705
196749
|
}
|
|
196706
|
-
} else if (
|
|
196750
|
+
} else if (import_typescript13.default.isConditionalExpression(body)) {
|
|
196707
196751
|
children = [transformConditional(body, ctx)];
|
|
196708
|
-
} else if (
|
|
196752
|
+
} else if (import_typescript13.default.isParenthesizedExpression(body)) {
|
|
196709
196753
|
let inner = body.expression;
|
|
196710
|
-
while (
|
|
196754
|
+
while (import_typescript13.default.isParenthesizedExpression(inner)) {
|
|
196711
196755
|
inner = inner.expression;
|
|
196712
196756
|
}
|
|
196713
|
-
if (
|
|
196757
|
+
if (import_typescript13.default.isJsxElement(inner) || import_typescript13.default.isJsxSelfClosingElement(inner) || import_typescript13.default.isJsxFragment(inner)) {
|
|
196714
196758
|
const transformed = transformNode(inner, ctx);
|
|
196715
196759
|
if (transformed) {
|
|
196716
196760
|
children = [transformed];
|
|
196717
196761
|
}
|
|
196718
|
-
} else if (
|
|
196762
|
+
} else if (import_typescript13.default.isConditionalExpression(inner)) {
|
|
196719
196763
|
children = [transformConditional(inner, ctx)];
|
|
196720
|
-
} else if (method === "flatMap" &&
|
|
196764
|
+
} else if (method === "flatMap" && import_typescript13.default.isArrayLiteralExpression(inner)) {
|
|
196721
196765
|
children = transformArrayLiteralChildren(inner, ctx);
|
|
196722
196766
|
} else {
|
|
196723
196767
|
tryTransformRenderableBody(inner);
|
|
196724
196768
|
}
|
|
196725
|
-
} else if (method === "flatMap" &&
|
|
196769
|
+
} else if (method === "flatMap" && import_typescript13.default.isArrayLiteralExpression(body)) {
|
|
196726
196770
|
children = transformArrayLiteralChildren(body, ctx);
|
|
196727
|
-
} else if (
|
|
196771
|
+
} else if (import_typescript13.default.isBlock(body)) {
|
|
196728
196772
|
const multiReturn = method !== "flatMap" ? extractMultiReturnJsxBranches(body, true) : null;
|
|
196729
196773
|
if (multiReturn && multiReturn.branches.length > 0) {
|
|
196730
196774
|
const loc = getSourceLocation(body, ctx.sourceFile, ctx.filePath);
|
|
@@ -196742,7 +196786,7 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
|
|
|
196742
196786
|
}
|
|
196743
196787
|
}
|
|
196744
196788
|
}
|
|
196745
|
-
const returnStmt = children.length === 0 ? body.statements.find((s) =>
|
|
196789
|
+
const returnStmt = children.length === 0 ? body.statements.find((s) => import_typescript13.default.isReturnStatement(s) && s.expression != null) : undefined;
|
|
196746
196790
|
let rowScopeBeforePreamble = null;
|
|
196747
196791
|
if (returnStmt) {
|
|
196748
196792
|
const preambleNames = new Set;
|
|
@@ -196763,10 +196807,10 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
|
|
|
196763
196807
|
}
|
|
196764
196808
|
if (returnStmt && returnStmt.expression) {
|
|
196765
196809
|
let returnExpr = returnStmt.expression;
|
|
196766
|
-
while (
|
|
196810
|
+
while (import_typescript13.default.isParenthesizedExpression(returnExpr)) {
|
|
196767
196811
|
returnExpr = returnExpr.expression;
|
|
196768
196812
|
}
|
|
196769
|
-
if (
|
|
196813
|
+
if (import_typescript13.default.isJsxElement(returnExpr) || import_typescript13.default.isJsxSelfClosingElement(returnExpr) || import_typescript13.default.isJsxFragment(returnExpr)) {
|
|
196770
196814
|
const transformed = transformNode(returnExpr, ctx);
|
|
196771
196815
|
if (transformed) {
|
|
196772
196816
|
children = [transformed];
|
|
@@ -196848,7 +196892,7 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
|
|
|
196848
196892
|
}
|
|
196849
196893
|
}
|
|
196850
196894
|
}
|
|
196851
|
-
if (method === "flatMap" && children.length === 0 && !flatMapCallback && !
|
|
196895
|
+
if (method === "flatMap" && children.length === 0 && !flatMapCallback && !import_typescript13.default.isBlock(body)) {
|
|
196852
196896
|
flatMapCallback = buildFlatMapCallback(callback, body, ctx);
|
|
196853
196897
|
}
|
|
196854
196898
|
if (flatMapCallback)
|
|
@@ -196866,7 +196910,7 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
|
|
|
196866
196910
|
}
|
|
196867
196911
|
if (children.length === 0 && !flatMapCallback) {
|
|
196868
196912
|
const cb = node.arguments[0];
|
|
196869
|
-
const cbBody = cb && (
|
|
196913
|
+
const cbBody = cb && (import_typescript13.default.isArrowFunction(cb) || import_typescript13.default.isFunctionExpression(cb)) ? cb.body : undefined;
|
|
196870
196914
|
if (cbBody && containsJsxInExpression(cbBody) && ctx.analyzer.errors.length === diagCountAtEntry) {
|
|
196871
196915
|
ctx.analyzer.errors.push(createError(ErrorCodes.UNSUPPORTED_JSX_PATTERN, getSourceLocation(cbBody, ctx.sourceFile, ctx.filePath), {
|
|
196872
196916
|
message: `A .${method}() callback that builds JSX in this shape cannot be ` + "compiled — the JSX would leak verbatim into the client bundle. " + "Recognized bodies: a JSX element/fragment, a ternary or " + "&& / || / ?? expression, an array literal (flatMap), or a block " + "body whose return the compiler can lower.",
|
|
@@ -196877,7 +196921,7 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
|
|
|
196877
196921
|
}
|
|
196878
196922
|
return null;
|
|
196879
196923
|
}
|
|
196880
|
-
if (
|
|
196924
|
+
if (import_typescript13.default.isArrowFunction(node.arguments[0]) && children.length > 0) {
|
|
196881
196925
|
checkLoopKey(node.arguments[0], ctx, isNested);
|
|
196882
196926
|
}
|
|
196883
196927
|
const itemConditional = children.length > 0 ? loopBodyItemConditional(children) : null;
|
|
@@ -196931,6 +196975,9 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
|
|
|
196931
196975
|
const preambleRegions = preamble && !isStaticArray ? collectPreambleRegions(children, new Set(preamble.declaredNames), ctx) : undefined;
|
|
196932
196976
|
if (preamble && !isStaticArray) {
|
|
196933
196977
|
markPreambleAttrSlots(children, new Set(preamble.declaredNames), ctx);
|
|
196978
|
+
if (preamble.reactiveNames && preamble.reactiveNames.length > 0) {
|
|
196979
|
+
markPreambleConditionalReactivity(children, new Set(preamble.reactiveNames), ctx);
|
|
196980
|
+
}
|
|
196934
196981
|
}
|
|
196935
196982
|
const nestedComponents = collectNestedComponents(children).filter((c) => c.name !== childComponent?.name);
|
|
196936
196983
|
return {
|
|
@@ -196974,12 +197021,12 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
|
|
|
196974
197021
|
function transformArrayLiteralChildren(arrayLiteral, ctx) {
|
|
196975
197022
|
const children = [];
|
|
196976
197023
|
for (const element of arrayLiteral.elements) {
|
|
196977
|
-
if (
|
|
197024
|
+
if (import_typescript13.default.isSpreadElement(element))
|
|
196978
197025
|
continue;
|
|
196979
197026
|
let inner = element;
|
|
196980
|
-
while (
|
|
197027
|
+
while (import_typescript13.default.isParenthesizedExpression(inner))
|
|
196981
197028
|
inner = inner.expression;
|
|
196982
|
-
if (
|
|
197029
|
+
if (import_typescript13.default.isJsxElement(inner) || import_typescript13.default.isJsxSelfClosingElement(inner) || import_typescript13.default.isJsxFragment(inner)) {
|
|
196983
197030
|
const transformed = transformNode(inner, ctx);
|
|
196984
197031
|
if (transformed)
|
|
196985
197032
|
children.push(transformed);
|
|
@@ -196988,7 +197035,7 @@ function transformArrayLiteralChildren(arrayLiteral, ctx) {
|
|
|
196988
197035
|
return children;
|
|
196989
197036
|
}
|
|
196990
197037
|
function containsJsx(node) {
|
|
196991
|
-
if (
|
|
197038
|
+
if (import_typescript13.default.isJsxElement(node) || import_typescript13.default.isJsxSelfClosingElement(node) || import_typescript13.default.isJsxFragment(node))
|
|
196992
197039
|
return true;
|
|
196993
197040
|
let found = false;
|
|
196994
197041
|
node.forEachChild((child) => {
|
|
@@ -197004,7 +197051,7 @@ function buildFlatMapCallback(callback, body, ctx) {
|
|
|
197004
197051
|
const leafIrs = [];
|
|
197005
197052
|
let refusalNode;
|
|
197006
197053
|
const collectJsx = (n, underTemplate) => {
|
|
197007
|
-
if (
|
|
197054
|
+
if (import_typescript13.default.isJsxElement(n) || import_typescript13.default.isJsxSelfClosingElement(n) || import_typescript13.default.isJsxFragment(n)) {
|
|
197008
197055
|
if (underTemplate)
|
|
197009
197056
|
refusalNode ??= n;
|
|
197010
197057
|
leafSpans.push({ start: n.getStart(ctx.sourceFile), end: n.getEnd() });
|
|
@@ -197012,7 +197059,7 @@ function buildFlatMapCallback(callback, body, ctx) {
|
|
|
197012
197059
|
leafIrs.push(ir ?? { type: "text", value: "", loc: getSourceLocation(n, ctx.sourceFile, ctx.filePath) });
|
|
197013
197060
|
return;
|
|
197014
197061
|
}
|
|
197015
|
-
const inTemplate = underTemplate ||
|
|
197062
|
+
const inTemplate = underTemplate || import_typescript13.default.isTemplateExpression(n) || import_typescript13.default.isTaggedTemplateExpression(n);
|
|
197016
197063
|
n.forEachChild((c) => collectJsx(c, inTemplate));
|
|
197017
197064
|
};
|
|
197018
197065
|
collectJsx(body, false);
|
|
@@ -197188,6 +197235,33 @@ function markPreambleAttrSlots(nodes, declared, ctx) {
|
|
|
197188
197235
|
};
|
|
197189
197236
|
visit2(nodes);
|
|
197190
197237
|
}
|
|
197238
|
+
function markPreambleConditionalReactivity(nodes, reactiveNames, ctx) {
|
|
197239
|
+
if (reactiveNames.size === 0)
|
|
197240
|
+
return;
|
|
197241
|
+
const visit2 = (list) => {
|
|
197242
|
+
for (const node of list) {
|
|
197243
|
+
switch (node.type) {
|
|
197244
|
+
case "element":
|
|
197245
|
+
case "fragment":
|
|
197246
|
+
visit2(node.children);
|
|
197247
|
+
break;
|
|
197248
|
+
case "conditional": {
|
|
197249
|
+
if (!node.reactive) {
|
|
197250
|
+
const refs = extractFreeIdentifiersFromText(node.condition);
|
|
197251
|
+
if ([...refs].some((r) => reactiveNames.has(r))) {
|
|
197252
|
+
node.reactive = true;
|
|
197253
|
+
if (!node.slotId)
|
|
197254
|
+
node.slotId = generateSlotId(ctx);
|
|
197255
|
+
}
|
|
197256
|
+
}
|
|
197257
|
+
visit2([node.whenTrue, ...node.whenFalse ? [node.whenFalse] : []]);
|
|
197258
|
+
break;
|
|
197259
|
+
}
|
|
197260
|
+
}
|
|
197261
|
+
}
|
|
197262
|
+
};
|
|
197263
|
+
visit2(nodes);
|
|
197264
|
+
}
|
|
197191
197265
|
function attrValueText(value) {
|
|
197192
197266
|
if (value.kind === "expression")
|
|
197193
197267
|
return value.expr;
|
|
@@ -197203,24 +197277,46 @@ function attrValueText(value) {
|
|
|
197203
197277
|
return out.join(" ");
|
|
197204
197278
|
}
|
|
197205
197279
|
function collectBindingNames2(name, out) {
|
|
197206
|
-
if (
|
|
197280
|
+
if (import_typescript13.default.isIdentifier(name)) {
|
|
197207
197281
|
out.add(name.text);
|
|
197208
197282
|
return;
|
|
197209
197283
|
}
|
|
197210
197284
|
for (const el of name.elements) {
|
|
197211
|
-
if (
|
|
197285
|
+
if (import_typescript13.default.isBindingElement(el))
|
|
197212
197286
|
collectBindingNames2(el.name, out);
|
|
197213
197287
|
}
|
|
197214
197288
|
}
|
|
197215
197289
|
function collectPreambleDeclaredNames(stmt, out) {
|
|
197216
|
-
if (
|
|
197290
|
+
if (import_typescript13.default.isVariableStatement(stmt)) {
|
|
197217
197291
|
for (const decl of stmt.declarationList.declarations) {
|
|
197218
197292
|
collectBindingNames2(decl.name, out);
|
|
197219
197293
|
}
|
|
197220
|
-
} else if (
|
|
197294
|
+
} else if (import_typescript13.default.isFunctionDeclaration(stmt) && stmt.name) {
|
|
197221
197295
|
out.add(stmt.name.text);
|
|
197222
197296
|
}
|
|
197223
197297
|
}
|
|
197298
|
+
function computePreambleReactiveNames(statements, ctx) {
|
|
197299
|
+
const reactiveNames = new Set;
|
|
197300
|
+
for (const stmt of statements) {
|
|
197301
|
+
if (!import_typescript13.default.isVariableStatement(stmt))
|
|
197302
|
+
continue;
|
|
197303
|
+
for (const decl of stmt.declarationList.declarations) {
|
|
197304
|
+
if (!decl.initializer)
|
|
197305
|
+
continue;
|
|
197306
|
+
const boundNames = new Set;
|
|
197307
|
+
collectBindingNames2(decl.name, boundNames);
|
|
197308
|
+
const initText = ctx.getJS(decl.initializer);
|
|
197309
|
+
const initFreeRefs = extractFreeIdentifiersFromNode(decl.initializer);
|
|
197310
|
+
const readsEarlierReactive = [...initFreeRefs].some((r) => reactiveNames.has(r));
|
|
197311
|
+
const isReactive = readsEarlierReactive || isReactiveExpression(initText, ctx, decl.initializer);
|
|
197312
|
+
if (isReactive) {
|
|
197313
|
+
for (const n of boundNames)
|
|
197314
|
+
reactiveNames.add(n);
|
|
197315
|
+
}
|
|
197316
|
+
}
|
|
197317
|
+
}
|
|
197318
|
+
return reactiveNames;
|
|
197319
|
+
}
|
|
197224
197320
|
function preambleFromValueStatements(statements, ctx) {
|
|
197225
197321
|
const segments = [];
|
|
197226
197322
|
const typedParts = [];
|
|
@@ -197235,21 +197331,23 @@ function preambleFromValueStatements(statements, ctx) {
|
|
|
197235
197331
|
typedParts.push(raw0.endsWith(";") ? raw0 : raw0 + ";");
|
|
197236
197332
|
segments.push(tjs !== js ? { kind: "js", text: js, templateText: tjs } : { kind: "js", text: js });
|
|
197237
197333
|
}
|
|
197334
|
+
const reactiveNames = computePreambleReactiveNames(statements, ctx);
|
|
197238
197335
|
return {
|
|
197239
197336
|
segments: trimPreambleSegments(segments),
|
|
197240
197337
|
ssrText: tsxSourceText(typedParts.join(" ")),
|
|
197241
197338
|
declaredNames: [...declared],
|
|
197242
197339
|
builderNames: [],
|
|
197243
|
-
declarations: neutralPreambleDeclarations(statements, ctx) ?? undefined
|
|
197340
|
+
declarations: neutralPreambleDeclarations(statements, ctx) ?? undefined,
|
|
197341
|
+
reactiveNames: reactiveNames.size > 0 ? [...reactiveNames] : undefined
|
|
197244
197342
|
};
|
|
197245
197343
|
}
|
|
197246
197344
|
function neutralPreambleDeclarations(statements, ctx) {
|
|
197247
197345
|
const out = [];
|
|
197248
197346
|
for (const stmt of statements) {
|
|
197249
|
-
if (!
|
|
197347
|
+
if (!import_typescript13.default.isVariableStatement(stmt))
|
|
197250
197348
|
return null;
|
|
197251
197349
|
for (const decl of stmt.declarationList.declarations) {
|
|
197252
|
-
if (!
|
|
197350
|
+
if (!import_typescript13.default.isIdentifier(decl.name))
|
|
197253
197351
|
return null;
|
|
197254
197352
|
if (!decl.initializer)
|
|
197255
197353
|
return null;
|
|
@@ -197282,11 +197380,11 @@ function buildPreambleSegments(statements, returnStmt, ctx) {
|
|
|
197282
197380
|
let refusalNode;
|
|
197283
197381
|
const recordBuilderTarget = (leaf, stmt) => {
|
|
197284
197382
|
for (let n = leaf.parent;n && n !== stmt.parent; n = n.parent) {
|
|
197285
|
-
if (
|
|
197383
|
+
if (import_typescript13.default.isCallExpression(n) && import_typescript13.default.isPropertyAccessExpression(n.expression) && (n.expression.name.text === "push" || n.expression.name.text === "unshift") && import_typescript13.default.isIdentifier(n.expression.expression)) {
|
|
197286
197384
|
builders.add(n.expression.expression.text);
|
|
197287
197385
|
return;
|
|
197288
197386
|
}
|
|
197289
|
-
if (
|
|
197387
|
+
if (import_typescript13.default.isVariableDeclaration(n) && import_typescript13.default.isIdentifier(n.name)) {
|
|
197290
197388
|
builders.add(n.name.text);
|
|
197291
197389
|
return;
|
|
197292
197390
|
}
|
|
@@ -197299,7 +197397,7 @@ function buildPreambleSegments(statements, returnStmt, ctx) {
|
|
|
197299
197397
|
const leafSpans = [];
|
|
197300
197398
|
const leafIrs = [];
|
|
197301
197399
|
const collect = (n, underTemplate) => {
|
|
197302
|
-
if (
|
|
197400
|
+
if (import_typescript13.default.isJsxElement(n) || import_typescript13.default.isJsxSelfClosingElement(n) || import_typescript13.default.isJsxFragment(n)) {
|
|
197303
197401
|
if (underTemplate)
|
|
197304
197402
|
refusalNode ??= n;
|
|
197305
197403
|
recordBuilderTarget(n, stmt);
|
|
@@ -197310,7 +197408,7 @@ function buildPreambleSegments(statements, returnStmt, ctx) {
|
|
|
197310
197408
|
leafIrs.push(ir ?? { type: "text", value: "", loc: getSourceLocation(n, ctx.sourceFile, ctx.filePath) });
|
|
197311
197409
|
return;
|
|
197312
197410
|
}
|
|
197313
|
-
const inTemplate = underTemplate ||
|
|
197411
|
+
const inTemplate = underTemplate || import_typescript13.default.isTemplateExpression(n) || import_typescript13.default.isTaggedTemplateExpression(n);
|
|
197314
197412
|
n.forEachChild((c) => collect(c, inTemplate));
|
|
197315
197413
|
};
|
|
197316
197414
|
collect(stmt, false);
|
|
@@ -197414,13 +197512,13 @@ function expandSpreadAttribute(attr, ctx) {
|
|
|
197414
197512
|
}];
|
|
197415
197513
|
}
|
|
197416
197514
|
function attrFreeIdentifiers(attr) {
|
|
197417
|
-
if (!attr.initializer || !
|
|
197515
|
+
if (!attr.initializer || !import_typescript13.default.isJsxExpression(attr.initializer) || !attr.initializer.expression) {
|
|
197418
197516
|
return;
|
|
197419
197517
|
}
|
|
197420
197518
|
return extractFreeIdentifiersFromNode(attr.initializer.expression);
|
|
197421
197519
|
}
|
|
197422
197520
|
function computeReactivityFlags(attr, ctx) {
|
|
197423
|
-
if (!attr.initializer || !
|
|
197521
|
+
if (!attr.initializer || !import_typescript13.default.isJsxExpression(attr.initializer) || !attr.initializer.expression) {
|
|
197424
197522
|
return {};
|
|
197425
197523
|
}
|
|
197426
197524
|
const expr = attr.initializer.expression;
|
|
@@ -197446,22 +197544,22 @@ function processAttributes(attributes, ctx) {
|
|
|
197446
197544
|
const events = [];
|
|
197447
197545
|
let ref = null;
|
|
197448
197546
|
for (const attr of attributes.properties) {
|
|
197449
|
-
if (
|
|
197547
|
+
if (import_typescript13.default.isJsxSpreadAttribute(attr)) {
|
|
197450
197548
|
attrs.push(...expandSpreadAttribute(attr, ctx));
|
|
197451
197549
|
continue;
|
|
197452
197550
|
}
|
|
197453
|
-
if (!
|
|
197551
|
+
if (!import_typescript13.default.isJsxAttribute(attr))
|
|
197454
197552
|
continue;
|
|
197455
197553
|
const rawName = attr.name.getText(ctx.sourceFile);
|
|
197456
197554
|
if (rawName === "ref") {
|
|
197457
|
-
if (attr.initializer &&
|
|
197555
|
+
if (attr.initializer && import_typescript13.default.isJsxExpression(attr.initializer) && attr.initializer.expression) {
|
|
197458
197556
|
reportJsxBranchLocalInCallback(attr.initializer.expression, ctx);
|
|
197459
197557
|
ref = ctx.getJS(attr.initializer.expression);
|
|
197460
197558
|
}
|
|
197461
197559
|
continue;
|
|
197462
197560
|
}
|
|
197463
197561
|
if (/^on[A-Z]/.test(rawName)) {
|
|
197464
|
-
if (attr.initializer &&
|
|
197562
|
+
if (attr.initializer && import_typescript13.default.isJsxExpression(attr.initializer) && attr.initializer.expression) {
|
|
197465
197563
|
const eventName = rawName.slice(2).toLowerCase();
|
|
197466
197564
|
reportJsxBranchLocalInCallback(attr.initializer.expression, ctx);
|
|
197467
197565
|
events.push({
|
|
@@ -197476,7 +197574,7 @@ function processAttributes(attributes, ctx) {
|
|
|
197476
197574
|
const name = toHTMLAttrName(rawName);
|
|
197477
197575
|
let value = getAttributeValue(attr, ctx);
|
|
197478
197576
|
let clientOnly;
|
|
197479
|
-
if (attr.initializer &&
|
|
197577
|
+
if (attr.initializer && import_typescript13.default.isJsxExpression(attr.initializer) && attr.initializer.expression) {
|
|
197480
197578
|
if (value.kind === "expression" && value.templateExpr === undefined) {
|
|
197481
197579
|
const rewritten = rewriteBarePropRefs2(value.expr, attr.initializer.expression, ctx);
|
|
197482
197580
|
if (rewritten !== value.expr) {
|
|
@@ -197503,55 +197601,55 @@ function getAttributeValue(attr, ctx) {
|
|
|
197503
197601
|
if (!attr.initializer) {
|
|
197504
197602
|
return AttrValueOf.booleanAttr();
|
|
197505
197603
|
}
|
|
197506
|
-
if (
|
|
197604
|
+
if (import_typescript13.default.isStringLiteral(attr.initializer)) {
|
|
197507
197605
|
return AttrValueOf.literal(decodeEntities(attr.initializer.text));
|
|
197508
197606
|
}
|
|
197509
|
-
if (
|
|
197607
|
+
if (import_typescript13.default.isJsxExpression(attr.initializer) && attr.initializer.expression) {
|
|
197510
197608
|
let expr = attr.initializer.expression;
|
|
197511
|
-
if (
|
|
197609
|
+
if (import_typescript13.default.isIdentifier(expr)) {
|
|
197512
197610
|
const branchInit = ctx._branchScopeVars?.get(expr.text);
|
|
197513
197611
|
if (branchInit && !initializerShapeContainsJsx(branchInit)) {
|
|
197514
197612
|
expr = branchInit;
|
|
197515
197613
|
}
|
|
197516
197614
|
}
|
|
197517
197615
|
expr = tryDesugarInterleaveTaggedTemplate(expr, ctx);
|
|
197518
|
-
if (
|
|
197616
|
+
if (import_typescript13.default.isAwaitExpression(expr)) {
|
|
197519
197617
|
ctx.analyzer.errors.push(createError(ErrorCodes.STAGE_AWAIT_IN_TEMPLATE, getSourceLocation(expr, ctx.sourceFile, ctx.filePath)));
|
|
197520
197618
|
return AttrValueOf.expression("undefined");
|
|
197521
197619
|
}
|
|
197522
197620
|
checkBareSignalOrMemoIdentifier(expr, ctx);
|
|
197523
|
-
if (attr.name.getText(ctx.sourceFile) === "style" &&
|
|
197621
|
+
if (attr.name.getText(ctx.sourceFile) === "style" && import_typescript13.default.isObjectLiteralExpression(expr)) {
|
|
197524
197622
|
const cssString = tryStaticStyleObjectToCss(expr);
|
|
197525
197623
|
if (cssString !== null) {
|
|
197526
197624
|
return AttrValueOf.literal(cssString);
|
|
197527
197625
|
}
|
|
197528
197626
|
}
|
|
197529
|
-
if (
|
|
197627
|
+
if (import_typescript13.default.isTemplateExpression(expr)) {
|
|
197530
197628
|
const parts = parseTemplateLiteral(expr, ctx);
|
|
197531
197629
|
if (parts.some((p) => p.type === "ternary" || p.type === "lookup")) {
|
|
197532
197630
|
return AttrValueOf.template(parts);
|
|
197533
197631
|
}
|
|
197534
197632
|
}
|
|
197535
|
-
if (
|
|
197633
|
+
if (import_typescript13.default.isElementAccessExpression(expr) && !import_typescript13.default.isStringLiteralLike(expr.argumentExpression) && !import_typescript13.default.isNumericLiteral(expr.argumentExpression)) {
|
|
197536
197634
|
const parts = tryResolveTemplateSpanFromConst(expr, ctx);
|
|
197537
197635
|
if (parts) {
|
|
197538
197636
|
return AttrValueOf.template(parts);
|
|
197539
197637
|
}
|
|
197540
197638
|
}
|
|
197541
|
-
if (
|
|
197639
|
+
if (import_typescript13.default.isIdentifier(expr)) {
|
|
197542
197640
|
const resolved = tryResolveIdentifierAsTemplateLiteral(expr, ctx);
|
|
197543
197641
|
if (resolved) {
|
|
197544
197642
|
return AttrValueOf.template(resolved);
|
|
197545
197643
|
}
|
|
197546
197644
|
}
|
|
197547
|
-
if (
|
|
197645
|
+
if (import_typescript13.default.isConditionalExpression(expr)) {
|
|
197548
197646
|
const ternary = parseTernary(expr, ctx);
|
|
197549
197647
|
if (ternary) {
|
|
197550
197648
|
return AttrValueOf.template([ternary]);
|
|
197551
197649
|
}
|
|
197552
197650
|
}
|
|
197553
|
-
if (
|
|
197554
|
-
if (
|
|
197651
|
+
if (import_typescript13.default.isBinaryExpression(expr) && expr.operatorToken.kind === import_typescript13.default.SyntaxKind.BarBarToken) {
|
|
197652
|
+
if (import_typescript13.default.isIdentifier(expr.right) && expr.right.text === "undefined") {
|
|
197555
197653
|
const baseExpr = ctx.getJS(expr.left);
|
|
197556
197654
|
return AttrValueOf.expression(baseExpr, { presenceOrUndefined: true });
|
|
197557
197655
|
}
|
|
@@ -197564,11 +197662,11 @@ function getAttributeValue(attr, ctx) {
|
|
|
197564
197662
|
function tryStaticStyleObjectToCss(expr) {
|
|
197565
197663
|
const parts = [];
|
|
197566
197664
|
for (const prop of expr.properties) {
|
|
197567
|
-
if (!
|
|
197665
|
+
if (!import_typescript13.default.isPropertyAssignment(prop))
|
|
197568
197666
|
return null;
|
|
197569
|
-
if (!
|
|
197667
|
+
if (!import_typescript13.default.isIdentifier(prop.name) && !import_typescript13.default.isStringLiteral(prop.name))
|
|
197570
197668
|
return null;
|
|
197571
|
-
if (!
|
|
197669
|
+
if (!import_typescript13.default.isStringLiteral(prop.initializer))
|
|
197572
197670
|
return null;
|
|
197573
197671
|
const key = cssKebabCase(prop.name.text);
|
|
197574
197672
|
parts.push(`${key}:${prop.initializer.text}`);
|
|
@@ -197581,7 +197679,7 @@ function parseTemplateLiteral(expr, ctx) {
|
|
|
197581
197679
|
parts.push({ type: "string", value: expr.head.text });
|
|
197582
197680
|
}
|
|
197583
197681
|
for (const span of expr.templateSpans) {
|
|
197584
|
-
if (
|
|
197682
|
+
if (import_typescript13.default.isConditionalExpression(span.expression)) {
|
|
197585
197683
|
const ternary = parseTernary(span.expression, ctx);
|
|
197586
197684
|
if (ternary) {
|
|
197587
197685
|
parts.push(ternary);
|
|
@@ -197607,7 +197705,7 @@ function parseTemplateLiteral(expr, ctx) {
|
|
|
197607
197705
|
return parts;
|
|
197608
197706
|
}
|
|
197609
197707
|
function tryResolveTemplateSpanFromConst(expr, ctx) {
|
|
197610
|
-
if (
|
|
197708
|
+
if (import_typescript13.default.isIdentifier(expr)) {
|
|
197611
197709
|
if (ctx.scope.isBound(expr.text))
|
|
197612
197710
|
return null;
|
|
197613
197711
|
const constInfo = findLocalConst(expr.text, ctx.analyzer);
|
|
@@ -197616,13 +197714,13 @@ function tryResolveTemplateSpanFromConst(expr, ctx) {
|
|
|
197616
197714
|
const ast = parseConstInitializer(constInfo);
|
|
197617
197715
|
if (!ast)
|
|
197618
197716
|
return null;
|
|
197619
|
-
if (
|
|
197717
|
+
if (import_typescript13.default.isStringLiteral(ast) || import_typescript13.default.isNoSubstitutionTemplateLiteral(ast)) {
|
|
197620
197718
|
return [{ type: "string", value: ast.text }];
|
|
197621
197719
|
}
|
|
197622
197720
|
return null;
|
|
197623
197721
|
}
|
|
197624
|
-
if (
|
|
197625
|
-
if (!
|
|
197722
|
+
if (import_typescript13.default.isElementAccessExpression(expr)) {
|
|
197723
|
+
if (!import_typescript13.default.isIdentifier(expr.expression))
|
|
197626
197724
|
return null;
|
|
197627
197725
|
if (ctx.scope.isBound(expr.expression.text))
|
|
197628
197726
|
return null;
|
|
@@ -197630,17 +197728,17 @@ function tryResolveTemplateSpanFromConst(expr, ctx) {
|
|
|
197630
197728
|
if (!constInfo)
|
|
197631
197729
|
return null;
|
|
197632
197730
|
const ast = parseConstInitializer(constInfo);
|
|
197633
|
-
if (!ast || !
|
|
197731
|
+
if (!ast || !import_typescript13.default.isObjectLiteralExpression(ast))
|
|
197634
197732
|
return null;
|
|
197635
197733
|
const cases = {};
|
|
197636
197734
|
for (const prop of ast.properties) {
|
|
197637
|
-
if (!
|
|
197735
|
+
if (!import_typescript13.default.isPropertyAssignment(prop))
|
|
197638
197736
|
return null;
|
|
197639
|
-
const keyName = prop.name && (
|
|
197737
|
+
const keyName = prop.name && (import_typescript13.default.isStringLiteral(prop.name) || import_typescript13.default.isIdentifier(prop.name)) ? prop.name.text : null;
|
|
197640
197738
|
if (!keyName)
|
|
197641
197739
|
return null;
|
|
197642
197740
|
const value = prop.initializer;
|
|
197643
|
-
if (
|
|
197741
|
+
if (import_typescript13.default.isStringLiteral(value) || import_typescript13.default.isNoSubstitutionTemplateLiteral(value)) {
|
|
197644
197742
|
cases[keyName] = value.text;
|
|
197645
197743
|
} else {
|
|
197646
197744
|
return null;
|
|
@@ -197687,17 +197785,17 @@ function hasDynamicTagBinding(name, sourceFile) {
|
|
|
197687
197785
|
const visit2 = (node) => {
|
|
197688
197786
|
if (found)
|
|
197689
197787
|
return;
|
|
197690
|
-
if (
|
|
197788
|
+
if (import_typescript13.default.isVariableDeclaration(node) && import_typescript13.default.isIdentifier(node.name) && node.name.text === name && node.initializer) {
|
|
197691
197789
|
let init = node.initializer;
|
|
197692
|
-
while (
|
|
197790
|
+
while (import_typescript13.default.isAsExpression(init) || import_typescript13.default.isSatisfiesExpression(init) || import_typescript13.default.isParenthesizedExpression(init) || import_typescript13.default.isNonNullExpression(init)) {
|
|
197693
197791
|
init = init.expression;
|
|
197694
197792
|
}
|
|
197695
|
-
if (
|
|
197793
|
+
if (import_typescript13.default.isPropertyAccessExpression(init) && init.name.text === "tag") {
|
|
197696
197794
|
found = true;
|
|
197697
197795
|
return;
|
|
197698
197796
|
}
|
|
197699
197797
|
}
|
|
197700
|
-
|
|
197798
|
+
import_typescript13.default.forEachChild(node, visit2);
|
|
197701
197799
|
};
|
|
197702
197800
|
visit2(sourceFile);
|
|
197703
197801
|
return found;
|
|
@@ -197711,13 +197809,13 @@ function tryResolveIdentifierAsTemplateLiteral(ident, ctx) {
|
|
|
197711
197809
|
const ast = parseConstInitializer(constInfo);
|
|
197712
197810
|
if (!ast)
|
|
197713
197811
|
return null;
|
|
197714
|
-
if (
|
|
197812
|
+
if (import_typescript13.default.isNoSubstitutionTemplateLiteral(ast) || import_typescript13.default.isStringLiteral(ast)) {
|
|
197715
197813
|
return [{ type: "string", value: ast.text }];
|
|
197716
197814
|
}
|
|
197717
|
-
if (
|
|
197815
|
+
if (import_typescript13.default.isElementAccessExpression(ast) && !import_typescript13.default.isStringLiteralLike(ast.argumentExpression) && !import_typescript13.default.isNumericLiteral(ast.argumentExpression)) {
|
|
197718
197816
|
return tryResolveTemplateSpanFromConst(ast, ctx);
|
|
197719
197817
|
}
|
|
197720
|
-
if (!
|
|
197818
|
+
if (!import_typescript13.default.isTemplateExpression(ast))
|
|
197721
197819
|
return null;
|
|
197722
197820
|
let resolvedAny = false;
|
|
197723
197821
|
const parts = [];
|
|
@@ -197755,14 +197853,14 @@ function parseConstInitializerImpl(c) {
|
|
|
197755
197853
|
if (!c.value)
|
|
197756
197854
|
return null;
|
|
197757
197855
|
const wrapped = `const __bf_resolve__ = (${c.value})`;
|
|
197758
|
-
const sf =
|
|
197856
|
+
const sf = import_typescript13.default.createSourceFile("__bf_resolve.ts", wrapped, import_typescript13.default.ScriptTarget.Latest, true, import_typescript13.default.ScriptKind.TS);
|
|
197759
197857
|
const stmt = sf.statements[0];
|
|
197760
|
-
if (!stmt || !
|
|
197858
|
+
if (!stmt || !import_typescript13.default.isVariableStatement(stmt))
|
|
197761
197859
|
return null;
|
|
197762
197860
|
const decl = stmt.declarationList.declarations[0];
|
|
197763
197861
|
if (!decl?.initializer)
|
|
197764
197862
|
return null;
|
|
197765
|
-
return
|
|
197863
|
+
return import_typescript13.default.isParenthesizedExpression(decl.initializer) ? decl.initializer.expression : decl.initializer;
|
|
197766
197864
|
}
|
|
197767
197865
|
function astText(node) {
|
|
197768
197866
|
return node.getText(node.getSourceFile());
|
|
@@ -197782,9 +197880,9 @@ function parseFunctionInfoAsExprImpl(fn) {
|
|
|
197782
197880
|
const params = fn.typedParams !== undefined ? fn.typedParams : fn.params.map(formatParamWithType).join(", ");
|
|
197783
197881
|
const body = fn.typedBody ?? fn.body;
|
|
197784
197882
|
const wrapped = `const __bf_resolve_fn__ = function(${params}) ${body}`;
|
|
197785
|
-
const sf =
|
|
197883
|
+
const sf = import_typescript13.default.createSourceFile("__bf_resolve_fn.ts", wrapped, import_typescript13.default.ScriptTarget.Latest, true, import_typescript13.default.ScriptKind.TS);
|
|
197786
197884
|
const stmt = sf.statements[0];
|
|
197787
|
-
if (!stmt || !
|
|
197885
|
+
if (!stmt || !import_typescript13.default.isVariableStatement(stmt))
|
|
197788
197886
|
return null;
|
|
197789
197887
|
const decl = stmt.declarationList.declarations[0];
|
|
197790
197888
|
if (!decl?.initializer)
|
|
@@ -197792,9 +197890,9 @@ function parseFunctionInfoAsExprImpl(fn) {
|
|
|
197792
197890
|
return decl.initializer;
|
|
197793
197891
|
}
|
|
197794
197892
|
function tryDesugarInterleaveTaggedTemplate(expr, ctx) {
|
|
197795
|
-
if (!
|
|
197893
|
+
if (!import_typescript13.default.isTaggedTemplateExpression(expr))
|
|
197796
197894
|
return expr;
|
|
197797
|
-
if (!
|
|
197895
|
+
if (!import_typescript13.default.isIdentifier(expr.tag))
|
|
197798
197896
|
return expr;
|
|
197799
197897
|
const resolvedTag = resolveInterleaveTagIdentifier(expr.tag.text, ctx);
|
|
197800
197898
|
if (!resolvedTag)
|
|
@@ -197811,23 +197909,23 @@ function resolveInterleaveTagIdentifier(name, ctx) {
|
|
|
197811
197909
|
return null;
|
|
197812
197910
|
if (constInfo) {
|
|
197813
197911
|
const ast = parseConstInitializer(constInfo);
|
|
197814
|
-
return ast && (
|
|
197912
|
+
return ast && (import_typescript13.default.isArrowFunction(ast) || import_typescript13.default.isFunctionExpression(ast)) ? ast : null;
|
|
197815
197913
|
}
|
|
197816
197914
|
if (fnInfo) {
|
|
197817
197915
|
const ast = parseFunctionInfoAsExpr(fnInfo);
|
|
197818
|
-
return ast && (
|
|
197916
|
+
return ast && (import_typescript13.default.isArrowFunction(ast) || import_typescript13.default.isFunctionExpression(ast)) ? ast : null;
|
|
197819
197917
|
}
|
|
197820
197918
|
return null;
|
|
197821
197919
|
}
|
|
197822
197920
|
function isInterleaveTagFunction(fn) {
|
|
197823
|
-
if (!
|
|
197921
|
+
if (!import_typescript13.default.isArrowFunction(fn) && !import_typescript13.default.isFunctionExpression(fn))
|
|
197824
197922
|
return false;
|
|
197825
197923
|
if (fn.parameters.length !== 2)
|
|
197826
197924
|
return false;
|
|
197827
197925
|
const [partsParam, argsParam] = fn.parameters;
|
|
197828
|
-
if (!
|
|
197926
|
+
if (!import_typescript13.default.isIdentifier(partsParam.name) || partsParam.dotDotDotToken)
|
|
197829
197927
|
return false;
|
|
197830
|
-
if (!
|
|
197928
|
+
if (!import_typescript13.default.isIdentifier(argsParam.name) || !argsParam.dotDotDotToken)
|
|
197831
197929
|
return false;
|
|
197832
197930
|
const parsed = tsNodeToParsedExpr(fn);
|
|
197833
197931
|
if (parsed.kind !== "arrow")
|
|
@@ -197884,7 +197982,7 @@ function isInterleaveSpanExpr(expr, i2, argsName) {
|
|
|
197884
197982
|
function buildUntaggedTemplateLiteral(node, ctx) {
|
|
197885
197983
|
const template = node.template;
|
|
197886
197984
|
let text;
|
|
197887
|
-
if (
|
|
197985
|
+
if (import_typescript13.default.isNoSubstitutionTemplateLiteral(template)) {
|
|
197888
197986
|
text = "`" + (template.rawText ?? template.text) + "`";
|
|
197889
197987
|
} else {
|
|
197890
197988
|
let body = template.head.rawText ?? template.head.text;
|
|
@@ -197896,15 +197994,15 @@ function buildUntaggedTemplateLiteral(node, ctx) {
|
|
|
197896
197994
|
text = "`" + body + "`";
|
|
197897
197995
|
}
|
|
197898
197996
|
const wrapped = `const __bf_resolve_tagged__ = (${text})`;
|
|
197899
|
-
const sf =
|
|
197997
|
+
const sf = import_typescript13.default.createSourceFile("__bf_resolve_tagged.tsx", wrapped, import_typescript13.default.ScriptTarget.Latest, true, import_typescript13.default.ScriptKind.TSX);
|
|
197900
197998
|
const stmt = sf.statements[0];
|
|
197901
|
-
if (!stmt || !
|
|
197999
|
+
if (!stmt || !import_typescript13.default.isVariableStatement(stmt))
|
|
197902
198000
|
return null;
|
|
197903
198001
|
const decl = stmt.declarationList.declarations[0];
|
|
197904
198002
|
if (!decl?.initializer)
|
|
197905
198003
|
return null;
|
|
197906
|
-
const result =
|
|
197907
|
-
if (!
|
|
198004
|
+
const result = import_typescript13.default.isParenthesizedExpression(decl.initializer) ? decl.initializer.expression : decl.initializer;
|
|
198005
|
+
if (!import_typescript13.default.isTemplateExpression(result) && !import_typescript13.default.isNoSubstitutionTemplateLiteral(result))
|
|
197908
198006
|
return null;
|
|
197909
198007
|
return result;
|
|
197910
198008
|
}
|
|
@@ -197924,10 +198022,10 @@ function parseTernary(expr, ctx) {
|
|
|
197924
198022
|
return null;
|
|
197925
198023
|
}
|
|
197926
198024
|
function getStringValue(node) {
|
|
197927
|
-
if (
|
|
198025
|
+
if (import_typescript13.default.isStringLiteral(node)) {
|
|
197928
198026
|
return node.text;
|
|
197929
198027
|
}
|
|
197930
|
-
if (
|
|
198028
|
+
if (import_typescript13.default.isNoSubstitutionTemplateLiteral(node)) {
|
|
197931
198029
|
return node.text;
|
|
197932
198030
|
}
|
|
197933
198031
|
return null;
|
|
@@ -197935,19 +198033,19 @@ function getStringValue(node) {
|
|
|
197935
198033
|
function processComponentProps(attributes, ctx) {
|
|
197936
198034
|
const props = [];
|
|
197937
198035
|
for (const attr of attributes.properties) {
|
|
197938
|
-
if (
|
|
198036
|
+
if (import_typescript13.default.isJsxSpreadAttribute(attr)) {
|
|
197939
198037
|
props.push(...expandSpreadAttribute(attr, ctx));
|
|
197940
198038
|
continue;
|
|
197941
198039
|
}
|
|
197942
|
-
if (!
|
|
198040
|
+
if (!import_typescript13.default.isJsxAttribute(attr))
|
|
197943
198041
|
continue;
|
|
197944
198042
|
const name = attr.name.getText(ctx.sourceFile);
|
|
197945
|
-
if (attr.initializer &&
|
|
198043
|
+
if (attr.initializer && import_typescript13.default.isJsxExpression(attr.initializer) && attr.initializer.expression) {
|
|
197946
198044
|
let jsxExpr = attr.initializer.expression;
|
|
197947
|
-
while (
|
|
198045
|
+
while (import_typescript13.default.isParenthesizedExpression(jsxExpr)) {
|
|
197948
198046
|
jsxExpr = jsxExpr.expression;
|
|
197949
198047
|
}
|
|
197950
|
-
if (
|
|
198048
|
+
if (import_typescript13.default.isJsxElement(jsxExpr) || import_typescript13.default.isJsxSelfClosingElement(jsxExpr) || import_typescript13.default.isJsxFragment(jsxExpr)) {
|
|
197951
198049
|
const prevInsideComponentChildren = ctx.insideComponentChildren;
|
|
197952
198050
|
ctx.insideComponentChildren = true;
|
|
197953
198051
|
const irNode = transformNode(jsxExpr, ctx);
|
|
@@ -197974,7 +198072,7 @@ function processComponentProps(attributes, ctx) {
|
|
|
197974
198072
|
value = AttrValueOf.booleanShorthand();
|
|
197975
198073
|
}
|
|
197976
198074
|
let clientOnly;
|
|
197977
|
-
if (attr.initializer &&
|
|
198075
|
+
if (attr.initializer && import_typescript13.default.isJsxExpression(attr.initializer) && attr.initializer.expression) {
|
|
197978
198076
|
if (value.kind === "expression" && value.templateExpr === undefined) {
|
|
197979
198077
|
const rewritten = rewriteBarePropRefs2(value.expr, attr.initializer.expression, ctx);
|
|
197980
198078
|
if (rewritten !== value.expr) {
|
|
@@ -197998,7 +198096,7 @@ function processComponentProps(attributes, ctx) {
|
|
|
197998
198096
|
return props;
|
|
197999
198097
|
}
|
|
198000
198098
|
function checkBareSignalOrMemoIdentifier(expr, ctx) {
|
|
198001
|
-
if (!
|
|
198099
|
+
if (!import_typescript13.default.isIdentifier(expr))
|
|
198002
198100
|
return;
|
|
198003
198101
|
const name = expr.text;
|
|
198004
198102
|
for (const signal of ctx.analyzer.signals) {
|
|
@@ -198029,12 +198127,12 @@ function checkBareSignalOrMemoIdentifier(expr, ctx) {
|
|
|
198029
198127
|
function isArrayExprDirectPropRef(arrayExpr, ctx) {
|
|
198030
198128
|
const propNames = new Set(ctx.patterns.props.map((p) => p.name));
|
|
198031
198129
|
const propsObjName = ctx.analyzer.propsObjectName;
|
|
198032
|
-
if (
|
|
198130
|
+
if (import_typescript13.default.isIdentifier(arrayExpr)) {
|
|
198033
198131
|
return propNames.has(arrayExpr.text);
|
|
198034
198132
|
}
|
|
198035
|
-
if (
|
|
198133
|
+
if (import_typescript13.default.isPropertyAccessExpression(arrayExpr) && propsObjName) {
|
|
198036
198134
|
const obj = arrayExpr.expression;
|
|
198037
|
-
if (
|
|
198135
|
+
if (import_typescript13.default.isIdentifier(obj) && obj.text === propsObjName) {
|
|
198038
198136
|
return true;
|
|
198039
198137
|
}
|
|
198040
198138
|
}
|
|
@@ -198229,7 +198327,7 @@ function buildIfStatementChain(analyzer, ctx, opts) {
|
|
|
198229
198327
|
jsxBranchLocalNames.add(n);
|
|
198230
198328
|
}
|
|
198231
198329
|
for (const decl of condReturn.scopeVariables) {
|
|
198232
|
-
if (
|
|
198330
|
+
if (import_typescript13.default.isIdentifier(decl.name) && decl.initializer) {
|
|
198233
198331
|
branchScopeVars.set(decl.name.text, decl.initializer);
|
|
198234
198332
|
if (initializerShapeContainsJsx(decl.initializer)) {
|
|
198235
198333
|
jsxBranchLocalNames.add(decl.name.text);
|
|
@@ -198296,7 +198394,7 @@ function buildIfStatementChain(analyzer, ctx, opts) {
|
|
|
198296
198394
|
}
|
|
198297
198395
|
const scopeVariables = [];
|
|
198298
198396
|
for (const decl of condReturn.scopeVariables) {
|
|
198299
|
-
if (
|
|
198397
|
+
if (import_typescript13.default.isIdentifier(decl.name) && decl.initializer) {
|
|
198300
198398
|
const init = ctx.getJS(decl.initializer);
|
|
198301
198399
|
const typedInit = decl.initializer.getText(ctx.sourceFile);
|
|
198302
198400
|
scopeVariables.push({
|
|
@@ -198434,13 +198532,13 @@ var KEYWORDS_AND_GLOBALS = new Set([
|
|
|
198434
198532
|
]);
|
|
198435
198533
|
|
|
198436
198534
|
// ../jsx/src/ir-to-client-js/walk-prop-accesses.ts
|
|
198437
|
-
var
|
|
198535
|
+
var import_typescript14 = __toESM(require_typescript(), 1);
|
|
198438
198536
|
|
|
198439
198537
|
// ../jsx/src/value-references.ts
|
|
198440
|
-
var
|
|
198538
|
+
var import_typescript15 = __toESM(require_typescript(), 1);
|
|
198441
198539
|
|
|
198442
198540
|
// ../jsx/src/relocate.ts
|
|
198443
|
-
var
|
|
198541
|
+
var import_typescript16 = __toESM(require_typescript(), 1);
|
|
198444
198542
|
|
|
198445
198543
|
// ../jsx/src/lowering-registry.ts
|
|
198446
198544
|
var plugins = [];
|
|
@@ -198619,10 +198717,10 @@ function formatDateLocalNames(metadata) {
|
|
|
198619
198717
|
}
|
|
198620
198718
|
|
|
198621
198719
|
// ../jsx/src/ir-to-client-js/prune-unused-prop-extractions.ts
|
|
198622
|
-
var
|
|
198720
|
+
var import_typescript17 = __toESM(require_typescript(), 1);
|
|
198623
198721
|
|
|
198624
198722
|
// ../jsx/src/ir-to-client-js/control-flow/plan/lazy-preamble.ts
|
|
198625
|
-
var
|
|
198723
|
+
var import_typescript18 = __toESM(require_typescript(), 1);
|
|
198626
198724
|
var NO_PREAMBLE = {
|
|
198627
198725
|
lazySafe: true,
|
|
198628
198726
|
facts: { declaredNames: new Set, freeNames: new Set }
|
|
@@ -198672,7 +198770,7 @@ var INERT_BINDING_GLOBALS = new Set([
|
|
|
198672
198770
|
]);
|
|
198673
198771
|
|
|
198674
198772
|
// ../jsx/src/ir-to-client-js/emit-reactive.ts
|
|
198675
|
-
var
|
|
198773
|
+
var import_typescript19 = __toESM(require_typescript(), 1);
|
|
198676
198774
|
|
|
198677
198775
|
// ../jsx/src/ir-to-client-js/control-flow/stringify/event-delegation.ts
|
|
198678
198776
|
var NON_BUBBLING_EVENTS = new Set([
|
|
@@ -198687,7 +198785,7 @@ var NON_BUBBLING_EVENTS = new Set([
|
|
|
198687
198785
|
]);
|
|
198688
198786
|
|
|
198689
198787
|
// ../jsx/src/ir-to-client-js/rewrite-props-object.ts
|
|
198690
|
-
var
|
|
198788
|
+
var import_typescript20 = __toESM(require_typescript(), 1);
|
|
198691
198789
|
|
|
198692
198790
|
// ../jsx/src/ir-to-client-js/source-map.ts
|
|
198693
198791
|
var BASE64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
@@ -198778,21 +198876,21 @@ class SourceMapGenerator {
|
|
|
198778
198876
|
}
|
|
198779
198877
|
|
|
198780
198878
|
// ../jsx/src/preprocess-inline-jsx-callbacks.ts
|
|
198781
|
-
var
|
|
198879
|
+
var import_typescript21 = __toESM(require_typescript(), 1);
|
|
198782
198880
|
|
|
198783
198881
|
// ../jsx/src/ssr-defaults.ts
|
|
198784
|
-
var
|
|
198882
|
+
var import_typescript22 = __toESM(require_typescript(), 1);
|
|
198785
198883
|
var UNRESOLVED = Symbol("unresolved");
|
|
198786
198884
|
var NO_RETURN = Symbol("no-return");
|
|
198787
198885
|
|
|
198788
198886
|
// ../jsx/src/augment-inherited-props.ts
|
|
198789
|
-
var
|
|
198887
|
+
var import_typescript23 = __toESM(require_typescript(), 1);
|
|
198790
198888
|
|
|
198791
198889
|
// ../jsx/src/rich-type-refusal.ts
|
|
198792
198890
|
var EMPTY_BINDINGS2 = new Map;
|
|
198793
198891
|
// ../jsx/src/shared-program.ts
|
|
198794
198892
|
init_path();
|
|
198795
|
-
var
|
|
198893
|
+
var import_typescript25 = __toESM(require_typescript(), 1);
|
|
198796
198894
|
// ../jsx/src/adapters/interface.ts
|
|
198797
198895
|
class BaseAdapter {
|
|
198798
198896
|
renderChildren(children) {
|
|
@@ -198845,7 +198943,7 @@ class JsxAdapter extends BaseAdapter {
|
|
|
198845
198943
|
...localFunctions.map((f) => ({ name: f.name, body: f.body })),
|
|
198846
198944
|
...localConstants.map((c) => ({ name: c.name, body: c.value }))
|
|
198847
198945
|
];
|
|
198848
|
-
const reachable =
|
|
198946
|
+
const reachable = closeOverWritersOfMutableBindings(primaryRefText, declarations, new Set(ir.metadata.localConstants.filter((c) => (c.declarationKind ?? "const") !== "const").map((c) => c.name)));
|
|
198849
198947
|
const reachableBodies = [...reachable].map((name) => {
|
|
198850
198948
|
const func = localFunctions.find((f) => f.name === name);
|
|
198851
198949
|
if (func)
|
|
@@ -198877,7 +198975,8 @@ class JsxAdapter extends BaseAdapter {
|
|
|
198877
198975
|
if (signal.setter) {
|
|
198878
198976
|
const setterUsed = identifierPattern(signal.setter).test(setterRefText);
|
|
198879
198977
|
if (setterUsed) {
|
|
198880
|
-
|
|
198978
|
+
const setterType = preserveTypes && signal.type.kind !== "unknown" ? `(valueOrFn: ${signal.type.raw} | ((prev: ${signal.type.raw}) => ${signal.type.raw})) => void` : null;
|
|
198979
|
+
lines.push(setterType ? ` const ${signal.setter}: ${setterType} = () => {}` : ` const ${signal.setter} = (..._args: any[]) => {}`);
|
|
198881
198980
|
}
|
|
198882
198981
|
}
|
|
198883
198982
|
}
|
|
@@ -199073,7 +199172,7 @@ class JsxAdapter extends BaseAdapter {
|
|
|
199073
199172
|
}
|
|
199074
199173
|
|
|
199075
199174
|
// ../jsx/src/adapters/template-imports.ts
|
|
199076
|
-
var
|
|
199175
|
+
var import_typescript26 = __toESM(require_typescript(), 1);
|
|
199077
199176
|
var CLIENT_PACKAGE_SOURCES = new Set([
|
|
199078
199177
|
"@barefootjs/client",
|
|
199079
199178
|
"@barefootjs/client/runtime"
|
|
@@ -199212,7 +199311,8 @@ export default ${this.componentName}` : "";
|
|
|
199212
199311
|
const noArgDefault = hasRequiredProps ? "" : ` = {} as ${propsTypeExpr}`;
|
|
199213
199312
|
const lines = [];
|
|
199214
199313
|
const exportPrefix = ir.metadata.isExported === false ? "" : "export ";
|
|
199215
|
-
|
|
199314
|
+
const typeParameters = ir.metadata.typeParameters ?? "";
|
|
199315
|
+
lines.push(`${exportPrefix}function ${name}${typeParameters}(${fullPropsDestructure}${typeAnnotation}${noArgDefault}) {`);
|
|
199216
199316
|
if (hasClientInteractivity) {
|
|
199217
199317
|
lines.push(` const __scopeId = (/_s\\d/.test(__bfScope || '') ? __bfScope : null) || __instanceId || \`${name}_\${Math.random().toString(36).slice(2, 8)}\``);
|
|
199218
199318
|
} else {
|
|
@@ -199463,9 +199563,9 @@ function registerBuiltinLoweringPlugins() {
|
|
|
199463
199563
|
registerLoweringPlugin(plugin);
|
|
199464
199564
|
}
|
|
199465
199565
|
// ../jsx/src/combine-client-js.ts
|
|
199466
|
-
var import_typescript26 = __toESM(require_typescript(), 1);
|
|
199467
|
-
// ../jsx/src/debug.ts
|
|
199468
199566
|
var import_typescript27 = __toESM(require_typescript(), 1);
|
|
199567
|
+
// ../jsx/src/debug.ts
|
|
199568
|
+
var import_typescript28 = __toESM(require_typescript(), 1);
|
|
199469
199569
|
function escapeForIdBoundary(name) {
|
|
199470
199570
|
return name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
199471
199571
|
}
|
|
@@ -199557,7 +199657,7 @@ function resolveSetters(handler, setterToSignal, fnSetters) {
|
|
|
199557
199657
|
return refs;
|
|
199558
199658
|
}
|
|
199559
199659
|
// ../jsx/src/profiler.ts
|
|
199560
|
-
var
|
|
199660
|
+
var import_typescript29 = __toESM(require_typescript(), 1);
|
|
199561
199661
|
|
|
199562
199662
|
// ../jsx/src/index.ts
|
|
199563
199663
|
registerBuiltinLoweringPlugins();
|