123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417 |
- /******/ (function(modules) { // webpackBootstrap
- /******/ // The module cache
- /******/ var installedModules = {};
- /******/
- /******/ // 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] = {
- /******/ i: moduleId,
- /******/ l: false,
- /******/ exports: {}
- /******/ };
- /******/
- /******/ // Execute the module function
- /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
- /******/
- /******/ // Flag the module as loaded
- /******/ module.l = true;
- /******/
- /******/ // Return the exports of the module
- /******/ return module.exports;
- /******/ }
- /******/
- /******/
- /******/ // expose the modules object (__webpack_modules__)
- /******/ __webpack_require__.m = modules;
- /******/
- /******/ // expose the module cache
- /******/ __webpack_require__.c = installedModules;
- /******/
- /******/ // define getter function for harmony exports
- /******/ __webpack_require__.d = function(exports, name, getter) {
- /******/ if(!__webpack_require__.o(exports, name)) {
- /******/ Object.defineProperty(exports, name, {
- /******/ configurable: false,
- /******/ enumerable: true,
- /******/ get: getter
- /******/ });
- /******/ }
- /******/ };
- /******/
- /******/ // getDefaultExport function for compatibility with non-harmony modules
- /******/ __webpack_require__.n = function(module) {
- /******/ var getter = module && module.__esModule ?
- /******/ function getDefault() { return module['default']; } :
- /******/ function getModuleExports() { return module; };
- /******/ __webpack_require__.d(getter, 'a', getter);
- /******/ return getter;
- /******/ };
- /******/
- /******/ // Object.prototype.hasOwnProperty.call
- /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
- /******/
- /******/ // __webpack_public_path__
- /******/ __webpack_require__.p = "";
- /******/
- /******/ // Load entry module and return exports
- /******/ return __webpack_require__(__webpack_require__.s = 1);
- /******/ })
- /************************************************************************/
- /******/ ([
- /* 0 */
- /***/ (function(module, exports, __webpack_require__) {
- (function (global, factory) {
- true ? module.exports = factory() :
- typeof define === 'function' && define.amd ? define(factory) :
- (global.Sprite = factory());
- }(this, (function () { 'use strict';
- var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
- function createCommonjsModule(fn, module) {
- return module = { exports: {} }, fn(module, module.exports), module.exports;
- }
- var deepmerge$1 = createCommonjsModule(function (module, exports) {
- (function (root, factory) {
- if (false) {
- undefined(factory);
- } else {
- module.exports = factory();
- }
- }(commonjsGlobal, function () {
- function isMergeableObject(val) {
- var nonNullObject = val && typeof val === 'object';
- return nonNullObject
- && Object.prototype.toString.call(val) !== '[object RegExp]'
- && Object.prototype.toString.call(val) !== '[object Date]'
- }
- function emptyTarget(val) {
- return Array.isArray(val) ? [] : {}
- }
- function cloneIfNecessary(value, optionsArgument) {
- var clone = optionsArgument && optionsArgument.clone === true;
- return (clone && isMergeableObject(value)) ? deepmerge(emptyTarget(value), value, optionsArgument) : value
- }
- function defaultArrayMerge(target, source, optionsArgument) {
- var destination = target.slice();
- source.forEach(function(e, i) {
- if (typeof destination[i] === 'undefined') {
- destination[i] = cloneIfNecessary(e, optionsArgument);
- } else if (isMergeableObject(e)) {
- destination[i] = deepmerge(target[i], e, optionsArgument);
- } else if (target.indexOf(e) === -1) {
- destination.push(cloneIfNecessary(e, optionsArgument));
- }
- });
- return destination
- }
- function mergeObject(target, source, optionsArgument) {
- var destination = {};
- if (isMergeableObject(target)) {
- Object.keys(target).forEach(function (key) {
- destination[key] = cloneIfNecessary(target[key], optionsArgument);
- });
- }
- Object.keys(source).forEach(function (key) {
- if (!isMergeableObject(source[key]) || !target[key]) {
- destination[key] = cloneIfNecessary(source[key], optionsArgument);
- } else {
- destination[key] = deepmerge(target[key], source[key], optionsArgument);
- }
- });
- return destination
- }
- function deepmerge(target, source, optionsArgument) {
- var array = Array.isArray(source);
- var options = optionsArgument || { arrayMerge: defaultArrayMerge };
- var arrayMerge = options.arrayMerge || defaultArrayMerge;
- if (array) {
- return Array.isArray(target) ? arrayMerge(target, source, optionsArgument) : cloneIfNecessary(source, optionsArgument)
- } else {
- return mergeObject(target, source, optionsArgument)
- }
- }
- deepmerge.all = function deepmergeAll(array, optionsArgument) {
- if (!Array.isArray(array) || array.length < 2) {
- throw new Error('first argument should be an array with at least two elements')
- }
- // we are sure there are at least 2 values, so it is safe to have no initial value
- return array.reduce(function(prev, next) {
- return deepmerge(prev, next, optionsArgument)
- })
- };
- return deepmerge
- }));
- });
- var namespaces_1 = createCommonjsModule(function (module, exports) {
- var namespaces = {
- svg: {
- name: 'xmlns',
- uri: 'http://www.w3.org/2000/svg'
- },
- xlink: {
- name: 'xmlns:xlink',
- uri: 'http://www.w3.org/1999/xlink'
- }
- };
- exports.default = namespaces;
- module.exports = exports.default;
- });
- /**
- * @param {Object} attrs
- * @return {string}
- */
- var objectToAttrsString = function (attrs) {
- return Object.keys(attrs).map(function (attr) {
- var value = attrs[attr].toString().replace(/"/g, '"');
- return (attr + "=\"" + value + "\"");
- }).join(' ');
- };
- var svg = namespaces_1.svg;
- var xlink = namespaces_1.xlink;
- var defaultAttrs = {};
- defaultAttrs[svg.name] = svg.uri;
- defaultAttrs[xlink.name] = xlink.uri;
- /**
- * @param {string} [content]
- * @param {Object} [attributes]
- * @return {string}
- */
- var wrapInSvgString = function (content, attributes) {
- if ( content === void 0 ) content = '';
- var attrs = deepmerge$1(defaultAttrs, attributes || {});
- var attrsRendered = objectToAttrsString(attrs);
- return ("<svg " + attrsRendered + ">" + content + "</svg>");
- };
- var svg$1 = namespaces_1.svg;
- var xlink$1 = namespaces_1.xlink;
- var defaultConfig = {
- attrs: ( obj = {
- style: ['position: absolute', 'width: 0', 'height: 0'].join('; ')
- }, obj[svg$1.name] = svg$1.uri, obj[xlink$1.name] = xlink$1.uri, obj )
- };
- var obj;
- var Sprite = function Sprite(config) {
- this.config = deepmerge$1(defaultConfig, config || {});
- this.symbols = [];
- };
- /**
- * Add new symbol. If symbol with the same id exists it will be replaced.
- * @param {SpriteSymbol} symbol
- * @return {boolean} `true` - symbol was added, `false` - replaced
- */
- Sprite.prototype.add = function add (symbol) {
- var ref = this;
- var symbols = ref.symbols;
- var existing = this.find(symbol.id);
- if (existing) {
- symbols[symbols.indexOf(existing)] = symbol;
- return false;
- }
- symbols.push(symbol);
- return true;
- };
- /**
- * Remove symbol & destroy it
- * @param {string} id
- * @return {boolean} `true` - symbol was found & successfully destroyed, `false` - otherwise
- */
- Sprite.prototype.remove = function remove (id) {
- var ref = this;
- var symbols = ref.symbols;
- var symbol = this.find(id);
- if (symbol) {
- symbols.splice(symbols.indexOf(symbol), 1);
- symbol.destroy();
- return true;
- }
- return false;
- };
- /**
- * @param {string} id
- * @return {SpriteSymbol|null}
- */
- Sprite.prototype.find = function find (id) {
- return this.symbols.filter(function (s) { return s.id === id; })[0] || null;
- };
- /**
- * @param {string} id
- * @return {boolean}
- */
- Sprite.prototype.has = function has (id) {
- return this.find(id) !== null;
- };
- /**
- * @return {string}
- */
- Sprite.prototype.stringify = function stringify () {
- var ref = this.config;
- var attrs = ref.attrs;
- var stringifiedSymbols = this.symbols.map(function (s) { return s.stringify(); }).join('');
- return wrapInSvgString(stringifiedSymbols, attrs);
- };
- /**
- * @return {string}
- */
- Sprite.prototype.toString = function toString () {
- return this.stringify();
- };
- Sprite.prototype.destroy = function destroy () {
- this.symbols.forEach(function (s) { return s.destroy(); });
- };
- var sprite = new Sprite({ attrs: { id: '__SVG_SPRITE_NODE__' } });
- return sprite;
- })));
- /***/ }),
- /* 1 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__assets_twitter_svg__ = __webpack_require__(2);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_svg_sprite_loader_runtime_sprite_build__ = __webpack_require__(0);
- /* 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__);
- // Import sprite instance which already contains twitter logo required above
- // Render sprite
- const spriteContent = __WEBPACK_IMPORTED_MODULE_1_svg_sprite_loader_runtime_sprite_build___default.a.stringify();
- const pageContent = `
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- </head>
- <body>
- ${spriteContent}
- <svg viewBox="${__WEBPACK_IMPORTED_MODULE_0__assets_twitter_svg__["a" /* default */].viewBox}">
- <use xlink:href="#${__WEBPACK_IMPORTED_MODULE_0__assets_twitter_svg__["a" /* default */].id}"></use>
- </svg>
- </body>
- </html>
- `;
- console.log(pageContent);
- /***/ }),
- /* 2 */
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__node_modules_svg_baker_runtime_symbol_js__ = __webpack_require__(3);
- /* 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__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__runtime_sprite_build_js__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__runtime_sprite_build_js___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1__runtime_sprite_build_js__);
- var symbol = new __WEBPACK_IMPORTED_MODULE_0__node_modules_svg_baker_runtime_symbol_js___default.a({
- "id": "twitter",
- "use": "twitter-usage",
- "viewBox": "0 0 273.4 222.2",
- "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>"
- });
- var result = __WEBPACK_IMPORTED_MODULE_1__runtime_sprite_build_js___default.a.add(symbol);
- /* harmony default export */ __webpack_exports__["a"] = (symbol);
- /***/ }),
- /* 3 */
- /***/ (function(module, exports, __webpack_require__) {
- (function (global, factory) {
- true ? module.exports = factory() :
- typeof define === 'function' && define.amd ? define(factory) :
- (global.SpriteSymbol = factory());
- }(this, (function () { 'use strict';
- var SpriteSymbol = function SpriteSymbol(ref) {
- var id = ref.id;
- var viewBox = ref.viewBox;
- var content = ref.content;
- this.id = id;
- this.viewBox = viewBox;
- this.content = content;
- };
- /**
- * @return {string}
- */
- SpriteSymbol.prototype.stringify = function stringify () {
- return this.content;
- };
- /**
- * @return {string}
- */
- SpriteSymbol.prototype.toString = function toString () {
- return this.stringify();
- };
- SpriteSymbol.prototype.destroy = function destroy () {
- var this$1 = this;
- ['id', 'viewBox', 'content'].forEach(function (prop) { return delete this$1[prop]; });
- };
- return SpriteSymbol;
- })));
- /***/ })
- /******/ ]);
|