Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions .changeset/structural-map-uint8array.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,24 @@
"@evolu/common": minor
---

Added `StructuralMap`, a `Map`-like collection for registries and coordination tables where callers have immutable JSON-like keys or `Uint8Array` keys and do not want to maintain a separate string id.
Added a new `StructuralMap` module for `Map`-like storage keyed by structural values instead of object identity.

`StructuralMap` works by deriving a canonical structural id for each key and storing entries in a native `Map` keyed by that id. Repeated lookups of the same object or array instance reuse cached ids through a `WeakMap`.
`StructuralMap` was added for cases where callers already had immutable keys such as JSON-like values, `undefined`, or `Uint8Array` and wanted to look up shared state, cached values, or in-flight work without maintaining a separate canonical string id. Structurally equal arrays, objects, and byte arrays addressed the same entry even when they were different JavaScript instances.

`StructuralMap` worked by deriving a canonical structural id for each key and storing entries in a native `Map` keyed by that id. Repeated lookups of the same object, array, or `Uint8Array` instance reused cached ids through a `WeakMap`.

### Example

```ts
import { createStructuralMap } from "@evolu/common";

const map = createStructuralMap<
{ readonly id: string; readonly filter: readonly [string, string] },
string
>();

map.set({ id: "items", filter: ["owner", "active"] }, "cached");

map.get({ id: "items", filter: ["owner", "active"] });
// => "cached"
```
2 changes: 1 addition & 1 deletion biome.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://biomejs.dev/schemas/2.4.7/schema.json",
"$schema": "https://biomejs.dev/schemas/2.4.8/schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
Expand Down
290 changes: 151 additions & 139 deletions bun.lock

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions examples/angular-vite-pwa/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@
"generate-pwa-assets": "pwa-assets-generator"
},
"dependencies": {
"@angular/core": "^21.2.4",
"@angular/platform-browser": "^21.2.4",
"@angular/core": "^21.2.5",
"@angular/platform-browser": "^21.2.5",
"@evolu/common": "workspace:*",
"@evolu/web": "workspace:*"
},
"devDependencies": {
"@analogjs/vite-plugin-angular": "^2.3.1",
"@angular/build": "^21.2.2",
"@angular/compiler-cli": "^21.2.4",
"@tailwindcss/vite": "^4.2.1",
"@angular/build": "^21.2.3",
"@angular/compiler-cli": "^21.2.5",
"@tailwindcss/vite": "^4.2.2",
"@vite-pwa/assets-generator": "^1.0.2",
"tailwindcss": "^4.2.1",
"tailwindcss": "^4.2.2",
"typescript": "^5.9.3",
"vite": "^7.3.1",
"vite-plugin-pwa": "^1.2.0"
Expand Down
4 changes: 2 additions & 2 deletions examples/astro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
"check": "astro check"
},
"dependencies": {
"@astrojs/react": "^5.0.0",
"@astrojs/react": "^5.0.1",
"@evolu/astro": "workspace:*",
"astro": "^6.0.5",
"astro": "^6.0.6",
"react": "19.2.4",
"react-dom": "19.2.4"
},
Expand Down
20 changes: 10 additions & 10 deletions examples/react-expo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,22 @@
"@expo/vector-icons": "^15.1.1",
"abort-signal-polyfill": "^1.0.0",
"babel-plugin-module-resolver": "^5.0.3",
"expo": "^55.0.6",
"expo-constants": "^55.0.7",
"expo": "^55.0.8",
"expo-constants": "^55.0.9",
"expo-font": "^55.0.4",
"expo-linking": "^55.0.7",
"expo-router": "^55.0.5",
"expo-secure-store": "~55.0.8",
"expo-splash-screen": "~55.0.10",
"expo-sqlite": "~55.0.10",
"expo-linking": "^55.0.8",
"expo-router": "^55.0.7",
"expo-secure-store": "~55.0.9",
"expo-splash-screen": "~55.0.12",
"expo-sqlite": "~55.0.11",
"react": "19.2.4",
"react-dom": "19.2.4",
"react-native": "0.84.1",
"react-native-nitro-modules": "0.34.1",
"react-native-quick-crypto": "^1.0.16",
"react-native-quick-crypto": "^1.0.17",
"react-native-safe-area-context": "^5.7.0",
"react-native-screens": "^4.24.0",
"react-native-svg": "15.15.3",
"react-native-svg": "15.15.4",
"react-native-web": "^0.21.0",
"set.prototype.difference": "^1.1.7",
"set.prototype.intersection": "^1.1.8",
Expand All @@ -57,7 +57,7 @@
"@babel/plugin-transform-explicit-resource-management": "^7.28.6",
"@babel/plugin-transform-modules-commonjs": "^7.28.6",
"@types/react": "~19.2.14",
"babel-preset-expo": "^55.0.11",
"babel-preset-expo": "^55.0.12",
"typescript": "^5.9.3"
}
}
6 changes: 3 additions & 3 deletions examples/react-nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@
"@evolu/react-web": "workspace:*",
"@tabler/icons-react": "^3.37.1",
"clsx": "^2.1.1",
"next": "^16.1.7",
"next": "^16.2.0",
"react": "19.2.4",
"react-dom": "19.2.4"
},
"devDependencies": {
"@tailwindcss/forms": "^0.5.11",
"@tailwindcss/postcss": "^4.2.1",
"@tailwindcss/postcss": "^4.2.2",
"@types/node": "^25.5.0",
"@types/react": "~19.2.14",
"@types/react-dom": "~19.2.3",
"postcss": "^8.5.8",
"tailwindcss": "^4.2.1",
"tailwindcss": "^4.2.2",
"typescript": "^5.9.3"
}
}
4 changes: 2 additions & 2 deletions examples/react-vite-pwa/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
"clsx": "^2.1.1",
"react": "19.2.4",
"react-dom": "19.2.4",
"tailwindcss": "^4.2.1"
"tailwindcss": "^4.2.2"
},
"devDependencies": {
"@tailwindcss/forms": "^0.5.11",
"@tailwindcss/vite": "^4.2.1",
"@tailwindcss/vite": "^4.2.2",
"@types/react": "~19.2.14",
"@types/react-dom": "~19.2.3",
"@vite-pwa/assets-generator": "^1.0.2",
Expand Down
2 changes: 1 addition & 1 deletion examples/svelte-vite-pwa/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"@evolu/web": "workspace:*",
"@sveltejs/vite-plugin-svelte": "^6.2.4",
"@tsconfig/svelte": "^5.0.8",
"svelte": "^5.53.12",
"svelte": "^5.54.0",
"svelte-check": "^4.4.3",
"tslib": "^2.8.1",
"typescript": "^5.9.3",
Expand Down
2 changes: 1 addition & 1 deletion examples/tanstack-start/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
"dependencies": {
"@evolu/tanstack-start": "workspace:*",
"@tanstack/react-router": "^1.167.4",
"@tanstack/react-router": "^1.167.5",
"react": "19.2.4",
"react-dom": "19.2.4"
},
Expand Down
2 changes: 1 addition & 1 deletion examples/vue-vite-pwa/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@
"typescript": "^5.9.3",
"vite": "^7.3.1",
"vite-plugin-pwa": "^1.2.0",
"vue-tsc": "^3.2.5"
"vue-tsc": "^3.2.6"
}
}
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,15 @@
"docs:sync:website": "bun ./scripts/docs-sync-website.mts"
},
"devDependencies": {
"@biomejs/biome": "^2.4.7",
"@biomejs/biome": "^2.4.8",
"@changesets/cli": "^2.29.8",
"@vitest/browser": "^4.0.18",
"@vitest/browser-playwright": "^4.0.18",
"@vitest/coverage-istanbul": "^4.0.18",
"@vitest/coverage-v8": "^4.0.18",
"turbo": "^2.8.17",
"turbo": "^2.8.19",
"typedoc": "^0.28.17",
"typedoc-plugin-markdown": "^4.10.0",
"typedoc-plugin-markdown": "^4.11.0",
"typescript": "^5.9.3",
"vitest": "^4.0.18"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/bun/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"devDependencies": {
"@evolu/common": "workspace:*",
"@evolu/tsconfig": "workspace:*",
"bun-types": "^1.3.9",
"bun-types": "^1.3.11",
"typescript": "^5.9.3"
},
"peerDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"@noble/ciphers": "^2.1.1",
"@noble/hashes": "^2.0.1",
"@scure/bip39": "^2.0.1",
"kysely": "^0.28.12",
"kysely": "^0.28.13",
"msgpackr": "^1.11.9",
"zod": "^4.3.6"
},
Expand Down
Loading
Loading