loro-crdt 1.4.5 → 1.5.0
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/CHANGELOG.md +160 -0
- package/base64/index.d.ts +52 -2
- package/base64/index.js +376 -26
- package/base64/loro_wasm.d.ts +239 -5
- package/base64/loro_wasm_bg-536e230f.js +64 -0
- package/bundler/index.d.ts +52 -2
- package/bundler/index.js +92 -3
- package/bundler/index.js.map +1 -1
- package/bundler/loro_wasm.d.ts +239 -5
- package/bundler/loro_wasm_bg.js +281 -22
- package/bundler/loro_wasm_bg.wasm +0 -0
- package/bundler/loro_wasm_bg.wasm.d.ts +20 -0
- package/nodejs/index.d.ts +52 -2
- package/nodejs/index.js +92 -1
- package/nodejs/index.js.map +1 -1
- package/nodejs/loro_wasm.d.ts +239 -5
- package/nodejs/loro_wasm.js +283 -22
- package/nodejs/loro_wasm_bg.wasm +0 -0
- package/nodejs/loro_wasm_bg.wasm.d.ts +20 -0
- package/package.json +1 -1
- package/web/index.d.ts +52 -2
- package/web/index.js +92 -3
- package/web/index.js.map +1 -1
- package/web/loro_wasm.d.ts +259 -5
- package/web/loro_wasm.js +278 -20
- package/web/loro_wasm_bg.wasm +0 -0
- package/web/loro_wasm_bg.wasm.d.ts +20 -0
- package/base64/loro_wasm_bg-2fc402da.js +0 -64
package/nodejs/loro_wasm.d.ts
CHANGED
|
@@ -161,6 +161,126 @@ interface LoroDoc {
|
|
|
161
161
|
*/
|
|
162
162
|
subscribeLocalUpdates(f: (bytes: Uint8Array) => void): () => void
|
|
163
163
|
|
|
164
|
+
/**
|
|
165
|
+
* Subscribe to the first commit from a peer. Operations performed on the `LoroDoc` within this callback
|
|
166
|
+
* will be merged into the current commit.
|
|
167
|
+
*
|
|
168
|
+
* This is useful for managing the relationship between `PeerID` and user information.
|
|
169
|
+
* For example, you could store user names in a `LoroMap` using `PeerID` as the key and the `UserID` as the value.
|
|
170
|
+
*
|
|
171
|
+
* @param f - A callback function that receives a peer id.
|
|
172
|
+
*
|
|
173
|
+
* @example
|
|
174
|
+
* ```ts
|
|
175
|
+
* const doc = new LoroDoc();
|
|
176
|
+
* doc.setPeerId(0);
|
|
177
|
+
* const p = [];
|
|
178
|
+
* doc.subscribeFirstCommitFromPeer((peer) => {
|
|
179
|
+
* p.push(peer);
|
|
180
|
+
* doc.getMap("map").set(e.peer, "user-" + e.peer);
|
|
181
|
+
* });
|
|
182
|
+
* doc.getList("list").insert(0, 100);
|
|
183
|
+
* doc.commit();
|
|
184
|
+
* doc.getList("list").insert(0, 200);
|
|
185
|
+
* doc.commit();
|
|
186
|
+
* doc.setPeerId(1);
|
|
187
|
+
* doc.getList("list").insert(0, 300);
|
|
188
|
+
* doc.commit();
|
|
189
|
+
* expect(p).toEqual(["0", "1"]);
|
|
190
|
+
* expect(doc.getMap("map").get("0")).toBe("user-0");
|
|
191
|
+
* ```
|
|
192
|
+
**/
|
|
193
|
+
subscribeFirstCommitFromPeer(f: (e: { peer: PeerID }) => void): () => void
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Subscribe to the pre-commit event.
|
|
197
|
+
*
|
|
198
|
+
* The callback will be called when the changes are committed but not yet applied to the OpLog.
|
|
199
|
+
* You can modify the commit message and timestamp in the callback by `ChangeModifier`.
|
|
200
|
+
*
|
|
201
|
+
* @example
|
|
202
|
+
* ```ts
|
|
203
|
+
* const doc = new LoroDoc();
|
|
204
|
+
* doc.subscribePreCommit((e) => {
|
|
205
|
+
* e.modifier.setMessage("test").setTimestamp(Date.now());
|
|
206
|
+
* });
|
|
207
|
+
* doc.getList("list").insert(0, 100);
|
|
208
|
+
* doc.commit();
|
|
209
|
+
* expect(doc.getChangeAt({ peer: "0", counter: 0 }).message).toBe("test");
|
|
210
|
+
* ```
|
|
211
|
+
*
|
|
212
|
+
* ### Advanced Example: Creating a Merkle DAG
|
|
213
|
+
*
|
|
214
|
+
* By combining `doc.subscribePreCommit` with `doc.exportJsonInIdSpan`, you can implement advanced features like representing Loro's editing history as a Merkle DAG:
|
|
215
|
+
*
|
|
216
|
+
* ```ts
|
|
217
|
+
* const doc = new LoroDoc();
|
|
218
|
+
* doc.setPeerId(0);
|
|
219
|
+
* doc.subscribePreCommit((e) => {
|
|
220
|
+
* const changes = doc.exportJsonInIdSpan(e.changeMeta)
|
|
221
|
+
* expect(changes).toHaveLength(1);
|
|
222
|
+
* const hash = crypto.createHash('sha256');
|
|
223
|
+
* const change = {
|
|
224
|
+
* ...changes[0],
|
|
225
|
+
* deps: changes[0].deps.map(d => {
|
|
226
|
+
* const depChange = doc.getChangeAt(idStrToId(d))
|
|
227
|
+
* return depChange.message;
|
|
228
|
+
* })
|
|
229
|
+
* }
|
|
230
|
+
* console.log(change); // The output is shown below
|
|
231
|
+
* hash.update(JSON.stringify(change));
|
|
232
|
+
* const sha256Hash = hash.digest('hex');
|
|
233
|
+
* e.modifier.setMessage(sha256Hash);
|
|
234
|
+
* });
|
|
235
|
+
*
|
|
236
|
+
* doc.getList("list").insert(0, 100);
|
|
237
|
+
* doc.commit();
|
|
238
|
+
* // Change 0
|
|
239
|
+
* // {
|
|
240
|
+
* // id: '0@0',
|
|
241
|
+
* // timestamp: 0,
|
|
242
|
+
* // deps: [],
|
|
243
|
+
* // lamport: 0,
|
|
244
|
+
* // msg: undefined,
|
|
245
|
+
* // ops: [
|
|
246
|
+
* // {
|
|
247
|
+
* // container: 'cid:root-list:List',
|
|
248
|
+
* // content: { type: 'insert', pos: 0, value: [100] },
|
|
249
|
+
* // counter: 0
|
|
250
|
+
* // }
|
|
251
|
+
* // ]
|
|
252
|
+
* // }
|
|
253
|
+
*
|
|
254
|
+
*
|
|
255
|
+
* doc.getList("list").insert(0, 200);
|
|
256
|
+
* doc.commit();
|
|
257
|
+
* // Change 1
|
|
258
|
+
* // {
|
|
259
|
+
* // id: '1@0',
|
|
260
|
+
* // timestamp: 0,
|
|
261
|
+
* // deps: [
|
|
262
|
+
* // '2af99cf93869173984bcf6b1ce5412610b0413d027a5511a8f720a02a4432853'
|
|
263
|
+
* // ],
|
|
264
|
+
* // lamport: 1,
|
|
265
|
+
* // msg: undefined,
|
|
266
|
+
* // ops: [
|
|
267
|
+
* // {
|
|
268
|
+
* // container: 'cid:root-list:List',
|
|
269
|
+
* // content: { type: 'insert', pos: 0, value: [200] },
|
|
270
|
+
* // counter: 1
|
|
271
|
+
* // }
|
|
272
|
+
* // ]
|
|
273
|
+
* // }
|
|
274
|
+
*
|
|
275
|
+
* expect(doc.getChangeAt({ peer: "0", counter: 0 }).message).toBe("2af99cf93869173984bcf6b1ce5412610b0413d027a5511a8f720a02a4432853");
|
|
276
|
+
* expect(doc.getChangeAt({ peer: "0", counter: 1 }).message).toBe("aedbb442c554ecf59090e0e8339df1d8febf647f25cc37c67be0c6e27071d37f");
|
|
277
|
+
* ```
|
|
278
|
+
*
|
|
279
|
+
* @param f - A callback function that receives a pre commit event.
|
|
280
|
+
*
|
|
281
|
+
**/
|
|
282
|
+
subscribePreCommit(f: (e: { changeMeta: Change, origin: string, modifier: ChangeModifier }) => void): () => void
|
|
283
|
+
|
|
164
284
|
/**
|
|
165
285
|
* Convert the document to a JSON value with a custom replacer function.
|
|
166
286
|
*
|
|
@@ -759,7 +879,6 @@ export type AwarenessListener = (
|
|
|
759
879
|
origin: "local" | "timeout" | "remote" | string,
|
|
760
880
|
) => void;
|
|
761
881
|
|
|
762
|
-
|
|
763
882
|
interface Listener {
|
|
764
883
|
(event: LoroEventBatch): void;
|
|
765
884
|
}
|
|
@@ -856,10 +975,15 @@ interface LoroDoc<T extends Record<string, Container> = Record<string, Container
|
|
|
856
975
|
*/
|
|
857
976
|
exportJsonUpdates(start?: VersionVector, end?: VersionVector, withPeerCompression?: boolean): JsonSchema;
|
|
858
977
|
/**
|
|
859
|
-
*
|
|
978
|
+
* Exports changes within the specified ID span to JSON schema format.
|
|
860
979
|
*
|
|
861
|
-
* The
|
|
980
|
+
* The JSON schema format produced by this method is identical to the one generated by `export_json_updates`.
|
|
981
|
+
* It ensures deterministic output, making it ideal for hash calculations and integrity checks.
|
|
862
982
|
*
|
|
983
|
+
* This method can also export pending changes from the uncommitted transaction that have not yet been applied to the OpLog.
|
|
984
|
+
*
|
|
985
|
+
* This method will NOT trigger a new commit implicitly.
|
|
986
|
+
*
|
|
863
987
|
* @param idSpan - The id span to export.
|
|
864
988
|
* @returns The changes in the given id span.
|
|
865
989
|
*/
|
|
@@ -1274,6 +1398,25 @@ interface AwarenessWasm<T extends Value = Value> {
|
|
|
1274
1398
|
removeOutdated(): PeerID[];
|
|
1275
1399
|
}
|
|
1276
1400
|
|
|
1401
|
+
type EphemeralListener = (event: EphemeralStoreEvent) => void;
|
|
1402
|
+
type EphemeralLocalListener = (bytes: Uint8Array) => void;
|
|
1403
|
+
|
|
1404
|
+
interface EphemeralStoreWasm<T extends Value = Value> {
|
|
1405
|
+
set(key: string, value: T): void;
|
|
1406
|
+
get(key: string): T | undefined;
|
|
1407
|
+
getAllStates(): Record<string, T>;
|
|
1408
|
+
removeOutdated();
|
|
1409
|
+
subscribeLocalUpdates(f: EphemeralLocalListener): () => void;
|
|
1410
|
+
subscribe(f: EphemeralListener): () => void;
|
|
1411
|
+
}
|
|
1412
|
+
|
|
1413
|
+
interface EphemeralStoreEvent {
|
|
1414
|
+
by: "local" | "import" | "timeout";
|
|
1415
|
+
added: string[];
|
|
1416
|
+
updated: string[];
|
|
1417
|
+
removed: string[];
|
|
1418
|
+
}
|
|
1419
|
+
|
|
1277
1420
|
|
|
1278
1421
|
|
|
1279
1422
|
/**
|
|
@@ -1349,6 +1492,21 @@ export class AwarenessWasm {
|
|
|
1349
1492
|
peers(): (PeerID)[];
|
|
1350
1493
|
}
|
|
1351
1494
|
/**
|
|
1495
|
+
*/
|
|
1496
|
+
export class ChangeModifier {
|
|
1497
|
+
free(): void;
|
|
1498
|
+
/**
|
|
1499
|
+
* @param {string} message
|
|
1500
|
+
* @returns {ChangeModifier}
|
|
1501
|
+
*/
|
|
1502
|
+
setMessage(message: string): ChangeModifier;
|
|
1503
|
+
/**
|
|
1504
|
+
* @param {number} timestamp
|
|
1505
|
+
* @returns {ChangeModifier}
|
|
1506
|
+
*/
|
|
1507
|
+
setTimestamp(timestamp: number): ChangeModifier;
|
|
1508
|
+
}
|
|
1509
|
+
/**
|
|
1352
1510
|
* Cursor is a stable position representation in the doc.
|
|
1353
1511
|
* When expressing the position of a cursor, using "index" can be unstable
|
|
1354
1512
|
* because the cursor's position may change due to other deletions and insertions,
|
|
@@ -1418,6 +1576,63 @@ export class Cursor {
|
|
|
1418
1576
|
kind(): any;
|
|
1419
1577
|
}
|
|
1420
1578
|
/**
|
|
1579
|
+
*/
|
|
1580
|
+
export class EphemeralStoreWasm {
|
|
1581
|
+
free(): void;
|
|
1582
|
+
/**
|
|
1583
|
+
* Creates a new `EphemeralStore` instance.
|
|
1584
|
+
*
|
|
1585
|
+
* The `timeout` parameter specifies the duration in milliseconds.
|
|
1586
|
+
* A state of a peer is considered outdated, if the last update of the state of the peer
|
|
1587
|
+
* is older than the `timeout`.
|
|
1588
|
+
* @param {number} timeout
|
|
1589
|
+
*/
|
|
1590
|
+
constructor(timeout: number);
|
|
1591
|
+
/**
|
|
1592
|
+
* @param {string} key
|
|
1593
|
+
* @param {any} value
|
|
1594
|
+
*/
|
|
1595
|
+
set(key: string, value: any): void;
|
|
1596
|
+
/**
|
|
1597
|
+
* @param {string} key
|
|
1598
|
+
*/
|
|
1599
|
+
delete(key: string): void;
|
|
1600
|
+
/**
|
|
1601
|
+
* @param {string} key
|
|
1602
|
+
* @returns {any}
|
|
1603
|
+
*/
|
|
1604
|
+
get(key: string): any;
|
|
1605
|
+
/**
|
|
1606
|
+
* @returns {any}
|
|
1607
|
+
*/
|
|
1608
|
+
getAllStates(): any;
|
|
1609
|
+
/**
|
|
1610
|
+
* @param {string} key
|
|
1611
|
+
* @returns {Uint8Array}
|
|
1612
|
+
*/
|
|
1613
|
+
encode(key: string): Uint8Array;
|
|
1614
|
+
/**
|
|
1615
|
+
* @returns {Uint8Array}
|
|
1616
|
+
*/
|
|
1617
|
+
encodeAll(): Uint8Array;
|
|
1618
|
+
/**
|
|
1619
|
+
* @param {Uint8Array} data
|
|
1620
|
+
*/
|
|
1621
|
+
apply(data: Uint8Array): void;
|
|
1622
|
+
/**
|
|
1623
|
+
*/
|
|
1624
|
+
removeOutdated(): void;
|
|
1625
|
+
/**
|
|
1626
|
+
* If the state is empty.
|
|
1627
|
+
* @returns {boolean}
|
|
1628
|
+
*/
|
|
1629
|
+
isEmpty(): boolean;
|
|
1630
|
+
/**
|
|
1631
|
+
* @returns {(string)[]}
|
|
1632
|
+
*/
|
|
1633
|
+
keys(): (string)[];
|
|
1634
|
+
}
|
|
1635
|
+
/**
|
|
1421
1636
|
* The handler of a counter container.
|
|
1422
1637
|
*/
|
|
1423
1638
|
export class LoroCounter {
|
|
@@ -2443,6 +2658,27 @@ export class LoroDoc {
|
|
|
2443
2658
|
*/
|
|
2444
2659
|
applyDiff(diff: [ContainerID, Diff|JsonDiff][]): void;
|
|
2445
2660
|
/**
|
|
2661
|
+
* Get the pending operations from the current transaction in JSON format
|
|
2662
|
+
*
|
|
2663
|
+
* This method returns a JSON representation of operations that have been applied
|
|
2664
|
+
* but not yet committed in the current transaction.
|
|
2665
|
+
*
|
|
2666
|
+
* It will use the same data format as `doc.exportJsonUpdates()`
|
|
2667
|
+
*
|
|
2668
|
+
* @example
|
|
2669
|
+
* ```ts
|
|
2670
|
+
* const doc = new LoroDoc();
|
|
2671
|
+
* const text = doc.getText("text");
|
|
2672
|
+
* text.insert(0, "Hello");
|
|
2673
|
+
* // Get pending ops before commit
|
|
2674
|
+
* const pendingOps = doc.getPendingOpsFromCurrentTxnAsJson();
|
|
2675
|
+
* doc.commit();
|
|
2676
|
+
* const emptyOps = doc.getPendingOpsFromCurrentTxnAsJson(); // this is undefined
|
|
2677
|
+
* ```
|
|
2678
|
+
* @returns {JsonSchema | undefined}
|
|
2679
|
+
*/
|
|
2680
|
+
getUncommittedOpsAsJson(): JsonSchema | undefined;
|
|
2681
|
+
/**
|
|
2446
2682
|
* Peer ID of the current writer.
|
|
2447
2683
|
*/
|
|
2448
2684
|
readonly peerId: bigint;
|
|
@@ -3104,8 +3340,6 @@ export class LoroText {
|
|
|
3104
3340
|
*
|
|
3105
3341
|
* You can use it to create a highlight, make a range of text bold, or add a link to a range of text.
|
|
3106
3342
|
*
|
|
3107
|
-
* Note: this is not suitable for unmergeable annotations like comments.
|
|
3108
|
-
*
|
|
3109
3343
|
* @example
|
|
3110
3344
|
* ```ts
|
|
3111
3345
|
* import { LoroDoc } from "loro-crdt";
|
package/nodejs/loro_wasm.js
CHANGED
|
@@ -617,6 +617,53 @@ class AwarenessWasm {
|
|
|
617
617
|
}
|
|
618
618
|
module.exports.AwarenessWasm = AwarenessWasm;
|
|
619
619
|
|
|
620
|
+
const ChangeModifierFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
621
|
+
? { register: () => {}, unregister: () => {} }
|
|
622
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_changemodifier_free(ptr >>> 0));
|
|
623
|
+
/**
|
|
624
|
+
*/
|
|
625
|
+
class ChangeModifier {
|
|
626
|
+
|
|
627
|
+
static __wrap(ptr) {
|
|
628
|
+
ptr = ptr >>> 0;
|
|
629
|
+
const obj = Object.create(ChangeModifier.prototype);
|
|
630
|
+
obj.__wbg_ptr = ptr;
|
|
631
|
+
ChangeModifierFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
632
|
+
return obj;
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
__destroy_into_raw() {
|
|
636
|
+
const ptr = this.__wbg_ptr;
|
|
637
|
+
this.__wbg_ptr = 0;
|
|
638
|
+
ChangeModifierFinalization.unregister(this);
|
|
639
|
+
return ptr;
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
free() {
|
|
643
|
+
const ptr = this.__destroy_into_raw();
|
|
644
|
+
wasm.__wbg_changemodifier_free(ptr);
|
|
645
|
+
}
|
|
646
|
+
/**
|
|
647
|
+
* @param {string} message
|
|
648
|
+
* @returns {ChangeModifier}
|
|
649
|
+
*/
|
|
650
|
+
setMessage(message) {
|
|
651
|
+
const ptr0 = passStringToWasm0(message, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
652
|
+
const len0 = WASM_VECTOR_LEN;
|
|
653
|
+
const ret = wasm.changemodifier_setMessage(this.__wbg_ptr, ptr0, len0);
|
|
654
|
+
return ChangeModifier.__wrap(ret);
|
|
655
|
+
}
|
|
656
|
+
/**
|
|
657
|
+
* @param {number} timestamp
|
|
658
|
+
* @returns {ChangeModifier}
|
|
659
|
+
*/
|
|
660
|
+
setTimestamp(timestamp) {
|
|
661
|
+
const ret = wasm.changemodifier_setTimestamp(this.__wbg_ptr, timestamp);
|
|
662
|
+
return ChangeModifier.__wrap(ret);
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
module.exports.ChangeModifier = ChangeModifier;
|
|
666
|
+
|
|
620
667
|
const CursorFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
621
668
|
? { register: () => {}, unregister: () => {} }
|
|
622
669
|
: new FinalizationRegistry(ptr => wasm.__wbg_cursor_free(ptr >>> 0));
|
|
@@ -750,6 +797,162 @@ class Cursor {
|
|
|
750
797
|
}
|
|
751
798
|
module.exports.Cursor = Cursor;
|
|
752
799
|
|
|
800
|
+
const EphemeralStoreWasmFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
801
|
+
? { register: () => {}, unregister: () => {} }
|
|
802
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_ephemeralstorewasm_free(ptr >>> 0));
|
|
803
|
+
/**
|
|
804
|
+
*/
|
|
805
|
+
class EphemeralStoreWasm {
|
|
806
|
+
|
|
807
|
+
__destroy_into_raw() {
|
|
808
|
+
const ptr = this.__wbg_ptr;
|
|
809
|
+
this.__wbg_ptr = 0;
|
|
810
|
+
EphemeralStoreWasmFinalization.unregister(this);
|
|
811
|
+
return ptr;
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
free() {
|
|
815
|
+
const ptr = this.__destroy_into_raw();
|
|
816
|
+
wasm.__wbg_ephemeralstorewasm_free(ptr);
|
|
817
|
+
}
|
|
818
|
+
/**
|
|
819
|
+
* Creates a new `EphemeralStore` instance.
|
|
820
|
+
*
|
|
821
|
+
* The `timeout` parameter specifies the duration in milliseconds.
|
|
822
|
+
* A state of a peer is considered outdated, if the last update of the state of the peer
|
|
823
|
+
* is older than the `timeout`.
|
|
824
|
+
* @param {number} timeout
|
|
825
|
+
*/
|
|
826
|
+
constructor(timeout) {
|
|
827
|
+
const ret = wasm.ephemeralstorewasm_new(timeout);
|
|
828
|
+
this.__wbg_ptr = ret >>> 0;
|
|
829
|
+
return this;
|
|
830
|
+
}
|
|
831
|
+
/**
|
|
832
|
+
* @param {string} key
|
|
833
|
+
* @param {any} value
|
|
834
|
+
*/
|
|
835
|
+
set(key, value) {
|
|
836
|
+
const ptr0 = passStringToWasm0(key, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
837
|
+
const len0 = WASM_VECTOR_LEN;
|
|
838
|
+
wasm.ephemeralstorewasm_set(this.__wbg_ptr, ptr0, len0, addHeapObject(value));
|
|
839
|
+
}
|
|
840
|
+
/**
|
|
841
|
+
* @param {string} key
|
|
842
|
+
*/
|
|
843
|
+
delete(key) {
|
|
844
|
+
const ptr0 = passStringToWasm0(key, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
845
|
+
const len0 = WASM_VECTOR_LEN;
|
|
846
|
+
wasm.ephemeralstorewasm_delete(this.__wbg_ptr, ptr0, len0);
|
|
847
|
+
}
|
|
848
|
+
/**
|
|
849
|
+
* @param {string} key
|
|
850
|
+
* @returns {any}
|
|
851
|
+
*/
|
|
852
|
+
get(key) {
|
|
853
|
+
const ptr0 = passStringToWasm0(key, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
854
|
+
const len0 = WASM_VECTOR_LEN;
|
|
855
|
+
const ret = wasm.ephemeralstorewasm_get(this.__wbg_ptr, ptr0, len0);
|
|
856
|
+
return takeObject(ret);
|
|
857
|
+
}
|
|
858
|
+
/**
|
|
859
|
+
* @returns {any}
|
|
860
|
+
*/
|
|
861
|
+
getAllStates() {
|
|
862
|
+
const ret = wasm.ephemeralstorewasm_getAllStates(this.__wbg_ptr);
|
|
863
|
+
return takeObject(ret);
|
|
864
|
+
}
|
|
865
|
+
/**
|
|
866
|
+
* @param {Function} f
|
|
867
|
+
* @returns {any}
|
|
868
|
+
*/
|
|
869
|
+
subscribeLocalUpdates(f) {
|
|
870
|
+
const ret = wasm.ephemeralstorewasm_subscribeLocalUpdates(this.__wbg_ptr, addHeapObject(f));
|
|
871
|
+
return takeObject(ret);
|
|
872
|
+
}
|
|
873
|
+
/**
|
|
874
|
+
* @param {Function} f
|
|
875
|
+
* @returns {any}
|
|
876
|
+
*/
|
|
877
|
+
subscribe(f) {
|
|
878
|
+
const ret = wasm.ephemeralstorewasm_subscribe(this.__wbg_ptr, addHeapObject(f));
|
|
879
|
+
return takeObject(ret);
|
|
880
|
+
}
|
|
881
|
+
/**
|
|
882
|
+
* @param {string} key
|
|
883
|
+
* @returns {Uint8Array}
|
|
884
|
+
*/
|
|
885
|
+
encode(key) {
|
|
886
|
+
try {
|
|
887
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
888
|
+
const ptr0 = passStringToWasm0(key, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
|
|
889
|
+
const len0 = WASM_VECTOR_LEN;
|
|
890
|
+
wasm.ephemeralstorewasm_encode(retptr, this.__wbg_ptr, ptr0, len0);
|
|
891
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
892
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
893
|
+
var v2 = getArrayU8FromWasm0(r0, r1).slice();
|
|
894
|
+
wasm.__wbindgen_export_5(r0, r1 * 1, 1);
|
|
895
|
+
return v2;
|
|
896
|
+
} finally {
|
|
897
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
/**
|
|
901
|
+
* @returns {Uint8Array}
|
|
902
|
+
*/
|
|
903
|
+
encodeAll() {
|
|
904
|
+
try {
|
|
905
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
906
|
+
wasm.ephemeralstorewasm_encodeAll(retptr, this.__wbg_ptr);
|
|
907
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
908
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
909
|
+
var v1 = getArrayU8FromWasm0(r0, r1).slice();
|
|
910
|
+
wasm.__wbindgen_export_5(r0, r1 * 1, 1);
|
|
911
|
+
return v1;
|
|
912
|
+
} finally {
|
|
913
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
/**
|
|
917
|
+
* @param {Uint8Array} data
|
|
918
|
+
*/
|
|
919
|
+
apply(data) {
|
|
920
|
+
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export_0);
|
|
921
|
+
const len0 = WASM_VECTOR_LEN;
|
|
922
|
+
wasm.ephemeralstorewasm_apply(this.__wbg_ptr, ptr0, len0);
|
|
923
|
+
}
|
|
924
|
+
/**
|
|
925
|
+
*/
|
|
926
|
+
removeOutdated() {
|
|
927
|
+
wasm.ephemeralstorewasm_removeOutdated(this.__wbg_ptr);
|
|
928
|
+
}
|
|
929
|
+
/**
|
|
930
|
+
* If the state is empty.
|
|
931
|
+
* @returns {boolean}
|
|
932
|
+
*/
|
|
933
|
+
isEmpty() {
|
|
934
|
+
const ret = wasm.ephemeralstorewasm_isEmpty(this.__wbg_ptr);
|
|
935
|
+
return ret !== 0;
|
|
936
|
+
}
|
|
937
|
+
/**
|
|
938
|
+
* @returns {(string)[]}
|
|
939
|
+
*/
|
|
940
|
+
keys() {
|
|
941
|
+
try {
|
|
942
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
943
|
+
wasm.ephemeralstorewasm_keys(retptr, this.__wbg_ptr);
|
|
944
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
945
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
946
|
+
var v1 = getArrayJsValueFromWasm0(r0, r1).slice();
|
|
947
|
+
wasm.__wbindgen_export_5(r0, r1 * 4, 4);
|
|
948
|
+
return v1;
|
|
949
|
+
} finally {
|
|
950
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
}
|
|
954
|
+
module.exports.EphemeralStoreWasm = EphemeralStoreWasm;
|
|
955
|
+
|
|
753
956
|
const LoroCounterFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
754
957
|
? { register: () => {}, unregister: () => {} }
|
|
755
958
|
: new FinalizationRegistry(ptr => wasm.__wbg_lorocounter_free(ptr >>> 0));
|
|
@@ -2803,6 +3006,61 @@ class LoroDoc {
|
|
|
2803
3006
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
2804
3007
|
}
|
|
2805
3008
|
}
|
|
3009
|
+
/**
|
|
3010
|
+
* Get the pending operations from the current transaction in JSON format
|
|
3011
|
+
*
|
|
3012
|
+
* This method returns a JSON representation of operations that have been applied
|
|
3013
|
+
* but not yet committed in the current transaction.
|
|
3014
|
+
*
|
|
3015
|
+
* It will use the same data format as `doc.exportJsonUpdates()`
|
|
3016
|
+
*
|
|
3017
|
+
* @example
|
|
3018
|
+
* ```ts
|
|
3019
|
+
* const doc = new LoroDoc();
|
|
3020
|
+
* const text = doc.getText("text");
|
|
3021
|
+
* text.insert(0, "Hello");
|
|
3022
|
+
* // Get pending ops before commit
|
|
3023
|
+
* const pendingOps = doc.getPendingOpsFromCurrentTxnAsJson();
|
|
3024
|
+
* doc.commit();
|
|
3025
|
+
* const emptyOps = doc.getPendingOpsFromCurrentTxnAsJson(); // this is undefined
|
|
3026
|
+
* ```
|
|
3027
|
+
* @returns {JsonSchema | undefined}
|
|
3028
|
+
*/
|
|
3029
|
+
getUncommittedOpsAsJson() {
|
|
3030
|
+
try {
|
|
3031
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
3032
|
+
wasm.lorodoc_getUncommittedOpsAsJson(retptr, this.__wbg_ptr);
|
|
3033
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
3034
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
3035
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
3036
|
+
if (r2) {
|
|
3037
|
+
throw takeObject(r1);
|
|
3038
|
+
}
|
|
3039
|
+
return takeObject(r0);
|
|
3040
|
+
} finally {
|
|
3041
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
3042
|
+
}
|
|
3043
|
+
}
|
|
3044
|
+
/**
|
|
3045
|
+
* @param {Function} f
|
|
3046
|
+
* @returns {any}
|
|
3047
|
+
*/
|
|
3048
|
+
subscribeFirstCommitFromPeer(f) {
|
|
3049
|
+
const ret = wasm.lorodoc_subscribeFirstCommitFromPeer(this.__wbg_ptr, addHeapObject(f));
|
|
3050
|
+
return takeObject(ret);
|
|
3051
|
+
}
|
|
3052
|
+
/**
|
|
3053
|
+
* Subscribe to the pre-commit event.
|
|
3054
|
+
*
|
|
3055
|
+
* The callback will be called when the changes are committed but not yet applied to the OpLog.
|
|
3056
|
+
* You can modify the commit message and timestamp in the callback by `ChangeModifier`.
|
|
3057
|
+
* @param {Function} f
|
|
3058
|
+
* @returns {any}
|
|
3059
|
+
*/
|
|
3060
|
+
subscribePreCommit(f) {
|
|
3061
|
+
const ret = wasm.lorodoc_subscribePreCommit(this.__wbg_ptr, addHeapObject(f));
|
|
3062
|
+
return takeObject(ret);
|
|
3063
|
+
}
|
|
2806
3064
|
}
|
|
2807
3065
|
module.exports.LoroDoc = LoroDoc;
|
|
2808
3066
|
|
|
@@ -4637,8 +4895,6 @@ class LoroText {
|
|
|
4637
4895
|
*
|
|
4638
4896
|
* You can use it to create a highlight, make a range of text bold, or add a link to a range of text.
|
|
4639
4897
|
*
|
|
4640
|
-
* Note: this is not suitable for unmergeable annotations like comments.
|
|
4641
|
-
*
|
|
4642
4898
|
* @example
|
|
4643
4899
|
* ```ts
|
|
4644
4900
|
* import { LoroDoc } from "loro-crdt";
|
|
@@ -6159,11 +6415,6 @@ module.exports.__wbg_lorocounter_new = function(arg0) {
|
|
|
6159
6415
|
return addHeapObject(ret);
|
|
6160
6416
|
};
|
|
6161
6417
|
|
|
6162
|
-
module.exports.__wbg_lorotreenode_new = function(arg0) {
|
|
6163
|
-
const ret = LoroTreeNode.__wrap(arg0);
|
|
6164
|
-
return addHeapObject(ret);
|
|
6165
|
-
};
|
|
6166
|
-
|
|
6167
6418
|
module.exports.__wbg_cursor_new = function(arg0) {
|
|
6168
6419
|
const ret = Cursor.__wrap(arg0);
|
|
6169
6420
|
return addHeapObject(ret);
|
|
@@ -6174,13 +6425,18 @@ module.exports.__wbg_loromap_new = function(arg0) {
|
|
|
6174
6425
|
return addHeapObject(ret);
|
|
6175
6426
|
};
|
|
6176
6427
|
|
|
6177
|
-
module.exports.
|
|
6178
|
-
const ret =
|
|
6428
|
+
module.exports.__wbg_lorotreenode_new = function(arg0) {
|
|
6429
|
+
const ret = LoroTreeNode.__wrap(arg0);
|
|
6179
6430
|
return addHeapObject(ret);
|
|
6180
6431
|
};
|
|
6181
6432
|
|
|
6182
|
-
module.exports.
|
|
6183
|
-
const ret =
|
|
6433
|
+
module.exports.__wbg_lorolist_new = function(arg0) {
|
|
6434
|
+
const ret = LoroList.__wrap(arg0);
|
|
6435
|
+
return addHeapObject(ret);
|
|
6436
|
+
};
|
|
6437
|
+
|
|
6438
|
+
module.exports.__wbg_lorotext_new = function(arg0) {
|
|
6439
|
+
const ret = LoroText.__wrap(arg0);
|
|
6184
6440
|
return addHeapObject(ret);
|
|
6185
6441
|
};
|
|
6186
6442
|
|
|
@@ -6189,8 +6445,8 @@ module.exports.__wbg_loromovablelist_new = function(arg0) {
|
|
|
6189
6445
|
return addHeapObject(ret);
|
|
6190
6446
|
};
|
|
6191
6447
|
|
|
6192
|
-
module.exports.
|
|
6193
|
-
const ret =
|
|
6448
|
+
module.exports.__wbg_lorotree_new = function(arg0) {
|
|
6449
|
+
const ret = LoroTree.__wrap(arg0);
|
|
6194
6450
|
return addHeapObject(ret);
|
|
6195
6451
|
};
|
|
6196
6452
|
|
|
@@ -6199,6 +6455,11 @@ module.exports.__wbg_versionvector_new = function(arg0) {
|
|
|
6199
6455
|
return addHeapObject(ret);
|
|
6200
6456
|
};
|
|
6201
6457
|
|
|
6458
|
+
module.exports.__wbg_changemodifier_new = function(arg0) {
|
|
6459
|
+
const ret = ChangeModifier.__wrap(arg0);
|
|
6460
|
+
return addHeapObject(ret);
|
|
6461
|
+
};
|
|
6462
|
+
|
|
6202
6463
|
module.exports.__wbindgen_is_function = function(arg0) {
|
|
6203
6464
|
const ret = typeof(getObject(arg0)) === 'function';
|
|
6204
6465
|
return ret;
|
|
@@ -6422,7 +6683,7 @@ module.exports.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) {
|
|
|
6422
6683
|
}
|
|
6423
6684
|
};
|
|
6424
6685
|
|
|
6425
|
-
module.exports.
|
|
6686
|
+
module.exports.__wbg_now_761faa1e2f3f9d93 = typeof Date.now == 'function' ? Date.now : notDefined('Date.now');
|
|
6426
6687
|
|
|
6427
6688
|
module.exports.__wbg_crypto_1d1f22824a6a080c = function(arg0) {
|
|
6428
6689
|
const ret = getObject(arg0).crypto;
|
|
@@ -6454,14 +6715,14 @@ module.exports.__wbg_msCrypto_eb05e62b530a1508 = function(arg0) {
|
|
|
6454
6715
|
return addHeapObject(ret);
|
|
6455
6716
|
};
|
|
6456
6717
|
|
|
6457
|
-
module.exports.__wbg_getRandomValues_3aa56aa6edec874c = function() { return handleError(function (arg0, arg1) {
|
|
6458
|
-
getObject(arg0).getRandomValues(getObject(arg1));
|
|
6459
|
-
}, arguments) };
|
|
6460
|
-
|
|
6461
6718
|
module.exports.__wbg_randomFillSync_5c9c955aa56b6049 = function() { return handleError(function (arg0, arg1) {
|
|
6462
6719
|
getObject(arg0).randomFillSync(takeObject(arg1));
|
|
6463
6720
|
}, arguments) };
|
|
6464
6721
|
|
|
6722
|
+
module.exports.__wbg_getRandomValues_3aa56aa6edec874c = function() { return handleError(function (arg0, arg1) {
|
|
6723
|
+
getObject(arg0).getRandomValues(getObject(arg1));
|
|
6724
|
+
}, arguments) };
|
|
6725
|
+
|
|
6465
6726
|
module.exports.__wbg_self_ce0dbfc45cf2f5be = function() { return handleError(function () {
|
|
6466
6727
|
const ret = self.self;
|
|
6467
6728
|
return addHeapObject(ret);
|
|
@@ -6746,13 +7007,13 @@ module.exports.__wbindgen_memory = function() {
|
|
|
6746
7007
|
return addHeapObject(ret);
|
|
6747
7008
|
};
|
|
6748
7009
|
|
|
6749
|
-
module.exports.
|
|
6750
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
7010
|
+
module.exports.__wbindgen_closure_wrapper487 = function(arg0, arg1, arg2) {
|
|
7011
|
+
const ret = makeMutClosure(arg0, arg1, 10, __wbg_adapter_60);
|
|
6751
7012
|
return addHeapObject(ret);
|
|
6752
7013
|
};
|
|
6753
7014
|
|
|
6754
|
-
module.exports.
|
|
6755
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
7015
|
+
module.exports.__wbindgen_closure_wrapper489 = function(arg0, arg1, arg2) {
|
|
7016
|
+
const ret = makeMutClosure(arg0, arg1, 8, __wbg_adapter_63);
|
|
6756
7017
|
return addHeapObject(ret);
|
|
6757
7018
|
};
|
|
6758
7019
|
|
package/nodejs/loro_wasm_bg.wasm
CHANGED
|
Binary file
|