@danielx/civet 0.11.8 → 0.11.10
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/CHANGELOG.md +45 -20
- package/dist/browser.js +113 -50
- package/dist/browser.min.js +1 -1
- package/dist/main.js +115 -33
- package/dist/main.mjs +115 -33
- package/dist/ts-diagnostic.js +45 -12
- package/dist/ts-diagnostic.mjs +44 -12
- package/dist/ts-service/index.js +22 -1
- package/dist/ts-service/index.js.map +2 -2
- package/dist/ts-service/index.mjs +22 -1
- package/dist/ts-service/index.mjs.map +2 -2
- package/package.json +7 -12
package/dist/main.mjs
CHANGED
|
@@ -483,6 +483,7 @@ __export(lib_exports, {
|
|
|
483
483
|
braceBlock: () => braceBlock,
|
|
484
484
|
bracedBlock: () => bracedBlock,
|
|
485
485
|
buildExportSplitClause: () => buildExportSplitClause,
|
|
486
|
+
canExpressionizeIfAsTernary: () => canExpressionizeIfAsTernary,
|
|
486
487
|
convertArrowFunctionToMethod: () => convertArrowFunctionToMethod,
|
|
487
488
|
convertFunctionToMethod: () => convertFunctionToMethod,
|
|
488
489
|
convertNamedImportsToObject: () => convertNamedImportsToObject,
|
|
@@ -929,12 +930,13 @@ function prepend(prefix, node) {
|
|
|
929
930
|
}
|
|
930
931
|
if (Array.isArray(node)) {
|
|
931
932
|
return [prefix, ...node];
|
|
932
|
-
} else {
|
|
933
|
-
assert(isParent(node), "prepend: can't glom into an AST leaf");
|
|
933
|
+
} else if (isParent(node)) {
|
|
934
934
|
return {
|
|
935
935
|
...node,
|
|
936
936
|
children: [prefix, ...node.children]
|
|
937
937
|
};
|
|
938
|
+
} else {
|
|
939
|
+
return [prefix, node];
|
|
938
940
|
}
|
|
939
941
|
}
|
|
940
942
|
function append(node, suffix) {
|
|
@@ -5659,6 +5661,9 @@ function prependStatementExpressionBlock(initializer, statement) {
|
|
|
5659
5661
|
return;
|
|
5660
5662
|
}
|
|
5661
5663
|
const statementExp = exp.statement;
|
|
5664
|
+
if (statementExp.type === "IfStatement" && canExpressionizeIfAsTernary(statementExp)) {
|
|
5665
|
+
return;
|
|
5666
|
+
}
|
|
5662
5667
|
const blockStatement = [ws || "", statementExp, ";"];
|
|
5663
5668
|
const pre = [blockStatement];
|
|
5664
5669
|
let ref;
|
|
@@ -7441,6 +7446,25 @@ function expressionizeBlock(blockOrExpression) {
|
|
|
7441
7446
|
return blockOrExpression;
|
|
7442
7447
|
}
|
|
7443
7448
|
}
|
|
7449
|
+
function canExpressionizeIfAsTernary(statement) {
|
|
7450
|
+
const { then: b, else: e } = statement;
|
|
7451
|
+
return canExpressionizeBlock(b) && (e ? canExpressionizeBlock(e.block) : true);
|
|
7452
|
+
}
|
|
7453
|
+
function canExpressionizeBlock(blockOrExpression) {
|
|
7454
|
+
if (blockOrExpression && typeof blockOrExpression === "object" && "expressions" in blockOrExpression) {
|
|
7455
|
+
const { expressions } = blockOrExpression;
|
|
7456
|
+
let results1 = true;
|
|
7457
|
+
for (const [, s] of expressions) {
|
|
7458
|
+
if (!isExpression(s)) {
|
|
7459
|
+
results1 = false;
|
|
7460
|
+
break;
|
|
7461
|
+
}
|
|
7462
|
+
}
|
|
7463
|
+
return results1;
|
|
7464
|
+
}
|
|
7465
|
+
;
|
|
7466
|
+
return;
|
|
7467
|
+
}
|
|
7444
7468
|
function expressionizeIfStatement(statement) {
|
|
7445
7469
|
const { condition, then: b, else: e } = statement;
|
|
7446
7470
|
const [...condRest] = condition.children, [closeParen] = condRest.splice(-1);
|
|
@@ -8575,11 +8599,11 @@ function attachPostfixStatementAsExpression(exp, post) {
|
|
|
8575
8599
|
}
|
|
8576
8600
|
}
|
|
8577
8601
|
function processTypes(node) {
|
|
8578
|
-
const
|
|
8602
|
+
const results2 = [];
|
|
8579
8603
|
for (let ref22 = gatherRecursiveAll(node, ($13) => $13.type === "TypeUnary"), i12 = 0, len11 = ref22.length; i12 < len11; i12++) {
|
|
8580
8604
|
const unary = ref22[i12];
|
|
8581
8605
|
let suffixIndex = unary.suffix.length - 1;
|
|
8582
|
-
const
|
|
8606
|
+
const results3 = [];
|
|
8583
8607
|
while (suffixIndex >= 0) {
|
|
8584
8608
|
const suffix = unary.suffix[suffixIndex];
|
|
8585
8609
|
if (typeof suffix === "object" && suffix != null && "token" in suffix && suffix.token === "?") {
|
|
@@ -8639,7 +8663,7 @@ function processTypes(node) {
|
|
|
8639
8663
|
children: [prefix, replace, outer]
|
|
8640
8664
|
});
|
|
8641
8665
|
}
|
|
8642
|
-
|
|
8666
|
+
results3.push(replaceNode(unary, replace, parent));
|
|
8643
8667
|
} else if (typeof suffix === "object" && suffix != null && "type" in suffix && suffix.type === "NonNullAssertion") {
|
|
8644
8668
|
const {} = suffix;
|
|
8645
8669
|
let m7;
|
|
@@ -8694,15 +8718,15 @@ function processTypes(node) {
|
|
|
8694
8718
|
children: [prefix, replace, outer]
|
|
8695
8719
|
});
|
|
8696
8720
|
}
|
|
8697
|
-
|
|
8721
|
+
results3.push(replaceNode(unary, replace, parent));
|
|
8698
8722
|
} else {
|
|
8699
|
-
|
|
8723
|
+
results3.push(suffixIndex--);
|
|
8700
8724
|
}
|
|
8701
8725
|
}
|
|
8702
|
-
|
|
8726
|
+
results2.push(results3);
|
|
8703
8727
|
}
|
|
8704
8728
|
;
|
|
8705
|
-
return
|
|
8729
|
+
return results2;
|
|
8706
8730
|
}
|
|
8707
8731
|
function processStatementExpressions(statements) {
|
|
8708
8732
|
for (let ref24 = gatherRecursiveAll(statements, ($14) => $14.type === "StatementExpression"), i13 = 0, len12 = ref24.length; i13 < len12; i13++) {
|
|
@@ -8887,12 +8911,12 @@ function processCoffeeClasses(statements) {
|
|
|
8887
8911
|
index + 1,
|
|
8888
8912
|
0,
|
|
8889
8913
|
...(() => {
|
|
8890
|
-
const
|
|
8914
|
+
const results4 = [];
|
|
8891
8915
|
for (let i16 = 0, len15 = autoBinds.length; i16 < len15; i16++) {
|
|
8892
8916
|
const [, a] = autoBinds[i16];
|
|
8893
|
-
|
|
8917
|
+
results4.push([indent, ["this.", a.name, " = this.", a.name, ".bind(this)"], ";"]);
|
|
8894
8918
|
}
|
|
8895
|
-
return
|
|
8919
|
+
return results4;
|
|
8896
8920
|
})()
|
|
8897
8921
|
);
|
|
8898
8922
|
}
|
|
@@ -9491,6 +9515,7 @@ var grammar = {
|
|
|
9491
9515
|
ImplicitAccessStart,
|
|
9492
9516
|
PropertyAccessModifier,
|
|
9493
9517
|
PropertyAccess,
|
|
9518
|
+
AccessLiteral,
|
|
9494
9519
|
ExplicitPropertyGlob,
|
|
9495
9520
|
PropertyGlob,
|
|
9496
9521
|
PropertyBind,
|
|
@@ -15519,13 +15544,14 @@ function ClassElement$0($$ctx, $$state) {
|
|
|
15519
15544
|
}
|
|
15520
15545
|
if ($$ctx.tokenize) return $$r;
|
|
15521
15546
|
const $$loc = $$r.loc, $$value = $$r.value;
|
|
15522
|
-
const $$m =
|
|
15547
|
+
const $$m = (function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7) {
|
|
15523
15548
|
var decorators = $2;
|
|
15524
15549
|
var declare = $3;
|
|
15525
15550
|
var access = $4;
|
|
15526
15551
|
var static_ = $5;
|
|
15527
15552
|
var override = $6;
|
|
15528
15553
|
var assignment = $7;
|
|
15554
|
+
if (assignment.assigned?.type === "SymbolLiteral") return $skip;
|
|
15529
15555
|
return {
|
|
15530
15556
|
type: static_ ? "CoffeeClassPublic" : "CoffeeClassPrivate",
|
|
15531
15557
|
children: [decorators, declare, access, static_, override, assignment],
|
|
@@ -17364,7 +17390,7 @@ function PropertyAccessModifier($$ctx, $$state) {
|
|
|
17364
17390
|
if ($$ctx.exit) $$ctx.exit("PropertyAccessModifier", $$state, $$final, $$eventData);
|
|
17365
17391
|
return $$final;
|
|
17366
17392
|
}
|
|
17367
|
-
var PropertyAccess$0$parser = (0, import_lib2.$S)(AccessStart, (0, import_lib2.$C)(TemplateLiteral,
|
|
17393
|
+
var PropertyAccess$0$parser = (0, import_lib2.$S)(AccessStart, (0, import_lib2.$C)(TemplateLiteral, AccessLiteral, SymbolLiteral));
|
|
17368
17394
|
var PropertyAccess$1$parser = (0, import_lib2.$S)(AccessStart, (0, import_lib2.$EXPECT)($L22, 'PropertyAccess "-"'), IntegerLiteral);
|
|
17369
17395
|
var PropertyAccess$2$parser = (0, import_lib2.$S)(AccessStart, (0, import_lib2.$Q)(InlineComment), (0, import_lib2.$C)(IdentifierName, PrivateIdentifier, LengthShorthand));
|
|
17370
17396
|
var PropertyAccess$3$parser = (0, import_lib2.$S)(ExplicitAccessStart, (0, import_lib2.$Y)(EOS));
|
|
@@ -17379,12 +17405,14 @@ function PropertyAccess$0($$ctx, $$state) {
|
|
|
17379
17405
|
const $$loc = $$r.loc, $$value = $$r.value;
|
|
17380
17406
|
const $$m = (function($skip, $loc, $0, $1, $2) {
|
|
17381
17407
|
var dot = $1;
|
|
17382
|
-
var
|
|
17408
|
+
var expression = $2;
|
|
17383
17409
|
return {
|
|
17384
17410
|
type: "Index",
|
|
17411
|
+
expression,
|
|
17385
17412
|
children: [
|
|
17386
17413
|
adjustIndexAccess(dot),
|
|
17387
|
-
|
|
17414
|
+
expression,
|
|
17415
|
+
"",
|
|
17388
17416
|
"]"
|
|
17389
17417
|
]
|
|
17390
17418
|
};
|
|
@@ -17442,12 +17470,21 @@ function PropertyAccess$2($$ctx, $$state) {
|
|
|
17442
17470
|
var comments = $2;
|
|
17443
17471
|
var id = $3;
|
|
17444
17472
|
if (id.unicode) {
|
|
17473
|
+
const key = propertyKey(id);
|
|
17474
|
+
const expression = {
|
|
17475
|
+
type: "Literal",
|
|
17476
|
+
subtype: "StringLiteral",
|
|
17477
|
+
children: [key],
|
|
17478
|
+
raw: key.token
|
|
17479
|
+
};
|
|
17445
17480
|
return {
|
|
17446
17481
|
type: "Index",
|
|
17482
|
+
expression,
|
|
17447
17483
|
children: [
|
|
17448
17484
|
adjustIndexAccess(dot),
|
|
17449
17485
|
...comments,
|
|
17450
|
-
|
|
17486
|
+
expression,
|
|
17487
|
+
"",
|
|
17451
17488
|
"]"
|
|
17452
17489
|
]
|
|
17453
17490
|
};
|
|
@@ -17537,11 +17574,12 @@ function PropertyAccess$5($$ctx, $$state) {
|
|
|
17537
17574
|
optional: modifier?.token === "?"
|
|
17538
17575
|
};
|
|
17539
17576
|
if (id) {
|
|
17577
|
+
const access = id.unicode ? ["prototype[", propertyKey(id), "]"] : ["prototype.", id];
|
|
17540
17578
|
return {
|
|
17541
17579
|
type: "PropertyAccess",
|
|
17542
17580
|
name: id.name,
|
|
17543
17581
|
dot: start,
|
|
17544
|
-
children: [start,
|
|
17582
|
+
children: [start, ...access]
|
|
17545
17583
|
};
|
|
17546
17584
|
} else {
|
|
17547
17585
|
return {
|
|
@@ -17580,6 +17618,40 @@ function PropertyAccess($$ctx, $$state) {
|
|
|
17580
17618
|
if ($$ctx.exit) $$ctx.exit("PropertyAccess", $$state, $$final, $$eventData);
|
|
17581
17619
|
return $$final;
|
|
17582
17620
|
}
|
|
17621
|
+
var AccessLiteral$parser = (0, import_lib2.$C)(StringLiteral, IntegerLiteral);
|
|
17622
|
+
function AccessLiteral($$ctx, $$state) {
|
|
17623
|
+
const $$entered = $$ctx.enter && $$ctx.enter("AccessLiteral", $$state);
|
|
17624
|
+
if ($$entered && "cache" in $$entered) return $$entered.cache;
|
|
17625
|
+
const $$eventData = $$entered && $$entered.data;
|
|
17626
|
+
const $$r = AccessLiteral$parser($$ctx, $$state);
|
|
17627
|
+
if (!$$r) {
|
|
17628
|
+
if ($$ctx.exit) $$ctx.exit("AccessLiteral", $$state, void 0, $$eventData);
|
|
17629
|
+
return void 0;
|
|
17630
|
+
}
|
|
17631
|
+
if ($$ctx.tokenize) {
|
|
17632
|
+
const $$tok = $$r;
|
|
17633
|
+
$$tok.value = { type: "AccessLiteral", children: [$$r.value].flat(), token: $$state.input.substring($$state.pos, $$r.pos), loc: $$r.loc };
|
|
17634
|
+
if ($$ctx.exit) $$ctx.exit("AccessLiteral", $$state, $$tok, $$eventData);
|
|
17635
|
+
return $$tok;
|
|
17636
|
+
}
|
|
17637
|
+
const $$loc = $$r.loc, $$value = $$r.value;
|
|
17638
|
+
const $$m = (function($skip, $loc, $0, $1) {
|
|
17639
|
+
var literal = $0;
|
|
17640
|
+
return {
|
|
17641
|
+
type: "Literal",
|
|
17642
|
+
subtype: literal.type,
|
|
17643
|
+
children: [literal],
|
|
17644
|
+
raw: literal.token
|
|
17645
|
+
};
|
|
17646
|
+
})(import_lib2.SKIP, $$loc, $$value, $$value);
|
|
17647
|
+
let $$final = void 0;
|
|
17648
|
+
if ($$m !== import_lib2.SKIP) {
|
|
17649
|
+
$$r.value = $$m;
|
|
17650
|
+
$$final = $$r;
|
|
17651
|
+
}
|
|
17652
|
+
if ($$ctx.exit) $$ctx.exit("AccessLiteral", $$state, $$final, $$eventData);
|
|
17653
|
+
return $$final;
|
|
17654
|
+
}
|
|
17583
17655
|
var ExplicitPropertyGlob$parser = (0, import_lib2.$S)((0, import_lib2.$Y)(ExplicitAccessStart), PropertyGlob);
|
|
17584
17656
|
function ExplicitPropertyGlob($$ctx, $$state) {
|
|
17585
17657
|
const $$entered = $$ctx.enter && $$ctx.enter("ExplicitPropertyGlob", $$state);
|
|
@@ -17665,10 +17737,11 @@ function PropertyBind($$ctx, $$state) {
|
|
|
17665
17737
|
var dot = $3;
|
|
17666
17738
|
var id = $4;
|
|
17667
17739
|
var args = $5;
|
|
17740
|
+
const children = id.unicode ? [modifier, modifier?.token === "?" ? dot : null, "[", propertyKey(id), "]"] : [modifier, dot, id];
|
|
17668
17741
|
return {
|
|
17669
17742
|
type: "PropertyBind",
|
|
17670
17743
|
name: id.name,
|
|
17671
|
-
children
|
|
17744
|
+
children,
|
|
17672
17745
|
// omit `@` from children
|
|
17673
17746
|
args: args?.children.slice(1, -1) ?? []
|
|
17674
17747
|
// remove the parens from the arg list, or give an empty list
|
|
@@ -17704,10 +17777,11 @@ function PropertyBindExplicitArguments($$ctx, $$state) {
|
|
|
17704
17777
|
var dot = $3;
|
|
17705
17778
|
var id = $4;
|
|
17706
17779
|
var args = $5;
|
|
17780
|
+
const children = id.unicode ? [modifier, modifier?.token === "?" ? dot : null, "[", propertyKey(id), "]"] : [modifier, dot, id];
|
|
17707
17781
|
return {
|
|
17708
17782
|
type: "PropertyBind",
|
|
17709
17783
|
name: id.name,
|
|
17710
|
-
children
|
|
17784
|
+
children,
|
|
17711
17785
|
// omit `@` from children
|
|
17712
17786
|
args: args?.children.slice(1, -1) ?? []
|
|
17713
17787
|
// remove the parens from the arg list, or give an empty list
|
|
@@ -21853,9 +21927,16 @@ function SymbolLiteral($$ctx, $$state) {
|
|
|
21853
21927
|
const $$m = (function($skip, $loc, $0, $1, $2) {
|
|
21854
21928
|
var colon = $1;
|
|
21855
21929
|
var id = $2;
|
|
21856
|
-
let name, token;
|
|
21930
|
+
let name, token, quoted;
|
|
21857
21931
|
if (id.type === "Identifier") {
|
|
21858
|
-
(
|
|
21932
|
+
if (id.unicode) {
|
|
21933
|
+
name = id.unicode;
|
|
21934
|
+
token = { $loc: id.children?.[0]?.$loc, token: `"${id.unicode}"` };
|
|
21935
|
+
quoted = true;
|
|
21936
|
+
} else {
|
|
21937
|
+
({ name, children: [token] } = id);
|
|
21938
|
+
quoted = false;
|
|
21939
|
+
}
|
|
21859
21940
|
} else {
|
|
21860
21941
|
name = literalValue({
|
|
21861
21942
|
type: "Literal",
|
|
@@ -21864,17 +21945,18 @@ function SymbolLiteral($$ctx, $$state) {
|
|
|
21864
21945
|
children: [id]
|
|
21865
21946
|
});
|
|
21866
21947
|
token = id;
|
|
21948
|
+
quoted = true;
|
|
21867
21949
|
}
|
|
21868
21950
|
if (config.symbols.includes(name)) {
|
|
21869
21951
|
return {
|
|
21870
21952
|
type: "SymbolLiteral",
|
|
21871
|
-
children:
|
|
21872
|
-
{ ...colon, token: "Symbol." },
|
|
21873
|
-
token
|
|
21874
|
-
] : [
|
|
21953
|
+
children: quoted ? [
|
|
21875
21954
|
{ ...colon, token: "Symbol[" },
|
|
21876
21955
|
token,
|
|
21877
21956
|
"]"
|
|
21957
|
+
] : [
|
|
21958
|
+
{ ...colon, token: "Symbol." },
|
|
21959
|
+
token
|
|
21878
21960
|
],
|
|
21879
21961
|
name
|
|
21880
21962
|
};
|
|
@@ -21883,7 +21965,7 @@ function SymbolLiteral($$ctx, $$state) {
|
|
|
21883
21965
|
type: "SymbolLiteral",
|
|
21884
21966
|
children: [
|
|
21885
21967
|
{ ...colon, token: "Symbol.for(" },
|
|
21886
|
-
|
|
21968
|
+
quoted ? token : ['"', token, '"'],
|
|
21887
21969
|
")"
|
|
21888
21970
|
],
|
|
21889
21971
|
name
|
|
@@ -34164,7 +34246,7 @@ function IntegerLiteral($$ctx, $$state) {
|
|
|
34164
34246
|
const $$loc = $$r.loc, $$value = $$r.value;
|
|
34165
34247
|
const $$m = /* @__PURE__ */ (function($skip, $loc, $0, $1, $2) {
|
|
34166
34248
|
var token = $2;
|
|
34167
|
-
return { $loc, token };
|
|
34249
|
+
return { type: "NumericLiteral", $loc, token };
|
|
34168
34250
|
})(import_lib2.SKIP, $$loc, $$value, $$value[0], $$value[1]);
|
|
34169
34251
|
let $$final = void 0;
|
|
34170
34252
|
if ($$m !== import_lib2.SKIP) {
|
|
@@ -35325,11 +35407,11 @@ function TemplateBlockCharacters($$ctx, $$state) {
|
|
|
35325
35407
|
if ($$ctx.exit) $$ctx.exit("TemplateBlockCharacters", $$state, $$final, $$eventData);
|
|
35326
35408
|
return $$final;
|
|
35327
35409
|
}
|
|
35328
|
-
var ReservedWord$0$parser = (0, import_lib2.$S)((0, import_lib2.$EXPECT)($R67, "ReservedWord /(?:off|yes|on|no)/"), NonIdContinue, CoffeeBooleansEnabled);
|
|
35329
|
-
var ReservedWord$1$parser = (0, import_lib2.$S)((0, import_lib2.$EXPECT)($R68, "ReservedWord /isnt/"), NonIdContinue, CoffeeIsntEnabled);
|
|
35330
|
-
var ReservedWord$2$parser = (0, import_lib2.$S)((0, import_lib2.$EXPECT)($R69, "ReservedWord /by/"), NonIdContinue, CoffeeForLoopsEnabled);
|
|
35331
|
-
var ReservedWord$3$parser = (0, import_lib2.$S)((0, import_lib2.$EXPECT)($R70, "ReservedWord /of/"), NonIdContinue, CoffeeOfEnabled);
|
|
35332
|
-
var ReservedWord$4$parser = (0, import_lib2.$S)((0, import_lib2.$EXPECT)($R71, "ReservedWord /(?:instanceof|interface|protected|continue|debugger|function|default|extends|finally|private|delete|export|import|public|return|static|switch|typeof|unless|await|break|catch|class|const|false|super|throw|until|while|yield|case|else|enum|loop|null|this|true|void|with|and|for|let|new|not|try|var|do|if|in|is|or)/"), NonIdContinue);
|
|
35410
|
+
var ReservedWord$0$parser = (0, import_lib2.$S)((0, import_lib2.$TEXT)((0, import_lib2.$EXPECT)($R67, "ReservedWord /(?:off|yes|on|no)/")), NonIdContinue, CoffeeBooleansEnabled);
|
|
35411
|
+
var ReservedWord$1$parser = (0, import_lib2.$S)((0, import_lib2.$TEXT)((0, import_lib2.$EXPECT)($R68, "ReservedWord /isnt/")), NonIdContinue, CoffeeIsntEnabled);
|
|
35412
|
+
var ReservedWord$2$parser = (0, import_lib2.$S)((0, import_lib2.$TEXT)((0, import_lib2.$EXPECT)($R69, "ReservedWord /by/")), NonIdContinue, CoffeeForLoopsEnabled);
|
|
35413
|
+
var ReservedWord$3$parser = (0, import_lib2.$S)((0, import_lib2.$TEXT)((0, import_lib2.$EXPECT)($R70, "ReservedWord /of/")), NonIdContinue, CoffeeOfEnabled);
|
|
35414
|
+
var ReservedWord$4$parser = (0, import_lib2.$S)((0, import_lib2.$TEXT)((0, import_lib2.$EXPECT)($R71, "ReservedWord /(?:instanceof|interface|protected|continue|debugger|function|default|extends|finally|private|delete|export|import|public|return|static|switch|typeof|unless|await|break|catch|class|const|false|super|throw|until|while|yield|case|else|enum|loop|null|this|true|void|with|and|for|let|new|not|try|var|do|if|in|is|or)/")), NonIdContinue);
|
|
35333
35415
|
function ReservedWord$0($$ctx, $$state) {
|
|
35334
35416
|
const $$r = ReservedWord$0$parser($$ctx, $$state);
|
|
35335
35417
|
if (!$$r) {
|
package/dist/ts-diagnostic.js
CHANGED
|
@@ -21,14 +21,22 @@ __export(ts_diagnostic_exports, {
|
|
|
21
21
|
flattenDiagnosticMessageText: () => flattenDiagnosticMessageText,
|
|
22
22
|
forwardMap: () => forwardMap,
|
|
23
23
|
remapPosition: () => remapPosition,
|
|
24
|
+
remapPositionStrict: () => remapPositionStrict,
|
|
24
25
|
remapRange: () => remapRange
|
|
25
26
|
});
|
|
26
27
|
module.exports = __toCommonJS(ts_diagnostic_exports);
|
|
27
28
|
function remapPosition(position, sourcemapLines) {
|
|
28
|
-
if (!sourcemapLines)
|
|
29
|
+
if (!sourcemapLines) {
|
|
30
|
+
return position;
|
|
31
|
+
}
|
|
32
|
+
return remapPositionStrict(position, sourcemapLines) ?? walkBack(position, sourcemapLines) ?? position;
|
|
33
|
+
}
|
|
34
|
+
function remapPositionStrict(position, sourcemapLines) {
|
|
29
35
|
const { line, character } = position;
|
|
30
36
|
const textLine = sourcemapLines[line];
|
|
31
|
-
if (!textLine?.length)
|
|
37
|
+
if (!textLine?.length) {
|
|
38
|
+
return void 0;
|
|
39
|
+
}
|
|
32
40
|
let i = 0, p = 0, l = textLine.length, lastMapping, lastMappingPosition = 0;
|
|
33
41
|
while (i < l) {
|
|
34
42
|
const mapping = textLine[i];
|
|
@@ -42,18 +50,42 @@ function remapPosition(position, sourcemapLines) {
|
|
|
42
50
|
}
|
|
43
51
|
i++;
|
|
44
52
|
}
|
|
45
|
-
if (lastMapping) {
|
|
46
|
-
|
|
47
|
-
const srcChar = lastMapping[3];
|
|
48
|
-
const newChar = srcChar + character - lastMappingPosition;
|
|
49
|
-
return {
|
|
50
|
-
line: srcLine,
|
|
51
|
-
character: Math.max(0, newChar)
|
|
52
|
-
};
|
|
53
|
-
} else {
|
|
54
|
-
return position;
|
|
53
|
+
if (!lastMapping) {
|
|
54
|
+
return void 0;
|
|
55
55
|
}
|
|
56
|
+
const srcLine = lastMapping[2];
|
|
57
|
+
const srcChar = lastMapping[3];
|
|
58
|
+
const newChar = srcChar + character - lastMappingPosition;
|
|
59
|
+
return {
|
|
60
|
+
line: srcLine,
|
|
61
|
+
character: Math.max(0, newChar)
|
|
62
|
+
};
|
|
56
63
|
}
|
|
64
|
+
const walkBack = function(position, sourcemapLines) {
|
|
65
|
+
for (let i1 = Math.min(position.line, sourcemapLines.length) + -1; i1 >= 0; --i1) {
|
|
66
|
+
const l = i1;
|
|
67
|
+
const prevLine = sourcemapLines[l];
|
|
68
|
+
if (!prevLine?.length) {
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
let results = void 0;
|
|
72
|
+
for (let i2 = prevLine.length + -1; i2 >= 0; --i2) {
|
|
73
|
+
const i = i2;
|
|
74
|
+
if (!(prevLine[i].length === 4)) continue;
|
|
75
|
+
results = prevLine[i];
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
;
|
|
79
|
+
const lastMapping = results;
|
|
80
|
+
if (lastMapping) {
|
|
81
|
+
return {
|
|
82
|
+
line: lastMapping[2],
|
|
83
|
+
character: Math.max(0, lastMapping[3])
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return void 0;
|
|
88
|
+
};
|
|
57
89
|
function remapRange(range, sourcemapLines) {
|
|
58
90
|
return {
|
|
59
91
|
start: remapPosition(range.start, sourcemapLines),
|
|
@@ -126,5 +158,6 @@ function flattenDiagnosticMessageText(diag, indent = 0) {
|
|
|
126
158
|
flattenDiagnosticMessageText,
|
|
127
159
|
forwardMap,
|
|
128
160
|
remapPosition,
|
|
161
|
+
remapPositionStrict,
|
|
129
162
|
remapRange
|
|
130
163
|
});
|
package/dist/ts-diagnostic.mjs
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
function remapPosition(position, sourcemapLines) {
|
|
2
|
-
if (!sourcemapLines)
|
|
2
|
+
if (!sourcemapLines) {
|
|
3
|
+
return position;
|
|
4
|
+
}
|
|
5
|
+
return remapPositionStrict(position, sourcemapLines) ?? walkBack(position, sourcemapLines) ?? position;
|
|
6
|
+
}
|
|
7
|
+
function remapPositionStrict(position, sourcemapLines) {
|
|
3
8
|
const { line, character } = position;
|
|
4
9
|
const textLine = sourcemapLines[line];
|
|
5
|
-
if (!textLine?.length)
|
|
10
|
+
if (!textLine?.length) {
|
|
11
|
+
return void 0;
|
|
12
|
+
}
|
|
6
13
|
let i = 0, p = 0, l = textLine.length, lastMapping, lastMappingPosition = 0;
|
|
7
14
|
while (i < l) {
|
|
8
15
|
const mapping = textLine[i];
|
|
@@ -16,18 +23,42 @@ function remapPosition(position, sourcemapLines) {
|
|
|
16
23
|
}
|
|
17
24
|
i++;
|
|
18
25
|
}
|
|
19
|
-
if (lastMapping) {
|
|
20
|
-
|
|
21
|
-
const srcChar = lastMapping[3];
|
|
22
|
-
const newChar = srcChar + character - lastMappingPosition;
|
|
23
|
-
return {
|
|
24
|
-
line: srcLine,
|
|
25
|
-
character: Math.max(0, newChar)
|
|
26
|
-
};
|
|
27
|
-
} else {
|
|
28
|
-
return position;
|
|
26
|
+
if (!lastMapping) {
|
|
27
|
+
return void 0;
|
|
29
28
|
}
|
|
29
|
+
const srcLine = lastMapping[2];
|
|
30
|
+
const srcChar = lastMapping[3];
|
|
31
|
+
const newChar = srcChar + character - lastMappingPosition;
|
|
32
|
+
return {
|
|
33
|
+
line: srcLine,
|
|
34
|
+
character: Math.max(0, newChar)
|
|
35
|
+
};
|
|
30
36
|
}
|
|
37
|
+
const walkBack = function(position, sourcemapLines) {
|
|
38
|
+
for (let i1 = Math.min(position.line, sourcemapLines.length) + -1; i1 >= 0; --i1) {
|
|
39
|
+
const l = i1;
|
|
40
|
+
const prevLine = sourcemapLines[l];
|
|
41
|
+
if (!prevLine?.length) {
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
let results = void 0;
|
|
45
|
+
for (let i2 = prevLine.length + -1; i2 >= 0; --i2) {
|
|
46
|
+
const i = i2;
|
|
47
|
+
if (!(prevLine[i].length === 4)) continue;
|
|
48
|
+
results = prevLine[i];
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
;
|
|
52
|
+
const lastMapping = results;
|
|
53
|
+
if (lastMapping) {
|
|
54
|
+
return {
|
|
55
|
+
line: lastMapping[2],
|
|
56
|
+
character: Math.max(0, lastMapping[3])
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return void 0;
|
|
61
|
+
};
|
|
31
62
|
function remapRange(range, sourcemapLines) {
|
|
32
63
|
return {
|
|
33
64
|
start: remapPosition(range.start, sourcemapLines),
|
|
@@ -99,5 +130,6 @@ export {
|
|
|
99
130
|
flattenDiagnosticMessageText,
|
|
100
131
|
forwardMap,
|
|
101
132
|
remapPosition,
|
|
133
|
+
remapPositionStrict,
|
|
102
134
|
remapRange
|
|
103
135
|
};
|
package/dist/ts-service/index.js
CHANGED
|
@@ -223,7 +223,26 @@ function parseTsConfigForCivet(projectPath, transpilers, options = {}) {
|
|
|
223
223
|
} else ref2 = system;
|
|
224
224
|
const configSys = ref2;
|
|
225
225
|
const tsConfigPath = import_node_path2.default.join(projectPath, "tsconfig.json");
|
|
226
|
-
|
|
226
|
+
let config;
|
|
227
|
+
let configFound;
|
|
228
|
+
if (options.tsConfig != null) {
|
|
229
|
+
config = options.tsConfig;
|
|
230
|
+
configFound = true;
|
|
231
|
+
} else {
|
|
232
|
+
configFound = system.fileExists(tsConfigPath);
|
|
233
|
+
let ref3;
|
|
234
|
+
if (configFound) {
|
|
235
|
+
ref3 = import_typescript4.default.readConfigFile(tsConfigPath, system.readFile).config;
|
|
236
|
+
} else {
|
|
237
|
+
if (extraExtensions.length > 0) {
|
|
238
|
+
ref3 = { include: extraExtensions.map((ext) => `**/*${ext}`) };
|
|
239
|
+
} else {
|
|
240
|
+
ref3 = {};
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
;
|
|
244
|
+
config = ref3;
|
|
245
|
+
}
|
|
227
246
|
const parsed = import_typescript4.default.parseJsonConfigFileContent(
|
|
228
247
|
config,
|
|
229
248
|
configSys,
|
|
@@ -235,6 +254,7 @@ function parseTsConfigForCivet(projectPath, transpilers, options = {}) {
|
|
|
235
254
|
parsed.options.allowNonTsExtensions ??= true;
|
|
236
255
|
parsed.options.jsx ??= import_typescript4.default.JsxEmit.Preserve;
|
|
237
256
|
parsed.options.rootDir ??= projectPath;
|
|
257
|
+
parsed.configFound = configFound;
|
|
238
258
|
return parsed;
|
|
239
259
|
}
|
|
240
260
|
|
|
@@ -695,6 +715,7 @@ function TSService(projectPath, options) {
|
|
|
695
715
|
};
|
|
696
716
|
return Object.assign({}, service, {
|
|
697
717
|
host,
|
|
718
|
+
configFound: parsedConfig.configFound,
|
|
698
719
|
/** `foo.civet.tsx` → `foo.civet`; passthrough for non-transpiled files. */
|
|
699
720
|
getSourceFileName(fileName) {
|
|
700
721
|
return getCanonicalFileName(remapFileName(fileName, transpilers));
|