@doracli/express-server 0.0.2 → 0.0.4

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.
@@ -0,0 +1,143 @@
1
+ import { Ctx, RouteManager, TEnvParams } from '@doracli/express';
2
+ import { Compiler } from '@doracli/esbuild';
3
+ import { TPlainObject, TAny, PartialRecursive } from '@cclr/lang';
4
+ import { TController } from '@doracli/define-server';
5
+ import { ConfigCtx } from '@doracli/helper';
6
+ import { TDoraConfig } from '@doracli/type';
7
+ import { Application } from 'express';
8
+
9
+ type TControllerConfig = {
10
+ /** 原始文件的绝对路径 */
11
+ absoluteFilePathOrigin: string;
12
+ /** 原始文件相对路径 */
13
+ relativeFilePathOrigin: string;
14
+ /** 处理后文件绝对路径 */
15
+ absoluteFilePath: string;
16
+ /** 路由前缀 */
17
+ route: string;
18
+ /** 文件相对路径 - 路径部分 */
19
+ relativePath: string;
20
+ /** 文件后缀 */
21
+ fileExt: string;
22
+ /** 文件名称 */
23
+ fileName: string;
24
+ /** 文件原始内容,类,函数,json */
25
+ orange: TPlainObject;
26
+ /** 统一后的类型 */
27
+ Controller: TController;
28
+ };
29
+
30
+ declare class ControllerConfig {
31
+ map: Map<string, TControllerConfig>;
32
+ update(absoluteFilePathOrigin: string, config: Partial<TControllerConfig>): void;
33
+ updateMulti(configs: Partial<TControllerConfig>[]): void;
34
+ updateAbsoluteFilePath(inOutMap: Record<string, string>): void;
35
+ getConfig(absoluteFilePathOrigin: string): TControllerConfig | undefined;
36
+ getConfigList(absoluteFilePathOriginList: string[]): (TControllerConfig | undefined)[];
37
+ }
38
+
39
+ declare class ControllerBuilder {
40
+ private ctx;
41
+ private controllerConfig;
42
+ compiler: Compiler;
43
+ outdirAbsolute: string;
44
+ /**
45
+ * absoluteFilePathOrigin => ctxKey
46
+ */
47
+ inputKeyMap: Record<string, string>;
48
+ /**
49
+ * ctxKey => compilerCtx
50
+ */
51
+ compilerCtxMap: Map<string, Awaited<ReturnType<Compiler['context']>>>;
52
+ constructor(ctx: Ctx, controllerConfig: ControllerConfig);
53
+ /** 批量构建 */
54
+ build(absoluteFilePathOriginList: string[]): Promise<Record<string, string>>;
55
+ /**
56
+ * 根据编译上下文分组构建
57
+ * @param groupkey
58
+ * @returns {input => output}[]
59
+ */
60
+ private buildGroup;
61
+ /** 获取输出文件路径 */
62
+ private getOutputPath;
63
+ }
64
+
65
+ /**
66
+ * 控制器处理类
67
+ */
68
+ declare class ControllerDeal {
69
+ private scanAbsolute;
70
+ constructor(scanAbsolute: string);
71
+ /** 收集路径中的参数 多个 */
72
+ getBaseConfigMult(absolutePathList: string[]): ({
73
+ relativeFilePathOrigin: string;
74
+ absoluteFilePathOrigin: string;
75
+ relativePath?: undefined;
76
+ fileName?: undefined;
77
+ fileExt?: undefined;
78
+ } | {
79
+ relativePath: string;
80
+ fileName: string;
81
+ fileExt: string;
82
+ relativeFilePathOrigin: string;
83
+ absoluteFilePathOrigin: string;
84
+ })[];
85
+ /** 收集路径中的参数 */
86
+ getBaseConfig(absolutePath: string): {
87
+ relativeFilePathOrigin: string;
88
+ absoluteFilePathOrigin: string;
89
+ relativePath?: undefined;
90
+ fileName?: undefined;
91
+ fileExt?: undefined;
92
+ } | {
93
+ relativePath: string;
94
+ fileName: string;
95
+ fileExt: string;
96
+ relativeFilePathOrigin: string;
97
+ absoluteFilePathOrigin: string;
98
+ };
99
+ /** 加载多个配置 */
100
+ loadMult(configs: TControllerConfig[]): Promise<Partial<TControllerConfig>[]>;
101
+ /** 加载单个配置 */
102
+ load(config: TControllerConfig): Promise<Partial<TControllerConfig>>;
103
+ /** 格式化多个配置 */
104
+ formatMult(configs: Partial<TControllerConfig>[]): Partial<TControllerConfig>[];
105
+ /** 格式化配置 */
106
+ format(config: Partial<TControllerConfig>): Partial<TControllerConfig>;
107
+ }
108
+
109
+ declare class ControllerWatcher {
110
+ private fileWatcher;
111
+ onCreate: (path: string) => void;
112
+ onUpdate: (path: string) => void;
113
+ onDelete: (path: string) => void;
114
+ constructor();
115
+ private handleChange;
116
+ listion(path: string): void;
117
+ }
118
+
119
+ declare class ServerWorkflow {
120
+ scanAbsolute: string;
121
+ controllerBuilder: ControllerBuilder;
122
+ controllerConfig: ControllerConfig;
123
+ controllerDeal: ControllerDeal;
124
+ routeManager: RouteManager;
125
+ controllerWatcher: ControllerWatcher;
126
+ constructor(ctx: Ctx);
127
+ scan(): Promise<void>;
128
+ listen(): void;
129
+ /**
130
+ * 1. 构建
131
+ * 2. 加载
132
+ * 3. 格式化
133
+ * @param absoluteFilePathOriginList 更新的文件
134
+ * @returns 更新的文件列表
135
+ */
136
+ private buildResolve;
137
+ }
138
+
139
+ declare const getConfigCtx: (envParams: TEnvParams, cmd: TAny, defaultDora: PartialRecursive<TDoraConfig>) => Promise<ConfigCtx>;
140
+
141
+ declare const getServerCtx: (configCtx: ConfigCtx, app: Application, envParams: TEnvParams) => Promise<Ctx>;
142
+
143
+ export { ServerWorkflow, getConfigCtx, getServerCtx };
package/package.json CHANGED
@@ -1,11 +1,16 @@
1
1
  {
2
2
  "name": "@doracli/express-server",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "description": "use server",
5
5
  "author": "cclr <18843152354@163.com>",
6
6
  "homepage": "",
7
7
  "license": "MIT",
8
8
  "type": "module",
9
+ "exports": {
10
+ "import": "./lib/esm/index.js",
11
+ "require": "./lib/cjs/index.js"
12
+ },
13
+ "types": "lib/type/index.d.ts",
9
14
  "bin": {
10
15
  "des": "bin/enter.mjs"
11
16
  },
@@ -27,19 +32,21 @@
27
32
  "g:build": "drn build"
28
33
  },
29
34
  "dependencies": {
30
- "@cclr/lang": "^0.1.28",
31
- "@cclr/utils": "^0.1.28",
32
- "@dorabag/config-loader": "^1.0.11",
35
+ "@cclr/lang": "^0.1.44",
36
+ "@cclr/utils": "^0.1.44",
37
+ "@dorabag/config-loader": "^1.0.16",
33
38
  "@dorabag/file-pro": "^1.0.10",
34
- "@doracli/commander": "0.0.2",
35
- "@doracli/define-server": "0.0.2",
36
- "@doracli/esbuild": "0.0.2",
37
- "@doracli/express": "0.0.2",
38
- "@doracli/helper": "0.0.2",
39
- "@doracli/type": "0.0.2",
40
- "@types/express": "^5.0.4",
39
+ "@dorabag/open-browser": "^1.0.16",
40
+ "@dorabag/srv-tool": "^1.0.16",
41
+ "@doracli/commander": "0.0.4",
42
+ "@doracli/define-server": "0.0.4",
43
+ "@doracli/esbuild": "0.0.4",
44
+ "@doracli/express": "0.0.4",
45
+ "@doracli/helper": "0.0.4",
46
+ "@doracli/type": "0.0.4",
47
+ "@types/express": "^5.0.6",
41
48
  "chokidar": "^4.0.3",
42
- "express": "^5.1.0"
49
+ "express": "^5.2.1"
43
50
  },
44
- "gitHead": "912cb44292b64679630a799974d18c22b2e69738"
51
+ "gitHead": "a978bb7e7b32c192b1eb527dae5f25bbe1a2af86"
45
52
  }