@kubb/fabric-core 0.9.5 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/dist/{Fabric-BXYWK9V4.d.cts → Fabric-BwLKB57c.d.ts} +2 -2
  2. package/dist/{Fabric-CDFwTDyP.d.ts → Fabric-DmNaPvSq.d.cts} +2 -2
  3. package/dist/{defineProperty-hUmuXj5B.cjs → defineProperty-Cs9FivAD.cjs} +36 -36
  4. package/dist/{defineProperty-hUmuXj5B.cjs.map → defineProperty-Cs9FivAD.cjs.map} +1 -1
  5. package/dist/{defineProperty-CS9Uk_6Q.js → defineProperty-DfrsyklJ.js} +37 -37
  6. package/dist/{defineProperty-CS9Uk_6Q.js.map → defineProperty-DfrsyklJ.js.map} +1 -1
  7. package/dist/index.cjs +397 -2
  8. package/dist/index.cjs.map +1 -1
  9. package/dist/index.d.cts +410 -4
  10. package/dist/index.d.ts +410 -4
  11. package/dist/index.js +379 -3
  12. package/dist/index.js.map +1 -1
  13. package/dist/parsers/typescript.d.cts +1 -1
  14. package/dist/parsers/typescript.d.ts +1 -1
  15. package/dist/parsers.d.cts +1 -1
  16. package/dist/parsers.d.ts +1 -1
  17. package/dist/plugins.cjs +1 -1
  18. package/dist/plugins.d.cts +1 -1
  19. package/dist/plugins.d.ts +1 -1
  20. package/dist/plugins.js +1 -1
  21. package/dist/types-B1GXvvBG.d.ts +7 -0
  22. package/dist/types-zKAit5TK.d.cts +7 -0
  23. package/dist/types.d.cts +3 -2
  24. package/dist/types.d.ts +3 -2
  25. package/package.json +1 -1
  26. package/src/components/App.ts +38 -0
  27. package/src/components/Const.ts +56 -0
  28. package/src/components/File.ts +79 -0
  29. package/src/components/Function.ts +171 -0
  30. package/src/components/Root.ts +36 -0
  31. package/src/components/Type.ts +45 -0
  32. package/src/composables/useApp.ts +17 -0
  33. package/src/composables/useContext.ts +16 -0
  34. package/src/composables/useFile.ts +19 -0
  35. package/src/composables/useLifecycle.ts +16 -0
  36. package/src/context.ts +82 -0
  37. package/src/contexts/AppContext.ts +15 -0
  38. package/src/contexts/FileCollectorContext.ts +18 -0
  39. package/src/contexts/RootContext.ts +16 -0
  40. package/src/index.ts +26 -0
  41. package/src/types.ts +5 -0
  42. package/src/utils/FileCollector.ts +30 -0
  43. package/src/utils/createJSDoc.ts +15 -0
package/dist/index.d.ts CHANGED
@@ -1,7 +1,403 @@
1
- import { a as FabricOptions, c as FileManager, h as ResolvedFile, l as FileProcessor, n as FabricConfig, p as File, t as Fabric } from "./Fabric-CDFwTDyP.js";
1
+ import { a as FabricOptions, b as Source, c as FileManager, f as BaseName, g as Import, h as File$1, l as FileProcessor, n as FabricConfig, p as Export, t as Fabric, v as Path, y as ResolvedFile } from "./Fabric-BwLKB57c.js";
2
+ import { t as JSDoc$1 } from "./types-B1GXvvBG.js";
2
3
 
4
+ //#region src/context.d.ts
5
+ /**
6
+ * Context type that carries type information about its value
7
+ * This is a branded symbol type that enables type-safe context usage
8
+ */
9
+ type Context<T> = symbol & {
10
+ readonly __type: T;
11
+ };
12
+ /**
13
+ * Provides a value to descendant components (Vue 3 style)
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * const ThemeKey = Symbol('theme')
18
+ * provide(ThemeKey, { color: 'blue' })
19
+ * ```
20
+ */
21
+ declare function provide<T>(key: symbol | Context<T>, value: T): void;
22
+ /**
23
+ * Injects a value provided by an ancestor component (Vue 3 style)
24
+ *
25
+ * @example
26
+ * ```ts
27
+ * const theme = inject(ThemeKey, { color: 'default' })
28
+ * ```
29
+ */
30
+ declare function inject<T>(key: symbol | Context<T>, defaultValue?: T): T;
31
+ /**
32
+ * Unprovides a value (for cleanup)
33
+ * @internal
34
+ */
35
+ declare function unprovide<T>(key: symbol | Context<T>): void;
36
+ /**
37
+ * Creates a context key with a default value (React-style compatibility)
38
+ *
39
+ * @example
40
+ * ```ts
41
+ * const ThemeContext = createContext({ color: 'blue' })
42
+ * // ThemeContext is now typed as Context<{ color: string }>
43
+ * const theme = useContext(ThemeContext) // theme is { color: string }
44
+ * ```
45
+ */
46
+ declare function createContext<T>(defaultValue: T): Context<T>;
47
+ //#endregion
48
+ //#region src/components/App.d.ts
49
+ type AppContextProps$1<TMeta = unknown> = {
50
+ /**
51
+ * Exit (unmount)
52
+ */
53
+ readonly exit: (error?: Error) => void;
54
+ readonly meta: TMeta;
55
+ };
56
+ type Props$3<TMeta = unknown> = {
57
+ readonly meta: TMeta;
58
+ readonly children?: string;
59
+ };
60
+ /**
61
+ * Minimal fsx app container — provides an AppContext carrying `meta` and an
62
+ * `exit` hook. In fsx mode this just returns children content.
63
+ */
64
+ declare function App<TMeta = unknown>({
65
+ children,
66
+ meta
67
+ }: Props$3<TMeta>): string;
68
+ declare namespace App {
69
+ var Context: Context<AppContextProps$1<unknown> | undefined>;
70
+ var displayName: string;
71
+ }
72
+ //#endregion
73
+ //#region src/components/Const.d.ts
74
+ type JSDoc = {
75
+ comments: Array<string>;
76
+ };
77
+ type Props$2 = {
78
+ /**
79
+ * Name of the const
80
+ */
81
+ name: string;
82
+ /**
83
+ * Does this type need to be exported.
84
+ */
85
+ export?: boolean;
86
+ /**
87
+ * Type to make the const being typed
88
+ */
89
+ type?: string;
90
+ /**
91
+ * Options for JSdocs.
92
+ */
93
+ JSDoc?: JSDoc;
94
+ /**
95
+ * Use of `const` assertions
96
+ */
97
+ asConst?: boolean;
98
+ children?: string;
99
+ };
100
+ declare function Const({
101
+ name,
102
+ export: canExport,
103
+ type,
104
+ JSDoc,
105
+ asConst,
106
+ children
107
+ }: Props$2): string;
108
+ declare namespace Const {
109
+ var displayName: string;
110
+ }
111
+ //#endregion
112
+ //#region src/components/File.d.ts
113
+ type FileProps<TMeta extends object = object> = {
114
+ /**
115
+ * Name to be used to dynamically create the baseName(based on input.path).
116
+ * Based on UNIX basename
117
+ * @link https://nodejs.org/api/path.html#pathbasenamepath-suffix
118
+ */
119
+ baseName: BaseName;
120
+ /**
121
+ * Path will be full qualified path to a specified file.
122
+ */
123
+ path: Path;
124
+ meta?: TMeta;
125
+ banner?: string;
126
+ footer?: string;
127
+ children?: string;
128
+ };
129
+ /**
130
+ * File component for fsx - registers files via context
131
+ *
132
+ * When executed this will create or reuse a FileCollector from context and
133
+ * register the file (baseName/path) so it can be emitted later. Returns the
134
+ * children string content for fsx renderers.
135
+ */
136
+ declare function File<TMeta extends object = object>({
137
+ children,
138
+ ...rest
139
+ }: FileProps<TMeta>): string;
140
+ declare namespace File {
141
+ var Source: typeof FileSource;
142
+ var Import: typeof FileImport;
143
+ var Export: typeof FileExport;
144
+ }
145
+ /**
146
+ * FileSource - for adding source code to a file
147
+ *
148
+ * Returns the provided children string so the fsx renderer can collect it.
149
+ */
150
+ declare function FileSource(props: Omit<Source, 'value'> & {
151
+ children?: string;
152
+ }): string;
153
+ /**
154
+ * FileExport - for adding exports to a file
155
+ *
156
+ * No-op function used by renderers to record exports.
157
+ */
158
+ declare function FileExport(_props: Export): string;
159
+ /**
160
+ * FileImport - for adding imports to a file
161
+ *
162
+ * No-op function used by renderers to record imports.
163
+ */
164
+ declare function FileImport(_props: Import): string;
165
+ //#endregion
166
+ //#region src/components/Function.d.ts
167
+ type Props$1 = {
168
+ /**
169
+ * Name of the function.
170
+ */
171
+ name: string;
172
+ /**
173
+ * Add default when export is being used
174
+ */
175
+ default?: boolean;
176
+ /**
177
+ * Parameters/options/props that need to be used.
178
+ */
179
+ params?: string;
180
+ /**
181
+ * Does this function need to be exported.
182
+ */
183
+ export?: boolean;
184
+ /**
185
+ * Does the function has async/promise behaviour.
186
+ * This will also add `Promise<returnType>` as the returnType.
187
+ */
188
+ async?: boolean;
189
+ /**
190
+ * Generics that needs to be added for TypeScript.
191
+ */
192
+ generics?: string | string[];
193
+ /**
194
+ * ReturnType(see async for adding Promise type).
195
+ */
196
+ returnType?: string;
197
+ /**
198
+ * Options for JSdocs.
199
+ */
200
+ JSDoc?: JSDoc$1;
201
+ children?: string;
202
+ };
203
+ /**
204
+ * Builds a function declaration string for the fsx renderer. Supports optional
205
+ * export/default/async flags, generics, params and JSDoc rendering.
206
+ */
207
+ declare function Function({
208
+ name,
209
+ default: isDefault,
210
+ export: canExport,
211
+ async,
212
+ generics,
213
+ params,
214
+ returnType,
215
+ JSDoc: JSDoc$1,
216
+ children
217
+ }: Props$1): string;
218
+ declare namespace Function {
219
+ var displayName: string;
220
+ var Arrow: typeof ArrowFunction;
221
+ }
222
+ type ArrowFunctionProps = Props$1 & {
223
+ /**
224
+ * Create Arrow function in one line
225
+ */
226
+ singleLine?: boolean;
227
+ };
228
+ /**
229
+ * ArrowFunction
230
+ *
231
+ * Builds an arrow function declaration string for the fsx renderer. Supports
232
+ * the same options as `Function`. Use `singleLine` to produce a one-line
233
+ * arrow expression.
234
+ */
235
+ declare function ArrowFunction({
236
+ name,
237
+ default: isDefault,
238
+ export: canExport,
239
+ async,
240
+ generics,
241
+ params,
242
+ returnType,
243
+ JSDoc: JSDoc$1,
244
+ singleLine,
245
+ children
246
+ }: ArrowFunctionProps): string;
247
+ declare namespace ArrowFunction {
248
+ var displayName: string;
249
+ }
250
+ //#endregion
251
+ //#region src/components/Root.d.ts
252
+ type RootProps = {
253
+ /**
254
+ * Exit (unmount) hook
255
+ */
256
+ readonly onExit: (error?: Error) => void;
257
+ /**
258
+ * Error hook
259
+ */
260
+ readonly onError: (error: Error) => void;
261
+ readonly children?: string;
262
+ };
263
+ /**
264
+ * Top-level root for fsx renderers. Returns children content and ensures
265
+ * `onError` is called for runtime exceptions. Provides a RootContext with
266
+ * an `exit` hook for downstream consumers.
267
+ */
268
+ declare function Root({
269
+ onError,
270
+ children
271
+ }: Omit<RootProps, 'onExit'>): string;
272
+ declare namespace Root {
273
+ var displayName: string;
274
+ }
275
+ //#endregion
276
+ //#region src/components/Type.d.ts
277
+ type Props = {
278
+ /**
279
+ * Name of the type, this needs to start with a capital letter.
280
+ */
281
+ name: string;
282
+ /**
283
+ * Does this type need to be exported.
284
+ */
285
+ export?: boolean;
286
+ /**
287
+ * Options for JSdocs.
288
+ */
289
+ JSDoc?: JSDoc$1;
290
+ children?: string;
291
+ };
292
+ /**
293
+ * Renders a TypeScript type alias string for use with the fsx renderer.
294
+ * Optionally emits JSDoc comments when `JSDoc.comments` is provided.
295
+ */
296
+ declare function Type({
297
+ name,
298
+ export: canExport,
299
+ JSDoc: JSDoc$1,
300
+ children
301
+ }: Props): string;
302
+ declare namespace Type {
303
+ var displayName: string;
304
+ }
305
+ //#endregion
306
+ //#region src/contexts/AppContext.d.ts
307
+ type AppContextProps<TMeta = unknown> = {
308
+ /**
309
+ * Exit (unmount)
310
+ */
311
+ readonly exit: (error?: Error) => void;
312
+ readonly meta: TMeta;
313
+ };
314
+ /**
315
+ * Provides app-level metadata and lifecycle hooks (like `exit`) to
316
+ * components and composables within a Fabric runtime.
317
+ */
318
+ declare const AppContext: Context<AppContextProps<unknown> | undefined>;
319
+ //#endregion
320
+ //#region src/composables/useApp.d.ts
321
+ /**
322
+ * `useApp` will return the current App with meta and exit function.
323
+ *
324
+ * Throws an error when there is no AppContext available.
325
+ */
326
+ declare function useApp<TMeta = unknown>(): AppContextProps<TMeta>;
327
+ //#endregion
328
+ //#region src/composables/useContext.d.ts
329
+ /**
330
+ * React-style alias for inject
331
+ *
332
+ * @example
333
+ * ```ts
334
+ * const theme = useContext(ThemeContext) // type is inferred from ThemeContext
335
+ * ```
336
+ */
337
+ declare function useContext<T>(key: Context<T>): T;
338
+ declare function useContext<T, TValue = T>(key: Context<T>, defaultValue: TValue): NonNullable<T> | TValue;
339
+ //#endregion
340
+ //#region src/utils/FileCollector.d.ts
341
+ /**
342
+ * FileCollector is used to collect files from components via context
343
+ * instead of walking the DOM tree.
344
+ */
345
+ declare class FileCollector {
346
+ #private;
347
+ /**
348
+ * Add a file to the collector
349
+ */
350
+ add(file: File$1): void;
351
+ /**
352
+ * Get all collected files
353
+ */
354
+ get files(): Array<File$1>;
355
+ /**
356
+ * Clear all collected files
357
+ */
358
+ clear(): void;
359
+ }
360
+ //#endregion
361
+ //#region src/composables/useFile.d.ts
362
+ /**
363
+ * `useFile` will return the current FileCollector for registering files.
364
+ *
365
+ * Throws when no FileCollector is present in context — ensure a Fabric that
366
+ * provides a FileCollector is mounted before calling this hook.
367
+ */
368
+ declare function useFile(): FileCollector;
369
+ //#endregion
370
+ //#region src/composables/useLifecycle.d.ts
371
+ /**
372
+ * `useLifecycle` will return some helpers to exit/restart the generation.
373
+ *
374
+ * This hook reads the RootContext and exposes lifecycle helpers (like `exit`)
375
+ * for consumers to programmatically stop generation or perform teardown.
376
+ */
377
+ declare function useLifecycle(): {
378
+ exit: ((error?: Error) => void) | (() => void);
379
+ };
380
+ //#endregion
381
+ //#region src/contexts/FileCollectorContext.d.ts
382
+ /**
383
+ * Context for collecting files - provided by createFsxFabric
384
+ */
385
+ declare const FileCollectorContext: Context<FileCollector | null>;
386
+ //#endregion
387
+ //#region src/contexts/RootContext.d.ts
388
+ type RootContextProps = {
389
+ /**
390
+ * Exit (unmount) the whole app.
391
+ */
392
+ readonly exit: (error?: Error) => void;
393
+ };
394
+ /**
395
+ * Provides a top-level lifecycle hook (`exit`) for terminating the Fabric
396
+ * runtime. This context is available at the root of a Fabric app.
397
+ */
398
+ declare const RootContext: Context<RootContextProps>;
399
+ //#endregion
3
400
  //#region src/createFabric.d.ts
4
-
5
401
  /**
6
402
  * Creates a new Fabric instance
7
403
  *
@@ -15,7 +411,17 @@ declare function createFabric<T extends FabricOptions>(config?: FabricConfig<T>)
15
411
  /**
16
412
  * Helper to create a file with name and id set
17
413
  */
18
- declare function createFile<TMeta extends object = object>(file: File<TMeta>): ResolvedFile<TMeta>;
414
+ declare function createFile<TMeta extends object = object>(file: File$1<TMeta>): ResolvedFile<TMeta>;
415
+ //#endregion
416
+ //#region src/utils/createJSDoc.d.ts
417
+ /**
418
+ * Create JSDoc comment block from comments array
419
+ */
420
+ declare function createJSDoc({
421
+ comments
422
+ }: {
423
+ comments: string[];
424
+ }): string;
19
425
  //#endregion
20
- export { type Fabric, FileManager, FileProcessor, createFabric, createFile };
426
+ export { App, AppContext, Const, type Context, type Fabric, File, FileCollector, FileCollectorContext, FileManager, FileProcessor, Function, Root, RootContext, Type, createContext, createFabric, createFile, createJSDoc, inject, provide, unprovide, useApp, useContext, useFile, useLifecycle };
21
427
  //# sourceMappingURL=index.d.ts.map