@kubb/core 3.0.0-alpha.9 → 3.0.0-beta.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 +14 -5
- package/dist/{FileManager-B0GJlthB.d.cts → FileManager-C9aZTwst.d.ts} +94 -77
- package/dist/{FileManager-BFycBDqG.d.ts → FileManager-ibNoWwHN.d.cts} +94 -77
- package/dist/chunk-2EU7DMPM.js +2 -3
- package/dist/chunk-2EU7DMPM.js.map +1 -1
- package/dist/{chunk-DID47EQD.cjs → chunk-2TOEDZ2U.cjs} +6 -7
- package/dist/chunk-2TOEDZ2U.cjs.map +1 -0
- package/dist/{chunk-A6PCLWEY.cjs → chunk-4GJEWGQN.cjs} +30 -31
- package/dist/chunk-4GJEWGQN.cjs.map +1 -0
- package/dist/{chunk-SEH6NUCX.cjs → chunk-72BWXKV4.cjs} +10 -10
- package/dist/chunk-72BWXKV4.cjs.map +1 -0
- package/dist/{chunk-4X5FFJPJ.js → chunk-BQXM32UO.js} +11 -16
- package/dist/chunk-BQXM32UO.js.map +1 -0
- package/dist/{chunk-27CPVXAT.js → chunk-DXGMSPTW.js} +174 -231
- package/dist/chunk-DXGMSPTW.js.map +1 -0
- package/dist/{chunk-SCR3LUXT.js → chunk-E6CN2CZC.js} +38 -27
- package/dist/chunk-E6CN2CZC.js.map +1 -0
- package/dist/chunk-HBQM723K.js +12 -26
- package/dist/chunk-HBQM723K.js.map +1 -1
- package/dist/{chunk-5E2I6KH4.cjs → chunk-KXT7F2WS.cjs} +54 -37
- package/dist/chunk-KXT7F2WS.cjs.map +1 -0
- package/dist/{chunk-IPZQXBA2.cjs → chunk-MVWRVN66.cjs} +57 -34
- package/dist/chunk-MVWRVN66.cjs.map +1 -0
- package/dist/{chunk-5IGANEGE.cjs → chunk-SQBOUPF4.cjs} +268 -301
- package/dist/chunk-SQBOUPF4.cjs.map +1 -0
- package/dist/index.cjs +223 -241
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -6
- package/dist/index.d.ts +4 -6
- package/dist/index.js +106 -148
- package/dist/index.js.map +1 -1
- package/dist/{logger-BWFeedRk.d.cts → logger-DvbHXjIO.d.cts} +10 -8
- package/dist/{logger-BWFeedRk.d.ts → logger-DvbHXjIO.d.ts} +10 -8
- package/dist/logger.cjs +25 -14
- package/dist/logger.cjs.map +1 -1
- package/dist/logger.d.cts +1 -1
- package/dist/logger.d.ts +1 -1
- package/dist/logger.js +3 -13
- package/dist/logger.js.map +1 -1
- package/dist/mocks.cjs +29 -24
- package/dist/mocks.cjs.map +1 -1
- package/dist/mocks.d.cts +4 -3
- package/dist/mocks.d.ts +4 -3
- package/dist/mocks.js +22 -25
- package/dist/mocks.js.map +1 -1
- package/dist/{prompt-DVQN7JTN.cjs → prompt-FODZPXQF.cjs} +89 -89
- package/dist/prompt-FODZPXQF.cjs.map +1 -0
- package/dist/prompt-WQQUN22Z.js +8 -13
- package/dist/prompt-WQQUN22Z.js.map +1 -1
- package/dist/transformers.cjs +63 -52
- package/dist/transformers.cjs.map +1 -1
- package/dist/transformers.d.cts +1 -1
- package/dist/transformers.d.ts +1 -1
- package/dist/transformers.js +10 -37
- package/dist/transformers.js.map +1 -1
- package/dist/utils.cjs +65 -34
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +6 -8
- package/dist/utils.d.ts +6 -8
- package/dist/utils.js +3 -33
- package/dist/utils.js.map +1 -1
- package/package.json +10 -13
- package/src/BarrelManager.ts +76 -74
- package/src/FileManager.ts +55 -60
- package/src/PluginManager.ts +61 -61
- package/src/PromiseManager.ts +1 -1
- package/src/__snapshots__/barrel.json +11 -29
- package/src/__snapshots__/grouped.json +18 -12
- package/src/__snapshots__/ordered.json +18 -12
- package/src/build.ts +24 -11
- package/src/config.ts +2 -4
- package/src/index.ts +1 -1
- package/src/logger.ts +41 -7
- package/src/plugin.ts +0 -3
- package/src/transformers/escape.ts +0 -10
- package/src/transformers/stringify.ts +1 -1
- package/src/types.ts +70 -38
- package/src/utils/TreeNode.ts +31 -56
- package/src/utils/executeStrategies.ts +2 -2
- package/src/utils/parser.ts +38 -39
- package/dist/chunk-27CPVXAT.js.map +0 -1
- package/dist/chunk-4X5FFJPJ.js.map +0 -1
- package/dist/chunk-5E2I6KH4.cjs.map +0 -1
- package/dist/chunk-5IGANEGE.cjs.map +0 -1
- package/dist/chunk-A6PCLWEY.cjs.map +0 -1
- package/dist/chunk-DID47EQD.cjs.map +0 -1
- package/dist/chunk-IPZQXBA2.cjs.map +0 -1
- package/dist/chunk-SCR3LUXT.js.map +0 -1
- package/dist/chunk-SEH6NUCX.cjs.map +0 -1
- package/dist/prompt-DVQN7JTN.cjs.map +0 -1
- package/src/utils/cache.ts +0 -35
package/src/PluginManager.ts
CHANGED
|
@@ -28,15 +28,10 @@ import type {
|
|
|
28
28
|
|
|
29
29
|
type RequiredPluginLifecycle = Required<PluginLifecycle>
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
* Get the type of the first argument in a function.
|
|
33
|
-
* @example Arg0<(a: string, b: number) => void> -> string
|
|
34
|
-
*/
|
|
35
|
-
type Argument0<H extends keyof PluginLifecycle> = Parameters<RequiredPluginLifecycle[H]>[0]
|
|
36
|
-
|
|
37
|
-
type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookReduceArg0' | 'hookSeq'
|
|
31
|
+
type Strategy = 'hookFirst' | 'hookForPlugin' | 'hookParallel' | 'hookSeq'
|
|
38
32
|
|
|
39
33
|
type Executer<H extends PluginLifecycleHooks = PluginLifecycleHooks> = {
|
|
34
|
+
message: string
|
|
40
35
|
strategy: Strategy
|
|
41
36
|
hookName: H
|
|
42
37
|
plugin: Plugin
|
|
@@ -58,7 +53,7 @@ type Options = {
|
|
|
58
53
|
}
|
|
59
54
|
|
|
60
55
|
type Events = {
|
|
61
|
-
|
|
56
|
+
executing: [executer: Executer]
|
|
62
57
|
executed: [executer: Executer]
|
|
63
58
|
error: [error: Error]
|
|
64
59
|
}
|
|
@@ -66,13 +61,13 @@ type Events = {
|
|
|
66
61
|
type GetFileProps<TOptions = object> = {
|
|
67
62
|
name: string
|
|
68
63
|
mode?: KubbFile.Mode
|
|
69
|
-
|
|
64
|
+
extname: KubbFile.Extname
|
|
70
65
|
pluginKey: Plugin['key']
|
|
71
66
|
options?: TOptions
|
|
72
67
|
}
|
|
73
68
|
|
|
74
69
|
export class PluginManager {
|
|
75
|
-
readonly plugins
|
|
70
|
+
readonly plugins = new Set<Plugin<GetPluginFactoryOptions<any>>>()
|
|
76
71
|
readonly fileManager: FileManager
|
|
77
72
|
readonly events: EventEmitter<Events> = new EventEmitter()
|
|
78
73
|
|
|
@@ -95,8 +90,6 @@ export class PluginManager {
|
|
|
95
90
|
nullCheck: (state: SafeParseResult<'resolveName'> | null) => !!state?.result,
|
|
96
91
|
})
|
|
97
92
|
|
|
98
|
-
const plugins = config.plugins || []
|
|
99
|
-
|
|
100
93
|
const core = pluginCore({
|
|
101
94
|
config,
|
|
102
95
|
logger: this.logger,
|
|
@@ -109,16 +102,17 @@ export class PluginManager {
|
|
|
109
102
|
|
|
110
103
|
// call core.context.call with empty context so we can transform `context()` to `context: {}`
|
|
111
104
|
this.#core = this.#parse(core as unknown as UserPlugin, this as any, core.context.call(null as any)) as Plugin<PluginCore>
|
|
105
|
+
;[this.#core, ...(config.plugins || [])].forEach((plugin) => {
|
|
106
|
+
const parsedPlugin = this.#parse(plugin as UserPlugin, this, this.#core.context)
|
|
112
107
|
|
|
113
|
-
|
|
114
|
-
return this.#parse(plugin as UserPlugin, this, this.#core.context)
|
|
108
|
+
this.plugins.add(parsedPlugin)
|
|
115
109
|
})
|
|
116
110
|
|
|
117
111
|
return this
|
|
118
112
|
}
|
|
119
113
|
|
|
120
|
-
getFile<TOptions = object>({ name, mode,
|
|
121
|
-
const baseName = `${name}${
|
|
114
|
+
getFile<TOptions = object>({ name, mode, extname, pluginKey, options }: GetFileProps<TOptions>): KubbFile.File<{ pluginKey: Plugin['key'] }> {
|
|
115
|
+
const baseName = `${name}${extname}` as const
|
|
122
116
|
const path = this.resolvePath({ baseName, mode, pluginKey, options })
|
|
123
117
|
|
|
124
118
|
if (!path) {
|
|
@@ -141,10 +135,12 @@ export class PluginManager {
|
|
|
141
135
|
pluginKey: params.pluginKey,
|
|
142
136
|
hookName: 'resolvePath',
|
|
143
137
|
parameters: [params.baseName, params.mode, params.options as object],
|
|
138
|
+
message: `Resolving path '${params.baseName}'`,
|
|
144
139
|
})
|
|
145
140
|
|
|
146
141
|
if (paths && paths?.length > 1) {
|
|
147
142
|
this.logger.emit('debug', {
|
|
143
|
+
date: new Date(),
|
|
148
144
|
logs: [
|
|
149
145
|
`Cannot return a path where the 'pluginKey' ${
|
|
150
146
|
params.pluginKey ? JSON.stringify(params.pluginKey) : '"'
|
|
@@ -158,6 +154,7 @@ export class PluginManager {
|
|
|
158
154
|
return this.hookFirstSync({
|
|
159
155
|
hookName: 'resolvePath',
|
|
160
156
|
parameters: [params.baseName, params.mode, params.options as object],
|
|
157
|
+
message: `Resolving path '${params.baseName}'`,
|
|
161
158
|
}).result
|
|
162
159
|
}
|
|
163
160
|
//TODO refactor by using the order of plugins and the cache of the fileManager instead of guessing and recreating the name/path
|
|
@@ -167,10 +164,12 @@ export class PluginManager {
|
|
|
167
164
|
pluginKey: params.pluginKey,
|
|
168
165
|
hookName: 'resolveName',
|
|
169
166
|
parameters: [params.name, params.type],
|
|
167
|
+
message: `Resolving name '${params.name}' and type '${params.type}'`,
|
|
170
168
|
})
|
|
171
169
|
|
|
172
170
|
if (names && names?.length > 1) {
|
|
173
171
|
this.logger.emit('debug', {
|
|
172
|
+
date: new Date(),
|
|
174
173
|
logs: [
|
|
175
174
|
`Cannot return a name where the 'pluginKey' ${
|
|
176
175
|
params.pluginKey ? JSON.stringify(params.pluginKey) : '"'
|
|
@@ -185,6 +184,7 @@ export class PluginManager {
|
|
|
185
184
|
const name = this.hookFirstSync({
|
|
186
185
|
hookName: 'resolveName',
|
|
187
186
|
parameters: [params.name, params.type],
|
|
187
|
+
message: `Resolving name '${params.name}' and type '${params.type}'`,
|
|
188
188
|
}).result
|
|
189
189
|
|
|
190
190
|
return transformReservedWord(name)
|
|
@@ -204,14 +204,16 @@ export class PluginManager {
|
|
|
204
204
|
pluginKey,
|
|
205
205
|
hookName,
|
|
206
206
|
parameters,
|
|
207
|
+
message,
|
|
207
208
|
}: {
|
|
208
209
|
pluginKey: Plugin['key']
|
|
209
210
|
hookName: H
|
|
210
211
|
parameters: PluginParameter<H>
|
|
212
|
+
message: string
|
|
211
213
|
}): Promise<Array<ReturnType<ParseResult<H>> | null>> {
|
|
212
214
|
const plugins = this.getPluginsByKey(hookName, pluginKey)
|
|
213
215
|
|
|
214
|
-
this.logger.emit('progress_start', { id: hookName, size: plugins.length })
|
|
216
|
+
this.logger.emit('progress_start', { id: hookName, size: plugins.length, message: 'Running plugins...' })
|
|
215
217
|
|
|
216
218
|
const promises = plugins
|
|
217
219
|
.map((plugin) => {
|
|
@@ -220,6 +222,7 @@ export class PluginManager {
|
|
|
220
222
|
hookName,
|
|
221
223
|
parameters,
|
|
222
224
|
plugin,
|
|
225
|
+
message,
|
|
223
226
|
})
|
|
224
227
|
})
|
|
225
228
|
.filter(Boolean)
|
|
@@ -238,10 +241,12 @@ export class PluginManager {
|
|
|
238
241
|
pluginKey,
|
|
239
242
|
hookName,
|
|
240
243
|
parameters,
|
|
244
|
+
message,
|
|
241
245
|
}: {
|
|
242
246
|
pluginKey: Plugin['key']
|
|
243
247
|
hookName: H
|
|
244
248
|
parameters: PluginParameter<H>
|
|
249
|
+
message: string
|
|
245
250
|
}): Array<ReturnType<ParseResult<H>>> | null {
|
|
246
251
|
const plugins = this.getPluginsByKey(hookName, pluginKey)
|
|
247
252
|
|
|
@@ -252,6 +257,7 @@ export class PluginManager {
|
|
|
252
257
|
hookName,
|
|
253
258
|
parameters,
|
|
254
259
|
plugin,
|
|
260
|
+
message,
|
|
255
261
|
})
|
|
256
262
|
})
|
|
257
263
|
.filter(Boolean)
|
|
@@ -266,10 +272,12 @@ export class PluginManager {
|
|
|
266
272
|
hookName,
|
|
267
273
|
parameters,
|
|
268
274
|
skipped,
|
|
275
|
+
message,
|
|
269
276
|
}: {
|
|
270
277
|
hookName: H
|
|
271
278
|
parameters: PluginParameter<H>
|
|
272
279
|
skipped?: ReadonlySet<Plugin> | null
|
|
280
|
+
message: string
|
|
273
281
|
}): Promise<SafeParseResult<H>> {
|
|
274
282
|
const plugins = this.#getSortedPlugins(hookName).filter((plugin) => {
|
|
275
283
|
return skipped ? skipped.has(plugin) : true
|
|
@@ -284,6 +292,7 @@ export class PluginManager {
|
|
|
284
292
|
hookName,
|
|
285
293
|
parameters,
|
|
286
294
|
plugin,
|
|
295
|
+
message,
|
|
287
296
|
})
|
|
288
297
|
|
|
289
298
|
return Promise.resolve({
|
|
@@ -307,10 +316,12 @@ export class PluginManager {
|
|
|
307
316
|
hookName,
|
|
308
317
|
parameters,
|
|
309
318
|
skipped,
|
|
319
|
+
message,
|
|
310
320
|
}: {
|
|
311
321
|
hookName: H
|
|
312
322
|
parameters: PluginParameter<H>
|
|
313
323
|
skipped?: ReadonlySet<Plugin> | null
|
|
324
|
+
message: string
|
|
314
325
|
}): SafeParseResult<H> {
|
|
315
326
|
let parseResult: SafeParseResult<H> = null as unknown as SafeParseResult<H>
|
|
316
327
|
const plugins = this.#getSortedPlugins(hookName).filter((plugin) => {
|
|
@@ -324,6 +335,7 @@ export class PluginManager {
|
|
|
324
335
|
hookName,
|
|
325
336
|
parameters,
|
|
326
337
|
plugin,
|
|
338
|
+
message,
|
|
327
339
|
}),
|
|
328
340
|
plugin,
|
|
329
341
|
} as SafeParseResult<H>
|
|
@@ -342,9 +354,11 @@ export class PluginManager {
|
|
|
342
354
|
async hookParallel<H extends PluginLifecycleHooks, TOuput = void>({
|
|
343
355
|
hookName,
|
|
344
356
|
parameters,
|
|
357
|
+
message,
|
|
345
358
|
}: {
|
|
346
359
|
hookName: H
|
|
347
360
|
parameters?: Parameters<RequiredPluginLifecycle[H]> | undefined
|
|
361
|
+
message: string
|
|
348
362
|
}): Promise<Awaited<TOuput>[]> {
|
|
349
363
|
const plugins = this.#getSortedPlugins(hookName)
|
|
350
364
|
this.logger.emit('progress_start', { id: hookName, size: plugins.length })
|
|
@@ -356,6 +370,7 @@ export class PluginManager {
|
|
|
356
370
|
hookName,
|
|
357
371
|
parameters,
|
|
358
372
|
plugin,
|
|
373
|
+
message,
|
|
359
374
|
}) as Promise<TOuput>
|
|
360
375
|
})
|
|
361
376
|
|
|
@@ -375,42 +390,13 @@ export class PluginManager {
|
|
|
375
390
|
}
|
|
376
391
|
|
|
377
392
|
/**
|
|
378
|
-
*
|
|
393
|
+
* Chains plugins
|
|
379
394
|
*/
|
|
380
|
-
|
|
395
|
+
async hookSeq<H extends PluginLifecycleHooks>({
|
|
381
396
|
hookName,
|
|
382
397
|
parameters,
|
|
383
|
-
|
|
384
|
-
}: {
|
|
385
|
-
hookName: H
|
|
386
|
-
parameters: PluginParameter<H>
|
|
387
|
-
reduce: (reduction: Argument0<H>, result: ReturnType<ParseResult<H>>, plugin: Plugin) => PossiblePromise<Argument0<H> | null>
|
|
388
|
-
}): Promise<Argument0<H>> {
|
|
389
|
-
const [argument0, ...rest] = parameters
|
|
390
|
-
const plugins = this.#getSortedPlugins(hookName)
|
|
391
|
-
|
|
392
|
-
let promise: Promise<Argument0<H>> = Promise.resolve(argument0)
|
|
393
|
-
for (const plugin of plugins) {
|
|
394
|
-
promise = promise
|
|
395
|
-
.then((arg0) => {
|
|
396
|
-
const value = this.#execute({
|
|
397
|
-
strategy: 'hookReduceArg0',
|
|
398
|
-
hookName,
|
|
399
|
-
parameters: [arg0, ...rest] as PluginParameter<H>,
|
|
400
|
-
plugin,
|
|
401
|
-
})
|
|
402
|
-
return value
|
|
403
|
-
})
|
|
404
|
-
.then((result) => reduce.call(this.#core.context, argument0, result as ReturnType<ParseResult<H>>, plugin)) as Promise<Argument0<H>>
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
return promise
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
/**
|
|
411
|
-
* Chains plugins
|
|
412
|
-
*/
|
|
413
|
-
async hookSeq<H extends PluginLifecycleHooks>({ hookName, parameters }: { hookName: H; parameters?: PluginParameter<H> }): Promise<void> {
|
|
398
|
+
message,
|
|
399
|
+
}: { hookName: H; parameters?: PluginParameter<H>; message: string }): Promise<void> {
|
|
414
400
|
const plugins = this.#getSortedPlugins(hookName)
|
|
415
401
|
this.logger.emit('progress_start', { id: hookName, size: plugins.length })
|
|
416
402
|
|
|
@@ -421,6 +407,7 @@ export class PluginManager {
|
|
|
421
407
|
hookName,
|
|
422
408
|
parameters,
|
|
423
409
|
plugin,
|
|
410
|
+
message,
|
|
424
411
|
})
|
|
425
412
|
})
|
|
426
413
|
|
|
@@ -433,12 +420,7 @@ export class PluginManager {
|
|
|
433
420
|
const plugins = [...this.plugins].filter((plugin) => plugin.name !== 'core')
|
|
434
421
|
|
|
435
422
|
if (hookName) {
|
|
436
|
-
|
|
437
|
-
if (!containsHookName) {
|
|
438
|
-
this.logger.emit('debug', { logs: [`No hook ${hookName} found`] })
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
return plugins.filter((item) => item[hookName])
|
|
423
|
+
return plugins.filter((plugin) => hookName in plugin)
|
|
442
424
|
}
|
|
443
425
|
// TODO add test case for sorting with pre/post
|
|
444
426
|
|
|
@@ -470,7 +452,7 @@ export class PluginManager {
|
|
|
470
452
|
const [searchPluginName, searchIdentifier] = pluginKey
|
|
471
453
|
|
|
472
454
|
const pluginByPluginName = plugins
|
|
473
|
-
.filter((plugin) => plugin
|
|
455
|
+
.filter((plugin) => hookName in plugin)
|
|
474
456
|
.filter((item) => {
|
|
475
457
|
const [name, identifier] = item.key
|
|
476
458
|
|
|
@@ -487,14 +469,16 @@ export class PluginManager {
|
|
|
487
469
|
if (!pluginByPluginName?.length) {
|
|
488
470
|
// fallback on the core plugin when there is no match
|
|
489
471
|
|
|
490
|
-
const corePlugin = plugins.find((plugin) => plugin.name === 'core' && plugin
|
|
472
|
+
const corePlugin = plugins.find((plugin) => plugin.name === 'core' && hookName in plugin)
|
|
491
473
|
|
|
492
474
|
if (corePlugin) {
|
|
493
475
|
this.logger.emit('debug', {
|
|
476
|
+
date: new Date(),
|
|
494
477
|
logs: [`No hook '${hookName}' for pluginKey '${JSON.stringify(pluginKey)}' found, falling back on the '@kubb/core' plugin`],
|
|
495
478
|
})
|
|
496
479
|
} else {
|
|
497
480
|
this.logger.emit('debug', {
|
|
481
|
+
date: new Date(),
|
|
498
482
|
logs: [`No hook '${hookName}' for pluginKey '${JSON.stringify(pluginKey)}' found, no fallback found in the '@kubb/core' plugin`],
|
|
499
483
|
})
|
|
500
484
|
}
|
|
@@ -509,7 +493,7 @@ export class PluginManager {
|
|
|
509
493
|
this.events.emit('executed', executer)
|
|
510
494
|
this.executed.push(executer)
|
|
511
495
|
|
|
512
|
-
this.logger.emit('
|
|
496
|
+
this.logger.emit('progressed', { id: executer.hookName, message: `${executer.plugin.name}: ${executer.message}` })
|
|
513
497
|
}
|
|
514
498
|
}
|
|
515
499
|
|
|
@@ -525,11 +509,13 @@ export class PluginManager {
|
|
|
525
509
|
hookName,
|
|
526
510
|
parameters,
|
|
527
511
|
plugin,
|
|
512
|
+
message,
|
|
528
513
|
}: {
|
|
529
514
|
strategy: Strategy
|
|
530
515
|
hookName: H
|
|
531
516
|
parameters: unknown[] | undefined
|
|
532
517
|
plugin: PluginWithLifeCycle
|
|
518
|
+
message: string
|
|
533
519
|
}): Promise<ReturnType<ParseResult<H>> | null> | null {
|
|
534
520
|
const hook = plugin[hookName]
|
|
535
521
|
let output: unknown
|
|
@@ -538,7 +524,7 @@ export class PluginManager {
|
|
|
538
524
|
return null
|
|
539
525
|
}
|
|
540
526
|
|
|
541
|
-
this.events.emit('
|
|
527
|
+
this.events.emit('executing', { strategy, hookName, parameters, plugin, message })
|
|
542
528
|
const promise = new Promise((resolve) => {
|
|
543
529
|
resolve(undefined)
|
|
544
530
|
})
|
|
@@ -565,6 +551,7 @@ export class PluginManager {
|
|
|
565
551
|
strategy,
|
|
566
552
|
hookName,
|
|
567
553
|
plugin,
|
|
554
|
+
message,
|
|
568
555
|
})
|
|
569
556
|
|
|
570
557
|
return result
|
|
@@ -590,11 +577,13 @@ export class PluginManager {
|
|
|
590
577
|
hookName,
|
|
591
578
|
parameters,
|
|
592
579
|
plugin,
|
|
580
|
+
message,
|
|
593
581
|
}: {
|
|
594
582
|
strategy: Strategy
|
|
595
583
|
hookName: H
|
|
596
584
|
parameters: PluginParameter<H>
|
|
597
585
|
plugin: PluginWithLifeCycle
|
|
586
|
+
message: string
|
|
598
587
|
}): ReturnType<ParseResult<H>> | null {
|
|
599
588
|
const hook = plugin[hookName]
|
|
600
589
|
let output: unknown
|
|
@@ -603,13 +592,23 @@ export class PluginManager {
|
|
|
603
592
|
return null
|
|
604
593
|
}
|
|
605
594
|
|
|
606
|
-
this.events.emit('
|
|
595
|
+
this.events.emit('executing', { strategy, hookName, parameters, plugin, message })
|
|
607
596
|
|
|
608
597
|
try {
|
|
609
598
|
if (typeof hook === 'function') {
|
|
610
599
|
const fn = (hook as Function).apply({ ...this.#core.context, plugin }, parameters) as ReturnType<ParseResult<H>>
|
|
611
600
|
|
|
612
601
|
output = fn
|
|
602
|
+
|
|
603
|
+
this.#addExecutedToCallStack({
|
|
604
|
+
parameters,
|
|
605
|
+
output,
|
|
606
|
+
strategy,
|
|
607
|
+
hookName,
|
|
608
|
+
plugin,
|
|
609
|
+
message,
|
|
610
|
+
})
|
|
611
|
+
|
|
613
612
|
return fn
|
|
614
613
|
}
|
|
615
614
|
|
|
@@ -621,6 +620,7 @@ export class PluginManager {
|
|
|
621
620
|
strategy,
|
|
622
621
|
hookName,
|
|
623
622
|
plugin,
|
|
623
|
+
message,
|
|
624
624
|
})
|
|
625
625
|
|
|
626
626
|
return hook
|
package/src/PromiseManager.ts
CHANGED
|
@@ -42,7 +42,7 @@ export function isPromise<T>(result: PossiblePromise<T>): result is Promise<T> {
|
|
|
42
42
|
return !!result && typeof (result as Promise<unknown>)?.then === 'function'
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
function isPromiseFulfilledResult<T = unknown>(result: PromiseSettledResult<unknown>): result is PromiseFulfilledResult<T> {
|
|
46
46
|
return result.status === 'fulfilled'
|
|
47
47
|
}
|
|
48
48
|
|
|
@@ -4,25 +4,13 @@
|
|
|
4
4
|
"baseName": "index.ts",
|
|
5
5
|
"exports": [
|
|
6
6
|
{
|
|
7
|
-
"
|
|
8
|
-
"hello"
|
|
9
|
-
],
|
|
10
|
-
"path": "./sub/hello.ts",
|
|
11
|
-
"extName": ".ts"
|
|
7
|
+
"path": "./sub/hello.ts"
|
|
12
8
|
},
|
|
13
9
|
{
|
|
14
|
-
"
|
|
15
|
-
"world"
|
|
16
|
-
],
|
|
17
|
-
"path": "./sub/world.ts",
|
|
18
|
-
"extName": ".ts"
|
|
10
|
+
"path": "./sub/world.ts"
|
|
19
11
|
},
|
|
20
12
|
{
|
|
21
|
-
"
|
|
22
|
-
"test"
|
|
23
|
-
],
|
|
24
|
-
"path": "./test.ts",
|
|
25
|
-
"extName": ".ts"
|
|
13
|
+
"path": "./test.ts"
|
|
26
14
|
}
|
|
27
15
|
],
|
|
28
16
|
"sources": [
|
|
@@ -47,26 +35,19 @@
|
|
|
47
35
|
],
|
|
48
36
|
"id": "feabc02536bd6630458e734990f7e2a21a55c469",
|
|
49
37
|
"name": "index",
|
|
50
|
-
"
|
|
51
|
-
"imports": []
|
|
38
|
+
"extname": ".ts",
|
|
39
|
+
"imports": [],
|
|
40
|
+
"meta": {}
|
|
52
41
|
},
|
|
53
42
|
{
|
|
54
43
|
"path": "src/sub/index.ts",
|
|
55
44
|
"baseName": "index.ts",
|
|
56
45
|
"exports": [
|
|
57
46
|
{
|
|
58
|
-
"
|
|
59
|
-
"hello"
|
|
60
|
-
],
|
|
61
|
-
"path": "./hello.ts",
|
|
62
|
-
"extName": ".ts"
|
|
47
|
+
"path": "./hello.ts"
|
|
63
48
|
},
|
|
64
49
|
{
|
|
65
|
-
"
|
|
66
|
-
"world"
|
|
67
|
-
],
|
|
68
|
-
"path": "./world.ts",
|
|
69
|
-
"extName": ".ts"
|
|
50
|
+
"path": "./world.ts"
|
|
70
51
|
}
|
|
71
52
|
],
|
|
72
53
|
"sources": [
|
|
@@ -85,7 +66,8 @@
|
|
|
85
66
|
],
|
|
86
67
|
"id": "c67967bd2363dd9637437671f6fe1ed146debdbf",
|
|
87
68
|
"name": "index",
|
|
88
|
-
"
|
|
89
|
-
"imports": []
|
|
69
|
+
"extname": ".ts",
|
|
70
|
+
"imports": [],
|
|
71
|
+
"meta": {}
|
|
90
72
|
}
|
|
91
73
|
]
|
|
@@ -18,9 +18,10 @@
|
|
|
18
18
|
"sources": [],
|
|
19
19
|
"id": "6af477de6b602aafbb2e1ce0011b1f411a7ab3a5",
|
|
20
20
|
"name": "file2",
|
|
21
|
-
"
|
|
21
|
+
"extname": ".ts",
|
|
22
22
|
"imports": [],
|
|
23
|
-
"exports": []
|
|
23
|
+
"exports": [],
|
|
24
|
+
"meta": {}
|
|
24
25
|
},
|
|
25
26
|
"path": "src/axios/file2.ts"
|
|
26
27
|
},
|
|
@@ -32,9 +33,10 @@
|
|
|
32
33
|
"sources": [],
|
|
33
34
|
"id": "a9679944d24c174b2f2fd5b1f19c9861f1d35d0e",
|
|
34
35
|
"name": "file2",
|
|
35
|
-
"
|
|
36
|
+
"extname": ".ts",
|
|
36
37
|
"imports": [],
|
|
37
|
-
"exports": []
|
|
38
|
+
"exports": [],
|
|
39
|
+
"meta": {}
|
|
38
40
|
},
|
|
39
41
|
"path": "src/axios/file1.ts"
|
|
40
42
|
},
|
|
@@ -50,9 +52,10 @@
|
|
|
50
52
|
"sources": [],
|
|
51
53
|
"id": "8beaaf5e1b1a6b89a11589c2e3dc5fd7f5eb5e8c",
|
|
52
54
|
"name": "pet",
|
|
53
|
-
"
|
|
55
|
+
"extname": ".ts",
|
|
54
56
|
"imports": [],
|
|
55
|
-
"exports": []
|
|
57
|
+
"exports": [],
|
|
58
|
+
"meta": {}
|
|
56
59
|
},
|
|
57
60
|
"path": "src/axios/controller/pet.ts"
|
|
58
61
|
}
|
|
@@ -66,9 +69,10 @@
|
|
|
66
69
|
"sources": [],
|
|
67
70
|
"id": "b077038b83c1ef4050649be406937a73c1f41ad3",
|
|
68
71
|
"name": "index",
|
|
69
|
-
"
|
|
72
|
+
"extname": ".ts",
|
|
70
73
|
"imports": [],
|
|
71
|
-
"exports": []
|
|
74
|
+
"exports": [],
|
|
75
|
+
"meta": {}
|
|
72
76
|
},
|
|
73
77
|
"path": "src/axios/index.ts"
|
|
74
78
|
}
|
|
@@ -86,9 +90,10 @@
|
|
|
86
90
|
"sources": [],
|
|
87
91
|
"id": "a2d277093a81a74c56c0d094071195302d6bb484",
|
|
88
92
|
"name": "test",
|
|
89
|
-
"
|
|
93
|
+
"extname": ".ts",
|
|
90
94
|
"imports": [],
|
|
91
|
-
"exports": []
|
|
95
|
+
"exports": [],
|
|
96
|
+
"meta": {}
|
|
92
97
|
},
|
|
93
98
|
"path": "src/controller/test.ts"
|
|
94
99
|
}
|
|
@@ -102,9 +107,10 @@
|
|
|
102
107
|
"sources": [],
|
|
103
108
|
"id": "f8e2d98f76d6e33f21aa686d674544b5c7d6fa3e",
|
|
104
109
|
"name": "test",
|
|
105
|
-
"
|
|
110
|
+
"extname": ".ts",
|
|
106
111
|
"imports": [],
|
|
107
|
-
"exports": []
|
|
112
|
+
"exports": [],
|
|
113
|
+
"meta": {}
|
|
108
114
|
},
|
|
109
115
|
"path": "src/test.ts"
|
|
110
116
|
}
|
|
@@ -5,9 +5,10 @@
|
|
|
5
5
|
"sources": [],
|
|
6
6
|
"id": "f8e2d98f76d6e33f21aa686d674544b5c7d6fa3e",
|
|
7
7
|
"name": "test",
|
|
8
|
-
"
|
|
8
|
+
"extname": ".ts",
|
|
9
9
|
"imports": [],
|
|
10
|
-
"exports": []
|
|
10
|
+
"exports": [],
|
|
11
|
+
"meta": {}
|
|
11
12
|
},
|
|
12
13
|
{
|
|
13
14
|
"path": "src/axios/file2.ts",
|
|
@@ -15,9 +16,10 @@
|
|
|
15
16
|
"sources": [],
|
|
16
17
|
"id": "6af477de6b602aafbb2e1ce0011b1f411a7ab3a5",
|
|
17
18
|
"name": "file2",
|
|
18
|
-
"
|
|
19
|
+
"extname": ".ts",
|
|
19
20
|
"imports": [],
|
|
20
|
-
"exports": []
|
|
21
|
+
"exports": [],
|
|
22
|
+
"meta": {}
|
|
21
23
|
},
|
|
22
24
|
{
|
|
23
25
|
"path": "src/axios/file1.ts",
|
|
@@ -25,9 +27,10 @@
|
|
|
25
27
|
"sources": [],
|
|
26
28
|
"id": "a9679944d24c174b2f2fd5b1f19c9861f1d35d0e",
|
|
27
29
|
"name": "file2",
|
|
28
|
-
"
|
|
30
|
+
"extname": ".ts",
|
|
29
31
|
"imports": [],
|
|
30
|
-
"exports": []
|
|
32
|
+
"exports": [],
|
|
33
|
+
"meta": {}
|
|
31
34
|
},
|
|
32
35
|
{
|
|
33
36
|
"path": "src/axios/index.ts",
|
|
@@ -35,9 +38,10 @@
|
|
|
35
38
|
"sources": [],
|
|
36
39
|
"id": "b077038b83c1ef4050649be406937a73c1f41ad3",
|
|
37
40
|
"name": "index",
|
|
38
|
-
"
|
|
41
|
+
"extname": ".ts",
|
|
39
42
|
"imports": [],
|
|
40
|
-
"exports": []
|
|
43
|
+
"exports": [],
|
|
44
|
+
"meta": {}
|
|
41
45
|
},
|
|
42
46
|
{
|
|
43
47
|
"path": "src/controller/test.ts",
|
|
@@ -45,9 +49,10 @@
|
|
|
45
49
|
"sources": [],
|
|
46
50
|
"id": "a2d277093a81a74c56c0d094071195302d6bb484",
|
|
47
51
|
"name": "test",
|
|
48
|
-
"
|
|
52
|
+
"extname": ".ts",
|
|
49
53
|
"imports": [],
|
|
50
|
-
"exports": []
|
|
54
|
+
"exports": [],
|
|
55
|
+
"meta": {}
|
|
51
56
|
},
|
|
52
57
|
{
|
|
53
58
|
"path": "src/axios/controller/pet.ts",
|
|
@@ -55,8 +60,9 @@
|
|
|
55
60
|
"sources": [],
|
|
56
61
|
"id": "8beaaf5e1b1a6b89a11589c2e3dc5fd7f5eb5e8c",
|
|
57
62
|
"name": "pet",
|
|
58
|
-
"
|
|
63
|
+
"extname": ".ts",
|
|
59
64
|
"imports": [],
|
|
60
|
-
"exports": []
|
|
65
|
+
"exports": [],
|
|
66
|
+
"meta": {}
|
|
61
67
|
}
|
|
62
68
|
]
|