@4399ywkf/core 4.0.85 → 5.0.0
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/cli/index.js +2180 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/config/index.d.ts +37 -0
- package/dist/config/index.js +143 -0
- package/dist/config/index.js.map +1 -0
- package/dist/index.d.ts +496 -6
- package/dist/index.js +3671 -49
- package/dist/index.js.map +1 -0
- package/dist/plugin/index.d.ts +110 -0
- package/dist/plugin/index.js +277 -0
- package/dist/plugin/index.js.map +1 -0
- package/dist/router/index.d.ts +126 -0
- package/dist/router/index.js +390 -0
- package/dist/router/index.js.map +1 -0
- package/dist/rspack/index.d.ts +29 -0
- package/dist/rspack/index.js +1574 -0
- package/dist/rspack/index.js.map +1 -0
- package/dist/runtime/index.d.ts +120 -0
- package/dist/runtime/index.js +406 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/schema-BuqmN_ra.d.ts +390 -0
- package/dist/types-BZV_2QtD.d.ts +97 -0
- package/package.json +88 -37
- package/README.md +0 -3
- package/compiled/dotenv/LICENSE +0 -23
- package/compiled/dotenv/index.js +0 -1
- package/compiled/dotenv/lib/main.d.ts +0 -73
- package/compiled/dotenv/package.json +0 -1
- package/compiled/dotenv/types/index.d.ts +0 -59
- package/compiled/dotenv-expand/LICENSE +0 -24
- package/compiled/dotenv-expand/index.js +0 -1
- package/compiled/dotenv-expand/lib/main.d.ts +0 -29
- package/compiled/dotenv-expand/package.json +0 -1
- package/compiled/just-diff/LICENSE +0 -21
- package/compiled/just-diff/index.d.ts +0 -20
- package/compiled/just-diff/index.js +0 -1
- package/compiled/just-diff/package.json +0 -1
- package/dist/config/config.d.ts +0 -62
- package/dist/config/config.js +0 -240
- package/dist/config/utils.d.ts +0 -8
- package/dist/config/utils.js +0 -40
- package/dist/constants.d.ts +0 -9
- package/dist/constants.js +0 -45
- package/dist/route/defineRoutes.d.ts +0 -1
- package/dist/route/defineRoutes.js +0 -61
- package/dist/route/route.d.ts +0 -3
- package/dist/route/route.js +0 -27
- package/dist/route/routeUtils.d.ts +0 -8
- package/dist/route/routeUtils.js +0 -46
- package/dist/route/routesConfig.d.ts +0 -6
- package/dist/route/routesConfig.js +0 -125
- package/dist/route/routesConvention.d.ts +0 -5
- package/dist/route/routesConvention.js +0 -88
- package/dist/route/utils.d.ts +0 -8
- package/dist/route/utils.js +0 -59
- package/dist/service/command.d.ts +0 -30
- package/dist/service/command.js +0 -39
- package/dist/service/env.d.ts +0 -4
- package/dist/service/env.js +0 -47
- package/dist/service/generatePlugin.d.ts +0 -4
- package/dist/service/generatePlugin.js +0 -102
- package/dist/service/generator.d.ts +0 -71
- package/dist/service/generator.js +0 -40
- package/dist/service/hook.d.ts +0 -16
- package/dist/service/hook.js +0 -52
- package/dist/service/path.d.ts +0 -15
- package/dist/service/path.js +0 -55
- package/dist/service/plugin.d.ts +0 -61
- package/dist/service/plugin.js +0 -174
- package/dist/service/pluginAPI.d.ts +0 -49
- package/dist/service/pluginAPI.js +0 -233
- package/dist/service/service.d.ts +0 -147
- package/dist/service/service.js +0 -544
- package/dist/service/servicePlugin.d.ts +0 -3
- package/dist/service/servicePlugin.js +0 -37
- package/dist/service/telemetry.d.ts +0 -32
- package/dist/service/telemetry.js +0 -127
- package/dist/service/utils.d.ts +0 -2
- package/dist/service/utils.js +0 -36
- package/dist/types.d.ts +0 -116
- package/dist/types.js +0 -77
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
import { Configuration } from '@rspack/core';
|
|
2
|
+
import { A as AppConfig, P as ProviderConfig } from './types-BZV_2QtD.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 路由项定义
|
|
6
|
+
*/
|
|
7
|
+
interface RouteItem {
|
|
8
|
+
/** 路由路径 */
|
|
9
|
+
path: string;
|
|
10
|
+
/** 组件文件路径(相对于 src) */
|
|
11
|
+
component: string;
|
|
12
|
+
/** 是否为 index 路由 */
|
|
13
|
+
index?: boolean;
|
|
14
|
+
/** 是否为布局组件 */
|
|
15
|
+
isLayout?: boolean;
|
|
16
|
+
/** 子路由 */
|
|
17
|
+
children?: RouteItem[];
|
|
18
|
+
/** 路由元信息 */
|
|
19
|
+
meta?: RouteMeta;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* 路由元信息
|
|
23
|
+
*/
|
|
24
|
+
interface RouteMeta {
|
|
25
|
+
/** 页面标题 */
|
|
26
|
+
title?: string;
|
|
27
|
+
/** 是否需要登录 */
|
|
28
|
+
auth?: boolean;
|
|
29
|
+
/** 自定义数据 */
|
|
30
|
+
[key: string]: unknown;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* 插件上下文
|
|
35
|
+
*/
|
|
36
|
+
interface PluginContext {
|
|
37
|
+
/** 工作目录 */
|
|
38
|
+
cwd: string;
|
|
39
|
+
/** 是否开发模式 */
|
|
40
|
+
isDev: boolean;
|
|
41
|
+
/** 是否生产模式 */
|
|
42
|
+
isProd: boolean;
|
|
43
|
+
/** 用户配置 */
|
|
44
|
+
config: Required<YwkfConfig>;
|
|
45
|
+
/** 日志工具 */
|
|
46
|
+
logger: PluginLogger;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* 插件日志工具
|
|
50
|
+
*/
|
|
51
|
+
interface PluginLogger {
|
|
52
|
+
info: (message: string) => void;
|
|
53
|
+
warn: (message: string) => void;
|
|
54
|
+
error: (message: string) => void;
|
|
55
|
+
debug: (message: string) => void;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* 构建阶段钩子
|
|
59
|
+
*/
|
|
60
|
+
interface BuildHooks {
|
|
61
|
+
/**
|
|
62
|
+
* 修改 Rspack 配置
|
|
63
|
+
*/
|
|
64
|
+
modifyRspackConfig?: (config: Configuration, context: PluginContext) => Configuration | void | Promise<Configuration | void>;
|
|
65
|
+
/**
|
|
66
|
+
* 构建开始前
|
|
67
|
+
*/
|
|
68
|
+
beforeBuild?: (context: PluginContext) => void | Promise<void>;
|
|
69
|
+
/**
|
|
70
|
+
* 构建完成后
|
|
71
|
+
*/
|
|
72
|
+
afterBuild?: (context: PluginContext, stats: {
|
|
73
|
+
success: boolean;
|
|
74
|
+
errors?: string[];
|
|
75
|
+
}) => void | Promise<void>;
|
|
76
|
+
/**
|
|
77
|
+
* 开发服务器启动前
|
|
78
|
+
*/
|
|
79
|
+
beforeDevServer?: (context: PluginContext) => void | Promise<void>;
|
|
80
|
+
/**
|
|
81
|
+
* 开发服务器启动后
|
|
82
|
+
*/
|
|
83
|
+
afterDevServer?: (context: PluginContext, server: {
|
|
84
|
+
port: number;
|
|
85
|
+
host: string;
|
|
86
|
+
}) => void | Promise<void>;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* 路由阶段钩子
|
|
90
|
+
*/
|
|
91
|
+
interface RouterHooks {
|
|
92
|
+
/**
|
|
93
|
+
* 修改路由配置
|
|
94
|
+
*/
|
|
95
|
+
modifyRoutes?: (routes: RouteItem[], context: PluginContext) => RouteItem[] | void | Promise<RouteItem[] | void>;
|
|
96
|
+
/**
|
|
97
|
+
* 路由生成后
|
|
98
|
+
*/
|
|
99
|
+
afterRoutesGenerated?: (routes: RouteItem[], context: PluginContext) => void | Promise<void>;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* 运行时阶段钩子
|
|
103
|
+
*/
|
|
104
|
+
interface RuntimeHooks {
|
|
105
|
+
/**
|
|
106
|
+
* 修改运行时配置
|
|
107
|
+
*/
|
|
108
|
+
modifyAppConfig?: (appConfig: AppConfig, context: PluginContext) => AppConfig | void;
|
|
109
|
+
/**
|
|
110
|
+
* 添加 Provider
|
|
111
|
+
*/
|
|
112
|
+
addProvider?: (context: PluginContext) => ProviderConfig | ProviderConfig[];
|
|
113
|
+
/**
|
|
114
|
+
* 应用渲染前
|
|
115
|
+
*/
|
|
116
|
+
beforeRender?: (context: PluginContext) => void;
|
|
117
|
+
/**
|
|
118
|
+
* 应用渲染后
|
|
119
|
+
*/
|
|
120
|
+
afterRender?: (context: PluginContext) => void;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* 生成的文件
|
|
124
|
+
*/
|
|
125
|
+
interface GeneratedFile {
|
|
126
|
+
/** 文件路径(相对于 .ywkf 目录) */
|
|
127
|
+
path: string;
|
|
128
|
+
/** 文件内容 */
|
|
129
|
+
content: string;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* 代码生成器上下文
|
|
133
|
+
*/
|
|
134
|
+
interface GeneratorContext {
|
|
135
|
+
/** 工作目录 */
|
|
136
|
+
cwd: string;
|
|
137
|
+
/** 输出目录(.ywkf) */
|
|
138
|
+
outputDir: string;
|
|
139
|
+
/** 用户配置 */
|
|
140
|
+
config: Required<YwkfConfig>;
|
|
141
|
+
/** 是否开发模式 */
|
|
142
|
+
isDev: boolean;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* 代码注入点
|
|
146
|
+
*/
|
|
147
|
+
interface CodeInjection {
|
|
148
|
+
/** 导入语句 */
|
|
149
|
+
imports?: string[];
|
|
150
|
+
/** 顶层代码(在函数外部) */
|
|
151
|
+
topLevel?: string[];
|
|
152
|
+
/** 导出语句 */
|
|
153
|
+
exports?: string[];
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* 代码生成阶段钩子
|
|
157
|
+
*/
|
|
158
|
+
interface GeneratorHooks {
|
|
159
|
+
/**
|
|
160
|
+
* 修改入口文件代码
|
|
161
|
+
*/
|
|
162
|
+
modifyEntryCode?: (code: string, context: GeneratorContext) => string | void;
|
|
163
|
+
/**
|
|
164
|
+
* 修改启动文件代码
|
|
165
|
+
*/
|
|
166
|
+
modifyBootstrapCode?: (code: string, context: GeneratorContext) => string | void;
|
|
167
|
+
/**
|
|
168
|
+
* 注入入口代码
|
|
169
|
+
* 返回需要注入到入口文件的代码片段
|
|
170
|
+
*/
|
|
171
|
+
injectEntry?: (context: GeneratorContext) => CodeInjection | void;
|
|
172
|
+
/**
|
|
173
|
+
* 注入启动代码
|
|
174
|
+
* 返回需要注入到启动文件的代码片段
|
|
175
|
+
*/
|
|
176
|
+
injectBootstrap?: (context: GeneratorContext) => CodeInjection | void;
|
|
177
|
+
/**
|
|
178
|
+
* 生成额外文件
|
|
179
|
+
*/
|
|
180
|
+
generateFiles?: (context: GeneratorContext) => GeneratedFile[] | void;
|
|
181
|
+
/**
|
|
182
|
+
* 代码生成完成后
|
|
183
|
+
*/
|
|
184
|
+
afterGenerate?: (context: GeneratorContext) => void | Promise<void>;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* 插件钩子集合
|
|
188
|
+
*/
|
|
189
|
+
interface PluginHooks extends BuildHooks, RouterHooks, RuntimeHooks, GeneratorHooks {
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* 插件定义
|
|
193
|
+
*/
|
|
194
|
+
interface YwkfPlugin {
|
|
195
|
+
/** 插件名称 */
|
|
196
|
+
name: string;
|
|
197
|
+
/** 插件版本 */
|
|
198
|
+
version?: string;
|
|
199
|
+
/** 插件描述 */
|
|
200
|
+
description?: string;
|
|
201
|
+
/**
|
|
202
|
+
* 插件初始化
|
|
203
|
+
* @returns 插件钩子
|
|
204
|
+
*/
|
|
205
|
+
setup: (context: PluginContext) => PluginHooks | Promise<PluginHooks>;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* 插件配置(用户在 ywkf.config.ts 中使用)
|
|
209
|
+
*/
|
|
210
|
+
type PluginConfig = string | YwkfPlugin | [string, Record<string, unknown>] | [YwkfPlugin, Record<string, unknown>];
|
|
211
|
+
/**
|
|
212
|
+
* 创建插件的辅助函数类型
|
|
213
|
+
*/
|
|
214
|
+
type DefinePlugin = (options?: Record<string, unknown>) => YwkfPlugin;
|
|
215
|
+
/**
|
|
216
|
+
* 插件 API(传递给插件的 setup 函数)
|
|
217
|
+
*/
|
|
218
|
+
interface PluginAPI {
|
|
219
|
+
/** 获取配置 */
|
|
220
|
+
getConfig: () => Required<YwkfConfig>;
|
|
221
|
+
/** 获取工作目录 */
|
|
222
|
+
getCwd: () => string;
|
|
223
|
+
/** 是否开发环境 */
|
|
224
|
+
isDev: () => boolean;
|
|
225
|
+
/** 添加 Rspack 插件 */
|
|
226
|
+
addRspackPlugin: (plugin: unknown) => void;
|
|
227
|
+
/** 修改 Rspack 配置 */
|
|
228
|
+
modifyRspackConfig: (modifier: (config: Configuration) => Configuration | void) => void;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* 开发服务器配置
|
|
233
|
+
*/
|
|
234
|
+
interface DevServerConfig {
|
|
235
|
+
/** 开发服务器端口 */
|
|
236
|
+
port?: number;
|
|
237
|
+
/** 开发服务器主机 */
|
|
238
|
+
host?: string;
|
|
239
|
+
/** 代理配置 */
|
|
240
|
+
proxy?: Record<string, string | object>;
|
|
241
|
+
/** 是否开启 HTTPS */
|
|
242
|
+
https?: boolean;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* 输出配置
|
|
246
|
+
*/
|
|
247
|
+
interface OutputConfig {
|
|
248
|
+
/** 输出目录 */
|
|
249
|
+
path?: string;
|
|
250
|
+
/** 公共路径 */
|
|
251
|
+
publicPath?: string;
|
|
252
|
+
/** 是否清理输出目录 */
|
|
253
|
+
clean?: boolean;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* HTML 配置
|
|
257
|
+
*/
|
|
258
|
+
interface HtmlConfig {
|
|
259
|
+
/** 页面标题 */
|
|
260
|
+
title?: string;
|
|
261
|
+
/** HTML 模板路径 */
|
|
262
|
+
template?: string;
|
|
263
|
+
/** favicon 路径 */
|
|
264
|
+
favicon?: string;
|
|
265
|
+
/** 挂载根元素 ID */
|
|
266
|
+
mountRoot?: string;
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* 样式配置
|
|
270
|
+
*/
|
|
271
|
+
interface StyleConfig {
|
|
272
|
+
/** 是否启用 CSS Modules */
|
|
273
|
+
cssModules?: boolean;
|
|
274
|
+
/** Less 配置 */
|
|
275
|
+
less?: {
|
|
276
|
+
/** 是否启用 */
|
|
277
|
+
enabled?: boolean;
|
|
278
|
+
/** Less 选项 */
|
|
279
|
+
lessOptions?: Record<string, unknown>;
|
|
280
|
+
};
|
|
281
|
+
/** Sass 配置 */
|
|
282
|
+
sass?: {
|
|
283
|
+
/** 是否启用 */
|
|
284
|
+
enabled?: boolean;
|
|
285
|
+
/** Sass 选项 */
|
|
286
|
+
sassOptions?: Record<string, unknown>;
|
|
287
|
+
};
|
|
288
|
+
/** 是否启用 TailwindCSS */
|
|
289
|
+
tailwindcss?: boolean;
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* 路由配置
|
|
293
|
+
*/
|
|
294
|
+
interface RouterConfig {
|
|
295
|
+
/** 路由基础路径 */
|
|
296
|
+
basename?: string;
|
|
297
|
+
/** 是否启用约定式路由 */
|
|
298
|
+
conventional?: boolean;
|
|
299
|
+
/** 约定式路由扫描目录 */
|
|
300
|
+
pagesDir?: string;
|
|
301
|
+
/** 排除的文件/目录模式 */
|
|
302
|
+
exclude?: (string | RegExp)[];
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* 微前端配置
|
|
306
|
+
*/
|
|
307
|
+
interface MicroFrontendConfig {
|
|
308
|
+
/** 是否启用微前端模式 */
|
|
309
|
+
enabled?: boolean;
|
|
310
|
+
/** 应用名称(用于 UMD 导出) */
|
|
311
|
+
name?: string;
|
|
312
|
+
/** 微前端框架类型 */
|
|
313
|
+
framework?: "qiankun" | "garfish";
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* 性能配置
|
|
317
|
+
*/
|
|
318
|
+
interface PerformanceConfig {
|
|
319
|
+
/** 是否启用 Rsdoctor 分析 */
|
|
320
|
+
rsdoctor?: boolean;
|
|
321
|
+
/** 是否开启代码分割 */
|
|
322
|
+
splitChunks?: boolean;
|
|
323
|
+
/** 是否移除 console */
|
|
324
|
+
dropConsole?: boolean;
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* 工具链配置
|
|
328
|
+
*/
|
|
329
|
+
interface ToolsConfig {
|
|
330
|
+
/**
|
|
331
|
+
* 自定义 Rspack 配置
|
|
332
|
+
* @param config 当前配置
|
|
333
|
+
* @param context 上下文信息
|
|
334
|
+
* @returns 修改后的配置
|
|
335
|
+
*/
|
|
336
|
+
rspack?: (config: Configuration, context: {
|
|
337
|
+
isDev: boolean;
|
|
338
|
+
isProd: boolean;
|
|
339
|
+
}) => Configuration | void;
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* 环境变量配置
|
|
343
|
+
*/
|
|
344
|
+
interface EnvConfig {
|
|
345
|
+
/** 公共环境变量文件路径 */
|
|
346
|
+
publicEnvFile?: string;
|
|
347
|
+
/** 环境特定的变量文件目录 */
|
|
348
|
+
envDir?: string;
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* 框架完整配置
|
|
352
|
+
*/
|
|
353
|
+
interface YwkfConfig {
|
|
354
|
+
/** 应用名称 */
|
|
355
|
+
appName?: string;
|
|
356
|
+
/** 应用中文名 */
|
|
357
|
+
appCName?: string;
|
|
358
|
+
/** 开发服务器配置 */
|
|
359
|
+
dev?: DevServerConfig;
|
|
360
|
+
/** 输出配置 */
|
|
361
|
+
output?: OutputConfig;
|
|
362
|
+
/** HTML 配置 */
|
|
363
|
+
html?: HtmlConfig;
|
|
364
|
+
/** 样式配置 */
|
|
365
|
+
style?: StyleConfig;
|
|
366
|
+
/** 路由配置 */
|
|
367
|
+
router?: RouterConfig;
|
|
368
|
+
/** 微前端配置 */
|
|
369
|
+
microFrontend?: MicroFrontendConfig;
|
|
370
|
+
/** 性能配置 */
|
|
371
|
+
performance?: PerformanceConfig;
|
|
372
|
+
/** 工具链配置 */
|
|
373
|
+
tools?: ToolsConfig;
|
|
374
|
+
/** 环境变量配置 */
|
|
375
|
+
env?: EnvConfig;
|
|
376
|
+
/** 路径别名 */
|
|
377
|
+
alias?: Record<string, string>;
|
|
378
|
+
/** 插件列表 */
|
|
379
|
+
plugins?: PluginConfig[];
|
|
380
|
+
}
|
|
381
|
+
/**
|
|
382
|
+
* 定义配置的辅助函数(提供类型提示)
|
|
383
|
+
*/
|
|
384
|
+
declare function defineConfig(config: YwkfConfig): YwkfConfig;
|
|
385
|
+
/**
|
|
386
|
+
* 默认配置
|
|
387
|
+
*/
|
|
388
|
+
declare const defaultConfig: Required<YwkfConfig>;
|
|
389
|
+
|
|
390
|
+
export { type BuildHooks as B, type CodeInjection as C, type DevServerConfig as D, type EnvConfig as E, type GeneratorContext as G, type HtmlConfig as H, type MicroFrontendConfig as M, type OutputConfig as O, type PerformanceConfig as P, type RouterConfig as R, type StyleConfig as S, type ToolsConfig as T, type YwkfConfig as Y, defaultConfig as a, type PluginHooks as b, type PluginConfig as c, defineConfig as d, type YwkfPlugin as e, type PluginContext as f, type RouterHooks as g, type RuntimeHooks as h, type GeneratorHooks as i, type GeneratedFile as j, type RouteItem as k, type PluginLogger as l, type PluginAPI as m, type DefinePlugin as n };
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { createBrowserRouter } from 'react-router';
|
|
3
|
+
|
|
4
|
+
/** 路由实例类型 */
|
|
5
|
+
type RouterInstance = ReturnType<typeof createBrowserRouter>;
|
|
6
|
+
/**
|
|
7
|
+
* 应用配置
|
|
8
|
+
*/
|
|
9
|
+
interface AppConfig {
|
|
10
|
+
/** 应用名称 */
|
|
11
|
+
appName?: string;
|
|
12
|
+
/** 路由实例(手动配置时使用) */
|
|
13
|
+
router?: RouterInstance;
|
|
14
|
+
/** 路由 basename */
|
|
15
|
+
basename?: string;
|
|
16
|
+
/**
|
|
17
|
+
* 使用约定式路由
|
|
18
|
+
* 设为 true 时,框架自动从 @ywkf/routes 加载生成的路由
|
|
19
|
+
* 无需手动配置 router
|
|
20
|
+
*/
|
|
21
|
+
conventionalRoutes?: boolean;
|
|
22
|
+
/** 根元素 ID */
|
|
23
|
+
rootId?: string;
|
|
24
|
+
/** 是否启用严格模式 */
|
|
25
|
+
strictMode?: boolean;
|
|
26
|
+
/** Ant Design 配置 */
|
|
27
|
+
antd?: AntdConfig;
|
|
28
|
+
/** 自定义 Providers */
|
|
29
|
+
providers?: ProviderConfig[];
|
|
30
|
+
/** 生命周期钩子 */
|
|
31
|
+
lifecycle?: LifecycleHooks;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Ant Design 配置
|
|
35
|
+
*/
|
|
36
|
+
interface AntdConfig {
|
|
37
|
+
/** 是否启用 */
|
|
38
|
+
enabled?: boolean;
|
|
39
|
+
/** 主题配置 */
|
|
40
|
+
theme?: Record<string, unknown>;
|
|
41
|
+
/** 语言包 */
|
|
42
|
+
locale?: object;
|
|
43
|
+
/** ConfigProvider props */
|
|
44
|
+
configProvider?: Record<string, unknown>;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Provider 配置
|
|
48
|
+
*/
|
|
49
|
+
interface ProviderConfig {
|
|
50
|
+
/** Provider 组件 */
|
|
51
|
+
component: React.ComponentType<{
|
|
52
|
+
children: ReactNode;
|
|
53
|
+
}>;
|
|
54
|
+
/** Provider props */
|
|
55
|
+
props?: Record<string, unknown>;
|
|
56
|
+
/** 排序权重(越小越外层) */
|
|
57
|
+
order?: number;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* 生命周期钩子
|
|
61
|
+
*/
|
|
62
|
+
interface LifecycleHooks {
|
|
63
|
+
/** 应用挂载前 */
|
|
64
|
+
onBeforeMount?: () => void | Promise<void>;
|
|
65
|
+
/** 应用挂载后 */
|
|
66
|
+
onMounted?: () => void;
|
|
67
|
+
/** 应用卸载时 */
|
|
68
|
+
onUnmount?: () => void;
|
|
69
|
+
/** 全局错误处理 */
|
|
70
|
+
onError?: (error: Error, errorInfo?: React.ErrorInfo) => void;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* 应用上下文数据
|
|
74
|
+
*/
|
|
75
|
+
interface AppContextValue {
|
|
76
|
+
/** 应用名称 */
|
|
77
|
+
appName: string;
|
|
78
|
+
/** 路由 basename */
|
|
79
|
+
basename: string;
|
|
80
|
+
/** 是否开发环境 */
|
|
81
|
+
isDev: boolean;
|
|
82
|
+
/** 环境变量 */
|
|
83
|
+
env: Record<string, string | undefined>;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* 微前端相关配置
|
|
87
|
+
*/
|
|
88
|
+
interface MicroAppConfig {
|
|
89
|
+
/** 是否作为子应用运行 */
|
|
90
|
+
isMicroApp?: boolean;
|
|
91
|
+
/** 微前端框架类型 */
|
|
92
|
+
framework?: "qiankun" | "garfish";
|
|
93
|
+
/** 主应用传递的 props */
|
|
94
|
+
masterProps?: Record<string, unknown>;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export type { AppConfig as A, LifecycleHooks as L, MicroAppConfig as M, ProviderConfig as P, AntdConfig as a, AppContextValue as b };
|
package/package.json
CHANGED
|
@@ -1,49 +1,100 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@4399ywkf/core",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
"version": "5.0.0",
|
|
4
|
+
"description": "4399运维客服前端框架核心",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./config": {
|
|
14
|
+
"types": "./dist/config/index.d.ts",
|
|
15
|
+
"import": "./dist/config/index.js"
|
|
16
|
+
},
|
|
17
|
+
"./rspack": {
|
|
18
|
+
"types": "./dist/rspack/index.d.ts",
|
|
19
|
+
"import": "./dist/rspack/index.js"
|
|
20
|
+
},
|
|
21
|
+
"./router": {
|
|
22
|
+
"types": "./dist/router/index.d.ts",
|
|
23
|
+
"import": "./dist/router/index.js"
|
|
24
|
+
},
|
|
25
|
+
"./runtime": {
|
|
26
|
+
"types": "./dist/runtime/index.d.ts",
|
|
27
|
+
"import": "./dist/runtime/index.js"
|
|
28
|
+
},
|
|
29
|
+
"./plugin": {
|
|
30
|
+
"types": "./dist/plugin/index.d.ts",
|
|
31
|
+
"import": "./dist/plugin/index.js"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"bin": {
|
|
35
|
+
"ywkf": "./dist/cli/index.js"
|
|
9
36
|
},
|
|
10
|
-
"license": "MIT",
|
|
11
|
-
"main": "dist/index.js",
|
|
12
|
-
"types": "dist/index.d.ts",
|
|
13
37
|
"files": [
|
|
14
|
-
"dist"
|
|
15
|
-
"compiled"
|
|
38
|
+
"dist"
|
|
16
39
|
],
|
|
40
|
+
"scripts": {
|
|
41
|
+
"build": "tsup",
|
|
42
|
+
"dev": "tsup --watch",
|
|
43
|
+
"typecheck": "tsc --noEmit"
|
|
44
|
+
},
|
|
17
45
|
"dependencies": {
|
|
18
|
-
"@
|
|
19
|
-
"@
|
|
46
|
+
"@rsdoctor/rspack-plugin": "^1.1.0",
|
|
47
|
+
"@rspack/cli": "^1.3.6",
|
|
48
|
+
"@rspack/core": "^1.3.6",
|
|
49
|
+
"@svgr/webpack": "^8.1.0",
|
|
50
|
+
"@tailwindcss/postcss": "^4.2.1",
|
|
51
|
+
"assert": "^2.1.0",
|
|
52
|
+
"autoprefixer": "^10.4.27",
|
|
53
|
+
"browserify-zlib": "^0.2.0",
|
|
54
|
+
"buffer": "^6.0.3",
|
|
55
|
+
"chalk": "^5.4.1",
|
|
56
|
+
"commander": "^13.1.0",
|
|
57
|
+
"crypto-browserify": "^3.12.1",
|
|
58
|
+
"css-loader": "^7.1.2",
|
|
59
|
+
"deepmerge": "^4.3.1",
|
|
60
|
+
"dotenv": "^16.5.0",
|
|
61
|
+
"esbuild-register": "^3.6.0",
|
|
62
|
+
"jiti": "^2.4.2",
|
|
63
|
+
"less": "^4.3.0",
|
|
64
|
+
"less-loader": "^12.3.0",
|
|
65
|
+
"ora": "^8.2.0",
|
|
66
|
+
"path-browserify": "^1.0.1",
|
|
67
|
+
"postcss": "^8.5.3",
|
|
68
|
+
"postcss-loader": "^8.1.1",
|
|
69
|
+
"process": "^0.11.10",
|
|
70
|
+
"querystring-es3": "^0.2.1",
|
|
71
|
+
"sass": "^1.86.0",
|
|
72
|
+
"sass-loader": "^16.0.5",
|
|
73
|
+
"stream-browserify": "^3.0.0",
|
|
74
|
+
"style-loader": "^4.0.0",
|
|
75
|
+
"url": "^0.11.4",
|
|
76
|
+
"util": "^0.12.5",
|
|
77
|
+
"webpack-merge": "^6.0.1"
|
|
20
78
|
},
|
|
21
79
|
"devDependencies": {
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
80
|
+
"@types/node": "^22.13.10",
|
|
81
|
+
"@types/react": "^19.2.14",
|
|
82
|
+
"@types/react-dom": "^19.2.3",
|
|
83
|
+
"antd": "^6.3.1",
|
|
84
|
+
"react": "^19.2.4",
|
|
85
|
+
"react-dom": "^19.2.4",
|
|
86
|
+
"react-router": "^7.13.1",
|
|
87
|
+
"tsup": "^8.4.0",
|
|
88
|
+
"typescript": "^5.8.2"
|
|
25
89
|
},
|
|
26
|
-
"
|
|
27
|
-
"
|
|
90
|
+
"peerDependencies": {
|
|
91
|
+
"react": "^18.0.0",
|
|
92
|
+
"react-dom": "^18.0.0"
|
|
28
93
|
},
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
],
|
|
32
|
-
"compiledConfig": {
|
|
33
|
-
"deps": [
|
|
34
|
-
"dotenv",
|
|
35
|
-
"just-diff"
|
|
36
|
-
],
|
|
37
|
-
"externals": {
|
|
38
|
-
"dotenv": "$$LOCAL",
|
|
39
|
-
"just-diff": "$$LOCAL",
|
|
40
|
-
"tapable": "@4399ywkf/bundler-utils/compiled/tapable"
|
|
41
|
-
}
|
|
94
|
+
"engines": {
|
|
95
|
+
"node": ">=18.0.0"
|
|
42
96
|
},
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"build:deps": "umi-scripts bundleDeps",
|
|
46
|
-
"dev": "umi-scripts father dev",
|
|
47
|
-
"test": "umi-scripts jest-turbo"
|
|
97
|
+
"publishConfig": {
|
|
98
|
+
"access": "public"
|
|
48
99
|
}
|
|
49
|
-
}
|
|
100
|
+
}
|
package/README.md
DELETED
package/compiled/dotenv/LICENSE
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
Copyright (c) 2015, Scott Motte
|
|
2
|
-
All rights reserved.
|
|
3
|
-
|
|
4
|
-
Redistribution and use in source and binary forms, with or without
|
|
5
|
-
modification, are permitted provided that the following conditions are met:
|
|
6
|
-
|
|
7
|
-
* Redistributions of source code must retain the above copyright notice, this
|
|
8
|
-
list of conditions and the following disclaimer.
|
|
9
|
-
|
|
10
|
-
* Redistributions in binary form must reproduce the above copyright notice,
|
|
11
|
-
this list of conditions and the following disclaimer in the documentation
|
|
12
|
-
and/or other materials provided with the distribution.
|
|
13
|
-
|
|
14
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
15
|
-
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
16
|
-
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
17
|
-
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
18
|
-
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
19
|
-
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
20
|
-
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
21
|
-
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
22
|
-
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
23
|
-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/compiled/dotenv/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(function(){var e={875:function(e,r,n){const o=n(147);const t=n(17);const s=n(37);const i=/(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/gm;function parse(e){const r={};let n=e.toString();n=n.replace(/\r\n?/gm,"\n");let o;while((o=i.exec(n))!=null){const e=o[1];let n=o[2]||"";n=n.trim();const t=n[0];n=n.replace(/^(['"`])([\s\S]*)\1$/gm,"$2");if(t==='"'){n=n.replace(/\\n/g,"\n");n=n.replace(/\\r/g,"\r")}r[e]=n}return r}function _log(e){console.log(`[dotenv][DEBUG] ${e}`)}function _resolveHome(e){return e[0]==="~"?t.join(s.homedir(),e.slice(1)):e}function config(e){let r=t.resolve(process.cwd(),".env");let n="utf8";const s=Boolean(e&&e.debug);const i=Boolean(e&&e.override);if(e){if(e.path!=null){r=_resolveHome(e.path)}if(e.encoding!=null){n=e.encoding}}try{const e=c.parse(o.readFileSync(r,{encoding:n}));Object.keys(e).forEach((function(r){if(!Object.prototype.hasOwnProperty.call(process.env,r)){process.env[r]=e[r]}else{if(i===true){process.env[r]=e[r]}if(s){if(i===true){_log(`"${r}" is already defined in \`process.env\` and WAS overwritten`)}else{_log(`"${r}" is already defined in \`process.env\` and was NOT overwritten`)}}}}));return{parsed:e}}catch(e){if(s){_log(`Failed to load ${r} ${e.message}`)}return{error:e}}}const c={config:config,parse:parse};e.exports.config=c.config;e.exports.parse=c.parse;e.exports=c},147:function(e){"use strict";e.exports=require("fs")},37:function(e){"use strict";e.exports=require("os")},17:function(e){"use strict";e.exports=require("path")}};var r={};function __nccwpck_require__(n){var o=r[n];if(o!==undefined){return o.exports}var t=r[n]={exports:{}};var s=true;try{e[n](t,t.exports,__nccwpck_require__);s=false}finally{if(s)delete r[n]}return t.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var n=__nccwpck_require__(875);module.exports=n})();
|