chore: add jimp dependency, icon padding script, and update configuration

This commit is contained in:
2026-05-31 14:04:37 +02:00
parent 30f81045ac
commit 7cd17307ba
1126 changed files with 166400 additions and 2 deletions
+63
View File
@@ -0,0 +1,63 @@
import Jimp, { addType, addJimpMethods, addConstants, jimpEvChange } from "@jimp/core";
export default function configure(configuration) {
let jimpInstance = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Jimp;
const jimpConfig = {
hasAlpha: {},
encoders: {},
decoders: {},
class: {},
constants: {}
};
function addToConfig(newConfig) {
Object.entries(newConfig).forEach(_ref => {
let [key, value] = _ref;
jimpConfig[key] = {
...jimpConfig[key],
...value
};
});
}
function addImageType(typeModule) {
const type = typeModule();
if (Array.isArray(type.mime)) {
addType(...type.mime);
} else {
Object.entries(type.mime).forEach(mimeType => addType(...mimeType));
}
delete type.mime;
addToConfig(type);
}
function addPlugin(pluginModule) {
const plugin = pluginModule(jimpEvChange) || {};
if (!plugin.class && !plugin.constants) {
// Default to class function
addToConfig({
class: plugin
});
} else {
addToConfig(plugin);
}
}
if (configuration.types) {
configuration.types.forEach(addImageType);
jimpInstance.decoders = {
...jimpInstance.decoders,
...jimpConfig.decoders
};
jimpInstance.encoders = {
...jimpInstance.encoders,
...jimpConfig.encoders
};
jimpInstance.hasAlpha = {
...jimpInstance.hasAlpha,
...jimpConfig.hasAlpha
};
}
if (configuration.plugins) {
configuration.plugins.forEach(addPlugin);
}
addJimpMethods(jimpConfig.class, jimpInstance);
addConstants(jimpConfig.constants, jimpInstance);
return Jimp;
}
//# sourceMappingURL=index.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.js","names":["Jimp","addType","addJimpMethods","addConstants","jimpEvChange","configure","configuration","jimpInstance","jimpConfig","hasAlpha","encoders","decoders","class","constants","addToConfig","newConfig","Object","entries","forEach","key","value","addImageType","typeModule","type","Array","isArray","mime","mimeType","addPlugin","pluginModule","plugin","types","plugins"],"sources":["../src/index.js"],"sourcesContent":["import Jimp, {\n addType,\n addJimpMethods,\n addConstants,\n jimpEvChange,\n} from \"@jimp/core\";\n\nexport default function configure(configuration, jimpInstance = Jimp) {\n const jimpConfig = {\n hasAlpha: {},\n encoders: {},\n decoders: {},\n class: {},\n constants: {},\n };\n\n function addToConfig(newConfig) {\n Object.entries(newConfig).forEach(([key, value]) => {\n jimpConfig[key] = {\n ...jimpConfig[key],\n ...value,\n };\n });\n }\n\n function addImageType(typeModule) {\n const type = typeModule();\n\n if (Array.isArray(type.mime)) {\n addType(...type.mime);\n } else {\n Object.entries(type.mime).forEach((mimeType) => addType(...mimeType));\n }\n\n delete type.mime;\n addToConfig(type);\n }\n\n function addPlugin(pluginModule) {\n const plugin = pluginModule(jimpEvChange) || {};\n if (!plugin.class && !plugin.constants) {\n // Default to class function\n addToConfig({ class: plugin });\n } else {\n addToConfig(plugin);\n }\n }\n\n if (configuration.types) {\n configuration.types.forEach(addImageType);\n\n jimpInstance.decoders = {\n ...jimpInstance.decoders,\n ...jimpConfig.decoders,\n };\n jimpInstance.encoders = {\n ...jimpInstance.encoders,\n ...jimpConfig.encoders,\n };\n jimpInstance.hasAlpha = {\n ...jimpInstance.hasAlpha,\n ...jimpConfig.hasAlpha,\n };\n }\n\n if (configuration.plugins) {\n configuration.plugins.forEach(addPlugin);\n }\n\n addJimpMethods(jimpConfig.class, jimpInstance);\n addConstants(jimpConfig.constants, jimpInstance);\n\n return Jimp;\n}\n"],"mappings":"AAAA,OAAOA,IAAI,IACTC,OAAO,EACPC,cAAc,EACdC,YAAY,EACZC,YAAY,QACP,YAAY;AAEnB,eAAe,SAASC,SAAS,CAACC,aAAa,EAAuB;EAAA,IAArBC,YAAY,uEAAGP,IAAI;EAClE,MAAMQ,UAAU,GAAG;IACjBC,QAAQ,EAAE,CAAC,CAAC;IACZC,QAAQ,EAAE,CAAC,CAAC;IACZC,QAAQ,EAAE,CAAC,CAAC;IACZC,KAAK,EAAE,CAAC,CAAC;IACTC,SAAS,EAAE,CAAC;EACd,CAAC;EAED,SAASC,WA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