From 6354cee838ae49f08d66f12ce55746000d7bef6d Mon Sep 17 00:00:00 2001 From: Ricardo Villarreal Date: Wed, 24 Aug 2016 14:41:59 -0700 Subject: [PATCH 01/16] EPICENTER-2129: update jQuery dependency to version 3 --- bower.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bower.json b/bower.json index c6028c03..24e2773d 100644 --- a/bower.json +++ b/bower.json @@ -16,7 +16,7 @@ "tests" ], "dependencies": { - "jquery": "~2.1.1", + "jquery": "~3.1.0", "cometd-jquery": "2.9.0" }, "devDependencies": {} From 6e26b102d07d99c0a1e35090ec7a7affc75cd062 Mon Sep 17 00:00:00 2001 From: Naren Ranjit Date: Wed, 7 Sep 2016 14:27:41 -0700 Subject: [PATCH 02/16] gitattributes --- .gitattributes | 1 + .gitignore | 1 + 2 files changed, 2 insertions(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..967a087a --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +dist/* binary \ No newline at end of file diff --git a/.gitignore b/.gitignore index fa5e5267..367bd67d 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ pids !.bowerrc !.gitignore !.jscsrc +!.gitattributes # sass .sass-cache/ From 235a561096ba7860d5b84715701d0ec00745a9d6 Mon Sep 17 00:00:00 2001 From: Naren Ranjit Date: Thu, 15 Sep 2016 13:12:25 -0700 Subject: [PATCH 03/16] fix context issue --- src/managers/run-strategies/multiplayer-strategy.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/managers/run-strategies/multiplayer-strategy.js b/src/managers/run-strategies/multiplayer-strategy.js index cb118a6c..40c42420 100644 --- a/src/managers/run-strategies/multiplayer-strategy.js +++ b/src/managers/run-strategies/multiplayer-strategy.js @@ -60,7 +60,7 @@ var Strategy = classFrom(IdentityStrategy, { var serverError = function (error) { // is this possible? - dtd.reject(error, session, this.options); + dtd.reject(error, session, _this.options); }; this.worldApi From 3dad06e4f6afb2dcc67cba463ef789f45652e7dc Mon Sep 17 00:00:00 2001 From: Naren Ranjit Date: Thu, 15 Sep 2016 13:32:00 -0700 Subject: [PATCH 04/16] fix error by checking with callback --- tests/spec/test-variables-api-service.js | 77 ++++++++++++------------ 1 file changed, 40 insertions(+), 37 deletions(-) diff --git a/tests/spec/test-variables-api-service.js b/tests/spec/test-variables-api-service.js index 23d69893..fc1b172c 100644 --- a/tests/spec/test-variables-api-service.js +++ b/tests/spec/test-variables-api-service.js @@ -47,7 +47,7 @@ xhr.respond(200, { 'Content-Type': 'application/json' }, JSON.stringify(variablesCD)); return true; }); - server.autoRespond = true; + server.respondImmediately = true; rs = new RunService({ account: account, project: project }); vs = rs.variables(); @@ -68,14 +68,14 @@ }); it('should use the right url', function () { vs.load('price'); - server.respond(); + // server.respond(); var req = server.requests.pop(); req.url.should.equal(baseURL + ';/variables/price/'); }); it('should not add the autorestore run flag', function () { vs.load('price'); - server.respond(); + // server.respond(); var req = server.requests.pop(); req.requestHeaders.should.not.have.property('X-AutoRestore'); @@ -84,7 +84,7 @@ var rs = new RunService({ account: account, project: 'js-libs', filter: 'myfancyrunid' }); var vs = rs.variables(); vs.load('price'); - server.respond(); + // server.respond(); var req = server.requests.pop(); req.requestHeaders.should.have.property('X-AutoRestore', true); @@ -93,7 +93,7 @@ var rs = new RunService({ account: account, project: 'js-libs', filter: 'myfancyrunid', autoRestore: false }); var vs = rs.variables(); vs.load('price'); - server.respond(); + // server.respond(); var req = server.requests.pop(); req.requestHeaders.should.not.have.property('X-AutoRestore'); @@ -103,28 +103,28 @@ describe('#query()', function () { it('should do a GET', function () { vs.query(['price', 'sales']); - server.respond(); + // server.respond(); var req = server.requests.pop(); req.method.toUpperCase().should.equal('GET'); }); it('should convert includes', function () { vs.query({ include: ['price', 'sales'] }); - server.respond(); + // server.respond(); var req = server.requests.pop(); req.url.should.equal(baseURL + ';/variables/?include=price,sales'); }); it('should convert sets', function () { vs.query({ set: 'a' }); - server.respond(); + // server.respond(); var req = server.requests.pop(); req.url.should.equal(baseURL + ';/variables/?set=a'); }); it('should convert sets & includes', function () { vs.query({ set: ['a', 'b'], include: 'price' }); - server.respond(); + // server.respond(); var req = server.requests.pop(); req.url.should.equal(baseURL + ';/variables/?set=a,b&include=price'); @@ -134,7 +134,7 @@ var include = createLargeInclude(); vs.query(include); - server.respond(); + // server.respond(); server.requests.length.should.be.above(1); server.requests.forEach(function (xhr) { xhr.url.length.should.be.below(2048); @@ -142,24 +142,27 @@ server.requests = []; }); it('should aggregate the response from the multiple GETs from the variables API', function () { - server.requests = []; - var done = sinon.spy(); - var fail = sinon.spy(); + var success = sinon.spy(); + var fail = sinon.spy(function () { + console.log('failll'); + }); var rs = new RunService({ account: account, project: project }); var include = createLargeInclude(); include.push('variables_c_d'); include = ['variables_a_b'].concat(include); - rs.query({}, { include: include }).done(done).fail(fail); - server.respond(); - done.should.have.been.calledWith({ - 'varA': 'Value A', - 'varB': 0.0001, - 'varC': 'Another string for run1', - 'varD': '2015-11-16 10:10:10' - }); - fail.should.not.have.been.called; - server.requests = []; + return rs.query({}, { include: include }) + .then(success) + .fail(fail) + .then(function () { + success.should.have.been.calledWith({ + varA: 'Value A', + varB: 0.0001, + varC: 'Another string for run1', + varD: '2015-11-16 10:10:10' + }); + fail.should.not.have.been.called; + }); }); it('the multiple GETs encoded urls length should not be larger than 2048', function () { server.requests = []; @@ -174,7 +177,7 @@ }); it('should not add the autorestore run flag', function () { vs.query({ set: ['a', 'b'], include: 'price' }); - server.respond(); + // server.respond(); var req = server.requests.pop(); req.requestHeaders.should.not.have.property('X-AutoRestore'); @@ -183,7 +186,7 @@ var rs = new RunService({ account: account, project: 'js-libs', filter: 'myfancyrunid' }); var vs = rs.variables(); vs.query({ set: ['a', 'b'], include: 'price' }); - server.respond(); + // server.respond(); var req = server.requests.pop(); req.requestHeaders.should.have.property('X-AutoRestore', true); @@ -192,7 +195,7 @@ var rs = new RunService({ account: account, project: 'js-libs', filter: 'myfancyrunid', autoRestore: false }); var vs = rs.variables(); vs.query({ set: ['a', 'b'], include: 'price' }); - server.respond(); + // server.respond(); var req = server.requests.pop(); req.requestHeaders.should.not.have.property('X-AutoRestore'); @@ -204,7 +207,7 @@ // Temporarily using PATCH to mean PUT // it('should do a PUT', function () { // vs.save({ a: 1, b: 2 }); - // server.respond(); + // server.respond(); // var req = server.requests.pop(); @@ -213,7 +216,7 @@ it('should do a PATCH', function () { vs.save({ a: 1, b: 2 }); - server.respond(); + // server.respond(); var req = server.requests.pop(); @@ -223,7 +226,7 @@ it('should send requests in the body', function () { var params = { a: 1, b: 2 }; vs.save(params); - server.respond(); + // server.respond(); var req = server.requests.pop(); @@ -232,7 +235,7 @@ }); it('should support setting key, value syntax', function () { vs.save('a', 1); - server.respond(); + // server.respond(); var req = server.requests.pop(); req.url.should.equal(baseURL + ';/variables/'); @@ -243,7 +246,7 @@ // describe('#merge()', function () { // it('should do a PATCH', function () { // vs.merge({ a: 1, b: 2 }); - // server.respond(); + // server.respond(); // var req = server.requests.pop(); // req.method.toUpperCase().should.equal('PATCH'); @@ -252,7 +255,7 @@ // it('should send requests in the body', function () { // var params = { a: 1, b: 2 }; // vs.merge(params); - // server.respond(); + // server.respond(); // var req = server.requests.pop(); // req.url.should.equal(baseURL + ';/variables/'); @@ -261,7 +264,7 @@ // it('should support setting key, value syntax', function () { // vs.merge('a', 1); - // server.respond(); + // server.respond(); // var req = server.requests.pop(); // req.url.should.equal(baseURL + ';/variables/'); @@ -275,7 +278,7 @@ var cb1 = sinon.spy(); vs.load('sales', null, { success: cb1 }); - server.respond(); + // server.respond(); cb1.called.should.equal(true); }); }); @@ -284,7 +287,7 @@ var cb1 = sinon.spy(); vs.query({ include: ['price', 'sales'] }, null, { success: cb1 }); - server.respond(); + // server.respond(); cb1.called.should.equal(true); }); }); @@ -295,7 +298,7 @@ vs.save({ a: 1, b: 2 }, { success: cb1 }); vs.save('a', 1, { success: cb2 }); - server.respond(); + // server.respond(); cb1.called.should.equal(true); cb2.called.should.equal(true); }); @@ -307,7 +310,7 @@ // vs.merge({ a: 1, b: 2 }, { success: cb1 }); // vs.merge('a', 1, { success: cb2 }); - // server.respond(); + // server.respond(); // cb1.called.should.equal(true); // cb2.called.should.equal(true); // }); From faf53c7fd6ae8d31a06c9838aee0f2680656a6d2 Mon Sep 17 00:00:00 2001 From: Naren Ranjit Date: Thu, 15 Sep 2016 13:41:31 -0700 Subject: [PATCH 05/16] passing tests --- tests/spec/test-asset-api-adapter.js | 36 +++++++++++++--------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/tests/spec/test-asset-api-adapter.js b/tests/spec/test-asset-api-adapter.js index fe85d04f..b5bc9020 100644 --- a/tests/spec/test-asset-api-adapter.js +++ b/tests/spec/test-asset-api-adapter.js @@ -25,7 +25,7 @@ server.respondWith('POST', /(.*)\/asset\/(.*)\/(.*)/, function (xhr, id) { xhr.respond(204); }); - server.autoRespond = true; + server.respondImmediately = true; }); after(function () { @@ -177,29 +177,27 @@ it('should get the list of the assets for the user', function () { var callback = sinon.spy(); var aa = new F.service.Asset(defaults); - aa.list({ scope: 'user', fullUrl: false }).done(callback); - - server.respond(); - var req = server.requests.pop(); - req.url.should.equal(baseURL + 'user/forio/js-libs/asset-group/myUserId'); - req.method.should.equal('GET'); - callback.should.have.been.called; - callback.should.have.been.calledWith(['file.txt', 'file2.txt']); + return aa.list({ scope: 'user', fullUrl: false }).then(callback).then(function () { + var req = server.requests.pop(); + req.url.should.equal(baseURL + 'user/forio/js-libs/asset-group/myUserId'); + req.method.should.equal('GET'); + callback.should.have.been.called; + callback.should.have.been.calledWith(['file.txt', 'file2.txt']); + }); }); it('should get the list of the assets for the user with the full URL', function () { var callback = sinon.spy(); var aa = new F.service.Asset(defaults); - aa.list({ scope: 'user' }).done(callback); - - server.respond(); - var req = server.requests.pop(); - req.url.should.equal(baseURL + 'user/forio/js-libs/asset-group/myUserId'); - req.method.should.equal('GET'); - callback.should.have.been.called; - callback.should.have.been.calledWith([ - baseURL + 'user/forio/js-libs/asset-group/myUserId/file.txt', - baseURL + 'user/forio/js-libs/asset-group/myUserId/file2.txt']); + return aa.list({ scope: 'user' }).then(callback).then(function () { + var req = server.requests.pop(); + req.url.should.equal(baseURL + 'user/forio/js-libs/asset-group/myUserId'); + req.method.should.equal('GET'); + callback.should.have.been.called; + callback.should.have.been.calledWith([ + baseURL + 'user/forio/js-libs/asset-group/myUserId/file.txt', + baseURL + 'user/forio/js-libs/asset-group/myUserId/file2.txt']); + }); }); }); From e631d6b09f7e487c56e5baeef308fa0949e76e64 Mon Sep 17 00:00:00 2001 From: Naren Ranjit Date: Thu, 15 Sep 2016 14:06:03 -0700 Subject: [PATCH 06/16] passing tests --- tests/spec/test-run-api-service-callbacks.js | 159 +++++++++---------- 1 file changed, 71 insertions(+), 88 deletions(-) diff --git a/tests/spec/test-run-api-service-callbacks.js b/tests/spec/test-run-api-service-callbacks.js index 1d83c8cb..5a40684b 100644 --- a/tests/spec/test-run-api-service-callbacks.js +++ b/tests/spec/test-run-api-service-callbacks.js @@ -30,7 +30,7 @@ xhr.respond(400, { 'Content-Type': 'application/json' }, JSON.stringify({ url: xhr.url })); }); - server.autoRespond = true; + server.respondImmediately = true; }); after(function () { @@ -43,11 +43,10 @@ var cb2 = sinon.spy(); var rs = new RunService({ account: 'forio', project: 'js-libs', filter: { saved: true } }); - rs.do('add', [1,2], { success: cb1 }).then(cb2); - server.respond(); - - cb1.should.have.been.called; - cb2.should.have.been.called; + return rs.do('add', [1,2], { success: cb1 }).then(cb2).then( function () { + cb1.should.have.been.called; + cb2.should.have.been.called; + }); }); it('passes error callbacks', function () { var cb1 = sinon.spy(); @@ -56,12 +55,11 @@ var rs = new RunService({ account: 'failure', project: 'js-libs', filter: { saved: true } }); - rs.do('add', [1,2], { error: cb1 }).fail(cb3); - server.respond(); - - cb1.should.have.been.called; - cb2.should.not.have.been.called; - cb3.should.have.been.called; + return rs.do('add', [1,2], { error: cb1 }).then(null, cb3).then(null, function () { + cb1.should.have.been.called; + cb2.should.not.have.been.called; + cb3.should.have.been.called; + }); }); }); describe('#serial', function () { @@ -70,12 +68,10 @@ var cb2 = sinon.spy(); var rs = new RunService({ account: 'forio', project: 'js-libs', filter: { saved: true } }); - rs.serial([{ first: [1,2] }, { second: [2,3] }], null, { success: cb1 }).then(cb2); - server.respond(); - server.respond(); - - cb1.should.have.been.called; - cb2.should.have.been.called; + return rs.serial([{ first: [1,2] }, { second: [2,3] }], null, { success: cb1 }).then(cb2).then(function () { + cb1.should.have.been.called; + cb2.should.have.been.called; + }); }); it('passes error callbacks', function () { var cb1 = sinon.spy(); @@ -83,12 +79,11 @@ var cb3 = sinon.spy(); var rs = new RunService({ account: 'failure', project: 'js-libs', filter: { saved: true } }); - rs.serial([{ first: [1,2] }, { second: [2,3] }], null, { error: cb1 }).fail(cb3); - server.respond(); - - cb1.should.have.been.called; - cb2.should.not.have.been.called; - cb3.should.have.been.called; + return rs.serial([{ first: [1,2] }, { second: [2,3] }], null, { error: cb1 }).then(null, cb3).then(function () { + cb1.should.have.been.called; + cb2.should.not.have.been.called; + cb3.should.have.been.called; + }); }); }); describe('#parallel', function () { @@ -98,11 +93,10 @@ var rs = new RunService({ account: 'forio', project: 'js-libs', filter: { saved: true } }); - rs.parallel([{ first: [1,2] }, { second: [2,3] }], null, { success: cb1 }).then(cb2); - server.respond(); - - cb1.should.have.been.called; - cb2.should.have.been.called; + return rs.parallel([{ first: [1,2] }, { second: [2,3] }], null, { success: cb1 }).then(cb2).then(function () { + cb1.should.have.been.called; + cb2.should.have.been.called; + }); }); it('passes error callbacks', function () { var cb1 = sinon.spy(); @@ -111,12 +105,11 @@ var rs = new RunService({ account: 'failure', project: 'js-libs', filter: { saved: true } }); - rs.parallel([{ first: [1,2] }, { second: [2,3] }], null, { error: cb1 }).fail(cb3); - server.respond(); - - cb1.should.have.been.called; - cb2.should.not.have.been.called; - cb3.should.have.been.called; + return rs.parallel([{ first: [1,2] }, { second: [2,3] }], null, { error: cb1 }).then(null, cb3).then(function () { + cb1.should.have.been.called; + cb2.should.not.have.been.called; + cb3.should.have.been.called; + }); }); }); @@ -126,11 +119,10 @@ var cb2 = sinon.spy(); var rs = new RunService({ account: 'forio', project: 'js-libs' }); - rs.create('model.jl', { success: cb1 }).then(cb2); - server.respond(); - - cb1.should.have.been.called; - cb2.should.have.been.called; + return rs.create('model.jl', { success: cb1 }).then(cb2).then(function () { + cb1.should.have.been.called; + cb2.should.have.been.called; + }); }); it('passes error callbacks', function () { var cb1 = sinon.spy(); @@ -139,12 +131,11 @@ var rs = new RunService({ account: 'failure', project: 'js-libs' }); - rs.create('model.jl', { error: cb1 }).fail(cb3); - server.respond(); - - cb1.should.have.been.called; - cb2.should.not.have.been.called; - cb3.should.have.been.called; + return rs.create('model.jl', { error: cb1 }).then(null, cb3).then(function () { + cb1.should.have.been.called; + cb2.should.not.have.been.called; + cb3.should.have.been.called; + }); }); }); describe('#query', function () { @@ -153,10 +144,10 @@ var cb2 = sinon.spy(); var rs = new RunService({ account: 'forio', project: 'js-libs' }); - rs.query({ saved: true, '.price': '>1' }, { page: 1 }, { success: cb1 }).then(cb2); - server.respond(); + return rs.query({ saved: true, '.price': '>1' }, { page: 1 }, { success: cb1 }).then(cb2).then(function () { + cb1.should.have.been.called; - cb1.should.have.been.called; + }); }); it('passes error callbacks', function () { var cb1 = sinon.spy(); @@ -165,12 +156,11 @@ var rs = new RunService({ account: 'failure', project: 'js-libs' }); - rs.query({ saved: true, '.price': '>1' }, { page: 1 }, { error: cb1 }).fail(cb3); - server.respond(); - - cb1.should.have.been.called; - cb2.should.not.have.been.called; - cb3.should.have.been.called; + return rs.query({ saved: true, '.price': '>1' }, { page: 1 }, { error: cb1 }).then(null, cb3).then(function () { + cb1.should.have.been.called; + cb2.should.not.have.been.called; + cb3.should.have.been.called; + }); }); }); describe('#filter', function () { @@ -179,10 +169,9 @@ var cb2 = sinon.spy(); var rs = new RunService({ account: 'forio', project: 'js-libs' }); - rs.filter({ saved: true, '.price': '>1' }, { page: 1 }, { success: cb1 }).then(cb2); - server.respond(); - - cb1.should.have.been.called; + return rs.filter({ saved: true, '.price': '>1' }, { page: 1 }, { success: cb1 }).then(cb2).then(function () { + cb1.should.have.been.called; + }); }); it('passes error callbacks', function () { var cb1 = sinon.spy(); @@ -191,12 +180,11 @@ var rs = new RunService({ account: 'failure', project: 'js-libs' }); - rs.filter({ saved: true, '.price': '>1' }, { page: 1 }, { error: cb1 }).fail(cb3); - server.respond(); - - cb1.should.have.been.called; - cb2.should.not.have.been.called; - cb3.should.have.been.called; + return rs.filter({ saved: true, '.price': '>1' }, { page: 1 }, { error: cb1 }).then(null, cb3).then(function () { + cb1.should.have.been.called; + cb2.should.not.have.been.called; + cb3.should.have.been.called; + }); }); }); describe('#load', function () { @@ -204,11 +192,10 @@ var cb1 = sinon.spy(); var cb2 = sinon.spy(); var rs = new RunService({ account: 'forio', project: 'js-libs' }); - rs.load('myfancyrunid', { include: 'score' }, { success: cb1 }).then(cb2); - server.respond(); - - cb1.should.have.been.called; - cb2.should.have.been.called; + return rs.load('myfancyrunid', { include: 'score' }, { success: cb1 }).then(cb2).then(function () { + cb1.should.have.been.called; + cb2.should.have.been.called; + }); }); it('passes error callbacks', function () { var cb1 = sinon.spy(); @@ -217,12 +204,11 @@ var rs = new RunService({ account: 'failure', project: 'js-libs' }); - rs.load('myfancyrunid', { include: 'score' }, { error: cb1 }).fail(cb3); - server.respond(); - - cb1.should.have.been.called; - cb2.should.not.have.been.called; - cb3.should.have.been.called; + return rs.load('myfancyrunid', { include: 'score' }, { error: cb1 }).then(null, cb3).then(function () { + cb1.should.have.been.called; + cb2.should.not.have.been.called; + cb3.should.have.been.called; + }); }); }); describe('#save', function () { @@ -231,11 +217,10 @@ var cb2 = sinon.spy(); var rs = new RunService({ account: 'forio', project: 'js-libs', filter: { saved: true } }); - rs.save({ completed: true }, { success: cb1 }).then(cb2); - server.respond(); - - cb1.should.have.been.called; - cb2.should.have.been.called; + return rs.save({ completed: true }, { success: cb1 }).then(cb2).then(function () { + cb1.should.have.been.called; + cb2.should.have.been.called; + }); }); it('passes error callbacks', function () { var cb1 = sinon.spy(); @@ -244,14 +229,12 @@ var rs = new RunService({ account: 'failure', project: 'js-libs', filter: { saved: true } }); - rs.save({ completed: true }, { error: cb1 }).fail(cb3); - server.respond(); - - cb1.should.have.been.called; - cb2.should.not.have.been.called; - cb3.should.have.been.called; + return rs.save({ completed: true }, { error: cb1 }).then(null, cb3).then(function () { + cb1.should.have.been.called; + cb2.should.not.have.been.called; + cb3.should.have.been.called; + }); }); }); - }); })(); From b5c0cd46be3b721e5e99db908a1ccbf890dceebd Mon Sep 17 00:00:00 2001 From: Naren Ranjit Date: Thu, 15 Sep 2016 14:11:25 -0700 Subject: [PATCH 07/16] passing tests --- tests/spec/test-run-api-service.js | 191 ++++++++++++----------------- 1 file changed, 81 insertions(+), 110 deletions(-) diff --git a/tests/spec/test-run-api-service.js b/tests/spec/test-run-api-service.js index c3813fb6..efad2073 100644 --- a/tests/spec/test-run-api-service.js +++ b/tests/spec/test-run-api-service.js @@ -18,7 +18,7 @@ return include; }; - describe('Run API Service', function () { + describe.only('Run API Service', function () { var server; before(function () { server = sinon.fakeServer.create(); @@ -133,9 +133,12 @@ xhr.respond(500, { 'Content-Type': 'application/json' }, JSON.stringify({ message: 'Internal server error' })); return true; }); - server.autoRespond = true; + server.respondImmediately = true; }); + afterEach(function () { + server.requests = []; + }); after(function () { server.restore(); }); @@ -165,24 +168,22 @@ it('should return promiseables', function () { var callback = sinon.spy(); var rs = new RunService({ account: account, project: project }); - rs + return rs .create('model.jl') - .then(callback); - - server.respond(); - - callback.should.have.been.called; - callback.should.have.been.calledWith({ - 'id': '065dfe50-d29d-4b55-a0fd-30868d7dd26c', - 'model': 'model.vmf', - 'account': 'mit', - 'project': 'afv', - 'saved': false, - 'lastModified': '2014-06-20T04:09:45.738Z', - 'created': '2014-06-20T04:09:45.738Z' + .then(callback) + .then(function () { + callback.should.have.been.called; + callback.should.have.been.calledWith({ + 'id': '065dfe50-d29d-4b55-a0fd-30868d7dd26c', + 'model': 'model.vmf', + 'account': 'mit', + 'project': 'afv', + 'saved': false, + 'lastModified': '2014-06-20T04:09:45.738Z', + 'created': '2014-06-20T04:09:45.738Z' + }); }); // callback.should.have.been.calledOn(rs); - }); describe('transport.options', function () { @@ -192,7 +193,6 @@ var rs = new RunService({ account: account, project: 'js-libs', transport: { beforeSend: beforeSend, complete: complete } }); rs.create('model.jl'); - server.respond(); beforeSend.should.have.been.called; complete.should.have.been.called; }); @@ -203,7 +203,6 @@ var rs = new RunService({ account: account, project: 'js-libs', transport: { complete: originalComplete } }); rs.create('model.jl', { complete: complete }); - server.respond(); originalComplete.should.not.have.been.called; complete.should.have.been.called; }); @@ -214,7 +213,6 @@ var rs = new RunService({ account: account, project: 'js-libs', transport: { complete: originalComplete } }); rs.create('model.jl', { complete: complete }); - server.respond(); originalComplete.should.not.have.been.called; complete.should.have.been.called; }); @@ -225,7 +223,6 @@ var rs = new RunService({ account: account, project: 'js-libs', success: originalSuccess, transport: { complete: transportSuccess } }); rs.create('model.jl'); - server.respond(); originalSuccess.should.have.been.called; transportSuccess.should.have.been.called; }); @@ -300,20 +297,13 @@ }); it('should be idempotent across multiple queries', function () { - server.requests = []; var rs = new RunService({ account: account, project: project }); - rs.query({ saved: true, '.price': '>1' }); - server.respond(); - - server.requests[0].url.should.equal(baseURL + ';saved=true;.price>1/'); - - - rs.query({ saved: false, '.sales': '<4' }); - server.respond(); - - server.requests[1].url.should.equal(baseURL + ';saved=false;.sales<4/'); - server.requests = []; - + return rs.query({ saved: true, '.price': '>1' }).then(function () { + return rs.query({ saved: false, '.sales': '<4' }).then(function () { + server.requests[0].url.should.equal(baseURL + ';saved=true;.price>1/'); + server.requests[1].url.should.equal(baseURL + ';saved=false;.sales<4/'); + }); + }); }); it('should convert op modifiers to query strings', function () { var rs = new RunService({ account: account, project: project }); @@ -323,94 +313,86 @@ req.url.should.equal(baseURL + ';/?page=1&limit=2'); }); it('should split the get in multiple GETs', function () { - server.requests = []; var rs = new RunService({ account: account, project: project }); var include = createLargeInclude(); rs.query({}, { include: include }); - //server.respond(); + server.respond(); server.requests.length.should.be.above(1); server.requests.forEach(function (xhr) { xhr.url.length.should.be.below(2049); }); - server.requests = []; }); it('should fail if one or more of the multiple GETs fail', function () { - server.requests = []; - var done = sinon.spy(); + var success = sinon.spy(); var fail = sinon.spy(); var rs = new RunService({ account: account, project: project }); var include = createLargeInclude(); include.push('internal_server_error'); - rs.query({}, { include: include }).then(done, fail); - server.respond(); - fail.should.have.been.called; - done.should.not.have.been.called; - server.requests = []; + return rs.query({}, { include: include }).then(success, fail).then(function () { + fail.should.have.been.called; + success.should.not.have.been.called; + }); }); it('should aggregate the response from the multiple GETs for a single run', function () { - server.requests = []; - var done = sinon.spy(); + var success = sinon.spy(); var fail = sinon.spy(); var rs = new RunService({ account: account, project: project }); var include = createLargeInclude(); include.push('single_variables_c_d'); include = ['single_variables_a_b'].concat(include); - rs.query({}, { include: include }).done(done).fail(fail); - server.respond(); - done.should.have.been.calledWith({ - 'id': '065dfe50-d29d-4b55-a0fd-30868d7dd26c', - 'model': 'model.vmf', - 'account': account, - 'project': 'js-libs', - 'saved': false, - 'lastModified': '2014-06-20T04:09:45.738Z', - 'created': '2014-06-20T04:09:45.738Z', - 'variables': { - 'varA': 9999.99, - 'varB': 'A string', - 'varC': 'Another string', - 'varD': 10.22, - } + return rs.query({}, { include: include }).then(success, fail).then(function () { + success.should.have.been.calledWith({ + 'id': '065dfe50-d29d-4b55-a0fd-30868d7dd26c', + 'model': 'model.vmf', + 'account': account, + 'project': 'js-libs', + 'saved': false, + 'lastModified': '2014-06-20T04:09:45.738Z', + 'created': '2014-06-20T04:09:45.738Z', + 'variables': { + 'varA': 9999.99, + 'varB': 'A string', + 'varC': 'Another string', + 'varD': 10.22, + } + }); + fail.should.not.have.been.called; }); - fail.should.not.have.been.called; - server.requests = []; }); it('should aggregate the reponse from the multiple GETs for a multiple runs', function () { - server.requests = []; - var done = sinon.spy(); + var success = sinon.spy(); var fail = sinon.spy(); var rs = new RunService({ account: account, project: project }); var include = createLargeInclude(); include.push('multiple_variables_c_d'); include = ['multiple_variables_a_b'].concat(include); - rs.query({}, { include: include }).done(done).fail(fail); - server.respond(); - done.should.have.been.calledWith([ - { - 'id': 'run1', - 'variables': { - 'varA': 1111.11, - 'varB': 'A string for run1', - 'varC': 'Another string for run1', - 'varD': '2015-11-16 10:10:10' - } - }, - { - 'id': 'run2', - 'variables': { - 'varA': 2222.22, - 'varB': 'A string for run2', - 'varC': 'Another string for run2', - 'varD': '2015-11-16 20:20:20' - } - }, - ]); - fail.should.not.have.been.called; - server.requests = []; + return rs.query({}, { include: include }).then(success, fail).then(function () { + success.should.have.been.calledWith([ + { + 'id': 'run1', + 'variables': { + 'varA': 1111.11, + 'varB': 'A string for run1', + 'varC': 'Another string for run1', + 'varD': '2015-11-16 10:10:10' + } + }, + { + 'id': 'run2', + 'variables': { + 'varA': 2222.22, + 'varB': 'A string for run2', + 'varC': 'Another string for run2', + 'varD': '2015-11-16 20:20:20' + } + }, + ]); + fail.should.not.have.been.called; + }); }); }); @@ -437,20 +419,16 @@ req.url.should.equal(baseURL + ';/?page=1&limit=2'); }); it('should pass through options across multiple queries', function () { - server.requests = []; var rs = new RunService({ account: account, project: project }); rs.filter({ saved: true, '.price': '>1' }); - server.respond(); server.requests[0].url.should.equal(baseURL + ';saved=true;.price>1/'); rs.filter({ saved: false, '.sales': '<4' }); - server.respond(); server.requests[1].url.should.equal(baseURL + ';saved=false;.price>1;.sales<4/'); - server.requests = []; }); it('should not include the AutoRestore header', function () { @@ -597,7 +575,6 @@ var rs = new RunService({ account: account, project: 'js-libs', filter: { saved: true } }); rs.do('init'); - server.respond(); var req = server.requests.pop(); req.url.should.equal(baseURL + ';saved=true/operations/init/'); req.requestBody.should.equal(JSON.stringify({ arguments: [] })); @@ -611,25 +588,21 @@ ret.should.throw(Error); }); - it('should send multiple operations calls once by one', function () { - server.requests = []; - + it.only('should send multiple operations calls one by one', function () { var rs = new RunService({ account: account, project: 'js-libs', filter: { saved: true } }); - rs.serial([{ first: [1,2] }, { second: [2,3] }]); - server.respond(); - - server.requests.length.should.equal(2); - server.requests[0].url.should.equal(baseURL + ';saved=true/operations/first/'); - server.requests[0].requestBody.should.equal(JSON.stringify({ arguments: [1,2] })); - - server.requests[1].url.should.equal(baseURL + ';saved=true/operations/second/'); - server.requests[1].requestBody.should.equal(JSON.stringify({ arguments: [2,3] })); + return rs.serial([{ first: [1, 2] }, { second: [2, 3] }]).then(function () { + server.requests.length.should.equal(2); + server.requests[0].url.should.equal(baseURL + ';saved=true/operations/first/'); + server.requests[0].requestBody.should.equal(JSON.stringify({ arguments: [1,2] })); + + server.requests[1].url.should.equal(baseURL + ';saved=true/operations/second/'); + server.requests[1].requestBody.should.equal(JSON.stringify({ arguments: [2,3] })); + }); }); it('should send operations without any parameters', function () { var rs = new RunService({ account: account, project: 'js-libs', filter: { saved: true } }); rs.serial(['init']); - server.respond(); var req = server.requests.pop(); req.url.should.equal(baseURL + ';saved=true/operations/init/'); @@ -645,11 +618,9 @@ }); it('should send multiple operations calls once by one', function () { - server.requests = []; var rs = new RunService({ account: account, project: 'js-libs', filter: { saved: true } }); rs.parallel([{ first: [1,2] }, { second: [2,3] }]); - server.respond(); server.requests.length.should.equal(2); }); From 175d5146ce1295b01bc7a19310479cb2b5b22ce7 Mon Sep 17 00:00:00 2001 From: Naren Ranjit Date: Thu, 15 Sep 2016 14:17:09 -0700 Subject: [PATCH 08/16] then => done --- tests/spec/test-auth-manager.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/tests/spec/test-auth-manager.js b/tests/spec/test-auth-manager.js index 9fbf5684..f34d0122 100644 --- a/tests/spec/test-auth-manager.js +++ b/tests/spec/test-auth-manager.js @@ -110,7 +110,7 @@ account: 'accountName', project: 'projectName', }); - am.login({ userName: 'test', password: 'test' }).done(function (response) { + am.login({ userName: 'test', password: 'test' }).then(function (response) { //jshint camelcase: false //jscs:disable response.auth.access_token.should.equal(token); @@ -126,7 +126,7 @@ account: 'accountName', project: 'projectName', }); - am.login({ userName: 'test', password: 'test' }).done(function (response) { + am.login({ userName: 'test', password: 'test' }).then(function (response) { var session = am.getCurrentUserSessionInfo(); session.groupName.should.equal('rv-test'); session.groupId.should.equal('111efcc9-726c-47b8-ba94-2895f110bd39'); @@ -147,7 +147,7 @@ account: 'accountName', project: 'projectName', }); - am.login({ userName: 'test', password: 'test' }).done(function (response) { + am.login({ userName: 'test', password: 'test' }).then(function (response) { multipleGroupsResponse = false; done(new Error('Login should not work')); }).fail(function (data) { @@ -163,7 +163,7 @@ account: 'accountName', project: 'projectName', }); - am.login({ userName: 'test', password: 'test', groupId: '111efcc9-726c-47b8-ba94-2895f110bd32' }).done(function (response) { + am.login({ userName: 'test', password: 'test', groupId: '111efcc9-726c-47b8-ba94-2895f110bd32' }).then(function (response) { var session = am.getCurrentUserSessionInfo(); session.groupName.should.equal('rv-test2'); multipleGroupsResponse = false; @@ -181,7 +181,7 @@ account: 'accountName', project: 'projectName', }); - am.login({ userName: 'test', password: 'test', groupId: 'wrong-id' }).done(function (response) { + am.login({ userName: 'test', password: 'test', groupId: 'wrong-id' }).then(function (response) { multipleGroupsResponse = false; done(new Error('Login should not work')); }).fail(function (data) { @@ -197,7 +197,7 @@ account: 'accountName', project: 'projectName', }); - am.login({ userName: 'test', password: 'test' }).done(function (response) { + am.login({ userName: 'test', password: 'test' }).then(function (response) { var req = server.requests.pop(); req.method.toUpperCase().should.equal('GET'); req.url.should.match(/https:\/\/api\.forio\.com\/group\/local\/?/); @@ -219,7 +219,7 @@ account: 'accountName', project: 'projectName', }); - am.login({ userName: 'test', password: 'test' }).done(function (response) { + am.login({ userName: 'test', password: 'test' }).then(function (response) { multipleGroupsResponse = false; teamMemberResponse = false; done(new Error('Login should not work')); @@ -248,7 +248,7 @@ domain: '.forio.com' } }); - am.logout().done(function (response) { + am.logout().then(function (response) { var spyCall = cookie.set.getCall(0); spyCall.args[0].should.match(/epicenterjs\.session=; expires=Thu, 01 Jan 1970 00:00:00 GMT; domain=\.forio\.com; path=\/app\/accountName\/projectName/); spyCall = cookie.set.getCall(1); @@ -292,7 +292,7 @@ project: 'projectName', userName: 'test', password: 'test', - }).done(function (response) { + }).then(function (response) { var pathIdx = cookie.get().indexOf('path=/app/accountName/projectName'); pathIdx.should.not.equal(-1); done(); @@ -310,7 +310,7 @@ account: 'accountName', project: 'projectName', }); - am.login({ userName: 'test', password: 'test' }).done(function (response) { + am.login({ userName: 'test', password: 'test' }).then(function (response) { var session = am.getCurrentUserSessionInfo(); Object.keys(session.groups).should.have.lengthOf(1); am.sessionManager.removeSession(); @@ -325,7 +325,7 @@ account: 'accountName', project: 'projectName', }); - am.login({ userName: 'test', password: 'test' }).done(function (response) { + am.login({ userName: 'test', password: 'test' }).then(function (response) { am.addGroups({ project: 'test-project', groupName: 'rv-test2', @@ -348,7 +348,7 @@ account: 'accountName', project: 'projectName', }); - am.login({ userName: 'test', password: 'test' }).done(function (response) { + am.login({ userName: 'test', password: 'test' }).then(function (response) { am.addGroups([{ project: 'test-project', groupName: 'rv-test2', @@ -376,7 +376,7 @@ account: 'accountName', project: 'projectName', }); - am.login({ userName: 'test', password: 'test' }).done(function (response) { + am.login({ userName: 'test', password: 'test' }).then(function (response) { am.addGroups([{ project: 'projectName', groupName: 'rv-test2', From 69fa7f8986c4eba44c073c048716ef5bc31a8b29 Mon Sep 17 00:00:00 2001 From: Naren Ranjit Date: Thu, 15 Sep 2016 14:18:51 -0700 Subject: [PATCH 09/16] done => then --- dist/components/assignment/assignment.js | 4 +- .../epicenter-multiplayer-dependencies.min.js | 2 +- ...center-multiplayer-dependencies.min.js.map | 2 +- src/components/assignment/js/assignment.js | 2 +- src/components/login/login.js | 2 - src/env-load.js | 4 +- src/managers/auth-manager.js | 2 +- src/service/run-api-service.js | 2 +- tests/integration/assets/assets-test.js | 8 +-- tests/integration/multiplayer/test-script.js | 2 +- tests/spec/test-multiplayer-strategy.js | 58 +++++++------------ tests/spec/test-run-api-service.js | 4 +- 12 files changed, 38 insertions(+), 54 deletions(-) diff --git a/dist/components/assignment/assignment.js b/dist/components/assignment/assignment.js index ddf61fed..369e2736 100644 --- a/dist/components/assignment/assignment.js +++ b/dist/components/assignment/assignment.js @@ -176,7 +176,7 @@ Assignment.prototype = { this._showUpdating(); var maxUsers = +this.$('#max-users').val(); return this.worlds.autoAssignAll({ maxUsers: maxUsers }) - .done(this._hideUpdating) + .then(this._hideUpdating) .fail(this._hideUpdating) .then(function () { this.worlds.joinUsers(); @@ -1231,4 +1231,4 @@ module.exports = function (base, props, staticProps) { }; },{}]},{},[6]) -//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9icm93c2VyLXBhY2svX3ByZWx1ZGUuanMiLCJzcmMvY29tcG9uZW50cy9hc3NpZ25tZW50L2pzL2Fzc2lnbm1lbnQtcm93LmpzIiwic3JjL2NvbXBvbmVudHMvYXNzaWdubWVudC9qcy9hc3NpZ25tZW50LmpzIiwic3JjL2NvbXBvbmVudHMvYXNzaWdubWVudC9qcy9iYXNlLWNvbGxlY3Rpb24uanMiLCJzcmMvY29tcG9uZW50cy9hc3NpZ25tZW50L2pzL2Jhc2UtbW9kZWwuanMiLCJzcmMvY29tcG9uZW50cy9hc3NpZ25tZW50L2pzL2RlZmF1bHRzLmpzIiwic3JjL2NvbXBvbmVudHMvYXNzaWdubWVudC9qcy9pbmRleC5qcyIsInNyYy9jb21wb25lbnRzL2Fzc2lnbm1lbnQvanMvcHJvamVjdC1tb2RlbC5qcyIsInNyYy9jb21wb25lbnRzL2Fzc2lnbm1lbnQvanMvc2VydmljZS1sb2NhdG9yLmpzIiwic3JjL2NvbXBvbmVudHMvYXNzaWdubWVudC9qcy90ZW1wbGF0ZXMuanMiLCJzcmMvY29tcG9uZW50cy9hc3NpZ25tZW50L2pzL3VzZ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HZpZXcpIHtcbiAgICAgICAgICAgICAgICB2YXIgdXNlciA9IHZpZXcubW9kZWw7XG4gICAgICAgICAgICAgICAgcXVldWUuYWRkKGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHZpZXcubWFrZUluYWN0aXZlKClcbiAgICAgICAgICAgICAgICAgICAgICAgIC50aGVuKGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB1c2VyLnJlbW92ZSgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZpZXcucmVtb3ZlKCk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICAgICAgfSk7XG5cbiAgICAgICAgICAgIH0sIHRoaXMpO1xuXG4gICAgICAgICAgICBxdWV1ZS5leGVjdXRlKHRoaXMpLnRoZW4oZG9uZSk7XG4gICAgICAgIH0uYmluZCh0aGlzKTtcblxuICAgICAgICByZXR1cm4gdGhpcy51bmFzc2lnblVzZXJzKGlkcylcbiAgICAgICAgICAgIC50aGVuKG1ha2VVc2Vyc0luYWN0aXZlKTtcblxuXG4gICAgfSxcblxuICAgIHJlbmRlcjogZnVuY3Rpb24gKCkge1xuICAgICAgICB0aGlzLiQoJ3RhYmxlIHRib2R5JykuZW1wdHkoKTtcbiAgICAgICAgdGhpcy5yZW5kZXJUYWJsZSgpO1xuICAgICAgICB0aGlzLnRvZ2dsZUNvbnRyb2xscygpO1xuICAgIH0sXG5cbiAgICByZW5kZXJUYWJsZTogZnVuY3Rpb24gKCkge1xuICAgICAgICB0aGlzLnJvd1ZpZXdzID0ge307XG4gICAgICAgIHZhciByb3dzID0gW107XG4gICAgICAgIHRoaXMudXNlcnMuZWFjaChmdW5jdGlvbiAodSkge1xuICAgICAgICAgICAgdmFyIHZpZXcgPSBuZXcgQXNzaWduZW1udFJvdyh7IG1vZGVsOiB1LCB3b3JsZHM6IHRoaXMud29ybGRzLCBwcm9qZWN0OiB0aGlz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ICAgICB9KS5sZW5ndGg7XG4gICAgfSxcblxuICAgIGZldGNoOiBmdW5jdGlvbiAoKSB7XG4gICAgICAgIHZhciBkdGQgPSAkLkRlZmVycmVkKCk7XG4gICAgICAgIHZhciBfdGhpcyA9IHRoaXM7XG4gICAgICAgIHZhciBncm91cElkID0gZW52LmdldCgpLmdyb3VwSWQ7XG5cbiAgICAgICAgdmFyIGdldEdyb3VwVXNlcnMgPSBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICB2YXIgbWVtYmVyQXBpID0gc2VydmljZUxvY2F0b3IubWVtYmVyQXBpKCk7XG4gICAgICAgICAgICB2YXIgdXNlckFwaSA9IHNlcnZpY2VMb2NhdG9yLnVzZXJBcGkoKTtcblxuICAgICAgICAgICAgdmFyIGxvYWRHcm91cE1lbWJlcnMgPSBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIG1lbWJlckFwaS5nZXRHcm91cERldGFpbHMoKTtcbiAgICAgICAgICAgIH07XG5cbiAgICAgICAgICAgIHZhciBsb2FkVXNlcnNJbmZvID0gZnVuY3Rpb24gKGdyb3VwKSB7XG4gICAgICAgICAgICAgICAgdmFyIG5vbkZhY0FuZEFjdGl2ZSA9IGZ1bmN0aW9uICh1KSB7IHJldHVybiB1LmFjdGl2ZSAmJiB1LnJvbGUgIT09ICdmYWNpbGl0YXRvcic7IH07XG4gICAgICAgICAgICAgICAgdmFyIHVzZXJzID0gXy5wbHVjayhfLmZpbHRlcihncm91cC5tZW1iZXJzLCBub25GYWNBbmRBY3RpdmUpLCAndXNlcklkJyk7XG4gICAgICAgICAgICAgICAgcmV0dXJuIHVzZXJBcGkuZ2V0KHsgaWQ6IHVzZXJzIH0pO1xuICAgICAgICAgICAgfTtcblxuICAgICAgICAgICAgcmV0dXJuIGxvYWRHcm91cE1lbWJlcnMoKVxuICAgICAgICAgICAgICAgIC50aGVuKGxvYWRVc2Vyc0luZm8pXG4gICAgICAgICAgICAgICAgLmZhaWwoZHR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ZXRXb3JsZEJ5VXNlcih1c2VyKTtcbiAgICAgICAgdmFyIGN1cldvcmxkID0gdGhpcy5nZXRPckNyZWF0ZVdvcmxkKHdvcmxkTmFtZSk7XG4gICAgICAgIHZhciBkb25lID0gZG9uZUZuKGR0ZCwgMSk7XG5cbiAgICAgICAgLy8gY2hlY2sgaWYgdGhlcmUncyBhbnl0aGluZyB0byBkb1xuICAgICAgICBpZiAoIXByZXZXb3JsZCAmJiAhY3VyV29ybGQpIHtcbiAgICAgICAgICAgIHJldHVybiBkdGQucmVzb2x2ZSgpLnByb21pc2UoKTtcbiAgICAgICAgfVxuXG4gICAgICAgIGlmIChwcmV2V29ybGQpIHtcbiAgICAgICAgICAgIHByZXZXb3JsZC5yZW1vdmVVc2VyKHVzZXIpXG4gICAgICAgICAgICAgICAgLnRoZW4oZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgICAgICAgICBpZiAoY3VyV29ybGQpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBjdXJXb3JsZC5hZGRVc2VyKHVzZXIpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSlcbiAgICAgICAgICAgICAgICAudGhlbihkb25lKTtcbiAgICAgICAgfSBlbHNlIGlmIChjdXJXb3JsZCkge1xuICAgICAgICAgICAgY3VyV29ybGQuYWRkVXNlcih1c2VyKVxuICAgICAgICAgICAgICAgIC50aGVuKGRvbmUpO1xuICAgICAgICB9XG5cbiAgICAgICAgcmV0dXJuIGR0ZC5wcm9taXNlKCk7XG4gICAgfSxcblxuICAgIGdldE9yQ3JlYXRlV29ybGQ6IGZ1bmN0aW9uICh3b3JsZE5hbWUpIHtcbiAgICAgICAgaWYgKCF3b3JsZE5hbWUpIHtcbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgfVxuXG4gICAgICAgIHZhciB3b3JsZCA9IHRoaXMuZ2V0V29yZEJ5TmFtZSh3b3JsZE5hbWUpO1xuXG4gICAgICAgIGlmICghd29ybGQpIHtcbiAgICAgICAgICAgIHdvcmxkID0gdGhpcy5jcmVhdGUoeyBuYW1lOiB3b3JsZE5hbWUgfSk7XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4gd29ybGQ7XG4gICAgfSxcblxuICAgIGdldFdvcmRCeU5hbWU6IGZ1bmN0aW9uICh3b3JsZE5hbWUpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuZmluZChmdW5jdGlvbiAod29ybGQpIHtcbiAgICAgICAgICAgIHJldHVybiB3b3JsZC5nZXQoJ25hbWUnKSA9PT0gd29ybGROYW1lO1xuICAgICAgICB9KTtcbiAgICB9LFxuXG4gICAgZ2V0V29ybGRCeVVzZXI6IGZ1bmN0aW9uICh1c2VyKSB7XG4gICAgICAgIGlmICghdXNlci5nZXQpIHtcbiAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcignZ2V0V29ybGRCeVVzZXIgZXhwZWN0ZXMgYSBtb2RlbCAoJyArIHVzZXIgKyAnKScpO1xuICAgICAgICB9XG5cbiAgICAgICAgdmFyIGlkID0gdXNlci5nZXQoJ2lkJyk7XG4gICAgICAgIHJldHVybiB0aGlzLmdldFdvcmxkQnlVc2VySWQoaWQpO1xuICAgIH0sXG5cbiAgICBnZXRXb3JsZEJ5VXNlcklkOiBmdW5jdGlvbiAodXNlcklkKSB7XG4gICAgICAgIHJldHVybiB0aGlzLmZpbmQoZnVuY3Rpb24gKHdvcmxkKSB7XG4gICAgICAgICAgICByZXR1cm4gXy5maW5kKHdvcmxkLmdldCgndXNlcnMnKSwgZnVuY3Rpb24gKHUpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gdS5nZXQoJ2lkJykgPT09IHVzZXJJZDtcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9KTtcbiAgICB9LFxuXG4gICAgZ2V0V29ybGROYW1lczogZnVuY3Rpb24gKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5wbHVjaygnbmFtZScpO1xuICAgIH0sXG5cbiAgICBnZXRO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IHZhciB1c2Vyc0hhc2ggPSB7fTtcbiAgICAgICAgdmFyIHVzZXJzQ29sbGVjdGlvbiA9IHRoaXMudXNlcnNDb2xsZWN0aW9uO1xuICAgICAgICB1c2Vyc0NvbGxlY3Rpb24uZWFjaChmdW5jdGlvbiAodSkge1xuICAgICAgICAgICAgdS5zZXQoeyBpc1dvcmxkQ29tcGxldGU6IHRydWUgfSk7XG4gICAgICAgICAgICByZXR1cm4gKHVzZXJzSGFzaFt1LmdldCgnaWQnKV0gPSB1KTtcbiAgICAgICAgfSk7XG5cbiAgICAgICAgdGhpcy5lYWNoKGZ1bmN0aW9uICh3LCBpKSB7XG4gICAgICAgICAgICB2YXIgbmFtZSA9IHcuZ2V0KCduYW1lJyk7XG4gICAgICAgICAgICB2YXIgaXNDb21wbGV0ZSA9IHcuZ2V0KCdjb21wbGV0ZScpO1xuICAgICAgICAgICAgdy5zZXQoeyBpbmRleDogaSwgbmFtZTogbmFtZSB8fCAoaSArIDEpICsgJycgfSk7XG4gICAgICAgICAgICBfLmVhY2gody5nZXQoJ3VzZXJzJyksIGZ1bmN0aW9uICh1KSB7XG4gICAgICAgICAgICAgICAgaWYgKHVzZXJzSGFzaFt1LmdldCgndXNlcklkJyldKSB7XG4gICAgICAgICAgICAgICAgICAgIHVzZXJzSGFzaFt1LmdldCgndXNlcklkJyldLnNldCh7IHdvcmxkOiBuYW1lLCByb2xlOiB1LmdldCgncm9sZScpLCBpc1dvcmxkQ29tcGxldGU6IGlzQ29tcGxldGUgfSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSk7XG4gICAgICAgIH0sIHRoaXMpO1xuXG4gICAgICAgIHVzZXJzQ29sbGVjdGlvbi5zb3J0KCk7XG4gICAgfSxcblxuICAgIGZldGNoOiBmdW5jdGlvbiAoKSB7XG4gICAgICAgIHJldHVybiB3b3JsZEFwaS5saXN0KClcbiAgICAgICAgICAgIC50aGVuKGZ1bmN0aW9uICh3b3JsZHMpIHtcbiAgICAgICAgICAgICAgICB0aGlzLnJlc2V0KHRoaXMucGFyc2Uod29ybGRzKSk7XG4gICAgICAgICAgICB9LmJpbmQodGhpcykpO1xuICAgIH0sXG5cbiAgICBwYXJzZTogZnVuY3Rpb24gKHdvcmxkcykge1xuICAgICAgICBpZiAod29ybGRzLmxlbmd0aCkge1xuICAgICAgICAgICAgd29ybGRzID0gXy5tYXAod29ybGRzLCBmdW5jdGlvbiAodykge1xuICAgICAgICAgICAgICAgIHZhciB1c2VycyA9IF8ubWFwKHcudXNlcnMsIGZ1bmN0aW9uICh1KSB7XG4gICAgICAgICAgICAgICAgICAgIC8vIGluIHRoZSB3b3JsZCBhcGkgdXNlcnMgSWRzIGNvbWVzIGFzIHVzZXJJZFxuICAgICAgICAgICAgICAgICAgICAvLyBtYWtlIHN1cmUgd2UgYWRkIGl0IGFzIGlkIHNvIHdlIGNhbiB1c2UgdGhlXG4gICAgICAgICAgICAgICAgICAgIC8vIHNhbWUgY29kZSB0byBhY2Nlc3MgbW9kZWxzIHRoYXQgY29tZSBmcm9tIHRoZVxuICAgICAgICAgICAgICAgICAgICAvLyBtZW1iZXIvbG9jYWwgYXBpIGFzIHdpdGggdGhlIHdvcmxkIGFwaVxuICAgICAgICAgICAgICAgICAgICB1LmlkID0gdS51c2VySWQ7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgVXNlck1vZGVsKHUpO1xuICAgICAgICAgICAgICAgIH0pO1xuXG4gICAgICAgICAgICAgICAgdy51c2VycyA9IHVzZXJzO1xuXG4gICAgICAgICAgICAgICAgcmV0dXJuIHc7XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfVxuXG4gICAgICAgIHJldHVybiB3b3JsZHM7XG4gICAgfVxufSk7XG4iLCIndXNlIHN0cmljdCc7XG5cbi8qKlxuKiBVdGlsaXR5IGNsYXNzIHRvIG1ha2UgYWpheCBjYWxscyBzZXF1ZW5jaWFsXG4qL1xuZnVuY3Rpb24gQWpheFF1ZXVlICgpIHtcbiAgIC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Y2gocm93cywgZnVuY3Rpb24gKHZpZXcpIHtcbiAgICAgICAgICAgICAgICB2YXIgdXNlciA9IHZpZXcubW9kZWw7XG4gICAgICAgICAgICAgICAgcXVldWUuYWRkKGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHZpZXcubWFrZUluYWN0aXZlKClcbiAgICAgICAgICAgICAgICAgICAgICAgIC50aGVuKGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB1c2VyLnJlbW92ZSgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZpZXcucmVtb3ZlKCk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICAgICAgfSk7XG5cbiAgICAgICAgICAgIH0sIHRoaXMpO1xuXG4gICAgICAgICAgICBxdWV1ZS5leGVjdXRlKHRoaXMpLnRoZW4oZG9uZSk7XG4gICAgICAgIH0uYmluZCh0aGlzKTtcblxuICAgICAgICByZXR1cm4gdGhpcy51bmFzc2lnblVzZXJzKGlkcylcbiAgICAgICAgICAgIC50aGVuKG1ha2VVc2Vyc0luYWN0aXZlKTtcblxuXG4gICAgfSxcblxuICAgIHJlbmRlcjogZnVuY3Rpb24gKCkge1xuICAgICAgICB0aGlzLiQoJ3RhYmxlIHRib2R5JykuZW1wdHkoKTtcbiAgICAgICAgdGhpcy5yZW5kZXJUYWJsZSgpO1xuICAgICAgICB0aGlzLnRvZ2dsZUNvbnRyb2xscygpO1xuICAgIH0sXG5cbiAgICByZW5kZXJUYWJsZTogZnVuY3Rpb24gKCkge1xuICAgICAgICB0aGlzLnJvd1ZpZXdzID0ge307XG4gICAgICAgIHZhciByb3dzID0gW107XG4gICAgICAgIHRoaXMudXNlcnMuZWFjaChmdW5jdGlvbiAodSkge1xuICAgICAgICAgICAgdmFyIHZpZXcgPSBuZXcgQXNzaWduZW1udFJvdyh7IG1vZGVsOiB1LCB3b3JsZHM6IHRoaXMud29ybG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XG4gICAgICAgIHJldHVybiBtb2RlbDtcbiAgICB9LFxuXG4gICAgc2V0OiBmdW5jdGlvbiAobW9kZWxzKSB7XG4gICAgICAgIGlmICghbW9kZWxzKSB7XG4gICAgICAgICAgICByZXR1cm47XG4gICAgICAgIH1cblxuICAgICAgICBtb2RlbHMgPSBbXS5jb25jYXQobW9kZWxzKTtcblxuICAgICAgICBpZiAoIW1vZGVscy5sZW5ndGgpIHtcbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgfVxuXG4gICAgICAgIF8uZWFjaChtb2RlbHMsIGZ1bmN0aW9uIChtKSB7XG4gICAgICAgICAgICBpZiAoIShtIGluc3RhbmNlb2YgdGhpcy5tb2RlbCkpIHtcbiAgICAgICAgICAgICAgICBtID0gbmV3IHRoaXMubW9kZWwobSk7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIG0uY29sbGVjdGlvbiA9IHRoaXM7XG5cbiAgICAgICAgICAgIHRoaXMuX21vZGVscy5wdXNoKG0pO1xuICAgICAgICB9LCB0aGlzKTtcblxuICAgICAgICB0aGlzLnNvcnQuY2FsbCh0aGlzKTtcblxuICAgICAgICByZXR1cm4gbW9kZWxzO1xuICAgIH0sXG5cbiAgICBzb3J0Rm46IGZ1bmN0aW9uIChhLCBiKSB7XG4gICAgICAgIHJldHVybiBiLl9kYXRhW3RoaXMuaWRBdHRyaWJ1dGVdIC0gYS5fZGF0YVt0aGlzLmlkQXR0cmlidXRlXTtcbiAgICB9LFxuXG4gICAgc29ydDogZnVuY3Rpb24gKCkge1xuICAgICAgICB0aGlzLl9tb2RlbHMgPSB0aGlzLl9tb2RlbHMuc29ydCh0aGlzLnNvcnRGbi5iaW5kKHRoaXMpKTtcblxuICAgICAgICByZXR1cm4gdGhpcy5fbW9kZWxzO1xuICAgIH0sXG5cbiAgICBnZXRCeUlkOiBmdW5jdGlvbiAoaWQpIHtcbiAgICAgICAgcmV0dXJuIF8uZmluZCh0aGlzLl9tb2RlbHMsIGZ1bmN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2V0KCd3b3JsZCcpO1xuICAgICAgICB9KS5sZW5ndGg7XG4gICAgfSxcblxuICAgIGZldGNoOiBmdW5jdGlvbiAoKSB7XG4gICAgICAgIHZhciBkdGQgPSAkLkRlZmVycmVkKCk7XG4gICAgICAgIHZhciBfdGhpcyA9IHRoaXM7XG4gICAgICAgIHZhciBncm91cElkID0gZW52LmdldCgpLmdyb3VwSWQ7XG5cbiAgICAgICAgdmFyIGdldEdyb3VwVXNlcnMgPSBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICB2YXIgbWVtYmVyQXBpID0gc2VydmljZUxvY2F0b3IubWVtYmVyQXBpKCk7XG4gICAgICAgICAgICB2YXIgdXNlckFwaSA9IHNlcnZpY2VMb2NhdG9yLnVzZXJBcGkoKTtcblxuICAgICAgICAgICAgdmFyIGxvYWRHcm91cE1lbWJlcnMgPSBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIG1lbWJlckFwaS5nZXRHcm91cERldGFpbHMoKTtcbiAgICAgICAgICAgIH07XG5cbiAgICAgICAgICAgIHZhciBsb2FkVXNlcnNJbmZvID0gZnVuY3Rpb24gKGdyb3VwKSB7XG4gICAgICAgICAgICAgICAgdmFyIG5vbkZhY0FuZEFjdGl2ZSA9IGZ1bmN0aW9uICh1KSB7IHJldHVybiB1LmFjdGl2ZSAmJiB1LnJvbGUgIT09ICdmYWNpbGl0YXRvcic7IH07XG4gICAgICAgICAgICAgICAgdmFyIHVzZXJzID0gXy5wbHVjayhfLmZpbHRlcihncm91cC5tZW1iZXJzLCBub25GYWNBbmRBY3RpdmUpLCAndXNlcklkJyk7XG4gICAgICAgICAgICAgICAgcmV0dXJuIHVzZXJBcGkuZ2V0KHsgaWQ6IHVzZXJzIH0pO1xuICAgICAgICAgICAgfTtcblxuICAgICAgICAgICAgcmV0dXJuIGxvYWRHcm91cE1lbWJlcnMoKVxuICAgICAgICAgICAgICAgIC50aGVuKGxvYWRVc2Vyc0luZm8pXG4gICAgIC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gcHJldldvcmxkID0gdGhpcy5nZXRXb3JsZEJ5VXNlcih1c2VyKTtcbiAgICAgICAgdmFyIGN1cldvcmxkID0gdGhpcy5nZXRPckNyZWF0ZVdvcmxkKHdvcmxkTmFtZSk7XG4gICAgICAgIHZhciBkb25lID0gZG9uZUZuKGR0ZCwgMSk7XG5cbiAgICAgICAgLy8gY2hlY2sgaWYgdGhlcmUncyBhbnl0aGluZyB0byBkb1xuICAgICAgICBpZiAoIXByZXZXb3JsZCAmJiAhY3VyV29ybGQpIHtcbiAgICAgICAgICAgIHJldHVybiBkdGQucmVzb2x2ZSgpLnByb21pc2UoKTtcbiAgICAgICAgfVxuXG4gICAgICAgIGlmIChwcmV2V29ybGQpIHtcbiAgICAgICAgICAgIHByZXZXb3JsZC5yZW1vdmVVc2VyKHVzZXIpXG4gICAgICAgICAgICAgICAgLnRoZW4oZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgICAgICAgICBpZiAoY3VyV29ybGQpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBjdXJXb3JsZC5hZGRVc2VyKHVzZXIpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSlcbiAgICAgICAgICAgICAgICAudGhlbihkb25lKTtcbiAgICAgICAgfSBlbHNlIGlmIChjdXJXb3JsZCkge1xuICAgICAgICAgICAgY3VyV29ybGQuYWRkVXNlcih1c2VyKVxuICAgICAgICAgICAgICAgIC50aGVuKGRvbmUpO1xuICAgICAgICB9XG5cbiAgICAgICAgcmV0dXJuIGR0ZC5wcm9taXNlKCk7XG4gICAgfSxcblxuICAgIGdldE9yQ3JlYXRlV29ybGQ6IGZ1bmN0aW9uICh3b3JsZE5hbWUpIHtcbiAgICAgICAgaWYgKCF3b3JsZE5hbWUpIHtcbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgfVxuXG4gICAgICAgIHZhciB3b3JsZCA9IHRoaXMuZ2V0V29yZEJ5TmFtZSh3b3JsZE5hbWUpO1xuXG4gICAgICAgIGlmICghd29ybGQpIHtcbiAgICAgICAgICAgIHdvcmxkID0gdGhpcy5jcmVhdGUoeyBuYW1lOiB3b3JsZE5hbWUgfSk7XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4gd29ybGQ7XG4gICAgfSxcblxuICAgIGdldFdvcmRCeU5hbWU6IGZ1bmN0aW9uICh3b3JsZE5hbWUpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuZmluZChmdW5jdGlvbiAod29ybGQpIHtcbiAgICAgICAgICAgIHJldHVybiB3b3JsZC5nZXQoJ25hbWUnKSA9PT0gd29ybGROYW1lO1xuICAgICAgICB9KTtcbiAgICB9LFxuXG4gICAgZ2V0V29ybGRCeVVzZXI6IGZ1bmN0aW9uICh1c2VyKSB7XG4gICAgICAgIGlmICghdXNlci5nZXQpIHtcbiAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcignZ2V0V29ybGRCeVVzZXIgZXhwZWN0ZXMgYSBtb2RlbCAoJyArIHVzZXIgKyAnKScpO1xuICAgICAgICB9XG5cbiAgICAgICAgdmFyIGlkID0gdXNlci5nZXQoJ2lkJyk7XG4gICAgICAgIHJldHVybiB0aGlzLmdldFdvcmxkQnlVc2VySWQoaWQpO1xuICAgIH0sXG5cbiAgICBnZXRXb3JsZEJ5VXNlcklkOiBmdW5jdGlvbiAodXNlcklkKSB7XG4gICAgICAgIHJldHVybiB0aGlzLmZpbmQoZnVuY3Rpb24gKHdvcmxkKSB7XG4gICAgICAgICAgICByZXR1cm4gXy5maW5kKHdvcmxkLmdldCgndXNlcnMnKSwgZnVuY3Rpb24gKHUpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gdS5nZXQoJ2lkJykgPT09IHVzZXJJZDtcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9KTtcbiAgICB9LFxuXG4gICAgZ2V0V29ybGROYW1lczogZnVuY3Rpb24gKCkge1xuICAgICAgICByZXR1cm4gdGhpcy5wbHVjaygnbmFtZScpO1x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dGlvbiAoKSB7XG4gICAgICAgIHZhciB1c2Vyc0hhc2ggPSB7fTtcbiAgICAgICAgdmFyIHVzZXJzQ29sbGVjdGlvbiA9IHRoaXMudXNlcnNDb2xsZWN0aW9uO1xuICAgICAgICB1c2Vyc0NvbGxlY3Rpb24uZWFjaChmdW5jdGlvbiAodSkge1xuICAgICAgICAgICAgdS5zZXQoeyBpc1dvcmxkQ29tcGxldGU6IHRydWUgfSk7XG4gICAgICAgICAgICByZXR1cm4gKHVzZXJzSGFzaFt1LmdldCgnaWQnKV0gPSB1KTtcbiAgICAgICAgfSk7XG5cbiAgICAgICAgdGhpcy5lYWNoKGZ1bmN0aW9uICh3LCBpKSB7XG4gICAgICAgICAgICB2YXIgbmFtZSA9IHcuZ2V0KCduYW1lJyk7XG4gICAgICAgICAgICB2YXIgaXNDb21wbGV0ZSA9IHcuZ2V0KCdjb21wbGV0ZScpO1xuICAgICAgICAgICAgdy5zZXQoeyBpbmRleDogaSwgbmFtZTogbmFtZSB8fCAoaSArIDEpICsgJycgfSk7XG4gICAgICAgICAgICBfLmVhY2gody5nZXQoJ3VzZXJzJyksIGZ1bmN0aW9uICh1KSB7XG4gICAgICAgICAgICAgICAgaWYgKHVzZXJzSGFzaFt1LmdldCgndXNlcklkJyldKSB7XG4gICAgICAgICAgICAgICAgICAgIHVzZXJzSGFzaFt1LmdldCgndXNlcklkJyldLnNldCh7IHdvcmxkOiBuYW1lLCByb2xlOiB1LmdldCgncm9sZScpLCBpc1dvcmxkQ29tcGxldGU6IGlzQ29tcGxldGUgfSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSk7XG4gICAgICAgIH0sIHRoaXMpO1xuXG4gICAgICAgIHVzZXJzQ29sbGVjdGlvbi5zb3J0KCk7XG4gICAgfSxcblxuICAgIGZldGNoOiBmdW5jdGlvbiAoKSB7XG4gICAgICAgIHJldHVybiB3b3JsZEFwaS5saXN0KClcbiAgICAgICAgICAgIC50aGVuKGZ1bmN0aW9uICh3b3JsZHMpIHtcbiAgICAgICAgICAgICAgICB0aGlzLnJlc2V0KHRoaXMucGFyc2Uod29ybGRzKSk7XG4gICAgICAgICAgICB9LmJpbmQodGhpcykpO1xuICAgIH0sXG5cbiAgICBwYXJzZTogZnVuY3Rpb24gKHdvcmxkcykge1xuICAgICAgICBpZiAod29ybGRzLmxlbmd0aCkge1xuICAgICAgICAgICAgd29ybGRzID0gXy5tYXAod29ybGRzLCBmdW5jdGlvbiAodykge1xuICAgICAgICAgICAgICAgIHZhciB1c2VycyA9IF8ubWFwKHcudXNlcnMsIGZ1bmN0aW9uICh1KSB7XG4gICAgICAgICAgICAgICAgICAgIC8vIGluIHRoZSB3b3JsZCBhcGkgdXNlcnMgSWRzIGNvbWVzIGFzIHVzZXJJZFxuICAgICAgICAgICAgICAgICAgICAvLyBtYWtlIHN1cmUgd2UgYWRkIGl0IGFzIGlkIHNvIHdlIGNhbiB1c2UgdGhlXG4gICAgICAgICAgICAgICAgICAgIC8vIHNhbWUgY29kZSB0byBhY2Nlc3MgbW9kZWxzIHRoYXQgY29tZSBmcm9tIHRoZVxuICAgICAgICAgICAgICAgICAgICAvLyBtZW1iZXIvbG9jYWwgYXBpIGFzIHdpdGggdGhlIHdvcmxkIGFwaVxuICAgICAgICAgICAgICAgICAgICB1LmlkID0gdS51c2VySWQ7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgVXNlck1vZGVsKHUpO1xuICAgICAgICAgICAgICAgIH0pO1xuXG4gICAgICAgICAgICAgICAgdy51c2VycyA9IHVzZXJzO1xuXG4gICAgICAgICAgICAgICAgcmV0dXJuIHc7XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfVxuXG4gICAgICAgIHJldHVybiB3b3JsZHM7XG4gICAgfVxufSk7XG4iLCIndXNlIHN0cmljdCc7XG5cbi8qKlxuKiBVdGlsaXR5IGNsYXNzIHRvIG1ha2UgYWpheCBjYWxscyBzZXF1ZW5jaWFsXG4qL1xuZnVuY3Rpb24gQW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1xuXG4gICAgLy8gYWRkIHN0YXRpYyBwcm9wZXJ0aWVzIHRvIHRoZSBjaGlsZCBjb25zdHJ1Y3RvciBmdW5jdGlvblxuICAgIGV4dGVuZChjaGlsZCwgcGFyZW50LCBzdGF0aWNQcm9wcyk7XG5cbiAgICAvLyBhc3NvY2lhdGUgcHJvdG90eXBlIGNoYWluXG4gICAgaW5oZXJpdChjaGlsZCwgcGFyZW50KTtcblxuICAgIC8vIGFkZCBpbnN0YW5jZSBwcm9wZXJ0aWVzXG4gICAgaWYgKHByb3BzKSB7XG4gICAgICAgIGV4dGVuZChjaGlsZC5wcm90b3R5cGUsIHByb3BzKTtcbiAgICB9XG5cbiAgICAvLyBkb25lXG4gICAgcmV0dXJuIGNoaWxkO1xufTtcbiJdfQ== diff --git a/dist/epicenter-multiplayer-dependencies.min.js b/dist/epicenter-multiplayer-dependencies.min.js index 15a6be71..d403fa82 100644 --- a/dist/epicenter-multiplayer-dependencies.min.js +++ b/dist/epicenter-multiplayer-dependencies.min.js @@ -1,2 +1,2 @@ -this.org=this.org||{},org.cometd={},org.cometd.JSON={},org.cometd.JSON.toJSON=org.cometd.JSON.fromJSON=function(a){throw"Abstract"},org.cometd.Utils={},org.cometd.Utils.isString=function(a){return void 0!==a&&null!==a&&("string"==typeof a||a instanceof String)},org.cometd.Utils.isArray=function(a){return void 0!==a&&null!==a&&a instanceof Array},org.cometd.Utils.inArray=function(a,b){for(var c=0;c0;){var b=l[0],c=b[0],d=b[1];if(c.url!==a.url||c.sync!==a.sync)break;l.shift(),a.messages=a.messages.concat(c.messages),this._debug("Coalesced",c.messages.length,"messages from request",d.id)}}function b(a,b){if(this.transportSend(a,b),b.expired=!1,!a.sync){var c=this.getConfiguration().maxNetworkDelay,d=c;b.metaConnect===!0&&(d+=this.getAdvice().timeout),this._debug("Transport",this.getType(),"waiting at most",d,"ms for the response, maxNetworkDelay",c);var e=this;b.timeout=this.setTimeout(function(){b.expired=!0;var c="Request "+b.id+" of transport "+e.getType()+" exceeded "+d+" ms max network delay",f={reason:c},g=b.xhr;f.httpCode=e.xhrStatus(g),e.abortXHR(g),e._debug(c),e.complete(b,!1,b.metaConnect),a.onFailure(g,a.messages,f)},d)}}function c(a){var c=++i,d={id:c,metaConnect:!1};k.length=0&&k.splice(e,1),l.length>0){var f=l.shift(),g=f[0],h=f[1];if(this._debug("Transport dequeued request",h.id),d)this.getConfiguration().autoBatch&&a.call(this,g),c.call(this,g),this._debug("Transport completed request",b.id,g);else{var i=this;this.setTimeout(function(){i.complete(h,!1,h.metaConnect);var a={reason:"Previous request failed"},b=h.xhr;a.httpCode=i.xhrStatus(b),g.onFailure(b,g.messages,a)},0)}}}function f(a){if(null!==j)throw"Concurrent metaConnect requests not allowed, request id="+j.id+" not yet completed";var c=++i;this._debug("Transport",this.getType(),"metaConnect send, request",c,"envelope",a);var d={id:c,metaConnect:!0};b.call(this,a,d),j=d}var g=new org.cometd.Transport,h=org.cometd.Transport.derive(g),i=0,j=null,k=[],l=[];return h.complete=function(a,b,c){c?d.call(this,a):e.call(this,a,b)},h.transportSend=function(a,b){throw"Abstract"},h.transportSuccess=function(a,b,c){b.expired||(this.clearTimeout(b.timeout),this.complete(b,!0,b.metaConnect),c&&c.length>0?a.onSuccess(c):a.onFailure(b.xhr,a.messages,{httpCode:204}))},h.transportFailure=function(a,b,c){b.expired||(this.clearTimeout(b.timeout),this.complete(b,!1,b.metaConnect),a.onFailure(b.xhr,a.messages,c))},h.send=function(a,b){b?f.call(this,a):c.call(this,a)},h.abort=function(){g.abort();for(var a=0;a0;){var h=org.cometd.JSON.toJSON(a.messages.slice(e,e+f)),i=a.url.length+encodeURI(h).length;if(i>c){if(1===f)return void this.setTimeout(function(){d.transportFailure(a,b,{reason:"Bayeux message too big, max is "+c})},0);--f}else g.push(f),e+=f,f=a.messages.length-e}var j=a;if(g.length>1){var k=0,l=g[0];this._debug("Transport",this.getType(),"split",a.messages.length,"messages into",g.join(" + ")),j=this._mixin(!1,{},a),j.messages=a.messages.slice(k,l),j.onSuccess=a.onSuccess,j.onFailure=a.onFailure;for(var m=1;m0&&(h=this.setTimeout(function(){h=null,f._debug("Transport",f.getType(),"timed out while connecting to URL",a,":",j,"ms");var b={code:1e3,reason:"Connect Timeout"};f.webSocketClose(c,b.code,b.reason),f.onClose(c,b)},j));var k=function(){f._debug("WebSocket opened",c),l=!1,h&&(f.clearTimeout(h),h=null),m?(d._warn("Closing Extra WebSocket Connections",c,m),f.webSocketClose(c,1e3,"Extra Connection")):f.onOpen(c)},n=function(a){a=a||{code:1e3},f._debug("WebSocket closing",c,a),l=!1,h&&(f.clearTimeout(h),h=null),null!==m&&c!==m?f._debug("Closed Extra WebSocket Connection",c):f.onClose(c,a)},o=function(a){f._debug("WebSocket message",a,c),c!==m&&d._warn("Extra WebSocket Connections",c,m),f.onMessage(c,a)};c.onopen=k,c.onclose=n,c.onerror=function(){n({code:1002,reason:"Error"})},c.onmessage=o,this._debug("Transport",this.getType(),"configured callbacks on",c)}}function b(a,b,c){var d=org.cometd.JSON.toJSON(b.messages);a.send(d),this._debug("Transport",this.getType(),"sent",b,"metaConnect =",c);var e=this.getConfiguration().maxNetworkDelay,f=e;c&&(f+=this.getAdvice().timeout,n=!0);for(var g=this,h=[],i=0;i=0){i=!0,q.splice(r,1);var s=j[p][0],t=j[p][1];delete j[p],q.length>0&&(j[q.join(",")]=[s,t]);break}}}i&&this._debug("Transport",this.getType(),"removed envelope, envelopes",j),o.call(this,d),c&&this.webSocketClose(a,1e3,"Disconnect")},f.onClose=function(a,b){this._debug("Transport",this.getType(),"closed",a,b),g=i&&h;for(var c in k)this.clearTimeout(k[c]);k={};for(var d in j){var e=j[d][0],f=j[d][1];f&&(n=!1),e.onFailure(a,e.messages,{websocketCode:b.code,reason:b.reason})}j={},m=null},f.registered=function(a,b){e.registered(a,b),d=b},f.accept=function(a,b,c){return g&&!!org.cometd.WebSocket&&d.websocketEnabled!==!1},f.send=function(a,b){this._debug("Transport",this.getType(),"sending",a,"metaConnect =",b);for(var d=[],e=0;e0)fa._info("Appending message type to URI "+f+g+" is not supported, disabling 'appendMessageTypeToURL' configuration"),xa.appendMessageTypeToURL=!1;else{var h=f.split("/"),i=h.length-1;f.match(/\/$/)&&(i-=1),h[i].indexOf(".")>=0&&(fa._info("Appending message type to URI "+f+" is not supported, disabling 'appendMessageTypeToURL' configuration"),xa.appendMessageTypeToURL=!1)}}function g(a){if(a){var b=pa[a.channel];b&&b[a.id]&&(delete b[a.id],fa._debug("Removed",a.listener?"listener":"subscription",a))}}function h(a){a&&!a.listener&&g(a)}function i(){for(var a in pa){var b=pa[a];if(b)for(var c=0;c",a),ja=a)}function k(){return"disconnecting"===ja||"disconnected"===ja}function l(){return++ka}function m(a,b,c,e,f){try{return b.call(a,e)}catch(g){fa._debug("Exception during execution of extension",c,g);var h=fa.onExtensionException;if(d(h)){fa._debug("Invoking extension exception callback",c,g);try{h.call(fa,g,c,f,e)}catch(i){fa._info("Exception during execution of exception callback in extension",c,i)}}return e}}function n(a){for(var b=0;b0)for(var e=0;e0;--e){var f=c.slice(0,e).join("/")+"/*";e===d&&p(f,b),f+="*",p(f,b)}}function r(){null!==ra&&org.cometd.Utils.clearTimeout(ra),ra=null}function s(a){r();var b=ta.interval+qa;fa._debug("Function scheduled in",b,"ms, interval =",ta.interval,"backoff =",qa,a),ra=org.cometd.Utils.setTimeout(fa,a,b)}function t(a,b,c,e){for(var f=0;f0||oa===!0?na.push(a):t(!1,[a],!1)}function v(){qa=0}function w(){qa0&&t(!1,a,!1)}function z(){if(--ma,ma<0)throw"Calls to startBatch() and endBatch() are not paired";0!==ma||k()||oa||y()}function A(){if(!k()){var a={channel:"/meta/connect",connectionType:ca.getType()};wa||(a.advice={timeout:0}),j("connecting"),fa._debug("Connect sent",a),t(!1,[a],!0,"connect"),j("connected")}}function B(){j("connecting"),s(function(){A()})}function C(a){a&&(ta=fa._mixin(!1,{},xa.advice,a),fa._debug("New advice",ta))}function D(a){if(r(),a&&ca&&ca.abort(),la=null,j("disconnected"),ma=0,v(),ca=null,na.length>0){var b=na;na=[],za.call(fa,void 0,b,{reason:"Disconnected"})}}function E(a,b,c){var e=fa.onTransportFailure;if(d(e)){fa._debug("Invoking transport failure callback",a,b,c);try{e.call(fa,a,b,c)}catch(f){fa._info("Exception during execution of transport failure callback",f)}}}function F(a,b){d(a)&&(b=a,a=void 0),la=null,i(),k()?(ia.reset(),C(xa.advice)):C(fa._mixin(!1,ta,{reconnect:"retry"})),ma=0,oa=!0,da=a,ea=b;var c="1.0",e=fa.getURL(),f=ia.findTransportTypes(c,ha,e),g={version:c,minimumVersion:c,channel:"/meta/handshake",supportedConnectionTypes:f,_callback:b,advice:{timeout:ta.timeout,interval:ta.interval}},h=fa._mixin(!1,{},da,g);if(!ca&&(ca=ia.negotiateTransport(f,c,ha,e),!ca)){var l="Could not find initial transport among: "+ia.getTransportTypes();throw fa._warn(l),l}fa._debug("Initial transport is",ca.getType()),j("handshaking"),fa._debug("Handshake sent",h),t(!1,[h],!1,"handshake")}function G(){j("handshaking"),oa=!0,s(function(){F(da,ea)})}function H(a){var b=ua[a.id];d(b)&&(delete ua[a.id],b.call(fa,a))}function I(a){H(a),q("/meta/handshake",a),q("/meta/unsuccessful",a);var b=!k()&&"none"!==ta.reconnect;b?(w(),G()):D(!1)}function J(a){if(a.successful){la=a.clientId;var b=fa.getURL(),c=ia.negotiateTransport(a.supportedConnectionTypes,a.version,ha,b);if(null===c){var d="Could not negotiate transport with server; client=["+ia.findTransportTypes(a.version,ha,b)+"], server=["+a.supportedConnectionTypes+"]",e=fa.getTransport();return E(e.getType(),null,{reason:d,connectionType:e.getType(),transport:e}),fa._warn(d),void D(!0)}ca!==c&&(fa._debug("Transport",ca.getType(),"->",c.getType()),ca=c),oa=!1,y(),a.reestablish=va,va=!0,H(a),q("/meta/handshake",a);var f=k()?"none":ta.reconnect;switch(f){case"retry":v(),B();break;case"none":D(!1);break;default:throw"Unrecognized advice action "+f}}else I(a)}function K(a){var b="1.0",c=fa.getURL(),d=fa.getTransport(),e=ia.findTransportTypes(b,ha,c),f=ia.negotiateTransport(e,b,ha,c);f?(fa._debug("Transport",d.getType(),"->",f.getType()),E(d.getType(),f.getType(),a.failure),I(a),ca=f):(E(d.getType(),null,a.failure),fa._warn("Could not negotiate transport; client=["+e+"]"),D(!0),I(a))}function L(a){q("/meta/connect",a),q("/meta/unsuccessful",a);var b=k()?"none":ta.reconnect;switch(b){case"retry":B(),w();break;case"handshake":ia.reset(),v(),G();break;case"none":D(!1);break;default:throw"Unrecognized advice action"+b}}function M(a){if(wa=a.successful){q("/meta/connect",a);var b=k()?"none":ta.reconnect;switch(b){case"retry":v(),B();break;case"none":D(!1);break;default:throw"Unrecognized advice action "+b}}else L(a)}function N(a){wa=!1,L(a)}function O(a){D(!0),H(a),q("/meta/disconnect",a),q("/meta/unsuccessful",a)}function P(a){a.successful?(D(!1),H(a),q("/meta/disconnect",a)):O(a)}function Q(a){O(a)}function R(a){var b=pa[a.subscription];if(b)for(var c=b.length-1;c>=0;--c){var d=b[c];if(d&&!d.listener){delete b[c],fa._debug("Removed failed subscription",d);break}}H(a),q("/meta/subscribe",a),q("/meta/unsuccessful",a)}function S(a){a.successful?(H(a),q("/meta/subscribe",a)):R(a)}function T(a){R(a)}function U(a){H(a),q("/meta/unsubscribe",a),q("/meta/unsuccessful",a)}function V(a){a.successful?(H(a),q("/meta/unsubscribe",a)):U(a)}function W(a){U(a)}function X(a){H(a),q("/meta/publish",a),q("/meta/unsuccessful",a)}function Y(a){void 0===a.successful?void 0!==a.data?q(a.channel,a):fa._warn("Unknown Bayeux Message",a):a.successful?(H(a),q("/meta/publish",a)):X(a)}function Z(a){X(a)}function $(a){if(a=n(a),void 0!==a&&null!==a){C(a.advice);var b=a.channel;switch(b){case"/meta/handshake":J(a);break;case"/meta/connect":M(a);break;case"/meta/disconnect":P(a);break;case"/meta/subscribe":S(a);break;case"/meta/unsubscribe":V(a);break;default:Y(a)}}}function _(a){var b=pa[a];if(b)for(var c=0;c0;){var b=l[0],c=b[0],d=b[1];if(c.url!==a.url||c.sync!==a.sync)break;l.shift(),a.messages=a.messages.concat(c.messages),this._debug("Coalesced",c.messages.length,"messages from request",d.id)}}function b(a,b){if(this.transportSend(a,b),b.expired=!1,!a.sync){var c=this.getConfiguration().maxNetworkDelay,d=c;b.metaConnect===!0&&(d+=this.getAdvice().timeout),this._debug("Transport",this.getType(),"waiting at most",d,"ms for the response, maxNetworkDelay",c);var e=this;b.timeout=this.setTimeout(function(){b.expired=!0;var c="Request "+b.id+" of transport "+e.getType()+" exceeded "+d+" ms max network delay",f={reason:c},g=b.xhr;f.httpCode=e.xhrStatus(g),e.abortXHR(g),e._debug(c),e.complete(b,!1,b.metaConnect),a.onFailure(g,a.messages,f)},d)}}function c(a){var c=++i,d={id:c,metaConnect:!1};k.length=0&&k.splice(e,1),l.length>0){var f=l.shift(),g=f[0],h=f[1];if(this._debug("Transport dequeued request",h.id),d)this.getConfiguration().autoBatch&&a.call(this,g),c.call(this,g),this._debug("Transport completed request",b.id,g);else{var i=this;this.setTimeout(function(){i.complete(h,!1,h.metaConnect);var a={reason:"Previous request failed"},b=h.xhr;a.httpCode=i.xhrStatus(b),g.onFailure(b,g.messages,a)},0)}}}function f(a){if(null!==j)throw"Concurrent metaConnect requests not allowed, request id="+j.id+" not yet completed";var c=++i;this._debug("Transport",this.getType(),"metaConnect send, request",c,"envelope",a);var d={id:c,metaConnect:!0};b.call(this,a,d),j=d}var g=new org.cometd.Transport,h=org.cometd.Transport.derive(g),i=0,j=null,k=[],l=[];return h.complete=function(a,b,c){c?d.call(this,a):e.call(this,a,b)},h.transportSend=function(a,b){throw"Abstract"},h.transportSuccess=function(a,b,c){b.expired||(this.clearTimeout(b.timeout),this.complete(b,!0,b.metaConnect),c&&c.length>0?a.onSuccess(c):a.onFailure(b.xhr,a.messages,{httpCode:204}))},h.transportFailure=function(a,b,c){b.expired||(this.clearTimeout(b.timeout),this.complete(b,!1,b.metaConnect),a.onFailure(b.xhr,a.messages,c))},h.send=function(a,b){b?f.call(this,a):c.call(this,a)},h.abort=function(){g.abort();for(var a=0;a0;){var h=org.cometd.JSON.toJSON(a.messages.slice(e,e+f)),i=a.url.length+encodeURI(h).length;if(i>c){if(1===f)return void this.setTimeout(function(){d.transportFailure(a,b,{reason:"Bayeux message too big, max is "+c})},0);--f}else g.push(f),e+=f,f=a.messages.length-e}var j=a;if(g.length>1){var k=0,l=g[0];this._debug("Transport",this.getType(),"split",a.messages.length,"messages into",g.join(" + ")),j=this._mixin(!1,{},a),j.messages=a.messages.slice(k,l),j.onSuccess=a.onSuccess,j.onFailure=a.onFailure;for(var m=1;m0&&(f=this.setTimeout(function(){f=null,e._debug("Transport",e.getType(),"timed out while connecting to URL",a,":",h,"ms");var b={code:1e3,reason:"Connect Timeout"};e.webSocketClose(c,b.code,b.reason),e.onClose(c,b)},h));var j=function(){e._debug("WebSocket opened",c),l=!1,f&&(e.clearTimeout(f),f=null),m?(d._warn("Closing Extra WebSocket Connections",c,m),e.webSocketClose(c,1e3,"Extra Connection")):e.onOpen(c)},k=function(a){a=a||{code:1e3},e._debug("WebSocket closing",c,a),l=!1,f&&(e.clearTimeout(f),f=null),null!==m&&c!==m?e._debug("Closed Extra WebSocket Connection",c):e.onClose(c,a)},n=function(a){e._debug("WebSocket message",a,c),c!==m&&d._warn("Extra WebSocket Connections",c,m),e.onMessage(c,a)};c.onopen=j,c.onclose=k,c.onerror=function(){k({code:1002,reason:"Error"})},c.onmessage=n,this._debug("Transport",this.getType(),"configured callbacks on",c)}}function b(a,b,c){var d=org.cometd.JSON.toJSON(b.messages);a.send(d),this._debug("Transport",this.getType(),"sent",b,"metaConnect =",c);var e=this.getConfiguration().maxNetworkDelay,f=e;c&&(f+=this.getAdvice().timeout,n=!0);for(var g=this,h=[],i=0;i=0){i=!0,q.splice(r,1);var s=j[p][0],t=j[p][1];delete j[p],q.length>0&&(j[q.join(",")]=[s,t]);break}}}i&&this._debug("Transport",this.getType(),"removed envelope, envelopes",j),o.call(this,d),c&&this.webSocketClose(a,1e3,"Disconnect")},f.onClose=function(a,b){this._debug("Transport",this.getType(),"closed",a,b),g=i&&h;for(var c in k)this.clearTimeout(k[c]);k={};for(var d in j){var e=j[d][0],f=j[d][1];f&&(n=!1),e.onFailure(a,e.messages,{websocketCode:b.code,reason:b.reason})}j={},m=null},f.registered=function(a,b){e.registered(a,b),d=b},f.accept=function(a,b,c){return g&&!!org.cometd.WebSocket&&d.websocketEnabled!==!1},f.send=function(a,b){this._debug("Transport",this.getType(),"sending",a,"metaConnect =",b);for(var d=[],e=0;e0)fa._info("Appending message type to URI "+f+g+" is not supported, disabling 'appendMessageTypeToURL' configuration"),xa.appendMessageTypeToURL=!1;else{var h=f.split("/"),i=h.length-1;f.match(/\/$/)&&(i-=1),h[i].indexOf(".")>=0&&(fa._info("Appending message type to URI "+f+" is not supported, disabling 'appendMessageTypeToURL' configuration"),xa.appendMessageTypeToURL=!1)}}function g(a){if(a){var b=pa[a.channel];b&&b[a.id]&&(delete b[a.id],fa._debug("Removed",a.listener?"listener":"subscription",a))}}function h(a){a&&!a.listener&&g(a)}function i(){for(var a in pa){var b=pa[a];if(b)for(var c=0;c",a),ja=a)}function k(){return"disconnecting"===ja||"disconnected"===ja}function l(){return++ka}function m(a,b,c,e,f){try{return b.call(a,e)}catch(a){fa._debug("Exception during execution of extension",c,a);var g=fa.onExtensionException;if(d(g)){fa._debug("Invoking extension exception callback",c,a);try{g.call(fa,a,c,f,e)}catch(a){fa._info("Exception during execution of exception callback in extension",c,a)}}return e}}function n(a){for(var b=0;b0)for(var e=0;e0;--e){var f=c.slice(0,e).join("/")+"/*";e===d&&p(f,b),f+="*",p(f,b)}}function r(){null!==ra&&org.cometd.Utils.clearTimeout(ra),ra=null}function s(a){r();var b=ta.interval+qa;fa._debug("Function scheduled in",b,"ms, interval =",ta.interval,"backoff =",qa,a),ra=org.cometd.Utils.setTimeout(fa,a,b)}function t(a,b,c,e){for(var f=0;f0||oa===!0?na.push(a):t(!1,[a],!1)}function v(){qa=0}function w(){qa0&&t(!1,a,!1)}function z(){if(--ma,ma<0)throw"Calls to startBatch() and endBatch() are not paired";0!==ma||k()||oa||y()}function A(){if(!k()){var a={channel:"/meta/connect",connectionType:ca.getType()};wa||(a.advice={timeout:0}),j("connecting"),fa._debug("Connect sent",a),t(!1,[a],!0,"connect"),j("connected")}}function B(){j("connecting"),s(function(){A()})}function C(a){a&&(ta=fa._mixin(!1,{},xa.advice,a),fa._debug("New advice",ta))}function D(a){if(r(),a&&ca&&ca.abort(),la=null,j("disconnected"),ma=0,v(),ca=null,na.length>0){var b=na;na=[],za.call(fa,void 0,b,{reason:"Disconnected"})}}function E(a,b,c){var e=fa.onTransportFailure;if(d(e)){fa._debug("Invoking transport failure callback",a,b,c);try{e.call(fa,a,b,c)}catch(a){fa._info("Exception during execution of transport failure callback",a)}}}function F(a,b){d(a)&&(b=a,a=void 0),la=null,i(),k()?(ia.reset(),C(xa.advice)):C(fa._mixin(!1,ta,{reconnect:"retry"})),ma=0,oa=!0,da=a,ea=b;var c="1.0",e=fa.getURL(),f=ia.findTransportTypes(c,ha,e),g={version:c,minimumVersion:c,channel:"/meta/handshake",supportedConnectionTypes:f,_callback:b,advice:{timeout:ta.timeout,interval:ta.interval}},h=fa._mixin(!1,{},da,g);if(!ca&&(ca=ia.negotiateTransport(f,c,ha,e),!ca)){var l="Could not find initial transport among: "+ia.getTransportTypes();throw fa._warn(l),l}fa._debug("Initial transport is",ca.getType()),j("handshaking"),fa._debug("Handshake sent",h),t(!1,[h],!1,"handshake")}function G(){j("handshaking"),oa=!0,s(function(){F(da,ea)})}function H(a){var b=ua[a.id];d(b)&&(delete ua[a.id],b.call(fa,a))}function I(a){H(a),q("/meta/handshake",a),q("/meta/unsuccessful",a);var b=!k()&&"none"!==ta.reconnect;b?(w(),G()):D(!1)}function J(a){if(a.successful){la=a.clientId;var b=fa.getURL(),c=ia.negotiateTransport(a.supportedConnectionTypes,a.version,ha,b);if(null===c){var d="Could not negotiate transport with server; client=["+ia.findTransportTypes(a.version,ha,b)+"], server=["+a.supportedConnectionTypes+"]",e=fa.getTransport();return E(e.getType(),null,{reason:d,connectionType:e.getType(),transport:e}),fa._warn(d),void D(!0)}ca!==c&&(fa._debug("Transport",ca.getType(),"->",c.getType()),ca=c),oa=!1,y(),a.reestablish=va,va=!0,H(a),q("/meta/handshake",a);var f=k()?"none":ta.reconnect;switch(f){case"retry":v(),B();break;case"none":D(!1);break;default:throw"Unrecognized advice action "+f}}else I(a)}function K(a){var b="1.0",c=fa.getURL(),d=fa.getTransport(),e=ia.findTransportTypes(b,ha,c),f=ia.negotiateTransport(e,b,ha,c);f?(fa._debug("Transport",d.getType(),"->",f.getType()),E(d.getType(),f.getType(),a.failure),I(a),ca=f):(E(d.getType(),null,a.failure),fa._warn("Could not negotiate transport; client=["+e+"]"),D(!0),I(a))}function L(a){q("/meta/connect",a),q("/meta/unsuccessful",a);var b=k()?"none":ta.reconnect;switch(b){case"retry":B(),w();break;case"handshake":ia.reset(),v(),G();break;case"none":D(!1);break;default:throw"Unrecognized advice action"+b}}function M(a){if(wa=a.successful){q("/meta/connect",a);var b=k()?"none":ta.reconnect;switch(b){case"retry":v(),B();break;case"none":D(!1);break;default:throw"Unrecognized advice action "+b}}else L(a)}function N(a){wa=!1,L(a)}function O(a){D(!0),H(a),q("/meta/disconnect",a),q("/meta/unsuccessful",a)}function P(a){a.successful?(D(!1),H(a),q("/meta/disconnect",a)):O(a)}function Q(a){O(a)}function R(a){var b=pa[a.subscription];if(b)for(var c=b.length-1;c>=0;--c){var d=b[c];if(d&&!d.listener){delete b[c],fa._debug("Removed failed subscription",d);break}}H(a),q("/meta/subscribe",a),q("/meta/unsuccessful",a)}function S(a){a.successful?(H(a),q("/meta/subscribe",a)):R(a)}function T(a){R(a)}function U(a){H(a),q("/meta/unsubscribe",a),q("/meta/unsuccessful",a)}function V(a){a.successful?(H(a),q("/meta/unsubscribe",a)):U(a)}function W(a){U(a)}function X(a){H(a),q("/meta/publish",a),q("/meta/unsuccessful",a)}function Y(a){void 0===a.successful?void 0!==a.data?q(a.channel,a):fa._warn("Unknown Bayeux Message",a):a.successful?(H(a),q("/meta/publish",a)):X(a)}function Z(a){X(a)}function $(a){if(a=n(a),void 0!==a&&null!==a){C(a.advice);var b=a.channel;switch(b){case"/meta/handshake":J(a);break;case"/meta/connect":M(a);break;case"/meta/disconnect":P(a);break;case"/meta/subscribe":S(a);break;case"/meta/unsubscribe":V(a);break;default:Y(a)}}}function _(a){var b=pa[a];if(b)for(var c=0;cLogged in as: ' + credentials.userName + ''); _this.assetAdapter = new F.service.Asset(server); @@ -66,7 +66,7 @@ $(function() { var imageExtensions = ['png', 'jpg', 'jpeg', 'gif', 'svg', 'bmp']; $('.images').empty(); - this.assetAdapter.list({ scope: scope }).done(function (response) { + this.assetAdapter.list({ scope: scope }).then(function (response) { $.each(response, function () { var url = this; var filename = url.substring(url.lastIndexOf('/') + 1); @@ -103,7 +103,7 @@ $(function() { try { // filename will be ignored if it's a multipart/form-data request - this.assetAdapter.create(filename, data, { scope: scope }).done(function () { + this.assetAdapter.create(filename, data, { scope: scope }).then(function () { $('.status').html('
File uploaded! Reloading assets...
'); $('.list [name=scope]').val(scope); _this.listAssets(); @@ -130,7 +130,7 @@ $(function() { // var aa = new F.service.Asset($.extend(server, extra)); // aa.create('test.txt', { encoding: 'BASE_64', data: 'VGhpcyBpcyBhIHRlc3QgZmlsZS4=' }, { scope: 'user' }); //aa.delete('test1.txt', { scope: 'user' }); - // aa.list({ scope: 'user', fullUrl: true }).done(function (response) { + // aa.list({ scope: 'user', fullUrl: true }).then(function (response) { // console.log(response); // }); }); diff --git a/tests/integration/multiplayer/test-script.js b/tests/integration/multiplayer/test-script.js index da394356..a3962e2e 100644 --- a/tests/integration/multiplayer/test-script.js +++ b/tests/integration/multiplayer/test-script.js @@ -24,7 +24,7 @@ $(function () { password: $('#txtPassword').val(), account: $('#txtAccount').val(), project: $('#txtProject').val() - }).done(function () { + }).then(function () { window.alert('login successful'); }); }); diff --git a/tests/spec/test-multiplayer-strategy.js b/tests/spec/test-multiplayer-strategy.js index e148fb28..80da769f 100644 --- a/tests/spec/test-multiplayer-strategy.js +++ b/tests/spec/test-multiplayer-strategy.js @@ -51,24 +51,20 @@ server = sinon.fakeServer.create(); setupResponse('GET', queryMatchers.worldEndpoint, 200, worlds || []); - setupResponse('POST', /multiplayer\/world\/worldid1\/run/, 201, 'run1'); setupResponse('POST', /multiplayer\/world\/worldid2\/run/, 201, 'run2'); - server.autorespond = true; + server.respondImmediately = true; }; var teardownServer = function () { server.restore(); }; - - - describe('Multiplayer strategy', function () { + describe.only('Multiplayer strategy', function () { beforeEach(_.partial(setupServer, worldSet)); afterEach(teardownServer); - function createRunManager(options) { var rm = new F.manager.RunManager(_.extend({ strategy: 'multiplayer', @@ -82,42 +78,34 @@ // this is briddle, it knows too much about the internals of the run manager // but replace the cookie store with a stub rm.strategy._auth = fakeAuth; - return rm; } describe('with world/users setup correctly', function () { it('should get the list of worlds for the current user first', function () { - createRunManager().getRun(); - - var req = server.requests.pop(); - req.method.toUpperCase().should.equal('GET'); - - req.url.should.match(queryMatchers.getWorlds); + return createRunManager().getRun().then(function () { + var req = server.requests.pop(); + req.method.toUpperCase().should.equal('GET'); + req.url.should.match(queryMatchers.getWorlds); + }); }); it('should post to the run endpoint after getting the world', function () { - createRunManager().getRun(); - - server.respond(); - var req = server.requests.pop(); - - req.method.toUpperCase().should.equal('POST'); - req.url.should.match(/multiplayer\/world\/worldid2\/run/); - + return createRunManager().getRun().then(function () { + var req = server.requests.pop(); + req.method.toUpperCase().should.equal('POST'); + req.url.should.match(/multiplayer\/world\/worldid2\/run/); + }); }); }); describe('with two worlds for the user', function () { it('should use the latest world to retore the run', function () { - createRunManager().getRun(); - - server.respond(); - var req = server.requests.pop(); - - req.method.toUpperCase().should.equal('POST'); - - req.url.should.match(/multiplayer\/world\/worldid2/); + return createRunManager().getRun().then(function () { + var req = server.requests.pop(); + req.method.toUpperCase().should.equal('POST'); + req.url.should.match(/multiplayer\/world\/worldid2/); + }); }); }); @@ -125,14 +113,12 @@ beforeEach(_.partial(setupServer, [])); it('should fail the getRun request with proper error', function () { var callback = sinon.spy(); - createRunManager().getRun() - .fail(callback); - - server.respond(); - - callback.called.should.be.true; + return createRunManager().getRun() + .then(null, callback) + .then(function () { + callback.called.should.be.true; + }); }); }); - }); })(); diff --git a/tests/spec/test-run-api-service.js b/tests/spec/test-run-api-service.js index efad2073..d5684896 100644 --- a/tests/spec/test-run-api-service.js +++ b/tests/spec/test-run-api-service.js @@ -18,7 +18,7 @@ return include; }; - describe.only('Run API Service', function () { + describe('Run API Service', function () { var server; before(function () { server = sinon.fakeServer.create(); @@ -588,7 +588,7 @@ ret.should.throw(Error); }); - it.only('should send multiple operations calls one by one', function () { + it('should send multiple operations calls one by one', function () { var rs = new RunService({ account: account, project: 'js-libs', filter: { saved: true } }); return rs.serial([{ first: [1, 2] }, { second: [2, 3] }]).then(function () { server.requests.length.should.equal(2); From 26e83b09dc9e7e65286648608dc36f9fcce36984 Mon Sep 17 00:00:00 2001 From: Naren Ranjit Date: Thu, 15 Sep 2016 14:28:00 -0700 Subject: [PATCH 10/16] fix context --- src/managers/run-strategies/multiplayer-strategy.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/managers/run-strategies/multiplayer-strategy.js b/src/managers/run-strategies/multiplayer-strategy.js index 40c42420..9bd4afb1 100644 --- a/src/managers/run-strategies/multiplayer-strategy.js +++ b/src/managers/run-strategies/multiplayer-strategy.js @@ -49,7 +49,7 @@ var Strategy = classFrom(IdentityStrategy, { var loadRunFromWorld = function (world) { if (!world) { - return dtd.reject({ statusCode: 404, error: 'The user is not in any world.' }, { options: this.options, session: session }); + return dtd.reject({ statusCode: 404, error: 'The user is not in any world.' }, { options: _this.options, session: session }); } return worldApi.getCurrentRunId({ model: model, filter: world.id }) From e99c509b75cf2acea8130d006d90b4d896c51d96 Mon Sep 17 00:00:00 2001 From: Naren Ranjit Date: Thu, 15 Sep 2016 16:24:52 -0700 Subject: [PATCH 11/16] Then really only takes 1 parameters, so we should not be resolving with multiples --- dist/components/assignment/assignment.js | 4 ++-- dist/components/login/login.js | 2 -- src/components/assignment/js/users-collection.js | 2 +- src/managers/world-manager.js | 2 +- src/service/asset-api-adapter.js | 2 +- src/service/world-api-adapter.js | 4 ++-- tests/spec/test-conditional-creation-strategy.js | 2 -- tests/spec/test-world-manager.js | 5 +---- 8 files changed, 8 insertions(+), 15 deletions(-) diff --git a/dist/components/assignment/assignment.js b/dist/components/assignment/assignment.js index 369e2736..3ca45965 100644 --- a/dist/components/assignment/assignment.js +++ b/dist/components/assignment/assignment.js @@ -850,7 +850,7 @@ module.exports = classFrom(Base, { .then(function (users) { users = _.map(users, function (u) { return _.extend(u, { groupId: groupId }); }); _this.set(users); - dtd.resolve(users, _this); + dtd.resolve(users); }); return dtd.promise(); @@ -1231,4 +1231,4 @@ module.exports = function (base, props, staticProps) { }; },{}]},{},[6]) -//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9icm93c2VyLXBhY2svX3ByZWx1ZGUuanMiLCJzcmMvY29tcG9uZW50cy9hc3NpZ25tZW50L2pzL2Fzc2lnbm1lbnQtcm93LmpzIiwic3JjL2NvbXBvbmVudHMvYXNzaWdubWVudC9qcy9hc3NpZ25tZW50LmpzIiwic3JjL2NvbXBvbmVudHMvYXNzaWdubWVudC9qcy9iYXNlLWNvbGxlY3Rpb24uanMiLCJzcmMvY29tcG9uZW50cy9hc3NpZ25tZW50L2pzL2Jhc2UtbW9kZWwuanMiLCJzcmMvY29tcG9uZW50cy9hc3NpZ25tZW50L2pzL2RlZmF1bHRzLmpzIiwic3JjL2NvbXBvbmVudHMvYXNzaWdubWVudC9qcy9pbmRleC5qcyIsInNyYy9jb21wb25lbnRzL2Fzc2lnbm1lbnQvanMvcHJvamVjdC1tb2RlbC5qcyIsInNy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G9ubHkgb3BlcmF0ZSBvbiBvbmUgY2FsbCBwZXIgZ3JvdXAgYXQgYSB0aW1lXG4gICAgICAgICAgICB2YXIgcXVldWUgPSBuZXcgQWpheFF1ZXVlKCk7XG4gICAgICAgICAgICBfLmVhY2gocm93cywgZnVuY3Rpb24gKHZpZXcpIHtcbiAgICAgICAgICAgICAgICB2YXIgdXNlciA9IHZpZXcubW9kZWw7XG4gICAgICAgICAgICAgICAgcXVldWUuYWRkKGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHZpZXcubWFrZUluYWN0aXZlKClcbiAgICAgICAgICAgICAgICAgICAgICAgIC50aGVuKGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB1c2VyLnJlbW92ZSgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZpZXcucmVtb3ZlKCk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICAgICAgfSk7XG5cbiAgICAgICAgICAgIH0sIHRoaXMpO1xuXG4gICAgICAgICAgICBxdWV1ZS5leGVjdXRlKHRoaXMpLnRoZW4oZG9uZSk7XG4gICAgICAgIH0uYmluZCh0aGlzKTtcblxuICAgICAgICByZXR1cm4gdGhpcy51bmFzc2lnblVzZXJzKGlkcylcbiAgICAgICAgICAgIC50aGVuKG1ha2VVc2Vyc0luYWN0aXZlKTtcblxuXG4gICAgfSxcblxuICAgIHJlbmRlcjogZnVuY3Rpb24gKCkge1xuICAgICAgICB0aGlzLiQoJ3RhYmxlIHRib2R5JykuZW1wdHkoKTtcbiAgICAgICAgdGhpcy5yZW5kZXJUYWJsZSgpO1xuICAgICAgICB0aGlzLnRvZ2dsZUNvbnRyb2xscygpO1xuICAgIH0sXG5cbiAgICByZW5kZXJUYWJsZTogZnVuY3Rpb24gKCkge1xuICAgICAgICB0aGlzLnJvd1ZpZXdzID0ge307XG4gICAgICAgIHZhciByb3dzID0gW107XG4g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GlkZSgpO1xuICAgICAgICAgICAgdGhpcy4kKCcudGFibGUtY29udHJvbHMgLnNpbmdsZScpLnNob3coKTtcbiAgICAgICAgICAgIHRoaXMuJCgnLnRhYmxlLWNvbnRyb2xzIC5uby1yb2xlcycpLnNob3coKTtcblxuICAgICAgICB9XG5cbiAgICAgICAgaWYgKHRoaXMudXNlcnMuYWxsVXNlcnNBc3NpZ25lZCgpKSB7XG4gICAgICAgICAgICB0aGlzLiQoJy50YWJsZS1jb250cm9scycpLnJlbW92ZUNsYXNzKCd2aXNpYmxlJyk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0aGlzLiQoJy50YWJsZS1jb250cm9scycpLmFkZENsYXNzKCd2aXNpYmxlJyk7XG4gICAgICAgIH1cbiAgICB9LFxuXG4gICAgc2VsZWN0QWxsOiBmdW5jdGlvbiAoZSkge1xuICAgICAgICB0aGlzLiQoJ3Rib2R5IDpjaGVja2JveCcpLnByb3AoJ2NoZWNrZWQnLCBlLnRhcmdldC5jaGVja2VkKTtcbiAgICAgICAgdGhpcy51cGRhdGVDb250cm9scygpO1xuICAgIH0sXG5cbiAgICB0b2dnbGVDb250cm9sbHM6IGZ1bmN0aW9uIChlKSB7XG4gICAgICAgIHZhciB0b3RhbCA9IHRoaXMuJCgndGJvZHkgOmNoZWNrYm94Jyk7XG4gICAgICAgIHZhciBjaGVja2VkID0gdGhpcy4kKCd0Ym9keSA6Y2hlY2tib3g6Y2hlY2tlZCcpO1xuXG4gICAgICAgIGlmICh0b3RhbC5sZW5ndGggPT09IGNoZWNrZWQubGVuZ3RoKSB7XG4gICAgICAgICAgICB0aGlzLiQoJyNzZWxlY3QtYWxsJykuYXR0cignY2hlY2tlZCcsICdjaGVja2VkJyk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0aGlzLiQoJyNzZWxlY3QtYWxsJykucmVtb3ZlQXR0cignY2hlY2tlZCcpO1xuICAgICAgICB9XG5cbiAgICAgICAgdGhpcy51cG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b2RlbHMsIGZ1bmN0aW9uIChtKSB7XG4gICAgICAgICAgICByZXR1cm4gbSA9PT0gbW9kZWw7XG4gICAgICAgIH0pO1xuXG4gICAgICAgIGRlbGV0ZSBtb2RlbC5jb2xsZWN0aW9uO1xuXG4gICAgICAgIHJldHVybiBtb2RlbDtcbiAgICB9LFxuXG4gICAgc2V0OiBmdW5jdGlvbiAobW9kZWxzKSB7XG4gICAgICAgIGlmICghbW9kZWxzKSB7XG4gICAgICAgICAgICByZXR1cm47XG4gICAgICAgIH1cblxuICAgICAgICBtb2RlbHMgPSBbXS5jb25jYXQobW9kZWxzKTtcblxuICAgICAgICBpZiAoIW1vZGVscy5sZW5ndGgpIHtcbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgfVxuXG4gICAgICAgIF8uZWFjaChtb2RlbHMsIGZ1bmN0aW9uIChtKSB7XG4gICAgICAgICAgICBpZiAoIShtIGluc3RhbmNlb2YgdGhpcy5tb2RlbCkpIHtcbiAgICAgICAgICAgICAgICBtID0gbmV3IHRoaXMubW9kZWwobSk7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIG0uY29sbGVjdGlvbiA9IHRoaXM7XG5cbiAgICAgICAgICAgIHRoaXMuX21vZGVscy5wdXNoKG0pO1xuICAgICAgICB9LCB0aGlzKTtcblxuICAgICAgICB0aGlzLnNvcnQuY2FsbCh0aGlzKTtcblxuICAgICAgICByZXR1cm4gbW9kZWxzO1xuICAgIH0sXG5cbiAgICBzb3J0Rm46IGZ1bmN0aW9uIChhLCBiKSB7XG4gICAgICAgIHJldHVybiBiLl9kYXRhW3RoaXMuaWRBdHRyaWJ1dGVdIC0gYS5fZGF0YVt0aGlzLmlkQXR0cmlidXRlXTtcbiAgICB9LFxuXG4gICAgc29ydDogZnVuY3Rpb24gKCkge1xuICAgICAgICB0aGlzLl9tb2RlbHMgPSB0aGlzLl9tb2RlbHMuc29ydCh0aGlzLnNvcnRGbi5iaW5kKHRoaXMpKTtcblxuICAgICAgIC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IHVzZXJzIH0pO1xuICAgICAgICAgICAgfTtcblxuICAgICAgICAgICAgcmV0dXJuIGxvYWRHcm91cE1lbWJlcnMoKVxuICAgICAgICAgICAgICAgIC50aGVuKGxvYWRVc2Vyc0luZm8pXG4gICAgICAgICAgICAgICAgLmZhaWwoZHRkLnJlamVjdCk7XG4gICAgICAgIH07XG5cbiAgICAgICAgZ2V0R3JvdXBVc2VycygpXG4gICAgICAgICAgICAudGhlbihmdW5jdGlvbiAodXNlcnMpIHtcbiAgICAgICAgICAgICAgICB1c2VycyA9IF8ubWFwKHVzZXJzLCBmdW5jdGlvbiAodSkgeyByZXR1cm4gXy5leHRlbmQodSwgeyBncm91cElkOiBncm91cElkIH0pOyB9KTtcbiAgICAgICAgICAgICAgICBfdGhpcy5zZXQodXNlcnMpO1xuICAgICAgICAgICAgICAgIGR0ZC5yZXNvbHZlKHVzZXJzLCBfdGhpcyk7XG4gICAgICAgICAgICB9KTtcblxuICAgICAgICByZXR1cm4gZHRkLnByb21pc2UoKTtcbiAgICB9XG5cbn0pO1xuIiwiJ3VzZSBzdHJpY3QnO1xudmFyIHNlcnZpY2VMb2NhdG9yID0gcmVxdWlyZSgnLi9zZXJ2aWNlLWxvY2F0b3InKTtcbnZhciBjbGFzc0Zyb20gPSByZXF1aXJlKCcuLi8uLi8uLi91dGlsL2luaGVyaXQnKTtcbnZhciBCYXNlID0gcmVxdWlyZSgnLi9iYXNlLW1vZGVsJyk7XG52YXIgX19zdXBlciA9IEJhc2UucHJvdG90eXBlO1xuXG5tb2R1bGUuZXhwb3J0cyA9IGNsYXNzRnJvbShCYXNlLCB7XG5cbiAgICBkZWZhdWx0czoge1xuICAgICAgICB1c2VyczogbnVsbCxcbiAgICAgICAgbW9kZWw6ICdtb2RlbC5lcW4nXG4gICAgfSxcblxuICAgIGluaXRpYWxpemU6IGZ1bmN0aW9uICgpIHtcbiAgICAgICAgX19zdXBlci5pbml0aWFsaXplLmFwcGx5KHRoaXMsIGFyZ3VtZW50cyk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uY3Rpb24gKHVzZXIpIHtcbiAgICAgICAgdmFyIHdvcmxkTmFtZSA9IHVzZXIuZ2V0KCd3b3JsZCcpO1xuICAgICAgICB2YXIgZHRkID0gJC5EZWZlcnJlZCgpO1xuICAgICAgICB2YXIgcHJldldvcmxkID0gdGhpcy5nZXRXb3JsZEJ5VXNlcih1c2VyKTtcbiAgICAgICAgdmFyIGN1cldvcmxkID0gdGhpcy5nZXRPckNyZWF0ZVdvcmxkKHdvcmxkTmFtZSk7XG4gICAgICAgIHZhciBkb25lID0gZG9uZUZuKGR0ZCwgMSk7XG5cbiAgICAgICAgLy8gY2hlY2sgaWYgdGhlcmUncyBhbnl0aGluZyB0byBkb1xuICAgICAgICBpZiAoIXByZXZXb3JsZCAmJiAhY3VyV29ybGQpIHtcbiAgICAgICAgICAgIHJldHVybiBkdGQucmVzb2x2ZSgpLnByb21pc2UoKTtcbiAgICAgICAgfVxuXG4gICAgICAgIGlmIChwcmV2V29ybGQpIHtcbiAgICAgICAgICAgIHByZXZXb3JsZC5yZW1vdmVVc2VyKHVzZXIpXG4gICAgICAgICAgICAgICAgLnRoZW4oZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgICAgICAgICBpZiAoY3VyV29ybGQpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBjdXJXb3JsZC5hZGRVc2VyKHVzZXIpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSlcbiAgICAgICAgICAgICAgICAudGhlbihkb25lKTtcbiAgICAgICAgfSBlbHNlIGlmIChjdXJXb3JsZCkge1xuICAgICAgICAgICAgY3VyV29ybGQuYWRkVXNlcih1c2VyKVxuICAgICAgICAgICAgICAgIC50aGVuKGRvbmUpO1xuICAgICAgICB9XG5cbiAgICAgICAgcmV0dXJuIGR0ZC5wcm9taXNlKCk7XG4gICAgfSxcblxuICAgIGdldE9yQ3JlYXRlV29ybGQ6IGZ1bmN0aW9uICh3b3JsZE5hbWUpIHtcbiAg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Glvbi5zb3J0KCk7XG4gICAgfSxcblxuICAgIGZldGNoOiBmdW5jdGlvbiAoKSB7XG4gICAgICAgIHJldHVybiB3b3JsZEFwaS5saXN0KClcbiAgICAgICAgICAgIC50aGVuKGZ1bmN0aW9uICh3b3JsZHMpIHtcbiAgICAgICAgICAgICAgICB0aGlzLnJlc2V0KHRoaXMucGFyc2Uod29ybGRzKSk7XG4gICAgICAgICAgICB9LmJpbmQodGhpcykpO1xuICAgIH0sXG5cbiAgICBwYXJzZTogZnVuY3Rpb24gKHdvcmxkcykge1xuICAgICAgICBpZiAod29ybGRzLmxlbmd0aCkge1xuICAgICAgICAgICAgd29ybGRzID0gXy5tYXAod29ybGRzLCBmdW5jdGlvbiAodykge1xuICAgICAgICAgICAgICAgIHZhciB1c2VycyA9IF8ubWFwKHcudXNlcnMsIGZ1bmN0aW9uICh1KSB7XG4gICAgICAgICAgICAgICAgICAgIC8vIGluIHRoZSB3b3JsZCBhcGkgdXNlcnMgSWRzIGNvbWVzIGFzIHVzZXJJZFxuICAgICAgICAgICAgICAgICAgICAvLyBtYWtlIHN1cmUgd2UgYWRkIGl0IGFzIGlkIHNvIHdlIGNhbiB1c2UgdGhlXG4gICAgICAgICAgICAgICAgICAgIC8vIHNhbWUgY29kZSB0byBhY2Nlc3MgbW9kZWxzIHRoYXQgY29tZSBmcm9tIHRoZVxuICAgICAgICAgICAgICAgICAgICAvLyBtZW1iZXIvbG9jYWwgYXBpIGFzIHdpdGggdGhlIHdvcmxkIGFwaVxuICAgICAgICAgICAgICAgICAgICB1LmlkID0gdS51c2VySWQ7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgVXNlck1vZGVsKHUpO1xuICAgICAgICAgICAgICAgIH0pO1xuXG4gICAgICAgICAgICAgICAgdy51c2VycyA9IHVzZXJzO1xuXG4gICAgICAgICAgICAgICAgcmV0dXJuIHc7XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfVxuXG4gICAgICAgIHJldHVybiB3b3JsZ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pbmNlIHRoZSBBUEkgY2FuIG9ubHkgb3BlcmF0ZSBvbiBvbmUgY2FsbCBwZXIgZ3JvdXAgYXQgYSB0aW1lXG4gICAgICAgICAgICB2YXIgcXVldWUgPSBuZXcgQWpheFF1ZXVlKCk7XG4gICAgICAgICAgICBfLmVhY2gocm93cywgZnVuY3Rpb24gKHZpZXcpIHtcbiAgICAgICAgICAgICAgICB2YXIgdXNlciA9IHZpZXcubW9kZWw7XG4gICAgICAgICAgICAgICAgcXVldWUuYWRkKGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHZpZXcubWFrZUluYWN0aXZlKClcbiAgICAgICAgICAgICAgICAgICAgICAgIC50aGVuKGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB1c2VyLnJlbW92ZSgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZpZXcucmVtb3ZlKCk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICAgICAgfSk7XG5cbiAgICAgICAgICAgIH0sIHRoaXMpO1xuXG4gICAgICAgICAgICBxdWV1ZS5leGVjdXRlKHRoaXMpLnRoZW4oZG9uZSk7XG4gICAgICAgIH0uYmluZCh0aGlzKTtcblxuICAgICAgICByZXR1cm4gdGhpcy51bmFzc2lnblVzZXJzKGlkcylcbiAgICAgICAgICAgIC50aGVuKG1ha2VVc2Vyc0luYWN0aXZlKTtcblxuXG4gICAgfSxcblxuICAgIHJlbmRlcjogZnVuY3Rpb24gKCkge1xuICAgICAgICB0aGlzLiQoJ3RhYmxlIHRib2R5JykuZW1wdHkoKTtcbiAgICAgICAgdGhpcy5yZW5kZXJUYWJsZSgpO1xuICAgICAgICB0aGlzLnRvZ2dsZUNvbnRyb2xscygpO1xuICAgIH0sXG5cbiAgICByZW5kZXJUYWJsZTogZnVuY3Rpb24gKCkge1xuICAgICAgICB0aGlzLnJvd1ZpZXdzID0ge307XG4gICAg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y1uby1yb2xlcy10ZXh0JykuaGlkZSgpO1xuICAgICAgICAgICAgdGhpcy4kKCcudGFibGUtY29udHJvbHMgLnNpbmdsZScpLnNob3coKTtcbiAgICAgICAgICAgIHRoaXMuJCgnLnRhYmxlLWNvbnRyb2xzIC5uby1yb2xlcycpLnNob3coKTtcblxuICAgICAgICB9XG5cbiAgICAgICAgaWYgKHRoaXMudXNlcnMuYWxsVXNlcnNBc3NpZ25lZCgpKSB7XG4gICAgICAgICAgICB0aGlzLiQoJy50YWJsZS1jb250cm9scycpLnJlbW92ZUNsYXNzKCd2aXNpYmxlJyk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0aGlzLiQoJy50YWJsZS1jb250cm9scycpLmFkZENsYXNzKCd2aXNpYmxlJyk7XG4gICAgICAgIH1cbiAgICB9LFxuXG4gICAgc2VsZWN0QWxsOiBmdW5jdGlvbiAoZSkge1xuICAgICAgICB0aGlzLiQoJ3Rib2R5IDpjaGVja2JveCcpLnByb3AoJ2NoZWNrZWQnLCBlLnRhcmdldC5jaGVja2VkKTtcbiAgICAgICAgdGhpcy51cGRhdGVDb250cm9scygpO1xuICAgIH0sXG5cbiAgICB0b2dnbGVDb250cm9sbHM6IGZ1bmN0aW9uIChlKSB7XG4gICAgICAgIHZhciB0b3RhbCA9IHRoaXMuJCgndGJvZHkgOmNoZWNrYm94Jyk7XG4gICAgICAgIHZhciBjaGVja2VkID0gdGhpcy4kKCd0Ym9keSA6Y2hlY2tib3g6Y2hlY2tlZCcpO1xuXG4gICAgICAgIGlmICh0b3RhbC5sZW5ndGggPT09IGNoZWNrZWQubGVuZ3RoKSB7XG4gICAgICAgICAgICB0aGlzLiQoJyNzZWxlY3QtYWxsJykuYXR0cignY2hlY2tlZCcsICdjaGVja2VkJyk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0aGlzLiQoJyNzZWxlY3QtYWxsJykucmVtb3ZlQXR0cignY2hlY2tlZCcpO1xuICAgICAgICB9X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ZXJBcGkuZ2V0KHsgaWQ6IHVzZXJzIH0pO1xuICAgICAgICAgICAgfTtcblxuICAgICAgICAgICAgcmV0dXJuIGxvYWRHcm91cE1lbWJlcnMoKVxuICAgICAgICAgICAgICAgIC50aGVuKGxvYWRVc2Vyc0luZm8pXG4gICAgICAgICAgICAgICAgLmZhaWwoZHRkLnJlamVjdCk7XG4gICAgICAgIH07XG5cbiAgICAgICAgZ2V0R3JvdXBVc2VycygpXG4gICAgICAgICAgICAudGhlbihmdW5jdGlvbiAodXNlcnMpIHtcbiAgICAgICAgICAgICAgICB1c2VycyA9IF8ubWFwKHVzZXJzLCBmdW5jdGlvbiAodSkgeyByZXR1cm4gXy5leHRlbmQodSwgeyBncm91cElkOiBncm91cElkIH0pOyB9KTtcbiAgICAgICAgICAgICAgICBfdGhpcy5zZXQodXNlcnMpO1xuICAgICAgICAgICAgICAgIGR0ZC5yZXNvbHZlKHVzZXJzKTtcbiAgICAgICAgICAgIH0pO1xuXG4gICAgICAgIHJldHVybiBkdGQucHJvbWlzZSgpO1xuICAgIH1cblxufSk7XG4iLCIndXNlIHN0cmljdCc7XG52YXIgc2VydmljZUxvY2F0b3IgPSByZXF1aXJlKCcuL3NlcnZpY2UtbG9jYXRvcicpO1xudmFyIGNsYXNzRnJvbSA9IHJlcXVpcmUoJy4uLy4uLy4uL3V0aWwvaW5oZXJpdCcpO1xudmFyIEJhc2UgPSByZXF1aXJlKCcuL2Jhc2UtbW9kZWwnKTtcbnZhciBfX3N1cGVyID0gQmFzZS5wcm90b3R5cGU7XG5cbm1vZHVsZS5leHBvcnRzID0gY2xhc3NGcm9tKEJhc2UsIHtcblxuICAgIGRlZmF1bHRzOiB7XG4gICAgICAgIHVzZXJzOiBudWxsLFxuICAgICAgICBtb2RlbDogJ21vZGVsLmVxbidcbiAgICB9LFxuXG4gICAgaW5pdGlhbGl6ZTogZnVuY3Rpb24gKCkge1xuICAgICAgICBfX3N1cGVyLmluaXRpYWxpemUuYXBwbHkodGhpcywg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aXMuX3dvcmxkQXBpXG4gICAgICAgICAgICAudXBkYXRlQ29uZmlnKHsgZmlsdGVyOiBpZCB9KVxuICAgICAgICAgICAgLnJlbW92ZVVzZXIoeyB1c2VySWQ6IHVzZXIuZ2V0KCdpZCcpIH0pXG4gICAgICAgICAgICAudGhlbihjaGVja1dvcmxkKTtcbiAgICB9LFxuXG4gICAgc2F2ZTogZnVuY3Rpb24gKCkge1xuICAgICAgICB2YXIgX3RoaXMgPSB0aGlzO1xuICAgICAgICB2YXIgbWFwVXNlcnMgPSBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICByZXR1cm4gXy5tYXAodGhpcy5nZXQoJ3VzZXJzJyksIGZ1bmN0aW9uICh1KSB7XG4gICAgICAgICAgICAgICAgdmFyIHJlcyA9IHsgdXNlcklkOiB1LmdldCgnaWQnKSB9O1xuICAgICAgICAgICAgICAgIHZhciByb2xlID0gdS5nZXQoJ3JvbGUnKTtcblxuICAgICAgICAgICAgICAgIGlmIChyb2xlKSB7XG4gICAgICAgICAgICAgICAgICAgIHJlcy5yb2xlID0gcm9sZTtcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICByZXR1cm4gcmVzO1xuICAgICAgICAgICAgfSk7XG4gICAgICAgIH0uYmluZCh0aGlzKTtcblxuICAgICAgICB2YXIgY3JlYXRlV29ybGQgPSBfLnBhcnRpYWwodGhpcy5fd29ybGRBcGkuY3JlYXRlLCB0aGlzLnBpY2soWydtb2RlbCcsICduYW1lJywgJ21pblVzZXJzJ10pKTtcbiAgICAgICAgdmFyIGFkZFVzZXJzID0gXy5wYXJ0aWFsKF90aGlzLl93b3JsZEFwaS5hZGRVc2VycywgbWFwVXNlcnMoKSwgeyBmaWx0ZXI6IF90aGlzLmdldCgnaWQnKSB9KTtcbiAgICAgICAgdmFyIHNhdmVkVXNlcnMgPSB0aGlzLmdldCgndXNlcnMnKTtcbiAgICAgICAgaWYgKHRoaXMuaXNOZXcoKSkge1xuICAgICAgICAgICA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c2VyOiBmdW5jdGlvbiAodXNlcikge1xuICAgICAgICB2YXIgd29ybGROYW1lID0gdXNlci5nZXQoJ3dvcmxkJyk7XG4gICAgICAgIHZhciBkdGQgPSAkLkRlZmVycmVkKCk7XG4gICAgICAgIHZhciBwcmV2V29ybGQgPSB0aGlzLmdldFdvcmxkQnlVc2VyKHVzZXIpO1xuICAgICAgICB2YXIgY3VyV29ybGQgPSB0aGlzLmdldE9yQ3JlYXRlV29ybGQod29ybGROYW1lKTtcbiAgICAgICAgdmFyIGRvbmUgPSBkb25lRm4oZHRkLCAxKTtcblxuICAgICAgICAvLyBjaGVjayBpZiB0aGVyZSdzIGFueXRoaW5nIHRvIGRvXG4gICAgICAgIGlmICghcHJldldvcmxkICYmICFjdXJXb3JsZCkge1xuICAgICAgICAgICAgcmV0dXJuIGR0ZC5yZXNvbHZlKCkucHJvbWlzZSgpO1xuICAgICAgICB9XG5cbiAgICAgICAgaWYgKHByZXZXb3JsZCkge1xuICAgICAgICAgICAgcHJldldvcmxkLnJlbW92ZVVzZXIodXNlcilcbiAgICAgICAgICAgICAgICAudGhlbihmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgICAgICAgIGlmIChjdXJXb3JsZCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGN1cldvcmxkLmFkZFVzZXIodXNlcik7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9KVxuICAgICAgICAgICAgICAgIC50aGVuKGRvbmUpO1xuICAgICAgICB9IGVsc2UgaWYgKGN1cldvcmxkKSB7XG4gICAgICAgICAgICBjdXJXb3JsZC5hZGRVc2VyKHVzZXIpXG4gICAgICAgICAgICAgICAgLnRoZW4oZG9uZSk7XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4gZHRkLnByb21pc2UoKTtcbiAgICB9LFxuXG4gICAgZ2V0T3JDcmVhdGVXb3JsZDogZnVuY3Rpb24gKHdvcmxkTmFtZSkge1xuICAgICAgICBpZiAoIXdvcmxkTmFtZSkge1xuICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICB9XG5cbiAgICAgICAgdmFyIHdvcmxkID0gdGhpcy5nZXRXb3JkQnlOYW1lKHdvcmxkTmFtZSk7XG5cbiAgICAgICAgaWYgKCF3b3JsZCkge1xuICAgICAgICAgICAgd29ybGQgPSB0aGlzLmNyZWF0ZSh7IG5hbWU6IHdvcmxkTmFtZSB9KTtcbiAgICAgICAgfVxuXG4gICAgICAgIHJldHVybiB3b3JsZDtcbiAgICB9LFxuXG4gICAgZ2V0V29yZEJ5TmFtZTogZnVuY3Rpb24gKHdvcmxkTmFtZSkge1xuICAgICAgICByZXR1cm4gdGhpcy5maW5kKGZ1bmN0aW9uICh3b3JsZCkge1xuICAgICAgICAgICAgcmV0dXJuIHdvcmxkLmdldCgnbmFtZScpID09PSB3b3JsZE5hbWU7XG4gICAgICAgIH0pO1xuICAgIH0sXG5cbiAgICBnZXRXb3JsZEJ5VXNlcjogZnVuY3Rpb24gKHVzZXIpIHtcbiAgICAgICAgaWYgKCF1c2VyLmdldCkge1xuICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCdnZXRXb3JsZEJ5VXNlciBleHBlY3RlcyBhIG1vZGVsICgnICsgdXNlciArICcpJyk7XG4gICAgICAgIH1cblxuICAgICAgICB2YXIgaWQgPSB1c2VyLmdldCgnaWQnKTtcbiAgICAgICAgcmV0dXJuIHRoaXMuZ2V0V29ybGRCeVVzZXJJZChpZCk7XG4gICAgfSxcblxuICAgIGdldFdvcmxkQnlVc2VySWQ6IGZ1bmN0aW9uICh1c2VySWQpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuZmluZChmdW5jdGlvbiAod29ybGQpIHtcbiAgICAgICAgICAgIHJldHVybiBfLmZpbmQod29ybGQuZ2V0KCd1c2VycycpLCBmdW5jdGlvbiAodSkge1xuICAgICAgICAgICAgICAgIHJldHVybiB1LmdldCgnaWQnKSA9PT0gdXNlcklkO1xuICAgICAgICAgIC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ICAgdXNlcnNDb2xsZWN0aW9uLnNvcnQoKTtcbiAgICB9LFxuXG4gICAgZmV0Y2g6IGZ1bmN0aW9uICgpIHtcbiAgICAgICAgcmV0dXJuIHdvcmxkQXBpLmxpc3QoKVxuICAgICAgICAgICAgLnRoZW4oZnVuY3Rpb24gKHdvcmxkcykge1xuICAgICAgICAgICAgICAgIHRoaXMucmVzZXQodGhpcy5wYXJzZSh3b3JsZHMpKTtcbiAgICAgICAgICAgIH0uYmluZCh0aGlzKSk7XG4gICAgfSxcblxuICAgIHBhcnNlOiBmdW5jdGlvbiAod29ybGRzKSB7XG4gICAgICAgIGlmICh3b3JsZHMubGVuZ3RoKSB7XG4gICAgICAgICAgICB3b3JsZHMgPSBfLm1hcCh3b3JsZHMsIGZ1bmN0aW9uICh3KSB7XG4gICAgICAgICAgICAgICAgdmFyIHVzZXJzID0gXy5tYXAody51c2VycywgZnVuY3Rpb24gKHUpIHtcbiAgICAgICAgICAgICAgICAgICAgLy8gaW4gdGhlIHdvcmxkIGFwaSB1c2VycyBJZHMgY29tZXMgYXMgdXNlcklkXG4gICAgICAgICAgICAgICAgICAgIC8vIG1ha2Ugc3VyZSB3ZSBhZGQgaXQgYXMgaWQgc28gd2UgY2FuIHVzZSB0aGVcbiAgICAgICAgICAgICAgICAgICAgLy8gc2FtZSBjb2RlIHRvIGFjY2VzcyBtb2RlbHMgdGhhdCBjb21lIGZyb20gdGhlXG4gICAgICAgICAgICAgICAgICAgIC8vIG1lbWJlci9sb2NhbCBhcGkgYXMgd2l0aCB0aGUgd29ybGQgYXBpXG4gICAgICAgICAgICAgICAgICAgIHUuaWQgPSB1LnVzZXJJZDtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBVc2VyTW9kZWwodSk7XG4gICAgICAgICAgICAgICAgfSk7XG5cbiAgICAgICAgICAgICAgICB3LnVzZXJzID0gdXNlcnM7XG5cbiAgICAgICAgICAgICAgICByZXR1cm4gdztcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9XG5cbiAgICAgICAgcmV0dXJuIHdvcmxkcztcbiAgICB9XG59KTtcbiIsIid1c2Ugc3RyaWN0JztcblxuLyoqXG4qIFV0aWxpdHkgY2xhc3MgdG8gbWFrZSBhamF4IGNhbGxzIHNlcXVlbmNpYWxcbiovXG5mdW5jdGlvbiBBamF4UXVldWUgKCkge1xuICAgIHRoaXMucXVldWUgPSBbXTtcbn1cblxuJC5leHRlbmQoQWpheFF1ZXVlLnByb3RvdHlwZSwge1xuICAgIGFkZDogZnVuY3Rpb24gKGZuKSB7XG4gICAgICAgIHJldHVybiB0aGlzLnF1ZXVlLnB1c2goZm4pO1xuICAgIH0sXG5cbiAgICBleGVjdXRlOiBmdW5jdGlvbiAoY29udGV4dCkge1xuICAgICAgICB2YXIgZHRkID0gJC5EZWZlcnJlZCgpO1xuICAgICAgICB2YXIgX3RoaXMgPSB0aGlzO1xuICAgICAgICBjb250ZXh0ID0gY29udGV4dCB8fCB0aGlzO1xuXG4gICAgICAgIGZ1bmN0aW9uIG5leHQoKSB7XG4gICAgICAgICAgICBpZiAoX3RoaXMucXVldWUubGVuZ3RoKSB7XG4gICAgICAgICAgICAgICAgdmFyIGZuID0gX3RoaXMucXVldWUuc2hpZnQoKTtcblxuICAgICAgICAgICAgICAgIGZuLmNhbGwoY29udGV4dClcbiAgICAgICAgICAgICAgICAgICAgLnRoZW4obmV4dClcbiAgICAgICAgICAgICAgICAgICAgLmZhaWwoZHRkLnJlamVjdCk7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIGR0ZC5yZXNvbHZlKCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICBuZXh0KCk7XG5cbiAgICAgICAgcmV0dXJuIGR0ZC5wcm9taXNlKCk7XG4gICAgfVxufSk7XG5cblxubW9kdWxlLmV4cG9ydHMgPSBBamF4UXVldWU7IiwiLyoqXG4vKiBJbmhlcml0IGZyb20gYSBjbGFzcyAodXNpbmcgcHJv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cm9wcy5oYXNPd25Qcm9wZXJ0eSgnY29uc3RydWN0b3InKSA/IHByb3BzLmNvbnN0cnVjdG9yIDogZnVuY3Rpb24gKCkgeyByZXR1cm4gcGFyZW50LmFwcGx5KHRoaXMsIGFyZ3VtZW50cyk7IH07XG5cbiAgICAvLyBhZGQgc3RhdGljIHByb3BlcnRpZXMgdG8gdGhlIGNoaWxkIGNvbnN0cnVjdG9yIGZ1bmN0aW9uXG4gICAgZXh0ZW5kKGNoaWxkLCBwYXJlbnQsIHN0YXRpY1Byb3BzKTtcblxuICAgIC8vIGFzc29jaWF0ZSBwcm90b3R5cGUgY2hhaW5cbiAgICBpbmhlcml0KGNoaWxkLCBwYXJlbnQpO1xuXG4gICAgLy8gYWRkIGluc3RhbmNlIHByb3BlcnRpZXNcbiAgICBpZiAocHJvcHMpIHtcbiAgICAgICAgZXh0ZW5kKGNoaWxkLnByb3RvdHlwZSwgcHJvcHMpO1xuICAgIH1cblxuICAgIC8vIGRvbmVcbiAgICByZXR1cm4gY2hpbGQ7XG59O1xuIl19 diff --git a/dist/components/login/login.js b/dist/components/login/login.js index 743bbf26..98cd82b0 100644 --- a/dist/components/login/login.js +++ b/dist/components/login/login.js @@ -92,8 +92,6 @@ $(function () { }) .then(function () { window.location = action; - }) - .done(function () { $('.group-selection-dialog').hide(); }); }); diff --git a/src/components/assignment/js/users-collection.js b/src/components/assignment/js/users-collection.js index 67c2e7d6..078fe3a6 100644 --- a/src/components/assignment/js/users-collection.js +++ b/src/components/assignment/js/users-collection.js @@ -70,7 +70,7 @@ module.exports = classFrom(Base, { .then(function (users) { users = _.map(users, function (u) { return _.extend(u, { groupId: groupId }); }); _this.set(users); - dtd.resolve(users, _this); + dtd.resolve(users); }); return dtd.promise(); diff --git a/src/managers/world-manager.js b/src/managers/world-manager.js index 4ef9e7a3..7601cd02 100644 --- a/src/managers/world-manager.js +++ b/src/managers/world-manager.js @@ -70,7 +70,7 @@ function buildStrategy(worldId, dtd) { return _this.runService.load(runId); }) .then(function (run) { - dtd.resolve.call(this, run, _this.runService); + dtd.resolveWith(_this, [run]); }) .fail(dtd.reject); } diff --git a/src/service/asset-api-adapter.js b/src/service/asset-api-adapter.js index 4d552453..bf18d560 100644 --- a/src/service/asset-api-adapter.js +++ b/src/service/asset-api-adapter.js @@ -302,7 +302,7 @@ module.exports = function (config) { var fullPathFiles = $.map(files, function (file) { return buildUrl(file, urlOptions); }); - dtd.resolve(fullPathFiles, me); + dtd.resolveWith(me, [fullPathFiles]); }) .fail(dtd.reject); diff --git a/src/service/world-api-adapter.js b/src/service/world-api-adapter.js index af1b07eb..89bdee36 100644 --- a/src/service/world-api-adapter.js +++ b/src/service/world-api-adapter.js @@ -585,10 +585,10 @@ module.exports = function (config) { var currentWorld = worlds[0]; if (currentWorld) { - serviceOptions.filter = currentWorld.id; + serviceOptions.filter = currentWorld.id; } - dtd.resolve(currentWorld, me); + dtd.resolveWith(me, [currentWorld]); }) .fail(dtd.reject); diff --git a/tests/spec/test-conditional-creation-strategy.js b/tests/spec/test-conditional-creation-strategy.js index f4862be8..f94b9916 100644 --- a/tests/spec/test-conditional-creation-strategy.js +++ b/tests/spec/test-conditional-creation-strategy.js @@ -33,9 +33,7 @@ var setupServer = function () { server = sinon.fakeServer.create(); - setupResponse('GET', /run\/forio-dev\/js-libs/, 200, runs || []); - server.autorespond = true; }; diff --git a/tests/spec/test-world-manager.js b/tests/spec/test-world-manager.js index 0793148f..0ea575b6 100644 --- a/tests/spec/test-world-manager.js +++ b/tests/spec/test-world-manager.js @@ -140,12 +140,9 @@ describe('getCurrentRun', function (done) { it('should return the current run object and runService of the run of the current world', function (done) { createWorldManager().getCurrentRun('model.py') - .then(function (run, runService) { + .then(function (run) { run.should.not.be.null; run.id.should.be.equal('run2'); - - runService.should.not.be.null; - done(); }) .fail(function () { From 1c94786beef5e0789c2cef143eaf74480ba7b2af Mon Sep 17 00:00:00 2001 From: Naren Ranjit Date: Thu, 15 Sep 2016 16:25:05 -0700 Subject: [PATCH 12/16] passing tests --- tests/spec/test-multiplayer-strategy.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/tests/spec/test-multiplayer-strategy.js b/tests/spec/test-multiplayer-strategy.js index 80da769f..8ec51cc2 100644 --- a/tests/spec/test-multiplayer-strategy.js +++ b/tests/spec/test-multiplayer-strategy.js @@ -25,7 +25,8 @@ var setupResponse = function (verb, endpoint, statusCode, resp, respHeaders) { server.respondWith(verb, endpoint, function (xhr, id) { - var headers = _.extend({}, { 'Content-Type': 'application/json' }, respHeaders); + var ct = typeof resp === 'string' ? {} : { 'Content-Type': 'application/json' }; + var headers = _.extend({}, ct, respHeaders); var body = typeof resp === 'object' ? JSON.stringify(resp) : resp; xhr.respond(statusCode, headers, body); }); @@ -49,7 +50,10 @@ var setupServer = function (worlds) { server = sinon.fakeServer.create(); - + server.respondWith('GET', /(.*)\/run\/(.*)\/(.*)/, function (xhr, id) { + xhr.respond(200, { 'Content-Type': 'application/json' }, JSON.stringify({ url: xhr.url })); + return true; + }); setupResponse('GET', queryMatchers.worldEndpoint, 200, worlds || []); setupResponse('POST', /multiplayer\/world\/worldid1\/run/, 201, 'run1'); setupResponse('POST', /multiplayer\/world\/worldid2\/run/, 201, 'run2'); @@ -61,7 +65,7 @@ server.restore(); }; - describe.only('Multiplayer strategy', function () { + describe('Multiplayer strategy', function () { beforeEach(_.partial(setupServer, worldSet)); afterEach(teardownServer); @@ -84,15 +88,18 @@ describe('with world/users setup correctly', function () { it('should get the list of worlds for the current user first', function () { return createRunManager().getRun().then(function () { - var req = server.requests.pop(); + var req = server.requests[0]; req.method.toUpperCase().should.equal('GET'); req.url.should.match(queryMatchers.getWorlds); + }).fail(function () { + var s = server; + console.log(arguments); }); }); it('should post to the run endpoint after getting the world', function () { return createRunManager().getRun().then(function () { - var req = server.requests.pop(); + var req = server.requests[1]; req.method.toUpperCase().should.equal('POST'); req.url.should.match(/multiplayer\/world\/worldid2\/run/); }); @@ -102,7 +109,7 @@ describe('with two worlds for the user', function () { it('should use the latest world to retore the run', function () { return createRunManager().getRun().then(function () { - var req = server.requests.pop(); + var req = server.requests[1]; req.method.toUpperCase().should.equal('POST'); req.url.should.match(/multiplayer\/world\/worldid2/); }); From 012c0c3f15ad75c9ac0f795995767a97f0762f27 Mon Sep 17 00:00:00 2001 From: Naren Ranjit Date: Thu, 15 Sep 2016 16:26:48 -0700 Subject: [PATCH 13/16] passing tests --- tests/spec/test-env-load.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/spec/test-env-load.js b/tests/spec/test-env-load.js index dc060f0f..137f06db 100644 --- a/tests/spec/test-env-load.js +++ b/tests/spec/test-env-load.js @@ -10,7 +10,7 @@ var server; beforeEach(function () { server = sinon.fakeServer.create(); - server.autoRespond = true; + server.respondImmediately = true; }); afterEach(function () { @@ -39,7 +39,6 @@ delete F.service.URL.host; //done(); }); - //server.respond(); }); it('it should set protocol and host to api.forio.com when the config request fails', function () { @@ -54,8 +53,9 @@ F.service.URL.host.should.equal('api.forio.com'); delete F.service.URL.protocol; delete F.service.URL.host; - }).fail(callback); - callback.should.have.been.called; + }).then(null, callback).then(function () { + callback.should.have.been.called; + }); }); }); }); From e284bb730c4156c9c12248caaaebfcb120202125 Mon Sep 17 00:00:00 2001 From: Naren Ranjit Date: Thu, 15 Sep 2016 16:32:31 -0700 Subject: [PATCH 14/16] autorespond => respondImmediately --- tests/spec/test-ajax-http-transport.js | 4 +- tests/spec/test-auth-api-service.js | 3 +- tests/spec/test-auth-manager.js | 39 ++++++++++--------- .../test-conditional-creation-strategy.js | 11 +----- tests/spec/test-group-api-service.js | 2 +- tests/spec/test-member-api-service.js | 2 +- tests/spec/test-user-api-adapter.js | 2 +- tests/spec/test-world-api-service.js | 2 +- tests/spec/test-world-manager.js | 5 +-- 9 files changed, 29 insertions(+), 41 deletions(-) diff --git a/tests/spec/test-ajax-http-transport.js b/tests/spec/test-ajax-http-transport.js index ba636417..f08041cd 100644 --- a/tests/spec/test-ajax-http-transport.js +++ b/tests/spec/test-ajax-http-transport.js @@ -13,7 +13,7 @@ server.respondWith('GET', /api\.fail/, function (xhr, id) { xhr.respond(500, { 'Content-Type': 'application/json' }, JSON.stringify({ url: xhr.url })); }); - //server.autoRespond = true; + server.respondImmediately = true; }); @@ -96,7 +96,6 @@ ajax.get({ a:2,b:3 }, { success: callback }); - server.respond(); callback.called.should.equal(true); }); it('should call fail callback on success', function () { @@ -106,7 +105,6 @@ ajax.get({ a:2,b:3 }, { error: callback }); - server.respond(); callback.called.should.equal(true); }); diff --git a/tests/spec/test-auth-api-service.js b/tests/spec/test-auth-api-service.js index aff4d0b6..c92803cf 100644 --- a/tests/spec/test-auth-api-service.js +++ b/tests/spec/test-auth-api-service.js @@ -14,7 +14,7 @@ { 'refresh_token':'snip-refresh','access_token': token,'expires':43199 } )); }); - server.autoRespond = true; + server.respondImmediately = true; }); after(function () { @@ -27,7 +27,6 @@ var as = new AuthService({ transport: { beforeSend: callback } }); as.login({ userName: 'john', password: 'y' }); - server.respond(); server.requests.pop(); callback.should.have.been.called; }); diff --git a/tests/spec/test-auth-manager.js b/tests/spec/test-auth-manager.js index f34d0122..4588eeca 100644 --- a/tests/spec/test-auth-manager.js +++ b/tests/spec/test-auth-manager.js @@ -86,26 +86,29 @@ var response = multipleGroupsResponse ? multipleGroups : singleGroup; xhr.respond(200, { 'Content-Type': 'application/json' }, JSON.stringify(response)); }); - server.autoRespond = true; + server.respondImmediately = true; }); + afterEach(function () { + server.requests = []; + }); after(function () { server.restore(); }); describe('Login', function () { - it ('It should construct the right authenticaton request', function () { + it('It should construct the right authenticaton request', function () { var am = new F.manager.AuthManager({ account: 'accountName', project: 'projectName', }); am.login({ userName: 'test', password: 'test' }); - var req = server.requests.pop(); + var req = server.requests[0]; req.method.toUpperCase().should.equal('POST'); req.url.should.match(/https:\/\/api\.forio\.com\/authentication\/?/); }); - it ('It should call members API on sucessful login', function (done) { + it('It should call members API on sucessful login', function (done) { var am = new F.manager.AuthManager({ account: 'accountName', project: 'projectName', @@ -121,7 +124,7 @@ }); }); - it ('it should set the session', function (done) { + it('it should set the session', function (done) { var am = new F.manager.AuthManager({ account: 'accountName', project: 'projectName', @@ -141,7 +144,7 @@ }); }); - it ('it should fail when the user has multiple groups', function (done) { + it('it should fail when the user has multiple groups', function (done) { multipleGroupsResponse = true; var am = new F.manager.AuthManager({ account: 'accountName', @@ -157,7 +160,7 @@ }); }); - it ('it should work when a group is specified', function (done) { + it('it should work when a group is specified', function (done) { multipleGroupsResponse = true; var am = new F.manager.AuthManager({ account: 'accountName', @@ -175,7 +178,7 @@ }); }); - it ('it should not work when a wrong group is used', function (done) { + it('it should not work when a wrong group is used', function (done) { multipleGroupsResponse = true; var am = new F.manager.AuthManager({ account: 'accountName', @@ -191,7 +194,7 @@ }); }); - it ('should log a team member and get all the groups in the project', function (done) { + it('should log a team member and get all the groups in the project', function (done) { teamMemberResponse = true; var am = new F.manager.AuthManager({ account: 'accountName', @@ -212,7 +215,7 @@ }); - it ('it should fail with the list of groups on a team member login with no group', function (done) { + it('it should fail with the list of groups on a team member login with no group', function (done) { multipleGroupsResponse = true; teamMemberResponse = true; var am = new F.manager.AuthManager({ @@ -237,7 +240,7 @@ }); describe('Logout', function () { - it ('It should remove the epicenter cookie', function (done) { + it('It should remove the epicenter cookie', function (done) { sinon.spy(cookie, 'set'); var am = new F.manager.AuthManager({ account: 'accountName', @@ -261,7 +264,7 @@ }); describe('#setting cookies', function () { - it ('creates cookie with the correct path name when passing in account info in consructor', function () { + it('creates cookie with the correct path name when passing in account info in consructor', function () { var am = new F.manager.AuthManager({ account: 'accountName', project: 'projectName', @@ -271,7 +274,7 @@ var store = am.sessionManager.getStore(); store.serviceOptions.root.should.equal('/app/accountName/projectName'); }); - it ('creates cookie with the root path in local mode', function () { + it('creates cookie with the root path in local mode', function () { var am = new F.manager.AuthManager({ account: 'accountName', project: 'projectName', @@ -280,7 +283,7 @@ var store = am.sessionManager.getStore(); store.serviceOptions.root.should.equal('/'); }); - it ('creates cookie with the correct path name when passing in account info in login', function (done) { + it('creates cookie with the correct path name when passing in account info in login', function (done) { var am = new F.manager.AuthManager({ isLocal: false, store: { @@ -305,7 +308,7 @@ }); describe('#addGroups', function () { - it ('it should have one group on login', function (done) { + it('it should have one group on login', function (done) { var am = new F.manager.AuthManager({ account: 'accountName', project: 'projectName', @@ -320,7 +323,7 @@ }); }); - it ('it should accept an object', function (done) { + it('it should accept an object', function (done) { var am = new F.manager.AuthManager({ account: 'accountName', project: 'projectName', @@ -343,7 +346,7 @@ }); }); - it ('it should accept an array', function (done) { + it('it should accept an array', function (done) { var am = new F.manager.AuthManager({ account: 'accountName', project: 'projectName', @@ -371,7 +374,7 @@ }); }); - it ('it should override a project\'s group', function (done) { + it('it should override a project\'s group', function (done) { var am = new F.manager.AuthManager({ account: 'accountName', project: 'projectName', diff --git a/tests/spec/test-conditional-creation-strategy.js b/tests/spec/test-conditional-creation-strategy.js index f94b9916..a42826f5 100644 --- a/tests/spec/test-conditional-creation-strategy.js +++ b/tests/spec/test-conditional-creation-strategy.js @@ -34,7 +34,7 @@ var setupServer = function () { server = sinon.fakeServer.create(); setupResponse('GET', /run\/forio-dev\/js-libs/, 200, runs || []); - server.autorespond = true; + server.respondImmediately = true; }; var teardownServer = function () { @@ -42,15 +42,6 @@ }; describe('Conditional Creation Strategy', function () { - - before(function () { - - }); - - after(function () { - - }); - beforeEach(function () { setupServer(); }); diff --git a/tests/spec/test-group-api-service.js b/tests/spec/test-group-api-service.js index c692005b..e2783ac5 100644 --- a/tests/spec/test-group-api-service.js +++ b/tests/spec/test-group-api-service.js @@ -5,7 +5,7 @@ describe('Group API Service', function () { before(function () { server = sinon.fakeServer.create(); - server.autoRespond = true; + server.respondImmediately = true; }); after(function () { diff --git a/tests/spec/test-member-api-service.js b/tests/spec/test-member-api-service.js index 366977c1..9bb46595 100644 --- a/tests/spec/test-member-api-service.js +++ b/tests/spec/test-member-api-service.js @@ -15,7 +15,7 @@ xhr.respond(201, { 'Content-Type': 'application/json' }, JSON.stringify({ })); }); - server.autoRespond = true; + server.respondImmediately = true; }); after(function () { diff --git a/tests/spec/test-user-api-adapter.js b/tests/spec/test-user-api-adapter.js index b1098bec..1dbfe5f7 100644 --- a/tests/spec/test-user-api-adapter.js +++ b/tests/spec/test-user-api-adapter.js @@ -12,7 +12,7 @@ describe('User API Service', function () { before(function () { server = sinon.fakeServer.create(); - server.autoRespond = true; + server.respondImmediately = true; }); after(function () { diff --git a/tests/spec/test-world-api-service.js b/tests/spec/test-world-api-service.js index fc61a6ed..abdd9e1c 100644 --- a/tests/spec/test-world-api-service.js +++ b/tests/spec/test-world-api-service.js @@ -13,7 +13,7 @@ xhr.respond(204, { 'Content-Type': 'application/json' }, null); }); - server.autoRespond = true; + server.respondImmediately = true; }); afterEach(function () { diff --git a/tests/spec/test-world-manager.js b/tests/spec/test-world-manager.js index 0ea575b6..290dddc0 100644 --- a/tests/spec/test-world-manager.js +++ b/tests/spec/test-world-manager.js @@ -62,10 +62,7 @@ lastModified: '123' })); }); - - - - server.autoRespond = true; + server.respondImmediately = true; }); afterEach(function () { From 16357baf1f586fa01fa569400c48978faf4d1545 Mon Sep 17 00:00:00 2001 From: Naren Ranjit Date: Thu, 15 Sep 2016 16:34:05 -0700 Subject: [PATCH 15/16] linting errors --- tests/spec/test-multiplayer-strategy.js | 3 --- tests/spec/test-run-api-service-callbacks.js | 4 ++-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/tests/spec/test-multiplayer-strategy.js b/tests/spec/test-multiplayer-strategy.js index 8ec51cc2..cdbd467c 100644 --- a/tests/spec/test-multiplayer-strategy.js +++ b/tests/spec/test-multiplayer-strategy.js @@ -91,9 +91,6 @@ var req = server.requests[0]; req.method.toUpperCase().should.equal('GET'); req.url.should.match(queryMatchers.getWorlds); - }).fail(function () { - var s = server; - console.log(arguments); }); }); diff --git a/tests/spec/test-run-api-service-callbacks.js b/tests/spec/test-run-api-service-callbacks.js index 5a40684b..8a5b7432 100644 --- a/tests/spec/test-run-api-service-callbacks.js +++ b/tests/spec/test-run-api-service-callbacks.js @@ -43,7 +43,7 @@ var cb2 = sinon.spy(); var rs = new RunService({ account: 'forio', project: 'js-libs', filter: { saved: true } }); - return rs.do('add', [1,2], { success: cb1 }).then(cb2).then( function () { + return rs.do('add', [1,2], { success: cb1 }).then(cb2).then(function () { cb1.should.have.been.called; cb2.should.have.been.called; }); @@ -219,7 +219,7 @@ var rs = new RunService({ account: 'forio', project: 'js-libs', filter: { saved: true } }); return rs.save({ completed: true }, { success: cb1 }).then(cb2).then(function () { cb1.should.have.been.called; - cb2.should.have.been.called; + cb2.should.have.been.called; }); }); it('passes error callbacks', function () { From 5f7d4b3871c9ae9c3bf7d8068b1189c6441e2443 Mon Sep 17 00:00:00 2001 From: Molly Jones Date: Tue, 20 Sep 2016 11:55:58 -0700 Subject: [PATCH 16/16] epicenter-2129: updating jquery version in bundled components too --- src/components/assignment/index.html | 2 +- src/components/login/index.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/assignment/index.html b/src/components/assignment/index.html index 1ac536db..2d3ae940 100644 --- a/src/components/assignment/index.html +++ b/src/components/assignment/index.html @@ -8,7 +8,7 @@ - + diff --git a/src/components/login/index.html b/src/components/login/index.html index 431e42e6..e80f30db 100644 --- a/src/components/login/index.html +++ b/src/components/login/index.html @@ -14,7 +14,7 @@ - +