diff --git a/node_modules/weapp-svg-icon/miniprogram_dist/index.js b/node_modules/weapp-svg-icon/miniprogram_dist/index.js index 46b3237..5caf8d1 100644 --- a/node_modules/weapp-svg-icon/miniprogram_dist/index.js +++ b/node_modules/weapp-svg-icon/miniprogram_dist/index.js @@ -1,338 +1,115 @@ -module.exports = -/******/ (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, { enumerable: true, get: getter }); -/******/ } -/******/ }; -/******/ -/******/ // define __esModule on exports -/******/ __webpack_require__.r = function(exports) { -/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { -/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); -/******/ } -/******/ Object.defineProperty(exports, '__esModule', { value: true }); -/******/ }; -/******/ -/******/ // create a fake namespace object -/******/ // mode & 1: value is a module id, require it -/******/ // mode & 2: merge all properties of value into the ns -/******/ // mode & 4: return value when already ns object -/******/ // mode & 8|1: behave like require -/******/ __webpack_require__.t = function(value, mode) { -/******/ if(mode & 1) value = __webpack_require__(value); -/******/ if(mode & 8) return value; -/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; -/******/ var ns = Object.create(null); -/******/ __webpack_require__.r(ns); -/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); -/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); -/******/ return ns; -/******/ }; -/******/ -/******/ // 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 = 0); -/******/ }) -/************************************************************************/ -/******/ ([ -/* 0 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -var _svgIcon = __webpack_require__(1); - -Component({ - /** - * 组件的属性列表 - */ - properties: { - name: { - type: String, - value: '' - }, - color: { - type: String, - value: '' - }, - size: { - type: String - } - }, - /** - * 组件的初始数据 - */ - data: { - width: '1em', - height: '1em', - iconUrl: '', - class: '' - }, - lifetimes: { - attached: function attached() { - this.getDataUri(this.data.name, this.data.color); - if (this.data.size) { - this.setData({ - width: this.data.size, - height: this.data.size - }); - } - } - }, - /** - * 组件的方法列表 - */ - methods: { - getDataUri: function getDataUri(name, color) { - var that = this; - var url = (0, _svgIcon.getLocalSVG)(name); - if (url) { - this.setData({ - iconUrl: url, - class: color ? 'icon' : 'default-icon' - }); - } else { - (0, _svgIcon.getIconifySVG)(name).then(function (res) { - that.setData({ - iconUrl: res, - class: color ? 'icon' : 'default-icon' - }); - }).catch(function (e) { - console.log(e); - }); - } - } - } -}); // components/svg-icon/index.js -// svg-icon - -/***/ }), -/* 1 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -exports.__esModule = true; -exports.getLocalSVG = getLocalSVG; -exports.getIconifySVG = getIconifySVG; -exports.iconifySetup = iconifySetup; - -var _mdiLight = __webpack_require__(2); - -var _mdiLight2 = _interopRequireDefault(_mdiLight); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var ICONIFY_API = ''; // https://github.com/LarchLiu/weapp-svg-icon/blob/main/miniprogram/utils/svgIcon.ts -// svg-icon - -var iconifyPresets = { - MdiLight: _mdiLight2.default -}; -var customerSvg = { - EmojioneMonotoneMotorcycle: '', - EmojioneMonotoneSportsMedal: '' -}; -var iconifyPreload = ['carbon:portfolio']; -function svgNameSwtich(id) { - return id.split(/:|-|_/).filter(Boolean).map(function (s) { - return s[0].toUpperCase() + s.slice(1).toLowerCase(); - }).join(''); +// Generated by scripts/generate-svg-icons.mjs — DO NOT EDIT. +// Minimal iconify data extracted from @iconify-json/ph + @iconify-json/solar. +var iconifyPresets = {"Ph":{"prefix":"ph","width":256,"height":256,"icons":{"arrow-right":{"body":""},"arrow-right-bold":{"body":""},"bank-duotone":{"body":""},"bank-fill":{"body":""},"bell-ringing-duotone":{"body":""},"boat-duotone":{"body":""},"boat-fill":{"body":""},"books-duotone":{"body":""},"bowl-food-fill":{"body":""},"broom-duotone":{"body":""},"building-duotone":{"body":""},"buildings-duotone":{"body":""},"buildings-fill":{"body":""},"calendar-heart-duotone":{"body":""},"camera-duotone":{"body":""},"caret-left-bold":{"body":""},"caret-right-bold":{"body":""},"chat-circle-dots-duotone":{"body":""},"clipboard-text-duotone":{"body":""},"columns-duotone":{"body":""},"compass-duotone":{"body":""},"compass-fill":{"body":""},"flower-lotus-duotone":{"body":""},"frame-corners-duotone":{"body":""},"hand-heart-duotone":{"body":""},"hand-heart-fill":{"body":""},"headset-duotone":{"body":""},"heart-duotone":{"body":""},"heart-fill":{"body":""},"house-duotone":{"body":""},"house-fill":{"body":""},"house-line-duotone":{"body":""},"info-duotone":{"body":""},"leaf-fill":{"body":""},"lightbulb-duotone":{"body":""},"lighthouse-duotone":{"body":""},"magnifying-glass":{"body":""},"magnifying-glass-duotone":{"body":""},"map-pin-area-duotone":{"body":""},"map-pin-line":{"body":""},"map-pin-line-duotone":{"body":""},"map-trifold-duotone":{"body":""},"map-trifold-fill":{"body":""},"mask-happy-duotone":{"body":""},"megaphone-duotone":{"body":""},"microphone-stage-duotone":{"body":""},"music-notes-duotone":{"body":""},"navigation-arrow":{"body":""},"newspaper-clipping-duotone":{"body":""},"paint-brush-broad-duotone":{"body":""},"pen-nib-duotone":{"body":""},"pencil-simple-duotone":{"body":""},"person-simple-tai-chi-duotone":{"body":""},"plant-duotone":{"body":""},"puzzle-piece-duotone":{"body":""},"scissors-duotone":{"body":""},"scroll-duotone":{"body":""},"shield-check-duotone":{"body":""},"sliders-horizontal-bold":{"body":""},"smiley-duotone":{"body":""},"star-duotone":{"body":""},"storefront-duotone":{"body":""},"student-duotone":{"body":""},"ticket-duotone":{"body":""},"trophy-duotone":{"body":""},"user-circle-duotone":{"body":""},"user-circle-fill":{"body":""},"user-focus-duotone":{"body":""},"user-plus-duotone":{"body":""},"users-three-duotone":{"body":""},"waves-duotone":{"body":""}}},"Solar":{"prefix":"solar","width":24,"height":24,"icons":{"alt-arrow-left-linear":{"body":""},"alt-arrow-right-linear":{"body":""},"bookmark-bold":{"body":""},"bookmark-linear":{"body":""},"map-point-linear":{"body":""},"share-linear":{"body":""}}}} + +function svgNameSwitch(id) { + return id + .split(/:|-|_/) + .filter(Boolean) + .map(function (s) { + return s[0].toUpperCase() + s.slice(1).toLowerCase() + }) + .join('') } + function encodeSvg(svg) { - return svg.replace('/g, '%3E'); + return svg + .replace('/g, '%3E') } + function getDataUri(data) { - return 'url("data:image/svg+xml;utf8,' + data + '")'; + return 'url("data:image/svg+xml;utf8,' + data + '")' } + function presetsIconify(id) { - var parts = id.split(':'); - var prefix = ''; - var icon = ''; - if (parts.length === 2) { - // prefix:icon.svg - prefix = svgNameSwtich(parts[0]); - icon = parts[1]; - } - if (parts.length === 1) { - parts = parts[0].split('-'); - if (parts.length > 1) { - // prefix-icon.svg - prefix = svgNameSwtich(parts.shift()); - icon = parts.join('-'); - } + var parts = id.split(':') + var prefix = '' + var icon = '' + if (parts.length === 2) { + prefix = svgNameSwitch(parts[0]) + icon = parts[1] + } else if (parts.length === 1) { + parts = parts[0].split('-') + if (parts.length > 1) { + prefix = svgNameSwitch(parts.shift()) + icon = parts.join('-') } - var setData = iconifyPresets[prefix] ? iconifyPresets[prefix].icons : null; - var width = setData && setData.width ? setData.width : 32; - var height = setData && setData.height ? setData.height : 32; - var iconData = setData && setData.icons && setData.icons[icon] ? setData.icons[icon] : null; - if (!iconData) { - return ''; - } - var renderData = { - attributes: { - width: '1em', - height: '1em', - preserveAspectRatio: 'xMidYMid meet', - viewBox: '0 0 ' + width + ' ' + height - }, - body: iconData.body - }; - var svgAttributes = Object.assign({ xmlns: 'http://www.w3.org/2000/svg', 'xmlns:xlink': 'http://www.w3.org/1999/xlink' }, renderData.attributes); - var svgAttributesStr = Object.keys(svgAttributes).map(function (attr) { - return attr + '="' + svgAttributes[attr] + '"'; - }).join(' '); - // Generate SVG - return '' + renderData.body + ''; + } + var setData = iconifyPresets[prefix] || null + var width = setData && setData.width ? setData.width : 32 + var height = setData && setData.height ? setData.height : 32 + var iconData = setData && setData.icons && setData.icons[icon] ? setData.icons[icon] : null + if (!iconData) { + return '' + } + var svgAttributes = { + xmlns: 'http://www.w3.org/2000/svg', + 'xmlns:xlink': 'http://www.w3.org/1999/xlink', + width: '1em', + height: '1em', + preserveAspectRatio: 'xMidYMid meet', + viewBox: '0 0 ' + width + ' ' + height + } + var svgAttributesStr = Object.keys(svgAttributes) + .map(function (attr) { + return attr + '="' + svgAttributes[attr] + '"' + }) + .join(' ') + return '' + iconData.body + '' } + function getLocalSVG(id) { - var name = svgNameSwtich(id); - var data = customerSvg[name]; - if (data) { - return getDataUri(encodeSvg(data)); - } else { - data = presetsIconify(id); - if (data) { - return getDataUri(encodeSvg(data)); - } else { - data = wx.getStorageSync(name); - if (data) { - return getDataUri(data); - } - return ''; - } - } -} -function iconifyApi(id) { - return new Promise(function (resolve, reject) { - if (ICONIFY_API) { - wx.request({ - url: ICONIFY_API + '/' + id + '.svg', - success: function success(res) { - if (res.statusCode === 200) resolve(res.data);else reject(res.errMsg); - }, - fail: function fail(err) { - reject(err); - } - }); - } else { - reject('no ICONIFY_API'); - } - }); + var name = svgNameSwitch(id) + var data = presetsIconify(id) + if (data) { + return getDataUri(encodeSvg(data)) + } + data = wx.getStorageSync(name) + if (data) { + return getDataUri(data) + } + return '' } -function getIconifySVG(id) { - return new Promise(function (resolve, reject) { - var name = svgNameSwtich(id); - iconifyApi(id).then(function (r) { - var data = encodeSvg(r); - wx.setStorage({ - key: name, - data: data, - success: function success(_) { - resolve(getDataUri(data)); - }, - fail: function fail(err) { - reject(err); - } - }); - }).catch(function (e) { - reject(e); - }); - }); -} -function iconifySetup(api) { - if (api) { - ICONIFY_API = api; - for (var _iterator = iconifyPreload, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) { - var _ref; - - if (_isArray) { - if (_i >= _iterator.length) break; - _ref = _iterator[_i++]; - } else { - _i = _iterator.next(); - if (_i.done) break; - _ref = _i.value; - } - var id = _ref; - - var name = svgNameSwtich(id); - console.log(name); - var data = wx.getStorageSync(name); - if (!data) { - getIconifySVG(id).catch(function (e) { - console.error(e); - }); - } - } +Component({ + properties: { + name: { + type: String, + value: '' + }, + color: { + type: String, + value: '' + }, + size: { + type: String } -} -exports.default = { - getLocalSVG: getLocalSVG, - getIconifySVG: getIconifySVG, - iconifySetup: iconifySetup -}; - -/***/ }), -/* 2 */ -/***/ (function(module, exports) { - -module.exports = require("@iconify-json/mdi-light"); - -/***/ }) -/******/ ]); -//# sourceMappingURL=index.js.map \ No newline at end of file + }, + data: { + width: '1em', + height: '1em', + iconUrl: '', + class: '' + }, + lifetimes: { + attached: function attached() { + this.setData({ + iconUrl: getLocalSVG(this.data.name), + class: this.data.color ? 'icon' : 'default-icon' + }) + if (this.data.size) { + this.setData({ + width: this.data.size, + height: this.data.size + }) + } + } + } +}) diff --git a/node_modules/weapp-svg-icon/miniprogram_dist/index.js.map b/node_modules/weapp-svg-icon/miniprogram_dist/index.js.map deleted file mode 100644 index efc117b..0000000 --- a/node_modules/weapp-svg-icon/miniprogram_dist/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./src/index.ts","webpack:///./src/svgIcon.ts","webpack:///external \"@iconify-json/mdi-light\""],"names":[],"mappings":";;QAAA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,iCAAiC;QAC1E,gHAAgH,mBAAmB,EAAE;QACrI;QACA;;QAEA;QACA;QACA;QACA,2BAA2B,0BAA0B,EAAE;QACvD,iCAAiC,eAAe;QAChD;QACA;QACA;;QAEA;QACA,sDAAsD,+DAA+D;;QAErH;QACA;;;QAGA;QACA;;;;;;;;;;AChFA;;AAEA,UAAU;AACR;;;AAGA,gBAAY;AACV,cAAM;AACJ,kBAAM,MADF;AAEJ,mBAAO;AAFH,SADI;AAKV,eAAO;AACL,kBAAM,MADD;AAEL,mBAAO;AAFF,SALG;AASV,cAAM;AACJ,kBAAM;AADF;AATI,KAJJ;AAkBR;;;AAGA,UAAM;AACJ,eAAO,KADH;AAEJ,gBAAQ,KAF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gBAAM,OAAO,GAAG,cAAH,CAAkB,IAAlB,CAAb;AACA,gBAAI,CAAC,IAAL,EAAW;AACT,8BAAc,EAAd,EAAkB,KAAlB,CAAwB,aAAI;AAC1B,4BAAQ,KAAR,CAAc,CAAd;AACD,iBAFD;AAGD;AACF;AACF;AACF;kBAEc;AACb,4BADa;AAEb,gCAFa;AAGb;AAHa,C;;;;;;AC3Kf,oD","file":"index.js","sourcesContent":[" \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 \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\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.l = 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// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n","// components/svg-icon/index.js\n// svg-icon\nimport {getIconifySVG, getLocalSVG} from './svgIcon.ts'\n\nComponent({\n /**\n * 组件的属性列表\n */\n properties: {\n name: {\n type: String,\n value: ''\n },\n color: {\n type: String,\n value: ''\n },\n size: {\n type: String,\n },\n },\n\n /**\n * 组件的初始数据\n */\n data: {\n width: '1em',\n height: '1em',\n iconUrl: '',\n class: '',\n },\n\n lifetimes: {\n attached() {\n this.getDataUri(this.data.name, this.data.color)\n if (this.data.size) {\n this.setData({\n width: this.data.size,\n height: this.data.size,\n })\n }\n },\n },\n /**\n * 组件的方法列表\n */\n methods: {\n getDataUri(name: string, color: string) {\n const that = this\n const url = getLocalSVG(name)\n if (url) {\n this.setData({\n iconUrl: url,\n class: color ? 'icon' : 'default-icon',\n })\n } else {\n getIconifySVG(name).then(res => {\n that.setData({\n iconUrl: res,\n class: color ? 'icon' : 'default-icon',\n })\n }).catch(e => {\n console.log(e)\n })\n }\n },\n }\n})\n","// https://github.com/LarchLiu/weapp-svg-icon/blob/main/miniprogram/utils/svgIcon.ts\r\n\r\n// svg-icon\r\nimport MdiLight from '@iconify-json/mdi-light'\r\n\r\nimport type {\n IconifyJSON, IconifyInfo, IconifyMetaData, IconifyChars\n} from '@iconify/types'\r\n\r\nlet ICONIFY_API = ''\r\n\r\ninterface IconifyData {\r\n icons: IconifyJSON;\r\n info: IconifyInfo;\r\n metadata: IconifyMetaData;\r\n chars: IconifyChars;\r\n}\r\n\r\nconst iconifyPresets: Record = {\r\n MdiLight\r\n}\r\nconst customerSvg: Record = {\r\n EmojioneMonotoneMotorcycle: '',\r\n EmojioneMonotoneSportsMedal: '',\r\n}\r\nconst iconifyPreload: string[] = [\r\n 'carbon:portfolio',\r\n]\r\n\r\nfunction svgNameSwtich(id: string) {\r\n return id.split(/:|-|_/).filter(Boolean).map(s => s[0].toUpperCase() + s.slice(1).toLowerCase()).join('')\r\n}\r\n\r\nfunction encodeSvg(svg: string) {\r\n return svg.replace('/g, '%3E')\r\n}\r\n\r\nfunction getDataUri(data: string) {\r\n return `url(\"data:image/svg+xml;utf8,${data}\")`\r\n}\r\n\r\nfunction presetsIconify(id: string) {\r\n let parts = id.split(':')\r\n let prefix = ''\r\n let icon = ''\r\n if (parts.length === 2) {\r\n // prefix:icon.svg\r\n prefix = svgNameSwtich(parts[0])\r\n icon = parts[1]\r\n }\r\n if (parts.length === 1) {\r\n parts = parts[0].split('-')\r\n if (parts.length > 1) {\r\n // prefix-icon.svg\r\n prefix = svgNameSwtich(parts.shift() as string)\r\n icon = parts.join('-')\r\n }\r\n }\r\n const setData = iconifyPresets[prefix] ? iconifyPresets[prefix].icons : null\r\n const width = setData && setData.width ? setData.width : 32\r\n const height = setData && setData.height ? setData.height : 32\r\n const iconData = setData && setData.icons && setData.icons[icon] ? setData.icons[icon] : null\r\n if (!iconData) {\r\n return ''\r\n }\r\n const renderData = {\r\n attributes: {\r\n width: '1em',\r\n height: '1em',\r\n preserveAspectRatio: 'xMidYMid meet',\r\n viewBox: `0 0 ${width} ${height}`\r\n },\r\n body: iconData.body\r\n }\r\n const svgAttributes = {\r\n xmlns: 'http://www.w3.org/2000/svg',\r\n 'xmlns:xlink': 'http://www.w3.org/1999/xlink',\r\n ...renderData.attributes,\r\n }\r\n const svgAttributesStr = Object.keys(svgAttributes)\r\n .map(\r\n (attr) => `${attr}=\"${svgAttributes[attr as keyof typeof svgAttributes]}\"`\r\n )\r\n .join(' ')\r\n\r\n // Generate SVG\r\n return `${renderData.body}`\r\n}\r\n\r\nexport function getLocalSVG(id: string) {\r\n const name = svgNameSwtich(id)\r\n let data = customerSvg[name]\r\n if (data) {\r\n return getDataUri(encodeSvg(data))\r\n } else {\r\n data = presetsIconify(id)\r\n if (data) {\r\n return getDataUri(encodeSvg(data))\r\n } else {\r\n data = wx.getStorageSync(name)\r\n if (data) {\r\n return getDataUri(data)\r\n }\r\n return ''\r\n }\r\n }\r\n}\r\n\r\nfunction iconifyApi(id: string): Promise {\r\n return new Promise((resolve, reject) => {\r\n if (ICONIFY_API) {\r\n wx.request({\r\n url: `${ICONIFY_API}/${id}.svg`,\r\n success: (res) => {\r\n if (res.statusCode === 200) resolve(res.data as string)\r\n else reject(res.errMsg)\r\n },\r\n fail: (err) => {\r\n reject(err)\r\n }\r\n })\r\n } else {\r\n reject('no ICONIFY_API')\r\n }\r\n })\r\n}\r\n\r\nexport function getIconifySVG(id: string): Promise {\r\n return new Promise((resolve, reject) => {\r\n const name = svgNameSwtich(id)\r\n iconifyApi(id).then(r => {\r\n const data = encodeSvg(r)\r\n wx.setStorage({\r\n key: name,\r\n data,\r\n success(_) {\r\n resolve(getDataUri(data))\r\n },\r\n fail(err) {\r\n reject(err)\r\n }\r\n })\r\n }).catch(e => {\r\n reject(e)\r\n })\r\n })\r\n}\r\n\r\nexport function iconifySetup(api: string) {\r\n if (api) {\r\n ICONIFY_API = api\r\n for (const id of iconifyPreload) {\r\n const name = svgNameSwtich(id)\r\n console.log(name)\r\n const data = wx.getStorageSync(name)\r\n if (!data) {\r\n getIconifySVG(id).catch(e => {\r\n console.error(e)\r\n })\r\n }\r\n }\r\n }\r\n}\r\n\r\nexport default {\r\n getLocalSVG,\r\n getIconifySVG,\r\n iconifySetup\r\n}\n","module.exports = require(\"@iconify-json/mdi-light\");"],"sourceRoot":""} \ No newline at end of file