UNPKG

@shockpkg/ria-packager

Version:

Package for creating Adobe AIR packages

134 lines (104 loc) 4.05 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.PackagerAdlMac = void 0; var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); var _path = require("path"); var puka = _interopRequireWildcard(require("puka")); var _fsExtra = _interopRequireDefault(require("fs-extra")); var _adl = require("../adl"); function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } // @ts-ignore-file const quoteForSh = puka.quoteForSh || puka.default.quoteForSh; /** * PackagerAdlMac constructor. * * @param path Output path. */ class PackagerAdlMac extends _adl.PackagerAdl { /** * Optionally preserve resource mtime. * The official packager does not preserve resource mtimes. */ constructor(path) { super(path); (0, _defineProperty2.default)(this, "preserveResourceMtime", false); } /** * Get app run path. * * @returns Resources path. */ get appRunPath() { return 'run'; } /** * Get file mode value. * * @param executable Is the entry executable. * @returns File mode. */ _getFileMode(executable) { return executable ? 0b111100100 : 0b110100100; } /** * The SDK components to be copied. * * @returns Required and optional components. */ _sdkComponents() { return { required: [['bin/adl'], ['runtimes/air/mac', // Old SDK 1.0 and 1.1 location: 'runtime/Adobe AIR.framework']], optional: [['bin/Contents']] }; } /** * Close implementation. */ async _close() { await this._writeRunScript(); } /** * Write resource with data implementation. * * @param destination Packaged file relative destination. * @param data Resource data. * @param options Resource options. */ async _writeResource(destination, data, options) { // Write resource to file. const mode = this._getFileMode(options.executable || false); const dest = this._getResourcePath(destination); await _fsExtra.default.outputFile(dest, data, { mode }); // Optionally preserve mtime information. if (this.preserveResourceMtime) { const { mtime } = options; if (mtime) { await _fsExtra.default.utimes(dest, mtime, mtime); } } } /** * Write the run script. */ async _writeRunScript() { const { appSdkPath, appResourcesPath, _metaResourceApplicationPath } = this; await _fsExtra.default.outputFile((0, _path.join)(this.path, this.appRunPath), ['#!/bin/sh', '', ['exec', ...[`${appSdkPath}/bin/adl`, ...this._generateOptionArguments(), `${appResourcesPath}/${_metaResourceApplicationPath}`, appResourcesPath].map(quoteForSh), '--', '"$@"'].join(' '), ''].join('\n'), { encoding: 'utf8', mode: 0o777 }); } } exports.PackagerAdlMac = PackagerAdlMac; //# sourceMappingURL=mac.js.map