Compare commits
1 Commits
v13.0.0-20
...
v13.0.0-18
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
256d08cb2a |
@@ -7,7 +7,8 @@ Y({
|
|||||||
},
|
},
|
||||||
connector: {
|
connector: {
|
||||||
name: 'websockets-client',
|
name: 'websockets-client',
|
||||||
url: 'http://127.0.0.1:1234',
|
// url: 'http://127.0.0.1:1234',
|
||||||
|
url: 'http://192.168.178.81:1234',
|
||||||
room: 'html-editor-example6'
|
room: 'html-editor-example6'
|
||||||
},
|
},
|
||||||
share: {
|
share: {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "yjs",
|
"name": "yjs",
|
||||||
"version": "13.0.0-20",
|
"version": "13.0.0-18",
|
||||||
"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": "./y.node.js",
|
"main": "./y.node.js",
|
||||||
"browser": "./y.js",
|
"browser": "./y.js",
|
||||||
|
|||||||
@@ -42,11 +42,6 @@ export default function extendConnector (Y/* :any */) {
|
|||||||
if (opts.generateUserId !== false) {
|
if (opts.generateUserId !== false) {
|
||||||
this.setUserId(Y.utils.generateUserId())
|
this.setUserId(Y.utils.generateUserId())
|
||||||
}
|
}
|
||||||
if (opts.maxBufferLength == null) {
|
|
||||||
this.maxBufferLength = -1
|
|
||||||
} else {
|
|
||||||
this.maxBufferLength = opts.maxBufferLength
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
reconnect () {
|
reconnect () {
|
||||||
@@ -202,19 +197,14 @@ export default function extendConnector (Y/* :any */) {
|
|||||||
encoder.writeVarString(self.opts.room)
|
encoder.writeVarString(self.opts.room)
|
||||||
encoder.writeVarString('update')
|
encoder.writeVarString('update')
|
||||||
let ops = self.broadcastOpBuffer
|
let ops = self.broadcastOpBuffer
|
||||||
|
self.broadcastOpBuffer = []
|
||||||
let length = ops.length
|
let length = ops.length
|
||||||
let encoderPosLen = encoder.pos
|
encoder.writeUint32(length)
|
||||||
encoder.writeUint32(0)
|
for (var i = 0; i < length; i++) {
|
||||||
for (var i = 0; i < length && (self.maxBufferLength < 0 || encoder.length < self.maxBufferLength); i++) {
|
|
||||||
let op = ops[i]
|
let op = ops[i]
|
||||||
Y.Struct[op.struct].binaryEncode(encoder, op)
|
Y.Struct[op.struct].binaryEncode(encoder, op)
|
||||||
}
|
}
|
||||||
encoder.setUint32(encoderPosLen, i)
|
|
||||||
self.broadcastOpBuffer = ops.slice(i)
|
|
||||||
self.broadcast(encoder.createBuffer())
|
self.broadcast(encoder.createBuffer())
|
||||||
if (i !== length) {
|
|
||||||
setTimeout(broadcastOperations, 100)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.broadcastOpBuffer.length === 0) {
|
if (this.broadcastOpBuffer.length === 0) {
|
||||||
|
|||||||
@@ -8,10 +8,6 @@ export class BinaryEncoder {
|
|||||||
this.data = []
|
this.data = []
|
||||||
}
|
}
|
||||||
|
|
||||||
get length () {
|
|
||||||
return this.data.length
|
|
||||||
}
|
|
||||||
|
|
||||||
get pos () {
|
get pos () {
|
||||||
return this.data.length
|
return this.data.length
|
||||||
}
|
}
|
||||||
|
|||||||
45
src/Utils.js
45
src/Utils.js
@@ -49,51 +49,6 @@ export default function Utils (Y) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Y.utils.getRelativePosition = function (type, offset) {
|
|
||||||
if (type == null) {
|
|
||||||
return null
|
|
||||||
} else {
|
|
||||||
if (type._content.length <= offset) {
|
|
||||||
return ['endof', type._model[0], type._model[1]]
|
|
||||||
} else {
|
|
||||||
return type._content[offset].id
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Y.utils.fromRelativePosition = function (y, id) {
|
|
||||||
var offset = 0
|
|
||||||
var op
|
|
||||||
if (id[0] === 'endof') {
|
|
||||||
id = y.db.os.find(id.slice(1)).end
|
|
||||||
op = y.db.os.findNodeWithUpperBound(id).val
|
|
||||||
if (!op.deleted) {
|
|
||||||
offset = op.content != null ? op.content.length : 1
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
op = y.db.os.findNodeWithUpperBound(id).val
|
|
||||||
if (!op.deleted) {
|
|
||||||
offset = id[1] - op.id[1]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var type = y.db.getType(op.parent)
|
|
||||||
if (type == null || y.db.os.find(op.parent).deleted) {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
while (op.left != null) {
|
|
||||||
op = y.db.os.findNodeWithUpperBound(op.left).val
|
|
||||||
if (!op.deleted) {
|
|
||||||
offset += op.content != null ? op.content.length : 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
type: type,
|
|
||||||
offset: offset
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class NamedEventHandler {
|
class NamedEventHandler {
|
||||||
constructor () {
|
constructor () {
|
||||||
this._eventListener = {}
|
this._eventListener = {}
|
||||||
|
|||||||
67
y.node.js
67
y.node.js
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* yjs - A framework for real-time p2p shared editing on any data
|
* yjs - A framework for real-time p2p shared editing on any data
|
||||||
* @version v13.0.0-20
|
* @version v13.0.0-18
|
||||||
* @license MIT
|
* @license MIT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -292,10 +292,6 @@ class BinaryEncoder {
|
|||||||
this.data = [];
|
this.data = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
get length () {
|
|
||||||
return this.data.length
|
|
||||||
}
|
|
||||||
|
|
||||||
get pos () {
|
get pos () {
|
||||||
return this.data.length
|
return this.data.length
|
||||||
}
|
}
|
||||||
@@ -670,11 +666,6 @@ function extendConnector (Y/* :any */) {
|
|||||||
if (opts.generateUserId !== false) {
|
if (opts.generateUserId !== false) {
|
||||||
this.setUserId(Y.utils.generateUserId());
|
this.setUserId(Y.utils.generateUserId());
|
||||||
}
|
}
|
||||||
if (opts.maxBufferLength == null) {
|
|
||||||
this.maxBufferLength = -1;
|
|
||||||
} else {
|
|
||||||
this.maxBufferLength = opts.maxBufferLength;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
reconnect () {
|
reconnect () {
|
||||||
@@ -830,19 +821,14 @@ function extendConnector (Y/* :any */) {
|
|||||||
encoder.writeVarString(self.opts.room);
|
encoder.writeVarString(self.opts.room);
|
||||||
encoder.writeVarString('update');
|
encoder.writeVarString('update');
|
||||||
let ops = self.broadcastOpBuffer;
|
let ops = self.broadcastOpBuffer;
|
||||||
|
self.broadcastOpBuffer = [];
|
||||||
let length = ops.length;
|
let length = ops.length;
|
||||||
let encoderPosLen = encoder.pos;
|
encoder.writeUint32(length);
|
||||||
encoder.writeUint32(0);
|
for (var i = 0; i < length; i++) {
|
||||||
for (var i = 0; i < length && (self.maxBufferLength < 0 || encoder.length < self.maxBufferLength); i++) {
|
|
||||||
let op = ops[i];
|
let op = ops[i];
|
||||||
Y.Struct[op.struct].binaryEncode(encoder, op);
|
Y.Struct[op.struct].binaryEncode(encoder, op);
|
||||||
}
|
}
|
||||||
encoder.setUint32(encoderPosLen, i);
|
|
||||||
self.broadcastOpBuffer = ops.slice(i);
|
|
||||||
self.broadcast(encoder.createBuffer());
|
self.broadcast(encoder.createBuffer());
|
||||||
if (i !== length) {
|
|
||||||
setTimeout(broadcastOperations, 100);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.broadcastOpBuffer.length === 0) {
|
if (this.broadcastOpBuffer.length === 0) {
|
||||||
@@ -3448,51 +3434,6 @@ function Utils (Y) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Y.utils.getRelativePosition = function (type, offset) {
|
|
||||||
if (type == null) {
|
|
||||||
return null
|
|
||||||
} else {
|
|
||||||
if (type._content.length <= offset) {
|
|
||||||
return ['endof', type._model[0], type._model[1]]
|
|
||||||
} else {
|
|
||||||
return type._content[offset].id
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Y.utils.fromRelativePosition = function (y, id) {
|
|
||||||
var offset = 0;
|
|
||||||
var op;
|
|
||||||
if (id[0] === 'endof') {
|
|
||||||
id = y.db.os.find(id.slice(1)).end;
|
|
||||||
op = y.db.os.findNodeWithUpperBound(id).val;
|
|
||||||
if (!op.deleted) {
|
|
||||||
offset = op.content != null ? op.content.length : 1;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
op = y.db.os.findNodeWithUpperBound(id).val;
|
|
||||||
if (!op.deleted) {
|
|
||||||
offset = id[1] - op.id[1];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var type = y.db.getType(op.parent);
|
|
||||||
if (type == null || y.db.os.find(op.parent).deleted) {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
while (op.left != null) {
|
|
||||||
op = y.db.os.findNodeWithUpperBound(op.left).val;
|
|
||||||
if (!op.deleted) {
|
|
||||||
offset += op.content != null ? op.content.length : 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
type: type,
|
|
||||||
offset: offset
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class NamedEventHandler {
|
class NamedEventHandler {
|
||||||
constructor () {
|
constructor () {
|
||||||
this._eventListener = {};
|
this._eventListener = {};
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user