@gesslar/toolkit 1.0.3 → 1.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/package.json +1 -1
- package/src/browser/index.js +3 -0
- package/src/browser/lib/Disposable.js +73 -0
- package/src/browser/lib/HTML.js +137 -0
- package/src/browser/lib/Notify.js +89 -0
- package/src/browser/lib/vendor/dompurify.esm.js +1515 -0
- package/src/index.js +1 -0
- package/src/lib/Contract.js +2 -2
- package/src/types/browser/index.d.ts +3 -0
- package/src/types/browser/lib/Base.d.ts +45 -0
- package/src/types/browser/lib/Base.d.ts.map +1 -0
- package/src/types/browser/lib/Disposable.d.ts +33 -0
- package/src/types/browser/lib/Disposable.d.ts.map +1 -0
- package/src/types/browser/lib/HTML.d.ts +38 -0
- package/src/types/browser/lib/HTML.d.ts.map +1 -0
- package/src/types/browser/lib/Notify.d.ts +60 -0
- package/src/types/browser/lib/Notify.d.ts.map +1 -0
- package/src/types/browser/lib/vendor/dompurify.esm.d.ts +29 -0
- package/src/types/browser/lib/vendor/dompurify.esm.d.ts.map +1 -0
- package/src/types/index.d.ts +1 -0
- package/src/types/lib/Contract.d.ts +4 -4
- package/src/types/lib/Contract.d.ts.map +1 -1
- package/src/types/lib/Disposable.d.ts +33 -0
- package/src/types/lib/Disposable.d.ts.map +1 -0
package/src/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Browser-compatible utilities (pure JS)
|
|
2
2
|
export {default as Collection} from "./browser/lib/Collection.js"
|
|
3
3
|
export {default as Data} from "./browser/lib/Data.js"
|
|
4
|
+
export {default as Disposable} from "./browser/lib/Disposable.js"
|
|
4
5
|
export {default as Type} from "./browser/lib/TypeSpec.js"
|
|
5
6
|
export {default as Valid} from "./lib/Valid.js"
|
|
6
7
|
|
package/src/lib/Contract.js
CHANGED
|
@@ -230,7 +230,7 @@ export default class Contract {
|
|
|
230
230
|
/**
|
|
231
231
|
* Get the provider terms (if any)
|
|
232
232
|
*
|
|
233
|
-
* @returns {Terms|null} Provider terms
|
|
233
|
+
* @returns {import("./Terms.js").default|null} Provider terms
|
|
234
234
|
*/
|
|
235
235
|
get providerTerms() {
|
|
236
236
|
return this.#providerTerms
|
|
@@ -239,7 +239,7 @@ export default class Contract {
|
|
|
239
239
|
/**
|
|
240
240
|
* Get the consumer terms (if any)
|
|
241
241
|
*
|
|
242
|
-
* @returns {Terms|null} Consumer terms
|
|
242
|
+
* @returns {import("./Terms.js").default|null} Consumer terms
|
|
243
243
|
*/
|
|
244
244
|
get consumerTerms() {
|
|
245
245
|
return this.#consumerTerms
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
export { default as Collection } from "./lib/Collection.js";
|
|
2
2
|
export { default as Data } from "./lib/Data.js";
|
|
3
|
+
export { default as Disposable } from "./lib/Disposable.js";
|
|
4
|
+
export { default as HTML } from "./lib/HTML.js";
|
|
5
|
+
export { default as Notify } from "./lib/Notify.js";
|
|
3
6
|
export { default as Sass } from "./lib/Sass.js";
|
|
4
7
|
export { default as Tantrum } from "./lib/Tantrum.js";
|
|
5
8
|
export { default as Type } from "./lib/TypeSpec.js";
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base helper for UI classes that want centralized event lifecycles.
|
|
3
|
+
* Tracks listener disposer functions and registered DOM elements so subclasses
|
|
4
|
+
* can easily tear down on removal.
|
|
5
|
+
*/
|
|
6
|
+
export default class Base extends Disposable {
|
|
7
|
+
/**
|
|
8
|
+
* Assigns an HTMLElement to this object.
|
|
9
|
+
*
|
|
10
|
+
* @throws {Error} If there is already one assigned.
|
|
11
|
+
*/
|
|
12
|
+
set element(element: HTMLElement);
|
|
13
|
+
/**
|
|
14
|
+
* Returns the HTMLElement associated with this object.
|
|
15
|
+
*
|
|
16
|
+
* @returns {HTMLElement} The HTMLElement associated with this object.
|
|
17
|
+
*/
|
|
18
|
+
get element(): HTMLElement;
|
|
19
|
+
/**
|
|
20
|
+
* Cleans up registered disposers and emits a removal event for subscribers.
|
|
21
|
+
*
|
|
22
|
+
* @returns {void}
|
|
23
|
+
*/
|
|
24
|
+
remove(): void;
|
|
25
|
+
/**
|
|
26
|
+
* Registers a Notify listener and tracks its disposer for later cleanup.
|
|
27
|
+
*
|
|
28
|
+
* @param {string} eventName - Event to subscribe to.
|
|
29
|
+
* @param {(evt: Event) => void} func - Handler to invoke.
|
|
30
|
+
* @param {HTMLElement | Window} [element] - Target element; defaults to window.
|
|
31
|
+
* @param {boolean | object} [options] - addEventListener options.
|
|
32
|
+
*/
|
|
33
|
+
registerOn(eventName: string, func: (evt: Event) => void, element?: HTMLElement | Window, options?: boolean | object): void;
|
|
34
|
+
/**
|
|
35
|
+
* Resolves a DOM element and optionally registers listener functions on it.
|
|
36
|
+
* Each listener's return value is treated as a disposer and tracked.
|
|
37
|
+
*
|
|
38
|
+
* @param {string} elementId - Selector passed to querySelector.
|
|
39
|
+
* @param {((element: Element) => (void | (() => void))) | Array<(element: Element) => (void | (() => void))>} [listenerFunctions] - One or more listener initializers.
|
|
40
|
+
*/
|
|
41
|
+
initialiseElement(elementId: string, listenerFunctions?: ((element: Element) => (void | (() => void))) | Array<(element: Element) => (void | (() => void))>): void;
|
|
42
|
+
#private;
|
|
43
|
+
}
|
|
44
|
+
import Disposable from "./Disposable.js";
|
|
45
|
+
//# sourceMappingURL=Base.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Base.d.ts","sourceRoot":"","sources":["../../../browser/lib/Base.js"],"names":[],"mappings":"AAIA;;;;GAIG;AACH;IAcE;;;;OAIG;IACH,qBAWa,WAAW,EALvB;IAED;;;;OAIG;IACH,eAFa,WAAW,CAIvB;IAED;;;;OAIG;IACH,UAFa,IAAI,CAQhB;IAED;;;;;;;OAOG;IACH,sBALW,MAAM,QACN,CAAC,GAAG,EAAE,KAAK,KAAK,IAAI,YACpB,WAAW,GAAG,MAAM,YACpB,OAAO,GAAG,MAAM,QAM1B;IAED;;;;;;OAMG;IACH,6BAHW,MAAM,sBACN,CAAC,CAAC,OAAO,EAAE,OAAO,KAAK,CAAC,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,OAAO,EAAE,OAAO,KAAK,CAAC,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC,QA8B5G;;CACF;uBA5GsB,iBAAiB"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Simple lifecycle helper that tracks disposer callbacks.
|
|
3
|
+
* Register any teardown functions and call dispose() to run them in reverse.
|
|
4
|
+
*/
|
|
5
|
+
export default class Disposable {
|
|
6
|
+
/**
|
|
7
|
+
* Registers a disposer callback to be executed when disposed.
|
|
8
|
+
*
|
|
9
|
+
* @param {() => void} disposer - Cleanup callback.
|
|
10
|
+
* @returns {() => void} Function to unregister the disposer.
|
|
11
|
+
*/
|
|
12
|
+
registerDisposer(disposer: () => void): () => void;
|
|
13
|
+
/**
|
|
14
|
+
* Runs all registered disposers in reverse order.
|
|
15
|
+
*
|
|
16
|
+
* @returns {void}
|
|
17
|
+
*/
|
|
18
|
+
dispose(): void;
|
|
19
|
+
/**
|
|
20
|
+
* Whether disposal has run.
|
|
21
|
+
*
|
|
22
|
+
* @returns {boolean} True when dispose() has already been called.
|
|
23
|
+
*/
|
|
24
|
+
get disposed(): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Read-only list of registered disposers.
|
|
27
|
+
*
|
|
28
|
+
* @returns {Array<() => void>} Snapshot of disposer callbacks.
|
|
29
|
+
*/
|
|
30
|
+
get disposers(): Array<() => void>;
|
|
31
|
+
#private;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=Disposable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Disposable.d.ts","sourceRoot":"","sources":["../../../browser/lib/Disposable.js"],"names":[],"mappings":"AAAA;;;GAGG;AACH;IAIE;;;;;OAKG;IACH,2BAHW,MAAM,IAAI,GACR,MAAM,IAAI,CAStB;IAED;;;;OAIG;IACH,WAFa,IAAI,CAoBhB;IAED;;;;OAIG;IACH,gBAFa,OAAO,CAInB;IAED;;;;OAIG;IACH,iBAFa,KAAK,CAAC,MAAM,IAAI,CAAC,CAI7B;;CAQF"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export default class HTML {
|
|
2
|
+
/**
|
|
3
|
+
* Lightweight HTML helper utilities for browser contexts.
|
|
4
|
+
*
|
|
5
|
+
* @param {object|(() => unknown)} domPurify - Optional DOMPurify instance or factory.
|
|
6
|
+
*/
|
|
7
|
+
constructor(domPurify?: object | (() => unknown));
|
|
8
|
+
/**
|
|
9
|
+
* Fetches an HTML fragment and returns the contents inside the <body> tag when present.
|
|
10
|
+
*
|
|
11
|
+
* @param {string} url - Location of the HTML resource to load.
|
|
12
|
+
* @param {boolean} filterBodyContent - If true, returns only content found between the <body> tags. Defaults to false.
|
|
13
|
+
* @returns {Promise<string>} Sanitized HTML string or empty string on missing content.
|
|
14
|
+
*/
|
|
15
|
+
loadHTML(url: string, filterBodyContent?: boolean): Promise<string>;
|
|
16
|
+
/**
|
|
17
|
+
* Sanitizes arbitrary HTML using DOMPurify.
|
|
18
|
+
*
|
|
19
|
+
* @param {string} text - HTML string to sanitize. Defaults to "".
|
|
20
|
+
* @returns {string} Sanitized HTML.
|
|
21
|
+
*/
|
|
22
|
+
sanitise(text?: string): string;
|
|
23
|
+
/**
|
|
24
|
+
* Sanitizes an HTML string and replaces the element's children with the result.
|
|
25
|
+
*
|
|
26
|
+
* @param {Element} element - Target element to replace content within.
|
|
27
|
+
* @param {string} htmlString - HTML string to sanitize and insert.
|
|
28
|
+
*/
|
|
29
|
+
setHTMLContent(element: Element, htmlString: string): void;
|
|
30
|
+
/**
|
|
31
|
+
* Removes all child nodes from the given element.
|
|
32
|
+
*
|
|
33
|
+
* @param {Element} element - Element to clear.
|
|
34
|
+
*/
|
|
35
|
+
clearHTMLContent(element: Element): void;
|
|
36
|
+
#private;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=HTML.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HTML.d.ts","sourceRoot":"","sources":["../../../browser/lib/HTML.js"],"names":[],"mappings":"AAGA;IAGE;;;;OAIG;IACH,wBAFW,MAAM,GAAC,CAAC,MAAM,OAAO,CAAC,EAIhC;IAED;;;;;;OAMG;IACH,cAJW,MAAM,sBACN,OAAO,GACL,OAAO,CAAC,MAAM,CAAC,CAmB3B;IAED;;;;;OAKG;IACH,gBAHW,MAAM,GACJ,MAAM,CAMlB;IAED;;;;;OAKG;IACH,wBAHW,OAAO,cACP,MAAM,QA+BhB;IAED;;;;OAIG;IACH,0BAFW,OAAO,QAmBjB;;CAwBF"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
/** @type {string} Display name for debugging. */
|
|
3
|
+
name: string;
|
|
4
|
+
/**
|
|
5
|
+
* Emits a CustomEvent without expecting a return value.
|
|
6
|
+
*
|
|
7
|
+
* @param {string} type - Event name to dispatch.
|
|
8
|
+
* @param {unknown} [payload] - Value assigned to `event.detail`.
|
|
9
|
+
* @param {boolean | NotifyEventOptions} [options] - CustomEvent options or boolean to set `bubbles`.
|
|
10
|
+
* @returns {void}
|
|
11
|
+
*/
|
|
12
|
+
emit(type: string, payload?: unknown, options?: boolean | NotifyEventOptions): void;
|
|
13
|
+
/**
|
|
14
|
+
* Emits a CustomEvent and returns the detail for simple request/response flows.
|
|
15
|
+
*
|
|
16
|
+
* @param {string} type - Event name to dispatch.
|
|
17
|
+
* @param {unknown} [payload] - Value assigned to `event.detail`.
|
|
18
|
+
* @param {boolean | NotifyEventOptions} [options] - CustomEvent options or boolean to set `bubbles`.
|
|
19
|
+
* @returns {unknown} The detail placed on the CustomEvent.
|
|
20
|
+
*/
|
|
21
|
+
request(type: string, payload?: unknown, options?: boolean | NotifyEventOptions): unknown;
|
|
22
|
+
/**
|
|
23
|
+
* Registers a listener for the given event type on an HTMLElement (or
|
|
24
|
+
* window, if not specified).
|
|
25
|
+
*
|
|
26
|
+
* @param {string} type - Event name to listen for.
|
|
27
|
+
* @param {(evt: Notify) => void} handler - Listener callback.
|
|
28
|
+
* @param {HTMLElement | Window} [element] - The object to which to attach the handler. Default is window.
|
|
29
|
+
* @param {boolean | object} [options] - Options to pass to addEventListener.
|
|
30
|
+
* @returns {() => void} Dispose function to unregister the handler.
|
|
31
|
+
*/
|
|
32
|
+
on(type: string, handler: (evt: /*elided*/ any) => void, element?: HTMLElement | Window, options?: boolean | object): () => void;
|
|
33
|
+
/**
|
|
34
|
+
* Removes a previously registered listener for the given event type.
|
|
35
|
+
*
|
|
36
|
+
* @param {string} type - Event name to remove.
|
|
37
|
+
* @param {(evt: Notify) => void} handler - Listener callback to detach.
|
|
38
|
+
* @param {HTMLElement | Window} [element] - The object from which to remove the handler. Default is window.
|
|
39
|
+
* @param {boolean | object} [options] - Options to pass to removeEventListener.
|
|
40
|
+
* @returns {void}
|
|
41
|
+
*/
|
|
42
|
+
off(type: string, handler: (evt: /*elided*/ any) => void, element?: HTMLElement | Window, options?: boolean | object): void;
|
|
43
|
+
"__#private@#buildEventInit"(detail: any, options: any): any;
|
|
44
|
+
};
|
|
45
|
+
export default _default;
|
|
46
|
+
export type NotifyEventOptions = {
|
|
47
|
+
/**
|
|
48
|
+
* - Whether the event bubbles up the DOM tree.
|
|
49
|
+
*/
|
|
50
|
+
bubbles?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* - Whether the event can be canceled.
|
|
53
|
+
*/
|
|
54
|
+
cancelable?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* - Whether the event can cross the shadow DOM boundary.
|
|
57
|
+
*/
|
|
58
|
+
composed?: boolean;
|
|
59
|
+
};
|
|
60
|
+
//# sourceMappingURL=Notify.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Notify.d.ts","sourceRoot":"","sources":["../../../browser/lib/Notify.js"],"names":[],"mappings":";IAaE,iDAAiD;UAAtC,MAAM;IAGjB;;;;;;;OAOG;eAJQ,MAAM,YACN,OAAO,YACP,OAAO,GAAG,kBAAkB,GAC1B,IAAI;IAOjB;;;;;;;OAOG;kBAJQ,MAAM,YACN,OAAO,YACP,OAAO,GAAG,kBAAkB,GAC1B,OAAO;IASpB;;;;;;;;;OASG;aALQ,MAAM,WACN,CAAC,GAAG,gBAAQ,KAAK,IAAI,YACrB,WAAW,GAAG,MAAM,YACpB,OAAO,GAAG,MAAM,GACd,MAAM,IAAI;IAcvB;;;;;;;;OAQG;cALQ,MAAM,WACN,CAAC,GAAG,gBAAQ,KAAK,IAAI,YACrB,WAAW,GAAG,MAAM,YACpB,OAAO,GAAG,MAAM,GACd,IAAI;;;;;;;;cAjEL,OAAO;;;;iBACP,OAAO;;;;eACP,OAAO"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export { purify as default };
|
|
2
|
+
declare function purify(root: any): {
|
|
3
|
+
(root: any): /*elided*/ any;
|
|
4
|
+
version: string;
|
|
5
|
+
removed: any[];
|
|
6
|
+
isSupported: boolean;
|
|
7
|
+
sanitize(dirty: any, ...args: any[]): any;
|
|
8
|
+
setConfig(...args: any[]): void;
|
|
9
|
+
clearConfig(): void;
|
|
10
|
+
isValidAttribute(tag: any, attr: any, value: any): boolean;
|
|
11
|
+
addHook(entryPoint: any, hookFunction: any): void;
|
|
12
|
+
removeHook(entryPoint: any, hookFunction: any): any;
|
|
13
|
+
removeHooks(entryPoint: any): void;
|
|
14
|
+
removeAllHooks(): void;
|
|
15
|
+
};
|
|
16
|
+
declare namespace purify {
|
|
17
|
+
let version: string;
|
|
18
|
+
let removed: any[];
|
|
19
|
+
let isSupported: boolean;
|
|
20
|
+
function sanitize(dirty: any, ...args: any[]): any;
|
|
21
|
+
function setConfig(...args: any[]): void;
|
|
22
|
+
function clearConfig(): void;
|
|
23
|
+
function isValidAttribute(tag: any, attr: any, value: any): boolean;
|
|
24
|
+
function addHook(entryPoint: any, hookFunction: any): void;
|
|
25
|
+
function removeHook(entryPoint: any, hookFunction: any): any;
|
|
26
|
+
function removeHooks(entryPoint: any): void;
|
|
27
|
+
function removeAllHooks(): void;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=dompurify.esm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dompurify.esm.d.ts","sourceRoot":"","sources":["../../../../browser/lib/vendor/dompurify.esm.js"],"names":[],"mappings":";AA0UE;;;;;;;;;;;;;EAA+C;;;;;IA+9B/C,mDAiJC;IACD,yCAIC;IACD,6BAGC;IACD,oEAUC;IACD,2DAMC;IACD,6DAQC;IACD,4CAEC;IACD,gCAEC"}
|
package/src/types/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { default as Collection } from "./browser/lib/Collection.js";
|
|
2
2
|
export { default as Data } from "./browser/lib/Data.js";
|
|
3
|
+
export { default as Disposable } from "./browser/lib/Disposable.js";
|
|
3
4
|
export { default as Type } from "./browser/lib/TypeSpec.js";
|
|
4
5
|
export { default as Valid } from "./lib/Valid.js";
|
|
5
6
|
export { default as Sass } from "./lib/Sass.js";
|
|
@@ -51,15 +51,15 @@ export default class Contract {
|
|
|
51
51
|
/**
|
|
52
52
|
* Get the provider terms (if any)
|
|
53
53
|
*
|
|
54
|
-
* @returns {Terms|null} Provider terms
|
|
54
|
+
* @returns {import("./Terms.js").default|null} Provider terms
|
|
55
55
|
*/
|
|
56
|
-
get providerTerms(): Terms | null;
|
|
56
|
+
get providerTerms(): import("./Terms.js").default | null;
|
|
57
57
|
/**
|
|
58
58
|
* Get the consumer terms (if any)
|
|
59
59
|
*
|
|
60
|
-
* @returns {Terms|null} Consumer terms
|
|
60
|
+
* @returns {import("./Terms.js").default|null} Consumer terms
|
|
61
61
|
*/
|
|
62
|
-
get consumerTerms(): Terms | null;
|
|
62
|
+
get consumerTerms(): import("./Terms.js").default | null;
|
|
63
63
|
/**
|
|
64
64
|
* Get the contract validator
|
|
65
65
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Contract.d.ts","sourceRoot":"","sources":["../../lib/Contract.js"],"names":[],"mappings":"AAIA;;;;GAIG;AACH;IAwBE;;;;;;;OAOG;IACH,oDAgBC;IAED;;;;;;;;OAQG;IACH,uBANW,MAAM,mBACN,MAAM,cACN,OAAO,KAAK,EAAE,gBAAgB,GAAC,IAAI,gBAEjC,QAAQ,CAsBpB;IAxED;;;;;;;OAOG;IACH,2BALW,OAAO,YAAY,EAAE,KAAK,iBAC1B,OAAO,YAAY,EAAE,KAAK,cAElC;QAAsD,KAAK,GAAnD,GAAmC;KAC7C,EAQA;IA6FD;;;;;;OAMG;IACH,eAJW,MAAM,GACJ,OAAO,CAsBnB;IAsED;;;;OAIG;IACH,oBAFa,OAAO,CAInB;IAED;;;;OAIG;IACH,qBAFa,
|
|
1
|
+
{"version":3,"file":"Contract.d.ts","sourceRoot":"","sources":["../../lib/Contract.js"],"names":[],"mappings":"AAIA;;;;GAIG;AACH;IAwBE;;;;;;;OAOG;IACH,oDAgBC;IAED;;;;;;;;OAQG;IACH,uBANW,MAAM,mBACN,MAAM,cACN,OAAO,KAAK,EAAE,gBAAgB,GAAC,IAAI,gBAEjC,QAAQ,CAsBpB;IAxED;;;;;;;OAOG;IACH,2BALW,OAAO,YAAY,EAAE,KAAK,iBAC1B,OAAO,YAAY,EAAE,KAAK,cAElC;QAAsD,KAAK,GAAnD,GAAmC;KAC7C,EAQA;IA6FD;;;;;;OAMG;IACH,eAJW,MAAM,GACJ,OAAO,CAsBnB;IAsED;;;;OAIG;IACH,oBAFa,OAAO,CAInB;IAED;;;;OAIG;IACH,qBAFa,OAAO,YAAY,EAAE,OAAO,GAAC,IAAI,CAI7C;IAED;;;;OAIG;IACH,qBAFa,OAAO,YAAY,EAAE,OAAO,GAAC,IAAI,CAI7C;IAED;;;;OAIG;IACH,iBAFa,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,GAAC,IAAI,CAI1C;;CACF"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Simple lifecycle helper that tracks disposer callbacks.
|
|
3
|
+
* Register any teardown functions and call dispose() to run them in reverse.
|
|
4
|
+
*/
|
|
5
|
+
export default class Disposable {
|
|
6
|
+
/**
|
|
7
|
+
* Registers a disposer callback to be executed when disposed.
|
|
8
|
+
*
|
|
9
|
+
* @param {() => void} disposer - Cleanup callback.
|
|
10
|
+
* @returns {() => void} Function to unregister the disposer.
|
|
11
|
+
*/
|
|
12
|
+
registerDisposer(disposer: () => void): () => void;
|
|
13
|
+
/**
|
|
14
|
+
* Runs all registered disposers in reverse order.
|
|
15
|
+
*
|
|
16
|
+
* @returns {void}
|
|
17
|
+
*/
|
|
18
|
+
dispose(): void;
|
|
19
|
+
/**
|
|
20
|
+
* Whether disposal has run.
|
|
21
|
+
*
|
|
22
|
+
* @returns {boolean} True when dispose() has already been called.
|
|
23
|
+
*/
|
|
24
|
+
get disposed(): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Read-only list of registered disposers.
|
|
27
|
+
*
|
|
28
|
+
* @returns {Array<() => void>} Snapshot of disposer callbacks.
|
|
29
|
+
*/
|
|
30
|
+
get disposers(): Array<() => void>;
|
|
31
|
+
#private;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=Disposable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Disposable.d.ts","sourceRoot":"","sources":["../../lib/Disposable.js"],"names":[],"mappings":"AAAA;;;GAGG;AACH;IAIE;;;;;OAKG;IACH,2BAHW,MAAM,IAAI,GACR,MAAM,IAAI,CAStB;IAED;;;;OAIG;IACH,WAFa,IAAI,CAoBhB;IAED;;;;OAIG;IACH,gBAFa,OAAO,CAInB;IAED;;;;OAIG;IACH,iBAFa,KAAK,CAAC,MAAM,IAAI,CAAC,CAI7B;;CAQF"}
|