ng-packagr
Version:
Compile and package Angular libraries in Angular Package Format (APF)
76 lines • 2.78 kB
JavaScript
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.PackageNode = exports.EntryPointNode = void 0;
exports.isEntryPoint = isEntryPoint;
exports.isPackage = isPackage;
exports.byEntryPoint = byEntryPoint;
exports.isEntryPointInProgress = isEntryPointInProgress;
exports.isEntryPointPending = isEntryPointPending;
exports.fileUrl = fileUrl;
exports.fileUrlPath = fileUrlPath;
exports.ngUrl = ngUrl;
const typescript_1 = __importDefault(require("typescript"));
const file_cache_1 = require("../file-system/file-cache");
const node_1 = require("../graph/node");
const select_1 = require("../graph/select");
const angular_diagnostics_cache_1 = require("../ngc/angular-diagnostics-cache");
const TYPE_NG_PACKAGE = 'application/ng-package';
const TYPE_NG_ENTRY_POINT = 'application/ng-entry-point';
/** A node that can be read through the `fs` api. */
const URL_PROTOCOL_FILE = 'file://';
/** A node specific to angular. */
const URL_PROTOCOL_NG = 'ng://';
function isEntryPoint(node) {
return node.type === TYPE_NG_ENTRY_POINT;
}
function isPackage(node) {
return node.type === TYPE_NG_PACKAGE;
}
function byEntryPoint() {
return (0, select_1.by)(isEntryPoint);
}
function isEntryPointInProgress() {
return (0, select_1.by)(n => isEntryPoint(n) && (0, select_1.isInProgress)(n));
}
function isEntryPointPending() {
return (0, select_1.by)(n => isEntryPoint(n) && (0, select_1.isPending)(n));
}
function fileUrl(path) {
return `${URL_PROTOCOL_FILE}${path}`;
}
function fileUrlPath(url) {
return url.startsWith(URL_PROTOCOL_FILE) ? url.slice(URL_PROTOCOL_FILE.length) : null;
}
function ngUrl(path) {
return `${URL_PROTOCOL_NG}${path}`;
}
class EntryPointNode extends node_1.Node {
constructor(url, sourcesFileCache, moduleResolutionCache) {
super(url);
this.url = url;
this.type = TYPE_NG_ENTRY_POINT;
this.cache = {
sourcesFileCache,
analysesSourcesFileCache: new file_cache_1.FileCache(),
moduleResolutionCache,
outputCache: new Map(),
angularDiagnosticCache: new angular_diagnostics_cache_1.AngularDiagnosticsCache(),
};
}
}
exports.EntryPointNode = EntryPointNode;
class PackageNode extends node_1.Node {
constructor() {
super(...arguments);
this.type = TYPE_NG_PACKAGE;
this.cache = {
sourcesFileCache: new file_cache_1.FileCache(),
moduleResolutionCache: typescript_1.default.createModuleResolutionCache(process.cwd(), s => s),
};
}
}
exports.PackageNode = PackageNode;
//# sourceMappingURL=nodes.js.map
;