@vmz/plugin-iconify 0.0.0 → 0.0.3

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/README.md CHANGED
@@ -1,3 +1,36 @@
1
1
  # @vmz/plugin-iconify
2
2
 
3
- Placeholder package (0.0.0). Reserved for the VMZ project.
3
+ ## Use a broad icon vocabulary without owning every SVG
4
+
5
+ `@vmz/plugin-iconify` connects Iconify collections to VMZ applications. It is a practical choice for product interfaces,
6
+ navigation, documentation, internal tools, and design systems that need consistent access to established icon sets.
7
+
8
+ ## What to consider
9
+
10
+ Icons improve scanning and recognition, but they are still product assets with delivery, licensing, and offline
11
+ implications. Iconify is attractive when breadth and familiar collections matter. A project that needs strict offline
12
+ builds, a locked visual language, or carefully audited assets may prefer to ship a selected local collection instead.
13
+
14
+ | Iconify is a good fit when... | Curated local assets are better when... |
15
+ |-------------------------------------------------|-------------------------------------------------------------|
16
+ | You need broad, familiar icon coverage | Offline builds and audited assets are mandatory |
17
+ | Product speed matters more than owning each SVG | Brand control and a narrow visual language are the priority |
18
+
19
+ VMZ keeps that decision at the asset boundary. Icons should not become an untracked runtime dependency that changes how
20
+ the rest of the application compiles, renders, or deploys.
21
+
22
+ ## VMZ boundary
23
+
24
+ This plugin provides icon access. VMZ retains responsibility for page output, resource placement, SSR behavior, testing,
25
+ and explainable application delivery.
26
+
27
+ ## A broad vocabulary, used deliberately ✨
28
+
29
+ - Product navigation can use familiar symbols instead of text-heavy controls.
30
+ - Documentation can distinguish notes, warnings, links, files, and actions at a glance.
31
+ - Operational tools can cover many domains without commissioning every utility icon.
32
+ - Design systems can prototype broadly before curating a final set.
33
+
34
+ The production question is not simply “does an icon exist?” It is how the application guarantees that icon in
35
+ development, CI, SSR, offline use, and long-term design consistency. Iconify solves discovery and breadth; a mature
36
+ product may then freeze the exact assets it depends on.
@@ -0,0 +1,17 @@
1
+ <template>
2
+ <span class="iconify-host" html={html != null ? html : iconFallback(name)}></span>
3
+ </template>
4
+
5
+ <script client>
6
+ import { loadIconSvg, iconFallback } from '@vmz/plugin-iconify/runtime';
7
+
8
+ export default class Iconify {
9
+ /** Iconify id, e.g. `mdi:home`. */
10
+ public name: string = '';
11
+ html: string | null = null;
12
+
13
+ async onMount() {
14
+ this.html = (await loadIconSvg(this.name)) || iconFallback(this.name);
15
+ }
16
+ }
17
+ </script>
package/package.json CHANGED
@@ -1,10 +1,43 @@
1
1
  {
2
2
  "name": "@vmz/plugin-iconify",
3
- "version": "0.0.0",
4
- "description": "VMZ placeholder — not for production use.",
3
+ "version": "0.0.3",
4
+ "type": "module",
5
+ "description": "VMZ Iconify adapter - <Iconify>",
5
6
  "license": "MIT",
6
- "private": false,
7
- "files": [
8
- "README.md"
9
- ]
7
+ "main": "./vmz.plugin.ts",
8
+ "types": "./vmz.plugin.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./vmz.plugin.ts",
12
+ "default": "./vmz.plugin.ts"
13
+ },
14
+ "./runtime": {
15
+ "types": "./runtime.ts",
16
+ "default": "./runtime.ts"
17
+ }
18
+ },
19
+ "dependencies": {
20
+ "@vmz/plugin": "0.0.3"
21
+ },
22
+ "peerDependencies": {
23
+ "@iconify/utils": ">=2"
24
+ },
25
+ "peerDependenciesMeta": {
26
+ "@iconify/utils": {
27
+ "optional": true
28
+ }
29
+ },
30
+ "keywords": [
31
+ "vmz",
32
+ "plugin",
33
+ "iconify",
34
+ "icon"
35
+ ],
36
+ "publishConfig": {
37
+ "access": "public"
38
+ },
39
+ "repository": {
40
+ "type": "git",
41
+ "url": "git+https://github.com/doki-land/vmz-framework.git"
42
+ }
10
43
  }
package/runtime.ts ADDED
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Iconify SVG fetch helper (runtime). Prefer build-time offline collections later.
3
+ */
4
+
5
+ const cache = new Map<string, string>();
6
+
7
+ /** `name` is icon set:name e.g. `mdi:home`. */
8
+ export async function loadIconSvg(name: string): Promise<string> {
9
+ const key = String(name ?? '');
10
+ if (cache.has(key)) return cache.get(key)!;
11
+ const [prefix, icon] = key.split(':');
12
+ if (!prefix || !icon) {
13
+ const empty = '';
14
+ cache.set(key, empty);
15
+ return empty;
16
+ }
17
+ try {
18
+ const res = await fetch(`https://api.iconify.design/${prefix}/${icon}.svg`);
19
+ if (!res.ok) throw new Error(String(res.status));
20
+ const svg = await res.text();
21
+ cache.set(key, svg);
22
+ return svg;
23
+ } catch {
24
+ const empty = '';
25
+ cache.set(key, empty);
26
+ return empty;
27
+ }
28
+ }
29
+
30
+ export function iconFallback(name: string): string {
31
+ const escaped = String(name ?? '')
32
+ .replace(/&/g, '&amp;')
33
+ .replace(/</g, '&lt;')
34
+ .replace(/>/g, '&gt;');
35
+ return `<span class="iconify-fallback" data-icon="${escaped}"></span>`;
36
+ }
package/vmz.plugin.ts ADDED
@@ -0,0 +1,46 @@
1
+ import { definePlugin, loadPluginSource } from '@vmz/plugin';
2
+
3
+ const source = loadPluginSource(import.meta.url, 'components/Iconify.vmz');
4
+
5
+ export default definePlugin({
6
+ name: '@vmz/plugin-iconify',
7
+ version: '0.1.0',
8
+ protocol: '0.1.0',
9
+ stages: ['workspace_resolve', 'analyzer'],
10
+ deterministic: true,
11
+ async contribute(ctx) {
12
+ if (ctx.stage === 'workspace_resolve') {
13
+ return {
14
+ stage: 'workspace_resolve',
15
+ cacheKey: `@vmz/plugin-iconify:Iconify.vmz:${source.contentHash.slice(0, 12)}`,
16
+ items: [
17
+ {
18
+ id: 'component-iconify',
19
+ kind: 'source',
20
+ path: 'src/components/Iconify.vmz',
21
+ content: source.content,
22
+ contentHash: source.contentHash,
23
+ materialize: true,
24
+ },
25
+ ],
26
+ };
27
+ }
28
+ if (ctx.stage === 'analyzer') {
29
+ return {
30
+ stage: 'analyzer',
31
+ cacheKey: '@vmz/plugin-iconify:analyzer',
32
+ items: [
33
+ {
34
+ id: 'component-iconify-online',
35
+ kind: 'analyzer',
36
+ path: 'src/components/Iconify.vmz',
37
+ severity: 'advice',
38
+ message: 'Iconify component online',
39
+ code: 'vmz.plugin.iconify',
40
+ },
41
+ ],
42
+ };
43
+ }
44
+ return { stage: ctx.stage, items: [] };
45
+ },
46
+ });