@marko/language-tools 2.5.23 → 2.5.25
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 +30 -20
- package/dist/index.mjs +30 -20
- package/marko.internal.d.ts +11 -21
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -2806,24 +2806,35 @@ ${isMutatedVar(tag.parent, valueLiteral) ? `${varLocal("return")}.mutate.` : ""}
|
|
|
2806
2806
|
}
|
|
2807
2807
|
#writeTagInputObject(tag) {
|
|
2808
2808
|
if (!tag.params) this.#writeComments(tag);
|
|
2809
|
+
const body = this.#processBody(tag);
|
|
2809
2810
|
let hasInput = false;
|
|
2810
|
-
|
|
2811
|
-
if (tag.args) {
|
|
2811
|
+
let writeInputObj = true;
|
|
2812
|
+
if (tag.args && (this.#api !== RuntimeAPI.class || !!this.#getDynamicTagExpression(tag))) {
|
|
2812
2813
|
hasInput = true;
|
|
2813
|
-
this.#extractor.
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
}
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
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
|
+
}
|
|
2820
2832
|
}
|
|
2821
2833
|
if (this.#writeAttrs(tag)) {
|
|
2822
2834
|
hasInput = true;
|
|
2823
2835
|
}
|
|
2824
2836
|
const isScript = isTextOnlyScript(tag);
|
|
2825
2837
|
let hasBodyContent = false;
|
|
2826
|
-
let body;
|
|
2827
2838
|
if (isScript) {
|
|
2828
2839
|
this.#extractor.write("async value(){");
|
|
2829
2840
|
this.#copyWithMutationsReplaced({
|
|
@@ -2831,15 +2842,12 @@ ${isMutatedVar(tag.parent, valueLiteral) ? `${varLocal("return")}.mutate.` : ""}
|
|
|
2831
2842
|
end: tag.body[tag.body.length - 1].end
|
|
2832
2843
|
});
|
|
2833
2844
|
this.#extractor.write(`}${SEP_COMMA_NEW_LINE}`);
|
|
2834
|
-
} else {
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
} else if (tag.close) {
|
|
2841
|
-
hasBodyContent = true;
|
|
2842
|
-
}
|
|
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;
|
|
2843
2851
|
}
|
|
2844
2852
|
if (tag.params || hasBodyContent) {
|
|
2845
2853
|
this.#extractor.write("[");
|
|
@@ -2901,7 +2909,9 @@ ${isMutatedVar(tag.parent, valueLiteral) ? `${varLocal("return")}.mutate.` : ""}
|
|
|
2901
2909
|
if (!hasInput) {
|
|
2902
2910
|
this.#writeTagNameComment(tag);
|
|
2903
2911
|
}
|
|
2904
|
-
|
|
2912
|
+
if (writeInputObj) {
|
|
2913
|
+
this.#extractor.write("\n}");
|
|
2914
|
+
}
|
|
2905
2915
|
}
|
|
2906
2916
|
#writeObjectKeys(keys) {
|
|
2907
2917
|
this.#extractor.write("{");
|
package/dist/index.mjs
CHANGED
|
@@ -2769,24 +2769,35 @@ ${isMutatedVar(tag.parent, valueLiteral) ? `${varLocal("return")}.mutate.` : ""}
|
|
|
2769
2769
|
}
|
|
2770
2770
|
#writeTagInputObject(tag) {
|
|
2771
2771
|
if (!tag.params) this.#writeComments(tag);
|
|
2772
|
+
const body = this.#processBody(tag);
|
|
2772
2773
|
let hasInput = false;
|
|
2773
|
-
|
|
2774
|
-
if (tag.args) {
|
|
2774
|
+
let writeInputObj = true;
|
|
2775
|
+
if (tag.args && (this.#api !== RuntimeAPI.class || !!this.#getDynamicTagExpression(tag))) {
|
|
2775
2776
|
hasInput = true;
|
|
2776
|
-
this.#extractor.
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
}
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
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
|
+
}
|
|
2783
2795
|
}
|
|
2784
2796
|
if (this.#writeAttrs(tag)) {
|
|
2785
2797
|
hasInput = true;
|
|
2786
2798
|
}
|
|
2787
2799
|
const isScript = isTextOnlyScript(tag);
|
|
2788
2800
|
let hasBodyContent = false;
|
|
2789
|
-
let body;
|
|
2790
2801
|
if (isScript) {
|
|
2791
2802
|
this.#extractor.write("async value(){");
|
|
2792
2803
|
this.#copyWithMutationsReplaced({
|
|
@@ -2794,15 +2805,12 @@ ${isMutatedVar(tag.parent, valueLiteral) ? `${varLocal("return")}.mutate.` : ""}
|
|
|
2794
2805
|
end: tag.body[tag.body.length - 1].end
|
|
2795
2806
|
});
|
|
2796
2807
|
this.#extractor.write(`}${SEP_COMMA_NEW_LINE}`);
|
|
2797
|
-
} else {
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
} else if (tag.close) {
|
|
2804
|
-
hasBodyContent = true;
|
|
2805
|
-
}
|
|
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;
|
|
2806
2814
|
}
|
|
2807
2815
|
if (tag.params || hasBodyContent) {
|
|
2808
2816
|
this.#extractor.write("[");
|
|
@@ -2864,7 +2872,9 @@ ${isMutatedVar(tag.parent, valueLiteral) ? `${varLocal("return")}.mutate.` : ""}
|
|
|
2864
2872
|
if (!hasInput) {
|
|
2865
2873
|
this.#writeTagNameComment(tag);
|
|
2866
2874
|
}
|
|
2867
|
-
|
|
2875
|
+
if (writeInputObj) {
|
|
2876
|
+
this.#extractor.write("\n}");
|
|
2877
|
+
}
|
|
2868
2878
|
}
|
|
2869
2879
|
#writeObjectKeys(keys) {
|
|
2870
2880
|
this.#extractor.write("{");
|
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,23 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@marko/language-tools",
|
|
3
3
|
"description": "Marko Language Tools",
|
|
4
|
-
"version": "2.5.
|
|
4
|
+
"version": "2.5.25",
|
|
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.28.0",
|
|
11
11
|
"@luxass/strip-json-comments": "^1.4.0",
|
|
12
12
|
"htmljs-parser": "^5.5.4",
|
|
13
13
|
"relative-import-path": "^1.0.0"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"@babel/code-frame": "^7.27.1",
|
|
17
|
-
"@marko/compiler": "^5.39.
|
|
17
|
+
"@marko/compiler": "^5.39.29",
|
|
18
18
|
"@types/babel__code-frame": "^7.0.6",
|
|
19
19
|
"@typescript/vfs": "^1.6.1",
|
|
20
|
-
"marko": "^5.37.
|
|
20
|
+
"marko": "^5.37.41",
|
|
21
21
|
"mitata": "^1.0.34",
|
|
22
22
|
"tsx": "^4.20.3"
|
|
23
23
|
},
|