@korajs/sync 0.1.0 → 0.1.2

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 (2) hide show
  1. package/README.md +67 -0
  2. package/package.json +3 -3
package/README.md ADDED
@@ -0,0 +1,67 @@
1
+ # @korajs/sync
2
+
3
+ Sync protocol and transports for Kora.js. Handles version vector delta sync, causal ordering, Protobuf wire format, and automatic reconnection with operation queuing.
4
+
5
+ > Most developers don't install this directly. Use [`korajs`](https://www.npmjs.com/package/korajs) instead.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ pnpm add @korajs/sync
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ### WebSocket Transport
16
+
17
+ ```typescript
18
+ import { SyncEngine, WebSocketTransport } from '@korajs/sync'
19
+
20
+ const transport = new WebSocketTransport({
21
+ url: 'wss://my-server.com/kora',
22
+ auth: async () => ({ token: await getAuthToken() }),
23
+ })
24
+
25
+ const sync = new SyncEngine({
26
+ transport,
27
+ mergeEngine,
28
+ operationLog,
29
+ })
30
+
31
+ sync.start()
32
+ ```
33
+
34
+ ### HTTP Transport
35
+
36
+ ```typescript
37
+ import { HttpTransport } from '@korajs/sync'
38
+
39
+ const transport = new HttpTransport({
40
+ url: 'https://my-server.com/kora/sync',
41
+ pollInterval: 5000,
42
+ })
43
+ ```
44
+
45
+ ### Sync Events
46
+
47
+ ```typescript
48
+ sync.on('connected', () => console.log('Connected'))
49
+ sync.on('disconnected', (reason) => console.log('Disconnected:', reason))
50
+ sync.on('sent', (ops) => console.log('Sent', ops.length, 'operations'))
51
+ sync.on('received', (ops) => console.log('Received', ops.length, 'operations'))
52
+ ```
53
+
54
+ ## Protocol
55
+
56
+ 1. **Handshake** -- exchange version vectors to determine what each side is missing
57
+ 2. **Delta sync** -- send only the operations the other side doesn't have
58
+ 3. **Real-time streaming** -- bidirectional operation flow after initial sync
59
+ 4. **Resumable** -- reconnects pick up from the last acknowledged sequence number
60
+
61
+ Operations are always sent in causal order. The protocol is idempotent -- duplicate operations are detected via content-addressing and safely ignored.
62
+
63
+ ## License
64
+
65
+ MIT
66
+
67
+ See the [full documentation](https://github.com/ehoneahobed/kora) for guides, API reference, and examples.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@korajs/sync",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Kora.js sync package",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -33,8 +33,8 @@
33
33
  ],
34
34
  "dependencies": {
35
35
  "protobufjs": "^8.0.1",
36
- "@korajs/core": "0.1.0",
37
- "@korajs/merge": "0.1.0"
36
+ "@korajs/core": "0.1.2",
37
+ "@korajs/merge": "0.1.2"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@fast-check/vitest": "0.2.0",