magic-glyphs 0.6.2 → 0.7.1

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/docs/cli.md CHANGED
@@ -59,6 +59,8 @@ Files for non-outline styles carry the style in the name, for example `heart.duo
59
59
  npx magic-glyphs login YOUR-LICENCE-KEY # the key from your Gumroad receipt (no < > around it); downloads the full library
60
60
  npx magic-glyphs buy # opens the page where you can buy a licence
61
61
  npx magic-glyphs update # tells you if a newer version is out, then downloads new paid icons
62
+ npx magic-glyphs build-key # a key for CI and build servers that does not use a device
63
+ npx magic-glyphs shadcn --env # connect a shadcn project (see the shadcn guide)
62
64
  npx magic-glyphs --version
63
65
  npx magic-glyphs licence # who this computer is licensed to
64
66
  npx magic-glyphs licence --show-key # prints the key to use on a build server
@@ -71,3 +73,15 @@ npx magic-glyphs static --out public/icons --styles outline,solid
71
73
  ```
72
74
 
73
75
  On a build server, set the `MAGIC_GLYPHS_KEY` environment variable instead of running `login`, then run `sync`.
76
+
77
+ ## Your own icons
78
+
79
+ Icons from the icon maker (exported as icon data, `.json`) work with every command. They need no licence:
80
+
81
+ ```bash
82
+ npx magic-glyphs add my-logo --from my-icons/ --format react --out src/icons
83
+ npx magic-glyphs static --from my-icons/ --out public/icons
84
+ MAGIC_GLYPHS_CUSTOM=./my-icons npx magic-glyphs add my-logo --stdout
85
+ ```
86
+
87
+ `--from` takes a file or a folder. `MAGIC_GLYPHS_CUSTOM` loads them for every command and for the MCP server, so your coding assistant can use them too. Files are checked so they can only contain drawing, motion and sound settings.
@@ -0,0 +1,18 @@
1
+ # Flutter
2
+
3
+ ## Install
4
+
5
+ ```bash
6
+ flutter pub add lottie audioplayers
7
+ npx magic-glyphs add heart bell --format flutter --sound --out lib/icons
8
+ ```
9
+
10
+ Each icon is one `.dart` file with its animation built in. For sound, move the `.wav` files to `assets/` and list them in `pubspec.yaml`.
11
+
12
+ ## Use
13
+
14
+ ```dart
15
+ const HeartGlyph(size: 28, sound: true, label: 'Like')
16
+ ```
17
+
18
+ > Generated from the same Lottie export as the other platforms, which is checked against an independent Lottie renderer. These component files have not yet been run on real devices; please report anything that does not work.
@@ -0,0 +1,50 @@
1
+ # Astro, Svelte, Tailwind
2
+
3
+ Magic Glyphs works in any framework that renders HTML, because the icons are a standard web component, `<magic-glyph>`.
4
+
5
+ ## Astro
6
+
7
+ ```astro
8
+ <magic-glyph name="heart" size="32" sound></magic-glyph>
9
+
10
+ <script>
11
+ import MG from 'magic-glyphs';
12
+ import icons from 'magic-glyphs/icons.json';
13
+ MG.register(icons);
14
+ </script>
15
+ ```
16
+
17
+ For paid icons or to ship only what you use, generate a bundle and load it once: `npx magic-glyphs bundle heart bell --out public/magic-glyphs.js`, then `<script src="/magic-glyphs.js" is:inline></script>`. Astro islands with React or Vue can use those components instead.
18
+
19
+ ## Svelte and SvelteKit
20
+
21
+ ```svelte
22
+ <script lang="ts">
23
+ import MG from 'magic-glyphs';
24
+ import icons from 'magic-glyphs/icons.json';
25
+ MG.register(icons);
26
+ </script>
27
+
28
+ <magic-glyph name="bell" variant="duotone"></magic-glyph>
29
+ ```
30
+
31
+ In SvelteKit, register in a `+layout.svelte` so every page has the icons.
32
+
33
+ ## Tailwind
34
+
35
+ Icons draw in the current text colour, so colour and size classes just work:
36
+
37
+ ```html
38
+ <magic-glyph name="heart" class="text-rose-500 size-10" size="40"></magic-glyph>
39
+ <button class="inline-flex items-center gap-2 bg-zinc-900 text-white px-3 py-2 rounded-md">
40
+ <magic-glyph name="heart" size="16"></magic-glyph> Like
41
+ </button>
42
+ ```
43
+
44
+ For duotone, set the fill with a CSS variable: `style="--mg-secondary: theme(colors.blue.500)"` or an arbitrary property class such as `[--mg-secondary:theme(colors.blue.500)]`.
45
+
46
+ ## Solid, Qwik, Lit, plain HTML
47
+
48
+ Use the `<magic-glyph>` tag as above. See the HTML guide for every attribute.
49
+
50
+ Tested with Astro 5, Svelte 5 with Tailwind 4, React 19 with Vite, Next.js App Router, and Vue 3 with TypeScript.
@@ -0,0 +1,21 @@
1
+ # Jetpack Compose
2
+
3
+ ## Install
4
+
5
+ ```kotlin
6
+ implementation("com.airbnb.android:lottie-compose:6.6.0")
7
+ ```
8
+
9
+ ```bash
10
+ npx magic-glyphs add heart bell --format compose --sound --out app/src/main/java/magicglyphs
11
+ ```
12
+
13
+ Each icon is one `.kt` file with its animation built in. For sound, move the `.wav` files to `res/raw` (dashes become underscores, so `heart.wav` stays `heart.wav`, `chat-reply.wav` becomes `chat_reply.wav`).
14
+
15
+ ## Use
16
+
17
+ ```kotlin
18
+ HeartGlyph(size = 28.dp, sound = true, label = "Like")
19
+ ```
20
+
21
+ > Generated from the same Lottie export as the other platforms, which is checked against an independent Lottie renderer. These component files have not yet been run on real devices; please report anything that does not work.
package/docs/licence.md CHANGED
@@ -8,10 +8,38 @@
8
8
  npx magic-glyphs login XXXXXXXX-XXXXXXXX-XXXXXXXX-XXXXXXXX # the key on your Gumroad receipt, once per computer
9
9
  npx magic-glyphs licence # shows who the key belongs to
10
10
  npx magic-glyphs list --free # the free set
11
- npx magic-glyphs logout
11
+ npx magic-glyphs logout # also frees this computer's device slot
12
12
  ```
13
13
 
14
- `login` swaps the Gumroad key for a signed Magic Glyphs key (it starts with `MG1.`) and downloads the full set. On a build server, set `MAGIC_GLYPHS_KEY` to that `MG1.` key (`npx magic-glyphs licence --show-key` prints it) and run `npx magic-glyphs sync`.
14
+ `login` swaps the Gumroad key for a signed Magic Glyphs key (it starts with `MG1.`) and downloads the full set. `npx magic-glyphs update` fetches icons added since.
15
+
16
+ ## Devices
17
+
18
+ A licence works on a set number of devices at once. A device is one computer using the command line tool or MCP server, or one browser on this website.
19
+
20
+ | Plan | People | Devices |
21
+ |---|---|---|
22
+ | Personal | 1 | 3 |
23
+ | Team | up to 10 | 20 |
24
+ | Business | up to 50 | 100 |
25
+
26
+ A device that has not been used for 30 days is freed automatically. To free one straight away, run `npx magic-glyphs logout` on it, or choose "Remove key from this browser" on the website. If you reach the limit, the error says so and tells you how to free a device.
27
+
28
+ There is also a daily download limit, set well above what normal use needs.
29
+
30
+ ## Build servers and CI
31
+
32
+ Build servers would otherwise use up devices, so they get their own key:
33
+
34
+ ```
35
+ npx magic-glyphs build-key # run once on your own computer after logging in
36
+ ```
37
+
38
+ Store the key it prints as a secret named `MAGIC_GLYPHS_KEY` in your CI, then run `npx magic-glyphs sync` in the build. A build key does not use a device, shares the daily download limit, and stops working if the licence is revoked.
39
+
40
+ ## Your downloads carry your licence
41
+
42
+ Each download of the full set records which licence it was made for. Keep your key private: it is tied to your purchase.
15
43
 
16
44
  With a key, `add`, `static`, `registry` and the MCP server's `get_icon` return every icon. Without one they return the free set and explain what is missing.
17
45
 
package/docs/maker.md ADDED
@@ -0,0 +1,64 @@
1
+ # Icon maker guide
2
+
3
+ The icon maker turns your own artwork into an animated icon with motion and sound, in the same style as the library. It is included with every paid licence; you can try it with the sample before unlocking.
4
+
5
+ ## 1. Unlock
6
+
7
+ Paste the licence key from your Gumroad receipt at the top of the [icon maker](https://magic-glyphs-site.lewisvillamor26.workers.dev/maker/) and press **Unlock**. The browser remembers it. Use **Remove key from this browser** on the [icon browser](https://magic-glyphs-site.lewisvillamor26.workers.dev/icons/) when you are on a shared computer.
8
+
9
+ ## 2. Start from your artwork
10
+
11
+ - **Upload SVG or image:** an `.svg` file, or a PNG, JPG or WebP logo. Images are traced into shapes; this works best on simple, high-contrast artwork with a plain background.
12
+ - **Paste SVG code:** straight from Figma, Illustrator or any icon set you own.
13
+ - **Remix a library icon:** type its name, for example `rocket`, and press **Remix**. Its drawing, motion and sound are kept, ready for you to change.
14
+
15
+ The maker fits everything to the 24-pixel grid with a little padding, so it sits nicely next to library icons.
16
+
17
+ ## 3. Shape
18
+
19
+ - **Line icon or filled shape:** line icons are drawn with the library's stroke; filled shapes are solid.
20
+ - **Parts:** each separate shape becomes a part. Untick **Moves** to keep a part still. Tick **Detail** for small inner marks (an eye, a dot) so they stay lines in the solid style.
21
+
22
+ ## 4. Motion
23
+
24
+ Pick a motion: pop, bounce, drop in, wiggle, swing, spin, slide, shake, float, pulse, tilt or still. **Strength** sets how far it moves; **Snappy**, **Normal** and **Bouncy** set the feel.
25
+
26
+ **Give each part its own motion.** Select a part in the list: the motion buttons now apply to that part only. Choose a motion and use **Start after** to delay it, so parts move in sequence. For example, a box that pops while its lid spins in 200 ms later. **Same as all parts** returns a part to the shared motion; **Done with this part** goes back to editing all parts.
27
+
28
+ ## 5. Sound
29
+
30
+ Choose one of 39 sounds, then tune it:
31
+
32
+ | Slider | What it does |
33
+ |---|---|
34
+ | Volume | Louder or quieter than other icons |
35
+ | Pitch | Higher or lower, in semitones |
36
+ | Speed | Faster or slower |
37
+ | Tone | Softer (muffled) to brighter |
38
+ | Stereo | How far the sound follows the icon left and right on screen |
39
+ | Delay | When the sound starts after the motion begins |
40
+
41
+ Press **Hear it**, or the preview itself, to listen. Browsers play sound only after you have clicked on the page.
42
+
43
+ ## 6. Save
44
+
45
+ **Save to My icons** keeps the icon with your licence. Your saved icons appear in any browser where you unlock with the same key, and they are also kept in this browser. Up to 100 icons are kept; delete the ones you no longer need. What you are working on right now is kept in the browser too, so a refresh never loses it.
46
+
47
+ ## 7. Export
48
+
49
+ - **SVG:** a still image.
50
+ - **React (.tsx or .jsx), Vue, HTML:** animated, with your sound settings, using the free `magic-glyphs` package.
51
+ - **Lottie:** the motion, for any Lottie player on iOS, Android, Windows or Flutter.
52
+ - **Sound (.wav):** the sound with your settings, to play alongside Lottie in native apps.
53
+ - **Icon data (JSON):** use your icon everywhere the library works:
54
+
55
+ ```bash
56
+ npx magic-glyphs add my-logo --from my-icons/ --format react # or swiftui, flutter, compose, winui
57
+ MAGIC_GLYPHS_CUSTOM=./my-icons npx -y magic-glyphs-mcp # your coding assistant can use them too
58
+ ```
59
+
60
+ ## Tips
61
+
62
+ - Simpler artwork animates better. Merge tiny shapes in your design tool before importing.
63
+ - Convert text to outlines first; the maker reads shapes, not fonts.
64
+ - Your icons are yours. The maker runs in your browser; only icons you save are stored, with your licence.
package/docs/mcp.md CHANGED
@@ -41,3 +41,11 @@ All four are read-only: the server never writes files. The agent decides where t
41
41
  ## Errors
42
42
 
43
43
  Unknown names return suggestions ("Did you mean: ..."), unknown categories return the valid list, and unsupported combinations (for example Lottie in the glass style) say why.
44
+
45
+ ## Your own icons
46
+
47
+ Set `MAGIC_GLYPHS_CUSTOM` to a folder of icon data exported from the icon maker, and the assistant can search and insert those too:
48
+
49
+ ```json
50
+ { "mcpServers": { "magic-glyphs": { "command": "npx", "args": ["-y", "magic-glyphs-mcp"], "env": { "MAGIC_GLYPHS_CUSTOM": "/path/to/my-icons" } } } }
51
+ ```
@@ -70,6 +70,14 @@ Add the `lottie` package, list the folder under `assets:` in `pubspec.yaml`, the
70
70
  Lottie.asset('assets/glyphs/heart.lottie.json', width: 32, height: 32, repeat: false)
71
71
  ```
72
72
 
73
+ ## Sound
74
+
75
+ Lottie carries motion only. Add `--sound` to also write each icon's sound as a `.wav` file, and play it with your platform's audio player when the animation starts:
76
+
77
+ ```bash
78
+ npx magic-glyphs add bell --format lottie --sound --out assets
79
+ ```
80
+
73
81
  ## How the export was checked
74
82
 
75
83
  Every icon was converted and rendered at two mid-animation frames with an independent Lottie library, then compared pixel by pixel with the web engine. All 3,947 matched within a small tolerance. The files have **not** yet been played in lottie-ios, lottie-android or Lottie-Windows; try a handful on a device before relying on them.
@@ -0,0 +1,34 @@
1
+ # React Native
2
+
3
+ ## Install
4
+
5
+ ```bash
6
+ npm install lottie-react-native
7
+ npx magic-glyphs add heart bell --format react-native --sound --out src/icons
8
+ ```
9
+
10
+ Each icon is one `.tsx` file with its animation built in. `--sound` also writes `heart.wav` and `bell.wav`.
11
+
12
+ ## Use
13
+
14
+ ```tsx
15
+ import HeartGlyph from './src/icons/HeartGlyph';
16
+
17
+ <HeartGlyph size=28 accessibilityLabel="Like" />
18
+ ```
19
+
20
+ The icon plays when pressed. Props: `size`, `playOnPress`, `onPlay`, `accessibilityLabel`, `style`.
21
+
22
+ ## Sound
23
+
24
+ Play the WAV from `onPlay` with the audio library you already use, for example Expo:
25
+
26
+ ```tsx
27
+ import { useAudioPlayer } from 'expo-audio';
28
+ const player = useAudioPlayer(require('./src/icons/heart.wav'));
29
+ <HeartGlyph onPlay={() => { player.seekTo(0); player.play(); }} />
30
+ ```
31
+
32
+ The generated component type-checks against `react-native` and `lottie-react-native`.
33
+
34
+ > Generated from the same Lottie export as the other platforms, which is checked against an independent Lottie renderer. These component files have not yet been run on real devices; please report anything that does not work.
package/docs/react-vue.md CHANGED
@@ -55,7 +55,14 @@ Each file registers just its own icon, so the bundle contains the 7 KB engine pl
55
55
 
56
56
  In a TypeScript project (one with a `tsconfig.json`), the CLI writes typed components: `.tsx` for React and `<script setup lang="ts">` for Vue, so `tsc` and `vue-tsc` builds pass. Add `--js` or `--ts` to choose yourself. React components start with `'use client'`, so they work inside Next.js server components.
57
57
 
58
- Tested with the default Vite React + TypeScript and Vue + TypeScript templates, and with Next.js (App Router).
58
+ Tested with the default Vite React + TypeScript and Vue + TypeScript templates, Next.js (App Router) and Nuxt 4. In Nuxt, generated components in `components/` are picked up automatically, and icons render on the server.
59
+
60
+ ## A mute switch
61
+
62
+ ```jsx
63
+ import { SoundToggle } from 'magic-glyphs/react'; // or 'magic-glyphs/vue'
64
+ <SoundToggle defaultOn={false} />
65
+ ```
59
66
 
60
67
  ## Module format
61
68
 
package/docs/shadcn.md ADDED
@@ -0,0 +1,50 @@
1
+ # shadcn
2
+
3
+ Magic Glyphs has an official shadcn registry. Each icon installs as a small component file in your project, and the `magic-glyphs` package is added for you.
4
+
5
+ ## Set up once
6
+
7
+ In a shadcn project (one with a `components.json`):
8
+
9
+ ```bash
10
+ npx magic-glyphs shadcn
11
+ ```
12
+
13
+ This adds the `@magic-glyphs` registry to `components.json`. The 120 free icons work straight away:
14
+
15
+ ```bash
16
+ npx shadcn@latest add @magic-glyphs/heart @magic-glyphs/bell
17
+ ```
18
+
19
+ ## Paid icons
20
+
21
+ Log in once, then run the setup again with `--env`:
22
+
23
+ ```bash
24
+ npx magic-glyphs login YOUR-LICENCE-KEY
25
+ npx magic-glyphs shadcn --env
26
+ npx shadcn@latest add @magic-glyphs/send
27
+ ```
28
+
29
+ `--env` saves your licence key to `.env.local`, where shadcn reads it, and adds `.env.local` to `.gitignore` if it is not already ignored. Keep that file out of version control. In CI, set `MAGIC_GLYPHS_KEY` as a secret instead; a build key from `npx magic-glyphs build-key` is the right one for that.
30
+
31
+ ## Use the component
32
+
33
+ ```tsx
34
+ import HeartGlyph from '@/components/magic-glyphs/heart';
35
+
36
+ <Button variant="ghost"><HeartGlyph size={18} /> Like</Button>
37
+ ```
38
+
39
+ Icons take their colour from the text colour, so Tailwind classes such as `text-rose-500` work, as do your theme's `text-foreground` and `text-muted-foreground`.
40
+
41
+ ## Your own icons
42
+
43
+ Icons you make in the icon maker can be served the same way from your own host:
44
+
45
+ ```bash
46
+ npx magic-glyphs registry --from my-icons/ --out public/registry --homepage https://your-site.example
47
+ npx shadcn@latest add https://your-site.example/registry/r/my-logo.json
48
+ ```
49
+
50
+ Tested with shadcn 4 on Vite + React + TypeScript and Tailwind 4.
package/docs/sound.md ADDED
@@ -0,0 +1,79 @@
1
+ # Sound
2
+
3
+ Every icon has a short synthesized sound that matches its motion. Sound is **off** unless you ask for it, and browsers only allow it after the visitor clicks or presses a key.
4
+
5
+ ## Turn it on
6
+
7
+ ```html
8
+ <magic-glyph name="bell" sound></magic-glyph> <!-- this icon only -->
9
+ <script>MagicGlyphs.sound.enable(true);</script> <!-- every icon on the page -->
10
+ ```
11
+
12
+ In React and Vue, pass the `sound` prop.
13
+
14
+ ## Shape the sound
15
+
16
+ Every setting is optional. Leave one out to keep the icon's own.
17
+
18
+ | Setting | Range | Default | What it does |
19
+ |---|---|---|---|
20
+ | `sound` | a sound name | the icon's own | Use a different sound |
21
+ | `volume` | 0 to 2 | 1 | Louder or quieter than the others |
22
+ | `pitch` | -12 to 12 | 0 | Semitones up or down |
23
+ | `speed` | 0.5 to 2 | 1 | Faster or slower |
24
+ | `tone` | -1 to 1 | 0 | Softer (muffled) to brighter |
25
+ | `pan` | 0 to 1 | 1 | How far the sound follows the icon left and right on screen |
26
+ | `delay` | 0 to 2000 ms, or `auto` | `auto` | When it starts. `auto` lines impact sounds up with the moment of impact in the motion |
27
+
28
+ **On the element**, with `sound-` in front of each name (`sound-name` for the sound itself):
29
+
30
+ ```html
31
+ <magic-glyph name="bell" sound sound-pitch="-3" sound-tone="-0.4"></magic-glyph>
32
+ ```
33
+
34
+ **In React and Vue**, with `soundOptions`:
35
+
36
+ ```jsx
37
+ <MagicGlyph name="bell" sound soundOptions={{ sound: 'chime', pitch: 2, volume: 0.8 }} />
38
+ ```
39
+
40
+ **For every use of an icon**, or for every icon:
41
+
42
+ ```js
43
+ MagicGlyphs.sound.set('bell', { sound: 'chime', pitch: 2 }); // null clears it
44
+ MagicGlyphs.sound.defaults({ volume: 0.8, pan: 0.5 });
45
+ MagicGlyphs.sound.volume(0.4); // master volume, 0 to 1
46
+ ```
47
+
48
+ Icons you make or remix in the [icon maker](https://magic-glyphs-site.lewisvillamor26.workers.dev/maker/) carry their sound settings with them, so the exported React, Vue and HTML play exactly what you chose.
49
+
50
+ ## A mute switch for visitors
51
+
52
+ Put a speaker button on the page. Visitors turn icon sounds on or off, and the choice is remembered in their browser:
53
+
54
+ ```html
55
+ <magic-glyphs-sound-toggle default="off"></magic-glyphs-sound-toggle>
56
+ ```
57
+
58
+ Attributes: `default` (`on` or `off`), `size`, `show-label`, `label-on`, `label-off`. In React and Vue, use `<SoundToggle defaultOn={false} />` from `magic-glyphs/react` or `magic-glyphs/vue`. From script: `MagicGlyphs.sound.toggle()`. When a visitor mutes, every icon is silent, including ones with the `sound` attribute.
59
+
60
+ ## Sound for native apps
61
+
62
+ Lottie files carry the motion but no sound. Export each icon's sound as a WAV file and play it alongside the animation:
63
+
64
+ ```bash
65
+ npx magic-glyphs add bell --format lottie --sound --out assets # bell.lottie.json and bell.wav
66
+ npx magic-glyphs add bell --format wav --out assets # the sound alone
67
+ ```
68
+
69
+ The icon maker exports WAV too, with your sound settings applied.
70
+
71
+ ## Levels
72
+
73
+ All sounds are measured with the same hearing-weighted loudness curve used for broadcast audio and trimmed to a common level, so no icon is suddenly louder than the rest, and none clip at any volume setting.
74
+
75
+ ## Be considerate
76
+
77
+ Give visitors a mute control if you turn sound on for a whole page, and keep it off for icons people see constantly, like navigation.
78
+
79
+ Hear every sound on the website: https://magic-glyphs-site.lewisvillamor26.workers.dev/docs/sound/
@@ -0,0 +1,22 @@
1
+ # SwiftUI
2
+
3
+ ## Install
4
+
5
+ Add the [Lottie package](https://github.com/airbnb/lottie-ios) (4.4 or later) to your Xcode project, then:
6
+
7
+ ```bash
8
+ npx magic-glyphs add heart bell --format swiftui --sound --out MyApp/Icons
9
+ ```
10
+
11
+ Each icon is one `.swift` file with its animation built in. Add the `.wav` files to the app bundle for sound.
12
+
13
+ ## Use
14
+
15
+ ```swift
16
+ HeartGlyph(size: 28, label: "Like")
17
+ HeartGlyph(size: 28, sound: false)
18
+ ```
19
+
20
+ The icon plays when tapped, and its sound plays with it if the WAV is in the bundle.
21
+
22
+ > Generated from the same Lottie export as the other platforms, which is checked against an independent Lottie renderer. These component files have not yet been run on real devices; please report anything that does not work.
@@ -0,0 +1,15 @@
1
+ # Tauri and Rust
2
+
3
+ ## Tauri, Dioxus and Leptos
4
+
5
+ These apps draw their interface in a web view, so Magic Glyphs works exactly as on the web, including sound:
6
+
7
+ ```bash
8
+ npm install magic-glyphs
9
+ ```
10
+
11
+ Then use the `<magic-glyph>` tag, or the React, Vue or Svelte setup your front end uses. Everything runs locally; no network access is needed at run time. For paid icons, bundle what you use with `npx magic-glyphs bundle heart bell --out src/magic-glyphs.js` so the app needs no licence check at run time.
12
+
13
+ ## Native Rust interfaces (egui, iced, Slint)
14
+
15
+ Export still icons with `npx magic-glyphs static --out assets/icons` and load the SVG files with your toolkit's SVG support, or export Lottie files for a Lottie player. A native Rust crate with animation is planned.
package/docs/web.md CHANGED
@@ -99,4 +99,5 @@ Every icon has a short synthesized sound that matches its motion. Sound is off u
99
99
  - **Position:** the sound is placed left or right in stereo according to where the icon sits on screen.
100
100
  - **First interaction:** browsers block audio until the visitor clicks or presses a key, so hover sounds start after that.
101
101
  - **React and Vue:** pass the `sound` prop, or import `sound` and call `sound.enable(true)`.
102
+ - **Shape it:** change the sound, volume, pitch, speed, tone, stereo and timing per icon. See the Sound page.
102
103
  - **Be considerate:** give visitors a mute control if you turn sound on for a whole page.
@@ -0,0 +1,23 @@
1
+ # Windows (WinUI)
2
+
3
+ ## Install
4
+
5
+ ```bash
6
+ dotnet add package CommunityToolkit.WinUI.Lottie
7
+ npx magic-glyphs add heart bell --format winui --sound --out Icons
8
+ ```
9
+
10
+ Each icon is one `.cs` control with its animation built in. Add the `.wav` files to the project as Content for sound.
11
+
12
+ ## Use
13
+
14
+ ```csharp
15
+ var heart = new HeartGlyph(28) { Sound = true };
16
+ panel.Children.Add(heart);
17
+ ```
18
+
19
+ The icon plays when tapped. Call `heart.Play()` to play it from code.
20
+
21
+ For WPF, Electron or Tauri on Windows, use the web or Lottie routes instead.
22
+
23
+ > Generated from the same Lottie export as the other platforms, which is checked against an independent Lottie renderer. These component files have not yet been run on real devices; please report anything that does not work.
package/lib.js CHANGED
@@ -12,7 +12,7 @@ const data=loadData();MG.register(data);
12
12
  const idxFile=path.join(__dirname,'data','index.json');
13
13
  const index=(()=>{let ix=null;try{ix=JSON.parse(fs.readFileSync(idxFile,'utf8'))}catch(e){}const own=data.icons.map(i=>({n:i.n,c:i.c,t:i.t}));return ix&&ix.length>own.length?ix:own})();
14
14
  const known=new Set(index.map(i=>i.n)),total=index.length;
15
- const STYLES=['outline','solid','duotone','glass'],FORMATS=['svg','lottie','json','react','vue','html'];
15
+ const STYLES=['outline','solid','duotone','glass'],FORMATS=['svg','lottie','json','react','vue','html','react-native','swiftui','compose','flutter','winui'];
16
16
  const byName=new Map(data.icons.map(i=>[i.n,i]));
17
17
  const categories=()=>{const c={};index.forEach(i=>c[i.c]=(c[i.c]||0)+1);return c};
18
18
  function search(query,opt){
@@ -50,6 +50,9 @@ function render(name,format,o){
50
50
  case 'lottie':{if(style==='glass')throw new Error('Lottie export supports outline, solid and duotone (glass uses a gradient that Lottie players handle inconsistently).');
51
51
  const {toLottie}=require('./tools/lottie.js');return{ext:'json',file:name+(style==='outline'?'':'.'+style)+'.lottie.json',text:JSON.stringify(toLottie(ic,Object.assign({},o,{color:o.color||'#000000'})))}}
52
52
  case 'json':return{ext:'json',file:name+'.json',text:JSON.stringify(ic)};
53
+ // native apps: one file each, with the Lottie animation inside (see tools/native.js)
54
+ case 'react-native':case 'swiftui':case 'compose':case 'flutter':case 'winui':{if(style==='glass')throw new Error('Native formats support outline, solid and duotone.');
55
+ const f=require('./tools/native.js')[format](ic,Object.assign({},o,{style}));return{ext:f.file.split('.').pop(),file:f.file,text:f.text}}
53
56
  case 'react':{const P=pascal(name),ts=!!o.ts;
54
57
  // "use client" lets the component sit inside a Next.js server component tree; other bundlers ignore it
55
58
  return{ext:ts?'tsx':'jsx',file:P+'Glyph.'+(ts?'tsx':'jsx'),text:`'use client';\nimport { MagicGlyph, register${ts?', type MagicGlyphProps':''} } from 'magic-glyphs/react';\n\nregister([${JSON.stringify(ic)}]);\n\n/** Animated "${name}" icon. Props: variant, size, trigger, label, sound, className, style. */\nexport default function ${P}Glyph(props${ts?": Omit<MagicGlyphProps, 'name'>":''}) {\n return <MagicGlyph name="${name}" variant="${style}" {...props} />;\n}\n`}}
@@ -58,4 +61,35 @@ function render(name,format,o){
58
61
  default:throw new Error('Unknown format "'+format+'". Use one of: '+FORMATS.join(', '));
59
62
  }
60
63
  }
61
- module.exports={MG,data,byName,index,known,total,fullFile,categories,search,render,staticSvg,pascal,STYLES,FORMATS};
64
+ // ---- your own icons: JSON from the icon maker (one icon, a list, or {icons:[...]}), from files or folders ----
65
+ // They need no licence. Everything is checked so a file can only ever contain drawing and motion data.
66
+ const custom=new Set();
67
+ const PATH_OK=/^[MmLlHhVvCcSsQqTtAaZz0-9eE.,\s+-]*$/,ID_OK=/^[A-Za-z0-9_-]{1,40}$/,NAME_OK=/^[a-z0-9][a-z0-9-]{0,59}$/;
68
+ function checkIcon(ic,src){const bad=m=>{throw new Error(src+': '+m)};
69
+ if(!ic||typeof ic!=='object')bad('not an icon');if(typeof ic.n!=='string'||!NAME_OK.test(ic.n))bad('the name must be lowercase letters, numbers and dashes');
70
+ if(!Array.isArray(ic.L)||!ic.L.length||ic.L.length>200)bad('"'+ic.n+'" has no drawing');
71
+ for(const l of ic.L){if(!ID_OK.test(String(l.i))||!['c','o','i','d','f'].includes(l.k)||!Array.isArray(l.p))bad('"'+ic.n+'" has a malformed layer');
72
+ for(const p of l.p){if(typeof p.d!=='string'||p.d.length>100000||!PATH_OK.test(p.d))bad('"'+ic.n+'" has path data that is not plain drawing commands');
73
+ for(const k of Object.keys(p))if(!['d','r'].includes(k))bad('"'+ic.n+'" has an unknown path field "'+k+'"');
74
+ if(p.r!==undefined&&!(Array.isArray(p.r)&&p.r.length===3&&p.r.every(Number.isFinite)))bad('"'+ic.n+'" has a malformed rotation')}}
75
+ if(ic.A!==undefined&&!Array.isArray(ic.A))bad('"'+ic.n+'" has malformed motion');
76
+ for(const a of ic.A||[]){if(typeof a.l!=='string'||!a.l.split(' ').every(x=>ID_OK.test(x))||!['tx','ty','r','s','sx','sy'].includes(a.p)||!Array.isArray(a.k)||!a.k.every(k=>Array.isArray(k)&&k.length===2&&k.every(Number.isFinite))||!Number.isFinite(a.st)||!Number.isFinite(a.d))bad('"'+ic.n+'" has malformed motion');
77
+ if(a.o!==undefined&&!(Array.isArray(a.o)&&a.o.length===2&&a.o.every(Number.isFinite)))bad('"'+ic.n+'" has a malformed motion origin');if(a.from!==undefined&&!Number.isFinite(a.from))bad('"'+ic.n+'" has a malformed motion start')}
78
+ const out={n:ic.n,c:typeof ic.c==='string'&&NAME_OK.test(ic.c)?ic.c:'custom',t:typeof ic.t==='string'?ic.t.replace(/[<>"&]/g,'').slice(0,200):'',L:ic.L,A:ic.A||[]};
79
+ if(typeof ic.s==='string'&&/^[a-z0-9]{1,20}$/.test(ic.s))out.s=ic.s;
80
+ if(ic.S&&typeof ic.S==='object'){const S={};for(const k of ['sound','volume','pitch','speed','tone','pan','delay']){const v=ic.S[k];if(typeof v==='number'&&isFinite(v))S[k]=v;else if(k==='sound'&&typeof v==='string'&&/^[a-z0-9]{1,20}$/.test(v))S[k]=v;else if(k==='delay'&&v==='auto')S[k]=v}if(Object.keys(S).length)out.S=S}
81
+ return out}
82
+ function addCustom(where){const files=[];
83
+ for(const w of [].concat(where).filter(Boolean)){const p=path.resolve(w);if(!fs.existsSync(p))throw new Error('No such file or folder: '+w);
84
+ if(fs.statSync(p).isDirectory())fs.readdirSync(p).filter(f=>f.endsWith('.json')).sort().forEach(f=>files.push(path.join(p,f)));else files.push(p)}
85
+ const added=[];
86
+ for(const f of files){let d;try{d=JSON.parse(fs.readFileSync(f,'utf8'))}catch(e){throw new Error(path.basename(f)+': not valid JSON')}
87
+ for(const raw of Array.isArray(d)?d:Array.isArray(d.icons)?d.icons:[d]){const ic=checkIcon(raw,path.basename(f));
88
+ if(known.has(ic.n)&&!custom.has(ic.n))throw new Error(path.basename(f)+': "'+ic.n+'" is already a library icon name. Rename yours.');
89
+ MG.register([ic]);byName.set(ic.n,ic);custom.add(ic.n);if(!known.has(ic.n)){index.push({n:ic.n,c:ic.c,t:ic.t});known.add(ic.n)}added.push(ic.n)}}
90
+ module.exports.total=index.length;return added}
91
+ // your own icons never need a licence
92
+ const locked=names=>Lic.locked(names.filter(n=>!custom.has(n)));
93
+ // MAGIC_GLYPHS_CUSTOM: files or folders of your icons, separated like PATH, loaded for every command and the MCP server
94
+ if(process.env.MAGIC_GLYPHS_CUSTOM)try{addCustom(process.env.MAGIC_GLYPHS_CUSTOM.split(path.delimiter))}catch(e){process.stderr.write('magic-glyphs: MAGIC_GLYPHS_CUSTOM: '+e.message+'\n')}
95
+ module.exports={MG,data,byName,index,known,total:index.length,fullFile,categories,search,render,staticSvg,pascal,STYLES,FORMATS,addCustom,custom,locked,checkIcon};
package/licence.js CHANGED
@@ -28,10 +28,13 @@ function verify(key,publicPem){
28
28
  function storedKey(){if(process.env.MAGIC_GLYPHS_KEY)return process.env.MAGIC_GLYPHS_KEY;try{return JSON.parse(fs.readFileSync(storeFile(),'utf8')).key}catch(e){return null}}
29
29
  function current(){const k=storedKey();return k?verify(k):{ok:false,reason:'No licence key. Run: magic-glyphs login YOUR-KEY'}}
30
30
  function login(key){const r=verify(key);if(!r.ok)throw new Error(r.reason);fs.mkdirSync(home(),{recursive:true});fs.writeFileSync(storeFile(),JSON.stringify({key:key.trim()}),{mode:0o600});return r.payload}
31
+ // a random id for this computer, so the licence server can count devices; it holds nothing about the machine or the person
32
+ function deviceId(){const f=path.join(home(),'device');try{const d=fs.readFileSync(f,'utf8').trim();if(/^[A-Za-z0-9_-]{8,64}$/.test(d))return d}catch(e){}
33
+ const d=crypto.randomBytes(16).toString('base64url');try{fs.mkdirSync(home(),{recursive:true});fs.writeFileSync(f,d)}catch(e){}return d}
31
34
  function logout(){try{fs.unlinkSync(storeFile());return true}catch(e){return false}}
32
35
  const isFree=n=>FREE.has(n);
33
36
  // names the caller may not export yet; empty when licensed or when every name is in the free set
34
37
  function locked(names){const paid=names.filter(n=>!FREE.has(n));if(!paid.length)return[];return current().ok?[]:paid}
35
38
  function lockedMessage(paid){return (paid.length===1?'"'+paid[0]+'" is':paid.length+' of these icons are')+' in the paid set. '+current().reason.replace(/^No licence key\. /,'')+(paid.length>1&&paid.length<=8?' Paid: '+paid.join(', ')+'.':'')+' Free icons: magic-glyphs list --free'+buyLine()}
36
39
  function buyLine(){let u=process.env.MAGIC_GLYPHS_BUY;if(!u)try{u=(require('./package.json').magicGlyphs||{}).buy}catch(e){}return u?'\nBuy a licence: '+u+' (or run: npx magic-glyphs buy)':''}
37
- module.exports={home,FREE,PLANS,keygen,issue,verify,current,login,logout,isFree,locked,lockedMessage,storeFile};
40
+ module.exports={home,FREE,PLANS,keygen,issue,verify,current,login,logout,isFree,locked,lockedMessage,storeFile,deviceId};
package/mcp/server.js CHANGED
@@ -26,7 +26,7 @@ server.registerTool('get_icon',{title:'Get icon',
26
26
  async({name,format,style,color,secondary,size})=>{
27
27
  if(!L.byName.has(name)&&L.known.has(name)){const Lic=require('../licence.js');return err(Lic.current().ok?'"'+name+'" is in the paid set. The licence is valid, but the full set is not on this computer yet. Run: npx magic-glyphs sync':Lic.lockedMessage([name])+'\nTell the user this icon needs a Magic Glyphs licence, or pick a free icon instead (search results marked "free").')}
28
28
  if(!L.byName.has(name)){const s=L.search(name,{limit:5}).map(x=>x.name);return err('No icon named "'+name+'".'+(s.length?' Did you mean: '+s.join(', ')+'?':' Use search_icons to find one.'))}
29
- {const Lic=require('../licence.js'),paid=Lic.locked([name]);if(paid.length)return err(Lic.lockedMessage(paid))}
29
+ {const Lic=require('../licence.js'),paid=L.locked([name]);if(paid.length)return err(Lic.lockedMessage(paid))}
30
30
  try{const f=L.render(name,format||'html',{style,color,secondary,size});return text('File: '+f.file+'\n\n'+f.text)}catch(e){return err(e.message)}});
31
31
  server.registerTool('usage_guide',{title:'Usage guide',description:'How to install and use Magic Glyphs in a given kind of project.',
32
32
  inputSchema:{platform:z.enum(['html','react','vue','angular','wordpress','shopify','rust','ios','android','windows','flutter']).describe('The project type')},annotations:{readOnlyHint:true}},