"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const base_resource_1 = __importDefault(require("./base-resource")); const asar_1 = __importDefault(require("../../utils/asar")); const path_1 = __importDefault(require("path")); const asar = new asar_1.default(); class AsarResource extends base_resource_1.default { constructor(resourcePath) { // NOTE: use a normalized path (GH-2101 PR) super(path_1.default.normalize(resourcePath)); this._archive = ''; this._fileName = ''; } _createContentStream() { try { this._contentStream = asar.extractFileToReadStream(this._archive, this._fileName); } catch (e) { e.message = asar.getFileInAsarNotFoundErrorMessage(this._archive, this._fileName); this._error = e; } } get isArchiveFound() { return !!this._archive; } async init() { if (!await asar.isAsar(this._path)) return; const { archive, fileName } = await asar.parse(this._path); this._archive = archive; this._fileName = fileName; await this._checkAccess(this._archive); if (!this._error) this._createContentStream(); } } exports.default = AsarResource;module.exports = exports.default;