UNPKG

@shockpkg/ria-packager

Version:

Package for creating Adobe AIR packages

274 lines (216 loc) 5.22 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.PackagerAdl = void 0; var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); var _path = require("path"); var _archiveFiles = require("@shockpkg/archive-files"); var _util = require("../util"); var _packager = require("../packager"); /** * PackagerAdl constructor. * * @param path Output path. */ class PackagerAdl extends _packager.Packager { /** * Path to the SDK, an archive or directory. */ /** * Application pubid. */ /** * Application profile. */ /** * Application screensize. */ /** * Application nodebug. */ /** * Application atlogin. */ constructor(path) { super(path); (0, _defineProperty2.default)(this, "sdkPath", null); (0, _defineProperty2.default)(this, "pubid", null); (0, _defineProperty2.default)(this, "profile", null); (0, _defineProperty2.default)(this, "screensize", null); (0, _defineProperty2.default)(this, "nodebug", false); (0, _defineProperty2.default)(this, "atlogin", false); } /** * Package mimetype. * * @returns Mimetype string. */ get mimetype() { return 'application/vnd.adobe.air-application-installer-package+zip'; } /** * Package signed. * * @returns Boolean for if package is signed or not. */ get signed() { return false; } /** * Get app sdk path. * * @returns Resources path. */ get appSdkPath() { return 'sdk'; } /** * Get app resources path. * * @returns Resources path. */ get appResourcesPath() { return 'app'; } /** * Get app run path. * * @returns Resources path. */ /** * Open the configured SDK. * * @returns Archive instance. */ async _openSdk() { const { sdkPath } = this; if (!sdkPath) { throw new Error('SDK path not set'); } const archive = await this._openArchive(sdkPath); return archive; } /** * Generate aruments. * * @returns Argument options. */ _generateOptionArguments() { const { pubid, profile, screensize, nodebug, atlogin } = this; const r = []; if (pubid !== null) { r.push('-pubid', pubid); } if (profile !== null) { r.push('-profile', profile); } if (screensize !== null) { r.push('-screensize', screensize); } if (nodebug) { r.push('-nodebug'); } if (atlogin) { r.push('-atlogin'); } return r; } /** * Open implementation. * * @param applicationData The application descriptor data. */ async _open(applicationData) { const { required, optional } = this._sdkComponents(); const components = [...required.map(paths => ({ paths, required: true, found: false })), ...optional.map(paths => ({ paths, required: false, found: false }))]; const component = volumePath => { // Default to not searching any subpaths. let r = false; for (const component of components) { for (const path of component.paths) { // If extracting, mark found, return true. if ((0, _util.pathRelativeBaseMatch)(volumePath, path, true)) { component.found = true; return true; } // If a parent path, remember to search down. if ((0, _util.pathRelativeBaseMatch)(path, volumePath, true)) { r = null; } } } return r; }; // Extract everything needed from the SDK. const sdk = await this._openSdk(); await sdk.read(async entry => { // Ignore any resource forks. if (entry.type === _archiveFiles.PathType.RESOURCE_FORK) { return true; } const path = entry.volumePath; const action = component(path); if (action === true) { const dest = this._getSdkPath(path); await entry.extract(dest); return true; } // Optimization to avoid walking unrelated directories if possible. return action === null ? true : null; }); // Check that everything necessary was extracted. for (const { found, required, paths } of components) { if (found || !required) { continue; } const info = paths.map(s => JSON.stringify(s)).join(' | '); throw new Error(`Failed to locate component in SDK: ${info}`); } } /** * Get path to a resource file. * * @param parts Path parts. * @returns Full path. */ _getSdkPath(...parts) { return (0, _path.join)(this.path, this.appSdkPath, ...parts); } /** * Get path to a resource file. * * @param parts Path parts. * @returns Full path. */ _getResourcePath(...parts) { return (0, _path.join)(this.path, this.appResourcesPath, ...parts); } /** * The SDK components to be copied. * * @returns Required and optional components. */ } exports.PackagerAdl = PackagerAdl; //# sourceMappingURL=adl.js.map