diff --git a/package-lock.json b/package-lock.json index c72de184..c8fa40a2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -98,9 +98,9 @@ } }, "acorn": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.1.0.tgz", - "integrity": "sha512-kL5CuoXA/dgxlBbVrflsflzQ3PAas7RYZB52NOm/6839iVYJgKMJ3cQJD+t2i5+qFa8h3MDpEOJiS64E8JLnSQ==", + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.1.1.tgz", + "integrity": "sha512-add7dgA5ppRPxCFJoAGfMDi7PIBXq1RtGo7BhbLaxwrXPOmw8gq48Y9ozT01hUKy9byMjlR20EJhu5zlkErEkg==", "dev": true }, "acorn-jsx": { @@ -513,9 +513,9 @@ }, "dependencies": { "minimist": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", "dev": true } } @@ -1439,9 +1439,9 @@ } }, "lib0": { - "version": "0.2.15", - "resolved": "https://registry.npmjs.org/lib0/-/lib0-0.2.15.tgz", - "integrity": "sha512-wLwuTNNgtC7EQH0b3w4iqpts69TRFVur74Wta7jwgS2w+r/vPLuGcsBA16VoPgBYME7oxDSjEesJw9p/gHmFEg==", + "version": "0.2.22", + "resolved": "https://registry.npmjs.org/lib0/-/lib0-0.2.22.tgz", + "integrity": "sha512-SFzX7/SGgrOK6VABQugczhAwaaZLW1VcrE9xG+cVG1+AMQWmcu/7SZaJq0KORnfHr1xK4P6JUBWfoxSCwBcgLA==", "requires": { "isomorphic.js": "^0.1.3" } @@ -2135,9 +2135,9 @@ "dev": true }, "minimist": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", "dev": true }, "strip-json-comments": { @@ -2473,9 +2473,9 @@ }, "dependencies": { "minimist": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", "dev": true } } @@ -2783,12 +2783,12 @@ "dev": true }, "y-protocols": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/y-protocols/-/y-protocols-0.2.0.tgz", - "integrity": "sha512-B9MCxMqLZCziLmQFlrXVN7MbIhXzF9bdwePcHzlVFIEHxnEvYIqAQYj4FHS376LBgfcjTUs7T614D+w0bpcJLA==", + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/y-protocols/-/y-protocols-0.2.3.tgz", + "integrity": "sha512-mJ838iW7XgMQqlv+9DtH7QyLqflZoy/VvaUWRIpwawee4mQiFJcEXazCmSYUHEbXIUuVNNc70FnuNSMWDC5vKQ==", "dev": true, "requires": { - "lib0": "^0.2.3" + "lib0": "^0.2.20" } } } diff --git a/package.json b/package.json index 59ff902b..60282551 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ }, "homepage": "https://yjs.dev", "dependencies": { - "lib0": "^0.2.20" + "lib0": "^0.2.22" }, "devDependencies": { "@rollup/plugin-commonjs": "^11.0.1", @@ -70,6 +70,6 @@ "standard": "^14.0.0", "tui-jsdoc-template": "^1.2.2", "typescript": "^3.7.5", - "y-protocols": "^0.2.0" + "y-protocols": "^0.2.3" } } diff --git a/src/structs/AbstractStruct.js b/src/structs/AbstractStruct.js index 5595af00..ef4acee1 100644 --- a/src/structs/AbstractStruct.js +++ b/src/structs/AbstractStruct.js @@ -6,9 +6,6 @@ import { import * as encoding from 'lib0/encoding.js' // eslint-disable-line import * as error from 'lib0/error.js' -/** - * @private - */ export class AbstractStruct { /** * @param {ID} id @@ -40,7 +37,6 @@ export class AbstractStruct { * @param {encoding.Encoder} encoder The encoder to write data to. * @param {number} offset * @param {number} encodingRef - * @private */ write (encoder, offset, encodingRef) { throw error.methodUnimplemented() @@ -54,9 +50,6 @@ export class AbstractStruct { } } -/** - * @private - */ export class AbstractStructRef { /** * @param {ID} id diff --git a/src/structs/ContentAny.js b/src/structs/ContentAny.js index 6d2b3288..bb2d6a34 100644 --- a/src/structs/ContentAny.js +++ b/src/structs/ContentAny.js @@ -5,9 +5,6 @@ import { import * as encoding from 'lib0/encoding.js' import * as decoding from 'lib0/decoding.js' -/** - * @private - */ export class ContentAny { /** * @param {Array} arr @@ -101,8 +98,6 @@ export class ContentAny { } /** - * @private - * * @param {decoding.Decoder} decoder * @return {ContentAny} */ diff --git a/src/structs/ContentBinary.js b/src/structs/ContentBinary.js index 06b14855..e597a64e 100644 --- a/src/structs/ContentBinary.js +++ b/src/structs/ContentBinary.js @@ -7,9 +7,6 @@ import * as decoding from 'lib0/decoding.js' import * as buffer from 'lib0/buffer.js' import * as error from 'lib0/error.js' -/** - * @private - */ export class ContentBinary { /** * @param {Uint8Array} content @@ -92,8 +89,6 @@ export class ContentBinary { } /** - * @private - * * @param {decoding.Decoder} decoder * @return {ContentBinary} */ diff --git a/src/structs/ContentDeleted.js b/src/structs/ContentDeleted.js index 2f20b7ab..1d430707 100644 --- a/src/structs/ContentDeleted.js +++ b/src/structs/ContentDeleted.js @@ -7,9 +7,6 @@ import { import * as encoding from 'lib0/encoding.js' import * as decoding from 'lib0/decoding.js' -/** - * @private - */ export class ContentDeleted { /** * @param {number} len diff --git a/src/structs/ContentFormat.js b/src/structs/ContentFormat.js index 27d134e1..c7990c61 100644 --- a/src/structs/ContentFormat.js +++ b/src/structs/ContentFormat.js @@ -95,8 +95,6 @@ export class ContentFormat { } /** - * @private - * * @param {decoding.Decoder} decoder * @return {ContentFormat} */ diff --git a/src/structs/Item.js b/src/structs/Item.js index 253c6e0e..15a81daa 100644 --- a/src/structs/Item.js +++ b/src/structs/Item.js @@ -304,7 +304,6 @@ export class Item extends AbstractStruct { /** * @param {Transaction} transaction - * @private */ integrate (transaction) { const store = transaction.doc.store @@ -403,7 +402,6 @@ export class Item extends AbstractStruct { /** * Returns the next non-deleted item - * @private */ get next () { let n = this.right @@ -415,7 +413,6 @@ export class Item extends AbstractStruct { /** * Returns the previous non-deleted item - * @private */ get prev () { let n = this.left @@ -486,8 +483,6 @@ export class Item extends AbstractStruct { /** * @param {StructStore} store * @param {boolean} parentGCd - * - * @private */ gc (store, parentGCd) { if (!this.deleted) { @@ -509,8 +504,6 @@ export class Item extends AbstractStruct { * * @param {encoding.Encoder} encoder The encoder to write data to. * @param {number} offset - * - * @private */ write (encoder, offset) { const origin = offset > 0 ? createID(this.id.client, this.id.clock + offset - 1) : this.origin diff --git a/src/types/AbstractType.js b/src/types/AbstractType.js index fc347197..94250ec0 100644 --- a/src/types/AbstractType.js +++ b/src/types/AbstractType.js @@ -22,7 +22,6 @@ import * as encoding from 'lib0/encoding.js' // eslint-disable-line /** * Call event listeners with an event. This will also add an event to all * parents (for `.observeDeep` handlers). - * @private * * @template EventType * @param {AbstractType} type @@ -54,17 +53,14 @@ export class AbstractType { */ this._item = null /** - * @private * @type {Map} */ this._map = new Map() /** - * @private * @type {Item|null} */ this._start = null /** - * @private * @type {Doc|null} */ this.doc = null @@ -90,7 +86,6 @@ export class AbstractType { * * @param {Doc} y The Yjs instance * @param {Item|null} item - * @private */ _integrate (y, item) { this.doc = y @@ -99,7 +94,6 @@ export class AbstractType { /** * @return {AbstractType} - * @private */ _copy () { throw error.methodUnimplemented() @@ -107,7 +101,6 @@ export class AbstractType { /** * @param {encoding.Encoder} encoder - * @private */ _write (encoder) { } @@ -128,8 +121,6 @@ export class AbstractType { * * @param {Transaction} transaction * @param {Set} parentSubs Keys changed on this type. `null` if list was modified. - * - * @private */ _callObserver (transaction, parentSubs) { /* skip if no type is specified */ } diff --git a/src/types/YArray.js b/src/types/YArray.js index 36d209d0..58334df3 100644 --- a/src/types/YArray.js +++ b/src/types/YArray.js @@ -61,8 +61,6 @@ export class YArray extends AbstractType { * * @param {Doc} y The Yjs instance * @param {Item} item - * - * @private */ _integrate (y, item) { super._integrate(y, item) @@ -83,8 +81,6 @@ export class YArray extends AbstractType { * * @param {Transaction} transaction * @param {Set} parentSubs Keys changed on this type. `null` if list was modified. - * - * @private */ _callObserver (transaction, parentSubs) { callTypeObservers(this, transaction, new YArrayEvent(this, transaction)) @@ -200,7 +196,6 @@ export class YArray extends AbstractType { /** * @param {encoding.Encoder} encoder - * @private */ _write (encoder) { encoding.writeVarUint(encoder, YArrayRefID) diff --git a/src/types/YMap.js b/src/types/YMap.js index c9399371..f0f06630 100644 --- a/src/types/YMap.js +++ b/src/types/YMap.js @@ -63,8 +63,6 @@ export class YMap extends AbstractType { * * @param {Doc} y The Yjs instance * @param {Item} item - * - * @private */ _integrate (y, item) { super._integrate(y, item) @@ -83,8 +81,6 @@ export class YMap extends AbstractType { * * @param {Transaction} transaction * @param {Set} parentSubs Keys changed on this type. `null` if list was modified. - * - * @private */ _callObserver (transaction, parentSubs) { callTypeObservers(this, transaction, new YMapEvent(this, transaction, parentSubs)) @@ -215,8 +211,6 @@ export class YMap extends AbstractType { /** * @param {encoding.Encoder} encoder - * - * @private */ _write (encoder) { encoding.writeVarUint(encoder, YMapRefID) diff --git a/src/types/YText.js b/src/types/YText.js index 7a33cd6d..a9c768b6 100644 --- a/src/types/YText.js +++ b/src/types/YText.js @@ -250,7 +250,7 @@ const insertText = (transaction, parent, left, right, currentAttributes, text, a left = insertPos.left right = insertPos.right // insert content - const content = text.constructor === String ? new ContentString(text) : new ContentEmbed(text) + const content = text.constructor === String ? new ContentString(/** @type {string} */ (text)) : new ContentEmbed(text) left = new Item(nextID(transaction), left, left === null ? null : left.lastId, right, right === null ? null : right.id, parent, null, content) left.integrate(transaction) return insertNegatedAttributes(transaction, parent, left, insertPos.right, insertPos.negatedAttributes) @@ -400,7 +400,6 @@ export class YTextEvent extends YEvent { constructor (ytext, transaction) { super(ytext, transaction) /** - * @private * @type {Array|null} */ this._delta = null @@ -612,7 +611,6 @@ export class YText extends AbstractType { /** * Array of pending operations on this type * @type {Array?} - * @private */ this._pending = string !== undefined ? [() => this.insert(0, string)] : [] } @@ -629,8 +627,6 @@ export class YText extends AbstractType { /** * @param {Doc} y * @param {Item} item - * - * @private */ _integrate (y, item) { super._integrate(y, item) @@ -651,8 +647,6 @@ export class YText extends AbstractType { * * @param {Transaction} transaction * @param {Set} parentSubs Keys changed on this type. `null` if list was modified. - * - * @private */ _callObserver (transaction, parentSubs) { callTypeObservers(this, transaction, new YTextEvent(this, transaction)) @@ -938,8 +932,6 @@ export class YText extends AbstractType { /** * @param {encoding.Encoder} encoder - * - * @private */ _write (encoder) { encoding.writeVarUint(encoder, YTextRefID) diff --git a/src/types/YXmlElement.js b/src/types/YXmlElement.js index 9429b310..c16e7abb 100644 --- a/src/types/YXmlElement.js +++ b/src/types/YXmlElement.js @@ -27,7 +27,6 @@ export class YXmlElement extends YXmlFragment { this.nodeName = nodeName /** * @type {Map|null} - * @private */ this._prelimAttrs = new Map() } @@ -41,7 +40,6 @@ export class YXmlElement extends YXmlFragment { * * @param {Doc} y The Yjs instance * @param {Item} item - * @private */ _integrate (y, item) { super._integrate(y, item) @@ -55,7 +53,6 @@ export class YXmlElement extends YXmlFragment { * Creates an Item with the same effect as this Item (without position effect) * * @return {YXmlElement} - * @private */ _copy () { return new YXmlElement(this.nodeName) @@ -184,7 +181,6 @@ export class YXmlElement extends YXmlFragment { * * This is called when this Item is sent to a remote peer. * - * @private * @param {encoding.Encoder} encoder The encoder to write data to. */ _write (encoder) { @@ -197,7 +193,6 @@ export class YXmlElement extends YXmlFragment { * @param {decoding.Decoder} decoder * @return {YXmlElement} * - * @private * @function */ export const readYXmlElement = decoder => new YXmlElement(decoding.readVarString(decoder)) diff --git a/src/types/YXmlFragment.js b/src/types/YXmlFragment.js index d692c8f6..f8876be7 100644 --- a/src/types/YXmlFragment.js +++ b/src/types/YXmlFragment.js @@ -127,7 +127,6 @@ export class YXmlFragment extends AbstractType { super() /** * @type {Array|null} - * @private */ this._prelimContent = [] } @@ -141,7 +140,6 @@ export class YXmlFragment extends AbstractType { * * @param {Doc} y The Yjs instance * @param {Item} item - * @private */ _integrate (y, item) { super._integrate(y, item) @@ -224,7 +222,6 @@ export class YXmlFragment extends AbstractType { /** * Creates YXmlEvent and calls observers. - * @private * * @param {Transaction} transaction * @param {Set} parentSubs Keys changed on this type. `null` if list was modified. @@ -328,7 +325,6 @@ export class YXmlFragment extends AbstractType { * * This is called when this Item is sent to a remote peer. * - * @private * @param {encoding.Encoder} encoder The encoder to write data to. */ _write (encoder) { diff --git a/src/types/YXmlHook.js b/src/types/YXmlHook.js index 06e1584b..4bb17554 100644 --- a/src/types/YXmlHook.js +++ b/src/types/YXmlHook.js @@ -25,8 +25,6 @@ export class YXmlHook extends YMap { /** * Creates an Item with the same effect as this Item (without position effect) - * - * @private */ _copy () { return new YXmlHook(this.hookName) @@ -69,8 +67,6 @@ export class YXmlHook extends YMap { * This is called when this Item is sent to a remote peer. * * @param {encoding.Encoder} encoder The encoder to write data to. - * - * @private */ _write (encoder) { super._write(encoder) diff --git a/src/types/YXmlText.js b/src/types/YXmlText.js index e4ef8f24..b7e03f18 100644 --- a/src/types/YXmlText.js +++ b/src/types/YXmlText.js @@ -79,8 +79,6 @@ export class YXmlText extends YText { /** * @param {encoding.Encoder} encoder - * - * @private */ _write (encoder) { encoding.writeVarUint(encoder, YXmlTextRefID) diff --git a/src/utils/DeleteSet.js b/src/utils/DeleteSet.js index 16c4a2ba..dfcb31ac 100644 --- a/src/utils/DeleteSet.js +++ b/src/utils/DeleteSet.js @@ -42,7 +42,6 @@ export class DeleteSet { constructor () { /** * @type {Map>} - * @private */ this.clients = new Map() } diff --git a/src/utils/Doc.js b/src/utils/Doc.js index fc5ca6dd..58c76467 100644 --- a/src/utils/Doc.js +++ b/src/utils/Doc.js @@ -39,12 +39,10 @@ export class Doc extends Observable { this.store = new StructStore() /** * @type {Transaction | null} - * @private */ this._transaction = null /** * @type {Array} - * @private */ this._transactionCleanups = [] } @@ -105,6 +103,7 @@ export class Doc extends Observable { t._map = type._map type._map.forEach(/** @param {Item?} n */ n => { for (; n !== null; n = n.left) { + // @ts-ignore n.parent = t } }) @@ -170,8 +169,6 @@ export class Doc extends Observable { /** * Emit `destroy` event and unregister all event handlers. - * - * @protected */ destroy () { this.emit('destroyed', [true]) diff --git a/src/utils/Snapshot.js b/src/utils/Snapshot.js index 716ddeed..521d3c44 100644 --- a/src/utils/Snapshot.js +++ b/src/utils/Snapshot.js @@ -28,13 +28,11 @@ export class Snapshot { constructor (ds, sv) { /** * @type {DeleteSet} - * @private */ this.ds = ds /** * State Map * @type {Map} - * @private */ this.sv = sv } diff --git a/src/utils/StructStore.js b/src/utils/StructStore.js index 30bc0c90..1ea11dd4 100644 --- a/src/utils/StructStore.js +++ b/src/utils/StructStore.js @@ -13,7 +13,6 @@ export class StructStore { constructor () { /** * @type {Map>} - * @private */ this.clients = new Map() /** @@ -23,19 +22,16 @@ export class StructStore { * slow in Chrome for arrays with more than 100k elements * @see tryResumePendingStructRefs * @type {Map}>} - * @private */ this.pendingClientsStructRefs = new Map() /** * Stack of pending structs waiting for struct dependencies * Maximum length of stack is structReaders.size * @type {Array} - * @private */ this.pendingStack = [] /** * @type {Array} - * @private */ this.pendingDeleteReaders = [] } diff --git a/src/utils/Transaction.js b/src/utils/Transaction.js index 3f0e2f8a..68459398 100644 --- a/src/utils/Transaction.js +++ b/src/utils/Transaction.js @@ -85,7 +85,6 @@ export class Transaction { this.changedParentTypes = new Map() /** * @type {Set} - * @private */ this._mergeStructs = new Set() /** diff --git a/tsconfig.json b/tsconfig.json index 828d8c88..31ccd70e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -39,10 +39,7 @@ "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ "paths": { - "yjs": ["./src/index.js"], - "lib0/*": ["node_modules/lib0/*"], - "lib0/set.js": ["node_modules/lib0/set.js"], - "lib0/function.js": ["node_modules/lib0/function.js"] + "yjs": ["./src/index.js"] }, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ // "typeRoots": [], /* List of folders to include type definitions from. */ @@ -60,9 +57,8 @@ /* Experimental Options */ // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ - "maxNodeModuleJsDepth": 5, + // "maxNodeModuleJsDepth": 0, // "types": ["./src/utils/typedefs.js"] }, - "include": ["./src/**/*.js", "./tests/**/*.js"], - "exclude": ["../lib0/**/*", "node_modules/**/*", "dist", "dist/**/*.js"] + "include": ["./src/**/*.js", "./tests/**/*.js"] }