forked from shockpkg/icon-encoder
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5e83194
commit b3fbac7
Showing
27 changed files
with
4,435 additions
and
2,900 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
/lib | ||
/module.mjs | ||
/dts | ||
/esm | ||
/cjs | ||
/spec/encodes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,4 +21,6 @@ yarn.lock | |
.vscode | ||
|
||
# Build files | ||
/lib | ||
/dts | ||
/esm | ||
/cjs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
18.12.0 | ||
18.18.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
/package-lock.json | ||
/lib | ||
/dts | ||
/esm | ||
/cjs | ||
/spec/encodes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,7 +41,7 @@ Usage: shockpkg-icon-encoder [options...] (icon.ico | icon.icns) pngs... | |
### Windows ICO | ||
|
||
```js | ||
import fs from 'fs'; | ||
import {readFile, writeFile} from 'node:fs/promises'; | ||
import {IconIco} from '@shockpkg/icon-encoder'; | ||
|
||
// Default null automatically compresses icons for backwards compatibility. | ||
|
@@ -53,19 +53,19 @@ const png = null; | |
const raw = false; | ||
|
||
const ico = new IconIco(); | ||
ico.addFromPng(fs.readFileSync('icon/256x256.png'), png, raw); | ||
ico.addFromPng(fs.readFileSync('icon/128x128.png'), png, raw); | ||
ico.addFromPng(fs.readFileSync('icon/64x64.png'), png, raw); | ||
ico.addFromPng(fs.readFileSync('icon/48x48.png'), png, raw); | ||
ico.addFromPng(fs.readFileSync('icon/32x32.png'), png, raw); | ||
ico.addFromPng(fs.readFileSync('icon/16x16.png'), png, raw); | ||
fs.writeFileSync('icon.ico', ico.encode()); | ||
ico.addFromPng(await readFile('icon/256x256.png'), png, raw); | ||
ico.addFromPng(await readFile('icon/128x128.png'), png, raw); | ||
ico.addFromPng(await readFile('icon/64x64.png'), png, raw); | ||
ico.addFromPng(await readFile('icon/48x48.png'), png, raw); | ||
ico.addFromPng(await readFile('icon/32x32.png'), png, raw); | ||
ico.addFromPng(await readFile('icon/16x16.png'), png, raw); | ||
await writeFile('icon.ico', ico.encode()); | ||
``` | ||
|
||
### macOS ICNS (current formats) | ||
|
||
```js | ||
import fs from 'fs'; | ||
import {readFile, writeFile} from 'node:fs/promises'; | ||
import {IconIcns} from '@shockpkg/icon-encoder'; | ||
|
||
const icns = new IconIcns(); | ||
|
@@ -80,31 +80,31 @@ const raw = false; | |
|
||
// This order matches that of iconutil with the same image set in macOS 10.14. | ||
// Images with @2x are just 2x the size their file name suggests. | ||
icns.addFromPng(fs.readFileSync('icon/[email protected]'), ['ic12'], raw); | ||
icns.addFromPng(fs.readFileSync('icon/128x128.png'), ['ic07'], raw); | ||
icns.addFromPng(fs.readFileSync('icon/[email protected]'), ['ic13'], raw); | ||
icns.addFromPng(fs.readFileSync('icon/256x256.png'), ['ic08'], raw); | ||
icns.addFromPng(fs.readFileSync('icon/16x16.png'), ['ic04'], raw); | ||
icns.addFromPng(fs.readFileSync('icon/[email protected]'), ['ic14'], raw); | ||
icns.addFromPng(fs.readFileSync('icon/512x512.png'), ['ic09'], raw); | ||
icns.addFromPng(fs.readFileSync('icon/32x32.png'), ['ic05'], raw); | ||
icns.addFromPng(fs.readFileSync('icon/[email protected]'), ['ic10'], raw); | ||
icns.addFromPng(fs.readFileSync('icon/[email protected]'), ['ic11'], raw); | ||
fs.writeFileSync('icon.icns', icns.encode()); | ||
icns.addFromPng(await readFile('icon/[email protected]'), ['ic12'], raw); | ||
icns.addFromPng(await readFile('icon/128x128.png'), ['ic07'], raw); | ||
icns.addFromPng(await readFile('icon/[email protected]'), ['ic13'], raw); | ||
icns.addFromPng(await readFile('icon/256x256.png'), ['ic08'], raw); | ||
icns.addFromPng(await readFile('icon/16x16.png'), ['ic04'], raw); | ||
icns.addFromPng(await readFile('icon/[email protected]'), ['ic14'], raw); | ||
icns.addFromPng(await readFile('icon/512x512.png'), ['ic09'], raw); | ||
icns.addFromPng(await readFile('icon/32x32.png'), ['ic05'], raw); | ||
icns.addFromPng(await readFile('icon/[email protected]'), ['ic10'], raw); | ||
icns.addFromPng(await readFile('icon/[email protected]'), ['ic11'], raw); | ||
await writeFile('icon.icns', icns.encode()); | ||
``` | ||
|
||
### macOS ICNS (legacy formats) | ||
|
||
```js | ||
import fs from 'fs'; | ||
import {readFile, writeFile} from 'node:fs/promises'; | ||
import {IconIcns} from '@shockpkg/icon-encoder'; | ||
|
||
const icns = new IconIcns(); | ||
icns.addFromPng(fs.readFileSync('icon/16x16.png'), ['is32', 's8mk']); | ||
icns.addFromPng(fs.readFileSync('icon/32x32.png'), ['il32', 'l8mk']); | ||
icns.addFromPng(fs.readFileSync('icon/48x48.png'), ['ih32', 'h8mk']); | ||
icns.addFromPng(fs.readFileSync('icon/128x128.png'), ['it32', 't8mk']); | ||
fs.writeFileSync('icon.icns', icns.encode()); | ||
icns.addFromPng(await readFile('icon/16x16.png'), ['is32', 's8mk']); | ||
icns.addFromPng(await readFile('icon/32x32.png'), ['il32', 'l8mk']); | ||
icns.addFromPng(await readFile('icon/48x48.png'), ['ih32', 'h8mk']); | ||
icns.addFromPng(await readFile('icon/128x128.png'), ['it32', 't8mk']); | ||
await writeFile('icon.icns', icns.encode()); | ||
``` | ||
|
||
# Bugs | ||
|
@@ -113,7 +113,7 @@ If you find a bug or have compatibility issues, please open a ticket under issue | |
|
||
# License | ||
|
||
Copyright (c) 2019-2022 JrMasterModelBuilder | ||
Copyright (c) 2019-2023 JrMasterModelBuilder | ||
|
||
Licensed under the Mozilla Public License, v. 2.0. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
'use strict'; | ||
|
||
const {name, version, engines} = require('./package.json'); | ||
|
||
const node = engines.node | ||
.split(/[^\d.]+/) | ||
.filter(s => s.length) | ||
.map(s => [...s.split('.').map(s => +s || 0), 0, 0].slice(0, 3)) | ||
.sort((a, b) => a[2] - b[2]) | ||
.sort((a, b) => a[1] - b[1]) | ||
.sort((a, b) => a[0] - b[0])[0] | ||
.join('.'); | ||
|
||
module.exports = api => { | ||
const env = api.env(); | ||
api.cache(() => env); | ||
const modules = env === 'esm' ? false : 'commonjs'; | ||
const ext = modules ? '.js' : '.mjs'; | ||
const presets = []; | ||
const plugins = []; | ||
presets.push([ | ||
'@babel/preset-env', | ||
{ | ||
modules, | ||
exclude: ['proposal-dynamic-import'], | ||
targets: { | ||
node | ||
} | ||
} | ||
]); | ||
presets.push(['@babel/preset-typescript']); | ||
if (modules === 'commonjs') { | ||
plugins.push([ | ||
'@babel/plugin-transform-modules-commonjs', | ||
{ | ||
importInterop: 'node' | ||
} | ||
]); | ||
} | ||
plugins.push([ | ||
'esm-resolver', | ||
{ | ||
source: { | ||
extensions: [ | ||
[['.js', '.mjs', '.jsx', '.mjsx', '.ts', '.tsx'], ext] | ||
] | ||
} | ||
} | ||
]); | ||
plugins.push([ | ||
'search-and-replace', | ||
{ | ||
rules: [ | ||
{ | ||
search: '#{NAME}', | ||
replace: name | ||
}, | ||
{ | ||
search: '#{VERSION}', | ||
replace: version | ||
} | ||
] | ||
} | ||
]); | ||
return { | ||
presets, | ||
plugins | ||
}; | ||
}; |
Oops, something went wrong.