revojs 0.0.88 → 0.1.1
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/index.d.ts +176 -9
- package/dist/index.js +220 -915
- package/dist/vite/index.d.ts +53 -0
- package/dist/vite/index.js +468 -0
- package/package.json +11 -10
- package/src/types/index.d.ts +20 -16
- package/dist/app/index.d.ts +0 -36
- package/dist/html/index.d.ts +0 -110
- package/dist/http/index.d.ts +0 -41
- package/dist/jsx/index.d.ts +0 -371
- package/dist/jsx/index.js +0 -160
- package/dist/locale/index.d.ts +0 -26
- package/dist/radix/index.d.ts +0 -12
- package/dist/router/index.d.ts +0 -45
- package/dist/runtime/index.d.ts +0 -55
- package/dist/schema/index.d.ts +0 -24
- package/dist/signals/index.d.ts +0 -44
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,176 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
//#region src/shared/index.d.ts
|
|
2
|
+
type Descriptor<T> = string & {
|
|
3
|
+
[descriptor]: T;
|
|
4
|
+
};
|
|
5
|
+
type Context = Record<string, unknown>;
|
|
6
|
+
type Output<T> = Success<T> | Failure;
|
|
7
|
+
type InferInput<T extends Schema> = NonNullable<T["~standard"]["types"]>["input"];
|
|
8
|
+
type InferOutput<T extends Schema> = NonNullable<T["~standard"]["types"]>["output"];
|
|
9
|
+
type Mergeable<T> = { [P in keyof T]?: Mergeable<T[P]> };
|
|
10
|
+
interface Issue {
|
|
11
|
+
readonly message: string;
|
|
12
|
+
}
|
|
13
|
+
interface Success<T> {
|
|
14
|
+
readonly value: T;
|
|
15
|
+
}
|
|
16
|
+
interface Failure {
|
|
17
|
+
readonly issues: ReadonlyArray<Issue>;
|
|
18
|
+
}
|
|
19
|
+
interface Schema<T = unknown, TOutput = T> {
|
|
20
|
+
readonly "~standard": {
|
|
21
|
+
readonly validate: (value: unknown) => Output<TOutput> | Promise<Output<TOutput>>;
|
|
22
|
+
readonly types?: {
|
|
23
|
+
readonly input: T;
|
|
24
|
+
readonly output: TOutput;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
declare class StopEvent extends Event {
|
|
29
|
+
constructor();
|
|
30
|
+
}
|
|
31
|
+
declare class Scope extends EventTarget {
|
|
32
|
+
parentScope?: Scope;
|
|
33
|
+
readonly context: Context;
|
|
34
|
+
constructor(parentScope?: Scope);
|
|
35
|
+
getContext<T>(input: Descriptor<T>): T;
|
|
36
|
+
setContext<T>(input: Descriptor<T>, value: T): void;
|
|
37
|
+
onStop(input: (event: StopEvent) => void): void;
|
|
38
|
+
stop(): boolean;
|
|
39
|
+
}
|
|
40
|
+
declare function defineContext<T>(name: string): Descriptor<T>;
|
|
41
|
+
declare function isClient(): boolean;
|
|
42
|
+
declare function isServer(): boolean;
|
|
43
|
+
declare function isFailure<T>(result: Output<T>): result is Failure;
|
|
44
|
+
declare function parseSchema<T extends Schema>(scope: Scope, schema: T, value: unknown): InferOutput<T>;
|
|
45
|
+
declare function mergeObjects<TBase, TInput>(base: TBase, input: TInput): TBase & TInput;
|
|
46
|
+
declare const descriptor: unique symbol;
|
|
47
|
+
declare global {
|
|
48
|
+
interface ElementEventMap {
|
|
49
|
+
stop: StopEvent;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
//#endregion
|
|
53
|
+
//#region src/app/index.d.ts
|
|
54
|
+
type Environment = typeof CLIENT | typeof SERVER;
|
|
55
|
+
type Virtual = (environment: Environment) => undefined | string | Promise<string>;
|
|
56
|
+
interface Config {
|
|
57
|
+
modules: Array<Module>;
|
|
58
|
+
client?: string;
|
|
59
|
+
server?: string;
|
|
60
|
+
sources: Record<string, Source>;
|
|
61
|
+
}
|
|
62
|
+
interface Module {
|
|
63
|
+
config?: Mergeable<Config>;
|
|
64
|
+
setup?: (app: App) => void | Promise<void>;
|
|
65
|
+
}
|
|
66
|
+
interface Source {
|
|
67
|
+
match: string;
|
|
68
|
+
entries: Array<string>;
|
|
69
|
+
suffix?: string;
|
|
70
|
+
}
|
|
71
|
+
interface App {
|
|
72
|
+
config: Config;
|
|
73
|
+
virtuals: Record<string, Virtual>;
|
|
74
|
+
alias: Record<string, string>;
|
|
75
|
+
}
|
|
76
|
+
declare function createApp(inputConfig?: Mergeable<Config>): App;
|
|
77
|
+
declare const SERVER = "ssr";
|
|
78
|
+
declare const CLIENT = "client";
|
|
79
|
+
//#endregion
|
|
80
|
+
//#region src/server/index.d.ts
|
|
81
|
+
type CookiePriority = "Low" | "Medium" | "High";
|
|
82
|
+
type CookieSameSite = "Lax" | "Strict" | "None";
|
|
83
|
+
type HttpMethod = "GET" | "HEAD" | "PATCH" | "POST" | "PUT" | "DELETE" | "CONNECT" | "OPTIONS" | "TRACE";
|
|
84
|
+
type Encoding = "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex";
|
|
85
|
+
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;
|
|
86
|
+
type MimeType = "text/plain" | "text/css" | "text/html" | "text/csv" | "text/javascript" | "application/json" | "application/xml" | "image/jpeg" | "image/png" | "image/gif" | "image/webp" | "image/svg+xml" | "image/bmp" | "image/x-icon" | "font/ttf" | "font/otf" | "font/woff" | "font/woff2" | "audio/mpeg" | "audio/wav" | "audio/ogg" | "audio/mp4" | "video/mp4" | "video/webm" | "video/ogg" | "video/quicktime" | "video/x-msvideo" | "application/zip" | "application/vnd.rar" | "application/x-tar" | "application/gzip" | "application/x-7z-compressed" | "application/pdf" | "application/msword" | "application/vnd.openxmlformats-officedocument.wordprocessingml.document" | "application/vnd.ms-excel" | "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" | "application/vnd.ms-powerpoint" | "application/vnd.openxmlformats-officedocument.presentationml.presentation" | "application/vnd.microsoft.portable-executable" | "application/vnd.android.package-archive";
|
|
87
|
+
type Result = void | Response | Promise<void | Response>;
|
|
88
|
+
type Node<T> = WildcardNode<T> | ParameterNode<T> | PathNode<T>;
|
|
89
|
+
interface CookieOptions {
|
|
90
|
+
domain?: string;
|
|
91
|
+
expires?: Date;
|
|
92
|
+
httpOnly?: boolean;
|
|
93
|
+
maxAge?: number;
|
|
94
|
+
path?: string;
|
|
95
|
+
priority?: CookiePriority;
|
|
96
|
+
sameSite?: CookieSameSite;
|
|
97
|
+
secure?: boolean;
|
|
98
|
+
}
|
|
99
|
+
interface ResponseConfig {
|
|
100
|
+
status?: StatusCode;
|
|
101
|
+
message?: string;
|
|
102
|
+
headers: Headers;
|
|
103
|
+
}
|
|
104
|
+
interface RouterContext {
|
|
105
|
+
route: Node<Route>;
|
|
106
|
+
segments: Array<string>;
|
|
107
|
+
parameters: Record<string, string>;
|
|
108
|
+
}
|
|
109
|
+
interface ServerContext<T extends Context = Context> {
|
|
110
|
+
request: Request;
|
|
111
|
+
response: ResponseConfig;
|
|
112
|
+
variables: T;
|
|
113
|
+
}
|
|
114
|
+
interface Route {
|
|
115
|
+
fetch: (scope: Scope) => Result;
|
|
116
|
+
}
|
|
117
|
+
interface Middleware {
|
|
118
|
+
fetch: (scope: Scope, next?: () => Result) => Result;
|
|
119
|
+
}
|
|
120
|
+
interface Server {
|
|
121
|
+
router: Router;
|
|
122
|
+
pipeline: Array<Middleware>;
|
|
123
|
+
fetch: (scope: Scope) => Promise<Response>;
|
|
124
|
+
}
|
|
125
|
+
interface WildcardNode<T> {
|
|
126
|
+
type: "WILDCARD";
|
|
127
|
+
value?: T;
|
|
128
|
+
parameter: string;
|
|
129
|
+
children: Record<string, Node<T>>;
|
|
130
|
+
}
|
|
131
|
+
interface ParameterNode<T> {
|
|
132
|
+
type: "PARAMETER";
|
|
133
|
+
value?: T;
|
|
134
|
+
parameter: string;
|
|
135
|
+
children: Record<string, Node<T>>;
|
|
136
|
+
}
|
|
137
|
+
interface PathNode<T> {
|
|
138
|
+
type: "PATH";
|
|
139
|
+
value?: T;
|
|
140
|
+
children: Record<string, Node<T>>;
|
|
141
|
+
}
|
|
142
|
+
declare class Radix<T> {
|
|
143
|
+
readonly rootNode: Node<T>;
|
|
144
|
+
constructor();
|
|
145
|
+
use(path: string, value: T): Node<T>;
|
|
146
|
+
}
|
|
147
|
+
declare class Router extends Radix<Route> implements Middleware {
|
|
148
|
+
fetch(scope: Scope, next?: () => Result): Result;
|
|
149
|
+
}
|
|
150
|
+
declare function defineRoute<T extends Route>(route: T): T;
|
|
151
|
+
declare function defineMiddleware<T extends Middleware>(middleware: T): T;
|
|
152
|
+
declare function useServer<T extends Context>(scope: Scope): ServerContext<T>;
|
|
153
|
+
declare function useUrl(scope: Scope, base?: string): URL;
|
|
154
|
+
declare function useQuery(scope: Scope): Record<string, string>;
|
|
155
|
+
declare function useQuery<T extends Schema>(scope: Scope, schema: T): InferOutput<T>;
|
|
156
|
+
declare function useCookies(scope: Scope): Record<string, string>;
|
|
157
|
+
declare function useCookies<T extends Schema>(scope: Scope, schema: T): InferOutput<T>;
|
|
158
|
+
declare function useSetCookies(scope: Scope): Record<string, string>;
|
|
159
|
+
declare function useSetCookies<T extends Schema>(scope: Scope, schema: T): InferOutput<T>;
|
|
160
|
+
declare function setCookie(scope: Scope, name: string, value: string, options?: CookieOptions): void;
|
|
161
|
+
declare function sendText(scope: Scope, text: string, config?: Mergeable<ResponseConfig>): Response;
|
|
162
|
+
declare function sendHtml(scope: Scope, text: string, config?: Mergeable<ResponseConfig>): Response;
|
|
163
|
+
declare function sendJson<T>(scope: Scope, value: T, config?: Mergeable<ResponseConfig>): Response;
|
|
164
|
+
declare function sendRedirect(scope: Scope, path: string, config?: Mergeable<ResponseConfig>): Response;
|
|
165
|
+
declare function sendBadRequest(scope: Scope, text: string, config?: Mergeable<ResponseConfig>): Response;
|
|
166
|
+
declare function sendUnauthorized(scope: Scope, config?: Mergeable<ResponseConfig>): Response;
|
|
167
|
+
declare function mimeType(file: string): MimeType;
|
|
168
|
+
declare function toRoutePath(path: string): [string, string | undefined];
|
|
169
|
+
declare function createServer(): Promise<Server>;
|
|
170
|
+
declare const ROUTER_CONTEXT: Descriptor<RouterContext>;
|
|
171
|
+
declare const SERVER_CONTEXT: Descriptor<ServerContext<Context>>;
|
|
172
|
+
declare const WILDCARD = "$";
|
|
173
|
+
declare const PARAMETER = ":";
|
|
174
|
+
declare const mimeTypes: Record<string, MimeType>;
|
|
175
|
+
//#endregion
|
|
176
|
+
export { App, CLIENT, Config, Context, CookieOptions, CookiePriority, CookieSameSite, Descriptor, Encoding, Environment, Failure, HttpMethod, InferInput, InferOutput, Issue, Mergeable, Middleware, MimeType, Module, Node, Output, PARAMETER, ParameterNode, PathNode, ROUTER_CONTEXT, Radix, ResponseConfig, Result, Route, Router, RouterContext, SERVER, SERVER_CONTEXT, Schema, Scope, Server, ServerContext, Source, StatusCode, StopEvent, Success, Virtual, WILDCARD, WildcardNode, createApp, createServer, defineContext, defineMiddleware, defineRoute, isClient, isFailure, isServer, mergeObjects, mimeType, mimeTypes, parseSchema, sendBadRequest, sendHtml, sendJson, sendRedirect, sendText, sendUnauthorized, setCookie, toRoutePath, useCookies, useQuery, useServer, useSetCookies, useUrl };
|