@kubb/fabric-core 0.2.0 → 0.2.2
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 +49 -78
- package/dist/{App-ztRQpZS9.d.ts → Fabric-CCPgegwe.d.cts} +29 -29
- package/dist/{App-Cjd-lGfW.d.cts → Fabric-Cu_YHe4S.d.ts} +29 -29
- package/dist/index-BUculP1D.d.cts +18 -0
- package/dist/index-CvkyZHXK.d.ts +18 -0
- package/dist/index.cjs +17 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +16 -16
- package/dist/index.js.map +1 -1
- package/dist/parsers/typescript.d.cts +2 -2
- package/dist/parsers/typescript.d.ts +2 -2
- package/dist/parsers.d.cts +2 -2
- package/dist/parsers.d.ts +2 -2
- package/dist/plugins.cjs +54 -30
- package/dist/plugins.cjs.map +1 -1
- package/dist/plugins.d.cts +5 -5
- package/dist/plugins.d.ts +5 -5
- package/dist/plugins.js +54 -29
- package/dist/plugins.js.map +1 -1
- package/dist/types.d.cts +3 -3
- package/dist/types.d.ts +3 -3
- package/dist/{typescriptParser-DDr_EXfe.d.ts → typescriptParser-CCbr9PD6.d.cts} +2 -2
- package/dist/{typescriptParser-CBt00C7L.d.cts → typescriptParser-DHu674Vq.d.ts} +2 -2
- package/package.json +2 -4
- package/src/{App.ts → Fabric.ts} +16 -16
- package/src/FileManager.ts +4 -4
- package/src/FileProcessor.ts +5 -5
- package/src/createFabric.ts +3 -0
- package/src/{defineApp.ts → defineFabric.ts} +19 -19
- package/src/index.ts +3 -3
- package/src/parsers/types.ts +1 -1
- package/src/plugins/barrelPlugin.ts +2 -2
- package/src/plugins/fsPlugin.ts +48 -55
- package/src/plugins/graphPlugin.ts +1 -1
- package/src/plugins/types.ts +1 -1
- package/src/types.ts +2 -4
- package/src/utils/open.ts +36 -0
- package/dist/index-BUERYeq7.d.cts +0 -18
- package/dist/index-DfaD7Pj_.d.ts +0 -18
- package/src/createApp.ts +0 -3
package/src/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
1
|
+
export { createFabric } from './createFabric.ts'
|
|
2
|
+
export { defineFabric } from './defineFabric.ts'
|
|
3
3
|
export { FileManager } from './FileManager.ts'
|
|
4
4
|
export { createFile } from './createFile.ts'
|
|
5
5
|
export { FileProcessor } from './FileProcessor.ts'
|
|
6
|
-
export type {
|
|
6
|
+
export type { Fabric } from './Fabric.ts'
|
package/src/parsers/types.ts
CHANGED
|
@@ -27,14 +27,14 @@ type ExtendOptions = {
|
|
|
27
27
|
// biome-ignore lint/suspicious/noTsIgnore: production ready
|
|
28
28
|
// @ts-ignore
|
|
29
29
|
declare module '@kubb/fabric-core' {
|
|
30
|
-
interface
|
|
30
|
+
interface Fabric {
|
|
31
31
|
writeEntry(options: WriteEntryOptions): Promise<void>
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
declare global {
|
|
36
36
|
namespace Kubb {
|
|
37
|
-
interface
|
|
37
|
+
interface Fabric {
|
|
38
38
|
writeEntry(options: WriteEntryOptions): Promise<void>
|
|
39
39
|
}
|
|
40
40
|
}
|
package/src/plugins/fsPlugin.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { createPlugin } from './createPlugin.ts'
|
|
2
|
-
import { switcher } from 'js-runtime'
|
|
3
2
|
import fs from 'fs-extra'
|
|
4
3
|
import { resolve } from 'node:path'
|
|
5
4
|
import type * as KubbFile from '../KubbFile.ts'
|
|
@@ -25,76 +24,70 @@ type ExtendOptions = {
|
|
|
25
24
|
}
|
|
26
25
|
|
|
27
26
|
export async function write(path: string, data: string | undefined, options: { sanity?: boolean } = {}): Promise<string | undefined> {
|
|
28
|
-
|
|
29
|
-
{
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
return undefined
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
try {
|
|
36
|
-
const oldContent = await fs.readFile(resolve(path), {
|
|
37
|
-
encoding: 'utf-8',
|
|
38
|
-
})
|
|
39
|
-
if (oldContent?.toString() === data?.toString()) {
|
|
40
|
-
return
|
|
41
|
-
}
|
|
42
|
-
} catch (_err) {
|
|
43
|
-
/* empty */
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
await fs.outputFile(resolve(path), data.trim(), { encoding: 'utf-8' })
|
|
47
|
-
|
|
48
|
-
if (sanity) {
|
|
49
|
-
const savedData = await fs.readFile(resolve(path), {
|
|
50
|
-
encoding: 'utf-8',
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
if (savedData?.toString() !== data?.toString()) {
|
|
54
|
-
throw new Error(`Sanity check failed for ${path}\n\nData[${data.length}]:\n${data}\n\nSaved[${savedData.length}]:\n${savedData}\n`)
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return savedData
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return data
|
|
61
|
-
},
|
|
62
|
-
bun: async (path: string, data: string | undefined, { sanity }: { sanity?: boolean }) => {
|
|
63
|
-
if (!data || data?.trim() === '') {
|
|
64
|
-
return undefined
|
|
65
|
-
}
|
|
27
|
+
if (typeof Bun !== 'undefined') {
|
|
28
|
+
if (!data || data?.trim() === '') {
|
|
29
|
+
return undefined
|
|
30
|
+
}
|
|
66
31
|
|
|
67
|
-
|
|
32
|
+
await Bun.write(resolve(path), data.trim())
|
|
68
33
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
34
|
+
if (options?.sanity) {
|
|
35
|
+
const file = Bun.file(resolve(path))
|
|
36
|
+
const savedData = await file.text()
|
|
72
37
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
38
|
+
if (savedData?.toString() !== data?.toString()) {
|
|
39
|
+
throw new Error(`Sanity check failed for ${path}\n\nData[${data.length}]:\n${data}\n\nSaved[${savedData.length}]:\n${savedData}\n`)
|
|
40
|
+
}
|
|
76
41
|
|
|
77
|
-
|
|
78
|
-
|
|
42
|
+
return savedData
|
|
43
|
+
}
|
|
79
44
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
45
|
+
return data
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (!data || data?.trim() === '') {
|
|
49
|
+
return undefined
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
try {
|
|
53
|
+
const oldContent = await fs.readFile(resolve(path), {
|
|
54
|
+
encoding: 'utf-8',
|
|
55
|
+
})
|
|
56
|
+
if (oldContent?.toString() === data?.toString()) {
|
|
57
|
+
return
|
|
58
|
+
}
|
|
59
|
+
} catch (_err) {
|
|
60
|
+
/* empty */
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
await fs.outputFile(resolve(path), data.trim(), { encoding: 'utf-8' })
|
|
64
|
+
|
|
65
|
+
if (options?.sanity) {
|
|
66
|
+
const savedData = await fs.readFile(resolve(path), {
|
|
67
|
+
encoding: 'utf-8',
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
if (savedData?.toString() !== data?.toString()) {
|
|
71
|
+
throw new Error(`Sanity check failed for ${path}\n\nData[${data.length}]:\n${data}\n\nSaved[${savedData.length}]:\n${savedData}\n`)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return savedData
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return data
|
|
85
78
|
}
|
|
86
79
|
|
|
87
80
|
// biome-ignore lint/suspicious/noTsIgnore: production ready
|
|
88
81
|
// @ts-ignore
|
|
89
82
|
declare module '@kubb/fabric-core' {
|
|
90
|
-
interface
|
|
83
|
+
interface Fabric {
|
|
91
84
|
write(options?: WriteOptions): Promise<void>
|
|
92
85
|
}
|
|
93
86
|
}
|
|
94
87
|
|
|
95
88
|
declare global {
|
|
96
89
|
namespace Kubb {
|
|
97
|
-
interface
|
|
90
|
+
interface Fabric {
|
|
98
91
|
write(options?: WriteOptions): Promise<void>
|
|
99
92
|
}
|
|
100
93
|
}
|
|
@@ -3,9 +3,9 @@ import type * as KubbFile from '../KubbFile.ts'
|
|
|
3
3
|
import { type Graph, TreeNode } from '../utils/TreeNode.ts'
|
|
4
4
|
import path from 'node:path'
|
|
5
5
|
import http from 'node:http'
|
|
6
|
-
import open from 'tiny-open'
|
|
7
6
|
import type { AddressInfo } from 'node:net'
|
|
8
7
|
import handler from 'serve-handler'
|
|
8
|
+
import { open } from '../utils/open.ts'
|
|
9
9
|
|
|
10
10
|
import { createFile } from '../createFile.ts'
|
|
11
11
|
|
package/src/plugins/types.ts
CHANGED
package/src/types.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
export * as KubbFile from './KubbFile.ts'
|
|
2
|
-
export type {
|
|
3
|
-
export type {
|
|
4
|
-
|
|
5
|
-
export type { App } from './App.ts'
|
|
2
|
+
export type { DefineFabric } from './defineFabric.ts'
|
|
3
|
+
export type { FabricContext, Fabric, FabricMode } from './Fabric.ts'
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process'
|
|
2
|
+
|
|
3
|
+
const spawnBin = (bin: string, args: string[]): Promise<boolean> => {
|
|
4
|
+
return new Promise((resolve) => {
|
|
5
|
+
const process = spawn(bin, args, {
|
|
6
|
+
detached: true,
|
|
7
|
+
shell: false,
|
|
8
|
+
windowsHide: true,
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
process.on('close', (code) => {
|
|
12
|
+
resolve(!code)
|
|
13
|
+
})
|
|
14
|
+
})
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
type Options = {
|
|
18
|
+
app?: string
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export async function open(path: string, options?: Options): Promise<boolean> {
|
|
22
|
+
const app = options?.app
|
|
23
|
+
|
|
24
|
+
if (process.platform === 'win32') {
|
|
25
|
+
return spawnBin('cmd.exe', ['/c', 'start', app || '', path.replace(/[&^]/g, '^$&')])
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (process.platform === 'linux') {
|
|
29
|
+
return spawnBin(app || 'xdg-open', [path])
|
|
30
|
+
}
|
|
31
|
+
if (process.platform === 'darwin') {
|
|
32
|
+
return spawnBin('open', app ? ['-a', app, path] : [path])
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
throw new Error(`Unsupported platform, could not open "${path}"`)
|
|
36
|
+
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { d as File, p as ResolvedFile, r as AppOptions, t as App } from "./App-Cjd-lGfW.cjs";
|
|
2
|
-
|
|
3
|
-
//#region src/defineApp.d.ts
|
|
4
|
-
type RootRenderFunction<TApp extends App> = (app: TApp) => void | Promise<void>;
|
|
5
|
-
type DefineApp<TOptions> = (options?: TOptions) => App;
|
|
6
|
-
declare function defineApp<TOptions extends AppOptions>(instance?: RootRenderFunction<App<TOptions>>): DefineApp<TOptions>;
|
|
7
|
-
//#endregion
|
|
8
|
-
//#region src/createApp.d.ts
|
|
9
|
-
declare const createApp: DefineApp<AppOptions>;
|
|
10
|
-
//#endregion
|
|
11
|
-
//#region src/createFile.d.ts
|
|
12
|
-
/**
|
|
13
|
-
* Helper to create a file with name and id set
|
|
14
|
-
*/
|
|
15
|
-
declare function createFile<TMeta extends object = object>(file: File<TMeta>): ResolvedFile<TMeta>;
|
|
16
|
-
//#endregion
|
|
17
|
-
export { defineApp as i, createApp as n, DefineApp as r, createFile as t };
|
|
18
|
-
//# sourceMappingURL=index-BUERYeq7.d.cts.map
|
package/dist/index-DfaD7Pj_.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { d as File, p as ResolvedFile, r as AppOptions, t as App } from "./App-ztRQpZS9.js";
|
|
2
|
-
|
|
3
|
-
//#region src/defineApp.d.ts
|
|
4
|
-
type RootRenderFunction<TApp extends App> = (app: TApp) => void | Promise<void>;
|
|
5
|
-
type DefineApp<TOptions> = (options?: TOptions) => App;
|
|
6
|
-
declare function defineApp<TOptions extends AppOptions>(instance?: RootRenderFunction<App<TOptions>>): DefineApp<TOptions>;
|
|
7
|
-
//#endregion
|
|
8
|
-
//#region src/createApp.d.ts
|
|
9
|
-
declare const createApp: DefineApp<AppOptions>;
|
|
10
|
-
//#endregion
|
|
11
|
-
//#region src/createFile.d.ts
|
|
12
|
-
/**
|
|
13
|
-
* Helper to create a file with name and id set
|
|
14
|
-
*/
|
|
15
|
-
declare function createFile<TMeta extends object = object>(file: File<TMeta>): ResolvedFile<TMeta>;
|
|
16
|
-
//#endregion
|
|
17
|
-
export { defineApp as i, createApp as n, DefineApp as r, createFile as t };
|
|
18
|
-
//# sourceMappingURL=index-DfaD7Pj_.d.ts.map
|
package/src/createApp.ts
DELETED