Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Socket
Sign inDemoInstall

yjs

Package Overview
Dependencies
Maintainers
1
Versions
286
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

yjs - npm Package Compare versions

Comparing version 13.5.13 to 13.5.14

2

dist/src/structs/Item.d.ts

@@ -7,3 +7,3 @@ export function followRedone(store: StructStore, id: ID): {

export function splitItem(transaction: Transaction, leftItem: Item, diff: number): Item;
export function redoItem(transaction: Transaction, item: Item, redoitems: Set<Item>): Item | null;
export function redoItem(transaction: Transaction, item: Item, redoitems: Set<Item>, itemsToDelete: Array<Item>): Item | null;
/**

@@ -10,0 +10,0 @@ * Abstract class that represents any content.

@@ -130,16 +130,16 @@ export class ArraySearchMarker {

[x: string]: any;
} | Array<any> | boolean | number | string | Uint8Array>): void;
} | Array<any> | boolean | number | null | string | Uint8Array>): void;
export function typeListInsertGenerics(transaction: Transaction, parent: AbstractType<any>, index: number, content: Array<{
[x: string]: any;
} | Array<any> | number | string | Uint8Array>): void;
} | Array<any> | number | null | string | Uint8Array>): void;
export function typeListDelete(transaction: Transaction, parent: AbstractType<any>, index: number, length: number): void;
export function typeMapDelete(transaction: Transaction, parent: AbstractType<any>, key: string): void;
export function typeMapSet(transaction: Transaction, parent: AbstractType<any>, key: string, value: Object | number | Array<any> | string | Uint8Array | AbstractType<any>): void;
export function typeMapSet(transaction: Transaction, parent: AbstractType<any>, key: string, value: Object | number | null | Array<any> | string | Uint8Array | AbstractType<any>): void;
export function typeMapGet(parent: AbstractType<any>, key: string): {
[x: string]: any;
} | number | Array<any> | string | Uint8Array | AbstractType<any> | undefined;
} | number | null | Array<any> | string | Uint8Array | AbstractType<any> | undefined;
export function typeMapGetAll(parent: AbstractType<any>): {
[x: string]: {
[x: string]: any;
} | number | Array<any> | string | Uint8Array | AbstractType<any> | undefined;
} | number | null | Array<any> | string | Uint8Array | AbstractType<any> | undefined;
};

@@ -149,3 +149,3 @@ export function typeMapHas(parent: AbstractType<any>, key: string): boolean;

[x: string]: any;
} | number | Array<any> | string | Uint8Array | AbstractType<any> | undefined;
} | number | null | Array<any> | string | Uint8Array | AbstractType<any> | undefined;
export function createMapIterator(map: Map<string, Item>): IterableIterator<Array<any>>;

@@ -152,0 +152,0 @@ import { Item } from "../structs/Item.js";

@@ -26,3 +26,3 @@ /**

*/
static from<T_2>(items: T_2[]): YArray<T_2>;
static from<T_1>(items: T_1[]): YArray<T_1>;
/**

@@ -95,3 +95,3 @@ * @type {Array<any>?}

*
* @template T,M
* @template M
* @param {function(T,number,YArray<T>):M} f Function that produces an element of the new Array

@@ -101,3 +101,3 @@ * @return {Array<M>} A new array with each element being the result of the

*/
map<T_1, M>(f: (arg0: T_1, arg1: number, arg2: YArray<T_1>) => M): M[];
map<M>(f: (arg0: T, arg1: number, arg2: YArray<T>) => M): M[];
/**

@@ -104,0 +104,0 @@ * Executes a provided function on once on overy element of this YArray.

@@ -15,9 +15,9 @@ /**

/**
* @template T number|string|Object|Array|Uint8Array
* @template MapType
* A shared Map implementation.
*
* @extends AbstractType<YMapEvent<T>>
* @implements {Iterable<T>}
* @extends AbstractType<YMapEvent<MapType>>
* @implements {Iterable<MapType>}
*/
export class YMap<T> extends AbstractType<YMapEvent<T>> implements Iterable<T> {
export class YMap<MapType> extends AbstractType<YMapEvent<MapType>> implements Iterable<MapType> {
/**

@@ -60,12 +60,8 @@ *

*
* @param {function(T,string,YMap<T>):void} f A function to execute on every element of this YArray.
* @param {function(MapType,string,YMap<MapType>):void} f A function to execute on every element of this YArray.
*/
forEach(f: (arg0: T, arg1: string, arg2: YMap<T>) => void): {
[x: string]: T;
forEach(f: (arg0: MapType, arg1: string, arg2: YMap<MapType>) => void): {
[x: string]: MapType;
};
/**
* @return {IterableIterator<T>}
*/
[Symbol.iterator](): IterableIterator<T>;
/**
* Remove a specified element from this YMap.

@@ -80,5 +76,5 @@ *

* @param {string} key The key of the element to add to this YMap
* @param {T} value The value of the element to add
* @param {MapType} value The value of the element to add
*/
set(key: string, value: T): T;
set(key: string, value: MapType): MapType;
/**

@@ -88,5 +84,5 @@ * Returns a specified element from this YMap.

* @param {string} key
* @return {T|undefined}
* @return {MapType|undefined}
*/
get(key: string): T | undefined;
get(key: string): MapType | undefined;
/**

@@ -103,2 +99,6 @@ * Returns a boolean indicating whether the specified key exists or not.

clear(): void;
/**
* @return {IterableIterator<MapType>}
*/
[Symbol.iterator](): IterableIterator<MapType>;
}

@@ -105,0 +105,0 @@ export function readYMap(decoder: UpdateDecoderV1 | UpdateDecoderV2): YMap<any>;

@@ -130,3 +130,3 @@ export class ItemTextListPosition {

* @param {number} index The index to insert the embed at.
* @param {Object} embed The Object that represents the embed.
* @param {Object | AbstractType<any>} embed The Object that represents the embed.
* @param {TextAttributes} attributes Attribute information to apply on the

@@ -137,3 +137,3 @@ * embed

*/
public insertEmbed(index: number, embed: Object, attributes?: TextAttributes): void;
public insertEmbed(index: number, embed: Object | AbstractType<any>, attributes?: TextAttributes): void;
/**

@@ -140,0 +140,0 @@ * Deletes text starting from an index.

@@ -42,3 +42,2 @@ /**

_firstCall: boolean;
[Symbol.iterator](): YXmlTreeWalker;
/**

@@ -52,2 +51,3 @@ * Get the next node.

public next(): IteratorResult<YXmlElement | YXmlText | YXmlHook>;
[Symbol.iterator](): YXmlTreeWalker;
}

@@ -204,3 +204,3 @@ /**

* Define the elements to which a set of CSS queries apply.
* {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors|CSS_Selectors}
* {@link https ://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors|CSS_Selectors}
*/

@@ -207,0 +207,0 @@ export type CSS_Selector = string;

@@ -113,8 +113,9 @@ export const generateNewClientId: typeof random.uint32;

/**
* @template T
* @param {string} [name]
* @return {YMap<any>}
* @return {YMap<T>}
*
* @public
*/
public getMap(name?: string | undefined): YMap<any>;
public getMap<T_1>(name?: string | undefined): YMap<T_1>;
/**

@@ -121,0 +122,0 @@ * @param {string} [name]

@@ -38,6 +38,6 @@ /**

/**
* @type {null | Array<{ insert?: string | Array<any>, retain?: number, delete?: number, attributes?: Object<string, any> }>}
* @type {null | Array<{ insert?: string | Array<any> | object | AbstractType<any>, retain?: number, delete?: number, attributes?: Object<string, any> }>}
*/
_delta: {
insert?: string | any[] | undefined;
insert?: string | object | any[] | AbstractType<any> | undefined;
retain?: number | undefined;

@@ -81,6 +81,6 @@ delete?: number | undefined;

/**
* @type {Array<{insert?: string | Array<any>, retain?: number, delete?: number, attributes?: Object<string, any>}>}
* @type {Array<{insert?: string | Array<any> | object | AbstractType<any>, retain?: number, delete?: number, attributes?: Object<string, any>}>}
*/
get delta(): {
insert?: string | any[] | undefined;
insert?: string | object | any[] | AbstractType<any> | undefined;
retain?: number | undefined;

@@ -87,0 +87,0 @@ delete?: number | undefined;

{
"name": "yjs",
"version": "13.5.13",
"version": "13.5.14",
"description": "Shared Editing Library",

@@ -74,3 +74,3 @@ "main": "./dist/yjs.cjs",

"dependencies": {
"lib0": "^0.2.41"
"lib0": "^0.2.42"
},

@@ -82,10 +82,10 @@ "devDependencies": {

"http-server": "^0.12.3",
"jsdoc": "^3.6.6",
"jsdoc": "^3.6.7",
"markdownlint-cli": "^0.23.2",
"rollup": "^2.47.0",
"standard": "^14.3.4",
"rollup": "^2.58.0",
"standard": "^16.0.4",
"tui-jsdoc-template": "^1.2.2",
"typescript": "^4.2.4",
"y-protocols": "^1.0.4"
"typescript": "^4.4.4",
"y-protocols": "^1.0.5"
}
}

@@ -253,3 +253,3 @@

<dd></dd>
<b><code>insert(index:number, content:Array&lt;object|boolean|Array|string|number|Uint8Array|Y.Type&gt;)</code></b>
<b><code>insert(index:number, content:Array&lt;object|boolean|Array|string|number|null|Uint8Array|Y.Type&gt;)</code></b>
<dd>

@@ -260,5 +260,5 @@ Insert content at <var>index</var>. Note that content is an array of elements.

</dd>
<b><code>push(Array&lt;Object|boolean|Array|string|number|Uint8Array|Y.Type&gt;)</code></b>
<b><code>push(Array&lt;Object|boolean|Array|string|number|null|Uint8Array|Y.Type&gt;)</code></b>
<dd></dd>
<b><code>unshift(Array&lt;Object|boolean|Array|string|number|Uint8Array|Y.Type&gt;)</code></b>
<b><code>unshift(Array&lt;Object|boolean|Array|string|number|null|Uint8Array|Y.Type&gt;)</code></b>
<dd></dd>

@@ -269,3 +269,3 @@ <b><code>delete(index:number, length:number)</code></b>

<dd></dd>
<b><code>slice(start:number, end:number):Array&lt;Object|boolean|Array|string|number|Uint8Array|Y.Type&gt;</code></b>
<b><code>slice(start:number, end:number):Array&lt;Object|boolean|Array|string|number|null|Uint8Array|Y.Type&gt;</code></b>
<dd>Retrieve a range of content</dd>

@@ -276,3 +276,3 @@ <b><code>length:number</code></b>

<code>
forEach(function(value:object|boolean|Array|string|number|Uint8Array|Y.Type,
forEach(function(value:object|boolean|Array|string|number|null|Uint8Array|Y.Type,
index:number, array: Y.Array))

@@ -284,5 +284,5 @@ </code>

<dd></dd>
<b><code>toArray():Array&lt;object|boolean|Array|string|number|Uint8Array|Y.Type&gt;</code></b>
<b><code>toArray():Array&lt;object|boolean|Array|string|number|null|Uint8Array|Y.Type&gt;</code></b>
<dd>Copies the content of this YArray to a new Array.</dd>
<b><code>toJSON():Array&lt;Object|boolean|Array|string|number&gt;</code></b>
<b><code>toJSON():Array&lt;Object|boolean|Array|string|number|null&gt;</code></b>
<dd>

@@ -333,5 +333,5 @@ Copies the content of this YArray to a new Array. It transforms all child types

<dd>Total number of key/value pairs.</dd>
<b><code>get(key:string):object|boolean|string|number|Uint8Array|Y.Type</code></b>
<b><code>get(key:string):object|boolean|string|number|null|Uint8Array|Y.Type</code></b>
<dd></dd>
<b><code>set(key:string, value:object|boolean|string|number|Uint8Array|Y.Type)</code></b>
<b><code>set(key:string, value:object|boolean|string|number|null|Uint8Array|Y.Type)</code></b>
<dd></dd>

@@ -348,3 +348,3 @@ <b><code>delete(key:string)</code></b>

<dd>Clone this type into a fresh Yjs type.</dd>
<b><code>toJSON():Object&lt;string, Object|boolean|Array|string|number|Uint8Array&gt;</code></b>
<b><code>toJSON():Object&lt;string, Object|boolean|Array|string|number|null|Uint8Array&gt;</code></b>
<dd>

@@ -354,3 +354,3 @@ Copies the <code>[key,value]</code> pairs of this YMap to a new Object.It

</dd>
<b><code>forEach(function(value:object|boolean|Array|string|number|Uint8Array|Y.Type,
<b><code>forEach(function(value:object|boolean|Array|string|number|null|Uint8Array|Y.Type,
key:string, map: Y.Map))</code></b>

@@ -357,0 +357,0 @@ <dd>

@@ -128,2 +128,3 @@

* @param {Set<Item>} redoitems
* @param {Array<Item>} itemsToDelete
*

@@ -134,3 +135,3 @@ * @return {Item|null}

*/
export const redoItem = (transaction, item, redoitems) => {
export const redoItem = (transaction, item, redoitems, itemsToDelete) => {
const doc = transaction.doc

@@ -175,3 +176,3 @@ const store = doc.store

// try to undo parent if it will be undone anyway
if (!redoitems.has(parentItem) || redoItem(transaction, parentItem, redoitems) === null) {
if (!redoitems.has(parentItem) || redoItem(transaction, parentItem, redoitems, itemsToDelete) === null) {
return null

@@ -215,2 +216,7 @@ }

}
// Iterate right while right is in itemsToDelete
// If it is intended to delete right while item is redone, we can expect that item should replace right.
while (left !== null && left.right !== null && left.right !== right && itemsToDelete.findIndex(d => d === /** @type {Item} */ (left).right) >= 0) {
left = left.right
}
}

@@ -217,0 +223,0 @@ const nextClock = getState(store, ownClientID)

@@ -626,3 +626,3 @@

* @param {Item?} referenceItem
* @param {Array<Object<string,any>|Array<any>|boolean|number|string|Uint8Array>} content
* @param {Array<Object<string,any>|Array<any>|boolean|number|null|string|Uint8Array>} content
*

@@ -639,3 +639,3 @@ * @private

/**
* @type {Array<Object|Array<any>|number>}
* @type {Array<Object|Array<any>|number|null>}
*/

@@ -651,30 +651,34 @@ let jsonContent = []

content.forEach(c => {
switch (c.constructor) {
case Number:
case Object:
case Boolean:
case Array:
case String:
jsonContent.push(c)
break
default:
packJsonContent()
switch (c.constructor) {
case Uint8Array:
case ArrayBuffer:
left = new Item(createID(ownClientId, getState(store, ownClientId)), left, left && left.lastId, right, right && right.id, parent, null, new ContentBinary(new Uint8Array(/** @type {Uint8Array} */ (c))))
left.integrate(transaction, 0)
break
case Doc:
left = new Item(createID(ownClientId, getState(store, ownClientId)), left, left && left.lastId, right, right && right.id, parent, null, new ContentDoc(/** @type {Doc} */ (c)))
left.integrate(transaction, 0)
break
default:
if (c instanceof AbstractType) {
left = new Item(createID(ownClientId, getState(store, ownClientId)), left, left && left.lastId, right, right && right.id, parent, null, new ContentType(c))
if (c === null) {
jsonContent.push(c)
} else {
switch (c.constructor) {
case Number:
case Object:
case Boolean:
case Array:
case String:
jsonContent.push(c)
break
default:
packJsonContent()
switch (c.constructor) {
case Uint8Array:
case ArrayBuffer:
left = new Item(createID(ownClientId, getState(store, ownClientId)), left, left && left.lastId, right, right && right.id, parent, null, new ContentBinary(new Uint8Array(/** @type {Uint8Array} */ (c))))
left.integrate(transaction, 0)
} else {
throw new Error('Unexpected content type in insert operation')
}
}
break
case Doc:
left = new Item(createID(ownClientId, getState(store, ownClientId)), left, left && left.lastId, right, right && right.id, parent, null, new ContentDoc(/** @type {Doc} */ (c)))
left.integrate(transaction, 0)
break
default:
if (c instanceof AbstractType) {
left = new Item(createID(ownClientId, getState(store, ownClientId)), left, left && left.lastId, right, right && right.id, parent, null, new ContentType(c))
left.integrate(transaction, 0)
} else {
throw new Error('Unexpected content type in insert operation')
}
}
}
}

@@ -691,3 +695,3 @@ })

* @param {number} index
* @param {Array<Object<string,any>|Array<any>|number|string|Uint8Array>} content
* @param {Array<Object<string,any>|Array<any>|number|null|string|Uint8Array>} content
*

@@ -804,3 +808,3 @@ * @private

* @param {string} key
* @param {Object|number|Array<any>|string|Uint8Array|AbstractType<any>} value
* @param {Object|number|null|Array<any>|string|Uint8Array|AbstractType<any>} value
*

@@ -846,3 +850,3 @@ * @private

* @param {string} key
* @return {Object<string,any>|number|Array<any>|string|Uint8Array|AbstractType<any>|undefined}
* @return {Object<string,any>|number|null|Array<any>|string|Uint8Array|AbstractType<any>|undefined}
*

@@ -859,3 +863,3 @@ * @private

* @param {AbstractType<any>} parent
* @return {Object<string,Object<string,any>|number|Array<any>|string|Uint8Array|AbstractType<any>|undefined>}
* @return {Object<string,Object<string,any>|number|null|Array<any>|string|Uint8Array|AbstractType<any>|undefined>}
*

@@ -895,3 +899,3 @@ * @private

* @param {Snapshot} snapshot
* @return {Object<string,any>|number|Array<any>|string|Uint8Array|AbstractType<any>|undefined}
* @return {Object<string,any>|number|null|Array<any>|string|Uint8Array|AbstractType<any>|undefined}
*

@@ -898,0 +902,0 @@ * @private

@@ -218,3 +218,3 @@ /**

*
* @template T,M
* @template M
* @param {function(T,number,YArray<T>):M} f Function that produces an element of the new Array

@@ -221,0 +221,0 @@ * @return {Array<M>} A new array with each element being the result of the

@@ -39,7 +39,7 @@

/**
* @template T number|string|Object|Array|Uint8Array
* @template MapType
* A shared Map implementation.
*
* @extends AbstractType<YMapEvent<T>>
* @implements {Iterable<T>}
* @extends AbstractType<YMapEvent<MapType>>
* @implements {Iterable<MapType>}
*/

@@ -89,3 +89,3 @@ export class YMap extends AbstractType {

/**
* @return {YMap<T>}
* @return {YMap<MapType>}
*/

@@ -113,7 +113,7 @@ clone () {

*
* @return {Object<string,T>}
* @return {Object<string,any>}
*/
toJSON () {
/**
* @type {Object<string,T>}
* @type {Object<string,MapType>}
*/

@@ -169,7 +169,7 @@ const map = {}

*
* @param {function(T,string,YMap<T>):void} f A function to execute on every element of this YArray.
* @param {function(MapType,string,YMap<MapType>):void} f A function to execute on every element of this YArray.
*/
forEach (f) {
/**
* @type {Object<string,T>}
* @type {Object<string,MapType>}
*/

@@ -186,3 +186,3 @@ const map = {}

/**
* @return {IterableIterator<T>}
* @return {IterableIterator<MapType>}
*/

@@ -212,3 +212,3 @@ [Symbol.iterator] () {

* @param {string} key The key of the element to add to this YMap
* @param {T} value The value of the element to add
* @param {MapType} value The value of the element to add
*/

@@ -230,3 +230,3 @@ set (key, value) {

* @param {string} key
* @return {T|undefined}
* @return {MapType|undefined}
*/

@@ -233,0 +233,0 @@ get (key) {

@@ -29,2 +29,3 @@

updateMarkerChanges,
ContentType,
ArraySearchMarker, UpdateDecoderV1, UpdateDecoderV2, UpdateEncoderV1, UpdateEncoderV2, ID, Doc, Item, Snapshot, Transaction // eslint-disable-line

@@ -66,11 +67,10 @@ } from '../internals.js'

switch (this.right.content.constructor) {
case ContentEmbed:
case ContentString:
case ContentFormat:
if (!this.right.deleted) {
this.index += this.right.length
updateCurrentAttributes(this.currentAttributes, /** @type {ContentFormat} */ (this.right.content))
}
break
case ContentFormat:
default:
if (!this.right.deleted) {
updateCurrentAttributes(this.currentAttributes, /** @type {ContentFormat} */ (this.right.content))
this.index += this.right.length
}

@@ -96,5 +96,9 @@ break

switch (pos.right.content.constructor) {
case ContentEmbed:
case ContentString:
case ContentFormat:
if (!pos.right.deleted) {
updateCurrentAttributes(pos.currentAttributes, /** @type {ContentFormat} */ (pos.right.content))
}
break
default:
if (!pos.right.deleted) {
if (count < pos.right.length) {

@@ -108,7 +112,2 @@ // split right

break
case ContentFormat:
if (!pos.right.deleted) {
updateCurrentAttributes(pos.currentAttributes, /** @type {ContentFormat} */ (pos.right.content))
}
break
}

@@ -252,3 +251,3 @@ pos.left = pos.right

* @param {ItemTextListPosition} currPos
* @param {string|object} text
* @param {string|object|AbstractType<any>} text
* @param {Object<string,any>} attributes

@@ -270,3 +269,3 @@ *

// insert content
const content = text.constructor === String ? new ContentString(/** @type {string} */ (text)) : new ContentEmbed(text)
const content = text.constructor === String ? new ContentString(/** @type {string} */ (text)) : (text instanceof AbstractType ? new ContentType(text) : new ContentEmbed(text))
let { left, right, index } = currPos

@@ -317,4 +316,3 @@ if (parent._searchMarker) {

}
case ContentEmbed:
case ContentString:
default:
if (length < currPos.right.length) {

@@ -358,3 +356,3 @@ getItemCleanStart(transaction, createID(currPos.right.id.client, currPos.right.id.clock + length))

const cleanupFormattingGap = (transaction, start, end, startAttributes, endAttributes) => {
while (end && end.content.constructor !== ContentString && end.content.constructor !== ContentEmbed) {
while (end && (!end.countable || end.deleted)) {
if (!end.deleted && end.content.constructor === ContentFormat) {

@@ -392,3 +390,3 @@ updateCurrentAttributes(endAttributes, /** @type {ContentFormat} */ (end.content))

// iterate until item.right is null or content
while (item && item.right && (item.right.deleted || (item.right.content.constructor !== ContentString && item.right.content.constructor !== ContentEmbed))) {
while (item && item.right && (item.right.deleted || !item.right.countable)) {
item = item.right

@@ -398,3 +396,3 @@ }

// iterate back until a content item is found
while (item && (item.deleted || (item.content.constructor !== ContentString && item.content.constructor !== ContentEmbed))) {
while (item && (item.deleted || !item.countable)) {
if (!item.deleted && item.content.constructor === ContentFormat) {

@@ -437,4 +435,3 @@ const key = /** @type {ContentFormat} */ (item.content).key

break
case ContentEmbed:
case ContentString:
default:
res += cleanupFormattingGap(transaction, start, end, startAttributes, currentAttributes)

@@ -468,2 +465,3 @@ startAttributes = map.copy(currentAttributes)

switch (currPos.right.content.constructor) {
case ContentType:
case ContentEmbed:

@@ -555,3 +553,3 @@ case ContentString:

/**
* @type {{added:Set<Item>,deleted:Set<Item>,keys:Map<string,{action:'add'|'update'|'delete',oldValue:any}>,delta:Array<{insert?:Array<any>|string, delete?:number, retain?:number}>}}
* @type {{added:Set<Item>,deleted:Set<Item>,keys:Map<string,{action:'add'|'update'|'delete',oldValue:any}>,delta:Array<{insert?:Array<any>|string|AbstractType<any>|object, delete?:number, retain?:number}>}}
*/

@@ -573,3 +571,3 @@ const changes = {

*
* @type {Array<{insert?:string, delete?:number, retain?:number, attributes?: Object<string,any>}>}
* @type {Array<{insert?:string|object|AbstractType<any>, delete?:number, retain?:number, attributes?: Object<string,any>}>}
*

@@ -582,3 +580,3 @@ * @public

/**
* @type {Array<{insert?:string, delete?:number, retain?:number, attributes?: Object<string,any>}>}
* @type {Array<{insert?:string|object|AbstractType<any>, delete?:number, retain?:number, attributes?: Object<string,any>}>}
*/

@@ -644,2 +642,3 @@ const delta = []

switch (item.content.constructor) {
case ContentType:
case ContentEmbed:

@@ -650,3 +649,3 @@ if (this.adds(item)) {

action = 'insert'
insert = /** @type {ContentEmbed} */ (item.content).embed
insert = item.content.getContent()[0]
addOp()

@@ -1028,2 +1027,3 @@ }

}
case ContentType:
case ContentEmbed: {

@@ -1035,3 +1035,3 @@ packStr()

const op = {
insert: /** @type {ContentEmbed} */ (n.content).embed
insert: n.content.getContent()[0]
}

@@ -1097,3 +1097,3 @@ if (currentAttributes.size > 0) {

* @param {number} index The index to insert the embed at.
* @param {Object} embed The Object that represents the embed.
* @param {Object | AbstractType<any>} embed The Object that represents the embed.
* @param {TextAttributes} attributes Attribute information to apply on the

@@ -1105,5 +1105,2 @@ * embed

insertEmbed (index, embed, attributes = {}) {
if (embed.constructor !== Object) {
throw new Error('Embed must be an Object')
}
const y = this.doc

@@ -1110,0 +1107,0 @@ if (y !== null) {

@@ -197,4 +197,5 @@ /**

/**
* @template T
* @param {string} [name]
* @return {YMap<any>}
* @return {YMap<T>}
*

@@ -201,0 +202,0 @@ * @public

@@ -132,5 +132,5 @@

*/
export const isVisible = (item, snapshot) => snapshot === undefined ? !item.deleted : (
snapshot.sv.has(item.id.client) && (snapshot.sv.get(item.id.client) || 0) > item.id.clock && !isDeleted(snapshot.ds, item.id)
)
export const isVisible = (item, snapshot) => snapshot === undefined
? !item.deleted
: snapshot.sv.has(item.id.client) && (snapshot.sv.get(item.id.client) || 0) > item.id.clock && !isDeleted(snapshot.ds, item.id)

@@ -137,0 +137,0 @@ /**

@@ -91,3 +91,3 @@ import {

itemsToRedo.forEach(struct => {
performedChange = redoItem(transaction, struct, itemsToRedo) !== null || performedChange
performedChange = redoItem(transaction, struct, itemsToRedo, itemsToDelete) !== null || performedChange
})

@@ -94,0 +94,0 @@ // We want to delete in reverse order so that children are deleted before

@@ -319,5 +319,5 @@

// @todo remove references to skip since the structDecoders must filter Skips.
return dec1.curr.constructor === dec2.curr.constructor ? 0 : (
dec1.curr.constructor === Skip ? 1 : -1 // we are filtering skips anyway.
)
return dec1.curr.constructor === dec2.curr.constructor
? 0
: dec1.curr.constructor === Skip ? 1 : -1 // we are filtering skips anyway.
} else {

@@ -324,0 +324,0 @@ return clockDiff

@@ -43,3 +43,3 @@

/**
* @type {null | Array<{ insert?: string | Array<any>, retain?: number, delete?: number, attributes?: Object<string, any> }>}
* @type {null | Array<{ insert?: string | Array<any> | object | AbstractType<any>, retain?: number, delete?: number, attributes?: Object<string, any> }>}
*/

@@ -133,3 +133,3 @@ this._delta = null

/**
* @type {Array<{insert?: string | Array<any>, retain?: number, delete?: number, attributes?: Object<string, any>}>}
* @type {Array<{insert?: string | Array<any> | object | AbstractType<any>, retain?: number, delete?: number, attributes?: Object<string, any>}>}
*/

@@ -136,0 +136,0 @@ get delta () {

@@ -327,3 +327,3 @@

users.forEach(u => u.connect())
while (users[0].tc.flushAllMessages()) {}
while (users[0].tc.flushAllMessages()) {} // eslint-disable-line
// For each document, merge all received document updates with Y.mergeUpdates and create a new document which will be added to the list of "users"

@@ -366,3 +366,10 @@ // This ensures that mergeUpdates works correctly

t.compare(userTextValues[i].map(/** @param {any} a */ a => typeof a.insert === 'string' ? a.insert : ' ').join('').length, users[i].getText('text').length)
t.compare(userTextValues[i], userTextValues[i + 1])
t.compare(userTextValues[i], userTextValues[i + 1], '', (constructor, a, b) => {
if (a instanceof Y.AbstractType) {
t.compare(a.toJSON(), b.toJSON())
} else if (a !== b) {
t.fail('Deltas dont match')
}
return true
})
t.compare(Y.getStateVector(users[i].store), Y.getStateVector(users[i + 1].store))

@@ -369,0 +376,0 @@ compareDS(Y.createDeleteSetFromStructStore(users[i].store), Y.createDeleteSetFromStructStore(users[i + 1].store))

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc