@jasonscheirer/electron-forge-maker-msix
Version:
An `electron-forge` maker for MSIX that supports `electron-forge` v6 and can be used as a replacement for `electron-builder`. Supports code-signing.
68 lines • 3.71 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.makeAppXImages = void 0;
const fs_extra_1 = __importDefault(require("fs-extra"));
const node_path_1 = __importDefault(require("node:path"));
const jimp_1 = require("jimp");
const REQUIRED_APPX_DIMENSIONS = [
{ w: 150, h: 150 },
{ w: 44, h: 44 },
{ w: 310, h: 150 },
{ w: 310, h: 310 },
{ w: 71, h: 71 },
{ w: 50, h: 50, specialName: 'StoreLogo' },
];
const REQUIRED_APPX_SCALES = [400]; // , 125, 150, 200, 400]
const makeAppXImages = async (appID, outPath, config) => {
var _a;
const assetPath = node_path_1.default.join(outPath, 'assets');
await fs_extra_1.default.ensureDir(assetPath);
for (const scale of REQUIRED_APPX_SCALES) {
const scaleMultiplier = scale / 100.0;
for (const dimensions of REQUIRED_APPX_DIMENSIONS) {
const { w, h } = dimensions;
const [imageWidth, imageHeight] = [
Math.trunc(w * scaleMultiplier),
Math.trunc(h * scaleMultiplier),
];
const baseName = (_a = dimensions.specialName) !== null && _a !== void 0 ? _a : `${appID}-${w}x${h}Logo`;
const imageNamewithScale = `${baseName}.scale-${scale}`;
const pathOnDiskWithScaleWithoutPng = node_path_1.default.join(node_path_1.default.join(assetPath, imageNamewithScale));
const pathOnDiskWithScale = `${pathOnDiskWithScaleWithoutPng}.${'png'}`;
const image = await jimp_1.Jimp.read(config.appIcon);
// Small touch: superimpose the app icon on a background for banner-sized images
if ((h > 300 || w > 300) && config.wallpaperIcon) {
const bgimage = (await jimp_1.Jimp.read(config.wallpaperIcon)).cover({
w: imageWidth,
h: imageHeight,
});
const overlayicon = await image.contain({
w: Math.trunc(imageWidth * 0.85),
h: Math.trunc(imageHeight * 0.85),
});
await bgimage
.composite(overlayicon, bgimage.width / 2 - overlayicon.width / 2, bgimage.height / 2 - overlayicon.height / 2)
.write(pathOnDiskWithScale);
}
else {
await image.cover({ w: imageWidth, h: imageHeight }).write(pathOnDiskWithScale);
}
if (scale === 400) {
const imageName = `${baseName}.png`;
const pathOnDiskWithoutScale = node_path_1.default.join(node_path_1.default.join(assetPath, imageName));
await fs_extra_1.default.copyFile(pathOnDiskWithScale, pathOnDiskWithoutScale);
const unplatedLightImageName = `${baseName}.targetsize-${dimensions.w}_altform-lightunplated.png`;
const pathOnDiskWithoutScaleAndUnplated = node_path_1.default.join(node_path_1.default.join(assetPath, unplatedLightImageName));
await fs_extra_1.default.copyFile(pathOnDiskWithScale, pathOnDiskWithoutScaleAndUnplated);
const unplatedDarkImageName = `${baseName}.targetsize-${dimensions.w}_altform-unplated.png`;
const pathOnDiskWithoutScaleAndDarkUnplated = node_path_1.default.join(node_path_1.default.join(assetPath, unplatedDarkImageName));
await fs_extra_1.default.copyFile(pathOnDiskWithScale, pathOnDiskWithoutScaleAndDarkUnplated);
}
}
}
};
exports.makeAppXImages = makeAppXImages;
//# sourceMappingURL=imageAssets.js.map