From 54086f7b7b9eecdbc4a670559a75070676e074b0 Mon Sep 17 00:00:00 2001 From: sarahm7 Date: Fri, 2 Apr 2021 14:07:40 +0800 Subject: [PATCH] removed circular dependency, errors and ys reference --- package.json | 8 ++++---- src/Transaction.js | 10 ++++++---- src/Utils.js | 10 +++++----- src/y.js | 4 ++-- 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/package.json b/package.json index 08d4709e..9e2ed171 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "yjs", - "version": "12.3.3", + "name": "ys-yjs", + "version": "12.5.0", "description": "A framework for real-time p2p shared editing on any data", "main": "./src/y.js", "scripts": { @@ -23,7 +23,7 @@ }, "repository": { "type": "git", - "url": "https://github.com/y-js/yjs.git" + "url": "https://github.com/yousourceinc/yjs.git" }, "keywords": [ "Yjs", @@ -38,7 +38,7 @@ "email": "kevin.jahns@rwth-aachen.de", "license": "MIT", "bugs": { - "url": "https://github.com/y-js/yjs/issues" + "url": "https://github.com/yousourceinc/yjs/issues" }, "homepage": "http://y-js.org", "devDependencies": { diff --git a/src/Transaction.js b/src/Transaction.js index 99e1c64b..3dbb5b43 100644 --- a/src/Transaction.js +++ b/src/Transaction.js @@ -506,10 +506,12 @@ module.exports = function (Y/* :any */) { // ** Now the new implementation starts ** // reset neworigin of all originOf[*] for (var _i of o.originOf) { - var originsIn = yield* this.getOperation(o.originOf[_i]) - if (originsIn != null) { - originsIn.origin = neworigin - yield* this.setOperation(originsIn) + if (_i) { + var originsIn = yield* this.getOperation(_i) + if (originsIn != null) { + originsIn.origin = neworigin + yield* this.setOperation(originsIn) + } } } if (neworigin != null) { diff --git a/src/Utils.js b/src/Utils.js index b1b4d848..24caa0c5 100644 --- a/src/Utils.js +++ b/src/Utils.js @@ -658,7 +658,7 @@ module.exports = function (Y /* : any*/) { for (i = this.readBuffer.length - 1; i >= 0; i--) { r = this.readBuffer[i] // we don't have to use compareids, because id is always defined! - if (r.id[1] === id[1] && r.id[0] === id[0]) { + if (r.id && id && r.id[1] === id[1] && r.id[0] === id[0]) { // found r // move r to the end of readBuffer for (; i < this.readBuffer.length - 1; i++) { @@ -671,7 +671,7 @@ module.exports = function (Y /* : any*/) { var o for (i = this.writeBuffer.length - 1; i >= 0; i--) { r = this.writeBuffer[i] - if (r.id[1] === id[1] && r.id[0] === id[0]) { + if (r.id && id && r.id[1] === id[1] && r.id[0] === id[0]) { o = r break } @@ -694,7 +694,7 @@ module.exports = function (Y /* : any*/) { var i, r // helper variables for (i = this.writeBuffer.length - 1; i >= 0; i--) { r = this.writeBuffer[i] - if (r.id[1] === id[1] && r.id[0] === id[0]) { + if (r.id && id && r.id[1] === id[1] && r.id[0] === id[0]) { // is already in buffer // forget r, and move o to the end of writeBuffer for (; i < this.writeBuffer.length - 1; i++) { @@ -721,7 +721,7 @@ module.exports = function (Y /* : any*/) { // whether found or not, we'll append o to the readbuffer for (i = 0; i < this.readBuffer.length - 1; i++) { r = this.readBuffer[i + 1] - if (r.id[1] === id[1] && r.id[0] === id[0]) { + if (r.id && id && r.id[1] === id[1] && r.id[0] === id[0]) { this.readBuffer[i] = o } else { this.readBuffer[i] = r @@ -733,7 +733,7 @@ module.exports = function (Y /* : any*/) { var i, r for (i = 0; i < this.readBuffer.length; i++) { r = this.readBuffer[i] - if (r.id[1] === id[1] && r.id[0] === id[0]) { + if (r.id && id && r.id[1] === id[1] && r.id[0] === id[0]) { this.readBuffer[i] = { id: [null, null] } diff --git a/src/y.js b/src/y.js index 7b828d97..f4369263 100644 --- a/src/y.js +++ b/src/y.js @@ -70,8 +70,8 @@ function requestModules (modules) { }) promises.push(requireModule.promise) } else { - console.info('YJS: Please do not depend on automatic requiring of modules anymore! Extend modules as follows `require(\'y-modulename\')(Y)`') - require(modulename)(Y) + console.error('YJS: Please do not depend on automatic requiring of modules anymore! Extend modules as follows `require(\'y-modulename\')(Y)`') + // require(modulename)(Y) // causing circular dependency for angular } } else { promises.push(requiringModules[modules[i]].promise)