@rozek/sds-sync-engine 0.0.4 → 0.0.6
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/README.md +19 -8
- package/package.json +7 -4
package/README.md
CHANGED
|
@@ -4,6 +4,17 @@ The orchestration layer of the **shareable-data-store** (SDS) family. `SDS_SyncE
|
|
|
4
4
|
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
+
## Prerequisites
|
|
8
|
+
|
|
9
|
+
| requirement | details |
|
|
10
|
+
| --- | --- |
|
|
11
|
+
| **Node.js 22+** | required when using this package in a Node.js project or build toolchain. Download from [nodejs.org](https://nodejs.org). |
|
|
12
|
+
| **Modern browser** | required when using this package in a web application. Any evergreen browser is supported: Chrome 90+, Firefox 90+, Safari 15+, Edge 90+. |
|
|
13
|
+
|
|
14
|
+
This package is isomorphic — it contains no native code, no WebAssembly, and no browser-specific APIs. It has no runtime dependencies beyond `@rozek/sds-core`.
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
7
18
|
## Installation
|
|
8
19
|
|
|
9
20
|
```bash
|
|
@@ -26,11 +37,11 @@ While the network connection is in `'disconnected'` or `'reconnecting'` state, o
|
|
|
26
37
|
|
|
27
38
|
Every local mutation's patch bytes are accumulated. When the total crosses **512 KB**, the engine writes a new snapshot and prunes all patches up to that point. A final checkpoint is also written on `stop()` if there are any un-checkpointed patches.
|
|
28
39
|
|
|
29
|
-
### Large-
|
|
40
|
+
### Large-value transfer
|
|
30
41
|
|
|
31
42
|
When a data's value changes to a reference kind (`'literal-reference'` or `'binary-reference'`), the engine sends the blob to the network provider. When the store receives a patch referencing an unknown blob hash, the engine requests the blob from the network provider.
|
|
32
43
|
|
|
33
|
-
### Presence
|
|
44
|
+
### Presence heartbeat
|
|
34
45
|
|
|
35
46
|
The engine periodically re-broadcasts the local presence state so that remote peers can detect stale entries (timeout controlled by `PresenceTimeoutMs`).
|
|
36
47
|
|
|
@@ -40,7 +51,7 @@ When running in a browser or Tauri context, the engine optionally uses a `Broadc
|
|
|
40
51
|
|
|
41
52
|
---
|
|
42
53
|
|
|
43
|
-
## API
|
|
54
|
+
## API reference
|
|
44
55
|
|
|
45
56
|
### `SDS_SyncEngine`
|
|
46
57
|
|
|
@@ -105,7 +116,7 @@ All providers are optional. You can use any combination — for example persiste
|
|
|
105
116
|
|
|
106
117
|
## Usage
|
|
107
118
|
|
|
108
|
-
### Persistence only — offline-capable local
|
|
119
|
+
### Persistence only — offline-capable local store
|
|
109
120
|
|
|
110
121
|
```typescript
|
|
111
122
|
import { SDS_DataStore } from '@rozek/sds-core'
|
|
@@ -113,7 +124,7 @@ import { SDS_DesktopPersistenceProvider } from '@rozek/sds-persistence-node'
|
|
|
113
124
|
import { SDS_SyncEngine } from '@rozek/sds-sync-engine'
|
|
114
125
|
|
|
115
126
|
const DataStore = SDS_DataStore.fromScratch()
|
|
116
|
-
const Persistence = new SDS_DesktopPersistenceProvider('./data', 'my-store')
|
|
127
|
+
const Persistence = new SDS_DesktopPersistenceProvider('./data/sds.db', 'my-store')
|
|
117
128
|
|
|
118
129
|
const engine = new SDS_SyncEngine(DataStore, { PersistenceProvider:Persistence })
|
|
119
130
|
await engine.start()
|
|
@@ -124,7 +135,7 @@ data.Label = 'This data survives restarts'
|
|
|
124
135
|
await engine.stop() // writes checkpoint, closes DB
|
|
125
136
|
```
|
|
126
137
|
|
|
127
|
-
### Full
|
|
138
|
+
### Full stack — persistence + WebSocket + presence
|
|
128
139
|
|
|
129
140
|
```typescript
|
|
130
141
|
import { SDS_DataStore } from '@rozek/sds-core'
|
|
@@ -151,7 +162,7 @@ SyncEngine.onConnectionChange((ConnectionState) => {
|
|
|
151
162
|
})
|
|
152
163
|
```
|
|
153
164
|
|
|
154
|
-
### Presence — show
|
|
165
|
+
### Presence — show collaborators
|
|
155
166
|
|
|
156
167
|
```typescript
|
|
157
168
|
// announce yourself
|
|
@@ -193,4 +204,4 @@ await SyncEngine.reconnect()
|
|
|
193
204
|
|
|
194
205
|
## License
|
|
195
206
|
|
|
196
|
-
MIT © Andreas Rozek
|
|
207
|
+
[MIT License](../../LICENSE.md) © Andreas Rozek
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rozek/sds-sync-engine",
|
|
3
3
|
"description": "Coordinates persistence, network and presence for shareable-data-store",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.6",
|
|
5
5
|
"author": "Andreas Rozek",
|
|
6
6
|
"homepage": "https://github.com/rozek/shareable-data-store#readme",
|
|
7
7
|
"repository": {
|
|
@@ -27,19 +27,22 @@
|
|
|
27
27
|
"dist"
|
|
28
28
|
],
|
|
29
29
|
"peerDependencies": {
|
|
30
|
-
"@rozek/sds-core": "0.0.
|
|
30
|
+
"@rozek/sds-core": "0.0.6"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"typescript": "^5.7.2",
|
|
34
34
|
"vite": "^6.0.0",
|
|
35
35
|
"vite-plugin-dts": "^4.0.0",
|
|
36
36
|
"vitest": "^2.0.0",
|
|
37
|
-
"@rozek/sds-core": "0.0.
|
|
38
|
-
"@rozek/sds-core-jj": "0.0.
|
|
37
|
+
"@rozek/sds-core": "0.0.6",
|
|
38
|
+
"@rozek/sds-core-jj": "0.0.6"
|
|
39
39
|
},
|
|
40
40
|
"publishConfig": {
|
|
41
41
|
"access": "public"
|
|
42
42
|
},
|
|
43
|
+
"engines": {
|
|
44
|
+
"node": ">=22"
|
|
45
|
+
},
|
|
43
46
|
"scripts": {
|
|
44
47
|
"dev": "vite build --watch",
|
|
45
48
|
"build": "vite build",
|