@atproto-labs/simple-store-memory 0.1.4 → 0.2.0-next.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/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # @atproto-labs/simple-store-memory
2
2
 
3
+ ## 0.2.0-next.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#4929](https://github.com/bluesky-social/atproto/pull/4929) [`bb7491c`](https://github.com/bluesky-social/atproto/commit/bb7491c29e06181e1d2f8cf6eb454f9bb8ab961b) Thanks [@devinivy](https://github.com/devinivy)! - **BREAKING:** Drop support for Node.js 18 and 20. Node.js 22 is now the minimum supported version. Docker images now use Node.js 24.
8
+
9
+ - [#4943](https://github.com/bluesky-social/atproto/pull/4943) [`07ae5d4`](https://github.com/bluesky-social/atproto/commit/07ae5d4452df51e045e0239da7a04cf0bc154028) Thanks [@devinivy](https://github.com/devinivy)! - **BREAKING:** Convert to pure ESM. All packages now ship `"type": "module"` with ES module output and Node16 module resolution.
10
+
11
+ Node.js 22's `require()` compatibility layer can still load these packages in CommonJS code.
12
+
13
+ - [#4930](https://github.com/bluesky-social/atproto/pull/4930) [`042df15`](https://github.com/bluesky-social/atproto/commit/042df15087c0e62cd1e715fcbf58852fab875af9) Thanks [@devinivy](https://github.com/devinivy)! - Build with TypeScript 6.0. Emitted `.d.ts` files now use TypeScript 6's stricter `Uint8Array<ArrayBuffer>` typing in places where Web/Node APIs require buffer-backed (not shared-memory) byte arrays. Consumers compiling against these types on older TypeScript should see no runtime impact, but may need to widen or cast in spots that previously relied on `Uint8Array` defaulting to `<ArrayBufferLike>`.
14
+
15
+ Internal: tsconfig `moduleResolution: "node"` is silenced via `ignoreDeprecations: "6.0"` for now; the proper migration to `node16`/`bundler` resolution is deferred.
16
+
17
+ ### Patch Changes
18
+
19
+ - Updated dependencies [[`bb7491c`](https://github.com/bluesky-social/atproto/commit/bb7491c29e06181e1d2f8cf6eb454f9bb8ab961b), [`07ae5d4`](https://github.com/bluesky-social/atproto/commit/07ae5d4452df51e045e0239da7a04cf0bc154028), [`042df15`](https://github.com/bluesky-social/atproto/commit/042df15087c0e62cd1e715fcbf58852fab875af9)]:
20
+ - @atproto-labs/simple-store@0.4.0-next.0
21
+
3
22
  ## 0.1.4
4
23
 
5
24
  ### Patch Changes
package/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  Dual MIT/Apache-2.0 License
2
2
 
3
- Copyright (c) 2022-2025 Bluesky Social PBC, and Contributors
3
+ Copyright (c) 2022-2026 Bluesky Social PBC, and Contributors
4
4
 
5
5
  Except as otherwise noted in individual files, this software is licensed under the MIT license (<http://opensource.org/licenses/MIT>), or the Apache License, Version 2.0 (<http://www.apache.org/licenses/LICENSE-2.0>).
6
6
 
package/dist/index.js CHANGED
@@ -1,28 +1,13 @@
1
- "use strict";
2
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
- if (kind === "m") throw new TypeError("Private method is not writable");
4
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
- };
8
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
- };
13
- var _SimpleStoreMemory_cache;
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.SimpleStoreMemory = void 0;
16
- const lru_cache_1 = require("lru-cache");
17
- const util_js_1 = require("./util.js");
1
+ import { LRUCache } from 'lru-cache';
2
+ import { roughSizeOfObject } from './util.js';
18
3
  // LRUCache does not allow storing "null", so we use a symbol to represent it.
19
4
  const nullSymbol = Symbol('nullItem');
20
5
  const toLruValue = (value) => (value === null ? nullSymbol : value);
21
6
  const fromLruValue = (value) => (value === nullSymbol ? null : value);
22
- class SimpleStoreMemory {
7
+ export class SimpleStoreMemory {
8
+ #cache;
23
9
  constructor({ sizeCalculation, ...options }) {
24
- _SimpleStoreMemory_cache.set(this, void 0);
25
- __classPrivateFieldSet(this, _SimpleStoreMemory_cache, new lru_cache_1.LRUCache({
10
+ this.#cache = new LRUCache({
26
11
  ...options,
27
12
  allowStale: false,
28
13
  updateAgeOnGet: false,
@@ -31,26 +16,24 @@ class SimpleStoreMemory {
31
16
  ? (value, key) => sizeCalculation(fromLruValue(value), key)
32
17
  : options.maxEntrySize != null || options.maxSize != null
33
18
  ? // maxEntrySize and maxSize require a size calculation function.
34
- util_js_1.roughSizeOfObject
19
+ roughSizeOfObject
35
20
  : undefined,
36
- }), "f");
21
+ });
37
22
  }
38
23
  get(key) {
39
- const value = __classPrivateFieldGet(this, _SimpleStoreMemory_cache, "f").get(key);
24
+ const value = this.#cache.get(key);
40
25
  if (value === undefined)
41
26
  return undefined;
42
27
  return fromLruValue(value);
43
28
  }
44
29
  set(key, value) {
45
- __classPrivateFieldGet(this, _SimpleStoreMemory_cache, "f").set(key, toLruValue(value));
30
+ this.#cache.set(key, toLruValue(value));
46
31
  }
47
32
  del(key) {
48
- __classPrivateFieldGet(this, _SimpleStoreMemory_cache, "f").delete(key);
33
+ this.#cache.delete(key);
49
34
  }
50
35
  clear() {
51
- __classPrivateFieldGet(this, _SimpleStoreMemory_cache, "f").clear();
36
+ this.#cache.clear();
52
37
  }
53
38
  }
54
- exports.SimpleStoreMemory = SimpleStoreMemory;
55
- _SimpleStoreMemory_cache = new WeakMap();
56
39
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index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AY,IAAI,IAAI,IAAI,OAAO,CAAC,OAAO,IAAI,IAAI;oBACvD,CAAC,CAAC,gEAAgE;wBAChE,iBAAiB;oBACnB,CAAC,CAAC,SAAS;SAChB,CAAC,CAAA;IACJ,CAAC;IAED,GAAG,CAAC,GAAM;QACR,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QAClC,IAAI,KAAK,KAAK,SAAS;YAAE,OAAO,SAAS,CAAA;QAEzC,OAAO,YAAY,CAAC,KAAK,CAAC,CAAA;IAC5B,CAAC;IAED,GAAG,CAAC,GAAM,EAAE,KAAQ;QAClB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC,CAAA;IACzC,CAAC;IAED,GAAG,CAAC,GAAM;QACR,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;IACzB,CAAC;IAED,KAAK;QACH,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAA;IACrB,CAAC;CACF","sourcesContent":["import { LRUCache } from 'lru-cache'\nimport { Key, SimpleStore, Value } from '@atproto-labs/simple-store'\nimport { roughSizeOfObject } from './util.js'\n\nexport type SimpleStoreMemoryOptions<K extends Key, V extends Value> = {\n /**\n * The maximum number of entries in the cache.\n */\n max?: number\n\n /**\n * The time-to-live of a cache entry, in milliseconds.\n */\n ttl?: number\n\n /**\n * Whether to automatically prune expired entries.\n */\n ttlAutopurge?: boolean\n\n /**\n * The maximum total size of the cache, in units defined by the sizeCalculation\n * function.\n *\n * @default No limit\n */\n maxSize?: number\n\n /**\n * The maximum size of a single cache entry, in units defined by the\n * sizeCalculation function.\n *\n * @default No limit\n */\n maxEntrySize?: number\n\n /**\n * A function that returns the size of a value. The size is used to determine\n * when the cache should be pruned, based on `maxSize`.\n *\n * @default The (rough) size in bytes used in memory.\n */\n sizeCalculation?: (value: V, key: K) => number\n} & ( // Memory is not infinite, so at least one pruning option is required.\n | { max: number }\n | { maxSize: number }\n | { ttl: number; ttlAutopurge: boolean }\n)\n\n// LRUCache does not allow storing \"null\", so we use a symbol to represent it.\nconst nullSymbol = Symbol('nullItem')\ntype AsLruValue<V extends Value> = V extends null\n ? typeof nullSymbol\n : Exclude<V, null>\nconst toLruValue = <V extends Value>(value: V) =>\n (value === null ? nullSymbol : value) as AsLruValue<V>\nconst fromLruValue = <V extends Value>(value: AsLruValue<V>) =>\n (value === nullSymbol ? null : value) as V\n\nexport class SimpleStoreMemory<K extends Key, V extends Value>\n implements SimpleStore<K, V>\n{\n #cache: LRUCache<K, AsLruValue<V>>\n\n constructor({ sizeCalculation, ...options }: SimpleStoreMemoryOptions<K, V>) {\n this.#cache = new LRUCache<K, AsLruValue<V>>({\n ...options,\n allowStale: false,\n updateAgeOnGet: false,\n updateAgeOnHas: false,\n sizeCalculation: sizeCalculation\n ? (value, key) => sizeCalculation(fromLruValue(value), key)\n : options.maxEntrySize != null || options.maxSize != null\n ? // maxEntrySize and maxSize require a size calculation function.\n roughSizeOfObject\n : undefined,\n })\n }\n\n get(key: K): V | undefined {\n const value = this.#cache.get(key)\n if (value === undefined) return undefined\n\n return fromLruValue(value)\n }\n\n set(key: K, value: V): void {\n this.#cache.set(key, toLruValue(value))\n }\n\n del(key: K): void {\n this.#cache.delete(key)\n }\n\n clear(): void {\n this.#cache.clear()\n }\n}\n"]}
package/dist/util.js CHANGED
@@ -1,11 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.roughSizeOfObject = roughSizeOfObject;
4
1
  const knownSizes = new WeakMap();
5
2
  /**
6
3
  * @see {@link https://stackoverflow.com/a/11900218/356537}
7
4
  */
8
- function roughSizeOfObject(value) {
5
+ export function roughSizeOfObject(value) {
9
6
  const objectList = new Set();
10
7
  const stack = [value]; // This would be more efficient using a circular buffer
11
8
  let bytes = 0;
package/dist/util.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"util.js","s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CAAC;oBACN,KAAK,IAAI,CAAC,CAAA;oBACV,MAAM,IAAI,GAAG,MAAM,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAA;oBAC9C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;wBACrC,KAAK,IAAI,CAAC,CAAA;wBACV,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA;wBACnB,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC,CAAA;wBACtB,IAAI,GAAG,KAAK,SAAS;4BAAE,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;wBACtC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;oBACjB,CAAC;gBACH,CAAC;gBACD,MAAK;YACP,KAAK,UAAU;gBACb,KAAK,IAAI,CAAC,CAAA,CAAC,6DAA6D;gBACxE,MAAK;YACP,KAAK,QAAQ;gBACX,KAAK,IAAI,CAAC,CAAA,CAAC,6BAA6B;gBACxC,MAAK;YACP,KAAK,QAAQ;gBACX,KAAK,IAAI,EAAE,CAAA,CAAC,4BAA4B;gBACxC,MAAK;QACT,CAAC;IACH,CAAC;IAED,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAChD,UAAU,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;IAC9B,CAAC;IAED,OAAO,KAAK,CAAA;AACd,CAAC","sourcesContent":["const knownSizes = new WeakMap<object, number>()\n\n/**\n * @see {@link https://stackoverflow.com/a/11900218/356537}\n */\nexport function roughSizeOfObject(value: unknown): number {\n const objectList = new Set()\n const stack = [value] // This would be more efficient using a circular buffer\n let bytes = 0\n\n while (stack.length) {\n const value = stack.pop()\n\n // > All objects on the heap start with a shape descriptor, which takes one\n // > pointer size (usually 4 bytes these days, thanks to \"pointer\n // > compression\" on 64-bit platforms).\n\n switch (typeof value) {\n // Types are ordered by frequency\n case 'string':\n // https://stackoverflow.com/a/68791382/356537\n bytes += 12 + 4 * Math.ceil(value.length / 4)\n break\n case 'number':\n bytes += 12 // Shape descriptor + double\n break\n case 'boolean':\n bytes += 4 // Shape descriptor\n break\n case 'object':\n bytes += 4 // Shape descriptor\n\n if (value === null) {\n break\n }\n\n if (knownSizes.has(value)) {\n bytes += knownSizes.get(value)!\n break\n }\n\n if (objectList.has(value)) continue\n objectList.add(value)\n\n if (Array.isArray(value)) {\n bytes += 4\n stack.push(...value)\n } else {\n bytes += 8\n const keys = Object.getOwnPropertyNames(value)\n for (let i = 0; i < keys.length; i++) {\n bytes += 4\n const key = keys[i]\n const val = value[key]\n if (val !== undefined) stack.push(val)\n stack.push(key)\n }\n }\n break\n case 'function':\n bytes += 8 // Shape descriptor + pointer (assuming functions are shared)\n break\n case 'symbol':\n bytes += 8 // Shape descriptor + pointer\n break\n case 'bigint':\n bytes += 16 // Shape descriptor + BigInt\n break\n }\n }\n\n if (typeof value === 'object' && value !== null) {\n knownSizes.set(value, bytes)\n }\n\n return bytes\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,9 @@
1
1
  {
2
2
  "name": "@atproto-labs/simple-store-memory",
3
- "version": "0.1.4",
3
+ "version": "0.2.0-next.0",
4
+ "engines": {
5
+ "node": ">=22"
6
+ },
4
7
  "license": "MIT",
5
8
  "description": "Memory based simple-store implementation",
6
9
  "keywords": [
@@ -14,9 +17,7 @@
14
17
  "url": "https://github.com/bluesky-social/atproto",
15
18
  "directory": "packages/internal/simple-store-memory"
16
19
  },
17
- "type": "commonjs",
18
- "main": "dist/index.js",
19
- "types": "dist/index.d.ts",
20
+ "type": "module",
20
21
  "exports": {
21
22
  ".": {
22
23
  "types": "./dist/index.d.ts",
@@ -25,10 +26,10 @@
25
26
  },
26
27
  "dependencies": {
27
28
  "lru-cache": "^10.2.0",
28
- "@atproto-labs/simple-store": "0.3.0"
29
+ "@atproto-labs/simple-store": "^0.4.0-next.0"
29
30
  },
30
31
  "devDependencies": {
31
- "typescript": "^5.6.3"
32
+ "typescript": "^6.0.3"
32
33
  },
33
34
  "scripts": {
34
35
  "build": "tsc --build tsconfig.build.json"
@@ -1 +1 @@
1
- {"root":["./src/index.ts","./src/util.ts"],"version":"5.8.2"}
1
+ {"root":["./src/index.ts","./src/util.ts"],"version":"6.0.3"}