@gesslar/toolkit 3.42.0 → 4.1.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/README.md +1 -0
- package/package.json +4 -4
- package/src/browser/lib/Collection.js +1 -2
- package/src/browser/lib/Data.js +4 -4
- package/src/browser/lib/TypeSpec.js +115 -39
- package/src/node/index.js +2 -1
- package/src/node/lib/Cache.js +105 -35
- package/src/node/lib/Data.js +49 -0
- package/src/node/lib/DirectoryObject.js +4 -7
- package/src/node/lib/FileObject.js +89 -53
- package/src/node/lib/FileSystem.js +47 -2
- package/src/node/lib/Font.js +1 -1
- package/src/node/lib/Glog.js +47 -28
- package/src/node/lib/Notify.js +6 -6
- package/src/node/lib/Sass.js +3 -6
- package/src/node/lib/Term.js +11 -11
- package/src/node/lib/Util.js +3 -3
- package/src/node/lib/Valid.js +3 -6
- package/src/node/lib/Watcher.js +118 -0
- package/types/browser/lib/Collection.d.ts.map +1 -1
- package/types/browser/lib/Data.d.ts +2 -8
- package/types/browser/lib/Data.d.ts.map +1 -1
- package/types/browser/lib/TypeSpec.d.ts +21 -36
- package/types/browser/lib/TypeSpec.d.ts.map +1 -1
- package/types/node/index.d.ts +2 -1
- package/types/node/lib/Cache.d.ts +36 -5
- package/types/node/lib/Cache.d.ts.map +1 -1
- package/types/node/lib/Data.d.ts +19 -0
- package/types/node/lib/Data.d.ts.map +1 -0
- package/types/node/lib/DirectoryObject.d.ts +6 -5
- package/types/node/lib/DirectoryObject.d.ts.map +1 -1
- package/types/node/lib/FileObject.d.ts +54 -26
- package/types/node/lib/FileObject.d.ts.map +1 -1
- package/types/node/lib/FileSystem.d.ts +19 -0
- package/types/node/lib/FileSystem.d.ts.map +1 -1
- package/types/node/lib/Glog.d.ts +2 -2
- package/types/node/lib/Glog.d.ts.map +1 -1
- package/types/node/lib/Notify.d.ts +10 -10
- package/types/node/lib/Notify.d.ts.map +1 -1
- package/types/node/lib/Sass.d.ts +7 -0
- package/types/node/lib/Sass.d.ts.map +1 -1
- package/types/node/lib/Term.d.ts +2 -9
- package/types/node/lib/Term.d.ts.map +1 -1
- package/types/node/lib/Util.d.ts +6 -6
- package/types/node/lib/Util.d.ts.map +1 -1
- package/types/node/lib/Valid.d.ts.map +1 -1
- package/types/node/lib/Watcher.d.ts +38 -0
- package/types/node/lib/Watcher.d.ts.map +1 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import {watch} from "node:fs/promises"
|
|
2
|
+
import Valid from "./Valid.js"
|
|
3
|
+
import Data from "./Data.js"
|
|
4
|
+
import Time from "../../browser/lib/Time.js"
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @import FileObject from "./FileObject.js"
|
|
8
|
+
* @import DirectoryObject from "./DirectoryObject.js"
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export const OverFlowBehaviour = Object.freeze({
|
|
12
|
+
IGNORE: "ignore",
|
|
13
|
+
THROW: "throw",
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
export default class Watcher {
|
|
17
|
+
#abortController
|
|
18
|
+
#state = new Map()
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Watch one or more file/directory targets for changes, invoking a callback
|
|
22
|
+
* with debounce protection.
|
|
23
|
+
*
|
|
24
|
+
* @param {FileObject|DirectoryObject|Array.<(FileObject|DirectoryObject)>} targets - The target(s) to watch
|
|
25
|
+
* @param {object} options - Watch options
|
|
26
|
+
* @param {(target: FileObject|DirectoryObject) => void} options.onChange - Callback invoked on change
|
|
27
|
+
* @param {number} [options.debounceMs=50] - Debounce interval in milliseconds
|
|
28
|
+
* @param {boolean} [options.persistent=true] - Keep the process alive while watching
|
|
29
|
+
* @param {boolean} [options.recursive=false] - Watch subdirectories (directories only)
|
|
30
|
+
* @param {string} [options.overflow="ignore"] - Overflow behaviour ("ignore" or "throw")
|
|
31
|
+
* @returns {Promise<undefined>}
|
|
32
|
+
*/
|
|
33
|
+
async watch(targets, {
|
|
34
|
+
onChange,
|
|
35
|
+
debounceMs=50,
|
|
36
|
+
persistent=true,
|
|
37
|
+
recursive=false,
|
|
38
|
+
overflow=OverFlowBehaviour.IGNORE
|
|
39
|
+
} = {}) {
|
|
40
|
+
Valid.type(targets, "FileObject|DirectoryObject|(FileObject|DirectoryObject)[]")
|
|
41
|
+
Valid.type(onChange, "Function")
|
|
42
|
+
Valid.type(debounceMs, "Number")
|
|
43
|
+
Valid.type(persistent, "Boolean")
|
|
44
|
+
Valid.type(recursive, "Undefined|Boolean")
|
|
45
|
+
Valid.type(overflow, "String")
|
|
46
|
+
Valid.assert(Object.values(OverFlowBehaviour).includes(overflow), `Overflow must be one of "ignore" or "throw".`)
|
|
47
|
+
|
|
48
|
+
if(!Data.isType(targets, "Array")) {
|
|
49
|
+
targets = [targets]
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
this.#abortController = new AbortController()
|
|
53
|
+
|
|
54
|
+
for(const target of targets) {
|
|
55
|
+
const watcher = watch(target.url, {
|
|
56
|
+
recursive: target.isDirectory ? recursive : false,
|
|
57
|
+
persistent,
|
|
58
|
+
signal: this.#abortController.signal,
|
|
59
|
+
overflow
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
this.#state.set(target, {busy: false, pending: false})
|
|
63
|
+
|
|
64
|
+
;(async() => {
|
|
65
|
+
try {
|
|
66
|
+
for await(const _ of watcher) {
|
|
67
|
+
const state = this.#state.get(target)
|
|
68
|
+
|
|
69
|
+
if(!state) {
|
|
70
|
+
return
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if(state.busy) {
|
|
74
|
+
state.pending = true
|
|
75
|
+
continue
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
state.pending = false
|
|
79
|
+
state.busy = true
|
|
80
|
+
|
|
81
|
+
while(true) {
|
|
82
|
+
await Time.after(debounceMs)
|
|
83
|
+
|
|
84
|
+
if(state.pending) {
|
|
85
|
+
state.pending = false
|
|
86
|
+
continue
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
break
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
try {
|
|
93
|
+
await onChange(target)
|
|
94
|
+
} catch(callbackErr) {
|
|
95
|
+
console.error("Watcher onChange callback error:", callbackErr)
|
|
96
|
+
}
|
|
97
|
+
state.busy = false
|
|
98
|
+
}
|
|
99
|
+
} catch(err) {
|
|
100
|
+
if(err.name === "AbortError") {
|
|
101
|
+
return
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
console.error("Watcher error:", err)
|
|
105
|
+
}
|
|
106
|
+
})()
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Stop watching all targets.
|
|
112
|
+
*/
|
|
113
|
+
stopWatching() {
|
|
114
|
+
this.#state.clear()
|
|
115
|
+
this.#abortController?.abort()
|
|
116
|
+
this.#abortController = null
|
|
117
|
+
}
|
|
118
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Collection.d.ts","sourceRoot":"","sources":["../../../src/browser/lib/Collection.js"],"names":[],"mappings":"AAcA;;;GAGG;AACH;IACE;;;;;;;;;OASG;IACH,6BANW,KAAK,CAAC,OAAO,CAAC,aACd,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK,OAAO,YACjE,OAAO,GACL,OAAO,GAAC,SAAS,CAqB7B;IAED;;;;;;;;OAQG;IACH,8BALW,MAAM,aACN,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,OAAO,GACtD,OAAO,GAAC,SAAS,CAmB7B;IAED;;;;;;;;OAQG;IACH,2BALW,GAAG,CAAC,OAAO,CAAC,aACZ,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,CAAC,OAAO,CAAC,KAAK,OAAO,GAC5C,OAAO,GAAC,SAAS,CAmB7B;IAED;;;;;;;;;OASG;IACH,2BANW,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,aACrB,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,KAAK,OAAO,YACrE,OAAO,GACL,OAAO,GAAC,SAAS,CAqB7B;IAED;;;;;;;OAOG;IACH,mBAJW,KAAK,CAAC,OAAO,CAAC,UACd,KAAK,CAAC,OAAO,CAAC,GACZ,KAAK,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAMrC;IAED;;;;;;OAMG;IACH,oBAHW,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,GACnB,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAsBjC;IAED;;;;;;;;OAQG;IACH,uBALW,KAAK,CAAC,OAAO,CAAC,WACd,CAAC,IAAI,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,GACjC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAkBnC;IAED;;;;;;;;OAQG;IACH,2BANW,KAAK,CAAC,OAAO,CAAC,SACd,MAAM,YACN,OAAO,GAEL,OAAO,
|
|
1
|
+
{"version":3,"file":"Collection.d.ts","sourceRoot":"","sources":["../../../src/browser/lib/Collection.js"],"names":[],"mappings":"AAcA;;;GAGG;AACH;IACE;;;;;;;;;OASG;IACH,6BANW,KAAK,CAAC,OAAO,CAAC,aACd,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK,OAAO,YACjE,OAAO,GACL,OAAO,GAAC,SAAS,CAqB7B;IAED;;;;;;;;OAQG;IACH,8BALW,MAAM,aACN,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,OAAO,GACtD,OAAO,GAAC,SAAS,CAmB7B;IAED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O,CAAC,GACZ,KAAK,CAAC,OAAO,CAAC,CAW1B;IAED;;;;;;;;OAQG;IACH,2BALW,KAAK,CAAC,OAAO,CAAC,WACd,KAAK,CAAC,OAAO,CAAC,GACZ,KAAK,CAAC,OAAO,CAAC,CAY1B;IAED;;;;;;;;OAQG;IACH,0BALW,KAAK,CAAC,OAAO,CAAC,WACd,KAAK,CAAC,OAAO,CAAC,GACZ,KAAK,CAAC,OAAO,CAAC,CAiB1B;IAED;;;;;;;OAOG;IACH,iCAJW,KAAK,CAAC,MAAM,CAAC,GACX,MAAM,CA0BlB;IAED;;;;;;OAMG;IACH,iCAHW,KAAK,CAAC,MAAM,CAAC,GAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,GAChC,MAAM,CAMlB;IAED;;;;;;;;;;;;;;OAcG;IACH,sBATW,MAAM,GAAC,KAAK,CAAC,OAAO,CAAC,WACrB,MAAM,GAAC,KAAK,CAAC,OAAO,CAAC,GACnB;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAC,CA8C7D;CACF"}
|
|
@@ -106,15 +106,9 @@ export default class Data {
|
|
|
106
106
|
* defining the type of a value and whether an array is expected.
|
|
107
107
|
*
|
|
108
108
|
* @param {string} string - The string to parse into a type spec.
|
|
109
|
-
* @
|
|
110
|
-
* @returns {Array<object>} An array of type specs.
|
|
109
|
+
* @returns {TypeSpec} A new TypeSpec instance.
|
|
111
110
|
*/
|
|
112
|
-
static newTypeSpec(string: string
|
|
113
|
-
/**
|
|
114
|
-
* - The delimiter for union types
|
|
115
|
-
*/
|
|
116
|
-
delimiter?: string;
|
|
117
|
-
}): Array<object>;
|
|
111
|
+
static newTypeSpec(string: string): TypeSpec;
|
|
118
112
|
/**
|
|
119
113
|
* Checks if a value is of a specified type
|
|
120
114
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Data.d.ts","sourceRoot":"","sources":["../../../src/browser/lib/Data.js"],"names":[],"mappings":"AAUA;IACA;;;;;OAKG;IACD,mBAFQ,KAAK,CAAC,MAAM,CAAC,CAgBnB;IAEF;;;;;OAKG;IACH,qBAFU,KAAK,CAAC,MAAM,CAAC,CAmBrB;IAEF;;;;;;;OAOG;IACH,kBAFU,KAAK,CAAC,MAAM,CAAC,CAKrB;IAEF;;;;;OAKG;IACH,uBAFU,KAAK,CAAC,MAAM,CAAC,CAE2D;IAElF;;;;;;OAMG;IACH,sBAJW,MAAM,UACN,MAAM,GACJ,MAAM,CAMlB;IAED;;;;;;OAMG;IACH,uBAJW,MAAM,WACN,MAAM,GACJ,MAAM,CAMlB;IAED;;;;;;;;;;;OAWG;IACH,yBATW,MAAM,UACN,MAAM,oBACN,OAAO,GACL,MAAM,CAWlB;IAED;;;;;;;;;;;OAWG;IACH,wBATW,MAAM,UACN,MAAM,oBACN,OAAO,GACL,MAAM,CAWlB;IAED;;;;;;;OAOG;IACH,yBALW,MAAM,UACN,MAAM,oBACN,OAAO,GACL,MAAM,CAWlB;IAED;;;;;;;OAOG;IACH,0BALW,MAAM,UACN,MAAM,oBACN,OAAO,GACL,MAAM,CAYlB;IAED;;;;;OAKG;IAEH;;;;;OAKG;IAEH
|
|
1
|
+
{"version":3,"file":"Data.d.ts","sourceRoot":"","sources":["../../../src/browser/lib/Data.js"],"names":[],"mappings":"AAUA;IACA;;;;;OAKG;IACD,mBAFQ,KAAK,CAAC,MAAM,CAAC,CAgBnB;IAEF;;;;;OAKG;IACH,qBAFU,KAAK,CAAC,MAAM,CAAC,CAmBrB;IAEF;;;;;;;OAOG;IACH,kBAFU,KAAK,CAAC,MAAM,CAAC,CAKrB;IAEF;;;;;OAKG;IACH,uBAFU,KAAK,CAAC,MAAM,CAAC,CAE2D;IAElF;;;;;;OAMG;IACH,sBAJW,MAAM,UACN,MAAM,GACJ,MAAM,CAMlB;IAED;;;;;;OAMG;IACH,uBAJW,MAAM,WACN,MAAM,GACJ,MAAM,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C,CAAC,CAMnC;IAED;;;;;;;OAOG;IACH,kBALW,MAAM,OACN,MAAM,OACN,MAAM,GACJ,MAAM,CAIlB;IAED;;;;;;;OAOG;IACH,oBALW,MAAM,OACN,MAAM,OACN,MAAM,GACJ,OAAO,CAInB;IAED;;;;;;;;;;;;;;;;;;;OAmBG;IACH,4BAbW,OAAO,GACL,OAAO,CA+BnB;IAED;;;;;;;;;;;;;;;OAeG;IACH,uBAXW,OAAO,GACL,OAAO,CAgBnB;CAEF;qBA5gBoB,eAAe"}
|
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Options for creating a new TypeSpec.
|
|
3
|
-
*
|
|
4
|
-
* @typedef {object} TypeSpecOptions
|
|
5
|
-
* @property {string} [delimiter="|"] - The delimiter for union types
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Options for type validation methods.
|
|
9
|
-
*
|
|
10
|
-
* @typedef {object} TypeValidationOptions
|
|
11
|
-
* @property {boolean} [allowEmpty=true] - Whether empty values are allowed
|
|
12
|
-
*/
|
|
13
1
|
/**
|
|
14
2
|
* Type specification class for parsing and validating complex type definitions.
|
|
15
3
|
* Supports union types, array types, and validation options.
|
|
@@ -19,9 +7,8 @@ export default class TypeSpec {
|
|
|
19
7
|
* Creates a new TypeSpec instance.
|
|
20
8
|
*
|
|
21
9
|
* @param {string} string - The type specification string (e.g., "string|number", "object[]")
|
|
22
|
-
* @param {TypeSpecOptions} [options] - Additional parsing options
|
|
23
10
|
*/
|
|
24
|
-
constructor(string: string
|
|
11
|
+
constructor(string: string);
|
|
25
12
|
specs: any[];
|
|
26
13
|
length: number;
|
|
27
14
|
stringRepresentation: string;
|
|
@@ -91,36 +78,34 @@ export default class TypeSpec {
|
|
|
91
78
|
* Handles array types, union types, and empty value validation.
|
|
92
79
|
*
|
|
93
80
|
* @param {unknown} value - The value to test against the type specifications
|
|
94
|
-
* @param {
|
|
81
|
+
* @param {TypeMatchOptions} [options] - Validation options
|
|
95
82
|
* @returns {boolean} True if the value matches any type specification
|
|
96
83
|
*/
|
|
97
|
-
matches(value: unknown, options?:
|
|
84
|
+
matches(value: unknown, options?: {
|
|
85
|
+
/**
|
|
86
|
+
* - Permit a spec of {@link Data.emptyableTypes} to be empty
|
|
87
|
+
*/
|
|
88
|
+
allowEmpty?: boolean;
|
|
89
|
+
}): boolean;
|
|
90
|
+
/**
|
|
91
|
+
* Options that can be passed to {@link TypeSpec.match}
|
|
92
|
+
*
|
|
93
|
+
* @typedef {object} TypeMatchOptions
|
|
94
|
+
* @property {boolean} [allowEmpty=true] - Permit a spec of {@link Data.emptyableTypes} to be empty
|
|
95
|
+
*/
|
|
98
96
|
/**
|
|
99
97
|
* Returns matching type specifications for a value.
|
|
100
98
|
*
|
|
101
99
|
* @param {unknown} value - The value to test against the type specifications
|
|
102
|
-
* @param {
|
|
100
|
+
* @param {TypeMatchOptions} [options] - Validation options
|
|
103
101
|
* @returns {Array<object>} Array of matching type specifications
|
|
104
102
|
*/
|
|
105
|
-
match(value: unknown,
|
|
103
|
+
match(value: unknown, { allowEmpty, }?: {
|
|
104
|
+
/**
|
|
105
|
+
* - Permit a spec of {@link Data.emptyableTypes} to be empty
|
|
106
|
+
*/
|
|
107
|
+
allowEmpty?: boolean;
|
|
108
|
+
}): Array<object>;
|
|
106
109
|
#private;
|
|
107
110
|
}
|
|
108
|
-
/**
|
|
109
|
-
* Options for creating a new TypeSpec.
|
|
110
|
-
*/
|
|
111
|
-
export type TypeSpecOptions = {
|
|
112
|
-
/**
|
|
113
|
-
* - The delimiter for union types
|
|
114
|
-
*/
|
|
115
|
-
delimiter?: string;
|
|
116
|
-
};
|
|
117
|
-
/**
|
|
118
|
-
* Options for type validation methods.
|
|
119
|
-
*/
|
|
120
|
-
export type TypeValidationOptions = {
|
|
121
|
-
/**
|
|
122
|
-
* - Whether empty values are allowed
|
|
123
|
-
*/
|
|
124
|
-
allowEmpty?: boolean;
|
|
125
|
-
};
|
|
126
111
|
//# sourceMappingURL=TypeSpec.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypeSpec.d.ts","sourceRoot":"","sources":["../../../src/browser/lib/TypeSpec.js"],"names":[],"mappings":"AAWA
|
|
1
|
+
{"version":3,"file":"TypeSpec.d.ts","sourceRoot":"","sources":["../../../src/browser/lib/TypeSpec.js"],"names":[],"mappings":"AAWA;;;GAGG;AACH;IAGE;;;;OAIG;IACH,oBAFW,MAAM,EAUhB;IAJC,aAAwB;IACxB,eAAgC;IAChC,6BAA2C;IAI7C;;;;OAIG;IACH,YAFa,MAAM,CAkBlB;IAED;;;;OAIG;IACH,UAFa,OAAO,CASnB;IAED;;;;OAIG;IACH,kBAFW,CAAS,IAAO,EAAP,OAAO,KAAG,IAAI,QAIjC;IAED;;;;;OAKG;IACH,gBAHW,CAAS,IAAO,EAAP,OAAO,KAAG,OAAO,GACxB,OAAO,CAInB;IAED;;;;;OAKG;IACH,eAHW,CAAS,IAAO,EAAP,OAAO,KAAG,OAAO,GACxB,OAAO,CAInB;IAED;;;;;OAKG;IACH,iBAHW,CAAS,IAAO,EAAP,OAAO,KAAG,OAAO,GACxB,KAAK,CAAC,OAAO,CAAC,CAI1B;IAED;;;;;OAKG;IACH,cAHW,CAAS,IAAO,EAAP,OAAO,KAAG,OAAO,GACxB,KAAK,CAAC,OAAO,CAAC,CAI1B;IAED;;;;;;OAMG;IACH,iBAJW,CAAS,IAAO,EAAP,OAAO,EAAE,IAAO,EAAP,OAAO,KAAG,OAAO,gBACnC,OAAO,GACL,OAAO,CAInB;IAED;;;;;OAKG;IACH,eAHW,CAAS,IAAO,EAAP,OAAO,KAAG,OAAO,GACxB,MAAM,GAAC,SAAS,CAI5B;IAED;;;;;;;OAOG;IACH,eAJW,OAAO;;;;qBAYJ,OAAO;QAVR,OAAO,CAInB;IAED;;;;;OAKG;IAEH;;;;;;OAMG;IACH,aAJW,OAAO;;;;qBANJ,OAAO;QAQR,KAAK,CAAC,MAAM,CAAC,CAsGzB;;CAqFF"}
|
package/types/node/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { default as Collection } from "../browser/lib/Collection.js";
|
|
2
|
-
export { default as Data } from "
|
|
2
|
+
export { default as Data } from "./lib/Data.js";
|
|
3
3
|
export { default as Promised } from "../browser/lib/Promised.js";
|
|
4
4
|
export { default as Time } from "../browser/lib/Time.js";
|
|
5
5
|
export { default as Type } from "../browser/lib/TypeSpec.js";
|
|
@@ -16,4 +16,5 @@ export { default as Glog } from "./lib/Glog.js";
|
|
|
16
16
|
export { default as Term } from "./lib/Term.js";
|
|
17
17
|
export { default as Disposer, Disposer as DisposerClass } from "../browser/lib/Disposer.js";
|
|
18
18
|
export { default as Notify, Notify as NotifyClass } from "./lib/Notify.js";
|
|
19
|
+
export { default as Watcher, OverFlowBehaviour } from "./lib/Watcher.js";
|
|
19
20
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,11 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @import FileObject from "./FileObject.js"
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* @typedef {"raw" | "structured"} CacheDataType
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* @typedef {{modified: Date, raw: string|null, structured: unknown}} CacheData
|
|
9
|
+
*/
|
|
1
10
|
/**
|
|
2
11
|
* File system cache with automatic invalidation based on modification time.
|
|
3
12
|
* Provides intelligent caching of parsed JSON5/YAML files with mtime-based
|
|
4
13
|
* cache invalidation to optimize performance for repeated file access.
|
|
5
14
|
*
|
|
6
|
-
* The cache eliminates redundant file reads and parsing when multiple
|
|
7
|
-
* access the same dependency files, while ensuring data freshness
|
|
8
|
-
* modification time checking.
|
|
15
|
+
* The cache eliminates redundant file reads and parsing when multiple
|
|
16
|
+
* processes access the same dependency files, while ensuring data freshness
|
|
17
|
+
* through modification time checking.
|
|
9
18
|
*/
|
|
10
19
|
export default class Cache {
|
|
11
20
|
/**
|
|
@@ -17,11 +26,33 @@ export default class Cache {
|
|
|
17
26
|
* freshness while optimizing performance for repeated file access during
|
|
18
27
|
* parallel processing.
|
|
19
28
|
*
|
|
20
|
-
* @param {
|
|
29
|
+
* @param {FileObject} fileObject - The file object to load and cache
|
|
21
30
|
* @returns {Promise<unknown>} The parsed file data (JSON5 or YAML)
|
|
22
31
|
* @throws {Sass} If the file cannot be found or accessed
|
|
23
32
|
*/
|
|
24
|
-
|
|
33
|
+
loadDataFromCache(fileObject: FileObject, options?: {}): Promise<unknown>;
|
|
34
|
+
/**
|
|
35
|
+
* Loads and caches raw file content with automatic mtime-based
|
|
36
|
+
* invalidation.
|
|
37
|
+
*
|
|
38
|
+
* @param {FileObject} fileObject - The file object to read and cache
|
|
39
|
+
* @returns {Promise<string>} The raw file content
|
|
40
|
+
* @throws {Sass} If the file cannot be found or accessed
|
|
41
|
+
*/
|
|
42
|
+
loadFromCache(fileObject: FileObject, options?: {}): Promise<string>;
|
|
43
|
+
/**
|
|
44
|
+
* Clears cached data for a specific file from both time and data maps.
|
|
45
|
+
*
|
|
46
|
+
* @param {import("./FileObject.js").default} file - The file object to clear from cache
|
|
47
|
+
*/
|
|
48
|
+
resetCache(file: import("./FileObject.js").default): void;
|
|
25
49
|
#private;
|
|
26
50
|
}
|
|
51
|
+
export type CacheDataType = "raw" | "structured";
|
|
52
|
+
export type CacheData = {
|
|
53
|
+
modified: Date;
|
|
54
|
+
raw: string | null;
|
|
55
|
+
structured: unknown;
|
|
56
|
+
};
|
|
57
|
+
import type FileObject from "./FileObject.js";
|
|
27
58
|
//# sourceMappingURL=Cache.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Cache.d.ts","sourceRoot":"","sources":["../../../src/node/lib/Cache.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Cache.d.ts","sourceRoot":"","sources":["../../../src/node/lib/Cache.js"],"names":[],"mappings":"AAIA;;GAEG;AAEH;;GAEG;AAEH;;GAEG;AAEH;;;;;;;;GAQG;AACH;IAuEE;;;;;;;;;;;;OAYG;IACH,8BAJW,UAAU,iBACR,OAAO,CAAC,OAAO,CAAC,CAQ5B;IAED;;;;;;;OAOG;IACH,0BAJW,UAAU,iBACR,OAAO,CAAC,MAAM,CAAC,CAQ3B;IAED;;;;OAIG;IACH,iBAFW,OAAO,iBAAiB,EAAE,OAAO,QAM3C;;CACF;4BApIY,KAAK,GAAG,YAAY;wBAIpB;IAAC,QAAQ,EAAE,IAAI,CAAC;IAAC,GAAG,EAAE,MAAM,GAAC,IAAI,CAAC;IAAC,UAAU,EAAE,OAAO,CAAA;CAAC;4BARzC,iBAAiB"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Node-side extension of Data with parsing utilities that require
|
|
3
|
+
* node-specific dependencies.
|
|
4
|
+
*/
|
|
5
|
+
export default class Data extends BrowserData {
|
|
6
|
+
/**
|
|
7
|
+
* Parses text content as structured data (JSON5 or YAML).
|
|
8
|
+
*
|
|
9
|
+
* @param {string} source - The text content to parse
|
|
10
|
+
* @param {string} [type="any"] - The expected format ("json",
|
|
11
|
+
* "json5", "yaml", or "any")
|
|
12
|
+
* @returns {unknown} The parsed data
|
|
13
|
+
* @throws {Sass} If content cannot be parsed or type is
|
|
14
|
+
* unsupported
|
|
15
|
+
*/
|
|
16
|
+
static textAsData(source: string, type?: string): unknown;
|
|
17
|
+
}
|
|
18
|
+
import BrowserData from "../../browser/lib/Data.js";
|
|
19
|
+
//# sourceMappingURL=Data.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Data.d.ts","sourceRoot":"","sources":["../../../src/node/lib/Data.js"],"names":[],"mappings":"AAKA;;;GAGG;AACH;IACE;;;;;;;;;OASG;IACH,0BAPW,MAAM,SACN,MAAM,GAEJ,OAAO,CA+BnB;CACF;wBA9CuB,2BAA2B"}
|
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
* @property {Array<string>|null} trail - Path segments
|
|
19
19
|
* @property {URL|null} url - The directory URL
|
|
20
20
|
*/
|
|
21
|
-
/**
|
|
21
|
+
/**
|
|
22
|
+
* DirectoryObject encapsulates metadata and operations for a directory,
|
|
22
23
|
* providing immutable path resolution, existence checks, and content enumeration.
|
|
23
24
|
*
|
|
24
25
|
* Features:
|
|
@@ -225,14 +226,14 @@ export default class DirectoryObject extends FS {
|
|
|
225
226
|
*
|
|
226
227
|
* @async
|
|
227
228
|
* @param {object} [options] - Options to pass to fs.mkdir (e.g., {recursive: true, mode: 0o755})
|
|
228
|
-
* @returns {Promise<
|
|
229
|
+
* @returns {Promise<undefined>}
|
|
229
230
|
* @throws {Sass} If directory creation fails for reasons other than already existing
|
|
230
231
|
* @example
|
|
231
232
|
* // Create directory recursively
|
|
232
233
|
* const dir = new DirectoryObject('./build/output')
|
|
233
234
|
* await dir.assureExists({recursive: true})
|
|
234
235
|
*/
|
|
235
|
-
assureExists(options?: object): Promise<
|
|
236
|
+
assureExists(options?: object): Promise<undefined>;
|
|
236
237
|
/**
|
|
237
238
|
* Generator that walks up the directory tree, yielding each parent directory.
|
|
238
239
|
* Starts from the current directory and yields each parent until reaching the root.
|
|
@@ -257,7 +258,7 @@ export default class DirectoryObject extends FS {
|
|
|
257
258
|
* a directory with contents, you must imperatively decide your deletion
|
|
258
259
|
* strategy and handle it explicitly.
|
|
259
260
|
*
|
|
260
|
-
* @returns {Promise<
|
|
261
|
+
* @returns {Promise<undefined>} Resolves when directory is deleted
|
|
261
262
|
* @throws {Sass} If the directory URL is invalid
|
|
262
263
|
* @throws {Sass} If the directory does not exist
|
|
263
264
|
* @throws {Error} If the directory is not empty (from fs.rmdir)
|
|
@@ -265,7 +266,7 @@ export default class DirectoryObject extends FS {
|
|
|
265
266
|
* const dir = new DirectoryObject('./temp/cache')
|
|
266
267
|
* await dir.delete() // Only works if directory is empty
|
|
267
268
|
*/
|
|
268
|
-
delete(): Promise<
|
|
269
|
+
delete(): Promise<undefined>;
|
|
269
270
|
/**
|
|
270
271
|
* Checks if a file exists within this directory.
|
|
271
272
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DirectoryObject.d.ts","sourceRoot":"","sources":["../../../src/node/lib/DirectoryObject.js"],"names":[],"mappings":"AAiBA;;;;GAIG;AAEH;;;;;;;;;;;;;;GAcG;AAEH
|
|
1
|
+
{"version":3,"file":"DirectoryObject.d.ts","sourceRoot":"","sources":["../../../src/node/lib/DirectoryObject.js"],"names":[],"mappings":"AAiBA;;;;GAIG;AAEH;;;;;;;;;;;;;;GAcG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH;IAuDE;;;;;;;;;OASG;IACH,kBALa,eAAe,CAO3B;IA7CD;;;;OAIG;IACH,uBAFW,MAAM,OAAC,EA4BjB;IAyBD;;;;OAIG;IACH,UAFa,MAAM,CAclB;IA8BD;;;;OAIG;IACH,WAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,cAFa,OAAO,CAAC,OAAO,CAAC,CAI5B;IAED;;;;OAIG;IACH,gBAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,YAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,WAFa,GAAG,CAIf;IAED;;;;OAIG;IACH,YAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,cAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,iBAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,WAFa,MAAM,CAIlB;IAED;;;;;;;OAOG;IACH,aALa,KAAK,CAAC,MAAM,CAAC,CAOzB;IAED;;;;;;;;;;;;OAYG;IACH,cARa,eAAe,GAAC,IAAI,CAsBhC;IAED;;;;OAIG;IACH,mBAFa,OAAO,CAInB;IAmBD;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,WAZW,MAAM,iBACJ,OAAO,CAAC;QAAC,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;QAAC,WAAW,EAAE,KAAK,CAAC,eAAe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;;;;WACX,KAAK,CAAC,MAAM,CAAC,GAAC,IAAI;;;;SAClB,GAAG,GAAC,IAAI;;eAvBP,iBAAiB;oBALd,UAAU;uBAIL,iBAAiB;wBAHlB,WAAW"}
|
|
@@ -13,15 +13,6 @@
|
|
|
13
13
|
* @property {Promise<boolean>} exists - Whether the file exists (async)
|
|
14
14
|
*/
|
|
15
15
|
export default class FileObject extends FS {
|
|
16
|
-
/**
|
|
17
|
-
* Configuration mapping data types to their respective parser modules for loadData method.
|
|
18
|
-
* Each parser module must have a .parse() method that accepts a string and returns parsed data.
|
|
19
|
-
*
|
|
20
|
-
* @type {{[key: string]: Array<typeof JSON5 | typeof YAML>}}
|
|
21
|
-
*/
|
|
22
|
-
static dataLoaderConfig: {
|
|
23
|
-
[key: string]: Array<typeof JSON5 | typeof YAML>;
|
|
24
|
-
};
|
|
25
16
|
/**
|
|
26
17
|
* Creates a FileObject representing the current working file (the file
|
|
27
18
|
* that called this method). Parses the stack trace to determine the
|
|
@@ -149,13 +140,45 @@ export default class FileObject extends FS {
|
|
|
149
140
|
* @returns {Promise<Date?>} The last modification time, or null if file doesn't exist
|
|
150
141
|
*/
|
|
151
142
|
modified(): Promise<Date | null>;
|
|
143
|
+
/**
|
|
144
|
+
* Whether this FileObject has an active cache attached.
|
|
145
|
+
*
|
|
146
|
+
* @returns {boolean} True if a Cache instance is attached
|
|
147
|
+
*/
|
|
148
|
+
get cached(): boolean;
|
|
149
|
+
/**
|
|
150
|
+
* Attaches a Cache instance to this FileObject for caching read and
|
|
151
|
+
* loadData results. If no cache is provided, a new Cache is created.
|
|
152
|
+
*
|
|
153
|
+
* @param {Cache} [cache] - The Cache instance to attach
|
|
154
|
+
* @returns {FileObject} This FileObject for chaining
|
|
155
|
+
* @throws {Sass} If a cache is already attached
|
|
156
|
+
*/
|
|
157
|
+
withCache(cache?: Cache): FileObject;
|
|
158
|
+
/**
|
|
159
|
+
* Removes the attached cache, clearing any cached data for this file first.
|
|
160
|
+
*
|
|
161
|
+
* @returns {FileObject} This FileObject for chaining
|
|
162
|
+
*/
|
|
163
|
+
removeCache(): FileObject;
|
|
164
|
+
/**
|
|
165
|
+
* Clears cached data for this file without removing the cache itself.
|
|
166
|
+
*
|
|
167
|
+
* @returns {FileObject} This FileObject for chaining
|
|
168
|
+
*/
|
|
169
|
+
resetCache(): FileObject;
|
|
152
170
|
/**
|
|
153
171
|
* Reads the content of a file asynchronously.
|
|
154
172
|
*
|
|
155
|
-
* @param {
|
|
173
|
+
* @param {object} [options] - Read options
|
|
174
|
+
* @param {string} [options.encoding="utf8"] - The encoding to read the file as
|
|
175
|
+
* @param {boolean} [options.skipCache=false] - If true, bypass the cache
|
|
156
176
|
* @returns {Promise<string>} The file contents
|
|
157
177
|
*/
|
|
158
|
-
read(encoding?:
|
|
178
|
+
read({ encoding, skipCache }?: {
|
|
179
|
+
encoding?: string;
|
|
180
|
+
skipCache?: boolean;
|
|
181
|
+
}): Promise<string>;
|
|
159
182
|
/**
|
|
160
183
|
* Reads binary data from a file asynchronously.
|
|
161
184
|
* Returns the file contents as a Buffer (Node.js binary data type).
|
|
@@ -175,20 +198,20 @@ export default class FileObject extends FS {
|
|
|
175
198
|
*
|
|
176
199
|
* @param {string} content - The content to write
|
|
177
200
|
* @param {string} [encoding] - The encoding in which to write (default: "utf8")
|
|
178
|
-
* @returns {Promise<
|
|
201
|
+
* @returns {Promise<undefined>}
|
|
179
202
|
* @throws {Sass} If the file URL is invalid or the parent directory doesn't exist
|
|
180
203
|
* @example
|
|
181
204
|
* const file = new FileObject('./output/data.json')
|
|
182
205
|
* await file.write(JSON.stringify({key: 'value'}))
|
|
183
206
|
*/
|
|
184
|
-
write(content: string, encoding?: string): Promise<
|
|
207
|
+
write(content: string, encoding?: string): Promise<undefined>;
|
|
185
208
|
/**
|
|
186
209
|
* Writes binary data to a file asynchronously.
|
|
187
210
|
* Validates that the parent directory exists and that the data is valid binary format.
|
|
188
211
|
* Supports ArrayBuffer, TypedArrays (Uint8Array, etc.), Blob, and Node Buffer types.
|
|
189
212
|
*
|
|
190
213
|
* @param {ArrayBuffer|Blob|Buffer} data - The binary data to write
|
|
191
|
-
* @returns {Promise<
|
|
214
|
+
* @returns {Promise<undefined>}
|
|
192
215
|
* @throws {Sass} If the file URL is invalid
|
|
193
216
|
* @throws {Sass} If the parent directory doesn't exist
|
|
194
217
|
* @throws {Sass} If the data is not a valid binary type
|
|
@@ -198,23 +221,29 @@ export default class FileObject extends FS {
|
|
|
198
221
|
* const buffer = await response.arrayBuffer()
|
|
199
222
|
* await file.writeBinary(buffer)
|
|
200
223
|
*/
|
|
201
|
-
writeBinary(data: ArrayBuffer | Blob | Buffer): Promise<
|
|
224
|
+
writeBinary(data: ArrayBuffer | Blob | Buffer): Promise<undefined>;
|
|
202
225
|
/**
|
|
203
|
-
* Loads an object from JSON or YAML file.
|
|
204
|
-
*
|
|
226
|
+
* Loads an object from JSON or YAML file. Attempts to parse content as JSON5
|
|
227
|
+
* first, then falls back to YAML if specified.
|
|
205
228
|
*
|
|
206
|
-
* @param {
|
|
207
|
-
* @param {string} [
|
|
229
|
+
* @param {object} [options] - Load options
|
|
230
|
+
* @param {string} [options.type="any"] - The expected type of data to parse ("json", "json5", "yaml", or "any")
|
|
231
|
+
* @param {string} [options.encoding="utf8"] - The encoding to read the file as
|
|
232
|
+
* @param {boolean} [options.skipCache=false] - If true, bypass the cache
|
|
208
233
|
* @returns {Promise<unknown>} The parsed data object
|
|
209
234
|
* @throws {Sass} If the content cannot be parsed or type is unsupported
|
|
210
235
|
* @example
|
|
211
236
|
* const configFile = new FileObject('./config.json5')
|
|
212
|
-
* const config = await configFile.loadData('json5')
|
|
237
|
+
* const config = await configFile.loadData({type: 'json5'})
|
|
213
238
|
*
|
|
214
239
|
* // Auto-detect format
|
|
215
|
-
* const data = await configFile.loadData(
|
|
240
|
+
* const data = await configFile.loadData()
|
|
216
241
|
*/
|
|
217
|
-
loadData(type
|
|
242
|
+
loadData({ type, encoding, skipCache }?: {
|
|
243
|
+
type?: string;
|
|
244
|
+
encoding?: string;
|
|
245
|
+
skipCache?: boolean;
|
|
246
|
+
}): Promise<unknown>;
|
|
218
247
|
/**
|
|
219
248
|
* Loads a file as a module and returns it.
|
|
220
249
|
*
|
|
@@ -253,14 +282,14 @@ export default class FileObject extends FS {
|
|
|
253
282
|
/**
|
|
254
283
|
* Deletes the file from the filesystem.
|
|
255
284
|
*
|
|
256
|
-
* @returns {Promise<
|
|
285
|
+
* @returns {Promise<undefined>} Resolves when file is deleted
|
|
257
286
|
* @throws {Sass} If the file URL is invalid
|
|
258
287
|
* @throws {Sass} If the file does not exist
|
|
259
288
|
* @example
|
|
260
289
|
* const file = new FileObject('./temp/data.json')
|
|
261
290
|
* await file.delete()
|
|
262
291
|
*/
|
|
263
|
-
delete(): Promise<
|
|
292
|
+
delete(): Promise<undefined>;
|
|
264
293
|
/**
|
|
265
294
|
* Custom Node.js inspect implementation for console.log output.
|
|
266
295
|
*
|
|
@@ -284,8 +313,7 @@ export default class FileObject extends FS {
|
|
|
284
313
|
import FS from "./FileSystem.js";
|
|
285
314
|
import { URL } from "node:url";
|
|
286
315
|
import DirectoryObject from "./DirectoryObject.js";
|
|
316
|
+
import Cache from "./Cache.js";
|
|
287
317
|
import { Buffer } from "node:buffer";
|
|
288
318
|
import { inspect } from "node:util";
|
|
289
|
-
import JSON5 from "json5";
|
|
290
|
-
import YAML from "yaml";
|
|
291
319
|
//# sourceMappingURL=FileObject.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileObject.d.ts","sourceRoot":"","sources":["../../../src/node/lib/FileObject.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FileObject.d.ts","sourceRoot":"","sources":["../../../src/node/lib/FileObject.js"],"names":[],"mappings":"AAkBA;;;;;;;;;;;;;GAaG;AAEH;IAunBE;;;;;;;;;;;OAWG;IACH,kBAPa,UAAU,CAsCtB;IAvoBD;;;;;OAKG;IACH,uBAHW,MAAM,WACN,eAA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;;;;;OAeG;IACH,kBAXW,WAAW,GAAC,IAAI,GAAC,MAAM,GACrB,OAAO,CAAC,SAAS,CAAC,CAwB9B;IAED;;;;;;;;;;;;;;;;OAgBG;IACH,yCAZG;QAAyB,IAAI,GAArB,MAAM;QACW,QAAQ,GAAzB,MAAM;QACY,SAAS,GAA3B,OAAO;KACf,GAAU,OAAO,CAAC,OAAO,CAAC,CAqB5B;IAED;;;;OAIG;IACH,UAFa,OAAO,CAAC,MAAM,CAAC,CAS3B;IAED;;;;;;;;;;;;OAYG;IACH,kBATW,MAAM,GACJ,OAAO,CAAC,UAAU,CAAC,CAyB/B;IAED;;;;;;;;;;;;;OAaG;IACH,kBATW,MAAM,GACJ,OAAO,CAAC,UAAU,CAAC,CA0C/B;IAED;;;;;;;;;OASG;IACH,UAPa,OAAO,CAAC,SAAS,CAAC,CAc9B;IA1fD;;;;;;;OAOG;IACH,wBALW,MAAM,WACN,MAAM,kBAEJ,MAAM,CAIlB;IAED;;;;;;;OAOG;IACH,2BAHW,QAAQ,GAAC,QAAQ,GAAC,SAAS,GACzB,MAAM,GAAC,MAAM,CAQzB;;CA8gBF;eAtrBc,iBAAiB;oBANd,UAAU;4BAKA,sBAAsB;kBAFhC,YAAY;uBALT,aAAa;wBAGZ,WAAW"}
|
|
@@ -197,5 +197,24 @@ export default class FileSystem {
|
|
|
197
197
|
* @throws {Sass} If the parameter is not a FileObject or DirectoryObject
|
|
198
198
|
*/
|
|
199
199
|
relativeTo(fileOrDirectoryObject: import("./FileObject.js").default | import("./DirectoryObject.js").default): string;
|
|
200
|
+
/**
|
|
201
|
+
* Watch this file or directory for changes.
|
|
202
|
+
*
|
|
203
|
+
* @param {object} [options] - Watch options
|
|
204
|
+
* @param {Function} [options.onChange] - Callback invoked on change
|
|
205
|
+
* @param {number} [options.debounceMs] - Debounce interval in milliseconds
|
|
206
|
+
* @param {boolean} [options.persistent] - Keep the process alive while watching
|
|
207
|
+
* @returns {Promise<undefined>}
|
|
208
|
+
*/
|
|
209
|
+
watch(options?: {
|
|
210
|
+
onChange?: Function;
|
|
211
|
+
debounceMs?: number;
|
|
212
|
+
persistent?: boolean;
|
|
213
|
+
}): Promise<undefined>;
|
|
214
|
+
/**
|
|
215
|
+
* Stop watching this file or directory for changes.
|
|
216
|
+
*/
|
|
217
|
+
stopWatching(): void;
|
|
218
|
+
#private;
|
|
200
219
|
}
|
|
201
220
|
//# sourceMappingURL=FileSystem.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileSystem.d.ts","sourceRoot":"","sources":["../../../src/node/lib/FileSystem.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FileSystem.d.ts","sourceRoot":"","sources":["../../../src/node/lib/FileSystem.js"],"names":[],"mappings":"AA6BA;;GAEG;AACH;IACE,kCAAwB;IACxB,uCAAkC;IAClC,mBAAsB;IAiEtB;;;;;;OAMG;IACH,4BAHW,MAAM,GACJ,MAAM,CAIlB;IAED;;;;;;OAMG;IACH,2BAHW,MAAM,GACJ,MAAM,CAQlB;IAED;;;;;;;;OAQG;IACH,0BALW,MAAM,GACJ,MAAM,CAUlB;IAED;;;;;;;;;;OAUG;IACH,gCAJW,OAAO,iBAAiB,EAAE,OAAO,GAAC,OAAO,sBAAsB,EAAE,OAAO,MACxE,OAAO,iBAAiB,EAAE,OAAO,GAAC,OAAO,sBAAsB,EAAE,OAAO,GACtE,MAAM,CAYlB;IAED;;;;;;;;;;OAUG;IACH,oCAJW,MAAM,MACN,MAAM,GACJ,MAAM,CAQlB;IAED;;;;;;;;;OASG;IACH,oCALW,MAAM,SACN,MAAM,QACN,MAAM,GACJ,MAAM,CA8BlB;IAED;;;;;;;;OAQG;IACH,6BAJW,MAAM,UACN,MAAM,GACJ,MAAM,CAmClB;IAED;;;;;;;;;;;;OAYG;IACH,+BATW,MAAM,aACN,MAAM,GACJ,OAAO,CAcnB;IAED;;;;;;;;;;;;;;OAcG;IACH,iCATW,MAAM,MACN,MAAM,QACN,MAAM,GACJ,MAAM,GAAC,IAAI,CAwBvB;IAED;;;;;;;;;;;;;;OAcG;IACH,4BARW,MAAM,MACN,MAAM,GACJ,MAAM,CAYlB;IAED;;;;;;;;;;;;;;;;;;OAkBG;IACH,+BAXW,MAAM,MACN,MAAM,QACN,MAAM,GACJ,MAAM,GAAC,IAAI,CA+BvB;IAED;;;;;;;OAOG;IAEH;;;;;;;OAOG;IACH,2BAJW,MAAM;;;;cAXH,MAAM;;;;aACN,MAAM;;;;aACN,MAAM;;;;cACN,MAAM;;;;cACN,MAAM;MAenB;IAED;;;;OAIG;IACH,kBAFa,MAAM,CAIlB;IAhYD;;;;;;;;;OASG;IACH,kCAJW,OAAO,iBAAiB,EAAE,OAAO,GAAC,OAAO,sBAAsB,EAAE,OAAO,GACtE,MAAM,CAWlB;IAED;;;;;;;;OAQG;IACH,gBALG;QAA2B,QAAQ;QACV,UAAU,GAA3B,MAAM;QACY,UAAU,GAA5B,OAAO;KACf,GAAU,OAAO,CAAC,SAAS,CAAC,CAwB9B;IAED;;OAEG;IACH,qBAGC;;CAsUF"}
|
package/types/node/lib/Glog.d.ts
CHANGED
|
@@ -209,7 +209,7 @@ declare class Glog {
|
|
|
209
209
|
* @param {boolean} [options.stackTrace=false] - Enable stack trace extraction
|
|
210
210
|
* @param {boolean} [options.tagsAsStrings=false] - Use string tags instead of symbols
|
|
211
211
|
* @param {boolean} [options.displayName=true] - Display logger name in output
|
|
212
|
-
* @param {
|
|
212
|
+
* @param {object} [options.vscode] - VS Code API object (auto-detected if not provided)
|
|
213
213
|
*/
|
|
214
214
|
constructor(options?: {
|
|
215
215
|
name?: string;
|
|
@@ -221,7 +221,7 @@ declare class Glog {
|
|
|
221
221
|
stackTrace?: boolean;
|
|
222
222
|
tagsAsStrings?: boolean;
|
|
223
223
|
displayName?: boolean;
|
|
224
|
-
|
|
224
|
+
vscode?: object;
|
|
225
225
|
});
|
|
226
226
|
/**
|
|
227
227
|
* Set configuration options for this logger instance
|