@kubb/fabric-core 0.2.14 → 0.2.16
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 +5 -1
- package/dist/{Fabric-BfnUdEpq.d.cts → Fabric-AmREkq58.d.ts} +108 -63
- package/dist/{Fabric-CxMkO4Rt.d.ts → Fabric-CBrTERuf.d.cts} +108 -63
- package/dist/{defineProperty-CspRhtP3.cjs → defineProperty-Dlhh3lSJ.cjs} +58 -44
- package/dist/defineProperty-Dlhh3lSJ.cjs.map +1 -0
- package/dist/{defineProperty-BtekiGIK.js → defineProperty-_FBdEen_.js} +53 -39
- package/dist/defineProperty-_FBdEen_.js.map +1 -0
- package/dist/index.cjs +102 -60
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +25 -3
- package/dist/index.d.ts +25 -3
- package/dist/index.js +102 -60
- 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.cjs.map +1 -1
- package/dist/parsers.d.cts +2 -2
- package/dist/parsers.d.ts +2 -2
- package/dist/parsers.js.map +1 -1
- package/dist/plugins.cjs +98 -104
- package/dist/plugins.cjs.map +1 -1
- package/dist/plugins.d.cts +30 -40
- package/dist/plugins.d.ts +30 -40
- package/dist/plugins.js +94 -100
- package/dist/plugins.js.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +2 -3
- package/dist/types.d.ts +2 -3
- package/dist/types.js.map +1 -1
- package/dist/{typescriptParser-Dz9T1BQ1.d.cts → typescriptParser-C3B3dzh_.d.cts} +2 -2
- package/dist/typescriptParser-CNHO6H2_.cjs.map +1 -1
- package/dist/typescriptParser-CWT7zCJy.js.map +1 -1
- package/dist/{typescriptParser-DypTa1AN.d.ts → typescriptParser-DaOfAlmM.d.ts} +2 -2
- package/package.json +1 -1
- package/src/Fabric.ts +102 -52
- package/src/FileManager.ts +23 -6
- package/src/FileProcessor.ts +3 -4
- package/src/KubbFile.ts +0 -2
- package/src/createFile.ts +90 -74
- package/src/defineFabric.ts +53 -28
- package/src/index.ts +3 -3
- package/src/parsers/tsxParser.ts +1 -1
- package/src/parsers/types.ts +1 -1
- package/src/parsers/typescriptParser.ts +1 -1
- package/src/plugins/barrelPlugin.ts +13 -21
- package/src/plugins/fsPlugin.ts +8 -16
- package/src/plugins/graphPlugin.ts +8 -9
- package/src/plugins/index.ts +2 -3
- package/src/plugins/progressPlugin.ts +6 -6
- package/src/plugins/types.ts +1 -1
- package/src/types.ts +1 -2
- package/src/utils/AsyncEventEmitter.ts +29 -8
- package/dist/defineFabric-CR1OjcoI.d.ts +0 -9
- package/dist/defineFabric-TvKfRefj.d.cts +0 -9
- package/dist/defineProperty-BtekiGIK.js.map +0 -1
- package/dist/defineProperty-CspRhtP3.cjs.map +0 -1
- package/src/utils/EventEmitter.ts +0 -31
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/** biome-ignore-all lint/suspicious/useIterableCallbackReturn: not needed */
|
|
2
2
|
|
|
3
|
-
import { createPlugin } from './createPlugin.ts'
|
|
4
|
-
import type * as KubbFile from '../KubbFile.ts'
|
|
5
|
-
import { TreeNode } from '../utils/TreeNode.ts'
|
|
6
3
|
import path from 'node:path'
|
|
7
|
-
import { getRelativePath } from '../utils/getRelativePath.ts'
|
|
8
4
|
import { createFile } from '../createFile.ts'
|
|
5
|
+
import type * as KubbFile from '../KubbFile.ts'
|
|
6
|
+
import { getRelativePath } from '../utils/getRelativePath.ts'
|
|
7
|
+
import { TreeNode } from '../utils/TreeNode.ts'
|
|
8
|
+
import { createPlugin } from './createPlugin.ts'
|
|
9
9
|
|
|
10
10
|
type Mode = 'all' | 'named' | 'propagate' | false
|
|
11
11
|
|
|
@@ -24,14 +24,6 @@ type ExtendOptions = {
|
|
|
24
24
|
writeEntry(options: WriteEntryOptions): Promise<void>
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
// biome-ignore lint/suspicious/noTsIgnore: production ready
|
|
28
|
-
// @ts-ignore
|
|
29
|
-
declare module '@kubb/fabric-core' {
|
|
30
|
-
interface Fabric {
|
|
31
|
-
writeEntry(options: WriteEntryOptions): Promise<void>
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
27
|
declare global {
|
|
36
28
|
namespace Kubb {
|
|
37
29
|
interface Fabric {
|
|
@@ -135,7 +127,7 @@ export function getBarrelFiles({ files, root, mode }: GetBarrelFilesOptions): Ar
|
|
|
135
127
|
|
|
136
128
|
export const barrelPlugin = createPlugin<Options, ExtendOptions>({
|
|
137
129
|
name: 'barrel',
|
|
138
|
-
install(
|
|
130
|
+
install(ctx, options) {
|
|
139
131
|
if (!options) {
|
|
140
132
|
throw new Error('Barrel plugin requires options.root and options.mode')
|
|
141
133
|
}
|
|
@@ -144,14 +136,14 @@ export const barrelPlugin = createPlugin<Options, ExtendOptions>({
|
|
|
144
136
|
return undefined
|
|
145
137
|
}
|
|
146
138
|
|
|
147
|
-
|
|
139
|
+
ctx.on('write:start', async ({ files }) => {
|
|
148
140
|
const root = options.root
|
|
149
141
|
const barrelFiles = getBarrelFiles({ files, root, mode: options.mode })
|
|
150
142
|
|
|
151
|
-
await
|
|
143
|
+
await ctx.fileManager.add(...barrelFiles)
|
|
152
144
|
})
|
|
153
145
|
},
|
|
154
|
-
inject(
|
|
146
|
+
inject(ctx, options) {
|
|
155
147
|
if (!options) {
|
|
156
148
|
throw new Error('Barrel plugin requires options.root and options.mode')
|
|
157
149
|
}
|
|
@@ -164,7 +156,7 @@ export const barrelPlugin = createPlugin<Options, ExtendOptions>({
|
|
|
164
156
|
|
|
165
157
|
const rootPath = path.resolve(root, 'index.ts')
|
|
166
158
|
|
|
167
|
-
const barrelFiles =
|
|
159
|
+
const barrelFiles = ctx.files.filter((file) => {
|
|
168
160
|
return file.sources.some((source) => source.isIndexable)
|
|
169
161
|
})
|
|
170
162
|
|
|
@@ -193,12 +185,12 @@ export const barrelPlugin = createPlugin<Options, ExtendOptions>({
|
|
|
193
185
|
sources: [],
|
|
194
186
|
})
|
|
195
187
|
|
|
196
|
-
await
|
|
188
|
+
await ctx.addFile(entryFile)
|
|
197
189
|
|
|
198
|
-
await
|
|
199
|
-
mode:
|
|
190
|
+
await ctx.fileManager.write({
|
|
191
|
+
mode: ctx.config?.options?.mode,
|
|
200
192
|
dryRun: options.dryRun,
|
|
201
|
-
parsers:
|
|
193
|
+
parsers: ctx.installedParsers,
|
|
202
194
|
})
|
|
203
195
|
},
|
|
204
196
|
}
|
package/src/plugins/fsPlugin.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { createPlugin } from './createPlugin.ts'
|
|
2
|
-
import fs from 'fs-extra'
|
|
3
1
|
import { resolve } from 'node:path'
|
|
2
|
+
import fs from 'fs-extra'
|
|
4
3
|
import type * as KubbFile from '../KubbFile.ts'
|
|
4
|
+
import { createPlugin } from './createPlugin.ts'
|
|
5
5
|
|
|
6
6
|
type WriteOptions = {
|
|
7
7
|
extension?: Record<KubbFile.Extname, KubbFile.Extname | ''>
|
|
@@ -77,14 +77,6 @@ export async function write(path: string, data: string | undefined, options: { s
|
|
|
77
77
|
return data
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
// biome-ignore lint/suspicious/noTsIgnore: production ready
|
|
81
|
-
// @ts-ignore
|
|
82
|
-
declare module '@kubb/fabric-core' {
|
|
83
|
-
interface Fabric {
|
|
84
|
-
write(options?: WriteOptions): Promise<void>
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
80
|
declare global {
|
|
89
81
|
namespace Kubb {
|
|
90
82
|
interface Fabric {
|
|
@@ -95,30 +87,30 @@ declare global {
|
|
|
95
87
|
|
|
96
88
|
export const fsPlugin = createPlugin<Options, ExtendOptions>({
|
|
97
89
|
name: 'fs',
|
|
98
|
-
install(
|
|
90
|
+
install(ctx, options = {}) {
|
|
99
91
|
if (options.clean) {
|
|
100
92
|
fs.removeSync(options.clean.path)
|
|
101
93
|
}
|
|
102
94
|
|
|
103
|
-
|
|
95
|
+
ctx.on('process:progress', async ({ file, source }) => {
|
|
104
96
|
if (options.onBeforeWrite) {
|
|
105
97
|
await options.onBeforeWrite(file.path, source)
|
|
106
98
|
}
|
|
107
99
|
await write(file.path, source, { sanity: false })
|
|
108
100
|
})
|
|
109
101
|
},
|
|
110
|
-
inject(
|
|
102
|
+
inject(ctx, { dryRun } = {}) {
|
|
111
103
|
return {
|
|
112
104
|
async write(
|
|
113
105
|
options = {
|
|
114
106
|
extension: { '.ts': '.ts' },
|
|
115
107
|
},
|
|
116
108
|
) {
|
|
117
|
-
await
|
|
118
|
-
mode:
|
|
109
|
+
await ctx.fileManager.write({
|
|
110
|
+
mode: ctx.config?.options?.mode,
|
|
119
111
|
extension: options.extension,
|
|
120
112
|
dryRun,
|
|
121
|
-
parsers:
|
|
113
|
+
parsers: ctx.installedParsers,
|
|
122
114
|
})
|
|
123
115
|
},
|
|
124
116
|
}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { createPlugin } from './createPlugin.ts'
|
|
2
|
-
import type * as KubbFile from '../KubbFile.ts'
|
|
3
|
-
import { type Graph, TreeNode } from '../utils/TreeNode.ts'
|
|
4
|
-
import path from 'node:path'
|
|
5
1
|
import http from 'node:http'
|
|
6
2
|
import type { AddressInfo } from 'node:net'
|
|
3
|
+
import path from 'node:path'
|
|
7
4
|
import handler from 'serve-handler'
|
|
8
|
-
import { open } from '../utils/open.ts'
|
|
9
|
-
|
|
10
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 { createPlugin } from './createPlugin.ts'
|
|
11
10
|
|
|
12
11
|
type Options = {
|
|
13
12
|
root: string
|
|
@@ -87,12 +86,12 @@ async function serve(root: string) {
|
|
|
87
86
|
|
|
88
87
|
export const graphPlugin = createPlugin<Options>({
|
|
89
88
|
name: 'graph',
|
|
90
|
-
install(
|
|
89
|
+
install(ctx, options) {
|
|
91
90
|
if (!options) {
|
|
92
91
|
throw new Error('Graph plugin requires options.root and options.mode')
|
|
93
92
|
}
|
|
94
93
|
|
|
95
|
-
|
|
94
|
+
ctx.on('write:start', async ({ files }) => {
|
|
96
95
|
const root = options.root
|
|
97
96
|
|
|
98
97
|
const graph = getGraph({ files, root })
|
|
@@ -123,7 +122,7 @@ export const graphPlugin = createPlugin<Options>({
|
|
|
123
122
|
],
|
|
124
123
|
})
|
|
125
124
|
|
|
126
|
-
await
|
|
125
|
+
await ctx.addFile(graphFile, graphHtmlFile)
|
|
127
126
|
|
|
128
127
|
if (options.open) {
|
|
129
128
|
await serve(root)
|
package/src/plugins/index.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
+
export { barrelPlugin } from './barrelPlugin.ts'
|
|
1
2
|
export { createPlugin } from './createPlugin.ts'
|
|
2
|
-
|
|
3
3
|
export { fsPlugin } from './fsPlugin.ts'
|
|
4
|
-
export { barrelPlugin } from './barrelPlugin.ts'
|
|
5
|
-
export { progressPlugin } from './progressPlugin.ts'
|
|
6
4
|
export { graphPlugin } from './graphPlugin.ts'
|
|
5
|
+
export { progressPlugin } from './progressPlugin.ts'
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { Presets, SingleBar } from 'cli-progress'
|
|
2
|
-
import { createPlugin } from './createPlugin.ts'
|
|
3
1
|
import { relative } from 'node:path'
|
|
4
2
|
import process from 'node:process'
|
|
3
|
+
import { Presets, SingleBar } from 'cli-progress'
|
|
4
|
+
import { createPlugin } from './createPlugin.ts'
|
|
5
5
|
|
|
6
6
|
export const progressPlugin = createPlugin({
|
|
7
7
|
name: 'progress',
|
|
8
|
-
install(
|
|
8
|
+
install(ctx) {
|
|
9
9
|
const progressBar = new SingleBar(
|
|
10
10
|
{
|
|
11
11
|
format: '{bar} {percentage}% | {value}/{total} | {message}',
|
|
@@ -17,16 +17,16 @@ export const progressPlugin = createPlugin({
|
|
|
17
17
|
Presets.shades_grey,
|
|
18
18
|
)
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
ctx.on('process:start', async ({ files }) => {
|
|
21
21
|
progressBar.start(files.length, 0, { message: 'Starting...' })
|
|
22
22
|
})
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
ctx.on('process:progress', async ({ file }) => {
|
|
25
25
|
const message = `Writing ${relative(process.cwd(), file.path)}`
|
|
26
26
|
progressBar.increment(1, { message })
|
|
27
27
|
})
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
ctx.on('process:end', async ({ files }) => {
|
|
30
30
|
progressBar.update(files.length, { message: 'Done ✅' })
|
|
31
31
|
progressBar.stop()
|
|
32
32
|
})
|
package/src/plugins/types.ts
CHANGED
package/src/types.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
+
export type { FabricConfig, FabricContext, FabricMode, FabricOptions } from './Fabric.ts'
|
|
1
2
|
export * as KubbFile from './KubbFile.ts'
|
|
2
|
-
export type { DefineFabric } from './defineFabric.ts'
|
|
3
|
-
export type { FabricContext, FabricMode, FabricConfig, FabricOptions } from './Fabric.ts'
|
|
@@ -1,27 +1,47 @@
|
|
|
1
1
|
import { EventEmitter as NodeEventEmitter } from 'node:events'
|
|
2
|
+
import type { FabricMode } from '../Fabric.ts'
|
|
3
|
+
|
|
4
|
+
type Options = {
|
|
5
|
+
mode?: FabricMode
|
|
6
|
+
maxListener?: number
|
|
7
|
+
}
|
|
2
8
|
|
|
3
9
|
export class AsyncEventEmitter<TEvents extends Record<string, any>> {
|
|
4
|
-
constructor(maxListener = 100) {
|
|
10
|
+
constructor({ maxListener = 100, mode = 'sequential' }: Options = {}) {
|
|
5
11
|
this.#emitter.setMaxListeners(maxListener)
|
|
12
|
+
this.#mode = mode
|
|
6
13
|
}
|
|
14
|
+
|
|
7
15
|
#emitter = new NodeEventEmitter()
|
|
16
|
+
#mode: FabricMode
|
|
8
17
|
|
|
9
18
|
async emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArgs: TEvents[TEventName]): Promise<void> {
|
|
10
19
|
const listeners = this.#emitter.listeners(eventName) as Array<(...args: TEvents[TEventName]) => any>
|
|
11
20
|
|
|
12
21
|
if (listeners.length === 0) {
|
|
13
|
-
return
|
|
22
|
+
return
|
|
14
23
|
}
|
|
15
24
|
|
|
16
|
-
|
|
17
|
-
listeners
|
|
25
|
+
if (this.#mode === 'sequential') {
|
|
26
|
+
// Run listeners one by one, in order
|
|
27
|
+
for (const listener of listeners) {
|
|
28
|
+
try {
|
|
29
|
+
await listener(...eventArgs)
|
|
30
|
+
} catch (err) {
|
|
31
|
+
console.error(`Error in listener for "${eventName}":`, err)
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
} else {
|
|
35
|
+
// Run all listeners concurrently
|
|
36
|
+
const promises = listeners.map(async (listener) => {
|
|
18
37
|
try {
|
|
19
|
-
|
|
38
|
+
await listener(...eventArgs)
|
|
20
39
|
} catch (err) {
|
|
21
|
-
console.error(`Error in
|
|
40
|
+
console.error(`Error in listener for "${eventName}":`, err)
|
|
22
41
|
}
|
|
23
|
-
})
|
|
24
|
-
|
|
42
|
+
})
|
|
43
|
+
await Promise.all(promises)
|
|
44
|
+
}
|
|
25
45
|
}
|
|
26
46
|
|
|
27
47
|
on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void {
|
|
@@ -39,6 +59,7 @@ export class AsyncEventEmitter<TEvents extends Record<string, any>> {
|
|
|
39
59
|
off<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void {
|
|
40
60
|
this.#emitter.off(eventName, handler as any)
|
|
41
61
|
}
|
|
62
|
+
|
|
42
63
|
removeAll(): void {
|
|
43
64
|
this.#emitter.removeAllListeners()
|
|
44
65
|
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { a as FabricOptions, n as FabricConfig, t as Fabric } from "./Fabric-CxMkO4Rt.js";
|
|
2
|
-
|
|
3
|
-
//#region src/defineFabric.d.ts
|
|
4
|
-
type RootRenderFunction<TOptions extends FabricOptions> = (fabric: Fabric<TOptions>) => void | Promise<void>;
|
|
5
|
-
type DefineFabric<TOptions extends FabricOptions> = (config?: FabricConfig<TOptions>) => Fabric<TOptions>;
|
|
6
|
-
declare function defineFabric<TOptions extends FabricOptions>(instance?: RootRenderFunction<TOptions>): DefineFabric<TOptions>;
|
|
7
|
-
//#endregion
|
|
8
|
-
export { defineFabric as n, DefineFabric as t };
|
|
9
|
-
//# sourceMappingURL=defineFabric-CR1OjcoI.d.ts.map
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { a as FabricOptions, n as FabricConfig, t as Fabric } from "./Fabric-BfnUdEpq.cjs";
|
|
2
|
-
|
|
3
|
-
//#region src/defineFabric.d.ts
|
|
4
|
-
type RootRenderFunction<TOptions extends FabricOptions> = (fabric: Fabric<TOptions>) => void | Promise<void>;
|
|
5
|
-
type DefineFabric<TOptions extends FabricOptions> = (config?: FabricConfig<TOptions>) => Fabric<TOptions>;
|
|
6
|
-
declare function defineFabric<TOptions extends FabricOptions>(instance?: RootRenderFunction<TOptions>): DefineFabric<TOptions>;
|
|
7
|
-
//#endregion
|
|
8
|
-
export { defineFabric as n, DefineFabric as t };
|
|
9
|
-
//# sourceMappingURL=defineFabric-TvKfRefj.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"defineProperty-BtekiGIK.js","names":["e","r","n","t","t","i","n","e","r","t","n","r","e","t","a","e","r","i","n","t","r","n","i","e","t","e","n","r","i","a","e","t","n","r","i","a","uniqueBy","isDeepEqual","name"],"sources":["../../../node_modules/.pnpm/remeda@2.32.0/node_modules/remeda/dist/lazyDataLastImpl-BDhrIOwR.js","../../../node_modules/.pnpm/remeda@2.32.0/node_modules/remeda/dist/purry-DH9cw9sy.js","../../../node_modules/.pnpm/remeda@2.32.0/node_modules/remeda/dist/utilityEvaluators-DORpnx39.js","../../../node_modules/.pnpm/remeda@2.32.0/node_modules/remeda/dist/pipe-jLehR9-P.js","../../../node_modules/.pnpm/remeda@2.32.0/node_modules/remeda/dist/purryFromLazy-3oywCNIb.js","../../../node_modules/.pnpm/remeda@2.32.0/node_modules/remeda/dist/isDeepEqual-jLo35Woq.js","../../../node_modules/.pnpm/remeda@2.32.0/node_modules/remeda/dist/uniqueBy-C_PxkF_D.js","../src/createFile.ts"],"sourcesContent":["function e(e,t,n){let r=n=>e(n,...t);return n===void 0?r:Object.assign(r,{lazy:n,lazyArgs:t})}export{e as lazyDataLastImpl};\n//# sourceMappingURL=lazyDataLastImpl-BDhrIOwR.js.map","import{lazyDataLastImpl as e}from\"./lazyDataLastImpl-BDhrIOwR.js\";function t(t,n,r){let i=t.length-n.length;if(i===0)return t(...n);if(i===1)return e(t,n,r);throw Error(`Wrong number of arguments`)}export{t as purry};\n//# sourceMappingURL=purry-DH9cw9sy.js.map","const e={done:!0,hasNext:!1},t={done:!1,hasNext:!1},n=()=>e,r=e=>({hasNext:!0,next:e,done:!1});export{t as SKIP_ITEM,n as lazyEmptyEvaluator,r as lazyIdentityEvaluator};\n//# sourceMappingURL=utilityEvaluators-DORpnx39.js.map","import{SKIP_ITEM as e}from\"./utilityEvaluators-DORpnx39.js\";function t(e,...t){let a=e,o=t.map(e=>`lazy`in e?r(e):void 0),s=0;for(;s<t.length;){if(o[s]===void 0||!i(a)){let e=t[s];a=e(a),s+=1;continue}let e=[];for(let n=s;n<t.length;n++){let t=o[n];if(t===void 0||(e.push(t),t.isSingle))break}let r=[];for(let t of a)if(n(t,r,e))break;let{isSingle:c}=e.at(-1);a=c?r[0]:r,s+=e.length}return a}function n(t,r,i){if(i.length===0)return r.push(t),!1;let a=t,o=e,s=!1;for(let[e,t]of i.entries()){let{index:c,items:l}=t;if(l.push(a),o=t(a,c,l),t.index+=1,o.hasNext){if(o.hasMany??!1){for(let t of o.next)if(n(t,r,i.slice(e+1)))return!0;return s}a=o.next}if(!o.hasNext)break;o.done&&(s=!0)}return o.hasNext&&r.push(a),s}function r(e){let{lazy:t,lazyArgs:n}=e,r=t(...n);return Object.assign(r,{isSingle:t.single??!1,index:0,items:[]})}function i(e){return typeof e==`string`||typeof e==`object`&&!!e&&Symbol.iterator in e}export{t as pipe};\n//# sourceMappingURL=pipe-jLehR9-P.js.map","import{pipe as e}from\"./pipe-jLehR9-P.js\";function t(t,n){let r=n.length-t.length;if(r===1){let[r,...i]=n;return e(r,{lazy:t,lazyArgs:i})}if(r===0){let r={lazy:t,lazyArgs:n};return Object.assign(t=>e(t,r),r)}throw Error(`Wrong number of arguments`)}export{t as purryFromLazy};\n//# sourceMappingURL=purryFromLazy-3oywCNIb.js.map","import{purry as e}from\"./purry-DH9cw9sy.js\";function t(...t){return e(n,t)}function n(e,t){if(e===t||Object.is(e,t))return!0;if(typeof e!=`object`||typeof t!=`object`||e===null||t===null||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1;if(Array.isArray(e))return r(e,t);if(e instanceof Map)return i(e,t);if(e instanceof Set)return a(e,t);if(e instanceof Date)return e.getTime()===t.getTime();if(e instanceof RegExp)return e.toString()===t.toString();if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let[r,i]of Object.entries(e))if(!(r in t)||!n(i,t[r]))return!1;return!0}function r(e,t){if(e.length!==t.length)return!1;for(let[r,i]of e.entries())if(!n(i,t[r]))return!1;return!0}function i(e,t){if(e.size!==t.size)return!1;for(let[r,i]of e.entries())if(!t.has(r)||!n(i,t.get(r)))return!1;return!0}function a(e,t){if(e.size!==t.size)return!1;let r=[...t];for(let t of e){let e=!1;for(let[i,a]of r.entries())if(n(t,a)){e=!0,r.splice(i,1);break}if(!e)return!1}return!0}export{t as isDeepEqual};\n//# sourceMappingURL=isDeepEqual-jLo35Woq.js.map","import{SKIP_ITEM as e}from\"./utilityEvaluators-DORpnx39.js\";import{purryFromLazy as t}from\"./purryFromLazy-3oywCNIb.js\";function n(...e){return t(r,e)}function r(t){let n=t,r=new Set;return(t,i,a)=>{let o=n(t,i,a);return r.has(o)?e:(r.add(o),{done:!1,hasNext:!0,next:t})}}export{n as uniqueBy};\n//# sourceMappingURL=uniqueBy-C_PxkF_D.js.map","import type * as KubbFile from './KubbFile.ts'\nimport { trimExtName } from './utils/trimExtName.ts'\nimport { createHash } from 'node:crypto'\nimport path from 'node:path'\nimport { isDeepEqual, uniqueBy } from 'remeda'\nimport { orderBy } from 'natural-orderby'\n\nfunction hashObject(obj: Record<string, unknown>): string {\n const str = JSON.stringify(obj, Object.keys(obj).sort())\n return createHash('sha256').update(str).digest('hex')\n}\n\nexport function combineSources(sources: Array<KubbFile.Source>): Array<KubbFile.Source> {\n return uniqueBy(sources, (obj) => [obj.name, obj.isExportable, obj.isTypeOnly] as const)\n}\n\nexport function combineExports(exports: Array<KubbFile.Export>): Array<KubbFile.Export> {\n return orderBy(exports, [\n (v) => !!Array.isArray(v.name),\n (v) => !v.isTypeOnly,\n (v) => v.path,\n (v) => !!v.name,\n (v) => (Array.isArray(v.name) ? orderBy(v.name) : v.name),\n ]).reduce(\n (prev, curr) => {\n const name = curr.name\n const prevByPath = prev.findLast((imp) => imp.path === curr.path)\n const prevByPathAndIsTypeOnly = prev.findLast((imp) => imp.path === curr.path && isDeepEqual(imp.name, name) && imp.isTypeOnly)\n\n if (prevByPathAndIsTypeOnly) {\n // we already have an export that has the same path but uses `isTypeOnly` (export type ...)\n return prev\n }\n\n const uniquePrev = prev.findLast(\n (imp) => imp.path === curr.path && isDeepEqual(imp.name, name) && imp.isTypeOnly === curr.isTypeOnly && imp.asAlias === curr.asAlias,\n )\n\n // we already have an item that was unique enough or name field is empty or prev asAlias is set but current has no changes\n if (uniquePrev || (Array.isArray(name) && !name.length) || (prevByPath?.asAlias && !curr.asAlias)) {\n return prev\n }\n\n if (!prevByPath) {\n return [\n ...prev,\n {\n ...curr,\n name: Array.isArray(name) ? [...new Set(name)] : name,\n },\n ]\n }\n\n // merge all names when prev and current both have the same isTypeOnly set\n if (prevByPath && Array.isArray(prevByPath.name) && Array.isArray(curr.name) && prevByPath.isTypeOnly === curr.isTypeOnly) {\n prevByPath.name = [...new Set([...prevByPath.name, ...curr.name])]\n\n return prev\n }\n\n return [...prev, curr]\n },\n [] as Array<KubbFile.Export>,\n )\n}\n\nexport function combineImports(imports: Array<KubbFile.Import>, exports: Array<KubbFile.Export>, source?: string): Array<KubbFile.Import> {\n return orderBy(imports, [\n (v) => !!Array.isArray(v.name),\n (v) => !v.isTypeOnly,\n (v) => v.path,\n (v) => !!v.name,\n (v) => (Array.isArray(v.name) ? orderBy(v.name) : v.name),\n ]).reduce(\n (prev, curr) => {\n let name = Array.isArray(curr.name) ? [...new Set(curr.name)] : curr.name\n\n const hasImportInSource = (importName: string) => {\n if (!source) {\n return true\n }\n\n const checker = (name?: string) => {\n return name && source.includes(name)\n }\n\n return checker(importName) || exports.some(({ name }) => (Array.isArray(name) ? name.some(checker) : checker(name)))\n }\n\n if (curr.path === curr.root) {\n // root and path are the same file, remove the \"./\" import\n return prev\n }\n\n // merge all names and check if the importName is being used in the generated source and if not filter those imports out\n if (Array.isArray(name)) {\n name = name.filter((item) => (typeof item === 'string' ? hasImportInSource(item) : hasImportInSource(item.propertyName)))\n }\n\n const prevByPath = prev.findLast((imp) => imp.path === curr.path && imp.isTypeOnly === curr.isTypeOnly)\n const uniquePrev = prev.findLast((imp) => imp.path === curr.path && isDeepEqual(imp.name, name) && imp.isTypeOnly === curr.isTypeOnly)\n const prevByPathNameAndIsTypeOnly = prev.findLast((imp) => imp.path === curr.path && isDeepEqual(imp.name, name) && imp.isTypeOnly)\n\n if (prevByPathNameAndIsTypeOnly) {\n // we already have an export that has the same path but uses `isTypeOnly` (import type ...)\n return prev\n }\n\n // already unique enough or name is empty\n if (uniquePrev || (Array.isArray(name) && !name.length)) {\n return prev\n }\n\n // new item, append name\n if (!prevByPath) {\n return [\n ...prev,\n {\n ...curr,\n name,\n },\n ]\n }\n\n // merge all names when prev and current both have the same isTypeOnly set\n if (prevByPath && Array.isArray(prevByPath.name) && Array.isArray(name) && prevByPath.isTypeOnly === curr.isTypeOnly) {\n prevByPath.name = [...new Set([...prevByPath.name, ...name])]\n\n return prev\n }\n\n // no import was found in the source, ignore import\n if (!Array.isArray(name) && name && !hasImportInSource(name)) {\n return prev\n }\n\n return [...prev, curr]\n },\n [] as Array<KubbFile.Import>,\n )\n}\n\n/**\n * Helper to create a file with name and id set\n */\nexport function createFile<TMeta extends object = object>(file: KubbFile.File<TMeta>): KubbFile.ResolvedFile<TMeta> {\n const extname = path.extname(file.baseName) as KubbFile.Extname\n if (!extname) {\n throw new Error(`No extname found for ${file.baseName}`)\n }\n\n const source = file.sources.map((item) => item.value).join('\\n\\n')\n const exports = file.exports?.length ? combineExports(file.exports) : []\n const imports = file.imports?.length && source ? combineImports(file.imports, exports, source) : []\n const sources = file.sources?.length ? combineSources(file.sources) : []\n\n return {\n ...file,\n id: hashObject({ path: file.path }),\n name: trimExtName(file.baseName),\n extname,\n imports: imports,\n exports: exports,\n sources: sources,\n meta: file.meta || ({} as TMeta),\n }\n}\n"],"x_google_ignoreList":[0,1,2,3,4,5,6],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAASA,IAAE,KAAE,KAAE,KAAE;CAAC,IAAIC,OAAE,QAAGD,IAAEE,KAAE,GAAGC,IAAE;AAAC,QAAOD,QAAI,KAAK,IAAED,MAAE,OAAO,OAAOA,KAAE;EAAC,MAAKC;EAAE,UAASC;EAAE,CAAC;;;;;ACA3B,SAASC,IAAE,KAAE,KAAE,KAAE;CAAC,IAAIC,MAAED,IAAE,SAAOE,IAAE;AAAO,KAAGD,QAAI,EAAE,QAAOD,IAAE,GAAGE,IAAE;AAAC,KAAGD,QAAI,EAAE,QAAOE,IAAEH,KAAEE,KAAEE,IAAE;AAAC,OAAM,MAAM,4BAA4B;;;;;ACArM,MAAM,IAAE;CAAC,MAAK,CAAC;CAAE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AI,MAAM,wBAAwB,KAAK,WAAW;CAG1D,MAAM,SAAS,KAAK,QAAQ,KAAK,SAAS,KAAK,MAAM,CAAC,KAAK,OAAO;CAClE,MAAM,4BAAU,KAAK,uEAAS,UAAS,eAAe,KAAK,QAAQ,GAAG,EAAE;CACxE,MAAM,4BAAU,KAAK,uEAAS,WAAU,SAAS,eAAe,KAAK,SAAS,SAAS,OAAO,GAAG,EAAE;CACnG,MAAM,4BAAU,KAAK,uEAAS,UAAS,eAAe,KAAK,QAAQ,GAAG,EAAE;AAExE,QAAO;EACL,GAAG;EACH,IAAI,WAAW,EAAE,MAAM,KAAK,MAAM,CAAC;EACnC,MAAM,YAAY,KAAK,SAAS;EAChC;EACS;EACA;EACA;EACT,MAAM,KAAK,QAAS,EAAE;EACvB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"defineProperty-CspRhtP3.cjs","names":["e","r","n","t","t","i","n","e","r","t","n","r","e","t","a","e","r","i","n","t","r","n","i","e","t","e","n","r","i","a","e","t","n","r","i","a","uniqueBy","exports","isDeepEqual","name","path","trimExtName"],"sources":["../../../node_modules/.pnpm/remeda@2.32.0/node_modules/remeda/dist/lazyDataLastImpl-BDhrIOwR.js","../../../node_modules/.pnpm/remeda@2.32.0/node_modules/remeda/dist/purry-DH9cw9sy.js","../../../node_modules/.pnpm/remeda@2.32.0/node_modules/remeda/dist/utilityEvaluators-DORpnx39.js","../../../node_modules/.pnpm/remeda@2.32.0/node_modules/remeda/dist/pipe-jLehR9-P.js","../../../node_modules/.pnpm/remeda@2.32.0/node_modules/remeda/dist/purryFromLazy-3oywCNIb.js","../../../node_modules/.pnpm/remeda@2.32.0/node_modules/remeda/dist/isDeepEqual-jLo35Woq.js","../../../node_modules/.pnpm/remeda@2.32.0/node_modules/remeda/dist/uniqueBy-C_PxkF_D.js","../src/createFile.ts"],"sourcesContent":["function e(e,t,n){let r=n=>e(n,...t);return n===void 0?r:Object.assign(r,{lazy:n,lazyArgs:t})}export{e as lazyDataLastImpl};\n//# sourceMappingURL=lazyDataLastImpl-BDhrIOwR.js.map","import{lazyDataLastImpl as e}from\"./lazyDataLastImpl-BDhrIOwR.js\";function t(t,n,r){let i=t.length-n.length;if(i===0)return t(...n);if(i===1)return e(t,n,r);throw Error(`Wrong number of arguments`)}export{t as purry};\n//# sourceMappingURL=purry-DH9cw9sy.js.map","const e={done:!0,hasNext:!1},t={done:!1,hasNext:!1},n=()=>e,r=e=>({hasNext:!0,next:e,done:!1});export{t as SKIP_ITEM,n as lazyEmptyEvaluator,r as lazyIdentityEvaluator};\n//# sourceMappingURL=utilityEvaluators-DORpnx39.js.map","import{SKIP_ITEM as e}from\"./utilityEvaluators-DORpnx39.js\";function t(e,...t){let a=e,o=t.map(e=>`lazy`in e?r(e):void 0),s=0;for(;s<t.length;){if(o[s]===void 0||!i(a)){let e=t[s];a=e(a),s+=1;continue}let e=[];for(let n=s;n<t.length;n++){let t=o[n];if(t===void 0||(e.push(t),t.isSingle))break}let r=[];for(let t of a)if(n(t,r,e))break;let{isSingle:c}=e.at(-1);a=c?r[0]:r,s+=e.length}return a}function n(t,r,i){if(i.length===0)return r.push(t),!1;let a=t,o=e,s=!1;for(let[e,t]of i.entries()){let{index:c,items:l}=t;if(l.push(a),o=t(a,c,l),t.index+=1,o.hasNext){if(o.hasMany??!1){for(let t of o.next)if(n(t,r,i.slice(e+1)))return!0;return s}a=o.next}if(!o.hasNext)break;o.done&&(s=!0)}return o.hasNext&&r.push(a),s}function r(e){let{lazy:t,lazyArgs:n}=e,r=t(...n);return Object.assign(r,{isSingle:t.single??!1,index:0,items:[]})}function i(e){return typeof e==`string`||typeof e==`object`&&!!e&&Symbol.iterator in e}export{t as pipe};\n//# sourceMappingURL=pipe-jLehR9-P.js.map","import{pipe as e}from\"./pipe-jLehR9-P.js\";function t(t,n){let r=n.length-t.length;if(r===1){let[r,...i]=n;return e(r,{lazy:t,lazyArgs:i})}if(r===0){let r={lazy:t,lazyArgs:n};return Object.assign(t=>e(t,r),r)}throw Error(`Wrong number of arguments`)}export{t as purryFromLazy};\n//# sourceMappingURL=purryFromLazy-3oywCNIb.js.map","import{purry as e}from\"./purry-DH9cw9sy.js\";function t(...t){return e(n,t)}function n(e,t){if(e===t||Object.is(e,t))return!0;if(typeof e!=`object`||typeof t!=`object`||e===null||t===null||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1;if(Array.isArray(e))return r(e,t);if(e instanceof Map)return i(e,t);if(e instanceof Set)return a(e,t);if(e instanceof Date)return e.getTime()===t.getTime();if(e instanceof RegExp)return e.toString()===t.toString();if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let[r,i]of Object.entries(e))if(!(r in t)||!n(i,t[r]))return!1;return!0}function r(e,t){if(e.length!==t.length)return!1;for(let[r,i]of e.entries())if(!n(i,t[r]))return!1;return!0}function i(e,t){if(e.size!==t.size)return!1;for(let[r,i]of e.entries())if(!t.has(r)||!n(i,t.get(r)))return!1;return!0}function a(e,t){if(e.size!==t.size)return!1;let r=[...t];for(let t of e){let e=!1;for(let[i,a]of r.entries())if(n(t,a)){e=!0,r.splice(i,1);break}if(!e)return!1}return!0}export{t as isDeepEqual};\n//# sourceMappingURL=isDeepEqual-jLo35Woq.js.map","import{SKIP_ITEM as e}from\"./utilityEvaluators-DORpnx39.js\";import{purryFromLazy as t}from\"./purryFromLazy-3oywCNIb.js\";function n(...e){return t(r,e)}function r(t){let n=t,r=new Set;return(t,i,a)=>{let o=n(t,i,a);return r.has(o)?e:(r.add(o),{done:!1,hasNext:!0,next:t})}}export{n as uniqueBy};\n//# sourceMappingURL=uniqueBy-C_PxkF_D.js.map","import type * as KubbFile from './KubbFile.ts'\nimport { trimExtName } from './utils/trimExtName.ts'\nimport { createHash } from 'node:crypto'\nimport path from 'node:path'\nimport { isDeepEqual, uniqueBy } from 'remeda'\nimport { orderBy } from 'natural-orderby'\n\nfunction hashObject(obj: Record<string, unknown>): string {\n const str = JSON.stringify(obj, Object.keys(obj).sort())\n return createHash('sha256').update(str).digest('hex')\n}\n\nexport function combineSources(sources: Array<KubbFile.Source>): Array<KubbFile.Source> {\n return uniqueBy(sources, (obj) => [obj.name, obj.isExportable, obj.isTypeOnly] as const)\n}\n\nexport function combineExports(exports: Array<KubbFile.Export>): Array<KubbFile.Export> {\n return orderBy(exports, [\n (v) => !!Array.isArray(v.name),\n (v) => !v.isTypeOnly,\n (v) => v.path,\n (v) => !!v.name,\n (v) => (Array.isArray(v.name) ? orderBy(v.name) : v.name),\n ]).reduce(\n (prev, curr) => {\n const name = curr.name\n const prevByPath = prev.findLast((imp) => imp.path === curr.path)\n const prevByPathAndIsTypeOnly = prev.findLast((imp) => imp.path === curr.path && isDeepEqual(imp.name, name) && imp.isTypeOnly)\n\n if (prevByPathAndIsTypeOnly) {\n // we already have an export that has the same path but uses `isTypeOnly` (export type ...)\n return prev\n }\n\n const uniquePrev = prev.findLast(\n (imp) => imp.path === curr.path && isDeepEqual(imp.name, name) && imp.isTypeOnly === curr.isTypeOnly && imp.asAlias === curr.asAlias,\n )\n\n // we already have an item that was unique enough or name field is empty or prev asAlias is set but current has no changes\n if (uniquePrev || (Array.isArray(name) && !name.length) || (prevByPath?.asAlias && !curr.asAlias)) {\n return prev\n }\n\n if (!prevByPath) {\n return [\n ...prev,\n {\n ...curr,\n name: Array.isArray(name) ? [...new Set(name)] : name,\n },\n ]\n }\n\n // merge all names when prev and current both have the same isTypeOnly set\n if (prevByPath && Array.isArray(prevByPath.name) && Array.isArray(curr.name) && prevByPath.isTypeOnly === curr.isTypeOnly) {\n prevByPath.name = [...new Set([...prevByPath.name, ...curr.name])]\n\n return prev\n }\n\n return [...prev, curr]\n },\n [] as Array<KubbFile.Export>,\n )\n}\n\nexport function combineImports(imports: Array<KubbFile.Import>, exports: Array<KubbFile.Export>, source?: string): Array<KubbFile.Import> {\n return orderBy(imports, [\n (v) => !!Array.isArray(v.name),\n (v) => !v.isTypeOnly,\n (v) => v.path,\n (v) => !!v.name,\n (v) => (Array.isArray(v.name) ? orderBy(v.name) : v.name),\n ]).reduce(\n (prev, curr) => {\n let name = Array.isArray(curr.name) ? [...new Set(curr.name)] : curr.name\n\n const hasImportInSource = (importName: string) => {\n if (!source) {\n return true\n }\n\n const checker = (name?: string) => {\n return name && source.includes(name)\n }\n\n return checker(importName) || exports.some(({ name }) => (Array.isArray(name) ? name.some(checker) : checker(name)))\n }\n\n if (curr.path === curr.root) {\n // root and path are the same file, remove the \"./\" import\n return prev\n }\n\n // merge all names and check if the importName is being used in the generated source and if not filter those imports out\n if (Array.isArray(name)) {\n name = name.filter((item) => (typeof item === 'string' ? hasImportInSource(item) : hasImportInSource(item.propertyName)))\n }\n\n const prevByPath = prev.findLast((imp) => imp.path === curr.path && imp.isTypeOnly === curr.isTypeOnly)\n const uniquePrev = prev.findLast((imp) => imp.path === curr.path && isDeepEqual(imp.name, name) && imp.isTypeOnly === curr.isTypeOnly)\n const prevByPathNameAndIsTypeOnly = prev.findLast((imp) => imp.path === curr.path && isDeepEqual(imp.name, name) && imp.isTypeOnly)\n\n if (prevByPathNameAndIsTypeOnly) {\n // we already have an export that has the same path but uses `isTypeOnly` (import type ...)\n return prev\n }\n\n // already unique enough or name is empty\n if (uniquePrev || (Array.isArray(name) && !name.length)) {\n return prev\n }\n\n // new item, append name\n if (!prevByPath) {\n return [\n ...prev,\n {\n ...curr,\n name,\n },\n ]\n }\n\n // merge all names when prev and current both have the same isTypeOnly set\n if (prevByPath && Array.isArray(prevByPath.name) && Array.isArray(name) && prevByPath.isTypeOnly === curr.isTypeOnly) {\n prevByPath.name = [...new Set([...prevByPath.name, ...name])]\n\n return prev\n }\n\n // no import was found in the source, ignore import\n if (!Array.isArray(name) && name && !hasImportInSource(name)) {\n return prev\n }\n\n return [...prev, curr]\n },\n [] as Array<KubbFile.Import>,\n )\n}\n\n/**\n * Helper to create a file with name and id set\n */\nexport function createFile<TMeta extends object = object>(file: KubbFile.File<TMeta>): KubbFile.ResolvedFile<TMeta> {\n const extname = path.extname(file.baseName) as KubbFile.Extname\n if (!extname) {\n throw new Error(`No extname found for ${file.baseName}`)\n }\n\n const source = file.sources.map((item) => item.value).join('\\n\\n')\n const exports = file.exports?.length ? combineExports(file.exports) : []\n const imports = file.imports?.length && source ? combineImports(file.imports, exports, source) : []\n const sources = file.sources?.length ? combineSources(file.sources) : []\n\n return {\n ...file,\n id: hashObject({ path: file.path }),\n name: trimExtName(file.baseName),\n extname,\n imports: imports,\n exports: exports,\n sources: sources,\n meta: file.meta || ({} as TMeta),\n }\n}\n"],"x_google_ignoreList":[0,1,2,3,4,5,6],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAASA,IAAE,KAAE,KAAE,KAAE;CAAC,IAAIC,OAAE,QAAGD,IAAEE,KAAE,GAAGC,IAAE;AAAC,QAAOD,QAAI,KAAK,IAAED,MAAE,OAAO,OAAOA,KAAE;EAAC,MAAKC;EAAE,UAASC;EAAE,CAAC;;;;;ACA3B,SAASC,IAAE,KAAE,KAAE,KAAE;CAAC,IAAIC,MAAED,IAAE,SAAOE,IAAE;AAAO,KAAGD,QAAI,EAAE,QAAOD,IAAE,GAAGE,IAAE;AAAC,KAAGD,QAAI,EAAE,QAAOE,IAAEH,KAAEE,KAAEE,IAAE;AAAC,OAAM,MAAM,4BAA4B;;;;;ACArM,MAAM,IAAE;CAAC,MAAK,CAAC;CAAE,SAAQ,CAAC;CAAE,EAACC,MAAE;CAAC,MAAK,CAAC;CAAE,SAAQ,CAAC;CAAE,EAACC,YAAM,GAAEC,OAAE,SAAI;CAAC,SAAQ,CAAC;CAAE,MAAKC;CAAE,MAAK,CAAC;CAAE;;;;ACAjC,SAASC,IAAE,KAAE,GAAGA,KAAE;CAAC,IAAIC,MAAEC,KAAE,IAAEF,IAAE,KAAI,QAAG,UAASE,MAAEC,IAAED,IAAE,GAAC,KAAK,EAAE,EAAC,IAAE;AAAE,QAAK,IAAEF,IAAE,SAAQ;AAAC,MAAG,EAAE,OAAK,KAAK,KAAG,CA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,MAAMI,gCAAY,KAAK,SAAS;EAChC;EACS;EACT,SAASJ;EACA;EACT,MAAM,KAAK,QAAS,EAAE;EACvB"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { EventEmitter as NodeEventEmitter } from 'node:events'
|
|
2
|
-
|
|
3
|
-
export class EventEmitter<TEvents extends Record<string, any>> {
|
|
4
|
-
constructor(maxListener = 100) {
|
|
5
|
-
this.#emitter.setMaxListeners(maxListener)
|
|
6
|
-
}
|
|
7
|
-
#emitter = new NodeEventEmitter()
|
|
8
|
-
|
|
9
|
-
emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArg: TEvents[TEventName]): void {
|
|
10
|
-
this.#emitter.emit(eventName, ...(eventArg as any))
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void {
|
|
14
|
-
this.#emitter.on(eventName, handler as any)
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
onOnce<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArgs: TEvents[TEventName]) => void): void {
|
|
18
|
-
const wrapper = (...args: TEvents[TEventName]) => {
|
|
19
|
-
this.off(eventName, wrapper)
|
|
20
|
-
handler(...args)
|
|
21
|
-
}
|
|
22
|
-
this.on(eventName, wrapper)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
off<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void {
|
|
26
|
-
this.#emitter.off(eventName, handler as any)
|
|
27
|
-
}
|
|
28
|
-
removeAll(): void {
|
|
29
|
-
this.#emitter.removeAllListeners()
|
|
30
|
-
}
|
|
31
|
-
}
|