@gesslar/toolkit 5.0.1 → 5.2.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 +1 -2
- package/package.json +5 -5
- package/src/browser/lib/TypeSpec.js +1 -1
- package/src/browser/lib/Valid.js +31 -17
- package/src/node/lib/Cache.js +1 -1
- package/src/node/lib/DirectoryObject.js +18 -11
- package/src/node/lib/FileObject.js +13 -3
- package/src/node/lib/Valid.js +6 -74
- package/types/browser/lib/Valid.d.ts +21 -3
- package/types/browser/lib/Valid.d.ts.map +1 -1
- package/types/node/lib/DirectoryObject.d.ts.map +1 -1
- package/types/node/lib/FileObject.d.ts.map +1 -1
- package/types/node/lib/Valid.d.ts +6 -45
- package/types/node/lib/Valid.d.ts.map +1 -1
- package/vendor/toolkit.esm.js +33 -19
- package/vendor/toolkit.umd.js +33 -19
package/README.md
CHANGED
|
@@ -47,7 +47,6 @@ Includes all browser functionality plus Node.js-specific modules for file I/O, l
|
|
|
47
47
|
| Valid | Validation and assertion methods |
|
|
48
48
|
| Watcher | File and directory change watcher with debounce protection |
|
|
49
49
|
|
|
50
|
-
|
|
51
50
|
## Installation
|
|
52
51
|
|
|
53
52
|
```shell
|
|
@@ -151,7 +150,7 @@ Sincerely, Senator Yabba of the Dabba (Doo)
|
|
|
151
150
|
|
|
152
151
|
## License
|
|
153
152
|
|
|
154
|
-
`@gesslar/toolkit` is released
|
|
153
|
+
`@gesslar/toolkit` is released under the [0BSD](LICENSE.txt).
|
|
155
154
|
|
|
156
155
|
This package includes or depends on third-party components under their own
|
|
157
156
|
licenses:
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"name": "gesslar",
|
|
6
6
|
"url": "https://gesslar.dev"
|
|
7
7
|
},
|
|
8
|
-
"version": "5.0
|
|
8
|
+
"version": "5.2.0",
|
|
9
9
|
"license": "0BSD",
|
|
10
10
|
"homepage": "https://github.com/gesslar/toolkit#readme",
|
|
11
11
|
"repository": {
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"LICENSE.txt"
|
|
56
56
|
],
|
|
57
57
|
"engines": {
|
|
58
|
-
"node": ">=24
|
|
58
|
+
"node": ">=24"
|
|
59
59
|
},
|
|
60
60
|
"scripts": {
|
|
61
61
|
"preinstall": "node ./scripts/check-node-version.mjs",
|
|
@@ -83,11 +83,11 @@
|
|
|
83
83
|
"yaml": "^2.8.3"
|
|
84
84
|
},
|
|
85
85
|
"devDependencies": {
|
|
86
|
-
"@gesslar/uglier": "^2.4.
|
|
86
|
+
"@gesslar/uglier": "^2.4.1",
|
|
87
87
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
88
88
|
"eslint": "^10.2.0",
|
|
89
|
-
"happy-dom": "^20.
|
|
89
|
+
"happy-dom": "^20.9.0",
|
|
90
90
|
"rollup": "^4.60.1",
|
|
91
|
-
"typescript": "^6.0.
|
|
91
|
+
"typescript": "^6.0.3"
|
|
92
92
|
}
|
|
93
93
|
}
|
|
@@ -193,7 +193,7 @@ export default class TypeSpec {
|
|
|
193
193
|
// Handle non-array values
|
|
194
194
|
if(!isArray && !allowedArray) {
|
|
195
195
|
if(valueType === allowedType)
|
|
196
|
-
return allowEmpty || !empty
|
|
196
|
+
return Data.isBaseType(value, allowedType) && (allowEmpty || !empty)
|
|
197
197
|
|
|
198
198
|
if(valueType === "Null" || valueType === "Undefined")
|
|
199
199
|
return false
|
package/src/browser/lib/Valid.js
CHANGED
|
@@ -9,21 +9,36 @@ import Sass from "./Sass.js"
|
|
|
9
9
|
import Data from "./Data.js"
|
|
10
10
|
import Collection from "./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
|
*/
|
|
15
22
|
export default class Valid {
|
|
23
|
+
/** @type {typeof Sass} */
|
|
24
|
+
static _Sass = Sass
|
|
25
|
+
|
|
16
26
|
/**
|
|
17
27
|
* Validates a value against a type. Uses Data.isType.
|
|
18
28
|
*
|
|
19
29
|
* @param {unknown} value - The value to validate
|
|
20
30
|
* @param {string} type - The expected type in the form of "object", "object[]", "object|object[]"
|
|
21
|
-
* @param {
|
|
31
|
+
* @param {TypeValidationOptions} [options] - Additional options for validation.
|
|
22
32
|
*/
|
|
23
33
|
static type(value, type, options) {
|
|
24
|
-
|
|
34
|
+
const expected = [type]
|
|
35
|
+
|
|
36
|
+
if(options?.allowEmpty !== true)
|
|
37
|
+
expected.push("[no empty values]")
|
|
38
|
+
|
|
39
|
+
this.assert(
|
|
25
40
|
Data.isType(value, type, options),
|
|
26
|
-
`Invalid type. Expected ${
|
|
41
|
+
`Invalid type. Expected ${expected.join(" ")}, got ${Data.typeOf(value)}`
|
|
27
42
|
)
|
|
28
43
|
}
|
|
29
44
|
|
|
@@ -37,23 +52,20 @@ export default class Valid {
|
|
|
37
52
|
* met (optional)
|
|
38
53
|
*/
|
|
39
54
|
static assert(condition, message, arg = null) {
|
|
40
|
-
if(!Data.isType(condition, "boolean"))
|
|
41
|
-
throw
|
|
42
|
-
}
|
|
55
|
+
if(!Data.isType(condition, "boolean"))
|
|
56
|
+
throw this._Sass.new(`Condition must be a boolean, got ${condition}`)
|
|
43
57
|
|
|
44
|
-
if(!Data.isType(message, "string"))
|
|
45
|
-
throw
|
|
46
|
-
}
|
|
58
|
+
if(!Data.isType(message, "string"))
|
|
59
|
+
throw this._Sass.new(`Message must be a string, got ${message}`)
|
|
47
60
|
|
|
48
|
-
if(!(arg === null || arg === undefined || typeof arg === "number"))
|
|
49
|
-
throw
|
|
50
|
-
}
|
|
61
|
+
if(!(arg === null || arg === undefined || typeof arg === "number"))
|
|
62
|
+
throw this._Sass.new(`Arg must be a number, got ${arg}`)
|
|
51
63
|
|
|
52
64
|
if(!condition)
|
|
53
|
-
throw
|
|
65
|
+
throw this._Sass.new(`${message}${arg ? `: ${arg}` : ""}`)
|
|
54
66
|
}
|
|
55
67
|
|
|
56
|
-
static #restrictedProto = ["__proto__", "constructor", "prototype"]
|
|
68
|
+
static #restrictedProto = Object.freeze(["__proto__", "constructor", "prototype"])
|
|
57
69
|
|
|
58
70
|
/**
|
|
59
71
|
* Protects against prototype pollution by checking keys for dangerous property names.
|
|
@@ -63,11 +75,13 @@ export default class Valid {
|
|
|
63
75
|
* @throws {Sass} If any key matches restricted prototype properties (__proto__, constructor, prototype)
|
|
64
76
|
*/
|
|
65
77
|
static prototypePollutionProtection(keys) {
|
|
66
|
-
|
|
78
|
+
this.type(keys, "String[]")
|
|
67
79
|
|
|
68
|
-
const oopsIDidItAgain = Collection.intersection(
|
|
80
|
+
const oopsIDidItAgain = Collection.intersection(
|
|
81
|
+
Valid.#restrictedProto, keys
|
|
82
|
+
)
|
|
69
83
|
|
|
70
|
-
|
|
84
|
+
this.assert(
|
|
71
85
|
oopsIDidItAgain.length === 0,
|
|
72
86
|
`We don't pee in your pool, don't pollute ours with your ${String(oopsIDidItAgain)}`
|
|
73
87
|
)
|
package/src/node/lib/Cache.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* resolution and existence checks.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import {glob, mkdir,
|
|
7
|
+
import {glob, mkdir, readdir, rmdir, stat} from "node:fs/promises"
|
|
8
8
|
import path, {relative} from "node:path"
|
|
9
9
|
import {URL} from "node:url"
|
|
10
10
|
import {inspect} from "node:util"
|
|
@@ -342,16 +342,24 @@ export default class DirectoryObject extends FS {
|
|
|
342
342
|
* Check if a directory exists
|
|
343
343
|
*
|
|
344
344
|
* @returns {Promise<boolean>} Whether the directory exists
|
|
345
|
+
* @throws {Sass} If the path exists but is not a directory
|
|
345
346
|
*/
|
|
346
347
|
async #directoryExists() {
|
|
347
|
-
const path = this.path
|
|
348
|
-
|
|
349
348
|
try {
|
|
350
|
-
|
|
349
|
+
const stats = await stat(this.path).catch(error => error.code === "ENOENT" ? null : error)
|
|
350
|
+
|
|
351
|
+
if(stats instanceof Error)
|
|
352
|
+
throw stats
|
|
353
|
+
|
|
354
|
+
if(stats === null)
|
|
355
|
+
return false
|
|
356
|
+
|
|
357
|
+
if(!stats.isDirectory())
|
|
358
|
+
throw Sass.new(`Path exists but is not a directory: '${this.path}'`)
|
|
351
359
|
|
|
352
360
|
return true
|
|
353
|
-
} catch {
|
|
354
|
-
|
|
361
|
+
} catch(error) {
|
|
362
|
+
throw Sass.new(`Determining status of '${this.path}'`, error)
|
|
355
363
|
}
|
|
356
364
|
}
|
|
357
365
|
|
|
@@ -583,9 +591,9 @@ export default class DirectoryObject extends FS {
|
|
|
583
591
|
* @returns {Promise<boolean>} True if the file exists, false otherwise
|
|
584
592
|
*/
|
|
585
593
|
async hasFile(filename) {
|
|
586
|
-
const file =
|
|
594
|
+
const file = this.getFile(filename)
|
|
587
595
|
|
|
588
|
-
return await file.exists
|
|
596
|
+
return await file.exists.catch(() => false)
|
|
589
597
|
}
|
|
590
598
|
|
|
591
599
|
/**
|
|
@@ -595,10 +603,9 @@ export default class DirectoryObject extends FS {
|
|
|
595
603
|
* @returns {Promise<boolean>} True if the directory exists, false otherwise
|
|
596
604
|
*/
|
|
597
605
|
async hasDirectory(dirname) {
|
|
598
|
-
const dir =
|
|
599
|
-
const directory = new DirectoryObject(dir)
|
|
606
|
+
const dir = this.getDirectory(dirname)
|
|
600
607
|
|
|
601
|
-
return await
|
|
608
|
+
return await dir.exists.catch(() => false)
|
|
602
609
|
}
|
|
603
610
|
|
|
604
611
|
/**
|
|
@@ -324,14 +324,24 @@ export default class FileObject extends FS {
|
|
|
324
324
|
* Check if a file exists
|
|
325
325
|
*
|
|
326
326
|
* @returns {Promise<boolean>} Whether the file exists
|
|
327
|
+
* @throws {Sass} If the path exists but is not a file
|
|
327
328
|
*/
|
|
328
329
|
async #fileExists() {
|
|
329
330
|
try {
|
|
330
|
-
await fs.
|
|
331
|
+
const stats = await fs.stat(this.path).catch(error => error.code === "ENOENT" ? null : error)
|
|
332
|
+
|
|
333
|
+
if(stats instanceof Error)
|
|
334
|
+
throw stats
|
|
335
|
+
|
|
336
|
+
if(stats === null)
|
|
337
|
+
return false
|
|
338
|
+
|
|
339
|
+
if(!stats.isFile())
|
|
340
|
+
throw Sass.new(`Path exists but is not a file: '${this.path}'`)
|
|
331
341
|
|
|
332
342
|
return true
|
|
333
|
-
} catch {
|
|
334
|
-
|
|
343
|
+
} catch(error) {
|
|
344
|
+
throw Sass.new(`Determining status of '${this.path}'`, error)
|
|
335
345
|
}
|
|
336
346
|
}
|
|
337
347
|
|
package/src/node/lib/Valid.js
CHANGED
|
@@ -2,85 +2,17 @@
|
|
|
2
2
|
* @file Valid.js
|
|
3
3
|
*
|
|
4
4
|
* Node-flavoured validation utilities that throw the Node Sass error type.
|
|
5
|
-
*
|
|
5
|
+
* Extends the browser Valid, swapping in the Node Sass for richer reporting.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
import BrowserValid from "../../browser/lib/Valid.js"
|
|
8
9
|
import Sass from "./Sass.js"
|
|
9
|
-
import Data from "../../browser/lib/Data.js"
|
|
10
|
-
import Collection from "../../browser/lib/Collection.js"
|
|
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
10
|
|
|
19
11
|
/**
|
|
20
12
|
* Validation utility class providing type checking and assertion methods.
|
|
13
|
+
* Inherits all behaviour from browser Valid; only the Sass class differs.
|
|
21
14
|
*/
|
|
22
|
-
export default class Valid {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Validates a value against a type. Uses Data.isType.
|
|
27
|
-
*
|
|
28
|
-
* @param {unknown} value - The value to validate
|
|
29
|
-
* @param {string} type - The expected type in the form of "object", "object[]", "object|object[]"
|
|
30
|
-
* @param {TypeValidationOptions} [options] - Additional options for validation.
|
|
31
|
-
*/
|
|
32
|
-
static type(value, type, options) {
|
|
33
|
-
const expected = [type]
|
|
34
|
-
|
|
35
|
-
if(options?.allowEmpty !== true)
|
|
36
|
-
expected.push("[no empty values]")
|
|
37
|
-
|
|
38
|
-
Valid.assert(
|
|
39
|
-
Data.isType(value, type, options),
|
|
40
|
-
`Invalid type. Expected ${expected.join(" ")}, got ${Data.typeOf(value)}`
|
|
41
|
-
)
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Asserts a condition
|
|
46
|
-
*
|
|
47
|
-
* @param {boolean} condition - The condition to assert
|
|
48
|
-
* @param {string} message - The message to display if the condition is not
|
|
49
|
-
* met
|
|
50
|
-
* @param {number} [arg] - The argument to display if the condition is not
|
|
51
|
-
* met (optional)
|
|
52
|
-
*/
|
|
53
|
-
static assert(condition, message, arg = null) {
|
|
54
|
-
if(!Data.isType(condition, "boolean"))
|
|
55
|
-
throw Sass.new(`Condition must be a boolean, got ${condition}`)
|
|
56
|
-
|
|
57
|
-
if(!Data.isType(message, "string"))
|
|
58
|
-
throw Sass.new(`Message must be a string, got ${message}`)
|
|
59
|
-
|
|
60
|
-
if(!(arg === null || arg === undefined || typeof arg === "number"))
|
|
61
|
-
throw Sass.new(`Arg must be a number, got ${arg}`)
|
|
62
|
-
|
|
63
|
-
if(!condition)
|
|
64
|
-
throw Sass.new(`${message}${arg ? `: ${arg}` : ""}`)
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Protects against prototype pollution by checking keys for dangerous
|
|
69
|
-
* property names.
|
|
70
|
-
*
|
|
71
|
-
* Throws if any restricted prototype properties are found in the keys array.
|
|
72
|
-
*
|
|
73
|
-
* @param {Array<string>} keys - Array of property keys to validate
|
|
74
|
-
* @throws {Sass} If any key matches restricted prototype properties (__proto__, constructor, prototype)
|
|
75
|
-
*/
|
|
76
|
-
static prototypePollutionProtection(keys) {
|
|
77
|
-
Valid.type(keys, "String[]")
|
|
78
|
-
|
|
79
|
-
const oopsIDidItAgain = Collection.intersection(this.#restrictedProto, keys)
|
|
80
|
-
|
|
81
|
-
Valid.assert(
|
|
82
|
-
oopsIDidItAgain.length === 0,
|
|
83
|
-
`We don't pee in your pool, don't pollute ours with your ${String(oopsIDidItAgain)}`
|
|
84
|
-
)
|
|
85
|
-
}
|
|
15
|
+
export default class Valid extends BrowserValid {
|
|
16
|
+
/** @type {typeof Sass} */
|
|
17
|
+
static _Sass = Sass
|
|
86
18
|
}
|
|
@@ -1,15 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Options for type validation methods.
|
|
3
|
+
*
|
|
4
|
+
* @typedef {object} TypeValidationOptions
|
|
5
|
+
* @property {boolean} [allowEmpty=true] - Whether empty values are allowed
|
|
6
|
+
*/
|
|
1
7
|
/**
|
|
2
8
|
* Validation utility class providing type checking and assertion methods.
|
|
3
9
|
*/
|
|
4
10
|
export default class Valid {
|
|
11
|
+
/** @type {typeof Sass} */
|
|
12
|
+
static _Sass: typeof Sass;
|
|
5
13
|
/**
|
|
6
14
|
* Validates a value against a type. Uses Data.isType.
|
|
7
15
|
*
|
|
8
16
|
* @param {unknown} value - The value to validate
|
|
9
17
|
* @param {string} type - The expected type in the form of "object", "object[]", "object|object[]"
|
|
10
|
-
* @param {
|
|
18
|
+
* @param {TypeValidationOptions} [options] - Additional options for validation.
|
|
11
19
|
*/
|
|
12
|
-
static type(value: unknown, type: string, options?:
|
|
20
|
+
static type(value: unknown, type: string, options?: TypeValidationOptions): void;
|
|
13
21
|
/**
|
|
14
22
|
* Asserts a condition
|
|
15
23
|
*
|
|
@@ -20,7 +28,7 @@ export default class Valid {
|
|
|
20
28
|
* met (optional)
|
|
21
29
|
*/
|
|
22
30
|
static assert(condition: boolean, message: string, arg?: number): void;
|
|
23
|
-
static #restrictedProto: string[];
|
|
31
|
+
static #restrictedProto: readonly string[];
|
|
24
32
|
/**
|
|
25
33
|
* Protects against prototype pollution by checking keys for dangerous property names.
|
|
26
34
|
* Throws if any restricted prototype properties are found in the keys array.
|
|
@@ -30,4 +38,14 @@ export default class Valid {
|
|
|
30
38
|
*/
|
|
31
39
|
static prototypePollutionProtection(keys: Array<string>): void;
|
|
32
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* Options for type validation methods.
|
|
43
|
+
*/
|
|
44
|
+
export type TypeValidationOptions = {
|
|
45
|
+
/**
|
|
46
|
+
* - Whether empty values are allowed
|
|
47
|
+
*/
|
|
48
|
+
allowEmpty?: boolean;
|
|
49
|
+
};
|
|
50
|
+
import Sass from "./Sass.js";
|
|
33
51
|
//# sourceMappingURL=Valid.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Valid.d.ts","sourceRoot":"","sources":["../../../src/browser/lib/Valid.js"],"names":[],"mappings":"AAWA;;GAEG;AACH;IACE;;;;;;OAMG;IACH,mBAJW,OAAO,QACP,MAAM,YACN,
|
|
1
|
+
{"version":3,"file":"Valid.d.ts","sourceRoot":"","sources":["../../../src/browser/lib/Valid.js"],"names":[],"mappings":"AAWA;;;;;GAKG;AAEH;;GAEG;AACH;IACE,0BAA0B;IAC1B,cADW,OAAO,IAAI,CACH;IAEnB;;;;;;OAMG;IACH,mBAJW,OAAO,QACP,MAAM,YACN,qBAAqB,QAY/B;IAED;;;;;;;;OAQG;IACH,yBANW,OAAO,WACP,MAAM,QAEN,MAAM,QAehB;IAED,2CAAkF;IAElF;;;;;;OAMG;IACH,0CAHW,KAAK,CAAC,MAAM,CAAC,QAcvB;CACF;;;;;;;;iBAzEa,OAAO;;iBARJ,WAAW"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DirectoryObject.d.ts","sourceRoot":"","sources":["../../../src/node/lib/DirectoryObject.js"],"names":[],"mappings":"AAiBA;;;;GAIG;AAEH;;;;;;;;;;;;;;GAcG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH;yBAoGa,MAAM,WACN,MAAM,oBAEJ,MAAM;IAhDnB;;;;;;;;;OASG;IACH,kBALa,eAAe,CAO3B;IA7CD;;;;OAIG;IACH,uBAFW,MAAM,OAAC,EA4BjB;IAyBD;;;;OAIG;IACH,UAFa,MAAM,CAclB;IA8BD;;;;OAIG;IACH,WAFa,MAAM,CAIlB;IAED;;;;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;
|
|
1
|
+
{"version":3,"file":"DirectoryObject.d.ts","sourceRoot":"","sources":["../../../src/node/lib/DirectoryObject.js"],"names":[],"mappings":"AAiBA;;;;GAIG;AAEH;;;;;;;;;;;;;;GAcG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH;yBAoGa,MAAM,WACN,MAAM,oBAEJ,MAAM;IAhDnB;;;;;;;;;OASG;IACH,kBALa,eAAe,CAO3B;IA7CD;;;;OAIG;IACH,uBAFW,MAAM,OAAC,EA4BjB;IAyBD;;;;OAIG;IACH,UAFa,MAAM,CAclB;IA8BD;;;;OAIG;IACH,WAFa,MAAM,CAIlB;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;;;;;;;;;OAyBG;IACH,sBAbW,MAAM,GACJ,eAAe,CAgC3B;IAED;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,kBAbW,MAAM,GACJ,UAAU,CAgCtB;IA/fD;;;;;;;OAOG;IACH,2BAHW,QAAQ,GAAC,QAAQ,GAAC,SAAS,GACzB,MAAM,GAAC,MAAM,CAQzB;;CAkfF;;UA9qBa,MAAY;QAAC,KAAK,EAAE,eAAe,CAAC;QAAC,IAAI,EAAE,OAAO,CAAA;KAAC;eACnD,MAAY,aAAa;;;;;;iBAMzB,OAAO;;;;eACP,MAAM,GAAC,IAAI;;;;YACX,MAAM,GAAC,IAAI;;;;UACX,MAAM,GAAC,IAAI;;;;YACX,eAAe,GAAC,SAAS;;;;gBACzB,MAAM,GAAC,IAAI;;;;UACX,MAAM,GAAC,IAAI;;;;SACX,MAAM,GAAC,IAAI;;;;cACX,MAAM,GAAC,IAAI;;;;WACX,KAAK,CAAC,MAAM,CAAC,GAAC,IAAI;;;;SAClB,GAAG,GAAC,IAAI;;eAvBP,iBAAiB;uBADT,iBAAiB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileObject.d.ts","sourceRoot":"","sources":["../../../src/node/lib/FileObject.js"],"names":[],"mappings":"AAkBA;;;;;;;;;;;;;GAaG;AAEH;yBA8Ha,MAAM,WACN,MAAM,oBAEJ,MAAM;
|
|
1
|
+
{"version":3,"file":"FileObject.d.ts","sourceRoot":"","sources":["../../../src/node/lib/FileObject.js"],"names":[],"mappings":"AAkBA;;;;;;;;;;;;;GAaG;AAEH;yBA8Ha,MAAM,WACN,MAAM,oBAEJ,MAAM;IAggBnB;;;;;;;;;;;OAWG;IACH,kBAPa,UAAU,CAsCtB;IAjpBD;;;;;OAKG;IACH,uBAHW,MAAM,WACN,eAAe,GAAC,MAAM,GAAC,IAAI,EA+DrC;IAWD;;;;OAIG;IACH,UAFa,MAAM,CAalB;IA8BD;;;;OAIG;IACH,WAFa,MAAM,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;;;;;;;OAgBG;IACH,yCAZG;QAAyB,IAAI,GAArB,MAAM;QACW,QAAQ,GAAzB,MAAM;QACY,SAAS,GAA3B,OAAO;KACf,GAAU,OAAO,CAAC,OAAO,CAAC,CAqB5B;IAED;;;;OAIG;IACH,UAFa,OAAO,CAAC,MAAM,CAAC,CAS3B;IAED;;;;;;;;;;;;OAYG;IACH,kBATW,MAAM,GACJ,OAAO,CAAC,UAAU,CAAC,CAyB/B;IAED;;;;;;;;;;;;;OAaG;IACH,kBATW,MAAM,GACJ,OAAO,CAAC,UAAU,CAAC,CA0C/B;IAED;;;;;;;;;OASG;IACH,UAPa,OAAO,CAAC,SAAS,CAAC,CAc9B;IAxfD;;;;;;;OAOG;IACH,2BAHW,QAAQ,GAAC,QAAQ,GAAC,SAAS,GACzB,MAAM,GAAC,MAAM,CAQzB;;CAwhBF;eAhsBc,iBAAiB;4BADJ,sBAAsB;kBAFhC,YAAY"}
|
|
@@ -1,50 +1,11 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Options for type validation methods.
|
|
3
|
-
*
|
|
4
|
-
* @typedef {object} TypeValidationOptions
|
|
5
|
-
* @property {boolean} [allowEmpty=true] - Whether empty values are allowed
|
|
6
|
-
*/
|
|
7
1
|
/**
|
|
8
2
|
* Validation utility class providing type checking and assertion methods.
|
|
3
|
+
* Inherits all behaviour from browser Valid; only the Sass class differs.
|
|
9
4
|
*/
|
|
10
|
-
export default class Valid {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
* Validates a value against a type. Uses Data.isType.
|
|
14
|
-
*
|
|
15
|
-
* @param {unknown} value - The value to validate
|
|
16
|
-
* @param {string} type - The expected type in the form of "object", "object[]", "object|object[]"
|
|
17
|
-
* @param {TypeValidationOptions} [options] - Additional options for validation.
|
|
18
|
-
*/
|
|
19
|
-
static type(value: unknown, type: string, options?: TypeValidationOptions): void;
|
|
20
|
-
/**
|
|
21
|
-
* Asserts a condition
|
|
22
|
-
*
|
|
23
|
-
* @param {boolean} condition - The condition to assert
|
|
24
|
-
* @param {string} message - The message to display if the condition is not
|
|
25
|
-
* met
|
|
26
|
-
* @param {number} [arg] - The argument to display if the condition is not
|
|
27
|
-
* met (optional)
|
|
28
|
-
*/
|
|
29
|
-
static assert(condition: boolean, message: string, arg?: number): void;
|
|
30
|
-
/**
|
|
31
|
-
* Protects against prototype pollution by checking keys for dangerous
|
|
32
|
-
* property names.
|
|
33
|
-
*
|
|
34
|
-
* Throws if any restricted prototype properties are found in the keys array.
|
|
35
|
-
*
|
|
36
|
-
* @param {Array<string>} keys - Array of property keys to validate
|
|
37
|
-
* @throws {Sass} If any key matches restricted prototype properties (__proto__, constructor, prototype)
|
|
38
|
-
*/
|
|
39
|
-
static prototypePollutionProtection(keys: Array<string>): void;
|
|
5
|
+
export default class Valid extends BrowserValid {
|
|
6
|
+
/** @type {typeof Sass} */
|
|
7
|
+
static _Sass: typeof Sass;
|
|
40
8
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
*/
|
|
44
|
-
export type TypeValidationOptions = {
|
|
45
|
-
/**
|
|
46
|
-
* - Whether empty values are allowed
|
|
47
|
-
*/
|
|
48
|
-
allowEmpty?: boolean;
|
|
49
|
-
};
|
|
9
|
+
import BrowserValid from "../../browser/lib/Valid.js";
|
|
10
|
+
import Sass from "./Sass.js";
|
|
50
11
|
//# sourceMappingURL=Valid.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Valid.d.ts","sourceRoot":"","sources":["../../../src/node/lib/Valid.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Valid.d.ts","sourceRoot":"","sources":["../../../src/node/lib/Valid.js"],"names":[],"mappings":"AAUA;;;GAGG;AACH;IACE,0BAA0B;IAC1B,cADW,OAAO,IAAI,CACH;CACpB;yBAVwB,4BAA4B;iBACpC,WAAW"}
|
package/vendor/toolkit.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// @gesslar/toolkit v5.0
|
|
1
|
+
// @gesslar/toolkit v5.2.0 - ES module bundle
|
|
2
2
|
/**
|
|
3
3
|
* @file Tantrum.js
|
|
4
4
|
*
|
|
@@ -317,21 +317,36 @@ class Sass extends Error {
|
|
|
317
317
|
*/
|
|
318
318
|
|
|
319
319
|
|
|
320
|
+
/**
|
|
321
|
+
* Options for type validation methods.
|
|
322
|
+
*
|
|
323
|
+
* @typedef {object} TypeValidationOptions
|
|
324
|
+
* @property {boolean} [allowEmpty=true] - Whether empty values are allowed
|
|
325
|
+
*/
|
|
326
|
+
|
|
320
327
|
/**
|
|
321
328
|
* Validation utility class providing type checking and assertion methods.
|
|
322
329
|
*/
|
|
323
330
|
class Valid {
|
|
331
|
+
/** @type {typeof Sass} */
|
|
332
|
+
static _Sass = Sass
|
|
333
|
+
|
|
324
334
|
/**
|
|
325
335
|
* Validates a value against a type. Uses Data.isType.
|
|
326
336
|
*
|
|
327
337
|
* @param {unknown} value - The value to validate
|
|
328
338
|
* @param {string} type - The expected type in the form of "object", "object[]", "object|object[]"
|
|
329
|
-
* @param {
|
|
339
|
+
* @param {TypeValidationOptions} [options] - Additional options for validation.
|
|
330
340
|
*/
|
|
331
341
|
static type(value, type, options) {
|
|
332
|
-
|
|
342
|
+
const expected = [type];
|
|
343
|
+
|
|
344
|
+
if(options?.allowEmpty !== true)
|
|
345
|
+
expected.push("[no empty values]");
|
|
346
|
+
|
|
347
|
+
this.assert(
|
|
333
348
|
Data.isType(value, type, options),
|
|
334
|
-
`Invalid type. Expected ${
|
|
349
|
+
`Invalid type. Expected ${expected.join(" ")}, got ${Data.typeOf(value)}`
|
|
335
350
|
);
|
|
336
351
|
}
|
|
337
352
|
|
|
@@ -345,23 +360,20 @@ class Valid {
|
|
|
345
360
|
* met (optional)
|
|
346
361
|
*/
|
|
347
362
|
static assert(condition, message, arg = null) {
|
|
348
|
-
if(!Data.isType(condition, "boolean"))
|
|
349
|
-
throw
|
|
350
|
-
}
|
|
363
|
+
if(!Data.isType(condition, "boolean"))
|
|
364
|
+
throw this._Sass.new(`Condition must be a boolean, got ${condition}`)
|
|
351
365
|
|
|
352
|
-
if(!Data.isType(message, "string"))
|
|
353
|
-
throw
|
|
354
|
-
}
|
|
366
|
+
if(!Data.isType(message, "string"))
|
|
367
|
+
throw this._Sass.new(`Message must be a string, got ${message}`)
|
|
355
368
|
|
|
356
|
-
if(!(arg === null || arg === undefined || typeof arg === "number"))
|
|
357
|
-
throw
|
|
358
|
-
}
|
|
369
|
+
if(!(arg === null || arg === undefined || typeof arg === "number"))
|
|
370
|
+
throw this._Sass.new(`Arg must be a number, got ${arg}`)
|
|
359
371
|
|
|
360
372
|
if(!condition)
|
|
361
|
-
throw
|
|
373
|
+
throw this._Sass.new(`${message}${arg ? `: ${arg}` : ""}`)
|
|
362
374
|
}
|
|
363
375
|
|
|
364
|
-
static #restrictedProto = ["__proto__", "constructor", "prototype"]
|
|
376
|
+
static #restrictedProto = Object.freeze(["__proto__", "constructor", "prototype"])
|
|
365
377
|
|
|
366
378
|
/**
|
|
367
379
|
* Protects against prototype pollution by checking keys for dangerous property names.
|
|
@@ -371,11 +383,13 @@ class Valid {
|
|
|
371
383
|
* @throws {Sass} If any key matches restricted prototype properties (__proto__, constructor, prototype)
|
|
372
384
|
*/
|
|
373
385
|
static prototypePollutionProtection(keys) {
|
|
374
|
-
|
|
386
|
+
this.type(keys, "String[]");
|
|
375
387
|
|
|
376
|
-
const oopsIDidItAgain = Collection.intersection(
|
|
388
|
+
const oopsIDidItAgain = Collection.intersection(
|
|
389
|
+
Valid.#restrictedProto, keys
|
|
390
|
+
);
|
|
377
391
|
|
|
378
|
-
|
|
392
|
+
this.assert(
|
|
379
393
|
oopsIDidItAgain.length === 0,
|
|
380
394
|
`We don't pee in your pool, don't pollute ours with your ${String(oopsIDidItAgain)}`
|
|
381
395
|
);
|
|
@@ -761,7 +775,7 @@ class TypeSpec {
|
|
|
761
775
|
// Handle non-array values
|
|
762
776
|
if(!isArray && !allowedArray) {
|
|
763
777
|
if(valueType === allowedType)
|
|
764
|
-
return allowEmpty || !empty
|
|
778
|
+
return Data.isBaseType(value, allowedType) && (allowEmpty || !empty)
|
|
765
779
|
|
|
766
780
|
if(valueType === "Null" || valueType === "Undefined")
|
|
767
781
|
return false
|
package/vendor/toolkit.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// @gesslar/toolkit v5.0
|
|
1
|
+
// @gesslar/toolkit v5.2.0 - UMD bundle
|
|
2
2
|
(function (global, factory) {
|
|
3
3
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
4
4
|
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
|
@@ -323,21 +323,36 @@
|
|
|
323
323
|
*/
|
|
324
324
|
|
|
325
325
|
|
|
326
|
+
/**
|
|
327
|
+
* Options for type validation methods.
|
|
328
|
+
*
|
|
329
|
+
* @typedef {object} TypeValidationOptions
|
|
330
|
+
* @property {boolean} [allowEmpty=true] - Whether empty values are allowed
|
|
331
|
+
*/
|
|
332
|
+
|
|
326
333
|
/**
|
|
327
334
|
* Validation utility class providing type checking and assertion methods.
|
|
328
335
|
*/
|
|
329
336
|
class Valid {
|
|
337
|
+
/** @type {typeof Sass} */
|
|
338
|
+
static _Sass = Sass
|
|
339
|
+
|
|
330
340
|
/**
|
|
331
341
|
* Validates a value against a type. Uses Data.isType.
|
|
332
342
|
*
|
|
333
343
|
* @param {unknown} value - The value to validate
|
|
334
344
|
* @param {string} type - The expected type in the form of "object", "object[]", "object|object[]"
|
|
335
|
-
* @param {
|
|
345
|
+
* @param {TypeValidationOptions} [options] - Additional options for validation.
|
|
336
346
|
*/
|
|
337
347
|
static type(value, type, options) {
|
|
338
|
-
|
|
348
|
+
const expected = [type];
|
|
349
|
+
|
|
350
|
+
if(options?.allowEmpty !== true)
|
|
351
|
+
expected.push("[no empty values]");
|
|
352
|
+
|
|
353
|
+
this.assert(
|
|
339
354
|
Data.isType(value, type, options),
|
|
340
|
-
`Invalid type. Expected ${
|
|
355
|
+
`Invalid type. Expected ${expected.join(" ")}, got ${Data.typeOf(value)}`
|
|
341
356
|
);
|
|
342
357
|
}
|
|
343
358
|
|
|
@@ -351,23 +366,20 @@
|
|
|
351
366
|
* met (optional)
|
|
352
367
|
*/
|
|
353
368
|
static assert(condition, message, arg = null) {
|
|
354
|
-
if(!Data.isType(condition, "boolean"))
|
|
355
|
-
throw
|
|
356
|
-
}
|
|
369
|
+
if(!Data.isType(condition, "boolean"))
|
|
370
|
+
throw this._Sass.new(`Condition must be a boolean, got ${condition}`)
|
|
357
371
|
|
|
358
|
-
if(!Data.isType(message, "string"))
|
|
359
|
-
throw
|
|
360
|
-
}
|
|
372
|
+
if(!Data.isType(message, "string"))
|
|
373
|
+
throw this._Sass.new(`Message must be a string, got ${message}`)
|
|
361
374
|
|
|
362
|
-
if(!(arg === null || arg === undefined || typeof arg === "number"))
|
|
363
|
-
throw
|
|
364
|
-
}
|
|
375
|
+
if(!(arg === null || arg === undefined || typeof arg === "number"))
|
|
376
|
+
throw this._Sass.new(`Arg must be a number, got ${arg}`)
|
|
365
377
|
|
|
366
378
|
if(!condition)
|
|
367
|
-
throw
|
|
379
|
+
throw this._Sass.new(`${message}${arg ? `: ${arg}` : ""}`)
|
|
368
380
|
}
|
|
369
381
|
|
|
370
|
-
static #restrictedProto = ["__proto__", "constructor", "prototype"]
|
|
382
|
+
static #restrictedProto = Object.freeze(["__proto__", "constructor", "prototype"])
|
|
371
383
|
|
|
372
384
|
/**
|
|
373
385
|
* Protects against prototype pollution by checking keys for dangerous property names.
|
|
@@ -377,11 +389,13 @@
|
|
|
377
389
|
* @throws {Sass} If any key matches restricted prototype properties (__proto__, constructor, prototype)
|
|
378
390
|
*/
|
|
379
391
|
static prototypePollutionProtection(keys) {
|
|
380
|
-
|
|
392
|
+
this.type(keys, "String[]");
|
|
381
393
|
|
|
382
|
-
const oopsIDidItAgain = Collection.intersection(
|
|
394
|
+
const oopsIDidItAgain = Collection.intersection(
|
|
395
|
+
Valid.#restrictedProto, keys
|
|
396
|
+
);
|
|
383
397
|
|
|
384
|
-
|
|
398
|
+
this.assert(
|
|
385
399
|
oopsIDidItAgain.length === 0,
|
|
386
400
|
`We don't pee in your pool, don't pollute ours with your ${String(oopsIDidItAgain)}`
|
|
387
401
|
);
|
|
@@ -767,7 +781,7 @@
|
|
|
767
781
|
// Handle non-array values
|
|
768
782
|
if(!isArray && !allowedArray) {
|
|
769
783
|
if(valueType === allowedType)
|
|
770
|
-
return allowEmpty || !empty
|
|
784
|
+
return Data.isBaseType(value, allowedType) && (allowEmpty || !empty)
|
|
771
785
|
|
|
772
786
|
if(valueType === "Null" || valueType === "Undefined")
|
|
773
787
|
return false
|