Icard/angular-clarity-master(work.../node_modules/@angular-devkit/schematics/tools/fallback-engine-host.js

88 lines
12 KiB
JavaScript
Raw Permalink Normal View History

2024-07-16 14:55:36 +00:00
"use strict";
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.FallbackEngineHost = void 0;
const rxjs_1 = require("rxjs");
const src_1 = require("../src");
/**
* An EngineHost that support multiple hosts in a fallback configuration. If a host does not
* have a collection/schematics, use the following host before giving up.
*/
class FallbackEngineHost {
constructor() {
this._hosts = [];
}
addHost(host) {
this._hosts.push(host);
}
createCollectionDescription(name, requester) {
for (const host of this._hosts) {
try {
const description = host.createCollectionDescription(name, requester);
return { name, host, description };
}
catch (_) { }
}
throw new src_1.UnknownCollectionException(name);
}
createSchematicDescription(name, collection) {
const description = collection.host.createSchematicDescription(name, collection.description);
if (!description) {
return null;
}
return { name, collection, description };
}
getSchematicRuleFactory(schematic, collection) {
return collection.host.getSchematicRuleFactory(schematic.description, collection.description);
}
createSourceFromUrl(url, context) {
return context.schematic.collection.description.host.createSourceFromUrl(url, context);
}
transformOptions(schematic, options, context) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return (0, rxjs_1.of)(options).pipe(...this._hosts.map((host) => (0, rxjs_1.mergeMap)((opt) => host.transformOptions(schematic, opt, context))));
}
transformContext(context) {
let result = context;
this._hosts.forEach((host) => {
result = (host.transformContext(result) || result);
});
return result;
}
listSchematicNames(collection, includeHidden) {
const allNames = new Set();
this._hosts.forEach((host) => {
try {
host
.listSchematicNames(collection.description, includeHidden)
.forEach((name) => allNames.add(name));
}
catch (_) { }
});
return [...allNames];
}
createTaskExecutor(name) {
for (const host of this._hosts) {
if (host.hasTaskExecutor(name)) {
return host.createTaskExecutor(name);
}
}
return (0, rxjs_1.throwError)(new src_1.UnregisteredTaskException(name));
}
hasTaskExecutor(name) {
for (const host of this._hosts) {
if (host.hasTaskExecutor(name)) {
return true;
}
}
return false;
}
}
exports.FallbackEngineHost = FallbackEngineHost;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmFsbGJhY2stZW5naW5lLWhvc3QuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi8uLi9wYWNrYWdlcy9hbmd1bGFyX2RldmtpdC9zY2hlbWF0aWNzL3Rvb2xzL2ZhbGxiYWNrLWVuZ2luZS1ob3N0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQTs7Ozs7O0dBTUc7OztBQUVILCtCQUE0RTtBQUU1RSxnQ0FVZ0I7QUFjaEI7OztHQUdHO0FBQ0gsTUFBYSxrQkFBa0I7SUFBL0I7UUFDVSxXQUFNLEdBQXlCLEVBQUUsQ0FBQztJQXdHNUMsQ0FBQztJQXRHQyxPQUFPLENBQ0wsSUFBeUM7UUFFekMsSUFBSSxDQUFDLE1BQU0sQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLENBQUM7SUFDekIsQ0FBQztJQUVELDJCQUEyQixDQUN6QixJQUFZLEVBQ1osU0FBcUM7UUFFckMsS0FBSyxNQUFNLElBQUksSUFBSSxJQUFJLENBQUMsTUFBTSxFQUFFO1lBQzlCLElBQUk7Z0JBQ0YsTUFBTSxXQUFXLEdBQUcsSUFBSSxDQUFDLDJCQUEyQixDQUFDLElBQUksRUFBRSxTQUFTLENBQUMsQ0FBQztnQkFFdEUsT0FBTyxFQUFFLElBQUksRUFBRSxJQUFJLEVBQUUsV0FBVyxFQUFFLENBQUM7YUFDcEM7WUFBQyxPQUFPLENBQUMsRUFBRSxHQUFFO1NBQ2Y7UUFFRCxNQUFNLElBQUksZ0NBQTBCLENBQUMsSUFBSSxDQUFDLENBQUM7SUFDN0MsQ0FBQztJQUVELDBCQUEwQixDQUN4QixJQUFZLEVBQ1osVUFBZ0U7UUFFaEUsTUFBT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