From 034463798df62fd2a1950179c19a6f06bb87caf6 Mon Sep 17 00:00:00 2001 From: Kevin Jahns Date: Tue, 22 Dec 2020 17:04:31 +0100 Subject: [PATCH 01/21] deprecate toJSON --- src/utils/Doc.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/utils/Doc.js b/src/utils/Doc.js index bec8966b..b18ea09e 100644 --- a/src/utils/Doc.js +++ b/src/utils/Doc.js @@ -217,6 +217,9 @@ export class Doc extends Observable { /** * Converts the entire document into a js object, recursively traversing each yjs type + * Doesn't log types that have not been defined (using ydoc.getType(..)). + * + * @deprecated Do not use this method and rather call toJSON directly on the shared types. * * @return {Object} */ From 7c0b98bbb27dd01d301582706d0c720ad38daae8 Mon Sep 17 00:00:00 2001 From: Kevin Jahns Date: Tue, 22 Dec 2020 17:05:36 +0100 Subject: [PATCH 02/21] lint --- README.md | 3 ++- funding.cjs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index eca608ec..2e2b1833 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,8 @@ Sponsorship also comes with special perks! [![Become a Sponsor](https://img.shie collaboratively organize radio broadcasts. * [Cattaz](http://cattaz.io/) A wiki that can run custom applications in the wiki pages. -* [Alldone](https://alldoneapp.com/) A next-gen project management and collaboration platform. +* [Alldone](https://alldoneapp.com/) A next-gen project management and + collaboration platform. ## Table of Contents diff --git a/funding.cjs b/funding.cjs index 66083e5b..aaf7d47f 100644 --- a/funding.cjs +++ b/funding.cjs @@ -7,4 +7,4 @@ log.print( log.GREY, 'The project has grown considerably in the past year. Too much for me to maintain\nin my spare time. Several companies built their products with Yjs.\nYet, this project receives very little funding. Yjs is far from done. I want to\ncreate more awesome extensions and work on the growing number of open issues.\n', log.BOLD, 'Dear user, the future of this project entirely depends on you.\n') log.print(log.BLUE, log.BOLD, 'Please start funding the project now: https://github.com/sponsors/dmonad \n') -log.print(log.GREY, '(This message will be removed when I achieved my funding goal)\n\n') \ No newline at end of file +log.print(log.GREY, '(This message will be removed when I achieved my funding goal)\n\n') From 6bc9c220b9bfd9c074172115bbc2c8b24c3f6284 Mon Sep 17 00:00:00 2001 From: Kevin Jahns Date: Tue, 22 Dec 2020 17:12:46 +0100 Subject: [PATCH 03/21] add funding to package.json --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 3b265715..385b9523 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,8 @@ "dist/*", "src/*", "tests/*", - "docs/*" + "docs/*", + "./funding.cjs" ], "dictionaries": { "doc": "docs", From bfacd2e63a8b4f1dac8fd4ea1a992d9faf75fdac Mon Sep 17 00:00:00 2001 From: Kevin Jahns Date: Tue, 22 Dec 2020 17:15:30 +0100 Subject: [PATCH 04/21] 13.4.8 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index ccecef0c..c26a038b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "yjs", - "version": "13.4.7", + "version": "13.4.8", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 385b9523..10e5ae2d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "yjs", - "version": "13.4.7", + "version": "13.4.8", "description": "Shared Editing Library", "main": "./dist/yjs.cjs", "module": "./dist/yjs.mjs", From fd59696b9ab92611f42e020d49248d40d6571e60 Mon Sep 17 00:00:00 2001 From: Kevin Jahns Date: Tue, 22 Dec 2020 17:21:07 +0100 Subject: [PATCH 05/21] change funding url format --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 10e5ae2d..ea228fe0 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "src/*", "tests/*", "docs/*", - "./funding.cjs" + "funding.cjs" ], "dictionaries": { "doc": "docs", From 728bb6f1b24449db57aa4f633d6771735f4a2573 Mon Sep 17 00:00:00 2001 From: Kevin Jahns Date: Tue, 22 Dec 2020 17:23:25 +0100 Subject: [PATCH 06/21] 13.4.9 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index c26a038b..ff425612 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "yjs", - "version": "13.4.8", + "version": "13.4.9", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index ea228fe0..2b5a91a4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "yjs", - "version": "13.4.8", + "version": "13.4.9", "description": "Shared Editing Library", "main": "./dist/yjs.cjs", "module": "./dist/yjs.mjs", From 656328631ccb12bbdaf6bcb54639846c0e672bee Mon Sep 17 00:00:00 2001 From: Kevin Jahns Date: Fri, 8 Jan 2021 23:03:16 +0100 Subject: [PATCH 07/21] first prototype of associative relative positions (left- or right-associative) --- src/index.js | 2 -- src/utils/RelativePosition.js | 68 ++++++++++++++++++++++++++--------- tests/index.js | 3 +- 3 files changed, 54 insertions(+), 19 deletions(-) diff --git a/src/index.js b/src/index.js index 3daecee2..ea40e25a 100644 --- a/src/index.js +++ b/src/index.js @@ -32,8 +32,6 @@ export { createRelativePositionFromJSON, createAbsolutePositionFromRelativePosition, compareRelativePositions, - writeRelativePosition, - readRelativePosition, ID, createID, compareIDs, diff --git a/src/utils/RelativePosition.js b/src/utils/RelativePosition.js index dc435359..a1e78c08 100644 --- a/src/utils/RelativePosition.js +++ b/src/utils/RelativePosition.js @@ -45,8 +45,9 @@ export class RelativePosition { * @param {ID|null} type * @param {string|null} tname * @param {ID|null} item + * @param {number} assoc */ - constructor (type, tname, item) { + constructor (type, tname, item, assoc = 0) { /** * @type {ID|null} */ @@ -59,6 +60,18 @@ export class RelativePosition { * @type {ID | null} */ this.item = item + /** + * A relative position is associated to a specific character. By default + * assoc >= 0, the relative position is associated to the character + * after the meant position. + * I.e. position 1 in 'ab' is associated to character 'b'. + * + * If assoc < 0, then the relative position is associated to the caharacter + * before the meant position. + * + * @type {number} + */ + this.assoc = assoc } } @@ -74,8 +87,9 @@ export class AbsolutePosition { /** * @param {AbstractType} type * @param {number} index + * @param {number} [assoc] */ - constructor (type, index) { + constructor (type, index, assoc = 0) { /** * @type {AbstractType} */ @@ -84,24 +98,27 @@ export class AbsolutePosition { * @type {number} */ this.index = index + this.assoc = assoc } } /** * @param {AbstractType} type * @param {number} index + * @param {number} [assoc] * * @function */ -export const createAbsolutePosition = (type, index) => new AbsolutePosition(type, index) +export const createAbsolutePosition = (type, index, assoc = 0) => new AbsolutePosition(type, index, assoc) /** * @param {AbstractType} type * @param {ID|null} item + * @param {number} [assoc] * * @function */ -export const createRelativePosition = (type, item) => { +export const createRelativePosition = (type, item, assoc) => { let typeid = null let tname = null if (type._item === null) { @@ -109,7 +126,7 @@ export const createRelativePosition = (type, item) => { } else { typeid = createID(type._item.id.client, type._item.id.clock) } - return new RelativePosition(typeid, tname, item) + return new RelativePosition(typeid, tname, item, assoc) } /** @@ -117,23 +134,35 @@ export const createRelativePosition = (type, item) => { * * @param {AbstractType} type The base type (e.g. YText or YArray). * @param {number} index The absolute position. + * @param {number} [assoc] * @return {RelativePosition} * * @function */ -export const createRelativePositionFromTypeIndex = (type, index) => { +export const createRelativePositionFromTypeIndex = (type, index, assoc = 0) => { let t = type._start + if (assoc < 0) { + // associated to the left character or the beginning of a type, increment index if possible. + if (index === 0) { + return createRelativePosition(type, null, assoc) + } + index++ + } while (t !== null) { if (!t.deleted && t.countable) { if (t.length > index) { // case 1: found position somewhere in the linked list - return createRelativePosition(type, createID(t.id.client, t.id.clock + index)) + return createRelativePosition(type, createID(t.id.client, t.id.clock + index), assoc) } index -= t.length } + if (t.right === null && assoc < 0) { + // left-associated position, return last available id + return createRelativePosition(type, t.lastId, assoc) + } t = t.right } - return createRelativePosition(type, null) + return createRelativePosition(type, null, assoc) } /** @@ -143,7 +172,7 @@ export const createRelativePositionFromTypeIndex = (type, index) => { * @function */ export const writeRelativePosition = (encoder, rpos) => { - const { type, tname, item } = rpos + const { type, tname, item, assoc } = rpos if (item !== null) { encoding.writeVarUint(encoder, 0) writeID(encoder, item) @@ -158,6 +187,7 @@ export const writeRelativePosition = (encoder, rpos) => { } else { throw error.unexpectedCase() } + encoding.writeVarInt(encoder, assoc) return encoder } @@ -173,7 +203,7 @@ export const encodeRelativePosition = rpos => { /** * @param {decoding.Decoder} decoder - * @return {RelativePosition|null} + * @return {RelativePosition} * * @function */ @@ -195,12 +225,13 @@ export const readRelativePosition = decoder => { type = readID(decoder) } } - return new RelativePosition(type, tname, itemID) + const assoc = decoding.hasContent(decoder) ? decoding.readVarInt(decoder) : 0 + return new RelativePosition(type, tname, itemID, assoc) } /** * @param {Uint8Array} uint8Array - * @return {RelativePosition|null} + * @return {RelativePosition} */ export const decodeRelativePosition = uint8Array => readRelativePosition(decoding.createDecoder(uint8Array)) @@ -216,6 +247,7 @@ export const createAbsolutePositionFromRelativePosition = (rpos, doc) => { const rightID = rpos.item const typeID = rpos.type const tname = rpos.tname + const assoc = rpos.assoc let type = null let index = 0 if (rightID !== null) { @@ -229,7 +261,7 @@ export const createAbsolutePositionFromRelativePosition = (rpos, doc) => { } type = /** @type {AbstractType} */ (right.parent) if (type._item === null || !type._item.deleted) { - index = right.deleted || !right.countable ? 0 : res.diff + index = (right.deleted || !right.countable) ? 0 : (res.diff + (assoc >= 0 ? 0 : 1)) // adjust position based on left association if necessary let n = right.left while (n !== null) { if (!n.deleted && n.countable) { @@ -256,9 +288,13 @@ export const createAbsolutePositionFromRelativePosition = (rpos, doc) => { } else { throw error.unexpectedCase() } - index = type._length + if (assoc >= 0) { + index = type._length + } else { + index = 0 + } } - return createAbsolutePosition(type, index) + return createAbsolutePosition(type, index, rpos.assoc) } /** @@ -269,5 +305,5 @@ export const createAbsolutePositionFromRelativePosition = (rpos, doc) => { * @function */ export const compareRelativePositions = (a, b) => a === b || ( - a !== null && b !== null && a.tname === b.tname && compareIDs(a.item, b.item) && compareIDs(a.type, b.type) + a !== null && b !== null && a.tname === b.tname && compareIDs(a.item, b.item) && compareIDs(a.type, b.type) && a.assoc === b.assoc ) diff --git a/tests/index.js b/tests/index.js index aec3ae5a..df701f20 100644 --- a/tests/index.js +++ b/tests/index.js @@ -8,6 +8,7 @@ import * as undoredo from './undo-redo.tests.js' import * as compatibility from './compatibility.tests.js' import * as doc from './doc.tests.js' import * as snapshot from './snapshot.tests.js' +import * as relativePositions from './relativePositions.tests.js' import { runTests } from 'lib0/testing.js' import { isBrowser, isNode } from 'lib0/environment.js' @@ -17,7 +18,7 @@ if (isBrowser) { log.createVConsole(document.body) } runTests({ - doc, map, array, text, xml, encoding, undoredo, compatibility, snapshot + doc, map, array, text, xml, encoding, undoredo, compatibility, snapshot, relativePositions }).then(success => { /* istanbul ignore next */ if (isNode) { From 32b734b24d43919224dec978117760219f34229a Mon Sep 17 00:00:00 2001 From: Kevin Jahns Date: Fri, 8 Jan 2021 23:03:44 +0100 Subject: [PATCH 08/21] add tests --- tests/relativePositions.tests.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 tests/relativePositions.tests.js diff --git a/tests/relativePositions.tests.js b/tests/relativePositions.tests.js new file mode 100644 index 00000000..55f27ab1 --- /dev/null +++ b/tests/relativePositions.tests.js @@ -0,0 +1,29 @@ + +import * as Y from '../src/internals' +import * as t from 'lib0/testing.js' + +/** + * @param {t.TestCase} tc + */ +export const testRelativePosition = tc => { + const ydoc = new Y.Doc() + const ytext = ydoc.getText() + ytext.insert(0, '1') + ytext.insert(0, 'abc') + ytext.insert(0, 'z') + ytext.insert(0, 'y') + ytext.insert(0, 'x') + + // test if all positions are encoded and restored correctly + for (let i = 0; i < ytext.length; i++) { + // for all types of associations.. + for (let assoc = -1; assoc < 2; assoc++) { + const rpos = Y.createRelativePositionFromTypeIndex(ytext, i, assoc) + const encodedRpos = Y.encodeRelativePosition(rpos) + const decodedRpos = Y.decodeRelativePosition(encodedRpos) + const absPos = /** @type {Y.AbsolutePosition} */ (Y.createAbsolutePositionFromRelativePosition(decodedRpos, ydoc)) + t.assert(absPos.index === i) + t.assert(absPos.assoc === assoc) + } + } +} From edc1f9418f422cf83ad2c56d52595f9c473dfb22 Mon Sep 17 00:00:00 2001 From: Kevin Jahns Date: Sat, 9 Jan 2021 14:45:51 +0100 Subject: [PATCH 09/21] reproduce #271 --- tests/y-text.tests.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/y-text.tests.js b/tests/y-text.tests.js index 62964520..3bd88365 100644 --- a/tests/y-text.tests.js +++ b/tests/y-text.tests.js @@ -78,6 +78,29 @@ export const testBasicFormat = tc => { compare(users) } +/** + * @param {t.TestCase} tc + */ +export const testMultilineFormat = tc => { + const ydoc = new Y.Doc() + const testText = ydoc.getText('test') + testText.insert(0, 'Test\nMulti-line\nFormatting') + testText.applyDelta([ + { retain: 4, attributes: { bold: true } }, + { retain: 1 }, // newline character + { retain: 10, attributes: { bold: true } }, + { retain: 1 }, // newline character + { retain: 10, attributes: { bold: true } } + ]) + t.compare(testText.toDelta(), [ + { insert: 'Test', attributes: { bold: true } }, + { insert: '\n' }, + { insert: 'Multi-line', attributes: { bold: true } }, + { insert: '\n' }, + { insert: 'Formatting', attributes: { bold: true } } + ]) +} + /** * @param {t.TestCase} tc */ @@ -286,7 +309,9 @@ export const testBestCase = tc => { } const tryGc = () => { + // @ts-ignore if (typeof global !== 'undefined' && global.gc) { + // @ts-ignore global.gc() } } From 186f7140b622aeda4b4a924dc9323513b2ca13c6 Mon Sep 17 00:00:00 2001 From: Kevin Jahns Date: Sat, 9 Jan 2021 14:55:08 +0100 Subject: [PATCH 10/21] fix #271 - multiline text formatting issue --- src/types/YText.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/types/YText.js b/src/types/YText.js index a12d0747..dfd525e9 100644 --- a/src/types/YText.js +++ b/src/types/YText.js @@ -169,6 +169,7 @@ const insertNegatedAttributes = (transaction, parent, currPos, negatedAttributes negatedAttributes.forEach((val, key) => { left = new Item(createID(ownClientId, getState(doc.store, ownClientId)), left, left && left.lastId, right, right && right.id, parent, null, new ContentFormat(key, val)) left.integrate(transaction, 0) + currPos.currentAttributes.set(key, val) }) } From 8086a4f816eff36bc69880c091aeec21da0790af Mon Sep 17 00:00:00 2001 From: Kevin Jahns Date: Sat, 9 Jan 2021 14:58:21 +0100 Subject: [PATCH 11/21] 13.4.10 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index ff425612..57a94b0f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "yjs", - "version": "13.4.9", + "version": "13.4.10", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 2b5a91a4..e9cab969 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "yjs", - "version": "13.4.9", + "version": "13.4.10", "description": "Shared Editing Library", "main": "./dist/yjs.cjs", "module": "./dist/yjs.mjs", From ca667be68b7e034867ca03f01f4e3f7bd9eccb03 Mon Sep 17 00:00:00 2001 From: Kevin Jahns Date: Sat, 9 Jan 2021 14:59:56 +0100 Subject: [PATCH 12/21] proper updating of text-attributes --- src/types/YText.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/types/YText.js b/src/types/YText.js index dfd525e9..b5694507 100644 --- a/src/types/YText.js +++ b/src/types/YText.js @@ -170,6 +170,7 @@ const insertNegatedAttributes = (transaction, parent, currPos, negatedAttributes left = new Item(createID(ownClientId, getState(doc.store, ownClientId)), left, left && left.lastId, right, right && right.id, parent, null, new ContentFormat(key, val)) left.integrate(transaction, 0) currPos.currentAttributes.set(key, val) + updateCurrentAttributes(currPos.currentAttributes, /** @type {ContentFormat} */ (left.content)) }) } From 97d97147105043de8232f71f80447eba920347cb Mon Sep 17 00:00:00 2001 From: Kevin Jahns Date: Sat, 9 Jan 2021 15:01:52 +0100 Subject: [PATCH 13/21] 13.4.11 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 57a94b0f..9b44bba9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "yjs", - "version": "13.4.10", + "version": "13.4.11", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index e9cab969..c1c1f919 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "yjs", - "version": "13.4.10", + "version": "13.4.11", "description": "Shared Editing Library", "main": "./dist/yjs.cjs", "module": "./dist/yjs.mjs", From 4af04d6a29b9be97d26dc29666963f785c07a7c6 Mon Sep 17 00:00:00 2001 From: Kevin Jahns Date: Sun, 10 Jan 2021 00:01:56 +0100 Subject: [PATCH 14/21] fix associative relative positions --- src/utils/RelativePosition.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/RelativePosition.js b/src/utils/RelativePosition.js index a1e78c08..9f50e591 100644 --- a/src/utils/RelativePosition.js +++ b/src/utils/RelativePosition.js @@ -146,7 +146,7 @@ export const createRelativePositionFromTypeIndex = (type, index, assoc = 0) => { if (index === 0) { return createRelativePosition(type, null, assoc) } - index++ + index-- } while (t !== null) { if (!t.deleted && t.countable) { From 6f074a873db81f4211633e277992dd5d55ca2230 Mon Sep 17 00:00:00 2001 From: Kevin Jahns Date: Sun, 10 Jan 2021 00:16:18 +0100 Subject: [PATCH 15/21] add bunch of tests for relative positions --- tests/relativePositions.tests.js | 97 ++++++++++++++++++++++++++++---- 1 file changed, 86 insertions(+), 11 deletions(-) diff --git a/tests/relativePositions.tests.js b/tests/relativePositions.tests.js index 55f27ab1..15b63c47 100644 --- a/tests/relativePositions.tests.js +++ b/tests/relativePositions.tests.js @@ -3,17 +3,9 @@ import * as Y from '../src/internals' import * as t from 'lib0/testing.js' /** - * @param {t.TestCase} tc + * @param {Y.YText} ytext */ -export const testRelativePosition = tc => { - const ydoc = new Y.Doc() - const ytext = ydoc.getText() - ytext.insert(0, '1') - ytext.insert(0, 'abc') - ytext.insert(0, 'z') - ytext.insert(0, 'y') - ytext.insert(0, 'x') - +const checkRelativePositions = ytext => { // test if all positions are encoded and restored correctly for (let i = 0; i < ytext.length; i++) { // for all types of associations.. @@ -21,9 +13,92 @@ export const testRelativePosition = tc => { const rpos = Y.createRelativePositionFromTypeIndex(ytext, i, assoc) const encodedRpos = Y.encodeRelativePosition(rpos) const decodedRpos = Y.decodeRelativePosition(encodedRpos) - const absPos = /** @type {Y.AbsolutePosition} */ (Y.createAbsolutePositionFromRelativePosition(decodedRpos, ydoc)) + const absPos = /** @type {Y.AbsolutePosition} */ (Y.createAbsolutePositionFromRelativePosition(decodedRpos, /** @type {Y.Doc} */ (ytext.doc))) t.assert(absPos.index === i) t.assert(absPos.assoc === assoc) } } } + +/** + * @param {t.TestCase} tc + */ +export const testRelativePositionCase1 = tc => { + const ydoc = new Y.Doc() + const ytext = ydoc.getText() + ytext.insert(0, '1') + ytext.insert(0, 'abc') + ytext.insert(0, 'z') + ytext.insert(0, 'y') + ytext.insert(0, 'x') + checkRelativePositions(ytext) +} + +/** + * @param {t.TestCase} tc + */ +export const testRelativePositionCase2 = tc => { + const ydoc = new Y.Doc() + const ytext = ydoc.getText() + ytext.insert(0, 'abc') + checkRelativePositions(ytext) +} + +/** + * @param {t.TestCase} tc + */ +export const testRelativePositionCase3 = tc => { + const ydoc = new Y.Doc() + const ytext = ydoc.getText() + ytext.insert(0, 'abc') + ytext.insert(0, '1') + ytext.insert(0, 'xyz') + checkRelativePositions(ytext) +} + +/** + * @param {t.TestCase} tc + */ +export const testRelativePositionCase4 = tc => { + const ydoc = new Y.Doc() + const ytext = ydoc.getText() + ytext.insert(0, '1') + checkRelativePositions(ytext) +} + +/** + * @param {t.TestCase} tc + */ +export const testRelativePositionCase5 = tc => { + const ydoc = new Y.Doc() + const ytext = ydoc.getText() + ytext.insert(0, '2') + ytext.insert(0, '1') + checkRelativePositions(ytext) +} + +/** + * @param {t.TestCase} tc + */ +export const testRelativePositionCase6 = tc => { + const ydoc = new Y.Doc() + const ytext = ydoc.getText() + checkRelativePositions(ytext) +} + +/** + * @param {t.TestCase} tc + */ +export const testRelativePositionAssociationDifference = tc => { + const ydoc = new Y.Doc() + const ytext = ydoc.getText() + ytext.insert(0, '2') + ytext.insert(0, '1') + const rposRight = Y.createRelativePositionFromTypeIndex(ytext, 1, 0) + const rposLeft = Y.createRelativePositionFromTypeIndex(ytext, 1, -1) + ytext.insert(1, 'x') + const posRight = Y.createAbsolutePositionFromRelativePosition(rposRight, ydoc) + const posLeft = Y.createAbsolutePositionFromRelativePosition(rposLeft, ydoc) + t.assert(posRight != null && posRight.index === 2) + t.assert(posLeft != null && posLeft.index === 1) +} From c28ad0608ec93895d621a463f44bc772688e01b2 Mon Sep 17 00:00:00 2001 From: Kevin Jahns Date: Sun, 10 Jan 2021 12:19:44 +0100 Subject: [PATCH 16/21] emit transaction on update call --- src/utils/Transaction.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils/Transaction.js b/src/utils/Transaction.js index 4a1746ac..10867038 100644 --- a/src/utils/Transaction.js +++ b/src/utils/Transaction.js @@ -340,14 +340,14 @@ const cleanupTransactions = (transactionCleanups, i) => { const encoder = new DefaultUpdateEncoder() const hasContent = writeUpdateMessageFromTransaction(encoder, transaction) if (hasContent) { - doc.emit('update', [encoder.toUint8Array(), transaction.origin, doc]) + doc.emit('update', [encoder.toUint8Array(), transaction.origin, doc, transaction]) } } if (doc._observers.has('updateV2')) { const encoder = new UpdateEncoderV2() const hasContent = writeUpdateMessageFromTransaction(encoder, transaction) if (hasContent) { - doc.emit('updateV2', [encoder.toUint8Array(), transaction.origin, doc]) + doc.emit('updateV2', [encoder.toUint8Array(), transaction.origin, doc, transaction]) } } transaction.subdocsAdded.forEach(subdoc => doc.subdocs.add(subdoc)) From 1e97cf832318b389e62593b248ed6d0457b2b5e2 Mon Sep 17 00:00:00 2001 From: Kevin Jahns Date: Sun, 10 Jan 2021 12:27:37 +0100 Subject: [PATCH 17/21] bump dependencies & update npm website --- package-lock.json | 200 ++++++++++++++++++++++++++++------------------ package.json | 15 ++-- 2 files changed, 128 insertions(+), 87 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9b44bba9..69ef1084 100644 --- a/package-lock.json +++ b/package-lock.json @@ -31,59 +31,95 @@ } }, "@babel/parser": { - "version": "7.11.5", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.11.5.tgz", - "integrity": "sha512-X9rD8qqm695vgmeaQ4fvz/o3+Wk4ZzQvSHkDBgpYKxpD4qTAUm88ZKtHkVqIOsYFFbIQ6wQYhC6q7pjqVK0E0Q==", + "version": "7.12.11", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.12.11.tgz", + "integrity": "sha512-N3UxG+uuF4CMYoNj8AhnbAcJF0PiuJ9KHuy1lQmkYsxTer/MAH9UBNHsBoAX/4s6NvlDD047No8mYVGGzLL4hg==", "dev": true }, "@rollup/plugin-commonjs": { - "version": "11.1.0", - "resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-11.1.0.tgz", - "integrity": "sha512-Ycr12N3ZPN96Fw2STurD21jMqzKwL9QuFhms3SD7KKRK7oaXUsBU9Zt0jL/rOPHiPYisI21/rXGO3jr9BnLHUA==", + "version": "17.0.0", + "resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-17.0.0.tgz", + "integrity": "sha512-/omBIJG1nHQc+bgkYDuLpb/V08QyutP9amOrJRUSlYJZP+b/68gM//D8sxJe3Yry2QnYIr3QjR3x4AlxJEN3GA==", "dev": true, "requires": { - "@rollup/pluginutils": "^3.0.8", + "@rollup/pluginutils": "^3.1.0", "commondir": "^1.0.1", - "estree-walker": "^1.0.1", - "glob": "^7.1.2", - "is-reference": "^1.1.2", - "magic-string": "^0.25.2", - "resolve": "^1.11.0" + "estree-walker": "^2.0.1", + "glob": "^7.1.6", + "is-reference": "^1.2.1", + "magic-string": "^0.25.7", + "resolve": "^1.17.0" + }, + "dependencies": { + "glob": { + "version": "7.1.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", + "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "resolve": { + "version": "1.19.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.19.0.tgz", + "integrity": "sha512-rArEXAgsBG4UgRGcynxWIWKFvh/XZCcS8UJdHhwy91zwAvCZIbcs+vAbflgBnNjYMs/i/i+/Ux6IZhML1yPvxg==", + "dev": true, + "requires": { + "is-core-module": "^2.1.0", + "path-parse": "^1.0.6" + } + } } }, "@rollup/plugin-node-resolve": { - "version": "7.1.3", - "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-7.1.3.tgz", - "integrity": "sha512-RxtSL3XmdTAE2byxekYLnx+98kEUOrPHF/KRVjLH+DEIHy6kjIw7YINQzn+NXiH/NTrQLAwYs0GWB+csWygA9Q==", + "version": "11.0.1", + "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-11.0.1.tgz", + "integrity": "sha512-ltlsj/4Bhwwhb+Nb5xCz/6vieuEj2/BAkkqVIKmZwC7pIdl8srmgmglE4S0jFlZa32K4qvdQ6NHdmpRKD/LwoQ==", "dev": true, "requires": { - "@rollup/pluginutils": "^3.0.8", - "@types/resolve": "0.0.8", + "@rollup/pluginutils": "^3.1.0", + "@types/resolve": "1.17.1", "builtin-modules": "^3.1.0", + "deepmerge": "^4.2.2", "is-module": "^1.0.0", - "resolve": "^1.14.2" + "resolve": "^1.19.0" }, "dependencies": { "resolve": { - "version": "1.17.0", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.17.0.tgz", - "integrity": "sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w==", + "version": "1.19.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.19.0.tgz", + "integrity": "sha512-rArEXAgsBG4UgRGcynxWIWKFvh/XZCcS8UJdHhwy91zwAvCZIbcs+vAbflgBnNjYMs/i/i+/Ux6IZhML1yPvxg==", "dev": true, "requires": { + "is-core-module": "^2.1.0", "path-parse": "^1.0.6" } } } }, "@rollup/pluginutils": { - "version": "3.0.10", - "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-3.0.10.tgz", - "integrity": "sha512-d44M7t+PjmMrASHbhgpSbVgtL6EFyX7J4mYxwQ/c5eoaE6N2VgCgEcWVzNnwycIloti+/MpwFr8qfw+nRw00sw==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-3.1.0.tgz", + "integrity": "sha512-GksZ6pr6TpIjHm8h9lSQ8pi8BE9VeubNT0OMJ3B5uZJ8pz73NPiqOtCog/x2/QzM1ENChPKxMDhiQuRHsqc+lg==", "dev": true, "requires": { "@types/estree": "0.0.39", "estree-walker": "^1.0.1", "picomatch": "^2.2.2" + }, + "dependencies": { + "estree-walker": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-1.0.1.tgz", + "integrity": "sha512-1fMXF3YP4pZZVozF8j/ZLfvnR8NSIljt56UhbZ5PeeDmmGHpgpdwQt7ITlGvYaQukCvuBRMLEiKiYC+oeIg4cg==", + "dev": true + } } }, "@types/color-name": { @@ -99,15 +135,15 @@ "dev": true }, "@types/node": { - "version": "14.0.9", - "resolved": "https://registry.npmjs.org/@types/node/-/node-14.0.9.tgz", - "integrity": "sha512-0sCTiXKXELOBxvZLN4krQ0FPOAA7ij+6WwvD0k/PHd9/KAkr4dXel5J9fh6F4x1FwAQILqAWkmpeuS6mjf1iKA==", + "version": "14.14.20", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.20.tgz", + "integrity": "sha512-Y93R97Ouif9JEOWPIUyU+eyIdyRqQR0I8Ez1dzku4hDx34NWh4HbtIc3WNzwB1Y9ULvNGeu5B8h8bVL5cAk4/A==", "dev": true }, "@types/resolve": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-0.0.8.tgz", - "integrity": "sha512-auApPaJf3NPfe18hSoJkp8EbZzer2ISk7o8mCC3M9he/a04+gbMF97NkpD2S8riMGvm4BMRI59/SZQSaLTKpsQ==", + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.17.1.tgz", + "integrity": "sha512-yy7HuzQhj0dhGpD8RLXSZWEkLsV9ibvxvi6EiJ3bkqLAO1RGo0WbkWQiwpRlSFymTJRz0d3k5LM3kkx8ArDbLw==", "dev": true, "requires": { "@types/node": "*" @@ -239,9 +275,9 @@ } }, "builtin-modules": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.1.0.tgz", - "integrity": "sha512-k0KL0aWZuBt2lrxrcASWDfwOLMnodeQjodT/1SxEQAXsHANgo6ZC/VEaSEHCXt7aSTZ4/4H5LKa+tBXmW7Vtvw==", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.2.0.tgz", + "integrity": "sha512-lGzLKcioL90C7wMczpkY0n/oART3MbBa8R9OFGE1rJxoVI86u4WAGfEk8Wjv10eKSyTHVGkSo3bvBylCEtk7LA==", "dev": true }, "callsites": { @@ -458,6 +494,12 @@ "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=", "dev": true }, + "deepmerge": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.2.2.tgz", + "integrity": "sha512-FJ3UgI4gIl+PHZm53knsuSFpE+nESMr7M4v9QcgB7S63Kj/6WqMiFQJpBBYz1Pt+66bZpP3Q7Lye0Oo9MPKEdg==", + "dev": true + }, "define-properties": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", @@ -946,9 +988,9 @@ "dev": true }, "estree-walker": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-1.0.1.tgz", - "integrity": "sha512-1fMXF3YP4pZZVozF8j/ZLfvnR8NSIljt56UhbZ5PeeDmmGHpgpdwQt7ITlGvYaQukCvuBRMLEiKiYC+oeIg4cg==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz", + "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==", "dev": true }, "esutils": { @@ -1057,6 +1099,13 @@ "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", "dev": true }, + "fsevents": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.1.3.tgz", + "integrity": "sha512-Auw9a4AxqWpa9GUfj370BMPzzyncfBABW8Mab7BGWBYDj4Isgq+cDKtx0i6u9jcX9pQDnswsaaOTgTmA5pEjuQ==", + "dev": true, + "optional": true + }, "function-bind": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", @@ -1243,9 +1292,9 @@ "dev": true }, "ini": { - "version": "1.3.5", - "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", - "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", + "version": "1.3.8", + "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz", + "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==", "dev": true }, "inquirer": { @@ -1342,6 +1391,15 @@ "integrity": "sha512-pyVD9AaGLxtg6srb2Ng6ynWJqkHU9bEM087AKck0w8QwDarTfNcpIYoU8x8Hv2Icm8u6kFJM18Dag8lyqGkviw==", "dev": true }, + "is-core-module": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.2.0.tgz", + "integrity": "sha512-XRAfAdyyY5F5cOXn7hYQDqh2Xmii+DEfIcQGxK/uNwMHhIkPWO0g8msXcbzLe+MpGoR951MlqM/2iIlU4vKDdQ==", + "dev": true, + "requires": { + "has": "^1.0.3" + } + }, "is-date-object": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.2.tgz", @@ -1376,20 +1434,12 @@ "dev": true }, "is-reference": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/is-reference/-/is-reference-1.2.0.tgz", - "integrity": "sha512-ZVxq+5TkOx6GQdnoMm2aRdCKADdcrOWXLGzGT+vIA8DMpqEJaRk5AL1bS80zJ2bjHunVmjdzfCt0e4BymIEqKQ==", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/is-reference/-/is-reference-1.2.1.tgz", + "integrity": "sha512-U82MsXXiFIrjCK4otLT+o2NA2Cd2g5MLoOVXUZjIOhLurrRxpEXzI8O0KZHr3IjLvlAH1kTPYSuqer5T9ZVBKQ==", "dev": true, "requires": { - "@types/estree": "0.0.44" - }, - "dependencies": { - "@types/estree": { - "version": "0.0.44", - "resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.44.tgz", - "integrity": "sha512-iaIVzr+w2ZJ5HkidlZ3EJM8VTZb2MJLCjw3V+505yVts0gRC4UMvjw0d1HPtGqI/HQC/KdsYtayfzl+AXY2R8g==", - "dev": true - } + "@types/estree": "*" } }, "is-regex": { @@ -1429,9 +1479,9 @@ "dev": true }, "isomorphic.js": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/isomorphic.js/-/isomorphic.js-0.1.4.tgz", - "integrity": "sha512-t9zbgkjE7f9f2M6OSW49YEq0lUrSdAllBbWFUZoeck/rnnFae6UlhmDtXWs48VJY3ZpryCoZsRiAiKD44hPIGQ==" + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/isomorphic.js/-/isomorphic.js-0.1.5.tgz", + "integrity": "sha512-MkX5lLQApx/8IAIU31PKvpAZosnu2Jqcj1rM8TzxyA4CR96tv3SgMKQNTCxL58G7696Q57zd7ubHV/hTg+5fNA==" }, "js-tokens": { "version": "4.0.0", @@ -1459,9 +1509,9 @@ } }, "jsdoc": { - "version": "3.6.5", - "resolved": "https://registry.npmjs.org/jsdoc/-/jsdoc-3.6.5.tgz", - "integrity": "sha512-SbY+i9ONuxSK35cgVHaI8O9senTE4CDYAmGSDJ5l3+sfe62Ff4gy96osy6OW84t4K4A8iGnMrlRrsSItSNp3RQ==", + "version": "3.6.6", + "resolved": "https://registry.npmjs.org/jsdoc/-/jsdoc-3.6.6.tgz", + "integrity": "sha512-znR99e1BHeyEkSvgDDpX0sTiTu+8aQyDl9DawrkOGZTTW8hv0deIFXx87114zJ7gRaDZKVQD/4tr1ifmJp9xhQ==", "dev": true, "requires": { "@babel/parser": "^7.9.4", @@ -1548,9 +1598,9 @@ } }, "lib0": { - "version": "0.2.33", - "resolved": "https://registry.npmjs.org/lib0/-/lib0-0.2.33.tgz", - "integrity": "sha512-Pnm8FzjUr+aTYkEu2A20c1EfVHla8GbVX+GXn6poxx0gcmEuCs+XszjLmtEbI9xYOoI/83xVi7VOIoyHgOO87w==", + "version": "0.2.35", + "resolved": "https://registry.npmjs.org/lib0/-/lib0-0.2.35.tgz", + "integrity": "sha512-drVD3EscB3TIxiFzceuZg7oF5Z6I8a0KX+7FowNcAXOEsTej/hlHB+ElJ8Pa/Ge73Gy3fklSJtPxpNd2PajdWg==", "requires": { "isomorphic.js": "^0.1.3" } @@ -1587,9 +1637,9 @@ } }, "lodash": { - "version": "4.17.15", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", - "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==", + "version": "4.17.20", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.20.tgz", + "integrity": "sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==", "dev": true }, "lodash.assignin": { @@ -2380,22 +2430,14 @@ } }, "rollup": { - "version": "1.32.1", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-1.32.1.tgz", - "integrity": "sha512-/2HA0Ec70TvQnXdzynFffkjA6XN+1e2pEv/uKS5Ulca40g2L7KuOE3riasHoNVHOsFD5KKZgDsMk1CP3Tw9s+A==", + "version": "2.36.1", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.36.1.tgz", + "integrity": "sha512-eAfqho8dyzuVvrGqpR0ITgEdq0zG2QJeWYh+HeuTbpcaXk8vNFc48B7bJa1xYosTCKx0CuW+447oQOW8HgBIZQ==", "dev": true, "requires": { - "@types/estree": "*", - "@types/node": "*", - "acorn": "^7.1.0" + "fsevents": "~2.1.2" } }, - "rollup-cli": { - "version": "1.0.9", - "resolved": "https://registry.npmjs.org/rollup-cli/-/rollup-cli-1.0.9.tgz", - "integrity": "sha1-N/ShwgYxHikuMpfql3eduKIduZQ=", - "dev": true - }, "run-async": { "version": "2.4.1", "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.4.1.tgz", @@ -2898,12 +2940,12 @@ "dev": true }, "y-protocols": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/y-protocols/-/y-protocols-0.2.3.tgz", - "integrity": "sha512-mJ838iW7XgMQqlv+9DtH7QyLqflZoy/VvaUWRIpwawee4mQiFJcEXazCmSYUHEbXIUuVNNc70FnuNSMWDC5vKQ==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/y-protocols/-/y-protocols-1.0.2.tgz", + "integrity": "sha512-V6ZAmokdogW52+VsIg/YC0R6CHWgG8/hjO3rYL10hAzeT5j464kDiRki31O+GzTj+dMgNYZNd6IDP9X35FLXrw==", "dev": true, "requires": { - "lib0": "^0.2.20" + "lib0": "^0.2.35" } } } diff --git a/package.json b/package.json index c1c1f919..a82eca65 100644 --- a/package.json +++ b/package.json @@ -61,22 +61,21 @@ "bugs": { "url": "https://github.com/yjs/yjs/issues" }, - "homepage": "https://yjs.dev", + "homepage": "https://docs.yjs.dev", "dependencies": { - "lib0": "^0.2.33" + "lib0": "^0.2.35" }, "devDependencies": { - "@rollup/plugin-commonjs": "^11.1.0", - "@rollup/plugin-node-resolve": "^7.1.3", + "@rollup/plugin-commonjs": "^17.0.0", + "@rollup/plugin-node-resolve": "^11.0.1", "concurrently": "^3.6.1", "http-server": "^0.12.3", - "jsdoc": "^3.6.5", + "jsdoc": "^3.6.6", "markdownlint-cli": "^0.23.2", - "rollup": "^1.32.1", - "rollup-cli": "^1.0.9", + "rollup": "^2.36.1", "standard": "^14.3.4", "tui-jsdoc-template": "^1.2.2", "typescript": "^3.9.7", - "y-protocols": "^0.2.3" + "y-protocols": "^1.0.2" } } From bee397f1e549a1fe91d34735f0b29e8686377491 Mon Sep 17 00:00:00 2001 From: Kevin Jahns Date: Sun, 10 Jan 2021 12:31:01 +0100 Subject: [PATCH 18/21] rename funding exec --- package.json | 4 ++-- funding.cjs => sponsor-y.js | 0 2 files changed, 2 insertions(+), 2 deletions(-) rename funding.cjs => sponsor-y.js (100%) diff --git a/package.json b/package.json index a82eca65..1e6216ea 100644 --- a/package.json +++ b/package.json @@ -23,14 +23,14 @@ "debug": "concurrently 'http-server -o test.html' 'npm run watch'", "trace-deopt": "clear && rollup -c && node --trace-deopt dist/test.cjs", "trace-opt": "clear && rollup -c && node --trace-opt dist/test.cjs", - "postinstall": "node ./funding.cjs" + "postinstall": "node ./sponsor-y.js" }, "files": [ "dist/*", "src/*", "tests/*", "docs/*", - "funding.cjs" + "sponsor-y.js" ], "dictionaries": { "doc": "docs", diff --git a/funding.cjs b/sponsor-y.js similarity index 100% rename from funding.cjs rename to sponsor-y.js From c8a59118b597ef34319b86452d406327e984e99a Mon Sep 17 00:00:00 2001 From: Kevin Jahns Date: Sun, 10 Jan 2021 12:37:08 +0100 Subject: [PATCH 19/21] 13.4.12 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 69ef1084..f92e77a9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "yjs", - "version": "13.4.11", + "version": "13.4.12", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 1e6216ea..7a1de1c8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "yjs", - "version": "13.4.11", + "version": "13.4.12", "description": "Shared Editing Library", "main": "./dist/yjs.cjs", "module": "./dist/yjs.mjs", From 7cbf2041432d5ad87acd8895544f279beb031bb5 Mon Sep 17 00:00:00 2001 From: Kevin Jahns Date: Sun, 10 Jan 2021 15:13:19 +0100 Subject: [PATCH 20/21] reduce bundle size #272 --- package.json | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 7a1de1c8..8fb41553 100644 --- a/package.json +++ b/package.json @@ -26,14 +26,11 @@ "postinstall": "node ./sponsor-y.js" }, "files": [ - "dist/*", - "src/*", - "tests/*", - "docs/*", + "dist/yjs.*", + "dist/src", "sponsor-y.js" ], "dictionaries": { - "doc": "docs", "test": "tests" }, "standard": { From baca852733eaa0c2b0b3cb5d30972418c356a47f Mon Sep 17 00:00:00 2001 From: Kevin Jahns Date: Wed, 13 Jan 2021 01:16:21 +0100 Subject: [PATCH 21/21] add relevant relative positions exports --- src/index.js | 3 +++ src/utils/RelativePosition.js | 23 ++++++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index ea40e25a..e38caef7 100644 --- a/src/index.js +++ b/src/index.js @@ -63,6 +63,9 @@ export { encodeSnapshotV2, decodeStateVector, decodeStateVectorV2, + encodeRelativePosition, + decodeRelativePosition, + relativePositionToJSON, isDeleted, isParentOf, equalSnapshots, diff --git a/src/utils/RelativePosition.js b/src/utils/RelativePosition.js index 9f50e591..764eedb5 100644 --- a/src/utils/RelativePosition.js +++ b/src/utils/RelativePosition.js @@ -75,13 +75,34 @@ export class RelativePosition { } } +/** + * @param {RelativePosition} rpos + * @return {any} + */ +export const relativePositionToJSON = rpos => { + const json = {} + if (rpos.type) { + json.type = rpos.type + } + if (rpos.tname) { + json.tname = rpos.tname + } + if (rpos.item) { + json.item = rpos.item + } + if (rpos.assoc != null) { + json.assoc = rpos.assoc + } + return json +} + /** * @param {any} json * @return {RelativePosition} * * @function */ -export const createRelativePositionFromJSON = json => new RelativePosition(json.type == null ? null : createID(json.type.client, json.type.clock), json.tname || null, json.item == null ? null : createID(json.item.client, json.item.clock)) +export const createRelativePositionFromJSON = json => new RelativePosition(json.type == null ? null : createID(json.type.client, json.type.clock), json.tname || null, json.item == null ? null : createID(json.item.client, json.item.clock), json.assoc == null ? 0 : json.assoc) export class AbsolutePosition { /**