Socket
Socket
Sign inDemoInstall

astro-icon

Package Overview
Dependencies
26
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.5.3 to 0.6.0

3

index.ts
import Icon from "./lib/Icon.astro";
import SpriteProvider from "./lib/SpriteProvider.astro";
import SpriteComponent from "./lib/Sprite.astro";
import createIconPack from "./lib/createIconPack.ts";
import Sheet from "./lib/Spritesheet.astro";

@@ -33,3 +31,2 @@

Sprite,
createIconPack,
};

8

lib/createIconPack.ts
import { statSync, promises as fs } from "fs";
import { fileURLToPath, pathToFileURL } from "url";
import { createRequire } from "module";
import resolvePackage from "resolve-pkg";
const require = createRequire(import.meta.url);
export interface CreateIconPackOptions {

@@ -13,3 +11,3 @@ package?: string;

export default function createIconPack({
export function createIconPack({
package: pkg,

@@ -20,4 +18,4 @@ dir,

if (pkg) {
const baseUrl = pathToFileURL(require.resolve(`${pkg}/package.json`));
return async (name: string) => {
const baseUrl = new URL(pathToFileURL(resolvePackage(pkg)) + "/");
const path = fileURLToPath(

@@ -24,0 +22,0 @@ new URL(dir ? `${dir}/${name}.svg` : `${name}.svg`, baseUrl)

@@ -0,1 +1,2 @@

/// <reference types="vite/client" />
import { SPRITESHEET_NAMESPACE } from "./constants";

@@ -148,3 +149,14 @@ import { Props, Optimize } from "./Props";

try {
const mod = await import(`${filepath}`);
const files = import.meta.globEager(
`/src/icons/**/*.{js,ts,cjs,mjc,cts,mts}`
);
const keys = Object.fromEntries(
Object.keys(files).map((key) => [key.replace(/\.[cm]?[jt]s$/, ""), key])
);
if (!(filepath in keys)) {
throw new Error(`Could not find the file "${filepath}"`);
}
const mod = files[keys[filepath]];
if (typeof mod.default !== "function") {

@@ -181,3 +193,13 @@ throw new Error(

try {
const { default: contents } = await import(`${filepath}?raw`);
const files = import.meta.globEager(`/src/icons/**/*.svg`, {
assert: {
type: "raw",
},
});
if (!(filepath in files)) {
throw new Error(`Could not find the file "${filepath}"`);
}
const contents = files[filepath];
if (!/<svg/gim.test(contents)) {

@@ -184,0 +206,0 @@ throw new Error(

{
"name": "astro-icon",
"version": "0.5.3",
"version": "0.6.0",
"type": "module",
"exports": {
".": "./index.ts"
".": "./index.ts",
"./pack": "./lib/createIconPack.ts"
},

@@ -35,4 +36,5 @@ "files": [

"node-fetch": "^3.1.0",
"resolve-pkg": "^2.0.0",
"svgo": "^2.8.0"
}
}

@@ -31,3 +31,3 @@ # Astro Icon

To browse supported icons, we recommend [Icônes](https://icones.js.org/).
To browse supported icons, check the official [Icon Sets reference](https://icon-sets.iconify.design/) or visit [Icônes](https://icones.js.org/).

@@ -173,2 +173,2 @@ ### Usage

See the [`Props.ts`](./lib/Props.ts) file for more details.
See the [`Props.ts`](./packages/core/lib/Props.ts) file for more details.

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc