@marko/run 0.0.1-beta2 → 0.0.1-beta3
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/adapter/default-entry.mjs +9 -3
- package/dist/adapter/dev-server.d.ts +1 -1
- package/dist/adapter/index.cjs +23 -8
- package/dist/adapter/index.js +22 -7
- package/dist/adapter/middleware.cjs +200 -0
- package/dist/adapter/middleware.d.ts +59 -0
- package/dist/adapter/middleware.js +169 -0
- package/dist/cli/default.config.mjs +1 -1
- package/dist/cli/index.mjs +45 -24
- 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 +6 -6
- package/dist/runtime/router.d.ts +4 -4
- package/dist/runtime/router.js +4 -4
- package/dist/runtime/types.d.ts +31 -16
- package/dist/runtime/utils.d.ts +3 -0
- 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 +542 -275
- package/dist/vite/index.d.ts +4 -3
- package/dist/vite/index.js +539 -275
- package/dist/vite/types.d.ts +9 -7
- package/dist/vite/utils/config.d.ts +2 -2
- package/dist/vite/utils/route.d.ts +1 -1
- package/dist/vite/utils/server.d.ts +3 -1
- package/package.json +18 -6
package/dist/vite/types.d.ts
CHANGED
|
@@ -8,18 +8,17 @@ export interface Adapter {
|
|
|
8
8
|
pluginOptions?(options: Options): Promise<Options> | Options | undefined;
|
|
9
9
|
viteConfig?(config: UserConfig): Promise<UserConfig> | UserConfig | undefined;
|
|
10
10
|
getEntryFile?(): Promise<string> | string;
|
|
11
|
-
startDev?(configFile: string, port: number): Promise<void> | void;
|
|
12
|
-
startPreview?(dir: string, entry?: string, port?: number): Promise<void> | void;
|
|
11
|
+
startDev?(configFile: string, port: number, envFile?: string): Promise<void> | void;
|
|
12
|
+
startPreview?(dir: string, entry?: string, port?: number, envFile?: string): Promise<void> | void;
|
|
13
13
|
buildEnd?(config: ResolvedConfig, routes: Route[], builtEntries: string[], sourceEntries: string[]): Promise<void> | void;
|
|
14
14
|
}
|
|
15
|
-
export interface
|
|
15
|
+
export interface RouterOptions {
|
|
16
|
+
trailingSlashes: 'Ignore' | 'RedirectWithout' | 'RedirectWith' | 'RewriteWithout' | 'RewriteWith';
|
|
17
|
+
}
|
|
18
|
+
export interface MarkoServeOptions extends Partial<RouterOptions> {
|
|
16
19
|
routesDir?: string;
|
|
17
20
|
emitRoutes?(routes: Route[]): void | Promise<void>;
|
|
18
21
|
adapter?: Adapter;
|
|
19
|
-
codegen?: CodegenOptions;
|
|
20
|
-
}
|
|
21
|
-
export interface CodegenOptions {
|
|
22
|
-
trailingSlashes: 'Ignore' | 'RedirectWithout' | 'RedirectWith' | 'RewriteWithout' | 'RewriteWith';
|
|
23
22
|
}
|
|
24
23
|
export declare type Options = MarkoServeOptions & MarkoViteOptions;
|
|
25
24
|
export interface Route {
|
|
@@ -43,9 +42,11 @@ export interface SpecialRoutes {
|
|
|
43
42
|
[RoutableFileTypes.Error]?: Route;
|
|
44
43
|
}
|
|
45
44
|
export interface RoutableFile {
|
|
45
|
+
id: string;
|
|
46
46
|
name: string;
|
|
47
47
|
type: RoutableFileType;
|
|
48
48
|
filePath: string;
|
|
49
|
+
relativePath: string;
|
|
49
50
|
importPath: string;
|
|
50
51
|
verbs?: HttpVerb[];
|
|
51
52
|
}
|
|
@@ -59,4 +60,5 @@ export interface RouteTrie {
|
|
|
59
60
|
export interface BuiltRoutes {
|
|
60
61
|
list: Route[];
|
|
61
62
|
special: SpecialRoutes;
|
|
63
|
+
middleware: RoutableFile[];
|
|
62
64
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { Options } from '../types';
|
|
2
|
-
export declare function
|
|
3
|
-
export declare function
|
|
2
|
+
export declare function getMarkoRunOptions<T extends Record<string, any>>(viteConfig: T): Readonly<Options> | undefined;
|
|
3
|
+
export declare function setMarkoRunOptions<T extends Record<string, any>>(viteConfig: T, options: Options): T;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { HttpVerb, Route } from "../types";
|
|
2
|
-
export declare function getVerbs(route: Route): ("get" | "
|
|
2
|
+
export declare function getVerbs(route: Route): ("get" | "post" | "put" | "delete")[];
|
|
3
3
|
export declare function hasVerb(route: Route, verb: HttpVerb): boolean | import("../types").RoutableFile | undefined;
|
|
@@ -2,6 +2,8 @@ export interface SpawnedServer {
|
|
|
2
2
|
port: number;
|
|
3
3
|
close(): void;
|
|
4
4
|
}
|
|
5
|
-
export declare function
|
|
5
|
+
export declare function parseEnv(envFile: string): Promise<import("dotenv").DotenvParseOutput | undefined>;
|
|
6
|
+
export declare function loadEnv(envFile: string): void;
|
|
7
|
+
export declare function spawnServer(cmd: string, port?: number, env?: string | Record<string, string>, cwd?: string, wait?: number): Promise<SpawnedServer>;
|
|
6
8
|
export declare function isPortInUse(port: number): Promise<boolean>;
|
|
7
9
|
export declare function getAvailablePort(): Promise<number>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@marko/run",
|
|
3
|
-
"version": "0.0.1-
|
|
3
|
+
"version": "0.0.1-beta3",
|
|
4
4
|
"description": "File-based routing for Marko based on Vite",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"author": "Ryan Turnquist <rturnq@gmail.com>",
|
|
@@ -33,6 +33,11 @@
|
|
|
33
33
|
"import": "./dist/vite/index.js",
|
|
34
34
|
"require": "./dist/vite/index.cjs"
|
|
35
35
|
},
|
|
36
|
+
"./adapter/middleware": {
|
|
37
|
+
"types": "./dist/adapter/middleware.d.ts",
|
|
38
|
+
"import": "./dist/adapter/middleware.js",
|
|
39
|
+
"require": "./dist/adapter/middleware.cjs"
|
|
40
|
+
},
|
|
36
41
|
"./adapter": {
|
|
37
42
|
"types": "./dist/adapter/index.d.ts",
|
|
38
43
|
"import": "./dist/adapter/index.js",
|
|
@@ -50,6 +55,9 @@
|
|
|
50
55
|
"vite": [
|
|
51
56
|
"./src/vite/index.ts"
|
|
52
57
|
],
|
|
58
|
+
"adapter/middleware": [
|
|
59
|
+
"./src/adapter/middleware.ts"
|
|
60
|
+
],
|
|
53
61
|
"adapter": [
|
|
54
62
|
"./src/adapter/index.ts"
|
|
55
63
|
]
|
|
@@ -66,8 +74,10 @@
|
|
|
66
74
|
"devDependencies": {
|
|
67
75
|
"@babel/types": "^7.19.0",
|
|
68
76
|
"@marko/compiler": "^5.22.6",
|
|
77
|
+
"@types/glob": "^8.0.1",
|
|
78
|
+
"@types/human-format": "^1.0.0",
|
|
69
79
|
"@types/mocha": "^9.1.1",
|
|
70
|
-
"@types/node": "^18.
|
|
80
|
+
"@types/node": "^18.11.18",
|
|
71
81
|
"acorn": "^8.8.0",
|
|
72
82
|
"cross-env": "^7.0.3",
|
|
73
83
|
"esbuild": "^0.15.7",
|
|
@@ -79,13 +89,15 @@
|
|
|
79
89
|
"typescript": "^4.7.4"
|
|
80
90
|
},
|
|
81
91
|
"dependencies": {
|
|
82
|
-
"@hattip/
|
|
83
|
-
"@
|
|
84
|
-
"@marko/vite": "^2.3.11",
|
|
92
|
+
"@hattip/polyfills": "^0.0.27",
|
|
93
|
+
"@marko/vite": "^2.3.9",
|
|
85
94
|
"cli-table3": "^0.6.3",
|
|
95
|
+
"compression": "^1.7.4",
|
|
96
|
+
"dotenv": "^16.0.3",
|
|
97
|
+
"glob": "^8.1.0",
|
|
86
98
|
"gzip-size": "^7.0.0",
|
|
99
|
+
"human-format": "^1.0.0",
|
|
87
100
|
"kleur": "^4.1.5",
|
|
88
|
-
"pretty-bytes": "^6.0.0",
|
|
89
101
|
"sade": "^1.8.1",
|
|
90
102
|
"serve-static": "^1.15.0",
|
|
91
103
|
"vite": "^3.0.8"
|