@kubb/fabric-core 0.12.11 → 0.13.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.
Files changed (61) hide show
  1. package/README.md +1 -1
  2. package/dist/{Fabric-CrRJykMN.d.ts → Fabric-CE-4sqCG.d.ts} +1 -4
  3. package/dist/{Fabric-DMmgrLto.d.cts → Fabric-efyCO1t7.d.ts} +2 -2
  4. package/dist/{RootContext-Cf7WJM7r.d.cts → RootContext-BgiMS39h.d.ts} +3 -3
  5. package/dist/{RootContext-CvaGJ-4g.d.ts → RootContext-CA-zkTEp.d.ts} +3 -4
  6. package/dist/{chunk-BVHe6Par.js → chunk-BYypO7fO.js} +1 -5
  7. package/dist/{chunk-DVipidnM.cjs → chunk-uaV2rQ02.cjs} +0 -10
  8. package/dist/{defaultParser-BK-zOanQ.cjs → defaultParser-BAgmtMo_.cjs} +2 -3
  9. package/dist/{defaultParser-BK-zOanQ.cjs.map → defaultParser-BAgmtMo_.cjs.map} +1 -1
  10. package/dist/{defaultParser-BD_N68Bo.js → defaultParser-C1atU7yU.js} +2 -3
  11. package/dist/{defaultParser-BD_N68Bo.js.map → defaultParser-C1atU7yU.js.map} +1 -1
  12. package/dist/{getRelativePath-C4Au07ON.js → getRelativePath-BcieQL5M.js} +1 -2
  13. package/dist/{getRelativePath-C4Au07ON.js.map → getRelativePath-BcieQL5M.js.map} +1 -1
  14. package/dist/{getRelativePath-DpbA6qm5.cjs → getRelativePath-DVG8dIzW.cjs} +2 -2
  15. package/dist/{getRelativePath-DpbA6qm5.cjs.map → getRelativePath-DVG8dIzW.cjs.map} +1 -1
  16. package/dist/index.cjs +62 -61
  17. package/dist/index.cjs.map +1 -1
  18. package/dist/index.d.ts +11 -5
  19. package/dist/index.js +8 -9
  20. package/dist/index.js.map +1 -1
  21. package/dist/{Root-CKos-Ahf.cjs → onProcessExit-B7_bTfyR.cjs} +115 -213
  22. package/dist/onProcessExit-B7_bTfyR.cjs.map +1 -0
  23. package/dist/{Root-BQX3eHqb.js → onProcessExit-CF200hsz.js} +109 -190
  24. package/dist/onProcessExit-CF200hsz.js.map +1 -0
  25. package/dist/parsers/typescript.cjs +4 -4
  26. package/dist/parsers/typescript.cjs.map +1 -1
  27. package/dist/parsers/typescript.d.ts +1 -2
  28. package/dist/parsers/typescript.js +3 -4
  29. package/dist/parsers/typescript.js.map +1 -1
  30. package/dist/parsers.cjs +2 -3
  31. package/dist/parsers.cjs.map +1 -1
  32. package/dist/parsers.d.ts +1 -2
  33. package/dist/parsers.js +2 -3
  34. package/dist/parsers.js.map +1 -1
  35. package/dist/plugins.cjs +61 -305
  36. package/dist/plugins.cjs.map +1 -1
  37. package/dist/plugins.d.ts +9 -40
  38. package/dist/plugins.js +58 -298
  39. package/dist/plugins.js.map +1 -1
  40. package/dist/types.cjs +1 -1
  41. package/dist/types.d.ts +3 -4
  42. package/dist/types.js +1 -1
  43. package/dist/{useNodeTree-CgEKFUV-.d.cts → useNodeTree-BpHR6gQx.d.ts} +2 -2
  44. package/dist/{useNodeTree-CamNuFQP.d.ts → useNodeTree-DuQ5Df0t.d.ts} +2 -3
  45. package/package.json +8 -18
  46. package/src/FileManager.ts +6 -2
  47. package/src/createFile.ts +12 -9
  48. package/src/index.ts +3 -2
  49. package/src/plugins/fsPlugin.ts +8 -6
  50. package/src/plugins/fsxPlugin/Runtime.ts +4 -7
  51. package/src/plugins/index.ts +0 -1
  52. package/src/plugins/loggerPlugin.ts +15 -192
  53. package/src/utils/onProcessExit.ts +35 -0
  54. package/dist/Root-BQX3eHqb.js.map +0 -1
  55. package/dist/Root-CKos-Ahf.cjs.map +0 -1
  56. package/dist/index.d.cts +0 -595
  57. package/dist/parsers/typescript.d.cts +0 -45
  58. package/dist/parsers.d.cts +0 -37
  59. package/dist/plugins.d.cts +0 -149
  60. package/dist/types.d.cts +0 -11
  61. package/src/plugins/graphPlugin.ts +0 -136
@@ -1,149 +0,0 @@
1
- import { E as Extname, N as __name, a as FabricElement, l as Plugin, u as UserPlugin } from "./Fabric-DMmgrLto.cjs";
2
- import { r as TreeNode, t as ComponentNode } from "./useNodeTree-CgEKFUV-.cjs";
3
-
4
- //#region src/plugins/barrelPlugin.d.ts
5
- type Mode = 'all' | 'named' | 'propagate' | false;
6
- type Options$4 = {
7
- root: string;
8
- mode: Mode;
9
- dryRun?: boolean;
10
- };
11
- type WriteEntryOptions = {
12
- root: string;
13
- mode: Mode;
14
- };
15
- type ExtendOptions$2 = {
16
- /**
17
- * `fabric.writeEntry` should be called before `fabric.write`
18
- */
19
- writeEntry(options: WriteEntryOptions): Promise<void>;
20
- };
21
- declare global {
22
- namespace Kubb {
23
- interface Fabric {
24
- /**
25
- * `fabric.writeEntry` should be called before `fabric.write`
26
- */
27
- writeEntry(options: WriteEntryOptions): Promise<void>;
28
- }
29
- }
30
- }
31
- declare const barrelPlugin: Plugin<Options$4, ExtendOptions$2>;
32
- //#endregion
33
- //#region src/plugins/definePlugin.d.ts
34
- /**
35
- * Defines a Fabric plugin with type safety.
36
- *
37
- * Use this function to create plugins that hook into Fabric's lifecycle
38
- * events and extend its functionality.
39
- *
40
- * @param plugin - The plugin configuration object
41
- * @returns A typed plugin ready to use with Fabric
42
- *
43
- * @example
44
- * ```ts
45
- * import { definePlugin } from '@kubb/fabric-core'
46
- *
47
- * export const myPlugin = definePlugin({
48
- * name: 'my-plugin',
49
- * async setup(fabric) {
50
- * fabric.context.on('write:start', (files) => {
51
- * console.log(`Writing ${files.length} files`)
52
- * })
53
- * }
54
- * })
55
- * ```
56
- */
57
- declare function definePlugin<Options = unknown, TAppExtension extends Record<string, any> = {}>(plugin: UserPlugin<Options, TAppExtension>): Plugin<Options, TAppExtension>;
58
- //#endregion
59
- //#region src/plugins/fsPlugin.d.ts
60
- type WriteOptions = {
61
- extension?: Record<Extname, Extname | ''>;
62
- };
63
- type Options$3 = {
64
- dryRun?: boolean;
65
- /**
66
- * Optional callback that is invoked whenever a file is written by the plugin.
67
- * Useful for tests to observe write operations without spying on internal functions.
68
- */
69
- onBeforeWrite?: (path: string, data: string | undefined) => void | Promise<void>;
70
- clean?: {
71
- path: string;
72
- };
73
- };
74
- type ExtendOptions$1 = {
75
- write(options?: WriteOptions): Promise<void>;
76
- };
77
- declare global {
78
- namespace Kubb {
79
- interface Fabric {
80
- write(options?: WriteOptions): Promise<void>;
81
- }
82
- }
83
- }
84
- declare const fsPlugin: Plugin<Options$3, ExtendOptions$1>;
85
- //#endregion
86
- //#region src/plugins/fsxPlugin/fsxPlugin.d.ts
87
- type Options$2 = {
88
- treeNode?: TreeNode<ComponentNode>;
89
- /**
90
- * Set this to true to always see the result of the render in the console(line per render)
91
- */
92
- debug?: boolean;
93
- };
94
- type ExtendOptions = {
95
- render(App: FabricElement<any>): Promise<string>;
96
- waitUntilExit(): Promise<void>;
97
- };
98
- declare global {
99
- namespace Kubb {
100
- interface Fabric {
101
- render(App: FabricElement<any>): Promise<string>;
102
- waitUntilExit(): Promise<void>;
103
- }
104
- }
105
- }
106
- declare const fsxPlugin: Plugin<Options$2, ExtendOptions>;
107
- //#endregion
108
- //#region src/plugins/graphPlugin.d.ts
109
- type Options$1 = {
110
- root: string;
111
- /**
112
- * @default false
113
- */
114
- open?: boolean;
115
- };
116
- declare const graphPlugin: Plugin<Options$1, {}>;
117
- //#endregion
118
- //#region src/plugins/loggerPlugin.d.ts
119
- type WebSocketOptions = {
120
- /**
121
- * Hostname to bind the websocket server to.
122
- * @default '127.0.0.1'
123
- */
124
- host?: string;
125
- /**
126
- * Port to bind the websocket server to.
127
- * @default 0 (random available port)
128
- */
129
- port?: number;
130
- };
131
- type Options = {
132
- /**
133
- * Toggle progress bar output.
134
- * @default true
135
- */
136
- progress?: boolean;
137
- /**
138
- * Toggle or configure the websocket broadcast server.
139
- * When `true`, a websocket server is started on an ephemeral port.
140
- * When `false`, websocket support is disabled.
141
- * When providing an object, the server uses the supplied host and port.
142
- * @default true
143
- */
144
- websocket?: boolean | WebSocketOptions;
145
- };
146
- declare const loggerPlugin: Plugin<Options, {}>;
147
- //#endregion
148
- export { barrelPlugin, definePlugin, fsPlugin, fsxPlugin, graphPlugin, loggerPlugin };
149
- //# sourceMappingURL=plugins.d.cts.map
package/dist/types.d.cts DELETED
@@ -1,11 +0,0 @@
1
- import { N as __name, c as FabricOptions, h as Context, i as FabricContext, k as KubbFile_d_exports, m as RenderContextProps, o as FabricMode, r as FabricConfig, t as Fabric } from "./Fabric-DMmgrLto.cjs";
2
- import { t as ComponentNode } from "./useNodeTree-CgEKFUV-.cjs";
3
- import { n as RootContextProps } from "./RootContext-Cf7WJM7r.cjs";
4
-
5
- //#region src/types.d.ts
6
- type JSDoc = {
7
- comments: string[];
8
- };
9
- //#endregion
10
- export { type ComponentNode, type Context, type Fabric, type FabricConfig, type FabricContext, KubbFile_d_exports as FabricFile, KubbFile_d_exports as KubbFile, type FabricMode, type FabricOptions, JSDoc, type RenderContextProps, type RootContextProps };
11
- //# sourceMappingURL=types.d.cts.map
@@ -1,136 +0,0 @@
1
- import http from 'node:http'
2
- import type { AddressInfo } from 'node:net'
3
- import path from 'node:path'
4
- import handler from 'serve-handler'
5
- import { createFile } from '../createFile.ts'
6
- import type * as KubbFile from '../KubbFile.ts'
7
- import { open } from '../utils/open.ts'
8
- import { type Graph, TreeNode } from '../utils/TreeNode.ts'
9
- import { definePlugin } from './definePlugin.ts'
10
-
11
- type Options = {
12
- root: string
13
- /**
14
- * @default false
15
- */
16
- open?: boolean
17
- }
18
-
19
- type GetGraphOptions = {
20
- files: KubbFile.File[]
21
- root: string
22
- }
23
-
24
- export function getGraph({ files, root }: GetGraphOptions): Graph | undefined {
25
- const treeNode = TreeNode.fromFiles(files, root)
26
-
27
- if (!treeNode) {
28
- return undefined
29
- }
30
-
31
- return TreeNode.toGraph(treeNode)
32
- }
33
- const html = `
34
- <!DOCTYPE html>
35
- <html lang="en">
36
- <head>
37
- <meta charset="UTF-8" />
38
- <title>File Graph</title>
39
- <script type="module">
40
- import { Network } from 'https://cdn.jsdelivr.net/npm/vis-network/standalone/esm/vis-network.min.js'
41
-
42
- async function main() {
43
- const res = await fetch('./graph.json')
44
- const { nodes, edges } = await res.json()
45
- const container = document.getElementById('graph')
46
-
47
- const network = new Network(
48
- container,
49
- { nodes, edges },
50
- {
51
- layout: { hierarchical: { direction: 'UD', sortMethod: 'directed' } },
52
- nodes: { shape: 'box', font: { face: 'monospace' } },
53
- edges: { arrows: 'to' },
54
- physics: false,
55
- },
56
- )
57
- }
58
-
59
- main()
60
- </script>
61
- <style>
62
- html, body, #graph { height: 100%; margin: 0; }
63
- </style>
64
- </head>
65
- <body>
66
- <div id="graph"></div>
67
- </body>
68
- </html>
69
- `
70
-
71
- async function serve(root: string) {
72
- const server = http.createServer((req, res) => {
73
- return handler(req, res, {
74
- public: root,
75
- cleanUrls: true,
76
- })
77
- })
78
-
79
- server.listen(0, async () => {
80
- const { port } = server.address() as AddressInfo
81
- console.log(`Running on http://localhost:${port}/graph.html`)
82
-
83
- await open(`http://localhost:${port}/graph.html`)
84
- })
85
- }
86
-
87
- export const graphPlugin = definePlugin<Options>({
88
- name: 'graph',
89
- install(ctx, options) {
90
- if (!options) {
91
- throw new Error('Graph plugin requires options.root and options.mode')
92
- }
93
-
94
- ctx.on('files:writing:start', async (files) => {
95
- const root = options.root
96
-
97
- const graph = getGraph({ files, root })
98
-
99
- if (!graph) {
100
- return undefined
101
- }
102
-
103
- const graphFile = createFile({
104
- baseName: 'graph.json',
105
- path: path.join(root, 'graph.json'),
106
- sources: [
107
- {
108
- name: 'graph',
109
- value: JSON.stringify(graph, null, 2),
110
- },
111
- ],
112
- imports: [],
113
- exports: [],
114
- })
115
-
116
- const graphHtmlFile = createFile({
117
- baseName: 'graph.html',
118
- path: path.join(root, 'graph.html'),
119
- sources: [
120
- {
121
- name: 'graph',
122
- value: html,
123
- },
124
- ],
125
- imports: [],
126
- exports: [],
127
- })
128
-
129
- await ctx.addFile(graphFile, graphHtmlFile)
130
-
131
- if (options.open) {
132
- await serve(root)
133
- }
134
- })
135
- },
136
- })