UNPKG

@tdb/web

Version:

Common condiguration for serving a web-site and testing web-based UI components.

79 lines 3.36 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); var common_1 = require("../common"); var util = require("./util"); var Manifest = (function () { function Manifest(args) { this.rootDir = args.rootDir; this.path = "/" + util.cleanPath(args.path); this.urlPrefix = args.urlPrefix ? "/" + util.cleanPath(args.urlPrefix) : undefined; } Object.defineProperty(Manifest.prototype, "dir", { get: function () { return common_1.fsPath.join(this.rootDir, this.path); }, enumerable: true, configurable: true }); Manifest.prototype.getPaths = function () { return tslib_1.__awaiter(this, void 0, void 0, function () { var paths; return tslib_1.__generator(this, function (_a) { switch (_a.label) { case 0: return [4, common_1.glob.find(this.dir)]; case 1: paths = _a.sent(); return [2, paths]; } }); }); }; Manifest.prototype.toObject = function (args) { if (args === void 0) { args = {}; } return tslib_1.__awaiter(this, void 0, void 0, function () { var loadExtensions_1, paths, wait, files, result, error_1; var _this = this; return tslib_1.__generator(this, function (_a) { switch (_a.label) { case 0: _a.trys.push([0, 3, , 4]); loadExtensions_1 = args.loadExtensions; return [4, this.getPaths()]; case 1: paths = _a.sent(); wait = paths .filter(function (filePath) { return filePath !== _this.rootDir; }) .filter(function (filePath) { return !filePath.includes('@2x.'); }) .map(function (filePath) { return tslib_1.__awaiter(_this, void 0, void 0, function () { return tslib_1.__generator(this, function (_a) { return [2, util.toResource({ filePath: filePath, rootPath: this.rootDir, urlPrefix: this.urlPrefix, loadExtensions: loadExtensions_1, })]; }); }); }); return [4, Promise.all(wait)]; case 2: files = _a.sent(); result = { path: this.path, resources: files.filter(function (f) { return Boolean(f); }), }; return [2, result]; case 3: error_1 = _a.sent(); throw new Error("Failed to convert manifest '" + this.path + "' into an object."); case 4: return [2]; } }); }); }; return Manifest; }()); exports.Manifest = Manifest; //# sourceMappingURL=Manifest.js.map