main.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  1. /******/ (function(modules) { // webpackBootstrap
  2. /******/ // The module cache
  3. /******/ var installedModules = {};
  4. /******/
  5. /******/ // The require function
  6. /******/ function __webpack_require__(moduleId) {
  7. /******/
  8. /******/ // Check if module is in cache
  9. /******/ if(installedModules[moduleId]) {
  10. /******/ return installedModules[moduleId].exports;
  11. /******/ }
  12. /******/ // Create a new module (and put it into the cache)
  13. /******/ var module = installedModules[moduleId] = {
  14. /******/ i: moduleId,
  15. /******/ l: false,
  16. /******/ exports: {}
  17. /******/ };
  18. /******/
  19. /******/ // Execute the module function
  20. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  21. /******/
  22. /******/ // Flag the module as loaded
  23. /******/ module.l = true;
  24. /******/
  25. /******/ // Return the exports of the module
  26. /******/ return module.exports;
  27. /******/ }
  28. /******/
  29. /******/
  30. /******/ // expose the modules object (__webpack_modules__)
  31. /******/ __webpack_require__.m = modules;
  32. /******/
  33. /******/ // expose the module cache
  34. /******/ __webpack_require__.c = installedModules;
  35. /******/
  36. /******/ // define getter function for harmony exports
  37. /******/ __webpack_require__.d = function(exports, name, getter) {
  38. /******/ if(!__webpack_require__.o(exports, name)) {
  39. /******/ Object.defineProperty(exports, name, {
  40. /******/ configurable: false,
  41. /******/ enumerable: true,
  42. /******/ get: getter
  43. /******/ });
  44. /******/ }
  45. /******/ };
  46. /******/
  47. /******/ // getDefaultExport function for compatibility with non-harmony modules
  48. /******/ __webpack_require__.n = function(module) {
  49. /******/ var getter = module && module.__esModule ?
  50. /******/ function getDefault() { return module['default']; } :
  51. /******/ function getModuleExports() { return module; };
  52. /******/ __webpack_require__.d(getter, 'a', getter);
  53. /******/ return getter;
  54. /******/ };
  55. /******/
  56. /******/ // Object.prototype.hasOwnProperty.call
  57. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  58. /******/
  59. /******/ // __webpack_public_path__
  60. /******/ __webpack_require__.p = "";
  61. /******/
  62. /******/ // Load entry module and return exports
  63. /******/ return __webpack_require__(__webpack_require__.s = 1);
  64. /******/ })
  65. /************************************************************************/
  66. /******/ ([
  67. /* 0 */
  68. /***/ (function(module, exports, __webpack_require__) {
  69. (function (global, factory) {
  70. true ? module.exports = factory() :
  71. typeof define === 'function' && define.amd ? define(factory) :
  72. (global.Sprite = factory());
  73. }(this, (function () { 'use strict';
  74. var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
  75. function createCommonjsModule(fn, module) {
  76. return module = { exports: {} }, fn(module, module.exports), module.exports;
  77. }
  78. var deepmerge$1 = createCommonjsModule(function (module, exports) {
  79. (function (root, factory) {
  80. if (false) {
  81. undefined(factory);
  82. } else {
  83. module.exports = factory();
  84. }
  85. }(commonjsGlobal, function () {
  86. function isMergeableObject(val) {
  87. var nonNullObject = val && typeof val === 'object';
  88. return nonNullObject
  89. && Object.prototype.toString.call(val) !== '[object RegExp]'
  90. && Object.prototype.toString.call(val) !== '[object Date]'
  91. }
  92. function emptyTarget(val) {
  93. return Array.isArray(val) ? [] : {}
  94. }
  95. function cloneIfNecessary(value, optionsArgument) {
  96. var clone = optionsArgument && optionsArgument.clone === true;
  97. return (clone && isMergeableObject(value)) ? deepmerge(emptyTarget(value), value, optionsArgument) : value
  98. }
  99. function defaultArrayMerge(target, source, optionsArgument) {
  100. var destination = target.slice();
  101. source.forEach(function(e, i) {
  102. if (typeof destination[i] === 'undefined') {
  103. destination[i] = cloneIfNecessary(e, optionsArgument);
  104. } else if (isMergeableObject(e)) {
  105. destination[i] = deepmerge(target[i], e, optionsArgument);
  106. } else if (target.indexOf(e) === -1) {
  107. destination.push(cloneIfNecessary(e, optionsArgument));
  108. }
  109. });
  110. return destination
  111. }
  112. function mergeObject(target, source, optionsArgument) {
  113. var destination = {};
  114. if (isMergeableObject(target)) {
  115. Object.keys(target).forEach(function (key) {
  116. destination[key] = cloneIfNecessary(target[key], optionsArgument);
  117. });
  118. }
  119. Object.keys(source).forEach(function (key) {
  120. if (!isMergeableObject(source[key]) || !target[key]) {
  121. destination[key] = cloneIfNecessary(source[key], optionsArgument);
  122. } else {
  123. destination[key] = deepmerge(target[key], source[key], optionsArgument);
  124. }
  125. });
  126. return destination
  127. }
  128. function deepmerge(target, source, optionsArgument) {
  129. var array = Array.isArray(source);
  130. var options = optionsArgument || { arrayMerge: defaultArrayMerge };
  131. var arrayMerge = options.arrayMerge || defaultArrayMerge;
  132. if (array) {
  133. return Array.isArray(target) ? arrayMerge(target, source, optionsArgument) : cloneIfNecessary(source, optionsArgument)
  134. } else {
  135. return mergeObject(target, source, optionsArgument)
  136. }
  137. }
  138. deepmerge.all = function deepmergeAll(array, optionsArgument) {
  139. if (!Array.isArray(array) || array.length < 2) {
  140. throw new Error('first argument should be an array with at least two elements')
  141. }
  142. // we are sure there are at least 2 values, so it is safe to have no initial value
  143. return array.reduce(function(prev, next) {
  144. return deepmerge(prev, next, optionsArgument)
  145. })
  146. };
  147. return deepmerge
  148. }));
  149. });
  150. var namespaces_1 = createCommonjsModule(function (module, exports) {
  151. var namespaces = {
  152. svg: {
  153. name: 'xmlns',
  154. uri: 'http://www.w3.org/2000/svg'
  155. },
  156. xlink: {
  157. name: 'xmlns:xlink',
  158. uri: 'http://www.w3.org/1999/xlink'
  159. }
  160. };
  161. exports.default = namespaces;
  162. module.exports = exports.default;
  163. });
  164. /**
  165. * @param {Object} attrs
  166. * @return {string}
  167. */
  168. var objectToAttrsString = function (attrs) {
  169. return Object.keys(attrs).map(function (attr) {
  170. var value = attrs[attr].toString().replace(/"/g, '&quot;');
  171. return (attr + "=\"" + value + "\"");
  172. }).join(' ');
  173. };
  174. var svg = namespaces_1.svg;
  175. var xlink = namespaces_1.xlink;
  176. var defaultAttrs = {};
  177. defaultAttrs[svg.name] = svg.uri;
  178. defaultAttrs[xlink.name] = xlink.uri;
  179. /**
  180. * @param {string} [content]
  181. * @param {Object} [attributes]
  182. * @return {string}
  183. */
  184. var wrapInSvgString = function (content, attributes) {
  185. if ( content === void 0 ) content = '';
  186. var attrs = deepmerge$1(defaultAttrs, attributes || {});
  187. var attrsRendered = objectToAttrsString(attrs);
  188. return ("<svg " + attrsRendered + ">" + content + "</svg>");
  189. };
  190. var svg$1 = namespaces_1.svg;
  191. var xlink$1 = namespaces_1.xlink;
  192. var defaultConfig = {
  193. attrs: ( obj = {
  194. style: ['position: absolute', 'width: 0', 'height: 0'].join('; ')
  195. }, obj[svg$1.name] = svg$1.uri, obj[xlink$1.name] = xlink$1.uri, obj )
  196. };
  197. var obj;
  198. var Sprite = function Sprite(config) {
  199. this.config = deepmerge$1(defaultConfig, config || {});
  200. this.symbols = [];
  201. };
  202. /**
  203. * Add new symbol. If symbol with the same id exists it will be replaced.
  204. * @param {SpriteSymbol} symbol
  205. * @return {boolean} `true` - symbol was added, `false` - replaced
  206. */
  207. Sprite.prototype.add = function add (symbol) {
  208. var ref = this;
  209. var symbols = ref.symbols;
  210. var existing = this.find(symbol.id);
  211. if (existing) {
  212. symbols[symbols.indexOf(existing)] = symbol;
  213. return false;
  214. }
  215. symbols.push(symbol);
  216. return true;
  217. };
  218. /**
  219. * Remove symbol & destroy it
  220. * @param {string} id
  221. * @return {boolean} `true` - symbol was found & successfully destroyed, `false` - otherwise
  222. */
  223. Sprite.prototype.remove = function remove (id) {
  224. var ref = this;
  225. var symbols = ref.symbols;
  226. var symbol = this.find(id);
  227. if (symbol) {
  228. symbols.splice(symbols.indexOf(symbol), 1);
  229. symbol.destroy();
  230. return true;
  231. }
  232. return false;
  233. };
  234. /**
  235. * @param {string} id
  236. * @return {SpriteSymbol|null}
  237. */
  238. Sprite.prototype.find = function find (id) {
  239. return this.symbols.filter(function (s) { return s.id === id; })[0] || null;
  240. };
  241. /**
  242. * @param {string} id
  243. * @return {boolean}
  244. */
  245. Sprite.prototype.has = function has (id) {
  246. return this.find(id) !== null;
  247. };
  248. /**
  249. * @return {string}
  250. */
  251. Sprite.prototype.stringify = function stringify () {
  252. var ref = this.config;
  253. var attrs = ref.attrs;
  254. var stringifiedSymbols = this.symbols.map(function (s) { return s.stringify(); }).join('');
  255. return wrapInSvgString(stringifiedSymbols, attrs);
  256. };
  257. /**
  258. * @return {string}
  259. */
  260. Sprite.prototype.toString = function toString () {
  261. return this.stringify();
  262. };
  263. Sprite.prototype.destroy = function destroy () {
  264. this.symbols.forEach(function (s) { return s.destroy(); });
  265. };
  266. var sprite = new Sprite({ attrs: { id: '__SVG_SPRITE_NODE__' } });
  267. return sprite;
  268. })));
  269. /***/ }),
  270. /* 1 */
  271. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  272. "use strict";
  273. Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
  274. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__assets_twitter_svg__ = __webpack_require__(2);
  275. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_svg_sprite_loader_runtime_sprite_build__ = __webpack_require__(0);
  276. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_svg_sprite_loader_runtime_sprite_build___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_svg_sprite_loader_runtime_sprite_build__);
  277. // Import sprite instance which already contains twitter logo required above
  278. // Render sprite
  279. const spriteContent = __WEBPACK_IMPORTED_MODULE_1_svg_sprite_loader_runtime_sprite_build___default.a.stringify();
  280. const pageContent = `
  281. <!DOCTYPE html>
  282. <html lang="en">
  283. <head>
  284. <meta charset="UTF-8">
  285. </head>
  286. <body>
  287. ${spriteContent}
  288. <svg viewBox="${__WEBPACK_IMPORTED_MODULE_0__assets_twitter_svg__["a" /* default */].viewBox}">
  289. <use xlink:href="#${__WEBPACK_IMPORTED_MODULE_0__assets_twitter_svg__["a" /* default */].id}"></use>
  290. </svg>
  291. </body>
  292. </html>
  293. `;
  294. console.log(pageContent);
  295. /***/ }),
  296. /* 2 */
  297. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  298. "use strict";
  299. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__node_modules_svg_baker_runtime_symbol_js__ = __webpack_require__(3);
  300. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__node_modules_svg_baker_runtime_symbol_js___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0__node_modules_svg_baker_runtime_symbol_js__);
  301. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__runtime_sprite_build_js__ = __webpack_require__(0);
  302. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__runtime_sprite_build_js___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1__runtime_sprite_build_js__);
  303. var symbol = new __WEBPACK_IMPORTED_MODULE_0__node_modules_svg_baker_runtime_symbol_js___default.a({
  304. "id": "twitter",
  305. "use": "twitter-usage",
  306. "viewBox": "0 0 273.4 222.2",
  307. "content": "<symbol xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" viewBox=\"0 0 273.4 222.2\" id=\"twitter\">\n<path d=\"M273.4,26.3c-10.1,4.5-20.9,7.5-32.2,8.8c11.6-6.9,20.5-17.9,24.7-31C255,10.5,243,15.2,230.2,17.7\n\tC220,6.8,205.4,0,189.3,0c-31,0-56.1,25.1-56.1,56.1c0,4.4,0.5,8.7,1.5,12.8C88,66.5,46.7,44.2,19,10.3c-4.8,8.3-7.6,17.9-7.6,28.2\n\tc0,19.5,9.9,36.6,25,46.7c-9.2-0.3-17.8-2.8-25.4-7c0,0.2,0,0.5,0,0.7c0,27.2,19.3,49.8,45,55c-4.7,1.3-9.7,2-14.8,2\n\tc-3.6,0-7.1-0.4-10.6-1c7.1,22.3,27.9,38.5,52.4,39c-19.2,15-43.4,24-69.7,24c-4.5,0-9-0.3-13.4-0.8c24.8,15.9,54.3,25.2,86,25.2\n\tc103.2,0,159.6-85.5,159.6-159.6c0-2.4-0.1-4.9-0.2-7.3C256.4,47.4,265.9,37.5,273.4,26.3z\" />\n</symbol>"
  308. });
  309. var result = __WEBPACK_IMPORTED_MODULE_1__runtime_sprite_build_js___default.a.add(symbol);
  310. /* harmony default export */ __webpack_exports__["a"] = (symbol);
  311. /***/ }),
  312. /* 3 */
  313. /***/ (function(module, exports, __webpack_require__) {
  314. (function (global, factory) {
  315. true ? module.exports = factory() :
  316. typeof define === 'function' && define.amd ? define(factory) :
  317. (global.SpriteSymbol = factory());
  318. }(this, (function () { 'use strict';
  319. var SpriteSymbol = function SpriteSymbol(ref) {
  320. var id = ref.id;
  321. var viewBox = ref.viewBox;
  322. var content = ref.content;
  323. this.id = id;
  324. this.viewBox = viewBox;
  325. this.content = content;
  326. };
  327. /**
  328. * @return {string}
  329. */
  330. SpriteSymbol.prototype.stringify = function stringify () {
  331. return this.content;
  332. };
  333. /**
  334. * @return {string}
  335. */
  336. SpriteSymbol.prototype.toString = function toString () {
  337. return this.stringify();
  338. };
  339. SpriteSymbol.prototype.destroy = function destroy () {
  340. var this$1 = this;
  341. ['id', 'viewBox', 'content'].forEach(function (prop) { return delete this$1[prop]; });
  342. };
  343. return SpriteSymbol;
  344. })));
  345. /***/ })
  346. /******/ ]);