@marko/run 0.1.16 → 0.2.1

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.
@@ -2,6 +2,5 @@ import type { BuiltRoutes, RoutableFileType, SpecialRoutes } from "../types";
2
2
  import type { Walker } from "./walk";
3
3
  export declare function isRoutableFile(filename: string): boolean;
4
4
  export declare function matchRoutableFile(filename: string): RoutableFileType | null;
5
- export declare function scorePath(path: string, index: number): number;
6
5
  export declare function isSpecialType(type: RoutableFileType): type is keyof SpecialRoutes;
7
6
  export declare function buildRoutes(walk: Walker, basePath?: string): Promise<BuiltRoutes>;
@@ -0,0 +1,13 @@
1
+ export interface Segment {
2
+ raw: string;
3
+ name: string;
4
+ type?: "_" | "$" | "$$" | undefined;
5
+ param?: string;
6
+ }
7
+ export interface Path {
8
+ id: string;
9
+ segments: Segment[];
10
+ isCatchall?: boolean;
11
+ source: string;
12
+ }
13
+ export declare function parseFlatRoute(pattern: string): Path[];
@@ -0,0 +1,19 @@
1
+ import type { Path, Segment } from "./parse";
2
+ import type { RoutableFile, RoutableFileType, PathInfo } from "../types";
3
+ export default class VDir {
4
+ #private;
5
+ readonly parent: VDir | null;
6
+ readonly source: Path | null;
7
+ readonly path: string;
8
+ readonly fullPath: string;
9
+ readonly segment: Segment;
10
+ files: Map<RoutableFileType, RoutableFile> | undefined;
11
+ constructor();
12
+ constructor(parent: VDir, segment: Segment, source: Path);
13
+ get pathInfo(): PathInfo;
14
+ addDir(path: Path, segment: Segment): VDir;
15
+ addFile(file: RoutableFile): void;
16
+ dirs(): IterableIterator<VDir>;
17
+ [Symbol.iterator](): IterableIterator<VDir>;
18
+ static addPaths(roots: VDir[], paths: Path[]): VDir[];
19
+ }
@@ -3,9 +3,9 @@ export interface WalkEntry {
3
3
  path: string;
4
4
  }
5
5
  export interface WalkOptions {
6
- onFile?: (file: WalkEntry) => void;
7
- onDir?: (dir: string) => (() => void) | false | void;
8
6
  onEnter?: (dir: WalkEntry) => (() => void) | false | void;
7
+ onFile?: (file: WalkEntry) => void;
8
+ onDir?: () => boolean;
9
9
  maxDepth?: number;
10
10
  }
11
11
  export type Walker = (options: WalkOptions) => Promise<void>;
@@ -30,7 +30,7 @@ export interface Adapter {
30
30
  typeInfo?(writer: (data: string) => void): Promise<string> | string;
31
31
  }
32
32
  export interface RouterOptions {
33
- trailingSlashes: 'Ignore' | 'RedirectWithout' | 'RedirectWith' | 'RewriteWithout' | 'RewriteWith';
33
+ trailingSlashes: "Ignore" | "RedirectWithout" | "RedirectWith" | "RewriteWithout" | "RewriteWith";
34
34
  }
35
35
  export interface MarkoServeOptions extends Partial<RouterOptions> {
36
36
  routesDir?: string;
@@ -41,19 +41,20 @@ export type Options = MarkoServeOptions & MarkoViteOptions;
41
41
  export interface Route {
42
42
  key: string;
43
43
  index: number;
44
- path: string;
45
- params?: ParamInfo[];
44
+ paths: PathInfo[];
46
45
  layouts: RoutableFile[];
47
46
  middleware: RoutableFile[];
48
47
  meta?: RoutableFile;
49
48
  handler?: RoutableFile;
50
49
  page?: RoutableFile;
51
50
  entryName: string;
52
- score: number;
53
51
  }
54
- export interface ParamInfo {
55
- name: string;
56
- index: number;
52
+ export interface PathInfo {
53
+ id: string;
54
+ path: string;
55
+ segments: string[];
56
+ params?: Record<string, number | null>;
57
+ isEnd?: boolean;
57
58
  }
58
59
  export interface SpecialRoutes {
59
60
  [RoutableFileTypes.NotFound]?: Route;
@@ -68,13 +69,6 @@ export interface RoutableFile {
68
69
  importPath: string;
69
70
  verbs?: HttpVerb[];
70
71
  }
71
- export interface RouteTrie {
72
- key: string;
73
- route?: Route;
74
- catchAll?: Route;
75
- static?: Map<string, RouteTrie>;
76
- dynamic?: RouteTrie;
77
- }
78
72
  export interface BuiltRoutes {
79
73
  list: Route[];
80
74
  special: SpecialRoutes;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marko/run",
3
- "version": "0.1.16",
3
+ "version": "0.2.1",
4
4
  "description": "The Marko application framework.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/marko-js/run/tree/main/packages/run",