@marko/language-tools 2.5.9 → 2.5.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/dist/index.js +41 -39
- package/dist/index.mjs +41 -39
- package/marko.internal.d.ts +7 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2430,51 +2430,53 @@ constructor(_?: Return) {}
|
|
|
2430
2430
|
const tagName = tag.nameText;
|
|
2431
2431
|
const renderId = this.#getRenderId(tag);
|
|
2432
2432
|
const def = tagName ? this.#lookup.getTag(tagName) : void 0;
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
if (
|
|
2439
|
-
this.#
|
|
2440
|
-
|
|
2441
|
-
const
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
const tagId = this.#ensureTagId(tag);
|
|
2446
|
-
let isDynamic = true;
|
|
2447
|
-
this.#extractor.write(
|
|
2448
|
-
`(${varShared("assertTag")}(${varShared("tags")},${tagId},(
|
|
2449
|
-
`
|
|
2450
|
-
);
|
|
2451
|
-
if (tagName && REG_TAG_NAME_IDENTIFIER.test(tagName)) {
|
|
2452
|
-
if (importPath) {
|
|
2453
|
-
this.#extractor.write(
|
|
2454
|
-
`${varShared("fallbackTemplate")}(${tagName},import("${importPath}"))`
|
|
2455
|
-
);
|
|
2456
|
-
} else {
|
|
2457
|
-
this.#extractor.copy(tag.name);
|
|
2458
|
-
}
|
|
2459
|
-
} else if (importPath) {
|
|
2460
|
-
isDynamic = !importPath.endsWith(".marko");
|
|
2433
|
+
const isHTML = def == null ? void 0 : def.html;
|
|
2434
|
+
const importPath = !isHTML && resolveTagImport(this.#filename, def);
|
|
2435
|
+
const isMissing = def && !isHTML && !importPath;
|
|
2436
|
+
let tagIdentifier;
|
|
2437
|
+
let isTemplate = false;
|
|
2438
|
+
if (!isHTML || !isMissing) {
|
|
2439
|
+
const tagId = this.#ensureTagId(tag);
|
|
2440
|
+
tagIdentifier = varLocal("tag_" + tagId);
|
|
2441
|
+
this.#extractor.write(`const ${tagIdentifier} = (
|
|
2442
|
+
`);
|
|
2443
|
+
if (tagName && REG_TAG_NAME_IDENTIFIER.test(tagName)) {
|
|
2444
|
+
if (importPath) {
|
|
2461
2445
|
this.#extractor.write(
|
|
2462
|
-
`${varShared("
|
|
2446
|
+
`${varShared("fallbackTemplate")}(${tagName},import("${importPath}"))`
|
|
2463
2447
|
);
|
|
2464
2448
|
} else {
|
|
2465
|
-
this.#
|
|
2466
|
-
}
|
|
2467
|
-
this.#extractor.write("\n)),");
|
|
2468
|
-
const attrTagTree = this.#getAttrTagTree(tag);
|
|
2469
|
-
if (attrTagTree) {
|
|
2470
|
-
this.#writeAttrTagTree(attrTagTree, `${varShared("tags")}[${tagId}]`);
|
|
2471
|
-
this.#extractor.write(",");
|
|
2449
|
+
this.#extractor.copy(tag.name);
|
|
2472
2450
|
}
|
|
2451
|
+
} else if (importPath) {
|
|
2452
|
+
isTemplate = importPath.endsWith(".marko");
|
|
2473
2453
|
this.#extractor.write(
|
|
2474
|
-
`${varShared(
|
|
2454
|
+
`${varShared("resolveTemplate")}(import("${importPath}"))`
|
|
2475
2455
|
);
|
|
2456
|
+
} else {
|
|
2457
|
+
this.#writeDynamicTagName(tag);
|
|
2458
|
+
}
|
|
2459
|
+
this.#extractor.write("\n);\n");
|
|
2460
|
+
const attrTagTree = this.#getAttrTagTree(tag);
|
|
2461
|
+
if (attrTagTree) {
|
|
2462
|
+
this.#writeAttrTagTree(attrTagTree, tagIdentifier);
|
|
2463
|
+
this.#extractor.write(";\n");
|
|
2476
2464
|
}
|
|
2477
2465
|
}
|
|
2466
|
+
if (renderId) {
|
|
2467
|
+
this.#extractor.write(
|
|
2468
|
+
`${varShared("assertRendered")}(${varShared("rendered")},${renderId},`
|
|
2469
|
+
);
|
|
2470
|
+
}
|
|
2471
|
+
if (isHTML) {
|
|
2472
|
+
this.#extractor.write(`${varShared("renderNativeTag")}("`).copy(tag.name).write('")');
|
|
2473
|
+
} else if (tagIdentifier) {
|
|
2474
|
+
this.#extractor.write(
|
|
2475
|
+
`${varShared(isTemplate ? "renderTemplate" : "renderDynamicTag")}(${tagIdentifier})`
|
|
2476
|
+
);
|
|
2477
|
+
} else {
|
|
2478
|
+
this.#extractor.write(varShared("missingTag"));
|
|
2479
|
+
}
|
|
2478
2480
|
if (tag.typeArgs) {
|
|
2479
2481
|
this.#extractor.write(`<0>()`).copy(tag.typeArgs).write("()(");
|
|
2480
2482
|
} else {
|
|
@@ -2712,7 +2714,7 @@ ${isMutatedVar(tag.parent, valueLiteral) ? `${varLocal("return")}.mutate.` : ""}
|
|
|
2712
2714
|
curTag = curTag.parent;
|
|
2713
2715
|
}
|
|
2714
2716
|
this.#extractor.write(
|
|
2715
|
-
`${varShared("attrTagFor")}(${
|
|
2717
|
+
`${varShared("attrTagFor")}(${varLocal("tag_" + tagId)},${accessor})([`
|
|
2716
2718
|
);
|
|
2717
2719
|
} else {
|
|
2718
2720
|
this.#extractor.write(`${varShared("attrTag")}([`);
|
|
@@ -2838,7 +2840,7 @@ ${isMutatedVar(tag.parent, valueLiteral) ? `${varLocal("return")}.mutate.` : ""}
|
|
|
2838
2840
|
);
|
|
2839
2841
|
if (tagId) {
|
|
2840
2842
|
this.#extractor.write(
|
|
2841
|
-
`${varShared("contentFor")}(${
|
|
2843
|
+
`${varShared("contentFor")}(${varLocal("tag_" + tagId)})`
|
|
2842
2844
|
);
|
|
2843
2845
|
} else {
|
|
2844
2846
|
this.#extractor.write(varShared("content"));
|
package/dist/index.mjs
CHANGED
|
@@ -2393,51 +2393,53 @@ constructor(_?: Return) {}
|
|
|
2393
2393
|
const tagName = tag.nameText;
|
|
2394
2394
|
const renderId = this.#getRenderId(tag);
|
|
2395
2395
|
const def = tagName ? this.#lookup.getTag(tagName) : void 0;
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
if (
|
|
2402
|
-
this.#
|
|
2403
|
-
|
|
2404
|
-
const
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
const tagId = this.#ensureTagId(tag);
|
|
2409
|
-
let isDynamic = true;
|
|
2410
|
-
this.#extractor.write(
|
|
2411
|
-
`(${varShared("assertTag")}(${varShared("tags")},${tagId},(
|
|
2412
|
-
`
|
|
2413
|
-
);
|
|
2414
|
-
if (tagName && REG_TAG_NAME_IDENTIFIER.test(tagName)) {
|
|
2415
|
-
if (importPath) {
|
|
2416
|
-
this.#extractor.write(
|
|
2417
|
-
`${varShared("fallbackTemplate")}(${tagName},import("${importPath}"))`
|
|
2418
|
-
);
|
|
2419
|
-
} else {
|
|
2420
|
-
this.#extractor.copy(tag.name);
|
|
2421
|
-
}
|
|
2422
|
-
} else if (importPath) {
|
|
2423
|
-
isDynamic = !importPath.endsWith(".marko");
|
|
2396
|
+
const isHTML = def == null ? void 0 : def.html;
|
|
2397
|
+
const importPath = !isHTML && resolveTagImport(this.#filename, def);
|
|
2398
|
+
const isMissing = def && !isHTML && !importPath;
|
|
2399
|
+
let tagIdentifier;
|
|
2400
|
+
let isTemplate = false;
|
|
2401
|
+
if (!isHTML || !isMissing) {
|
|
2402
|
+
const tagId = this.#ensureTagId(tag);
|
|
2403
|
+
tagIdentifier = varLocal("tag_" + tagId);
|
|
2404
|
+
this.#extractor.write(`const ${tagIdentifier} = (
|
|
2405
|
+
`);
|
|
2406
|
+
if (tagName && REG_TAG_NAME_IDENTIFIER.test(tagName)) {
|
|
2407
|
+
if (importPath) {
|
|
2424
2408
|
this.#extractor.write(
|
|
2425
|
-
`${varShared("
|
|
2409
|
+
`${varShared("fallbackTemplate")}(${tagName},import("${importPath}"))`
|
|
2426
2410
|
);
|
|
2427
2411
|
} else {
|
|
2428
|
-
this.#
|
|
2429
|
-
}
|
|
2430
|
-
this.#extractor.write("\n)),");
|
|
2431
|
-
const attrTagTree = this.#getAttrTagTree(tag);
|
|
2432
|
-
if (attrTagTree) {
|
|
2433
|
-
this.#writeAttrTagTree(attrTagTree, `${varShared("tags")}[${tagId}]`);
|
|
2434
|
-
this.#extractor.write(",");
|
|
2412
|
+
this.#extractor.copy(tag.name);
|
|
2435
2413
|
}
|
|
2414
|
+
} else if (importPath) {
|
|
2415
|
+
isTemplate = importPath.endsWith(".marko");
|
|
2436
2416
|
this.#extractor.write(
|
|
2437
|
-
`${varShared(
|
|
2417
|
+
`${varShared("resolveTemplate")}(import("${importPath}"))`
|
|
2438
2418
|
);
|
|
2419
|
+
} else {
|
|
2420
|
+
this.#writeDynamicTagName(tag);
|
|
2421
|
+
}
|
|
2422
|
+
this.#extractor.write("\n);\n");
|
|
2423
|
+
const attrTagTree = this.#getAttrTagTree(tag);
|
|
2424
|
+
if (attrTagTree) {
|
|
2425
|
+
this.#writeAttrTagTree(attrTagTree, tagIdentifier);
|
|
2426
|
+
this.#extractor.write(";\n");
|
|
2439
2427
|
}
|
|
2440
2428
|
}
|
|
2429
|
+
if (renderId) {
|
|
2430
|
+
this.#extractor.write(
|
|
2431
|
+
`${varShared("assertRendered")}(${varShared("rendered")},${renderId},`
|
|
2432
|
+
);
|
|
2433
|
+
}
|
|
2434
|
+
if (isHTML) {
|
|
2435
|
+
this.#extractor.write(`${varShared("renderNativeTag")}("`).copy(tag.name).write('")');
|
|
2436
|
+
} else if (tagIdentifier) {
|
|
2437
|
+
this.#extractor.write(
|
|
2438
|
+
`${varShared(isTemplate ? "renderTemplate" : "renderDynamicTag")}(${tagIdentifier})`
|
|
2439
|
+
);
|
|
2440
|
+
} else {
|
|
2441
|
+
this.#extractor.write(varShared("missingTag"));
|
|
2442
|
+
}
|
|
2441
2443
|
if (tag.typeArgs) {
|
|
2442
2444
|
this.#extractor.write(`<0>()`).copy(tag.typeArgs).write("()(");
|
|
2443
2445
|
} else {
|
|
@@ -2675,7 +2677,7 @@ ${isMutatedVar(tag.parent, valueLiteral) ? `${varLocal("return")}.mutate.` : ""}
|
|
|
2675
2677
|
curTag = curTag.parent;
|
|
2676
2678
|
}
|
|
2677
2679
|
this.#extractor.write(
|
|
2678
|
-
`${varShared("attrTagFor")}(${
|
|
2680
|
+
`${varShared("attrTagFor")}(${varLocal("tag_" + tagId)},${accessor})([`
|
|
2679
2681
|
);
|
|
2680
2682
|
} else {
|
|
2681
2683
|
this.#extractor.write(`${varShared("attrTag")}([`);
|
|
@@ -2801,7 +2803,7 @@ ${isMutatedVar(tag.parent, valueLiteral) ? `${varLocal("return")}.mutate.` : ""}
|
|
|
2801
2803
|
);
|
|
2802
2804
|
if (tagId) {
|
|
2803
2805
|
this.#extractor.write(
|
|
2804
|
-
`${varShared("contentFor")}(${
|
|
2806
|
+
`${varShared("contentFor")}(${varLocal("tag_" + tagId)})`
|
|
2805
2807
|
);
|
|
2806
2808
|
} else {
|
|
2807
2809
|
this.#extractor.write(varShared("content"));
|
package/marko.internal.d.ts
CHANGED
|
@@ -331,11 +331,13 @@ declare global {
|
|
|
331
331
|
): <AttrTag>(
|
|
332
332
|
attrTags: Relate<
|
|
333
333
|
AttrTag,
|
|
334
|
-
|
|
335
|
-
?
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
334
|
+
[0] extends [1 & Tag]
|
|
335
|
+
? Marko.AttrTag<unknown>
|
|
336
|
+
: Marko.Input<Tag> extends infer Input
|
|
337
|
+
? [0] extends [1 & Input]
|
|
338
|
+
? Marko.AttrTag<unknown>
|
|
339
|
+
: AttrTagValue<Marko.Input<Tag>, Path>
|
|
340
|
+
: Marko.AttrTag<unknown>
|
|
339
341
|
>[],
|
|
340
342
|
) => AttrTag;
|
|
341
343
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@marko/language-tools",
|
|
3
3
|
"description": "Marko Language Tools",
|
|
4
|
-
"version": "2.5.
|
|
4
|
+
"version": "2.5.10",
|
|
5
5
|
"bugs": "https://github.com/marko-js/language-server/issues/new?template=Bug_report.md",
|
|
6
6
|
"peerDependencies": {
|
|
7
7
|
"@marko/compiler": "^5.28.4"
|