@epigraph/epigraph-std-lib 1.1.0 → 2.0.1

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.
@@ -1,46 +1,130 @@
1
- export type ILoggerDetails = string | boolean | object | Array<string> | Array<boolean> | HTMLElement;
2
- export interface LoggerLevel {
1
+ interface LoggerMode {
3
2
  name: string;
4
3
  allows: Array<string>;
5
4
  }
6
- export interface LoggerLevels {
7
- release: LoggerLevel;
8
- staging: LoggerLevel;
9
- dev: LoggerLevel;
5
+ interface LoggerModes {
6
+ release: LoggerMode;
7
+ staging: LoggerMode;
8
+ dev: LoggerMode;
10
9
  }
11
- export declare enum LoggerLevelNames {
12
- release = "release",
13
- staging = "staging",
14
- dev = "dev"
10
+ export declare enum LoggerModeNames {
11
+ Release = "release",
12
+ Staging = "staging",
13
+ Dev = "dev"
15
14
  }
16
- export declare enum Severities {
17
- log = "log",
18
- warn = "warn",
19
- error = "error"
15
+ export declare enum LogTypes {
16
+ Info = "info",
17
+ Warn = "warn",
18
+ Error = "error"
20
19
  }
21
20
  /**
22
- * Temporary class to use instead of console.log so it's
23
- * easy to migrate int he future.
21
+ * Epigraph's Logger class that provides various modes and functionalities to easily
22
+ * manage logging within our solutions in a consistent manner.
23
+ *
24
+ * Some common terminologies are:
25
+ * Mode: A logger's mode defines what log types would be automatically executed and
26
+ * what would be ignored.
24
27
  */
25
28
  declare class EpigraphLogger {
26
29
  context: string;
27
- private _levels;
28
- private _level;
30
+ private _allModes;
31
+ private _currentMode;
29
32
  /**
30
33
  * @param {string} [context="EPIGRAPH-LOGGER"] Used to categorise each message within
31
34
  * the console.
32
35
  * @example,CORE, UI
33
36
  */
34
37
  constructor(context: string);
35
- get levels(): LoggerLevels;
36
- setLevel(newValue: LoggerLevelNames): void;
37
- private _isSeverityAllowedInCurrentLevel;
38
- log(title?: string, details?: ILoggerDetails): void;
39
- warn(title?: string, details?: ILoggerDetails): void;
40
- error(title?: string, details?: ILoggerDetails): void;
41
- table(title?: string, details?: ILoggerDetails, severity?: Severities): void;
42
- group(title: string, severity?: Severities): void;
43
- groupCollapsed(title: string, severity?: Severities): void;
38
+ get modes(): LoggerModes;
39
+ /**
40
+ *
41
+ * @param {LoggerModeNames} newValue Sets the logger mode of the current instance.
42
+ */
43
+ setCurrentMode(newValue: LoggerModeNames): void;
44
+ private _isLogTypeAllowedInCurrentMode;
45
+ /**
46
+ * A log type that doesn't necessarily need to be looked at by the end user.
47
+ * This can be any generic log that would be ignored in most logger modes except verbose.
48
+ *
49
+ * @param {string} title A short title for this log.
50
+ * @param {any} details Any optional detail that would be shown if this log was expanded in the console.
51
+ * @param {string | undefined} contextOverride Allows the user to specify where this log
52
+ * was recorded from. For eg. Core and Ui can pass in different values for this
53
+ * paramater to make it easy to debug. If not provided, the default context would be used
54
+ * that was provided at the time of initialisation of this class.
55
+ */
56
+ info(title?: string, details?: any, contextOverride?: string | undefined): void;
57
+ /**
58
+ * A warning log type that let's the user know that some action that could be dangerous was just
59
+ * performed and might need attention.
60
+ *
61
+ * @param {string} title A short title for this log.
62
+ * @param {any} details Any optional detail that would be shown if this log was expanded in the console.
63
+ * @param {string | undefined} contextOverride Allows the user to specify where this log
64
+ * was recorded from. For eg. Core and Ui can pass in different values for this
65
+ * paramater to make it easy to debug. If not provided, the default context would be used
66
+ * that was provided at the time of initialisation of this class.
67
+ */
68
+ warn(title?: string, details?: any, contextOverride?: string | undefined): void;
69
+ /**
70
+ * A critical error log type that let's the user know that some action that was unexpected and required immediate attention.
71
+ *
72
+ * @param {string} title A short title for this log.
73
+ * @param {any} details Any optional detail that would be shown if this log was expanded in the console.
74
+ * @param {string | undefined} contextOverride Allows the user to specify where this log
75
+ * was recorded from. For eg. Core and Ui can pass in different values for this
76
+ * paramater to make it easy to debug. If not provided, the default context would be used
77
+ * that was provided at the time of initialisation of this class.
78
+ */
79
+ error(title?: string, details?: any, contextOverride?: string | undefined): void;
80
+ /**
81
+ * A table log type that can show an object in an organised manner within the console.
82
+ * This is primarily for the visual purposes and doesn't provide any additional functionality
83
+ * that other log types cannot provide.
84
+ *
85
+ * @param {string} title A short title for this log.
86
+ * @param {any} details Any optional detail that would be shown if this log was expanded in the console.
87
+ * @param {string | undefined} contextOverride Allows the user to specify where this log
88
+ * was recorded from. For eg. Core and Ui can pass in different values for this
89
+ * paramater to make it easy to debug. If not provided, the default context would be used
90
+ * that was provided at the time of initialisation of this class.
91
+ * @param {LogTypes} logType A
92
+ */
93
+ table(title?: string, details?: any, contextOverride?: string | undefined, logType?: LogTypes): void;
94
+ /**
95
+ * Begins an expanded group with the browser's console window.
96
+ * NOTE: Please remember to close this group once done using EpigraphLogger.groupEnd();
97
+ *
98
+ * @param {string} title A short title for this group.
99
+ * @param {string | undefined} contextOverride Allows the user to specify where this log
100
+ * was recorded from. For eg. Core and Ui can pass in different values for this
101
+ * paramater to make it easy to debug. If not provided, the default context would be used
102
+ * that was provided at the time of initialisation of this class.
103
+ * @param {LogTypes} logType A group can implictly of any log type, by default it is of type
104
+ * info but this parameter allows the user to override this.
105
+ * @returns {void}
106
+ */
107
+ group(title: string, contextOverride?: string | undefined, logType?: LogTypes): void;
108
+ /**
109
+ * Begins a collapsed group with the browser's console window.
110
+ * NOTE: Please remember to close this group once done using EpigraphLogger.groupEnd();
111
+ *
112
+ * @param {string} title A short title for this group.
113
+ * @param {string | undefined} contextOverride Allows the user to specify where this log
114
+ * was recorded from. For eg. Core and Ui can pass in different values for this
115
+ * paramater to make it easy to debug. If not provided, the default context would be used
116
+ * that was provided at the time of initialisation of this class.
117
+ * @param {LogTypes} logType A group can implictly of any log type, by default it is of type
118
+ * info but this parameter allows the user to override this.
119
+ * @returns {void}
120
+ */
121
+ groupCollapsed(title: string, contextOverride?: string | undefined, logType?: LogTypes): void;
122
+ /**
123
+ * Similar to the console.groupEnd(). Useful for ending either a group or
124
+ * groupCollapse that was initialised by this logger.
125
+ *
126
+ * @returns {void}
127
+ */
44
128
  groupEnd(): void;
45
129
  }
46
130
  export { EpigraphLogger };
@@ -31615,7 +31615,7 @@ const KR = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
31615
31615
  ModelViewerElement: dv,
31616
31616
  NearestFilter: pt
31617
31617
  }, Symbol.toStringTag, { value: "Module" }));
31618
- var GB = /* @__PURE__ */ ((a) => (a.release = "release", a.staging = "staging", a.dev = "dev", a))(GB || {}), zB = /* @__PURE__ */ ((a) => (a.log = "log", a.warn = "warn", a.error = "error", a))(zB || {});
31618
+ var GB = /* @__PURE__ */ ((a) => (a.Release = "release", a.Staging = "staging", a.Dev = "dev", a))(GB || {}), zB = /* @__PURE__ */ ((a) => (a.Info = "info", a.Warn = "warn", a.Error = "error", a))(zB || {});
31619
31619
  class jR {
31620
31620
  /**
31621
31621
  * @param {string} [context="EPIGRAPH-LOGGER"] Used to categorise each message within
@@ -31624,61 +31624,172 @@ class jR {
31624
31624
  */
31625
31625
  constructor(e) {
31626
31626
  Ca(this, "context", "EPIGRAPH-LOGGER");
31627
- Ca(this, "_levels", {
31628
- release: { name: "release", allows: ["error"] },
31629
- staging: { name: "staging", allows: ["warn", "error"] },
31630
- dev: { name: "dev", allows: ["log", "warn", "error"] }
31627
+ Ca(this, "_allModes", {
31628
+ release: { name: "release", allows: [
31629
+ "error"
31630
+ /* Error */
31631
+ ] },
31632
+ staging: { name: "staging", allows: [
31633
+ "warn",
31634
+ "error"
31635
+ /* Error */
31636
+ ] },
31637
+ dev: {
31638
+ name: "dev",
31639
+ allows: [
31640
+ "info",
31641
+ "warn",
31642
+ "error"
31643
+ /* Error */
31644
+ ]
31645
+ }
31631
31646
  });
31632
- Ca(this, "_level", "release");
31647
+ Ca(this, "_currentMode", "release");
31633
31648
  e && (this.context = e.toLocaleUpperCase());
31634
31649
  }
31635
- get levels() {
31636
- return this._levels;
31650
+ get modes() {
31651
+ return this._allModes;
31637
31652
  }
31638
- setLevel(e) {
31639
- if (!Object.keys(this._levels).includes(e)) {
31640
- console.warn(`"${e}": is not a valid logger level`);
31653
+ /**
31654
+ *
31655
+ * @param {LoggerModeNames} newValue Sets the logger mode of the current instance.
31656
+ */
31657
+ setCurrentMode(e) {
31658
+ if (!Object.keys(this._allModes).includes(e)) {
31659
+ console.warn(`"${e}": is not a valid logger mode`);
31641
31660
  return;
31642
31661
  }
31643
- this._level = e;
31662
+ this._currentMode = e;
31644
31663
  }
31645
- _isSeverityAllowedInCurrentLevel(e) {
31646
- return this._levels[this._level].allows.includes(e);
31664
+ _isLogTypeAllowedInCurrentMode(e) {
31665
+ return this._allModes[this._currentMode].allows.includes(e);
31647
31666
  }
31648
- log(e = "", t = "") {
31649
- this._isSeverityAllowedInCurrentLevel(
31650
- "log"
31651
- /* log */
31652
- ) && (console.groupCollapsed(`[${this.context}]: ${e}`), console.log(t), console.groupCollapsed("Traceback..."), console.trace(), console.groupEnd(), console.groupEnd());
31667
+ /**
31668
+ * A log type that doesn't necessarily need to be looked at by the end user.
31669
+ * This can be any generic log that would be ignored in most logger modes except verbose.
31670
+ *
31671
+ * @param {string} title A short title for this log.
31672
+ * @param {any} details Any optional detail that would be shown if this log was expanded in the console.
31673
+ * @param {string | undefined} contextOverride Allows the user to specify where this log
31674
+ * was recorded from. For eg. Core and Ui can pass in different values for this
31675
+ * paramater to make it easy to debug. If not provided, the default context would be used
31676
+ * that was provided at the time of initialisation of this class.
31677
+ */
31678
+ info(e = "", t = "", n = void 0) {
31679
+ if (!this._isLogTypeAllowedInCurrentMode(
31680
+ "info"
31681
+ /* Info */
31682
+ ))
31683
+ return;
31684
+ const i = n || this.context;
31685
+ console.groupCollapsed(`[${i}]: ${e}`), console.log(t), console.groupCollapsed("Traceback..."), console.trace(), console.groupEnd(), console.groupEnd();
31653
31686
  }
31654
- warn(e = "", t = "") {
31655
- this._isSeverityAllowedInCurrentLevel(
31687
+ /**
31688
+ * A warning log type that let's the user know that some action that could be dangerous was just
31689
+ * performed and might need attention.
31690
+ *
31691
+ * @param {string} title A short title for this log.
31692
+ * @param {any} details Any optional detail that would be shown if this log was expanded in the console.
31693
+ * @param {string | undefined} contextOverride Allows the user to specify where this log
31694
+ * was recorded from. For eg. Core and Ui can pass in different values for this
31695
+ * paramater to make it easy to debug. If not provided, the default context would be used
31696
+ * that was provided at the time of initialisation of this class.
31697
+ */
31698
+ warn(e = "", t = "", n = void 0) {
31699
+ if (!this._isLogTypeAllowedInCurrentMode(
31656
31700
  "warn"
31657
- /* warn */
31658
- ) && (console.groupCollapsed(
31659
- `%c[${this.context}]: ${e}`,
31660
- "color: orange;"
31661
- ), console.warn(t), console.groupCollapsed("Traceback..."), console.trace(), console.groupEnd(), console.groupEnd());
31662
- }
31663
- error(e = "", t = "") {
31664
- this._isSeverityAllowedInCurrentLevel(
31701
+ /* Warn */
31702
+ ))
31703
+ return;
31704
+ const i = n || this.context;
31705
+ console.groupCollapsed(`%c[${i}]: ${e}`, "color: orange;"), console.warn(t), console.groupCollapsed("Traceback..."), console.trace(), console.groupEnd(), console.groupEnd();
31706
+ }
31707
+ /**
31708
+ * A critical error log type that let's the user know that some action that was unexpected and required immediate attention.
31709
+ *
31710
+ * @param {string} title A short title for this log.
31711
+ * @param {any} details Any optional detail that would be shown if this log was expanded in the console.
31712
+ * @param {string | undefined} contextOverride Allows the user to specify where this log
31713
+ * was recorded from. For eg. Core and Ui can pass in different values for this
31714
+ * paramater to make it easy to debug. If not provided, the default context would be used
31715
+ * that was provided at the time of initialisation of this class.
31716
+ */
31717
+ error(e = "", t = "", n = void 0) {
31718
+ if (!this._isLogTypeAllowedInCurrentMode(
31665
31719
  "error"
31666
- /* error */
31667
- ) && (console.groupCollapsed(`%c[${this.context}]: ${e}`, "color: red;"), console.error(t), console.groupCollapsed("Traceback..."), console.trace(), console.groupEnd(), console.groupEnd());
31720
+ /* Error */
31721
+ ))
31722
+ return;
31723
+ const i = n || this.context;
31724
+ console.groupCollapsed(`%c[${i}]: ${e}`, "color: red;"), console.error(t), console.groupCollapsed("Traceback..."), console.trace(), console.groupEnd(), console.groupEnd();
31668
31725
  }
31669
- table(e = "", t = {}, n) {
31670
- n || (n = "log"), this._isSeverityAllowedInCurrentLevel(n) && (console.groupCollapsed(`[${this.context}]: ${e}`), console.table(t), console.groupCollapsed("Traceback..."), console.trace(), console.groupEnd(), console.groupEnd());
31726
+ /**
31727
+ * A table log type that can show an object in an organised manner within the console.
31728
+ * This is primarily for the visual purposes and doesn't provide any additional functionality
31729
+ * that other log types cannot provide.
31730
+ *
31731
+ * @param {string} title A short title for this log.
31732
+ * @param {any} details Any optional detail that would be shown if this log was expanded in the console.
31733
+ * @param {string | undefined} contextOverride Allows the user to specify where this log
31734
+ * was recorded from. For eg. Core and Ui can pass in different values for this
31735
+ * paramater to make it easy to debug. If not provided, the default context would be used
31736
+ * that was provided at the time of initialisation of this class.
31737
+ * @param {LogTypes} logType A
31738
+ */
31739
+ table(e = "", t = {}, n = void 0, i = "info") {
31740
+ if (!this._isLogTypeAllowedInCurrentMode(i))
31741
+ return;
31742
+ const s = n || this.context;
31743
+ console.groupCollapsed(`[${s}]: ${e}`), console.table(t), console.groupCollapsed("Traceback..."), console.trace(), console.groupEnd(), console.groupEnd();
31671
31744
  }
31672
- group(e, t) {
31673
- t || (t = "log"), this._isSeverityAllowedInCurrentLevel(t) && console.group(`%c ${this.context} GROUP`, e);
31745
+ /**
31746
+ * Begins an expanded group with the browser's console window.
31747
+ * NOTE: Please remember to close this group once done using EpigraphLogger.groupEnd();
31748
+ *
31749
+ * @param {string} title A short title for this group.
31750
+ * @param {string | undefined} contextOverride Allows the user to specify where this log
31751
+ * was recorded from. For eg. Core and Ui can pass in different values for this
31752
+ * paramater to make it easy to debug. If not provided, the default context would be used
31753
+ * that was provided at the time of initialisation of this class.
31754
+ * @param {LogTypes} logType A group can implictly of any log type, by default it is of type
31755
+ * info but this parameter allows the user to override this.
31756
+ * @returns {void}
31757
+ */
31758
+ group(e, t = void 0, n = "info") {
31759
+ if (!this._isLogTypeAllowedInCurrentMode(n))
31760
+ return;
31761
+ const i = t || this.context;
31762
+ console.group(`%c ${i} GROUP`, e);
31674
31763
  }
31675
- groupCollapsed(e, t) {
31676
- t || (t = "log"), this._isSeverityAllowedInCurrentLevel(t) && console.groupCollapsed(`%c ${this.context} GROUP`, e);
31764
+ /**
31765
+ * Begins a collapsed group with the browser's console window.
31766
+ * NOTE: Please remember to close this group once done using EpigraphLogger.groupEnd();
31767
+ *
31768
+ * @param {string} title A short title for this group.
31769
+ * @param {string | undefined} contextOverride Allows the user to specify where this log
31770
+ * was recorded from. For eg. Core and Ui can pass in different values for this
31771
+ * paramater to make it easy to debug. If not provided, the default context would be used
31772
+ * that was provided at the time of initialisation of this class.
31773
+ * @param {LogTypes} logType A group can implictly of any log type, by default it is of type
31774
+ * info but this parameter allows the user to override this.
31775
+ * @returns {void}
31776
+ */
31777
+ groupCollapsed(e, t = void 0, n = "info") {
31778
+ if (!this._isLogTypeAllowedInCurrentMode(n))
31779
+ return;
31780
+ const i = t || this.context;
31781
+ console.groupCollapsed(`%c ${i} GROUP`, e);
31677
31782
  }
31783
+ /**
31784
+ * Similar to the console.groupEnd(). Useful for ending either a group or
31785
+ * groupCollapse that was initialised by this logger.
31786
+ *
31787
+ * @returns {void}
31788
+ */
31678
31789
  groupEnd() {
31679
- this._isSeverityAllowedInCurrentLevel(
31680
- "log"
31681
- /* log */
31790
+ this._isLogTypeAllowedInCurrentMode(
31791
+ "info"
31792
+ /* Info */
31682
31793
  ) && (console.log("----------------------------------"), console.groupEnd());
31683
31794
  }
31684
31795
  }
@@ -33085,7 +33196,8 @@ export {
33085
33196
  Yt as Loader,
33086
33197
  ha as LoaderUtils,
33087
33198
  j0 as LoadingManager,
33088
- GB as LoggerLevelNames,
33199
+ zB as LogTypes,
33200
+ GB as LoggerModeNames,
33089
33201
  g0 as LoopOnce,
33090
33202
  Qd as LoopPingPong,
33091
33203
  Fd as LoopRepeat,
@@ -33215,7 +33327,6 @@ export {
33215
33327
  Wf as SIGNED_RED_RGTC1_Format,
33216
33328
  Bn as SRGBColorSpace,
33217
33329
  wi as Scene,
33218
- zB as Severities,
33219
33330
  Ge as ShaderChunk,
33220
33331
  $n as ShaderLib,
33221
33332
  En as ShaderMaterial,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@epigraph/epigraph-std-lib",
3
- "version": "1.1.0",
3
+ "version": "2.0.1",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "/dist"