@gesslar/toolkit 2.9.0 → 2.10.1
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 +1 -1
- package/src/lib/CappedDirectoryObject.js +106 -85
- package/src/lib/FileObject.js +18 -10
- package/src/lib/TempDirectoryObject.js +57 -14
- package/src/types/lib/CappedDirectoryObject.d.ts +27 -10
- package/src/types/lib/CappedDirectoryObject.d.ts.map +1 -1
- package/src/types/lib/FileObject.d.ts +3 -2
- package/src/types/lib/FileObject.d.ts.map +1 -1
- package/src/types/lib/TempDirectoryObject.d.ts.map +1 -1
package/package.json
CHANGED
|
@@ -31,89 +31,80 @@ export default class CappedDirectoryObject extends DirectoryObject {
|
|
|
31
31
|
/**
|
|
32
32
|
* Constructs a CappedDirectoryObject instance.
|
|
33
33
|
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
34
|
+
* Without a parent, the path becomes both the directory location and the cap
|
|
35
|
+
* (virtual root). With a parent, the path is resolved relative to the parent's
|
|
36
|
+
* cap using virtual path semantics (absolute paths treated as cap-relative).
|
|
36
37
|
*
|
|
37
|
-
* @param {string
|
|
38
|
-
* @param {string} cap - The root path that constrains this directory tree
|
|
38
|
+
* @param {string} dirPath - Directory path (becomes cap if no parent, else relative to parent's cap)
|
|
39
39
|
* @param {CappedDirectoryObject?} [parent] - Optional parent capped directory
|
|
40
40
|
* @param {boolean} [temporary=false] - Whether this is a temporary directory
|
|
41
|
-
* @throws {Sass} If
|
|
42
|
-
* @throws {Sass} If
|
|
43
|
-
* @throws {Sass} If name contains path separators
|
|
44
|
-
* @throws {Sass} If parent is not a capped directory
|
|
45
|
-
* @throws {Sass} If parent's lineage does not trace back to the cap
|
|
41
|
+
* @throws {Sass} If path is empty
|
|
42
|
+
* @throws {Sass} If parent is provided but not a CappedDirectoryObject
|
|
46
43
|
* @throws {Sass} If the resulting path would escape the cap
|
|
44
|
+
* @example
|
|
45
|
+
* // Create new capped directory
|
|
46
|
+
* const cache = new CappedDirectoryObject("/home/user/.cache")
|
|
47
|
+
* // path: /home/user/.cache, cap: /home/user/.cache
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* // Create subdirectory with parent
|
|
51
|
+
* const data = new CappedDirectoryObject("data", cache)
|
|
52
|
+
* // path: /home/user/.cache/data, cap: /home/user/.cache
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* // Virtual absolute path with parent
|
|
56
|
+
* const config = new CappedDirectoryObject("/etc/config", cache)
|
|
57
|
+
* // path: /home/user/.cache/etc/config, cap: /home/user/.cache
|
|
47
58
|
*/
|
|
48
|
-
constructor(
|
|
49
|
-
Valid.type(
|
|
59
|
+
constructor(dirPath, parent=null, temporary=false) {
|
|
60
|
+
Valid.type(dirPath, "String")
|
|
61
|
+
Valid.assert(dirPath.length > 0, "Path must not be empty.")
|
|
50
62
|
|
|
51
63
|
// Validate parent using instanceof since TypeSpec doesn't understand inheritance
|
|
52
64
|
if(parent !== null && !(parent instanceof CappedDirectoryObject)) {
|
|
53
65
|
throw Sass.new(`Parent must be null or a CappedDirectoryObject instance, got ${Data.typeOf(parent)}`)
|
|
54
66
|
}
|
|
55
67
|
|
|
56
|
-
let
|
|
68
|
+
let cap
|
|
69
|
+
let resolvedPath
|
|
57
70
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
71
|
+
if(!parent) {
|
|
72
|
+
// No parent: dirPath becomes both the directory and the cap
|
|
73
|
+
cap = path.resolve(dirPath)
|
|
74
|
+
resolvedPath = cap
|
|
61
75
|
} else {
|
|
62
|
-
|
|
76
|
+
// With parent: inherit cap and resolve dirPath relative to it
|
|
77
|
+
cap = parent.#cap
|
|
63
78
|
|
|
64
|
-
//
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
Valid.assert(
|
|
70
|
-
name.length > 0,
|
|
71
|
-
"Capped directory name must not be empty.",
|
|
72
|
-
)
|
|
73
|
-
Valid.assert(
|
|
74
|
-
!name.includes("/") && !name.includes("\\") && !name.includes(path.sep),
|
|
75
|
-
"Capped directory name must not contain path separators.",
|
|
76
|
-
)
|
|
79
|
+
// Use real path for filesystem operations
|
|
80
|
+
const parentPath = parent.realPath || parent.path
|
|
81
|
+
const capResolved = path.resolve(cap)
|
|
82
|
+
|
|
83
|
+
let targetPath
|
|
77
84
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
// Ensure parent has same cap
|
|
83
|
-
Valid.assert(
|
|
84
|
-
parent.cap === cap,
|
|
85
|
-
"Parent must have the same cap as this directory.",
|
|
86
|
-
)
|
|
87
|
-
|
|
88
|
-
// Use real path for filesystem operations
|
|
89
|
-
const parentPath = parent.realPath || parent.path
|
|
90
|
-
|
|
91
|
-
// Validate parent's lineage traces back to the cap
|
|
92
|
-
let found = false
|
|
93
|
-
if(parent.trail) {
|
|
94
|
-
for(const p of parent.walkUp) {
|
|
95
|
-
if(p.path === cap) {
|
|
96
|
-
found = true
|
|
97
|
-
break
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
Valid.assert(
|
|
103
|
-
found,
|
|
104
|
-
`The lineage of this directory must trace back to the cap '${cap}'.`,
|
|
105
|
-
)
|
|
106
|
-
|
|
107
|
-
dirPath = path.join(parentPath, name)
|
|
85
|
+
// If absolute, treat as virtual path relative to cap (strip leading /)
|
|
86
|
+
if(path.isAbsolute(dirPath)) {
|
|
87
|
+
const relative = dirPath.replace(/^[/\\]+/, "")
|
|
88
|
+
targetPath = relative ? path.join(capResolved, relative) : capResolved
|
|
108
89
|
} else {
|
|
109
|
-
//
|
|
110
|
-
|
|
90
|
+
// Relative path - resolve from parent directory
|
|
91
|
+
targetPath = FS.resolvePath(parentPath, dirPath)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Resolve to absolute path (handles .. and .)
|
|
95
|
+
const resolved = path.resolve(targetPath)
|
|
96
|
+
|
|
97
|
+
// Clamp to cap boundary - cannot escape above cap
|
|
98
|
+
if(!resolved.startsWith(capResolved)) {
|
|
99
|
+
// Path tried to escape - clamp to cap root
|
|
100
|
+
resolvedPath = capResolved
|
|
101
|
+
} else {
|
|
102
|
+
resolvedPath = resolved
|
|
111
103
|
}
|
|
112
104
|
}
|
|
113
105
|
|
|
114
106
|
// Call parent constructor with the path
|
|
115
|
-
|
|
116
|
-
super(dirPath, temporary)
|
|
107
|
+
super(resolvedPath, temporary)
|
|
117
108
|
|
|
118
109
|
// Store the cap AFTER calling super()
|
|
119
110
|
this.#cap = cap
|
|
@@ -257,6 +248,40 @@ export default class CappedDirectoryObject extends DirectoryObject {
|
|
|
257
248
|
: new DirectoryObject(parentPath, this.temporary)
|
|
258
249
|
}
|
|
259
250
|
|
|
251
|
+
/**
|
|
252
|
+
* Returns the URL with virtual path (cap-relative).
|
|
253
|
+
*
|
|
254
|
+
* @returns {URL} Virtual URL
|
|
255
|
+
*/
|
|
256
|
+
get url() {
|
|
257
|
+
return new URL(FS.pathToUri(this.path))
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Returns JSON representation with virtual paths and .real escape hatch.
|
|
262
|
+
*
|
|
263
|
+
* @returns {object} JSON representation
|
|
264
|
+
*/
|
|
265
|
+
toJSON() {
|
|
266
|
+
const capResolved = path.resolve(this.#cap)
|
|
267
|
+
const parentPath = this.#realPath === capResolved
|
|
268
|
+
? null
|
|
269
|
+
: "/"
|
|
270
|
+
|
|
271
|
+
return {
|
|
272
|
+
supplied: this.supplied,
|
|
273
|
+
path: this.path,
|
|
274
|
+
url: this.url.toString(),
|
|
275
|
+
name: this.name,
|
|
276
|
+
module: this.module,
|
|
277
|
+
extension: this.extension,
|
|
278
|
+
isFile: this.isFile,
|
|
279
|
+
isDirectory: this.isDirectory,
|
|
280
|
+
parent: parentPath,
|
|
281
|
+
real: this.real.toJSON()
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
260
285
|
/**
|
|
261
286
|
* Generator that walks up the directory tree, stopping at the cap.
|
|
262
287
|
* Yields parent directories from current up to (and including) the cap root.
|
|
@@ -344,20 +369,8 @@ export default class CappedDirectoryObject extends DirectoryObject {
|
|
|
344
369
|
!newPath.includes("..")
|
|
345
370
|
|
|
346
371
|
if(isSimpleName) {
|
|
347
|
-
//
|
|
348
|
-
|
|
349
|
-
// internally call super with the cap parameter
|
|
350
|
-
if(this.constructor === CappedDirectoryObject) {
|
|
351
|
-
return new CappedDirectoryObject(
|
|
352
|
-
newPath,
|
|
353
|
-
this.#cap,
|
|
354
|
-
this,
|
|
355
|
-
this.temporary
|
|
356
|
-
)
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
// For subclasses like TempDirectoryObject
|
|
360
|
-
return new this.constructor(newPath, this)
|
|
372
|
+
// Both CappedDirectoryObject and subclasses use same signature now
|
|
373
|
+
return new this.constructor(newPath, this, this.temporary)
|
|
361
374
|
}
|
|
362
375
|
|
|
363
376
|
// Complex path - handle coercion
|
|
@@ -407,7 +420,7 @@ export default class CappedDirectoryObject extends DirectoryObject {
|
|
|
407
420
|
// Create a base CappedDirectoryObject at the cap path
|
|
408
421
|
// This works for direct usage of CappedDirectoryObject
|
|
409
422
|
// Subclasses may need to override if they have special semantics
|
|
410
|
-
return new CappedDirectoryObject(
|
|
423
|
+
return new CappedDirectoryObject(this.#cap, null, this.temporary)
|
|
411
424
|
}
|
|
412
425
|
|
|
413
426
|
/**
|
|
@@ -426,12 +439,7 @@ export default class CappedDirectoryObject extends DirectoryObject {
|
|
|
426
439
|
// Traverse each segment, creating CappedDirectoryObject instances
|
|
427
440
|
// (not subclass instances, to avoid constructor signature issues)
|
|
428
441
|
for(const segment of segments) {
|
|
429
|
-
current = new CappedDirectoryObject(
|
|
430
|
-
segment,
|
|
431
|
-
this.#cap,
|
|
432
|
-
current,
|
|
433
|
-
this.temporary
|
|
434
|
-
)
|
|
442
|
+
current = new CappedDirectoryObject(segment, current, this.temporary)
|
|
435
443
|
}
|
|
436
444
|
|
|
437
445
|
return current
|
|
@@ -548,7 +556,20 @@ export default class CappedDirectoryObject extends DirectoryObject {
|
|
|
548
556
|
return new this.constructor(name, this)
|
|
549
557
|
})
|
|
550
558
|
|
|
551
|
-
return
|
|
559
|
+
// Recreate FileObjects with capped parent so they return virtual paths
|
|
560
|
+
const cappedFiles = files.map(file => new FileObject(file.name, this))
|
|
561
|
+
|
|
562
|
+
return {files: cappedFiles, directories: cappedDirectories}
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
/**
|
|
566
|
+
* Override hasDirectory to use real filesystem path.
|
|
567
|
+
*
|
|
568
|
+
* @param {string} dirname - Directory name to check
|
|
569
|
+
* @returns {Promise<boolean>} True if directory exists
|
|
570
|
+
*/
|
|
571
|
+
async hasDirectory(dirname) {
|
|
572
|
+
return await this.real.hasDirectory(dirname)
|
|
552
573
|
}
|
|
553
574
|
|
|
554
575
|
/**
|
package/src/lib/FileObject.js
CHANGED
|
@@ -214,11 +214,19 @@ export default class FileObject extends FS {
|
|
|
214
214
|
}
|
|
215
215
|
|
|
216
216
|
/**
|
|
217
|
-
* Returns the URL of the current file.
|
|
217
|
+
* Returns the URL of the current file. If the parent is a capped directory,
|
|
218
|
+
* returns a virtual URL relative to the cap. Otherwise returns the real URL.
|
|
218
219
|
*
|
|
219
|
-
* @returns {URL} The file URL
|
|
220
|
+
* @returns {URL} The file URL (virtual if parent is capped, real otherwise)
|
|
220
221
|
*/
|
|
221
222
|
get url() {
|
|
223
|
+
const parent = this.#meta.parent
|
|
224
|
+
|
|
225
|
+
// If parent is capped, return virtual URL
|
|
226
|
+
if(parent?.capped) {
|
|
227
|
+
return new URL(FS.pathToUri(this.path))
|
|
228
|
+
}
|
|
229
|
+
|
|
222
230
|
return this.#meta.url
|
|
223
231
|
}
|
|
224
232
|
|
|
@@ -408,7 +416,7 @@ export default class FileObject extends FS {
|
|
|
408
416
|
* @returns {Promise<string>} The file contents
|
|
409
417
|
*/
|
|
410
418
|
async read(encoding="utf8") {
|
|
411
|
-
const url = this.url
|
|
419
|
+
const url = this.#meta.url
|
|
412
420
|
|
|
413
421
|
if(!url)
|
|
414
422
|
throw Sass.new("No URL in file map")
|
|
@@ -432,7 +440,7 @@ export default class FileObject extends FS {
|
|
|
432
440
|
* // Use the buffer (e.g., send in HTTP response, process image, etc.)
|
|
433
441
|
*/
|
|
434
442
|
async readBinary() {
|
|
435
|
-
const url = this.url
|
|
443
|
+
const url = this.#meta.url
|
|
436
444
|
|
|
437
445
|
if(!url)
|
|
438
446
|
throw Sass.new("No URL in file map")
|
|
@@ -456,11 +464,11 @@ export default class FileObject extends FS {
|
|
|
456
464
|
* await file.write(JSON.stringify({key: 'value'}))
|
|
457
465
|
*/
|
|
458
466
|
async write(content, encoding="utf8") {
|
|
459
|
-
if(!this.url)
|
|
467
|
+
if(!this.#meta.url)
|
|
460
468
|
throw Sass.new("No URL in file")
|
|
461
469
|
|
|
462
470
|
if(await this.parent.exists)
|
|
463
|
-
await fs.writeFile(this.url, content, encoding)
|
|
471
|
+
await fs.writeFile(this.#meta.url, content, encoding)
|
|
464
472
|
|
|
465
473
|
else
|
|
466
474
|
throw Sass.new(`Invalid directory, ${this.parent.url.href}`)
|
|
@@ -483,7 +491,7 @@ export default class FileObject extends FS {
|
|
|
483
491
|
* await file.writeBinary(buffer)
|
|
484
492
|
*/
|
|
485
493
|
async writeBinary(data) {
|
|
486
|
-
if(!this.url)
|
|
494
|
+
if(!this.#meta.url)
|
|
487
495
|
throw Sass.new("No URL in file")
|
|
488
496
|
|
|
489
497
|
const exists = await this.parent.exists
|
|
@@ -496,7 +504,7 @@ export default class FileObject extends FS {
|
|
|
496
504
|
|
|
497
505
|
// According to the internet, if it's already binary, I don't need
|
|
498
506
|
// an encoding. 🤷
|
|
499
|
-
return await fs.writeFile(this.url, bufferData)
|
|
507
|
+
return await fs.writeFile(this.#meta.url, bufferData)
|
|
500
508
|
}
|
|
501
509
|
|
|
502
510
|
/**
|
|
@@ -547,7 +555,7 @@ export default class FileObject extends FS {
|
|
|
547
555
|
* @returns {Promise<object>} The file contents as a module.
|
|
548
556
|
*/
|
|
549
557
|
async import() {
|
|
550
|
-
const url = this.url
|
|
558
|
+
const url = this.#meta.url
|
|
551
559
|
|
|
552
560
|
if(!url)
|
|
553
561
|
throw Sass.new("No URL in file map")
|
|
@@ -569,7 +577,7 @@ export default class FileObject extends FS {
|
|
|
569
577
|
* await file.delete()
|
|
570
578
|
*/
|
|
571
579
|
async delete() {
|
|
572
|
-
const url = this.url
|
|
580
|
+
const url = this.#meta.url
|
|
573
581
|
|
|
574
582
|
if(!url)
|
|
575
583
|
throw Sass.new("This object does not represent a valid resource.")
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
import fs from "node:fs"
|
|
8
8
|
import os from "node:os"
|
|
9
|
+
import path from "node:path"
|
|
9
10
|
|
|
10
11
|
import CappedDirectoryObject from "./CappedDirectoryObject.js"
|
|
11
12
|
import Sass from "./Sass.js"
|
|
@@ -57,22 +58,63 @@ export default class TempDirectoryObject extends CappedDirectoryObject {
|
|
|
57
58
|
* await parent.remove() // Removes both parent and child
|
|
58
59
|
*/
|
|
59
60
|
constructor(name, parent=null) {
|
|
60
|
-
let
|
|
61
|
+
let dirPath
|
|
62
|
+
let cappedParent = parent
|
|
61
63
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
64
|
+
if(!parent) {
|
|
65
|
+
// No parent: need to create a capped parent at tmpdir first
|
|
66
|
+
cappedParent = new CappedDirectoryObject(os.tmpdir(), null, true)
|
|
67
|
+
|
|
68
|
+
if(name) {
|
|
69
|
+
// Check if name is a simple name (no separators, not absolute)
|
|
70
|
+
const isSimpleName = !path.isAbsolute(name) &&
|
|
71
|
+
!name.includes("/") &&
|
|
72
|
+
!name.includes("\\") &&
|
|
73
|
+
!name.includes(path.sep)
|
|
74
|
+
|
|
75
|
+
if(isSimpleName) {
|
|
76
|
+
// Simple name: add unique suffix
|
|
77
|
+
const prefix = name.endsWith("-") ? name : `${name}-`
|
|
78
|
+
const uniqueSuffix =
|
|
79
|
+
Math.random()
|
|
80
|
+
.toString(36)
|
|
81
|
+
.substring(2, 8)
|
|
82
|
+
.toUpperCase()
|
|
83
|
+
dirPath = `${prefix}${uniqueSuffix}`
|
|
84
|
+
} else {
|
|
85
|
+
// Complex path: use as-is, let CappedDirectoryObject handle coercion
|
|
86
|
+
dirPath = name
|
|
87
|
+
}
|
|
88
|
+
} else {
|
|
89
|
+
// No name: use tmpdir itself (no parent)
|
|
90
|
+
dirPath = os.tmpdir()
|
|
91
|
+
cappedParent = null
|
|
92
|
+
}
|
|
93
|
+
} else {
|
|
94
|
+
// With parent: validate it's a proper temp directory parent
|
|
95
|
+
if(!(parent instanceof CappedDirectoryObject)) {
|
|
96
|
+
throw Sass.new(
|
|
97
|
+
"Parent must be a CappedDirectoryObject or TempDirectoryObject."
|
|
98
|
+
)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// SECURITY: Ensure parent's cap is tmpdir (prevent escape to other caps)
|
|
102
|
+
const tmpdir = os.tmpdir()
|
|
103
|
+
if(parent.cap !== tmpdir) {
|
|
104
|
+
throw Sass.new(
|
|
105
|
+
`Parent must be capped to OS temp directory (${tmpdir}), ` +
|
|
106
|
+
`got cap: ${parent.cap}`
|
|
107
|
+
)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
dirPath = name || ""
|
|
111
|
+
if(!dirPath) {
|
|
112
|
+
throw Sass.new("Name must not be empty when parent is provided.")
|
|
113
|
+
}
|
|
71
114
|
}
|
|
72
115
|
|
|
73
|
-
// Call parent constructor with
|
|
74
|
-
|
|
75
|
-
super(finalName, os.tmpdir(), parent, true)
|
|
116
|
+
// Call parent constructor with new signature
|
|
117
|
+
super(dirPath, cappedParent, true)
|
|
76
118
|
|
|
77
119
|
// Temp-specific behavior: create directory immediately
|
|
78
120
|
this.#createDirectory()
|
|
@@ -86,7 +128,8 @@ export default class TempDirectoryObject extends CappedDirectoryObject {
|
|
|
86
128
|
*/
|
|
87
129
|
#createDirectory() {
|
|
88
130
|
try {
|
|
89
|
-
|
|
131
|
+
// Use recursive: true to create parent directories as needed
|
|
132
|
+
fs.mkdirSync(this.realPath, {recursive: true})
|
|
90
133
|
} catch(e) {
|
|
91
134
|
// EEXIST is fine - directory already exists
|
|
92
135
|
if(e.code !== "EEXIST") {
|
|
@@ -11,21 +11,32 @@ export default class CappedDirectoryObject extends DirectoryObject {
|
|
|
11
11
|
/**
|
|
12
12
|
* Constructs a CappedDirectoryObject instance.
|
|
13
13
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
14
|
+
* Without a parent, the path becomes both the directory location and the cap
|
|
15
|
+
* (virtual root). With a parent, the path is resolved relative to the parent's
|
|
16
|
+
* cap using virtual path semantics (absolute paths treated as cap-relative).
|
|
16
17
|
*
|
|
17
|
-
* @param {string
|
|
18
|
-
* @param {string} cap - The root path that constrains this directory tree
|
|
18
|
+
* @param {string} dirPath - Directory path (becomes cap if no parent, else relative to parent's cap)
|
|
19
19
|
* @param {CappedDirectoryObject?} [parent] - Optional parent capped directory
|
|
20
20
|
* @param {boolean} [temporary=false] - Whether this is a temporary directory
|
|
21
|
-
* @throws {Sass} If
|
|
22
|
-
* @throws {Sass} If
|
|
23
|
-
* @throws {Sass} If name contains path separators
|
|
24
|
-
* @throws {Sass} If parent is not a capped directory
|
|
25
|
-
* @throws {Sass} If parent's lineage does not trace back to the cap
|
|
21
|
+
* @throws {Sass} If path is empty
|
|
22
|
+
* @throws {Sass} If parent is provided but not a CappedDirectoryObject
|
|
26
23
|
* @throws {Sass} If the resulting path would escape the cap
|
|
24
|
+
* @example
|
|
25
|
+
* // Create new capped directory
|
|
26
|
+
* const cache = new CappedDirectoryObject("/home/user/.cache")
|
|
27
|
+
* // path: /home/user/.cache, cap: /home/user/.cache
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* // Create subdirectory with parent
|
|
31
|
+
* const data = new CappedDirectoryObject("data", cache)
|
|
32
|
+
* // path: /home/user/.cache/data, cap: /home/user/.cache
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* // Virtual absolute path with parent
|
|
36
|
+
* const config = new CappedDirectoryObject("/etc/config", cache)
|
|
37
|
+
* // path: /home/user/.cache/etc/config, cap: /home/user/.cache
|
|
27
38
|
*/
|
|
28
|
-
constructor(
|
|
39
|
+
constructor(dirPath: string, parent?: CappedDirectoryObject | null, temporary?: boolean);
|
|
29
40
|
/**
|
|
30
41
|
* Returns the cap path for this directory.
|
|
31
42
|
*
|
|
@@ -64,6 +75,12 @@ export default class CappedDirectoryObject extends DirectoryObject {
|
|
|
64
75
|
* subdir.real.parent // Can traverse outside the cap
|
|
65
76
|
*/
|
|
66
77
|
get real(): DirectoryObject;
|
|
78
|
+
/**
|
|
79
|
+
* Returns the URL with virtual path (cap-relative).
|
|
80
|
+
*
|
|
81
|
+
* @returns {URL} Virtual URL
|
|
82
|
+
*/
|
|
83
|
+
get url(): URL;
|
|
67
84
|
/**
|
|
68
85
|
* Returns a generator that walks up to the cap.
|
|
69
86
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CappedDirectoryObject.d.ts","sourceRoot":"","sources":["../../lib/CappedDirectoryObject.js"],"names":[],"mappings":"AAkBA;;;;;;;;GAQG;AACH;IAGE
|
|
1
|
+
{"version":3,"file":"CappedDirectoryObject.d.ts","sourceRoot":"","sources":["../../lib/CappedDirectoryObject.js"],"names":[],"mappings":"AAkBA;;;;;;;;GAQG;AACH;IAGE;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACH,qBArBW,MAAM,WACN,qBAAqB,OAAC,cACtB,OAAO,EA0EjB;IAqBD;;;;OAIG;IACH,WAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,cAFa,OAAO,CAInB;IAED;;;;;OAKG;IACH,0BAFa,MAAM,CAIlB;IAqCD;;;;;;;;;;;;;;;;;OAiBG;IACH,YAba,eAAe,CAe3B;IAiCD;;;;OAIG;IACH,WAFa,GAAG,CAIf;IAqED;;;;OAIG;IACH,cAFa,SAAS,CAAC,eAAe,CAAC,CAItC;IAED;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,sBAjBW,MAAM,GACJ,qBAAqB,CAiEjC;IAqID;;;;;OAKG;IACH,WAHW,MAAM,GACJ,OAAO,CAAC;QAAC,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;QAAC,WAAW,QAAO;KAAC,CAAC,CAgBnE;;CA8DF;4BAnmB2B,sBAAsB;uBAC3B,iBAAiB"}
|
|
@@ -58,9 +58,10 @@ export default class FileObject extends FS {
|
|
|
58
58
|
*/
|
|
59
59
|
get path(): string;
|
|
60
60
|
/**
|
|
61
|
-
* Returns the URL of the current file.
|
|
61
|
+
* Returns the URL of the current file. If the parent is a capped directory,
|
|
62
|
+
* returns a virtual URL relative to the cap. Otherwise returns the real URL.
|
|
62
63
|
*
|
|
63
|
-
* @returns {URL} The file URL
|
|
64
|
+
* @returns {URL} The file URL (virtual if parent is capped, real otherwise)
|
|
64
65
|
*/
|
|
65
66
|
get url(): URL;
|
|
66
67
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileObject.d.ts","sourceRoot":"","sources":["../../lib/FileObject.js"],"names":[],"mappings":"AAmBA;;;;;;;;;;;;;;GAcG;AAEH;uBAmIe,MAAM;IAlInB;;;;;OAKG;IACH,yBAFU;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAAC,OAAO,KAAK,GAAG,OAAO,IAAI,CAAC,CAAA;KAAC,CAO1D;IA2BF;;;;;OAKG;IACH,sBAHW,MAAM,GAAG,UAAU,WACnB,eAAe,GAAC,MAAM,GAAC,IAAI,EAuDrC;IAWD;;;;OAIG;IACH,UAFa,MAAM,CAclB;IAWD;;;;OAIG;IACH,cAFa,OAAO,CAAC,OAAO,CAAC,CAI5B;IAED;;;;OAIG;IACH,gBAFa,MAAM,CAIlB;IAED;;;;;;OAMG;IACH,YAFa,MAAM,CAkBlB;IAED
|
|
1
|
+
{"version":3,"file":"FileObject.d.ts","sourceRoot":"","sources":["../../lib/FileObject.js"],"names":[],"mappings":"AAmBA;;;;;;;;;;;;;;GAcG;AAEH;uBAmIe,MAAM;IAlInB;;;;;OAKG;IACH,yBAFU;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAAC,OAAO,KAAK,GAAG,OAAO,IAAI,CAAC,CAAA;KAAC,CAO1D;IA2BF;;;;;OAKG;IACH,sBAHW,MAAM,GAAG,UAAU,WACnB,eAAe,GAAC,MAAM,GAAC,IAAI,EAuDrC;IAWD;;;;OAIG;IACH,UAFa,MAAM,CAclB;IAWD;;;;OAIG;IACH,cAFa,OAAO,CAAC,OAAO,CAAC,CAI5B;IAED;;;;OAIG;IACH,gBAFa,MAAM,CAIlB;IAED;;;;;;OAMG;IACH,YAFa,MAAM,CAkBlB;IAED;;;;;OAKG;IACH,WAFa,GAAG,CAWf;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;;;;OAIG;IACH,mBAFa,OAAO,CAInB;IAED;;;;;;;;;;;;;;OAcG;IACH,cAFa,eAAe,CAI3B;IAED;;;;;;;;;;;;;;;OAeG;IACH,YAXa,UAAU,CAatB;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;IAsBD;;;;;OAKG;IACH,gBAHW,MAAM,GACJ,OAAO,CAAC,MAAM,CAAC,CAY3B;IAED;;;;;;;;;;;OAWG;IACH,cARa,OAAO,CAAC,MAAM,CAAC,CAkB3B;IAED;;;;;;;;;;;OAWG;IACH,eARW,MAAM,aACN,MAAM,GACJ,OAAO,CAAC,IAAI,CAAC,CAezB;IAED;;;;;;;;;;;;;;;OAeG;IACH,kBAXW,WAAW,GAAC,IAAI,GAAC,MAAM,GACrB,OAAO,CAAC,IAAI,CAAC,CAyBzB;IAED;;;;;;;;;;;;;;OAcG;IACH,gBAXW,MAAM,aACN,MAAM,GACJ,OAAO,CAAC,OAAO,CAAC,CAkC5B;IAED;;;;OAIG;IACH,UAFa,OAAO,CAAC,MAAM,CAAC,CAY3B;IAED;;;;;;;;;OASG;IACH,UAPa,OAAO,CAAC,IAAI,CAAC,CAiBzB;;CACF;eA9jBc,SAAS;4BADI,sBAAsB;kBARhC,OAAO;iBAIR,MAAM"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TempDirectoryObject.d.ts","sourceRoot":"","sources":["../../lib/TempDirectoryObject.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TempDirectoryObject.d.ts","sourceRoot":"","sources":["../../lib/TempDirectoryObject.js"],"names":[],"mappings":"AAaA;;;;;;;;;GASG;AACH;IAEE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAiCG;IACH,mBAxBW,MAAM,OAAC,WACP,mBAAmB,OAAC,EAoF9B;IAsBD;;;;;;;;;;;;;;OAcG;IACH,sBAVW,MAAM,GACJ,mBAAmB,CAY/B;IAED;;;;;;;;;;;;;;OAcG;IACH,kBAVW,MAAM,GACJ,UAAU,CAYtB;;CAUF;kCApLiC,4BAA4B"}
|