@marko/language-tools 2.5.3 → 2.5.5
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 +57 -9
- package/dist/index.mjs +57 -9
- package/marko.internal.d.ts +58 -51
- package/package.json +4 -5
package/dist/index.js
CHANGED
|
@@ -2215,12 +2215,14 @@ constructor(_?: Return) {}
|
|
|
2215
2215
|
)}, ${renderId}, `
|
|
2216
2216
|
);
|
|
2217
2217
|
}
|
|
2218
|
-
this.#extractor.write(
|
|
2219
|
-
|
|
2218
|
+
this.#extractor.write(
|
|
2219
|
+
`${varShared(getForTagRuntime(this.#parsed, child))}({
|
|
2220
|
+
`
|
|
2221
|
+
);
|
|
2222
|
+
this.#writeTagNameComment(child);
|
|
2220
2223
|
this.#writeAttrs(child);
|
|
2221
|
-
this.#extractor.write(
|
|
2224
|
+
this.#extractor.write("\n}" + SEP_COMMA_NEW_LINE).copy(child.typeParams).write("(\n");
|
|
2222
2225
|
this.#writeComments(child);
|
|
2223
|
-
this.#extractor.copy(child.typeParams).write("(\n");
|
|
2224
2226
|
if (child.params) {
|
|
2225
2227
|
this.#copyWithMutationsReplaced(child.params.value);
|
|
2226
2228
|
}
|
|
@@ -2233,7 +2235,6 @@ constructor(_?: Return) {}
|
|
|
2233
2235
|
void 0,
|
|
2234
2236
|
(body == null ? void 0 : body.renderBody) ? getHoistSources(child) : void 0
|
|
2235
2237
|
);
|
|
2236
|
-
this.#extractor.write("})");
|
|
2237
2238
|
if (renderId) {
|
|
2238
2239
|
this.#extractor.write("\n}));\n");
|
|
2239
2240
|
} else {
|
|
@@ -2648,10 +2649,13 @@ const attrTags = ${varShared(
|
|
|
2648
2649
|
break;
|
|
2649
2650
|
}
|
|
2650
2651
|
case "for": {
|
|
2651
|
-
this.#extractor.write(
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2652
|
+
this.#extractor.write(
|
|
2653
|
+
`${varShared(getForAttrTagRuntime(this.#parsed, tag))}({
|
|
2654
|
+
`
|
|
2655
|
+
);
|
|
2656
|
+
this.#writeTagNameComment(tag);
|
|
2657
|
+
this.#writeAttrs(tag);
|
|
2658
|
+
this.#extractor.write("\n}, \n");
|
|
2655
2659
|
this.#writeComments(tag);
|
|
2656
2660
|
this.#extractor.copy(tag.typeParams).write("(\n").copy((_b = tag.params) == null ? void 0 : _b.value).write("\n) => (");
|
|
2657
2661
|
this.#writeDynamicAttrTagBody(tag);
|
|
@@ -3063,6 +3067,50 @@ const attrTags = ${varShared(
|
|
|
3063
3067
|
return reg.exec(this.#code);
|
|
3064
3068
|
}
|
|
3065
3069
|
};
|
|
3070
|
+
function getForTagType(parsed, tag) {
|
|
3071
|
+
if (tag.attrs) {
|
|
3072
|
+
for (const attr of tag.attrs) {
|
|
3073
|
+
if (attr.type === 15 /* AttrSpread */) {
|
|
3074
|
+
return 0 /* unknown */;
|
|
3075
|
+
}
|
|
3076
|
+
switch (parsed.read(attr.name)) {
|
|
3077
|
+
case "of":
|
|
3078
|
+
return 1 /* of */;
|
|
3079
|
+
case "in":
|
|
3080
|
+
return 2 /* in */;
|
|
3081
|
+
case "to":
|
|
3082
|
+
case "from":
|
|
3083
|
+
case "step":
|
|
3084
|
+
return 3 /* to */;
|
|
3085
|
+
}
|
|
3086
|
+
}
|
|
3087
|
+
}
|
|
3088
|
+
return 0 /* unknown */;
|
|
3089
|
+
}
|
|
3090
|
+
function getForTagRuntime(parsed, tag) {
|
|
3091
|
+
switch (getForTagType(parsed, tag)) {
|
|
3092
|
+
case 1 /* of */:
|
|
3093
|
+
return "forOfTag";
|
|
3094
|
+
case 2 /* in */:
|
|
3095
|
+
return "forInTag";
|
|
3096
|
+
case 3 /* to */:
|
|
3097
|
+
return "forToTag";
|
|
3098
|
+
default:
|
|
3099
|
+
return "forTag";
|
|
3100
|
+
}
|
|
3101
|
+
}
|
|
3102
|
+
function getForAttrTagRuntime(parsed, tag) {
|
|
3103
|
+
switch (getForTagType(parsed, tag)) {
|
|
3104
|
+
case 1 /* of */:
|
|
3105
|
+
return "forOfAttrTag";
|
|
3106
|
+
case 2 /* in */:
|
|
3107
|
+
return "forInAttrTag";
|
|
3108
|
+
case 3 /* to */:
|
|
3109
|
+
return "forToAttrTag";
|
|
3110
|
+
default:
|
|
3111
|
+
return "forAttrTag";
|
|
3112
|
+
}
|
|
3113
|
+
}
|
|
3066
3114
|
function varLocal(name) {
|
|
3067
3115
|
return VAR_LOCAL_PREFIX + name;
|
|
3068
3116
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -2179,12 +2179,14 @@ constructor(_?: Return) {}
|
|
|
2179
2179
|
)}, ${renderId}, `
|
|
2180
2180
|
);
|
|
2181
2181
|
}
|
|
2182
|
-
this.#extractor.write(
|
|
2183
|
-
|
|
2182
|
+
this.#extractor.write(
|
|
2183
|
+
`${varShared(getForTagRuntime(this.#parsed, child))}({
|
|
2184
|
+
`
|
|
2185
|
+
);
|
|
2186
|
+
this.#writeTagNameComment(child);
|
|
2184
2187
|
this.#writeAttrs(child);
|
|
2185
|
-
this.#extractor.write(
|
|
2188
|
+
this.#extractor.write("\n}" + SEP_COMMA_NEW_LINE).copy(child.typeParams).write("(\n");
|
|
2186
2189
|
this.#writeComments(child);
|
|
2187
|
-
this.#extractor.copy(child.typeParams).write("(\n");
|
|
2188
2190
|
if (child.params) {
|
|
2189
2191
|
this.#copyWithMutationsReplaced(child.params.value);
|
|
2190
2192
|
}
|
|
@@ -2197,7 +2199,6 @@ constructor(_?: Return) {}
|
|
|
2197
2199
|
void 0,
|
|
2198
2200
|
(body == null ? void 0 : body.renderBody) ? getHoistSources(child) : void 0
|
|
2199
2201
|
);
|
|
2200
|
-
this.#extractor.write("})");
|
|
2201
2202
|
if (renderId) {
|
|
2202
2203
|
this.#extractor.write("\n}));\n");
|
|
2203
2204
|
} else {
|
|
@@ -2612,10 +2613,13 @@ const attrTags = ${varShared(
|
|
|
2612
2613
|
break;
|
|
2613
2614
|
}
|
|
2614
2615
|
case "for": {
|
|
2615
|
-
this.#extractor.write(
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2616
|
+
this.#extractor.write(
|
|
2617
|
+
`${varShared(getForAttrTagRuntime(this.#parsed, tag))}({
|
|
2618
|
+
`
|
|
2619
|
+
);
|
|
2620
|
+
this.#writeTagNameComment(tag);
|
|
2621
|
+
this.#writeAttrs(tag);
|
|
2622
|
+
this.#extractor.write("\n}, \n");
|
|
2619
2623
|
this.#writeComments(tag);
|
|
2620
2624
|
this.#extractor.copy(tag.typeParams).write("(\n").copy((_b = tag.params) == null ? void 0 : _b.value).write("\n) => (");
|
|
2621
2625
|
this.#writeDynamicAttrTagBody(tag);
|
|
@@ -3027,6 +3031,50 @@ const attrTags = ${varShared(
|
|
|
3027
3031
|
return reg.exec(this.#code);
|
|
3028
3032
|
}
|
|
3029
3033
|
};
|
|
3034
|
+
function getForTagType(parsed, tag) {
|
|
3035
|
+
if (tag.attrs) {
|
|
3036
|
+
for (const attr of tag.attrs) {
|
|
3037
|
+
if (attr.type === 15 /* AttrSpread */) {
|
|
3038
|
+
return 0 /* unknown */;
|
|
3039
|
+
}
|
|
3040
|
+
switch (parsed.read(attr.name)) {
|
|
3041
|
+
case "of":
|
|
3042
|
+
return 1 /* of */;
|
|
3043
|
+
case "in":
|
|
3044
|
+
return 2 /* in */;
|
|
3045
|
+
case "to":
|
|
3046
|
+
case "from":
|
|
3047
|
+
case "step":
|
|
3048
|
+
return 3 /* to */;
|
|
3049
|
+
}
|
|
3050
|
+
}
|
|
3051
|
+
}
|
|
3052
|
+
return 0 /* unknown */;
|
|
3053
|
+
}
|
|
3054
|
+
function getForTagRuntime(parsed, tag) {
|
|
3055
|
+
switch (getForTagType(parsed, tag)) {
|
|
3056
|
+
case 1 /* of */:
|
|
3057
|
+
return "forOfTag";
|
|
3058
|
+
case 2 /* in */:
|
|
3059
|
+
return "forInTag";
|
|
3060
|
+
case 3 /* to */:
|
|
3061
|
+
return "forToTag";
|
|
3062
|
+
default:
|
|
3063
|
+
return "forTag";
|
|
3064
|
+
}
|
|
3065
|
+
}
|
|
3066
|
+
function getForAttrTagRuntime(parsed, tag) {
|
|
3067
|
+
switch (getForTagType(parsed, tag)) {
|
|
3068
|
+
case 1 /* of */:
|
|
3069
|
+
return "forOfAttrTag";
|
|
3070
|
+
case 2 /* in */:
|
|
3071
|
+
return "forInAttrTag";
|
|
3072
|
+
case 3 /* to */:
|
|
3073
|
+
return "forToAttrTag";
|
|
3074
|
+
default:
|
|
3075
|
+
return "forAttrTag";
|
|
3076
|
+
}
|
|
3077
|
+
}
|
|
3030
3078
|
function varLocal(name) {
|
|
3031
3079
|
return VAR_LOCAL_PREFIX + name;
|
|
3032
3080
|
}
|
package/marko.internal.d.ts
CHANGED
|
@@ -150,49 +150,55 @@ declare global {
|
|
|
150
150
|
Input extends { value: unknown; valueChange?: (value: any) => void },
|
|
151
151
|
>(input: Input): Input;
|
|
152
152
|
|
|
153
|
-
export function
|
|
153
|
+
export function forOfTag<
|
|
154
154
|
Value,
|
|
155
155
|
Item extends Value extends
|
|
156
156
|
| readonly (infer Item)[]
|
|
157
157
|
| Iterable<infer Item>
|
|
158
158
|
? Item
|
|
159
159
|
: unknown,
|
|
160
|
-
|
|
160
|
+
BodyContent extends Marko.Body<
|
|
161
161
|
[item: Item, index: number, all: Value],
|
|
162
162
|
void
|
|
163
163
|
>,
|
|
164
|
-
>(
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
164
|
+
>(
|
|
165
|
+
input: {
|
|
166
|
+
of: Value | false | void | null;
|
|
167
|
+
by?: (item: Item, index: number) => string;
|
|
168
|
+
},
|
|
169
|
+
content: BodyContent,
|
|
170
|
+
): ReturnAndScope<BodyContentScope<BodyContent>, void>;
|
|
169
171
|
|
|
170
|
-
export function
|
|
172
|
+
export function forInTag<
|
|
171
173
|
Value,
|
|
172
|
-
|
|
174
|
+
BodyContent extends Marko.Body<
|
|
173
175
|
[key: keyof Value, value: Value[keyof Value]],
|
|
174
176
|
void
|
|
175
177
|
>,
|
|
176
|
-
>(
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
178
|
+
>(
|
|
179
|
+
input: {
|
|
180
|
+
in: Value | false | void | null;
|
|
181
|
+
by?: (value: Value[keyof Value], key: keyof Value) => string;
|
|
182
|
+
},
|
|
183
|
+
content: BodyContent,
|
|
184
|
+
): ReturnAndScope<BodyContentScope<BodyContent>, void>;
|
|
181
185
|
|
|
182
|
-
export function
|
|
186
|
+
export function forToTag<
|
|
183
187
|
From extends void | number,
|
|
184
188
|
To extends number,
|
|
185
189
|
Step extends void | number,
|
|
186
|
-
|
|
187
|
-
>(
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
190
|
+
BodyContent extends Marko.Body<[index: number], void>,
|
|
191
|
+
>(
|
|
192
|
+
input: {
|
|
193
|
+
from?: From;
|
|
194
|
+
to: To;
|
|
195
|
+
step?: Step;
|
|
196
|
+
by?: (index: number) => string;
|
|
197
|
+
},
|
|
198
|
+
content: BodyContent,
|
|
199
|
+
): ReturnAndScope<BodyContentScope<BodyContent>, void>;
|
|
200
|
+
|
|
201
|
+
export function forTag<BodyContent extends AnyMarkoBody>(
|
|
196
202
|
input: (
|
|
197
203
|
| {
|
|
198
204
|
from?: number;
|
|
@@ -200,22 +206,23 @@ declare global {
|
|
|
200
206
|
step?: number;
|
|
201
207
|
}
|
|
202
208
|
| {
|
|
203
|
-
in:
|
|
209
|
+
in: object | false | void | null;
|
|
204
210
|
}
|
|
205
211
|
| {
|
|
206
|
-
of: readonly unknown[] |
|
|
212
|
+
of: Iterable<unknown> | readonly unknown[] | false | void | null;
|
|
207
213
|
}
|
|
208
|
-
) & {
|
|
209
|
-
|
|
214
|
+
) & { by?: (...args: unknown[]) => string },
|
|
215
|
+
content: BodyContent,
|
|
216
|
+
): ReturnAndScope<BodyContentScope<BodyContent>, void>;
|
|
210
217
|
|
|
211
|
-
export function
|
|
218
|
+
export function forOfAttrTag<
|
|
212
219
|
Value extends Iterable<any> | readonly any[],
|
|
213
220
|
const Return,
|
|
214
221
|
>(
|
|
215
222
|
input: {
|
|
216
|
-
of: Value;
|
|
223
|
+
of: Value | false | void | null;
|
|
217
224
|
},
|
|
218
|
-
|
|
225
|
+
content: (
|
|
219
226
|
value: Value extends readonly (infer Item)[] | Iterable<infer Item>
|
|
220
227
|
? Item
|
|
221
228
|
: unknown,
|
|
@@ -230,11 +237,11 @@ declare global {
|
|
|
230
237
|
: never;
|
|
231
238
|
};
|
|
232
239
|
|
|
233
|
-
export function
|
|
240
|
+
export function forInAttrTag<Value extends object, const Return>(
|
|
234
241
|
input: {
|
|
235
|
-
in: Value;
|
|
242
|
+
in: Value | false | void | null;
|
|
236
243
|
},
|
|
237
|
-
|
|
244
|
+
content: (key: keyof Value, value: Value[keyof Value]) => Return,
|
|
238
245
|
): {
|
|
239
246
|
[Key in keyof Return]: Return[Key] extends
|
|
240
247
|
| readonly (infer Item)[]
|
|
@@ -243,7 +250,7 @@ declare global {
|
|
|
243
250
|
: never;
|
|
244
251
|
};
|
|
245
252
|
|
|
246
|
-
export function
|
|
253
|
+
export function forToAttrTag<
|
|
247
254
|
From extends void | number,
|
|
248
255
|
To extends number,
|
|
249
256
|
Step extends void | number,
|
|
@@ -254,7 +261,7 @@ declare global {
|
|
|
254
261
|
to: To;
|
|
255
262
|
step?: Step;
|
|
256
263
|
},
|
|
257
|
-
|
|
264
|
+
content: (index: number) => Return,
|
|
258
265
|
): {
|
|
259
266
|
[Key in keyof Return]: Return[Key] extends
|
|
260
267
|
| readonly (infer Item)[]
|
|
@@ -269,21 +276,21 @@ declare global {
|
|
|
269
276
|
: never;
|
|
270
277
|
};
|
|
271
278
|
|
|
272
|
-
export function forAttrTag<const Return>(
|
|
279
|
+
export function forAttrTag<const Return>(
|
|
273
280
|
input:
|
|
274
281
|
| {
|
|
275
|
-
of:
|
|
282
|
+
of: Iterable<unknown> | readonly unknown[] | false | void | null;
|
|
276
283
|
}
|
|
277
284
|
| {
|
|
278
|
-
in:
|
|
285
|
+
in: object;
|
|
279
286
|
}
|
|
280
287
|
| {
|
|
281
|
-
from?:
|
|
282
|
-
to:
|
|
283
|
-
step?:
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
|
|
288
|
+
from?: number;
|
|
289
|
+
to: number;
|
|
290
|
+
step?: number;
|
|
291
|
+
},
|
|
292
|
+
content: (...args: unknown[]) => Return,
|
|
293
|
+
): {
|
|
287
294
|
[Key in keyof Return]: Return[Key] extends
|
|
288
295
|
| readonly (infer Item)[]
|
|
289
296
|
| (infer Item extends Record<PropertyKey, any>)
|
|
@@ -313,7 +320,7 @@ declare global {
|
|
|
313
320
|
? [Name["renderBody"]] extends [AnyMarkoBody]
|
|
314
321
|
? BodyRenderer<Name["renderBody"]>
|
|
315
322
|
: BaseRenderer<
|
|
316
|
-
|
|
323
|
+
BodyContentInput<
|
|
317
324
|
BodyParameters<Exclude<Name["renderBody"], void>>
|
|
318
325
|
>
|
|
319
326
|
>
|
|
@@ -349,10 +356,10 @@ declare global {
|
|
|
349
356
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-constraint
|
|
350
357
|
(): () => <__marko_internal_input extends unknown>(
|
|
351
358
|
input: Marko.Directives &
|
|
352
|
-
|
|
359
|
+
BodyContentInput<BodyParameters<Body>> &
|
|
353
360
|
Relate<
|
|
354
361
|
__marko_internal_input,
|
|
355
|
-
Marko.Directives &
|
|
362
|
+
Marko.Directives & BodyContentInput<BodyParameters<Body>>
|
|
356
363
|
>,
|
|
357
364
|
) => ReturnAndScope<
|
|
358
365
|
Scopes<__marko_internal_input>,
|
|
@@ -389,7 +396,7 @@ declare abstract class MarkoReturn<Return> {
|
|
|
389
396
|
|
|
390
397
|
type AnyMarkoBody = Marko.Body<any, any>;
|
|
391
398
|
|
|
392
|
-
type
|
|
399
|
+
type BodyContentScope<BodyContent> = BodyContent extends (...params: any) => {
|
|
393
400
|
[Marko._.scope]: infer Scope;
|
|
394
401
|
}
|
|
395
402
|
? Scope
|
|
@@ -400,7 +407,7 @@ type ReturnAndScope<Scope, Return> = {
|
|
|
400
407
|
scope: Scope;
|
|
401
408
|
};
|
|
402
409
|
|
|
403
|
-
type
|
|
410
|
+
type BodyContentInput<Args extends readonly unknown[]> = Args extends {
|
|
404
411
|
length: infer Length;
|
|
405
412
|
}
|
|
406
413
|
? number extends Length
|
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.5",
|
|
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"
|
|
@@ -14,12 +14,11 @@
|
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"@babel/code-frame": "^7.26.2",
|
|
17
|
-
"@marko/compiler": "^5.
|
|
18
|
-
"@marko/translator-default": "^6.1.2",
|
|
17
|
+
"@marko/compiler": "^5.39.4",
|
|
19
18
|
"@types/babel__code-frame": "^7.0.6",
|
|
20
19
|
"@typescript/vfs": "^1.6.0",
|
|
21
|
-
"marko": "^5.
|
|
22
|
-
"mitata": "^1.0.
|
|
20
|
+
"marko": "^5.37.4",
|
|
21
|
+
"mitata": "^1.0.21",
|
|
23
22
|
"tsx": "^4.19.2"
|
|
24
23
|
},
|
|
25
24
|
"exports": {
|