shelving 1.145.2 → 1.145.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/db/ItemStore.d.ts +2 -2
- package/db/QueryStore.d.ts +2 -2
- package/package.json +7 -7
- package/sequence/LazyDeferredSequence.d.ts +2 -2
- package/util/base64.d.ts +3 -3
- package/util/bytes.d.ts +15 -8
- package/util/bytes.js +13 -6
- package/util/crypto.d.ts +2 -1
- package/util/jwt.d.ts +2 -2
- package/util/sequence.d.ts +2 -2
- package/util/start.d.ts +5 -5
package/db/ItemStore.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { BooleanStore } from "../store/BooleanStore.js";
|
|
|
2
2
|
import { OptionalDataStore } from "../store/DataStore.js";
|
|
3
3
|
import type { DataKey, Database } from "../util/data.js";
|
|
4
4
|
import type { Item } from "../util/item.js";
|
|
5
|
-
import type {
|
|
5
|
+
import type { StopCallback } from "../util/start.js";
|
|
6
6
|
import type { MemoryProvider } from "./MemoryProvider.js";
|
|
7
7
|
import type { AbstractProvider } from "./Provider.js";
|
|
8
8
|
/** Store a single item. */
|
|
@@ -22,5 +22,5 @@ export declare class ItemStore<T extends Database, K extends DataKey<T>> extends
|
|
|
22
22
|
/** Refresh this store if data in the cache is older than `maxAge` (in milliseconds). */
|
|
23
23
|
refreshStale(maxAge: number, provider?: AbstractProvider<T>): void;
|
|
24
24
|
/** Subscribe this store to a provider. */
|
|
25
|
-
connect(provider?: AbstractProvider<T>):
|
|
25
|
+
connect(provider?: AbstractProvider<T>): StopCallback;
|
|
26
26
|
}
|
package/db/QueryStore.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { ArrayStore } from "../store/ArrayStore.js";
|
|
|
2
2
|
import { BooleanStore } from "../store/BooleanStore.js";
|
|
3
3
|
import type { DataKey, Database } from "../util/data.js";
|
|
4
4
|
import type { Item, ItemQuery } from "../util/item.js";
|
|
5
|
-
import type {
|
|
5
|
+
import type { StopCallback } from "../util/start.js";
|
|
6
6
|
import type { MemoryProvider } from "./MemoryProvider.js";
|
|
7
7
|
import type { AbstractProvider } from "./Provider.js";
|
|
8
8
|
/** Store a set of multiple items. */
|
|
@@ -26,7 +26,7 @@ export declare class QueryStore<T extends Database, K extends DataKey<T>> extend
|
|
|
26
26
|
/** Refresh this store if data in the cache is older than `maxAge` (in milliseconds). */
|
|
27
27
|
refreshStale(maxAge: number): void;
|
|
28
28
|
/** Subscribe this store to a provider. */
|
|
29
|
-
connect(provider?: AbstractProvider<T>):
|
|
29
|
+
connect(provider?: AbstractProvider<T>): StopCallback;
|
|
30
30
|
/**
|
|
31
31
|
* Load more items after the last once.
|
|
32
32
|
* - Promise that needs to be handled.
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"state-management",
|
|
12
12
|
"query-builder"
|
|
13
13
|
],
|
|
14
|
-
"version": "1.145.
|
|
14
|
+
"version": "1.145.3",
|
|
15
15
|
"repository": "https://github.com/dhoulb/shelving",
|
|
16
16
|
"author": "Dave Houlbrooke <dave@shax.com>",
|
|
17
17
|
"license": "0BSD",
|
|
@@ -59,13 +59,13 @@
|
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@biomejs/biome": "^1.9.4",
|
|
61
61
|
"@google-cloud/firestore": "^7.11.3",
|
|
62
|
-
"@types/bun": "^1.2.
|
|
63
|
-
"@types/react": "^19.1.
|
|
64
|
-
"@types/react-dom": "^19.1.
|
|
62
|
+
"@types/bun": "^1.2.20",
|
|
63
|
+
"@types/react": "^19.1.11",
|
|
64
|
+
"@types/react-dom": "^19.1.7",
|
|
65
65
|
"firebase": "^11.10.0",
|
|
66
|
-
"react": "^19.1.
|
|
67
|
-
"react-dom": "^19.1.
|
|
68
|
-
"typescript": "^5.
|
|
66
|
+
"react": "^19.1.1",
|
|
67
|
+
"react-dom": "^19.1.1",
|
|
68
|
+
"typescript": "^5.9.2"
|
|
69
69
|
},
|
|
70
70
|
"peerDependencies": {
|
|
71
71
|
"@google-cloud/firestore": ">=7.0.0",
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type StartCallback } from "../util/start.js";
|
|
2
2
|
import { DeferredSequence } from "./DeferredSequence.js";
|
|
3
3
|
/** Deferred sequence of values that calls a `StartCallback` when it has iterators that are iterating, and calls the corresponding `StopCallback` when all iterators have finished. */
|
|
4
4
|
export declare class LazyDeferredSequence<T = void> extends DeferredSequence<T> implements Disposable {
|
|
5
5
|
private _iterating;
|
|
6
6
|
private _starter;
|
|
7
|
-
constructor(start:
|
|
7
|
+
constructor(start: StartCallback<[DeferredSequence<T>]>);
|
|
8
8
|
[Symbol.asyncIterator](): AsyncIterator<T, void, void>;
|
|
9
9
|
[Symbol.dispose](): void;
|
|
10
10
|
}
|
package/util/base64.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { type PossibleBytes } from "./bytes.js";
|
|
1
|
+
import { type Bytes, type PossibleBytes } from "./bytes.js";
|
|
2
2
|
/** Encode a string or binary data to Base64 string. */
|
|
3
3
|
export declare function encodeBase64(input: PossibleBytes, pad?: boolean): string;
|
|
4
4
|
/** Decode Base64 string to string (decodes Base64URL too). */
|
|
5
5
|
export declare function decodeBase64String(base64: string): string;
|
|
6
6
|
/** Decode URL-safe Base64 string to byte sequence (decodes Base64URL too). */
|
|
7
|
-
export declare function decodeBase64Bytes(base64: string):
|
|
7
|
+
export declare function decodeBase64Bytes(base64: string): Bytes;
|
|
8
8
|
/** Encode a string or binary data to URL-safe Base64 */
|
|
9
9
|
export declare function encodeBase64URL(input: PossibleBytes, pad?: boolean): string;
|
|
10
10
|
/** Decode a string from URL-safe Base64 (decodes Base64 too). */
|
|
11
11
|
export declare function decodeBase64URLString(base64: string): string;
|
|
12
12
|
/** Decode URL-safe Base64 string to byte sequence (decodes Base64 too). */
|
|
13
|
-
export declare function decodeBase64URLBytes(base64: string):
|
|
13
|
+
export declare function decodeBase64URLBytes(base64: string): Bytes;
|
package/util/bytes.d.ts
CHANGED
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
import type { AnyCaller } from "./function.js";
|
|
2
|
+
/** We store a sets of bytes as a `Uint8Array` byte sequence. */
|
|
3
|
+
export type Bytes = Uint8Array<ArrayBuffer>;
|
|
2
4
|
/** Types that can be converted to a `Uint8Array` byte sequence. */
|
|
3
|
-
export type PossibleBytes =
|
|
5
|
+
export type PossibleBytes = Bytes | ArrayBuffer | string;
|
|
6
|
+
/** Is an unknown value a set of bytes? */
|
|
7
|
+
export declare function isBytes(value: unknown): value is Bytes;
|
|
4
8
|
/** Assert that an unknown value is a `Uint8Array` byte sequence. */
|
|
5
|
-
export declare function assertBytes(value: unknown, min?: number, max?: number, caller?: AnyCaller): asserts value is
|
|
9
|
+
export declare function assertBytes(value: unknown, min?: number, max?: number, caller?: AnyCaller): asserts value is Bytes;
|
|
6
10
|
/**
|
|
7
|
-
* Convert an unknown value to a `Uint8Array
|
|
11
|
+
* Convert an unknown value to a `Uint8Array<ArrayBuffer>` byte sequence, or `undefined` if the value cannot be converted.
|
|
8
12
|
*
|
|
9
|
-
* -
|
|
10
|
-
* -
|
|
13
|
+
* - `Uint8Array` values are returned as-is (if backed by an `ArrayBuffer`) or copied to a new `Uint8Array` (if not).
|
|
14
|
+
* - `ArrayBuffer` instances are converted to `Uint8Array`
|
|
15
|
+
* - Strings are encoded as UTF-8 characters in a `Uint8Array`
|
|
11
16
|
* - Everything else returns `undefined`
|
|
12
17
|
*/
|
|
13
|
-
export declare function getBytes(value: unknown): Uint8Array | undefined;
|
|
14
|
-
/**
|
|
15
|
-
|
|
18
|
+
export declare function getBytes(value: unknown): Uint8Array<ArrayBuffer> | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* Convert a possible set of bytes to a `Uint8Array` byte sequence, or throw `RequiredError` if the value cannot be converted.
|
|
21
|
+
*/
|
|
22
|
+
export declare function requireBytes(value: PossibleBytes, min?: number, max?: number, caller?: AnyCaller): Uint8Array<ArrayBuffer>;
|
package/util/bytes.js
CHANGED
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
import { RequiredError } from "../error/RequiredError.js";
|
|
2
|
+
/** Is an unknown value a set of bytes? */
|
|
3
|
+
export function isBytes(value) {
|
|
4
|
+
return value instanceof Uint8Array && value.buffer instanceof ArrayBuffer;
|
|
5
|
+
}
|
|
2
6
|
/** Assert that an unknown value is a `Uint8Array` byte sequence. */
|
|
3
7
|
export function assertBytes(value, min = 0, max = Number.POSITIVE_INFINITY, caller = assertBytes) {
|
|
4
|
-
if (!(value
|
|
8
|
+
if (!isBytes(value) || value.length < min || value.length > max)
|
|
5
9
|
throw new RequiredError(`Value must be byte sequence${min > 0 || max < Number.POSITIVE_INFINITY ? ` with length between ${min} and ${max}` : ""}`, { received: value, caller });
|
|
6
10
|
}
|
|
7
11
|
/**
|
|
8
|
-
* Convert an unknown value to a `Uint8Array
|
|
12
|
+
* Convert an unknown value to a `Uint8Array<ArrayBuffer>` byte sequence, or `undefined` if the value cannot be converted.
|
|
9
13
|
*
|
|
10
|
-
* -
|
|
11
|
-
* -
|
|
14
|
+
* - `Uint8Array` values are returned as-is (if backed by an `ArrayBuffer`) or copied to a new `Uint8Array` (if not).
|
|
15
|
+
* - `ArrayBuffer` instances are converted to `Uint8Array`
|
|
16
|
+
* - Strings are encoded as UTF-8 characters in a `Uint8Array`
|
|
12
17
|
* - Everything else returns `undefined`
|
|
13
18
|
*/
|
|
14
19
|
export function getBytes(value) {
|
|
15
|
-
if (value
|
|
20
|
+
if (isBytes(value))
|
|
16
21
|
return value;
|
|
17
22
|
if (value instanceof ArrayBuffer)
|
|
18
23
|
return new Uint8Array(value);
|
|
@@ -20,7 +25,9 @@ export function getBytes(value) {
|
|
|
20
25
|
return new TextEncoder().encode(value);
|
|
21
26
|
return undefined;
|
|
22
27
|
}
|
|
23
|
-
/**
|
|
28
|
+
/**
|
|
29
|
+
* Convert a possible set of bytes to a `Uint8Array` byte sequence, or throw `RequiredError` if the value cannot be converted.
|
|
30
|
+
*/
|
|
24
31
|
export function requireBytes(value, min = 0, max = Number.POSITIVE_INFINITY, caller = requireBytes) {
|
|
25
32
|
const bytes = getBytes(value);
|
|
26
33
|
assertBytes(bytes, min, max, caller);
|
package/util/crypto.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { type Bytes } from "./bytes.js";
|
|
1
2
|
/** Get random bytes from the crypto API. */
|
|
2
|
-
export declare function getRandomBytes(length: number):
|
|
3
|
+
export declare function getRandomBytes(length: number): Bytes;
|
|
3
4
|
/**
|
|
4
5
|
* Hash a password using PBKDF2, generating a new salt, and return the combined salt$iterations$hash string.
|
|
5
6
|
*
|
package/util/jwt.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type PossibleBytes } from "./bytes.js";
|
|
1
|
+
import { type Bytes, type PossibleBytes } from "./bytes.js";
|
|
2
2
|
import type { Data } from "./data.js";
|
|
3
3
|
import type { AnyCaller } from "./function.js";
|
|
4
4
|
/**
|
|
@@ -15,7 +15,7 @@ export type TokenData = {
|
|
|
15
15
|
signature: string;
|
|
16
16
|
headerData: Data;
|
|
17
17
|
payloadData: Data;
|
|
18
|
-
signatureBytes:
|
|
18
|
+
signatureBytes: Bytes;
|
|
19
19
|
};
|
|
20
20
|
/**
|
|
21
21
|
* Split a JSON Web Token into its header, payload, and signature, and decode and parse the JSON.
|
package/util/sequence.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { AsyncValueCallback, ValueCallback } from "./callback.js";
|
|
2
2
|
import type { ErrorCallback } from "./callback.js";
|
|
3
3
|
import { STOP } from "./constants.js";
|
|
4
|
-
import type {
|
|
4
|
+
import type { StopCallback } from "./start.js";
|
|
5
5
|
/**
|
|
6
6
|
* Is a value an async iterable object?
|
|
7
7
|
* - Any object with a `Symbol.iterator` property is iterable.
|
|
@@ -15,4 +15,4 @@ export declare function repeatDelay(ms: number): AsyncIterable<number>;
|
|
|
15
15
|
/** Dispatch items in a sequence to a (possibly async) callback. */
|
|
16
16
|
export declare function callSequence<T>(sequence: AsyncIterable<T>, callback: AsyncValueCallback<T>): AsyncIterable<T>;
|
|
17
17
|
/** Pull values from a sequence until the returned function is called. */
|
|
18
|
-
export declare function runSequence<T>(sequence: AsyncIterable<T>, onNext?: ValueCallback<T>, onError?: ErrorCallback):
|
|
18
|
+
export declare function runSequence<T>(sequence: AsyncIterable<T>, onNext?: ValueCallback<T>, onError?: ErrorCallback): StopCallback;
|
package/util/start.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Arguments } from "./function.js";
|
|
2
2
|
/** Callback function that starts something with multiple values and returns an optional stop callback. */
|
|
3
|
-
export type
|
|
3
|
+
export type StartCallback<T extends Arguments = []> = (...values: T) => StopCallback | void;
|
|
4
4
|
/** Callback function that stops something. */
|
|
5
|
-
export type
|
|
5
|
+
export type StopCallback = () => void;
|
|
6
6
|
/**
|
|
7
7
|
* Wrapper class to handle state on start/stop callback process.
|
|
8
8
|
* - If process has already started, `starter.start()` won't be called twice (including if `start()` didn't return a `stop()` callback).
|
|
@@ -10,12 +10,12 @@ export type Stop = () => void;
|
|
|
10
10
|
export declare class Starter<T extends Arguments> implements Disposable {
|
|
11
11
|
private readonly _start;
|
|
12
12
|
private _stop;
|
|
13
|
-
constructor(start:
|
|
13
|
+
constructor(start: StartCallback<T>);
|
|
14
14
|
start(...values: T): void;
|
|
15
15
|
stop(): void;
|
|
16
16
|
[Symbol.dispose](): void;
|
|
17
17
|
}
|
|
18
18
|
/** Something that can be made into a `Starter` */
|
|
19
|
-
export type PossibleStarter<T extends Arguments> =
|
|
19
|
+
export type PossibleStarter<T extends Arguments> = StartCallback<T> | Starter<T>;
|
|
20
20
|
/** Get a `Starter` from a `PossibleStarter` */
|
|
21
|
-
export declare function getStarter<T extends Arguments>(start:
|
|
21
|
+
export declare function getStarter<T extends Arguments>(start: StartCallback<T> | Starter<T>): Starter<T>;
|