@marko/language-tools 2.5.9 → 2.5.11
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 +40 -39
- package/dist/index.mjs +40 -39
- package/marko.internal.d.ts +7 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2430,51 +2430,52 @@ 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
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
if (
|
|
2443
|
-
|
|
2444
|
-
} else {
|
|
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
|
+
let tagIdentifier;
|
|
2436
|
+
let isTemplate = false;
|
|
2437
|
+
if (!isHTML && (!def || importPath)) {
|
|
2438
|
+
const tagId = this.#ensureTagId(tag);
|
|
2439
|
+
tagIdentifier = varLocal("tag_" + tagId);
|
|
2440
|
+
this.#extractor.write(`const ${tagIdentifier} = (
|
|
2441
|
+
`);
|
|
2442
|
+
if (tagName && REG_TAG_NAME_IDENTIFIER.test(tagName)) {
|
|
2443
|
+
if (importPath) {
|
|
2461
2444
|
this.#extractor.write(
|
|
2462
|
-
`${varShared("
|
|
2445
|
+
`${varShared("fallbackTemplate")}(${tagName},import("${importPath}"))`
|
|
2463
2446
|
);
|
|
2464
2447
|
} 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(",");
|
|
2448
|
+
this.#extractor.copy(tag.name);
|
|
2472
2449
|
}
|
|
2450
|
+
} else if (importPath) {
|
|
2451
|
+
isTemplate = importPath.endsWith(".marko");
|
|
2473
2452
|
this.#extractor.write(
|
|
2474
|
-
`${varShared(
|
|
2453
|
+
`${varShared("resolveTemplate")}(import("${importPath}"))`
|
|
2475
2454
|
);
|
|
2455
|
+
} else {
|
|
2456
|
+
this.#writeDynamicTagName(tag);
|
|
2457
|
+
}
|
|
2458
|
+
this.#extractor.write("\n);\n");
|
|
2459
|
+
const attrTagTree = this.#getAttrTagTree(tag);
|
|
2460
|
+
if (attrTagTree) {
|
|
2461
|
+
this.#writeAttrTagTree(attrTagTree, tagIdentifier);
|
|
2462
|
+
this.#extractor.write(";\n");
|
|
2476
2463
|
}
|
|
2477
2464
|
}
|
|
2465
|
+
if (renderId) {
|
|
2466
|
+
this.#extractor.write(
|
|
2467
|
+
`${varShared("assertRendered")}(${varShared("rendered")},${renderId},`
|
|
2468
|
+
);
|
|
2469
|
+
}
|
|
2470
|
+
if (isHTML) {
|
|
2471
|
+
this.#extractor.write(`${varShared("renderNativeTag")}("`).copy(tag.name).write('")');
|
|
2472
|
+
} else if (tagIdentifier) {
|
|
2473
|
+
this.#extractor.write(
|
|
2474
|
+
`${varShared(isTemplate ? "renderTemplate" : "renderDynamicTag")}(${tagIdentifier})`
|
|
2475
|
+
);
|
|
2476
|
+
} else {
|
|
2477
|
+
this.#extractor.write(varShared("missingTag"));
|
|
2478
|
+
}
|
|
2478
2479
|
if (tag.typeArgs) {
|
|
2479
2480
|
this.#extractor.write(`<0>()`).copy(tag.typeArgs).write("()(");
|
|
2480
2481
|
} else {
|
|
@@ -2712,7 +2713,7 @@ ${isMutatedVar(tag.parent, valueLiteral) ? `${varLocal("return")}.mutate.` : ""}
|
|
|
2712
2713
|
curTag = curTag.parent;
|
|
2713
2714
|
}
|
|
2714
2715
|
this.#extractor.write(
|
|
2715
|
-
`${varShared("attrTagFor")}(${
|
|
2716
|
+
`${varShared("attrTagFor")}(${varLocal("tag_" + tagId)},${accessor})([`
|
|
2716
2717
|
);
|
|
2717
2718
|
} else {
|
|
2718
2719
|
this.#extractor.write(`${varShared("attrTag")}([`);
|
|
@@ -2838,7 +2839,7 @@ ${isMutatedVar(tag.parent, valueLiteral) ? `${varLocal("return")}.mutate.` : ""}
|
|
|
2838
2839
|
);
|
|
2839
2840
|
if (tagId) {
|
|
2840
2841
|
this.#extractor.write(
|
|
2841
|
-
`${varShared("contentFor")}(${
|
|
2842
|
+
`${varShared("contentFor")}(${varLocal("tag_" + tagId)})`
|
|
2842
2843
|
);
|
|
2843
2844
|
} else {
|
|
2844
2845
|
this.#extractor.write(varShared("content"));
|
package/dist/index.mjs
CHANGED
|
@@ -2393,51 +2393,52 @@ 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
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
if (
|
|
2406
|
-
|
|
2407
|
-
} else {
|
|
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
|
+
let tagIdentifier;
|
|
2399
|
+
let isTemplate = false;
|
|
2400
|
+
if (!isHTML && (!def || importPath)) {
|
|
2401
|
+
const tagId = this.#ensureTagId(tag);
|
|
2402
|
+
tagIdentifier = varLocal("tag_" + tagId);
|
|
2403
|
+
this.#extractor.write(`const ${tagIdentifier} = (
|
|
2404
|
+
`);
|
|
2405
|
+
if (tagName && REG_TAG_NAME_IDENTIFIER.test(tagName)) {
|
|
2406
|
+
if (importPath) {
|
|
2424
2407
|
this.#extractor.write(
|
|
2425
|
-
`${varShared("
|
|
2408
|
+
`${varShared("fallbackTemplate")}(${tagName},import("${importPath}"))`
|
|
2426
2409
|
);
|
|
2427
2410
|
} 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(",");
|
|
2411
|
+
this.#extractor.copy(tag.name);
|
|
2435
2412
|
}
|
|
2413
|
+
} else if (importPath) {
|
|
2414
|
+
isTemplate = importPath.endsWith(".marko");
|
|
2436
2415
|
this.#extractor.write(
|
|
2437
|
-
`${varShared(
|
|
2416
|
+
`${varShared("resolveTemplate")}(import("${importPath}"))`
|
|
2438
2417
|
);
|
|
2418
|
+
} else {
|
|
2419
|
+
this.#writeDynamicTagName(tag);
|
|
2420
|
+
}
|
|
2421
|
+
this.#extractor.write("\n);\n");
|
|
2422
|
+
const attrTagTree = this.#getAttrTagTree(tag);
|
|
2423
|
+
if (attrTagTree) {
|
|
2424
|
+
this.#writeAttrTagTree(attrTagTree, tagIdentifier);
|
|
2425
|
+
this.#extractor.write(";\n");
|
|
2439
2426
|
}
|
|
2440
2427
|
}
|
|
2428
|
+
if (renderId) {
|
|
2429
|
+
this.#extractor.write(
|
|
2430
|
+
`${varShared("assertRendered")}(${varShared("rendered")},${renderId},`
|
|
2431
|
+
);
|
|
2432
|
+
}
|
|
2433
|
+
if (isHTML) {
|
|
2434
|
+
this.#extractor.write(`${varShared("renderNativeTag")}("`).copy(tag.name).write('")');
|
|
2435
|
+
} else if (tagIdentifier) {
|
|
2436
|
+
this.#extractor.write(
|
|
2437
|
+
`${varShared(isTemplate ? "renderTemplate" : "renderDynamicTag")}(${tagIdentifier})`
|
|
2438
|
+
);
|
|
2439
|
+
} else {
|
|
2440
|
+
this.#extractor.write(varShared("missingTag"));
|
|
2441
|
+
}
|
|
2441
2442
|
if (tag.typeArgs) {
|
|
2442
2443
|
this.#extractor.write(`<0>()`).copy(tag.typeArgs).write("()(");
|
|
2443
2444
|
} else {
|
|
@@ -2675,7 +2676,7 @@ ${isMutatedVar(tag.parent, valueLiteral) ? `${varLocal("return")}.mutate.` : ""}
|
|
|
2675
2676
|
curTag = curTag.parent;
|
|
2676
2677
|
}
|
|
2677
2678
|
this.#extractor.write(
|
|
2678
|
-
`${varShared("attrTagFor")}(${
|
|
2679
|
+
`${varShared("attrTagFor")}(${varLocal("tag_" + tagId)},${accessor})([`
|
|
2679
2680
|
);
|
|
2680
2681
|
} else {
|
|
2681
2682
|
this.#extractor.write(`${varShared("attrTag")}([`);
|
|
@@ -2801,7 +2802,7 @@ ${isMutatedVar(tag.parent, valueLiteral) ? `${varLocal("return")}.mutate.` : ""}
|
|
|
2801
2802
|
);
|
|
2802
2803
|
if (tagId) {
|
|
2803
2804
|
this.#extractor.write(
|
|
2804
|
-
`${varShared("contentFor")}(${
|
|
2805
|
+
`${varShared("contentFor")}(${varLocal("tag_" + tagId)})`
|
|
2805
2806
|
);
|
|
2806
2807
|
} else {
|
|
2807
2808
|
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.11",
|
|
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"
|