@buenojs/bueno 0.8.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/.env.example +109 -0
- package/.github/workflows/ci.yml +31 -0
- package/LICENSE +21 -0
- package/README.md +892 -0
- package/architecture.md +652 -0
- package/bun.lock +70 -0
- package/dist/cli/index.js +3233 -0
- package/dist/index.js +9014 -0
- package/package.json +77 -0
- package/src/cache/index.ts +795 -0
- package/src/cli/ARCHITECTURE.md +837 -0
- package/src/cli/bin.ts +10 -0
- package/src/cli/commands/build.ts +425 -0
- package/src/cli/commands/dev.ts +248 -0
- package/src/cli/commands/generate.ts +541 -0
- package/src/cli/commands/help.ts +55 -0
- package/src/cli/commands/index.ts +112 -0
- package/src/cli/commands/migration.ts +355 -0
- package/src/cli/commands/new.ts +804 -0
- package/src/cli/commands/start.ts +208 -0
- package/src/cli/core/args.ts +283 -0
- package/src/cli/core/console.ts +349 -0
- package/src/cli/core/index.ts +60 -0
- package/src/cli/core/prompt.ts +424 -0
- package/src/cli/core/spinner.ts +265 -0
- package/src/cli/index.ts +135 -0
- package/src/cli/templates/deploy.ts +295 -0
- package/src/cli/templates/docker.ts +307 -0
- package/src/cli/templates/index.ts +24 -0
- package/src/cli/utils/fs.ts +428 -0
- package/src/cli/utils/index.ts +8 -0
- package/src/cli/utils/strings.ts +197 -0
- package/src/config/env.ts +408 -0
- package/src/config/index.ts +506 -0
- package/src/config/loader.ts +329 -0
- package/src/config/merge.ts +285 -0
- package/src/config/types.ts +320 -0
- package/src/config/validation.ts +441 -0
- package/src/container/forward-ref.ts +143 -0
- package/src/container/index.ts +386 -0
- package/src/context/index.ts +360 -0
- package/src/database/index.ts +1142 -0
- package/src/database/migrations/index.ts +371 -0
- package/src/database/schema/index.ts +619 -0
- package/src/frontend/api-routes.ts +640 -0
- package/src/frontend/bundler.ts +643 -0
- package/src/frontend/console-client.ts +419 -0
- package/src/frontend/console-stream.ts +587 -0
- package/src/frontend/dev-server.ts +846 -0
- package/src/frontend/file-router.ts +611 -0
- package/src/frontend/frameworks/index.ts +106 -0
- package/src/frontend/frameworks/react.ts +85 -0
- package/src/frontend/frameworks/solid.ts +104 -0
- package/src/frontend/frameworks/svelte.ts +110 -0
- package/src/frontend/frameworks/vue.ts +92 -0
- package/src/frontend/hmr-client.ts +663 -0
- package/src/frontend/hmr.ts +728 -0
- package/src/frontend/index.ts +342 -0
- package/src/frontend/islands.ts +552 -0
- package/src/frontend/isr.ts +555 -0
- package/src/frontend/layout.ts +475 -0
- package/src/frontend/ssr/react.ts +446 -0
- package/src/frontend/ssr/solid.ts +523 -0
- package/src/frontend/ssr/svelte.ts +546 -0
- package/src/frontend/ssr/vue.ts +504 -0
- package/src/frontend/ssr.ts +699 -0
- package/src/frontend/types.ts +2274 -0
- package/src/health/index.ts +604 -0
- package/src/index.ts +410 -0
- package/src/lock/index.ts +587 -0
- package/src/logger/index.ts +444 -0
- package/src/logger/transports/index.ts +969 -0
- package/src/metrics/index.ts +494 -0
- package/src/middleware/built-in.ts +360 -0
- package/src/middleware/index.ts +94 -0
- package/src/modules/filters.ts +458 -0
- package/src/modules/guards.ts +405 -0
- package/src/modules/index.ts +1256 -0
- package/src/modules/interceptors.ts +574 -0
- package/src/modules/lazy.ts +418 -0
- package/src/modules/lifecycle.ts +478 -0
- package/src/modules/metadata.ts +90 -0
- package/src/modules/pipes.ts +626 -0
- package/src/router/index.ts +339 -0
- package/src/router/linear.ts +371 -0
- package/src/router/regex.ts +292 -0
- package/src/router/tree.ts +562 -0
- package/src/rpc/index.ts +1263 -0
- package/src/security/index.ts +436 -0
- package/src/ssg/index.ts +631 -0
- package/src/storage/index.ts +456 -0
- package/src/telemetry/index.ts +1097 -0
- package/src/testing/index.ts +1586 -0
- package/src/types/index.ts +236 -0
- package/src/types/optional-deps.d.ts +219 -0
- package/src/validation/index.ts +276 -0
- package/src/websocket/index.ts +1004 -0
- package/tests/integration/cli.test.ts +1016 -0
- package/tests/integration/fullstack.test.ts +234 -0
- package/tests/unit/cache.test.ts +174 -0
- package/tests/unit/cli-commands.test.ts +892 -0
- package/tests/unit/cli.test.ts +1258 -0
- package/tests/unit/container.test.ts +279 -0
- package/tests/unit/context.test.ts +221 -0
- package/tests/unit/database.test.ts +183 -0
- package/tests/unit/linear-router.test.ts +280 -0
- package/tests/unit/lock.test.ts +336 -0
- package/tests/unit/middleware.test.ts +184 -0
- package/tests/unit/modules.test.ts +142 -0
- package/tests/unit/pubsub.test.ts +257 -0
- package/tests/unit/regex-router.test.ts +265 -0
- package/tests/unit/router.test.ts +373 -0
- package/tests/unit/rpc.test.ts +1248 -0
- package/tests/unit/security.test.ts +174 -0
- package/tests/unit/telemetry.test.ts +371 -0
- package/tests/unit/test-cache.test.ts +110 -0
- package/tests/unit/test-database.test.ts +282 -0
- package/tests/unit/tree-router.test.ts +325 -0
- package/tests/unit/validation.test.ts +794 -0
- package/tsconfig.json +27 -0
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core type definitions for Bueno Framework
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
// ============= HTTP Types =============
|
|
6
|
+
|
|
7
|
+
export type HTTPMethod =
|
|
8
|
+
| "GET"
|
|
9
|
+
| "POST"
|
|
10
|
+
| "PUT"
|
|
11
|
+
| "PATCH"
|
|
12
|
+
| "DELETE"
|
|
13
|
+
| "HEAD"
|
|
14
|
+
| "OPTIONS";
|
|
15
|
+
|
|
16
|
+
export type StatusCode =
|
|
17
|
+
| 200
|
|
18
|
+
| 201
|
|
19
|
+
| 202
|
|
20
|
+
| 204
|
|
21
|
+
| 301
|
|
22
|
+
| 302
|
|
23
|
+
| 303
|
|
24
|
+
| 307
|
|
25
|
+
| 308
|
|
26
|
+
| 400
|
|
27
|
+
| 401
|
|
28
|
+
| 403
|
|
29
|
+
| 404
|
|
30
|
+
| 405
|
|
31
|
+
| 409
|
|
32
|
+
| 422
|
|
33
|
+
| 429
|
|
34
|
+
| 500
|
|
35
|
+
| 502
|
|
36
|
+
| 503
|
|
37
|
+
| 504;
|
|
38
|
+
|
|
39
|
+
// ============= Route Types =============
|
|
40
|
+
|
|
41
|
+
export type PathParams = Record<string, string>;
|
|
42
|
+
|
|
43
|
+
export type RouteHandler<T = unknown, C = unknown> = (
|
|
44
|
+
context: C,
|
|
45
|
+
) => T | Promise<T>;
|
|
46
|
+
|
|
47
|
+
export type RoutePath = string;
|
|
48
|
+
|
|
49
|
+
export interface RouteDefinition {
|
|
50
|
+
method: HTTPMethod;
|
|
51
|
+
path: RoutePath;
|
|
52
|
+
handler: RouteHandler;
|
|
53
|
+
middleware?: MiddlewareHandler[];
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// ============= Middleware Types =============
|
|
57
|
+
|
|
58
|
+
export type MiddlewareHandler<T = unknown> = (
|
|
59
|
+
context: unknown,
|
|
60
|
+
next: () => Promise<unknown>,
|
|
61
|
+
) => T | Promise<T>;
|
|
62
|
+
|
|
63
|
+
export type MiddlewareChain = MiddlewareHandler[];
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Typed middleware function that receives a Context
|
|
67
|
+
*/
|
|
68
|
+
export type Middleware<T = Response> = (
|
|
69
|
+
context: import("../context").Context,
|
|
70
|
+
next: () => Promise<Response>,
|
|
71
|
+
) => T | Promise<T>;
|
|
72
|
+
|
|
73
|
+
// ============= DI Types =============
|
|
74
|
+
|
|
75
|
+
export type Token<T = unknown> =
|
|
76
|
+
| string
|
|
77
|
+
| symbol
|
|
78
|
+
| (abstract new (
|
|
79
|
+
...args: unknown[]
|
|
80
|
+
) => T);
|
|
81
|
+
|
|
82
|
+
export interface Provider<T = unknown> {
|
|
83
|
+
token: Token<T>;
|
|
84
|
+
useClass?: abstract new (...args: unknown[]) => T;
|
|
85
|
+
useValue?: T;
|
|
86
|
+
useFactory?: (...args: unknown[]) => T | Promise<T>;
|
|
87
|
+
inject?: Token[];
|
|
88
|
+
scope?: "singleton" | "transient" | "request";
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export interface ModuleMetadata {
|
|
92
|
+
imports?: Token[];
|
|
93
|
+
providers?: Provider[];
|
|
94
|
+
controllers?: Token[];
|
|
95
|
+
exports?: Token[];
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// ============= Context Types =============
|
|
99
|
+
|
|
100
|
+
export interface ContextVariableMap {
|
|
101
|
+
[key: string]: unknown;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export interface ContextDefaults {
|
|
105
|
+
status: StatusCode;
|
|
106
|
+
headers: Headers;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// ============= Standard Schema Types (v1 spec) =============
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Standard Schema v1 interface
|
|
113
|
+
* Works with Zod 4, Valibot v1, ArkType, Typia, and any Standard Schema compliant validator
|
|
114
|
+
*/
|
|
115
|
+
export interface StandardSchema<Input = unknown, Output = Input> {
|
|
116
|
+
readonly "~standard": {
|
|
117
|
+
readonly version: 1;
|
|
118
|
+
readonly vendor: string;
|
|
119
|
+
readonly validate: (
|
|
120
|
+
value: unknown,
|
|
121
|
+
options?: StandardSchemaOptions,
|
|
122
|
+
) => StandardResult<Output> | Promise<StandardResult<Output>>;
|
|
123
|
+
readonly types?: StandardTypes<Input, Output>;
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export interface StandardSchemaOptions {
|
|
128
|
+
readonly libraryOptions?: Record<string, unknown>;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export interface StandardTypes<Input = unknown, Output = Input> {
|
|
132
|
+
readonly input: Input;
|
|
133
|
+
readonly output: Output;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export type StandardResult<Output> =
|
|
137
|
+
| StandardSuccessResult<Output>
|
|
138
|
+
| StandardFailureResult;
|
|
139
|
+
|
|
140
|
+
export interface StandardSuccessResult<Output> {
|
|
141
|
+
readonly value: Output;
|
|
142
|
+
readonly issues?: undefined;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export interface StandardFailureResult {
|
|
146
|
+
readonly issues: ReadonlyArray<StandardIssue>;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export interface StandardIssue {
|
|
150
|
+
readonly message: string;
|
|
151
|
+
readonly path?: ReadonlyArray<PropertyKey | StandardPathSegment>;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export interface StandardPathSegment {
|
|
155
|
+
readonly key: PropertyKey;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export type ValidationTarget =
|
|
159
|
+
| "body"
|
|
160
|
+
| "query"
|
|
161
|
+
| "params"
|
|
162
|
+
| "headers"
|
|
163
|
+
| "cookies";
|
|
164
|
+
|
|
165
|
+
// Type utilities
|
|
166
|
+
export type InferInput<Schema extends StandardSchema> = NonNullable<
|
|
167
|
+
Schema["~standard"]["types"]
|
|
168
|
+
>["input"];
|
|
169
|
+
export type InferOutput<Schema extends StandardSchema> = NonNullable<
|
|
170
|
+
Schema["~standard"]["types"]
|
|
171
|
+
>["output"];
|
|
172
|
+
|
|
173
|
+
// ============= Database Types =============
|
|
174
|
+
|
|
175
|
+
export type DatabaseDriver = "postgresql" | "mysql" | "sqlite";
|
|
176
|
+
|
|
177
|
+
export interface DatabaseConfig {
|
|
178
|
+
url: string;
|
|
179
|
+
pool?: {
|
|
180
|
+
min?: number;
|
|
181
|
+
max?: number;
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// ============= Server Types =============
|
|
186
|
+
|
|
187
|
+
export interface ServerConfig {
|
|
188
|
+
port?: number;
|
|
189
|
+
hostname?: string;
|
|
190
|
+
development?: {
|
|
191
|
+
hmr?: boolean;
|
|
192
|
+
console?: boolean;
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export interface AppOptions {
|
|
197
|
+
server?: ServerConfig;
|
|
198
|
+
database?: DatabaseConfig;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// ============= RPC Types =============
|
|
202
|
+
|
|
203
|
+
export interface RPCClientConfig {
|
|
204
|
+
baseUrl: string;
|
|
205
|
+
headers?: Record<string, string>;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// ============= Error Types =============
|
|
209
|
+
|
|
210
|
+
export class BuenoError extends Error {
|
|
211
|
+
constructor(
|
|
212
|
+
message: string,
|
|
213
|
+
public statusCode: StatusCode = 500,
|
|
214
|
+
public code?: string,
|
|
215
|
+
) {
|
|
216
|
+
super(message);
|
|
217
|
+
this.name = "BuenoError";
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
export class ValidationError extends BuenoError {
|
|
222
|
+
constructor(
|
|
223
|
+
message: string,
|
|
224
|
+
public issues: StandardIssue[],
|
|
225
|
+
) {
|
|
226
|
+
super(message, 422, "VALIDATION_ERROR");
|
|
227
|
+
this.name = "ValidationError";
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
export class NotFoundError extends BuenoError {
|
|
232
|
+
constructor(message = "Not Found") {
|
|
233
|
+
super(message, 404, "NOT_FOUND");
|
|
234
|
+
this.name = "NotFoundError";
|
|
235
|
+
}
|
|
236
|
+
}
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type declarations for optional peer dependencies
|
|
3
|
+
*
|
|
4
|
+
* These modules are optional peer dependencies for SSR rendering.
|
|
5
|
+
* Users need to install them separately if they want to use SSR features.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// React types
|
|
9
|
+
declare module "react" {
|
|
10
|
+
export type ReactElement = {
|
|
11
|
+
type: unknown;
|
|
12
|
+
props: Record<string, unknown>;
|
|
13
|
+
key: string | number | null;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type ReactNode = ReactElement | string | number | boolean | null | undefined | Iterable<ReactNode>;
|
|
17
|
+
|
|
18
|
+
export function createElement(
|
|
19
|
+
type: string | ((props: unknown) => ReactElement),
|
|
20
|
+
props?: Record<string, unknown> | null,
|
|
21
|
+
...children: ReactNode[]
|
|
22
|
+
): ReactElement;
|
|
23
|
+
|
|
24
|
+
export const Suspense: {
|
|
25
|
+
(props: { fallback?: ReactNode; children?: ReactNode }): ReactElement;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const Fragment: unique symbol;
|
|
29
|
+
|
|
30
|
+
export function useState<T>(initialState: T): [T, (value: T | ((prev: T) => T)) => void];
|
|
31
|
+
export function useEffect(effect: () => void | (() => void), deps?: unknown[]): void;
|
|
32
|
+
export function useContext<T>(context: ReactContext<T>): T;
|
|
33
|
+
export function createContext<T>(defaultValue: T): ReactContext<T>;
|
|
34
|
+
export function useRef<T>(initialValue: T): { current: T };
|
|
35
|
+
export function useMemo<T>(factory: () => T, deps?: unknown[]): T;
|
|
36
|
+
export function useCallback<T extends (...args: unknown[]) => unknown>(callback: T, deps?: unknown[]): T;
|
|
37
|
+
export function useReducer<S, A>(reducer: (state: S, action: A) => S, initialArg: S): [S, (action: A) => void];
|
|
38
|
+
|
|
39
|
+
export interface ReactContext<T> {
|
|
40
|
+
Provider: (props: { value: T; children?: ReactNode }) => ReactElement;
|
|
41
|
+
Consumer: (props: { children: (value: T) => ReactNode }) => ReactElement;
|
|
42
|
+
displayName?: string;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export const version: string;
|
|
46
|
+
export default { createElement, Suspense, Fragment, useState, useEffect, useContext, createContext, useRef, useMemo, useCallback, useReducer, version };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
declare module "react-dom/server" {
|
|
50
|
+
import { ReactElement } from "react";
|
|
51
|
+
|
|
52
|
+
export function renderToString(element: ReactElement): string;
|
|
53
|
+
export function renderToStaticMarkup(element: ReactElement): string;
|
|
54
|
+
export function renderToPipeableStream(element: ReactElement, options?: {
|
|
55
|
+
bootstrapScripts?: string[];
|
|
56
|
+
bootstrapModules?: string[];
|
|
57
|
+
identifierPrefix?: string;
|
|
58
|
+
namespaceURI?: string;
|
|
59
|
+
nonce?: string;
|
|
60
|
+
onAllReady?: () => void;
|
|
61
|
+
onError?: (error: Error) => void;
|
|
62
|
+
onShellReady?: () => void;
|
|
63
|
+
onShellError?: (error: Error) => void;
|
|
64
|
+
}): { pipe: (destination: unknown) => void; abort: () => void };
|
|
65
|
+
|
|
66
|
+
export function renderToReadableStream(element: ReactElement, options?: {
|
|
67
|
+
bootstrapScripts?: string[];
|
|
68
|
+
bootstrapModules?: string[];
|
|
69
|
+
identifierPrefix?: string;
|
|
70
|
+
namespaceURI?: string;
|
|
71
|
+
nonce?: string;
|
|
72
|
+
onError?: (error: Error) => void;
|
|
73
|
+
}): Promise<ReadableStream<Uint8Array> & { allReady: Promise<void> }>;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// SolidJS types
|
|
77
|
+
declare module "solid-js" {
|
|
78
|
+
export type Accessor<T> = () => T;
|
|
79
|
+
export type Setter<T> = (value: T | ((prev: T) => T)) => void;
|
|
80
|
+
export type Signal<T> = [Accessor<T>, Setter<T>];
|
|
81
|
+
|
|
82
|
+
export function createSignal<T>(value: T, options?: { equals?: boolean | ((prev: T, next: T) => boolean) }): Signal<T>;
|
|
83
|
+
export function createEffect(fn: () => void | (() => void)): void;
|
|
84
|
+
export function createMemo<T>(fn: () => T, value?: T, options?: { equals?: boolean | ((prev: T, next: T) => boolean) }): Accessor<T>;
|
|
85
|
+
export function onMount(fn: () => void): void;
|
|
86
|
+
export function onCleanup(fn: () => void): void;
|
|
87
|
+
export function onError(fn: (err: Error) => void): void;
|
|
88
|
+
|
|
89
|
+
export function untrack<T>(fn: () => T): T;
|
|
90
|
+
export function batch<T>(fn: () => T): T;
|
|
91
|
+
|
|
92
|
+
export function For<T>(props: { each: T[]; fallback?: unknown; children: (item: T, index: Accessor<number>) => unknown }): unknown;
|
|
93
|
+
export function Show(props: { when: unknown; keyed?: boolean; fallback?: unknown; children: unknown }): unknown;
|
|
94
|
+
export function Switch(props: { fallback?: unknown; children: unknown }): unknown;
|
|
95
|
+
export function Match(props: { when: unknown; keyed?: boolean; children: unknown }): unknown;
|
|
96
|
+
export function Index<T>(props: { each: T[]; fallback?: unknown; children: (item: Accessor<T>, index: number) => unknown }): unknown;
|
|
97
|
+
|
|
98
|
+
export function children(fn: () => unknown): Accessor<unknown>;
|
|
99
|
+
export function mergeProps<T extends object>(...sources: T[]): T;
|
|
100
|
+
export function splitProps<T extends object>(props: T, ...keys: (keyof T)[][]): T[];
|
|
101
|
+
|
|
102
|
+
export const Suspense: (props: { fallback?: unknown; children?: unknown }) => unknown;
|
|
103
|
+
|
|
104
|
+
export interface JSX {
|
|
105
|
+
Element: unknown;
|
|
106
|
+
IntrinsicElements: Record<string, unknown>;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
declare module "solid-js/web" {
|
|
111
|
+
export function renderToString(code: () => unknown, options?: { nonce?: string; renderId?: string }): string;
|
|
112
|
+
export function renderToStringAsync(code: () => unknown, options?: { timeoutMs?: number; nonce?: string; renderId?: string }): Promise<string>;
|
|
113
|
+
export function renderToStream(code: () => unknown, options?: { nonce?: string; renderId?: string }): ReadableStream<Uint8Array>;
|
|
114
|
+
export function hydrate(code: () => unknown, element: Element): void;
|
|
115
|
+
export function Dynamic(props: { component: unknown; [key: string]: unknown }): unknown;
|
|
116
|
+
export function Portal(props: { mount?: Element; useShadow?: boolean; children: unknown }): unknown;
|
|
117
|
+
export function Assets(props: { children: unknown }): unknown;
|
|
118
|
+
export function HydrationScript(props?: { nonce?: string }): unknown;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Svelte types
|
|
122
|
+
declare module "svelte/server" {
|
|
123
|
+
export interface SvelteComponent {
|
|
124
|
+
render(props?: Record<string, unknown>): { html: string; head: string; css: { code: string } };
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export function render(component: typeof SvelteComponent, options?: { props?: Record<string, unknown> }): { html: string; head: string; css: { code: string } };
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// Vue types
|
|
131
|
+
declare module "vue" {
|
|
132
|
+
export type Component = unknown;
|
|
133
|
+
|
|
134
|
+
export function createApp(rootComponent: Component, rootProps?: Record<string, unknown>): {
|
|
135
|
+
mount(rootContainer: Element | string): unknown;
|
|
136
|
+
unmount(): void;
|
|
137
|
+
provide<T>(key: string | symbol, value: T): void;
|
|
138
|
+
component(name: string, component: Component): void;
|
|
139
|
+
directive(name: string, directive: unknown): void;
|
|
140
|
+
use(plugin: unknown, ...options: unknown[]): void;
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
export function createSSRApp(rootComponent: Component, rootProps?: Record<string, unknown>): ReturnType<typeof createApp>;
|
|
144
|
+
|
|
145
|
+
export function defineComponent(options: {
|
|
146
|
+
name?: string;
|
|
147
|
+
props?: Record<string, unknown>;
|
|
148
|
+
setup?: (props: Record<string, unknown>, ctx: unknown) => unknown;
|
|
149
|
+
render?: (ctx: unknown) => unknown;
|
|
150
|
+
template?: string;
|
|
151
|
+
components?: Record<string, Component>;
|
|
152
|
+
directives?: Record<string, unknown>;
|
|
153
|
+
data?: () => Record<string, unknown>;
|
|
154
|
+
computed?: Record<string, (this: unknown) => unknown>;
|
|
155
|
+
methods?: Record<string, (this: unknown, ...args: unknown[]) => unknown>;
|
|
156
|
+
watch?: Record<string, unknown>;
|
|
157
|
+
emits?: string[] | Record<string, unknown>;
|
|
158
|
+
[key: string]: unknown;
|
|
159
|
+
}): Component;
|
|
160
|
+
|
|
161
|
+
export function ref<T>(value: T): { value: T };
|
|
162
|
+
export function reactive<T extends object>(obj: T): T;
|
|
163
|
+
export function computed<T>(fn: () => T): { readonly value: T };
|
|
164
|
+
export function watch(source: unknown, callback: (value: unknown, oldValue: unknown, onCleanup: (fn: () => void) => void) => void, options?: { immediate?: boolean; deep?: boolean }): () => void;
|
|
165
|
+
export function watchEffect(fn: (onCleanup: (fn: () => void) => void) => void): () => void;
|
|
166
|
+
export function onMounted(fn: () => void): void;
|
|
167
|
+
export function onUnmounted(fn: () => void): void;
|
|
168
|
+
export function onServerPrefetch(fn: () => Promise<void>): void;
|
|
169
|
+
|
|
170
|
+
export function h(type: string | Component, props?: Record<string, unknown> | null, children?: unknown): unknown;
|
|
171
|
+
export function defineAsyncComponent(loader: () => Promise<{ default: Component }>): Component;
|
|
172
|
+
export function provide(key: string | symbol, value: unknown): void;
|
|
173
|
+
export function inject<T>(key: string | symbol, defaultValue?: T): T | undefined;
|
|
174
|
+
export function useSSRContext(): Record<string, unknown>;
|
|
175
|
+
|
|
176
|
+
export const version: string;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
declare module "vue/server-renderer" {
|
|
180
|
+
export function renderToString(app: unknown, options?: { context?: Record<string, unknown> }): Promise<string>;
|
|
181
|
+
export function renderToStream(app: unknown, options?: { context?: Record<string, unknown> }): ReadableStream<Uint8Array>;
|
|
182
|
+
export function renderToWebStream(app: unknown, options?: { context?: Record<string, unknown> }): ReadableStream<Uint8Array>;
|
|
183
|
+
export function renderToNodeStream(app: unknown, options?: { context?: Record<string, unknown> }): NodeJS.ReadableStream;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
declare module "vue-router" {
|
|
187
|
+
import { Component } from "vue";
|
|
188
|
+
|
|
189
|
+
export interface RouteRecordRaw {
|
|
190
|
+
path: string;
|
|
191
|
+
name?: string;
|
|
192
|
+
component?: Component;
|
|
193
|
+
components?: Record<string, Component>;
|
|
194
|
+
redirect?: string | ((to: unknown) => string);
|
|
195
|
+
alias?: string | string[];
|
|
196
|
+
children?: RouteRecordRaw[];
|
|
197
|
+
meta?: Record<string, unknown>;
|
|
198
|
+
beforeEnter?: (to: unknown, from: unknown, next: () => void) => void;
|
|
199
|
+
props?: boolean | Record<string, unknown> | ((to: unknown) => Record<string, unknown>);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export interface Router {
|
|
203
|
+
isReady(): Promise<void>;
|
|
204
|
+
push(to: string | { path: string; query?: Record<string, string>; params?: Record<string, string> }): void;
|
|
205
|
+
replace(to: string | { path: string; query?: Record<string, string>; params?: Record<string, string> }): void;
|
|
206
|
+
go(delta: number): void;
|
|
207
|
+
back(): void;
|
|
208
|
+
forward(): void;
|
|
209
|
+
beforeEach(guard: (to: unknown, from: unknown, next: () => void) => void): () => void;
|
|
210
|
+
currentRoute: { path: string; params: Record<string, string>; query: Record<string, string>; name: string | symbol | null };
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
export function createRouter(options: { history: unknown; routes: RouteRecordRaw[] }): Router;
|
|
214
|
+
export function createWebHistory(base?: string): unknown;
|
|
215
|
+
export function createWebHashHistory(base?: string): unknown;
|
|
216
|
+
export function createMemoryHistory(base?: string): unknown;
|
|
217
|
+
export function useRoute(): Router["currentRoute"];
|
|
218
|
+
export function useRouter(): Router;
|
|
219
|
+
}
|