@barefootjs/test 0.33.4 → 0.33.6
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 +970 -848
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -187291,7 +187291,7 @@ Additional information: BADCLIENT: Bad error code, ${badCode} not found in range
|
|
|
187291
187291
|
var import_typescript25 = __toESM(require_typescript(), 1);
|
|
187292
187292
|
|
|
187293
187293
|
// ../jsx/src/analyzer.ts
|
|
187294
|
-
var
|
|
187294
|
+
var import_typescript10 = __toESM(require_typescript(), 1);
|
|
187295
187295
|
|
|
187296
187296
|
// ../jsx/src/expression-parser.ts
|
|
187297
187297
|
var import_typescript = __toESM(require_typescript(), 1);
|
|
@@ -188829,7 +188829,7 @@ function identifierPath(callee) {
|
|
|
188829
188829
|
}
|
|
188830
188830
|
|
|
188831
188831
|
// ../jsx/src/prop-rewrite.ts
|
|
188832
|
-
var
|
|
188832
|
+
var import_typescript7 = __toESM(require_typescript(), 1);
|
|
188833
188833
|
|
|
188834
188834
|
// ../jsx/src/ir-to-client-js/utils.ts
|
|
188835
188835
|
var import_typescript3 = __toESM(require_typescript(), 1);
|
|
@@ -189251,18 +189251,82 @@ function computeFileScope(entryPath) {
|
|
|
189251
189251
|
}
|
|
189252
189252
|
|
|
189253
189253
|
// ../jsx/src/ir-to-client-js/csr-substitute.ts
|
|
189254
|
+
var import_typescript5 = __toESM(require_typescript(), 1);
|
|
189255
|
+
|
|
189256
|
+
// ../jsx/src/props-binding.ts
|
|
189254
189257
|
var import_typescript4 = __toESM(require_typescript(), 1);
|
|
189258
|
+
function isIdentifierName(key) {
|
|
189259
|
+
if (key.length === 0)
|
|
189260
|
+
return false;
|
|
189261
|
+
for (let i2 = 0;i2 < key.length; ) {
|
|
189262
|
+
const cp = key.codePointAt(i2);
|
|
189263
|
+
const ok = i2 === 0 ? import_typescript4.default.isIdentifierStart(cp, import_typescript4.default.ScriptTarget.Latest) : import_typescript4.default.isIdentifierPart(cp, import_typescript4.default.ScriptTarget.Latest);
|
|
189264
|
+
if (!ok)
|
|
189265
|
+
return false;
|
|
189266
|
+
i2 += cp > 65535 ? 2 : 1;
|
|
189267
|
+
}
|
|
189268
|
+
return true;
|
|
189269
|
+
}
|
|
189270
|
+
function propsDestructureBinding(p) {
|
|
189271
|
+
const callerKey = p.sourceName ?? p.name;
|
|
189272
|
+
const localName = p.name;
|
|
189273
|
+
const binding = callerKey === localName ? localName : `${isIdentifierName(callerKey) ? callerKey : JSON.stringify(callerKey)}: ${localName}`;
|
|
189274
|
+
return p.defaultValue ? `${binding} = ${p.defaultValue}` : binding;
|
|
189275
|
+
}
|
|
189276
|
+
function buildPropAliasMap(params) {
|
|
189277
|
+
let map;
|
|
189278
|
+
for (const p of params) {
|
|
189279
|
+
if (p.sourceName) {
|
|
189280
|
+
if (!map)
|
|
189281
|
+
map = new Map;
|
|
189282
|
+
map.set(p.name, p.sourceName);
|
|
189283
|
+
}
|
|
189284
|
+
}
|
|
189285
|
+
return map;
|
|
189286
|
+
}
|
|
189287
|
+
function boundPropLocalNames(b) {
|
|
189288
|
+
if (b.propsObjectName !== null)
|
|
189289
|
+
return EMPTY_SET;
|
|
189290
|
+
return new Set(b.propsParams.filter((p) => !p.isRest).map((p) => p.name));
|
|
189291
|
+
}
|
|
189292
|
+
var EMPTY_SET = new Set;
|
|
189293
|
+
function resolveAliasOrigin(constantValues, name, terminal) {
|
|
189294
|
+
const visited = new Set;
|
|
189295
|
+
let current = name.trim();
|
|
189296
|
+
while (current !== undefined && !visited.has(current)) {
|
|
189297
|
+
const hit = terminal(current);
|
|
189298
|
+
if (hit !== null)
|
|
189299
|
+
return hit;
|
|
189300
|
+
visited.add(current);
|
|
189301
|
+
current = constantValues.get(current)?.trim();
|
|
189302
|
+
}
|
|
189303
|
+
return null;
|
|
189304
|
+
}
|
|
189305
|
+
function resolveRestSpreadOriginCore(bindings, constantValues, name) {
|
|
189306
|
+
return resolveAliasOrigin(constantValues, name, (current) => {
|
|
189307
|
+
if (bindings.restPropsName && current === bindings.restPropsName)
|
|
189308
|
+
return "rest";
|
|
189309
|
+
if (bindings.propsObjectName && current === bindings.propsObjectName)
|
|
189310
|
+
return "props";
|
|
189311
|
+
return null;
|
|
189312
|
+
});
|
|
189313
|
+
}
|
|
189314
|
+
|
|
189315
|
+
// ../jsx/src/ir-to-client-js/csr-substitute.ts
|
|
189255
189316
|
function extractFreeIdentifiersFromText(text) {
|
|
189256
189317
|
if (!text || text.trim().length === 0)
|
|
189257
189318
|
return new Set;
|
|
189258
|
-
const sf =
|
|
189319
|
+
const sf = import_typescript5.default.createSourceFile("__free_ids__.ts", `(${text});`, import_typescript5.default.ScriptTarget.Latest, true, import_typescript5.default.ScriptKind.TS);
|
|
189259
189320
|
const stmt = sf.statements[0];
|
|
189260
|
-
if (!stmt || !
|
|
189321
|
+
if (!stmt || !import_typescript5.default.isExpressionStatement(stmt))
|
|
189261
189322
|
return new Set;
|
|
189262
|
-
const expr =
|
|
189323
|
+
const expr = import_typescript5.default.isParenthesizedExpression(stmt.expression) ? stmt.expression.expression : stmt.expression;
|
|
189263
189324
|
return extractFreeIdentifiersFromNode(expr);
|
|
189264
189325
|
}
|
|
189265
189326
|
|
|
189327
|
+
// ../jsx/src/ir-to-client-js/rewrite-props-object.ts
|
|
189328
|
+
var import_typescript6 = __toESM(require_typescript(), 1);
|
|
189329
|
+
|
|
189266
189330
|
// ../jsx/src/scope/binding-scope.ts
|
|
189267
189331
|
class BindingScope {
|
|
189268
189332
|
frames;
|
|
@@ -189457,37 +189521,37 @@ var SKELETON_PATH_FORCE_CLOSE_GROUPS = [
|
|
|
189457
189521
|
|
|
189458
189522
|
// ../jsx/src/prop-rewrite.ts
|
|
189459
189523
|
function collectBindingNames(name, out) {
|
|
189460
|
-
if (
|
|
189524
|
+
if (import_typescript7.default.isIdentifier(name)) {
|
|
189461
189525
|
out.add(name.text);
|
|
189462
189526
|
return;
|
|
189463
189527
|
}
|
|
189464
189528
|
for (const el of name.elements) {
|
|
189465
|
-
if (
|
|
189529
|
+
if (import_typescript7.default.isBindingElement(el))
|
|
189466
189530
|
collectBindingNames(el.name, out);
|
|
189467
189531
|
}
|
|
189468
189532
|
}
|
|
189469
189533
|
function scopeFrameOf(n) {
|
|
189470
|
-
if (
|
|
189534
|
+
if (import_typescript7.default.isFunctionLike(n)) {
|
|
189471
189535
|
const frame = new Set;
|
|
189472
189536
|
for (const p of n.parameters)
|
|
189473
189537
|
collectBindingNames(p.name, frame);
|
|
189474
|
-
if ((
|
|
189538
|
+
if ((import_typescript7.default.isFunctionExpression(n) || import_typescript7.default.isFunctionDeclaration(n)) && n.name)
|
|
189475
189539
|
frame.add(n.name.text);
|
|
189476
189540
|
return frame.size > 0 ? frame : null;
|
|
189477
189541
|
}
|
|
189478
|
-
if (
|
|
189542
|
+
if (import_typescript7.default.isBlock(n)) {
|
|
189479
189543
|
const frame = new Set;
|
|
189480
189544
|
for (const st of n.statements) {
|
|
189481
|
-
if (
|
|
189545
|
+
if (import_typescript7.default.isVariableStatement(st)) {
|
|
189482
189546
|
for (const d of st.declarationList.declarations)
|
|
189483
189547
|
collectBindingNames(d.name, frame);
|
|
189484
|
-
} else if (
|
|
189548
|
+
} else if (import_typescript7.default.isFunctionDeclaration(st) && st.name) {
|
|
189485
189549
|
frame.add(st.name.text);
|
|
189486
189550
|
}
|
|
189487
189551
|
}
|
|
189488
189552
|
return frame.size > 0 ? frame : null;
|
|
189489
189553
|
}
|
|
189490
|
-
if (
|
|
189554
|
+
if (import_typescript7.default.isCatchClause(n) && n.variableDeclaration) {
|
|
189491
189555
|
const frame = new Set;
|
|
189492
189556
|
collectBindingNames(n.variableDeclaration.name, frame);
|
|
189493
189557
|
return frame.size > 0 ? frame : null;
|
|
@@ -189501,9 +189565,9 @@ function walkWithScope(root, visit) {
|
|
|
189501
189565
|
const frame = scopeFrameOf(n);
|
|
189502
189566
|
if (frame)
|
|
189503
189567
|
scopeStack.push(frame);
|
|
189504
|
-
if (
|
|
189568
|
+
if (import_typescript7.default.isIdentifier(n))
|
|
189505
189569
|
visit(n, parent, isShadowed(n.text));
|
|
189506
|
-
|
|
189570
|
+
import_typescript7.default.forEachChild(n, (child) => rec(child, n));
|
|
189507
189571
|
if (frame)
|
|
189508
189572
|
scopeStack.pop();
|
|
189509
189573
|
}
|
|
@@ -189512,15 +189576,15 @@ function walkWithScope(root, visit) {
|
|
|
189512
189576
|
function isNonValuePosition(n, parent) {
|
|
189513
189577
|
if (!parent)
|
|
189514
189578
|
return false;
|
|
189515
|
-
if (
|
|
189579
|
+
if (import_typescript7.default.isPropertyAssignment(parent) && parent.name === n)
|
|
189516
189580
|
return true;
|
|
189517
|
-
if (
|
|
189581
|
+
if (import_typescript7.default.isPropertyAccessExpression(parent) && parent.name === n)
|
|
189518
189582
|
return true;
|
|
189519
|
-
if (
|
|
189583
|
+
if (import_typescript7.default.isQualifiedName(parent) && parent.right === n)
|
|
189520
189584
|
return true;
|
|
189521
|
-
if ((
|
|
189585
|
+
if ((import_typescript7.default.isParameter(parent) || import_typescript7.default.isVariableDeclaration(parent) || import_typescript7.default.isBindingElement(parent)) && parent.name === n)
|
|
189522
189586
|
return true;
|
|
189523
|
-
if (
|
|
189587
|
+
if (import_typescript7.default.isTypeReferenceNode(parent))
|
|
189524
189588
|
return true;
|
|
189525
189589
|
return false;
|
|
189526
189590
|
}
|
|
@@ -189528,17 +189592,17 @@ function collectAstPropRefs(node, propNames, out) {
|
|
|
189528
189592
|
walkWithScope(node, (n, parent, shadowed) => {
|
|
189529
189593
|
if (shadowed || !propNames.has(n.text))
|
|
189530
189594
|
return;
|
|
189531
|
-
if (parent &&
|
|
189595
|
+
if (parent && import_typescript7.default.isShorthandPropertyAssignment(parent) && parent.name === n)
|
|
189532
189596
|
return;
|
|
189533
189597
|
if (isNonValuePosition(n, parent))
|
|
189534
189598
|
return;
|
|
189535
189599
|
out.add(n.text);
|
|
189536
189600
|
});
|
|
189537
189601
|
}
|
|
189538
|
-
function applyScopedPropRefRewrite(text, propRefs, propAliases) {
|
|
189602
|
+
function applyScopedPropRefRewrite(text, propRefs, propAliases, replacementFor) {
|
|
189539
189603
|
const prefix = "(";
|
|
189540
|
-
const sf =
|
|
189541
|
-
)`,
|
|
189604
|
+
const sf = import_typescript7.default.createSourceFile("__bf_prop_rewrite.ts", `${prefix}${text}
|
|
189605
|
+
)`, import_typescript7.default.ScriptTarget.Latest, true);
|
|
189542
189606
|
const parseDiagnostics = sf.parseDiagnostics;
|
|
189543
189607
|
if (parseDiagnostics && parseDiagnostics.length > 0)
|
|
189544
189608
|
return null;
|
|
@@ -189553,11 +189617,12 @@ function applyScopedPropRefRewrite(text, propRefs, propAliases) {
|
|
|
189553
189617
|
if (start < 0 || end > text.length)
|
|
189554
189618
|
return;
|
|
189555
189619
|
const callerKey = propAliases?.get(n.text) ?? n.text;
|
|
189556
|
-
|
|
189557
|
-
|
|
189620
|
+
const value = replacementFor ? replacementFor(n.text, callerKey) : `${PROPS_PARAM}.${callerKey}`;
|
|
189621
|
+
if (parent && import_typescript7.default.isShorthandPropertyAssignment(parent) && parent.name === n) {
|
|
189622
|
+
edits.push({ start, end, replacement: `${n.text}: ${value}` });
|
|
189558
189623
|
return;
|
|
189559
189624
|
}
|
|
189560
|
-
edits.push({ start, end, replacement:
|
|
189625
|
+
edits.push({ start, end, replacement: value });
|
|
189561
189626
|
});
|
|
189562
189627
|
if (edits.length === 0)
|
|
189563
189628
|
return text;
|
|
@@ -189567,11 +189632,12 @@ function applyScopedPropRefRewrite(text, propRefs, propAliases) {
|
|
|
189567
189632
|
}
|
|
189568
189633
|
return result;
|
|
189569
189634
|
}
|
|
189570
|
-
function applyRegexPropRefRewrite(text, propRefs, propAliases) {
|
|
189635
|
+
function applyRegexPropRefRewrite(text, propRefs, propAliases, replacementFor) {
|
|
189571
189636
|
const { protect, restore } = createTemplateAwareStringProtector();
|
|
189572
189637
|
let result = protect(text);
|
|
189573
189638
|
for (const propName of propRefs) {
|
|
189574
189639
|
const callerKey = propAliases?.get(propName) ?? propName;
|
|
189640
|
+
const value = replacementFor ? replacementFor(propName, callerKey) : `${PROPS_PARAM}.${callerKey}`;
|
|
189575
189641
|
const pattern = new RegExp(`(?<!${PROPS_PARAM}\\.)(?<!['"\\w.-])\\b${propName}\\b(?![a-zA-Z0-9_$])`, "g");
|
|
189576
189642
|
result = result.replace(pattern, (match, offset, str) => {
|
|
189577
189643
|
const after = str.slice(offset + match.length);
|
|
@@ -189580,12 +189646,12 @@ function applyRegexPropRefRewrite(text, propRefs, propAliases) {
|
|
|
189580
189646
|
if (/[{,]\s*$/.test(before))
|
|
189581
189647
|
return match;
|
|
189582
189648
|
}
|
|
189583
|
-
return
|
|
189649
|
+
return value;
|
|
189584
189650
|
});
|
|
189585
189651
|
}
|
|
189586
189652
|
return restore(result);
|
|
189587
189653
|
}
|
|
189588
|
-
function rewriteBarePropRefs(text, node, propNames, extraPropRefs, propAliases) {
|
|
189654
|
+
function rewriteBarePropRefs(text, node, propNames, extraPropRefs, propAliases, replacementFor) {
|
|
189589
189655
|
const foundPropRefs = new Set;
|
|
189590
189656
|
collectAstPropRefs(node, propNames, foundPropRefs);
|
|
189591
189657
|
if (extraPropRefs) {
|
|
@@ -189596,52 +189662,7 @@ function rewriteBarePropRefs(text, node, propNames, extraPropRefs, propAliases)
|
|
|
189596
189662
|
}
|
|
189597
189663
|
if (foundPropRefs.size === 0)
|
|
189598
189664
|
return;
|
|
189599
|
-
return applyScopedPropRefRewrite(text, foundPropRefs, propAliases) ?? applyRegexPropRefRewrite(text, foundPropRefs, propAliases);
|
|
189600
|
-
}
|
|
189601
|
-
|
|
189602
|
-
// ../jsx/src/props-binding.ts
|
|
189603
|
-
var import_typescript6 = __toESM(require_typescript(), 1);
|
|
189604
|
-
function isIdentifierName(key) {
|
|
189605
|
-
if (key.length === 0)
|
|
189606
|
-
return false;
|
|
189607
|
-
for (let i2 = 0;i2 < key.length; ) {
|
|
189608
|
-
const cp = key.codePointAt(i2);
|
|
189609
|
-
const ok = i2 === 0 ? import_typescript6.default.isIdentifierStart(cp, import_typescript6.default.ScriptTarget.Latest) : import_typescript6.default.isIdentifierPart(cp, import_typescript6.default.ScriptTarget.Latest);
|
|
189610
|
-
if (!ok)
|
|
189611
|
-
return false;
|
|
189612
|
-
i2 += cp > 65535 ? 2 : 1;
|
|
189613
|
-
}
|
|
189614
|
-
return true;
|
|
189615
|
-
}
|
|
189616
|
-
function propsDestructureBinding(p) {
|
|
189617
|
-
const callerKey = p.sourceName ?? p.name;
|
|
189618
|
-
const localName = p.name;
|
|
189619
|
-
const binding = callerKey === localName ? localName : `${isIdentifierName(callerKey) ? callerKey : JSON.stringify(callerKey)}: ${localName}`;
|
|
189620
|
-
return p.defaultValue ? `${binding} = ${p.defaultValue}` : binding;
|
|
189621
|
-
}
|
|
189622
|
-
function buildPropAliasMap(params) {
|
|
189623
|
-
let map;
|
|
189624
|
-
for (const p of params) {
|
|
189625
|
-
if (p.sourceName) {
|
|
189626
|
-
if (!map)
|
|
189627
|
-
map = new Map;
|
|
189628
|
-
map.set(p.name, p.sourceName);
|
|
189629
|
-
}
|
|
189630
|
-
}
|
|
189631
|
-
return map;
|
|
189632
|
-
}
|
|
189633
|
-
function resolveRestSpreadOriginCore(bindings, constantValues, name) {
|
|
189634
|
-
const visited = new Set;
|
|
189635
|
-
let current = name.trim();
|
|
189636
|
-
while (current !== undefined && !visited.has(current)) {
|
|
189637
|
-
if (bindings.restPropsName && current === bindings.restPropsName)
|
|
189638
|
-
return "rest";
|
|
189639
|
-
if (bindings.propsObjectName && current === bindings.propsObjectName)
|
|
189640
|
-
return "props";
|
|
189641
|
-
visited.add(current);
|
|
189642
|
-
current = constantValues.get(current)?.trim();
|
|
189643
|
-
}
|
|
189644
|
-
return null;
|
|
189665
|
+
return applyScopedPropRefRewrite(text, foundPropRefs, propAliases, replacementFor) ?? applyRegexPropRefRewrite(text, foundPropRefs, propAliases, replacementFor);
|
|
189645
189666
|
}
|
|
189646
189667
|
|
|
189647
189668
|
// ../jsx/src/instrumentation.ts
|
|
@@ -189662,10 +189683,10 @@ function incrementCounter(key) {
|
|
|
189662
189683
|
}
|
|
189663
189684
|
|
|
189664
189685
|
// ../jsx/src/analyzer-context.ts
|
|
189665
|
-
var
|
|
189686
|
+
var import_typescript9 = __toESM(require_typescript(), 1);
|
|
189666
189687
|
|
|
189667
189688
|
// ../jsx/src/strip-types.ts
|
|
189668
|
-
var
|
|
189689
|
+
var import_typescript8 = __toESM(require_typescript(), 1);
|
|
189669
189690
|
function collectAllTypeRanges(sourceFile) {
|
|
189670
189691
|
const ranges = [];
|
|
189671
189692
|
collectTypeRanges(sourceFile, sourceFile, sourceFile.text, ranges);
|
|
@@ -189750,7 +189771,7 @@ function mergeRanges(ranges) {
|
|
|
189750
189771
|
return merged;
|
|
189751
189772
|
}
|
|
189752
189773
|
function collectTypeRanges(node, sourceFile, fullText, ranges) {
|
|
189753
|
-
if (
|
|
189774
|
+
if (import_typescript8.default.isParameter(node)) {
|
|
189754
189775
|
const hasQuestion = !!node.questionToken;
|
|
189755
189776
|
const hasType = !!node.type;
|
|
189756
189777
|
if (hasQuestion && hasType) {
|
|
@@ -189764,72 +189785,72 @@ function collectTypeRanges(node, sourceFile, fullText, ranges) {
|
|
|
189764
189785
|
}
|
|
189765
189786
|
}
|
|
189766
189787
|
}
|
|
189767
|
-
if (
|
|
189788
|
+
if (import_typescript8.default.isVariableDeclaration(node) && node.type) {
|
|
189768
189789
|
const colonPos = findColonBefore(node.type, fullText, node.name.getEnd());
|
|
189769
189790
|
if (colonPos >= 0) {
|
|
189770
189791
|
ranges.push({ start: colonPos, end: node.type.getEnd() });
|
|
189771
189792
|
}
|
|
189772
189793
|
}
|
|
189773
|
-
if (
|
|
189794
|
+
if (import_typescript8.default.isArrowFunction(node) && node.type) {
|
|
189774
189795
|
const colonPos = findColonBefore(node.type, fullText, node.parameters.end);
|
|
189775
189796
|
if (colonPos >= 0) {
|
|
189776
189797
|
ranges.push({ start: colonPos, end: node.type.getEnd() });
|
|
189777
189798
|
}
|
|
189778
189799
|
}
|
|
189779
|
-
if ((
|
|
189800
|
+
if ((import_typescript8.default.isFunctionDeclaration(node) || import_typescript8.default.isFunctionExpression(node)) && node.type) {
|
|
189780
189801
|
const colonPos = findColonBefore(node.type, fullText, node.parameters.end);
|
|
189781
189802
|
if (colonPos >= 0) {
|
|
189782
189803
|
ranges.push({ start: colonPos, end: node.type.getEnd() });
|
|
189783
189804
|
}
|
|
189784
189805
|
}
|
|
189785
|
-
if (
|
|
189806
|
+
if (import_typescript8.default.isAsExpression(node)) {
|
|
189786
189807
|
const exprEnd = node.expression.getEnd();
|
|
189787
189808
|
ranges.push({ start: exprEnd, end: node.getEnd() });
|
|
189788
189809
|
collectTypeRanges(node.expression, sourceFile, fullText, ranges);
|
|
189789
189810
|
return;
|
|
189790
189811
|
}
|
|
189791
|
-
if (
|
|
189812
|
+
if (import_typescript8.default.isSatisfiesExpression(node)) {
|
|
189792
189813
|
const exprEnd = node.expression.getEnd();
|
|
189793
189814
|
ranges.push({ start: exprEnd, end: node.getEnd() });
|
|
189794
189815
|
collectTypeRanges(node.expression, sourceFile, fullText, ranges);
|
|
189795
189816
|
return;
|
|
189796
189817
|
}
|
|
189797
|
-
if (
|
|
189818
|
+
if (import_typescript8.default.isNonNullExpression(node)) {
|
|
189798
189819
|
const exprEnd = node.expression.getEnd();
|
|
189799
189820
|
ranges.push({ start: exprEnd, end: node.getEnd() });
|
|
189800
189821
|
collectTypeRanges(node.expression, sourceFile, fullText, ranges);
|
|
189801
189822
|
return;
|
|
189802
189823
|
}
|
|
189803
|
-
if (
|
|
189824
|
+
if (import_typescript8.default.isTypeAssertionExpression(node)) {
|
|
189804
189825
|
const exprStart = node.expression.getStart(sourceFile);
|
|
189805
189826
|
ranges.push({ start: node.getStart(sourceFile), end: exprStart });
|
|
189806
189827
|
collectTypeRanges(node.expression, sourceFile, fullText, ranges);
|
|
189807
189828
|
return;
|
|
189808
189829
|
}
|
|
189809
|
-
if (
|
|
189830
|
+
if (import_typescript8.default.isCallExpression(node) && node.typeArguments) {
|
|
189810
189831
|
const typeArgsStart = findAngleBracketBefore(node.typeArguments[0], fullText, node.expression.getEnd());
|
|
189811
189832
|
const typeArgsEnd = findAngleBracketAfter(node.typeArguments[node.typeArguments.length - 1], fullText);
|
|
189812
189833
|
if (typeArgsStart >= 0 && typeArgsEnd >= 0) {
|
|
189813
189834
|
ranges.push({ start: typeArgsStart, end: typeArgsEnd });
|
|
189814
189835
|
}
|
|
189815
189836
|
}
|
|
189816
|
-
if (
|
|
189837
|
+
if (import_typescript8.default.isNewExpression(node) && node.typeArguments) {
|
|
189817
189838
|
const typeArgsStart = findAngleBracketBefore(node.typeArguments[0], fullText, node.expression.getEnd());
|
|
189818
189839
|
const typeArgsEnd = findAngleBracketAfter(node.typeArguments[node.typeArguments.length - 1], fullText);
|
|
189819
189840
|
if (typeArgsStart >= 0 && typeArgsEnd >= 0) {
|
|
189820
189841
|
ranges.push({ start: typeArgsStart, end: typeArgsEnd });
|
|
189821
189842
|
}
|
|
189822
189843
|
}
|
|
189823
|
-
if (
|
|
189844
|
+
if (import_typescript8.default.isTypeAliasDeclaration(node) || import_typescript8.default.isInterfaceDeclaration(node)) {
|
|
189824
189845
|
ranges.push({
|
|
189825
189846
|
start: expandToLineStart(node.getStart(sourceFile), fullText),
|
|
189826
189847
|
end: expandThroughLineEnd(node.getEnd(), fullText)
|
|
189827
189848
|
});
|
|
189828
189849
|
return;
|
|
189829
189850
|
}
|
|
189830
|
-
if (
|
|
189851
|
+
if (import_typescript8.default.isTypeNode(node))
|
|
189831
189852
|
return;
|
|
189832
|
-
|
|
189853
|
+
import_typescript8.default.forEachChild(node, (child) => {
|
|
189833
189854
|
collectTypeRanges(child, sourceFile, fullText, ranges);
|
|
189834
189855
|
});
|
|
189835
189856
|
}
|
|
@@ -189941,9 +189962,9 @@ function createAnalyzerContext(sourceFile, filePath, acceptsCallbackBody) {
|
|
|
189941
189962
|
};
|
|
189942
189963
|
}
|
|
189943
189964
|
function nodeContainsJsx(node) {
|
|
189944
|
-
if (
|
|
189965
|
+
if (import_typescript9.default.isJsxElement(node) || import_typescript9.default.isJsxSelfClosingElement(node) || import_typescript9.default.isJsxFragment(node))
|
|
189945
189966
|
return true;
|
|
189946
|
-
return
|
|
189967
|
+
return import_typescript9.default.forEachChild(node, nodeContainsJsx) ?? false;
|
|
189947
189968
|
}
|
|
189948
189969
|
function getSourceLocation(node, sourceFile, filePath) {
|
|
189949
189970
|
const start = sourceFile.getLineAndCharacterOfPosition(node.getStart());
|
|
@@ -189961,20 +189982,20 @@ function getSourceLocation(node, sourceFile, filePath) {
|
|
|
189961
189982
|
};
|
|
189962
189983
|
}
|
|
189963
189984
|
function membersToProperties(members, sourceFile) {
|
|
189964
|
-
return members.filter(
|
|
189985
|
+
return members.filter(import_typescript9.default.isPropertySignature).map((member) => ({
|
|
189965
189986
|
name: propertyNameText(member.name, sourceFile),
|
|
189966
189987
|
type: typeNodeToTypeInfo(member.type, sourceFile) ?? {
|
|
189967
189988
|
kind: "unknown",
|
|
189968
189989
|
raw: "unknown"
|
|
189969
189990
|
},
|
|
189970
189991
|
optional: !!member.questionToken,
|
|
189971
|
-
readonly: !!member.modifiers?.some((m) => m.kind ===
|
|
189992
|
+
readonly: !!member.modifiers?.some((m) => m.kind === import_typescript9.default.SyntaxKind.ReadonlyKeyword)
|
|
189972
189993
|
}));
|
|
189973
189994
|
}
|
|
189974
189995
|
function propertyNameText(name, sourceFile) {
|
|
189975
189996
|
if (!name)
|
|
189976
189997
|
return "";
|
|
189977
|
-
if (
|
|
189998
|
+
if (import_typescript9.default.isStringLiteral(name) || import_typescript9.default.isNumericLiteral(name))
|
|
189978
189999
|
return name.text;
|
|
189979
190000
|
return name.getText(sourceFile);
|
|
189980
190001
|
}
|
|
@@ -189985,56 +190006,56 @@ function typeNodeToTypeInfo(typeNode, sourceFile, rawOf) {
|
|
|
189985
190006
|
const raw = rawOf ? rawOf(typeNode) : typeNode.getText(sourceFile);
|
|
189986
190007
|
const recurse = (n) => typeNodeToTypeInfo(n, sourceFile, rawOf) ?? { kind: "unknown", raw: "unknown" };
|
|
189987
190008
|
switch (typeNode.kind) {
|
|
189988
|
-
case
|
|
190009
|
+
case import_typescript9.default.SyntaxKind.StringKeyword:
|
|
189989
190010
|
return { kind: "primitive", raw, primitive: "string" };
|
|
189990
|
-
case
|
|
190011
|
+
case import_typescript9.default.SyntaxKind.NumberKeyword:
|
|
189991
190012
|
return { kind: "primitive", raw, primitive: "number" };
|
|
189992
|
-
case
|
|
190013
|
+
case import_typescript9.default.SyntaxKind.BooleanKeyword:
|
|
189993
190014
|
return { kind: "primitive", raw, primitive: "boolean" };
|
|
189994
|
-
case
|
|
190015
|
+
case import_typescript9.default.SyntaxKind.NullKeyword:
|
|
189995
190016
|
return { kind: "primitive", raw, primitive: "null" };
|
|
189996
|
-
case
|
|
190017
|
+
case import_typescript9.default.SyntaxKind.UndefinedKeyword:
|
|
189997
190018
|
return { kind: "primitive", raw, primitive: "undefined" };
|
|
189998
190019
|
}
|
|
189999
|
-
if (
|
|
190020
|
+
if (import_typescript9.default.isArrayTypeNode(typeNode)) {
|
|
190000
190021
|
return { kind: "array", raw, elementType: recurse(typeNode.elementType) };
|
|
190001
190022
|
}
|
|
190002
|
-
if (
|
|
190023
|
+
if (import_typescript9.default.isLiteralTypeNode(typeNode)) {
|
|
190003
190024
|
const lit = typeNode.literal;
|
|
190004
|
-
if (
|
|
190025
|
+
if (import_typescript9.default.isStringLiteral(lit) || import_typescript9.default.isNoSubstitutionTemplateLiteral(lit)) {
|
|
190005
190026
|
return { kind: "primitive", raw, primitive: "string", literalValue: lit.text };
|
|
190006
190027
|
}
|
|
190007
|
-
if (
|
|
190028
|
+
if (import_typescript9.default.isNumericLiteral(lit)) {
|
|
190008
190029
|
return { kind: "primitive", raw, primitive: "number", literalValue: lit.text };
|
|
190009
190030
|
}
|
|
190010
|
-
if (
|
|
190031
|
+
if (import_typescript9.default.isPrefixUnaryExpression(lit) && lit.operator === import_typescript9.default.SyntaxKind.MinusToken && import_typescript9.default.isNumericLiteral(lit.operand)) {
|
|
190011
190032
|
return { kind: "primitive", raw, primitive: "number", literalValue: `-${lit.operand.text}` };
|
|
190012
190033
|
}
|
|
190013
|
-
if (lit.kind ===
|
|
190034
|
+
if (lit.kind === import_typescript9.default.SyntaxKind.TrueKeyword || lit.kind === import_typescript9.default.SyntaxKind.FalseKeyword) {
|
|
190014
190035
|
return {
|
|
190015
190036
|
kind: "primitive",
|
|
190016
190037
|
raw,
|
|
190017
190038
|
primitive: "boolean",
|
|
190018
|
-
literalValue: lit.kind ===
|
|
190039
|
+
literalValue: lit.kind === import_typescript9.default.SyntaxKind.TrueKeyword ? "true" : "false"
|
|
190019
190040
|
};
|
|
190020
190041
|
}
|
|
190021
|
-
if (lit.kind ===
|
|
190042
|
+
if (lit.kind === import_typescript9.default.SyntaxKind.NullKeyword) {
|
|
190022
190043
|
return { kind: "primitive", raw, primitive: "null" };
|
|
190023
190044
|
}
|
|
190024
190045
|
return { kind: "unknown", raw };
|
|
190025
190046
|
}
|
|
190026
|
-
if (
|
|
190047
|
+
if (import_typescript9.default.isUnionTypeNode(typeNode)) {
|
|
190027
190048
|
return { kind: "union", raw, unionTypes: typeNode.types.map(recurse) };
|
|
190028
190049
|
}
|
|
190029
|
-
if (
|
|
190050
|
+
if (import_typescript9.default.isTypeLiteralNode(typeNode)) {
|
|
190030
190051
|
return {
|
|
190031
190052
|
kind: "object",
|
|
190032
190053
|
raw,
|
|
190033
190054
|
...synthetic ? {} : { properties: membersToProperties(typeNode.members, sourceFile) }
|
|
190034
190055
|
};
|
|
190035
190056
|
}
|
|
190036
|
-
if (
|
|
190037
|
-
const refName =
|
|
190057
|
+
if (import_typescript9.default.isTypeReferenceNode(typeNode)) {
|
|
190058
|
+
const refName = import_typescript9.default.isIdentifier(typeNode.typeName) ? typeNode.typeName.text : "";
|
|
190038
190059
|
if ((refName === "Array" || refName === "ReadonlyArray") && typeNode.typeArguments?.length === 1) {
|
|
190039
190060
|
return { kind: "array", raw, elementType: recurse(typeNode.typeArguments[0]) };
|
|
190040
190061
|
}
|
|
@@ -190043,7 +190064,7 @@ function typeNodeToTypeInfo(typeNode, sourceFile, rawOf) {
|
|
|
190043
190064
|
raw
|
|
190044
190065
|
};
|
|
190045
190066
|
}
|
|
190046
|
-
if (
|
|
190067
|
+
if (import_typescript9.default.isFunctionTypeNode(typeNode)) {
|
|
190047
190068
|
if (synthetic)
|
|
190048
190069
|
return { kind: "function", raw };
|
|
190049
190070
|
return {
|
|
@@ -190063,15 +190084,15 @@ function typeNodeToTypeInfo(typeNode, sourceFile, rawOf) {
|
|
|
190063
190084
|
}
|
|
190064
190085
|
return { kind: "unknown", raw };
|
|
190065
190086
|
}
|
|
190066
|
-
var _typePrinter =
|
|
190067
|
-
var _blankTypeSourceFile =
|
|
190087
|
+
var _typePrinter = import_typescript9.default.createPrinter({ removeComments: true, omitTrailingSemicolon: true });
|
|
190088
|
+
var _blankTypeSourceFile = import_typescript9.default.createSourceFile("__bf_types__.ts", "", import_typescript9.default.ScriptTarget.Latest);
|
|
190068
190089
|
function tsTypeToTypeInfo(type2, checker) {
|
|
190069
|
-
const node = checker.typeToTypeNode(type2, undefined,
|
|
190090
|
+
const node = checker.typeToTypeNode(type2, undefined, import_typescript9.default.NodeBuilderFlags.NoTruncation);
|
|
190070
190091
|
if (!node)
|
|
190071
190092
|
return null;
|
|
190072
190093
|
const rawOf = (n) => {
|
|
190073
190094
|
try {
|
|
190074
|
-
return _typePrinter.printNode(
|
|
190095
|
+
return _typePrinter.printNode(import_typescript9.default.EmitHint.Unspecified, n, _blankTypeSourceFile);
|
|
190075
190096
|
} catch {
|
|
190076
190097
|
return "unknown";
|
|
190077
190098
|
}
|
|
@@ -190082,16 +190103,16 @@ function isPascalCase(name) {
|
|
|
190082
190103
|
return /^[A-Z][a-zA-Z0-9]*$/.test(name);
|
|
190083
190104
|
}
|
|
190084
190105
|
function isComponentFunction(node) {
|
|
190085
|
-
return
|
|
190106
|
+
return import_typescript9.default.isFunctionDeclaration(node) && !!node.name && isPascalCase(node.name.text) && !!node.body;
|
|
190086
190107
|
}
|
|
190087
190108
|
function isArrowComponentFunction(node) {
|
|
190088
|
-
if (!
|
|
190109
|
+
if (!import_typescript9.default.isVariableDeclaration(node))
|
|
190089
190110
|
return false;
|
|
190090
|
-
if (!
|
|
190111
|
+
if (!import_typescript9.default.isIdentifier(node.name))
|
|
190091
190112
|
return false;
|
|
190092
190113
|
if (!isPascalCase(node.name.text))
|
|
190093
190114
|
return false;
|
|
190094
|
-
if (!node.initializer || !
|
|
190115
|
+
if (!node.initializer || !import_typescript9.default.isArrowFunction(node.initializer))
|
|
190095
190116
|
return false;
|
|
190096
190117
|
return true;
|
|
190097
190118
|
}
|
|
@@ -190110,6 +190131,7 @@ var ErrorCodes = {
|
|
|
190110
190131
|
MISSING_USE_CLIENT: "BF001",
|
|
190111
190132
|
CLIENT_IMPORTING_SERVER: "BF003",
|
|
190112
190133
|
SIGNAL_OUTSIDE_COMPONENT: "BF011",
|
|
190134
|
+
PRIMITIVE_VIA_NAMESPACE_IMPORT: "BF013",
|
|
190113
190135
|
UNSUPPORTED_JSX_PATTERN: "BF021",
|
|
190114
190136
|
MISSING_KEY_IN_LIST: "BF023",
|
|
190115
190137
|
MISSING_KEY_IN_NESTED_LIST: "BF024",
|
|
@@ -190142,6 +190164,7 @@ var errorMessages = {
|
|
|
190142
190164
|
[ErrorCodes.MISSING_USE_CLIENT]: "'use client' directive required for components with createSignal or event handlers",
|
|
190143
190165
|
[ErrorCodes.CLIENT_IMPORTING_SERVER]: "Client component cannot import server component",
|
|
190144
190166
|
[ErrorCodes.SIGNAL_OUTSIDE_COMPONENT]: "Module-level reactive declaration (createSignal / createMemo) is not allowed. " + "The downstream codegen drops the declaration silently and every reference becomes a ReferenceError at SSR and at hydrate. " + "Move the declaration inside a component function so each mount gets its own state.",
|
|
190167
|
+
[ErrorCodes.PRIMITIVE_VIA_NAMESPACE_IMPORT]: "Reactive primitive called through a namespace import of '@barefootjs/client' (import * as ns) is not recognized; " + "the declaration is dropped and its references throw ReferenceError at hydrate. Import the primitive by name instead.",
|
|
190145
190168
|
[ErrorCodes.UNSUPPORTED_JSX_PATTERN]: "Unsupported JSX pattern",
|
|
190146
190169
|
[ErrorCodes.MISSING_KEY_IN_LIST]: "Missing key attribute in list rendering. Add a key prop for efficient updates",
|
|
190147
190170
|
[ErrorCodes.MISSING_KEY_IN_NESTED_LIST]: "Nested .map() loop requires key attribute for event delegation. Add a key prop to elements in the inner loop",
|
|
@@ -190343,9 +190366,9 @@ function needsTypeBasedDetection(source) {
|
|
|
190343
190366
|
}
|
|
190344
190367
|
function findBrandPackageImportLoc(sourceFile, filePath) {
|
|
190345
190368
|
for (const stmt of sourceFile.statements) {
|
|
190346
|
-
if (!
|
|
190369
|
+
if (!import_typescript10.default.isImportDeclaration(stmt))
|
|
190347
190370
|
continue;
|
|
190348
|
-
if (!
|
|
190371
|
+
if (!import_typescript10.default.isStringLiteral(stmt.moduleSpecifier))
|
|
190349
190372
|
continue;
|
|
190350
190373
|
if (!REACTIVE_BRAND_PACKAGES.includes(stmt.moduleSpecifier.text))
|
|
190351
190374
|
continue;
|
|
@@ -190364,21 +190387,21 @@ function createProgramForFile(source, filePath) {
|
|
|
190364
190387
|
try {
|
|
190365
190388
|
const normalizedPath = path_default.resolve(filePath);
|
|
190366
190389
|
const compilerOptions = {
|
|
190367
|
-
target:
|
|
190368
|
-
module:
|
|
190369
|
-
moduleResolution:
|
|
190370
|
-
jsx:
|
|
190390
|
+
target: import_typescript10.default.ScriptTarget.Latest,
|
|
190391
|
+
module: import_typescript10.default.ModuleKind.ESNext,
|
|
190392
|
+
moduleResolution: import_typescript10.default.ModuleResolutionKind.Bundler,
|
|
190393
|
+
jsx: import_typescript10.default.JsxEmit.ReactJSX,
|
|
190371
190394
|
strict: true,
|
|
190372
190395
|
skipLibCheck: true,
|
|
190373
190396
|
noEmit: true,
|
|
190374
190397
|
baseUrl: path_default.dirname(normalizedPath)
|
|
190375
190398
|
};
|
|
190376
|
-
const defaultHost =
|
|
190399
|
+
const defaultHost = import_typescript10.default.createCompilerHost(compilerOptions);
|
|
190377
190400
|
const virtualHost = {
|
|
190378
190401
|
...defaultHost,
|
|
190379
190402
|
getSourceFile(fileName, languageVersion) {
|
|
190380
190403
|
if (path_default.resolve(fileName) === normalizedPath) {
|
|
190381
|
-
return
|
|
190404
|
+
return import_typescript10.default.createSourceFile(fileName, source, languageVersion, true, import_typescript10.default.ScriptKind.TSX);
|
|
190382
190405
|
}
|
|
190383
190406
|
return defaultHost.getSourceFile(fileName, languageVersion);
|
|
190384
190407
|
},
|
|
@@ -190393,7 +190416,7 @@ function createProgramForFile(source, filePath) {
|
|
|
190393
190416
|
return defaultHost.readFile(fileName);
|
|
190394
190417
|
}
|
|
190395
190418
|
};
|
|
190396
|
-
const program =
|
|
190419
|
+
const program = import_typescript10.default.createProgram([normalizedPath], compilerOptions, virtualHost);
|
|
190397
190420
|
const sourceFile = program.getSourceFile(normalizedPath);
|
|
190398
190421
|
if (!sourceFile)
|
|
190399
190422
|
return null;
|
|
@@ -190426,7 +190449,7 @@ function analyzeComponent(source, filePath, targetComponentName, program, accept
|
|
|
190426
190449
|
}
|
|
190427
190450
|
}
|
|
190428
190451
|
if (!sourceFile) {
|
|
190429
|
-
sourceFile =
|
|
190452
|
+
sourceFile = import_typescript10.default.createSourceFile(filePath, source, import_typescript10.default.ScriptTarget.Latest, true, import_typescript10.default.ScriptKind.TSX);
|
|
190430
190453
|
}
|
|
190431
190454
|
if (!checker && needsTypeBasedDetection(source)) {
|
|
190432
190455
|
const result = createProgramForFile(source, filePath);
|
|
@@ -190472,23 +190495,23 @@ function analyzeComponent(source, filePath, targetComponentName, program, accept
|
|
|
190472
190495
|
function findDefaultExportedComponent(sourceFile) {
|
|
190473
190496
|
let defaultExportName;
|
|
190474
190497
|
function findDefaultExport(node) {
|
|
190475
|
-
if (
|
|
190476
|
-
if (
|
|
190498
|
+
if (import_typescript10.default.isExportAssignment(node) && !node.isExportEquals) {
|
|
190499
|
+
if (import_typescript10.default.isIdentifier(node.expression)) {
|
|
190477
190500
|
defaultExportName = node.expression.text;
|
|
190478
190501
|
}
|
|
190479
190502
|
}
|
|
190480
|
-
if (
|
|
190503
|
+
if (import_typescript10.default.isFunctionDeclaration(node) && node.name && node.modifiers?.some((m) => m.kind === import_typescript10.default.SyntaxKind.DefaultKeyword)) {
|
|
190481
190504
|
defaultExportName = node.name.text;
|
|
190482
190505
|
}
|
|
190483
|
-
|
|
190506
|
+
import_typescript10.default.forEachChild(node, findDefaultExport);
|
|
190484
190507
|
}
|
|
190485
|
-
|
|
190508
|
+
import_typescript10.default.forEachChild(sourceFile, findDefaultExport);
|
|
190486
190509
|
return defaultExportName;
|
|
190487
190510
|
}
|
|
190488
190511
|
function collectNamedExports(sourceFile) {
|
|
190489
190512
|
const exported = new Set;
|
|
190490
190513
|
for (const stmt of sourceFile.statements) {
|
|
190491
|
-
if (
|
|
190514
|
+
if (import_typescript10.default.isExportDeclaration(stmt) && stmt.exportClause && import_typescript10.default.isNamedExports(stmt.exportClause)) {
|
|
190492
190515
|
for (const spec of stmt.exportClause.elements) {
|
|
190493
190516
|
const local = (spec.propertyName ?? spec.name).text;
|
|
190494
190517
|
exported.add(local);
|
|
@@ -190498,22 +190521,22 @@ function collectNamedExports(sourceFile) {
|
|
|
190498
190521
|
return exported;
|
|
190499
190522
|
}
|
|
190500
190523
|
function visit(node, ctx, targetComponentName, namedExports) {
|
|
190501
|
-
if (
|
|
190524
|
+
if (import_typescript10.default.isExpressionStatement(node) && import_typescript10.default.isStringLiteral(node.expression)) {
|
|
190502
190525
|
if (node.expression.text === "use client" || node.expression.text === "'use client'") {
|
|
190503
190526
|
ctx.hasUseClientDirective = true;
|
|
190504
190527
|
}
|
|
190505
190528
|
}
|
|
190506
|
-
if (
|
|
190529
|
+
if (import_typescript10.default.isImportDeclaration(node)) {
|
|
190507
190530
|
collectImport(node, ctx);
|
|
190508
190531
|
}
|
|
190509
|
-
if (
|
|
190532
|
+
if (import_typescript10.default.isInterfaceDeclaration(node)) {
|
|
190510
190533
|
collectInterfaceDefinition(node, ctx);
|
|
190511
190534
|
}
|
|
190512
|
-
if (
|
|
190535
|
+
if (import_typescript10.default.isTypeAliasDeclaration(node)) {
|
|
190513
190536
|
collectTypeAliasDefinition(node, ctx);
|
|
190514
190537
|
}
|
|
190515
|
-
if (!ctx.hasUseClientDirective &&
|
|
190516
|
-
const hasInlineExport = node.modifiers?.some((m) => m.kind ===
|
|
190538
|
+
if (!ctx.hasUseClientDirective && import_typescript10.default.isFunctionDeclaration(node) && node.name && node.body && isMultiReturnJsxFunctionBody(node.body)) {
|
|
190539
|
+
const hasInlineExport = node.modifiers?.some((m) => m.kind === import_typescript10.default.SyntaxKind.ExportKeyword) ?? false;
|
|
190517
190540
|
const hasNamedExport = namedExports?.has(node.name.text) ?? false;
|
|
190518
190541
|
if (!hasInlineExport && !hasNamedExport) {
|
|
190519
190542
|
collectFunction(node, ctx, true, false);
|
|
@@ -190528,9 +190551,9 @@ function visit(node, ctx, targetComponentName, namedExports) {
|
|
|
190528
190551
|
if (!ctx.componentName) {
|
|
190529
190552
|
ctx.componentName = node.name.text;
|
|
190530
190553
|
ctx.componentNode = node;
|
|
190531
|
-
ctx.isExported = node.modifiers?.some((m) => m.kind ===
|
|
190554
|
+
ctx.isExported = node.modifiers?.some((m) => m.kind === import_typescript10.default.SyntaxKind.ExportKeyword) ?? false;
|
|
190532
190555
|
analyzeComponentBody(node, ctx);
|
|
190533
|
-
if (node.modifiers?.some((m) => m.kind ===
|
|
190556
|
+
if (node.modifiers?.some((m) => m.kind === import_typescript10.default.SyntaxKind.DefaultKeyword)) {
|
|
190534
190557
|
ctx.hasDefaultExport = true;
|
|
190535
190558
|
}
|
|
190536
190559
|
}
|
|
@@ -190544,10 +190567,10 @@ function visit(node, ctx, targetComponentName, namedExports) {
|
|
|
190544
190567
|
ctx.componentName = node.name.text;
|
|
190545
190568
|
ctx.componentNode = node.initializer;
|
|
190546
190569
|
const parentStatement = node.parent;
|
|
190547
|
-
if (
|
|
190570
|
+
if (import_typescript10.default.isVariableDeclarationList(parentStatement)) {
|
|
190548
190571
|
const varStatement = parentStatement.parent;
|
|
190549
|
-
if (
|
|
190550
|
-
ctx.isExported = varStatement.modifiers?.some((m) => m.kind ===
|
|
190572
|
+
if (import_typescript10.default.isVariableStatement(varStatement)) {
|
|
190573
|
+
ctx.isExported = varStatement.modifiers?.some((m) => m.kind === import_typescript10.default.SyntaxKind.ExportKeyword) ?? false;
|
|
190551
190574
|
}
|
|
190552
190575
|
}
|
|
190553
190576
|
analyzeComponentBody(node.initializer, ctx);
|
|
@@ -190559,10 +190582,10 @@ function visit(node, ctx, targetComponentName, namedExports) {
|
|
|
190559
190582
|
if (!ctx.componentNode) {
|
|
190560
190583
|
collectAmbientGlobals(node, ctx);
|
|
190561
190584
|
}
|
|
190562
|
-
const isDeclareStatement =
|
|
190563
|
-
if (
|
|
190564
|
-
const isExported = node.modifiers?.some((m) => m.kind ===
|
|
190565
|
-
const isLet = (node.declarationList.flags &
|
|
190585
|
+
const isDeclareStatement = import_typescript10.default.isVariableStatement(node) && (node.modifiers?.some((m) => m.kind === import_typescript10.default.SyntaxKind.DeclareKeyword) ?? false);
|
|
190586
|
+
if (import_typescript10.default.isVariableStatement(node) && !ctx.componentNode && !isDeclareStatement) {
|
|
190587
|
+
const isExported = node.modifiers?.some((m) => m.kind === import_typescript10.default.SyntaxKind.ExportKeyword) ?? false;
|
|
190588
|
+
const isLet = (node.declarationList.flags & import_typescript10.default.NodeFlags.Let) !== 0;
|
|
190566
190589
|
const isModuleClientDirective = hasLeadingClientDirectiveOnStatement(node, ctx.sourceFile);
|
|
190567
190590
|
for (const decl of node.declarationList.declarations) {
|
|
190568
190591
|
if (declarationIsReactiveFactoryCall(decl, ctx)) {
|
|
@@ -190573,19 +190596,19 @@ function visit(node, ctx, targetComponentName, namedExports) {
|
|
|
190573
190596
|
}
|
|
190574
190597
|
continue;
|
|
190575
190598
|
}
|
|
190576
|
-
if (
|
|
190599
|
+
if (import_typescript10.default.isIdentifier(decl.name) && (decl.initializer || isLet) && !isArrowComponentFunction(decl)) {
|
|
190577
190600
|
collectConstant(decl, ctx, true, isLet ? "let" : "const", isExported);
|
|
190578
190601
|
}
|
|
190579
190602
|
}
|
|
190580
190603
|
}
|
|
190581
|
-
if (
|
|
190582
|
-
const isExported = node.modifiers?.some((m) => m.kind ===
|
|
190604
|
+
if (import_typescript10.default.isFunctionDeclaration(node) && node.name && !isComponentFunction(node)) {
|
|
190605
|
+
const isExported = node.modifiers?.some((m) => m.kind === import_typescript10.default.SyntaxKind.ExportKeyword) ?? false;
|
|
190583
190606
|
collectFunction(node, ctx, true, isExported);
|
|
190584
190607
|
return;
|
|
190585
190608
|
}
|
|
190586
|
-
if (
|
|
190609
|
+
if (import_typescript10.default.isExportDeclaration(node) && node.exportClause && import_typescript10.default.isNamedExports(node.exportClause)) {
|
|
190587
190610
|
const isFromReexport = !!node.moduleSpecifier;
|
|
190588
|
-
const sourceSpec = node.moduleSpecifier &&
|
|
190611
|
+
const sourceSpec = node.moduleSpecifier && import_typescript10.default.isStringLiteral(node.moduleSpecifier) ? node.moduleSpecifier.text : null;
|
|
190589
190612
|
const exportSpecifiers = node.exportClause.elements.map((spec) => ({
|
|
190590
190613
|
name: (spec.propertyName ?? spec.name).text,
|
|
190591
190614
|
alias: spec.propertyName ? spec.name.text : null,
|
|
@@ -190613,24 +190636,24 @@ function visit(node, ctx, targetComponentName, namedExports) {
|
|
|
190613
190636
|
}
|
|
190614
190637
|
}
|
|
190615
190638
|
}
|
|
190616
|
-
if (
|
|
190639
|
+
if (import_typescript10.default.isExportAssignment(node) && !node.isExportEquals) {
|
|
190617
190640
|
const expr = node.expression;
|
|
190618
|
-
if (
|
|
190641
|
+
if (import_typescript10.default.isIdentifier(expr)) {
|
|
190619
190642
|
if (ctx.componentName && expr.text === ctx.componentName) {
|
|
190620
190643
|
ctx.hasDefaultExport = true;
|
|
190621
190644
|
ctx.isExported = true;
|
|
190622
190645
|
}
|
|
190623
190646
|
}
|
|
190624
190647
|
}
|
|
190625
|
-
|
|
190648
|
+
import_typescript10.default.forEachChild(node, (child) => visit(child, ctx, targetComponentName, namedExports));
|
|
190626
190649
|
}
|
|
190627
190650
|
function analyzeComponentBody(node, ctx) {
|
|
190628
190651
|
if (node.parameters.length > 0) {
|
|
190629
190652
|
extractProps(node.parameters[0], ctx);
|
|
190630
190653
|
}
|
|
190631
|
-
const body =
|
|
190654
|
+
const body = import_typescript10.default.isFunctionDeclaration(node) ? node.body : getArrowFunctionBody(node);
|
|
190632
190655
|
if (body) {
|
|
190633
|
-
ctx.componentBodyBlock =
|
|
190656
|
+
ctx.componentBodyBlock = import_typescript10.default.isBlock(body) ? body : null;
|
|
190634
190657
|
if (!ctx.componentBodyBlock) {
|
|
190635
190658
|
ctx.jsxReturn = unwrapJsxTransparent(body);
|
|
190636
190659
|
}
|
|
@@ -190640,14 +190663,14 @@ function analyzeComponentBody(node, ctx) {
|
|
|
190640
190663
|
}
|
|
190641
190664
|
}
|
|
190642
190665
|
function getArrowFunctionBody(node) {
|
|
190643
|
-
if (
|
|
190666
|
+
if (import_typescript10.default.isBlock(node.body)) {
|
|
190644
190667
|
return node.body;
|
|
190645
190668
|
}
|
|
190646
190669
|
return node.body;
|
|
190647
190670
|
}
|
|
190648
190671
|
function visitComponentBody(node, ctx) {
|
|
190649
190672
|
const isTopLevel = ctx.componentBodyBlock !== null && node.parent === ctx.componentBodyBlock;
|
|
190650
|
-
if (
|
|
190673
|
+
if (import_typescript10.default.isVariableStatement(node)) {
|
|
190651
190674
|
for (const decl of node.declarationList.declarations) {
|
|
190652
190675
|
if (isSignalDeclaration(decl, ctx)) {
|
|
190653
190676
|
collectSignal(decl, ctx);
|
|
@@ -190670,16 +190693,16 @@ function visitComponentBody(node, ctx) {
|
|
|
190670
190693
|
collectEffect(decl.initializer, ctx, decl.name.text);
|
|
190671
190694
|
continue;
|
|
190672
190695
|
}
|
|
190673
|
-
if (
|
|
190674
|
-
const isLet = (node.declarationList.flags &
|
|
190696
|
+
if (import_typescript10.default.isIdentifier(decl.name)) {
|
|
190697
|
+
const isLet = (node.declarationList.flags & import_typescript10.default.NodeFlags.Let) !== 0;
|
|
190675
190698
|
collectConstant(decl, ctx, false, isLet ? "let" : "const");
|
|
190676
|
-
} else if (
|
|
190677
|
-
const isLet = (node.declarationList.flags &
|
|
190699
|
+
} else if (import_typescript10.default.isObjectBindingPattern(decl.name) && decl.initializer && import_typescript10.default.isIdentifier(decl.initializer) && ctx.propsObjectName === decl.initializer.text) {
|
|
190700
|
+
const isLet = (node.declarationList.flags & import_typescript10.default.NodeFlags.Let) !== 0;
|
|
190678
190701
|
collectConstant(decl, ctx, false, isLet ? "let" : "const");
|
|
190679
190702
|
}
|
|
190680
190703
|
}
|
|
190681
190704
|
}
|
|
190682
|
-
if (
|
|
190705
|
+
if (import_typescript10.default.isExpressionStatement(node)) {
|
|
190683
190706
|
if (isEffectCall(node.expression, ctx)) {
|
|
190684
190707
|
collectEffect(node.expression, ctx);
|
|
190685
190708
|
return;
|
|
@@ -190693,10 +190716,10 @@ function visitComponentBody(node, ctx) {
|
|
|
190693
190716
|
return;
|
|
190694
190717
|
}
|
|
190695
190718
|
}
|
|
190696
|
-
if (
|
|
190719
|
+
if (import_typescript10.default.isFunctionDeclaration(node) && node.name) {
|
|
190697
190720
|
collectFunction(node, ctx, false);
|
|
190698
190721
|
}
|
|
190699
|
-
if (
|
|
190722
|
+
if (import_typescript10.default.isIfStatement(node)) {
|
|
190700
190723
|
const jsxReturn = findJsxReturnInBlock(node.thenStatement);
|
|
190701
190724
|
if (jsxReturn) {
|
|
190702
190725
|
const scopeVars = collectScopeVariables(node.thenStatement, ctx);
|
|
@@ -190715,8 +190738,8 @@ function visitComponentBody(node, ctx) {
|
|
|
190715
190738
|
return;
|
|
190716
190739
|
}
|
|
190717
190740
|
}
|
|
190718
|
-
if (isTopLevel && (
|
|
190719
|
-
if (
|
|
190741
|
+
if (isTopLevel && (import_typescript10.default.isTryStatement(node) || import_typescript10.default.isSwitchStatement(node) || import_typescript10.default.isForStatement(node) || import_typescript10.default.isForInStatement(node) || import_typescript10.default.isForOfStatement(node) || import_typescript10.default.isWhileStatement(node) || import_typescript10.default.isDoStatement(node) || import_typescript10.default.isThrowStatement(node) || import_typescript10.default.isBlock(node) && node.parent === ctx.componentBodyBlock)) {
|
|
190742
|
+
if (import_typescript10.default.isBlock(node)) {
|
|
190720
190743
|
const returnedLocal = findBlockBodyReturnedJsxLocalName(node);
|
|
190721
190744
|
if (returnedLocal) {
|
|
190722
190745
|
ctx.errors.push(createError(ErrorCodes.RETURN_VALUE_NOT_JSX, getSourceLocation(node, ctx.sourceFile, ctx.filePath), {
|
|
@@ -190727,34 +190750,34 @@ function visitComponentBody(node, ctx) {
|
|
|
190727
190750
|
collectInitStatement(node, ctx);
|
|
190728
190751
|
return;
|
|
190729
190752
|
}
|
|
190730
|
-
if (
|
|
190753
|
+
if (import_typescript10.default.isReturnStatement(node) && node.expression) {
|
|
190731
190754
|
ctx.jsxReturn = unwrapJsxTransparent(node.expression);
|
|
190732
190755
|
}
|
|
190733
|
-
|
|
190734
|
-
if (
|
|
190756
|
+
import_typescript10.default.forEachChild(node, (child) => {
|
|
190757
|
+
if (import_typescript10.default.isArrowFunction(child) || import_typescript10.default.isFunctionExpression(child) || import_typescript10.default.isFunctionDeclaration(child)) {
|
|
190735
190758
|
return;
|
|
190736
190759
|
}
|
|
190737
190760
|
visitComponentBody(child, ctx);
|
|
190738
190761
|
});
|
|
190739
190762
|
}
|
|
190740
190763
|
function findJsxReturnInBlock(node) {
|
|
190741
|
-
if (
|
|
190764
|
+
if (import_typescript10.default.isBlock(node)) {
|
|
190742
190765
|
for (const stmt of node.statements) {
|
|
190743
|
-
if (
|
|
190766
|
+
if (import_typescript10.default.isReturnStatement(stmt) && stmt.expression) {
|
|
190744
190767
|
const jsx = extractJsxFromExpression(stmt.expression);
|
|
190745
190768
|
if (jsx)
|
|
190746
190769
|
return jsx;
|
|
190747
190770
|
}
|
|
190748
190771
|
}
|
|
190749
190772
|
}
|
|
190750
|
-
if (
|
|
190773
|
+
if (import_typescript10.default.isReturnStatement(node) && node.expression) {
|
|
190751
190774
|
return extractJsxFromExpression(node.expression);
|
|
190752
190775
|
}
|
|
190753
190776
|
return null;
|
|
190754
190777
|
}
|
|
190755
190778
|
function unwrapJsxTransparent(expr) {
|
|
190756
190779
|
let current = expr;
|
|
190757
|
-
while (
|
|
190780
|
+
while (import_typescript10.default.isParenthesizedExpression(current) || import_typescript10.default.isAsExpression(current) || import_typescript10.default.isSatisfiesExpression(current) || import_typescript10.default.isNonNullExpression(current) || import_typescript10.default.isTypeAssertionExpression(current) || current.kind === import_typescript10.default.SyntaxKind.PartiallyEmittedExpression) {
|
|
190758
190781
|
current = current.expression;
|
|
190759
190782
|
}
|
|
190760
190783
|
return current;
|
|
@@ -190762,22 +190785,22 @@ function unwrapJsxTransparent(expr) {
|
|
|
190762
190785
|
function findBlockBodyReturnedJsxLocalName(block) {
|
|
190763
190786
|
const stmts = block.statements;
|
|
190764
190787
|
const last = stmts[stmts.length - 1];
|
|
190765
|
-
if (!last || !
|
|
190788
|
+
if (!last || !import_typescript10.default.isReturnStatement(last) || !last.expression)
|
|
190766
190789
|
return null;
|
|
190767
190790
|
const returned = unwrapJsxTransparent(last.expression);
|
|
190768
|
-
if (!
|
|
190791
|
+
if (!import_typescript10.default.isIdentifier(returned))
|
|
190769
190792
|
return null;
|
|
190770
190793
|
const name = returned.text;
|
|
190771
190794
|
for (const stmt of stmts) {
|
|
190772
|
-
if (!
|
|
190795
|
+
if (!import_typescript10.default.isVariableStatement(stmt))
|
|
190773
190796
|
continue;
|
|
190774
190797
|
for (const decl of stmt.declarationList.declarations) {
|
|
190775
|
-
if (!
|
|
190798
|
+
if (!import_typescript10.default.isIdentifier(decl.name) || decl.name.text !== name || !decl.initializer)
|
|
190776
190799
|
continue;
|
|
190777
190800
|
let init = decl.initializer;
|
|
190778
|
-
while (
|
|
190801
|
+
while (import_typescript10.default.isParenthesizedExpression(init))
|
|
190779
190802
|
init = init.expression;
|
|
190780
|
-
if (
|
|
190803
|
+
if (import_typescript10.default.isJsxElement(init) || import_typescript10.default.isJsxSelfClosingElement(init) || import_typescript10.default.isJsxFragment(init) || initializerShapeContainsJsx(init) || isMapLikeCallWithJsx(init)) {
|
|
190781
190804
|
return name;
|
|
190782
190805
|
}
|
|
190783
190806
|
}
|
|
@@ -190786,16 +190809,16 @@ function findBlockBodyReturnedJsxLocalName(block) {
|
|
|
190786
190809
|
}
|
|
190787
190810
|
function extractJsxFromExpression(expr) {
|
|
190788
190811
|
const inner = unwrapJsxTransparent(expr);
|
|
190789
|
-
if (
|
|
190812
|
+
if (import_typescript10.default.isJsxElement(inner) || import_typescript10.default.isJsxFragment(inner) || import_typescript10.default.isJsxSelfClosingElement(inner)) {
|
|
190790
190813
|
return inner;
|
|
190791
190814
|
}
|
|
190792
190815
|
return null;
|
|
190793
190816
|
}
|
|
190794
190817
|
function collectScopeVariables(node, ctx) {
|
|
190795
190818
|
const variables = [];
|
|
190796
|
-
if (
|
|
190819
|
+
if (import_typescript10.default.isBlock(node)) {
|
|
190797
190820
|
for (const stmt of node.statements) {
|
|
190798
|
-
if (
|
|
190821
|
+
if (import_typescript10.default.isVariableStatement(stmt)) {
|
|
190799
190822
|
for (const decl of stmt.declarationList.declarations) {
|
|
190800
190823
|
variables.push(decl);
|
|
190801
190824
|
}
|
|
@@ -190807,13 +190830,13 @@ function collectScopeVariables(node, ctx) {
|
|
|
190807
190830
|
function collectParamBindingNames(params) {
|
|
190808
190831
|
const out = new Set;
|
|
190809
190832
|
const addBindingNames = (name) => {
|
|
190810
|
-
if (
|
|
190833
|
+
if (import_typescript10.default.isIdentifier(name)) {
|
|
190811
190834
|
out.add(name.text);
|
|
190812
|
-
} else if (
|
|
190835
|
+
} else if (import_typescript10.default.isObjectBindingPattern(name)) {
|
|
190813
190836
|
name.elements.forEach((e) => addBindingNames(e.name));
|
|
190814
|
-
} else if (
|
|
190837
|
+
} else if (import_typescript10.default.isArrayBindingPattern(name)) {
|
|
190815
190838
|
name.elements.forEach((e) => {
|
|
190816
|
-
if (!
|
|
190839
|
+
if (!import_typescript10.default.isOmittedExpression(e))
|
|
190817
190840
|
addBindingNames(e.name);
|
|
190818
190841
|
});
|
|
190819
190842
|
}
|
|
@@ -190830,7 +190853,7 @@ function collectEnclosingBranchVars(node, ctx) {
|
|
|
190830
190853
|
if (cr.ifStatement.thenStatement !== current)
|
|
190831
190854
|
continue;
|
|
190832
190855
|
for (const decl of cr.scopeVariables) {
|
|
190833
|
-
if (!
|
|
190856
|
+
if (!import_typescript10.default.isIdentifier(decl.name) || !decl.initializer)
|
|
190834
190857
|
continue;
|
|
190835
190858
|
const varName = decl.name.text;
|
|
190836
190859
|
if (result.has(varName))
|
|
@@ -190845,10 +190868,10 @@ function collectEnclosingBranchVars(node, ctx) {
|
|
|
190845
190868
|
return result;
|
|
190846
190869
|
}
|
|
190847
190870
|
function collectBranchSignals(thenStatement, ctx, branchCondition) {
|
|
190848
|
-
if (!
|
|
190871
|
+
if (!import_typescript10.default.isBlock(thenStatement))
|
|
190849
190872
|
return;
|
|
190850
190873
|
for (const stmt of thenStatement.statements) {
|
|
190851
|
-
if (!
|
|
190874
|
+
if (!import_typescript10.default.isVariableStatement(stmt))
|
|
190852
190875
|
continue;
|
|
190853
190876
|
for (const decl of stmt.declarationList.declarations) {
|
|
190854
190877
|
if (!isSignalDeclaration(decl, ctx))
|
|
@@ -190874,13 +190897,13 @@ var ENV_SIGNAL_FACTORIES = {
|
|
|
190874
190897
|
createSearchParams: "search"
|
|
190875
190898
|
};
|
|
190876
190899
|
function resolvePrimitiveKind(callExpr, ctx) {
|
|
190877
|
-
if (
|
|
190900
|
+
if (import_typescript10.default.isIdentifier(callExpr.expression)) {
|
|
190878
190901
|
const hit = PRIMITIVE_CANONICAL_NAMES[callExpr.expression.text];
|
|
190879
190902
|
if (hit)
|
|
190880
190903
|
return hit;
|
|
190881
190904
|
return resolveCalleeViaChecker(callExpr.expression, ctx);
|
|
190882
190905
|
}
|
|
190883
|
-
if (
|
|
190906
|
+
if (import_typescript10.default.isPropertyAccessExpression(callExpr.expression)) {
|
|
190884
190907
|
const propName = callExpr.expression.name.text;
|
|
190885
190908
|
const hit = PRIMITIVE_CANONICAL_NAMES[propName];
|
|
190886
190909
|
if (!hit)
|
|
@@ -190907,7 +190930,7 @@ function resolveCanonicalClientExportName(ident, ctx) {
|
|
|
190907
190930
|
if (!symbol)
|
|
190908
190931
|
return null;
|
|
190909
190932
|
let target = symbol;
|
|
190910
|
-
if (symbol.flags &
|
|
190933
|
+
if (symbol.flags & import_typescript10.default.SymbolFlags.Alias) {
|
|
190911
190934
|
try {
|
|
190912
190935
|
target = ctx.checker.getAliasedSymbol(symbol);
|
|
190913
190936
|
} catch {
|
|
@@ -190923,14 +190946,14 @@ function resolveCanonicalClientExportName(ident, ctx) {
|
|
|
190923
190946
|
return null;
|
|
190924
190947
|
}
|
|
190925
190948
|
function resolveEnvSignalKey(callExpr, ctx) {
|
|
190926
|
-
if (
|
|
190949
|
+
if (import_typescript10.default.isIdentifier(callExpr.expression)) {
|
|
190927
190950
|
const key = ENV_SIGNAL_FACTORIES[callExpr.expression.text];
|
|
190928
190951
|
if (key)
|
|
190929
190952
|
return key;
|
|
190930
190953
|
const canonical = resolveCanonicalClientExportName(callExpr.expression, ctx);
|
|
190931
190954
|
return canonical ? ENV_SIGNAL_FACTORIES[canonical] ?? null : null;
|
|
190932
190955
|
}
|
|
190933
|
-
if (
|
|
190956
|
+
if (import_typescript10.default.isPropertyAccessExpression(callExpr.expression)) {
|
|
190934
190957
|
const key = ENV_SIGNAL_FACTORIES[callExpr.expression.name.text];
|
|
190935
190958
|
if (key && isBarefootClientNamespace(callExpr.expression.expression, ctx))
|
|
190936
190959
|
return key;
|
|
@@ -190938,7 +190961,7 @@ function resolveEnvSignalKey(callExpr, ctx) {
|
|
|
190938
190961
|
return null;
|
|
190939
190962
|
}
|
|
190940
190963
|
function isBarefootClientNamespace(expr, ctx) {
|
|
190941
|
-
if (!
|
|
190964
|
+
if (!import_typescript10.default.isIdentifier(expr))
|
|
190942
190965
|
return false;
|
|
190943
190966
|
if (!ctx.checker)
|
|
190944
190967
|
return false;
|
|
@@ -190951,22 +190974,22 @@ function isBarefootClientNamespace(expr, ctx) {
|
|
|
190951
190974
|
if (!symbol)
|
|
190952
190975
|
return false;
|
|
190953
190976
|
for (const decl of symbol.declarations ?? []) {
|
|
190954
|
-
if (!
|
|
190977
|
+
if (!import_typescript10.default.isNamespaceImport(decl))
|
|
190955
190978
|
continue;
|
|
190956
190979
|
const importDecl = decl.parent.parent;
|
|
190957
|
-
if (!
|
|
190980
|
+
if (!import_typescript10.default.isImportDeclaration(importDecl))
|
|
190958
190981
|
continue;
|
|
190959
190982
|
const mod = importDecl.moduleSpecifier;
|
|
190960
|
-
if (
|
|
190983
|
+
if (import_typescript10.default.isStringLiteral(mod) && mod.text === "@barefootjs/client") {
|
|
190961
190984
|
return true;
|
|
190962
190985
|
}
|
|
190963
190986
|
}
|
|
190964
190987
|
return false;
|
|
190965
190988
|
}
|
|
190966
190989
|
function isSignalDeclaration(node, ctx) {
|
|
190967
|
-
if (!
|
|
190990
|
+
if (!import_typescript10.default.isArrayBindingPattern(node.name))
|
|
190968
190991
|
return false;
|
|
190969
|
-
if (!node.initializer || !
|
|
190992
|
+
if (!node.initializer || !import_typescript10.default.isCallExpression(node.initializer))
|
|
190970
190993
|
return false;
|
|
190971
190994
|
return resolvePrimitiveKind(node.initializer, ctx) === "signal";
|
|
190972
190995
|
}
|
|
@@ -190974,14 +190997,14 @@ function collectSignal(node, ctx) {
|
|
|
190974
190997
|
const pattern = node.name;
|
|
190975
190998
|
const callExpr = node.initializer;
|
|
190976
190999
|
const elements = pattern.elements;
|
|
190977
|
-
const getterElided = elements.length === 2 &&
|
|
190978
|
-
if (elements.length < 1 || elements.length > 2 || !getterElided && (!
|
|
191000
|
+
const getterElided = elements.length === 2 && import_typescript10.default.isOmittedExpression(elements[0]);
|
|
191001
|
+
if (elements.length < 1 || elements.length > 2 || !getterElided && (!import_typescript10.default.isBindingElement(elements[0]) || !import_typescript10.default.isIdentifier(elements[0].name))) {
|
|
190979
191002
|
return;
|
|
190980
191003
|
}
|
|
190981
|
-
if (elements.length === 2 && (!
|
|
191004
|
+
if (elements.length === 2 && (!import_typescript10.default.isBindingElement(elements[1]) || !import_typescript10.default.isIdentifier(elements[1].name))) {
|
|
190982
191005
|
return;
|
|
190983
191006
|
}
|
|
190984
|
-
const setter = elements.length === 2 &&
|
|
191007
|
+
const setter = elements.length === 2 && import_typescript10.default.isBindingElement(elements[1]) && import_typescript10.default.isIdentifier(elements[1].name) ? elements[1].name.text : null;
|
|
190985
191008
|
if (getterElided && !setter)
|
|
190986
191009
|
return;
|
|
190987
191010
|
const getter = getterElided ? `__bfGet_${setter}` : elements[0].name.text;
|
|
@@ -191018,33 +191041,33 @@ function collectSignal(node, ctx) {
|
|
|
191018
191041
|
});
|
|
191019
191042
|
}
|
|
191020
191043
|
function isSignalTupleDeclaration(node) {
|
|
191021
|
-
if (!
|
|
191044
|
+
if (!import_typescript10.default.isIdentifier(node.name))
|
|
191022
191045
|
return false;
|
|
191023
|
-
if (!node.initializer || !
|
|
191046
|
+
if (!node.initializer || !import_typescript10.default.isCallExpression(node.initializer))
|
|
191024
191047
|
return false;
|
|
191025
191048
|
const callExpr = node.initializer;
|
|
191026
|
-
return
|
|
191049
|
+
return import_typescript10.default.isIdentifier(callExpr.expression) && callExpr.expression.text === "createSignal";
|
|
191027
191050
|
}
|
|
191028
191051
|
function isSignalIndexAccess(node, ctx) {
|
|
191029
|
-
if (!
|
|
191052
|
+
if (!import_typescript10.default.isIdentifier(node.name))
|
|
191030
191053
|
return null;
|
|
191031
|
-
if (!node.initializer || !
|
|
191054
|
+
if (!node.initializer || !import_typescript10.default.isElementAccessExpression(node.initializer))
|
|
191032
191055
|
return null;
|
|
191033
191056
|
const access = node.initializer;
|
|
191034
|
-
if (!
|
|
191057
|
+
if (!import_typescript10.default.isNumericLiteral(access.argumentExpression))
|
|
191035
191058
|
return null;
|
|
191036
191059
|
const indexValue = Number(access.argumentExpression.text);
|
|
191037
191060
|
if (indexValue !== 0 && indexValue !== 1)
|
|
191038
191061
|
return null;
|
|
191039
191062
|
const index = indexValue;
|
|
191040
|
-
if (
|
|
191063
|
+
if (import_typescript10.default.isCallExpression(access.expression)) {
|
|
191041
191064
|
const call = access.expression;
|
|
191042
|
-
if (
|
|
191065
|
+
if (import_typescript10.default.isIdentifier(call.expression) && call.expression.text === "createSignal") {
|
|
191043
191066
|
return { kind: "direct", index, callExpr: call };
|
|
191044
191067
|
}
|
|
191045
191068
|
return null;
|
|
191046
191069
|
}
|
|
191047
|
-
if (
|
|
191070
|
+
if (import_typescript10.default.isIdentifier(access.expression)) {
|
|
191048
191071
|
const tupleName = access.expression.text;
|
|
191049
191072
|
if (ctx.signalTupleRefs.has(tupleName)) {
|
|
191050
191073
|
return { kind: "tupleRef", index, tupleName };
|
|
@@ -191139,30 +191162,30 @@ function flushPendingSignalTuples(ctx) {
|
|
|
191139
191162
|
ctx.signalTupleRefs.clear();
|
|
191140
191163
|
}
|
|
191141
191164
|
function isMemoDeclaration(node, ctx) {
|
|
191142
|
-
if (!
|
|
191165
|
+
if (!import_typescript10.default.isIdentifier(node.name))
|
|
191143
191166
|
return false;
|
|
191144
|
-
if (!node.initializer || !
|
|
191167
|
+
if (!node.initializer || !import_typescript10.default.isCallExpression(node.initializer))
|
|
191145
191168
|
return false;
|
|
191146
191169
|
return resolvePrimitiveKind(node.initializer, ctx) === "memo";
|
|
191147
191170
|
}
|
|
191148
191171
|
function memoBodyIsTemplateLiteral(memoArrow) {
|
|
191149
191172
|
let node = memoArrow;
|
|
191150
|
-
while (node &&
|
|
191173
|
+
while (node && import_typescript10.default.isParenthesizedExpression(node))
|
|
191151
191174
|
node = node.expression;
|
|
191152
|
-
if (!node || !
|
|
191175
|
+
if (!node || !import_typescript10.default.isArrowFunction(node))
|
|
191153
191176
|
return false;
|
|
191154
191177
|
let body = node.body;
|
|
191155
|
-
while (
|
|
191178
|
+
while (import_typescript10.default.isParenthesizedExpression(body))
|
|
191156
191179
|
body = body.expression;
|
|
191157
|
-
if (
|
|
191158
|
-
const ret = body.statements.find(
|
|
191180
|
+
if (import_typescript10.default.isBlock(body)) {
|
|
191181
|
+
const ret = body.statements.find(import_typescript10.default.isReturnStatement);
|
|
191159
191182
|
if (!ret || !ret.expression)
|
|
191160
191183
|
return false;
|
|
191161
191184
|
body = ret.expression;
|
|
191162
|
-
while (
|
|
191185
|
+
while (import_typescript10.default.isParenthesizedExpression(body))
|
|
191163
191186
|
body = body.expression;
|
|
191164
191187
|
}
|
|
191165
|
-
return
|
|
191188
|
+
return import_typescript10.default.isTemplateExpression(body) || import_typescript10.default.isNoSubstitutionTemplateLiteral(body);
|
|
191166
191189
|
}
|
|
191167
191190
|
function collectMemo(node, ctx) {
|
|
191168
191191
|
const name = node.name.text;
|
|
@@ -191179,7 +191202,7 @@ function collectMemo(node, ctx) {
|
|
|
191179
191202
|
type2 = inferTypeFromValue(arrowBody);
|
|
191180
191203
|
}
|
|
191181
191204
|
}
|
|
191182
|
-
if (ctx.checker && (type2.kind === "unknown" || type2.kind === "object") && callExpr.arguments[0] && (
|
|
191205
|
+
if (ctx.checker && (type2.kind === "unknown" || type2.kind === "object") && callExpr.arguments[0] && (import_typescript10.default.isArrowFunction(callExpr.arguments[0]) || import_typescript10.default.isFunctionExpression(callExpr.arguments[0]))) {
|
|
191183
191206
|
const fnType = ctx.checker.getTypeAtLocation(callExpr.arguments[0]);
|
|
191184
191207
|
const sig = fnType.getCallSignatures()[0];
|
|
191185
191208
|
if (sig) {
|
|
@@ -191189,12 +191212,12 @@ function collectMemo(node, ctx) {
|
|
|
191189
191212
|
}
|
|
191190
191213
|
}
|
|
191191
191214
|
const memoArrow = callExpr.arguments[0];
|
|
191192
|
-
const parsedBody = memoArrow &&
|
|
191215
|
+
const parsedBody = memoArrow && import_typescript10.default.isArrowFunction(memoArrow) && !import_typescript10.default.isBlock(memoArrow.body) ? parseExpression(ctx.getJS(memoArrow.body)) : undefined;
|
|
191193
191216
|
const parsed = parsedBody && parsedBody.kind !== "unsupported" && parsedBody.kind !== "object-literal" ? parsedBody : undefined;
|
|
191194
191217
|
let arrowNode = memoArrow;
|
|
191195
|
-
while (arrowNode &&
|
|
191218
|
+
while (arrowNode && import_typescript10.default.isParenthesizedExpression(arrowNode))
|
|
191196
191219
|
arrowNode = arrowNode.expression;
|
|
191197
|
-
const blockBody = arrowNode &&
|
|
191220
|
+
const blockBody = arrowNode && import_typescript10.default.isArrowFunction(arrowNode) && import_typescript10.default.isBlock(arrowNode.body) ? arrowNode.body : undefined;
|
|
191198
191221
|
const parsedBlock = blockBody ? parseBlockBodyTolerant(blockBody, ctx.sourceFile, (node2) => ctx.getJS(node2)) : undefined;
|
|
191199
191222
|
const parsedBlockComplete = parsedBlock && blockBody ? parsedBlock.length === blockBody.statements.length : undefined;
|
|
191200
191223
|
let templateComputation;
|
|
@@ -191221,14 +191244,14 @@ function collectMemo(node, ctx) {
|
|
|
191221
191244
|
});
|
|
191222
191245
|
}
|
|
191223
191246
|
function isEffectCall(node, ctx) {
|
|
191224
|
-
if (!
|
|
191247
|
+
if (!import_typescript10.default.isCallExpression(node))
|
|
191225
191248
|
return false;
|
|
191226
191249
|
return resolvePrimitiveKind(node, ctx) === "effect";
|
|
191227
191250
|
}
|
|
191228
191251
|
function isEffectDisposerCapture(node, ctx) {
|
|
191229
|
-
if (!
|
|
191252
|
+
if (!import_typescript10.default.isIdentifier(node.name))
|
|
191230
191253
|
return false;
|
|
191231
|
-
if (!node.initializer || !
|
|
191254
|
+
if (!node.initializer || !import_typescript10.default.isCallExpression(node.initializer))
|
|
191232
191255
|
return false;
|
|
191233
191256
|
return resolvePrimitiveKind(node.initializer, ctx) === "effect";
|
|
191234
191257
|
}
|
|
@@ -191243,7 +191266,7 @@ function collectEffect(node, ctx, captureName) {
|
|
|
191243
191266
|
});
|
|
191244
191267
|
}
|
|
191245
191268
|
function isOnMountCall(node, ctx) {
|
|
191246
|
-
if (!
|
|
191269
|
+
if (!import_typescript10.default.isCallExpression(node))
|
|
191247
191270
|
return false;
|
|
191248
191271
|
return resolvePrimitiveKind(node, ctx) === "onMount";
|
|
191249
191272
|
}
|
|
@@ -191278,19 +191301,19 @@ function leadsWithAsiHazard(body) {
|
|
|
191278
191301
|
function extractAssignedIdentifiersFromNode(node) {
|
|
191279
191302
|
const ids = new Set;
|
|
191280
191303
|
function addFromTarget(target) {
|
|
191281
|
-
if (
|
|
191304
|
+
if (import_typescript10.default.isIdentifier(target)) {
|
|
191282
191305
|
ids.add(target.text);
|
|
191283
191306
|
return;
|
|
191284
191307
|
}
|
|
191285
|
-
if (
|
|
191308
|
+
if (import_typescript10.default.isParenthesizedExpression(target)) {
|
|
191286
191309
|
addFromTarget(target.expression);
|
|
191287
191310
|
return;
|
|
191288
191311
|
}
|
|
191289
|
-
if (
|
|
191312
|
+
if (import_typescript10.default.isArrayLiteralExpression(target)) {
|
|
191290
191313
|
for (const el of target.elements) {
|
|
191291
|
-
if (
|
|
191314
|
+
if (import_typescript10.default.isOmittedExpression(el))
|
|
191292
191315
|
continue;
|
|
191293
|
-
if (
|
|
191316
|
+
if (import_typescript10.default.isSpreadElement(el)) {
|
|
191294
191317
|
addFromTarget(el.expression);
|
|
191295
191318
|
continue;
|
|
191296
191319
|
}
|
|
@@ -191298,17 +191321,17 @@ function extractAssignedIdentifiersFromNode(node) {
|
|
|
191298
191321
|
}
|
|
191299
191322
|
return;
|
|
191300
191323
|
}
|
|
191301
|
-
if (
|
|
191324
|
+
if (import_typescript10.default.isObjectLiteralExpression(target)) {
|
|
191302
191325
|
for (const prop of target.properties) {
|
|
191303
|
-
if (
|
|
191326
|
+
if (import_typescript10.default.isShorthandPropertyAssignment(prop)) {
|
|
191304
191327
|
ids.add(prop.name.text);
|
|
191305
191328
|
continue;
|
|
191306
191329
|
}
|
|
191307
|
-
if (
|
|
191330
|
+
if (import_typescript10.default.isPropertyAssignment(prop)) {
|
|
191308
191331
|
addFromTarget(prop.initializer);
|
|
191309
191332
|
continue;
|
|
191310
191333
|
}
|
|
191311
|
-
if (
|
|
191334
|
+
if (import_typescript10.default.isSpreadAssignment(prop)) {
|
|
191312
191335
|
addFromTarget(prop.expression);
|
|
191313
191336
|
continue;
|
|
191314
191337
|
}
|
|
@@ -191317,21 +191340,21 @@ function extractAssignedIdentifiersFromNode(node) {
|
|
|
191317
191340
|
}
|
|
191318
191341
|
}
|
|
191319
191342
|
function visit2(n) {
|
|
191320
|
-
if (
|
|
191343
|
+
if (import_typescript10.default.isArrowFunction(n) || import_typescript10.default.isFunctionExpression(n) || import_typescript10.default.isFunctionDeclaration(n) || import_typescript10.default.isMethodDeclaration(n) || import_typescript10.default.isGetAccessorDeclaration(n) || import_typescript10.default.isSetAccessorDeclaration(n) || import_typescript10.default.isConstructorDeclaration(n)) {
|
|
191321
191344
|
return;
|
|
191322
191345
|
}
|
|
191323
|
-
if (
|
|
191346
|
+
if (import_typescript10.default.isBinaryExpression(n)) {
|
|
191324
191347
|
const op = n.operatorToken.kind;
|
|
191325
|
-
if (op ===
|
|
191348
|
+
if (op === import_typescript10.default.SyntaxKind.EqualsToken || op === import_typescript10.default.SyntaxKind.PlusEqualsToken || op === import_typescript10.default.SyntaxKind.MinusEqualsToken || op === import_typescript10.default.SyntaxKind.AsteriskEqualsToken || op === import_typescript10.default.SyntaxKind.SlashEqualsToken || op === import_typescript10.default.SyntaxKind.PercentEqualsToken || op === import_typescript10.default.SyntaxKind.AsteriskAsteriskEqualsToken || op === import_typescript10.default.SyntaxKind.AmpersandEqualsToken || op === import_typescript10.default.SyntaxKind.BarEqualsToken || op === import_typescript10.default.SyntaxKind.CaretEqualsToken || op === import_typescript10.default.SyntaxKind.LessThanLessThanEqualsToken || op === import_typescript10.default.SyntaxKind.GreaterThanGreaterThanEqualsToken || op === import_typescript10.default.SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken || op === import_typescript10.default.SyntaxKind.AmpersandAmpersandEqualsToken || op === import_typescript10.default.SyntaxKind.BarBarEqualsToken || op === import_typescript10.default.SyntaxKind.QuestionQuestionEqualsToken) {
|
|
191326
191349
|
addFromTarget(n.left);
|
|
191327
191350
|
}
|
|
191328
191351
|
}
|
|
191329
|
-
if (
|
|
191330
|
-
if (n.operator ===
|
|
191352
|
+
if (import_typescript10.default.isPrefixUnaryExpression(n) || import_typescript10.default.isPostfixUnaryExpression(n)) {
|
|
191353
|
+
if (n.operator === import_typescript10.default.SyntaxKind.PlusPlusToken || n.operator === import_typescript10.default.SyntaxKind.MinusMinusToken) {
|
|
191331
191354
|
addFromTarget(n.operand);
|
|
191332
191355
|
}
|
|
191333
191356
|
}
|
|
191334
|
-
|
|
191357
|
+
import_typescript10.default.forEachChild(n, visit2);
|
|
191335
191358
|
}
|
|
191336
191359
|
visit2(node);
|
|
191337
191360
|
const localDecls = collectLocalDeclarations(node);
|
|
@@ -191342,30 +191365,30 @@ function extractAssignedIdentifiersFromNode(node) {
|
|
|
191342
191365
|
function collectLocalDeclarations(root) {
|
|
191343
191366
|
const names = new Set;
|
|
191344
191367
|
function addBindingName(name) {
|
|
191345
|
-
if (
|
|
191368
|
+
if (import_typescript10.default.isIdentifier(name)) {
|
|
191346
191369
|
names.add(name.text);
|
|
191347
191370
|
return;
|
|
191348
191371
|
}
|
|
191349
|
-
if (
|
|
191372
|
+
if (import_typescript10.default.isArrayBindingPattern(name)) {
|
|
191350
191373
|
for (const el of name.elements) {
|
|
191351
|
-
if (
|
|
191374
|
+
if (import_typescript10.default.isBindingElement(el))
|
|
191352
191375
|
addBindingName(el.name);
|
|
191353
191376
|
}
|
|
191354
191377
|
return;
|
|
191355
191378
|
}
|
|
191356
|
-
if (
|
|
191379
|
+
if (import_typescript10.default.isObjectBindingPattern(name)) {
|
|
191357
191380
|
for (const el of name.elements) {
|
|
191358
191381
|
addBindingName(el.name);
|
|
191359
191382
|
}
|
|
191360
191383
|
}
|
|
191361
191384
|
}
|
|
191362
191385
|
function visit2(n) {
|
|
191363
|
-
if (
|
|
191386
|
+
if (import_typescript10.default.isArrowFunction(n) || import_typescript10.default.isFunctionExpression(n) || import_typescript10.default.isFunctionDeclaration(n))
|
|
191364
191387
|
return;
|
|
191365
|
-
if (
|
|
191388
|
+
if (import_typescript10.default.isVariableDeclaration(n)) {
|
|
191366
191389
|
addBindingName(n.name);
|
|
191367
191390
|
}
|
|
191368
|
-
|
|
191391
|
+
import_typescript10.default.forEachChild(n, visit2);
|
|
191369
191392
|
}
|
|
191370
191393
|
visit2(root);
|
|
191371
191394
|
return names;
|
|
@@ -191399,35 +191422,35 @@ var CLIENT_EXPORTS = new Set([
|
|
|
191399
191422
|
"Region"
|
|
191400
191423
|
]);
|
|
191401
191424
|
function collectAmbientGlobals(node, ctx) {
|
|
191402
|
-
if (
|
|
191403
|
-
const isDeclare = node.modifiers?.some((m) => m.kind ===
|
|
191425
|
+
if (import_typescript10.default.isVariableStatement(node)) {
|
|
191426
|
+
const isDeclare = node.modifiers?.some((m) => m.kind === import_typescript10.default.SyntaxKind.DeclareKeyword) ?? false;
|
|
191404
191427
|
if (!isDeclare)
|
|
191405
191428
|
return;
|
|
191406
191429
|
for (const decl of node.declarationList.declarations) {
|
|
191407
|
-
if (
|
|
191430
|
+
if (import_typescript10.default.isIdentifier(decl.name))
|
|
191408
191431
|
ctx.ambientGlobals.add(decl.name.text);
|
|
191409
191432
|
}
|
|
191410
191433
|
return;
|
|
191411
191434
|
}
|
|
191412
|
-
if (
|
|
191413
|
-
const isDeclare = node.modifiers?.some((m) => m.kind ===
|
|
191435
|
+
if (import_typescript10.default.isFunctionDeclaration(node) && node.name) {
|
|
191436
|
+
const isDeclare = node.modifiers?.some((m) => m.kind === import_typescript10.default.SyntaxKind.DeclareKeyword) ?? false;
|
|
191414
191437
|
if (isDeclare)
|
|
191415
191438
|
ctx.ambientGlobals.add(node.name.text);
|
|
191416
191439
|
return;
|
|
191417
191440
|
}
|
|
191418
|
-
if (
|
|
191419
|
-
const isGlobalAugmentation = (node.flags &
|
|
191441
|
+
if (import_typescript10.default.isModuleDeclaration(node)) {
|
|
191442
|
+
const isGlobalAugmentation = (node.flags & import_typescript10.default.NodeFlags.GlobalAugmentation) !== 0;
|
|
191420
191443
|
if (!isGlobalAugmentation)
|
|
191421
191444
|
return;
|
|
191422
|
-
if (!node.body || !
|
|
191445
|
+
if (!node.body || !import_typescript10.default.isModuleBlock(node.body))
|
|
191423
191446
|
return;
|
|
191424
191447
|
for (const inner of node.body.statements) {
|
|
191425
|
-
if (
|
|
191448
|
+
if (import_typescript10.default.isVariableStatement(inner)) {
|
|
191426
191449
|
for (const decl of inner.declarationList.declarations) {
|
|
191427
|
-
if (
|
|
191450
|
+
if (import_typescript10.default.isIdentifier(decl.name))
|
|
191428
191451
|
ctx.ambientGlobals.add(decl.name.text);
|
|
191429
191452
|
}
|
|
191430
|
-
} else if (
|
|
191453
|
+
} else if (import_typescript10.default.isFunctionDeclaration(inner) && inner.name) {
|
|
191431
191454
|
ctx.ambientGlobals.add(inner.name.text);
|
|
191432
191455
|
}
|
|
191433
191456
|
}
|
|
@@ -191438,7 +191461,7 @@ function collectImport(node, ctx) {
|
|
|
191438
191461
|
const specifiers = [];
|
|
191439
191462
|
const isTypeOnly = !!node.importClause?.isTypeOnly;
|
|
191440
191463
|
const loc = getSourceLocation(node, ctx.sourceFile, ctx.filePath);
|
|
191441
|
-
if (source === "@barefootjs/client" && !isTypeOnly && node.importClause?.namedBindings &&
|
|
191464
|
+
if (source === "@barefootjs/client" && !isTypeOnly && node.importClause?.namedBindings && import_typescript10.default.isNamedImports(node.importClause.namedBindings)) {
|
|
191442
191465
|
const wrongImports = [];
|
|
191443
191466
|
for (const element of node.importClause.namedBindings.elements) {
|
|
191444
191467
|
const name = element.propertyName?.text ?? element.name.text;
|
|
@@ -191466,7 +191489,7 @@ function collectImport(node, ctx) {
|
|
|
191466
191489
|
});
|
|
191467
191490
|
}
|
|
191468
191491
|
if (node.importClause.namedBindings) {
|
|
191469
|
-
if (
|
|
191492
|
+
if (import_typescript10.default.isNamedImports(node.importClause.namedBindings)) {
|
|
191470
191493
|
for (const element of node.importClause.namedBindings.elements) {
|
|
191471
191494
|
specifiers.push({
|
|
191472
191495
|
name: element.propertyName?.text ?? element.name.text,
|
|
@@ -191477,7 +191500,7 @@ function collectImport(node, ctx) {
|
|
|
191477
191500
|
});
|
|
191478
191501
|
}
|
|
191479
191502
|
}
|
|
191480
|
-
if (
|
|
191503
|
+
if (import_typescript10.default.isNamespaceImport(node.importClause.namedBindings)) {
|
|
191481
191504
|
specifiers.push({
|
|
191482
191505
|
name: node.importClause.namedBindings.name.text,
|
|
191483
191506
|
alias: null,
|
|
@@ -191504,7 +191527,7 @@ function collectInterfaceDefinition(node, ctx) {
|
|
|
191504
191527
|
});
|
|
191505
191528
|
}
|
|
191506
191529
|
function collectTypeAliasDefinition(node, ctx) {
|
|
191507
|
-
const properties =
|
|
191530
|
+
const properties = import_typescript10.default.isTypeLiteralNode(node.type) ? membersToProperties(node.type.members, ctx.sourceFile) : undefined;
|
|
191508
191531
|
ctx.typeDefinitions.push({
|
|
191509
191532
|
kind: "type",
|
|
191510
191533
|
name: node.name.text,
|
|
@@ -191517,20 +191540,20 @@ function extractSingleJsxReturn(body) {
|
|
|
191517
191540
|
let jsxReturn = null;
|
|
191518
191541
|
let returnCount = 0;
|
|
191519
191542
|
function visit2(node) {
|
|
191520
|
-
if (
|
|
191543
|
+
if (import_typescript10.default.isFunctionDeclaration(node) || import_typescript10.default.isFunctionExpression(node) || import_typescript10.default.isArrowFunction(node))
|
|
191521
191544
|
return;
|
|
191522
|
-
if (
|
|
191545
|
+
if (import_typescript10.default.isReturnStatement(node)) {
|
|
191523
191546
|
returnCount++;
|
|
191524
191547
|
if (node.expression) {
|
|
191525
191548
|
const expr = unwrapJsxTransparent(node.expression);
|
|
191526
|
-
if (
|
|
191549
|
+
if (import_typescript10.default.isJsxElement(expr) || import_typescript10.default.isJsxSelfClosingElement(expr) || import_typescript10.default.isJsxFragment(expr)) {
|
|
191527
191550
|
jsxReturn = expr;
|
|
191528
191551
|
}
|
|
191529
191552
|
}
|
|
191530
191553
|
}
|
|
191531
|
-
|
|
191554
|
+
import_typescript10.default.forEachChild(node, visit2);
|
|
191532
191555
|
}
|
|
191533
|
-
|
|
191556
|
+
import_typescript10.default.forEachChild(body, visit2);
|
|
191534
191557
|
if (returnCount !== 1)
|
|
191535
191558
|
return null;
|
|
191536
191559
|
return jsxReturn;
|
|
@@ -191547,9 +191570,9 @@ function extractMultiReturnJsxBranches(body, allowPreamble = false) {
|
|
|
191547
191570
|
const stmts = body.statements;
|
|
191548
191571
|
for (let i2 = 0;i2 < stmts.length; i2++) {
|
|
191549
191572
|
const stmt = stmts[i2];
|
|
191550
|
-
if (
|
|
191573
|
+
if (import_typescript10.default.isIfStatement(stmt)) {
|
|
191551
191574
|
let current = stmt;
|
|
191552
|
-
while (
|
|
191575
|
+
while (import_typescript10.default.isIfStatement(current)) {
|
|
191553
191576
|
const ifStmt = current;
|
|
191554
191577
|
if (!isDirectReturnBlock(ifStmt.thenStatement))
|
|
191555
191578
|
return null;
|
|
@@ -191559,7 +191582,7 @@ function extractMultiReturnJsxBranches(body, allowPreamble = false) {
|
|
|
191559
191582
|
return null;
|
|
191560
191583
|
branches.push({ condition: ifStmt.expression, jsxReturn: jsxReturn ?? null });
|
|
191561
191584
|
if (ifStmt.elseStatement) {
|
|
191562
|
-
if (
|
|
191585
|
+
if (import_typescript10.default.isIfStatement(ifStmt.elseStatement)) {
|
|
191563
191586
|
current = ifStmt.elseStatement;
|
|
191564
191587
|
continue;
|
|
191565
191588
|
}
|
|
@@ -191581,18 +191604,18 @@ function extractMultiReturnJsxBranches(body, allowPreamble = false) {
|
|
|
191581
191604
|
}
|
|
191582
191605
|
continue;
|
|
191583
191606
|
}
|
|
191584
|
-
if (
|
|
191607
|
+
if (import_typescript10.default.isSwitchStatement(stmt)) {
|
|
191585
191608
|
if (branches.length > 0)
|
|
191586
191609
|
return null;
|
|
191587
|
-
if (!
|
|
191610
|
+
if (!import_typescript10.default.isIdentifier(stmt.expression) && !import_typescript10.default.isPropertyAccessExpression(stmt.expression)) {
|
|
191588
191611
|
return null;
|
|
191589
191612
|
}
|
|
191590
|
-
const hasDefault = stmt.caseBlock.clauses.some((c) =>
|
|
191613
|
+
const hasDefault = stmt.caseBlock.clauses.some((c) => import_typescript10.default.isDefaultClause(c));
|
|
191591
191614
|
if (!hasDefault)
|
|
191592
191615
|
return null;
|
|
191593
191616
|
let pendingCases = [];
|
|
191594
191617
|
for (const clause of stmt.caseBlock.clauses) {
|
|
191595
|
-
if (
|
|
191618
|
+
if (import_typescript10.default.isCaseClause(clause) && clause.statements.length === 0) {
|
|
191596
191619
|
pendingCases.push(clause.expression);
|
|
191597
191620
|
continue;
|
|
191598
191621
|
}
|
|
@@ -191602,7 +191625,7 @@ function extractMultiReturnJsxBranches(body, allowPreamble = false) {
|
|
|
191602
191625
|
return null;
|
|
191603
191626
|
if (!caseClauseIsDirectReturn(clause))
|
|
191604
191627
|
return null;
|
|
191605
|
-
if (
|
|
191628
|
+
if (import_typescript10.default.isCaseClause(clause)) {
|
|
191606
191629
|
branches.push({
|
|
191607
191630
|
condition: clause.expression,
|
|
191608
191631
|
jsxReturn: jsxReturn ?? null,
|
|
@@ -191623,18 +191646,18 @@ function extractMultiReturnJsxBranches(body, allowPreamble = false) {
|
|
|
191623
191646
|
return null;
|
|
191624
191647
|
return { branches, fallback, switchDiscriminant: stmt.expression, preamble };
|
|
191625
191648
|
}
|
|
191626
|
-
if (
|
|
191649
|
+
if (import_typescript10.default.isReturnStatement(stmt) && stmt.expression) {
|
|
191627
191650
|
const expr = unwrapJsxTransparent(stmt.expression);
|
|
191628
|
-
if (
|
|
191651
|
+
if (import_typescript10.default.isJsxElement(expr) || import_typescript10.default.isJsxSelfClosingElement(expr) || import_typescript10.default.isJsxFragment(expr)) {
|
|
191629
191652
|
fallback = expr;
|
|
191630
|
-
} else if (expr.kind ===
|
|
191653
|
+
} else if (expr.kind === import_typescript10.default.SyntaxKind.NullKeyword) {} else {
|
|
191631
191654
|
return null;
|
|
191632
191655
|
}
|
|
191633
191656
|
continue;
|
|
191634
191657
|
}
|
|
191635
|
-
if (
|
|
191658
|
+
if (import_typescript10.default.isVariableStatement(stmt)) {
|
|
191636
191659
|
const declFlags = stmt.declarationList.flags;
|
|
191637
|
-
const isConstOrLet = (declFlags &
|
|
191660
|
+
const isConstOrLet = (declFlags & import_typescript10.default.NodeFlags.Const) !== 0 || (declFlags & import_typescript10.default.NodeFlags.Let) !== 0;
|
|
191638
191661
|
if (allowPreamble && isConstOrLet && branches.length === 0 && fallback === null) {
|
|
191639
191662
|
preamble.push(stmt);
|
|
191640
191663
|
continue;
|
|
@@ -191650,12 +191673,12 @@ function extractMultiReturnJsxBranches(body, allowPreamble = false) {
|
|
|
191650
191673
|
return { branches, fallback, preamble };
|
|
191651
191674
|
}
|
|
191652
191675
|
function isDirectReturnBlock(node) {
|
|
191653
|
-
if (
|
|
191676
|
+
if (import_typescript10.default.isReturnStatement(node))
|
|
191654
191677
|
return true;
|
|
191655
|
-
if (
|
|
191678
|
+
if (import_typescript10.default.isBlock(node)) {
|
|
191656
191679
|
let returnCount = 0;
|
|
191657
191680
|
for (const stmt of node.statements) {
|
|
191658
|
-
if (
|
|
191681
|
+
if (import_typescript10.default.isReturnStatement(stmt)) {
|
|
191659
191682
|
returnCount++;
|
|
191660
191683
|
continue;
|
|
191661
191684
|
}
|
|
@@ -191666,25 +191689,25 @@ function isDirectReturnBlock(node) {
|
|
|
191666
191689
|
return false;
|
|
191667
191690
|
}
|
|
191668
191691
|
function findNullReturnInBlock(node) {
|
|
191669
|
-
if (
|
|
191692
|
+
if (import_typescript10.default.isBlock(node)) {
|
|
191670
191693
|
for (const stmt of node.statements) {
|
|
191671
|
-
if (
|
|
191694
|
+
if (import_typescript10.default.isReturnStatement(stmt) && stmt.expression) {
|
|
191672
191695
|
const expr = unwrapJsxTransparent(stmt.expression);
|
|
191673
|
-
if (expr.kind ===
|
|
191696
|
+
if (expr.kind === import_typescript10.default.SyntaxKind.NullKeyword)
|
|
191674
191697
|
return true;
|
|
191675
191698
|
}
|
|
191676
191699
|
}
|
|
191677
191700
|
}
|
|
191678
|
-
if (
|
|
191701
|
+
if (import_typescript10.default.isReturnStatement(node) && node.expression) {
|
|
191679
191702
|
const expr = unwrapJsxTransparent(node.expression);
|
|
191680
|
-
if (expr.kind ===
|
|
191703
|
+
if (expr.kind === import_typescript10.default.SyntaxKind.NullKeyword)
|
|
191681
191704
|
return true;
|
|
191682
191705
|
}
|
|
191683
191706
|
return false;
|
|
191684
191707
|
}
|
|
191685
191708
|
function findJsxReturnInCaseClause(clause) {
|
|
191686
191709
|
for (const stmt of clause.statements) {
|
|
191687
|
-
if (
|
|
191710
|
+
if (import_typescript10.default.isReturnStatement(stmt) && stmt.expression) {
|
|
191688
191711
|
return extractJsxFromExpression(stmt.expression);
|
|
191689
191712
|
}
|
|
191690
191713
|
}
|
|
@@ -191694,12 +191717,12 @@ function caseClauseIsDirectReturn(clause) {
|
|
|
191694
191717
|
let returnCount = 0;
|
|
191695
191718
|
let seenReturn = false;
|
|
191696
191719
|
for (const stmt of clause.statements) {
|
|
191697
|
-
if (
|
|
191720
|
+
if (import_typescript10.default.isReturnStatement(stmt)) {
|
|
191698
191721
|
returnCount++;
|
|
191699
191722
|
seenReturn = true;
|
|
191700
191723
|
continue;
|
|
191701
191724
|
}
|
|
191702
|
-
if (
|
|
191725
|
+
if (import_typescript10.default.isBreakStatement(stmt)) {
|
|
191703
191726
|
if (!seenReturn)
|
|
191704
191727
|
return false;
|
|
191705
191728
|
continue;
|
|
@@ -191710,9 +191733,9 @@ function caseClauseIsDirectReturn(clause) {
|
|
|
191710
191733
|
}
|
|
191711
191734
|
function findNullReturnInCaseClause(clause) {
|
|
191712
191735
|
for (const stmt of clause.statements) {
|
|
191713
|
-
if (
|
|
191736
|
+
if (import_typescript10.default.isReturnStatement(stmt) && stmt.expression) {
|
|
191714
191737
|
const expr = unwrapJsxTransparent(stmt.expression);
|
|
191715
|
-
if (expr.kind ===
|
|
191738
|
+
if (expr.kind === import_typescript10.default.SyntaxKind.NullKeyword)
|
|
191716
191739
|
return true;
|
|
191717
191740
|
}
|
|
191718
191741
|
}
|
|
@@ -191723,26 +191746,26 @@ function isMultiReturnJsxFunctionBody(body) {
|
|
|
191723
191746
|
let hasJsxReturn = false;
|
|
191724
191747
|
let allReturnsAreJsxOrNull = true;
|
|
191725
191748
|
function visit2(node) {
|
|
191726
|
-
if (
|
|
191749
|
+
if (import_typescript10.default.isFunctionDeclaration(node) || import_typescript10.default.isFunctionExpression(node) || import_typescript10.default.isArrowFunction(node))
|
|
191727
191750
|
return;
|
|
191728
|
-
if (
|
|
191751
|
+
if (import_typescript10.default.isReturnStatement(node)) {
|
|
191729
191752
|
returnCount++;
|
|
191730
191753
|
if (!node.expression) {
|
|
191731
191754
|
allReturnsAreJsxOrNull = false;
|
|
191732
191755
|
return;
|
|
191733
191756
|
}
|
|
191734
191757
|
const expr = unwrapJsxTransparent(node.expression);
|
|
191735
|
-
const isJsx =
|
|
191736
|
-
const isNull2 = expr.kind ===
|
|
191758
|
+
const isJsx = import_typescript10.default.isJsxElement(expr) || import_typescript10.default.isJsxSelfClosingElement(expr) || import_typescript10.default.isJsxFragment(expr);
|
|
191759
|
+
const isNull2 = expr.kind === import_typescript10.default.SyntaxKind.NullKeyword;
|
|
191737
191760
|
if (isJsx)
|
|
191738
191761
|
hasJsxReturn = true;
|
|
191739
191762
|
if (!isJsx && !isNull2)
|
|
191740
191763
|
allReturnsAreJsxOrNull = false;
|
|
191741
191764
|
return;
|
|
191742
191765
|
}
|
|
191743
|
-
|
|
191766
|
+
import_typescript10.default.forEachChild(node, visit2);
|
|
191744
191767
|
}
|
|
191745
|
-
|
|
191768
|
+
import_typescript10.default.forEachChild(body, visit2);
|
|
191746
191769
|
return returnCount > 1 && hasJsxReturn && allReturnsAreJsxOrNull;
|
|
191747
191770
|
}
|
|
191748
191771
|
function collectFunction(node, ctx, _isModule, isExported = false) {
|
|
@@ -191812,7 +191835,7 @@ function collectFunction(node, ctx, _isModule, isExported = false) {
|
|
|
191812
191835
|
}
|
|
191813
191836
|
}
|
|
191814
191837
|
}
|
|
191815
|
-
const isAsync = node.modifiers?.some((m) => m.kind ===
|
|
191838
|
+
const isAsync = node.modifiers?.some((m) => m.kind === import_typescript10.default.SyntaxKind.AsyncKeyword) ?? false;
|
|
191816
191839
|
const isGenerator = !!node.asteriskToken;
|
|
191817
191840
|
ctx.localFunctions.push({
|
|
191818
191841
|
name,
|
|
@@ -191833,10 +191856,10 @@ function collectFunction(node, ctx, _isModule, isExported = false) {
|
|
|
191833
191856
|
});
|
|
191834
191857
|
}
|
|
191835
191858
|
function extractValueBranches(node, ctx) {
|
|
191836
|
-
if (
|
|
191859
|
+
if (import_typescript10.default.isParenthesizedExpression(node)) {
|
|
191837
191860
|
return extractValueBranches(node.expression, ctx);
|
|
191838
191861
|
}
|
|
191839
|
-
if (
|
|
191862
|
+
if (import_typescript10.default.isConditionalExpression(node)) {
|
|
191840
191863
|
return [
|
|
191841
191864
|
...extractValueBranches(node.whenTrue, ctx),
|
|
191842
191865
|
...extractValueBranches(node.whenFalse, ctx)
|
|
@@ -191848,46 +191871,46 @@ function extractFreeIdentifiersFromNode(node) {
|
|
|
191848
191871
|
const ids = new Set;
|
|
191849
191872
|
const boundNames = new Set;
|
|
191850
191873
|
function addBindingNames(name, out) {
|
|
191851
|
-
if (
|
|
191874
|
+
if (import_typescript10.default.isIdentifier(name))
|
|
191852
191875
|
out.push(name.text);
|
|
191853
|
-
else if (
|
|
191876
|
+
else if (import_typescript10.default.isObjectBindingPattern(name))
|
|
191854
191877
|
name.elements.forEach((e) => addBindingNames(e.name, out));
|
|
191855
|
-
else if (
|
|
191878
|
+
else if (import_typescript10.default.isArrayBindingPattern(name))
|
|
191856
191879
|
name.elements.forEach((e) => {
|
|
191857
|
-
if (!
|
|
191880
|
+
if (!import_typescript10.default.isOmittedExpression(e))
|
|
191858
191881
|
addBindingNames(e.name, out);
|
|
191859
191882
|
});
|
|
191860
191883
|
}
|
|
191861
191884
|
function visit2(n) {
|
|
191862
|
-
if (
|
|
191885
|
+
if (import_typescript10.default.isTypeNode(n))
|
|
191863
191886
|
return;
|
|
191864
|
-
if (
|
|
191887
|
+
if (import_typescript10.default.isIdentifier(n)) {
|
|
191865
191888
|
const parent = n.parent;
|
|
191866
|
-
if (parent &&
|
|
191889
|
+
if (parent && import_typescript10.default.isPropertyAccessExpression(parent) && parent.name === n)
|
|
191867
191890
|
return;
|
|
191868
|
-
if (parent &&
|
|
191891
|
+
if (parent && import_typescript10.default.isPropertyAssignment(parent) && parent.name === n)
|
|
191869
191892
|
return;
|
|
191870
|
-
if (parent &&
|
|
191893
|
+
if (parent && import_typescript10.default.isParameter(parent) && parent.name === n)
|
|
191871
191894
|
return;
|
|
191872
|
-
if (parent &&
|
|
191895
|
+
if (parent && import_typescript10.default.isVariableDeclaration(parent) && parent.name === n)
|
|
191873
191896
|
return;
|
|
191874
191897
|
if (boundNames.has(n.text))
|
|
191875
191898
|
return;
|
|
191876
191899
|
ids.add(n.text);
|
|
191877
191900
|
return;
|
|
191878
191901
|
}
|
|
191879
|
-
if (
|
|
191902
|
+
if (import_typescript10.default.isArrowFunction(n)) {
|
|
191880
191903
|
const params = [];
|
|
191881
191904
|
for (const p of n.parameters)
|
|
191882
191905
|
addBindingNames(p.name, params);
|
|
191883
191906
|
for (const name of params)
|
|
191884
191907
|
boundNames.add(name);
|
|
191885
|
-
|
|
191908
|
+
import_typescript10.default.forEachChild(n, visit2);
|
|
191886
191909
|
for (const name of params)
|
|
191887
191910
|
boundNames.delete(name);
|
|
191888
191911
|
return;
|
|
191889
191912
|
}
|
|
191890
|
-
|
|
191913
|
+
import_typescript10.default.forEachChild(n, visit2);
|
|
191891
191914
|
}
|
|
191892
191915
|
visit2(node);
|
|
191893
191916
|
return ids;
|
|
@@ -191896,29 +191919,29 @@ function extractFreeTypeIdentifiersFromNode(node) {
|
|
|
191896
191919
|
const ids = new Set;
|
|
191897
191920
|
const boundTypeParams = new Set;
|
|
191898
191921
|
function rootName(name) {
|
|
191899
|
-
return
|
|
191922
|
+
return import_typescript10.default.isQualifiedName(name) ? rootName(name.left) : name;
|
|
191900
191923
|
}
|
|
191901
191924
|
function visit2(n) {
|
|
191902
|
-
if (
|
|
191925
|
+
if (import_typescript10.default.isTypeReferenceNode(n)) {
|
|
191903
191926
|
const name = rootName(n.typeName).text;
|
|
191904
191927
|
if (!boundTypeParams.has(name))
|
|
191905
191928
|
ids.add(name);
|
|
191906
191929
|
}
|
|
191907
|
-
if (
|
|
191930
|
+
if (import_typescript10.default.isTypeQueryNode(n)) {
|
|
191908
191931
|
const name = rootName(n.exprName).text;
|
|
191909
191932
|
if (!boundTypeParams.has(name))
|
|
191910
191933
|
ids.add(name);
|
|
191911
191934
|
}
|
|
191912
|
-
if (
|
|
191935
|
+
if (import_typescript10.default.isFunctionLike(n) && n.typeParameters && n.typeParameters.length > 0) {
|
|
191913
191936
|
const names = n.typeParameters.map((p) => p.name.text);
|
|
191914
191937
|
for (const p of names)
|
|
191915
191938
|
boundTypeParams.add(p);
|
|
191916
|
-
|
|
191939
|
+
import_typescript10.default.forEachChild(n, visit2);
|
|
191917
191940
|
for (const p of names)
|
|
191918
191941
|
boundTypeParams.delete(p);
|
|
191919
191942
|
return;
|
|
191920
191943
|
}
|
|
191921
|
-
|
|
191944
|
+
import_typescript10.default.forEachChild(n, visit2);
|
|
191922
191945
|
}
|
|
191923
191946
|
visit2(node);
|
|
191924
191947
|
return ids;
|
|
@@ -191928,22 +191951,22 @@ function initializerShapeContainsJsx(node) {
|
|
|
191928
191951
|
function visit2(n) {
|
|
191929
191952
|
if (found)
|
|
191930
191953
|
return;
|
|
191931
|
-
if (
|
|
191954
|
+
if (import_typescript10.default.isJsxElement(n) || import_typescript10.default.isJsxSelfClosingElement(n) || import_typescript10.default.isJsxFragment(n)) {
|
|
191932
191955
|
found = true;
|
|
191933
191956
|
return;
|
|
191934
191957
|
}
|
|
191935
|
-
if (
|
|
191958
|
+
if (import_typescript10.default.isFunctionDeclaration(n) || import_typescript10.default.isFunctionExpression(n) || import_typescript10.default.isArrowFunction(n)) {
|
|
191936
191959
|
return;
|
|
191937
191960
|
}
|
|
191938
|
-
|
|
191961
|
+
import_typescript10.default.forEachChild(n, visit2);
|
|
191939
191962
|
}
|
|
191940
191963
|
visit2(node);
|
|
191941
191964
|
return found;
|
|
191942
191965
|
}
|
|
191943
191966
|
function isMapLikeCallWithJsx(node) {
|
|
191944
|
-
if (!
|
|
191967
|
+
if (!import_typescript10.default.isCallExpression(node))
|
|
191945
191968
|
return false;
|
|
191946
|
-
if (!
|
|
191969
|
+
if (!import_typescript10.default.isPropertyAccessExpression(node.expression))
|
|
191947
191970
|
return false;
|
|
191948
191971
|
const method = node.expression.name.text;
|
|
191949
191972
|
if (method !== "map" && method !== "flatMap")
|
|
@@ -191951,12 +191974,12 @@ function isMapLikeCallWithJsx(node) {
|
|
|
191951
191974
|
const callback = node.arguments[0];
|
|
191952
191975
|
if (!callback)
|
|
191953
191976
|
return false;
|
|
191954
|
-
if (!
|
|
191977
|
+
if (!import_typescript10.default.isArrowFunction(callback) && !import_typescript10.default.isFunctionExpression(callback))
|
|
191955
191978
|
return false;
|
|
191956
191979
|
return containsJsxDeep(callback.body);
|
|
191957
191980
|
}
|
|
191958
191981
|
function containsJsxDeep(node) {
|
|
191959
|
-
if (
|
|
191982
|
+
if (import_typescript10.default.isJsxElement(node) || import_typescript10.default.isJsxSelfClosingElement(node) || import_typescript10.default.isJsxFragment(node))
|
|
191960
191983
|
return true;
|
|
191961
191984
|
let found = false;
|
|
191962
191985
|
node.forEachChild((child) => {
|
|
@@ -191970,11 +191993,11 @@ function nodeContainsArrow(node) {
|
|
|
191970
191993
|
function visit2(n) {
|
|
191971
191994
|
if (found)
|
|
191972
191995
|
return;
|
|
191973
|
-
if (
|
|
191996
|
+
if (import_typescript10.default.isArrowFunction(n) || import_typescript10.default.isFunctionExpression(n)) {
|
|
191974
191997
|
found = true;
|
|
191975
191998
|
return;
|
|
191976
191999
|
}
|
|
191977
|
-
|
|
192000
|
+
import_typescript10.default.forEachChild(n, visit2);
|
|
191978
192001
|
}
|
|
191979
192002
|
visit2(node);
|
|
191980
192003
|
return found;
|
|
@@ -192022,28 +192045,30 @@ function collectModuleScopeReactive(decl, ctx, isExported) {
|
|
|
192022
192045
|
}));
|
|
192023
192046
|
}
|
|
192024
192047
|
function getSystemConstructKind(node) {
|
|
192025
|
-
if (
|
|
192048
|
+
if (import_typescript10.default.isCallExpression(node) && import_typescript10.default.isIdentifier(node.expression) && node.expression.text === "createContext")
|
|
192026
192049
|
return "createContext";
|
|
192027
|
-
if (
|
|
192050
|
+
if (import_typescript10.default.isNewExpression(node) && import_typescript10.default.isIdentifier(node.expression) && node.expression.text === "WeakMap")
|
|
192028
192051
|
return "weakMap";
|
|
192029
192052
|
return;
|
|
192030
192053
|
}
|
|
192031
192054
|
function collectConstant(node, ctx, _isModule, declarationKind = "const", isExported = false) {
|
|
192032
|
-
if (!_isModule &&
|
|
192055
|
+
if (!_isModule && import_typescript10.default.isObjectBindingPattern(node.name) && node.initializer && import_typescript10.default.isIdentifier(node.initializer) && ctx.propsObjectName === node.initializer.text) {
|
|
192033
192056
|
const propsName = node.initializer.text;
|
|
192034
192057
|
for (const el of node.name.elements) {
|
|
192035
|
-
if (!
|
|
192058
|
+
if (!import_typescript10.default.isBindingElement(el) || !import_typescript10.default.isIdentifier(el.name) || el.dotDotDotToken)
|
|
192036
192059
|
continue;
|
|
192037
192060
|
const localName = el.name.text;
|
|
192038
|
-
const sourceKey = el.propertyName &&
|
|
192061
|
+
const sourceKey = el.propertyName && import_typescript10.default.isIdentifier(el.propertyName) ? el.propertyName.text : localName;
|
|
192039
192062
|
const defaultValueExpr = el.initializer ? ctx.getJS(el.initializer) : undefined;
|
|
192040
192063
|
const baseValue = `${propsName}.${sourceKey}`;
|
|
192041
192064
|
const value2 = defaultValueExpr ? `${baseValue} ?? ${defaultValueExpr}` : baseValue;
|
|
192042
192065
|
const containsArrow2 = el.initializer ? nodeContainsArrow(el.initializer) : false;
|
|
192043
192066
|
const freeIdentifiers2 = el.initializer ? extractFreeIdentifiersFromNode(el.initializer) : new Set([propsName]);
|
|
192067
|
+
const parsed2 = parseExpression(`(${value2.trim()})`);
|
|
192044
192068
|
ctx.localConstants.push({
|
|
192045
192069
|
name: localName,
|
|
192046
192070
|
value: value2,
|
|
192071
|
+
parsed: parsed2,
|
|
192047
192072
|
declarationKind,
|
|
192048
192073
|
isExported,
|
|
192049
192074
|
type: null,
|
|
@@ -192055,7 +192080,7 @@ function collectConstant(node, ctx, _isModule, declarationKind = "const", isExpo
|
|
|
192055
192080
|
}
|
|
192056
192081
|
return;
|
|
192057
192082
|
}
|
|
192058
|
-
if (!
|
|
192083
|
+
if (!import_typescript10.default.isIdentifier(node.name))
|
|
192059
192084
|
return;
|
|
192060
192085
|
if (isSignalDeclaration(node, ctx) || isMemoDeclaration(node, ctx))
|
|
192061
192086
|
return;
|
|
@@ -192073,9 +192098,9 @@ function collectConstant(node, ctx, _isModule, declarationKind = "const", isExpo
|
|
|
192073
192098
|
let isJsxFunction = false;
|
|
192074
192099
|
if (node.initializer) {
|
|
192075
192100
|
let init = node.initializer;
|
|
192076
|
-
while (
|
|
192101
|
+
while (import_typescript10.default.isParenthesizedExpression(init))
|
|
192077
192102
|
init = init.expression;
|
|
192078
|
-
if (
|
|
192103
|
+
if (import_typescript10.default.isJsxElement(init) || import_typescript10.default.isJsxSelfClosingElement(init) || import_typescript10.default.isJsxFragment(init)) {
|
|
192079
192104
|
isJsx = true;
|
|
192080
192105
|
ctx.jsxConstants.set(name, init);
|
|
192081
192106
|
} else if (initializerShapeContainsJsx(init)) {
|
|
@@ -192083,9 +192108,9 @@ function collectConstant(node, ctx, _isModule, declarationKind = "const", isExpo
|
|
|
192083
192108
|
} else if (isMapLikeCallWithJsx(init)) {
|
|
192084
192109
|
ctx.inlineableJsxConsts.set(name, init);
|
|
192085
192110
|
}
|
|
192086
|
-
if (
|
|
192111
|
+
if (import_typescript10.default.isArrowFunction(init)) {
|
|
192087
192112
|
const arrowBody = init.body;
|
|
192088
|
-
if (
|
|
192113
|
+
if (import_typescript10.default.isBlock(arrowBody)) {
|
|
192089
192114
|
const jsxReturn = extractSingleJsxReturn(arrowBody);
|
|
192090
192115
|
if (jsxReturn) {
|
|
192091
192116
|
isJsxFunction = true;
|
|
@@ -192105,9 +192130,9 @@ function collectConstant(node, ctx, _isModule, declarationKind = "const", isExpo
|
|
|
192105
192130
|
}
|
|
192106
192131
|
} else {
|
|
192107
192132
|
let body = arrowBody;
|
|
192108
|
-
while (
|
|
192133
|
+
while (import_typescript10.default.isParenthesizedExpression(body))
|
|
192109
192134
|
body = body.expression;
|
|
192110
|
-
if (
|
|
192135
|
+
if (import_typescript10.default.isJsxElement(body) || import_typescript10.default.isJsxSelfClosingElement(body) || import_typescript10.default.isJsxFragment(body)) {
|
|
192111
192136
|
isJsxFunction = true;
|
|
192112
192137
|
ctx.jsxFunctions.set(name, {
|
|
192113
192138
|
jsxReturn: body,
|
|
@@ -192120,9 +192145,9 @@ function collectConstant(node, ctx, _isModule, declarationKind = "const", isExpo
|
|
|
192120
192145
|
let valueBranches;
|
|
192121
192146
|
if (node.initializer) {
|
|
192122
192147
|
let inner = node.initializer;
|
|
192123
|
-
while (
|
|
192148
|
+
while (import_typescript10.default.isParenthesizedExpression(inner))
|
|
192124
192149
|
inner = inner.expression;
|
|
192125
|
-
if (
|
|
192150
|
+
if (import_typescript10.default.isConditionalExpression(inner)) {
|
|
192126
192151
|
valueBranches = extractValueBranches(node.initializer, ctx);
|
|
192127
192152
|
}
|
|
192128
192153
|
}
|
|
@@ -192200,7 +192225,7 @@ function collectConstant(node, ctx, _isModule, declarationKind = "const", isExpo
|
|
|
192200
192225
|
function hasIgnoreDirective(node, sourceFile, ruleId) {
|
|
192201
192226
|
const checkComments = (targetNode) => {
|
|
192202
192227
|
const fullStart = targetNode.getFullStart();
|
|
192203
|
-
const leadingComments =
|
|
192228
|
+
const leadingComments = import_typescript10.default.getLeadingCommentRanges(sourceFile.getFullText(), fullStart);
|
|
192204
192229
|
if (!leadingComments)
|
|
192205
192230
|
return false;
|
|
192206
192231
|
for (const range of leadingComments) {
|
|
@@ -192213,10 +192238,10 @@ function hasIgnoreDirective(node, sourceFile, ruleId) {
|
|
|
192213
192238
|
};
|
|
192214
192239
|
if (checkComments(node))
|
|
192215
192240
|
return true;
|
|
192216
|
-
if (
|
|
192241
|
+
if (import_typescript10.default.isArrowFunction(node)) {
|
|
192217
192242
|
let current = node.parent;
|
|
192218
192243
|
while (current) {
|
|
192219
|
-
if (
|
|
192244
|
+
if (import_typescript10.default.isVariableStatement(current)) {
|
|
192220
192245
|
if (checkComments(current))
|
|
192221
192246
|
return true;
|
|
192222
192247
|
break;
|
|
@@ -192227,7 +192252,7 @@ function hasIgnoreDirective(node, sourceFile, ruleId) {
|
|
|
192227
192252
|
return false;
|
|
192228
192253
|
}
|
|
192229
192254
|
function extractProps(param, ctx) {
|
|
192230
|
-
if (
|
|
192255
|
+
if (import_typescript10.default.isObjectBindingPattern(param.name)) {
|
|
192231
192256
|
const componentNode = ctx.componentNode;
|
|
192232
192257
|
const ignored = !!(componentNode && hasIgnoreDirective(componentNode, ctx.sourceFile, "props-destructuring"));
|
|
192233
192258
|
ctx.propsDestructuring = {
|
|
@@ -192236,14 +192261,14 @@ function extractProps(param, ctx) {
|
|
|
192236
192261
|
};
|
|
192237
192262
|
const memberTypes = param.type ? collectMemberTypes(param.type, ctx) : null;
|
|
192238
192263
|
for (const element of param.name.elements) {
|
|
192239
|
-
if (
|
|
192264
|
+
if (import_typescript10.default.isBindingElement(element) && import_typescript10.default.isIdentifier(element.name)) {
|
|
192240
192265
|
const localName = element.name.text;
|
|
192241
192266
|
const defaultValue = element.initializer ? ctx.getJS(element.initializer) : undefined;
|
|
192242
192267
|
if (element.dotDotDotToken) {
|
|
192243
192268
|
ctx.restPropsName = localName;
|
|
192244
192269
|
continue;
|
|
192245
192270
|
}
|
|
192246
|
-
const sourcePropName = element.propertyName &&
|
|
192271
|
+
const sourcePropName = element.propertyName && import_typescript10.default.isIdentifier(element.propertyName) ? element.propertyName.text : localName;
|
|
192247
192272
|
const member = memberTypes?.get(sourcePropName);
|
|
192248
192273
|
const resolvedType = member?.type ?? { kind: "unknown", raw: "unknown" };
|
|
192249
192274
|
const defaultContainsArrow = element.initializer ? nodeContainsArrow(element.initializer) : false;
|
|
@@ -192267,7 +192292,7 @@ function extractProps(param, ctx) {
|
|
|
192267
192292
|
}
|
|
192268
192293
|
}
|
|
192269
192294
|
}
|
|
192270
|
-
if (
|
|
192295
|
+
if (import_typescript10.default.isIdentifier(param.name)) {
|
|
192271
192296
|
ctx.propsObjectName = param.name.text;
|
|
192272
192297
|
if (param.type) {
|
|
192273
192298
|
extractPropsFromType(param.type, ctx);
|
|
@@ -192278,24 +192303,24 @@ function extractProps(param, ctx) {
|
|
|
192278
192303
|
}
|
|
192279
192304
|
}
|
|
192280
192305
|
function collectTypeKeys(typeNode, ctx) {
|
|
192281
|
-
if (
|
|
192306
|
+
if (import_typescript10.default.isTypeLiteralNode(typeNode)) {
|
|
192282
192307
|
return collectKeysFromMembers(typeNode.members, ctx);
|
|
192283
192308
|
}
|
|
192284
|
-
if (
|
|
192309
|
+
if (import_typescript10.default.isTypeReferenceNode(typeNode)) {
|
|
192285
192310
|
const typeName = typeNode.typeName.getText(ctx.sourceFile);
|
|
192286
192311
|
const typeDecl = findTypeDeclaration(typeName, ctx.sourceFile);
|
|
192287
192312
|
if (!typeDecl)
|
|
192288
192313
|
return null;
|
|
192289
|
-
if (
|
|
192314
|
+
if (import_typescript10.default.isInterfaceDeclaration(typeDecl)) {
|
|
192290
192315
|
if (typeDecl.heritageClauses && typeDecl.heritageClauses.length > 0)
|
|
192291
192316
|
return null;
|
|
192292
192317
|
return collectKeysFromMembers(typeDecl.members, ctx);
|
|
192293
192318
|
}
|
|
192294
|
-
if (
|
|
192295
|
-
if (
|
|
192319
|
+
if (import_typescript10.default.isTypeAliasDeclaration(typeDecl)) {
|
|
192320
|
+
if (import_typescript10.default.isTypeLiteralNode(typeDecl.type)) {
|
|
192296
192321
|
return collectKeysFromMembers(typeDecl.type.members, ctx);
|
|
192297
192322
|
}
|
|
192298
|
-
if (
|
|
192323
|
+
if (import_typescript10.default.isIntersectionTypeNode(typeDecl.type)) {
|
|
192299
192324
|
return null;
|
|
192300
192325
|
}
|
|
192301
192326
|
}
|
|
@@ -192305,9 +192330,9 @@ function collectTypeKeys(typeNode, ctx) {
|
|
|
192305
192330
|
function collectKeysFromMembers(members, ctx) {
|
|
192306
192331
|
const keys = [];
|
|
192307
192332
|
for (const member of members) {
|
|
192308
|
-
if (
|
|
192333
|
+
if (import_typescript10.default.isIndexSignatureDeclaration(member))
|
|
192309
192334
|
return null;
|
|
192310
|
-
if (
|
|
192335
|
+
if (import_typescript10.default.isPropertySignature(member) && member.name) {
|
|
192311
192336
|
keys.push(member.name.getText(ctx.sourceFile));
|
|
192312
192337
|
}
|
|
192313
192338
|
}
|
|
@@ -192331,7 +192356,7 @@ function collectMemberTypes(typeNode, ctx) {
|
|
|
192331
192356
|
const fromMembers = (members) => {
|
|
192332
192357
|
const map = new Map;
|
|
192333
192358
|
for (const member of members) {
|
|
192334
|
-
if (
|
|
192359
|
+
if (import_typescript10.default.isPropertySignature(member) && member.name) {
|
|
192335
192360
|
const info = member.type ? typeNodeToTypeInfo(member.type, ctx.sourceFile) : null;
|
|
192336
192361
|
map.set(member.name.getText(ctx.sourceFile), {
|
|
192337
192362
|
type: info && isResolvableMemberType(info) ? info : null,
|
|
@@ -192341,35 +192366,35 @@ function collectMemberTypes(typeNode, ctx) {
|
|
|
192341
192366
|
}
|
|
192342
192367
|
return map;
|
|
192343
192368
|
};
|
|
192344
|
-
if (
|
|
192369
|
+
if (import_typescript10.default.isTypeLiteralNode(typeNode)) {
|
|
192345
192370
|
return fromMembers(typeNode.members);
|
|
192346
192371
|
}
|
|
192347
|
-
if (
|
|
192372
|
+
if (import_typescript10.default.isTypeReferenceNode(typeNode)) {
|
|
192348
192373
|
const typeName = typeNode.typeName.getText(ctx.sourceFile);
|
|
192349
192374
|
const typeDecl = findTypeDeclaration(typeName, ctx.sourceFile);
|
|
192350
192375
|
if (!typeDecl)
|
|
192351
192376
|
return null;
|
|
192352
|
-
if (
|
|
192377
|
+
if (import_typescript10.default.isInterfaceDeclaration(typeDecl)) {
|
|
192353
192378
|
return fromMembers(typeDecl.members);
|
|
192354
192379
|
}
|
|
192355
|
-
if (
|
|
192380
|
+
if (import_typescript10.default.isTypeAliasDeclaration(typeDecl) && import_typescript10.default.isTypeLiteralNode(typeDecl.type)) {
|
|
192356
192381
|
return fromMembers(typeDecl.type.members);
|
|
192357
192382
|
}
|
|
192358
192383
|
}
|
|
192359
192384
|
return null;
|
|
192360
192385
|
}
|
|
192361
192386
|
function extractPropsFromType(typeNode, ctx) {
|
|
192362
|
-
if (
|
|
192387
|
+
if (import_typescript10.default.isTypeLiteralNode(typeNode)) {
|
|
192363
192388
|
extractPropsFromTypeMembers(typeNode.members, ctx);
|
|
192364
192389
|
return;
|
|
192365
192390
|
}
|
|
192366
|
-
if (
|
|
192391
|
+
if (import_typescript10.default.isTypeReferenceNode(typeNode)) {
|
|
192367
192392
|
const typeName = typeNode.typeName.getText(ctx.sourceFile);
|
|
192368
192393
|
const typeDecl = findTypeDeclaration(typeName, ctx.sourceFile);
|
|
192369
192394
|
if (typeDecl) {
|
|
192370
|
-
if (
|
|
192395
|
+
if (import_typescript10.default.isInterfaceDeclaration(typeDecl)) {
|
|
192371
192396
|
extractPropsFromTypeMembers(typeDecl.members, ctx);
|
|
192372
|
-
} else if (
|
|
192397
|
+
} else if (import_typescript10.default.isTypeAliasDeclaration(typeDecl) && import_typescript10.default.isTypeLiteralNode(typeDecl.type)) {
|
|
192373
192398
|
extractPropsFromTypeMembers(typeDecl.type.members, ctx);
|
|
192374
192399
|
}
|
|
192375
192400
|
}
|
|
@@ -192377,7 +192402,7 @@ function extractPropsFromType(typeNode, ctx) {
|
|
|
192377
192402
|
}
|
|
192378
192403
|
function extractPropsFromTypeMembers(members, ctx) {
|
|
192379
192404
|
for (const member of members) {
|
|
192380
|
-
if (
|
|
192405
|
+
if (import_typescript10.default.isPropertySignature(member) && member.name) {
|
|
192381
192406
|
const propName = member.name.getText(ctx.sourceFile);
|
|
192382
192407
|
const isOptional = !!member.questionToken;
|
|
192383
192408
|
const propType = member.type ? typeNodeToTypeInfo(member.type, ctx.sourceFile) : { kind: "unknown", raw: "unknown" };
|
|
@@ -192393,17 +192418,17 @@ function extractPropsFromTypeMembers(members, ctx) {
|
|
|
192393
192418
|
function findTypeDeclaration(typeName, sourceFile) {
|
|
192394
192419
|
let result;
|
|
192395
192420
|
function visit2(node) {
|
|
192396
|
-
if (
|
|
192421
|
+
if (import_typescript10.default.isInterfaceDeclaration(node) && node.name.text === typeName) {
|
|
192397
192422
|
result = node;
|
|
192398
192423
|
return;
|
|
192399
192424
|
}
|
|
192400
|
-
if (
|
|
192425
|
+
if (import_typescript10.default.isTypeAliasDeclaration(node) && node.name.text === typeName) {
|
|
192401
192426
|
result = node;
|
|
192402
192427
|
return;
|
|
192403
192428
|
}
|
|
192404
|
-
|
|
192429
|
+
import_typescript10.default.forEachChild(node, visit2);
|
|
192405
192430
|
}
|
|
192406
|
-
|
|
192431
|
+
import_typescript10.default.forEachChild(sourceFile, visit2);
|
|
192407
192432
|
return result;
|
|
192408
192433
|
}
|
|
192409
192434
|
function inferTypeFromValue(value) {
|
|
@@ -192449,12 +192474,12 @@ function inferTypeFromValue(value) {
|
|
|
192449
192474
|
}
|
|
192450
192475
|
function collectCalledIdentifiers(code2) {
|
|
192451
192476
|
const called = new Set;
|
|
192452
|
-
const sf =
|
|
192477
|
+
const sf = import_typescript10.default.createSourceFile("__deps__.tsx", code2, import_typescript10.default.ScriptTarget.Latest, false, import_typescript10.default.ScriptKind.TSX);
|
|
192453
192478
|
const visit2 = (node) => {
|
|
192454
|
-
if (
|
|
192479
|
+
if (import_typescript10.default.isCallExpression(node) && import_typescript10.default.isIdentifier(node.expression)) {
|
|
192455
192480
|
called.add(node.expression.text);
|
|
192456
192481
|
}
|
|
192457
|
-
|
|
192482
|
+
import_typescript10.default.forEachChild(node, visit2);
|
|
192458
192483
|
};
|
|
192459
192484
|
visit2(sf);
|
|
192460
192485
|
return called;
|
|
@@ -192495,6 +192520,7 @@ function validateContext(ctx) {
|
|
|
192495
192520
|
}
|
|
192496
192521
|
validateInitStatementReferences(ctx);
|
|
192497
192522
|
validateReactiveFactoryCalls(ctx);
|
|
192523
|
+
validateNamespaceQualifiedPrimitives(ctx);
|
|
192498
192524
|
validateClientImports(ctx);
|
|
192499
192525
|
}
|
|
192500
192526
|
function validateClientImports(ctx) {
|
|
@@ -192551,16 +192577,16 @@ function isResolvableComponentSource(source) {
|
|
|
192551
192577
|
function collectJsxComponentTags(sourceFile) {
|
|
192552
192578
|
const tags = new Set;
|
|
192553
192579
|
function visit2(node) {
|
|
192554
|
-
if (
|
|
192580
|
+
if (import_typescript10.default.isJsxOpeningElement(node) || import_typescript10.default.isJsxSelfClosingElement(node)) {
|
|
192555
192581
|
const tagName = node.tagName;
|
|
192556
|
-
if (
|
|
192582
|
+
if (import_typescript10.default.isIdentifier(tagName)) {
|
|
192557
192583
|
const first = tagName.text.charAt(0);
|
|
192558
192584
|
if (first >= "A" && first <= "Z") {
|
|
192559
192585
|
tags.add(tagName.text);
|
|
192560
192586
|
}
|
|
192561
192587
|
}
|
|
192562
192588
|
}
|
|
192563
|
-
|
|
192589
|
+
import_typescript10.default.forEachChild(node, visit2);
|
|
192564
192590
|
}
|
|
192565
192591
|
visit2(sourceFile);
|
|
192566
192592
|
return tags;
|
|
@@ -192639,18 +192665,18 @@ function fileHasUseClientDirective(filePath) {
|
|
|
192639
192665
|
} catch {
|
|
192640
192666
|
return true;
|
|
192641
192667
|
}
|
|
192642
|
-
const sf =
|
|
192668
|
+
const sf = import_typescript10.default.createSourceFile(filePath, content, import_typescript10.default.ScriptTarget.Latest, false, import_typescript10.default.ScriptKind.TSX);
|
|
192643
192669
|
let found = false;
|
|
192644
192670
|
function visit2(node) {
|
|
192645
192671
|
if (found)
|
|
192646
192672
|
return;
|
|
192647
|
-
if (
|
|
192673
|
+
if (import_typescript10.default.isExpressionStatement(node) && import_typescript10.default.isStringLiteral(node.expression)) {
|
|
192648
192674
|
if (node.expression.text === "use client") {
|
|
192649
192675
|
found = true;
|
|
192650
192676
|
return;
|
|
192651
192677
|
}
|
|
192652
192678
|
}
|
|
192653
|
-
|
|
192679
|
+
import_typescript10.default.forEachChild(node, visit2);
|
|
192654
192680
|
}
|
|
192655
192681
|
visit2(sf);
|
|
192656
192682
|
return found;
|
|
@@ -192735,13 +192761,13 @@ var REACTIVE_PRIMITIVES = new Set([
|
|
|
192735
192761
|
"onCleanup"
|
|
192736
192762
|
]);
|
|
192737
192763
|
function prescanReactiveFactoriesInSource(source, filePath) {
|
|
192738
|
-
const sourceFile =
|
|
192764
|
+
const sourceFile = import_typescript10.default.createSourceFile(filePath + ".prescan", source, import_typescript10.default.ScriptTarget.Latest, true, import_typescript10.default.ScriptKind.TSX);
|
|
192739
192765
|
const factories = new Map;
|
|
192740
192766
|
const declined = new Map;
|
|
192741
192767
|
const reactiveShaped = new Set;
|
|
192742
192768
|
const cleanFactoryImports = new Set;
|
|
192743
192769
|
function visitTop(node) {
|
|
192744
|
-
if (
|
|
192770
|
+
if (import_typescript10.default.isFunctionDeclaration(node) && node.name && node.body) {
|
|
192745
192771
|
const det = detectReactiveFactory(node, sourceFile, filePath);
|
|
192746
192772
|
if (!det)
|
|
192747
192773
|
return;
|
|
@@ -192758,7 +192784,7 @@ function prescanReactiveFactoriesInSource(source, filePath) {
|
|
|
192758
192784
|
}
|
|
192759
192785
|
}
|
|
192760
192786
|
}
|
|
192761
|
-
|
|
192787
|
+
import_typescript10.default.forEachChild(sourceFile, visitTop);
|
|
192762
192788
|
const result = { factories, declined, reactiveShaped, cleanFactoryImports, sourceFile };
|
|
192763
192789
|
prescanImportedReactiveFactories(sourceFile, filePath, result);
|
|
192764
192790
|
return result;
|
|
@@ -192775,15 +192801,15 @@ function toComponentRelativeSpecifier(resolvedAbs, componentFilePath) {
|
|
|
192775
192801
|
function buildEntryImportIndex(sf, filePath) {
|
|
192776
192802
|
const index = new Map;
|
|
192777
192803
|
for (const stmt of sf.statements) {
|
|
192778
|
-
if (!
|
|
192804
|
+
if (!import_typescript10.default.isImportDeclaration(stmt))
|
|
192779
192805
|
continue;
|
|
192780
|
-
if (!
|
|
192806
|
+
if (!import_typescript10.default.isStringLiteral(stmt.moduleSpecifier))
|
|
192781
192807
|
continue;
|
|
192782
192808
|
const src = stmt.moduleSpecifier.text;
|
|
192783
192809
|
const targetKey = src.startsWith("./") || src.startsWith("../") ? resolveRelativeImportToFile(src, filePath) ?? "unresolved:" + src : src;
|
|
192784
192810
|
const wholeTypeOnly = stmt.importClause?.isTypeOnly === true;
|
|
192785
192811
|
const namedBindings = stmt.importClause?.namedBindings;
|
|
192786
|
-
if (namedBindings &&
|
|
192812
|
+
if (namedBindings && import_typescript10.default.isNamedImports(namedBindings)) {
|
|
192787
192813
|
for (const el of namedBindings.elements) {
|
|
192788
192814
|
index.set(el.name.text, {
|
|
192789
192815
|
targetKey,
|
|
@@ -192798,31 +192824,31 @@ function buildEntryImportIndex(sf, filePath) {
|
|
|
192798
192824
|
function collectEntryBindingNames(sf) {
|
|
192799
192825
|
const names = new Set;
|
|
192800
192826
|
function visit2(node) {
|
|
192801
|
-
if (
|
|
192827
|
+
if (import_typescript10.default.isImportDeclaration(node) && node.importClause) {
|
|
192802
192828
|
if (node.importClause.name)
|
|
192803
192829
|
names.add(node.importClause.name.text);
|
|
192804
192830
|
const namedBindings = node.importClause.namedBindings;
|
|
192805
|
-
if (namedBindings &&
|
|
192831
|
+
if (namedBindings && import_typescript10.default.isNamedImports(namedBindings)) {
|
|
192806
192832
|
for (const el of namedBindings.elements)
|
|
192807
192833
|
names.add(el.name.text);
|
|
192808
192834
|
}
|
|
192809
|
-
if (namedBindings &&
|
|
192835
|
+
if (namedBindings && import_typescript10.default.isNamespaceImport(namedBindings)) {
|
|
192810
192836
|
names.add(namedBindings.name.text);
|
|
192811
192837
|
}
|
|
192812
192838
|
}
|
|
192813
|
-
if (
|
|
192839
|
+
if (import_typescript10.default.isVariableDeclaration(node)) {
|
|
192814
192840
|
const out = [];
|
|
192815
192841
|
addBindingNames(node.name, out);
|
|
192816
192842
|
for (const n of out)
|
|
192817
192843
|
names.add(n);
|
|
192818
192844
|
}
|
|
192819
|
-
if ((
|
|
192845
|
+
if ((import_typescript10.default.isFunctionDeclaration(node) || import_typescript10.default.isClassDeclaration(node) || import_typescript10.default.isEnumDeclaration(node)) && node.name) {
|
|
192820
192846
|
names.add(node.name.text);
|
|
192821
192847
|
}
|
|
192822
|
-
if ((
|
|
192848
|
+
if ((import_typescript10.default.isTypeAliasDeclaration(node) || import_typescript10.default.isInterfaceDeclaration(node)) && node.name) {
|
|
192823
192849
|
names.add(node.name.text);
|
|
192824
192850
|
}
|
|
192825
|
-
if (
|
|
192851
|
+
if (import_typescript10.default.isFunctionLike(node)) {
|
|
192826
192852
|
for (const p of node.parameters) {
|
|
192827
192853
|
const out = [];
|
|
192828
192854
|
addBindingNames(p.name, out);
|
|
@@ -192830,7 +192856,7 @@ function collectEntryBindingNames(sf) {
|
|
|
192830
192856
|
names.add(n);
|
|
192831
192857
|
}
|
|
192832
192858
|
}
|
|
192833
|
-
|
|
192859
|
+
import_typescript10.default.forEachChild(node, visit2);
|
|
192834
192860
|
}
|
|
192835
192861
|
visit2(sf);
|
|
192836
192862
|
return names;
|
|
@@ -192839,19 +192865,19 @@ var MAX_REEXPORT_HOPS = 1;
|
|
|
192839
192865
|
function prescanImportedReactiveFactories(entrySourceFile, filePath, result) {
|
|
192840
192866
|
const candidateCallees = new Set;
|
|
192841
192867
|
function collectCandidates(node) {
|
|
192842
|
-
if (
|
|
192868
|
+
if (import_typescript10.default.isVariableDeclaration(node) && (import_typescript10.default.isArrayBindingPattern(node.name) || import_typescript10.default.isObjectBindingPattern(node.name)) && node.initializer && import_typescript10.default.isCallExpression(node.initializer) && import_typescript10.default.isIdentifier(node.initializer.expression)) {
|
|
192843
192869
|
candidateCallees.add(node.initializer.expression.text);
|
|
192844
192870
|
}
|
|
192845
|
-
|
|
192871
|
+
import_typescript10.default.forEachChild(node, collectCandidates);
|
|
192846
192872
|
}
|
|
192847
192873
|
collectCandidates(entrySourceFile);
|
|
192848
192874
|
if (candidateCallees.size === 0)
|
|
192849
192875
|
return;
|
|
192850
192876
|
const importsToCheck = [];
|
|
192851
192877
|
for (const stmt of entrySourceFile.statements) {
|
|
192852
|
-
if (!
|
|
192878
|
+
if (!import_typescript10.default.isImportDeclaration(stmt))
|
|
192853
192879
|
continue;
|
|
192854
|
-
if (!
|
|
192880
|
+
if (!import_typescript10.default.isStringLiteral(stmt.moduleSpecifier))
|
|
192855
192881
|
continue;
|
|
192856
192882
|
const src = stmt.moduleSpecifier.text;
|
|
192857
192883
|
if (!src.startsWith("./") && !src.startsWith("../"))
|
|
@@ -192859,7 +192885,7 @@ function prescanImportedReactiveFactories(entrySourceFile, filePath, result) {
|
|
|
192859
192885
|
if (stmt.importClause?.isTypeOnly)
|
|
192860
192886
|
continue;
|
|
192861
192887
|
const namedBindings = stmt.importClause?.namedBindings;
|
|
192862
|
-
if (!namedBindings || !
|
|
192888
|
+
if (!namedBindings || !import_typescript10.default.isNamedImports(namedBindings))
|
|
192863
192889
|
continue;
|
|
192864
192890
|
const specs = [];
|
|
192865
192891
|
for (const el of namedBindings.elements) {
|
|
@@ -192897,14 +192923,14 @@ function prescanImportedReactiveFactories(entrySourceFile, filePath, result) {
|
|
|
192897
192923
|
helperCache.set(abs, "clean");
|
|
192898
192924
|
return "clean";
|
|
192899
192925
|
}
|
|
192900
|
-
const sf =
|
|
192926
|
+
const sf = import_typescript10.default.createSourceFile(abs + ".prescan", content, import_typescript10.default.ScriptTarget.Latest, true, import_typescript10.default.ScriptKind.TSX);
|
|
192901
192927
|
const localFns = new Map;
|
|
192902
192928
|
const exportedFns = new Map;
|
|
192903
192929
|
for (const stmt of sf.statements) {
|
|
192904
|
-
if (
|
|
192930
|
+
if (import_typescript10.default.isFunctionDeclaration(stmt) && stmt.name && stmt.body) {
|
|
192905
192931
|
localFns.set(stmt.name.text, stmt);
|
|
192906
|
-
const hasExportModifier = stmt.modifiers?.some((m) => m.kind ===
|
|
192907
|
-
const hasDefaultModifier = stmt.modifiers?.some((m) => m.kind ===
|
|
192932
|
+
const hasExportModifier = stmt.modifiers?.some((m) => m.kind === import_typescript10.default.SyntaxKind.ExportKeyword) ?? false;
|
|
192933
|
+
const hasDefaultModifier = stmt.modifiers?.some((m) => m.kind === import_typescript10.default.SyntaxKind.DefaultKeyword) ?? false;
|
|
192908
192934
|
if (hasExportModifier && !hasDefaultModifier) {
|
|
192909
192935
|
exportedFns.set(stmt.name.text, stmt);
|
|
192910
192936
|
}
|
|
@@ -192913,10 +192939,10 @@ function prescanImportedReactiveFactories(entrySourceFile, filePath, result) {
|
|
|
192913
192939
|
const reexports = new Map;
|
|
192914
192940
|
let hasStarReexport = false;
|
|
192915
192941
|
for (const stmt of sf.statements) {
|
|
192916
|
-
if (!
|
|
192942
|
+
if (!import_typescript10.default.isExportDeclaration(stmt) || stmt.isTypeOnly)
|
|
192917
192943
|
continue;
|
|
192918
192944
|
if (!stmt.moduleSpecifier) {
|
|
192919
|
-
if (stmt.exportClause &&
|
|
192945
|
+
if (stmt.exportClause && import_typescript10.default.isNamedExports(stmt.exportClause)) {
|
|
192920
192946
|
for (const el of stmt.exportClause.elements) {
|
|
192921
192947
|
if (el.isTypeOnly)
|
|
192922
192948
|
continue;
|
|
@@ -192927,9 +192953,9 @@ function prescanImportedReactiveFactories(entrySourceFile, filePath, result) {
|
|
|
192927
192953
|
}
|
|
192928
192954
|
continue;
|
|
192929
192955
|
}
|
|
192930
|
-
if (!
|
|
192956
|
+
if (!import_typescript10.default.isStringLiteral(stmt.moduleSpecifier))
|
|
192931
192957
|
continue;
|
|
192932
|
-
if (stmt.exportClause &&
|
|
192958
|
+
if (stmt.exportClause && import_typescript10.default.isNamedExports(stmt.exportClause)) {
|
|
192933
192959
|
for (const el of stmt.exportClause.elements) {
|
|
192934
192960
|
if (el.isTypeOnly)
|
|
192935
192961
|
continue;
|
|
@@ -193079,7 +193105,7 @@ function collectHelperModuleValueBindings(sf) {
|
|
|
193079
193105
|
const importedTypes = new Map;
|
|
193080
193106
|
const imported = new Map;
|
|
193081
193107
|
for (const stmt of sf.statements) {
|
|
193082
|
-
if (
|
|
193108
|
+
if (import_typescript10.default.isVariableStatement(stmt)) {
|
|
193083
193109
|
const out = [];
|
|
193084
193110
|
for (const decl of stmt.declarationList.declarations) {
|
|
193085
193111
|
addBindingNames(decl.name, out);
|
|
@@ -193088,16 +193114,16 @@ function collectHelperModuleValueBindings(sf) {
|
|
|
193088
193114
|
local.add(n);
|
|
193089
193115
|
continue;
|
|
193090
193116
|
}
|
|
193091
|
-
if ((
|
|
193117
|
+
if ((import_typescript10.default.isFunctionDeclaration(stmt) || import_typescript10.default.isClassDeclaration(stmt) || import_typescript10.default.isEnumDeclaration(stmt)) && stmt.name) {
|
|
193092
193118
|
local.add(stmt.name.text);
|
|
193093
193119
|
continue;
|
|
193094
193120
|
}
|
|
193095
|
-
if ((
|
|
193121
|
+
if ((import_typescript10.default.isTypeAliasDeclaration(stmt) || import_typescript10.default.isInterfaceDeclaration(stmt)) && stmt.name) {
|
|
193096
193122
|
localTypes.add(stmt.name.text);
|
|
193097
193123
|
continue;
|
|
193098
193124
|
}
|
|
193099
|
-
if (
|
|
193100
|
-
if (!
|
|
193125
|
+
if (import_typescript10.default.isImportDeclaration(stmt)) {
|
|
193126
|
+
if (!import_typescript10.default.isStringLiteral(stmt.moduleSpecifier))
|
|
193101
193127
|
continue;
|
|
193102
193128
|
const src = stmt.moduleSpecifier.text;
|
|
193103
193129
|
if (src === "@barefootjs/client" || src === "@barefootjs/client/runtime")
|
|
@@ -193106,7 +193132,7 @@ function collectHelperModuleValueBindings(sf) {
|
|
|
193106
193132
|
if (stmt.importClause?.name)
|
|
193107
193133
|
(wholeTypeOnly ? localTypes : local).add(stmt.importClause.name.text);
|
|
193108
193134
|
const namedBindings = stmt.importClause?.namedBindings;
|
|
193109
|
-
if (namedBindings &&
|
|
193135
|
+
if (namedBindings && import_typescript10.default.isNamedImports(namedBindings)) {
|
|
193110
193136
|
for (const el of namedBindings.elements) {
|
|
193111
193137
|
const entry = { source: src, exportedName: (el.propertyName ?? el.name).text };
|
|
193112
193138
|
if (wholeTypeOnly || el.isTypeOnly)
|
|
@@ -193115,7 +193141,7 @@ function collectHelperModuleValueBindings(sf) {
|
|
|
193115
193141
|
imported.set(el.name.text, entry);
|
|
193116
193142
|
}
|
|
193117
193143
|
}
|
|
193118
|
-
if (namedBindings &&
|
|
193144
|
+
if (namedBindings && import_typescript10.default.isNamespaceImport(namedBindings)) {
|
|
193119
193145
|
(wholeTypeOnly ? localTypes : local).add(namedBindings.name.text);
|
|
193120
193146
|
}
|
|
193121
193147
|
}
|
|
@@ -193182,11 +193208,11 @@ function detectReactiveFactory(node, sourceFile, filePath) {
|
|
|
193182
193208
|
function checkForReactive(n) {
|
|
193183
193209
|
if (hasReactiveCall)
|
|
193184
193210
|
return;
|
|
193185
|
-
if (
|
|
193211
|
+
if (import_typescript10.default.isCallExpression(n) && import_typescript10.default.isIdentifier(n.expression) && REACTIVE_PRIMITIVES.has(n.expression.text)) {
|
|
193186
193212
|
hasReactiveCall = true;
|
|
193187
193213
|
return;
|
|
193188
193214
|
}
|
|
193189
|
-
|
|
193215
|
+
import_typescript10.default.forEachChild(n, checkForReactive);
|
|
193190
193216
|
}
|
|
193191
193217
|
checkForReactive(node.body);
|
|
193192
193218
|
if (!hasReactiveCall)
|
|
@@ -193194,29 +193220,29 @@ function detectReactiveFactory(node, sourceFile, filePath) {
|
|
|
193194
193220
|
const loc = getSourceLocation(node, sourceFile, filePath);
|
|
193195
193221
|
let totalReturnCount = 0;
|
|
193196
193222
|
function countReturns(n) {
|
|
193197
|
-
if (
|
|
193223
|
+
if (import_typescript10.default.isFunctionLike(n))
|
|
193198
193224
|
return;
|
|
193199
|
-
if (
|
|
193225
|
+
if (import_typescript10.default.isReturnStatement(n)) {
|
|
193200
193226
|
totalReturnCount++;
|
|
193201
193227
|
return;
|
|
193202
193228
|
}
|
|
193203
|
-
|
|
193229
|
+
import_typescript10.default.forEachChild(n, countReturns);
|
|
193204
193230
|
}
|
|
193205
|
-
|
|
193231
|
+
import_typescript10.default.forEachChild(node.body, countReturns);
|
|
193206
193232
|
let returnExpr = null;
|
|
193207
193233
|
let returnCount = 0;
|
|
193208
193234
|
for (const stmt of node.body.statements) {
|
|
193209
|
-
if (!
|
|
193235
|
+
if (!import_typescript10.default.isReturnStatement(stmt))
|
|
193210
193236
|
continue;
|
|
193211
193237
|
returnCount++;
|
|
193212
193238
|
if (!stmt.expression)
|
|
193213
193239
|
return { kind: "reactive-shaped" };
|
|
193214
193240
|
let expr = stmt.expression;
|
|
193215
|
-
while (
|
|
193241
|
+
while (import_typescript10.default.isParenthesizedExpression(expr))
|
|
193216
193242
|
expr = expr.expression;
|
|
193217
|
-
if (
|
|
193243
|
+
if (import_typescript10.default.isAsExpression(expr))
|
|
193218
193244
|
expr = expr.expression;
|
|
193219
|
-
if (
|
|
193245
|
+
if (import_typescript10.default.isTypeAssertionExpression(expr))
|
|
193220
193246
|
expr = expr.expression;
|
|
193221
193247
|
returnExpr = expr;
|
|
193222
193248
|
}
|
|
@@ -193224,18 +193250,18 @@ function detectReactiveFactory(node, sourceFile, filePath) {
|
|
|
193224
193250
|
return { kind: "reactive-shaped" };
|
|
193225
193251
|
const returnTupleIdentifiers = [];
|
|
193226
193252
|
let returnKind;
|
|
193227
|
-
if (
|
|
193253
|
+
if (import_typescript10.default.isArrayLiteralExpression(returnExpr)) {
|
|
193228
193254
|
returnKind = "tuple";
|
|
193229
193255
|
for (const el of returnExpr.elements) {
|
|
193230
|
-
if (!
|
|
193256
|
+
if (!import_typescript10.default.isIdentifier(el))
|
|
193231
193257
|
return { kind: "reactive-shaped" };
|
|
193232
193258
|
returnTupleIdentifiers.push(el.text);
|
|
193233
193259
|
}
|
|
193234
193260
|
if (returnTupleIdentifiers.length === 0)
|
|
193235
193261
|
return { kind: "reactive-shaped" };
|
|
193236
|
-
} else if (
|
|
193262
|
+
} else if (import_typescript10.default.isObjectLiteralExpression(returnExpr)) {
|
|
193237
193263
|
returnKind = "object";
|
|
193238
|
-
const hasNonShorthand = returnExpr.properties.some((p) => !
|
|
193264
|
+
const hasNonShorthand = returnExpr.properties.some((p) => !import_typescript10.default.isShorthandPropertyAssignment(p));
|
|
193239
193265
|
if (hasNonShorthand) {
|
|
193240
193266
|
return {
|
|
193241
193267
|
kind: "declined",
|
|
@@ -193256,7 +193282,7 @@ function detectReactiveFactory(node, sourceFile, filePath) {
|
|
|
193256
193282
|
}
|
|
193257
193283
|
const params = [];
|
|
193258
193284
|
for (const p of node.parameters) {
|
|
193259
|
-
if (
|
|
193285
|
+
if (import_typescript10.default.isIdentifier(p.name)) {
|
|
193260
193286
|
params.push(p.name.text);
|
|
193261
193287
|
continue;
|
|
193262
193288
|
}
|
|
@@ -193264,11 +193290,11 @@ function detectReactiveFactory(node, sourceFile, filePath) {
|
|
|
193264
193290
|
}
|
|
193265
193291
|
const localBindings = [];
|
|
193266
193292
|
for (const stmt of node.body.statements) {
|
|
193267
|
-
if (
|
|
193293
|
+
if (import_typescript10.default.isVariableStatement(stmt)) {
|
|
193268
193294
|
for (const decl of stmt.declarationList.declarations) {
|
|
193269
193295
|
addBindingNames(decl.name, localBindings);
|
|
193270
193296
|
}
|
|
193271
|
-
} else if (
|
|
193297
|
+
} else if (import_typescript10.default.isFunctionDeclaration(stmt) && stmt.name) {
|
|
193272
193298
|
localBindings.push(stmt.name.text);
|
|
193273
193299
|
}
|
|
193274
193300
|
}
|
|
@@ -193288,47 +193314,47 @@ function detectReactiveFactory(node, sourceFile, filePath) {
|
|
|
193288
193314
|
if (!relevantNames.has(id.text))
|
|
193289
193315
|
return;
|
|
193290
193316
|
const p = id.parent;
|
|
193291
|
-
if (
|
|
193317
|
+
if (import_typescript10.default.isPropertyAccessExpression(p) && p.name === id)
|
|
193292
193318
|
return;
|
|
193293
|
-
if (
|
|
193319
|
+
if (import_typescript10.default.isPropertyAssignment(p) && p.name === id)
|
|
193294
193320
|
return;
|
|
193295
|
-
if (
|
|
193321
|
+
if (import_typescript10.default.isBindingElement(p) && p.propertyName === id)
|
|
193296
193322
|
return;
|
|
193297
|
-
if ((
|
|
193323
|
+
if ((import_typescript10.default.isMethodDeclaration(p) || import_typescript10.default.isGetAccessorDeclaration(p) || import_typescript10.default.isSetAccessorDeclaration(p) || import_typescript10.default.isPropertyDeclaration(p) || import_typescript10.default.isEnumMember(p)) && p.name === id)
|
|
193298
193324
|
return;
|
|
193299
|
-
if (
|
|
193325
|
+
if (import_typescript10.default.isJsxAttribute(p) && p.name === id)
|
|
193300
193326
|
return;
|
|
193301
|
-
if (
|
|
193327
|
+
if (import_typescript10.default.isLabeledStatement(p) && p.label === id || (import_typescript10.default.isBreakStatement(p) || import_typescript10.default.isContinueStatement(p)) && p.label === id)
|
|
193302
193328
|
return;
|
|
193303
|
-
if ((
|
|
193329
|
+
if ((import_typescript10.default.isJsxOpeningElement(p) || import_typescript10.default.isJsxSelfClosingElement(p) || import_typescript10.default.isJsxClosingElement(p)) && p.tagName === id && /^[a-z]/.test(id.text))
|
|
193304
193330
|
return;
|
|
193305
|
-
if (
|
|
193331
|
+
if (import_typescript10.default.isShorthandPropertyAssignment(p) && p.name === id) {
|
|
193306
193332
|
push(id, "shorthand");
|
|
193307
193333
|
return;
|
|
193308
193334
|
}
|
|
193309
|
-
if (
|
|
193335
|
+
if (import_typescript10.default.isBindingElement(p) && p.name === id && !p.propertyName && import_typescript10.default.isObjectBindingPattern(p.parent)) {
|
|
193310
193336
|
if (params.includes(id.text))
|
|
193311
193337
|
shadowedParam = id.text;
|
|
193312
193338
|
push(id, "shorthand");
|
|
193313
193339
|
return;
|
|
193314
193340
|
}
|
|
193315
|
-
const isDecl = (
|
|
193341
|
+
const isDecl = (import_typescript10.default.isVariableDeclaration(p) || import_typescript10.default.isParameter(p) || import_typescript10.default.isBindingElement(p) || import_typescript10.default.isFunctionDeclaration(p) || import_typescript10.default.isFunctionExpression(p) || import_typescript10.default.isClassDeclaration(p) || import_typescript10.default.isClassExpression(p)) && p.name === id;
|
|
193316
193342
|
if (isDecl && params.includes(id.text))
|
|
193317
193343
|
shadowedParam = id.text;
|
|
193318
193344
|
push(id, "plain");
|
|
193319
193345
|
}
|
|
193320
193346
|
function visit2(n) {
|
|
193321
|
-
if (
|
|
193347
|
+
if (import_typescript10.default.isTypeNode(n) || import_typescript10.default.isTypeParameterDeclaration(n) || import_typescript10.default.isTypeAliasDeclaration(n) || import_typescript10.default.isInterfaceDeclaration(n))
|
|
193322
193348
|
return;
|
|
193323
|
-
if (
|
|
193349
|
+
if (import_typescript10.default.isIdentifier(n)) {
|
|
193324
193350
|
classify(n);
|
|
193325
193351
|
return;
|
|
193326
193352
|
}
|
|
193327
|
-
|
|
193353
|
+
import_typescript10.default.forEachChild(n, visit2);
|
|
193328
193354
|
}
|
|
193329
193355
|
visit2(root);
|
|
193330
193356
|
}
|
|
193331
|
-
const keptStatements = node.body.statements.filter((s) => !
|
|
193357
|
+
const keptStatements = node.body.statements.filter((s) => !import_typescript10.default.isReturnStatement(s));
|
|
193332
193358
|
const pieces = [];
|
|
193333
193359
|
let base = 0;
|
|
193334
193360
|
for (const stmt of keptStatements) {
|
|
@@ -193376,18 +193402,18 @@ function detectReactiveFactory(node, sourceFile, filePath) {
|
|
|
193376
193402
|
};
|
|
193377
193403
|
}
|
|
193378
193404
|
function addBindingNames(name, out) {
|
|
193379
|
-
if (
|
|
193405
|
+
if (import_typescript10.default.isIdentifier(name)) {
|
|
193380
193406
|
out.push(name.text);
|
|
193381
193407
|
return;
|
|
193382
193408
|
}
|
|
193383
|
-
if (
|
|
193409
|
+
if (import_typescript10.default.isObjectBindingPattern(name)) {
|
|
193384
193410
|
for (const el of name.elements)
|
|
193385
193411
|
addBindingNames(el.name, out);
|
|
193386
193412
|
return;
|
|
193387
193413
|
}
|
|
193388
|
-
if (
|
|
193414
|
+
if (import_typescript10.default.isArrayBindingPattern(name)) {
|
|
193389
193415
|
for (const el of name.elements) {
|
|
193390
|
-
if (
|
|
193416
|
+
if (import_typescript10.default.isOmittedExpression(el))
|
|
193391
193417
|
continue;
|
|
193392
193418
|
addBindingNames(el.name, out);
|
|
193393
193419
|
}
|
|
@@ -193399,33 +193425,33 @@ function rewriteFactoryCallsInSource(source, prescan) {
|
|
|
193399
193425
|
let callSiteIndex = 0;
|
|
193400
193426
|
const inlinedFactories = new Set;
|
|
193401
193427
|
function visitStmt(node, inComponent) {
|
|
193402
|
-
if (
|
|
193428
|
+
if (import_typescript10.default.isVariableStatement(node) && inComponent) {
|
|
193403
193429
|
for (const decl of node.declarationList.declarations) {
|
|
193404
193430
|
maybeRewriteDecl(node, decl);
|
|
193405
193431
|
}
|
|
193406
193432
|
}
|
|
193407
|
-
|
|
193408
|
-
if (
|
|
193433
|
+
import_typescript10.default.forEachChild(node, (child) => {
|
|
193434
|
+
if (import_typescript10.default.isFunctionDeclaration(child) && child.name && factories.has(child.name.text))
|
|
193409
193435
|
return;
|
|
193410
193436
|
visitStmt(child, inComponent || isPascalCaseComponentFn(child));
|
|
193411
193437
|
});
|
|
193412
193438
|
}
|
|
193413
193439
|
function maybeRewriteDecl(stmt, decl) {
|
|
193414
|
-
if (!decl.initializer || !
|
|
193440
|
+
if (!decl.initializer || !import_typescript10.default.isCallExpression(decl.initializer))
|
|
193415
193441
|
return;
|
|
193416
|
-
if (!
|
|
193442
|
+
if (!import_typescript10.default.isIdentifier(decl.initializer.expression))
|
|
193417
193443
|
return;
|
|
193418
193444
|
const factoryName = decl.initializer.expression.text;
|
|
193419
193445
|
const factory = factories.get(factoryName);
|
|
193420
193446
|
if (!factory)
|
|
193421
193447
|
return;
|
|
193422
|
-
if (
|
|
193448
|
+
if (import_typescript10.default.isArrayBindingPattern(decl.name)) {
|
|
193423
193449
|
if (factory.returnKind !== "tuple")
|
|
193424
193450
|
return;
|
|
193425
193451
|
rewriteTupleDecl(stmt, decl.name, decl.initializer, factory);
|
|
193426
193452
|
return;
|
|
193427
193453
|
}
|
|
193428
|
-
if (
|
|
193454
|
+
if (import_typescript10.default.isObjectBindingPattern(decl.name)) {
|
|
193429
193455
|
if (factory.returnKind !== "object")
|
|
193430
193456
|
return;
|
|
193431
193457
|
rewriteObjectDecl(stmt, decl.name, decl.initializer, factory);
|
|
@@ -193438,7 +193464,7 @@ function rewriteFactoryCallsInSource(source, prescan) {
|
|
|
193438
193464
|
return;
|
|
193439
193465
|
const callerNames = [];
|
|
193440
193466
|
for (const el of elements) {
|
|
193441
|
-
if (
|
|
193467
|
+
if (import_typescript10.default.isOmittedExpression(el) || !import_typescript10.default.isIdentifier(el.name))
|
|
193442
193468
|
return;
|
|
193443
193469
|
callerNames.push(el.name.text);
|
|
193444
193470
|
}
|
|
@@ -193460,7 +193486,7 @@ function rewriteFactoryCallsInSource(source, prescan) {
|
|
|
193460
193486
|
return;
|
|
193461
193487
|
if (el.initializer)
|
|
193462
193488
|
return;
|
|
193463
|
-
if (!
|
|
193489
|
+
if (!import_typescript10.default.isIdentifier(el.name))
|
|
193464
193490
|
return;
|
|
193465
193491
|
if (!factory.returnTupleIdentifiers.includes(el.name.text))
|
|
193466
193492
|
return;
|
|
@@ -193569,21 +193595,21 @@ function factoryImportInsertionOffset(sf) {
|
|
|
193569
193595
|
let lastImportEnd = -1;
|
|
193570
193596
|
let directiveEnd = -1;
|
|
193571
193597
|
for (const stmt of sf.statements) {
|
|
193572
|
-
if (
|
|
193598
|
+
if (import_typescript10.default.isImportDeclaration(stmt)) {
|
|
193573
193599
|
lastImportEnd = stmt.getEnd();
|
|
193574
193600
|
continue;
|
|
193575
193601
|
}
|
|
193576
|
-
if (directiveEnd === -1 &&
|
|
193602
|
+
if (directiveEnd === -1 && import_typescript10.default.isExpressionStatement(stmt) && import_typescript10.default.isStringLiteral(stmt.expression) && stmt.expression.text === "use client") {
|
|
193577
193603
|
directiveEnd = stmt.getEnd();
|
|
193578
193604
|
}
|
|
193579
193605
|
}
|
|
193580
193606
|
return lastImportEnd >= 0 ? lastImportEnd : directiveEnd >= 0 ? directiveEnd : 0;
|
|
193581
193607
|
}
|
|
193582
193608
|
function isPascalCaseComponentFn(node) {
|
|
193583
|
-
if (
|
|
193609
|
+
if (import_typescript10.default.isFunctionDeclaration(node) && node.name) {
|
|
193584
193610
|
return /^[A-Z]/.test(node.name.text);
|
|
193585
193611
|
}
|
|
193586
|
-
if (
|
|
193612
|
+
if (import_typescript10.default.isVariableDeclaration(node) && import_typescript10.default.isIdentifier(node.name) && node.initializer && import_typescript10.default.isArrowFunction(node.initializer)) {
|
|
193587
193613
|
return /^[A-Z]/.test(node.name.text);
|
|
193588
193614
|
}
|
|
193589
193615
|
return false;
|
|
@@ -193612,20 +193638,20 @@ function declinedFactoryErrorCode(code2) {
|
|
|
193612
193638
|
function validateReactiveFactoryCalls(ctx) {
|
|
193613
193639
|
if (!ctx.componentNode)
|
|
193614
193640
|
return;
|
|
193615
|
-
const body =
|
|
193641
|
+
const body = import_typescript10.default.isFunctionDeclaration(ctx.componentNode) ? ctx.componentNode.body : import_typescript10.default.isBlock(ctx.componentNode.body) ? ctx.componentNode.body : null;
|
|
193616
193642
|
if (!body)
|
|
193617
193643
|
return;
|
|
193618
193644
|
for (const stmt of body.statements) {
|
|
193619
|
-
if (!
|
|
193645
|
+
if (!import_typescript10.default.isVariableStatement(stmt))
|
|
193620
193646
|
continue;
|
|
193621
193647
|
for (const decl of stmt.declarationList.declarations) {
|
|
193622
|
-
if (!decl.initializer || !
|
|
193648
|
+
if (!decl.initializer || !import_typescript10.default.isCallExpression(decl.initializer))
|
|
193623
193649
|
continue;
|
|
193624
|
-
if (!
|
|
193650
|
+
if (!import_typescript10.default.isIdentifier(decl.initializer.expression))
|
|
193625
193651
|
continue;
|
|
193626
193652
|
const callee = decl.initializer.expression.text;
|
|
193627
193653
|
const loc = getSourceLocation(stmt, ctx.sourceFile, ctx.filePath);
|
|
193628
|
-
if (
|
|
193654
|
+
if (import_typescript10.default.isArrayBindingPattern(decl.name)) {
|
|
193629
193655
|
if (callee === "createSignal" || callee === "createMemo")
|
|
193630
193656
|
continue;
|
|
193631
193657
|
if (resolveEnvSignalKey(decl.initializer, ctx))
|
|
@@ -193652,12 +193678,77 @@ function validateReactiveFactoryCalls(ctx) {
|
|
|
193652
193678
|
}));
|
|
193653
193679
|
continue;
|
|
193654
193680
|
}
|
|
193655
|
-
if (
|
|
193681
|
+
if (import_typescript10.default.isObjectBindingPattern(decl.name)) {
|
|
193656
193682
|
validateObjectFactoryDestructure(ctx, decl.name, callee, loc);
|
|
193657
193683
|
}
|
|
193658
193684
|
}
|
|
193659
193685
|
}
|
|
193660
193686
|
}
|
|
193687
|
+
function validateNamespaceQualifiedPrimitives(ctx) {
|
|
193688
|
+
if (!ctx.componentNode)
|
|
193689
|
+
return;
|
|
193690
|
+
const body = import_typescript10.default.isFunctionDeclaration(ctx.componentNode) ? ctx.componentNode.body : import_typescript10.default.isBlock(ctx.componentNode.body) ? ctx.componentNode.body : null;
|
|
193691
|
+
if (!body)
|
|
193692
|
+
return;
|
|
193693
|
+
for (const stmt of body.statements) {
|
|
193694
|
+
const calls = [];
|
|
193695
|
+
if (import_typescript10.default.isVariableStatement(stmt)) {
|
|
193696
|
+
for (const decl of stmt.declarationList.declarations) {
|
|
193697
|
+
let init = decl.initializer;
|
|
193698
|
+
if (init && import_typescript10.default.isElementAccessExpression(init))
|
|
193699
|
+
init = init.expression;
|
|
193700
|
+
if (init && import_typescript10.default.isCallExpression(init))
|
|
193701
|
+
calls.push(init);
|
|
193702
|
+
}
|
|
193703
|
+
} else if (import_typescript10.default.isExpressionStatement(stmt) && import_typescript10.default.isCallExpression(stmt.expression)) {
|
|
193704
|
+
calls.push(stmt.expression);
|
|
193705
|
+
}
|
|
193706
|
+
for (const call of calls) {
|
|
193707
|
+
const callee = call.expression;
|
|
193708
|
+
if (!import_typescript10.default.isPropertyAccessExpression(callee) || !import_typescript10.default.isIdentifier(callee.expression))
|
|
193709
|
+
continue;
|
|
193710
|
+
const primitive = callee.name.text;
|
|
193711
|
+
if (!(primitive in PRIMITIVE_CANONICAL_NAMES))
|
|
193712
|
+
continue;
|
|
193713
|
+
if (resolvePrimitiveKind(call, ctx) !== null)
|
|
193714
|
+
continue;
|
|
193715
|
+
const ns = callee.expression.text;
|
|
193716
|
+
if (!isClientNamespaceImportName(ns, ctx))
|
|
193717
|
+
continue;
|
|
193718
|
+
if (isNamespaceNameShadowedAtComponentTopLevel(ns, body, ctx))
|
|
193719
|
+
continue;
|
|
193720
|
+
const loc = getSourceLocation(stmt, ctx.sourceFile, ctx.filePath);
|
|
193721
|
+
ctx.errors.push(createError(ErrorCodes.PRIMITIVE_VIA_NAMESPACE_IMPORT, loc, {
|
|
193722
|
+
severity: "error",
|
|
193723
|
+
message: `'${ns}.${primitive}(...)' calls a @barefootjs/client reactive primitive through the namespace ` + `import 'import * as ${ns}' and was not recognized by the analyzer. The declaration is dropped ` + `from the compiled output and every reference to it throws ReferenceError at hydrate.`,
|
|
193724
|
+
suggestion: {
|
|
193725
|
+
message: `Import the primitive by name: import { ${primitive} } from '@barefootjs/client' and call ` + `${primitive}(...) directly. (A shared ts.Program passed via CompileOptions.program lets the ` + `analyzer resolve the namespace through the TypeChecker; without one the named form is required.)`,
|
|
193726
|
+
escape: [{ kind: "rewrite" }]
|
|
193727
|
+
}
|
|
193728
|
+
}));
|
|
193729
|
+
}
|
|
193730
|
+
}
|
|
193731
|
+
}
|
|
193732
|
+
function isClientNamespaceImportName(name, ctx) {
|
|
193733
|
+
return ctx.imports.some((imp) => imp.source === "@barefootjs/client" && !imp.isTypeOnly && imp.specifiers.some((s) => s.isNamespace && s.name === name));
|
|
193734
|
+
}
|
|
193735
|
+
function isNamespaceNameShadowedAtComponentTopLevel(name, body, ctx) {
|
|
193736
|
+
if (ctx.propsObjectName === name)
|
|
193737
|
+
return true;
|
|
193738
|
+
if (ctx.propsParams.some((p) => p.name === name))
|
|
193739
|
+
return true;
|
|
193740
|
+
for (const stmt of body.statements) {
|
|
193741
|
+
if (import_typescript10.default.isFunctionDeclaration(stmt) && stmt.name?.text === name)
|
|
193742
|
+
return true;
|
|
193743
|
+
if (import_typescript10.default.isVariableStatement(stmt)) {
|
|
193744
|
+
for (const decl of stmt.declarationList.declarations) {
|
|
193745
|
+
if (import_typescript10.default.isIdentifier(decl.name) && decl.name.text === name)
|
|
193746
|
+
return true;
|
|
193747
|
+
}
|
|
193748
|
+
}
|
|
193749
|
+
}
|
|
193750
|
+
return false;
|
|
193751
|
+
}
|
|
193661
193752
|
function validateObjectFactoryDestructure(ctx, pattern, callee, loc) {
|
|
193662
193753
|
const factory = ctx.reactiveFactories.get(callee);
|
|
193663
193754
|
if (factory) {
|
|
@@ -193668,7 +193759,7 @@ function validateObjectFactoryDestructure(ctx, pattern, callee, loc) {
|
|
|
193668
193759
|
}));
|
|
193669
193760
|
return;
|
|
193670
193761
|
}
|
|
193671
|
-
const hasUnsupportedElement = pattern.elements.some((el) => !!el.propertyName || !!el.initializer || !!el.dotDotDotToken || !
|
|
193762
|
+
const hasUnsupportedElement = pattern.elements.some((el) => !!el.propertyName || !!el.initializer || !!el.dotDotDotToken || !import_typescript10.default.isIdentifier(el.name));
|
|
193672
193763
|
if (hasUnsupportedElement) {
|
|
193673
193764
|
ctx.errors.push(createError(ErrorCodes.REACTIVE_FACTORY_RENAME_UNSUPPORTED, loc, {
|
|
193674
193765
|
severity: "error",
|
|
@@ -193676,7 +193767,7 @@ function validateObjectFactoryDestructure(ctx, pattern, callee, loc) {
|
|
|
193676
193767
|
}));
|
|
193677
193768
|
return;
|
|
193678
193769
|
}
|
|
193679
|
-
const unknown = pattern.elements.map((el) =>
|
|
193770
|
+
const unknown = pattern.elements.map((el) => import_typescript10.default.isIdentifier(el.name) ? el.name.text : "").filter((name) => name && !factory.returnTupleIdentifiers.includes(name));
|
|
193680
193771
|
if (unknown.length > 0) {
|
|
193681
193772
|
const label = unknown.length === 1 ? "property" : "properties";
|
|
193682
193773
|
ctx.errors.push(createError(ErrorCodes.UNRECOGNIZED_REACTIVE_FACTORY, loc, {
|
|
@@ -193720,7 +193811,7 @@ function validateObjectFactoryDestructure(ctx, pattern, callee, loc) {
|
|
|
193720
193811
|
}
|
|
193721
193812
|
|
|
193722
193813
|
// ../jsx/src/jsx-to-ir.ts
|
|
193723
|
-
var
|
|
193814
|
+
var import_typescript14 = __toESM(require_typescript(), 1);
|
|
193724
193815
|
|
|
193725
193816
|
// ../jsx/src/types.ts
|
|
193726
193817
|
var SCOPE_FORBIDDEN = {
|
|
@@ -193796,7 +193887,7 @@ var AttrValueOf = {
|
|
|
193796
193887
|
};
|
|
193797
193888
|
|
|
193798
193889
|
// ../jsx/src/module-exports.ts
|
|
193799
|
-
var
|
|
193890
|
+
var import_typescript11 = __toESM(require_typescript(), 1);
|
|
193800
193891
|
function formatParamWithType(p) {
|
|
193801
193892
|
const rest = p.isRest ? "..." : "";
|
|
193802
193893
|
const optional = p.optional ? "?" : "";
|
|
@@ -193831,21 +193922,21 @@ function findAssignedNames(bodyText, candidates) {
|
|
|
193831
193922
|
const assigned = new Set;
|
|
193832
193923
|
if (candidates.size === 0)
|
|
193833
193924
|
return assigned;
|
|
193834
|
-
const sf =
|
|
193925
|
+
const sf = import_typescript11.default.createSourceFile("bf-assignment-scan.tsx", bodyText, import_typescript11.default.ScriptTarget.Latest, false, import_typescript11.default.ScriptKind.TSX);
|
|
193835
193926
|
const record = (target) => {
|
|
193836
|
-
if (
|
|
193927
|
+
if (import_typescript11.default.isIdentifier(target) && candidates.has(target.text)) {
|
|
193837
193928
|
assigned.add(target.text);
|
|
193838
193929
|
}
|
|
193839
193930
|
};
|
|
193840
193931
|
const visit2 = (node) => {
|
|
193841
|
-
if (
|
|
193932
|
+
if (import_typescript11.default.isBinaryExpression(node) && isAssignmentOperator(node.operatorToken.kind)) {
|
|
193842
193933
|
record(node.left);
|
|
193843
|
-
} else if ((
|
|
193934
|
+
} else if ((import_typescript11.default.isPrefixUnaryExpression(node) || import_typescript11.default.isPostfixUnaryExpression(node)) && (node.operator === import_typescript11.default.SyntaxKind.PlusPlusToken || node.operator === import_typescript11.default.SyntaxKind.MinusMinusToken)) {
|
|
193844
193935
|
record(node.operand);
|
|
193845
193936
|
}
|
|
193846
|
-
|
|
193937
|
+
import_typescript11.default.forEachChild(node, visit2);
|
|
193847
193938
|
};
|
|
193848
|
-
|
|
193939
|
+
import_typescript11.default.forEachChild(sf, visit2);
|
|
193849
193940
|
return assigned;
|
|
193850
193941
|
}
|
|
193851
193942
|
function closeOverWritersOfMutableBindings(primaryRefs, declarations, mutableNames) {
|
|
@@ -193868,7 +193959,7 @@ function closeOverWritersOfMutableBindings(primaryRefs, declarations, mutableNam
|
|
|
193868
193959
|
return reachable;
|
|
193869
193960
|
}
|
|
193870
193961
|
function isAssignmentOperator(kind) {
|
|
193871
|
-
return kind >=
|
|
193962
|
+
return kind >= import_typescript11.default.SyntaxKind.FirstAssignment && kind <= import_typescript11.default.SyntaxKind.LastAssignment;
|
|
193872
193963
|
}
|
|
193873
193964
|
|
|
193874
193965
|
// ../jsx/src/builtins.ts
|
|
@@ -193878,7 +193969,7 @@ function isClientBuiltinName(name) {
|
|
|
193878
193969
|
}
|
|
193879
193970
|
|
|
193880
193971
|
// ../jsx/src/reactivity-checker.ts
|
|
193881
|
-
var
|
|
193972
|
+
var import_typescript12 = __toESM(require_typescript(), 1);
|
|
193882
193973
|
var REACTIVE_BRAND = "__reactive";
|
|
193883
193974
|
function queryType(checker, node) {
|
|
193884
193975
|
incrementCounter("typeCheckerQueries");
|
|
@@ -193896,7 +193987,7 @@ function safeGetText(node) {
|
|
|
193896
193987
|
}
|
|
193897
193988
|
}
|
|
193898
193989
|
function analyze(node, checker) {
|
|
193899
|
-
if (
|
|
193990
|
+
if (import_typescript12.default.isPropertyAccessExpression(node)) {
|
|
193900
193991
|
try {
|
|
193901
193992
|
const type2 = queryType(checker, node);
|
|
193902
193993
|
if (isReactiveType(type2)) {
|
|
@@ -193920,7 +194011,7 @@ function analyze(node, checker) {
|
|
|
193920
194011
|
}
|
|
193921
194012
|
return NOT_REACTIVE;
|
|
193922
194013
|
}
|
|
193923
|
-
if (
|
|
194014
|
+
if (import_typescript12.default.isIdentifier(node)) {
|
|
193924
194015
|
try {
|
|
193925
194016
|
const type2 = queryType(checker, node);
|
|
193926
194017
|
if (isReactiveType(type2)) {
|
|
@@ -193932,7 +194023,7 @@ function analyze(node, checker) {
|
|
|
193932
194023
|
} catch {}
|
|
193933
194024
|
return NOT_REACTIVE;
|
|
193934
194025
|
}
|
|
193935
|
-
if (
|
|
194026
|
+
if (import_typescript12.default.isCallExpression(node)) {
|
|
193936
194027
|
try {
|
|
193937
194028
|
const calleeType = queryType(checker, node.expression);
|
|
193938
194029
|
if (isReactiveType(calleeType)) {
|
|
@@ -193945,7 +194036,7 @@ function analyze(node, checker) {
|
|
|
193945
194036
|
}
|
|
193946
194037
|
let foundChild;
|
|
193947
194038
|
let foundChildText = "";
|
|
193948
|
-
|
|
194039
|
+
import_typescript12.default.forEachChild(node, (child) => {
|
|
193949
194040
|
if (foundChild?.isReactive)
|
|
193950
194041
|
return;
|
|
193951
194042
|
const result = analyze(child, checker);
|
|
@@ -193974,7 +194065,7 @@ function containsReactiveExpression(node, checker) {
|
|
|
193974
194065
|
}
|
|
193975
194066
|
|
|
193976
194067
|
// ../jsx/src/free-refs.ts
|
|
193977
|
-
var
|
|
194068
|
+
var import_typescript13 = __toESM(require_typescript(), 1);
|
|
193978
194069
|
var _bindingMapCache = new WeakMap;
|
|
193979
194070
|
function buildBindingMap(env) {
|
|
193980
194071
|
const cached = _bindingMapCache.get(env);
|
|
@@ -194042,20 +194133,20 @@ function defaultBindingScope(kind) {
|
|
|
194042
194133
|
function collectIdentifiers2(node) {
|
|
194043
194134
|
const out = [];
|
|
194044
194135
|
const visit2 = (n, parent) => {
|
|
194045
|
-
if (
|
|
194046
|
-
if (parent &&
|
|
194136
|
+
if (import_typescript13.default.isIdentifier(n)) {
|
|
194137
|
+
if (parent && import_typescript13.default.isPropertyAccessExpression(parent) && parent.name === n)
|
|
194047
194138
|
return;
|
|
194048
|
-
if (parent &&
|
|
194139
|
+
if (parent && import_typescript13.default.isPropertyAssignment(parent) && parent.name === n)
|
|
194049
194140
|
return;
|
|
194050
|
-
if (parent && (
|
|
194141
|
+
if (parent && (import_typescript13.default.isJsxOpeningElement(parent) || import_typescript13.default.isJsxClosingElement(parent) || import_typescript13.default.isJsxSelfClosingElement(parent)) && parent.tagName === n) {
|
|
194051
194142
|
return;
|
|
194052
194143
|
}
|
|
194053
|
-
if (parent &&
|
|
194144
|
+
if (parent && import_typescript13.default.isJsxAttribute(parent) && parent.name === n)
|
|
194054
194145
|
return;
|
|
194055
194146
|
out.push(n);
|
|
194056
194147
|
return;
|
|
194057
194148
|
}
|
|
194058
|
-
|
|
194149
|
+
import_typescript13.default.forEachChild(n, (child) => visit2(child, n));
|
|
194059
194150
|
};
|
|
194060
194151
|
visit2(node);
|
|
194061
194152
|
return out;
|
|
@@ -194064,7 +194155,7 @@ function collectReactiveBrandRefs(node, checker) {
|
|
|
194064
194155
|
const out = [];
|
|
194065
194156
|
const seen = new Set;
|
|
194066
194157
|
const visit2 = (n) => {
|
|
194067
|
-
if (
|
|
194158
|
+
if (import_typescript13.default.isPropertyAccessExpression(n)) {
|
|
194068
194159
|
try {
|
|
194069
194160
|
const type2 = checker.getTypeAtLocation(n);
|
|
194070
194161
|
if (isReactiveType(type2)) {
|
|
@@ -194082,7 +194173,7 @@ function collectReactiveBrandRefs(node, checker) {
|
|
|
194082
194173
|
incrementCounter("freeRefsTypeLookupFailures");
|
|
194083
194174
|
}
|
|
194084
194175
|
}
|
|
194085
|
-
|
|
194176
|
+
import_typescript13.default.forEachChild(n, visit2);
|
|
194086
194177
|
};
|
|
194087
194178
|
visit2(node);
|
|
194088
194179
|
return out;
|
|
@@ -194092,14 +194183,14 @@ function resolveConstantInitializerRefs(c, env, visited) {
|
|
|
194092
194183
|
return [];
|
|
194093
194184
|
if (c.containsArrow)
|
|
194094
194185
|
return [];
|
|
194095
|
-
const sf =
|
|
194186
|
+
const sf = import_typescript13.default.createSourceFile("__const_init.ts", `const __probe = (${c.value});`, import_typescript13.default.ScriptTarget.Latest, true);
|
|
194096
194187
|
const stmt = sf.statements[0];
|
|
194097
|
-
if (!stmt || !
|
|
194188
|
+
if (!stmt || !import_typescript13.default.isVariableStatement(stmt))
|
|
194098
194189
|
return [];
|
|
194099
194190
|
const decl = stmt.declarationList.declarations[0];
|
|
194100
194191
|
if (!decl || !decl.initializer)
|
|
194101
194192
|
return [];
|
|
194102
|
-
const expr =
|
|
194193
|
+
const expr = import_typescript13.default.isParenthesizedExpression(decl.initializer) ? decl.initializer.expression : decl.initializer;
|
|
194103
194194
|
return resolveFreeRefsInternal(expr, env, visited);
|
|
194104
194195
|
}
|
|
194105
194196
|
function resolveFreeRefsInternal(node, env, visited) {
|
|
@@ -194111,7 +194202,7 @@ function resolveFreeRefsInternal(node, env, visited) {
|
|
|
194111
194202
|
const name = ident.text;
|
|
194112
194203
|
if (env.propsObjectName === name) {
|
|
194113
194204
|
const parent = ident.parent;
|
|
194114
|
-
if (parent &&
|
|
194205
|
+
if (parent && import_typescript13.default.isPropertyAccessExpression(parent) && parent.expression === ident && parent.name.text === "children") {
|
|
194115
194206
|
continue;
|
|
194116
194207
|
}
|
|
194117
194208
|
}
|
|
@@ -194541,13 +194632,13 @@ function exprCallsReactiveGetters(expr, ctx) {
|
|
|
194541
194632
|
function visit2(n) {
|
|
194542
194633
|
if (found)
|
|
194543
194634
|
return;
|
|
194544
|
-
if (
|
|
194635
|
+
if (import_typescript14.default.isCallExpression(n) && import_typescript14.default.isIdentifier(n.expression)) {
|
|
194545
194636
|
if (names.has(n.expression.text)) {
|
|
194546
194637
|
found = true;
|
|
194547
194638
|
return;
|
|
194548
194639
|
}
|
|
194549
194640
|
}
|
|
194550
|
-
|
|
194641
|
+
import_typescript14.default.forEachChild(n, visit2);
|
|
194551
194642
|
}
|
|
194552
194643
|
visit2(expr);
|
|
194553
194644
|
return found;
|
|
@@ -194574,11 +194665,11 @@ function exprReferencesModuleClientSignal(expr, ctx) {
|
|
|
194574
194665
|
function visit2(n) {
|
|
194575
194666
|
if (found)
|
|
194576
194667
|
return;
|
|
194577
|
-
if (
|
|
194668
|
+
if (import_typescript14.default.isCallExpression(n) && import_typescript14.default.isIdentifier(n.expression) && names.has(n.expression.text)) {
|
|
194578
194669
|
found = true;
|
|
194579
194670
|
return;
|
|
194580
194671
|
}
|
|
194581
|
-
|
|
194672
|
+
import_typescript14.default.forEachChild(n, visit2);
|
|
194582
194673
|
}
|
|
194583
194674
|
visit2(expr);
|
|
194584
194675
|
return found;
|
|
@@ -194588,11 +194679,11 @@ function exprHasFunctionCalls(expr) {
|
|
|
194588
194679
|
function visit2(n) {
|
|
194589
194680
|
if (found)
|
|
194590
194681
|
return;
|
|
194591
|
-
if (
|
|
194682
|
+
if (import_typescript14.default.isCallExpression(n)) {
|
|
194592
194683
|
found = true;
|
|
194593
194684
|
return;
|
|
194594
194685
|
}
|
|
194595
|
-
|
|
194686
|
+
import_typescript14.default.forEachChild(n, visit2);
|
|
194596
194687
|
}
|
|
194597
194688
|
visit2(expr);
|
|
194598
194689
|
return found;
|
|
@@ -194629,10 +194720,10 @@ function lowerDateCalls(text, expr, ctx) {
|
|
|
194629
194720
|
return text;
|
|
194630
194721
|
const candidates = [];
|
|
194631
194722
|
function visit2(n) {
|
|
194632
|
-
if (
|
|
194723
|
+
if (import_typescript14.default.isCallExpression(n) && n.arguments.length === 0 && import_typescript14.default.isPropertyAccessExpression(n.expression) && !n.expression.questionDotToken && DATE_METHODS.has(n.expression.name.text)) {
|
|
194633
194724
|
candidates.push(n);
|
|
194634
194725
|
}
|
|
194635
|
-
|
|
194726
|
+
import_typescript14.default.forEachChild(n, visit2);
|
|
194636
194727
|
}
|
|
194637
194728
|
visit2(expr);
|
|
194638
194729
|
if (candidates.length === 0)
|
|
@@ -194657,10 +194748,10 @@ function lowerToLocaleDateCalls(text, expr, ctx) {
|
|
|
194657
194748
|
return text;
|
|
194658
194749
|
const candidates = [];
|
|
194659
194750
|
function visit2(n) {
|
|
194660
|
-
if (
|
|
194751
|
+
if (import_typescript14.default.isCallExpression(n) && n.arguments.length === 2 && import_typescript14.default.isPropertyAccessExpression(n.expression) && !n.expression.questionDotToken && n.expression.name.text === "toLocaleDateString") {
|
|
194661
194752
|
candidates.push(n);
|
|
194662
194753
|
}
|
|
194663
|
-
|
|
194754
|
+
import_typescript14.default.forEachChild(n, visit2);
|
|
194664
194755
|
}
|
|
194665
194756
|
visit2(expr);
|
|
194666
194757
|
if (candidates.length === 0)
|
|
@@ -194714,10 +194805,10 @@ function collectBranchLocalPropRefsViaSubstitution(node, ctx) {
|
|
|
194714
194805
|
return;
|
|
194715
194806
|
let acc;
|
|
194716
194807
|
function visit2(n, parent) {
|
|
194717
|
-
if (
|
|
194718
|
-
const isObjectKey = parent &&
|
|
194719
|
-
const isShorthand = parent &&
|
|
194720
|
-
const isAccessName = parent &&
|
|
194808
|
+
if (import_typescript14.default.isIdentifier(n) && propDepsMap.has(n.text)) {
|
|
194809
|
+
const isObjectKey = parent && import_typescript14.default.isPropertyAssignment(parent) && parent.name === n;
|
|
194810
|
+
const isShorthand = parent && import_typescript14.default.isShorthandPropertyAssignment(parent) && parent.name === n;
|
|
194811
|
+
const isAccessName = parent && import_typescript14.default.isPropertyAccessExpression(parent) && parent.name === n;
|
|
194721
194812
|
if (!isObjectKey && !isShorthand && !isAccessName) {
|
|
194722
194813
|
const deps = propDepsMap.get(n.text);
|
|
194723
194814
|
if (deps && deps.size > 0) {
|
|
@@ -194728,7 +194819,7 @@ function collectBranchLocalPropRefsViaSubstitution(node, ctx) {
|
|
|
194728
194819
|
}
|
|
194729
194820
|
}
|
|
194730
194821
|
}
|
|
194731
|
-
|
|
194822
|
+
import_typescript14.default.forEachChild(n, (child) => visit2(child, n));
|
|
194732
194823
|
}
|
|
194733
194824
|
visit2(node);
|
|
194734
194825
|
return acc;
|
|
@@ -194763,6 +194854,7 @@ function getDestructuredPropAliases(ctx) {
|
|
|
194763
194854
|
return ctx._destructuredPropAliases ?? null;
|
|
194764
194855
|
}
|
|
194765
194856
|
function createTransformContext(analyzer) {
|
|
194857
|
+
const propsParamsForMatching = analyzer.propsParams.filter((p) => p.name !== "children");
|
|
194766
194858
|
return {
|
|
194767
194859
|
analyzer,
|
|
194768
194860
|
sourceFile: analyzer.sourceFile,
|
|
@@ -194776,6 +194868,7 @@ function createTransformContext(analyzer) {
|
|
|
194776
194868
|
insideComponentChildren: false,
|
|
194777
194869
|
scope: BindingScope.EMPTY,
|
|
194778
194870
|
loopDepth: 0,
|
|
194871
|
+
boundPropNames: boundPropLocalNames({ propsParams: propsParamsForMatching, propsObjectName: analyzer.propsObjectName }),
|
|
194779
194872
|
patterns: {
|
|
194780
194873
|
signals: analyzer.signals.map((s) => ({
|
|
194781
194874
|
getter: s.getter,
|
|
@@ -194785,7 +194878,7 @@ function createTransformContext(analyzer) {
|
|
|
194785
194878
|
name: m.name,
|
|
194786
194879
|
pattern: identifierCallPattern(m.name)
|
|
194787
194880
|
})),
|
|
194788
|
-
props:
|
|
194881
|
+
props: propsParamsForMatching.map((p) => ({ name: p.name, pattern: identifierPattern(p.name) })),
|
|
194789
194882
|
constants: analyzer.localConstants.map((c) => ({
|
|
194790
194883
|
name: c.name,
|
|
194791
194884
|
value: c.value,
|
|
@@ -194804,21 +194897,21 @@ function createTransformContext(analyzer) {
|
|
|
194804
194897
|
function buildComponentNamespaces(ctx) {
|
|
194805
194898
|
const result = new Map;
|
|
194806
194899
|
for (const stmt of ctx.sourceFile.statements) {
|
|
194807
|
-
if (!
|
|
194900
|
+
if (!import_typescript14.default.isVariableStatement(stmt))
|
|
194808
194901
|
continue;
|
|
194809
194902
|
for (const decl of stmt.declarationList.declarations) {
|
|
194810
|
-
if (!decl.initializer || !
|
|
194903
|
+
if (!decl.initializer || !import_typescript14.default.isIdentifier(decl.name))
|
|
194811
194904
|
continue;
|
|
194812
194905
|
let init = decl.initializer;
|
|
194813
|
-
while (
|
|
194906
|
+
while (import_typescript14.default.isParenthesizedExpression(init))
|
|
194814
194907
|
init = init.expression;
|
|
194815
|
-
if (!
|
|
194908
|
+
if (!import_typescript14.default.isObjectLiteralExpression(init))
|
|
194816
194909
|
continue;
|
|
194817
194910
|
const members = new Map;
|
|
194818
194911
|
for (const prop of init.properties) {
|
|
194819
|
-
if (
|
|
194912
|
+
if (import_typescript14.default.isShorthandPropertyAssignment(prop)) {
|
|
194820
194913
|
members.set(prop.name.text, prop.name.text);
|
|
194821
|
-
} else if (
|
|
194914
|
+
} else if (import_typescript14.default.isPropertyAssignment(prop) && (import_typescript14.default.isIdentifier(prop.name) || import_typescript14.default.isStringLiteral(prop.name)) && import_typescript14.default.isIdentifier(prop.initializer)) {
|
|
194822
194915
|
members.set(prop.name.text, prop.initializer.text);
|
|
194823
194916
|
}
|
|
194824
194917
|
}
|
|
@@ -194830,11 +194923,11 @@ function buildComponentNamespaces(ctx) {
|
|
|
194830
194923
|
return result;
|
|
194831
194924
|
}
|
|
194832
194925
|
function resolveMemberExpressionTag(tagNode, ctx) {
|
|
194833
|
-
if (!
|
|
194926
|
+
if (!import_typescript14.default.isPropertyAccessExpression(tagNode))
|
|
194834
194927
|
return null;
|
|
194835
|
-
if (!
|
|
194928
|
+
if (!import_typescript14.default.isIdentifier(tagNode.expression))
|
|
194836
194929
|
return null;
|
|
194837
|
-
if (!
|
|
194930
|
+
if (!import_typescript14.default.isIdentifier(tagNode.name))
|
|
194838
194931
|
return null;
|
|
194839
194932
|
if (!ctx._componentNamespaces) {
|
|
194840
194933
|
ctx._componentNamespaces = buildComponentNamespaces(ctx);
|
|
@@ -195025,7 +195118,7 @@ function buildIRRoot(analyzer) {
|
|
|
195025
195118
|
return null;
|
|
195026
195119
|
const ctx = createTransformContext(analyzer);
|
|
195027
195120
|
const jsxReturn = analyzer.jsxReturn;
|
|
195028
|
-
if (
|
|
195121
|
+
if (import_typescript14.default.isJsxElement(jsxReturn) || import_typescript14.default.isJsxSelfClosingElement(jsxReturn) || import_typescript14.default.isJsxFragment(jsxReturn)) {
|
|
195029
195122
|
const ir2 = transformNode(jsxReturn, ctx);
|
|
195030
195123
|
if (ir2 && needsScopeWrapper(ir2)) {
|
|
195031
195124
|
return wrapInScopeElement(ir2);
|
|
@@ -195035,7 +195128,7 @@ function buildIRRoot(analyzer) {
|
|
|
195035
195128
|
ctx.isRoot = false;
|
|
195036
195129
|
const ir = transformJsxExpression(jsxReturn, ctx);
|
|
195037
195130
|
if (ir === null) {
|
|
195038
|
-
if (
|
|
195131
|
+
if (import_typescript14.default.isIdentifier(jsxReturn) && (analyzer.jsxConstants.has(jsxReturn.text) || analyzer.inlineableJsxConsts.has(jsxReturn.text))) {
|
|
195039
195132
|
analyzer.errors.push(createError(ErrorCodes.RETURN_VALUE_NOT_JSX, getSourceLocation(jsxReturn, analyzer.sourceFile, analyzer.filePath), {
|
|
195040
195133
|
message: `Component '${analyzer.componentName ?? "(unknown)"}' return value is not recognized ` + `as JSX — return the JSX expression directly instead of binding it to a local variable ` + `first (\`return ${jsxReturn.text}\` after \`const ${jsxReturn.text} = <jsx/>\` is not ` + `resolved at return position).`
|
|
195041
195134
|
}));
|
|
@@ -195087,22 +195180,22 @@ function wrapInScopeElement(node) {
|
|
|
195087
195180
|
};
|
|
195088
195181
|
}
|
|
195089
195182
|
function transformNode(node, ctx) {
|
|
195090
|
-
if (
|
|
195183
|
+
if (import_typescript14.default.isJsxElement(node)) {
|
|
195091
195184
|
return transformJsxElement(node, ctx);
|
|
195092
195185
|
}
|
|
195093
|
-
if (
|
|
195186
|
+
if (import_typescript14.default.isJsxSelfClosingElement(node)) {
|
|
195094
195187
|
return transformSelfClosingElement(node, ctx);
|
|
195095
195188
|
}
|
|
195096
|
-
if (
|
|
195189
|
+
if (import_typescript14.default.isJsxFragment(node)) {
|
|
195097
195190
|
return transformFragment(node, ctx);
|
|
195098
195191
|
}
|
|
195099
|
-
if (
|
|
195192
|
+
if (import_typescript14.default.isJsxText(node)) {
|
|
195100
195193
|
return transformText(node, ctx);
|
|
195101
195194
|
}
|
|
195102
|
-
if (
|
|
195195
|
+
if (import_typescript14.default.isJsxExpression(node)) {
|
|
195103
195196
|
return transformExpression(node, ctx);
|
|
195104
195197
|
}
|
|
195105
|
-
if (
|
|
195198
|
+
if (import_typescript14.default.isConditionalExpression(node)) {
|
|
195106
195199
|
return transformConditional(node, ctx);
|
|
195107
195200
|
}
|
|
195108
195201
|
return null;
|
|
@@ -195460,7 +195553,7 @@ function transformSelfClosingComponent(node, ctx, name) {
|
|
|
195460
195553
|
}
|
|
195461
195554
|
function isTransparentFragment(node, ctx) {
|
|
195462
195555
|
const children = node.children.filter((child2) => {
|
|
195463
|
-
if (
|
|
195556
|
+
if (import_typescript14.default.isJsxText(child2)) {
|
|
195464
195557
|
return child2.text.trim() !== "";
|
|
195465
195558
|
}
|
|
195466
195559
|
return true;
|
|
@@ -195468,7 +195561,7 @@ function isTransparentFragment(node, ctx) {
|
|
|
195468
195561
|
if (children.length !== 1)
|
|
195469
195562
|
return false;
|
|
195470
195563
|
const child = children[0];
|
|
195471
|
-
if (!
|
|
195564
|
+
if (!import_typescript14.default.isJsxExpression(child))
|
|
195472
195565
|
return false;
|
|
195473
195566
|
if (!child.expression)
|
|
195474
195567
|
return false;
|
|
@@ -195539,7 +195632,7 @@ function transformChildren(children, ctx) {
|
|
|
195539
195632
|
const result = [];
|
|
195540
195633
|
for (let i2 = 0;i2 < children.length; i2++) {
|
|
195541
195634
|
const child = children[i2];
|
|
195542
|
-
if (
|
|
195635
|
+
if (import_typescript14.default.isJsxExpression(child) && !child.expression) {
|
|
195543
195636
|
continue;
|
|
195544
195637
|
}
|
|
195545
195638
|
const transformed = transformNode(child, ctx);
|
|
@@ -195554,10 +195647,10 @@ function transformChildren(children, ctx) {
|
|
|
195554
195647
|
}
|
|
195555
195648
|
function isRenderNothingLiteral(expr, ctx) {
|
|
195556
195649
|
let e = expr;
|
|
195557
|
-
while (
|
|
195650
|
+
while (import_typescript14.default.isParenthesizedExpression(e) || import_typescript14.default.isAsExpression(e) || import_typescript14.default.isSatisfiesExpression(e) || import_typescript14.default.isNonNullExpression(e)) {
|
|
195558
195651
|
e = e.expression;
|
|
195559
195652
|
}
|
|
195560
|
-
return e.kind ===
|
|
195653
|
+
return e.kind === import_typescript14.default.SyntaxKind.NullKeyword || e.kind === import_typescript14.default.SyntaxKind.TrueKeyword || e.kind === import_typescript14.default.SyntaxKind.FalseKeyword || import_typescript14.default.isIdentifier(e) && e.text === "undefined" && !isNameBound("undefined", makeBindingEnv(ctx));
|
|
195561
195654
|
}
|
|
195562
195655
|
function transformText(node, ctx) {
|
|
195563
195656
|
const text = node.text.replace(/\s+/g, " ");
|
|
@@ -195583,7 +195676,7 @@ function transformExpressionInner(expr, ctx, node, isClientOnly) {
|
|
|
195583
195676
|
return null;
|
|
195584
195677
|
}
|
|
195585
195678
|
checkBareSignalOrMemoIdentifier(expr, ctx, { descendNested: true });
|
|
195586
|
-
if (
|
|
195679
|
+
if (import_typescript14.default.isIdentifier(expr)) {
|
|
195587
195680
|
const jsxNode = ctx.analyzer.jsxConstants.get(expr.text);
|
|
195588
195681
|
if (jsxNode) {
|
|
195589
195682
|
return transformNode(jsxNode, ctx);
|
|
@@ -195862,38 +195955,38 @@ function transformLogicalAnd(node, ctx) {
|
|
|
195862
195955
|
};
|
|
195863
195956
|
}
|
|
195864
195957
|
function containsJsxInExpression(node) {
|
|
195865
|
-
if (
|
|
195958
|
+
if (import_typescript14.default.isJsxElement(node) || import_typescript14.default.isJsxSelfClosingElement(node) || import_typescript14.default.isJsxFragment(node)) {
|
|
195866
195959
|
return true;
|
|
195867
195960
|
}
|
|
195868
|
-
return
|
|
195961
|
+
return import_typescript14.default.forEachChild(node, containsJsxInExpression) ?? false;
|
|
195869
195962
|
}
|
|
195870
195963
|
function callsJsxHelper(node, ctx) {
|
|
195871
195964
|
let found = false;
|
|
195872
195965
|
const visit2 = (n) => {
|
|
195873
195966
|
if (found)
|
|
195874
195967
|
return;
|
|
195875
|
-
if (
|
|
195968
|
+
if (import_typescript14.default.isCallExpression(n) && import_typescript14.default.isIdentifier(n.expression)) {
|
|
195876
195969
|
const name = n.expression.text;
|
|
195877
195970
|
if (ctx.analyzer.jsxFunctions.has(name) || ctx.analyzer.jsxMultiReturnFunctions.has(name)) {
|
|
195878
195971
|
found = true;
|
|
195879
195972
|
return;
|
|
195880
195973
|
}
|
|
195881
195974
|
}
|
|
195882
|
-
|
|
195975
|
+
import_typescript14.default.forEachChild(n, visit2);
|
|
195883
195976
|
};
|
|
195884
195977
|
visit2(node);
|
|
195885
195978
|
return found;
|
|
195886
195979
|
}
|
|
195887
195980
|
function containsAwaitExpression(node) {
|
|
195888
|
-
if (
|
|
195981
|
+
if (import_typescript14.default.isAwaitExpression(node))
|
|
195889
195982
|
return true;
|
|
195890
|
-
if (
|
|
195983
|
+
if (import_typescript14.default.isFunctionDeclaration(node) || import_typescript14.default.isFunctionExpression(node) || import_typescript14.default.isArrowFunction(node))
|
|
195891
195984
|
return false;
|
|
195892
|
-
return
|
|
195985
|
+
return import_typescript14.default.forEachChild(node, containsAwaitExpression) ?? false;
|
|
195893
195986
|
}
|
|
195894
195987
|
function transformNullishCoalescing(node, ctx) {
|
|
195895
195988
|
const leftText = ctx.getJS(node.left);
|
|
195896
|
-
const isNullish = node.operatorToken.kind ===
|
|
195989
|
+
const isNullish = node.operatorToken.kind === import_typescript14.default.SyntaxKind.QuestionQuestionToken;
|
|
195897
195990
|
const condition = isNullish ? `${leftText} != null` : leftText;
|
|
195898
195991
|
const leftOrigin = {
|
|
195899
195992
|
phase: "tick",
|
|
@@ -195939,36 +196032,36 @@ function transformNullishCoalescing(node, ctx) {
|
|
|
195939
196032
|
}
|
|
195940
196033
|
function assertNever2(expr) {
|
|
195941
196034
|
const kind = expr?.kind;
|
|
195942
|
-
throw new Error(`transformJsxExpression: unhandled ts.SyntaxKind ${kind !== undefined ?
|
|
196035
|
+
throw new Error(`transformJsxExpression: unhandled ts.SyntaxKind ${kind !== undefined ? import_typescript14.default.SyntaxKind[kind] : "unknown"} ` + `(kind=${kind}). Update spec/compiler.md Appendix A and the switch in jsx-to-ir.ts.`);
|
|
195943
196036
|
}
|
|
195944
196037
|
function transformJsxExpression(expr, ctx, isClientOnly = false) {
|
|
195945
196038
|
const node = expr;
|
|
195946
196039
|
switch (node.kind) {
|
|
195947
|
-
case
|
|
195948
|
-
case
|
|
195949
|
-
case
|
|
195950
|
-
case
|
|
195951
|
-
case
|
|
195952
|
-
case
|
|
196040
|
+
case import_typescript14.default.SyntaxKind.ParenthesizedExpression:
|
|
196041
|
+
case import_typescript14.default.SyntaxKind.AsExpression:
|
|
196042
|
+
case import_typescript14.default.SyntaxKind.SatisfiesExpression:
|
|
196043
|
+
case import_typescript14.default.SyntaxKind.NonNullExpression:
|
|
196044
|
+
case import_typescript14.default.SyntaxKind.TypeAssertionExpression:
|
|
196045
|
+
case import_typescript14.default.SyntaxKind.PartiallyEmittedExpression:
|
|
195953
196046
|
return transformJsxExpression(node.expression, ctx, isClientOnly);
|
|
195954
|
-
case
|
|
196047
|
+
case import_typescript14.default.SyntaxKind.JsxElement:
|
|
195955
196048
|
return transformJsxElement(node, ctx);
|
|
195956
|
-
case
|
|
196049
|
+
case import_typescript14.default.SyntaxKind.JsxFragment:
|
|
195957
196050
|
return transformFragment(node, ctx);
|
|
195958
|
-
case
|
|
196051
|
+
case import_typescript14.default.SyntaxKind.JsxSelfClosingElement:
|
|
195959
196052
|
return transformSelfClosingElement(node, ctx);
|
|
195960
|
-
case
|
|
196053
|
+
case import_typescript14.default.SyntaxKind.ConditionalExpression:
|
|
195961
196054
|
return transformConditional(node, ctx);
|
|
195962
|
-
case
|
|
195963
|
-
if (node.operatorToken.kind ===
|
|
196055
|
+
case import_typescript14.default.SyntaxKind.BinaryExpression: {
|
|
196056
|
+
if (node.operatorToken.kind === import_typescript14.default.SyntaxKind.AmpersandAmpersandToken) {
|
|
195964
196057
|
return transformLogicalAnd(node, ctx);
|
|
195965
196058
|
}
|
|
195966
|
-
if ((node.operatorToken.kind ===
|
|
196059
|
+
if ((node.operatorToken.kind === import_typescript14.default.SyntaxKind.QuestionQuestionToken || node.operatorToken.kind === import_typescript14.default.SyntaxKind.BarBarToken) && (containsJsxInExpression(node.right) || callsJsxHelper(node.right, ctx))) {
|
|
195967
196060
|
return transformNullishCoalescing(node, ctx);
|
|
195968
196061
|
}
|
|
195969
196062
|
return null;
|
|
195970
196063
|
}
|
|
195971
|
-
case
|
|
196064
|
+
case import_typescript14.default.SyntaxKind.CallExpression: {
|
|
195972
196065
|
const mapMethod = getMapLikeMethod(node);
|
|
195973
196066
|
if (mapMethod) {
|
|
195974
196067
|
const mapResult = transformMapCall(node, ctx, isClientOnly, mapMethod);
|
|
@@ -195976,7 +196069,7 @@ function transformJsxExpression(expr, ctx, isClientOnly = false) {
|
|
|
195976
196069
|
return mapResult;
|
|
195977
196070
|
}
|
|
195978
196071
|
const callee = node.expression;
|
|
195979
|
-
if (
|
|
196072
|
+
if (import_typescript14.default.isIdentifier(callee)) {
|
|
195980
196073
|
const jsxFunc = ctx.analyzer.jsxFunctions.get(callee.text);
|
|
195981
196074
|
if (jsxFunc) {
|
|
195982
196075
|
return transformJsxFunctionCall(node, jsxFunc, ctx, isClientOnly);
|
|
@@ -195988,39 +196081,39 @@ function transformJsxExpression(expr, ctx, isClientOnly = false) {
|
|
|
195988
196081
|
}
|
|
195989
196082
|
return null;
|
|
195990
196083
|
}
|
|
195991
|
-
case
|
|
195992
|
-
case
|
|
195993
|
-
case
|
|
195994
|
-
case
|
|
195995
|
-
case
|
|
195996
|
-
case
|
|
195997
|
-
case
|
|
195998
|
-
case
|
|
195999
|
-
case
|
|
196000
|
-
case
|
|
196001
|
-
case
|
|
196002
|
-
case
|
|
196003
|
-
case
|
|
196004
|
-
case
|
|
196005
|
-
case
|
|
196006
|
-
case
|
|
196007
|
-
case
|
|
196008
|
-
case
|
|
196009
|
-
case
|
|
196010
|
-
case
|
|
196011
|
-
case
|
|
196012
|
-
case
|
|
196013
|
-
case
|
|
196014
|
-
case
|
|
196015
|
-
case
|
|
196016
|
-
case
|
|
196017
|
-
case
|
|
196018
|
-
case
|
|
196019
|
-
case
|
|
196020
|
-
case
|
|
196021
|
-
case
|
|
196084
|
+
case import_typescript14.default.SyntaxKind.Identifier:
|
|
196085
|
+
case import_typescript14.default.SyntaxKind.StringLiteral:
|
|
196086
|
+
case import_typescript14.default.SyntaxKind.NumericLiteral:
|
|
196087
|
+
case import_typescript14.default.SyntaxKind.BigIntLiteral:
|
|
196088
|
+
case import_typescript14.default.SyntaxKind.RegularExpressionLiteral:
|
|
196089
|
+
case import_typescript14.default.SyntaxKind.NoSubstitutionTemplateLiteral:
|
|
196090
|
+
case import_typescript14.default.SyntaxKind.TemplateExpression:
|
|
196091
|
+
case import_typescript14.default.SyntaxKind.TaggedTemplateExpression:
|
|
196092
|
+
case import_typescript14.default.SyntaxKind.TrueKeyword:
|
|
196093
|
+
case import_typescript14.default.SyntaxKind.FalseKeyword:
|
|
196094
|
+
case import_typescript14.default.SyntaxKind.NullKeyword:
|
|
196095
|
+
case import_typescript14.default.SyntaxKind.ThisKeyword:
|
|
196096
|
+
case import_typescript14.default.SyntaxKind.SuperKeyword:
|
|
196097
|
+
case import_typescript14.default.SyntaxKind.ImportKeyword:
|
|
196098
|
+
case import_typescript14.default.SyntaxKind.PropertyAccessExpression:
|
|
196099
|
+
case import_typescript14.default.SyntaxKind.ElementAccessExpression:
|
|
196100
|
+
case import_typescript14.default.SyntaxKind.PrefixUnaryExpression:
|
|
196101
|
+
case import_typescript14.default.SyntaxKind.PostfixUnaryExpression:
|
|
196102
|
+
case import_typescript14.default.SyntaxKind.TypeOfExpression:
|
|
196103
|
+
case import_typescript14.default.SyntaxKind.VoidExpression:
|
|
196104
|
+
case import_typescript14.default.SyntaxKind.DeleteExpression:
|
|
196105
|
+
case import_typescript14.default.SyntaxKind.NewExpression:
|
|
196106
|
+
case import_typescript14.default.SyntaxKind.ObjectLiteralExpression:
|
|
196107
|
+
case import_typescript14.default.SyntaxKind.ArrowFunction:
|
|
196108
|
+
case import_typescript14.default.SyntaxKind.FunctionExpression:
|
|
196109
|
+
case import_typescript14.default.SyntaxKind.ClassExpression:
|
|
196110
|
+
case import_typescript14.default.SyntaxKind.MetaProperty:
|
|
196111
|
+
case import_typescript14.default.SyntaxKind.ExpressionWithTypeArguments:
|
|
196112
|
+
case import_typescript14.default.SyntaxKind.CommaListExpression:
|
|
196113
|
+
case import_typescript14.default.SyntaxKind.SyntheticExpression:
|
|
196114
|
+
case import_typescript14.default.SyntaxKind.ArrayLiteralExpression:
|
|
196022
196115
|
return null;
|
|
196023
|
-
case
|
|
196116
|
+
case import_typescript14.default.SyntaxKind.AwaitExpression:
|
|
196024
196117
|
ctx.analyzer.errors.push(createError(ErrorCodes.STAGE_AWAIT_IN_TEMPLATE, getSourceLocation(node, ctx.sourceFile, ctx.filePath)));
|
|
196025
196118
|
return {
|
|
196026
196119
|
type: "expression",
|
|
@@ -196031,16 +196124,16 @@ function transformJsxExpression(expr, ctx, isClientOnly = false) {
|
|
|
196031
196124
|
loc: getSourceLocation(node, ctx.sourceFile, ctx.filePath),
|
|
196032
196125
|
origin: { phase: "tick", scope: "template", effect: "pure", freeRefs: [] }
|
|
196033
196126
|
};
|
|
196034
|
-
case
|
|
196127
|
+
case import_typescript14.default.SyntaxKind.YieldExpression:
|
|
196035
196128
|
return null;
|
|
196036
|
-
case
|
|
196037
|
-
case
|
|
196038
|
-
case
|
|
196039
|
-
case
|
|
196040
|
-
case
|
|
196041
|
-
case
|
|
196042
|
-
case
|
|
196043
|
-
case
|
|
196129
|
+
case import_typescript14.default.SyntaxKind.SpreadElement:
|
|
196130
|
+
case import_typescript14.default.SyntaxKind.OmittedExpression:
|
|
196131
|
+
case import_typescript14.default.SyntaxKind.JsxExpression:
|
|
196132
|
+
case import_typescript14.default.SyntaxKind.JsxOpeningElement:
|
|
196133
|
+
case import_typescript14.default.SyntaxKind.JsxOpeningFragment:
|
|
196134
|
+
case import_typescript14.default.SyntaxKind.JsxClosingFragment:
|
|
196135
|
+
case import_typescript14.default.SyntaxKind.JsxAttributes:
|
|
196136
|
+
case import_typescript14.default.SyntaxKind.MissingDeclaration:
|
|
196044
196137
|
return null;
|
|
196045
196138
|
default:
|
|
196046
196139
|
return assertNever2(node);
|
|
@@ -196077,7 +196170,7 @@ function transformConditionalBranch(node, ctx) {
|
|
|
196077
196170
|
};
|
|
196078
196171
|
}
|
|
196079
196172
|
function getMapLikeMethod(node) {
|
|
196080
|
-
if (!
|
|
196173
|
+
if (!import_typescript14.default.isPropertyAccessExpression(node.expression))
|
|
196081
196174
|
return null;
|
|
196082
196175
|
const name = node.expression.name.text;
|
|
196083
196176
|
if (name === "map")
|
|
@@ -196087,9 +196180,9 @@ function getMapLikeMethod(node) {
|
|
|
196087
196180
|
return null;
|
|
196088
196181
|
}
|
|
196089
196182
|
function isFilterCall(node) {
|
|
196090
|
-
if (!
|
|
196183
|
+
if (!import_typescript14.default.isCallExpression(node))
|
|
196091
196184
|
return null;
|
|
196092
|
-
if (!
|
|
196185
|
+
if (!import_typescript14.default.isPropertyAccessExpression(node.expression))
|
|
196093
196186
|
return null;
|
|
196094
196187
|
if (node.expression.name.text !== "filter")
|
|
196095
196188
|
return null;
|
|
@@ -196101,9 +196194,9 @@ function isFilterCall(node) {
|
|
|
196101
196194
|
};
|
|
196102
196195
|
}
|
|
196103
196196
|
function isSortCall(node) {
|
|
196104
|
-
if (!
|
|
196197
|
+
if (!import_typescript14.default.isCallExpression(node))
|
|
196105
196198
|
return null;
|
|
196106
|
-
if (!
|
|
196199
|
+
if (!import_typescript14.default.isPropertyAccessExpression(node.expression))
|
|
196107
196200
|
return null;
|
|
196108
196201
|
const methodName = node.expression.name.text;
|
|
196109
196202
|
if (methodName !== "sort" && methodName !== "toSorted")
|
|
@@ -196117,9 +196210,9 @@ function isSortCall(node) {
|
|
|
196117
196210
|
};
|
|
196118
196211
|
}
|
|
196119
196212
|
function isIteratorShapeCall(node) {
|
|
196120
|
-
if (!
|
|
196213
|
+
if (!import_typescript14.default.isCallExpression(node))
|
|
196121
196214
|
return null;
|
|
196122
|
-
if (!
|
|
196215
|
+
if (!import_typescript14.default.isPropertyAccessExpression(node.expression))
|
|
196123
196216
|
return null;
|
|
196124
196217
|
if (node.arguments.length !== 0)
|
|
196125
196218
|
return null;
|
|
@@ -196129,11 +196222,11 @@ function isIteratorShapeCall(node) {
|
|
|
196129
196222
|
return { array: node.expression.expression, shape: name };
|
|
196130
196223
|
}
|
|
196131
196224
|
function isObjectIteratorCall(node) {
|
|
196132
|
-
if (!
|
|
196225
|
+
if (!import_typescript14.default.isCallExpression(node))
|
|
196133
196226
|
return null;
|
|
196134
|
-
if (!
|
|
196227
|
+
if (!import_typescript14.default.isPropertyAccessExpression(node.expression))
|
|
196135
196228
|
return null;
|
|
196136
|
-
if (!
|
|
196229
|
+
if (!import_typescript14.default.isIdentifier(node.expression.expression))
|
|
196137
196230
|
return null;
|
|
196138
196231
|
if (node.expression.expression.text !== "Object")
|
|
196139
196232
|
return null;
|
|
@@ -196158,7 +196251,7 @@ function extractSortComparator(callback, _method, ctx) {
|
|
|
196158
196251
|
` + `(reverse the operands for descending order).`
|
|
196159
196252
|
});
|
|
196160
196253
|
let resolvedNode = callback;
|
|
196161
|
-
if (
|
|
196254
|
+
if (import_typescript14.default.isIdentifier(callback)) {
|
|
196162
196255
|
const resolved = resolveSortComparatorIdentifier(callback.text, ctx);
|
|
196163
196256
|
if (!resolved) {
|
|
196164
196257
|
return {
|
|
@@ -196168,7 +196261,7 @@ function extractSortComparator(callback, _method, ctx) {
|
|
|
196168
196261
|
}
|
|
196169
196262
|
resolvedNode = resolved;
|
|
196170
196263
|
}
|
|
196171
|
-
if (!
|
|
196264
|
+
if (!import_typescript14.default.isArrowFunction(resolvedNode) && !import_typescript14.default.isFunctionExpression(resolvedNode)) {
|
|
196172
196265
|
return {
|
|
196173
196266
|
result: null,
|
|
196174
196267
|
unsupportedReason: "Sort comparator must be an arrow function or function expression"
|
|
@@ -196195,11 +196288,11 @@ function resolveSortComparatorIdentifier(name, ctx) {
|
|
|
196195
196288
|
return null;
|
|
196196
196289
|
if (constInfo) {
|
|
196197
196290
|
const ast = parseConstInitializer(constInfo);
|
|
196198
|
-
return ast && (
|
|
196291
|
+
return ast && (import_typescript14.default.isArrowFunction(ast) || import_typescript14.default.isFunctionExpression(ast)) ? ast : null;
|
|
196199
196292
|
}
|
|
196200
196293
|
if (fnInfo) {
|
|
196201
196294
|
const ast = parseFunctionInfoAsExpr(fnInfo);
|
|
196202
|
-
return ast && (
|
|
196295
|
+
return ast && (import_typescript14.default.isArrowFunction(ast) || import_typescript14.default.isFunctionExpression(ast)) ? ast : null;
|
|
196203
196296
|
}
|
|
196204
196297
|
return null;
|
|
196205
196298
|
}
|
|
@@ -196210,11 +196303,11 @@ function resolveCallbackMethodFunctionReferenceIdentifier(name, analyzer) {
|
|
|
196210
196303
|
return null;
|
|
196211
196304
|
if (constInfo) {
|
|
196212
196305
|
const ast = parseConstInitializer(constInfo);
|
|
196213
|
-
return ast && (
|
|
196306
|
+
return ast && (import_typescript14.default.isArrowFunction(ast) || import_typescript14.default.isFunctionExpression(ast)) ? ast : null;
|
|
196214
196307
|
}
|
|
196215
196308
|
if (fnInfo) {
|
|
196216
196309
|
const ast = parseFunctionInfoAsExpr(fnInfo);
|
|
196217
|
-
return ast && (
|
|
196310
|
+
return ast && (import_typescript14.default.isArrowFunction(ast) || import_typescript14.default.isFunctionExpression(ast)) ? ast : null;
|
|
196218
196311
|
}
|
|
196219
196312
|
return null;
|
|
196220
196313
|
}
|
|
@@ -196273,13 +196366,13 @@ function resolveCallbackMethodFunctionReferences(expr, analyzer, bound = EMPTY_B
|
|
|
196273
196366
|
return visit2(expr, bound);
|
|
196274
196367
|
}
|
|
196275
196368
|
function extractFilterPredicate(callback, ctx) {
|
|
196276
|
-
if (!
|
|
196369
|
+
if (!import_typescript14.default.isArrowFunction(callback))
|
|
196277
196370
|
return { result: null };
|
|
196278
196371
|
if (callback.parameters.length < 1)
|
|
196279
196372
|
return { result: null };
|
|
196280
196373
|
const firstParam = callback.parameters[0];
|
|
196281
|
-
if (!
|
|
196282
|
-
if (
|
|
196374
|
+
if (!import_typescript14.default.isIdentifier(firstParam.name)) {
|
|
196375
|
+
if (import_typescript14.default.isBlock(callback.body)) {
|
|
196283
196376
|
return {
|
|
196284
196377
|
result: null,
|
|
196285
196378
|
unsupportedReason: "Block body in a destructured filter param is not supported. Workaround: use an expression-body arrow, or add /* @client */."
|
|
@@ -196299,7 +196392,7 @@ function extractFilterPredicate(callback, ctx) {
|
|
|
196299
196392
|
return { result: null };
|
|
196300
196393
|
}
|
|
196301
196394
|
const param = firstParam.name.getText(ctx.sourceFile);
|
|
196302
|
-
if (
|
|
196395
|
+
if (import_typescript14.default.isBlock(callback.body)) {
|
|
196303
196396
|
const raw2 = ctx.getJS(callback.body);
|
|
196304
196397
|
const statements = parseBlockBody(callback.body, ctx.sourceFile, (n) => ctx.getJS(n));
|
|
196305
196398
|
if (!statements) {
|
|
@@ -196325,7 +196418,7 @@ function extractFilterPredicate(callback, ctx) {
|
|
|
196325
196418
|
return { result: { param, predicate, raw } };
|
|
196326
196419
|
}
|
|
196327
196420
|
function extractLoopParamBindings(pattern) {
|
|
196328
|
-
if (
|
|
196421
|
+
if (import_typescript14.default.isIdentifier(pattern))
|
|
196329
196422
|
return null;
|
|
196330
196423
|
const bindings = [];
|
|
196331
196424
|
let unsupported = false;
|
|
@@ -196334,7 +196427,7 @@ function extractLoopParamBindings(pattern) {
|
|
|
196334
196427
|
return false;
|
|
196335
196428
|
for (let i2 = 0;i2 < key.length; ) {
|
|
196336
196429
|
const cp = key.codePointAt(i2);
|
|
196337
|
-
const ok = i2 === 0 ?
|
|
196430
|
+
const ok = i2 === 0 ? import_typescript14.default.isIdentifierStart(cp, import_typescript14.default.ScriptTarget.Latest) : import_typescript14.default.isIdentifierPart(cp, import_typescript14.default.ScriptTarget.Latest);
|
|
196338
196431
|
if (!ok)
|
|
196339
196432
|
return false;
|
|
196340
196433
|
i2 += cp > 65535 ? 2 : 1;
|
|
@@ -196347,17 +196440,17 @@ function extractLoopParamBindings(pattern) {
|
|
|
196347
196440
|
const walk = (p, prefix, segments) => {
|
|
196348
196441
|
if (unsupported)
|
|
196349
196442
|
return;
|
|
196350
|
-
if (
|
|
196443
|
+
if (import_typescript14.default.isArrayBindingPattern(p)) {
|
|
196351
196444
|
const elements2 = p.elements;
|
|
196352
196445
|
for (let index = 0;index < elements2.length; index++) {
|
|
196353
196446
|
if (unsupported)
|
|
196354
196447
|
return;
|
|
196355
196448
|
const el = elements2[index];
|
|
196356
|
-
if (
|
|
196449
|
+
if (import_typescript14.default.isOmittedExpression(el))
|
|
196357
196450
|
continue;
|
|
196358
196451
|
if (el.dotDotDotToken) {
|
|
196359
196452
|
internalInvariant(index === elements2.length - 1, "extractLoopParamBindings: array rest token in non-final position (parser should reject)");
|
|
196360
|
-
internalInvariant(
|
|
196453
|
+
internalInvariant(import_typescript14.default.isIdentifier(el.name), "extractLoopParamBindings: array rest target is not an identifier (parser should reject)");
|
|
196361
196454
|
bindings.push({
|
|
196362
196455
|
name: el.name.text,
|
|
196363
196456
|
path: prefix,
|
|
@@ -196368,7 +196461,7 @@ function extractLoopParamBindings(pattern) {
|
|
|
196368
196461
|
}
|
|
196369
196462
|
const path = `${prefix}[${index}]`;
|
|
196370
196463
|
const nextSegments = [...segments, { kind: "index", index }];
|
|
196371
|
-
if (
|
|
196464
|
+
if (import_typescript14.default.isIdentifier(el.name)) {
|
|
196372
196465
|
bindings.push({ name: el.name.text, path, segments: nextSegments });
|
|
196373
196466
|
} else {
|
|
196374
196467
|
walk(el.name, path, nextSegments);
|
|
@@ -196384,7 +196477,7 @@ function extractLoopParamBindings(pattern) {
|
|
|
196384
196477
|
const el = elements[i2];
|
|
196385
196478
|
if (el.dotDotDotToken) {
|
|
196386
196479
|
internalInvariant(i2 === elements.length - 1, "extractLoopParamBindings: object rest token in non-final position (parser should reject)");
|
|
196387
|
-
internalInvariant(
|
|
196480
|
+
internalInvariant(import_typescript14.default.isIdentifier(el.name), "extractLoopParamBindings: object rest target is not an identifier (parser should reject)");
|
|
196388
196481
|
bindings.push({
|
|
196389
196482
|
name: el.name.text,
|
|
196390
196483
|
path: prefix,
|
|
@@ -196396,17 +196489,17 @@ function extractLoopParamBindings(pattern) {
|
|
|
196396
196489
|
let keyText = null;
|
|
196397
196490
|
if (el.propertyName) {
|
|
196398
196491
|
const pn = el.propertyName;
|
|
196399
|
-
if (
|
|
196492
|
+
if (import_typescript14.default.isIdentifier(pn))
|
|
196400
196493
|
keyText = pn.text;
|
|
196401
|
-
else if (
|
|
196494
|
+
else if (import_typescript14.default.isStringLiteral(pn))
|
|
196402
196495
|
keyText = pn.text;
|
|
196403
|
-
else if (
|
|
196496
|
+
else if (import_typescript14.default.isNumericLiteral(pn))
|
|
196404
196497
|
keyText = pn.text;
|
|
196405
196498
|
else {
|
|
196406
196499
|
unsupported = true;
|
|
196407
196500
|
return;
|
|
196408
196501
|
}
|
|
196409
|
-
} else if (
|
|
196502
|
+
} else if (import_typescript14.default.isIdentifier(el.name)) {
|
|
196410
196503
|
keyText = el.name.text;
|
|
196411
196504
|
} else {
|
|
196412
196505
|
unsupported = true;
|
|
@@ -196416,14 +196509,14 @@ function extractLoopParamBindings(pattern) {
|
|
|
196416
196509
|
collectedKeys.push({ key: keyText, isIdent: keyIsIdent });
|
|
196417
196510
|
const path = appendDotAccess(prefix, keyText);
|
|
196418
196511
|
const nextSegments = [...segments, { kind: "field", key: keyText, isIdent: keyIsIdent }];
|
|
196419
|
-
if (
|
|
196512
|
+
if (import_typescript14.default.isIdentifier(el.name)) {
|
|
196420
196513
|
bindings.push({ name: el.name.text, path, segments: nextSegments });
|
|
196421
196514
|
} else {
|
|
196422
196515
|
walk(el.name, path, nextSegments);
|
|
196423
196516
|
}
|
|
196424
196517
|
}
|
|
196425
196518
|
};
|
|
196426
|
-
if (
|
|
196519
|
+
if (import_typescript14.default.isArrayBindingPattern(pattern) || import_typescript14.default.isObjectBindingPattern(pattern)) {
|
|
196427
196520
|
walk(pattern, "", []);
|
|
196428
196521
|
if (unsupported)
|
|
196429
196522
|
return { unsupported: true };
|
|
@@ -196433,7 +196526,7 @@ function extractLoopParamBindings(pattern) {
|
|
|
196433
196526
|
}
|
|
196434
196527
|
function findKeyJsxAttribute(opening) {
|
|
196435
196528
|
for (const prop of opening.attributes.properties) {
|
|
196436
|
-
if (
|
|
196529
|
+
if (import_typescript14.default.isJsxAttribute(prop) && prop.name.getText() === "key") {
|
|
196437
196530
|
return prop;
|
|
196438
196531
|
}
|
|
196439
196532
|
}
|
|
@@ -196482,7 +196575,7 @@ function keyAttrValueToExpr(v) {
|
|
|
196482
196575
|
function normalizeKeyExpr(expr) {
|
|
196483
196576
|
let out = "";
|
|
196484
196577
|
for (const tok of iterateJsTokens(expr)) {
|
|
196485
|
-
if (tok.kind ===
|
|
196578
|
+
if (tok.kind === import_typescript14.default.SyntaxKind.WhitespaceTrivia || tok.kind === import_typescript14.default.SyntaxKind.NewLineTrivia) {
|
|
196486
196579
|
continue;
|
|
196487
196580
|
}
|
|
196488
196581
|
out += expr.slice(tok.pos, tok.end);
|
|
@@ -196494,13 +196587,13 @@ function conditionalHasExplicitNullishBranch(cond) {
|
|
|
196494
196587
|
}
|
|
196495
196588
|
function branchHasExplicitNullish(branch) {
|
|
196496
196589
|
let b = branch;
|
|
196497
|
-
while (
|
|
196590
|
+
while (import_typescript14.default.isParenthesizedExpression(b))
|
|
196498
196591
|
b = b.expression;
|
|
196499
|
-
if (b.kind ===
|
|
196592
|
+
if (b.kind === import_typescript14.default.SyntaxKind.NullKeyword)
|
|
196500
196593
|
return true;
|
|
196501
|
-
if (
|
|
196594
|
+
if (import_typescript14.default.isIdentifier(b) && b.text === "undefined")
|
|
196502
196595
|
return true;
|
|
196503
|
-
if (
|
|
196596
|
+
if (import_typescript14.default.isConditionalExpression(b))
|
|
196504
196597
|
return conditionalHasExplicitNullishBranch(b);
|
|
196505
196598
|
return false;
|
|
196506
196599
|
}
|
|
@@ -196509,26 +196602,26 @@ function classifyKeyProblem(keyAttr, checker) {
|
|
|
196509
196602
|
return "missing";
|
|
196510
196603
|
if (!keyAttr.initializer)
|
|
196511
196604
|
return "missing";
|
|
196512
|
-
if (
|
|
196605
|
+
if (import_typescript14.default.isJsxExpression(keyAttr.initializer) && !keyAttr.initializer.expression) {
|
|
196513
196606
|
return "missing";
|
|
196514
196607
|
}
|
|
196515
196608
|
let expr;
|
|
196516
|
-
if (
|
|
196609
|
+
if (import_typescript14.default.isStringLiteral(keyAttr.initializer)) {
|
|
196517
196610
|
return null;
|
|
196518
|
-
} else if (
|
|
196611
|
+
} else if (import_typescript14.default.isJsxExpression(keyAttr.initializer)) {
|
|
196519
196612
|
expr = keyAttr.initializer.expression;
|
|
196520
196613
|
}
|
|
196521
196614
|
if (!expr)
|
|
196522
196615
|
return null;
|
|
196523
|
-
if (expr.kind ===
|
|
196616
|
+
if (expr.kind === import_typescript14.default.SyntaxKind.NullKeyword)
|
|
196524
196617
|
return null;
|
|
196525
|
-
if (
|
|
196618
|
+
if (import_typescript14.default.isIdentifier(expr) && expr.text === "undefined")
|
|
196526
196619
|
return null;
|
|
196527
|
-
if (
|
|
196620
|
+
if (import_typescript14.default.isConditionalExpression(expr) && conditionalHasExplicitNullishBranch(expr))
|
|
196528
196621
|
return null;
|
|
196529
196622
|
if (checker) {
|
|
196530
196623
|
const type2 = checker.getTypeAtLocation(expr);
|
|
196531
|
-
const isNullable = type2.isUnion() ? type2.types.some((t) => (t.flags & (
|
|
196624
|
+
const isNullable = type2.isUnion() ? type2.types.some((t) => (t.flags & (import_typescript14.default.TypeFlags.Null | import_typescript14.default.TypeFlags.Undefined | import_typescript14.default.TypeFlags.Void)) !== 0) : (type2.flags & (import_typescript14.default.TypeFlags.Null | import_typescript14.default.TypeFlags.Undefined | import_typescript14.default.TypeFlags.Void)) !== 0;
|
|
196532
196625
|
if (isNullable)
|
|
196533
196626
|
return "nullable-type";
|
|
196534
196627
|
}
|
|
@@ -196554,81 +196647,81 @@ function checkLoopKey(callback, ctx, isNested) {
|
|
|
196554
196647
|
ctx.analyzer.errors.push(createError(errorCode, getSourceLocation(locNode, ctx.sourceFile, ctx.filePath), { suggestion: { message: keyErrorSuggestion(problem) } }));
|
|
196555
196648
|
}
|
|
196556
196649
|
let body = callback.body;
|
|
196557
|
-
if (
|
|
196558
|
-
const ret = body.statements.find((s) =>
|
|
196650
|
+
if (import_typescript14.default.isBlock(body)) {
|
|
196651
|
+
const ret = body.statements.find((s) => import_typescript14.default.isReturnStatement(s) && s.expression != null);
|
|
196559
196652
|
if (!ret?.expression)
|
|
196560
196653
|
return;
|
|
196561
196654
|
body = ret.expression;
|
|
196562
196655
|
}
|
|
196563
|
-
while (
|
|
196656
|
+
while (import_typescript14.default.isParenthesizedExpression(body))
|
|
196564
196657
|
body = body.expression;
|
|
196565
196658
|
function checkJsxOperand(node) {
|
|
196566
196659
|
let n = node;
|
|
196567
|
-
while (
|
|
196660
|
+
while (import_typescript14.default.isParenthesizedExpression(n))
|
|
196568
196661
|
n = n.expression;
|
|
196569
|
-
if (
|
|
196662
|
+
if (import_typescript14.default.isJsxElement(n))
|
|
196570
196663
|
checkOpening(n.openingElement);
|
|
196571
|
-
else if (
|
|
196664
|
+
else if (import_typescript14.default.isJsxSelfClosingElement(n))
|
|
196572
196665
|
checkOpening(n);
|
|
196573
196666
|
}
|
|
196574
|
-
if (
|
|
196667
|
+
if (import_typescript14.default.isConditionalExpression(body)) {
|
|
196575
196668
|
checkJsxOperand(body.whenTrue);
|
|
196576
196669
|
checkJsxOperand(body.whenFalse);
|
|
196577
196670
|
return;
|
|
196578
196671
|
}
|
|
196579
|
-
if (
|
|
196672
|
+
if (import_typescript14.default.isBinaryExpression(body) && (body.operatorToken.kind === import_typescript14.default.SyntaxKind.AmpersandAmpersandToken || body.operatorToken.kind === import_typescript14.default.SyntaxKind.BarBarToken || body.operatorToken.kind === import_typescript14.default.SyntaxKind.QuestionQuestionToken)) {
|
|
196580
196673
|
checkJsxOperand(body.left);
|
|
196581
196674
|
checkJsxOperand(body.right);
|
|
196582
196675
|
return;
|
|
196583
196676
|
}
|
|
196584
|
-
if (
|
|
196677
|
+
if (import_typescript14.default.isJsxElement(body)) {
|
|
196585
196678
|
checkOpening(body.openingElement);
|
|
196586
196679
|
return;
|
|
196587
196680
|
}
|
|
196588
|
-
if (
|
|
196681
|
+
if (import_typescript14.default.isJsxSelfClosingElement(body)) {
|
|
196589
196682
|
checkOpening(body);
|
|
196590
196683
|
return;
|
|
196591
196684
|
}
|
|
196592
196685
|
}
|
|
196593
196686
|
function flatMapProjectionCall(body) {
|
|
196594
196687
|
let expr;
|
|
196595
|
-
if (
|
|
196688
|
+
if (import_typescript14.default.isBlock(body)) {
|
|
196596
196689
|
const real = body.statements;
|
|
196597
|
-
if (real.length !== 1 || !
|
|
196690
|
+
if (real.length !== 1 || !import_typescript14.default.isReturnStatement(real[0]) || !real[0].expression)
|
|
196598
196691
|
return null;
|
|
196599
196692
|
expr = real[0].expression;
|
|
196600
196693
|
} else {
|
|
196601
196694
|
expr = body;
|
|
196602
196695
|
}
|
|
196603
|
-
while (
|
|
196696
|
+
while (import_typescript14.default.isParenthesizedExpression(expr))
|
|
196604
196697
|
expr = expr.expression;
|
|
196605
|
-
if (!
|
|
196698
|
+
if (!import_typescript14.default.isCallExpression(expr))
|
|
196606
196699
|
return null;
|
|
196607
196700
|
if (!getMapLikeMethod(expr))
|
|
196608
196701
|
return null;
|
|
196609
196702
|
const cb = expr.arguments[0];
|
|
196610
|
-
if (!cb || !
|
|
196703
|
+
if (!cb || !import_typescript14.default.isArrowFunction(cb) && !import_typescript14.default.isFunctionExpression(cb))
|
|
196611
196704
|
return null;
|
|
196612
196705
|
for (const p of cb.parameters) {
|
|
196613
|
-
if (!
|
|
196706
|
+
if (!import_typescript14.default.isIdentifier(p.name))
|
|
196614
196707
|
return null;
|
|
196615
196708
|
}
|
|
196616
196709
|
let innerBody = cb.body;
|
|
196617
|
-
if (
|
|
196618
|
-
const ret = innerBody.statements.find((s) =>
|
|
196710
|
+
if (import_typescript14.default.isBlock(innerBody)) {
|
|
196711
|
+
const ret = innerBody.statements.find((s) => import_typescript14.default.isReturnStatement(s) && s.expression != null);
|
|
196619
196712
|
if (innerBody.statements.length !== 1 || !ret?.expression)
|
|
196620
196713
|
return null;
|
|
196621
196714
|
innerBody = ret.expression;
|
|
196622
196715
|
}
|
|
196623
|
-
while (
|
|
196716
|
+
while (import_typescript14.default.isParenthesizedExpression(innerBody))
|
|
196624
196717
|
innerBody = innerBody.expression;
|
|
196625
196718
|
const isElementish = (n) => {
|
|
196626
196719
|
let m = n;
|
|
196627
|
-
while (
|
|
196720
|
+
while (import_typescript14.default.isParenthesizedExpression(m))
|
|
196628
196721
|
m = m.expression;
|
|
196629
|
-
if (
|
|
196722
|
+
if (import_typescript14.default.isJsxElement(m) || import_typescript14.default.isJsxSelfClosingElement(m))
|
|
196630
196723
|
return leafIsWirelessElement(m);
|
|
196631
|
-
if (
|
|
196724
|
+
if (import_typescript14.default.isConditionalExpression(m))
|
|
196632
196725
|
return isElementish(m.whenTrue) && isElementish(m.whenFalse);
|
|
196633
196726
|
return false;
|
|
196634
196727
|
};
|
|
@@ -196641,19 +196734,19 @@ function leafIsWirelessElement(el) {
|
|
|
196641
196734
|
const visit2 = (n) => {
|
|
196642
196735
|
if (!ok)
|
|
196643
196736
|
return;
|
|
196644
|
-
if (
|
|
196737
|
+
if (import_typescript14.default.isJsxOpeningElement(n) || import_typescript14.default.isJsxSelfClosingElement(n)) {
|
|
196645
196738
|
const tagNode = n.tagName;
|
|
196646
|
-
const isIntrinsic =
|
|
196739
|
+
const isIntrinsic = import_typescript14.default.isIdentifier(tagNode) ? !/^[A-Z]/.test(tagNode.text) : import_typescript14.default.isJsxNamespacedName(tagNode);
|
|
196647
196740
|
if (!isIntrinsic) {
|
|
196648
196741
|
ok = false;
|
|
196649
196742
|
return;
|
|
196650
196743
|
}
|
|
196651
196744
|
for (const attr of n.attributes.properties) {
|
|
196652
|
-
if (
|
|
196745
|
+
if (import_typescript14.default.isJsxSpreadAttribute(attr)) {
|
|
196653
196746
|
ok = false;
|
|
196654
196747
|
return;
|
|
196655
196748
|
}
|
|
196656
|
-
if (
|
|
196749
|
+
if (import_typescript14.default.isJsxAttribute(attr)) {
|
|
196657
196750
|
const name = attr.name.getText();
|
|
196658
196751
|
if (isEventHandlerAttrName(name)) {
|
|
196659
196752
|
ok = false;
|
|
@@ -196662,11 +196755,11 @@ function leafIsWirelessElement(el) {
|
|
|
196662
196755
|
}
|
|
196663
196756
|
}
|
|
196664
196757
|
}
|
|
196665
|
-
if (
|
|
196758
|
+
if (import_typescript14.default.isCallExpression(n) && getMapLikeMethod(n) && containsJsxInExpression(n)) {
|
|
196666
196759
|
ok = false;
|
|
196667
196760
|
return;
|
|
196668
196761
|
}
|
|
196669
|
-
|
|
196762
|
+
import_typescript14.default.forEachChild(n, visit2);
|
|
196670
196763
|
};
|
|
196671
196764
|
visit2(el);
|
|
196672
196765
|
return ok;
|
|
@@ -196862,7 +196955,7 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
|
|
|
196862
196955
|
let children = [];
|
|
196863
196956
|
let paramBindings;
|
|
196864
196957
|
let flatMapCallback;
|
|
196865
|
-
if (
|
|
196958
|
+
if (import_typescript14.default.isArrowFunction(callback)) {
|
|
196866
196959
|
if (callback.parameters.length > 0) {
|
|
196867
196960
|
const firstParam = callback.parameters[0];
|
|
196868
196961
|
param = firstParam.name.getText(ctx.sourceFile);
|
|
@@ -196870,9 +196963,9 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
|
|
|
196870
196963
|
paramType = firstParam.type.getText(ctx.sourceFile);
|
|
196871
196964
|
}
|
|
196872
196965
|
const isEntriesShape = iterationShape === "entries" || objectIteration === "entries";
|
|
196873
|
-
if (isEntriesShape &&
|
|
196874
|
-
const elements = firstParam.name.elements.filter((el) => !
|
|
196875
|
-
if (elements.length === 2 &&
|
|
196966
|
+
if (isEntriesShape && import_typescript14.default.isArrayBindingPattern(firstParam.name)) {
|
|
196967
|
+
const elements = firstParam.name.elements.filter((el) => !import_typescript14.default.isOmittedExpression(el));
|
|
196968
|
+
if (elements.length === 2 && import_typescript14.default.isBindingElement(elements[0]) && import_typescript14.default.isIdentifier(elements[0].name) && import_typescript14.default.isBindingElement(elements[1]) && import_typescript14.default.isIdentifier(elements[1].name)) {
|
|
196876
196969
|
index = elements[0].name.text;
|
|
196877
196970
|
param = elements[1].name.text;
|
|
196878
196971
|
} else {
|
|
@@ -196903,10 +196996,10 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
|
|
|
196903
196996
|
ctx.scope = ctx.scope.enterLoopRow({ param, index, paramBindings });
|
|
196904
196997
|
ctx.loopDepth++;
|
|
196905
196998
|
const tryTransformRenderableBody = (expr) => {
|
|
196906
|
-
if (!
|
|
196999
|
+
if (!import_typescript14.default.isBinaryExpression(expr))
|
|
196907
197000
|
return;
|
|
196908
197001
|
const op = expr.operatorToken.kind;
|
|
196909
|
-
if (op !==
|
|
197002
|
+
if (op !== import_typescript14.default.SyntaxKind.AmpersandAmpersandToken && op !== import_typescript14.default.SyntaxKind.BarBarToken && op !== import_typescript14.default.SyntaxKind.QuestionQuestionToken) {
|
|
196910
197003
|
return;
|
|
196911
197004
|
}
|
|
196912
197005
|
if (!containsJsxInExpression(expr) && !callsJsxHelper(expr, ctx))
|
|
@@ -196916,33 +197009,33 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
|
|
|
196916
197009
|
children = [transformed];
|
|
196917
197010
|
};
|
|
196918
197011
|
const body = callback.body;
|
|
196919
|
-
if (
|
|
197012
|
+
if (import_typescript14.default.isJsxElement(body) || import_typescript14.default.isJsxSelfClosingElement(body) || import_typescript14.default.isJsxFragment(body)) {
|
|
196920
197013
|
const transformed = transformNode(body, ctx);
|
|
196921
197014
|
if (transformed) {
|
|
196922
197015
|
children = [transformed];
|
|
196923
197016
|
}
|
|
196924
|
-
} else if (
|
|
197017
|
+
} else if (import_typescript14.default.isConditionalExpression(body)) {
|
|
196925
197018
|
children = [transformConditional(body, ctx)];
|
|
196926
|
-
} else if (
|
|
197019
|
+
} else if (import_typescript14.default.isParenthesizedExpression(body)) {
|
|
196927
197020
|
let inner = body.expression;
|
|
196928
|
-
while (
|
|
197021
|
+
while (import_typescript14.default.isParenthesizedExpression(inner)) {
|
|
196929
197022
|
inner = inner.expression;
|
|
196930
197023
|
}
|
|
196931
|
-
if (
|
|
197024
|
+
if (import_typescript14.default.isJsxElement(inner) || import_typescript14.default.isJsxSelfClosingElement(inner) || import_typescript14.default.isJsxFragment(inner)) {
|
|
196932
197025
|
const transformed = transformNode(inner, ctx);
|
|
196933
197026
|
if (transformed) {
|
|
196934
197027
|
children = [transformed];
|
|
196935
197028
|
}
|
|
196936
|
-
} else if (
|
|
197029
|
+
} else if (import_typescript14.default.isConditionalExpression(inner)) {
|
|
196937
197030
|
children = [transformConditional(inner, ctx)];
|
|
196938
|
-
} else if (method === "flatMap" &&
|
|
197031
|
+
} else if (method === "flatMap" && import_typescript14.default.isArrayLiteralExpression(inner)) {
|
|
196939
197032
|
children = transformArrayLiteralChildren(inner, ctx);
|
|
196940
197033
|
} else {
|
|
196941
197034
|
tryTransformRenderableBody(inner);
|
|
196942
197035
|
}
|
|
196943
|
-
} else if (method === "flatMap" &&
|
|
197036
|
+
} else if (method === "flatMap" && import_typescript14.default.isArrayLiteralExpression(body)) {
|
|
196944
197037
|
children = transformArrayLiteralChildren(body, ctx);
|
|
196945
|
-
} else if (
|
|
197038
|
+
} else if (import_typescript14.default.isBlock(body)) {
|
|
196946
197039
|
const multiReturn = method !== "flatMap" ? extractMultiReturnJsxBranches(body, true) : null;
|
|
196947
197040
|
if (multiReturn && multiReturn.branches.length > 0) {
|
|
196948
197041
|
const loc = getSourceLocation(body, ctx.sourceFile, ctx.filePath);
|
|
@@ -196960,7 +197053,7 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
|
|
|
196960
197053
|
}
|
|
196961
197054
|
}
|
|
196962
197055
|
}
|
|
196963
|
-
const returnStmt = children.length === 0 ? body.statements.find((s) =>
|
|
197056
|
+
const returnStmt = children.length === 0 ? body.statements.find((s) => import_typescript14.default.isReturnStatement(s) && s.expression != null) : undefined;
|
|
196964
197057
|
let rowScopeBeforePreamble = null;
|
|
196965
197058
|
if (returnStmt) {
|
|
196966
197059
|
const preambleNames = new Set;
|
|
@@ -196981,10 +197074,10 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
|
|
|
196981
197074
|
}
|
|
196982
197075
|
if (returnStmt && returnStmt.expression) {
|
|
196983
197076
|
let returnExpr = returnStmt.expression;
|
|
196984
|
-
while (
|
|
197077
|
+
while (import_typescript14.default.isParenthesizedExpression(returnExpr)) {
|
|
196985
197078
|
returnExpr = returnExpr.expression;
|
|
196986
197079
|
}
|
|
196987
|
-
if (
|
|
197080
|
+
if (import_typescript14.default.isJsxElement(returnExpr) || import_typescript14.default.isJsxSelfClosingElement(returnExpr) || import_typescript14.default.isJsxFragment(returnExpr)) {
|
|
196988
197081
|
const transformed = transformNode(returnExpr, ctx);
|
|
196989
197082
|
if (transformed) {
|
|
196990
197083
|
children = [transformed];
|
|
@@ -197066,7 +197159,7 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
|
|
|
197066
197159
|
}
|
|
197067
197160
|
}
|
|
197068
197161
|
}
|
|
197069
|
-
if (method === "flatMap" && children.length === 0 && !flatMapCallback && !
|
|
197162
|
+
if (method === "flatMap" && children.length === 0 && !flatMapCallback && !import_typescript14.default.isBlock(body)) {
|
|
197070
197163
|
flatMapCallback = buildFlatMapCallback(callback, body, ctx);
|
|
197071
197164
|
}
|
|
197072
197165
|
if (flatMapCallback)
|
|
@@ -197084,7 +197177,7 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
|
|
|
197084
197177
|
}
|
|
197085
197178
|
if (children.length === 0 && !flatMapCallback) {
|
|
197086
197179
|
const cb = node.arguments[0];
|
|
197087
|
-
const cbBody = cb && (
|
|
197180
|
+
const cbBody = cb && (import_typescript14.default.isArrowFunction(cb) || import_typescript14.default.isFunctionExpression(cb)) ? cb.body : undefined;
|
|
197088
197181
|
if (cbBody && containsJsxInExpression(cbBody) && ctx.analyzer.errors.length === diagCountAtEntry) {
|
|
197089
197182
|
ctx.analyzer.errors.push(createError(ErrorCodes.UNSUPPORTED_JSX_PATTERN, getSourceLocation(cbBody, ctx.sourceFile, ctx.filePath), {
|
|
197090
197183
|
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.",
|
|
@@ -197095,7 +197188,7 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
|
|
|
197095
197188
|
}
|
|
197096
197189
|
return null;
|
|
197097
197190
|
}
|
|
197098
|
-
if (
|
|
197191
|
+
if (import_typescript14.default.isArrowFunction(node.arguments[0]) && children.length > 0) {
|
|
197099
197192
|
checkLoopKey(node.arguments[0], ctx, isNested);
|
|
197100
197193
|
}
|
|
197101
197194
|
const itemConditional = children.length > 0 ? loopBodyItemConditional(children) : null;
|
|
@@ -197203,12 +197296,12 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
|
|
|
197203
197296
|
function transformArrayLiteralChildren(arrayLiteral, ctx) {
|
|
197204
197297
|
const children = [];
|
|
197205
197298
|
for (const element of arrayLiteral.elements) {
|
|
197206
|
-
if (
|
|
197299
|
+
if (import_typescript14.default.isSpreadElement(element))
|
|
197207
197300
|
continue;
|
|
197208
197301
|
let inner = element;
|
|
197209
|
-
while (
|
|
197302
|
+
while (import_typescript14.default.isParenthesizedExpression(inner))
|
|
197210
197303
|
inner = inner.expression;
|
|
197211
|
-
if (
|
|
197304
|
+
if (import_typescript14.default.isJsxElement(inner) || import_typescript14.default.isJsxSelfClosingElement(inner) || import_typescript14.default.isJsxFragment(inner)) {
|
|
197212
197305
|
const transformed = transformNode(inner, ctx);
|
|
197213
197306
|
if (transformed)
|
|
197214
197307
|
children.push(transformed);
|
|
@@ -197217,7 +197310,7 @@ function transformArrayLiteralChildren(arrayLiteral, ctx) {
|
|
|
197217
197310
|
return children;
|
|
197218
197311
|
}
|
|
197219
197312
|
function containsJsx(node) {
|
|
197220
|
-
if (
|
|
197313
|
+
if (import_typescript14.default.isJsxElement(node) || import_typescript14.default.isJsxSelfClosingElement(node) || import_typescript14.default.isJsxFragment(node))
|
|
197221
197314
|
return true;
|
|
197222
197315
|
let found = false;
|
|
197223
197316
|
node.forEachChild((child) => {
|
|
@@ -197233,7 +197326,7 @@ function buildFlatMapCallback(callback, body, ctx) {
|
|
|
197233
197326
|
const leafIrs = [];
|
|
197234
197327
|
let refusalNode;
|
|
197235
197328
|
const collectJsx = (n, underTemplate) => {
|
|
197236
|
-
if (
|
|
197329
|
+
if (import_typescript14.default.isJsxElement(n) || import_typescript14.default.isJsxSelfClosingElement(n) || import_typescript14.default.isJsxFragment(n)) {
|
|
197237
197330
|
if (underTemplate)
|
|
197238
197331
|
refusalNode ??= n;
|
|
197239
197332
|
leafSpans.push({ start: n.getStart(ctx.sourceFile), end: n.getEnd() });
|
|
@@ -197241,7 +197334,7 @@ function buildFlatMapCallback(callback, body, ctx) {
|
|
|
197241
197334
|
leafIrs.push(ir ?? { type: "text", value: "", loc: getSourceLocation(n, ctx.sourceFile, ctx.filePath) });
|
|
197242
197335
|
return;
|
|
197243
197336
|
}
|
|
197244
|
-
const inTemplate = underTemplate ||
|
|
197337
|
+
const inTemplate = underTemplate || import_typescript14.default.isTemplateExpression(n) || import_typescript14.default.isTaggedTemplateExpression(n);
|
|
197245
197338
|
n.forEachChild((c) => collectJsx(c, inTemplate));
|
|
197246
197339
|
};
|
|
197247
197340
|
collectJsx(body, false);
|
|
@@ -197459,28 +197552,28 @@ function attrValueText(value) {
|
|
|
197459
197552
|
return out.join(" ");
|
|
197460
197553
|
}
|
|
197461
197554
|
function collectBindingNames2(name, out) {
|
|
197462
|
-
if (
|
|
197555
|
+
if (import_typescript14.default.isIdentifier(name)) {
|
|
197463
197556
|
out.add(name.text);
|
|
197464
197557
|
return;
|
|
197465
197558
|
}
|
|
197466
197559
|
for (const el of name.elements) {
|
|
197467
|
-
if (
|
|
197560
|
+
if (import_typescript14.default.isBindingElement(el))
|
|
197468
197561
|
collectBindingNames2(el.name, out);
|
|
197469
197562
|
}
|
|
197470
197563
|
}
|
|
197471
197564
|
function collectPreambleDeclaredNames(stmt, out) {
|
|
197472
|
-
if (
|
|
197565
|
+
if (import_typescript14.default.isVariableStatement(stmt)) {
|
|
197473
197566
|
for (const decl of stmt.declarationList.declarations) {
|
|
197474
197567
|
collectBindingNames2(decl.name, out);
|
|
197475
197568
|
}
|
|
197476
|
-
} else if (
|
|
197569
|
+
} else if (import_typescript14.default.isFunctionDeclaration(stmt) && stmt.name) {
|
|
197477
197570
|
out.add(stmt.name.text);
|
|
197478
197571
|
}
|
|
197479
197572
|
}
|
|
197480
197573
|
function computePreambleReactiveNames(statements, ctx) {
|
|
197481
197574
|
const reactiveNames = new Set;
|
|
197482
197575
|
for (const stmt of statements) {
|
|
197483
|
-
if (!
|
|
197576
|
+
if (!import_typescript14.default.isVariableStatement(stmt))
|
|
197484
197577
|
continue;
|
|
197485
197578
|
for (const decl of stmt.declarationList.declarations) {
|
|
197486
197579
|
if (!decl.initializer)
|
|
@@ -197526,10 +197619,10 @@ function preambleFromValueStatements(statements, ctx, bodyStatements) {
|
|
|
197526
197619
|
function neutralPreambleDeclarations(statements, ctx, bodyStatements) {
|
|
197527
197620
|
const out = [];
|
|
197528
197621
|
for (const stmt of statements) {
|
|
197529
|
-
if (!
|
|
197622
|
+
if (!import_typescript14.default.isVariableStatement(stmt))
|
|
197530
197623
|
return null;
|
|
197531
197624
|
for (const decl of stmt.declarationList.declarations) {
|
|
197532
|
-
if (!
|
|
197625
|
+
if (!import_typescript14.default.isIdentifier(decl.name))
|
|
197533
197626
|
return null;
|
|
197534
197627
|
if (!decl.initializer)
|
|
197535
197628
|
return null;
|
|
@@ -197551,22 +197644,22 @@ function neutralPreambleDeclarations(statements, ctx, bodyStatements) {
|
|
|
197551
197644
|
return out;
|
|
197552
197645
|
}
|
|
197553
197646
|
function isFunctionLiteral(node) {
|
|
197554
|
-
return
|
|
197647
|
+
return import_typescript14.default.isArrowFunction(node) || import_typescript14.default.isFunctionExpression(node);
|
|
197555
197648
|
}
|
|
197556
197649
|
function everyReadIsEventHandlerPropValue(name, bodyStatements) {
|
|
197557
197650
|
const findDisallowedRead = (node) => {
|
|
197558
|
-
if (
|
|
197559
|
-
const isBindingName =
|
|
197560
|
-
const isPropertyName =
|
|
197651
|
+
if (import_typescript14.default.isIdentifier(node) && node.text === name) {
|
|
197652
|
+
const isBindingName = import_typescript14.default.isVariableDeclaration(node.parent) && node.parent.name === node;
|
|
197653
|
+
const isPropertyName = import_typescript14.default.isPropertyAccessExpression(node.parent) && node.parent.name === node;
|
|
197561
197654
|
if (!isBindingName && !isPropertyName) {
|
|
197562
197655
|
const jsxExpr = node.parent;
|
|
197563
197656
|
const attr = jsxExpr.parent;
|
|
197564
|
-
const isEventHandlerAttrValue =
|
|
197657
|
+
const isEventHandlerAttrValue = import_typescript14.default.isJsxExpression(jsxExpr) && import_typescript14.default.isJsxAttribute(attr) && attr.initializer === jsxExpr && import_typescript14.default.isIdentifier(attr.name) && isEventHandlerAttrName(attr.name.text);
|
|
197565
197658
|
if (!isEventHandlerAttrValue)
|
|
197566
197659
|
return true;
|
|
197567
197660
|
}
|
|
197568
197661
|
}
|
|
197569
|
-
return
|
|
197662
|
+
return import_typescript14.default.forEachChild(node, findDisallowedRead);
|
|
197570
197663
|
};
|
|
197571
197664
|
return !bodyStatements.some(findDisallowedRead);
|
|
197572
197665
|
}
|
|
@@ -197590,11 +197683,11 @@ function buildPreambleSegments(statements, returnStmt, ctx) {
|
|
|
197590
197683
|
let refusalNode;
|
|
197591
197684
|
const recordBuilderTarget = (leaf, stmt) => {
|
|
197592
197685
|
for (let n = leaf.parent;n && n !== stmt.parent; n = n.parent) {
|
|
197593
|
-
if (
|
|
197686
|
+
if (import_typescript14.default.isCallExpression(n) && import_typescript14.default.isPropertyAccessExpression(n.expression) && (n.expression.name.text === "push" || n.expression.name.text === "unshift") && import_typescript14.default.isIdentifier(n.expression.expression)) {
|
|
197594
197687
|
builders.add(n.expression.expression.text);
|
|
197595
197688
|
return;
|
|
197596
197689
|
}
|
|
197597
|
-
if (
|
|
197690
|
+
if (import_typescript14.default.isVariableDeclaration(n) && import_typescript14.default.isIdentifier(n.name)) {
|
|
197598
197691
|
builders.add(n.name.text);
|
|
197599
197692
|
return;
|
|
197600
197693
|
}
|
|
@@ -197607,7 +197700,7 @@ function buildPreambleSegments(statements, returnStmt, ctx) {
|
|
|
197607
197700
|
const leafSpans = [];
|
|
197608
197701
|
const leafIrs = [];
|
|
197609
197702
|
const collect = (n, underTemplate) => {
|
|
197610
|
-
if (
|
|
197703
|
+
if (import_typescript14.default.isJsxElement(n) || import_typescript14.default.isJsxSelfClosingElement(n) || import_typescript14.default.isJsxFragment(n)) {
|
|
197611
197704
|
if (underTemplate)
|
|
197612
197705
|
refusalNode ??= n;
|
|
197613
197706
|
recordBuilderTarget(n, stmt);
|
|
@@ -197618,7 +197711,7 @@ function buildPreambleSegments(statements, returnStmt, ctx) {
|
|
|
197618
197711
|
leafIrs.push(ir ?? { type: "text", value: "", loc: getSourceLocation(n, ctx.sourceFile, ctx.filePath) });
|
|
197619
197712
|
return;
|
|
197620
197713
|
}
|
|
197621
|
-
const inTemplate = underTemplate ||
|
|
197714
|
+
const inTemplate = underTemplate || import_typescript14.default.isTemplateExpression(n) || import_typescript14.default.isTaggedTemplateExpression(n);
|
|
197622
197715
|
n.forEachChild((c) => collect(c, inTemplate));
|
|
197623
197716
|
};
|
|
197624
197717
|
collect(stmt, false);
|
|
@@ -197722,13 +197815,13 @@ function expandSpreadAttribute(attr, ctx) {
|
|
|
197722
197815
|
}];
|
|
197723
197816
|
}
|
|
197724
197817
|
function attrFreeIdentifiers(attr) {
|
|
197725
|
-
if (!attr.initializer || !
|
|
197818
|
+
if (!attr.initializer || !import_typescript14.default.isJsxExpression(attr.initializer) || !attr.initializer.expression) {
|
|
197726
197819
|
return;
|
|
197727
197820
|
}
|
|
197728
197821
|
return extractFreeIdentifiersFromNode(attr.initializer.expression);
|
|
197729
197822
|
}
|
|
197730
197823
|
function computeReactivityFlags(attr, ctx) {
|
|
197731
|
-
if (!attr.initializer || !
|
|
197824
|
+
if (!attr.initializer || !import_typescript14.default.isJsxExpression(attr.initializer) || !attr.initializer.expression) {
|
|
197732
197825
|
return {};
|
|
197733
197826
|
}
|
|
197734
197827
|
const expr = attr.initializer.expression;
|
|
@@ -197754,22 +197847,22 @@ function processAttributes(attributes, ctx) {
|
|
|
197754
197847
|
const events = [];
|
|
197755
197848
|
let ref = null;
|
|
197756
197849
|
for (const attr of attributes.properties) {
|
|
197757
|
-
if (
|
|
197850
|
+
if (import_typescript14.default.isJsxSpreadAttribute(attr)) {
|
|
197758
197851
|
attrs.push(...expandSpreadAttribute(attr, ctx));
|
|
197759
197852
|
continue;
|
|
197760
197853
|
}
|
|
197761
|
-
if (!
|
|
197854
|
+
if (!import_typescript14.default.isJsxAttribute(attr))
|
|
197762
197855
|
continue;
|
|
197763
197856
|
const rawName = attr.name.getText(ctx.sourceFile);
|
|
197764
197857
|
if (rawName === "ref") {
|
|
197765
|
-
if (attr.initializer &&
|
|
197858
|
+
if (attr.initializer && import_typescript14.default.isJsxExpression(attr.initializer) && attr.initializer.expression) {
|
|
197766
197859
|
reportJsxBranchLocalInCallback(attr.initializer.expression, ctx);
|
|
197767
197860
|
ref = ctx.getJS(attr.initializer.expression);
|
|
197768
197861
|
}
|
|
197769
197862
|
continue;
|
|
197770
197863
|
}
|
|
197771
197864
|
if (isEventHandlerAttrName(rawName)) {
|
|
197772
|
-
if (attr.initializer &&
|
|
197865
|
+
if (attr.initializer && import_typescript14.default.isJsxExpression(attr.initializer) && attr.initializer.expression) {
|
|
197773
197866
|
const eventName = rawName.slice(2).toLowerCase();
|
|
197774
197867
|
reportJsxBranchLocalInCallback(attr.initializer.expression, ctx);
|
|
197775
197868
|
events.push({
|
|
@@ -197784,7 +197877,7 @@ function processAttributes(attributes, ctx) {
|
|
|
197784
197877
|
const name = toHTMLAttrName(rawName);
|
|
197785
197878
|
let value = getAttributeValue(attr, ctx);
|
|
197786
197879
|
let clientOnly;
|
|
197787
|
-
if (attr.initializer &&
|
|
197880
|
+
if (attr.initializer && import_typescript14.default.isJsxExpression(attr.initializer) && attr.initializer.expression) {
|
|
197788
197881
|
if (value.kind === "expression" && value.templateExpr === undefined) {
|
|
197789
197882
|
const rewritten = rewriteBarePropRefs2(value.expr, attr.initializer.expression, ctx);
|
|
197790
197883
|
if (rewritten !== value.expr) {
|
|
@@ -197811,55 +197904,55 @@ function getAttributeValue(attr, ctx) {
|
|
|
197811
197904
|
if (!attr.initializer) {
|
|
197812
197905
|
return AttrValueOf.booleanAttr();
|
|
197813
197906
|
}
|
|
197814
|
-
if (
|
|
197907
|
+
if (import_typescript14.default.isStringLiteral(attr.initializer)) {
|
|
197815
197908
|
return AttrValueOf.literal(decodeEntities(attr.initializer.text));
|
|
197816
197909
|
}
|
|
197817
|
-
if (
|
|
197910
|
+
if (import_typescript14.default.isJsxExpression(attr.initializer) && attr.initializer.expression) {
|
|
197818
197911
|
let expr = attr.initializer.expression;
|
|
197819
|
-
if (
|
|
197912
|
+
if (import_typescript14.default.isIdentifier(expr)) {
|
|
197820
197913
|
const branchInit = ctx._branchScopeVars?.get(expr.text);
|
|
197821
197914
|
if (branchInit && !initializerShapeContainsJsx(branchInit)) {
|
|
197822
197915
|
expr = branchInit;
|
|
197823
197916
|
}
|
|
197824
197917
|
}
|
|
197825
197918
|
expr = tryDesugarInterleaveTaggedTemplate(expr, ctx);
|
|
197826
|
-
if (
|
|
197919
|
+
if (import_typescript14.default.isAwaitExpression(expr)) {
|
|
197827
197920
|
ctx.analyzer.errors.push(createError(ErrorCodes.STAGE_AWAIT_IN_TEMPLATE, getSourceLocation(expr, ctx.sourceFile, ctx.filePath)));
|
|
197828
197921
|
return AttrValueOf.expression("undefined");
|
|
197829
197922
|
}
|
|
197830
197923
|
checkBareSignalOrMemoIdentifier(expr, ctx, { descendNested: isRenderedElementAttribute(attr, ctx) });
|
|
197831
|
-
if (attr.name.getText(ctx.sourceFile) === "style" &&
|
|
197924
|
+
if (attr.name.getText(ctx.sourceFile) === "style" && import_typescript14.default.isObjectLiteralExpression(expr)) {
|
|
197832
197925
|
const cssString = tryStaticStyleObjectToCss(expr);
|
|
197833
197926
|
if (cssString !== null) {
|
|
197834
197927
|
return AttrValueOf.literal(cssString);
|
|
197835
197928
|
}
|
|
197836
197929
|
}
|
|
197837
|
-
if (
|
|
197930
|
+
if (import_typescript14.default.isTemplateExpression(expr)) {
|
|
197838
197931
|
const parts = parseTemplateLiteral(expr, ctx);
|
|
197839
197932
|
if (parts.some((p) => p.type === "ternary" || p.type === "lookup")) {
|
|
197840
197933
|
return AttrValueOf.template(parts);
|
|
197841
197934
|
}
|
|
197842
197935
|
}
|
|
197843
|
-
if (
|
|
197936
|
+
if (import_typescript14.default.isElementAccessExpression(expr) && !import_typescript14.default.isStringLiteralLike(expr.argumentExpression) && !import_typescript14.default.isNumericLiteral(expr.argumentExpression)) {
|
|
197844
197937
|
const parts = tryResolveTemplateSpanFromConst(expr, ctx);
|
|
197845
197938
|
if (parts) {
|
|
197846
197939
|
return AttrValueOf.template(parts);
|
|
197847
197940
|
}
|
|
197848
197941
|
}
|
|
197849
|
-
if (
|
|
197942
|
+
if (import_typescript14.default.isIdentifier(expr)) {
|
|
197850
197943
|
const resolved = tryResolveIdentifierAsTemplateLiteral(expr, ctx);
|
|
197851
197944
|
if (resolved) {
|
|
197852
197945
|
return AttrValueOf.template(resolved);
|
|
197853
197946
|
}
|
|
197854
197947
|
}
|
|
197855
|
-
if (
|
|
197948
|
+
if (import_typescript14.default.isConditionalExpression(expr)) {
|
|
197856
197949
|
const ternary = parseTernary(expr, ctx);
|
|
197857
197950
|
if (ternary) {
|
|
197858
197951
|
return AttrValueOf.template([ternary]);
|
|
197859
197952
|
}
|
|
197860
197953
|
}
|
|
197861
|
-
if (
|
|
197862
|
-
if (
|
|
197954
|
+
if (import_typescript14.default.isBinaryExpression(expr) && expr.operatorToken.kind === import_typescript14.default.SyntaxKind.BarBarToken) {
|
|
197955
|
+
if (import_typescript14.default.isIdentifier(expr.right) && expr.right.text === "undefined") {
|
|
197863
197956
|
const baseExpr = ctx.getJS(expr.left);
|
|
197864
197957
|
return AttrValueOf.expression(baseExpr, { presenceOrUndefined: true });
|
|
197865
197958
|
}
|
|
@@ -197872,11 +197965,11 @@ function getAttributeValue(attr, ctx) {
|
|
|
197872
197965
|
function tryStaticStyleObjectToCss(expr) {
|
|
197873
197966
|
const parts = [];
|
|
197874
197967
|
for (const prop of expr.properties) {
|
|
197875
|
-
if (!
|
|
197968
|
+
if (!import_typescript14.default.isPropertyAssignment(prop))
|
|
197876
197969
|
return null;
|
|
197877
|
-
if (!
|
|
197970
|
+
if (!import_typescript14.default.isIdentifier(prop.name) && !import_typescript14.default.isStringLiteral(prop.name))
|
|
197878
197971
|
return null;
|
|
197879
|
-
if (!
|
|
197972
|
+
if (!import_typescript14.default.isStringLiteral(prop.initializer))
|
|
197880
197973
|
return null;
|
|
197881
197974
|
const key = cssKebabCase(prop.name.text);
|
|
197882
197975
|
parts.push(`${key}:${prop.initializer.text}`);
|
|
@@ -197889,7 +197982,7 @@ function parseTemplateLiteral(expr, ctx) {
|
|
|
197889
197982
|
parts.push({ type: "string", value: expr.head.text });
|
|
197890
197983
|
}
|
|
197891
197984
|
for (const span of expr.templateSpans) {
|
|
197892
|
-
if (
|
|
197985
|
+
if (import_typescript14.default.isConditionalExpression(span.expression)) {
|
|
197893
197986
|
const ternary = parseTernary(span.expression, ctx);
|
|
197894
197987
|
if (ternary) {
|
|
197895
197988
|
parts.push(ternary);
|
|
@@ -197915,7 +198008,7 @@ function parseTemplateLiteral(expr, ctx) {
|
|
|
197915
198008
|
return parts;
|
|
197916
198009
|
}
|
|
197917
198010
|
function tryResolveTemplateSpanFromConst(expr, ctx) {
|
|
197918
|
-
if (
|
|
198011
|
+
if (import_typescript14.default.isIdentifier(expr)) {
|
|
197919
198012
|
if (ctx.scope.isBound(expr.text))
|
|
197920
198013
|
return null;
|
|
197921
198014
|
const constInfo = findLocalConst(expr.text, ctx.analyzer);
|
|
@@ -197924,13 +198017,13 @@ function tryResolveTemplateSpanFromConst(expr, ctx) {
|
|
|
197924
198017
|
const ast = parseConstInitializer(constInfo);
|
|
197925
198018
|
if (!ast)
|
|
197926
198019
|
return null;
|
|
197927
|
-
if (
|
|
198020
|
+
if (import_typescript14.default.isStringLiteral(ast) || import_typescript14.default.isNoSubstitutionTemplateLiteral(ast)) {
|
|
197928
198021
|
return [{ type: "string", value: ast.text }];
|
|
197929
198022
|
}
|
|
197930
198023
|
return null;
|
|
197931
198024
|
}
|
|
197932
|
-
if (
|
|
197933
|
-
if (!
|
|
198025
|
+
if (import_typescript14.default.isElementAccessExpression(expr)) {
|
|
198026
|
+
if (!import_typescript14.default.isIdentifier(expr.expression))
|
|
197934
198027
|
return null;
|
|
197935
198028
|
if (ctx.scope.isBound(expr.expression.text))
|
|
197936
198029
|
return null;
|
|
@@ -197938,17 +198031,17 @@ function tryResolveTemplateSpanFromConst(expr, ctx) {
|
|
|
197938
198031
|
if (!constInfo)
|
|
197939
198032
|
return null;
|
|
197940
198033
|
const ast = parseConstInitializer(constInfo);
|
|
197941
|
-
if (!ast || !
|
|
198034
|
+
if (!ast || !import_typescript14.default.isObjectLiteralExpression(ast))
|
|
197942
198035
|
return null;
|
|
197943
198036
|
const cases = {};
|
|
197944
198037
|
for (const prop of ast.properties) {
|
|
197945
|
-
if (!
|
|
198038
|
+
if (!import_typescript14.default.isPropertyAssignment(prop))
|
|
197946
198039
|
return null;
|
|
197947
|
-
const keyName = prop.name && (
|
|
198040
|
+
const keyName = prop.name && (import_typescript14.default.isStringLiteral(prop.name) || import_typescript14.default.isIdentifier(prop.name)) ? prop.name.text : null;
|
|
197948
198041
|
if (!keyName)
|
|
197949
198042
|
return null;
|
|
197950
198043
|
const value = prop.initializer;
|
|
197951
|
-
if (
|
|
198044
|
+
if (import_typescript14.default.isStringLiteral(value) || import_typescript14.default.isNoSubstitutionTemplateLiteral(value)) {
|
|
197952
198045
|
cases[keyName] = value.text;
|
|
197953
198046
|
} else {
|
|
197954
198047
|
return null;
|
|
@@ -197995,17 +198088,17 @@ function hasDynamicTagBinding(name, sourceFile) {
|
|
|
197995
198088
|
const visit2 = (node) => {
|
|
197996
198089
|
if (found)
|
|
197997
198090
|
return;
|
|
197998
|
-
if (
|
|
198091
|
+
if (import_typescript14.default.isVariableDeclaration(node) && import_typescript14.default.isIdentifier(node.name) && node.name.text === name && node.initializer) {
|
|
197999
198092
|
let init = node.initializer;
|
|
198000
|
-
while (
|
|
198093
|
+
while (import_typescript14.default.isAsExpression(init) || import_typescript14.default.isSatisfiesExpression(init) || import_typescript14.default.isParenthesizedExpression(init) || import_typescript14.default.isNonNullExpression(init)) {
|
|
198001
198094
|
init = init.expression;
|
|
198002
198095
|
}
|
|
198003
|
-
if (
|
|
198096
|
+
if (import_typescript14.default.isPropertyAccessExpression(init) && init.name.text === "tag") {
|
|
198004
198097
|
found = true;
|
|
198005
198098
|
return;
|
|
198006
198099
|
}
|
|
198007
198100
|
}
|
|
198008
|
-
|
|
198101
|
+
import_typescript14.default.forEachChild(node, visit2);
|
|
198009
198102
|
};
|
|
198010
198103
|
visit2(sourceFile);
|
|
198011
198104
|
return found;
|
|
@@ -198019,13 +198112,13 @@ function tryResolveIdentifierAsTemplateLiteral(ident, ctx) {
|
|
|
198019
198112
|
const ast = parseConstInitializer(constInfo);
|
|
198020
198113
|
if (!ast)
|
|
198021
198114
|
return null;
|
|
198022
|
-
if (
|
|
198115
|
+
if (import_typescript14.default.isNoSubstitutionTemplateLiteral(ast) || import_typescript14.default.isStringLiteral(ast)) {
|
|
198023
198116
|
return [{ type: "string", value: ast.text }];
|
|
198024
198117
|
}
|
|
198025
|
-
if (
|
|
198118
|
+
if (import_typescript14.default.isElementAccessExpression(ast) && !import_typescript14.default.isStringLiteralLike(ast.argumentExpression) && !import_typescript14.default.isNumericLiteral(ast.argumentExpression)) {
|
|
198026
198119
|
return tryResolveTemplateSpanFromConst(ast, ctx);
|
|
198027
198120
|
}
|
|
198028
|
-
if (!
|
|
198121
|
+
if (!import_typescript14.default.isTemplateExpression(ast))
|
|
198029
198122
|
return null;
|
|
198030
198123
|
let resolvedAny = false;
|
|
198031
198124
|
const parts = [];
|
|
@@ -198063,14 +198156,14 @@ function parseConstInitializerImpl(c) {
|
|
|
198063
198156
|
if (!c.value)
|
|
198064
198157
|
return null;
|
|
198065
198158
|
const wrapped = `const __bf_resolve__ = (${c.value})`;
|
|
198066
|
-
const sf =
|
|
198159
|
+
const sf = import_typescript14.default.createSourceFile("__bf_resolve.ts", wrapped, import_typescript14.default.ScriptTarget.Latest, true, import_typescript14.default.ScriptKind.TS);
|
|
198067
198160
|
const stmt = sf.statements[0];
|
|
198068
|
-
if (!stmt || !
|
|
198161
|
+
if (!stmt || !import_typescript14.default.isVariableStatement(stmt))
|
|
198069
198162
|
return null;
|
|
198070
198163
|
const decl = stmt.declarationList.declarations[0];
|
|
198071
198164
|
if (!decl?.initializer)
|
|
198072
198165
|
return null;
|
|
198073
|
-
return
|
|
198166
|
+
return import_typescript14.default.isParenthesizedExpression(decl.initializer) ? decl.initializer.expression : decl.initializer;
|
|
198074
198167
|
}
|
|
198075
198168
|
function astText(node) {
|
|
198076
198169
|
return node.getText(node.getSourceFile());
|
|
@@ -198090,9 +198183,9 @@ function parseFunctionInfoAsExprImpl(fn) {
|
|
|
198090
198183
|
const params = fn.typedParams !== undefined ? fn.typedParams : fn.params.map(formatParamWithType).join(", ");
|
|
198091
198184
|
const body = fn.typedBody ?? fn.body;
|
|
198092
198185
|
const wrapped = `const __bf_resolve_fn__ = function(${params}) ${body}`;
|
|
198093
|
-
const sf =
|
|
198186
|
+
const sf = import_typescript14.default.createSourceFile("__bf_resolve_fn.ts", wrapped, import_typescript14.default.ScriptTarget.Latest, true, import_typescript14.default.ScriptKind.TS);
|
|
198094
198187
|
const stmt = sf.statements[0];
|
|
198095
|
-
if (!stmt || !
|
|
198188
|
+
if (!stmt || !import_typescript14.default.isVariableStatement(stmt))
|
|
198096
198189
|
return null;
|
|
198097
198190
|
const decl = stmt.declarationList.declarations[0];
|
|
198098
198191
|
if (!decl?.initializer)
|
|
@@ -198100,9 +198193,9 @@ function parseFunctionInfoAsExprImpl(fn) {
|
|
|
198100
198193
|
return decl.initializer;
|
|
198101
198194
|
}
|
|
198102
198195
|
function tryDesugarInterleaveTaggedTemplate(expr, ctx) {
|
|
198103
|
-
if (!
|
|
198196
|
+
if (!import_typescript14.default.isTaggedTemplateExpression(expr))
|
|
198104
198197
|
return expr;
|
|
198105
|
-
if (!
|
|
198198
|
+
if (!import_typescript14.default.isIdentifier(expr.tag))
|
|
198106
198199
|
return expr;
|
|
198107
198200
|
const resolvedTag = resolveInterleaveTagIdentifier(expr.tag.text, ctx);
|
|
198108
198201
|
if (!resolvedTag)
|
|
@@ -198119,23 +198212,23 @@ function resolveInterleaveTagIdentifier(name, ctx) {
|
|
|
198119
198212
|
return null;
|
|
198120
198213
|
if (constInfo) {
|
|
198121
198214
|
const ast = parseConstInitializer(constInfo);
|
|
198122
|
-
return ast && (
|
|
198215
|
+
return ast && (import_typescript14.default.isArrowFunction(ast) || import_typescript14.default.isFunctionExpression(ast)) ? ast : null;
|
|
198123
198216
|
}
|
|
198124
198217
|
if (fnInfo) {
|
|
198125
198218
|
const ast = parseFunctionInfoAsExpr(fnInfo);
|
|
198126
|
-
return ast && (
|
|
198219
|
+
return ast && (import_typescript14.default.isArrowFunction(ast) || import_typescript14.default.isFunctionExpression(ast)) ? ast : null;
|
|
198127
198220
|
}
|
|
198128
198221
|
return null;
|
|
198129
198222
|
}
|
|
198130
198223
|
function isInterleaveTagFunction(fn) {
|
|
198131
|
-
if (!
|
|
198224
|
+
if (!import_typescript14.default.isArrowFunction(fn) && !import_typescript14.default.isFunctionExpression(fn))
|
|
198132
198225
|
return false;
|
|
198133
198226
|
if (fn.parameters.length !== 2)
|
|
198134
198227
|
return false;
|
|
198135
198228
|
const [partsParam, argsParam] = fn.parameters;
|
|
198136
|
-
if (!
|
|
198229
|
+
if (!import_typescript14.default.isIdentifier(partsParam.name) || partsParam.dotDotDotToken)
|
|
198137
198230
|
return false;
|
|
198138
|
-
if (!
|
|
198231
|
+
if (!import_typescript14.default.isIdentifier(argsParam.name) || !argsParam.dotDotDotToken)
|
|
198139
198232
|
return false;
|
|
198140
198233
|
const parsed = tsNodeToParsedExpr(fn);
|
|
198141
198234
|
if (parsed.kind !== "arrow")
|
|
@@ -198192,7 +198285,7 @@ function isInterleaveSpanExpr(expr, i2, argsName) {
|
|
|
198192
198285
|
function buildUntaggedTemplateLiteral(node, ctx) {
|
|
198193
198286
|
const template = node.template;
|
|
198194
198287
|
let text;
|
|
198195
|
-
if (
|
|
198288
|
+
if (import_typescript14.default.isNoSubstitutionTemplateLiteral(template)) {
|
|
198196
198289
|
text = "`" + (template.rawText ?? template.text) + "`";
|
|
198197
198290
|
} else {
|
|
198198
198291
|
let body = template.head.rawText ?? template.head.text;
|
|
@@ -198204,15 +198297,15 @@ function buildUntaggedTemplateLiteral(node, ctx) {
|
|
|
198204
198297
|
text = "`" + body + "`";
|
|
198205
198298
|
}
|
|
198206
198299
|
const wrapped = `const __bf_resolve_tagged__ = (${text})`;
|
|
198207
|
-
const sf =
|
|
198300
|
+
const sf = import_typescript14.default.createSourceFile("__bf_resolve_tagged.tsx", wrapped, import_typescript14.default.ScriptTarget.Latest, true, import_typescript14.default.ScriptKind.TSX);
|
|
198208
198301
|
const stmt = sf.statements[0];
|
|
198209
|
-
if (!stmt || !
|
|
198302
|
+
if (!stmt || !import_typescript14.default.isVariableStatement(stmt))
|
|
198210
198303
|
return null;
|
|
198211
198304
|
const decl = stmt.declarationList.declarations[0];
|
|
198212
198305
|
if (!decl?.initializer)
|
|
198213
198306
|
return null;
|
|
198214
|
-
const result =
|
|
198215
|
-
if (!
|
|
198307
|
+
const result = import_typescript14.default.isParenthesizedExpression(decl.initializer) ? decl.initializer.expression : decl.initializer;
|
|
198308
|
+
if (!import_typescript14.default.isTemplateExpression(result) && !import_typescript14.default.isNoSubstitutionTemplateLiteral(result))
|
|
198216
198309
|
return null;
|
|
198217
198310
|
return result;
|
|
198218
198311
|
}
|
|
@@ -198232,39 +198325,39 @@ function parseTernary(expr, ctx) {
|
|
|
198232
198325
|
return null;
|
|
198233
198326
|
}
|
|
198234
198327
|
function getStringValue(node) {
|
|
198235
|
-
if (
|
|
198328
|
+
if (import_typescript14.default.isStringLiteral(node)) {
|
|
198236
198329
|
return node.text;
|
|
198237
198330
|
}
|
|
198238
|
-
if (
|
|
198331
|
+
if (import_typescript14.default.isNoSubstitutionTemplateLiteral(node)) {
|
|
198239
198332
|
return node.text;
|
|
198240
198333
|
}
|
|
198241
198334
|
return null;
|
|
198242
198335
|
}
|
|
198243
198336
|
function unwrapTransparentTsWrappers(node) {
|
|
198244
198337
|
let n = node;
|
|
198245
|
-
while (
|
|
198338
|
+
while (import_typescript14.default.isParenthesizedExpression(n) || import_typescript14.default.isAsExpression(n) || import_typescript14.default.isSatisfiesExpression(n) || import_typescript14.default.isNonNullExpression(n)) {
|
|
198246
198339
|
n = n.expression;
|
|
198247
198340
|
}
|
|
198248
198341
|
return n;
|
|
198249
198342
|
}
|
|
198250
198343
|
function expressionWrapsJsx(node) {
|
|
198251
198344
|
const n = unwrapTransparentTsWrappers(node);
|
|
198252
|
-
if (
|
|
198345
|
+
if (import_typescript14.default.isJsxElement(n) || import_typescript14.default.isJsxSelfClosingElement(n) || import_typescript14.default.isJsxFragment(n))
|
|
198253
198346
|
return true;
|
|
198254
|
-
if (
|
|
198347
|
+
if (import_typescript14.default.isConditionalExpression(n)) {
|
|
198255
198348
|
return expressionWrapsJsx(n.whenTrue) || expressionWrapsJsx(n.whenFalse);
|
|
198256
198349
|
}
|
|
198257
|
-
if (
|
|
198258
|
-
return n.elements.some((el) => expressionWrapsJsx(
|
|
198350
|
+
if (import_typescript14.default.isArrayLiteralExpression(n)) {
|
|
198351
|
+
return n.elements.some((el) => expressionWrapsJsx(import_typescript14.default.isSpreadElement(el) ? el.expression : el));
|
|
198259
198352
|
}
|
|
198260
198353
|
return false;
|
|
198261
198354
|
}
|
|
198262
198355
|
function reportNakedJsxWrapperProp(ctx, attr, propName, jsxExpr) {
|
|
198263
|
-
const shape =
|
|
198356
|
+
const shape = import_typescript14.default.isConditionalExpression(jsxExpr) ? "a ternary" : "an array literal";
|
|
198264
198357
|
ctx.analyzer.errors.push(createError(ErrorCodes.UNSUPPORTED_JSX_PATTERN, getSourceLocation(attr, ctx.sourceFile, ctx.filePath), {
|
|
198265
198358
|
message: `Prop '${propName}' is ${shape} wrapping JSX (${jsxExpr.getText(ctx.sourceFile)}). ` + `This shape is not compiled — only a JSX element/fragment given DIRECTLY as the prop value is.`,
|
|
198266
198359
|
suggestion: {
|
|
198267
|
-
message: `Move the conditional
|
|
198360
|
+
message: import_typescript14.default.isConditionalExpression(jsxExpr) ? `Move the conditional out of the prop position: compute it in a local const and pass it as ` + `the component's children instead of a named prop ` + `(e.g. const ${propName} = ${jsxExpr.getText(ctx.sourceFile)}; <Comp>{${propName}}</Comp>). ` + `Wrapping the ternary in a fragment at the prop position ` + `(${propName}={<>{${jsxExpr.getText(ctx.sourceFile)}}</>}) is also a safe escape (#2702): the ` + `compiler brands each JSX branch individually, so the child's reactive prop getter unwraps it ` + `correctly instead of re-escaping it as text.` : `Move the array out of the prop position: compute it in a local const and pass it as the ` + `component's children instead of a named prop ` + `(e.g. const ${propName} = ${jsxExpr.getText(ctx.sourceFile)}; <Comp>{${propName}}</Comp>). ` + `Wrapping the array in a fragment at the prop position is NOT a safe escape here: it compiles, ` + `but flattens to more than one part, which the child's reactive prop getter has no branding ` + `contract for (a multi-part jsx-children shape, tracked separately from #2702's single-` + `conditional fix).`,
|
|
198268
198361
|
escape: [{ kind: "rewrite" }]
|
|
198269
198362
|
}
|
|
198270
198363
|
}));
|
|
@@ -198272,16 +198365,16 @@ function reportNakedJsxWrapperProp(ctx, attr, propName, jsxExpr) {
|
|
|
198272
198365
|
function processComponentProps(attributes, ctx) {
|
|
198273
198366
|
const props = [];
|
|
198274
198367
|
for (const attr of attributes.properties) {
|
|
198275
|
-
if (
|
|
198368
|
+
if (import_typescript14.default.isJsxSpreadAttribute(attr)) {
|
|
198276
198369
|
props.push(...expandSpreadAttribute(attr, ctx));
|
|
198277
198370
|
continue;
|
|
198278
198371
|
}
|
|
198279
|
-
if (!
|
|
198372
|
+
if (!import_typescript14.default.isJsxAttribute(attr))
|
|
198280
198373
|
continue;
|
|
198281
198374
|
const name = attr.name.getText(ctx.sourceFile);
|
|
198282
|
-
if (attr.initializer &&
|
|
198375
|
+
if (attr.initializer && import_typescript14.default.isJsxExpression(attr.initializer) && attr.initializer.expression) {
|
|
198283
198376
|
const jsxExpr = unwrapTransparentTsWrappers(attr.initializer.expression);
|
|
198284
|
-
if (
|
|
198377
|
+
if (import_typescript14.default.isJsxElement(jsxExpr) || import_typescript14.default.isJsxSelfClosingElement(jsxExpr) || import_typescript14.default.isJsxFragment(jsxExpr)) {
|
|
198285
198378
|
const prevInsideComponentChildren = ctx.insideComponentChildren;
|
|
198286
198379
|
ctx.insideComponentChildren = true;
|
|
198287
198380
|
const irNode = transformNode(jsxExpr, ctx);
|
|
@@ -198295,7 +198388,7 @@ function processComponentProps(attributes, ctx) {
|
|
|
198295
198388
|
continue;
|
|
198296
198389
|
}
|
|
198297
198390
|
}
|
|
198298
|
-
if ((
|
|
198391
|
+
if ((import_typescript14.default.isConditionalExpression(jsxExpr) || import_typescript14.default.isArrayLiteralExpression(jsxExpr)) && expressionWrapsJsx(jsxExpr)) {
|
|
198299
198392
|
reportNakedJsxWrapperProp(ctx, attr, name, jsxExpr);
|
|
198300
198393
|
continue;
|
|
198301
198394
|
}
|
|
@@ -198312,7 +198405,7 @@ function processComponentProps(attributes, ctx) {
|
|
|
198312
198405
|
value = AttrValueOf.booleanShorthand();
|
|
198313
198406
|
}
|
|
198314
198407
|
let clientOnly;
|
|
198315
|
-
if (attr.initializer &&
|
|
198408
|
+
if (attr.initializer && import_typescript14.default.isJsxExpression(attr.initializer) && attr.initializer.expression) {
|
|
198316
198409
|
if (value.kind === "expression" && value.templateExpr === undefined) {
|
|
198317
198410
|
const rewritten = rewriteBarePropRefs2(value.expr, attr.initializer.expression, ctx);
|
|
198318
198411
|
if (rewritten !== value.expr) {
|
|
@@ -198357,7 +198450,7 @@ function checkBareSignalOrMemoIdentifier(expr, ctx, options) {
|
|
|
198357
198450
|
}
|
|
198358
198451
|
}));
|
|
198359
198452
|
};
|
|
198360
|
-
if (
|
|
198453
|
+
if (import_typescript14.default.isIdentifier(expr)) {
|
|
198361
198454
|
const kind = reactiveNames.get(expr.text);
|
|
198362
198455
|
if (kind && !ctx.scope.isBound(expr.text))
|
|
198363
198456
|
report(expr, expr.text, kind);
|
|
@@ -198374,12 +198467,12 @@ function checkBareSignalOrMemoIdentifier(expr, ctx, options) {
|
|
|
198374
198467
|
return ctx.scope.isBound(name);
|
|
198375
198468
|
};
|
|
198376
198469
|
const visitBindingDefaults = (name, bound) => {
|
|
198377
|
-
if (
|
|
198470
|
+
if (import_typescript14.default.isIdentifier(name)) {
|
|
198378
198471
|
bound.add(name.text);
|
|
198379
198472
|
return;
|
|
198380
198473
|
}
|
|
198381
198474
|
for (const el of name.elements) {
|
|
198382
|
-
if (
|
|
198475
|
+
if (import_typescript14.default.isOmittedExpression(el))
|
|
198383
198476
|
continue;
|
|
198384
198477
|
if (el.initializer)
|
|
198385
198478
|
visit2(el.initializer);
|
|
@@ -198387,56 +198480,56 @@ function checkBareSignalOrMemoIdentifier(expr, ctx, options) {
|
|
|
198387
198480
|
}
|
|
198388
198481
|
};
|
|
198389
198482
|
const collectBindingNames3 = (name, out) => {
|
|
198390
|
-
if (
|
|
198483
|
+
if (import_typescript14.default.isIdentifier(name))
|
|
198391
198484
|
out.add(name.text);
|
|
198392
|
-
else if (
|
|
198485
|
+
else if (import_typescript14.default.isObjectBindingPattern(name)) {
|
|
198393
198486
|
for (const el of name.elements)
|
|
198394
198487
|
collectBindingNames3(el.name, out);
|
|
198395
|
-
} else if (
|
|
198488
|
+
} else if (import_typescript14.default.isArrayBindingPattern(name)) {
|
|
198396
198489
|
for (const el of name.elements) {
|
|
198397
|
-
if (!
|
|
198490
|
+
if (!import_typescript14.default.isOmittedExpression(el))
|
|
198398
198491
|
collectBindingNames3(el.name, out);
|
|
198399
198492
|
}
|
|
198400
198493
|
}
|
|
198401
198494
|
};
|
|
198402
198495
|
const collectBlockDeclarations = (block, out) => {
|
|
198403
198496
|
for (const stmt of block.statements) {
|
|
198404
|
-
if (
|
|
198497
|
+
if (import_typescript14.default.isVariableStatement(stmt)) {
|
|
198405
198498
|
for (const decl of stmt.declarationList.declarations)
|
|
198406
198499
|
collectBindingNames3(decl.name, out);
|
|
198407
|
-
} else if (
|
|
198500
|
+
} else if (import_typescript14.default.isFunctionDeclaration(stmt) && stmt.name) {
|
|
198408
198501
|
out.add(stmt.name.text);
|
|
198409
198502
|
}
|
|
198410
198503
|
}
|
|
198411
198504
|
};
|
|
198412
198505
|
function visit2(node) {
|
|
198413
|
-
if (
|
|
198506
|
+
if (import_typescript14.default.isJsxElement(node) || import_typescript14.default.isJsxSelfClosingElement(node) || import_typescript14.default.isJsxFragment(node)) {
|
|
198414
198507
|
return;
|
|
198415
198508
|
}
|
|
198416
|
-
if (
|
|
198509
|
+
if (import_typescript14.default.isTypeNode(node))
|
|
198417
198510
|
return;
|
|
198418
|
-
if (
|
|
198511
|
+
if (import_typescript14.default.isCallExpression(node) && node.arguments.length === 0 && import_typescript14.default.isIdentifier(node.expression)) {
|
|
198419
198512
|
return;
|
|
198420
198513
|
}
|
|
198421
|
-
if (
|
|
198514
|
+
if (import_typescript14.default.isPropertyAccessExpression(node)) {
|
|
198422
198515
|
visit2(node.expression);
|
|
198423
198516
|
return;
|
|
198424
198517
|
}
|
|
198425
|
-
if (
|
|
198426
|
-
if (
|
|
198518
|
+
if (import_typescript14.default.isPropertyAssignment(node)) {
|
|
198519
|
+
if (import_typescript14.default.isComputedPropertyName(node.name))
|
|
198427
198520
|
visit2(node.name.expression);
|
|
198428
198521
|
visit2(node.initializer);
|
|
198429
198522
|
return;
|
|
198430
198523
|
}
|
|
198431
|
-
if (
|
|
198432
|
-
if (
|
|
198524
|
+
if (import_typescript14.default.isShorthandPropertyAssignment(node)) {
|
|
198525
|
+
if (import_typescript14.default.isIdentifier(node.name) && !isBound(node.name.text)) {
|
|
198433
198526
|
const kind = reactiveNames.get(node.name.text);
|
|
198434
198527
|
if (kind)
|
|
198435
198528
|
report(node.name, node.name.text, kind);
|
|
198436
198529
|
}
|
|
198437
198530
|
return;
|
|
198438
198531
|
}
|
|
198439
|
-
if (
|
|
198532
|
+
if (import_typescript14.default.isArrowFunction(node) || import_typescript14.default.isFunctionExpression(node)) {
|
|
198440
198533
|
const bound = new Set;
|
|
198441
198534
|
boundStack.push(bound);
|
|
198442
198535
|
for (const p of node.parameters) {
|
|
@@ -198444,14 +198537,14 @@ function checkBareSignalOrMemoIdentifier(expr, ctx, options) {
|
|
|
198444
198537
|
visit2(p.initializer);
|
|
198445
198538
|
visitBindingDefaults(p.name, bound);
|
|
198446
198539
|
}
|
|
198447
|
-
if (node.body &&
|
|
198540
|
+
if (node.body && import_typescript14.default.isBlock(node.body))
|
|
198448
198541
|
collectBlockDeclarations(node.body, bound);
|
|
198449
198542
|
if (node.body)
|
|
198450
198543
|
visit2(node.body);
|
|
198451
198544
|
boundStack.pop();
|
|
198452
198545
|
return;
|
|
198453
198546
|
}
|
|
198454
|
-
if (
|
|
198547
|
+
if (import_typescript14.default.isVariableDeclaration(node)) {
|
|
198455
198548
|
if (node.initializer)
|
|
198456
198549
|
visit2(node.initializer);
|
|
198457
198550
|
const declared = new Set;
|
|
@@ -198460,7 +198553,7 @@ function checkBareSignalOrMemoIdentifier(expr, ctx, options) {
|
|
|
198460
198553
|
boundStack.pop();
|
|
198461
198554
|
return;
|
|
198462
198555
|
}
|
|
198463
|
-
if (
|
|
198556
|
+
if (import_typescript14.default.isIdentifier(node)) {
|
|
198464
198557
|
if (isBound(node.text))
|
|
198465
198558
|
return;
|
|
198466
198559
|
const kind = reactiveNames.get(node.text);
|
|
@@ -198468,24 +198561,45 @@ function checkBareSignalOrMemoIdentifier(expr, ctx, options) {
|
|
|
198468
198561
|
report(node, node.text, kind);
|
|
198469
198562
|
return;
|
|
198470
198563
|
}
|
|
198471
|
-
|
|
198564
|
+
import_typescript14.default.forEachChild(node, visit2);
|
|
198472
198565
|
}
|
|
198473
198566
|
visit2(expr);
|
|
198474
198567
|
}
|
|
198475
198568
|
function isArrayExprDirectPropRef(arrayExpr, ctx) {
|
|
198476
|
-
const propNames = new Set(ctx.patterns.props.map((p) => p.name));
|
|
198477
198569
|
const propsObjName = ctx.analyzer.propsObjectName;
|
|
198478
|
-
if (
|
|
198479
|
-
return
|
|
198570
|
+
if (import_typescript14.default.isIdentifier(arrayExpr)) {
|
|
198571
|
+
return resolveAliasOrigin(propAliasHopCandidates(ctx), arrayExpr.text, (name) => isDirectPropBindingName(name, ctx) ? true : null) === true;
|
|
198480
198572
|
}
|
|
198481
|
-
if (
|
|
198573
|
+
if (import_typescript14.default.isPropertyAccessExpression(arrayExpr) && propsObjName) {
|
|
198482
198574
|
const obj = arrayExpr.expression;
|
|
198483
|
-
if (
|
|
198484
|
-
return true;
|
|
198575
|
+
if (import_typescript14.default.isIdentifier(obj)) {
|
|
198576
|
+
return resolveAliasOrigin(propAliasHopCandidates(ctx), obj.text, (name) => name === propsObjName ? true : null) === true;
|
|
198485
198577
|
}
|
|
198486
198578
|
}
|
|
198487
198579
|
return false;
|
|
198488
198580
|
}
|
|
198581
|
+
function isDirectPropBindingName(name, ctx) {
|
|
198582
|
+
if (ctx.scope.isBound(name))
|
|
198583
|
+
return false;
|
|
198584
|
+
if (ctx.boundPropNames.has(name))
|
|
198585
|
+
return true;
|
|
198586
|
+
const propsObjName = ctx.analyzer.propsObjectName;
|
|
198587
|
+
if (!propsObjName)
|
|
198588
|
+
return false;
|
|
198589
|
+
const parsed = constantsByName(ctx).get(name)?.parsed;
|
|
198590
|
+
return !!parsed && parsed.kind === "member" && !parsed.computed && parsed.object.kind === "identifier" && parsed.object.name === propsObjName;
|
|
198591
|
+
}
|
|
198592
|
+
function propAliasHopCandidates(ctx) {
|
|
198593
|
+
const bound = ctx.scope.boundNames();
|
|
198594
|
+
const candidates = new Map;
|
|
198595
|
+
for (const constant of ctx.analyzer.localConstants) {
|
|
198596
|
+
if (constant.isModule || bound.has(constant.name))
|
|
198597
|
+
continue;
|
|
198598
|
+
if (!candidates.has(constant.name))
|
|
198599
|
+
candidates.set(constant.name, constant.value);
|
|
198600
|
+
}
|
|
198601
|
+
return candidates;
|
|
198602
|
+
}
|
|
198489
198603
|
function isSignalOrMemoArray(array, ctx) {
|
|
198490
198604
|
for (const { pattern } of ctx.patterns.signals) {
|
|
198491
198605
|
if (pattern.test(array))
|
|
@@ -198573,7 +198687,7 @@ function forwardsCallerRestProps(attrs, ctx) {
|
|
|
198573
198687
|
for (const attr of attrs) {
|
|
198574
198688
|
if (attr.value.kind !== "spread")
|
|
198575
198689
|
continue;
|
|
198576
|
-
const constants3 =
|
|
198690
|
+
const constants3 = constantValuesByName(ctx);
|
|
198577
198691
|
for (const name of new Set([attr.value.expr, attr.value.templateExpr])) {
|
|
198578
198692
|
if (!name)
|
|
198579
198693
|
continue;
|
|
@@ -198583,15 +198697,26 @@ function forwardsCallerRestProps(attrs, ctx) {
|
|
|
198583
198697
|
}
|
|
198584
198698
|
return false;
|
|
198585
198699
|
}
|
|
198586
|
-
function
|
|
198587
|
-
if (ctx.
|
|
198588
|
-
return ctx.
|
|
198700
|
+
function constantValuesByName(ctx) {
|
|
198701
|
+
if (ctx._constantValuesByName)
|
|
198702
|
+
return ctx._constantValuesByName;
|
|
198589
198703
|
const byName = new Map;
|
|
198590
198704
|
for (const constant of ctx.analyzer.localConstants) {
|
|
198591
198705
|
if (!byName.has(constant.name))
|
|
198592
198706
|
byName.set(constant.name, constant.value);
|
|
198593
198707
|
}
|
|
198594
|
-
ctx.
|
|
198708
|
+
ctx._constantValuesByName = byName;
|
|
198709
|
+
return byName;
|
|
198710
|
+
}
|
|
198711
|
+
function constantsByName(ctx) {
|
|
198712
|
+
if (ctx._constantsByName)
|
|
198713
|
+
return ctx._constantsByName;
|
|
198714
|
+
const byName = new Map;
|
|
198715
|
+
for (const constant of ctx.analyzer.localConstants) {
|
|
198716
|
+
if (!byName.has(constant.name))
|
|
198717
|
+
byName.set(constant.name, constant);
|
|
198718
|
+
}
|
|
198719
|
+
ctx._constantsByName = byName;
|
|
198595
198720
|
return byName;
|
|
198596
198721
|
}
|
|
198597
198722
|
function hasReactiveAttributes(attrs, ctx) {
|
|
@@ -198700,7 +198825,7 @@ function buildIfStatementChain(analyzer, ctx, opts) {
|
|
|
198700
198825
|
jsxBranchLocalNames.add(n);
|
|
198701
198826
|
}
|
|
198702
198827
|
for (const decl of condReturn.scopeVariables) {
|
|
198703
|
-
if (
|
|
198828
|
+
if (import_typescript14.default.isIdentifier(decl.name) && decl.initializer) {
|
|
198704
198829
|
branchScopeVars.set(decl.name.text, decl.initializer);
|
|
198705
198830
|
if (initializerShapeContainsJsx(decl.initializer)) {
|
|
198706
198831
|
jsxBranchLocalNames.add(decl.name.text);
|
|
@@ -198767,7 +198892,7 @@ function buildIfStatementChain(analyzer, ctx, opts) {
|
|
|
198767
198892
|
}
|
|
198768
198893
|
const scopeVariables = [];
|
|
198769
198894
|
for (const decl of condReturn.scopeVariables) {
|
|
198770
|
-
if (
|
|
198895
|
+
if (import_typescript14.default.isIdentifier(decl.name) && decl.initializer) {
|
|
198771
198896
|
const init = ctx.getJS(decl.initializer);
|
|
198772
198897
|
const typedInit = decl.initializer.getText(ctx.sourceFile);
|
|
198773
198898
|
scopeVariables.push({
|
|
@@ -198937,16 +199062,16 @@ var KEYWORDS_AND_GLOBALS = new Set([
|
|
|
198937
199062
|
]);
|
|
198938
199063
|
|
|
198939
199064
|
// ../jsx/src/ir-to-client-js/walk-prop-accesses.ts
|
|
198940
|
-
var
|
|
199065
|
+
var import_typescript15 = __toESM(require_typescript(), 1);
|
|
198941
199066
|
|
|
198942
199067
|
// ../jsx/src/ir-to-client-js/imports.ts
|
|
198943
|
-
var
|
|
199068
|
+
var import_typescript17 = __toESM(require_typescript(), 1);
|
|
198944
199069
|
|
|
198945
199070
|
// ../jsx/src/value-references.ts
|
|
198946
|
-
var
|
|
199071
|
+
var import_typescript16 = __toESM(require_typescript(), 1);
|
|
198947
199072
|
|
|
198948
199073
|
// ../jsx/src/relocate.ts
|
|
198949
|
-
var
|
|
199074
|
+
var import_typescript18 = __toESM(require_typescript(), 1);
|
|
198950
199075
|
|
|
198951
199076
|
// ../jsx/src/lowering-registry.ts
|
|
198952
199077
|
var plugins = [];
|
|
@@ -199125,10 +199250,10 @@ function formatDateLocalNames(metadata) {
|
|
|
199125
199250
|
}
|
|
199126
199251
|
|
|
199127
199252
|
// ../jsx/src/ir-to-client-js/prune-unused-prop-extractions.ts
|
|
199128
|
-
var
|
|
199253
|
+
var import_typescript19 = __toESM(require_typescript(), 1);
|
|
199129
199254
|
|
|
199130
199255
|
// ../jsx/src/ir-to-client-js/control-flow/plan/lazy-preamble.ts
|
|
199131
|
-
var
|
|
199256
|
+
var import_typescript20 = __toESM(require_typescript(), 1);
|
|
199132
199257
|
var NO_PREAMBLE = {
|
|
199133
199258
|
lazySafe: true,
|
|
199134
199259
|
facts: { declaredNames: new Set, freeNames: new Set }
|
|
@@ -199178,7 +199303,7 @@ var INERT_BINDING_GLOBALS = new Set([
|
|
|
199178
199303
|
]);
|
|
199179
199304
|
|
|
199180
199305
|
// ../jsx/src/ir-to-client-js/emit-reactive.ts
|
|
199181
|
-
var
|
|
199306
|
+
var import_typescript21 = __toESM(require_typescript(), 1);
|
|
199182
199307
|
|
|
199183
199308
|
// ../jsx/src/ir-to-client-js/control-flow/stringify/event-delegation.ts
|
|
199184
199309
|
var NON_BUBBLING_EVENTS = new Set([
|
|
@@ -199192,9 +199317,6 @@ var NON_BUBBLING_EVENTS = new Set([
|
|
|
199192
199317
|
"pointerleave"
|
|
199193
199318
|
]);
|
|
199194
199319
|
|
|
199195
|
-
// ../jsx/src/ir-to-client-js/rewrite-props-object.ts
|
|
199196
|
-
var import_typescript21 = __toESM(require_typescript(), 1);
|
|
199197
|
-
|
|
199198
199320
|
// ../jsx/src/ir-to-client-js/source-map.ts
|
|
199199
199321
|
var BASE64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
199200
199322
|
function encodeVLQ(value) {
|