-
-
Notifications
You must be signed in to change notification settings - Fork 1
feat(convert-svg): add package for converting svg to multiple formats #243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| # @stephansama/convert-svg | ||
|
|
||
| [](https://github.com/stephansama/packages/tree/main/core/convert-svg) | ||
| [](https://packages.stephansama.info/api/@stephansama/convert-svg) | ||
| [](https://www.npmx.dev/package/@stephansama/convert-svg) | ||
| [](https://www.npmx.dev/package/@stephansama/convert-svg) | ||
|
|
||
| convert svg into multiple formats | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| ##### Table of contents | ||
|
|
||
| <details><summary>Open Table of contents</summary> | ||
|
|
||
| - [Installation](#installation) | ||
| - [Usage](#usage) | ||
|
|
||
| </details> | ||
|
|
||
| ## Installation | ||
|
|
||
| ```sh | ||
| pnpm install @stephansama/convert-svg | ||
| ``` | ||
|
|
||
| ## Usage | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Usage section is empty. The Usage section has no content. Consider adding at least a basic example showing how to use Would you like me to generate a usage example based on the 🤖 Prompt for AI Agents |
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,53 @@ | ||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||
| "name": "@stephansama/convert-svg", | ||||||||||||||||||||||||||||||||||||||||||||||
| "version": "0.0.0", | ||||||||||||||||||||||||||||||||||||||||||||||
| "description": "convert svg into multiple formats", | ||||||||||||||||||||||||||||||||||||||||||||||
| "keywords": [ | ||||||||||||||||||||||||||||||||||||||||||||||
| "convert-svg" | ||||||||||||||||||||||||||||||||||||||||||||||
| ], | ||||||||||||||||||||||||||||||||||||||||||||||
| "homepage": "https://packages.stephansama.info/api/@stephansama/convert-svg", | ||||||||||||||||||||||||||||||||||||||||||||||
| "repository": { | ||||||||||||||||||||||||||||||||||||||||||||||
| "type": "git", | ||||||||||||||||||||||||||||||||||||||||||||||
| "url": "https://github.com/stephansama/packages", | ||||||||||||||||||||||||||||||||||||||||||||||
| "directory": "core/convert-svg" | ||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||
| "license": "MIT", | ||||||||||||||||||||||||||||||||||||||||||||||
| "author": { | ||||||||||||||||||||||||||||||||||||||||||||||
| "name": "Stephan Randle", | ||||||||||||||||||||||||||||||||||||||||||||||
| "email": "stephanrandle.dev@gmail.com", | ||||||||||||||||||||||||||||||||||||||||||||||
| "url": "https://stephansama.info" | ||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||
| "type": "module", | ||||||||||||||||||||||||||||||||||||||||||||||
| "scripts": { | ||||||||||||||||||||||||||||||||||||||||||||||
| "build": "tsdown", | ||||||||||||||||||||||||||||||||||||||||||||||
| "dev": "tsdown --watch", | ||||||||||||||||||||||||||||||||||||||||||||||
| "lint": "eslint ./ --pass-on-no-patterns --no-error-on-unmatched-pattern", | ||||||||||||||||||||||||||||||||||||||||||||||
| "lint:fix": "eslint ./ --fix" | ||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||
| "dependencies": { | ||||||||||||||||||||||||||||||||||||||||||||||
| "cleye": "catalog:", | ||||||||||||||||||||||||||||||||||||||||||||||
| "ico-endec": "catalog:", | ||||||||||||||||||||||||||||||||||||||||||||||
| "sharp": "catalog:" | ||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||
| "devDependencies": { | ||||||||||||||||||||||||||||||||||||||||||||||
| "tsdown": "catalog:" | ||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||
| "publishConfig": { | ||||||||||||||||||||||||||||||||||||||||||||||
| "access": "public", | ||||||||||||||||||||||||||||||||||||||||||||||
| "provenance": true | ||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||
| "main": "./dist/index.cjs", | ||||||||||||||||||||||||||||||||||||||||||||||
| "module": "./dist/index.js", | ||||||||||||||||||||||||||||||||||||||||||||||
| "types": "./dist/index.d.cts", | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+39
to
+41
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Check tsdown documentation or other packages for expected .d.ts output naming
rg -l "\.d\.cts" --type jsonRepository: stephansama/packages Length of output: 534 🏁 Script executed: #!/bin/bash
# Check what's actually in the dist folder for core/convert-svg
cd core/convert-svg && find dist -type f 2>/dev/null | head -20Repository: stephansama/packages Length of output: 46 🏁 Script executed: #!/bin/bash
# Check the full package.json to understand the export map
cd core/convert-svg && cat package.jsonRepository: stephansama/packages Length of output: 1266 🏁 Script executed: #!/bin/bash
# Check tsdown configuration
cd core/convert-svg && cat tsconfig.jsonRepository: stephansama/packages Length of output: 226 🏁 Script executed: #!/bin/bash
# Look for tsdown documentation or config related to output naming
rg "tsdown" --type json | head -20Repository: stephansama/packages Length of output: 1211 🏁 Script executed: #!/bin/bash
# Check if dist folder exists and its contents
ls -la core/convert-svg/dist/ 2>/dev/null || echo "dist folder not found"Repository: stephansama/packages Length of output: 85 🏁 Script executed: #!/bin/bash
# Look at the src structure to understand what gets built
ls -la core/convert-svg/src/Repository: stephansama/packages Length of output: 401 🏁 Script executed: #!/bin/bash
# Check if there are any build outputs or documentation about tsdown's output naming
rg "\.d\.(ts|cts|mts)" core/convert-svg/dist/ 2>/dev/null || echo "No dist files found with pattern"Repository: stephansama/packages Length of output: 96 🏁 Script executed: #!/bin/bash
# Search for tsdown usage or output examples in another similar package
ls -la core/typed-events/dist/ 2>/dev/null | head -20Repository: stephansama/packages Length of output: 46 🌐 Web query:
💡 Result: In tsdown, the declaration-file extension depends on your output format and whether you’re using fixed extensions:
Separately, in TypeScript itself, Citations:
🏁 Script executed: #!/bin/bash
# Check if any other packages in the monorepo have built dist folders
find core -maxdepth 2 -name "dist" -type d 2>/dev/nullRepository: stephansama/packages Length of output: 46 🏁 Script executed: #!/bin/bash
# Search for any documentation or comments about .d.cts in the repo
rg "d\.cts|d\.ts" --type markdownRepository: stephansama/packages Length of output: 145 🏁 Script executed: #!/bin/bash
# Check tsdown configuration - look for tsdown.config or build settings
find core/convert-svg -name "tsdown*" -o -name ".tsdownrc*" 2>/dev/nullRepository: stephansama/packages Length of output: 97 🏁 Script executed: #!/bin/bash
# Check package.json and tsconfig for tsdown options
cd core/convert-svg && cat package.json | grep -A 10 '"build"'Repository: stephansama/packages Length of output: 341 🏁 Script executed: #!/bin/bash
# Look at the tsconfig to see if there are any build-related options
rg "fixedExtension|declaration" core/convert-svg/Repository: stephansama/packages Length of output: 46 🏁 Script executed: #!/bin/bash
# Check the shared tsconfig base for any tsdown-related settings
cat core/tsconfig.base.json 2>/dev/null | head -50Repository: stephansama/packages Length of output: 46 🏁 Script executed: #!/bin/bash
# Read the tsdown config to understand the build settings
cat core/convert-svg/tsdown.config.tsRepository: stephansama/packages Length of output: 282 🏁 Script executed: #!/bin/bash
# Check if other packages have tsdown configs and how they handle types
find core -name "tsdown.config.ts" -exec sh -c 'echo "=== {} ===" && cat "{}"' \;Repository: stephansama/packages Length of output: 2981 🏁 Script executed: #!/bin/bash
# Check if there are other packages with similar setup to cross-reference
rg '"types":.*"\.d\.' core --type json -A 1 -B 1Repository: stephansama/packages Length of output: 46 🏁 Script executed: #!/bin/bash
# Check how the export map should map types for ESM/CJS
rg '"export' core/convert-svg/package.json -A 10Repository: stephansama/packages Length of output: 275 🌐 Web query:
💡 Result:
Sources: [1] Output Format (tsdown docs) [2] Declaration Files / dts (tsdown docs) [3] CJS Default Export (tsdown docs) 🌐 Web query:
💡 Result: To make a package ESM-first (prefer ESM at runtime) and have TypeScript consistently find the right .d.ts when you use an Key points
A common ESM-first pattern (single types file)If your ESM and CJS builds have the same public API shape, you can usually point both to one declaration file: {
"name": "pkg",
"type": "module",
"main": "./dist/cjs/index.cjs", // legacy
"module": "./dist/esm/index.js", // legacy/bundlers (optional)
"types": "./dist/types/index.d.ts", // legacy fallback
"exports": {
".": {
"types": "./dist/types/index.d.ts",
"import": "./dist/esm/index.js",
"require": "./dist/cjs/index.cjs",
"default": "./dist/esm/index.js"
},
"./package.json": "./package.json"
}
}
If you truly need different types for ESM vs CJSSome dual packages need separate declarations (e.g., {
"exports": {
".": {
"import": {
"types": "./dist/esm/index.d.ts",
"default": "./dist/esm/index.js"
},
"require": {
"types": "./dist/cjs/index.d.cts",
"default": "./dist/cjs/index.cjs"
}
}
}
}This matches real-world guidance for dual ESM/CJS publishing where separate declarations may be necessary. [3] Sources: TypeScript module resolution reference (exports vs typesVersions) [1], Node.js packages/exports docs (including 🏁 Script executed: #!/bin/bash
# Verify tsdown default behavior - check if fixedExtension defaults to false/undefined
web_search "tsdown fixedExtension default"Repository: stephansama/packages Length of output: 114 Fix declaration file path mismatch with tsdown defaults. The "exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js",
"require": "./dist/index.cjs"
}
}If 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||
| "exports": { | ||||||||||||||||||||||||||||||||||||||||||||||
| ".": { | ||||||||||||||||||||||||||||||||||||||||||||||
| "import": "./dist/index.js", | ||||||||||||||||||||||||||||||||||||||||||||||
| "require": "./dist/index.cjs" | ||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||
| "./cli": { | ||||||||||||||||||||||||||||||||||||||||||||||
| "import": "./dist/cli.js", | ||||||||||||||||||||||||||||||||||||||||||||||
| "require": "./dist/cli.cjs" | ||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+42
to
+50
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Check if there are other packages in this repo to see how they handle exports with types
fd -e json -t f 'package.json' --exec grep -l '"exports"' {} \; | head -5 | xargs -I{} sh -c 'echo "=== {} ===" && cat {} | jq ".exports"'Repository: stephansama/packages Length of output: 1289 🏁 Script executed: #!/bin/bash
# Check tsdown.config.ts in convert-svg
find . -path "*/core/convert-svg/tsdown.config.ts" -exec cat {} \;Repository: stephansama/packages Length of output: 282 🏁 Script executed: #!/bin/bash
# Check main package.json entry points for convert-svg
cat core/convert-svg/package.json | jq '.main, .module, .types'Repository: stephansama/packages Length of output: 121 🏁 Script executed: #!/bin/bash
# Look for any .d.ts or .d.cts files in the core/convert-svg/src or dist directories
fd -e 'd.ts' -e 'd.cts' 'core/convert-svg' 2>/dev/null || echo "No generated declaration files found (may not be built yet)"Repository: stephansama/packages Length of output: 123 🏁 Script executed: #!/bin/bash
# Search for packages in the repo with both esm/cjs format to see how they handle types in exports
fd -e json -t f 'package.json' -path '*/core/*' --exec sh -c '
if grep -q '"'"'"format".*\["esm", "cjs"\]'"'"' "$(dirname {})/tsdown.config.ts" 2>/dev/null; then
echo "=== {} ==="
cat {} | jq -r ".exports, .types"
fi
' \; 2>/dev/null | head -40Repository: stephansama/packages Length of output: 46 🏁 Script executed: #!/bin/bash
# Check if svelte-social-share-links (which has types condition) also has .d.ts or .d.cts
cat core/svelte-social-share-links/tsdown.config.ts 2>/dev/null || echo "No tsdown config found"Repository: stephansama/packages Length of output: 86 🏁 Script executed: #!/bin/bash
# Check what the correct filename convention is for dual-format TypeScript packages
# Look at the actual proposed fix - it suggests .d.ts but package.json has .d.cts
# Let's verify the pattern across multiple files
rg -l '\.d\.cts' core/*/package.json | head -5 | xargs -I{} sh -c 'echo "=== {} ===" && cat {} | jq ".types"'Repository: stephansama/packages Length of output: 365 🌐 Web query:
💡 Result: Goal: one npm package that works in ESM + CJS and resolves the right .d.ts under
|
||||||||||||||||||||||||||||||||||||||||||||||
| "exports": { | |
| ".": { | |
| "import": "./dist/index.js", | |
| "require": "./dist/index.cjs" | |
| }, | |
| "./cli": { | |
| "import": "./dist/cli.js", | |
| "require": "./dist/cli.cjs" | |
| }, | |
| "exports": { | |
| ".": { | |
| "types": "./dist/index.d.cts", | |
| "import": "./dist/index.js", | |
| "require": "./dist/index.cjs" | |
| }, | |
| "./cli": { | |
| "types": "./dist/cli.d.cts", | |
| "import": "./dist/cli.js", | |
| "require": "./dist/cli.cjs" | |
| }, | |
| "./package.json": "./package.json" | |
| } |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@core/convert-svg/package.json` around lines 42 - 50, The package.json exports
map is missing explicit "types" conditions, which prevents TypeScript
bundler/node16/nodenext resolution; update the exports entries for "." and
"./cli" (the exports map keys) to include a "types" condition alongside "import"
and "require" that points to the compiled declaration files (e.g.,
dist/index.d.ts and dist/cli.d.ts), ensuring TypeScript consumers can resolve
type definitions correctly.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| import { cli } from "cleye"; | ||
|
|
||
| // Parse argv | ||
| const argv = cli({ | ||
| flags: { | ||
| input: { | ||
| description: "input svg filename", | ||
| type: String, | ||
| }, | ||
| output: { | ||
| default: "output ico filename", | ||
| description: "Time of day to greet (morning or evening)", | ||
| type: String, | ||
| }, | ||
| }, | ||
| name: "@stephansama/convert-svg", | ||
| parameters: [ | ||
| "<first name>", // First name is required | ||
| "[last name]", // Last name is optional | ||
| ], | ||
| }); | ||
|
|
||
| const name = [argv._.firstName, argv._.lastName].filter(Boolean).join(" "); | ||
|
|
||
| if (argv.flags.time === "morning") { | ||
| console.log(`Good morning ${name}!`); | ||
| } else { | ||
| console.log(`Good evening ${name}!`); | ||
| } | ||
|
Comment on lines
+1
to
+29
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file appears to contain placeholder example code from the Specifically:
Comment on lines
+1
to
+29
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CLI is placeholder code that doesn't implement SVG conversion. This file appears to be boilerplate/example code from
The CLI should import and call the 🛠️ Proposed implementation import { cli } from "cleye";
+import { svgToIco, ValidSizes } from "./ico";
// Parse argv
const argv = cli({
flags: {
input: {
- description: "input svg filename",
+ alias: "i",
+ description: "Input SVG filename",
type: String,
+ required: true,
},
output: {
- default: "output ico filename",
- description: "Time of day to greet (morning or evening)",
+ alias: "o",
+ default: "favicon.ico",
+ description: "Output ICO filename",
type: String,
},
+ sizes: {
+ alias: "s",
+ default: ValidSizes.join(","),
+ description: "Comma-separated list of sizes (16,32,48,64,128,256)",
+ type: String,
+ },
+ compression: {
+ alias: "c",
+ default: 1,
+ description: "PNG compression level (0-9)",
+ type: Number,
+ },
},
name: "@stephansama/convert-svg",
- parameters: [
- "<first name>", // First name is required
- "[last name]", // Last name is optional
- ],
});
-const name = [argv._.firstName, argv._.lastName].filter(Boolean).join(" ");
-
-if (argv.flags.time === "morning") {
- console.log(`Good morning ${name}!`);
-} else {
- console.log(`Good evening ${name}!`);
-}
+const { input, output, sizes, compression } = argv.flags;
+
+if (!input) {
+ console.error("Error: --input flag is required");
+ process.exit(1);
+}
+
+const sizeArray = sizes.split(",").map(Number) as (16 | 32 | 48 | 64 | 128 | 256)[];
+
+svgToIco({
+ input,
+ output,
+ sizes: sizeArray,
+ compressionLevel: compression as 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9,
+}).then(() => {
+ console.info(`Successfully created ${output} from ${input}`);
+}).catch((err) => {
+ console.error("Error converting SVG to ICO:", err.message);
+ process.exit(1);
+});Note: The static analysis warnings about 🧰 Tools🪛 GitHub Check: Examples / Test[warning] 28-28: [warning] 26-26: 🤖 Prompt for AI Agents |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| import ico from "ico-endec"; | ||
| import * as fs from "node:fs"; | ||
| import sharp from "sharp"; | ||
|
|
||
| export const ValidSizes = [16, 32, 48, 64, 128, 256] as const; | ||
| export type ValidSize = (typeof ValidSizes)[number]; | ||
|
Comment on lines
+5
to
+6
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial
These exports are useful for consumers to validate sizes programmatically, but In -export { svgToIco } from "./ico";
+export { svgToIco, ValidSizes, type ValidSize } from "./ico";🤖 Prompt for AI Agents |
||
|
|
||
| export async function svgToIco({ | ||
| compressionLevel = 1, | ||
| input, | ||
| output = "favicon.ico", | ||
| sizes = [16, 32, 48, 64, 128, 256], | ||
| }: { | ||
| compressionLevel: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9; | ||
| input: string; | ||
| output: string; | ||
| sizes: ValidSize[]; | ||
| }) { | ||
| if (!Number.isInteger(compressionLevel)) { | ||
| throw new Error( | ||
| `compression level must be a number above -1 and below 10 '${compressionLevel}'`, | ||
| ); | ||
| } | ||
|
|
||
| if (compressionLevel < 0) { | ||
| throw new Error(`compression level is to low must be above -1`); | ||
| } | ||
|
|
||
| if (compressionLevel > 9) { | ||
| throw new Error(`compression level is to high must be below 10`); | ||
| } | ||
|
Comment on lines
+19
to
+31
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The validation for if (!Number.isInteger(compressionLevel) || compressionLevel < 0 || compressionLevel > 9) {
throw new Error(
`compressionLevel must be an integer between 0 and 9, but got '${compressionLevel}'.`
);
}
Comment on lines
+19
to
+31
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial Runtime validation is redundant given the TypeScript type constraint. The If you intend to support JavaScript consumers without type checking, keep the validation but consider consolidating into a single check. Otherwise, remove the redundant validation. Also, minor typos: "to low" → "too low" and "to high" → "too high". ♻️ Consolidated validation (if keeping for JS consumers)- if (!Number.isInteger(compressionLevel)) {
- throw new Error(
- `compression level must be a number above -1 and below 10 '${compressionLevel}'`,
- );
- }
-
- if (compressionLevel < 0) {
- throw new Error(`compression level is to low must be above -1`);
- }
-
- if (compressionLevel > 9) {
- throw new Error(`compression level is to high must be below 10`);
- }
+ if (!Number.isInteger(compressionLevel) || compressionLevel < 0 || compressionLevel > 9) {
+ throw new Error(
+ `compressionLevel must be an integer between 0 and 9, got '${compressionLevel}'`,
+ );
+ }🤖 Prompt for AI Agents |
||
|
|
||
| for (const size of sizes) { | ||
| const png_buffer = await sharp(input) | ||
| .resize(size, size, { | ||
| background: { alpha: 0, b: 0, g: 0, r: 0 }, | ||
| fit: "contain", | ||
| }) | ||
| .png({ compressionLevel }) | ||
| .toBuffer(); | ||
|
|
||
| const ico_buffer = ico.encode(png_buffer); | ||
|
|
||
| await fs.promises.writeFile(output, ico_buffer); | ||
| } | ||
|
Comment on lines
+33
to
+45
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a critical bug in this loop. To create a single ICO file with multiple sizes, you should first generate all the PNG buffers and collect them in an array. Then, pass this array to const pngBuffers = await Promise.all(
sizes.map((size) =>
sharp(input)
.resize(size, size, {
background: { alpha: 0, b: 0, g: 0, r: 0 },
fit: "contain",
})
.png({ compressionLevel })
.toBuffer(),
),
);
const icoBuffer = ico.encode(pngBuffers);
await fs.promises.writeFile(output, icoBuffer);
Comment on lines
+33
to
+45
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🌐 Web query:
💡 Result:
const icoEndec = require('ico-endec');
const fs = require('fs').promises;
(async () => {
const icoBuffer = icoEndec.encode([
await fs.readFile('icon-16x16.png'),
await fs.readFile('icon-32x32.png'),
await fs.readFile('icon-48x48.png'),
await fs.readFile('icon-64x64.png'),
await fs.readFile('icon-128x128.png'),
await fs.readFile('icon-256x256.png'), // max is 256x256
]);
await fs.writeFile('favicon.ico', icoBuffer);
})();Notes:
Citations:
Critical: Loop overwrites output file on each iteration; only the last size is retained. The loop iterates over According to the
Currently, the code calls 🤖 Prompt for AI Agents |
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export { svgToIco } from "./ico"; |
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,7 @@ | ||||||||||||||
| { | ||||||||||||||
| "extends": ["../../tsconfig.base.json"], | ||||||||||||||
| "include": ["./src/**/*", "./types/*.d.ts"], | ||||||||||||||
| "compilerOptions": { | ||||||||||||||
| "types": ["./types/ico-endec.d.ts", "node"] | ||||||||||||||
| } | ||||||||||||||
|
Comment on lines
+4
to
+6
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial Consider removing redundant type path from The ♻️ Proposed simplification "compilerOptions": {
- "types": ["./types/ico-endec.d.ts", "node"]
+ "types": ["node"]
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||
| } | ||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import { defineConfig } from "tsdown"; | ||
|
|
||
| export default defineConfig({ | ||
| attw: true, | ||
| dts: true, | ||
| entry: ["./src/index.ts", "./src/cli.ts"], | ||
| exports: true, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🌐 Web query:
💡 Result: In tsdown, the Key behaviors:
Sources: tsdown “Auto-Generating Package Exports” docs [1] and tsdown CLI reference ( Address the conflict between The 🤖 Prompt for AI Agents |
||
| format: ["esm", "cjs"], | ||
| publint: true, | ||
| target: "esnext", | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| { | ||
| "entryPoints": ["src/*"], | ||
| "tsconfig": "./tsconfig.json", | ||
| "exclude": [ | ||
| "**/tests/**", | ||
| "**/*.test.ts", | ||
| "**/*.spec.ts", | ||
| "node_modules", | ||
| "**/{node_modules,test,book,doc,dist}/**/*", | ||
| "**/{pages,components}/**" | ||
| ] | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,3 @@ | ||||||
| declare module "ico-endec" { | ||||||
| export function encode(buf: Buffer): Buffer; | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The type definition for
Suggested change
|
||||||
| } | ||||||
|
Comment on lines
+1
to
+3
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🌐 Web query:
💡 Result:
A precise TypeScript-style signature would be: function encode(images: Array<Buffer | ArrayBuffer>): Buffer;[1] Fix the The type declaration declares Type declaration fixdeclare module "ico-endec" {
export function encode(images: Array<Buffer | ArrayBuffer>): Buffer;
}🤖 Prompt for AI Agents |
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| # @stephansama/github-env | ||
| # @stephansama/types-github-action-env | ||
|
|
||
| ## 1.0.0 | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency with other package descriptions in this file, the description should be capitalized.