Compare commits

..

2 Commits

Author SHA1 Message Date
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
5 changed files with 93 additions and 54 deletions

View File

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

133
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.2.0 * @version v12.3.0
* @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){
@@ -817,7 +820,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 +829,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')
@@ -3563,6 +3567,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 +3609,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 +4023,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