@gesslar/toolkit 3.22.2 → 3.24.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 +2 -5
- package/package.json +10 -4
- package/src/browser/lib/Data.js +16 -2
- package/src/browser/lib/OObject.js +196 -0
- package/src/browser/lib/Promised.js +4 -2
- package/src/browser/lib/Time.js +4 -2
- package/src/browser/lib/TypeSpec.js +24 -5
- package/src/node/index.js +0 -3
- package/src/node/lib/DirectoryObject.js +100 -212
- package/src/node/lib/FileObject.js +71 -44
- package/src/node/lib/FileSystem.js +11 -48
- package/src/node/lib/Glog.js +2 -12
- package/src/node/lib/Valid.js +8 -1
- package/types/browser/lib/Data.d.ts +26 -4
- package/types/browser/lib/Data.d.ts.map +1 -1
- package/types/browser/lib/OObject.d.ts +127 -0
- package/types/browser/lib/OObject.d.ts.map +1 -0
- package/types/browser/lib/Promised.d.ts.map +1 -1
- package/types/browser/lib/Time.d.ts.map +1 -1
- package/types/browser/lib/TypeSpec.d.ts +42 -6
- package/types/browser/lib/TypeSpec.d.ts.map +1 -1
- package/types/node/index.d.ts +0 -3
- package/types/node/lib/DirectoryObject.d.ts +93 -51
- package/types/node/lib/DirectoryObject.d.ts.map +1 -1
- package/types/node/lib/FileObject.d.ts +12 -7
- package/types/node/lib/FileObject.d.ts.map +1 -1
- package/types/node/lib/FileSystem.d.ts +16 -23
- package/types/node/lib/FileSystem.d.ts.map +1 -1
- package/types/node/lib/Glog.d.ts +0 -7
- package/types/node/lib/Glog.d.ts.map +1 -1
- package/types/node/lib/Valid.d.ts +17 -2
- package/types/node/lib/Valid.d.ts.map +1 -1
- package/src/node/lib/TempDirectoryObject.js +0 -165
- package/src/node/lib/VDirectoryObject.js +0 -198
- package/src/node/lib/VFileObject.js +0 -110
- package/types/node/lib/TempDirectoryObject.d.ts +0 -42
- package/types/node/lib/TempDirectoryObject.d.ts.map +0 -1
- package/types/node/lib/VDirectoryObject.d.ts +0 -132
- package/types/node/lib/VDirectoryObject.d.ts.map +0 -1
- package/types/node/lib/VFileObject.d.ts +0 -33
- package/types/node/lib/VFileObject.d.ts.map +0 -1
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
|
|
7
7
|
import JSON5 from "json5"
|
|
8
8
|
import fs from "node:fs/promises"
|
|
9
|
-
import path from "node:path"
|
|
10
9
|
import YAML from "yaml"
|
|
11
10
|
import {URL} from "node:url"
|
|
11
|
+
import {Buffer} from "node:buffer"
|
|
12
12
|
|
|
13
13
|
import Data from "../../browser/lib/Data.js"
|
|
14
14
|
import DirectoryObject from "./DirectoryObject.js"
|
|
@@ -47,7 +47,6 @@ export default class FileObject extends FS {
|
|
|
47
47
|
|
|
48
48
|
/**
|
|
49
49
|
* @type {object}
|
|
50
|
-
* @private
|
|
51
50
|
* @property {string|null} supplied - User-supplied path
|
|
52
51
|
* @property {string|null} path - The absolute file path
|
|
53
52
|
* @property {URL|null} url - The file URL
|
|
@@ -67,26 +66,9 @@ export default class FileObject extends FS {
|
|
|
67
66
|
isFile: true,
|
|
68
67
|
parent: null,
|
|
69
68
|
parentPath: null,
|
|
69
|
+
real: 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
|
-
|
|
90
72
|
/**
|
|
91
73
|
* Constructs a FileObject instance.
|
|
92
74
|
*
|
|
@@ -100,14 +82,15 @@ export default class FileObject extends FS {
|
|
|
100
82
|
Valid.type(parent, "Null|String|DirectoryObject", {allowEmpty: false})
|
|
101
83
|
|
|
102
84
|
const normalizedFile = FS.fixSlashes(submitted)
|
|
103
|
-
const absOrRelPath =
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
const
|
|
85
|
+
const absOrRelPath = normalizedFile
|
|
86
|
+
const pathParts = FS.pathParts(absOrRelPath)
|
|
87
|
+
const {dir, base, ext} = pathParts
|
|
88
|
+
const name = base.slice(0, base.length - ext.length)
|
|
107
89
|
|
|
108
90
|
const [parentObject, fullPath] = (() => {
|
|
109
91
|
if(Data.isType(parent, "String")) {
|
|
110
|
-
const
|
|
92
|
+
const parentPath = /** @type {string} */ (parent)
|
|
93
|
+
const resolved = FS.resolvePath(parentPath, absOrRelPath)
|
|
111
94
|
const {dir} = FS.pathParts(resolved)
|
|
112
95
|
|
|
113
96
|
return [
|
|
@@ -116,15 +99,16 @@ export default class FileObject extends FS {
|
|
|
116
99
|
]
|
|
117
100
|
}
|
|
118
101
|
|
|
119
|
-
if(Data.isType(parent, "DirectoryObject")) {
|
|
120
|
-
const
|
|
102
|
+
if(Data.isType(parent, "DirectoryObject") && parent !== null) {
|
|
103
|
+
const parentDir = /** @type {DirectoryObject} */ (parent)
|
|
104
|
+
const parentPath = parentDir.path
|
|
121
105
|
const resolved = FS.resolvePath(parentPath, absOrRelPath)
|
|
122
106
|
const parts = FS.pathParts(resolved)
|
|
123
107
|
|
|
124
108
|
return [
|
|
125
|
-
|
|
126
|
-
?
|
|
127
|
-
: new
|
|
109
|
+
parentDir.path === parts.dir
|
|
110
|
+
? parentDir
|
|
111
|
+
: new DirectoryObject(parts.dir),
|
|
128
112
|
resolved,
|
|
129
113
|
]
|
|
130
114
|
}
|
|
@@ -160,9 +144,7 @@ export default class FileObject extends FS {
|
|
|
160
144
|
* @returns {string} String representation of the FileObject
|
|
161
145
|
*/
|
|
162
146
|
toString() {
|
|
163
|
-
return this.
|
|
164
|
-
?`[${this.constructor.name}: ${this.path} → ${this.real.path}]`
|
|
165
|
-
:`[${this.constructor.name}: ${this.path}]`
|
|
147
|
+
return `[${this.constructor.name}: ${this.path}]`
|
|
166
148
|
}
|
|
167
149
|
|
|
168
150
|
/**
|
|
@@ -271,7 +253,7 @@ export default class FileObject extends FS {
|
|
|
271
253
|
*/
|
|
272
254
|
async canRead() {
|
|
273
255
|
try {
|
|
274
|
-
await fs.access(this.
|
|
256
|
+
await fs.access(this.path, fs.constants.R_OK)
|
|
275
257
|
|
|
276
258
|
return true
|
|
277
259
|
} catch {
|
|
@@ -286,7 +268,7 @@ export default class FileObject extends FS {
|
|
|
286
268
|
*/
|
|
287
269
|
async canWrite() {
|
|
288
270
|
try {
|
|
289
|
-
await fs.access(this.
|
|
271
|
+
await fs.access(this.path, fs.constants.W_OK)
|
|
290
272
|
|
|
291
273
|
return true
|
|
292
274
|
} catch {
|
|
@@ -301,7 +283,7 @@ export default class FileObject extends FS {
|
|
|
301
283
|
*/
|
|
302
284
|
async #fileExists() {
|
|
303
285
|
try {
|
|
304
|
-
await fs.access(this.
|
|
286
|
+
await fs.access(this.path, fs.constants.F_OK)
|
|
305
287
|
|
|
306
288
|
return true
|
|
307
289
|
} catch {
|
|
@@ -316,7 +298,7 @@ export default class FileObject extends FS {
|
|
|
316
298
|
*/
|
|
317
299
|
async size() {
|
|
318
300
|
try {
|
|
319
|
-
const stat = await fs.stat(this.
|
|
301
|
+
const stat = await fs.stat(this.path)
|
|
320
302
|
|
|
321
303
|
return stat.size
|
|
322
304
|
} catch {
|
|
@@ -332,7 +314,7 @@ export default class FileObject extends FS {
|
|
|
332
314
|
*/
|
|
333
315
|
async modified() {
|
|
334
316
|
try {
|
|
335
|
-
const stat = await fs.stat(this.
|
|
317
|
+
const stat = await fs.stat(this.path)
|
|
336
318
|
|
|
337
319
|
return stat.mtime
|
|
338
320
|
} catch {
|
|
@@ -347,7 +329,7 @@ export default class FileObject extends FS {
|
|
|
347
329
|
* @returns {Promise<string>} The file contents
|
|
348
330
|
*/
|
|
349
331
|
async read(encoding="utf8") {
|
|
350
|
-
const filePath = this.
|
|
332
|
+
const filePath = this.path
|
|
351
333
|
|
|
352
334
|
if(!(await this.exists))
|
|
353
335
|
throw Sass.new(`No such file '${filePath}'`)
|
|
@@ -368,7 +350,7 @@ export default class FileObject extends FS {
|
|
|
368
350
|
* // Use the buffer (e.g., send in HTTP response, process image, etc.)
|
|
369
351
|
*/
|
|
370
352
|
async readBinary() {
|
|
371
|
-
const filePath = this.
|
|
353
|
+
const filePath = this.path
|
|
372
354
|
|
|
373
355
|
if(!(await this.exists))
|
|
374
356
|
throw Sass.new(`No such file '${filePath}'`)
|
|
@@ -389,7 +371,7 @@ export default class FileObject extends FS {
|
|
|
389
371
|
* await file.write(JSON.stringify({key: 'value'}))
|
|
390
372
|
*/
|
|
391
373
|
async write(content, encoding="utf8") {
|
|
392
|
-
const filePath = this.
|
|
374
|
+
const filePath = this.path
|
|
393
375
|
|
|
394
376
|
if(!filePath)
|
|
395
377
|
throw Sass.new("No actual disk location detected.")
|
|
@@ -418,7 +400,7 @@ export default class FileObject extends FS {
|
|
|
418
400
|
* await file.writeBinary(buffer)
|
|
419
401
|
*/
|
|
420
402
|
async writeBinary(data) {
|
|
421
|
-
const filePath = this.
|
|
403
|
+
const filePath = this.path
|
|
422
404
|
|
|
423
405
|
const exists = await this.parent.exists
|
|
424
406
|
Valid.assert(exists, `Invalid directory writing ${filePath}`)
|
|
@@ -480,7 +462,7 @@ export default class FileObject extends FS {
|
|
|
480
462
|
* @returns {Promise<object>} The file contents as a module.
|
|
481
463
|
*/
|
|
482
464
|
async import() {
|
|
483
|
-
const filePath = this.
|
|
465
|
+
const filePath = this.path
|
|
484
466
|
|
|
485
467
|
if(!(await this.exists))
|
|
486
468
|
throw Sass.new(`No such file '${filePath}'`)
|
|
@@ -499,11 +481,56 @@ export default class FileObject extends FS {
|
|
|
499
481
|
* await file.delete()
|
|
500
482
|
*/
|
|
501
483
|
async delete() {
|
|
502
|
-
const filePath = this.
|
|
484
|
+
const filePath = this.path
|
|
503
485
|
|
|
504
486
|
if(!(await this.exists))
|
|
505
487
|
throw Sass.new(`No such resource '${filePath}'`)
|
|
506
488
|
|
|
507
489
|
return await fs.unlink(filePath)
|
|
508
490
|
}
|
|
491
|
+
|
|
492
|
+
/**
|
|
493
|
+
* Creates a FileObject representing the current working file (the file
|
|
494
|
+
* that called this method). Parses the stack trace to determine the
|
|
495
|
+
* caller's file path.
|
|
496
|
+
*
|
|
497
|
+
* @returns {FileObject} A new FileObject instance for the calling file
|
|
498
|
+
* @throws {Sass} If unable to determine caller file from stack trace
|
|
499
|
+
* @example
|
|
500
|
+
* // In /home/user/project/src/app.js:
|
|
501
|
+
* const thisFile = FileObject.fromCwf()
|
|
502
|
+
* console.log(thisFile.path) // /home/user/project/src/app.js
|
|
503
|
+
*/
|
|
504
|
+
static fromCwf() {
|
|
505
|
+
const originalPrepare = Error.prepareStackTrace
|
|
506
|
+
Error.prepareStackTrace = (_, stack) => stack
|
|
507
|
+
/** @type {Array<{getFileName: () => string|null}>} */
|
|
508
|
+
const stack = (new Error().stack)
|
|
509
|
+
Error.prepareStackTrace = originalPrepare
|
|
510
|
+
|
|
511
|
+
// Find the first call site that isn't this file
|
|
512
|
+
// Stack filenames may be file:// URLs, so compare both forms
|
|
513
|
+
const thisFileUrl = import.meta.url
|
|
514
|
+
const thisFilePath = FS.urlToPath(thisFileUrl)
|
|
515
|
+
const callerSite = stack.find(site => {
|
|
516
|
+
const fileName = site.getFileName()
|
|
517
|
+
|
|
518
|
+
if(!fileName)
|
|
519
|
+
return false
|
|
520
|
+
|
|
521
|
+
return fileName !== thisFileUrl && fileName !== thisFilePath
|
|
522
|
+
})
|
|
523
|
+
|
|
524
|
+
const callerFile = callerSite?.getFileName()
|
|
525
|
+
|
|
526
|
+
if(!callerFile)
|
|
527
|
+
throw Sass.new("Unable to determine caller file from stack trace")
|
|
528
|
+
|
|
529
|
+
// Handle file:// URLs
|
|
530
|
+
const filePath = callerFile.startsWith("file://")
|
|
531
|
+
? FS.urlToPath(callerFile)
|
|
532
|
+
: callerFile
|
|
533
|
+
|
|
534
|
+
return new this(filePath)
|
|
535
|
+
}
|
|
509
536
|
}
|
|
@@ -14,6 +14,7 @@ import url from "node:url"
|
|
|
14
14
|
import Collection from "../../browser/lib/Collection.js"
|
|
15
15
|
import Data from "../../browser/lib/Data.js"
|
|
16
16
|
import Valid from "./Valid.js"
|
|
17
|
+
import Sass from "./Sass.js"
|
|
17
18
|
|
|
18
19
|
/** @typedef {import("./FileObject.js").default} FileObject */
|
|
19
20
|
/** @typedef {import("./DirectoryObject.js").default} DirectoryObject */
|
|
@@ -79,17 +80,19 @@ export default class FileSystem {
|
|
|
79
80
|
}
|
|
80
81
|
|
|
81
82
|
/**
|
|
82
|
-
* Convert a
|
|
83
|
+
* Convert a file URL to a path.
|
|
83
84
|
*
|
|
84
85
|
* @static
|
|
85
|
-
* @param {string}
|
|
86
|
-
* @returns {string} The path
|
|
86
|
+
* @param {string} fileUrl - The file URL to convert (e.g., import.meta.url)
|
|
87
|
+
* @returns {string} The file path
|
|
88
|
+
* @example
|
|
89
|
+
* const currentFile = FileSystem.urlToPath(import.meta.url)
|
|
87
90
|
*/
|
|
88
|
-
static urlToPath(
|
|
91
|
+
static urlToPath(fileUrl) {
|
|
89
92
|
try {
|
|
90
|
-
return url.fileURLToPath(
|
|
93
|
+
return url.fileURLToPath(fileUrl)
|
|
91
94
|
} catch {
|
|
92
|
-
return
|
|
95
|
+
return fileUrl
|
|
93
96
|
}
|
|
94
97
|
}
|
|
95
98
|
|
|
@@ -318,6 +321,8 @@ export default class FileSystem {
|
|
|
318
321
|
* @property {string} base - The file name with extension
|
|
319
322
|
* @property {string} dir - The directory path
|
|
320
323
|
* @property {string} ext - The file extension (including dot)
|
|
324
|
+
* @property {string} root - The root of the path
|
|
325
|
+
* @property {string} name - The file name without extension
|
|
321
326
|
*/
|
|
322
327
|
|
|
323
328
|
/**
|
|
@@ -334,48 +339,6 @@ export default class FileSystem {
|
|
|
334
339
|
return path.parse(pathName)
|
|
335
340
|
}
|
|
336
341
|
|
|
337
|
-
/**
|
|
338
|
-
* Convert a virtual capped path to its real filesystem path.
|
|
339
|
-
* For capped objects, resolves the virtual path relative to the cap's real path.
|
|
340
|
-
* For uncapped objects, returns the path unchanged.
|
|
341
|
-
*
|
|
342
|
-
* @static
|
|
343
|
-
* @param {FileObject|DirectoryObject} fileOrDirectoryObject - The file or directory object to convert
|
|
344
|
-
* @returns {string} The real filesystem path
|
|
345
|
-
* @throws {Sass} If parameter is not a FileObject or DirectoryObject
|
|
346
|
-
* @example
|
|
347
|
-
* const temp = new TempDirectoryObject("myapp")
|
|
348
|
-
* const file = temp.getFile("/config.json")
|
|
349
|
-
* FS.virtualToRealPath(file) // "/tmp/myapp-ABC123/config.json"
|
|
350
|
-
*
|
|
351
|
-
* @example
|
|
352
|
-
* const regular = new FileObject("/home/user/file.txt")
|
|
353
|
-
* FS.virtualToRealPath(regular) // "/home/user/file.txt"
|
|
354
|
-
*/
|
|
355
|
-
static virtualToRealPath(fileOrDirectoryObject) {
|
|
356
|
-
Valid.type(fileOrDirectoryObject, "FileObject|DirectoryObject")
|
|
357
|
-
|
|
358
|
-
let target, cap
|
|
359
|
-
|
|
360
|
-
if(fileOrDirectoryObject.isFile) {
|
|
361
|
-
if(!fileOrDirectoryObject.parent.isVirtual) {
|
|
362
|
-
return fileOrDirectoryObject.path
|
|
363
|
-
} else {
|
|
364
|
-
target = fileOrDirectoryObject.path
|
|
365
|
-
cap = fileOrDirectoryObject.parent.cap.real.path
|
|
366
|
-
}
|
|
367
|
-
} else {
|
|
368
|
-
if(!fileOrDirectoryObject.isVirtual) {
|
|
369
|
-
return fileOrDirectoryObject.path
|
|
370
|
-
} else {
|
|
371
|
-
target = fileOrDirectoryObject.path
|
|
372
|
-
cap = fileOrDirectoryObject.cap.real.path
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
return this.resolvePath(cap, target)
|
|
377
|
-
}
|
|
378
|
-
|
|
379
342
|
/**
|
|
380
343
|
* Returns the current working directory as a string.
|
|
381
344
|
*
|
package/src/node/lib/Glog.js
CHANGED
|
@@ -542,17 +542,6 @@ class Glog {
|
|
|
542
542
|
: c`${namePrefix}${colours[level]}${tag}{/} ${message}`
|
|
543
543
|
}
|
|
544
544
|
|
|
545
|
-
/**
|
|
546
|
-
* Extract file and function information from stack trace
|
|
547
|
-
*
|
|
548
|
-
* @private
|
|
549
|
-
* @returns {string} Caller tag
|
|
550
|
-
*/
|
|
551
|
-
extractFileFunction() {
|
|
552
|
-
// Simple fallback - just return a basic tag
|
|
553
|
-
return "caller"
|
|
554
|
-
}
|
|
555
|
-
|
|
556
545
|
/**
|
|
557
546
|
* Create a new debug function with a specific tag
|
|
558
547
|
*
|
|
@@ -562,7 +551,8 @@ class Glog {
|
|
|
562
551
|
newDebug(tag) {
|
|
563
552
|
return function(message, level, ...arg) {
|
|
564
553
|
if(this.#stackTrace || Glog.stackTrace) {
|
|
565
|
-
tag
|
|
554
|
+
// extractFileFunction was removed - use original tag as fallback
|
|
555
|
+
// Stack trace extraction is not available in Glog (use Logger for full stack trace support)
|
|
566
556
|
}
|
|
567
557
|
|
|
568
558
|
this.debug(`[${tag}] ${message}`, level, ...arg)
|
package/src/node/lib/Valid.js
CHANGED
|
@@ -9,6 +9,13 @@ import Sass from "./Sass.js"
|
|
|
9
9
|
import Data from "../../browser/lib/Data.js"
|
|
10
10
|
import Collection from "../../browser/lib/Collection.js"
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* Options for type validation methods.
|
|
14
|
+
*
|
|
15
|
+
* @typedef {object} TypeValidationOptions
|
|
16
|
+
* @property {boolean} [allowEmpty=true] - Whether empty values are allowed
|
|
17
|
+
*/
|
|
18
|
+
|
|
12
19
|
/**
|
|
13
20
|
* Validation utility class providing type checking and assertion methods.
|
|
14
21
|
*/
|
|
@@ -20,7 +27,7 @@ export default class Valid {
|
|
|
20
27
|
*
|
|
21
28
|
* @param {unknown} value - The value to validate
|
|
22
29
|
* @param {string} type - The expected type in the form of "object", "object[]", "object|object[]"
|
|
23
|
-
* @param {
|
|
30
|
+
* @param {TypeValidationOptions} [options] - Additional options for validation.
|
|
24
31
|
*/
|
|
25
32
|
static type(value, type, options) {
|
|
26
33
|
const expected = [type]
|
|
@@ -89,24 +89,46 @@ export default class Data {
|
|
|
89
89
|
* @returns {string} The remaining string
|
|
90
90
|
*/
|
|
91
91
|
static chopBefore(string: string, needle: string, caseInsensitive?: boolean): string;
|
|
92
|
+
/**
|
|
93
|
+
* Options for creating a new TypeSpec.
|
|
94
|
+
*
|
|
95
|
+
* @typedef {object} TypeSpecOptions
|
|
96
|
+
* @property {string} [delimiter="|"] - The delimiter for union types
|
|
97
|
+
*/
|
|
98
|
+
/**
|
|
99
|
+
* Options for type validation methods.
|
|
100
|
+
*
|
|
101
|
+
* @typedef {object} TypeValidationOptions
|
|
102
|
+
* @property {boolean} [allowEmpty=true] - Whether empty values are allowed
|
|
103
|
+
*/
|
|
92
104
|
/**
|
|
93
105
|
* Creates a type spec from a string. A type spec is an array of objects
|
|
94
106
|
* defining the type of a value and whether an array is expected.
|
|
95
107
|
*
|
|
96
108
|
* @param {string} string - The string to parse into a type spec.
|
|
97
|
-
* @param {
|
|
109
|
+
* @param {TypeSpecOptions} [options] - Additional options for parsing.
|
|
98
110
|
* @returns {Array<object>} An array of type specs.
|
|
99
111
|
*/
|
|
100
|
-
static newTypeSpec(string: string, options
|
|
112
|
+
static newTypeSpec(string: string, options?: {
|
|
113
|
+
/**
|
|
114
|
+
* - The delimiter for union types
|
|
115
|
+
*/
|
|
116
|
+
delimiter?: string;
|
|
117
|
+
}): Array<object>;
|
|
101
118
|
/**
|
|
102
119
|
* Checks if a value is of a specified type
|
|
103
120
|
*
|
|
104
121
|
* @param {unknown} value The value to check
|
|
105
122
|
* @param {string|TypeSpec} type The type to check for
|
|
106
|
-
* @param {
|
|
123
|
+
* @param {TypeValidationOptions} [options] Additional options for checking
|
|
107
124
|
* @returns {boolean} Whether the value is of the specified type
|
|
108
125
|
*/
|
|
109
|
-
static isType(value: unknown, type: string | TypeSpec, options?:
|
|
126
|
+
static isType(value: unknown, type: string | TypeSpec, options?: {
|
|
127
|
+
/**
|
|
128
|
+
* - Whether empty values are allowed
|
|
129
|
+
*/
|
|
130
|
+
allowEmpty?: boolean;
|
|
131
|
+
}): boolean;
|
|
110
132
|
/**
|
|
111
133
|
* Checks if a type is valid
|
|
112
134
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Data.d.ts","sourceRoot":"","sources":["../../../src/browser/lib/Data.js"],"names":[],"mappings":"AAUA;IACA;;;;;OAKG;IACD,mBAFQ,KAAK,CAAC,MAAM,CAAC,CAgBnB;IAEF;;;;;OAKG;IACH,qBAFU,KAAK,CAAC,MAAM,CAAC,CAmBrB;IAEF;;;;;;;OAOG;IACH,kBAFU,KAAK,CAAC,MAAM,CAAC,CAKrB;IAEF;;;;;OAKG;IACH,uBAFU,KAAK,CAAC,MAAM,CAAC,CAE2D;IAElF;;;;;;OAMG;IACH,sBAJW,MAAM,UACN,MAAM,GACJ,MAAM,CAMlB;IAED;;;;;;OAMG;IACH,uBAJW,MAAM,WACN,MAAM,GACJ,MAAM,CAMlB;IAED;;;;;;;;;;;OAWG;IACH,yBATW,MAAM,UACN,MAAM,oBACN,OAAO,GACL,MAAM,CAWlB;IAED;;;;;;;;;;;OAWG;IACH,wBATW,MAAM,UACN,MAAM,oBACN,OAAO,GACL,MAAM,CAWlB;IAED;;;;;;;OAOG;IACH,yBALW,MAAM,UACN,MAAM,oBACN,OAAO,GACL,MAAM,CAWlB;IAED;;;;;;;OAOG;IACH,0BALW,MAAM,UACN,MAAM,oBACN,OAAO,GACL,MAAM,CAYlB;IAED;;;;;;;OAOG;IACH,2BAJW,MAAM,
|
|
1
|
+
{"version":3,"file":"Data.d.ts","sourceRoot":"","sources":["../../../src/browser/lib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AED;;;;;OAKG;IACH,6BAHW,MAAM,GACJ,MAAM,CAmBlB;IAED;;;;;;;OAOG;IACH,6BAJW,MAAM,QACN,KAAK,CAAC,MAAM,CAAC,GACX,MAAM,CAiBlB;IAED;;;;;;;OAOG;IACH,2BAJW,MAAM,QACN,KAAK,CAAC,MAAM,CAAC,SACb,OAAO,QAMjB;IAED;;;;;OAKG;IACH,+BAHc,MAAM,EAAA,GACP,MAAM,CAqBlB;IAED;;;;;;;OAOG;IACH,wBAJW,KAAK,CAAC,OAAO,CAAC,aACd,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,GAClC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAMnC;IAED;;;;;;;OAOG;IACH,kBALW,MAAM,OACN,MAAM,OACN,MAAM,GACJ,MAAM,CAIlB;IAED;;;;;;;OAOG;IACH,oBALW,MAAM,OACN,MAAM,OACN,MAAM,GACJ,OAAO,CAInB;IAED;;;;;;;;;;;;;;;;;;;OAmBG;IACH,4BAbW,OAAO,GACL,OAAO,CA+BnB;IAED;;;;;;;;;;;;;;;OAeG;IACH,uBAXW,OAAO,GACL,OAAO,CAgBnB;CACF;qBA9gBoB,eAAe"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {object} OObjectArrayInfo
|
|
3
|
+
* @property {Array<string>} path - The path array to the array element
|
|
4
|
+
* @property {string} flatPath - The dot-separated path to the array element
|
|
5
|
+
* @property {number} index - The index of the element in the array
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* @typedef {object} OObjectEntry
|
|
9
|
+
* @property {string} key - The property key
|
|
10
|
+
* @property {any} value - The property value
|
|
11
|
+
* @property {string} valueString - String representation of the value
|
|
12
|
+
* @property {Array<string>} path - The path array to this property
|
|
13
|
+
* @property {string} flatPath - The dot-separated path to this property
|
|
14
|
+
* @property {OObjectArrayInfo} [array] - Array information if this entry is from an array
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* @typedef {Record<string, any> | Array<any>} OObjectSource
|
|
18
|
+
*/
|
|
19
|
+
export default class OObject {
|
|
20
|
+
/**
|
|
21
|
+
* Creates an OObject from a source object or array
|
|
22
|
+
*
|
|
23
|
+
* @param {OObjectSource} source - The source object or array to decompose
|
|
24
|
+
* @returns {OObject} A new OObject instance
|
|
25
|
+
*/
|
|
26
|
+
static from(source: OObjectSource): OObject;
|
|
27
|
+
/**
|
|
28
|
+
* Decomposes a nested object into flat entries with path information.
|
|
29
|
+
* Recursively processes objects and arrays to create a flat structure for
|
|
30
|
+
* evaluation.
|
|
31
|
+
*
|
|
32
|
+
* @param {Record<string, any>} work - The object to decompose
|
|
33
|
+
* @param {Array<string>} objectPath - Current path array for nested properties
|
|
34
|
+
* @returns {Array<OObjectEntry>} Array of decomposed object entries with path information
|
|
35
|
+
*/
|
|
36
|
+
static "__#private@#decomposeObject"(work: Record<string, any>, objectPath?: Array<string>): Array<OObjectEntry>;
|
|
37
|
+
/**
|
|
38
|
+
* Constructs an OObject with optional initial data.
|
|
39
|
+
*
|
|
40
|
+
* @param {Array<OObjectEntry>} oobject
|
|
41
|
+
*/
|
|
42
|
+
constructor(oobject?: Array<OObjectEntry>);
|
|
43
|
+
/**
|
|
44
|
+
* Gets the internal data array
|
|
45
|
+
*
|
|
46
|
+
* @returns {Array<object>} The decomposed object entries
|
|
47
|
+
*/
|
|
48
|
+
get data(): Array<object>;
|
|
49
|
+
/**
|
|
50
|
+
* Finds the first entry matching a flat path or predicate
|
|
51
|
+
*
|
|
52
|
+
* @param {string|((entry: OObjectEntry, index: number, array: Array<OObjectEntry>) => boolean)} pathOrPredicate - Flat path string or predicate function
|
|
53
|
+
* @returns {OObjectEntry|undefined} The matching entry or undefined
|
|
54
|
+
*/
|
|
55
|
+
find(pathOrPredicate: string | ((entry: OObjectEntry, index: number, array: Array<OObjectEntry>) => boolean)): OObjectEntry | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* Finds all entries matching a flat path or predicate
|
|
58
|
+
*
|
|
59
|
+
* @param {string|((entry: OObjectEntry, index: number, array: Array<OObjectEntry>) => boolean)} pathOrPredicate - Flat path string or predicate function
|
|
60
|
+
* @returns {Array<object>} Array of matching entries
|
|
61
|
+
*/
|
|
62
|
+
findAll(pathOrPredicate: string | ((entry: OObjectEntry, index: number, array: Array<OObjectEntry>) => boolean)): Array<object>;
|
|
63
|
+
/**
|
|
64
|
+
* Returns an iterator over all entries in order
|
|
65
|
+
*
|
|
66
|
+
* @returns {Iterator<object>} Iterator of decomposed entries
|
|
67
|
+
*/
|
|
68
|
+
entries(): Iterator<object>;
|
|
69
|
+
/**
|
|
70
|
+
* Executes a callback for each entry in order
|
|
71
|
+
*
|
|
72
|
+
* @param {(entry: OObjectEntry, index: number, array: Array<OObjectEntry>) => void} callback - Function to call for each entry
|
|
73
|
+
* @returns {void}
|
|
74
|
+
*/
|
|
75
|
+
forEach(callback: (entry: OObjectEntry, index: number, array: Array<OObjectEntry>) => void): void;
|
|
76
|
+
/**
|
|
77
|
+
* Ensures a path exists in the data, optionally setting a value
|
|
78
|
+
*
|
|
79
|
+
* @param {string} flatPath - The dot-separated path to ensure
|
|
80
|
+
* @param {*} value - Optional value to set (defaults to undefined)
|
|
81
|
+
* @returns {object} The entry at the path
|
|
82
|
+
*/
|
|
83
|
+
assurePath(flatPath: string, value?: any): object;
|
|
84
|
+
#private;
|
|
85
|
+
}
|
|
86
|
+
export type OObjectArrayInfo = {
|
|
87
|
+
/**
|
|
88
|
+
* - The path array to the array element
|
|
89
|
+
*/
|
|
90
|
+
path: Array<string>;
|
|
91
|
+
/**
|
|
92
|
+
* - The dot-separated path to the array element
|
|
93
|
+
*/
|
|
94
|
+
flatPath: string;
|
|
95
|
+
/**
|
|
96
|
+
* - The index of the element in the array
|
|
97
|
+
*/
|
|
98
|
+
index: number;
|
|
99
|
+
};
|
|
100
|
+
export type OObjectEntry = {
|
|
101
|
+
/**
|
|
102
|
+
* - The property key
|
|
103
|
+
*/
|
|
104
|
+
key: string;
|
|
105
|
+
/**
|
|
106
|
+
* - The property value
|
|
107
|
+
*/
|
|
108
|
+
value: any;
|
|
109
|
+
/**
|
|
110
|
+
* - String representation of the value
|
|
111
|
+
*/
|
|
112
|
+
valueString: string;
|
|
113
|
+
/**
|
|
114
|
+
* - The path array to this property
|
|
115
|
+
*/
|
|
116
|
+
path: Array<string>;
|
|
117
|
+
/**
|
|
118
|
+
* - The dot-separated path to this property
|
|
119
|
+
*/
|
|
120
|
+
flatPath: string;
|
|
121
|
+
/**
|
|
122
|
+
* - Array information if this entry is from an array
|
|
123
|
+
*/
|
|
124
|
+
array?: OObjectArrayInfo;
|
|
125
|
+
};
|
|
126
|
+
export type OObjectSource = Record<string, any> | Array<any>;
|
|
127
|
+
//# sourceMappingURL=OObject.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OObject.d.ts","sourceRoot":"","sources":["../../../src/browser/lib/OObject.js"],"names":[],"mappings":"AAGA;;;;;GAKG;AAEH;;;;;;;;GAQG;AAEH;;GAEG;AAEH;IAaE;;;;;OAKG;IACH,oBAHW,aAAa,GACX,OAAO,CAMnB;IAED;;;;;;;;OAQG;IACH,2CAJW,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,eACnB,KAAK,CAAC,MAAM,CAAC,GACX,KAAK,CAAC,YAAY,CAAC,CAyC/B;IArED;;;;OAIG;IACH,sBAFW,KAAK,CAAC,YAAY,CAAC,EAI7B;IAgED;;;;OAIG;IACH,YAFa,KAAK,CAAC,MAAM,CAAC,CAIzB;IAED;;;;;OAKG;IACH,sBAHW,MAAM,GAAC,CAAC,CAAC,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,YAAY,CAAC,KAAK,OAAO,CAAC,GAClF,YAAY,GAAC,SAAS,CAUlC;IAED;;;;;OAKG;IACH,yBAHW,MAAM,GAAC,CAAC,CAAC,KAAK,EAA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;;GAGG;AACH;IACE;;;;;;;;;;;;;;;;;;OAkBG;IACH,oBAfW,MAAM,UACN,OAAO,GACL,OAAO,CAAC,OAAO,CAAC,GAAG;QAAC,OAAO,EAAE,MAAM,CAAA;KAAC,
|
|
1
|
+
{"version":3,"file":"Time.d.ts","sourceRoot":"","sources":["../../../src/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,CA0BhD;IAED;;;;;;;;;OASG;IACH,uBANW,OAAO,CAAC,OAAO,CAAC,GAAG;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAC,GACnC,IAAI,CAQhB;CACF"}
|
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Options for creating a new TypeSpec.
|
|
3
|
+
*
|
|
4
|
+
* @typedef {object} TypeSpecOptions
|
|
5
|
+
* @property {string} [delimiter="|"] - The delimiter for union types
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Options for type validation methods.
|
|
9
|
+
*
|
|
10
|
+
* @typedef {object} TypeValidationOptions
|
|
11
|
+
* @property {boolean} [allowEmpty=true] - Whether empty values are allowed
|
|
12
|
+
*/
|
|
1
13
|
/**
|
|
2
14
|
* Type specification class for parsing and validating complex type definitions.
|
|
3
15
|
* Supports union types, array types, and validation options.
|
|
@@ -7,9 +19,9 @@ export default class TypeSpec {
|
|
|
7
19
|
* Creates a new TypeSpec instance.
|
|
8
20
|
*
|
|
9
21
|
* @param {string} string - The type specification string (e.g., "string|number", "object[]")
|
|
10
|
-
* @param {
|
|
22
|
+
* @param {TypeSpecOptions} [options] - Additional parsing options
|
|
11
23
|
*/
|
|
12
|
-
constructor(string: string, options
|
|
24
|
+
constructor(string: string, options?: TypeSpecOptions);
|
|
13
25
|
specs: any[];
|
|
14
26
|
length: number;
|
|
15
27
|
stringRepresentation: string;
|
|
@@ -79,12 +91,36 @@ export default class TypeSpec {
|
|
|
79
91
|
* Handles array types, union types, and empty value validation.
|
|
80
92
|
*
|
|
81
93
|
* @param {unknown} value - The value to test against the type specifications
|
|
82
|
-
* @param {
|
|
83
|
-
* @param {boolean} options.allowEmpty - Whether empty values are allowed
|
|
94
|
+
* @param {TypeValidationOptions} [options] - Validation options
|
|
84
95
|
* @returns {boolean} True if the value matches any type specification
|
|
85
96
|
*/
|
|
86
|
-
matches(value: unknown, options
|
|
87
|
-
|
|
97
|
+
matches(value: unknown, options?: TypeValidationOptions): boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Returns matching type specifications for a value.
|
|
100
|
+
*
|
|
101
|
+
* @param {unknown} value - The value to test against the type specifications
|
|
102
|
+
* @param {TypeValidationOptions} [options] - Validation options
|
|
103
|
+
* @returns {Array<object>} Array of matching type specifications
|
|
104
|
+
*/
|
|
105
|
+
match(value: unknown, options?: TypeValidationOptions): Array<object>;
|
|
88
106
|
#private;
|
|
89
107
|
}
|
|
108
|
+
/**
|
|
109
|
+
* Options for creating a new TypeSpec.
|
|
110
|
+
*/
|
|
111
|
+
export type TypeSpecOptions = {
|
|
112
|
+
/**
|
|
113
|
+
* - The delimiter for union types
|
|
114
|
+
*/
|
|
115
|
+
delimiter?: string;
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* Options for type validation methods.
|
|
119
|
+
*/
|
|
120
|
+
export type TypeValidationOptions = {
|
|
121
|
+
/**
|
|
122
|
+
* - Whether empty values are allowed
|
|
123
|
+
*/
|
|
124
|
+
allowEmpty?: boolean;
|
|
125
|
+
};
|
|
90
126
|
//# sourceMappingURL=TypeSpec.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypeSpec.d.ts","sourceRoot":"","sources":["../../../src/browser/lib/TypeSpec.js"],"names":[],"mappings":"AAWA;;;GAGG;AACH;IAGE;;;;;OAKG;IACH,oBAHW,MAAM,
|
|
1
|
+
{"version":3,"file":"TypeSpec.d.ts","sourceRoot":"","sources":["../../../src/browser/lib/TypeSpec.js"],"names":[],"mappings":"AAWA;;;;;GAKG;AAEH;;;;;GAKG;AAEH;;;GAGG;AACH;IAGE;;;;;OAKG;IACH,oBAHW,MAAM,YACN,eAAe,EAUzB;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;;;;;;;OAOG;IACH,eAJW,OAAO,YACP,qBAAqB,GACnB,OAAO,CAInB;IAED;;;;;;OAMG;IACH,aAJW,OAAO,YACP,qBAAqB,GACnB,KAAK,CAAC,MAAM,CAAC,CA+DzB;;CAkDF;;;;;;;;gBApQa,MAAM;;;;;;;;;iBAON,OAAO"}
|