revojs 0.0.2 → 0.0.4
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 +18 -22
- package/dist/hooks/index.d.ts +9 -0
- package/dist/html/index.d.ts +30 -15
- package/dist/http/index.d.ts +37 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +476 -202
- package/dist/jsx/index.d.ts +361 -2
- package/dist/jsx/index.js +90 -1
- package/dist/markdown/index.d.ts +2 -2
- 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 +1 -1
- package/dist/runtime/index.d.ts +16 -15
- package/dist/signals/index.d.ts +21 -15
- package/dist/types/index.d.ts +4 -0
- package/package.json +3 -3
- package/dist/event/index.d.ts +0 -19
package/dist/app/index.d.ts
CHANGED
|
@@ -1,17 +1,9 @@
|
|
|
1
|
-
import type
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
source: string;
|
|
8
|
-
include: Array<string>;
|
|
9
|
-
};
|
|
10
|
-
export type AssetContent = {
|
|
11
|
-
type: "asset";
|
|
12
|
-
source: string;
|
|
13
|
-
include: Array<string>;
|
|
14
|
-
};
|
|
1
|
+
import { type Template } from "../html";
|
|
2
|
+
import type { Middleware } from "../http";
|
|
3
|
+
export type NestedPartial<T> = T extends any[] ? T : T extends Record<string, any> ? {
|
|
4
|
+
[P in keyof T]?: NestedPartial<T[P]>;
|
|
5
|
+
} : T;
|
|
6
|
+
export type Environment = "CLIENT" | "SERVER";
|
|
15
7
|
export type ServerEntry = "revojs/presets/node" | "revojs/presets/deno" | "revojs/presets/bun" | "revojs/presets/cloudflare" | (string & {});
|
|
16
8
|
export type ClientConfig = {
|
|
17
9
|
entry: string;
|
|
@@ -19,15 +11,19 @@ export type ClientConfig = {
|
|
|
19
11
|
export type ServerConfig = {
|
|
20
12
|
entry: ServerEntry;
|
|
21
13
|
};
|
|
22
|
-
export type
|
|
14
|
+
export type DevelopmentConfig<T> = {
|
|
15
|
+
middleware: Array<Middleware<T>>;
|
|
16
|
+
};
|
|
17
|
+
export type Config<T> = {
|
|
23
18
|
client: ClientConfig;
|
|
24
|
-
server: ServerConfig;
|
|
25
|
-
content: Record<string, StaticContent | AssetContent>;
|
|
19
|
+
server: false | ServerConfig;
|
|
26
20
|
markdown: Record<string, Template>;
|
|
21
|
+
dev: DevelopmentConfig<T>;
|
|
27
22
|
};
|
|
28
|
-
export type App = {
|
|
29
|
-
config: Config
|
|
30
|
-
virtuals: Record<string, () => string>;
|
|
23
|
+
export type App<T> = {
|
|
24
|
+
config: Config<T>;
|
|
25
|
+
virtuals: Record<string, (environment: Environment) => string>;
|
|
31
26
|
};
|
|
32
|
-
export declare const
|
|
33
|
-
export declare const
|
|
27
|
+
export declare const getRoutes: <T>() => Promise<Record<string, () => Promise<T>>>;
|
|
28
|
+
export declare const getAssets: <T>() => Promise<Record<string, () => Promise<T>>>;
|
|
29
|
+
export declare const createApp: <T>(config?: NestedPartial<Config<T>>) => App<T>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Scope } from "../signals";
|
|
2
|
+
import { type Descriptor } from "../types";
|
|
3
|
+
export declare class Hooks {
|
|
4
|
+
readonly hooks: Map<string, Set<(value: any) => unknown>>;
|
|
5
|
+
constructor();
|
|
6
|
+
on: <T>(scope: Scope, input: string | Descriptor<T>, invoke: (value: T) => unknown) => number;
|
|
7
|
+
dispatch: <T>(input: string | Descriptor<T>, value: T) => void;
|
|
8
|
+
}
|
|
9
|
+
export declare const defineHook: <T>(description?: string | number) => Descriptor<T>;
|
package/dist/html/index.d.ts
CHANGED
|
@@ -1,21 +1,24 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Hooks } from "../hooks";
|
|
2
|
+
import { type HtmlAttributes } from "../jsx";
|
|
3
|
+
import { Scope, type State, type Value } from "../signals";
|
|
4
|
+
import { type Descriptor } from "../types";
|
|
2
5
|
export type TypeOf<T> = {
|
|
3
6
|
(): T;
|
|
4
7
|
};
|
|
5
8
|
export type Infer<T> = T extends TypeOf<infer U> ? U : unknown;
|
|
6
|
-
export type Slot =
|
|
9
|
+
export type Slot = unknown | Template | Array<Slot> | (() => Slot);
|
|
7
10
|
export type Template = {
|
|
8
11
|
tag: string;
|
|
9
|
-
attributes: Record<string,
|
|
12
|
+
attributes: Record<string, unknown>;
|
|
10
13
|
children: Array<Slot>;
|
|
11
14
|
};
|
|
12
15
|
export type EventInput<T extends Events> = {
|
|
13
|
-
[K in keyof T]?: (event: Infer<T[K]["type"]>) => void;
|
|
16
|
+
[K in keyof T]?: (event: Infer<T[K]["type"]> extends Event ? Infer<T[K]["type"]> : CustomEvent<Infer<T[K]["type"]>>) => void;
|
|
14
17
|
};
|
|
15
18
|
export type AttributeInput<T extends Attributes> = {
|
|
16
|
-
[K in keyof T]?: Infer<T[K]["type"]>;
|
|
19
|
+
[K in keyof T]?: Value<Infer<T[K]["type"]> | undefined>;
|
|
17
20
|
};
|
|
18
|
-
export type Input<TEvents extends Events, TAttributes extends Attributes> = EventInput<TEvents> & AttributeInput<TAttributes
|
|
21
|
+
export type Input<TEvents extends Events, TAttributes extends Attributes> = EventInput<TEvents> & AttributeInput<TAttributes> & HtmlAttributes;
|
|
19
22
|
export type EventOutput<T extends Events> = {
|
|
20
23
|
[K in keyof T]?: (event: Infer<T[K]["type"]>) => void;
|
|
21
24
|
};
|
|
@@ -32,8 +35,8 @@ export type AttributeOptions<T> = {
|
|
|
32
35
|
type: T;
|
|
33
36
|
default?: Infer<T>;
|
|
34
37
|
};
|
|
35
|
-
export type Events = Record<string, EventOptions<
|
|
36
|
-
export type Attributes = Record<string, AttributeOptions<
|
|
38
|
+
export type Events = Record<string, EventOptions<unknown>>;
|
|
39
|
+
export type Attributes = Record<string, AttributeOptions<unknown>>;
|
|
37
40
|
export interface ComponentOptions<TEvents extends Events, TAttributes extends Attributes> {
|
|
38
41
|
name: string;
|
|
39
42
|
events?: TEvents;
|
|
@@ -42,16 +45,23 @@ export interface ComponentOptions<TEvents extends Events, TAttributes extends At
|
|
|
42
45
|
setup: (component: Component<TEvents, TAttributes>) => Slot | Promise<Slot>;
|
|
43
46
|
}
|
|
44
47
|
export interface Component<TEvents extends Events, TAttributes extends Attributes> {
|
|
48
|
+
readonly scope: Scope;
|
|
49
|
+
readonly hooks: Hooks;
|
|
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
|
+
readonly host?: CustomElement<TEvents, TAttributes>;
|
|
55
|
+
getContext: <T>(input: string | Descriptor<T>) => T;
|
|
56
|
+
setContext: <T>(input: string | Descriptor<T>, value: T) => void;
|
|
57
|
+
onMounted: (invoke: (input: HTMLElement) => void | Promise<void>) => void;
|
|
48
58
|
setup: () => Slot | Promise<Slot>;
|
|
49
59
|
}
|
|
50
60
|
export interface ComponentConstructor<TEvents extends Events, TAttributes extends Attributes> {
|
|
51
61
|
$name: string;
|
|
52
62
|
$events: TEvents;
|
|
53
63
|
$attributes: TAttributes;
|
|
54
|
-
new (input?: Input<TEvents, TAttributes>): Component<TEvents, TAttributes>;
|
|
64
|
+
new (input?: Input<TEvents, TAttributes>, context?: Record<string, unknown>, host?: CustomElement<TEvents, TAttributes>): Component<TEvents, TAttributes>;
|
|
55
65
|
}
|
|
56
66
|
export interface CustomElement<TEvents extends Events, TAttributes extends Attributes> extends HTMLElement {
|
|
57
67
|
readonly component: Component<TEvents, TAttributes>;
|
|
@@ -59,17 +69,22 @@ export interface CustomElement<TEvents extends Events, TAttributes extends Attri
|
|
|
59
69
|
export interface CustomElementConstructor<TEvents extends Events, TAttributes extends Attributes> {
|
|
60
70
|
new (): CustomElement<TEvents, TAttributes>;
|
|
61
71
|
}
|
|
72
|
+
export declare const isTemplate: (value: object) => value is Template;
|
|
73
|
+
export declare const defineContext: <T>(description?: string | number) => Descriptor<T>;
|
|
62
74
|
export declare const createElement: <TEvents extends Events, TAttributes extends Attributes>(input: string | ComponentConstructor<TEvents, TAttributes>, attributes?: AttributeInput<TAttributes>, ...children: Array<Slot>) => Slot;
|
|
63
75
|
export declare const toString: (slot: Slot) => string;
|
|
64
|
-
export declare const
|
|
65
|
-
export declare const
|
|
76
|
+
export declare const toFragment: (nodes: Array<Node>) => DocumentFragment;
|
|
77
|
+
export declare const renderToString: (slot: Slot, context: Record<string, unknown>) => Promise<string>;
|
|
78
|
+
export declare const renderToNode: (scope: Scope, slot: Slot) => Promise<Node>;
|
|
66
79
|
export declare const defineComponent: <TEvents extends Events = {}, TAttributes extends Attributes = {}>(options: ComponentOptions<TEvents, TAttributes>) => ComponentConstructor<TEvents, TAttributes>;
|
|
67
80
|
export declare const toCustomElement: <TEvents extends Events = {}, TAttributes extends Attributes = {}>(component: ComponentConstructor<TEvents, TAttributes>) => CustomElementConstructor<TEvents, TAttributes>;
|
|
68
81
|
export declare const registerComponent: <TEvents extends Events = {}, TAttributes extends Attributes = {}>(component: ComponentConstructor<TEvents, TAttributes>) => ComponentConstructor<TEvents, TAttributes>;
|
|
82
|
+
export declare const getGlobalStyles: () => CSSStyleSheet[];
|
|
83
|
+
export declare const getCustomElement: (node: Node | null) => CustomElement<Events, Attributes> | undefined;
|
|
69
84
|
export declare const isClient: () => boolean;
|
|
70
85
|
export declare const isServer: () => boolean;
|
|
71
|
-
export declare const
|
|
72
|
-
export declare const
|
|
73
|
-
export declare
|
|
74
|
-
export declare
|
|
86
|
+
export declare const preventDefault: (event: Event) => void;
|
|
87
|
+
export declare const stopPropagation: (event: Event) => void;
|
|
88
|
+
export declare const stopImmediatePropagation: (event: Event) => void;
|
|
89
|
+
export declare const MOUNTED_HOOK: Descriptor<HTMLElement>;
|
|
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 = Record<string, unknown>> = {
|
|
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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export * from "./app";
|
|
2
|
-
export * from "./
|
|
2
|
+
export * from "./hooks";
|
|
3
3
|
export * from "./html";
|
|
4
4
|
export * from "./http";
|
|
5
5
|
export * from "./markdown";
|
|
@@ -7,3 +7,4 @@ export * from "./radix";
|
|
|
7
7
|
export * from "./router";
|
|
8
8
|
export * from "./runtime";
|
|
9
9
|
export * from "./signals";
|
|
10
|
+
export * from "./types";
|