@marko/language-tools 2.3.1 → 2.4.0
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 +108 -137
- package/dist/index.mjs +108 -141
- package/dist/processors/index.d.ts +2 -2
- package/dist/util/project.d.ts +1 -1
- package/marko.internal.d.ts +46 -77
- package/package.json +9 -11
- package/dist/extractors/script/util/is-valid-identifier.d.ts +0 -1
package/dist/index.js
CHANGED
|
@@ -53,8 +53,7 @@ var import_htmljs_parser = require("htmljs-parser");
|
|
|
53
53
|
// src/util/get-node-at-offset.ts
|
|
54
54
|
function getNodeAtOffset(offset, program) {
|
|
55
55
|
const childNode = childAtOffset(offset, program.body);
|
|
56
|
-
if (childNode)
|
|
57
|
-
return visitChildNode(offset, childNode);
|
|
56
|
+
if (childNode) return visitChildNode(offset, childNode);
|
|
58
57
|
return childAtOffset(offset, program.static) || program;
|
|
59
58
|
}
|
|
60
59
|
function visitChildNode(offset, child) {
|
|
@@ -118,8 +117,7 @@ function visitAttrNode(offset, attr) {
|
|
|
118
117
|
}
|
|
119
118
|
function childAtOffset(offset, children) {
|
|
120
119
|
let max = children.length - 1;
|
|
121
|
-
if (max === -1)
|
|
122
|
-
return void 0;
|
|
120
|
+
if (max === -1) return void 0;
|
|
123
121
|
let min = 0;
|
|
124
122
|
while (min < max) {
|
|
125
123
|
const mid = 1 + min + max >>> 1;
|
|
@@ -297,6 +295,7 @@ var Builder = class {
|
|
|
297
295
|
}
|
|
298
296
|
if (!range.expressions.length) {
|
|
299
297
|
switch (nameText = this.#code.slice(range.start, range.end)) {
|
|
298
|
+
// All statement types will early return.
|
|
300
299
|
case "style": {
|
|
301
300
|
styleBlockReg.lastIndex = range.end;
|
|
302
301
|
const styleBlockMatch = styleBlockReg.exec(this.#code);
|
|
@@ -371,6 +370,8 @@ var Builder = class {
|
|
|
371
370
|
);
|
|
372
371
|
this.#comments = void 0;
|
|
373
372
|
return import_htmljs_parser.TagType.statement;
|
|
373
|
+
// The following are all still tags,
|
|
374
|
+
// but with a different body type.
|
|
374
375
|
case "area":
|
|
375
376
|
case "base":
|
|
376
377
|
case "br":
|
|
@@ -630,8 +631,7 @@ var Builder = class {
|
|
|
630
631
|
}
|
|
631
632
|
onCloseTagEnd(range) {
|
|
632
633
|
const parent = this.#parentNode;
|
|
633
|
-
if (hasCloseTag(parent))
|
|
634
|
-
parent.close.end = range.end;
|
|
634
|
+
if (hasCloseTag(parent)) parent.close.end = range.end;
|
|
635
635
|
parent.end = range.end;
|
|
636
636
|
this.#parentNode = parent.parent;
|
|
637
637
|
}
|
|
@@ -730,8 +730,7 @@ var Extracted = class {
|
|
|
730
730
|
}
|
|
731
731
|
sourcePositionAt(generatedOffset) {
|
|
732
732
|
const sourceOffset = this.sourceOffsetAt(generatedOffset);
|
|
733
|
-
if (sourceOffset !== void 0)
|
|
734
|
-
return this.parsed.positionAt(sourceOffset);
|
|
733
|
+
if (sourceOffset !== void 0) return this.parsed.positionAt(sourceOffset);
|
|
735
734
|
}
|
|
736
735
|
sourceLocationAt(generatedStart, generatedEnd) {
|
|
737
736
|
const sourceRange = this.#generatedToSource.rangeAt(
|
|
@@ -807,8 +806,7 @@ var TokenView = class {
|
|
|
807
806
|
}
|
|
808
807
|
const startToken = this.#tokens[max];
|
|
809
808
|
const startTokenInStart = this.inStart(startToken);
|
|
810
|
-
if (startTokenInStart >= inEnd)
|
|
811
|
-
return;
|
|
809
|
+
if (startTokenInStart >= inEnd) return;
|
|
812
810
|
max = this.#last;
|
|
813
811
|
while (min < max) {
|
|
814
812
|
const mid = 1 + min + max >>> 1;
|
|
@@ -823,8 +821,7 @@ var TokenView = class {
|
|
|
823
821
|
const endToken = this.#tokens[min];
|
|
824
822
|
const endTokenInStart = this.inStart(endToken);
|
|
825
823
|
const endTokenInEnd = endTokenInStart + endToken.length;
|
|
826
|
-
if (endTokenInEnd < inStart)
|
|
827
|
-
return;
|
|
824
|
+
if (endTokenInEnd < inStart) return;
|
|
828
825
|
const startIndex = inStart - startTokenInStart;
|
|
829
826
|
const endIndex = inEnd - endTokenInStart;
|
|
830
827
|
const start = this.outStart(startToken) + Math.max(0, startIndex);
|
|
@@ -983,12 +980,6 @@ var ScriptParser = class {
|
|
|
983
980
|
}
|
|
984
981
|
};
|
|
985
982
|
|
|
986
|
-
// src/extractors/script/util/is-valid-identifier.ts
|
|
987
|
-
var import_helper_validator_identifier = require("@babel/helper-validator-identifier");
|
|
988
|
-
function isValidIdentifier(name) {
|
|
989
|
-
return (0, import_helper_validator_identifier.isIdentifierName)(name) && !(0, import_helper_validator_identifier.isKeyword)(name) && !(0, import_helper_validator_identifier.isStrictBindReservedWord)(name, true);
|
|
990
|
-
}
|
|
991
|
-
|
|
992
983
|
// src/extractors/script/util/attach-scopes.ts
|
|
993
984
|
var t = __toESM(require("@babel/types"));
|
|
994
985
|
var ATTR_UNAMED = "value";
|
|
@@ -1359,6 +1350,10 @@ function* getVarIdentifiers(parsed, lVal, objectPath, sourceName) {
|
|
|
1359
1350
|
function trackMutationsInClosures(root, scope, mutations) {
|
|
1360
1351
|
traverse(root, (node) => {
|
|
1361
1352
|
switch (node.type) {
|
|
1353
|
+
// Since the root will always be an expression it's impossible
|
|
1354
|
+
// to hit a "FunctionDeclaration" without first going through
|
|
1355
|
+
// a a different function context. So we don't need to track it.
|
|
1356
|
+
// case "FunctionDeclaration":
|
|
1362
1357
|
case "FunctionExpression":
|
|
1363
1358
|
case "ObjectMethod":
|
|
1364
1359
|
case "ArrowFunctionExpression":
|
|
@@ -1370,8 +1365,7 @@ function trackMutationsInClosures(root, scope, mutations) {
|
|
|
1370
1365
|
});
|
|
1371
1366
|
}
|
|
1372
1367
|
function trackMutations(node, scope, mutations, parentBlock, parentBlockShadows, parentBlockMutations) {
|
|
1373
|
-
if (!node)
|
|
1374
|
-
return;
|
|
1368
|
+
if (!node) return;
|
|
1375
1369
|
let block = parentBlock;
|
|
1376
1370
|
let blockShadows = parentBlockShadows;
|
|
1377
1371
|
let blockMutations = parentBlockMutations;
|
|
@@ -1494,8 +1488,7 @@ function trackMutations(node, scope, mutations, parentBlock, parentBlockShadows,
|
|
|
1494
1488
|
}
|
|
1495
1489
|
if (block !== parentBlock && blockMutations.length) {
|
|
1496
1490
|
for (const { name, start } of blockMutations) {
|
|
1497
|
-
if (blockShadows.has(name))
|
|
1498
|
-
continue;
|
|
1491
|
+
if (blockShadows.has(name)) continue;
|
|
1499
1492
|
const binding = resolveWritableVar(scope, name);
|
|
1500
1493
|
if (binding) {
|
|
1501
1494
|
binding.mutated = true;
|
|
@@ -1512,10 +1505,8 @@ function trackShadows(node, scope, shadows) {
|
|
|
1512
1505
|
}
|
|
1513
1506
|
}
|
|
1514
1507
|
function traverse(node, enter) {
|
|
1515
|
-
if (!node)
|
|
1516
|
-
|
|
1517
|
-
if (enter(node))
|
|
1518
|
-
return;
|
|
1508
|
+
if (!node) return;
|
|
1509
|
+
if (enter(node)) return;
|
|
1519
1510
|
for (const key of t.VISITOR_KEYS[node.type]) {
|
|
1520
1511
|
const child = node[key];
|
|
1521
1512
|
if (Array.isArray(child)) {
|
|
@@ -1613,8 +1604,7 @@ function getRuntimeOverrides(runtimeTypes, generics, applyGenerics) {
|
|
|
1613
1604
|
var MaybeInputTypedefReg = /@typedef\b[\s\S]*\bInput\b/;
|
|
1614
1605
|
function getJSDocInputType(comment, ts) {
|
|
1615
1606
|
var _a, _b, _c, _d;
|
|
1616
|
-
if (!MaybeInputTypedefReg.test(comment))
|
|
1617
|
-
return;
|
|
1607
|
+
if (!MaybeInputTypedefReg.test(comment)) return;
|
|
1618
1608
|
const sourceFile = ts.createSourceFile(
|
|
1619
1609
|
"_.js",
|
|
1620
1610
|
comment,
|
|
@@ -1623,8 +1613,7 @@ function getJSDocInputType(comment, ts) {
|
|
|
1623
1613
|
ts.ScriptKind.JS
|
|
1624
1614
|
);
|
|
1625
1615
|
const tags = (_b = (_a = sourceFile.endOfFileToken.jsDoc) == null ? void 0 : _a[0]) == null ? void 0 : _b.tags;
|
|
1626
|
-
if (!(tags && hasInputTypeDef(ts, sourceFile, tags)))
|
|
1627
|
-
return;
|
|
1616
|
+
if (!(tags && hasInputTypeDef(ts, sourceFile, tags))) return;
|
|
1628
1617
|
let typeParameters;
|
|
1629
1618
|
for (const tag of tags) {
|
|
1630
1619
|
if (isTemplateTag(ts, tag)) {
|
|
@@ -1674,10 +1663,11 @@ var REG_EXT = /(?<=[/\\][^/\\]+)\.[^.]+$/;
|
|
|
1674
1663
|
var REG_BLOCK = /\s*{/y;
|
|
1675
1664
|
var REG_NEW_LINE = /^|(\r?\n)/g;
|
|
1676
1665
|
var REG_ATTR_ARG_LITERAL = /(?<=\s*)(["'])((?:[^"'\\]+|\\.|(?!\1))*)\1\s*([,)])/my;
|
|
1677
|
-
var REG_TAG_IMPORT = /(?<=(['"]))<([
|
|
1666
|
+
var REG_TAG_IMPORT = /(?<=(['"]))<([^'">]+)>(?=\1)/;
|
|
1678
1667
|
var REG_INPUT_TYPE = /\s*(interface|type)\s+Input\b/y;
|
|
1679
1668
|
var REG_OBJECT_PROPERTY = /^[_$a-z][_$a-z0-9]*$/i;
|
|
1680
1669
|
var REG_COMMENT_PRAGMA = /\/\/(?:\s*@ts-|\/\s*<)/y;
|
|
1670
|
+
var REG_TAG_NAME_IDENTIFIER = /^[A-Z][a-zA-Z_$]+$/;
|
|
1681
1671
|
var IF_TAG_ALTERNATES = /* @__PURE__ */ new WeakMap();
|
|
1682
1672
|
var WROTE_COMMENT = /* @__PURE__ */ new WeakSet();
|
|
1683
1673
|
var START_OF_FILE = { start: 0, end: 0 };
|
|
@@ -1992,8 +1982,7 @@ constructor(_?: Return) {}
|
|
|
1992
1982
|
let renderId = this.#getRenderId(child);
|
|
1993
1983
|
if (!renderId && alternates) {
|
|
1994
1984
|
for (const { node } of alternates) {
|
|
1995
|
-
if (renderId = this.#getRenderId(node))
|
|
1996
|
-
break;
|
|
1985
|
+
if (renderId = this.#getRenderId(node)) break;
|
|
1997
1986
|
}
|
|
1998
1987
|
}
|
|
1999
1988
|
if (renderId) {
|
|
@@ -2164,7 +2153,7 @@ constructor(_?: Return) {}
|
|
|
2164
2153
|
if (def) {
|
|
2165
2154
|
const importPath = resolveTagImport(this.#filename, def);
|
|
2166
2155
|
const renderer = (importPath == null ? void 0 : importPath.endsWith(".marko")) ? `renderTemplate(import("${importPath}"))` : def.html ? `renderNativeTag("${def.name}")` : "missingTag";
|
|
2167
|
-
if (!def.html &&
|
|
2156
|
+
if (!def.html && REG_TAG_NAME_IDENTIFIER.test(tagName)) {
|
|
2168
2157
|
this.#extractor.write(
|
|
2169
2158
|
`${varShared("renderPreferLocal")}(
|
|
2170
2159
|
// @ts-expect-error We expect the compiler to error because we are checking if the tag is defined.
|
|
@@ -2174,7 +2163,7 @@ ${varShared(renderer)})`);
|
|
|
2174
2163
|
} else {
|
|
2175
2164
|
this.#extractor.write(varShared(renderer));
|
|
2176
2165
|
}
|
|
2177
|
-
} else if (
|
|
2166
|
+
} else if (REG_TAG_NAME_IDENTIFIER.test(tagName)) {
|
|
2178
2167
|
this.#extractor.write(`${varShared("renderDynamicTag")}(
|
|
2179
2168
|
`).copy(tag.name).write("\n)");
|
|
2180
2169
|
} else {
|
|
@@ -2396,13 +2385,11 @@ ${isMutatedVar(tag.parent, valueLiteral) ? `${varLocal("return")}.mutate.` : ""}
|
|
|
2396
2385
|
}
|
|
2397
2386
|
if (dynamicAttrTagParents) {
|
|
2398
2387
|
this.#writeDynamicAttrTagParents(dynamicAttrTagParents);
|
|
2399
|
-
if (wasMerge)
|
|
2400
|
-
this.#extractor.write(`)${SEP_COMMA_NEW_LINE}`);
|
|
2388
|
+
if (wasMerge) this.#extractor.write(`)${SEP_COMMA_NEW_LINE}`);
|
|
2401
2389
|
}
|
|
2402
2390
|
}
|
|
2403
2391
|
#writeStaticAttrTags(staticAttrTags, wasMerge) {
|
|
2404
|
-
if (!wasMerge)
|
|
2405
|
-
this.#extractor.write("...{");
|
|
2392
|
+
if (!wasMerge) this.#extractor.write("...{");
|
|
2406
2393
|
this.#extractor.write(
|
|
2407
2394
|
`[${varShared("never")}](){
|
|
2408
2395
|
const attrTags = ${varShared(
|
|
@@ -2418,27 +2405,27 @@ const attrTags = ${varShared(
|
|
|
2418
2405
|
}
|
|
2419
2406
|
}
|
|
2420
2407
|
this.#extractor.write("\n}");
|
|
2421
|
-
if (!wasMerge)
|
|
2422
|
-
this.#extractor.write("}");
|
|
2408
|
+
if (!wasMerge) this.#extractor.write("}");
|
|
2423
2409
|
this.#extractor.write(SEP_COMMA_NEW_LINE);
|
|
2424
2410
|
for (const nameText in staticAttrTags) {
|
|
2425
2411
|
const attrTag = staticAttrTags[nameText];
|
|
2426
2412
|
const attrTagDef = this.#lookup.getTag(nameText);
|
|
2427
|
-
const isRepeated = attrTag.length > 1
|
|
2413
|
+
const isRepeated = attrTag.length > 1;
|
|
2428
2414
|
const [firstAttrTag] = attrTag;
|
|
2429
2415
|
const name = (attrTagDef == null ? void 0 : attrTagDef.targetProperty) || nameText.slice(nameText.lastIndexOf(":") + 1);
|
|
2430
2416
|
this.#extractor.write(`["${name}"`);
|
|
2431
2417
|
this.#writeTagNameComment(firstAttrTag);
|
|
2432
2418
|
this.#extractor.write("]: ");
|
|
2433
2419
|
if (isRepeated) {
|
|
2434
|
-
this.#extractor.write("
|
|
2420
|
+
this.#extractor.write(`${varShared("repeatedAttrTag")}(
|
|
2421
|
+
`);
|
|
2435
2422
|
}
|
|
2436
2423
|
for (const childNode of attrTag) {
|
|
2437
2424
|
this.#writeTagInputObject(childNode);
|
|
2438
2425
|
this.#extractor.write(SEP_COMMA_NEW_LINE);
|
|
2439
2426
|
}
|
|
2440
2427
|
if (isRepeated) {
|
|
2441
|
-
this.#extractor.write(`
|
|
2428
|
+
this.#extractor.write(`)${SEP_COMMA_NEW_LINE}`);
|
|
2442
2429
|
}
|
|
2443
2430
|
}
|
|
2444
2431
|
}
|
|
@@ -2477,8 +2464,7 @@ const attrTags = ${varShared(
|
|
|
2477
2464
|
case "for": {
|
|
2478
2465
|
this.#extractor.write(`${varShared("forAttrTag")}({
|
|
2479
2466
|
`);
|
|
2480
|
-
if (!this.#writeAttrs(tag))
|
|
2481
|
-
this.#writeTagNameComment(tag);
|
|
2467
|
+
if (!this.#writeAttrs(tag)) this.#writeTagNameComment(tag);
|
|
2482
2468
|
this.#extractor.write("}, \n");
|
|
2483
2469
|
this.#writeComments(tag);
|
|
2484
2470
|
this.#extractor.copy(tag.typeParams).write("(\n").copy((_b = tag.params) == null ? void 0 : _b.value).write("\n) => (");
|
|
@@ -2488,12 +2474,11 @@ const attrTags = ${varShared(
|
|
|
2488
2474
|
}
|
|
2489
2475
|
case "while": {
|
|
2490
2476
|
this.#writeComments(tag);
|
|
2491
|
-
this.#extractor.write(
|
|
2492
|
-
`).copy(
|
|
2477
|
+
this.#extractor.write("((\n").copy(
|
|
2493
2478
|
this.#getRangeWithoutTrailingComma((_c = tag.args) == null ? void 0 : _c.value) || "undefined"
|
|
2494
|
-
).write("\n) ?
|
|
2479
|
+
).write("\n) ? ");
|
|
2495
2480
|
this.#writeDynamicAttrTagBody(tag);
|
|
2496
|
-
this.#extractor.write("
|
|
2481
|
+
this.#extractor.write(" : {})");
|
|
2497
2482
|
break;
|
|
2498
2483
|
}
|
|
2499
2484
|
}
|
|
@@ -2501,24 +2486,24 @@ const attrTags = ${varShared(
|
|
|
2501
2486
|
}
|
|
2502
2487
|
}
|
|
2503
2488
|
#writeTagInputObject(tag) {
|
|
2504
|
-
if (!tag.params)
|
|
2505
|
-
|
|
2489
|
+
if (!tag.params) this.#writeComments(tag);
|
|
2490
|
+
const body = this.#processBody(tag);
|
|
2491
|
+
let writeInputObj = true;
|
|
2506
2492
|
let hasInput = false;
|
|
2507
|
-
this.#extractor.write("{\n");
|
|
2508
2493
|
if (tag.args) {
|
|
2509
2494
|
hasInput = true;
|
|
2510
|
-
this.#extractor.
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
}
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2495
|
+
this.#extractor.copy(tag.args.value);
|
|
2496
|
+
if (body || tag.attrs || tag.shorthandId || tag.shorthandClassNames) {
|
|
2497
|
+
this.#extractor.write(",\n{\n");
|
|
2498
|
+
} else {
|
|
2499
|
+
writeInputObj = false;
|
|
2500
|
+
}
|
|
2501
|
+
} else {
|
|
2502
|
+
this.#extractor.write("{\n");
|
|
2517
2503
|
}
|
|
2518
2504
|
if (this.#writeAttrs(tag)) {
|
|
2519
2505
|
hasInput = true;
|
|
2520
2506
|
}
|
|
2521
|
-
const body = this.#processBody(tag);
|
|
2522
2507
|
let hasRenderBody = false;
|
|
2523
2508
|
if (body) {
|
|
2524
2509
|
hasInput = true;
|
|
@@ -2564,7 +2549,9 @@ const attrTags = ${varShared(
|
|
|
2564
2549
|
if (!hasInput) {
|
|
2565
2550
|
this.#writeTagNameComment(tag);
|
|
2566
2551
|
}
|
|
2567
|
-
|
|
2552
|
+
if (writeInputObj) {
|
|
2553
|
+
this.#extractor.write("\n}");
|
|
2554
|
+
}
|
|
2568
2555
|
}
|
|
2569
2556
|
#writeObjectKeys(keys) {
|
|
2570
2557
|
this.#extractor.write("{");
|
|
@@ -2578,8 +2565,7 @@ const attrTags = ${varShared(
|
|
|
2578
2565
|
}
|
|
2579
2566
|
#copyWithMutationsReplaced(range) {
|
|
2580
2567
|
const mutations = this.#mutationOffsets;
|
|
2581
|
-
if (!mutations)
|
|
2582
|
-
return this.#extractor.copy(range);
|
|
2568
|
+
if (!mutations) return this.#extractor.copy(range);
|
|
2583
2569
|
const len = mutations.length;
|
|
2584
2570
|
let curOffset = range.start;
|
|
2585
2571
|
let minIndex = 0;
|
|
@@ -2629,8 +2615,7 @@ const attrTags = ${varShared(
|
|
|
2629
2615
|
#processBody(parent) {
|
|
2630
2616
|
var _a;
|
|
2631
2617
|
const { body } = parent;
|
|
2632
|
-
if (!body)
|
|
2633
|
-
return;
|
|
2618
|
+
if (!body) return;
|
|
2634
2619
|
const last = body.length - 1;
|
|
2635
2620
|
let renderBody;
|
|
2636
2621
|
let staticAttrTags;
|
|
@@ -2663,56 +2648,55 @@ const attrTags = ${varShared(
|
|
|
2663
2648
|
case "if": {
|
|
2664
2649
|
let alternates;
|
|
2665
2650
|
hasDynamicAttrTags ||= child.hasAttrTags;
|
|
2666
|
-
loop:
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2651
|
+
loop: while (i <= last) {
|
|
2652
|
+
const nextChild = body[i++];
|
|
2653
|
+
switch (nextChild.type) {
|
|
2654
|
+
case 17 /* Text */:
|
|
2655
|
+
if (this.#isEmptyText(nextChild)) {
|
|
2656
|
+
continue loop;
|
|
2657
|
+
} else {
|
|
2658
|
+
break;
|
|
2659
|
+
}
|
|
2660
|
+
case 1 /* Tag */:
|
|
2661
|
+
switch (nextChild.nameText) {
|
|
2662
|
+
case "else-if": {
|
|
2663
|
+
const alternate = {
|
|
2664
|
+
condition: this.#getRangeWithoutTrailingComma(
|
|
2665
|
+
(_a = nextChild.args) == null ? void 0 : _a.value
|
|
2666
|
+
) || this.#getAttrValue(nextChild, ATTR_UNAMED2),
|
|
2667
|
+
node: nextChild
|
|
2668
|
+
};
|
|
2669
|
+
hasDynamicAttrTags ||= nextChild.hasAttrTags;
|
|
2670
|
+
if (alternates) {
|
|
2671
|
+
alternates.push(alternate);
|
|
2672
|
+
} else {
|
|
2673
|
+
alternates = [alternate];
|
|
2674
|
+
}
|
|
2672
2675
|
continue loop;
|
|
2673
|
-
} else {
|
|
2674
|
-
break;
|
|
2675
2676
|
}
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
if (alternates) {
|
|
2687
|
-
alternates.push(alternate);
|
|
2688
|
-
} else {
|
|
2689
|
-
alternates = [alternate];
|
|
2690
|
-
}
|
|
2691
|
-
continue loop;
|
|
2677
|
+
case "else": {
|
|
2678
|
+
const alternate = {
|
|
2679
|
+
condition: this.#getAttrValue(nextChild, "if"),
|
|
2680
|
+
node: nextChild
|
|
2681
|
+
};
|
|
2682
|
+
hasDynamicAttrTags ||= nextChild.hasAttrTags;
|
|
2683
|
+
if (alternates) {
|
|
2684
|
+
alternates.push(alternate);
|
|
2685
|
+
} else {
|
|
2686
|
+
alternates = [alternate];
|
|
2692
2687
|
}
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
};
|
|
2698
|
-
hasDynamicAttrTags ||= nextChild.hasAttrTags;
|
|
2699
|
-
if (alternates) {
|
|
2700
|
-
alternates.push(alternate);
|
|
2701
|
-
} else {
|
|
2702
|
-
alternates = [alternate];
|
|
2703
|
-
}
|
|
2704
|
-
if (alternate.condition) {
|
|
2705
|
-
continue loop;
|
|
2706
|
-
} else {
|
|
2707
|
-
break loop;
|
|
2708
|
-
}
|
|
2688
|
+
if (alternate.condition) {
|
|
2689
|
+
continue loop;
|
|
2690
|
+
} else {
|
|
2691
|
+
break loop;
|
|
2709
2692
|
}
|
|
2710
2693
|
}
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
i--;
|
|
2714
|
-
break;
|
|
2694
|
+
}
|
|
2695
|
+
break;
|
|
2715
2696
|
}
|
|
2697
|
+
i--;
|
|
2698
|
+
break;
|
|
2699
|
+
}
|
|
2716
2700
|
IF_TAG_ALTERNATES.set(child, alternates);
|
|
2717
2701
|
}
|
|
2718
2702
|
}
|
|
@@ -2780,8 +2764,7 @@ const attrTags = ${varShared(
|
|
|
2780
2764
|
}
|
|
2781
2765
|
}
|
|
2782
2766
|
#getRangeWithoutTrailingComma(range) {
|
|
2783
|
-
if (!range)
|
|
2784
|
-
return void 0;
|
|
2767
|
+
if (!range) return void 0;
|
|
2785
2768
|
const { start } = range;
|
|
2786
2769
|
let end = range.end - 1;
|
|
2787
2770
|
while (end >= start) {
|
|
@@ -2836,8 +2819,7 @@ const attrTags = ${varShared(
|
|
|
2836
2819
|
const code = this.#read(node);
|
|
2837
2820
|
code;
|
|
2838
2821
|
const info = this.#getJSDocInputTypeFromNode(node);
|
|
2839
|
-
if (info)
|
|
2840
|
-
return info;
|
|
2822
|
+
if (info) return info;
|
|
2841
2823
|
}
|
|
2842
2824
|
}
|
|
2843
2825
|
#getJSDocInputTypeFromNode(node) {
|
|
@@ -2872,8 +2854,7 @@ const attrTags = ${varShared(
|
|
|
2872
2854
|
const start = attr.name.start + 1;
|
|
2873
2855
|
const end = attr.name.end - 1;
|
|
2874
2856
|
for (let i = end; i-- > start; ) {
|
|
2875
|
-
if (this.#code.charAt(i) === ":")
|
|
2876
|
-
return i;
|
|
2857
|
+
if (this.#code.charAt(i) === ":") return i;
|
|
2877
2858
|
}
|
|
2878
2859
|
return false;
|
|
2879
2860
|
}
|
|
@@ -2965,8 +2946,7 @@ function getTypeLibs(rootDir, ts, host) {
|
|
|
2965
2946
|
var _a;
|
|
2966
2947
|
const config = getConfig(rootDir);
|
|
2967
2948
|
let typeLibs = config.cache.get(getTypeLibs);
|
|
2968
|
-
if (typeLibs)
|
|
2969
|
-
return typeLibs;
|
|
2949
|
+
if (typeLibs) return typeLibs;
|
|
2970
2950
|
const resolveTypeCompilerOptions = {
|
|
2971
2951
|
moduleResolution: ts.ModuleResolutionKind.Bundler
|
|
2972
2952
|
};
|
|
@@ -3011,8 +2991,7 @@ function getTypeLibs(rootDir, ts, host) {
|
|
|
3011
2991
|
return typeLibs;
|
|
3012
2992
|
}
|
|
3013
2993
|
function getScriptLang(fileName, defaultScriptLang, ts, host) {
|
|
3014
|
-
if (fileName.endsWith(".d.marko"))
|
|
3015
|
-
return "ts" /* ts */;
|
|
2994
|
+
if (fileName.endsWith(".d.marko")) return "ts" /* ts */;
|
|
3016
2995
|
const dir = import_path2.default.dirname(fileName);
|
|
3017
2996
|
const config = getConfig(dir);
|
|
3018
2997
|
const cache = config.cache.get(getScriptLang);
|
|
@@ -3167,8 +3146,7 @@ __export(processors_exports, {
|
|
|
3167
3146
|
// src/util/get-ext.ts
|
|
3168
3147
|
function getExt(fileName) {
|
|
3169
3148
|
const extIndex = fileName.lastIndexOf(".");
|
|
3170
|
-
if (extIndex !== -1)
|
|
3171
|
-
return fileName.slice(extIndex);
|
|
3149
|
+
if (extIndex !== -1) return fileName.slice(extIndex);
|
|
3172
3150
|
}
|
|
3173
3151
|
|
|
3174
3152
|
// src/processors/marko.ts
|
|
@@ -3298,8 +3276,7 @@ var marko_default = {
|
|
|
3298
3276
|
statement,
|
|
3299
3277
|
sourceFile
|
|
3300
3278
|
);
|
|
3301
|
-
if (!/^(?:import|export) /.test(printed))
|
|
3302
|
-
code += "static ";
|
|
3279
|
+
if (!/^(?:import|export) /.test(printed)) code += "static ";
|
|
3303
3280
|
code += printed + nlChar;
|
|
3304
3281
|
}
|
|
3305
3282
|
if (componentImpl == null ? void 0 : componentImpl.members.length) {
|
|
@@ -3347,7 +3324,7 @@ var marko_default = {
|
|
|
3347
3324
|
return ts.isTypeAliasDeclaration(statement) && statement.name.escapedText === "Input" && ts.isTypeLiteralNode(statement.type) && !statement.typeParameters && statement.type.members.length === 0 || ts.isInterfaceDeclaration(statement) && statement.name.escapedText === "Input" && !statement.heritageClauses && !statement.typeParameters && statement.members.length === 0;
|
|
3348
3325
|
}
|
|
3349
3326
|
function isExportComponentType(statement) {
|
|
3350
|
-
return ts.isExportDeclaration(statement) && statement.exportClause && ts.isNamedExports(statement.exportClause) && statement.exportClause.elements.length === 1 && statement.exportClause.elements[0].name.escapedText === "Component";
|
|
3327
|
+
return ts.isExportDeclaration(statement) && statement.exportClause && ts.isNamedExports(statement.exportClause) && statement.exportClause.elements.length === 1 && ts.isIdentifier(statement.exportClause.elements[0].name) && statement.exportClause.elements[0].name.escapedText === "Component";
|
|
3351
3328
|
}
|
|
3352
3329
|
function isVariableStatementForName(statement, name) {
|
|
3353
3330
|
if (ts.isVariableStatement(statement)) {
|
|
@@ -3390,8 +3367,7 @@ function isHTMLTag(tag) {
|
|
|
3390
3367
|
return builtinTagsRegex.test(tag);
|
|
3391
3368
|
}
|
|
3392
3369
|
function getAttributeValueType(value) {
|
|
3393
|
-
if (value === void 0 || value[0] !== "=")
|
|
3394
|
-
return void 0;
|
|
3370
|
+
if (value === void 0 || value[0] !== "=") return void 0;
|
|
3395
3371
|
value = value.substring(1).trim();
|
|
3396
3372
|
switch (value) {
|
|
3397
3373
|
case "NaN":
|
|
@@ -3449,8 +3425,7 @@ var HTMLExtractor = class {
|
|
|
3449
3425
|
switch (node.type) {
|
|
3450
3426
|
case 16 /* AttrTag */:
|
|
3451
3427
|
(_a = node.body) == null ? void 0 : _a.forEach((child) => {
|
|
3452
|
-
if (this.#visitNode(child))
|
|
3453
|
-
hasDynamicBody = true;
|
|
3428
|
+
if (this.#visitNode(child)) hasDynamicBody = true;
|
|
3454
3429
|
});
|
|
3455
3430
|
break;
|
|
3456
3431
|
case 1 /* Tag */: {
|
|
@@ -3492,16 +3467,13 @@ var HTMLExtractor = class {
|
|
|
3492
3467
|
this.#extractor.copy(node.name);
|
|
3493
3468
|
this.#extractor.write(` data-marko-node-id="${id}"`);
|
|
3494
3469
|
(_a = node.attrs) == null ? void 0 : _a.forEach((attr) => {
|
|
3495
|
-
if (attr.type === 10 /* AttrNamed */)
|
|
3496
|
-
|
|
3497
|
-
else if (attr.type === 15 /* AttrSpread */)
|
|
3498
|
-
hasDynamicAttrs = true;
|
|
3470
|
+
if (attr.type === 10 /* AttrNamed */) this.#writeAttrNamed(attr);
|
|
3471
|
+
else if (attr.type === 15 /* AttrSpread */) hasDynamicAttrs = true;
|
|
3499
3472
|
});
|
|
3500
3473
|
this.#extractor.write(">");
|
|
3501
3474
|
if (!isVoidTag(node.nameText)) {
|
|
3502
3475
|
(_b = node.body) == null ? void 0 : _b.forEach((child) => {
|
|
3503
|
-
if (this.#visitNode(child))
|
|
3504
|
-
hasDynamicBody = true;
|
|
3476
|
+
if (this.#visitNode(child)) hasDynamicBody = true;
|
|
3505
3477
|
});
|
|
3506
3478
|
this.#extractor.write(`</${node.nameText}>`);
|
|
3507
3479
|
}
|
|
@@ -3530,8 +3502,7 @@ var HTMLExtractor = class {
|
|
|
3530
3502
|
}
|
|
3531
3503
|
const valueString = this.#read(attr.value);
|
|
3532
3504
|
const valueType = getAttributeValueType(valueString);
|
|
3533
|
-
if (valueType === void 0)
|
|
3534
|
-
return;
|
|
3505
|
+
if (valueType === void 0) return;
|
|
3535
3506
|
switch (valueType) {
|
|
3536
3507
|
case 0 /* True */:
|
|
3537
3508
|
break;
|