Release 11.2.0

This commit is contained in:
Kevin Jahns 2016-05-10 18:13:01 +02:00
parent 6669be104e
commit f7ae62a906
4 changed files with 66 additions and 52 deletions

2
dist

@ -1 +1 @@
Subproject commit 80ab682b0a6f338e48979b619e0c7b6f55ca9a48 Subproject commit b9f9c762ebed9b30c44b1c87b555e89a7257ae58

View File

@ -1,6 +1,6 @@
{ {
"name": "yjs", "name": "yjs",
"version": "11.1.0", "version": "11.2.0",
"description": "A framework for real-time p2p shared editing on arbitrary complex data types", "description": "A framework for real-time p2p shared editing on arbitrary complex data types",
"main": "./src/y.js", "main": "./src/y.js",
"scripts": { "scripts": {

View File

@ -379,18 +379,34 @@ module.exports = function (Y /* :any */) {
} }
} }
} }
// called by a transaction when an operation is added /*
* Called by a transaction when an operation is added.
* This function is especially important for y-indexeddb, where several instances may share a single database.
* Every time an operation is created by one instance, it is send to all other instances and operationAdded is called
*
* If it's not a Delete operation:
* * Checks if another operation is executable (listenersById)
* * Update state, if possible
*
* Always:
* * Call type
*/
* operationAdded (transaction, op) { * operationAdded (transaction, op) {
if (op.struct === 'Delete') {
var target = yield* transaction.getInsertion(op.target)
var type = this.initializedTypes[JSON.stringify(target.parent)]
if (type != null) {
yield* type._changed(transaction, op)
}
} else {
// increase SS // increase SS
yield* transaction.updateState(op.id[0]) yield* transaction.updateState(op.id[0])
var opLen = op.content != null ? op.content.length : 1 var opLen = op.content != null ? op.content.length : 1
for (let i = 0; i < opLen; i++) { for (let i = 0; i < opLen; i++) {
// notify whenOperation listeners (by id) // notify whenOperation listeners (by id)
var sid = JSON.stringify([op.id[0], op.id[1] + i]) var sid = JSON.stringify([op.id[0], op.id[1] + i])
var l = this.listenersById[sid] var l = this.listenersById[sid]
delete this.listenersById[sid] delete this.listenersById[sid]
if (l != null) { if (l != null) {
for (var key in l) { for (var key in l) {
var listener = l[key] var listener = l[key]
@ -433,6 +449,7 @@ module.exports = function (Y /* :any */) {
} }
} }
} }
}
whenTransactionsFinished () { whenTransactionsFinished () {
if (this.transactionInProgress) { if (this.transactionInProgress) {
if (this.transactionsFinished == null) { if (this.transactionsFinished == null) {

View File

@ -254,15 +254,12 @@ module.exports = function (Y/* :any */) {
right = null right = null
} }
if (callType && !preventCallType) { if (callType && !preventCallType) {
var type = this.store.initializedTypes[JSON.stringify(target.parent)] yield* this.store.operationAdded(this, {
if (type != null) {
yield* type._changed(this, {
struct: 'Delete', struct: 'Delete',
target: target.id, target: target.id,
length: targetLength length: targetLength
}) })
} }
}
// need to gc in the end! // need to gc in the end!
yield* this.store.addToGarbageCollector.call(this, target, left) yield* this.store.addToGarbageCollector.call(this, target, left)
if (right != null) { if (right != null) {