flash-store 2.0.1 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/README.md +94 -19
  2. package/dist/package.json +90 -61
  3. package/dist/src/config.d.ts +4 -0
  4. package/dist/src/config.d.ts.map +1 -1
  5. package/dist/src/config.js +4 -11
  6. package/dist/src/config.js.map +1 -1
  7. package/dist/src/{flash-store.d.ts → flash-store-core.d.ts} +17 -21
  8. package/dist/src/flash-store-core.d.ts.map +1 -0
  9. package/dist/src/flash-store-core.js +201 -0
  10. package/dist/src/flash-store-core.js.map +1 -0
  11. package/dist/src/{flash-store-sync.d.ts → flash-store-sync-core.d.ts} +8 -9
  12. package/dist/src/flash-store-sync-core.d.ts.map +1 -0
  13. package/dist/src/{flash-store-sync.js → flash-store-sync-core.js} +10 -11
  14. package/dist/src/flash-store-sync-core.js.map +1 -0
  15. package/dist/src/indexeddb-backend.d.ts +44 -0
  16. package/dist/src/indexeddb-backend.d.ts.map +1 -0
  17. package/dist/src/indexeddb-backend.js +207 -0
  18. package/dist/src/indexeddb-backend.js.map +1 -0
  19. package/dist/src/key-encoding.d.ts +9 -0
  20. package/dist/src/key-encoding.d.ts.map +1 -0
  21. package/dist/src/key-encoding.js +11 -0
  22. package/dist/src/key-encoding.js.map +1 -0
  23. package/dist/src/mod.d.ts +21 -5
  24. package/dist/src/mod.d.ts.map +1 -1
  25. package/dist/src/mod.js +25 -4
  26. package/dist/src/mod.js.map +1 -1
  27. package/dist/src/node/flash-store-sync.d.ts +12 -0
  28. package/dist/src/node/flash-store-sync.d.ts.map +1 -0
  29. package/dist/src/node/flash-store-sync.js +14 -0
  30. package/dist/src/node/flash-store-sync.js.map +1 -0
  31. package/dist/src/node/flash-store.d.ts +11 -0
  32. package/dist/src/node/flash-store.d.ts.map +1 -0
  33. package/dist/src/node/flash-store.js +108 -0
  34. package/dist/src/node/flash-store.js.map +1 -0
  35. package/dist/src/node/key-encoding.d.ts +8 -0
  36. package/dist/src/node/key-encoding.d.ts.map +1 -0
  37. package/dist/src/node/key-encoding.js +18 -0
  38. package/dist/src/node/key-encoding.js.map +1 -0
  39. package/dist/src/node/mod.d.ts +14 -0
  40. package/dist/src/node/mod.d.ts.map +1 -0
  41. package/dist/src/node/mod.js +13 -0
  42. package/dist/src/node/mod.js.map +1 -0
  43. package/dist/src/store-backend.d.ts +35 -0
  44. package/dist/src/store-backend.d.ts.map +1 -0
  45. package/dist/src/store-backend.js +2 -0
  46. package/dist/src/store-backend.js.map +1 -0
  47. package/package.json +39 -10
  48. package/dist/src/flash-store-sync.d.ts.map +0 -1
  49. package/dist/src/flash-store-sync.js.map +0 -1
  50. package/dist/src/flash-store.d.ts.map +0 -1
  51. package/dist/src/flash-store.js +0 -246
  52. package/dist/src/flash-store.js.map +0 -1
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Binds the public native FlashStore constructor to LMDB. Filesystem paths,
3
+ * destruction safeguards, and Node diagnostics stay behind this entry point.
4
+ */
5
+ import { channel } from 'node:diagnostics_channel';
6
+ import { rm } from 'node:fs/promises';
7
+ import { homedir, tmpdir } from 'node:os';
8
+ import { parse, resolve } from 'node:path';
9
+ import { IF_EXISTS, open } from 'lmdb';
10
+ import { FlashStoreCore } from '../flash-store-core.js';
11
+ import { encodePrefixEnd } from './key-encoding.js';
12
+ const operations = channel('flash-store.operation');
13
+ /** Adapts the existing LMDB layout without changing its key encoding or JSON bytes. */
14
+ class LmdbBackend {
15
+ db;
16
+ path;
17
+ /** Opens the existing on-disk database or creates a fresh environment. */
18
+ constructor(path) {
19
+ this.path = path;
20
+ this.db = open({ path, noSubdir: false, encoding: 'string' });
21
+ }
22
+ /** Enqueues a write of serialized JSON. */
23
+ put(key, json) {
24
+ return this.db.put(key, json);
25
+ }
26
+ /** Reads from the current transaction snapshot. */
27
+ get(key) {
28
+ return this.db.get(key);
29
+ }
30
+ /** Checks existence without decoding the value. */
31
+ has(key) {
32
+ return this.db.doesExist(key);
33
+ }
34
+ /** Reports existence in the transaction that performs the deletion. */
35
+ delete(key) {
36
+ // A plain remove() reports success even when the key was absent.
37
+ return this.db.remove(key, IF_EXISTS);
38
+ }
39
+ /** Queues an atomic clear. */
40
+ clear() {
41
+ return this.db.clearAsync();
42
+ }
43
+ /** Counts the entries in the current snapshot. */
44
+ async count() {
45
+ return this.db.getCount();
46
+ }
47
+ /** Seeks directly to the range and releases the LMDB cursor on early exit. */
48
+ *scan({ lower, upper, lowerOpen, upperOpen, reverse, prefix, limit, }) {
49
+ const endOfPrefix = reverse && prefix !== undefined ? encodePrefixEnd(prefix) : undefined;
50
+ const range = prefix === undefined
51
+ ? {
52
+ start: reverse ? upper : lower,
53
+ end: reverse ? lower : upper,
54
+ reverse,
55
+ exclusiveStart: reverse ? upperOpen : lowerOpen,
56
+ inclusiveEnd: reverse ? !lowerOpen : !upperOpen,
57
+ }
58
+ : {
59
+ start: reverse ? endOfPrefix : prefix,
60
+ reverse,
61
+ exclusiveStart: reverse && endOfPrefix !== undefined,
62
+ };
63
+ let count = 0;
64
+ for (const entry of this.db.getRange(range)) {
65
+ if (prefix !== undefined &&
66
+ (typeof entry.key !== 'string' || !entry.key.startsWith(prefix)))
67
+ break;
68
+ yield entry;
69
+ if (++count === limit)
70
+ break;
71
+ }
72
+ }
73
+ /** Flushes pending writes and closes LMDB. */
74
+ close() {
75
+ return this.db.close();
76
+ }
77
+ /** Removes the dedicated directory after the facade closes the environment. */
78
+ destroy() {
79
+ return rm(this.path, { recursive: true, force: true });
80
+ }
81
+ /** Publishes the operation name after a successful commit without storing caller data. */
82
+ publish(operation) {
83
+ if (operations.hasSubscribers)
84
+ operations.publish({ operation });
85
+ }
86
+ }
87
+ /** Persistent Map backed by LMDB with JSON-serialized values. */
88
+ export class FlashStore extends FlashStoreCore {
89
+ /** Opens an LMDB database in the specified directory. */
90
+ constructor(workdir) {
91
+ const path = resolve(workdir);
92
+ super(path, new LmdbBackend(path), workdir);
93
+ }
94
+ /** Refuses to close or remove protected locations. Use a dedicated directory. */
95
+ async destroy() {
96
+ const protectedPaths = [
97
+ parse(this.workdir).root,
98
+ resolve(process.cwd()),
99
+ resolve(tmpdir()),
100
+ resolve(homedir()),
101
+ ];
102
+ if (protectedPaths.includes(this.workdir))
103
+ throw new Error('Refusing to remove a protected directory');
104
+ await super.destroy();
105
+ }
106
+ }
107
+ export default FlashStore;
108
+ //# sourceMappingURL=flash-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flash-store.js","sourceRoot":"","sources":["../../../src/node/flash-store.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAA;AAClD,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAA;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AACzC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,EAAE,SAAS,EAAE,IAAI,EAAqB,MAAM,MAAM,CAAA;AACzD,OAAO,EAAE,cAAc,EAAiB,MAAM,wBAAwB,CAAA;AAEtE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAOnD,MAAM,UAAU,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAA;AAEnD,uFAAuF;AACvF,MAAM,WAAW;IACE,EAAE,CAAgC;IAClC,IAAI,CAAQ;IAE7B,0EAA0E;IAC1E,YAAY,IAAY;QACtB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAA;IAC/D,CAAC;IAED,2CAA2C;IAC3C,GAAG,CAAC,GAAa,EAAE,IAAY;QAC7B,OAAO,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,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CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI;YACxB,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC;YACtB,OAAO,CAAC,MAAM,EAAE,CAAC;YACjB,OAAO,CAAC,OAAO,EAAE,CAAC;SACnB,CAAA;QACD,IAAI,cAAc,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC;YACvC,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAA;QAC7D,MAAM,KAAK,CAAC,OAAO,EAAE,CAAA;IACvB,CAAC;CACF;AAED,eAAe,UAAU,CAAA"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Encodes string prefixes into LMDB key bounds. It is node-only because the
3
+ * bound's byte layout is specific to LMDB; the web build uses IndexedDB
4
+ * key ranges instead.
5
+ */
6
+ /** Returns an exclusive bound for a nonempty encoded string prefix for LMDB. */
7
+ export declare function encodePrefixEnd(prefix: string): Uint8Array<ArrayBuffer> | undefined;
8
+ //# sourceMappingURL=key-encoding.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"key-encoding.d.ts","sourceRoot":"","sources":["../../../src/node/key-encoding.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,gFAAgF;AAChF,wBAAgB,eAAe,CAC7B,MAAM,EAAE,MAAM,GACb,UAAU,CAAC,WAAW,CAAC,GAAG,SAAS,CAQrC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Encodes string prefixes into LMDB key bounds. It is node-only because the
3
+ * bound's byte layout is specific to LMDB; the web build uses IndexedDB
4
+ * key ranges instead.
5
+ */
6
+ const encoder = new TextEncoder();
7
+ /** Returns an exclusive bound for a nonempty encoded string prefix for LMDB. */
8
+ export function encodePrefixEnd(prefix) {
9
+ if (prefix === '')
10
+ return undefined;
11
+ const bytes = encoder.encode(prefix);
12
+ // An encoded UTF-8 string ends in an ASCII or continuation byte (none is 255).
13
+ // Advancing the byte keeps the bound within the key limit.
14
+ const last = bytes.length - 1;
15
+ bytes[last] = (bytes[last] ?? 0) + 1;
16
+ return bytes;
17
+ }
18
+ //# sourceMappingURL=key-encoding.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"key-encoding.js","sourceRoot":"","sources":["../../../src/node/key-encoding.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAA;AAEjC,gFAAgF;AAChF,MAAM,UAAU,eAAe,CAC7B,MAAc;IAEd,IAAI,MAAM,KAAK,EAAE;QAAE,OAAO,SAAS,CAAA;IACnC,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;IACpC,+EAA+E;IAC/E,2DAA2D;IAC3D,MAAM,IAAI,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,CAAA;IAC7B,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAA;IACpC,OAAO,KAAK,CAAA;AACd,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Node entry: the build selected by the `node` export condition (Node.js,
3
+ * Deno, Bun). Persists to LMDB and may use native OS capabilities. It exports
4
+ * the same names and public contract as `../mod.ts`.
5
+ */
6
+ import { FlashStore } from './flash-store.ts';
7
+ export { log, VERSION } from '../config.ts';
8
+ export { FlashStoreCore } from '../flash-store-core.ts';
9
+ export { FlashStoreSyncCore } from '../flash-store-sync-core.ts';
10
+ export type { IteratorOptions, StoreKey } from './flash-store.ts';
11
+ export { FlashStore } from './flash-store.ts';
12
+ export { FlashStoreSync } from './flash-store-sync.ts';
13
+ export default FlashStore;
14
+ //# sourceMappingURL=mod.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../src/node/mod.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAE7C,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAA;AAChE,YAAY,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;eACvC,UAAU"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Node entry: the build selected by the `node` export condition (Node.js,
3
+ * Deno, Bun). Persists to LMDB and may use native OS capabilities. It exports
4
+ * the same names and public contract as `../mod.ts`.
5
+ */
6
+ import { FlashStore } from './flash-store.js';
7
+ export { log, VERSION } from '../config.js';
8
+ export { FlashStoreCore } from '../flash-store-core.js';
9
+ export { FlashStoreSyncCore } from '../flash-store-sync-core.js';
10
+ export { FlashStore } from './flash-store.js';
11
+ export { FlashStoreSync } from './flash-store-sync.js';
12
+ export default FlashStore;
13
+ //# sourceMappingURL=mod.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mod.js","sourceRoot":"","sources":["../../../src/node/mod.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAE7C,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAA;AAEhE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACtD,eAAe,UAAU,CAAA"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Describes the serialized storage contract between the shared Map API and
3
+ * LMDB or IndexedDB. Backends own resource lifetimes and transaction boundaries.
4
+ */
5
+ import type { StoreKey } from './flash-store-core.ts';
6
+ /** A normalized scan. A string prefix is mutually exclusive with explicit bounds. */
7
+ export interface ScanRange {
8
+ lower?: StoreKey;
9
+ upper?: StoreKey;
10
+ lowerOpen: boolean;
11
+ upperOpen: boolean;
12
+ reverse: boolean;
13
+ prefix?: string;
14
+ limit?: number;
15
+ }
16
+ /** A record whose value is already serialized. */
17
+ export interface StoredEntry {
18
+ key: StoreKey;
19
+ value: string;
20
+ }
21
+ /** Internal storage operations. Writes resolve once the backend commits them. */
22
+ export interface StoreBackend {
23
+ put(key: StoreKey, json: string): Promise<unknown>;
24
+ get(key: StoreKey): string | undefined | Promise<string | undefined>;
25
+ has(key: StoreKey): boolean | Promise<boolean>;
26
+ delete(key: StoreKey): Promise<boolean>;
27
+ clear(): Promise<void>;
28
+ /** Starts a count on the current read snapshot before returning its promise. */
29
+ count(): Promise<number>;
30
+ scan(range: ScanRange): Iterable<StoredEntry> | Promise<Iterable<StoredEntry>>;
31
+ close(): Promise<void>;
32
+ destroy(): Promise<void>;
33
+ publish?(operation: 'set' | 'delete' | 'clear'): void;
34
+ }
35
+ //# sourceMappingURL=store-backend.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store-backend.d.ts","sourceRoot":"","sources":["../../src/store-backend.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAErD,qFAAqF;AACrF,MAAM,WAAW,SAAS;IACxB,KAAK,CAAC,EAAE,QAAQ,CAAA;IAChB,KAAK,CAAC,EAAE,QAAQ,CAAA;IAChB,SAAS,EAAE,OAAO,CAAA;IAClB,SAAS,EAAE,OAAO,CAAA;IAClB,OAAO,EAAE,OAAO,CAAA;IAChB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,kDAAkD;AAClD,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,QAAQ,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;CACd;AAED,iFAAiF;AACjF,MAAM,WAAW,YAAY;IAC3B,GAAG,CAAC,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IAClD,GAAG,CAAC,GAAG,EAAE,QAAQ,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAA;IACpE,GAAG,CAAC,GAAG,EAAE,QAAQ,GAAG,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IAC9C,MAAM,CAAC,GAAG,EAAE,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IACvC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IACtB,gFAAgF;IAChF,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC,CAAA;IACxB,IAAI,CAAC,KAAK,EAAE,SAAS,GAAG,QAAQ,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAA;IAC9E,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IACtB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IACxB,OAAO,CAAC,CAAC,SAAS,EAAE,KAAK,GAAG,QAAQ,GAAG,OAAO,GAAG,IAAI,CAAA;CACtD"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=store-backend.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store-backend.js","sourceRoot":"","sources":["../../src/store-backend.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,12 +1,22 @@
1
1
  {
2
2
  "name": "flash-store",
3
- "version": "2.0.1",
4
- "description": "Persistent Map-like storage backed by LMDB.",
3
+ "version": "2.2.0",
4
+ "description": "Persistent Map-like storage for Node.js, Deno, and Chrome.",
5
5
  "type": "module",
6
6
  "exports": {
7
7
  ".": {
8
8
  "types": "./dist/src/mod.d.ts",
9
- "import": "./dist/src/mod.js"
9
+ "browser": "./dist/src/mod.js",
10
+ "node": "./dist/src/node/mod.js",
11
+ "default": "./dist/src/mod.js"
12
+ },
13
+ "./browser": {
14
+ "types": "./dist/src/mod.d.ts",
15
+ "default": "./dist/src/mod.js"
16
+ },
17
+ "./node": {
18
+ "types": "./dist/src/node/mod.d.ts",
19
+ "default": "./dist/src/node/mod.js"
10
20
  }
11
21
  },
12
22
  "types": "./dist/src/mod.d.ts",
@@ -15,18 +25,23 @@
15
25
  "npm": ">=11"
16
26
  },
17
27
  "scripts": {
18
- "build": "tsc && node scripts/prepare-package.ts",
28
+ "build": "node scripts/prepare-package.ts && tsc",
19
29
  "prepack": "npm run build",
20
30
  "demo": "node example/demo.ts",
21
31
  "benchmark": "node scripts/benchmark.ts",
22
- "lint": "biome check src example scripts tsconfig.json package.json biome.json coverage-baselines.json",
32
+ "lint": "biome check src example scripts tests web-test-runner.config.js tsconfig.json package.json biome.json .github/coverage-baselines",
23
33
  "typecheck": "tsc --noEmit",
24
34
  "test": "npm run typecheck && npm run lint && npm run test:unit",
25
- "test:unit": "node --test src/*.test.ts",
26
- "test:deno": "deno test --no-check --allow-read --allow-write --allow-env --allow-ffi --allow-sys=homedir src/",
35
+ "test:unit": "node --test \"src/**/*.test.ts\"",
36
+ "test:deno": "npm run test:unit:deno",
27
37
  "coverage:node": "node scripts/coverage.ts node",
28
38
  "coverage:deno": "node scripts/coverage.ts deno",
29
- "test:pack": "node scripts/pack-test.ts"
39
+ "coverage:browser": "node scripts/coverage.ts browser",
40
+ "test:pack": "node scripts/pack-test.ts",
41
+ "test:unit:deno": "deno test --no-check --allow-read --allow-write --allow-env --allow-ffi --allow-sys=homedir src/",
42
+ "test:unit:browser": "wtr --config web-test-runner.config.js",
43
+ "test:integration": "node --test \"tests/*.integration.test.ts\"",
44
+ "test:integration:deno": "deno test --no-check --allow-read --allow-write --allow-env --allow-ffi --allow-sys=homedir tests/native.integration.test.ts"
30
45
  },
31
46
  "repository": {
32
47
  "type": "git",
@@ -44,21 +59,35 @@
44
59
  },
45
60
  "homepage": "https://github.com/huan/flash-store#readme",
46
61
  "dependencies": {
47
- "brolog": "^1.14.2",
62
+ "brolog": "^2.0.0",
48
63
  "lmdb": "~3.5.9"
49
64
  },
50
65
  "devDependencies": {
51
66
  "@biomejs/biome": "2.6.7",
67
+ "@types/chai": "^5.2.3",
52
68
  "@types/node": "^26.6.6",
69
+ "@web/dev-server-esbuild": "^2.0.1",
70
+ "@web/test-runner": "^1.0.1",
71
+ "@web/test-runner-playwright": "^1.0.2",
72
+ "chai": "^6.3.0",
73
+ "esbuild": "^0.28.2",
74
+ "playwright": "^1.61.1",
53
75
  "typescript": "^7.0.2"
54
76
  },
55
77
  "files": [
56
78
  "dist/src/",
57
- "!dist/src/*.test.*",
79
+ "!dist/src/**/*.test.*",
80
+ "!dist/src/**/test-fixture.*",
58
81
  "dist/package.json"
59
82
  ],
60
83
  "publishConfig": {
61
84
  "access": "public",
62
85
  "tag": "next"
86
+ },
87
+ "imports": {
88
+ "#test-store": {
89
+ "browser": "./src/mod.ts",
90
+ "default": "./src/node/mod.ts"
91
+ }
63
92
  }
64
93
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"flash-store-sync.d.ts","sourceRoot":"","sources":["../../src/flash-store-sync.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAEL,KAAK,QAAQ,EAId,MAAM,kBAAkB,CAAA;AAEzB;;;;GAIG;AACH,qBAAa,cAAc,CAAC,CAAC,SAAS,QAAQ,GAAG,QAAQ,EAAE,CAAC,GAAG,OAAO,CACpE,YAAW,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC;IAEpB,MAAM,CAAC,OAAO,SAAqB;IACnC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAkB;IAC3C,OAAO,CAAC,QAAQ,CAAC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AAE,KAAK,EAAE,IAAI,KAAK,OAAO,EACpD,OAAO,CAAC,EAAE,OAAO,GAChB,OAAO,CAAC,IAAI,CAAC,CAIf;IAED,6EAA6E;IACvE,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAI3B;IAED,uFAAuF;IACjF,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAY7B;CACF;eAEc,UAAU"}
@@ -1,246 +0,0 @@
1
- /**
2
- * Implements the asynchronous Map-like API over an LMDB environment.
3
- * It owns the database lifecycle, key validation, and JSON serialization. The
4
- * synchronous facade builds on this API and its internal serialized-write hook.
5
- */
6
- import { channel } from 'node:diagnostics_channel';
7
- import { rm } from 'node:fs/promises';
8
- import { homedir, tmpdir } from 'node:os';
9
- import { parse, resolve } from 'node:path';
10
- import { IF_EXISTS, open } from 'lmdb';
11
- import { log, VERSION } from './config.js';
12
- const operations = channel('flash-store.operation');
13
- /** Reject keys that the configured ordered-binary encoding cannot represent safely. */
14
- export function validateKey(key) {
15
- if ((typeof key === 'number' && !Number.isFinite(key)) ||
16
- (typeof key === 'string' && key.includes('\0')) ||
17
- (typeof key !== 'number' && typeof key !== 'string')) {
18
- throw new TypeError('Keys must be finite numbers or strings without null characters');
19
- }
20
- }
21
- /** Serialize a value once, rejecting values that JSON cannot represent. */
22
- export function serialize(value) {
23
- const serialized = JSON.stringify(value);
24
- if (serialized === undefined)
25
- throw new TypeError('Value must be JSON serializable');
26
- return serialized;
27
- }
28
- /**
29
- * Return the smallest string after every string starting with `prefix`, or
30
- * undefined when none exists. LMDB orders strings by UTF-8 bytes, which matches
31
- * code point order, so matching keys form one contiguous interval.
32
- */
33
- function prefixEnd(prefix) {
34
- const codePoints = Array.from(prefix);
35
- while (codePoints.length > 0) {
36
- const last = codePoints.pop()?.codePointAt(0);
37
- if (last !== undefined && last < 0x10ffff) {
38
- // Surrogate code points are not encodable scalar values; skip them.
39
- const next = last === 0xd7ff ? 0xe000 : last + 1;
40
- return codePoints.join('') + String.fromCodePoint(next);
41
- }
42
- }
43
- return undefined;
44
- }
45
- /** Start reverse prefix scans just below the interval end, or at the database end. */
46
- function prefixRange(prefix) {
47
- const end = prefixEnd(prefix);
48
- return { start: end, reverse: true, exclusiveStart: end !== undefined };
49
- }
50
- /**
51
- * Writes pre-serialized JSON for FlashStoreSync, which serializes at call time.
52
- * Internal: mod.ts does not export it, and package exports expose only mod.ts.
53
- */
54
- export let writeSerialized;
55
- /** Use Map's zero equality; TypeScript represents both signs as the same numeric type. */
56
- function normalizeKey(key) {
57
- return Object.is(key, -0) ? 0 : key;
58
- }
59
- /** Reject ambiguous bounds before creating an LMDB cursor. */
60
- function validateOptions(options) {
61
- if (options.prefix !== undefined && typeof options.prefix !== 'string') {
62
- throw new TypeError('prefix must be a string');
63
- }
64
- if ((options.gt !== undefined && options.gte !== undefined) ||
65
- (options.lt !== undefined && options.lte !== undefined) ||
66
- (options.prefix !== undefined &&
67
- (options.gt !== undefined ||
68
- options.gte !== undefined ||
69
- options.lt !== undefined ||
70
- options.lte !== undefined))) {
71
- throw new TypeError('Conflicting range bounds');
72
- }
73
- if (options.limit !== undefined &&
74
- (!Number.isSafeInteger(options.limit) || options.limit < 0)) {
75
- throw new RangeError('limit must be a non-negative safe integer');
76
- }
77
- for (const bound of [options.gt, options.gte, options.lt, options.lte]) {
78
- if (bound !== undefined)
79
- validateKey(bound);
80
- }
81
- }
82
- /**
83
- * Persistent key-value store. Values use JSON round-tripping, which may change their
84
- * runtime type; the generic value type does not validate or prevent this.
85
- */
86
- export class FlashStore {
87
- static VERSION = VERSION;
88
- workdir;
89
- db;
90
- closePromise;
91
- static {
92
- writeSerialized = (store, key, serialized) => store.write(key, serialized);
93
- }
94
- /** Opens an LMDB database in the specified directory. */
95
- constructor(workdir) {
96
- this.workdir = resolve(workdir);
97
- this.db = open({
98
- path: this.workdir,
99
- noSubdir: false,
100
- // Values are serialized once before writing, using LMDB's JSON byte format.
101
- encoding: 'string',
102
- });
103
- log.verbose('FlashStore', 'constructor(%s)', workdir);
104
- }
105
- /** Returns the package version. */
106
- version() {
107
- return VERSION;
108
- }
109
- /** Stores a JSON-serializable value and resolves after its write completes. */
110
- async set(key, value) {
111
- validateKey(key);
112
- const serialized = serialize(value);
113
- log.verbose('FlashStore', 'set(%s, %s)', key, typeof value);
114
- await this.write(key, serialized);
115
- return this;
116
- }
117
- /** Writes validated, serialized JSON and publishes the set event on success. */
118
- async write(key, serialized) {
119
- log.silly('FlashStore', 'set(%s, %s)', key, serialized);
120
- await this.db.put(normalizeKey(key), serialized);
121
- if (operations.hasSubscribers)
122
- operations.publish({ operation: 'set' });
123
- }
124
- /** Returns the stored value, or undefined when the key is absent. */
125
- async get(key) {
126
- validateKey(key);
127
- log.verbose('FlashStore', 'get(%s)', key);
128
- const value = this.db.get(normalizeKey(key));
129
- return value === undefined ? undefined : JSON.parse(value);
130
- }
131
- /** Returns whether the key exists, including when its value is falsey. */
132
- async has(key) {
133
- validateKey(key);
134
- return this.db.doesExist(normalizeKey(key));
135
- }
136
- /** Deletes a key and reports whether an entry existed. */
137
- async delete(key) {
138
- validateKey(key);
139
- log.verbose('FlashStore', 'delete(%s)', key);
140
- // A plain remove() resolves true even for absent keys; IF_EXISTS makes LMDB
141
- // report this operation's own result, in order with other queued writes.
142
- const deleted = await this.db.remove(normalizeKey(key), IF_EXISTS);
143
- if (operations.hasSubscribers)
144
- operations.publish({ operation: 'delete' });
145
- return deleted;
146
- }
147
- /** Removes every entry after queued writes. */
148
- async clear() {
149
- log.verbose('FlashStore', 'clear()');
150
- await this.db.clearAsync();
151
- if (operations.hasSubscribers)
152
- operations.publish({ operation: 'clear' });
153
- }
154
- /** Resolves to the number of entries in the current snapshot. */
155
- get size() {
156
- log.verbose('FlashStore', 'size()');
157
- return Promise.resolve().then(() => this.db.getCount());
158
- }
159
- /**
160
- * Iterates a snapshot in LMDB key order, releasing the cursor on early exit.
161
- * A prefix seeks to its contiguous key interval and stops on leaving it, so
162
- * the cost depends on matching entries rather than database size.
163
- */
164
- async *entries(options = {}) {
165
- log.verbose('FlashStore', '*entries(%s)', JSON.stringify(options));
166
- validateOptions(options);
167
- if (options.limit === 0)
168
- return;
169
- const reverse = options.reverse ?? false;
170
- const lowerBound = options.gte ?? options.gt;
171
- const upperBound = options.lte ?? options.lt;
172
- const lower = lowerBound === undefined ? undefined : normalizeKey(lowerBound);
173
- const upper = upperBound === undefined ? undefined : normalizeKey(upperBound);
174
- const { prefix } = options;
175
- const range = prefix === undefined
176
- ? {
177
- start: reverse ? upper : lower,
178
- end: reverse ? lower : upper,
179
- reverse,
180
- exclusiveStart: reverse
181
- ? options.lt !== undefined
182
- : options.gt !== undefined,
183
- inclusiveEnd: reverse
184
- ? options.gte !== undefined
185
- : options.lte !== undefined,
186
- }
187
- : reverse
188
- ? prefixRange(prefix)
189
- : { start: prefix };
190
- let count = 0;
191
- for (const { key, value } of this.db.getRange(range)) {
192
- // Matching keys are contiguous, so the first mismatch ends the prefix.
193
- if (prefix !== undefined &&
194
- (typeof key !== 'string' || !key.startsWith(prefix)))
195
- break;
196
- yield [key, JSON.parse(value)];
197
- if (++count === options.limit)
198
- break;
199
- }
200
- }
201
- /** Iterates keys with the same range semantics as entries(). */
202
- async *keys(options = {}) {
203
- log.verbose('FlashStore', 'keys()');
204
- for await (const [key] of this.entries(options))
205
- yield key;
206
- }
207
- /** Iterates values with the same range semantics as entries(). */
208
- async *values(options = {}) {
209
- log.verbose('FlashStore', 'values()');
210
- for await (const [, value] of this.entries(options))
211
- yield value;
212
- }
213
- /** Returns the asynchronous entries iterator. */
214
- [Symbol.asyncIterator]() {
215
- log.verbose('FlashStore', '*[Symbol.asyncIterator]()');
216
- return this.entries();
217
- }
218
- /** Awaits each callback in snapshot key order; stops and rejects on the first failure. */
219
- async forEach(callback, thisArg) {
220
- log.verbose('FlashStore', 'forEach()');
221
- for await (const [key, value] of this)
222
- await callback.call(thisArg, value, key, this);
223
- }
224
- /** Closes the database after outstanding writes; repeated calls are safe. */
225
- async close() {
226
- log.verbose('FlashStore', 'close()');
227
- this.closePromise ??= this.db.close();
228
- await this.closePromise;
229
- }
230
- /** Closes and removes the entire database directory. Never pass a shared directory. */
231
- async destroy() {
232
- log.verbose('FlashStore', 'destroy()');
233
- const protectedPaths = [
234
- parse(this.workdir).root,
235
- resolve(process.cwd()),
236
- resolve(tmpdir()),
237
- resolve(homedir()),
238
- ];
239
- if (protectedPaths.includes(this.workdir))
240
- throw new Error('Refusing to remove a protected directory');
241
- await this.close();
242
- await rm(this.workdir, { recursive: true, force: true });
243
- }
244
- }
245
- export default FlashStore;
246
- //# sourceMappingURL=flash-store.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"flash-store.js","sourceRoot":"","sources":["../../src/flash-store.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAA;AAClD,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAA;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AACzC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,EAAE,SAAS,EAAE,IAAI,EAAqB,MAAM,MAAM,CAAA;AACzD,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAgB1C,MAAM,UAAU,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAA;AAEnD,uFAAuF;AACvF,MAAM,UAAU,WAAW,CAAC,GAAa;IACvC,IACE,CAAC,OAAO,GAAG,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QAClD,CAAC,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAC/C,CAAC,OAAO,GAAG,KAAK,QAAQ,IAAI,OAAO,GAAG,KAAK,QAAQ,CAAC,EACpD,CAAC;QACD,MAAM,IAAI,SAAS,CACjB,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