making sync more efficient. using new connector features. found lots of small bugs

This commit is contained in:
DadaMonad 2015-01-06 10:29:50 +00:00
parent d2fa906b50
commit d898136f64
28 changed files with 683 additions and 432 deletions

View File

@ -26,7 +26,8 @@
], ],
"dependencies": { "dependencies": {
"peerjs": "~0.3.14", "peerjs": "~0.3.14",
"polymer": "Polymer/polymer#~0.5.2", "polymer": "~0.5.2",
"paper-slider": "Polymer/paper-slider#~0.5.2" "paper-slider": "Polymer/paper-slider#~0.5.2",
"webcomponentsjs": "~0.5.2"
} }
} }

View File

@ -1,7 +1,7 @@
{ {
"name": "webcomponentsjs", "name": "webcomponentsjs",
"main": "webcomponents.js", "main": "webcomponents.js",
"version": "0.5.1", "version": "0.5.2",
"homepage": "http://webcomponents.org", "homepage": "http://webcomponents.org",
"authors": [ "authors": [
"The Polymer Authors" "The Polymer Authors"
@ -11,13 +11,14 @@
], ],
"license": "BSD", "license": "BSD",
"ignore": [], "ignore": [],
"_release": "0.5.1", "_release": "0.5.2",
"_resolution": { "_resolution": {
"type": "version", "type": "version",
"tag": "0.5.1", "tag": "0.5.2",
"commit": "89c466eb29642c3e5ba2594e9330eb62ade1dbab" "commit": "4f469f65d3fa3c03a44326d138331003fa340337"
}, },
"_source": "git://github.com/Polymer/webcomponentsjs.git", "_source": "git://github.com/Polymer/webcomponentsjs.git",
"_target": "^0.5.0", "_target": "~0.5.2",
"_originalSource": "Polymer/webcomponentsjs" "_originalSource": "webcomponentsjs",
"_direct": true
} }

View File

@ -7,7 +7,7 @@
* Code distributed by Google as part of the polymer project is also * Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
*/ */
// @version 0.5.1 // @version 0.5.1-1
if (typeof WeakMap === "undefined") { if (typeof WeakMap === "undefined") {
(function() { (function() {
var defineProperty = Object.defineProperty; var defineProperty = Object.defineProperty;
@ -47,7 +47,7 @@ if (typeof WeakMap === "undefined") {
(function(global) { (function(global) {
var registrationsTable = new WeakMap(); var registrationsTable = new WeakMap();
var setImmediate; var setImmediate;
if (/Trident/.test(navigator.userAgent)) { if (/Trident|Edge/.test(navigator.userAgent)) {
setImmediate = setTimeout; setImmediate = setTimeout;
} else if (window.setImmediate) { } else if (window.setImmediate) {
setImmediate = window.setImmediate; setImmediate = window.setImmediate;
@ -868,6 +868,7 @@ CustomElements.addModule(function(scope) {
(function(scope) { (function(scope) {
var useNative = scope.useNative; var useNative = scope.useNative;
var initializeModules = scope.initializeModules; var initializeModules = scope.initializeModules;
var isIE11OrOlder = /Trident/.test(navigator.userAgent);
if (useNative) { if (useNative) {
var nop = function() {}; var nop = function() {};
scope.watchShadow = nop; scope.watchShadow = nop;
@ -911,7 +912,7 @@ CustomElements.addModule(function(scope) {
})); }));
}); });
} }
if (typeof window.CustomEvent !== "function") { if (isIE11OrOlder && typeof window.CustomEvent !== "function") {
window.CustomEvent = function(inType, params) { window.CustomEvent = function(inType, params) {
params = params || {}; params = params || {};
var e = document.createEvent("CustomEvent"); var e = document.createEvent("CustomEvent");

File diff suppressed because one or more lines are too long

View File

@ -7,7 +7,7 @@
* Code distributed by Google as part of the polymer project is also * Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
*/ */
// @version 0.5.1 // @version 0.5.1-1
if (typeof WeakMap === "undefined") { if (typeof WeakMap === "undefined") {
(function() { (function() {
var defineProperty = Object.defineProperty; var defineProperty = Object.defineProperty;
@ -47,7 +47,7 @@ if (typeof WeakMap === "undefined") {
(function(global) { (function(global) {
var registrationsTable = new WeakMap(); var registrationsTable = new WeakMap();
var setImmediate; var setImmediate;
if (/Trident/.test(navigator.userAgent)) { if (/Trident|Edge/.test(navigator.userAgent)) {
setImmediate = setTimeout; setImmediate = setTimeout;
} else if (window.setImmediate) { } else if (window.setImmediate) {
setImmediate = window.setImmediate; setImmediate = window.setImmediate;
@ -365,7 +365,7 @@ window.HTMLImports = window.HTMLImports || {
}; };
Object.defineProperty(document, "_currentScript", currentScriptDescriptor); Object.defineProperty(document, "_currentScript", currentScriptDescriptor);
Object.defineProperty(rootDocument, "_currentScript", currentScriptDescriptor); Object.defineProperty(rootDocument, "_currentScript", currentScriptDescriptor);
var isIE = /Trident/.test(navigator.userAgent); var isIE = /Trident|Edge/.test(navigator.userAgent);
function whenReady(callback, doc) { function whenReady(callback, doc) {
doc = doc || rootDocument; doc = doc || rootDocument;
whenDocumentReady(function() { whenDocumentReady(function() {
@ -787,12 +787,7 @@ HTMLImports.addModule(function(scope) {
}, },
addElementToDocument: function(elt) { addElementToDocument: function(elt) {
var port = this.rootImportForElement(elt.__importElement || elt); var port = this.rootImportForElement(elt.__importElement || elt);
var l = port.__insertedElements = port.__insertedElements || 0; port.parentNode.insertBefore(elt, port);
var refNode = port.nextElementSibling;
for (var i = 0; i < l; i++) {
refNode = refNode && refNode.nextElementSibling;
}
port.parentNode.insertBefore(elt, refNode);
}, },
trackElement: function(elt, callback) { trackElement: function(elt, callback) {
var self = this; var self = this;
@ -972,7 +967,9 @@ HTMLImports.addModule(function(scope) {
var base = doc.createElement("base"); var base = doc.createElement("base");
base.setAttribute("href", url); base.setAttribute("href", url);
if (!doc.baseURI) { if (!doc.baseURI) {
doc.baseURI = url; Object.defineProperty(doc, "baseURI", {
value: url
});
} }
var meta = doc.createElement("meta"); var meta = doc.createElement("meta");
meta.setAttribute("charset", "utf-8"); meta.setAttribute("charset", "utf-8");
@ -1031,16 +1028,19 @@ HTMLImports.addModule(function(scope) {
}); });
(function(scope) { (function(scope) {
initializeModules = scope.initializeModules; var initializeModules = scope.initializeModules;
var isIE = scope.isIE;
if (scope.useNative) { if (scope.useNative) {
return; return;
} }
if (typeof window.CustomEvent !== "function") { if (isIE && typeof window.CustomEvent !== "function") {
window.CustomEvent = function(inType, dictionary) { window.CustomEvent = function(inType, params) {
var e = document.createEvent("HTMLEvents"); params = params || {};
e.initEvent(inType, dictionary.bubbles === false ? false : true, dictionary.cancelable === false ? false : true, dictionary.detail); var e = document.createEvent("CustomEvent");
e.initCustomEvent(inType, Boolean(params.bubbles), Boolean(params.cancelable), params.detail);
return e; return e;
}; };
window.CustomEvent.prototype = window.Event.prototype;
} }
initializeModules(); initializeModules();
var rootDocument = scope.rootDocument; var rootDocument = scope.rootDocument;

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,7 @@
webcomponents.js webcomponents.js
================ ================
A suite of polyfills supporting the HTML web components specs: A suite of polyfills supporting the [Web Components](http://webcomponents.org) specs:
**Custom Elements**: allows authors to define their own custom tags ([spec](https://w3c.github.io/webcomponents/spec/custom/)). **Custom Elements**: allows authors to define their own custom tags ([spec](https://w3c.github.io/webcomponents/spec/custom/)).
@ -14,7 +14,7 @@ This also folds in polyfills for `MutationObserver` and `WeakMap`.
## Releases ## Releases
Pre-built (concatenated & minified) versions of the polyfills are maintained in the [tagged versions](https://github.com/Polymer/webcomponentsjs/releases) of this repo. There are two variants: Pre-built (concatenated & minified) versions of the polyfills are maintained in the [tagged versions](https://github.com/webcomponents/webcomponentsjs/releases) of this repo. There are two variants:
`webcomponents.js` includes all of the polyfills. `webcomponents.js` includes all of the polyfills.
@ -36,3 +36,9 @@ Now you are ready to build the polyfills with:
gulp build gulp build
The builds will be placed into the `dist/` directory. The builds will be placed into the `dist/` directory.
## Contribute
See the [contributing guide](CONTRIBUTING.md)

View File

@ -7,7 +7,7 @@
* Code distributed by Google as part of the polymer project is also * Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
*/ */
// @version 0.5.1 // @version 0.5.1-1
if (typeof WeakMap === "undefined") { if (typeof WeakMap === "undefined") {
(function() { (function() {
var defineProperty = Object.defineProperty; var defineProperty = Object.defineProperty;
@ -1726,7 +1726,7 @@ window.ShadowDOMPolyfill = {};
var originalInsertBefore = OriginalNode.prototype.insertBefore; var originalInsertBefore = OriginalNode.prototype.insertBefore;
var originalRemoveChild = OriginalNode.prototype.removeChild; var originalRemoveChild = OriginalNode.prototype.removeChild;
var originalReplaceChild = OriginalNode.prototype.replaceChild; var originalReplaceChild = OriginalNode.prototype.replaceChild;
var isIe = /Trident/.test(navigator.userAgent); var isIe = /Trident|Edge/.test(navigator.userAgent);
var removeChildOriginalHelper = isIe ? function(parent, child) { var removeChildOriginalHelper = isIe ? function(parent, child) {
try { try {
originalRemoveChild.call(parent, child); originalRemoveChild.call(parent, child);

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,7 @@
{ {
"name": "webcomponentsjs", "name": "webcomponentsjs",
"main": "webcomponents.js", "main": "webcomponents.js",
"version": "0.5.1", "version": "0.5.2",
"homepage": "http://webcomponents.org", "homepage": "http://webcomponents.org",
"authors": [ "authors": [
"The Polymer Authors" "The Polymer Authors"

View File

@ -0,0 +1,31 @@
BUILD LOG
---------
Build Time: 2014-12-11T12:45:39-0800
NODEJS INFORMATION
==================
nodejs: v0.10.33
gulp: 3.8.10
gulp-audit: 1.0.0
gulp-concat: 2.4.2
gulp-header: 1.2.2
gulp-uglify: 1.0.2
run-sequence: 1.0.2
web-component-tester: 2.0.1
REPO REVISIONS
==============
webcomponentsjs: d83cc676df65dc61db22bca47d33da679391f5a0
BUILD HASHES
============
CustomElements.js: b221f7741515b570df70fd1c50b398bb8f731b81
CustomElements.min.js: 6a55999d9f4895525d35c5248e2f409f176162a6
HTMLImports.js: 72dd4ea891dc3c5256c569992288eca9f5c5e450
HTMLImports.min.js: 1677819e83722c7d163a571598d8d36cdc8ae690
ShadowDOM.js: a1cce2304031d5acb440978761b346b98d06e1a4
ShadowDOM.min.js: 9371908d889872eb7e8e320e8877c394eb906732
webcomponents-lite.js: 7b6c8fbd7f67a2bd04b797a72e808b16ab54518f
webcomponents-lite.min.js: 41b033fa7e52bf612686f222d5a496d48bd2909c
webcomponents.js: 523f45c65c94d71543729f7e3d32ec4b7a48ae5b
webcomponents.min.js: 645b22d4c22bf6eaf470bc03d819d396661ac439

View File

@ -0,0 +1,31 @@
{
"name": "webcomponents.js",
"version": "0.5.1-1",
"description": "webcomponents.js",
"main": "gulpfile.js",
"directories": {
"test": "tests"
},
"repository": {
"type": "git",
"url": "https://github.com/webcomponents/webcomponentsjs.git"
},
"author": "The Polymer Authors",
"license": {
"type": "BSD-3-Clause",
"url": "http://polymer.github.io/LICENSE.txt"
},
"bugs": {
"url": "https://github.com/webcomponents/webcomponentsjs/issues"
},
"homepage": "http://webcomponents.org",
"devDependencies": {
"gulp": "^3.8.8",
"gulp-audit": "^1.0.0",
"gulp-concat": "^2.4.1",
"gulp-header": "^1.1.1",
"gulp-uglify": "^1.0.1",
"run-sequence": "^1.0.1",
"web-component-tester": "*"
}
}

View File

@ -7,7 +7,7 @@
* Code distributed by Google as part of the polymer project is also * Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
*/ */
// @version 0.5.1 // @version 0.5.1-1
window.WebComponents = window.WebComponents || {}; window.WebComponents = window.WebComponents || {};
(function(scope) { (function(scope) {
@ -91,7 +91,7 @@ if (typeof WeakMap === "undefined") {
(function(global) { (function(global) {
var registrationsTable = new WeakMap(); var registrationsTable = new WeakMap();
var setImmediate; var setImmediate;
if (/Trident/.test(navigator.userAgent)) { if (/Trident|Edge/.test(navigator.userAgent)) {
setImmediate = setTimeout; setImmediate = setTimeout;
} else if (window.setImmediate) { } else if (window.setImmediate) {
setImmediate = window.setImmediate; setImmediate = window.setImmediate;
@ -409,7 +409,7 @@ window.HTMLImports = window.HTMLImports || {
}; };
Object.defineProperty(document, "_currentScript", currentScriptDescriptor); Object.defineProperty(document, "_currentScript", currentScriptDescriptor);
Object.defineProperty(rootDocument, "_currentScript", currentScriptDescriptor); Object.defineProperty(rootDocument, "_currentScript", currentScriptDescriptor);
var isIE = /Trident/.test(navigator.userAgent); var isIE = /Trident|Edge/.test(navigator.userAgent);
function whenReady(callback, doc) { function whenReady(callback, doc) {
doc = doc || rootDocument; doc = doc || rootDocument;
whenDocumentReady(function() { whenDocumentReady(function() {
@ -831,12 +831,7 @@ HTMLImports.addModule(function(scope) {
}, },
addElementToDocument: function(elt) { addElementToDocument: function(elt) {
var port = this.rootImportForElement(elt.__importElement || elt); var port = this.rootImportForElement(elt.__importElement || elt);
var l = port.__insertedElements = port.__insertedElements || 0; port.parentNode.insertBefore(elt, port);
var refNode = port.nextElementSibling;
for (var i = 0; i < l; i++) {
refNode = refNode && refNode.nextElementSibling;
}
port.parentNode.insertBefore(elt, refNode);
}, },
trackElement: function(elt, callback) { trackElement: function(elt, callback) {
var self = this; var self = this;
@ -1016,7 +1011,9 @@ HTMLImports.addModule(function(scope) {
var base = doc.createElement("base"); var base = doc.createElement("base");
base.setAttribute("href", url); base.setAttribute("href", url);
if (!doc.baseURI) { if (!doc.baseURI) {
doc.baseURI = url; Object.defineProperty(doc, "baseURI", {
value: url
});
} }
var meta = doc.createElement("meta"); var meta = doc.createElement("meta");
meta.setAttribute("charset", "utf-8"); meta.setAttribute("charset", "utf-8");
@ -1075,16 +1072,19 @@ HTMLImports.addModule(function(scope) {
}); });
(function(scope) { (function(scope) {
initializeModules = scope.initializeModules; var initializeModules = scope.initializeModules;
var isIE = scope.isIE;
if (scope.useNative) { if (scope.useNative) {
return; return;
} }
if (typeof window.CustomEvent !== "function") { if (isIE && typeof window.CustomEvent !== "function") {
window.CustomEvent = function(inType, dictionary) { window.CustomEvent = function(inType, params) {
var e = document.createEvent("HTMLEvents"); params = params || {};
e.initEvent(inType, dictionary.bubbles === false ? false : true, dictionary.cancelable === false ? false : true, dictionary.detail); var e = document.createEvent("CustomEvent");
e.initCustomEvent(inType, Boolean(params.bubbles), Boolean(params.cancelable), params.detail);
return e; return e;
}; };
window.CustomEvent.prototype = window.Event.prototype;
} }
initializeModules(); initializeModules();
var rootDocument = scope.rootDocument; var rootDocument = scope.rootDocument;
@ -1622,6 +1622,7 @@ CustomElements.addModule(function(scope) {
(function(scope) { (function(scope) {
var useNative = scope.useNative; var useNative = scope.useNative;
var initializeModules = scope.initializeModules; var initializeModules = scope.initializeModules;
var isIE11OrOlder = /Trident/.test(navigator.userAgent);
if (useNative) { if (useNative) {
var nop = function() {}; var nop = function() {};
scope.watchShadow = nop; scope.watchShadow = nop;
@ -1665,7 +1666,7 @@ CustomElements.addModule(function(scope) {
})); }));
}); });
} }
if (typeof window.CustomEvent !== "function") { if (isIE11OrOlder && typeof window.CustomEvent !== "function") {
window.CustomEvent = function(inType, params) { window.CustomEvent = function(inType, params) {
params = params || {}; params = params || {};
var e = document.createEvent("CustomEvent"); var e = document.createEvent("CustomEvent");
@ -1684,6 +1685,32 @@ CustomElements.addModule(function(scope) {
} }
})(window.CustomElements); })(window.CustomElements);
if (typeof HTMLTemplateElement === "undefined") {
(function() {
var TEMPLATE_TAG = "template";
HTMLTemplateElement = function() {};
HTMLTemplateElement.prototype = Object.create(HTMLElement.prototype);
HTMLTemplateElement.decorate = function(template) {
if (!template.content) {
template.content = template.ownerDocument.createDocumentFragment();
var child;
while (child = template.firstChild) {
template.content.appendChild(child);
}
}
};
HTMLTemplateElement.bootstrap = function(doc) {
var templates = doc.querySelectorAll(TEMPLATE_TAG);
for (var i = 0, l = templates.length, t; i < l && (t = templates[i]); i++) {
HTMLTemplateElement.decorate(t);
}
};
addEventListener("DOMContentLoaded", function() {
HTMLTemplateElement.bootstrap(document);
});
})();
}
(function(scope) { (function(scope) {
var style = document.createElement("style"); var style = document.createElement("style");
style.textContent = "" + "body {" + "transition: opacity ease-in 0.2s;" + " } \n" + "body[unresolved] {" + "opacity: 0; display: block; overflow: hidden; position: relative;" + " } \n"; style.textContent = "" + "body {" + "transition: opacity ease-in 0.2s;" + " } \n" + "body[unresolved] {" + "opacity: 0; display: block; overflow: hidden; position: relative;" + " } \n";

File diff suppressed because one or more lines are too long

View File

@ -7,7 +7,7 @@
* Code distributed by Google as part of the polymer project is also * Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
*/ */
// @version 0.5.1 // @version 0.5.1-1
window.WebComponents = window.WebComponents || {}; window.WebComponents = window.WebComponents || {};
(function(scope) { (function(scope) {
@ -1760,7 +1760,7 @@ if (WebComponents.flags.shadow) {
var originalInsertBefore = OriginalNode.prototype.insertBefore; var originalInsertBefore = OriginalNode.prototype.insertBefore;
var originalRemoveChild = OriginalNode.prototype.removeChild; var originalRemoveChild = OriginalNode.prototype.removeChild;
var originalReplaceChild = OriginalNode.prototype.replaceChild; var originalReplaceChild = OriginalNode.prototype.replaceChild;
var isIe = /Trident/.test(navigator.userAgent); var isIe = /Trident|Edge/.test(navigator.userAgent);
var removeChildOriginalHelper = isIe ? function(parent, child) { var removeChildOriginalHelper = isIe ? function(parent, child) {
try { try {
originalRemoveChild.call(parent, child); originalRemoveChild.call(parent, child);
@ -4695,7 +4695,7 @@ if (WebComponents.flags.shadow) {
(function(global) { (function(global) {
var registrationsTable = new WeakMap(); var registrationsTable = new WeakMap();
var setImmediate; var setImmediate;
if (/Trident/.test(navigator.userAgent)) { if (/Trident|Edge/.test(navigator.userAgent)) {
setImmediate = setTimeout; setImmediate = setTimeout;
} else if (window.setImmediate) { } else if (window.setImmediate) {
setImmediate = window.setImmediate; setImmediate = window.setImmediate;
@ -5013,7 +5013,7 @@ window.HTMLImports = window.HTMLImports || {
}; };
Object.defineProperty(document, "_currentScript", currentScriptDescriptor); Object.defineProperty(document, "_currentScript", currentScriptDescriptor);
Object.defineProperty(rootDocument, "_currentScript", currentScriptDescriptor); Object.defineProperty(rootDocument, "_currentScript", currentScriptDescriptor);
var isIE = /Trident/.test(navigator.userAgent); var isIE = /Trident|Edge/.test(navigator.userAgent);
function whenReady(callback, doc) { function whenReady(callback, doc) {
doc = doc || rootDocument; doc = doc || rootDocument;
whenDocumentReady(function() { whenDocumentReady(function() {
@ -5435,12 +5435,7 @@ HTMLImports.addModule(function(scope) {
}, },
addElementToDocument: function(elt) { addElementToDocument: function(elt) {
var port = this.rootImportForElement(elt.__importElement || elt); var port = this.rootImportForElement(elt.__importElement || elt);
var l = port.__insertedElements = port.__insertedElements || 0; port.parentNode.insertBefore(elt, port);
var refNode = port.nextElementSibling;
for (var i = 0; i < l; i++) {
refNode = refNode && refNode.nextElementSibling;
}
port.parentNode.insertBefore(elt, refNode);
}, },
trackElement: function(elt, callback) { trackElement: function(elt, callback) {
var self = this; var self = this;
@ -5620,7 +5615,9 @@ HTMLImports.addModule(function(scope) {
var base = doc.createElement("base"); var base = doc.createElement("base");
base.setAttribute("href", url); base.setAttribute("href", url);
if (!doc.baseURI) { if (!doc.baseURI) {
doc.baseURI = url; Object.defineProperty(doc, "baseURI", {
value: url
});
} }
var meta = doc.createElement("meta"); var meta = doc.createElement("meta");
meta.setAttribute("charset", "utf-8"); meta.setAttribute("charset", "utf-8");
@ -5679,16 +5676,19 @@ HTMLImports.addModule(function(scope) {
}); });
(function(scope) { (function(scope) {
initializeModules = scope.initializeModules; var initializeModules = scope.initializeModules;
var isIE = scope.isIE;
if (scope.useNative) { if (scope.useNative) {
return; return;
} }
if (typeof window.CustomEvent !== "function") { if (isIE && typeof window.CustomEvent !== "function") {
window.CustomEvent = function(inType, dictionary) { window.CustomEvent = function(inType, params) {
var e = document.createEvent("HTMLEvents"); params = params || {};
e.initEvent(inType, dictionary.bubbles === false ? false : true, dictionary.cancelable === false ? false : true, dictionary.detail); var e = document.createEvent("CustomEvent");
e.initCustomEvent(inType, Boolean(params.bubbles), Boolean(params.cancelable), params.detail);
return e; return e;
}; };
window.CustomEvent.prototype = window.Event.prototype;
} }
initializeModules(); initializeModules();
var rootDocument = scope.rootDocument; var rootDocument = scope.rootDocument;
@ -6226,6 +6226,7 @@ CustomElements.addModule(function(scope) {
(function(scope) { (function(scope) {
var useNative = scope.useNative; var useNative = scope.useNative;
var initializeModules = scope.initializeModules; var initializeModules = scope.initializeModules;
var isIE11OrOlder = /Trident/.test(navigator.userAgent);
if (useNative) { if (useNative) {
var nop = function() {}; var nop = function() {};
scope.watchShadow = nop; scope.watchShadow = nop;
@ -6269,7 +6270,7 @@ CustomElements.addModule(function(scope) {
})); }));
}); });
} }
if (typeof window.CustomEvent !== "function") { if (isIE11OrOlder && typeof window.CustomEvent !== "function") {
window.CustomEvent = function(inType, params) { window.CustomEvent = function(inType, params) {
params = params || {}; params = params || {};
var e = document.createEvent("CustomEvent"); var e = document.createEvent("CustomEvent");

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,7 @@
window.onload = function(){ window.onload = function(){
window.x = document.querySelector("yatta-test"); window.x = document.querySelector("yatta-test");
x.yatta.val("stuff",{otherstuff:{nostuff:"this is no stuff"}}) x.yatta.val("stuff",{otherstuff:{nostuff:"this is no stuff"}});
setTimeout(function(){ setTimeout(function(){
var res = x.yatta.val("stuff"); var res = x.yatta.val("stuff");
if(!(x.nostuff.val() === "this is no stuff")){ if(!(x.nostuff.val() === "this is no stuff")){

View File

@ -1,6 +1,7 @@
setTimeout(function(){ setTimeout(function(){
window.x = document.querySelector("yatta-test"); window.x = document.querySelector("yatta-test");
// x.yatta.HB.stopGarbageCollection();
x.yatta.val("stuff",{otherstuff:{nostuff:"this is no stuff"}}) x.yatta.val("stuff",{otherstuff:{nostuff:"this is no stuff"}})
setTimeout(function(){ setTimeout(function(){
var res = x.yatta.val("stuff"); var res = x.yatta.val("stuff");

View File

@ -11,23 +11,38 @@ adaptConnector = (connector, engine, HB, execution_listener)->
connector.broadcast o connector.broadcast o
execution_listener.push send_ execution_listener.push send_
# For the XMPPConnector: lets send it as an array
# therefore, we have to restructure it later
encode_state_vector = (v)->
for name,value of v
user: name
state: value
parse_state_vector = (v)->
state_vector = {}
for s in v
state_vector[s.user] = s.state
state_vector
sendStateVector = ()-> sendStateVector = ()->
HB.getOperationCounter() encode_state_vector HB.getOperationCounter()
sendHb = (state_vector)->
json = HB._encode(state_vector) sendHb = (v)->
if json.length > 0 state_vector = parse_state_vector v
json json =
else hb: HB._encode(state_vector)
null state_vector: encode_state_vector HB.getOperationCounter()
applyHb = (hb)-> json
if hb?
engine.applyOpsCheckDouble hb applyHb = (res)->
else HB.renewStateVector parse_state_vector res.state_vector
null engine.applyOpsCheckDouble res.hb
connector.whenSyncing sendStateVector, sendHb, applyHb connector.whenSyncing sendStateVector, sendHb, applyHb
connector.whenReceiving (sender, op)-> connector.whenReceiving (sender, op)->
if op.uid.creator isnt HB.getUserId() if op.uid.creator isnt HB.getUserId()
engine.applyOp op engine.applyOp op
HB.setInvokeSyncHandler connector.invokeSync
module.exports = adaptConnector module.exports = adaptConnector

View File

@ -30,7 +30,7 @@ class Engine
# #
# Apply a set of operations. E.g. the operations you received from another users HB._encode(). # Apply a set of operations. E.g. the operations you received from another users HB._encode().
# @note You must not use this method when you already have ops in your HB! # @note You must not use this method when you already have ops in your HB!
# ###
applyOpsBundle: (ops_json)-> applyOpsBundle: (ops_json)->
ops = [] ops = []
for o in ops_json for o in ops_json
@ -39,6 +39,7 @@ class Engine
if not o.execute() if not o.execute()
@unprocessed_ops.push o @unprocessed_ops.push o
@tryUnprocessed() @tryUnprocessed()
###
# #
# Same as applyOps but operations that are already in the HB are not applied. # Same as applyOps but operations that are already in the HB are not applied.
@ -53,22 +54,25 @@ class Engine
# Apply a set of operations. (Helper for using applyOp on Arrays) # Apply a set of operations. (Helper for using applyOp on Arrays)
# @see Engine.applyOp # @see Engine.applyOp
applyOps: (ops_json)-> applyOps: (ops_json)->
for o in ops_json @applyOp ops_json
@applyOp o
# #
# Apply an operation that you received from another peer. # Apply an operation that you received from another peer.
# # TODO: make this more efficient!!
applyOp: (op_json)-> # - operations may only executed in order by creator, order them in object of arrays (key by creator)
# $parse_and_execute will return false if $o_json was parsed and executed, otherwise the parsed operadion # - you can probably make something like dependencies (creator1 waits for creator2)
o = @parseOperation op_json applyOp: (op_json_array)->
@HB.addToCounter o if op_json_array.constructor isnt Array
# @HB.addOperation o op_json_array = [op_json_array]
if @HB.getOperation(o)? for op_json in op_json_array
else if not o.execute() # $parse_and_execute will return false if $o_json was parsed and executed, otherwise the parsed operadion
@unprocessed_ops.push o o = @parseOperation op_json
window?.unprocessed_counter++ # TODO: del this # @HB.addOperation o
window?.unprocessed_types.push o.type if @HB.getOperation(o)?
# nop
else if (not @HB.isExpectedOperation(o)) or (not o.execute())
@unprocessed_ops.push o
window?.unprocessed_types.push o.type # TODO: delete this
@tryUnprocessed() @tryUnprocessed()
# #
@ -77,18 +81,18 @@ class Engine
# #
tryUnprocessed: ()-> tryUnprocessed: ()->
while true while true
window?.unprocessed_exec_counter++ # TODO: del this
old_length = @unprocessed_ops.length old_length = @unprocessed_ops.length
unprocessed = [] unprocessed = []
for op in @unprocessed_ops for op in @unprocessed_ops
if @HB.getOperation(op)? if @HB.getOperation(op)?
else if not op.execute() # nop
else if (not @HB.isExpectedOperation(op)) or (not op.execute())
unprocessed.push op unprocessed.push op
@unprocessed_ops = unprocessed @unprocessed_ops = unprocessed
if @unprocessed_ops.length is old_length if @unprocessed_ops.length is old_length
break break
if @unprocessed_ops.length isnt 0
@HB.invokeSync()
module.exports = Engine module.exports = Engine

View File

@ -18,7 +18,7 @@ class HistoryBuffer
@garbage = [] # Will be cleaned on next call of garbageCollector @garbage = [] # Will be cleaned on next call of garbageCollector
@trash = [] # Is deleted. Wait until it is not used anymore. @trash = [] # Is deleted. Wait until it is not used anymore.
@performGarbageCollection = true @performGarbageCollection = true
@garbageCollectTimeout = 30000 @garbageCollectTimeout = 2000
@reserved_identifier_counter = 0 @reserved_identifier_counter = 0
setTimeout @emptyGarbage, @garbageCollectTimeout setTimeout @emptyGarbage, @garbageCollectTimeout
@ -96,6 +96,10 @@ class HistoryBuffer
else else
@operation_counter[user_id] @operation_counter[user_id]
isExpectedOperation: (o)->
@operation_counter[o.uid.creator] ?= 0
o.uid.op_number <= @operation_counter[o.uid.creator]
# #
# Encode this operation in such a way that it can be parsed by remote peers. # Encode this operation in such a way that it can be parsed by remote peers.
# TODO: Make this more efficient! # TODO: Make this more efficient!
@ -162,14 +166,31 @@ class HistoryBuffer
@buffer[o.uid.creator] = {} @buffer[o.uid.creator] = {}
if @buffer[o.uid.creator][o.uid.op_number]? if @buffer[o.uid.creator][o.uid.op_number]?
throw new Error "You must not overwrite operations!" throw new Error "You must not overwrite operations!"
if (o.uid.op_number.constructor isnt String) and (not @isExpectedOperation(o)) # you already do this in the engine, so delete it here!
throw new Error "this operation was not expected!"
@addToCounter(o)
@buffer[o.uid.creator][o.uid.op_number] = o @buffer[o.uid.creator][o.uid.op_number] = o
@number_of_operations_added_to_HB ?= 0 # TODO: Debug, remove this
@number_of_operations_added_to_HB++
o o
removeOperation: (o)-> removeOperation: (o)->
delete @buffer[o.uid.creator]?[o.uid.op_number] delete @buffer[o.uid.creator]?[o.uid.op_number]
# When the HB determines inconsistencies, then the invokeSync
# handler wil be called, which should somehow invoke the sync with another collaborator.
# The parameter of the sync handler is the user_id with wich an inconsistency was determined
setInvokeSyncHandler: (f)->
@invokeSync = f
# empty per default # TODO: do i need this?
invokeSync: ()->
# after you received the HB of another user (in the sync process),
# you renew your own state_vector to the state_vector of the other user
renewStateVector: (state_vector)->
for user,state of state_vector
if (not @operation_counter[user]?) or (@operation_counter[user] < state_vector[user])
@operation_counter[user] = state_vector[user]
# #
# Increment the operation_counter that defines the current state of the Engine. # Increment the operation_counter that defines the current state of the Engine.
# #
@ -177,13 +198,11 @@ class HistoryBuffer
if not @operation_counter[o.uid.creator]? if not @operation_counter[o.uid.creator]?
@operation_counter[o.uid.creator] = 0 @operation_counter[o.uid.creator] = 0
if typeof o.uid.op_number is 'number' and o.uid.creator isnt @getUserId() if typeof o.uid.op_number is 'number' and o.uid.creator isnt @getUserId()
# TODO: fix this issue better. # TODO: check if operations are send in order
# Operations should income in order
# Then you don't have to do this..
if o.uid.op_number is @operation_counter[o.uid.creator] if o.uid.op_number is @operation_counter[o.uid.creator]
@operation_counter[o.uid.creator]++ @operation_counter[o.uid.creator]++
while @getOperation({creator:o.uid.creator, op_number: @operation_counter[o.uid.creator]})? else
@operation_counter[o.uid.creator]++ @invokeSync o.uid.creator
#if @operation_counter[o.uid.creator] isnt (o.uid.op_number + 1) #if @operation_counter[o.uid.creator] isnt (o.uid.op_number + 1)
#console.log (@operation_counter[o.uid.creator] - (o.uid.op_number + 1)) #console.log (@operation_counter[o.uid.creator] - (o.uid.op_number + 1))

View File

@ -413,7 +413,7 @@ module.exports = (HB)->
{ {
'type': "Replaceable" 'type': "Replaceable"
'content': @content?.getUid() 'content': @content?.getUid()
'ReplaceManager' : @parent.getUid() 'replace_manager' : @parent.getUid()
'prev': @prev_cl.getUid() 'prev': @prev_cl.getUid()
'next': @next_cl.getUid() 'next': @next_cl.getUid()
'uid' : @getUid() 'uid' : @getUid()
@ -425,7 +425,7 @@ module.exports = (HB)->
parser["Replaceable"] = (json)-> parser["Replaceable"] = (json)->
{ {
'content' : content 'content' : content
'ReplaceManager' : parent 'replace_manager' : parent
'uid' : uid 'uid' : uid
'prev': prev 'prev': prev
'next': next 'next': next

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long