ovr 2.0.1 → 2.0.3
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/app/action.d.ts +1 -1
- package/dist/app/context.js +2 -2
- package/dist/app/page.d.ts +1 -1
- package/dist/jsx/elements.d.ts +1 -0
- package/dist/jsx/index.js +12 -1
- package/dist/jsx/is-generator.d.ts +1 -0
- package/dist/jsx/is-generator.js +7 -0
- package/dist/jsx/yield-controller.d.ts +4 -0
- package/dist/jsx/yield-controller.js +8 -0
- package/package.json +1 -1
package/dist/app/action.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type JSX } from "../jsx/index.js";
|
|
2
2
|
import type { ExtractParams } from "../types/index.js";
|
|
3
3
|
import type { Middleware, Params } from "./index.js";
|
|
4
|
-
type FormProps<P extends Params> =
|
|
4
|
+
type FormProps<P extends Params> = JSX.IntrinsicElements["form"] & (keyof P extends never ? {
|
|
5
5
|
params?: never;
|
|
6
6
|
} : {
|
|
7
7
|
params: P;
|
package/dist/app/context.js
CHANGED
|
@@ -21,9 +21,9 @@ export class Context {
|
|
|
21
21
|
*
|
|
22
22
|
* @example { slug: "my-post" }
|
|
23
23
|
*/
|
|
24
|
-
params
|
|
24
|
+
params; // set after match
|
|
25
25
|
/** The matched `Route` instance. */
|
|
26
|
-
route
|
|
26
|
+
route; // set after match
|
|
27
27
|
/** [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Response/Response#body) */
|
|
28
28
|
body = null;
|
|
29
29
|
/** [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status) */
|
package/dist/app/page.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type JSX } from "../jsx/index.js";
|
|
2
2
|
import type { ExtractParams } from "../types/index.js";
|
|
3
3
|
import type { Middleware, Params } from "./index.js";
|
|
4
|
-
type AnchorProps<P extends Params> =
|
|
4
|
+
type AnchorProps<P extends Params> = JSX.IntrinsicElements["a"] & (keyof P extends never ? {
|
|
5
5
|
params?: never;
|
|
6
6
|
} : {
|
|
7
7
|
params: P;
|
package/dist/jsx/elements.d.ts
CHANGED
|
@@ -264,6 +264,7 @@ type InputAttributes = Attributes<{
|
|
|
264
264
|
step: string;
|
|
265
265
|
type: "button" | "checkbox" | "color" | "date" | "datetime-local" | "email" | "file" | "hidden" | "image" | "month" | "number" | "password" | "radio" | "range" | "reset" | "search" | "submit" | "tel" | "text" | "time" | "url" | "week";
|
|
266
266
|
value: string;
|
|
267
|
+
webkitdirectory: boolean;
|
|
267
268
|
width: string;
|
|
268
269
|
}, never>;
|
|
269
270
|
type InsAttributes = Attributes<{
|
package/dist/jsx/index.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { isGenerator } from "./is-generator.js";
|
|
1
2
|
import { merge } from "./merge-async-iterables.js";
|
|
3
|
+
import { YieldController } from "./yield-controller.js";
|
|
2
4
|
// https://developer.mozilla.org/en-US/docs/Glossary/Void_element#self-closing_tags
|
|
3
5
|
const voidElements = new Set([
|
|
4
6
|
"area",
|
|
@@ -15,6 +17,7 @@ const voidElements = new Set([
|
|
|
15
17
|
"track",
|
|
16
18
|
"wbr",
|
|
17
19
|
]);
|
|
20
|
+
const yieldController = new YieldController();
|
|
18
21
|
/**
|
|
19
22
|
* The main function of the JSX transform cycle, each time JSX is encountered
|
|
20
23
|
* it is passed into this function to be resolved.
|
|
@@ -82,15 +85,23 @@ export async function* toGenerator(element) {
|
|
|
82
85
|
yield* toGenerator(children);
|
|
83
86
|
}
|
|
84
87
|
else if (Symbol.iterator in element) {
|
|
88
|
+
if (isGenerator(element)) {
|
|
89
|
+
// process lazily - avoid loading all in memory
|
|
90
|
+
for (const children of element)
|
|
91
|
+
yield* toGenerator(children);
|
|
92
|
+
}
|
|
85
93
|
const generators = [];
|
|
86
94
|
for (const children of element) {
|
|
87
|
-
// this is where to escape string children if added in the future
|
|
88
95
|
generators.push(toGenerator(children));
|
|
89
96
|
}
|
|
90
97
|
let queue = new Array(generators.length).fill("");
|
|
91
98
|
const complete = new Set();
|
|
92
99
|
let current = 0;
|
|
93
100
|
for await (const { index, result } of merge(generators)) {
|
|
101
|
+
const maybeYield = yieldController.maybeYield();
|
|
102
|
+
// yield control back to event loop to stream current
|
|
103
|
+
if (maybeYield instanceof Promise)
|
|
104
|
+
await maybeYield;
|
|
94
105
|
if (result.done) {
|
|
95
106
|
complete.add(index);
|
|
96
107
|
if (index === current) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isGenerator: <T, R = unknown, N = unknown>(iterable: Iterable<T, R, N>) => iterable is Generator<T, R, N>;
|