ovr 4.2.7 → 4.4.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/dist/app/context.d.ts.map +1 -1
- package/dist/app/context.js +5 -21
- package/dist/app/helper/get.d.ts +3 -3
- package/dist/app/helper/get.d.ts.map +1 -1
- package/dist/app/helper/get.js +4 -9
- package/dist/app/helper/index.d.ts +31 -3
- package/dist/app/helper/index.d.ts.map +1 -1
- package/dist/app/helper/index.js +40 -20
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/jsx/index.d.ts +9 -1
- package/dist/jsx/index.d.ts.map +1 -1
- package/dist/jsx/index.js +30 -1
- package/dist/jsx/intrinsic-elements.d.ts +54 -54
- package/dist/jsx/intrinsic-elements.d.ts.map +1 -1
- package/dist/types/index.d.ts +0 -16
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/app/context.ts +5 -28
- package/src/app/helper/get.ts +11 -12
- package/src/app/helper/index.ts +87 -26
- package/src/index.ts +1 -1
- package/src/jsx/index.ts +37 -1
- package/src/jsx/intrinsic-elements.ts +68 -60
- package/src/types/index.ts +0 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/app/context.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,GAAG,
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/app/context.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,GAAG,EAAY,MAAM,iBAAiB,CAAC;AACrD,OAAO,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEtD,OAAO,EAEN,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,MAAM,YAAY,CAAC;AAGpB,KAAK,MAAM,GAAG,CAAC,KAAK,EAAE;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IAAI,EAAE,MAAM,CAAC,EAAE,MAAM;IAO3C;;;;;OAKG;IACH,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,MAAM,CAAC,EAAE,MAAM;IAO/B;;;;;OAKG;IACH,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,CAAC,EAAE,MAAM;IAOpC;;;;;;;;;;;OAWG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,GAAG,EAAE,MAAM,GAAE,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAS;IAK1E;;OAEG;IACH,IAAI,CAAC,GAAG,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE;IAK9B;;OAEG;IACH,MAAM,CAAC,GAAG,MAAM,EAAE,MAAM,EAAE;IAK1B;;;;;OAKG;IACH,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM;IAyCvC;;;;;;;;OAQG;IACH,IAAI,CAAC,CAAC,EAAE,MAAM;IAed;;OAEG;IACH,KAAK;IA2BL;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,MAAM,CAAC,GAAG;CAUV"}
|
package/dist/app/context.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Chunk } from "../jsx/chunk/index.js";
|
|
2
|
-
import {
|
|
2
|
+
import { toStream } from "../jsx/index.js";
|
|
3
3
|
import { hash } from "../util/hash.js";
|
|
4
4
|
import { App, } from "./index.js";
|
|
5
5
|
import { Memo } from "./memo/index.js";
|
|
@@ -50,8 +50,6 @@ export class Context {
|
|
|
50
50
|
memo = this.#memo.use;
|
|
51
51
|
/** Check if the `Response` has been built already */
|
|
52
52
|
#finalized = false;
|
|
53
|
-
/** Used across requests */
|
|
54
|
-
static #encoder = new TextEncoder();
|
|
55
53
|
static #headClose = "</head>";
|
|
56
54
|
static #bodyClose = "</body>";
|
|
57
55
|
constructor(req, url, trailingSlash, base, error, notFound) {
|
|
@@ -182,7 +180,7 @@ export class Context {
|
|
|
182
180
|
for (let i = this.#layouts.length - 1; i >= 0; i--) {
|
|
183
181
|
Page = this.#layouts[i]({ children: Page });
|
|
184
182
|
}
|
|
185
|
-
let
|
|
183
|
+
let stream;
|
|
186
184
|
if (this.base) {
|
|
187
185
|
// inject into base
|
|
188
186
|
const elements = this.base.split(Context.#headClose);
|
|
@@ -201,27 +199,13 @@ export class Context {
|
|
|
201
199
|
}
|
|
202
200
|
elements[3] = bodyParts[0];
|
|
203
201
|
elements.push(Page, Context.#bodyClose + bodyParts[1]);
|
|
204
|
-
|
|
202
|
+
stream = toStream(elements.map((el) => typeof el === "string" ? new Chunk(el, true) : el));
|
|
205
203
|
}
|
|
206
204
|
else {
|
|
207
205
|
// HTML partial - just use the layouts + page
|
|
208
|
-
|
|
206
|
+
stream = toStream(Page);
|
|
209
207
|
}
|
|
210
|
-
this.html(
|
|
211
|
-
async pull(c) {
|
|
212
|
-
const result = await gen.next();
|
|
213
|
-
if (result.done) {
|
|
214
|
-
c.close();
|
|
215
|
-
gen.return();
|
|
216
|
-
return;
|
|
217
|
-
}
|
|
218
|
-
// need to encode for Node JS (ex: during prerendering)
|
|
219
|
-
c.enqueue(Context.#encoder.encode(result.value.value));
|
|
220
|
-
},
|
|
221
|
-
cancel() {
|
|
222
|
-
gen.return();
|
|
223
|
-
},
|
|
224
|
-
}), status);
|
|
208
|
+
this.html(stream, status);
|
|
225
209
|
}
|
|
226
210
|
/**
|
|
227
211
|
* Generates an etag from a hash of the string provided.
|
package/dist/app/helper/get.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { type JSX } from "../../jsx/index.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { ExtractParams } from "../../types/index.js";
|
|
3
3
|
import type { Middleware } from "../index.js";
|
|
4
|
-
import { Helper } from "./index.js";
|
|
4
|
+
import { Helper, type HelperComponentProps } from "./index.js";
|
|
5
5
|
export declare class Get<Pattern extends string = string> extends Helper<Pattern> {
|
|
6
6
|
/** `<a>` component with preset `href` attribute. */
|
|
7
|
-
Anchor: (props:
|
|
7
|
+
Anchor: (props: JSX.IntrinsicElements["a"] & HelperComponentProps<ExtractParams<Pattern>>) => JSX.Element;
|
|
8
8
|
/**
|
|
9
9
|
* @param pattern Route pattern
|
|
10
10
|
* @param middleware GET middleware
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get.d.ts","sourceRoot":"","sources":["../../../src/app/helper/get.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,EAAO,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"get.d.ts","sourceRoot":"","sources":["../../../src/app/helper/get.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,EAAO,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,KAAK,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAE/D,qBAAa,GAAG,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM,CAAE,SAAQ,MAAM,CAAC,OAAO,CAAC;IACxE,oDAAoD;IACpD,MAAM,EAAE,CACP,KAAK,EAAE,GAAG,CAAC,iBAAiB,CAAC,GAAG,CAAC,GAChC,oBAAoB,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,KACzC,GAAG,CAAC,OAAO,CAAC;IAEjB;;;;;;;;;;;;;;;;;;;OAmBG;gBAEF,OAAO,EAAE,OAAO,EAChB,GAAG,UAAU,EAAE,UAAU,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,EAAE;CAYpD"}
|
package/dist/app/helper/get.js
CHANGED
|
@@ -25,14 +25,9 @@ export class Get extends Helper {
|
|
|
25
25
|
*/
|
|
26
26
|
constructor(pattern, ...middleware) {
|
|
27
27
|
super("GET", pattern, ...middleware);
|
|
28
|
-
this.Anchor = (
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
// @ts-expect-error - do not have to pass in {} if no params
|
|
33
|
-
params),
|
|
34
|
-
...rest,
|
|
35
|
-
});
|
|
36
|
-
};
|
|
28
|
+
this.Anchor = ({ params, search, hash, ...rest }) => jsx("a", {
|
|
29
|
+
href: this.url({ params, search, hash }),
|
|
30
|
+
...rest,
|
|
31
|
+
});
|
|
37
32
|
}
|
|
38
33
|
}
|
|
@@ -1,6 +1,27 @@
|
|
|
1
1
|
import { type JSX } from "../../jsx/index.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { Params } from "../../trie/index.js";
|
|
3
|
+
import type { ExtractParams, InsertParams } from "../../types/index.js";
|
|
3
4
|
import type { Middleware } from "../index.js";
|
|
5
|
+
export type HelperComponentProps<P extends Params> = {
|
|
6
|
+
/**
|
|
7
|
+
* Passed into `URLSearchParams` constructor.
|
|
8
|
+
*
|
|
9
|
+
* [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams)
|
|
10
|
+
*/
|
|
11
|
+
search?: string | Iterable<[string, string]> | Record<string, string>;
|
|
12
|
+
/**
|
|
13
|
+
* Hash (fragment) of the URL. `"#"` prefix is added if not present.
|
|
14
|
+
*
|
|
15
|
+
* [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/URL/hash)
|
|
16
|
+
*/
|
|
17
|
+
hash?: string;
|
|
18
|
+
} & (keyof P extends never ? {
|
|
19
|
+
/** Route pattern does not contain parameters */
|
|
20
|
+
params?: never;
|
|
21
|
+
} : {
|
|
22
|
+
/** Route pattern parameters */
|
|
23
|
+
params: P;
|
|
24
|
+
});
|
|
4
25
|
export declare class Helper<Pattern extends string> {
|
|
5
26
|
#private;
|
|
6
27
|
/** Extracted parameters type for the pattern */
|
|
@@ -10,10 +31,17 @@ export declare class Helper<Pattern extends string> {
|
|
|
10
31
|
/** GET middleware */
|
|
11
32
|
middleware: Middleware<any>[];
|
|
12
33
|
/** `<button>` component with preset `formaction` and `formmethod` attributes. */
|
|
13
|
-
Button: (props:
|
|
34
|
+
Button: (props: JSX.IntrinsicElements["button"] & HelperComponentProps<ExtractParams<Pattern>>) => JSX.Element;
|
|
14
35
|
/** `<form>` component with preset `method` and `action` attributes. */
|
|
15
|
-
Form: (props:
|
|
36
|
+
Form: (props: JSX.IntrinsicElements["form"] & HelperComponentProps<ExtractParams<Pattern>>) => JSX.Element;
|
|
16
37
|
constructor(method: string, pattern: Pattern, ...middleware: Middleware<ExtractParams<Pattern>>[]);
|
|
38
|
+
/**
|
|
39
|
+
* Constructs a _relative_ URL for the route.
|
|
40
|
+
*
|
|
41
|
+
* @param [options] Options with type safe parameters
|
|
42
|
+
* @returns `pathname` + `search` + `hash`
|
|
43
|
+
*/
|
|
44
|
+
url(...[options]: keyof ExtractParams<Pattern> extends never ? [HelperComponentProps<ExtractParams<Pattern>>] | [] : [HelperComponentProps<ExtractParams<Pattern>>]): string;
|
|
17
45
|
/**
|
|
18
46
|
* @param [params] Parameters to insert
|
|
19
47
|
* @returns Resolved `pathname` with params
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/app/helper/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,EAAO,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/app/helper/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,EAAO,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACxE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,MAAM,MAAM,oBAAoB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AAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,GACnD,CAAC,oBAAoB,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC;IA6BlD;;;OAGG;IACH,QAAQ,CAAC,MAAM,SAAS,aAAa,CAAC,OAAO,CAAC,EAC7C,GAAG,CAAC,MAAM,CAAC,EAAE,MAAM,MAAM,SAAS,KAAK,GAAG,EAAE,GAAG,CAAC,MAAM,CAAC,GACrD,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC;CA2BhC"}
|
package/dist/app/helper/index.js
CHANGED
|
@@ -14,26 +14,46 @@ export class Helper {
|
|
|
14
14
|
this.pattern = pattern;
|
|
15
15
|
this.middleware = middleware;
|
|
16
16
|
this.#parts = pattern.split("/");
|
|
17
|
-
this.Button = (
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
17
|
+
this.Button = ({ params, search, hash, ...rest }) => jsx("button", {
|
|
18
|
+
formaction: this.url({ params, search, hash }),
|
|
19
|
+
formmethod: method,
|
|
20
|
+
...rest,
|
|
21
|
+
});
|
|
22
|
+
this.Form = ({ params, search, hash, ...rest }) => jsx("form", {
|
|
23
|
+
action: this.url({ params, search, hash }),
|
|
24
|
+
method,
|
|
25
|
+
...rest,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Constructs a _relative_ URL for the route.
|
|
30
|
+
*
|
|
31
|
+
* @param [options] Options with type safe parameters
|
|
32
|
+
* @returns `pathname` + `search` + `hash`
|
|
33
|
+
*/
|
|
34
|
+
url(...[options]) {
|
|
35
|
+
const pathname = this.pathname(
|
|
36
|
+
// @ts-expect-error - do not have to pass in {} if no params
|
|
37
|
+
options?.params);
|
|
38
|
+
const search = options?.search
|
|
39
|
+
? "?" +
|
|
40
|
+
new URLSearchParams(options.search)
|
|
41
|
+
: "";
|
|
42
|
+
// adding # prefix if not present matches the URL setter:
|
|
43
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/URL/hash
|
|
44
|
+
let hash;
|
|
45
|
+
if (options?.hash) {
|
|
46
|
+
if (options.hash.startsWith("#")) {
|
|
47
|
+
hash = options.hash;
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
hash = "#" + options.hash;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
hash = "";
|
|
55
|
+
}
|
|
56
|
+
return pathname + search + hash;
|
|
37
57
|
}
|
|
38
58
|
/**
|
|
39
59
|
* @param [params] Parameters to insert
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { jsx, toGenerator, toString, type JSX } from "./jsx/index.js";
|
|
1
|
+
export { jsx, toGenerator, toStream, toString, type JSX } from "./jsx/index.js";
|
|
2
2
|
export { Chunk } from "./jsx/chunk/index.js";
|
|
3
3
|
export { Trie, Route } from "./trie/index.js";
|
|
4
4
|
export { App, type Middleware } from "./app/index.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,QAAQ,EAAE,KAAK,GAAG,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAChF,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,GAAG,EAAE,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/jsx/index.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ export declare function Fragment(props?: {
|
|
|
31
31
|
}): AsyncGenerator<Chunk, void, unknown>;
|
|
32
32
|
/**
|
|
33
33
|
* @param element
|
|
34
|
-
* @yields
|
|
34
|
+
* @yields `Chunk`s of HTML as the `Element` resolves.
|
|
35
35
|
*/
|
|
36
36
|
export declare function toGenerator(element: JSX.Element): AsyncGenerator<Chunk, void, unknown>;
|
|
37
37
|
/**
|
|
@@ -46,4 +46,12 @@ export declare function toGenerator(element: JSX.Element): AsyncGenerator<Chunk,
|
|
|
46
46
|
* @returns Concatenated HTML
|
|
47
47
|
*/
|
|
48
48
|
export declare const toString: (element: JSX.Element) => Promise<string>;
|
|
49
|
+
/**
|
|
50
|
+
* `toGenerator` piped into a `ReadableStream`.
|
|
51
|
+
* Use `toGenerator` when possible to avoid the overhead of the stream.
|
|
52
|
+
*
|
|
53
|
+
* @param element
|
|
54
|
+
* @returns `ReadableStream` of HTML
|
|
55
|
+
*/
|
|
56
|
+
export declare const toStream: (element: JSX.Element) => ReadableStream<Uint8Array<ArrayBufferLike>>;
|
|
49
57
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/jsx/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/jsx/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,a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
CHANGED
|
@@ -69,7 +69,7 @@ export async function* Fragment(props = {}) {
|
|
|
69
69
|
}
|
|
70
70
|
/**
|
|
71
71
|
* @param element
|
|
72
|
-
* @yields
|
|
72
|
+
* @yields `Chunk`s of HTML as the `Element` resolves.
|
|
73
73
|
*/
|
|
74
74
|
export async function* toGenerator(element) {
|
|
75
75
|
// modifications
|
|
@@ -178,3 +178,32 @@ export async function* toGenerator(element) {
|
|
|
178
178
|
* @returns Concatenated HTML
|
|
179
179
|
*/
|
|
180
180
|
export const toString = async (element) => (await Array.fromAsync(toGenerator(element))).join("");
|
|
181
|
+
/** Single encoder to use across requests. */
|
|
182
|
+
const encoder = new TextEncoder();
|
|
183
|
+
/**
|
|
184
|
+
* `toGenerator` piped into a `ReadableStream`.
|
|
185
|
+
* Use `toGenerator` when possible to avoid the overhead of the stream.
|
|
186
|
+
*
|
|
187
|
+
* @param element
|
|
188
|
+
* @returns `ReadableStream` of HTML
|
|
189
|
+
*/
|
|
190
|
+
export const toStream = (element) => {
|
|
191
|
+
const gen = toGenerator(element);
|
|
192
|
+
return new ReadableStream({
|
|
193
|
+
async pull(c) {
|
|
194
|
+
const result = await gen.next();
|
|
195
|
+
if (result.done) {
|
|
196
|
+
c.close();
|
|
197
|
+
gen.return();
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
c.enqueue(
|
|
201
|
+
// need to encode for Node JS (ex: during prerendering)
|
|
202
|
+
// faster than piping through a `TextEncoderStream`
|
|
203
|
+
encoder.encode(result.value.value));
|
|
204
|
+
},
|
|
205
|
+
cancel() {
|
|
206
|
+
gen.return();
|
|
207
|
+
},
|
|
208
|
+
});
|
|
209
|
+
};
|
|
@@ -30,7 +30,7 @@ type Attributes<P extends Props = Props, Children = JSX.Element> = Partial<{
|
|
|
30
30
|
slot: string;
|
|
31
31
|
spellcheck: "true" | "false";
|
|
32
32
|
style: string;
|
|
33
|
-
tabindex: number;
|
|
33
|
+
tabindex: string | number;
|
|
34
34
|
title: string;
|
|
35
35
|
translate: string;
|
|
36
36
|
virtualkeyboardpolicy: string;
|
|
@@ -61,16 +61,16 @@ type Attributes<P extends Props = Props, Children = JSX.Element> = Partial<{
|
|
|
61
61
|
type SharedAttributes = {
|
|
62
62
|
autocomplete: "on" | "off" | (string & {});
|
|
63
63
|
blocking: "render";
|
|
64
|
-
crossorigin: boolean | "anonymous" | "use-credentials";
|
|
65
|
-
referrerpolicy: "no-referrer" | "no-referrer-when-downgrade" | "origin" | "origin-when-cross-origin" | "same-origin" | "strict-origin" | "strict-origin-when-cross-origin" | "unsafe-url";
|
|
66
|
-
target: "_self" | "_blank" | "_parent" | "_top";
|
|
67
|
-
preload: "none" | "metadata" | "auto";
|
|
68
64
|
controlslist: "nodownload" | "nofullscreen" | "noremoteplayback" | (string & {});
|
|
65
|
+
crossorigin: boolean | "anonymous" | "use-credentials";
|
|
69
66
|
enctype: "application/x-www-form-urlencoded" | "multipart/form-data" | "text/plain";
|
|
70
|
-
method: "get" | "post" | "dialog";
|
|
71
|
-
loading: "eager" | "lazy";
|
|
72
67
|
fetchpriority: "high" | "low" | "auto";
|
|
68
|
+
loading: "eager" | "lazy";
|
|
69
|
+
method: "get" | "post" | "dialog";
|
|
73
70
|
popovertargetaction: "hide" | "show" | "toggle";
|
|
71
|
+
preload: "none" | "metadata" | "auto";
|
|
72
|
+
referrerpolicy: "no-referrer" | "no-referrer-when-downgrade" | "origin" | "origin-when-cross-origin" | "same-origin" | "strict-origin" | "strict-origin-when-cross-origin" | "unsafe-url";
|
|
73
|
+
target: "_self" | "_blank" | "_parent" | "_top";
|
|
74
74
|
};
|
|
75
75
|
type AAttributes = Attributes<{
|
|
76
76
|
download: string | boolean;
|
|
@@ -153,15 +153,15 @@ type ButtonAttributes = Attributes<{
|
|
|
153
153
|
value: string;
|
|
154
154
|
}>;
|
|
155
155
|
type CanvasAttributes = Attributes<{
|
|
156
|
-
height: string;
|
|
156
|
+
height: string | number;
|
|
157
157
|
["moz-opaque"]: boolean;
|
|
158
|
-
width: string;
|
|
158
|
+
width: string | number;
|
|
159
159
|
}>;
|
|
160
160
|
type ColAttributes = Attributes<{
|
|
161
|
-
span: string;
|
|
161
|
+
span: string | number;
|
|
162
162
|
}, undefined>;
|
|
163
163
|
type ColgroupAttributes = Attributes<{
|
|
164
|
-
span: string;
|
|
164
|
+
span: string | number;
|
|
165
165
|
}>;
|
|
166
166
|
type DataAttributes = Attributes<{
|
|
167
167
|
value: string;
|
|
@@ -178,10 +178,10 @@ type DialogAttributes = Attributes<{
|
|
|
178
178
|
open: boolean;
|
|
179
179
|
}>;
|
|
180
180
|
type EmbedAttributes = Attributes<{
|
|
181
|
-
height: string;
|
|
181
|
+
height: string | number;
|
|
182
182
|
src: string;
|
|
183
183
|
type: string;
|
|
184
|
-
width: string;
|
|
184
|
+
width: string | number;
|
|
185
185
|
}, undefined>;
|
|
186
186
|
type FieldsetAttributes = Attributes<{
|
|
187
187
|
disabled: boolean;
|
|
@@ -205,14 +205,14 @@ type HtmlAttributes = Attributes<{
|
|
|
205
205
|
type IframeAttributes = Attributes<{
|
|
206
206
|
allow: string;
|
|
207
207
|
allowfullscreen: boolean;
|
|
208
|
-
height: string;
|
|
208
|
+
height: string | number;
|
|
209
209
|
loading: SharedAttributes["loading"];
|
|
210
210
|
name: string;
|
|
211
211
|
referrerpolicy: SharedAttributes["referrerpolicy"];
|
|
212
212
|
sandbox: string;
|
|
213
213
|
src: string;
|
|
214
214
|
srcdoc: string;
|
|
215
|
-
width: string;
|
|
215
|
+
width: string | number;
|
|
216
216
|
}>;
|
|
217
217
|
type ImgAttributes = Attributes<{
|
|
218
218
|
alt: string;
|
|
@@ -220,14 +220,14 @@ type ImgAttributes = Attributes<{
|
|
|
220
220
|
decoding: "sync" | "async" | "auto";
|
|
221
221
|
elementtiming: string;
|
|
222
222
|
fetchpriority: SharedAttributes["fetchpriority"];
|
|
223
|
-
height: string;
|
|
223
|
+
height: string | number;
|
|
224
224
|
ismap: boolean;
|
|
225
225
|
loading: SharedAttributes["loading"];
|
|
226
226
|
referrerpolicy: SharedAttributes["referrerpolicy"];
|
|
227
227
|
sizes: string;
|
|
228
228
|
src: string;
|
|
229
229
|
srcset: string;
|
|
230
|
-
width: string;
|
|
230
|
+
width: string | number;
|
|
231
231
|
usemap: string;
|
|
232
232
|
}, undefined>;
|
|
233
233
|
type InputAttributes = Attributes<{
|
|
@@ -246,10 +246,10 @@ type InputAttributes = Attributes<{
|
|
|
246
246
|
formtarget: SharedAttributes["target"];
|
|
247
247
|
height: string;
|
|
248
248
|
list: string;
|
|
249
|
-
max: string;
|
|
250
|
-
maxlength: string;
|
|
251
|
-
min: string;
|
|
252
|
-
minlength: string;
|
|
249
|
+
max: string | number;
|
|
250
|
+
maxlength: string | number;
|
|
251
|
+
min: string | number;
|
|
252
|
+
minlength: string | number;
|
|
253
253
|
multiple: boolean;
|
|
254
254
|
name: string;
|
|
255
255
|
pattern: string;
|
|
@@ -258,11 +258,11 @@ type InputAttributes = Attributes<{
|
|
|
258
258
|
popovertargetaction: SharedAttributes["popovertargetaction"];
|
|
259
259
|
readonly: boolean;
|
|
260
260
|
required: boolean;
|
|
261
|
-
size: string;
|
|
261
|
+
size: string | number;
|
|
262
262
|
src: string;
|
|
263
|
-
step: string;
|
|
263
|
+
step: string | number;
|
|
264
264
|
type: "button" | "checkbox" | "color" | "date" | "datetime-local" | "email" | "file" | "hidden" | "image" | "month" | "number" | "password" | "radio" | "range" | "reset" | "search" | "submit" | "tel" | "text" | "time" | "url" | "week";
|
|
265
|
-
value: string;
|
|
265
|
+
value: string | number;
|
|
266
266
|
webkitdirectory: boolean;
|
|
267
267
|
width: string;
|
|
268
268
|
}, never>;
|
|
@@ -274,9 +274,9 @@ type LabelAttributes = Attributes<{
|
|
|
274
274
|
for: string;
|
|
275
275
|
}>;
|
|
276
276
|
type LiAttributes = Attributes<{
|
|
277
|
-
value: string;
|
|
277
|
+
value: string | number;
|
|
278
278
|
}>;
|
|
279
|
-
type
|
|
279
|
+
type LinkAttributes = Attributes<{
|
|
280
280
|
as: "audio" | "document" | "embed" | "fetch" | "font" | "image" | "object" | "script" | "style" | "track" | "video" | "worker";
|
|
281
281
|
blocking: SharedAttributes["blocking"];
|
|
282
282
|
crossorigin: SharedAttributes["crossorigin"];
|
|
@@ -304,25 +304,25 @@ type MetaAttributes = Attributes<{
|
|
|
304
304
|
name: "application-name" | "author" | "description" | "generator" | "keywords" | "theme-color" | "viewport" | (string & {});
|
|
305
305
|
}, undefined>;
|
|
306
306
|
type MeterAttributes = Attributes<{
|
|
307
|
-
value: string;
|
|
308
|
-
min: string;
|
|
309
|
-
max: string;
|
|
310
|
-
low: string;
|
|
311
|
-
high: string;
|
|
312
|
-
optimum: string;
|
|
307
|
+
value: string | number;
|
|
308
|
+
min: string | number;
|
|
309
|
+
max: string | number;
|
|
310
|
+
low: string | number;
|
|
311
|
+
high: string | number;
|
|
312
|
+
optimum: string | number;
|
|
313
313
|
form: string;
|
|
314
314
|
}>;
|
|
315
315
|
type ObjectAttributes = Attributes<{
|
|
316
316
|
data: string;
|
|
317
317
|
form: string;
|
|
318
|
-
height: string;
|
|
318
|
+
height: string | number;
|
|
319
319
|
name: string;
|
|
320
320
|
type: string;
|
|
321
|
-
width: string;
|
|
321
|
+
width: string | number;
|
|
322
322
|
}>;
|
|
323
323
|
type OlAttributes = Attributes<{
|
|
324
324
|
reversed: boolean;
|
|
325
|
-
start: string;
|
|
325
|
+
start: string | number;
|
|
326
326
|
type: "a" | "A" | "i" | "I" | "1";
|
|
327
327
|
}>;
|
|
328
328
|
type OptgroupAttributes = Attributes<{
|
|
@@ -341,8 +341,8 @@ type OutputAttributes = Attributes<{
|
|
|
341
341
|
name: string;
|
|
342
342
|
}>;
|
|
343
343
|
type ProgressAttributes = Attributes<{
|
|
344
|
-
max: string;
|
|
345
|
-
value: string;
|
|
344
|
+
max: string | number;
|
|
345
|
+
value: string | number;
|
|
346
346
|
}>;
|
|
347
347
|
type QAttributes = Attributes<{
|
|
348
348
|
cite: string;
|
|
@@ -366,28 +366,28 @@ type SelectAttributes = Attributes<{
|
|
|
366
366
|
multiple: boolean;
|
|
367
367
|
name: string;
|
|
368
368
|
required: boolean;
|
|
369
|
-
size: string;
|
|
369
|
+
size: string | number;
|
|
370
370
|
}>;
|
|
371
371
|
type SlotAttributes = Attributes<{
|
|
372
372
|
name: string;
|
|
373
373
|
}>;
|
|
374
374
|
type SourceAttributes = Attributes<{
|
|
375
|
-
|
|
375
|
+
height: string | number;
|
|
376
|
+
media: string;
|
|
377
|
+
sizes: string;
|
|
376
378
|
src: string;
|
|
377
379
|
srcset: string;
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
height: string;
|
|
381
|
-
width: string;
|
|
380
|
+
type: string;
|
|
381
|
+
width: string | number;
|
|
382
382
|
}, undefined>;
|
|
383
383
|
type StyleAttributes = Attributes<{
|
|
384
384
|
blocking: SharedAttributes["blocking"];
|
|
385
385
|
media: string;
|
|
386
386
|
}>;
|
|
387
387
|
type TdAttributes = Attributes<{
|
|
388
|
-
colspan: string;
|
|
388
|
+
colspan: string | number;
|
|
389
389
|
headers: string;
|
|
390
|
-
rowspan: string;
|
|
390
|
+
rowspan: string | number;
|
|
391
391
|
}>;
|
|
392
392
|
type TemplateAttributes = Attributes<{
|
|
393
393
|
shadowrootmode: "open" | "closed";
|
|
@@ -397,24 +397,24 @@ type TemplateAttributes = Attributes<{
|
|
|
397
397
|
}>;
|
|
398
398
|
type TextareaAttributes = Attributes<{
|
|
399
399
|
autocomplete: SharedAttributes["autocomplete"];
|
|
400
|
-
cols: string;
|
|
400
|
+
cols: string | number;
|
|
401
401
|
dirname: string;
|
|
402
402
|
disabled: boolean;
|
|
403
403
|
form: string;
|
|
404
|
-
maxlength: string;
|
|
405
|
-
minlength: string;
|
|
404
|
+
maxlength: string | number;
|
|
405
|
+
minlength: string | number;
|
|
406
406
|
name: string;
|
|
407
407
|
placeholder: string;
|
|
408
408
|
readonly: boolean;
|
|
409
409
|
required: boolean;
|
|
410
|
-
rows: string;
|
|
410
|
+
rows: string | number;
|
|
411
411
|
wrap: "hard" | "soft" | "off";
|
|
412
412
|
}>;
|
|
413
413
|
type ThAttributes = Attributes<{
|
|
414
414
|
abbr: string;
|
|
415
|
-
colspan: string;
|
|
415
|
+
colspan: string | number;
|
|
416
416
|
headers: string;
|
|
417
|
-
rowspan: string;
|
|
417
|
+
rowspan: string | number;
|
|
418
418
|
scope: "row" | "col" | "rowgroup" | "colgroup" | (string & {});
|
|
419
419
|
}>;
|
|
420
420
|
type TimeAttributes = Attributes<{
|
|
@@ -434,14 +434,14 @@ type VideoAttributes = Attributes<{
|
|
|
434
434
|
crossorigin: SharedAttributes["crossorigin"];
|
|
435
435
|
disablepictureinpicture: boolean;
|
|
436
436
|
disableremoteplayback: boolean;
|
|
437
|
-
height: string;
|
|
437
|
+
height: string | number;
|
|
438
438
|
loop: boolean;
|
|
439
439
|
muted: boolean;
|
|
440
440
|
playsinline: boolean;
|
|
441
441
|
poster: string;
|
|
442
442
|
preload: SharedAttributes["preload"];
|
|
443
443
|
src: string;
|
|
444
|
-
width: string;
|
|
444
|
+
width: string | number;
|
|
445
445
|
}>;
|
|
446
446
|
export type IntrinsicElements = Record<string, Attributes> & {
|
|
447
447
|
a: AAttributes;
|
|
@@ -501,7 +501,7 @@ export type IntrinsicElements = Record<string, Attributes> & {
|
|
|
501
501
|
label: LabelAttributes;
|
|
502
502
|
legend: Attributes;
|
|
503
503
|
li: LiAttributes;
|
|
504
|
-
link:
|
|
504
|
+
link: LinkAttributes;
|
|
505
505
|
main: Attributes;
|
|
506
506
|
map: MapAttributes;
|
|
507
507
|
mark: Attributes;
|