webpack
Version:
Packs CommonJs/AMD modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jade, coffee, css, less, ... and your custom stuff.
1,568 lines (1,307 loc) • 265 kB
JavaScript
/******/ (function(modules) { // webpackBootstrap
/******/ // install a JSONP callback for chunk loading
/******/ var parentJsonpFunction = window["webpackJsonp"];
/******/ window["webpackJsonp"] = function webpackJsonpCallback(chunkIds, moreModules) {
/******/ // add "moreModules" to the modules object,
/******/ // then flag all "chunkIds" as loaded and fire callback
/******/ var moduleId, chunkId, i = 0, callbacks = [];
/******/ for(;i < chunkIds.length; i++) {
/******/ chunkId = chunkIds[i];
/******/ if(installedChunks[chunkId])
/******/ callbacks.push.apply(callbacks, installedChunks[chunkId]);
/******/ installedChunks[chunkId] = 0;
/******/ }
/******/ for(moduleId in moreModules) {
/******/ var _m = moreModules[moduleId];
/******/
/******/ // Check if module is deduplicated
/******/ switch(typeof _m) {
/******/ case "number":
/******/ // Module is a copy of another module
/******/ modules[moduleId] = modules[_m];
/******/ break;
/******/ case "object":
/******/ // Module can be created from a template
/******/ modules[moduleId] = (function(_m) {
/******/ var args = _m.slice(1), templateId = _m[0];
/******/ return function (a,b,c) {
/******/ modules[templateId].apply(this, [a,b,c].concat(args));
/******/ };
/******/ }(_m));
/******/ break;
/******/ default:
/******/ // Normal module
/******/ modules[moduleId] = _m;
/******/ }
/******/ }
/******/ if(parentJsonpFunction) parentJsonpFunction(chunkIds, moreModules);
/******/ while(callbacks.length)
/******/ callbacks.shift().call(null, __webpack_require__);
/******/
/******/ };
/******/
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // object to store loaded and loading chunks
/******/ // "0" means "already loaded"
/******/ // Array means "loading", array contains callbacks
/******/ var installedChunks = {
/******/ 0:0
/******/ };
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
/******/
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ exports: {},
/******/ id: moduleId,
/******/ loaded: false
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.loaded = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/ // This file contains only the entry chunk.
/******/ // The chunk loading function for additional chunks
/******/ __webpack_require__.e = function requireEnsure(chunkId, callback) {
/******/ // "0" is the signal for "already loaded"
/******/ if(installedChunks[chunkId] === 0)
/******/ return callback.call(null, __webpack_require__);
/******/
/******/ // an array means "currently loading".
/******/ if(installedChunks[chunkId] !== undefined) {
/******/ installedChunks[chunkId].push(callback);
/******/ } else {
/******/ // start chunk loading
/******/ installedChunks[chunkId] = [callback];
/******/ var head = document.getElementsByTagName('head')[0];
/******/ var script = document.createElement('script');
/******/ script.type = 'text/javascript';
/******/ script.charset = 'utf-8';
/******/ script.src = __webpack_require__.p + "" + ({"0":"main","3":"named-chunk"}[chunkId]||chunkId) + ".web.js";
/******/ head.appendChild(script);
/******/ }
/******/ };
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "js/";
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(0);
/******/ })
/************************************************************************/
/******/ ((function(modules) {
// Check all modules for deduplicated modules
for(var i in modules) {
switch(typeof modules[i]) {
case "number":
// Module is a copy of another module
modules[i] = modules[modules[i]];
break;
case "object":
// Module can be created from a template
modules[i] = (function(_m) {
var args = _m.slice(1), fn = modules[_m[0]];
return function (a,b,c) {
fn.apply(null, [a,b,c].concat(args));
};
}(modules[i]));
}
}
return modules;
}([
/* 0 */
/*!**************************!*\
!*** ./lib/index.web.js ***!
\**************************/
/***/ function(module, exports, __webpack_require__) {
/* WEBPACK VAR INJECTION */(function(module, global) {// Should not break it...
if(false)
var require = require("amdrequire");
if(false)
var define = require("amdefine");
function test(cond, message) {
if(!cond) throw new Error(message);
}
// load tests from library1, with script loader
__webpack_require__(/*! script!../js/library1.js */ 9);
// Buildin 'style' loader adds css to document
__webpack_require__(/*! ./stylesheet.css */ 14);
__webpack_require__(/*! ./stylesheet.less */ 3);
var should = __webpack_require__(/*! should */ 18);
if(!should.exist) should.exist = function(x) { should.strictEqual(x === undefined, false); should.strictEqual(x === null, false); }
describe("main", function() {
it("should load library1 with script-loader", function() {
should.exist(window.library1);
window.library1.should.be.eql(true);
});
it("should load library2 exported as global", function() {
should.exist(window.library2);
should.exist(window.library2.ok);
window.library2.ok.should.be.eql(true);
});
var testCasesContext = __webpack_require__(/*! ../../cases */ 1);
var testCasesMap = testCasesContext.keys().map(function(key) {
return key.substring(2, key.length - "/index".length).split("/");
}).reduce(function(map, x) {
if(!map[x[0]]) map[x[0]] = [x[1]];
else map[x[0]].push(x[1]);
return map;
}, {});
Object.keys(testCasesMap).forEach(function(category) {
describe(category, function() {
testCasesMap[category].forEach(function(name) {
describe(name, function() {
testCasesContext("./" + category + "/" + name + "/index");
});
});
});
});
describe("web resolving", function() {
it("should load index.web.js instead of index.js", function() {
true.should.be.eql(true);
});
it("should load correct replacements for files", function(done) {
__webpack_require__.e/*nsure*/(1, function(require) {
// Comments work!
exports.ok = true;
test(__webpack_require__(/*! subcontent */ 7) === "replaced", "node_modules should be replaced with web_modules");
test(__webpack_require__(/*! subcontent2/file.js */ 8) === "orginal", "node_modules should still work when web_modules exists");
done();
});
});
after(function() {
should.exist(exports.ok);
exports.ok.should.be.eql(true);
});
});
describe("web runtime", function() {
it("should have support for require.main", function() {
var value = __webpack_require__.c[0] === module;
var otherModuleValue = __webpack_require__(/*! ./testRequireMain */ 2);
value.should.be.eql(true);
otherModuleValue.should.be.eql(false);
});
});
describe("web polyfilling", function() {
var sum2;
before(function() {
sum2 = 0;
});
it("should polyfill process and module", function(done) {
module.id.should.have.type("number");
!/*require.ensure*/(function(require) {/* WEBPACK VAR INJECTION */(function(process) {
test(Array.isArray(process.argv), "process.argv should be an array");
process.nextTick(function() {
sum2++;
sum2.should.be.eql(2);
done();
});
sum2++;
test(global === window, "global === window");
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! (webpack)/~/node-libs-browser/~/process/browser.js */ 11)))}(__webpack_require__));
});
});
describe("web loaders", function() {
it("should handle the file loader correctly", function() {
__webpack_require__(/*! file!../img/image.png */ 5).should.match(/js\/.+\.png$/);
document.getElementById("image").src = __webpack_require__(/*! file?prefix=img/!../img/image.png */ 6);
});
});
});
if(false) {
module.hot.accept();
module.hot.dispose(function() {
mocha.suite.suites.length = 0;
var stats = document.getElementById("stats");
stats.parentNode.removeChild(stats);
});
if(module.data) {
mocha.run();
}
}
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(/*! (webpack)/buildin/module.js */ 16)(module), (function() { return this; }())))
/***/ },
/* 1 */
/*!**********************************************!*\
!*** ../cases ^\.\/[^\/_]+\/[^\/_]+\/index$ ***!
\**********************************************/
/***/ function(module, exports, __webpack_require__) {
var map = {
"./chunks/context/index": 34,
"./chunks/named-chunks/index": 35,
"./chunks/parsing/index": 36,
"./chunks/runtime/index": 37,
"./compile/deduplication/index": 38,
"./compile/error-hide-stack/index": 39,
"./loaders/async/index": 40,
"./loaders/coffee-loader/index": 41,
"./loaders/context/index": 42,
"./loaders/css-loader/index": 43,
"./loaders/jade-loader/index": 44,
"./loaders/json-loader/index": 45,
"./loaders/less-loader/index": 46,
"./loaders/module-description-file/index": 47,
"./loaders/query/index": 48,
"./loaders/raw-loader/index": 49,
"./loaders/val-loader/index": 50,
"./parsing/bom/index": 51,
"./parsing/browserify/index": 52,
"./parsing/chunks/index": 53,
"./parsing/context/index": 54,
"./parsing/evaluate/index": 55,
"./parsing/extract-amd/index": 56,
"./parsing/extract-labeled/index": 57,
"./parsing/extract-require/index": 58,
"./parsing/filename/index": 59,
"./parsing/hot-error-handler/index": 60,
"./parsing/hot-hash/index": 61,
"./parsing/inject-free-vars/index": 62,
"./parsing/issue-345/index": 63,
"./parsing/issue-387/index": 64,
"./parsing/javascript/index": 65,
"./parsing/local-modules/index": 66,
"./parsing/renaming/index": 67,
"./parsing/requirejs/index": 68,
"./parsing/typeof/index": 69,
"./resolving/browser-field/index": 70,
"./resolving/context/index": 71,
"./resolving/query/index": 72,
"./resolving/single-file-module/index": 73,
"./runtime/chunk-callback-order/index": 74,
"./runtime/circular-dependencies/index": 75,
"./runtime/error-handling/index": 76,
"./runtime/missing-module-exception/index": 77,
"./runtime/module-caching/index": 78,
"./runtime/require-function/index": 79
};
function webpackContext(req) {
return __webpack_require__(webpackContextResolve(req));
};
function webpackContextResolve(req) {
return map[req] || (function() { throw new Error("Cannot find module '" + req + "'.") }());
};
webpackContext.id = 1;
webpackContext.keys = function webpackContextKeys() {
return Object.keys(map);
};
webpackContext.resolve = webpackContextResolve;
module.exports = webpackContext;
/***/ },
/* 2 */
/*!********************************!*\
!*** ./lib/testRequireMain.js ***!
\********************************/
/***/ function(module, exports, __webpack_require__) {
/* WEBPACK VAR INJECTION */(function(module) {module.exports = __webpack_require__.c[0] === module;
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(/*! (webpack)/buildin/module.js */ 16)(module)))
/***/ },
/* 3 */
/*!*****************************!*\
!*** ./lib/stylesheet.less ***!
\*****************************/
/***/ function(module, exports, __webpack_require__) {
// style-loader: Adds some reference to a css file to the DOM by adding a <link> tag
var update = __webpack_require__(/*! (webpack)/~/style-loader/addStyleUrl.js */ 10)(
__webpack_require__(/*! !(webpack)/~/file-loader?postfix=.css&string!(webpack)/~/less-loader!./lib/stylesheet.less */ 4)
);
// Hot Module Replacement
if(false) {
module.hot.accept("!!C:\\Users\\kop\\Repos\\webpack\\node_modules\\file-loader\\index.js?postfix=.css&string!C:\\Users\\kop\\Repos\\webpack\\node_modules\\less-loader\\index.js!C:\\Users\\kop\\Repos\\webpack\\test\\browsertest\\lib\\stylesheet.less", function() {
update(require("!!C:\\Users\\kop\\Repos\\webpack\\node_modules\\file-loader\\index.js?postfix=.css&string!C:\\Users\\kop\\Repos\\webpack\\node_modules\\less-loader\\index.js!C:\\Users\\kop\\Repos\\webpack\\test\\browsertest\\lib\\stylesheet.less"));
});
module.hot.dispose(function() { update(); });
}
/***/ },
/* 4 */
/*!*************************************************************************************************!*\
!*** (webpack)/~/file-loader?postfix=.css&string!(webpack)/~/less-loader!./lib/stylesheet.less ***!
\*************************************************************************************************/
/***/ function(module, exports, __webpack_require__) {
module.exports = __webpack_require__.p + "a583b564d703bb31cee70f60ec715be7.less"
/***/ },
/* 5 */
/*!***********************************************!*\
!*** (webpack)/~/file-loader!./img/image.png ***!
\***********************************************/
/***/ function(module, exports, __webpack_require__) {
module.exports = __webpack_require__.p + "c31e9820c001c9c4a86bce33ce43b679.png"
/***/ },
/* 6 */
/*!***********************************************************!*\
!*** (webpack)/~/file-loader?prefix=img/!./img/image.png ***!
\***********************************************************/
5,
/* 7 */,
/* 8 */,
/* 9 */
/*!**************************************************!*\
!*** (webpack)/~/script-loader!./js/library1.js ***!
\**************************************************/
/***/ function(module, exports, __webpack_require__) {
__webpack_require__(/*! (webpack)/~/script-loader/addScript.js */ 12)(__webpack_require__(/*! (webpack)/~/raw-loader!./js/library1.js */ 13))
/***/ },
/* 10 */
/*!***********************************************!*\
!*** (webpack)/~/style-loader/addStyleUrl.js ***!
\***********************************************/
/***/ function(module, exports, __webpack_require__) {
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
module.exports = function addStyleUrl(cssUrl) {
if(false) {
if(typeof document !== "object") throw new Error("The style-loader cannot be used in a non-browser environment");
}
var styleElement = document.createElement("link");
styleElement.rel = "stylesheet";
styleElement.type = "text/css";
styleElement.href = cssUrl;
var head = document.getElementsByTagName("head")[0];
head.appendChild(styleElement);
if(false) {
return function(cssUrl) {
if(typeof cssUrl === "string") {
styleElement.href = cssUrl;
} else {
head.removeChild(styleElement);
}
};
}
}
/***/ },
/* 11 */
/*!**********************************************************!*\
!*** (webpack)/~/node-libs-browser/~/process/browser.js ***!
\**********************************************************/
/***/ function(module, exports, __webpack_require__) {
// shim for using process in browser
var process = module.exports = {};
process.nextTick = (function () {
var canSetImmediate = typeof window !== 'undefined'
&& window.setImmediate;
var canPost = typeof window !== 'undefined'
&& window.postMessage && window.addEventListener
;
if (canSetImmediate) {
return function (f) { return window.setImmediate(f) };
}
if (canPost) {
var queue = [];
window.addEventListener('message', function (ev) {
var source = ev.source;
if ((source === window || source === null) && ev.data === 'process-tick') {
ev.stopPropagation();
if (queue.length > 0) {
var fn = queue.shift();
fn();
}
}
}, true);
return function nextTick(fn) {
queue.push(fn);
window.postMessage('process-tick', '*');
};
}
return function nextTick(fn) {
setTimeout(fn, 0);
};
})();
process.title = 'browser';
process.browser = true;
process.env = {};
process.argv = [];
function noop() {}
process.on = noop;
process.addListener = noop;
process.once = noop;
process.off = noop;
process.removeListener = noop;
process.removeAllListeners = noop;
process.emit = noop;
process.binding = function (name) {
throw new Error('process.binding is not supported');
}
// TODO(shtylman)
process.cwd = function () { return '/' };
process.chdir = function (dir) {
throw new Error('process.chdir is not supported');
};
/***/ },
/* 12 */
/*!**********************************************!*\
!*** (webpack)/~/script-loader/addScript.js ***!
\**********************************************/
/***/ function(module, exports, __webpack_require__) {
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
module.exports = function(src) {
if (window.execScript)
window.execScript(src);
else
eval.call(null, src);
}
/***/ },
/* 13 */
/*!***********************************************!*\
!*** (webpack)/~/raw-loader!./js/library1.js ***!
\***********************************************/
/***/ function(module, exports, __webpack_require__) {
module.exports = "var library1 =\n/******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId])\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\texports: {},\n/******/ \t\t\tid: moduleId,\n/******/ \t\t\tloaded: false\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.loaded = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"\";\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(0);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/*!*****************************!*\\\n !*** ./~/library1/index.js ***!\n \\*****************************/\n/***/ function(module, exports, __webpack_require__) {\n\n\t// Single File library\r\n\tvar loadTimelibrary1 = typeof window.library1 === \"undefined\"\r\n\tdescribe(\"library1\", function() {\r\n\t\tit(\"should load library1 only once\", function() {\r\n\t\t\tloadTimelibrary1.should.be.ok;\r\n\t\t});\r\n\t\t\r\n\t\tit(\"should load a component\", function() {\r\n\t\t\t__webpack_require__(/*! ./lib/component */ 1).should.be.eql(\"lib1 component\");\r\n\t\t});\r\n\t\t\r\n\t\tit(\"should load async submodules with require.ensure even if single == true\", function(done) {\r\n\t\t\tvar sameTick = true;\r\n\t\t\t!/*require.ensure*/(function(require) {\r\n\t\t\t\tsameTick.should.be.eql(true);\r\n\t\t\t\t__webpack_require__(/*! submodule1 */ 3).should.be.eql(\"submodule1\");\r\n\t\t\t\t__webpack_require__(/*! submodule2 */ 4).should.be.eql(\"submodule2\");\r\n\t\t\t\t__webpack_require__(/*! submodule3 */ 2)().should.be.eql(\"submodule3\");\r\n\t\t\t\t!/*require.ensure*/(function(require) {\r\n\t\t\t\t\tsameTick.should.be.eql(true);\r\n\t\t\t\t\tdone();\r\n\t\t\t\t}(__webpack_require__));\r\n\t\t\t}(__webpack_require__));\r\n\t\t\tsameTick = false;\r\n\t\t});\r\n\t});\r\n\tmodule.exports = true;\n\n/***/ },\n/* 1 */\n/*!*************************************!*\\\n !*** ./~/library1/lib/component.js ***!\n \\*************************************/\n/***/ function(module, exports, __webpack_require__) {\n\n\tmodule.exports = __webpack_require__(/*! ./comp.js */ 5);\n\n/***/ },\n/* 2 */\n/*!*******************************!*\\\n !*** ./~/submodule3/index.js ***!\n \\*******************************/\n/***/ function(module, exports, __webpack_require__) {\n\n\tmodule.exports = function() {\r\n\t\treturn \"submodule3\";\r\n\t};\n\n/***/ },\n/* 3 */\n/*!******************************************!*\\\n !*** ./~/library1/~/submodule1/index.js ***!\n \\******************************************/\n/***/ function(module, exports, __webpack_require__) {\n\n\tmodule.exports = \"submodule1\";\n\n/***/ },\n/* 4 */\n/*!******************************************!*\\\n !*** ./~/library1/~/submodule2/index.js ***!\n \\******************************************/\n/***/ function(module, exports, __webpack_require__) {\n\n\tmodule.exports = (function() {\r\n\t\treturn \"submodule2\";\r\n\t}());\n\n/***/ },\n/* 5 */\n/*!********************************!*\\\n !*** ./~/library1/lib/comp.js ***!\n \\********************************/\n/***/ function(module, exports, __webpack_require__) {\n\n\tmodule.exports = \"lib1 component\";\n\n/***/ }\n/******/ ])"
/***/ },
/* 14 */
/*!****************************!*\
!*** ./lib/stylesheet.css ***!
\****************************/
/***/ function(module, exports, __webpack_require__) {
// style-loader: Adds some css to the DOM by adding a <style> tag
// load the styles
var content = __webpack_require__(/*! !(webpack)/~/css-loader!./lib/stylesheet.css */ 15);
if(typeof content === 'string') content = [module.id, content, ''];
// add the styles to the DOM
var update = __webpack_require__(/*! (webpack)/~/style-loader/addStyles.js */ 17)(content);
// Hot Module Replacement
if(false) {
// When the styles change, update the <style> tags
module.hot.accept("!!C:\\Users\\kop\\Repos\\webpack\\node_modules\\css-loader\\index.js!C:\\Users\\kop\\Repos\\webpack\\test\\browsertest\\lib\\stylesheet.css", function() {
var newContent = require("!!C:\\Users\\kop\\Repos\\webpack\\node_modules\\css-loader\\index.js!C:\\Users\\kop\\Repos\\webpack\\test\\browsertest\\lib\\stylesheet.css");
if(typeof newContent === 'string') newContent = [module.id, newContent, ''];
update(newContent);
});
// When the module is disposed, remove the <style> tags
module.hot.dispose(function() { update(); });
}
/***/ },
/* 15 */
/*!***************************************************!*\
!*** (webpack)/~/css-loader!./lib/stylesheet.css ***!
\***************************************************/
/***/ function(module, exports, __webpack_require__) {
exports = module.exports = __webpack_require__(/*! (webpack)/~/css-loader/cssToString.js */ 19)();
exports.push([module.id, ".style-test.css-styles {\r\n\tbackground: #3F3;\r\n}", ""]);
/***/ },
/* 16 */
/*!***********************************!*\
!*** (webpack)/buildin/module.js ***!
\***********************************/
/***/ function(module, exports, __webpack_require__) {
module.exports = function(module) {
if(!module.webpackPolyfill) {
module.deprecate = function() {};
module.paths = [];
// module.parent = undefined by default
module.children = [];
module.webpackPolyfill = 1;
}
return module;
}
/***/ },
/* 17 */
/*!*********************************************!*\
!*** (webpack)/~/style-loader/addStyles.js ***!
\*********************************************/
/***/ function(module, exports, __webpack_require__) {
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
var stylesInDom = {};
module.exports = function(list) {
if(false) {
if(typeof document !== "object") throw new Error("The style-loader cannot be used in a non-browser environment");
}
var styles = listToStyles(list);
addStylesToDom(styles);
return function update(newList) {
var mayRemove = [];
for(var i = 0; i < styles.length; i++) {
var item = styles[i];
var domStyle = stylesInDom[item.id];
domStyle.refs--;
mayRemove.push(domStyle);
}
if(newList) {
var newStyles = listToStyles(newList);
addStylesToDom(newStyles);
}
for(var i = 0; i < mayRemove.length; i++) {
var domStyle = mayRemove[i];
if(domStyle.refs === 0) {
for(var j = 0; j < domStyle.parts.length; j++)
domStyle.parts[j]();
delete stylesInDom[domStyle.id];
}
}
};
}
function addStylesToDom(styles) {
for(var i = 0; i < styles.length; i++) {
var item = styles[i];
var domStyle = stylesInDom[item.id];
if(domStyle) {
domStyle.refs++;
for(var j = 0; j < domStyle.parts.length; j++) {
domStyle.parts[j](item.parts[j]);
}
for(; j < item.parts.length; j++) {
domStyle.parts.push(addStyle(item.parts[j]));
}
} else {
var parts = [];
for(var j = 0; j < item.parts.length; j++) {
parts.push(addStyle(item.parts[j]));
}
stylesInDom[item.id] = {id: item.id, refs: 1, parts: parts};
}
}
}
function listToStyles(list) {
var styles = [];
var newStyles = {};
for(var i = 0; i < list.length; i++) {
var item = list[i];
var id = item[0];
var css = item[1];
var media = item[2];
// var sourceMap = item[3];
var part = {css: css, media: media/*, sourceMap: sourceMap*/};
if(!newStyles[id])
styles.push(newStyles[id] = {id: id, parts: [part]});
else
newStyles[id].parts.push(part);
}
return styles;
}
function addStyle(obj) {
var styleElement = document.createElement("style");
var head = document.head || document.getElementsByTagName("head")[0];
styleElement.type = "text/css";
head.appendChild(styleElement);
applyToTag(styleElement, obj);
return function(newObj) {
if(newObj) {
if(newObj.css === obj.css && newObj.media === obj.media /*&& newObj.sourceMap === obj.sourceMap*/)
return;
applyToTag(styleElement, obj = newObj);
} else {
head.removeChild(styleElement);
}
};
};
function applyToTag(styleElement, obj) {
var css = obj.css;
var media = obj.media;
// var sourceMap = obj.sourceMap;
// No browser support
// if(sourceMap && typeof btoa === "function") {
// try {
// css += "\n/*# sourceMappingURL=data:application/json;base64," + btoa(JSON.stringify(sourceMap)) + " */";
// } catch(e) {}
// }
if(media) {
styleElement.setAttribute("media", media)
}
if (styleElement.styleSheet) {
styleElement.styleSheet.cssText = css;
} else {
while(styleElement.firstChild) {
styleElement.removeChild(styleElement.firstChild);
}
styleElement.appendChild(document.createTextNode(css));
}
}
/***/ },
/* 18 */
/*!****************************************!*\
!*** (webpack)/~/should/lib/should.js ***!
\****************************************/
/***/ function(module, exports, __webpack_require__) {
/*!
* Should
* Copyright(c) 2010-2014 TJ Holowaychuk <tj@vision-media.ca>
* MIT Licensed
*/
var util = __webpack_require__(/*! ./util */ 20),
AssertionError = util.AssertionError,
inspect = util.inspect;
/**
* Our function should
* @param obj
* @returns {Assertion}
*/
var should = function(obj) {
return new Assertion(util.isWrapperType(obj) ? obj.valueOf() : obj);
};
/**
* Initialize a new `Assertion` with the given _obj_.
*
* @param {*} obj
* @api private
*/
var Assertion = should.Assertion = function Assertion(obj) {
this.obj = obj;
};
/**
Way to extend Assertion function. It uses some logic
to define only positive assertions and itself rule with negative assertion.
All actions happen in subcontext and this method take care about negation.
Potentially we can add some more modifiers that does not depends from state of assertion.
*/
Assertion.add = function(name, f, isGetter) {
var prop = { enumerable: true };
prop[isGetter ? 'get' : 'value'] = function() {
var context = new Assertion(this.obj);
context.copy = context.copyIfMissing;
context.anyOne = this.anyOne;
try {
f.apply(context, arguments);
} catch(e) {
//copy data from sub context to this
this.copy(context);
//check for fail
if(e instanceof should.AssertionError) {
//negative fail
if(this.negate) {
this.obj = context.obj;
this.negate = false;
return this;
}
this.assert(false);
}
// throw if it is another exception
throw e;
}
//copy data from sub context to this
this.copy(context);
if(this.negate) {
this.assert(false);
}
this.obj = context.obj;
this.negate = false;
return this;
};
Object.defineProperty(Assertion.prototype, name, prop);
};
Assertion.alias = function(from, to) {
var desc = Object.getOwnPropertyDescriptor(Assertion.prototype, from);
if(!desc) throw new Error('Alias ' + from + ' -> ' + to + ' could not be created as ' + from + ' not defined');
Object.defineProperty(Assertion.prototype, to, desc);
};
should.AssertionError = AssertionError;
should.format = function (value) {
if(util.isDate(value) && typeof value.inspect !== 'function') return value.toISOString(); //show millis in dates
return inspect(value, { depth: null });
};
should.use = function(f) {
f(this, Assertion);
return this;
};
/**
* Expose should to external world.
*/
exports = module.exports = should;
/**
* Expose api via `Object#should`.
*
* @api public
*/
Object.defineProperty(Object.prototype, 'should', {
set: function() {
},
get: function() {
return should(this);
},
configurable: true
});
Assertion.prototype = {
constructor: Assertion,
assert: function(expr) {
if(expr) return this;
var params = this.params;
var msg = params.message, generatedMessage = false;
if(!msg) {
msg = this.getMessage();
generatedMessage = true;
}
var err = new AssertionError({
message: msg, actual: this.obj, expected: params.expected, stackStartFunction: this.assert
});
err.showDiff = params.showDiff;
err.operator = params.operator;
err.generatedMessage = generatedMessage;
throw err;
},
getMessage: function() {
return 'expected ' + ('obj' in this.params ? this.params.obj: should.format(this.obj)) + (this.negate ? ' not ': ' ') +
this.params.operator + ('expected' in this.params ? ' ' + should.format(this.params.expected) : '');
},
copy: function(other) {
this.params = other.params;
},
copyIfMissing: function(other) {
if(!this.params) this.params = other.params;
},
/**
* Negation modifier.
*
* @api public
*/
get not() {
this.negate = !this.negate;
return this;
},
/**
* Any modifier - it affect on execution of sequenced assertion to do not check all, but any of
*
* @api public
*/
get any() {
this.anyOne = true;
return this;
}
};
should
.use(__webpack_require__(/*! ./ext/assert */ 21))
.use(__webpack_require__(/*! ./ext/chain */ 22))
.use(__webpack_require__(/*! ./ext/bool */ 23))
.use(__webpack_require__(/*! ./ext/number */ 24))
.use(__webpack_require__(/*! ./ext/eql */ 25))
.use(__webpack_require__(/*! ./ext/type */ 26))
.use(__webpack_require__(/*! ./ext/string */ 27))
.use(__webpack_require__(/*! ./ext/property */ 28))
.use(__webpack_require__(/*! ./ext/error */ 29))
.use(__webpack_require__(/*! ./ext/match */ 30))
.use(__webpack_require__(/*! ./ext/contain */ 31));
/***/ },
/* 19 */
/*!*********************************************!*\
!*** (webpack)/~/css-loader/cssToString.js ***!
\*********************************************/
/***/ function(module, exports, __webpack_require__) {
module.exports = function() {
var list = [];
list.toString = function toString() {
var result = [];
for(var i = 0; i < this.length; i++) {
var item = this[i];
if(item[2]) {
result.push("@media " + item[2] + "{" + item[1] + "}");
} else {
result.push(item[1]);
}
}
return result.join("");
};
return list;
}
/***/ },
/* 20 */
/*!**************************************!*\
!*** (webpack)/~/should/lib/util.js ***!
\**************************************/
/***/ function(module, exports, __webpack_require__) {
/* WEBPACK VAR INJECTION */(function(Buffer) {/*!
* Should
* Copyright(c) 2010-2014 TJ Holowaychuk <tj@vision-media.ca>
* MIT Licensed
*/
/**
* Check if given obj just a primitive type wrapper
* @param {Object} obj
* @returns {boolean}
* @api private
*/
exports.isWrapperType = function(obj) {
return isNumber(obj) || isString(obj) || isBoolean(obj);
};
/**
* Merge object b with object a.
*
* var a = { foo: 'bar' }
* , b = { bar: 'baz' };
*
* utils.merge(a, b);
* // => { foo: 'bar', bar: 'baz' }
*
* @param {Object} a
* @param {Object} b
* @return {Object}
* @api private
*/
exports.merge = function(a, b){
if (a && b) {
for (var key in b) {
a[key] = b[key];
}
}
return a;
};
function isArray(arr) {
return isObject(arr) && (arr.__ArrayLike || Array.isArray(arr));
}
exports.isArray = isArray;
function isNumber(arg) {
return typeof arg === 'number' || arg instanceof Number;
}
exports.isNumber = isNumber;
function isString(arg) {
return typeof arg === 'string' || arg instanceof String;
}
function isBoolean(arg) {
return typeof arg === 'boolean' || arg instanceof Boolean;
}
exports.isBoolean = isBoolean;
exports.isString = isString;
function isBuffer(arg) {
return typeof Buffer !== 'undefined' && arg instanceof Buffer;
}
exports.isBuffer = isBuffer;
function isDate(d) {
return isObject(d) && objectToString(d) === '[object Date]';
}
exports.isDate = isDate;
function objectToString(o) {
return Object.prototype.toString.call(o);
}
function isObject(arg) {
return typeof arg === 'object' && arg !== null;
}
exports.isObject = isObject;
function isRegExp(re) {
return isObject(re) && objectToString(re) === '[object RegExp]';
}
exports.isRegExp = isRegExp;
function isNullOrUndefined(arg) {
return arg == null;
}
exports.isNullOrUndefined = isNullOrUndefined;
function isNull(arg) {
return arg === null;
}
exports.isNull = isNull;
function isArguments(object) {
return objectToString(object) === '[object Arguments]';
}
exports.isArguments = isArguments;
exports.isFunction = function(arg) {
return typeof arg === 'function' || arg instanceof Function;
};
function isError(e) {
return (isObject(e) && objectToString(e) === '[object Error]') || (e instanceof Error);
}
exports.isError = isError;
function isUndefined(arg) {
return arg === void 0;
}
exports.isUndefined = isUndefined;
exports.inspect = __webpack_require__(/*! ./inspect */ 32).inspect;
exports.AssertionError = __webpack_require__(/*! assert */ 80).AssertionError;
var hasOwnProperty = Object.prototype.hasOwnProperty;
exports.forOwn = function(obj, f, context) {
for(var prop in obj) {
if(hasOwnProperty.call(obj, prop)) {
f.call(context, obj[prop], prop);
}
}
};
var functionNameRE = /^\s*function\s*(\S*)\s*\(/;
exports.functionName = function(f) {
if(f.name) {
return f.name;
}
var name = f.toString().match(functionNameRE)[1];
return name;
};
exports.formatProp = function(name) {
name = JSON.stringify('' + name);
if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
name = name.substr(1, name.length - 2);
} else {
name = name.replace(/'/g, "\\'")
.replace(/\\"/g, '"')
.replace(/(^"|"$)/g, "'")
.replace(/\\\\/g, '\\');
}
return name;
}
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(/*! (webpack)/~/node-libs-browser/~/buffer/index.js */ 81).Buffer))
/***/ },
/* 21 */
/*!********************************************!*\
!*** (webpack)/~/should/lib/ext/assert.js ***!
\********************************************/
/***/ function(module, exports, __webpack_require__) {
/*!
* Should
* Copyright(c) 2010-2014 TJ Holowaychuk <tj@vision-media.ca>
* MIT Licensed
*/
var util = __webpack_require__(/*! ../util */ 20)
, assert = __webpack_require__(/*! assert */ 80)
, AssertionError = assert.AssertionError;
module.exports = function(should) {
var i = should.format;
/**
* Expose assert to should
*
* This allows you to do things like below
* without require()ing the assert module.
*
* should.equal(foo.bar, undefined);
*
*/
util.merge(should, assert);
/**
* Assert _obj_ exists, with optional message.
*
* @param {*} obj
* @param {String} [msg]
* @api public
*/
should.exist = should.exists = function(obj, msg) {
if(null == obj) {
throw new AssertionError({
message: msg || ('expected ' + i(obj) + ' to exist'), stackStartFunction: should.exist
});
}
};
/**
* Asserts _obj_ does not exist, with optional message.
*
* @param {*} obj
* @param {String} [msg]
* @api public
*/
should.not = {};
should.not.exist = should.not.exists = function(obj, msg) {
if(null != obj) {
throw new AssertionError({
message: msg || ('expected ' + i(obj) + ' to not exist'), stackStartFunction: should.not.exist
});
}
};
};
/***/ },
/* 22 */
/*!*******************************************!*\
!*** (webpack)/~/should/lib/ext/chain.js ***!
\*******************************************/
/***/ function(module, exports, __webpack_require__) {
/*!
* Should
* Copyright(c) 2010-2014 TJ Holowaychuk <tj@vision-media.ca>
* MIT Licensed
*/
module.exports = function(should, Assertion) {
function addLink(name) {
Object.defineProperty(Assertion.prototype, name, {
get: function() {
return this;
},
enumerable: true
});
}
['an', 'of', 'a', 'and', 'be', 'have', 'with', 'is', 'which', 'the'].forEach(addLink);
};
/***/ },
/* 23 */
/*!******************************************!*\
!*** (webpack)/~/should/lib/ext/bool.js ***!
\******************************************/
/***/ function(module, exports, __webpack_require__) {
/*!
* Should
* Copyright(c) 2010-2014 TJ Holowaychuk <tj@vision-media.ca>
* MIT Licensed
*/
module.exports = function(should, Assertion) {
Assertion.add('true', function() {
this.is.exactly(true);
}, true);
Assertion.alias('true', 'True');
Assertion.add('false', function() {
this.is.exactly(false);
}, true);
Assertion.alias('false', 'False');
Assertion.add('ok', function() {
this.params = { operator: 'to be truthy' };
this.assert(this.obj);
}, true);
};
/***/ },
/* 24 */
/*!********************************************!*\
!*** (webpack)/~/should/lib/ext/number.js ***!
\********************************************/
/***/ function(module, exports, __webpack_require__) {
/*!
* Should
* Copyright(c) 2010-2014 TJ Holowaychuk <tj@vision-media.ca>
* MIT Licensed
*/
module.exports = function(should, Assertion) {
Assertion.add('NaN', function() {
this.params = { operator: 'to be NaN' };
this.assert(this.obj !== this.obj);
}, true);
Assertion.add('Infinity', function() {
this.params = { operator: 'to be Infinity' };
this.is.a.Number
.and.not.a.NaN
.and.assert(!isFinite(this.obj));
}, true);
Assertion.add('within', function(start, finish, description) {
this.params = { operator: 'to be within ' + start + '..' + finish, message: description };
this.assert(this.obj >= start && this.obj <= finish);
});
Assertion.add('approximately', function(value, delta, description) {
this.params = { operator: 'to be approximately ' + value + " ±" + delta, message: description };
this.assert(Math.abs(this.obj - value) <= delta);
});
Assertion.add('above', function(n, description) {
this.params = { operator: 'to be above ' + n, message: description };
this.assert(this.obj > n);
});
Assertion.add('below', function(n, description) {
this.params = { operator: 'to be below ' + n, message: description };
this.assert(this.obj < n);
});
Assertion.alias('above', 'greaterThan');
Assertion.alias('below', 'lessThan');
};
/***/ },
/* 25 */
/*!*****************************************!*\
!*** (webpack)/~/should/lib/ext/eql.js ***!
\*****************************************/
/***/ function(module, exports, __webpack_require__) {
/*!
* Should
* Copyright(c) 2010-2014 TJ Holowaychuk <tj@vision-media.ca>
* MIT Licensed
*/
var eql = __webpack_require__(/*! ../eql */ 33);
module.exports = function(should, Assertion) {
Assertion.add('eql', function(val, description) {
this.params = { operator: 'to equal', expected: val, showDiff: true, message: description };
this.assert(eql(val, this.obj));
});
Assertion.add('equal', function(val, description) {
this.params = { operator: 'to be', expected: val, showDiff: true, message: description };
this.assert(val === this.obj);
});
Assertion.alias('equal', 'exactly');
};
/***/ },
/* 26 */
/*!******************************************!*\
!*** (webpack)/~/should/lib/ext/type.js ***!
\******************************************/
/***/ function(module, exports, __webpack_require__) {
/*!
* Should
* Copyright(c) 2010-2014 TJ Holowaychuk <tj@vision-media.ca>
* MIT Licensed
*/
var util = __webpack_require__(/*! ../util */ 20);
module.exports = function(should, Assertion) {
Assertion.add('Number', function() {
this.params = { operator: 'to be a number' };
this.assert(util.isNumber(this.obj));
}, true);
Assertion.add('arguments', function() {
this.params = { operator: 'to be arguments' };
this.assert(util.isArguments(this.obj));
}, true);
Assertion.add('type', function(type, description) {
this.params = { operator: 'to have type ' + type, message: description };
(typeof this.obj).should.be.exactly(type, description);
});
Assertion.add('instanceof', function(constructor, description) {
this.params = { operator: 'to be an instance of ' + util.functionName(constructor), message: description };
this.assert(Object(this.obj) instanceof constructor);
});
Assertion.add('Function', function() {
this.params = { operator: 'to be a function' };
this.assert(util.isFunction(this.obj));
}, true);
Assertion.add('Object', function() {
this.params = { operator: 'to be an object' };
this.assert(util.isObject(this.obj));
}, true);
Assertion.add('String', function() {
this.params = { operator: 'to be a string' };
this.assert(util.isString(this.obj));
}, true);
Assertion.add('Array', function() {
this.params = { operator: 'to be an array' };
this.assert(util.isArray(this.obj));
}, true);
Assertion.add('Boolean', function() {
this.params = { operator: 'to be a boolean' };
this.assert(util.isBoolean(this.obj));
}, true);
Assertion.add('Error', function() {
this.params = { operator: 'to be an error' };
this.assert(util.isError(this.obj));
}, true);
Assertion.add('null', function() {
this.params = { operator: 'to be null' };
this.assert(this.obj === null);
}, true);
Assertion.alias('null', 'Null');
Assertion.alias('instanceof', 'instanceOf');
};
/***/ },
/* 27 */
/*!********************************************!*\
!*** (webpack)/~/should/lib/ext/string.js ***!
\********************************************/
/***/ function(module, exports, __webpack_require__) {
/*!
* Should
* Copyright(c) 2010-2014 TJ Holowaychuk <tj@vision-media.ca>
* MIT Licensed
*/
module.exports = function(should, Assertion) {
Assertion.add('startWith', function(str, description) {
this.params = { operator: 'to start with ' + should.format(str), message: description };
this.assert(0 === this.obj.indexOf(str));
});
Assertion.add('endWith', function(str, description) {
this.params = { operator: 'to end with ' + should.format(str), message: description };
this.assert(this.obj.indexOf(str, this.obj.length - str.length) >= 0);
});
};
/***/ },
/* 28 */
/*!**********************************************!*\
!*** (webpack)/~/should/lib/ext/property.js ***!
\**********************************************/
/***/ function(module, exports, __webpack_require__) {
/*!
* Should
* Copyright(c) 2010-2014 TJ Holowaychuk <tj@vision-media.ca>
* MIT Licensed
*/
var util = __webpack_require__(/*! ../util */ 20),
eql = __webpack_require__(/*! ../eql */ 33);
var aSlice = Array.prototype.slice;
module.exports = function(should, Assertion) {
var i = should.format;
Assertion.add('enumerable', function(name, val) {
name = String(name);
this.params = {
operator:"to have enumerable property " + util.formatProp(name)
};
this.assert(this.obj.propertyIsEnumerable(name));
if(arguments.length > 1){
this.params.operator += " equal to "+i(val);
this.assert(eql(val, this.obj[name]));
}
});
Assertion.add('property', function(name, val) {
name = String(name);
if(arguments.length > 1) {
var p = {};
p[name] = val;
this.have.properties(p);
} else {
this.have.properties(name);
}
this.obj = this.obj[name];
});
Assertion.add('properties', function(names) {
var values = {};
if(arguments.length > 1) {
names = aSlice.call(arguments);
} else if(!util.isArray(names)) {
if(util.isString(names)) {
names = [names];
} else {
values = names;
names = Object.keys(names);
}
}
var obj = Object(this.obj), missingProperties = [];
//just enumerate properties and check if they all present
names.forEach(function(name) {
if(!(name in obj)) missingProperties.push(util.formatProp(name));
});
var props = missingProperties;
if(props.length === 0) {
props = names.map(util.formatProp);
} else if(this.anyOne) {
props = names.filter(function(name) {
return missingProperties.indexOf(util.formatProp(name)) < 0;
}).map(util.formatProp);
}
var operator = (props.length === 1 ?
'to have property ' : 'to have '+(this.anyOne? 'any of ' : '')+'properties ') + props.join(', ');
this.params = { operator: operator };
//check that all properties presented
//or if we request one of them that at least one them presented
this.assert(missingProperties.length === 0 || (this.anyOne && missingProperties.length != names.length));
// check if values in object matched expected
var valueCheckNames = Object.keys(values);
if(valueCheckNames.length) {
var wrongValues = [];
props = [];
// now check values, as there we have all properties
valueCheckNames.forEach(function(name) {
var value = values[name];
if(!eql(obj[name], value)) {
wrongValues.push(util.formatProp(name) + ' of ' + i(value) + ' (got ' + i(obj[name]) + ')');
} else {
props.push(util.formatProp(name) + ' of ' + i(value));
}
});
if((wrongValues.length !== 0 && !this.anyOne) || (this.anyOne && props.length === 0)) {
props = wrongValues;
}
operator = (props.length === 1 ?
'to have property ' : 'to have '+(this.anyOne? 'any of ' : '')+'properties ') + props.join(', ');
this.params = { operator: operator };
//if there is no not matched values
//or there is at least one matched
this.assert(wrongValues.length === 0 || (this.anyOne && wrongValues.length != valueCheckNames.length));
}
});
Assertion.add('length', function(n, description) {
this.have.property('length', n, description);
});
Assertion.alias('length', 'lengthOf');
var hasOwnProperty = Object.prototype.hasOwnProperty;
Assertion.add('ownProperty', function(name, description) {
name = String(name);
this.params = { operator: 'to have own property ' + util.formatProp(name), message: description };
this.assert(hasOwnProperty.call(this.obj, name));
this.obj = this.obj[name];
});
Assertion.alias('ownProperty', 'hasOwnProperty');
Assertion.add('empty', function() {
this.params = { operator: 'to be empty' };
if(util.isString(this.obj) || util.isArray(this.obj) || util.isArguments(this.obj)) {
this.have.property('