offdex 2.0.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,68 +1,120 @@
1
- # Offdex
2
-
3
- Keyed object storage for the browser. Offdex wraps IndexedDB with a tiny, unbiased API so you can drop in `{ key: "<string>", ...data }` objects and have them shared across tabs, workers, and sessions without thinking about schema versions.
4
-
5
- ## Why use Offdex
6
-
7
- - Zero schema/versioning overhead: one object store keyed by `key`, no migrations to manage.
8
- - Minimal wrapper: no hooks or proxies in the storage API, just data in and data out.
9
- - Works everywhere IndexedDB works: tabs, workers, and other browser runtimes share the same underlying database.
10
- - Offline by default: IndexedDB persists across reloads and disconnects.
11
- - Typed surface: ships with TypeScript definitions for easy adoption.
12
-
13
- ## Install
14
-
15
- ```bash
16
- npm install offdex
17
- ```
18
-
19
- ## Quick start
20
-
21
- ```js
22
- import { storage } from "offdex";
23
-
24
- const profile = {
25
- key: "profile:ada",
26
- name: "Ada Lovelace",
27
- role: "analyst",
28
- };
29
-
30
- await storage.put(profile);
31
-
32
- const again = await storage.get(profile.key);
33
- // -> { key: "profile:ada", name: "Ada Lovelace", role: "analyst" }
34
-
35
- await storage.delete(profile.key);
36
- ```
37
-
38
- ## API
39
-
40
- ### `storage`
41
-
42
- - Ready-to-use singleton instance shared across every import in the same origin. Uses the `offdex` database and `objects` store under the hood.
43
-
44
- ### `class ObjectStore`
45
-
46
- - `constructor()` opens (or creates) the `offdex` database with the `objects` store. Use this only if you need a separate instance.
47
- - `put(object: { key: string } & Record<string, unknown>): Promise<void>` - upserts an object keyed by `key`.
48
- - `putAll(objects: { key: string } & Record<string, unknown>[]): Promise<void>` - upserts multiple objects in a single transaction.
49
- - `get(key: string): Promise<{ key: string } & Record<string, unknown> | undefined>` - fetches by `key`, returning `undefined` when missing.
50
- - `delete(key: string): Promise<void>` - removes an object by `key`.
51
- - `getAllMatches(queryOrFilter: StorageQuery | (object) => boolean): Promise<object[]>` - returns objects that pass a query or predicate.
52
- - `deleteAllMatches(queryOrFilter: StorageQuery | (object) => boolean): Promise<void>` — deletes objects that pass a query or predicate.
53
-
54
- ### Other exports
55
-
56
- - `StorageQuery` helper for simple equality-based queries.
57
- - `ObservableValue` — observable wrapper around a single value.
58
- - `ObservableObject` wraps an object in observable values keyed by its properties.
59
-
60
- ### Types
61
-
62
- - `StoredObject` - `{ key: string } & Record<string, unknown>`.
63
-
64
- ## Notes
65
-
66
- - Runs in any environment that exposes `indexedDB` (secure contexts in modern browsers).
67
- - Data is shared per origin; open multiple tabs or workers and you will see the same store.
68
- - There is no schema migration system; keep your stored objects backward compatible or manage migrations externally if you need them.
1
+ # Offdex
2
+
3
+ IndexedDB-backed object storage for browsers and workers. Store
4
+ structured-clone JS values (objects, arrays, and primitives limited to
5
+ msgpack-compatible types) by key, read them back directly, and share data across
6
+ tabs and workers without schema migrations.
7
+
8
+ ## Why use Offdex
9
+
10
+ - Simple `put/get/head/delete/list` API in browser contexts.
11
+ - Object storage for msgpack-safe structured-clone JS values: primitives,
12
+ arrays, plain objects, Date, and typed arrays.
13
+ - Single object store keyed by string; no migrations to manage.
14
+ - Data shared per origin across tabs and workers (instance per JavaScript realm).
15
+ - Offline persistence via IndexedDB.
16
+ - TypeScript-first.
17
+ - Singleton-only API: one shared `storage` instance per JavaScript realm (per thread).
18
+
19
+ ## Install
20
+
21
+ ```bash
22
+ npm install offdex
23
+ ```
24
+
25
+ ## Quick start
26
+
27
+ ```js
28
+ import storage from "offdex";
29
+
30
+ await storage.put("profile:ada", { greeting: "hello from IndexedDB" });
31
+
32
+ const object = await storage.get("profile:ada");
33
+ if (object) {
34
+ console.log(object);
35
+ }
36
+
37
+ await storage.put("bytes", new Uint8Array([1, 2, 3]));
38
+ const bytes = await storage.get("bytes");
39
+ console.log(bytes instanceof Uint8Array, bytes);
40
+ ```
41
+
42
+ ## API
43
+
44
+ ### `storage` (default export)
45
+
46
+ Singleton storage instance per JavaScript realm backed by the `offdex` database
47
+ and `blobs` object store. The underlying store is shared per origin across tabs
48
+ and workers.
49
+
50
+ ### Methods
51
+
52
+ - `put(key, value, options?)` -> `Promise<void>`
53
+ - `get(key, options?)` -> `Promise<unknown | null>`
54
+ - `head(key)` -> `Promise<boolean>`
55
+ - `delete(key)` -> `Promise<void>`
56
+ - `list(options?)` -> `Promise<{ objects: { key: string }[] }>`
57
+
58
+ ### Value requirements (msgpack-compatible)
59
+
60
+ - `value` must be a structured-clone JS value encodable by `@msgpack/msgpack`
61
+ with default options.
62
+ - Allowed: `null`/`undefined`, booleans, numbers, strings, arrays, plain
63
+ objects, `Date`, and `ArrayBufferView` (typed arrays/DataView).
64
+ - Not allowed: `BigInt`, `Map`, `Set`, `RegExp`, `Error`, `Blob`/`File`,
65
+ `ArrayBuffer`, functions, symbols, or circular references.
66
+ - `put` throws a `TypeError` if a value is not msgpack-compatible.
67
+ - MessagePack note: `undefined` decodes as `null`, and binary decodes as
68
+ `Uint8Array`.
69
+
70
+ ## Compatibility notes
71
+
72
+ - Method names mirror Cloudflare R2 (`put/get/head/delete/list`), but return
73
+ values are simplified for direct value access.
74
+ - Offdex does not use MessagePack internally; it just validates compatibility.
75
+ - `options` arguments are accepted for signature compatibility but not used.
76
+ - `list` currently returns all keys; prefix/limit/cursor options are ignored.
77
+
78
+ ## Build
79
+
80
+ ```bash
81
+ npm run build
82
+ ```
83
+
84
+ ## Tests
85
+
86
+ ```bash
87
+ npx playwright install
88
+ npm test
89
+ ```
90
+
91
+ Playwright runs Chromium, Firefox, WebKit, plus mobile emulation projects.
92
+
93
+ ## Benchmarks
94
+
95
+ ```bash
96
+ npx playwright install
97
+ npm run bench
98
+ ```
99
+
100
+ The benchmark runs in Chromium via Playwright and times a batch of msgpack-safe
101
+ `put/head/get/list/delete` operations.
102
+
103
+ ```text
104
+ [bench] put 200 items: 148.6ms
105
+ [bench] head 200 items: 101.6ms
106
+ [bench] get 200 items: 100.3ms
107
+ [bench] list 200 items: 2.7ms
108
+ [bench] delete 200 items: 123.8ms
109
+ ```
110
+
111
+ ## Manual browser check
112
+
113
+ - Run `npm run build`, open `in-browser-testing.html`, then use `storage` from
114
+ the console with msgpack-compatible structured-clone values.
115
+
116
+ ## Notes
117
+
118
+ - Requires `indexedDB` (modern browsers / worker runtimes).
119
+ - Data is scoped per origin; all tabs/workers on the same origin share the same
120
+ store.
@@ -0,0 +1,10 @@
1
+ import type { R2GetOptions, R2ListOptions, R2Objects, R2PutOptions } from "@cloudflare/workers-types";
2
+ export declare class BlobStorage {
3
+ #private;
4
+ put: (key: string, value: unknown, _options?: R2PutOptions) => Promise<void>;
5
+ head: (key: string) => Promise<boolean>;
6
+ get: (key: string, _options?: R2GetOptions) => Promise<unknown | null>;
7
+ delete: (key: string) => Promise<void>;
8
+ list: (_options?: R2ListOptions) => Promise<R2Objects>;
9
+ }
10
+ //# sourceMappingURL=class.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"class.d.ts","sourceRoot":"","sources":["../../src/BlobStorage/class.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,YAAY,EACZ,aAAa,EACb,SAAS,EACT,YAAY,EACb,MAAM,2BAA2B,CAAC;AAInC,qBAAa,WAAW;;IAgItB,GAAG,GACD,KAAK,MAAM,EACX,OAAO,OAAO,EACd,WAAW,YAAY,KACtB,OAAO,CAAC,IAAI,CAAC,CAwBd;IAEF,IAAI,GAAU,KAAK,MAAM,KAAG,OAAO,CAAC,OAAO,CAAC,CAc1C;IAEF,GAAG,GACD,KAAK,MAAM,EACX,WAAW,YAAY,KACtB,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAcxB;IAEF,MAAM,GAAU,KAAK,MAAM,KAAG,OAAO,CAAC,IAAI,CAAC,CASzC;IAEF,IAAI,GAAU,WAAW,aAAa,KAAG,OAAO,CAAC,SAAS,CAAC,CAiBzD;CACH"}
@@ -0,0 +1,169 @@
1
+ var _a;
2
+ export class BlobStorage {
3
+ static #dbName = "offdex";
4
+ static #storeName = "blobs";
5
+ #dbPromise = _a.#open();
6
+ static #open() {
7
+ return new Promise((resolve, reject) => {
8
+ const request = indexedDB.open(_a.#dbName, 1);
9
+ request.onupgradeneeded = () => {
10
+ const db = request.result;
11
+ if (!db.objectStoreNames.contains(_a.#storeName)) {
12
+ db.createObjectStore(_a.#storeName, { keyPath: "key" });
13
+ }
14
+ };
15
+ request.onsuccess = () => resolve(request.result);
16
+ request.onerror = () => reject(request.error);
17
+ });
18
+ }
19
+ static #throwMsgpackError(path, reason) {
20
+ throw new TypeError(`{offdex} BlobStorage.put: value at ${path} is not msgpack-compatible (${reason})`);
21
+ }
22
+ static #assertMsgpackCompatible(value, path, seen) {
23
+ if (value === null || value === undefined)
24
+ return;
25
+ const valueType = typeof value;
26
+ if (valueType === "string" ||
27
+ valueType === "boolean" ||
28
+ valueType === "number")
29
+ return;
30
+ if (valueType === "bigint") {
31
+ _a.#throwMsgpackError(path, "bigint is not supported without custom msgpack options");
32
+ }
33
+ if (valueType === "symbol") {
34
+ _a.#throwMsgpackError(path, "symbol values are not supported");
35
+ }
36
+ if (valueType === "function") {
37
+ _a.#throwMsgpackError(path, "functions are not supported");
38
+ }
39
+ if (value instanceof Date)
40
+ return;
41
+ if (ArrayBuffer.isView(value))
42
+ return;
43
+ if (value instanceof ArrayBuffer) {
44
+ _a.#throwMsgpackError(path, "ArrayBuffer is not supported; use Uint8Array instead");
45
+ }
46
+ if (typeof Blob === "function" && value instanceof Blob) {
47
+ _a.#throwMsgpackError(path, "Blob/File values are not supported; use Uint8Array instead");
48
+ }
49
+ if (typeof File === "function" && value instanceof File) {
50
+ _a.#throwMsgpackError(path, "Blob/File values are not supported; use Uint8Array instead");
51
+ }
52
+ if (value instanceof Map) {
53
+ _a.#throwMsgpackError(path, "Map is not supported");
54
+ }
55
+ if (value instanceof Set) {
56
+ _a.#throwMsgpackError(path, "Set is not supported");
57
+ }
58
+ if (value instanceof RegExp) {
59
+ _a.#throwMsgpackError(path, "RegExp is not supported");
60
+ }
61
+ if (value instanceof Error) {
62
+ _a.#throwMsgpackError(path, "Error is not supported");
63
+ }
64
+ if (Array.isArray(value)) {
65
+ if (seen.has(value)) {
66
+ _a.#throwMsgpackError(path, "circular references are not supported");
67
+ }
68
+ seen.add(value);
69
+ for (let index = 0; index < value.length; index += 1) {
70
+ _a.#assertMsgpackCompatible(value[index], `${path}[${index}]`, seen);
71
+ }
72
+ seen.delete(value);
73
+ return;
74
+ }
75
+ if (value && typeof value === "object") {
76
+ const proto = Object.getPrototypeOf(value);
77
+ if (proto !== Object.prototype && proto !== null) {
78
+ _a.#throwMsgpackError(path, "only plain objects are supported");
79
+ }
80
+ if (Object.getOwnPropertySymbols(value).length > 0) {
81
+ _a.#throwMsgpackError(path, "symbol keys are not supported");
82
+ }
83
+ if (seen.has(value)) {
84
+ _a.#throwMsgpackError(path, "circular references are not supported");
85
+ }
86
+ seen.add(value);
87
+ for (const [key, entry] of Object.entries(value)) {
88
+ _a.#assertMsgpackCompatible(entry, `${path}.${key}`, seen);
89
+ }
90
+ seen.delete(value);
91
+ return;
92
+ }
93
+ _a.#throwMsgpackError(path, "unsupported value type");
94
+ }
95
+ put = async (key, value, _options) => {
96
+ _a.#assertMsgpackCompatible(value, "$", new WeakSet());
97
+ const db = await this.#dbPromise;
98
+ await new Promise((resolve, reject) => {
99
+ const tx = db.transaction(_a.#storeName, "readwrite");
100
+ try {
101
+ tx.objectStore(_a.#storeName).put({
102
+ key: String(key),
103
+ value,
104
+ });
105
+ }
106
+ catch (error) {
107
+ const message = error instanceof Error ? error.message : String(error);
108
+ reject(new TypeError(`{offdex} BlobStorage.put: value must be structured-cloneable (${message})`));
109
+ return;
110
+ }
111
+ tx.oncomplete = () => resolve();
112
+ tx.onerror = () => reject(tx.error);
113
+ tx.onabort = () => reject(tx.error);
114
+ });
115
+ };
116
+ head = async (key) => {
117
+ const db = await this.#dbPromise;
118
+ const exists = await new Promise((resolve, reject) => {
119
+ const tx = db.transaction(_a.#storeName, "readonly");
120
+ const store = tx.objectStore(_a.#storeName);
121
+ const req = typeof store.getKey === "function" ? store.getKey(key) : store.get(key);
122
+ tx.oncomplete = () => resolve(req.result !== undefined);
123
+ tx.onerror = () => reject(tx.error);
124
+ tx.onabort = () => reject(tx.error);
125
+ });
126
+ return exists;
127
+ };
128
+ get = async (key, _options) => {
129
+ const db = await this.#dbPromise;
130
+ const row = await new Promise((resolve, reject) => {
131
+ const tx = db.transaction(_a.#storeName, "readonly");
132
+ const req = tx.objectStore(_a.#storeName).get(key);
133
+ tx.oncomplete = () => resolve(req.result);
134
+ tx.onerror = () => reject(tx.error);
135
+ tx.onabort = () => reject(tx.error);
136
+ });
137
+ if (!row)
138
+ return null;
139
+ return row.value;
140
+ };
141
+ delete = async (key) => {
142
+ const db = await this.#dbPromise;
143
+ await new Promise((resolve, reject) => {
144
+ const tx = db.transaction(_a.#storeName, "readwrite");
145
+ tx.objectStore(_a.#storeName).delete(key);
146
+ tx.oncomplete = () => resolve();
147
+ tx.onerror = () => reject(tx.error);
148
+ tx.onabort = () => reject(tx.error);
149
+ });
150
+ };
151
+ list = async (_options) => {
152
+ const db = await this.#dbPromise;
153
+ const keys = await new Promise((resolve, reject) => {
154
+ const tx = db.transaction(_a.#storeName, "readonly");
155
+ const req = tx.objectStore(_a.#storeName).getAllKeys();
156
+ tx.oncomplete = () => resolve(req.result);
157
+ tx.onerror = () => reject(tx.error);
158
+ tx.onabort = () => reject(tx.error);
159
+ });
160
+ return {
161
+ objects: keys.map((key) => ({ key })),
162
+ truncated: false,
163
+ delimitedPrefixes: [],
164
+ cursor: undefined,
165
+ };
166
+ };
167
+ }
168
+ _a = BlobStorage;
169
+ //# sourceMappingURL=class.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"class.js","sourceRoot":"","sources":["../../src/BlobStorage/class.ts"],"names":[],"mappings":";AAUA,MAAM,OAAO,WAAW;IACtB,MAAM,CAAU,OAAO,GAAG,QAAQ,CAAC;IACnC,MAAM,CAAU,UAAU,GAA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,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;QACtC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,IAAI,GAAG,KAAK,EAAE,QAAwB,EAAsB,EAAE;QAC5D,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC;QAEjC,MAAM,IAAI,GAAG,MAAM,IAAI,OAAO,CAAW,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAC3D,MAAM,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,EAAW,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;YAC9D,MAAM,GAAG,GAAG,EAAE,CAAC,WAAW,CAAC,EAAW,CAAC,UAAU,CAAC,CAAC,UAAU,EAAE,CAAC;YAChE,EAAE,CAAC,UAAU,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,MAAkB,CAAC,CAAC;YACtD,EAAE,CAAC,OAAO,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;YACpC,EAAE,CAAC,OAAO,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;QACtC,CAAC,CAAC,CAAC;QAEH,OAAO;YACL,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,EAAe,CAAA,CAAC;YACjD,SAAS,EAAE,KAAK;YAChB,iBAAiB,EAAE,EAAE;YACrB,MAAM,EAAE,SAAS;SACL,CAAC;IACjB,CAAC,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { R2GetOptions, R2ListOptions, R2Objects, R2PutOptions } from "@cloudflare/workers-types";
2
+ export declare class ObjectStorage {
3
+ #private;
4
+ put: (key: string, value: unknown, _options?: R2PutOptions) => Promise<void>;
5
+ head: (key: string) => Promise<boolean>;
6
+ get: (key: string, _options?: R2GetOptions) => Promise<unknown | null>;
7
+ delete: (key: string) => Promise<void>;
8
+ list: (_options?: R2ListOptions) => Promise<R2Objects>;
9
+ }
10
+ //# sourceMappingURL=class.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"class.d.ts","sourceRoot":"","sources":["../../src/ObjectStorage/class.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,YAAY,EACZ,aAAa,EACb,SAAS,EACT,YAAY,EACb,MAAM,2BAA2B,CAAC;AAInC,qBAAa,aAAa;;IAsIxB,GAAG,GACD,KAAK,MAAM,EACX,OAAO,OAAO,EACd,WAAW,YAAY,KACtB,OAAO,CAAC,IAAI,CAAC,CAwBd;IAEF,IAAI,GAAU,KAAK,MAAM,KAAG,OAAO,CAAC,OAAO,CAAC,CAc1C;IAEF,GAAG,GACD,KAAK,MAAM,EACX,WAAW,YAAY,KACtB,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAcxB;IAEF,MAAM,GAAU,KAAK,MAAM,KAAG,OAAO,CAAC,IAAI,CAAC,CASzC;IAEF,IAAI,GAAU,WAAW,aAAa,KAAG,OAAO,CAAC,SAAS,CAAC,CAiBzD;CACH"}
@@ -0,0 +1,169 @@
1
+ var _a;
2
+ export class ObjectStorage {
3
+ static #dbName = "offdex";
4
+ static #storeName = "blobs";
5
+ #dbPromise = _a.#open();
6
+ static #open() {
7
+ return new Promise((resolve, reject) => {
8
+ const request = indexedDB.open(_a.#dbName, 1);
9
+ request.onupgradeneeded = () => {
10
+ const db = request.result;
11
+ if (!db.objectStoreNames.contains(_a.#storeName)) {
12
+ db.createObjectStore(_a.#storeName, { keyPath: "key" });
13
+ }
14
+ };
15
+ request.onsuccess = () => resolve(request.result);
16
+ request.onerror = () => reject(request.error);
17
+ });
18
+ }
19
+ static #throwMsgpackError(path, reason) {
20
+ throw new TypeError(`{offdex} ObjectStorage.put: value at ${path} is not msgpack-compatible (${reason})`);
21
+ }
22
+ static #assertMsgpackCompatible(value, path, seen) {
23
+ if (value === null || value === undefined)
24
+ return;
25
+ const valueType = typeof value;
26
+ if (valueType === "string" ||
27
+ valueType === "boolean" ||
28
+ valueType === "number")
29
+ return;
30
+ if (valueType === "bigint") {
31
+ _a.#throwMsgpackError(path, "bigint is not supported without custom msgpack options");
32
+ }
33
+ if (valueType === "symbol") {
34
+ _a.#throwMsgpackError(path, "symbol values are not supported");
35
+ }
36
+ if (valueType === "function") {
37
+ _a.#throwMsgpackError(path, "functions are not supported");
38
+ }
39
+ if (value instanceof Date)
40
+ return;
41
+ if (ArrayBuffer.isView(value))
42
+ return;
43
+ if (value instanceof ArrayBuffer) {
44
+ _a.#throwMsgpackError(path, "ArrayBuffer is not supported; use Uint8Array instead");
45
+ }
46
+ if (typeof Blob === "function" && value instanceof Blob) {
47
+ _a.#throwMsgpackError(path, "Blob/File values are not supported; use Uint8Array instead");
48
+ }
49
+ if (typeof File === "function" && value instanceof File) {
50
+ _a.#throwMsgpackError(path, "Blob/File values are not supported; use Uint8Array instead");
51
+ }
52
+ if (value instanceof Map) {
53
+ _a.#throwMsgpackError(path, "Map is not supported");
54
+ }
55
+ if (value instanceof Set) {
56
+ _a.#throwMsgpackError(path, "Set is not supported");
57
+ }
58
+ if (value instanceof RegExp) {
59
+ _a.#throwMsgpackError(path, "RegExp is not supported");
60
+ }
61
+ if (value instanceof Error) {
62
+ _a.#throwMsgpackError(path, "Error is not supported");
63
+ }
64
+ if (Array.isArray(value)) {
65
+ if (seen.has(value)) {
66
+ _a.#throwMsgpackError(path, "circular references are not supported");
67
+ }
68
+ seen.add(value);
69
+ for (let index = 0; index < value.length; index += 1) {
70
+ _a.#assertMsgpackCompatible(value[index], `${path}[${index}]`, seen);
71
+ }
72
+ seen.delete(value);
73
+ return;
74
+ }
75
+ if (value && typeof value === "object") {
76
+ const proto = Object.getPrototypeOf(value);
77
+ if (proto !== Object.prototype && proto !== null) {
78
+ _a.#throwMsgpackError(path, "only plain objects are supported");
79
+ }
80
+ if (Object.getOwnPropertySymbols(value).length > 0) {
81
+ _a.#throwMsgpackError(path, "symbol keys are not supported");
82
+ }
83
+ if (seen.has(value)) {
84
+ _a.#throwMsgpackError(path, "circular references are not supported");
85
+ }
86
+ seen.add(value);
87
+ for (const [key, entry] of Object.entries(value)) {
88
+ _a.#assertMsgpackCompatible(entry, `${path}.${key}`, seen);
89
+ }
90
+ seen.delete(value);
91
+ return;
92
+ }
93
+ _a.#throwMsgpackError(path, "unsupported value type");
94
+ }
95
+ put = async (key, value, _options) => {
96
+ _a.#assertMsgpackCompatible(value, "$", new WeakSet());
97
+ const db = await this.#dbPromise;
98
+ await new Promise((resolve, reject) => {
99
+ const tx = db.transaction(_a.#storeName, "readwrite");
100
+ try {
101
+ tx.objectStore(_a.#storeName).put({
102
+ key: String(key),
103
+ value,
104
+ });
105
+ }
106
+ catch (error) {
107
+ const message = error instanceof Error ? error.message : String(error);
108
+ reject(new TypeError(`{offdex} ObjectStorage.put: value must be structured-cloneable (${message})`));
109
+ return;
110
+ }
111
+ tx.oncomplete = () => resolve();
112
+ tx.onerror = () => reject(tx.error);
113
+ tx.onabort = () => reject(tx.error);
114
+ });
115
+ };
116
+ head = async (key) => {
117
+ const db = await this.#dbPromise;
118
+ const exists = await new Promise((resolve, reject) => {
119
+ const tx = db.transaction(_a.#storeName, "readonly");
120
+ const store = tx.objectStore(_a.#storeName);
121
+ const req = typeof store.getKey === "function" ? store.getKey(key) : store.get(key);
122
+ tx.oncomplete = () => resolve(req.result !== undefined);
123
+ tx.onerror = () => reject(tx.error);
124
+ tx.onabort = () => reject(tx.error);
125
+ });
126
+ return exists;
127
+ };
128
+ get = async (key, _options) => {
129
+ const db = await this.#dbPromise;
130
+ const row = await new Promise((resolve, reject) => {
131
+ const tx = db.transaction(_a.#storeName, "readonly");
132
+ const req = tx.objectStore(_a.#storeName).get(key);
133
+ tx.oncomplete = () => resolve(req.result);
134
+ tx.onerror = () => reject(tx.error);
135
+ tx.onabort = () => reject(tx.error);
136
+ });
137
+ if (!row)
138
+ return null;
139
+ return row.value;
140
+ };
141
+ delete = async (key) => {
142
+ const db = await this.#dbPromise;
143
+ await new Promise((resolve, reject) => {
144
+ const tx = db.transaction(_a.#storeName, "readwrite");
145
+ tx.objectStore(_a.#storeName).delete(key);
146
+ tx.oncomplete = () => resolve();
147
+ tx.onerror = () => reject(tx.error);
148
+ tx.onabort = () => reject(tx.error);
149
+ });
150
+ };
151
+ list = async (_options) => {
152
+ const db = await this.#dbPromise;
153
+ const keys = await new Promise((resolve, reject) => {
154
+ const tx = db.transaction(_a.#storeName, "readonly");
155
+ const req = tx.objectStore(_a.#storeName).getAllKeys();
156
+ tx.oncomplete = () => resolve(req.result);
157
+ tx.onerror = () => reject(tx.error);
158
+ tx.onabort = () => reject(tx.error);
159
+ });
160
+ return {
161
+ objects: keys.map((key) => ({ key })),
162
+ truncated: false,
163
+ delimitedPrefixes: [],
164
+ cursor: undefined,
165
+ };
166
+ };
167
+ }
168
+ _a = ObjectStorage;
169
+ //# sourceMappingURL=class.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"class.js","sourceRoot":"","sources":["../../src/ObjectStorage/class.ts"],"names":[],"mappings":";AAUA,MAAM,OAAO,aAAa;IACxB,MAAM,CAAU,OAAO,GAAG,QAAQ,CAAC;IACnC,MAAM,CAAU,UAAU,GAAG,OAAO,CAAC;IAC5B,UAAU,GAAyB,EAAa,CAAC,KAAK,EAAE,CAAC;IAElE,MAAM,CAAC,KAAK;QACV,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,MAAM,OAAO,GAAG,SAAS,CAAC,IAAI,CAAC,EAAa,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;YACzD,OAAO,CAAC,eAAe,GAAG,GAAG,EAAE;gBAC7B,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC;gBAC1B,IAAI,CAAC,EAAE,CAAC,gBAAgB,CAAC,QAAQ,CAAC,EAAa,CAAC,UAAU,CAAC,EAAE,CAAC;oBAC5D,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AAC,UAAU,CAAC,CAAC,UAAU,EAAE,CAAC;YAClE,EAAE,CAAC,UAAU,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,MAAkB,CAAC,CAAC;YACtD,EAAE,CAAC,OAAO,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;YACpC,EAAE,CAAC,OAAO,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;QACtC,CAAC,CAAC,CAAC;QAEH,OAAO;YACL,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,EAAe,CAAA,CAAC;YACjD,SAAS,EAAE,KAAK;YAChB,iBAAiB,EAAE,EAAE;YACrB,MAAM,EAAE,SAAS;SACL,CAAC;IACjB,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { ObjectStorage } from "./ObjectStorage/class.js";
2
+ declare const _default: ObjectStorage;
3
+ export default _default;
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;;AAEzD,wBAAmC"}
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ import { ObjectStorage } from "./ObjectStorage/class.js";
2
+ export default new ObjectStorage();
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEzD,eAAe,IAAI,aAAa,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,26 +1,27 @@
1
1
  {
2
2
  "name": "offdex",
3
- "version": "2.0.0",
4
- "description": "Minimal, unbiased IndexedDB object-store wrapper keyed by a string. Shared across browser threads, offline-persistent, simple API.",
3
+ "version": "3.0.0",
4
+ "description": "IndexedDB-backed object storage for structured-clone JS values (msgpack-compatible) in browsers and workers.",
5
5
  "keywords": [
6
6
  "indexeddb",
7
- "offline",
7
+ "structured-clone",
8
+ "msgpack",
9
+ "binary",
10
+ "object",
8
11
  "storage",
9
12
  "browser-storage",
10
13
  "web-storage",
11
- "object-store",
12
- "key-value",
13
- "key",
14
- "persist",
15
- "threads",
16
- "workers",
17
- "shared",
18
- "minimal"
14
+ "r2",
15
+ "cloudflare",
16
+ "bucket",
17
+ "offline",
18
+ "worker",
19
+ "persist"
19
20
  ],
20
21
  "license": "MIT",
21
22
  "type": "module",
22
- "main": "src/index.js",
23
- "types": "src/index.d.ts",
23
+ "main": "dist/index.js",
24
+ "types": "dist/index.d.ts",
24
25
  "repository": {
25
26
  "type": "git",
26
27
  "url": "git+https://github.com/jortsupetterson/offdex.git"
@@ -31,15 +32,28 @@
31
32
  "homepage": "https://github.com/jortsupetterson/offdex#readme",
32
33
  "exports": {
33
34
  ".": {
34
- "types": "./src/index.d.ts",
35
- "import": "./src/index.js"
35
+ "types": "./dist/index.d.ts",
36
+ "import": "./dist/index.js"
36
37
  },
37
38
  "./package.json": "./package.json"
38
39
  },
39
40
  "files": [
40
- "src",
41
+ "dist",
41
42
  "LICENSE",
42
43
  "README.md"
43
44
  ],
44
- "sideEffects": false
45
+ "sideEffects": false,
46
+ "scripts": {
47
+ "build": "tsc -p tsconfig.build.json",
48
+ "test": "npm run build && playwright test",
49
+ "bench": "npm run build && playwright test -c playwright.bench.config.ts",
50
+ "prepublishOnly": "npm run build"
51
+ },
52
+ "dependencies": {
53
+ "@cloudflare/workers-types": "^4.20260101.0"
54
+ },
55
+ "devDependencies": {
56
+ "@playwright/test": "^1.57.0",
57
+ "typescript": "^5.9.3"
58
+ }
45
59
  }
@@ -1,184 +0,0 @@
1
- export class ObjectStore {
2
- static #idb = "offdex";
3
- static #store = "objects";
4
-
5
- /**
6
- * @returns {Promise<IDBDatabase>}
7
- */
8
- static #open() {
9
- return new Promise((resolve, reject) => {
10
- const request = indexedDB.open(ObjectStore.#idb);
11
-
12
- request.addEventListener("upgradeneeded", () => {
13
- const db = request.result;
14
- if (!db.objectStoreNames.contains(ObjectStore.#store)) {
15
- db.createObjectStore(ObjectStore.#store, { keyPath: "key" });
16
- }
17
- });
18
-
19
- request.addEventListener("success", () => {
20
- resolve(request.result);
21
- });
22
-
23
- request.addEventListener("error", () => {
24
- reject(request.error);
25
- });
26
- });
27
- }
28
-
29
- constructor() {
30
- this.instance = ObjectStore.#open();
31
- }
32
-
33
- /**
34
- * @param {import("../types").StoredObject} object
35
- * @returns {Promise<void>}
36
- */
37
- async put(object) {
38
- const db = await this.instance;
39
- return new Promise((resolve, reject) => {
40
- const transaction = db.transaction(ObjectStore.#store, "readwrite");
41
- const store = transaction.objectStore(ObjectStore.#store);
42
- store.put(object);
43
-
44
- transaction.oncomplete = () => resolve();
45
- transaction.onerror = () =>
46
- reject(new Error(`{offdex} ObjectStore: ${transaction.error}`));
47
- });
48
- }
49
-
50
- /**
51
- * @param {string} key
52
- * @returns {Promise<import("../types").StoredObject | undefined>}
53
- */
54
- async get(key) {
55
- const db = await this.instance;
56
-
57
- return new Promise((resolve, reject) => {
58
- const transaction = db.transaction(ObjectStore.#store, "readonly");
59
- const store = transaction.objectStore(ObjectStore.#store);
60
- const request = store.get(key);
61
-
62
- transaction.oncomplete = () => {
63
- if (!request.result) {
64
- resolve(undefined);
65
- return;
66
- }
67
-
68
- resolve(request.result);
69
- };
70
-
71
- transaction.onerror = () =>
72
- reject(new Error(`{offdex} ObjectStore: ${transaction.error}`));
73
- });
74
- }
75
-
76
- /**
77
- * @param {string} key
78
- * @returns {Promise<void>}
79
- */
80
- async delete(key) {
81
- const db = await this.instance;
82
- return new Promise((resolve, reject) => {
83
- const transaction = db.transaction(ObjectStore.#store, "readwrite");
84
- const store = transaction.objectStore(ObjectStore.#store);
85
- store.delete(key);
86
- transaction.oncomplete = () => resolve();
87
- transaction.onerror = () =>
88
- reject(new Error(`{offdex} ObjectStore: ${transaction.error}`));
89
- });
90
- }
91
-
92
- /**
93
- * @param {import("../types").StoredObject[]} objects
94
- * @returns {Promise<void>}
95
- */
96
- async putAll(objects) {
97
- const db = await this.instance;
98
- return new Promise((resolve, reject) => {
99
- const transaction = db.transaction(ObjectStore.#store, "readwrite");
100
- const store = transaction.objectStore(ObjectStore.#store);
101
-
102
- for (const object of objects) {
103
- store.put(object);
104
- }
105
-
106
- transaction.oncomplete = () => resolve();
107
- transaction.onerror = () =>
108
- reject(new Error(`{offdex} ObjectStore.putAll: ${transaction.error}`));
109
- });
110
- }
111
-
112
- /**
113
- * @param {import("../StorageQuery/index.js").StorageQuery | ((object: import("../types").StoredObject) => boolean)} queryOrPredicate
114
- * @returns {Promise<import("../types").StoredObject[]>}
115
- */
116
- async getAllMatches(queryOrPredicate) {
117
- const db = await this.instance;
118
- const objectStoreInstance = this;
119
-
120
- const predicate =
121
- typeof queryOrPredicate === "function"
122
- ? queryOrPredicate
123
- : (object) => queryOrPredicate.matches(object);
124
-
125
- return new Promise((resolve, reject) => {
126
- const transaction = db.transaction(ObjectStore.#store, "readonly");
127
- const store = transaction.objectStore(ObjectStore.#store);
128
- const request = store.openCursor();
129
-
130
- const results = [];
131
-
132
- request.onsuccess = () => {
133
- const cursor = request.result;
134
- if (!cursor) return;
135
-
136
- const value = cursor.value;
137
-
138
- if (predicate(value)) {
139
- results.push(value);
140
- }
141
-
142
- cursor.continue();
143
- };
144
-
145
- transaction.oncomplete = () => resolve(results);
146
- transaction.onerror = () =>
147
- reject(new Error(`{offdex} ObjectStore: ${transaction.error}`));
148
- });
149
- }
150
-
151
- /**
152
- * @param {import("../StorageQuery/index.js").StorageQuery | ((object: import("../types").StoredObject) => boolean)} queryOrPredicate
153
- * @returns {Promise<void>}
154
- */
155
- async deleteAllMatches(queryOrPredicate) {
156
- const db = await this.instance;
157
-
158
- const predicate =
159
- typeof queryOrPredicate === "function"
160
- ? queryOrPredicate
161
- : (object) => queryOrPredicate.matches(object);
162
-
163
- return new Promise((resolve, reject) => {
164
- const transaction = db.transaction(ObjectStore.#store, "readwrite");
165
- const store = transaction.objectStore(ObjectStore.#store);
166
- const request = store.openCursor();
167
-
168
- request.onsuccess = () => {
169
- const cursor = request.result;
170
- if (!cursor) return;
171
-
172
- if (predicate(cursor.value)) {
173
- cursor.delete();
174
- }
175
-
176
- cursor.continue();
177
- };
178
-
179
- transaction.oncomplete = () => resolve();
180
- transaction.onerror = () =>
181
- reject(new Error(`{offdex} ObjectStore: ${transaction.error}`));
182
- });
183
- }
184
- }
@@ -1,12 +0,0 @@
1
- import { ObservableValue } from "../ObservableValue/index.js";
2
-
3
- export class ObservableObject {
4
- /**
5
- * @param {import("../types").StoredObject} object
6
- */
7
- constructor(object) {
8
- for (const key in object) {
9
- this[key] = new ObservableValue(object[key]);
10
- }
11
- }
12
- }
@@ -1,58 +0,0 @@
1
- export class ObservableValue {
2
- /**
3
- * @param {any} value
4
- * @param {any} [fallback]
5
- */
6
- constructor(value, fallback = null) {
7
- this.value = value;
8
- this.fallback = fallback;
9
- /** @type {Set<{ event: "set" | "reset"; callback: (value: any) => void }>} */
10
- this.observers = new Set();
11
- }
12
- get() {
13
- return this.value;
14
- }
15
- /**
16
- * @param {any} newValue
17
- * @returns {void}
18
- */
19
- set(newValue) {
20
- if (newValue === this.value) return;
21
- this.value = newValue;
22
- const changeObservers = [...this.observers].filter(
23
- (observer) => observer.event === "set"
24
- );
25
- for (const observer of changeObservers) {
26
- observer.callback(newValue);
27
- }
28
- }
29
- reset() {
30
- this.value = this.fallback;
31
- const resetObservers = [...this.observers].filter(
32
- (observer) => observer.event === "reset"
33
- );
34
- for (const observer of resetObservers) {
35
- observer.callback(this.fallback);
36
- }
37
- }
38
- /**
39
- * @param {"set" | "reset"} event
40
- * @param {Function} callback
41
- * @returns {() => void}
42
- */
43
- observe(event, callback) {
44
- if (event !== "set" && event !== "reset")
45
- throw new Error(
46
- "{offdex} ObservableValue: Supported `event` parameters are [set, reset]"
47
- );
48
- if (typeof callback !== "function")
49
- throw new Error(
50
- "{offdex} ObservableValue: Paramater `callback` must be of type function"
51
- );
52
- const observer = { event, callback };
53
- this.observers.add(observer);
54
- return () => {
55
- this.observers.delete(observer);
56
- };
57
- }
58
- }
@@ -1,12 +0,0 @@
1
- export class StorageQuery {
2
- constructor(args = {}) {
3
- this.args = args;
4
- }
5
-
6
- matches(object) {
7
- for (const key in this.args) {
8
- if (object[key] !== this.args[key]) return false;
9
- }
10
- return true;
11
- }
12
- }
package/src/index.d.ts DELETED
@@ -1,36 +0,0 @@
1
- export type StoredObject = { key: string } & Record<string, unknown>;
2
-
3
- export class StorageQuery {
4
- constructor(args?: Record<string, unknown>);
5
- args: Record<string, unknown>;
6
- matches(object: StoredObject): boolean;
7
- }
8
-
9
- export class ObservableValue<T = unknown> {
10
- constructor(value: T, fallback?: T);
11
- get(): T;
12
- set(newValue: T): void;
13
- reset(): void;
14
- observe(event: "set" | "reset", callback: (value: T) => void): () => void;
15
- }
16
-
17
- export class ObservableObject<T extends StoredObject = StoredObject> {
18
- constructor(object: T);
19
- [key: string]: ObservableValue<unknown>;
20
- }
21
-
22
- export class ObjectStore {
23
- constructor();
24
- put(object: StoredObject): Promise<void>;
25
- get(key: string): Promise<StoredObject | undefined>;
26
- delete(key: string): Promise<void>;
27
- putAll(objects: StoredObject[]): Promise<void>;
28
- getAllMatches(
29
- queryOrFilter: StorageQuery | ((object: StoredObject) => boolean)
30
- ): Promise<StoredObject[]>;
31
- deleteAllMatches(
32
- queryOrFilter: StorageQuery | ((object: StoredObject) => boolean)
33
- ): Promise<void>;
34
- }
35
-
36
- export const storage: ObjectStore;
package/src/index.js DELETED
@@ -1,7 +0,0 @@
1
- import { ObjectStore } from "./ObjectStore/index.js";
2
- import { StorageQuery } from "./StorageQuery/index.js";
3
- import { ObservableValue } from "./ObservableValue/index.js";
4
- import { ObservableObject } from "./ObservableObject/index.js";
5
-
6
- export { ObjectStore, StorageQuery, ObservableValue, ObservableObject };
7
- export const storage = new ObjectStore();
package/src/types.d.ts DELETED
@@ -1 +0,0 @@
1
- export type StoredObject = { key: string } & Record<string, unknown>;