@gesslar/toolkit 1.5.0 → 1.8.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/package.json +5 -5
- package/src/browser/lib/Data.js +0 -7
- package/src/browser/lib/Disposer.js +1 -24
- package/src/browser/lib/Util.js +1 -11
- package/src/index.js +1 -0
- package/src/lib/DirectoryObject.js +25 -0
- package/src/lib/Notify.js +87 -0
- package/src/types/browser/lib/Data.d.ts.map +1 -1
- package/src/types/browser/lib/Disposer.d.ts +0 -6
- package/src/types/browser/lib/Disposer.d.ts.map +1 -1
- package/src/types/browser/lib/Util.d.ts +0 -1
- package/src/types/browser/lib/Util.d.ts.map +1 -1
- package/src/types/index.d.ts +1 -0
- package/src/types/lib/DirectoryObject.d.ts +14 -0
- package/src/types/lib/DirectoryObject.d.ts.map +1 -1
- package/src/types/lib/Notify.d.ts +55 -0
- package/src/types/lib/Notify.d.ts.map +1 -0
- package/src/browser/lib/Hook.js +0 -82
- package/src/browser/lib/test.js +0 -25
- package/src/browser/lib/test2.js +0 -46
- package/src/types/Cache.d.ts +0 -30
- package/src/types/Collection.d.ts +0 -321
- package/src/types/Contract.d.ts +0 -162
- package/src/types/Data.d.ts +0 -175
- package/src/types/DirectoryObject.d.ts +0 -135
- package/src/types/FS.d.ts +0 -40
- package/src/types/FileObject.d.ts +0 -388
- package/src/types/Glog.d.ts +0 -345
- package/src/types/Sass.d.ts +0 -24
- package/src/types/Schemer.d.ts +0 -179
- package/src/types/Tantrum.d.ts +0 -81
- package/src/types/Term.d.ts +0 -16
- package/src/types/Terms.d.ts +0 -145
- package/src/types/Type.d.ts +0 -26
- package/src/types/Util.d.ts +0 -275
- package/src/types/Valid.d.ts +0 -13
- package/src/types/browser/lib/Disposable.d.ts +0 -35
- package/src/types/browser/lib/Disposable.d.ts.map +0 -10
- package/src/types/browser/lib/Hook.d.ts +0 -11
- package/src/types/browser/lib/Hook.d.ts.map +0 -1
- package/src/types/browser/lib/test.d.ts +0 -2
- package/src/types/browser/lib/test.d.ts.map +0 -1
- package/src/types/browser/lib/test2.d.ts +0 -2
- package/src/types/browser/lib/test2.d.ts.map +0 -1
- package/src/types/lib/Chide.d.ts +0 -37
- package/src/types/lib/Chide.d.ts.map +0 -1
- package/src/types/lib/Collection.d.ts +0 -246
- package/src/types/lib/Collection.d.ts.map +0 -1
- package/src/types/lib/Data.d.ts +0 -206
- package/src/types/lib/Data.d.ts.map +0 -1
- package/src/types/lib/Disposable.d.ts +0 -33
- package/src/types/lib/Disposable.d.ts.map +0 -10
- package/src/types/lib/TypeSpec.d.ts +0 -92
- package/src/types/lib/TypeSpec.d.ts.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gesslar/toolkit",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"description": "Get in, bitches, we're going toolkitting.",
|
|
5
5
|
"main": "./src/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"node": ">=20"
|
|
32
32
|
},
|
|
33
33
|
"scripts": {
|
|
34
|
-
"types:build": "tsc -p tsconfig.types.json",
|
|
34
|
+
"types:build": "node -e \"require('fs').rmSync('src/types',{recursive:true,force:true});\" && tsc -p tsconfig.types.json",
|
|
35
35
|
"prepublishOnly": "npm run types:build",
|
|
36
36
|
"lint": "eslint src/",
|
|
37
37
|
"lint:fix": "eslint src/ --fix",
|
|
@@ -66,14 +66,14 @@
|
|
|
66
66
|
"ajv": "^8.17.1",
|
|
67
67
|
"globby": "^16.0.0",
|
|
68
68
|
"json5": "^2.2.3",
|
|
69
|
-
"yaml": "^2.8.
|
|
69
|
+
"yaml": "^2.8.2"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
72
|
"@gesslar/uglier": "^0.0.5",
|
|
73
73
|
"@stylistic/eslint-plugin": "^5.6.1",
|
|
74
74
|
"@types/node": "^24.10.1",
|
|
75
|
-
"@typescript-eslint/eslint-plugin": "^8.48.
|
|
76
|
-
"@typescript-eslint/parser": "^8.48.
|
|
75
|
+
"@typescript-eslint/eslint-plugin": "^8.48.1",
|
|
76
|
+
"@typescript-eslint/parser": "^8.48.1",
|
|
77
77
|
"eslint": "^9.39.1",
|
|
78
78
|
"eslint-plugin-jsdoc": "^61.4.1",
|
|
79
79
|
"globals": "^16.5.0"
|
package/src/browser/lib/Data.js
CHANGED
|
@@ -27,7 +27,6 @@ export default class Data {
|
|
|
27
27
|
"Undefined",
|
|
28
28
|
|
|
29
29
|
// Object Categories from typeof
|
|
30
|
-
"AsyncFunction",
|
|
31
30
|
"Function",
|
|
32
31
|
"Object",
|
|
33
32
|
])
|
|
@@ -41,7 +40,6 @@ export default class Data {
|
|
|
41
40
|
static constructors = Object.freeze([
|
|
42
41
|
// Object Constructors
|
|
43
42
|
"Array",
|
|
44
|
-
"AsyncFunction",
|
|
45
43
|
"Date",
|
|
46
44
|
"Error",
|
|
47
45
|
"Float32Array",
|
|
@@ -192,11 +190,6 @@ export default class Data {
|
|
|
192
190
|
if(type === "object")
|
|
193
191
|
return value.constructor.name
|
|
194
192
|
|
|
195
|
-
if(type === "function") {
|
|
196
|
-
if(value.constructor.name === "AsyncFunction")
|
|
197
|
-
return "AsyncFunction"
|
|
198
|
-
}
|
|
199
|
-
|
|
200
193
|
const [first, ...rest] = Array.from(type)
|
|
201
194
|
|
|
202
195
|
return `${first?.toLocaleUpperCase() ?? ""}${rest.join("")}`
|
|
@@ -6,8 +6,6 @@ import Valid from "./Valid.js"
|
|
|
6
6
|
*/
|
|
7
7
|
export class Disposer {
|
|
8
8
|
#disposers = []
|
|
9
|
-
#disposed = false
|
|
10
|
-
#noop = () => {}
|
|
11
9
|
|
|
12
10
|
/**
|
|
13
11
|
* Registers a disposer callback to be executed when disposed.
|
|
@@ -21,13 +19,6 @@ export class Disposer {
|
|
|
21
19
|
*/
|
|
22
20
|
register(...disposers) {
|
|
23
21
|
const normalized = this.#normalizeDisposers(disposers)
|
|
24
|
-
|
|
25
|
-
if(this.#disposed) {
|
|
26
|
-
return normalized.length === 1
|
|
27
|
-
? this.#noop
|
|
28
|
-
: normalized.map(() => this.#noop)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
22
|
const unregisters = normalized.map(
|
|
32
23
|
disposer => this.#registerDisposer(disposer)
|
|
33
24
|
)
|
|
@@ -36,7 +27,7 @@ export class Disposer {
|
|
|
36
27
|
}
|
|
37
28
|
|
|
38
29
|
#registerDisposer(disposer) {
|
|
39
|
-
if(
|
|
30
|
+
if(typeof disposer !== "function")
|
|
40
31
|
return () => {}
|
|
41
32
|
|
|
42
33
|
this.#disposers.push(disposer)
|
|
@@ -50,11 +41,6 @@ export class Disposer {
|
|
|
50
41
|
* @returns {void}
|
|
51
42
|
*/
|
|
52
43
|
dispose() {
|
|
53
|
-
if(this.#disposed)
|
|
54
|
-
return
|
|
55
|
-
|
|
56
|
-
this.#disposed = true
|
|
57
|
-
|
|
58
44
|
const errors = []
|
|
59
45
|
this.#disposers.toReversed().forEach(disposer => {
|
|
60
46
|
try {
|
|
@@ -81,15 +67,6 @@ export class Disposer {
|
|
|
81
67
|
return normalized
|
|
82
68
|
}
|
|
83
69
|
|
|
84
|
-
/**
|
|
85
|
-
* Whether disposal has run.
|
|
86
|
-
*
|
|
87
|
-
* @returns {boolean} True when dispose() has already been called.
|
|
88
|
-
*/
|
|
89
|
-
get disposed() {
|
|
90
|
-
return this.#disposed
|
|
91
|
-
}
|
|
92
|
-
|
|
93
70
|
/**
|
|
94
71
|
* Read-only list of registered disposers.
|
|
95
72
|
*
|
package/src/browser/lib/Util.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import Collection from "./Collection.js"
|
|
2
|
-
import Data from "./Data.js"
|
|
3
1
|
import Sass from "./Sass.js"
|
|
4
2
|
import Valid from "./Valid.js"
|
|
3
|
+
import Collection from "./Collection.js"
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
6
|
* Utility class providing common helper functions for string manipulation,
|
|
@@ -255,13 +254,4 @@ export default class Util {
|
|
|
255
254
|
.join("")
|
|
256
255
|
, flags?.join(""))
|
|
257
256
|
}
|
|
258
|
-
|
|
259
|
-
static disasyncify(func) {
|
|
260
|
-
Valid.type(func, "Function|AsyncFunction")
|
|
261
|
-
|
|
262
|
-
if(Data.isType(func, "Function"))
|
|
263
|
-
return func
|
|
264
|
-
|
|
265
|
-
return (async(...arg) => await func(...arg))()
|
|
266
|
-
}
|
|
267
257
|
}
|
package/src/index.js
CHANGED
|
@@ -18,6 +18,7 @@ export {default as DirectoryObject} from "./lib/DirectoryObject.js"
|
|
|
18
18
|
export {default as FileObject} from "./lib/FileObject.js"
|
|
19
19
|
export {default as FS} from "./lib/FS.js"
|
|
20
20
|
export {default as Glog} from "./lib/Glog.js"
|
|
21
|
+
export {default as Notify} from "./lib/Notify.js"
|
|
21
22
|
export {default as Schemer} from "./lib/Schemer.js"
|
|
22
23
|
export {default as Term} from "./lib/Term.js"
|
|
23
24
|
export {default as Terms} from "./lib/Terms.js"
|
|
@@ -355,4 +355,29 @@ export default class DirectoryObject extends FS {
|
|
|
355
355
|
|
|
356
356
|
return await fs.rmdir(this.path)
|
|
357
357
|
}
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* Checks if a file exists within this directory.
|
|
361
|
+
*
|
|
362
|
+
* @param {string} filename - The filename to check for
|
|
363
|
+
* @returns {Promise<boolean>} True if the file exists, false otherwise
|
|
364
|
+
*/
|
|
365
|
+
async hasFile(filename) {
|
|
366
|
+
const file = new FileObject(filename, this)
|
|
367
|
+
|
|
368
|
+
return await file.exists
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* Checks if a subdirectory exists within this directory.
|
|
373
|
+
*
|
|
374
|
+
* @param {string} dirname - The directory name to check for
|
|
375
|
+
* @returns {Promise<boolean>} True if the directory exists, false otherwise
|
|
376
|
+
*/
|
|
377
|
+
async hasDirectory(dirname) {
|
|
378
|
+
const resolved = FS.resolvePath(this.path, dirname)
|
|
379
|
+
const directory = new DirectoryObject(resolved)
|
|
380
|
+
|
|
381
|
+
return await directory.exists
|
|
382
|
+
}
|
|
358
383
|
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Notify.js
|
|
3
|
+
* @description Node.js event notification system using EventEmitter.
|
|
4
|
+
* Provides a centralized API for event emission and handling.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import {EventEmitter} from "node:events"
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @typedef {object} NotifyEventOptions
|
|
11
|
+
* @property {boolean} [once] - Whether the listener should be invoked only once.
|
|
12
|
+
* @property {AbortSignal} [signal] - An AbortSignal to remove the listener.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Notify class provides a thin wrapper around EventEmitter for centralized
|
|
17
|
+
* event handling in Node.js applications. Mirrors the browser Notify API.
|
|
18
|
+
*/
|
|
19
|
+
export default new class Notify {
|
|
20
|
+
/** @type {string} Display name for debugging. */
|
|
21
|
+
name = "Notify"
|
|
22
|
+
|
|
23
|
+
/** @type {EventEmitter} Internal event emitter */
|
|
24
|
+
#emitter = new EventEmitter()
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Emits an event without expecting a return value.
|
|
28
|
+
*
|
|
29
|
+
* @param {string} type - Event name to dispatch.
|
|
30
|
+
* @param {unknown} [payload] - Data to send with the event.
|
|
31
|
+
* @returns {void}
|
|
32
|
+
*/
|
|
33
|
+
emit(type, payload=undefined) {
|
|
34
|
+
this.#emitter.emit(type, payload)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Emits an event and returns the payload for simple request/response flows.
|
|
39
|
+
* Listeners can mutate the payload object to provide responses.
|
|
40
|
+
*
|
|
41
|
+
* @param {string} type - Event name to dispatch.
|
|
42
|
+
* @param {unknown} [payload] - Data to send with the event (will be returned).
|
|
43
|
+
* @returns {unknown} The payload after listeners have processed it.
|
|
44
|
+
*/
|
|
45
|
+
request(type, payload={}) {
|
|
46
|
+
this.#emitter.emit(type, payload)
|
|
47
|
+
|
|
48
|
+
return payload
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Registers a listener for the given event type.
|
|
53
|
+
*
|
|
54
|
+
* @param {string} type - Event name to listen for.
|
|
55
|
+
* @param {(payload: unknown) => void} handler - Listener callback.
|
|
56
|
+
* @param {EventEmitter} [emitter] - The EventEmitter to attach to. Default is internal emitter.
|
|
57
|
+
* @param {NotifyEventOptions} [options] - Options for the listener.
|
|
58
|
+
* @returns {() => void} Dispose function to unregister the handler.
|
|
59
|
+
*/
|
|
60
|
+
on(type, handler, emitter=this.#emitter, options=undefined) {
|
|
61
|
+
if(!(typeof type === "string" && type))
|
|
62
|
+
throw new Error("No event 'type' specified to listen for.")
|
|
63
|
+
|
|
64
|
+
if(typeof handler !== "function")
|
|
65
|
+
throw new Error("No handler function specified.")
|
|
66
|
+
|
|
67
|
+
if(options?.once) {
|
|
68
|
+
emitter.once(type, handler, options)
|
|
69
|
+
} else {
|
|
70
|
+
emitter.on(type, handler, options)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return () => this.off(type, handler, emitter)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Removes a previously registered listener for the given event type.
|
|
78
|
+
*
|
|
79
|
+
* @param {string} type - Event name to remove.
|
|
80
|
+
* @param {(payload: unknown) => void} handler - Listener callback to detach.
|
|
81
|
+
* @param {EventEmitter} [emitter] - The EventEmitter from which to remove. Default is internal emitter.
|
|
82
|
+
* @returns {void}
|
|
83
|
+
*/
|
|
84
|
+
off(type, handler, emitter=this.#emitter) {
|
|
85
|
+
emitter.off(type, handler)
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Data.d.ts","sourceRoot":"","sources":["../../../browser/lib/Data.js"],"names":[],"mappings":"AAUA;IACA;;;;;OAKG;IACD,mBAFQ,KAAK,CAAC,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"Data.d.ts","sourceRoot":"","sources":["../../../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,CAE6C;IAEpE;;;;;;OAMG;IACH,4BAJW,MAAM,UACN,MAAM,GACJ,MAAM,CAIlB;IAED;;;;;;OAMG;IACH,6BAJW,MAAM,WACN,MAAM,GACJ,MAAM,CAIlB;IAED;;;;;;;OAOG;IACH,2BAJW,MAAM,WACN,MAAM,GACJ,KAAK,CAAC,MAAM,CAAC,CAIzB;IAED;;;;;;;OAOG;IACH,qBALW,OAAO,QACP,MAAM,GAAC,QAAQ,YACf,MAAM,GACJ,OAAO,CAQnB;IAED;;;;;OAKG;IACH,yBAHW,MAAM,GACJ,OAAO,CASnB;IAED;;;;;;;;OAQG;IACH,yBAJW,OAAO,QACP,MAAM,GACJ,OAAO,CAwBnB;IAED;;;;;OAKG;IACH,qBAHW,OAAO,GACL,MAAM,CAclB;IAED;;;;;OAKG;IACH,wBAHW,OAAO,GACL,OAAO,CAInB;IAED;;;;;;;;OAQG;IACH,sBALW,OAAO,oBACP,OAAO,GAEL,OAAO,CA2BnB;IAED;;;;;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;qBA5aoB,eAAe"}
|
|
@@ -20,12 +20,6 @@ export class Disposer {
|
|
|
20
20
|
* @returns {void}
|
|
21
21
|
*/
|
|
22
22
|
dispose(): void;
|
|
23
|
-
/**
|
|
24
|
-
* Whether disposal has run.
|
|
25
|
-
*
|
|
26
|
-
* @returns {boolean} True when dispose() has already been called.
|
|
27
|
-
*/
|
|
28
|
-
get disposed(): boolean;
|
|
29
23
|
/**
|
|
30
24
|
* Read-only list of registered disposers.
|
|
31
25
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Disposer.d.ts","sourceRoot":"","sources":["../../../browser/lib/Disposer.js"],"names":[],"mappings":"AAEA;;;GAGG;AACH;
|
|
1
|
+
{"version":3,"file":"Disposer.d.ts","sourceRoot":"","sources":["../../../browser/lib/Disposer.js"],"names":[],"mappings":"AAEA;;;GAGG;AACH;IAGE;;;;;;;;;OASG;IACH,uBAHW,CAAG,CAAC,MAAM,IAAI,CAAC,GAAC,KAAK,CAAC,MAAM,IAAI,CAAC,GAAA,GAC/B,CAAC,MAAM,IAAI,CAAC,GAAC,KAAK,CAAC,MAAM,IAAI,CAAC,CAS1C;IAWD;;;;OAIG;IACH,WAFa,IAAI,CAehB;IAcD;;;;OAIG;IACH,iBAFa,KAAK,CAAC,MAAM,IAAI,CAAC,CAI7B;;CAQF"}
|
|
@@ -125,6 +125,5 @@ export default class Util {
|
|
|
125
125
|
*/
|
|
126
126
|
static findClosestMatch(input: string, allowedValues: Array<string>, threshold?: number): string;
|
|
127
127
|
static regexify(input: any, trim?: boolean, flags?: any[]): RegExp;
|
|
128
|
-
static disasyncify(func: any): any;
|
|
129
128
|
}
|
|
130
129
|
//# sourceMappingURL=Util.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Util.d.ts","sourceRoot":"","sources":["../../../browser/lib/Util.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Util.d.ts","sourceRoot":"","sources":["../../../browser/lib/Util.js"],"names":[],"mappings":"AAIA;;;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,0BAHW,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,GACrB,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAInC;IAED;;;;;;OAMG;IACH,2BAHW,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,GACrB,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAIlC;IAED;;;;;OAKG;IACH,2BAHW,KAAK,CAAC,MAAM,CAAC,GACX,OAAO,CAInB;IAED;;;;;OAKG;IACH,kCAHW,KAAK,CAAC,MAAM,CAAC,GACX,KAAK,CAAC,MAAM,CAAC,CAIzB;IAED;;;;;OAKG;IACH,iCAHW,KAAK,CAAC,MAAM,CAAC,GACX,KAAK,CAAC,OAAO,CAAC,CAI1B;IAED;;;;;;OAMG;IACH,gCAJW,MAAM,YACN,KAAK,CAAC,MAAM,CAAC,QAKvB;IAED;;;;;OAKG;IACH,mCAHW,KAAK,CAAC,MAAM,CAAC,GACX,KAAK,CAAC,MAAM,CAAC,CAIzB;IAED;;;;;OAKG;IACH,+BAHW,KAAK,CAAC,MAAM,CAAC,GACX,KAAK,CAAC,OAAO,CAAC,CAI1B;IAED;;;;;;OAMG;IACH,sBAHW,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,GACrB,OAAO,CAAC,OAAO,CAAC,CAI5B;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"}
|
package/src/types/index.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export { default as DirectoryObject } from "./lib/DirectoryObject.js";
|
|
|
11
11
|
export { default as FileObject } from "./lib/FileObject.js";
|
|
12
12
|
export { default as FS } from "./lib/FS.js";
|
|
13
13
|
export { default as Glog } from "./lib/Glog.js";
|
|
14
|
+
export { default as Notify } from "./lib/Notify.js";
|
|
14
15
|
export { default as Schemer } from "./lib/Schemer.js";
|
|
15
16
|
export { default as Term } from "./lib/Term.js";
|
|
16
17
|
export { default as Terms } from "./lib/Terms.js";
|
|
@@ -150,6 +150,20 @@ export default class DirectoryObject extends FS {
|
|
|
150
150
|
* await dir.delete() // Only works if directory is empty
|
|
151
151
|
*/
|
|
152
152
|
delete(): Promise<void>;
|
|
153
|
+
/**
|
|
154
|
+
* Checks if a file exists within this directory.
|
|
155
|
+
*
|
|
156
|
+
* @param {string} filename - The filename to check for
|
|
157
|
+
* @returns {Promise<boolean>} True if the file exists, false otherwise
|
|
158
|
+
*/
|
|
159
|
+
hasFile(filename: string): Promise<boolean>;
|
|
160
|
+
/**
|
|
161
|
+
* Checks if a subdirectory exists within this directory.
|
|
162
|
+
*
|
|
163
|
+
* @param {string} dirname - The directory name to check for
|
|
164
|
+
* @returns {Promise<boolean>} True if the directory exists, false otherwise
|
|
165
|
+
*/
|
|
166
|
+
hasDirectory(dirname: string): Promise<boolean>;
|
|
153
167
|
/**
|
|
154
168
|
* Custom inspect method for Node.js console.
|
|
155
169
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DirectoryObject.d.ts","sourceRoot":"","sources":["../../lib/DirectoryObject.js"],"names":[],"mappings":"AAeA;;;;;;;;;;;;;GAaG;AACH;IA0BE;;;;OAIG;IACH,uBAFW,MAAM,EAsBhB;IAWD;;;;OAIG;IACH,UAFa,MAAM,CAalB;IAWD;;;;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;;;;OAIG;IACH,cAFa,OAAO,CAInB;IAED;;;;OAIG;IACH,mBAFa,OAAO,CAInB;IAiBD;;;;OAIG;IACH,QAFa,OAAO,CAAC;QAAC,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;QAAC,WAAW,EAAE,KAAK,CAAC,eAAe,CAAC,CAAA;KAAC,CAAC,CAcpF;IAED;;;;;;;;;;;;OAYG;IACH,uBARW,MAAM,GACJ,OAAO,CAAC,IAAI,CAAC,CAqBzB;IA8BD;;;;;;;;;;;;;;;OAeG;IACH,cAZa,MAAM,CAclB;IAED;;;;;;;;;;;;;;OAcG;IACH,UARa,OAAO,CAAC,IAAI,CAAC,CAkBzB;
|
|
1
|
+
{"version":3,"file":"DirectoryObject.d.ts","sourceRoot":"","sources":["../../lib/DirectoryObject.js"],"names":[],"mappings":"AAeA;;;;;;;;;;;;;GAaG;AACH;IA0BE;;;;OAIG;IACH,uBAFW,MAAM,EAsBhB;IAWD;;;;OAIG;IACH,UAFa,MAAM,CAalB;IAWD;;;;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;;;;OAIG;IACH,cAFa,OAAO,CAInB;IAED;;;;OAIG;IACH,mBAFa,OAAO,CAInB;IAiBD;;;;OAIG;IACH,QAFa,OAAO,CAAC;QAAC,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;QAAC,WAAW,EAAE,KAAK,CAAC,eAAe,CAAC,CAAA;KAAC,CAAC,CAcpF;IAED;;;;;;;;;;;;OAYG;IACH,uBARW,MAAM,GACJ,OAAO,CAAC,IAAI,CAAC,CAqBzB;IA8BD;;;;;;;;;;;;;;;OAeG;IACH,cAZa,MAAM,CAclB;IAED;;;;;;;;;;;;;;OAcG;IACH,UARa,OAAO,CAAC,IAAI,CAAC,CAkBzB;IAED;;;;;OAKG;IACH,kBAHW,MAAM,GACJ,OAAO,CAAC,OAAO,CAAC,CAM5B;IAED;;;;;OAKG;IACH,sBAHW,MAAM,GACJ,OAAO,CAAC,OAAO,CAAC,CAO5B;IAhRD;;;;OAIG;IACH,yBAFa,MAAM,CAIlB;;CA0QF;eAnXc,SAAS;oBAFN,UAAU;uBAGL,iBAAiB;iBAJvB,WAAW"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
/** @type {string} Display name for debugging. */
|
|
3
|
+
name: string;
|
|
4
|
+
/** @type {EventEmitter} Internal event emitter */
|
|
5
|
+
"__#private@#emitter": EventEmitter;
|
|
6
|
+
/**
|
|
7
|
+
* Emits an event without expecting a return value.
|
|
8
|
+
*
|
|
9
|
+
* @param {string} type - Event name to dispatch.
|
|
10
|
+
* @param {unknown} [payload] - Data to send with the event.
|
|
11
|
+
* @returns {void}
|
|
12
|
+
*/
|
|
13
|
+
emit(type: string, payload?: unknown): void;
|
|
14
|
+
/**
|
|
15
|
+
* Emits an event and returns the payload for simple request/response flows.
|
|
16
|
+
* Listeners can mutate the payload object to provide responses.
|
|
17
|
+
*
|
|
18
|
+
* @param {string} type - Event name to dispatch.
|
|
19
|
+
* @param {unknown} [payload] - Data to send with the event (will be returned).
|
|
20
|
+
* @returns {unknown} The payload after listeners have processed it.
|
|
21
|
+
*/
|
|
22
|
+
request(type: string, payload?: unknown): unknown;
|
|
23
|
+
/**
|
|
24
|
+
* Registers a listener for the given event type.
|
|
25
|
+
*
|
|
26
|
+
* @param {string} type - Event name to listen for.
|
|
27
|
+
* @param {(payload: unknown) => void} handler - Listener callback.
|
|
28
|
+
* @param {EventEmitter} [emitter] - The EventEmitter to attach to. Default is internal emitter.
|
|
29
|
+
* @param {NotifyEventOptions} [options] - Options for the listener.
|
|
30
|
+
* @returns {() => void} Dispose function to unregister the handler.
|
|
31
|
+
*/
|
|
32
|
+
on(type: string, handler: (payload: unknown) => void, emitter?: EventEmitter, options?: NotifyEventOptions): () => void;
|
|
33
|
+
/**
|
|
34
|
+
* Removes a previously registered listener for the given event type.
|
|
35
|
+
*
|
|
36
|
+
* @param {string} type - Event name to remove.
|
|
37
|
+
* @param {(payload: unknown) => void} handler - Listener callback to detach.
|
|
38
|
+
* @param {EventEmitter} [emitter] - The EventEmitter from which to remove. Default is internal emitter.
|
|
39
|
+
* @returns {void}
|
|
40
|
+
*/
|
|
41
|
+
off(type: string, handler: (payload: unknown) => void, emitter?: EventEmitter): void;
|
|
42
|
+
};
|
|
43
|
+
export default _default;
|
|
44
|
+
export type NotifyEventOptions = {
|
|
45
|
+
/**
|
|
46
|
+
* - Whether the listener should be invoked only once.
|
|
47
|
+
*/
|
|
48
|
+
once?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* - An AbortSignal to remove the listener.
|
|
51
|
+
*/
|
|
52
|
+
signal?: AbortSignal;
|
|
53
|
+
};
|
|
54
|
+
import { EventEmitter } from "node:events";
|
|
55
|
+
//# sourceMappingURL=Notify.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Notify.d.ts","sourceRoot":"","sources":["../../lib/Notify.js"],"names":[],"mappings":";IAmBE,iDAAiD;UAAtC,MAAM;IAGjB,kDAAkD;2BAAvC,YAAY;IAGvB;;;;;;OAMG;eAHQ,MAAM,YACN,OAAO,GACL,IAAI;IAMjB;;;;;;;OAOG;kBAHQ,MAAM,YACN,OAAO,GACL,OAAO;IAQpB;;;;;;;;OAQG;aALQ,MAAM,WACN,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,YAC1B,YAAY,YACZ,kBAAkB,GAChB,MAAM,IAAI;IAkBvB;;;;;;;OAOG;cAJQ,MAAM,WACN,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,YAC1B,YAAY,GACV,IAAI;;;;;;;WAvEL,OAAO;;;;aACP,WAAW;;6BALE,aAAa"}
|
package/src/browser/lib/Hook.js
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import Sass from "./Sass.js"
|
|
2
|
-
import Valid from "./Valid.js"
|
|
3
|
-
|
|
4
|
-
class PipeClass {
|
|
5
|
-
name = "Pipe"
|
|
6
|
-
|
|
7
|
-
#lastResult
|
|
8
|
-
#it = 0
|
|
9
|
-
|
|
10
|
-
constructor(func) {
|
|
11
|
-
Valid.type(func, "Function|AsyncFunction|Promise")
|
|
12
|
-
|
|
13
|
-
this.#processStart(func)
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
static source(func) {
|
|
17
|
-
return new this(func)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
async then(func) {
|
|
21
|
-
if(++this.it > 2)
|
|
22
|
-
throw new Error("hi")
|
|
23
|
-
|
|
24
|
-
console.log("then", this.#lastResult, "func", func)
|
|
25
|
-
|
|
26
|
-
this.#lastResult =
|
|
27
|
-
this.#lastResult.then(prev => this.#resolve(func, prev))
|
|
28
|
-
|
|
29
|
-
return this
|
|
30
|
-
/*
|
|
31
|
-
|
|
32
|
-
this.#processThen(func)
|
|
33
|
-
|
|
34
|
-
return this
|
|
35
|
-
*/
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
get value() {
|
|
39
|
-
return this.#processResult()
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
#processStart(func) {
|
|
43
|
-
console.log("start", func)
|
|
44
|
-
|
|
45
|
-
this.#lastResult = Promise.resolve(this.#resolve(func))
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
#processThen(func) {
|
|
49
|
-
if(++this.#it > 2)
|
|
50
|
-
throw new Error("hi")
|
|
51
|
-
|
|
52
|
-
this.#lastResult = this.#lastResult.then(prev => this.#resolve(func, prev))
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
#processResult() {
|
|
56
|
-
const result = this.#lastResult
|
|
57
|
-
this.#lastResult = undefined
|
|
58
|
-
|
|
59
|
-
return result
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
#resolve = (val, prev) => typeof val === "function" ? val(prev) : val
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export default new Proxy(PipeClass, {
|
|
66
|
-
apply(target, _, argumentsList) {
|
|
67
|
-
return target.source(...argumentsList)
|
|
68
|
-
},
|
|
69
|
-
|
|
70
|
-
construct(..._) {
|
|
71
|
-
throw new Sass("This class may not be instantiated in this manner.")
|
|
72
|
-
},
|
|
73
|
-
|
|
74
|
-
get(target, prop) {
|
|
75
|
-
// Hide 'source' method from public API
|
|
76
|
-
if(prop === "source") {
|
|
77
|
-
return undefined
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
return Reflect.get(target, prop)
|
|
81
|
-
}
|
|
82
|
-
})
|
package/src/browser/lib/test.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import {setTimeout as timeout} from "node:timers/promises"
|
|
2
|
-
import Pipe from "./Hook.js"
|
|
3
|
-
import Disposer from "./Disposer.js"
|
|
4
|
-
|
|
5
|
-
const step1 = () => 1
|
|
6
|
-
const step2 = num => num+1
|
|
7
|
-
const step3 = num => num+1
|
|
8
|
-
const step4 = async num => {
|
|
9
|
-
console.log("Waiting for",num,typeof num)
|
|
10
|
-
await timeout(5_000)
|
|
11
|
-
|
|
12
|
-
return num + 1
|
|
13
|
-
}
|
|
14
|
-
const step5 = num => num+1
|
|
15
|
-
const step6 = num => num+1
|
|
16
|
-
|
|
17
|
-
const result = await Pipe(step1)
|
|
18
|
-
.then(step2)
|
|
19
|
-
.then(step3)
|
|
20
|
-
.then(step4)
|
|
21
|
-
.then(step5)
|
|
22
|
-
.then(step6)
|
|
23
|
-
.result
|
|
24
|
-
|
|
25
|
-
console.log("result", result)
|
package/src/browser/lib/test2.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import {setTimeout as timeout} from "node:timers/promises"
|
|
2
|
-
|
|
3
|
-
const step1 = () => 1
|
|
4
|
-
const step2 = num => num+1
|
|
5
|
-
const step3 = num => num+1
|
|
6
|
-
const step4 = async num => {
|
|
7
|
-
console.log("Waiting for",num,typeof num)
|
|
8
|
-
await timeout(5_000)
|
|
9
|
-
|
|
10
|
-
return num + 1
|
|
11
|
-
}
|
|
12
|
-
const step5 = num => num+1
|
|
13
|
-
const step6 = num => num+1
|
|
14
|
-
|
|
15
|
-
function Pipe(initialPromise) {
|
|
16
|
-
console.log("start", initialPromise)
|
|
17
|
-
|
|
18
|
-
const resolve = (val, prev) =>
|
|
19
|
-
typeof val === "function" ? val(prev) : val
|
|
20
|
-
|
|
21
|
-
let chain = Promise.resolve(resolve(initialPromise))
|
|
22
|
-
|
|
23
|
-
return {
|
|
24
|
-
then(promiseOrFn) {
|
|
25
|
-
console.log("then", chain, "func", promiseOrFn)
|
|
26
|
-
|
|
27
|
-
chain = chain.then(prev => resolve(promiseOrFn, prev))
|
|
28
|
-
|
|
29
|
-
return this
|
|
30
|
-
},
|
|
31
|
-
|
|
32
|
-
get result() {
|
|
33
|
-
return chain
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const result = await Pipe(step1)
|
|
39
|
-
.then(step2)
|
|
40
|
-
.then(step3)
|
|
41
|
-
.then(step4)
|
|
42
|
-
.then(step5)
|
|
43
|
-
.then(step6)
|
|
44
|
-
.result
|
|
45
|
-
|
|
46
|
-
console.log("result", result)
|
package/src/types/Cache.d.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
// Implementation: ../lib/Cache.js
|
|
2
|
-
import FileObject from './FileObject.js'
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* File system cache for theme compilation data with automatic invalidation.
|
|
6
|
-
* Provides intelligent caching of parsed JSON5/YAML files with mtime-based
|
|
7
|
-
* cache invalidation to optimize parallel theme compilation performance.
|
|
8
|
-
*
|
|
9
|
-
* The cache eliminates redundant file reads and parsing when multiple themes
|
|
10
|
-
* import the same dependency files, while ensuring data freshness through
|
|
11
|
-
* modification time checking.
|
|
12
|
-
*/
|
|
13
|
-
declare class Cache {
|
|
14
|
-
/**
|
|
15
|
-
* Loads and caches parsed file data with automatic invalidation based on
|
|
16
|
-
* modification time.
|
|
17
|
-
*
|
|
18
|
-
* Implements a sophisticated caching strategy that checks file modification
|
|
19
|
-
* times to determine whether cached data is still valid, ensuring data
|
|
20
|
-
* freshness while optimizing performance for repeated file access during
|
|
21
|
-
* parallel theme compilation.
|
|
22
|
-
*
|
|
23
|
-
* @param fileObject - The file object to load and cache
|
|
24
|
-
* @returns The parsed file data (JSON5 or YAML)
|
|
25
|
-
* @throws If the file cannot be found or accessed
|
|
26
|
-
*/
|
|
27
|
-
loadCachedData(fileObject: FileObject): Promise<unknown>
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export default Cache
|