renovate-log-parser 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +402 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +30 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/analyze.d.ts +24 -0
- package/dist/commands/analyze.js +114 -0
- package/dist/commands/analyze.js.map +1 -0
- package/dist/commands/detect-errors.d.ts +17 -0
- package/dist/commands/detect-errors.js +119 -0
- package/dist/commands/detect-errors.js.map +1 -0
- package/dist/commands/install-analyze-skill.d.ts +27 -0
- package/dist/commands/install-analyze-skill.js +181 -0
- package/dist/commands/install-analyze-skill.js.map +1 -0
- package/dist/commands/web.d.ts +12 -0
- package/dist/commands/web.js +103 -0
- package/dist/commands/web.js.map +1 -0
- package/dist/core/analyzer.d.ts +89 -0
- package/dist/core/analyzer.js +179 -0
- package/dist/core/analyzer.js.map +1 -0
- package/dist/core/error-detector.d.ts +56 -0
- package/dist/core/error-detector.js +236 -0
- package/dist/core/error-detector.js.map +1 -0
- package/dist/core/filters.d.ts +136 -0
- package/dist/core/filters.js +95 -0
- package/dist/core/filters.js.map +1 -0
- package/dist/core/ignore-file.d.ts +52 -0
- package/dist/core/ignore-file.js +104 -0
- package/dist/core/ignore-file.js.map +1 -0
- package/dist/core/levels.d.ts +33 -0
- package/dist/core/levels.js +35 -0
- package/dist/core/levels.js.map +1 -0
- package/dist/core/parser.d.ts +57 -0
- package/dist/core/parser.js +201 -0
- package/dist/core/parser.js.map +1 -0
- package/dist/core/query-builder.d.ts +47 -0
- package/dist/core/query-builder.js +155 -0
- package/dist/core/query-builder.js.map +1 -0
- package/dist/core/skill-template.d.ts +34 -0
- package/dist/core/skill-template.js +259 -0
- package/dist/core/skill-template.js.map +1 -0
- package/package.json +68 -0
- package/web/.output/nitro.json +15 -0
- package/web/.output/public/_fonts/57NSSoFy1VLVs2gqly8Ls9awBnZMFyXGrefpmqvdqmc-zJfbBtpgM4cDmcXBsqZNW79_kFnlpPd62b48glgdydA.woff2 +0 -0
- package/web/.output/public/_fonts/8VR2wSMN-3U4NbWAVYXlkRV6hA0jFBXP-0RtL3X7fko-x2gYI4qfmkRdxyQQUPaBZdZdgl1TeVrquF_TxHeM4lM.woff2 +0 -0
- package/web/.output/public/_fonts/GsKUclqeNLJ96g5AU593ug6yanivOiwjW_7zESNPChw-jHA4tBeM1bjF7LATGUpfBuSTyomIFrWBTzjF7txVYfg.woff2 +0 -0
- package/web/.output/public/_fonts/Ld1FnTo3yTIwDyGfTQ5-Fws9AWsCbKfMvgxduXr7JcY-W25bL8NF1fjpLRSOgJb7RoZPHqGQNwMTM7S9tHVoxx8.woff2 +0 -0
- package/web/.output/public/_fonts/NdzqRASp2bovDUhQT1IRE_EMqKJ2KYQdTCfFcBvL8yw-KhwZiS86o3fErOe5GGMExHUemmI_dBfaEFxjISZrBd0.woff2 +0 -0
- package/web/.output/public/_fonts/iTkrULNFJJkTvihIg1Vqi5IODRH_9btXCioVF5l98I8-AndUyau2HR2felA_ra8V2mutQgschhasE5FD1dXGJX8.woff2 +0 -0
- package/web/.output/public/_nuxt/BWja8e3M.js +37 -0
- package/web/.output/public/_nuxt/BgApMHS1.js +1 -0
- package/web/.output/public/_nuxt/CGPWRqbc.js +1 -0
- package/web/.output/public/_nuxt/DlAUqK2U.js +1 -0
- package/web/.output/public/_nuxt/Sgtec1U0.js +1 -0
- package/web/.output/public/_nuxt/builds/latest.json +1 -0
- package/web/.output/public/_nuxt/builds/meta/c4723e49-0623-47af-ae79-9ab6428bdcc1.json +1 -0
- package/web/.output/public/_nuxt/entry.9mB-pyEY.css +1 -0
- package/web/.output/public/_nuxt/error-404.B_PvSG-P.css +1 -0
- package/web/.output/public/_nuxt/error-500.CghkKCEr.css +1 -0
- package/web/.output/public/_nuxt/index.BlvAG7F6.css +1 -0
- package/web/.output/public/favicon.ico +0 -0
- package/web/.output/server/chunks/_/error-500.mjs +19 -0
- package/web/.output/server/chunks/_/error-500.mjs.map +1 -0
- package/web/.output/server/chunks/_/icons.mjs +6153 -0
- package/web/.output/server/chunks/_/icons.mjs.map +1 -0
- package/web/.output/server/chunks/_/icons2.mjs +11494 -0
- package/web/.output/server/chunks/_/icons2.mjs.map +1 -0
- package/web/.output/server/chunks/build/_plugin-vue_export-helper-1tPrXgE0.mjs +10 -0
- package/web/.output/server/chunks/build/_plugin-vue_export-helper-1tPrXgE0.mjs.map +1 -0
- package/web/.output/server/chunks/build/client.precomputed.mjs +4 -0
- package/web/.output/server/chunks/build/client.precomputed.mjs.map +1 -0
- package/web/.output/server/chunks/build/error-404-DyaaQUIS.mjs +106 -0
- package/web/.output/server/chunks/build/error-404-DyaaQUIS.mjs.map +1 -0
- package/web/.output/server/chunks/build/error-404-styles.9cNA4arh.mjs +8 -0
- package/web/.output/server/chunks/build/error-404-styles.9cNA4arh.mjs.map +1 -0
- package/web/.output/server/chunks/build/error-500-CVSP-p02.mjs +89 -0
- package/web/.output/server/chunks/build/error-500-CVSP-p02.mjs.map +1 -0
- package/web/.output/server/chunks/build/error-500-styles.BX54ZlkH.mjs +8 -0
- package/web/.output/server/chunks/build/error-500-styles.BX54ZlkH.mjs.map +1 -0
- package/web/.output/server/chunks/build/index-88dXYOxO.mjs +19675 -0
- package/web/.output/server/chunks/build/index-88dXYOxO.mjs.map +1 -0
- package/web/.output/server/chunks/build/index-styles.V2iua2bE.mjs +8 -0
- package/web/.output/server/chunks/build/index-styles.V2iua2bE.mjs.map +1 -0
- package/web/.output/server/chunks/build/server.mjs +7910 -0
- package/web/.output/server/chunks/build/server.mjs.map +1 -0
- package/web/.output/server/chunks/build/styles.mjs +10 -0
- package/web/.output/server/chunks/build/styles.mjs.map +1 -0
- package/web/.output/server/chunks/nitro/nitro.mjs +6944 -0
- package/web/.output/server/chunks/nitro/nitro.mjs.map +1 -0
- package/web/.output/server/chunks/routes/api/fields.get.mjs +27 -0
- package/web/.output/server/chunks/routes/api/fields.get.mjs.map +1 -0
- package/web/.output/server/chunks/routes/api/findings.get.mjs +30 -0
- package/web/.output/server/chunks/routes/api/findings.get.mjs.map +1 -0
- package/web/.output/server/chunks/routes/api/log/contents.post.mjs +29 -0
- package/web/.output/server/chunks/routes/api/log/contents.post.mjs.map +1 -0
- package/web/.output/server/chunks/routes/api/log/path.post.mjs +30 -0
- package/web/.output/server/chunks/routes/api/log/path.post.mjs.map +1 -0
- package/web/.output/server/chunks/routes/api/repositories.get.mjs +27 -0
- package/web/.output/server/chunks/routes/api/repositories.get.mjs.map +1 -0
- package/web/.output/server/chunks/routes/api/rows.get.mjs +48 -0
- package/web/.output/server/chunks/routes/api/rows.get.mjs.map +1 -0
- package/web/.output/server/chunks/routes/renderer.mjs +451 -0
- package/web/.output/server/chunks/routes/renderer.mjs.map +1 -0
- package/web/.output/server/chunks/virtual/_virtual_spa-template.mjs +4 -0
- package/web/.output/server/chunks/virtual/_virtual_spa-template.mjs.map +1 -0
- package/web/.output/server/index.mjs +16 -0
- package/web/.output/server/index.mjs.map +1 -0
- package/web/.output/server/node_modules/.nitro/hookable@5.5.3/dist/index.mjs +290 -0
- package/web/.output/server/node_modules/.nitro/hookable@5.5.3/package.json +49 -0
- package/web/.output/server/node_modules/.nitro/hookable@6.1.1/dist/index.mjs +257 -0
- package/web/.output/server/node_modules/.nitro/hookable@6.1.1/package.json +53 -0
- package/web/.output/server/node_modules/@babel/parser/lib/index.js +14599 -0
- package/web/.output/server/node_modules/@babel/parser/package.json +50 -0
- package/web/.output/server/node_modules/@floating-ui/core/dist/floating-ui.core.mjs +1038 -0
- package/web/.output/server/node_modules/@floating-ui/core/package.json +63 -0
- package/web/.output/server/node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs +789 -0
- package/web/.output/server/node_modules/@floating-ui/dom/package.json +72 -0
- package/web/.output/server/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs +165 -0
- package/web/.output/server/node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs +136 -0
- package/web/.output/server/node_modules/@floating-ui/utils/package.json +70 -0
- package/web/.output/server/node_modules/@floating-ui/vue/dist/floating-ui.vue.mjs +190 -0
- package/web/.output/server/node_modules/@floating-ui/vue/package.json +71 -0
- package/web/.output/server/node_modules/@iconify/utils/lib/colors/index.js +295 -0
- package/web/.output/server/node_modules/@iconify/utils/lib/colors/keywords.js +701 -0
- package/web/.output/server/node_modules/@iconify/utils/lib/css/common.js +75 -0
- package/web/.output/server/node_modules/@iconify/utils/lib/css/format.js +39 -0
- package/web/.output/server/node_modules/@iconify/utils/lib/css/icon.js +47 -0
- package/web/.output/server/node_modules/@iconify/utils/lib/css/icons.js +128 -0
- package/web/.output/server/node_modules/@iconify/utils/lib/customisations/bool.js +19 -0
- package/web/.output/server/node_modules/@iconify/utils/lib/customisations/defaults.js +13 -0
- package/web/.output/server/node_modules/@iconify/utils/lib/customisations/flip.js +17 -0
- package/web/.output/server/node_modules/@iconify/utils/lib/customisations/merge.js +16 -0
- package/web/.output/server/node_modules/@iconify/utils/lib/customisations/rotate.js +30 -0
- package/web/.output/server/node_modules/@iconify/utils/lib/emoji/cleanup.js +78 -0
- package/web/.output/server/node_modules/@iconify/utils/lib/emoji/convert.js +100 -0
- package/web/.output/server/node_modules/@iconify/utils/lib/emoji/data.js +28 -0
- package/web/.output/server/node_modules/@iconify/utils/lib/emoji/format.js +58 -0
- package/web/.output/server/node_modules/@iconify/utils/lib/emoji/parse.js +48 -0
- package/web/.output/server/node_modules/@iconify/utils/lib/emoji/regex/base.js +203 -0
- package/web/.output/server/node_modules/@iconify/utils/lib/emoji/regex/create.js +33 -0
- package/web/.output/server/node_modules/@iconify/utils/lib/emoji/regex/numbers.js +132 -0
- package/web/.output/server/node_modules/@iconify/utils/lib/emoji/regex/similar.js +165 -0
- package/web/.output/server/node_modules/@iconify/utils/lib/emoji/regex/tree.js +79 -0
- package/web/.output/server/node_modules/@iconify/utils/lib/emoji/replace/find.js +92 -0
- package/web/.output/server/node_modules/@iconify/utils/lib/emoji/replace/replace.js +26 -0
- package/web/.output/server/node_modules/@iconify/utils/lib/emoji/test/components.js +76 -0
- package/web/.output/server/node_modules/@iconify/utils/lib/emoji/test/missing.js +66 -0
- package/web/.output/server/node_modules/@iconify/utils/lib/emoji/test/name.js +45 -0
- package/web/.output/server/node_modules/@iconify/utils/lib/emoji/test/parse.js +103 -0
- package/web/.output/server/node_modules/@iconify/utils/lib/emoji/test/similar.js +36 -0
- package/web/.output/server/node_modules/@iconify/utils/lib/emoji/test/tree.js +92 -0
- package/web/.output/server/node_modules/@iconify/utils/lib/emoji/test/variations.js +62 -0
- package/web/.output/server/node_modules/@iconify/utils/lib/icon/defaults.js +25 -0
- package/web/.output/server/node_modules/@iconify/utils/lib/icon/merge.js +16 -0
- package/web/.output/server/node_modules/@iconify/utils/lib/icon/name.js +57 -0
- package/web/.output/server/node_modules/@iconify/utils/lib/icon/square.js +33 -0
- package/web/.output/server/node_modules/@iconify/utils/lib/icon/transformations.js +12 -0
- package/web/.output/server/node_modules/@iconify/utils/lib/icon-set/convert-info.js +125 -0
- package/web/.output/server/node_modules/@iconify/utils/lib/icon-set/expand.js +19 -0
- package/web/.output/server/node_modules/@iconify/utils/lib/icon-set/get-icon.js +25 -0
- package/web/.output/server/node_modules/@iconify/utils/lib/icon-set/get-icons.js +36 -0
- package/web/.output/server/node_modules/@iconify/utils/lib/icon-set/minify.js +91 -0
- package/web/.output/server/node_modules/@iconify/utils/lib/icon-set/parse.js +46 -0
- package/web/.output/server/node_modules/@iconify/utils/lib/icon-set/tree.js +23 -0
- package/web/.output/server/node_modules/@iconify/utils/lib/icon-set/validate-basic.js +42 -0
- package/web/.output/server/node_modules/@iconify/utils/lib/icon-set/validate.js +123 -0
- package/web/.output/server/node_modules/@iconify/utils/lib/index.js +52 -0
- package/web/.output/server/node_modules/@iconify/utils/lib/loader/custom.js +30 -0
- package/web/.output/server/node_modules/@iconify/utils/lib/loader/loader.js +26 -0
- package/web/.output/server/node_modules/@iconify/utils/lib/loader/modern.js +27 -0
- package/web/.output/server/node_modules/@iconify/utils/lib/loader/utils.js +105 -0
- package/web/.output/server/node_modules/@iconify/utils/lib/misc/objects.js +26 -0
- package/web/.output/server/node_modules/@iconify/utils/lib/misc/strings.js +26 -0
- package/web/.output/server/node_modules/@iconify/utils/lib/misc/title.js +9 -0
- package/web/.output/server/node_modules/@iconify/utils/lib/svg/build.js +113 -0
- package/web/.output/server/node_modules/@iconify/utils/lib/svg/defs.js +31 -0
- package/web/.output/server/node_modules/@iconify/utils/lib/svg/encode-svg-for-css.js +13 -0
- package/web/.output/server/node_modules/@iconify/utils/lib/svg/html.js +9 -0
- package/web/.output/server/node_modules/@iconify/utils/lib/svg/id.js +41 -0
- package/web/.output/server/node_modules/@iconify/utils/lib/svg/inner-html.js +22 -0
- package/web/.output/server/node_modules/@iconify/utils/lib/svg/parse.js +67 -0
- package/web/.output/server/node_modules/@iconify/utils/lib/svg/pretty.js +54 -0
- package/web/.output/server/node_modules/@iconify/utils/lib/svg/size.js +27 -0
- package/web/.output/server/node_modules/@iconify/utils/lib/svg/trim.js +7 -0
- package/web/.output/server/node_modules/@iconify/utils/lib/svg/url.js +22 -0
- package/web/.output/server/node_modules/@iconify/utils/lib/svg/viewbox.js +8 -0
- package/web/.output/server/node_modules/@iconify/utils/package.json +119 -0
- package/web/.output/server/node_modules/@iconify/vue/dist/iconify.mjs +1896 -0
- package/web/.output/server/node_modules/@iconify/vue/package.json +62 -0
- package/web/.output/server/node_modules/@tanstack/virtual-core/dist/esm/index.js +1268 -0
- package/web/.output/server/node_modules/@tanstack/virtual-core/dist/esm/lazy-measurements.js +34 -0
- package/web/.output/server/node_modules/@tanstack/virtual-core/dist/esm/utils.js +74 -0
- package/web/.output/server/node_modules/@tanstack/virtual-core/package.json +56 -0
- package/web/.output/server/node_modules/@tanstack/vue-virtual/dist/esm/index.js +66 -0
- package/web/.output/server/node_modules/@tanstack/vue-virtual/package.json +68 -0
- package/web/.output/server/node_modules/@vue/compiler-core/dist/compiler-core.cjs.prod.js +6759 -0
- package/web/.output/server/node_modules/@vue/compiler-core/package.json +58 -0
- package/web/.output/server/node_modules/@vue/compiler-dom/dist/compiler-dom.cjs.prod.js +689 -0
- package/web/.output/server/node_modules/@vue/compiler-dom/package.json +57 -0
- package/web/.output/server/node_modules/@vue/compiler-ssr/dist/compiler-ssr.cjs.js +1413 -0
- package/web/.output/server/node_modules/@vue/compiler-ssr/package.json +34 -0
- package/web/.output/server/node_modules/@vue/devtools-api/dist/index.js +2 -0
- package/web/.output/server/node_modules/@vue/devtools-api/package.json +34 -0
- package/web/.output/server/node_modules/@vue/devtools-kit/dist/index.js +5670 -0
- package/web/.output/server/node_modules/@vue/devtools-kit/node_modules/hookable/dist/index.mjs +290 -0
- package/web/.output/server/node_modules/@vue/devtools-kit/node_modules/hookable/package.json +49 -0
- package/web/.output/server/node_modules/@vue/devtools-kit/package.json +44 -0
- package/web/.output/server/node_modules/@vue/devtools-shared/dist/index.js +239 -0
- package/web/.output/server/node_modules/@vue/devtools-shared/package.json +33 -0
- package/web/.output/server/node_modules/@vue/reactivity/dist/reactivity.cjs.prod.js +1899 -0
- package/web/.output/server/node_modules/@vue/reactivity/package.json +55 -0
- package/web/.output/server/node_modules/@vue/runtime-core/dist/runtime-core.cjs.prod.js +6940 -0
- package/web/.output/server/node_modules/@vue/runtime-core/package.json +52 -0
- package/web/.output/server/node_modules/@vue/runtime-dom/dist/runtime-dom.cjs.prod.js +1822 -0
- package/web/.output/server/node_modules/@vue/runtime-dom/package.json +60 -0
- package/web/.output/server/node_modules/@vue/server-renderer/dist/server-renderer.cjs.prod.js +896 -0
- package/web/.output/server/node_modules/@vue/server-renderer/package.json +55 -0
- package/web/.output/server/node_modules/@vue/shared/dist/shared.cjs.prod.js +604 -0
- package/web/.output/server/node_modules/@vue/shared/package.json +47 -0
- package/web/.output/server/node_modules/@vueuse/core/dist/index.js +8464 -0
- package/web/.output/server/node_modules/@vueuse/core/package.json +49 -0
- package/web/.output/server/node_modules/@vueuse/shared/dist/index.js +2013 -0
- package/web/.output/server/node_modules/@vueuse/shared/package.json +42 -0
- package/web/.output/server/node_modules/aria-hidden/dist/es5/index.js +174 -0
- package/web/.output/server/node_modules/aria-hidden/package.json +71 -0
- package/web/.output/server/node_modules/birpc/dist/index.mjs +291 -0
- package/web/.output/server/node_modules/birpc/package.json +57 -0
- package/web/.output/server/node_modules/consola/dist/chunks/prompt.mjs +280 -0
- package/web/.output/server/node_modules/consola/dist/core.mjs +512 -0
- package/web/.output/server/node_modules/consola/dist/index.mjs +651 -0
- package/web/.output/server/node_modules/consola/dist/shared/consola.DRwqZj3T.mjs +72 -0
- package/web/.output/server/node_modules/consola/dist/shared/consola.DXBYu-KD.mjs +288 -0
- package/web/.output/server/node_modules/consola/package.json +136 -0
- package/web/.output/server/node_modules/devalue/index.js +4 -0
- package/web/.output/server/node_modules/devalue/package.json +40 -0
- package/web/.output/server/node_modules/devalue/src/base64.js +60 -0
- package/web/.output/server/node_modules/devalue/src/constants.js +12 -0
- package/web/.output/server/node_modules/devalue/src/parse.js +283 -0
- package/web/.output/server/node_modules/devalue/src/stringify.js +401 -0
- package/web/.output/server/node_modules/devalue/src/uneval.js +552 -0
- package/web/.output/server/node_modules/devalue/src/utils.js +160 -0
- package/web/.output/server/node_modules/entities/dist/commonjs/decode-codepoint.js +77 -0
- package/web/.output/server/node_modules/entities/dist/commonjs/decode.js +568 -0
- package/web/.output/server/node_modules/entities/dist/commonjs/generated/decode-data-html.js +7 -0
- package/web/.output/server/node_modules/entities/dist/commonjs/generated/decode-data-xml.js +7 -0
- package/web/.output/server/node_modules/entities/dist/commonjs/internal/bin-trie-flags.js +21 -0
- package/web/.output/server/node_modules/entities/dist/commonjs/internal/decode-shared.js +31 -0
- package/web/.output/server/node_modules/entities/dist/commonjs/package.json +3 -0
- package/web/.output/server/node_modules/entities/package.json +120 -0
- package/web/.output/server/node_modules/estree-walker/dist/umd/estree-walker.js +344 -0
- package/web/.output/server/node_modules/estree-walker/package.json +37 -0
- package/web/.output/server/node_modules/hookable/dist/index.mjs +257 -0
- package/web/.output/server/node_modules/hookable/package.json +53 -0
- package/web/.output/server/node_modules/nostics/dist/index.mjs +179 -0
- package/web/.output/server/node_modules/nostics/package.json +124 -0
- package/web/.output/server/node_modules/perfect-debounce/dist/index.mjs +89 -0
- package/web/.output/server/node_modules/perfect-debounce/package.json +41 -0
- package/web/.output/server/node_modules/rou3/dist/index.mjs +501 -0
- package/web/.output/server/node_modules/rou3/package.json +48 -0
- package/web/.output/server/node_modules/source-map-js/lib/array-set.js +121 -0
- package/web/.output/server/node_modules/source-map-js/lib/base64-vlq.js +140 -0
- package/web/.output/server/node_modules/source-map-js/lib/base64.js +67 -0
- package/web/.output/server/node_modules/source-map-js/lib/binary-search.js +111 -0
- package/web/.output/server/node_modules/source-map-js/lib/mapping-list.js +79 -0
- package/web/.output/server/node_modules/source-map-js/lib/quick-sort.js +132 -0
- package/web/.output/server/node_modules/source-map-js/lib/source-map-consumer.js +1188 -0
- package/web/.output/server/node_modules/source-map-js/lib/source-map-generator.js +444 -0
- package/web/.output/server/node_modules/source-map-js/lib/source-node.js +413 -0
- package/web/.output/server/node_modules/source-map-js/lib/util.js +594 -0
- package/web/.output/server/node_modules/source-map-js/package.json +71 -0
- package/web/.output/server/node_modules/source-map-js/source-map.js +8 -0
- package/web/.output/server/node_modules/srvx/dist/_chunks/_body-limit.mjs +39 -0
- package/web/.output/server/node_modules/srvx/dist/_chunks/_plugins.mjs +56 -0
- package/web/.output/server/node_modules/srvx/dist/_chunks/_trust-proxy.mjs +58 -0
- package/web/.output/server/node_modules/srvx/dist/_chunks/_url.mjs +134 -0
- package/web/.output/server/node_modules/srvx/dist/_chunks/_utils.mjs +15 -0
- package/web/.output/server/node_modules/srvx/dist/_chunks/_utils2.mjs +75 -0
- package/web/.output/server/node_modules/srvx/dist/adapters/node.mjs +976 -0
- package/web/.output/server/node_modules/srvx/package.json +102 -0
- package/web/.output/server/node_modules/tailwind-merge/dist/bundle-mjs.mjs +3365 -0
- package/web/.output/server/node_modules/tailwind-merge/package.json +93 -0
- package/web/.output/server/node_modules/tailwind-variants/dist/chunk-LQJYWU4O.js +112 -0
- package/web/.output/server/node_modules/tailwind-variants/dist/chunk-RZF76H2U.js +269 -0
- package/web/.output/server/node_modules/tailwind-variants/dist/index.js +38 -0
- package/web/.output/server/node_modules/tailwind-variants/package.json +122 -0
- package/web/.output/server/node_modules/tailwindcss/dist/chunk-X4GG3EDV.mjs +1 -0
- package/web/.output/server/node_modules/tailwindcss/dist/colors.mjs +1 -0
- package/web/.output/server/node_modules/tailwindcss/package.json +89 -0
- package/web/.output/server/node_modules/ufo/dist/index.mjs +645 -0
- package/web/.output/server/node_modules/ufo/package.json +48 -0
- package/web/.output/server/node_modules/unhead/dist/index.mjs +9 -0
- package/web/.output/server/node_modules/unhead/dist/parser.mjs +508 -0
- package/web/.output/server/node_modules/unhead/dist/plugins.mjs +101 -0
- package/web/.output/server/node_modules/unhead/dist/scripts.mjs +30 -0
- package/web/.output/server/node_modules/unhead/dist/server.mjs +180 -0
- package/web/.output/server/node_modules/unhead/dist/shared/unhead.B3VbJo7Y.mjs +207 -0
- package/web/.output/server/node_modules/unhead/dist/shared/unhead.BYvz9V1x.mjs +43 -0
- package/web/.output/server/node_modules/unhead/dist/shared/unhead.BnoAbrHA.mjs +269 -0
- package/web/.output/server/node_modules/unhead/dist/shared/unhead.CaI5ZD4O.mjs +182 -0
- package/web/.output/server/node_modules/unhead/dist/shared/unhead.CbpEuj3y.mjs +71 -0
- package/web/.output/server/node_modules/unhead/dist/shared/unhead.D4vSFytZ.mjs +236 -0
- package/web/.output/server/node_modules/unhead/dist/shared/unhead.DQc16pHI.mjs +196 -0
- package/web/.output/server/node_modules/unhead/dist/shared/unhead.Dh1cQCTe.mjs +44 -0
- package/web/.output/server/node_modules/unhead/dist/shared/unhead.TxTMM7cM.mjs +166 -0
- package/web/.output/server/node_modules/unhead/dist/shared/unhead.yem5I2v_.mjs +38 -0
- package/web/.output/server/node_modules/unhead/dist/utils.mjs +5 -0
- package/web/.output/server/node_modules/unhead/node_modules/hookable/dist/index.mjs +257 -0
- package/web/.output/server/node_modules/unhead/node_modules/hookable/package.json +53 -0
- package/web/.output/server/node_modules/unhead/package.json +105 -0
- package/web/.output/server/node_modules/vue/dist/vue.cjs.js +80 -0
- package/web/.output/server/node_modules/vue/dist/vue.cjs.prod.js +66 -0
- package/web/.output/server/node_modules/vue/index.js +7 -0
- package/web/.output/server/node_modules/vue/index.mjs +1 -0
- package/web/.output/server/node_modules/vue/package.json +112 -0
- package/web/.output/server/node_modules/vue/server-renderer/index.mjs +1 -0
- package/web/.output/server/node_modules/vue-bundle-renderer/dist/runtime.mjs +249 -0
- package/web/.output/server/node_modules/vue-bundle-renderer/package.json +57 -0
- package/web/.output/server/node_modules/vue-demi/lib/index.mjs +34 -0
- package/web/.output/server/node_modules/vue-demi/package.json +47 -0
- package/web/.output/server/node_modules/vue-router/dist/devtools-Bpr7ZAVB.js +1056 -0
- package/web/.output/server/node_modules/vue-router/dist/useApi-CROJJdhE.js +436 -0
- package/web/.output/server/node_modules/vue-router/dist/vue-router.js +1543 -0
- package/web/.output/server/node_modules/vue-router/package.json +214 -0
- package/web/.output/server/node_modules/vue-router/vue-router.node.mjs +2 -0
- package/web/.output/server/package.json +51 -0
|
@@ -0,0 +1,1896 @@
|
|
|
1
|
+
import { h, defineComponent, ref, shallowRef, onMounted, watch, onUnmounted, nextTick } from 'vue';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Expression to test part of icon name.
|
|
5
|
+
*
|
|
6
|
+
* Used when loading icons from Iconify API due to project naming convension.
|
|
7
|
+
* Ignored when using custom icon sets - convension does not apply.
|
|
8
|
+
*/
|
|
9
|
+
const matchIconName = /^[a-z0-9]+(-[a-z0-9]+)*$/;
|
|
10
|
+
/**
|
|
11
|
+
* Convert string icon name to IconifyIconName object.
|
|
12
|
+
*/
|
|
13
|
+
const stringToIcon = (value, validate, allowSimpleName, provider = "") => {
|
|
14
|
+
const colonSeparated = value.split(":");
|
|
15
|
+
if (value.slice(0, 1) === "@") {
|
|
16
|
+
if (colonSeparated.length < 2 || colonSeparated.length > 3) return null;
|
|
17
|
+
provider = colonSeparated.shift().slice(1);
|
|
18
|
+
}
|
|
19
|
+
if (colonSeparated.length > 3 || !colonSeparated.length) return null;
|
|
20
|
+
if (colonSeparated.length > 1) {
|
|
21
|
+
const name = colonSeparated.pop();
|
|
22
|
+
const prefix = colonSeparated.pop();
|
|
23
|
+
const result = {
|
|
24
|
+
provider: colonSeparated.length > 0 ? colonSeparated[0] : provider,
|
|
25
|
+
prefix,
|
|
26
|
+
name
|
|
27
|
+
};
|
|
28
|
+
return validate && !validateIconName(result) ? null : result;
|
|
29
|
+
}
|
|
30
|
+
const name = colonSeparated[0];
|
|
31
|
+
const dashSeparated = name.split("-");
|
|
32
|
+
if (dashSeparated.length > 1) {
|
|
33
|
+
const result = {
|
|
34
|
+
provider,
|
|
35
|
+
prefix: dashSeparated.shift(),
|
|
36
|
+
name: dashSeparated.join("-")
|
|
37
|
+
};
|
|
38
|
+
return validate && !validateIconName(result) ? null : result;
|
|
39
|
+
}
|
|
40
|
+
if (allowSimpleName && provider === "") {
|
|
41
|
+
const result = {
|
|
42
|
+
provider,
|
|
43
|
+
prefix: "",
|
|
44
|
+
name
|
|
45
|
+
};
|
|
46
|
+
return validate && !validateIconName(result, allowSimpleName) ? null : result;
|
|
47
|
+
}
|
|
48
|
+
return null;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Check if icon is valid.
|
|
52
|
+
*
|
|
53
|
+
* This function is not part of stringToIcon because validation is not needed for most code.
|
|
54
|
+
*/
|
|
55
|
+
const validateIconName = (icon, allowSimpleName) => {
|
|
56
|
+
if (!icon) return false;
|
|
57
|
+
return !!((allowSimpleName && icon.prefix === "" || !!icon.prefix) && !!icon.name);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Resolve icon set icons
|
|
62
|
+
*
|
|
63
|
+
* Returns parent icon for each icon
|
|
64
|
+
*/
|
|
65
|
+
function getIconsTree(data, names) {
|
|
66
|
+
const icons = data.icons;
|
|
67
|
+
const aliases = data.aliases || Object.create(null);
|
|
68
|
+
const resolved = Object.create(null);
|
|
69
|
+
function resolve(name) {
|
|
70
|
+
if (icons[name]) return resolved[name] = [];
|
|
71
|
+
if (!(name in resolved)) {
|
|
72
|
+
resolved[name] = null;
|
|
73
|
+
const parent = aliases[name] && aliases[name].parent;
|
|
74
|
+
const value = parent && resolve(parent);
|
|
75
|
+
if (value) resolved[name] = [parent].concat(value);
|
|
76
|
+
}
|
|
77
|
+
return resolved[name];
|
|
78
|
+
}
|
|
79
|
+
(Object.keys(icons).concat(Object.keys(aliases))).forEach(resolve);
|
|
80
|
+
return resolved;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** Default values for dimensions */
|
|
84
|
+
const defaultIconDimensions = Object.freeze({
|
|
85
|
+
left: 0,
|
|
86
|
+
top: 0,
|
|
87
|
+
width: 16,
|
|
88
|
+
height: 16
|
|
89
|
+
});
|
|
90
|
+
/** Default values for transformations */
|
|
91
|
+
const defaultIconTransformations = Object.freeze({
|
|
92
|
+
rotate: 0,
|
|
93
|
+
vFlip: false,
|
|
94
|
+
hFlip: false
|
|
95
|
+
});
|
|
96
|
+
/** Default values for all optional IconifyIcon properties */
|
|
97
|
+
const defaultIconProps = Object.freeze({
|
|
98
|
+
...defaultIconDimensions,
|
|
99
|
+
...defaultIconTransformations
|
|
100
|
+
});
|
|
101
|
+
/** Default values for all properties used in ExtendedIconifyIcon */
|
|
102
|
+
const defaultExtendedIconProps = Object.freeze({
|
|
103
|
+
...defaultIconProps,
|
|
104
|
+
body: "",
|
|
105
|
+
hidden: false
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Merge transformations
|
|
110
|
+
*/
|
|
111
|
+
function mergeIconTransformations(obj1, obj2) {
|
|
112
|
+
const result = {};
|
|
113
|
+
if (!obj1.hFlip !== !obj2.hFlip) result.hFlip = true;
|
|
114
|
+
if (!obj1.vFlip !== !obj2.vFlip) result.vFlip = true;
|
|
115
|
+
const rotate = ((obj1.rotate || 0) + (obj2.rotate || 0)) % 4;
|
|
116
|
+
if (rotate) result.rotate = rotate;
|
|
117
|
+
return result;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Merge icon and alias
|
|
122
|
+
*
|
|
123
|
+
* Can also be used to merge default values and icon
|
|
124
|
+
*/
|
|
125
|
+
function mergeIconData(parent, child) {
|
|
126
|
+
const result = mergeIconTransformations(parent, child);
|
|
127
|
+
for (const key in defaultExtendedIconProps) if (key in defaultIconTransformations) {
|
|
128
|
+
if (key in parent && !(key in result)) result[key] = defaultIconTransformations[key];
|
|
129
|
+
} else if (key in child) result[key] = child[key];
|
|
130
|
+
else if (key in parent) result[key] = parent[key];
|
|
131
|
+
return result;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Get icon data, using prepared aliases tree
|
|
136
|
+
*/
|
|
137
|
+
function internalGetIconData(data, name, tree) {
|
|
138
|
+
const icons = data.icons;
|
|
139
|
+
const aliases = data.aliases || Object.create(null);
|
|
140
|
+
let currentProps = {};
|
|
141
|
+
function parse(name) {
|
|
142
|
+
currentProps = mergeIconData(icons[name] || aliases[name], currentProps);
|
|
143
|
+
}
|
|
144
|
+
parse(name);
|
|
145
|
+
tree.forEach(parse);
|
|
146
|
+
return mergeIconData(data, currentProps);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Extract icons from an icon set
|
|
151
|
+
*
|
|
152
|
+
* Returns list of icons that were found in icon set
|
|
153
|
+
*/
|
|
154
|
+
function parseIconSet(data, callback) {
|
|
155
|
+
const names = [];
|
|
156
|
+
if (typeof data !== "object" || typeof data.icons !== "object") return names;
|
|
157
|
+
if (data.not_found instanceof Array) data.not_found.forEach((name) => {
|
|
158
|
+
callback(name, null);
|
|
159
|
+
names.push(name);
|
|
160
|
+
});
|
|
161
|
+
const tree = getIconsTree(data);
|
|
162
|
+
for (const name in tree) {
|
|
163
|
+
const item = tree[name];
|
|
164
|
+
if (item) {
|
|
165
|
+
callback(name, internalGetIconData(data, name, item));
|
|
166
|
+
names.push(name);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return names;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Optional properties
|
|
174
|
+
*/
|
|
175
|
+
const optionalPropertyDefaults = {
|
|
176
|
+
provider: "",
|
|
177
|
+
aliases: {},
|
|
178
|
+
not_found: {},
|
|
179
|
+
...defaultIconDimensions
|
|
180
|
+
};
|
|
181
|
+
/**
|
|
182
|
+
* Check props
|
|
183
|
+
*/
|
|
184
|
+
function checkOptionalProps(item, defaults) {
|
|
185
|
+
for (const prop in defaults) if (prop in item && typeof item[prop] !== typeof defaults[prop]) return false;
|
|
186
|
+
return true;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Validate icon set, return it as IconifyJSON on success, null on failure
|
|
190
|
+
*
|
|
191
|
+
* Unlike validateIconSet(), this function is very basic.
|
|
192
|
+
* It does not throw exceptions, it does not check metadata, it does not fix stuff.
|
|
193
|
+
*/
|
|
194
|
+
function quicklyValidateIconSet(obj) {
|
|
195
|
+
if (typeof obj !== "object" || obj === null) return null;
|
|
196
|
+
const data = obj;
|
|
197
|
+
if (typeof data.prefix !== "string" || !obj.icons || typeof obj.icons !== "object") return null;
|
|
198
|
+
if (!checkOptionalProps(obj, optionalPropertyDefaults)) return null;
|
|
199
|
+
const icons = data.icons;
|
|
200
|
+
for (const name in icons) {
|
|
201
|
+
const icon = icons[name];
|
|
202
|
+
if (!name || typeof icon.body !== "string" || !checkOptionalProps(icon, defaultExtendedIconProps)) return null;
|
|
203
|
+
}
|
|
204
|
+
const aliases = data.aliases || Object.create(null);
|
|
205
|
+
for (const name in aliases) {
|
|
206
|
+
const icon = aliases[name];
|
|
207
|
+
const parent = icon.parent;
|
|
208
|
+
if (!name || typeof parent !== "string" || !icons[parent] && !aliases[parent] || !checkOptionalProps(icon, defaultExtendedIconProps)) return null;
|
|
209
|
+
}
|
|
210
|
+
return data;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Storage by provider and prefix
|
|
215
|
+
*/
|
|
216
|
+
const dataStorage = Object.create(null);
|
|
217
|
+
/**
|
|
218
|
+
* Create new storage
|
|
219
|
+
*/
|
|
220
|
+
function newStorage(provider, prefix) {
|
|
221
|
+
return {
|
|
222
|
+
provider,
|
|
223
|
+
prefix,
|
|
224
|
+
icons: Object.create(null),
|
|
225
|
+
missing: /* @__PURE__ */ new Set()
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Get storage for provider and prefix
|
|
230
|
+
*/
|
|
231
|
+
function getStorage(provider, prefix) {
|
|
232
|
+
const providerStorage = dataStorage[provider] || (dataStorage[provider] = Object.create(null));
|
|
233
|
+
return providerStorage[prefix] || (providerStorage[prefix] = newStorage(provider, prefix));
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Add icon set to storage
|
|
237
|
+
*
|
|
238
|
+
* Returns array of added icons
|
|
239
|
+
*/
|
|
240
|
+
function addIconSet(storage, data) {
|
|
241
|
+
if (!quicklyValidateIconSet(data)) return [];
|
|
242
|
+
return parseIconSet(data, (name, icon) => {
|
|
243
|
+
if (icon) storage.icons[name] = icon;
|
|
244
|
+
else storage.missing.add(name);
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Add icon to storage
|
|
249
|
+
*/
|
|
250
|
+
function addIconToStorage(storage, name, icon) {
|
|
251
|
+
try {
|
|
252
|
+
if (typeof icon.body === "string") {
|
|
253
|
+
storage.icons[name] = { ...icon };
|
|
254
|
+
return true;
|
|
255
|
+
}
|
|
256
|
+
} catch (err) {}
|
|
257
|
+
return false;
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* List available icons
|
|
261
|
+
*/
|
|
262
|
+
function listIcons(provider, prefix) {
|
|
263
|
+
let allIcons = [];
|
|
264
|
+
(typeof provider === "string" ? [provider] : Object.keys(dataStorage)).forEach((provider) => {
|
|
265
|
+
(typeof provider === "string" && typeof prefix === "string" ? [prefix] : Object.keys(dataStorage[provider] || {})).forEach((prefix) => {
|
|
266
|
+
const storage = getStorage(provider, prefix);
|
|
267
|
+
allIcons = allIcons.concat(Object.keys(storage.icons).map((name) => (provider !== "" ? "@" + provider + ":" : "") + prefix + ":" + name));
|
|
268
|
+
});
|
|
269
|
+
});
|
|
270
|
+
return allIcons;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Allow storing icons without provider or prefix, making it possible to store icons like "home"
|
|
275
|
+
*/
|
|
276
|
+
let simpleNames = false;
|
|
277
|
+
function allowSimpleNames(allow) {
|
|
278
|
+
if (typeof allow === "boolean") simpleNames = allow;
|
|
279
|
+
return simpleNames;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Get icon data
|
|
283
|
+
*
|
|
284
|
+
* Returns:
|
|
285
|
+
* - IconifyIcon on success, object directly from storage so don't modify it
|
|
286
|
+
* - null if icon is marked as missing (returned in `not_found` property from API, so don't bother sending API requests)
|
|
287
|
+
* - undefined if icon is missing in storage
|
|
288
|
+
*/
|
|
289
|
+
function getIconData(name) {
|
|
290
|
+
const icon = typeof name === "string" ? stringToIcon(name, true, simpleNames) : name;
|
|
291
|
+
if (icon) {
|
|
292
|
+
const storage = getStorage(icon.provider, icon.prefix);
|
|
293
|
+
const iconName = icon.name;
|
|
294
|
+
return storage.icons[iconName] || (storage.missing.has(iconName) ? null : void 0);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Add one icon
|
|
299
|
+
*/
|
|
300
|
+
function addIcon(name, data) {
|
|
301
|
+
const icon = stringToIcon(name, true, simpleNames);
|
|
302
|
+
if (!icon) return false;
|
|
303
|
+
const storage = getStorage(icon.provider, icon.prefix);
|
|
304
|
+
if (data) return addIconToStorage(storage, icon.name, data);
|
|
305
|
+
else {
|
|
306
|
+
storage.missing.add(icon.name);
|
|
307
|
+
return true;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Add icon set
|
|
312
|
+
*/
|
|
313
|
+
function addCollection(data, provider) {
|
|
314
|
+
if (typeof data !== "object") return false;
|
|
315
|
+
if (typeof provider !== "string") provider = data.provider || "";
|
|
316
|
+
if (simpleNames && !provider && !data.prefix) {
|
|
317
|
+
let added = false;
|
|
318
|
+
if (quicklyValidateIconSet(data)) {
|
|
319
|
+
data.prefix = "";
|
|
320
|
+
parseIconSet(data, (name, icon) => {
|
|
321
|
+
if (addIcon(name, icon)) added = true;
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
return added;
|
|
325
|
+
}
|
|
326
|
+
const prefix = data.prefix;
|
|
327
|
+
if (!validateIconName({
|
|
328
|
+
prefix,
|
|
329
|
+
name: "a"
|
|
330
|
+
})) return false;
|
|
331
|
+
return !!addIconSet(getStorage(provider, prefix), data);
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* Check if icon data is available
|
|
335
|
+
*/
|
|
336
|
+
function iconLoaded(name) {
|
|
337
|
+
return !!getIconData(name);
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* Get full icon
|
|
341
|
+
*/
|
|
342
|
+
function getIcon(name) {
|
|
343
|
+
const result = getIconData(name);
|
|
344
|
+
return result ? {
|
|
345
|
+
...defaultIconProps,
|
|
346
|
+
...result
|
|
347
|
+
} : result;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* Default icon customisations values
|
|
352
|
+
*/
|
|
353
|
+
const defaultIconSizeCustomisations = Object.freeze({
|
|
354
|
+
width: null,
|
|
355
|
+
height: null
|
|
356
|
+
});
|
|
357
|
+
const defaultIconCustomisations = Object.freeze({
|
|
358
|
+
...defaultIconSizeCustomisations,
|
|
359
|
+
...defaultIconTransformations
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* Regular expressions for calculating dimensions
|
|
364
|
+
*/
|
|
365
|
+
const unitsSplit = /(-?[0-9.]*[0-9]+[0-9.]*)/g;
|
|
366
|
+
const unitsTest = /^-?[0-9.]*[0-9]+[0-9.]*$/g;
|
|
367
|
+
function calculateSize(size, ratio, precision) {
|
|
368
|
+
if (ratio === 1) return size;
|
|
369
|
+
precision = precision || 100;
|
|
370
|
+
if (typeof size === "number") return Math.ceil(size * ratio * precision) / precision;
|
|
371
|
+
if (typeof size !== "string") return size;
|
|
372
|
+
const oldParts = size.split(unitsSplit);
|
|
373
|
+
if (oldParts === null || !oldParts.length) return size;
|
|
374
|
+
const newParts = [];
|
|
375
|
+
let code = oldParts.shift();
|
|
376
|
+
let isNumber = unitsTest.test(code);
|
|
377
|
+
while (true) {
|
|
378
|
+
if (isNumber) {
|
|
379
|
+
const num = parseFloat(code);
|
|
380
|
+
if (isNaN(num)) newParts.push(code);
|
|
381
|
+
else newParts.push(Math.ceil(num * ratio * precision) / precision);
|
|
382
|
+
} else newParts.push(code);
|
|
383
|
+
code = oldParts.shift();
|
|
384
|
+
if (code === void 0) return newParts.join("");
|
|
385
|
+
isNumber = !isNumber;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
function splitSVGDefs(content, tag = "defs") {
|
|
390
|
+
let defs = "";
|
|
391
|
+
const index = content.indexOf("<" + tag);
|
|
392
|
+
while (index >= 0) {
|
|
393
|
+
const start = content.indexOf(">", index);
|
|
394
|
+
const end = content.indexOf("</" + tag);
|
|
395
|
+
if (start === -1 || end === -1) break;
|
|
396
|
+
const endEnd = content.indexOf(">", end);
|
|
397
|
+
if (endEnd === -1) break;
|
|
398
|
+
defs += content.slice(start + 1, end).trim();
|
|
399
|
+
content = content.slice(0, index).trim() + content.slice(endEnd + 1);
|
|
400
|
+
}
|
|
401
|
+
return {
|
|
402
|
+
defs,
|
|
403
|
+
content
|
|
404
|
+
};
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* Merge defs and content
|
|
408
|
+
*/
|
|
409
|
+
function mergeDefsAndContent(defs, content) {
|
|
410
|
+
return defs ? "<defs>" + defs + "</defs>" + content : content;
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
* Wrap SVG content, without wrapping definitions
|
|
414
|
+
*/
|
|
415
|
+
function wrapSVGContent(body, start, end) {
|
|
416
|
+
const split = splitSVGDefs(body);
|
|
417
|
+
return mergeDefsAndContent(split.defs, start + split.content + end);
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
/**
|
|
421
|
+
* Check if value should be unset. Allows multiple keywords
|
|
422
|
+
*/
|
|
423
|
+
const isUnsetKeyword = (value) => value === "unset" || value === "undefined" || value === "none";
|
|
424
|
+
/**
|
|
425
|
+
* Get SVG attributes and content from icon + customisations
|
|
426
|
+
*
|
|
427
|
+
* Does not generate style to make it compatible with frameworks that use objects for style, such as React.
|
|
428
|
+
* Instead, it generates 'inline' value. If true, rendering engine should add verticalAlign: -0.125em to icon.
|
|
429
|
+
*
|
|
430
|
+
* Customisations should be normalised by platform specific parser.
|
|
431
|
+
* Result should be converted to <svg> by platform specific parser.
|
|
432
|
+
* Use replaceIDs to generate unique IDs for body.
|
|
433
|
+
*/
|
|
434
|
+
function iconToSVG(icon, customisations) {
|
|
435
|
+
const fullIcon = {
|
|
436
|
+
...defaultIconProps,
|
|
437
|
+
...icon
|
|
438
|
+
};
|
|
439
|
+
const fullCustomisations = {
|
|
440
|
+
...defaultIconCustomisations,
|
|
441
|
+
...customisations
|
|
442
|
+
};
|
|
443
|
+
const box = {
|
|
444
|
+
left: fullIcon.left,
|
|
445
|
+
top: fullIcon.top,
|
|
446
|
+
width: fullIcon.width,
|
|
447
|
+
height: fullIcon.height
|
|
448
|
+
};
|
|
449
|
+
let body = fullIcon.body;
|
|
450
|
+
[fullIcon, fullCustomisations].forEach((props) => {
|
|
451
|
+
const transformations = [];
|
|
452
|
+
const hFlip = props.hFlip;
|
|
453
|
+
const vFlip = props.vFlip;
|
|
454
|
+
let rotation = props.rotate;
|
|
455
|
+
if (hFlip) if (vFlip) rotation += 2;
|
|
456
|
+
else {
|
|
457
|
+
transformations.push("translate(" + (box.width + box.left).toString() + " " + (0 - box.top).toString() + ")");
|
|
458
|
+
transformations.push("scale(-1 1)");
|
|
459
|
+
box.top = box.left = 0;
|
|
460
|
+
}
|
|
461
|
+
else if (vFlip) {
|
|
462
|
+
transformations.push("translate(" + (0 - box.left).toString() + " " + (box.height + box.top).toString() + ")");
|
|
463
|
+
transformations.push("scale(1 -1)");
|
|
464
|
+
box.top = box.left = 0;
|
|
465
|
+
}
|
|
466
|
+
let tempValue;
|
|
467
|
+
if (rotation < 0) rotation -= Math.floor(rotation / 4) * 4;
|
|
468
|
+
rotation = rotation % 4;
|
|
469
|
+
switch (rotation) {
|
|
470
|
+
case 1:
|
|
471
|
+
tempValue = box.height / 2 + box.top;
|
|
472
|
+
transformations.unshift("rotate(90 " + tempValue.toString() + " " + tempValue.toString() + ")");
|
|
473
|
+
break;
|
|
474
|
+
case 2:
|
|
475
|
+
transformations.unshift("rotate(180 " + (box.width / 2 + box.left).toString() + " " + (box.height / 2 + box.top).toString() + ")");
|
|
476
|
+
break;
|
|
477
|
+
case 3:
|
|
478
|
+
tempValue = box.width / 2 + box.left;
|
|
479
|
+
transformations.unshift("rotate(-90 " + tempValue.toString() + " " + tempValue.toString() + ")");
|
|
480
|
+
break;
|
|
481
|
+
}
|
|
482
|
+
if (rotation % 2 === 1) {
|
|
483
|
+
if (box.left !== box.top) {
|
|
484
|
+
tempValue = box.left;
|
|
485
|
+
box.left = box.top;
|
|
486
|
+
box.top = tempValue;
|
|
487
|
+
}
|
|
488
|
+
if (box.width !== box.height) {
|
|
489
|
+
tempValue = box.width;
|
|
490
|
+
box.width = box.height;
|
|
491
|
+
box.height = tempValue;
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
if (transformations.length) body = wrapSVGContent(body, "<g transform=\"" + transformations.join(" ") + "\">", "</g>");
|
|
495
|
+
});
|
|
496
|
+
const customisationsWidth = fullCustomisations.width;
|
|
497
|
+
const customisationsHeight = fullCustomisations.height;
|
|
498
|
+
const boxWidth = box.width;
|
|
499
|
+
const boxHeight = box.height;
|
|
500
|
+
let width;
|
|
501
|
+
let height;
|
|
502
|
+
if (customisationsWidth === null) {
|
|
503
|
+
height = customisationsHeight === null ? "1em" : customisationsHeight === "auto" ? boxHeight : customisationsHeight;
|
|
504
|
+
width = calculateSize(height, boxWidth / boxHeight);
|
|
505
|
+
} else {
|
|
506
|
+
width = customisationsWidth === "auto" ? boxWidth : customisationsWidth;
|
|
507
|
+
height = customisationsHeight === null ? calculateSize(width, boxHeight / boxWidth) : customisationsHeight === "auto" ? boxHeight : customisationsHeight;
|
|
508
|
+
}
|
|
509
|
+
const attributes = {};
|
|
510
|
+
const setAttr = (prop, value) => {
|
|
511
|
+
if (!isUnsetKeyword(value)) attributes[prop] = value.toString();
|
|
512
|
+
};
|
|
513
|
+
setAttr("width", width);
|
|
514
|
+
setAttr("height", height);
|
|
515
|
+
const viewBox = [
|
|
516
|
+
box.left,
|
|
517
|
+
box.top,
|
|
518
|
+
boxWidth,
|
|
519
|
+
boxHeight
|
|
520
|
+
];
|
|
521
|
+
attributes.viewBox = viewBox.join(" ");
|
|
522
|
+
return {
|
|
523
|
+
attributes,
|
|
524
|
+
viewBox,
|
|
525
|
+
body
|
|
526
|
+
};
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
/**
|
|
530
|
+
* Regular expression for finding ids
|
|
531
|
+
*/
|
|
532
|
+
const regex = /\sid="(\S+)"/g;
|
|
533
|
+
/**
|
|
534
|
+
* Counters
|
|
535
|
+
*/
|
|
536
|
+
const counters = /* @__PURE__ */ new Map();
|
|
537
|
+
/**
|
|
538
|
+
* Get unique new ID
|
|
539
|
+
*/
|
|
540
|
+
function nextID(id) {
|
|
541
|
+
id = id.replace(/[0-9]+$/, "") || "a";
|
|
542
|
+
const count = counters.get(id) || 0;
|
|
543
|
+
counters.set(id, count + 1);
|
|
544
|
+
return count ? `${id}${count}` : id;
|
|
545
|
+
}
|
|
546
|
+
/**
|
|
547
|
+
* Replace IDs in SVG output with unique IDs
|
|
548
|
+
*/
|
|
549
|
+
function replaceIDs(body) {
|
|
550
|
+
const ids = [];
|
|
551
|
+
let match;
|
|
552
|
+
while (match = regex.exec(body)) ids.push(match[1]);
|
|
553
|
+
if (!ids.length) return body;
|
|
554
|
+
const suffix = "suffix" + (Math.random() * 16777216 | Date.now()).toString(16);
|
|
555
|
+
ids.forEach((id) => {
|
|
556
|
+
const newID = nextID(id);
|
|
557
|
+
const escapedID = id.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
558
|
+
body = body.replace(new RegExp("([#;\"])(" + escapedID + ")([\")]|\\.[a-z])", "g"), "$1" + newID + suffix + "$3");
|
|
559
|
+
});
|
|
560
|
+
body = body.replace(new RegExp(suffix, "g"), "");
|
|
561
|
+
return body;
|
|
562
|
+
}
|
|
563
|
+
/**
|
|
564
|
+
* Clear ID cache
|
|
565
|
+
*/
|
|
566
|
+
function clearIDCache() {
|
|
567
|
+
counters.clear();
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
/**
|
|
571
|
+
* Local storate types and entries
|
|
572
|
+
*/
|
|
573
|
+
const storage = Object.create(null);
|
|
574
|
+
/**
|
|
575
|
+
* Set API module
|
|
576
|
+
*/
|
|
577
|
+
function setAPIModule(provider, item) {
|
|
578
|
+
storage[provider] = item;
|
|
579
|
+
}
|
|
580
|
+
/**
|
|
581
|
+
* Get API module
|
|
582
|
+
*/
|
|
583
|
+
function getAPIModule(provider) {
|
|
584
|
+
return storage[provider] || storage[""];
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
/**
|
|
588
|
+
* Create full API configuration from partial data
|
|
589
|
+
*/
|
|
590
|
+
function createAPIConfig(source) {
|
|
591
|
+
let resources;
|
|
592
|
+
if (typeof source.resources === "string") resources = [source.resources];
|
|
593
|
+
else {
|
|
594
|
+
resources = source.resources;
|
|
595
|
+
if (!(resources instanceof Array) || !resources.length) return null;
|
|
596
|
+
}
|
|
597
|
+
return {
|
|
598
|
+
resources,
|
|
599
|
+
path: source.path || "/",
|
|
600
|
+
maxURL: source.maxURL || 500,
|
|
601
|
+
rotate: source.rotate || 750,
|
|
602
|
+
timeout: source.timeout || 5e3,
|
|
603
|
+
random: source.random === true,
|
|
604
|
+
index: source.index || 0,
|
|
605
|
+
dataAfterTimeout: source.dataAfterTimeout !== false
|
|
606
|
+
};
|
|
607
|
+
}
|
|
608
|
+
/**
|
|
609
|
+
* Local storage
|
|
610
|
+
*/
|
|
611
|
+
const configStorage = Object.create(null);
|
|
612
|
+
/**
|
|
613
|
+
* Redundancy for API servers.
|
|
614
|
+
*
|
|
615
|
+
* API should have very high uptime because of implemented redundancy at server level, but
|
|
616
|
+
* sometimes bad things happen. On internet 100% uptime is not possible.
|
|
617
|
+
*
|
|
618
|
+
* There could be routing problems. Server might go down for whatever reason, but it takes
|
|
619
|
+
* few minutes to detect that downtime, so during those few minutes API might not be accessible.
|
|
620
|
+
*
|
|
621
|
+
* This script has some redundancy to mitigate possible network issues.
|
|
622
|
+
*
|
|
623
|
+
* If one host cannot be reached in 'rotate' (750 by default) ms, script will try to retrieve
|
|
624
|
+
* data from different host. Hosts have different configurations, pointing to different
|
|
625
|
+
* API servers hosted at different providers.
|
|
626
|
+
*/
|
|
627
|
+
const fallBackAPISources = ["https://api.simplesvg.com", "https://api.unisvg.com"];
|
|
628
|
+
const fallBackAPI = [];
|
|
629
|
+
while (fallBackAPISources.length > 0) if (fallBackAPISources.length === 1) fallBackAPI.push(fallBackAPISources.shift());
|
|
630
|
+
else if (Math.random() > .5) fallBackAPI.push(fallBackAPISources.shift());
|
|
631
|
+
else fallBackAPI.push(fallBackAPISources.pop());
|
|
632
|
+
configStorage[""] = createAPIConfig({ resources: ["https://api.iconify.design"].concat(fallBackAPI) });
|
|
633
|
+
/**
|
|
634
|
+
* Add custom config for provider
|
|
635
|
+
*/
|
|
636
|
+
function addAPIProvider(provider, customConfig) {
|
|
637
|
+
const config = createAPIConfig(customConfig);
|
|
638
|
+
if (config === null) return false;
|
|
639
|
+
configStorage[provider] = config;
|
|
640
|
+
return true;
|
|
641
|
+
}
|
|
642
|
+
/**
|
|
643
|
+
* Get API configuration
|
|
644
|
+
*/
|
|
645
|
+
function getAPIConfig(provider) {
|
|
646
|
+
return configStorage[provider];
|
|
647
|
+
}
|
|
648
|
+
/**
|
|
649
|
+
* List API providers
|
|
650
|
+
*/
|
|
651
|
+
function listAPIProviders() {
|
|
652
|
+
return Object.keys(configStorage);
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
const detectFetch = () => {
|
|
656
|
+
let callback;
|
|
657
|
+
try {
|
|
658
|
+
callback = fetch;
|
|
659
|
+
if (typeof callback === "function") return callback;
|
|
660
|
+
} catch (err) {}
|
|
661
|
+
};
|
|
662
|
+
/**
|
|
663
|
+
* Fetch function
|
|
664
|
+
*/
|
|
665
|
+
let fetchModule = detectFetch();
|
|
666
|
+
/**
|
|
667
|
+
* Set custom fetch() function
|
|
668
|
+
*/
|
|
669
|
+
function setFetch(fetch) {
|
|
670
|
+
fetchModule = fetch;
|
|
671
|
+
}
|
|
672
|
+
/**
|
|
673
|
+
* Get fetch() function. Used by Icon Finder Core
|
|
674
|
+
*/
|
|
675
|
+
function getFetch() {
|
|
676
|
+
return fetchModule;
|
|
677
|
+
}
|
|
678
|
+
/**
|
|
679
|
+
* Calculate maximum icons list length for prefix
|
|
680
|
+
*/
|
|
681
|
+
function calculateMaxLength(provider, prefix) {
|
|
682
|
+
const config = getAPIConfig(provider);
|
|
683
|
+
if (!config) return 0;
|
|
684
|
+
let result;
|
|
685
|
+
if (!config.maxURL) result = 0;
|
|
686
|
+
else {
|
|
687
|
+
let maxHostLength = 0;
|
|
688
|
+
config.resources.forEach((item) => {
|
|
689
|
+
maxHostLength = Math.max(maxHostLength, item.length);
|
|
690
|
+
});
|
|
691
|
+
const url = prefix + ".json?icons=";
|
|
692
|
+
result = config.maxURL - maxHostLength - config.path.length - url.length;
|
|
693
|
+
}
|
|
694
|
+
return result;
|
|
695
|
+
}
|
|
696
|
+
/**
|
|
697
|
+
* Should query be aborted, based on last HTTP status
|
|
698
|
+
*/
|
|
699
|
+
function shouldAbort(status) {
|
|
700
|
+
return status === 404;
|
|
701
|
+
}
|
|
702
|
+
/**
|
|
703
|
+
* Prepare params
|
|
704
|
+
*/
|
|
705
|
+
const prepare = (provider, prefix, icons) => {
|
|
706
|
+
const results = [];
|
|
707
|
+
const maxLength = calculateMaxLength(provider, prefix);
|
|
708
|
+
const type = "icons";
|
|
709
|
+
let item = {
|
|
710
|
+
type,
|
|
711
|
+
provider,
|
|
712
|
+
prefix,
|
|
713
|
+
icons: []
|
|
714
|
+
};
|
|
715
|
+
let length = 0;
|
|
716
|
+
icons.forEach((name, index) => {
|
|
717
|
+
length += name.length + 1;
|
|
718
|
+
if (length >= maxLength && index > 0) {
|
|
719
|
+
results.push(item);
|
|
720
|
+
item = {
|
|
721
|
+
type,
|
|
722
|
+
provider,
|
|
723
|
+
prefix,
|
|
724
|
+
icons: []
|
|
725
|
+
};
|
|
726
|
+
length = name.length;
|
|
727
|
+
}
|
|
728
|
+
item.icons.push(name);
|
|
729
|
+
});
|
|
730
|
+
results.push(item);
|
|
731
|
+
return results;
|
|
732
|
+
};
|
|
733
|
+
/**
|
|
734
|
+
* Get path
|
|
735
|
+
*/
|
|
736
|
+
function getPath(provider) {
|
|
737
|
+
if (typeof provider === "string") {
|
|
738
|
+
const config = getAPIConfig(provider);
|
|
739
|
+
if (config) return config.path;
|
|
740
|
+
}
|
|
741
|
+
return "/";
|
|
742
|
+
}
|
|
743
|
+
/**
|
|
744
|
+
* Load icons
|
|
745
|
+
*/
|
|
746
|
+
const send = (host, params, callback) => {
|
|
747
|
+
if (!fetchModule) {
|
|
748
|
+
callback("abort", 424);
|
|
749
|
+
return;
|
|
750
|
+
}
|
|
751
|
+
let path = getPath(params.provider);
|
|
752
|
+
switch (params.type) {
|
|
753
|
+
case "icons": {
|
|
754
|
+
const prefix = params.prefix;
|
|
755
|
+
const iconsList = params.icons.join(",");
|
|
756
|
+
const urlParams = new URLSearchParams({ icons: iconsList });
|
|
757
|
+
path += prefix + ".json?" + urlParams.toString();
|
|
758
|
+
break;
|
|
759
|
+
}
|
|
760
|
+
case "custom": {
|
|
761
|
+
const uri = params.uri;
|
|
762
|
+
path += uri.slice(0, 1) === "/" ? uri.slice(1) : uri;
|
|
763
|
+
break;
|
|
764
|
+
}
|
|
765
|
+
default:
|
|
766
|
+
callback("abort", 400);
|
|
767
|
+
return;
|
|
768
|
+
}
|
|
769
|
+
let defaultError = 503;
|
|
770
|
+
fetchModule(host + path).then((response) => {
|
|
771
|
+
const status = response.status;
|
|
772
|
+
if (status !== 200) {
|
|
773
|
+
setTimeout(() => {
|
|
774
|
+
callback(shouldAbort(status) ? "abort" : "next", status);
|
|
775
|
+
});
|
|
776
|
+
return;
|
|
777
|
+
}
|
|
778
|
+
defaultError = 501;
|
|
779
|
+
return response.json();
|
|
780
|
+
}).then((data) => {
|
|
781
|
+
if (typeof data !== "object" || data === null) {
|
|
782
|
+
setTimeout(() => {
|
|
783
|
+
if (data === 404) callback("abort", data);
|
|
784
|
+
else callback("next", defaultError);
|
|
785
|
+
});
|
|
786
|
+
return;
|
|
787
|
+
}
|
|
788
|
+
setTimeout(() => {
|
|
789
|
+
callback("success", data);
|
|
790
|
+
});
|
|
791
|
+
}).catch(() => {
|
|
792
|
+
callback("next", defaultError);
|
|
793
|
+
});
|
|
794
|
+
};
|
|
795
|
+
/**
|
|
796
|
+
* Export module
|
|
797
|
+
*/
|
|
798
|
+
const fetchAPIModule = {
|
|
799
|
+
prepare,
|
|
800
|
+
send
|
|
801
|
+
};
|
|
802
|
+
|
|
803
|
+
/**
|
|
804
|
+
* Remove callback
|
|
805
|
+
*/
|
|
806
|
+
function removeCallback(storages, id) {
|
|
807
|
+
storages.forEach((storage) => {
|
|
808
|
+
const items = storage.loaderCallbacks;
|
|
809
|
+
if (items) storage.loaderCallbacks = items.filter((row) => row.id !== id);
|
|
810
|
+
});
|
|
811
|
+
}
|
|
812
|
+
/**
|
|
813
|
+
* Update all callbacks for provider and prefix
|
|
814
|
+
*/
|
|
815
|
+
function updateCallbacks(storage) {
|
|
816
|
+
if (!storage.pendingCallbacksFlag) {
|
|
817
|
+
storage.pendingCallbacksFlag = true;
|
|
818
|
+
setTimeout(() => {
|
|
819
|
+
storage.pendingCallbacksFlag = false;
|
|
820
|
+
const items = storage.loaderCallbacks ? storage.loaderCallbacks.slice(0) : [];
|
|
821
|
+
if (!items.length) return;
|
|
822
|
+
let hasPending = false;
|
|
823
|
+
const provider = storage.provider;
|
|
824
|
+
const prefix = storage.prefix;
|
|
825
|
+
items.forEach((item) => {
|
|
826
|
+
const icons = item.icons;
|
|
827
|
+
const oldLength = icons.pending.length;
|
|
828
|
+
icons.pending = icons.pending.filter((icon) => {
|
|
829
|
+
if (icon.prefix !== prefix) return true;
|
|
830
|
+
const name = icon.name;
|
|
831
|
+
if (storage.icons[name]) icons.loaded.push({
|
|
832
|
+
provider,
|
|
833
|
+
prefix,
|
|
834
|
+
name
|
|
835
|
+
});
|
|
836
|
+
else if (storage.missing.has(name)) icons.missing.push({
|
|
837
|
+
provider,
|
|
838
|
+
prefix,
|
|
839
|
+
name
|
|
840
|
+
});
|
|
841
|
+
else {
|
|
842
|
+
hasPending = true;
|
|
843
|
+
return true;
|
|
844
|
+
}
|
|
845
|
+
return false;
|
|
846
|
+
});
|
|
847
|
+
if (icons.pending.length !== oldLength) {
|
|
848
|
+
if (!hasPending) removeCallback([storage], item.id);
|
|
849
|
+
item.callback(icons.loaded.slice(0), icons.missing.slice(0), icons.pending.slice(0), item.abort);
|
|
850
|
+
}
|
|
851
|
+
});
|
|
852
|
+
});
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
/**
|
|
856
|
+
* Unique id counter for callbacks
|
|
857
|
+
*/
|
|
858
|
+
let idCounter = 0;
|
|
859
|
+
/**
|
|
860
|
+
* Add callback
|
|
861
|
+
*/
|
|
862
|
+
function storeCallback(callback, icons, pendingSources) {
|
|
863
|
+
const id = idCounter++;
|
|
864
|
+
const abort = removeCallback.bind(null, pendingSources, id);
|
|
865
|
+
if (!icons.pending.length) return abort;
|
|
866
|
+
const item = {
|
|
867
|
+
id,
|
|
868
|
+
icons,
|
|
869
|
+
callback,
|
|
870
|
+
abort
|
|
871
|
+
};
|
|
872
|
+
pendingSources.forEach((storage) => {
|
|
873
|
+
(storage.loaderCallbacks || (storage.loaderCallbacks = [])).push(item);
|
|
874
|
+
});
|
|
875
|
+
return abort;
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
/**
|
|
879
|
+
* Check if icons have been loaded
|
|
880
|
+
*/
|
|
881
|
+
function sortIcons(icons) {
|
|
882
|
+
const result = {
|
|
883
|
+
loaded: [],
|
|
884
|
+
missing: [],
|
|
885
|
+
pending: []
|
|
886
|
+
};
|
|
887
|
+
const storage = Object.create(null);
|
|
888
|
+
icons.sort((a, b) => {
|
|
889
|
+
if (a.provider !== b.provider) return a.provider.localeCompare(b.provider);
|
|
890
|
+
if (a.prefix !== b.prefix) return a.prefix.localeCompare(b.prefix);
|
|
891
|
+
return a.name.localeCompare(b.name);
|
|
892
|
+
});
|
|
893
|
+
let lastIcon = {
|
|
894
|
+
provider: "",
|
|
895
|
+
prefix: "",
|
|
896
|
+
name: ""
|
|
897
|
+
};
|
|
898
|
+
icons.forEach((icon) => {
|
|
899
|
+
if (lastIcon.name === icon.name && lastIcon.prefix === icon.prefix && lastIcon.provider === icon.provider) return;
|
|
900
|
+
lastIcon = icon;
|
|
901
|
+
const provider = icon.provider;
|
|
902
|
+
const prefix = icon.prefix;
|
|
903
|
+
const name = icon.name;
|
|
904
|
+
const providerStorage = storage[provider] || (storage[provider] = Object.create(null));
|
|
905
|
+
const localStorage = providerStorage[prefix] || (providerStorage[prefix] = getStorage(provider, prefix));
|
|
906
|
+
let list;
|
|
907
|
+
if (name in localStorage.icons) list = result.loaded;
|
|
908
|
+
else if (prefix === "" || localStorage.missing.has(name)) list = result.missing;
|
|
909
|
+
else list = result.pending;
|
|
910
|
+
const item = {
|
|
911
|
+
provider,
|
|
912
|
+
prefix,
|
|
913
|
+
name
|
|
914
|
+
};
|
|
915
|
+
list.push(item);
|
|
916
|
+
});
|
|
917
|
+
return result;
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
/**
|
|
921
|
+
* Convert icons list from string/icon mix to icons and validate them
|
|
922
|
+
*/
|
|
923
|
+
function listToIcons(list, validate = true, simpleNames = false) {
|
|
924
|
+
const result = [];
|
|
925
|
+
list.forEach((item) => {
|
|
926
|
+
const icon = typeof item === "string" ? stringToIcon(item, validate, simpleNames) : item;
|
|
927
|
+
if (icon) result.push(icon);
|
|
928
|
+
});
|
|
929
|
+
return result;
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
/**
|
|
933
|
+
* Default RedundancyConfig for API calls
|
|
934
|
+
*/
|
|
935
|
+
const defaultConfig = {
|
|
936
|
+
resources: [],
|
|
937
|
+
index: 0,
|
|
938
|
+
timeout: 2e3,
|
|
939
|
+
rotate: 750,
|
|
940
|
+
random: false,
|
|
941
|
+
dataAfterTimeout: false
|
|
942
|
+
};
|
|
943
|
+
/**
|
|
944
|
+
* Send query
|
|
945
|
+
*/
|
|
946
|
+
function sendQuery(config, payload, query, done) {
|
|
947
|
+
const resourcesCount = config.resources.length;
|
|
948
|
+
const startIndex = config.random ? Math.floor(Math.random() * resourcesCount) : config.index;
|
|
949
|
+
let resources;
|
|
950
|
+
if (config.random) {
|
|
951
|
+
let list = config.resources.slice(0);
|
|
952
|
+
resources = [];
|
|
953
|
+
while (list.length > 1) {
|
|
954
|
+
const nextIndex = Math.floor(Math.random() * list.length);
|
|
955
|
+
resources.push(list[nextIndex]);
|
|
956
|
+
list = list.slice(0, nextIndex).concat(list.slice(nextIndex + 1));
|
|
957
|
+
}
|
|
958
|
+
resources = resources.concat(list);
|
|
959
|
+
} else resources = config.resources.slice(startIndex).concat(config.resources.slice(0, startIndex));
|
|
960
|
+
const startTime = Date.now();
|
|
961
|
+
let status = "pending";
|
|
962
|
+
let queriesSent = 0;
|
|
963
|
+
let lastError;
|
|
964
|
+
let timer = null;
|
|
965
|
+
let queue = [];
|
|
966
|
+
let doneCallbacks = [];
|
|
967
|
+
if (typeof done === "function") doneCallbacks.push(done);
|
|
968
|
+
/**
|
|
969
|
+
* Reset timer
|
|
970
|
+
*/
|
|
971
|
+
function resetTimer() {
|
|
972
|
+
if (timer) {
|
|
973
|
+
clearTimeout(timer);
|
|
974
|
+
timer = null;
|
|
975
|
+
}
|
|
976
|
+
}
|
|
977
|
+
/**
|
|
978
|
+
* Abort everything
|
|
979
|
+
*/
|
|
980
|
+
function abort() {
|
|
981
|
+
if (status === "pending") status = "aborted";
|
|
982
|
+
resetTimer();
|
|
983
|
+
queue.forEach((item) => {
|
|
984
|
+
if (item.status === "pending") item.status = "aborted";
|
|
985
|
+
});
|
|
986
|
+
queue = [];
|
|
987
|
+
}
|
|
988
|
+
/**
|
|
989
|
+
* Add / replace callback to call when execution is complete.
|
|
990
|
+
* This can be used to abort pending query implementations when query is complete or aborted.
|
|
991
|
+
*/
|
|
992
|
+
function subscribe(callback, overwrite) {
|
|
993
|
+
if (overwrite) doneCallbacks = [];
|
|
994
|
+
if (typeof callback === "function") doneCallbacks.push(callback);
|
|
995
|
+
}
|
|
996
|
+
/**
|
|
997
|
+
* Get query status
|
|
998
|
+
*/
|
|
999
|
+
function getQueryStatus() {
|
|
1000
|
+
return {
|
|
1001
|
+
startTime,
|
|
1002
|
+
payload,
|
|
1003
|
+
status,
|
|
1004
|
+
queriesSent,
|
|
1005
|
+
queriesPending: queue.length,
|
|
1006
|
+
subscribe,
|
|
1007
|
+
abort
|
|
1008
|
+
};
|
|
1009
|
+
}
|
|
1010
|
+
/**
|
|
1011
|
+
* Fail query
|
|
1012
|
+
*/
|
|
1013
|
+
function failQuery() {
|
|
1014
|
+
status = "failed";
|
|
1015
|
+
doneCallbacks.forEach((callback) => {
|
|
1016
|
+
callback(void 0, lastError);
|
|
1017
|
+
});
|
|
1018
|
+
}
|
|
1019
|
+
/**
|
|
1020
|
+
* Clear queue
|
|
1021
|
+
*/
|
|
1022
|
+
function clearQueue() {
|
|
1023
|
+
queue.forEach((item) => {
|
|
1024
|
+
if (item.status === "pending") item.status = "aborted";
|
|
1025
|
+
});
|
|
1026
|
+
queue = [];
|
|
1027
|
+
}
|
|
1028
|
+
/**
|
|
1029
|
+
* Got response from module
|
|
1030
|
+
*/
|
|
1031
|
+
function moduleResponse(item, response, data) {
|
|
1032
|
+
const isError = response !== "success";
|
|
1033
|
+
queue = queue.filter((queued) => queued !== item);
|
|
1034
|
+
switch (status) {
|
|
1035
|
+
case "pending": break;
|
|
1036
|
+
case "failed":
|
|
1037
|
+
if (isError || !config.dataAfterTimeout) return;
|
|
1038
|
+
break;
|
|
1039
|
+
default: return;
|
|
1040
|
+
}
|
|
1041
|
+
if (response === "abort") {
|
|
1042
|
+
lastError = data;
|
|
1043
|
+
failQuery();
|
|
1044
|
+
return;
|
|
1045
|
+
}
|
|
1046
|
+
if (isError) {
|
|
1047
|
+
lastError = data;
|
|
1048
|
+
if (!queue.length) if (!resources.length) failQuery();
|
|
1049
|
+
else execNext();
|
|
1050
|
+
return;
|
|
1051
|
+
}
|
|
1052
|
+
resetTimer();
|
|
1053
|
+
clearQueue();
|
|
1054
|
+
if (!config.random) {
|
|
1055
|
+
const index = config.resources.indexOf(item.resource);
|
|
1056
|
+
if (index !== -1 && index !== config.index) config.index = index;
|
|
1057
|
+
}
|
|
1058
|
+
status = "completed";
|
|
1059
|
+
doneCallbacks.forEach((callback) => {
|
|
1060
|
+
callback(data);
|
|
1061
|
+
});
|
|
1062
|
+
}
|
|
1063
|
+
/**
|
|
1064
|
+
* Execute next query
|
|
1065
|
+
*/
|
|
1066
|
+
function execNext() {
|
|
1067
|
+
if (status !== "pending") return;
|
|
1068
|
+
resetTimer();
|
|
1069
|
+
const resource = resources.shift();
|
|
1070
|
+
if (resource === void 0) {
|
|
1071
|
+
if (queue.length) {
|
|
1072
|
+
timer = setTimeout(() => {
|
|
1073
|
+
resetTimer();
|
|
1074
|
+
if (status === "pending") {
|
|
1075
|
+
clearQueue();
|
|
1076
|
+
failQuery();
|
|
1077
|
+
}
|
|
1078
|
+
}, config.timeout);
|
|
1079
|
+
return;
|
|
1080
|
+
}
|
|
1081
|
+
failQuery();
|
|
1082
|
+
return;
|
|
1083
|
+
}
|
|
1084
|
+
const item = {
|
|
1085
|
+
status: "pending",
|
|
1086
|
+
resource,
|
|
1087
|
+
callback: (status, data) => {
|
|
1088
|
+
moduleResponse(item, status, data);
|
|
1089
|
+
}
|
|
1090
|
+
};
|
|
1091
|
+
queue.push(item);
|
|
1092
|
+
queriesSent++;
|
|
1093
|
+
timer = setTimeout(execNext, config.rotate);
|
|
1094
|
+
query(resource, payload, item.callback);
|
|
1095
|
+
}
|
|
1096
|
+
setTimeout(execNext);
|
|
1097
|
+
return getQueryStatus;
|
|
1098
|
+
}
|
|
1099
|
+
/**
|
|
1100
|
+
* Redundancy instance
|
|
1101
|
+
*/
|
|
1102
|
+
function initRedundancy(cfg) {
|
|
1103
|
+
const config = {
|
|
1104
|
+
...defaultConfig,
|
|
1105
|
+
...cfg
|
|
1106
|
+
};
|
|
1107
|
+
let queries = [];
|
|
1108
|
+
/**
|
|
1109
|
+
* Remove aborted and completed queries
|
|
1110
|
+
*/
|
|
1111
|
+
function cleanup() {
|
|
1112
|
+
queries = queries.filter((item) => item().status === "pending");
|
|
1113
|
+
}
|
|
1114
|
+
/**
|
|
1115
|
+
* Send query
|
|
1116
|
+
*/
|
|
1117
|
+
function query(payload, queryCallback, doneCallback) {
|
|
1118
|
+
const query = sendQuery(config, payload, queryCallback, (data, error) => {
|
|
1119
|
+
cleanup();
|
|
1120
|
+
if (doneCallback) doneCallback(data, error);
|
|
1121
|
+
});
|
|
1122
|
+
queries.push(query);
|
|
1123
|
+
return query;
|
|
1124
|
+
}
|
|
1125
|
+
/**
|
|
1126
|
+
* Find instance
|
|
1127
|
+
*/
|
|
1128
|
+
function find(callback) {
|
|
1129
|
+
return queries.find((value) => {
|
|
1130
|
+
return callback(value);
|
|
1131
|
+
}) || null;
|
|
1132
|
+
}
|
|
1133
|
+
return {
|
|
1134
|
+
query,
|
|
1135
|
+
find,
|
|
1136
|
+
setIndex: (index) => {
|
|
1137
|
+
config.index = index;
|
|
1138
|
+
},
|
|
1139
|
+
getIndex: () => config.index,
|
|
1140
|
+
cleanup
|
|
1141
|
+
};
|
|
1142
|
+
}
|
|
1143
|
+
|
|
1144
|
+
function emptyCallback$1() {}
|
|
1145
|
+
const redundancyCache = Object.create(null);
|
|
1146
|
+
/**
|
|
1147
|
+
* Get Redundancy instance for provider
|
|
1148
|
+
*/
|
|
1149
|
+
function getRedundancyCache(provider) {
|
|
1150
|
+
if (!redundancyCache[provider]) {
|
|
1151
|
+
const config = getAPIConfig(provider);
|
|
1152
|
+
if (!config) return;
|
|
1153
|
+
redundancyCache[provider] = {
|
|
1154
|
+
config,
|
|
1155
|
+
redundancy: initRedundancy(config)
|
|
1156
|
+
};
|
|
1157
|
+
}
|
|
1158
|
+
return redundancyCache[provider];
|
|
1159
|
+
}
|
|
1160
|
+
/**
|
|
1161
|
+
* Send API query
|
|
1162
|
+
*/
|
|
1163
|
+
function sendAPIQuery(target, query, callback) {
|
|
1164
|
+
let redundancy;
|
|
1165
|
+
let send;
|
|
1166
|
+
if (typeof target === "string") {
|
|
1167
|
+
const api = getAPIModule(target);
|
|
1168
|
+
if (!api) {
|
|
1169
|
+
callback(void 0, 424);
|
|
1170
|
+
return emptyCallback$1;
|
|
1171
|
+
}
|
|
1172
|
+
send = api.send;
|
|
1173
|
+
const cached = getRedundancyCache(target);
|
|
1174
|
+
if (cached) redundancy = cached.redundancy;
|
|
1175
|
+
} else {
|
|
1176
|
+
const config = createAPIConfig(target);
|
|
1177
|
+
if (config) {
|
|
1178
|
+
redundancy = initRedundancy(config);
|
|
1179
|
+
const api = getAPIModule(target.resources ? target.resources[0] : "");
|
|
1180
|
+
if (api) send = api.send;
|
|
1181
|
+
}
|
|
1182
|
+
}
|
|
1183
|
+
if (!redundancy || !send) {
|
|
1184
|
+
callback(void 0, 424);
|
|
1185
|
+
return emptyCallback$1;
|
|
1186
|
+
}
|
|
1187
|
+
return redundancy.query(query, send, callback)().abort;
|
|
1188
|
+
}
|
|
1189
|
+
|
|
1190
|
+
function emptyCallback() {}
|
|
1191
|
+
/**
|
|
1192
|
+
* Function called when new icons have been loaded
|
|
1193
|
+
*/
|
|
1194
|
+
function loadedNewIcons(storage) {
|
|
1195
|
+
if (!storage.iconsLoaderFlag) {
|
|
1196
|
+
storage.iconsLoaderFlag = true;
|
|
1197
|
+
setTimeout(() => {
|
|
1198
|
+
storage.iconsLoaderFlag = false;
|
|
1199
|
+
updateCallbacks(storage);
|
|
1200
|
+
});
|
|
1201
|
+
}
|
|
1202
|
+
}
|
|
1203
|
+
/**
|
|
1204
|
+
* Check icon names for API
|
|
1205
|
+
*/
|
|
1206
|
+
function checkIconNamesForAPI(icons) {
|
|
1207
|
+
const valid = [];
|
|
1208
|
+
const invalid = [];
|
|
1209
|
+
icons.forEach((name) => {
|
|
1210
|
+
(name.match(matchIconName) ? valid : invalid).push(name);
|
|
1211
|
+
});
|
|
1212
|
+
return {
|
|
1213
|
+
valid,
|
|
1214
|
+
invalid
|
|
1215
|
+
};
|
|
1216
|
+
}
|
|
1217
|
+
/**
|
|
1218
|
+
* Parse loader response
|
|
1219
|
+
*/
|
|
1220
|
+
function parseLoaderResponse(storage, icons, data) {
|
|
1221
|
+
function checkMissing() {
|
|
1222
|
+
const pending = storage.pendingIcons;
|
|
1223
|
+
icons.forEach((name) => {
|
|
1224
|
+
if (pending) pending.delete(name);
|
|
1225
|
+
if (!storage.icons[name]) storage.missing.add(name);
|
|
1226
|
+
});
|
|
1227
|
+
}
|
|
1228
|
+
if (data && typeof data === "object") try {
|
|
1229
|
+
if (!addIconSet(storage, data).length) {
|
|
1230
|
+
checkMissing();
|
|
1231
|
+
return;
|
|
1232
|
+
}
|
|
1233
|
+
} catch (err) {
|
|
1234
|
+
console.error(err);
|
|
1235
|
+
}
|
|
1236
|
+
checkMissing();
|
|
1237
|
+
loadedNewIcons(storage);
|
|
1238
|
+
}
|
|
1239
|
+
/**
|
|
1240
|
+
* Handle response that can be async
|
|
1241
|
+
*/
|
|
1242
|
+
function parsePossiblyAsyncResponse(response, callback) {
|
|
1243
|
+
if (response instanceof Promise) response.then((data) => {
|
|
1244
|
+
callback(data);
|
|
1245
|
+
}).catch(() => {
|
|
1246
|
+
callback(null);
|
|
1247
|
+
});
|
|
1248
|
+
else callback(response);
|
|
1249
|
+
}
|
|
1250
|
+
/**
|
|
1251
|
+
* Load icons
|
|
1252
|
+
*/
|
|
1253
|
+
function loadNewIcons(storage, icons) {
|
|
1254
|
+
if (!storage.iconsToLoad) storage.iconsToLoad = icons;
|
|
1255
|
+
else storage.iconsToLoad = storage.iconsToLoad.concat(icons).sort();
|
|
1256
|
+
if (!storage.iconsQueueFlag) {
|
|
1257
|
+
storage.iconsQueueFlag = true;
|
|
1258
|
+
setTimeout(() => {
|
|
1259
|
+
storage.iconsQueueFlag = false;
|
|
1260
|
+
const { provider, prefix } = storage;
|
|
1261
|
+
const icons = storage.iconsToLoad;
|
|
1262
|
+
delete storage.iconsToLoad;
|
|
1263
|
+
if (!icons || !icons.length) return;
|
|
1264
|
+
const customIconLoader = storage.loadIcon;
|
|
1265
|
+
if (storage.loadIcons && (icons.length > 1 || !customIconLoader)) {
|
|
1266
|
+
parsePossiblyAsyncResponse(storage.loadIcons(icons, prefix, provider), (data) => {
|
|
1267
|
+
parseLoaderResponse(storage, icons, data);
|
|
1268
|
+
});
|
|
1269
|
+
return;
|
|
1270
|
+
}
|
|
1271
|
+
if (customIconLoader) {
|
|
1272
|
+
icons.forEach((name) => {
|
|
1273
|
+
parsePossiblyAsyncResponse(customIconLoader(name, prefix, provider), (data) => {
|
|
1274
|
+
parseLoaderResponse(storage, [name], data ? {
|
|
1275
|
+
prefix,
|
|
1276
|
+
icons: { [name]: data }
|
|
1277
|
+
} : null);
|
|
1278
|
+
});
|
|
1279
|
+
});
|
|
1280
|
+
return;
|
|
1281
|
+
}
|
|
1282
|
+
const { valid, invalid } = checkIconNamesForAPI(icons);
|
|
1283
|
+
if (invalid.length) parseLoaderResponse(storage, invalid, null);
|
|
1284
|
+
if (!valid.length) return;
|
|
1285
|
+
const api = prefix.match(matchIconName) ? getAPIModule(provider) : null;
|
|
1286
|
+
if (!api) {
|
|
1287
|
+
parseLoaderResponse(storage, valid, null);
|
|
1288
|
+
return;
|
|
1289
|
+
}
|
|
1290
|
+
api.prepare(provider, prefix, valid).forEach((item) => {
|
|
1291
|
+
sendAPIQuery(provider, item, (data) => {
|
|
1292
|
+
parseLoaderResponse(storage, item.icons, data);
|
|
1293
|
+
});
|
|
1294
|
+
});
|
|
1295
|
+
});
|
|
1296
|
+
}
|
|
1297
|
+
}
|
|
1298
|
+
/**
|
|
1299
|
+
* Load icons
|
|
1300
|
+
*/
|
|
1301
|
+
const loadIcons = (icons, callback) => {
|
|
1302
|
+
const sortedIcons = sortIcons(listToIcons(icons, true, allowSimpleNames()));
|
|
1303
|
+
if (!sortedIcons.pending.length) {
|
|
1304
|
+
let callCallback = true;
|
|
1305
|
+
if (callback) setTimeout(() => {
|
|
1306
|
+
if (callCallback) callback(sortedIcons.loaded, sortedIcons.missing, sortedIcons.pending, emptyCallback);
|
|
1307
|
+
});
|
|
1308
|
+
return () => {
|
|
1309
|
+
callCallback = false;
|
|
1310
|
+
};
|
|
1311
|
+
}
|
|
1312
|
+
const newIcons = Object.create(null);
|
|
1313
|
+
const sources = [];
|
|
1314
|
+
let lastProvider, lastPrefix;
|
|
1315
|
+
sortedIcons.pending.forEach((icon) => {
|
|
1316
|
+
const { provider, prefix } = icon;
|
|
1317
|
+
if (prefix === lastPrefix && provider === lastProvider) return;
|
|
1318
|
+
lastProvider = provider;
|
|
1319
|
+
lastPrefix = prefix;
|
|
1320
|
+
sources.push(getStorage(provider, prefix));
|
|
1321
|
+
const providerNewIcons = newIcons[provider] || (newIcons[provider] = Object.create(null));
|
|
1322
|
+
if (!providerNewIcons[prefix]) providerNewIcons[prefix] = [];
|
|
1323
|
+
});
|
|
1324
|
+
sortedIcons.pending.forEach((icon) => {
|
|
1325
|
+
const { provider, prefix, name } = icon;
|
|
1326
|
+
const storage = getStorage(provider, prefix);
|
|
1327
|
+
const pendingQueue = storage.pendingIcons || (storage.pendingIcons = /* @__PURE__ */ new Set());
|
|
1328
|
+
if (!pendingQueue.has(name)) {
|
|
1329
|
+
pendingQueue.add(name);
|
|
1330
|
+
newIcons[provider][prefix].push(name);
|
|
1331
|
+
}
|
|
1332
|
+
});
|
|
1333
|
+
sources.forEach((storage) => {
|
|
1334
|
+
const list = newIcons[storage.provider][storage.prefix];
|
|
1335
|
+
if (list.length) loadNewIcons(storage, list);
|
|
1336
|
+
});
|
|
1337
|
+
return callback ? storeCallback(callback, sortedIcons, sources) : emptyCallback;
|
|
1338
|
+
};
|
|
1339
|
+
/**
|
|
1340
|
+
* Load one icon using Promise
|
|
1341
|
+
*/
|
|
1342
|
+
const loadIcon = (icon) => {
|
|
1343
|
+
return new Promise((fulfill, reject) => {
|
|
1344
|
+
const iconObj = typeof icon === "string" ? stringToIcon(icon, true) : icon;
|
|
1345
|
+
if (!iconObj) {
|
|
1346
|
+
reject(icon);
|
|
1347
|
+
return;
|
|
1348
|
+
}
|
|
1349
|
+
loadIcons([iconObj || icon], (loaded) => {
|
|
1350
|
+
if (loaded.length && iconObj) {
|
|
1351
|
+
const data = getIconData(iconObj);
|
|
1352
|
+
if (data) {
|
|
1353
|
+
fulfill({
|
|
1354
|
+
...defaultIconProps,
|
|
1355
|
+
...data
|
|
1356
|
+
});
|
|
1357
|
+
return;
|
|
1358
|
+
}
|
|
1359
|
+
}
|
|
1360
|
+
reject(icon);
|
|
1361
|
+
});
|
|
1362
|
+
});
|
|
1363
|
+
};
|
|
1364
|
+
|
|
1365
|
+
/**
|
|
1366
|
+
* Set custom loader for multiple icons
|
|
1367
|
+
*/
|
|
1368
|
+
function setCustomIconsLoader(loader, prefix, provider) {
|
|
1369
|
+
getStorage(provider || "", prefix).loadIcons = loader;
|
|
1370
|
+
}
|
|
1371
|
+
/**
|
|
1372
|
+
* Set custom loader for one icon
|
|
1373
|
+
*/
|
|
1374
|
+
function setCustomIconLoader(loader, prefix, provider) {
|
|
1375
|
+
getStorage(provider || "", prefix).loadIcon = loader;
|
|
1376
|
+
}
|
|
1377
|
+
|
|
1378
|
+
/**
|
|
1379
|
+
* Convert IconifyIconCustomisations to FullIconCustomisations, checking value types
|
|
1380
|
+
*/
|
|
1381
|
+
function mergeCustomisations(defaults, item) {
|
|
1382
|
+
const result = { ...defaults };
|
|
1383
|
+
for (const key in item) {
|
|
1384
|
+
const value = item[key];
|
|
1385
|
+
const valueType = typeof value;
|
|
1386
|
+
if (key in defaultIconSizeCustomisations) {
|
|
1387
|
+
if (value === null || value && (valueType === "string" || valueType === "number")) result[key] = value;
|
|
1388
|
+
} else if (valueType === typeof result[key]) result[key] = key === "rotate" ? value % 4 : value;
|
|
1389
|
+
}
|
|
1390
|
+
return result;
|
|
1391
|
+
}
|
|
1392
|
+
|
|
1393
|
+
const separator = /[\s,]+/;
|
|
1394
|
+
/**
|
|
1395
|
+
* Apply "flip" string to icon customisations
|
|
1396
|
+
*/
|
|
1397
|
+
function flipFromString(custom, flip) {
|
|
1398
|
+
flip.split(separator).forEach((str) => {
|
|
1399
|
+
switch (str.trim()) {
|
|
1400
|
+
case "horizontal":
|
|
1401
|
+
custom.hFlip = true;
|
|
1402
|
+
break;
|
|
1403
|
+
case "vertical":
|
|
1404
|
+
custom.vFlip = true;
|
|
1405
|
+
break;
|
|
1406
|
+
}
|
|
1407
|
+
});
|
|
1408
|
+
}
|
|
1409
|
+
|
|
1410
|
+
/**
|
|
1411
|
+
* Get rotation value
|
|
1412
|
+
*/
|
|
1413
|
+
function rotateFromString(value, defaultValue = 0) {
|
|
1414
|
+
const units = value.replace(/^-?[0-9.]*/, "");
|
|
1415
|
+
function cleanup(value) {
|
|
1416
|
+
while (value < 0) value += 4;
|
|
1417
|
+
return value % 4;
|
|
1418
|
+
}
|
|
1419
|
+
if (units === "") {
|
|
1420
|
+
const num = parseInt(value);
|
|
1421
|
+
return isNaN(num) ? 0 : cleanup(num);
|
|
1422
|
+
} else if (units !== value) {
|
|
1423
|
+
let split = 0;
|
|
1424
|
+
switch (units) {
|
|
1425
|
+
case "%":
|
|
1426
|
+
split = 25;
|
|
1427
|
+
break;
|
|
1428
|
+
case "deg": split = 90;
|
|
1429
|
+
}
|
|
1430
|
+
if (split) {
|
|
1431
|
+
let num = parseFloat(value.slice(0, value.length - units.length));
|
|
1432
|
+
if (isNaN(num)) return 0;
|
|
1433
|
+
num = num / split;
|
|
1434
|
+
return num % 1 === 0 ? cleanup(num) : 0;
|
|
1435
|
+
}
|
|
1436
|
+
}
|
|
1437
|
+
return defaultValue;
|
|
1438
|
+
}
|
|
1439
|
+
|
|
1440
|
+
/**
|
|
1441
|
+
* Generate <svg>
|
|
1442
|
+
*/
|
|
1443
|
+
function iconToHTML(body, attributes) {
|
|
1444
|
+
let renderAttribsHTML = body.indexOf("xlink:") === -1 ? "" : " xmlns:xlink=\"http://www.w3.org/1999/xlink\"";
|
|
1445
|
+
for (const attr in attributes) renderAttribsHTML += " " + attr + "=\"" + attributes[attr] + "\"";
|
|
1446
|
+
return "<svg xmlns=\"http://www.w3.org/2000/svg\"" + renderAttribsHTML + ">" + body + "</svg>";
|
|
1447
|
+
}
|
|
1448
|
+
|
|
1449
|
+
/**
|
|
1450
|
+
* Encode SVG for use in url()
|
|
1451
|
+
*
|
|
1452
|
+
* Short alternative to encodeURIComponent() that encodes only stuff used in SVG, generating
|
|
1453
|
+
* smaller code.
|
|
1454
|
+
*/
|
|
1455
|
+
function encodeSVGforURL(svg) {
|
|
1456
|
+
return svg.replace(/"/g, "'").replace(/%/g, "%25").replace(/#/g, "%23").replace(/</g, "%3C").replace(/>/g, "%3E").replace(/\s+/g, " ");
|
|
1457
|
+
}
|
|
1458
|
+
/**
|
|
1459
|
+
* Generate data: URL from SVG
|
|
1460
|
+
*/
|
|
1461
|
+
function svgToData(svg) {
|
|
1462
|
+
return "data:image/svg+xml," + encodeSVGforURL(svg);
|
|
1463
|
+
}
|
|
1464
|
+
/**
|
|
1465
|
+
* Generate url() from SVG
|
|
1466
|
+
*/
|
|
1467
|
+
function svgToURL(svg) {
|
|
1468
|
+
return "url(\"" + svgToData(svg) + "\")";
|
|
1469
|
+
}
|
|
1470
|
+
|
|
1471
|
+
const defaultExtendedIconCustomisations = {
|
|
1472
|
+
...defaultIconCustomisations,
|
|
1473
|
+
inline: false,
|
|
1474
|
+
};
|
|
1475
|
+
|
|
1476
|
+
/**
|
|
1477
|
+
* Default SVG attributes
|
|
1478
|
+
*/
|
|
1479
|
+
const svgDefaults = {
|
|
1480
|
+
'xmlns': 'http://www.w3.org/2000/svg',
|
|
1481
|
+
'xmlns:xlink': 'http://www.w3.org/1999/xlink',
|
|
1482
|
+
'aria-hidden': true,
|
|
1483
|
+
'role': 'img',
|
|
1484
|
+
};
|
|
1485
|
+
/**
|
|
1486
|
+
* Style modes
|
|
1487
|
+
*/
|
|
1488
|
+
const commonProps = {
|
|
1489
|
+
display: 'inline-block',
|
|
1490
|
+
};
|
|
1491
|
+
const monotoneProps = {
|
|
1492
|
+
backgroundColor: 'currentColor',
|
|
1493
|
+
};
|
|
1494
|
+
const coloredProps = {
|
|
1495
|
+
backgroundColor: 'transparent',
|
|
1496
|
+
};
|
|
1497
|
+
// Dynamically add common props to variables above
|
|
1498
|
+
const propsToAdd = {
|
|
1499
|
+
Image: 'var(--svg)',
|
|
1500
|
+
Repeat: 'no-repeat',
|
|
1501
|
+
Size: '100% 100%',
|
|
1502
|
+
};
|
|
1503
|
+
const propsToAddTo = {
|
|
1504
|
+
webkitMask: monotoneProps,
|
|
1505
|
+
mask: monotoneProps,
|
|
1506
|
+
background: coloredProps,
|
|
1507
|
+
};
|
|
1508
|
+
for (const prefix in propsToAddTo) {
|
|
1509
|
+
const list = propsToAddTo[prefix];
|
|
1510
|
+
for (const prop in propsToAdd) {
|
|
1511
|
+
list[prefix + prop] = propsToAdd[prop];
|
|
1512
|
+
}
|
|
1513
|
+
}
|
|
1514
|
+
/**
|
|
1515
|
+
* Aliases for customisations.
|
|
1516
|
+
* In Vue 'v-' properties are reserved, so v-flip must be renamed
|
|
1517
|
+
*/
|
|
1518
|
+
const customisationAliases = {};
|
|
1519
|
+
['horizontal', 'vertical'].forEach((prefix) => {
|
|
1520
|
+
const attr = prefix.slice(0, 1) + 'Flip';
|
|
1521
|
+
// vertical-flip
|
|
1522
|
+
customisationAliases[prefix + '-flip'] = attr;
|
|
1523
|
+
// v-flip
|
|
1524
|
+
customisationAliases[prefix.slice(0, 1) + '-flip'] = attr;
|
|
1525
|
+
// verticalFlip
|
|
1526
|
+
customisationAliases[prefix + 'Flip'] = attr;
|
|
1527
|
+
});
|
|
1528
|
+
/**
|
|
1529
|
+
* Fix size: add 'px' to numbers
|
|
1530
|
+
*/
|
|
1531
|
+
function fixSize(value) {
|
|
1532
|
+
return value + (value.match(/^[-0-9.]+$/) ? 'px' : '');
|
|
1533
|
+
}
|
|
1534
|
+
/**
|
|
1535
|
+
* Render icon
|
|
1536
|
+
*/
|
|
1537
|
+
const render = (
|
|
1538
|
+
// Icon must be validated before calling this function
|
|
1539
|
+
icon,
|
|
1540
|
+
// Partial properties
|
|
1541
|
+
props) => {
|
|
1542
|
+
// Split properties
|
|
1543
|
+
const customisations = mergeCustomisations(defaultExtendedIconCustomisations, props);
|
|
1544
|
+
const componentProps = { ...svgDefaults };
|
|
1545
|
+
// Check mode
|
|
1546
|
+
const mode = props.mode || 'svg';
|
|
1547
|
+
// Copy style
|
|
1548
|
+
const style = {};
|
|
1549
|
+
const propsStyle = props.style;
|
|
1550
|
+
const customStyle = typeof propsStyle === 'object' && !(propsStyle instanceof Array)
|
|
1551
|
+
? propsStyle
|
|
1552
|
+
: {};
|
|
1553
|
+
// Get element properties
|
|
1554
|
+
for (let key in props) {
|
|
1555
|
+
const value = props[key];
|
|
1556
|
+
if (value === void 0) {
|
|
1557
|
+
continue;
|
|
1558
|
+
}
|
|
1559
|
+
switch (key) {
|
|
1560
|
+
// Properties to ignore
|
|
1561
|
+
case 'icon':
|
|
1562
|
+
case 'style':
|
|
1563
|
+
case 'onLoad':
|
|
1564
|
+
case 'mode':
|
|
1565
|
+
case 'ssr':
|
|
1566
|
+
case 'customise':
|
|
1567
|
+
break;
|
|
1568
|
+
// Boolean attributes
|
|
1569
|
+
case 'inline':
|
|
1570
|
+
case 'hFlip':
|
|
1571
|
+
case 'vFlip':
|
|
1572
|
+
customisations[key] =
|
|
1573
|
+
value === true || value === 'true' || value === 1;
|
|
1574
|
+
break;
|
|
1575
|
+
// Flip as string: 'horizontal,vertical'
|
|
1576
|
+
case 'flip':
|
|
1577
|
+
if (typeof value === 'string') {
|
|
1578
|
+
flipFromString(customisations, value);
|
|
1579
|
+
}
|
|
1580
|
+
break;
|
|
1581
|
+
// Color: override style
|
|
1582
|
+
case 'color':
|
|
1583
|
+
style.color = value;
|
|
1584
|
+
break;
|
|
1585
|
+
// Rotation as string
|
|
1586
|
+
case 'rotate':
|
|
1587
|
+
if (typeof value === 'string') {
|
|
1588
|
+
customisations[key] = rotateFromString(value);
|
|
1589
|
+
}
|
|
1590
|
+
else if (typeof value === 'number') {
|
|
1591
|
+
customisations[key] = value;
|
|
1592
|
+
}
|
|
1593
|
+
break;
|
|
1594
|
+
// Remove aria-hidden
|
|
1595
|
+
case 'ariaHidden':
|
|
1596
|
+
case 'aria-hidden':
|
|
1597
|
+
// Vue transforms 'aria-hidden' property to 'ariaHidden'
|
|
1598
|
+
if (value !== true && value !== 'true') {
|
|
1599
|
+
delete componentProps['aria-hidden'];
|
|
1600
|
+
}
|
|
1601
|
+
break;
|
|
1602
|
+
default: {
|
|
1603
|
+
const alias = customisationAliases[key];
|
|
1604
|
+
if (alias) {
|
|
1605
|
+
// Aliases for boolean customisations
|
|
1606
|
+
if (value === true || value === 'true' || value === 1) {
|
|
1607
|
+
customisations[alias] = true;
|
|
1608
|
+
}
|
|
1609
|
+
}
|
|
1610
|
+
else if (defaultExtendedIconCustomisations[key] === void 0) {
|
|
1611
|
+
// Copy missing property if it does not exist in customisations
|
|
1612
|
+
componentProps[key] = value;
|
|
1613
|
+
}
|
|
1614
|
+
}
|
|
1615
|
+
}
|
|
1616
|
+
}
|
|
1617
|
+
// Generate icon
|
|
1618
|
+
const item = iconToSVG(icon, customisations);
|
|
1619
|
+
const renderAttribs = item.attributes;
|
|
1620
|
+
// Inline display
|
|
1621
|
+
if (customisations.inline) {
|
|
1622
|
+
style.verticalAlign = '-0.125em';
|
|
1623
|
+
}
|
|
1624
|
+
if (mode === 'svg') {
|
|
1625
|
+
// Add style
|
|
1626
|
+
componentProps.style = {
|
|
1627
|
+
...style,
|
|
1628
|
+
...customStyle,
|
|
1629
|
+
};
|
|
1630
|
+
// Add icon stuff
|
|
1631
|
+
Object.assign(componentProps, renderAttribs);
|
|
1632
|
+
// Add innerHTML and style to props
|
|
1633
|
+
componentProps['innerHTML'] = replaceIDs(item.body);
|
|
1634
|
+
// Render icon
|
|
1635
|
+
return h('svg', componentProps);
|
|
1636
|
+
}
|
|
1637
|
+
// Render <span> with style
|
|
1638
|
+
const { body, width, height } = icon;
|
|
1639
|
+
const useMask = mode === 'mask' ||
|
|
1640
|
+
(mode === 'bg' ? false : body.indexOf('currentColor') !== -1);
|
|
1641
|
+
// Generate SVG
|
|
1642
|
+
const html = iconToHTML(body, {
|
|
1643
|
+
...renderAttribs,
|
|
1644
|
+
width: width + '',
|
|
1645
|
+
height: height + '',
|
|
1646
|
+
});
|
|
1647
|
+
// Generate style
|
|
1648
|
+
componentProps.style = {
|
|
1649
|
+
...style,
|
|
1650
|
+
'--svg': svgToURL(html),
|
|
1651
|
+
'width': fixSize(renderAttribs.width),
|
|
1652
|
+
'height': fixSize(renderAttribs.height),
|
|
1653
|
+
...commonProps,
|
|
1654
|
+
...(useMask ? monotoneProps : coloredProps),
|
|
1655
|
+
...customStyle,
|
|
1656
|
+
};
|
|
1657
|
+
return h('span', componentProps);
|
|
1658
|
+
};
|
|
1659
|
+
|
|
1660
|
+
/**
|
|
1661
|
+
* Initialise stuff
|
|
1662
|
+
*/
|
|
1663
|
+
// Enable short names
|
|
1664
|
+
allowSimpleNames(true);
|
|
1665
|
+
// Set API module
|
|
1666
|
+
setAPIModule('', fetchAPIModule);
|
|
1667
|
+
/**
|
|
1668
|
+
* Browser stuff
|
|
1669
|
+
*/
|
|
1670
|
+
if (typeof document !== 'undefined' && typeof window !== 'undefined') {
|
|
1671
|
+
const _window = window;
|
|
1672
|
+
// Load icons from global "IconifyPreload"
|
|
1673
|
+
if (_window.IconifyPreload !== void 0) {
|
|
1674
|
+
const preload = _window.IconifyPreload;
|
|
1675
|
+
const err = 'Invalid IconifyPreload syntax.';
|
|
1676
|
+
if (typeof preload === 'object' && preload !== null) {
|
|
1677
|
+
(preload instanceof Array ? preload : [preload]).forEach((item) => {
|
|
1678
|
+
try {
|
|
1679
|
+
if (
|
|
1680
|
+
// Check if item is an object and not null/array
|
|
1681
|
+
typeof item !== 'object' ||
|
|
1682
|
+
item === null ||
|
|
1683
|
+
item instanceof Array ||
|
|
1684
|
+
// Check for 'icons' and 'prefix'
|
|
1685
|
+
typeof item.icons !== 'object' ||
|
|
1686
|
+
typeof item.prefix !== 'string' ||
|
|
1687
|
+
// Add icon set
|
|
1688
|
+
!addCollection(item)) {
|
|
1689
|
+
console.error(err);
|
|
1690
|
+
}
|
|
1691
|
+
}
|
|
1692
|
+
catch (e) {
|
|
1693
|
+
console.error(err);
|
|
1694
|
+
}
|
|
1695
|
+
});
|
|
1696
|
+
}
|
|
1697
|
+
}
|
|
1698
|
+
// Set API from global "IconifyProviders"
|
|
1699
|
+
if (_window.IconifyProviders !== void 0) {
|
|
1700
|
+
const providers = _window.IconifyProviders;
|
|
1701
|
+
if (typeof providers === 'object' && providers !== null) {
|
|
1702
|
+
for (let key in providers) {
|
|
1703
|
+
const err = 'IconifyProviders[' + key + '] is invalid.';
|
|
1704
|
+
try {
|
|
1705
|
+
const value = providers[key];
|
|
1706
|
+
if (typeof value !== 'object' ||
|
|
1707
|
+
!value ||
|
|
1708
|
+
value.resources === void 0) {
|
|
1709
|
+
continue;
|
|
1710
|
+
}
|
|
1711
|
+
if (!addAPIProvider(key, value)) {
|
|
1712
|
+
console.error(err);
|
|
1713
|
+
}
|
|
1714
|
+
}
|
|
1715
|
+
catch (e) {
|
|
1716
|
+
console.error(err);
|
|
1717
|
+
}
|
|
1718
|
+
}
|
|
1719
|
+
}
|
|
1720
|
+
}
|
|
1721
|
+
}
|
|
1722
|
+
/**
|
|
1723
|
+
* Empty icon data, rendered when icon is not available
|
|
1724
|
+
*/
|
|
1725
|
+
const emptyIcon = {
|
|
1726
|
+
...defaultIconProps,
|
|
1727
|
+
body: '',
|
|
1728
|
+
};
|
|
1729
|
+
/**
|
|
1730
|
+
* Component
|
|
1731
|
+
*/
|
|
1732
|
+
const Icon = defineComponent((props, { emit }) => {
|
|
1733
|
+
const loader = ref(null);
|
|
1734
|
+
function abortLoading() {
|
|
1735
|
+
if (loader.value) {
|
|
1736
|
+
loader.value.abort?.();
|
|
1737
|
+
loader.value = null;
|
|
1738
|
+
}
|
|
1739
|
+
}
|
|
1740
|
+
// Render state
|
|
1741
|
+
const rendering = ref(!!props.ssr);
|
|
1742
|
+
const lastRenderedIconName = ref('');
|
|
1743
|
+
const iconData = shallowRef(null);
|
|
1744
|
+
// Update icon data
|
|
1745
|
+
function getIcon() {
|
|
1746
|
+
const icon = props.icon;
|
|
1747
|
+
// Icon is an object
|
|
1748
|
+
if (typeof icon === 'object' &&
|
|
1749
|
+
icon !== null &&
|
|
1750
|
+
typeof icon.body === 'string') {
|
|
1751
|
+
lastRenderedIconName.value = '';
|
|
1752
|
+
return {
|
|
1753
|
+
data: icon,
|
|
1754
|
+
};
|
|
1755
|
+
}
|
|
1756
|
+
// Check for valid icon name
|
|
1757
|
+
let iconName;
|
|
1758
|
+
if (typeof icon !== 'string' ||
|
|
1759
|
+
(iconName = stringToIcon(icon, false, true)) === null) {
|
|
1760
|
+
return null;
|
|
1761
|
+
}
|
|
1762
|
+
// Load icon
|
|
1763
|
+
let data = getIconData(iconName);
|
|
1764
|
+
if (!data) {
|
|
1765
|
+
// Icon data is not available
|
|
1766
|
+
const oldState = loader.value;
|
|
1767
|
+
if (!oldState || oldState.name !== icon) {
|
|
1768
|
+
// Icon name does not match old loader state
|
|
1769
|
+
if (data === null) {
|
|
1770
|
+
// Failed to load
|
|
1771
|
+
loader.value = {
|
|
1772
|
+
name: icon,
|
|
1773
|
+
};
|
|
1774
|
+
}
|
|
1775
|
+
else {
|
|
1776
|
+
loader.value = {
|
|
1777
|
+
name: icon,
|
|
1778
|
+
abort: loadIcons([iconName], updateIconData),
|
|
1779
|
+
};
|
|
1780
|
+
}
|
|
1781
|
+
}
|
|
1782
|
+
return null;
|
|
1783
|
+
}
|
|
1784
|
+
// Icon data is available
|
|
1785
|
+
abortLoading();
|
|
1786
|
+
if (lastRenderedIconName.value !== icon) {
|
|
1787
|
+
lastRenderedIconName.value = icon;
|
|
1788
|
+
// Emit on next tick because render will be called on next tick
|
|
1789
|
+
nextTick(() => {
|
|
1790
|
+
emit('load', icon);
|
|
1791
|
+
});
|
|
1792
|
+
}
|
|
1793
|
+
// Customise icon
|
|
1794
|
+
const customise = props.customise;
|
|
1795
|
+
if (customise) {
|
|
1796
|
+
// Clone data and customise it
|
|
1797
|
+
data = Object.assign({}, data);
|
|
1798
|
+
const customised = customise(data.body, iconName.name, iconName.prefix, iconName.provider);
|
|
1799
|
+
if (typeof customised === 'string') {
|
|
1800
|
+
data.body = customised;
|
|
1801
|
+
}
|
|
1802
|
+
}
|
|
1803
|
+
// Add classes
|
|
1804
|
+
const classes = ['iconify'];
|
|
1805
|
+
if (iconName.prefix !== '') {
|
|
1806
|
+
classes.push('iconify--' + iconName.prefix);
|
|
1807
|
+
}
|
|
1808
|
+
if (iconName.provider !== '') {
|
|
1809
|
+
classes.push('iconify--' + iconName.provider);
|
|
1810
|
+
}
|
|
1811
|
+
return { data, classes };
|
|
1812
|
+
}
|
|
1813
|
+
function updateIconData() {
|
|
1814
|
+
const icon = getIcon();
|
|
1815
|
+
if (!icon) {
|
|
1816
|
+
iconData.value = null;
|
|
1817
|
+
}
|
|
1818
|
+
else if (icon.data !== iconData.value?.data) {
|
|
1819
|
+
iconData.value = icon;
|
|
1820
|
+
}
|
|
1821
|
+
}
|
|
1822
|
+
// Set icon data
|
|
1823
|
+
if (rendering.value) {
|
|
1824
|
+
updateIconData();
|
|
1825
|
+
}
|
|
1826
|
+
else {
|
|
1827
|
+
onMounted(() => {
|
|
1828
|
+
rendering.value = true;
|
|
1829
|
+
updateIconData();
|
|
1830
|
+
});
|
|
1831
|
+
}
|
|
1832
|
+
watch(() => props.icon, updateIconData);
|
|
1833
|
+
// Abort loading on unmount
|
|
1834
|
+
onUnmounted(abortLoading);
|
|
1835
|
+
// Render function
|
|
1836
|
+
return () => {
|
|
1837
|
+
// Get icon data
|
|
1838
|
+
const icon = iconData.value;
|
|
1839
|
+
if (!icon) {
|
|
1840
|
+
// Icon is not available
|
|
1841
|
+
return render(emptyIcon, props);
|
|
1842
|
+
}
|
|
1843
|
+
// Add classes
|
|
1844
|
+
let newProps = props;
|
|
1845
|
+
if (icon.classes) {
|
|
1846
|
+
newProps = {
|
|
1847
|
+
...props,
|
|
1848
|
+
class: icon.classes.join(' '),
|
|
1849
|
+
};
|
|
1850
|
+
}
|
|
1851
|
+
// Render icon
|
|
1852
|
+
return render({
|
|
1853
|
+
...defaultIconProps,
|
|
1854
|
+
...icon.data,
|
|
1855
|
+
}, newProps);
|
|
1856
|
+
};
|
|
1857
|
+
}, {
|
|
1858
|
+
props: [
|
|
1859
|
+
// Icon and render mode
|
|
1860
|
+
'icon',
|
|
1861
|
+
'mode',
|
|
1862
|
+
'ssr',
|
|
1863
|
+
// Layout and style
|
|
1864
|
+
'width',
|
|
1865
|
+
'height',
|
|
1866
|
+
'style',
|
|
1867
|
+
'color',
|
|
1868
|
+
'inline',
|
|
1869
|
+
// Transformations
|
|
1870
|
+
'rotate',
|
|
1871
|
+
'hFlip',
|
|
1872
|
+
'horizontalFlip',
|
|
1873
|
+
'vFlip',
|
|
1874
|
+
'verticalFlip',
|
|
1875
|
+
'flip',
|
|
1876
|
+
// Misc
|
|
1877
|
+
'id',
|
|
1878
|
+
'ariaHidden',
|
|
1879
|
+
'customise',
|
|
1880
|
+
'title',
|
|
1881
|
+
],
|
|
1882
|
+
emits: ['load'],
|
|
1883
|
+
});
|
|
1884
|
+
/**
|
|
1885
|
+
* Internal API
|
|
1886
|
+
*/
|
|
1887
|
+
const _api = {
|
|
1888
|
+
getAPIConfig,
|
|
1889
|
+
setAPIModule,
|
|
1890
|
+
sendAPIQuery,
|
|
1891
|
+
setFetch,
|
|
1892
|
+
getFetch,
|
|
1893
|
+
listAPIProviders,
|
|
1894
|
+
};
|
|
1895
|
+
|
|
1896
|
+
export { Icon, _api, addAPIProvider, addCollection, addIcon, iconToSVG as buildIcon, calculateSize, clearIDCache, getIcon, iconLoaded, listIcons, loadIcon, loadIcons, replaceIDs, setCustomIconLoader, setCustomIconsLoader };
|