diff --git a/gulpfile.js b/gulpfile.js index 76d9fd86..5bbafb84 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -70,23 +70,34 @@ var options = minimist(process.argv.slice(2), { }); var files = { - y: polyfills.concat(["src/y.js", "src/**/*.js", "!src/**/*.spec.js"]), + y: polyfills.concat(["src/y.js", "src/Connector.js", "src/OperationStore.js", "src/Struct.js", "src/**/*.js", "!src/**/*.spec.js"]), lint: ["src/**/*.js", "gulpfile.js"], test: polyfills.concat([options.testfiles]), build_test: ["build_test/y.js"] }; gulp.task("build", function () { - return gulp.src(files.y) + /*return gulp.src(files.y) .pipe(sourcemaps.init()) .pipe(concat(options.name)) .pipe(babel({ loose: "all", - modules: options.export + modules: options.export, + // blacklist: "regenerator" // you can't uglify when regenerator is blacklisted! })) .pipe(uglify()) .pipe(sourcemaps.write(".")) - .pipe(gulp.dest(".")); + .pipe(gulp.dest("."));*/ + return gulp.src(files.y) + .pipe(sourcemaps.init()) + .pipe(concat(options.name)) + .pipe(babel({ + loose: "all", + modules: "ignore", + blacklist: ["regenerator"] + })) + .pipe(sourcemaps.write()) + .pipe(gulp.dest(".")); }); gulp.task("lint", function(){ @@ -131,7 +142,7 @@ gulp.task("develop", ["build_jasmine_browser", "build"], function(){ gulp.watch(files.test, ["build_jasmine_browser"]); //gulp.watch(files.test, ["test"]); - //gulp.watch(files.test, ["build"]); + gulp.watch(files.test, ["build"]); return gulp.src("build/jasmine_browser.js") .pipe(watch("build/jasmine_browser.js")) diff --git a/src/Connector.js b/src/Connector.js index 9ca2710a..77cad2d8 100644 --- a/src/Connector.js +++ b/src/Connector.js @@ -113,6 +113,9 @@ class AbstractConnector { //eslint-disable-line no-unused-vars } // You received a raw message, and you know that it is intended for to Yjs. Then call this function. receiveMessage (sender, m){ + if (sender === this.userId) { + return; + } if (this.debug) { console.log(`${sender} -> ${this.userId}: ${JSON.stringify(m)}`); //eslint-disable-line } diff --git a/src/Connectors/WebRTC.js b/src/Connectors/WebRTC.js index 709ca1e9..575ee892 100644 --- a/src/Connectors/WebRTC.js +++ b/src/Connectors/WebRTC.js @@ -1,12 +1,14 @@ class WebRTC extends AbstractConnector { - constructor (options) { + constructor (y, options) { if(options === undefined){ throw new Error("Options must not be undefined!"); } - super({ - role: "slave" - }); + if(options.room == null) { + throw new Error("You must define a room name!"); + } + options.role = "slave"; + super(y, options); var room = options.room; @@ -25,12 +27,13 @@ class WebRTC extends AbstractConnector { swr.once("joinedRoom", function(){ self.setUserId(userId); + /* var i; // notify the connector class about all the users that already // joined the session for(i in self.swr.webrtc.peers){ self.userJoined(self.swr.webrtc.peers[i].id, "master"); - } + }*/ swr.on("channelMessage", function(peer, room_, message){ // The client received a message // Check if the connector is already initialized, diff --git a/src/OperationStore.js b/src/OperationStore.js index 1eda2c51..501759b3 100644 --- a/src/OperationStore.js +++ b/src/OperationStore.js @@ -93,7 +93,7 @@ class AbstractOperationStore { //eslint-disable-line no-unused-vars apply (ops) { for (var key in ops) { var o = ops[key]; - var required = Y.Struct[o.struct].requiredOps(o); + var required = Struct[o.struct].requiredOps(o); this.whenOperationsExist(required, o); } } diff --git a/src/OperationStores/Memory.js b/src/OperationStores/Memory.js index 8f705fe0..ab48773f 100644 --- a/src/OperationStores/Memory.js +++ b/src/OperationStores/Memory.js @@ -97,6 +97,9 @@ Y.Memory = (function(){ //eslint-disable-line no-unused-vars } *makeOperationReady (ss, op) { // instead of ss, you could use currSS (a ss that increments when you add an operation) + if (op.right == null) { + return op; + } var clock; var o = op; while (o.right != null){ diff --git a/src/Struct.spec b/src/Struct.spec.js similarity index 100% rename from src/Struct.spec rename to src/Struct.spec.js diff --git a/src/Types/Array.js b/src/Types/Array.js index b08aa4d9..d591b361 100644 --- a/src/Types/Array.js +++ b/src/Types/Array.js @@ -8,6 +8,7 @@ this._model = _model; // Array of all the operation id's this.idArray = idArray; + // Array of all the values this.valArray = valArray; this.eventHandler = new EventHandler( ops =>{ for (var i in ops) { diff --git a/src/Types/Map.js b/src/Types/Map.js index 7dd0ad93..7c5f977d 100644 --- a/src/Types/Map.js +++ b/src/Types/Map.js @@ -104,7 +104,11 @@ class EventHandler { // if property does not exist, return null // if property is a type, return a promise if (this.opContents[key] == null) { - return this.contents[key]; + if (key == null) { + return copyObject(this.contents); + } else { + return this.contents[key]; + } } else { let def = Promise.defer(); var oid = this.opContents[key];