Comparing version 13.5.10 to 13.5.11
@@ -95,2 +95,6 @@ /** | ||
has(key: string): boolean; | ||
/** | ||
* Removes all elements from this YMap. | ||
*/ | ||
clear(): void; | ||
} | ||
@@ -97,0 +101,0 @@ export function readYMap(decoder: UpdateDecoderV1 | UpdateDecoderV2): YMap<any>; |
@@ -51,2 +51,11 @@ /** | ||
/** | ||
* Returns whether an attribute exists | ||
* | ||
* @param {String} attributeName The attribute name to check for existence. | ||
* @return {boolean} whether the attribute exists. | ||
* | ||
* @public | ||
*/ | ||
public hasAttribute(attributeName: string): boolean; | ||
/** | ||
* Returns all attribute name/value pairs in a JSON Object. | ||
@@ -53,0 +62,0 @@ * |
@@ -59,2 +59,5 @@ export class LazyStructReader { | ||
export function diffUpdate(update: Uint8Array, sv: Uint8Array): Uint8Array; | ||
export function convertUpdateFormat(update: Uint8Array, YDecoder: typeof UpdateDecoderV2 | typeof UpdateDecoderV1, YEncoder: typeof UpdateEncoderV2 | typeof UpdateEncoderV1): Uint8Array; | ||
export function convertUpdateFormatV1ToV2(update: Uint8Array): Uint8Array; | ||
export function convertUpdateFormatV2ToV1(update: Uint8Array): Uint8Array; | ||
import { GC } from "../structs/GC.js"; | ||
@@ -61,0 +64,0 @@ import { Item } from "../structs/Item.js"; |
{ | ||
"name": "yjs", | ||
"version": "13.5.10", | ||
"version": "13.5.11", | ||
"description": "Shared Editing Library", | ||
@@ -5,0 +5,0 @@ "main": "./dist/yjs.cjs", |
@@ -337,2 +337,4 @@ | ||
<dd></dd> | ||
<b><code>clear()</code></b> | ||
<dd>Removes all elements from this YMap.</dd> | ||
<b><code>clone():Y.Map</code></b> | ||
@@ -339,0 +341,0 @@ <dd>Clone this type into a fresh Yjs type.</dd> |
@@ -682,2 +682,4 @@ | ||
const lengthExceeded = error.create('Length exceeded!') | ||
/** | ||
@@ -693,2 +695,5 @@ * @param {Transaction} transaction | ||
export const typeListInsertGenerics = (transaction, parent, index, content) => { | ||
if (index > parent._length) { | ||
throw lengthExceeded | ||
} | ||
if (index === 0) { | ||
@@ -771,3 +776,3 @@ if (parent._searchMarker) { | ||
if (length > 0) { | ||
throw error.create('array length exceeded') | ||
throw lengthExceeded | ||
} | ||
@@ -774,0 +779,0 @@ if (parent._searchMarker) { |
@@ -241,2 +241,17 @@ | ||
/** | ||
* Removes all elements from this YMap. | ||
*/ | ||
clear () { | ||
if (this.doc !== null) { | ||
transact(this.doc, transaction => { | ||
this.forEach(function (value, key, map) { | ||
typeMapDelete(transaction, map, key) | ||
}) | ||
}) | ||
} else { | ||
/** @type {Map<string, any>} */ (this._prelimContent).clear() | ||
} | ||
} | ||
/** | ||
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder | ||
@@ -243,0 +258,0 @@ */ |
@@ -6,2 +6,3 @@ | ||
typeMapDelete, | ||
typeMapHas, | ||
typeMapSet, | ||
@@ -165,2 +166,14 @@ typeMapGet, | ||
/** | ||
* Returns whether an attribute exists | ||
* | ||
* @param {String} attributeName The attribute name to check for existence. | ||
* @return {boolean} whether the attribute exists. | ||
* | ||
* @public | ||
*/ | ||
hasAttribute (attributeName) { | ||
return /** @type {any} */ (typeMapHas(this, attributeName)) | ||
} | ||
/** | ||
* Returns all attribute name/value pairs in a JSON Object. | ||
@@ -167,0 +180,0 @@ * |
@@ -35,5 +35,7 @@ | ||
DSEncoderV1, | ||
mergeUpdates, | ||
mergeUpdatesV2, | ||
Skip, | ||
diffUpdateV2, | ||
convertUpdateFormatV2ToV1, | ||
DSDecoderV2, Doc, Transaction, GC, Item, StructStore // eslint-disable-line | ||
@@ -527,11 +529,12 @@ } from '../internals.js' | ||
// also add the pending updates (if there are any) | ||
// @todo support diffirent encoders | ||
if (encoder.constructor === UpdateEncoderV2) { | ||
if (doc.store.pendingDs) { | ||
updates.push(doc.store.pendingDs) | ||
} | ||
if (doc.store.pendingStructs) { | ||
updates.push(diffUpdateV2(doc.store.pendingStructs.update, encodedTargetStateVector)) | ||
} | ||
if (updates.length > 1) { | ||
if (doc.store.pendingDs) { | ||
updates.push(doc.store.pendingDs) | ||
} | ||
if (doc.store.pendingStructs) { | ||
updates.push(diffUpdateV2(doc.store.pendingStructs.update, encodedTargetStateVector)) | ||
} | ||
if (updates.length > 1) { | ||
if (encoder.constructor === UpdateEncoderV1) { | ||
return mergeUpdates(updates.map((update, i) => i === 0 ? update : convertUpdateFormatV2ToV1(update))) | ||
} else if (encoder.constructor === UpdateEncoderV2) { | ||
return mergeUpdatesV2(updates) | ||
@@ -538,0 +541,0 @@ } |
@@ -157,12 +157,5 @@ | ||
let currClient = curr.id.client | ||
let currClock = 0 | ||
let stopCounting = curr.id.clock !== 0 // must start at 0 | ||
let currClock = stopCounting ? 0 : curr.id.clock + curr.length | ||
for (; curr !== null; curr = updateDecoder.next()) { | ||
// we ignore skips | ||
if (curr.constructor === Skip) { | ||
stopCounting = true | ||
} | ||
if (!stopCounting) { | ||
currClock = curr.id.clock + curr.length | ||
} | ||
if (currClient !== curr.id.client) { | ||
@@ -177,4 +170,12 @@ if (currClock !== 0) { | ||
currClient = curr.id.client | ||
stopCounting = false | ||
currClock = 0 | ||
stopCounting = curr.id.clock !== 0 | ||
} | ||
// we ignore skips | ||
if (curr.constructor === Skip) { | ||
stopCounting = true | ||
} | ||
if (!stopCounting) { | ||
currClock = curr.id.clock + curr.length | ||
} | ||
} | ||
@@ -337,2 +338,3 @@ // write what we have | ||
let curr = /** @type {Item | GC | null} */ (currDecoder.curr) | ||
let iterated = false | ||
@@ -343,4 +345,9 @@ // iterate until we find something that we haven't written already | ||
curr = currDecoder.next() | ||
iterated = true | ||
} | ||
if (curr === null || curr.id.client !== firstClient) { | ||
if ( | ||
curr === null || // current decoder is empty | ||
curr.id.client !== firstClient || // check whether there is another decoder that has has updates from `firstClient` | ||
(iterated && curr.id.clock > currWrite.struct.id.clock + currWrite.struct.length) // the above while loop was used and we are potentially missing updates | ||
) { | ||
continue | ||
@@ -521,1 +528,31 @@ } | ||
} | ||
/** | ||
* @param {Uint8Array} update | ||
* @param {typeof UpdateDecoderV2 | typeof UpdateDecoderV1} YDecoder | ||
* @param {typeof UpdateEncoderV2 | typeof UpdateEncoderV1 } YEncoder | ||
*/ | ||
export const convertUpdateFormat = (update, YDecoder, YEncoder) => { | ||
const updateDecoder = new YDecoder(decoding.createDecoder(update)) | ||
const lazyDecoder = new LazyStructReader(updateDecoder, false) | ||
const updateEncoder = new YEncoder() | ||
const lazyWriter = new LazyStructWriter(updateEncoder) | ||
for (let curr = lazyDecoder.curr; curr !== null; curr = lazyDecoder.next()) { | ||
writeStructToLazyStructWriter(lazyWriter, curr, 0) | ||
} | ||
finishLazyStructWriting(lazyWriter) | ||
const ds = readDeleteSet(updateDecoder) | ||
writeDeleteSet(updateEncoder, ds) | ||
return updateEncoder.toUint8Array() | ||
} | ||
/** | ||
* @param {Uint8Array} update | ||
*/ | ||
export const convertUpdateFormatV1ToV2 = update => convertUpdateFormat(update, UpdateDecoderV1, UpdateEncoderV2) | ||
/** | ||
* @param {Uint8Array} update | ||
*/ | ||
export const convertUpdateFormatV2ToV1 = update => convertUpdateFormat(update, UpdateDecoderV2, UpdateEncoderV1) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2019290
31192
1033