bugfixes creating structs without loading type (e.g. for y-websockets-server)

This commit is contained in:
Kevin Jahns 2016-03-14 19:46:57 +01:00
parent c9c00b5a08
commit f844dcbc1e
5 changed files with 55 additions and 30 deletions

2
dist

@ -1 +1 @@
Subproject commit 51c8d3bdc6e9b4e485fcce88f50ab132f65db252 Subproject commit 5cfe209688c31ae496b6c86db0dc5adbf15b8046

View File

@ -91,10 +91,12 @@ module.exports = function (gulp, helperOptions) {
var browserify = require('browserify') var browserify = require('browserify')
var source = require('vinyl-source-stream') var source = require('vinyl-source-stream')
var buffer = require('vinyl-buffer') var buffer = require('vinyl-buffer')
return browserify({ return browserify({
entries: files.specs, entries: files.specs, // .concat(files.distEs5),
debug: true debug: true
}).bundle() })// .transform('babelify', { presets: ['es2015'] })
.bundle()
.pipe(source('specs.js')) .pipe(source('specs.js'))
.pipe(buffer()) .pipe(buffer())
// .pipe($.sourcemaps.init({loadMaps: true})) // .pipe($.sourcemaps.init({loadMaps: true}))

View File

@ -25,7 +25,7 @@ g.g = g
g.YConcurrency_TestingMode = true g.YConcurrency_TestingMode = true
jasmine.DEFAULT_TIMEOUT_INTERVAL = 5000 jasmine.DEFAULT_TIMEOUT_INTERVAL = 50000
g.describeManyTimes = function describeManyTimes (times, name, f) { g.describeManyTimes = function describeManyTimes (times, name, f) {
for (var i = 0; i < times; i++) { for (var i = 0; i < times; i++) {

View File

@ -100,6 +100,26 @@ module.exports = function (Y/* :any */) {
return t return t
} }
* createType (typedefinition, id) { * createType (typedefinition, id) {
var structname = typedefinition[0].struct
id = id || this.store.getNextOpId()
var op
if (id[0] === '_') {
op = yield* this.getOperation(id)
} else {
op = Y.Struct[structname].create(id)
op.type = typedefinition[0].name
}
if (typedefinition[0].appendAdditionalInfo != null) {
yield* typedefinition[0].appendAdditionalInfo.call(this, op, typedefinition[1])
}
if (op[0] === '_') {
yield* this.setOperation(op)
} else {
yield* this.applyCreatedOperations([op])
}
return yield* this.getType(id, typedefinition[1])
}
/* createType (typedefinition, id) {
var structname = typedefinition[0].struct var structname = typedefinition[0].struct
id = id || this.store.getNextOpId() id = id || this.store.getNextOpId()
var op = Y.Struct[structname].create(id) var op = Y.Struct[structname].create(id)
@ -107,9 +127,12 @@ module.exports = function (Y/* :any */) {
if (typedefinition[0].appendAdditionalInfo != null) { if (typedefinition[0].appendAdditionalInfo != null) {
yield* typedefinition[0].appendAdditionalInfo.call(this, op, typedefinition[1]) yield* typedefinition[0].appendAdditionalInfo.call(this, op, typedefinition[1])
} }
yield* this.applyCreatedOperations([op]) // yield* this.applyCreatedOperations([op])
yield* Y.Struct[op.struct].execute.call(this, op)
yield* this.addOperation(op)
yield* this.store.operationAdded(this, op)
return yield* this.getType(id, typedefinition[1]) return yield* this.getType(id, typedefinition[1])
} }*/
/* /*
Apply operations that this user created (no remote ones!) Apply operations that this user created (no remote ones!)
* does not check for Struct.*.requiredOps() * does not check for Struct.*.requiredOps()
@ -156,7 +179,7 @@ module.exports = function (Y/* :any */) {
yield* this.markDeleted(targetId, 1) yield* this.markDeleted(targetId, 1)
} }
if (target != null && target.gc == null) { if (target != null) {
if (!target.deleted) { if (!target.deleted) {
callType = true callType = true
// set deleted & notify type // set deleted & notify type
@ -187,7 +210,7 @@ module.exports = function (Y/* :any */) {
} }
if (target.opContent != null) { if (target.opContent != null) {
yield* this.deleteOperation(target.opContent) yield* this.deleteOperation(target.opContent)
target.opContent = null // target.opContent = null
} }
} }
var left var left
@ -474,10 +497,12 @@ module.exports = function (Y/* :any */) {
yield* this.setOperation(origin) yield* this.setOperation(origin)
} }
} }
var parent
if (o.parent != null) { if (o.parent != null){
parent = yield* this.getOperation(o.parent)
}
// remove gc'd op from parent, if it exists // remove gc'd op from parent, if it exists
var parent /* MapOperation */ = yield* this.getOperation(o.parent) if (parent != null) {
var setParent = false // whether to save parent to the os var setParent = false // whether to save parent to the os
if (o.parentSub != null) { if (o.parentSub != null) {
if (Y.utils.compareIds(parent.map[o.parentSub], o.id)) { if (Y.utils.compareIds(parent.map[o.parentSub], o.id)) {
@ -656,10 +681,9 @@ module.exports = function (Y/* :any */) {
if (o != null || id[0] !== '_') { if (o != null || id[0] !== '_') {
return o return o
} else { } else {
/* // generate this operation? // generate this operation?
if (typeof id[1] === 'string') {
var comp = id[1].split('_') var comp = id[1].split('_')
if (comp.length > 2 || id[0] === '_') { if (comp.length > 1) {
var struct = comp[0] var struct = comp[0]
var op = Y.Struct[struct].create(id) var op = Y.Struct[struct].create(id)
op.type = comp[1] op.type = comp[1]
@ -671,8 +695,6 @@ module.exports = function (Y/* :any */) {
debugger // eslint-disable-line debugger // eslint-disable-line
return null return null
} }
} else {
*/
return null return null
} }
} }

View File

@ -145,9 +145,10 @@ class YConfig {
throw new Error('Was not able to parse type definition! (share.' + propertyname + ')') throw new Error('Was not able to parse type definition! (share.' + propertyname + ')')
} }
} }
var id = ['_', propertyname + '_' + typeConstructor]
var type = Y[typeName] var type = Y[typeName]
share[propertyname] = yield* this.createType(type.apply(type.typeDefinition, args), id) var typedef = type.typeDefinition
var id = ['_', typedef.struct + '_' + typeName + '_' + propertyname + '_' + typeConstructor]
share[propertyname] = yield* this.createType(type.apply(typedef, args), id)
} }
this.store.whenTransactionsFinished() this.store.whenTransactionsFinished()
.then(callback) .then(callback)