@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.
@@ -3,23 +3,27 @@ import type { Options as MarkoViteOptions } from "@marko/vite";
3
3
  import type { ResolvedConfig, UserConfig } from "vite";
4
4
  export type { RoutableFileType, HttpVerb };
5
5
  export declare type StartServer = (port?: number) => Promise<void>;
6
+ export interface AdapterConfig {
7
+ [name: PropertyKey]: any;
8
+ }
6
9
  export interface Adapter {
7
10
  readonly name: string;
11
+ configure?(config: AdapterConfig): void;
8
12
  pluginOptions?(options: Options): Promise<Options> | Options | undefined;
9
13
  viteConfig?(config: UserConfig): Promise<UserConfig> | UserConfig | undefined;
10
14
  getEntryFile?(): Promise<string> | string;
11
- startDev?(configFile: string, port: number): Promise<void> | void;
12
- startPreview?(dir: string, entry?: string, port?: number): Promise<void> | void;
15
+ startDev?(configFile: string, port: number, envFile?: string): Promise<void> | void;
16
+ startPreview?(dir: string, entry?: string, port?: number, envFile?: string): Promise<void> | void;
13
17
  buildEnd?(config: ResolvedConfig, routes: Route[], builtEntries: string[], sourceEntries: string[]): Promise<void> | void;
18
+ writeTypeInfo?(): Promise<string> | string;
19
+ }
20
+ export interface RouterOptions {
21
+ trailingSlashes: 'Ignore' | 'RedirectWithout' | 'RedirectWith' | 'RewriteWithout' | 'RewriteWith';
14
22
  }
15
- export interface MarkoServeOptions {
23
+ export interface MarkoServeOptions extends Partial<RouterOptions> {
16
24
  routesDir?: string;
17
25
  emitRoutes?(routes: Route[]): void | Promise<void>;
18
26
  adapter?: Adapter;
19
- codegen?: CodegenOptions;
20
- }
21
- export interface CodegenOptions {
22
- trailingSlashes: 'Ignore' | 'RedirectWithout' | 'RedirectWith' | 'RewriteWithout' | 'RewriteWith';
23
27
  }
24
28
  export declare type Options = MarkoServeOptions & MarkoViteOptions;
25
29
  export interface Route {
@@ -43,9 +47,11 @@ export interface SpecialRoutes {
43
47
  [RoutableFileTypes.Error]?: Route;
44
48
  }
45
49
  export interface RoutableFile {
50
+ id: string;
46
51
  name: string;
47
52
  type: RoutableFileType;
48
53
  filePath: string;
54
+ relativePath: string;
49
55
  importPath: string;
50
56
  verbs?: HttpVerb[];
51
57
  }
@@ -59,4 +65,5 @@ export interface RouteTrie {
59
65
  export interface BuiltRoutes {
60
66
  list: Route[];
61
67
  special: SpecialRoutes;
68
+ middleware: RoutableFile[];
62
69
  }
@@ -1,3 +1,5 @@
1
- import type { Options } from '../types';
2
- export declare function getMarkoServeOptions<T extends Record<string, any>>(viteConfig: T): Readonly<Options> | undefined;
3
- export declare function setMarkoServeOptions<T extends Record<string, any>>(viteConfig: T, options: Options): T;
1
+ import type { Options, AdapterConfig } from '../types';
2
+ export declare const getExternalPluginOptions: <T>(viteConfig: T) => Readonly<Options> | undefined;
3
+ export declare const setExternalPluginOptions: <T>(viteConfig: T, value: Options) => T;
4
+ export declare const getExternalAdapterOptions: <T>(viteConfig: T) => Readonly<AdapterConfig> | undefined;
5
+ export declare const setExternalAdapterOptions: <T>(viteConfig: T, value: AdapterConfig) => T;
@@ -2,6 +2,8 @@ export interface SpawnedServer {
2
2
  port: number;
3
3
  close(): void;
4
4
  }
5
- export declare function spawnServer(cmd: string, port?: number, cwd?: string, wait?: number): Promise<SpawnedServer>;
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-beta2",
3
+ "version": "0.0.1-beta4",
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",
@@ -42,16 +47,19 @@
42
47
  "typesVersions": {
43
48
  "*": {
44
49
  "*": [
45
- "./src/runtime/index.ts"
50
+ "./dist/runtime/index.d.ts"
46
51
  ],
47
52
  "router": [
48
- "./src/runtime/router.ts"
53
+ "./dist/runtime/router.d.ts"
49
54
  ],
50
55
  "vite": [
51
- "./src/vite/index.ts"
56
+ "./dist/vite/index.d.ts"
57
+ ],
58
+ "adapter/middleware": [
59
+ "./dist/adapter/middleware.d.ts"
52
60
  ],
53
61
  "adapter": [
54
- "./src/adapter/index.ts"
62
+ "./dist/adapter/index.d.ts"
55
63
  ]
56
64
  }
57
65
  },
@@ -66,12 +74,14 @@
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.7.6",
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",
74
- "marko": "^5.21.9",
84
+ "marko": "^5.22.4",
75
85
  "mocha": "^10.0.0",
76
86
  "mocha-snap": "^4.3.0",
77
87
  "prettier": "^2.7.1",
@@ -79,13 +89,15 @@
79
89
  "typescript": "^4.7.4"
80
90
  },
81
91
  "dependencies": {
82
- "@hattip/adapter-node": "^0.0.24",
83
- "@hattip/core": "^0.0.24",
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"