@kubb/core 2.0.0-beta.13 → 2.0.0-beta.14

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 (77) hide show
  1. package/dist/chunk-35FDNG5F.cjs +71 -0
  2. package/dist/chunk-35FDNG5F.cjs.map +1 -0
  3. package/dist/chunk-7CNPSL5M.js +85 -0
  4. package/dist/chunk-7CNPSL5M.js.map +1 -0
  5. package/dist/{chunk-SX2AYX5F.js → chunk-DKYWBKNH.js} +2 -2
  6. package/dist/chunk-EZSRGYAY.js +128 -0
  7. package/dist/chunk-EZSRGYAY.js.map +1 -0
  8. package/dist/{chunk-77QZQ377.cjs → chunk-GBX7KRCX.cjs} +12 -5
  9. package/dist/chunk-GBX7KRCX.cjs.map +1 -0
  10. package/dist/{chunk-FOQFLMOC.js → chunk-ICRPOCV4.cjs} +400 -446
  11. package/dist/chunk-ICRPOCV4.cjs.map +1 -0
  12. package/dist/chunk-LAS7UYTK.cjs +129 -0
  13. package/dist/chunk-LAS7UYTK.cjs.map +1 -0
  14. package/dist/chunk-LJHT3DNH.js +67 -0
  15. package/dist/chunk-LJHT3DNH.js.map +1 -0
  16. package/dist/{chunk-I7UUR5MZ.cjs → chunk-MM42A6GN.cjs} +3 -3
  17. package/dist/{chunk-I7UUR5MZ.cjs.map → chunk-MM42A6GN.cjs.map} +1 -1
  18. package/dist/{chunk-L6F5QUH2.js → chunk-SRGTC4FJ.js} +2 -2
  19. package/dist/{chunk-PY7I7OEN.cjs → chunk-ST7GHHSU.cjs} +34 -22
  20. package/dist/chunk-ST7GHHSU.cjs.map +1 -0
  21. package/dist/{chunk-ABFPJZJL.cjs → chunk-U4C2WTCI.cjs} +5 -5
  22. package/dist/{chunk-WFDR7OMY.js → chunk-UIQUKFF4.js} +9 -2
  23. package/dist/chunk-UIQUKFF4.js.map +1 -0
  24. package/dist/{chunk-6N4JBFFS.js → chunk-WTSDXEWD.js} +4 -12
  25. package/dist/chunk-WTSDXEWD.js.map +1 -0
  26. package/dist/fs.cjs +9 -8
  27. package/dist/fs.cjs.map +1 -1
  28. package/dist/fs.d.cts +1 -1
  29. package/dist/fs.d.ts +1 -1
  30. package/dist/fs.js +3 -2
  31. package/dist/fs.js.map +1 -1
  32. package/dist/index.cjs +955 -244
  33. package/dist/index.cjs.map +1 -1
  34. package/dist/index.d.cts +17 -15
  35. package/dist/index.d.ts +17 -15
  36. package/dist/index.js +135 -83
  37. package/dist/index.js.map +1 -1
  38. package/dist/logger.cjs +7 -6
  39. package/dist/logger.d.cts +1 -0
  40. package/dist/logger.d.ts +1 -0
  41. package/dist/logger.js +3 -2
  42. package/dist/transformers.cjs +21 -21
  43. package/dist/transformers.js +5 -5
  44. package/dist/utils.cjs +22 -19
  45. package/dist/utils.cjs.map +1 -1
  46. package/dist/utils.d.cts +0 -1
  47. package/dist/utils.d.ts +0 -1
  48. package/dist/utils.js +14 -4
  49. package/dist/utils.js.map +1 -1
  50. package/dist/{write-46ytbnu9.d.cts → write-A6VgHkYA.d.cts} +4 -1
  51. package/dist/{write-46ytbnu9.d.ts → write-A6VgHkYA.d.ts} +4 -1
  52. package/package.json +9 -8
  53. package/src/FileManager.ts +60 -57
  54. package/src/PluginManager.ts +11 -18
  55. package/src/build.ts +57 -32
  56. package/src/fs/clean.ts +2 -2
  57. package/src/fs/read.ts +1 -0
  58. package/src/fs/write.ts +40 -24
  59. package/src/logger.ts +10 -0
  60. package/src/utils/index.ts +0 -2
  61. package/dist/Queue-2-6pMcCx.d.cts +0 -32
  62. package/dist/Queue-2-6pMcCx.d.ts +0 -32
  63. package/dist/chunk-56YH3VX6.js +0 -239
  64. package/dist/chunk-56YH3VX6.js.map +0 -1
  65. package/dist/chunk-6N4JBFFS.js.map +0 -1
  66. package/dist/chunk-72O327DC.cjs +0 -247
  67. package/dist/chunk-72O327DC.cjs.map +0 -1
  68. package/dist/chunk-77QZQ377.cjs.map +0 -1
  69. package/dist/chunk-FOQFLMOC.js.map +0 -1
  70. package/dist/chunk-PY7I7OEN.cjs.map +0 -1
  71. package/dist/chunk-WFDR7OMY.js.map +0 -1
  72. package/dist/chunk-Z7XZQBAK.cjs +0 -2339
  73. package/dist/chunk-Z7XZQBAK.cjs.map +0 -1
  74. package/src/utils/Queue.ts +0 -110
  75. /package/dist/{chunk-SX2AYX5F.js.map → chunk-DKYWBKNH.js.map} +0 -0
  76. /package/dist/{chunk-L6F5QUH2.js.map → chunk-SRGTC4FJ.js.map} +0 -0
  77. /package/dist/{chunk-ABFPJZJL.cjs.map → chunk-U4C2WTCI.cjs.map} +0 -0
@@ -1,8 +1,9 @@
1
1
  /* eslint-disable @typescript-eslint/ban-types, @typescript-eslint/no-unsafe-argument */
2
2
 
3
+ import PQueue from 'p-queue'
4
+
3
5
  import { transformReservedWord } from './transformers/transformReservedWord.ts'
4
6
  import { EventEmitter } from './utils/EventEmitter.ts'
5
- import { Queue } from './utils/Queue.ts'
6
7
  import { setUniqueName } from './utils/uniqueName.ts'
7
8
  import { ValidationPluginError } from './errors.ts'
8
9
  import { FileManager } from './FileManager.ts'
@@ -29,7 +30,6 @@ import type {
29
30
  ResolveNameParams,
30
31
  ResolvePathParams,
31
32
  } from './types.ts'
32
- import type { QueueJob } from './utils/Queue.ts'
33
33
 
34
34
  type RequiredPluginLifecycle = Required<PluginLifecycle>
35
35
 
@@ -64,11 +64,7 @@ type Options = {
64
64
  /**
65
65
  * Task for the FileManager
66
66
  */
67
- task: QueueJob<KubbFile.ResolvedFile>
68
- /**
69
- * Timeout between writes in the FileManager
70
- */
71
- writeTimeout?: number
67
+ task: (file: KubbFile.ResolvedFile) => Promise<KubbFile.ResolvedFile>
72
68
  }
73
69
 
74
70
  type Events = {
@@ -82,7 +78,6 @@ export class PluginManager {
82
78
  readonly fileManager: FileManager
83
79
  readonly events: EventEmitter<Events> = new EventEmitter()
84
80
 
85
- readonly queue: Queue
86
81
  readonly config: KubbConfig
87
82
 
88
83
  readonly executed: Array<Executer> = []
@@ -92,11 +87,13 @@ export class PluginManager {
92
87
  readonly #usedPluginNames: Record<string, number> = {}
93
88
  readonly #promiseManager: PromiseManager
94
89
 
90
+ readonly queue: PQueue
91
+
95
92
  constructor(config: KubbConfig, options: Options) {
96
93
  this.config = config
97
94
  this.logger = options.logger
98
- this.queue = new Queue(100, this.logger.logLevel === LogLevel.debug)
99
- this.fileManager = new FileManager({ task: options.task, queue: this.queue, timeout: options.writeTimeout })
95
+ this.queue = new PQueue({ concurrency: 1 })
96
+ this.fileManager = new FileManager({ task: options.task, queue: this.queue })
100
97
  this.#promiseManager = new PromiseManager({ nullCheck: (state: SafeParseResult<'resolveName'> | null) => !!state?.result })
101
98
 
102
99
  const plugins = config.plugins || []
@@ -130,7 +127,7 @@ export class PluginManager {
130
127
  })
131
128
 
132
129
  if (paths && paths?.length > 1 && this.logger.logLevel === LogLevel.debug) {
133
- this.logger.warn(
130
+ this.logger.debug(
134
131
  `Cannot return a path where the 'pluginKey' ${params.pluginKey ? JSON.stringify(params.pluginKey) : '"'} is not unique enough\n\nPaths: ${
135
132
  JSON.stringify(paths, undefined, 2)
136
133
  }\n\nFalling back on the first item.\n`,
@@ -153,7 +150,7 @@ export class PluginManager {
153
150
  })
154
151
 
155
152
  if (names && names?.length > 1 && this.logger.logLevel === LogLevel.debug) {
156
- this.logger.warn(
153
+ this.logger.debug(
157
154
  `Cannot return a name where the 'pluginKey' ${params.pluginKey ? JSON.stringify(params.pluginKey) : '"'} is not unique enough\n\nNames: ${
158
155
  JSON.stringify(names, undefined, 2)
159
156
  }\n\nFalling back on the first item.\n`,
@@ -442,9 +439,9 @@ export class PluginManager {
442
439
 
443
440
  if (this.logger.logLevel === LogLevel.debug) {
444
441
  if (corePlugin) {
445
- this.logger.warn(`No hook '${hookName}' for pluginKey '${JSON.stringify(pluginKey)}' found, falling back on the '@kubb/core' plugin`)
442
+ this.logger.debug(`No hook '${hookName}' for pluginKey '${JSON.stringify(pluginKey)}' found, falling back on the '@kubb/core' plugin`)
446
443
  } else {
447
- this.logger.warn(`No hook '${hookName}' for pluginKey '${JSON.stringify(pluginKey)}' found, no fallback found in the '@kubb/core' plugin`)
444
+ this.logger.debug(`No hook '${hookName}' for pluginKey '${JSON.stringify(pluginKey)}' found, no fallback found in the '@kubb/core' plugin`)
448
445
  }
449
446
  }
450
447
 
@@ -594,10 +591,6 @@ export class PluginManager {
594
591
 
595
592
  const key = [plugin.name, usedPluginNames[plugin.name]].filter(Boolean) as [typeof plugin.name, string]
596
593
 
597
- if (plugin.name !== 'core' && usedPluginNames[plugin.name]! >= 2) {
598
- pluginManager.logger.warn('Using multiple of the same plugin is an experimental feature')
599
- }
600
-
601
594
  // default transform
602
595
  if (!plugin.transform) {
603
596
  plugin.transform = function transform(code) {
package/src/build.ts CHANGED
@@ -12,7 +12,6 @@ import { isPromise } from './PromiseManager.ts'
12
12
  import type { KubbFile } from './FileManager.ts'
13
13
  import type { Logger } from './logger.ts'
14
14
  import type { KubbPlugin, PluginContext, PluginParameter, TransformResult } from './types.ts'
15
- import type { QueueJob } from './utils/Queue.ts'
16
15
 
17
16
  type BuildOptions = {
18
17
  config: PluginContext['config']
@@ -42,6 +41,7 @@ async function transformReducer(
42
41
 
43
42
  async function setup(options: BuildOptions): Promise<PluginManager> {
44
43
  const { config, logger = createLogger({ logLevel: LogLevel.silent }) } = options
44
+ let count = 0
45
45
 
46
46
  try {
47
47
  if (isInputPath(config) && !new URLPath(config.input.path).isURL) {
@@ -62,48 +62,53 @@ async function setup(options: BuildOptions): Promise<PluginManager> {
62
62
  await clean(config.output.path)
63
63
  }
64
64
 
65
- const queueTask = async (file: KubbFile.File) => {
65
+ const task = async (file: KubbFile.ResolvedFile): Promise<KubbFile.ResolvedFile> => {
66
66
  const { path } = file
67
67
 
68
- let code: string | null = FileManager.getSource(file)
68
+ let source: string | null = FileManager.getSource(file)
69
69
 
70
70
  const { result: loadedResult } = await pluginManager.hookFirst({
71
71
  hookName: 'load',
72
72
  parameters: [path],
73
73
  })
74
74
  if (loadedResult && isPromise(loadedResult)) {
75
- code = await loadedResult
75
+ source = await loadedResult
76
76
  }
77
77
  if (loadedResult && !isPromise(loadedResult)) {
78
- code = loadedResult
78
+ source = loadedResult
79
79
  }
80
80
 
81
- if (code) {
82
- const transformedCode = await pluginManager.hookReduceArg0({
81
+ if (source) {
82
+ source = await pluginManager.hookReduceArg0({
83
83
  hookName: 'transform',
84
- parameters: [code, path],
84
+ parameters: [source, path],
85
85
  reduce: transformReducer,
86
86
  })
87
87
 
88
88
  if (config.output.write || config.output.write === undefined) {
89
89
  if (file.meta?.pluginKey) {
90
90
  // run only for pluginKey defined in the meta of the file
91
- return pluginManager.hookForPlugin({
91
+ await pluginManager.hookForPlugin({
92
92
  pluginKey: file.meta?.pluginKey,
93
93
  hookName: 'writeFile',
94
- parameters: [transformedCode, path],
94
+ parameters: [source, path],
95
95
  })
96
96
  }
97
97
 
98
- return pluginManager.hookFirst({
98
+ await pluginManager.hookFirst({
99
99
  hookName: 'writeFile',
100
- parameters: [transformedCode, path],
100
+ parameters: [source, path],
101
101
  })
102
102
  }
103
103
  }
104
+
105
+ return {
106
+ ...file,
107
+ source: source || '',
108
+ }
104
109
  }
105
110
 
106
- const pluginManager = new PluginManager(config, { logger, task: queueTask as QueueJob<KubbFile.ResolvedFile>, writeTimeout: 0 })
111
+ const pluginManager = new PluginManager(config, { logger, task })
107
112
 
108
113
  pluginManager.on('execute', (executer) => {
109
114
  const { hookName, parameters, plugin } = executer
@@ -111,40 +116,60 @@ async function setup(options: BuildOptions): Promise<PluginManager> {
111
116
  if (hookName === 'writeFile' && logger.spinner) {
112
117
  const [code] = parameters as PluginParameter<'writeFile'>
113
118
 
114
- if (logger.logLevel === LogLevel.info) {
115
- logger.spinner.start(`💾 Writing`)
116
- }
117
-
118
119
  if (logger.logLevel === LogLevel.debug) {
119
- logger.info(`PluginKey ${c.dim(JSON.stringify(plugin.key))} \nwith source\n\n${code}`)
120
+ logger.debug(`PluginKey ${c.dim(JSON.stringify(plugin.key))} \nwith source\n\n${code}`)
120
121
  }
121
122
  }
122
123
  })
123
124
 
124
- pluginManager.on('executed', (executer) => {
125
- const { hookName, plugin, output, parameters } = executer
126
- const messsage = `${randomCliColour(plugin.name)} Executing ${hookName}`
125
+ pluginManager.queue.on('add', () => {
126
+ if (logger.logLevel !== LogLevel.info) {
127
+ return
128
+ }
127
129
 
128
- if (logger.logLevel === LogLevel.info && logger.spinner) {
129
- if (hookName === 'writeFile') {
130
- const [_code, path] = parameters as PluginParameter<'writeFile'>
130
+ if (logger.spinner && count === 0) {
131
+ logger.spinner?.start(`💾 Writing`)
132
+ }
133
+ })
131
134
 
132
- logger.spinner.suffixText = c.dim(path)
133
- } else {
134
- logger.spinner.suffixText = messsage
135
- }
135
+ pluginManager.queue.on('active', () => {
136
+ if (logger.logLevel !== LogLevel.info) {
137
+ return
136
138
  }
137
139
 
140
+ if (logger.spinner && pluginManager.queue.size > 0) {
141
+ const text = `Item: ${count} Size: ${pluginManager.queue.size} Pending: ${pluginManager.queue.pending}`
142
+
143
+ logger.spinner.suffixText = c.dim(text)
144
+ }
145
+ ;++count
146
+ })
147
+
148
+ pluginManager.queue.on('completed', () => {
149
+ if (logger.logLevel !== LogLevel.info) {
150
+ return
151
+ }
152
+
153
+ if (logger.spinner) {
154
+ const text = `Item: ${count} Size: ${pluginManager.queue.size} Pending: ${pluginManager.queue.pending}`
155
+
156
+ logger.spinner.suffixText = c.dim(text)
157
+ }
158
+ })
159
+
160
+ pluginManager.on('executed', (executer) => {
161
+ const { hookName, plugin, output, parameters } = executer
162
+
138
163
  if (logger.logLevel === LogLevel.debug) {
139
- logger.info(messsage)
140
164
  const logs = [
165
+ `${randomCliColour(plugin.name)} Executing ${hookName}`,
141
166
  parameters && `${c.bgWhite(`Parameters`)} ${randomCliColour(plugin.name)} ${hookName}`,
142
167
  JSON.stringify(parameters, undefined, 2),
143
168
  output && `${c.bgWhite('Output')} ${randomCliColour(plugin.name)} ${hookName}`,
144
169
  output,
145
170
  ].filter(Boolean)
146
171
 
147
- console.log(logs.join('\n'))
172
+ logger.debug(logs.join('\n'))
148
173
  }
149
174
  })
150
175
 
@@ -163,7 +188,7 @@ export async function build(options: BuildOptions): Promise<BuildOutput> {
163
188
 
164
189
  await pluginManager.hookParallel({ hookName: 'buildEnd' })
165
190
 
166
- if (!fileManager.isExecuting && logger.spinner) {
191
+ if (logger.logLevel === LogLevel.info && logger.spinner) {
167
192
  logger.spinner.suffixText = ''
168
193
  logger.spinner.succeed(`💾 Writing completed`)
169
194
  }
@@ -184,7 +209,7 @@ export async function safeBuild(options: BuildOptions): Promise<BuildOutput> {
184
209
 
185
210
  await pluginManager.hookParallel({ hookName: 'buildEnd' })
186
211
 
187
- if (!fileManager.isExecuting && logger.spinner) {
212
+ if (logger.logLevel === LogLevel.info && logger.spinner) {
188
213
  logger.spinner.suffixText = ''
189
214
  logger.spinner.succeed(`💾 Writing completed`)
190
215
  }
package/src/fs/clean.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { remove } from 'fs-extra'
1
+ import fs from 'fs-extra'
2
2
 
3
3
  export async function clean(path: string): Promise<void> {
4
- return remove(path)
4
+ return fs.remove(path)
5
5
  }
package/src/fs/read.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { basename, extname, relative } from 'node:path'
2
2
 
3
3
  import fs from 'fs-extra'
4
+
4
5
  import { switcher } from 'js-runtime'
5
6
 
6
7
  function slash(path: string, platform: 'windows' | 'mac' | 'linux' = 'linux') {
package/src/fs/write.ts CHANGED
@@ -1,20 +1,14 @@
1
- import { dirname, resolve } from 'node:path'
1
+ import { resolve } from 'node:path'
2
2
 
3
3
  import fs from 'fs-extra'
4
4
  import { switcher } from 'js-runtime'
5
5
 
6
- async function saveCreateDirectory(path: string): Promise<void> {
7
- // resolve the full path and get just the directory, ignoring the file and extension
8
- const passedPath = dirname(resolve(path))
9
- // make the directory, recursively. Theoretically, if every directory in the path exists, this won't do anything.
10
- await fs.mkdir(passedPath, { recursive: true })
11
- }
6
+ type Options = { sanity?: boolean }
12
7
 
13
8
  const writer = switcher(
14
9
  {
15
- node: async (path: string, data: string) => {
10
+ node: async (path: string, data: string, { sanity }: Options) => {
16
11
  try {
17
- await fs.stat(resolve(path))
18
12
  const oldContent = await fs.readFile(resolve(path), { encoding: 'utf-8' })
19
13
  if (oldContent?.toString() === data?.toString()) {
20
14
  return
@@ -23,30 +17,36 @@ const writer = switcher(
23
17
  /* empty */
24
18
  }
25
19
 
26
- await saveCreateDirectory(path)
27
- await fs.writeFile(resolve(path), data, { encoding: 'utf-8' })
20
+ await fs.outputFile(resolve(path), data, { encoding: 'utf-8' })
21
+
22
+ if (sanity) {
23
+ const savedData = await fs.readFile(resolve(path), { encoding: 'utf-8' })
28
24
 
29
- const savedData = await fs.readFile(resolve(path), { encoding: 'utf-8' })
25
+ if (savedData?.toString() !== data?.toString()) {
26
+ throw new Error(`Sanity check failed for ${path}\n\nData[${data.length}]:\n${data}\n\nSaved[${savedData.length}]:\n${savedData}\n`)
27
+ }
30
28
 
31
- if (savedData?.toString() !== data?.toString()) {
32
- throw new Error(`Sanity check failed for ${path}\n\nData[${data.length}]:\n${data}\n\nSaved[${savedData.length}]:\n${savedData}\n`)
29
+ return savedData
33
30
  }
34
31
 
35
- return savedData
32
+ return data
36
33
  },
37
- bun: async (path: string, data: string) => {
34
+ bun: async (path: string, data: string, { sanity }: Options) => {
38
35
  try {
39
- await saveCreateDirectory(path)
40
36
  await Bun.write(resolve(path), data)
41
37
 
42
- const file = Bun.file(resolve(path))
43
- const savedData = await file.text()
38
+ if (sanity) {
39
+ const file = Bun.file(resolve(path))
40
+ const savedData = await file.text()
44
41
 
45
- if (savedData?.toString() !== data?.toString()) {
46
- throw new Error(`Sanity check failed for ${path}\n\nData[${data.length}]:\n${data}\n\nSaved[${savedData.length}]:\n${savedData}\n`)
42
+ if (savedData?.toString() !== data?.toString()) {
43
+ throw new Error(`Sanity check failed for ${path}\n\nData[${data.length}]:\n${data}\n\nSaved[${savedData.length}]:\n${savedData}\n`)
44
+ }
45
+
46
+ return savedData
47
47
  }
48
48
 
49
- return savedData
49
+ return data
50
50
  } catch (e) {
51
51
  console.log(e, resolve(path))
52
52
  }
@@ -55,9 +55,25 @@ const writer = switcher(
55
55
  'node',
56
56
  )
57
57
 
58
- export async function write(data: string, path: string): Promise<string | undefined> {
58
+ export async function write(data: string, path: string, options: Options = {}): Promise<string | undefined> {
59
59
  if (data.trim() === '') {
60
60
  return undefined
61
61
  }
62
- return writer(path, data.trim())
62
+ return writer(path, data.trim(), options)
63
+ }
64
+
65
+ export async function writeLog(data: string): Promise<string | undefined> {
66
+ if (data.trim() === '') {
67
+ return undefined
68
+ }
69
+ const path = resolve(process.cwd(), 'kubb-log.log')
70
+ let previousLogs = ''
71
+
72
+ try {
73
+ previousLogs = await fs.readFile(resolve(path), { encoding: 'utf-8' })
74
+ } catch (_err) {
75
+ /* empty */
76
+ }
77
+
78
+ return writer(path, [previousLogs, data.trim()].filter(Boolean).join('\n\n\n'), { sanity: false })
63
79
  }
package/src/logger.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  import seedrandom from 'seedrandom'
2
2
  import c, { createColors } from 'tinyrainbow'
3
3
 
4
+ import { writeLog } from './fs/write.ts'
5
+
4
6
  import type { Ora } from 'ora'
5
7
  import type { Formatter } from 'tinyrainbow'
6
8
 
@@ -22,6 +24,7 @@ export type Logger = {
22
24
  error: (message: string | null) => void
23
25
  info: (message: string | null) => void
24
26
  warn: (message: string | null) => void
27
+ debug: (message: string | null) => Promise<void>
25
28
  spinner?: Ora
26
29
  logs: string[]
27
30
  }
@@ -61,6 +64,12 @@ export function createLogger({ logLevel, name, spinner }: Props): Logger {
61
64
  }
62
65
  }
63
66
 
67
+ const debug: Logger['debug'] = async (message) => {
68
+ if (message) {
69
+ await writeLog(message)
70
+ }
71
+ }
72
+
64
73
  const logger: Logger = {
65
74
  name,
66
75
  logLevel,
@@ -68,6 +77,7 @@ export function createLogger({ logLevel, name, spinner }: Props): Logger {
68
77
  error,
69
78
  warn,
70
79
  info,
80
+ debug,
71
81
  spinner,
72
82
  logs,
73
83
  }
@@ -1,8 +1,6 @@
1
1
  export type { FunctionParamsAST } from './FunctionParams.ts'
2
2
  export { FunctionParams } from './FunctionParams.ts'
3
3
  export { isPromise, isPromiseFulfilledResult, isPromiseRejectedResult } from './promise.ts'
4
- export type { QueueJob } from './Queue.ts'
5
- export { Queue } from './Queue.ts'
6
4
  export { renderTemplate } from './renderTemplate.ts'
7
5
  export { timeout } from './timeout.ts'
8
6
  export { getUniqueName, setUniqueName } from './uniqueName.ts'
@@ -1,32 +0,0 @@
1
- declare class EventEmitter<TEvents extends Record<string, any>> {
2
- #private;
3
- constructor();
4
- emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArg: TEvents[TEventName]): void;
5
- on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
6
- off<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
7
- removeAll(): void;
8
- }
9
-
10
- type QueueJob<T = unknown> = {
11
- (...args: unknown[]): Promise<T | void>;
12
- };
13
- type RunOptions = {
14
- controller?: AbortController;
15
- name?: string;
16
- description?: string;
17
- };
18
- type Events = {
19
- jobDone: [result: unknown];
20
- jobFailed: [error: Error];
21
- };
22
- declare class Queue {
23
- #private;
24
- readonly eventEmitter: EventEmitter<Events>;
25
- constructor(maxParallel: number, debug?: boolean);
26
- run<T>(job: QueueJob<T>, options?: RunOptions): Promise<T>;
27
- runSync<T>(job: QueueJob<T>, options?: RunOptions): void;
28
- get hasJobs(): boolean;
29
- get count(): number;
30
- }
31
-
32
- export { EventEmitter as E, Queue as Q, type QueueJob as a };
@@ -1,32 +0,0 @@
1
- declare class EventEmitter<TEvents extends Record<string, any>> {
2
- #private;
3
- constructor();
4
- emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArg: TEvents[TEventName]): void;
5
- on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
6
- off<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
7
- removeAll(): void;
8
- }
9
-
10
- type QueueJob<T = unknown> = {
11
- (...args: unknown[]): Promise<T | void>;
12
- };
13
- type RunOptions = {
14
- controller?: AbortController;
15
- name?: string;
16
- description?: string;
17
- };
18
- type Events = {
19
- jobDone: [result: unknown];
20
- jobFailed: [error: Error];
21
- };
22
- declare class Queue {
23
- #private;
24
- readonly eventEmitter: EventEmitter<Events>;
25
- constructor(maxParallel: number, debug?: boolean);
26
- run<T>(job: QueueJob<T>, options?: RunOptions): Promise<T>;
27
- runSync<T>(job: QueueJob<T>, options?: RunOptions): void;
28
- get hasJobs(): boolean;
29
- get count(): number;
30
- }
31
-
32
- export { EventEmitter as E, Queue as Q, type QueueJob as a };