removed circular dependency, errors and ys reference

This commit is contained in:
sarahm7 2021-04-02 14:07:40 +08:00
parent fc739a2f27
commit 54086f7b7b
4 changed files with 17 additions and 15 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "yjs", "name": "ys-yjs",
"version": "12.3.3", "version": "12.5.0",
"description": "A framework for real-time p2p shared editing on any data", "description": "A framework for real-time p2p shared editing on any data",
"main": "./src/y.js", "main": "./src/y.js",
"scripts": { "scripts": {
@ -23,7 +23,7 @@
}, },
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/y-js/yjs.git" "url": "https://github.com/yousourceinc/yjs.git"
}, },
"keywords": [ "keywords": [
"Yjs", "Yjs",
@ -38,7 +38,7 @@
"email": "kevin.jahns@rwth-aachen.de", "email": "kevin.jahns@rwth-aachen.de",
"license": "MIT", "license": "MIT",
"bugs": { "bugs": {
"url": "https://github.com/y-js/yjs/issues" "url": "https://github.com/yousourceinc/yjs/issues"
}, },
"homepage": "http://y-js.org", "homepage": "http://y-js.org",
"devDependencies": { "devDependencies": {

View File

@ -506,10 +506,12 @@ module.exports = function (Y/* :any */) {
// ** Now the new implementation starts ** // ** Now the new implementation starts **
// reset neworigin of all originOf[*] // reset neworigin of all originOf[*]
for (var _i of o.originOf) { for (var _i of o.originOf) {
var originsIn = yield* this.getOperation(o.originOf[_i]) if (_i) {
if (originsIn != null) { var originsIn = yield* this.getOperation(_i)
originsIn.origin = neworigin if (originsIn != null) {
yield* this.setOperation(originsIn) originsIn.origin = neworigin
yield* this.setOperation(originsIn)
}
} }
} }
if (neworigin != null) { if (neworigin != null) {

View File

@ -658,7 +658,7 @@ module.exports = function (Y /* : any*/) {
for (i = this.readBuffer.length - 1; i >= 0; i--) { for (i = this.readBuffer.length - 1; i >= 0; i--) {
r = this.readBuffer[i] r = this.readBuffer[i]
// we don't have to use compareids, because id is always defined! // 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 // found r
// move r to the end of readBuffer // move r to the end of readBuffer
for (; i < this.readBuffer.length - 1; i++) { for (; i < this.readBuffer.length - 1; i++) {
@ -671,7 +671,7 @@ module.exports = function (Y /* : any*/) {
var o var o
for (i = this.writeBuffer.length - 1; i >= 0; i--) { for (i = this.writeBuffer.length - 1; i >= 0; i--) {
r = this.writeBuffer[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 o = r
break break
} }
@ -694,7 +694,7 @@ module.exports = function (Y /* : any*/) {
var i, r // helper variables var i, r // helper variables
for (i = this.writeBuffer.length - 1; i >= 0; i--) { for (i = this.writeBuffer.length - 1; i >= 0; i--) {
r = this.writeBuffer[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 // is already in buffer
// forget r, and move o to the end of writeBuffer // forget r, and move o to the end of writeBuffer
for (; i < this.writeBuffer.length - 1; i++) { 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 // whether found or not, we'll append o to the readbuffer
for (i = 0; i < this.readBuffer.length - 1; i++) { for (i = 0; i < this.readBuffer.length - 1; i++) {
r = this.readBuffer[i + 1] 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 this.readBuffer[i] = o
} else { } else {
this.readBuffer[i] = r this.readBuffer[i] = r
@ -733,7 +733,7 @@ module.exports = function (Y /* : any*/) {
var i, r var i, r
for (i = 0; i < this.readBuffer.length; i++) { for (i = 0; i < this.readBuffer.length; i++) {
r = this.readBuffer[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] = { this.readBuffer[i] = {
id: [null, null] id: [null, null]
} }

View File

@ -70,8 +70,8 @@ function requestModules (modules) {
}) })
promises.push(requireModule.promise) promises.push(requireModule.promise)
} else { } else {
console.info('YJS: Please do not depend on automatic requiring of modules anymore! Extend modules as follows `require(\'y-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) // require(modulename)(Y) // causing circular dependency for angular
} }
} else { } else {
promises.push(requiringModules[modules[i]].promise) promises.push(requiringModules[modules[i]].promise)