You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor!: Introduce subpath exports and remove server-registry abstraction in loro-adaptors (#25)
* feat(loro-adaptors): Introduce subpath exports and remove server-registry abstraction
This commit refactors the `loro-adaptors` package to improve modularity and
make peer dependencies truly optional.
Previously, importing from `loro-adaptors` would implicitly pull in all
peer dependencies, leading to "Could not resolve" errors if a user only
intended to use a subset of adaptors (e.g., only `flock` without `loro-crdt`).
Additionally, the `server-registry` abstraction was identified as unnecessary.
This change addresses these issues by:
- Introducing subpath exports for specific adaptor groups:
- `loro-adaptors/loro`: Exports `LoroAdaptor`, `LoroEphemeralAdaptor`,
`LoroPersistentStoreAdaptor`, `EloAdaptor`, and their server counterparts.
This requires `loro-crdt` as a peer dependency.
- `loro-adaptors/flock`: Exports `FlockAdaptor` and `FlockServerAdaptor`.
This requires `@loro-dev/flock` as a peer dependency.
- `loro-adaptors/yjs`: Exports `YjsAwarenessServerAdaptor` for Yjs awareness.
This requires `yjs` as a peer dependency.
- Refactoring `src/index.ts` to only export general types and core utilities,
effectively making it a lean entry point without direct adaptor implementations.
- Removing `src/server/server-registry.ts` and the `AdaptorsForServer` interface
from `src/types.ts`, as this abstraction was deemed unnecessary.
- Updating `package.json` `exports` and `tsdown.config.ts` entry points to reflect
the new modular structure.
- Updating `README.md` with revised installation instructions and usage examples
for the new subpath imports.
* chore: update docs
Copy file name to clipboardExpand all lines: packages/loro-adaptors/README.md
+50-17Lines changed: 50 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,11 +1,20 @@
1
1
# loro-adaptors
2
2
3
-
Adaptors that bridge the Loro protocol to `loro-crdt` documents and the ephemeral store. Includes an end‑to‑end encrypted adaptor for %ELO.
3
+
Adaptors that bridge the Loro protocol to `loro-crdt` documents, `flock` replicas, and the ephemeral store. Includes an end‑to‑end encrypted adaptor for %ELO.
4
4
5
5
## Install
6
6
7
7
```bash
8
-
pnpm add loro-adaptors loro-protocol loro-crdt
8
+
pnpm add loro-adaptors loro-protocol
9
+
10
+
# If using loro-crdt:
11
+
pnpm add loro-crdt
12
+
13
+
# If using flock:
14
+
pnpm add @loro-dev/flock
15
+
16
+
# If using yjs:
17
+
pnpm add yjs
9
18
```
10
19
11
20
## Why
@@ -15,18 +24,22 @@ The websocket client (`loro-websocket`) speaks the binary wire protocol. These a
15
24
-`LoroAdaptor`: wraps a `LoroDoc` and streams local updates to the connection; applies remote updates on receipt
16
25
-`LoroEphemeralAdaptor`: wraps an `EphemeralStore` for transient presence/cursor data
17
26
-`LoroPersistentStoreAdaptor`: wraps an `EphemeralStore` but marks updates as persisted so the server stores them for new peers
18
-
-`EloLoroAdaptor`: wraps a `LoroDoc` and packages updates into %ELO containers with AES‑GCM; decrypts inbound containers and imports plaintext.
27
+
-`EloAdaptor`: wraps a `LoroDoc` and packages updates into %ELO containers with AES‑GCM; decrypts inbound containers and imports plaintext.
28
+
-`FlockAdaptor`: wraps a `Flock` replica and streams local updates to the connection; applies remote updates on receipt.
29
+
-`YjsAwarenessServerAdaptor`: handles Yjs awareness updates on the server side (opaque blob merging).
0 commit comments