@jxsuite/collab 0.8.2 → 0.8.4
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 +13 -13
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ One `Y.Doc` per open file:
|
|
|
13
13
|
|
|
14
14
|
| Root type | Purpose |
|
|
15
15
|
| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
16
|
-
| `source: Y.Text` | **The authoritative file content.** Providers persist `getText("source").toString()`
|
|
16
|
+
| `source: Y.Text` | **The authoritative file content.** Providers persist `getText("source").toString()` and nothing else. |
|
|
17
17
|
| `structure: Y.Map` | The `JxMutableNode` tree, projected by Studio. Only `children` nests (`Y.Array`); every other key is a plain-JSON value merged whole (LWW). |
|
|
18
18
|
| `frontmatter: Y.Map` | Per-field plain-JSON values. |
|
|
19
19
|
| `meta: Y.Map` | `schemaVersion`, `structureSeeded`, `canonical`, `canonicalRev`, `sourceFormat`. |
|
|
@@ -24,16 +24,16 @@ The CRDT granularity deliberately equals Studio's op-log granularity: mutators e
|
|
|
24
24
|
**Seeding contract.** Providers seed only `source` from file bytes; they never parse or serialize
|
|
25
25
|
Jx documents. Clients derive `structure` on first sync via `seedStructure()`, which is safe under
|
|
26
26
|
concurrent seeders because it only performs whole-key `Y.Map` sets (per-key LWW keeps one seeder's
|
|
27
|
-
subtrees wholesale
|
|
28
|
-
empty; never seed locally before the provider's sync completes.
|
|
27
|
+
subtrees wholesale; it never uses array inserts, which would duplicate). A client's `Y.Doc` must
|
|
28
|
+
start empty; never seed locally before the provider's sync completes.
|
|
29
29
|
|
|
30
30
|
## The op bridge
|
|
31
31
|
|
|
32
32
|
- `applyDocOpsToY(doc, ops, origin)` replays Studio's recorded forward `JxDocOp`s onto the Y tree
|
|
33
33
|
in one origin-tagged transaction (`LOCAL_ORIGIN` for user edits, `MIRROR_ORIGIN` for derived
|
|
34
34
|
writes, `SEED_ORIGIN` for bootstraps).
|
|
35
|
-
- `yEventsToDocOps(events)` converts a remote transaction's deep events back into `JxDocOp`s
|
|
36
|
-
|
|
35
|
+
- `yEventsToDocOps(events)` converts a remote transaction's deep events back into `JxDocOp`s.
|
|
36
|
+
Call it **inside** the `observeDeep` callback. It returns `null` for shapes it cannot convert
|
|
37
37
|
safely; reconcile by diffing instead.
|
|
38
38
|
- `diffDocs(a, b)` produces ops transforming `a` into `b` (invariant: `apply(clone(a), diff(a,b))
|
|
39
39
|
≡ b`); returns `null` past `maxOps`, in which case `replaceYStructure()` hard-replaces and bumps
|
|
@@ -68,19 +68,19 @@ one `error{read-only}`.
|
|
|
68
68
|
## Awareness (`./awareness-types`)
|
|
69
69
|
|
|
70
70
|
One project-level `Awareness` per connection. State shape:
|
|
71
|
-
`{ user: {login, name?, avatarUrl?, color}, focusedPath, mode?, structuralSelection?, selection? }
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
71
|
+
`{ user: {login, name?, avatarUrl?, color}, focusedPath, mode?, structuralSelection?, selection? }`.
|
|
72
|
+
File-tree presence (the plain `selection` field is the code view's in-buffer cursor) and
|
|
73
|
+
per-document cursor overlays both filter the same states. Identity comes from the server `hello`;
|
|
74
|
+
colors are deterministic (`colorForKey`).
|
|
75
75
|
|
|
76
76
|
## Provider contract (`./provider`, type-only)
|
|
77
77
|
|
|
78
78
|
`StudioPlatform.collab?: (docPath) => Promise<CollabHandle | null>` where a handle carries
|
|
79
79
|
`{doc, awareness, whenSynced, identity(), flush(), onStatus(), onReset(), destroy()}`. `onReset`
|
|
80
|
-
fires on a `doc-reset`: the handle is dead
|
|
80
|
+
fires on a `doc-reset`: the handle is dead, so destroy it and re-acquire.
|
|
81
81
|
|
|
82
82
|
## Versioning
|
|
83
83
|
|
|
84
|
-
Published to npm as `@jxsuite/collab
|
|
85
|
-
package,
|
|
86
|
-
|
|
84
|
+
Published to npm as `@jxsuite/collab`, following the monorepo's release train. Like every `@jxsuite`
|
|
85
|
+
package, it ships TypeScript source. Within the monorepo, other packages (`@jxsuite/server`,
|
|
86
|
+
`@jxsuite/studio`) depend on it via `workspace:^`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jxsuite/collab",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.4",
|
|
4
4
|
"description": "Realtime co-editing for Jx Studio — Y.Doc schema, op bridge, structural differ, wire envelope, and provider contracts shared by every collab backend",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"test:coverage": "bun test --isolate --coverage"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@jxsuite/schema": "^
|
|
36
|
+
"@jxsuite/schema": "^2.0.0",
|
|
37
37
|
"lib0": "^0.2.117",
|
|
38
38
|
"y-protocols": "^1.0.7",
|
|
39
39
|
"yjs": "13.6.32"
|