"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AutoUnpackNativesPlugin = void 0;
const plugin_base_1 = require("@electron-forge/plugin-base");
class AutoUnpackNativesPlugin extends plugin_base_1.PluginBase {
    constructor() {
        super(...arguments);
        this.name = 'auto-unpack-natives';
        this.resolveForgeConfig = async (forgeConfig) => {
            if (!forgeConfig.packagerConfig) {
                forgeConfig.packagerConfig = {};
            }
            if (!forgeConfig.packagerConfig.asar) {
                throw new Error('The AutoUnpackNatives plugin requires asar to be truthy or an object');
            }
            if (forgeConfig.packagerConfig.asar === true) {
                forgeConfig.packagerConfig.asar = {};
            }
            const existingUnpack = forgeConfig.packagerConfig.asar.unpack;
            const newUnpack = '**/*.node';
            if (existingUnpack) {
                forgeConfig.packagerConfig.asar.unpack = `{${existingUnpack},${newUnpack}}`;
            }
            else {
                forgeConfig.packagerConfig.asar.unpack = newUnpack;
            }
            return forgeConfig;
        };
    }
    getHooks() {
        return {
            resolveForgeConfig: this.resolveForgeConfig,
        };
    }
}
exports.default = AutoUnpackNativesPlugin;
exports.AutoUnpackNativesPlugin = AutoUnpackNativesPlugin;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiQXV0b1VucGFja05hdGl2ZXNQbHVnaW4uanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvQXV0b1VucGFja05hdGl2ZXNQbHVnaW4udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUEsNkRBQXlEO0FBS3pELE1BQXFCLHVCQUF3QixTQUFRLHdCQUFtQztJQUF4Rjs7UUFDRSxTQUFJLEdBQUcscUJBQXFCLENBQUM7UUFRN0IsdUJBQWtCLEdBQXNDLEtBQUssRUFBRSxXQUFXLEVBQUUsRUFBRTtZQUM1RSxJQUFJLENBQUMsV0FBVyxDQUFDLGNBQWMsRUFBRTtnQkFDL0IsV0FBVyxDQUFDLGNBQWMsR0FBRyxFQUFFLENBQUM7YU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