@marko/language-tools 2.5.22 → 2.5.24
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 +37 -28
- package/dist/index.mjs +37 -28
- package/marko.internal.d.ts +11 -21
- package/package.json +9 -9
package/dist/index.js
CHANGED
|
@@ -1740,8 +1740,6 @@ function detectAPIFromTag(parsed, tag) {
|
|
|
1740
1740
|
case "const":
|
|
1741
1741
|
case "debug":
|
|
1742
1742
|
case "define":
|
|
1743
|
-
case "html-script":
|
|
1744
|
-
case "html-style":
|
|
1745
1743
|
case "id":
|
|
1746
1744
|
case "let":
|
|
1747
1745
|
case "lifecycle":
|
|
@@ -2808,24 +2806,35 @@ ${isMutatedVar(tag.parent, valueLiteral) ? `${varLocal("return")}.mutate.` : ""}
|
|
|
2808
2806
|
}
|
|
2809
2807
|
#writeTagInputObject(tag) {
|
|
2810
2808
|
if (!tag.params) this.#writeComments(tag);
|
|
2809
|
+
const body = this.#processBody(tag);
|
|
2811
2810
|
let hasInput = false;
|
|
2812
|
-
|
|
2813
|
-
if (tag.args) {
|
|
2811
|
+
let writeInputObj = true;
|
|
2812
|
+
if (tag.args && (this.#api !== RuntimeAPI.class || !!this.#getDynamicTagExpression(tag))) {
|
|
2814
2813
|
hasInput = true;
|
|
2815
|
-
this.#extractor.
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
}
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2814
|
+
this.#extractor.copy(tag.args.value);
|
|
2815
|
+
if (body || tag.attrs || tag.shorthandId || tag.shorthandClassNames) {
|
|
2816
|
+
this.#extractor.write(",\n{\n");
|
|
2817
|
+
} else {
|
|
2818
|
+
writeInputObj = false;
|
|
2819
|
+
}
|
|
2820
|
+
} else {
|
|
2821
|
+
this.#extractor.write("{\n");
|
|
2822
|
+
if (tag.args) {
|
|
2823
|
+
hasInput = true;
|
|
2824
|
+
this.#extractor.write("[").copy({
|
|
2825
|
+
start: tag.args.start,
|
|
2826
|
+
end: tag.args.start + 1
|
|
2827
|
+
}).write('"value"').copy({
|
|
2828
|
+
start: tag.args.end - 1,
|
|
2829
|
+
end: tag.args.end
|
|
2830
|
+
}).write(`]: ${varShared("tuple")}(`).copy(tag.args.value).write(")").write(",\n");
|
|
2831
|
+
}
|
|
2822
2832
|
}
|
|
2823
2833
|
if (this.#writeAttrs(tag)) {
|
|
2824
2834
|
hasInput = true;
|
|
2825
2835
|
}
|
|
2826
2836
|
const isScript = isTextOnlyScript(tag);
|
|
2827
2837
|
let hasBodyContent = false;
|
|
2828
|
-
let body;
|
|
2829
2838
|
if (isScript) {
|
|
2830
2839
|
this.#extractor.write("async value(){");
|
|
2831
2840
|
this.#copyWithMutationsReplaced({
|
|
@@ -2833,15 +2842,12 @@ ${isMutatedVar(tag.parent, valueLiteral) ? `${varLocal("return")}.mutate.` : ""}
|
|
|
2833
2842
|
end: tag.body[tag.body.length - 1].end
|
|
2834
2843
|
});
|
|
2835
2844
|
this.#extractor.write(`}${SEP_COMMA_NEW_LINE}`);
|
|
2836
|
-
} else {
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
} else if (tag.close) {
|
|
2843
|
-
hasBodyContent = true;
|
|
2844
|
-
}
|
|
2845
|
+
} else if (body) {
|
|
2846
|
+
hasInput = true;
|
|
2847
|
+
this.#writeAttrTags(body);
|
|
2848
|
+
hasBodyContent = body.content !== void 0;
|
|
2849
|
+
} else if (tag.close) {
|
|
2850
|
+
hasBodyContent = true;
|
|
2845
2851
|
}
|
|
2846
2852
|
if (tag.params || hasBodyContent) {
|
|
2847
2853
|
this.#extractor.write("[");
|
|
@@ -2903,7 +2909,9 @@ ${isMutatedVar(tag.parent, valueLiteral) ? `${varLocal("return")}.mutate.` : ""}
|
|
|
2903
2909
|
if (!hasInput) {
|
|
2904
2910
|
this.#writeTagNameComment(tag);
|
|
2905
2911
|
}
|
|
2906
|
-
|
|
2912
|
+
if (writeInputObj) {
|
|
2913
|
+
this.#extractor.write("\n}");
|
|
2914
|
+
}
|
|
2907
2915
|
}
|
|
2908
2916
|
#writeObjectKeys(keys) {
|
|
2909
2917
|
this.#extractor.write("{");
|
|
@@ -3476,7 +3484,7 @@ var defaultMeta;
|
|
|
3476
3484
|
var ignoreErrors = (_err) => {
|
|
3477
3485
|
};
|
|
3478
3486
|
var metaByDir = /* @__PURE__ */ new Map();
|
|
3479
|
-
var
|
|
3487
|
+
var metaByTranslator = /* @__PURE__ */ new Map();
|
|
3480
3488
|
function getCompiler(dir) {
|
|
3481
3489
|
return getMeta(dir).compiler;
|
|
3482
3490
|
}
|
|
@@ -3579,7 +3587,7 @@ function clearCaches() {
|
|
|
3579
3587
|
if (defaultMeta) {
|
|
3580
3588
|
clearCacheForMeta(defaultMeta);
|
|
3581
3589
|
}
|
|
3582
|
-
for (const project of
|
|
3590
|
+
for (const project of metaByTranslator.values()) {
|
|
3583
3591
|
clearCacheForMeta(project);
|
|
3584
3592
|
}
|
|
3585
3593
|
}
|
|
@@ -3625,20 +3633,21 @@ function loadMeta(dir) {
|
|
|
3625
3633
|
if (!cached) {
|
|
3626
3634
|
const require2 = (0, import_module.createRequire)(import_path2.default.join(dir, "_.js"));
|
|
3627
3635
|
const configPath = require2.resolve("@marko/compiler/config");
|
|
3628
|
-
|
|
3636
|
+
const config = interopDefault(require2(configPath));
|
|
3637
|
+
const translatorPath = require2.resolve(config.translator);
|
|
3638
|
+
cached = metaByTranslator.get(translatorPath);
|
|
3629
3639
|
if (!cached) {
|
|
3630
3640
|
const compiler = require2(import_path2.default.dirname(configPath));
|
|
3631
|
-
const config = interopDefault(require2(configPath));
|
|
3632
3641
|
cached = {
|
|
3633
3642
|
compiler,
|
|
3634
3643
|
config: {
|
|
3635
3644
|
...config,
|
|
3636
3645
|
cache: /* @__PURE__ */ new Map(),
|
|
3637
|
-
translator: require2(
|
|
3646
|
+
translator: require2(translatorPath)
|
|
3638
3647
|
}
|
|
3639
3648
|
};
|
|
3640
3649
|
compiler.configure(cached.config);
|
|
3641
|
-
|
|
3650
|
+
metaByTranslator.set(translatorPath, cached);
|
|
3642
3651
|
}
|
|
3643
3652
|
metaByDir.set(dir, cached);
|
|
3644
3653
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1700,8 +1700,6 @@ function detectAPIFromTag(parsed, tag) {
|
|
|
1700
1700
|
case "const":
|
|
1701
1701
|
case "debug":
|
|
1702
1702
|
case "define":
|
|
1703
|
-
case "html-script":
|
|
1704
|
-
case "html-style":
|
|
1705
1703
|
case "id":
|
|
1706
1704
|
case "let":
|
|
1707
1705
|
case "lifecycle":
|
|
@@ -2771,24 +2769,35 @@ ${isMutatedVar(tag.parent, valueLiteral) ? `${varLocal("return")}.mutate.` : ""}
|
|
|
2771
2769
|
}
|
|
2772
2770
|
#writeTagInputObject(tag) {
|
|
2773
2771
|
if (!tag.params) this.#writeComments(tag);
|
|
2772
|
+
const body = this.#processBody(tag);
|
|
2774
2773
|
let hasInput = false;
|
|
2775
|
-
|
|
2776
|
-
if (tag.args) {
|
|
2774
|
+
let writeInputObj = true;
|
|
2775
|
+
if (tag.args && (this.#api !== RuntimeAPI.class || !!this.#getDynamicTagExpression(tag))) {
|
|
2777
2776
|
hasInput = true;
|
|
2778
|
-
this.#extractor.
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
}
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2777
|
+
this.#extractor.copy(tag.args.value);
|
|
2778
|
+
if (body || tag.attrs || tag.shorthandId || tag.shorthandClassNames) {
|
|
2779
|
+
this.#extractor.write(",\n{\n");
|
|
2780
|
+
} else {
|
|
2781
|
+
writeInputObj = false;
|
|
2782
|
+
}
|
|
2783
|
+
} else {
|
|
2784
|
+
this.#extractor.write("{\n");
|
|
2785
|
+
if (tag.args) {
|
|
2786
|
+
hasInput = true;
|
|
2787
|
+
this.#extractor.write("[").copy({
|
|
2788
|
+
start: tag.args.start,
|
|
2789
|
+
end: tag.args.start + 1
|
|
2790
|
+
}).write('"value"').copy({
|
|
2791
|
+
start: tag.args.end - 1,
|
|
2792
|
+
end: tag.args.end
|
|
2793
|
+
}).write(`]: ${varShared("tuple")}(`).copy(tag.args.value).write(")").write(",\n");
|
|
2794
|
+
}
|
|
2785
2795
|
}
|
|
2786
2796
|
if (this.#writeAttrs(tag)) {
|
|
2787
2797
|
hasInput = true;
|
|
2788
2798
|
}
|
|
2789
2799
|
const isScript = isTextOnlyScript(tag);
|
|
2790
2800
|
let hasBodyContent = false;
|
|
2791
|
-
let body;
|
|
2792
2801
|
if (isScript) {
|
|
2793
2802
|
this.#extractor.write("async value(){");
|
|
2794
2803
|
this.#copyWithMutationsReplaced({
|
|
@@ -2796,15 +2805,12 @@ ${isMutatedVar(tag.parent, valueLiteral) ? `${varLocal("return")}.mutate.` : ""}
|
|
|
2796
2805
|
end: tag.body[tag.body.length - 1].end
|
|
2797
2806
|
});
|
|
2798
2807
|
this.#extractor.write(`}${SEP_COMMA_NEW_LINE}`);
|
|
2799
|
-
} else {
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
} else if (tag.close) {
|
|
2806
|
-
hasBodyContent = true;
|
|
2807
|
-
}
|
|
2808
|
+
} else if (body) {
|
|
2809
|
+
hasInput = true;
|
|
2810
|
+
this.#writeAttrTags(body);
|
|
2811
|
+
hasBodyContent = body.content !== void 0;
|
|
2812
|
+
} else if (tag.close) {
|
|
2813
|
+
hasBodyContent = true;
|
|
2808
2814
|
}
|
|
2809
2815
|
if (tag.params || hasBodyContent) {
|
|
2810
2816
|
this.#extractor.write("[");
|
|
@@ -2866,7 +2872,9 @@ ${isMutatedVar(tag.parent, valueLiteral) ? `${varLocal("return")}.mutate.` : ""}
|
|
|
2866
2872
|
if (!hasInput) {
|
|
2867
2873
|
this.#writeTagNameComment(tag);
|
|
2868
2874
|
}
|
|
2869
|
-
|
|
2875
|
+
if (writeInputObj) {
|
|
2876
|
+
this.#extractor.write("\n}");
|
|
2877
|
+
}
|
|
2870
2878
|
}
|
|
2871
2879
|
#writeObjectKeys(keys) {
|
|
2872
2880
|
this.#extractor.write("{");
|
|
@@ -3439,7 +3447,7 @@ var defaultMeta;
|
|
|
3439
3447
|
var ignoreErrors = (_err) => {
|
|
3440
3448
|
};
|
|
3441
3449
|
var metaByDir = /* @__PURE__ */ new Map();
|
|
3442
|
-
var
|
|
3450
|
+
var metaByTranslator = /* @__PURE__ */ new Map();
|
|
3443
3451
|
function getCompiler(dir) {
|
|
3444
3452
|
return getMeta(dir).compiler;
|
|
3445
3453
|
}
|
|
@@ -3542,7 +3550,7 @@ function clearCaches() {
|
|
|
3542
3550
|
if (defaultMeta) {
|
|
3543
3551
|
clearCacheForMeta(defaultMeta);
|
|
3544
3552
|
}
|
|
3545
|
-
for (const project of
|
|
3553
|
+
for (const project of metaByTranslator.values()) {
|
|
3546
3554
|
clearCacheForMeta(project);
|
|
3547
3555
|
}
|
|
3548
3556
|
}
|
|
@@ -3588,20 +3596,21 @@ function loadMeta(dir) {
|
|
|
3588
3596
|
if (!cached) {
|
|
3589
3597
|
const require2 = createRequire(path2.join(dir, "_.js"));
|
|
3590
3598
|
const configPath = require2.resolve("@marko/compiler/config");
|
|
3591
|
-
|
|
3599
|
+
const config = interopDefault(require2(configPath));
|
|
3600
|
+
const translatorPath = require2.resolve(config.translator);
|
|
3601
|
+
cached = metaByTranslator.get(translatorPath);
|
|
3592
3602
|
if (!cached) {
|
|
3593
3603
|
const compiler = require2(path2.dirname(configPath));
|
|
3594
|
-
const config = interopDefault(require2(configPath));
|
|
3595
3604
|
cached = {
|
|
3596
3605
|
compiler,
|
|
3597
3606
|
config: {
|
|
3598
3607
|
...config,
|
|
3599
3608
|
cache: /* @__PURE__ */ new Map(),
|
|
3600
|
-
translator: require2(
|
|
3609
|
+
translator: require2(translatorPath)
|
|
3601
3610
|
}
|
|
3602
3611
|
};
|
|
3603
3612
|
compiler.configure(cached.config);
|
|
3604
|
-
|
|
3613
|
+
metaByTranslator.set(translatorPath, cached);
|
|
3605
3614
|
}
|
|
3606
3615
|
metaByDir.set(dir, cached);
|
|
3607
3616
|
}
|
package/marko.internal.d.ts
CHANGED
|
@@ -336,14 +336,11 @@ declare global {
|
|
|
336
336
|
? BodyRenderer<Name>
|
|
337
337
|
: [Name] extends [
|
|
338
338
|
{
|
|
339
|
-
[BodyContentKey in DefaultBodyContentKey]?: infer BodyValue
|
|
339
|
+
[BodyContentKey in DefaultBodyContentKey]?: infer BodyValue extends
|
|
340
|
+
AnyMarkoBody;
|
|
340
341
|
},
|
|
341
342
|
]
|
|
342
|
-
?
|
|
343
|
-
? BodyRenderer<BodyValue>
|
|
344
|
-
: BaseRenderer<
|
|
345
|
-
BodyContentInput<BodyParameters<Exclude<BodyValue, void>>>
|
|
346
|
-
>
|
|
343
|
+
? BodyRenderer<BodyValue>
|
|
347
344
|
: DefaultRenderer;
|
|
348
345
|
|
|
349
346
|
export type TemplateRenderer<Template> = Template extends {
|
|
@@ -372,12 +369,8 @@ declare global {
|
|
|
372
369
|
export interface BodyRenderer<Body extends AnyMarkoBody> {
|
|
373
370
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-constraint
|
|
374
371
|
(): () => <__marko_internal_input extends unknown>(
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
Relate<
|
|
378
|
-
__marko_internal_input,
|
|
379
|
-
Marko.Directives & BodyContentInput<BodyParameters<Body>>
|
|
380
|
-
>,
|
|
372
|
+
...args: BodyParamsWithDefault<Body> &
|
|
373
|
+
Relate<__marko_internal_input, BodyParamsWithDefault<Body>>
|
|
381
374
|
) => ReturnAndScope<
|
|
382
375
|
Scopes<__marko_internal_input>,
|
|
383
376
|
BodyReturnType<Body>
|
|
@@ -419,15 +412,12 @@ type ReturnAndScope<Scope, Return> = {
|
|
|
419
412
|
scope: Scope;
|
|
420
413
|
};
|
|
421
414
|
|
|
422
|
-
type
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
:
|
|
428
|
-
? { value?: [] }
|
|
429
|
-
: { value: Args }
|
|
430
|
-
: never;
|
|
415
|
+
type BodyParamsWithDefault<Body extends AnyMarkoBody> =
|
|
416
|
+
Body extends Marko.Body<infer Params, any>
|
|
417
|
+
? Params extends []
|
|
418
|
+
? [input?: Record<string, never>]
|
|
419
|
+
: Params
|
|
420
|
+
: never;
|
|
431
421
|
|
|
432
422
|
type Scopes<Input> = [0] extends [1 & Input]
|
|
433
423
|
? never
|
package/package.json
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@marko/language-tools",
|
|
3
3
|
"description": "Marko Language Tools",
|
|
4
|
-
"version": "2.5.
|
|
4
|
+
"version": "2.5.24",
|
|
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"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@babel/parser": "^7.
|
|
10
|
+
"@babel/parser": "^7.27.5",
|
|
11
11
|
"@luxass/strip-json-comments": "^1.4.0",
|
|
12
|
-
"htmljs-parser": "^5.5.
|
|
12
|
+
"htmljs-parser": "^5.5.4",
|
|
13
13
|
"relative-import-path": "^1.0.0"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
|
-
"@babel/code-frame": "^7.
|
|
17
|
-
"@marko/compiler": "^5.39.
|
|
16
|
+
"@babel/code-frame": "^7.27.1",
|
|
17
|
+
"@marko/compiler": "^5.39.26",
|
|
18
18
|
"@types/babel__code-frame": "^7.0.6",
|
|
19
|
-
"@typescript/vfs": "^1.6.
|
|
20
|
-
"marko": "^5.37.
|
|
21
|
-
"mitata": "^1.0.
|
|
22
|
-
"tsx": "^4.
|
|
19
|
+
"@typescript/vfs": "^1.6.1",
|
|
20
|
+
"marko": "^5.37.38",
|
|
21
|
+
"mitata": "^1.0.34",
|
|
22
|
+
"tsx": "^4.20.3"
|
|
23
23
|
},
|
|
24
24
|
"exports": {
|
|
25
25
|
".": {
|