From 3b9961571101a98e3116dd90dbd0fc20ec70e6df Mon Sep 17 00:00:00 2001 From: Evgeny Poberezkin Date: Thu, 20 Aug 2015 11:53:29 +0100 Subject: [PATCH] 0.2.9: logger emit messages, config.check is false by default --- dist/milo.bundle.js | 46 +++++++++++++------- package.json | 4 +- test/abstract/faceted_object_test.js | 15 ++++++- test/abstract/registry_test.js | 11 ++++- test/attributes/a_bind_test.js | 11 ++++- test/check_test.js | 11 ++++- test/components/c_facets/cf_registry_test.js | 11 ++++- test/components/c_registry_test.js | 11 ++++- 8 files changed, 97 insertions(+), 23 deletions(-) diff --git a/dist/milo.bundle.js b/dist/milo.bundle.js index 9110873..f191615 100644 --- a/dist/milo.bundle.js +++ b/dist/milo.bundle.js @@ -13399,7 +13399,7 @@ config({ mixin: { instancePropertiesMap: '___mixin_instances' }, - check: true, + check: false, debug: false }); @@ -14092,8 +14092,7 @@ function getMessageSource() { },{"../abstract/mixin":100,"../util/check":119,"./m_source":106,"mol-proto":125}],104:[function(require,module,exports){ 'use strict'; -var _ = require('mol-proto') - , logger = require('../util/logger'); +var _ = require('mol-proto'); module.exports = MessengerAPI; @@ -14183,7 +14182,7 @@ function addInternalMessage(message) { if (internalMsgs.indexOf(message) == -1) internalMsgs.push(message); else - logger.warn('Duplicate addInternalMessage call for internal message ' + message); + require('../util/logger').warn('Duplicate addInternalMessage call for internal message ' + message); } else { internalMsgs = this._internalMessages[sourceMessage] = []; internalMsgs.push(message); @@ -14222,7 +14221,7 @@ function removeInternalMessage(message) { function unexpectedNotificationWarning() { - logger.warn('notification received: un-subscribe from internal message ' + message + require('../util/logger').warn('notification received: un-subscribe from internal message ' + message + ' without previous subscription notification'); } } @@ -14401,7 +14400,6 @@ function getInternalMessages(sourceMessage) { var Mixin = require('../abstract/mixin') , MessengerAPI = require('./m_api') - , logger = require('../util/logger') , _ = require('mol-proto') , check = require('../util/check') , Match = check.Match; @@ -14572,7 +14570,7 @@ function toBeImplemented() { throw new Error('calling the method of an absctract class'); } -},{"../abstract/mixin":100,"../util/check":119,"../util/logger":121,"./m_api":104,"mol-proto":125}],107:[function(require,module,exports){ +},{"../abstract/mixin":100,"../util/check":119,"./m_api":104,"mol-proto":125}],107:[function(require,module,exports){ 'use strict'; @@ -17024,7 +17022,8 @@ module.exports = logger; // true by default. Set to false to disable all logging in browser console. -var _ = require('mol-proto'); +var _ = require('mol-proto') + , Messenger = require('../messenger'); /** @@ -17075,14 +17074,23 @@ var DEFAULT_OPTIONS = { } +/** + * Expose Messenger methods on Logger prototype + */ +var MESSENGER_PROPERTY = '_messenger'; +Messenger.useWith(Logger, MESSENGER_PROPERTY, Messenger.defaultMethods); + + /** * Logger (console). * * @api public */ -var Logger = function (opts) { +function Logger(opts) { _.extend(this, DEFAULT_OPTIONS); _.extend(this, opts || {}); + var messenger = new Messenger(this); + _.defineProperty(this, MESSENGER_PROPERTY, messenger); }; @@ -17098,10 +17106,14 @@ Logger.prototype.log = function (type) { if (! this.enabled || index > this.level) return this; - var args = _.slice(arguments, 1); + var args = _.slice(arguments, 1) + , self = this; if (index <= this.throwLevel) - throw new Error([this.logPrefix, type + ':'].concat(args).join(' ')); + throw new Error(logString()); + + if (index <= this.messageLevel) + this.postMessage('log', { level: index, type: type, str: logString() }); console.log.apply( console @@ -17115,6 +17127,11 @@ Logger.prototype.log = function (type) { ); return this; + + + function logString() { + return [self.logPrefix, type + ':'].concat(args).join(' '); + } }; /** @@ -17130,7 +17147,7 @@ levels.forEach(function (name) { module.exports = Logger; -},{"mol-proto":125}],123:[function(require,module,exports){ +},{"../messenger":103,"mol-proto":125}],123:[function(require,module,exports){ // doT.js // 2011-2014, Laura Doktorova, https://github.com/olado/doT // Licensed under the MIT license. @@ -19458,6 +19475,5 @@ function makeFindMethod(someMethod, findWhat) { } },{}]},{},[67]) - -; -//# sourceMappingURL=milo.bundle.map \ No newline at end of file +//@ sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi9Vc2Vycy9ldmdl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RoaXMuY29tcEZhY2V0cyAmJiB0aGlzLmNvbXBGYWNldHMubGVuZ3RoXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgID8gJ1snICsgdGhpcy5jb21wRmFjZXRzLmpvaW4oJywgJykgKyAnXSdcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgOiAnJylcbiAgICAgICAgICAgICAgICAucmVwbGFjZSgnJWNvbXBOYW1lJywgdGhpcy5jb21wTmFtZSk7XG59XG5cblxuLyoqXG4gKiBCaW5kQXR0cmlidXRlIGNsYXNzIG1ldGhvZFxuICogQHBhcmFtIHtFbGVtZW50fSBlbFxuICogQHBhcmFtIHtTdHJpbmd9IGNvbXBvbmVudENsYXNzIG9wdGlvbmFsIGNsYXNzIG5hbWVcbiAqIEBwYXJhbSB7U3RyaW5nfSBjb21wb25lbnROYW1lIG9wdGlvbmFsXG4gKiBAcGFyYW0ge0FycmF5PFN0cmluZz59IGNvbXBvbmVudEZhY2V0cyBvcHRpb25hbCBleHRyYSBmYWNldCB0byBhZGQgdG8gdGhlIGNsYXNzXG4gKi9cbmZ1bmN0aW9uIEJpbmRBdHRyaWJ1dGUkJHNldEluZm8oZWwsIGNvbXBvbmVudENsYXNzLCBjb21wb25lbnROYW1lLCBjb21wb25lbnRGYWNldHMpIHtcbiAgICB2YXIgYXR0ciA9IG5ldyBCaW5kQXR0cmlidXRlKGVsKTtcbiAgICBfLmV4dGVuZChhdHRyLCB7XG4gICAgICAgIGNvbXBDbGFzczogY29tcG9uZW50Q2xhc3MsXG4gICAgICAgIGNvbXBOYW1lOiBjb21wb25lbnROYW1lLFxuICAgICAgICBjb21wRmFjZXRzOiBjb21wb25lbnRGYWNldHNcbiAgICB9KTtcbiAgICBhdHRyLmRlY29yYXRlKCk7XG59XG4iLCIndXNlIHN0cmljdCc7XG5cbnZhciBtaWxvQ29yZSA9IHJlcXVpcmUoJ21pbG8tY29yZScpXG4gICAgLCBfID0gbWl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uZnVuY3Rpb24gc2NhbihzY29wZUVsLCByb290U2NvcGUsIGJpbmRSb290RWxlbWVudCwgdGhyb3dPbkVycm9ycykge1xuICAgIHJldHVybiBjcmVhdGVCaW5kZXJTY29wZShzY29wZUVsLCBmdW5jdGlvbihzY29wZSwgZWwsIGF0dHIsIHRocm93T25FcnJvcnMpIHtcbiAgICAgICAgcmV0dXJuIG5ldyBDb21wb25lbnRJbmZvKHNjb3BlLCBlbCwgYXR0ciwgdGhyb3dPbkVycm9ycyk7XG4gICAgfSwgcm9vdFNjb3BlLCBiaW5kUm9vdEVsZW1lbnQsIHRocm93T25FcnJvcnMpO1xufVxuXG5cbi8vIGNyZWF0ZSBib3VuZCBjb21wb25lbnRzXG5mdW5jdGlvbiBjcmVhdGUoc2NhblNjb3BlLCBob3N0T2JqZWN0LCB0aHJvd09uRXJyb3JzKSB7XG4gICAgdmFyIHNjb3BlID0gbmV3IFNjb3BlKHNjYW5TY29wZS5fcm9vdEVsLCBob3N0T2JqZWN0KVxuICAgICAgICAsIGFkZE1ldGhvZCA9IHRocm93T25FcnJvcnMgPT09IGZhbHNlID8gJ19zYWZlQWRkJyA6ICdfYWRkJztcblxuICAgIHNjYW5TY29wZS5fZWFjaChmdW5jdGlvbihjb21wSW5mbykge1xuICAgICAgICAvLyBzZXQgY29ycmVjdCBjb21wb25lbnQncyBzY29wZVxuICAgICAgICB2YXIgaW5mbyA9IF8uY2xvbmUoY29tcEluZm8pXG4gICAgICAgIGluZm8uc2NvcGUgPSBzY29wZTtcblxuICAgICAgICAvLyBjcmVhdGUgY29tcG9uZW50XG4gICAgICAgIHZhciBhQ29tcG9uZW50ID0gQ29tcG9uZW50LmNyZWF0ZShpbmZvLCB0aHJvd09uRXJyb3JzKTtcblxuICAgICAgICBzY29wZVthZGRNZXRob2RdKGFDb21wb25lbnQsIGFDb21wb25lbnQubmFtZSk7XG4gICAgICAgIGlmIChhQ29tcG9uZW50LmNvbnRhaW5lcilcbiAgICAgICAgICAgIGFDb21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VyKTtcblxuICAgICAgICBpZiAoc3Vic2NyaWJlclR5cGUgPT0gJ29iamVjdCcpIHtcbiAgICAgICAgICAgIHZhciBjb250ZXh0VHlwZSA9IHR5cGVvZiBzdWJzY3JpYmVyLmNvbnRleHQ7XG4gICAgICAgICAgICBpZiAoY29udGV4dFR5cGUgPT0gJ29iamVjdCcpXG4gICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMub24obWVzc2FnZXMsIHN1YnNjcmliZXIpO1xuXG4gICAgICAgICAgICBpZiAoY29udGV4dFR5cGUgPT0gJ3N0cmluZycpIHtcbiAgICAgICAgICAgICAgICBpZiAoc3Vic2NyaWJlci5jb250ZXh0ID09IHRoaXMubmFtZSB8fCBzdWJzY3JpYmVyLmNvbnRleHQgPT0gJ2ZhY2V0JylcbiAgICAgICAgICAgICAgICAgICAgc3Vic2NyaWJlciA9IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHN1YnNjcmliZXI6IHN1YnNjcmliZXIuc3Vic2NyaWJlcixcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRleHQ6IHRoaXNcbiAgICAgICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgICAgICBlbHNlIGlmIChzdWJzY3JpYmVyLmNvbnRleHQgPT0gJ293bmVyJylcbiAgICAgICAgICAgICAgICAgICAgc3Vic2NyaWJlciA9IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHN1YnNjcmliZXI6IHN1YnNjcmliZXIuc3Vic2NyaWJlcixcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRleHQ6IHRoaXMub3duZXJcbiAgICAgICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgICAgICBlbHNlXG4gICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcigndW5rbm93biBzdWJzY3JpYmVyIGNvbnRleHQgaW4gY29uZmlndXJhdGlvbjogJyArIHN1YnNjcmliZXIuY29udGV4dCk7XG5cbiAgICAgICAgICAgICAgICByZXR1cm4gdGh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ICAgICAgICAgICBsaXN0RmFjZXQuX3VwZGF0ZURhdGFQYXRocyhsaXN0TGVuZ3RoLCBsaXN0RmFjZXQuY291bnQoKSk7XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgdmFsdWUuZm9yRWFjaChmdW5jdGlvbihjaGlsZFZhbHVlLCBpbmRleCkge1xuICAgICAgICAgICAgICAgICAgICBzZXRDaGlsZERhdGEuY2FsbCh0aGlzLCB2YWx1ZVNldCwgY2hpbGRWYWx1ZSwgaW5kZXgsICdbJCRdJyk7XG4gICAgICAgICAgICAgICAgfSwgdGhpcyk7XG5cbiAgICAgICAgICAgICAgICB2YXIgbGlzdENvdW50ID0gbGlzdEZhY2V0LmNvdW50KClcbiAgICAgICAgICAgICAgICAgICAgLCByZW1vdmVDb3VudCA9IGxpc3RDb3VudCAtIHZhbHVlLmxlbmd0aDtcblxuICAgICAgICAgICAgICAgIHdoaWxlIChyZW1vdmVDb3VudC0tID4gMClcbiAgICAgICAgICAgICAgICAgICAgbGlzdEZhY2V0Ll9yZW1vdmVJdGVtKHZhbHVlLmxlbmd0aCk7XG4gICAgICAgICAgICB9IGVsc2VcbiAgICAgICAgICAgICAgICBsb2dnZXIud2FybignRGF0YTogc2V0dGluZyBhcnJheSBkYXRhIHdpdGhvdXQgTGlzdCBmYWNldCcpO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgdmFsdWVTZXQgPSB7fTtcbiAgICAgICAgICAgIF8uZWFjaEtleSh2YWx1ZSwgZnVuY3Rpb24oY2hpbGRWYWx1ZSwga2V5KSB7XG4gICAgICAgICAgICAgICAgc2V0Q2hpbGREYXRhLmNhbGwodGhpcywgdmFsdWVTZXQsIGNoaWxkVmFsdWUsIGtleSwgJy4kJCcpO1xuICAgICAgICAgICAgfSwgdGhpcyk7XG4gICAgICAgIH1cbiAgICB9IGVsc2VcbiAgICAgICAgdmFsdWVTZXQgPSB0aGlzLl9zZXRTY2FsYXJWYWx1ZSh2YWx1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G4gICAgICAgICAgICAvLyBjb21wb25lbnQgY2xhc3NcbiAgICAgICAgICAgIGNhc2UgJ3N0cmluZyc6XG4gICAgICAgICAgICAgICAgcmV0dXJuIG1ldGEgJiYgbWV0YS5jb21wQ2xhc3MgPT0gYWxsb3dDb21wcztcbiAgICAgICAgICAgIC8vIHRlc3QgZnVuY3Rpb25cbiAgICAgICAgICAgIGNhc2UgJ2Z1bmN0aW9uJzpcbiAgICAgICAgICAgICAgICByZXR1cm4gYWxsb3dDb21wcy5jYWxsKHRoaXMub3duZXIsIG1ldGEsIGR0LCBvcmlnaW5hbERyb3BDb21wb25lbnQpO1xuICAgICAgICAgICAgY2FzZSAnb2JqZWN0JzpcbiAgICAgICAgICAgICAgICBpZiAoQXJyYXkuaXNBcnJheShhbGxvd0NvbXBzKSlcbiAgICAgICAgICAgICAgICAgICAgLy8gbGlzdCBvZiBhbGxvd2VkIGNsYXNzZXNcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGFsbG93Q29tcHMuaW5kZXhPZihtZXRhICYmIG1ldGEuY29tcENsYXNzKSA+PSAwO1xuICAgICAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAvLyBtYXAgb2YgY2xhc3M6IGJvb2xlYW58dGVzdCBmdW5jdGlvblxuICAgICAgICAgICAgICAgICAgICB2YXIgdGVzdCA9IGFsbG93Q29tcHNbbWV0YSAmJiBtZXRhLmNvbXBDbGFzc107XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiAhISBfLnJlc3VsdCh0ZXN0LCB0aGlzLm93bmVyLCBtZXRhLCBkdCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgZGVmYXVsdDpcbiAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoJ0luY29ycmVjdCBhbGxvd2VkIGNvbXBvbmVudHMgaW4gY29uZmlnJyk7XG4gICAgICAgIH1cbiAgICB9IGVsc2Uge1xuICAgICAgICB2YXIgZGF0YVR5cGVzID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GUpO1xuICAgIHZhciBjaGlsZHJlbiA9IGRvbVV0aWxzLmNoaWxkcmVuKHdyYXBFbCk7XG5cbiAgICBpZiAoY291bnQgIT0gY2hpbGRyZW4ubGVuZ3RoKVxuICAgICAgICBsb2dnZXIuZXJyb3IoJ251bWJlciBvZiBpdGVtcyBhZGRlZCBpcyBkaWZmZXJlbnQgZnJvbSByZXF1ZXN0ZWQnKTtcblxuICAgIGlmIChjaGlsZHJlbiAmJiBjaGlsZHJlbi5sZW5ndGgpIHtcbiAgICAgICAgdmFyIGxpc3RMZW5ndGggPSB0aGlzLmNvdW50KCk7XG4gICAgICAgIHZhciBzcGxpY2VJbmRleCA9IGluZGV4IDwgMFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgID8gMFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIDogdHlwZW9mIGluZGV4ID09ICd1bmRlZmluZWQnIHx8IGluZGV4ID4gbGlzdExlbmd0aFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA/IGxpc3RMZW5ndGhcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgOiBpbmRleDtcblxuICAgICAgICB2YXIgcHJldkNvbXBvbmVudCA9IHNwbGljZUluZGV4ID09IDBcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgPyB0aGlzLml0ZW1TYW1wbGVcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgOiB0aGlzLl9saXN0SXRlbXNbc3BsaWNlSW5kZXggLSAxXTtcblxuICAgICAgICB2YXIgZnJhZyA9IGRvY3VtZW50LmNyZWF0ZURvY3VtZW50RnJhZ21lbnQoKVxuICAgICAgICAgICAgLCBuZXdDb21wb25lbnRzID0gW107XG5cbiAgICAgICAgY2hpbGRyZW4uZm9yRWFjaChmdW5jdGlvbihlbCwgaSkge1xuICAgICAgICAgICAgdmFyIGNvbXBvbmVudCA9IENvbXBvbmVudC5nZXRDb21wb25lbnQoZWwpO1xuICAgICAgICAgICAgaWYgKCEg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hc3M9XCJtbC11aS1mb2xkdHJlZS1saXN0XCI+XFxcbiAgICAgICAgICAgICAgICAgICAgICAgIHt7fiBpdC5kYXRhLml0ZW1zIDppdGVtOmluZGV4IH19XFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB7eyB2YXIgaGFzU3ViVHJlZSA9IGl0ZW0uaXRlbXMgJiYgaXRlbS5pdGVtcy5sZW5ndGg7IH19XFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICA8bGkge3s/IGhhc1N1YlRyZWUgfX1jbGFzcz1cIm1sLXVpLWZvbGR0cmVlLS1oYXMtbXVsdGlwbGVcInt7P319PlxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDxkaXYgY2xhc3M9XCJtbC11aS1mb2xkdHJlZS1pdGVtXCIgZGF0YS1pdGVtLWlkPVwie3s9IGl0Lml0ZW1JRHNbaW5kZXhdIH19XCI+XFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHt7PyBoYXNTdWJUcmVlIH19XFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA8ZGl2IGNsYXNzPVwibWwtdWktZm9sZHRyZWUtYnV0dG9uXCI+PC9kaXY+XFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHt7P319XFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHt7PSBpdC5pdGVtVGVtcGxhdGUoeyBpdGVtOiBpdGVtIH0pIH19XFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgPC9kaXY+XFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAge3s/IGhhc1N1YlRyZWUgfX1cXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAge3s9IGl0LnRyZWVUZW1wbGF0ZShpdGVtKSB9fVxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHt7P319XFxcbiAgICAgICAgICAgICAgICAgICAg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ZW50OiBSQURJT19DSEFOR0VfTUVTU0FHRVxuICAgIH0sXG4gICAgbW9kZWw6IHtcbiAgICAgICAgbWVzc2FnZXM6IHtcbiAgICAgICAgICAgICcqKionOiB7IHN1YnNjcmliZXI6IG9uT3B0aW9uc0NoYW5nZSwgY29udGV4dDogJ293bmVyJyB9XG4gICAgICAgIH1cbiAgICB9LFxuICAgIGV2ZW50czoge1xuICAgICAgICBtZXNzYWdlczoge1xuICAgICAgICAgICAgJ2NsaWNrJzogeyBzdWJzY3JpYmVyOiBvbkdyb3VwQ2xpY2ssIGNvbnRleHQ6ICdvd25lcicgfVxuICAgICAgICB9XG4gICAgfSxcbiAgICBjb250YWluZXI6IHVuZGVmaW5lZCxcbiAgICBkb206IHtcbiAgICAgICAgY2xzOiAnbWwtdWktcmFkaW8tZ3JvdXAnXG4gICAgfSxcbiAgICB0ZW1wbGF0ZToge1xuICAgICAgICB0ZW1wbGF0ZTogJ3t7fiBpdC5yYWRpb09wdGlvbnMgOm9wdGlvbiB9fSBcXFxuICAgICAgICAgICAgICAgICAgICAgICAge3sjI2RlZi5lbElEOnt7PSBpdC5lbGVtZW50TmFtZSB9fS17ez0gb3B0aW9uLnZhbHVlIH19I319IFxcXG4gICAgICAgICAgICAgICAgICAgICAgICA8c3BhbiBjbGFzcz1cInt7PSBpdC5fcmVuZGVyT3B0aW9ucy5vcHRpb25Dc3NDbGFzcyB8fCBcIicgKyBFTEVNRU5UX05BTUVfUFJFRklYICsgJ29wdGlvblwiIH19XCI+IFxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgPGlucHV0IGlkPVwie3sjIGRlZi5lbElEIH19XCIgdHlwZT1cInJhZGlvXCIgdmFsdWU9XCJ7ez0gb3B0aW9uLnZhbHVlIH19XCIgbmFtZT1cInt7PSBpdC5lbGVtZW50TmFtZSB9fVwiPiBcXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIDxsYWJlbCBmb3I9XCJ7eyMgZGVmLmVsSUQgfX1cIj57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ICAgICAgICAgPGRpdiBtbC1iaW5kPVwiW2RvbV06YWRkSXRlbURpdlwiIGNsYXNzPVwibWwtdWktc3VwZXJjb21iby1hZGRcIj5cXFxuICAgICAgICAgICAgICAgICAgICAgICAgPHNwYW4gbWwtYmluZD1cIjphZGRQcm9tcHRcIj48L3NwYW4+XFxcbiAgICAgICAgICAgICAgICAgICAgICAgIDxidXR0b24gbWwtYmluZD1cIltldmVudHMsIGRvbV06YWRkQnRuXCIgY2xhc3M9XCJidG4gYnRuLWRlZmF1bHQgbWwtdWktYnV0dG9uXCI+QWRkPC9idXR0b24+XFxcbiAgICAgICAgICAgICAgICAgICA8L2Rpdj5cXFxuICAgICAgICAgICAgICAgICAgIDxkaXYgbWwtYmluZD1cIltkb20sIGV2ZW50c106bGlzdFwiIGNsYXNzPVwibWwtdWktc3VwZXJjb21iby1kcm9wZG93blwiPlxcXG4gICAgICAgICAgICAgICAgICAgICAgIDxkaXYgbWwtYmluZD1cIltkb21dOmJlZm9yZVwiPjwvZGl2PlxcXG4gICAgICAgICAgICAgICAgICAgICAgIDxkaXYgbWwtYmluZD1cIlt0ZW1wbGF0ZSwgZG9tLCBldmVudHNdOm9wdGlvbnNcIiBjbGFzcz1cIm1sLXVpLXN1cGVyY29tYm8tb3B0aW9uc1wiPjwvZGl2PlxcXG4gICAgICAgICAgICAgICAgICAgICAgIDxkaXYgbWwtYmluZD1cIltkb21dOmFmdGVyXCI+PC9kaXY+XFxcbiAgICAgICAgICAgICAgICAgICA8L2Rpdj4nXG4gICAgfSxcbiAgICBjb250YWluZXI6IHVuZGVmaW5lZFxufSk7XG5cbmNvbXBvbmVudHNSZWdpc3RyeS5hZGQoTUxTdXBlckNvbWJvKTtcblxubW9kdWxlLmV4cG9ydHMgPSBNTFN1cGVyQ29tYm87XG5cbi8qKlxuICogUHVibGljIEFwaVxuICovXG5fLmV4dGVuZFByb3RvKE1MU3VwZXJDb21ibywge1xuICAgIGluaXQ6IE1MU3VwZXJDb21ibyRpbml0LF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dG9uXCIgY2xhc3M9XCJjbG9zZVwiPiZ0aW1lczs8L2J1dHRvbj5cXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHt7P319XFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICA8aDQgY2xhc3M9XCJtb2RhbC10aXRsZVwiPnt7PSBpdC50aXRsZSB9fTwvaDQ+XFxcbiAgICAgICAgICAgICAgICAgICAgICAgIDwvZGl2PlxcXG4gICAgICAgICAgICAgICAgICAgIHt7P319XFxcbiAgICAgICAgICAgICAgICAgICAge3s/IGl0Lmh0bWwgfHwgaXQudGV4dCB9fVxcXG4gICAgICAgICAgICAgICAgICAgICAgICA8ZGl2IGNsYXNzPVwibW9kYWwtYm9keVwiIG1sLWJpbmQ9XCJbY29udGFpbmVyXTpkaWFsb2dCb2R5XCI+XFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB7ez8gaXQuaHRtbCB9fVxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHt7PSBpdC5odG1sIH19XFxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB7ez8/fX1cXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA8cD57ez0gaXQudGV4dCB9fTwvcD5cXFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHt7P319XFxcbiAgICAgICAgICAgICAgICAgICAgICAgIDwvZGl2PlxcXG4gICAgICAgICAgICAgICAgICAgIHt7P319XFxcbiAgICAgICAgICAgICAgICAgICAge3s/IGl0LmJ1dHRvbnMgJiYgaXQuYnV0dG9ucy5sZW5ndGggfX1cXFxuICAgICAgICAgICAgICAgICAgICAgICAgPGRpdiBjbGFzcz1cIm1vZGFsLWZvb3RlclwiPlxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAge3t+IGl0LmJ1dHRvbnMgOmJ0biB9fVxcXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDxidXR0b24gdHlwZT1cImJ1dHRvblwiXFxcbiAgICAgICAgICA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FkOiAnbWwtbG9hZCdcbiAgICB9LFxuICAgIGNvbXBvbmVudFJlZjogJ19fX21pbG9fY29tcG9uZW50JyxcbiAgICBjb21wb25lbnRQcmVmaXg6ICdtaWxvXycsXG4gICAgdGVtcGxhdGU6IHtcbiAgICAgICAgY29tcGlsZTogZG9ULmNvbXBpbGVcbiAgICB9LFxuICAgIGRvbVN0b3JhZ2U6IHtcbiAgICAgICAgdHlwZVN1ZmZpeDogJzpfX19taWxvX2RhdGFfdHlwZScsXG4gICAgICAgIHByZWZpeFNlcGFyYXRvcjogJy8nLFxuICAgICAgICByb290OiAnJyxcbiAgICAgICAgbWVzc2FnZUtleTogJ19fX21pbG9fbWVzc2FnZS8nLFxuICAgICAgICBtZXNzYWdlVGltZXN0YW1wOiAnX19fbWlsb190aW1lc3RhbXAnLFxuICAgICAgICBxdW90YUV4Y2VlZGVkOiB7XG4gICAgICAgICAgICB0aHJvd0Vycm9yOiB0cnVlLFxuICAgICAgICAgICAgbWVzc2FnZTogZmFsc2VcbiAgICAgICAgfVxuICAgIH0sXG4gICAgZHJhZ0Ryb3A6IHtcbiAgICAgICAgZGF0YVR5cGVzOiB7XG4gICAgICAgICAgICBjb21wb25lbnQ6ICd4LWFwcGxpY2F0aW9uL21pbG8vY29tcG9uZW50JyxcbiAgICAgICAgICAgIGNvbXBvbmVudE1ldGFUZW1wbGF0ZTogJ3gtYXBwbGljYXRpb24vbWlsby9jb21wb25lbnQtbWV0YS8lY2xhc3MvJW5hbWUvJXBhcmFtcycsXG4gICAgICAgICAgICBjb21wb25lbnRNZXRhUmVnZXg6IC9eeFxcLWFwcGxpY2F0aW9uXFwvbWlsb1xcL2NvbXBvbmVudFxcLW1ldGFcXC8oW2EtejAtOV0rKVxcLyhbYS16MC05XSspXFwvKFthLXowLTldKikkLyxcbiAgICAgICAgfVxuICAgIH0sXG4gICAgcmVxdWVzdDoge1xuICAgICAgICBqc29ucFRpbWVvdXQ6IDYwMDAwLFxuICAgICAgICBqc29ucENhbGx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FyIHN0YXJ0U2libGluZyA9IF9maW5kQ29udGFpbmluZ0NoaWxkKGNvbnRhaW5lck5vZGUsIHN0YXJ0Tm9kZSk7XG4gICAgdmFyIGVuZFNpYmxpbmcgPSBfZmluZENvbnRhaW5pbmdDaGlsZChjb250YWluZXJOb2RlLCBlbmROb2RlKTtcblxuICAgIGlmIChzdGFydFNpYmxpbmcgJiYgZW5kU2libGluZykge1xuICAgICAgICBpZiAoc3RhcnRTaWJsaW5nID09IGVuZFNpYmxpbmcpIHtcbiAgICAgICAgICAgIGxvZ2dlci5lcnJvcignZGVsZXRlU2VsZWN0aW9uQ29tbWFuZCBsb2dpY2FsIGVycm9yOiBzYW1lIHNpYmxpbmdzJyk7XG4gICAgICAgICAgICByZXR1cm4geyBzaWJsaW5nczogZmFsc2UsIHN0YXJ0OiBzdGFydFNpYmxpbmcgfTtcbiAgICAgICAgfSBlbHNlXG4gICAgICAgICAgICByZXR1cm4geyBzaWJsaW5nczogdHJ1ZSwgc3RhcnQ6IHN0YXJ0U2libGluZywgZW5kOiBlbmRTaWJsaW5nIH07XG4gICAgfVxufVxuXG5cbmZ1bmN0aW9uIF9maW5kQ29udGFpbmluZ0NoaWxkKGNvbnRhaW5lck5vZGUsIHNlbE5vZGUpIHtcbiAgICByZXR1cm4gXy5maW5kKGNvbnRhaW5lck5vZGUuY2hpbGROb2RlcywgZnVuY3Rpb24obm9kZSkge1xuICAgICAgICByZXR1cm4gbm9kZS5jb250YWlucyhzZWxOb2RlKTtcbiAgICB9KTtcbn1cblxuXG5mdW5jdGlvbiBfY3JlYXRlTm9kZXNBbmRQYXRoc0Z1bmMoZnVuYykge1xuICAgIHJldHVybiBmdW5jdGlvbihyb290RWwsIGZyb21PYmopIHtcbiAgICAgICAgdmFyIHRvT2JqID0ge1xuICAgICAgICAgICAgc2libGluZ3M6IGZyb21PYmouc2libGluZ3MsXG4gICAgICAgICAgICBzdGFydDogZnVuYyhyb290RWwsIGZyb21PYmouc3RhcnQpXG4gICAgICA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ICAgICAgICB9XG4gICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgdmFyIGVycm9yUmVhc29uID0gcmVxLnN0YXR1cyB8fCBldmVudFR5cGU7XG4gICAgICAgICAgICB0cnkge1xuICAgICAgICAgICAgICAgIHBvc3RNZXNzYWdlKCdlcnJvcicpO1xuICAgICAgICAgICAgICAgIHBvc3RNZXNzYWdlKCdlcnJvcicgKyBlcnJvclJlYXNvbik7XG4gICAgICAgICAgICAgICAgY2FsbGJhY2sgJiYgY2FsbGJhY2soZXJyb3JSZWFzb24sIHJlcS5yZXNwb25zZVRleHQsIHJlcSk7XG4gICAgICAgICAgICB9IGNhdGNoKGUpIHsgZXJyb3IgPSBlOyB9XG4gICAgICAgICAgICB4UHJvbWlzZS5yZWplY3QoeyByZWFzb246IGVycm9yUmVhc29uLCByZXNwb25zZTogcmVxLnJlc3BvbnNlVGV4dCB9KTtcbiAgICAgICAgfVxuICAgIH0gY2F0Y2goZSkge1xuICAgICAgICBlcnJvciA9IGVycm9yIHx8IGU7XG4gICAgfVxuXG4gICAgLy8gbm90IHJlbW92aW5nIHN1YnNjcmlwdGlvbiBjcmVhdGVzIG1lbW9yeSBsZWFrLCBkZWxldGluZyBwcm9wZXJ0eSB3b3VsZCBub3QgcmVtb3ZlIHN1YnNjcmlwdGlvblxuICAgIHJlcS5vbnJlYWR5c3RhdGVjaGFuZ2UgPSByZXEub250aW1lb3V0ID0gcmVxLm9uYWJvcnQgPSB1bmRlZmluZWQ7XG5cbiAgICBpZiAoIV9wZW5kaW5nUmVxdWVzdHMubGVuZ3RoKVxuICAgICAgICBwb3N0TWVzc2FnZSgncmVxdWVzdHNjb21wbGV0ZWQnKTtcblxuICAgIGlmIChlcnJvcikge1xuICAgICAgICB2YXIgZXJyT2JqID0gbmV3IEVycm9yKCdFeGNlcHRpb246ICcgKyBlcnJvcik7XG4gICAgICAgIGxvZ2dlci5lcnJvcihlcnJvci5zdGFjayk7XG4gICAgICAgIHRocm93IGVyck9iajtcbiA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IDApXG4gICAgICAgIGRlbGV0ZSBfY29ubmVjdG9yc1tpbmRleF07XG4gICAgZWxzZVxuICAgICAgICBsb2dnZXIud2FybignbWluZGVyOiBjb25uZWN0b3IgZGVzdHJveWVkIHRoYXQgaXMgbm90IHJlZ2lzdGVyZWQgaW4gbWluZGVyJyk7XG59XG5cblxuZnVuY3Rpb24gbWluZGVyX2dldEV4cGFuZGVkQ29ubmVjdGlvbnMob25PZmYsIHNlYXJjaFN0cikge1xuICAgIHZhciBjb25uZWN0b3JzID0gbWluZGVyLmdldENvbm5lY3RvcnMob25PZmYpO1xuICAgIHZhciBjb25uZWN0aW9ucyA9ICBjb25uZWN0b3JzLm1hcChmdW5jdGlvbihjbmN0KSB7XG4gICAgICAgIHZhciBjb25uZWN0aW9uID0ge1xuICAgICAgICAgICAgbGVmdFNvdXJjZTogX2dldEV4cGFuZGVkU291cmNlKGNuY3QuZHMxKSxcbiAgICAgICAgICAgIHJpZ2h0U291cmNlOiBfZ2V0RXhwYW5kZWRTb3VyY2UoY25jdC5kczIpLFxuICAgICAgICAgICAgbW9kZTogY25jdC5tb2RlLFxuICAgICAgICAgICAgaXNPbjogY25jdC5pc09uXG4gICAgICAgIH07XG4gICAgICAgIFxuICAgICAgICBpZiAoY25jdC5vcHRpb25zKVxuICAgICAgICAgICAgY29ubmVjdGlvbi5vcHRpb25zID0gY25jdC5vcHRpb25zO1xuXG4gICAgICAgIHJldHVybiBjb25uZWN0aW9uO1xuICAgIH0pO1xuXG4gICAgaWYgKHNlYXJjaFN0cilcbiAgICAgICAgY29ubmVjdGlvbnMgPSBjb25uZWN0aW9ucy5maWx0ZXIoZnVuY3Rpb24oY25jdG4pIHtcbiAgICAgICAgICAgIHJldHVybiBfc291cmNlTWF0Y2hlc1N0cmluZyhjbmN0bi5sZWZ0U291cmNlLCBzZWFyY2hTdHIpXG4gICAgICAgICAgICAgICAgICAgIHx8IF9zb3VyY2VNYXRjaGVzU3RyaW5nKGNuY3RuLnJpZ2h0U291cm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Z1bmN0aW9uIGxpbmtEYXRhU291cmNlKHJldmVyc2VMaW5rLCBmcm9tRFMsIHRvRFMsIGNoYW5nZXNRdWV1ZSwgcGF0aFRyYW5zbGF0aW9uLCBwYXR0ZXJuVHJhbnNsYXRpb24sIGRhdGFUcmFuc2xhdGlvbiwgZGF0YVZhbGlkYXRpb24pIHtcbiAgICAgICAgZnJvbURTLm9uU3luYygnZGF0YWNoYW5nZXMnLCBvbkRhdGEpO1xuICAgICAgICByZXR1cm4gb25EYXRhO1xuXG4gICAgICAgIGZ1bmN0aW9uIG9uRGF0YShtZXNzYWdlLCBiYXRjaCkge1xuICAgICAgICAgICAgdmFyIHNlbmREYXRhID0ge1xuICAgICAgICAgICAgICAgIGNoYW5nZXM6IFtdLFxuICAgICAgICAgICAgICAgIHRyYW5zYWN0aW9uOiBiYXRjaC50cmFuc2FjdGlvblxuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBiYXRjaC5jaGFuZ2VzLmZvckVhY2goZnVuY3Rpb24oY2hhbmdlKSB7XG4gICAgICAgICAgICAgICAgdmFyIHNvdXJjZVBhdGggPSBjaGFuZ2UucGF0aFxuICAgICAgICAgICAgICAgICAgICAsIHRhcmdldFBhdGggPSB0cmFuc2xhdGVQYXRoKHNvdXJjZVBhdGgpO1xuXG4gICAgICAgICAgICAgICAgaWYgKHR5cGVvZiB0YXJnZXRQYXRoID09ICd1bmRlZmluZWQnKSByZXR1cm47XG5cbiAgICAgICAgICAgICAgICB2YXIgY2hhbmdlID0gXy5jbG9uZShjaGFuZ2UpO1xuICAgICAgICAgICAgICAgIF8uZXh0ZW5kKGNoYW5nZSwge1xuICAgICAgICAgICAgICAgICAgICBzb3VyY2U6IGZyb21EUyxcbiAgICAgICAgICAgICAgICAgICAgcGF0aDogdGFyZ2V0UGF0aFxuICAgICAgICAgICAgICAgIH0pO1xuXG4gICAgICAgICAgICAgICAgdHJhbnNsYXRlRGF0YShzb3VyY2VQYXRoLCBjaGFuZ2UpO1xuICAgICAgICAgICAgICAgIHZhbGlkYXRlRGF0YShzb3VyY2VQYXRoLCBjaGFuZ2UpO1xuICAgICAgICAgICAgfSk7XG5cbiAgICAgICAgICAgIGlmICghIGNoYW5nZXNRdWV1ZS5sZW5ndGgpXG4gICAgICAgICAgICAgICAgXy5kZWZlcihwb3N0Q2hhbmdlRGF0YSk7XG5cbiAgICAgICAgICAgIGNoYW5nZXNRdWV1ZS5wdXNoKHNlbmREYXRhKTtcblxuXG4gICAgICAgICAgICBmdW5jdGlvbiB0cmFuc2xhdGVQYXRoKHNvdXJjZVBhdGgpIHtcbiAgICAgICAgICAgICAgICBpZiAocGF0aFRyYW5zbGF0aW9uKSB7XG4gICAgICAgICAgICAgICAgICAgIHZhciB0cmFuc2xhdGVkUGF0aCA9IHBhdGhUcmFuc2xhdGlvbltzb3VyY2VQYXRoXTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKHRyYW5zbGF0ZWRQYXRoKSByZXR1cm4gdHJhbnNsYXRlZFBhdGg7XG4gICAgICAgICAgICAgICAgICAgIGlmICghcGF0dGVyblRyYW5zbGF0aW9uLmxlbmd0aCkgcmV0dXJuO1xuICAgICAgICAgICAgICAgICAgICB2YXIgcHQgPSBfLmZpbmQocGF0dGVyblRyYW5zbGF0aW9uLCBmdW5jdGlvbihwVHJhbnNsYXRpb24pIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBwVHJhbnNsYXRpb24uZnJvbVBhdHRlcm4udGVzdChzb3VyY2VQYXRoKTtcbiAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgICAgIGlmICghcHQpIHJldHVybjtcbiAgICAgICAgICAgICAgICAgICAgdmFyIHRyYW5zbGF0ZWRQYXRoID0gc291cmNlUGF0aC5yZXBsYWNlKHB0LmZyb21TdGF0aWNQYXRoLCBwdC50b1N0YXRpY1BhdGgpO1xuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoISAoKHN1YnNjcmlwdGlvblBhdHRlcm4gaW5zdGFuY2VvZiBSZWdFeHBcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICYmIHN1YnNjcmlwdGlvblBhdHRlcm4udGVzdChzb3VyY2VQYXRoKSlcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHx8IHN1YnNjcmlwdGlvblBhdHRlcm4gPT0gc291cmNlUGF0aCkpIHJldHVybjtcblxuICAgICAgICAgICAgICAgIHJldHVybiB0cmFuc2xhdGVkUGF0aCB8fCBzb3VyY2VQYXRoO1xuICAgICAgICAgICAgfVxuXG5cbiAgICAgICAgICAgIGZ1bmN0aW9uIHRyYW5zbGF0ZURhdGEoc291cmNlUGF0aCwgY2hhbmdlKSB7XG4gICAgICAgICAgICAgICAgaWYgKGRhdGFUcmFuc2xhdGlvbikge1xuICAgICAgICAgICAgICAgICAgICB2YXIgdHJhbnNsYXRlID0gZGF0YVRyYW5zbGF0aW9uW3NvdXJjZVBhdGhdO1xuICAgICAgICAgICAgICAgICAgICBpZiAodHJhbnNsYXRlICYmIHR5cGVvZiB0cmFuc2xhdGUgPT0gJ2Z1bmN0aW9uJykge1xuICAgICAgICAgICAgICAgICAgICAgICAgY2hhbmdlLm9sZFZhbHVlID0gdHJhbnNsYXRlKGNoYW5nZS5vbGRWYWx1ZSk7XG4gICAgICAgICAgICAgICAgICAgICAgICBjaGFuZ2UubmV3VmFsdWUgPSB0cmFuc2xhdGUoY2hhbmdlLm5ld1ZhbHVlKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgIFxuICAgICAgICAgICAgZnVuY3Rpb24gdmFsaWRhdGVEYXRhKHNvdXJjZVBhdGgsIGNoYW5nZSkge1xuICAgICAgICAgICAgICAgIHByb3BhZ2F0ZURhdGEoY2hhbmdlKTtcblxuICAgICAgICAgICAgICAgIGlmIChkYXRhVmFsaWRhdGlvbikge1xuICAgICAgICAgICAgICAgICAgICB2YXIgdmFsaWRhdG9ycyA9IGRhdGFWYWxpZGF0aW9uW3NvdXJjZVBhdGhdXG4gICAgICAgICAgICAgICAgICAgICAgICAsIHBhc3NlZENvdW50ID0gMFxuICAgICAgICAgICAgICAgICAgICAgICAgLCBhbHJlYWR5RmFpbGVkID0gZmFsc2U7XG5cbiAgICAgICAgICAgICAgICAgICAgaWYgKHZhbGlkYXRvcnMpXG4gICAgICAgICAgICAgICAgICAgICAgICB2YWxpZGF0b3JzLmZvckVhY2goY2FsbFZhbGlkYXRvcik7ICAgXG4gICAgICAgICAgICAgICAgfVxuXG5cbiAgICAgICAgICAgICAgICBmdW5jdGlvbiBjYWxsVmFsaWRhdG9yKHZhbGlkYXRvcikge1xuICAgICAgICAgICAgICAgICAgICB2YWxpZGF0b3IoY2hhbmdlLm5ld1ZhbHVlLCBmdW5jdGlvbihlcnIsIHJlc3BvbnNlKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICByZXNwb25zZS5wYXRoID0gc291cmNlUGF0aDtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghIGFscmVhZHlGYWlsZWQgJiYgKGVyciB8fCByZXNwb25zZS52YWxpZCkgJiYgKytwYXNzZWRDb3VudCA9PSB2YWxpZGF0b3JzLmxlbmd0aCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZyb21EUy5wb3N0TWVzc2FnZSgndmFsaWRhdGVkJywgcmVzcG9uc2UpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmICghIHJlc3BvbnNlLnZhbGlkKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgYWxyZWFkeUZhaWxlZCA9IHRydWU7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZnJvbURTLnBvc3RNZXNzYWdlKCd2YWxpZGF0ZWQnLCByZXNwb25zZSk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAg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ZmJztcbiAgICAgICAgICAgICAgICB0b0RTW29uT2ZmXSgnZGF0YWNoYW5nZXMnLCBzZWxmW3JldmVyc2VMaW5rXSk7XG5cbiAgICAgICAgICAgICAgICB2YXIgbWVzc2FnZSA9IGNoYW5nZUZpbmlzaGVkID8gJ2NoYW5nZWNvbXBsZXRlZCcgOiAnY2hhbmdlc3RhcnRlZCc7XG4gICAgICAgICAgICAgICAgc2VsZi5wb3N0TWVzc2FnZShtZXNzYWdlLCB7IHNvdXJjZTogZnJvbURTLCB0YXJnZXQ6IHRvRFMgfSk7XG4gICAgICAgICAgICB9XG5cblxuICAgICAgICAgICAgZnVuY3Rpb24gbWVyZ2VUcmFuc2FjdGlvbnMoYmF0Y2hlcykge1xuICAgICAgICAgICAgICAgIHZhciB0cmFuc2FjdGlvbnMgPSBbXVxuICAgICAgICAgICAgICAgICAgICAsIGN1cnJlbnRUcmFuc2FjdGlvbjtcblxuICAgICAgICAgICAgICAgIGJhdGNoZXMuZm9yRWFjaChmdW5jdGlvbihiYXRjaCkge1xuICAgICAgICAgICAgICAgICAgICBpZiAoISBiYXRjaC50cmFuc2FjdGlvbikgY3VycmVudFRyYW5zYWN0aW9uID0gdW5kZWZpbmVkO1xuICAgICAgICAgICAgICAgICAgICBpZiAoISBiYXRjaC5jaGFuZ2VzLmxlbmd0aCkgcmV0dXJuO1xuXG4gICAgICAgICAgICAgICAgICAgIGlmIChiYXRjaC50cmFuc2FjdGlvbikge1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGN1cnJlbnRUcmFuc2FjdGlvbilcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfLmFwcGVuZEFycmF5KGN1cnJlbnRUcmFuc2FjdGlvbiwgYmF0Y2guY2hhbmdlcyk7XG4gICAgICAgICAgICAgICAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50VHJhbnNhY3Rpb24gPSBfLmNsb25lKGJhdGNoLmNoYW5nZXMpO1xu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zEtOV1bMC05XSonXG4gICAgLCBwcm9wZXJ0eUludGVycG9sYXRlU3ludGF4ID0gJ1xcXFwuJyArIGludGVycG9sYXRpb25TeW50YXhcbiAgICAsIGFycmF5SW50ZXJwb2xhdGVTeW50YXggPSAnXFxcXFsnICsgaW50ZXJwb2xhdGlvblN5bnRheCArICdcXFxcXSdcblxuICAgICwgcHJvcGVydHlTdGFyU3ludGF4ID0gJ1xcXFwuXFxcXConXG4gICAgLCBhcnJheVN0YXJTeW50YXggPSAnXFxcXFtcXFxcKlxcXFxdJ1xuICAgICwgc3RhclN5bnRheCA9ICdcXFxcKidcblxuICAgICwgcGF0aFBhcnNlU3ludGF4ID0gW1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByb3BlcnR5UGF0aFN5bnRheCxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhcnJheVBhdGhTeW50YXgsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJvcGVydHlJbnRlcnBvbGF0ZVN5bnRheCxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhcnJheUludGVycG9sYXRlU3ludGF4XG4gICAgICAgICAgICAgICAgICAgICAgICBdLmpvaW4oJ3wnKVxuICAgICwgcGF0aFBhcnNlUGF0dGVybiA9IG5ldyBSZWdFeHAocGF0aFBhcnNlU3ludGF4LCAnZycpXG5cbiAgICAsIHBhdHRlcm5QYXRoUGFyc2VTeW50YXggPSAgW1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGF0aFBhcnNlU3ludGF4LFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJvcGVydHlTdGFyU3ludGF4LFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXJyYXlTdGFyU3ludGF4LFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhclN5bnRheFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBdLmpvaW4oJ3wnKVxuICAgICw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ID0ge3s9IGVtcHR5UHJvcCB9fTtcXG4gICAgICAgICAgICB3YXNEZWYgPSBmYWxzZTtcXG5cXG4gICAgICAgICAgICBpZiAodGhpcy5fb3B0aW9ucy5yZWFjdGl2ZSAhPT0gZmFsc2UpIHtcXG4gICAgICAgICAgICAgICAge3sjIGRlZi5hZGRNc2cgfX0gJycsIHR5cGU6ICdhZGRlZCcsXFxuICAgICAgICAgICAgICAgICAgICAgIG5ld1ZhbHVlOiBtIH0pO1xcbiAgICAgICAgICAgIH1cXG4gICAgICAgIH1cXG4gICAge3s/P319XFxuICAgICAgICB7ez8gbWV0aG9kID09ICdzcGxpY2UnIH19XFxuICAgICAgICAgICAgaWYgKCEgbSkge1xcbiAgICAgICAge3s/fX1cXG4gICAgICAgICAgICAgICAgbSA9IHt7IyBkZWYubW9kZWxBY2Nlc3NQcmVmaXggfX0gPSBjbG9uZVRyZWUodmFsdWUpO1xcbiAgICAgICAgICAgICAgICB3YXNEZWYgPSB0eXBlb2Ygb2xkICE9ICd1bmRlZmluZWQnO1xcbiAgICAgICAge3s/IG1ldGhvZCA9PSAnc3BsaWNlJyB9fVxcbiAgICAgICAgICAgIH1cXG4gICAgICAgIHt7P319ICAgICAgIFxcbiAgICB7ez99fVxcblxcblxcbiAgICB7eyAvKiBjcmVhdGUgbW9kZWwgdHJlZSBpZiBpdCBkb2Vzbid0IGV4aXN0ICovIH19XFxuICAgIHt7ICB2YXIgbW9kZWxEYXRhUHJvcGVydHkgPSAnJztcXG4gICAgICAgIHZhciBuZXh0Tm9kZSA9IGl0LnBhcnNlZFBhdGhbMF07XFxuICAgICAgICB2YXIgY291bnQgPSBpdC5wYXJzZWRQYXRoLmxlbmd0aCAtIDE7XFxuXFxuICAgICAgICBmb3IgKHZhciBpID0gMDsgaSA8IGNvdW50OyBpKyspIHtcXG4gICAgICAgICAgICB2YXIgY3Vyck5vZGUgPSBuZXh0Tm9kZTtcXG4gICAgICAgICAgICB2YXIgY3VyclByb3AgPSBjdXJyTm9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ID0gcGF0aFN5bnRheC5yZXBsYWNlKCckJCcsIGtleSlcbiAgICAgICAgICAgICAgICAsIGV4aXN0aW5nTXNnID0gbWVzc2FnZXNIYXNoW3BhdGhdO1xuXG4gICAgICAgICAgICBpZiAoZXhpc3RpbmdNc2cpIHtcbiAgICAgICAgICAgICAgICBpZiAoZXhpc3RpbmdNc2cudHlwZSA9PSBtc2dUeXBlKVxuICAgICAgICAgICAgICAgICAgICBsb2dnZXIuZXJyb3IoJ3NldHRlciBlcnJvcjogc2FtZSBtZXNzYWdlIHR5cGUgcG9zdGVkIG9uIHRoZSBzYW1lIHBhdGgnKTtcbiAgICAgICAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgZXhpc3RpbmdNc2cudHlwZSA9ICdjaGFuZ2VkJztcbiAgICAgICAgICAgICAgICAgICAgZXhpc3RpbmdNc2dbdmFsdWVQcm9wXSA9IHZhbHVlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgdmFyIG1zZyA9IHsgcGF0aDogcGF0aCwgdHlwZTogbXNnVHlwZSB9O1xuICAgICAgICAgICAgICAgIG1zZ1t2YWx1ZVByb3BdID0gdmFsdWU7XG4gICAgICAgICAgICAgICAgYWRkQ2hhbmdlTWVzc2FnZShtZXNzYWdlcywgbWVzc2FnZXNIYXNoLCBtc2cpO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBpZiAodmFsdWVJc1RyZWUodmFsdWUpKVxuICAgICAgICAgICAgICAgIF9hZGRNZXNzYWdlcyhwYXRoLCB2YWx1ZSk7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBmdW5jdGlvbiBjbG9uZVRyZWUodmFsdWUpIHtcbiAgICAgICAgcmV0dXJuIHZhbHVlSXNOb3JtYWxPYmplY3QodmFsdWUpXG4gICAgICAgICAgICAgICAgPyBfLmRlZXBDbG9uZSh2YWx1ZSlcbiAgICAgICAgICAgICAgICA6I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5PYmplY3RJbmNsdWRpbmcoe30pO1xuICAgIGlmIChwYXR0ZXJuID09PSBPYmplY3QpXG4gICAgICAgIHBhdHRlcm4gPSBNYXRjaC5PYmplY3RJbmNsdWRpbmcoe30pO1xuXG4gICAgLy8gQXJyYXkgKGNoZWNrZWQgQUZURVIgQW55LCB3aGljaCBpcyBpbXBsZW1lbnRlZCBhcyBhbiBBcnJheSkuXG4gICAgaWYgKHBhdHRlcm4gaW5zdGFuY2VvZiBBcnJheSkge1xuICAgICAgICBpZiAocGF0dGVybi5sZW5ndGggIT09IDEpXG4gICAgICAgICAgICB0aHJvdyBFcnJvcihcIkJhZCBwYXR0ZXJuOiBhcnJheXMgbXVzdCBoYXZlIG9uZSB0eXBlIGVsZW1lbnRcIiArXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBKU09OLnN0cmluZ2lmeShwYXR0ZXJuKSk7XG4gICAgICAgIGlmICghQXJyYXkuaXNBcnJheSh2YWx1ZSkpIHtcbiAgICAgICAgICAgIHRocm93IG5ldyBNYXRjaC5FcnJvcihcIkV4cGVjdGVkIGFycmF5LCBnb3QgXCIgKyBKU09OLnN0cmluZ2lmeSh2YWx1ZSkpO1xuICAgICAgICB9XG5cbiAgICAgICAgdmFsdWUuZm9yRWFjaChmdW5jdGlvbiAodmFsdWVFbGVtZW50LCBpbmRleCkge1xuICAgICAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgICAgICBjaGVja1N1YnRyZWUodmFsdWVFbGVtZW50LCBwYXR0ZXJuWzBdKTtcbiAgICAgICAgICAgIH0gY2F0Y2ggKGVycikge1xuICAgICAgICAgICAgICAgIGlmIChlcnIgaW5zdGFuY2VvZiBNYXRjaC5FcnJvcikge1xuICAgICAgICAgICAgICAgICAgICBlcnIucGF0aCA9IF9wcmVwZW5kUGF0aChpbmRleCwgZXJyLnBhdGgpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB0aHJvdyBlcnI7XG4gICAgICAgICAgIC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3dpdGNoIChjbGFzc05hbWUpIHtcbiAgICAgICAgY2FzZSAnU3RyaW5nJzpcbiAgICAgICAgICAgIHJldHVybiB0aGlzID09IFN0cmluZyhvYmopO1xuICAgICAgICBjYXNlICdOdW1iZXInOlxuICAgICAgICAgICAgcmV0dXJuIHRoaXMgIT0gK3RoaXMgPyBvYmogIT0gK29iaiA6ICh0aGlzID09IDAgPyAxL3RoaXMgPT0gMS9vYmogOiB0aGlzID09ICtvYmopO1xuICAgICAgICBjYXNlICdEYXRlJzpcbiAgICAgICAgY2FzZSAnQm9vbGVhbic6XG4gICAgICAgICAgICByZXR1cm4gK3RoaXMgPT0gK29iajtcbiAgICAgICAgY2FzZSAnUmVnRXhwJzpcbiAgICAgICAgICAgIHJldHVybiB0aGlzLnNvdXJjZSA9PSBvYmouc291cmNlXG4gICAgICAgICAgICAgICAgICAgICYmIHRoaXMuZ2xvYmFsID09IG9iai5nbG9iYWxcbiAgICAgICAgICAgICAgICAgICAgJiYgdGhpcy5tdWx0aWxpbmUgPT0gb2JqLm11bHRpbGluZVxuICAgICAgICAgICAgICAgICAgICAmJiB0aGlzLmlnbm9yZUNhc2UgPT0gb2JqLmlnbm9yZUNhc2U7XG4gICAgfVxuICAgIGlmICh0eXBlb2YgdGhpcyAhPSAnb2JqZWN0JyB8fCB0eXBlb2Ygb2JqICE9ICdvYmplY3QnKSByZXR1cm4gZmFsc2U7XG5cbiAgICBpZiAoQXJyYXkuaXNBcnJheSh0aGlzKSlcbiAgICAgICAgcmV0dXJuIHRoaXMubGVuZ3RoID09IG9iai5sZW5ndGhcbiAgICAgICAgICAgICAgICAmJiB0aGlzLmV2ZXJ5KGZ1bmN0aW9uKGl0ZW0sIGluZGV4KSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBpc0VxdWFsLmNhbGwoaXRlbSwgb2JqW2luZGV4XSk7XG4gICAgICAgICAgICAgICAgfSk7XG4gICAgZWxzZSB7XG4gICAgICAgIHJldHVybiBhbGxLZXlzLmNh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gICAgICAgICBmb3VuZFZhbHVlT3JJbmRleCA9IGFyZ3VtZW50c1thcmdJbmRleF1cbiAgICAgICAgICAgICAgICByZXR1cm4gdGVzdDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH1cbn1cbiJdfQ== +; \ No newline at end of file diff --git a/package.json b/package.json index 2c95c89..f83dd25 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "milojs", - "version": "0.2.8", + "version": "0.2.9", "description": "Browser/nodejs reactive programming and data driven DOM manipulation with modular components.", "keywords": [ "framework", @@ -31,7 +31,7 @@ }, "dependencies": { "base32": "git://github.com/milojs/base32-js", - "milo-core": "^0.1.19" + "milo-core": "0.2.1" }, "devDependencies": { "async": "~0.2.9", diff --git a/test/abstract/faceted_object_test.js b/test/abstract/faceted_object_test.js index 4365c82..b7786ad 100644 --- a/test/abstract/faceted_object_test.js +++ b/test/abstract/faceted_object_test.js @@ -3,7 +3,9 @@ var FacetedObject = require('../../lib/abstract/faceted_object') , Facet = require('../../lib/abstract/facet') , assert = require('assert') - , _ = require('milo-core').proto; + , _ = require('milo-core').proto + , config = require('../../lib/config'); + describe('FacetedObject class', function() { var factory = FacetedObject.createFacetedClass.bind(FacetedObject); @@ -14,6 +16,17 @@ describe('FacetedObject class', function() { var MyFacet = _.createSubclass(Facet, 'MyFacet'); + + before(function() { + config({ check: true }); + }); + + + after(function() { + config({ check: false }); + }); + + it('should define a factory createFacetedClass that creates classes of faceted objects', function() { var TestFacetedClass = factory('TestFacetedClass', facetsClasses, { facet: { diff --git a/test/abstract/registry_test.js b/test/abstract/registry_test.js index 9ebbe41..ee8cb2e 100644 --- a/test/abstract/registry_test.js +++ b/test/abstract/registry_test.js @@ -2,11 +2,20 @@ var ClassRegistry = require('../../lib/abstract/registry.js') , _ = require('milo-core').proto - , assert = require('assert'); + , assert = require('assert') + , config = require('../../lib/config'); describe('ClassRegistry class', function() { var registry = new ClassRegistry(Object); + before(function() { + config({ check: true }); + }); + + after(function() { + config({ check: false }); + }); + beforeEach(function() { registry.clean(); }); diff --git a/test/attributes/a_bind_test.js b/test/attributes/a_bind_test.js index bb0feeb..f389045 100644 --- a/test/attributes/a_bind_test.js +++ b/test/attributes/a_bind_test.js @@ -1,10 +1,19 @@ 'use strict'; var BindAttribute = require('../../lib/attributes/a_bind') - , assert = require('assert'); + , assert = require('assert') + , config = require('../../lib/config'); describe('BindAttribute class', function() { + before(function() { + config({ check: true }); + }); + + after(function() { + config({ check: false }); + }); + it('should have parse and validate methods', function() { var elMock = { attributes: { diff --git a/test/check_test.js b/test/check_test.js index 333057e..02880c1 100644 --- a/test/check_test.js +++ b/test/check_test.js @@ -3,7 +3,8 @@ var _ = require('milo-core').proto , assert = require('assert') , check = require('milo-core').util.check - , Match = check.Match; + , Match = check.Match + , config = require('../lib/config'); describe('check module', function() { var notDefined @@ -42,6 +43,14 @@ describe('check module', function() { undefined ]; + before(function() { + config({ check: true }); + }); + + after(function() { + config({ check: false }); + }); + it('should match.test for different data types', function() { toTest.forEach(function(val, i) { assert(Match.test(val[0], val[1]), 'match.test ' + val[2]); diff --git a/test/components/c_facets/cf_registry_test.js b/test/components/c_facets/cf_registry_test.js index 6eaa29a..927a260 100644 --- a/test/components/c_facets/cf_registry_test.js +++ b/test/components/c_facets/cf_registry_test.js @@ -2,8 +2,17 @@ var facetsRegistry = require('../../../lib/components/c_facets/cf_registry') , ComponentFacet = require('../../../lib/components/c_facet') - , testRegistry = require('../../utils/test_registry');; + , testRegistry = require('../../utils/test_registry') + , config = require('../../../lib/config'); describe('registry of facets', function() { + before(function() { + config({ check: true }); + }); + + after(function() { + config({ check: false }); + }); + testRegistry(facetsRegistry, ComponentFacet); }); diff --git a/test/components/c_registry_test.js b/test/components/c_registry_test.js index f92f126..530dc9c 100644 --- a/test/components/c_registry_test.js +++ b/test/components/c_registry_test.js @@ -2,8 +2,17 @@ var componentsRegistry = require('../../lib/components/c_registry') , Component = require('../../lib/components/c_class') - , testRegistry = require('../utils/test_registry');; + , testRegistry = require('../utils/test_registry') + , config = require('../../lib/config'); describe('registry of components', function() { + before(function() { + config({ check: true }); + }); + + after(function() { + config({ check: false }); + }); + testRegistry(componentsRegistry, Component); });