@marko/ts-plugin 0.0.0 → 3.1.0
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/README.md +29 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +673 -0
- package/dist/index.js.map +6 -0
- package/dist/lib.decorators.d.ts +382 -0
- package/dist/lib.decorators.legacy.d.ts +20 -0
- package/dist/lib.dom.asynciterable.d.ts +18 -0
- package/dist/lib.dom.d.ts +45125 -0
- package/dist/lib.dom.iterable.d.ts +18 -0
- package/dist/lib.es2015.collection.d.ts +150 -0
- package/dist/lib.es2015.core.d.ts +595 -0
- package/dist/lib.es2015.d.ts +26 -0
- package/dist/lib.es2015.generator.d.ts +75 -0
- package/dist/lib.es2015.iterable.d.ts +603 -0
- package/dist/lib.es2015.promise.d.ts +79 -0
- package/dist/lib.es2015.proxy.d.ts +126 -0
- package/dist/lib.es2015.reflect.d.ts +142 -0
- package/dist/lib.es2015.symbol.d.ts +44 -0
- package/dist/lib.es2015.symbol.wellknown.d.ts +324 -0
- package/dist/lib.es2016.array.include.d.ts +114 -0
- package/dist/lib.es2016.d.ts +19 -0
- package/dist/lib.es2016.full.d.ts +21 -0
- package/dist/lib.es2016.intl.d.ts +29 -0
- package/dist/lib.es2017.arraybuffer.d.ts +19 -0
- package/dist/lib.es2017.d.ts +24 -0
- package/dist/lib.es2017.date.d.ts +29 -0
- package/dist/lib.es2017.full.d.ts +21 -0
- package/dist/lib.es2017.intl.d.ts +42 -0
- package/dist/lib.es2017.object.d.ts +47 -0
- package/dist/lib.es2017.sharedmemory.d.ts +133 -0
- package/dist/lib.es2017.string.d.ts +43 -0
- package/dist/lib.es2017.typedarrays.d.ts +51 -0
- package/dist/lib.es2018.asyncgenerator.d.ts +75 -0
- package/dist/lib.es2018.asynciterable.d.ts +51 -0
- package/dist/lib.es2018.d.ts +22 -0
- package/dist/lib.es2018.full.d.ts +22 -0
- package/dist/lib.es2018.intl.d.ts +81 -0
- package/dist/lib.es2018.promise.d.ts +28 -0
- package/dist/lib.es2018.regexp.d.ts +35 -0
- package/dist/lib.es2019.array.d.ts +77 -0
- package/dist/lib.es2019.d.ts +22 -0
- package/dist/lib.es2019.full.d.ts +22 -0
- package/dist/lib.es2019.intl.d.ts +21 -0
- package/dist/lib.es2019.object.d.ts +31 -0
- package/dist/lib.es2019.string.d.ts +35 -0
- package/dist/lib.es2019.symbol.d.ts +22 -0
- package/dist/lib.es2020.bigint.d.ts +763 -0
- package/dist/lib.es2020.d.ts +25 -0
- package/dist/lib.es2020.date.d.ts +40 -0
- package/dist/lib.es2020.full.d.ts +22 -0
- package/dist/lib.es2020.intl.d.ts +472 -0
- package/dist/lib.es2020.number.d.ts +26 -0
- package/dist/lib.es2020.promise.d.ts +45 -0
- package/dist/lib.es2020.sharedmemory.d.ts +97 -0
- package/dist/lib.es2020.string.d.ts +42 -0
- package/dist/lib.es2020.symbol.wellknown.d.ts +39 -0
- package/dist/lib.es2021.d.ts +21 -0
- package/dist/lib.es2021.full.d.ts +22 -0
- package/dist/lib.es2021.intl.d.ts +164 -0
- package/dist/lib.es2021.promise.d.ts +46 -0
- package/dist/lib.es2021.string.d.ts +31 -0
- package/dist/lib.es2021.weakref.d.ts +76 -0
- package/dist/lib.es2022.array.d.ts +119 -0
- package/dist/lib.es2022.d.ts +23 -0
- package/dist/lib.es2022.error.d.ts +73 -0
- package/dist/lib.es2022.full.d.ts +22 -0
- package/dist/lib.es2022.intl.d.ts +143 -0
- package/dist/lib.es2022.object.d.ts +24 -0
- package/dist/lib.es2022.regexp.d.ts +37 -0
- package/dist/lib.es2022.string.d.ts +23 -0
- package/dist/lib.es2023.array.d.ts +922 -0
- package/dist/lib.es2023.collection.d.ts +19 -0
- package/dist/lib.es2023.d.ts +20 -0
- package/dist/lib.es2023.full.d.ts +22 -0
- package/dist/lib.es2023.intl.d.ts +62 -0
- package/dist/lib.es2024.arraybuffer.d.ts +63 -0
- package/dist/lib.es2024.collection.d.ts +27 -0
- package/dist/lib.es2024.d.ts +24 -0
- package/dist/lib.es2024.full.d.ts +22 -0
- package/dist/lib.es2024.object.d.ts +27 -0
- package/dist/lib.es2024.promise.d.ts +33 -0
- package/dist/lib.es2024.regexp.d.ts +23 -0
- package/dist/lib.es2024.sharedmemory.d.ts +66 -0
- package/dist/lib.es2024.string.d.ts +27 -0
- package/dist/lib.es2025.collection.d.ts +94 -0
- package/dist/lib.es2025.d.ts +23 -0
- package/dist/lib.es2025.float16.d.ts +443 -0
- package/dist/lib.es2025.full.d.ts +22 -0
- package/dist/lib.es2025.intl.d.ts +200 -0
- package/dist/lib.es2025.iterator.d.ts +146 -0
- package/dist/lib.es2025.promise.d.ts +32 -0
- package/dist/lib.es2025.regexp.d.ts +30 -0
- package/dist/lib.es5.d.ts +4599 -0
- package/dist/lib.es6.d.ts +21 -0
- package/dist/lib.esnext.array.d.ts +33 -0
- package/dist/lib.esnext.collection.d.ts +47 -0
- package/dist/lib.esnext.d.ts +27 -0
- package/dist/lib.esnext.date.d.ts +21 -0
- package/dist/lib.esnext.decorators.d.ts +26 -0
- package/dist/lib.esnext.disposable.d.ts +191 -0
- package/dist/lib.esnext.error.d.ts +22 -0
- package/dist/lib.esnext.full.d.ts +22 -0
- package/dist/lib.esnext.intl.d.ts +107 -0
- package/dist/lib.esnext.sharedmemory.d.ts +23 -0
- package/dist/lib.esnext.temporal.d.ts +485 -0
- package/dist/lib.esnext.typedarrays.d.ts +90 -0
- package/dist/lib.scripthost.d.ts +320 -0
- package/dist/lib.webworker.asynciterable.d.ts +18 -0
- package/dist/lib.webworker.d.ts +15606 -0
- package/dist/lib.webworker.importscripts.d.ts +21 -0
- package/dist/lib.webworker.iterable.d.ts +18 -0
- package/dist/marko.internal.d.ts +730 -0
- package/dist/marko.runtime.d.ts +410 -0
- package/package.json +35 -1
|
@@ -0,0 +1,730 @@
|
|
|
1
|
+
// This is a typescript file which defines utilities used in the output of the typescript extractor.
|
|
2
|
+
declare global {
|
|
3
|
+
namespace Marko {
|
|
4
|
+
export interface Directives {}
|
|
5
|
+
|
|
6
|
+
// Extend the Body type to keep track of what is yielded (used for scope hoisted types).
|
|
7
|
+
export interface Body<
|
|
8
|
+
in Params extends readonly any[] = [],
|
|
9
|
+
out Return = void,
|
|
10
|
+
> {
|
|
11
|
+
(...params: Params): MarkoReturn<Return>;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Do not use or you will be fired.
|
|
16
|
+
*/
|
|
17
|
+
namespace _ {
|
|
18
|
+
export const voidReturn = new (class Void {
|
|
19
|
+
readonly [Marko._.scope] = Marko._.never;
|
|
20
|
+
declare return: void;
|
|
21
|
+
})();
|
|
22
|
+
export const scope: unique symbol;
|
|
23
|
+
export const never: never;
|
|
24
|
+
export const any: any;
|
|
25
|
+
|
|
26
|
+
export function getGlobal<Override>(
|
|
27
|
+
override: Override,
|
|
28
|
+
): [0] extends [1 & Override] ? Marko.Global : Override;
|
|
29
|
+
|
|
30
|
+
export function returned<T>(
|
|
31
|
+
rendered: () => T,
|
|
32
|
+
): T extends { return: { value: infer Returned } } ? Returned : never;
|
|
33
|
+
|
|
34
|
+
export function hoist<T>(
|
|
35
|
+
value: () => T,
|
|
36
|
+
): T extends () => infer R ? T & Iterable<R> : never;
|
|
37
|
+
// TODO: hoist should really be the below implementation which accounts for hoisting from unknown
|
|
38
|
+
// sections causing the getter to return undefined. Right now the type says it always has a value.
|
|
39
|
+
// export function hoist<T, U = T>(
|
|
40
|
+
// value: () => T,
|
|
41
|
+
// ): T extends () => infer R
|
|
42
|
+
// ? (T | (U extends undefined ? () => undefined : never)) & Iterable<R>
|
|
43
|
+
// : never;
|
|
44
|
+
|
|
45
|
+
export function attrTagNames<Tag>(
|
|
46
|
+
tag: Tag,
|
|
47
|
+
fn: (input: AttrTagNames<InputFor<Tag>>) => void,
|
|
48
|
+
): void;
|
|
49
|
+
export function nestedAttrTagNames<Input>(
|
|
50
|
+
input: Input,
|
|
51
|
+
fn: (input: AttrTagNames<Input>) => void,
|
|
52
|
+
): void;
|
|
53
|
+
|
|
54
|
+
export const content: DefaultBodyContentKey;
|
|
55
|
+
|
|
56
|
+
export function el<Name extends string>(
|
|
57
|
+
name: Name,
|
|
58
|
+
): Marko.NativeTags[Name]["return"]["value"];
|
|
59
|
+
|
|
60
|
+
export function contentFor<Name>(tag: Name): ContentFor<Name>;
|
|
61
|
+
|
|
62
|
+
export const Template: new <Overrides = unknown>() => {
|
|
63
|
+
[K in Exclude<
|
|
64
|
+
keyof Marko.Template,
|
|
65
|
+
keyof Overrides
|
|
66
|
+
>]: Marko.Template[K];
|
|
67
|
+
} & Overrides;
|
|
68
|
+
|
|
69
|
+
export function noop(value: any): void;
|
|
70
|
+
|
|
71
|
+
export function tuple<T extends readonly any[]>(...v: T): T;
|
|
72
|
+
|
|
73
|
+
export function interpolated(
|
|
74
|
+
strs: TemplateStringsArray,
|
|
75
|
+
...exprs: (string | number | void | null | false)[]
|
|
76
|
+
): string;
|
|
77
|
+
|
|
78
|
+
export function state<Component>(
|
|
79
|
+
component: Component,
|
|
80
|
+
): Component extends {
|
|
81
|
+
state: infer State extends object;
|
|
82
|
+
}
|
|
83
|
+
? State
|
|
84
|
+
: never;
|
|
85
|
+
|
|
86
|
+
export type ReturnWithScope<Input, Return> = ReturnAndScope<
|
|
87
|
+
Scopes<Input>,
|
|
88
|
+
Return
|
|
89
|
+
>;
|
|
90
|
+
|
|
91
|
+
export function instance<Constructor>(
|
|
92
|
+
constructor: Constructor,
|
|
93
|
+
): Constructor extends abstract new (...args: any) => infer Instance
|
|
94
|
+
? Instance
|
|
95
|
+
: never;
|
|
96
|
+
|
|
97
|
+
export function readScopes<Rendered>(rendered: Rendered): MergeScopes<
|
|
98
|
+
{
|
|
99
|
+
[K in keyof Rendered]: Rendered[K] extends infer Value
|
|
100
|
+
? undefined extends Value
|
|
101
|
+
? Value extends { scope: infer Scope }
|
|
102
|
+
? [0] extends [1 & Scope]
|
|
103
|
+
? never
|
|
104
|
+
: Partial<Scope>
|
|
105
|
+
: never
|
|
106
|
+
: Value extends { scope: infer Scope }
|
|
107
|
+
? [0] extends [1 & Scope]
|
|
108
|
+
? never
|
|
109
|
+
: Scope
|
|
110
|
+
: never
|
|
111
|
+
: never;
|
|
112
|
+
}[keyof Rendered]
|
|
113
|
+
>;
|
|
114
|
+
|
|
115
|
+
export function readScope<Value>(
|
|
116
|
+
value: Value,
|
|
117
|
+
): MergeScopes<
|
|
118
|
+
undefined extends Value
|
|
119
|
+
? Value extends { scope: infer Scope }
|
|
120
|
+
? [0] extends [1 & Scope]
|
|
121
|
+
? never
|
|
122
|
+
: Partial<Scope>
|
|
123
|
+
: never
|
|
124
|
+
: Value extends { scope: infer Scope }
|
|
125
|
+
? [0] extends [1 & Scope]
|
|
126
|
+
? never
|
|
127
|
+
: Scope
|
|
128
|
+
: never
|
|
129
|
+
>;
|
|
130
|
+
|
|
131
|
+
export function change<const Item extends readonly unknown[]>(
|
|
132
|
+
...item: Item
|
|
133
|
+
): UnionToIntersection<
|
|
134
|
+
Item extends
|
|
135
|
+
| readonly [infer LocalName extends string, infer Data]
|
|
136
|
+
| readonly [
|
|
137
|
+
infer LocalName extends string,
|
|
138
|
+
infer SourceName,
|
|
139
|
+
infer Data,
|
|
140
|
+
]
|
|
141
|
+
? Data extends {
|
|
142
|
+
[K in `${SourceName extends string
|
|
143
|
+
? SourceName
|
|
144
|
+
: LocalName}Change`]: (value: infer V, ...args: any[]) => any;
|
|
145
|
+
}
|
|
146
|
+
? { [K in LocalName]: V }
|
|
147
|
+
: { readonly [K in LocalName]: unknown }
|
|
148
|
+
: never
|
|
149
|
+
>;
|
|
150
|
+
|
|
151
|
+
export function bind<
|
|
152
|
+
Owner extends Marko.Component,
|
|
153
|
+
OwnerHandlers extends ComponentEventHandlers<Owner>,
|
|
154
|
+
Handler extends
|
|
155
|
+
| keyof OwnerHandlers
|
|
156
|
+
| ((...args: any) => any)
|
|
157
|
+
| false
|
|
158
|
+
| void,
|
|
159
|
+
Args extends readonly any[],
|
|
160
|
+
>(
|
|
161
|
+
owner: Owner,
|
|
162
|
+
handler: Handler,
|
|
163
|
+
...args: Args
|
|
164
|
+
): Args extends readonly []
|
|
165
|
+
? Handler extends keyof OwnerHandlers
|
|
166
|
+
? OwnerHandlers[Handler]
|
|
167
|
+
: Handler
|
|
168
|
+
: (...args: any) => any; // If typescript ever actually supports partial application maybe we do this.
|
|
169
|
+
|
|
170
|
+
export function renderTemplate<Name>(
|
|
171
|
+
template: Name,
|
|
172
|
+
): TemplateRenderer<Name>;
|
|
173
|
+
export function renderNativeTag<Name extends string>(
|
|
174
|
+
tag: Name,
|
|
175
|
+
): NativeTagRenderer<Name>;
|
|
176
|
+
export const missingTag: DefaultRenderer;
|
|
177
|
+
export function resolveTemplate<Template>(
|
|
178
|
+
imported: Promise<{ default: Template }>,
|
|
179
|
+
): Template;
|
|
180
|
+
export function fallbackTemplate<Tag, Template>(
|
|
181
|
+
tag: Tag,
|
|
182
|
+
fallback: Promise<{ default: Template }>,
|
|
183
|
+
): [0] extends [1 & Tag] ? Template : Tag;
|
|
184
|
+
export function input<Name>(tag: Name): InputFor<Name>;
|
|
185
|
+
export function inputForAttr<
|
|
186
|
+
Name,
|
|
187
|
+
Path extends readonly [string, ...string[]],
|
|
188
|
+
>(tag: Name, ...path: Path): AttrTagValue<InputFor<Name>, Path>;
|
|
189
|
+
export function renderDynamicTag<Name>(tag: Name): DynamicRenderer<Name>;
|
|
190
|
+
|
|
191
|
+
export function returnTag<
|
|
192
|
+
Input extends {
|
|
193
|
+
value: unknown;
|
|
194
|
+
valueChange?: ((value: any) => void) | false | null;
|
|
195
|
+
},
|
|
196
|
+
>(input: Input): Input;
|
|
197
|
+
|
|
198
|
+
export function forOfTag<
|
|
199
|
+
Value,
|
|
200
|
+
Item extends [0] extends [1 & Value]
|
|
201
|
+
? any
|
|
202
|
+
: Value extends Iterable<infer Item>
|
|
203
|
+
? Item
|
|
204
|
+
: never,
|
|
205
|
+
BodyContent extends Marko.Body<
|
|
206
|
+
[item: Item, index: number, all: Exclude<Value, false | void | null>],
|
|
207
|
+
void
|
|
208
|
+
>,
|
|
209
|
+
>(
|
|
210
|
+
input: {
|
|
211
|
+
of: Value & (Iterable<unknown> | false | void | null);
|
|
212
|
+
by?: ((item: Item, index: number) => string) | string;
|
|
213
|
+
},
|
|
214
|
+
content: BodyContent,
|
|
215
|
+
): ReturnAndScope<BodyContentScope<BodyContent>, void>;
|
|
216
|
+
|
|
217
|
+
export function forInTag<
|
|
218
|
+
Value,
|
|
219
|
+
BodyContent extends Marko.Body<
|
|
220
|
+
[key: keyof Value, value: Value[keyof Value]],
|
|
221
|
+
void
|
|
222
|
+
>,
|
|
223
|
+
>(
|
|
224
|
+
input: {
|
|
225
|
+
in: Value | false | void | null;
|
|
226
|
+
by?: (value: Value[keyof Value], key: keyof Value) => string;
|
|
227
|
+
},
|
|
228
|
+
content: BodyContent,
|
|
229
|
+
): ReturnAndScope<BodyContentScope<BodyContent>, void>;
|
|
230
|
+
|
|
231
|
+
export function forToTag<
|
|
232
|
+
To extends number,
|
|
233
|
+
From extends void | number,
|
|
234
|
+
Step extends void | number,
|
|
235
|
+
BodyContent extends Marko.Body<[index: number], void>,
|
|
236
|
+
>(
|
|
237
|
+
input: {
|
|
238
|
+
to: To;
|
|
239
|
+
from?: From;
|
|
240
|
+
step?: Step;
|
|
241
|
+
by?: (index: number) => string;
|
|
242
|
+
},
|
|
243
|
+
content: BodyContent,
|
|
244
|
+
): ReturnAndScope<BodyContentScope<BodyContent>, void>;
|
|
245
|
+
|
|
246
|
+
export function forUntilTag<
|
|
247
|
+
Until extends number,
|
|
248
|
+
From extends void | number,
|
|
249
|
+
Step extends void | number,
|
|
250
|
+
BodyContent extends Marko.Body<[index: number], void>,
|
|
251
|
+
>(
|
|
252
|
+
input: {
|
|
253
|
+
until: Until;
|
|
254
|
+
from?: From;
|
|
255
|
+
step?: Step;
|
|
256
|
+
by?: (index: number) => string;
|
|
257
|
+
},
|
|
258
|
+
content: BodyContent,
|
|
259
|
+
): ReturnAndScope<BodyContentScope<BodyContent>, void>;
|
|
260
|
+
|
|
261
|
+
export function forTag<BodyContent extends AnyMarkoBody>(
|
|
262
|
+
input: (
|
|
263
|
+
| {
|
|
264
|
+
to: number;
|
|
265
|
+
from?: number;
|
|
266
|
+
step?: number;
|
|
267
|
+
}
|
|
268
|
+
| {
|
|
269
|
+
until: number;
|
|
270
|
+
from?: number;
|
|
271
|
+
step?: number;
|
|
272
|
+
}
|
|
273
|
+
| {
|
|
274
|
+
in: any;
|
|
275
|
+
}
|
|
276
|
+
| {
|
|
277
|
+
of: any;
|
|
278
|
+
}
|
|
279
|
+
) & { by?: string | ((...args: unknown[]) => string) },
|
|
280
|
+
content: BodyContent,
|
|
281
|
+
): ReturnAndScope<BodyContentScope<BodyContent>, void>;
|
|
282
|
+
|
|
283
|
+
export function forOfAttrTag<
|
|
284
|
+
Value,
|
|
285
|
+
Item extends [0] extends [1 & Value]
|
|
286
|
+
? any
|
|
287
|
+
: Value extends readonly (infer Item)[] | Iterable<infer Item>
|
|
288
|
+
? Item
|
|
289
|
+
: never,
|
|
290
|
+
const Return extends Partial<Constraint>,
|
|
291
|
+
Constraint = unknown,
|
|
292
|
+
>(
|
|
293
|
+
input: {
|
|
294
|
+
of: Value & (Iterable<unknown> | false | void | null);
|
|
295
|
+
},
|
|
296
|
+
content: (
|
|
297
|
+
value: Item,
|
|
298
|
+
index: number,
|
|
299
|
+
all: Exclude<Value, false | void | null>,
|
|
300
|
+
) => Return,
|
|
301
|
+
constraint?: Constraint,
|
|
302
|
+
): {
|
|
303
|
+
[Key in keyof Return]: Return[Key] extends
|
|
304
|
+
| readonly (infer Item)[]
|
|
305
|
+
| (infer Item extends Record<PropertyKey, any>)
|
|
306
|
+
? AttrTagByListSize<Exclude<Value, false | void | null>, Item>
|
|
307
|
+
: never;
|
|
308
|
+
};
|
|
309
|
+
|
|
310
|
+
export function forInAttrTag<
|
|
311
|
+
Value extends object,
|
|
312
|
+
const Return extends Partial<Constraint>,
|
|
313
|
+
Constraint = unknown,
|
|
314
|
+
>(
|
|
315
|
+
input: {
|
|
316
|
+
in: Value | false | void | null;
|
|
317
|
+
},
|
|
318
|
+
content: (key: keyof Value, value: Value[keyof Value]) => Return,
|
|
319
|
+
constraint?: Constraint,
|
|
320
|
+
): {
|
|
321
|
+
[Key in keyof Return]: Return[Key] extends
|
|
322
|
+
| readonly (infer Item)[]
|
|
323
|
+
| (infer Item extends Record<PropertyKey, any>)
|
|
324
|
+
? AttrTagByObjectSize<Value, Item>
|
|
325
|
+
: never;
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
export function forToAttrTag<
|
|
329
|
+
To extends number,
|
|
330
|
+
From extends void | number,
|
|
331
|
+
Step extends void | number,
|
|
332
|
+
const Return extends Partial<Constraint>,
|
|
333
|
+
Constraint = unknown,
|
|
334
|
+
>(
|
|
335
|
+
input: {
|
|
336
|
+
to: To;
|
|
337
|
+
from?: From;
|
|
338
|
+
step?: Step;
|
|
339
|
+
},
|
|
340
|
+
content: (index: number) => Return,
|
|
341
|
+
constraint?: Constraint,
|
|
342
|
+
): {
|
|
343
|
+
[Key in keyof Return]: Return[Key] extends
|
|
344
|
+
| readonly (infer Item)[]
|
|
345
|
+
| (infer Item extends Record<PropertyKey, any>)
|
|
346
|
+
? number extends From | To | Step
|
|
347
|
+
? undefined | Marko.AttrTag<Item>
|
|
348
|
+
: Step extends 0
|
|
349
|
+
? never
|
|
350
|
+
: [To] extends [From extends void ? 0 : From]
|
|
351
|
+
? undefined
|
|
352
|
+
: Marko.AttrTag<Item>
|
|
353
|
+
: never;
|
|
354
|
+
};
|
|
355
|
+
|
|
356
|
+
export function forUntilAttrTag<
|
|
357
|
+
Until extends number,
|
|
358
|
+
From extends void | number,
|
|
359
|
+
Step extends void | number,
|
|
360
|
+
const Return extends Partial<Constraint>,
|
|
361
|
+
Constraint = unknown,
|
|
362
|
+
>(
|
|
363
|
+
input: {
|
|
364
|
+
until: Until;
|
|
365
|
+
from?: From;
|
|
366
|
+
step?: Step;
|
|
367
|
+
},
|
|
368
|
+
content: (index: number) => Return,
|
|
369
|
+
constraint?: Constraint,
|
|
370
|
+
): {
|
|
371
|
+
[Key in keyof Return]: Return[Key] extends
|
|
372
|
+
| readonly (infer Item)[]
|
|
373
|
+
| (infer Item extends Record<PropertyKey, any>)
|
|
374
|
+
? number extends From | Until | Step
|
|
375
|
+
? undefined | Marko.AttrTag<Item>
|
|
376
|
+
: Step extends 0
|
|
377
|
+
? never
|
|
378
|
+
: [Until] extends [From extends void ? 0 : From]
|
|
379
|
+
? undefined
|
|
380
|
+
: Marko.AttrTag<Item>
|
|
381
|
+
: never;
|
|
382
|
+
};
|
|
383
|
+
|
|
384
|
+
export function forAttrTag<
|
|
385
|
+
const Return extends Partial<Constraint>,
|
|
386
|
+
Constraint = unknown,
|
|
387
|
+
>(
|
|
388
|
+
input:
|
|
389
|
+
| {
|
|
390
|
+
of: Iterable<unknown> | false | void | null;
|
|
391
|
+
}
|
|
392
|
+
| {
|
|
393
|
+
in: object | false | void | null;
|
|
394
|
+
}
|
|
395
|
+
| {
|
|
396
|
+
to: number;
|
|
397
|
+
from?: number;
|
|
398
|
+
step?: number;
|
|
399
|
+
}
|
|
400
|
+
| {
|
|
401
|
+
until: number;
|
|
402
|
+
from?: number;
|
|
403
|
+
step?: number;
|
|
404
|
+
},
|
|
405
|
+
content: (...args: unknown[]) => Return,
|
|
406
|
+
constraint?: Constraint,
|
|
407
|
+
): {
|
|
408
|
+
[Key in keyof Return]: Return[Key] extends
|
|
409
|
+
| readonly (infer Item)[]
|
|
410
|
+
| (infer Item extends Record<PropertyKey, any>)
|
|
411
|
+
? undefined | Marko.AttrTag<Item>
|
|
412
|
+
: never;
|
|
413
|
+
};
|
|
414
|
+
|
|
415
|
+
export function mergeAttrTags<Attrs extends readonly any[]>(
|
|
416
|
+
...attrs: Attrs
|
|
417
|
+
): MergeAttrTags<Attrs>;
|
|
418
|
+
export function attrTag<
|
|
419
|
+
Name extends string,
|
|
420
|
+
AttrTags extends readonly { [K in Name]: unknown }[],
|
|
421
|
+
>(name: Name, ...attrTags: AttrTags): AttrTagsToAttrTag<Name, AttrTags>;
|
|
422
|
+
export function attrTagFor<Tag, Path extends readonly string[]>(
|
|
423
|
+
tag: Tag,
|
|
424
|
+
...path: Path
|
|
425
|
+
): <
|
|
426
|
+
Name extends string,
|
|
427
|
+
const AttrTags extends readonly ([0] extends [1 & Tag]
|
|
428
|
+
? Record<Name, Marko.AttrTag<unknown>>
|
|
429
|
+
: Record<
|
|
430
|
+
Name,
|
|
431
|
+
Tag extends InputFor<infer Input>
|
|
432
|
+
? [0] extends [1 & Input]
|
|
433
|
+
? Marko.AttrTag<unknown>
|
|
434
|
+
: AttrTagValue<Input, Path>
|
|
435
|
+
: Marko.AttrTag<unknown>
|
|
436
|
+
>)[],
|
|
437
|
+
>(
|
|
438
|
+
name: Name,
|
|
439
|
+
...attrTags: AttrTags
|
|
440
|
+
) => AttrTagsToAttrTag<Name, AttrTags>;
|
|
441
|
+
|
|
442
|
+
export type DynamicRenderer<Name> = [0] extends [1 & Name]
|
|
443
|
+
? DefaultRenderer
|
|
444
|
+
: [Name] extends [Marko.Template<any, any> | string]
|
|
445
|
+
? {
|
|
446
|
+
(): () => <Input extends Marko.Input<Name>>(
|
|
447
|
+
input: Marko.Directives & Input,
|
|
448
|
+
) => ReturnAndScope<Scopes<Input>, Marko.Return<Name>>;
|
|
449
|
+
}
|
|
450
|
+
: [Name] extends [AnyMarkoBody]
|
|
451
|
+
? BodyRenderer<Name>
|
|
452
|
+
: [Name] extends [
|
|
453
|
+
{
|
|
454
|
+
[BodyContentKey in DefaultBodyContentKey]?: infer BodyValue extends
|
|
455
|
+
AnyMarkoBody;
|
|
456
|
+
},
|
|
457
|
+
]
|
|
458
|
+
? BodyRenderer<BodyValue>
|
|
459
|
+
: DefaultRenderer;
|
|
460
|
+
|
|
461
|
+
export type TemplateRenderer<Template> = Template extends {
|
|
462
|
+
_: infer Renderer;
|
|
463
|
+
}
|
|
464
|
+
? Renderer
|
|
465
|
+
: Template extends Marko.Template<infer Input, infer Return>
|
|
466
|
+
? BaseRenderer<Input, Return>
|
|
467
|
+
: DefaultRenderer;
|
|
468
|
+
|
|
469
|
+
export interface NativeTagRenderer<Name extends string> {
|
|
470
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-constraint
|
|
471
|
+
(): () => <__marko_internal_input extends unknown>(
|
|
472
|
+
input: Marko.Directives &
|
|
473
|
+
Marko.NativeTags[Name]["input"] &
|
|
474
|
+
Relate<
|
|
475
|
+
__marko_internal_input,
|
|
476
|
+
Marko.Directives & Marko.NativeTags[Name]["input"]
|
|
477
|
+
>,
|
|
478
|
+
) => ReturnAndScope<
|
|
479
|
+
Scopes<__marko_internal_input>,
|
|
480
|
+
Marko.NativeTags[Name]["return"]
|
|
481
|
+
>;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
export interface BodyRenderer<Body extends AnyMarkoBody> {
|
|
485
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-constraint
|
|
486
|
+
(): () => <__marko_internal_input extends unknown>(
|
|
487
|
+
...args: BodyParamsWithDefault<Body> &
|
|
488
|
+
Relate<__marko_internal_input, BodyParamsWithDefault<Body>>
|
|
489
|
+
) => ReturnAndScope<
|
|
490
|
+
Scopes<__marko_internal_input extends [infer Input] ? Input : never>,
|
|
491
|
+
Body extends Marko.Body<any, infer Return> ? Return : never
|
|
492
|
+
>;
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
export interface BaseRenderer<Input, Return = void> {
|
|
496
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-constraint
|
|
497
|
+
(): () => <__marko_input_with_scope extends unknown>(
|
|
498
|
+
input: Marko.Directives &
|
|
499
|
+
Input &
|
|
500
|
+
Relate<__marko_input_with_scope, Marko.Directives & Input>,
|
|
501
|
+
) => ReturnAndScope<Scopes<__marko_input_with_scope>, Return>;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
export interface DefaultRenderer {
|
|
505
|
+
(): () => <Input>(input: Input) => ReturnAndScope<Scopes<Input>, void>;
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
export type ResolveComponent<Component> = CheckNever<
|
|
509
|
+
ComponentOf<
|
|
510
|
+
InstanceOf<
|
|
511
|
+
Component extends { default: infer Component }
|
|
512
|
+
? Component
|
|
513
|
+
: Component
|
|
514
|
+
>
|
|
515
|
+
>,
|
|
516
|
+
Marko.Component
|
|
517
|
+
>;
|
|
518
|
+
|
|
519
|
+
export type Relate<A, B> = B extends A ? A : B;
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
declare abstract class MarkoReturn<Return> {
|
|
525
|
+
return: Return;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
type AnyMarkoBody = Marko.Body<any, any>;
|
|
529
|
+
|
|
530
|
+
type BodyContentScope<BodyContent> = BodyContent extends (...params: any) => {
|
|
531
|
+
[Marko._.scope]: infer Scope;
|
|
532
|
+
}
|
|
533
|
+
? Scope
|
|
534
|
+
: never;
|
|
535
|
+
|
|
536
|
+
type ReturnAndScope<Scope, Return> = {
|
|
537
|
+
return: Return;
|
|
538
|
+
scope: Scope;
|
|
539
|
+
};
|
|
540
|
+
|
|
541
|
+
type BodyParamsWithDefault<Body extends AnyMarkoBody> =
|
|
542
|
+
Body extends Marko.Body<infer Params, any>
|
|
543
|
+
? Params extends []
|
|
544
|
+
? [input?: Record<string, never>]
|
|
545
|
+
: Params
|
|
546
|
+
: never;
|
|
547
|
+
|
|
548
|
+
type ComponentEventHandlers<Component extends Marko.Component> = {
|
|
549
|
+
[K in Exclude<
|
|
550
|
+
keyof Component,
|
|
551
|
+
Exclude<
|
|
552
|
+
keyof Marko.Component,
|
|
553
|
+
"emit" | "setState" | "setStateDirty" | "forceUpdate"
|
|
554
|
+
>
|
|
555
|
+
>]: Component[K] extends (...args: any) => any ? Component[K] : never;
|
|
556
|
+
};
|
|
557
|
+
|
|
558
|
+
type Scopes<Input> = [0] extends [1 & Input]
|
|
559
|
+
? never
|
|
560
|
+
:
|
|
561
|
+
| (Input[("content" | "renderBody") & keyof Input] extends infer Prop
|
|
562
|
+
? Prop extends (...args: any[]) => { [Marko._.scope]: infer Scope }
|
|
563
|
+
? Scope
|
|
564
|
+
: never
|
|
565
|
+
: never)
|
|
566
|
+
| (Input[string & keyof Input] extends infer Prop
|
|
567
|
+
? Prop extends { [Symbol.iterator]: any }
|
|
568
|
+
? Prop extends readonly any[]
|
|
569
|
+
? never
|
|
570
|
+
: Scopes<Prop>
|
|
571
|
+
: never
|
|
572
|
+
: never);
|
|
573
|
+
|
|
574
|
+
type MergeScopes<Scopes> = {
|
|
575
|
+
[K in Scopes extends Scopes ? keyof Scopes : never]: Scopes extends Scopes
|
|
576
|
+
? Scopes[K & keyof Scopes]
|
|
577
|
+
: never;
|
|
578
|
+
};
|
|
579
|
+
|
|
580
|
+
type MergeAttrTags<Attrs extends readonly any[]> = Attrs extends readonly [
|
|
581
|
+
infer A,
|
|
582
|
+
infer B,
|
|
583
|
+
...infer Rest,
|
|
584
|
+
]
|
|
585
|
+
? MergeAttrTags<[MergeAttrTag<A, B>, ...Rest]>
|
|
586
|
+
: Attrs extends readonly [infer A]
|
|
587
|
+
? A
|
|
588
|
+
: never;
|
|
589
|
+
|
|
590
|
+
type MergeAttrTag<A, B> = {
|
|
591
|
+
[K in keyof A | keyof B]: K extends keyof A
|
|
592
|
+
? K extends keyof B
|
|
593
|
+
? MergeAttrTagValue<A[K], B[K]>
|
|
594
|
+
: A[K]
|
|
595
|
+
: K extends keyof B
|
|
596
|
+
? B[K]
|
|
597
|
+
: never;
|
|
598
|
+
};
|
|
599
|
+
|
|
600
|
+
type MergeAttrTagValue<A, B> = A extends readonly (infer AType)[]
|
|
601
|
+
? B extends readonly (infer BType)[]
|
|
602
|
+
? AType | BType
|
|
603
|
+
: B extends void
|
|
604
|
+
? A
|
|
605
|
+
: AType | B
|
|
606
|
+
: A extends void
|
|
607
|
+
? B
|
|
608
|
+
: B extends void
|
|
609
|
+
? A
|
|
610
|
+
: A | B;
|
|
611
|
+
|
|
612
|
+
type AttrTagsToAttrTag<
|
|
613
|
+
Name extends string,
|
|
614
|
+
AttrTags extends readonly unknown[],
|
|
615
|
+
> = AttrTags[number] extends infer AttrTag
|
|
616
|
+
? AttrTag extends { [K in Name]: Marko.AttrTag<infer Input> }
|
|
617
|
+
? [0] extends [1 & Input]
|
|
618
|
+
? never
|
|
619
|
+
: Marko.AttrTag<Input>
|
|
620
|
+
: never
|
|
621
|
+
: never;
|
|
622
|
+
|
|
623
|
+
type AttrTagByListSize<T, Item> = T extends
|
|
624
|
+
| readonly [any, ...any[]]
|
|
625
|
+
| readonly [...any[], any]
|
|
626
|
+
? Marko.AttrTag<Item>
|
|
627
|
+
: T extends readonly []
|
|
628
|
+
? undefined
|
|
629
|
+
: undefined | Marko.AttrTag<Item>;
|
|
630
|
+
|
|
631
|
+
type AttrTagByObjectSize<
|
|
632
|
+
Value,
|
|
633
|
+
Item,
|
|
634
|
+
Keys = RecordKeys<Value>,
|
|
635
|
+
KnownKeys = KnownRecordKeys<Value>,
|
|
636
|
+
> = CheckNever<
|
|
637
|
+
Keys,
|
|
638
|
+
undefined,
|
|
639
|
+
CheckNever<KnownKeys, Marko.AttrTag<Item>, undefined | Marko.AttrTag<Item>>
|
|
640
|
+
>;
|
|
641
|
+
|
|
642
|
+
type AttrTagValue<Input, Path extends readonly string[]> = Path extends [
|
|
643
|
+
infer Prop extends keyof Input,
|
|
644
|
+
...infer Rest extends readonly string[],
|
|
645
|
+
]
|
|
646
|
+
? Input[Prop] & Marko.AttrTag<unknown> extends infer Value
|
|
647
|
+
? Rest extends readonly []
|
|
648
|
+
? Value
|
|
649
|
+
: AttrTagValue<Value, Rest>
|
|
650
|
+
: Marko.AttrTag<unknown>
|
|
651
|
+
: Marko.AttrTag<unknown>;
|
|
652
|
+
|
|
653
|
+
type AttrTagNames<Input> = Record<string, never> &
|
|
654
|
+
(Input extends infer Input extends {}
|
|
655
|
+
? {
|
|
656
|
+
[Key in keyof Input & string as `@${Input[Key] extends infer Value
|
|
657
|
+
? Value extends Marko.AttrTag<any>
|
|
658
|
+
? Key
|
|
659
|
+
: never
|
|
660
|
+
: never}`]: Input[Key];
|
|
661
|
+
}
|
|
662
|
+
: never);
|
|
663
|
+
|
|
664
|
+
type RecordKeys<T> = keyof {
|
|
665
|
+
[K in keyof T as CheckNever<T[K], never, K>]: 0;
|
|
666
|
+
};
|
|
667
|
+
|
|
668
|
+
type KnownRecordKeys<T> = keyof {
|
|
669
|
+
[Key in keyof T as string extends Key
|
|
670
|
+
? never
|
|
671
|
+
: number extends Key
|
|
672
|
+
? never
|
|
673
|
+
: symbol extends Key
|
|
674
|
+
? never
|
|
675
|
+
: CheckNever<T[Key], never, Key>]: 0;
|
|
676
|
+
};
|
|
677
|
+
|
|
678
|
+
type CheckNever<T, If, Else = T> = [T] extends [never] ? If : Else;
|
|
679
|
+
type ComponentOf<T> = T extends Marko.Component ? T : T & Marko.Component;
|
|
680
|
+
type InstanceOf<T> = T extends abstract new () => infer R ? R : T;
|
|
681
|
+
|
|
682
|
+
type UnionToIntersection<T> = (T extends any ? (_: T) => any : never) extends (
|
|
683
|
+
_: infer U,
|
|
684
|
+
) => any
|
|
685
|
+
? U
|
|
686
|
+
: never;
|
|
687
|
+
|
|
688
|
+
type DefaultBodyContentKey = keyof Exclude<
|
|
689
|
+
Marko.Renderable,
|
|
690
|
+
Marko.Template<any, any> | Marko.Body<any, any> | string
|
|
691
|
+
>;
|
|
692
|
+
|
|
693
|
+
type ContentFor<Name> = [0] extends [1 & Name]
|
|
694
|
+
? DefaultBodyContentKey
|
|
695
|
+
: Name extends { api: infer API }
|
|
696
|
+
? API extends "tags"
|
|
697
|
+
? "content"
|
|
698
|
+
: API extends "class"
|
|
699
|
+
? "renderBody"
|
|
700
|
+
: DefaultBodyContentKey
|
|
701
|
+
: DefaultBodyContentKey;
|
|
702
|
+
|
|
703
|
+
type InputFor<Name> = 0 extends 1 & Name
|
|
704
|
+
? any
|
|
705
|
+
: Name extends string
|
|
706
|
+
? Name extends keyof Marko.NativeTags
|
|
707
|
+
? Marko.NativeTags[Name]["input"]
|
|
708
|
+
: Record<string, unknown>
|
|
709
|
+
: Name extends
|
|
710
|
+
| Marko.Template<infer Input, any>
|
|
711
|
+
| { _(): () => (input: infer Input) => any }
|
|
712
|
+
? Input
|
|
713
|
+
: Name extends
|
|
714
|
+
| Marko.Body<infer Args, any>
|
|
715
|
+
| Record<
|
|
716
|
+
DefaultBodyContentKey,
|
|
717
|
+
undefined | null | false | Marko.Body<infer Args, any>
|
|
718
|
+
>
|
|
719
|
+
? Args extends {
|
|
720
|
+
length: infer Length;
|
|
721
|
+
}
|
|
722
|
+
? number extends Length
|
|
723
|
+
? Args[0] | undefined
|
|
724
|
+
: 0 extends Length
|
|
725
|
+
? undefined
|
|
726
|
+
: Args[0]
|
|
727
|
+
: never
|
|
728
|
+
: never;
|
|
729
|
+
|
|
730
|
+
export {};
|