Compare commits

..

4 Commits

Author SHA1 Message Date
Kevin Jahns
b3b12958fa Deploy 12.3.2 2017-07-19 18:50:48 +02:00
Kevin Jahns
42aa7ec5c9 Deploy 12.3.1 2017-06-17 14:32:22 +02:00
Kevin Jahns
73e53e3dcc Deploy 12.3.0 2017-05-08 12:40:26 +02:00
Kevin Jahns
222ffea11e Deploy 12.2.1 2017-05-03 18:00:53 +02:00
6 changed files with 97 additions and 60 deletions

View File

@@ -22,6 +22,7 @@ is a list of the modules we know of:
|[webrtc](https://github.com/y-js/y-webrtc) | Propagate updates Browser2Browser via WebRTC| |[webrtc](https://github.com/y-js/y-webrtc) | Propagate updates Browser2Browser via WebRTC|
|[websockets](https://github.com/y-js/y-websockets-client) | Set up [a central server](https://github.com/y-js/y-websockets-client), and connect to it via websockets | |[websockets](https://github.com/y-js/y-websockets-client) | Set up [a central server](https://github.com/y-js/y-websockets-client), and connect to it via websockets |
|[xmpp](https://github.com/y-js/y-xmpp) | Propagate updates in a XMPP multi-user-chat room ([XEP-0045](http://xmpp.org/extensions/xep-0045.html))| |[xmpp](https://github.com/y-js/y-xmpp) | Propagate updates in a XMPP multi-user-chat room ([XEP-0045](http://xmpp.org/extensions/xep-0045.html))|
|[ipfs](https://github.com/ipfs-labs/y-ipfs-connector) | Connector for the [Interplanetary File System](https://ipfs.io/)!|
|[test](https://github.com/y-js/y-test) | A Connector for testing purposes. It is designed to simulate delays that happen in worst case scenarios| |[test](https://github.com/y-js/y-test) | A Connector for testing purposes. It is designed to simulate delays that happen in worst case scenarios|
##### Database adapters ##### Database adapters

View File

@@ -1,6 +1,6 @@
{ {
"name": "yjs", "name": "yjs",
"version": "12.2.0", "version": "12.3.2",
"homepage": "y-js.org", "homepage": "y-js.org",
"authors": [ "authors": [
"Kevin Jahns <kevin.jahns@rwth-aachen.de>" "Kevin Jahns <kevin.jahns@rwth-aachen.de>"

142
y.es6
View File

@@ -1,6 +1,6 @@
/** /**
* 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 v12.1.7 * @version v12.3.1
* @link http://y-js.org * @link http://y-js.org
* @license MIT * @license MIT
*/ */
@@ -48,20 +48,20 @@ function useColors() {
// NB: In an Electron preload script, document will be defined but not fully // NB: In an Electron preload script, document will be defined but not fully
// initialized. Since we know we're in Chrome, we'll just detect this case // initialized. Since we know we're in Chrome, we'll just detect this case
// explicitly // explicitly
if (typeof window !== 'undefined' && window && typeof window.process !== 'undefined' && window.process.type === 'renderer') { if (typeof window !== 'undefined' && window.process && window.process.type === 'renderer') {
return true; return true;
} }
// is webkit? http://stackoverflow.com/a/16459606/376773 // is webkit? http://stackoverflow.com/a/16459606/376773
// document is undefined in react-native: https://github.com/facebook/react-native/pull/1632 // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
return (typeof document !== 'undefined' && document && 'WebkitAppearance' in document.documentElement.style) || return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
// is firebug? http://stackoverflow.com/a/398120/376773 // is firebug? http://stackoverflow.com/a/398120/376773
(typeof window !== 'undefined' && window && window.console && (console.firebug || (console.exception && console.table))) || (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
// is firefox >= v31? // is firefox >= v31?
// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
(typeof navigator !== 'undefined' && navigator && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) || (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||
// double check webkit in userAgent just in case we are in a worker // double check webkit in userAgent just in case we are in a worker
(typeof navigator !== 'undefined' && navigator && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)); (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
} }
/** /**
@@ -403,11 +403,11 @@ function coerce(val) {
* Helpers. * Helpers.
*/ */
var s = 1000 var s = 1000;
var m = s * 60 var m = s * 60;
var h = m * 60 var h = m * 60;
var d = h * 24 var d = h * 24;
var y = d * 365.25 var y = d * 365.25;
/** /**
* Parse or format the given `val`. * Parse or format the given `val`.
@@ -423,18 +423,19 @@ var y = d * 365.25
* @api public * @api public
*/ */
module.exports = function (val, options) { module.exports = function(val, options) {
options = options || {} options = options || {};
var type = typeof val var type = typeof val;
if (type === 'string' && val.length > 0) { if (type === 'string' && val.length > 0) {
return parse(val) return parse(val);
} else if (type === 'number' && isNaN(val) === false) { } else if (type === 'number' && isNaN(val) === false) {
return options.long ? return options.long ? fmtLong(val) : fmtShort(val);
fmtLong(val) :
fmtShort(val)
} }
throw new Error('val is not a non-empty string or a valid number. val=' + JSON.stringify(val)) throw new Error(
} 'val is not a non-empty string or a valid number. val=' +
JSON.stringify(val)
);
};
/** /**
* Parse the given `str` and return milliseconds. * Parse the given `str` and return milliseconds.
@@ -445,53 +446,55 @@ module.exports = function (val, options) {
*/ */
function parse(str) { function parse(str) {
str = String(str) str = String(str);
if (str.length > 10000) { if (str.length > 100) {
return return;
} }
var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(str) var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(
str
);
if (!match) { if (!match) {
return return;
} }
var n = parseFloat(match[1]) var n = parseFloat(match[1]);
var type = (match[2] || 'ms').toLowerCase() var type = (match[2] || 'ms').toLowerCase();
switch (type) { switch (type) {
case 'years': case 'years':
case 'year': case 'year':
case 'yrs': case 'yrs':
case 'yr': case 'yr':
case 'y': case 'y':
return n * y return n * y;
case 'days': case 'days':
case 'day': case 'day':
case 'd': case 'd':
return n * d return n * d;
case 'hours': case 'hours':
case 'hour': case 'hour':
case 'hrs': case 'hrs':
case 'hr': case 'hr':
case 'h': case 'h':
return n * h return n * h;
case 'minutes': case 'minutes':
case 'minute': case 'minute':
case 'mins': case 'mins':
case 'min': case 'min':
case 'm': case 'm':
return n * m return n * m;
case 'seconds': case 'seconds':
case 'second': case 'second':
case 'secs': case 'secs':
case 'sec': case 'sec':
case 's': case 's':
return n * s return n * s;
case 'milliseconds': case 'milliseconds':
case 'millisecond': case 'millisecond':
case 'msecs': case 'msecs':
case 'msec': case 'msec':
case 'ms': case 'ms':
return n return n;
default: default:
return undefined return undefined;
} }
} }
@@ -505,18 +508,18 @@ function parse(str) {
function fmtShort(ms) { function fmtShort(ms) {
if (ms >= d) { if (ms >= d) {
return Math.round(ms / d) + 'd' return Math.round(ms / d) + 'd';
} }
if (ms >= h) { if (ms >= h) {
return Math.round(ms / h) + 'h' return Math.round(ms / h) + 'h';
} }
if (ms >= m) { if (ms >= m) {
return Math.round(ms / m) + 'm' return Math.round(ms / m) + 'm';
} }
if (ms >= s) { if (ms >= s) {
return Math.round(ms / s) + 's' return Math.round(ms / s) + 's';
} }
return ms + 'ms' return ms + 'ms';
} }
/** /**
@@ -532,7 +535,7 @@ function fmtLong(ms) {
plural(ms, h, 'hour') || plural(ms, h, 'hour') ||
plural(ms, m, 'minute') || plural(ms, m, 'minute') ||
plural(ms, s, 'second') || plural(ms, s, 'second') ||
ms + ' ms' ms + ' ms';
} }
/** /**
@@ -541,12 +544,12 @@ function fmtLong(ms) {
function plural(ms, n, name) { function plural(ms, n, name) {
if (ms < n) { if (ms < n) {
return return;
} }
if (ms < n * 1.5) { if (ms < n * 1.5) {
return Math.floor(ms / n) + ' ' + name return Math.floor(ms / n) + ' ' + name;
} }
return Math.ceil(ms / n) + ' ' + name + 's' return Math.ceil(ms / n) + ' ' + name + 's';
} }
},{}],4:[function(require,module,exports){ },{}],4:[function(require,module,exports){
@@ -736,9 +739,6 @@ process.chdir = function (dir) {
process.umask = function() { return 0; }; process.umask = function() { return 0; };
},{}],5:[function(require,module,exports){ },{}],5:[function(require,module,exports){
/* @flow */
'use strict'
function canRead (auth) { return auth === 'read' || auth === 'write' } function canRead (auth) { return auth === 'read' || auth === 'write' }
function canWrite (auth) { return auth === 'write' } function canWrite (auth) { return auth === 'write' }
@@ -817,7 +817,7 @@ module.exports = function (Y/* :any */) {
} }
reconnect () { reconnect () {
this.log('reconnecting..') this.log('reconnecting..')
this.y.db.startGarbageCollector() return this.y.db.startGarbageCollector()
} }
disconnect () { disconnect () {
this.log('discronnecting..') this.log('discronnecting..')
@@ -826,7 +826,8 @@ module.exports = function (Y/* :any */) {
this.currentSyncTarget = null this.currentSyncTarget = null
this.syncingClients = [] this.syncingClients = []
this.whenSyncedListeners = [] this.whenSyncedListeners = []
return this.y.db.stopGarbageCollector() this.y.db.stopGarbageCollector()
return this.y.db.whenTransactionsFinished()
} }
repair () { repair () {
this.log('Repairing the state of Yjs. This can happen if messages get lost, and Yjs detects that something is wrong. If this happens often, please report an issue here: https://github.com/y-js/yjs/issues') this.log('Repairing the state of Yjs. This can happen if messages get lost, and Yjs detects that something is wrong. If this happens often, please report an issue here: https://github.com/y-js/yjs/issues')
@@ -1009,7 +1010,7 @@ module.exports = function (Y/* :any */) {
} }
if (message.auth != null && this.connections[sender] != null) { if (message.auth != null && this.connections[sender] != null) {
// authenticate using auth in message // authenticate using auth in message
var auth = this.checkAuth(message.auth, this.y) var auth = this.checkAuth(message.auth, this.y, sender)
this.connections[sender].auth = auth this.connections[sender].auth = auth
auth.then(auth => { auth.then(auth => {
for (var f of this.userEventListeners) { for (var f of this.userEventListeners) {
@@ -1022,7 +1023,7 @@ module.exports = function (Y/* :any */) {
}) })
} else if (this.connections[sender] != null && this.connections[sender].auth == null) { } else if (this.connections[sender] != null && this.connections[sender].auth == null) {
// authenticate without otherwise // authenticate without otherwise
this.connections[sender].auth = this.checkAuth(null, this.y) this.connections[sender].auth = this.checkAuth(null, this.y, sender)
} }
if (this.connections[sender] != null && this.connections[sender].auth != null) { if (this.connections[sender] != null && this.connections[sender].auth != null) {
return this.connections[sender].auth.then((auth) => { return this.connections[sender].auth.then((auth) => {
@@ -3459,7 +3460,7 @@ module.exports = function (Y/* :any */) {
var ops = [] var ops = []
yield* this.os.iterate(this, null, null, function * (op) { yield* this.os.iterate(this, null, null, function * (op) {
if (op.id[0] !== '_') { if (op.id[0] !== '_') {
ops.push(Y.Struct[op.struct].encode(op)) ops.push(op)
} }
}) })
return { return {
@@ -3563,6 +3564,24 @@ module.exports = function (Y/* :any */) {
module.exports = function (Y /* : any*/) { module.exports = function (Y /* : any*/) {
Y.utils = {} Y.utils = {}
Y.utils.bubbleEvent = function (type, event) {
type.eventHandler.callEventListeners(event)
event.path = []
while (type != null && type._deepEventHandler != null) {
type._deepEventHandler.callEventListeners(event)
var parent = null
if (type._parent != null) {
parent = type.os.getType(type._parent)
}
if (parent != null && parent._getPathToChild != null) {
event.path = [parent._getPathToChild(type._model)].concat(event.path)
type = parent
} else {
type = null
}
}
}
class EventListenerHandler { class EventListenerHandler {
constructor () { constructor () {
this.eventListeners = [] this.eventListeners = []
@@ -3587,7 +3606,11 @@ module.exports = function (Y /* : any*/) {
callEventListeners (event) { callEventListeners (event) {
for (var i = 0; i < this.eventListeners.length; i++) { for (var i = 0; i < this.eventListeners.length; i++) {
try { try {
this.eventListeners[i](event) var _event = {}
for (var name in event) {
_event[name] = event[name]
}
this.eventListeners[i](_event)
} catch (e) { } catch (e) {
console.error('Your observer threw an error. This error was caught so that Yjs still can ensure data consistency! In order to debug this error you have to check "Pause On Caught Exceptions"', e) console.error('Your observer threw an error. This error was caught so that Yjs still can ensure data consistency! In order to debug this error you have to check "Pause On Caught Exceptions"', e)
} }
@@ -3997,7 +4020,20 @@ module.exports = function (Y /* : any*/) {
Default class of custom types! Default class of custom types!
*/ */
class CustomType { class CustomType {
getPath () {
var parent = null
if (this._parent != null) {
parent = this.os.getType(this._parent)
}
if (parent != null && parent._getPathToChild != null) {
var firstKey = parent._getPathToChild(this._model)
var parentKeys = parent.getPath()
parentKeys.push(firstKey)
return parentKeys
} else {
return []
}
}
} }
Y.utils.CustomType = CustomType Y.utils.CustomType = CustomType

File diff suppressed because one or more lines are too long

8
y.js

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long