First upload version 0.0.1

This commit is contained in:
Neyra
2026-02-05 15:27:49 +08:00
commit 8e9b7201ed
4182 changed files with 593136 additions and 0 deletions

21
node_modules/lifecycle-utils/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2023 Gilad S.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

516
node_modules/lifecycle-utils/README.md generated vendored Normal file
View File

@@ -0,0 +1,516 @@
# `lifecycle-utils`
A set of general utilities for the lifecycle of a JS/TS project/library
[![Build](https://github.com/giladgd/lifecycle-utils/actions/workflows/test.yml/badge.svg)](https://github.com/giladgd/lifecycle-utils/actions/workflows/test.yml)
[![License](https://badgen.net/badge/color/MIT/green?label=license)](https://www.npmjs.com/package/lifecycle-utils)
[![Types](https://badgen.net/badge/color/TypeScript/blue?label=types)](https://www.npmjs.com/package/lifecycle-utils)
[![Version](https://badgen.net/npm/v/lifecycle-utils)](https://www.npmjs.com/package/lifecycle-utils)
[![codecov](https://codecov.io/gh/giladgd/lifecycle-utils/branch/master/graph/badge.svg)](https://codecov.io/gh/giladgd/lifecycle-utils)
* [Documentation](https://giladgd.github.io/lifecycle-utils/)
* [Changelog](https://github.com/giladgd/lifecycle-utils/releases)
## Installation
```bash
npm install --save lifecycle-utils
```
> This is an ESM package, so you can only use `import` to import it, and cannot use `require`
## Documentation
### `withLock`
Calling `withLock` with the same `scope` values will ensure that the callback inside cannot run in parallel to other calls with the same `scope` values.
The order of the values in the `scope` array it important, and should be consistent across calls to reference the same lock.
You can use as many values as you like, but always ensure that at least one of them is a reference to an object.
```typescript
import {withLock} from "lifecycle-utils";
const scope = {}; // can be a reference to any object you like
const startTime = Date.now();
async function doSomething(index: number): number {
return await withLock([scope, "myKey"], async () => {
await new Promise(resolve => setTimeout(resolve, 1000));
console.log("index:", index, "time:", Date.now() - startTime);
return 42;
});
}
const res = await Promise.all([
doSomething(1),
doSomething(2),
doSomething(3)
]);
// index: 1 time: 1000
// index: 2 time: 2000
// index: 3 time: 3000
console.log(res); // [42, 42, 42]
```
### `isLockActive`
Check whether a lock is currently active for the given `scope` values.
```typescript
import {isLockActive} from "lifecycle-utils";
const scope = {}; // can be a reference to any object you like
const res = isLockActive([scope, "myKey"]);
console.log(res); // false
```
### `acquireLock`
Acquire a lock for the given `scope` values.
```typescript
import {acquireLock} from "lifecycle-utils";
const scope = {}; // can be a reference to any object you like
const activeLock = await acquireLock([scope, "myKey"]);
console.log("lock acquired");
// ... do some work
activeLock.dispose();
```
### `waitForLockRelease`
Wait for a lock to be released for a given `scope` values.
```typescript
import {waitForLockRelease} from "lifecycle-utils";
const scope = {}; // can be a reference to any object you like
await waitForLockRelease([scope, "myKey"]);
console.log("lock is released");
```
### `EventRelay`
A simple event relay.
Create a listener with `createListener` and dispatch events with `dispatchEvent`.
For each supported event type, create a new instance of `EventRelay` and expose it as a property.
For example, this code:
```ts
import {EventRelay} from "lifecycle-utils";
class MyClass {
public readonly onSomethingHappened = new EventRelay<string>();
public doSomething(whatToDo: string) {
this.onSomethingHappened.dispatchEvent(whatToDo);
console.log("Done notifying listeners");
}
}
const myClass = new MyClass();
myClass.onSomethingHappened.createListener((whatHappened) => {
console.log(`Something happened: ${whatHappened}`);
});
myClass.doSomething("eat a cookie");
```
Will print this:
```
Something happened: eat a cookie
Done notifying listeners
```
### `DisposeAggregator`
`DisposeAggregator` is a utility class that allows you to add multiple items and then dispose them all at once.
You can add a function to call, an object with a `dispose` method, or an object with a `Symbol.dispose` method.
To dispose all the items, call `dispose` or use the `Symbol.dispose` symbol.
```typescript
import {DisposeAggregator, EventRelay} from "lifecycle-utils";
const disposeAggregator = new DisposeAggregator();
const eventRelay = new EventRelay<string>();
disposeAggregator.add(eventRelay);
const eventRelay2 = disposeAggregator.add(new EventRelay<string>());
disposeAggregator.dispose();
console.log(eventRelay.disposed === true); // true
console.log(eventRelay2.disposed === true); // true
```
### `AsyncDisposeAggregator`
`AsyncDisposeAggregator` is a utility class that allows you to add multiple items and then dispose them all at once.
The items are disposed one by one in the order they were added.
You can add a function to call, an object with a `dispose` method, an object with a `Symbol.dispose` method,
an object with a `Symbol.asyncDispose` method, or a Promise that resolves to one of the previous types.
To dispose all the items, call `dispose` or use the `Symbol.asyncDispose` symbol.
The difference between `AsyncDisposeAggregator` and `DisposeAggregator` is that `AsyncDisposeAggregator` can dispose async targets.
```typescript
import {AsyncDisposeAggregator, EventRelay} from "lifecycle-utils";
const disposeAggregator = new AsyncDisposeAggregator();
const eventRelay = new EventRelay<string>();
disposeAggregator.add(eventRelay);
disposeAggregator.add(async () => {
await new Promise(resolve => setTimeout(resolve, 0));
// do some async work
});
disposeAggregator.dispose();
```
### `DisposableHandle`
An object that provides a `.dispose()` method that can called only once.
Calling `.dispose()` will call the provided `onDispose` function only once.
Any subsequent calls to `.dispose()` will do nothing.
```typescript
import {DisposableHandle} from "lifecycle-utils";
function createHandle() {
console.log("allocating resources");
return new DisposableHandle(() => {
console.log("resources disposed");
});
}
const handle = createHandle();
handle.dispose();
```
Using the `using` feature of TypeScript is also supported:
```typescript
import {DisposableHandle} from "lifecycle-utils";
function createHandle() {
console.log("allocating resources");
return new DisposableHandle(() => {
console.log("resources disposed");
});
}
function doWork() {
using handle = createHandle();
}
doWork();
// resources disposed
// the dispose function was called since the scope of the `doWork` function ended
```
### `AsyncDisposableHandle`
An object that provides an async `.dispose()` method that can called only once.
Calling `.dispose()` will call the provided `onDispose` function only once.
Any subsequent calls to `.dispose()` will do nothing.
```typescript
import {AsyncDisposableHandle} from "lifecycle-utils";
function createHandle() {
console.log("allocating resources");
return new AsyncDisposableHandle(async () => {
await new Promise(resolve => setTimeout(resolve, 1000));
console.log("resources disposed");
});
}
const handle = createHandle();
await handle.dispose();
```
Using the `await using` feature of TypeScript is also supported:
```typescript
import {AsyncDisposableHandle} from "lifecycle-utils";
function createHandle() {
console.log("allocating resources");
return new AsyncDisposableHandle(async () => {
await new Promise(resolve => setTimeout(resolve, 1000));
console.log("resources disposed");
});
}
async function doWork() {
await using handle = createHandle();
}
await doWork();
// resources disposed
// the dispose function was called since the scope of the `doWork` function ended
```
### `MultiKeyMap`
`MultiKeyMap` is a utility class that works like a `Map`, but accepts multiple values as the key for each value.
`.set(...)`, `.get(...)`, `.has(...)`, `.delete(...)` are in time complexity of O(1), given that the length of the keys is constant.
```typescript
import {MultiKeyMap} from "lifecycle-utils";
type Provider = {name: string};
const provider1: Provider = {name: "1"};
const provider2: Provider = {name: "2"};
const map = new MultiKeyMap<[provider: Provider, name: string], number>();
map.set([provider1, "key1"], 1);
map.set([provider2, "key1"], 2);
map.set([provider1, "key2"], 3);
console.log(map.get([provider1, "key1"])); // 1
console.log(map.get([provider2, "key1"])); // 2
console.log(map.get([provider1, "key2"])); // 3
console.log([...map.keys()]); // [[{name: "1"}, "key1"], [{name: "2"}, "key1"], [{name: "1"}, "key2"]])
```
### `WeakValueMultiKeyMap`
`WeakValueMultiKeyMap` is a utility class that works like a [`MultiKeyMap`](#multikeymap), but doesn't keep strong references to the values.
When a value is garbage collected, it is automatically removed from the map.
```typescript
import {WeakValueMultiKeyMap} from "lifecycle-utils";
type Provider = {name: string};
const map = new WeakValueMultiKeyMap<[type: string, name: string], Provider>();
{
const provider1: Provider = {name: "1"};
map.set(["type1", "key1"], provider1);
console.log(map.has(["type1", "key1"])); // true
console.log(map.get(["type1", "key1"])); // {name: "1"}
console.log(map.size); // 1
}
// wait for the runtime to run garbage collection
await new Promise(resolve => setTimeout(resolve, 1000 * 60 * 10));
console.log(map.has(["type1", "key1"])); // false
console.log(map.get(["type1", "key1"])); // undefined
console.log(map.size); // 0
```
### `WeakValueMap`
`WeakValueMap` is a utility class that works like a `Map`, but doesn't keep strong references to the values.
When a value is garbage collected, it is automatically removed from the map.
```typescript
import {WeakValueMap} from "lifecycle-utils";
type Provider = {name: string};
const map = new WeakValueMap<string, Provider>();
{
const provider1: Provider = {name: "1"};
map.set("provider1", provider1);
console.log(map.has("provider1")); // true
console.log(map.get("provider1")); // {name: "1"}
console.log(map.size); // 1
}
// wait for the runtime to run garbage collection
await new Promise(resolve => setTimeout(resolve, 1000 * 60 * 10));
console.log(map.has("provider1")); // false
console.log(map.get("provider1")); // undefined
console.log(map.size); // 0
```
### `LongTimeout`
A timeout that can be set to a delay longer than the maximum timeout delay supported by a regular `setTimeout`.
```typescript
import {LongTimeout} from "lifecycle-utils";
const month = 1000 * 60 * 60 * 24 * 7 * 30;
const timeout = new LongTimeout(() => {
console.log("timeout");
}, month);
// to clear the timeout, call dispose
// timeout.dispose();
```
### `setLongTimeout`
Sets a timeout that can also be set to a delay longer than the maximum timeout delay supported by a regular `setTimeout`.
You can use `clearLongTimeout` to clear the timeout.
```typescript
import {setLongTimeout, clearLongTimeout} from "lifecycle-utils";
const month = 1000 * 60 * 60 * 24 * 7 * 30;
const timeout = setLongTimeout(() => {
console.log("timeout");
}, month);
// to clear the timeout, call clearLongTimeout
// clearLongTimeout(timeout);
```
### `clearLongTimeout`
Clears a timeout that was set with `setLongTimeout`.
You can also clear a regular timeout with this function.
```typescript
import {setLongTimeout, clearLongTimeout} from "lifecycle-utils";
const month = 1000 * 60 * 60 * 24 * 7 * 30;
const timeout = setLongTimeout(() => {
console.log("timeout");
}, month);
const timeout2 = setTimeout(() => {
console.log("timeout2");
}, 1000 * 60);
clearLongTimeout(timeout);
clearLongTimeout(timeout2);
```
### `State`
`State` is a utility class that allows you to hold a value and notify listeners when the value changes.
```typescript
import {State} from "lifecycle-utils";
const valueState = new State<number>(6);
const eventHandle = valueState.createChangeListener((newValue, previousValue) => {
console.log("new value:", newValue);
console.log("previous value:", previousValue);
});
valueState.state = 7;
// after a microtask, the listener will be called
// to make event fire immediately upon change, disable the `queueEvents` option on the constructor
await new Promise(resolve => setTimeout(resolve, 0));
// will print:
// new value: 7
// previous value: 6
eventHandle.dispose();
```
### `State.createCombinedChangeListener`
Create a listener that listens to multiple states and calls the callback when any of the states change.
```typescript
import {State} from "lifecycle-utils";
const valueState1 = new State<number>(6);
const valueState2 = new State<string>("hello");
const valueState3 = new State<boolean>(true);
const eventHandle = State.createCombinedChangeListener([valueState1, valueState2, valueState3], (newValues, previousValues) => {
console.log("new values:", newValues);
console.log("previous values:", previousValues);
});
valueState1.state = 7;
valueState2.state = "world";
valueState3.state = false;
// after a microtask, the listener will be called
// to make event fire immediately upon change, disable the `queueEvents` option on the constructor
await new Promise(resolve => setTimeout(resolve, 0));
// will print:
// new values: [7, "world", false]
// previous values: [6, "hello", true]
eventHandle.dispose();
```
### `splitText`
Split a text by multiple separators, and return a result of the text and separators.
```typescript
const parts = splitText("Hello <and> world [then] !", ["<and>", "[then]"]);
console.log(parts); // ["Hello ", new Separator("<and>"), " world ", new Separator("[then]"), " !"]
```
### `scopeExit`
Create a scope exit handle that will call the provided callback when disposed, to be used with `using` or `await using`.
For example, this code:
```typescript
import {scopeExit} from "lifecycle-utils";
function example() {
using exitHandle = scopeExit(() => {
console.log("exiting scope");
});
console.log("inside scope");
}
async function asyncExample() {
await using exitHandle = scopeExit(async () => {
await new Promise((resolve) => setTimeout(resolve, 100));
console.log("exiting async scope");
});
console.log("inside async scope");
}
example();
console.log("example done");
console.log()
await asyncExample();
console.log("asyncExample done");
```
Will print this:
```
inside scope
exiting scope
example done
inside async scope
exiting async scope
asyncExample done
```
## Contributing
To contribute to `lifecycle-utils` see [CONTRIBUTING.md](https://github.com/giladgd/lifecycle-utils/blob/master/CONTRIBUTING.md).
<br />
<div align="center" width="360">
<img alt="Star please" src="https://raw.githubusercontent.com/giladgd/lifecycle-utils/master/assets/star.please.roundEdges.png" width="360" margin="auto" />
<br/>
<p align="right">
<i>If you like this repo, star it ✨</i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</p>
</div>

View File

@@ -0,0 +1,13 @@
/**
* An object that provides an async `.dispose()` method that can called only once.
*
* Calling `.dispose()` will call the provided `onDispose` function only once.
* Any subsequent calls to `.dispose()` will do nothing.
*/
export declare class AsyncDisposableHandle {
constructor(onDispose: () => Promise<void>);
get disposed(): boolean;
[Symbol.asyncDispose](): Promise<void>;
dispose(): Promise<void>;
}
//# sourceMappingURL=AsyncDisposableHandle.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"AsyncDisposableHandle.d.ts","sourceRoot":"","sources":["../src/AsyncDisposableHandle.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,qBAAa,qBAAqB;gBAIX,SAAS,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC;IAOjD,IAAW,QAAQ,YAElB;IAEY,CAAC,MAAM,CAAC,YAAY,CAAC;IAIrB,OAAO;CAWvB"}

View File

@@ -0,0 +1,31 @@
/**
* An object that provides an async `.dispose()` method that can called only once.
*
* Calling `.dispose()` will call the provided `onDispose` function only once.
* Any subsequent calls to `.dispose()` will do nothing.
*/
export class AsyncDisposableHandle {
/** @internal */ _onDispose;
/** @internal */ _disposePromise;
constructor(onDispose) {
this._onDispose = onDispose;
this.dispose = this.dispose.bind(this);
this[Symbol.asyncDispose] = this[Symbol.asyncDispose].bind(this);
}
get disposed() {
return this._onDispose == null;
}
async [Symbol.asyncDispose]() {
await this.dispose();
}
async dispose() {
if (this._onDispose != null) {
const onDispose = this._onDispose;
delete this._onDispose;
this._disposePromise = onDispose();
await this._disposePromise;
}
await this._disposePromise;
}
}
//# sourceMappingURL=AsyncDisposableHandle.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"AsyncDisposableHandle.js","sourceRoot":"","sources":["../src/AsyncDisposableHandle.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,OAAO,qBAAqB;IAC9B,gBAAgB,CAAS,UAAU,CAAoC;IACvE,gBAAgB,CAAS,eAAe,CAAiB;IAEzD,YAAmB,SAA8B;QAC7C,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAE5B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACvC,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACrE,CAAC;IAED,IAAW,QAAQ;QACf,OAAO,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC;IACnC,CAAC;IAEM,KAAK,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC;QAC9B,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;IACzB,CAAC;IAEM,KAAK,CAAC,OAAO;QAChB,IAAI,IAAI,CAAC,UAAU,IAAI,IAAI,EAAE,CAAC;YAC1B,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC;YAClC,OAAO,IAAI,CAAC,UAAU,CAAC;YAEvB,IAAI,CAAC,eAAe,GAAG,SAAS,EAAE,CAAC;YACnC,MAAM,IAAI,CAAC,eAAe,CAAC;QAC/B,CAAC;QAED,MAAM,IAAI,CAAC,eAAe,CAAC;IAC/B,CAAC;CACJ"}

View File

@@ -0,0 +1,54 @@
/**
* `AsyncDisposeAggregator` is a utility class that allows you to add multiple items and then dispose them all at once.
* The items are disposed one by one in the order they were added.
* You can add a function to call, an object with a `dispose` method, an object with a `Symbol.dispose` method,
* an object with a `Symbol.asyncDispose` method, or a Promise that resolves to one of the previous types.
* To dispose all the items, call `dispose` or use the `Symbol.asyncDispose` symbol.
* The difference between `AsyncDisposeAggregator` and `DisposeAggregator` is that `AsyncDisposeAggregator` can dispose async targets.
*
* For example,
* ```typescript
* import {AsyncDisposeAggregator, EventRelay} from "lifecycle-utils";
*
* const disposeAggregator = new AsyncDisposeAggregator();
*
* const eventRelay = new EventRelay<string>();
* disposeAggregator.add(eventRelay);
*
* disposeAggregator.add(async () => {
* await new Promise(resolve => setTimeout(resolve, 0));
* // do some async work
* });
*
* disposeAggregator.dispose();
* ```
*/
export declare class AsyncDisposeAggregator {
constructor();
/**
* Adds a target to be disposed.
* You can wrap the target with a `WeakRef` to prevent this class from holding a strong reference to the target.
*/
add(target: AsyncDisposeAggregatorTarget): this;
/**
* Disposes all the targets that have been added and clears the list of targets.
*/
dispose(): Promise<void>;
[Symbol.asyncDispose](): Promise<void>;
get targetCount(): number;
}
export type AsyncDisposeAggregatorTarget = AsyncDisposeAggregatorWrappedTarget | Promise<AsyncDisposeAggregatorWrappedTarget>;
export type AsyncDisposeAggregatorWrappedTarget = (() => void | Promise<void>) | {
[Symbol.asyncDispose](): void | Promise<void>;
} | {
[Symbol.dispose](): void;
} | {
dispose(): void | Promise<void>;
} | WeakRef<{
[Symbol.asyncDispose](): void | Promise<void>;
} | {
[Symbol.dispose](): void;
} | {
dispose(): void | Promise<void>;
}>;
//# sourceMappingURL=AsyncDisposeAggregator.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"AsyncDisposeAggregator.d.ts","sourceRoot":"","sources":["../src/AsyncDisposeAggregator.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,qBAAa,sBAAsB;;IAU/B;;;OAGG;IACI,GAAG,CAAC,MAAM,EAAE,4BAA4B,GAAG,IAAI;IAOtD;;OAEG;IACU,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAyCxB,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC;IAInD,IAAW,WAAW,IAAI,MAAM,CAE/B;CAOJ;AAED,MAAM,MAAM,4BAA4B,GAAG,mCAAmC,GAAG,OAAO,CAAC,mCAAmC,CAAC,CAAC;AAE9H,MAAM,MAAM,mCAAmC,GAAG,CAAC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG;IAC7E,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CAChD,GAAG;IACA,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI,CAAA;CAC3B,GAAG;IACA,OAAO,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CAClC,GAAG,OAAO,CAAC;IACR,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CAChD,GAAG;IACA,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI,CAAA;CAC3B,GAAG;IACA,OAAO,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CAClC,CAAC,CAAC"}

View File

@@ -0,0 +1,91 @@
import { DisposedError } from "./DisposedError.js";
/**
* `AsyncDisposeAggregator` is a utility class that allows you to add multiple items and then dispose them all at once.
* The items are disposed one by one in the order they were added.
* You can add a function to call, an object with a `dispose` method, an object with a `Symbol.dispose` method,
* an object with a `Symbol.asyncDispose` method, or a Promise that resolves to one of the previous types.
* To dispose all the items, call `dispose` or use the `Symbol.asyncDispose` symbol.
* The difference between `AsyncDisposeAggregator` and `DisposeAggregator` is that `AsyncDisposeAggregator` can dispose async targets.
*
* For example,
* ```typescript
* import {AsyncDisposeAggregator, EventRelay} from "lifecycle-utils";
*
* const disposeAggregator = new AsyncDisposeAggregator();
*
* const eventRelay = new EventRelay<string>();
* disposeAggregator.add(eventRelay);
*
* disposeAggregator.add(async () => {
* await new Promise(resolve => setTimeout(resolve, 0));
* // do some async work
* });
*
* disposeAggregator.dispose();
* ```
*/
export class AsyncDisposeAggregator {
/** @internal */ _targets = [];
/** @internal */ _disposed = false;
constructor() {
this.add = this.add.bind(this);
this.dispose = this.dispose.bind(this);
this[Symbol.asyncDispose] = this[Symbol.asyncDispose].bind(this);
}
/**
* Adds a target to be disposed.
* You can wrap the target with a `WeakRef` to prevent this class from holding a strong reference to the target.
*/
add(target) {
this._ensureNotDisposed();
this._targets.push(target);
return this;
}
/**
* Disposes all the targets that have been added and clears the list of targets.
*/
async dispose() {
if (this._disposed)
return;
this._disposed = true;
while (this._targets.length > 0) {
let disposeTarget = this._targets.shift();
if (disposeTarget instanceof Promise) {
try {
disposeTarget = await disposeTarget;
}
catch (err) {
/* c8 ignore start */
console.error(err);
continue;
} /* c8 ignore stop */
}
if (typeof WeakRef !== "undefined" && disposeTarget instanceof WeakRef)
disposeTarget = disposeTarget.deref();
if (disposeTarget == null)
continue;
else if (Symbol.asyncDispose != null && Symbol.asyncDispose in disposeTarget &&
disposeTarget[Symbol.asyncDispose] instanceof Function)
await disposeTarget[Symbol.asyncDispose]();
else if (Symbol.dispose != null && Symbol.dispose in disposeTarget &&
disposeTarget[Symbol.dispose] instanceof Function)
disposeTarget[Symbol.dispose]();
else if ("dispose" in disposeTarget && disposeTarget.dispose instanceof Function)
await disposeTarget.dispose();
else if (disposeTarget instanceof Function)
await disposeTarget();
}
}
async [Symbol.asyncDispose]() {
return this.dispose();
}
get targetCount() {
return this._targets.length;
}
/** @internal */
_ensureNotDisposed() {
if (this._disposed)
throw new DisposedError();
}
}
//# sourceMappingURL=AsyncDisposeAggregator.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"AsyncDisposeAggregator.js","sourceRoot":"","sources":["../src/AsyncDisposeAggregator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,oBAAoB,CAAC;AAEjD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,OAAO,sBAAsB;IAC/B,gBAAgB,CAAkB,QAAQ,GAAmC,EAAE,CAAC;IAChF,gBAAgB,CAAS,SAAS,GAAY,KAAK,CAAC;IAEpD;QACI,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC/B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACvC,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACrE,CAAC;IAED;;;OAGG;IACI,GAAG,CAAC,MAAoC;QAC3C,IAAI,CAAC,kBAAkB,EAAE,CAAC;QAC1B,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAE3B,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,OAAO;QAChB,IAAI,IAAI,CAAC,SAAS;YACd,OAAO;QAEX,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QAEtB,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC9B,IAAI,aAAa,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;YAE1C,IAAI,aA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,MAAM,IAAI,aAAa,EAAE,CAAC;IAClC,CAAC;CACJ"}

View File

@@ -0,0 +1,13 @@
/**
* An object that provides a `.dispose()` method that can called only once.
*
* Calling `.dispose()` will call the provided `onDispose` function only once.
* Any subsequent calls to `.dispose()` will do nothing.
*/
export declare class DisposableHandle {
constructor(onDispose: () => void);
get disposed(): boolean;
[Symbol.dispose](): void;
dispose(): void;
}
//# sourceMappingURL=DisposableHandle.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"DisposableHandle.d.ts","sourceRoot":"","sources":["../src/DisposableHandle.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,qBAAa,gBAAgB;gBAGN,SAAS,EAAE,MAAM,IAAI;IAOxC,IAAW,QAAQ,YAElB;IAEM,CAAC,MAAM,CAAC,OAAO,CAAC;IAIhB,OAAO;CAQjB"}

28
node_modules/lifecycle-utils/dist/DisposableHandle.js generated vendored Normal file
View File

@@ -0,0 +1,28 @@
/**
* An object that provides a `.dispose()` method that can called only once.
*
* Calling `.dispose()` will call the provided `onDispose` function only once.
* Any subsequent calls to `.dispose()` will do nothing.
*/
export class DisposableHandle {
/** @internal */ _onDispose;
constructor(onDispose) {
this._onDispose = onDispose;
this.dispose = this.dispose.bind(this);
this[Symbol.dispose] = this[Symbol.dispose].bind(this);
}
get disposed() {
return this._onDispose == null;
}
[Symbol.dispose]() {
this.dispose();
}
dispose() {
if (this._onDispose != null) {
const onDispose = this._onDispose;
delete this._onDispose;
onDispose();
}
}
}
//# sourceMappingURL=DisposableHandle.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"DisposableHandle.js","sourceRoot":"","sources":["../src/DisposableHandle.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,OAAO,gBAAgB;IACzB,gBAAgB,CAAS,UAAU,CAA2B;IAE9D,YAAmB,SAAqB;QACpC,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAE5B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACvC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC3D,CAAC;IAED,IAAW,QAAQ;QACf,OAAO,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC;IACnC,CAAC;IAEM,CAAC,MAAM,CAAC,OAAO,CAAC;QACnB,IAAI,CAAC,OAAO,EAAE,CAAC;IACnB,CAAC;IAEM,OAAO;QACV,IAAI,IAAI,CAAC,UAAU,IAAI,IAAI,EAAE,CAAC;YAC1B,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC;YAClC,OAAO,IAAI,CAAC,UAAU,CAAC;YAEvB,SAAS,EAAE,CAAC;QAChB,CAAC;IACL,CAAC;CACJ"}

View File

@@ -0,0 +1,43 @@
/**
* `DisposeAggregator` is a utility class that allows you to add multiple items and then dispose them all at once.
* You can add a function to call, an object with a `dispose` method, or an object with a `Symbol.dispose` method.
* To dispose all the items, call `dispose` or use the `Symbol.dispose` symbol.
*
* For example,
* ```typescript
* const disposeAggregator = new DisposeAggregator();
*
* const eventRelay = new EventRelay<string>();
* disposeAggregator.add(eventRelay);
*
* const eventRelay2 = disposeAggregator.add(new EventRelay<string>());
*
* disposeAggregator.dispose();
* console.log(eventRelay.disposed === true); // true
* console.log(eventRelay2.disposed === true); // true
* ```
*/
export declare class DisposeAggregator {
constructor();
/**
* Adds a target to be disposed.
* You can wrap the target with a `WeakRef` to prevent this class from holding a strong reference to the target.
*/
add<T extends DisposeAggregatorTarget>(target: T): T;
/**
* Disposes all the targets that have been added and clears the list of targets.
*/
dispose(): void;
[Symbol.dispose](): void;
get targetCount(): number;
}
export type DisposeAggregatorTarget = (() => void) | {
[Symbol.dispose](): void;
} | {
dispose(): void;
} | WeakRef<{
[Symbol.dispose](): void;
} | {
dispose(): void;
}>;
//# sourceMappingURL=DisposeAggregator.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"DisposeAggregator.d.ts","sourceRoot":"","sources":["../src/DisposeAggregator.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,iBAAiB;;IAU1B;;;OAGG;IACI,GAAG,CAAC,CAAC,SAAS,uBAAuB,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC;IAO3D;;OAEG;IACI,OAAO,IAAI,IAAI;IAuBf,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI;IAI/B,IAAW,WAAW,IAAI,MAAM,CAE/B;CAOJ;AAED,MAAM,MAAM,uBAAuB,GAAG,CAAC,MAAM,IAAI,CAAC,GAAG;IACjD,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI,CAAA;CAC3B,GAAG;IACA,OAAO,IAAI,IAAI,CAAA;CAClB,GAAG,OAAO,CAAC;IACR,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI,CAAA;CAC3B,GAAG;IACA,OAAO,IAAI,IAAI,CAAA;CAClB,CAAC,CAAC"}

71
node_modules/lifecycle-utils/dist/DisposeAggregator.js generated vendored Normal file
View File

@@ -0,0 +1,71 @@
import { DisposedError } from "./DisposedError.js";
/**
* `DisposeAggregator` is a utility class that allows you to add multiple items and then dispose them all at once.
* You can add a function to call, an object with a `dispose` method, or an object with a `Symbol.dispose` method.
* To dispose all the items, call `dispose` or use the `Symbol.dispose` symbol.
*
* For example,
* ```typescript
* const disposeAggregator = new DisposeAggregator();
*
* const eventRelay = new EventRelay<string>();
* disposeAggregator.add(eventRelay);
*
* const eventRelay2 = disposeAggregator.add(new EventRelay<string>());
*
* disposeAggregator.dispose();
* console.log(eventRelay.disposed === true); // true
* console.log(eventRelay2.disposed === true); // true
* ```
*/
export class DisposeAggregator {
/** @internal */ _targets = [];
/** @internal */ _disposed = false;
constructor() {
this.add = this.add.bind(this);
this.dispose = this.dispose.bind(this);
this[Symbol.dispose] = this[Symbol.dispose].bind(this);
}
/**
* Adds a target to be disposed.
* You can wrap the target with a `WeakRef` to prevent this class from holding a strong reference to the target.
*/
add(target) {
this._ensureNotDisposed();
this._targets.push(target);
return target;
}
/**
* Disposes all the targets that have been added and clears the list of targets.
*/
dispose() {
if (this._disposed)
return;
while (this._targets.length > 0) {
let disposeTarget = this._targets.shift();
if (typeof WeakRef !== "undefined" && disposeTarget instanceof WeakRef)
disposeTarget = disposeTarget.deref();
if (disposeTarget == null)
continue;
else if (Symbol.dispose != null && Symbol.dispose in disposeTarget && disposeTarget[Symbol.dispose] instanceof Function)
disposeTarget[Symbol.dispose]();
else if ("dispose" in disposeTarget && disposeTarget.dispose instanceof Function)
disposeTarget.dispose();
else if (disposeTarget instanceof Function)
disposeTarget();
}
this._disposed = true;
}
[Symbol.dispose]() {
this.dispose();
}
get targetCount() {
return this._targets.length;
}
/** @internal */
_ensureNotDisposed() {
if (this._disposed)
throw new DisposedError();
}
}
//# sourceMappingURL=DisposeAggregator.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"DisposeAggregator.js","sourceRoot":"","sources":["../src/DisposeAggregator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,oBAAoB,CAAC;AAEjD;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,OAAO,iBAAiB;IAC1B,gBAAgB,CAAkB,QAAQ,GAA8B,EAAE,CAAC;IAC3E,gBAAgB,CAAS,SAAS,GAAY,KAAK,CAAC;IAEpD;QACI,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC/B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACvC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC3D,CAAC;IAED;;;O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utils/dist/DisposedError.d.ts generated vendored Normal file
View File

@@ -0,0 +1,9 @@
/**
* This error is thrown when an object is disposed and a method is called on it.
* You can use this error to check if an error is caused by a disposed object.
* You can also use this error to throw when an object is disposed and a method is called on it.
*/
export declare class DisposedError extends Error {
constructor();
}
//# sourceMappingURL=DisposedError.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"DisposedError.d.ts","sourceRoot":"","sources":["../src/DisposedError.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,qBAAa,aAAc,SAAQ,KAAK;;CAIvC"}

11
node_modules/lifecycle-utils/dist/DisposedError.js generated vendored Normal file
View File

@@ -0,0 +1,11 @@
/**
* This error is thrown when an object is disposed and a method is called on it.
* You can use this error to check if an error is caused by a disposed object.
* You can also use this error to throw when an object is disposed and a method is called on it.
*/
export class DisposedError extends Error {
constructor() {
super("Object is disposed");
}
}
//# sourceMappingURL=DisposedError.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"DisposedError.js","sourceRoot":"","sources":["../src/DisposedError.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,OAAO,aAAc,SAAQ,KAAK;IACpC;QACI,KAAK,CAAC,oBAAoB,CAAC,CAAC;IAChC,CAAC;CACJ"}

47
node_modules/lifecycle-utils/dist/EventRelay.d.ts generated vendored Normal file
View File

@@ -0,0 +1,47 @@
/**
* A simple event relay.
* Create a listener with `createListener` and dispatch events with `dispatchEvent`.
* For each supported event type, create a new instance of `EventRelay` and expose it as a property.
*
* For example, this code:
* ```ts
* class MyClass {
* public readonly onSomethingHappened = new EventRelay<string>();
*
* public doSomething(whatToDo: string) {
* this.onSomethingHappened.dispatchEvent(whatToDo);
* console.log("Done notifying listeners");
* }
* }
*
* const myClass = new MyClass();
* myClass.onSomethingHappened.createListener((whatHappened) => {
* console.log(`Something happened: ${whatHappened}`);
* });
* myClass.doSomething("eat a cookie");
* ```
*
* Will print this:
* ```
* Something happened: eat a cookie
* Done notifying listeners
* ```
*/
export declare class EventRelay<T> {
constructor();
createListener(callback: ((data: T) => void)): EventRelayListenerHandle;
createOnceListener(callback: ((data: T) => void)): EventRelayListenerHandle;
dispatchEvent(data: T): void;
clearListeners(): void;
get listenerCount(): number;
get disposed(): boolean;
dispose(): void;
[Symbol.dispose](): void;
}
export declare class EventRelayListenerHandle {
private constructor();
dispose(): void;
[Symbol.dispose](): void;
get disposed(): boolean;
}
//# sourceMappingURL=EventRelay.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"EventRelay.d.ts","sourceRoot":"","sources":["../src/EventRelay.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,qBAAa,UAAU,CAAC,CAAC;;IAcd,cAAc,CAAC,QAAQ,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,CAAC;IAsB5C,kBAAkB,CAAC,QAAQ,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,CAAC;IAWhD,aAAa,CAAC,IAAI,EAAE,CAAC;IAUrB,cAAc;IAKrB,IAAW,aAAa,WAEvB;IAED,IAAW,QAAQ,YAElB;IAEM,OAAO;IAKP,CAAC,MAAM,CAAC,OAAO,CAAC;CAoB1B;AAED,qBAAa,wBAAwB;IAIjC,OAAO;IAOA,OAAO;IAOP,CAAC,MAAM,CAAC,OAAO,CAAC;IAIvB,IAAW,QAAQ,YAElB;CAMJ"}

132
node_modules/lifecycle-utils/dist/EventRelay.js generated vendored Normal file
View File

@@ -0,0 +1,132 @@
import { DisposedError } from "./DisposedError.js";
/**
* A simple event relay.
* Create a listener with `createListener` and dispatch events with `dispatchEvent`.
* For each supported event type, create a new instance of `EventRelay` and expose it as a property.
*
* For example, this code:
* ```ts
* class MyClass {
* public readonly onSomethingHappened = new EventRelay<string>();
*
* public doSomething(whatToDo: string) {
* this.onSomethingHappened.dispatchEvent(whatToDo);
* console.log("Done notifying listeners");
* }
* }
*
* const myClass = new MyClass();
* myClass.onSomethingHappened.createListener((whatHappened) => {
* console.log(`Something happened: ${whatHappened}`);
* });
* myClass.doSomething("eat a cookie");
* ```
*
* Will print this:
* ```
* Something happened: eat a cookie
* Done notifying listeners
* ```
*/
export class EventRelay {
/** @internal */ _listenerCallbacks;
/** @internal */ _disposed = false;
constructor() {
this._listenerCallbacks = new Map();
this.createListener = this.createListener.bind(this);
this.dispatchEvent = this.dispatchEvent.bind(this);
this.clearListeners = this.clearListeners.bind(this);
this.dispose = this.dispose.bind(this);
this[Symbol.dispose] = this[Symbol.dispose].bind(this);
}
createListener(callback) {
this._ensureNotDisposed();
const handle = EventRelayListenerHandle._create(() => {
const handles = this._listenerCallbacks.get(callback);
if (handles != null) {
handles.delete(handle);
if (handles.size === 0)
this._listenerCallbacks.delete(callback);
}
});
if (!this._listenerCallbacks.has(callback))
this._listenerCallbacks.set(callback, new Set());
this._listenerCallbacks.get(callback).add(handle);
return handle;
}
createOnceListener(callback) {
this._ensureNotDisposed();
const handle = this.createListener((data) => {
handle.dispose();
callback(data);
});
return handle;
}
dispatchEvent(data) {
for (const [listenerCallback] of Array.from(this._listenerCallbacks.entries())) {
try {
listenerCallback(data);
}
catch (err) {
console.error(err);
}
}
}
clearListeners() {
this._ensureNotDisposed();
this._clearListeners();
}
get listenerCount() {
return this._listenerCallbacks.size;
}
get disposed() {
return this._disposed;
}
dispose() {
this._clearListeners();
this._disposed = true;
}
[Symbol.dispose]() {
this.dispose();
}
/** @internal */
_clearListeners() {
for (const handles of Array.from(this._listenerCallbacks.values())) {
for (const handle of Array.from(handles)) {
handle.dispose();
}
}
this._listenerCallbacks.clear();
}
/** @internal */
_ensureNotDisposed() {
if (this._disposed)
throw new DisposedError();
}
}
export class EventRelayListenerHandle {
/** @internal */
_dispose;
constructor(dispose) {
this._dispose = dispose;
this.dispose = this.dispose.bind(this);
this[Symbol.dispose] = this[Symbol.dispose].bind(this);
}
dispose() {
if (this._dispose != null) {
this._dispose();
this._dispose = null;
}
}
[Symbol.dispose]() {
this.dispose();
}
get disposed() {
return this._dispose == null;
}
/** @internal */
static _create(dispose) {
return new EventRelayListenerHandle(dispose);
}
}
//# sourceMappingURL=EventRelay.js.map

1
node_modules/lifecycle-utils/dist/EventRelay.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"EventRelay.js","sourceRoot":"","sources":["../src/EventRelay.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,oBAAoB,CAAC;AAEjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,OAAO,UAAU;IACnB,gBAAgB,CAAkB,kBAAkB,CAA0D;IAC9G,gBAAgB,CAAS,SAAS,GAAY,KAAK,CAAC;IAEpD;QACI,IAAI,CAAC,kBAAkB,GAAG,IAAI,GAAG,EAAsD,CAAC;QAExF,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACrD,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACnD,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACrD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACvC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC3D,CAAC;IAEM,cAAc,CAAC,QAA6B;QAC/C,IAAI,CAAC,kBAAkB,EAAE,CAAC;QAE1B,MAAM,MAAM,GAAG,wBAAwB,CAAC,OAAO,CAAC,GAAG,EAAE;YACjD,MAAM,OAAO,GAAG,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YAEtD,IAAI,OAAO,IAAI,IAAI,EAAE,CAAC;gB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C;IACL,CAAC;IAEM,CAAC,MAAM,CAAC,OAAO,CAAC;QACnB,IAAI,CAAC,OAAO,EAAE,CAAC;IACnB,CAAC;IAED,IAAW,QAAQ;QACf,OAAO,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC;IACjC,CAAC;IAED,gBAAgB;IACT,MAAM,CAAC,OAAO,CAAC,OAAmB;QACrC,OAAO,IAAI,wBAAwB,CAAC,OAAO,CAAC,CAAC;IACjD,CAAC;CACJ"}

65
node_modules/lifecycle-utils/dist/LongTimeout.d.ts generated vendored Normal file
View File

@@ -0,0 +1,65 @@
/**
* A timeout that can be set to a delay longer than the maximum timeout delay supported by a regular `setTimeout`.
*
* For example,
* ```typescript
* import {LongTimeout} from "lifecycle-utils";
*
* const month = 1000 * 60 * 60 * 24 * 7 * 30;
*
* const timeout = new LongTimeout(() => {
* console.log("timeout");
* }, month);
*
* // to clear the timeout, call dispose
* // timeout.dispose();
* ```
*/
export declare class LongTimeout {
constructor(callback: () => void, delay: number);
dispose(): void;
[Symbol.dispose](): void;
get disposed(): boolean;
}
/**
* Sets a timeout that can also be set to a delay longer than the maximum timeout delay supported by a regular `setTimeout`.
* You can use `clearLongTimeout` to clear the timeout.
*
* For example,
* ```typescript
* import {setLongTimeout, clearLongTimeout} from "lifecycle-utils";
*
* const month = 1000 * 60 * 60 * 24 * 7 * 30;
*
* const timeout = setLongTimeout(() => {
* console.log("timeout");
* }, month);
*
* // to clear the timeout, call clearLongTimeout
* // clearLongTimeout(timeout);
* ```
*/
export declare function setLongTimeout(callback: () => void, delay: number): LongTimeout;
/**
* Clears a timeout that was set with `setLongTimeout`.
* You can also clear a regular timeout with this function.
*
* For example,
* ```typescript
* import {setLongTimeout, clearLongTimeout} from "lifecycle-utils";
*
* const month = 1000 * 60 * 60 * 24 * 7 * 30;
*
* const timeout = setLongTimeout(() => {
* console.log("timeout");
* }, month);
* const timeout2 = setTimeout(() => {
* console.log("timeout2");
* }, 1000 * 60);
*
* clearLongTimeout(timeout);
* clearLongTimeout(timeout2);
* ```
*/
export declare function clearLongTimeout(timeout: LongTimeout | number | undefined | null | ReturnType<typeof setTimeout>): void;
//# sourceMappingURL=LongTimeout.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"LongTimeout.d.ts","sourceRoot":"","sources":["../src/LongTimeout.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,WAAW;gBAMD,QAAQ,EAAE,MAAM,IAAI,EAAE,KAAK,EAAE,MAAM;IAS/C,OAAO;IAQP,CAAC,MAAM,CAAC,OAAO,CAAC;IAIvB,IAAW,QAAQ,YAElB;CAcJ;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG,WAAW,CAE/E;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,UAAU,CAAC,OAAO,UAAU,CAAC,QAQhH"}

106
node_modules/lifecycle-utils/dist/LongTimeout.js generated vendored Normal file
View File

@@ -0,0 +1,106 @@
const maxTimeoutDelay = 2147483647;
/**
* A timeout that can be set to a delay longer than the maximum timeout delay supported by a regular `setTimeout`.
*
* For example,
* ```typescript
* import {LongTimeout} from "lifecycle-utils";
*
* const month = 1000 * 60 * 60 * 24 * 7 * 30;
*
* const timeout = new LongTimeout(() => {
* console.log("timeout");
* }, month);
*
* // to clear the timeout, call dispose
* // timeout.dispose();
* ```
*/
export class LongTimeout {
/** @internal */ _callback;
/** @internal */ _startTime;
/** @internal */ _delay;
/** @internal */ _timeout;
constructor(callback, delay) {
this._callback = callback;
this._delay = delay;
this._startTime = Date.now();
this._onTimeout = this._onTimeout.bind(this);
this._timeout = setTimeout(this._onTimeout, Math.floor(Math.max(0, Math.min(delay, maxTimeoutDelay))));
}
dispose() {
if (this._timeout == null)
return;
clearTimeout(this._timeout);
this._timeout = undefined;
}
[Symbol.dispose]() {
this.dispose();
}
get disposed() {
return this._timeout == null;
}
/** @internal */
_onTimeout() {
const currentTime = Date.now();
const timePassed = currentTime - this._startTime;
const timeLeft = this._delay - timePassed;
if (timeLeft <= 0) {
this._timeout = undefined;
this._callback();
}
else
this._timeout = setTimeout(this._onTimeout, Math.min(timeLeft, maxTimeoutDelay));
}
}
/**
* Sets a timeout that can also be set to a delay longer than the maximum timeout delay supported by a regular `setTimeout`.
* You can use `clearLongTimeout` to clear the timeout.
*
* For example,
* ```typescript
* import {setLongTimeout, clearLongTimeout} from "lifecycle-utils";
*
* const month = 1000 * 60 * 60 * 24 * 7 * 30;
*
* const timeout = setLongTimeout(() => {
* console.log("timeout");
* }, month);
*
* // to clear the timeout, call clearLongTimeout
* // clearLongTimeout(timeout);
* ```
*/
export function setLongTimeout(callback, delay) {
return new LongTimeout(callback, delay);
}
/**
* Clears a timeout that was set with `setLongTimeout`.
* You can also clear a regular timeout with this function.
*
* For example,
* ```typescript
* import {setLongTimeout, clearLongTimeout} from "lifecycle-utils";
*
* const month = 1000 * 60 * 60 * 24 * 7 * 30;
*
* const timeout = setLongTimeout(() => {
* console.log("timeout");
* }, month);
* const timeout2 = setTimeout(() => {
* console.log("timeout2");
* }, 1000 * 60);
*
* clearLongTimeout(timeout);
* clearLongTimeout(timeout2);
* ```
*/
export function clearLongTimeout(timeout) {
if (timeout == null)
return;
if (timeout instanceof LongTimeout)
timeout.dispose();
else
clearTimeout(timeout);
}
//# sourceMappingURL=LongTimeout.js.map

1
node_modules/lifecycle-utils/dist/LongTimeout.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"LongTimeout.js","sourceRoot":"","sources":["../src/LongTimeout.ts"],"names":[],"mappings":"AAAA,MAAM,eAAe,GAAG,UAAU,CAAC;AAEnC;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,OAAO,WAAW;IACpB,gBAAgB,CAAkB,SAAS,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AAS,EAAE,CAAC;QACrB,CAAC;;YACG,IAAI,CAAC,QAAQ,GAAG,UAAU,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC,CAAC;IACzF,CAAC;CACJ;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,cAAc,CAAC,QAAoB,EAAE,KAAa;IAC9D,OAAO,IAAI,WAAW,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;AAC5C,CAAC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAgF;IAC7G,IAAI,OAAO,IAAI,IAAI;QACf,OAAO;IAEX,IAAI,OAAO,YAAY,WAAW;QAC9B,OAAO,CAAC,OAAO,EAAE,CAAC;;QAElB,YAAY,CAAC,OAAO,CAAC,CAAC;AAC9B,CAAC"}

57
node_modules/lifecycle-utils/dist/MultiKeyMap.d.ts generated vendored Normal file
View File

@@ -0,0 +1,57 @@
/**
* A utility class that works like a `Map`, but accepts multiple values as the key for each value.
*/
export declare class MultiKeyMap<const Key extends readonly any[], const V> {
constructor(entries?: readonly (readonly [key: Key, value: V])[] | MultiKeyMap<Key, V> | ReadonlyMultiKeyMap<Key, V> | null);
/**
* Add or update a value for a given key.
*
* Time complexity: O(1), given that the length of the key is constant.
*/
set(key: Readonly<Key>, value: V): this;
/**
* Get a value for a given key.
*
* Time complexity: O(1), given that the length of the key is constant.
*/
get(key: Readonly<Key>): V | undefined;
/**
* Check if a value exists for a given key.
*
* Time complexity: O(1), given that the length of the key is constant.
*/
has(key: Readonly<Key>): boolean;
/**
* Delete the value for a given key.
*
* Time complexity: O(1), given that the length of the key is constant.
*/
delete(key: Readonly<Key>): boolean;
/**
* Clear all values from the map.
*/
clear(): void;
/**
* Get the number of entries in the map.
*/
get size(): number;
/**
* Get an iterator for all entries in the map.
*/
entries(): Generator<[key: Key, value: V]>;
/**
* Get an iterator for all keys in the map.
*/
keys(): Generator<Key>;
/**
* Get an iterator for all values in the map.
*/
values(): Generator<V>;
/**
* Call a function for each entry in the map.
*/
forEach(callbackfn: (value: V, key: Key, map: this) => void, thisArg?: any): void;
[Symbol.iterator](): Generator<[key: Key, value: V]>;
}
export type ReadonlyMultiKeyMap<Key extends readonly any[], V> = Omit<MultiKeyMap<Key, V>, "set" | "delete" | "clear">;
//# sourceMappingURL=MultiKeyMap.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"MultiKeyMap.d.ts","sourceRoot":"","sources":["../src/MultiKeyMap.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,qBAAa,WAAW,CAAC,KAAK,CAAC,GAAG,SAAS,SAAS,GAAG,EAAE,EAAE,KAAK,CAAC,CAAC;gBAK1D,OAAO,CAAC,EACJ,SAAS,CAAC,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,GAC1C,WAAW,CAAC,GAAG,EAAE,CAAC,CAAC,GACnB,mBAAmB,CAAC,GAAG,EAAE,CAAC,CAAC,GAC3B,IAAI;IAQZ;;;;OAIG;IACI,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI;IAwB9C;;;;OAIG;IACI,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,SAAS;IAgB7C;;;;OAIG;IACI,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,GAAG,CAAC,GAAG,OAAO;IAUvC;;;;OAIG;IACI,MAAM,CAAC,GAAG,EAAE,QAAQ,CAAC,GAAG,CAAC,GAAG,OAAO;IAgC1C;;OAEG;IACI,KAAK,IAAI,IAAI;IAKpB;;OAEG;IACH,IAAW,IAAI,IAAI,MAAM,CAExB;IAED;;OAEG;IACK,OAAO,IAAI,SAAS,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;IAKlD;;OAEG;IACK,IAAI,IAAI,SAAS,CAAC,GAAG,CAAC;IAK9B;;OAEG;IACK,MAAM,IAAI,SAAS,CAAC,CAAC,CAAC;IAK9B;;OAEG;IACI,OAAO,CAAC,UAAU,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,KAAK,IAAI,EAAE,OAAO,CAAC,EAAE,GAAG,GAAG,IAAI;IASjF,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,SAAS,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;CAG9D;AAED,MAAM,MAAM,mBAAmB,CAAC,GAAG,SAAS,SAAS,GAAG,EAAE,EAAE,CAAC,IAAI,IAAI,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,OAAO,CAAC,CAAC"}

142
node_modules/lifecycle-utils/dist/MultiKeyMap.js generated vendored Normal file
View File

@@ -0,0 +1,142 @@
const valueSymbol = Symbol();
/**
* A utility class that works like a `Map`, but accepts multiple values as the key for each value.
*/
export class MultiKeyMap {
/** @internal */ _map = new Map();
/** @internal */ _keys = new Map();
constructor(entries) {
if (entries != null) {
for (const [key, value] of entries)
this.set(key, value);
}
}
/**
* Add or update a value for a given key.
*
* Time complexity: O(1), given that the length of the key is constant.
*/
set(key, value) {
let map = this._map;
for (let i = 0; i < key.length; i++) {
const keyItem = key[i];
let nextMap = map.get(keyItem);
if (nextMap == null) {
nextMap = new Map();
map.set(keyItem, nextMap);
}
map = nextMap;
}
const valueKey = map.has(valueSymbol)
? map.get(valueSymbol)
: key.slice();
this._keys.set(valueKey, value);
map.set(valueSymbol, valueKey);
return this;
}
/**
* Get a value for a given key.
*
* Time complexity: O(1), given that the length of the key is constant.
*/
get(key) {
let map = this._map;
for (let i = 0; i < key.length && map != null; i++)
map = map.get(key[i]);
if (map == null)
return undefined;
const valueKey = map.get(valueSymbol);
if (valueKey == null)
return undefined;
return this._keys.get(valueKey);
}
/**
* Check if a value exists for a given key.
*
* Time complexity: O(1), given that the length of the key is constant.
*/
has(key) {
let map = this._map;
for (let i = 0; i < key.length && map != null; i++) {
map = map.get(key[i]);
}
return map != null && map.has(valueSymbol);
}
/**
* Delete the value for a given key.
*
* Time complexity: O(1), given that the length of the key is constant.
*/
delete(key) {
let map = this._map;
const stack = [];
for (let i = 0; i < key.length && map != null; i++) {
stack.push([map, key[i]]);
map = map.get(key[i]);
}
if (map == null)
return false;
const valueKey = map.get(valueSymbol);
if (valueKey == null)
return false;
map.delete(valueSymbol);
this._keys.delete(valueKey);
for (let i = stack.length - 1; i >= 0; i--) {
const [accessMap, accessKey] = stack[i];
if (map.size !== 0)
break;
accessMap.delete(accessKey);
map = accessMap;
}
return true;
}
/**
* Clear all values from the map.
*/
clear() {
this._map.clear();
this._keys.clear();
}
/**
* Get the number of entries in the map.
*/
get size() {
return this._keys.size;
}
/**
* Get an iterator for all entries in the map.
*/
*entries() {
for (const [key, value] of this._keys)
yield [key.slice(), value];
}
/**
* Get an iterator for all keys in the map.
*/
*keys() {
for (const key of this._keys.keys())
yield key.slice();
}
/**
* Get an iterator for all values in the map.
*/
*values() {
for (const value of this._keys.values())
yield value;
}
/**
* Call a function for each entry in the map.
*/
forEach(callbackfn, thisArg) {
for (const [key, value] of this.entries()) {
if (thisArg !== undefined)
callbackfn.call(thisArg, value, key, this);
else
callbackfn.call(this, value, key, this);
}
}
[Symbol.iterator]() {
return this.entries();
}
}
//# sourceMappingURL=MultiKeyMap.js.map

1
node_modules/lifecycle-utils/dist/MultiKeyMap.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"MultiKeyMap.js","sourceRoot":"","sources":["../src/MultiKeyMap.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,GAAG,MAAM,EAAE,CAAC;AAE7B;;GAEG;AACH,MAAM,OAAO,WAAW;IACpB,gBAAg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AAE;YAC/B,MAAM,GAAG,CAAC,KAAK,EAA2B,CAAC;IACnD,CAAC;IAED;;OAEG;IACI,CAAC,MAAM;QACV,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE;YACnC,MAAM,KAAK,CAAC;IACpB,CAAC;IAED;;OAEG;IACI,OAAO,CAAC,UAAmD,EAAE,OAAa;QAC7E,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC;YACxC,IAAI,OAAO,KAAK,SAAS;gBACrB,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;;gBAE3C,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;QAChD,CAAC;IACL,CAAC;IAEM,CAAC,MAAM,CAAC,QAAQ,CAAC;QACpB,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC;IAC1B,CAAC;CACJ"}

77
node_modules/lifecycle-utils/dist/ScopeExit.d.ts generated vendored Normal file
View File

@@ -0,0 +1,77 @@
/**
* The handle returned from `scopeExit` that allows calling or skipping the provided `onExit` function.
*
* Calling `.call()` will call the provided `onExit` function immediately, and prevent it from being called again.
*
* Calling `.skip()` will prevent the `onExit` function from being called.
*
* If neither `.call()` nor `.skip()` is called, the `onExit` function will be called automatically when the handle is disposed.
*/
export declare class ScopeExitHandle<const Callback extends (() => Promise<void> | void)> {
private constructor();
/** Whether the `onExit` function has been called */
get called(): boolean;
/** Whether the `onExit` function has been skipped */
get skipped(): boolean;
/**
* Call the `onExit` function immediately if it has not been called or skipped yet, and prevent it from being called again.
*/
call(): ReturnType<Callback> | void;
/** Prevent the `onExit` function from being called if it has not been called yet */
skip(): void;
[Symbol.dispose](): void;
[Symbol.asyncDispose](): Promise<void>;
}
/**
* Create a scope exit handle that will call the provided callback when disposed, to be used with `using` or `await using`.
*
* For example, this code:
* ```typescript
* import {scopeExit} from "lifecycle-utils";
*
* function example() {
* using exitHandle = scopeExit(() => {
* console.log("exiting scope");
* });
* console.log("inside scope");
* }
*
* async function asyncExample() {
* await using exitHandle = scopeExit(async () => {
* await new Promise((resolve) => setTimeout(resolve, 100));
* console.log("exiting async scope");
* });
* console.log("inside async scope");
* }
*
* example();
* console.log("example done");
* console.log()
*
* await asyncExample();
* console.log("asyncExample done");
* ```
*
* Will print this:
* ```
* inside scope
* exiting scope
* example done
*
* inside async scope
* exiting async scope
* asyncExample done
* ```
*/
export declare function scopeExit<const Callback extends (() => Promise<void> | void)>(onExit: Callback): ScopeExit<Callback>;
export type ScopeExit<Callback extends (() => Promise<void> | void)> = {
readonly called: boolean;
readonly skipped: boolean;
call(): ReturnType<Callback> | void;
skip(): void;
} & ((Promise<void> extends ReturnType<Callback> ? true : false) extends true ? {
[Symbol.asyncDispose](): Promise<void>;
} : {
[Symbol.dispose](): void;
});
//# sourceMappingURL=ScopeExit.d.ts.map

1
node_modules/lifecycle-utils/dist/ScopeExit.d.ts.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"ScopeExit.d.ts","sourceRoot":"","sources":["../src/ScopeExit.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,qBAAa,eAAe,CAAC,KAAK,CAAC,QAAQ,SAAS,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IAI5E,OAAO;IASP,oDAAoD;IACpD,IAAW,MAAM,YAEhB;IAED,qDAAqD;IACrD,IAAW,OAAO,YAEjB;IAED;;OAEG;IACI,IAAI,IAAI,UAAU,CAAC,QAAQ,CAAC,GAAG,IAAI;IAW1C,oFAAoF;IAC7E,IAAI;IAQJ,CAAC,MAAM,CAAC,OAAO,CAAC;IAIV,CAAC,MAAM,CAAC,YAAY,CAAC;CAQrC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,wBAAgB,SAAS,CAAC,KAAK,CAAC,QAAQ,SAAS,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,EACzE,MAAM,EAAE,QAAQ,GACjB,SAAS,CAAC,QAAQ,CAAC,CAErB;AAED,MAAM,MAAM,SAAS,CAAC,QAAQ,SAAS,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI;IACnE,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,IAAI,IAAI,UAAU,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC;IACpC,IAAI,IAAI,IAAI,CAAA;CACf,GAAG,CACA,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,UAAU,CAAC,QAAQ,CAAC,GAAG,IAAI,GAAG,KAAK,CAAC,SAAS,IAAI,GAClE;IAAC,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CAAC,GACxC;IAAC,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI,CAAA;CAAC,CACnC,CAAC"}

101
node_modules/lifecycle-utils/dist/ScopeExit.js generated vendored Normal file
View File

@@ -0,0 +1,101 @@
/**
* The handle returned from `scopeExit` that allows calling or skipping the provided `onExit` function.
*
* Calling `.call()` will call the provided `onExit` function immediately, and prevent it from being called again.
*
* Calling `.skip()` will prevent the `onExit` function from being called.
*
* If neither `.call()` nor `.skip()` is called, the `onExit` function will be called automatically when the handle is disposed.
*/
export class ScopeExitHandle {
/** @internal */ _onExit;
/** @internal */ _skipped;
constructor(onExit) {
this._onExit = onExit;
this.call = this.call.bind(this);
this.skip = this.skip.bind(this);
this[Symbol.dispose] = this[Symbol.dispose].bind(this);
this[Symbol.asyncDispose] = this[Symbol.asyncDispose].bind(this);
}
/** Whether the `onExit` function has been called */
get called() {
return this._onExit == null && this._skipped !== true;
}
/** Whether the `onExit` function has been skipped */
get skipped() {
return this._skipped === true;
}
/**
* Call the `onExit` function immediately if it has not been called or skipped yet, and prevent it from being called again.
*/
call() {
if (this._onExit != null) {
const onExit = this._onExit;
delete this._onExit;
return onExit();
}
return undefined;
}
/** Prevent the `onExit` function from being called if it has not been called yet */
skip() {
if (this._onExit == null)
return;
this._skipped = true;
delete this._onExit;
}
[Symbol.dispose]() {
this.call();
}
async [Symbol.asyncDispose]() {
await this.call();
}
/** @internal */
static _create(onExit) {
return new ScopeExitHandle(onExit);
}
}
/**
* Create a scope exit handle that will call the provided callback when disposed, to be used with `using` or `await using`.
*
* For example, this code:
* ```typescript
* import {scopeExit} from "lifecycle-utils";
*
* function example() {
* using exitHandle = scopeExit(() => {
* console.log("exiting scope");
* });
* console.log("inside scope");
* }
*
* async function asyncExample() {
* await using exitHandle = scopeExit(async () => {
* await new Promise((resolve) => setTimeout(resolve, 100));
* console.log("exiting async scope");
* });
* console.log("inside async scope");
* }
*
* example();
* console.log("example done");
* console.log()
*
* await asyncExample();
* console.log("asyncExample done");
* ```
*
* Will print this:
* ```
* inside scope
* exiting scope
* example done
*
* inside async scope
* exiting async scope
* asyncExample done
* ```
*/
export function scopeExit(onExit) {
return ScopeExitHandle._create(onExit);
}
//# sourceMappingURL=ScopeExit.js.map

1
node_modules/lifecycle-utils/dist/ScopeExit.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"ScopeExit.js","sourceRoot":"","sources":["../src/ScopeExit.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,OAAO,eAAe;IACxB,gBAAgB,CAAS,OAAO,CAAuB;IACvD,gBAAgB,CAAS,QAAQ,CAAQ;IAEzC,YAAoB,MAAgB;QAChC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QAEtB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACjC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,C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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,MAAM,UAAU,SAAS,CACrB,MAAgB;IAEhB,OAAO,eAAe,CAAC,OAAO,CAAW,MAAM,CAAwB,CAAC;AAC5E,CAAC"}

76
node_modules/lifecycle-utils/dist/State.d.ts generated vendored Normal file
View File

@@ -0,0 +1,76 @@
/**
* `State` is a utility class that allows you to hold a value and notify listeners when the value changes.
*/
export declare class State<T> {
/**
* @param defaultState
* @param [options]
* @param [options.queueEvents] - queue events to be dispatched in a microtask.
* If the state changes multiple times in the same microtask, only the last change will be dispatched.
* If the most recent value is the same as the previous value, no event will be dispatched.
* Set this to `false` to dispatch events immediately upon state changes.
*/
constructor(defaultState: T, { queueEvents }?: {
queueEvents?: boolean | undefined;
});
get state(): T;
set state(newState: T);
createChangeListener(callback: ((state: T, lastValue?: T) => void), callInstantlyWithCurrentState?: boolean): StateChangeListenerHandle;
clearChangeListeners(): void;
get changeListenerCount(): number;
/**
* Create a listener that listens to multiple states and calls the callback when any of the states change.
*
* For example,
* ```typescript
* import {State} from "lifecycle-utils";
*
* const valueState1 = new State<number>(6);
* const valueState2 = new State<string>("hello");
* const valueState3 = new State<boolean>(true);
*
* const eventHandle = State.createCombinedChangeListener([valueState1, valueState2, valueState3], (newValues, previousValues) => {
* console.log("new values:", newValues);
* console.log("previous values:", previousValues);
* });
*
* valueState1.state = 7;
* valueState2.state = "world";
* valueState3.state = false;
*
* // after a microtask, the listener will be called
* // to make event fire immediately upon change, disable the `queueEvents` option on the constructor
* await new Promise(resolve => setTimeout(resolve, 0));
* // will print:
* // new values: [7, "world", false]
* // previous values: [6, "hello", true]
*
* eventHandle.dispose();
* ```
* @param states
* @param callback
* @param [options]
* @param [options.callInstantlyWithCurrentState]
* @param [options.queueEvents] - queue events to be dispatched in a microtask.
* If the state changes multiple times in the same microtask, only the last change will be dispatched.
* If the most recent value is the same as the previous value, no event will be dispatched.
* Set this to `false` to dispatch events immediately upon state changes.
*/
static createCombinedChangeListener<const StatesObjects extends readonly State<any>[], const StateTypes = {
-readonly [Index in keyof StatesObjects]: TypeOfState<StatesObjects[Index]>;
}>(states: StatesObjects, callback: ((state: StateTypes, previousState: StateTypes | {
-readonly [Index in keyof StatesObjects]: undefined;
}) => void), { callInstantlyWithCurrentState, queueEvents }?: {
callInstantlyWithCurrentState?: boolean;
queueEvents?: boolean;
}): StateChangeListenerHandle;
}
export declare class StateChangeListenerHandle {
private constructor();
dispose(): void;
[Symbol.dispose](): void;
get disposed(): boolean;
}
type TypeOfState<T extends State<any>> = T extends State<infer S> ? S : never;
export {};
//# sourceMappingURL=State.d.ts.map

1
node_modules/lifecycle-utils/dist/State.d.ts.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"State.d.ts","sourceRoot":"","sources":["../src/State.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,KAAK,CAAC,CAAC;IAMhB;;;;;;;OAOG;gBACgB,YAAY,EAAE,CAAC,EAAE,EAAC,WAAkB,EAAC;;KAAK;IAW7D,IAAW,KAAK,IAAI,CAAC,CAEpB;IAED,IAAW,KAAK,CAAC,QAAQ,EAAE,CAAC,EAiB3B;IAEM,oBAAoB,CAAC,QAAQ,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE,SAAS,CAAC,EAAE,CAAC,KAAK,IAAI,CAAC,EAAE,6BAA6B,GAAE,OAAe;IAgBlH,oBAAoB;IAI3B,IAAW,mBAAmB,WAE7B;IAmBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAqCG;WACW,4BAA4B,CAAC,KAAK,CAAC,aAAa,SAAS,SAAS,KAAK,CAAC,GAAG,CAAC,EAAE,EAAE,KAAK,CAAC,UAAU,GAAG;QAC7G,CAAC,UAAU,KAAK,IAAI,MAAM,aAAa,GAAG,WAAW,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;KAC9E,EACG,MAAM,EAAE,aAAa,EACrB,QAAQ,EAAE,CAAC,CAAC,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,UAAU,GAAG;QAAC,CAAC,UAAU,KAAK,IAAI,MAAM,aAAa,GAAG,SAAS;KAAC,KAAK,IAAI,CAAC,EAC1H,EACI,6BAAqC,EACrC,WAAkB,EACrB,GAAE;QACC,6BAA6B,CAAC,EAAE,OAAO,CAAC;QACxC,WAAW,CAAC,EAAE,OAAO,CAAA;KACnB;CAqDb;AAED,qBAAa,yBAAyB;IAIlC,OAAO;IAOA,OAAO;IAOP,CAAC,MAAM,CAAC,OAAO,CAAC;IAIvB,IAAW,QAAQ,YAElB;CAMJ;AAED,KAAK,WAAW,CAAC,CAAC,SAAS,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC"}

180
node_modules/lifecycle-utils/dist/State.js generated vendored Normal file
View File

@@ -0,0 +1,180 @@
/**
* `State` is a utility class that allows you to hold a value and notify listeners when the value changes.
*/
export class State {
/** @internal */ _queueEvents;
/** @internal */ _listenerCallbacks;
/** @internal */ _state;
/** @internal */ _changeEventMicrotaskQueued;
/**
* @param defaultState
* @param [options]
* @param [options.queueEvents] - queue events to be dispatched in a microtask.
* If the state changes multiple times in the same microtask, only the last change will be dispatched.
* If the most recent value is the same as the previous value, no event will be dispatched.
* Set this to `false` to dispatch events immediately upon state changes.
*/
constructor(defaultState, { queueEvents = true } = {}) {
this._queueEvents = queueEvents;
this._listenerCallbacks = new Map();
this._state = defaultState;
this._changeEventMicrotaskQueued = false;
this.createChangeListener = this.createChangeListener.bind(this);
this.clearChangeListeners = this.clearChangeListeners.bind(this);
}
get state() {
return this._state;
}
set state(newState) {
if (this._state === newState)
return;
this._state = newState;
if (!this._queueEvents) {
this._dispatchChangeEvent(this._state);
}
else if (!this._changeEventMicrotaskQueued) {
this._changeEventMicrotaskQueued = true;
(globalThis.queueMicrotask || globalThis.setTimeout)(() => {
this._changeEventMicrotaskQueued = false;
this._dispatchChangeEvent(this._state);
});
}
}
createChangeListener(callback, callInstantlyWithCurrentState = false) {
this._listenerCallbacks.set(callback, this._state);
if (callInstantlyWithCurrentState) {
try {
callback(this._state, undefined);
}
catch (err) {
console.error(err);
}
}
return StateChangeListenerHandle._create(() => {
this._listenerCallbacks.delete(callback);
});
}
clearChangeListeners() {
this._listenerCallbacks.clear();
}
get changeListenerCount() {
return this._listenerCallbacks.size;
}
/** @internal */
_dispatchChangeEvent(newState) {
for (const [listenerCallback, lastValue] of Array.from(this._listenerCallbacks.entries())) {
if (lastValue === newState)
continue;
if (this._listenerCallbacks.has(listenerCallback))
this._listenerCallbacks.set(listenerCallback, newState);
try {
listenerCallback(newState, lastValue);
}
catch (err) {
console.error(err);
}
}
}
/**
* Create a listener that listens to multiple states and calls the callback when any of the states change.
*
* For example,
* ```typescript
* import {State} from "lifecycle-utils";
*
* const valueState1 = new State<number>(6);
* const valueState2 = new State<string>("hello");
* const valueState3 = new State<boolean>(true);
*
* const eventHandle = State.createCombinedChangeListener([valueState1, valueState2, valueState3], (newValues, previousValues) => {
* console.log("new values:", newValues);
* console.log("previous values:", previousValues);
* });
*
* valueState1.state = 7;
* valueState2.state = "world";
* valueState3.state = false;
*
* // after a microtask, the listener will be called
* // to make event fire immediately upon change, disable the `queueEvents` option on the constructor
* await new Promise(resolve => setTimeout(resolve, 0));
* // will print:
* // new values: [7, "world", false]
* // previous values: [6, "hello", true]
*
* eventHandle.dispose();
* ```
* @param states
* @param callback
* @param [options]
* @param [options.callInstantlyWithCurrentState]
* @param [options.queueEvents] - queue events to be dispatched in a microtask.
* If the state changes multiple times in the same microtask, only the last change will be dispatched.
* If the most recent value is the same as the previous value, no event will be dispatched.
* Set this to `false` to dispatch events immediately upon state changes.
*/
static createCombinedChangeListener(states, callback, { callInstantlyWithCurrentState = false, queueEvents = true } = {}) {
let changeEventMicrotaskQueued = false;
const getState = () => states.map((state) => state.state);
let lastDispatchState = getState();
const dispatchEvent = (onlyIfChanged = true, includeLastState = true) => {
const newState = getState();
const previousState = lastDispatchState;
if (onlyIfChanged &&
newState.every((value, index) => value === previousState[index]))
return;
lastDispatchState = newState;
try {
callback(newState, includeLastState
? previousState
: previousState.map(() => undefined));
}
catch (err) {
console.error(err);
}
};
const onChange = () => {
if (changeEventMicrotaskQueued)
return;
if (!queueEvents)
dispatchEvent();
else {
changeEventMicrotaskQueued = true;
(globalThis.queueMicrotask || globalThis.setTimeout)(() => {
changeEventMicrotaskQueued = false;
dispatchEvent();
});
}
};
const handlers = states.map((state) => state.createChangeListener(onChange, false));
if (callInstantlyWithCurrentState)
dispatchEvent(false, false);
return StateChangeListenerHandle._create(() => handlers.forEach((handler) => handler.dispose()));
}
}
export class StateChangeListenerHandle {
/** @internal */
_dispose;
constructor(dispose) {
this._dispose = dispose;
this.dispose = this.dispose.bind(this);
this[Symbol.dispose] = this[Symbol.dispose].bind(this);
}
dispose() {
if (this._dispose != null) {
this._dispose();
this._dispose = null;
}
}
[Symbol.dispose]() {
this.dispose();
}
get disposed() {
return this._dispose == null;
}
/** @internal */
static _create(dispose) {
return new StateChangeListenerHandle(dispose);
}
}
//# sourceMappingURL=State.js.map

1
node_modules/lifecycle-utils/dist/State.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"State.js","sourceRoot":"","sources":["../src/State.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,OAAO,KAAK;IACd,gBAAgB,CAAkB,YAAY,CAAU;IACxD,gBAAgB,CAAkB,kBAAkB,CAA8C;IAClG,gBAAgB,CAAS,MAAM,CAAI;IACnC,gBAAgB,CAAS,2BAA2B,CAAU;IAE9D;;;;;;;OAOG;IACH,YAAmB,YAAe,EAAE,EAAC,WAAW,GAAG,IAAI,EAAC,GAAG,EAAE;QACzD,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;QAChC,IAAI,CAAC,kBAAkB,GAAG,IAAI,GAAG,EAA2B,CAAC;QAE7D,IAAI,CAAC,MAAM,GAAG,YAAY,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K,EAAE,KAAK,CAAC,CAAC;QAEhC,OAAO,yBAAyB,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;IACrG,CAAC;CACJ;AAED,MAAM,OAAO,yBAAyB;IAClC,gBAAgB;IACR,QAAQ,CAAsB;IAEtC,YAAoB,OAAmB;QACnC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QAExB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACvC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC3D,CAAC;IAEM,OAAO;QACV,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,EAAE,CAAC;YACxB,IAAI,CAAC,QAAQ,EAAE,CAAC;YAChB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACzB,CAAC;IACL,CAAC;IAEM,CAAC,MAAM,CAAC,OAAO,CAAC;QACnB,IAAI,CAAC,OAAO,EAAE,CAAC;IACnB,CAAC;IAED,IAAW,QAAQ;QACf,OAAO,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC;IACjC,CAAC;IAED,gBAAgB;IACT,MAAM,CAAC,OAAO,CAAC,OAAmB;QACrC,OAAO,IAAI,yBAAyB,CAAC,OAAO,CAAC,CAAC;IAClD,CAAC;CACJ"}

60
node_modules/lifecycle-utils/dist/WeakValueMap.d.ts generated vendored Normal file
View File

@@ -0,0 +1,60 @@
/**
* A utility class that works like a `Map`,
* but does not keep strong references to the values (allowing them to be garbage collected).
*
* When a value is garbage collected, it is automatically removed from the map.
*/
export declare class WeakValueMap<const Key, const V extends object> {
constructor(entries?: readonly (readonly [key: Key, value: V])[] | Map<Key, V> | ReadonlyMap<Key, V> | WeakValueMap<Key, V> | ReadonlyWeakValueMap<Key, V> | null);
/**
* Add or update a value for a given key.
*
* Time complexity: O(1), given that the length of the key is constant.
*/
set(key: Readonly<Key>, value: V): this;
/**
* Get a value for a given key.
*
* Time complexity: O(1), given that the length of the key is constant.
*/
get(key: Readonly<Key>): V | undefined;
/**
* Check if a value exists for a given key.
*
* Time complexity: O(1), given that the length of the key is constant.
*/
has(key: Readonly<Key>): boolean;
/**
* Delete the value for a given key.
*
* Time complexity: O(1), given that the length of the key is constant.
*/
delete(key: Readonly<Key>): boolean;
/**
* Clear all values from the map.
*/
clear(): void;
/**
* Get the number of entries in the map.
*/
get size(): number;
/**
* Get an iterator for all entries in the map.
*/
entries(): Generator<[key: Key, value: V]>;
/**
* Get an iterator for all keys in the map.
*/
keys(): Generator<Key>;
/**
* Get an iterator for all values in the map.
*/
values(): Generator<V>;
/**
* Call a function for each entry in the map.
*/
forEach(callbackfn: (value: V, key: Key, map: this) => void, thisArg?: any): void;
[Symbol.iterator](): Generator<[key: Key, value: V]>;
}
export type ReadonlyWeakValueMap<Key, V extends object> = Omit<WeakValueMap<Key, V>, "set" | "delete" | "clear">;
//# sourceMappingURL=WeakValueMap.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"WeakValueMap.d.ts","sourceRoot":"","sources":["../src/WeakValueMap.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,qBAAa,YAAY,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,SAAS,MAAM;gBAInD,OAAO,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,GAChD,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,GACX,WAAW,CAAC,GAAG,EAAE,CAAC,CAAC,GACnB,YAAY,CAAC,GAAG,EAAE,CAAC,CAAC,GACpB,oBAAoB,CAAC,GAAG,EAAE,CAAC,CAAC,GAC5B,IAAI;IAQZ;;;;OAIG;IACI,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI;IAoB9C;;;;OAIG;IACI,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,SAAS;IAe7C;;;;OAIG;IACI,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,GAAG,CAAC,GAAG,OAAO;IAIvC;;;;OAIG;IACI,MAAM,CAAC,GAAG,EAAE,QAAQ,CAAC,GAAG,CAAC,GAAG,OAAO;IAa1C;;OAEG;IACI,KAAK,IAAI,IAAI;IASpB;;OAEG;IACH,IAAW,IAAI,IAAI,MAAM,CAExB;IAED;;OAEG;IACK,OAAO,IAAI,SAAS,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;IAQlD;;OAEG;IACK,IAAI,IAAI,SAAS,CAAC,GAAG,CAAC;IAK9B;;OAEG;IACK,MAAM,IAAI,SAAS,CAAC,CAAC,CAAC;IAK9B;;OAEG;IACI,OAAO,CAAC,UAAU,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,KAAK,IAAI,EAAE,OAAO,CAAC,EAAE,GAAG,GAAG,IAAI;IASjF,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,SAAS,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;CAU9D;AAED,MAAM,MAAM,oBAAoB,CAAC,GAAG,EAAE,CAAC,SAAS,MAAM,IAAI,IAAI,CAAC,YAAY,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,OAAO,CAAC,CAAC"}

138
node_modules/lifecycle-utils/dist/WeakValueMap.js generated vendored Normal file
View File

@@ -0,0 +1,138 @@
/**
* A utility class that works like a `Map`,
* but does not keep strong references to the values (allowing them to be garbage collected).
*
* When a value is garbage collected, it is automatically removed from the map.
*/
export class WeakValueMap {
/** @internal */ _map = new Map();
constructor(entries) {
if (entries != null) {
for (const [key, value] of entries)
this.set(key, value);
}
}
/**
* Add or update a value for a given key.
*
* Time complexity: O(1), given that the length of the key is constant.
*/
set(key, value) {
const currentWeakValue = this._map.get(key);
if (currentWeakValue != null) {
const currentValue = currentWeakValue.ref.deref();
if (currentValue != null)
currentWeakValue.tracker.unregister(currentValue);
}
const weakValue = {
ref: new WeakRef(value),
tracker: null // will be set below
};
weakValue.tracker = new FinalizationRegistry(this._finalize.bind(this, weakValue));
weakValue.tracker.register(value, key);
this._map.set(key, weakValue);
return this;
}
/**
* Get a value for a given key.
*
* Time complexity: O(1), given that the length of the key is constant.
*/
get(key) {
const weakValue = this._map.get(key);
if (weakValue == null)
return undefined;
const value = weakValue.ref.deref();
/* c8 ignore start */
if (value == null) {
this._map.delete(key);
return undefined;
} /* c8 ignore stop */
return value;
}
/**
* Check if a value exists for a given key.
*
* Time complexity: O(1), given that the length of the key is constant.
*/
has(key) {
return this.get(key) != null;
}
/**
* Delete the value for a given key.
*
* Time complexity: O(1), given that the length of the key is constant.
*/
delete(key) {
const weakValue = this._map.get(key);
if (weakValue == null)
return false;
const value = weakValue.ref.deref();
if (value != null)
weakValue.tracker.unregister(value);
this._map.delete(key);
return true;
}
/**
* Clear all values from the map.
*/
clear() {
for (const [, weakValue] of this._map.entries()) {
const value = weakValue.ref.deref();
if (value != null)
weakValue.tracker.unregister(value);
}
this._map.clear();
}
/**
* Get the number of entries in the map.
*/
get size() {
return this._map.size;
}
/**
* Get an iterator for all entries in the map.
*/
*entries() {
for (const [key, weakValue] of this._map.entries()) {
const value = weakValue.ref.deref();
if (value != null)
yield [key, value];
}
}
/**
* Get an iterator for all keys in the map.
*/
*keys() {
for (const [key] of this.entries())
yield key;
}
/**
* Get an iterator for all values in the map.
*/
*values() {
for (const [, value] of this.entries())
yield value;
}
/**
* Call a function for each entry in the map.
*/
forEach(callbackfn, thisArg) {
for (const [key, value] of this.entries()) {
if (thisArg !== undefined)
callbackfn.call(thisArg, value, key, this);
else
callbackfn.call(this, value, key, this);
}
}
[Symbol.iterator]() {
return this.entries();
}
/** @internal */
_finalize(value, key) {
const weakValue = this._map.get(key);
if (weakValue === value)
this._map.delete(key);
}
}
//# sourceMappingURL=WeakValueMap.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"WeakValueMap.js","sourceRoot":"","sources":["../src/WeakValueMap.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,OAAO,YAAY;IACrB,gBAAgB,CAAkB,IAAI,GAAG,IAAI,GAAG,EAA6B,CAAC;IAE9E,YACI,OAKQ;QAER,IAAI,OAAO,IAAI,IAAI,EAAE,CAAC;YAClB,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,OAAO;gBAC9B,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAC7B,CAAC;IACL,CAAC;IAED;;;;OAIG;IACI,GAAG,CAAC,GAAkB,EAAE,KAAQ;QACnC,MAAM,gBAAgB,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC5C,IAAI,gBAAgB,IAAI,IAAI,EAAE,CAAC;YAC3B,MAAM,YAAY,GAAG,gBAAgB,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC;YAElD,IAAI,YAAY,IAAI,IAAI;gBACpB,gBAAgB,CAAC,OAAO,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;QAC1D,CAAC;QAED,MAAM,SAAS,GAAyB;YACpC,GAAG,EAAE,IAAI,OAAO,CAAC,KAAK,CAAC;YACvB,OAAO,EAAE,IAAW,CAAC,oBAAoB;SAC5C,CAAC;QACF,SAAS,CAAC,OAAO,GAAG,IAAI,oBAAoB,CAAgB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC,C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AAC,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;QAChD,CAAC;IACL,CAAC;IAEM,CAAC,MAAM,CAAC,QAAQ,CAAC;QACpB,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC;IAC1B,CAAC;IAED,gBAAgB;IACR,SAAS,CAAC,KAA2B,EAAE,GAAkB;QAC7D,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACrC,IAAI,SAAS,KAAK,KAAK;YACnB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC9B,CAAC;CACJ"}

View File

@@ -0,0 +1,62 @@
import { MultiKeyMap, ReadonlyMultiKeyMap } from "./MultiKeyMap.js";
/**
* A utility class that works like a `Map`,
* but accepts multiple values as the key for each value,
* and does not keep strong references to the values (allowing them to be garbage collected).
*
* When a value is garbage collected, it is automatically removed from the map.
*/
export declare class WeakValueMultiKeyMap<const Key extends readonly any[], const V extends object> {
constructor(entries?: readonly (readonly [key: Key, value: V])[] | MultiKeyMap<Key, V> | ReadonlyMultiKeyMap<Key, V> | WeakValueMultiKeyMap<Key, V> | ReadonlyWeakValueMultiKeyMap<Key, V> | null);
/**
* Add or update a value for a given key.
*
* Time complexity: O(1), given that the length of the key is constant.
*/
set(key: Readonly<Key>, value: V): this;
/**
* Get a value for a given key.
*
* Time complexity: O(1), given that the length of the key is constant.
*/
get(key: Readonly<Key>): V | undefined;
/**
* Check if a value exists for a given key.
*
* Time complexity: O(1), given that the length of the key is constant.
*/
has(key: Readonly<Key>): boolean;
/**
* Delete the value for a given key.
*
* Time complexity: O(1), given that the length of the key is constant.
*/
delete(key: Readonly<Key>): boolean;
/**
* Clear all values from the map.
*/
clear(): void;
/**
* Get the number of entries in the map.
*/
get size(): number;
/**
* Get an iterator for all entries in the map.
*/
entries(): Generator<[key: Key, value: V]>;
/**
* Get an iterator for all keys in the map.
*/
keys(): Generator<Key>;
/**
* Get an iterator for all values in the map.
*/
values(): Generator<V>;
/**
* Call a function for each entry in the map.
*/
forEach(callbackfn: (value: V, key: Key, map: this) => void, thisArg?: any): void;
[Symbol.iterator](): Generator<[key: Key, value: V]>;
}
export type ReadonlyWeakValueMultiKeyMap<Key extends readonly any[], V extends object> = Omit<WeakValueMultiKeyMap<Key, V>, "set" | "delete" | "clear">;
//# sourceMappingURL=WeakValueMultiKeyMap.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"WeakValueMultiKeyMap.d.ts","sourceRoot":"","sources":["../src/WeakValueMultiKeyMap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAE,mBAAmB,EAAC,MAAM,kBAAkB,CAAC;AAElE;;;;;;GAMG;AACH,qBAAa,oBAAoB,CAAC,KAAK,CAAC,GAAG,SAAS,SAAS,GAAG,EAAE,EAAE,KAAK,CAAC,CAAC,SAAS,MAAM;gBAIlF,OAAO,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,GAChD,WAAW,CAAC,GAAG,EAAE,CAAC,CAAC,GACnB,mBAAmB,CAAC,GAAG,EAAE,CAAC,CAAC,GAC3B,oBAAoB,CAAC,GAAG,EAAE,CAAC,CAAC,GAC5B,4BAA4B,CAAC,GAAG,EAAE,CAAC,CAAC,GACpC,IAAI;IAQZ;;;;OAIG;IACI,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI;IAoB9C;;;;OAIG;IACI,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,SAAS;IAe7C;;;;OAIG;IACI,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,GAAG,CAAC,GAAG,OAAO;IAIvC;;;;OAIG;IACI,MAAM,CAAC,GAAG,EAAE,QAAQ,CAAC,GAAG,CAAC,GAAG,OAAO;IAa1C;;OAEG;IACI,KAAK,IAAI,IAAI;IASpB;;OAEG;IACH,IAAW,IAAI,IAAI,MAAM,CAExB;IAED;;OAEG;IACK,OAAO,IAAI,SAAS,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;IAQlD;;OAEG;IACK,IAAI,IAAI,SAAS,CAAC,GAAG,CAAC;IAK9B;;OAEG;IACK,MAAM,IAAI,SAAS,CAAC,CAAC,CAAC;IAK9B;;OAEG;IACI,OAAO,CAAC,UAAU,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,KAAK,IAAI,EAAE,OAAO,CAAC,EAAE,GAAG,GAAG,IAAI;IASjF,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,SAAS,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;CAU9D;AAED,MAAM,MAAM,4BAA4B,CACpC,GAAG,SAAS,SAAS,GAAG,EAAE,EAAE,CAAC,SAAS,MAAM,IAC5C,IAAI,CAAC,oBAAoB,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,OAAO,CAAC,CAAC"}

View File

@@ -0,0 +1,140 @@
import { MultiKeyMap } from "./MultiKeyMap.js";
/**
* A utility class that works like a `Map`,
* but accepts multiple values as the key for each value,
* and does not keep strong references to the values (allowing them to be garbage collected).
*
* When a value is garbage collected, it is automatically removed from the map.
*/
export class WeakValueMultiKeyMap {
/** @internal */ _map = new MultiKeyMap();
constructor(entries) {
if (entries != null) {
for (const [key, value] of entries)
this.set(key, value);
}
}
/**
* Add or update a value for a given key.
*
* Time complexity: O(1), given that the length of the key is constant.
*/
set(key, value) {
const currentWeakValue = this._map.get(key);
if (currentWeakValue != null) {
const currentValue = currentWeakValue.ref.deref();
if (currentValue != null)
currentWeakValue.tracker.unregister(currentValue);
}
const weakValue = {
ref: new WeakRef(value),
tracker: null // will be set below
};
weakValue.tracker = new FinalizationRegistry(this._finalize.bind(this, weakValue));
weakValue.tracker.register(value, key.slice());
this._map.set(key, weakValue);
return this;
}
/**
* Get a value for a given key.
*
* Time complexity: O(1), given that the length of the key is constant.
*/
get(key) {
const weakValue = this._map.get(key);
if (weakValue == null)
return undefined;
const value = weakValue.ref.deref();
/* c8 ignore start */
if (value == null) {
this._map.delete(key);
return undefined;
} /* c8 ignore stop */
return value;
}
/**
* Check if a value exists for a given key.
*
* Time complexity: O(1), given that the length of the key is constant.
*/
has(key) {
return this.get(key) != null;
}
/**
* Delete the value for a given key.
*
* Time complexity: O(1), given that the length of the key is constant.
*/
delete(key) {
const weakValue = this._map.get(key);
if (weakValue == null)
return false;
const value = weakValue.ref.deref();
if (value != null)
weakValue.tracker.unregister(value);
this._map.delete(key);
return true;
}
/**
* Clear all values from the map.
*/
clear() {
for (const [, weakValue] of this._map.entries()) {
const value = weakValue.ref.deref();
if (value != null)
weakValue.tracker.unregister(value);
}
this._map.clear();
}
/**
* Get the number of entries in the map.
*/
get size() {
return this._map.size;
}
/**
* Get an iterator for all entries in the map.
*/
*entries() {
for (const [key, weakValue] of this._map.entries()) {
const value = weakValue.ref.deref();
if (value != null)
yield [key, value];
}
}
/**
* Get an iterator for all keys in the map.
*/
*keys() {
for (const [key] of this.entries())
yield key;
}
/**
* Get an iterator for all values in the map.
*/
*values() {
for (const [, value] of this.entries())
yield value;
}
/**
* Call a function for each entry in the map.
*/
forEach(callbackfn, thisArg) {
for (const [key, value] of this.entries()) {
if (thisArg !== undefined)
callbackfn.call(thisArg, value, key, this);
else
callbackfn.call(this, value, key, this);
}
}
[Symbol.iterator]() {
return this.entries();
}
/** @internal */
_finalize(value, key) {
const weakValue = this._map.get(key);
if (weakValue === value)
this._map.delete(key);
}
}
//# sourceMappingURL=WeakValueMultiKeyMap.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"WeakValueMultiKeyMap.js","sourceRoot":"","s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AAkB;QAC7D,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACrC,IAAI,SAAS,KAAK,KAAK;YACnB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC9B,CAAC;CACJ"}

15
node_modules/lifecycle-utils/dist/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,15 @@
export * from "./withLock.js";
export * from "./EventRelay.js";
export * from "./LongTimeout.js";
export * from "./State.js";
export * from "./DisposeAggregator.js";
export * from "./AsyncDisposeAggregator.js";
export * from "./DisposableHandle.js";
export * from "./AsyncDisposableHandle.js";
export * from "./MultiKeyMap.js";
export * from "./WeakValueMultiKeyMap.js";
export * from "./WeakValueMap.js";
export * from "./splitText.js";
export * from "./ScopeExit.js";
export * from "./DisposedError.js";
//# sourceMappingURL=index.d.ts.map

1
node_modules/lifecycle-utils/dist/index.d.ts.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,wBAAwB,CAAC;AACvC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,kBAAkB,CAAC;AACjC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC"}

15
node_modules/lifecycle-utils/dist/index.js generated vendored Normal file
View File

@@ -0,0 +1,15 @@
export * from "./withLock.js";
export * from "./EventRelay.js";
export * from "./LongTimeout.js";
export * from "./State.js";
export * from "./DisposeAggregator.js";
export * from "./AsyncDisposeAggregator.js";
export * from "./DisposableHandle.js";
export * from "./AsyncDisposableHandle.js";
export * from "./MultiKeyMap.js";
export * from "./WeakValueMultiKeyMap.js";
export * from "./WeakValueMap.js";
export * from "./splitText.js";
export * from "./ScopeExit.js";
export * from "./DisposedError.js";
//# sourceMappingURL=index.js.map

1
node_modules/lifecycle-utils/dist/index.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,wBAAwB,CAAC;AACvC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,kBAAkB,CAAC;AACjC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC"}

13
node_modules/lifecycle-utils/dist/splitText.d.ts generated vendored Normal file
View File

@@ -0,0 +1,13 @@
/**
* Split a text by multiple separators, and return a result of the text and separators.
* For example, `splitText("Hello <and> world [then] !", ["<and>", "[then]"])`
* will return `["Hello ", new Separator("<and>"), " world ", new Separator("[then]"), " !"]`
*/
export declare function splitText<const S extends string>(text: string, separators: readonly S[]): (string | {
[Sep in S]: Separator<Sep>;
}[S])[];
export declare class Separator<S extends string> {
readonly separator: S;
private constructor();
}
//# sourceMappingURL=splitText.d.ts.map

1
node_modules/lifecycle-utils/dist/splitText.d.ts.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"splitText.d.ts","sourceRoot":"","sources":["../src/splitText.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,KAAK,CAAC,CAAC,SAAS,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,CAAC,EAAE,GAAG,CAAC,MAAM,GAAG;KAAE,GAAG,IAAI,CAAC,GAAG,SAAS,CAAC,GAAG,CAAC;CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CA4FtI;AAED,qBAAa,SAAS,CAAC,CAAC,SAAS,MAAM;IACnC,SAAgB,SAAS,EAAE,CAAC,CAAC;IAE7B,OAAO;CAQV"}

102
node_modules/lifecycle-utils/dist/splitText.js generated vendored Normal file
View File

@@ -0,0 +1,102 @@
/**
* Split a text by multiple separators, and return a result of the text and separators.
* For example, `splitText("Hello <and> world [then] !", ["<and>", "[then]"])`
* will return `["Hello ", new Separator("<and>"), " world ", new Separator("[then]"), " !"]`
*/
export function splitText(text, separators) {
if (separators.length === 0)
return [text];
const separatorsFindTree = separatorsToFindTree(separators);
const activeChecks = [];
const textIndexToLowestSeparatorIndex = new Map();
const finalPartRanges = [];
for (let i = 0; i < text.length; i++) {
const char = text[i];
activeChecks.unshift({
currentNode: separatorsFindTree,
startIndex: i,
conflictedBy: []
});
let rangeToAdd = null;
for (let j = 0; j < activeChecks.length; j++) {
const activeCheck = activeChecks[j];
const nextNode = activeCheck.currentNode.next.get(char);
if (nextNode == null) {
activeChecks.splice(j, 1);
j--;
continue;
}
if (nextNode.separator != null && nextNode.separatorIndex != null) {
if (!textIndexToLowestSeparatorIndex.has(activeCheck.startIndex) ||
nextNode.separatorIndex < textIndexToLowestSeparatorIndex.get(activeCheck.startIndex))
textIndexToLowestSeparatorIndex.set(activeCheck.startIndex, nextNode.separatorIndex);
if (rangeToAdd == null || nextNode.separatorIndex < rangeToAdd.separatorIndex)
rangeToAdd = {
textStartIndex: activeCheck.startIndex,
separatorIndex: nextNode.separatorIndex,
conflictedBy: activeCheck.conflictedBy.slice()
};
}
activeCheck.currentNode = nextNode;
}
if (rangeToAdd != null) {
if (activeChecks.length > 0) {
for (const activeCheck of activeChecks) {
rangeToAdd.conflictedBy.push(activeCheck.startIndex);
activeCheck.conflictedBy.push(rangeToAdd.textStartIndex);
}
}
finalPartRanges.push(rangeToAdd);
}
}
const res = [];
let lastEndIndex = 0;
for (const range of finalPartRanges) {
const isConflicted = range.conflictedBy.some((textIndex) => {
const conflictedByIndexSeparatorIndex = textIndexToLowestSeparatorIndex.get(textIndex);
if (conflictedByIndexSeparatorIndex == null)
return false;
return conflictedByIndexSeparatorIndex < range.separatorIndex;
});
if (isConflicted)
continue;
if (lastEndIndex < range.textStartIndex)
res.push(text.slice(lastEndIndex, range.textStartIndex));
res.push(Separator._create(separators[range.separatorIndex]));
lastEndIndex = range.textStartIndex + separators[range.separatorIndex].length;
}
if (lastEndIndex < text.length)
res.push(text.slice(lastEndIndex));
if (res.length === 0 && text.length === 0)
res.push("");
return res;
}
export class Separator {
separator;
constructor(separator) {
this.separator = separator;
}
/** @internal */
static _create(separator) {
return new Separator(separator);
}
}
function separatorsToFindTree(separators) {
const root = { next: new Map() };
for (let i = 0; i < separators.length; i++) {
const separator = separators[i];
let node = root;
for (let j = 0; j < separator.length; j++) {
const char = separator[j];
if (!node.next.has(char))
node.next.set(char, { next: new Map() });
node = node.next.get(char);
}
if (node.separator == null) {
node.separator = separator;
node.separatorIndex = i;
}
}
return root;
}
//# sourceMappingURL=splitText.js.map

1
node_modules/lifecycle-utils/dist/splitText.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"splitText.js","sourceRoot":"","sources":["../src/splitText.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAyB,IAAY,EAAE,UAAwB;IACpF,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC;QACvB,OAAO,CAAC,IAAI,CAAC,CAAC;IAElB,MAAM,kBAAkB,GAAG,oBAAoB,CAAC,UAAU,CAAC,CAAC;IAC5D,MAAM,YAAY,GAAqB,EAAE,CAAC;IAC1C,MAAM,+BAA+B,GAAG,IAAI,GAAG,EAA6B,CAAC;IAC7E,MAAM,eAAe,GAIhB,EAAE,CAAC;IAER,KA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AC;YAE3C,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAE,CAAC;QAChC,CAAC;QAED,IAAI,IAAI,CAAC,SAAS,IAAI,IAAI,EAAE,CAAC;YACzB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;YAC3B,IAAI,CAAC,cAAc,GAAG,CAAC,CAAC;QAC5B,CAAC;IACL,CAAC;IAED,OAAO,IAAI,CAAC;AAChB,CAAC"}

View File

@@ -0,0 +1 @@
{"root":["../src/index.ts","../src/AsyncDisposableHandle.ts","../src/AsyncDisposeAggregator.ts","../src/DisposableHandle.ts","../src/DisposeAggregator.ts","../src/DisposedError.ts","../src/EventRelay.ts","../src/LongTimeout.ts","../src/MultiKeyMap.ts","../src/ScopeExit.ts","../src/State.ts","../src/WeakValueMap.ts","../src/WeakValueMultiKeyMap.ts","../src/splitText.ts","../src/withLock.ts"],"version":"5.9.3"}

35
node_modules/lifecycle-utils/dist/withLock.d.ts generated vendored Normal file
View File

@@ -0,0 +1,35 @@
/**
* Only allow one instance of the callback to run at a time for a given `scope` values.
*/
export declare function withLock<ReturnType, const Scope extends readonly any[]>(scope: ValidLockScope<Scope>, callback: () => Promise<ReturnType> | ReturnType): Promise<ReturnType>;
export declare function withLock<ReturnType, const Scope extends readonly any[]>(scope: ValidLockScope<Scope>, acquireLockSignal: AbortSignal | undefined, callback: () => Promise<ReturnType> | ReturnType): Promise<ReturnType>;
/**
* Check if a lock is currently active for a given `scope` values.
*/
export declare function isLockActive<const Scope extends readonly any[]>(scope: ValidLockScope<Scope>): boolean;
/**
* Acquire a lock for a given `scope` values.
*/
export declare function acquireLock<const Scope extends readonly any[]>(scope: ValidLockScope<Scope>, acquireLockSignal?: AbortSignal): Promise<Lock<Scope>>;
/**
* Wait for a lock to be released for a given `scope` values.
*/
export declare function waitForLockRelease<const Scope extends readonly any[]>(scope: ValidLockScope<Scope>, signal?: AbortSignal): Promise<void>;
export type Lock<Scope extends readonly any[] = readonly any[]> = {
scope: Scope;
dispose(): void;
[Symbol.dispose](): void;
};
/**
* Ensure that the scope array contains at least one object, otherwise it will be `never`.
*/
export type ValidLockScope<T extends readonly unknown[] = readonly unknown[]> = IncludesObject<T> extends true ? Readonly<T & [...T]> : InvalidScopeError<"Scope array must include at least one object reference">;
type IncludesObject<T extends readonly unknown[]> = true extends ({
[K in keyof T]: readonly [T[K]] extends readonly [object] ? true : false;
}[keyof T]) ? true : false;
type InvalidScopeError<Message extends string> = readonly unknown[] & {
error: Message;
__error: never;
};
export {};
//# sourceMappingURL=withLock.d.ts.map

1
node_modules/lifecycle-utils/dist/withLock.d.ts.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"withLock.d.ts","sourceRoot":"","sources":["../src/withLock.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,wBAAsB,QAAQ,CAAC,UAAU,EAAE,KAAK,CAAC,KAAK,SAAS,SAAS,GAAG,EAAE,EACzE,KAAK,EAAE,cAAc,CAAC,KAAK,CAAC,EAC5B,QAAQ,EAAE,MAAM,OAAO,CAAC,UAAU,CAAC,GAAG,UAAU,GACjD,OAAO,CAAC,UAAU,CAAC,CAAC;AACvB,wBAAsB,QAAQ,CAAC,UAAU,EAAE,KAAK,CAAC,KAAK,SAAS,SAAS,GAAG,EAAE,EACzE,KAAK,EAAE,cAAc,CAAC,KAAK,CAAC,EAC5B,iBAAiB,EAAE,WAAW,GAAG,SAAS,EAC1C,QAAQ,EAAE,MAAM,OAAO,CAAC,UAAU,CAAC,GAAG,UAAU,GACjD,OAAO,CAAC,UAAU,CAAC,CAAC;AA4CvB;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,CAAC,KAAK,SAAS,SAAS,GAAG,EAAE,EAAE,KAAK,EAAE,cAAc,CAAC,KAAK,CAAC,GAAG,OAAO,CAEtG;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,CAAC,KAAK,SAAS,SAAS,GAAG,EAAE,EAC1D,KAAK,EAAE,cAA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0,0 +1,97 @@
import { MultiKeyMap } from "./MultiKeyMap.js";
const locks = new MultiKeyMap();
export async function withLock(scope, acquireLockSignalOrCallback, callback) {
let acquireLockSignal = undefined;
if (acquireLockSignalOrCallback instanceof AbortSignal)
acquireLockSignal = acquireLockSignalOrCallback;
else if (acquireLockSignalOrCallback != null)
callback = acquireLockSignalOrCallback;
if (callback == null)
throw new Error("callback is required");
if (acquireLockSignal?.aborted)
throw acquireLockSignal.reason;
const scopeClone = scope.slice();
let [queue, onDelete] = locks.get(scopeClone) || [];
if (queue != null && onDelete != null)
await createQueuePromise(queue, acquireLockSignal);
else {
queue = [];
onDelete = [];
locks.set(scopeClone, [queue, onDelete]);
}
try {
return await callback();
}
finally {
if (queue.length > 0)
queue.shift()();
else {
locks.delete(scopeClone);
while (onDelete.length > 0)
onDelete.shift()();
}
}
}
/**
* Check if a lock is currently active for a given `scope` values.
*/
export function isLockActive(scope) {
return locks.has(scope) ?? false;
}
/**
* Acquire a lock for a given `scope` values.
*/
export function acquireLock(scope, acquireLockSignal) {
return new Promise((accept, reject) => {
const scopeClone = scope.slice();
void withLock(scopeClone, acquireLockSignal, () => {
let releaseLock;
const promise = new Promise((accept) => {
releaseLock = accept;
});
accept({
scope: scopeClone,
dispose() {
releaseLock();
},
[Symbol.dispose]() {
releaseLock();
}
});
return promise;
})
.catch(reject);
});
}
/**
* Wait for a lock to be released for a given `scope` values.
*/
export async function waitForLockRelease(scope, signal) {
if (signal?.aborted)
throw signal.reason;
const [queue, onDelete] = locks.get(scope) ?? [];
if (queue == null || onDelete == null)
return;
await createQueuePromise(onDelete, signal);
}
function createQueuePromise(queue, signal) {
if (signal == null)
return new Promise((accept) => void queue.push(accept));
return new Promise((accept, reject) => {
function onAcquireLock() {
signal.removeEventListener("abort", onAbort);
accept();
}
const queueLength = queue.length;
function onAbort() {
const itemIndex = queue.lastIndexOf(onAcquireLock, queueLength);
if (itemIndex >= 0)
queue.splice(itemIndex, 1);
signal.removeEventListener("abort", onAbort);
reject(signal.reason);
}
queue.push(onAcquireLock);
signal.addEventListener("abort", onAbort);
});
}
//# sourceMappingURL=withLock.js.map

1
node_modules/lifecycle-utils/dist/withLock.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"withLock.js","sourceRoot":"","sources":["../src/withLock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,kBAAkB,CAAC;AAE7C,MAAM,KAAK,GAAG,IAAI,WAAW,EAA4D,CAAC;AAc1F,MAAM,CAAC,KAAK,UAAU,QAAQ,CAC1B,KAA4B,EAC5B,2BAA+F,EAC/F,QAAiD;IAEjD,IAAI,iBAAiB,GAA4B,SAAS,CAAC;IAE3D,IAAI,2BAA2B,YAAY,WAAW;QAClD,iBAAiB,GAAG,2BAA2B,CAAC;SAC/C,IAAI,2BAA2B,IAAI,IAAI;QACxC,QAAQ,GAAG,2BAA2B,CAAC;IAE3C,IAAI,QAAQ,IAAI,IAAI;QAChB,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;IAE5C,IAAI,iBAAiB,EAAE,OAAO;QAC1B,MAAM,iBAAiB,CAAC,MAAM,CAAC;IAEnC,MAAM,UAAU,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC;IAEjC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC;IACpD,IAAI,KAAK,IAAI,IAAI,IAAI,QAAQ,IAAI,IAAI;QACjC,MAAM,kBAAkB,CAAC,KAAK,EAAE,iBAAiB,CAAC,CAAC;SAClD,CAAC;QACF,KAAK,GAAG,EAAE,CAAC;QACX,QAAQ,GAAG,EAAE,CAAC;QACd,KAAK,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC;IAC7C,CAAC;IAED,IAAI,CAAC;QACD,OAAO,MAAM,QAAQ,EAAE,CAAC;IAC5B,CAAC;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description": "A set of general utilities for the lifecycle of a JS/TS project/library",
"main": "dist/index.js",
"type": "module",
"types": "./dist/index.d.ts",
"files": [
"dist/",
"package.json",
"README.md",
"LICENSE"
],
"exports": {
".": {
"import": "./dist/index.js",
"node": "./dist/index.js",
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
}
},
"scripts": {
"prepare": "node -e \"process.env.CI !== 'true' && console.log(require('husky').default())\"",
"prebuild": "rimraf ./dist ./tsconfig.tsbuildinfo",
"build": "tsc --build tsconfig.json --force",
"prewatch": "rimraf ./dist ./tsconfig.tsbuildinfo",
"watch": "tsc --build tsconfig.json --watch --force",
"test": "npm run test:typescript && npm run lint:eslint && npm run test:vitest",
"test:vitest": "vitest run ./test",
"test:vitest:interactive": "vitest watch ./test",
"test:typescript": "tsc --build tsconfig.json --dry --force",
"lint": "npm run lint:eslint",
"lint:eslint": "eslint --ext .js --ext .ts .",
"format": "npm run lint:eslint -- --fix",
"clean": "rm -rf ./node_modules ./dist ./tsconfig.tsbuildinfo ./docs-site",
"docs:build": "typedoc"
},
"repository": {
"type": "git",
"url": "git+https://github.com/giladgd/lifecycle-utils.git"
},
"keywords": [
"utils",
"lifecycle",
"typescript"
],
"author": "Gilad S.",
"license": "MIT",
"bugs": {
"url": "https://github.com/giladgd/lifecycle-utils/issues"
},
"homepage": "https://giladgd.github.io/lifecycle-utils/",
"devDependencies": {
"@commitlint/cli": "^19.8.1",
"@commitlint/config-conventional": "^19.8.1",
"@semantic-release/exec": "^7.1.0",
"@stylistic/eslint-plugin": "^5.7.1",
"@types/node": "^20.8.4",
"@vitest/coverage-v8": "^4.0.18",
"eslint": "^9.39.2",
"eslint-import-resolver-typescript": "^4.4.4",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-jsdoc": "^62.5.0",
"eslint-plugin-n": "^17.23.2",
"husky": "^9.1.7",
"rimraf": "^6.0.1",
"semantic-release": "^25.0.2",
"tslib": "^2.8.1",
"typedoc": "^0.28.16",
"typedoc-plugin-mdn-links": "^5.1.1",
"typescript": "^5.9.3",
"typescript-eslint": "^8.54.0",
"vitest": "^4.0.18"
}
}