revojs 0.0.1 → 0.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/index.d.ts +34 -19
- package/dist/hooks/index.d.ts +8 -0
- package/dist/html/index.d.ts +27 -12
- package/dist/http/index.d.ts +37 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +476 -151
- package/dist/jsx/index.d.ts +362 -3
- package/dist/jsx/index.js +83 -1
- package/dist/presets/bun.js +6 -1
- package/dist/presets/cloudflare.d.ts +1 -1
- package/dist/presets/cloudflare.js +6 -1
- package/dist/router/index.d.ts +2 -3
- package/dist/runtime/index.d.ts +15 -15
- package/dist/signals/index.d.ts +23 -14
- package/package.json +3 -3
- package/dist/event/index.d.ts +0 -19
package/dist/app/index.d.ts
CHANGED
|
@@ -1,14 +1,22 @@
|
|
|
1
|
-
import type { Template } from "../html";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
10
|
-
export type
|
|
11
|
-
|
|
1
|
+
import type { Attributes, ComponentConstructor, Events, Template } from "../html";
|
|
2
|
+
import type { Middleware } from "../http";
|
|
3
|
+
import type { Route } from "../runtime";
|
|
4
|
+
export type NestedPartial<T> = T extends any[] ? T : T extends Record<string, any> ? {
|
|
5
|
+
[P in keyof T]?: NestedPartial<T[P]>;
|
|
6
|
+
} : T;
|
|
7
|
+
export type Content<T> = string & {
|
|
8
|
+
key: string;
|
|
9
|
+
};
|
|
10
|
+
export type InferContent<T> = T extends Content<infer U> ? U : unknown;
|
|
11
|
+
export type StaticContent = {
|
|
12
|
+
type: "static";
|
|
13
|
+
source: string;
|
|
14
|
+
include: Array<string>;
|
|
15
|
+
};
|
|
16
|
+
export type AssetContent = {
|
|
17
|
+
type: "asset";
|
|
18
|
+
source: string;
|
|
19
|
+
include: Array<string>;
|
|
12
20
|
};
|
|
13
21
|
export type ServerEntry = "revojs/presets/node" | "revojs/presets/deno" | "revojs/presets/bun" | "revojs/presets/cloudflare" | (string & {});
|
|
14
22
|
export type ClientConfig = {
|
|
@@ -17,16 +25,23 @@ export type ClientConfig = {
|
|
|
17
25
|
export type ServerConfig = {
|
|
18
26
|
entry: ServerEntry;
|
|
19
27
|
};
|
|
20
|
-
export type
|
|
21
|
-
|
|
22
|
-
|
|
28
|
+
export type DevelopmentConfig<T> = {
|
|
29
|
+
middleware: Array<Middleware<T>>;
|
|
30
|
+
};
|
|
31
|
+
export type Config<T> = {
|
|
23
32
|
client: ClientConfig;
|
|
24
|
-
server: ServerConfig;
|
|
33
|
+
server: false | ServerConfig;
|
|
34
|
+
content: Record<string, StaticContent | AssetContent>;
|
|
25
35
|
markdown: Record<string, Template>;
|
|
36
|
+
dev: DevelopmentConfig<T>;
|
|
26
37
|
};
|
|
27
|
-
export type App = {
|
|
28
|
-
config: Config
|
|
38
|
+
export type App<T> = {
|
|
39
|
+
config: Config<T>;
|
|
29
40
|
virtuals: Record<string, () => string>;
|
|
30
41
|
};
|
|
31
|
-
export declare const
|
|
32
|
-
export declare const
|
|
42
|
+
export declare const defineContent: <T>(key: string) => Content<T>;
|
|
43
|
+
export declare const getContent: <T>(key: string | Content<T>) => Promise<Record<string, () => Promise<T>>>;
|
|
44
|
+
export declare const createApp: <T>(config?: NestedPartial<Config<T>>) => App<T>;
|
|
45
|
+
export declare const STATIC_CONTENT: Content<string>;
|
|
46
|
+
export declare const PAGES_CONTENT: Content<ComponentConstructor<Events, Attributes>>;
|
|
47
|
+
export declare const ROUTES_CONTENT: Content<Route<unknown>>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type Descriptor } from "../html";
|
|
2
|
+
export declare class Hooks {
|
|
3
|
+
hooks: Map<string, Set<(value: any) => unknown>>;
|
|
4
|
+
constructor();
|
|
5
|
+
on: <T>(input: string | Descriptor<T>, invoke: (value: T) => unknown) => void;
|
|
6
|
+
dispatch: <T>(input: string | Descriptor<T>, value: T) => void;
|
|
7
|
+
}
|
|
8
|
+
export declare const defineHook: <T>(description?: string | number) => Descriptor<T>;
|
package/dist/html/index.d.ts
CHANGED
|
@@ -1,21 +1,26 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type HtmlAttributes } from "../jsx";
|
|
2
|
+
import { type State, type Value } from "../signals";
|
|
3
|
+
export type Descriptor<T> = {
|
|
4
|
+
key: symbol;
|
|
5
|
+
};
|
|
2
6
|
export type TypeOf<T> = {
|
|
3
7
|
(): T;
|
|
4
8
|
};
|
|
5
9
|
export type Infer<T> = T extends TypeOf<infer U> ? U : unknown;
|
|
6
|
-
export type
|
|
10
|
+
export type Primitiv = string | number | bigint | boolean | symbol | undefined | object | Function;
|
|
11
|
+
export type Slot = void | Primitiv | Template | Array<Slot> | (() => Slot);
|
|
7
12
|
export type Template = {
|
|
8
13
|
tag: string;
|
|
9
|
-
attributes: Record<string,
|
|
14
|
+
attributes: Record<string, Primitiv>;
|
|
10
15
|
children: Array<Slot>;
|
|
11
16
|
};
|
|
12
17
|
export type EventInput<T extends Events> = {
|
|
13
|
-
[K in keyof T]?: (event: Infer<T[K]["type"]>) => void;
|
|
18
|
+
[K in keyof T]?: (event: Infer<T[K]["type"]> extends Event ? Infer<T[K]["type"]> : CustomEvent<Infer<T[K]["type"]>>) => void;
|
|
14
19
|
};
|
|
15
20
|
export type AttributeInput<T extends Attributes> = {
|
|
16
|
-
[K in keyof T]?: Infer<T[K]["type"]
|
|
21
|
+
[K in keyof T]?: Value<Infer<T[K]["type"]>>;
|
|
17
22
|
};
|
|
18
|
-
export type Input<TEvents extends Events, TAttributes extends Attributes> = EventInput<TEvents> & AttributeInput<TAttributes
|
|
23
|
+
export type Input<TEvents extends Events, TAttributes extends Attributes> = EventInput<TEvents> & AttributeInput<TAttributes> & HtmlAttributes;
|
|
19
24
|
export type EventOutput<T extends Events> = {
|
|
20
25
|
[K in keyof T]?: (event: Infer<T[K]["type"]>) => void;
|
|
21
26
|
};
|
|
@@ -32,8 +37,8 @@ export type AttributeOptions<T> = {
|
|
|
32
37
|
type: T;
|
|
33
38
|
default?: Infer<T>;
|
|
34
39
|
};
|
|
35
|
-
export type Events = Record<string, EventOptions<
|
|
36
|
-
export type Attributes = Record<string, AttributeOptions<
|
|
40
|
+
export type Events = Record<string, EventOptions<Primitiv>>;
|
|
41
|
+
export type Attributes = Record<string, AttributeOptions<Primitiv>>;
|
|
37
42
|
export interface ComponentOptions<TEvents extends Events, TAttributes extends Attributes> {
|
|
38
43
|
name: string;
|
|
39
44
|
events?: TEvents;
|
|
@@ -45,13 +50,16 @@ export interface Component<TEvents extends Events, TAttributes extends Attribute
|
|
|
45
50
|
readonly events: EventOutput<TEvents>;
|
|
46
51
|
readonly attributes: State<AttributeOutput<TAttributes>>;
|
|
47
52
|
readonly shadowRoot: false | ShadowRootInit;
|
|
53
|
+
readonly context: Record<string, unknown>;
|
|
54
|
+
getContext: <T>(input: string | Descriptor<T>) => T;
|
|
55
|
+
setContext: <T>(input: string | Descriptor<T>, value: T) => void;
|
|
48
56
|
setup: () => Slot | Promise<Slot>;
|
|
49
57
|
}
|
|
50
58
|
export interface ComponentConstructor<TEvents extends Events, TAttributes extends Attributes> {
|
|
51
59
|
$name: string;
|
|
52
60
|
$events: TEvents;
|
|
53
61
|
$attributes: TAttributes;
|
|
54
|
-
new (input?: Input<TEvents, TAttributes>): Component<TEvents, TAttributes>;
|
|
62
|
+
new (input?: Input<TEvents, TAttributes>, context?: Record<string, unknown>): Component<TEvents, TAttributes>;
|
|
55
63
|
}
|
|
56
64
|
export interface CustomElement<TEvents extends Events, TAttributes extends Attributes> extends HTMLElement {
|
|
57
65
|
readonly component: Component<TEvents, TAttributes>;
|
|
@@ -59,10 +67,14 @@ export interface CustomElement<TEvents extends Events, TAttributes extends Attri
|
|
|
59
67
|
export interface CustomElementConstructor<TEvents extends Events, TAttributes extends Attributes> {
|
|
60
68
|
new (): CustomElement<TEvents, TAttributes>;
|
|
61
69
|
}
|
|
70
|
+
export declare const isTemplate: (value: object) => value is Template;
|
|
71
|
+
export declare const descriptor: <T>(descriptor: string | Descriptor<T>) => string;
|
|
72
|
+
export declare const defineContext: <T>(description?: string | number) => Descriptor<T>;
|
|
62
73
|
export declare const createElement: <TEvents extends Events, TAttributes extends Attributes>(input: string | ComponentConstructor<TEvents, TAttributes>, attributes?: AttributeInput<TAttributes>, ...children: Array<Slot>) => Slot;
|
|
63
74
|
export declare const toString: (slot: Slot) => string;
|
|
64
|
-
export declare const
|
|
65
|
-
export declare const
|
|
75
|
+
export declare const toFragment: (nodes: Array<Node>) => DocumentFragment;
|
|
76
|
+
export declare const renderToString: (slot: Slot, context: Record<string, unknown>) => Promise<string>;
|
|
77
|
+
export declare const renderToNode: (slot: Slot) => Promise<Node>;
|
|
66
78
|
export declare const defineComponent: <TEvents extends Events = {}, TAttributes extends Attributes = {}>(options: ComponentOptions<TEvents, TAttributes>) => ComponentConstructor<TEvents, TAttributes>;
|
|
67
79
|
export declare const toCustomElement: <TEvents extends Events = {}, TAttributes extends Attributes = {}>(component: ComponentConstructor<TEvents, TAttributes>) => CustomElementConstructor<TEvents, TAttributes>;
|
|
68
80
|
export declare const registerComponent: <TEvents extends Events = {}, TAttributes extends Attributes = {}>(component: ComponentConstructor<TEvents, TAttributes>) => ComponentConstructor<TEvents, TAttributes>;
|
|
@@ -70,6 +82,9 @@ export declare const isClient: () => boolean;
|
|
|
70
82
|
export declare const isServer: () => boolean;
|
|
71
83
|
export declare const addStyles: (...styles: Array<CSSStyleSheet>) => void;
|
|
72
84
|
export declare const getGlobalStyles: () => CSSStyleSheet[];
|
|
73
|
-
export declare
|
|
85
|
+
export declare const getCustomElement: (node: Node | null) => CustomElement<Events, Attributes> | undefined;
|
|
86
|
+
export declare const preventDefault: (event: Event) => void;
|
|
87
|
+
export declare const stopPropagation: (event: Event) => void;
|
|
88
|
+
export declare const stopImmediatePropagation: (event: Event) => void;
|
|
74
89
|
export declare let activeElement: CustomElement<Events, Attributes> | undefined;
|
|
75
90
|
export declare const components: Map<string, ComponentConstructor<Events, Attributes>>;
|
package/dist/http/index.d.ts
CHANGED
|
@@ -1,5 +1,42 @@
|
|
|
1
|
+
export type CookieOptions = {
|
|
2
|
+
domain?: string;
|
|
3
|
+
expires?: Date;
|
|
4
|
+
httpOnly?: boolean;
|
|
5
|
+
maxAge?: number;
|
|
6
|
+
path?: string;
|
|
7
|
+
priority?: "Low" | "Medium" | "High";
|
|
8
|
+
sameSite?: "Lax" | "Strict" | "None";
|
|
9
|
+
secure?: boolean;
|
|
10
|
+
};
|
|
1
11
|
export type HttpMethod = "GET" | "HEAD" | "PATCH" | "POST" | "PUT" | "DELETE" | "CONNECT" | "OPTIONS" | "TRACE";
|
|
2
12
|
export type Encoding = "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex";
|
|
3
13
|
export type StatusCode = 100 | 101 | 102 | 103 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 226 | 300 | 301 | 302 | 303 | 304 | 305 | 307 | 308 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 444 | 450 | 451 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | 504 | 506 | 507 | 508 | 509 | 510 | 511 | 521 | 522 | 523 | 525 | 530 | 599;
|
|
4
14
|
export type MimeType = "text/css" | "text/javascript" | "text/plain";
|
|
15
|
+
export type Context<T> = {
|
|
16
|
+
inputs: Record<string, string>;
|
|
17
|
+
variables: T;
|
|
18
|
+
};
|
|
19
|
+
export type Set = {
|
|
20
|
+
status?: StatusCode;
|
|
21
|
+
message?: string;
|
|
22
|
+
headers: Headers;
|
|
23
|
+
};
|
|
24
|
+
export type Event<T> = {
|
|
25
|
+
request: Request;
|
|
26
|
+
response: Set;
|
|
27
|
+
context: Context<T>;
|
|
28
|
+
};
|
|
29
|
+
export type Handle<T> = (event: Event<T>) => void | Response | Promise<void | Response>;
|
|
30
|
+
export type Middleware<T> = (event: Event<T>, next: Handle<T>) => void | Response | Promise<void | Response>;
|
|
31
|
+
export declare const createEvent: <T>(request: Request, context: Context<T>) => Event<T>;
|
|
32
|
+
export declare const sendText: <T>(event: Event<T>, text: string) => Response;
|
|
33
|
+
export declare const sendHtml: <T>(event: Event<T>, text: string) => Response;
|
|
34
|
+
export declare const sendJson: <TValue, T>(event: Event<T>, value: TValue) => Response;
|
|
35
|
+
export declare const sendRedirect: <T>(event: Event<T>, path: string) => Response;
|
|
36
|
+
export declare const sendBadRequest: <T>(event: Event<T>, text: string) => Response;
|
|
37
|
+
export declare const sendUnauthorized: <T>(event: Event<T>) => Response;
|
|
38
|
+
export declare const getRequestUrl: <T>(event: Event<T> | Request) => URL;
|
|
39
|
+
export declare const getCookies: <T>(event: Event<T>) => Record<string, string>;
|
|
40
|
+
export declare const getSetCookies: <T>(event: Event<T>) => Record<string, string>;
|
|
41
|
+
export declare const setCookie: <T>(event: Event<T>, name: string, value: string, options?: CookieOptions) => void;
|
|
5
42
|
export declare const getMimeType: (file: string) => MimeType;
|
package/dist/index.d.ts
CHANGED