@gesslar/toolkit 5.3.0 → 5.5.0

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/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "name": "gesslar",
6
6
  "url": "https://gesslar.dev"
7
7
  },
8
- "version": "5.3.0",
8
+ "version": "5.5.0",
9
9
  "license": "0BSD",
10
10
  "homepage": "https://github.com/gesslar/toolkit#readme",
11
11
  "repository": {
@@ -77,17 +77,16 @@
77
77
  },
78
78
  "dependencies": {
79
79
  "@gesslar/colours": "^1.0.0",
80
- "ajv": "^8.18.0",
81
80
  "json5": "^2.2.3",
82
81
  "supports-color": "^10.2.2",
83
- "yaml": "^2.8.3"
82
+ "yaml": "^2.9.0"
84
83
  },
85
84
  "devDependencies": {
86
85
  "@gesslar/uglier": "^2.4.1",
87
86
  "@rollup/plugin-node-resolve": "^16.0.3",
88
- "eslint": "^10.2.0",
89
- "happy-dom": "^20.9.0",
90
- "rollup": "^4.60.1",
87
+ "eslint": "^10.4.1",
88
+ "happy-dom": "^20.10.2",
89
+ "rollup": "^4.61.1",
91
90
  "typescript": "^6.0.3"
92
91
  }
93
92
  }
@@ -7,10 +7,10 @@
7
7
  */
8
8
 
9
9
  import Data from "./Data.js"
10
- import Valid from "./Valid.js"
11
10
  import Sass from "./Sass.js"
12
- import Util from "./Util.js"
13
11
  import TypeSpec from "./TypeSpec.js"
12
+ import Util from "./Util.js"
13
+ import Valid from "./Valid.js"
14
14
 
15
15
  /**
16
16
  * Utility class for collection operations.
@@ -166,25 +166,37 @@ export default class Util {
166
166
  Valid.type(supplied, "String", {allowEmpty: false})
167
167
  Valid.type(target, "String", {allowEmpty: false})
168
168
 
169
- const suppliedSemver = supplied.split(".").filter(Boolean).map(Number).filter(e => !isNaN(e))
170
- const targetSemver = target.split(".").filter(Boolean).map(Number).filter(e => !isNaN(e))
169
+ const {major: sMajor, minor: sMinor, patch: sPatch} =
170
+ this.semver.basic.exec(supplied)?.groups ?? {}
171
+ const {major: tMajor, minor: tMinor, patch: tPatch} =
172
+ this.semver.basic.exec(target)?.groups ?? {}
171
173
 
172
- Valid.assert(suppliedSemver.length === 3, "Invalid format for supplied semver.")
173
- Valid.assert(targetSemver.length === 3, "Invalid format for target semver.")
174
+ Valid.assert(Boolean(sMajor && sMinor && sPatch), "Invalid format for supplied semver.")
175
+ Valid.assert(Boolean(tMajor && tMinor && tPatch), "Invalid format for target semver.")
174
176
 
175
- if(suppliedSemver[0] < targetSemver[0])
177
+ const isMajor = Number(sMajor)
178
+ const itMajor = Number(tMajor)
179
+ if(isMajor < itMajor)
176
180
  return false
177
181
 
178
- if(suppliedSemver[0] === targetSemver[0]) {
179
- if(suppliedSemver[1] < targetSemver[1])
182
+ if(isMajor === itMajor) {
183
+ const isMinor = Number(sMinor)
184
+ const itMinor = Number(tMinor)
185
+ if(isMinor < itMinor)
180
186
  return false
181
187
 
182
- if(suppliedSemver[1] === targetSemver[1])
183
- if(suppliedSemver[2] < targetSemver[2])
188
+ if(isMinor === itMinor) {
189
+ const isPatch = Number(sPatch)
190
+ const itPatch = Number(tPatch)
191
+ if(isPatch < itPatch)
184
192
  return false
193
+ }
185
194
  }
186
195
 
187
196
  return true
188
- }
197
+ },
198
+
199
+ basic: /^(?<major>0|(?:[1-9]\d*))\.(?<minor>0|(?:[1-9]\d*))\.(?<patch>0|(?:[1-9]\d*))$/,
200
+ enhanced: /^(?<major>0|(?:[1-9]\d*))\.(?<minor>0|(?:[1-9]\d*))\.(?<patch>0|(?:[1-9]\d*))(?:-(?<prerelease>(?:0|(?:[1-9A-Za-z-][0-9A-Za-z-]*))(?:\.(?:0|(?:[1-9A-Za-z-][0-9A-Za-z-]*)))*))?(?:\+(?<build>(?:0|(?:[1-9A-Za-z-][0-9A-Za-z-]*))(?:\.(?:0|(?:[1-9A-Za-z-][0-9A-Za-z-]*)))*))?$/
189
201
  }
190
202
  }
@@ -12,6 +12,7 @@
12
12
  */
13
13
 
14
14
  import {createRequire} from "node:module"
15
+ import {stripVTControlCharacters} from "node:util"
15
16
 
16
17
  import c from "@gesslar/colours"
17
18
 
@@ -19,6 +20,26 @@ import Data from "../../browser/lib/Data.js"
19
20
  import Term from "./Term.js"
20
21
  import Util from "../../browser/lib/Util.js"
21
22
 
23
+ /**
24
+ * Apply `@gesslar/colours` formatting, then defer to Term for colour support.
25
+ *
26
+ * The colour template must always be evaluated so that `@gesslar/colours`
27
+ * format tokens (e.g. `{F019}`) are resolved out of the text. When Term reports
28
+ * that the terminal lacks colour support, the resulting ANSI escape sequences
29
+ * are stripped so only plain text remains.
30
+ *
31
+ * @param {Array<string>} strings - Template strings.
32
+ * @param {...unknown} values - Template values.
33
+ * @returns {string} Formatted text, with ANSI stripped when colour is unsupported.
34
+ */
35
+ function paint(strings, ...values) {
36
+ const formatted = c(strings, ...values)
37
+
38
+ return Term.hasColor
39
+ ? formatted
40
+ : stripVTControlCharacters(formatted)
41
+ }
42
+
22
43
  // Auto-detect VS Code extension environment
23
44
  let vscodeApi = null
24
45
  try {
@@ -40,7 +61,7 @@ try {
40
61
  * @property {string} success - Colour code for success messages
41
62
  * @property {string} reset - Colour reset code
42
63
  */
43
- export const loggerColours = {
64
+ const loggerColours = {
44
65
  debug: [
45
66
  "{F019}", // Debug level 0: Dark blue
46
67
  "{F027}", // Debug level 1: Medium blue
@@ -65,7 +86,7 @@ export const loggerColours = {
65
86
  * @property {string} error - Symbol for error messages
66
87
  * @property {string} success - Symbol for success messages
67
88
  */
68
- export const logSymbols = {
89
+ const logSymbols = {
69
90
  debug: "?",
70
91
  info: "i",
71
92
  warn: "!",
@@ -547,13 +568,13 @@ class Glog {
547
568
  const colourCode = colours[level][debugLevel] || colours[level][0]
548
569
 
549
570
  return useStrings
550
- ? c`${namePrefix}${colourCode}${tag}{/}: ${message}`
551
- : c`${namePrefix}${colourCode}${tag}{/} ${message}`
571
+ ? paint`${namePrefix}${colourCode}${tag}{/}: ${message}`
572
+ : paint`${namePrefix}${colourCode}${tag}{/} ${message}`
552
573
  }
553
574
 
554
575
  return useStrings
555
- ? c`${namePrefix}${colours[level]}${tag}{/}: ${message}`
556
- : c`${namePrefix}${colours[level]}${tag}{/} ${message}`
576
+ ? paint`${namePrefix}${colours[level]}${tag}{/}: ${message}`
577
+ : paint`${namePrefix}${colours[level]}${tag}{/} ${message}`
557
578
  }
558
579
 
559
580
  /**
@@ -707,7 +728,7 @@ class Glog {
707
728
  * @example logger.colourize`{success}Operation completed{/} in {bold}${time}ms{/}`
708
729
  */
709
730
  colourize(strings, ...values) {
710
- const message = c(strings, ...values)
731
+ const message = paint(strings, ...values)
711
732
  const name = this.#name || Glog.name || "Log"
712
733
 
713
734
  Term.log(`[${name}] ${message}`)
@@ -720,7 +741,7 @@ class Glog {
720
741
  * @param {...unknown} values - Template values
721
742
  */
722
743
  static colourize(strings, ...values) {
723
- const message = c(strings, ...values)
744
+ const message = paint(strings, ...values)
724
745
  const name = this.name || "Log"
725
746
 
726
747
  Term.log(`[${name}] ${message}`)
@@ -750,8 +771,8 @@ class Glog {
750
771
  const tag = useStrings ? "Success" : symbols.success
751
772
  const colourCode = colours.success || "{F046}"
752
773
  const formatted = useStrings
753
- ? c`[${name}] ${colourCode}${tag}{/}: ${message}`
754
- : c`[${name}] ${colourCode}${tag}{/} ${message}`
774
+ ? paint`[${name}] ${colourCode}${tag}{/}: ${message}`
775
+ : paint`[${name}] ${colourCode}${tag}{/} ${message}`
755
776
 
756
777
  Term.log(formatted, ...args)
757
778
  }
@@ -789,8 +810,8 @@ class Glog {
789
810
  const tag = useStrings ? "Debug" : symbols.debug
790
811
  const colourCode = colours.debug[level] || colours.debug[0]
791
812
  const label = useStrings
792
- ? c`[${name}] ${colourCode}${tag}{/}: ${message}`
793
- : c`[${name}] ${colourCode}${tag}{/} ${message}`
813
+ ? paint`[${name}] ${colourCode}${tag}{/}: ${message}`
814
+ : paint`[${name}] ${colourCode}${tag}{/} ${message}`
794
815
 
795
816
  Term.group(label)
796
817
  }
@@ -807,8 +828,8 @@ class Glog {
807
828
  const symbols = this.symbols || logSymbols
808
829
  const tag = useStrings ? "Info" : symbols.info
809
830
  const label = useStrings
810
- ? c`[${name}] ${colours.info}${tag}{/}: ${message}`
811
- : c`[${name}] ${colours.info}${tag}{/} ${message}`
831
+ ? paint`[${name}] ${colours.info}${tag}{/}: ${message}`
832
+ : paint`[${name}] ${colours.info}${tag}{/} ${message}`
812
833
 
813
834
  Term.group(label)
814
835
  }
@@ -824,8 +845,8 @@ class Glog {
824
845
  const symbols = this.symbols || logSymbols
825
846
  const tag = useStrings ? "Success" : symbols.success
826
847
  const label = useStrings
827
- ? c`[${name}] {success}${tag}{/}: ${message}`
828
- : c`[${name}] {success}${tag}{/} ${message}`
848
+ ? paint`[${name}] {success}${tag}{/}: ${message}`
849
+ : paint`[${name}] {success}${tag}{/} ${message}`
829
850
 
830
851
  Term.group(label)
831
852
  }
@@ -883,8 +904,8 @@ class Glog {
883
904
  const tag = useStrings ? "Success" : symbols.success
884
905
  const namePrefix = showName ? `[${name}] ` : ""
885
906
  const label = useStrings
886
- ? c`${namePrefix}{success}${tag}{/}: ${message}`
887
- : c`${namePrefix}{success}${tag}{/} ${message}`
907
+ ? paint`${namePrefix}{success}${tag}{/}: ${message}`
908
+ : paint`${namePrefix}{success}${tag}{/} ${message}`
888
909
 
889
910
  Term.group(label)
890
911
  }
@@ -912,7 +933,7 @@ class Glog {
912
933
  }
913
934
 
914
935
  if(label) {
915
- Term.log(c`[${this.#name || Glog.name || "Log"}] {info}Table{/}: ${label}`)
936
+ Term.log(paint`[${this.#name || Glog.name || "Log"}] {info}Table{/}: ${label}`)
916
937
  }
917
938
 
918
939
  Term.table(data, tableOptions)
@@ -941,7 +962,7 @@ class Glog {
941
962
  }
942
963
 
943
964
  if(label) {
944
- Term.log(c`[${this.name || "Log"}] {info}Table{/}: ${label}`)
965
+ Term.log(paint`[${this.name || "Log"}] {info}Table{/}: ${label}`)
945
966
  }
946
967
 
947
968
  Term.table(data, tableOptions)
@@ -1,4 +1,4 @@
1
- import {watch} from "node:fs/promises"
1
+ import {realpath, watch} from "node:fs/promises"
2
2
  import Valid from "./Valid.js"
3
3
  import Data from "./Data.js"
4
4
  import Time from "../../browser/lib/Time.js"
@@ -52,7 +52,8 @@ export default class Watcher {
52
52
  this.#abortController = new AbortController()
53
53
 
54
54
  for(const target of targets) {
55
- const watcher = watch(target.url, {
55
+ const watchPath = await realpath(target.path).catch(() => target.path)
56
+ const watcher = watch(watchPath, {
56
57
  recursive: target.isDirectory ? recursive : false,
57
58
  persistent,
58
59
  signal: this.#abortController.signal,
@@ -60,6 +60,8 @@ export default class Util {
60
60
  static regexify(input: any, trim?: boolean, flags?: any[]): RegExp;
61
61
  static semver: {
62
62
  meetsOrExceeds: (supplied: any, target: any) => boolean;
63
+ basic: RegExp;
64
+ enhanced: RegExp;
63
65
  };
64
66
  }
65
67
  //# sourceMappingURL=Util.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Util.d.ts","sourceRoot":"","sources":["../../../src/browser/lib/Util.js"],"names":[],"mappings":"AAGA;;;GAGG;AACH;IACE;;;;;OAKG;IACH,wBAHW,MAAM,GACJ,MAAM,CAYlB;IAED;;;;;;OAMG;IACH,YAJa,CAAC,MACH,MAAM,OAAO,CAAC,CAAC,CAAC,GACd,OAAO,CAAC;QAAC,MAAM,EAAE,CAAC,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAC,CAAC,CAQ9C;IAED;;;;;;;OAOG;IACH,4BAJW,MAAM,GAAC,MAAM,UACb,MAAM,GACJ,MAAM,CAWlB;IAED;;;;;;;OAOG;IACH,6BAJW,MAAM,GAAC,MAAM,UACb,MAAM,GACJ,MAAM,CAalB;IAED;;;;;;OAMG;IACH,8BAJW,MAAM,KACN,MAAM,GACJ,MAAM,CAsBlB;IAED;;;;;;;;OAQG;IACH,+BALW,MAAM,iBACN,KAAK,CAAC,MAAM,CAAC,cACb,MAAM,GACJ,MAAM,CAwBlB;IAED,mEAkBC;IAED;;MAyBC;CACF"}
1
+ {"version":3,"file":"Util.d.ts","sourceRoot":"","sources":["../../../src/browser/lib/Util.js"],"names":[],"mappings":"AAGA;;;GAGG;AACH;IACE;;;;;OAKG;IACH,wBAHW,MAAM,GACJ,MAAM,CAYlB;IAED;;;;;;OAMG;IACH,YAJa,CAAC,MACH,MAAM,OAAO,CAAC,CAAC,CAAC,GACd,OAAO,CAAC;QAAC,MAAM,EAAE,CAAC,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAC,CAAC,CAQ9C;IAED;;;;;;;OAOG;IACH,4BAJW,MAAM,GAAC,MAAM,UACb,MAAM,GACJ,MAAM,CAWlB;IAED;;;;;;;OAOG;IACH,6BAJW,MAAM,GAAC,MAAM,UACb,MAAM,GACJ,MAAM,CAalB;IAED;;;;;;OAMG;IACH,8BAJW,MAAM,KACN,MAAM,GACJ,MAAM,CAsBlB;IAED;;;;;;;;OAQG;IACH,+BALW,MAAM,iBACN,KAAK,CAAC,MAAM,CAAC,cACb,MAAM,GACJ,MAAM,CAwBlB;IAED,mEAkBC;IAED;;;;MAqCC;CACF"}
@@ -1,26 +1,3 @@
1
- /**
2
- * Default colour configuration for logger output using @gesslar/colours format
3
- *
4
- * @type {object}
5
- * @property {string[]} debug - Array of 5 colour codes for debug levels 0-4
6
- * @property {string} info - Colour code for info messages
7
- * @property {string} warn - Colour code for warning messages
8
- * @property {string} error - Colour code for error messages
9
- * @property {string} success - Colour code for success messages
10
- * @property {string} reset - Colour reset code
11
- */
12
- export const loggerColours: object;
13
- /**
14
- * Symbol characters used for log level tags when colours are disabled or tagsAsStrings is false
15
- *
16
- * @type {object}
17
- * @property {string} debug - Symbol for debug messages
18
- * @property {string} info - Symbol for info messages
19
- * @property {string} warn - Symbol for warning messages
20
- * @property {string} error - Symbol for error messages
21
- * @property {string} success - Symbol for success messages
22
- */
23
- export const logSymbols: object;
24
1
  declare const _default: typeof Glog;
25
2
  export default _default;
26
3
  declare class Glog {
@@ -1 +1 @@
1
- {"version":3,"file":"Glog.d.ts","sourceRoot":"","sources":["../../../src/node/lib/Glog.js"],"names":[],"mappings":"AA+BA;;;;;;;;;;GAUG;AACH,4BARU,MAAM,CAqBf;AAED;;;;;;;;;GASG;AACH,yBAPU,MAAM,CAaf;;;AAED;IAEE,wBAAmB;IACnB,yBAAqB;IACrB,oBAAqB;IACrB,2BAAyB;IACzB,oBAAgB;IAChB,8BAA4B;IAC5B,oBAAqB;IAiFrB;;;;;OAKG;IACH,4BAHW,MAAM,GACJ,OAAO,IAAI,CAMvB;IAED;;;;;OAKG;IACH,0BAHW,MAAM,GACJ,OAAO,IAAI,CAMvB;IAED;;;;;OAKG;IACH,sBAHW,MAAM,GACJ,OAAO,IAAI,CAMvB;IAED;;;;;;;;;;OAUG;IACH,6BAHW,MAAM,GACJ,OAAO,IAAI,CAMvB;IAED;;;;;OAKG;IACH,gCAHW,OAAO,GACL,OAAO,IAAI,CAMvB;IAED;;;;;OAKG;IACH,mCAHW,OAAO,GACL,OAAO,IAAI,CAMvB;IAED;;;;;;;;;;OAUG;IACH,6BALW,MAAM,GACJ,OAAO,IAAI,CAQvB;IAED;;;;;;;;;OASG;IACH,mBANW,MAAM,GACJ,MAAM,CAyClB;IAID;;;;;OAKG;IACH,wBAHW,MAAM,GACJ,IAAI,CAIhB;IAyVD;;;;;OAKG;IACH,wBAFc,OAAO,EAAA,QAsBpB;IA4BD;;;;;OAKG;IACH,0BAHW,KAAK,CAAC,MAAM,CAAC,aACV,OAAO,EAAA,QAOpB;IAYD;;;;;OAKG;IACH,wBAHW,MAAM,WACH,OAAO,EAAA,QAcpB;IAED;;;;OAIG;IACH,sBAFc,OAAO,EAAA,QAOpB;IAED;;OAEG;IACH,wBAEC;IAED;;;;;OAKG;IACH,2BAHW,MAAM,UACN,MAAM,QAchB;IAED;;;;OAIG;IACH,0BAFW,MAAM,QAahB;IAED;;;;OAIG;IACH,6BAFW,MAAM,QAYhB;IA0FD;;;;;;;;;OASG;IACH,mBA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;IAED;;;;OAIG;IACH,iBAFa,IAAI,CAMhB;IAED;;;;;;;;;OASG;IACH,YANW,MAAM,GACJ,MAAM,CA2ClB;IAID;;;;OAIG;IACH,YAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,kBAFa,MAAM,CAIlB;IAED;;;;;;;;;OASG;IACH,eAPa,MAAM,CAelB;IA+CD;;;;;OAKG;IACH,cAHW,MAAM,YAYhB;IA8BD;;;;;;;;;OASG;IACH,eALW,MAAM,UACN,MAAM,UACH,OAAO,EAAA,QAapB;IAED;;;;;OAKG;IACH,cAHW,MAAM,UACH,OAAO,EAAA,QAMpB;IAED;;;;;OAKG;IACH,cAHW,MAAM,UACH,OAAO,EAAA,QAMpB;IAED;;;;;OAKG;IACH,eAHW,MAAM,UACH,OAAO,EAAA,QAMpB;IA8BD;;;;;OAKG;IACH,iBAFc,OAAO,EAAA,QAIpB;IAID;;;;;;OAMG;IACH,mBAJW,KAAK,CAAC,MAAM,CAAC,aACV,OAAO,EAAA,QAQpB;IAeD;;;;;OAKG;IACH,iBAHW,MAAM,WACH,OAAO,EAAA,QAIpB;IAgGD;;;;OAIG;IACH,eAFc,OAAO,EAAA,QASpB;IAED;;OAEG;IACH,iBAEC;IAED;;;;;OAKG;IACH,oBAHW,MAAM,UACN,MAAM,QAIhB;IAED;;;;OAIG;IACH,mBAFW,MAAM,QAIhB;IAED;;;;OAIG;IACH,sBAFW,MAAM,QAchB;IAED;;;;;;;;;OASG;IACH,YAPW,MAAM,QAAQ,mBACd,MAAM,GAAG,MAAM,YAEvB;QAAgC,UAAU,GAAlC,KAAK,CAAC,MAAM,CAAC;QACK,UAAU,GAA5B,OAAO;QACW,aAAa,GAA/B,OAAO;KACjB,QAkBA;IA4CD;;;;OAIG;IACH,iDAEC;IAED;;;;;;;;;;;;;OAaG;IACH,WAXa,MAAM,CAuBlB;;CA6BF"}
1
+ {"version":3,"file":"Glog.d.ts","sourceRoot":"","sources":["../../../src/node/lib/Glog.js"],"names":[],"mappings":";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B;IAED;;;;;;;;;OASG;IACH,eAPa,MAAM,CAelB;IA+CD;;;;;OAKG;IACH,cAHW,MAAM,YAYhB;IA8BD;;;;;;;;;OASG;IACH,eALW,MAAM,UACN,MAAM,UACH,OAAO,EAAA,QAapB;IAED;;;;;OAKG;IACH,cAHW,MAAM,UACH,OAAO,EAAA,QAMpB;IAED;;;;;OAKG;IACH,cAHW,MAAM,UACH,OAAO,EAAA,QAMpB;IAED;;;;;OAKG;IACH,eAHW,MAAM,UACH,OAAO,EAAA,QAMpB;IA8BD;;;;;OAKG;IACH,iBAFc,OAAO,EAAA,QAIpB;IAID;;;;;;OAMG;IACH,mBAJW,KAAK,CAAC,MAAM,CAAC,aACV,OAAO,EAAA,QAQpB;IAeD;;;;;OAKG;IACH,iBAHW,MAAM,WACH,OAAO,EAAA,QAIpB;IAgGD;;;;OAIG;IACH,eAFc,OAAO,EAAA,QASpB;IAED;;OAEG;IACH,iBAEC;IAED;;;;;OAKG;IACH,oBAHW,MAAM,UACN,MAAM,QAIhB;IAED;;;;OAIG;IACH,mBAFW,MAAM,QAIhB;IAED;;;;OAIG;IACH,sBAFW,MAAM,QAchB;IAED;;;;;;;;;OASG;IACH,YAPW,MAAM,QAAQ,mBACd,MAAM,GAAG,MAAM,YAEvB;QAAgC,UAAU,GAAlC,KAAK,CAAC,MAAM,CAAC;QACK,UAAU,GAA5B,OAAO;QACW,aAAa,GAA/B,OAAO;KACjB,QAkBA;IA4CD;;;;OAIG;IACH,iDAEC;IAED;;;;;;;;;;;;;OAaG;IACH,WAXa,MAAM,CAuBlB;;CA6BF"}
@@ -1 +1 @@
1
- {"version":3,"file":"Watcher.d.ts","sourceRoot":"","sources":["../../../src/node/lib/Watcher.js"],"names":[],"mappings":"AAKA;;;GAGG;AAEH;;;GAGE;AAEF;IAIE;;;;;;;;;;;;OAYG;IACH,eATW,UAAU,GAAC,eAAe,GAAC,KAAK,CAAE,CAAC,UAAU,GAAC,eAAe,CAAC,CAAC,8DAEvE;QAA8D,QAAQ,EAA9D,CAAC,MAAM,EAAE,UAAU,GAAC,eAAe,KAAK,IAAI;QAC3B,UAAU,GAA3B,MAAM;QACY,UAAU,GAA5B,OAAO;QACW,SAAS,GAA3B,OAAO;QACU,QAAQ,GAAzB,MAAM;KACd,GAAU,OAAO,CAAC,SAAS,CAAC,CA6E9B;IAED;;OAEG;IACH,qBAIC;;CACF;4BA/G0B,iBAAiB;iCACZ,sBAAsB"}
1
+ {"version":3,"file":"Watcher.d.ts","sourceRoot":"","sources":["../../../src/node/lib/Watcher.js"],"names":[],"mappings":"AAKA;;;GAGG;AAEH;;;GAGE;AAEF;IAIE;;;;;;;;;;;;OAYG;IACH,eATW,UAAU,GAAC,eAAe,GAAC,KAAK,CAAE,CAAC,UAAU,GAAC,eAAe,CAAC,CAAC,8DAEvE;QAA8D,QAAQ,EAA9D,CAAC,MAAM,EAAE,UAAU,GAAC,eAAe,KAAK,IAAI;QAC3B,UAAU,GAA3B,MAAM;QACY,UAAU,GAA5B,OAAO;QACW,SAAS,GAA3B,OAAO;QACU,QAAQ,GAAzB,MAAM;KACd,GAAU,OAAO,CAAC,SAAS,CAAC,CA8E9B;IAED;;OAEG;IACH,qBAIC;;CACF;4BAhH0B,iBAAiB;iCACZ,sBAAsB"}
@@ -1,4 +1,4 @@
1
- // @gesslar/toolkit v5.3.0 - ES module bundle
1
+ // @gesslar/toolkit v5.5.0 - ES module bundle
2
2
  /**
3
3
  * @file Tantrum.js
4
4
  *
@@ -559,26 +559,38 @@ class Util {
559
559
  Valid.type(supplied, "String", {allowEmpty: false});
560
560
  Valid.type(target, "String", {allowEmpty: false});
561
561
 
562
- const suppliedSemver = supplied.split(".").filter(Boolean).map(Number).filter(e => !isNaN(e));
563
- const targetSemver = target.split(".").filter(Boolean).map(Number).filter(e => !isNaN(e));
562
+ const {major: sMajor, minor: sMinor, patch: sPatch} =
563
+ this.semver.basic.exec(supplied)?.groups ?? {};
564
+ const {major: tMajor, minor: tMinor, patch: tPatch} =
565
+ this.semver.basic.exec(target)?.groups ?? {};
564
566
 
565
- Valid.assert(suppliedSemver.length === 3, "Invalid format for supplied semver.");
566
- Valid.assert(targetSemver.length === 3, "Invalid format for target semver.");
567
+ Valid.assert(Boolean(sMajor && sMinor && sPatch), "Invalid format for supplied semver.");
568
+ Valid.assert(Boolean(tMajor && tMinor && tPatch), "Invalid format for target semver.");
567
569
 
568
- if(suppliedSemver[0] < targetSemver[0])
570
+ const isMajor = Number(sMajor);
571
+ const itMajor = Number(tMajor);
572
+ if(isMajor < itMajor)
569
573
  return false
570
574
 
571
- if(suppliedSemver[0] === targetSemver[0]) {
572
- if(suppliedSemver[1] < targetSemver[1])
575
+ if(isMajor === itMajor) {
576
+ const isMinor = Number(sMinor);
577
+ const itMinor = Number(tMinor);
578
+ if(isMinor < itMinor)
573
579
  return false
574
580
 
575
- if(suppliedSemver[1] === targetSemver[1])
576
- if(suppliedSemver[2] < targetSemver[2])
581
+ if(isMinor === itMinor) {
582
+ const isPatch = Number(sPatch);
583
+ const itPatch = Number(tPatch);
584
+ if(isPatch < itPatch)
577
585
  return false
586
+ }
578
587
  }
579
588
 
580
589
  return true
581
- }
590
+ },
591
+
592
+ basic: /^(?<major>0|(?:[1-9]\d*))\.(?<minor>0|(?:[1-9]\d*))\.(?<patch>0|(?:[1-9]\d*))$/,
593
+ enhanced: /^(?<major>0|(?:[1-9]\d*))\.(?<minor>0|(?:[1-9]\d*))\.(?<patch>0|(?:[1-9]\d*))(?:-(?<prerelease>(?:0|(?:[1-9A-Za-z-][0-9A-Za-z-]*))(?:\.(?:0|(?:[1-9A-Za-z-][0-9A-Za-z-]*)))*))?(?:\+(?<build>(?:0|(?:[1-9A-Za-z-][0-9A-Za-z-]*))(?:\.(?:0|(?:[1-9A-Za-z-][0-9A-Za-z-]*)))*))?$/
582
594
  }
583
595
  }
584
596
 
@@ -1,4 +1,4 @@
1
- // @gesslar/toolkit v5.3.0 - UMD bundle
1
+ // @gesslar/toolkit v5.5.0 - UMD bundle
2
2
  (function (global, factory) {
3
3
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
4
4
  typeof define === 'function' && define.amd ? define(['exports'], factory) :
@@ -565,26 +565,38 @@
565
565
  Valid.type(supplied, "String", {allowEmpty: false});
566
566
  Valid.type(target, "String", {allowEmpty: false});
567
567
 
568
- const suppliedSemver = supplied.split(".").filter(Boolean).map(Number).filter(e => !isNaN(e));
569
- const targetSemver = target.split(".").filter(Boolean).map(Number).filter(e => !isNaN(e));
568
+ const {major: sMajor, minor: sMinor, patch: sPatch} =
569
+ this.semver.basic.exec(supplied)?.groups ?? {};
570
+ const {major: tMajor, minor: tMinor, patch: tPatch} =
571
+ this.semver.basic.exec(target)?.groups ?? {};
570
572
 
571
- Valid.assert(suppliedSemver.length === 3, "Invalid format for supplied semver.");
572
- Valid.assert(targetSemver.length === 3, "Invalid format for target semver.");
573
+ Valid.assert(Boolean(sMajor && sMinor && sPatch), "Invalid format for supplied semver.");
574
+ Valid.assert(Boolean(tMajor && tMinor && tPatch), "Invalid format for target semver.");
573
575
 
574
- if(suppliedSemver[0] < targetSemver[0])
576
+ const isMajor = Number(sMajor);
577
+ const itMajor = Number(tMajor);
578
+ if(isMajor < itMajor)
575
579
  return false
576
580
 
577
- if(suppliedSemver[0] === targetSemver[0]) {
578
- if(suppliedSemver[1] < targetSemver[1])
581
+ if(isMajor === itMajor) {
582
+ const isMinor = Number(sMinor);
583
+ const itMinor = Number(tMinor);
584
+ if(isMinor < itMinor)
579
585
  return false
580
586
 
581
- if(suppliedSemver[1] === targetSemver[1])
582
- if(suppliedSemver[2] < targetSemver[2])
587
+ if(isMinor === itMinor) {
588
+ const isPatch = Number(sPatch);
589
+ const itPatch = Number(tPatch);
590
+ if(isPatch < itPatch)
583
591
  return false
592
+ }
584
593
  }
585
594
 
586
595
  return true
587
- }
596
+ },
597
+
598
+ basic: /^(?<major>0|(?:[1-9]\d*))\.(?<minor>0|(?:[1-9]\d*))\.(?<patch>0|(?:[1-9]\d*))$/,
599
+ enhanced: /^(?<major>0|(?:[1-9]\d*))\.(?<minor>0|(?:[1-9]\d*))\.(?<patch>0|(?:[1-9]\d*))(?:-(?<prerelease>(?:0|(?:[1-9A-Za-z-][0-9A-Za-z-]*))(?:\.(?:0|(?:[1-9A-Za-z-][0-9A-Za-z-]*)))*))?(?:\+(?<build>(?:0|(?:[1-9A-Za-z-][0-9A-Za-z-]*))(?:\.(?:0|(?:[1-9A-Za-z-][0-9A-Za-z-]*)))*))?$/
588
600
  }
589
601
  }
590
602
 
@@ -1,196 +0,0 @@
1
- import Data from "./Data.js"
2
- import Valid from "./Valid.js"
3
-
4
- /**
5
- * @typedef {object} OObjectArrayInfo
6
- * @property {Array<string>} path - The path array to the array element
7
- * @property {string} flatPath - The dot-separated path to the array element
8
- * @property {number} index - The index of the element in the array
9
- */
10
-
11
- /**
12
- * @typedef {object} OObjectEntry
13
- * @property {string} key - The property key
14
- * @property {any} value - The property value
15
- * @property {string} valueString - String representation of the value
16
- * @property {Array<string>} path - The path array to this property
17
- * @property {string} flatPath - The dot-separated path to this property
18
- * @property {OObjectArrayInfo} [array] - Array information if this entry is from an array
19
- */
20
-
21
- /**
22
- * @typedef {Record<string, any> | Array<any>} OObjectSource
23
- */
24
-
25
- export default class OObject {
26
- /** @type {Array<OObjectEntry>} */
27
- #data = []
28
-
29
- /**
30
- * Constructs an OObject with optional initial data.
31
- *
32
- * @param {Array<OObjectEntry>} oobject
33
- */
34
- constructor(oobject=[]) {
35
- this.#data = oobject
36
- }
37
-
38
- /**
39
- * Creates an OObject from a source object or array
40
- *
41
- * @param {OObjectSource} source - The source object or array to decompose
42
- * @returns {OObject} A new OObject instance
43
- */
44
- static from(source) {
45
- Valid.type(source, "Object|Array")
46
-
47
- return new this(this.#decomposeObject(source))
48
- }
49
-
50
- /**
51
- * Decomposes a nested object into flat entries with path information.
52
- * Recursively processes objects and arrays to create a flat structure for
53
- * evaluation.
54
- *
55
- * @param {Record<string, any>} work - The object to decompose
56
- * @param {Array<string>} objectPath - Current path array for nested properties
57
- * @returns {Array<OObjectEntry>} Array of decomposed object entries with path information
58
- */
59
- static #decomposeObject(work, objectPath=[]) {
60
- Valid.type(work, "Object|Array")
61
- Valid.type(objectPath, "Array")
62
-
63
- const result = []
64
-
65
- for(const key in work) {
66
- const currPath = [...objectPath, key]
67
- const item = work[key]
68
-
69
- if(Data.isPlainObject(item)) {
70
- result.push(...this.#decomposeObject(work[key], currPath))
71
- } else if(Array.isArray(work[key])) {
72
- work[key].forEach((item, index) => {
73
- const path = [...currPath, String(index+1)]
74
-
75
- if(Data.isPlainObject(item)) {
76
- result.push(...this.#decomposeObject(item, path))
77
- } else {
78
- result.push({
79
- key,
80
- value: item,
81
- valueString: String(item),
82
- path,
83
- flatPath: path.join("."),
84
- array: {
85
- path: path.slice(0, -1),
86
- flatPath: path.slice(0, -1).join("."),
87
- index
88
- }
89
- })
90
- }
91
- })
92
- } else {
93
- result.push({key, value: item, valueString: String(item), path: currPath, flatPath: currPath.join(".")})
94
- }
95
- }
96
-
97
- return result
98
- }
99
-
100
- /**
101
- * Gets the internal data array
102
- *
103
- * @returns {Array<object>} The decomposed object entries
104
- */
105
- get data() {
106
- return this.#data
107
- }
108
-
109
- /**
110
- * Finds the first entry matching a flat path or predicate
111
- *
112
- * @param {string|((entry: OObjectEntry, index: number, array: Array<OObjectEntry>) => boolean)} pathOrPredicate - Flat path string or predicate function
113
- * @returns {OObjectEntry|undefined} The matching entry or undefined
114
- */
115
- find(pathOrPredicate) {
116
- if(typeof pathOrPredicate === "string") {
117
- return this.#data.find(entry => entry.flatPath === pathOrPredicate)
118
- }
119
-
120
- Valid.type(pathOrPredicate, "function")
121
-
122
- return this.#data.find(pathOrPredicate)
123
- }
124
-
125
- /**
126
- * Finds all entries matching a flat path or predicate
127
- *
128
- * @param {string|((entry: OObjectEntry, index: number, array: Array<OObjectEntry>) => boolean)} pathOrPredicate - Flat path string or predicate function
129
- * @returns {Array<object>} Array of matching entries
130
- */
131
- findAll(pathOrPredicate) {
132
- if(typeof pathOrPredicate === "string") {
133
- return this.#data.filter(entry => entry.flatPath === pathOrPredicate)
134
- }
135
-
136
- Valid.type(pathOrPredicate, "function")
137
-
138
- return this.#data.filter(pathOrPredicate)
139
- }
140
-
141
- /**
142
- * Returns an iterator over all entries in order
143
- *
144
- * @returns {Iterator<object>} Iterator of decomposed entries
145
- */
146
- entries() {
147
- return this.#data[Symbol.iterator]()
148
- }
149
-
150
- /**
151
- * Executes a callback for each entry in order
152
- *
153
- * @param {(entry: OObjectEntry, index: number, array: Array<OObjectEntry>) => void} callback - Function to call for each entry
154
- * @returns {void}
155
- */
156
- forEach(callback) {
157
- Valid.type(callback, "function")
158
-
159
- this.#data.forEach(callback)
160
- }
161
-
162
- /**
163
- * Ensures a path exists in the data, optionally setting a value
164
- *
165
- * @param {string} flatPath - The dot-separated path to ensure
166
- * @param {*} value - Optional value to set (defaults to undefined)
167
- * @returns {object} The entry at the path
168
- */
169
- assurePath(flatPath, value=undefined) {
170
- Valid.type(flatPath, "string")
171
-
172
- let entry = this.find(flatPath)
173
-
174
- if(!entry) {
175
- const path = flatPath.split(".")
176
- const key = path[path.length - 1]
177
-
178
- /** @type {OObjectEntry} */
179
- const newEntry = {
180
- key,
181
- value,
182
- valueString: String(value),
183
- path,
184
- flatPath
185
- }
186
-
187
- this.#data.push(newEntry)
188
- entry = newEntry
189
- } else if(value !== undefined) {
190
- entry.value = value
191
- entry.valueString = String(value)
192
- }
193
-
194
- return entry
195
- }
196
- }
@@ -1,185 +0,0 @@
1
- /*
2
- For formatting console info, see:
3
- https://nodejs.org/docs/latest-v22.x/api/util.html#utilformatformat-args
4
-
5
- * %s: String will be used to convert all values except BigInt, Object and -0.
6
- BigInt values will be represented with an n and Objects that have no
7
- user defined toString function are inspected using util.inspect() with
8
- options { depth: 0, colors: false, compact: 3 }.
9
- * %d: Number will be used to convert all values except BigInt and Symbol.
10
- * %i: parseInt(value, 10) is used for all values except BigInt and Symbol.
11
- * %f: parseFloat(value) is used for all values except Symbol.
12
- * %j: JSON. Replaced with the string '[Circular]' if the argument contains
13
- circular references.
14
- * %o: Object. A string representation of an object with generic JavaScript
15
- object formatting. Similar to util.inspect() with options { showHidden:
16
- true, showProxy: true }. This will show the full object including non-
17
- enumerable properties and proxies.
18
- * %O: Object. A string representation of an object with generic JavaScript
19
- object formatting. Similar to util.inspect() without options. This will
20
- show the full object not including non-enumerable properties and
21
- proxies.
22
- * %%: single percent sign ('%'). This does not consume an argument.
23
-
24
- */
25
-
26
- import ErrorStackParser from "error-stack-parser"
27
- import console from "node:console"
28
- import {Environment} from "./Core.js"
29
- import {FileObject, Util} from "../../../types/node/index.js"
30
-
31
- export const loggerColours = {
32
- debug: [
33
- "\x1b[38;5;19m", // Debug level 0: Dark blue
34
- "\x1b[38;5;27m", // Debug level 1: Medium blue
35
- "\x1b[38;5;33m", // Debug level 2: Light blue
36
- "\x1b[38;5;39m", // Debug level 3: Teal
37
- "\x1b[38;5;44m", // Debug level 4: Blue-tinted cyan
38
- ],
39
- info: "\x1b[38;5;36m", // Medium Spring Green
40
- warn: "\x1b[38;5;214m", // Orange1
41
- error: "\x1b[38;5;196m", // Red1
42
- reset: "\x1b[0m", // Reset
43
- }
44
-
45
- /**
46
- * Logger class
47
- *
48
- * Log levels:
49
- * - debug: Debugging information
50
- * - Debug levels
51
- * - 0: No/critical debug information, not error level, but, should be
52
- * logged
53
- * - 1: Basic debug information, startup, shutdown, etc
54
- * - 2: Intermediate debug information, discovery, starting to get more
55
- * detailed
56
- * - 3: Detailed debug information, parsing, processing, etc
57
- * - 4: Very detailed debug information, nerd mode!
58
- * - warn: Warning information
59
- * - info: Informational information
60
- * - error: Error information
61
- */
62
-
63
- export default class Logger {
64
- #name = null
65
- #debugLevel = 0
66
-
67
- constructor(options) {
68
- this.#name = "BeDoc"
69
- if(options) {
70
- this.setOptions(options)
71
- if(options.env === Environment.EXTENSION) {
72
- const vscode = import("vscode")
73
-
74
- this.vscodeError = vscode.window.showErrorMessage
75
- this.vscodeWarn = vscode.window.showWarningMessage
76
- this.vscodeInfo = vscode.window.showInformationMessage
77
- }
78
- }
79
- }
80
-
81
- get name() {
82
- return this.#name
83
- }
84
-
85
- get debugLevel() {
86
- return this.#debugLevel
87
- }
88
-
89
- get options() {
90
- return {
91
- name: this.#name,
92
- debugLevel: this.#debugLevel,
93
- }
94
- }
95
-
96
- setOptions(options) {
97
- this.#name = options.name ?? this.#name
98
- this.#debugLevel = options.debugLevel
99
- }
100
-
101
- #compose(level, message, debugLevel = 0) {
102
- const tag = Util.capitalize(level)
103
-
104
- if(level === "debug")
105
- return `[${this.#name}] ${loggerColours[level][debugLevel]}${tag}${loggerColours.reset}: ${message}`
106
-
107
- return `[${this.#name}] ${loggerColours[level]}${tag}${loggerColours.reset}: ${message}`
108
- }
109
-
110
- lastStackLine(error = new Error(), stepsRemoved = 3) {
111
- const stack = ErrorStackParser.parse(error)
112
-
113
- return stack[stepsRemoved]
114
- }
115
-
116
- extractFileFunction(level = 0) {
117
- const frame = this.lastStackLine()
118
- const {
119
- functionName: func,
120
- fileName: file,
121
- lineNumber: line,
122
- columnNumber: col,
123
- } = frame
124
-
125
- const tempFile = new FileObject(file)
126
- const {module, uri} = tempFile
127
-
128
- let functionName = func ?? "anonymous"
129
-
130
- if(functionName.startsWith("#"))
131
- functionName = `${module}.${functionName}`
132
-
133
- const methodName = /\[as \w+\]$/.test(functionName)
134
- ? /\[as (\w+)\]/.exec(functionName)[1]
135
- : null
136
-
137
- if(methodName) {
138
- functionName = functionName.replace(/\[as \w+\]$/, "")
139
- functionName = `${functionName}{${methodName}}`
140
- }
141
-
142
- if(/^async /.test(functionName))
143
- functionName = functionName.replace(/^async /, "(async)")
144
-
145
- let result = functionName
146
-
147
- if(level >= 2)
148
- result = `${result}:${line}:${col}`
149
-
150
- if(level >= 3)
151
- result = `${uri} ${result}`
152
-
153
- return result
154
- }
155
-
156
- newDebug(tag) {
157
- return function(message, level, ...arg) {
158
- tag = this.extractFileFunction(this.#debugLevel)
159
- this.debug(`[${tag}] ${message}`, level, ...arg)
160
- }.bind(this)
161
- }
162
-
163
- debug(message, level = 0, ...arg) {
164
- if(level <= (this.debugLevel ?? 4))
165
- console.debug(this.#compose("debug", message, level), ...arg)
166
- }
167
-
168
- warn(message, ...arg) {
169
- console.warn(this.#compose("warn", message), ...arg)
170
- this.vscodeWarn?.(JSON.stringify(message))
171
- }
172
-
173
- info(message, ...arg) {
174
- console.info(this.#compose("info", message), ...arg)
175
- this.vscodeInfo?.(JSON.stringify(message))
176
- }
177
-
178
- error(message, ...arg) {
179
- console.error(this.#compose("error", message), ...arg)
180
- this.vscodeError?.(JSON.stringify(message))
181
- }
182
- }
183
-
184
- // NOTE: This is an artifact file kept for reference during Glog development.
185
- // Not exported from toolkit. Has broken imports to ./Core.js (actions package).
@@ -1,127 +0,0 @@
1
- /**
2
- * @typedef {object} OObjectArrayInfo
3
- * @property {Array<string>} path - The path array to the array element
4
- * @property {string} flatPath - The dot-separated path to the array element
5
- * @property {number} index - The index of the element in the array
6
- */
7
- /**
8
- * @typedef {object} OObjectEntry
9
- * @property {string} key - The property key
10
- * @property {any} value - The property value
11
- * @property {string} valueString - String representation of the value
12
- * @property {Array<string>} path - The path array to this property
13
- * @property {string} flatPath - The dot-separated path to this property
14
- * @property {OObjectArrayInfo} [array] - Array information if this entry is from an array
15
- */
16
- /**
17
- * @typedef {Record<string, any> | Array<any>} OObjectSource
18
- */
19
- export default class OObject {
20
- /**
21
- * Creates an OObject from a source object or array
22
- *
23
- * @param {OObjectSource} source - The source object or array to decompose
24
- * @returns {OObject} A new OObject instance
25
- */
26
- static from(source: OObjectSource): OObject;
27
- /**
28
- * Decomposes a nested object into flat entries with path information.
29
- * Recursively processes objects and arrays to create a flat structure for
30
- * evaluation.
31
- *
32
- * @param {Record<string, any>} work - The object to decompose
33
- * @param {Array<string>} objectPath - Current path array for nested properties
34
- * @returns {Array<OObjectEntry>} Array of decomposed object entries with path information
35
- */
36
- static #decomposeObject(work: Record<string, any>, objectPath?: Array<string>): Array<OObjectEntry>;
37
- /**
38
- * Constructs an OObject with optional initial data.
39
- *
40
- * @param {Array<OObjectEntry>} oobject
41
- */
42
- constructor(oobject?: Array<OObjectEntry>);
43
- /**
44
- * Gets the internal data array
45
- *
46
- * @returns {Array<object>} The decomposed object entries
47
- */
48
- get data(): Array<object>;
49
- /**
50
- * Finds the first entry matching a flat path or predicate
51
- *
52
- * @param {string|((entry: OObjectEntry, index: number, array: Array<OObjectEntry>) => boolean)} pathOrPredicate - Flat path string or predicate function
53
- * @returns {OObjectEntry|undefined} The matching entry or undefined
54
- */
55
- find(pathOrPredicate: string | ((entry: OObjectEntry, index: number, array: Array<OObjectEntry>) => boolean)): OObjectEntry | undefined;
56
- /**
57
- * Finds all entries matching a flat path or predicate
58
- *
59
- * @param {string|((entry: OObjectEntry, index: number, array: Array<OObjectEntry>) => boolean)} pathOrPredicate - Flat path string or predicate function
60
- * @returns {Array<object>} Array of matching entries
61
- */
62
- findAll(pathOrPredicate: string | ((entry: OObjectEntry, index: number, array: Array<OObjectEntry>) => boolean)): Array<object>;
63
- /**
64
- * Returns an iterator over all entries in order
65
- *
66
- * @returns {Iterator<object>} Iterator of decomposed entries
67
- */
68
- entries(): Iterator<object>;
69
- /**
70
- * Executes a callback for each entry in order
71
- *
72
- * @param {(entry: OObjectEntry, index: number, array: Array<OObjectEntry>) => void} callback - Function to call for each entry
73
- * @returns {void}
74
- */
75
- forEach(callback: (entry: OObjectEntry, index: number, array: Array<OObjectEntry>) => void): void;
76
- /**
77
- * Ensures a path exists in the data, optionally setting a value
78
- *
79
- * @param {string} flatPath - The dot-separated path to ensure
80
- * @param {*} value - Optional value to set (defaults to undefined)
81
- * @returns {object} The entry at the path
82
- */
83
- assurePath(flatPath: string, value?: any): object;
84
- #private;
85
- }
86
- export type OObjectArrayInfo = {
87
- /**
88
- * - The path array to the array element
89
- */
90
- path: Array<string>;
91
- /**
92
- * - The dot-separated path to the array element
93
- */
94
- flatPath: string;
95
- /**
96
- * - The index of the element in the array
97
- */
98
- index: number;
99
- };
100
- export type OObjectEntry = {
101
- /**
102
- * - The property key
103
- */
104
- key: string;
105
- /**
106
- * - The property value
107
- */
108
- value: any;
109
- /**
110
- * - String representation of the value
111
- */
112
- valueString: string;
113
- /**
114
- * - The path array to this property
115
- */
116
- path: Array<string>;
117
- /**
118
- * - The dot-separated path to this property
119
- */
120
- flatPath: string;
121
- /**
122
- * - Array information if this entry is from an array
123
- */
124
- array?: OObjectArrayInfo;
125
- };
126
- export type OObjectSource = Record<string, any> | Array<any>;
127
- //# sourceMappingURL=OObject.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"OObject.d.ts","sourceRoot":"","sources":["../../../src/browser/lib/OObject.js"],"names":[],"mappings":"AAGA;;;;;GAKG;AAEH;;;;;;;;GAQG;AAEH;;GAEG;AAEH;IAaE;;;;;OAKG;IACH,oBAHW,aAAa,GACX,OAAO,CAMnB;IAED;;;;;;;;OAQG;IACH,8BAJW,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,eACnB,KAAK,CAAC,MAAM,CAAC,GACX,KAAK,CAAC,YAAY,CAAC,CAyC/B;IArED;;;;OAIG;IACH,sBAFW,KAAK,CAAC,YAAY,CAAC,EAI7B;IAgED;;;;OAIG;IACH,YAFa,KAAK,CAAC,MAAM,CAAC,CAIzB;IAED;;;;;OAKG;IACH,sBAHW,MAAM,GAAC,CAAC,CAAC,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,YAAY,CAAC,KAAK,OAAO,CAAC,GAClF,YAAY,GAAC,SAAS,CAUlC;IAED;;;;;OAKG;IACH,yBAHW,MAAM,GAAC,CAAC,CAAC,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,YAAY,CAAC,KAAK,OAAO,CAAC,GAClF,KAAK,CAAC,MAAM,CAAC,CAUzB;IAED;;;;OAIG;IACH,WAFa,QAAQ,CAAC,MAAM,CAAC,CAI5B;IAED;;;;;OAKG;IACH,kBAHW,CAAC,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,YAAY,CAAC,KAAK,IAAI,GACtE,IAAI,CAMhB;IAED;;;;;;OAMG;IACH,qBAJW,MAAM,UACN,GAAC,GACC,MAAM,CA4BlB;;CACF;;;;;UA9La,KAAK,CAAC,MAAM,CAAC;;;;cACb,MAAM;;;;WACN,MAAM;;;;;;SAKN,MAAM;;;;WACN,GAAG;;;;iBACH,MAAM;;;;UACN,KAAK,CAAC,MAAM,CAAC;;;;cACb,MAAM;;;;YACN,gBAAgB;;4BAIjB,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC"}
@@ -1,46 +0,0 @@
1
- export namespace loggerColours {
2
- let debug: string[];
3
- let info: string;
4
- let warn: string;
5
- let error: string;
6
- let reset: string;
7
- }
8
- /**
9
- * Logger class
10
- *
11
- * Log levels:
12
- * - debug: Debugging information
13
- * - Debug levels
14
- * - 0: No/critical debug information, not error level, but, should be
15
- * logged
16
- * - 1: Basic debug information, startup, shutdown, etc
17
- * - 2: Intermediate debug information, discovery, starting to get more
18
- * detailed
19
- * - 3: Detailed debug information, parsing, processing, etc
20
- * - 4: Very detailed debug information, nerd mode!
21
- * - warn: Warning information
22
- * - info: Informational information
23
- * - error: Error information
24
- */
25
- export default class Logger {
26
- constructor(options: any);
27
- vscodeError: any;
28
- vscodeWarn: any;
29
- vscodeInfo: any;
30
- get name(): any;
31
- get debugLevel(): number;
32
- get options(): {
33
- name: any;
34
- debugLevel: number;
35
- };
36
- setOptions(options: any): void;
37
- lastStackLine(error?: Error, stepsRemoved?: number): any;
38
- extractFileFunction(level?: number): any;
39
- newDebug(tag: any): any;
40
- debug(message: any, level?: number, ...arg: any[]): void;
41
- warn(message: any, ...arg: any[]): void;
42
- info(message: any, ...arg: any[]): void;
43
- error(message: any, ...arg: any[]): void;
44
- #private;
45
- }
46
- //# sourceMappingURL=Logger.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Logger.d.ts","sourceRoot":"","sources":["../../../src/node/lib/Logger.js"],"names":[],"mappings":";;;;;;;AA4CA;;;;;;;;;;;;;;;;GAgBG;AAEH;IAIE,0BAYC;IALK,iBAAiD;IACjD,gBAAkD;IAClD,gBAAsD;IAK5D,gBAEC;IAED,yBAEC;IAED;;;MAKC;IAED,+BAGC;IAWD,yDAIC;IAED,yCAsCC;IAED,wBAKC;IAED,yDAGC;IAED,wCAGC;IAED,wCAGC;IAED,yCAGC;;CACF"}