@gesslar/toolkit 3.9.0 → 3.13.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.
@@ -16,73 +16,26 @@ export default class TempDirectoryObject extends CappedDirectoryObject {
16
16
  * @throws {Sass} Always throws an error
17
17
  */
18
18
  static fromCwd(): void;
19
+ get isTemporary(): boolean;
20
+ get cap(): any;
19
21
  /**
20
- * Constructs a TempDirectoryObject instance and creates the directory.
22
+ * Recursively removes a temporary directory and all its contents.
21
23
  *
22
- * The directory is created synchronously during construction, so it will
23
- * exist immediately after the constructor returns.
24
+ * This method will delete all files and subdirectories within this directory,
25
+ * then delete the directory itself. It only works on directories explicitly
26
+ * marked as temporary for safety.
24
27
  *
25
- * If no name is provided, uses the OS temp directory directly. If a name
26
- * is provided without a parent, creates a new directory with a unique suffix.
27
- * If a parent is provided, creates a subdirectory within that parent.
28
- *
29
- * @param {string?} [name] - Base name for the temp directory (if empty/null, uses OS temp dir)
30
- * @param {TempDirectoryObject?} [parent] - Optional parent temporary directory
31
- * @throws {Sass} If name is absolute
32
- * @throws {Sass} If name is empty (when parent is provided)
33
- * @throws {Sass} If name contains path separators
34
- * @throws {Sass} If parent is provided but not a temporary directory
35
- * @throws {Sass} If parent's lineage does not trace back to the OS temp directory
36
- * @throws {Sass} If directory creation fails
37
- * @example
38
- * // Use OS temp directory directly
39
- * const temp = new TempDirectoryObject()
40
- * console.log(temp.path) // "/tmp"
41
- *
42
- * @example
43
- * // Create with unique name
44
- * const temp = new TempDirectoryObject("myapp")
45
- * console.log(temp.path) // "/tmp/myapp-ABC123"
46
- *
47
- * @example
48
- * // Nested temp directories
49
- * const parent = new TempDirectoryObject("parent")
50
- * const child = new TempDirectoryObject("child", parent)
51
- * await parent.remove() // Removes both parent and child
52
- */
53
- constructor(name?: string | null, parent?: TempDirectoryObject | null);
54
- /**
55
- * Creates a new TempDirectoryObject by extending this directory's path.
56
- *
57
- * Validates that the resulting path remains within the temp directory tree.
58
- *
59
- * @param {string} newPath - The path segment to append
60
- * @returns {TempDirectoryObject} A new TempDirectoryObject with the extended path
61
- * @throws {Sass} If the path would escape the temp directory
62
- * @throws {Sass} If the path is absolute
63
- * @throws {Sass} If the path contains traversal (..)
64
- * @example
65
- * const temp = new TempDirectoryObject("myapp")
66
- * const subDir = temp.getDirectory("data")
67
- * console.log(subDir.path) // "/tmp/myapp-ABC123/data"
68
- */
69
- getDirectory(newPath: string): TempDirectoryObject;
70
- /**
71
- * Creates a new FileObject by extending this directory's path.
72
- *
73
- * Validates that the resulting path remains within the temp directory tree.
74
- *
75
- * @param {string} filename - The filename to append
76
- * @returns {FileObject} A new FileObject with the extended path
77
- * @throws {Sass} If the path would escape the temp directory
78
- * @throws {Sass} If the path is absolute
79
- * @throws {Sass} If the path contains traversal (..)
28
+ * @async
29
+ * @returns {Promise<void>}
30
+ * @throws {Sass} If the directory is not marked as temporary
31
+ * @throws {Sass} If the directory deletion fails
80
32
  * @example
81
- * const temp = new TempDirectoryObject("myapp")
82
- * const file = temp.getFile("config.json")
83
- * console.log(file.path) // "/tmp/myapp-ABC123/config.json"
33
+ * const tempDir = new TempDirectoryObject("my-temp")
34
+ * await tempDir.assureExists()
35
+ * // ... use the directory ...
36
+ * await tempDir.remove() // Recursively deletes everything
84
37
  */
85
- getFile(filename: string): FileObject;
38
+ remove(): Promise<void>;
86
39
  #private;
87
40
  }
88
41
  import CappedDirectoryObject from "./CappedDirectoryObject.js";
@@ -1 +1 @@
1
- {"version":3,"file":"TempDirectoryObject.d.ts","sourceRoot":"","sources":["../../lib/TempDirectoryObject.js"],"names":[],"mappings":"AAcA;;;;;;;;;GASG;AACH;IA4GE;;;;;OAKG;IACH,uBAKC;IArHD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAiCG;IACH,mBAxBW,MAAM,OAAC,WACP,mBAAmB,OAAC,EA6F9B;IAmCD;;;;;;;;;;;;;;OAcG;IACH,sBAVW,MAAM,GACJ,mBAAmB,CAY/B;IAED;;;;;;;;;;;;;;OAcG;IACH,kBAVW,MAAM,GACJ,UAAU,CAYtB;;CAUF;kCA3MiC,4BAA4B"}
1
+ {"version":3,"file":"TempDirectoryObject.d.ts","sourceRoot":"","sources":["../../lib/TempDirectoryObject.js"],"names":[],"mappings":"AAiBA;;;;;;;;;GASG;AACH;IAgIE;;;;;OAKG;IACH,uBAEC;IA1ED,2BAEC;IAwBD,eAEC;IAED;;;;;;;;;;;;;;;;OAgBG;IACH,UATa,OAAO,CAAC,IAAI,CAAC,CAWzB;;CA0BF;kCAzJiC,4BAA4B"}