{"id":18583199,"url":"https://github.com/crabnebula-dev/file-icons","last_synced_at":"2025-04-10T11:36:58.818Z","repository":{"id":204871793,"uuid":"711887488","full_name":"crabnebula-dev/file-icons","owner":"crabnebula-dev","description":"File Icons for IDEs","archived":false,"fork":false,"pushed_at":"2025-04-09T02:46:55.000Z","size":1928,"stargazers_count":30,"open_issues_count":13,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-09T03:29:48.761Z","etag":null,"topics":["icons","vscode-icons"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/crabnebula-dev.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE-APACHE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-10-30T11:27:51.000Z","updated_at":"2025-01-10T19:37:41.000Z","dependencies_parsed_at":"2024-01-03T10:39:35.453Z","dependency_job_id":"9e292713-e456-4649-8df5-a05c87dc2dfa","html_url":"https://github.com/crabnebula-dev/file-icons","commit_stats":null,"previous_names":["crabnebula-dev/file-icons"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crabnebula-dev%2Ffile-icons","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crabnebula-dev%2Ffile-icons/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crabnebula-dev%2Ffile-icons/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crabnebula-dev%2Ffile-icons/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/crabnebula-dev","download_url":"https://codeload.github.com/crabnebula-dev/file-icons/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248208689,"owners_count":21065205,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["icons","vscode-icons"],"created_at":"2024-11-07T00:21:09.546Z","updated_at":"2025-04-10T11:36:53.797Z","avatar_url":"https://github.com/crabnebula-dev.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003ch1\u003e\n    \u003ccode\u003efile-icons\u003c/code\u003e\n  \u003c/h1\u003e\n  \u003cp\u003e\n    \u003cstrong\u003eFile Icons for IDEs\u003c/strong\u003e\n  \u003c/p\u003e\n  \u003cp\u003e\n\n![MIT or Apache 2.0 licensed][mit-or-apache-badge]\n\n\u003c/p\u003e\n\u003c/div\u003e\n\n[mit-or-apache-badge]: https://img.shields.io/badge/license-MIT%20or%20Apache%202.0-blue.svg\n\nThis package provides simple \u0026 fast programmatic access to the icons from\n[vscode-icons](https://github.com/vscode-icons/vscode-icons), letting you use\nthem in your own projects!\n\nThere are only two functions exported from this package: `getIconForFile` and\n`getIconForFolder`. They employ a matching heuristic similar to the one used in\nvscode-icons to find the best matching icon for a given file or folder.\n\n\u003e Note that this heuristic is simplified from the `vscode-icons` one, so it may\n\u003e not be as accurate or complete. It should be _good enough_ though, but feel\n\u003e free to open a PR if you find any issues!\n\n## Installation\n\nFor usage in JavaScript/TypeScript projects:\n\n```sh\nnpm install @crabnebula/file-icons\n# OR\nyarn add @crabnebula/file-icons\n# OR\npnpm add @crabnebula/file-icons\n```\n\nFor usage in Rust projects:\n\n```sh\ncargo add file-icons\n```\n\n## Usage\n\n### Matching a File Icon\n\n`getIconForFile` returns the URL of the icon for a given file or `null` if no\nmatching icon could be found. You **MUST** call `setCDN` before calling this\nfunction with a valid URL to where the icons from this package are hosted.\n\n```js\nimport { getIconForFile, setCDN } from \"@crabnebula/file-icons\";\n\nsetCDN(\"/icons/\"); // point this to wherever you have hosted the file-icons/icons folder\n\nconst icon = getIconForFile(\"foo.js\");\n```\n\n### Matching a Folder Icon\n\n`getIconForFolder` returns the URL of the icon for a given folder or `null` if\nno matching icon could be found. You **MUST** call `setCDN` before calling this\nfunction with a valid URL to where the icons from this package are hosted.\n\n```js\nimport { getIconForFolder, setCDN } from \"@crabnebula/file-icons\";\n\nsetCDN(\"/icons/\"); // point this to wherever you have hosted the file-icons/icons folder\n\nconst icon = getIconForFolder(\".github\");\n```\n\n### Usage from Rust\n\nThis package can also be used as a Rust crate. The API is a bit lower level\nthough, i.e. instead of returning a URL to the icon, it returns the `u64` ID of\nthe icon. Each ID maps to a `.svg` file in the `icons` folder.\n\n```rust\nuse file_icons::get_icon_for_file;\n\nfn main() {\n    let icon = get_icon_for_file(\"foo.js\"); // Returns the ID of the icon\n    println!(\"{}\", icon);\n}\n```\n\n## Benchmarks\n\nYou said fast, but how fast is t really?\n\nWell, plenty! Here's the benchmark results on a 2023 MacBook Pro:\n\n```\n                                [   min       mean        max   ]\n_get_icon_for_file      time:   [42.963 ns  43.045 ns  43.134 ns]\n_get_icon_for_folder    time:   [68.751 ns  68.879 ns  69.019 ns]\n```\n\nand here is the same running as WebAssembly in Safari on that same 2023 MacBook Pro:\n\n```\n                                [   min       mean        max   ]   \n_get_icon_for_file      time:   [53.251 ns  53.374 ns  53.538 ns]\n_get_icon_for_folder    time:   [70.595 ns  70.680 ns  70.771 ns]\n```\n\n## Usage with Vite\n\nIf you're using Vite then there are a few Vite plugins you will need:\n\n- [`vite-plugin-wasm`](https://www.npmjs.com/package/vite-plugin-wasm) \n  This plugin allows you to use WASM modules in your Vite project which this module depends on.\n- [`vite-plugin-top-level-await`](https://www.npmjs.com/package/vite-plugin-top-level-await) \n  This module uses top-level-await which isn't supported by all browsers yet. \n  This Vite plugin transforms the code to be compatible with all browsers.\n- [`vite-plugin-static-copy`](https://github.com/sapphi-red/vite-plugin-static-copy) \n  This plugin copies the icons from the node_modules folder to the dist folder\n\n\n```shell \nnpm install vite-plugin-wasm vite-plugin-top-level-await vite-plugin-static-copy\n# OR\nyarn add vite-plugin-wasm vite-plugin-top-level-await vite-plugin-static-copy\n# OR\npnpm add vite-plugin-wasm vite-plugin-top-level-await vite-plugin-static-copy\n```\n\nand add the following configuration to your `vite.config.js` / `vite.config.ts`\n\n```javascript\n// vite.config.js / vite.config.ts\nimport wasm from \"vite-plugin-wasm\";\nimport topLevelAwait from \"vite-plugin-top-level-await\";\nimport { viteStaticCopy } from \"vite-plugin-static-copy\";\nimport { normalizePath } from \"vite\";\n\nexport default {\n  plugins: [\n      wasm(),\n      topLevelAwait(),\n      viteStaticCopy({\n        targets: [\n          {\n            src: normalizePath(\n              path.resolve(__dirname, \"node_modules/@crabnebula/file-icons/icons\") + \"/[!.]*\"\n            ),\n            dest: \"./icons/\",\n          }\n        ]\n      })\n  ]\n}\n```\n\n\u003e :warning: **This will copy all the icons into your ``./dist/icons`` directory on build and add around ~3.32 MB to it**\n\n## Contributing\n\nPRs are welcome!\n\n#### License\n\n\u003csup\u003e\nLicensed under either of \u003ca href=\"LICENSE-APACHE\"\u003eApache License, Version\n2.0\u003c/a\u003e or \u003ca href=\"LICENSE-MIT\"\u003eMIT license\u003c/a\u003e at your option.\n\u003c/sup\u003e\n\n\u003cbr\u003e\n\n\u003csub\u003e\nUnless you explicitly state otherwise, any contribution intentionally submitted\nfor inclusion in this crate by you, as defined in the Apache-2.0 license, shall\nbe dual licensed as above, without any additional terms or conditions.\n\u003c/sub\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrabnebula-dev%2Ffile-icons","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcrabnebula-dev%2Ffile-icons","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrabnebula-dev%2Ffile-icons/lists"}