@gesslar/toolkit 3.13.0 → 3.14.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.
Files changed (76) hide show
  1. package/README.md +5 -4
  2. package/package.json +2 -2
  3. package/src/{index.js → node/index.js} +11 -10
  4. package/src/{lib → node/lib}/DirectoryObject.js +47 -56
  5. package/src/{lib → node/lib}/FileObject.js +76 -149
  6. package/src/{lib/FS.js → node/lib/FileSystem.js} +7 -7
  7. package/src/{lib → node/lib}/Glog.js +2 -2
  8. package/src/{lib → node/lib}/Logger.js +1 -1
  9. package/src/{lib → node/lib}/Sass.js +1 -1
  10. package/src/{lib → node/lib}/Tantrum.js +1 -1
  11. package/src/{lib → node/lib}/TempDirectoryObject.js +9 -9
  12. package/src/{lib → node/lib}/Util.js +1 -1
  13. package/src/{lib/CappedDirectoryObject.js → node/lib/VDirectoryObject.js} +37 -92
  14. package/src/node/lib/VFileObject.js +61 -0
  15. package/src/{lib → node/lib}/Valid.js +11 -5
  16. package/src/types/browser/index.d.ts +0 -13
  17. package/src/types/browser/index.d.ts.map +0 -1
  18. package/src/types/browser/lib/Collection.d.ts +0 -248
  19. package/src/types/browser/lib/Collection.d.ts.map +0 -1
  20. package/src/types/browser/lib/Data.d.ts +0 -250
  21. package/src/types/browser/lib/Data.d.ts.map +0 -1
  22. package/src/types/browser/lib/Disposer.d.ts +0 -33
  23. package/src/types/browser/lib/Disposer.d.ts.map +0 -1
  24. package/src/types/browser/lib/HTML.d.ts +0 -40
  25. package/src/types/browser/lib/HTML.d.ts.map +0 -1
  26. package/src/types/browser/lib/Notify.d.ts +0 -60
  27. package/src/types/browser/lib/Notify.d.ts.map +0 -1
  28. package/src/types/browser/lib/Promised.d.ts +0 -119
  29. package/src/types/browser/lib/Promised.d.ts.map +0 -1
  30. package/src/types/browser/lib/Sass.d.ts +0 -63
  31. package/src/types/browser/lib/Sass.d.ts.map +0 -1
  32. package/src/types/browser/lib/Tantrum.d.ts +0 -52
  33. package/src/types/browser/lib/Tantrum.d.ts.map +0 -1
  34. package/src/types/browser/lib/Time.d.ts +0 -42
  35. package/src/types/browser/lib/Time.d.ts.map +0 -1
  36. package/src/types/browser/lib/TypeSpec.d.ts +0 -90
  37. package/src/types/browser/lib/TypeSpec.d.ts.map +0 -1
  38. package/src/types/browser/lib/Util.d.ts +0 -62
  39. package/src/types/browser/lib/Util.d.ts.map +0 -1
  40. package/src/types/browser/lib/Valid.d.ts +0 -33
  41. package/src/types/browser/lib/Valid.d.ts.map +0 -1
  42. package/src/types/browser/lib/vendor/dompurify.esm.d.ts +0 -29
  43. package/src/types/browser/lib/vendor/dompurify.esm.d.ts.map +0 -1
  44. package/src/types/index.d.ts +0 -20
  45. package/src/types/index.d.ts.map +0 -1
  46. package/src/types/lib/Cache.d.ts +0 -27
  47. package/src/types/lib/Cache.d.ts.map +0 -1
  48. package/src/types/lib/CappedDirectoryObject.d.ts +0 -144
  49. package/src/types/lib/CappedDirectoryObject.d.ts.map +0 -1
  50. package/src/types/lib/DirectoryObject.d.ts +0 -277
  51. package/src/types/lib/DirectoryObject.d.ts.map +0 -1
  52. package/src/types/lib/FS.d.ts +0 -188
  53. package/src/types/lib/FS.d.ts.map +0 -1
  54. package/src/types/lib/FileObject.d.ts +0 -238
  55. package/src/types/lib/FileObject.d.ts.map +0 -1
  56. package/src/types/lib/Glog.d.ts +0 -228
  57. package/src/types/lib/Glog.d.ts.map +0 -1
  58. package/src/types/lib/Logger.d.ts +0 -46
  59. package/src/types/lib/Logger.d.ts.map +0 -1
  60. package/src/types/lib/Notify.d.ts +0 -54
  61. package/src/types/lib/Notify.d.ts.map +0 -1
  62. package/src/types/lib/Sass.d.ts +0 -9
  63. package/src/types/lib/Sass.d.ts.map +0 -1
  64. package/src/types/lib/Tantrum.d.ts +0 -9
  65. package/src/types/lib/Tantrum.d.ts.map +0 -1
  66. package/src/types/lib/TempDirectoryObject.d.ts +0 -42
  67. package/src/types/lib/TempDirectoryObject.d.ts.map +0 -1
  68. package/src/types/lib/Term.d.ts +0 -127
  69. package/src/types/lib/Term.d.ts.map +0 -1
  70. package/src/types/lib/Util.d.ts +0 -100
  71. package/src/types/lib/Util.d.ts.map +0 -1
  72. package/src/types/lib/Valid.d.ts +0 -33
  73. package/src/types/lib/Valid.d.ts.map +0 -1
  74. /package/src/{lib → node/lib}/Cache.js +0 -0
  75. /package/src/{lib → node/lib}/Notify.js +0 -0
  76. /package/src/{lib → node/lib}/Term.js +0 -0
@@ -1,42 +0,0 @@
1
- /**
2
- * Utility class for timing operations and promise-based delays.
3
- * Provides methods for creating cancellable timeout promises.
4
- */
5
- export default class Time {
6
- /**
7
- * Creates a promise that resolves after a specified delay.
8
- * The returned promise includes a timerId property that can be used with cancel().
9
- *
10
- * @param {number} delay - Delay in milliseconds before resolving (must be >= 0)
11
- * @param {unknown} [value] - Optional value to resolve with after the delay
12
- * @returns {Promise<unknown> & {timerId: number}} Promise that resolves with the value after delay, extended with timerId property
13
- * @throws {Sass} If delay is not a number or is negative
14
- * @example
15
- * // Wait 1 second then continue
16
- * await Time.after(1000)
17
- *
18
- * // Wait 1 second then get a value
19
- * const result = await Time.after(1000, 'done')
20
- *
21
- * // Create a cancellable delay
22
- * const promise = Time.after(5000, 'data')
23
- * Time.cancel(promise) // Cancel before it resolves
24
- */
25
- static after(delay: number, value?: unknown): Promise<unknown> & {
26
- timerId: number;
27
- };
28
- /**
29
- * Cancels a promise created by Time.after() by clearing its timeout.
30
- * If the promise has already resolved or is not a Time.after() promise, this is a no-op.
31
- *
32
- * @param {Promise<unknown> & {timerId?: number}} promise - Promise returned from Time.after() to cancel
33
- * @returns {void}
34
- * @example
35
- * const promise = Time.after(5000, 'data')
36
- * Time.cancel(promise) // Prevents the promise from resolving
37
- */
38
- static cancel(promise: Promise<unknown> & {
39
- timerId?: number;
40
- }): void;
41
- }
42
- //# sourceMappingURL=Time.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Time.d.ts","sourceRoot":"","sources":["../../../browser/lib/Time.js"],"names":[],"mappings":"AAEA;;;GAGG;AACH;IACE;;;;;;;;;;;;;;;;;;OAkBG;IACH,oBAfW,MAAM,UACN,OAAO,GACL,OAAO,CAAC,OAAO,CAAC,GAAG;QAAC,OAAO,EAAE,MAAM,CAAA;KAAC,CAwBhD;IAED;;;;;;;;;OASG;IACH,uBANW,OAAO,CAAC,OAAO,CAAC,GAAG;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAC,GACnC,IAAI,CAQhB;CACF"}
@@ -1,90 +0,0 @@
1
- /**
2
- * Type specification class for parsing and validating complex type definitions.
3
- * Supports union types, array types, and validation options.
4
- */
5
- export default class TypeSpec {
6
- /**
7
- * Creates a new TypeSpec instance.
8
- *
9
- * @param {string} string - The type specification string (e.g., "string|number", "object[]")
10
- * @param {unknown} options - Additional parsing options
11
- */
12
- constructor(string: string, options: unknown);
13
- specs: any[];
14
- length: number;
15
- stringRepresentation: string;
16
- /**
17
- * Returns a string representation of the type specification.
18
- *
19
- * @returns {string} The type specification as a string (e.g., "string|number[]")
20
- */
21
- toString(): string;
22
- /**
23
- * Returns a JSON representation of the TypeSpec.
24
- *
25
- * @returns {unknown} Object containing specs, length, and string representation
26
- */
27
- toJSON(): unknown;
28
- /**
29
- * Executes a provided function once for each type specification.
30
- *
31
- * @param {function(unknown): void} callback - Function to execute for each spec
32
- */
33
- forEach(callback: (arg0: unknown) => void): void;
34
- /**
35
- * Tests whether all type specifications pass the provided test function.
36
- *
37
- * @param {function(unknown): boolean} callback - Function to test each spec
38
- * @returns {boolean} True if all specs pass the test
39
- */
40
- every(callback: (arg0: unknown) => boolean): boolean;
41
- /**
42
- * Tests whether at least one type specification passes the provided test function.
43
- *
44
- * @param {function(unknown): boolean} callback - Function to test each spec
45
- * @returns {boolean} True if at least one spec passes the test
46
- */
47
- some(callback: (arg0: unknown) => boolean): boolean;
48
- /**
49
- * Creates a new array with all type specifications that pass the provided test function.
50
- *
51
- * @param {function(unknown): boolean} callback - Function to test each spec
52
- * @returns {Array<unknown>} New array with filtered specs
53
- */
54
- filter(callback: (arg0: unknown) => boolean): Array<unknown>;
55
- /**
56
- * Creates a new array populated with the results of calling the provided function on every spec.
57
- *
58
- * @param {function(unknown): unknown} callback - Function to call on each spec
59
- * @returns {Array<unknown>} New array with mapped values
60
- */
61
- map(callback: (arg0: unknown) => unknown): Array<unknown>;
62
- /**
63
- * Executes a reducer function on each spec, resulting in a single output value.
64
- *
65
- * @param {function(unknown, unknown): unknown} callback - Function to execute on each spec
66
- * @param {unknown} initialValue - Initial value for the accumulator
67
- * @returns {unknown} The final accumulated value
68
- */
69
- reduce(callback: (arg0: unknown, arg1: unknown) => unknown, initialValue: unknown): unknown;
70
- /**
71
- * Returns the first type specification that satisfies the provided testing function.
72
- *
73
- * @param {function(unknown): boolean} callback - Function to test each spec
74
- * @returns {object|undefined} The first spec that matches, or undefined
75
- */
76
- find(callback: (arg0: unknown) => boolean): object | undefined;
77
- /**
78
- * Tests whether a value matches any of the type specifications.
79
- * Handles array types, union types, and empty value validation.
80
- *
81
- * @param {unknown} value - The value to test against the type specifications
82
- * @param {unknown} options - Validation options
83
- * @param {boolean} options.allowEmpty - Whether empty values are allowed
84
- * @returns {boolean} True if the value matches any type specification
85
- */
86
- matches(value: unknown, options: unknown): boolean;
87
- match(value: any, options: any): unknown[];
88
- #private;
89
- }
90
- //# sourceMappingURL=TypeSpec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TypeSpec.d.ts","sourceRoot":"","sources":["../../../browser/lib/TypeSpec.js"],"names":[],"mappings":"AAWA;;;GAGG;AACH;IAGE;;;;;OAKG;IACH,oBAHW,MAAM,WACN,OAAO,EAUjB;IAJC,aAAwB;IACxB,eAAgC;IAChC,6BAA2C;IAI7C;;;;OAIG;IACH,YAFa,MAAM,CAQlB;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;;;;;;;;OAQG;IACH,eALW,OAAO,WACP,OAAO,GAEL,OAAO,CAInB;IAED,2CA6DC;;CAmDF"}
@@ -1,62 +0,0 @@
1
- /**
2
- * Utility class providing common helper functions for string manipulation,
3
- * timing, and option parsing.
4
- */
5
- export default class Util {
6
- /**
7
- * Capitalizes the first letter of a string.
8
- *
9
- * @param {string} text - The text to capitalize
10
- * @returns {string} Text with first letter capitalized
11
- */
12
- static capitalize(text: string): string;
13
- /**
14
- * Measure wall-clock time for an async function.
15
- *
16
- * @template T
17
- * @param {() => Promise<T>} fn - Thunk returning a promise.
18
- * @returns {Promise<{result: T, cost: number}>} Object containing result and elapsed ms (number, 1 decimal).
19
- */
20
- static time<T>(fn: () => Promise<T>): Promise<{
21
- result: T;
22
- cost: number;
23
- }>;
24
- /**
25
- * Right-align a string inside a fixed width (left pad with spaces).
26
- * If the string exceeds width it is returned unchanged.
27
- *
28
- * @param {string|number} text - Text to align.
29
- * @param {number} width - Target field width (default 80).
30
- * @returns {string} Padded string.
31
- */
32
- static rightAlignText(text: string | number, width?: number): string;
33
- /**
34
- * Centre-align a string inside a fixed width (pad with spaces on left).
35
- * If the string exceeds width it is returned unchanged.
36
- *
37
- * @param {string|number} text - Text to align.
38
- * @param {number} width - Target field width (default 80).
39
- * @returns {string} Padded string with text centred.
40
- */
41
- static centreAlignText(text: string | number, width?: number): string;
42
- /**
43
- * Determine the Levenshtein distance between two string values
44
- *
45
- * @param {string} a The first value for comparison.
46
- * @param {string} b The second value for comparison.
47
- * @returns {number} The Levenshtein distance
48
- */
49
- static levenshteinDistance(a: string, b: string): number;
50
- /**
51
- * Determine the closest match between a string and allowed values
52
- * from the Levenshtein distance.
53
- *
54
- * @param {string} input The input string to resolve
55
- * @param {Array<string>} allowedValues The values which are permitted
56
- * @param {number} [threshold] Max edit distance for a "close match"
57
- * @returns {string} Suggested, probable match.
58
- */
59
- static findClosestMatch(input: string, allowedValues: Array<string>, threshold?: number): string;
60
- static regexify(input: any, trim?: boolean, flags?: any[]): RegExp;
61
- }
62
- //# sourceMappingURL=Util.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Util.d.ts","sourceRoot":"","sources":["../../../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,mEAiBC;CACF"}
@@ -1,33 +0,0 @@
1
- /**
2
- * Validation utility class providing type checking and assertion methods.
3
- */
4
- export default class Valid {
5
- /**
6
- * Validates a value against a type. Uses Data.isType.
7
- *
8
- * @param {unknown} value - The value to validate
9
- * @param {string} type - The expected type in the form of "object", "object[]", "object|object[]"
10
- * @param {object} [options] - Additional options for validation.
11
- */
12
- static type(value: unknown, type: string, options?: object): void;
13
- /**
14
- * Asserts a condition
15
- *
16
- * @param {boolean} condition - The condition to assert
17
- * @param {string} message - The message to display if the condition is not
18
- * met
19
- * @param {number} [arg] - The argument to display if the condition is not
20
- * met (optional)
21
- */
22
- static assert(condition: boolean, message: string, arg?: number): void;
23
- static "__#private@#restrictedProto": string[];
24
- /**
25
- * Protects against prototype pollution by checking keys for dangerous property names.
26
- * Throws if any restricted prototype properties are found in the keys array.
27
- *
28
- * @param {Array<string>} keys - Array of property keys to validate
29
- * @throws {Sass} If any key matches restricted prototype properties (__proto__, constructor, prototype)
30
- */
31
- static prototypePollutionProtection(keys: Array<string>): void;
32
- }
33
- //# sourceMappingURL=Valid.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Valid.d.ts","sourceRoot":"","sources":["../../../browser/lib/Valid.js"],"names":[],"mappings":"AAWA;;GAEG;AACH;IACE;;;;;;OAMG;IACH,mBAJW,OAAO,QACP,MAAM,YACN,MAAM,QAQhB;IAED;;;;;;;;OAQG;IACH,yBANW,OAAO,WACP,MAAM,QAEN,MAAM,QAkBhB;IAED,+CAAmE;IAEnE;;;;;;OAMG;IACH,0CAHW,KAAK,CAAC,MAAM,CAAC,QAYvB;CACF"}
@@ -1,29 +0,0 @@
1
- export { purify as default };
2
- declare function purify(root: any): {
3
- (root: any): /*elided*/ any;
4
- version: string;
5
- removed: any[];
6
- isSupported: boolean;
7
- sanitize(dirty: any, ...args: any[]): any;
8
- setConfig(...args: any[]): void;
9
- clearConfig(): void;
10
- isValidAttribute(tag: any, attr: any, value: any): boolean;
11
- addHook(entryPoint: any, hookFunction: any): void;
12
- removeHook(entryPoint: any, hookFunction: any): any;
13
- removeHooks(entryPoint: any): void;
14
- removeAllHooks(): void;
15
- };
16
- declare namespace purify {
17
- let version: string;
18
- let removed: any[];
19
- let isSupported: boolean;
20
- function sanitize(dirty: any, ...args: any[]): any;
21
- function setConfig(...args: any[]): void;
22
- function clearConfig(): void;
23
- function isValidAttribute(tag: any, attr: any, value: any): boolean;
24
- function addHook(entryPoint: any, hookFunction: any): void;
25
- function removeHook(entryPoint: any, hookFunction: any): any;
26
- function removeHooks(entryPoint: any): void;
27
- function removeAllHooks(): void;
28
- }
29
- //# sourceMappingURL=dompurify.esm.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dompurify.esm.d.ts","sourceRoot":"","sources":["../../../../browser/lib/vendor/dompurify.esm.js"],"names":[],"mappings":";AA0UE;;;;;;;;;;;;;EAA+C;;;;;IA+9B/C,mDAiJC;IACD,yCAIC;IACD,6BAGC;IACD,oEAUC;IACD,2DAMC;IACD,6DAQC;IACD,4CAEC;IACD,gCAEC"}
@@ -1,20 +0,0 @@
1
- export { default as Collection } from "./browser/lib/Collection.js";
2
- export { default as Data } from "./browser/lib/Data.js";
3
- export { default as Promised } from "./browser/lib/Promised.js";
4
- export { default as Time } from "./browser/lib/Time.js";
5
- export { default as Type } from "./browser/lib/TypeSpec.js";
6
- export { default as Valid } from "./lib/Valid.js";
7
- export { default as Sass } from "./lib/Sass.js";
8
- export { default as Tantrum } from "./lib/Tantrum.js";
9
- export { default as Util } from "./lib/Util.js";
10
- export { default as Cache } from "./lib/Cache.js";
11
- export { default as CappedDirectoryObject } from "./lib/CappedDirectoryObject.js";
12
- export { default as DirectoryObject } from "./lib/DirectoryObject.js";
13
- export { default as TempDirectoryObject } from "./lib/TempDirectoryObject.js";
14
- export { default as FileObject } from "./lib/FileObject.js";
15
- export { default as FS } from "./lib/FS.js";
16
- export { default as Glog } from "./lib/Glog.js";
17
- export { default as Notify } from "./lib/Notify.js";
18
- export { default as Term } from "./lib/Term.js";
19
- export { default as Disposer, Disposer as DisposerClass } from "./browser/lib/Disposer.js";
20
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.js"],"names":[],"mappings":""}
@@ -1,27 +0,0 @@
1
- /**
2
- * File system cache with automatic invalidation based on modification time.
3
- * Provides intelligent caching of parsed JSON5/YAML files with mtime-based
4
- * cache invalidation to optimize performance for repeated file access.
5
- *
6
- * The cache eliminates redundant file reads and parsing when multiple processes
7
- * access the same dependency files, while ensuring data freshness through
8
- * modification time checking.
9
- */
10
- export default class Cache {
11
- /**
12
- * Loads and caches parsed file data with automatic invalidation based on
13
- * modification time.
14
- *
15
- * Implements a sophisticated caching strategy that checks file modification
16
- * times to determine whether cached data is still valid, ensuring data
17
- * freshness while optimizing performance for repeated file access during
18
- * parallel processing.
19
- *
20
- * @param {import("./FileObject.js").FileObject} fileObject - The file object to load and cache
21
- * @returns {Promise<unknown>} The parsed file data (JSON5 or YAML)
22
- * @throws {Sass} If the file cannot be found or accessed
23
- */
24
- loadCachedData(fileObject: import("./FileObject.js").FileObject): Promise<unknown>;
25
- #private;
26
- }
27
- //# sourceMappingURL=Cache.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Cache.d.ts","sourceRoot":"","sources":["../../lib/Cache.js"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH;IAoBE;;;;;;;;;;;;OAYG;IACH,2BAJW,OAAO,iBAAiB,EAAE,UAAU,GAClC,OAAO,CAAC,OAAO,CAAC,CA6B5B;;CACF"}
@@ -1,144 +0,0 @@
1
- /**
2
- * CappedDirectoryObject extends DirectoryObject with constraints that ensure
3
- * all operations are restricted to a specific directory tree (the "cap").
4
- *
5
- * All path operations are validated to ensure they remain within the
6
- * cap directory hierarchy for security.
7
- *
8
- * @augments DirectoryObject
9
- */
10
- export default class CappedDirectoryObject extends DirectoryObject {
11
- /**
12
- * Creates a CappedDirectoryObject from the current working directory.
13
- * This is useful when working with pnpx or other tools where you need to
14
- * cap at the project's root directory determined at runtime.
15
- *
16
- * @returns {CappedDirectoryObject} A CappedDirectoryObject capped at the current working directory
17
- * @example
18
- * // When using pnpx or similar tools
19
- * const projectRoot = CappedDirectoryObject.fromCwd()
20
- * const srcDir = projectRoot.getDirectory("src")
21
- * // srcDir is capped at the project root
22
- */
23
- static fromCwd(): CappedDirectoryObject;
24
- /**
25
- * Constructs a CappedDirectoryObject instance.
26
- *
27
- * Without a parent, the path becomes both the directory location and the cap
28
- * (virtual root). With a parent, the path is resolved relative to the parent's
29
- * cap using virtual path semantics (absolute paths treated as cap-relative).
30
- *
31
- * @param {string} [directory="."] - Directory path (becomes cap if no parent, else relative to parent's cap, defaults to current directory)
32
- * @param {CappedDirectoryObject?} [parent] - Optional parent capped directory
33
- * @throws {Sass} If parent is provided but not a CappedDirectoryObject
34
- * @throws {Sass} If the resulting path would escape the cap
35
- * @example
36
- * // Create new capped directory at current directory
37
- * const cwd = new CappedDirectoryObject()
38
- * // path: process.cwd(), cap: process.cwd()
39
- *
40
- * @example
41
- * // Create new capped directory
42
- * const cache = new CappedDirectoryObject("/home/user/.cache")
43
- * // path: /home/user/.cache, cap: /home/user/.cache
44
- *
45
- * @example
46
- * // Create subdirectory with parent
47
- * const data = new CappedDirectoryObject("data", cache)
48
- * // path: /home/user/.cache/data, cap: /home/user/.cache
49
- *
50
- * @example
51
- * // Virtual absolute path with parent
52
- * const config = new CappedDirectoryObject("/etc/config", cache)
53
- * // path: /home/user/.cache/etc/config, cap: /home/user/.cache
54
- */
55
- constructor(directory?: string, source?: any);
56
- /**
57
- * Indicates whether this directory is capped (constrained to a specific tree).
58
- * Always returns true for CappedDirectoryObject instances.
59
- *
60
- * @returns {boolean} True for all CappedDirectoryObject instances
61
- * @example
62
- * const capped = new TempDirectoryObject("myapp")
63
- * console.log(capped.isCapped) // true
64
- *
65
- * const regular = new DirectoryObject("/tmp")
66
- * console.log(regular.isCapped) // false
67
- */
68
- get isCapped(): boolean;
69
- /**
70
- * Returns the cap (root) of the capped directory tree.
71
- * For root CappedDirectoryObject instances, returns itself.
72
- * For children, returns the inherited cap from the parent chain.
73
- *
74
- * @returns {CappedDirectoryObject} The cap directory object (root of the capped tree)
75
- * @example
76
- * const temp = new TempDirectoryObject("myapp")
77
- * console.log(temp.cap === temp) // true (root is its own cap)
78
- *
79
- * const subdir = temp.getDirectory("data")
80
- * console.log(subdir.cap === temp) // true (child inherits parent's cap)
81
- */
82
- get cap(): CappedDirectoryObject;
83
- /**
84
- * Returns a plain DirectoryObject representing the actual filesystem location.
85
- * This provides an "escape hatch" from the capped environment to interact
86
- * with the real filesystem when needed.
87
- *
88
- * @returns {DirectoryObject} Uncapped directory object at the real filesystem path
89
- * @example
90
- * const temp = new TempDirectoryObject("myapp")
91
- * const subdir = temp.getDirectory("data")
92
- *
93
- * // Work within the capped environment (virtual paths)
94
- * console.log(subdir.path) // "/data" (virtual)
95
- * subdir.getFile("config.json") // Stays within cap
96
- *
97
- * // Break out to real filesystem when needed
98
- * console.log(subdir.real.path) // "/tmp/myapp-ABC123/data" (real)
99
- * subdir.real.parent // Can traverse outside the cap
100
- */
101
- get real(): DirectoryObject;
102
- /**
103
- * Returns the parent directory of this capped directory.
104
- * Returns null only if this directory is at the cap (the "root" of the capped tree).
105
- *
106
- * Note: The returned parent is a CappedDirectoryObject with the same cap.
107
- * This maintains the capping behavior throughout the directory hierarchy.
108
- *
109
- * @returns {CappedDirectoryObject|null} Parent directory or null if at cap root
110
- * @example
111
- * const capped = new TempDirectoryObject("myapp")
112
- * const subdir = capped.getDirectory("data")
113
- * console.log(subdir.parent.path) // Returns parent CappedDirectoryObject
114
- * console.log(capped.parent) // null (at cap root)
115
- */
116
- get parent(): CappedDirectoryObject | null;
117
- /**
118
- * Returns the path of the parent directory.
119
- * Returns null if this directory is at the cap root (no parent).
120
- *
121
- * @returns {string|null} The parent directory path, or null if at cap root
122
- * @example
123
- * const temp = new TempDirectoryObject("myapp")
124
- * console.log(temp.parentPath) // null (at cap root)
125
- *
126
- * const subdir = temp.getDirectory("data")
127
- * console.log(subdir.parentPath) // "/data" or similar (parent's virtual path)
128
- */
129
- get parentPath(): string | null;
130
- /**
131
- * Override read to use real filesystem path and return capped objects.
132
- *
133
- * @param {string} [pat=""] - Optional glob pattern
134
- * @returns {Promise<{files: Array<FileObject>, directories: Array}>} Directory contents
135
- */
136
- read(...arg: any[]): Promise<{
137
- files: Array<FileObject>;
138
- directories: any[];
139
- }>;
140
- #private;
141
- }
142
- import DirectoryObject from "./DirectoryObject.js";
143
- import FileObject from "./FileObject.js";
144
- //# sourceMappingURL=CappedDirectoryObject.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CappedDirectoryObject.d.ts","sourceRoot":"","sources":["../../lib/CappedDirectoryObject.js"],"names":[],"mappings":"AAiBA;;;;;;;;GAQG;AACH;IAoEE;;;;;;;;;;;OAWG;IACH,kBAPa,qBAAqB,CASjC;IA5ED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACH,wBAxBW,MAAM,gBAqDhB;IAkBD;;;;;;;;;;;OAWG;IACH,gBARa,OAAO,CAUnB;IAED;;;;;;;;;;;;OAYG;IACH,WARa,qBAAqB,CAUjC;IAED;;;;;;;;;;;;;;;;;OAiBG;IACH,YAba,eAAe,CAe3B;IAED;;;;;;;;;;;;;OAaG;IACH,cAPa,qBAAqB,GAAC,IAAI,CAStC;IAED;;;;;;;;;;;OAWG;IACH,kBARa,MAAM,GAAC,IAAI,CAUvB;IAWD;;;;;OAKG;IACH,qBAFa,OAAO,CAAC;QAAC,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;QAAC,WAAW,QAAO;KAAC,CAAC,CAUnE;;CA8BF;4BAhP2B,sBAAsB;uBAC3B,iBAAiB"}