@marko/run 0.0.1-beta1 → 0.0.1-beta10
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 +385 -131
- package/dist/.tsbuildinfo +1 -0
- package/dist/adapter/default-entry.mjs +14 -5
- package/dist/adapter/dev-server.d.ts +1 -1
- package/dist/adapter/index.cjs +34 -10
- package/dist/adapter/index.d.ts +1 -0
- package/dist/adapter/index.js +34 -10
- package/dist/adapter/middleware.cjs +237 -0
- package/dist/adapter/middleware.d.ts +55 -0
- package/dist/adapter/middleware.js +209 -0
- package/dist/adapter/polyfill.d.ts +6 -0
- package/dist/cli/default.config.mjs +2 -2
- package/dist/cli/index.mjs +90 -59
- package/dist/runtime/index.cjs +0 -16
- package/dist/runtime/index.d.ts +21 -2
- package/dist/runtime/index.js +0 -7
- package/dist/runtime/internal.cjs +160 -0
- package/dist/runtime/internal.d.ts +11 -0
- package/dist/runtime/internal.js +126 -0
- package/dist/runtime/router.cjs +12 -10
- package/dist/runtime/router.d.ts +3 -4
- package/dist/runtime/router.js +9 -7
- package/dist/runtime/types.d.ts +39 -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 +715 -312
- package/dist/vite/index.d.ts +4 -3
- package/dist/vite/index.js +712 -312
- package/dist/vite/types.d.ts +14 -7
- package/dist/vite/utils/config.d.ts +5 -3
- package/dist/vite/utils/route.d.ts +1 -1
- package/dist/vite/utils/server.d.ts +3 -1
- package/package.json +39 -17
- package/dist/adapter/server-old.d.ts +0 -3
- package/dist/adapter/server.d.ts +0 -6
- package/dist/adapters/node/index.d.ts +0 -5
- package/dist/adapters/node/server.d.ts +0 -3
- package/dist/adapters/static/crawler.d.ts +0 -9
- package/dist/adapters/static/default-entry.mjs +0 -1
- package/dist/adapters/static/index.cjs +0 -371
- package/dist/adapters/static/index.d.ts +0 -5
- package/dist/adapters/static/index.js +0 -341
- package/dist/adapters/static/server.d.ts +0 -3
- package/dist/runtime/request.d.ts +0 -4
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/runtime/internal.ts
|
|
21
|
+
var internal_exports = {};
|
|
22
|
+
__export(internal_exports, {
|
|
23
|
+
NotHandled: () => NotHandled,
|
|
24
|
+
NotMatched: () => NotMatched,
|
|
25
|
+
call: () => call,
|
|
26
|
+
compose: () => compose,
|
|
27
|
+
createInput: () => createInput,
|
|
28
|
+
noContent: () => noContent,
|
|
29
|
+
normalize: () => normalize,
|
|
30
|
+
notHandled: () => notHandled,
|
|
31
|
+
notMatched: () => notMatched,
|
|
32
|
+
pageResponse: () => pageResponse
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(internal_exports);
|
|
35
|
+
var pageResponseInit = {
|
|
36
|
+
status: 200,
|
|
37
|
+
headers: { "content-type": "text/html;charset=UTF-8" }
|
|
38
|
+
};
|
|
39
|
+
function pageResponse(template, input) {
|
|
40
|
+
return new Response(template.stream(input), pageResponseInit);
|
|
41
|
+
}
|
|
42
|
+
var NotHandled = Symbol();
|
|
43
|
+
var NotMatched = Symbol();
|
|
44
|
+
globalThis.MarkoRun ?? (globalThis.MarkoRun = {
|
|
45
|
+
NotHandled,
|
|
46
|
+
NotMatched,
|
|
47
|
+
route(handler) {
|
|
48
|
+
return handler;
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
function createInput(context) {
|
|
52
|
+
let existing;
|
|
53
|
+
return (data) => {
|
|
54
|
+
existing ?? (existing = {
|
|
55
|
+
$global: context
|
|
56
|
+
});
|
|
57
|
+
return data ? Object.assign(existing, data) : existing;
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
async function call(handler, next, context) {
|
|
61
|
+
let response;
|
|
62
|
+
if (process.env.NODE_ENV !== "production") {
|
|
63
|
+
let nextCallCount = 0;
|
|
64
|
+
let didThrow = false;
|
|
65
|
+
try {
|
|
66
|
+
response = await handler(context, () => {
|
|
67
|
+
nextCallCount++;
|
|
68
|
+
return next();
|
|
69
|
+
});
|
|
70
|
+
} catch (error) {
|
|
71
|
+
didThrow = true;
|
|
72
|
+
if (error instanceof Response) {
|
|
73
|
+
return error;
|
|
74
|
+
}
|
|
75
|
+
throw error;
|
|
76
|
+
} finally {
|
|
77
|
+
if (!response && !didThrow && nextCallCount > 0) {
|
|
78
|
+
console.warn(
|
|
79
|
+
`Handler '${handler.name}' called its next function but no response was returned. This will cause the next function to be called again which is wasteful. Either return or throw the result of calling \`next\`, return or throw a new Response object or finally \`throw null\` to skip handling the request`
|
|
80
|
+
);
|
|
81
|
+
} else if (nextCallCount > 1) {
|
|
82
|
+
console.warn(
|
|
83
|
+
`Handler '${handler.name}' called its next function more than once. Make sure this is intentional because it is inefficient.`
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
} else {
|
|
88
|
+
try {
|
|
89
|
+
response = await handler(context, next);
|
|
90
|
+
} catch (error) {
|
|
91
|
+
if (error == null) {
|
|
92
|
+
throw NotHandled;
|
|
93
|
+
} else if (error instanceof Response) {
|
|
94
|
+
return error;
|
|
95
|
+
}
|
|
96
|
+
throw error;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
if (response === null) {
|
|
100
|
+
throw NotMatched;
|
|
101
|
+
}
|
|
102
|
+
return response || next();
|
|
103
|
+
}
|
|
104
|
+
function compose(handlers) {
|
|
105
|
+
const len = handlers.length;
|
|
106
|
+
if (!len) {
|
|
107
|
+
return (_context, next) => next();
|
|
108
|
+
} else if (len === 1) {
|
|
109
|
+
return handlers[0];
|
|
110
|
+
}
|
|
111
|
+
return (context, next) => {
|
|
112
|
+
let i = 0;
|
|
113
|
+
return function nextHandler() {
|
|
114
|
+
return i < len ? call(handlers[i++], nextHandler, context) : next();
|
|
115
|
+
}();
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
function normalize(obj) {
|
|
119
|
+
if (typeof obj === "function") {
|
|
120
|
+
return obj;
|
|
121
|
+
} else if (Array.isArray(obj)) {
|
|
122
|
+
return compose(obj);
|
|
123
|
+
} else if (obj instanceof Promise) {
|
|
124
|
+
const promise = obj.then((value) => {
|
|
125
|
+
fn = Array.isArray(value) ? compose(value) : value;
|
|
126
|
+
});
|
|
127
|
+
let fn = async (context, next) => {
|
|
128
|
+
await promise;
|
|
129
|
+
return fn(context, next);
|
|
130
|
+
};
|
|
131
|
+
return (context, next) => fn(context, next);
|
|
132
|
+
}
|
|
133
|
+
throw new Error(
|
|
134
|
+
`Invalid handler - expected function, array or Promise but received ${obj}`
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
function noContent() {
|
|
138
|
+
return new Response(null, {
|
|
139
|
+
status: 204
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
function notHandled() {
|
|
143
|
+
throw null;
|
|
144
|
+
}
|
|
145
|
+
function notMatched() {
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
149
|
+
0 && (module.exports = {
|
|
150
|
+
NotHandled,
|
|
151
|
+
NotMatched,
|
|
152
|
+
call,
|
|
153
|
+
compose,
|
|
154
|
+
createInput,
|
|
155
|
+
noContent,
|
|
156
|
+
normalize,
|
|
157
|
+
notHandled,
|
|
158
|
+
notMatched,
|
|
159
|
+
pageResponse
|
|
160
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { InputObject, NextFunction, Route, Context, RouteHandler } from "./types";
|
|
2
|
+
export declare function pageResponse(template: any, input: Record<PropertyKey, unknown>): Response;
|
|
3
|
+
export declare const NotHandled: typeof MarkoRun.NotHandled;
|
|
4
|
+
export declare const NotMatched: typeof MarkoRun.NotMatched;
|
|
5
|
+
export declare function createInput(context: Context): (data: InputObject) => InputObject;
|
|
6
|
+
export declare function call(handler: RouteHandler<Route>, next: NextFunction, context: Context): Promise<Response>;
|
|
7
|
+
export declare function compose(handlers: RouteHandler[]): RouteHandler;
|
|
8
|
+
export declare function normalize(obj: RouteHandler | RouteHandler[] | Promise<RouteHandler | RouteHandler[]>): RouteHandler;
|
|
9
|
+
export declare function noContent(): Response;
|
|
10
|
+
export declare function notHandled(): void;
|
|
11
|
+
export declare function notMatched(): null;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
// src/runtime/internal.ts
|
|
2
|
+
var pageResponseInit = {
|
|
3
|
+
status: 200,
|
|
4
|
+
headers: { "content-type": "text/html;charset=UTF-8" }
|
|
5
|
+
};
|
|
6
|
+
function pageResponse(template, input) {
|
|
7
|
+
return new Response(template.stream(input), pageResponseInit);
|
|
8
|
+
}
|
|
9
|
+
var NotHandled = Symbol();
|
|
10
|
+
var NotMatched = Symbol();
|
|
11
|
+
globalThis.MarkoRun ?? (globalThis.MarkoRun = {
|
|
12
|
+
NotHandled,
|
|
13
|
+
NotMatched,
|
|
14
|
+
route(handler) {
|
|
15
|
+
return handler;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
function createInput(context) {
|
|
19
|
+
let existing;
|
|
20
|
+
return (data) => {
|
|
21
|
+
existing ?? (existing = {
|
|
22
|
+
$global: context
|
|
23
|
+
});
|
|
24
|
+
return data ? Object.assign(existing, data) : existing;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
async function call(handler, next, context) {
|
|
28
|
+
let response;
|
|
29
|
+
if (process.env.NODE_ENV !== "production") {
|
|
30
|
+
let nextCallCount = 0;
|
|
31
|
+
let didThrow = false;
|
|
32
|
+
try {
|
|
33
|
+
response = await handler(context, () => {
|
|
34
|
+
nextCallCount++;
|
|
35
|
+
return next();
|
|
36
|
+
});
|
|
37
|
+
} catch (error) {
|
|
38
|
+
didThrow = true;
|
|
39
|
+
if (error instanceof Response) {
|
|
40
|
+
return error;
|
|
41
|
+
}
|
|
42
|
+
throw error;
|
|
43
|
+
} finally {
|
|
44
|
+
if (!response && !didThrow && nextCallCount > 0) {
|
|
45
|
+
console.warn(
|
|
46
|
+
`Handler '${handler.name}' called its next function but no response was returned. This will cause the next function to be called again which is wasteful. Either return or throw the result of calling \`next\`, return or throw a new Response object or finally \`throw null\` to skip handling the request`
|
|
47
|
+
);
|
|
48
|
+
} else if (nextCallCount > 1) {
|
|
49
|
+
console.warn(
|
|
50
|
+
`Handler '${handler.name}' called its next function more than once. Make sure this is intentional because it is inefficient.`
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
} else {
|
|
55
|
+
try {
|
|
56
|
+
response = await handler(context, next);
|
|
57
|
+
} catch (error) {
|
|
58
|
+
if (error == null) {
|
|
59
|
+
throw NotHandled;
|
|
60
|
+
} else if (error instanceof Response) {
|
|
61
|
+
return error;
|
|
62
|
+
}
|
|
63
|
+
throw error;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (response === null) {
|
|
67
|
+
throw NotMatched;
|
|
68
|
+
}
|
|
69
|
+
return response || next();
|
|
70
|
+
}
|
|
71
|
+
function compose(handlers) {
|
|
72
|
+
const len = handlers.length;
|
|
73
|
+
if (!len) {
|
|
74
|
+
return (_context, next) => next();
|
|
75
|
+
} else if (len === 1) {
|
|
76
|
+
return handlers[0];
|
|
77
|
+
}
|
|
78
|
+
return (context, next) => {
|
|
79
|
+
let i = 0;
|
|
80
|
+
return function nextHandler() {
|
|
81
|
+
return i < len ? call(handlers[i++], nextHandler, context) : next();
|
|
82
|
+
}();
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
function normalize(obj) {
|
|
86
|
+
if (typeof obj === "function") {
|
|
87
|
+
return obj;
|
|
88
|
+
} else if (Array.isArray(obj)) {
|
|
89
|
+
return compose(obj);
|
|
90
|
+
} else if (obj instanceof Promise) {
|
|
91
|
+
const promise = obj.then((value) => {
|
|
92
|
+
fn = Array.isArray(value) ? compose(value) : value;
|
|
93
|
+
});
|
|
94
|
+
let fn = async (context, next) => {
|
|
95
|
+
await promise;
|
|
96
|
+
return fn(context, next);
|
|
97
|
+
};
|
|
98
|
+
return (context, next) => fn(context, next);
|
|
99
|
+
}
|
|
100
|
+
throw new Error(
|
|
101
|
+
`Invalid handler - expected function, array or Promise but received ${obj}`
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
function noContent() {
|
|
105
|
+
return new Response(null, {
|
|
106
|
+
status: 204
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
function notHandled() {
|
|
110
|
+
throw null;
|
|
111
|
+
}
|
|
112
|
+
function notMatched() {
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
export {
|
|
116
|
+
NotHandled,
|
|
117
|
+
NotMatched,
|
|
118
|
+
call,
|
|
119
|
+
compose,
|
|
120
|
+
createInput,
|
|
121
|
+
noContent,
|
|
122
|
+
normalize,
|
|
123
|
+
notHandled,
|
|
124
|
+
notMatched,
|
|
125
|
+
pageResponse
|
|
126
|
+
};
|
package/dist/runtime/router.cjs
CHANGED
|
@@ -20,20 +20,22 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/runtime/router.ts
|
|
21
21
|
var router_exports = {};
|
|
22
22
|
__export(router_exports, {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
fetch: () => fetch,
|
|
24
|
+
invoke: () => invoke,
|
|
25
|
+
match: () => match
|
|
26
26
|
});
|
|
27
27
|
module.exports = __toCommonJS(router_exports);
|
|
28
28
|
function notImplemented() {
|
|
29
|
-
throw new Error(
|
|
29
|
+
throw new Error(
|
|
30
|
+
"This should have been replaced by the @marko/run plugin at build/dev time"
|
|
31
|
+
);
|
|
30
32
|
}
|
|
31
|
-
var
|
|
32
|
-
var
|
|
33
|
-
var
|
|
33
|
+
var fetch = notImplemented;
|
|
34
|
+
var match = notImplemented;
|
|
35
|
+
var invoke = notImplemented;
|
|
34
36
|
// Annotate the CommonJS export names for ESM import in node:
|
|
35
37
|
0 && (module.exports = {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
38
|
+
fetch,
|
|
39
|
+
invoke,
|
|
40
|
+
match
|
|
39
41
|
});
|
package/dist/runtime/router.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const getMatchedRoute: RouteMatcher;
|
|
1
|
+
export declare const fetch: <Platform = unknown>(request: Request, platform: Platform) => Promise<void | Response>;
|
|
2
|
+
export declare const match: (method: string, pathname: string) => import("./types").RouteWithHandler<{}, unknown, string> | null;
|
|
3
|
+
export declare const invoke: <Platform = unknown>(route: import("./types").RouteWithHandler<{}, unknown, string> | null, request: Request, platform: Platform) => Promise<void | Response>;
|
package/dist/runtime/router.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
// src/runtime/router.ts
|
|
2
2
|
function notImplemented() {
|
|
3
|
-
throw new Error(
|
|
3
|
+
throw new Error(
|
|
4
|
+
"This should have been replaced by the @marko/run plugin at build/dev time"
|
|
5
|
+
);
|
|
4
6
|
}
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
7
|
+
var fetch = notImplemented;
|
|
8
|
+
var match = notImplemented;
|
|
9
|
+
var invoke = notImplemented;
|
|
8
10
|
export {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
fetch,
|
|
12
|
+
invoke,
|
|
13
|
+
match
|
|
12
14
|
};
|
package/dist/runtime/types.d.ts
CHANGED
|
@@ -1,22 +1,45 @@
|
|
|
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 ContextExtensions {
|
|
7
|
+
}
|
|
8
|
+
export declare type ParamsObject = Record<string, string>;
|
|
9
|
+
export declare type InputObject = Record<PropertyKey, any>;
|
|
10
|
+
export declare type Context<Platform = unknown, TRoute extends Route = Route> = TRoute extends any ? Combine<ContextExtensions & Readonly<{
|
|
4
11
|
url: URL;
|
|
12
|
+
request: Request;
|
|
13
|
+
route: TRoute["path"];
|
|
14
|
+
params: TRoute["params"];
|
|
15
|
+
meta: TRoute["meta"];
|
|
16
|
+
platform: Platform;
|
|
17
|
+
}>> : never;
|
|
18
|
+
export declare type NextFunction = () => Awaitable<Response>;
|
|
19
|
+
export declare type HandlerLike<TRoute extends Route = Route> = Awaitable<OneOrMany<RouteHandler<TRoute>>>;
|
|
20
|
+
export declare type RouteHandler<TRoute extends Route = Route> = (context: Context<unknown, TRoute>, next: NextFunction) => Awaitable<Response | null | void>;
|
|
21
|
+
export interface Route<Params extends ParamsObject = {}, Meta = unknown, Path extends string = string> {
|
|
22
|
+
path: Path;
|
|
5
23
|
params: Params;
|
|
6
24
|
meta: Meta;
|
|
7
|
-
error?: unknown;
|
|
8
25
|
}
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
handler: RouteHandler;
|
|
12
|
-
params: Params;
|
|
13
|
-
meta: Meta;
|
|
14
|
-
invoke: Router;
|
|
26
|
+
export interface RouteWithHandler<Params extends ParamsObject = {}, Meta = unknown, Path extends string = string> extends Route<Params, Meta, Path> {
|
|
27
|
+
handler: RouteHandler<this>;
|
|
15
28
|
}
|
|
16
|
-
export declare type
|
|
17
|
-
export declare type
|
|
18
|
-
export declare type
|
|
19
|
-
export interface
|
|
20
|
-
|
|
21
|
-
|
|
29
|
+
export declare type Fetch<Platform = unknown> = (request: Request, platform: Platform) => Promise<Response | void>;
|
|
30
|
+
export declare type Match = (method: string, pathname: string) => RouteWithHandler | null;
|
|
31
|
+
export declare type Invoke = <Platform = unknown>(route: RouteWithHandler | null, request: Request, platform: Platform) => Promise<Response | void>;
|
|
32
|
+
export interface RuntimeModule {
|
|
33
|
+
fetch: <Platform = unknown>(request: Request, platform: Platform) => Promise<Response | void>;
|
|
34
|
+
match: (method: string, pathname: string) => RouteWithHandler | null;
|
|
35
|
+
invoke: <Platform = unknown>(route: RouteWithHandler | null, request: Request, platform: Platform) => Promise<Response | void>;
|
|
22
36
|
}
|
|
37
|
+
declare type Member<T, U> = T extends T ? (U extends T ? T : never) : never;
|
|
38
|
+
declare type Segments<T extends string, Acc extends string[] = []> = T extends "" ? Acc : T extends `${infer Left}/${infer Rest}` ? Segments<Rest, [...Acc, Left]> : [...Acc, T];
|
|
39
|
+
declare type GTE<A extends any[], B extends any[]> = A["length"] extends B["length"] ? 1 : A extends [infer _Ha, ...infer Ta] ? B extends [infer _Hb, ...infer Tb] ? GTE<Ta, Tb> : 1 : 0;
|
|
40
|
+
declare type MatchSegments<A extends string, B extends string> = A extends `${infer P}/${string}*` ? 1 extends GTE<Segments<B>, Segments<P>> ? `${P}/${string}` : never : Segments<B>["length"] extends Segments<A>["length"] ? A : never;
|
|
41
|
+
declare type PathPattern<T extends string> = T extends `${infer Left}/\${${string}}/${infer Rest}` ? PathPattern<`${Left}/${string}/${Rest}`> : T extends `${infer Left}/\${...${string}}` ? PathPattern<`${Left}/${string}*`> : T extends `${infer Left}/\${${string}}` ? PathPattern<`${Left}/${string}`> : T;
|
|
42
|
+
export declare type PathTemplate<Path extends string> = Path extends `${infer Left}/\${${string}}/${infer Rest}` ? PathTemplate<`${Left}/${string}/${Rest}`> : Path extends `${infer Left}/\${${string}}` ? PathTemplate<`${Left}/${string}`> : Path;
|
|
43
|
+
export declare type ValidatePath<Paths extends string, Path extends string> = Paths | (Path extends `/${string}` ? MatchSegments<Member<PathPattern<Paths>, Path>, Path> : Path);
|
|
44
|
+
export declare type ValidateHref<Paths extends string, Href extends string> = Href extends `${infer P}#${infer H}?${infer Q}` ? `${ValidatePath<Paths, P>}#${H}?${Q}` : Href extends `${infer P}?${infer Q}` ? `${ValidatePath<Paths, P>}?${Q}` : Href extends `${infer P}#${infer H}` ? `${ValidatePath<Paths, P>}#${H}` : ValidatePath<Paths, Href>;
|
|
45
|
+
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, adapterTypes?: 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";
|