@nuxt/devtools-ui-kit 4.0.0-alpha.17 → 4.0.0-alpha.18
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/dist/components/NIcon.vue +14 -2
- package/dist/composables/iconify.d.ts +7 -0
- package/dist/composables/iconify.mjs +23 -0
- package/dist/module.json +1 -1
- package/package.json +13 -12
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
|
|
2
|
+
import { ref, watchEffect } from "vue";
|
|
3
|
+
import { getIconifySvg } from "../composables/iconify";
|
|
4
|
+
const props = defineProps({ icon: {
|
|
3
5
|
type: String,
|
|
4
6
|
required: false
|
|
5
7
|
} });
|
|
8
|
+
const svg = ref();
|
|
9
|
+
watchEffect(async () => {
|
|
10
|
+
svg.value = props.icon ? await getIconifySvg(props.icon) : undefined;
|
|
11
|
+
});
|
|
6
12
|
</script>
|
|
7
13
|
|
|
8
14
|
<template>
|
|
9
|
-
<div
|
|
15
|
+
<div
|
|
16
|
+
v-if="svg"
|
|
17
|
+
class="n-icon"
|
|
18
|
+
inline-block align-middle
|
|
19
|
+
v-html="svg"
|
|
20
|
+
/>
|
|
21
|
+
<div v-else class="n-icon" :class="icon" />
|
|
10
22
|
</template>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve a UnoCSS-style icon id (`carbon-tree-view-alt`, `i-logos-vue`,
|
|
3
|
+
* `carbon:settings`, ...) to inline, sanitized SVG markup, fetched from the
|
|
4
|
+
* Iconify API and cached in-memory. Returns `undefined` when the id doesn't
|
|
5
|
+
* parse as a known Iconify collection, or the fetch fails.
|
|
6
|
+
*/
|
|
7
|
+
export declare function getIconifySvg(id: string): Promise<string | undefined>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { parseIconWithLoader } from "@unocss/preset-icons/browser";
|
|
2
|
+
import DOMPurify from "dompurify";
|
|
3
|
+
const cache = /* @__PURE__ */ new Map();
|
|
4
|
+
async function fetchIconifySvg(collection, icon) {
|
|
5
|
+
const url = `https://api.iconify.design/${collection}/${icon}.svg?color=currentColor&width=1.2em&height=1.2em`;
|
|
6
|
+
try {
|
|
7
|
+
const res = await fetch(url, { signal: AbortSignal.timeout(1e4) });
|
|
8
|
+
if (!res.ok)
|
|
9
|
+
return void 0;
|
|
10
|
+
return DOMPurify.sanitize(await res.text(), { USE_PROFILES: { svg: true } });
|
|
11
|
+
} catch {
|
|
12
|
+
return void 0;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export function getIconifySvg(id) {
|
|
16
|
+
const cached = cache.get(id);
|
|
17
|
+
if (cached)
|
|
18
|
+
return cached;
|
|
19
|
+
const promise = parseIconWithLoader(id.replace(/^i-/, ""), fetchIconifySvg).then((result) => result?.svg).catch(() => void 0);
|
|
20
|
+
cache.set(id, promise);
|
|
21
|
+
promise.then((svg) => svg === void 0 && cache.delete(id));
|
|
22
|
+
return promise;
|
|
23
|
+
}
|
package/dist/module.json
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuxt/devtools-ui-kit",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.0.0-alpha.
|
|
4
|
+
"version": "4.0.0-alpha.18",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"deprecated": "This package is deprecated and no longer recommended for use. See https://devtools.nuxt.com/module/ui-kit for details.",
|
|
7
7
|
"homepage": "https://devtools.nuxt.com/module/ui-kit",
|
|
@@ -20,32 +20,33 @@
|
|
|
20
20
|
"dist"
|
|
21
21
|
],
|
|
22
22
|
"peerDependencies": {
|
|
23
|
-
"@nuxt/devtools": "4.0.0-alpha.
|
|
23
|
+
"@nuxt/devtools": "4.0.0-alpha.18",
|
|
24
24
|
"@nuxt/kit": "^4.0.0-0 || ^5.0.0-0"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@iconify-json/carbon": "^1.2.26",
|
|
28
|
-
"@iconify-json/logos": "^1.2.
|
|
28
|
+
"@iconify-json/logos": "^1.2.14",
|
|
29
29
|
"@iconify-json/ri": "^1.2.10",
|
|
30
30
|
"@iconify-json/tabler": "^1.2.38",
|
|
31
|
-
"@nuxt/devtools-kit": "4.0.0-alpha.
|
|
32
|
-
"@unocss/core": "^66.
|
|
33
|
-
"@unocss/nuxt": "^66.
|
|
34
|
-
"@unocss/preset-attributify": "^66.
|
|
35
|
-
"@unocss/preset-icons": "^66.
|
|
36
|
-
"@unocss/preset-mini": "^66.
|
|
37
|
-
"@unocss/reset": "^66.
|
|
31
|
+
"@nuxt/devtools-kit": "4.0.0-alpha.18",
|
|
32
|
+
"@unocss/core": "^66.10.1",
|
|
33
|
+
"@unocss/nuxt": "^66.10.1",
|
|
34
|
+
"@unocss/preset-attributify": "^66.10.1",
|
|
35
|
+
"@unocss/preset-icons": "^66.10.1",
|
|
36
|
+
"@unocss/preset-mini": "^66.10.1",
|
|
37
|
+
"@unocss/reset": "^66.10.1",
|
|
38
38
|
"@vueuse/core": "^14.4.0",
|
|
39
39
|
"@vueuse/integrations": "^14.4.0",
|
|
40
40
|
"@vueuse/nuxt": "^14.4.0",
|
|
41
41
|
"defu": "^6.1.7",
|
|
42
|
+
"dompurify": "^3.2.4",
|
|
42
43
|
"focus-trap": "^8.2.2",
|
|
43
44
|
"splitpanes": "^4.1.2",
|
|
44
|
-
"unocss": "^66.
|
|
45
|
+
"unocss": "^66.10.1",
|
|
45
46
|
"v-lazy-show": "^0.3.0"
|
|
46
47
|
},
|
|
47
48
|
"devDependencies": {
|
|
48
|
-
"@nuxt/devtools": "4.0.0-alpha.
|
|
49
|
+
"@nuxt/devtools": "4.0.0-alpha.18",
|
|
49
50
|
"@nuxt/kit": "npm:@nuxt/kit-nightly@5.0.0-29806258.d070492f",
|
|
50
51
|
"nuxt": "npm:nuxt-nightly@5.0.0-29806258.d070492f",
|
|
51
52
|
"unbuild": "^3.6.1"
|