@gesslar/toolkit 4.0.0 → 4.2.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/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/Notify.js +26 -6
- package/src/node/lib/Term.js +1 -1
- package/src/node/lib/Util.js +47 -5
- package/src/node/lib/Watcher.js +118 -0
- 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/Notify.d.ts +23 -10
- package/types/node/lib/Notify.d.ts.map +1 -1
- package/types/node/lib/Term.d.ts +2 -2
- package/types/node/lib/Term.d.ts.map +1 -1
- package/types/node/lib/Util.d.ts +20 -6
- package/types/node/lib/Util.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,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @import FileObject from "./FileObject.js"
|
|
3
|
+
* @import DirectoryObject from "./DirectoryObject.js"
|
|
4
|
+
*/
|
|
5
|
+
export const OverFlowBehaviour: Readonly<{
|
|
6
|
+
IGNORE: "ignore";
|
|
7
|
+
THROW: "throw";
|
|
8
|
+
}>;
|
|
9
|
+
export default class Watcher {
|
|
10
|
+
/**
|
|
11
|
+
* Watch one or more file/directory targets for changes, invoking a callback
|
|
12
|
+
* with debounce protection.
|
|
13
|
+
*
|
|
14
|
+
* @param {FileObject|DirectoryObject|Array.<(FileObject|DirectoryObject)>} targets - The target(s) to watch
|
|
15
|
+
* @param {object} options - Watch options
|
|
16
|
+
* @param {(target: FileObject|DirectoryObject) => void} options.onChange - Callback invoked on change
|
|
17
|
+
* @param {number} [options.debounceMs=50] - Debounce interval in milliseconds
|
|
18
|
+
* @param {boolean} [options.persistent=true] - Keep the process alive while watching
|
|
19
|
+
* @param {boolean} [options.recursive=false] - Watch subdirectories (directories only)
|
|
20
|
+
* @param {string} [options.overflow="ignore"] - Overflow behaviour ("ignore" or "throw")
|
|
21
|
+
* @returns {Promise<undefined>}
|
|
22
|
+
*/
|
|
23
|
+
watch(targets: FileObject | DirectoryObject | Array<(FileObject | DirectoryObject)>, { onChange, debounceMs, persistent, recursive, overflow }?: {
|
|
24
|
+
onChange: (target: FileObject | DirectoryObject) => void;
|
|
25
|
+
debounceMs?: number;
|
|
26
|
+
persistent?: boolean;
|
|
27
|
+
recursive?: boolean;
|
|
28
|
+
overflow?: string;
|
|
29
|
+
}): Promise<undefined>;
|
|
30
|
+
/**
|
|
31
|
+
* Stop watching all targets.
|
|
32
|
+
*/
|
|
33
|
+
stopWatching(): void;
|
|
34
|
+
#private;
|
|
35
|
+
}
|
|
36
|
+
import type FileObject from "./FileObject.js";
|
|
37
|
+
import type DirectoryObject from "./DirectoryObject.js";
|
|
38
|
+
//# sourceMappingURL=Watcher.d.ts.map
|
|
@@ -0,0 +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"}
|