marko 5.37.25 → 5.37.26
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.
|
@@ -232,6 +232,23 @@ var proto = AsyncStream.prototype = {
|
|
|
232
232
|
};
|
|
233
233
|
},
|
|
234
234
|
|
|
235
|
+
toReadable() {
|
|
236
|
+
return new ReadableStream({
|
|
237
|
+
async start(ctrl) {
|
|
238
|
+
const encoder = new TextEncoder();
|
|
239
|
+
try {
|
|
240
|
+
for await (const chunk of this) {
|
|
241
|
+
ctrl.enqueue(encoder.encode(chunk));
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
ctrl.close();
|
|
245
|
+
} catch (err) {
|
|
246
|
+
ctrl.error(err);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
},
|
|
251
|
+
|
|
235
252
|
sync: function () {
|
|
236
253
|
this._sync = true;
|
|
237
254
|
},
|
package/index.d.ts
CHANGED
|
@@ -28,8 +28,28 @@ declare global {
|
|
|
28
28
|
$global?: Global;
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
+
/** The result of calling `template.render`. */
|
|
32
|
+
export type RenderedTemplate<
|
|
33
|
+
Component extends Marko.Component = Marko.Component,
|
|
34
|
+
> = Promise<RenderResult<Component>> &
|
|
35
|
+
AsyncIterable<string> & {
|
|
36
|
+
toReadable(): ReadableStream<Uint8Array<ArrayBufferLike>>;
|
|
37
|
+
pipe(stream: {
|
|
38
|
+
write(chunk: string): unknown;
|
|
39
|
+
end(): unknown;
|
|
40
|
+
flush?(): void;
|
|
41
|
+
}): void;
|
|
42
|
+
toString(): string;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
/** The result of calling `template.mount`. */
|
|
46
|
+
export type MountedTemplate<Input = unknown> = {
|
|
47
|
+
update(input: Marko.TemplateInput<Input>): void;
|
|
48
|
+
destroy(): void;
|
|
49
|
+
};
|
|
50
|
+
|
|
31
51
|
export interface Out<Component extends Marko.Component = Marko.Component>
|
|
32
|
-
extends
|
|
52
|
+
extends Marko.RenderedTemplate<Component> {
|
|
33
53
|
/** The underlying ReadableStream Marko is writing into. */
|
|
34
54
|
stream: unknown;
|
|
35
55
|
/** A mutable global object for the current render. */
|
|
@@ -42,8 +62,6 @@ declare global {
|
|
|
42
62
|
write(val: string | void): this;
|
|
43
63
|
/** Write javascript content to be merged with the scripts Marko sends out on the next flush. */
|
|
44
64
|
script(val: string | void): this;
|
|
45
|
-
/** Returns the currently rendered html content. */
|
|
46
|
-
toString(): string;
|
|
47
65
|
/** Starts a new async/forked stream. */
|
|
48
66
|
beginAsync(options?: {
|
|
49
67
|
name?: string;
|
|
@@ -65,8 +83,6 @@ declare global {
|
|
|
65
83
|
): this;
|
|
66
84
|
/** Register a callback executed when the last async out has completed. */
|
|
67
85
|
onLast(listener: (next: () => void) => unknown): this;
|
|
68
|
-
/** Pipe Marko's stream to another stream. */
|
|
69
|
-
pipe(stream: unknown): this;
|
|
70
86
|
/** Emits an error on the stream. */
|
|
71
87
|
error(e: Error): this;
|
|
72
88
|
/** Schedules a Marko to flush buffered html to the underlying stream. */
|
|
@@ -256,6 +272,13 @@ declare global {
|
|
|
256
272
|
abstract stream(
|
|
257
273
|
input: Marko.TemplateInput<Input>,
|
|
258
274
|
): ReadableStream<string> & NodeJS.ReadableStream;
|
|
275
|
+
|
|
276
|
+
/** Render and attach the template to a DOM node. */
|
|
277
|
+
abstract mount(
|
|
278
|
+
input: Marko.TemplateInput<Input>,
|
|
279
|
+
reference: Node,
|
|
280
|
+
position?: "afterbegin" | "afterend" | "beforebegin" | "beforeend",
|
|
281
|
+
): Marko.MountedTemplate<typeof input>;
|
|
259
282
|
/** @marko-overload-end */
|
|
260
283
|
}
|
|
261
284
|
|
package/package.json
CHANGED
|
@@ -232,6 +232,23 @@ var proto = (AsyncStream.prototype = {
|
|
|
232
232
|
});
|
|
233
233
|
},
|
|
234
234
|
|
|
235
|
+
toReadable() {
|
|
236
|
+
return new ReadableStream({
|
|
237
|
+
async start(ctrl) {
|
|
238
|
+
const encoder = new TextEncoder();
|
|
239
|
+
try {
|
|
240
|
+
for await (const chunk of this) {
|
|
241
|
+
ctrl.enqueue(encoder.encode(chunk));
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
ctrl.close();
|
|
245
|
+
} catch (err) {
|
|
246
|
+
ctrl.error(err);
|
|
247
|
+
}
|
|
248
|
+
},
|
|
249
|
+
});
|
|
250
|
+
},
|
|
251
|
+
|
|
235
252
|
sync: function () {
|
|
236
253
|
this._sync = true;
|
|
237
254
|
},
|