magic-glyphs 0.6.0 → 0.6.2

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/cli/index.js CHANGED
@@ -14,7 +14,10 @@ Usage
14
14
  magic-glyphs bundle [name...] [--out <file>] one script for web pages: the runtime plus the icons you name (all if none)
15
15
  magic-glyphs static [--out <dir>] [--styles outline,solid,duotone] plain SVG files and sprites, no JavaScript
16
16
  magic-glyphs registry [--out <dir>] [--homepage <url>] shadcn registry files to host
17
- magic-glyphs login <key> | sync | logout | licence paid icons need a licence key; sync re-downloads the full set
17
+ magic-glyphs login YOUR-KEY | sync | logout | licence paid icons need a licence key; sync re-downloads the full set
18
+ magic-glyphs update check for a newer version and download new paid icons
19
+ magic-glyphs --version
20
+ magic-glyphs buy open the page where you can buy a licence
18
21
 
19
22
  Options for add
20
23
  --format <f> svg (default) | lottie | react | vue | json | html
@@ -24,6 +27,7 @@ Options for add
24
27
  --secondary <hex> duotone fill colour
25
28
  --background <hex> colour knocked out of solid icons (default #ffffff)
26
29
  --size <px> svg width and height (default 24)
30
+ --ts | --js typed or plain React/Vue components (default: typed when the project has a tsconfig.json)
27
31
  --stdout print a single icon instead of writing a file
28
32
  --dry-run show what would be written
29
33
 
@@ -33,8 +37,8 @@ Examples
33
37
  magic-glyphs add --category arrows --format lottie --color "#2747f5" --out assets/lottie
34
38
  `;
35
39
  function parse(argv){const pos=[],opt={};for(let i=0;i<argv.length;i++){const a=argv[i];
36
- if(a.startsWith('--')){const k=a.slice(2);if(['json','all','stdout','dry-run','help','free','show-key'].includes(k))opt[k]=true;else{if(i+1>=argv.length)fail('Option --'+k+' needs a value.');opt[k]=argv[++i]}}
37
- else if(a==='-h')opt.help=true;else pos.push(a)}return{pos,opt}}
40
+ if(a.startsWith('--')){const k=a.slice(2);if(['json','all','stdout','dry-run','help','free','show-key','version','ts','js'].includes(k))opt[k]=true;else{if(i+1>=argv.length)fail('Option --'+k+' needs a value.');opt[k]=argv[++i]}}
41
+ else if(a==='-h')opt.help=true;else if(a==='-v')opt.version=true;else pos.push(a)}return{pos,opt}}
38
42
  // fetch the full set for a valid key; the server address comes from MAGIC_GLYPHS_API or package.json "magicGlyphs.api"
39
43
  const apiBase=()=>(process.env.MAGIC_GLYPHS_API||(require('../package.json').magicGlyphs||{}).api||'').replace(/\/$/,'');
40
44
  // swap the licence key from a Gumroad receipt for a Magic Glyphs key; the server checks the purchase with Gumroad
@@ -43,9 +47,9 @@ async function redeem(gumroadKey){
43
47
  const api=apiBase();if(!/^https?:\/\//.test(api))throw new Error('no licence server is configured');
44
48
  let r;try{r=await fetch(api+'/v1/redeem',{method:'POST',headers:{'content-type':'application/json'},body:JSON.stringify({licence_key:gumroadKey})})}catch(e){throw new Error('The licence server could not be reached. Check your connection and try again.')}
45
49
  let d={};try{d=await r.json()}catch(e){}if(!r.ok||!d.key)throw new Error(d.error||'The licence server answered '+r.status+'.');return d.key}
46
- async function download(){
50
+ async function download(force){
47
51
  const api=(process.env.MAGIC_GLYPHS_API||(require('../package.json').magicGlyphs||{}).api||'').replace(/\/$/,'');
48
- if(L.data.icons.length>=L.total&&!process.env.MAGIC_GLYPHS_API)return 0;
52
+ if(!force&&L.data.icons.length>=L.total&&!process.env.MAGIC_GLYPHS_API)return 0;
49
53
  if(!/^https?:\/\//.test(api))throw new Error('no download server is configured');
50
54
  const key=process.env.MAGIC_GLYPHS_KEY||JSON.parse(fs.readFileSync(Lic.storeFile(),'utf8')).key;
51
55
  const r=await fetch(api+'/v1/icons.json',{headers:{authorization:'Bearer '+key}});
@@ -53,8 +57,18 @@ async function download(){
53
57
  const text=await r.text(),d=JSON.parse(text);if(!d||!Array.isArray(d.icons))throw new Error('the server sent something unexpected');
54
58
  fs.mkdirSync(Lic.home(),{recursive:true});fs.writeFileSync(L.fullFile(),text);return d.icons.length}
55
59
  function fail(msg){process.stderr.write('magic-glyphs: '+msg+'\n');process.exit(1)}
60
+ // where to buy a licence; MAGIC_GLYPHS_BUY or package.json "magicGlyphs.buy"
61
+ const buyUrl=()=>process.env.MAGIC_GLYPHS_BUY||(require('../package.json').magicGlyphs||{}).buy||'';
62
+ const BUYLINE=()=>buyUrl()?'Buy a licence: '+buyUrl()+' (or run: npx magic-glyphs buy)':'';
63
+ // open the buy page in the browser, only for a person at a terminal (never in CI or when MAGIC_GLYPHS_NO_OPEN is set)
64
+ function openBuy(){const u=buyUrl();if(!u)return false;
65
+ if(!process.stdout.isTTY||process.env.CI||process.env.MAGIC_GLYPHS_NO_OPEN)return false;
66
+ const cp=require('child_process');const [c,a]=process.platform==='win32'?['cmd',['/c','start','""',u]]:process.platform==='darwin'?['open',[u]]:['xdg-open',[u]];
67
+ try{const ch=cp.spawn(c,a,{stdio:'ignore',detached:true});ch.on('error',()=>{});ch.unref();return true}catch(e){return false}}
68
+ function failBuy(msg){process.stderr.write('magic-glyphs: '+msg+'\n');const b=BUYLINE();if(b)process.stderr.write(b+'\n');process.exit(1)}
56
69
  const {pos,opt}=parse(process.argv.slice(2)),cmd=pos.shift();
57
70
  try{
71
+ if(opt.version||cmd==='version'){console.log(require('../package.json').version);process.exit(0)}
58
72
  if(!cmd||opt.help||cmd==='help'){process.stdout.write(HELP);process.exit(cmd||opt.help?0:1)}
59
73
  if(opt.category&&!L.categories()[opt.category])fail('No category "'+opt.category+'". Run: magic-glyphs categories');
60
74
  if(cmd==='categories'){const c=L.categories();Object.keys(c).sort().forEach(k=>console.log(k.padEnd(12)+String(c[k]).padStart(5)));console.log('total'.padEnd(12)+String(L.total).padStart(5))}
@@ -66,7 +80,7 @@ try{
66
80
  else rows.forEach(r=>console.log(r.name.padEnd(28)+r.category.padEnd(11)+r.tags));
67
81
  }
68
82
  else if(cmd==='info'){
69
- if(!pos[0])fail('Give an icon name.');const ic=L.byName.get(pos[0]);if(!ic)fail(L.known.has(pos[0])?'"'+pos[0]+'" is in the paid set. Run: magic-glyphs login <key>':'No icon named "'+pos[0]+'". Try: magic-glyphs search '+pos[0]);
83
+ if(!pos[0])fail('Give an icon name.');const ic=L.byName.get(pos[0]);if(!ic)fail(L.known.has(pos[0])?'"'+pos[0]+'" is in the paid set. Run: magic-glyphs login YOUR-KEY'+(buyUrl()?'\n'+BUYLINE():''):'No icon named "'+pos[0]+'". Try: magic-glyphs search '+pos[0]);
70
84
  console.log(['name '+ic.n,'category '+ic.c,'tags '+ic.t,'layers '+ic.L.map(l=>l.i).join(', '),'animated '+(ic.A.length?'yes ('+ic.A.length+' spring'+(ic.A.length>1?'s':'')+')':'no'),'html <magic-glyph name="'+ic.n+'"></magic-glyph>'].join('\n'));
71
85
  }
72
86
  else if(cmd==='add'){
@@ -76,6 +90,8 @@ try{
76
90
  const paid=Lic.locked(names);if(paid.length)fail(Lic.lockedMessage(paid));
77
91
  const away=names.filter(n=>!L.byName.has(n));if(away.length)fail('Your licence is valid, but the full icon set is not on this computer yet. Run: magic-glyphs sync');
78
92
  const format=opt.format||'svg',o={style:opt.style,color:opt.color,secondary:opt.secondary,background:opt.background,size:opt.size&&+opt.size};
93
+ // React and Vue components come out typed in TypeScript projects (.tsx, lang="ts") (a tsconfig.json in this folder or above), .jsx otherwise; --ts or --js overrides
94
+ if(format==='react'||format==='vue')o.ts=opt.ts?true:opt.js?false:(()=>{let d=process.cwd();for(;;){if(fs.existsSync(path.join(d,'tsconfig.json')))return true;const up=path.dirname(d);if(up===d)return false;d=up}})();
79
95
  if(opt.size&&!(+opt.size>0))fail('--size must be a positive number.');
80
96
  for(const k of ['color','secondary','background'])if(opt[k]&&!/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.test(opt[k])&&!(format==='svg'&&/^[a-z]+$/i.test(opt[k])))fail('--'+k+' must be a hex colour such as #2747f5.');
81
97
  if(opt.stdout){if(names.length!==1)fail('--stdout prints one icon; name exactly one.');process.stdout.write(L.render(names[0],format,o).text+'\n')}
@@ -84,9 +100,19 @@ try{
84
100
  console.log((opt['dry-run']?'Would write ':'Wrote ')+files.length+' file'+(files.length>1?'s':'')+' to '+dir+(files.length<=6?': '+files.map(f=>f.file).join(', '):''));
85
101
  if(format==='react'||format==='vue')console.log('These components import from the "magic-glyphs" package, so keep it installed.');}
86
102
  }
103
+ else if(cmd==='update'){const mine=require('../package.json').version;
104
+ const newer=(a,b)=>{const x=a.split(/[.-]/).map(Number),y=b.split(/[.-]/).map(Number);for(let i=0;i<3;i++){if((x[i]||0)!==(y[i]||0))return (x[i]||0)>(y[i]||0)}return false};
105
+ (async()=>{let latest=null;try{const r=await fetch('https://registry.npmjs.org/magic-glyphs/latest');if(r.ok)latest=(await r.json()).version}catch(e){}
106
+ if(!latest)console.log('Could not reach npm to check for a newer version. This is '+mine+'.');
107
+ else if(newer(latest,mine))console.log('Version '+latest+' is out (this is '+mine+'). Install it with:\n npm install magic-glyphs@latest\nThen run: npx magic-glyphs update');
108
+ else console.log('You have the latest version ('+mine+').');
109
+ if(!Lic.current().ok){console.log(Lic.FREE.size+' free icons included. '+(BUYLINE()||''));return}
110
+ const n=await download(true).catch(e=>{fail(e.message)});console.log(n?'Icons up to date: '+n+' icons.':'Icons up to date.')})();return}
111
+ else if(cmd==='buy'){const u=buyUrl();if(!u)fail('No buy page is configured.');console.log(u);if(openBuy())console.log('Opened in your browser.')}
87
112
  else if(cmd==='login'||cmd==='sync'){
88
- if(cmd==='login'){if(!pos[0])fail('Give the licence key from your Gumroad receipt: magic-glyphs login <key>');
89
- if(!/^MG1\./.test(pos[0].trim())){redeem(pos[0].trim()).then(k=>{const p=Lic.login(k);console.log('Licence saved for '+p.email+' ('+p.plan+', '+p.seats+' seat'+(p.seats>1?'s':'')+').');return download()}).then(n=>console.log(n?'Downloaded the full set: '+n+' icons.':'This copy already has every icon.')).catch(e=>fail(e.message));return}
113
+ if(cmd==='login'){if(!pos[0]||/^<.*>$/.test(pos[0])||/gumroad-key|your-.*key|^x{8}(-x{8}){3}$/i.test(pos[0])){const o=openBuy();
114
+ failBuy('Give the licence key from your Gumroad receipt, like: magic-glyphs login ABCD1234-EFGH5678-IJKL9012-MNOP3456'+(o?'\nOpening the buy page in your browser.':''))}
115
+ if(!/^MG1\./.test(pos[0].trim())){redeem(pos[0].trim()).then(k=>{const p=Lic.login(k);console.log('Licence saved for '+p.email+' ('+p.plan+', '+p.seats+' seat'+(p.seats>1?'s':'')+').');return download()}).then(n=>console.log(n?'Downloaded the full set: '+n+' icons.':'This copy already has every icon.')).catch(e=>failBuy(e.message));return}
90
116
  const p=Lic.login(pos[0]);console.log('Licence saved for '+p.email+' ('+p.plan+', '+p.seats+' seat'+(p.seats>1?'s':'')+').')}
91
117
  else if(!Lic.current().ok)fail(Lic.current().reason);
92
118
  download().then(n=>console.log(n?'Downloaded the full set: '+n+' icons.':'This copy already has every icon.')).catch(e=>fail('The key is saved, but the full set could not be downloaded ('+e.message+'). Try again with: magic-glyphs sync'));}
package/docs/cli.md CHANGED
@@ -56,7 +56,10 @@ Files for non-outline styles carry the style in the name, for example `heart.duo
56
56
  ## Licence and bundles
57
57
 
58
58
  ```bash
59
- npx magic-glyphs login <key> # the key from your Gumroad receipt; downloads the full library
59
+ npx magic-glyphs login YOUR-LICENCE-KEY # the key from your Gumroad receipt (no < > around it); downloads the full library
60
+ npx magic-glyphs buy # opens the page where you can buy a licence
61
+ npx magic-glyphs update # tells you if a newer version is out, then downloads new paid icons
62
+ npx magic-glyphs --version
60
63
  npx magic-glyphs licence # who this computer is licensed to
61
64
  npx magic-glyphs licence --show-key # prints the key to use on a build server
62
65
  npx magic-glyphs sync # download the full library again
package/docs/react-vue.md CHANGED
@@ -53,6 +53,10 @@ import HeartGlyph from './icons/HeartGlyph';
53
53
 
54
54
  Each file registers just its own icon, so the bundle contains the 7 KB engine plus the icons you added.
55
55
 
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
+
58
+ Tested with the default Vite React + TypeScript and Vue + TypeScript templates, and with Next.js (App Router).
59
+
56
60
  ## Module format
57
61
 
58
62
  The package is CommonJS today. Vite, webpack, Next.js and Nuxt import it without configuration. A native ES module build is planned.
package/lib.js CHANGED
@@ -42,7 +42,7 @@ function staticSvg(name,o){
42
42
  .replace(/currentColor/g,col).replace(' overflow="visible"','');
43
43
  }
44
44
  function render(name,format,o){
45
- const ic=byName.get(name);if(!ic)throw new Error(known.has(name)?'"'+name+'" is in the paid set and is not on this computer yet. Run: magic-glyphs login <key>':'No icon named "'+name+'". Try: magic-glyphs search '+name);
45
+ const ic=byName.get(name);if(!ic)throw new Error(known.has(name)?'"'+name+'" is in the paid set and is not on this computer yet. Run: magic-glyphs login YOUR-KEY':'No icon named "'+name+'". Try: magic-glyphs search '+name);
46
46
  o=o||{};const style=o.style||'outline';
47
47
  if(!STYLES.includes(style))throw new Error('Unknown style "'+style+'". Use one of: '+STYLES.join(', '));
48
48
  switch(format){
@@ -50,8 +50,10 @@ 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
- case 'react':return{ext:'jsx',file:pascal(name)+'Glyph.jsx',text:`import { MagicGlyph, register } from 'magic-glyphs/react';\n\nregister([${JSON.stringify(ic)}]);\n\n/** Animated "${name}" icon. Props: variant, size, trigger, label, className, style. */\nexport default function ${pascal(name)}Glyph(props) {\n return <MagicGlyph name="${name}" variant="${style}" {...props} />;\n}\n`};
54
- case 'vue':return{ext:'vue',file:pascal(name)+'Glyph.vue',text:`<script setup>\nimport { MagicGlyph, register } from 'magic-glyphs/vue';\n\nregister([${JSON.stringify(ic)}]);\n</script>\n\n<template>\n <MagicGlyph name="${name}" variant="${style}" v-bind="$attrs" />\n</template>\n`};
53
+ case 'react':{const P=pascal(name),ts=!!o.ts;
54
+ // "use client" lets the component sit inside a Next.js server component tree; other bundlers ignore it
55
+ 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`}}
56
+ case 'vue':return{ext:'vue',file:pascal(name)+'Glyph.vue',text:`<script setup${o.ts?' lang="ts"':''}>\nimport { MagicGlyph, register } from 'magic-glyphs/vue';\n\nregister([${JSON.stringify(ic)}]);\n</script>\n\n<template>\n <MagicGlyph name="${name}" variant="${style}" v-bind="$attrs" />\n</template>\n`};
55
57
  case 'html':return{ext:'html',file:name+'.html',text:`<magic-glyph name="${name}"${style==='outline'?'':' variant="'+style+'"'}${o.size?' size="'+o.size+'"':''}></magic-glyph>`};
56
58
  default:throw new Error('Unknown format "'+format+'". Use one of: '+FORMATS.join(', '));
57
59
  }
package/licence.js CHANGED
@@ -26,11 +26,12 @@ function verify(key,publicPem){
26
26
  if(payload.expires&&payload.expires<new Date().toISOString().slice(0,10))return{ok:false,reason:'This licence expired on '+payload.expires+'.',payload};
27
27
  return{ok:true,payload};}
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
- function current(){const k=storedKey();return k?verify(k):{ok:false,reason:'No licence key. Run: magic-glyphs login <key>'}}
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
31
  function logout(){try{fs.unlinkSync(storeFile());return true}catch(e){return false}}
32
32
  const isFree=n=>FREE.has(n);
33
33
  // names the caller may not export yet; empty when licensed or when every name is in the free set
34
34
  function locked(names){const paid=names.filter(n=>!FREE.has(n));if(!paid.length)return[];return current().ok?[]:paid}
35
- 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'}
35
+ 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
+ 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)':''}
36
37
  module.exports={home,FREE,PLANS,keygen,issue,verify,current,login,logout,isFree,locked,lockedMessage,storeFile};
package/mcp/server.js CHANGED
@@ -24,6 +24,7 @@ server.registerTool('get_icon',{title:'Get icon',
24
24
  color:z.string().regex(/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/).optional().describe('Hex colour for svg and lottie output'),secondary:z.string().regex(/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/).optional().describe('Hex duotone fill colour'),size:z.number().positive().max(2048).optional().describe('Pixel size for svg and html')},
25
25
  annotations:{readOnlyHint:true}},
26
26
  async({name,format,style,color,secondary,size})=>{
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").')}
27
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.'))}
28
29
  {const Lic=require('../licence.js'),paid=Lic.locked([name]);if(paid.length)return err(Lic.lockedMessage(paid))}
29
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)}});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "magic-glyphs",
3
- "version": "0.6.0",
3
+ "version": "0.6.2",
4
4
  "description": "Animated icons with spring motion and sound: web component, React, Vue, static SVG, Lottie export and a CLI. 120 icons free.",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "author": "Lewis John Villamor",
@@ -9,13 +9,19 @@
9
9
  "magic-glyphs": "cli/index.js"
10
10
  },
11
11
  "exports": {
12
- ".": "./web/runtime.js",
12
+ ".": {
13
+ "types": "./web/runtime.d.ts",
14
+ "default": "./web/runtime.js"
15
+ },
13
16
  "./all": "./web/magic-glyphs.all.js",
14
17
  "./react": {
15
18
  "types": "./react/index.d.ts",
16
19
  "default": "./react/index.js"
17
20
  },
18
- "./vue": "./vue/index.js",
21
+ "./vue": {
22
+ "types": "./vue/index.d.ts",
23
+ "default": "./vue/index.js"
24
+ },
19
25
  "./lottie": "./tools/lottie.js",
20
26
  "./node": "./lib.js",
21
27
  "./icons.json": "./data/icons.json",
@@ -68,7 +74,9 @@
68
74
  "mcp"
69
75
  ],
70
76
  "magicGlyphs": {
71
- "api": "https://magic-glyphs-licence.lewisvillamor26.workers.dev"
77
+ "api": "https://magic-glyphs-licence.lewisvillamor26.workers.dev",
78
+ "buy": "https://magicscraper.gumroad.com/l/vjaxbp"
72
79
  },
73
- "homepage": "https://magic-glyphs-site.lewisvillamor26.workers.dev"
80
+ "homepage": "https://magic-glyphs-site.lewisvillamor26.workers.dev",
81
+ "types": "./web/runtime.d.ts"
74
82
  }
package/react/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ 'use client';
1
2
  // Magic Glyphs for React. Usage: <MagicGlyph name="heart" variant="duotone" trigger="hover" size={32} label="Like" />
2
3
  // Renders the SVG on the server and the client; animation attaches after mount.
3
4
  const React=require('react');const MG=require('../web/runtime.js');
package/vue/index.d.ts ADDED
@@ -0,0 +1,16 @@
1
+ import type { DefineComponent } from 'vue';
2
+ export type GlyphVariant = 'outline' | 'solid' | 'duotone' | 'glass';
3
+ export interface MagicGlyphProps {
4
+ name: string;
5
+ variant?: GlyphVariant;
6
+ size?: number | string;
7
+ /** When the animation plays. Default "hover". */
8
+ trigger?: 'hover' | 'click' | 'load' | 'none';
9
+ /** Accessible name. Leave out for decorative icons. */
10
+ label?: string;
11
+ /** Play the icon's sound with its animation. */
12
+ sound?: boolean;
13
+ }
14
+ export const MagicGlyph: DefineComponent<MagicGlyphProps>;
15
+ export function register(icons: unknown): void;
16
+ export const sound: { enable(on?: boolean): void; enabled(): boolean; volume(v?: number): number };
@@ -0,0 +1,27 @@
1
+ // Types for the Magic Glyphs web runtime: import MagicGlyphs from 'magic-glyphs'
2
+ export type GlyphStyle = 'outline' | 'solid' | 'duotone' | 'glass';
3
+ export interface GlyphPlayer { play(): void; }
4
+ export interface GlyphSound {
5
+ /** Turn sound on or off for every icon. Off by default. */
6
+ enable(on?: boolean): void;
7
+ enabled(): boolean;
8
+ /** Get or set the volume, 0 to 1. */
9
+ volume(v?: number): number;
10
+ play(name: string, pan?: number): void;
11
+ names(): string[];
12
+ unlocked(): boolean;
13
+ }
14
+ export interface MagicGlyphsRuntime {
15
+ /** Add icon data, from a generated component or magic-glyphs/icons.json. */
16
+ register(icons: unknown): MagicGlyphsRuntime;
17
+ /** SVG markup for an icon in its resting pose. */
18
+ svg(name: string, options?: { style?: GlyphStyle; size?: number | string; title?: string }): string;
19
+ /** Make an element holding the icon's SVG playable. */
20
+ attach(element: Element, name: string): GlyphPlayer;
21
+ has(name: string): boolean;
22
+ names(): string[];
23
+ sound: GlyphSound;
24
+ [key: string]: unknown;
25
+ }
26
+ declare const MagicGlyphs: MagicGlyphsRuntime;
27
+ export = MagicGlyphs;