@devlusoft/devix 0.4.1-beta.4 → 0.4.1-beta.6
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/cli/build.d.ts +1 -0
- package/dist/cli/dev-server.d.ts +1 -0
- package/dist/cli/dev-server.js +1 -1
- package/dist/cli/dev.d.ts +1 -0
- package/dist/cli/generate.d.ts +1 -0
- package/dist/cli/generate.js +9 -9
- package/dist/cli/generate.js.map +3 -3
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +23 -23
- package/dist/cli/index.js.map +3 -3
- package/dist/cli/start.d.ts +1 -0
- package/dist/cli/start.js +1 -1
- package/dist/cli/start.js.map +3 -3
- package/dist/config.d.ts +22 -0
- package/dist/runtime/api-context.d.ts +24 -0
- package/dist/runtime/client-router.d.ts +13 -0
- package/dist/runtime/context.d.ts +32 -0
- package/dist/runtime/create-handler.d.ts +10 -0
- package/dist/runtime/error-boundary.d.ts +19 -0
- package/dist/runtime/fetch.d.ts +39 -0
- package/dist/runtime/head.d.ts +7 -0
- package/dist/runtime/index.d.ts +14 -0
- package/dist/runtime/link.d.ts +8 -0
- package/dist/runtime/metadata.d.ts +10 -0
- package/dist/runtime/router-provider.d.ts +25 -0
- package/dist/runtime/server-app.d.ts +15 -0
- package/dist/server/api-router.d.ts +22 -0
- package/dist/server/api.d.ts +2 -0
- package/dist/server/collect-css.d.ts +2 -0
- package/dist/server/handler-store.d.ts +10 -0
- package/dist/server/index.d.ts +6 -0
- package/dist/server/pages-router.d.ts +21 -0
- package/dist/server/public-index.d.ts +1 -0
- package/dist/server/render.d.ts +62 -0
- package/dist/server/routes.d.ts +11 -0
- package/dist/server/types.d.ts +52 -0
- package/dist/types.d.ts +42 -0
- package/dist/utils/async.d.ts +1 -0
- package/dist/utils/banner.d.ts +1 -0
- package/dist/utils/banner.js +1 -1
- package/dist/utils/cookies.d.ts +12 -0
- package/dist/utils/duration.d.ts +1 -0
- package/dist/utils/env.d.ts +1 -0
- package/dist/utils/html.d.ts +2 -0
- package/dist/utils/patterns.d.ts +1 -0
- package/dist/utils/response.d.ts +19 -0
- package/dist/vite/codegen/api.d.ts +6 -0
- package/dist/vite/codegen/client-routes.d.ts +6 -0
- package/dist/vite/codegen/context.d.ts +1 -0
- package/dist/vite/codegen/entry-client.d.ts +5 -0
- package/dist/vite/codegen/extract-methods.d.ts +4 -0
- package/dist/vite/codegen/render.d.ts +6 -0
- package/dist/vite/codegen/routes-dts.d.ts +10 -0
- package/dist/vite/codegen/scan-api.d.ts +2 -0
- package/dist/vite/codegen/write-routes-dts.d.ts +1 -0
- package/dist/vite/index.d.ts +3 -0
- package/package.json +1 -1
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface ApiRoute {
|
|
2
|
+
path: string;
|
|
3
|
+
key: string;
|
|
4
|
+
params: string[];
|
|
5
|
+
regex: RegExp;
|
|
6
|
+
}
|
|
7
|
+
export interface ApiMiddleware {
|
|
8
|
+
dir: string;
|
|
9
|
+
key: string;
|
|
10
|
+
}
|
|
11
|
+
export interface ApiResult {
|
|
12
|
+
routes: ApiRoute[];
|
|
13
|
+
middlewares: ApiMiddleware[];
|
|
14
|
+
}
|
|
15
|
+
export declare function keyToRoutePattern(key: string, apiDir: string): string;
|
|
16
|
+
export declare function invalidateApiCache(): void;
|
|
17
|
+
export declare function buildRoutes(routeKeys: string[], middlewareKeys: string[], apiDir: string): ApiResult;
|
|
18
|
+
export declare function collectMiddlewareChain(routeKey: string, middlewares: ApiMiddleware[]): ApiMiddleware[];
|
|
19
|
+
export declare function matchRoute(pathname: string, routes: ApiRoute[]): {
|
|
20
|
+
route: ApiRoute;
|
|
21
|
+
params: Record<string, string>;
|
|
22
|
+
} | null;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { RouteContext } from '../runtime/api-context';
|
|
2
|
+
interface HandlerStore {
|
|
3
|
+
request: Request;
|
|
4
|
+
ctx: RouteContext;
|
|
5
|
+
}
|
|
6
|
+
export declare function withHandlerStore<T>(store: HandlerStore, fn: () => T): T;
|
|
7
|
+
export declare function useRequest(): Request;
|
|
8
|
+
export declare function useCtx(): RouteContext;
|
|
9
|
+
export declare function useParams(): Record<string, string>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { buildPages, collectLayoutChain, matchPage } from './pages-router';
|
|
2
|
+
export { buildRoutes, collectMiddlewareChain, matchRoute } from './api-router';
|
|
3
|
+
export { resolveMetadata, mergeMetadata } from '../runtime/metadata';
|
|
4
|
+
export type { Page, Layout, PagesResult } from './pages-router';
|
|
5
|
+
export type { ApiRoute, ApiMiddleware, ApiResult } from './api-router';
|
|
6
|
+
export type { PageModule, LayoutModule } from './types';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface Page {
|
|
2
|
+
path: string;
|
|
3
|
+
key: string;
|
|
4
|
+
params: string[];
|
|
5
|
+
regex: RegExp;
|
|
6
|
+
}
|
|
7
|
+
export interface Layout {
|
|
8
|
+
dir: string;
|
|
9
|
+
key: string;
|
|
10
|
+
}
|
|
11
|
+
export interface PagesResult {
|
|
12
|
+
pages: Page[];
|
|
13
|
+
layouts: Layout[];
|
|
14
|
+
}
|
|
15
|
+
export declare function invalidatePagesCache(): void;
|
|
16
|
+
export declare function buildPages(pageKeys: string[], layoutKeys: string[], pagesDir: string): PagesResult;
|
|
17
|
+
export declare function collectLayoutChain(pageKey: string, layouts: Layout[]): Layout[];
|
|
18
|
+
export declare function matchPage(pathname: string, pages: Page[]): {
|
|
19
|
+
page: Page;
|
|
20
|
+
params: Record<string, string>;
|
|
21
|
+
} | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useRequest, useCtx, useParams } from './handler-store';
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { PageGlob } from './types';
|
|
2
|
+
import type { Manifest } from "vite";
|
|
3
|
+
export declare function runLoader(url: string, request: Request, glob: PageGlob, options?: {
|
|
4
|
+
loaderTimeout?: number;
|
|
5
|
+
}): Promise<{
|
|
6
|
+
error: true;
|
|
7
|
+
loaderData: null;
|
|
8
|
+
params: {};
|
|
9
|
+
layouts: never[];
|
|
10
|
+
metadata: null;
|
|
11
|
+
viewport: undefined;
|
|
12
|
+
redirect?: undefined;
|
|
13
|
+
redirectStatus?: undefined;
|
|
14
|
+
redirectReplace?: undefined;
|
|
15
|
+
} | {
|
|
16
|
+
loaderData: null;
|
|
17
|
+
params: {};
|
|
18
|
+
layouts: never[];
|
|
19
|
+
metadata: null;
|
|
20
|
+
viewport: undefined;
|
|
21
|
+
error?: undefined;
|
|
22
|
+
redirect?: undefined;
|
|
23
|
+
redirectStatus?: undefined;
|
|
24
|
+
redirectReplace?: undefined;
|
|
25
|
+
} | {
|
|
26
|
+
redirect: string | undefined;
|
|
27
|
+
redirectStatus: number | undefined;
|
|
28
|
+
redirectReplace: boolean | undefined;
|
|
29
|
+
error?: undefined;
|
|
30
|
+
loaderData?: undefined;
|
|
31
|
+
params?: undefined;
|
|
32
|
+
layouts?: undefined;
|
|
33
|
+
metadata?: undefined;
|
|
34
|
+
viewport?: undefined;
|
|
35
|
+
} | {
|
|
36
|
+
loaderData: unknown;
|
|
37
|
+
params: Record<string, string>;
|
|
38
|
+
layouts: {
|
|
39
|
+
loaderData: unknown;
|
|
40
|
+
}[];
|
|
41
|
+
metadata: import("../types").Metadata;
|
|
42
|
+
viewport: import("../types").Viewport | undefined;
|
|
43
|
+
error?: undefined;
|
|
44
|
+
redirect?: undefined;
|
|
45
|
+
redirectStatus?: undefined;
|
|
46
|
+
redirectReplace?: undefined;
|
|
47
|
+
}>;
|
|
48
|
+
export declare function render(url: string, request: Request, glob: PageGlob, options?: {
|
|
49
|
+
manifest?: Manifest;
|
|
50
|
+
loaderTimeout?: number;
|
|
51
|
+
}): Promise<{
|
|
52
|
+
html: string;
|
|
53
|
+
statusCode: number | undefined;
|
|
54
|
+
headers: {
|
|
55
|
+
Location: string | undefined;
|
|
56
|
+
};
|
|
57
|
+
} | {
|
|
58
|
+
html: string;
|
|
59
|
+
statusCode: number;
|
|
60
|
+
headers: Record<string, string>;
|
|
61
|
+
}>;
|
|
62
|
+
export declare function getStaticRoutes(glob: PageGlob): Promise<string[]>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Hono } from 'hono';
|
|
2
|
+
import type { Manifest } from 'vite';
|
|
3
|
+
interface ServerOptions {
|
|
4
|
+
renderModule: any;
|
|
5
|
+
apiModule: any;
|
|
6
|
+
manifest?: Manifest;
|
|
7
|
+
loaderTimeout?: number;
|
|
8
|
+
}
|
|
9
|
+
export declare function registerApiRoutes(app: Hono, { apiModule, renderModule, loaderTimeout }: ServerOptions): void;
|
|
10
|
+
export declare function registerSsrRoute(app: Hono, { renderModule, manifest, loaderTimeout }: ServerOptions): void;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type React from "react";
|
|
2
|
+
import { LoaderContext, Metadata, Viewport } from "../types";
|
|
3
|
+
import type { Redirect } from "../utils/response";
|
|
4
|
+
type InferLoaderData<T> = T extends (...args: any[]) => infer R ? [Awaited<R>] extends [void | undefined | Redirect] ? undefined : Exclude<Awaited<R>, Redirect> : T;
|
|
5
|
+
type IsParams<T> = [T] extends [Record<string, string>] ? true : false;
|
|
6
|
+
export interface PageProps<TDataOrParams = unknown, TParams = Record<string, string>> {
|
|
7
|
+
data: IsParams<TDataOrParams> extends true ? unknown : InferLoaderData<TDataOrParams>;
|
|
8
|
+
params: IsParams<TDataOrParams> extends true ? TDataOrParams extends Record<string, string> ? TDataOrParams : Record<string, string> : TParams;
|
|
9
|
+
url: string;
|
|
10
|
+
}
|
|
11
|
+
export interface LayoutProps<TDataOrParams = unknown, TParams = Record<string, string>> {
|
|
12
|
+
children: React.ReactNode;
|
|
13
|
+
data: IsParams<TDataOrParams> extends true ? unknown : InferLoaderData<TDataOrParams>;
|
|
14
|
+
params: IsParams<TDataOrParams> extends true ? TDataOrParams extends Record<string, string> ? TDataOrParams : Record<string, string> : TParams;
|
|
15
|
+
}
|
|
16
|
+
export interface ErrorProps {
|
|
17
|
+
statusCode: number;
|
|
18
|
+
message?: string;
|
|
19
|
+
}
|
|
20
|
+
export interface PageGlob {
|
|
21
|
+
pages: Record<string, () => Promise<unknown>>;
|
|
22
|
+
layouts: Record<string, () => Promise<unknown>>;
|
|
23
|
+
pagesDir: string;
|
|
24
|
+
}
|
|
25
|
+
export interface ApiGlob {
|
|
26
|
+
routes: Record<string, () => Promise<unknown>>;
|
|
27
|
+
middlewares: Record<string, () => Promise<unknown>>;
|
|
28
|
+
apiDir: string;
|
|
29
|
+
}
|
|
30
|
+
interface BaseModule<TData, TParams> {
|
|
31
|
+
loader?: (ctx: LoaderContext<TParams>) => Promise<TData | Redirect | void> | TData | Redirect | void;
|
|
32
|
+
guard?: (ctx: LoaderContext<TParams>) => Promise<string | Redirect | Record<string, unknown> | null> | string | Redirect | Record<string, unknown> | null;
|
|
33
|
+
metadata?: Metadata;
|
|
34
|
+
generateMetadata?: (ctx: LoaderContext<TParams> & {
|
|
35
|
+
loaderData: TData;
|
|
36
|
+
}) => Promise<Metadata> | Metadata;
|
|
37
|
+
viewport?: Viewport;
|
|
38
|
+
generateViewport?: (ctx: LoaderContext<TParams>) => Promise<Viewport> | Viewport;
|
|
39
|
+
headers?: Record<string, string>;
|
|
40
|
+
}
|
|
41
|
+
export interface PageModule<TData = unknown, TParams = Record<string, string>> extends BaseModule<TData, TParams> {
|
|
42
|
+
default: React.ComponentType<PageProps<TData, TParams>>;
|
|
43
|
+
generateStaticParams?: () => Promise<Record<string, string>[]> | Record<string, string>[];
|
|
44
|
+
}
|
|
45
|
+
export interface LayoutModule<TData = unknown, TParams = Record<string, string>> extends BaseModule<TData, TParams> {
|
|
46
|
+
default: React.ComponentType<LayoutProps<TData, TParams>>;
|
|
47
|
+
lang?: string;
|
|
48
|
+
generateLang?: (ctx: LoaderContext<TParams> & {
|
|
49
|
+
loaderData: TData;
|
|
50
|
+
}) => Promise<string> | string;
|
|
51
|
+
}
|
|
52
|
+
export {};
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export interface Metadata {
|
|
2
|
+
title?: string;
|
|
3
|
+
description?: string;
|
|
4
|
+
keywords?: string[];
|
|
5
|
+
og?: {
|
|
6
|
+
title?: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
image?: string;
|
|
9
|
+
type?: 'website' | 'article' | 'product';
|
|
10
|
+
url?: string;
|
|
11
|
+
};
|
|
12
|
+
twitter?: {
|
|
13
|
+
card?: 'summary' | 'summary_large_image';
|
|
14
|
+
title?: string;
|
|
15
|
+
description?: string;
|
|
16
|
+
image?: string;
|
|
17
|
+
creator?: string;
|
|
18
|
+
};
|
|
19
|
+
canonical?: string;
|
|
20
|
+
robots?: string;
|
|
21
|
+
alternates?: Record<string, string>;
|
|
22
|
+
}
|
|
23
|
+
export interface Viewport {
|
|
24
|
+
width?: string | number;
|
|
25
|
+
initialScale?: number;
|
|
26
|
+
maximumScale?: number;
|
|
27
|
+
userScalable?: boolean;
|
|
28
|
+
themeColor?: string;
|
|
29
|
+
}
|
|
30
|
+
export interface LoaderContext<TParams = Record<string, string>> {
|
|
31
|
+
params: TParams;
|
|
32
|
+
request: Request;
|
|
33
|
+
guardData: unknown;
|
|
34
|
+
}
|
|
35
|
+
import type { Redirect } from './utils/response';
|
|
36
|
+
export type LoaderFunction<TData = unknown, TParams = Record<string, string>> = (ctx: LoaderContext<TParams>) => Promise<TData | Redirect | void> | TData | Redirect | void;
|
|
37
|
+
export type GuardFunction<TParams = Record<string, string>> = (ctx: LoaderContext<TParams>) => Promise<string | Redirect | Record<string, unknown> | null> | string | Redirect | Record<string, unknown> | null;
|
|
38
|
+
type GuardData<TGuard> = TGuard extends (...args: any[]) => infer R ? Exclude<Awaited<R>, string | Redirect | null | undefined> : unknown;
|
|
39
|
+
export type LoaderContextWithGuard<TGuard extends GuardFunction | undefined = undefined, TParams = Record<string, string>> = LoaderContext<TParams> & {
|
|
40
|
+
guardData: GuardData<TGuard>;
|
|
41
|
+
};
|
|
42
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function withTimeout<T>(promise: Promise<T>, ms: number): Promise<T>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function printDevBanner(port: number): void;
|
package/dist/utils/banner.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import o from"picocolors";import{networkInterfaces as r}from"node:os";function s(e){let l=r();for(let n of Object.values(l))for(let t of n??[])if(t.family==="IPv4"&&!t.internal)return`http://${t.address}:${e}/`;return null}function $(e){let l="0.4.1-beta.
|
|
1
|
+
import o from"picocolors";import{networkInterfaces as r}from"node:os";function s(e){let l=r();for(let n of Object.values(l))for(let t of n??[])if(t.family==="IPv4"&&!t.internal)return`http://${t.address}:${e}/`;return null}function $(e){let l="0.4.1-beta.6",n=s(e);console.log(),console.log(` ${o.bold(o.yellow("devix"))} ${o.dim(`v${l}`)}`),console.log(),console.log(` ${o.green("\u279C")} ${o.bold("Local:")} ${o.cyan(`http://localhost:${e}/`)}`),console.log(n?` ${o.green("\u279C")} ${o.bold("Network:")} ${o.cyan(n)}`:` ${o.green("\u279C")} ${o.bold("Network:")} ${o.dim("use --host to expose")}`),console.log()}export{$ as printDevBanner};
|
|
2
2
|
//# sourceMappingURL=banner.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface CookieOptions {
|
|
2
|
+
httpOnly?: boolean;
|
|
3
|
+
secure?: boolean;
|
|
4
|
+
sameSite?: 'Strict' | 'Lax' | 'None';
|
|
5
|
+
maxAge?: number;
|
|
6
|
+
expires?: Date;
|
|
7
|
+
path?: string;
|
|
8
|
+
domain?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function getCookie(req: Request, name: string): string | undefined;
|
|
11
|
+
export declare function setCookie(headers: Headers, name: string, value: string, options?: CookieOptions): void;
|
|
12
|
+
export declare function deleteCookie(headers: Headers, name: string, options?: Pick<CookieOptions, 'path' | 'domain'>): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function parseDuration(value: number | string): number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function loadDotenv(mode: string): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function routePattern(rel: string): string;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type JsonResponse<T = unknown> = Response & {
|
|
2
|
+
readonly __body: T;
|
|
3
|
+
};
|
|
4
|
+
export declare const json: <const T>(data: T, status?: number) => JsonResponse<T>;
|
|
5
|
+
export declare const text: (body: string, status?: number) => Response;
|
|
6
|
+
declare const REDIRECT_BRAND: unique symbol;
|
|
7
|
+
export interface RedirectOptions {
|
|
8
|
+
status?: number;
|
|
9
|
+
replace?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface Redirect {
|
|
12
|
+
readonly [REDIRECT_BRAND]: true;
|
|
13
|
+
readonly url: string;
|
|
14
|
+
readonly status: number;
|
|
15
|
+
readonly replace: boolean;
|
|
16
|
+
}
|
|
17
|
+
export declare function redirect(url: string, statusOrOptions?: number | RedirectOptions): Redirect;
|
|
18
|
+
export declare function isRedirect(value: unknown): value is Redirect;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function generateContext(): string;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { HttpMethod } from './extract-methods';
|
|
2
|
+
export interface RouteEntry {
|
|
3
|
+
filePath: string;
|
|
4
|
+
urlPattern: string;
|
|
5
|
+
identifier: string;
|
|
6
|
+
methods: HttpMethod[];
|
|
7
|
+
}
|
|
8
|
+
export declare function filePathToIdentifier(filePath: string, apiDir: string): string;
|
|
9
|
+
export declare function buildRouteEntry(filePath: string, apiDir: string, methods: HttpMethod[]): RouteEntry;
|
|
10
|
+
export declare function generateRoutesDts(entries: RouteEntry[], apiDir: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function writeRoutesDts(content: string, projectRoot: string): boolean;
|