@marko/language-tools 2.5.5 → 2.5.7
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/extractors/script/index.d.ts +2 -0
- package/dist/extractors/script/util/get-runtime-api.d.ts +9 -0
- package/dist/index.js +249 -87
- package/dist/index.mjs +245 -84
- package/dist/parser.d.ts +7 -1
- package/dist/util/project.d.ts +2 -0
- package/marko.internal.d.ts +53 -13
- package/package.json +3 -3
package/marko.internal.d.ts
CHANGED
|
@@ -40,6 +40,19 @@ declare global {
|
|
|
40
40
|
returns: Record<number, never>;
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
+
export const tags: Record<number, unknown>;
|
|
44
|
+
export const content: DefaultBodyContentKey;
|
|
45
|
+
|
|
46
|
+
export function contentFor<Name>(
|
|
47
|
+
tag: Name,
|
|
48
|
+
): Name extends { api: infer API }
|
|
49
|
+
? API extends "tags"
|
|
50
|
+
? "content"
|
|
51
|
+
: API extends "class"
|
|
52
|
+
? "renderBody"
|
|
53
|
+
: DefaultBodyContentKey
|
|
54
|
+
: DefaultBodyContentKey;
|
|
55
|
+
|
|
43
56
|
export const Template: new <Overrides = unknown>() => {
|
|
44
57
|
[K in Exclude<
|
|
45
58
|
keyof Marko.Template,
|
|
@@ -82,6 +95,12 @@ declare global {
|
|
|
82
95
|
> &
|
|
83
96
|
Record<any, never>;
|
|
84
97
|
|
|
98
|
+
export function assertTag<Index extends number, Tags, Tag>(
|
|
99
|
+
tags: Tags,
|
|
100
|
+
index: Index,
|
|
101
|
+
tag: Tag,
|
|
102
|
+
): asserts tags is Tags & Record<Index, Tag>;
|
|
103
|
+
|
|
85
104
|
export function assertRendered<Index extends number, Rendered, Result>(
|
|
86
105
|
rendered: Rendered,
|
|
87
106
|
index: Index,
|
|
@@ -134,16 +153,20 @@ declare global {
|
|
|
134
153
|
: (...args: any) => any; // If typescript ever actually supports partial application maybe we do this.
|
|
135
154
|
|
|
136
155
|
export function renderTemplate<Name extends Marko.Template>(
|
|
137
|
-
|
|
156
|
+
template: Name,
|
|
138
157
|
): TemplateRenderer<Name>;
|
|
139
158
|
export function renderNativeTag<Name extends string>(
|
|
140
159
|
tag: Name,
|
|
141
160
|
): NativeTagRenderer<Name>;
|
|
142
161
|
export const missingTag: DefaultRenderer;
|
|
143
|
-
export function
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
162
|
+
export function resolveTemplate<Template>(
|
|
163
|
+
imported: Promise<{ default: Template }>,
|
|
164
|
+
): Template;
|
|
165
|
+
export function fallbackTemplate<Tag, Template>(
|
|
166
|
+
tag: Tag,
|
|
167
|
+
fallback: Promise<{ default: Template }>,
|
|
168
|
+
): [0] extends [1 & Tag] ? Template : Tag;
|
|
169
|
+
export function input<Name>(tag: Name): Marko.Input<Name>;
|
|
147
170
|
export function renderDynamicTag<Name>(tag: Name): DynamicRenderer<Name>;
|
|
148
171
|
|
|
149
172
|
export function returnTag<
|
|
@@ -301,10 +324,18 @@ declare global {
|
|
|
301
324
|
export function mergeAttrTags<Attrs extends readonly any[]>(
|
|
302
325
|
...attrs: Attrs
|
|
303
326
|
): MergeAttrTags<Attrs>;
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
327
|
+
export function attrTags<T>(
|
|
328
|
+
type?: T,
|
|
329
|
+
): <AttrTag>(
|
|
330
|
+
attrTags: Relate<
|
|
331
|
+
AttrTag,
|
|
332
|
+
[0] extends [1 & T]
|
|
333
|
+
? Marko.AttrTag<unknown>
|
|
334
|
+
: T extends Marko.AttrTag<infer Type>
|
|
335
|
+
? Marko.AttrTag<Type>
|
|
336
|
+
: Marko.AttrTag<unknown>
|
|
337
|
+
>[],
|
|
338
|
+
) => AttrTag;
|
|
308
339
|
|
|
309
340
|
// TODO: this could be improved.
|
|
310
341
|
// currently falls back to DefaultRenderer too eagerly.
|
|
@@ -316,12 +347,16 @@ declare global {
|
|
|
316
347
|
? NativeTagRenderer<Name>
|
|
317
348
|
: [Name] extends [AnyMarkoBody]
|
|
318
349
|
? BodyRenderer<Name>
|
|
319
|
-
: [Name] extends [
|
|
320
|
-
|
|
321
|
-
|
|
350
|
+
: [Name] extends [
|
|
351
|
+
{
|
|
352
|
+
[BodyContentKey in DefaultBodyContentKey]?: AnyMarkoBody;
|
|
353
|
+
},
|
|
354
|
+
]
|
|
355
|
+
? [Name[BodyContentKey]] extends [AnyMarkoBody]
|
|
356
|
+
? BodyRenderer<Name[BodyContentKey]>
|
|
322
357
|
: BaseRenderer<
|
|
323
358
|
BodyContentInput<
|
|
324
|
-
BodyParameters<Exclude<Name[
|
|
359
|
+
BodyParameters<Exclude<Name[BodyContentKey], void>>
|
|
325
360
|
>
|
|
326
361
|
>
|
|
327
362
|
: DefaultRenderer;
|
|
@@ -535,4 +570,9 @@ type UnionToIntersection<T> = (T extends any ? (_: T) => any : never) extends (
|
|
|
535
570
|
? U
|
|
536
571
|
: never;
|
|
537
572
|
|
|
573
|
+
type DefaultBodyContentKey = keyof Exclude<
|
|
574
|
+
Marko.Renderable,
|
|
575
|
+
Marko.Template<any, any> | Marko.Body<any, any> | string
|
|
576
|
+
>;
|
|
577
|
+
|
|
538
578
|
export {};
|
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.7",
|
|
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,10 +14,10 @@
|
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"@babel/code-frame": "^7.26.2",
|
|
17
|
-
"@marko/compiler": "^5.39.
|
|
17
|
+
"@marko/compiler": "^5.39.6",
|
|
18
18
|
"@types/babel__code-frame": "^7.0.6",
|
|
19
19
|
"@typescript/vfs": "^1.6.0",
|
|
20
|
-
"marko": "^5.37.
|
|
20
|
+
"marko": "^5.37.7",
|
|
21
21
|
"mitata": "^1.0.21",
|
|
22
22
|
"tsx": "^4.19.2"
|
|
23
23
|
},
|