@gesslar/toolkit 3.17.0 → 3.19.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": "3.17.0",
8
+ "version": "3.19.0",
9
9
  "license": "Unlicense",
10
10
  "homepage": "https://github.com/gesslar/toolkit#readme",
11
11
  "repository": {
@@ -60,7 +60,7 @@
60
60
  "devDependencies": {
61
61
  "@gesslar/uglier": "^0.6.0",
62
62
  "eslint": "^9.39.2",
63
- "happy-dom": "^20.0.11",
63
+ "happy-dom": "^20.1.0",
64
64
  "typescript": "^5.9.3"
65
65
  },
66
66
  "scripts": {
package/src/node/index.js CHANGED
@@ -17,7 +17,7 @@ export {default as Util} from "./lib/Util.js"
17
17
  export {default as Cache} from "./lib/Cache.js"
18
18
  export {default as DirectoryObject} from "./lib/DirectoryObject.js"
19
19
  export {default as FileObject} from "./lib/FileObject.js"
20
- export {default as FS} from "./lib/FileSystem.js"
20
+ export {default as FileSystem} from "./lib/FileSystem.js"
21
21
  export {default as Glog} from "./lib/Glog.js"
22
22
  export {default as Notify} from "./lib/Notify.js"
23
23
  export {default as TempDirectoryObject} from "./lib/TempDirectoryObject.js"
@@ -368,26 +368,29 @@ export default class DirectoryObject extends FS {
368
368
  const files = [], directories = []
369
369
  const virtual = this.isVirtual
370
370
 
371
- found.forEach(e => {
371
+ for(const e of found) {
372
372
  if(e.isFile()) {
373
373
  const {name, parentPath} = e
374
374
  const resolved = FS.resolvePath(parentPath, name)
375
375
 
376
376
  const file = virtual
377
- ? new VFileObject(resolved, this)
377
+ ? new VFileObject(path.relative(this.real.path, resolved), this)
378
378
  : new FileObject(resolved, this)
379
379
 
380
380
  files.push(file)
381
381
  } else if(e.isDirectory()) {
382
382
  const {name, parentPath} = e
383
383
  const resolved = FS.resolvePath(parentPath, name)
384
- const directory = new this.constructor(resolved, this)
384
+ const relativePath = virtual
385
+ ? path.relative(this.real.path, resolved)
386
+ : resolved
387
+ const directory = new this.constructor(relativePath, this)
385
388
 
386
389
  directories.push(directory)
387
390
  } else {
388
391
  throw Sass.new(`wtf is this? ${e}`)
389
392
  }
390
- })
393
+ }
391
394
 
392
395
  return {files, directories}
393
396
  }
@@ -69,6 +69,24 @@ export default class FileObject extends FS {
69
69
  parentPath: null,
70
70
  })
71
71
 
72
+ /**
73
+ * Strip root from absolute path to make it relative.
74
+ * Used for virtual filesystem path resolution.
75
+ *
76
+ * @private
77
+ * @static
78
+ * @param {string} pathName - The path to convert
79
+ * @returns {string} Path with root stripped, or original if already relative
80
+ */
81
+ static #absoluteToRelative(pathName) {
82
+ if(!path.isAbsolute(pathName))
83
+ return pathName
84
+
85
+ const {root} = FS.pathParts(pathName)
86
+
87
+ return Data.chopLeft(pathName, root)
88
+ }
89
+
72
90
  /**
73
91
  * Constructs a FileObject instance.
74
92
  *
@@ -82,40 +100,41 @@ export default class FileObject extends FS {
82
100
  Valid.type(parent, "Null|String|DirectoryObject", {allowEmpty: false})
83
101
 
84
102
  const normalizedFile = FS.fixSlashes(submitted)
85
- const absOrRel = path.isAbsolute(normalizedFile) && parent
86
- ? FS.absoluteToRelative(normalizedFile, true)
103
+ const absOrRelPath = path.isAbsolute(normalizedFile) && parent
104
+ ? FileObject.#absoluteToRelative(normalizedFile)
87
105
  : normalizedFile
88
- const {dir, base, ext, name} = FS.pathParts(absOrRel)
106
+ const {dir, base, ext, name} = FS.pathParts(absOrRelPath)
89
107
 
90
108
  const [parentObject, fullPath] = (() => {
91
109
  if(Data.isType(parent, "String")) {
92
- const joined = FS.resolvePath(parent, absOrRel)
93
- const {dir} = FS.pathParts(joined)
110
+ const resolved = FS.resolvePath(parent, absOrRelPath)
111
+ const {dir} = FS.pathParts(resolved)
94
112
 
95
113
  return [
96
114
  new DirectoryObject(dir),
97
- joined,
115
+ resolved,
98
116
  ]
99
117
  }
100
118
 
101
119
  if(Data.isType(parent, "DirectoryObject")) {
102
- const joined = FS.resolvePath(parent.path, absOrRel)
103
- const {dir} = FS.pathParts(joined)
120
+ const parentPath = parent.path
121
+ const resolved = FS.resolvePath(parentPath, absOrRelPath)
122
+ const parts = FS.pathParts(resolved)
104
123
 
105
124
  return [
106
- parent.path === dir
125
+ parent.path === parts.dir
107
126
  ? parent
108
- : new parent.constructor(dir, parent),
109
- joined,
127
+ : new parent.constructor(parts.dir, parent),
128
+ resolved,
110
129
  ]
111
130
  }
112
131
 
113
132
  const directory = new DirectoryObject(dir)
114
- const joined = FS.resolvePath(directory.path, absOrRel)
133
+ const resolved = FS.resolvePath(directory.path, absOrRelPath)
115
134
 
116
135
  return [
117
136
  directory,
118
- joined,
137
+ resolved,
119
138
  ]
120
139
  })()
121
140
 
@@ -49,7 +49,7 @@ export default class FileSystem {
49
49
  1
50
50
  )
51
51
 
52
- return FileSystem.relativeOrAbsolutePath(fileOrDirectoryObject, this)
52
+ return FileSystem.relativeOrAbsolute(fileOrDirectoryObject, this)
53
53
  }
54
54
 
55
55
  /**
@@ -104,7 +104,7 @@ export default class FileSystem {
104
104
  * @param {FileObject|DirectoryObject} to - The target file or directory object
105
105
  * @returns {string} The relative path from `from` to `to`, or the absolute path if not reachable
106
106
  */
107
- static relativeOrAbsolutePath(from, to) {
107
+ static relativeOrAbsolute(from, to) {
108
108
  const fromBasePath = from.isDirectory
109
109
  ? from.path
110
110
  : from.parent?.path ?? path.dirname(from.path)
@@ -116,6 +116,25 @@ export default class FileSystem {
116
116
  : relative
117
117
  }
118
118
 
119
+ /**
120
+ * Computes the relative path from one file or directory to another.
121
+ *
122
+ * If the target is outside the source (i.e., the relative path starts with
123
+ * ".."), returns the absolute path to the target instead.
124
+ *
125
+ * @static
126
+ * @param {string} from - The source file or directory object
127
+ * @param {string} to - The target file or directory object
128
+ * @returns {string} The relative path from `from` to `to`, or the absolute path if not reachable
129
+ */
130
+ static relativeOrAbsolutePath(from, to) {
131
+ const relative = path.relative(from, to)
132
+
133
+ return relative.startsWith("..")
134
+ ? to
135
+ : relative
136
+ }
137
+
119
138
  /**
120
139
  * Merge two paths by finding overlapping segments and combining them
121
140
  * efficiently
@@ -356,32 +375,4 @@ export default class FileSystem {
356
375
 
357
376
  return this.resolvePath(cap, target)
358
377
  }
359
-
360
- /**
361
- * Convert an absolute path to a relative format by removing the root component.
362
- * By default, keeps a leading separator (making it "absolute-like relative").
363
- * Use forceActuallyRelative to get a truly relative path without leading separator.
364
- *
365
- * @static
366
- * @param {string} pathToCheck - The path to convert (returned unchanged if already relative)
367
- * @param {boolean} [forceActuallyRelative=false] - If true, removes leading separator for truly relative path
368
- * @returns {string} The relative path (with or without leading separator based on forceActuallyRelative)
369
- * @example
370
- * FS.absoluteToRelative("/home/user/docs") // "/home/user/docs" (with leading /)
371
- * FS.absoluteToRelative("/home/user/docs", true) // "home/user/docs" (truly relative)
372
- * FS.absoluteToRelative("relative/path") // "relative/path" (unchanged)
373
- */
374
- static absoluteToRelative(pathToCheck, forceActuallyRelative=false) {
375
- if(!path.isAbsolute(pathToCheck))
376
- return pathToCheck
377
-
378
- const {root} = this.pathParts(pathToCheck)
379
- const sep = path.sep
380
- const chopped = Data.chopLeft(pathToCheck, root)
381
- const absolute = forceActuallyRelative
382
- ? chopped
383
- : Data.prepend(chopped, sep)
384
-
385
- return absolute
386
- }
387
378
  }
@@ -44,11 +44,10 @@ export default class VFileObject extends FileObject {
44
44
  super(fileName, parent)
45
45
 
46
46
  const parentRealPath = this.parent.real.path
47
- const relative = FS.absoluteToRelative(this.path, true)
48
- const resolved = FS.resolvePath(parentRealPath, relative)
49
- const {base, dir} = FS.pathParts(resolved)
47
+ const resolved = FS.resolvePath(this.parent.path, fileName)
48
+ const {base} = FS.pathParts(resolved)
50
49
 
51
- this.#real = new FileObject(base, dir)
50
+ this.#real = new FileObject(base, parentRealPath)
52
51
  }
53
52
 
54
53
  get isVirtual() {
@@ -10,7 +10,7 @@ export { default as Util } from "./lib/Util.js";
10
10
  export { default as Cache } from "./lib/Cache.js";
11
11
  export { default as DirectoryObject } from "./lib/DirectoryObject.js";
12
12
  export { default as FileObject } from "./lib/FileObject.js";
13
- export { default as FS } from "./lib/FileSystem.js";
13
+ export { default as FileSystem } from "./lib/FileSystem.js";
14
14
  export { default as Glog } from "./lib/Glog.js";
15
15
  export { default as Notify } from "./lib/Notify.js";
16
16
  export { default as TempDirectoryObject } from "./lib/TempDirectoryObject.js";
@@ -1 +1 @@
1
- {"version":3,"file":"DirectoryObject.d.ts","sourceRoot":"","sources":["../../../src/node/lib/DirectoryObject.js"],"names":[],"mappings":"AAiBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH;IA2DE;;;;;;;;;OASG;IACH,kBALa,eAAe,CAO3B;IA3CD;;;;OAIG;IACH,uBAFW,MAAM,OAAC,EA0BjB;IA2BD;;;;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;;;;;;;;;;;;;;;;;;OAkBG;IACH,WAZW,MAAM,GACJ,OAAO,CAAC;QAAC,KAAK,EAAE,KAAK,CAAC,UAAU,GAAC,WAAW,CAAC,CAAC;QAAC,WAAW,EAAE,KAAK,CAAC,eAAe,GAAC,gBAAgB,CAAC,CAAA;KAAC,CAA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eA3kBc,iBAAiB;uBACT,iBAAiB;wBAGhB,kBAAkB"}
@@ -22,6 +22,16 @@ export default class FileObject extends FS {
22
22
  static dataLoaderConfig: {
23
23
  [key: string]: Array<typeof JSON5 | typeof YAML>;
24
24
  };
25
+ /**
26
+ * Strip root from absolute path to make it relative.
27
+ * Used for virtual filesystem path resolution.
28
+ *
29
+ * @private
30
+ * @static
31
+ * @param {string} pathName - The path to convert
32
+ * @returns {string} Path with root stripped, or original if already relative
33
+ */
34
+ private static "__#private@#absoluteToRelative";
25
35
  /**
26
36
  * Constructs a FileObject instance.
27
37
  *
@@ -1 +1 @@
1
- {"version":3,"file":"FileObject.d.ts","sourceRoot":"","sources":["../../../src/node/lib/FileObject.js"],"names":[],"mappings":"AAkBA;;;;;;;;;;;;;GAaG;AAEH;IACE;;;;;OAKG;IACH,yBAFU;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAAC,OAAO,KAAK,GAAG,OAAO,IAAI,CAAC,CAAA;KAAC,CAO1D;IA0BF;;;;;OAKG;IACH,uBAHW,MAAM,WACN,eAAe,GAAC,MAAM,GAAC,IAAI,EA4DrC;IAaD;;;;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;IACD;;;;OAIG;IACH,cAFa,OAAO,CAInB;IAED;;;;;;;;;;;;;;OAcG;IACH,cAFa,eAAe,CAI3B;IAED;;;;OAIG;IACH,kBAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,WAFa,OAAO,CAAC,OAAO,CAAC,CAU5B;IAED;;;;OAIG;IACH,YAFa,OAAO,CAAC,OAAO,CAAC,CAU5B;IAiBD;;;;OAIG;IACH,QAFa,OAAO,CAAC,MAAM,OAAC,CAAC,CAU5B;IAED;;;;;OAKG;IACH,YAFa,OAAO,CAAC,IAAI,OAAC,CAAC,CAU1B;IAED;;;;;OAKG;IACH,gBAHW,MAAM,GACJ,OAAO,CAAC,MAAM,CAAC,CAS3B;IAED;;;;;;;;;;;OAWG;IACH,cARa,OAAO,CAAC,MAAM,CAAC,CAe3B;IAED;;;;;;;;;;;OAWG;IACH,eARW,MAAM,aACN,MAAM,GACJ,OAAO,CAAC,IAAI,CAAC,CAiBzB;IAED;;;;;;;;;;;;;;;OAeG;IACH,kBAXW,WAAW,GAAC,IAAI,GAAC,MAAM,GACrB,OAAO,CAAC,IAAI,CAAC,CAwBzB;IAED;;;;;;;;;;;;;;OAcG;IACH,gBAXW,MAAM,aACN,MAAM,GACJ,OAAO,CAAC,OAAO,CAAC,CAkC5B;IAED;;;;OAIG;IACH,UAFa,OAAO,CAAC,MAAM,CAAC,CAS3B;IAED;;;;;;;;;OASG;IACH,UAPa,OAAO,CAAC,IAAI,CAAC,CAczB;;CACF;eA5dc,iBAAiB;4BADJ,sBAAsB"}
1
+ {"version":3,"file":"FileObject.d.ts","sourceRoot":"","sources":["../../../src/node/lib/FileObject.js"],"names":[],"mappings":"AAkBA;;;;;;;;;;;;;GAaG;AAEH;IACE;;;;;OAKG;IACH,yBAFU;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAAC,OAAO,KAAK,GAAG,OAAO,IAAI,CAAC,CAAA;KAAC,CAO1D;IA0BF;;;;;;;;OAQG;IACH,gDAOC;IAED;;;;;OAKG;IACH,uBAHW,MAAM,WACN,eAAe,GAAC,MAAM,GAAC,IAAI,EA6DrC;IAaD;;;;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;IACD;;;;OAIG;IACH,cAFa,OAAO,CAInB;IAED;;;;;;;;;;;;;;OAcG;IACH,cAFa,eAAe,CAI3B;IAED;;;;OAIG;IACH,kBAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,WAFa,OAAO,CAAC,OAAO,CAAC,CAU5B;IAED;;;;OAIG;IACH,YAFa,OAAO,CAAC,OAAO,CAAC,CAU5B;IAiBD;;;;OAIG;IACH,QAFa,OAAO,CAAC,MAAM,OAAC,CAAC,CAU5B;IAED;;;;;OAKG;IACH,YAFa,OAAO,CAAC,IAAI,OAAC,CAAC,CAU1B;IAED;;;;;OAKG;IACH,gBAHW,MAAM,GACJ,OAAO,CAAC,MAAM,CAAC,CAS3B;IAED;;;;;;;;;;;OAWG;IACH,cARa,OAAO,CAAC,MAAM,CAAC,CAe3B;IAED;;;;;;;;;;;OAWG;IACH,eARW,MAAM,aACN,MAAM,GACJ,OAAO,CAAC,IAAI,CAAC,CAiBzB;IAED;;;;;;;;;;;;;;;OAeG;IACH,kBAXW,WAAW,GAAC,IAAI,GAAC,MAAM,GACrB,OAAO,CAAC,IAAI,CAAC,CAwBzB;IAED;;;;;;;;;;;;;;OAcG;IACH,gBAXW,MAAM,aACN,MAAM,GACJ,OAAO,CAAC,OAAO,CAAC,CAkC5B;IAED;;;;OAIG;IACH,UAFa,OAAO,CAAC,MAAM,CAAC,CAS3B;IAED;;;;;;;;;OASG;IACH,UAPa,OAAO,CAAC,IAAI,CAAC,CAczB;;CACF;eA/ec,iBAAiB;4BADJ,sBAAsB"}
@@ -40,7 +40,19 @@ export default class FileSystem {
40
40
  * @param {FileObject|DirectoryObject} to - The target file or directory object
41
41
  * @returns {string} The relative path from `from` to `to`, or the absolute path if not reachable
42
42
  */
43
- static relativeOrAbsolutePath(from: FileObject | DirectoryObject, to: FileObject | DirectoryObject): string;
43
+ static relativeOrAbsolute(from: FileObject | DirectoryObject, to: FileObject | DirectoryObject): string;
44
+ /**
45
+ * Computes the relative path from one file or directory to another.
46
+ *
47
+ * If the target is outside the source (i.e., the relative path starts with
48
+ * ".."), returns the absolute path to the target instead.
49
+ *
50
+ * @static
51
+ * @param {string} from - The source file or directory object
52
+ * @param {string} to - The target file or directory object
53
+ * @returns {string} The relative path from `from` to `to`, or the absolute path if not reachable
54
+ */
55
+ static relativeOrAbsolutePath(from: string, to: string): string;
44
56
  /**
45
57
  * Merge two paths by finding overlapping segments and combining them
46
58
  * efficiently
@@ -156,21 +168,6 @@ export default class FileSystem {
156
168
  * FS.virtualToRealPath(regular) // "/home/user/file.txt"
157
169
  */
158
170
  static virtualToRealPath(fileOrDirectoryObject: FileObject | DirectoryObject): string;
159
- /**
160
- * Convert an absolute path to a relative format by removing the root component.
161
- * By default, keeps a leading separator (making it "absolute-like relative").
162
- * Use forceActuallyRelative to get a truly relative path without leading separator.
163
- *
164
- * @static
165
- * @param {string} pathToCheck - The path to convert (returned unchanged if already relative)
166
- * @param {boolean} [forceActuallyRelative=false] - If true, removes leading separator for truly relative path
167
- * @returns {string} The relative path (with or without leading separator based on forceActuallyRelative)
168
- * @example
169
- * FS.absoluteToRelative("/home/user/docs") // "/home/user/docs" (with leading /)
170
- * FS.absoluteToRelative("/home/user/docs", true) // "home/user/docs" (truly relative)
171
- * FS.absoluteToRelative("relative/path") // "relative/path" (unchanged)
172
- */
173
- static absoluteToRelative(pathToCheck: string, forceActuallyRelative?: boolean): string;
174
171
  /**
175
172
  * Compute the relative path from another file or directory to this instance.
176
173
  *
@@ -1 +1 @@
1
- {"version":3,"file":"FileSystem.d.ts","sourceRoot":"","sources":["../../../src/node/lib/FileSystem.js"],"names":[],"mappings":"AA0BA;;GAEG;AACH;IACE,kCAAwB;IACxB,uCAAkC;IAClC,mBAAsB;IAsBtB;;;;;;OAMG;IACH,4BAHW,MAAM,GACJ,MAAM,CAIlB;IAED;;;;;;OAMG;IACH,2BAHW,MAAM,GACJ,MAAM,CAQlB;IAED;;;;;;OAMG;IACH,2BAHW,MAAM,GACJ,MAAM,CAQlB;IAED;;;;;;;;;;OAUG;IACH,oCAJW,UAAU,GAAC,eAAe,MAC1B,UAAU,GAAC,eAAe,GACxB,MAAM,CAYlB;IAED;;;;;;;;;OASG;IACH,oCALW,MAAM,SACN,MAAM,QACN,MAAM,GACJ,MAAM,CA0BlB;IAED;;;;;;;;OAQG;IACH,6BAJW,MAAM,UACN,MAAM,GACJ,MAAM,CAmClB;IAED;;;;;;;;;;;;OAYG;IACH,+BATW,MAAM,aACN,MAAM,GACJ,OAAO,CAcnB;IAED;;;;;;;;;;;;;;OAcG;IACH,4BATW,MAAM,MACN,MAAM,QACN,MAAM,GACJ,MAAM,GAAC,IAAI,CAwBvB;IAED;;;;;;;;;;;;;;;OAeG;IACH,+BAXW,MAAM,MACN,MAAM,QACN,MAAM,GACJ,MAAM,GAAC,IAAI,CA+BvB;IAED;;;;;OAKG;IAEH;;;;;;;OAOG;IACH,2BAJW,MAAM;;;;cATH,MAAM;;;;aACN,MAAM;;;;aACN,MAAM;MAenB;IAED;;;;;;;;;;;;;;;;;OAiBG;IACH,gDAZW,UAAU,GAAC,eAAe,GACxB,MAAM,CAiClB;IAED;;;;;;;;;;;;;OAaG;IACH,uCARW,MAAM,0BACN,OAAO,GACL,MAAM,CAkBlB;IA/VD;;;;;;;;;OASG;IACH,kCAJW,UAAU,GAAC,eAAe,GACxB,MAAM,CAWlB;CA8UF;yBAjXa,OAAO,iBAAiB,EAAE,OAAO;8BACjC,OAAO,sBAAsB,EAAE,OAAO"}
1
+ {"version":3,"file":"FileSystem.d.ts","sourceRoot":"","sources":["../../../src/node/lib/FileSystem.js"],"names":[],"mappings":"AA0BA;;GAEG;AACH;IACE,kCAAwB;IACxB,uCAAkC;IAClC,mBAAsB;IAsBtB;;;;;;OAMG;IACH,4BAHW,MAAM,GACJ,MAAM,CAIlB;IAED;;;;;;OAMG;IACH,2BAHW,MAAM,GACJ,MAAM,CAQlB;IAED;;;;;;OAMG;IACH,2BAHW,MAAM,GACJ,MAAM,CAQlB;IAED;;;;;;;;;;OAUG;IACH,gCAJW,UAAU,GAAC,eAAe,MAC1B,UAAU,GAAC,eAAe,GACxB,MAAM,CAYlB;IAED;;;;;;;;;;OAUG;IACH,oCAJW,MAAM,MACN,MAAM,GACJ,MAAM,CAQlB;IAED;;;;;;;;;OASG;IACH,oCALW,MAAM,SACN,MAAM,QACN,MAAM,GACJ,MAAM,CA0BlB;IAED;;;;;;;;OAQG;IACH,6BAJW,MAAM,UACN,MAAM,GACJ,MAAM,CAmClB;IAED;;;;;;;;;;;;OAYG;IACH,+BATW,MAAM,aACN,MAAM,GACJ,OAAO,CAcnB;IAED;;;;;;;;;;;;;;OAcG;IACH,4BATW,MAAM,MACN,MAAM,QACN,MAAM,GACJ,MAAM,GAAC,IAAI,CAwBvB;IAED;;;;;;;;;;;;;;;OAeG;IACH,+BAXW,MAAM,MACN,MAAM,QACN,MAAM,GACJ,MAAM,GAAC,IAAI,CA+BvB;IAED;;;;;OAKG;IAEH;;;;;;;OAOG;IACH,2BAJW,MAAM;;;;cATH,MAAM;;;;aACN,MAAM;;;;aACN,MAAM;MAenB;IAED;;;;;;;;;;;;;;;;;OAiBG;IACH,gDAZW,UAAU,GAAC,eAAe,GACxB,MAAM,CAiClB;IAtVD;;;;;;;;;OASG;IACH,kCAJW,UAAU,GAAC,eAAe,GACxB,MAAM,CAWlB;CAqUF;yBAxWa,OAAO,iBAAiB,EAAE,OAAO;8BACjC,OAAO,sBAAsB,EAAE,OAAO"}
@@ -1 +1 @@
1
- {"version":3,"file":"VFileObject.d.ts","sourceRoot":"","sources":["../../../src/node/lib/VFileObject.js"],"names":[],"mappings":"AAUA;;;;;;;;;;;;;;;;;;GAkBG;AAEH;IAGE;;;;;OAKG;IACH,sBAHW,MAAM,UACN,gBAAgB,EAc1B;IAED,yBAEC;IAED,uBAEC;;CACF;uBAtDsB,iBAAiB"}
1
+ {"version":3,"file":"VFileObject.d.ts","sourceRoot":"","sources":["../../../src/node/lib/VFileObject.js"],"names":[],"mappings":"AAUA;;;;;;;;;;;;;;;;;;GAkBG;AAEH;IAGE;;;;;OAKG;IACH,sBAHW,MAAM,UACN,gBAAgB,EAa1B;IAED,yBAEC;IAED,uBAEC;;CACF;uBArDsB,iBAAiB"}