{"_id":"@svg-fns/io","_rev":"3-cef803c5bf06fd0ce362ebc4eb0f7c42","name":"@svg-fns/io","dist-tags":{"latest":"1.0.1"},"versions":{"0.0.0":{"name":"@svg-fns/io","version":"0.0.0","keywords":["svg","svg parser","svg io","svg string","svg dom","svg serialization","svg parse","svg load","svg utils","browser","nodejs","utilities","svg-fns","svg-fns-io","Customizable","Cutting-edge","Compatibility","Frontend development","UI components","Progressive","Web development","Modern","Seamless integration","mayank1513"],"author":{"url":"https:/mayank-chaudhari.vercel.app","name":"Mayank Kumar Chaudhari"},"license":"MPL-2.0","_id":"@svg-fns/io@0.0.0","maintainers":[{"name":"mayank1513","email":"mayank.srmu@gmail.com"}],"homepage":"https://github.com/svg-fns/svg-fns/tree/main/packages/io/#readme","bugs":{"url":"https://github.com/svg-fns/svg-fns/issues"},"dist":{"shasum":"ed3a4222c73d6bb9c3796692845e5c122218eb2a","tarball":"https://registry.npmjs.org/@svg-fns/io/-/io-0.0.0.tgz","fileCount":7,"integrity":"sha512-n4Mlfod4Y5qKUebopkws4tfwMvx/USErR9HyXSYB54MeWNEaF/fb9WgSqOZnWmYmHtZ34cV0VqU7iquStQ1z4Q==","signatures":[{"sig":"MEUCIQC4K27MOOpvKG26pQ81JlR2gWHrpmiDzRWuap9sQW6rjAIgZVPEL7zPvCuf60Uyoikra/LZYqhJU0NCaCXygfDdTbw=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":39191},"main":"./dist/index.js","_from":"file:svg-fns-io-0.0.0.tgz","types":"./dist/index.d.ts","module":"./dist/index.mjs","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"funding":[{"url":"https://github.com/sponsors/svg-fns","type":"github"},{"url":"https:/github.com/sponsors/mayank1513","type":"github"}],"private":false,"scripts":{"dev":"tsup --watch","build":"tsup && gzip -c dist/index.js | wc -c","clean":"rm -rf dist","typecheck":"tsc --noEmit"},"_npmUser":{"name":"mayank1513","email":"mayank.srmu@gmail.com"},"_resolved":"C:\\Users\\G\\AppData\\Local\\Temp\\93145f1be978000e1882fe3055ce82a9\\svg-fns-io-0.0.0.tgz","_integrity":"sha512-n4Mlfod4Y5qKUebopkws4tfwMvx/USErR9HyXSYB54MeWNEaF/fb9WgSqOZnWmYmHtZ34cV0VqU7iquStQ1z4Q==","repository":{"url":"git+https://github.com/svg-fns/svg-fns.git","type":"git"},"_npmVersion":"10.9.3","description":"Simple and fast utilities to parse, serialize, and load SVG strings and elements. Optimized for both browser and Node.js environments.","directories":{},"sideEffects":false,"_nodeVersion":"22.19.0","_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.5.0","typescript":"^5.9.2","@types/node":"^24.5.0","@xmldom/xmldom":"^0.8.11","esbuild-plugin-rdi":"^0.0.0"},"peerDependencies":{"@xmldom/xmldom":"^0.8.11"},"peerDependenciesMeta":{"@xmldom/xmldom":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/io_0.0.0_1758689923176_0.20733271661847974","host":"s3://npm-registry-packages-npm-production"}},"1.0.0":{"name":"@svg-fns/io","version":"1.0.0","keywords":["svg","svg parser","svg io","svg string","svg dom","svg serialization","svg parse","svg load","svg utils","browser","nodejs","utilities","svg-fns","svg-fns-io","Customizable","Cutting-edge","Compatibility","Frontend development","UI components","Progressive","Web development","Modern","Seamless integration","mayank1513"],"author":{"url":"https:/mayank-chaudhari.vercel.app","name":"Mayank Kumar Chaudhari"},"license":"MPL-2.0","_id":"@svg-fns/io@1.0.0","maintainers":[{"name":"mayank1513","email":"mayank.srmu@gmail.com"}],"homepage":"https://github.com/svg-fns/svg-fns/tree/main/packages/io/#readme","bugs":{"url":"https://github.com/svg-fns/svg-fns/issues"},"dist":{"shasum":"4b4d14bf3f58be51fe4cd2f3f46408877f2cdaf5","tarball":"https://registry.npmjs.org/@svg-fns/io/-/io-1.0.0.tgz","fileCount":31,"integrity":"sha512-fDZTyIjbl327M9H8W6U1TJkaLlVNvSQ1SWLKjHTZlCWTywXQHJOIekpSHhCjlVc6ogU8uQ0E1/6UbPx60qv/NA==","signatures":[{"sig":"MEQCIC2PqFAPALyCPUF6u29DurwTdDVcDIwXoyzuHxy5UhjeAiAyaZ1JWs+cBs1uSix7Pc8xTklDr/dXWMyf/9hbW9N4EQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":966858},"main":"./dist/index.js","_from":"file:svg-fns-io-1.0.0.tgz","types":"./dist/index.d.ts","module":"./dist/index.mjs","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"},"./*":{"types":["./dist/*.d.ts","./dist/*/index.d.ts"],"import":["./dist/*.mjs","./dist/*/index.mjs"],"require":["./dist/*.js","./dist/*/index.js"]},"./dist/*":{"types":["./dist/*.d.ts","./dist/*/index.d.ts"],"import":["./dist/*.mjs","./dist/*/index.mjs"],"require":["./dist/*.js","./dist/*/index.js"]}},"funding":[{"url":"https://github.com/sponsors/svg-fns","type":"github"},{"url":"https:/github.com/sponsors/mayank1513","type":"github"}],"private":false,"scripts":{"dev":"tsup --watch","build":"tsup && gzip -c dist/index.js | wc -c","clean":"rm -rf dist","typecheck":"tsc --noEmit"},"_npmUser":{"name":"mayank1513","email":"mayank.srmu@gmail.com"},"_resolved":"/tmp/3f4ee1ceb06c889f3f9b64e6b19ee082/svg-fns-io-1.0.0.tgz","_integrity":"sha512-fDZTyIjbl327M9H8W6U1TJkaLlVNvSQ1SWLKjHTZlCWTywXQHJOIekpSHhCjlVc6ogU8uQ0E1/6UbPx60qv/NA==","repository":{"url":"git+https://github.com/svg-fns/svg-fns.git","type":"git"},"_npmVersion":"10.8.2","description":"Simple and fast utilities to parse, serialize, and load SVG strings and elements. Optimized for both browser and Node.js environments.","directories":{},"sideEffects":false,"_nodeVersion":"20.19.5","_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.5.0","typescript":"^5.9.2","@types/node":"^24.5.0","@xmldom/xmldom":"^0.8.11","esbuild-plugin-rdi":"^0.0.0"},"peerDependencies":{"@xmldom/xmldom":"^0.8.11"},"peerDependenciesMeta":{"@xmldom/xmldom":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/io_1.0.0_1758816388285_0.05437833619271526","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@svg-fns/io","author":{"name":"Mayank Kumar Chaudhari","url":"https:/mayank-chaudhari.vercel.app"},"private":false,"version":"1.0.1","description":"Simple and fast utilities to parse, serialize, and load SVG strings and elements. Optimized for both browser and Node.js environments.","license":"MPL-2.0","main":"./dist/index.js","module":"./dist/index.mjs","types":"./dist/index.d.ts","repository":{"type":"git","url":"git+https://github.com/svg-fns/svg-fns.git"},"bugs":{"url":"https://github.com/svg-fns/svg-fns/issues"},"homepage":"https://github.com/svg-fns/svg-fns/tree/main/packages/io/#readme","sideEffects":false,"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"},"./*":{"types":["./dist/*.d.ts","./dist/*/index.d.ts"],"import":["./dist/*.mjs","./dist/*/index.mjs"],"require":["./dist/*.js","./dist/*/index.js"]},"./dist/*":{"types":["./dist/*.d.ts","./dist/*/index.d.ts"],"import":["./dist/*.mjs","./dist/*/index.mjs"],"require":["./dist/*.js","./dist/*/index.js"]}},"devDependencies":{"@types/node":"^24.5.0","@xmldom/xmldom":"^0.8.11","esbuild-plugin-rdi":"^0.0.0","tsup":"^8.5.0","typescript":"^5.9.2"},"funding":[{"type":"github","url":"https://github.com/sponsors/svg-fns"},{"type":"github","url":"https:/github.com/sponsors/mayank1513"}],"keywords":["svg","svg parser","svg io","svg string","svg dom","svg serialization","svg parse","svg load","svg utils","browser","nodejs","utilities","svg-fns","svg-fns-io","Customizable","Cutting-edge","Compatibility","Frontend development","UI components","Progressive","Web development","Modern","Seamless integration","mayank1513"],"peerDependencies":{"@xmldom/xmldom":"^0.8.11"},"peerDependenciesMeta":{"@xmldom/xmldom":{"optional":true}},"scripts":{"build":"tsup && gzip -c dist/index.js | wc -c","clean":"rm -rf dist","dev":"tsup --watch","typecheck":"tsc --noEmit"},"_id":"@svg-fns/io@1.0.1","_integrity":"sha512-QcrGrP+JO9zkmFwBaAOLstA4qMzfM+RDoQrYm6JnQX/WhB56Uj5+goC+IhzAf7d0xbW7EbhBrYarr1dvP8D6hA==","_resolved":"/tmp/4d79c3c0fca6f6a50b821426acfbb6ac/svg-fns-io-1.0.1.tgz","_from":"file:svg-fns-io-1.0.1.tgz","_nodeVersion":"20.19.5","_npmVersion":"10.8.2","dist":{"integrity":"sha512-QcrGrP+JO9zkmFwBaAOLstA4qMzfM+RDoQrYm6JnQX/WhB56Uj5+goC+IhzAf7d0xbW7EbhBrYarr1dvP8D6hA==","shasum":"b65992e42da5f1290d3dbb9a2ce0ce4032018770","tarball":"https://registry.npmjs.org/@svg-fns/io/-/io-1.0.1.tgz","fileCount":31,"unpackedSize":966942,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCWK66jlBmy67OwFyKdPyDEDH3H+nU9/i8e7JCxr1EzQgIgKn9+NS3wG4lPsyk2mygQHPP4PJwrIn5cQ8ua5YQ7Qto="}]},"_npmUser":{"name":"mayank1513","email":"mayank.srmu@gmail.com"},"directories":{},"maintainers":[{"name":"mayank1513","email":"mayank.srmu@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/io_1.0.1_1758881026160_0.8038647801315801"},"_hasShrinkwrap":false}},"time":{"created":"2025-09-24T04:58:43.120Z","modified":"2025-09-26T10:03:46.654Z","0.0.0":"2025-09-24T04:58:43.368Z","1.0.0":"2025-09-25T16:06:28.534Z","1.0.1":"2025-09-26T10:03:46.450Z"},"bugs":{"url":"https://github.com/svg-fns/svg-fns/issues"},"author":{"name":"Mayank Kumar Chaudhari","url":"https:/mayank-chaudhari.vercel.app"},"license":"MPL-2.0","homepage":"https://github.com/svg-fns/svg-fns/tree/main/packages/io/#readme","keywords":["svg","svg parser","svg io","svg string","svg dom","svg serialization","svg parse","svg load","svg utils","browser","nodejs","utilities","svg-fns","svg-fns-io","Customizable","Cutting-edge","Compatibility","Frontend development","UI components","Progressive","Web development","Modern","Seamless integration","mayank1513"],"repository":{"type":"git","url":"git+https://github.com/svg-fns/svg-fns.git"},"description":"Simple and fast utilities to parse, serialize, and load SVG strings and elements. Optimized for both browser and Node.js environments.","maintainers":[{"name":"mayank1513","email":"mayank.srmu@gmail.com"}],"readme":"# @svg-fns/io <img src=\"https://raw.githubusercontent.com/mayank1513/mayank1513/main/popper.png\" style=\"height: 40px\"/>\n\n[![test](https://github.com/svg-fns/svg-fns/actions/workflows/test.yml/badge.svg)](https://github.com/svg-fns/svg-fns/actions/workflows/test.yml)\n[![codecov](https://codecov.io/gh/svg-fns/svg-fns/graph/badge.svg)](https://codecov.io/gh/svg-fns/svg-fns)\n[![Version](https://img.shields.io/npm/v/@svg-fns/io.svg?colorB=green)](https://www.npmjs.com/package/@svg-fns/io)\n[![Downloads](https://img.jsdelivr.com/img.shields.io/npm/d18m/@svg-fns/io.svg)](https://www.npmjs.com/package/@svg-fns/io)\n![npm bundle size](https://img.shields.io/bundlephobia/minzip/@svg-fns/io)\n[![NPM License](https://img.shields.io/npm/l/@svg-fns/io)](../../LICENSE)\n\nFeather-light **I/O utilities for working with SVGs** in **browser** and **Node.js**. Minimal, dev-friendly, and universal.\n\n---\n\n## TL;DR 🚀\n\n| Feature                           | Browser | Node.js                     | Notes                                             |\n| --------------------------------- | ------- | --------------------------- | ------------------------------------------------- |\n| Parse SVG string → `SVGElement`   | ✅ sync | ✅ async (`@xmldom/xmldom`) | Safe / unsafe modes                               |\n| Serialize `SVGElement` → string   | ✅ sync | ✅ async                    | Standards-compliant (`XMLSerializer`)             |\n| Load from string, URL, File, Blob | ✅      | ✅ string + URL             | Unified API across envs                           |\n| Unsafe fast parsing               | ✅      | ❌                          | Only for trusted inputs, risk arises on DOM mount |\n\n---\n\n## Why @svg-fns/io?\n\n- **Feather-light:** No dependencies unless in Node.js.\n- **Universal:** Works in browser + Node.\n- **Dev-friendly:** Throws meaningful errors, ideal for library authors and apps.\n- **Secure:** Unsafe mode is optional and clearly documented.\n- **Composable:** Integrates with other `svg-fns` groups (convert, geometry, style, etc.).\n- **OSS-advantage:** Designed for corporate, personal, and open-source projects.\n\n---\n\n## Features\n\n<details>\n<summary>Parsing</summary>\n\n- `parseSvgBrowser(svgString, config?)` – sync, safe (DOMParser) or unsafe (innerHTML).\n- `unsafeParseSvg(svgString, config)` – fast, only for trusted inputs.\n- `parseSvgNode(svgString, config?)` – async Node.js parser.\n- `parseSvg(svgString, config?)` – universal wrapper.\n\n</details>\n\n<details>\n<summary>Serialization</summary>\n\n- `serializeSvgBrowser(svgElement, config?)` – sync, standards-compliant.\n- `serializeSvgNode(svgElement, config?)` – async Node.js serializer.\n- `serializeSvg(svgElement, config?)` – universal wrapper.\n\n</details>\n\n<details>\n<summary>Loading SVGs</summary>\n\n- `loadSvg(input: string | File | Blob | URL, config?)` – unified loader.\n\n  - Browser: string, File, Blob, URL\n  - Node.js: string, URL (via fetch)\n\n</details>\n\n---\n\n## Usage Examples\n\n```ts\nimport { parseSvg, serializeSvg, loadSvg } from \"@svg-fns/io\";\n\n// parse SVG safely\nconst svgEl = parseSvg(`<svg><circle cx=\"5\" cy=\"5\" r=\"5\"/></svg>`);\n\n// serialize back to string\nconst svgString = serializeSvg(svgEl);\n\n// load from URL\nconst svgFromUrl = await loadSvg(\"https://example.com/icon.svg\");\n```\n\n---\n\n## Browser & Node Compatibility\n\n| Feature                   | Browser | Node.js                                |\n| ------------------------- | ------- | -------------------------------------- |\n| DOMParser / XMLSerializer | ✅      | ❌ (needs @xmldom/xmldom, lazy-loaded) |\n| innerHTML fast parsing    | ✅      | ❌                                     |\n| File / Blob               | ✅      | ❌ natively                            |\n| URL fetch                 | ✅      | ✅ (node-fetch / global fetch)         |\n\n---\n\n## Security Notes\n\n- **Unsafe mode**: parsing itself does **not** execute scripts.\n- Risk arises only when the parsed SVG is **attached to the DOM**.\n- Always sanitize untrusted SVGs before mounting in unsafe mode.\n\n---\n\n## Installation\n\n```bash\npnpm add @svg-fns/io\n```\n\n**_or_**\n\n```\nnpm install @svg-fns/io\n```\n\n---\n\n## Configuration (`IOConfig`)\n\n| Option                | Type                 | Default | Description                                   |\n| --------------------- | -------------------- | ------- | --------------------------------------------- |\n| `unsafe`              | boolean              | false   | Browser only: use innerHTML parsing for speed |\n| `removeScripts`       | boolean              | true    | Strip `<script>` elements in unsafe mode      |\n| `removeEventHandlers` | boolean              | true    | Strip `on*` attributes in unsafe mode         |\n| `removeForeignObject` | boolean              | false   | Remove `<foreignObject>` elements             |\n| `strict`              | boolean              | true    | Validate root element is `<svg>`              |\n| `domParser`           | typeof DOMParser     | auto    | Custom parser                                 |\n| `xmlSerializer`       | typeof XMLSerializer | auto    | Custom serializer                             |\n\n---\n\n## Contribution & Sponsorship\n\n`@svg-fns/io` thrives with your feedback, PRs, and sponsorship:\n\n- ⭐ Star to show support\n- 📝 Submit issues / PRs for bug fixes, new features\n- 💖 Sponsor via GitHub Sponsors or Patreon\n\nWe welcome **OSS, corporate, and personal project use** — MPL 2.0 ensures safe adoption in commercial products.\n\n---\n\n## SEO & AI-Friendly Tips\n\n- Keywords: `SVG utilities`, `SVG parser`, `SVG serializer`, `SVG Node.js`, `feather-light SVG library`, `universal SVG library`.\n- AI usage: The functions are deterministic and type-safe; perfect for AI-assisted SVG generation pipelines.\n\n---\n\n## Roadmap / Future Enhancements\n\n- `convert` utilities: Base64, raster, download\n- `geometry` utilities: crop, resize, merge\n- `style` utilities: inline, optimize, strip scripts/styles\n- Framework JSX/TSX output (`react`, `vue`, `solid`)\n\n## License\n\nThis library is licensed under the MPL-2.0 open-source license.\n\n> <img src=\"https://raw.githubusercontent.com/mayank1513/mayank1513/main/popper.png\" style=\"height: 20px\"/> Please enroll in [our courses](https://mayank-chaudhari.vercel.app/courses) or [sponsor](https://github.com/sponsors/mayank1513) our work.\n\n<hr />\n\n<p align=\"center\" style=\"text-align:center\">with 💖 by <a href=\"https://mayank-chaudhari.vercel.app\" target=\"_blank\">Mayank Kumar Chaudhari</a></p>\n","readmeFilename":"README.md"}