@marko/language-tools 2.5.38 → 2.5.40
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 +31 -15
- package/dist/index.mjs +31 -15
- package/marko.internal.d.ts +31 -35
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1743,6 +1743,9 @@ function detectAPIFromChild(parsed, child) {
|
|
|
1743
1743
|
}
|
|
1744
1744
|
function detectAPIFromTag(parsed, tag) {
|
|
1745
1745
|
var _a;
|
|
1746
|
+
if (tag.var) {
|
|
1747
|
+
return RuntimeAPI.tags;
|
|
1748
|
+
}
|
|
1746
1749
|
switch (tag.nameText) {
|
|
1747
1750
|
case "macro":
|
|
1748
1751
|
case "include-text":
|
|
@@ -1750,7 +1753,6 @@ function detectAPIFromTag(parsed, tag) {
|
|
|
1750
1753
|
case "init-components":
|
|
1751
1754
|
case "await-reorderer":
|
|
1752
1755
|
case "while":
|
|
1753
|
-
case "module-code":
|
|
1754
1756
|
return RuntimeAPI.class;
|
|
1755
1757
|
case "const":
|
|
1756
1758
|
case "debug":
|
|
@@ -1760,11 +1762,11 @@ function detectAPIFromTag(parsed, tag) {
|
|
|
1760
1762
|
case "lifecycle":
|
|
1761
1763
|
case "log":
|
|
1762
1764
|
case "return":
|
|
1765
|
+
case "html-script":
|
|
1766
|
+
case "html-style":
|
|
1767
|
+
case "try":
|
|
1763
1768
|
return RuntimeAPI.tags;
|
|
1764
1769
|
}
|
|
1765
|
-
if (tag.var) {
|
|
1766
|
-
return RuntimeAPI.tags;
|
|
1767
|
-
}
|
|
1768
1770
|
if (tag.attrs) {
|
|
1769
1771
|
for (const attr of tag.attrs) {
|
|
1770
1772
|
if (attr.type !== 15 /* AttrSpread */) {
|
|
@@ -2108,20 +2110,32 @@ var ScriptExtractor = class {
|
|
|
2108
2110
|
}
|
|
2109
2111
|
if (this.#api !== RuntimeAPI.tags) {
|
|
2110
2112
|
if (isExternalComponentFile) {
|
|
2113
|
+
const componentImport = `"${stripExt((0, import_relative_import_path.relativeImportPath)(this.#filename, componentFileName))}"`;
|
|
2111
2114
|
if (this.#scriptLang === "ts" /* ts */) {
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2115
|
+
if (typeArgsStr) {
|
|
2116
|
+
this.#extractor.write(
|
|
2117
|
+
`import type Component from ${componentImport};
|
|
2118
|
+
export type { Component };
|
|
2116
2119
|
`
|
|
2117
|
-
|
|
2120
|
+
);
|
|
2121
|
+
} else {
|
|
2122
|
+
this.#extractor.write(
|
|
2123
|
+
`export interface Component extends ${varShared("ResolveComponent")}<typeof import(${componentImport})> {}
|
|
2124
|
+
`
|
|
2125
|
+
);
|
|
2126
|
+
}
|
|
2118
2127
|
} else {
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
)}")>} Component */
|
|
2128
|
+
if (typeArgsStr) {
|
|
2129
|
+
this.#extractor.write(
|
|
2130
|
+
`/** @import Component from ${componentImport} */
|
|
2123
2131
|
`
|
|
2124
|
-
|
|
2132
|
+
);
|
|
2133
|
+
} else {
|
|
2134
|
+
this.#extractor.write(
|
|
2135
|
+
`/** @typedef {${varShared("ResolveComponent")}<typeof import(${componentImport})>} Component */
|
|
2136
|
+
`
|
|
2137
|
+
);
|
|
2138
|
+
}
|
|
2125
2139
|
}
|
|
2126
2140
|
} else {
|
|
2127
2141
|
const body2 = componentClassBody || " {}";
|
|
@@ -2856,7 +2870,9 @@ ${isMutatedVar(tag.parent, valueLiteral) ? `${varLocal("return")}.mutate.` : ""}
|
|
|
2856
2870
|
const isScript = isTextOnlyScript(tag);
|
|
2857
2871
|
let hasBodyContent = false;
|
|
2858
2872
|
if (isScript) {
|
|
2859
|
-
this.#extractor.write(
|
|
2873
|
+
this.#extractor.write(
|
|
2874
|
+
`async ${this.#api === RuntimeAPI.tags ? "value" : `[${varShared("never")}]`}(){`
|
|
2875
|
+
);
|
|
2860
2876
|
this.#copyWithMutationsReplaced({
|
|
2861
2877
|
start: tag.body[0].start,
|
|
2862
2878
|
end: tag.body[tag.body.length - 1].end
|
package/dist/index.mjs
CHANGED
|
@@ -1703,6 +1703,9 @@ function detectAPIFromChild(parsed, child) {
|
|
|
1703
1703
|
}
|
|
1704
1704
|
function detectAPIFromTag(parsed, tag) {
|
|
1705
1705
|
var _a;
|
|
1706
|
+
if (tag.var) {
|
|
1707
|
+
return RuntimeAPI.tags;
|
|
1708
|
+
}
|
|
1706
1709
|
switch (tag.nameText) {
|
|
1707
1710
|
case "macro":
|
|
1708
1711
|
case "include-text":
|
|
@@ -1710,7 +1713,6 @@ function detectAPIFromTag(parsed, tag) {
|
|
|
1710
1713
|
case "init-components":
|
|
1711
1714
|
case "await-reorderer":
|
|
1712
1715
|
case "while":
|
|
1713
|
-
case "module-code":
|
|
1714
1716
|
return RuntimeAPI.class;
|
|
1715
1717
|
case "const":
|
|
1716
1718
|
case "debug":
|
|
@@ -1720,11 +1722,11 @@ function detectAPIFromTag(parsed, tag) {
|
|
|
1720
1722
|
case "lifecycle":
|
|
1721
1723
|
case "log":
|
|
1722
1724
|
case "return":
|
|
1725
|
+
case "html-script":
|
|
1726
|
+
case "html-style":
|
|
1727
|
+
case "try":
|
|
1723
1728
|
return RuntimeAPI.tags;
|
|
1724
1729
|
}
|
|
1725
|
-
if (tag.var) {
|
|
1726
|
-
return RuntimeAPI.tags;
|
|
1727
|
-
}
|
|
1728
1730
|
if (tag.attrs) {
|
|
1729
1731
|
for (const attr of tag.attrs) {
|
|
1730
1732
|
if (attr.type !== 15 /* AttrSpread */) {
|
|
@@ -2071,20 +2073,32 @@ var ScriptExtractor = class {
|
|
|
2071
2073
|
}
|
|
2072
2074
|
if (this.#api !== RuntimeAPI.tags) {
|
|
2073
2075
|
if (isExternalComponentFile) {
|
|
2076
|
+
const componentImport = `"${stripExt(relativeImportPath(this.#filename, componentFileName))}"`;
|
|
2074
2077
|
if (this.#scriptLang === "ts" /* ts */) {
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2078
|
+
if (typeArgsStr) {
|
|
2079
|
+
this.#extractor.write(
|
|
2080
|
+
`import type Component from ${componentImport};
|
|
2081
|
+
export type { Component };
|
|
2079
2082
|
`
|
|
2080
|
-
|
|
2083
|
+
);
|
|
2084
|
+
} else {
|
|
2085
|
+
this.#extractor.write(
|
|
2086
|
+
`export interface Component extends ${varShared("ResolveComponent")}<typeof import(${componentImport})> {}
|
|
2087
|
+
`
|
|
2088
|
+
);
|
|
2089
|
+
}
|
|
2081
2090
|
} else {
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
)}")>} Component */
|
|
2091
|
+
if (typeArgsStr) {
|
|
2092
|
+
this.#extractor.write(
|
|
2093
|
+
`/** @import Component from ${componentImport} */
|
|
2086
2094
|
`
|
|
2087
|
-
|
|
2095
|
+
);
|
|
2096
|
+
} else {
|
|
2097
|
+
this.#extractor.write(
|
|
2098
|
+
`/** @typedef {${varShared("ResolveComponent")}<typeof import(${componentImport})>} Component */
|
|
2099
|
+
`
|
|
2100
|
+
);
|
|
2101
|
+
}
|
|
2088
2102
|
}
|
|
2089
2103
|
} else {
|
|
2090
2104
|
const body2 = componentClassBody || " {}";
|
|
@@ -2819,7 +2833,9 @@ ${isMutatedVar(tag.parent, valueLiteral) ? `${varLocal("return")}.mutate.` : ""}
|
|
|
2819
2833
|
const isScript = isTextOnlyScript(tag);
|
|
2820
2834
|
let hasBodyContent = false;
|
|
2821
2835
|
if (isScript) {
|
|
2822
|
-
this.#extractor.write(
|
|
2836
|
+
this.#extractor.write(
|
|
2837
|
+
`async ${this.#api === RuntimeAPI.tags ? "value" : `[${varShared("never")}]`}(){`
|
|
2838
|
+
);
|
|
2823
2839
|
this.#copyWithMutationsReplaced({
|
|
2824
2840
|
start: tag.body[0].start,
|
|
2825
2841
|
end: tag.body[tag.body.length - 1].end
|
package/marko.internal.d.ts
CHANGED
|
@@ -152,7 +152,7 @@ declare global {
|
|
|
152
152
|
: Handler
|
|
153
153
|
: (...args: any) => any; // If typescript ever actually supports partial application maybe we do this.
|
|
154
154
|
|
|
155
|
-
export function renderTemplate<Name
|
|
155
|
+
export function renderTemplate<Name>(
|
|
156
156
|
template: Name,
|
|
157
157
|
): TemplateRenderer<Name>;
|
|
158
158
|
export function renderNativeTag<Name extends string>(
|
|
@@ -177,19 +177,19 @@ declare global {
|
|
|
177
177
|
>(input: Input): Input;
|
|
178
178
|
|
|
179
179
|
export function forOfTag<
|
|
180
|
-
Value
|
|
180
|
+
Value,
|
|
181
181
|
Item extends [0] extends [1 & Value]
|
|
182
182
|
? any
|
|
183
|
-
: Value extends
|
|
183
|
+
: Value extends Iterable<infer Item>
|
|
184
184
|
? Item
|
|
185
185
|
: never,
|
|
186
186
|
BodyContent extends Marko.Body<
|
|
187
|
-
[item: Item, index: number, all: Value],
|
|
187
|
+
[item: Item, index: number, all: Exclude<Value, false | void | null>],
|
|
188
188
|
void
|
|
189
189
|
>,
|
|
190
190
|
>(
|
|
191
191
|
input: {
|
|
192
|
-
of: Value | false | void | null;
|
|
192
|
+
of: Value & (Iterable<unknown> | false | void | null);
|
|
193
193
|
by?: ((item: Item, index: number) => string) | string;
|
|
194
194
|
},
|
|
195
195
|
content: BodyContent,
|
|
@@ -210,14 +210,14 @@ declare global {
|
|
|
210
210
|
): ReturnAndScope<BodyContentScope<BodyContent>, void>;
|
|
211
211
|
|
|
212
212
|
export function forToTag<
|
|
213
|
-
From extends void | number,
|
|
214
213
|
To extends number,
|
|
214
|
+
From extends void | number,
|
|
215
215
|
Step extends void | number,
|
|
216
216
|
BodyContent extends Marko.Body<[index: number], void>,
|
|
217
217
|
>(
|
|
218
218
|
input: {
|
|
219
|
-
from?: From;
|
|
220
219
|
to: To;
|
|
220
|
+
from?: From;
|
|
221
221
|
step?: Step;
|
|
222
222
|
by?: (index: number) => string;
|
|
223
223
|
},
|
|
@@ -225,14 +225,14 @@ declare global {
|
|
|
225
225
|
): ReturnAndScope<BodyContentScope<BodyContent>, void>;
|
|
226
226
|
|
|
227
227
|
export function forUntilTag<
|
|
228
|
-
From extends void | number,
|
|
229
228
|
Until extends number,
|
|
229
|
+
From extends void | number,
|
|
230
230
|
Step extends void | number,
|
|
231
231
|
BodyContent extends Marko.Body<[index: number], void>,
|
|
232
232
|
>(
|
|
233
233
|
input: {
|
|
234
|
-
from?: From;
|
|
235
234
|
until: Until;
|
|
235
|
+
from?: From;
|
|
236
236
|
step?: Step;
|
|
237
237
|
by?: (index: number) => string;
|
|
238
238
|
},
|
|
@@ -242,27 +242,27 @@ declare global {
|
|
|
242
242
|
export function forTag<BodyContent extends AnyMarkoBody>(
|
|
243
243
|
input: (
|
|
244
244
|
| {
|
|
245
|
-
from?: number;
|
|
246
245
|
to: number;
|
|
246
|
+
from?: number;
|
|
247
247
|
step?: number;
|
|
248
248
|
}
|
|
249
249
|
| {
|
|
250
|
-
from?: number;
|
|
251
250
|
until: number;
|
|
251
|
+
from?: number;
|
|
252
252
|
step?: number;
|
|
253
253
|
}
|
|
254
254
|
| {
|
|
255
|
-
in:
|
|
255
|
+
in: any;
|
|
256
256
|
}
|
|
257
257
|
| {
|
|
258
|
-
of:
|
|
258
|
+
of: any;
|
|
259
259
|
}
|
|
260
|
-
) & { by?: (...args: unknown[]) => string },
|
|
260
|
+
) & { by?: string | ((...args: unknown[]) => string) },
|
|
261
261
|
content: BodyContent,
|
|
262
262
|
): ReturnAndScope<BodyContentScope<BodyContent>, void>;
|
|
263
263
|
|
|
264
264
|
export function forOfAttrTag<
|
|
265
|
-
Value
|
|
265
|
+
Value,
|
|
266
266
|
Item extends [0] extends [1 & Value]
|
|
267
267
|
? any
|
|
268
268
|
: Value extends readonly (infer Item)[] | Iterable<infer Item>
|
|
@@ -271,14 +271,18 @@ declare global {
|
|
|
271
271
|
const Return,
|
|
272
272
|
>(
|
|
273
273
|
input: {
|
|
274
|
-
of: Value | false | void | null;
|
|
274
|
+
of: Value & (Iterable<unknown> | false | void | null);
|
|
275
275
|
},
|
|
276
|
-
content: (
|
|
276
|
+
content: (
|
|
277
|
+
value: Item,
|
|
278
|
+
index: number,
|
|
279
|
+
all: Exclude<Value, false | void | null>,
|
|
280
|
+
) => Return,
|
|
277
281
|
): {
|
|
278
282
|
[Key in keyof Return]: Return[Key] extends
|
|
279
283
|
| readonly (infer Item)[]
|
|
280
284
|
| (infer Item extends Record<PropertyKey, any>)
|
|
281
|
-
? AttrTagByListSize<Value, Item>
|
|
285
|
+
? AttrTagByListSize<Exclude<Value, false | void | null>, Item>
|
|
282
286
|
: never;
|
|
283
287
|
};
|
|
284
288
|
|
|
@@ -296,14 +300,14 @@ declare global {
|
|
|
296
300
|
};
|
|
297
301
|
|
|
298
302
|
export function forToAttrTag<
|
|
299
|
-
From extends void | number,
|
|
300
303
|
To extends number,
|
|
304
|
+
From extends void | number,
|
|
301
305
|
Step extends void | number,
|
|
302
306
|
const Return,
|
|
303
307
|
>(
|
|
304
308
|
input: {
|
|
305
|
-
from?: From;
|
|
306
309
|
to: To;
|
|
310
|
+
from?: From;
|
|
307
311
|
step?: Step;
|
|
308
312
|
},
|
|
309
313
|
content: (index: number) => Return,
|
|
@@ -322,14 +326,14 @@ declare global {
|
|
|
322
326
|
};
|
|
323
327
|
|
|
324
328
|
export function forUntilAttrTag<
|
|
325
|
-
From extends void | number,
|
|
326
329
|
Until extends number,
|
|
330
|
+
From extends void | number,
|
|
327
331
|
Step extends void | number,
|
|
328
332
|
const Return,
|
|
329
333
|
>(
|
|
330
334
|
input: {
|
|
331
|
-
from?: From;
|
|
332
335
|
until: Until;
|
|
336
|
+
from?: From;
|
|
333
337
|
step?: Step;
|
|
334
338
|
},
|
|
335
339
|
content: (index: number) => Return,
|
|
@@ -350,19 +354,19 @@ declare global {
|
|
|
350
354
|
export function forAttrTag<const Return>(
|
|
351
355
|
input:
|
|
352
356
|
| {
|
|
353
|
-
of: Iterable<unknown> |
|
|
357
|
+
of: Iterable<unknown> | false | void | null;
|
|
354
358
|
}
|
|
355
359
|
| {
|
|
356
|
-
in: object;
|
|
360
|
+
in: object | false | void | null;
|
|
357
361
|
}
|
|
358
362
|
| {
|
|
359
|
-
from?: number;
|
|
360
363
|
to: number;
|
|
364
|
+
from?: number;
|
|
361
365
|
step?: number;
|
|
362
366
|
}
|
|
363
367
|
| {
|
|
364
|
-
from?: number;
|
|
365
368
|
until: number;
|
|
369
|
+
from?: number;
|
|
366
370
|
step?: number;
|
|
367
371
|
},
|
|
368
372
|
content: (...args: unknown[]) => Return,
|
|
@@ -420,7 +424,7 @@ declare global {
|
|
|
420
424
|
? Renderer
|
|
421
425
|
: Template extends Marko.Template<infer Input, infer Return>
|
|
422
426
|
? BaseRenderer<Input, Return>
|
|
423
|
-
:
|
|
427
|
+
: DefaultRenderer;
|
|
424
428
|
|
|
425
429
|
export interface NativeTagRenderer<Name extends string> {
|
|
426
430
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-constraint
|
|
@@ -537,14 +541,6 @@ type MergeScopes<Scopes> = {
|
|
|
537
541
|
: never;
|
|
538
542
|
};
|
|
539
543
|
|
|
540
|
-
type MergeOptionalScopes<Scopes> = {
|
|
541
|
-
[K in Scopes extends Scopes ? keyof Scopes : never]: Scopes extends Scopes
|
|
542
|
-
? K extends keyof Scopes
|
|
543
|
-
? Scopes[K]
|
|
544
|
-
: undefined
|
|
545
|
-
: never;
|
|
546
|
-
};
|
|
547
|
-
|
|
548
544
|
type MergeAttrTags<Attrs extends readonly any[]> = Attrs extends readonly [
|
|
549
545
|
infer A,
|
|
550
546
|
infer B,
|
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.40",
|
|
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"
|