@y/y 14.0.0-rc.20 → 14.0.0-rc.22
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 +1 -1
- package/dist/src/utils/Doc.d.ts.map +1 -1
- package/dist/src/utils/Transaction.d.ts.map +1 -1
- package/dist/src/utils/YEvent.d.ts +1 -1
- package/dist/src/utils/transaction-helpers.d.ts +2 -2
- package/dist/src/utils/transaction-helpers.d.ts.map +1 -1
- package/dist/src/ytype.d.ts +103 -24
- package/dist/src/ytype.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/utils/Doc.js +3 -0
- package/src/utils/Transaction.js +31 -19
- package/src/utils/YEvent.js +2 -2
- package/src/utils/transaction-helpers.js +15 -15
- package/src/ytype.js +334 -164
package/README.md
CHANGED
|
@@ -175,7 +175,7 @@ are implemented in separate modules.
|
|
|
175
175
|
| [Superdoc](https://superdoc.dev/) | ✔ | (native) | [demo](https://superdoc.dev/) |
|
|
176
176
|
| [valtio](https://github.com/pmndrs/valtio) | | [valtio-yjs](https://github.com/dai-shi/valtio-yjs) | [demo](https://codesandbox.io/s/valtio-yjs-demo-ox3iy) |
|
|
177
177
|
| [immer](https://github.com/immerjs/immer) | | [immer-yjs](https://github.com/sep2/immer-yjs) | [demo](https://codesandbox.io/s/immer-yjs-demo-6e0znb) |
|
|
178
|
-
| [mutative](https://github.com/unadlib/mutative) |
|
|
178
|
+
| [mutative](https://github.com/unadlib/mutative) | | [mutative-yjs](https://github.com/mutativejs/mutative-yjs) | [demo](https://codesandbox.io/p/sandbox/fjrwk3) |
|
|
179
179
|
| React | | [react-yjs](https://github.com/nikgraf/react-yjs) | [demo](https://react-yjs-example.vercel.app/) |
|
|
180
180
|
| React / Vue / Svelte / MobX | | [SyncedStore](https://syncedstore.org) | [demo](https://syncedstore.org/docs/react) |
|
|
181
181
|
| [mobx-keystone](https://mobx-keystone.js.org/) | | [mobx-keystone-yjs](https://github.com/xaviergonz/mobx-keystone/tree/master/packages/mobx-keystone-yjs) | [demo](https://mobx-keystone.js.org/examples/yjs-binding) |
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Doc.d.ts","sourceRoot":"","sources":["../../../src/utils/Doc.js"],"names":[],"mappings":"AAeA;;;;;;;;;;;;GAYG;AAEH;;;;;;;;;;;;;;GAcG;AAEH;;;GAGG;AACH;IACE;;OAEG;IACH,gGAFW,OAAO,EAwFjB;IApFC,YAAY;IACZ,iBAtCmB,IAAI,KAAE,OAAO,CAsCR;IACxB,iBAAqC;IACrC,aAAgB;IAChB,4BAAgC;IAChC,yBAAsC;IACtC,2BAAyC;IACzC;;OAEG;IACH,OAFU,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,CAEN;IACtB,mBAA8B;IAC9B;;OAEG;IACH,cAFU,WAAW,GAAG,IAAI,CAEJ;IACxB;;OAEG;IACH,sBAFU,KAAK,CAAC,WAAW,CAAC,CAEE;IAC9B;;OAEG;IACH,SAFU,GAAG,CAAC,GAAG,CAAC,CAEM;IACxB;;;OAGG;IACH,OAFU,IAAI,OAAC,CAEE;IACjB,oBAA4B;IAC5B,kBAAwB;IACxB,UAAgB;IAChB;;;;;OAKG;IACH,UAFU,OAAO,CAEI;IACrB;;;;;;OAMG;IACH,kBAAqB;IACrB,qBAAwB;IACxB;;OAEG;IACH,yBAKE;IAeE,yBAAwC;IAe9C;;;;;;OAMG;IACH,aAQC;IAED,uBAEC;IAED,8BAEC;IAED;;;;;;;;;;;OAWG;IACH,SANa,CAAC,KACH,CAAS,IAAW,EAAX,WAAW,KAAE,CAAC,WACvB,GAAG,UACH,OAAO,KAKjB;IAED;;;;;;;;;;;;;OAaG;IACH,UALW,MAAM,SACN,MAAM,OAAC,GAEN,KAAK,CAQhB;IAED;;;;;;;OAOG;IACH;;MASC;
|
|
1
|
+
{"version":3,"file":"Doc.d.ts","sourceRoot":"","sources":["../../../src/utils/Doc.js"],"names":[],"mappings":"AAeA;;;;;;;;;;;;GAYG;AA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IACH,mCAA6B;IAC7B;;OAEG;IACH,oCAA8B;IAC9B;;;OAGG;IACH,cAFU,GAAG,gBAAe,OAAC,CAEL;IACxB;;;OAGG;IACH,aAFU,GAAG,gBAAe,OAAC,CAEN;IACvB;;;;;OAKG;IACH,SAFU,GAAG,CAAC,KAAK,EAAC,GAAG,CAAC,SAAO,IAAI,CAAC,CAAC,CAEb;IACxB;;;;OAIG;IACH,oBAFU,GAAG,CAAC,KAAK,EAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAEJ;IACnC;;OAEG;IACH,eAFU,KAAK,CAAC,cAAc,CAAC,CAER;IACvB;;OAEG;IACH,QAFU,GAAG,CAEO;IACpB;;;OAGG;IACH,MAFU,GAAG,CAAC,GAAG,EAAC,GAAG,CAAC,CAED;IACrB;;;OAGG;IACH,OAFU,OAAO,CAEC;IAClB;;OAEG;IACH,cAFU,GAAG,CAAC,GAAG,CAAC,CAEW;IAC7B;;OAEG;IACH,gBAFU,GAAG,CAAC,GAAG,CAAC,CAEa;IAC/B;;OAEG;IACH,eAFU,GAAG,CAAC,GAAG,CAAC,CAEY;IAC9B;;OAEG;IACH,wBAFU,OAAO,CAEkB;IACnC,eAAkB;IAGpB;;;;;OAKG;IACH,mBAFU,GAAG,gBAAe,CAW3B;IAED;;;;;OAKG;IACH,kBAFU,GAAG,gBAAe,CAc3B;CACF;AAcM,6CAHI,KAAK,GACJ,MAAM,CA2BjB;
|
|
1
|
+
{"version":3,"file":"Transaction.d.ts","sourceRoot":"","sources":["../../../src/utils/Transaction.js"],"names":[],"mappings":"AAiBA,uDAAgD;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH;IACE;;;;OAIG;IACH,iBAJW,GAAG,UACH,GAAG,SACH,OAAO,EA+EjB;IA5EC;;;OAGG;IACH,KAFU,GAAG,CAEC;IACd;;OAEG;IACH,oCAA8B;IAC9B;;;OAGG;IACH,mCAA6B;IAC7B;;OAEG;IACH,oCAA8B;IAC9B;;;OAGG;IACH,cAFU,GAAG,gBAAe,OAAC,CAEL;IACxB;;;OAGG;IACH,aAFU,GAAG,gBAAe,OAAC,CAEN;IACvB;;;;;OAKG;IACH,SAFU,GAAG,CAAC,KAAK,EAAC,GAAG,CAAC,SAAO,IAAI,CAAC,CAAC,CAEb;IACxB;;;;OAIG;IACH,oBAFU,GAAG,CAAC,KAAK,EAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAEJ;IACnC;;OAEG;IACH,eAFU,KAAK,CAAC,cAAc,CAAC,CAER;IACvB;;OAEG;IACH,QAFU,GAAG,CAEO;IACpB;;;OAGG;IACH,MAFU,GAAG,CAAC,GAAG,EAAC,GAAG,CAAC,CAED;IACrB;;;OAGG;IACH,OAFU,OAAO,CAEC;IAClB;;OAEG;IACH,cAFU,GAAG,CAAC,GAAG,CAAC,CAEW;IAC7B;;OAEG;IACH,gBAFU,GAAG,CAAC,GAAG,CAAC,CAEa;IAC/B;;OAEG;IACH,eAFU,GAAG,CAAC,GAAG,CAAC,CAEY;IAC9B;;OAEG;IACH,wBAFU,OAAO,CAEkB;IACnC,eAAkB;IAGpB;;;;;OAKG;IACH,mBAFU,GAAG,gBAAe,CAW3B;IAED;;;;;OAKG;IACH,kBAFU,GAAG,gBAAe,CAc3B;CACF;AAcM,6CAHI,KAAK,GACJ,MAAM,CA2BjB;AAoJM,0DAFI,WAAW,QAsCrB;AAcM,yBATM,CAAC,OACH,GAAG,KACH,CAAS,IAAW,EAAX,WAAW,KAAE,CAAC,WACvB,GAAG,UACH,OAAO,GACN,CAAC,CAwCZ;wBAvauB,aAAa;uBAJd,aAAa"}
|
|
@@ -64,7 +64,7 @@ export class YEvent<DConf extends DeltaConf> {
|
|
|
64
64
|
/**
|
|
65
65
|
* @template {boolean} [Deep=false]
|
|
66
66
|
* @param {object} [opts]
|
|
67
|
-
* @param {AbstractRenderer} [opts.renderer] - renders the content (with attributions); defaults to `baseRenderer`
|
|
67
|
+
* @param {AbstractRenderer} [opts.renderer] - renders the content (with attributions); defaults to the target type's active renderer (see {@link YType#useRenderer}), i.e. `baseRenderer` unless changed
|
|
68
68
|
* @param {Deep} [opts.deep]
|
|
69
69
|
* @return {Deep extends true ? Delta<DConf> : Delta<import('../ytype.js').DeltaConfDeltaToYType<DConf>>} The Delta representation of this type.
|
|
70
70
|
*
|
|
@@ -13,6 +13,6 @@ export function tryGcDeleteSet(tr: Transaction, ds: IdSet, gcFilter: (arg0: Item
|
|
|
13
13
|
export function tryMerge(ds: IdSet, store: StructStore): void;
|
|
14
14
|
export function tryGc(tr: Transaction, idset: IdSet, gcFilter: (arg0: Item) => boolean): void;
|
|
15
15
|
export function cleanupContextlessFormattingGap(transaction: Transaction, item: Item | null): 0 | undefined;
|
|
16
|
-
export function
|
|
17
|
-
export function cleanupFormattingGap(transaction: Transaction, start: Item, curr: Item | null,
|
|
16
|
+
export function updateCurrentFormats(currentFormats: Map<string, any>, { key, value }: ContentFormat): void;
|
|
17
|
+
export function cleanupFormattingGap(transaction: Transaction, start: Item, curr: Item | null, startFormats: Map<string, any>, currFormats: Map<string, any>): number;
|
|
18
18
|
//# sourceMappingURL=transaction-helpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction-helpers.d.ts","sourceRoot":"","sources":["../../../src/utils/transaction-helpers.js"],"names":[],"mappings":"AAqBO,qCAPI,KAAK,CAAC,IAAI,GAAC,EAAE,GAAC,IAAI,CAAC,SACnB,MAAM,GACL,MAAM,CAiCjB;AAOM,iDAJI,WAAW,OAAC,WACZ,KAAK,CAAC,IAAI,GAAC,EAAE,GAAC,IAAI,CAAC,SACnB,MAAM,UAUhB;AAYM,+CAPI,WAAW,MACX,EAAE,GACD,IAAI,CAQf;AAaM,6CARI,WAAW,SACX,WAAW,MACX,EAAE,GACD,IAAI,CAaf;AAWM,kCAPI,WAAW,UACX,EAAE,GAAC,IAAI,aACP,EAAE,GAAC,IAAI,QASjB;AAaM,4CARI,WAAW,WACX,KAAK,CAAC,IAAI,GAAC,EAAE,CAAC,cACd,MAAM,OACN,MAAM,KACN,CAAS,IAAO,EAAP,EAAE,GAAC,IAAI,KAAE,IAAI,QAkBhC;AAaM,qDAPI,KAAK,CAAC,IAAI,GAAC,EAAE,CAAC,cACd,MAAM,OACN,MAAM,KACN,CAAC,MAAM,EAAE,EAAE,GAAC,IAAI,GAAC,IAAI,EAAE,MAAM,EAAC,MAAM,EAAE,GAAG,EAAC,MAAM,KAAG,IAAI,QAkBjE;AAYM,yCARI,WAAW,OAAC,cACZ,IAAI,GAAC,EAAE,GAAC,IAAI,QACZ,MAAM,GACL,EAAE,GAAC,IAAI,GAAC,IAAI,CAavB;AAQM,oCALI,WAAW,wBAQrB;AAUM,yDAJI,WAAW,QACX,KAAK,aACL,MAAM,GAAC,IAAI,QAOrB;AAOM,6CAJI,KAAK,CAAC,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC,OACvB,MAAM,GACL,MAAM,CAuBjB;AAOM,mCAJI,WAAW,MACX,KAAK,YACL,CAAS,IAAI,EAAJ,IAAI,KAAE,OAAO,QAwBhC;AAMM,6BAHI,KAAK,SACL,WAAW,QAqBrB;AAOM,0BAJI,WAAW,SACX,KAAK,YACL,CAAS,IAAI,EAAJ,IAAI,KAAE,OAAO,QAKhC;AAMM,6DAHI,WAAW,QACX,IAAI,GAAG,IAAI,iBAsBrB;AASM,
|
|
1
|
+
{"version":3,"file":"transaction-helpers.d.ts","sourceRoot":"","sources":["../../../src/utils/transaction-helpers.js"],"names":[],"mappings":"AAqBO,qCAPI,KAAK,CAAC,IAAI,GAAC,EAAE,GAAC,IAAI,CAAC,SACnB,MAAM,GACL,MAAM,CAiCjB;AAOM,iDAJI,WAAW,OAAC,WACZ,KAAK,CAAC,IAAI,GAAC,EAAE,GAAC,IAAI,CAAC,SACnB,MAAM,UAUhB;AAYM,+CAPI,WAAW,MACX,EAAE,GACD,IAAI,CAQf;AAaM,6CARI,WAAW,SACX,WAAW,M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 -1,18 +1,18 @@
|
|
|
1
1
|
export function warnPrematureAccess(): void;
|
|
2
|
-
export function createAttributionFromAttributionItems(attrs: Array<ContentAttribute<any>> | null, deleted: boolean): Attribution |
|
|
2
|
+
export function createAttributionFromAttributionItems(attrs: Array<ContentAttribute<any>> | null, deleted: boolean): Attribution | undefined;
|
|
3
3
|
export class ItemTextListPosition {
|
|
4
4
|
/**
|
|
5
5
|
* @param {Item|null} left
|
|
6
6
|
* @param {Item|null} right
|
|
7
7
|
* @param {number} index
|
|
8
|
-
* @param {Map<string,any>}
|
|
8
|
+
* @param {Map<string,any>} currentFormats
|
|
9
9
|
* @param {AbstractRenderer} renderer
|
|
10
10
|
*/
|
|
11
|
-
constructor(left: Item | null, right: Item | null, index: number,
|
|
11
|
+
constructor(left: Item | null, right: Item | null, index: number, currentFormats: Map<string, any>, renderer: AbstractRenderer);
|
|
12
12
|
left: Item | null;
|
|
13
13
|
right: Item | null;
|
|
14
14
|
index: number;
|
|
15
|
-
|
|
15
|
+
currentFormats: Map<string, any>;
|
|
16
16
|
renderer: import("./utils/renderer-helpers.js").AbstractRenderer;
|
|
17
17
|
/**
|
|
18
18
|
* Only call this if you know that this.right is defined
|
|
@@ -22,18 +22,18 @@ export class ItemTextListPosition {
|
|
|
22
22
|
* @param {Transaction} transaction
|
|
23
23
|
* @param {YType} parent
|
|
24
24
|
* @param {number} length
|
|
25
|
-
* @param {Object<string,any>}
|
|
25
|
+
* @param {Object<string,any>} formats
|
|
26
26
|
*
|
|
27
27
|
* @function
|
|
28
28
|
*/
|
|
29
|
-
formatText(transaction: Transaction, parent: YType, length: number,
|
|
29
|
+
formatText(transaction: Transaction, parent: YType, length: number, formats: {
|
|
30
30
|
[x: string]: any;
|
|
31
31
|
}): void;
|
|
32
32
|
}
|
|
33
|
-
export function insertContent(transaction: Transaction, parent: YType, currPos: ItemTextListPosition, content: import("./structs/Item.js").AbstractContent,
|
|
33
|
+
export function insertContent(transaction: Transaction, parent: YType, currPos: ItemTextListPosition, content: import("./structs/Item.js").AbstractContent, formats: {
|
|
34
34
|
[x: string]: any;
|
|
35
35
|
}): void;
|
|
36
|
-
export function insertContentHelper(transaction: Transaction, parent: YType, currPos: ItemTextListPosition, insert: Array<any> | string,
|
|
36
|
+
export function insertContentHelper(transaction: Transaction, parent: YType, currPos: ItemTextListPosition, insert: Array<any> | string, formats: {
|
|
37
37
|
[x: string]: any;
|
|
38
38
|
}): void;
|
|
39
39
|
export function deleteText(transaction: Transaction, currPos: ItemTextListPosition, length: number): ItemTextListPosition;
|
|
@@ -52,10 +52,24 @@ export function updateMarkerChanges(searchMarker: Array<ArraySearchMarker>, inde
|
|
|
52
52
|
export function getTypeChildren(t: YType): Array<Item>;
|
|
53
53
|
export function callTypeObservers(type: YType, transaction: Transaction, event: YEvent<any>): void;
|
|
54
54
|
/**
|
|
55
|
-
* Abstract Yjs Type class
|
|
55
|
+
* Abstract Yjs Type class.
|
|
56
|
+
*
|
|
57
|
+
* A `YType` is a {@link https://github.com/dmonad/lib0 lib0} `RDT` ("replicated data type", see
|
|
58
|
+
* `lib0/delta/rdt.js`): it emits a `'delta'` event whenever its state changes (carrying the change
|
|
59
|
+
* and the origin of the transaction that caused it), accepts foreign
|
|
60
|
+
* changes via {@link YType#applyDelta}, exposes its delta {@link YType#$delta schema}, and can be
|
|
61
|
+
* torn down via {@link YType#destroy}. This lets a `YType` be `bind()`-ed to any other RDT (another
|
|
62
|
+
* `YType`, an in-memory delta, a DOM subtree, …). The legacy {@link YType#observe `observe`} /
|
|
63
|
+
* {@link YType#observeDeep `observeDeep`} `YEvent` API continues to work alongside the `'delta'`
|
|
64
|
+
* channel.
|
|
65
|
+
*
|
|
56
66
|
* @template {delta.DeltaConf} [DConf=any]
|
|
67
|
+
* @extends {ObservableV2<{ delta: (delta: delta.Delta<DConf>, origin: any) => void, destroy: (type: YType<DConf>) => void }>}
|
|
57
68
|
*/
|
|
58
|
-
export class YType<DConf extends delta.DeltaConf = any> {
|
|
69
|
+
export class YType<DConf extends delta.DeltaConf = any> extends ObservableV2<{
|
|
70
|
+
delta: (delta: delta.Delta<DConf>, origin: any) => void;
|
|
71
|
+
destroy: (type: YType<DConf>) => void;
|
|
72
|
+
}> {
|
|
59
73
|
/**
|
|
60
74
|
* @template {delta.DeltaConf} DC
|
|
61
75
|
* @param {delta.Delta<DC>} d
|
|
@@ -102,16 +116,78 @@ export class YType<DConf extends delta.DeltaConf = any> {
|
|
|
102
116
|
*/
|
|
103
117
|
_searchMarker: null | Array<ArraySearchMarker>;
|
|
104
118
|
/**
|
|
105
|
-
* @
|
|
106
|
-
*
|
|
119
|
+
* Maintained deep-delta cache backing {@link YType#delta}. `null` until `delta` is first
|
|
120
|
+
* accessed; thereafter kept current on every event of this type (incrementally, by applying the
|
|
121
|
+
* deep change) and re-diffed by {@link YType#useRenderer}. Cleared by {@link YType#clearCache}.
|
|
122
|
+
* @type {delta.DeltaBuilderAny | null}
|
|
107
123
|
*/
|
|
108
|
-
|
|
124
|
+
_delta: delta.DeltaBuilderAny | null;
|
|
109
125
|
_legacyTypeRef: number;
|
|
110
126
|
/**
|
|
111
|
-
* Whether this YText contains
|
|
127
|
+
* Whether this YText contains formats.
|
|
112
128
|
* This flag is updated when a formatting item is integrated (see ContentFormat.integrate)
|
|
113
129
|
*/
|
|
114
130
|
_hasFormatting: boolean;
|
|
131
|
+
/**
|
|
132
|
+
* The active default renderer. Used by `toDelta`, `applyDelta`, and the events whenever no
|
|
133
|
+
* explicit renderer is passed. Change it via {@link YType#useRenderer}.
|
|
134
|
+
* @type {AbstractRenderer}
|
|
135
|
+
*/
|
|
136
|
+
_renderer: AbstractRenderer;
|
|
137
|
+
/**
|
|
138
|
+
* Schema of the deltas this type produces — part of the lib0 `RDT` interface.
|
|
139
|
+
*
|
|
140
|
+
* @type {s.Schema<delta.Delta<DConf>>}
|
|
141
|
+
*/
|
|
142
|
+
get $delta(): s.Schema<delta.Delta<DConf>>;
|
|
143
|
+
/**
|
|
144
|
+
* The deep delta of this type (the full nested content tree, children rendered as their own
|
|
145
|
+
* deltas).
|
|
146
|
+
*
|
|
147
|
+
* The returned value is the type's **live** maintained cache: it is materialized on first access
|
|
148
|
+
* and then kept current on every event fired on this type (and re-diffed by
|
|
149
|
+
* {@link YType#useRenderer}), so a reference held across edits keeps updating in place. Clone it
|
|
150
|
+
* (e.g. `type.delta.clone()`) if you need a stable snapshot, and call {@link YType#clearCache} to
|
|
151
|
+
* drop the cache.
|
|
152
|
+
*
|
|
153
|
+
* Consider the returned delta **done** — it must not be edited from the outside. It is
|
|
154
|
+
* deliberately typed as a `Delta` (not a `DeltaBuilder`) so the mutating builder API is not
|
|
155
|
+
* reachable; editing it anyway would corrupt the cache without changing the CRDT. The proper way
|
|
156
|
+
* to change this type is {@link YType#applyDelta}.
|
|
157
|
+
*
|
|
158
|
+
* @type {delta.Delta<DConf>}
|
|
159
|
+
*/
|
|
160
|
+
get delta(): delta.Delta<DConf>;
|
|
161
|
+
/**
|
|
162
|
+
* Render the full deep current state into a fresh `isFinal` builder (so subsequent `.apply`s of
|
|
163
|
+
* deep changes update content in place). Uses this type's active renderer.
|
|
164
|
+
*
|
|
165
|
+
* @return {delta.DeltaBuilderAny}
|
|
166
|
+
*/
|
|
167
|
+
_renderDelta(): delta.DeltaBuilderAny;
|
|
168
|
+
/**
|
|
169
|
+
* Discard the cached deep delta backing {@link YType#delta}.
|
|
170
|
+
*
|
|
171
|
+
* After `delta` is first accessed, the cache is updated on every event fired on this type (and
|
|
172
|
+
* re-diffed by {@link YType#useRenderer}). Call this to drop it — e.g. to reclaim memory, or to
|
|
173
|
+
* force an exact recomputation after editing while a non-base renderer is active (the incremental
|
|
174
|
+
* updates can drift from a fresh deep render in that case).
|
|
175
|
+
*/
|
|
176
|
+
clearCache(): void;
|
|
177
|
+
/**
|
|
178
|
+
* Change the default renderer used by this type. After calling `useRenderer(renderer)`, the
|
|
179
|
+
* `toDelta`, `applyDelta`, and event methods all use `renderer` whenever no explicit renderer is
|
|
180
|
+
* passed (an explicit `{ renderer }` argument still overrides it per call).
|
|
181
|
+
*
|
|
182
|
+
* If the deep-delta cache ({@link YType#delta}) is being maintained, or a `'delta'` listener is
|
|
183
|
+
* attached, the content is re-rendered with the new renderer and the difference is emitted on the
|
|
184
|
+
* `'delta'` channel only (a renderer switch is not a CRDT change, so no `YEvent` is produced, and
|
|
185
|
+
* the emitted origin is `null` as no transaction is involved).
|
|
186
|
+
*
|
|
187
|
+
* @param {AbstractRenderer} renderer
|
|
188
|
+
* @return {this}
|
|
189
|
+
*/
|
|
190
|
+
useRenderer(renderer: AbstractRenderer): this;
|
|
115
191
|
get length(): number;
|
|
116
192
|
/**
|
|
117
193
|
* Returns a fresh delta that can be used to change this YType.
|
|
@@ -184,7 +260,7 @@ export class YType<DConf extends delta.DeltaConf = any> {
|
|
|
184
260
|
* @template {boolean} [Deep=false]
|
|
185
261
|
*
|
|
186
262
|
* @param {Object} [opts]
|
|
187
|
-
* @param {AbstractRenderer} [opts.renderer] - renders the content (with attributions); defaults to `baseRenderer`
|
|
263
|
+
* @param {AbstractRenderer} [opts.renderer] - renders the content (with attributions); defaults to this type's active renderer (see {@link YType#useRenderer}), i.e. `baseRenderer` unless changed
|
|
188
264
|
* @param {IdSet?} [opts.itemsToRender]
|
|
189
265
|
* @param {boolean} [opts.retainInserts] - if true, retain rendered inserts with attributions
|
|
190
266
|
* @param {boolean} [opts.retainDeletes] - if true, retain rendered+attributed deletes only
|
|
@@ -209,7 +285,7 @@ export class YType<DConf extends delta.DeltaConf = any> {
|
|
|
209
285
|
* attributions.
|
|
210
286
|
*
|
|
211
287
|
* @param {Object} [opts]
|
|
212
|
-
* @param {AbstractRenderer} [opts.renderer] - renders the content (with attributions); defaults to `baseRenderer`
|
|
288
|
+
* @param {AbstractRenderer} [opts.renderer] - renders the content (with attributions); defaults to this type's active renderer (see {@link YType#useRenderer}), i.e. `baseRenderer` unless changed
|
|
213
289
|
* @return {delta.Delta<DConf>}
|
|
214
290
|
*/
|
|
215
291
|
toDeltaDeep(opts?: {
|
|
@@ -220,13 +296,15 @@ export class YType<DConf extends delta.DeltaConf = any> {
|
|
|
220
296
|
*
|
|
221
297
|
* @param {delta.DeltaAny} d The changes to apply on this element.
|
|
222
298
|
* @param {Object} [opts]
|
|
223
|
-
* @param {AbstractRenderer} [opts.renderer] - renders the content (with attributions); defaults to `baseRenderer`
|
|
299
|
+
* @param {AbstractRenderer} [opts.renderer] - renders the content (with attributions); defaults to this type's active renderer (see {@link YType#useRenderer}), i.e. `baseRenderer` unless changed
|
|
300
|
+
* @return {null} The lib0 `RDT` "fix" of this apply — always `null`: a `YType` accepts every valid
|
|
301
|
+
* delta as-is and never needs to self-correct.
|
|
224
302
|
*
|
|
225
303
|
* @public
|
|
226
304
|
*/
|
|
227
305
|
public applyDelta(d: delta.DeltaAny, { renderer }?: {
|
|
228
306
|
renderer?: import("./utils/renderer-helpers.js").AbstractRenderer | undefined;
|
|
229
|
-
}):
|
|
307
|
+
}): null;
|
|
230
308
|
/**
|
|
231
309
|
* Makes a copy of this data type that can be included somewhere else.
|
|
232
310
|
*
|
|
@@ -302,9 +380,9 @@ export class YType<DConf extends delta.DeltaConf = any> {
|
|
|
302
380
|
*
|
|
303
381
|
* @param {number} index The index to insert content at.
|
|
304
382
|
* @param {Array<delta.DeltaConfGetChildren<DConf>>|delta.DeltaConfGetText<DConf>} content Array of content to append.
|
|
305
|
-
* @param {delta.
|
|
383
|
+
* @param {delta.Formats} [format]
|
|
306
384
|
*/
|
|
307
|
-
insert(index: number, content: Array<delta.DeltaConfGetChildren<DConf>> | delta.DeltaConfGetText<DConf>, format?: delta.
|
|
385
|
+
insert(index: number, content: Array<delta.DeltaConfGetChildren<DConf>> | delta.DeltaConfGetText<DConf>, format?: delta.Formats): void;
|
|
308
386
|
/**
|
|
309
387
|
* Inserts new content at an index.
|
|
310
388
|
*
|
|
@@ -320,10 +398,10 @@ export class YType<DConf extends delta.DeltaConf = any> {
|
|
|
320
398
|
*
|
|
321
399
|
* @param {number} index The index to insert content at.
|
|
322
400
|
* @param {number} length The index to insert content at.
|
|
323
|
-
* @param {delta.
|
|
401
|
+
* @param {delta.Formats} formats
|
|
324
402
|
*
|
|
325
403
|
*/
|
|
326
|
-
format(index: number, length: number, formats: delta.
|
|
404
|
+
format(index: number, length: number, formats: delta.Formats): void;
|
|
327
405
|
/**
|
|
328
406
|
* Appends content to this YArray.
|
|
329
407
|
*
|
|
@@ -452,7 +530,7 @@ export class YType<DConf extends delta.DeltaConf = any> {
|
|
|
452
530
|
export function $ytype<DConf extends import("lib0/delta").ReadableDeltaConf>(_dconf: DConf): s.Schema<YType<import("lib0/delta").ReadDeltaConf<DConf>>>;
|
|
453
531
|
export const $ytypeAny: s.Schema<YType<any>>;
|
|
454
532
|
export function computeModifiedFromItems(store: StructStore, items: IdSet): Map<YType<any>, Set<string | null>>;
|
|
455
|
-
export function
|
|
533
|
+
export function equalFormats(a: any, b: any): boolean;
|
|
456
534
|
export function typeListSlice(type: YType<any>, start: number, end: number): Array<any>;
|
|
457
535
|
export function typeListGet(type: YType, index: number): any;
|
|
458
536
|
export function typeListInsertGenericsAfter(transaction: Transaction, parent: YType, referenceItem: Item | null, content: Array<YValue>): void;
|
|
@@ -515,8 +593,9 @@ export type DeltaToYType<Data extends unknown> = Exclude<Data, delta.DeltaAny> |
|
|
|
515
593
|
import { Item } from './structs/Item.js';
|
|
516
594
|
import { YEvent } from './utils/YEvent.js';
|
|
517
595
|
import * as delta from 'lib0/delta';
|
|
518
|
-
import
|
|
596
|
+
import { ObservableV2 } from 'lib0/observable';
|
|
519
597
|
import * as s from 'lib0/schema';
|
|
598
|
+
import * as traits from 'lib0/traits';
|
|
520
599
|
import { ContentType } from './structs/Item.js';
|
|
521
600
|
import { ContentString } from './structs/Item.js';
|
|
522
601
|
import { ContentJSON } from './structs/Item.js';
|
package/dist/src/ytype.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ytype.d.ts","sourceRoot":"","sources":["../../src/ytype.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ytype.d.ts","sourceRoot":"","sources":["../../src/ytype.js"],"names":[],"mappings":"AA6CO,4CAAiH;AAWjH,6DALI,KAAK,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,OAAC,WAC7B,OAAO,GACN,WAAW,GAAC,SAAS,CAiChC;AAWD;IACE;;;;;;OAMG;IACH,kBANW,IAAI,GAAC,IAAI,SACT,IAAI,GAAC,IAAI,SACT,MAAM,kBACN,GAAG,CAAC,MAAM,EAAC,GAAG,CAAC,YACf,gBAAgB,EAQ1B;IALC,kBAAgB;IAChB,mBAAkB;IAClB,cAAkB;IAClB,iCAAoC;IACpC,iEAAwB;IAG1B;;OAEG;IACH,gBAgBC;IAED;;;;;;;OAOG;IACH,wBAPW,WAAW,UACX,KAAK,UACL,MAAM;;aA4EhB;CACF;AAqHM,2CATI,WAAW,UACX,KAAK,WACL,oBAAoB,WACpB,OAAO,mBAAmB,EAAE,eAAe;;SA0BrD;AASM,iDANI,WAAW,UACX,KAAK,WACL,oBAAoB,UACpB,KAAK,CAAC,GAAG,CAAC,GAAC,MAAM;;SA0B3B;AAWM,wCARI,WAAW,WACX,oBAAoB,UACpB,MAAM,GACL,oBAAoB,CAkD/B;AAED;IACE;;;OAGG;IACH,eAHW,IAAI,SACJ,MAAM,EAOhB;IAHC,QAAU;IACV,cAAkB;IAClB,kBAA8C;CAEjD;AAqDM,mCAHI,KAAK,SACL,MAAM,4BAgDhB;AAWM,kDAJI,KAAK,CAAC,iBAAiB,CAAC,SACxB,MAAM,OACN,MAAM,QAiChB;AAQM,mCAHI,KAAK,GACJ,KAAK,CAAC,IAAI,CAAC,CAWtB;AAUM,wCAJI,KAAK,eACL,WAAW,SACV,MAAM,CAAC,GAAG,CAAC,QActB;AAED;;;;;;;;;;;;;;GAcG;AACH,mBAHgC,KAAK,SAAvB,KAAK,CAAC,SAAU;WACK,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,C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,mBAAmB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@y/y",
|
|
3
|
-
"version": "14.0.0-rc.
|
|
3
|
+
"version": "14.0.0-rc.22",
|
|
4
4
|
"description": "Shared Editing Library",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
},
|
|
72
72
|
"homepage": "https://docs.yjs.dev",
|
|
73
73
|
"dependencies": {
|
|
74
|
-
"lib0": "^1.0.0-rc.
|
|
74
|
+
"lib0": "^1.0.0-rc.20"
|
|
75
75
|
},
|
|
76
76
|
"devDependencies": {
|
|
77
77
|
"@types/node": "^22.14.1",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"@y/y": ".",
|
|
80
80
|
"dpdm": "^4.0.1",
|
|
81
81
|
"markdownlint": "^0.40.0",
|
|
82
|
-
"markdownlint-cli": "^0.
|
|
82
|
+
"markdownlint-cli": "^0.49.0",
|
|
83
83
|
"standard": "^17.1.2",
|
|
84
84
|
"typescript": "^5.9.3"
|
|
85
85
|
},
|
package/src/utils/Doc.js
CHANGED
|
@@ -226,6 +226,9 @@ export class Doc extends ObservableV2 {
|
|
|
226
226
|
*/
|
|
227
227
|
destroy () {
|
|
228
228
|
this.isDestroyed = true
|
|
229
|
+
// Tear down the top-level shared types as RDTs (emits their `'destroy'` event so any bindings
|
|
230
|
+
// unsubscribe). Only top-level types are destroyed here; nested child types are not recursed.
|
|
231
|
+
this.share.forEach(type => type.destroy())
|
|
229
232
|
array.from(this.subdocs).forEach(subdoc => subdoc.destroy())
|
|
230
233
|
const item = this._item
|
|
231
234
|
if (item !== null) {
|
package/src/utils/Transaction.js
CHANGED
|
@@ -12,7 +12,7 @@ import { GC } from '../structs/GC.js'
|
|
|
12
12
|
import { YEvent } from './YEvent.js'
|
|
13
13
|
import { writeUpdateMessageFromTransaction } from './encoding-helpers.js'
|
|
14
14
|
import { UpdateEncoderV1, UpdateEncoderV2 } from './UpdateEncoder.js'
|
|
15
|
-
import { findIndexSS,
|
|
15
|
+
import { findIndexSS, updateCurrentFormats, cleanupFormattingGap, tryGcDeleteSet, tryMerge, tryToMergeWithLefts, cleanupContextlessFormattingGap } from './transaction-helpers.js'
|
|
16
16
|
import * as random from 'lib0/random'
|
|
17
17
|
|
|
18
18
|
export const generateNewClientId = random.uint53
|
|
@@ -168,14 +168,14 @@ export class Transaction {
|
|
|
168
168
|
/**
|
|
169
169
|
* This function is experimental and subject to change / be removed.
|
|
170
170
|
*
|
|
171
|
-
* Ideally, we don't need this function at all.
|
|
171
|
+
* Ideally, we don't need this function at all. Formats should be cleaned up
|
|
172
172
|
* automatically after each change. This function iterates twice over the complete YText type
|
|
173
|
-
* and removes unnecessary
|
|
173
|
+
* and removes unnecessary formats. This is also helpful for testing.
|
|
174
174
|
*
|
|
175
175
|
* This function won't be exported anymore as soon as there is confidence that the YText type works as intended.
|
|
176
176
|
*
|
|
177
177
|
* @param {YType} type
|
|
178
|
-
* @return {number} How many
|
|
178
|
+
* @return {number} How many formats have been cleaned up.
|
|
179
179
|
*/
|
|
180
180
|
export const cleanupYTextFormatting = type => {
|
|
181
181
|
if (!type.doc?.cleanupFormatting) return 0
|
|
@@ -183,17 +183,17 @@ export const cleanupYTextFormatting = type => {
|
|
|
183
183
|
transact(/** @type {Doc} */ (type.doc), transaction => {
|
|
184
184
|
let start = /** @type {Item} */ (type._start)
|
|
185
185
|
let end = type._start
|
|
186
|
-
let
|
|
187
|
-
const
|
|
186
|
+
let startFormats = map.create()
|
|
187
|
+
const currentFormats = map.copy(startFormats)
|
|
188
188
|
while (end) {
|
|
189
189
|
if (end.deleted === false) {
|
|
190
190
|
switch (end.content.constructor) {
|
|
191
191
|
case ContentFormat:
|
|
192
|
-
|
|
192
|
+
updateCurrentFormats(currentFormats, /** @type {ContentFormat} */ (end.content))
|
|
193
193
|
break
|
|
194
194
|
default:
|
|
195
|
-
res += cleanupFormattingGap(transaction, start, end,
|
|
196
|
-
|
|
195
|
+
res += cleanupFormattingGap(transaction, start, end, startFormats, currentFormats)
|
|
196
|
+
startFormats = map.copy(currentFormats)
|
|
197
197
|
start = end
|
|
198
198
|
break
|
|
199
199
|
}
|
|
@@ -236,17 +236,29 @@ const cleanupTransactions = (transactionCleanups, i) => {
|
|
|
236
236
|
})
|
|
237
237
|
)
|
|
238
238
|
fs.push(() => {
|
|
239
|
-
// deep observe events
|
|
239
|
+
// deep observe events + the RDT `'delta'` channel. `changedParentTypes` holds the changed
|
|
240
|
+
// type AND all of its ancestors, so both `observeDeep` and `'delta'` bubble identically.
|
|
240
241
|
transaction.changedParentTypes.forEach((events, type) => {
|
|
241
242
|
// We need to think about the possibility that the user transforms the
|
|
242
243
|
// Y.Doc in the event.
|
|
243
|
-
if (type.
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
244
|
+
if (type._item !== null && type._item.deleted) return
|
|
245
|
+
const hasDeep = type._dEH.l.length > 0
|
|
246
|
+
const hasDeltaListeners = (type._observers.get('delta')?.size ?? 0) > 0
|
|
247
|
+
const maintaining = type._delta !== null
|
|
248
|
+
if (!hasDeep && !hasDeltaListeners && !maintaining) return
|
|
249
|
+
/**
|
|
250
|
+
* @type {YEvent<any>}
|
|
251
|
+
*/
|
|
252
|
+
const deepEventHandler = events.find(event => event.target === type) || new YEvent(type, transaction, new Set(null))
|
|
253
|
+
if (hasDeep) {
|
|
248
254
|
callEventHandlerListeners(type._dEH, deepEventHandler, transaction)
|
|
249
255
|
}
|
|
256
|
+
if (hasDeltaListeners || maintaining) {
|
|
257
|
+
// the type-rooted deep delta of this transaction (a nested `modify` chain for ancestors)
|
|
258
|
+
const change = /** @type {any} */ (deepEventHandler.getDelta({ renderer: type._renderer, deep: true }).done())
|
|
259
|
+
type._delta?.apply(change) // keep the cache current (incl. ancestors and diff-renderer attributions)
|
|
260
|
+
if (hasDeltaListeners) type.emit('delta', [change, transaction.origin])
|
|
261
|
+
}
|
|
250
262
|
})
|
|
251
263
|
})
|
|
252
264
|
fs.push(() => doc.emit('afterTransaction', [transaction, doc]))
|
|
@@ -334,7 +346,7 @@ const cleanupTransactions = (transactionCleanups, i) => {
|
|
|
334
346
|
|
|
335
347
|
/**
|
|
336
348
|
* This will be called by the transaction once the event handlers are called to potentially cleanup
|
|
337
|
-
*
|
|
349
|
+
* formats.
|
|
338
350
|
*
|
|
339
351
|
* @param {Transaction} transaction
|
|
340
352
|
*/
|
|
@@ -362,14 +374,14 @@ export const cleanupYTextAfterTransaction = transaction => {
|
|
|
362
374
|
if (item.content.constructor === ContentFormat) {
|
|
363
375
|
needFullCleanup.add(parent)
|
|
364
376
|
} else {
|
|
365
|
-
// If no
|
|
377
|
+
// If no format was inserted or deleted, we can make due with contextless
|
|
366
378
|
// formatting cleanups.
|
|
367
|
-
// Contextless: it is not necessary to compute
|
|
379
|
+
// Contextless: it is not necessary to compute currentFormats for the affected position.
|
|
368
380
|
cleanupContextlessFormattingGap(t, item)
|
|
369
381
|
}
|
|
370
382
|
})
|
|
371
383
|
// If a formatting item was inserted, we simply clean the whole type.
|
|
372
|
-
// We need to compute
|
|
384
|
+
// We need to compute currentFormats for the current position anyway.
|
|
373
385
|
for (const yText of needFullCleanup) {
|
|
374
386
|
cleanupYTextFormatting(yText)
|
|
375
387
|
}
|
package/src/utils/YEvent.js
CHANGED
|
@@ -86,13 +86,13 @@ export class YEvent {
|
|
|
86
86
|
/**
|
|
87
87
|
* @template {boolean} [Deep=false]
|
|
88
88
|
* @param {object} [opts]
|
|
89
|
-
* @param {AbstractRenderer} [opts.renderer] - renders the content (with attributions); defaults to `baseRenderer`
|
|
89
|
+
* @param {AbstractRenderer} [opts.renderer] - renders the content (with attributions); defaults to the target type's active renderer (see {@link YType#useRenderer}), i.e. `baseRenderer` unless changed
|
|
90
90
|
* @param {Deep} [opts.deep]
|
|
91
91
|
* @return {Deep extends true ? Delta<DConf> : Delta<import('../ytype.js').DeltaConfDeltaToYType<DConf>>} The Delta representation of this type.
|
|
92
92
|
*
|
|
93
93
|
* @public
|
|
94
94
|
*/
|
|
95
|
-
getDelta ({ renderer =
|
|
95
|
+
getDelta ({ renderer = this.target._renderer, deep } = {}) {
|
|
96
96
|
const itemsToRender = mergeIdSets([diffIdSet(this.transaction.insertSet, this.transaction.deleteSet), diffIdSet(this.transaction.deleteSet, this.transaction.insertSet)])
|
|
97
97
|
/**
|
|
98
98
|
* @todo this should be done only one in the transaction step
|
|
@@ -334,17 +334,17 @@ export const cleanupContextlessFormattingGap = (transaction, item) => {
|
|
|
334
334
|
}
|
|
335
335
|
|
|
336
336
|
/**
|
|
337
|
-
* @param {Map<string,any>}
|
|
337
|
+
* @param {Map<string,any>} currentFormats
|
|
338
338
|
* @param {ContentFormat} format
|
|
339
339
|
*
|
|
340
340
|
* @private
|
|
341
341
|
* @function
|
|
342
342
|
*/
|
|
343
|
-
export const
|
|
343
|
+
export const updateCurrentFormats = (currentFormats, { key, value }) => {
|
|
344
344
|
if (value === null) {
|
|
345
|
-
|
|
345
|
+
currentFormats.delete(key)
|
|
346
346
|
} else {
|
|
347
|
-
|
|
347
|
+
currentFormats.set(key, value)
|
|
348
348
|
}
|
|
349
349
|
}
|
|
350
350
|
|
|
@@ -355,13 +355,13 @@ export const updateCurrentAttributes = (currentAttributes, { key, value }) => {
|
|
|
355
355
|
* @param {Transaction} transaction
|
|
356
356
|
* @param {Item} start
|
|
357
357
|
* @param {Item|null} curr exclusive end, automatically iterates to the next Content Item
|
|
358
|
-
* @param {Map<string,any>}
|
|
359
|
-
* @param {Map<string,any>}
|
|
358
|
+
* @param {Map<string,any>} startFormats
|
|
359
|
+
* @param {Map<string,any>} currFormats
|
|
360
360
|
* @return {number} The amount of formatting Items deleted.
|
|
361
361
|
*
|
|
362
362
|
* @function
|
|
363
363
|
*/
|
|
364
|
-
export const cleanupFormattingGap = (transaction, start, curr,
|
|
364
|
+
export const cleanupFormattingGap = (transaction, start, curr, startFormats, currFormats) => {
|
|
365
365
|
if (!transaction.doc.cleanupFormatting) return 0
|
|
366
366
|
/**
|
|
367
367
|
* @type {Item|null}
|
|
@@ -388,22 +388,22 @@ export const cleanupFormattingGap = (transaction, start, curr, startAttributes,
|
|
|
388
388
|
const content = start.content
|
|
389
389
|
if (content.getRef() === 6) { // is ContentFormat
|
|
390
390
|
const { key, value } = /** @type {ContentFormat} */ (content)
|
|
391
|
-
const
|
|
392
|
-
if (endFormats.get(key) !== content ||
|
|
393
|
-
// Either this format is overwritten or it is not necessary because the
|
|
391
|
+
const startFormatValue = startFormats.get(key) ?? null
|
|
392
|
+
if (endFormats.get(key) !== content || startFormatValue === value) {
|
|
393
|
+
// Either this format is overwritten or it is not necessary because the format already existed.
|
|
394
394
|
start.delete(transaction)
|
|
395
395
|
transaction.cleanUps.add(start.id.client, start.id.clock, start.length)
|
|
396
396
|
cleanups++
|
|
397
|
-
if (!reachedCurr && (
|
|
398
|
-
if (
|
|
399
|
-
|
|
397
|
+
if (!reachedCurr && (currFormats.get(key) ?? null) === value && startFormatValue !== value) {
|
|
398
|
+
if (startFormatValue === null) {
|
|
399
|
+
currFormats.delete(key)
|
|
400
400
|
} else {
|
|
401
|
-
|
|
401
|
+
currFormats.set(key, startFormatValue)
|
|
402
402
|
}
|
|
403
403
|
}
|
|
404
404
|
}
|
|
405
405
|
if (!reachedCurr && !start.deleted) {
|
|
406
|
-
|
|
406
|
+
updateCurrentFormats(currFormats, /** @type {ContentFormat} */ (content))
|
|
407
407
|
}
|
|
408
408
|
}
|
|
409
409
|
}
|