From 0b98e16f3252b4f5facf7f407eced92ba2d3b905 Mon Sep 17 00:00:00 2001 From: Manuel Mujica Date: Fri, 17 Feb 2017 14:10:49 -0700 Subject: [PATCH] Multiple fixes to the steal-tool's bundle - Provide graph filter options through glob patterns - Allow user to set bundle destination folder - Prevent bundle to create a steal.production.js file - Fix CSS development bundle generation --- index.js | 2 + lib/build/bundle.js | 21 ++--- lib/bundle/concat_stream.js | 51 ++++++++----- lib/stream/dev_bundle.js | 64 +++++++++++----- lib/stream/filter_dev_bundle_graph.js | 40 ++++++---- package.json | 3 +- test/dev_bundle_build_test.js | 106 ++++++++++++++++++++------ test/npm/steal.production.js | 12 --- 8 files changed, 202 insertions(+), 97 deletions(-) delete mode 100644 test/npm/steal.production.js diff --git a/index.js b/index.js index f0a50ce6..bd6019b9 100644 --- a/index.js +++ b/index.js @@ -1,8 +1,10 @@ var multiBuild = require("./lib/build/multi"); var transform = require("./lib/build/transform"); var exporter = require("./lib/build/export"); +var bundle = require("./lib/build/bundle"); module.exports = { + bundle: bundle, build: multiBuild, transform: transform, graph: { diff --git a/lib/build/bundle.js b/lib/build/bundle.js index 7b9daf32..1a0bc994 100644 --- a/lib/build/bundle.js +++ b/lib/build/bundle.js @@ -1,8 +1,8 @@ +var assign = require("lodash").assign; var minify = require("../stream/minify"); var devBundle = require("../stream/dev_bundle"); var transpile = require("../stream/transpile"); var concat = require("../bundle/concat_stream"); -var stealWriteStream = require("../stream/steal"); var filterDevBundleGraph = require("../stream/filter_dev_bundle_graph"); var assignDefaultOptions = require("../assign_default_options"); @@ -13,7 +13,9 @@ module.exports = function(config, options) { // Use the build-development environment. if (!options) options = {}; - // Minification is on by default + var isDestProvided = !!options.dest; + + // minification is on by default options.minify = options.minify == null ? true : options.minify; try { @@ -22,8 +24,12 @@ module.exports = function(config, options) { return Promise.reject(err); } - options.dest = ""; - options.defaultBundlesPathName = ""; + // if `dest` was not provided in the options object, override the default + // value so the development bundle is written out in the root folder + assign(options, { + defaultBundlesPathName: "", + dest: isDestProvided ? options.dest : "" + }); var graphStream = createBundleGraphStream(config, options); var filteredGraphStream = graphStream.pipe(filterDevBundleGraph()); @@ -32,12 +38,8 @@ module.exports = function(config, options) { var buildStream = minifyStream.pipe(devBundle()); var concatStream = buildStream.pipe(concat()); - // Return a Promise that will resolve after bundles have been written return new Promise(function(resolve, reject) { - // Pipe the build result into a write stream. - var writeStream = buildStream - .pipe(createWriteStream()) - .pipe(stealWriteStream()); + var writeStream = buildStream.pipe(createWriteStream()); writeStream.on("data", function(data){ this.end(); @@ -58,3 +60,4 @@ module.exports = function(config, options) { }); }); }; + diff --git a/lib/bundle/concat_stream.js b/lib/bundle/concat_stream.js index cae5b186..9c397b3a 100644 --- a/lib/bundle/concat_stream.js +++ b/lib/bundle/concat_stream.js @@ -1,30 +1,43 @@ +var _ = require("lodash"); +var through = require("through2"); var bundleFilename = require("./filename"); var concatSource = require("../bundle/concat_source"); var normalizeSource = require("./normalize_source"); -var through = require("through2"); module.exports = function(){ - return through.obj(function(data, enc, next){ - var bundles = data.bundles; - var configuration = data.configuration; - var bundlesDir = configuration.bundlesPath + "/"; + return through.obj(function(data, enc, next) { + try { + var result = concat(data); + next(null, result); + } catch(err) { + next(err); + } + }); +}; - bundles.forEach(function(bundle){ - var bundlePath = bundle.bundlePath = - bundlesDir + "" + bundleFilename(bundle); +function concat(data) { + var bundles = data.bundles; + var configuration = data.configuration; + var bundlesPath = configuration.bundlesPath; - // If the bundle is explicity marked as clean, just resolve. - if(bundle.isDirty === false) { - return; - } + var bundlesDir = _.endsWith(bundlesPath, "/") ? + bundlesPath : bundlesPath + "/"; - // Adjusts URLs - normalizeSource(bundle, bundlePath); + bundles.forEach(function(bundle){ + var bundlePath = bundle.bundlePath = + bundlesDir + "" + bundleFilename(bundle); - // Combines the source - concatSource(bundle); - }); + // If the bundle is explicity marked as clean, just resolve. + if(bundle.isDirty === false) { + return; + } - next(null, data); + // Adjusts URLs + normalizeSource(bundle, bundlePath); + + // Combines the source + concatSource(bundle); }); -}; + + return data; +} diff --git a/lib/stream/dev_bundle.js b/lib/stream/dev_bundle.js index 20c1dd8b..dc4172da 100644 --- a/lib/stream/dev_bundle.js +++ b/lib/stream/dev_bundle.js @@ -2,11 +2,14 @@ var _ = require("lodash"); var through = require("through2"); var hasES6 = require("../graph/has_es6"); var unbundle = require("../graph/unbundle"); +var flattenBundle = require("../bundle/flatten"); var makeBundle = require("../bundle/make_bundle"); var splitByBuildType = require("../bundle/split_by_build_type"); var addTraceurRuntime = require("../bundle/add_traceur_runtime"); var makeBundlesConfig = require("../bundle/make_bundles_config"); +var BUNDLE_DEPTH = 1; + module.exports = function() { return through.obj(function(data, enc, done) { try { @@ -19,49 +22,74 @@ module.exports = function() { }; function bundle(data) { - var graph = data.graph; var configGraph = data.configGraph; var configuration = data.configuration; + var graph = includePluginsInBuild(data.graph); unbundle(graph); var mainBundle = makeBundle(graph); + flattenBundle(mainBundle, BUNDLE_DEPTH); var splitMainBundles = nameBundles(splitByBuildType(mainBundle)); - splitMainBundles.forEach(function(mainJSBundle) { + splitMainBundles.filter(isJSBundle).forEach(function(bundle) { var unshift = [].unshift; - - unshift.apply(mainJSBundle.nodes, configGraph); + unshift.apply(bundle.nodes, configGraph); // Make config JS code so System knows where to look for bundles. var configNode = makeBundlesConfig( splitMainBundles, configuration, - mainJSBundle, - { excludedBundles: [] } + bundle, + { excludedBundles: {} } ); - mainJSBundle.nodes.unshift(configNode); + bundle.nodes.unshift(configNode); // Traceur code requires a runtime. if (hasES6(graph)) { - addTraceurRuntime(mainJSBundle); + addTraceurRuntime(bundle); } }); - return _.assign( - {}, - data, - { bundles: splitMainBundles } - ); + return _.assign({}, data, { + bundles: splitMainBundles + }); +} + +function isJSBundle(bundle) { + return bundle.buildType !== "css"; } function nameBundles(bundles) { return bundles.map(function(bundle) { - return _.assign( - {}, - bundle, - { name: "dev-bundle" } - ); + var type = bundle.buildType; + + // this is needed so css bundles are written out with the + // right file extension + var suffix = type === "js" ? "" : "." + type + "!"; + + return _.assign({}, bundle, { + name: "dev-bundle" + suffix + }); }); } + +function includePluginsInBuild(graph) { + var cloned = _.assign({}, graph); + + function isPlugin(name) { + return cloned[name].isPlugin; + } + + function includeInBuild(name) { + var node = cloned[name]; + var metadata = node.load.metadata; + + if (metadata) metadata.includeInBuild = true; + } + + _.keys(cloned).filter(isPlugin).forEach(includeInBuild); + + return cloned; +} diff --git a/lib/stream/filter_dev_bundle_graph.js b/lib/stream/filter_dev_bundle_graph.js index c6eb0248..e4918e96 100644 --- a/lib/stream/filter_dev_bundle_graph.js +++ b/lib/stream/filter_dev_bundle_graph.js @@ -1,9 +1,8 @@ var _ = require("lodash"); +var path = require("path"); var winston = require("winston"); var through = require("through2"); -var npmUtils = require("steal/ext/npm-utils"); - -var isNpm = npmUtils.moduleName.isNpm; +var minimatch = require("minimatch"); module.exports = function() { return through.obj(function(data, enc, done) { @@ -20,26 +19,27 @@ function filterGraph(data) { var filtered = {}; var graph = data.graph; - function visit(name) { - if (!visited[name]) { + _.keys(graph).forEach(function visit(name) { + // don't visit a node twice + if (visited[name]) return; - visited[name] = true; - var node = graph[name]; + visited[name] = true; + var node = graph[name]; - if (!node) { - if (name && name[0] !== "@") { - winston.warn("Can't find dependency", name, "in graph."); - } - return; + if (!node) { + if (name && name[0] !== "@") { + winston.warn("Can't find dependency", name, "in graph."); } + return; + } + var address = node.load.address; + var pattern = getGlobPattern(data); + + if (minimatch(address, pattern)) { node.dependencies.forEach(visit); filtered[name] = node; } - } - - _.keys(graph).forEach(function(name) { - if (isNpm(name)) visit(name); }); return _.assign( @@ -48,3 +48,11 @@ function filterGraph(data) { { graph: filtered } ); } + +function getGlobPattern(data) { + var options = data.options; + var baseUrl = data.loader.baseURL; + var filter = options.filter || "node_modules/**/*"; + + return path.join(baseUrl, filter); +} diff --git a/package.json b/package.json index 6b7e9428..6ba3541f 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "web": "http://bitovi.com/" }, "dependencies": { + "bitovi-source-map": "0.4.2-bitovi.2", "chokidar": "^1.0.1", "clean-css": "^4.0.5", "colors": "^1.1.2", @@ -17,9 +18,9 @@ "glob": "^7.1.1", "is-appveyor": "^1.0.0", "lodash": "^4.3.0", + "minimatch": "^3.0.3", "moment": "^2.10.2", "pdenodeify": "^0.1.0", - "bitovi-source-map": "0.4.2-bitovi.2", "steal": "^1.2.4", "steal-bundler": "^0.3.0", "steal-parse-amd": "^1.0.0", diff --git a/test/dev_bundle_build_test.js b/test/dev_bundle_build_test.js index 6b1a5681..a8e86624 100644 --- a/test/dev_bundle_build_test.js +++ b/test/dev_bundle_build_test.js @@ -1,3 +1,4 @@ +var _ = require("lodash"); var path = require("path"); var fs = require("fs-extra"); var assert = require("assert"); @@ -6,37 +7,25 @@ var testHelpers = require("./helpers"); var devBundleBuild = require("../lib/build/bundle"); var open = testHelpers.popen; +var readFile = denodeify(fs.readFile); var rmdir = denodeify(require("rimraf")); describe("dev bundle build", function() { + this.timeout(5000); - // what should I assert here? - it.skip("app without npm dependencies?", function() { - return rmdir(path.join(__dirname, "bundle", "dist")) - .then(function() { - return devBundleBuild({ - config: path.join(__dirname, "bundle", "stealconfig.js"), - main: "bundle" - }); - }); - }); - - // what should I assert here? - it("should work", function() { - this.timeout(5000); + var baseOptions = { + quiet: true, + minify: false + }; + it("should work with defaults", function() { var config = { - config: path.join(__dirname, "npm", "package.json!npm"), - main: "src/main" - }; - - var options = { - minify: false + config: path.join(__dirname, "npm", "package.json!npm") }; var devBundlePath = path.join(__dirname, "npm", "dev-bundle.js"); - return devBundleBuild(config, options) + return devBundleBuild(config, baseOptions) .then(function() { var exists = fs.existsSync(devBundlePath); assert(exists, "dev bundle should be created"); @@ -44,7 +33,9 @@ describe("dev bundle build", function() { .then(function() { return open(path.join(__dirname, "npm"), "dev-bundle-main.html"); }) - .then(function({ browser, close }) { + .then(function(params) { + var close = params.close; + var browser = params.browser; var h1s = browser.window.document.getElementsByTagName('h1'); assert.equal(h1s.length, 1, "Wrote H!."); close(); @@ -54,5 +45,76 @@ describe("dev bundle build", function() { }); }); + it("allows filtering modules through a glob pattern", function() { + var config = { + main: "bundle", + config: path.join(__dirname, "bundle", "stealconfig.js"), + }; + + var options = _.assign({}, baseOptions, { + filter: "/**/*" + }); + + var bundlePath = path.join(__dirname, "bundle", "dev-bundle.js"); + + return devBundleBuild(config, options) + .then(function() { + var exists = fs.existsSync(bundlePath); + assert(exists, "should create dev bundle"); + }) + .then(function() { + return rmdir(bundlePath); + }); + }); + + it("allows setting the bundle destination", function() { + var config = { + main: "bundle", + config: path.join(__dirname, "bundle", "stealconfig.js"), + }; + + var options = _.assign({}, baseOptions, { + filter: "/**/*", + dest: "folder/" + }); + + var bundlePath = path.join(__dirname, "bundle", "folder", "dev-bundle.js"); + + return devBundleBuild(config, options) + .then(function() { + var exists = fs.existsSync(bundlePath); + assert(exists, "should create dev bundle"); + }) + .then(function() { + return rmdir(bundlePath); + }); + }); + + it("includes plugins in the build", function() { + var config = { + main: "main", + config: path.join(__dirname, "plugins", "config.js") + }; + + var options = _.assign({}, baseOptions, { + filter: "/**/*" + }); + + var bundlePath = path.join(__dirname, "plugins", "dev-bundle.js"); + + return devBundleBuild(config, options) + .then(function() { + return readFile(bundlePath); + }) + .then(function(contents) { + var empty = "define('plug', [], function(){ return {}; });"; + var regexp = new RegExp(_.escapeRegExp(empty)); + + assert(!regexp.test(contents), "plugin code should be included"); + }) + .then(function() { + return rmdir(bundlePath); + }); + }); }); diff --git a/test/npm/steal.production.js b/test/npm/steal.production.js deleted file mode 100644 index a4d0a40b..00000000 --- a/test/npm/steal.production.js +++ /dev/null @@ -1,12 +0,0 @@ -if(typeof steal === "undefined") steal = {}; -steal.bundlesPath = "bundles"; -steal.main = "src/main"; -steal.configMain = "package.json!npm"; -/* - * steal v1.2.1 - * - * Copyright (c) 2017 Bitovi; Licensed MIT - */ -!function(a){"object"==typeof exports?module.exports=a():"function"==typeof define&&define.amd?define(a):"undefined"!=typeof window?window.Promise=a():"undefined"!=typeof global?global.Promise=a():"undefined"!=typeof self&&(self.Promise=a())}(function(){var a;return function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};b[g][0].call(j.exports,function(a){var c=b[g][1][a];return e(c?c:a)},j,j.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g=0&&(n.splice(b,1),l("Handled previous rejection ["+a.id+"] "+e.formatObject(a.value)))}function h(a,b){m.push(a,b),null===o&&(o=d(i,0))}function i(){for(o=null;m.length>0;)m.shift()(m.shift())}var j,k=c,l=c;"undefined"!=typeof console&&(j=console,k="undefined"!=typeof j.error?function(a){j.error(a)}:function(a){j.log(a)},l="undefined"!=typeof j.info?function(a){j.info(a)}:function(a){j.log(a)}),a.onPotentiallyUnhandledRejection=function(a){h(f,a)},a.onPotentiallyUnhandledRejectionHandled=function(a){h(g,a)},a.onFatalRejection=function(a){h(b,a.value)};var m=[],n=[],o=null;return a}})}("function"==typeof a&&a.amd?a:function(a){c.exports=a(b)})},{"../env":5,"../format":6}],5:[function(b,c,d){!function(a){"use strict";a(function(a){function b(){return"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process)}function c(){return"function"==typeof MutationObserver&&MutationObserver||"function"==typeof WebKitMutationObserver&&WebKitMutationObserver}function d(a){function b(){var a=c;c=void 0,a()}var c,d=document.createTextNode(""),e=new a(b);e.observe(d,{characterData:!0});var f=0;return function(a){c=a,d.data=f^=1}}var e,f="undefined"!=typeof setTimeout&&setTimeout,g=function(a,b){return setTimeout(a,b)},h=function(a){return clearTimeout(a)},i=function(a){return f(a,0)};if(b())i=function(a){return process.nextTick(a)};else if(e=c())i=d(e);else if(!f){var j=a,k=j("vertx");g=function(a,b){return k.setTimer(b,a)},h=k.cancelTimer,i=k.runOnLoop||k.runOnContext}return{setTimer:g,clearTimer:h,asap:i}})}("function"==typeof a&&a.amd?a:function(a){c.exports=a(b)})},{}],6:[function(b,c,d){!function(a){"use strict";a(function(){function a(a){var c="object"==typeof a&&null!==a&&(a.stack||a.message)?a.stack||a.message:b(a);return a instanceof Error?c:c+" (WARNING: non-Error used)"}function b(a){var b=String(a);return"[object Object]"===b&&"undefined"!=typeof JSON&&(b=c(a,b)),b}function c(a,b){try{return JSON.stringify(a)}catch(a){return b}}return{formatError:a,formatObject:b,tryStringify:c}})}("function"==typeof a&&a.amd?a:function(a){c.exports=a()})},{}],7:[function(b,c,d){!function(a){"use strict";a(function(){return function(a){function b(a,b){this._handler=a===t?b:c(a)}function c(a){function b(a){e.resolve(a)}function c(a){e.reject(a)}function d(a){e.notify(a)}var e=new v;try{a(b,c,d)}catch(a){c(a)}return e}function d(a){return I(a)?a:new b(t,new w(q(a)))}function e(a){return new b(t,new w(new z(a)))}function f(){return _}function g(){return new b(t,new v)}function h(a,b){var c=new v(a.receiver,a.join().context);return new b(t,c)}function i(a){return k(S,null,a)}function j(a,b){return k(N,a,b)}function k(a,c,d){function e(b,e,g){g.resolved||l(d,f,b,a(c,e,b),g)}function f(a,b,c){k[a]=b,0===--j&&c.become(new y(k))}for(var g,h="function"==typeof c?e:f,i=new v,j=d.length>>>0,k=new Array(j),m=0;m0?b(c,f.value,e):(e.become(f),m(a,c+1,f))}else b(c,d,e)}function m(a,b,c){for(var d=b;d0||"function"!=typeof b&&e<0)return new this.constructor(t,d);var f=this._beget(),g=f._handler;return d.chain(g,d.receiver,a,b,c),f},b.prototype.catch=function(a){return this.then(void 0,a)},b.prototype._beget=function(){return h(this._handler,this.constructor)},b.all=i,b.race=o,b._traverse=j,b._visitRemaining=m,t.prototype.when=t.prototype.become=t.prototype.notify=t.prototype.fail=t.prototype._unreport=t.prototype._report=T,t.prototype._state=0,t.prototype.state=function(){return this._state},t.prototype.join=function(){for(var a=this;void 0!==a.handler;)a=a.handler;return a},t.prototype.chain=function(a,b,c,d,e){this.when({resolver:a,receiver:b,fulfilled:c,rejected:d,progress:e})},t.prototype.visit=function(a,b,c,d){this.chain(Y,a,b,c,d)},t.prototype.fold=function(a,b,c,d){this.when(new H(a,b,c,d))},R(t,u),u.prototype.become=function(a){a.fail()};var Y=new u;R(t,v),v.prototype._state=0,v.prototype.resolve=function(a){this.become(q(a))},v.prototype.reject=function(a){this.resolved||this.become(new z(a))},v.prototype.join=function(){if(!this.resolved)return this;for(var a=this;void 0!==a.handler;)if(a=a.handler,a===this)return this.handler=C();return a},v.prototype.run=function(){var a=this.consumers,b=this.handler;this.handler=this.handler.join(),this.consumers=void 0;for(var c=0;c",b.isDeclarative=!0,a.loaderObj.transpile(b).then(function(a){var c=__global.System,d=c.register;c.register=function(a,c,d){"string"!=typeof a&&(d=c,c=a),b.declare=d,b.depsList=c},__eval(a,__global,b),c.register=d});if("object"!=typeof c)throw TypeError("Invalid instantiate return value");b.depsList=c.deps||[],b.execute=c.execute,b.isDeclarative=!1}}).then(function(){if("loading"==b.status){b.dependencies=[];for(var d=b.depsList,e=[],f=0,g=d.length;f0)){var c=a.startingLoad;if(a.loader.loaderObj.execute===!1){for(var d=[].concat(a.loads),e=0,f=d.length;e")+"\n")),c=w(c,'Error loading "'+b.name+'" at '+(b.address||"")+"\n");for(var e=a.loads.concat([]),f=0,g=e.length;f=0;g--){for(var h=d[g],i=0;i=6?(delete c.optional,delete c.whitelist,delete c.blacklist,c.presets||c.plugins||(c.presets=["es2015-no-commonjs","react","stage-0"],c.plugins=["transform-es2015-modules-systemjs"])):(c.modules="system",c.blacklist||(c.blacklist=["react"]));var e=b.transform(a.source,c).code;return e+"\n//# sourceURL="+a.address+"!eval"}var f=__global;a.prototype.transpiler="babel",a.prototype.transpile=function(a){var d=this;return d.transpilerHasRun||(f.traceur&&!d.has("traceur")&&d.set("traceur",b(d,"traceur")),f.babel&&!d.has("babel")&&d.set("babel",b(d,"babel")),d.transpilerHasRun=!0),d.import(d.transpiler).then(function(b){return b.__useDefault&&(b=b.default),'var __moduleAddress = "'+a.address+'";'+(b.Compiler?c:e).call(d,a,b)})},a.prototype.instantiate=function(a){var c=this;return Promise.resolve(c.normalize(c.transpiler)).then(function(d){if(a.name===d)return{deps:[],execute:function(){var d=f.System,e=f.Reflect.Loader;return __eval("(function(require,exports,module){"+a.source+"})();",f,a),f.System=d,f.Reflect.Loader=e,b(c,a.name)}}})}}(__global.LoaderPolyfill),function(){function a(a){var b=String(a).replace(/^\s+|\s+$/g,"").match(/^([^:\/?#]+:)?(\/\/(?:[^:@\/?#]*(?::[^:@\/?#]*)?@)?(([^:\/?#]*)(?::(\d*))?))?([^?#]*)(\?[^#]*)?(#[\s\S]*)?/);return b?{href:b[0]||"",protocol:b[1]||"",authority:b[2]||"",host:b[3]||"",hostname:b[4]||"",port:b[5]||"",pathname:b[6]||"",search:b[7]||"",hash:b[8]||""}:null}function b(a){var b=[];return a.replace(/^(\.\.?(\/|$))+/,"").replace(/\/(\.(\/|$))+/g,"/").replace(/\/\.\.$/,"/../").replace(/\/?[^\/]*/g,function(a){"/.."===a?b.pop():b.push(a)}),b.join("").replace(/^\//,"/"===a.charAt(0)?"/":"")}function c(c,d){return g&&(d=d.replace(/\\/g,"/")),d=a(d||""),c=a(c||""),d&&c?(d.protocol||c.protocol)+(d.protocol||d.authority?d.authority:c.authority)+b(d.protocol||d.authority||"/"===d.pathname.charAt(0)?d.pathname:d.pathname?(c.authority&&!c.pathname?"/":"")+c.pathname.slice(0,c.pathname.lastIndexOf("/")+1)+d.pathname:c.pathname)+(d.protocol||d.authority||d.pathname?d.search:d.search||c.search)+d.hash:null}var d,e="undefined"!=typeof self&&"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope,f="undefined"!=typeof window&&!e,g="undefined"!=typeof process&&!!process.platform.match(/^win/),h=__global.Promise||require("when/es6-shim/Promise");if("undefined"!=typeof XMLHttpRequest)d=function(a,b,c){function d(){b(f.responseText)}function e(){var b=f.statusText+": "+a||"XHR error",d=new Error(b);d.statusCode=f.status,c(d)}var f=new XMLHttpRequest,g=!0,h=!1;if(!("withCredentials"in f)){var i=/^(\w+:)?\/\/([^\/]+)/.exec(a);i&&(g=i[2]===window.location.host,i[1]&&(g&=i[1]===window.location.protocol))}g||"undefined"==typeof XDomainRequest||(f=new XDomainRequest,f.onload=d,f.onerror=e,f.ontimeout=e,f.onprogress=function(){},f.timeout=0,h=!0),f.onreadystatechange=function(){4===f.readyState&&(200===f.status||0==f.status&&f.responseText?d():e())},f.open("GET",a,!0),h&&setTimeout(function(){f.send()},0),f.send(null)};else if("undefined"!=typeof require){var i,j=/ENOENT/;d=function(a,b,c){if("file:"!=a.substr(0,5))throw"Only file URLs of the form file: allowed running in Node.";return i=i||require("fs"),a=a.substr(5),g&&(a=a.replace(/\//g,"\\")),i.readFile(a,function(a,d){return a?(j.test(a.message)&&(a.statusCode=404),c(a)):void b(d+"")})}}else{if("function"!=typeof fetch)throw new TypeError("No environment fetch API available.");d=function(a,b,c){fetch(a).then(function(a){return a.text()}).then(function(a){b(a)}).then(null,function(a){c(a)})}}var k=function(a){function b(b){if(a.call(this,b||{}),"undefined"!=typeof location&&location.href){var c=__global.location.href.split("#")[0].split("?")[0];this.baseURL=c.substring(0,c.lastIndexOf("/")+1)}else{if("undefined"==typeof process||!process.cwd)throw new TypeError("No environment baseURL");this.baseURL="file:"+process.cwd()+"/",g&&(this.baseURL=this.baseURL.replace(/\\/g,"/"))}this.paths={"*":"*.js"}}return b.__proto__=null!==a?a:Function.prototype,b.prototype=$__Object$create(null!==a?a.prototype:null),$__Object$defineProperty(b.prototype,"constructor",{value:b}),$__Object$defineProperty(b.prototype,"global",{get:function(){return f?window:e?self:__global},enumerable:!1}),$__Object$defineProperty(b.prototype,"strict",{get:function(){return!0},enumerable:!1}),$__Object$defineProperty(b.prototype,"normalize",{value:function(a,b,c){if("string"!=typeof a)throw new TypeError("Module name must be a string");var d=a.split("/");if(0==d.length)throw new TypeError("No module name provided");var e=0,f=!1,g=0;if("."==d[0]){if(e++,e==d.length)throw new TypeError('Illegal module name "'+a+'"');f=!0}else{for(;".."==d[e];)if(e++,e==d.length)throw new TypeError('Illegal module name "'+a+'"');e&&(f=!0),g=e}for(var h=e;h2)throw new TypeError("Only one wildcard in a path is permitted");if(1==h.length){if(d==g&&g.length>e.length){e=g;break}}else d.substr(0,h[0].length)==h[0]&&d.substr(d.length-h[1].length)==h[1]&&(e=g,b=d.substr(h[0].length,d.length-h[1].length-h[0].length))}var i=this.paths[e];return b&&(i=i.replace("*",b)),f&&(i=i.replace(/#/g,"%23")),c(this.baseURL,i)},enumerable:!1,writable:!0}),$__Object$defineProperty(b.prototype,"fetch",{value:function(a){var b=this;return new h(function(e,f){d(c(b.baseURL,a.address),function(a){e(a)},f)})},enumerable:!1,writable:!0}),b}(__global.LoaderPolyfill),l=new k;"object"==typeof exports&&(module.exports=l),__global.System=l}()}("undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope?self:global),function(a){a.upgradeSystemLoader=function(){function b(a){var b=String(a).replace(/^\s+|\s+$/g,"").match(/^([^:\/?#]+:)?(\/\/(?:[^:@\/?#]*(?::[^:@\/?#]*)?@)?(([^:\/?#]*)(?::(\d*))?))?([^?#]*)(\?[^#]*)?(#[\s\S]*)?/);return b?{href:b[0]||"",protocol:b[1]||"",authority:b[2]||"",host:b[3]||"",hostname:b[4]||"",port:b[5]||"",pathname:b[6]||"",search:b[7]||"",hash:b[8]||""}:null}function d(a,c){function d(a){var b=[];return a.replace(/^(\.\.?(\/|$))+/,"").replace(/\/(\.(\/|$))+/g,"/").replace(/\/\.\.$/,"/../").replace(/\/?[^\/]*/g,function(a){"/.."===a?b.pop():b.push(a)}),b.join("").replace(/^\//,"/"===a.charAt(0)?"/":"")}return u&&(c=c.replace(/\\/g,"/")),c=b(c||""),a=b(a||""),c&&a?(c.protocol||a.protocol)+(c.protocol||c.authority?c.authority:a.authority)+d(c.protocol||c.authority||"/"===c.pathname.charAt(0)?c.pathname:c.pathname?(a.authority&&!a.pathname?"/":"")+a.pathname.slice(0,a.pathname.lastIndexOf("/")+1)+c.pathname:a.pathname)+(c.protocol||c.authority||c.pathname?c.search:c.search||a.search)+c.hash:null}function e(b){var c={};if(("object"==typeof b||"function"==typeof b)&&b!==a)if(v)for(var d in b)"default"!==d&&f(c,b,d);else g(c,b); -return c.default=b,w(c,"__useDefault",{value:!0}),c}function f(a,b,c){try{var d;(d=Object.getOwnPropertyDescriptor(b,c))&&w(a,c,d)}catch(d){return a[c]=b[c],!1}}function g(a,b,c){var d=b&&b.hasOwnProperty;for(var e in b)d&&!b.hasOwnProperty(e)||c&&e in a||(a[e]=b[e]);return a}function h(a){function b(a,b){b._extensions=[];for(var c=0,d=a.length;c=0;f--){for(var g=d[f],h=0;hb.index)return!0;return!1}d.lastIndex=e.lastIndex=f.lastIndex=0;var c,g=[],h=[],i=[];if(a.length/a.split("\n").length<200){for(;c=f.exec(a);)h.push([c.index,c.index+c[0].length]);for(;c=e.exec(a);)b(h,c)||i.push([c.index,c.index+c[0].length])}for(;c=d.exec(a);)if(!b(h,c)&&!b(i,c)){var j=c[1].substr(1,c[1].length-2);if(j.match(/"|'/))continue;g.push(j)}return g}a._extensions.push(m);var c=/(?:^\uFEFF?|[^$_a-zA-Z\xA0-\uFFFF.])(exports\s*(\[['"]|\.)|module(\.exports|\['exports'\]|\["exports"\])\s*(\[['"]|[=,\.]))/,d=/(?:^\uFEFF?|[^$_a-zA-Z\xA0-\uFFFF."'])require\s*\(\s*("[^"\\]*(?:\\.[^"\\]*)*"|'[^'\\]*(?:\\.[^'\\]*)*')\s*\)/g,e=/(^|[^\\])(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/gm,f=/("[^"\\\n\r]*(\\.[^"\\\n\r]*)*"|'[^'\\\n\r]*(\\.[^'\\\n\r]*)*')/g,g=a.instantiate;a.instantiate=function(e){return e.metadata.format||(c.lastIndex=0,d.lastIndex=0,(d.exec(e.source)||c.exec(e.source))&&(e.metadata.format="cjs")),"cjs"==e.metadata.format&&(e.metadata.deps=e.metadata.deps?e.metadata.deps.concat(b(e.source)):b(e.source),e.metadata.executingRequire=!0,e.metadata.execute=function(b,c,d){var f=(e.address||"").split("/");f.pop(),f=f.join("/"),s._nodeRequire&&(f=f.substr(5));var g=(a.global._g={global:a.global,exports:c,module:d,require:b,__filename:s._nodeRequire?e.address.substr(5):e.address,__dirname:f},a.global.define);a.global.define=void 0;var h={name:e.name,source:"(function() {\n(function(global, exports, module, require, __filename, __dirname){\n"+e.source+"\n}).call(_g.exports, _g.global, _g.exports, _g.module, _g.require, _g.__filename, _g.__dirname);})();",address:e.address};a.__exec(h),a.global.define=g,a.global._g=void 0}),g.call(this,e)}}function n(a){function b(a,b){function c(a,b){for(var c=0;cb)return!0;return!1}for(var d,e=[];d=m.exec(a);)e.push([d.index,d.index+d[0].length]);a=a.replace(k,function(a,b,d,f,g,h){return c(e,h+1)?a:""});var f=a.match(r),g=(f[1].split(",")[b]||"require").replace(s,""),h=u[g]||(u[g]=new RegExp(p+g+q,"g"));h.lastIndex=0;for(var d,i=[];d=h.exec(a);)i.push(d[2]||d[3]);return i}function c(a,b,d,e){var f=this;if("object"==typeof a&&!(a instanceof Array))return c.apply(null,Array.prototype.splice.call(arguments,1,arguments.length-1));if(!(a instanceof Array)){if("string"==typeof a){var g=f.get(a);return g.__useDefault?g.default:g}throw new TypeError("Invalid require")}Promise.all(a.map(function(a){return f.import(a,e)})).then(function(a){b&&b.apply(null,a)},d)}function d(a,b,d){return function(e,f,g){return"string"==typeof e?b(e):c.call(d,e,f,g,{name:a})}}function e(a){function c(c,e,f){"string"!=typeof c&&(f=e,e=c,c=null),e instanceof Array||(f=e,e=["require","exports","module"]),"function"!=typeof f&&(f=function(a){return function(){return a}}(f)),void 0===e[e.length-1]&&e.pop();var g,h,i;if((g=t.call(e,"require"))!=-1){e.splice(g,1);var j=f.toString();e=e.concat(b(j,g))}(h=t.call(e,"exports"))!=-1&&e.splice(h,1),(i=t.call(e,"module"))!=-1&&e.splice(i,1);var k={deps:e,execute:function(b,c,j){for(var k=[],m=0;m=0;d--)a.source=a.source.substr(0,g[d].start)+g[d].postLocate(b[d])+a.source.substr(g[d].end,a.source.length);return f.call(c,a)})}}),t(function(a){a._contextualModules={},a.setContextual=function(a,b){this._contextualModules[a]=b};var b=a.normalize;a.normalize=function(a,c){var d=this;if(c){var e=this._contextualModules[a];if(e)return a=a+"/"+c,d.has(a)?Promise.resolve(a):("string"==typeof e&&(e=d.import(e)),Promise.resolve(e).then(function(a){a.default&&(a=a.default);var b=Promise.resolve(a.call(d,c));return b}).then(function(b){return d.set(a,d.newModule(b)),a}))}return b.apply(this,arguments)}}),t(function(a){function b(){document.removeEventListener("DOMContentLoaded",b,!1),window.removeEventListener("load",b,!1),c()}function c(){for(var b=document.getElementsByTagName("script"),c=0;cb.index)return!0;return!1}function c(a){for(;e=a.exec(d);)if(!b(g,e)){var c=e[1];f.push(c)}}var d=a.replace(l,"");j.lastIndex=l.lastIndex=k.lastIndex=m.lastIndex=0;var e,f=[],g=[];if(a.length/a.split("\n").length<200)for(;e=m.exec(d);)g.push([e.index,e.index+e[0].length]);return c(j),c(k),f}b._extensions&&b._extensions.push(a),b._traceData={loads:{},parentMap:{}},b.getDependencies=function(a){var b=this.getModuleLoad(a);return b?b.metadata.dependencies:void 0},b.getDependants=function(a){var b=[],d=this._traceData.parentMap[a]||{};return c(d,function(a){b.push(a)}),b},b.getModuleLoad=function(a){return this._traceData.loads[a]},b.getBundles=function(a,b){b=b||{},b[a]=!0;var d=this,e=d._traceData.parentMap,f=e[a];if(!f)return[a];var g=[];return c(f,function(a,c){b[a]||(g=g.concat(d.getBundles(a,b)))}),g},b._allowModuleExecution={},b.allowModuleExecution=function(a){var b=this;return b.normalize(a).then(function(a){b._allowModuleExecution[a]=!0})};var e=b.normalize;b.normalize=function(a,b){var c=e.apply(this,arguments);if(b){var d=this._traceData.parentMap;return c.then(function(a){return d[a]||(d[a]={}),d[a][b]=!0,a})}return c};var f=function(){return b.newModule({})},g={traceur:!0,babel:!0},h=function(a){return g[a.name]||this._allowModuleExecution[a.name]},i=[].map||function(a){for(var b=[],c=0,d=this.length;c-1&&!c.env)&&this.config({env:i+"-production"}),(this.isEnv("production")||this.loadBundles)&&L.call(this),Q.stealPath.set.call(this,h,c)}}};c(Q,function(a,b){a.order?O.splice(a.order,0,b):O.push(b)}),A(a,O,Q),y.config=function(a){return"string"==typeof a?this.loader[a]:void this.loader.config(a)},t(function(a){a.getEnv=function(){var a=(this.env||"").split("-");return a[1]||this.env},a.getPlatform=function(){var a=(this.env||"").split("-");return 2===a.length?a[0]:void 0},a.isEnv=function(a){return this.getEnv()===a},a.isPlatform=function(a){return this.getPlatform()===a}});var R=function(a){var c={},d=/Url$/,e=a.split("?"),f=e.shift(),g=e.join("?"),h=g.split("&"),i=f.split("/");i.pop(),i.join("/");if(h.length&&h[0].length)for(var j,k=0;k1){var m=b(l[0]);m=m.replace(d,"URL"),c[m]=l.slice(1).join("=")}}return c},S=function(a){var d={},e=/Url$/;d.stealURL=a.src,c(a.attributes,function(a){var c=b(0===a.nodeName.indexOf("data-")?a.nodeName.replace("data-",""):a.nodeName);c=c.replace(e,"URL"),d[c]=""===a.value||a.value});var g=a.innerHTML;return/\S/.test(g)&&(d.mainSource=g),f(R(a.src),d)},T=function(){return new Promise(function(a,b){function c(b){var d=b.target||event.target;if(d.src&&g.test(d.src)){for(var f=0;f1?Promise.all(a):a[0]}var b=arguments,d=this.System;return v||(d.main||(d.main="@empty"),y.startup()),v.then(a)},y.setContextual=l.call(a.setContextual,a),y.isEnv=l.call(a.isEnv,a),y.isPlatform=l.call(a.isPlatform,a),y};if(o&&!q)require("steal-systemjs"),a.steal=w(System),a.steal.System=System,a.steal.dev=require("./ext/dev.js"),steal.clone=v,module.exports=a.steal;else{var x=a.steal;a.steal=w(System),a.steal.startup(x&&"object"==typeof x&&x).then(null,function(a){if("undefined"!=typeof console){var b=console,c=b.error?"error":"log";b[c](a,a.stack)}}),a.steal.clone=v}}("undefined"==typeof window?"undefined"==typeof global?this:global:window); \ No newline at end of file