@marko/run 0.0.1-beta2 → 0.0.1-beta4
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/README.md +102 -74
- package/dist/adapter/default-entry.mjs +9 -3
- package/dist/adapter/dev-server.d.ts +1 -1
- package/dist/adapter/index.cjs +189 -8
- package/dist/adapter/index.d.ts +1 -0
- package/dist/adapter/index.js +188 -7
- package/dist/adapter/middleware.cjs +199 -0
- package/dist/adapter/middleware.d.ts +55 -0
- package/dist/adapter/middleware.js +168 -0
- package/dist/cli/default.config.mjs +1 -1
- package/dist/cli/index.mjs +88 -59
- package/dist/runtime/index.cjs +0 -16
- package/dist/runtime/index.d.ts +10 -2
- package/dist/runtime/index.js +0 -7
- package/dist/runtime/internal.cjs +148 -0
- package/dist/runtime/internal.d.ts +10 -0
- package/dist/runtime/internal.js +115 -0
- package/dist/runtime/router.cjs +9 -7
- package/dist/runtime/router.d.ts +4 -4
- package/dist/runtime/router.js +7 -5
- package/dist/runtime/types.d.ts +29 -16
- package/dist/vite/codegen/index.d.ts +4 -3
- package/dist/vite/codegen/writer.d.ts +1 -1
- package/dist/vite/constants.d.ts +3 -2
- package/dist/vite/index.cjs +557 -282
- package/dist/vite/index.d.ts +4 -3
- package/dist/vite/index.js +554 -282
- package/dist/vite/types.d.ts +14 -7
- package/dist/vite/utils/config.d.ts +5 -3
- package/dist/vite/utils/server.d.ts +3 -1
- package/package.json +23 -11
package/dist/runtime/types.d.ts
CHANGED
|
@@ -1,22 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
declare type Awaitable<T> = Promise<T> | T;
|
|
2
|
+
declare type OneOrMany<T> = T | T[];
|
|
3
|
+
declare type Combine<T> = T extends object ? {
|
|
4
|
+
[P in keyof T]: T[P];
|
|
5
|
+
} : T;
|
|
6
|
+
export interface RouteContextExtensions {
|
|
7
|
+
}
|
|
8
|
+
export declare type ParamsObject = Record<string, string>;
|
|
9
|
+
export declare type InputObject = Record<PropertyKey, any>;
|
|
10
|
+
export interface RequestContext<T = unknown> {
|
|
4
11
|
url: URL;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
12
|
+
method: string;
|
|
13
|
+
request: Request;
|
|
14
|
+
platform: T;
|
|
8
15
|
}
|
|
9
|
-
export declare type
|
|
10
|
-
|
|
11
|
-
|
|
16
|
+
export declare type RouteContext<TRoute extends Route = Route> = TRoute extends any ? Combine<RouteContextExtensions & Readonly<RequestContext & {
|
|
17
|
+
route: TRoute["path"];
|
|
18
|
+
params: TRoute["params"];
|
|
19
|
+
meta: TRoute["meta"];
|
|
20
|
+
}>> : never;
|
|
21
|
+
export declare type NextFunction = () => Awaitable<Response>;
|
|
22
|
+
export declare type HandlerLike<TRoute extends Route = Route> = Awaitable<OneOrMany<RouteHandler<TRoute>>>;
|
|
23
|
+
export declare type RouteHandler<TRoute extends Route = Route> = (context: RouteContext<TRoute>, next: NextFunction) => Awaitable<Response | null | void>;
|
|
24
|
+
export interface Route<Params extends ParamsObject = {}, Meta = unknown, Path extends string = string> {
|
|
25
|
+
path: Path;
|
|
12
26
|
params: Params;
|
|
13
27
|
meta: Meta;
|
|
14
|
-
invoke: Router;
|
|
15
28
|
}
|
|
16
|
-
export
|
|
17
|
-
|
|
18
|
-
export declare type Handler = (context: AdapterRequestContext) => Promise<Response>;
|
|
19
|
-
export interface Runtime {
|
|
20
|
-
router: Router;
|
|
21
|
-
getMatchedRoute: RouteMatcher;
|
|
29
|
+
export interface RouteWithHandler<Params extends ParamsObject = {}, Meta = unknown, Path extends string = string> extends Route<Params, Meta, Path> {
|
|
30
|
+
handler: RouteHandler<this>;
|
|
22
31
|
}
|
|
32
|
+
export declare type MatchRoute = (method: string, pathname: string) => RouteWithHandler | null;
|
|
33
|
+
export declare type Router<T = unknown> = (context: RequestContext<T>) => Promise<Response | void>;
|
|
34
|
+
export declare type InvokeRoute<T = unknown> = (route: Route | null, context: RequestContext<T>) => Promise<Response | void>;
|
|
35
|
+
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { Route, BuiltRoutes,
|
|
2
|
-
export declare const DefaultCodegenOptions: CodegenOptions;
|
|
1
|
+
import type { Route, BuiltRoutes, RoutableFile, RouterOptions } from "../types";
|
|
3
2
|
export declare function renderRouteTemplate(route: Route): string;
|
|
4
3
|
export declare function renderRouteEntry(route: Route): string;
|
|
5
|
-
export declare function renderRouter(routes: BuiltRoutes, options?:
|
|
4
|
+
export declare function renderRouter(routes: BuiltRoutes, options?: RouterOptions): string;
|
|
5
|
+
export declare function renderMiddleware(middleware: RoutableFile[]): string;
|
|
6
|
+
export declare function renderRouteTypeInfo(routes: BuiltRoutes, pathPrefix?: string): string;
|
|
@@ -2,7 +2,7 @@ export interface Writer {
|
|
|
2
2
|
indent: number;
|
|
3
3
|
branch(name: string): Writer;
|
|
4
4
|
join(closeBranches?: boolean): void;
|
|
5
|
-
write(data: string): Writer;
|
|
5
|
+
write(data: string, indent?: boolean): Writer;
|
|
6
6
|
writeLines(...lines: string[]): Writer;
|
|
7
7
|
writeBlockStart(data: string): Writer;
|
|
8
8
|
writeBlockEnd(data: string): Writer;
|
package/dist/vite/constants.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
declare type ValuesOf<T> = T[keyof T];
|
|
2
|
-
export declare const
|
|
3
|
-
export declare const virtualFilePrefix = "virtual:marko-
|
|
2
|
+
export declare const markoRunFilePrefix = "__marko-run__";
|
|
3
|
+
export declare const virtualFilePrefix = "virtual:marko-run";
|
|
4
4
|
export declare const virtualRoutesPrefix: string;
|
|
5
|
+
export declare const virtualRuntimePrefix: string;
|
|
5
6
|
export declare const httpVerbs: readonly ["get", "post", "put", "delete"];
|
|
6
7
|
export declare const serverEntryQuery = "?marko-server-entry";
|
|
7
8
|
export declare const browserEntryQuery = "?marko-browser-entry";
|