@4399ywkf/core 5.0.27 → 5.0.28

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.
@@ -169,4 +169,4 @@ interface RequestConfig {
169
169
  errorHandler?: (error: Record<string, unknown>) => unknown;
170
170
  }
171
171
 
172
- export type { AppConfig as A, LifecycleHooks as L, MicroAppConfig as M, ProviderConfig as P, RequestConfig as R, AntdConfig as a, AppContextValue as b, Result as c };
172
+ export type { AntdConfig as A, LifecycleHooks as L, MicroAppConfig as M, ProviderConfig as P, RequestConfig as R, AppConfig as a, AppContextValue as b, Result as c };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@4399ywkf/core",
3
- "version": "5.0.27",
3
+ "version": "5.0.28",
4
4
  "description": "4399运维开发前端框架核心",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,407 +0,0 @@
1
- import { Configuration } from '@rspack/core';
2
- import { A as AppConfig, P as ProviderConfig } from './types-DbUq-VY8.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 | undefined | Promise<Configuration | undefined>;
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[] | undefined | Promise<RouteItem[] | undefined>;
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 | undefined;
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 | undefined;
163
- /**
164
- * 修改启动文件代码
165
- */
166
- modifyBootstrapCode?: (code: string, context: GeneratorContext) => string | undefined;
167
- /**
168
- * 注入入口代码
169
- * 返回需要注入到入口文件的代码片段
170
- */
171
- injectEntry?: (context: GeneratorContext) => CodeInjection | undefined;
172
- /**
173
- * 注入启动代码
174
- * 返回需要注入到启动文件的代码片段
175
- */
176
- injectBootstrap?: (context: GeneratorContext) => CodeInjection | undefined;
177
- /**
178
- * 生成额外文件
179
- */
180
- generateFiles?: (context: GeneratorContext) => GeneratedFile[] | undefined;
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 | undefined) => 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
- * - `false`:禁用全局默认加载状态(各路由仍可通过 loading.tsx 单独配置)
306
- * - `{ component: string }`:自定义全局默认加载组件的导入路径
307
- * - 不配置:使用内置默认加载组件
308
- *
309
- * @example
310
- * // 禁用加载状态
311
- * loading: false
312
- *
313
- * @example
314
- * // 自定义加载组件
315
- * loading: { component: "@/components/Loading" }
316
- */
317
- loading?: false | {
318
- component: string;
319
- };
320
- }
321
- /**
322
- * 微前端配置
323
- */
324
- interface MicroFrontendConfig {
325
- /** 是否启用微前端模式 */
326
- enabled?: boolean;
327
- /** 应用名称(用于 UMD 导出) */
328
- name?: string;
329
- /** 微前端框架类型 */
330
- framework?: "qiankun" | "garfish";
331
- }
332
- /**
333
- * 性能配置
334
- */
335
- interface PerformanceConfig {
336
- /** 是否启用 Rsdoctor 分析 */
337
- rsdoctor?: boolean;
338
- /** 是否开启代码分割 */
339
- splitChunks?: boolean;
340
- /** 是否移除 console */
341
- dropConsole?: boolean;
342
- }
343
- /**
344
- * 工具链配置
345
- */
346
- interface ToolsConfig {
347
- /**
348
- * 自定义 Rspack 配置
349
- * @param config 当前配置
350
- * @param context 上下文信息
351
- * @returns 修改后的配置
352
- */
353
- rspack?: (config: Configuration, context: {
354
- isDev: boolean;
355
- isProd: boolean;
356
- }) => Configuration | undefined;
357
- }
358
- /**
359
- * 环境变量配置
360
- */
361
- interface EnvConfig {
362
- /** 公共环境变量文件路径 */
363
- publicEnvFile?: string;
364
- /** 环境特定的变量文件目录 */
365
- envDir?: string;
366
- }
367
- /**
368
- * 框架完整配置
369
- */
370
- interface YwkfConfig {
371
- /** 应用名称 */
372
- appName?: string;
373
- /** 应用中文名 */
374
- appCName?: string;
375
- /** 开发服务器配置 */
376
- dev?: DevServerConfig;
377
- /** 输出配置 */
378
- output?: OutputConfig;
379
- /** HTML 配置 */
380
- html?: HtmlConfig;
381
- /** 样式配置 */
382
- style?: StyleConfig;
383
- /** 路由配置 */
384
- router?: RouterConfig;
385
- /** 微前端配置 */
386
- microFrontend?: MicroFrontendConfig;
387
- /** 性能配置 */
388
- performance?: PerformanceConfig;
389
- /** 工具链配置 */
390
- tools?: ToolsConfig;
391
- /** 环境变量配置 */
392
- env?: EnvConfig;
393
- /** 路径别名 */
394
- alias?: Record<string, string>;
395
- /** 插件列表 */
396
- plugins?: PluginConfig[];
397
- }
398
- /**
399
- * 定义配置的辅助函数(提供类型提示)
400
- */
401
- declare function defineConfig(config: YwkfConfig): YwkfConfig;
402
- /**
403
- * 默认配置
404
- */
405
- declare const defaultConfig: Required<YwkfConfig>;
406
-
407
- 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, defineConfig as a, type PluginHooks as b, type PluginConfig as c, defaultConfig as d, type YwkfPlugin as e, type GeneratedFile as f, type GeneratorHooks as g, type PluginContext as h, type RouterHooks as i, type RuntimeHooks as j, type RouteItem as k, type DefinePlugin as l, type PluginAPI as m, type PluginLogger as n };