tinybase 6.7.3 → 6.7.5

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 (55) hide show
  1. package/@types/mergeable-store/with-schemas/index.d.ts +3 -2
  2. package/@types/persisters/persister-automerge/index.d.ts +4 -6
  3. package/@types/persisters/persister-automerge/with-schemas/index.d.ts +7 -8
  4. package/@types/persisters/persister-browser/index.d.ts +3 -6
  5. package/@types/persisters/persister-browser/with-schemas/index.d.ts +9 -6
  6. package/@types/persisters/persister-cr-sqlite-wasm/with-schemas/index.d.ts +3 -2
  7. package/@types/persisters/persister-durable-object-sql-storage/index.d.ts +1 -2
  8. package/@types/persisters/persister-durable-object-storage/index.d.ts +1 -2
  9. package/@types/persisters/persister-durable-object-storage/with-schemas/index.d.ts +3 -2
  10. package/@types/persisters/persister-electric-sql/with-schemas/index.d.ts +3 -2
  11. package/@types/persisters/persister-expo-sqlite/index.d.ts +1 -2
  12. package/@types/persisters/persister-expo-sqlite/with-schemas/index.d.ts +3 -2
  13. package/@types/persisters/persister-file/index.d.ts +1 -2
  14. package/@types/persisters/persister-file/with-schemas/index.d.ts +3 -2
  15. package/@types/persisters/persister-indexed-db/with-schemas/index.d.ts +3 -2
  16. package/@types/persisters/persister-libsql/with-schemas/index.d.ts +3 -2
  17. package/@types/persisters/persister-partykit-client/with-schemas/index.d.ts +3 -2
  18. package/@types/persisters/persister-pglite/index.d.ts +1 -2
  19. package/@types/persisters/persister-pglite/with-schemas/index.d.ts +3 -2
  20. package/@types/persisters/persister-postgres/index.d.ts +1 -2
  21. package/@types/persisters/persister-postgres/with-schemas/index.d.ts +3 -2
  22. package/@types/persisters/persister-powersync/with-schemas/index.d.ts +3 -2
  23. package/@types/persisters/persister-react-native-mmkv/index.d.ts +1 -2
  24. package/@types/persisters/persister-react-native-mmkv/with-schemas/index.d.ts +3 -2
  25. package/@types/persisters/persister-react-native-sqlite/index.d.ts +1 -2
  26. package/@types/persisters/persister-react-native-sqlite/with-schemas/index.d.ts +3 -2
  27. package/@types/persisters/persister-remote/with-schemas/index.d.ts +3 -2
  28. package/@types/persisters/persister-sqlite-bun/index.d.ts +1 -2
  29. package/@types/persisters/persister-sqlite-bun/with-schemas/index.d.ts +3 -2
  30. package/@types/persisters/persister-sqlite-wasm/index.d.ts +1 -2
  31. package/@types/persisters/persister-sqlite-wasm/with-schemas/index.d.ts +3 -2
  32. package/@types/persisters/persister-sqlite3/index.d.ts +1 -2
  33. package/@types/persisters/persister-sqlite3/with-schemas/index.d.ts +3 -2
  34. package/@types/persisters/persister-yjs/with-schemas/index.d.ts +3 -2
  35. package/@types/queries/with-schemas/index.d.ts +4 -8
  36. package/@types/synchronizers/synchronizer-broadcast-channel/with-schemas/index.d.ts +3 -2
  37. package/@types/synchronizers/synchronizer-local/with-schemas/index.d.ts +3 -2
  38. package/@types/synchronizers/synchronizer-ws-client/index.d.ts +3 -2
  39. package/@types/synchronizers/with-schemas/index.d.ts +3 -2
  40. package/agents.md +281 -0
  41. package/min/omni/index.js +1 -1
  42. package/min/omni/index.js.gz +0 -0
  43. package/min/omni/with-schemas/index.js +1 -1
  44. package/min/omni/with-schemas/index.js.gz +0 -0
  45. package/min/persisters/persister-automerge/index.js +1 -1
  46. package/min/persisters/persister-automerge/index.js.gz +0 -0
  47. package/min/persisters/persister-automerge/with-schemas/index.js +1 -1
  48. package/min/persisters/persister-automerge/with-schemas/index.js.gz +0 -0
  49. package/omni/index.js +1 -1
  50. package/omni/with-schemas/index.js +1 -1
  51. package/package.json +4 -4
  52. package/persisters/persister-automerge/index.js +1 -1
  53. package/persisters/persister-automerge/with-schemas/index.js +1 -1
  54. package/readme.md +1 -1
  55. package/releases.md +1 -1
package/agents.md ADDED
@@ -0,0 +1,281 @@
1
+ # Agents Guide
2
+
3
+ This file follows the [agents.md](https://agents.md/) specification for AI agent
4
+ context. If you're a human reading this, it provides a comprehensive overview of
5
+ the TinyBase project for AI assistants working with the codebase.
6
+
7
+ ## Overview
8
+
9
+ **TinyBase** is a reactive data store and sync engine for local-first
10
+ applications. It is a TypeScript library that provides a reactive, in-memory
11
+ data store with a powerful synchronization engine. It's designed for building
12
+ local-first applications that work offline and sync across devices. The library
13
+ is exceptionally small (5.3kB-11.7kB), has zero runtime dependencies, and
14
+ maintains 100% test coverage.
15
+
16
+ - **Website**: https://tinybase.org
17
+ - **Repository**: https://github.com/tinyplex/tinybase
18
+ - **Documentation**: https://tinybase.org/api/
19
+ - **License**: MIT
20
+ - **Author**: James Pearce (@jamesgpearce)
21
+
22
+ ## Core Concepts
23
+
24
+ ### Data Store
25
+
26
+ TinyBase provides two types of data structures:
27
+
28
+ - **Tables**: Tabular data organized as Table → Row → Cell (similar to
29
+ relational databases)
30
+ - **Values**: Simple key-value pairs for application state
31
+
32
+ Both can coexist in the same Store and support optional schemas with type
33
+ enforcement.
34
+
35
+ ### Reactivity
36
+
37
+ The library implements a fine-grained reactive system where you can listen to
38
+ changes at any level:
39
+
40
+ - Entire store changes
41
+ - Table/value additions or removals
42
+ - Row changes within a table
43
+ - Individual cell or value changes
44
+
45
+ Listeners fire automatically when data changes, enabling efficient UI updates
46
+ that only re-render affected components.
47
+
48
+ ### Synchronization
49
+
50
+ TinyBase includes native CRDT (Conflict-free Replicated Data Type) support via
51
+ the MergeableStore, allowing deterministic synchronization across multiple
52
+ clients and servers using Hybrid Logical Clocks for causality tracking.
53
+
54
+ ## Key Features
55
+
56
+ ### Data Management
57
+
58
+ - **Schemas**: Optional TypeScript-inferred schemas for type safety
59
+ - **Indexes**: Fast lookups by cell values with slice-based grouping
60
+ - **Queries**: SQL-like query engine (select, join, filter, group) without
61
+ actual SQL
62
+ - **Relationships**: Define foreign-key relationships between tables
63
+ - **Metrics**: Built-in aggregations (sum, avg, min, max)
64
+ - **Checkpoints**: Undo/redo functionality with branching support
65
+
66
+ ### Persistence
67
+
68
+ Multiple storage backends supported via Persisters:
69
+
70
+ - **Browser**: LocalStorage, SessionStorage, IndexedDB, OPFS
71
+ - **Databases**: SQLite (Bun, WASM, sqlite3), PostgreSQL, PGlite, Turso (libSQL)
72
+ - **Third-party**: ElectricSQL, PowerSync, CR-SQLite
73
+ - **Cloud**: PartyKit, Cloudflare Durable Objects
74
+ - **Files**: Node.js file system
75
+ - **CRDT**: Yjs, Automerge integration
76
+ - **React Native**: MMKV, SQLite
77
+
78
+ ### Synchronization
79
+
80
+ Synchronizers enable real-time data sync:
81
+
82
+ - WebSocket (client and server)
83
+ - BroadcastChannel (same-origin tabs)
84
+ - Local (in-memory for testing)
85
+ - Custom transports (extensible)
86
+
87
+ ### React Integration
88
+
89
+ Optional `ui-react` module provides:
90
+
91
+ - **Hooks**: `useCell`, `useRow`, `useTable`, `useTables`, `useValue`, etc.
92
+ - **Components**: Pre-built reactive views for data rendering
93
+ - **Context**: Multi-store support with ID-based contexts
94
+ - **DOM Components**: `ui-react-dom` with interactive tables
95
+ - **Inspector**: Developer tools overlay for debugging
96
+
97
+ ## Architecture
98
+
99
+ ### Modular Design
100
+
101
+ TinyBase uses a modular architecture where each feature is an independent module
102
+ that can be imported separately:
103
+
104
+ ```
105
+ tinybase # Core store module
106
+ tinybase/indexes # Indexing
107
+ tinybase/queries # Query engine
108
+ tinybase/relationships # Relationships
109
+ tinybase/metrics # Aggregations
110
+ tinybase/checkpoints # Undo/redo
111
+ tinybase/mergeable-store # CRDT support
112
+ tinybase/persisters/persister-* # Storage backends
113
+ tinybase/synchronizers/synchronizer-* # Sync transports
114
+ tinybase/ui-react # React hooks
115
+ tinybase/ui-react-dom # React DOM components
116
+ tinybase/ui-react-inspector # DevTools
117
+ ```
118
+
119
+ ### Type System
120
+
121
+ Strong TypeScript support with:
122
+
123
+ - Generic types that infer from schemas
124
+ - Conditional types for schema-aware APIs
125
+ - Mapped types for compile-time validation
126
+ - Type-safe hooks and components
127
+
128
+ ### Build System
129
+
130
+ - **Gulp**: Build orchestration
131
+ - **TypeScript**: Source language with strict mode
132
+ - **Rollup**: Bundling (implied)
133
+ - **ESM**: Primary module format
134
+ - **Tree-shaking**: Aggressive optimization for minimal bundles
135
+
136
+ ## Development
137
+
138
+ ### Prerequisites
139
+
140
+ - Node.js >= 23.10.0
141
+ - npm >= 10.9.2
142
+
143
+ ### Setup
144
+
145
+ ```bash
146
+ git clone https://github.com/tinyplex/tinybase.git
147
+ cd tinybase
148
+ npm install
149
+ ```
150
+
151
+ ### Common Commands
152
+
153
+ ```bash
154
+ npm run compileAndTestUnit # Compile and run unit tests
155
+ npm run testUnitFast # Quick test iteration
156
+ npm run lint # Run ESLint
157
+ npm run spell # Spell check
158
+ npm run preCommit # Full pre-commit check
159
+ npm run compileDocs # Generate API documentation
160
+ npm run serveDocs # Preview documentation locally
161
+ ```
162
+
163
+ ### Testing
164
+
165
+ - **Framework**: Vitest
166
+ - **Coverage**: 100% required (enforced)
167
+ - **Types**: Unit, performance, end-to-end, production
168
+ - **Environment**: happy-dom (unit), puppeteer (e2e)
169
+
170
+ ### Code Style
171
+
172
+ - **ESLint**: Enforced with strict rules
173
+ - **Prettier**: Automatic formatting
174
+ - **Max line length**: 80 characters
175
+ - **Quotes**: Single quotes (template literals allowed)
176
+ - **Semicolons**: Required
177
+ - **Object spacing**: No spaces in braces `{key: value}`
178
+
179
+ ## Project Structure
180
+
181
+ ```
182
+ tinybase/
183
+ ├── src/ # Source code
184
+ │ ├── @types/ # TypeScript declarations
185
+ │ ├── store/ # Core store implementation
186
+ │ ├── indexes/ # Indexing module
187
+ │ ├── queries/ # Query engine
188
+ │ ├── relationships/ # Relationships module
189
+ │ ├── metrics/ # Metrics module
190
+ │ ├── checkpoints/ # Checkpoints module
191
+ │ ├── mergeable-store/ # CRDT implementation
192
+ │ ├── persisters/ # Storage backends
193
+ │ ├── synchronizers/ # Sync transports
194
+ │ ├── ui-react/ # React hooks
195
+ │ ├── ui-react-dom/ # React DOM components
196
+ │ ├── ui-react-inspector/ # DevTools
197
+ │ └── common/ # Shared utilities
198
+ ├── test/ # Tests
199
+ │ ├── unit/ # Unit tests
200
+ │ ├── perf/ # Performance tests
201
+ │ ├── e2e/ # End-to-end tests
202
+ │ └── prod/ # Production build tests
203
+ ├── docs/ # Generated documentation
204
+ ├── dist/ # Build output
205
+ ├── site/ # Documentation site source
206
+ ├── gulpfile.mjs # Build configuration
207
+ ├── vitest.config.ts # Test configuration
208
+ ├── eslint.config.js # Linting rules
209
+ └── tsconfig.json # TypeScript config
210
+ ```
211
+
212
+ ## Contributing
213
+
214
+ Contributions are welcome! This is a spare-time project, so response times may
215
+ vary.
216
+
217
+ **Requirements**:
218
+
219
+ 1. Follow the Prettier and ESLint configurations
220
+ 2. Maintain 100% test coverage
221
+ 3. Update documentation for API changes
222
+ 4. Add examples for new features
223
+
224
+ **Process**:
225
+
226
+ 1. Fork the repository
227
+ 2. Create a feature branch
228
+ 3. Make your changes with tests
229
+ 4. Run `npm run preCommit` to verify
230
+ 5. Submit a pull request
231
+
232
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for details.
233
+
234
+ ## Community
235
+
236
+ - **Discord**: https://discord.com/invite/mGz3mevwP8
237
+ - **Discussions**: https://github.com/tinyplex/tinybase/discussions
238
+ - **Issues**: https://github.com/tinyplex/tinybase/issues
239
+ - **Bluesky**: https://bsky.app/profile/tinybase.bsky.social
240
+ - **Twitter/X**: https://x.com/tinybasejs
241
+
242
+ ## Use Cases
243
+
244
+ TinyBase is ideal for:
245
+
246
+ - **Local-first applications**: Apps that work offline and sync later
247
+ - **Real-time collaboration**: Multi-user applications with CRDT sync
248
+ - **Reactive UIs**: Applications requiring fine-grained reactivity
249
+ - **Mobile apps**: React Native apps with local storage
250
+ - **Edge computing**: Cloudflare Workers, Durable Objects
251
+ - **Progressive Web Apps**: Offline-capable web applications
252
+ - **Games**: Real-time state management with undo/redo
253
+ - **Data dashboards**: Reactive data visualization
254
+
255
+ ## Performance
256
+
257
+ - Tiny bundle sizes (5.3kB - 11.7kB depending on features)
258
+ - Zero runtime dependencies
259
+ - Efficient change detection and listener notification
260
+ - Memory pooling for ID generation
261
+ - Tree-shakeable modular design
262
+ - Optimized for bundle size and runtime performance
263
+
264
+ ## Related Projects
265
+
266
+ - **Synclets**: Generic synchronization library (https://synclets.org)
267
+ - **TinyWidgets**: Widget toolkit built on TinyBase (https://tinywidgets.org)
268
+ - **TinyTick**: Reactive ticker tape component (https://tinytick.org)
269
+
270
+ ## License
271
+
272
+ MIT License - see [LICENSE](LICENSE) file for details.
273
+
274
+ ---
275
+
276
+ **Note for AI Agents**: TinyBase uses unique patterns including utility function
277
+ wrappers (e.g., `arrayForEach`, `mapGet`, `objHas`) instead of native methods
278
+ for consistency and tree-shaking. Always use factory functions (`createStore`,
279
+ `createIndexes`, etc.) with builder pattern chaining. Maintain 100% test
280
+ coverage and follow the strict 80-character line length. See
281
+ `.github/copilot-instructions.md` for detailed coding patterns.