@kubb/core 2.0.0-beta.10 → 2.0.0-beta.11

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/src/index.ts CHANGED
@@ -3,16 +3,16 @@ import { build } from './build.ts'
3
3
  import type { ObjValueTuple, TupleToUnion } from '@kubb/types'
4
4
 
5
5
  export { build, safeBuild } from './build.ts'
6
- export * from './config.ts'
7
- export * from './errors.ts'
8
- export * from './FileManager.ts'
6
+ export { defineConfig, isInputPath } from './config.ts'
7
+ export { Warning } from './errors.ts'
8
+ export { FileManager, KubbFile } from './FileManager.ts'
9
9
  export { Generator } from './Generator.ts'
10
10
  export { PackageManager } from './PackageManager.ts'
11
11
  // dprint-ignore
12
12
  export { createPlugin, pluginName as name, pluginName } from './plugin.ts'
13
13
  export { PluginManager } from './PluginManager.ts'
14
14
  export { PromiseManager } from './PromiseManager.ts'
15
- export * from './types.ts'
15
+ export type * from './types.ts'
16
16
 
17
17
  export interface _Register {}
18
18
  export type Plugins = _Register
@@ -1,6 +1,8 @@
1
1
  import pc from 'picocolors'
2
+ import seedrandom from 'seedrandom'
2
3
 
3
4
  import type { Ora } from 'ora'
5
+ import type { Formatter } from 'picocolors/types.ts'
4
6
 
5
7
  export const LogLevel = {
6
8
  silent: 'silent',
@@ -73,4 +75,39 @@ export function createLogger({ logLevel, name, spinner }: Props): Logger {
73
75
  return logger
74
76
  }
75
77
 
78
+ const defaultColours = ['black', 'blue', 'darkBlue', 'cyan', 'gray', 'green', 'darkGreen', 'magenta', 'red', 'darkRed', 'yellow', 'darkYellow'] as const
79
+
80
+ export function randomColour(text?: string, colours = defaultColours): string {
81
+ if (!text) {
82
+ return 'white'
83
+ }
84
+
85
+ const random = seedrandom(text)
86
+ const colour = colours.at(Math.floor(random() * colours.length)) || 'white'
87
+
88
+ return colour
89
+ }
90
+
91
+ export function randomPicoColour(text?: string, colors = defaultColours): string {
92
+ const colours = pc.createColors(true)
93
+
94
+ if (!text) {
95
+ return colours.white(text)
96
+ }
97
+
98
+ const colour = randomColour(text, colors)
99
+ const isDark = colour.includes('dark')
100
+ const key = colour.replace('dark', '').toLowerCase() as keyof typeof colours
101
+ const formatter: Formatter = colours[key] as Formatter
102
+
103
+ if (isDark) {
104
+ return pc.bold(formatter(text))
105
+ }
106
+
107
+ if (typeof formatter !== 'function') {
108
+ throw new Error('Formatter for picoColor is not of type function/Formatter')
109
+ }
110
+ return formatter(text)
111
+ }
112
+
76
113
  export { default as pc } from 'picocolors'
package/src/types.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import type { PossiblePromise } from '@kubb/types'
2
2
  import type { FileManager, KubbFile } from './FileManager.ts'
3
3
  import type { OptionsPlugins, PluginUnion } from './index.ts'
4
+ import type { Logger, LogLevel } from './logger.ts'
4
5
  import type { PluginManager } from './PluginManager.ts'
5
6
  import type { Cache } from './utils/cache.ts'
6
- import type { Logger, LogLevel } from './utils/logger.ts'
7
7
 
8
8
  // config
9
9
 
@@ -1,18 +1,10 @@
1
- export * from './cache.ts'
2
- export * from './cache.ts'
3
- export * from './clean.ts'
4
- export * from './FunctionParams.ts'
5
- export * from './FunctionParams.ts'
6
- export * from './logger.ts'
7
- export * from './promise.ts'
8
- export * from './Queue.ts'
9
- export * from './Queue.ts'
10
- export * from './randomColour.ts'
11
- export * from './read.ts'
12
- export * from './renderTemplate.ts'
13
- export * from './throttle.ts'
14
- export * from './timeout.ts'
15
- export * from './TreeNode.ts'
16
- export * from './uniqueName.ts'
17
- export * from './URLPath.ts'
18
- export * from './write.ts'
1
+ export type { FunctionParamsAST } from './FunctionParams.ts'
2
+ export { FunctionParams } from './FunctionParams.ts'
3
+ export { isPromise, isPromiseFulfilledResult, isPromiseRejectedResult } from './promise.ts'
4
+ export type { QueueJob } from './Queue.ts'
5
+ export { Queue } from './Queue.ts'
6
+ export { renderTemplate } from './renderTemplate.ts'
7
+ export { timeout } from './timeout.ts'
8
+ export { getUniqueName, setUniqueName } from './uniqueName.ts'
9
+ export type { URLObject } from './URLPath.ts'
10
+ export { URLPath } from './URLPath.ts'
@@ -1,39 +0,0 @@
1
- import pc from 'picocolors'
2
- import seedrandom from 'seedrandom'
3
-
4
- import type { Formatter } from 'picocolors/types.ts'
5
-
6
- const defaultColours = ['black', 'blue', 'darkBlue', 'cyan', 'gray', 'green', 'darkGreen', 'magenta', 'red', 'darkRed', 'yellow', 'darkYellow'] as const
7
-
8
- export function randomColour(text?: string, colours = defaultColours): string {
9
- if (!text) {
10
- return 'white'
11
- }
12
-
13
- const random = seedrandom(text)
14
- const colour = colours.at(Math.floor(random() * colours.length)) || 'white'
15
-
16
- return colour
17
- }
18
-
19
- export function randomPicoColour(text?: string, colors = defaultColours): string {
20
- const colours = pc.createColors(true)
21
-
22
- if (!text) {
23
- return colours.white(text)
24
- }
25
-
26
- const colour = randomColour(text, colors)
27
- const isDark = colour.includes('dark')
28
- const key = colour.replace('dark', '').toLowerCase() as keyof typeof colours
29
- const formatter: Formatter = colours[key] as Formatter
30
-
31
- if (isDark) {
32
- return pc.bold(formatter(text))
33
- }
34
-
35
- if (typeof formatter !== 'function') {
36
- throw new Error('Formatter for picoColor is not of type function/Formatter')
37
- }
38
- return formatter(text)
39
- }
@@ -1,30 +0,0 @@
1
- export const throttle = <R, A extends any[]>(fn: (...args: A) => R, delay: number): [(...args: A) => R | undefined, () => void] => {
2
- let wait = false
3
- let timeout: NodeJS.Timeout
4
- let cancelled = false
5
-
6
- return [
7
- (...args: A) => {
8
- if (cancelled) {
9
- return undefined
10
- }
11
- if (wait) {
12
- return undefined
13
- }
14
-
15
- const val = fn(...args)
16
-
17
- wait = true
18
-
19
- timeout = setTimeout(() => {
20
- wait = false
21
- }, delay)
22
-
23
- return val
24
- },
25
- () => {
26
- cancelled = true
27
- clearTimeout(timeout)
28
- },
29
- ]
30
- }
File without changes
File without changes
File without changes