marko 5.25.4 → 5.25.5
Sign up to get free protection for your applications and to get access to all the features.
- package/docs/marko-json.md +1 -1
- package/docs/state.md +1 -1
- package/docs/typescript.md +3 -3
- package/docs/vite.md +1 -1
- package/index.d.ts +341 -303
- package/package.json +6 -4
- package/tags-html.d.ts +4598 -0
package/index.d.ts
CHANGED
@@ -1,330 +1,368 @@
|
|
1
|
+
import "./tags-html";
|
2
|
+
|
1
3
|
declare module "*.marko" {
|
2
4
|
const template: Marko.Template;
|
3
5
|
export default template;
|
4
6
|
}
|
5
7
|
|
6
|
-
declare
|
7
|
-
|
8
|
-
|
9
|
-
}
|
10
|
-
|
11
|
-
declare namespace Marko {
|
12
|
-
/** A mutable global object for the current render. */
|
13
|
-
export interface Global {
|
14
|
-
/** A list of globals that should be serialized to the browser. */
|
15
|
-
serializedGlobals?: Record<string, boolean>;
|
16
|
-
/** A CSP Nonce to add to each script output from Marko. */
|
17
|
-
cspNonce?: string;
|
18
|
-
/** Used to uniquely identify a instance of a Marko runtime. */
|
19
|
-
runtimeId?: string;
|
20
|
-
/** Used for rendering multiple Marko templates in a single hydrated page. */
|
21
|
-
componentIdPrefix?: string;
|
22
|
-
[attr: PropertyKey]: unknown;
|
8
|
+
declare global {
|
9
|
+
namespace NodeJS {
|
10
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
11
|
+
interface ReadableStream {}
|
23
12
|
}
|
24
13
|
|
25
|
-
|
26
|
-
$global?: Global;
|
27
|
-
};
|
28
|
-
|
29
|
-
export interface Out<Component extends Marko.Component = Marko.Component>
|
30
|
-
extends PromiseLike<RenderResult<Component>> {
|
31
|
-
/** The underlying ReadableStream Marko is writing into. */
|
32
|
-
stream: unknown;
|
14
|
+
namespace Marko {
|
33
15
|
/** A mutable global object for the current render. */
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
/** Starts a new async/forked stream. */
|
46
|
-
beginAsync(options?: {
|
47
|
-
name?: string;
|
48
|
-
timeout?: number;
|
49
|
-
last?: boolean;
|
50
|
-
}): Out;
|
51
|
-
/** Marks the current stream as complete (async streams may still be executing). */
|
52
|
-
end(val?: string | void): this;
|
53
|
-
emit(eventName: PropertyKey, ...args: any[]): boolean;
|
54
|
-
on(eventName: PropertyKey, listener: (...args: any[]) => any): this;
|
55
|
-
once(eventName: PropertyKey, listener: (...args: any[]) => any): this;
|
56
|
-
prependListener(
|
57
|
-
eventName: PropertyKey,
|
58
|
-
listener: (...args: any[]) => any
|
59
|
-
): this;
|
60
|
-
removeListener(
|
61
|
-
eventName: PropertyKey,
|
62
|
-
listener: (...args: any[]) => any
|
63
|
-
): this;
|
64
|
-
/** Register a callback executed when the last async out has completed. */
|
65
|
-
onLast(listener: (next: () => void) => unknown): this;
|
66
|
-
/** Pipe Marko's stream to another stream. */
|
67
|
-
pipe(stream: unknown): this;
|
68
|
-
/** Emits an error on the stream. */
|
69
|
-
error(e: Error): this;
|
70
|
-
/** Schedules a Marko to flush buffered html to the underlying stream. */
|
71
|
-
flush(): this;
|
72
|
-
/** Creates a detached out stream (used for out of order flushing). */
|
73
|
-
createOut(): Out;
|
74
|
-
/** Write escaped text at the current stream position. */
|
75
|
-
text(val: string | void): void;
|
76
|
-
}
|
16
|
+
export interface Global {
|
17
|
+
/** A list of globals that should be serialized to the browser. */
|
18
|
+
serializedGlobals?: Record<string, boolean>;
|
19
|
+
/** A CSP Nonce to add to each script output from Marko. */
|
20
|
+
cspNonce?: string;
|
21
|
+
/** Used to uniquely identify a instance of a Marko runtime. */
|
22
|
+
runtimeId?: string;
|
23
|
+
/** Used for rendering multiple Marko templates in a single hydrated page. */
|
24
|
+
componentIdPrefix?: string;
|
25
|
+
[attr: PropertyKey]: unknown;
|
26
|
+
}
|
77
27
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
82
|
-
in Params extends readonly any[] = [],
|
83
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
84
|
-
out Return = void
|
85
|
-
> {}
|
28
|
+
export type TemplateInput<Input = { [attr: PropertyKey]: any }> = Input & {
|
29
|
+
$global?: Global;
|
30
|
+
};
|
86
31
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
32
|
+
export interface Out<Component extends Marko.Component = Marko.Component>
|
33
|
+
extends PromiseLike<RenderResult<Component>> {
|
34
|
+
/** The underlying ReadableStream Marko is writing into. */
|
35
|
+
stream: unknown;
|
36
|
+
/** A mutable global object for the current render. */
|
37
|
+
global: Global;
|
38
|
+
/** Disable all async rendering. Will error if something beings async. */
|
39
|
+
sync(): void;
|
40
|
+
/** Returns true if async rendering is disabled. */
|
41
|
+
isSync(): boolean;
|
42
|
+
/** Write unescaped text at the current stream position. */
|
43
|
+
write(val: string | void): this;
|
44
|
+
/** Write javascript content to be merged with the scripts Marko sends out on the next flush. */
|
45
|
+
script(val: string | void): this;
|
46
|
+
/** Returns the currently rendered html content. */
|
47
|
+
toString(): string;
|
48
|
+
/** Starts a new async/forked stream. */
|
49
|
+
beginAsync(options?: {
|
50
|
+
name?: string;
|
51
|
+
timeout?: number;
|
52
|
+
last?: boolean;
|
53
|
+
}): Out;
|
54
|
+
/** Marks the current stream as complete (async streams may still be executing). */
|
55
|
+
end(val?: string | void): this;
|
56
|
+
emit(eventName: PropertyKey, ...args: any[]): boolean;
|
57
|
+
on(eventName: PropertyKey, listener: (...args: any[]) => any): this;
|
58
|
+
once(eventName: PropertyKey, listener: (...args: any[]) => any): this;
|
59
|
+
prependListener(
|
60
|
+
eventName: PropertyKey,
|
61
|
+
listener: (...args: any[]) => any
|
62
|
+
): this;
|
63
|
+
removeListener(
|
64
|
+
eventName: PropertyKey,
|
65
|
+
listener: (...args: any[]) => any
|
66
|
+
): this;
|
67
|
+
/** Register a callback executed when the last async out has completed. */
|
68
|
+
onLast(listener: (next: () => void) => unknown): this;
|
69
|
+
/** Pipe Marko's stream to another stream. */
|
70
|
+
pipe(stream: unknown): this;
|
71
|
+
/** Emits an error on the stream. */
|
72
|
+
error(e: Error): this;
|
73
|
+
/** Schedules a Marko to flush buffered html to the underlying stream. */
|
74
|
+
flush(): this;
|
75
|
+
/** Creates a detached out stream (used for out of order flushing). */
|
76
|
+
createOut(): Out;
|
77
|
+
/** Write escaped text at the current stream position. */
|
78
|
+
text(val: string | void): void;
|
79
|
+
}
|
93
80
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
81
|
+
/** Body content created from by a component, typically held in an object with a renderBody property. */
|
82
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
83
|
+
export interface Body<
|
84
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
85
|
+
in Params extends readonly any[] = [],
|
86
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
87
|
+
out Return = void
|
88
|
+
> {}
|
98
89
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
90
|
+
/** Valid data types which can be passed in as a <${dynamic}/> tag name. */
|
91
|
+
export type Renderable =
|
92
|
+
| { renderBody: Body<any, any> | Template | string }
|
93
|
+
| Body<any, any>
|
94
|
+
| Template
|
95
|
+
| string;
|
103
96
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
| null
|
109
|
-
| Record<PropertyKey, any>
|
110
|
-
> implements Emitter
|
111
|
-
{
|
112
|
-
/** A unique id for this instance. */
|
113
|
-
public readonly id: string;
|
114
|
-
/** The top level element rendered by this instance. */
|
115
|
-
public readonly el: Element | void;
|
116
|
-
/** The attributes passed to this instance. */
|
117
|
-
public readonly input: Input;
|
118
|
-
/** @deprecated */
|
119
|
-
public readonly els: Element[];
|
120
|
-
/** Mutable state that when changed causes a rerender. */
|
121
|
-
state: State;
|
97
|
+
/** Extract the return tag type from a renderBody. */
|
98
|
+
export type BodyReturnType<B> = B extends Body<any, infer Return>
|
99
|
+
? Return
|
100
|
+
: never;
|
122
101
|
|
123
|
-
/**
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
* cleaned up once this component is destroyed
|
128
|
-
* */
|
129
|
-
subscribeTo(
|
130
|
-
emitter: unknown
|
131
|
-
): Omit<Emitter, "listenerCount" | "prependListener" | "emit">;
|
132
|
-
/** Emits an event on the component instance. */
|
133
|
-
emit(eventName: PropertyKey, ...args: any[]): boolean;
|
134
|
-
/** Listen to an event on the component instance. */
|
135
|
-
on(eventName: PropertyKey, listener: (...args: any[]) => any): this;
|
136
|
-
/** Listen to an event on the component instance once. */
|
137
|
-
once(eventName: PropertyKey, listener: (...args: any[]) => any): this;
|
138
|
-
/** Listen to an event on the component instance before all other listeners. */
|
139
|
-
prependListener(
|
140
|
-
eventName: PropertyKey,
|
141
|
-
listener: (...args: any[]) => any
|
142
|
-
): this;
|
143
|
-
/** Remove a listener from the component instance. */
|
144
|
-
removeListener(
|
145
|
-
eventName: PropertyKey,
|
146
|
-
listener: (...args: any[]) => any
|
147
|
-
): this;
|
148
|
-
/** Remove all listeners from the component instance. */
|
149
|
-
removeAllListeners(eventName?: PropertyKey): this;
|
150
|
-
/** Removes the component instance from the DOM and cleans up all active event handlers including all children. */
|
151
|
-
destroy(): void;
|
152
|
-
/** Schedule an update (similar to if a state had been changed). */
|
153
|
-
forceUpdate(): void;
|
154
|
-
/** Generates a unique id derived from the current unique instance id (similar to :scoped in the template). */
|
155
|
-
elId(key?: string, index?: number): string;
|
156
|
-
/** @alias elId */
|
157
|
-
getElId(key?: string, index?: number): string;
|
158
|
-
/** Gets an element reference by its `key` attribute in the template. */
|
159
|
-
getEl<T extends Element | void = Element | void>(
|
160
|
-
key?: string,
|
161
|
-
index?: number
|
162
|
-
): T;
|
163
|
-
/** Gets all element references by their `key` attribute in the template. */
|
164
|
-
getEls<T extends Element[] = Element[]>(key: string): T;
|
165
|
-
/** Gets a component reference by its `key` attribute in the template. */
|
166
|
-
getComponent<T extends Component | void = Component | void>(
|
167
|
-
key: string,
|
168
|
-
index?: number
|
169
|
-
): T;
|
170
|
-
/** Gets all component references by their `key` attribute in the template. */
|
171
|
-
getComponents<T extends Component[] = Component[]>(key: string): T;
|
172
|
-
/** True if this instance has been removed from the dom. */
|
173
|
-
/** True if this instance is scheduled to rerender. */
|
174
|
-
isDestroyed(): boolean;
|
175
|
-
/** Replace the entire state object with a new one, removing old properties. */
|
176
|
-
replaceState(state: this["state"]): void;
|
177
|
-
/**
|
178
|
-
* Update a property on this.state (should prefer mutating this.state directly).
|
179
|
-
* When passed an object as the first argument, it will be merged into the state.
|
180
|
-
*/
|
181
|
-
setState<Key extends PropertyKey>(
|
182
|
-
name: Key & keyof this["state"],
|
183
|
-
value: (this["state"] & Record<PropertyKey, unknown>)[Key]
|
184
|
-
): void;
|
185
|
-
setState(value: Partial<this["state"]>): void;
|
102
|
+
/** Extract the tag parameter types received by a renderBody. */
|
103
|
+
export type BodyParameters<B> = B extends Body<infer Params, any>
|
104
|
+
? Params
|
105
|
+
: never;
|
186
106
|
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
replaceChildrenOf(target: ParentNode): this;
|
206
|
-
// /** Called when the component is firsted created. */
|
207
|
-
// onCreate?(input: this["input"], out: Marko.Out): void;
|
208
|
-
// /** Called every time the component receives input from it's parent. */
|
209
|
-
// onInput?(input: this["input"], out: Marko.Out): void | this["input"];
|
210
|
-
// /** Called after a component has successfully rendered, but before it's update has been applied to the dom. */
|
211
|
-
// onRender?(out: Marko.Out): void;
|
212
|
-
// /** Called after the first time the component renders and is attached to the dom. */
|
213
|
-
// onMount?(): void;
|
214
|
-
// /** Called when a components render has been applied to the DOM (excluding when it is initially mounted). */
|
215
|
-
// onUpdate?(): void;
|
216
|
-
// /** Called when a component is destroyed and removed from the dom. */
|
217
|
-
// onDestroy?(): void;
|
218
|
-
}
|
107
|
+
export class Component<
|
108
|
+
Input extends Record<PropertyKey, any> = Record<PropertyKey, any>,
|
109
|
+
State extends undefined | null | Record<PropertyKey, any> =
|
110
|
+
| undefined
|
111
|
+
| null
|
112
|
+
| Record<PropertyKey, any>
|
113
|
+
> implements Emitter
|
114
|
+
{
|
115
|
+
/** A unique id for this instance. */
|
116
|
+
public readonly id: string;
|
117
|
+
/** The top level element rendered by this instance. */
|
118
|
+
public readonly el: Element | void;
|
119
|
+
/** The attributes passed to this instance. */
|
120
|
+
public readonly input: Input;
|
121
|
+
/** @deprecated */
|
122
|
+
public readonly els: Element[];
|
123
|
+
/** Mutable state that when changed causes a rerender. */
|
124
|
+
state: State;
|
219
125
|
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
126
|
+
/** Returns the amount of event handlers listening to a specific event. */
|
127
|
+
listenerCount(eventName: PropertyKey): number;
|
128
|
+
/**
|
129
|
+
* Used to wrap an existing event emitted and ensure that all events are
|
130
|
+
* cleaned up once this component is destroyed
|
131
|
+
* */
|
132
|
+
subscribeTo(
|
133
|
+
emitter: unknown
|
134
|
+
): Omit<Emitter, "listenerCount" | "prependListener" | "emit">;
|
135
|
+
/** Emits an event on the component instance. */
|
136
|
+
emit(eventName: PropertyKey, ...args: any[]): boolean;
|
137
|
+
/** Listen to an event on the component instance. */
|
138
|
+
on(eventName: PropertyKey, listener: (...args: any[]) => any): this;
|
139
|
+
/** Listen to an event on the component instance once. */
|
140
|
+
once(eventName: PropertyKey, listener: (...args: any[]) => any): this;
|
141
|
+
/** Listen to an event on the component instance before all other listeners. */
|
142
|
+
prependListener(
|
143
|
+
eventName: PropertyKey,
|
144
|
+
listener: (...args: any[]) => any
|
145
|
+
): this;
|
146
|
+
/** Remove a listener from the component instance. */
|
147
|
+
removeListener(
|
148
|
+
eventName: PropertyKey,
|
149
|
+
listener: (...args: any[]) => any
|
150
|
+
): this;
|
151
|
+
/** Remove all listeners from the component instance. */
|
152
|
+
removeAllListeners(eventName?: PropertyKey): this;
|
153
|
+
/** Removes the component instance from the DOM and cleans up all active event handlers including all children. */
|
154
|
+
destroy(): void;
|
155
|
+
/** Schedule an update (similar to if a state had been changed). */
|
156
|
+
forceUpdate(): void;
|
157
|
+
/** Generates a unique id derived from the current unique instance id (similar to :scoped in the template). */
|
158
|
+
elId(key?: string, index?: number): string;
|
159
|
+
/** @alias elId */
|
160
|
+
getElId(key?: string, index?: number): string;
|
161
|
+
/** Gets an element reference by its `key` attribute in the template. */
|
162
|
+
getEl<T extends Element | void = Element | void>(
|
163
|
+
key?: string,
|
164
|
+
index?: number
|
165
|
+
): T;
|
166
|
+
/** Gets all element references by their `key` attribute in the template. */
|
167
|
+
getEls<T extends Element[] = Element[]>(key: string): T;
|
168
|
+
/** Gets a component reference by its `key` attribute in the template. */
|
169
|
+
getComponent<T extends Component | void = Component | void>(
|
170
|
+
key: string,
|
171
|
+
index?: number
|
172
|
+
): T;
|
173
|
+
/** Gets all component references by their `key` attribute in the template. */
|
174
|
+
getComponents<T extends Component[] = Component[]>(key: string): T;
|
175
|
+
/** True if this instance has been removed from the dom. */
|
176
|
+
/** True if this instance is scheduled to rerender. */
|
177
|
+
isDestroyed(): boolean;
|
178
|
+
/** Replace the entire state object with a new one, removing old properties. */
|
179
|
+
replaceState(state: this["state"]): void;
|
180
|
+
/**
|
181
|
+
* Update a property on this.state (should prefer mutating this.state directly).
|
182
|
+
* When passed an object as the first argument, it will be merged into the state.
|
183
|
+
*/
|
184
|
+
setState<Key extends PropertyKey>(
|
185
|
+
name: Key & keyof this["state"],
|
186
|
+
value: (this["state"] & Record<PropertyKey, unknown>)[Key]
|
187
|
+
): void;
|
188
|
+
setState(value: Partial<this["state"]>): void;
|
227
189
|
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
190
|
+
/** Schedules an update related to a specific state property and optionally updates the value. */
|
191
|
+
setStateDirty<Key extends PropertyKey>(
|
192
|
+
name: Key & keyof this["state"],
|
193
|
+
value?: (this["state"] & Record<PropertyKey, unknown>)[Key]
|
194
|
+
): void;
|
195
|
+
/** Synchronously flush any scheduled updates. */
|
196
|
+
update(): void;
|
197
|
+
/** Appends the dom for the current instance to a parent DOM element. */
|
198
|
+
appendTo(target: ParentNode): this;
|
199
|
+
/** Inserts the dom for the current instance after a sibling DOM element. */
|
200
|
+
insertAfter(target: ChildNode): this;
|
201
|
+
/** Inserts the dom for the current instance before a sibling DOM element. */
|
202
|
+
insertBefore(target: ChildNode): this;
|
203
|
+
/** Prepends the dom for the current instance to a parent DOM element. */
|
204
|
+
prependTo(target: ParentNode): this;
|
205
|
+
/** Replaces an existing DOM element with the dom for the current instance. */
|
206
|
+
replace(target: ChildNode): this;
|
207
|
+
/** Replaces the children of an existing DOM element with the dom for the current instance. */
|
208
|
+
replaceChildrenOf(target: ParentNode): this;
|
209
|
+
// /** Called when the component is firsted created. */
|
210
|
+
// onCreate?(input: this["input"], out: Marko.Out): void;
|
211
|
+
// /** Called every time the component receives input from it's parent. */
|
212
|
+
// onInput?(input: this["input"], out: Marko.Out): void | this["input"];
|
213
|
+
// /** Called after a component has successfully rendered, but before it's update has been applied to the dom. */
|
214
|
+
// onRender?(out: Marko.Out): void;
|
215
|
+
// /** Called after the first time the component renders and is attached to the dom. */
|
216
|
+
// onMount?(): void;
|
217
|
+
// /** Called when a components render has been applied to the DOM (excluding when it is initially mounted). */
|
218
|
+
// onUpdate?(): void;
|
219
|
+
// /** Called when a component is destroyed and removed from the dom. */
|
220
|
+
// onDestroy?(): void;
|
221
|
+
}
|
237
222
|
|
238
|
-
/**
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
}
|
246
|
-
): Marko.Out<Marko.Component>;
|
223
|
+
/** The top level api for a Marko Template. */
|
224
|
+
export abstract class Template<
|
225
|
+
Input = { [attr: PropertyKey]: any },
|
226
|
+
Return = unknown
|
227
|
+
> {
|
228
|
+
/** Creates a Marko compatible output stream. */
|
229
|
+
createOut(): Out;
|
247
230
|
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
231
|
+
/**
|
232
|
+
* The folowing types are processed up by the @marko/language-tools
|
233
|
+
* and inlined into the compiled template.
|
234
|
+
*
|
235
|
+
* This is done to support generics on each of these methods
|
236
|
+
* until TypeScript supports higher kinded types.
|
237
|
+
*
|
238
|
+
* https://github.com/microsoft/TypeScript/issues/1213
|
239
|
+
*/
|
252
240
|
|
253
|
-
|
254
|
-
|
241
|
+
/** @marko-overload-start */
|
242
|
+
/** Asynchronously render the template. */
|
243
|
+
abstract render(
|
244
|
+
input: Marko.TemplateInput<Input>,
|
245
|
+
stream?: {
|
246
|
+
write: (chunk: string) => void;
|
247
|
+
end: (chunk?: string) => void;
|
248
|
+
}
|
249
|
+
): Marko.Out<Marko.Component>;
|
255
250
|
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
/** @marko-overload-end */
|
261
|
-
}
|
251
|
+
/** Synchronously render the template. */
|
252
|
+
abstract renderSync(
|
253
|
+
input: Marko.TemplateInput<Input>
|
254
|
+
): Marko.RenderResult<Marko.Component>;
|
262
255
|
|
263
|
-
|
264
|
-
|
265
|
-
> {
|
266
|
-
/** Returns the component created as a result of rendering the template. */
|
267
|
-
getComponent(): Component;
|
268
|
-
getComponents(selector?: any): any;
|
269
|
-
/** Triggers the mount lifecycle of a component without necessarily attaching it to the DOM. */
|
270
|
-
afterInsert(host?: any): this;
|
271
|
-
/** Gets the DOM node rendered by a template. */
|
272
|
-
getNode(host?: any): Node;
|
273
|
-
/** Gets the HTML output of the rendered template. */
|
274
|
-
toString(): string;
|
275
|
-
/** Appends the dom of the rendered template to a parent DOM element. */
|
276
|
-
appendTo(target: ParentNode): this;
|
277
|
-
/** Inserts the dom of the rendered template after a sibling DOM element. */
|
278
|
-
insertAfter(target: ChildNode): this;
|
279
|
-
/** Inserts the dom of the rendered template before a sibling DOM element. */
|
280
|
-
insertBefore(target: ChildNode): this;
|
281
|
-
/** Prepends the dom of the rendered template to a parent DOM element. */
|
282
|
-
prependTo(target: ParentNode): this;
|
283
|
-
/** Replaces an existing DOM element with the dom of the rendered template. */
|
284
|
-
replace(target: ChildNode): this;
|
285
|
-
/** Replaces the children of an existing DOM element with the dom of the rendered template. */
|
286
|
-
replaceChildrenOf(target: ParentNode): this;
|
287
|
-
out: Out<Component>;
|
288
|
-
/** @deprecated */
|
289
|
-
document: any;
|
290
|
-
/** @deprecated */
|
291
|
-
getOutput(): string;
|
292
|
-
/** @deprecated */
|
293
|
-
html: string;
|
294
|
-
/** @deprecated */
|
295
|
-
context: Out<Component>;
|
296
|
-
}
|
256
|
+
/** Synchronously render a template to a string. */
|
257
|
+
abstract renderToString(input: Marko.TemplateInput<Input>): string;
|
297
258
|
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
eventName: PropertyKey,
|
305
|
-
listener: (...args: any[]) => any
|
306
|
-
): this;
|
307
|
-
removeListener(
|
308
|
-
eventName: PropertyKey,
|
309
|
-
listener: (...args: any[]) => any
|
310
|
-
): this;
|
311
|
-
removeAllListeners(eventName?: PropertyKey): this;
|
312
|
-
}
|
259
|
+
/** Render a template and return a stream.Readable in nodejs or a ReadableStream in a web worker environment. */
|
260
|
+
abstract stream(
|
261
|
+
input: Marko.TemplateInput<Input>
|
262
|
+
): ReadableStream<string> & NodeJS.ReadableStream;
|
263
|
+
/** @marko-overload-end */
|
264
|
+
}
|
313
265
|
|
314
|
-
|
315
|
-
|
266
|
+
export interface RenderResult<
|
267
|
+
out Component extends Marko.Component = Marko.Component
|
268
|
+
> {
|
269
|
+
/** Returns the component created as a result of rendering the template. */
|
270
|
+
getComponent(): Component;
|
271
|
+
getComponents(selector?: any): any;
|
272
|
+
/** Triggers the mount lifecycle of a component without necessarily attaching it to the DOM. */
|
273
|
+
afterInsert(host?: any): this;
|
274
|
+
/** Gets the DOM node rendered by a template. */
|
275
|
+
getNode(host?: any): Node;
|
276
|
+
/** Gets the HTML output of the rendered template. */
|
277
|
+
toString(): string;
|
278
|
+
/** Appends the dom of the rendered template to a parent DOM element. */
|
279
|
+
appendTo(target: ParentNode): this;
|
280
|
+
/** Inserts the dom of the rendered template after a sibling DOM element. */
|
281
|
+
insertAfter(target: ChildNode): this;
|
282
|
+
/** Inserts the dom of the rendered template before a sibling DOM element. */
|
283
|
+
insertBefore(target: ChildNode): this;
|
284
|
+
/** Prepends the dom of the rendered template to a parent DOM element. */
|
285
|
+
prependTo(target: ParentNode): this;
|
286
|
+
/** Replaces an existing DOM element with the dom of the rendered template. */
|
287
|
+
replace(target: ChildNode): this;
|
288
|
+
/** Replaces the children of an existing DOM element with the dom of the rendered template. */
|
289
|
+
replaceChildrenOf(target: ParentNode): this;
|
290
|
+
out: Out<Component>;
|
291
|
+
/** @deprecated */
|
292
|
+
document: any;
|
293
|
+
/** @deprecated */
|
294
|
+
getOutput(): string;
|
295
|
+
/** @deprecated */
|
296
|
+
html: string;
|
297
|
+
/** @deprecated */
|
298
|
+
context: Out<Component>;
|
299
|
+
}
|
316
300
|
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
301
|
+
export interface Emitter {
|
302
|
+
listenerCount(eventName: PropertyKey): number;
|
303
|
+
emit(eventName: PropertyKey, ...args: any[]): boolean;
|
304
|
+
on(eventName: PropertyKey, listener: (...args: any[]) => any): this;
|
305
|
+
once(eventName: PropertyKey, listener: (...args: any[]) => any): this;
|
306
|
+
prependListener(
|
307
|
+
eventName: PropertyKey,
|
308
|
+
listener: (...args: any[]) => any
|
309
|
+
): this;
|
310
|
+
removeListener(
|
311
|
+
eventName: PropertyKey,
|
312
|
+
listener: (...args: any[]) => any
|
313
|
+
): this;
|
314
|
+
removeAllListeners(eventName?: PropertyKey): this;
|
315
|
+
}
|
323
316
|
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
}
|
317
|
+
export type AttrTag<T> = T & Iterable<AttrTag<T>>;
|
318
|
+
export type RepeatableAttrTag<T> =
|
319
|
+
| AttrTag<T>
|
320
|
+
| [AttrTag<T>, AttrTag<T>, ...AttrTag<T>[]];
|
329
321
|
|
330
|
-
|
322
|
+
export interface NativeTag<
|
323
|
+
Input extends Record<string, any>,
|
324
|
+
Return extends Element
|
325
|
+
> {
|
326
|
+
input: Input;
|
327
|
+
return: () => Return;
|
328
|
+
}
|
329
|
+
export interface NativeTags {
|
330
|
+
[name: string]: NativeTag<Record<string, any>, Element>;
|
331
|
+
}
|
332
|
+
|
333
|
+
export type Input<Name> = 0 extends 1 & Name
|
334
|
+
? any
|
335
|
+
: Name extends string
|
336
|
+
? Name extends keyof NativeTags
|
337
|
+
? NativeTags[Name]["input"]
|
338
|
+
: Record<string, unknown>
|
339
|
+
: Name extends
|
340
|
+
| Template<infer Input, any>
|
341
|
+
| { _(): () => (input: infer Input) => any }
|
342
|
+
? Input
|
343
|
+
: Name extends Body<infer Args, any>
|
344
|
+
? Args extends {
|
345
|
+
length: infer Length;
|
346
|
+
}
|
347
|
+
? number extends Length
|
348
|
+
? { value?: Args }
|
349
|
+
: 0 extends Length
|
350
|
+
? { value?: [] }
|
351
|
+
: { value: Args }
|
352
|
+
: never
|
353
|
+
: never;
|
354
|
+
|
355
|
+
export type Return<Name> = 0 extends 1 & Name
|
356
|
+
? any
|
357
|
+
: Name extends string
|
358
|
+
? Name extends keyof NativeTags
|
359
|
+
? NativeTags[Name]["return"]
|
360
|
+
: () => Element
|
361
|
+
: Name extends
|
362
|
+
| { _(): () => (input: any) => { return: infer Return } }
|
363
|
+
| Template<any, infer Return>
|
364
|
+
| Body<any, infer Return>
|
365
|
+
? Return
|
366
|
+
: never;
|
367
|
+
}
|
368
|
+
}
|