@marko/run 0.1.8 → 0.1.9
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/runtime/index.d.ts +1 -1
- package/dist/runtime/types.d.ts +8 -8
- package/dist/vite/index.cjs +3 -3
- package/dist/vite/index.js +3 -3
- package/package.json +1 -1
package/dist/runtime/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NotHandled, NotMatched } from "./namespace";
|
|
2
|
-
import { GetPaths, PostPaths, GetablePath, GetableHref, PostablePath, PostableHref, Platform, HandlerTypeFn, RuntimeModule, AnyRoute, AnyContext, AnyHandler } from "./types";
|
|
2
|
+
import type { GetPaths, PostPaths, GetablePath, GetableHref, PostablePath, PostableHref, Platform, HandlerTypeFn, RuntimeModule, AnyRoute, AnyContext, AnyHandler } from "./types";
|
|
3
3
|
declare global {
|
|
4
4
|
var __marko_run__: RuntimeModule;
|
|
5
5
|
namespace MarkoRun {
|
package/dist/runtime/types.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ type OneOrMany<T> = T | T[];
|
|
|
3
3
|
type NoParams = {};
|
|
4
4
|
export interface Platform {
|
|
5
5
|
}
|
|
6
|
-
export interface Context<TRoute extends
|
|
6
|
+
export interface Context<TRoute extends Route = AnyRoute> {
|
|
7
7
|
readonly url: URL;
|
|
8
8
|
readonly request: Request;
|
|
9
9
|
readonly route: TRoute["path"];
|
|
@@ -12,13 +12,13 @@ export interface Context<TRoute extends AnyRoute = AnyRoute> {
|
|
|
12
12
|
readonly platform: Platform;
|
|
13
13
|
readonly serializedGlobals: Record<string, boolean>;
|
|
14
14
|
}
|
|
15
|
-
export type MultiRouteContext<TRoute extends
|
|
15
|
+
export type MultiRouteContext<TRoute extends Route> = TRoute extends any ? Context<TRoute> : never;
|
|
16
16
|
export type ParamsObject = Record<string, string>;
|
|
17
17
|
export type InputObject = Record<PropertyKey, any>;
|
|
18
18
|
export type NextFunction = () => Awaitable<Response>;
|
|
19
|
-
export type HandlerLike<TRoute extends
|
|
20
|
-
export type RouteHandler<TRoute extends
|
|
21
|
-
export interface Route<Params extends ParamsObject, Meta, Path extends string> {
|
|
19
|
+
export type HandlerLike<TRoute extends Route = AnyRoute> = Awaitable<OneOrMany<RouteHandler<TRoute>>>;
|
|
20
|
+
export type RouteHandler<TRoute extends Route = AnyRoute> = (context: MultiRouteContext<TRoute>, next: NextFunction) => Awaitable<Response | null | void>;
|
|
21
|
+
export interface Route<Params extends ParamsObject = ParamsObject, Meta = unknown, Path extends string = string> {
|
|
22
22
|
path: Path;
|
|
23
23
|
params: Params;
|
|
24
24
|
meta: Meta;
|
|
@@ -79,11 +79,11 @@ type AnyParams = 0 extends HasAppData ? ParamsObject : never;
|
|
|
79
79
|
type AnyMeta = 0 extends HasAppData ? unknown : never;
|
|
80
80
|
export type Routes = AppData extends {
|
|
81
81
|
routes: infer T;
|
|
82
|
-
} ? T : Record<string, Route
|
|
82
|
+
} ? T : Record<string, Route>;
|
|
83
83
|
export type AnyRoute = Routes[keyof Routes];
|
|
84
84
|
export type AnyContext = MultiRouteContext<AnyRoute>;
|
|
85
|
-
export type AnyHandler<Params extends AnyParams = AnyParams, Meta extends AnyMeta = AnyMeta> = 0 extends HasAppData ? HandlerLike<Route<Params, Meta
|
|
86
|
-
export type HandlerTypeFn<
|
|
85
|
+
export type AnyHandler<Params extends AnyParams = AnyParams, Meta extends AnyMeta = AnyMeta> = 0 extends HasAppData ? HandlerLike<Route<Params, Meta>> : HandlerLike<AnyRoute>;
|
|
86
|
+
export type HandlerTypeFn<TRoute extends Route = AnyRoute> = 0 extends HasAppData ? <Params extends ParamsObject = ParamsObject, Meta = unknown>(handler: HandlerLike<Route<Params, Meta>>) => HandlerLike<Route<Params, Meta>> : (handler: HandlerLike<TRoute>) => HandlerLike<TRoute>;
|
|
87
87
|
export type GetPaths = AppData extends {
|
|
88
88
|
getPaths: infer T;
|
|
89
89
|
} ? T : string;
|
package/dist/vite/index.cjs
CHANGED
|
@@ -987,7 +987,7 @@ async function renderRouteTypeInfo(routes, pathPrefix = ".", adapter) {
|
|
|
987
987
|
Do NOT manually edit this file or your changes will be lost.
|
|
988
988
|
*/
|
|
989
989
|
`,
|
|
990
|
-
`import "@marko/run/namespace";`,
|
|
990
|
+
`import { NotHandled, NotMatched, GetPaths, PostPaths, GetablePath, GetableHref, PostablePath, PostableHref, Platform } from "@marko/run/namespace";`,
|
|
991
991
|
`import type Run from "@marko/run";`
|
|
992
992
|
);
|
|
993
993
|
const headWriter = writer.branch("head");
|
|
@@ -1130,11 +1130,11 @@ function writeModuleDeclaration(writer, path3, routeType, moduleTypes) {
|
|
|
1130
1130
|
const isMarko = path3.endsWith(".marko");
|
|
1131
1131
|
writer.write(`
|
|
1132
1132
|
namespace MarkoRun {
|
|
1133
|
-
export
|
|
1133
|
+
export { NotHandled, NotMatched, GetPaths, PostPaths, GetablePath, GetableHref, PostablePath, PostableHref, Platform };
|
|
1134
1134
|
export type Route = ${routeType};
|
|
1135
1135
|
export type Context = Run.MultiRouteContext<Route>${isMarko ? " & Marko.Global" : ""};
|
|
1136
1136
|
export type Handler = Run.HandlerLike<Route>;
|
|
1137
|
-
export const route: Run.HandlerTypeFn<
|
|
1137
|
+
export const route: Run.HandlerTypeFn<Route>;
|
|
1138
1138
|
}`);
|
|
1139
1139
|
}
|
|
1140
1140
|
writer.writeLines(`
|
package/dist/vite/index.js
CHANGED
|
@@ -950,7 +950,7 @@ async function renderRouteTypeInfo(routes, pathPrefix = ".", adapter) {
|
|
|
950
950
|
Do NOT manually edit this file or your changes will be lost.
|
|
951
951
|
*/
|
|
952
952
|
`,
|
|
953
|
-
`import "@marko/run/namespace";`,
|
|
953
|
+
`import { NotHandled, NotMatched, GetPaths, PostPaths, GetablePath, GetableHref, PostablePath, PostableHref, Platform } from "@marko/run/namespace";`,
|
|
954
954
|
`import type Run from "@marko/run";`
|
|
955
955
|
);
|
|
956
956
|
const headWriter = writer.branch("head");
|
|
@@ -1093,11 +1093,11 @@ function writeModuleDeclaration(writer, path3, routeType, moduleTypes) {
|
|
|
1093
1093
|
const isMarko = path3.endsWith(".marko");
|
|
1094
1094
|
writer.write(`
|
|
1095
1095
|
namespace MarkoRun {
|
|
1096
|
-
export
|
|
1096
|
+
export { NotHandled, NotMatched, GetPaths, PostPaths, GetablePath, GetableHref, PostablePath, PostableHref, Platform };
|
|
1097
1097
|
export type Route = ${routeType};
|
|
1098
1098
|
export type Context = Run.MultiRouteContext<Route>${isMarko ? " & Marko.Global" : ""};
|
|
1099
1099
|
export type Handler = Run.HandlerLike<Route>;
|
|
1100
|
-
export const route: Run.HandlerTypeFn<
|
|
1100
|
+
export const route: Run.HandlerTypeFn<Route>;
|
|
1101
1101
|
}`);
|
|
1102
1102
|
}
|
|
1103
1103
|
writer.writeLines(`
|