{"_id":"@ai-path/tb-collab","_rev":"2-99a124775368d7a4f7ef2fd88f61752e","name":"@ai-path/tb-collab","dist-tags":{"latest":"0.3.0"},"versions":{"0.2.0":{"name":"@ai-path/tb-collab","version":"0.2.0","license":"MIT","_id":"@ai-path/tb-collab@0.2.0","maintainers":[{"name":"fsakurai","email":"f-sakurai@ai-path.jp"}],"homepage":"https://github.com/aipathjp/lattica#readme","bugs":{"url":"https://github.com/aipathjp/lattica/issues"},"dist":{"shasum":"d92e4381ff4cc0f3fe35838e00d21201889584eb","tarball":"https://registry.npmjs.org/@ai-path/tb-collab/-/tb-collab-0.2.0.tgz","fileCount":9,"integrity":"sha512-391VJznynLyiKIHx8ClQOtihzUemb7JkbggbHPZWjg3NtqHhC8411Mkyszl4I6L/jrCQQ7A7RJsrZk2BE6Wjsw==","signatures":[{"sig":"MEQCIAavO41BV99v0/5jjS58ncPFp12tldN5OCtXxHHA2K3lAiA+wMkR7NBhE9P8tr63c0O+wsUQefPti0O9JQ8Tmj0Lug==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":80933},"main":"./dist/index.cjs","type":"module","_from":"file:ai-path-tb-collab-0.2.0.tgz","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"scripts":{"build":"tsup","typecheck":"tsc --noEmit"},"_npmUser":{"name":"fsakurai","email":"f-sakurai@ai-path.jp"},"_resolved":"/private/var/folders/tf/0c43660d4k1dg4ssxq0n63ww0000gn/T/18c997ff453635f6c3aa83203b3432b1/ai-path-tb-collab-0.2.0.tgz","_integrity":"sha512-391VJznynLyiKIHx8ClQOtihzUemb7JkbggbHPZWjg3NtqHhC8411Mkyszl4I6L/jrCQQ7A7RJsrZk2BE6Wjsw==","repository":{"url":"git+https://github.com/aipathjp/lattica.git","type":"git","directory":"packages/collab"},"_npmVersion":"10.9.3","description":"Realtime collaboration primitives for Taible: a table-specific LWW CRDT, fractional indexing for stable row/column order, presence, and a transport abstraction.","directories":{},"sideEffects":false,"_nodeVersion":"22.18.0","dependencies":{"@ai-path/tb-core":"0.2.0"},"publishConfig":{"access":"public","provenance":false},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/tb-collab_0.2.0_1783181297839_0.9129411687231794","host":"s3://npm-registry-packages-npm-production"}},"0.3.0":{"name":"@ai-path/tb-collab","version":"0.3.0","description":"Realtime collaboration primitives for Taible: a table-specific LWW CRDT, fractional indexing for stable row/column order, presence, and a transport abstraction.","license":"MIT","type":"module","sideEffects":false,"main":"./dist/index.cjs","module":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"dependencies":{"@ai-path/tb-core":"0.3.0"},"publishConfig":{"access":"public","provenance":false},"repository":{"type":"git","url":"git+https://github.com/aipathjp/lattica.git","directory":"packages/collab"},"homepage":"https://github.com/aipathjp/lattica#readme","bugs":{"url":"https://github.com/aipathjp/lattica/issues"},"scripts":{"build":"tsup","typecheck":"tsc --noEmit"},"_id":"@ai-path/tb-collab@0.3.0","_integrity":"sha512-J/u7M3exYc6pGH91i582xD63uXAcEbtTRRiD4hqn3fa5hKgh2+PEKyyTdqe/wqC0FJ12LcYYoP7A5zSewnnvyw==","_resolved":"/private/var/folders/tf/0c43660d4k1dg4ssxq0n63ww0000gn/T/1f9fb61e533ec1ab238d1cf5df36186b/ai-path-tb-collab-0.3.0.tgz","_from":"file:ai-path-tb-collab-0.3.0.tgz","_nodeVersion":"22.18.0","_npmVersion":"10.9.3","dist":{"integrity":"sha512-J/u7M3exYc6pGH91i582xD63uXAcEbtTRRiD4hqn3fa5hKgh2+PEKyyTdqe/wqC0FJ12LcYYoP7A5zSewnnvyw==","shasum":"0526560c47e4ed770ad9c5f0dd2188774d4024cf","tarball":"https://registry.npmjs.org/@ai-path/tb-collab/-/tb-collab-0.3.0.tgz","fileCount":9,"unpackedSize":80933,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIEhcacO10lVztcTpHBqUaBKgE5iiu/NWU4A0JQFbUyGzAiEA9D63q50hN16QPVx8yz2CEJjlSTuBwUiVluQUMQPem1k="}]},"_npmUser":{"name":"fsakurai","email":"f-sakurai@ai-path.jp"},"directories":{},"maintainers":[{"name":"fsakurai","email":"f-sakurai@ai-path.jp"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/tb-collab_0.3.0_1783188075482_0.717327455421586"},"_hasShrinkwrap":false}},"time":{"created":"2026-07-04T16:08:17.685Z","modified":"2026-07-04T18:01:15.866Z","0.2.0":"2026-07-04T16:08:17.994Z","0.3.0":"2026-07-04T18:01:15.737Z"},"bugs":{"url":"https://github.com/aipathjp/lattica/issues"},"license":"MIT","homepage":"https://github.com/aipathjp/lattica#readme","repository":{"type":"git","url":"git+https://github.com/aipathjp/lattica.git","directory":"packages/collab"},"description":"Realtime collaboration primitives for Taible: a table-specific LWW CRDT, fractional indexing for stable row/column order, presence, and a transport abstraction.","maintainers":[{"name":"fsakurai","email":"f-sakurai@ai-path.jp"}],"readme":"# @ai-path/tb-collab\n\nRealtime collaboration primitives for Taible. It provides a last-writer-wins\nCRDT for cell values (`TableDocument`), a presence registry for remote cursors\nand selections, a transport abstraction with an in-memory implementation for\ntests and local demos, and `CollabSession` which wires them together into the\nsingle object a UI layer talks to. Fractional order keys (`keyBetween`) support\nstable ordering of inserted rows/columns.\n\n## Install\n\n```sh\npnpm add @ai-path/tb-collab\n```\n\n## API overview\n\n### CollabSession + InMemoryNetwork\n\nA `CollabSession` applies and broadcasts local edits and merges remote ones. The\n`InMemoryNetwork` connects multiple sessions in-process — ideal for tests.\n\n```ts\nimport { CollabSession, InMemoryNetwork } from '@ai-path/tb-collab';\n\nconst network = new InMemoryNetwork();\nconst alice = new CollabSession('alice', network.connect(), { name: 'Alice', color: '#e11' });\nconst bob = new CollabSession('bob', network.connect(), { name: 'Bob' });\n\nalice.setCell('A1', 'hello');\nbob.doc.get('A1'); // 'hello' — replicated through the network\n\nalice.updatePresence({ cursor: 'B2' });\nalice.leave();\n```\n\n### TableDocument (CRDT)\n\n`TableDocument` is a self-contained LWW cell store. `setLocal` produces a\n`CellOp` to broadcast; `applyRemote` merges an incoming op; `merge` folds in\nanother document's ops.\n\n```ts\nimport { TableDocument } from '@ai-path/tb-collab';\n\nconst doc = new TableDocument('site-1');\nconst op = doc.setLocal('A1', 42);\ndoc.get('A1');     // 42\ndoc.snapshot();    // { A1: 42 }\n\nconst other = new TableDocument('site-2');\nother.applyRemote(op);\n```\n\n### Presence\n\n```ts\nimport { PresenceRegistry, type PresenceState } from '@ai-path/tb-collab';\n\nconst presence = new PresenceRegistry();\npresence.set({ site: 'bob', name: 'Bob', cursor: 'C3' } as PresenceState);\npresence.remove('bob');\n```\n\n### Order keys\n\n`keyBetween` / `keysBetween` generate fractional-index strings for ordering\ninserted items; `isOrderKey` validates them.\n\n```ts\nimport { keyBetween } from '@ai-path/tb-collab';\n\nconst k = keyBetween(null, null);  // first key\nconst k2 = keyBetween(k, null);    // sorts after k\n```\n\nTo bridge a real backend, implement the `CollabTransport` interface\n(`send` + `subscribe`) and pass it to `CollabSession` in place of the in-memory\ntransport.\n","readmeFilename":"README.md"}