topkat-utils 1.2.35 → 1.2.36

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/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ### v1.2.36
2
+ * FIX typeof config partial and required
3
+
1
4
  ### v1.2.35
2
5
  * other fix logFromOtherErr is not iterable
3
6
 
@@ -1,4 +1,23 @@
1
1
  import { Color, ErrorOptions } from './types';
2
+ type TerminalTheme = {
3
+ primary: Color;
4
+ shade1: Color;
5
+ shade2: Color;
6
+ bgColor?: Color;
7
+ paddingX?: number;
8
+ paddingY?: number;
9
+ fontColor?: Color;
10
+ pageWidth?: number;
11
+ debugModeColor?: Color;
12
+ };
13
+ type TerminalConfig = {
14
+ noColor: boolean;
15
+ theme: TerminalTheme;
16
+ };
17
+ type TerminalConfigRequired = {
18
+ noColor: boolean;
19
+ theme: Required<TerminalTheme>;
20
+ };
2
21
  export type TopkatUtilConfig = {
3
22
  env: string;
4
23
  isProd: boolean;
@@ -6,21 +25,11 @@ export type TopkatUtilConfig = {
6
25
  customTypes: object;
7
26
  preprocessLog?: (log: string) => any;
8
27
  onError?: (msg: string, extraInfos: ErrorOptions) => any;
9
- terminal: {
10
- noColor: boolean;
11
- theme: {
12
- primary: Color;
13
- shade1: Color;
14
- shade2: Color;
15
- bgColor?: Color;
16
- paddingX: number;
17
- paddingY: number;
18
- fontColor?: Color;
19
- pageWidth: number;
20
- debugModeColor?: Color;
21
- };
22
- };
28
+ terminal: TerminalConfig;
23
29
  };
24
30
  /** Allow dynamic changing of config */
25
- export declare function configFn(): TopkatUtilConfig;
31
+ export declare function configFn(): Required<TopkatUtilConfig & {
32
+ terminal: TerminalConfigRequired;
33
+ }>;
26
34
  export declare function registerConfig(customConfig: Partial<TopkatUtilConfig>): void;
35
+ export {};
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":";;;AAEA,2CAAsC;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AAA;IACD,SAAS,CAAC,QAAQ,CAAC,KAAK,mCACjB,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,QAAQ,0CAAE,KAAK,GACvB,CAAC,CAAA,MAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,QAAQ,0CAAE,KAAK,KAAI,EAAE,CAAC,CAC3C,CAAA;IACD,MAAM,GAAG,SAAgB,CAAA;IAEzB,MAAM,CAAC,MAAM,GAAG,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,GAAG,0CAAE,QAAQ,CAAC,MAAM,CAAC,CAAA,CAAC,uBAAuB;AACzE,CAAC;AAjBD,wCAiBC"}
@@ -27,10 +27,10 @@ export declare const C: {
27
27
  /** Eg: ['cell1', 'cell2', 'cell3'], [25, 15] will start cell2 at 25 and cell 3 at 25 + 15
28
28
  * @param {Array} limits default divide the viewport
29
29
  */
30
- cols(strings: any, limits?: number[], clr?: Color | undefined, paddingX?: number): void;
30
+ cols(strings: any, limits?: number[], clr?: Color, paddingX?: number): void;
31
31
  /** Console log alias */
32
32
  log(...stringsCtxMayBeFirstParam: any[]): void;
33
- logClr(str: any, clr?: Color | undefined, paddingX?: number): void;
33
+ logClr(str: any, clr?: Color, paddingX?: number): void;
34
34
  info(...str: any[]): void;
35
35
  success(...str: any[]): void;
36
36
  /** First param **false** to avoid logging stack trace */
@@ -48,7 +48,7 @@ export declare const C: {
48
48
  notification(type: any, ...messages: any[]): void;
49
49
  notifications: any[];
50
50
  /** Gratientize lines of text (separated by \n) */
51
- gradientize(str?: string, rgb1?: Color, rgb2?: Color, bgRgb?: Color | undefined, paddingY?: number, paddingX?: number): void;
51
+ gradientize(str?: string, rgb1?: Color, rgb2?: Color, bgRgb?: Color, paddingY?: number, paddingX?: number): void;
52
52
  debugModeLog(title: any, ...string: any[]): void;
53
53
  useTheme(): void;
54
54
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "topkat-utils",
3
- "version": "1.2.35",
3
+ "version": "1.2.36",
4
4
  "type": "commonjs",
5
5
  "types": "index.ts",
6
6
  "main": "dist",
package/src/config.ts CHANGED
@@ -1,9 +1,29 @@
1
1
  import { Color, ErrorOptions } from './types'
2
- import { isset } from './isset'
3
2
  import { isNodeJs } from './is-nodejs'
4
3
 
5
4
  const isNode = isNodeJs()
6
5
 
6
+ type TerminalTheme = {
7
+ primary: Color, // blue theme
8
+ shade1: Color,
9
+ shade2: Color,
10
+ bgColor?: Color
11
+ paddingX?: number
12
+ paddingY?: number
13
+ fontColor?: Color
14
+ pageWidth?: number
15
+ debugModeColor?: Color,
16
+ }
17
+
18
+ type TerminalConfig = {
19
+ noColor: boolean
20
+ theme: TerminalTheme
21
+ }
22
+ type TerminalConfigRequired = {
23
+ noColor: boolean
24
+ theme: Required<TerminalTheme>
25
+ }
26
+
7
27
  export type TopkatUtilConfig = {
8
28
  env: string
9
29
  isProd: boolean
@@ -11,23 +31,10 @@ export type TopkatUtilConfig = {
11
31
  customTypes: object,
12
32
  preprocessLog?: (log: string) => any,
13
33
  onError?: (msg: string, extraInfos: ErrorOptions) => any
14
- terminal: {
15
- noColor: boolean
16
- theme: {
17
- primary: Color, // blue theme
18
- shade1: Color,
19
- shade2: Color,
20
- bgColor?: Color
21
- paddingX: number
22
- paddingY: number
23
- fontColor?: Color
24
- pageWidth: number
25
- debugModeColor?: Color,
26
- }
27
- }
34
+ terminal: TerminalConfig
28
35
  }
29
36
 
30
- let config: TopkatUtilConfig = {
37
+ let config = {
31
38
  // Also used as default config
32
39
  env: 'development',
33
40
  isProd: false,
@@ -48,7 +55,7 @@ let config: TopkatUtilConfig = {
48
55
  }
49
56
 
50
57
  /** Allow dynamic changing of config */
51
- export function configFn(): TopkatUtilConfig { return config }
58
+ export function configFn(): Required<TopkatUtilConfig & { terminal: TerminalConfigRequired }> { return config as any }
52
59
 
53
60
  export function registerConfig(customConfig: Partial<TopkatUtilConfig>) {
54
61
  if ('terminal' in customConfig === false) customConfig.terminal = {} as TopkatUtilConfig['terminal']
@@ -64,7 +71,7 @@ export function registerConfig(customConfig: Partial<TopkatUtilConfig>) {
64
71
  ...config?.terminal?.theme,
65
72
  ...(customConfig?.terminal?.theme || {})
66
73
  }
67
- config = newconfig
74
+ config = newconfig as any
68
75
 
69
76
  config.isProd = config?.env?.includes('prod') // preprod | production
70
77
  }