@actdim/msgmesh-store Setup, Build & Workflow
1. Prerequisites & Installation
- Node.js: a release with global
crypto,structuredCloneandqueueMicrotask(Node 19 or later; current LTS recommended). - Package manager:
pnpm. - TypeScript:
^5.9.3(dev dependency).
Install as a consumer:
bash
pnpm add @actdim/msgmesh-store @actdim/msgmesh @actdim/utico rxjs
pnpm add @actdim/livestruct # optional peer2. Scripts
| Command | Action | Description |
|---|---|---|
pnpm run test | npx vitest --config=vitest.node.config.ts --no-cache | Runs the Node test suite in tests/ once. |
pnpm run test:w | npx vitest --config=vitest.node.config.ts --watch | Runs the test suite in watch mode. |
pnpm run build | tsc -b tsconfig.json && vite build | Typechecks, then builds ESM bundles and .d.ts files into dist/ for the ., ./cdc, ./bridge, ./worker entries. |
pnpm run typecheck | tsc -b tsconfig.json | Type checks without bundling. |
pnpm run format | prettier --write . | Formats the package. |
pnpm run format:check | prettier --check . | Verifies formatting. |
pnpm run docs:dev | vitepress dev docs | Serves the documentation site locally. |
pnpm run docs:build | vitepress build docs | Builds the documentation site. |
pnpm run docs:preview | vitepress preview docs | Previews the built site. |
3. Test Suite (tests/)
The tests run in Node against in-memory LiveStruct stores (forceMemory: true) and in-memory ports, so they need no browser:
| File | Covers |
|---|---|
bridge.test.ts | Command translation, origin labeling, echo suppression, ordering, errors, disposal. |
cdc.test.ts | toStoreCdcObservable, filters, publishCdcToBus, subscribeCdc, createCdcBridge, secondary channels. |
worker.test.ts | Handshake, lazy factories, commands, queries, CDC streaming, timeouts, close and reconnect, batching. |
ledger.test.ts | MutationLedger semantics and capacity eviction. |
keyedQueue.test.ts | KeyedSerialQueue ordering, isolation and drain(). |
applyMutation.test.ts | normalizeCommand, resolveMutationTarget, applyStoreCommand. |
types.test.ts | Compile-time constraints of the public API. |
Tests are hermetic: they await whenIdle(), CDC promises or microtasks rather than fixed timers.
4. Development Inside the Mempart Monorepo
- The package lives at
src/packages/msgmesh-storeand is a Git submodule of the mempart repository (https://github.com/actdim/msgmesh-store.git). - It is a member of the pnpm workspace (
src/pnpm-workspace.yamlincludespackages/*). Withlink-workspace-packages=trueinsrc/.npmrc, the dev dependencies@actdim/livestruct,@actdim/msgmeshand@actdim/uticoresolve to the sibling packages insrc/packages/, so changes there are picked up without publishing. - Run package scripts from the package folder, or from
src/with a filter, for examplepnpm --filter @actdim/msgmesh-store test. - Versions are synchronized monorepo-wide; do not bump this package's version on its own (the root
pnpm run version:sync <version>script updates every package together). - When
@actdim/livestructchanges its engine or collection shape, run this package'stypecheckandtestto confirm the structural targets still match.
5. Cross-Links
- Knowledge Base Index - Knowledge Base Root
- System Architecture - Architecture
- Domain Model - Domain Model
- Integration Guide - Integration Guide
- API Reference - API Reference
- License - License Information