@ac-kit/browser 0.0.0-stage → 0.1.1

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.
Files changed (36) hide show
  1. package/CHANGELOG.md +67 -0
  2. package/LICENSE +28 -0
  3. package/README.md +187 -2
  4. package/dist/index.d.ts +7 -0
  5. package/dist/index.d.ts.map +1 -0
  6. package/dist/index.js +7 -0
  7. package/dist/index.js.map +1 -0
  8. package/dist/indexeddb/_indexed-db-request.d.ts +16 -0
  9. package/dist/indexeddb/_indexed-db-request.d.ts.map +1 -0
  10. package/dist/indexeddb/_indexed-db-request.js +45 -0
  11. package/dist/indexeddb/_indexed-db-request.js.map +1 -0
  12. package/dist/indexeddb/indexed-db-error.d.ts +9 -0
  13. package/dist/indexeddb/indexed-db-error.d.ts.map +1 -0
  14. package/dist/indexeddb/indexed-db-error.js +12 -0
  15. package/dist/indexeddb/indexed-db-error.js.map +1 -0
  16. package/dist/indexeddb/indexed-db-records.d.ts +95 -0
  17. package/dist/indexeddb/indexed-db-records.d.ts.map +1 -0
  18. package/dist/indexeddb/indexed-db-records.js +121 -0
  19. package/dist/indexeddb/indexed-db-records.js.map +1 -0
  20. package/dist/indexeddb/open-indexed-db.d.ts +68 -0
  21. package/dist/indexeddb/open-indexed-db.d.ts.map +1 -0
  22. package/dist/indexeddb/open-indexed-db.js +102 -0
  23. package/dist/indexeddb/open-indexed-db.js.map +1 -0
  24. package/dist/web-midi/web-midi-access.d.ts +54 -0
  25. package/dist/web-midi/web-midi-access.d.ts.map +1 -0
  26. package/dist/web-midi/web-midi-access.js +78 -0
  27. package/dist/web-midi/web-midi-access.js.map +1 -0
  28. package/dist/web-midi/web-midi-inputs.d.ts +81 -0
  29. package/dist/web-midi/web-midi-inputs.d.ts.map +1 -0
  30. package/dist/web-midi/web-midi-inputs.js +107 -0
  31. package/dist/web-midi/web-midi-inputs.js.map +1 -0
  32. package/dist/xhr/send-with-progress.d.ts +96 -0
  33. package/dist/xhr/send-with-progress.d.ts.map +1 -0
  34. package/dist/xhr/send-with-progress.js +132 -0
  35. package/dist/xhr/send-with-progress.js.map +1 -0
  36. package/package.json +64 -3
package/CHANGELOG.md ADDED
@@ -0,0 +1,67 @@
1
+ # @ac-kit/browser
2
+
3
+ ## 0.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [5152230]
8
+ - Updated dependencies [2a0fe74]
9
+ - Updated dependencies [2a0fe74]
10
+ - Updated dependencies [5152230]
11
+ - Updated dependencies [2a0fe74]
12
+ - Updated dependencies [5152230]
13
+ - Updated dependencies [5152230]
14
+ - Updated dependencies [2a0fe74]
15
+ - Updated dependencies [2a0fe74]
16
+ - Updated dependencies [5152230]
17
+ - Updated dependencies [5152230]
18
+ - Updated dependencies [5152230]
19
+ - Updated dependencies [5152230]
20
+ - Updated dependencies [5152230]
21
+ - Updated dependencies [5152230]
22
+ - Updated dependencies [5152230]
23
+ - @ac-kit/async@0.6.0
24
+ - @ac-kit/core@0.10.0
25
+
26
+ ## 0.1.0
27
+
28
+ ### Minor Changes
29
+
30
+ - 20341eb: New `@ac-kit/browser`, browser-bound: browser extensions and zero-dependency
31
+ wrappers over browser APIs, the counterpart of `@ac-kit/node`. It reads no
32
+ browser global: each function takes the `indexedDB`, `navigator`, `MIDIAccess`
33
+ or `XMLHttpRequest` it works through.
34
+
35
+ - IndexedDB as promises. `openIndexedDb({ factory, name, version, upgrade,
36
+ onBlocked?, onVersionChange?, signal? })` opens a database, upgrading it
37
+ version by version, and closes it for a newer version opened elsewhere.
38
+ `createIndexedDbRecords(database, storeName, { durability? })` reads and
39
+ writes an object store by key — `get`, `getAll` and `count` (optionally
40
+ within a key range, in key order), `putAll`, `deleteAll` and `clear` — each
41
+ call one transaction. `openIndexedDbRecords` opens a database of one store
42
+ and returns its records, disposable. Every failure, a key IndexedDB cannot
43
+ hold or a value it cannot clone included, rejects with `IndexedDbError`,
44
+ IndexedDB's `DOMException` as the cause.
45
+ - Web MIDI. `queryWebMidiPermission` answers whether the page may reach the
46
+ devices without asking (or `"unsupported"`); `requestWebMidiAccess` asks for
47
+ them — SysEx and software ports only when told — failing with
48
+ `WebMidiUnsupportedError` or `WebMidiDeniedError`. `WebMidiInputs` lists the
49
+ input ports and follows one by name and manufacturer across reloads and
50
+ hot-plugs, emitting each message's raw bytes with its arrival time and port,
51
+ for `@ac-kit/format-midi`'s decoder. `isSameMidiPort` compares two port
52
+ identities.
53
+ - Upload progress. `sendWithProgress(XMLHttpRequest, request)` sends a request
54
+ through the `XMLHttpRequest` class it is given, reporting `{ loaded, total }`
55
+ as its body is sent (`onUploadProgress`) and its response received
56
+ (`onDownloadProgress`), which `fetch` cannot. It resolves with the response
57
+ whatever its status — status, status text, `Headers`, final URL and the body
58
+ as text, bytes or a `Blob` — rejects with `HttpNetworkError` (a `TypeError`)
59
+ when no response came, with the signal's reason when aborted, and with the
60
+ error of a method, URL or field refused, nothing sent.
61
+
62
+ ### Patch Changes
63
+
64
+ - Updated dependencies [20341eb]
65
+ - Updated dependencies [20341eb]
66
+ - @ac-kit/async@0.5.0
67
+ - @ac-kit/core@0.9.0
package/LICENSE ADDED
@@ -0,0 +1,28 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2024-2026 Anthony Champagne and contributors
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ 3. Neither the name of the copyright holder nor the names of its
16
+ contributors may be used to endorse or promote products derived from
17
+ this software without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package/README.md CHANGED
@@ -1,3 +1,188 @@
1
- # Temporary Holding Version
1
+ # @ac-kit/browser
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Browser extensions and zero-dependency wrappers over browser APIs, the
4
+ browser's counterpart of `@ac-kit/node`: IndexedDB as promises, with versioned
5
+ upgrades; Web MIDI, with access asked for and the input port a person chose
6
+ followed by its name across reloads and hot-plugs; and requests over
7
+ `XMLHttpRequest` that report their upload progress, which `fetch` cannot.
8
+
9
+ Every function takes the browser object it works through — `indexedDB`,
10
+ `navigator`, a `MIDIAccess`, `XMLHttpRequest` — rather than reading a global,
11
+ so it also runs in tests against a stand-in such as `fake-indexeddb`.
12
+
13
+ ## IndexedDB
14
+
15
+ ```ts
16
+ import {
17
+ createIndexedDbRecords,
18
+ openIndexedDb,
19
+ openIndexedDbRecords,
20
+ } from "@ac-kit/browser";
21
+
22
+ // One store is all the page keeps.
23
+ using settings = await openIndexedDbRecords<string, unknown>({
24
+ factory: indexedDB,
25
+ name: "settings",
26
+ storeName: "values",
27
+ });
28
+ await settings.putAll([{ key: "theme", value: "dark" }]);
29
+
30
+ // Several stores, and a schema that changes.
31
+ const database = await openIndexedDb({
32
+ factory: indexedDB,
33
+ name: "practice",
34
+ version: 2,
35
+ upgrade: ({ database, oldVersion }) => {
36
+ if (oldVersion < 1) {
37
+ database.createObjectStore("songs");
38
+ }
39
+ if (oldVersion < 2) {
40
+ database.createObjectStore("sessions");
41
+ }
42
+ },
43
+ onVersionChange: () => showReloadPrompt(),
44
+ });
45
+ const songs = createIndexedDbRecords<string, Song>(database, "songs");
46
+ const all = await songs.getAll();
47
+ ```
48
+
49
+ - `openIndexedDb` — a database at a version, `upgrade` bringing it there from
50
+ the version it had (`0` when new), synchronously, in the upgrade's own
51
+ transaction; what it throws aborts the upgrade and fails the opening. When
52
+ another page holds an older version open, `onBlocked` is told and the
53
+ opening waits, as long as `signal` lets it. When another page opens a newer
54
+ version, the database is closed so that page's upgrade can run, and
55
+ `onVersionChange` is told.
56
+ - `createIndexedDbRecords` — the records of one object store holding its keys
57
+ apart from its values: `get`, `getAll` and `count` (all, or within an
58
+ `IDBKeyRange`, in key order), `putAll`, `deleteAll` (by key or range) and
59
+ `clear`, each in one transaction, so a batch is written whole or not at all.
60
+ `durability` chooses how hard writes are pushed to disk.
61
+ - `openIndexedDbRecords` — both at once, for a database holding one store,
62
+ created at first use; disposing the records closes the database.
63
+ - `IndexedDbError` — the browser has no IndexedDB (some private modes), the
64
+ database cannot be opened, or a request or transaction failed — a key it
65
+ cannot hold, a value it cannot clone included; IndexedDB's `DOMException` is
66
+ its `cause`, named `QuotaExceededError` when storage ran out. What an
67
+ iterable given to `putAll` or `deleteAll` throws goes through as it is, and
68
+ nothing of that batch is written.
69
+
70
+ Values are kept as the structured clone algorithm copies them and come back
71
+ typed as the caller says, unchecked: check them when another version of the
72
+ page may have written them. `getAll` holds what it returns in memory, linear
73
+ in the records.
74
+
75
+ ## Web MIDI
76
+
77
+ ```ts
78
+ import { MidiMessageDecoder } from "@ac-kit/format-midi";
79
+ import {
80
+ queryWebMidiPermission,
81
+ requestWebMidiAccess,
82
+ WebMidiInputs,
83
+ } from "@ac-kit/browser";
84
+
85
+ if ((await queryWebMidiPermission(navigator)) !== "unsupported") {
86
+ const inputs = new WebMidiInputs(await requestWebMidiAccess(navigator));
87
+ // One decoder per port: it keeps the stream's running status.
88
+ const decoders = new Map<string, MidiMessageDecoder>();
89
+ inputs.subscribe("message", (data, time, port) => {
90
+ let decoder = decoders.get(port.id);
91
+ if (decoder === undefined) {
92
+ decoder = new MidiMessageDecoder();
93
+ decoders.set(port.id, decoder);
94
+ }
95
+ for (let bytes = data; bytes.length > 0; ) {
96
+ const result = decoder.decode(bytes);
97
+ if (
98
+ result.status === "incomplete" ||
99
+ result.status === "pending" ||
100
+ result.status === "fatal"
101
+ ) {
102
+ break;
103
+ }
104
+ if (result.status === "decoded") {
105
+ play(result.value, time);
106
+ }
107
+ bytes = bytes.subarray(result.consumed);
108
+ }
109
+ });
110
+ inputs.subscribe("connection", (isConnected) => showConnected(isConnected));
111
+ inputs.follow({ name: "Keystation 49", manufacturer: "M-Audio" });
112
+ }
113
+ ```
114
+
115
+ - `queryWebMidiPermission(navigator, { sysex? })` — whether the page may reach
116
+ the devices without asking: `"granted"`, `"prompt"` (also when the browser
117
+ cannot say), `"denied"`, or `"unsupported"` without Web MIDI.
118
+ - `requestWebMidiAccess(navigator, { sysex?, software? })` — the browser's
119
+ `MIDIAccess`, after it asked the user if it does. System Exclusive messages
120
+ and software ports are asked for only when told. Fails with
121
+ `WebMidiUnsupportedError` without Web MIDI and `WebMidiDeniedError` when
122
+ refused.
123
+ - `WebMidiInputs` — the input ports (`ports`: id, name, manufacturer,
124
+ connected or not) and the one followed by its identity: listened to while
125
+ connected, given up when unplugged or gone from the list, taken up again
126
+ when it comes back under any id. Events: `ports` when the list changes,
127
+ `connection` when the followed port comes or goes, and `message` with each
128
+ event's bytes as the browser delivered them (one whole message, a SysEx
129
+ included), its `timeStamp` on the page's `performance.now()` time line, and
130
+ the port. It reads no MIDI syntax: decode the bytes with
131
+ `@ac-kit/format-midi`, as above. Disposing it stops listening and closes the
132
+ port.
133
+ - `isSameMidiPort` — whether two port identities (name and manufacturer) are
134
+ the same device; a port's id changes between sessions, its identity does not.
135
+
136
+ ## Upload progress
137
+
138
+ ```ts
139
+ import { sendWithProgress } from "@ac-kit/browser";
140
+
141
+ const response = await sendWithProgress(XMLHttpRequest, {
142
+ method: "POST",
143
+ url: "/songs",
144
+ headers: { "Content-Type": file.type },
145
+ body: file,
146
+ onUploadProgress: ({ loaded, total }) => {
147
+ progressBar.value = total === undefined ? 0 : loaded / total;
148
+ },
149
+ signal: controller.signal,
150
+ });
151
+ if (response.status === 201) {
152
+ console.log(JSON.parse(response.body));
153
+ }
154
+ ```
155
+
156
+ - `sendWithProgress(XMLHttpRequest, request)` — sends `request` through the
157
+ `XMLHttpRequest` class given, its body with its length declared, and calls
158
+ `onUploadProgress` and `onDownloadProgress` with `{ loaded, total }`,
159
+ `total` absent when the length is unknown. It resolves with the response
160
+ whatever its status: `status`, `statusText`, `headers` as a `Headers`, the
161
+ final `url` after redirects, and the body read whole as `responseType`
162
+ says — `"text"` (the default), `"bytes"` or `"blob"`. `credentials:
163
+ "include"` sends the page's cookies on a cross-origin request too.
164
+ - `HttpNetworkError` — the request failed before any response: the network,
165
+ CORS, or the browser. It is a `TypeError`, as `fetch`'s failure is.
166
+
167
+ Aborting `signal` cancels the request, which rejects with the signal's reason;
168
+ the browser aborting it on its own rejects with a `DOMException` named
169
+ `"AbortError"`. A field `Headers` refuses rejects with a `TypeError`, and a
170
+ method, URL or field the browser refuses with its `DOMException`; nothing is
171
+ sent then. The browser follows redirects and applies its own cookie and CORS
172
+ rules, as for `fetch`. `fetch` cannot report an upload's progress, and streams
173
+ a request body only without its declared length; reach for `fetch` for
174
+ everything else.
175
+
176
+ Browser-bound: it needs a page's (or a worker's) browser APIs, and depends on
177
+ `@ac-kit/core` and `@ac-kit/async` only. Its Node counterpart is
178
+ `@ac-kit/node`.
179
+
180
+ See the
181
+ [generated API docs](https://anthochamp.pages.grenadine.io/node-essentials/api/browser/)
182
+ for the full reference.
183
+
184
+ ## Further reading
185
+
186
+ - [Indexed Database API 3.0](https://www.w3.org/TR/IndexedDB/)
187
+ - [Web MIDI API](https://webaudio.github.io/web-midi-api/)
188
+ - [XMLHttpRequest Standard](https://xhr.spec.whatwg.org/)
@@ -0,0 +1,7 @@
1
+ export * from "./indexeddb/indexed-db-error.js";
2
+ export * from "./indexeddb/indexed-db-records.js";
3
+ export * from "./indexeddb/open-indexed-db.js";
4
+ export * from "./web-midi/web-midi-access.js";
5
+ export * from "./web-midi/web-midi-inputs.js";
6
+ export * from "./xhr/send-with-progress.js";
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC;AAChD,cAAc,mCAAmC,CAAC;AAClD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,6BAA6B,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,7 @@
1
+ export * from "./indexeddb/indexed-db-error.js";
2
+ export * from "./indexeddb/indexed-db-records.js";
3
+ export * from "./indexeddb/open-indexed-db.js";
4
+ export * from "./web-midi/web-midi-access.js";
5
+ export * from "./web-midi/web-midi-inputs.js";
6
+ export * from "./xhr/send-with-progress.js";
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC;AAChD,cAAc,mCAAmC,CAAC;AAClD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,6BAA6B,CAAC"}
@@ -0,0 +1,16 @@
1
+ /** What `request` succeeds with, or an {@link IndexedDbError} when it fails. */
2
+ export declare function requestResult_<Result>(request: IDBRequest<Result>): Promise<Result>;
3
+ /** Resolves once `transaction` committed; rejects when it aborts. */
4
+ export declare function transactionDone_(transaction: IDBTransaction): Promise<void>;
5
+ /**
6
+ * Starts a transaction, turning what `IDBDatabase.transaction` throws (a
7
+ * missing store, a closed database) into an {@link IndexedDbError}.
8
+ */
9
+ export declare function startTransaction_(database: IDBDatabase, storeName: string, mode: IDBTransactionMode, options: IDBTransactionOptions | undefined): IDBTransaction;
10
+ /**
11
+ * Makes a request on a store, turning what IndexedDB throws synchronously (a
12
+ * `DataError` for a key it cannot hold, a `DataCloneError` for a value it
13
+ * cannot copy) into an {@link IndexedDbError}.
14
+ */
15
+ export declare function startRequest_<Result>(makeRequest: () => IDBRequest<Result>): IDBRequest<Result>;
16
+ //# sourceMappingURL=_indexed-db-request.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_indexed-db-request.d.ts","sourceRoot":"","sources":["../../src/indexeddb/_indexed-db-request.ts"],"names":[],"mappings":"AAEA,gFAAgF;AAChF,wBAAgB,cAAc,CAAC,MAAM,EACpC,OAAO,EAAE,UAAU,CAAC,MAAM,CAAC,GACzB,OAAO,CAAC,MAAM,CAAC,CAWjB;AAED,qEAAqE;AACrE,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAW3E;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAChC,QAAQ,EAAE,WAAW,EACrB,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,kBAAkB,EACxB,OAAO,EAAE,qBAAqB,GAAG,SAAS,GACxC,cAAc,CAShB;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,MAAM,EACnC,WAAW,EAAE,MAAM,UAAU,CAAC,MAAM,CAAC,GACnC,UAAU,CAAC,MAAM,CAAC,CAMpB"}
@@ -0,0 +1,45 @@
1
+ import { IndexedDbError } from "./indexed-db-error.js";
2
+ /** What `request` succeeds with, or an {@link IndexedDbError} when it fails. */
3
+ export function requestResult_(request) {
4
+ return new Promise((resolve, reject) => {
5
+ request.addEventListener("success", () => resolve(request.result));
6
+ request.addEventListener("error", () => reject(new IndexedDbError("An IndexedDB request failed", {
7
+ cause: request.error,
8
+ })));
9
+ });
10
+ }
11
+ /** Resolves once `transaction` committed; rejects when it aborts. */
12
+ export function transactionDone_(transaction) {
13
+ return new Promise((resolve, reject) => {
14
+ transaction.addEventListener("complete", () => resolve());
15
+ transaction.addEventListener("abort", () => reject(new IndexedDbError("An IndexedDB transaction failed", {
16
+ cause: transaction.error,
17
+ })));
18
+ });
19
+ }
20
+ /**
21
+ * Starts a transaction, turning what `IDBDatabase.transaction` throws (a
22
+ * missing store, a closed database) into an {@link IndexedDbError}.
23
+ */
24
+ export function startTransaction_(database, storeName, mode, options) {
25
+ try {
26
+ return database.transaction(storeName, mode, options);
27
+ }
28
+ catch (error) {
29
+ throw new IndexedDbError(`Cannot start an IndexedDB transaction on "${storeName}"`, { cause: error });
30
+ }
31
+ }
32
+ /**
33
+ * Makes a request on a store, turning what IndexedDB throws synchronously (a
34
+ * `DataError` for a key it cannot hold, a `DataCloneError` for a value it
35
+ * cannot copy) into an {@link IndexedDbError}.
36
+ */
37
+ export function startRequest_(makeRequest) {
38
+ try {
39
+ return makeRequest();
40
+ }
41
+ catch (error) {
42
+ throw new IndexedDbError("IndexedDB refused a request", { cause: error });
43
+ }
44
+ }
45
+ //# sourceMappingURL=_indexed-db-request.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_indexed-db-request.js","sourceRoot":"","sources":["../../src/indexeddb/_indexed-db-request.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,gFAAgF;AAChF,MAAM,UAAU,cAAc,CAC7B,OAA2B;IAE3B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACtC,OAAO,C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c,CAAC,6BAA6B,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;IAC3E,CAAC;AACF,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * IndexedDB failed: the browser has none (some private modes), refused to open
3
+ * the database, or a request or transaction failed — its `DOMException` is the
4
+ * `cause`, named `QuotaExceededError` when storage ran out.
5
+ */
6
+ export declare class IndexedDbError extends Error {
7
+ constructor(message: string, options?: ErrorOptions);
8
+ }
9
+ //# sourceMappingURL=indexed-db-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"indexed-db-error.d.ts","sourceRoot":"","sources":["../../src/indexeddb/indexed-db-error.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,qBAAa,cAAe,SAAQ,KAAK;IACxC,YAAY,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,EAGlD;CACD"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * IndexedDB failed: the browser has none (some private modes), refused to open
3
+ * the database, or a request or transaction failed — its `DOMException` is the
4
+ * `cause`, named `QuotaExceededError` when storage ran out.
5
+ */
6
+ export class IndexedDbError extends Error {
7
+ constructor(message, options) {
8
+ super(message, options);
9
+ this.name = "IndexedDbError";
10
+ }
11
+ }
12
+ //# sourceMappingURL=indexed-db-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"indexed-db-error.js","sourceRoot":"","sources":["../../src/indexeddb/indexed-db-error.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,OAAO,cAAe,SAAQ,KAAK;IACxC,YAAY,OAAe,EAAE,OAAsB;QAClD,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;IAC9B,CAAC;CACD"}
@@ -0,0 +1,95 @@
1
+ import type { CallableNoArgs } from "@ac-kit/core";
2
+ /** A value and the key it is kept under. */
3
+ export type IndexedDbRecord<Key extends IDBValidKey, Value> = {
4
+ readonly key: Key;
5
+ readonly value: Value;
6
+ };
7
+ /**
8
+ * The records of one IndexedDB object store, by key, every call a promise. Each
9
+ * call is one transaction of its own: a batch is written whole or not at all.
10
+ */
11
+ export type IndexedDbRecords<Key extends IDBValidKey, Value> = {
12
+ /** The value under `key`, `undefined` when there is none. */
13
+ get(key: Key): Promise<Value | undefined>;
14
+ /**
15
+ * Every record, or those whose key is in `range`, in key order. Time and
16
+ * memory are linear in the records returned.
17
+ */
18
+ getAll(range?: IDBKeyRange): Promise<IndexedDbRecord<Key, Value>[]>;
19
+ /** How many records there are, or how many have their key in `range`. */
20
+ count(range?: IDBKeyRange): Promise<number>;
21
+ /** Adds or replaces records. Linear in their number. */
22
+ putAll(records: Iterable<IndexedDbRecord<Key, Value>>): Promise<void>;
23
+ /**
24
+ * Deletes the records of each key, or each key range, given; a missing key is
25
+ * skipped.
26
+ */
27
+ deleteAll(keys: Iterable<Key | IDBKeyRange>): Promise<void>;
28
+ /** Deletes every record. */
29
+ clear(): Promise<void>;
30
+ };
31
+ /** Optional settings of {@link createIndexedDbRecords}. */
32
+ export type IndexedDbRecordsOptions = {
33
+ /**
34
+ * How hard a write is pushed to disk before it resolves: `"strict"` waits for
35
+ * the storage to confirm it, `"relaxed"` for the operating system to hold it,
36
+ * which is faster and loses only the last writes in a power cut. Default: the
37
+ * browser's.
38
+ */
39
+ readonly durability?: IDBTransactionDurability;
40
+ };
41
+ /**
42
+ * The records of the object store `storeName` of `database`: its values by key,
43
+ * each kept as the structured clone algorithm copies it. The store holds its
44
+ * keys apart from its values (it was created without a `keyPath`).
45
+ *
46
+ * The values come back as `Value`, unchecked: check them when another version
47
+ * of the page may have written them.
48
+ *
49
+ * @example
50
+ * const songs = createIndexedDbRecords<string, Song>(database, "songs");
51
+ * await songs.putAll([{ key: song.id, value: song }]);
52
+ *
53
+ * @throws {IndexedDbError} From every call, when its transaction cannot start
54
+ * (a missing store, a closed database), IndexedDB refuses a request (a key it
55
+ * cannot hold, a value it cannot clone) or the transaction fails; its `cause`
56
+ * is IndexedDB's `DOMException`. What the iterable given to `putAll` or
57
+ * `deleteAll` throws goes through as it is, the batch abandoned.
58
+ */
59
+ export declare function createIndexedDbRecords<Key extends IDBValidKey, Value>(database: IDBDatabase, storeName: string, options?: IndexedDbRecordsOptions): IndexedDbRecords<Key, Value>;
60
+ /** What {@link openIndexedDbRecords} opens. */
61
+ export type OpenIndexedDbRecordsInput = {
62
+ /** The page's or worker's `indexedDB`, or a stand-in in tests. */
63
+ readonly factory: IDBFactory | undefined;
64
+ /** The database's name, holding this one store. */
65
+ readonly name: string;
66
+ readonly storeName: string;
67
+ /** Told that another page opens the database at a newer version. */
68
+ readonly onVersionChange?: CallableNoArgs;
69
+ /** Gives up opening: the opening rejects with its reason. */
70
+ readonly signal?: AbortSignal;
71
+ };
72
+ /**
73
+ * Opens the object store `storeName` of a database `name` holding only it,
74
+ * creating both at first use, and returns its records: values kept across page
75
+ * loads by a key of the caller's. Disposing them closes the database.
76
+ *
77
+ * Reach for it when one store is all a page keeps; with several stores, or a
78
+ * schema that changes, {@link openIndexedDb} with an `upgrade` and
79
+ * {@link createIndexedDbRecords} per store. For values the page needs only while
80
+ * it runs, a `Map` does.
81
+ *
82
+ * @example
83
+ * using settings = await openIndexedDbRecords<string, unknown>({
84
+ * factory: indexedDB,
85
+ * name: "settings",
86
+ * storeName: "values",
87
+ * });
88
+ * await settings.putAll([{ key: "theme", value: "dark" }]);
89
+ *
90
+ * @throws {IndexedDbError} When the browser has no IndexedDB (some private
91
+ * modes), or the database cannot be opened.
92
+ * @throws `signal`'s reason when it aborts first.
93
+ */
94
+ export declare function openIndexedDbRecords<Key extends IDBValidKey, Value>(input: OpenIndexedDbRecordsInput): Promise<IndexedDbRecords<Key, Value> & Disposable>;
95
+ //# sourceMappingURL=indexed-db-records.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"indexed-db-records.d.ts","sourceRoot":"","sources":["../../src/indexeddb/indexed-db-records.ts"],"names":[],"m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,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE,uBAAuB,GAC/B,gBAAgB,CAAC,GAAG,EAAE,KAAK,CAAC,CA6E9B;AAED,+CAA+C;AAC/C,MAAM,MAAM,yBAAyB,GAAG;IACvC,kEAAkE;IAClE,QAAQ,CAAC,OAAO,EAAE,UAAU,GAAG,SAAS,CAAC;IACzC,mDAAmD;IACnD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,oEAAoE;IACpE,QAAQ,CAAC,eAAe,CAAC,EAAE,cAAc,CAAC;IAC1C,6DAA6D;IAC7D,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC9B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,oBAAoB,CAAC,GAAG,SAAS,WAAW,EAAE,KAAK,EACxE,KAAK,EAAE,yBAAyB,GAC9B,OAAO,CAAC,gBAAgB,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,UAAU,CAAC,CAmBpD"}
@@ -0,0 +1,121 @@
1
+ import { requestResult_, startRequest_, startTransaction_, transactionDone_, } from "./_indexed-db-request.js";
2
+ import { openIndexedDb } from "./open-indexed-db.js";
3
+ /**
4
+ * The records of the object store `storeName` of `database`: its values by key,
5
+ * each kept as the structured clone algorithm copies it. The store holds its
6
+ * keys apart from its values (it was created without a `keyPath`).
7
+ *
8
+ * The values come back as `Value`, unchecked: check them when another version
9
+ * of the page may have written them.
10
+ *
11
+ * @example
12
+ * const songs = createIndexedDbRecords<string, Song>(database, "songs");
13
+ * await songs.putAll([{ key: song.id, value: song }]);
14
+ *
15
+ * @throws {IndexedDbError} From every call, when its transaction cannot start
16
+ * (a missing store, a closed database), IndexedDB refuses a request (a key it
17
+ * cannot hold, a value it cannot clone) or the transaction fails; its `cause`
18
+ * is IndexedDB's `DOMException`. What the iterable given to `putAll` or
19
+ * `deleteAll` throws goes through as it is, the batch abandoned.
20
+ */
21
+ export function createIndexedDbRecords(database, storeName, options) {
22
+ const transactionOptions = options?.durability === undefined
23
+ ? undefined
24
+ : { durability: options.durability };
25
+ const read = () => startTransaction_(database, storeName, "readonly", transactionOptions).objectStore(storeName);
26
+ const write = async (work) => {
27
+ const transaction = startTransaction_(database, storeName, "readwrite", transactionOptions);
28
+ const done = transactionDone_(transaction);
29
+ try {
30
+ work(transaction.objectStore(storeName));
31
+ }
32
+ catch (error) {
33
+ // A request refused at once (a key IndexedDB cannot hold, a value it
34
+ // cannot clone), or the caller's iterable failing: nothing of the
35
+ // batch is kept.
36
+ transaction.abort();
37
+ await done.catch(() => { });
38
+ throw error;
39
+ }
40
+ await done;
41
+ };
42
+ return {
43
+ async get(key) {
44
+ const store = read();
45
+ // Every value was put by `putAll`, as a `Value`.
46
+ return (await requestResult_(startRequest_(() => store.get(key))));
47
+ },
48
+ async getAll(range) {
49
+ const store = read();
50
+ const [keys, values] = await Promise.all([
51
+ requestResult_(startRequest_(() => store.getAllKeys(range))),
52
+ requestResult_(startRequest_(() => store.getAll(range))),
53
+ ]);
54
+ // Both in key order, from one transaction; every key and value was put
55
+ // by `putAll`, as a `Key` and a `Value`.
56
+ return keys.map((key, index) => ({
57
+ key: key,
58
+ value: values[index],
59
+ }));
60
+ },
61
+ async count(range) {
62
+ const store = read();
63
+ return requestResult_(startRequest_(() => store.count(range)));
64
+ },
65
+ putAll: (records) => write((store) => {
66
+ for (const { key, value } of records) {
67
+ startRequest_(() => store.put(value, key));
68
+ }
69
+ }),
70
+ deleteAll: (keys) => write((store) => {
71
+ for (const key of keys) {
72
+ startRequest_(() => store.delete(key));
73
+ }
74
+ }),
75
+ clear: () => write((store) => {
76
+ startRequest_(() => store.clear());
77
+ }),
78
+ };
79
+ }
80
+ /**
81
+ * Opens the object store `storeName` of a database `name` holding only it,
82
+ * creating both at first use, and returns its records: values kept across page
83
+ * loads by a key of the caller's. Disposing them closes the database.
84
+ *
85
+ * Reach for it when one store is all a page keeps; with several stores, or a
86
+ * schema that changes, {@link openIndexedDb} with an `upgrade` and
87
+ * {@link createIndexedDbRecords} per store. For values the page needs only while
88
+ * it runs, a `Map` does.
89
+ *
90
+ * @example
91
+ * using settings = await openIndexedDbRecords<string, unknown>({
92
+ * factory: indexedDB,
93
+ * name: "settings",
94
+ * storeName: "values",
95
+ * });
96
+ * await settings.putAll([{ key: "theme", value: "dark" }]);
97
+ *
98
+ * @throws {IndexedDbError} When the browser has no IndexedDB (some private
99
+ * modes), or the database cannot be opened.
100
+ * @throws `signal`'s reason when it aborts first.
101
+ */
102
+ export async function openIndexedDbRecords(input) {
103
+ const { storeName } = input;
104
+ const database = await openIndexedDb({
105
+ factory: input.factory,
106
+ name: input.name,
107
+ version: 1,
108
+ upgrade: ({ database: created }) => {
109
+ created.createObjectStore(storeName);
110
+ },
111
+ onVersionChange: input.onVersionChange,
112
+ signal: input.signal,
113
+ });
114
+ return {
115
+ ...createIndexedDbRecords(database, storeName),
116
+ [Symbol.dispose]() {
117
+ database.close();
118
+ },
119
+ };
120
+ }
121
+ //# sourceMappingURL=indexed-db-records.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"indexed-db-records.js","sourceRoot":"","sources":["../../src/indexeddb/indexed-db-records.ts"],"names":[],"mappings":"AAEA,OAAO,EACN,cAAc,EACd,aAAa,EACb,iBAAiB,EACjB,gBAAgB,GAChB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AA4CrD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,sBAAsB,CACrC,QAAqB,EACrB,SAAiB,EACjB,OAAiC;IAEjC,MAAM,kBAAkB,GACvB,OAAO,EAAE,UAAU,KAAK,SAAS;QAChC,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,EAAE,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE,CAAC;IACvC,MAAM,IAAI,GAAG,GAAmB,EAAE,CACjC,iBAAiB,CAChB,QAAQ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