@kimesh/kit 0.0.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.
- package/README.md +3 -0
- package/dist/index.d.mts +2257 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +2795 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +53 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,2257 @@
|
|
|
1
|
+
import { Hookable } from "hookable";
|
|
2
|
+
import { Ignore } from "ignore";
|
|
3
|
+
import * as vite3 from "vite";
|
|
4
|
+
import { Plugin, Plugin as VitePlugin, PluginOption, PluginOption as VitePluginOption, ResolvedConfig, UserConfig, ViteDevServer } from "vite";
|
|
5
|
+
import { KimeshLayerConfig, LayerAutoImportConfig, LayerComponentConfig, LayerComposableConfig, LayerRouteConfig, ResolvedLayer, ResolvedLayer as ResolvedLayer$1, generateLayerAliases, mergeLayerConfigs, prepareLayers, resolveLayers } from "@kimesh/layers";
|
|
6
|
+
import { AutoImportConfig, ImportPreset, LayerAutoImportSource as ImportSource, buildImportRegistry, generateDts, kimeshAutoImport, scanExports } from "@kimesh/auto-import";
|
|
7
|
+
import { ComponentResolver } from "unplugin-vue-components";
|
|
8
|
+
import { App } from "vue";
|
|
9
|
+
|
|
10
|
+
//#region src/types/components.d.ts
|
|
11
|
+
/**
|
|
12
|
+
* @kimesh/kit - Component Types
|
|
13
|
+
*/
|
|
14
|
+
interface KimeshComponent {
|
|
15
|
+
/** Component name as used in templates */
|
|
16
|
+
name: string;
|
|
17
|
+
/** Path to the component file */
|
|
18
|
+
filePath: string;
|
|
19
|
+
/** Named export to use (default: 'default') */
|
|
20
|
+
export?: string;
|
|
21
|
+
/** Component prefix */
|
|
22
|
+
prefix?: string;
|
|
23
|
+
/** Register globally */
|
|
24
|
+
global?: boolean;
|
|
25
|
+
/** Priority for resolution (higher = preferred) */
|
|
26
|
+
priority?: number;
|
|
27
|
+
/** Source layer name */
|
|
28
|
+
layer?: string;
|
|
29
|
+
}
|
|
30
|
+
interface KimeshComponentsDir {
|
|
31
|
+
/** Path to the components directory */
|
|
32
|
+
path: string;
|
|
33
|
+
/** Component prefix */
|
|
34
|
+
prefix?: string;
|
|
35
|
+
/** Register globally */
|
|
36
|
+
global?: boolean;
|
|
37
|
+
/** Glob pattern for matching components */
|
|
38
|
+
pattern?: string | string[];
|
|
39
|
+
/** Patterns to ignore */
|
|
40
|
+
ignore?: string[];
|
|
41
|
+
/** File extensions to include */
|
|
42
|
+
extensions?: string[];
|
|
43
|
+
/** Enable deep scanning (subdirectories) */
|
|
44
|
+
deep?: boolean;
|
|
45
|
+
/** Source layer name */
|
|
46
|
+
layer?: string;
|
|
47
|
+
}
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region src/types/imports.d.ts
|
|
50
|
+
/**
|
|
51
|
+
* @kimesh/kit - Import Types
|
|
52
|
+
*/
|
|
53
|
+
interface KimeshImport {
|
|
54
|
+
/** Import name */
|
|
55
|
+
name: string;
|
|
56
|
+
/** Alias for the import */
|
|
57
|
+
as?: string;
|
|
58
|
+
/** Module to import from */
|
|
59
|
+
from: string;
|
|
60
|
+
/** Is type-only import */
|
|
61
|
+
type?: boolean;
|
|
62
|
+
/** Priority for resolution */
|
|
63
|
+
priority?: number;
|
|
64
|
+
/** Source layer name */
|
|
65
|
+
layer?: string;
|
|
66
|
+
}
|
|
67
|
+
interface KimeshImportsDir {
|
|
68
|
+
/** Path to the directory */
|
|
69
|
+
path: string;
|
|
70
|
+
/** Only scan these patterns */
|
|
71
|
+
pattern?: string | string[];
|
|
72
|
+
/** Patterns to ignore */
|
|
73
|
+
ignore?: string[];
|
|
74
|
+
/** Import as type-only */
|
|
75
|
+
type?: boolean;
|
|
76
|
+
/** Source layer name */
|
|
77
|
+
layer?: string;
|
|
78
|
+
}
|
|
79
|
+
interface KimeshImportPreset {
|
|
80
|
+
/** Preset name (e.g., 'vue', 'vue-router') */
|
|
81
|
+
from: string;
|
|
82
|
+
/** Imports to include from the preset */
|
|
83
|
+
imports: string[];
|
|
84
|
+
/** Import as type-only */
|
|
85
|
+
type?: boolean;
|
|
86
|
+
}
|
|
87
|
+
//#endregion
|
|
88
|
+
//#region src/types/router.d.ts
|
|
89
|
+
/**
|
|
90
|
+
* @kimesh/kit - Router Types
|
|
91
|
+
*/
|
|
92
|
+
interface KimeshRoute {
|
|
93
|
+
/** Route name */
|
|
94
|
+
name?: string;
|
|
95
|
+
/** Route path */
|
|
96
|
+
path: string;
|
|
97
|
+
/** Component file path */
|
|
98
|
+
file?: string;
|
|
99
|
+
/** Child routes */
|
|
100
|
+
children?: KimeshRoute[];
|
|
101
|
+
/** Route meta */
|
|
102
|
+
meta?: Record<string, unknown>;
|
|
103
|
+
/** Source layer name */
|
|
104
|
+
layer?: string;
|
|
105
|
+
}
|
|
106
|
+
interface KimeshRouteMiddleware {
|
|
107
|
+
/** Middleware name */
|
|
108
|
+
name: string;
|
|
109
|
+
/** Middleware file path */
|
|
110
|
+
path: string;
|
|
111
|
+
/** Global middleware (applied to all routes) */
|
|
112
|
+
global?: boolean;
|
|
113
|
+
/** Source layer name */
|
|
114
|
+
layer?: string;
|
|
115
|
+
}
|
|
116
|
+
//#endregion
|
|
117
|
+
//#region src/types/hooks.d.ts
|
|
118
|
+
type HookResult = void | Promise<void>;
|
|
119
|
+
interface KimeshHooks {
|
|
120
|
+
/** Called after config is loaded, before layers */
|
|
121
|
+
"config:loaded": (config: KimeshConfig) => HookResult;
|
|
122
|
+
/** Called after layers are resolved */
|
|
123
|
+
"layers:resolved": (layers: ResolvedLayer$1[]) => HookResult;
|
|
124
|
+
/** Called to extend layer configuration */
|
|
125
|
+
"layers:extend": (layers: ResolvedLayer$1[]) => HookResult;
|
|
126
|
+
/** Called when Kimesh is fully initialized and ready */
|
|
127
|
+
ready: (kimesh: Kimesh) => HookResult;
|
|
128
|
+
/** Called before modules are processed */
|
|
129
|
+
"modules:before": (kimesh: Kimesh) => HookResult;
|
|
130
|
+
/** Called after all modules are processed */
|
|
131
|
+
"modules:done": (kimesh: Kimesh) => HookResult;
|
|
132
|
+
/** Called before build starts */
|
|
133
|
+
"build:before": (kimesh: Kimesh) => HookResult;
|
|
134
|
+
/** Called after build completes */
|
|
135
|
+
"build:done": (kimesh: Kimesh) => HookResult;
|
|
136
|
+
/** Called on build error */
|
|
137
|
+
"build:error": (error: Error, kimesh: Kimesh) => HookResult;
|
|
138
|
+
/** Called to extend Vite config before it's resolved */
|
|
139
|
+
"vite:extend": (ctx: {
|
|
140
|
+
kimesh: Kimesh;
|
|
141
|
+
config: vite3.UserConfig;
|
|
142
|
+
}) => HookResult;
|
|
143
|
+
/** Called after Vite config is resolved */
|
|
144
|
+
"vite:configResolved": (config: ResolvedConfig, kimesh: Kimesh) => HookResult;
|
|
145
|
+
/** Called when Vite dev server is created */
|
|
146
|
+
"vite:serverCreated": (server: ViteDevServer, kimesh: Kimesh) => HookResult;
|
|
147
|
+
/** Called to add import sources/presets */
|
|
148
|
+
"imports:sources": (sources: Array<{
|
|
149
|
+
from: string;
|
|
150
|
+
imports: string[];
|
|
151
|
+
}>, kimesh: Kimesh) => HookResult;
|
|
152
|
+
/** Called to extend imports */
|
|
153
|
+
"imports:extend": (imports: KimeshImport[], kimesh: Kimesh) => HookResult;
|
|
154
|
+
/** Called to add import directories */
|
|
155
|
+
"imports:dirs": (dirs: KimeshImportsDir[], kimesh: Kimesh) => HookResult;
|
|
156
|
+
/** Called to add component directories */
|
|
157
|
+
"components:dirs": (dirs: KimeshComponentsDir[], kimesh: Kimesh) => HookResult;
|
|
158
|
+
/** Called to extend components */
|
|
159
|
+
"components:extend": (components: KimeshComponent[], kimesh: Kimesh) => HookResult;
|
|
160
|
+
/** Called to add component resolvers */
|
|
161
|
+
"components:resolvers": (resolvers: ComponentResolver[], kimesh: Kimesh) => HookResult;
|
|
162
|
+
/** Called after routes are generated */
|
|
163
|
+
"routes:extend": (routes: KimeshRoute[], kimesh: Kimesh) => HookResult;
|
|
164
|
+
/** Called to add route middleware */
|
|
165
|
+
"routes:middleware": (middleware: KimeshRouteMiddleware[], kimesh: Kimesh) => HookResult;
|
|
166
|
+
/** Called when templates need generation */
|
|
167
|
+
"templates:extend": (templates: KimeshTemplate[], kimesh: Kimesh) => HookResult;
|
|
168
|
+
/** Called after templates are written */
|
|
169
|
+
"templates:done": (templates: KimeshTemplate[], kimesh: Kimesh) => HookResult;
|
|
170
|
+
/** Called to extend type templates */
|
|
171
|
+
"types:extend": (typeTemplates: KimeshTypeTemplate[], kimesh: Kimesh) => HookResult;
|
|
172
|
+
/** Called after types are generated */
|
|
173
|
+
"types:done": (files: string[], kimesh: Kimesh) => HookResult;
|
|
174
|
+
/** Called on file change in watch mode */
|
|
175
|
+
"watch:change": (file: string, event: "add" | "change" | "unlink", kimesh: Kimesh) => HookResult;
|
|
176
|
+
/** Called before HMR update */
|
|
177
|
+
"hmr:before": (file: string, kimesh: Kimesh) => HookResult;
|
|
178
|
+
/** Called after HMR update */
|
|
179
|
+
"hmr:after": (file: string, kimesh: Kimesh) => HookResult;
|
|
180
|
+
/** Called when Kimesh is closing */
|
|
181
|
+
close: (kimesh: Kimesh) => HookResult;
|
|
182
|
+
}
|
|
183
|
+
//#endregion
|
|
184
|
+
//#region src/types/runtime-plugin.d.ts
|
|
185
|
+
/**
|
|
186
|
+
* Metadata for runtime plugin ordering and identification
|
|
187
|
+
*/
|
|
188
|
+
interface KimeshRuntimePluginMeta {
|
|
189
|
+
name?: string;
|
|
190
|
+
enforce?: "pre" | "default" | "post";
|
|
191
|
+
order?: number;
|
|
192
|
+
dependsOn?: string[];
|
|
193
|
+
parallel?: boolean;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Runtime hooks available in Kimesh app lifecycle
|
|
197
|
+
*/
|
|
198
|
+
interface KimeshRuntimeHooks {
|
|
199
|
+
"app:created": (app: App) => void | Promise<void>;
|
|
200
|
+
"app:beforeMount": (app: App) => void | Promise<void>;
|
|
201
|
+
"app:mounted": (app: App) => void | Promise<void>;
|
|
202
|
+
"app:error": (err: unknown) => void | Promise<void>;
|
|
203
|
+
"page:start": () => void | Promise<void>;
|
|
204
|
+
"page:finish": () => void | Promise<void>;
|
|
205
|
+
"navigate:before": (context: {
|
|
206
|
+
to: unknown;
|
|
207
|
+
from: unknown;
|
|
208
|
+
}) => void | false | Promise<void | false>;
|
|
209
|
+
"navigate:after": (context: {
|
|
210
|
+
to: unknown;
|
|
211
|
+
from: unknown;
|
|
212
|
+
failure?: unknown;
|
|
213
|
+
}) => void | Promise<void>;
|
|
214
|
+
"navigate:error": (context: {
|
|
215
|
+
error: Error;
|
|
216
|
+
to: unknown;
|
|
217
|
+
from: unknown;
|
|
218
|
+
}) => void | Promise<void>;
|
|
219
|
+
}
|
|
220
|
+
interface RuntimeConfigPublic {
|
|
221
|
+
[key: string]: unknown;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Minimal build-time app context. Full runtime version is in @kimesh/router-runtime.
|
|
225
|
+
*/
|
|
226
|
+
interface KimeshAppContext {
|
|
227
|
+
vueApp: App;
|
|
228
|
+
router: unknown;
|
|
229
|
+
queryClient: unknown;
|
|
230
|
+
hooks: {
|
|
231
|
+
callHook: <T extends keyof KimeshRuntimeHooks>(name: T, ...args: Parameters<KimeshRuntimeHooks[T]>) => Promise<void>;
|
|
232
|
+
addHooks: (hooks: Partial<KimeshRuntimeHooks>) => void;
|
|
233
|
+
};
|
|
234
|
+
provide: <T>(name: string, value: T) => void;
|
|
235
|
+
$config: RuntimeConfigPublic;
|
|
236
|
+
isHydrating: boolean;
|
|
237
|
+
runWithContext: <T extends () => unknown>(fn: T) => ReturnType<T>;
|
|
238
|
+
}
|
|
239
|
+
interface KimeshRuntimePluginResult<Injections = Record<string, unknown>> {
|
|
240
|
+
provide?: Injections;
|
|
241
|
+
}
|
|
242
|
+
/** Plugin setup return type */
|
|
243
|
+
type PluginSetupReturn<Injections> = void | KimeshRuntimePluginResult<Injections> | Promise<void> | Promise<KimeshRuntimePluginResult<Injections>>;
|
|
244
|
+
/**
|
|
245
|
+
* Runtime plugin function signature
|
|
246
|
+
*/
|
|
247
|
+
interface KimeshRuntimePlugin<Injections = Record<string, unknown>> {
|
|
248
|
+
(app: KimeshAppContext): PluginSetupReturn<Injections>;
|
|
249
|
+
__kimesh_plugin?: true;
|
|
250
|
+
_name?: string;
|
|
251
|
+
meta?: KimeshRuntimePluginMeta;
|
|
252
|
+
hooks?: Partial<KimeshRuntimeHooks>;
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Object-style runtime plugin definition
|
|
256
|
+
*/
|
|
257
|
+
interface KimeshRuntimePluginDefinition<Injections = Record<string, unknown>> extends KimeshRuntimePluginMeta {
|
|
258
|
+
hooks?: Partial<KimeshRuntimeHooks>;
|
|
259
|
+
setup?: (app: KimeshAppContext) => PluginSetupReturn<Injections>;
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Normalized runtime plugin for registry storage
|
|
263
|
+
*/
|
|
264
|
+
interface KimeshRuntimePluginEntry {
|
|
265
|
+
src?: string;
|
|
266
|
+
name?: string;
|
|
267
|
+
meta?: KimeshRuntimePluginMeta;
|
|
268
|
+
plugin?: KimeshRuntimePlugin;
|
|
269
|
+
append?: boolean;
|
|
270
|
+
}
|
|
271
|
+
interface AddRuntimePluginOptions {
|
|
272
|
+
append?: boolean;
|
|
273
|
+
}
|
|
274
|
+
//#endregion
|
|
275
|
+
//#region src/types/kimesh.d.ts
|
|
276
|
+
interface KimeshTemplate<TData = unknown> {
|
|
277
|
+
/** Output filename (relative to buildDir) */
|
|
278
|
+
filename: string;
|
|
279
|
+
/** Generate template contents */
|
|
280
|
+
getContents?: (data: TData & {
|
|
281
|
+
kimesh: Kimesh;
|
|
282
|
+
}) => string | Promise<string>;
|
|
283
|
+
/** Source file path (alternative to getContents) */
|
|
284
|
+
src?: string;
|
|
285
|
+
/** Write to disk (default: true) */
|
|
286
|
+
write?: boolean;
|
|
287
|
+
/** Custom data passed to getContents */
|
|
288
|
+
data?: TData;
|
|
289
|
+
}
|
|
290
|
+
interface KimeshTypeTemplate<TData = unknown> extends KimeshTemplate<TData> {
|
|
291
|
+
/** Always writes .d.ts files */
|
|
292
|
+
filename: `${string}.d.ts`;
|
|
293
|
+
}
|
|
294
|
+
interface ResolvedTemplate {
|
|
295
|
+
/** Output filename */
|
|
296
|
+
filename: string;
|
|
297
|
+
/** Absolute path to the written file */
|
|
298
|
+
dst: string;
|
|
299
|
+
/** Template contents */
|
|
300
|
+
contents: string;
|
|
301
|
+
}
|
|
302
|
+
interface KimeshAlias {
|
|
303
|
+
/** Alias name (e.g., '#my-alias', '@/components') */
|
|
304
|
+
find: string | RegExp;
|
|
305
|
+
/** Path to resolve to */
|
|
306
|
+
replacement: string;
|
|
307
|
+
}
|
|
308
|
+
interface KimeshVitePluginEntry {
|
|
309
|
+
/** The Vite plugin */
|
|
310
|
+
plugin: Plugin;
|
|
311
|
+
/** Plugin enforce order */
|
|
312
|
+
enforce?: "pre" | "post";
|
|
313
|
+
/** Numeric order (lower = earlier) */
|
|
314
|
+
order?: number;
|
|
315
|
+
/** Metadata for debugging */
|
|
316
|
+
meta?: {
|
|
317
|
+
name?: string;
|
|
318
|
+
module?: string;
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
interface KimeshRegistries {
|
|
322
|
+
/** Vite plugins to add */
|
|
323
|
+
vitePlugins: KimeshVitePluginEntry[];
|
|
324
|
+
/** Aliases */
|
|
325
|
+
aliases: KimeshAlias[];
|
|
326
|
+
/** Templates to generate */
|
|
327
|
+
templates: KimeshTemplate[];
|
|
328
|
+
/** Type templates to generate (.d.ts) */
|
|
329
|
+
typeTemplates: KimeshTypeTemplate[];
|
|
330
|
+
/** Auto-imports */
|
|
331
|
+
imports: KimeshImport[];
|
|
332
|
+
/** Auto-import directories */
|
|
333
|
+
importsDirs: KimeshImportsDir[];
|
|
334
|
+
/** Import presets */
|
|
335
|
+
importsPresets: KimeshImportPreset[];
|
|
336
|
+
/** Components */
|
|
337
|
+
components: KimeshComponent[];
|
|
338
|
+
/** Component directories */
|
|
339
|
+
componentsDirs: KimeshComponentsDir[];
|
|
340
|
+
/** Component resolvers */
|
|
341
|
+
componentResolvers: ComponentResolver[];
|
|
342
|
+
/** Routes */
|
|
343
|
+
routes: KimeshRoute[];
|
|
344
|
+
/** Route middleware */
|
|
345
|
+
routeMiddleware: KimeshRouteMiddleware[];
|
|
346
|
+
/** Runtime plugins (execute in Vue app at runtime) */
|
|
347
|
+
runtimePlugins: KimeshRuntimePluginEntry[];
|
|
348
|
+
}
|
|
349
|
+
interface KimeshOptions {
|
|
350
|
+
/** Whether in development mode */
|
|
351
|
+
dev: boolean;
|
|
352
|
+
/** Project root directory */
|
|
353
|
+
root: string;
|
|
354
|
+
/** Build output directory (.kimesh) */
|
|
355
|
+
buildDir: string;
|
|
356
|
+
/** The Kimesh configuration */
|
|
357
|
+
config: KimeshConfig;
|
|
358
|
+
/** Resolved layers */
|
|
359
|
+
layers: ResolvedLayer$1[];
|
|
360
|
+
/** Runtime config (exposed to client/server) */
|
|
361
|
+
runtimeConfig: {
|
|
362
|
+
public: Record<string, unknown>;
|
|
363
|
+
private: Record<string, unknown>;
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
interface Kimesh {
|
|
367
|
+
/** Kimesh options */
|
|
368
|
+
readonly options: KimeshOptions;
|
|
369
|
+
/** Hookable instance for lifecycle hooks */
|
|
370
|
+
readonly hooks: Hookable<KimeshHooks>;
|
|
371
|
+
/** Registries for plugins, templates, imports, components, etc. */
|
|
372
|
+
readonly _registries: KimeshRegistries;
|
|
373
|
+
/** Resolved layers (shorthand for options.layers) */
|
|
374
|
+
readonly layers: ResolvedLayer$1[];
|
|
375
|
+
/** Project root directory */
|
|
376
|
+
readonly root: string;
|
|
377
|
+
/** Build directory (.kimesh) */
|
|
378
|
+
readonly buildDir: string;
|
|
379
|
+
/** Register a hook */
|
|
380
|
+
hook: <T extends keyof KimeshHooks>(name: T, handler: KimeshHooks[T], options?: {
|
|
381
|
+
allowDeprecated?: boolean;
|
|
382
|
+
}) => () => void;
|
|
383
|
+
/** Call a hook */
|
|
384
|
+
callHook: <T extends keyof KimeshHooks>(name: T, ...args: Parameters<KimeshHooks[T]>) => Promise<void>;
|
|
385
|
+
/** Register a hook that runs only once */
|
|
386
|
+
hookOnce: <T extends keyof KimeshHooks>(name: T, handler: KimeshHooks[T]) => () => void;
|
|
387
|
+
}
|
|
388
|
+
//#endregion
|
|
389
|
+
//#region src/types/module.d.ts
|
|
390
|
+
interface KimeshModuleMeta {
|
|
391
|
+
/** Module name (npm package name) */
|
|
392
|
+
name?: string;
|
|
393
|
+
/** Module version */
|
|
394
|
+
version?: string;
|
|
395
|
+
/** Config key in kimesh.config.ts for module options */
|
|
396
|
+
configKey?: string;
|
|
397
|
+
/** Compatibility constraints */
|
|
398
|
+
compatibility?: {
|
|
399
|
+
/** Minimum Kimesh version required */kimesh?: string; /** Minimum Vite version required */
|
|
400
|
+
vite?: string;
|
|
401
|
+
};
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* Module defaults can be:
|
|
405
|
+
* - A static object
|
|
406
|
+
* - A function that receives Kimesh and returns defaults (sync or async)
|
|
407
|
+
*/
|
|
408
|
+
type KimeshModuleDefaults<TOptions> = TOptions | ((kimesh: Kimesh) => TOptions | Promise<TOptions>);
|
|
409
|
+
interface KimeshModuleDefinition<TOptions = Record<string, unknown>> {
|
|
410
|
+
/** Module metadata */
|
|
411
|
+
meta?: KimeshModuleMeta;
|
|
412
|
+
/** Default options (can be function for dynamic defaults) */
|
|
413
|
+
defaults?: KimeshModuleDefaults<Partial<TOptions>>;
|
|
414
|
+
/** Shorthand hook registration */
|
|
415
|
+
hooks?: Partial<KimeshHooks>;
|
|
416
|
+
/**
|
|
417
|
+
* Setup function called after layers are resolved
|
|
418
|
+
* @param options - Merged options (defaults + user config)
|
|
419
|
+
* @param kimesh - Kimesh context
|
|
420
|
+
*/
|
|
421
|
+
setup?: (options: TOptions, kimesh: Kimesh) => void | Promise<void>;
|
|
422
|
+
}
|
|
423
|
+
/**
|
|
424
|
+
* A resolved Kimesh module
|
|
425
|
+
*/
|
|
426
|
+
interface KimeshModule<TOptions = Record<string, unknown>> {
|
|
427
|
+
/** Module definition */
|
|
428
|
+
_def: KimeshModuleDefinition<TOptions>;
|
|
429
|
+
/** Module meta (resolved) */
|
|
430
|
+
meta: Required<KimeshModuleMeta>;
|
|
431
|
+
/** Get default options */
|
|
432
|
+
getDefaults: (kimesh: Kimesh) => Promise<Partial<TOptions>>;
|
|
433
|
+
/** Setup function */
|
|
434
|
+
setup: (options: TOptions, kimesh: Kimesh) => void | Promise<void>;
|
|
435
|
+
}
|
|
436
|
+
/**
|
|
437
|
+
* Module input in config - can be:
|
|
438
|
+
* - A string package name (resolved from node_modules)
|
|
439
|
+
* - A module object
|
|
440
|
+
* - A tuple of [module, options]
|
|
441
|
+
* - A tuple of [string, options]
|
|
442
|
+
*/
|
|
443
|
+
type KimeshModuleInput<TOptions = any> = string | KimeshModule<TOptions> | [KimeshModule<TOptions>, Partial<TOptions>] | [string, Partial<TOptions>];
|
|
444
|
+
interface KimeshPluginDefinition {
|
|
445
|
+
/** Plugin name */
|
|
446
|
+
name: string;
|
|
447
|
+
/**
|
|
448
|
+
* Setup function that returns Vite plugin(s)
|
|
449
|
+
* @param kimesh - Kimesh context
|
|
450
|
+
*/
|
|
451
|
+
setup: (kimesh: Kimesh) => vite3.PluginOption | vite3.PluginOption[];
|
|
452
|
+
}
|
|
453
|
+
interface KimeshPlugin {
|
|
454
|
+
/** Plugin definition */
|
|
455
|
+
_def: KimeshPluginDefinition;
|
|
456
|
+
/** Plugin name */
|
|
457
|
+
name: string;
|
|
458
|
+
/** Get Vite plugins */
|
|
459
|
+
getPlugins: (kimesh: Kimesh) => vite3.PluginOption[];
|
|
460
|
+
}
|
|
461
|
+
//#endregion
|
|
462
|
+
//#region src/types/config.d.ts
|
|
463
|
+
/**
|
|
464
|
+
* Runtime configuration that can be overridden by environment variables.
|
|
465
|
+
*
|
|
466
|
+
* Values are resolved at build-time via Vite's `define` mechanism.
|
|
467
|
+
* Use `KIMESH_*` environment variables to override values.
|
|
468
|
+
*
|
|
469
|
+
* @example
|
|
470
|
+
* ```ts
|
|
471
|
+
* // In kimesh.config.ts
|
|
472
|
+
* runtimeConfig: {
|
|
473
|
+
* apiBase: '/api', // KIMESH_API_BASE
|
|
474
|
+
* debug: false, // KIMESH_DEBUG=true
|
|
475
|
+
* features: {
|
|
476
|
+
* darkMode: true, // KIMESH_FEATURES_DARK_MODE
|
|
477
|
+
* }
|
|
478
|
+
* }
|
|
479
|
+
* ```
|
|
480
|
+
*/
|
|
481
|
+
interface RuntimeConfig {
|
|
482
|
+
[key: string]: string | number | boolean | null | undefined | RuntimeConfig;
|
|
483
|
+
}
|
|
484
|
+
/**
|
|
485
|
+
* Layer configuration in kimesh.config.ts
|
|
486
|
+
*/
|
|
487
|
+
interface LayersConfig {
|
|
488
|
+
/** Directories to scan for layers (default: ['layers']) */
|
|
489
|
+
dirs?: string[];
|
|
490
|
+
/** Layers to enable - 'all' | 'none' | string[] */
|
|
491
|
+
enabled?: "all" | "none" | string[];
|
|
492
|
+
/** Layers to exclude */
|
|
493
|
+
excluded?: string[];
|
|
494
|
+
}
|
|
495
|
+
/**
|
|
496
|
+
* Auto-import configuration in kimesh.config.ts
|
|
497
|
+
*/
|
|
498
|
+
interface AutoImportOptions {
|
|
499
|
+
/** Enable auto-imports (default: true) */
|
|
500
|
+
enabled?: boolean;
|
|
501
|
+
/** Directories to scan for composables */
|
|
502
|
+
dirs?: string[];
|
|
503
|
+
/** External import presets (vue, vue-router, etc.) */
|
|
504
|
+
presets?: string[];
|
|
505
|
+
/** Custom import sources */
|
|
506
|
+
imports?: Array<{
|
|
507
|
+
from: string;
|
|
508
|
+
imports: string[];
|
|
509
|
+
type?: boolean;
|
|
510
|
+
}>;
|
|
511
|
+
/** Generate .d.ts files (default: true) */
|
|
512
|
+
dts?: boolean;
|
|
513
|
+
}
|
|
514
|
+
/**
|
|
515
|
+
* Component auto-import configuration
|
|
516
|
+
*/
|
|
517
|
+
interface ComponentsConfig {
|
|
518
|
+
/** Enable component auto-imports (default: true) */
|
|
519
|
+
enabled?: boolean;
|
|
520
|
+
/** Directories to scan */
|
|
521
|
+
dirs?: string[];
|
|
522
|
+
/** Component prefix */
|
|
523
|
+
prefix?: string;
|
|
524
|
+
/** Global component registration */
|
|
525
|
+
global?: boolean;
|
|
526
|
+
}
|
|
527
|
+
/**
|
|
528
|
+
* Vite configuration options for Kimesh.
|
|
529
|
+
*/
|
|
530
|
+
interface KimeshViteConfig extends Omit<UserConfig, "root" | "configFile"> {
|
|
531
|
+
/**
|
|
532
|
+
* Additional Vite plugins.
|
|
533
|
+
* These are merged AFTER Kimesh's internal plugins.
|
|
534
|
+
*/
|
|
535
|
+
plugins?: PluginOption[];
|
|
536
|
+
}
|
|
537
|
+
/**
|
|
538
|
+
* Default aliases provided by Kimesh.
|
|
539
|
+
* Templates use placeholders: <srcDir>, <rootDir>
|
|
540
|
+
* These are replaced at build time with actual paths.
|
|
541
|
+
*/
|
|
542
|
+
declare const DEFAULT_ALIASES: Record<string, string>;
|
|
543
|
+
/**
|
|
544
|
+
* Debug mode configuration for detailed logging and diagnostics.
|
|
545
|
+
*/
|
|
546
|
+
interface DebugConfig {
|
|
547
|
+
/**
|
|
548
|
+
* Log hook execution with timing information
|
|
549
|
+
* @default false
|
|
550
|
+
*/
|
|
551
|
+
hooks?: boolean;
|
|
552
|
+
/**
|
|
553
|
+
* Log module loading and setup
|
|
554
|
+
* @default false
|
|
555
|
+
*/
|
|
556
|
+
modules?: boolean;
|
|
557
|
+
/**
|
|
558
|
+
* Log layer resolution
|
|
559
|
+
* @default false
|
|
560
|
+
*/
|
|
561
|
+
layers?: boolean;
|
|
562
|
+
/**
|
|
563
|
+
* Log configuration loading and merging
|
|
564
|
+
* @default false
|
|
565
|
+
*/
|
|
566
|
+
config?: boolean;
|
|
567
|
+
/**
|
|
568
|
+
* Log Vite plugin operations
|
|
569
|
+
* @default false
|
|
570
|
+
*/
|
|
571
|
+
vite?: boolean;
|
|
572
|
+
/**
|
|
573
|
+
* Log route generation
|
|
574
|
+
* @default false
|
|
575
|
+
*/
|
|
576
|
+
routes?: boolean;
|
|
577
|
+
/**
|
|
578
|
+
* Log auto-import resolution
|
|
579
|
+
* @default false
|
|
580
|
+
*/
|
|
581
|
+
imports?: boolean;
|
|
582
|
+
}
|
|
583
|
+
/**
|
|
584
|
+
* Default file/folder ignore patterns
|
|
585
|
+
*/
|
|
586
|
+
declare const DEFAULT_IGNORE_PATTERNS: string[];
|
|
587
|
+
/**
|
|
588
|
+
* Options for file ignore patterns (passed to node-ignore)
|
|
589
|
+
*/
|
|
590
|
+
interface IgnoreOptions {
|
|
591
|
+
/**
|
|
592
|
+
* Whether matching is case-insensitive
|
|
593
|
+
* @default false
|
|
594
|
+
*/
|
|
595
|
+
ignorecase?: boolean;
|
|
596
|
+
}
|
|
597
|
+
/**
|
|
598
|
+
* Per-route configuration rules.
|
|
599
|
+
* Keys are route patterns (supports wildcards).
|
|
600
|
+
*
|
|
601
|
+
* @example
|
|
602
|
+
* ```ts
|
|
603
|
+
* routeRules: {
|
|
604
|
+
* '/admin/**': {
|
|
605
|
+
* redirect: '/login',
|
|
606
|
+
* },
|
|
607
|
+
* '/api/**': {
|
|
608
|
+
* headers: { 'Cache-Control': 'no-store' },
|
|
609
|
+
* },
|
|
610
|
+
* '/static/**': {
|
|
611
|
+
* prerender: true,
|
|
612
|
+
* },
|
|
613
|
+
* }
|
|
614
|
+
* ```
|
|
615
|
+
*/
|
|
616
|
+
interface RouteRule {
|
|
617
|
+
/**
|
|
618
|
+
* Redirect to another path
|
|
619
|
+
* Can be a string path or an object with statusCode
|
|
620
|
+
*/
|
|
621
|
+
redirect?: string | {
|
|
622
|
+
to: string;
|
|
623
|
+
statusCode?: 301 | 302 | 307 | 308;
|
|
624
|
+
};
|
|
625
|
+
/**
|
|
626
|
+
* Pre-render this route at build time (for static generation)
|
|
627
|
+
* @default false
|
|
628
|
+
*/
|
|
629
|
+
prerender?: boolean;
|
|
630
|
+
/**
|
|
631
|
+
* Cache configuration for this route
|
|
632
|
+
*/
|
|
633
|
+
cache?: boolean | {
|
|
634
|
+
/**
|
|
635
|
+
* Cache max age in seconds
|
|
636
|
+
*/
|
|
637
|
+
maxAge?: number;
|
|
638
|
+
/**
|
|
639
|
+
* Stale-while-revalidate in seconds
|
|
640
|
+
*/
|
|
641
|
+
swr?: number;
|
|
642
|
+
/**
|
|
643
|
+
* Cache key modifiers
|
|
644
|
+
*/
|
|
645
|
+
varies?: string[];
|
|
646
|
+
};
|
|
647
|
+
/**
|
|
648
|
+
* Custom headers to set for this route
|
|
649
|
+
*/
|
|
650
|
+
headers?: Record<string, string>;
|
|
651
|
+
/**
|
|
652
|
+
* CORS configuration for this route
|
|
653
|
+
*/
|
|
654
|
+
cors?: boolean | {
|
|
655
|
+
origin?: string | string[];
|
|
656
|
+
methods?: string[];
|
|
657
|
+
headers?: string[];
|
|
658
|
+
credentials?: boolean;
|
|
659
|
+
};
|
|
660
|
+
/**
|
|
661
|
+
* Custom meta data for the route
|
|
662
|
+
*/
|
|
663
|
+
meta?: Record<string, unknown>;
|
|
664
|
+
}
|
|
665
|
+
/**
|
|
666
|
+
* Directory configuration for Kimesh.
|
|
667
|
+
* Customizes the default directory structure.
|
|
668
|
+
*/
|
|
669
|
+
interface DirectoryConfig {
|
|
670
|
+
/**
|
|
671
|
+
* Directory for static assets
|
|
672
|
+
* @default 'assets'
|
|
673
|
+
*/
|
|
674
|
+
assets?: string;
|
|
675
|
+
/**
|
|
676
|
+
* Directory for runtime plugins
|
|
677
|
+
* @default 'plugins'
|
|
678
|
+
*/
|
|
679
|
+
plugins?: string;
|
|
680
|
+
/**
|
|
681
|
+
* Directory for public static files
|
|
682
|
+
* @default 'public'
|
|
683
|
+
*/
|
|
684
|
+
public?: string;
|
|
685
|
+
/**
|
|
686
|
+
* Directory for shared code across the app
|
|
687
|
+
* @default 'shared'
|
|
688
|
+
*/
|
|
689
|
+
shared?: string;
|
|
690
|
+
}
|
|
691
|
+
/**
|
|
692
|
+
* Bundle analyzer configuration options.
|
|
693
|
+
*/
|
|
694
|
+
interface AnalyzeConfig {
|
|
695
|
+
/**
|
|
696
|
+
* Enable the bundle analyzer
|
|
697
|
+
* @default false
|
|
698
|
+
*/
|
|
699
|
+
enabled?: boolean;
|
|
700
|
+
/**
|
|
701
|
+
* Automatically open analyzer report in browser
|
|
702
|
+
* @default false
|
|
703
|
+
*/
|
|
704
|
+
openAnalyzer?: boolean;
|
|
705
|
+
/**
|
|
706
|
+
* Custom filename for the report
|
|
707
|
+
* @default 'report.html'
|
|
708
|
+
*/
|
|
709
|
+
reportFilename?: string;
|
|
710
|
+
}
|
|
711
|
+
/**
|
|
712
|
+
* Build configuration for Kimesh.
|
|
713
|
+
* Controls production build behavior.
|
|
714
|
+
*/
|
|
715
|
+
interface BuildConfig {
|
|
716
|
+
/**
|
|
717
|
+
* Enable bundle analysis. Shows a visualization of bundle contents.
|
|
718
|
+
*
|
|
719
|
+
* @example
|
|
720
|
+
* ```ts
|
|
721
|
+
* build: {
|
|
722
|
+
* analyze: true,
|
|
723
|
+
* // or with options:
|
|
724
|
+
* analyze: {
|
|
725
|
+
* enabled: true,
|
|
726
|
+
* openAnalyzer: false,
|
|
727
|
+
* reportFilename: 'stats.html',
|
|
728
|
+
* },
|
|
729
|
+
* }
|
|
730
|
+
* ```
|
|
731
|
+
*/
|
|
732
|
+
analyze?: boolean | AnalyzeConfig;
|
|
733
|
+
/**
|
|
734
|
+
* Generate source maps for production builds.
|
|
735
|
+
* - `true`: Generate separate source map files
|
|
736
|
+
* - `'hidden'`: Generate source maps but don't reference them in bundles
|
|
737
|
+
* - `'inline'`: Inline source maps into bundles
|
|
738
|
+
* - `false`: No source maps
|
|
739
|
+
*
|
|
740
|
+
* @default false
|
|
741
|
+
*/
|
|
742
|
+
sourcemap?: boolean | "hidden" | "inline";
|
|
743
|
+
/**
|
|
744
|
+
* Build target for esbuild/terser.
|
|
745
|
+
* Specifies the JS language version to target.
|
|
746
|
+
*
|
|
747
|
+
* @default 'esnext'
|
|
748
|
+
*/
|
|
749
|
+
target?: string;
|
|
750
|
+
/**
|
|
751
|
+
* Minification strategy for production builds.
|
|
752
|
+
* - `true`: Use default minifier (esbuild)
|
|
753
|
+
* - `'esbuild'`: Fast minification with esbuild
|
|
754
|
+
* - `'terser'`: More aggressive minification with terser
|
|
755
|
+
* - `false`: No minification
|
|
756
|
+
*
|
|
757
|
+
* @default 'esbuild'
|
|
758
|
+
*/
|
|
759
|
+
minify?: boolean | "esbuild" | "terser";
|
|
760
|
+
}
|
|
761
|
+
/**
|
|
762
|
+
* HTTPS configuration options for dev server.
|
|
763
|
+
*/
|
|
764
|
+
interface HttpsConfig {
|
|
765
|
+
/**
|
|
766
|
+
* Path to SSL key file
|
|
767
|
+
*/
|
|
768
|
+
key?: string;
|
|
769
|
+
/**
|
|
770
|
+
* Path to SSL certificate file
|
|
771
|
+
*/
|
|
772
|
+
cert?: string;
|
|
773
|
+
}
|
|
774
|
+
/**
|
|
775
|
+
* Proxy target configuration.
|
|
776
|
+
*/
|
|
777
|
+
interface ProxyOptions {
|
|
778
|
+
/**
|
|
779
|
+
* Target URL to proxy to
|
|
780
|
+
*/
|
|
781
|
+
target: string;
|
|
782
|
+
/**
|
|
783
|
+
* Change the origin header to match target
|
|
784
|
+
* @default true
|
|
785
|
+
*/
|
|
786
|
+
changeOrigin?: boolean;
|
|
787
|
+
/**
|
|
788
|
+
* Rewrite the URL path
|
|
789
|
+
*/
|
|
790
|
+
rewrite?: (path: string) => string;
|
|
791
|
+
/**
|
|
792
|
+
* Whether to proxy WebSocket connections
|
|
793
|
+
* @default false
|
|
794
|
+
*/
|
|
795
|
+
ws?: boolean;
|
|
796
|
+
/**
|
|
797
|
+
* SSL verification options
|
|
798
|
+
*/
|
|
799
|
+
secure?: boolean;
|
|
800
|
+
/**
|
|
801
|
+
* Custom headers to send with the proxy request
|
|
802
|
+
*/
|
|
803
|
+
headers?: Record<string, string>;
|
|
804
|
+
}
|
|
805
|
+
/**
|
|
806
|
+
* CORS configuration options for dev server.
|
|
807
|
+
*/
|
|
808
|
+
interface CorsOptions {
|
|
809
|
+
/**
|
|
810
|
+
* Allowed origins
|
|
811
|
+
* @default '*'
|
|
812
|
+
*/
|
|
813
|
+
origin?: string | string[] | boolean;
|
|
814
|
+
/**
|
|
815
|
+
* Allowed HTTP methods
|
|
816
|
+
* @default ['GET', 'HEAD', 'PUT', 'PATCH', 'POST', 'DELETE']
|
|
817
|
+
*/
|
|
818
|
+
methods?: string[];
|
|
819
|
+
/**
|
|
820
|
+
* Allowed headers
|
|
821
|
+
*/
|
|
822
|
+
allowedHeaders?: string[];
|
|
823
|
+
/**
|
|
824
|
+
* Headers exposed to the client
|
|
825
|
+
*/
|
|
826
|
+
exposedHeaders?: string[];
|
|
827
|
+
/**
|
|
828
|
+
* Allow credentials (cookies, authorization headers)
|
|
829
|
+
* @default false
|
|
830
|
+
*/
|
|
831
|
+
credentials?: boolean;
|
|
832
|
+
/**
|
|
833
|
+
* Max age for preflight request caching (seconds)
|
|
834
|
+
* @default 86400
|
|
835
|
+
*/
|
|
836
|
+
maxAge?: number;
|
|
837
|
+
}
|
|
838
|
+
/**
|
|
839
|
+
* Enhanced development server configuration.
|
|
840
|
+
*/
|
|
841
|
+
interface DevServerConfig {
|
|
842
|
+
/**
|
|
843
|
+
* Port to listen on
|
|
844
|
+
* @default 3000
|
|
845
|
+
*/
|
|
846
|
+
port?: number;
|
|
847
|
+
/**
|
|
848
|
+
* Host to bind to.
|
|
849
|
+
* - `'localhost'`: Only accessible from this machine
|
|
850
|
+
* - `true` or `'0.0.0.0'`: Accessible from network
|
|
851
|
+
*
|
|
852
|
+
* @default 'localhost'
|
|
853
|
+
*/
|
|
854
|
+
host?: string | boolean;
|
|
855
|
+
/**
|
|
856
|
+
* Automatically open browser when server starts
|
|
857
|
+
* @default false
|
|
858
|
+
*/
|
|
859
|
+
open?: boolean;
|
|
860
|
+
/**
|
|
861
|
+
* Enable HTTPS for dev server.
|
|
862
|
+
* Set to `true` to use auto-generated certificates,
|
|
863
|
+
* or provide custom key/cert paths.
|
|
864
|
+
*
|
|
865
|
+
* @example
|
|
866
|
+
* ```ts
|
|
867
|
+
* dev: {
|
|
868
|
+
* https: true, // Auto-generate certificates
|
|
869
|
+
* // or with custom certs:
|
|
870
|
+
* https: {
|
|
871
|
+
* key: './certs/localhost.key',
|
|
872
|
+
* cert: './certs/localhost.crt',
|
|
873
|
+
* },
|
|
874
|
+
* }
|
|
875
|
+
* ```
|
|
876
|
+
*/
|
|
877
|
+
https?: boolean | HttpsConfig;
|
|
878
|
+
/**
|
|
879
|
+
* Configure proxy rules for dev server.
|
|
880
|
+
* Useful for API proxying during development.
|
|
881
|
+
*
|
|
882
|
+
* @example
|
|
883
|
+
* ```ts
|
|
884
|
+
* dev: {
|
|
885
|
+
* proxy: {
|
|
886
|
+
* '/api': 'http://localhost:8080',
|
|
887
|
+
* '/socket': {
|
|
888
|
+
* target: 'ws://localhost:8081',
|
|
889
|
+
* ws: true,
|
|
890
|
+
* },
|
|
891
|
+
* },
|
|
892
|
+
* }
|
|
893
|
+
* ```
|
|
894
|
+
*/
|
|
895
|
+
proxy?: Record<string, string | ProxyOptions>;
|
|
896
|
+
/**
|
|
897
|
+
* Configure CORS for dev server.
|
|
898
|
+
* Set to `true` to enable default CORS settings.
|
|
899
|
+
*
|
|
900
|
+
* @default false
|
|
901
|
+
*/
|
|
902
|
+
cors?: boolean | CorsOptions;
|
|
903
|
+
/**
|
|
904
|
+
* Exit if the specified port is already in use
|
|
905
|
+
* @default false
|
|
906
|
+
*/
|
|
907
|
+
strictPort?: boolean;
|
|
908
|
+
}
|
|
909
|
+
/**
|
|
910
|
+
* TypeScript configuration options for Kimesh.
|
|
911
|
+
*/
|
|
912
|
+
interface TypeScriptConfig {
|
|
913
|
+
/**
|
|
914
|
+
* Enable strict TypeScript mode.
|
|
915
|
+
* When true, adds strict compiler options to generated tsconfig.
|
|
916
|
+
*
|
|
917
|
+
* @default true
|
|
918
|
+
*/
|
|
919
|
+
strict?: boolean;
|
|
920
|
+
/**
|
|
921
|
+
* Enable type checking during development and/or build.
|
|
922
|
+
* - `true`: Enable type checking during both dev and build
|
|
923
|
+
* - `'build'`: Only type check during build
|
|
924
|
+
* - `false`: Disable type checking
|
|
925
|
+
*
|
|
926
|
+
* @default false
|
|
927
|
+
*/
|
|
928
|
+
typeCheck?: boolean | "build";
|
|
929
|
+
/**
|
|
930
|
+
* Additional tsconfig compiler options to merge with generated config.
|
|
931
|
+
* These options will extend the auto-generated `.kimesh/tsconfig.json`.
|
|
932
|
+
*
|
|
933
|
+
* @example
|
|
934
|
+
* ```ts
|
|
935
|
+
* typescript: {
|
|
936
|
+
* tsConfig: {
|
|
937
|
+
* compilerOptions: {
|
|
938
|
+
* experimentalDecorators: true,
|
|
939
|
+
* emitDecoratorMetadata: true,
|
|
940
|
+
* },
|
|
941
|
+
* },
|
|
942
|
+
* }
|
|
943
|
+
* ```
|
|
944
|
+
*/
|
|
945
|
+
tsConfig?: {
|
|
946
|
+
compilerOptions?: Record<string, unknown>;
|
|
947
|
+
include?: string[];
|
|
948
|
+
exclude?: string[];
|
|
949
|
+
references?: Array<{
|
|
950
|
+
path: string;
|
|
951
|
+
}>;
|
|
952
|
+
};
|
|
953
|
+
}
|
|
954
|
+
/**
|
|
955
|
+
* Chokidar watch options (simplified subset).
|
|
956
|
+
* @see https://github.com/paulmillr/chokidar#api
|
|
957
|
+
*/
|
|
958
|
+
interface ChokidarOptions {
|
|
959
|
+
/**
|
|
960
|
+
* Indicates whether the process should continue as long as files are being watched
|
|
961
|
+
* @default true
|
|
962
|
+
*/
|
|
963
|
+
persistent?: boolean;
|
|
964
|
+
/**
|
|
965
|
+
* Patterns to ignore
|
|
966
|
+
*/
|
|
967
|
+
ignored?: string | RegExp | string[] | ((path: string) => boolean);
|
|
968
|
+
/**
|
|
969
|
+
* Use polling instead of native events
|
|
970
|
+
* @default false
|
|
971
|
+
*/
|
|
972
|
+
usePolling?: boolean;
|
|
973
|
+
/**
|
|
974
|
+
* Polling interval in milliseconds (if usePolling is true)
|
|
975
|
+
* @default 100
|
|
976
|
+
*/
|
|
977
|
+
interval?: number;
|
|
978
|
+
/**
|
|
979
|
+
* Polling interval for binary files (if usePolling is true)
|
|
980
|
+
* @default 300
|
|
981
|
+
*/
|
|
982
|
+
binaryInterval?: number;
|
|
983
|
+
/**
|
|
984
|
+
* Delay in milliseconds for stabilized 'add' events
|
|
985
|
+
* @default 2000
|
|
986
|
+
*/
|
|
987
|
+
awaitWriteFinish?: boolean | {
|
|
988
|
+
stabilityThreshold?: number;
|
|
989
|
+
pollInterval?: number;
|
|
990
|
+
};
|
|
991
|
+
/**
|
|
992
|
+
* Use file descriptor watching instead of stat polling
|
|
993
|
+
* @default false
|
|
994
|
+
*/
|
|
995
|
+
atomic?: boolean | number;
|
|
996
|
+
/**
|
|
997
|
+
* Watch depth limit (how many levels to traverse)
|
|
998
|
+
* @default undefined (no limit)
|
|
999
|
+
*/
|
|
1000
|
+
depth?: number;
|
|
1001
|
+
}
|
|
1002
|
+
/**
|
|
1003
|
+
* Watchers configuration for advanced file watching control.
|
|
1004
|
+
*/
|
|
1005
|
+
interface WatchersConfig {
|
|
1006
|
+
/**
|
|
1007
|
+
* Chokidar options for file watching
|
|
1008
|
+
*/
|
|
1009
|
+
chokidar?: ChokidarOptions;
|
|
1010
|
+
/**
|
|
1011
|
+
* Webpack watch options (for future use if needed)
|
|
1012
|
+
*/
|
|
1013
|
+
webpack?: {
|
|
1014
|
+
aggregateTimeout?: number;
|
|
1015
|
+
poll?: boolean | number;
|
|
1016
|
+
ignored?: string | RegExp | string[];
|
|
1017
|
+
};
|
|
1018
|
+
}
|
|
1019
|
+
/**
|
|
1020
|
+
* Module options interface - augmented by modules via declaration merging.
|
|
1021
|
+
*
|
|
1022
|
+
* Modules augment this interface to add their config keys.
|
|
1023
|
+
* The keys become available in defineKmConfig once the module is installed.
|
|
1024
|
+
*
|
|
1025
|
+
* @example
|
|
1026
|
+
* ```ts
|
|
1027
|
+
* // In @kimesh/tailwindcss/types.ts:
|
|
1028
|
+
* declare module '@kimesh/kit' {
|
|
1029
|
+
* interface KimeshModuleOptions {
|
|
1030
|
+
* tailwindcss?: KimeshTailwindConfig
|
|
1031
|
+
* }
|
|
1032
|
+
* }
|
|
1033
|
+
* ```
|
|
1034
|
+
*/
|
|
1035
|
+
interface KimeshModuleOptions {
|
|
1036
|
+
[key: string]: unknown;
|
|
1037
|
+
}
|
|
1038
|
+
/**
|
|
1039
|
+
* App-level configuration
|
|
1040
|
+
*/
|
|
1041
|
+
interface AppConfig {
|
|
1042
|
+
/**
|
|
1043
|
+
* Global head configuration for the app
|
|
1044
|
+
* Automatically enables @kimesh/head plugin when configured
|
|
1045
|
+
*/
|
|
1046
|
+
head?: {
|
|
1047
|
+
/** Page title */title?: string; /** Title template (e.g., '%s | My App') */
|
|
1048
|
+
titleTemplate?: string | ((title: string) => string); /** Meta tags */
|
|
1049
|
+
meta?: Array<Record<string, string | undefined>>; /** Link tags */
|
|
1050
|
+
link?: Array<Record<string, string | undefined>>; /** Script tags */
|
|
1051
|
+
script?: Array<Record<string, string | boolean | undefined>>; /** Style tags */
|
|
1052
|
+
style?: Array<Record<string, string | undefined>>; /** HTML attributes */
|
|
1053
|
+
htmlAttrs?: Record<string, string | undefined>; /** Body attributes */
|
|
1054
|
+
bodyAttrs?: Record<string, string | undefined>;
|
|
1055
|
+
};
|
|
1056
|
+
}
|
|
1057
|
+
/**
|
|
1058
|
+
* Kimesh configuration (kimesh.config.ts)
|
|
1059
|
+
*
|
|
1060
|
+
* Module options are typed via the KimeshModuleOptions interface.
|
|
1061
|
+
* Modules can augment this interface to add typesafe config keys.
|
|
1062
|
+
*/
|
|
1063
|
+
interface KimeshConfig extends KimeshModuleOptions {
|
|
1064
|
+
/** Application/layer name */
|
|
1065
|
+
name?: string;
|
|
1066
|
+
/** Base path for routes (for layers) */
|
|
1067
|
+
basePath?: string;
|
|
1068
|
+
/**
|
|
1069
|
+
* Define additional aliases to access custom directories within your JavaScript and CSS.
|
|
1070
|
+
*
|
|
1071
|
+
* Aliases are automatically added to the generated TypeScript configurations
|
|
1072
|
+
* for full type support and path auto-complete.
|
|
1073
|
+
*
|
|
1074
|
+
* @default { "~": "/<srcDir>", "@": "/<srcDir>", "~~": "/<rootDir>", "@@": "/<rootDir>", "#build": "/<rootDir>/.kimesh" }
|
|
1075
|
+
*
|
|
1076
|
+
* @example
|
|
1077
|
+
* ```ts
|
|
1078
|
+
* import { fileURLToPath } from 'node:url'
|
|
1079
|
+
*
|
|
1080
|
+
* export default defineKmConfig({
|
|
1081
|
+
* alias: {
|
|
1082
|
+
* 'images': fileURLToPath(new URL('./assets/images', import.meta.url)),
|
|
1083
|
+
* 'style': fileURLToPath(new URL('./assets/style', import.meta.url)),
|
|
1084
|
+
* },
|
|
1085
|
+
* })
|
|
1086
|
+
* ```
|
|
1087
|
+
*/
|
|
1088
|
+
alias?: Record<string, string>;
|
|
1089
|
+
/**
|
|
1090
|
+
* Set to `true` to enable debug mode.
|
|
1091
|
+
*
|
|
1092
|
+
* Prints out hook names and timings, logs hook arguments,
|
|
1093
|
+
* and provides detailed information about module loading and layer resolution.
|
|
1094
|
+
*
|
|
1095
|
+
* @default false
|
|
1096
|
+
*
|
|
1097
|
+
* @example
|
|
1098
|
+
* ```ts
|
|
1099
|
+
* export default defineKmConfig({
|
|
1100
|
+
* debug: true,
|
|
1101
|
+
* // or with specific options:
|
|
1102
|
+
* debug: {
|
|
1103
|
+
* hooks: true,
|
|
1104
|
+
* modules: true,
|
|
1105
|
+
* layers: true,
|
|
1106
|
+
* },
|
|
1107
|
+
* })
|
|
1108
|
+
* ```
|
|
1109
|
+
*/
|
|
1110
|
+
debug?: boolean | DebugConfig;
|
|
1111
|
+
/**
|
|
1112
|
+
* Hooks are listeners to Kimesh events that are typically used in modules,
|
|
1113
|
+
* but are also available in `kimesh.config.ts`.
|
|
1114
|
+
*
|
|
1115
|
+
* Internally, hooks follow a naming pattern using colons (e.g., build:done).
|
|
1116
|
+
* For ease of configuration, you can structure them as an hierarchical object.
|
|
1117
|
+
*
|
|
1118
|
+
* @example
|
|
1119
|
+
* ```ts
|
|
1120
|
+
* export default defineKmConfig({
|
|
1121
|
+
* hooks: {
|
|
1122
|
+
* 'ready': (kimesh) => {
|
|
1123
|
+
* console.log('Kimesh is ready!')
|
|
1124
|
+
* },
|
|
1125
|
+
* 'build:done': (kimesh) => {
|
|
1126
|
+
* console.log('Build completed!')
|
|
1127
|
+
* },
|
|
1128
|
+
* },
|
|
1129
|
+
* })
|
|
1130
|
+
* ```
|
|
1131
|
+
*/
|
|
1132
|
+
hooks?: Partial<KimeshHooks>;
|
|
1133
|
+
/**
|
|
1134
|
+
* Files matching glob patterns specified inside the `ignore` array
|
|
1135
|
+
* will be ignored in building.
|
|
1136
|
+
*
|
|
1137
|
+
* More customizable than `ignorePrefix`: allows complex patterns.
|
|
1138
|
+
*
|
|
1139
|
+
* @default ["**\/*.stories.{js,cts,mts,ts,jsx,tsx}", "**\/*.{spec,test}.{js,cts,mts,ts,jsx,tsx}", "**\/*.d.{cts,mts,ts}", ".kimesh"]
|
|
1140
|
+
*
|
|
1141
|
+
* @example
|
|
1142
|
+
* ```ts
|
|
1143
|
+
* export default defineKmConfig({
|
|
1144
|
+
* ignore: [
|
|
1145
|
+
* '**\/__tests__/**',
|
|
1146
|
+
* '**\/*.mock.ts',
|
|
1147
|
+
* 'legacy/**',
|
|
1148
|
+
* ],
|
|
1149
|
+
* })
|
|
1150
|
+
* ```
|
|
1151
|
+
*/
|
|
1152
|
+
ignore?: string[];
|
|
1153
|
+
/**
|
|
1154
|
+
* Any file in routes, layouts, middleware directories will be ignored
|
|
1155
|
+
* during the build process if its filename starts with the prefix specified.
|
|
1156
|
+
*
|
|
1157
|
+
* @default "-"
|
|
1158
|
+
*
|
|
1159
|
+
* @example
|
|
1160
|
+
* ```ts
|
|
1161
|
+
* export default defineKmConfig({
|
|
1162
|
+
* ignorePrefix: '_', // Ignore files starting with underscore
|
|
1163
|
+
* })
|
|
1164
|
+
* ```
|
|
1165
|
+
*/
|
|
1166
|
+
ignorePrefix?: string;
|
|
1167
|
+
/**
|
|
1168
|
+
* Pass options directly to `node-ignore` (which is used by Kimesh to ignore files).
|
|
1169
|
+
*
|
|
1170
|
+
* @see https://github.com/kaelzhang/node-ignore
|
|
1171
|
+
*
|
|
1172
|
+
* @example
|
|
1173
|
+
* ```ts
|
|
1174
|
+
* export default defineKmConfig({
|
|
1175
|
+
* ignoreOptions: {
|
|
1176
|
+
* ignorecase: false, // Case-sensitive matching
|
|
1177
|
+
* },
|
|
1178
|
+
* })
|
|
1179
|
+
* ```
|
|
1180
|
+
*/
|
|
1181
|
+
ignoreOptions?: IgnoreOptions;
|
|
1182
|
+
/**
|
|
1183
|
+
* Global route rules applied to matching routes.
|
|
1184
|
+
*
|
|
1185
|
+
* Keys are route patterns (supports wildcards with **).
|
|
1186
|
+
* Useful for redirects, caching, and per-route configuration.
|
|
1187
|
+
*
|
|
1188
|
+
* @experimental This feature's API may change in the future.
|
|
1189
|
+
*
|
|
1190
|
+
* @example
|
|
1191
|
+
* ```ts
|
|
1192
|
+
* export default defineKmConfig({
|
|
1193
|
+
* routeRules: {
|
|
1194
|
+
* '/admin/**': {
|
|
1195
|
+
* redirect: '/login',
|
|
1196
|
+
* },
|
|
1197
|
+
* '/api/**': {
|
|
1198
|
+
* headers: { 'Cache-Control': 'no-store' },
|
|
1199
|
+
* cors: true,
|
|
1200
|
+
* },
|
|
1201
|
+
* '/blog/**': {
|
|
1202
|
+
* prerender: true,
|
|
1203
|
+
* },
|
|
1204
|
+
* },
|
|
1205
|
+
* })
|
|
1206
|
+
* ```
|
|
1207
|
+
*/
|
|
1208
|
+
routeRules?: Record<string, RouteRule>;
|
|
1209
|
+
/**
|
|
1210
|
+
* Source directory for your application code.
|
|
1211
|
+
* All relative paths are resolved from this directory.
|
|
1212
|
+
*
|
|
1213
|
+
* @default 'src'
|
|
1214
|
+
*
|
|
1215
|
+
* @example
|
|
1216
|
+
* ```ts
|
|
1217
|
+
* export default defineKmConfig({
|
|
1218
|
+
* srcDir: 'app', // Use 'app' instead of 'src'
|
|
1219
|
+
* })
|
|
1220
|
+
* ```
|
|
1221
|
+
*/
|
|
1222
|
+
srcDir?: string;
|
|
1223
|
+
/**
|
|
1224
|
+
* Build output directory for Kimesh's generated files.
|
|
1225
|
+
* Contains TypeScript configs, generated routes, and other build artifacts.
|
|
1226
|
+
*
|
|
1227
|
+
* @default '.kimesh'
|
|
1228
|
+
*
|
|
1229
|
+
* @example
|
|
1230
|
+
* ```ts
|
|
1231
|
+
* export default defineKmConfig({
|
|
1232
|
+
* buildDir: '.output', // Use '.output' instead of '.kimesh'
|
|
1233
|
+
* })
|
|
1234
|
+
* ```
|
|
1235
|
+
*/
|
|
1236
|
+
buildDir?: string;
|
|
1237
|
+
/**
|
|
1238
|
+
* Directory configuration for customizing the project structure.
|
|
1239
|
+
*
|
|
1240
|
+
* @example
|
|
1241
|
+
* ```ts
|
|
1242
|
+
* export default defineKmConfig({
|
|
1243
|
+
* dir: {
|
|
1244
|
+
* assets: 'static/assets',
|
|
1245
|
+
* plugins: 'app/plugins',
|
|
1246
|
+
* public: 'public',
|
|
1247
|
+
* shared: 'lib/shared',
|
|
1248
|
+
* },
|
|
1249
|
+
* })
|
|
1250
|
+
* ```
|
|
1251
|
+
*/
|
|
1252
|
+
dir?: DirectoryConfig;
|
|
1253
|
+
/**
|
|
1254
|
+
* Build configuration for production builds.
|
|
1255
|
+
*
|
|
1256
|
+
* @example
|
|
1257
|
+
* ```ts
|
|
1258
|
+
* export default defineKmConfig({
|
|
1259
|
+
* build: {
|
|
1260
|
+
* analyze: true,
|
|
1261
|
+
* sourcemap: 'hidden',
|
|
1262
|
+
* target: 'es2022',
|
|
1263
|
+
* minify: 'esbuild',
|
|
1264
|
+
* },
|
|
1265
|
+
* })
|
|
1266
|
+
* ```
|
|
1267
|
+
*/
|
|
1268
|
+
build?: BuildConfig;
|
|
1269
|
+
/**
|
|
1270
|
+
* Enhanced development server configuration.
|
|
1271
|
+
* Supports HTTPS, proxy, CORS, and more.
|
|
1272
|
+
*
|
|
1273
|
+
* @example
|
|
1274
|
+
* ```ts
|
|
1275
|
+
* export default defineKmConfig({
|
|
1276
|
+
* dev: {
|
|
1277
|
+
* port: 3000,
|
|
1278
|
+
* host: 'localhost',
|
|
1279
|
+
* open: true,
|
|
1280
|
+
* https: true,
|
|
1281
|
+
* proxy: {
|
|
1282
|
+
* '/api': 'http://localhost:8080',
|
|
1283
|
+
* },
|
|
1284
|
+
* cors: true,
|
|
1285
|
+
* strictPort: false,
|
|
1286
|
+
* },
|
|
1287
|
+
* })
|
|
1288
|
+
* ```
|
|
1289
|
+
*/
|
|
1290
|
+
dev?: DevServerConfig;
|
|
1291
|
+
/**
|
|
1292
|
+
* TypeScript configuration options.
|
|
1293
|
+
*
|
|
1294
|
+
* @example
|
|
1295
|
+
* ```ts
|
|
1296
|
+
* export default defineKmConfig({
|
|
1297
|
+
* typescript: {
|
|
1298
|
+
* strict: true,
|
|
1299
|
+
* typeCheck: 'build',
|
|
1300
|
+
* tsConfig: {
|
|
1301
|
+
* compilerOptions: {
|
|
1302
|
+
* experimentalDecorators: true,
|
|
1303
|
+
* },
|
|
1304
|
+
* },
|
|
1305
|
+
* },
|
|
1306
|
+
* })
|
|
1307
|
+
* ```
|
|
1308
|
+
*/
|
|
1309
|
+
typescript?: TypeScriptConfig;
|
|
1310
|
+
/**
|
|
1311
|
+
* Additional file patterns to watch during development.
|
|
1312
|
+
* Uses glob patterns relative to the project root.
|
|
1313
|
+
*
|
|
1314
|
+
* @example
|
|
1315
|
+
* ```ts
|
|
1316
|
+
* export default defineKmConfig({
|
|
1317
|
+
* watch: [
|
|
1318
|
+
* './custom-dir/**\/*',
|
|
1319
|
+
* './config/**\/*.json',
|
|
1320
|
+
* ],
|
|
1321
|
+
* })
|
|
1322
|
+
* ```
|
|
1323
|
+
*/
|
|
1324
|
+
watch?: string[];
|
|
1325
|
+
/**
|
|
1326
|
+
* Advanced watcher configuration.
|
|
1327
|
+
* Customize chokidar options for file watching.
|
|
1328
|
+
*
|
|
1329
|
+
* @example
|
|
1330
|
+
* ```ts
|
|
1331
|
+
* export default defineKmConfig({
|
|
1332
|
+
* watchers: {
|
|
1333
|
+
* chokidar: {
|
|
1334
|
+
* usePolling: true,
|
|
1335
|
+
* interval: 1000,
|
|
1336
|
+
* ignored: ['**\/.git/**'],
|
|
1337
|
+
* },
|
|
1338
|
+
* },
|
|
1339
|
+
* })
|
|
1340
|
+
* ```
|
|
1341
|
+
*/
|
|
1342
|
+
watchers?: WatchersConfig;
|
|
1343
|
+
/** Router configuration */
|
|
1344
|
+
router?: {
|
|
1345
|
+
/** Routes directory relative to srcDir (default: 'routes') */routesDir?: string; /** Import mode for route components */
|
|
1346
|
+
importMode?: "async" | "sync";
|
|
1347
|
+
};
|
|
1348
|
+
/** Extend from other layers (paths or package names) */
|
|
1349
|
+
extends?: Array<string | {
|
|
1350
|
+
name: string;
|
|
1351
|
+
path?: string;
|
|
1352
|
+
}>;
|
|
1353
|
+
/** Layers configuration */
|
|
1354
|
+
layers?: LayersConfig;
|
|
1355
|
+
/**
|
|
1356
|
+
* Kimesh modules to load
|
|
1357
|
+
*/
|
|
1358
|
+
modules?: KimeshModuleInput[];
|
|
1359
|
+
/**
|
|
1360
|
+
* App-level configuration
|
|
1361
|
+
* Includes head management and other app-wide settings
|
|
1362
|
+
*/
|
|
1363
|
+
app?: AppConfig;
|
|
1364
|
+
/** Routes configuration (for layers) */
|
|
1365
|
+
routes?: {
|
|
1366
|
+
/** Base path for all routes */basePath?: string; /** Routes folder name */
|
|
1367
|
+
folder?: string;
|
|
1368
|
+
};
|
|
1369
|
+
/** Auto-import configuration */
|
|
1370
|
+
autoImport?: AutoImportOptions;
|
|
1371
|
+
/** Component auto-import configuration */
|
|
1372
|
+
components?: ComponentsConfig;
|
|
1373
|
+
/** Composables configuration (for layers) */
|
|
1374
|
+
composables?: {
|
|
1375
|
+
/** Directories to scan */dirs?: string[];
|
|
1376
|
+
};
|
|
1377
|
+
/** CSS files to include */
|
|
1378
|
+
css?: string[];
|
|
1379
|
+
/**
|
|
1380
|
+
* Vite configuration options.
|
|
1381
|
+
*/
|
|
1382
|
+
vite?: KimeshViteConfig;
|
|
1383
|
+
/**
|
|
1384
|
+
* Runtime configuration with environment variable override support.
|
|
1385
|
+
*
|
|
1386
|
+
* In Phase 1, all config is client-side (build-time injection).
|
|
1387
|
+
* Use KIMESH_* environment variables to override values.
|
|
1388
|
+
*
|
|
1389
|
+
* @example
|
|
1390
|
+
* ```ts
|
|
1391
|
+
* runtimeConfig: {
|
|
1392
|
+
* apiBase: '/api', // KIMESH_API_BASE
|
|
1393
|
+
* debug: false, // KIMESH_DEBUG=true
|
|
1394
|
+
* features: {
|
|
1395
|
+
* darkMode: true, // KIMESH_FEATURES_DARK_MODE
|
|
1396
|
+
* }
|
|
1397
|
+
* }
|
|
1398
|
+
* ```
|
|
1399
|
+
*/
|
|
1400
|
+
runtimeConfig?: RuntimeConfig;
|
|
1401
|
+
}
|
|
1402
|
+
/**
|
|
1403
|
+
* Define Kimesh configuration with type inference.
|
|
1404
|
+
*/
|
|
1405
|
+
declare function defineKmConfig(config: KimeshConfig): KimeshConfig;
|
|
1406
|
+
//#endregion
|
|
1407
|
+
//#region src/types/resolver.d.ts
|
|
1408
|
+
/**
|
|
1409
|
+
* @kimesh/kit - Resolver Types
|
|
1410
|
+
*/
|
|
1411
|
+
interface KimeshResolver {
|
|
1412
|
+
/** Resolve paths relative to the resolver's base */
|
|
1413
|
+
resolve: (...paths: string[]) => string;
|
|
1414
|
+
/** Resolve a path and check if it exists */
|
|
1415
|
+
resolvePath: (path: string) => Promise<string>;
|
|
1416
|
+
/** Resolve an alias to its actual path */
|
|
1417
|
+
resolveAlias: (alias: string) => string | undefined;
|
|
1418
|
+
}
|
|
1419
|
+
//#endregion
|
|
1420
|
+
//#region src/core/kimesh.d.ts
|
|
1421
|
+
/**
|
|
1422
|
+
* Create a new Kimesh context
|
|
1423
|
+
*/
|
|
1424
|
+
declare function createKimesh(options: {
|
|
1425
|
+
config: KimeshConfig;
|
|
1426
|
+
layers: ResolvedLayer$1[];
|
|
1427
|
+
root: string;
|
|
1428
|
+
buildDir: string;
|
|
1429
|
+
dev?: boolean;
|
|
1430
|
+
}): Kimesh;
|
|
1431
|
+
/**
|
|
1432
|
+
* Get the current Kimesh context
|
|
1433
|
+
* @throws Error if not in a Kimesh context
|
|
1434
|
+
*/
|
|
1435
|
+
declare function useKimesh(): Kimesh;
|
|
1436
|
+
/**
|
|
1437
|
+
* Try to get the current Kimesh context
|
|
1438
|
+
* @returns Kimesh instance or undefined if not in context
|
|
1439
|
+
*/
|
|
1440
|
+
declare function tryUseKimesh(): Kimesh | undefined;
|
|
1441
|
+
//#endregion
|
|
1442
|
+
//#region src/core/module.d.ts
|
|
1443
|
+
/**
|
|
1444
|
+
* Define a Kimesh module with full type inference
|
|
1445
|
+
*
|
|
1446
|
+
* @example
|
|
1447
|
+
* ```ts
|
|
1448
|
+
* export default defineKimeshModule<{ apiKey: string }>({
|
|
1449
|
+
* meta: {
|
|
1450
|
+
* name: "@kimesh/analytics",
|
|
1451
|
+
* configKey: "analytics",
|
|
1452
|
+
* },
|
|
1453
|
+
* defaults: {
|
|
1454
|
+
* apiKey: "",
|
|
1455
|
+
* },
|
|
1456
|
+
* hooks: {
|
|
1457
|
+
* "ready": (kimesh) => {
|
|
1458
|
+
* console.log("Kimesh is ready!");
|
|
1459
|
+
* },
|
|
1460
|
+
* },
|
|
1461
|
+
* async setup(options, kimesh) {
|
|
1462
|
+
* // Module setup logic
|
|
1463
|
+
* },
|
|
1464
|
+
* });
|
|
1465
|
+
* ```
|
|
1466
|
+
*/
|
|
1467
|
+
declare function defineKimeshModule<TOptions = Record<string, unknown>>(definition: KimeshModuleDefinition<TOptions>): KimeshModule<TOptions>;
|
|
1468
|
+
/**
|
|
1469
|
+
* Normalize module input (string, module, or [module, options] tuple)
|
|
1470
|
+
*/
|
|
1471
|
+
declare function normalizeModuleInput<TOptions>(input: KimeshModuleInput<TOptions>, kimesh: Kimesh): Promise<{
|
|
1472
|
+
module: KimeshModule<TOptions>;
|
|
1473
|
+
options: Partial<TOptions>;
|
|
1474
|
+
}>;
|
|
1475
|
+
/**
|
|
1476
|
+
* Execute a single module
|
|
1477
|
+
*/
|
|
1478
|
+
declare function executeModule<TOptions>(moduleInput: KimeshModuleInput<TOptions>, kimesh: Kimesh): Promise<void>;
|
|
1479
|
+
/**
|
|
1480
|
+
* Execute all modules in order
|
|
1481
|
+
*/
|
|
1482
|
+
declare function executeModules(modules: KimeshModuleInput[], kimesh: Kimesh): Promise<void>;
|
|
1483
|
+
//#endregion
|
|
1484
|
+
//#region src/core/plugin.d.ts
|
|
1485
|
+
/**
|
|
1486
|
+
* Define a Kimesh plugin (lightweight Vite plugin wrapper)
|
|
1487
|
+
*
|
|
1488
|
+
* @example
|
|
1489
|
+
* ```ts
|
|
1490
|
+
* export default defineKimeshPlugin({
|
|
1491
|
+
* name: "@kimesh/icons",
|
|
1492
|
+
* setup(kimesh) {
|
|
1493
|
+
* return Icons({
|
|
1494
|
+
* compiler: "vue3",
|
|
1495
|
+
* autoInstall: true,
|
|
1496
|
+
* });
|
|
1497
|
+
* },
|
|
1498
|
+
* });
|
|
1499
|
+
* ```
|
|
1500
|
+
*/
|
|
1501
|
+
declare function defineKimeshPlugin(definition: KimeshPluginDefinition): KimeshPlugin;
|
|
1502
|
+
//#endregion
|
|
1503
|
+
//#region src/kit/vite.d.ts
|
|
1504
|
+
interface AddVitePluginOptions {
|
|
1505
|
+
/** Plugin enforce order */
|
|
1506
|
+
enforce?: "pre" | "post";
|
|
1507
|
+
/** Numeric order (lower = earlier) */
|
|
1508
|
+
order?: number;
|
|
1509
|
+
/** Add to beginning of plugins array */
|
|
1510
|
+
prepend?: boolean;
|
|
1511
|
+
}
|
|
1512
|
+
/**
|
|
1513
|
+
* Add a Vite plugin to the build
|
|
1514
|
+
*
|
|
1515
|
+
* @example
|
|
1516
|
+
* ```ts
|
|
1517
|
+
* addVitePlugin(myPlugin());
|
|
1518
|
+
* addVitePlugin(myPlugin(), { enforce: "pre" });
|
|
1519
|
+
* ```
|
|
1520
|
+
*/
|
|
1521
|
+
declare function addVitePlugin(plugin: Plugin | Plugin[] | PluginOption, options?: AddVitePluginOptions): void;
|
|
1522
|
+
/**
|
|
1523
|
+
* Add a build plugin (alias for addVitePlugin with default order)
|
|
1524
|
+
*/
|
|
1525
|
+
declare function addBuildPlugin(plugin: Plugin | Plugin[], options?: AddVitePluginOptions): void;
|
|
1526
|
+
//#endregion
|
|
1527
|
+
//#region src/kit/alias.d.ts
|
|
1528
|
+
/**
|
|
1529
|
+
* Add an alias
|
|
1530
|
+
*
|
|
1531
|
+
* @example
|
|
1532
|
+
* ```ts
|
|
1533
|
+
* addAlias("#my-module", "/path/to/module");
|
|
1534
|
+
* addAlias("@/components", "./src/components");
|
|
1535
|
+
* ```
|
|
1536
|
+
*/
|
|
1537
|
+
declare function addAlias(find: string | RegExp, replacement: string): void;
|
|
1538
|
+
/**
|
|
1539
|
+
* Resolve an alias to its actual path
|
|
1540
|
+
*/
|
|
1541
|
+
declare function resolveAlias(alias: string): string | undefined;
|
|
1542
|
+
//#endregion
|
|
1543
|
+
//#region src/kit/templates.d.ts
|
|
1544
|
+
/**
|
|
1545
|
+
* Add a template to be generated
|
|
1546
|
+
*
|
|
1547
|
+
* @example
|
|
1548
|
+
* ```ts
|
|
1549
|
+
* addTemplate({
|
|
1550
|
+
* filename: "my-config.ts",
|
|
1551
|
+
* getContents: ({ kimesh }) => `export default ${JSON.stringify(config)}`,
|
|
1552
|
+
* });
|
|
1553
|
+
* ```
|
|
1554
|
+
*/
|
|
1555
|
+
declare function addTemplate<TData = unknown>(template: KimeshTemplate<TData>): void;
|
|
1556
|
+
/**
|
|
1557
|
+
* Add a type template (.d.ts) to be generated
|
|
1558
|
+
*
|
|
1559
|
+
* @example
|
|
1560
|
+
* ```ts
|
|
1561
|
+
* addTypeTemplate({
|
|
1562
|
+
* filename: "components.d.ts",
|
|
1563
|
+
* getContents: ({ kimesh }) => generateComponentTypes(kimesh),
|
|
1564
|
+
* });
|
|
1565
|
+
* ```
|
|
1566
|
+
*/
|
|
1567
|
+
declare function addTypeTemplate<TData = unknown>(template: KimeshTypeTemplate<TData>): void;
|
|
1568
|
+
/**
|
|
1569
|
+
* Generate and write all templates
|
|
1570
|
+
*/
|
|
1571
|
+
declare function writeTemplates(kimesh: Kimesh): Promise<ResolvedTemplate[]>;
|
|
1572
|
+
/**
|
|
1573
|
+
* Update specific templates (for HMR)
|
|
1574
|
+
*/
|
|
1575
|
+
declare function updateTemplates(kimesh: Kimesh, options?: {
|
|
1576
|
+
filter?: (t: KimeshTemplate) => boolean;
|
|
1577
|
+
}): Promise<ResolvedTemplate[]>;
|
|
1578
|
+
//#endregion
|
|
1579
|
+
//#region src/kit/components.d.ts
|
|
1580
|
+
/**
|
|
1581
|
+
* Add a single component
|
|
1582
|
+
*
|
|
1583
|
+
* @example
|
|
1584
|
+
* ```ts
|
|
1585
|
+
* addComponent({
|
|
1586
|
+
* name: "MyButton",
|
|
1587
|
+
* filePath: "./components/MyButton.vue",
|
|
1588
|
+
* });
|
|
1589
|
+
* ```
|
|
1590
|
+
*/
|
|
1591
|
+
declare function addComponent(component: KimeshComponent): void;
|
|
1592
|
+
/**
|
|
1593
|
+
* Add a components directory
|
|
1594
|
+
*
|
|
1595
|
+
* @example
|
|
1596
|
+
* ```ts
|
|
1597
|
+
* addComponentsDir({
|
|
1598
|
+
* path: "./components/ui",
|
|
1599
|
+
* prefix: "Ui",
|
|
1600
|
+
* });
|
|
1601
|
+
* ```
|
|
1602
|
+
*/
|
|
1603
|
+
declare function addComponentsDir(dir: KimeshComponentsDir, options?: {
|
|
1604
|
+
prepend?: boolean;
|
|
1605
|
+
}): void;
|
|
1606
|
+
/**
|
|
1607
|
+
* Add a component resolver
|
|
1608
|
+
*
|
|
1609
|
+
* @example
|
|
1610
|
+
* ```ts
|
|
1611
|
+
* addComponentResolver({
|
|
1612
|
+
* type: "component",
|
|
1613
|
+
* resolve: (name) => {
|
|
1614
|
+
* if (name.startsWith("Ui")) {
|
|
1615
|
+
* return { name, from: `./components/ui/${name}.vue` };
|
|
1616
|
+
* }
|
|
1617
|
+
* },
|
|
1618
|
+
* });
|
|
1619
|
+
* ```
|
|
1620
|
+
*/
|
|
1621
|
+
declare function addComponentResolver(resolver: ComponentResolver): void;
|
|
1622
|
+
//#endregion
|
|
1623
|
+
//#region src/kit/imports.d.ts
|
|
1624
|
+
/**
|
|
1625
|
+
* Add imports (auto-imports)
|
|
1626
|
+
*
|
|
1627
|
+
* @example
|
|
1628
|
+
* ```ts
|
|
1629
|
+
* addImports({ name: "useAuth", from: "./composables/auth" });
|
|
1630
|
+
* addImports([
|
|
1631
|
+
* { name: "ref", from: "vue" },
|
|
1632
|
+
* { name: "computed", from: "vue" },
|
|
1633
|
+
* ]);
|
|
1634
|
+
* ```
|
|
1635
|
+
*/
|
|
1636
|
+
declare function addImports(imports: KimeshImport | KimeshImport[]): void;
|
|
1637
|
+
/**
|
|
1638
|
+
* Add an imports directory
|
|
1639
|
+
*
|
|
1640
|
+
* @example
|
|
1641
|
+
* ```ts
|
|
1642
|
+
* addImportsDir("./composables");
|
|
1643
|
+
* addImportsDir({ path: "./utils", pattern: "use*.ts" });
|
|
1644
|
+
* ```
|
|
1645
|
+
*/
|
|
1646
|
+
declare function addImportsDir(dir: string | KimeshImportsDir, options?: {
|
|
1647
|
+
prepend?: boolean;
|
|
1648
|
+
}): void;
|
|
1649
|
+
/**
|
|
1650
|
+
* Add import presets
|
|
1651
|
+
*
|
|
1652
|
+
* @example
|
|
1653
|
+
* ```ts
|
|
1654
|
+
* addImportsPreset({ from: "vue", imports: ["ref", "computed", "watch"] });
|
|
1655
|
+
* ```
|
|
1656
|
+
*/
|
|
1657
|
+
declare function addImportsPreset(preset: KimeshImportPreset): void;
|
|
1658
|
+
//#endregion
|
|
1659
|
+
//#region src/kit/resolver.d.ts
|
|
1660
|
+
/**
|
|
1661
|
+
* Create a resolver for the current module
|
|
1662
|
+
*
|
|
1663
|
+
* @example
|
|
1664
|
+
* ```ts
|
|
1665
|
+
* const resolver = createResolver(import.meta.url);
|
|
1666
|
+
* const runtimePath = resolver.resolve("./runtime");
|
|
1667
|
+
* ```
|
|
1668
|
+
*/
|
|
1669
|
+
declare function createResolver(base: string): KimeshResolver;
|
|
1670
|
+
/**
|
|
1671
|
+
* Resolve a path relative to project root
|
|
1672
|
+
*/
|
|
1673
|
+
declare function resolvePathFromRoot(...paths: string[]): string;
|
|
1674
|
+
/**
|
|
1675
|
+
* Resolve a path relative to build directory
|
|
1676
|
+
*/
|
|
1677
|
+
declare function resolvePathFromBuild(...paths: string[]): string;
|
|
1678
|
+
//#endregion
|
|
1679
|
+
//#region src/kit/runtime-plugin.d.ts
|
|
1680
|
+
/**
|
|
1681
|
+
* Add a runtime plugin to the Kimesh app
|
|
1682
|
+
*
|
|
1683
|
+
* @example
|
|
1684
|
+
* ```ts
|
|
1685
|
+
* addRuntimePlugin('~/plugins/analytics.ts')
|
|
1686
|
+
* addRuntimePlugin({ src: '~/plugins/analytics.ts', meta: { enforce: 'post' } })
|
|
1687
|
+
* ```
|
|
1688
|
+
*/
|
|
1689
|
+
declare function addRuntimePlugin(plugin: string | KimeshRuntimePluginEntry, options?: AddRuntimePluginOptions): void;
|
|
1690
|
+
/**
|
|
1691
|
+
* Remove a runtime plugin by source path
|
|
1692
|
+
*/
|
|
1693
|
+
declare function removeRuntimePlugin(src: string): void;
|
|
1694
|
+
/**
|
|
1695
|
+
* Check if a runtime plugin is registered
|
|
1696
|
+
*/
|
|
1697
|
+
declare function hasRuntimePlugin(src: string): boolean;
|
|
1698
|
+
/**
|
|
1699
|
+
* Get all registered runtime plugins
|
|
1700
|
+
*/
|
|
1701
|
+
declare function getRuntimePlugins(): KimeshRuntimePluginEntry[];
|
|
1702
|
+
//#endregion
|
|
1703
|
+
//#region src/kit/plugin-scanner.d.ts
|
|
1704
|
+
/**
|
|
1705
|
+
* @kimesh/kit - Plugin Scanner
|
|
1706
|
+
*
|
|
1707
|
+
* Scans the plugins directory for auto-discovered runtime plugins.
|
|
1708
|
+
*/
|
|
1709
|
+
/**
|
|
1710
|
+
* Discovered plugin entry from filesystem scanning
|
|
1711
|
+
*/
|
|
1712
|
+
interface DiscoveredPlugin {
|
|
1713
|
+
/** Plugin file path (absolute) */
|
|
1714
|
+
src: string;
|
|
1715
|
+
/** Plugin name derived from filename */
|
|
1716
|
+
name: string;
|
|
1717
|
+
/** Order derived from filename prefix (e.g., 01.auth.ts -> 1) */
|
|
1718
|
+
order?: number;
|
|
1719
|
+
}
|
|
1720
|
+
/**
|
|
1721
|
+
* Options for scanning plugins directory
|
|
1722
|
+
*/
|
|
1723
|
+
interface ScanPluginsOptions {
|
|
1724
|
+
/** File extensions to scan (default: ['.ts', '.js', '.mjs']) */
|
|
1725
|
+
extensions?: string[];
|
|
1726
|
+
/** Pattern to ignore */
|
|
1727
|
+
ignore?: string[];
|
|
1728
|
+
}
|
|
1729
|
+
/**
|
|
1730
|
+
* Scan plugins directory for auto-discovered plugins
|
|
1731
|
+
*
|
|
1732
|
+
* @example
|
|
1733
|
+
* ```ts
|
|
1734
|
+
* const plugins = await scanPluginsDir('/app/src/plugins')
|
|
1735
|
+
* // Returns: [
|
|
1736
|
+
* // { src: '/app/src/plugins/01.auth.ts', name: 'auth', order: 1 },
|
|
1737
|
+
* // { src: '/app/src/plugins/02.analytics.ts', name: 'analytics', order: 2 },
|
|
1738
|
+
* // { src: '/app/src/plugins/utils.ts', name: 'utils', order: undefined },
|
|
1739
|
+
* // ]
|
|
1740
|
+
* ```
|
|
1741
|
+
*/
|
|
1742
|
+
declare function scanPluginsDir(pluginsDir: string, options?: ScanPluginsOptions): Promise<DiscoveredPlugin[]>;
|
|
1743
|
+
/**
|
|
1744
|
+
* Check if a directory has any plugin files
|
|
1745
|
+
*/
|
|
1746
|
+
declare function hasPlugins(pluginsDir: string, options?: ScanPluginsOptions): Promise<boolean>;
|
|
1747
|
+
//#endregion
|
|
1748
|
+
//#region src/kit/plugin-template.d.ts
|
|
1749
|
+
/**
|
|
1750
|
+
* Options for generating plugins template
|
|
1751
|
+
*/
|
|
1752
|
+
interface GeneratePluginsTemplateOptions {
|
|
1753
|
+
/** Auto-discovered plugins from filesystem */
|
|
1754
|
+
discoveredPlugins: DiscoveredPlugin[];
|
|
1755
|
+
/** Module-registered plugins */
|
|
1756
|
+
registeredPlugins: KimeshRuntimePluginEntry[];
|
|
1757
|
+
/** Build directory for relative path calculation */
|
|
1758
|
+
buildDir: string;
|
|
1759
|
+
}
|
|
1760
|
+
/**
|
|
1761
|
+
* Generate the plugins.mjs template content
|
|
1762
|
+
*
|
|
1763
|
+
* @example Output:
|
|
1764
|
+
* ```js
|
|
1765
|
+
* // Auto-discovered plugins
|
|
1766
|
+
* import plugin_auth_0 from '../src/plugins/01.auth.ts'
|
|
1767
|
+
* import plugin_analytics_1 from '../src/plugins/02.analytics.ts'
|
|
1768
|
+
*
|
|
1769
|
+
* // Module-registered plugins
|
|
1770
|
+
* import plugin_icons_2 from '@kimesh/icons/runtime/plugin'
|
|
1771
|
+
*
|
|
1772
|
+
* export const plugins = [
|
|
1773
|
+
* plugin_auth_0,
|
|
1774
|
+
* plugin_analytics_1,
|
|
1775
|
+
* plugin_icons_2,
|
|
1776
|
+
* ]
|
|
1777
|
+
*
|
|
1778
|
+
* export default plugins
|
|
1779
|
+
* ```
|
|
1780
|
+
*/
|
|
1781
|
+
declare function generatePluginsTemplate(options: GeneratePluginsTemplateOptions): string;
|
|
1782
|
+
/**
|
|
1783
|
+
* Add plugins template to Kimesh registries
|
|
1784
|
+
*/
|
|
1785
|
+
declare function addPluginsTemplate(kimesh: Kimesh, discoveredPlugins: DiscoveredPlugin[]): void;
|
|
1786
|
+
//#endregion
|
|
1787
|
+
//#region src/kit/alias-utils.d.ts
|
|
1788
|
+
/**
|
|
1789
|
+
* Resolve an alias path template to an actual path
|
|
1790
|
+
*
|
|
1791
|
+
* @param template - Alias path template (e.g., "/<srcDir>/components")
|
|
1792
|
+
* @param srcDir - Source directory path
|
|
1793
|
+
* @param rootDir - Root directory path
|
|
1794
|
+
* @returns Resolved absolute path
|
|
1795
|
+
*/
|
|
1796
|
+
declare function resolveAliasPath(template: string, srcDir: string, rootDir: string): string;
|
|
1797
|
+
/**
|
|
1798
|
+
* Build resolved aliases from config
|
|
1799
|
+
*
|
|
1800
|
+
* @param config - Kimesh configuration
|
|
1801
|
+
* @param srcDir - Source directory (default: rootDir/src)
|
|
1802
|
+
* @param rootDir - Root directory
|
|
1803
|
+
* @returns Resolved alias map
|
|
1804
|
+
*/
|
|
1805
|
+
declare function buildAliases(config: KimeshConfig, srcDir: string, rootDir: string): Record<string, string>;
|
|
1806
|
+
/**
|
|
1807
|
+
* Convert aliases to Vite's resolve.alias format
|
|
1808
|
+
*
|
|
1809
|
+
* @param aliases - Alias map
|
|
1810
|
+
* @returns Array of Vite alias entries
|
|
1811
|
+
*/
|
|
1812
|
+
declare function toViteAliases(aliases: Record<string, string>): Array<{
|
|
1813
|
+
find: string | RegExp;
|
|
1814
|
+
replacement: string;
|
|
1815
|
+
}>;
|
|
1816
|
+
/**
|
|
1817
|
+
* Generate TypeScript path mappings from aliases
|
|
1818
|
+
*
|
|
1819
|
+
* @param aliases - Alias map
|
|
1820
|
+
* @param rootDir - Root directory for relative paths
|
|
1821
|
+
* @returns TypeScript compilerOptions.paths object
|
|
1822
|
+
*/
|
|
1823
|
+
declare function toTsConfigPaths(aliases: Record<string, string>, rootDir: string): Record<string, string[]>;
|
|
1824
|
+
/**
|
|
1825
|
+
* Normalize debug configuration to DebugConfig object
|
|
1826
|
+
*
|
|
1827
|
+
* @param debug - Debug config from KimeshConfig (boolean or DebugConfig)
|
|
1828
|
+
* @returns Normalized DebugConfig
|
|
1829
|
+
*/
|
|
1830
|
+
declare function normalizeDebugConfig(debug: boolean | DebugConfig | undefined): DebugConfig;
|
|
1831
|
+
/**
|
|
1832
|
+
* Check if a specific debug option is enabled
|
|
1833
|
+
*
|
|
1834
|
+
* @param debug - Debug config
|
|
1835
|
+
* @param option - Debug option to check
|
|
1836
|
+
* @returns Whether the option is enabled
|
|
1837
|
+
*/
|
|
1838
|
+
declare function isDebugEnabled(debug: boolean | DebugConfig | undefined, option: keyof DebugConfig): boolean;
|
|
1839
|
+
//#endregion
|
|
1840
|
+
//#region src/kit/ignore-utils.d.ts
|
|
1841
|
+
/**
|
|
1842
|
+
* Create an ignore instance with default and custom patterns
|
|
1843
|
+
*
|
|
1844
|
+
* @param config - Kimesh configuration
|
|
1845
|
+
* @returns Configured ignore instance
|
|
1846
|
+
*/
|
|
1847
|
+
declare function createIgnoreFilter(config: KimeshConfig): Ignore;
|
|
1848
|
+
/**
|
|
1849
|
+
* Check if a file should be ignored
|
|
1850
|
+
*
|
|
1851
|
+
* @param ig - Ignore instance
|
|
1852
|
+
* @param filePath - Relative file path to check
|
|
1853
|
+
* @returns Whether the file should be ignored
|
|
1854
|
+
*/
|
|
1855
|
+
declare function shouldIgnore(ig: Ignore, filePath: string): boolean;
|
|
1856
|
+
/**
|
|
1857
|
+
* Filter an array of paths, removing ignored ones
|
|
1858
|
+
*
|
|
1859
|
+
* @param ig - Ignore instance
|
|
1860
|
+
* @param paths - Array of relative paths
|
|
1861
|
+
* @returns Array of non-ignored paths
|
|
1862
|
+
*/
|
|
1863
|
+
declare function filterIgnored(ig: Ignore, paths: string[]): string[];
|
|
1864
|
+
/**
|
|
1865
|
+
* Create a simple matcher function for ignore patterns
|
|
1866
|
+
*
|
|
1867
|
+
* @param config - Kimesh configuration
|
|
1868
|
+
* @returns A function that returns true if a path should be ignored
|
|
1869
|
+
*/
|
|
1870
|
+
declare function createIgnoreMatcher(config: KimeshConfig): (filePath: string) => boolean;
|
|
1871
|
+
/**
|
|
1872
|
+
* Get all active ignore patterns from config
|
|
1873
|
+
*
|
|
1874
|
+
* @param config - Kimesh configuration
|
|
1875
|
+
* @returns Array of all ignore patterns
|
|
1876
|
+
*/
|
|
1877
|
+
declare function getIgnorePatterns(config: KimeshConfig): string[];
|
|
1878
|
+
//#endregion
|
|
1879
|
+
//#region src/kit/route-rules.d.ts
|
|
1880
|
+
/**
|
|
1881
|
+
* Match a route path against a pattern
|
|
1882
|
+
*
|
|
1883
|
+
* Supports:
|
|
1884
|
+
* - Exact matches: `/about`
|
|
1885
|
+
* - Wildcards: `/admin/**` (matches `/admin/users`, `/admin/users/123`)
|
|
1886
|
+
* - Single segment wildcards: `/users/*` (matches `/users/123` but not `/users/123/posts`)
|
|
1887
|
+
*
|
|
1888
|
+
* @param pattern - Route pattern (e.g., `/admin/**`)
|
|
1889
|
+
* @param routePath - Actual route path (e.g., `/admin/users`)
|
|
1890
|
+
* @returns Whether the pattern matches the path
|
|
1891
|
+
*/
|
|
1892
|
+
declare function matchRoutePattern(pattern: string, routePath: string): boolean;
|
|
1893
|
+
/**
|
|
1894
|
+
* Find matching route rules for a given path
|
|
1895
|
+
*
|
|
1896
|
+
* @param routeRules - Route rules configuration
|
|
1897
|
+
* @param routePath - Route path to match
|
|
1898
|
+
* @returns Array of matching rules in order of specificity (most specific first)
|
|
1899
|
+
*/
|
|
1900
|
+
declare function findMatchingRules(routeRules: Record<string, RouteRule>, routePath: string): Array<{
|
|
1901
|
+
pattern: string;
|
|
1902
|
+
rule: RouteRule;
|
|
1903
|
+
}>;
|
|
1904
|
+
/**
|
|
1905
|
+
* Merge multiple route rules into a single rule
|
|
1906
|
+
*
|
|
1907
|
+
* Later rules override earlier rules for same properties.
|
|
1908
|
+
*
|
|
1909
|
+
* @param rules - Array of route rules to merge
|
|
1910
|
+
* @returns Merged route rule
|
|
1911
|
+
*/
|
|
1912
|
+
declare function mergeRouteRules(rules: RouteRule[]): RouteRule;
|
|
1913
|
+
/**
|
|
1914
|
+
* Get the effective route rule for a path
|
|
1915
|
+
*
|
|
1916
|
+
* @param config - Kimesh configuration
|
|
1917
|
+
* @param routePath - Route path to get rule for
|
|
1918
|
+
* @returns Merged route rule or undefined if no rules match
|
|
1919
|
+
*/
|
|
1920
|
+
declare function getRouteRule(config: KimeshConfig, routePath: string): RouteRule | undefined;
|
|
1921
|
+
/**
|
|
1922
|
+
* Check if a route should be redirected
|
|
1923
|
+
*
|
|
1924
|
+
* @param rule - Route rule
|
|
1925
|
+
* @returns Redirect information or undefined
|
|
1926
|
+
*/
|
|
1927
|
+
declare function getRedirectInfo(rule: RouteRule): {
|
|
1928
|
+
to: string;
|
|
1929
|
+
statusCode: 301 | 302 | 307 | 308;
|
|
1930
|
+
} | undefined;
|
|
1931
|
+
/**
|
|
1932
|
+
* Generate route rules manifest for build output
|
|
1933
|
+
*
|
|
1934
|
+
* @param config - Kimesh configuration
|
|
1935
|
+
* @returns Route rules manifest object
|
|
1936
|
+
*/
|
|
1937
|
+
declare function generateRouteRulesManifest(config: KimeshConfig): Record<string, RouteRule>;
|
|
1938
|
+
//#endregion
|
|
1939
|
+
//#region src/kit/debug.d.ts
|
|
1940
|
+
/**
|
|
1941
|
+
* Set the debug configuration
|
|
1942
|
+
*
|
|
1943
|
+
* @param config - Kimesh configuration
|
|
1944
|
+
*/
|
|
1945
|
+
declare function setDebugConfig(config: KimeshConfig): void;
|
|
1946
|
+
/**
|
|
1947
|
+
* Check if debug mode is enabled for a specific category
|
|
1948
|
+
*
|
|
1949
|
+
* @param category - Debug category to check
|
|
1950
|
+
* @returns Whether debug is enabled for this category
|
|
1951
|
+
*/
|
|
1952
|
+
declare function isDebug(category?: keyof DebugConfig): boolean;
|
|
1953
|
+
/**
|
|
1954
|
+
* Debug logger that only logs when debug mode is enabled
|
|
1955
|
+
*/
|
|
1956
|
+
declare const debug: {
|
|
1957
|
+
/**
|
|
1958
|
+
* Log debug message for hooks
|
|
1959
|
+
*/
|
|
1960
|
+
hook(hookName: string, ...args: unknown[]): void;
|
|
1961
|
+
/**
|
|
1962
|
+
* Log debug message for modules
|
|
1963
|
+
*/
|
|
1964
|
+
module(moduleName: string, message: string, ...args: unknown[]): void;
|
|
1965
|
+
/**
|
|
1966
|
+
* Log debug message for layers
|
|
1967
|
+
*/
|
|
1968
|
+
layer(layerName: string, message: string, ...args: unknown[]): void;
|
|
1969
|
+
/**
|
|
1970
|
+
* Log debug message for config
|
|
1971
|
+
*/
|
|
1972
|
+
config(message: string, ...args: unknown[]): void;
|
|
1973
|
+
/**
|
|
1974
|
+
* Log debug message for Vite
|
|
1975
|
+
*/
|
|
1976
|
+
vite(message: string, ...args: unknown[]): void;
|
|
1977
|
+
/**
|
|
1978
|
+
* Log debug message for routes
|
|
1979
|
+
*/
|
|
1980
|
+
route(routePath: string, message: string, ...args: unknown[]): void;
|
|
1981
|
+
/**
|
|
1982
|
+
* Log debug message for imports
|
|
1983
|
+
*/
|
|
1984
|
+
import(name: string, message: string, ...args: unknown[]): void;
|
|
1985
|
+
/**
|
|
1986
|
+
* Log timing information
|
|
1987
|
+
*/
|
|
1988
|
+
timing(label: string, startTime: number): void;
|
|
1989
|
+
/**
|
|
1990
|
+
* Create a timing tracker
|
|
1991
|
+
*/
|
|
1992
|
+
startTiming(label: string): () => void;
|
|
1993
|
+
};
|
|
1994
|
+
/**
|
|
1995
|
+
* Create a scoped debug logger for a specific module
|
|
1996
|
+
*
|
|
1997
|
+
* @param scope - Module or component name
|
|
1998
|
+
* @returns Scoped debug logger
|
|
1999
|
+
*/
|
|
2000
|
+
declare function createDebugLogger(scope: string): {
|
|
2001
|
+
log(message: string, ...args: unknown[]): void;
|
|
2002
|
+
info(message: string, ...args: unknown[]): void;
|
|
2003
|
+
warn(message: string, ...args: unknown[]): void;
|
|
2004
|
+
error(message: string, ...args: unknown[]): void;
|
|
2005
|
+
timing: (label: string) => () => void;
|
|
2006
|
+
};
|
|
2007
|
+
/**
|
|
2008
|
+
* Log a debug table (formatted key-value pairs)
|
|
2009
|
+
*
|
|
2010
|
+
* @param title - Table title
|
|
2011
|
+
* @param data - Data to display
|
|
2012
|
+
*/
|
|
2013
|
+
declare function debugTable(title: string, data: Record<string, unknown>): void;
|
|
2014
|
+
//#endregion
|
|
2015
|
+
//#region src/vite/plugin.d.ts
|
|
2016
|
+
/**
|
|
2017
|
+
* Kimesh Vite plugin
|
|
2018
|
+
* Sets up Vue with Vite 8 + Rolldown + File-based routing + Layers + Auto-Import
|
|
2019
|
+
*/
|
|
2020
|
+
declare function kimeshPlugin(options?: KimeshPluginOptions): PluginOption[];
|
|
2021
|
+
//#endregion
|
|
2022
|
+
//#region src/config.d.ts
|
|
2023
|
+
interface LoadConfigOptions {
|
|
2024
|
+
/** Project root directory */
|
|
2025
|
+
root?: string;
|
|
2026
|
+
/** Config file path */
|
|
2027
|
+
configFile?: string;
|
|
2028
|
+
}
|
|
2029
|
+
/**
|
|
2030
|
+
* Load kimesh.config.ts using c12
|
|
2031
|
+
*/
|
|
2032
|
+
declare function loadConfig(options?: LoadConfigOptions): Promise<KimeshConfig>;
|
|
2033
|
+
//#endregion
|
|
2034
|
+
//#region src/prepare.d.ts
|
|
2035
|
+
/**
|
|
2036
|
+
* @kimesh/kit - Prepare Utilities
|
|
2037
|
+
*
|
|
2038
|
+
* Generates the .kimesh directory with TypeScript configurations,
|
|
2039
|
+
* type declarations, and other generated files needed for IDE support.
|
|
2040
|
+
*
|
|
2041
|
+
* Similar to `nuxt prepare` - run before IDE work for full type support.
|
|
2042
|
+
*/
|
|
2043
|
+
/**
|
|
2044
|
+
* Options for the prepare function
|
|
2045
|
+
*/
|
|
2046
|
+
interface PrepareOptions {
|
|
2047
|
+
/** Root directory of the project */
|
|
2048
|
+
root?: string;
|
|
2049
|
+
/** Path to kimesh.config file */
|
|
2050
|
+
configFile?: string;
|
|
2051
|
+
/** Enable verbose logging */
|
|
2052
|
+
verbose?: boolean;
|
|
2053
|
+
}
|
|
2054
|
+
/**
|
|
2055
|
+
* Result of the prepare function
|
|
2056
|
+
*/
|
|
2057
|
+
interface PrepareResult {
|
|
2058
|
+
/** Path to the .kimesh directory */
|
|
2059
|
+
buildDir: string;
|
|
2060
|
+
/** Number of layers resolved */
|
|
2061
|
+
layerCount: number;
|
|
2062
|
+
/** Number of aliases configured */
|
|
2063
|
+
aliasCount: number;
|
|
2064
|
+
/** Files that were generated */
|
|
2065
|
+
generatedFiles: string[];
|
|
2066
|
+
}
|
|
2067
|
+
/**
|
|
2068
|
+
* Prepare the .kimesh directory for TypeScript support
|
|
2069
|
+
*
|
|
2070
|
+
* This function generates all necessary files in the .kimesh directory
|
|
2071
|
+
* to enable TypeScript autocompletion and type checking before running
|
|
2072
|
+
* the dev server.
|
|
2073
|
+
*
|
|
2074
|
+
* @param options - Prepare options
|
|
2075
|
+
* @returns Result with generated file information
|
|
2076
|
+
*
|
|
2077
|
+
* @example
|
|
2078
|
+
* ```ts
|
|
2079
|
+
* import { prepare } from '@kimesh/kit'
|
|
2080
|
+
*
|
|
2081
|
+
* await prepare({ root: process.cwd() })
|
|
2082
|
+
* ```
|
|
2083
|
+
*/
|
|
2084
|
+
declare function prepare(options?: PrepareOptions): Promise<PrepareResult>;
|
|
2085
|
+
//#endregion
|
|
2086
|
+
//#region src/runtime-config.d.ts
|
|
2087
|
+
/**
|
|
2088
|
+
* Options for environment variable processing
|
|
2089
|
+
*/
|
|
2090
|
+
interface EnvOptions {
|
|
2091
|
+
/** Environment variable prefix (default: 'KIMESH_') */
|
|
2092
|
+
prefix?: string;
|
|
2093
|
+
/** Environment object to read from (default: process.env) */
|
|
2094
|
+
env?: Record<string, string | undefined>;
|
|
2095
|
+
}
|
|
2096
|
+
/**
|
|
2097
|
+
* Convert a config key path to environment variable name.
|
|
2098
|
+
*
|
|
2099
|
+
* @param keys - Array of keys representing the path (e.g., ['features', 'darkMode'])
|
|
2100
|
+
* @param prefix - Environment variable prefix (default: 'KIMESH_')
|
|
2101
|
+
* @returns Environment variable name (e.g., 'KIMESH_FEATURES_DARK_MODE')
|
|
2102
|
+
*
|
|
2103
|
+
* @example
|
|
2104
|
+
* ```ts
|
|
2105
|
+
* keyToEnv(['apiBase']) // => 'KIMESH_API_BASE'
|
|
2106
|
+
* keyToEnv(['features', 'darkMode']) // => 'KIMESH_FEATURES_DARK_MODE'
|
|
2107
|
+
* ```
|
|
2108
|
+
*/
|
|
2109
|
+
declare function keyToEnv(keys: string[], prefix?: string): string;
|
|
2110
|
+
/**
|
|
2111
|
+
* Convert environment variable name to config key path.
|
|
2112
|
+
*
|
|
2113
|
+
* Note: This function uses a best-effort heuristic for reverse conversion.
|
|
2114
|
+
* Since SNAKE_CASE to camelCase is ambiguous (e.g., API_BASE could be 'apiBase' or 'apibase'),
|
|
2115
|
+
* this function assumes each underscore-separated segment is a word boundary.
|
|
2116
|
+
*
|
|
2117
|
+
* @param envKey - Environment variable name
|
|
2118
|
+
* @param prefix - Environment variable prefix (default: 'KIMESH_')
|
|
2119
|
+
* @returns Array of keys or null if the env var doesn't match the prefix
|
|
2120
|
+
*
|
|
2121
|
+
* @example
|
|
2122
|
+
* ```ts
|
|
2123
|
+
* envToKey('KIMESH_API_BASE') // => ['apiBase']
|
|
2124
|
+
* envToKey('KIMESH_FEATURES_DARK_MODE') // => ['features', 'darkMode']
|
|
2125
|
+
* ```
|
|
2126
|
+
*/
|
|
2127
|
+
declare function envToKey(envKey: string, prefix?: string): string[] | null;
|
|
2128
|
+
/**
|
|
2129
|
+
* Apply environment variables to runtime config.
|
|
2130
|
+
*
|
|
2131
|
+
* Scans the environment for `KIMESH_*` variables and overlays them onto
|
|
2132
|
+
* the config object. Called at build time to bake env values into the bundle.
|
|
2133
|
+
*
|
|
2134
|
+
* @param config - Base runtime config from kimesh.config.ts
|
|
2135
|
+
* @param opts - Options for environment processing
|
|
2136
|
+
* @returns Merged config with env overrides
|
|
2137
|
+
*
|
|
2138
|
+
* @example
|
|
2139
|
+
* ```ts
|
|
2140
|
+
* // Given:
|
|
2141
|
+
* // KIMESH_API_BASE=https://api.example.com
|
|
2142
|
+
* // KIMESH_DEBUG=true
|
|
2143
|
+
*
|
|
2144
|
+
* const config = applyEnv({
|
|
2145
|
+
* apiBase: '/api',
|
|
2146
|
+
* debug: false,
|
|
2147
|
+
* });
|
|
2148
|
+
*
|
|
2149
|
+
* // Result:
|
|
2150
|
+
* // { apiBase: 'https://api.example.com', debug: true }
|
|
2151
|
+
* ```
|
|
2152
|
+
*/
|
|
2153
|
+
declare function applyEnv(config: Record<string, unknown>, opts?: EnvOptions): RuntimeConfig;
|
|
2154
|
+
/**
|
|
2155
|
+
* Create an empty runtime config object.
|
|
2156
|
+
* Used as a default when no config is provided.
|
|
2157
|
+
*/
|
|
2158
|
+
declare function createDefaultRuntimeConfig(): RuntimeConfig;
|
|
2159
|
+
//#endregion
|
|
2160
|
+
//#region src/hmr/watcher.d.ts
|
|
2161
|
+
interface HMRWatcherOptions {
|
|
2162
|
+
/** Vite dev server instance */
|
|
2163
|
+
server: ViteDevServer;
|
|
2164
|
+
/** Resolved layers */
|
|
2165
|
+
layers: ResolvedLayer$1[];
|
|
2166
|
+
/** Debug mode */
|
|
2167
|
+
debug?: boolean;
|
|
2168
|
+
}
|
|
2169
|
+
interface HMRContext {
|
|
2170
|
+
/** File that changed */
|
|
2171
|
+
file: string;
|
|
2172
|
+
/** Type of change */
|
|
2173
|
+
type: "add" | "change" | "unlink";
|
|
2174
|
+
/** Layer this file belongs to (if any) */
|
|
2175
|
+
layer?: ResolvedLayer$1;
|
|
2176
|
+
/** Category of the file */
|
|
2177
|
+
category: "route" | "component" | "composable" | "config" | "other";
|
|
2178
|
+
}
|
|
2179
|
+
/**
|
|
2180
|
+
* Create HMR watcher for Kimesh layers
|
|
2181
|
+
*/
|
|
2182
|
+
declare function createHMRWatcher(options: HMRWatcherOptions): {
|
|
2183
|
+
handleChange: (file: string, type: "add" | "change" | "unlink") => Promise<void>;
|
|
2184
|
+
detectLayer: (filePath: string) => ResolvedLayer$1 | undefined;
|
|
2185
|
+
detectCategory: (filePath: string) => "route" | "component" | "composable" | "config" | "other";
|
|
2186
|
+
};
|
|
2187
|
+
//#endregion
|
|
2188
|
+
//#region src/errors/formatter.d.ts
|
|
2189
|
+
interface ErrorContext {
|
|
2190
|
+
/** File that caused the error */
|
|
2191
|
+
file?: string;
|
|
2192
|
+
/** Line number */
|
|
2193
|
+
line?: number;
|
|
2194
|
+
/** Column number */
|
|
2195
|
+
column?: number;
|
|
2196
|
+
/** Layer this error occurred in */
|
|
2197
|
+
layer?: ResolvedLayer$1;
|
|
2198
|
+
/** Code snippet */
|
|
2199
|
+
snippet?: string;
|
|
2200
|
+
}
|
|
2201
|
+
interface FormattedError {
|
|
2202
|
+
/** Error title */
|
|
2203
|
+
title: string;
|
|
2204
|
+
/** Error message */
|
|
2205
|
+
message: string;
|
|
2206
|
+
/** Location info */
|
|
2207
|
+
location?: string;
|
|
2208
|
+
/** Suggestions for fixing */
|
|
2209
|
+
suggestions?: string[];
|
|
2210
|
+
/** Full formatted output */
|
|
2211
|
+
formatted: string;
|
|
2212
|
+
}
|
|
2213
|
+
/**
|
|
2214
|
+
* Format an error with layer context
|
|
2215
|
+
*/
|
|
2216
|
+
declare function formatError(error: Error, context?: ErrorContext): FormattedError;
|
|
2217
|
+
/**
|
|
2218
|
+
* Format a warning message
|
|
2219
|
+
*/
|
|
2220
|
+
declare function formatWarning(message: string, context?: ErrorContext): string;
|
|
2221
|
+
/**
|
|
2222
|
+
* Format a conflict warning
|
|
2223
|
+
*/
|
|
2224
|
+
declare function formatConflictWarning(type: "route" | "import" | "component", name: string, sources: Array<{
|
|
2225
|
+
layer: string;
|
|
2226
|
+
path: string;
|
|
2227
|
+
}>, winner: string): string;
|
|
2228
|
+
/**
|
|
2229
|
+
* Format timing info for debug
|
|
2230
|
+
*/
|
|
2231
|
+
declare function formatTiming(operation: string, timeMs: number, details?: Record<string, unknown>): string;
|
|
2232
|
+
/**
|
|
2233
|
+
* Create a timing logger
|
|
2234
|
+
*/
|
|
2235
|
+
declare function createTimer(operation: string, debug?: boolean): {
|
|
2236
|
+
end(details?: Record<string, unknown>): number;
|
|
2237
|
+
};
|
|
2238
|
+
//#endregion
|
|
2239
|
+
//#region src/index.d.ts
|
|
2240
|
+
interface KimeshPluginOptions {
|
|
2241
|
+
/** Pre-resolved config (from CLI) */
|
|
2242
|
+
config?: KimeshConfig;
|
|
2243
|
+
/** Layer configuration (from CLI) */
|
|
2244
|
+
layers?: {
|
|
2245
|
+
/** Enabled layers */enabled?: "all" | "none" | string[]; /** Excluded layers */
|
|
2246
|
+
excluded?: string[];
|
|
2247
|
+
};
|
|
2248
|
+
/** Enable debug logging */
|
|
2249
|
+
debug?: boolean;
|
|
2250
|
+
/**
|
|
2251
|
+
* Additional Vite plugins added programmatically.
|
|
2252
|
+
*/
|
|
2253
|
+
additionalPlugins?: vite3.PluginOption[];
|
|
2254
|
+
}
|
|
2255
|
+
//#endregion
|
|
2256
|
+
export { type AddRuntimePluginOptions, type AutoImportConfig, type AutoImportOptions, type ComponentsConfig, DEFAULT_ALIASES, DEFAULT_IGNORE_PATTERNS, type DebugConfig, type DiscoveredPlugin, type EnvOptions, type ErrorContext, type FormattedError, type GeneratePluginsTemplateOptions, type HMRContext, type HMRWatcherOptions, type HookResult, type IgnoreOptions, type ImportPreset, type ImportSource, type Kimesh, type KimeshAlias, type KimeshAppContext, type KimeshComponent, type KimeshComponentsDir, type KimeshConfig, type KimeshHooks, type KimeshImport, type KimeshImportPreset, type KimeshImportsDir, type KimeshLayerConfig, type KimeshModule, type KimeshModuleDefaults, type KimeshModuleDefinition, type KimeshModuleInput, type KimeshModuleMeta, type KimeshModuleOptions, type KimeshOptions, type KimeshPlugin, type KimeshPluginDefinition, KimeshPluginOptions, type KimeshRegistries, type KimeshResolver, type KimeshRoute, type KimeshRouteMiddleware, type KimeshRuntimeHooks, type KimeshRuntimePlugin, type KimeshRuntimePluginDefinition, type KimeshRuntimePluginEntry, type KimeshRuntimePluginMeta, type KimeshRuntimePluginResult, type KimeshTemplate, type KimeshTypeTemplate, type KimeshViteConfig, type KimeshVitePluginEntry, type LayerAutoImportConfig, type LayerComponentConfig, type LayerComposableConfig, type LayerRouteConfig, type LayersConfig, type LoadConfigOptions, type PrepareOptions, type PrepareResult, type ResolvedLayer, type ResolvedTemplate, type RouteRule, type RuntimeConfig, type RuntimeConfigPublic, type ScanPluginsOptions, type VitePlugin, type VitePluginOption, addAlias, addBuildPlugin, addComponent, addComponentResolver, addComponentsDir, addImports, addImportsDir, addImportsPreset, addPluginsTemplate, addRuntimePlugin, addTemplate, addTypeTemplate, addVitePlugin, applyEnv, buildAliases, buildImportRegistry, createDebugLogger, createDefaultRuntimeConfig, createHMRWatcher, createIgnoreFilter, createIgnoreMatcher, createKimesh, createResolver, createTimer, debug, debugTable, defineKimeshModule, defineKimeshPlugin, defineKmConfig, envToKey, executeModule, executeModules, filterIgnored, findMatchingRules, formatConflictWarning, formatError, formatTiming, formatWarning, generateDts, generateLayerAliases, generatePluginsTemplate, generateRouteRulesManifest, getIgnorePatterns, getRedirectInfo, getRouteRule, getRuntimePlugins, hasPlugins, hasRuntimePlugin, isDebug, isDebugEnabled, keyToEnv, kimeshAutoImport, kimeshPlugin, loadConfig, matchRoutePattern, mergeLayerConfigs, mergeRouteRules, normalizeDebugConfig, normalizeModuleInput, prepare, prepareLayers, removeRuntimePlugin, resolveAlias, resolveAliasPath, resolveLayers, resolvePathFromBuild, resolvePathFromRoot, scanExports, scanPluginsDir, setDebugConfig, shouldIgnore, toTsConfigPaths, toViteAliases, tryUseKimesh, updateTemplates, useKimesh, writeTemplates };
|
|
2257
|
+
//# sourceMappingURL=index.d.mts.map
|