···77import { Attribute, Attributes, FilterAttributes } from "./attributes";
88import { v7 } from "uuid";
99import * as base64 from "base64-js";
1010-import * as Y from "yjs";
1010+import * as Y from "src/ywasm";
1111import { DeepReadonly } from "replicache";
12121313type WriteCacheEntry =
···186186 if (values.length > 0) {
187187 let existingFact = await scanIndex.eav(f.entity, f.attribute);
188188 if (existingFact[0]) values.push(existingFact[0].data.value);
189189- let updateBytes = Y.mergeUpdates(
189189+ let updateBytes = Y.mergeUpdatesV1(
190190 values.map((v) => base64.toByteArray(v)),
191191 );
192192 data.value = base64.fromByteArray(updateBytes);
+23
src/ywasm/LICENSE
···11+The MIT License (MIT)
22+33+Copyright (c) 2020
44+ - Kevin Jahns <kevin.jahns@pm.me>.
55+ - Bartosz Sypytkowski <b.sypytkowski@gmail.com>.
66+77+Permission is hereby granted, free of charge, to any person obtaining a copy
88+of this software and associated documentation files (the "Software"), to deal
99+in the Software without restriction, including without limitation the rights
1010+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1111+copies of the Software, and to permit persons to whom the Software is
1212+furnished to do so, subject to the following conditions:
1313+1414+The above copyright notice and this permission notice shall be included in all
1515+copies or substantial portions of the Software.
1616+1717+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1818+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1919+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2020+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2121+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2222+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2323+SOFTWARE.
+36
src/ywasm/README.md
···11+# Ywasm
22+33+This project is a wrapper around [Yrs](../yrs/README.md) and targets Web Assembly bindings.
44+55+It's a library used on collaborative document editing using Conflict-free Replicated Data Types.
66+This enables to provide a shared document editing experience on a client devices without explicit requirement for hosting a single server - CRDTs can resolve potential update conflicts on their own with no central authority - as well as provide first-class offline editing capabilities, where document replicas are modified without having connection to each other, and then synchronize automatically once such connection is enabled.
77+88+## [Documentation](https://docs.rs/ywasm/)
99+1010+## Example
1111+1212+```js
1313+import * as Y from 'ywasm';
1414+1515+const doc = new Y.YDoc()
1616+const text = doc.getText('name')
1717+1818+// append text to our collaborative document
1919+text.insert(0, 'hello world', { bold: true })
2020+2121+// simulate update with remote peer
2222+const remoteDoc = new Y.YDoc()
2323+const remoteText = remoteDoc.getText('name')
2424+2525+// in order to exchange data with other documents
2626+// we first need to create a state vector
2727+const remoteSV = Y.encodeStateVector(remoteDoc)
2828+// now compute a differential update based on remote document's state vector
2929+const update = Y.encodeStateAsUpdate(doc, remoteSV)
3030+// both update and state vector are serializable, we can pass them over the wire
3131+// now apply update to a remote document
3232+Y.applyUpdate(remoteDoc, update)
3333+3434+const str = remoteText.toString()
3535+console.log(str)
3636+```
···11+/* tslint:disable */
22+/* eslint-disable */
33+/**
44+ * When called will call console log errors whenever internal panic is called from within
55+ * WebAssembly module.
66+ */
77+export function setPanicHook(): void;
88+/**
99+ * Encodes a state vector of a given ywasm document into its binary representation using lib0 v1
1010+ * encoding. State vector is a compact representation of updates performed on a given document and
1111+ * can be used by `encode_state_as_update` on remote peer to generate a delta update payload to
1212+ * synchronize changes between peers.
1313+ *
1414+ * Example:
1515+ *
1616+ * ```javascript
1717+ * import {YDoc, encodeStateVector, encodeStateAsUpdate, applyUpdate} from 'ywasm'
1818+ *
1919+ * /// document on machine A
2020+ * const localDoc = new YDoc()
2121+ * const localSV = encodeStateVector(localDoc)
2222+ *
2323+ * // document on machine B
2424+ * const remoteDoc = new YDoc()
2525+ * const remoteDelta = encodeStateAsUpdate(remoteDoc, localSV)
2626+ *
2727+ * applyUpdate(localDoc, remoteDelta)
2828+ * ```
2929+ */
3030+export function encodeStateVector(doc: YDoc): Uint8Array;
3131+/**
3232+ * Returns a string dump representation of a given `update` encoded using lib0 v1 encoding.
3333+ */
3434+export function debugUpdateV1(update: Uint8Array): string;
3535+/**
3636+ * Returns a string dump representation of a given `update` encoded using lib0 v2 encoding.
3737+ */
3838+export function debugUpdateV2(update: Uint8Array): string;
3939+/**
4040+ * Merges a sequence of updates (encoded using lib0 v1 encoding) together, producing another
4141+ * update (also lib0 v1 encoded) in the result. Returned binary is a combination of all input
4242+ * `updates`, compressed.
4343+ *
4444+ * Returns an error whenever any of the input updates couldn't be decoded.
4545+ */
4646+export function mergeUpdatesV1(updates: Array<any>): Uint8Array;
4747+/**
4848+ * Merges a sequence of updates (encoded using lib0 v2 encoding) together, producing another
4949+ * update (also lib0 v2 encoded) in the result. Returned binary is a combination of all input
5050+ * `updates`, compressed.
5151+ *
5252+ * Returns an error whenever any of the input updates couldn't be decoded.
5353+ */
5454+export function mergeUpdatesV2(updates: Array<any>): Uint8Array;
5555+/**
5656+ * Encodes all updates that have happened since a given version `vector` into a compact delta
5757+ * representation using lib0 v1 encoding. If `vector` parameter has not been provided, generated
5858+ * delta payload will contain all changes of a current ywasm document, working effectivelly as its
5959+ * state snapshot.
6060+ *
6161+ * Example:
6262+ *
6363+ * ```javascript
6464+ * import {YDoc, encodeStateVector, encodeStateAsUpdate, applyUpdate} from 'ywasm'
6565+ *
6666+ * /// document on machine A
6767+ * const localDoc = new YDoc()
6868+ * const localSV = encodeStateVector(localDoc)
6969+ *
7070+ * // document on machine B
7171+ * const remoteDoc = new YDoc()
7272+ * const remoteDelta = encodeStateAsUpdate(remoteDoc, localSV)
7373+ *
7474+ * applyUpdate(localDoc, remoteDelta)
7575+ * ```
7676+ */
7777+export function encodeStateAsUpdate(doc: YDoc, vector?: Uint8Array | null): Uint8Array;
7878+/**
7979+ * Encodes all updates that have happened since a given version `vector` into a compact delta
8080+ * representation using lib0 v2 encoding. If `vector` parameter has not been provided, generated
8181+ * delta payload will contain all changes of a current ywasm document, working effectivelly as its
8282+ * state snapshot.
8383+ *
8484+ * Example:
8585+ *
8686+ * ```javascript
8787+ * import {YDoc, encodeStateVector, encodeStateAsUpdate, applyUpdate} from 'ywasm'
8888+ *
8989+ * /// document on machine A
9090+ * const localDoc = new YDoc()
9191+ * const localSV = encodeStateVector(localDoc)
9292+ *
9393+ * // document on machine B
9494+ * const remoteDoc = new YDoc()
9595+ * const remoteDelta = encodeStateAsUpdateV2(remoteDoc, localSV)
9696+ *
9797+ * applyUpdate(localDoc, remoteDelta)
9898+ * ```
9999+ */
100100+export function encodeStateAsUpdateV2(doc: YDoc, vector?: Uint8Array | null): Uint8Array;
101101+/**
102102+ * Applies delta update generated by the remote document replica to a current document. This
103103+ * method assumes that a payload maintains lib0 v1 encoding format.
104104+ *
105105+ * Example:
106106+ *
107107+ * ```javascript
108108+ * import {YDoc, encodeStateVector, encodeStateAsUpdate, applyUpdate} from 'ywasm'
109109+ *
110110+ * /// document on machine A
111111+ * const localDoc = new YDoc()
112112+ * const localSV = encodeStateVector(localDoc)
113113+ *
114114+ * // document on machine B
115115+ * const remoteDoc = new YDoc()
116116+ * const remoteDelta = encodeStateAsUpdate(remoteDoc, localSV)
117117+ *
118118+ * applyUpdateV2(localDoc, remoteDelta)
119119+ * ```
120120+ */
121121+export function applyUpdate(doc: YDoc, update: Uint8Array, origin: any): void;
122122+/**
123123+ * Applies delta update generated by the remote document replica to a current document. This
124124+ * method assumes that a payload maintains lib0 v2 encoding format.
125125+ *
126126+ * Example:
127127+ *
128128+ * ```javascript
129129+ * import {YDoc, encodeStateVector, encodeStateAsUpdate, applyUpdate} from 'ywasm'
130130+ *
131131+ * /// document on machine A
132132+ * const localDoc = new YDoc()
133133+ * const localSV = encodeStateVector(localDoc)
134134+ *
135135+ * // document on machine B
136136+ * const remoteDoc = new YDoc()
137137+ * const remoteDelta = encodeStateAsUpdateV2(remoteDoc, localSV)
138138+ *
139139+ * applyUpdateV2(localDoc, remoteDelta)
140140+ * ```
141141+ */
142142+export function applyUpdateV2(doc: YDoc, update: Uint8Array, origin: any): void;
143143+export function snapshot(doc: YDoc): any;
144144+export function equalSnapshots(snap1: any, snap2: any): boolean;
145145+export function encodeSnapshotV1(snapshot: any): Uint8Array;
146146+export function encodeSnapshotV2(snapshot: any): Uint8Array;
147147+export function decodeSnapshotV2(snapshot: Uint8Array): any;
148148+export function decodeSnapshotV1(snapshot: Uint8Array): any;
149149+export function encodeStateFromSnapshotV1(doc: YDoc, snapshot: any): Uint8Array;
150150+export function encodeStateFromSnapshotV2(doc: YDoc, snapshot: any): Uint8Array;
151151+/**
152152+ * Retrieves a sticky index corresponding to a given human-readable `index` pointing into
153153+ * the shared `ytype`. Unlike standard indexes sticky indexes enables to track
154154+ * the location inside of a shared y-types, even in the face of concurrent updates.
155155+ *
156156+ * If association is >= 0, the resulting position will point to location **after** the referenced index.
157157+ * If association is < 0, the resulting position will point to location **before** the referenced index.
158158+ */
159159+export function createRelativePositionFromTypeIndex(ytype: any, index: number, assoc: number, txn: YTransaction | undefined): any;
160160+/**
161161+ * Converts a sticky index (see: `createStickyIndexFromType`) into an object
162162+ * containing human-readable index.
163163+ */
164164+export function createAbsolutePositionFromRelativePosition(rpos: any, doc: YDoc): any;
165165+/**
166166+ * Serializes sticky index created by `createStickyIndexFromType` into a binary
167167+ * payload.
168168+ */
169169+export function encodeRelativePosition(rpos: any): Uint8Array;
170170+/**
171171+ * Deserializes sticky index serialized previously by `encodeStickyIndex`.
172172+ */
173173+export function decodeRelativePosition(bin: Uint8Array): any;
174174+export function compareRelativePositions(a: any, b: any): boolean;
175175+export function removeAwarenessStates(awareness: Awareness, clients: BigUint64Array): void;
176176+export function encodeAwarenessUpdate(awareness: Awareness, clients: any): Uint8Array;
177177+export function modifyAwarenessUpdate(update: Uint8Array, modify: Function): Uint8Array;
178178+export function applyAwarenessUpdate(awareness: Awareness, update: Uint8Array, _origin: any): void;
179179+export class Awareness {
180180+ free(): void;
181181+ constructor(doc: YDoc);
182182+ destroy(): void;
183183+ getLocalState(): any;
184184+ setLocalState(state: any): void;
185185+ setLocalStateField(key: string, value: any): void;
186186+ getStates(): Map<any, any>;
187187+ on(event: string, callback: Function): void;
188188+ off(event: string, callback: Function): boolean;
189189+ readonly doc: YDoc;
190190+ readonly meta: Map<any, any>;
191191+}
192192+/**
193193+ * A collection used to store data in an indexed sequence structure. This type is internally
194194+ * implemented as a double linked list, which may squash values inserted directly one after another
195195+ * into single list node upon transaction commit.
196196+ *
197197+ * Reading a root-level type as an YArray means treating its sequence components as a list, where
198198+ * every countable element becomes an individual entity:
199199+ *
200200+ * - JSON-like primitives (booleans, numbers, strings, JSON maps, arrays etc.) are counted
201201+ * individually.
202202+ * - Text chunks inserted by [Text] data structure: each character becomes an element of an
203203+ * array.
204204+ * - Embedded and binary values: they count as a single element even though they correspond of
205205+ * multiple bytes.
206206+ *
207207+ * Like all Yrs shared data types, YArray is resistant to the problem of interleaving (situation
208208+ * when elements inserted one after another may interleave with other peers concurrent inserts
209209+ * after merging all updates together). In case of Yrs conflict resolution is solved by using
210210+ * unique document id to determine correct and consistent ordering.
211211+ */
212212+export class YArray {
213213+ free(): void;
214214+ /**
215215+ * Creates a new preliminary instance of a `YArray` shared data type, with its state
216216+ * initialized to provided parameter.
217217+ *
218218+ * Preliminary instances can be nested into other shared data types such as `YArray` and `YMap`.
219219+ * Once a preliminary instance has been inserted this way, it becomes integrated into ywasm
220220+ * document store and cannot be nested again: attempt to do so will result in an exception.
221221+ */
222222+ constructor(items?: any[] | null);
223223+ /**
224224+ * Checks if current YArray reference is alive and has not been deleted by its parent collection.
225225+ * This method only works on already integrated shared types and will return false is current
226226+ * type is preliminary (has not been integrated into document).
227227+ */
228228+ alive(txn: YTransaction): boolean;
229229+ /**
230230+ * Returns a number of elements stored within this instance of `YArray`.
231231+ */
232232+ length(txn: YTransaction | undefined): number;
233233+ /**
234234+ * Converts an underlying contents of this `YArray` instance into their JSON representation.
235235+ */
236236+ toJson(txn: YTransaction | undefined): any;
237237+ /**
238238+ * Inserts a given range of `items` into this `YArray` instance, starting at given `index`.
239239+ */
240240+ insert(index: number, items: any[], txn: YTransaction | undefined): void;
241241+ /**
242242+ * Appends a range of `items` at the end of this `YArray` instance.
243243+ */
244244+ push(items: any[], txn: YTransaction | undefined): void;
245245+ /**
246246+ * Deletes a range of items of given `length` from current `YArray` instance,
247247+ * starting from given `index`.
248248+ */
249249+ delete(index: number, length: number | null | undefined, txn: YTransaction | undefined): void;
250250+ /**
251251+ * Moves element found at `source` index into `target` index position.
252252+ */
253253+ move(source: number, target: number, txn: YTransaction | undefined): void;
254254+ /**
255255+ * Returns an element stored under given `index`.
256256+ */
257257+ get(index: number, txn: YTransaction | undefined): any;
258258+ quote(lower: number | null | undefined, upper: number | null | undefined, lower_open: boolean | null | undefined, upper_open: boolean | null | undefined, txn: YTransaction | undefined): YWeakLink;
259259+ /**
260260+ * Returns an iterator that can be used to traverse over the values stored withing this
261261+ * instance of `YArray`.
262262+ *
263263+ * Example:
264264+ *
265265+ * ```javascript
266266+ * import YDoc from 'ywasm'
267267+ *
268268+ * /// document on machine A
269269+ * const doc = new YDoc()
270270+ * const array = doc.getArray('name')
271271+ * const txn = doc.beginTransaction()
272272+ * try {
273273+ * array.push(txn, ['hello', 'world'])
274274+ * for (let item of array.values(txn)) {
275275+ * console.log(item)
276276+ * }
277277+ * } finally {
278278+ * txn.free()
279279+ * }
280280+ * ```
281281+ */
282282+ values(txn: YTransaction | undefined): any;
283283+ /**
284284+ * Subscribes to all operations happening over this instance of `YArray`. All changes are
285285+ * batched and eventually triggered during transaction commit phase.
286286+ */
287287+ observe(callback: Function): void;
288288+ unobserve(callback: Function): boolean;
289289+ /**
290290+ * Subscribes to all operations happening over this Y shared type, as well as events in
291291+ * shared types stored within this one. All changes are batched and eventually triggered
292292+ * during transaction commit phase.
293293+ */
294294+ observeDeep(callback: Function): void;
295295+ unobserveDeep(callback: Function): boolean;
296296+ readonly type: number;
297297+ /**
298298+ * Gets unique logical identifier of this type, shared across peers collaborating on the same
299299+ * document.
300300+ */
301301+ readonly id: any;
302302+ /**
303303+ * Returns true if this is a preliminary instance of `YArray`.
304304+ *
305305+ * Preliminary instances can be nested into other shared data types such as `YArray` and `YMap`.
306306+ * Once a preliminary instance has been inserted this way, it becomes integrated into ywasm
307307+ * document store and cannot be nested again: attempt to do so will result in an exception.
308308+ */
309309+ readonly prelim: boolean;
310310+}
311311+/**
312312+ * Event generated by `YArray.observe` method. Emitted during transaction commit phase.
313313+ */
314314+export class YArrayEvent {
315315+ private constructor();
316316+ free(): void;
317317+ /**
318318+ * Returns an array of keys and indexes creating a path from root type down to current instance
319319+ * of shared type (accessible via `target` getter).
320320+ */
321321+ path(): any;
322322+ /**
323323+ * Returns a current shared type instance, that current event changes refer to.
324324+ */
325325+ readonly target: any;
326326+ readonly origin: any;
327327+ /**
328328+ * Returns a list of text changes made over corresponding `YArray` collection within
329329+ * bounds of current transaction. These changes follow a format:
330330+ *
331331+ * - { insert: any[] }
332332+ * - { delete: number }
333333+ * - { retain: number }
334334+ */
335335+ readonly delta: any;
336336+}
337337+/**
338338+ * A ywasm document type. Documents are most important units of collaborative resources management.
339339+ * All shared collections live within a scope of their corresponding documents. All updates are
340340+ * generated on per-document basis (rather than individual shared type). All operations on shared
341341+ * collections happen via [YTransaction], which lifetime is also bound to a document.
342342+ *
343343+ * Document manages so-called root types, which are top-level shared types definitions (as opposed
344344+ * to recursively nested types).
345345+ *
346346+ * A basic workflow sample:
347347+ *
348348+ * ```javascript
349349+ * import YDoc from 'ywasm'
350350+ *
351351+ * const doc = new YDoc()
352352+ * const txn = doc.beginTransaction()
353353+ * try {
354354+ * const text = txn.getText('name')
355355+ * text.push(txn, 'hello world')
356356+ * const output = text.toString(txn)
357357+ * console.log(output)
358358+ * } finally {
359359+ * txn.free()
360360+ * }
361361+ * ```
362362+ */
363363+export class YDoc {
364364+ free(): void;
365365+ /**
366366+ * Creates a new ywasm document. If `id` parameter was passed it will be used as this document
367367+ * globally unique identifier (it's up to caller to ensure that requirement). Otherwise it will
368368+ * be assigned a randomly generated number.
369369+ */
370370+ constructor(options: any);
371371+ /**
372372+ * Returns a new transaction for this document. Ywasm shared data types execute their
373373+ * operations in a context of a given transaction. Each document can have only one active
374374+ * transaction at the time - subsequent attempts will cause exception to be thrown.
375375+ *
376376+ * Transactions started with `doc.beginTransaction` can be released using `transaction.free`
377377+ * method.
378378+ *
379379+ * Example:
380380+ *
381381+ * ```javascript
382382+ * import YDoc from 'ywasm'
383383+ *
384384+ * // helper function used to simplify transaction
385385+ * // create/release cycle
386386+ * YDoc.prototype.transact = callback => {
387387+ * const txn = this.transaction()
388388+ * try {
389389+ * return callback(txn)
390390+ * } finally {
391391+ * txn.free()
392392+ * }
393393+ * }
394394+ *
395395+ * const doc = new YDoc()
396396+ * const text = doc.getText('name')
397397+ * doc.transact(txn => text.insert(txn, 0, 'hello world'))
398398+ * ```
399399+ */
400400+ beginTransaction(origin: any): YTransaction;
401401+ /**
402402+ * Returns a `YText` shared data type, that's accessible for subsequent accesses using given
403403+ * `name`.
404404+ *
405405+ * If there was no instance with this name before, it will be created and then returned.
406406+ *
407407+ * If there was an instance with this name, but it was of different type, it will be projected
408408+ * onto `YText` instance.
409409+ */
410410+ getText(name: string): YText;
411411+ /**
412412+ * Returns a `YArray` shared data type, that's accessible for subsequent accesses using given
413413+ * `name`.
414414+ *
415415+ * If there was no instance with this name before, it will be created and then returned.
416416+ *
417417+ * If there was an instance with this name, but it was of different type, it will be projected
418418+ * onto `YArray` instance.
419419+ */
420420+ getArray(name: string): YArray;
421421+ /**
422422+ * Returns a `YMap` shared data type, that's accessible for subsequent accesses using given
423423+ * `name`.
424424+ *
425425+ * If there was no instance with this name before, it will be created and then returned.
426426+ *
427427+ * If there was an instance with this name, but it was of different type, it will be projected
428428+ * onto `YMap` instance.
429429+ */
430430+ getMap(name: string): YMap;
431431+ /**
432432+ * Returns a `YXmlFragment` shared data type, that's accessible for subsequent accesses using
433433+ * given `name`.
434434+ *
435435+ * If there was no instance with this name before, it will be created and then returned.
436436+ *
437437+ * If there was an instance with this name, but it was of different type, it will be projected
438438+ * onto `YXmlFragment` instance.
439439+ */
440440+ getXmlFragment(name: string): YXmlFragment;
441441+ on(event: string, callback: Function): void;
442442+ off(event: string, callback: Function): boolean;
443443+ /**
444444+ * Notify the parent document that you request to load data into this subdocument
445445+ * (if it is a subdocument).
446446+ */
447447+ load(parent_txn: YTransaction | undefined): void;
448448+ /**
449449+ * Emit `onDestroy` event and unregister all event handlers.
450450+ */
451451+ destroy(parent_txn: YTransaction | undefined): void;
452452+ /**
453453+ * Returns a list of sub-documents existings within the scope of this document.
454454+ */
455455+ getSubdocs(txn: YTransaction | undefined): Array<any>;
456456+ /**
457457+ * Returns a list of unique identifiers of the sub-documents existings within the scope of
458458+ * this document.
459459+ */
460460+ getSubdocGuids(txn: YTransaction | undefined): Set<any>;
461461+ /**
462462+ * Returns a list of all root-level replicated collections, together with their types.
463463+ * These collections can then be accessed via `getMap`/`getText` etc. methods.
464464+ *
465465+ * Example:
466466+ * ```js
467467+ * import * as Y from 'ywasm'
468468+ *
469469+ * const doc = new Y.YDoc()
470470+ * const ymap = doc.getMap('a')
471471+ * const yarray = doc.getArray('b')
472472+ * const ytext = doc.getText('c')
473473+ * const yxml = doc.getXmlFragment('d')
474474+ *
475475+ * const roots = doc.roots() // [['a',ymap], ['b',yarray], ['c',ytext], ['d',yxml]]
476476+ * ```
477477+ */
478478+ roots(txn: YTransaction | undefined): Array<any>;
479479+ /**
480480+ * Evaluates a JSON path expression (see: https://en.wikipedia.org/wiki/JSONPath) on
481481+ * the document and returns an array of values matching that query.
482482+ *
483483+ * Currently, this method supports the following syntax:
484484+ * - `$` - root object
485485+ * - `@` - current object
486486+ * - `.field` or `['field']` - member accessor
487487+ * - `[1]` - array index (also supports negative indices)
488488+ * - `.*` or `[*]` - wildcard (matches all members of an object or array)
489489+ * - `..` - recursive descent (matches all descendants not only direct children)
490490+ * - `[start:end:step]` - array slice operator (requires positive integer arguments)
491491+ * - `['a', 'b', 'c']` - union operator (returns an array of values for each query)
492492+ * - `[1, -1, 3]` - multiple indices operator (returns an array of values for each index)
493493+ *
494494+ * At the moment, JSON Path does not support filter predicates.
495495+ */
496496+ selectAll(json_path: string): Array<any>;
497497+ /**
498498+ * Evaluates a JSON path expression (see: https://en.wikipedia.org/wiki/JSONPath) on
499499+ * the document and returns first value matching that query.
500500+ *
501501+ * Currently, this method supports the following syntax:
502502+ * - `$` - root object
503503+ * - `@` - current object
504504+ * - `.field` or `['field']` - member accessor
505505+ * - `[1]` - array index (also supports negative indices)
506506+ * - `.*` or `[*]` - wildcard (matches all members of an object or array)
507507+ * - `..` - recursive descent (matches all descendants not only direct children)
508508+ * - `[start:end:step]` - array slice operator (requires positive integer arguments)
509509+ * - `['a', 'b', 'c']` - union operator (returns an array of values for each query)
510510+ * - `[1, -1, 3]` - multiple indices operator (returns an array of values for each index)
511511+ *
512512+ * At the moment, JSON Path does not support filter predicates.
513513+ */
514514+ selectOne(json_path: string): any;
515515+ readonly type: number;
516516+ /**
517517+ * Checks if a document is a preliminary type. It returns false, if current document
518518+ * is already a sub-document of another document.
519519+ */
520520+ readonly prelim: boolean;
521521+ /**
522522+ * Returns a parent document of this document or null if current document is not sub-document.
523523+ */
524524+ readonly parentDoc: YDoc | undefined;
525525+ /**
526526+ * Gets unique peer identifier of this `YDoc` instance.
527527+ */
528528+ readonly id: number;
529529+ /**
530530+ * Gets globally unique identifier of this `YDoc` instance.
531531+ */
532532+ readonly guid: string;
533533+ readonly shouldLoad: boolean;
534534+ readonly autoLoad: boolean;
535535+}
536536+/**
537537+ * Collection used to store key-value entries in an unordered manner. Keys are always represented
538538+ * as UTF-8 strings. Values can be any value type supported by Yrs: JSON-like primitives as well as
539539+ * shared data types.
540540+ *
541541+ * In terms of conflict resolution, [Map] uses logical last-write-wins principle, meaning the past
542542+ * updates are automatically overridden and discarded by newer ones, while concurrent updates made
543543+ * by different peers are resolved into a single value using document id seniority to establish
544544+ * order.
545545+ */
546546+export class YMap {
547547+ free(): void;
548548+ /**
549549+ * Creates a new preliminary instance of a `YMap` shared data type, with its state
550550+ * initialized to provided parameter.
551551+ *
552552+ * Preliminary instances can be nested into other shared data types such as `YArray` and `YMap`.
553553+ * Once a preliminary instance has been inserted this way, it becomes integrated into ywasm
554554+ * document store and cannot be nested again: attempt to do so will result in an exception.
555555+ */
556556+ constructor(init?: object | null);
557557+ /**
558558+ * Checks if current YMap reference is alive and has not been deleted by its parent collection.
559559+ * This method only works on already integrated shared types and will return false is current
560560+ * type is preliminary (has not been integrated into document).
561561+ */
562562+ alive(txn: YTransaction): boolean;
563563+ /**
564564+ * Returns a number of entries stored within this instance of `YMap`.
565565+ */
566566+ length(txn: YTransaction | undefined): number;
567567+ /**
568568+ * Converts contents of this `YMap` instance into a JSON representation.
569569+ */
570570+ toJson(txn: YTransaction | undefined): any;
571571+ /**
572572+ * Sets a given `key`-`value` entry within this instance of `YMap`. If another entry was
573573+ * already stored under given `key`, it will be overridden with new `value`.
574574+ */
575575+ set(key: string, value: any, txn: YTransaction | undefined): void;
576576+ /**
577577+ * Removes an entry identified by a given `key` from this instance of `YMap`, if such exists.
578578+ */
579579+ delete(key: string, txn: YTransaction | undefined): void;
580580+ /**
581581+ * Returns value of an entry stored under given `key` within this instance of `YMap`,
582582+ * or `undefined` if no such entry existed.
583583+ */
584584+ get(key: string, txn: YTransaction | undefined): any;
585585+ link(key: string, txn: YTransaction | undefined): any;
586586+ /**
587587+ * Returns an iterator that can be used to traverse over all entries stored within this
588588+ * instance of `YMap`. Order of entry is not specified.
589589+ *
590590+ * Example:
591591+ *
592592+ * ```javascript
593593+ * import YDoc from 'ywasm'
594594+ *
595595+ * /// document on machine A
596596+ * const doc = new YDoc()
597597+ * const map = doc.getMap('name')
598598+ * const txn = doc.beginTransaction()
599599+ * try {
600600+ * map.set(txn, 'key1', 'value1')
601601+ * map.set(txn, 'key2', true)
602602+ *
603603+ * for (let [key, value] of map.entries(txn)) {
604604+ * console.log(key, value)
605605+ * }
606606+ * } finally {
607607+ * txn.free()
608608+ * }
609609+ * ```
610610+ */
611611+ entries(txn: YTransaction | undefined): any;
612612+ /**
613613+ * Subscribes to all operations happening over this instance of `YMap`. All changes are
614614+ * batched and eventually triggered during transaction commit phase.
615615+ */
616616+ observe(callback: Function): void;
617617+ /**
618618+ * Unsubscribes a callback previously subscribed with `observe` method.
619619+ */
620620+ unobserve(callback: Function): boolean;
621621+ /**
622622+ * Subscribes to all operations happening over this Y shared type, as well as events in
623623+ * shared types stored within this one. All changes are batched and eventually triggered
624624+ * during transaction commit phase.
625625+ */
626626+ observeDeep(callback: Function): void;
627627+ /**
628628+ * Unsubscribes a callback previously subscribed with `observeDeep` method.
629629+ */
630630+ unobserveDeep(callback: Function): boolean;
631631+ readonly type: number;
632632+ /**
633633+ * Gets unique logical identifier of this type, shared across peers collaborating on the same
634634+ * document.
635635+ */
636636+ readonly id: any;
637637+ /**
638638+ * Returns true if this is a preliminary instance of `YMap`.
639639+ *
640640+ * Preliminary instances can be nested into other shared data types such as `YArray` and `YMap`.
641641+ * Once a preliminary instance has been inserted this way, it becomes integrated into ywasm
642642+ * document store and cannot be nested again: attempt to do so will result in an exception.
643643+ */
644644+ readonly prelim: boolean;
645645+}
646646+/**
647647+ * Event generated by `YMap.observe` method. Emitted during transaction commit phase.
648648+ */
649649+export class YMapEvent {
650650+ private constructor();
651651+ free(): void;
652652+ /**
653653+ * Returns an array of keys and indexes creating a path from root type down to current instance
654654+ * of shared type (accessible via `target` getter).
655655+ */
656656+ path(): any;
657657+ readonly origin: any;
658658+ /**
659659+ * Returns a current shared type instance, that current event changes refer to.
660660+ */
661661+ readonly target: any;
662662+ /**
663663+ * Returns a list of key-value changes made over corresponding `YMap` collection within
664664+ * bounds of current transaction. These changes follow a format:
665665+ *
666666+ * - { action: 'add'|'update'|'delete', oldValue: any|undefined, newValue: any|undefined }
667667+ */
668668+ readonly keys: any;
669669+}
670670+export class YSubdocsEvent {
671671+ private constructor();
672672+ free(): void;
673673+ readonly added: Array<any>;
674674+ readonly removed: Array<any>;
675675+ readonly loaded: Array<any>;
676676+}
677677+/**
678678+ * A shared data type used for collaborative text editing. It enables multiple users to add and
679679+ * remove chunks of text in efficient manner. This type is internally represented as a mutable
680680+ * double-linked list of text chunks - an optimization occurs during `YTransaction.commit`, which
681681+ * allows to squash multiple consecutively inserted characters together as a single chunk of text
682682+ * even between transaction boundaries in order to preserve more efficient memory model.
683683+ *
684684+ * `YText` structure internally uses UTF-8 encoding and its length is described in a number of
685685+ * bytes rather than individual characters (a single UTF-8 code point can consist of many bytes).
686686+ *
687687+ * Like all Yrs shared data types, `YText` is resistant to the problem of interleaving (situation
688688+ * when characters inserted one after another may interleave with other peers concurrent inserts
689689+ * after merging all updates together). In case of Yrs conflict resolution is solved by using
690690+ * unique document id to determine correct and consistent ordering.
691691+ */
692692+export class YText {
693693+ free(): void;
694694+ /**
695695+ * Creates a new preliminary instance of a `YText` shared data type, with its state initialized
696696+ * to provided parameter.
697697+ *
698698+ * Preliminary instances can be nested into other shared data types such as `YArray` and `YMap`.
699699+ * Once a preliminary instance has been inserted this way, it becomes integrated into ywasm
700700+ * document store and cannot be nested again: attempt to do so will result in an exception.
701701+ */
702702+ constructor(init?: string | null);
703703+ /**
704704+ * Checks if current YArray reference is alive and has not been deleted by its parent collection.
705705+ * This method only works on already integrated shared types and will return false is current
706706+ * type is preliminary (has not been integrated into document).
707707+ */
708708+ alive(txn: YTransaction): boolean;
709709+ /**
710710+ * Returns length of an underlying string stored in this `YText` instance,
711711+ * understood as a number of UTF-8 encoded bytes.
712712+ */
713713+ length(txn: YTransaction | undefined): number;
714714+ /**
715715+ * Returns an underlying shared string stored in this data type.
716716+ */
717717+ toString(txn: YTransaction | undefined): string;
718718+ /**
719719+ * Returns an underlying shared string stored in this data type.
720720+ */
721721+ toJson(txn: YTransaction | undefined): any;
722722+ /**
723723+ * Inserts a given `chunk` of text into this `YText` instance, starting at a given `index`.
724724+ *
725725+ * Optional object with defined `attributes` will be used to wrap provided text `chunk`
726726+ * with a formatting blocks.`attributes` are only supported for a `YText` instance which
727727+ * already has been integrated into document store.
728728+ */
729729+ insert(index: number, chunk: string, attributes: any, txn: YTransaction | undefined): void;
730730+ /**
731731+ * Inserts a given `embed` object into this `YText` instance, starting at a given `index`.
732732+ *
733733+ * Optional object with defined `attributes` will be used to wrap provided `embed`
734734+ * with a formatting blocks.`attributes` are only supported for a `YText` instance which
735735+ * already has been integrated into document store.
736736+ */
737737+ insertEmbed(index: number, embed: any, attributes: any, txn: YTransaction | undefined): void;
738738+ /**
739739+ * Wraps an existing piece of text within a range described by `index`-`length` parameters with
740740+ * formatting blocks containing provided `attributes` metadata. This method only works for
741741+ * `YText` instances that already have been integrated into document store.
742742+ */
743743+ format(index: number, length: number, attributes: any, txn: YTransaction | undefined): void;
744744+ /**
745745+ * Appends a given `chunk` of text at the end of current `YText` instance.
746746+ *
747747+ * Optional object with defined `attributes` will be used to wrap provided text `chunk`
748748+ * with a formatting blocks.`attributes` are only supported for a `YText` instance which
749749+ * already has been integrated into document store.
750750+ */
751751+ push(chunk: string, attributes: any, txn: YTransaction | undefined): void;
752752+ /**
753753+ * Deletes a specified range of characters, starting at a given `index`.
754754+ * Both `index` and `length` are counted in terms of a number of UTF-8 character bytes.
755755+ */
756756+ delete(index: number, length: number, txn: YTransaction | undefined): void;
757757+ quote(lower: number | null | undefined, upper: number | null | undefined, lower_open: boolean | null | undefined, upper_open: boolean | null | undefined, txn: YTransaction | undefined): YWeakLink;
758758+ /**
759759+ * Returns the Delta representation of this YText type.
760760+ */
761761+ toDelta(snapshot: any, prev_snapshot: any, compute_ychange: Function | null | undefined, txn: YTransaction | undefined): Array<any>;
762762+ applyDelta(delta: Array<any>, txn: YTransaction | undefined): void;
763763+ /**
764764+ * Subscribes to all operations happening over this instance of `YText`. All changes are
765765+ * batched and eventually triggered during transaction commit phase.
766766+ */
767767+ observe(callback: Function): void;
768768+ /**
769769+ * Unsubscribes a callback previously subscribed with `observe` method.
770770+ */
771771+ unobserve(callback: Function): boolean;
772772+ /**
773773+ * Subscribes to all operations happening over this Y shared type, as well as events in
774774+ * shared types stored within this one. All changes are batched and eventually triggered
775775+ * during transaction commit phase.
776776+ */
777777+ observeDeep(callback: Function): void;
778778+ /**
779779+ * Unsubscribes a callback previously subscribed with `observeDeep` method.
780780+ */
781781+ unobserveDeep(callback: Function): boolean;
782782+ readonly type: number;
783783+ /**
784784+ * Gets unique logical identifier of this type, shared across peers collaborating on the same
785785+ * document.
786786+ */
787787+ readonly id: any;
788788+ /**
789789+ * Returns true if this is a preliminary instance of `YArray`.
790790+ *
791791+ * Preliminary instances can be nested into other shared data types such as `YArray` and `YMap`.
792792+ * Once a preliminary instance has been inserted this way, it becomes integrated into ywasm
793793+ * document store and cannot be nested again: attempt to do so will result in an exception.
794794+ */
795795+ readonly prelim: boolean;
796796+}
797797+/**
798798+ * Event generated by `YYText.observe` method. Emitted during transaction commit phase.
799799+ */
800800+export class YTextEvent {
801801+ private constructor();
802802+ free(): void;
803803+ /**
804804+ * Returns an array of keys and indexes creating a path from root type down to current instance
805805+ * of shared type (accessible via `target` getter).
806806+ */
807807+ path(): any;
808808+ /**
809809+ * Returns a current shared type instance, that current event changes refer to.
810810+ */
811811+ readonly target: any;
812812+ readonly origin: any;
813813+ /**
814814+ * Returns a list of text changes made over corresponding `YText` collection within
815815+ * bounds of current transaction. These changes follow a format:
816816+ *
817817+ * - { insert: string, attributes: any|undefined }
818818+ * - { delete: number }
819819+ * - { retain: number, attributes: any|undefined }
820820+ */
821821+ readonly delta: any;
822822+}
823823+export class YTransaction {
824824+ private constructor();
825825+ free(): void;
826826+ /**
827827+ * Given a logical identifier of the collection (obtained via `YText.id`, `YArray.id` etc.),
828828+ * attempts to return an instance of that collection in the scope of current document.
829829+ *
830830+ * Returns `undefined` if an instance was not defined locally, haven't been integrated or
831831+ * has been deleted.
832832+ */
833833+ get(id: any): any;
834834+ /**
835835+ * Triggers a post-update series of operations without `free`ing the transaction. This includes
836836+ * compaction and optimization of internal representation of updates, triggering events etc.
837837+ * ywasm transactions are auto-committed when they are `free`d.
838838+ */
839839+ commit(): void;
840840+ /**
841841+ * Encodes a state vector of a given transaction document into its binary representation using
842842+ * lib0 v1 encoding. State vector is a compact representation of updates performed on a given
843843+ * document and can be used by `encode_state_as_update` on remote peer to generate a delta
844844+ * update payload to synchronize changes between peers.
845845+ *
846846+ * Example:
847847+ *
848848+ * ```javascript
849849+ * import YDoc from 'ywasm'
850850+ *
851851+ * /// document on machine A
852852+ * const localDoc = new YDoc()
853853+ * const localTxn = localDoc.beginTransaction()
854854+ *
855855+ * // document on machine B
856856+ * const remoteDoc = new YDoc()
857857+ * const remoteTxn = localDoc.beginTransaction()
858858+ *
859859+ * try {
860860+ * const localSV = localTxn.stateVectorV1()
861861+ * const remoteDelta = remoteTxn.diffV1(localSv)
862862+ * localTxn.applyV1(remoteDelta)
863863+ * } finally {
864864+ * localTxn.free()
865865+ * remoteTxn.free()
866866+ * }
867867+ * ```
868868+ */
869869+ stateVectorV1(): Uint8Array;
870870+ /**
871871+ * Encodes all updates that have happened since a given version `vector` into a compact delta
872872+ * representation using lib0 v1 encoding. If `vector` parameter has not been provided, generated
873873+ * delta payload will contain all changes of a current ywasm document, working effectively as
874874+ * its state snapshot.
875875+ *
876876+ * Example:
877877+ *
878878+ * ```javascript
879879+ * import YDoc from 'ywasm'
880880+ *
881881+ * /// document on machine A
882882+ * const localDoc = new YDoc()
883883+ * const localTxn = localDoc.beginTransaction()
884884+ *
885885+ * // document on machine B
886886+ * const remoteDoc = new YDoc()
887887+ * const remoteTxn = localDoc.beginTransaction()
888888+ *
889889+ * try {
890890+ * const localSV = localTxn.stateVectorV1()
891891+ * const remoteDelta = remoteTxn.diffV1(localSv)
892892+ * localTxn.applyV1(remoteDelta)
893893+ * } finally {
894894+ * localTxn.free()
895895+ * remoteTxn.free()
896896+ * }
897897+ * ```
898898+ */
899899+ diffV1(vector?: Uint8Array | null): Uint8Array;
900900+ /**
901901+ * Encodes all updates that have happened since a given version `vector` into a compact delta
902902+ * representation using lib0 v1 encoding. If `vector` parameter has not been provided, generated
903903+ * delta payload will contain all changes of a current ywasm document, working effectively as
904904+ * its state snapshot.
905905+ *
906906+ * Example:
907907+ *
908908+ * ```javascript
909909+ * import YDoc from 'ywasm'
910910+ *
911911+ * /// document on machine A
912912+ * const localDoc = new YDoc()
913913+ * const localTxn = localDoc.beginTransaction()
914914+ *
915915+ * // document on machine B
916916+ * const remoteDoc = new YDoc()
917917+ * const remoteTxn = localDoc.beginTransaction()
918918+ *
919919+ * try {
920920+ * const localSV = localTxn.stateVectorV1()
921921+ * const remoteDelta = remoteTxn.diffV2(localSv)
922922+ * localTxn.applyV2(remoteDelta)
923923+ * } finally {
924924+ * localTxn.free()
925925+ * remoteTxn.free()
926926+ * }
927927+ * ```
928928+ */
929929+ diffV2(vector?: Uint8Array | null): Uint8Array;
930930+ /**
931931+ * Applies delta update generated by the remote document replica to a current transaction's
932932+ * document. This method assumes that a payload maintains lib0 v1 encoding format.
933933+ *
934934+ * Example:
935935+ *
936936+ * ```javascript
937937+ * import YDoc from 'ywasm'
938938+ *
939939+ * /// document on machine A
940940+ * const localDoc = new YDoc()
941941+ * const localTxn = localDoc.beginTransaction()
942942+ *
943943+ * // document on machine B
944944+ * const remoteDoc = new YDoc()
945945+ * const remoteTxn = localDoc.beginTransaction()
946946+ *
947947+ * try {
948948+ * const localSV = localTxn.stateVectorV1()
949949+ * const remoteDelta = remoteTxn.diffV1(localSv)
950950+ * localTxn.applyV1(remoteDelta)
951951+ * } finally {
952952+ * localTxn.free()
953953+ * remoteTxn.free()
954954+ * }
955955+ * ```
956956+ */
957957+ applyV1(diff: Uint8Array): void;
958958+ /**
959959+ * Applies delta update generated by the remote document replica to a current transaction's
960960+ * document. This method assumes that a payload maintains lib0 v2 encoding format.
961961+ *
962962+ * Example:
963963+ *
964964+ * ```javascript
965965+ * import YDoc from 'ywasm'
966966+ *
967967+ * /// document on machine A
968968+ * const localDoc = new YDoc()
969969+ * const localTxn = localDoc.beginTransaction()
970970+ *
971971+ * // document on machine B
972972+ * const remoteDoc = new YDoc()
973973+ * const remoteTxn = localDoc.beginTransaction()
974974+ *
975975+ * try {
976976+ * const localSV = localTxn.stateVectorV1()
977977+ * const remoteDelta = remoteTxn.diffV2(localSv)
978978+ * localTxn.applyV2(remoteDelta)
979979+ * } finally {
980980+ * localTxn.free()
981981+ * remoteTxn.free()
982982+ * }
983983+ * ```
984984+ */
985985+ applyV2(diff: Uint8Array): void;
986986+ encodeUpdate(): Uint8Array;
987987+ encodeUpdateV2(): Uint8Array;
988988+ /**
989989+ * Force garbage collection of the deleted elements, regardless of a parent doc was created
990990+ * with `gc` option turned on or off.
991991+ */
992992+ gc(): void;
993993+ /**
994994+ * Evaluates a JSON path expression (see: https://en.wikipedia.org/wiki/JSONPath) on
995995+ * the document and returns an array of values matching that query.
996996+ *
997997+ * Currently, this method supports the following syntax:
998998+ * - `$` - root object
999999+ * - `@` - current object
10001000+ * - `.field` or `['field']` - member accessor
10011001+ * - `[1]` - array index (also supports negative indices)
10021002+ * - `.*` or `[*]` - wildcard (matches all members of an object or array)
10031003+ * - `..` - recursive descent (matches all descendants not only direct children)
10041004+ * - `[start:end:step]` - array slice operator (requires positive integer arguments)
10051005+ * - `['a', 'b', 'c']` - union operator (returns an array of values for each query)
10061006+ * - `[1, -1, 3]` - multiple indices operator (returns an array of values for each index)
10071007+ *
10081008+ * At the moment, JSON Path does not support filter predicates.
10091009+ */
10101010+ selectAll(json_path: string): Array<any>;
10111011+ /**
10121012+ * Evaluates a JSON path expression (see: https://en.wikipedia.org/wiki/JSONPath) on
10131013+ * the document and returns first value matching that query.
10141014+ *
10151015+ * Currently, this method supports the following syntax:
10161016+ * - `$` - root object
10171017+ * - `@` - current object
10181018+ * - `.field` or `['field']` - member accessor
10191019+ * - `[1]` - array index (also supports negative indices)
10201020+ * - `.*` or `[*]` - wildcard (matches all members of an object or array)
10211021+ * - `..` - recursive descent (matches all descendants not only direct children)
10221022+ * - `[start:end:step]` - array slice operator (requires positive integer arguments)
10231023+ * - `['a', 'b', 'c']` - union operator (returns an array of values for each query)
10241024+ * - `[1, -1, 3]` - multiple indices operator (returns an array of values for each index)
10251025+ *
10261026+ * At the moment, JSON Path does not support filter predicates.
10271027+ */
10281028+ selectOne(json_path: string): any;
10291029+ /**
10301030+ * Returns state vector describing the state of the document
10311031+ * at the moment when the transaction began.
10321032+ */
10331033+ readonly beforeState: Map<any, any>;
10341034+ /**
10351035+ * Returns state vector describing the current state of
10361036+ * the document.
10371037+ */
10381038+ readonly afterState: Map<any, any>;
10391039+ readonly pendingStructs: any;
10401040+ /**
10411041+ * Returns a unapplied delete set, that was received in one of the previous remote updates.
10421042+ * This DeleteSet is waiting for a missing updates to arrive in order to be applied.
10431043+ */
10441044+ readonly pendingDeleteSet: Map<any, any> | undefined;
10451045+ /**
10461046+ * Returns a delete set containing information about
10471047+ * all blocks removed as part of a current transaction.
10481048+ */
10491049+ readonly deleteSet: Map<any, any>;
10501050+ readonly origin: any;
10511051+}
10521052+export class YUndoEvent {
10531053+ private constructor();
10541054+ free(): void;
10551055+ readonly origin: any;
10561056+ readonly kind: any;
10571057+ meta: any;
10581058+}
10591059+export class YUndoManager {
10601060+ free(): void;
10611061+ constructor(doc: YDoc, scope: any, options: any);
10621062+ addToScope(ytypes: Array<any>): void;
10631063+ addTrackedOrigin(origin: any): void;
10641064+ removeTrackedOrigin(origin: any): void;
10651065+ clear(): void;
10661066+ stopCapturing(): void;
10671067+ undo(): void;
10681068+ redo(): void;
10691069+ on(event: string, callback: Function): void;
10701070+ off(event: string, callback: Function): boolean;
10711071+ readonly canUndo: boolean;
10721072+ readonly canRedo: boolean;
10731073+}
10741074+export class YWeakLink {
10751075+ private constructor();
10761076+ free(): void;
10771077+ /**
10781078+ * Checks if current YWeakLink reference is alive and has not been deleted by its parent collection.
10791079+ * This method only works on already integrated shared types and will return false is current
10801080+ * type is preliminary (has not been integrated into document).
10811081+ */
10821082+ alive(txn: YTransaction): boolean;
10831083+ deref(txn: YTransaction | undefined): any;
10841084+ unquote(txn: YTransaction | undefined): Array<any>;
10851085+ toString(txn: YTransaction | undefined): string;
10861086+ /**
10871087+ * Subscribes to all operations happening over this instance of `YMap`. All changes are
10881088+ * batched and eventually triggered during transaction commit phase.
10891089+ */
10901090+ observe(callback: Function): void;
10911091+ /**
10921092+ * Unsubscribes a callback previously subscribed with `observe` method.
10931093+ */
10941094+ unobserve(callback: Function): boolean;
10951095+ /**
10961096+ * Subscribes to all operations happening over this Y shared type, as well as events in
10971097+ * shared types stored within this one. All changes are batched and eventually triggered
10981098+ * during transaction commit phase.
10991099+ */
11001100+ observeDeep(callback: Function): void;
11011101+ /**
11021102+ * Unsubscribes a callback previously subscribed with `observeDeep` method.
11031103+ */
11041104+ unobserveDeep(callback: Function): boolean;
11051105+ /**
11061106+ * Returns true if this is a preliminary instance of `YWeakLink`.
11071107+ *
11081108+ * Preliminary instances can be nested into other shared data types such as `YArray` and `YMap`.
11091109+ * Once a preliminary instance has been inserted this way, it becomes integrated into ywasm
11101110+ * document store and cannot be nested again: attempt to do so will result in an exception.
11111111+ */
11121112+ readonly prelim: boolean;
11131113+ readonly type: number;
11141114+ /**
11151115+ * Gets unique logical identifier of this type, shared across peers collaborating on the same
11161116+ * document.
11171117+ */
11181118+ readonly id: any;
11191119+}
11201120+/**
11211121+ * Event generated by `YXmlElement.observe` method. Emitted during transaction commit phase.
11221122+ */
11231123+export class YWeakLinkEvent {
11241124+ private constructor();
11251125+ free(): void;
11261126+ /**
11271127+ * Returns an array of keys and indexes creating a path from root type down to current instance
11281128+ * of shared type (accessible via `target` getter).
11291129+ */
11301130+ path(): any;
11311131+ readonly origin: any;
11321132+ /**
11331133+ * Returns a current shared type instance, that current event changes refer to.
11341134+ */
11351135+ readonly target: any;
11361136+}
11371137+/**
11381138+ * XML element data type. It represents an XML node, which can contain key-value attributes
11391139+ * (interpreted as strings) as well as other nested XML elements or rich text (represented by
11401140+ * `YXmlText` type).
11411141+ *
11421142+ * In terms of conflict resolution, `YXmlElement` uses following rules:
11431143+ *
11441144+ * - Attribute updates use logical last-write-wins principle, meaning the past updates are
11451145+ * automatically overridden and discarded by newer ones, while concurrent updates made by
11461146+ * different peers are resolved into a single value using document id seniority to establish
11471147+ * an order.
11481148+ * - Child node insertion uses sequencing rules from other Yrs collections - elements are inserted
11491149+ * using interleave-resistant algorithm, where order of concurrent inserts at the same index
11501150+ * is established using peer's document id seniority.
11511151+ */
11521152+export class YXmlElement {
11531153+ free(): void;
11541154+ constructor(name: string, attributes: any, children: any);
11551155+ /**
11561156+ * Checks if current shared type reference is alive and has not been deleted by its parent collection.
11571157+ * This method only works on already integrated shared types and will return false is current
11581158+ * type is preliminary (has not been integrated into document).
11591159+ */
11601160+ alive(txn: YTransaction): boolean;
11611161+ /**
11621162+ * Returns a tag name of this XML node.
11631163+ */
11641164+ name(txn: YTransaction | undefined): string;
11651165+ /**
11661166+ * Returns a number of child XML nodes stored within this `YXMlElement` instance.
11671167+ */
11681168+ length(txn: YTransaction | undefined): number;
11691169+ insert(index: number, xml_node: any, txn: YTransaction | undefined): void;
11701170+ push(xml_node: any, txn: YTransaction | undefined): void;
11711171+ delete(index: number, length: number | null | undefined, txn: YTransaction | undefined): void;
11721172+ /**
11731173+ * Returns a first child of this XML node.
11741174+ * It can be either `YXmlElement`, `YXmlText` or `undefined` if current node has not children.
11751175+ */
11761176+ firstChild(txn: YTransaction | undefined): any;
11771177+ /**
11781178+ * Returns a next XML sibling node of this XMl node.
11791179+ * It can be either `YXmlElement`, `YXmlText` or `undefined` if current node is a last child of
11801180+ * parent XML node.
11811181+ */
11821182+ nextSibling(txn: YTransaction | undefined): any;
11831183+ /**
11841184+ * Returns a previous XML sibling node of this XMl node.
11851185+ * It can be either `YXmlElement`, `YXmlText` or `undefined` if current node is a first child
11861186+ * of parent XML node.
11871187+ */
11881188+ prevSibling(txn: YTransaction | undefined): any;
11891189+ /**
11901190+ * Returns a parent `YXmlElement` node or `undefined` if current node has no parent assigned.
11911191+ */
11921192+ parent(txn: YTransaction | undefined): any;
11931193+ /**
11941194+ * Returns a string representation of this XML node.
11951195+ */
11961196+ toString(txn: YTransaction | undefined): string;
11971197+ /**
11981198+ * Sets a `name` and `value` as new attribute for this XML node. If an attribute with the same
11991199+ * `name` already existed on that node, its value with be overridden with a provided one.
12001200+ * This method accepts any JavaScript value, not just strings.
12011201+ */
12021202+ setAttribute(name: string, value: any, txn: YTransaction | undefined): void;
12031203+ /**
12041204+ * Returns a value of an attribute given its `name` as any JS value. If no attribute with such name existed,
12051205+ * `undefined` will be returned.
12061206+ */
12071207+ getAttribute(name: string, txn: YTransaction | undefined): any;
12081208+ /**
12091209+ * Removes an attribute from this XML node, given its `name`.
12101210+ */
12111211+ removeAttribute(name: string, txn: YTransaction | undefined): void;
12121212+ /**
12131213+ * Returns an iterator that enables to traverse over all attributes of this XML node in
12141214+ * unspecified order. This method returns attribute values as their original JS values,
12151215+ * not just as strings.
12161216+ */
12171217+ attributes(txn: YTransaction | undefined): any;
12181218+ /**
12191219+ * Returns an iterator that enables a deep traversal of this XML node - starting from first
12201220+ * child over this XML node successors using depth-first strategy.
12211221+ */
12221222+ treeWalker(txn: YTransaction | undefined): Array<any>;
12231223+ /**
12241224+ * Subscribes to all operations happening over this instance of `YXmlElement`. All changes are
12251225+ * batched and eventually triggered during transaction commit phase.
12261226+ */
12271227+ observe(callback: Function): void;
12281228+ /**
12291229+ * Unsubscribes a callback previously subscribed with `observe` method.
12301230+ */
12311231+ unobserve(callback: Function): boolean;
12321232+ /**
12331233+ * Subscribes to all operations happening over this Y shared type, as well as events in
12341234+ * shared types stored within this one. All changes are batched and eventually triggered
12351235+ * during transaction commit phase.
12361236+ */
12371237+ observeDeep(callback: Function): void;
12381238+ /**
12391239+ * Unsubscribes a callback previously subscribed with `observeDeep` method.
12401240+ */
12411241+ unobserveDeep(callback: Function): boolean;
12421242+ readonly type: number;
12431243+ /**
12441244+ * Gets unique logical identifier of this type, shared across peers collaborating on the same
12451245+ * document.
12461246+ */
12471247+ readonly id: any;
12481248+ /**
12491249+ * Returns true if this is a preliminary instance of `YXmlElement`.
12501250+ *
12511251+ * Preliminary instances can be nested into other shared data types.
12521252+ * Once a preliminary instance has been inserted this way, it becomes integrated into ywasm
12531253+ * document store and cannot be nested again: attempt to do so will result in an exception.
12541254+ */
12551255+ readonly prelim: boolean;
12561256+}
12571257+/**
12581258+ * Event generated by `YXmlElement.observe` method. Emitted during transaction commit phase.
12591259+ */
12601260+export class YXmlEvent {
12611261+ private constructor();
12621262+ free(): void;
12631263+ /**
12641264+ * Returns an array of keys and indexes creating a path from root type down to current instance
12651265+ * of shared type (accessible via `target` getter).
12661266+ */
12671267+ path(): any;
12681268+ /**
12691269+ * Returns a current shared type instance, that current event changes refer to.
12701270+ */
12711271+ readonly target: any;
12721272+ readonly origin: any;
12731273+ /**
12741274+ * Returns a list of attribute changes made over corresponding `YXmlText` collection within
12751275+ * bounds of current transaction. These changes follow a format:
12761276+ *
12771277+ * - { action: 'add'|'update'|'delete', oldValue: string|undefined, newValue: string|undefined }
12781278+ */
12791279+ readonly keys: any;
12801280+ /**
12811281+ * Returns a list of XML child node changes made over corresponding `YXmlElement` collection
12821282+ * within bounds of current transaction. These changes follow a format:
12831283+ *
12841284+ * - { insert: (YXmlText|YXmlElement)[] }
12851285+ * - { delete: number }
12861286+ * - { retain: number }
12871287+ */
12881288+ readonly delta: any;
12891289+}
12901290+/**
12911291+ * Represents a list of `YXmlElement` and `YXmlText` types.
12921292+ * A `YXmlFragment` is similar to a `YXmlElement`, but it does not have a
12931293+ * nodeName and it does not have attributes. Though it can be bound to a DOM
12941294+ * element - in this case the attributes and the nodeName are not shared
12951295+ */
12961296+export class YXmlFragment {
12971297+ free(): void;
12981298+ constructor(children: any[]);
12991299+ /**
13001300+ * Checks if current shared type reference is alive and has not been deleted by its parent collection.
13011301+ * This method only works on already integrated shared types and will return false is current
13021302+ * type is preliminary (has not been integrated into document).
13031303+ */
13041304+ alive(txn: YTransaction): boolean;
13051305+ /**
13061306+ * Returns a number of child XML nodes stored within this `YXMlElement` instance.
13071307+ */
13081308+ length(txn: YTransaction | undefined): number;
13091309+ insert(index: number, xml_node: any, txn: YTransaction | undefined): void;
13101310+ push(xml_node: any, txn: YTransaction | undefined): void;
13111311+ delete(index: number, length: number | null | undefined, txn: YTransaction | undefined): void;
13121312+ /**
13131313+ * Returns a first child of this XML node.
13141314+ * It can be either `YXmlElement`, `YXmlText` or `undefined` if current node has not children.
13151315+ */
13161316+ firstChild(txn: YTransaction | undefined): any;
13171317+ /**
13181318+ * Returns a string representation of this XML node.
13191319+ */
13201320+ toString(txn: YTransaction | undefined): string;
13211321+ /**
13221322+ * Returns an iterator that enables a deep traversal of this XML node - starting from first
13231323+ * child over this XML node successors using depth-first strategy.
13241324+ */
13251325+ treeWalker(txn: YTransaction | undefined): Array<any>;
13261326+ /**
13271327+ * Subscribes to all operations happening over this instance of `YXmlFragment`. All changes are
13281328+ * batched and eventually triggered during transaction commit phase.
13291329+ */
13301330+ observe(callback: Function): void;
13311331+ /**
13321332+ * Unsubscribes a callback previously subscribed with `observe` method.
13331333+ */
13341334+ unobserve(callback: Function): boolean;
13351335+ /**
13361336+ * Subscribes to all operations happening over this Y shared type, as well as events in
13371337+ * shared types stored within this one. All changes are batched and eventually triggered
13381338+ * during transaction commit phase.
13391339+ */
13401340+ observeDeep(callback: Function): void;
13411341+ /**
13421342+ * Unsubscribes a callback previously subscribed with `observeDeep` method.
13431343+ */
13441344+ unobserveDeep(callback: Function): boolean;
13451345+ readonly type: number;
13461346+ /**
13471347+ * Gets unique logical identifier of this type, shared across peers collaborating on the same
13481348+ * document.
13491349+ */
13501350+ readonly id: any;
13511351+ /**
13521352+ * Returns true if this is a preliminary instance of `YXmlFragment`.
13531353+ *
13541354+ * Preliminary instances can be nested into other shared data types.
13551355+ * Once a preliminary instance has been inserted this way, it becomes integrated into ywasm
13561356+ * document store and cannot be nested again: attempt to do so will result in an exception.
13571357+ */
13581358+ readonly prelim: boolean;
13591359+}
13601360+/**
13611361+ * A shared data type used for collaborative text editing, that can be used in a context of
13621362+ * `YXmlElement` nodee. It enables multiple users to add and remove chunks of text in efficient
13631363+ * manner. This type is internally represented as a mutable double-linked list of text chunks
13641364+ * - an optimization occurs during `YTransaction.commit`, which allows to squash multiple
13651365+ * consecutively inserted characters together as a single chunk of text even between transaction
13661366+ * boundaries in order to preserve more efficient memory model.
13671367+ *
13681368+ * Just like `YXmlElement`, `YXmlText` can be marked with extra metadata in form of attributes.
13691369+ *
13701370+ * `YXmlText` structure internally uses UTF-8 encoding and its length is described in a number of
13711371+ * bytes rather than individual characters (a single UTF-8 code point can consist of many bytes).
13721372+ *
13731373+ * Like all Yrs shared data types, `YXmlText` is resistant to the problem of interleaving (situation
13741374+ * when characters inserted one after another may interleave with other peers concurrent inserts
13751375+ * after merging all updates together). In case of Yrs conflict resolution is solved by using
13761376+ * unique document id to determine correct and consistent ordering.
13771377+ */
13781378+export class YXmlText {
13791379+ free(): void;
13801380+ constructor(text: string | null | undefined, attributes: any);
13811381+ /**
13821382+ * Checks if current shared type reference is alive and has not been deleted by its parent collection.
13831383+ * This method only works on already integrated shared types and will return false is current
13841384+ * type is preliminary (has not been integrated into document).
13851385+ */
13861386+ alive(txn: YTransaction): boolean;
13871387+ /**
13881388+ * Returns length of an underlying string stored in this `YXmlText` instance,
13891389+ * understood as a number of UTF-8 encoded bytes.
13901390+ */
13911391+ length(txn: YTransaction | undefined): number;
13921392+ /**
13931393+ * Inserts a given `chunk` of text into this `YXmlText` instance, starting at a given `index`.
13941394+ *
13951395+ * Optional object with defined `attributes` will be used to wrap provided text `chunk`
13961396+ * with a formatting blocks.
13971397+ */
13981398+ insert(index: number, chunk: string, attributes: any, txn: YTransaction | undefined): void;
13991399+ /**
14001400+ * Formats text within bounds specified by `index` and `len` with a given formatting
14011401+ * attributes.
14021402+ */
14031403+ format(index: number, length: number, attributes: any, txn: YTransaction | undefined): void;
14041404+ quote(lower: number | null | undefined, upper: number | null | undefined, lower_open: boolean | null | undefined, upper_open: boolean | null | undefined, txn: YTransaction | undefined): YWeakLink;
14051405+ /**
14061406+ * Returns the Delta representation of this YXmlText type.
14071407+ */
14081408+ toDelta(snapshot: any, prev_snapshot: any, compute_ychange: Function | null | undefined, txn: YTransaction | undefined): Array<any>;
14091409+ /**
14101410+ * Inserts a given `embed` object into this `YXmlText` instance, starting at a given `index`.
14111411+ *
14121412+ * Optional object with defined `attributes` will be used to wrap provided `embed`
14131413+ * with a formatting blocks.`attributes` are only supported for a `YXmlText` instance which
14141414+ * already has been integrated into document store.
14151415+ */
14161416+ insertEmbed(index: number, embed: any, attributes: any, txn: YTransaction | undefined): void;
14171417+ /**
14181418+ * Appends a given `chunk` of text at the end of `YXmlText` instance.
14191419+ *
14201420+ * Optional object with defined `attributes` will be used to wrap provided text `chunk`
14211421+ * with a formatting blocks.
14221422+ */
14231423+ push(chunk: string, attributes: any, txn: YTransaction | undefined): void;
14241424+ applyDelta(delta: Array<any>, txn: YTransaction | undefined): void;
14251425+ /**
14261426+ * Deletes a specified range of characters, starting at a given `index`.
14271427+ * Both `index` and `length` are counted in terms of a number of UTF-8 character bytes.
14281428+ */
14291429+ delete(index: number, length: number, txn: YTransaction | undefined): void;
14301430+ /**
14311431+ * Returns a next XML sibling node of this XMl node.
14321432+ * It can be either `YXmlElement`, `YXmlText` or `undefined` if current node is a last child of
14331433+ * parent XML node.
14341434+ */
14351435+ nextSibling(txn: YTransaction | undefined): any;
14361436+ /**
14371437+ * Returns a previous XML sibling node of this XMl node.
14381438+ * It can be either `YXmlElement`, `YXmlText` or `undefined` if current node is a first child
14391439+ * of parent XML node.
14401440+ */
14411441+ prevSibling(txn: YTransaction | undefined): any;
14421442+ /**
14431443+ * Returns a parent `YXmlElement` node or `undefined` if current node has no parent assigned.
14441444+ */
14451445+ parent(txn: YTransaction | undefined): any;
14461446+ /**
14471447+ * Returns an underlying string stored in this `YXmlText` instance.
14481448+ */
14491449+ toString(txn: YTransaction | undefined): string;
14501450+ /**
14511451+ * Sets a `name` and `value` as new attribute for this XML node. If an attribute with the same
14521452+ * `name` already existed on that node, its value with be overridden with a provided one.
14531453+ * This method accepts any JavaScript value, not just strings.
14541454+ */
14551455+ setAttribute(name: string, value: any, txn: YTransaction | undefined): void;
14561456+ /**
14571457+ * Returns a value of an attribute given its `name` as any JS value. If no attribute with such name existed,
14581458+ * `undefined` will be returned.
14591459+ */
14601460+ getAttribute(name: string, txn: YTransaction | undefined): any;
14611461+ /**
14621462+ * Removes an attribute from this XML node, given its `name`.
14631463+ */
14641464+ removeAttribute(name: string, txn: YTransaction | undefined): void;
14651465+ /**
14661466+ * Returns an iterator that enables to traverse over all attributes of this XML node in
14671467+ * unspecified order. This method returns attribute values as their original JS values,
14681468+ * not just as strings.
14691469+ */
14701470+ attributes(txn: YTransaction | undefined): any;
14711471+ /**
14721472+ * Subscribes to all operations happening over this instance of `YXmlText`. All changes are
14731473+ * batched and eventually triggered during transaction commit phase.
14741474+ */
14751475+ observe(callback: Function): void;
14761476+ /**
14771477+ * Unsubscribes a callback previously subscribed with `observe` method.
14781478+ */
14791479+ unobserve(callback: Function): boolean;
14801480+ /**
14811481+ * Subscribes to all operations happening over this Y shared type, as well as events in
14821482+ * shared types stored within this one. All changes are batched and eventually triggered
14831483+ * during transaction commit phase.
14841484+ */
14851485+ observeDeep(callback: Function): void;
14861486+ /**
14871487+ * Unsubscribes a callback previously subscribed with `observe` method.
14881488+ */
14891489+ unobserveDeep(callback: Function): boolean;
14901490+ readonly type: number;
14911491+ /**
14921492+ * Gets unique logical identifier of this type, shared across peers collaborating on the same
14931493+ * document.
14941494+ */
14951495+ readonly id: any;
14961496+ /**
14971497+ * Returns true if this is a preliminary instance of `YXmlText`.
14981498+ *
14991499+ * Preliminary instances can be nested into other shared data types.
15001500+ * Once a preliminary instance has been inserted this way, it becomes integrated into ywasm
15011501+ * document store and cannot be nested again: attempt to do so will result in an exception.
15021502+ */
15031503+ readonly prelim: boolean;
15041504+}
15051505+/**
15061506+ * Event generated by `YXmlText.observe` method. Emitted during transaction commit phase.
15071507+ */
15081508+export class YXmlTextEvent {
15091509+ private constructor();
15101510+ free(): void;
15111511+ /**
15121512+ * Returns an array of keys and indexes creating a path from root type down to current instance
15131513+ * of shared type (accessible via `target` getter).
15141514+ */
15151515+ path(): any;
15161516+ /**
15171517+ * Returns a current shared type instance, that current event changes refer to.
15181518+ */
15191519+ readonly target: any;
15201520+ readonly origin: any;
15211521+ /**
15221522+ * Returns a list of text changes made over corresponding `YText` collection within
15231523+ * bounds of current transaction. These changes follow a format:
15241524+ *
15251525+ * - { insert: string, attributes: any|undefined }
15261526+ * - { delete: number }
15271527+ * - { retain: number, attributes: any|undefined }
15281528+ */
15291529+ readonly delta: any;
15301530+ /**
15311531+ * Returns a list of attribute changes made over corresponding `YXmlText` collection within
15321532+ * bounds of current transaction. These changes follow a format:
15331533+ *
15341534+ * - { action: 'add'|'update'|'delete', oldValue: string|undefined, newValue: string|undefined }
15351535+ */
15361536+ readonly keys: any;
15371537+}
+5022
src/ywasm/ywasm.js
···11+let imports = {};
22+imports["__wbindgen_placeholder__"] = module.exports;
33+let wasm;
44+const { TextDecoder, TextEncoder } = require(`util`);
55+66+function addToExternrefTable0(obj) {
77+ const idx = wasm.__externref_table_alloc();
88+ wasm.__wbindgen_export_2.set(idx, obj);
99+ return idx;
1010+}
1111+1212+function handleError(f, args) {
1313+ try {
1414+ return f.apply(this, args);
1515+ } catch (e) {
1616+ const idx = addToExternrefTable0(e);
1717+ wasm.__wbindgen_exn_store(idx);
1818+ }
1919+}
2020+2121+let cachedTextDecoder = new TextDecoder("utf-8", {
2222+ ignoreBOM: true,
2323+ fatal: true,
2424+});
2525+2626+cachedTextDecoder.decode();
2727+2828+let cachedUint8ArrayMemory0 = null;
2929+3030+function getUint8ArrayMemory0() {
3131+ if (
3232+ cachedUint8ArrayMemory0 === null ||
3333+ cachedUint8ArrayMemory0.byteLength === 0
3434+ ) {
3535+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
3636+ }
3737+ return cachedUint8ArrayMemory0;
3838+}
3939+4040+function getStringFromWasm0(ptr, len) {
4141+ ptr = ptr >>> 0;
4242+ return cachedTextDecoder.decode(
4343+ getUint8ArrayMemory0().subarray(ptr, ptr + len),
4444+ );
4545+}
4646+4747+let WASM_VECTOR_LEN = 0;
4848+4949+let cachedTextEncoder = new TextEncoder("utf-8");
5050+5151+const encodeString =
5252+ typeof cachedTextEncoder.encodeInto === "function"
5353+ ? function (arg, view) {
5454+ return cachedTextEncoder.encodeInto(arg, view);
5555+ }
5656+ : function (arg, view) {
5757+ const buf = cachedTextEncoder.encode(arg);
5858+ view.set(buf);
5959+ return {
6060+ read: arg.length,
6161+ written: buf.length,
6262+ };
6363+ };
6464+6565+function passStringToWasm0(arg, malloc, realloc) {
6666+ if (realloc === undefined) {
6767+ const buf = cachedTextEncoder.encode(arg);
6868+ const ptr = malloc(buf.length, 1) >>> 0;
6969+ getUint8ArrayMemory0()
7070+ .subarray(ptr, ptr + buf.length)
7171+ .set(buf);
7272+ WASM_VECTOR_LEN = buf.length;
7373+ return ptr;
7474+ }
7575+7676+ let len = arg.length;
7777+ let ptr = malloc(len, 1) >>> 0;
7878+7979+ const mem = getUint8ArrayMemory0();
8080+8181+ let offset = 0;
8282+8383+ for (; offset < len; offset++) {
8484+ const code = arg.charCodeAt(offset);
8585+ if (code > 0x7f) break;
8686+ mem[ptr + offset] = code;
8787+ }
8888+8989+ if (offset !== len) {
9090+ if (offset !== 0) {
9191+ arg = arg.slice(offset);
9292+ }
9393+ ptr = realloc(ptr, len, (len = offset + arg.length * 3), 1) >>> 0;
9494+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
9595+ const ret = encodeString(arg, view);
9696+9797+ offset += ret.written;
9898+ ptr = realloc(ptr, len, offset, 1) >>> 0;
9999+ }
100100+101101+ WASM_VECTOR_LEN = offset;
102102+ return ptr;
103103+}
104104+105105+let cachedDataViewMemory0 = null;
106106+107107+function getDataViewMemory0() {
108108+ if (
109109+ cachedDataViewMemory0 === null ||
110110+ cachedDataViewMemory0.buffer.detached === true ||
111111+ (cachedDataViewMemory0.buffer.detached === undefined &&
112112+ cachedDataViewMemory0.buffer !== wasm.memory.buffer)
113113+ ) {
114114+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
115115+ }
116116+ return cachedDataViewMemory0;
117117+}
118118+119119+function isLikeNone(x) {
120120+ return x === undefined || x === null;
121121+}
122122+123123+function debugString(val) {
124124+ // primitive types
125125+ const type = typeof val;
126126+ if (type == "number" || type == "boolean" || val == null) {
127127+ return `${val}`;
128128+ }
129129+ if (type == "string") {
130130+ return `"${val}"`;
131131+ }
132132+ if (type == "symbol") {
133133+ const description = val.description;
134134+ if (description == null) {
135135+ return "Symbol";
136136+ } else {
137137+ return `Symbol(${description})`;
138138+ }
139139+ }
140140+ if (type == "function") {
141141+ const name = val.name;
142142+ if (typeof name == "string" && name.length > 0) {
143143+ return `Function(${name})`;
144144+ } else {
145145+ return "Function";
146146+ }
147147+ }
148148+ // objects
149149+ if (Array.isArray(val)) {
150150+ const length = val.length;
151151+ let debug = "[";
152152+ if (length > 0) {
153153+ debug += debugString(val[0]);
154154+ }
155155+ for (let i = 1; i < length; i++) {
156156+ debug += ", " + debugString(val[i]);
157157+ }
158158+ debug += "]";
159159+ return debug;
160160+ }
161161+ // Test for built-in
162162+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
163163+ let className;
164164+ if (builtInMatches && builtInMatches.length > 1) {
165165+ className = builtInMatches[1];
166166+ } else {
167167+ // Failed to match the standard '[object ClassName]'
168168+ return toString.call(val);
169169+ }
170170+ if (className == "Object") {
171171+ // we're a user defined class or Object
172172+ // JSON.stringify avoids problems with cycles, and is generally much
173173+ // easier than looping through ownProperties of `val`.
174174+ try {
175175+ return "Object(" + JSON.stringify(val) + ")";
176176+ } catch (_) {
177177+ return "Object";
178178+ }
179179+ }
180180+ // errors
181181+ if (val instanceof Error) {
182182+ return `${val.name}: ${val.message}\n${val.stack}`;
183183+ }
184184+ // TODO we could test for more things here, like `Set`s and `Map`s.
185185+ return className;
186186+}
187187+188188+function takeFromExternrefTable0(idx) {
189189+ const value = wasm.__wbindgen_export_2.get(idx);
190190+ wasm.__externref_table_dealloc(idx);
191191+ return value;
192192+}
193193+194194+function _assertClass(instance, klass) {
195195+ if (!(instance instanceof klass)) {
196196+ throw new Error(`expected instance of ${klass.name}`);
197197+ }
198198+}
199199+200200+function passArrayJsValueToWasm0(array, malloc) {
201201+ const ptr = malloc(array.length * 4, 4) >>> 0;
202202+ for (let i = 0; i < array.length; i++) {
203203+ const add = addToExternrefTable0(array[i]);
204204+ getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
205205+ }
206206+ WASM_VECTOR_LEN = array.length;
207207+ return ptr;
208208+}
209209+/**
210210+ * When called will call console log errors whenever internal panic is called from within
211211+ * WebAssembly module.
212212+ */
213213+module.exports.setPanicHook = function () {
214214+ wasm.setPanicHook();
215215+};
216216+217217+/**
218218+ * Encodes a state vector of a given ywasm document into its binary representation using lib0 v1
219219+ * encoding. State vector is a compact representation of updates performed on a given document and
220220+ * can be used by `encode_state_as_update` on remote peer to generate a delta update payload to
221221+ * synchronize changes between peers.
222222+ *
223223+ * Example:
224224+ *
225225+ * ```javascript
226226+ * import {YDoc, encodeStateVector, encodeStateAsUpdate, applyUpdate} from 'ywasm'
227227+ *
228228+ * /// document on machine A
229229+ * const localDoc = new YDoc()
230230+ * const localSV = encodeStateVector(localDoc)
231231+ *
232232+ * // document on machine B
233233+ * const remoteDoc = new YDoc()
234234+ * const remoteDelta = encodeStateAsUpdate(remoteDoc, localSV)
235235+ *
236236+ * applyUpdate(localDoc, remoteDelta)
237237+ * ```
238238+ * @param {YDoc} doc
239239+ * @returns {Uint8Array}
240240+ */
241241+module.exports.encodeStateVector = function (doc) {
242242+ _assertClass(doc, YDoc);
243243+ const ret = wasm.encodeStateVector(doc.__wbg_ptr);
244244+ if (ret[2]) {
245245+ throw takeFromExternrefTable0(ret[1]);
246246+ }
247247+ return takeFromExternrefTable0(ret[0]);
248248+};
249249+250250+/**
251251+ * Returns a string dump representation of a given `update` encoded using lib0 v1 encoding.
252252+ * @param {Uint8Array} update
253253+ * @returns {string}
254254+ */
255255+module.exports.debugUpdateV1 = function (update) {
256256+ let deferred2_0;
257257+ let deferred2_1;
258258+ try {
259259+ const ret = wasm.debugUpdateV1(update);
260260+ var ptr1 = ret[0];
261261+ var len1 = ret[1];
262262+ if (ret[3]) {
263263+ ptr1 = 0;
264264+ len1 = 0;
265265+ throw takeFromExternrefTable0(ret[2]);
266266+ }
267267+ deferred2_0 = ptr1;
268268+ deferred2_1 = len1;
269269+ return getStringFromWasm0(ptr1, len1);
270270+ } finally {
271271+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
272272+ }
273273+};
274274+275275+/**
276276+ * Returns a string dump representation of a given `update` encoded using lib0 v2 encoding.
277277+ * @param {Uint8Array} update
278278+ * @returns {string}
279279+ */
280280+module.exports.debugUpdateV2 = function (update) {
281281+ let deferred2_0;
282282+ let deferred2_1;
283283+ try {
284284+ const ret = wasm.debugUpdateV2(update);
285285+ var ptr1 = ret[0];
286286+ var len1 = ret[1];
287287+ if (ret[3]) {
288288+ ptr1 = 0;
289289+ len1 = 0;
290290+ throw takeFromExternrefTable0(ret[2]);
291291+ }
292292+ deferred2_0 = ptr1;
293293+ deferred2_1 = len1;
294294+ return getStringFromWasm0(ptr1, len1);
295295+ } finally {
296296+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
297297+ }
298298+};
299299+300300+/**
301301+ * Merges a sequence of updates (encoded using lib0 v1 encoding) together, producing another
302302+ * update (also lib0 v1 encoded) in the result. Returned binary is a combination of all input
303303+ * `updates`, compressed.
304304+ *
305305+ * Returns an error whenever any of the input updates couldn't be decoded.
306306+ * @param {Array<any>} updates
307307+ * @returns {Uint8Array}
308308+ */
309309+module.exports.mergeUpdatesV1 = function (updates) {
310310+ const ret = wasm.mergeUpdatesV1(updates);
311311+ if (ret[2]) {
312312+ throw takeFromExternrefTable0(ret[1]);
313313+ }
314314+ return takeFromExternrefTable0(ret[0]);
315315+};
316316+317317+/**
318318+ * Merges a sequence of updates (encoded using lib0 v2 encoding) together, producing another
319319+ * update (also lib0 v2 encoded) in the result. Returned binary is a combination of all input
320320+ * `updates`, compressed.
321321+ *
322322+ * Returns an error whenever any of the input updates couldn't be decoded.
323323+ * @param {Array<any>} updates
324324+ * @returns {Uint8Array}
325325+ */
326326+module.exports.mergeUpdatesV2 = function (updates) {
327327+ const ret = wasm.mergeUpdatesV2(updates);
328328+ if (ret[2]) {
329329+ throw takeFromExternrefTable0(ret[1]);
330330+ }
331331+ return takeFromExternrefTable0(ret[0]);
332332+};
333333+334334+/**
335335+ * Encodes all updates that have happened since a given version `vector` into a compact delta
336336+ * representation using lib0 v1 encoding. If `vector` parameter has not been provided, generated
337337+ * delta payload will contain all changes of a current ywasm document, working effectivelly as its
338338+ * state snapshot.
339339+ *
340340+ * Example:
341341+ *
342342+ * ```javascript
343343+ * import {YDoc, encodeStateVector, encodeStateAsUpdate, applyUpdate} from 'ywasm'
344344+ *
345345+ * /// document on machine A
346346+ * const localDoc = new YDoc()
347347+ * const localSV = encodeStateVector(localDoc)
348348+ *
349349+ * // document on machine B
350350+ * const remoteDoc = new YDoc()
351351+ * const remoteDelta = encodeStateAsUpdate(remoteDoc, localSV)
352352+ *
353353+ * applyUpdate(localDoc, remoteDelta)
354354+ * ```
355355+ * @param {YDoc} doc
356356+ * @param {Uint8Array | null} [vector]
357357+ * @returns {Uint8Array}
358358+ */
359359+module.exports.encodeStateAsUpdate = function (doc, vector) {
360360+ _assertClass(doc, YDoc);
361361+ const ret = wasm.encodeStateAsUpdate(
362362+ doc.__wbg_ptr,
363363+ isLikeNone(vector) ? 0 : addToExternrefTable0(vector),
364364+ );
365365+ if (ret[2]) {
366366+ throw takeFromExternrefTable0(ret[1]);
367367+ }
368368+ return takeFromExternrefTable0(ret[0]);
369369+};
370370+371371+/**
372372+ * Encodes all updates that have happened since a given version `vector` into a compact delta
373373+ * representation using lib0 v2 encoding. If `vector` parameter has not been provided, generated
374374+ * delta payload will contain all changes of a current ywasm document, working effectivelly as its
375375+ * state snapshot.
376376+ *
377377+ * Example:
378378+ *
379379+ * ```javascript
380380+ * import {YDoc, encodeStateVector, encodeStateAsUpdate, applyUpdate} from 'ywasm'
381381+ *
382382+ * /// document on machine A
383383+ * const localDoc = new YDoc()
384384+ * const localSV = encodeStateVector(localDoc)
385385+ *
386386+ * // document on machine B
387387+ * const remoteDoc = new YDoc()
388388+ * const remoteDelta = encodeStateAsUpdateV2(remoteDoc, localSV)
389389+ *
390390+ * applyUpdate(localDoc, remoteDelta)
391391+ * ```
392392+ * @param {YDoc} doc
393393+ * @param {Uint8Array | null} [vector]
394394+ * @returns {Uint8Array}
395395+ */
396396+module.exports.encodeStateAsUpdateV2 = function (doc, vector) {
397397+ _assertClass(doc, YDoc);
398398+ const ret = wasm.encodeStateAsUpdateV2(
399399+ doc.__wbg_ptr,
400400+ isLikeNone(vector) ? 0 : addToExternrefTable0(vector),
401401+ );
402402+ if (ret[2]) {
403403+ throw takeFromExternrefTable0(ret[1]);
404404+ }
405405+ return takeFromExternrefTable0(ret[0]);
406406+};
407407+408408+/**
409409+ * Applies delta update generated by the remote document replica to a current document. This
410410+ * method assumes that a payload maintains lib0 v1 encoding format.
411411+ *
412412+ * Example:
413413+ *
414414+ * ```javascript
415415+ * import {YDoc, encodeStateVector, encodeStateAsUpdate, applyUpdate} from 'ywasm'
416416+ *
417417+ * /// document on machine A
418418+ * const localDoc = new YDoc()
419419+ * const localSV = encodeStateVector(localDoc)
420420+ *
421421+ * // document on machine B
422422+ * const remoteDoc = new YDoc()
423423+ * const remoteDelta = encodeStateAsUpdate(remoteDoc, localSV)
424424+ *
425425+ * applyUpdateV2(localDoc, remoteDelta)
426426+ * ```
427427+ * @param {YDoc} doc
428428+ * @param {Uint8Array} update
429429+ * @param {any} origin
430430+ */
431431+module.exports.applyUpdate = function (doc, update, origin) {
432432+ _assertClass(doc, YDoc);
433433+ const ret = wasm.applyUpdate(doc.__wbg_ptr, update, origin);
434434+ if (ret[1]) {
435435+ throw takeFromExternrefTable0(ret[0]);
436436+ }
437437+};
438438+439439+/**
440440+ * Applies delta update generated by the remote document replica to a current document. This
441441+ * method assumes that a payload maintains lib0 v2 encoding format.
442442+ *
443443+ * Example:
444444+ *
445445+ * ```javascript
446446+ * import {YDoc, encodeStateVector, encodeStateAsUpdate, applyUpdate} from 'ywasm'
447447+ *
448448+ * /// document on machine A
449449+ * const localDoc = new YDoc()
450450+ * const localSV = encodeStateVector(localDoc)
451451+ *
452452+ * // document on machine B
453453+ * const remoteDoc = new YDoc()
454454+ * const remoteDelta = encodeStateAsUpdateV2(remoteDoc, localSV)
455455+ *
456456+ * applyUpdateV2(localDoc, remoteDelta)
457457+ * ```
458458+ * @param {YDoc} doc
459459+ * @param {Uint8Array} update
460460+ * @param {any} origin
461461+ */
462462+module.exports.applyUpdateV2 = function (doc, update, origin) {
463463+ _assertClass(doc, YDoc);
464464+ const ret = wasm.applyUpdateV2(doc.__wbg_ptr, update, origin);
465465+ if (ret[1]) {
466466+ throw takeFromExternrefTable0(ret[0]);
467467+ }
468468+};
469469+470470+/**
471471+ * @param {YDoc} doc
472472+ * @returns {any}
473473+ */
474474+module.exports.snapshot = function (doc) {
475475+ _assertClass(doc, YDoc);
476476+ const ret = wasm.snapshot(doc.__wbg_ptr);
477477+ if (ret[2]) {
478478+ throw takeFromExternrefTable0(ret[1]);
479479+ }
480480+ return takeFromExternrefTable0(ret[0]);
481481+};
482482+483483+/**
484484+ * @param {any} snap1
485485+ * @param {any} snap2
486486+ * @returns {boolean}
487487+ */
488488+module.exports.equalSnapshots = function (snap1, snap2) {
489489+ const ret = wasm.equalSnapshots(snap1, snap2);
490490+ return ret !== 0;
491491+};
492492+493493+function getArrayU8FromWasm0(ptr, len) {
494494+ ptr = ptr >>> 0;
495495+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
496496+}
497497+/**
498498+ * @param {any} snapshot
499499+ * @returns {Uint8Array}
500500+ */
501501+module.exports.encodeSnapshotV1 = function (snapshot) {
502502+ const ret = wasm.encodeSnapshotV1(snapshot);
503503+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
504504+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
505505+ return v1;
506506+};
507507+508508+/**
509509+ * @param {any} snapshot
510510+ * @returns {Uint8Array}
511511+ */
512512+module.exports.encodeSnapshotV2 = function (snapshot) {
513513+ const ret = wasm.encodeSnapshotV2(snapshot);
514514+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
515515+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
516516+ return v1;
517517+};
518518+519519+function passArray8ToWasm0(arg, malloc) {
520520+ const ptr = malloc(arg.length * 1, 1) >>> 0;
521521+ getUint8ArrayMemory0().set(arg, ptr / 1);
522522+ WASM_VECTOR_LEN = arg.length;
523523+ return ptr;
524524+}
525525+/**
526526+ * @param {Uint8Array} snapshot
527527+ * @returns {any}
528528+ */
529529+module.exports.decodeSnapshotV2 = function (snapshot) {
530530+ const ptr0 = passArray8ToWasm0(snapshot, wasm.__wbindgen_malloc);
531531+ const len0 = WASM_VECTOR_LEN;
532532+ const ret = wasm.decodeSnapshotV2(ptr0, len0);
533533+ if (ret[2]) {
534534+ throw takeFromExternrefTable0(ret[1]);
535535+ }
536536+ return takeFromExternrefTable0(ret[0]);
537537+};
538538+539539+/**
540540+ * @param {Uint8Array} snapshot
541541+ * @returns {any}
542542+ */
543543+module.exports.decodeSnapshotV1 = function (snapshot) {
544544+ const ptr0 = passArray8ToWasm0(snapshot, wasm.__wbindgen_malloc);
545545+ const len0 = WASM_VECTOR_LEN;
546546+ const ret = wasm.decodeSnapshotV1(ptr0, len0);
547547+ if (ret[2]) {
548548+ throw takeFromExternrefTable0(ret[1]);
549549+ }
550550+ return takeFromExternrefTable0(ret[0]);
551551+};
552552+553553+/**
554554+ * @param {YDoc} doc
555555+ * @param {any} snapshot
556556+ * @returns {Uint8Array}
557557+ */
558558+module.exports.encodeStateFromSnapshotV1 = function (doc, snapshot) {
559559+ _assertClass(doc, YDoc);
560560+ const ret = wasm.encodeStateFromSnapshotV1(doc.__wbg_ptr, snapshot);
561561+ if (ret[3]) {
562562+ throw takeFromExternrefTable0(ret[2]);
563563+ }
564564+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
565565+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
566566+ return v1;
567567+};
568568+569569+/**
570570+ * @param {YDoc} doc
571571+ * @param {any} snapshot
572572+ * @returns {Uint8Array}
573573+ */
574574+module.exports.encodeStateFromSnapshotV2 = function (doc, snapshot) {
575575+ _assertClass(doc, YDoc);
576576+ const ret = wasm.encodeStateFromSnapshotV2(doc.__wbg_ptr, snapshot);
577577+ if (ret[3]) {
578578+ throw takeFromExternrefTable0(ret[2]);
579579+ }
580580+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
581581+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
582582+ return v1;
583583+};
584584+585585+/**
586586+ * Retrieves a sticky index corresponding to a given human-readable `index` pointing into
587587+ * the shared `ytype`. Unlike standard indexes sticky indexes enables to track
588588+ * the location inside of a shared y-types, even in the face of concurrent updates.
589589+ *
590590+ * If association is >= 0, the resulting position will point to location **after** the referenced index.
591591+ * If association is < 0, the resulting position will point to location **before** the referenced index.
592592+ * @param {any} ytype
593593+ * @param {number} index
594594+ * @param {number} assoc
595595+ * @param {YTransaction | undefined} txn
596596+ * @returns {any}
597597+ */
598598+module.exports.createRelativePositionFromTypeIndex = function (
599599+ ytype,
600600+ index,
601601+ assoc,
602602+ txn,
603603+) {
604604+ const ret = wasm.createRelativePositionFromTypeIndex(
605605+ ytype,
606606+ index,
607607+ assoc,
608608+ txn,
609609+ );
610610+ if (ret[2]) {
611611+ throw takeFromExternrefTable0(ret[1]);
612612+ }
613613+ return takeFromExternrefTable0(ret[0]);
614614+};
615615+616616+/**
617617+ * Converts a sticky index (see: `createStickyIndexFromType`) into an object
618618+ * containing human-readable index.
619619+ * @param {any} rpos
620620+ * @param {YDoc} doc
621621+ * @returns {any}
622622+ */
623623+module.exports.createAbsolutePositionFromRelativePosition = function (
624624+ rpos,
625625+ doc,
626626+) {
627627+ _assertClass(doc, YDoc);
628628+ const ret = wasm.createAbsolutePositionFromRelativePosition(
629629+ rpos,
630630+ doc.__wbg_ptr,
631631+ );
632632+ if (ret[2]) {
633633+ throw takeFromExternrefTable0(ret[1]);
634634+ }
635635+ return takeFromExternrefTable0(ret[0]);
636636+};
637637+638638+/**
639639+ * Serializes sticky index created by `createStickyIndexFromType` into a binary
640640+ * payload.
641641+ * @param {any} rpos
642642+ * @returns {Uint8Array}
643643+ */
644644+module.exports.encodeRelativePosition = function (rpos) {
645645+ const ret = wasm.encodeRelativePosition(rpos);
646646+ if (ret[2]) {
647647+ throw takeFromExternrefTable0(ret[1]);
648648+ }
649649+ return takeFromExternrefTable0(ret[0]);
650650+};
651651+652652+/**
653653+ * Deserializes sticky index serialized previously by `encodeStickyIndex`.
654654+ * @param {Uint8Array} bin
655655+ * @returns {any}
656656+ */
657657+module.exports.decodeRelativePosition = function (bin) {
658658+ const ret = wasm.decodeRelativePosition(bin);
659659+ if (ret[2]) {
660660+ throw takeFromExternrefTable0(ret[1]);
661661+ }
662662+ return takeFromExternrefTable0(ret[0]);
663663+};
664664+665665+/**
666666+ * @param {any} a
667667+ * @param {any} b
668668+ * @returns {boolean}
669669+ */
670670+module.exports.compareRelativePositions = function (a, b) {
671671+ const ret = wasm.compareRelativePositions(a, b);
672672+ return ret !== 0;
673673+};
674674+675675+let cachedBigUint64ArrayMemory0 = null;
676676+677677+function getBigUint64ArrayMemory0() {
678678+ if (
679679+ cachedBigUint64ArrayMemory0 === null ||
680680+ cachedBigUint64ArrayMemory0.byteLength === 0
681681+ ) {
682682+ cachedBigUint64ArrayMemory0 = new BigUint64Array(wasm.memory.buffer);
683683+ }
684684+ return cachedBigUint64ArrayMemory0;
685685+}
686686+687687+function passArray64ToWasm0(arg, malloc) {
688688+ const ptr = malloc(arg.length * 8, 8) >>> 0;
689689+ getBigUint64ArrayMemory0().set(arg, ptr / 8);
690690+ WASM_VECTOR_LEN = arg.length;
691691+ return ptr;
692692+}
693693+/**
694694+ * @param {Awareness} awareness
695695+ * @param {BigUint64Array} clients
696696+ */
697697+module.exports.removeAwarenessStates = function (awareness, clients) {
698698+ _assertClass(awareness, Awareness);
699699+ const ptr0 = passArray64ToWasm0(clients, wasm.__wbindgen_malloc);
700700+ const len0 = WASM_VECTOR_LEN;
701701+ const ret = wasm.removeAwarenessStates(awareness.__wbg_ptr, ptr0, len0);
702702+ if (ret[1]) {
703703+ throw takeFromExternrefTable0(ret[0]);
704704+ }
705705+};
706706+707707+/**
708708+ * @param {Awareness} awareness
709709+ * @param {any} clients
710710+ * @returns {Uint8Array}
711711+ */
712712+module.exports.encodeAwarenessUpdate = function (awareness, clients) {
713713+ _assertClass(awareness, Awareness);
714714+ const ret = wasm.encodeAwarenessUpdate(awareness.__wbg_ptr, clients);
715715+ if (ret[2]) {
716716+ throw takeFromExternrefTable0(ret[1]);
717717+ }
718718+ return takeFromExternrefTable0(ret[0]);
719719+};
720720+721721+/**
722722+ * @param {Uint8Array} update
723723+ * @param {Function} modify
724724+ * @returns {Uint8Array}
725725+ */
726726+module.exports.modifyAwarenessUpdate = function (update, modify) {
727727+ const ret = wasm.modifyAwarenessUpdate(update, modify);
728728+ if (ret[2]) {
729729+ throw takeFromExternrefTable0(ret[1]);
730730+ }
731731+ return takeFromExternrefTable0(ret[0]);
732732+};
733733+734734+/**
735735+ * @param {Awareness} awareness
736736+ * @param {Uint8Array} update
737737+ * @param {any} _origin
738738+ */
739739+module.exports.applyAwarenessUpdate = function (awareness, update, _origin) {
740740+ _assertClass(awareness, Awareness);
741741+ const ret = wasm.applyAwarenessUpdate(awareness.__wbg_ptr, update, _origin);
742742+ if (ret[1]) {
743743+ throw takeFromExternrefTable0(ret[0]);
744744+ }
745745+};
746746+747747+const AwarenessFinalization =
748748+ typeof FinalizationRegistry === "undefined"
749749+ ? { register: () => {}, unregister: () => {} }
750750+ : new FinalizationRegistry((ptr) =>
751751+ wasm.__wbg_awareness_free(ptr >>> 0, 1),
752752+ );
753753+754754+class Awareness {
755755+ __destroy_into_raw() {
756756+ const ptr = this.__wbg_ptr;
757757+ this.__wbg_ptr = 0;
758758+ AwarenessFinalization.unregister(this);
759759+ return ptr;
760760+ }
761761+762762+ free() {
763763+ const ptr = this.__destroy_into_raw();
764764+ wasm.__wbg_awareness_free(ptr, 0);
765765+ }
766766+ /**
767767+ * @param {YDoc} doc
768768+ */
769769+ constructor(doc) {
770770+ _assertClass(doc, YDoc);
771771+ var ptr0 = doc.__destroy_into_raw();
772772+ const ret = wasm.awareness_new(ptr0);
773773+ this.__wbg_ptr = ret >>> 0;
774774+ AwarenessFinalization.register(this, this.__wbg_ptr, this);
775775+ return this;
776776+ }
777777+ /**
778778+ * @returns {YDoc}
779779+ */
780780+ get doc() {
781781+ const ret = wasm.awareness_doc(this.__wbg_ptr);
782782+ return YDoc.__wrap(ret);
783783+ }
784784+ /**
785785+ * @returns {Map<any, any>}
786786+ */
787787+ get meta() {
788788+ const ret = wasm.awareness_meta(this.__wbg_ptr);
789789+ if (ret[2]) {
790790+ throw takeFromExternrefTable0(ret[1]);
791791+ }
792792+ return takeFromExternrefTable0(ret[0]);
793793+ }
794794+ destroy() {
795795+ wasm.awareness_destroy(this.__wbg_ptr);
796796+ }
797797+ /**
798798+ * @returns {any}
799799+ */
800800+ getLocalState() {
801801+ const ret = wasm.awareness_getLocalState(this.__wbg_ptr);
802802+ if (ret[2]) {
803803+ throw takeFromExternrefTable0(ret[1]);
804804+ }
805805+ return takeFromExternrefTable0(ret[0]);
806806+ }
807807+ /**
808808+ * @param {any} state
809809+ */
810810+ setLocalState(state) {
811811+ const ret = wasm.awareness_setLocalState(this.__wbg_ptr, state);
812812+ if (ret[1]) {
813813+ throw takeFromExternrefTable0(ret[0]);
814814+ }
815815+ }
816816+ /**
817817+ * @param {string} key
818818+ * @param {any} value
819819+ */
820820+ setLocalStateField(key, value) {
821821+ const ptr0 = passStringToWasm0(
822822+ key,
823823+ wasm.__wbindgen_malloc,
824824+ wasm.__wbindgen_realloc,
825825+ );
826826+ const len0 = WASM_VECTOR_LEN;
827827+ const ret = wasm.awareness_setLocalStateField(
828828+ this.__wbg_ptr,
829829+ ptr0,
830830+ len0,
831831+ value,
832832+ );
833833+ if (ret[1]) {
834834+ throw takeFromExternrefTable0(ret[0]);
835835+ }
836836+ }
837837+ /**
838838+ * @returns {Map<any, any>}
839839+ */
840840+ getStates() {
841841+ const ret = wasm.awareness_getStates(this.__wbg_ptr);
842842+ if (ret[2]) {
843843+ throw takeFromExternrefTable0(ret[1]);
844844+ }
845845+ return takeFromExternrefTable0(ret[0]);
846846+ }
847847+ /**
848848+ * @param {string} event
849849+ * @param {Function} callback
850850+ */
851851+ on(event, callback) {
852852+ const ptr0 = passStringToWasm0(
853853+ event,
854854+ wasm.__wbindgen_malloc,
855855+ wasm.__wbindgen_realloc,
856856+ );
857857+ const len0 = WASM_VECTOR_LEN;
858858+ const ret = wasm.awareness_on(this.__wbg_ptr, ptr0, len0, callback);
859859+ if (ret[1]) {
860860+ throw takeFromExternrefTable0(ret[0]);
861861+ }
862862+ }
863863+ /**
864864+ * @param {string} event
865865+ * @param {Function} callback
866866+ * @returns {boolean}
867867+ */
868868+ off(event, callback) {
869869+ const ptr0 = passStringToWasm0(
870870+ event,
871871+ wasm.__wbindgen_malloc,
872872+ wasm.__wbindgen_realloc,
873873+ );
874874+ const len0 = WASM_VECTOR_LEN;
875875+ const ret = wasm.awareness_off(this.__wbg_ptr, ptr0, len0, callback);
876876+ if (ret[2]) {
877877+ throw takeFromExternrefTable0(ret[1]);
878878+ }
879879+ return ret[0] !== 0;
880880+ }
881881+}
882882+module.exports.Awareness = Awareness;
883883+884884+const YArrayFinalization =
885885+ typeof FinalizationRegistry === "undefined"
886886+ ? { register: () => {}, unregister: () => {} }
887887+ : new FinalizationRegistry((ptr) => wasm.__wbg_yarray_free(ptr >>> 0, 1));
888888+/**
889889+ * A collection used to store data in an indexed sequence structure. This type is internally
890890+ * implemented as a double linked list, which may squash values inserted directly one after another
891891+ * into single list node upon transaction commit.
892892+ *
893893+ * Reading a root-level type as an YArray means treating its sequence components as a list, where
894894+ * every countable element becomes an individual entity:
895895+ *
896896+ * - JSON-like primitives (booleans, numbers, strings, JSON maps, arrays etc.) are counted
897897+ * individually.
898898+ * - Text chunks inserted by [Text] data structure: each character becomes an element of an
899899+ * array.
900900+ * - Embedded and binary values: they count as a single element even though they correspond of
901901+ * multiple bytes.
902902+ *
903903+ * Like all Yrs shared data types, YArray is resistant to the problem of interleaving (situation
904904+ * when elements inserted one after another may interleave with other peers concurrent inserts
905905+ * after merging all updates together). In case of Yrs conflict resolution is solved by using
906906+ * unique document id to determine correct and consistent ordering.
907907+ */
908908+class YArray {
909909+ static __wrap(ptr) {
910910+ ptr = ptr >>> 0;
911911+ const obj = Object.create(YArray.prototype);
912912+ obj.__wbg_ptr = ptr;
913913+ YArrayFinalization.register(obj, obj.__wbg_ptr, obj);
914914+ return obj;
915915+ }
916916+917917+ __destroy_into_raw() {
918918+ const ptr = this.__wbg_ptr;
919919+ this.__wbg_ptr = 0;
920920+ YArrayFinalization.unregister(this);
921921+ return ptr;
922922+ }
923923+924924+ free() {
925925+ const ptr = this.__destroy_into_raw();
926926+ wasm.__wbg_yarray_free(ptr, 0);
927927+ }
928928+ /**
929929+ * Creates a new preliminary instance of a `YArray` shared data type, with its state
930930+ * initialized to provided parameter.
931931+ *
932932+ * Preliminary instances can be nested into other shared data types such as `YArray` and `YMap`.
933933+ * Once a preliminary instance has been inserted this way, it becomes integrated into ywasm
934934+ * document store and cannot be nested again: attempt to do so will result in an exception.
935935+ * @param {any[] | null} [items]
936936+ */
937937+ constructor(items) {
938938+ var ptr0 = isLikeNone(items)
939939+ ? 0
940940+ : passArrayJsValueToWasm0(items, wasm.__wbindgen_malloc);
941941+ var len0 = WASM_VECTOR_LEN;
942942+ const ret = wasm.yarray_new(ptr0, len0);
943943+ this.__wbg_ptr = ret >>> 0;
944944+ YArrayFinalization.register(this, this.__wbg_ptr, this);
945945+ return this;
946946+ }
947947+ /**
948948+ * @returns {number}
949949+ */
950950+ get type() {
951951+ const ret = wasm.yarray_type(this.__wbg_ptr);
952952+ return ret;
953953+ }
954954+ /**
955955+ * Gets unique logical identifier of this type, shared across peers collaborating on the same
956956+ * document.
957957+ * @returns {any}
958958+ */
959959+ get id() {
960960+ const ret = wasm.yarray_id(this.__wbg_ptr);
961961+ if (ret[2]) {
962962+ throw takeFromExternrefTable0(ret[1]);
963963+ }
964964+ return takeFromExternrefTable0(ret[0]);
965965+ }
966966+ /**
967967+ * Returns true if this is a preliminary instance of `YArray`.
968968+ *
969969+ * Preliminary instances can be nested into other shared data types such as `YArray` and `YMap`.
970970+ * Once a preliminary instance has been inserted this way, it becomes integrated into ywasm
971971+ * document store and cannot be nested again: attempt to do so will result in an exception.
972972+ * @returns {boolean}
973973+ */
974974+ get prelim() {
975975+ const ret = wasm.yarray_prelim(this.__wbg_ptr);
976976+ return ret !== 0;
977977+ }
978978+ /**
979979+ * Checks if current YArray reference is alive and has not been deleted by its parent collection.
980980+ * This method only works on already integrated shared types and will return false is current
981981+ * type is preliminary (has not been integrated into document).
982982+ * @param {YTransaction} txn
983983+ * @returns {boolean}
984984+ */
985985+ alive(txn) {
986986+ _assertClass(txn, YTransaction);
987987+ const ret = wasm.yarray_alive(this.__wbg_ptr, txn.__wbg_ptr);
988988+ return ret !== 0;
989989+ }
990990+ /**
991991+ * Returns a number of elements stored within this instance of `YArray`.
992992+ * @param {YTransaction | undefined} txn
993993+ * @returns {number}
994994+ */
995995+ length(txn) {
996996+ const ret = wasm.yarray_length(this.__wbg_ptr, txn);
997997+ if (ret[2]) {
998998+ throw takeFromExternrefTable0(ret[1]);
999999+ }
10001000+ return ret[0] >>> 0;
10011001+ }
10021002+ /**
10031003+ * Converts an underlying contents of this `YArray` instance into their JSON representation.
10041004+ * @param {YTransaction | undefined} txn
10051005+ * @returns {any}
10061006+ */
10071007+ toJson(txn) {
10081008+ const ret = wasm.yarray_toJson(this.__wbg_ptr, txn);
10091009+ if (ret[2]) {
10101010+ throw takeFromExternrefTable0(ret[1]);
10111011+ }
10121012+ return takeFromExternrefTable0(ret[0]);
10131013+ }
10141014+ /**
10151015+ * Inserts a given range of `items` into this `YArray` instance, starting at given `index`.
10161016+ * @param {number} index
10171017+ * @param {any[]} items
10181018+ * @param {YTransaction | undefined} txn
10191019+ */
10201020+ insert(index, items, txn) {
10211021+ const ptr0 = passArrayJsValueToWasm0(items, wasm.__wbindgen_malloc);
10221022+ const len0 = WASM_VECTOR_LEN;
10231023+ const ret = wasm.yarray_insert(this.__wbg_ptr, index, ptr0, len0, txn);
10241024+ if (ret[1]) {
10251025+ throw takeFromExternrefTable0(ret[0]);
10261026+ }
10271027+ }
10281028+ /**
10291029+ * Appends a range of `items` at the end of this `YArray` instance.
10301030+ * @param {any[]} items
10311031+ * @param {YTransaction | undefined} txn
10321032+ */
10331033+ push(items, txn) {
10341034+ const ptr0 = passArrayJsValueToWasm0(items, wasm.__wbindgen_malloc);
10351035+ const len0 = WASM_VECTOR_LEN;
10361036+ const ret = wasm.yarray_push(this.__wbg_ptr, ptr0, len0, txn);
10371037+ if (ret[1]) {
10381038+ throw takeFromExternrefTable0(ret[0]);
10391039+ }
10401040+ }
10411041+ /**
10421042+ * Deletes a range of items of given `length` from current `YArray` instance,
10431043+ * starting from given `index`.
10441044+ * @param {number} index
10451045+ * @param {number | null | undefined} length
10461046+ * @param {YTransaction | undefined} txn
10471047+ */
10481048+ delete(index, length, txn) {
10491049+ const ret = wasm.yarray_delete(
10501050+ this.__wbg_ptr,
10511051+ index,
10521052+ isLikeNone(length) ? 0x100000001 : length >>> 0,
10531053+ txn,
10541054+ );
10551055+ if (ret[1]) {
10561056+ throw takeFromExternrefTable0(ret[0]);
10571057+ }
10581058+ }
10591059+ /**
10601060+ * Moves element found at `source` index into `target` index position.
10611061+ * @param {number} source
10621062+ * @param {number} target
10631063+ * @param {YTransaction | undefined} txn
10641064+ */
10651065+ move(source, target, txn) {
10661066+ const ret = wasm.yarray_move(this.__wbg_ptr, source, target, txn);
10671067+ if (ret[1]) {
10681068+ throw takeFromExternrefTable0(ret[0]);
10691069+ }
10701070+ }
10711071+ /**
10721072+ * Returns an element stored under given `index`.
10731073+ * @param {number} index
10741074+ * @param {YTransaction | undefined} txn
10751075+ * @returns {any}
10761076+ */
10771077+ get(index, txn) {
10781078+ const ret = wasm.yarray_get(this.__wbg_ptr, index, txn);
10791079+ if (ret[2]) {
10801080+ throw takeFromExternrefTable0(ret[1]);
10811081+ }
10821082+ return takeFromExternrefTable0(ret[0]);
10831083+ }
10841084+ /**
10851085+ * @param {number | null | undefined} lower
10861086+ * @param {number | null | undefined} upper
10871087+ * @param {boolean | null | undefined} lower_open
10881088+ * @param {boolean | null | undefined} upper_open
10891089+ * @param {YTransaction | undefined} txn
10901090+ * @returns {YWeakLink}
10911091+ */
10921092+ quote(lower, upper, lower_open, upper_open, txn) {
10931093+ const ret = wasm.yarray_quote(
10941094+ this.__wbg_ptr,
10951095+ isLikeNone(lower) ? 0x100000001 : lower >>> 0,
10961096+ isLikeNone(upper) ? 0x100000001 : upper >>> 0,
10971097+ isLikeNone(lower_open) ? 0xffffff : lower_open ? 1 : 0,
10981098+ isLikeNone(upper_open) ? 0xffffff : upper_open ? 1 : 0,
10991099+ txn,
11001100+ );
11011101+ if (ret[2]) {
11021102+ throw takeFromExternrefTable0(ret[1]);
11031103+ }
11041104+ return YWeakLink.__wrap(ret[0]);
11051105+ }
11061106+ /**
11071107+ * Returns an iterator that can be used to traverse over the values stored withing this
11081108+ * instance of `YArray`.
11091109+ *
11101110+ * Example:
11111111+ *
11121112+ * ```javascript
11131113+ * import YDoc from 'ywasm'
11141114+ *
11151115+ * /// document on machine A
11161116+ * const doc = new YDoc()
11171117+ * const array = doc.getArray('name')
11181118+ * const txn = doc.beginTransaction()
11191119+ * try {
11201120+ * array.push(txn, ['hello', 'world'])
11211121+ * for (let item of array.values(txn)) {
11221122+ * console.log(item)
11231123+ * }
11241124+ * } finally {
11251125+ * txn.free()
11261126+ * }
11271127+ * ```
11281128+ * @param {YTransaction | undefined} txn
11291129+ * @returns {any}
11301130+ */
11311131+ values(txn) {
11321132+ const ret = wasm.yarray_values(this.__wbg_ptr, txn);
11331133+ if (ret[2]) {
11341134+ throw takeFromExternrefTable0(ret[1]);
11351135+ }
11361136+ return takeFromExternrefTable0(ret[0]);
11371137+ }
11381138+ /**
11391139+ * Subscribes to all operations happening over this instance of `YArray`. All changes are
11401140+ * batched and eventually triggered during transaction commit phase.
11411141+ * @param {Function} callback
11421142+ */
11431143+ observe(callback) {
11441144+ const ret = wasm.yarray_observe(this.__wbg_ptr, callback);
11451145+ if (ret[1]) {
11461146+ throw takeFromExternrefTable0(ret[0]);
11471147+ }
11481148+ }
11491149+ /**
11501150+ * @param {Function} callback
11511151+ * @returns {boolean}
11521152+ */
11531153+ unobserve(callback) {
11541154+ const ret = wasm.yarray_unobserve(this.__wbg_ptr, callback);
11551155+ if (ret[2]) {
11561156+ throw takeFromExternrefTable0(ret[1]);
11571157+ }
11581158+ return ret[0] !== 0;
11591159+ }
11601160+ /**
11611161+ * Subscribes to all operations happening over this Y shared type, as well as events in
11621162+ * shared types stored within this one. All changes are batched and eventually triggered
11631163+ * during transaction commit phase.
11641164+ * @param {Function} callback
11651165+ */
11661166+ observeDeep(callback) {
11671167+ const ret = wasm.yarray_observeDeep(this.__wbg_ptr, callback);
11681168+ if (ret[1]) {
11691169+ throw takeFromExternrefTable0(ret[0]);
11701170+ }
11711171+ }
11721172+ /**
11731173+ * @param {Function} callback
11741174+ * @returns {boolean}
11751175+ */
11761176+ unobserveDeep(callback) {
11771177+ const ret = wasm.yarray_unobserveDeep(this.__wbg_ptr, callback);
11781178+ if (ret[2]) {
11791179+ throw takeFromExternrefTable0(ret[1]);
11801180+ }
11811181+ return ret[0] !== 0;
11821182+ }
11831183+}
11841184+module.exports.YArray = YArray;
11851185+11861186+const YArrayEventFinalization =
11871187+ typeof FinalizationRegistry === "undefined"
11881188+ ? { register: () => {}, unregister: () => {} }
11891189+ : new FinalizationRegistry((ptr) =>
11901190+ wasm.__wbg_yarrayevent_free(ptr >>> 0, 1),
11911191+ );
11921192+/**
11931193+ * Event generated by `YArray.observe` method. Emitted during transaction commit phase.
11941194+ */
11951195+class YArrayEvent {
11961196+ static __wrap(ptr) {
11971197+ ptr = ptr >>> 0;
11981198+ const obj = Object.create(YArrayEvent.prototype);
11991199+ obj.__wbg_ptr = ptr;
12001200+ YArrayEventFinalization.register(obj, obj.__wbg_ptr, obj);
12011201+ return obj;
12021202+ }
12031203+12041204+ __destroy_into_raw() {
12051205+ const ptr = this.__wbg_ptr;
12061206+ this.__wbg_ptr = 0;
12071207+ YArrayEventFinalization.unregister(this);
12081208+ return ptr;
12091209+ }
12101210+12111211+ free() {
12121212+ const ptr = this.__destroy_into_raw();
12131213+ wasm.__wbg_yarrayevent_free(ptr, 0);
12141214+ }
12151215+ /**
12161216+ * Returns an array of keys and indexes creating a path from root type down to current instance
12171217+ * of shared type (accessible via `target` getter).
12181218+ * @returns {any}
12191219+ */
12201220+ path() {
12211221+ const ret = wasm.yarrayevent_path(this.__wbg_ptr);
12221222+ return ret;
12231223+ }
12241224+ /**
12251225+ * Returns a current shared type instance, that current event changes refer to.
12261226+ * @returns {any}
12271227+ */
12281228+ get target() {
12291229+ const ret = wasm.yarrayevent_target(this.__wbg_ptr);
12301230+ return ret;
12311231+ }
12321232+ /**
12331233+ * @returns {any}
12341234+ */
12351235+ get origin() {
12361236+ const ret = wasm.yarrayevent_origin(this.__wbg_ptr);
12371237+ return ret;
12381238+ }
12391239+ /**
12401240+ * Returns a list of text changes made over corresponding `YArray` collection within
12411241+ * bounds of current transaction. These changes follow a format:
12421242+ *
12431243+ * - { insert: any[] }
12441244+ * - { delete: number }
12451245+ * - { retain: number }
12461246+ * @returns {any}
12471247+ */
12481248+ get delta() {
12491249+ const ret = wasm.yarrayevent_delta(this.__wbg_ptr);
12501250+ return ret;
12511251+ }
12521252+}
12531253+module.exports.YArrayEvent = YArrayEvent;
12541254+12551255+const YDocFinalization =
12561256+ typeof FinalizationRegistry === "undefined"
12571257+ ? { register: () => {}, unregister: () => {} }
12581258+ : new FinalizationRegistry((ptr) => wasm.__wbg_ydoc_free(ptr >>> 0, 1));
12591259+/**
12601260+ * A ywasm document type. Documents are most important units of collaborative resources management.
12611261+ * All shared collections live within a scope of their corresponding documents. All updates are
12621262+ * generated on per-document basis (rather than individual shared type). All operations on shared
12631263+ * collections happen via [YTransaction], which lifetime is also bound to a document.
12641264+ *
12651265+ * Document manages so-called root types, which are top-level shared types definitions (as opposed
12661266+ * to recursively nested types).
12671267+ *
12681268+ * A basic workflow sample:
12691269+ *
12701270+ * ```javascript
12711271+ * import YDoc from 'ywasm'
12721272+ *
12731273+ * const doc = new YDoc()
12741274+ * const txn = doc.beginTransaction()
12751275+ * try {
12761276+ * const text = txn.getText('name')
12771277+ * text.push(txn, 'hello world')
12781278+ * const output = text.toString(txn)
12791279+ * console.log(output)
12801280+ * } finally {
12811281+ * txn.free()
12821282+ * }
12831283+ * ```
12841284+ */
12851285+class YDoc {
12861286+ static __wrap(ptr) {
12871287+ ptr = ptr >>> 0;
12881288+ const obj = Object.create(YDoc.prototype);
12891289+ obj.__wbg_ptr = ptr;
12901290+ YDocFinalization.register(obj, obj.__wbg_ptr, obj);
12911291+ return obj;
12921292+ }
12931293+12941294+ __destroy_into_raw() {
12951295+ const ptr = this.__wbg_ptr;
12961296+ this.__wbg_ptr = 0;
12971297+ YDocFinalization.unregister(this);
12981298+ return ptr;
12991299+ }
13001300+13011301+ free() {
13021302+ const ptr = this.__destroy_into_raw();
13031303+ wasm.__wbg_ydoc_free(ptr, 0);
13041304+ }
13051305+ /**
13061306+ * Creates a new ywasm document. If `id` parameter was passed it will be used as this document
13071307+ * globally unique identifier (it's up to caller to ensure that requirement). Otherwise it will
13081308+ * be assigned a randomly generated number.
13091309+ * @param {any} options
13101310+ */
13111311+ constructor(options) {
13121312+ const ret = wasm.ydoc_new(options);
13131313+ if (ret[2]) {
13141314+ throw takeFromExternrefTable0(ret[1]);
13151315+ }
13161316+ this.__wbg_ptr = ret[0] >>> 0;
13171317+ YDocFinalization.register(this, this.__wbg_ptr, this);
13181318+ return this;
13191319+ }
13201320+ /**
13211321+ * @returns {number}
13221322+ */
13231323+ get type() {
13241324+ const ret = wasm.ydoc_type(this.__wbg_ptr);
13251325+ return ret;
13261326+ }
13271327+ /**
13281328+ * Checks if a document is a preliminary type. It returns false, if current document
13291329+ * is already a sub-document of another document.
13301330+ * @returns {boolean}
13311331+ */
13321332+ get prelim() {
13331333+ const ret = wasm.ydoc_prelim(this.__wbg_ptr);
13341334+ return ret !== 0;
13351335+ }
13361336+ /**
13371337+ * Returns a parent document of this document or null if current document is not sub-document.
13381338+ * @returns {YDoc | undefined}
13391339+ */
13401340+ get parentDoc() {
13411341+ const ret = wasm.ydoc_parentDoc(this.__wbg_ptr);
13421342+ return ret === 0 ? undefined : YDoc.__wrap(ret);
13431343+ }
13441344+ /**
13451345+ * Gets unique peer identifier of this `YDoc` instance.
13461346+ * @returns {number}
13471347+ */
13481348+ get id() {
13491349+ const ret = wasm.ydoc_id(this.__wbg_ptr);
13501350+ return ret;
13511351+ }
13521352+ /**
13531353+ * Gets globally unique identifier of this `YDoc` instance.
13541354+ * @returns {string}
13551355+ */
13561356+ get guid() {
13571357+ let deferred1_0;
13581358+ let deferred1_1;
13591359+ try {
13601360+ const ret = wasm.ydoc_guid(this.__wbg_ptr);
13611361+ deferred1_0 = ret[0];
13621362+ deferred1_1 = ret[1];
13631363+ return getStringFromWasm0(ret[0], ret[1]);
13641364+ } finally {
13651365+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
13661366+ }
13671367+ }
13681368+ /**
13691369+ * @returns {boolean}
13701370+ */
13711371+ get shouldLoad() {
13721372+ const ret = wasm.ydoc_shouldLoad(this.__wbg_ptr);
13731373+ return ret !== 0;
13741374+ }
13751375+ /**
13761376+ * @returns {boolean}
13771377+ */
13781378+ get autoLoad() {
13791379+ const ret = wasm.ydoc_autoLoad(this.__wbg_ptr);
13801380+ return ret !== 0;
13811381+ }
13821382+ /**
13831383+ * Returns a new transaction for this document. Ywasm shared data types execute their
13841384+ * operations in a context of a given transaction. Each document can have only one active
13851385+ * transaction at the time - subsequent attempts will cause exception to be thrown.
13861386+ *
13871387+ * Transactions started with `doc.beginTransaction` can be released using `transaction.free`
13881388+ * method.
13891389+ *
13901390+ * Example:
13911391+ *
13921392+ * ```javascript
13931393+ * import YDoc from 'ywasm'
13941394+ *
13951395+ * // helper function used to simplify transaction
13961396+ * // create/release cycle
13971397+ * YDoc.prototype.transact = callback => {
13981398+ * const txn = this.transaction()
13991399+ * try {
14001400+ * return callback(txn)
14011401+ * } finally {
14021402+ * txn.free()
14031403+ * }
14041404+ * }
14051405+ *
14061406+ * const doc = new YDoc()
14071407+ * const text = doc.getText('name')
14081408+ * doc.transact(txn => text.insert(txn, 0, 'hello world'))
14091409+ * ```
14101410+ * @param {any} origin
14111411+ * @returns {YTransaction}
14121412+ */
14131413+ beginTransaction(origin) {
14141414+ const ret = wasm.ydoc_beginTransaction(this.__wbg_ptr, origin);
14151415+ return YTransaction.__wrap(ret);
14161416+ }
14171417+ /**
14181418+ * Returns a `YText` shared data type, that's accessible for subsequent accesses using given
14191419+ * `name`.
14201420+ *
14211421+ * If there was no instance with this name before, it will be created and then returned.
14221422+ *
14231423+ * If there was an instance with this name, but it was of different type, it will be projected
14241424+ * onto `YText` instance.
14251425+ * @param {string} name
14261426+ * @returns {YText}
14271427+ */
14281428+ getText(name) {
14291429+ const ptr0 = passStringToWasm0(
14301430+ name,
14311431+ wasm.__wbindgen_malloc,
14321432+ wasm.__wbindgen_realloc,
14331433+ );
14341434+ const len0 = WASM_VECTOR_LEN;
14351435+ const ret = wasm.ydoc_getText(this.__wbg_ptr, ptr0, len0);
14361436+ return YText.__wrap(ret);
14371437+ }
14381438+ /**
14391439+ * Returns a `YArray` shared data type, that's accessible for subsequent accesses using given
14401440+ * `name`.
14411441+ *
14421442+ * If there was no instance with this name before, it will be created and then returned.
14431443+ *
14441444+ * If there was an instance with this name, but it was of different type, it will be projected
14451445+ * onto `YArray` instance.
14461446+ * @param {string} name
14471447+ * @returns {YArray}
14481448+ */
14491449+ getArray(name) {
14501450+ const ptr0 = passStringToWasm0(
14511451+ name,
14521452+ wasm.__wbindgen_malloc,
14531453+ wasm.__wbindgen_realloc,
14541454+ );
14551455+ const len0 = WASM_VECTOR_LEN;
14561456+ const ret = wasm.ydoc_getArray(this.__wbg_ptr, ptr0, len0);
14571457+ return YArray.__wrap(ret);
14581458+ }
14591459+ /**
14601460+ * Returns a `YMap` shared data type, that's accessible for subsequent accesses using given
14611461+ * `name`.
14621462+ *
14631463+ * If there was no instance with this name before, it will be created and then returned.
14641464+ *
14651465+ * If there was an instance with this name, but it was of different type, it will be projected
14661466+ * onto `YMap` instance.
14671467+ * @param {string} name
14681468+ * @returns {YMap}
14691469+ */
14701470+ getMap(name) {
14711471+ const ptr0 = passStringToWasm0(
14721472+ name,
14731473+ wasm.__wbindgen_malloc,
14741474+ wasm.__wbindgen_realloc,
14751475+ );
14761476+ const len0 = WASM_VECTOR_LEN;
14771477+ const ret = wasm.ydoc_getMap(this.__wbg_ptr, ptr0, len0);
14781478+ return YMap.__wrap(ret);
14791479+ }
14801480+ /**
14811481+ * Returns a `YXmlFragment` shared data type, that's accessible for subsequent accesses using
14821482+ * given `name`.
14831483+ *
14841484+ * If there was no instance with this name before, it will be created and then returned.
14851485+ *
14861486+ * If there was an instance with this name, but it was of different type, it will be projected
14871487+ * onto `YXmlFragment` instance.
14881488+ * @param {string} name
14891489+ * @returns {YXmlFragment}
14901490+ */
14911491+ getXmlFragment(name) {
14921492+ const ptr0 = passStringToWasm0(
14931493+ name,
14941494+ wasm.__wbindgen_malloc,
14951495+ wasm.__wbindgen_realloc,
14961496+ );
14971497+ const len0 = WASM_VECTOR_LEN;
14981498+ const ret = wasm.ydoc_getXmlFragment(this.__wbg_ptr, ptr0, len0);
14991499+ return YXmlFragment.__wrap(ret);
15001500+ }
15011501+ /**
15021502+ * @param {string} event
15031503+ * @param {Function} callback
15041504+ */
15051505+ on(event, callback) {
15061506+ const ptr0 = passStringToWasm0(
15071507+ event,
15081508+ wasm.__wbindgen_malloc,
15091509+ wasm.__wbindgen_realloc,
15101510+ );
15111511+ const len0 = WASM_VECTOR_LEN;
15121512+ const ret = wasm.ydoc_on(this.__wbg_ptr, ptr0, len0, callback);
15131513+ if (ret[1]) {
15141514+ throw takeFromExternrefTable0(ret[0]);
15151515+ }
15161516+ }
15171517+ /**
15181518+ * @param {string} event
15191519+ * @param {Function} callback
15201520+ * @returns {boolean}
15211521+ */
15221522+ off(event, callback) {
15231523+ const ptr0 = passStringToWasm0(
15241524+ event,
15251525+ wasm.__wbindgen_malloc,
15261526+ wasm.__wbindgen_realloc,
15271527+ );
15281528+ const len0 = WASM_VECTOR_LEN;
15291529+ const ret = wasm.ydoc_off(this.__wbg_ptr, ptr0, len0, callback);
15301530+ if (ret[2]) {
15311531+ throw takeFromExternrefTable0(ret[1]);
15321532+ }
15331533+ return ret[0] !== 0;
15341534+ }
15351535+ /**
15361536+ * Notify the parent document that you request to load data into this subdocument
15371537+ * (if it is a subdocument).
15381538+ * @param {YTransaction | undefined} parent_txn
15391539+ */
15401540+ load(parent_txn) {
15411541+ const ret = wasm.ydoc_load(this.__wbg_ptr, parent_txn);
15421542+ if (ret[1]) {
15431543+ throw takeFromExternrefTable0(ret[0]);
15441544+ }
15451545+ }
15461546+ /**
15471547+ * Emit `onDestroy` event and unregister all event handlers.
15481548+ * @param {YTransaction | undefined} parent_txn
15491549+ */
15501550+ destroy(parent_txn) {
15511551+ const ret = wasm.ydoc_destroy(this.__wbg_ptr, parent_txn);
15521552+ if (ret[1]) {
15531553+ throw takeFromExternrefTable0(ret[0]);
15541554+ }
15551555+ }
15561556+ /**
15571557+ * Returns a list of sub-documents existings within the scope of this document.
15581558+ * @param {YTransaction | undefined} txn
15591559+ * @returns {Array<any>}
15601560+ */
15611561+ getSubdocs(txn) {
15621562+ const ret = wasm.ydoc_getSubdocs(this.__wbg_ptr, txn);
15631563+ if (ret[2]) {
15641564+ throw takeFromExternrefTable0(ret[1]);
15651565+ }
15661566+ return takeFromExternrefTable0(ret[0]);
15671567+ }
15681568+ /**
15691569+ * Returns a list of unique identifiers of the sub-documents existings within the scope of
15701570+ * this document.
15711571+ * @param {YTransaction | undefined} txn
15721572+ * @returns {Set<any>}
15731573+ */
15741574+ getSubdocGuids(txn) {
15751575+ const ret = wasm.ydoc_getSubdocGuids(this.__wbg_ptr, txn);
15761576+ if (ret[2]) {
15771577+ throw takeFromExternrefTable0(ret[1]);
15781578+ }
15791579+ return takeFromExternrefTable0(ret[0]);
15801580+ }
15811581+ /**
15821582+ * Returns a list of all root-level replicated collections, together with their types.
15831583+ * These collections can then be accessed via `getMap`/`getText` etc. methods.
15841584+ *
15851585+ * Example:
15861586+ * ```js
15871587+ * import * as Y from 'ywasm'
15881588+ *
15891589+ * const doc = new Y.YDoc()
15901590+ * const ymap = doc.getMap('a')
15911591+ * const yarray = doc.getArray('b')
15921592+ * const ytext = doc.getText('c')
15931593+ * const yxml = doc.getXmlFragment('d')
15941594+ *
15951595+ * const roots = doc.roots() // [['a',ymap], ['b',yarray], ['c',ytext], ['d',yxml]]
15961596+ * ```
15971597+ * @param {YTransaction | undefined} txn
15981598+ * @returns {Array<any>}
15991599+ */
16001600+ roots(txn) {
16011601+ const ret = wasm.ydoc_roots(this.__wbg_ptr, txn);
16021602+ if (ret[2]) {
16031603+ throw takeFromExternrefTable0(ret[1]);
16041604+ }
16051605+ return takeFromExternrefTable0(ret[0]);
16061606+ }
16071607+ /**
16081608+ * Evaluates a JSON path expression (see: https://en.wikipedia.org/wiki/JSONPath) on
16091609+ * the document and returns an array of values matching that query.
16101610+ *
16111611+ * Currently, this method supports the following syntax:
16121612+ * - `$` - root object
16131613+ * - `@` - current object
16141614+ * - `.field` or `['field']` - member accessor
16151615+ * - `[1]` - array index (also supports negative indices)
16161616+ * - `.*` or `[*]` - wildcard (matches all members of an object or array)
16171617+ * - `..` - recursive descent (matches all descendants not only direct children)
16181618+ * - `[start:end:step]` - array slice operator (requires positive integer arguments)
16191619+ * - `['a', 'b', 'c']` - union operator (returns an array of values for each query)
16201620+ * - `[1, -1, 3]` - multiple indices operator (returns an array of values for each index)
16211621+ *
16221622+ * At the moment, JSON Path does not support filter predicates.
16231623+ * @param {string} json_path
16241624+ * @returns {Array<any>}
16251625+ */
16261626+ selectAll(json_path) {
16271627+ const ptr0 = passStringToWasm0(
16281628+ json_path,
16291629+ wasm.__wbindgen_malloc,
16301630+ wasm.__wbindgen_realloc,
16311631+ );
16321632+ const len0 = WASM_VECTOR_LEN;
16331633+ const ret = wasm.ydoc_selectAll(this.__wbg_ptr, ptr0, len0);
16341634+ if (ret[2]) {
16351635+ throw takeFromExternrefTable0(ret[1]);
16361636+ }
16371637+ return takeFromExternrefTable0(ret[0]);
16381638+ }
16391639+ /**
16401640+ * Evaluates a JSON path expression (see: https://en.wikipedia.org/wiki/JSONPath) on
16411641+ * the document and returns first value matching that query.
16421642+ *
16431643+ * Currently, this method supports the following syntax:
16441644+ * - `$` - root object
16451645+ * - `@` - current object
16461646+ * - `.field` or `['field']` - member accessor
16471647+ * - `[1]` - array index (also supports negative indices)
16481648+ * - `.*` or `[*]` - wildcard (matches all members of an object or array)
16491649+ * - `..` - recursive descent (matches all descendants not only direct children)
16501650+ * - `[start:end:step]` - array slice operator (requires positive integer arguments)
16511651+ * - `['a', 'b', 'c']` - union operator (returns an array of values for each query)
16521652+ * - `[1, -1, 3]` - multiple indices operator (returns an array of values for each index)
16531653+ *
16541654+ * At the moment, JSON Path does not support filter predicates.
16551655+ * @param {string} json_path
16561656+ * @returns {any}
16571657+ */
16581658+ selectOne(json_path) {
16591659+ const ptr0 = passStringToWasm0(
16601660+ json_path,
16611661+ wasm.__wbindgen_malloc,
16621662+ wasm.__wbindgen_realloc,
16631663+ );
16641664+ const len0 = WASM_VECTOR_LEN;
16651665+ const ret = wasm.ydoc_selectOne(this.__wbg_ptr, ptr0, len0);
16661666+ if (ret[2]) {
16671667+ throw takeFromExternrefTable0(ret[1]);
16681668+ }
16691669+ return takeFromExternrefTable0(ret[0]);
16701670+ }
16711671+}
16721672+module.exports.YDoc = YDoc;
16731673+16741674+const YMapFinalization =
16751675+ typeof FinalizationRegistry === "undefined"
16761676+ ? { register: () => {}, unregister: () => {} }
16771677+ : new FinalizationRegistry((ptr) => wasm.__wbg_ymap_free(ptr >>> 0, 1));
16781678+/**
16791679+ * Collection used to store key-value entries in an unordered manner. Keys are always represented
16801680+ * as UTF-8 strings. Values can be any value type supported by Yrs: JSON-like primitives as well as
16811681+ * shared data types.
16821682+ *
16831683+ * In terms of conflict resolution, [Map] uses logical last-write-wins principle, meaning the past
16841684+ * updates are automatically overridden and discarded by newer ones, while concurrent updates made
16851685+ * by different peers are resolved into a single value using document id seniority to establish
16861686+ * order.
16871687+ */
16881688+class YMap {
16891689+ static __wrap(ptr) {
16901690+ ptr = ptr >>> 0;
16911691+ const obj = Object.create(YMap.prototype);
16921692+ obj.__wbg_ptr = ptr;
16931693+ YMapFinalization.register(obj, obj.__wbg_ptr, obj);
16941694+ return obj;
16951695+ }
16961696+16971697+ __destroy_into_raw() {
16981698+ const ptr = this.__wbg_ptr;
16991699+ this.__wbg_ptr = 0;
17001700+ YMapFinalization.unregister(this);
17011701+ return ptr;
17021702+ }
17031703+17041704+ free() {
17051705+ const ptr = this.__destroy_into_raw();
17061706+ wasm.__wbg_ymap_free(ptr, 0);
17071707+ }
17081708+ /**
17091709+ * Creates a new preliminary instance of a `YMap` shared data type, with its state
17101710+ * initialized to provided parameter.
17111711+ *
17121712+ * Preliminary instances can be nested into other shared data types such as `YArray` and `YMap`.
17131713+ * Once a preliminary instance has been inserted this way, it becomes integrated into ywasm
17141714+ * document store and cannot be nested again: attempt to do so will result in an exception.
17151715+ * @param {object | null} [init]
17161716+ */
17171717+ constructor(init) {
17181718+ const ret = wasm.ymap_new(
17191719+ isLikeNone(init) ? 0 : addToExternrefTable0(init),
17201720+ );
17211721+ this.__wbg_ptr = ret >>> 0;
17221722+ YMapFinalization.register(this, this.__wbg_ptr, this);
17231723+ return this;
17241724+ }
17251725+ /**
17261726+ * @returns {number}
17271727+ */
17281728+ get type() {
17291729+ const ret = wasm.ymap_type(this.__wbg_ptr);
17301730+ return ret;
17311731+ }
17321732+ /**
17331733+ * Gets unique logical identifier of this type, shared across peers collaborating on the same
17341734+ * document.
17351735+ * @returns {any}
17361736+ */
17371737+ get id() {
17381738+ const ret = wasm.ymap_id(this.__wbg_ptr);
17391739+ if (ret[2]) {
17401740+ throw takeFromExternrefTable0(ret[1]);
17411741+ }
17421742+ return takeFromExternrefTable0(ret[0]);
17431743+ }
17441744+ /**
17451745+ * Returns true if this is a preliminary instance of `YMap`.
17461746+ *
17471747+ * Preliminary instances can be nested into other shared data types such as `YArray` and `YMap`.
17481748+ * Once a preliminary instance has been inserted this way, it becomes integrated into ywasm
17491749+ * document store and cannot be nested again: attempt to do so will result in an exception.
17501750+ * @returns {boolean}
17511751+ */
17521752+ get prelim() {
17531753+ const ret = wasm.ymap_prelim(this.__wbg_ptr);
17541754+ return ret !== 0;
17551755+ }
17561756+ /**
17571757+ * Checks if current YMap reference is alive and has not been deleted by its parent collection.
17581758+ * This method only works on already integrated shared types and will return false is current
17591759+ * type is preliminary (has not been integrated into document).
17601760+ * @param {YTransaction} txn
17611761+ * @returns {boolean}
17621762+ */
17631763+ alive(txn) {
17641764+ _assertClass(txn, YTransaction);
17651765+ const ret = wasm.ymap_alive(this.__wbg_ptr, txn.__wbg_ptr);
17661766+ return ret !== 0;
17671767+ }
17681768+ /**
17691769+ * Returns a number of entries stored within this instance of `YMap`.
17701770+ * @param {YTransaction | undefined} txn
17711771+ * @returns {number}
17721772+ */
17731773+ length(txn) {
17741774+ const ret = wasm.ymap_length(this.__wbg_ptr, txn);
17751775+ if (ret[2]) {
17761776+ throw takeFromExternrefTable0(ret[1]);
17771777+ }
17781778+ return ret[0] >>> 0;
17791779+ }
17801780+ /**
17811781+ * Converts contents of this `YMap` instance into a JSON representation.
17821782+ * @param {YTransaction | undefined} txn
17831783+ * @returns {any}
17841784+ */
17851785+ toJson(txn) {
17861786+ const ret = wasm.ymap_toJson(this.__wbg_ptr, txn);
17871787+ if (ret[2]) {
17881788+ throw takeFromExternrefTable0(ret[1]);
17891789+ }
17901790+ return takeFromExternrefTable0(ret[0]);
17911791+ }
17921792+ /**
17931793+ * Sets a given `key`-`value` entry within this instance of `YMap`. If another entry was
17941794+ * already stored under given `key`, it will be overridden with new `value`.
17951795+ * @param {string} key
17961796+ * @param {any} value
17971797+ * @param {YTransaction | undefined} txn
17981798+ */
17991799+ set(key, value, txn) {
18001800+ const ptr0 = passStringToWasm0(
18011801+ key,
18021802+ wasm.__wbindgen_malloc,
18031803+ wasm.__wbindgen_realloc,
18041804+ );
18051805+ const len0 = WASM_VECTOR_LEN;
18061806+ const ret = wasm.ymap_set(this.__wbg_ptr, ptr0, len0, value, txn);
18071807+ if (ret[1]) {
18081808+ throw takeFromExternrefTable0(ret[0]);
18091809+ }
18101810+ }
18111811+ /**
18121812+ * Removes an entry identified by a given `key` from this instance of `YMap`, if such exists.
18131813+ * @param {string} key
18141814+ * @param {YTransaction | undefined} txn
18151815+ */
18161816+ delete(key, txn) {
18171817+ const ptr0 = passStringToWasm0(
18181818+ key,
18191819+ wasm.__wbindgen_malloc,
18201820+ wasm.__wbindgen_realloc,
18211821+ );
18221822+ const len0 = WASM_VECTOR_LEN;
18231823+ const ret = wasm.ymap_delete(this.__wbg_ptr, ptr0, len0, txn);
18241824+ if (ret[1]) {
18251825+ throw takeFromExternrefTable0(ret[0]);
18261826+ }
18271827+ }
18281828+ /**
18291829+ * Returns value of an entry stored under given `key` within this instance of `YMap`,
18301830+ * or `undefined` if no such entry existed.
18311831+ * @param {string} key
18321832+ * @param {YTransaction | undefined} txn
18331833+ * @returns {any}
18341834+ */
18351835+ get(key, txn) {
18361836+ const ptr0 = passStringToWasm0(
18371837+ key,
18381838+ wasm.__wbindgen_malloc,
18391839+ wasm.__wbindgen_realloc,
18401840+ );
18411841+ const len0 = WASM_VECTOR_LEN;
18421842+ const ret = wasm.ymap_get(this.__wbg_ptr, ptr0, len0, txn);
18431843+ if (ret[2]) {
18441844+ throw takeFromExternrefTable0(ret[1]);
18451845+ }
18461846+ return takeFromExternrefTable0(ret[0]);
18471847+ }
18481848+ /**
18491849+ * @param {string} key
18501850+ * @param {YTransaction | undefined} txn
18511851+ * @returns {any}
18521852+ */
18531853+ link(key, txn) {
18541854+ const ptr0 = passStringToWasm0(
18551855+ key,
18561856+ wasm.__wbindgen_malloc,
18571857+ wasm.__wbindgen_realloc,
18581858+ );
18591859+ const len0 = WASM_VECTOR_LEN;
18601860+ const ret = wasm.ymap_link(this.__wbg_ptr, ptr0, len0, txn);
18611861+ if (ret[2]) {
18621862+ throw takeFromExternrefTable0(ret[1]);
18631863+ }
18641864+ return takeFromExternrefTable0(ret[0]);
18651865+ }
18661866+ /**
18671867+ * Returns an iterator that can be used to traverse over all entries stored within this
18681868+ * instance of `YMap`. Order of entry is not specified.
18691869+ *
18701870+ * Example:
18711871+ *
18721872+ * ```javascript
18731873+ * import YDoc from 'ywasm'
18741874+ *
18751875+ * /// document on machine A
18761876+ * const doc = new YDoc()
18771877+ * const map = doc.getMap('name')
18781878+ * const txn = doc.beginTransaction()
18791879+ * try {
18801880+ * map.set(txn, 'key1', 'value1')
18811881+ * map.set(txn, 'key2', true)
18821882+ *
18831883+ * for (let [key, value] of map.entries(txn)) {
18841884+ * console.log(key, value)
18851885+ * }
18861886+ * } finally {
18871887+ * txn.free()
18881888+ * }
18891889+ * ```
18901890+ * @param {YTransaction | undefined} txn
18911891+ * @returns {any}
18921892+ */
18931893+ entries(txn) {
18941894+ const ret = wasm.ymap_entries(this.__wbg_ptr, txn);
18951895+ if (ret[2]) {
18961896+ throw takeFromExternrefTable0(ret[1]);
18971897+ }
18981898+ return takeFromExternrefTable0(ret[0]);
18991899+ }
19001900+ /**
19011901+ * Subscribes to all operations happening over this instance of `YMap`. All changes are
19021902+ * batched and eventually triggered during transaction commit phase.
19031903+ * @param {Function} callback
19041904+ */
19051905+ observe(callback) {
19061906+ const ret = wasm.ymap_observe(this.__wbg_ptr, callback);
19071907+ if (ret[1]) {
19081908+ throw takeFromExternrefTable0(ret[0]);
19091909+ }
19101910+ }
19111911+ /**
19121912+ * Unsubscribes a callback previously subscribed with `observe` method.
19131913+ * @param {Function} callback
19141914+ * @returns {boolean}
19151915+ */
19161916+ unobserve(callback) {
19171917+ const ret = wasm.ymap_unobserve(this.__wbg_ptr, callback);
19181918+ if (ret[2]) {
19191919+ throw takeFromExternrefTable0(ret[1]);
19201920+ }
19211921+ return ret[0] !== 0;
19221922+ }
19231923+ /**
19241924+ * Subscribes to all operations happening over this Y shared type, as well as events in
19251925+ * shared types stored within this one. All changes are batched and eventually triggered
19261926+ * during transaction commit phase.
19271927+ * @param {Function} callback
19281928+ */
19291929+ observeDeep(callback) {
19301930+ const ret = wasm.ymap_observeDeep(this.__wbg_ptr, callback);
19311931+ if (ret[1]) {
19321932+ throw takeFromExternrefTable0(ret[0]);
19331933+ }
19341934+ }
19351935+ /**
19361936+ * Unsubscribes a callback previously subscribed with `observeDeep` method.
19371937+ * @param {Function} callback
19381938+ * @returns {boolean}
19391939+ */
19401940+ unobserveDeep(callback) {
19411941+ const ret = wasm.ymap_unobserveDeep(this.__wbg_ptr, callback);
19421942+ if (ret[2]) {
19431943+ throw takeFromExternrefTable0(ret[1]);
19441944+ }
19451945+ return ret[0] !== 0;
19461946+ }
19471947+}
19481948+module.exports.YMap = YMap;
19491949+19501950+const YMapEventFinalization =
19511951+ typeof FinalizationRegistry === "undefined"
19521952+ ? { register: () => {}, unregister: () => {} }
19531953+ : new FinalizationRegistry((ptr) =>
19541954+ wasm.__wbg_ymapevent_free(ptr >>> 0, 1),
19551955+ );
19561956+/**
19571957+ * Event generated by `YMap.observe` method. Emitted during transaction commit phase.
19581958+ */
19591959+class YMapEvent {
19601960+ static __wrap(ptr) {
19611961+ ptr = ptr >>> 0;
19621962+ const obj = Object.create(YMapEvent.prototype);
19631963+ obj.__wbg_ptr = ptr;
19641964+ YMapEventFinalization.register(obj, obj.__wbg_ptr, obj);
19651965+ return obj;
19661966+ }
19671967+19681968+ __destroy_into_raw() {
19691969+ const ptr = this.__wbg_ptr;
19701970+ this.__wbg_ptr = 0;
19711971+ YMapEventFinalization.unregister(this);
19721972+ return ptr;
19731973+ }
19741974+19751975+ free() {
19761976+ const ptr = this.__destroy_into_raw();
19771977+ wasm.__wbg_ymapevent_free(ptr, 0);
19781978+ }
19791979+ /**
19801980+ * @returns {any}
19811981+ */
19821982+ get origin() {
19831983+ const ret = wasm.ymapevent_origin(this.__wbg_ptr);
19841984+ return ret;
19851985+ }
19861986+ /**
19871987+ * Returns an array of keys and indexes creating a path from root type down to current instance
19881988+ * of shared type (accessible via `target` getter).
19891989+ * @returns {any}
19901990+ */
19911991+ path() {
19921992+ const ret = wasm.ymapevent_path(this.__wbg_ptr);
19931993+ return ret;
19941994+ }
19951995+ /**
19961996+ * Returns a current shared type instance, that current event changes refer to.
19971997+ * @returns {any}
19981998+ */
19991999+ get target() {
20002000+ const ret = wasm.ymapevent_target(this.__wbg_ptr);
20012001+ return ret;
20022002+ }
20032003+ /**
20042004+ * Returns a list of key-value changes made over corresponding `YMap` collection within
20052005+ * bounds of current transaction. These changes follow a format:
20062006+ *
20072007+ * - { action: 'add'|'update'|'delete', oldValue: any|undefined, newValue: any|undefined }
20082008+ * @returns {any}
20092009+ */
20102010+ get keys() {
20112011+ const ret = wasm.ymapevent_keys(this.__wbg_ptr);
20122012+ if (ret[2]) {
20132013+ throw takeFromExternrefTable0(ret[1]);
20142014+ }
20152015+ return takeFromExternrefTable0(ret[0]);
20162016+ }
20172017+}
20182018+module.exports.YMapEvent = YMapEvent;
20192019+20202020+const YSubdocsEventFinalization =
20212021+ typeof FinalizationRegistry === "undefined"
20222022+ ? { register: () => {}, unregister: () => {} }
20232023+ : new FinalizationRegistry((ptr) =>
20242024+ wasm.__wbg_ysubdocsevent_free(ptr >>> 0, 1),
20252025+ );
20262026+20272027+class YSubdocsEvent {
20282028+ static __wrap(ptr) {
20292029+ ptr = ptr >>> 0;
20302030+ const obj = Object.create(YSubdocsEvent.prototype);
20312031+ obj.__wbg_ptr = ptr;
20322032+ YSubdocsEventFinalization.register(obj, obj.__wbg_ptr, obj);
20332033+ return obj;
20342034+ }
20352035+20362036+ __destroy_into_raw() {
20372037+ const ptr = this.__wbg_ptr;
20382038+ this.__wbg_ptr = 0;
20392039+ YSubdocsEventFinalization.unregister(this);
20402040+ return ptr;
20412041+ }
20422042+20432043+ free() {
20442044+ const ptr = this.__destroy_into_raw();
20452045+ wasm.__wbg_ysubdocsevent_free(ptr, 0);
20462046+ }
20472047+ /**
20482048+ * @returns {Array<any>}
20492049+ */
20502050+ get added() {
20512051+ const ret = wasm.ysubdocsevent_added(this.__wbg_ptr);
20522052+ return ret;
20532053+ }
20542054+ /**
20552055+ * @returns {Array<any>}
20562056+ */
20572057+ get removed() {
20582058+ const ret = wasm.ysubdocsevent_removed(this.__wbg_ptr);
20592059+ return ret;
20602060+ }
20612061+ /**
20622062+ * @returns {Array<any>}
20632063+ */
20642064+ get loaded() {
20652065+ const ret = wasm.ysubdocsevent_loaded(this.__wbg_ptr);
20662066+ return ret;
20672067+ }
20682068+}
20692069+module.exports.YSubdocsEvent = YSubdocsEvent;
20702070+20712071+const YTextFinalization =
20722072+ typeof FinalizationRegistry === "undefined"
20732073+ ? { register: () => {}, unregister: () => {} }
20742074+ : new FinalizationRegistry((ptr) => wasm.__wbg_ytext_free(ptr >>> 0, 1));
20752075+/**
20762076+ * A shared data type used for collaborative text editing. It enables multiple users to add and
20772077+ * remove chunks of text in efficient manner. This type is internally represented as a mutable
20782078+ * double-linked list of text chunks - an optimization occurs during `YTransaction.commit`, which
20792079+ * allows to squash multiple consecutively inserted characters together as a single chunk of text
20802080+ * even between transaction boundaries in order to preserve more efficient memory model.
20812081+ *
20822082+ * `YText` structure internally uses UTF-8 encoding and its length is described in a number of
20832083+ * bytes rather than individual characters (a single UTF-8 code point can consist of many bytes).
20842084+ *
20852085+ * Like all Yrs shared data types, `YText` is resistant to the problem of interleaving (situation
20862086+ * when characters inserted one after another may interleave with other peers concurrent inserts
20872087+ * after merging all updates together). In case of Yrs conflict resolution is solved by using
20882088+ * unique document id to determine correct and consistent ordering.
20892089+ */
20902090+class YText {
20912091+ static __wrap(ptr) {
20922092+ ptr = ptr >>> 0;
20932093+ const obj = Object.create(YText.prototype);
20942094+ obj.__wbg_ptr = ptr;
20952095+ YTextFinalization.register(obj, obj.__wbg_ptr, obj);
20962096+ return obj;
20972097+ }
20982098+20992099+ __destroy_into_raw() {
21002100+ const ptr = this.__wbg_ptr;
21012101+ this.__wbg_ptr = 0;
21022102+ YTextFinalization.unregister(this);
21032103+ return ptr;
21042104+ }
21052105+21062106+ free() {
21072107+ const ptr = this.__destroy_into_raw();
21082108+ wasm.__wbg_ytext_free(ptr, 0);
21092109+ }
21102110+ /**
21112111+ * Creates a new preliminary instance of a `YText` shared data type, with its state initialized
21122112+ * to provided parameter.
21132113+ *
21142114+ * Preliminary instances can be nested into other shared data types such as `YArray` and `YMap`.
21152115+ * Once a preliminary instance has been inserted this way, it becomes integrated into ywasm
21162116+ * document store and cannot be nested again: attempt to do so will result in an exception.
21172117+ * @param {string | null} [init]
21182118+ */
21192119+ constructor(init) {
21202120+ var ptr0 = isLikeNone(init)
21212121+ ? 0
21222122+ : passStringToWasm0(
21232123+ init,
21242124+ wasm.__wbindgen_malloc,
21252125+ wasm.__wbindgen_realloc,
21262126+ );
21272127+ var len0 = WASM_VECTOR_LEN;
21282128+ const ret = wasm.ytext_new(ptr0, len0);
21292129+ this.__wbg_ptr = ret >>> 0;
21302130+ YTextFinalization.register(this, this.__wbg_ptr, this);
21312131+ return this;
21322132+ }
21332133+ /**
21342134+ * @returns {number}
21352135+ */
21362136+ get type() {
21372137+ const ret = wasm.ytext_type(this.__wbg_ptr);
21382138+ return ret;
21392139+ }
21402140+ /**
21412141+ * Gets unique logical identifier of this type, shared across peers collaborating on the same
21422142+ * document.
21432143+ * @returns {any}
21442144+ */
21452145+ get id() {
21462146+ const ret = wasm.ytext_id(this.__wbg_ptr);
21472147+ if (ret[2]) {
21482148+ throw takeFromExternrefTable0(ret[1]);
21492149+ }
21502150+ return takeFromExternrefTable0(ret[0]);
21512151+ }
21522152+ /**
21532153+ * Returns true if this is a preliminary instance of `YArray`.
21542154+ *
21552155+ * Preliminary instances can be nested into other shared data types such as `YArray` and `YMap`.
21562156+ * Once a preliminary instance has been inserted this way, it becomes integrated into ywasm
21572157+ * document store and cannot be nested again: attempt to do so will result in an exception.
21582158+ * @returns {boolean}
21592159+ */
21602160+ get prelim() {
21612161+ const ret = wasm.ytext_prelim(this.__wbg_ptr);
21622162+ return ret !== 0;
21632163+ }
21642164+ /**
21652165+ * Checks if current YArray reference is alive and has not been deleted by its parent collection.
21662166+ * This method only works on already integrated shared types and will return false is current
21672167+ * type is preliminary (has not been integrated into document).
21682168+ * @param {YTransaction} txn
21692169+ * @returns {boolean}
21702170+ */
21712171+ alive(txn) {
21722172+ _assertClass(txn, YTransaction);
21732173+ const ret = wasm.ytext_alive(this.__wbg_ptr, txn.__wbg_ptr);
21742174+ return ret !== 0;
21752175+ }
21762176+ /**
21772177+ * Returns length of an underlying string stored in this `YText` instance,
21782178+ * understood as a number of UTF-8 encoded bytes.
21792179+ * @param {YTransaction | undefined} txn
21802180+ * @returns {number}
21812181+ */
21822182+ length(txn) {
21832183+ const ret = wasm.ytext_length(this.__wbg_ptr, txn);
21842184+ if (ret[2]) {
21852185+ throw takeFromExternrefTable0(ret[1]);
21862186+ }
21872187+ return ret[0] >>> 0;
21882188+ }
21892189+ /**
21902190+ * Returns an underlying shared string stored in this data type.
21912191+ * @param {YTransaction | undefined} txn
21922192+ * @returns {string}
21932193+ */
21942194+ toString(txn) {
21952195+ let deferred2_0;
21962196+ let deferred2_1;
21972197+ try {
21982198+ const ret = wasm.ytext_toString(this.__wbg_ptr, txn);
21992199+ var ptr1 = ret[0];
22002200+ var len1 = ret[1];
22012201+ if (ret[3]) {
22022202+ ptr1 = 0;
22032203+ len1 = 0;
22042204+ throw takeFromExternrefTable0(ret[2]);
22052205+ }
22062206+ deferred2_0 = ptr1;
22072207+ deferred2_1 = len1;
22082208+ return getStringFromWasm0(ptr1, len1);
22092209+ } finally {
22102210+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
22112211+ }
22122212+ }
22132213+ /**
22142214+ * Returns an underlying shared string stored in this data type.
22152215+ * @param {YTransaction | undefined} txn
22162216+ * @returns {any}
22172217+ */
22182218+ toJson(txn) {
22192219+ const ret = wasm.ytext_toJson(this.__wbg_ptr, txn);
22202220+ if (ret[2]) {
22212221+ throw takeFromExternrefTable0(ret[1]);
22222222+ }
22232223+ return takeFromExternrefTable0(ret[0]);
22242224+ }
22252225+ /**
22262226+ * Inserts a given `chunk` of text into this `YText` instance, starting at a given `index`.
22272227+ *
22282228+ * Optional object with defined `attributes` will be used to wrap provided text `chunk`
22292229+ * with a formatting blocks.`attributes` are only supported for a `YText` instance which
22302230+ * already has been integrated into document store.
22312231+ * @param {number} index
22322232+ * @param {string} chunk
22332233+ * @param {any} attributes
22342234+ * @param {YTransaction | undefined} txn
22352235+ */
22362236+ insert(index, chunk, attributes, txn) {
22372237+ const ptr0 = passStringToWasm0(
22382238+ chunk,
22392239+ wasm.__wbindgen_malloc,
22402240+ wasm.__wbindgen_realloc,
22412241+ );
22422242+ const len0 = WASM_VECTOR_LEN;
22432243+ const ret = wasm.ytext_insert(
22442244+ this.__wbg_ptr,
22452245+ index,
22462246+ ptr0,
22472247+ len0,
22482248+ attributes,
22492249+ txn,
22502250+ );
22512251+ if (ret[1]) {
22522252+ throw takeFromExternrefTable0(ret[0]);
22532253+ }
22542254+ }
22552255+ /**
22562256+ * Inserts a given `embed` object into this `YText` instance, starting at a given `index`.
22572257+ *
22582258+ * Optional object with defined `attributes` will be used to wrap provided `embed`
22592259+ * with a formatting blocks.`attributes` are only supported for a `YText` instance which
22602260+ * already has been integrated into document store.
22612261+ * @param {number} index
22622262+ * @param {any} embed
22632263+ * @param {any} attributes
22642264+ * @param {YTransaction | undefined} txn
22652265+ */
22662266+ insertEmbed(index, embed, attributes, txn) {
22672267+ const ret = wasm.ytext_insertEmbed(
22682268+ this.__wbg_ptr,
22692269+ index,
22702270+ embed,
22712271+ attributes,
22722272+ txn,
22732273+ );
22742274+ if (ret[1]) {
22752275+ throw takeFromExternrefTable0(ret[0]);
22762276+ }
22772277+ }
22782278+ /**
22792279+ * Wraps an existing piece of text within a range described by `index`-`length` parameters with
22802280+ * formatting blocks containing provided `attributes` metadata. This method only works for
22812281+ * `YText` instances that already have been integrated into document store.
22822282+ * @param {number} index
22832283+ * @param {number} length
22842284+ * @param {any} attributes
22852285+ * @param {YTransaction | undefined} txn
22862286+ */
22872287+ format(index, length, attributes, txn) {
22882288+ const ret = wasm.ytext_format(
22892289+ this.__wbg_ptr,
22902290+ index,
22912291+ length,
22922292+ attributes,
22932293+ txn,
22942294+ );
22952295+ if (ret[1]) {
22962296+ throw takeFromExternrefTable0(ret[0]);
22972297+ }
22982298+ }
22992299+ /**
23002300+ * Appends a given `chunk` of text at the end of current `YText` instance.
23012301+ *
23022302+ * Optional object with defined `attributes` will be used to wrap provided text `chunk`
23032303+ * with a formatting blocks.`attributes` are only supported for a `YText` instance which
23042304+ * already has been integrated into document store.
23052305+ * @param {string} chunk
23062306+ * @param {any} attributes
23072307+ * @param {YTransaction | undefined} txn
23082308+ */
23092309+ push(chunk, attributes, txn) {
23102310+ const ptr0 = passStringToWasm0(
23112311+ chunk,
23122312+ wasm.__wbindgen_malloc,
23132313+ wasm.__wbindgen_realloc,
23142314+ );
23152315+ const len0 = WASM_VECTOR_LEN;
23162316+ const ret = wasm.ytext_push(this.__wbg_ptr, ptr0, len0, attributes, txn);
23172317+ if (ret[1]) {
23182318+ throw takeFromExternrefTable0(ret[0]);
23192319+ }
23202320+ }
23212321+ /**
23222322+ * Deletes a specified range of characters, starting at a given `index`.
23232323+ * Both `index` and `length` are counted in terms of a number of UTF-8 character bytes.
23242324+ * @param {number} index
23252325+ * @param {number} length
23262326+ * @param {YTransaction | undefined} txn
23272327+ */
23282328+ delete(index, length, txn) {
23292329+ const ret = wasm.ytext_delete(this.__wbg_ptr, index, length, txn);
23302330+ if (ret[1]) {
23312331+ throw takeFromExternrefTable0(ret[0]);
23322332+ }
23332333+ }
23342334+ /**
23352335+ * @param {number | null | undefined} lower
23362336+ * @param {number | null | undefined} upper
23372337+ * @param {boolean | null | undefined} lower_open
23382338+ * @param {boolean | null | undefined} upper_open
23392339+ * @param {YTransaction | undefined} txn
23402340+ * @returns {YWeakLink}
23412341+ */
23422342+ quote(lower, upper, lower_open, upper_open, txn) {
23432343+ const ret = wasm.ytext_quote(
23442344+ this.__wbg_ptr,
23452345+ isLikeNone(lower) ? 0x100000001 : lower >>> 0,
23462346+ isLikeNone(upper) ? 0x100000001 : upper >>> 0,
23472347+ isLikeNone(lower_open) ? 0xffffff : lower_open ? 1 : 0,
23482348+ isLikeNone(upper_open) ? 0xffffff : upper_open ? 1 : 0,
23492349+ txn,
23502350+ );
23512351+ if (ret[2]) {
23522352+ throw takeFromExternrefTable0(ret[1]);
23532353+ }
23542354+ return YWeakLink.__wrap(ret[0]);
23552355+ }
23562356+ /**
23572357+ * Returns the Delta representation of this YText type.
23582358+ * @param {any} snapshot
23592359+ * @param {any} prev_snapshot
23602360+ * @param {Function | null | undefined} compute_ychange
23612361+ * @param {YTransaction | undefined} txn
23622362+ * @returns {Array<any>}
23632363+ */
23642364+ toDelta(snapshot, prev_snapshot, compute_ychange, txn) {
23652365+ const ret = wasm.ytext_toDelta(
23662366+ this.__wbg_ptr,
23672367+ snapshot,
23682368+ prev_snapshot,
23692369+ isLikeNone(compute_ychange) ? 0 : addToExternrefTable0(compute_ychange),
23702370+ txn,
23712371+ );
23722372+ if (ret[2]) {
23732373+ throw takeFromExternrefTable0(ret[1]);
23742374+ }
23752375+ return takeFromExternrefTable0(ret[0]);
23762376+ }
23772377+ /**
23782378+ * @param {Array<any>} delta
23792379+ * @param {YTransaction | undefined} txn
23802380+ */
23812381+ applyDelta(delta, txn) {
23822382+ const ret = wasm.ytext_applyDelta(this.__wbg_ptr, delta, txn);
23832383+ if (ret[1]) {
23842384+ throw takeFromExternrefTable0(ret[0]);
23852385+ }
23862386+ }
23872387+ /**
23882388+ * Subscribes to all operations happening over this instance of `YText`. All changes are
23892389+ * batched and eventually triggered during transaction commit phase.
23902390+ * @param {Function} callback
23912391+ */
23922392+ observe(callback) {
23932393+ const ret = wasm.ytext_observe(this.__wbg_ptr, callback);
23942394+ if (ret[1]) {
23952395+ throw takeFromExternrefTable0(ret[0]);
23962396+ }
23972397+ }
23982398+ /**
23992399+ * Unsubscribes a callback previously subscribed with `observe` method.
24002400+ * @param {Function} callback
24012401+ * @returns {boolean}
24022402+ */
24032403+ unobserve(callback) {
24042404+ const ret = wasm.ytext_unobserve(this.__wbg_ptr, callback);
24052405+ if (ret[2]) {
24062406+ throw takeFromExternrefTable0(ret[1]);
24072407+ }
24082408+ return ret[0] !== 0;
24092409+ }
24102410+ /**
24112411+ * Subscribes to all operations happening over this Y shared type, as well as events in
24122412+ * shared types stored within this one. All changes are batched and eventually triggered
24132413+ * during transaction commit phase.
24142414+ * @param {Function} callback
24152415+ */
24162416+ observeDeep(callback) {
24172417+ const ret = wasm.ytext_observeDeep(this.__wbg_ptr, callback);
24182418+ if (ret[1]) {
24192419+ throw takeFromExternrefTable0(ret[0]);
24202420+ }
24212421+ }
24222422+ /**
24232423+ * Unsubscribes a callback previously subscribed with `observeDeep` method.
24242424+ * @param {Function} callback
24252425+ * @returns {boolean}
24262426+ */
24272427+ unobserveDeep(callback) {
24282428+ const ret = wasm.ytext_unobserveDeep(this.__wbg_ptr, callback);
24292429+ if (ret[2]) {
24302430+ throw takeFromExternrefTable0(ret[1]);
24312431+ }
24322432+ return ret[0] !== 0;
24332433+ }
24342434+}
24352435+module.exports.YText = YText;
24362436+24372437+const YTextEventFinalization =
24382438+ typeof FinalizationRegistry === "undefined"
24392439+ ? { register: () => {}, unregister: () => {} }
24402440+ : new FinalizationRegistry((ptr) =>
24412441+ wasm.__wbg_ytextevent_free(ptr >>> 0, 1),
24422442+ );
24432443+/**
24442444+ * Event generated by `YYText.observe` method. Emitted during transaction commit phase.
24452445+ */
24462446+class YTextEvent {
24472447+ static __wrap(ptr) {
24482448+ ptr = ptr >>> 0;
24492449+ const obj = Object.create(YTextEvent.prototype);
24502450+ obj.__wbg_ptr = ptr;
24512451+ YTextEventFinalization.register(obj, obj.__wbg_ptr, obj);
24522452+ return obj;
24532453+ }
24542454+24552455+ __destroy_into_raw() {
24562456+ const ptr = this.__wbg_ptr;
24572457+ this.__wbg_ptr = 0;
24582458+ YTextEventFinalization.unregister(this);
24592459+ return ptr;
24602460+ }
24612461+24622462+ free() {
24632463+ const ptr = this.__destroy_into_raw();
24642464+ wasm.__wbg_ytextevent_free(ptr, 0);
24652465+ }
24662466+ /**
24672467+ * Returns an array of keys and indexes creating a path from root type down to current instance
24682468+ * of shared type (accessible via `target` getter).
24692469+ * @returns {any}
24702470+ */
24712471+ path() {
24722472+ const ret = wasm.ytextevent_path(this.__wbg_ptr);
24732473+ return ret;
24742474+ }
24752475+ /**
24762476+ * Returns a current shared type instance, that current event changes refer to.
24772477+ * @returns {any}
24782478+ */
24792479+ get target() {
24802480+ const ret = wasm.ytextevent_target(this.__wbg_ptr);
24812481+ return ret;
24822482+ }
24832483+ /**
24842484+ * @returns {any}
24852485+ */
24862486+ get origin() {
24872487+ const ret = wasm.ytextevent_origin(this.__wbg_ptr);
24882488+ return ret;
24892489+ }
24902490+ /**
24912491+ * Returns a list of text changes made over corresponding `YText` collection within
24922492+ * bounds of current transaction. These changes follow a format:
24932493+ *
24942494+ * - { insert: string, attributes: any|undefined }
24952495+ * - { delete: number }
24962496+ * - { retain: number, attributes: any|undefined }
24972497+ * @returns {any}
24982498+ */
24992499+ get delta() {
25002500+ const ret = wasm.ytextevent_delta(this.__wbg_ptr);
25012501+ if (ret[2]) {
25022502+ throw takeFromExternrefTable0(ret[1]);
25032503+ }
25042504+ return takeFromExternrefTable0(ret[0]);
25052505+ }
25062506+}
25072507+module.exports.YTextEvent = YTextEvent;
25082508+25092509+const YTransactionFinalization =
25102510+ typeof FinalizationRegistry === "undefined"
25112511+ ? { register: () => {}, unregister: () => {} }
25122512+ : new FinalizationRegistry((ptr) =>
25132513+ wasm.__wbg_ytransaction_free(ptr >>> 0, 1),
25142514+ );
25152515+25162516+class YTransaction {
25172517+ static __wrap(ptr) {
25182518+ ptr = ptr >>> 0;
25192519+ const obj = Object.create(YTransaction.prototype);
25202520+ obj.__wbg_ptr = ptr;
25212521+ YTransactionFinalization.register(obj, obj.__wbg_ptr, obj);
25222522+ return obj;
25232523+ }
25242524+25252525+ __destroy_into_raw() {
25262526+ const ptr = this.__wbg_ptr;
25272527+ this.__wbg_ptr = 0;
25282528+ YTransactionFinalization.unregister(this);
25292529+ return ptr;
25302530+ }
25312531+25322532+ free() {
25332533+ const ptr = this.__destroy_into_raw();
25342534+ wasm.__wbg_ytransaction_free(ptr, 0);
25352535+ }
25362536+ /**
25372537+ * Returns state vector describing the state of the document
25382538+ * at the moment when the transaction began.
25392539+ * @returns {Map<any, any>}
25402540+ */
25412541+ get beforeState() {
25422542+ const ret = wasm.ytransaction_beforeState(this.__wbg_ptr);
25432543+ return ret;
25442544+ }
25452545+ /**
25462546+ * Returns state vector describing the current state of
25472547+ * the document.
25482548+ * @returns {Map<any, any>}
25492549+ */
25502550+ get afterState() {
25512551+ const ret = wasm.ytransaction_afterState(this.__wbg_ptr);
25522552+ return ret;
25532553+ }
25542554+ /**
25552555+ * @returns {any}
25562556+ */
25572557+ get pendingStructs() {
25582558+ const ret = wasm.ytransaction_pendingStructs(this.__wbg_ptr);
25592559+ if (ret[2]) {
25602560+ throw takeFromExternrefTable0(ret[1]);
25612561+ }
25622562+ return takeFromExternrefTable0(ret[0]);
25632563+ }
25642564+ /**
25652565+ * Returns a unapplied delete set, that was received in one of the previous remote updates.
25662566+ * This DeleteSet is waiting for a missing updates to arrive in order to be applied.
25672567+ * @returns {Map<any, any> | undefined}
25682568+ */
25692569+ get pendingDeleteSet() {
25702570+ const ret = wasm.ytransaction_pendingDeleteSet(this.__wbg_ptr);
25712571+ return ret;
25722572+ }
25732573+ /**
25742574+ * Returns a delete set containing information about
25752575+ * all blocks removed as part of a current transaction.
25762576+ * @returns {Map<any, any>}
25772577+ */
25782578+ get deleteSet() {
25792579+ const ret = wasm.ytransaction_deleteSet(this.__wbg_ptr);
25802580+ return ret;
25812581+ }
25822582+ /**
25832583+ * @returns {any}
25842584+ */
25852585+ get origin() {
25862586+ const ret = wasm.ytransaction_origin(this.__wbg_ptr);
25872587+ return ret;
25882588+ }
25892589+ /**
25902590+ * Given a logical identifier of the collection (obtained via `YText.id`, `YArray.id` etc.),
25912591+ * attempts to return an instance of that collection in the scope of current document.
25922592+ *
25932593+ * Returns `undefined` if an instance was not defined locally, haven't been integrated or
25942594+ * has been deleted.
25952595+ * @param {any} id
25962596+ * @returns {any}
25972597+ */
25982598+ get(id) {
25992599+ const ret = wasm.ytransaction_get(this.__wbg_ptr, id);
26002600+ if (ret[2]) {
26012601+ throw takeFromExternrefTable0(ret[1]);
26022602+ }
26032603+ return takeFromExternrefTable0(ret[0]);
26042604+ }
26052605+ /**
26062606+ * Triggers a post-update series of operations without `free`ing the transaction. This includes
26072607+ * compaction and optimization of internal representation of updates, triggering events etc.
26082608+ * ywasm transactions are auto-committed when they are `free`d.
26092609+ */
26102610+ commit() {
26112611+ const ret = wasm.ytransaction_commit(this.__wbg_ptr);
26122612+ if (ret[1]) {
26132613+ throw takeFromExternrefTable0(ret[0]);
26142614+ }
26152615+ }
26162616+ /**
26172617+ * Encodes a state vector of a given transaction document into its binary representation using
26182618+ * lib0 v1 encoding. State vector is a compact representation of updates performed on a given
26192619+ * document and can be used by `encode_state_as_update` on remote peer to generate a delta
26202620+ * update payload to synchronize changes between peers.
26212621+ *
26222622+ * Example:
26232623+ *
26242624+ * ```javascript
26252625+ * import YDoc from 'ywasm'
26262626+ *
26272627+ * /// document on machine A
26282628+ * const localDoc = new YDoc()
26292629+ * const localTxn = localDoc.beginTransaction()
26302630+ *
26312631+ * // document on machine B
26322632+ * const remoteDoc = new YDoc()
26332633+ * const remoteTxn = localDoc.beginTransaction()
26342634+ *
26352635+ * try {
26362636+ * const localSV = localTxn.stateVectorV1()
26372637+ * const remoteDelta = remoteTxn.diffV1(localSv)
26382638+ * localTxn.applyV1(remoteDelta)
26392639+ * } finally {
26402640+ * localTxn.free()
26412641+ * remoteTxn.free()
26422642+ * }
26432643+ * ```
26442644+ * @returns {Uint8Array}
26452645+ */
26462646+ stateVectorV1() {
26472647+ const ret = wasm.ytransaction_stateVectorV1(this.__wbg_ptr);
26482648+ return ret;
26492649+ }
26502650+ /**
26512651+ * Encodes all updates that have happened since a given version `vector` into a compact delta
26522652+ * representation using lib0 v1 encoding. If `vector` parameter has not been provided, generated
26532653+ * delta payload will contain all changes of a current ywasm document, working effectively as
26542654+ * its state snapshot.
26552655+ *
26562656+ * Example:
26572657+ *
26582658+ * ```javascript
26592659+ * import YDoc from 'ywasm'
26602660+ *
26612661+ * /// document on machine A
26622662+ * const localDoc = new YDoc()
26632663+ * const localTxn = localDoc.beginTransaction()
26642664+ *
26652665+ * // document on machine B
26662666+ * const remoteDoc = new YDoc()
26672667+ * const remoteTxn = localDoc.beginTransaction()
26682668+ *
26692669+ * try {
26702670+ * const localSV = localTxn.stateVectorV1()
26712671+ * const remoteDelta = remoteTxn.diffV1(localSv)
26722672+ * localTxn.applyV1(remoteDelta)
26732673+ * } finally {
26742674+ * localTxn.free()
26752675+ * remoteTxn.free()
26762676+ * }
26772677+ * ```
26782678+ * @param {Uint8Array | null} [vector]
26792679+ * @returns {Uint8Array}
26802680+ */
26812681+ diffV1(vector) {
26822682+ const ret = wasm.ytransaction_diffV1(
26832683+ this.__wbg_ptr,
26842684+ isLikeNone(vector) ? 0 : addToExternrefTable0(vector),
26852685+ );
26862686+ if (ret[2]) {
26872687+ throw takeFromExternrefTable0(ret[1]);
26882688+ }
26892689+ return takeFromExternrefTable0(ret[0]);
26902690+ }
26912691+ /**
26922692+ * Encodes all updates that have happened since a given version `vector` into a compact delta
26932693+ * representation using lib0 v1 encoding. If `vector` parameter has not been provided, generated
26942694+ * delta payload will contain all changes of a current ywasm document, working effectively as
26952695+ * its state snapshot.
26962696+ *
26972697+ * Example:
26982698+ *
26992699+ * ```javascript
27002700+ * import YDoc from 'ywasm'
27012701+ *
27022702+ * /// document on machine A
27032703+ * const localDoc = new YDoc()
27042704+ * const localTxn = localDoc.beginTransaction()
27052705+ *
27062706+ * // document on machine B
27072707+ * const remoteDoc = new YDoc()
27082708+ * const remoteTxn = localDoc.beginTransaction()
27092709+ *
27102710+ * try {
27112711+ * const localSV = localTxn.stateVectorV1()
27122712+ * const remoteDelta = remoteTxn.diffV2(localSv)
27132713+ * localTxn.applyV2(remoteDelta)
27142714+ * } finally {
27152715+ * localTxn.free()
27162716+ * remoteTxn.free()
27172717+ * }
27182718+ * ```
27192719+ * @param {Uint8Array | null} [vector]
27202720+ * @returns {Uint8Array}
27212721+ */
27222722+ diffV2(vector) {
27232723+ const ret = wasm.ytransaction_diffV2(
27242724+ this.__wbg_ptr,
27252725+ isLikeNone(vector) ? 0 : addToExternrefTable0(vector),
27262726+ );
27272727+ if (ret[2]) {
27282728+ throw takeFromExternrefTable0(ret[1]);
27292729+ }
27302730+ return takeFromExternrefTable0(ret[0]);
27312731+ }
27322732+ /**
27332733+ * Applies delta update generated by the remote document replica to a current transaction's
27342734+ * document. This method assumes that a payload maintains lib0 v1 encoding format.
27352735+ *
27362736+ * Example:
27372737+ *
27382738+ * ```javascript
27392739+ * import YDoc from 'ywasm'
27402740+ *
27412741+ * /// document on machine A
27422742+ * const localDoc = new YDoc()
27432743+ * const localTxn = localDoc.beginTransaction()
27442744+ *
27452745+ * // document on machine B
27462746+ * const remoteDoc = new YDoc()
27472747+ * const remoteTxn = localDoc.beginTransaction()
27482748+ *
27492749+ * try {
27502750+ * const localSV = localTxn.stateVectorV1()
27512751+ * const remoteDelta = remoteTxn.diffV1(localSv)
27522752+ * localTxn.applyV1(remoteDelta)
27532753+ * } finally {
27542754+ * localTxn.free()
27552755+ * remoteTxn.free()
27562756+ * }
27572757+ * ```
27582758+ * @param {Uint8Array} diff
27592759+ */
27602760+ applyV1(diff) {
27612761+ const ret = wasm.ytransaction_applyV1(this.__wbg_ptr, diff);
27622762+ if (ret[1]) {
27632763+ throw takeFromExternrefTable0(ret[0]);
27642764+ }
27652765+ }
27662766+ /**
27672767+ * Applies delta update generated by the remote document replica to a current transaction's
27682768+ * document. This method assumes that a payload maintains lib0 v2 encoding format.
27692769+ *
27702770+ * Example:
27712771+ *
27722772+ * ```javascript
27732773+ * import YDoc from 'ywasm'
27742774+ *
27752775+ * /// document on machine A
27762776+ * const localDoc = new YDoc()
27772777+ * const localTxn = localDoc.beginTransaction()
27782778+ *
27792779+ * // document on machine B
27802780+ * const remoteDoc = new YDoc()
27812781+ * const remoteTxn = localDoc.beginTransaction()
27822782+ *
27832783+ * try {
27842784+ * const localSV = localTxn.stateVectorV1()
27852785+ * const remoteDelta = remoteTxn.diffV2(localSv)
27862786+ * localTxn.applyV2(remoteDelta)
27872787+ * } finally {
27882788+ * localTxn.free()
27892789+ * remoteTxn.free()
27902790+ * }
27912791+ * ```
27922792+ * @param {Uint8Array} diff
27932793+ */
27942794+ applyV2(diff) {
27952795+ const ret = wasm.ytransaction_applyV2(this.__wbg_ptr, diff);
27962796+ if (ret[1]) {
27972797+ throw takeFromExternrefTable0(ret[0]);
27982798+ }
27992799+ }
28002800+ /**
28012801+ * @returns {Uint8Array}
28022802+ */
28032803+ encodeUpdate() {
28042804+ const ret = wasm.ytransaction_encodeUpdate(this.__wbg_ptr);
28052805+ return ret;
28062806+ }
28072807+ /**
28082808+ * @returns {Uint8Array}
28092809+ */
28102810+ encodeUpdateV2() {
28112811+ const ret = wasm.ytransaction_encodeUpdateV2(this.__wbg_ptr);
28122812+ return ret;
28132813+ }
28142814+ /**
28152815+ * Force garbage collection of the deleted elements, regardless of a parent doc was created
28162816+ * with `gc` option turned on or off.
28172817+ */
28182818+ gc() {
28192819+ const ret = wasm.ytransaction_gc(this.__wbg_ptr);
28202820+ if (ret[1]) {
28212821+ throw takeFromExternrefTable0(ret[0]);
28222822+ }
28232823+ }
28242824+ /**
28252825+ * Evaluates a JSON path expression (see: https://en.wikipedia.org/wiki/JSONPath) on
28262826+ * the document and returns an array of values matching that query.
28272827+ *
28282828+ * Currently, this method supports the following syntax:
28292829+ * - `$` - root object
28302830+ * - `@` - current object
28312831+ * - `.field` or `['field']` - member accessor
28322832+ * - `[1]` - array index (also supports negative indices)
28332833+ * - `.*` or `[*]` - wildcard (matches all members of an object or array)
28342834+ * - `..` - recursive descent (matches all descendants not only direct children)
28352835+ * - `[start:end:step]` - array slice operator (requires positive integer arguments)
28362836+ * - `['a', 'b', 'c']` - union operator (returns an array of values for each query)
28372837+ * - `[1, -1, 3]` - multiple indices operator (returns an array of values for each index)
28382838+ *
28392839+ * At the moment, JSON Path does not support filter predicates.
28402840+ * @param {string} json_path
28412841+ * @returns {Array<any>}
28422842+ */
28432843+ selectAll(json_path) {
28442844+ const ptr0 = passStringToWasm0(
28452845+ json_path,
28462846+ wasm.__wbindgen_malloc,
28472847+ wasm.__wbindgen_realloc,
28482848+ );
28492849+ const len0 = WASM_VECTOR_LEN;
28502850+ const ret = wasm.ytransaction_selectAll(this.__wbg_ptr, ptr0, len0);
28512851+ if (ret[2]) {
28522852+ throw takeFromExternrefTable0(ret[1]);
28532853+ }
28542854+ return takeFromExternrefTable0(ret[0]);
28552855+ }
28562856+ /**
28572857+ * Evaluates a JSON path expression (see: https://en.wikipedia.org/wiki/JSONPath) on
28582858+ * the document and returns first value matching that query.
28592859+ *
28602860+ * Currently, this method supports the following syntax:
28612861+ * - `$` - root object
28622862+ * - `@` - current object
28632863+ * - `.field` or `['field']` - member accessor
28642864+ * - `[1]` - array index (also supports negative indices)
28652865+ * - `.*` or `[*]` - wildcard (matches all members of an object or array)
28662866+ * - `..` - recursive descent (matches all descendants not only direct children)
28672867+ * - `[start:end:step]` - array slice operator (requires positive integer arguments)
28682868+ * - `['a', 'b', 'c']` - union operator (returns an array of values for each query)
28692869+ * - `[1, -1, 3]` - multiple indices operator (returns an array of values for each index)
28702870+ *
28712871+ * At the moment, JSON Path does not support filter predicates.
28722872+ * @param {string} json_path
28732873+ * @returns {any}
28742874+ */
28752875+ selectOne(json_path) {
28762876+ const ptr0 = passStringToWasm0(
28772877+ json_path,
28782878+ wasm.__wbindgen_malloc,
28792879+ wasm.__wbindgen_realloc,
28802880+ );
28812881+ const len0 = WASM_VECTOR_LEN;
28822882+ const ret = wasm.ytransaction_selectOne(this.__wbg_ptr, ptr0, len0);
28832883+ if (ret[2]) {
28842884+ throw takeFromExternrefTable0(ret[1]);
28852885+ }
28862886+ return takeFromExternrefTable0(ret[0]);
28872887+ }
28882888+}
28892889+module.exports.YTransaction = YTransaction;
28902890+28912891+const YUndoEventFinalization =
28922892+ typeof FinalizationRegistry === "undefined"
28932893+ ? { register: () => {}, unregister: () => {} }
28942894+ : new FinalizationRegistry((ptr) =>
28952895+ wasm.__wbg_yundoevent_free(ptr >>> 0, 1),
28962896+ );
28972897+28982898+class YUndoEvent {
28992899+ static __wrap(ptr) {
29002900+ ptr = ptr >>> 0;
29012901+ const obj = Object.create(YUndoEvent.prototype);
29022902+ obj.__wbg_ptr = ptr;
29032903+ YUndoEventFinalization.register(obj, obj.__wbg_ptr, obj);
29042904+ return obj;
29052905+ }
29062906+29072907+ __destroy_into_raw() {
29082908+ const ptr = this.__wbg_ptr;
29092909+ this.__wbg_ptr = 0;
29102910+ YUndoEventFinalization.unregister(this);
29112911+ return ptr;
29122912+ }
29132913+29142914+ free() {
29152915+ const ptr = this.__destroy_into_raw();
29162916+ wasm.__wbg_yundoevent_free(ptr, 0);
29172917+ }
29182918+ /**
29192919+ * @returns {any}
29202920+ */
29212921+ get origin() {
29222922+ const ret = wasm.yundoevent_origin(this.__wbg_ptr);
29232923+ return ret;
29242924+ }
29252925+ /**
29262926+ * @returns {any}
29272927+ */
29282928+ get kind() {
29292929+ const ret = wasm.yundoevent_kind(this.__wbg_ptr);
29302930+ return ret;
29312931+ }
29322932+ /**
29332933+ * @returns {any}
29342934+ */
29352935+ get meta() {
29362936+ const ret = wasm.yundoevent_meta(this.__wbg_ptr);
29372937+ return ret;
29382938+ }
29392939+ /**
29402940+ * @param {any} value
29412941+ */
29422942+ set meta(value) {
29432943+ wasm.yundoevent_set_meta(this.__wbg_ptr, value);
29442944+ }
29452945+}
29462946+module.exports.YUndoEvent = YUndoEvent;
29472947+29482948+const YUndoManagerFinalization =
29492949+ typeof FinalizationRegistry === "undefined"
29502950+ ? { register: () => {}, unregister: () => {} }
29512951+ : new FinalizationRegistry((ptr) =>
29522952+ wasm.__wbg_yundomanager_free(ptr >>> 0, 1),
29532953+ );
29542954+29552955+class YUndoManager {
29562956+ __destroy_into_raw() {
29572957+ const ptr = this.__wbg_ptr;
29582958+ this.__wbg_ptr = 0;
29592959+ YUndoManagerFinalization.unregister(this);
29602960+ return ptr;
29612961+ }
29622962+29632963+ free() {
29642964+ const ptr = this.__destroy_into_raw();
29652965+ wasm.__wbg_yundomanager_free(ptr, 0);
29662966+ }
29672967+ /**
29682968+ * @param {YDoc} doc
29692969+ * @param {any} scope
29702970+ * @param {any} options
29712971+ */
29722972+ constructor(doc, scope, options) {
29732973+ _assertClass(doc, YDoc);
29742974+ const ret = wasm.yundomanager_new(doc.__wbg_ptr, scope, options);
29752975+ if (ret[2]) {
29762976+ throw takeFromExternrefTable0(ret[1]);
29772977+ }
29782978+ this.__wbg_ptr = ret[0] >>> 0;
29792979+ YUndoManagerFinalization.register(this, this.__wbg_ptr, this);
29802980+ return this;
29812981+ }
29822982+ /**
29832983+ * @param {Array<any>} ytypes
29842984+ */
29852985+ addToScope(ytypes) {
29862986+ const ret = wasm.yundomanager_addToScope(this.__wbg_ptr, ytypes);
29872987+ if (ret[1]) {
29882988+ throw takeFromExternrefTable0(ret[0]);
29892989+ }
29902990+ }
29912991+ /**
29922992+ * @param {any} origin
29932993+ */
29942994+ addTrackedOrigin(origin) {
29952995+ wasm.yundomanager_addTrackedOrigin(this.__wbg_ptr, origin);
29962996+ }
29972997+ /**
29982998+ * @param {any} origin
29992999+ */
30003000+ removeTrackedOrigin(origin) {
30013001+ wasm.yundomanager_removeTrackedOrigin(this.__wbg_ptr, origin);
30023002+ }
30033003+ clear() {
30043004+ wasm.yundomanager_clear(this.__wbg_ptr);
30053005+ }
30063006+ stopCapturing() {
30073007+ wasm.yundomanager_stopCapturing(this.__wbg_ptr);
30083008+ }
30093009+ undo() {
30103010+ const ret = wasm.yundomanager_undo(this.__wbg_ptr);
30113011+ if (ret[1]) {
30123012+ throw takeFromExternrefTable0(ret[0]);
30133013+ }
30143014+ }
30153015+ redo() {
30163016+ const ret = wasm.yundomanager_redo(this.__wbg_ptr);
30173017+ if (ret[1]) {
30183018+ throw takeFromExternrefTable0(ret[0]);
30193019+ }
30203020+ }
30213021+ /**
30223022+ * @returns {boolean}
30233023+ */
30243024+ get canUndo() {
30253025+ const ret = wasm.yundomanager_canUndo(this.__wbg_ptr);
30263026+ return ret !== 0;
30273027+ }
30283028+ /**
30293029+ * @returns {boolean}
30303030+ */
30313031+ get canRedo() {
30323032+ const ret = wasm.yundomanager_canRedo(this.__wbg_ptr);
30333033+ return ret !== 0;
30343034+ }
30353035+ /**
30363036+ * @param {string} event
30373037+ * @param {Function} callback
30383038+ */
30393039+ on(event, callback) {
30403040+ const ptr0 = passStringToWasm0(
30413041+ event,
30423042+ wasm.__wbindgen_malloc,
30433043+ wasm.__wbindgen_realloc,
30443044+ );
30453045+ const len0 = WASM_VECTOR_LEN;
30463046+ const ret = wasm.yundomanager_on(this.__wbg_ptr, ptr0, len0, callback);
30473047+ if (ret[1]) {
30483048+ throw takeFromExternrefTable0(ret[0]);
30493049+ }
30503050+ }
30513051+ /**
30523052+ * @param {string} event
30533053+ * @param {Function} callback
30543054+ * @returns {boolean}
30553055+ */
30563056+ off(event, callback) {
30573057+ const ptr0 = passStringToWasm0(
30583058+ event,
30593059+ wasm.__wbindgen_malloc,
30603060+ wasm.__wbindgen_realloc,
30613061+ );
30623062+ const len0 = WASM_VECTOR_LEN;
30633063+ const ret = wasm.yundomanager_off(this.__wbg_ptr, ptr0, len0, callback);
30643064+ if (ret[2]) {
30653065+ throw takeFromExternrefTable0(ret[1]);
30663066+ }
30673067+ return ret[0] !== 0;
30683068+ }
30693069+}
30703070+module.exports.YUndoManager = YUndoManager;
30713071+30723072+const YWeakLinkFinalization =
30733073+ typeof FinalizationRegistry === "undefined"
30743074+ ? { register: () => {}, unregister: () => {} }
30753075+ : new FinalizationRegistry((ptr) =>
30763076+ wasm.__wbg_yweaklink_free(ptr >>> 0, 1),
30773077+ );
30783078+30793079+class YWeakLink {
30803080+ static __wrap(ptr) {
30813081+ ptr = ptr >>> 0;
30823082+ const obj = Object.create(YWeakLink.prototype);
30833083+ obj.__wbg_ptr = ptr;
30843084+ YWeakLinkFinalization.register(obj, obj.__wbg_ptr, obj);
30853085+ return obj;
30863086+ }
30873087+30883088+ __destroy_into_raw() {
30893089+ const ptr = this.__wbg_ptr;
30903090+ this.__wbg_ptr = 0;
30913091+ YWeakLinkFinalization.unregister(this);
30923092+ return ptr;
30933093+ }
30943094+30953095+ free() {
30963096+ const ptr = this.__destroy_into_raw();
30973097+ wasm.__wbg_yweaklink_free(ptr, 0);
30983098+ }
30993099+ /**
31003100+ * Returns true if this is a preliminary instance of `YWeakLink`.
31013101+ *
31023102+ * Preliminary instances can be nested into other shared data types such as `YArray` and `YMap`.
31033103+ * Once a preliminary instance has been inserted this way, it becomes integrated into ywasm
31043104+ * document store and cannot be nested again: attempt to do so will result in an exception.
31053105+ * @returns {boolean}
31063106+ */
31073107+ get prelim() {
31083108+ const ret = wasm.yweaklink_prelim(this.__wbg_ptr);
31093109+ return ret !== 0;
31103110+ }
31113111+ /**
31123112+ * @returns {number}
31133113+ */
31143114+ get type() {
31153115+ const ret = wasm.yweaklink_type(this.__wbg_ptr);
31163116+ return ret;
31173117+ }
31183118+ /**
31193119+ * Gets unique logical identifier of this type, shared across peers collaborating on the same
31203120+ * document.
31213121+ * @returns {any}
31223122+ */
31233123+ get id() {
31243124+ const ret = wasm.yweaklink_id(this.__wbg_ptr);
31253125+ if (ret[2]) {
31263126+ throw takeFromExternrefTable0(ret[1]);
31273127+ }
31283128+ return takeFromExternrefTable0(ret[0]);
31293129+ }
31303130+ /**
31313131+ * Checks if current YWeakLink reference is alive and has not been deleted by its parent collection.
31323132+ * This method only works on already integrated shared types and will return false is current
31333133+ * type is preliminary (has not been integrated into document).
31343134+ * @param {YTransaction} txn
31353135+ * @returns {boolean}
31363136+ */
31373137+ alive(txn) {
31383138+ _assertClass(txn, YTransaction);
31393139+ const ret = wasm.yweaklink_alive(this.__wbg_ptr, txn.__wbg_ptr);
31403140+ return ret !== 0;
31413141+ }
31423142+ /**
31433143+ * @param {YTransaction | undefined} txn
31443144+ * @returns {any}
31453145+ */
31463146+ deref(txn) {
31473147+ const ret = wasm.yweaklink_deref(this.__wbg_ptr, txn);
31483148+ if (ret[2]) {
31493149+ throw takeFromExternrefTable0(ret[1]);
31503150+ }
31513151+ return takeFromExternrefTable0(ret[0]);
31523152+ }
31533153+ /**
31543154+ * @param {YTransaction | undefined} txn
31553155+ * @returns {Array<any>}
31563156+ */
31573157+ unquote(txn) {
31583158+ const ret = wasm.yweaklink_unquote(this.__wbg_ptr, txn);
31593159+ if (ret[2]) {
31603160+ throw takeFromExternrefTable0(ret[1]);
31613161+ }
31623162+ return takeFromExternrefTable0(ret[0]);
31633163+ }
31643164+ /**
31653165+ * @param {YTransaction | undefined} txn
31663166+ * @returns {string}
31673167+ */
31683168+ toString(txn) {
31693169+ let deferred2_0;
31703170+ let deferred2_1;
31713171+ try {
31723172+ const ret = wasm.yweaklink_toString(this.__wbg_ptr, txn);
31733173+ var ptr1 = ret[0];
31743174+ var len1 = ret[1];
31753175+ if (ret[3]) {
31763176+ ptr1 = 0;
31773177+ len1 = 0;
31783178+ throw takeFromExternrefTable0(ret[2]);
31793179+ }
31803180+ deferred2_0 = ptr1;
31813181+ deferred2_1 = len1;
31823182+ return getStringFromWasm0(ptr1, len1);
31833183+ } finally {
31843184+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
31853185+ }
31863186+ }
31873187+ /**
31883188+ * Subscribes to all operations happening over this instance of `YMap`. All changes are
31893189+ * batched and eventually triggered during transaction commit phase.
31903190+ * @param {Function} callback
31913191+ */
31923192+ observe(callback) {
31933193+ const ret = wasm.yweaklink_observe(this.__wbg_ptr, callback);
31943194+ if (ret[1]) {
31953195+ throw takeFromExternrefTable0(ret[0]);
31963196+ }
31973197+ }
31983198+ /**
31993199+ * Unsubscribes a callback previously subscribed with `observe` method.
32003200+ * @param {Function} callback
32013201+ * @returns {boolean}
32023202+ */
32033203+ unobserve(callback) {
32043204+ const ret = wasm.yweaklink_unobserve(this.__wbg_ptr, callback);
32053205+ if (ret[2]) {
32063206+ throw takeFromExternrefTable0(ret[1]);
32073207+ }
32083208+ return ret[0] !== 0;
32093209+ }
32103210+ /**
32113211+ * Subscribes to all operations happening over this Y shared type, as well as events in
32123212+ * shared types stored within this one. All changes are batched and eventually triggered
32133213+ * during transaction commit phase.
32143214+ * @param {Function} callback
32153215+ */
32163216+ observeDeep(callback) {
32173217+ const ret = wasm.yweaklink_observeDeep(this.__wbg_ptr, callback);
32183218+ if (ret[1]) {
32193219+ throw takeFromExternrefTable0(ret[0]);
32203220+ }
32213221+ }
32223222+ /**
32233223+ * Unsubscribes a callback previously subscribed with `observeDeep` method.
32243224+ * @param {Function} callback
32253225+ * @returns {boolean}
32263226+ */
32273227+ unobserveDeep(callback) {
32283228+ const ret = wasm.yweaklink_unobserveDeep(this.__wbg_ptr, callback);
32293229+ if (ret[2]) {
32303230+ throw takeFromExternrefTable0(ret[1]);
32313231+ }
32323232+ return ret[0] !== 0;
32333233+ }
32343234+}
32353235+module.exports.YWeakLink = YWeakLink;
32363236+32373237+const YWeakLinkEventFinalization =
32383238+ typeof FinalizationRegistry === "undefined"
32393239+ ? { register: () => {}, unregister: () => {} }
32403240+ : new FinalizationRegistry((ptr) =>
32413241+ wasm.__wbg_yweaklinkevent_free(ptr >>> 0, 1),
32423242+ );
32433243+/**
32443244+ * Event generated by `YXmlElement.observe` method. Emitted during transaction commit phase.
32453245+ */
32463246+class YWeakLinkEvent {
32473247+ static __wrap(ptr) {
32483248+ ptr = ptr >>> 0;
32493249+ const obj = Object.create(YWeakLinkEvent.prototype);
32503250+ obj.__wbg_ptr = ptr;
32513251+ YWeakLinkEventFinalization.register(obj, obj.__wbg_ptr, obj);
32523252+ return obj;
32533253+ }
32543254+32553255+ __destroy_into_raw() {
32563256+ const ptr = this.__wbg_ptr;
32573257+ this.__wbg_ptr = 0;
32583258+ YWeakLinkEventFinalization.unregister(this);
32593259+ return ptr;
32603260+ }
32613261+32623262+ free() {
32633263+ const ptr = this.__destroy_into_raw();
32643264+ wasm.__wbg_yweaklinkevent_free(ptr, 0);
32653265+ }
32663266+ /**
32673267+ * @returns {any}
32683268+ */
32693269+ get origin() {
32703270+ const ret = wasm.yweaklinkevent_origin(this.__wbg_ptr);
32713271+ return ret;
32723272+ }
32733273+ /**
32743274+ * Returns a current shared type instance, that current event changes refer to.
32753275+ * @returns {any}
32763276+ */
32773277+ get target() {
32783278+ const ret = wasm.yweaklinkevent_target(this.__wbg_ptr);
32793279+ return ret;
32803280+ }
32813281+ /**
32823282+ * Returns an array of keys and indexes creating a path from root type down to current instance
32833283+ * of shared type (accessible via `target` getter).
32843284+ * @returns {any}
32853285+ */
32863286+ path() {
32873287+ const ret = wasm.yweaklinkevent_path(this.__wbg_ptr);
32883288+ return ret;
32893289+ }
32903290+}
32913291+module.exports.YWeakLinkEvent = YWeakLinkEvent;
32923292+32933293+const YXmlElementFinalization =
32943294+ typeof FinalizationRegistry === "undefined"
32953295+ ? { register: () => {}, unregister: () => {} }
32963296+ : new FinalizationRegistry((ptr) =>
32973297+ wasm.__wbg_yxmlelement_free(ptr >>> 0, 1),
32983298+ );
32993299+/**
33003300+ * XML element data type. It represents an XML node, which can contain key-value attributes
33013301+ * (interpreted as strings) as well as other nested XML elements or rich text (represented by
33023302+ * `YXmlText` type).
33033303+ *
33043304+ * In terms of conflict resolution, `YXmlElement` uses following rules:
33053305+ *
33063306+ * - Attribute updates use logical last-write-wins principle, meaning the past updates are
33073307+ * automatically overridden and discarded by newer ones, while concurrent updates made by
33083308+ * different peers are resolved into a single value using document id seniority to establish
33093309+ * an order.
33103310+ * - Child node insertion uses sequencing rules from other Yrs collections - elements are inserted
33113311+ * using interleave-resistant algorithm, where order of concurrent inserts at the same index
33123312+ * is established using peer's document id seniority.
33133313+ */
33143314+class YXmlElement {
33153315+ static __wrap(ptr) {
33163316+ ptr = ptr >>> 0;
33173317+ const obj = Object.create(YXmlElement.prototype);
33183318+ obj.__wbg_ptr = ptr;
33193319+ YXmlElementFinalization.register(obj, obj.__wbg_ptr, obj);
33203320+ return obj;
33213321+ }
33223322+33233323+ __destroy_into_raw() {
33243324+ const ptr = this.__wbg_ptr;
33253325+ this.__wbg_ptr = 0;
33263326+ YXmlElementFinalization.unregister(this);
33273327+ return ptr;
33283328+ }
33293329+33303330+ free() {
33313331+ const ptr = this.__destroy_into_raw();
33323332+ wasm.__wbg_yxmlelement_free(ptr, 0);
33333333+ }
33343334+ /**
33353335+ * @param {string} name
33363336+ * @param {any} attributes
33373337+ * @param {any} children
33383338+ */
33393339+ constructor(name, attributes, children) {
33403340+ const ptr0 = passStringToWasm0(
33413341+ name,
33423342+ wasm.__wbindgen_malloc,
33433343+ wasm.__wbindgen_realloc,
33443344+ );
33453345+ const len0 = WASM_VECTOR_LEN;
33463346+ const ret = wasm.yxmlelement_new(ptr0, len0, attributes, children);
33473347+ if (ret[2]) {
33483348+ throw takeFromExternrefTable0(ret[1]);
33493349+ }
33503350+ this.__wbg_ptr = ret[0] >>> 0;
33513351+ YXmlElementFinalization.register(this, this.__wbg_ptr, this);
33523352+ return this;
33533353+ }
33543354+ /**
33553355+ * @returns {number}
33563356+ */
33573357+ get type() {
33583358+ const ret = wasm.yxmlelement_type(this.__wbg_ptr);
33593359+ return ret;
33603360+ }
33613361+ /**
33623362+ * Gets unique logical identifier of this type, shared across peers collaborating on the same
33633363+ * document.
33643364+ * @returns {any}
33653365+ */
33663366+ get id() {
33673367+ const ret = wasm.yxmlelement_id(this.__wbg_ptr);
33683368+ if (ret[2]) {
33693369+ throw takeFromExternrefTable0(ret[1]);
33703370+ }
33713371+ return takeFromExternrefTable0(ret[0]);
33723372+ }
33733373+ /**
33743374+ * Returns true if this is a preliminary instance of `YXmlElement`.
33753375+ *
33763376+ * Preliminary instances can be nested into other shared data types.
33773377+ * Once a preliminary instance has been inserted this way, it becomes integrated into ywasm
33783378+ * document store and cannot be nested again: attempt to do so will result in an exception.
33793379+ * @returns {boolean}
33803380+ */
33813381+ get prelim() {
33823382+ const ret = wasm.yxmlelement_prelim(this.__wbg_ptr);
33833383+ return ret !== 0;
33843384+ }
33853385+ /**
33863386+ * Checks if current shared type reference is alive and has not been deleted by its parent collection.
33873387+ * This method only works on already integrated shared types and will return false is current
33883388+ * type is preliminary (has not been integrated into document).
33893389+ * @param {YTransaction} txn
33903390+ * @returns {boolean}
33913391+ */
33923392+ alive(txn) {
33933393+ _assertClass(txn, YTransaction);
33943394+ const ret = wasm.yxmlelement_alive(this.__wbg_ptr, txn.__wbg_ptr);
33953395+ return ret !== 0;
33963396+ }
33973397+ /**
33983398+ * Returns a tag name of this XML node.
33993399+ * @param {YTransaction | undefined} txn
34003400+ * @returns {string}
34013401+ */
34023402+ name(txn) {
34033403+ let deferred2_0;
34043404+ let deferred2_1;
34053405+ try {
34063406+ const ret = wasm.yxmlelement_name(this.__wbg_ptr, txn);
34073407+ var ptr1 = ret[0];
34083408+ var len1 = ret[1];
34093409+ if (ret[3]) {
34103410+ ptr1 = 0;
34113411+ len1 = 0;
34123412+ throw takeFromExternrefTable0(ret[2]);
34133413+ }
34143414+ deferred2_0 = ptr1;
34153415+ deferred2_1 = len1;
34163416+ return getStringFromWasm0(ptr1, len1);
34173417+ } finally {
34183418+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
34193419+ }
34203420+ }
34213421+ /**
34223422+ * Returns a number of child XML nodes stored within this `YXMlElement` instance.
34233423+ * @param {YTransaction | undefined} txn
34243424+ * @returns {number}
34253425+ */
34263426+ length(txn) {
34273427+ const ret = wasm.yxmlelement_length(this.__wbg_ptr, txn);
34283428+ if (ret[2]) {
34293429+ throw takeFromExternrefTable0(ret[1]);
34303430+ }
34313431+ return ret[0] >>> 0;
34323432+ }
34333433+ /**
34343434+ * @param {number} index
34353435+ * @param {any} xml_node
34363436+ * @param {YTransaction | undefined} txn
34373437+ */
34383438+ insert(index, xml_node, txn) {
34393439+ const ret = wasm.yxmlelement_insert(this.__wbg_ptr, index, xml_node, txn);
34403440+ if (ret[1]) {
34413441+ throw takeFromExternrefTable0(ret[0]);
34423442+ }
34433443+ }
34443444+ /**
34453445+ * @param {any} xml_node
34463446+ * @param {YTransaction | undefined} txn
34473447+ */
34483448+ push(xml_node, txn) {
34493449+ const ret = wasm.yxmlelement_push(this.__wbg_ptr, xml_node, txn);
34503450+ if (ret[1]) {
34513451+ throw takeFromExternrefTable0(ret[0]);
34523452+ }
34533453+ }
34543454+ /**
34553455+ * @param {number} index
34563456+ * @param {number | null | undefined} length
34573457+ * @param {YTransaction | undefined} txn
34583458+ */
34593459+ delete(index, length, txn) {
34603460+ const ret = wasm.yxmlelement_delete(
34613461+ this.__wbg_ptr,
34623462+ index,
34633463+ isLikeNone(length) ? 0x100000001 : length >>> 0,
34643464+ txn,
34653465+ );
34663466+ if (ret[1]) {
34673467+ throw takeFromExternrefTable0(ret[0]);
34683468+ }
34693469+ }
34703470+ /**
34713471+ * Returns a first child of this XML node.
34723472+ * It can be either `YXmlElement`, `YXmlText` or `undefined` if current node has not children.
34733473+ * @param {YTransaction | undefined} txn
34743474+ * @returns {any}
34753475+ */
34763476+ firstChild(txn) {
34773477+ const ret = wasm.yxmlelement_firstChild(this.__wbg_ptr, txn);
34783478+ if (ret[2]) {
34793479+ throw takeFromExternrefTable0(ret[1]);
34803480+ }
34813481+ return takeFromExternrefTable0(ret[0]);
34823482+ }
34833483+ /**
34843484+ * Returns a next XML sibling node of this XMl node.
34853485+ * It can be either `YXmlElement`, `YXmlText` or `undefined` if current node is a last child of
34863486+ * parent XML node.
34873487+ * @param {YTransaction | undefined} txn
34883488+ * @returns {any}
34893489+ */
34903490+ nextSibling(txn) {
34913491+ const ret = wasm.yxmlelement_nextSibling(this.__wbg_ptr, txn);
34923492+ if (ret[2]) {
34933493+ throw takeFromExternrefTable0(ret[1]);
34943494+ }
34953495+ return takeFromExternrefTable0(ret[0]);
34963496+ }
34973497+ /**
34983498+ * Returns a previous XML sibling node of this XMl node.
34993499+ * It can be either `YXmlElement`, `YXmlText` or `undefined` if current node is a first child
35003500+ * of parent XML node.
35013501+ * @param {YTransaction | undefined} txn
35023502+ * @returns {any}
35033503+ */
35043504+ prevSibling(txn) {
35053505+ const ret = wasm.yxmlelement_prevSibling(this.__wbg_ptr, txn);
35063506+ if (ret[2]) {
35073507+ throw takeFromExternrefTable0(ret[1]);
35083508+ }
35093509+ return takeFromExternrefTable0(ret[0]);
35103510+ }
35113511+ /**
35123512+ * Returns a parent `YXmlElement` node or `undefined` if current node has no parent assigned.
35133513+ * @param {YTransaction | undefined} txn
35143514+ * @returns {any}
35153515+ */
35163516+ parent(txn) {
35173517+ const ret = wasm.yxmlelement_parent(this.__wbg_ptr, txn);
35183518+ if (ret[2]) {
35193519+ throw takeFromExternrefTable0(ret[1]);
35203520+ }
35213521+ return takeFromExternrefTable0(ret[0]);
35223522+ }
35233523+ /**
35243524+ * Returns a string representation of this XML node.
35253525+ * @param {YTransaction | undefined} txn
35263526+ * @returns {string}
35273527+ */
35283528+ toString(txn) {
35293529+ let deferred2_0;
35303530+ let deferred2_1;
35313531+ try {
35323532+ const ret = wasm.yxmlelement_toString(this.__wbg_ptr, txn);
35333533+ var ptr1 = ret[0];
35343534+ var len1 = ret[1];
35353535+ if (ret[3]) {
35363536+ ptr1 = 0;
35373537+ len1 = 0;
35383538+ throw takeFromExternrefTable0(ret[2]);
35393539+ }
35403540+ deferred2_0 = ptr1;
35413541+ deferred2_1 = len1;
35423542+ return getStringFromWasm0(ptr1, len1);
35433543+ } finally {
35443544+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
35453545+ }
35463546+ }
35473547+ /**
35483548+ * Sets a `name` and `value` as new attribute for this XML node. If an attribute with the same
35493549+ * `name` already existed on that node, its value with be overridden with a provided one.
35503550+ * This method accepts any JavaScript value, not just strings.
35513551+ * @param {string} name
35523552+ * @param {any} value
35533553+ * @param {YTransaction | undefined} txn
35543554+ */
35553555+ setAttribute(name, value, txn) {
35563556+ const ptr0 = passStringToWasm0(
35573557+ name,
35583558+ wasm.__wbindgen_malloc,
35593559+ wasm.__wbindgen_realloc,
35603560+ );
35613561+ const len0 = WASM_VECTOR_LEN;
35623562+ const ret = wasm.yxmlelement_setAttribute(
35633563+ this.__wbg_ptr,
35643564+ ptr0,
35653565+ len0,
35663566+ value,
35673567+ txn,
35683568+ );
35693569+ if (ret[1]) {
35703570+ throw takeFromExternrefTable0(ret[0]);
35713571+ }
35723572+ }
35733573+ /**
35743574+ * Returns a value of an attribute given its `name` as any JS value. If no attribute with such name existed,
35753575+ * `undefined` will be returned.
35763576+ * @param {string} name
35773577+ * @param {YTransaction | undefined} txn
35783578+ * @returns {any}
35793579+ */
35803580+ getAttribute(name, txn) {
35813581+ const ptr0 = passStringToWasm0(
35823582+ name,
35833583+ wasm.__wbindgen_malloc,
35843584+ wasm.__wbindgen_realloc,
35853585+ );
35863586+ const len0 = WASM_VECTOR_LEN;
35873587+ const ret = wasm.yxmlelement_getAttribute(this.__wbg_ptr, ptr0, len0, txn);
35883588+ if (ret[2]) {
35893589+ throw takeFromExternrefTable0(ret[1]);
35903590+ }
35913591+ return takeFromExternrefTable0(ret[0]);
35923592+ }
35933593+ /**
35943594+ * Removes an attribute from this XML node, given its `name`.
35953595+ * @param {string} name
35963596+ * @param {YTransaction | undefined} txn
35973597+ */
35983598+ removeAttribute(name, txn) {
35993599+ const ptr0 = passStringToWasm0(
36003600+ name,
36013601+ wasm.__wbindgen_malloc,
36023602+ wasm.__wbindgen_realloc,
36033603+ );
36043604+ const len0 = WASM_VECTOR_LEN;
36053605+ const ret = wasm.yxmlelement_removeAttribute(
36063606+ this.__wbg_ptr,
36073607+ ptr0,
36083608+ len0,
36093609+ txn,
36103610+ );
36113611+ if (ret[1]) {
36123612+ throw takeFromExternrefTable0(ret[0]);
36133613+ }
36143614+ }
36153615+ /**
36163616+ * Returns an iterator that enables to traverse over all attributes of this XML node in
36173617+ * unspecified order. This method returns attribute values as their original JS values,
36183618+ * not just as strings.
36193619+ * @param {YTransaction | undefined} txn
36203620+ * @returns {any}
36213621+ */
36223622+ attributes(txn) {
36233623+ const ret = wasm.yxmlelement_attributes(this.__wbg_ptr, txn);
36243624+ if (ret[2]) {
36253625+ throw takeFromExternrefTable0(ret[1]);
36263626+ }
36273627+ return takeFromExternrefTable0(ret[0]);
36283628+ }
36293629+ /**
36303630+ * Returns an iterator that enables a deep traversal of this XML node - starting from first
36313631+ * child over this XML node successors using depth-first strategy.
36323632+ * @param {YTransaction | undefined} txn
36333633+ * @returns {Array<any>}
36343634+ */
36353635+ treeWalker(txn) {
36363636+ const ret = wasm.yxmlelement_treeWalker(this.__wbg_ptr, txn);
36373637+ if (ret[2]) {
36383638+ throw takeFromExternrefTable0(ret[1]);
36393639+ }
36403640+ return takeFromExternrefTable0(ret[0]);
36413641+ }
36423642+ /**
36433643+ * Subscribes to all operations happening over this instance of `YXmlElement`. All changes are
36443644+ * batched and eventually triggered during transaction commit phase.
36453645+ * @param {Function} callback
36463646+ */
36473647+ observe(callback) {
36483648+ const ret = wasm.yxmlelement_observe(this.__wbg_ptr, callback);
36493649+ if (ret[1]) {
36503650+ throw takeFromExternrefTable0(ret[0]);
36513651+ }
36523652+ }
36533653+ /**
36543654+ * Unsubscribes a callback previously subscribed with `observe` method.
36553655+ * @param {Function} callback
36563656+ * @returns {boolean}
36573657+ */
36583658+ unobserve(callback) {
36593659+ const ret = wasm.yxmlelement_unobserve(this.__wbg_ptr, callback);
36603660+ if (ret[2]) {
36613661+ throw takeFromExternrefTable0(ret[1]);
36623662+ }
36633663+ return ret[0] !== 0;
36643664+ }
36653665+ /**
36663666+ * Subscribes to all operations happening over this Y shared type, as well as events in
36673667+ * shared types stored within this one. All changes are batched and eventually triggered
36683668+ * during transaction commit phase.
36693669+ * @param {Function} callback
36703670+ */
36713671+ observeDeep(callback) {
36723672+ const ret = wasm.yxmlelement_observeDeep(this.__wbg_ptr, callback);
36733673+ if (ret[1]) {
36743674+ throw takeFromExternrefTable0(ret[0]);
36753675+ }
36763676+ }
36773677+ /**
36783678+ * Unsubscribes a callback previously subscribed with `observeDeep` method.
36793679+ * @param {Function} callback
36803680+ * @returns {boolean}
36813681+ */
36823682+ unobserveDeep(callback) {
36833683+ const ret = wasm.yxmlelement_unobserveDeep(this.__wbg_ptr, callback);
36843684+ if (ret[2]) {
36853685+ throw takeFromExternrefTable0(ret[1]);
36863686+ }
36873687+ return ret[0] !== 0;
36883688+ }
36893689+}
36903690+module.exports.YXmlElement = YXmlElement;
36913691+36923692+const YXmlEventFinalization =
36933693+ typeof FinalizationRegistry === "undefined"
36943694+ ? { register: () => {}, unregister: () => {} }
36953695+ : new FinalizationRegistry((ptr) =>
36963696+ wasm.__wbg_yxmlevent_free(ptr >>> 0, 1),
36973697+ );
36983698+/**
36993699+ * Event generated by `YXmlElement.observe` method. Emitted during transaction commit phase.
37003700+ */
37013701+class YXmlEvent {
37023702+ static __wrap(ptr) {
37033703+ ptr = ptr >>> 0;
37043704+ const obj = Object.create(YXmlEvent.prototype);
37053705+ obj.__wbg_ptr = ptr;
37063706+ YXmlEventFinalization.register(obj, obj.__wbg_ptr, obj);
37073707+ return obj;
37083708+ }
37093709+37103710+ __destroy_into_raw() {
37113711+ const ptr = this.__wbg_ptr;
37123712+ this.__wbg_ptr = 0;
37133713+ YXmlEventFinalization.unregister(this);
37143714+ return ptr;
37153715+ }
37163716+37173717+ free() {
37183718+ const ptr = this.__destroy_into_raw();
37193719+ wasm.__wbg_yxmlevent_free(ptr, 0);
37203720+ }
37213721+ /**
37223722+ * Returns an array of keys and indexes creating a path from root type down to current instance
37233723+ * of shared type (accessible via `target` getter).
37243724+ * @returns {any}
37253725+ */
37263726+ path() {
37273727+ const ret = wasm.yxmlevent_path(this.__wbg_ptr);
37283728+ return ret;
37293729+ }
37303730+ /**
37313731+ * Returns a current shared type instance, that current event changes refer to.
37323732+ * @returns {any}
37333733+ */
37343734+ get target() {
37353735+ const ret = wasm.yxmlevent_target(this.__wbg_ptr);
37363736+ return ret;
37373737+ }
37383738+ /**
37393739+ * @returns {any}
37403740+ */
37413741+ get origin() {
37423742+ const ret = wasm.yxmlevent_origin(this.__wbg_ptr);
37433743+ return ret;
37443744+ }
37453745+ /**
37463746+ * Returns a list of attribute changes made over corresponding `YXmlText` collection within
37473747+ * bounds of current transaction. These changes follow a format:
37483748+ *
37493749+ * - { action: 'add'|'update'|'delete', oldValue: string|undefined, newValue: string|undefined }
37503750+ * @returns {any}
37513751+ */
37523752+ get keys() {
37533753+ const ret = wasm.yxmlevent_keys(this.__wbg_ptr);
37543754+ if (ret[2]) {
37553755+ throw takeFromExternrefTable0(ret[1]);
37563756+ }
37573757+ return takeFromExternrefTable0(ret[0]);
37583758+ }
37593759+ /**
37603760+ * Returns a list of XML child node changes made over corresponding `YXmlElement` collection
37613761+ * within bounds of current transaction. These changes follow a format:
37623762+ *
37633763+ * - { insert: (YXmlText|YXmlElement)[] }
37643764+ * - { delete: number }
37653765+ * - { retain: number }
37663766+ * @returns {any}
37673767+ */
37683768+ get delta() {
37693769+ const ret = wasm.yxmlevent_delta(this.__wbg_ptr);
37703770+ return ret;
37713771+ }
37723772+}
37733773+module.exports.YXmlEvent = YXmlEvent;
37743774+37753775+const YXmlFragmentFinalization =
37763776+ typeof FinalizationRegistry === "undefined"
37773777+ ? { register: () => {}, unregister: () => {} }
37783778+ : new FinalizationRegistry((ptr) =>
37793779+ wasm.__wbg_yxmlfragment_free(ptr >>> 0, 1),
37803780+ );
37813781+/**
37823782+ * Represents a list of `YXmlElement` and `YXmlText` types.
37833783+ * A `YXmlFragment` is similar to a `YXmlElement`, but it does not have a
37843784+ * nodeName and it does not have attributes. Though it can be bound to a DOM
37853785+ * element - in this case the attributes and the nodeName are not shared
37863786+ */
37873787+class YXmlFragment {
37883788+ static __wrap(ptr) {
37893789+ ptr = ptr >>> 0;
37903790+ const obj = Object.create(YXmlFragment.prototype);
37913791+ obj.__wbg_ptr = ptr;
37923792+ YXmlFragmentFinalization.register(obj, obj.__wbg_ptr, obj);
37933793+ return obj;
37943794+ }
37953795+37963796+ __destroy_into_raw() {
37973797+ const ptr = this.__wbg_ptr;
37983798+ this.__wbg_ptr = 0;
37993799+ YXmlFragmentFinalization.unregister(this);
38003800+ return ptr;
38013801+ }
38023802+38033803+ free() {
38043804+ const ptr = this.__destroy_into_raw();
38053805+ wasm.__wbg_yxmlfragment_free(ptr, 0);
38063806+ }
38073807+ /**
38083808+ * @param {any[]} children
38093809+ */
38103810+ constructor(children) {
38113811+ const ptr0 = passArrayJsValueToWasm0(children, wasm.__wbindgen_malloc);
38123812+ const len0 = WASM_VECTOR_LEN;
38133813+ const ret = wasm.yxmlfragment_new(ptr0, len0);
38143814+ if (ret[2]) {
38153815+ throw takeFromExternrefTable0(ret[1]);
38163816+ }
38173817+ this.__wbg_ptr = ret[0] >>> 0;
38183818+ YXmlFragmentFinalization.register(this, this.__wbg_ptr, this);
38193819+ return this;
38203820+ }
38213821+ /**
38223822+ * @returns {number}
38233823+ */
38243824+ get type() {
38253825+ const ret = wasm.yxmlfragment_type(this.__wbg_ptr);
38263826+ return ret;
38273827+ }
38283828+ /**
38293829+ * Gets unique logical identifier of this type, shared across peers collaborating on the same
38303830+ * document.
38313831+ * @returns {any}
38323832+ */
38333833+ get id() {
38343834+ const ret = wasm.yxmlfragment_id(this.__wbg_ptr);
38353835+ if (ret[2]) {
38363836+ throw takeFromExternrefTable0(ret[1]);
38373837+ }
38383838+ return takeFromExternrefTable0(ret[0]);
38393839+ }
38403840+ /**
38413841+ * Returns true if this is a preliminary instance of `YXmlFragment`.
38423842+ *
38433843+ * Preliminary instances can be nested into other shared data types.
38443844+ * Once a preliminary instance has been inserted this way, it becomes integrated into ywasm
38453845+ * document store and cannot be nested again: attempt to do so will result in an exception.
38463846+ * @returns {boolean}
38473847+ */
38483848+ get prelim() {
38493849+ const ret = wasm.yxmlfragment_prelim(this.__wbg_ptr);
38503850+ return ret !== 0;
38513851+ }
38523852+ /**
38533853+ * Checks if current shared type reference is alive and has not been deleted by its parent collection.
38543854+ * This method only works on already integrated shared types and will return false is current
38553855+ * type is preliminary (has not been integrated into document).
38563856+ * @param {YTransaction} txn
38573857+ * @returns {boolean}
38583858+ */
38593859+ alive(txn) {
38603860+ _assertClass(txn, YTransaction);
38613861+ const ret = wasm.yxmlfragment_alive(this.__wbg_ptr, txn.__wbg_ptr);
38623862+ return ret !== 0;
38633863+ }
38643864+ /**
38653865+ * Returns a number of child XML nodes stored within this `YXMlElement` instance.
38663866+ * @param {YTransaction | undefined} txn
38673867+ * @returns {number}
38683868+ */
38693869+ length(txn) {
38703870+ const ret = wasm.yxmlfragment_length(this.__wbg_ptr, txn);
38713871+ if (ret[2]) {
38723872+ throw takeFromExternrefTable0(ret[1]);
38733873+ }
38743874+ return ret[0] >>> 0;
38753875+ }
38763876+ /**
38773877+ * @param {number} index
38783878+ * @param {any} xml_node
38793879+ * @param {YTransaction | undefined} txn
38803880+ */
38813881+ insert(index, xml_node, txn) {
38823882+ const ret = wasm.yxmlfragment_insert(this.__wbg_ptr, index, xml_node, txn);
38833883+ if (ret[1]) {
38843884+ throw takeFromExternrefTable0(ret[0]);
38853885+ }
38863886+ }
38873887+ /**
38883888+ * @param {any} xml_node
38893889+ * @param {YTransaction | undefined} txn
38903890+ */
38913891+ push(xml_node, txn) {
38923892+ const ret = wasm.yxmlfragment_push(this.__wbg_ptr, xml_node, txn);
38933893+ if (ret[1]) {
38943894+ throw takeFromExternrefTable0(ret[0]);
38953895+ }
38963896+ }
38973897+ /**
38983898+ * @param {number} index
38993899+ * @param {number | null | undefined} length
39003900+ * @param {YTransaction | undefined} txn
39013901+ */
39023902+ delete(index, length, txn) {
39033903+ const ret = wasm.yxmlfragment_delete(
39043904+ this.__wbg_ptr,
39053905+ index,
39063906+ isLikeNone(length) ? 0x100000001 : length >>> 0,
39073907+ txn,
39083908+ );
39093909+ if (ret[1]) {
39103910+ throw takeFromExternrefTable0(ret[0]);
39113911+ }
39123912+ }
39133913+ /**
39143914+ * Returns a first child of this XML node.
39153915+ * It can be either `YXmlElement`, `YXmlText` or `undefined` if current node has not children.
39163916+ * @param {YTransaction | undefined} txn
39173917+ * @returns {any}
39183918+ */
39193919+ firstChild(txn) {
39203920+ const ret = wasm.yxmlfragment_firstChild(this.__wbg_ptr, txn);
39213921+ if (ret[2]) {
39223922+ throw takeFromExternrefTable0(ret[1]);
39233923+ }
39243924+ return takeFromExternrefTable0(ret[0]);
39253925+ }
39263926+ /**
39273927+ * Returns a string representation of this XML node.
39283928+ * @param {YTransaction | undefined} txn
39293929+ * @returns {string}
39303930+ */
39313931+ toString(txn) {
39323932+ let deferred2_0;
39333933+ let deferred2_1;
39343934+ try {
39353935+ const ret = wasm.yxmlfragment_toString(this.__wbg_ptr, txn);
39363936+ var ptr1 = ret[0];
39373937+ var len1 = ret[1];
39383938+ if (ret[3]) {
39393939+ ptr1 = 0;
39403940+ len1 = 0;
39413941+ throw takeFromExternrefTable0(ret[2]);
39423942+ }
39433943+ deferred2_0 = ptr1;
39443944+ deferred2_1 = len1;
39453945+ return getStringFromWasm0(ptr1, len1);
39463946+ } finally {
39473947+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
39483948+ }
39493949+ }
39503950+ /**
39513951+ * Returns an iterator that enables a deep traversal of this XML node - starting from first
39523952+ * child over this XML node successors using depth-first strategy.
39533953+ * @param {YTransaction | undefined} txn
39543954+ * @returns {Array<any>}
39553955+ */
39563956+ treeWalker(txn) {
39573957+ const ret = wasm.yxmlfragment_treeWalker(this.__wbg_ptr, txn);
39583958+ if (ret[2]) {
39593959+ throw takeFromExternrefTable0(ret[1]);
39603960+ }
39613961+ return takeFromExternrefTable0(ret[0]);
39623962+ }
39633963+ /**
39643964+ * Subscribes to all operations happening over this instance of `YXmlFragment`. All changes are
39653965+ * batched and eventually triggered during transaction commit phase.
39663966+ * @param {Function} callback
39673967+ */
39683968+ observe(callback) {
39693969+ const ret = wasm.yxmlfragment_observe(this.__wbg_ptr, callback);
39703970+ if (ret[1]) {
39713971+ throw takeFromExternrefTable0(ret[0]);
39723972+ }
39733973+ }
39743974+ /**
39753975+ * Unsubscribes a callback previously subscribed with `observe` method.
39763976+ * @param {Function} callback
39773977+ * @returns {boolean}
39783978+ */
39793979+ unobserve(callback) {
39803980+ const ret = wasm.yxmlfragment_unobserve(this.__wbg_ptr, callback);
39813981+ if (ret[2]) {
39823982+ throw takeFromExternrefTable0(ret[1]);
39833983+ }
39843984+ return ret[0] !== 0;
39853985+ }
39863986+ /**
39873987+ * Subscribes to all operations happening over this Y shared type, as well as events in
39883988+ * shared types stored within this one. All changes are batched and eventually triggered
39893989+ * during transaction commit phase.
39903990+ * @param {Function} callback
39913991+ */
39923992+ observeDeep(callback) {
39933993+ const ret = wasm.yxmlfragment_observeDeep(this.__wbg_ptr, callback);
39943994+ if (ret[1]) {
39953995+ throw takeFromExternrefTable0(ret[0]);
39963996+ }
39973997+ }
39983998+ /**
39993999+ * Unsubscribes a callback previously subscribed with `observeDeep` method.
40004000+ * @param {Function} callback
40014001+ * @returns {boolean}
40024002+ */
40034003+ unobserveDeep(callback) {
40044004+ const ret = wasm.yxmlfragment_unobserveDeep(this.__wbg_ptr, callback);
40054005+ if (ret[2]) {
40064006+ throw takeFromExternrefTable0(ret[1]);
40074007+ }
40084008+ return ret[0] !== 0;
40094009+ }
40104010+}
40114011+module.exports.YXmlFragment = YXmlFragment;
40124012+40134013+const YXmlTextFinalization =
40144014+ typeof FinalizationRegistry === "undefined"
40154015+ ? { register: () => {}, unregister: () => {} }
40164016+ : new FinalizationRegistry((ptr) => wasm.__wbg_yxmltext_free(ptr >>> 0, 1));
40174017+/**
40184018+ * A shared data type used for collaborative text editing, that can be used in a context of
40194019+ * `YXmlElement` nodee. It enables multiple users to add and remove chunks of text in efficient
40204020+ * manner. This type is internally represented as a mutable double-linked list of text chunks
40214021+ * - an optimization occurs during `YTransaction.commit`, which allows to squash multiple
40224022+ * consecutively inserted characters together as a single chunk of text even between transaction
40234023+ * boundaries in order to preserve more efficient memory model.
40244024+ *
40254025+ * Just like `YXmlElement`, `YXmlText` can be marked with extra metadata in form of attributes.
40264026+ *
40274027+ * `YXmlText` structure internally uses UTF-8 encoding and its length is described in a number of
40284028+ * bytes rather than individual characters (a single UTF-8 code point can consist of many bytes).
40294029+ *
40304030+ * Like all Yrs shared data types, `YXmlText` is resistant to the problem of interleaving (situation
40314031+ * when characters inserted one after another may interleave with other peers concurrent inserts
40324032+ * after merging all updates together). In case of Yrs conflict resolution is solved by using
40334033+ * unique document id to determine correct and consistent ordering.
40344034+ */
40354035+class YXmlText {
40364036+ static __wrap(ptr) {
40374037+ ptr = ptr >>> 0;
40384038+ const obj = Object.create(YXmlText.prototype);
40394039+ obj.__wbg_ptr = ptr;
40404040+ YXmlTextFinalization.register(obj, obj.__wbg_ptr, obj);
40414041+ return obj;
40424042+ }
40434043+40444044+ __destroy_into_raw() {
40454045+ const ptr = this.__wbg_ptr;
40464046+ this.__wbg_ptr = 0;
40474047+ YXmlTextFinalization.unregister(this);
40484048+ return ptr;
40494049+ }
40504050+40514051+ free() {
40524052+ const ptr = this.__destroy_into_raw();
40534053+ wasm.__wbg_yxmltext_free(ptr, 0);
40544054+ }
40554055+ /**
40564056+ * @param {string | null | undefined} text
40574057+ * @param {any} attributes
40584058+ */
40594059+ constructor(text, attributes) {
40604060+ var ptr0 = isLikeNone(text)
40614061+ ? 0
40624062+ : passStringToWasm0(
40634063+ text,
40644064+ wasm.__wbindgen_malloc,
40654065+ wasm.__wbindgen_realloc,
40664066+ );
40674067+ var len0 = WASM_VECTOR_LEN;
40684068+ const ret = wasm.yxmltext_new(ptr0, len0, attributes);
40694069+ if (ret[2]) {
40704070+ throw takeFromExternrefTable0(ret[1]);
40714071+ }
40724072+ this.__wbg_ptr = ret[0] >>> 0;
40734073+ YXmlTextFinalization.register(this, this.__wbg_ptr, this);
40744074+ return this;
40754075+ }
40764076+ /**
40774077+ * @returns {number}
40784078+ */
40794079+ get type() {
40804080+ const ret = wasm.yxmltext_type(this.__wbg_ptr);
40814081+ return ret;
40824082+ }
40834083+ /**
40844084+ * Gets unique logical identifier of this type, shared across peers collaborating on the same
40854085+ * document.
40864086+ * @returns {any}
40874087+ */
40884088+ get id() {
40894089+ const ret = wasm.yxmltext_id(this.__wbg_ptr);
40904090+ if (ret[2]) {
40914091+ throw takeFromExternrefTable0(ret[1]);
40924092+ }
40934093+ return takeFromExternrefTable0(ret[0]);
40944094+ }
40954095+ /**
40964096+ * Returns true if this is a preliminary instance of `YXmlText`.
40974097+ *
40984098+ * Preliminary instances can be nested into other shared data types.
40994099+ * Once a preliminary instance has been inserted this way, it becomes integrated into ywasm
41004100+ * document store and cannot be nested again: attempt to do so will result in an exception.
41014101+ * @returns {boolean}
41024102+ */
41034103+ get prelim() {
41044104+ const ret = wasm.yxmltext_prelim(this.__wbg_ptr);
41054105+ return ret !== 0;
41064106+ }
41074107+ /**
41084108+ * Checks if current shared type reference is alive and has not been deleted by its parent collection.
41094109+ * This method only works on already integrated shared types and will return false is current
41104110+ * type is preliminary (has not been integrated into document).
41114111+ * @param {YTransaction} txn
41124112+ * @returns {boolean}
41134113+ */
41144114+ alive(txn) {
41154115+ _assertClass(txn, YTransaction);
41164116+ const ret = wasm.yxmltext_alive(this.__wbg_ptr, txn.__wbg_ptr);
41174117+ return ret !== 0;
41184118+ }
41194119+ /**
41204120+ * Returns length of an underlying string stored in this `YXmlText` instance,
41214121+ * understood as a number of UTF-8 encoded bytes.
41224122+ * @param {YTransaction | undefined} txn
41234123+ * @returns {number}
41244124+ */
41254125+ length(txn) {
41264126+ const ret = wasm.yxmltext_length(this.__wbg_ptr, txn);
41274127+ if (ret[2]) {
41284128+ throw takeFromExternrefTable0(ret[1]);
41294129+ }
41304130+ return ret[0] >>> 0;
41314131+ }
41324132+ /**
41334133+ * Inserts a given `chunk` of text into this `YXmlText` instance, starting at a given `index`.
41344134+ *
41354135+ * Optional object with defined `attributes` will be used to wrap provided text `chunk`
41364136+ * with a formatting blocks.
41374137+ * @param {number} index
41384138+ * @param {string} chunk
41394139+ * @param {any} attributes
41404140+ * @param {YTransaction | undefined} txn
41414141+ */
41424142+ insert(index, chunk, attributes, txn) {
41434143+ const ptr0 = passStringToWasm0(
41444144+ chunk,
41454145+ wasm.__wbindgen_malloc,
41464146+ wasm.__wbindgen_realloc,
41474147+ );
41484148+ const len0 = WASM_VECTOR_LEN;
41494149+ const ret = wasm.yxmltext_insert(
41504150+ this.__wbg_ptr,
41514151+ index,
41524152+ ptr0,
41534153+ len0,
41544154+ attributes,
41554155+ txn,
41564156+ );
41574157+ if (ret[1]) {
41584158+ throw takeFromExternrefTable0(ret[0]);
41594159+ }
41604160+ }
41614161+ /**
41624162+ * Formats text within bounds specified by `index` and `len` with a given formatting
41634163+ * attributes.
41644164+ * @param {number} index
41654165+ * @param {number} length
41664166+ * @param {any} attributes
41674167+ * @param {YTransaction | undefined} txn
41684168+ */
41694169+ format(index, length, attributes, txn) {
41704170+ const ret = wasm.yxmltext_format(
41714171+ this.__wbg_ptr,
41724172+ index,
41734173+ length,
41744174+ attributes,
41754175+ txn,
41764176+ );
41774177+ if (ret[1]) {
41784178+ throw takeFromExternrefTable0(ret[0]);
41794179+ }
41804180+ }
41814181+ /**
41824182+ * @param {number | null | undefined} lower
41834183+ * @param {number | null | undefined} upper
41844184+ * @param {boolean | null | undefined} lower_open
41854185+ * @param {boolean | null | undefined} upper_open
41864186+ * @param {YTransaction | undefined} txn
41874187+ * @returns {YWeakLink}
41884188+ */
41894189+ quote(lower, upper, lower_open, upper_open, txn) {
41904190+ const ret = wasm.yxmltext_quote(
41914191+ this.__wbg_ptr,
41924192+ isLikeNone(lower) ? 0x100000001 : lower >>> 0,
41934193+ isLikeNone(upper) ? 0x100000001 : upper >>> 0,
41944194+ isLikeNone(lower_open) ? 0xffffff : lower_open ? 1 : 0,
41954195+ isLikeNone(upper_open) ? 0xffffff : upper_open ? 1 : 0,
41964196+ txn,
41974197+ );
41984198+ if (ret[2]) {
41994199+ throw takeFromExternrefTable0(ret[1]);
42004200+ }
42014201+ return YWeakLink.__wrap(ret[0]);
42024202+ }
42034203+ /**
42044204+ * Returns the Delta representation of this YXmlText type.
42054205+ * @param {any} snapshot
42064206+ * @param {any} prev_snapshot
42074207+ * @param {Function | null | undefined} compute_ychange
42084208+ * @param {YTransaction | undefined} txn
42094209+ * @returns {Array<any>}
42104210+ */
42114211+ toDelta(snapshot, prev_snapshot, compute_ychange, txn) {
42124212+ const ret = wasm.yxmltext_toDelta(
42134213+ this.__wbg_ptr,
42144214+ snapshot,
42154215+ prev_snapshot,
42164216+ isLikeNone(compute_ychange) ? 0 : addToExternrefTable0(compute_ychange),
42174217+ txn,
42184218+ );
42194219+ if (ret[2]) {
42204220+ throw takeFromExternrefTable0(ret[1]);
42214221+ }
42224222+ return takeFromExternrefTable0(ret[0]);
42234223+ }
42244224+ /**
42254225+ * Inserts a given `embed` object into this `YXmlText` instance, starting at a given `index`.
42264226+ *
42274227+ * Optional object with defined `attributes` will be used to wrap provided `embed`
42284228+ * with a formatting blocks.`attributes` are only supported for a `YXmlText` instance which
42294229+ * already has been integrated into document store.
42304230+ * @param {number} index
42314231+ * @param {any} embed
42324232+ * @param {any} attributes
42334233+ * @param {YTransaction | undefined} txn
42344234+ */
42354235+ insertEmbed(index, embed, attributes, txn) {
42364236+ const ret = wasm.yxmltext_insertEmbed(
42374237+ this.__wbg_ptr,
42384238+ index,
42394239+ embed,
42404240+ attributes,
42414241+ txn,
42424242+ );
42434243+ if (ret[1]) {
42444244+ throw takeFromExternrefTable0(ret[0]);
42454245+ }
42464246+ }
42474247+ /**
42484248+ * Appends a given `chunk` of text at the end of `YXmlText` instance.
42494249+ *
42504250+ * Optional object with defined `attributes` will be used to wrap provided text `chunk`
42514251+ * with a formatting blocks.
42524252+ * @param {string} chunk
42534253+ * @param {any} attributes
42544254+ * @param {YTransaction | undefined} txn
42554255+ */
42564256+ push(chunk, attributes, txn) {
42574257+ const ptr0 = passStringToWasm0(
42584258+ chunk,
42594259+ wasm.__wbindgen_malloc,
42604260+ wasm.__wbindgen_realloc,
42614261+ );
42624262+ const len0 = WASM_VECTOR_LEN;
42634263+ const ret = wasm.yxmltext_push(this.__wbg_ptr, ptr0, len0, attributes, txn);
42644264+ if (ret[1]) {
42654265+ throw takeFromExternrefTable0(ret[0]);
42664266+ }
42674267+ }
42684268+ /**
42694269+ * @param {Array<any>} delta
42704270+ * @param {YTransaction | undefined} txn
42714271+ */
42724272+ applyDelta(delta, txn) {
42734273+ const ret = wasm.yxmltext_applyDelta(this.__wbg_ptr, delta, txn);
42744274+ if (ret[1]) {
42754275+ throw takeFromExternrefTable0(ret[0]);
42764276+ }
42774277+ }
42784278+ /**
42794279+ * Deletes a specified range of characters, starting at a given `index`.
42804280+ * Both `index` and `length` are counted in terms of a number of UTF-8 character bytes.
42814281+ * @param {number} index
42824282+ * @param {number} length
42834283+ * @param {YTransaction | undefined} txn
42844284+ */
42854285+ delete(index, length, txn) {
42864286+ const ret = wasm.yxmltext_delete(this.__wbg_ptr, index, length, txn);
42874287+ if (ret[1]) {
42884288+ throw takeFromExternrefTable0(ret[0]);
42894289+ }
42904290+ }
42914291+ /**
42924292+ * Returns a next XML sibling node of this XMl node.
42934293+ * It can be either `YXmlElement`, `YXmlText` or `undefined` if current node is a last child of
42944294+ * parent XML node.
42954295+ * @param {YTransaction | undefined} txn
42964296+ * @returns {any}
42974297+ */
42984298+ nextSibling(txn) {
42994299+ const ret = wasm.yxmltext_nextSibling(this.__wbg_ptr, txn);
43004300+ if (ret[2]) {
43014301+ throw takeFromExternrefTable0(ret[1]);
43024302+ }
43034303+ return takeFromExternrefTable0(ret[0]);
43044304+ }
43054305+ /**
43064306+ * Returns a previous XML sibling node of this XMl node.
43074307+ * It can be either `YXmlElement`, `YXmlText` or `undefined` if current node is a first child
43084308+ * of parent XML node.
43094309+ * @param {YTransaction | undefined} txn
43104310+ * @returns {any}
43114311+ */
43124312+ prevSibling(txn) {
43134313+ const ret = wasm.yxmltext_prevSibling(this.__wbg_ptr, txn);
43144314+ if (ret[2]) {
43154315+ throw takeFromExternrefTable0(ret[1]);
43164316+ }
43174317+ return takeFromExternrefTable0(ret[0]);
43184318+ }
43194319+ /**
43204320+ * Returns a parent `YXmlElement` node or `undefined` if current node has no parent assigned.
43214321+ * @param {YTransaction | undefined} txn
43224322+ * @returns {any}
43234323+ */
43244324+ parent(txn) {
43254325+ const ret = wasm.yxmltext_parent(this.__wbg_ptr, txn);
43264326+ if (ret[2]) {
43274327+ throw takeFromExternrefTable0(ret[1]);
43284328+ }
43294329+ return takeFromExternrefTable0(ret[0]);
43304330+ }
43314331+ /**
43324332+ * Returns an underlying string stored in this `YXmlText` instance.
43334333+ * @param {YTransaction | undefined} txn
43344334+ * @returns {string}
43354335+ */
43364336+ toString(txn) {
43374337+ let deferred2_0;
43384338+ let deferred2_1;
43394339+ try {
43404340+ const ret = wasm.yxmltext_toString(this.__wbg_ptr, txn);
43414341+ var ptr1 = ret[0];
43424342+ var len1 = ret[1];
43434343+ if (ret[3]) {
43444344+ ptr1 = 0;
43454345+ len1 = 0;
43464346+ throw takeFromExternrefTable0(ret[2]);
43474347+ }
43484348+ deferred2_0 = ptr1;
43494349+ deferred2_1 = len1;
43504350+ return getStringFromWasm0(ptr1, len1);
43514351+ } finally {
43524352+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
43534353+ }
43544354+ }
43554355+ /**
43564356+ * Sets a `name` and `value` as new attribute for this XML node. If an attribute with the same
43574357+ * `name` already existed on that node, its value with be overridden with a provided one.
43584358+ * This method accepts any JavaScript value, not just strings.
43594359+ * @param {string} name
43604360+ * @param {any} value
43614361+ * @param {YTransaction | undefined} txn
43624362+ */
43634363+ setAttribute(name, value, txn) {
43644364+ const ptr0 = passStringToWasm0(
43654365+ name,
43664366+ wasm.__wbindgen_malloc,
43674367+ wasm.__wbindgen_realloc,
43684368+ );
43694369+ const len0 = WASM_VECTOR_LEN;
43704370+ const ret = wasm.yxmltext_setAttribute(
43714371+ this.__wbg_ptr,
43724372+ ptr0,
43734373+ len0,
43744374+ value,
43754375+ txn,
43764376+ );
43774377+ if (ret[1]) {
43784378+ throw takeFromExternrefTable0(ret[0]);
43794379+ }
43804380+ }
43814381+ /**
43824382+ * Returns a value of an attribute given its `name` as any JS value. If no attribute with such name existed,
43834383+ * `undefined` will be returned.
43844384+ * @param {string} name
43854385+ * @param {YTransaction | undefined} txn
43864386+ * @returns {any}
43874387+ */
43884388+ getAttribute(name, txn) {
43894389+ const ptr0 = passStringToWasm0(
43904390+ name,
43914391+ wasm.__wbindgen_malloc,
43924392+ wasm.__wbindgen_realloc,
43934393+ );
43944394+ const len0 = WASM_VECTOR_LEN;
43954395+ const ret = wasm.yxmltext_getAttribute(this.__wbg_ptr, ptr0, len0, txn);
43964396+ if (ret[2]) {
43974397+ throw takeFromExternrefTable0(ret[1]);
43984398+ }
43994399+ return takeFromExternrefTable0(ret[0]);
44004400+ }
44014401+ /**
44024402+ * Removes an attribute from this XML node, given its `name`.
44034403+ * @param {string} name
44044404+ * @param {YTransaction | undefined} txn
44054405+ */
44064406+ removeAttribute(name, txn) {
44074407+ const ptr0 = passStringToWasm0(
44084408+ name,
44094409+ wasm.__wbindgen_malloc,
44104410+ wasm.__wbindgen_realloc,
44114411+ );
44124412+ const len0 = WASM_VECTOR_LEN;
44134413+ const ret = wasm.yxmltext_removeAttribute(this.__wbg_ptr, ptr0, len0, txn);
44144414+ if (ret[1]) {
44154415+ throw takeFromExternrefTable0(ret[0]);
44164416+ }
44174417+ }
44184418+ /**
44194419+ * Returns an iterator that enables to traverse over all attributes of this XML node in
44204420+ * unspecified order. This method returns attribute values as their original JS values,
44214421+ * not just as strings.
44224422+ * @param {YTransaction | undefined} txn
44234423+ * @returns {any}
44244424+ */
44254425+ attributes(txn) {
44264426+ const ret = wasm.yxmltext_attributes(this.__wbg_ptr, txn);
44274427+ if (ret[2]) {
44284428+ throw takeFromExternrefTable0(ret[1]);
44294429+ }
44304430+ return takeFromExternrefTable0(ret[0]);
44314431+ }
44324432+ /**
44334433+ * Subscribes to all operations happening over this instance of `YXmlText`. All changes are
44344434+ * batched and eventually triggered during transaction commit phase.
44354435+ * @param {Function} callback
44364436+ */
44374437+ observe(callback) {
44384438+ const ret = wasm.yxmltext_observe(this.__wbg_ptr, callback);
44394439+ if (ret[1]) {
44404440+ throw takeFromExternrefTable0(ret[0]);
44414441+ }
44424442+ }
44434443+ /**
44444444+ * Unsubscribes a callback previously subscribed with `observe` method.
44454445+ * @param {Function} callback
44464446+ * @returns {boolean}
44474447+ */
44484448+ unobserve(callback) {
44494449+ const ret = wasm.yxmltext_unobserve(this.__wbg_ptr, callback);
44504450+ if (ret[2]) {
44514451+ throw takeFromExternrefTable0(ret[1]);
44524452+ }
44534453+ return ret[0] !== 0;
44544454+ }
44554455+ /**
44564456+ * Subscribes to all operations happening over this Y shared type, as well as events in
44574457+ * shared types stored within this one. All changes are batched and eventually triggered
44584458+ * during transaction commit phase.
44594459+ * @param {Function} callback
44604460+ */
44614461+ observeDeep(callback) {
44624462+ const ret = wasm.yxmltext_observeDeep(this.__wbg_ptr, callback);
44634463+ if (ret[1]) {
44644464+ throw takeFromExternrefTable0(ret[0]);
44654465+ }
44664466+ }
44674467+ /**
44684468+ * Unsubscribes a callback previously subscribed with `observe` method.
44694469+ * @param {Function} callback
44704470+ * @returns {boolean}
44714471+ */
44724472+ unobserveDeep(callback) {
44734473+ const ret = wasm.yxmltext_unobserveDeep(this.__wbg_ptr, callback);
44744474+ if (ret[2]) {
44754475+ throw takeFromExternrefTable0(ret[1]);
44764476+ }
44774477+ return ret[0] !== 0;
44784478+ }
44794479+}
44804480+module.exports.YXmlText = YXmlText;
44814481+44824482+const YXmlTextEventFinalization =
44834483+ typeof FinalizationRegistry === "undefined"
44844484+ ? { register: () => {}, unregister: () => {} }
44854485+ : new FinalizationRegistry((ptr) =>
44864486+ wasm.__wbg_yxmltextevent_free(ptr >>> 0, 1),
44874487+ );
44884488+/**
44894489+ * Event generated by `YXmlText.observe` method. Emitted during transaction commit phase.
44904490+ */
44914491+class YXmlTextEvent {
44924492+ static __wrap(ptr) {
44934493+ ptr = ptr >>> 0;
44944494+ const obj = Object.create(YXmlTextEvent.prototype);
44954495+ obj.__wbg_ptr = ptr;
44964496+ YXmlTextEventFinalization.register(obj, obj.__wbg_ptr, obj);
44974497+ return obj;
44984498+ }
44994499+45004500+ __destroy_into_raw() {
45014501+ const ptr = this.__wbg_ptr;
45024502+ this.__wbg_ptr = 0;
45034503+ YXmlTextEventFinalization.unregister(this);
45044504+ return ptr;
45054505+ }
45064506+45074507+ free() {
45084508+ const ptr = this.__destroy_into_raw();
45094509+ wasm.__wbg_yxmltextevent_free(ptr, 0);
45104510+ }
45114511+ /**
45124512+ * Returns an array of keys and indexes creating a path from root type down to current instance
45134513+ * of shared type (accessible via `target` getter).
45144514+ * @returns {any}
45154515+ */
45164516+ path() {
45174517+ const ret = wasm.yxmltextevent_path(this.__wbg_ptr);
45184518+ return ret;
45194519+ }
45204520+ /**
45214521+ * Returns a current shared type instance, that current event changes refer to.
45224522+ * @returns {any}
45234523+ */
45244524+ get target() {
45254525+ const ret = wasm.yxmltextevent_target(this.__wbg_ptr);
45264526+ return ret;
45274527+ }
45284528+ /**
45294529+ * @returns {any}
45304530+ */
45314531+ get origin() {
45324532+ const ret = wasm.yxmltextevent_origin(this.__wbg_ptr);
45334533+ return ret;
45344534+ }
45354535+ /**
45364536+ * Returns a list of text changes made over corresponding `YText` collection within
45374537+ * bounds of current transaction. These changes follow a format:
45384538+ *
45394539+ * - { insert: string, attributes: any|undefined }
45404540+ * - { delete: number }
45414541+ * - { retain: number, attributes: any|undefined }
45424542+ * @returns {any}
45434543+ */
45444544+ get delta() {
45454545+ const ret = wasm.yxmltextevent_delta(this.__wbg_ptr);
45464546+ if (ret[2]) {
45474547+ throw takeFromExternrefTable0(ret[1]);
45484548+ }
45494549+ return takeFromExternrefTable0(ret[0]);
45504550+ }
45514551+ /**
45524552+ * Returns a list of attribute changes made over corresponding `YXmlText` collection within
45534553+ * bounds of current transaction. These changes follow a format:
45544554+ *
45554555+ * - { action: 'add'|'update'|'delete', oldValue: string|undefined, newValue: string|undefined }
45564556+ * @returns {any}
45574557+ */
45584558+ get keys() {
45594559+ const ret = wasm.yxmltextevent_keys(this.__wbg_ptr);
45604560+ if (ret[2]) {
45614561+ throw takeFromExternrefTable0(ret[1]);
45624562+ }
45634563+ return takeFromExternrefTable0(ret[0]);
45644564+ }
45654565+}
45664566+module.exports.YXmlTextEvent = YXmlTextEvent;
45674567+45684568+module.exports.__wbg_buffer_609cc3eee51ed158 = function (arg0) {
45694569+ const ret = arg0.buffer;
45704570+ return ret;
45714571+};
45724572+45734573+module.exports.__wbg_call_672a4d21634d4a24 = function () {
45744574+ return handleError(function (arg0, arg1) {
45754575+ const ret = arg0.call(arg1);
45764576+ return ret;
45774577+ }, arguments);
45784578+};
45794579+45804580+module.exports.__wbg_call_7cccdd69e0791ae2 = function () {
45814581+ return handleError(function (arg0, arg1, arg2) {
45824582+ const ret = arg0.call(arg1, arg2);
45834583+ return ret;
45844584+ }, arguments);
45854585+};
45864586+45874587+module.exports.__wbg_call_833bed5770ea2041 = function () {
45884588+ return handleError(function (arg0, arg1, arg2, arg3) {
45894589+ const ret = arg0.call(arg1, arg2, arg3);
45904590+ return ret;
45914591+ }, arguments);
45924592+};
45934593+45944594+module.exports.__wbg_crypto_574e78ad8b13b65f = function (arg0) {
45954595+ const ret = arg0.crypto;
45964596+ return ret;
45974597+};
45984598+45994599+module.exports.__wbg_entries_3265d4158b33e5dc = function (arg0) {
46004600+ const ret = Object.entries(arg0);
46014601+ return ret;
46024602+};
46034603+46044604+module.exports.__wbg_error_7534b8e9a36f1ab4 = function (arg0, arg1) {
46054605+ let deferred0_0;
46064606+ let deferred0_1;
46074607+ try {
46084608+ deferred0_0 = arg0;
46094609+ deferred0_1 = arg1;
46104610+ console.error(getStringFromWasm0(arg0, arg1));
46114611+ } finally {
46124612+ wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
46134613+ }
46144614+};
46154615+46164616+module.exports.__wbg_from_2a5d3e218e67aa85 = function (arg0) {
46174617+ const ret = Array.from(arg0);
46184618+ return ret;
46194619+};
46204620+46214621+module.exports.__wbg_getRandomValues_b8f5dbd5f3995a9e = function () {
46224622+ return handleError(function (arg0, arg1) {
46234623+ arg0.getRandomValues(arg1);
46244624+ }, arguments);
46254625+};
46264626+46274627+module.exports.__wbg_get_67b2ba62fc30de12 = function () {
46284628+ return handleError(function (arg0, arg1) {
46294629+ const ret = Reflect.get(arg0, arg1);
46304630+ return ret;
46314631+ }, arguments);
46324632+};
46334633+46344634+module.exports.__wbg_get_b9b93047fe3cf45b = function (arg0, arg1) {
46354635+ const ret = arg0[arg1 >>> 0];
46364636+ return ret;
46374637+};
46384638+46394639+module.exports.__wbg_isArray_a1eab7e0d067391b = function (arg0) {
46404640+ const ret = Array.isArray(arg0);
46414641+ return ret;
46424642+};
46434643+46444644+module.exports.__wbg_length_a446193dc22c12f8 = function (arg0) {
46454645+ const ret = arg0.length;
46464646+ return ret;
46474647+};
46484648+46494649+module.exports.__wbg_length_e2d2a49132c1b256 = function (arg0) {
46504650+ const ret = arg0.length;
46514651+ return ret;
46524652+};
46534653+46544654+module.exports.__wbg_msCrypto_a61aeb35a24c1329 = function (arg0) {
46554655+ const ret = arg0.msCrypto;
46564656+ return ret;
46574657+};
46584658+46594659+module.exports.__wbg_new_405e22f390576ce2 = function () {
46604660+ const ret = new Object();
46614661+ return ret;
46624662+};
46634663+46644664+module.exports.__wbg_new_5e0be73521bc8c17 = function () {
46654665+ const ret = new Map();
46664666+ return ret;
46674667+};
46684668+46694669+module.exports.__wbg_new_78feb108b6472713 = function () {
46704670+ const ret = new Array();
46714671+ return ret;
46724672+};
46734673+46744674+module.exports.__wbg_new_8a6f238a6ece86ea = function () {
46754675+ const ret = new Error();
46764676+ return ret;
46774677+};
46784678+46794679+module.exports.__wbg_new_a12002a7f91c75be = function (arg0) {
46804680+ const ret = new Uint8Array(arg0);
46814681+ return ret;
46824682+};
46834683+46844684+module.exports.__wbg_new_a239edaa1dc2968f = function (arg0) {
46854685+ const ret = new Set(arg0);
46864686+ return ret;
46874687+};
46884688+46894689+module.exports.__wbg_newnoargs_105ed471475aaf50 = function (arg0, arg1) {
46904690+ const ret = new Function(getStringFromWasm0(arg0, arg1));
46914691+ return ret;
46924692+};
46934693+46944694+module.exports.__wbg_newwithbyteoffsetandlength_d97e637ebe145a9a = function (
46954695+ arg0,
46964696+ arg1,
46974697+ arg2,
46984698+) {
46994699+ const ret = new Uint8Array(arg0, arg1 >>> 0, arg2 >>> 0);
47004700+ return ret;
47014701+};
47024702+47034703+module.exports.__wbg_newwithlength_a381634e90c276d4 = function (arg0) {
47044704+ const ret = new Uint8Array(arg0 >>> 0);
47054705+ return ret;
47064706+};
47074707+47084708+module.exports.__wbg_node_905d3e251edff8a2 = function (arg0) {
47094709+ const ret = arg0.node;
47104710+ return ret;
47114711+};
47124712+47134713+module.exports.__wbg_now_807e54c39636c349 = function () {
47144714+ const ret = Date.now();
47154715+ return ret;
47164716+};
47174717+47184718+module.exports.__wbg_parse_def2e24ef1252aff = function () {
47194719+ return handleError(function (arg0, arg1) {
47204720+ const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
47214721+ return ret;
47224722+ }, arguments);
47234723+};
47244724+47254725+module.exports.__wbg_process_dc0fbacc7c1c06f7 = function (arg0) {
47264726+ const ret = arg0.process;
47274727+ return ret;
47284728+};
47294729+47304730+module.exports.__wbg_push_737cfc8c1432c2c6 = function (arg0, arg1) {
47314731+ const ret = arg0.push(arg1);
47324732+ return ret;
47334733+};
47344734+47354735+module.exports.__wbg_randomFillSync_ac0988aba3254290 = function () {
47364736+ return handleError(function (arg0, arg1) {
47374737+ arg0.randomFillSync(arg1);
47384738+ }, arguments);
47394739+};
47404740+47414741+module.exports.__wbg_require_60cc747a6bc5215a = function () {
47424742+ return handleError(function () {
47434743+ const ret = module.require;
47444744+ return ret;
47454745+ }, arguments);
47464746+};
47474747+47484748+module.exports.__wbg_set_65595bdd868b3009 = function (arg0, arg1, arg2) {
47494749+ arg0.set(arg1, arg2 >>> 0);
47504750+};
47514751+47524752+module.exports.__wbg_set_8fc6bf8a5b1071d1 = function (arg0, arg1, arg2) {
47534753+ const ret = arg0.set(arg1, arg2);
47544754+ return ret;
47554755+};
47564756+47574757+module.exports.__wbg_set_bb8cecf6a62b9f46 = function () {
47584758+ return handleError(function (arg0, arg1, arg2) {
47594759+ const ret = Reflect.set(arg0, arg1, arg2);
47604760+ return ret;
47614761+ }, arguments);
47624762+};
47634763+47644764+module.exports.__wbg_stack_0ed75d68575b0f3c = function (arg0, arg1) {
47654765+ const ret = arg1.stack;
47664766+ const ptr1 = passStringToWasm0(
47674767+ ret,
47684768+ wasm.__wbindgen_malloc,
47694769+ wasm.__wbindgen_realloc,
47704770+ );
47714771+ const len1 = WASM_VECTOR_LEN;
47724772+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
47734773+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
47744774+};
47754775+47764776+module.exports.__wbg_static_accessor_GLOBAL_88a902d13a557d07 = function () {
47774777+ const ret = typeof global === "undefined" ? null : global;
47784778+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
47794779+};
47804780+47814781+module.exports.__wbg_static_accessor_GLOBAL_THIS_56578be7e9f832b0 =
47824782+ function () {
47834783+ const ret = typeof globalThis === "undefined" ? null : globalThis;
47844784+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
47854785+ };
47864786+47874787+module.exports.__wbg_static_accessor_SELF_37c5d418e4bf5819 = function () {
47884788+ const ret = typeof self === "undefined" ? null : self;
47894789+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
47904790+};
47914791+47924792+module.exports.__wbg_static_accessor_WINDOW_5de37043a91a9c40 = function () {
47934793+ const ret = typeof window === "undefined" ? null : window;
47944794+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
47954795+};
47964796+47974797+module.exports.__wbg_stringify_f7ed6987935b4a24 = function () {
47984798+ return handleError(function (arg0) {
47994799+ const ret = JSON.stringify(arg0);
48004800+ return ret;
48014801+ }, arguments);
48024802+};
48034803+48044804+module.exports.__wbg_subarray_aa9065fa9dc5df96 = function (arg0, arg1, arg2) {
48054805+ const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
48064806+ return ret;
48074807+};
48084808+48094809+module.exports.__wbg_versions_c01dfd4722a88165 = function (arg0) {
48104810+ const ret = arg0.versions;
48114811+ return ret;
48124812+};
48134813+48144814+module.exports.__wbg_yarray_new = function (arg0) {
48154815+ const ret = YArray.__wrap(arg0);
48164816+ return ret;
48174817+};
48184818+48194819+module.exports.__wbg_yarrayevent_new = function (arg0) {
48204820+ const ret = YArrayEvent.__wrap(arg0);
48214821+ return ret;
48224822+};
48234823+48244824+module.exports.__wbg_ydoc_new = function (arg0) {
48254825+ const ret = YDoc.__wrap(arg0);
48264826+ return ret;
48274827+};
48284828+48294829+module.exports.__wbg_ymap_new = function (arg0) {
48304830+ const ret = YMap.__wrap(arg0);
48314831+ return ret;
48324832+};
48334833+48344834+module.exports.__wbg_ymapevent_new = function (arg0) {
48354835+ const ret = YMapEvent.__wrap(arg0);
48364836+ return ret;
48374837+};
48384838+48394839+module.exports.__wbg_ysubdocsevent_new = function (arg0) {
48404840+ const ret = YSubdocsEvent.__wrap(arg0);
48414841+ return ret;
48424842+};
48434843+48444844+module.exports.__wbg_ytext_new = function (arg0) {
48454845+ const ret = YText.__wrap(arg0);
48464846+ return ret;
48474847+};
48484848+48494849+module.exports.__wbg_ytextevent_new = function (arg0) {
48504850+ const ret = YTextEvent.__wrap(arg0);
48514851+ return ret;
48524852+};
48534853+48544854+module.exports.__wbg_ytransaction_new = function (arg0) {
48554855+ const ret = YTransaction.__wrap(arg0);
48564856+ return ret;
48574857+};
48584858+48594859+module.exports.__wbg_yundoevent_new = function (arg0) {
48604860+ const ret = YUndoEvent.__wrap(arg0);
48614861+ return ret;
48624862+};
48634863+48644864+module.exports.__wbg_yweaklink_new = function (arg0) {
48654865+ const ret = YWeakLink.__wrap(arg0);
48664866+ return ret;
48674867+};
48684868+48694869+module.exports.__wbg_yweaklinkevent_new = function (arg0) {
48704870+ const ret = YWeakLinkEvent.__wrap(arg0);
48714871+ return ret;
48724872+};
48734873+48744874+module.exports.__wbg_yxmlelement_new = function (arg0) {
48754875+ const ret = YXmlElement.__wrap(arg0);
48764876+ return ret;
48774877+};
48784878+48794879+module.exports.__wbg_yxmlevent_new = function (arg0) {
48804880+ const ret = YXmlEvent.__wrap(arg0);
48814881+ return ret;
48824882+};
48834883+48844884+module.exports.__wbg_yxmlfragment_new = function (arg0) {
48854885+ const ret = YXmlFragment.__wrap(arg0);
48864886+ return ret;
48874887+};
48884888+48894889+module.exports.__wbg_yxmltext_new = function (arg0) {
48904890+ const ret = YXmlText.__wrap(arg0);
48914891+ return ret;
48924892+};
48934893+48944894+module.exports.__wbg_yxmltextevent_new = function (arg0) {
48954895+ const ret = YXmlTextEvent.__wrap(arg0);
48964896+ return ret;
48974897+};
48984898+48994899+module.exports.__wbindgen_bigint_from_i64 = function (arg0) {
49004900+ const ret = arg0;
49014901+ return ret;
49024902+};
49034903+49044904+module.exports.__wbindgen_bigint_from_u64 = function (arg0) {
49054905+ const ret = BigInt.asUintN(64, arg0);
49064906+ return ret;
49074907+};
49084908+49094909+module.exports.__wbindgen_boolean_get = function (arg0) {
49104910+ const v = arg0;
49114911+ const ret = typeof v === "boolean" ? (v ? 1 : 0) : 2;
49124912+ return ret;
49134913+};
49144914+49154915+module.exports.__wbindgen_debug_string = function (arg0, arg1) {
49164916+ const ret = debugString(arg1);
49174917+ const ptr1 = passStringToWasm0(
49184918+ ret,
49194919+ wasm.__wbindgen_malloc,
49204920+ wasm.__wbindgen_realloc,
49214921+ );
49224922+ const len1 = WASM_VECTOR_LEN;
49234923+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
49244924+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
49254925+};
49264926+49274927+module.exports.__wbindgen_init_externref_table = function () {
49284928+ const table = wasm.__wbindgen_export_2;
49294929+ const offset = table.grow(4);
49304930+ table.set(0, undefined);
49314931+ table.set(offset + 0, undefined);
49324932+ table.set(offset + 1, null);
49334933+ table.set(offset + 2, true);
49344934+ table.set(offset + 3, false);
49354935+};
49364936+49374937+module.exports.__wbindgen_is_bigint = function (arg0) {
49384938+ const ret = typeof arg0 === "bigint";
49394939+ return ret;
49404940+};
49414941+49424942+module.exports.__wbindgen_is_function = function (arg0) {
49434943+ const ret = typeof arg0 === "function";
49444944+ return ret;
49454945+};
49464946+49474947+module.exports.__wbindgen_is_null = function (arg0) {
49484948+ const ret = arg0 === null;
49494949+ return ret;
49504950+};
49514951+49524952+module.exports.__wbindgen_is_object = function (arg0) {
49534953+ const val = arg0;
49544954+ const ret = typeof val === "object" && val !== null;
49554955+ return ret;
49564956+};
49574957+49584958+module.exports.__wbindgen_is_string = function (arg0) {
49594959+ const ret = typeof arg0 === "string";
49604960+ return ret;
49614961+};
49624962+49634963+module.exports.__wbindgen_is_undefined = function (arg0) {
49644964+ const ret = arg0 === undefined;
49654965+ return ret;
49664966+};
49674967+49684968+module.exports.__wbindgen_memory = function () {
49694969+ const ret = wasm.memory;
49704970+ return ret;
49714971+};
49724972+49734973+module.exports.__wbindgen_number_get = function (arg0, arg1) {
49744974+ const obj = arg1;
49754975+ const ret = typeof obj === "number" ? obj : undefined;
49764976+ getDataViewMemory0().setFloat64(
49774977+ arg0 + 8 * 1,
49784978+ isLikeNone(ret) ? 0 : ret,
49794979+ true,
49804980+ );
49814981+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
49824982+};
49834983+49844984+module.exports.__wbindgen_number_new = function (arg0) {
49854985+ const ret = arg0;
49864986+ return ret;
49874987+};
49884988+49894989+module.exports.__wbindgen_string_get = function (arg0, arg1) {
49904990+ const obj = arg1;
49914991+ const ret = typeof obj === "string" ? obj : undefined;
49924992+ var ptr1 = isLikeNone(ret)
49934993+ ? 0
49944994+ : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
49954995+ var len1 = WASM_VECTOR_LEN;
49964996+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
49974997+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
49984998+};
49994999+50005000+module.exports.__wbindgen_string_new = function (arg0, arg1) {
50015001+ const ret = getStringFromWasm0(arg0, arg1);
50025002+ return ret;
50035003+};
50045004+50055005+module.exports.__wbindgen_throw = function (arg0, arg1) {
50065006+ throw new Error(getStringFromWasm0(arg0, arg1));
50075007+};
50085008+50095009+const path = require("path").join(
50105010+ process.cwd(),
50115011+ "public",
50125012+ "wasm",
50135013+ "ywasm_bg.wasm",
50145014+);
50155015+const bytes = require("fs").readFileSync(path);
50165016+50175017+const wasmModule = new WebAssembly.Module(bytes);
50185018+const wasmInstance = new WebAssembly.Instance(wasmModule, imports);
50195019+wasm = wasmInstance.exports;
50205020+module.exports.__wasm = wasm;
50215021+50225022+wasm.__wbindgen_start();