Primeiro commit do projeto Angular
This commit is contained in:
+20
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* @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.dev/license
|
||||
*/
|
||||
import { JsonValue } from '@angular-devkit/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { jobs } from '../../src';
|
||||
export declare class NodeModuleJobRegistry<MinimumArgumentValueT extends JsonValue = JsonValue, MinimumInputValueT extends JsonValue = JsonValue, MinimumOutputValueT extends JsonValue = JsonValue> implements jobs.Registry<MinimumArgumentValueT, MinimumInputValueT, MinimumOutputValueT> {
|
||||
protected _resolve(name: string): string | null;
|
||||
/**
|
||||
* Get a job description for a named job.
|
||||
*
|
||||
* @param name The name of the job.
|
||||
* @returns A description, or null if the job is not registered.
|
||||
*/
|
||||
get<A extends MinimumArgumentValueT, I extends MinimumInputValueT, O extends MinimumOutputValueT>(name: jobs.JobName): Observable<jobs.JobHandler<A, I, O> | null>;
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
"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.dev/license
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.NodeModuleJobRegistry = void 0;
|
||||
const core_1 = require("@angular-devkit/core");
|
||||
const rxjs_1 = require("rxjs");
|
||||
class NodeModuleJobRegistry {
|
||||
_resolve(name) {
|
||||
try {
|
||||
return require.resolve(name);
|
||||
}
|
||||
catch (e) {
|
||||
if (e.code === 'MODULE_NOT_FOUND') {
|
||||
return null;
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Get a job description for a named job.
|
||||
*
|
||||
* @param name The name of the job.
|
||||
* @returns A description, or null if the job is not registered.
|
||||
*/
|
||||
get(name) {
|
||||
const [moduleName, exportName] = name.split(/#/, 2);
|
||||
const resolvedPath = this._resolve(moduleName);
|
||||
if (!resolvedPath) {
|
||||
return (0, rxjs_1.of)(null);
|
||||
}
|
||||
const pkg = require(resolvedPath);
|
||||
const handler = pkg[exportName || 'default'];
|
||||
if (!handler) {
|
||||
return (0, rxjs_1.of)(null);
|
||||
}
|
||||
function _getValue(...fields) {
|
||||
return fields.find((x) => core_1.schema.isJsonSchema(x)) || true;
|
||||
}
|
||||
const argument = _getValue(pkg.argument, handler.argument);
|
||||
const input = _getValue(pkg.input, handler.input);
|
||||
const output = _getValue(pkg.output, handler.output);
|
||||
const channels = _getValue(pkg.channels, handler.channels);
|
||||
return (0, rxjs_1.of)(Object.assign(handler.bind(undefined), {
|
||||
jobDescription: {
|
||||
argument,
|
||||
input,
|
||||
output,
|
||||
channels,
|
||||
},
|
||||
}));
|
||||
}
|
||||
}
|
||||
exports.NodeModuleJobRegistry = NodeModuleJobRegistry;
|
||||
//# sourceMappingURL=job-registry.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"job-registry.js","sourceRoot":"","sources":["job-registry.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,+CAAyD;AACzD,+BAAsC;AAGtC,MAAa,qBAAqB;IAMtB,QAAQ,CAAC,IAAY;QAC7B,IAAI,CAAC;YACH,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAC/B,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,IAAK,CAA2B,CAAC,IAAI,KAAK,kBAAkB,EAAE,CAAC;gBAC7D,OAAO,IAAI,CAAC;YACd,CAAC;YACD,MAAM,CAAC,CAAC;QACV,CAAC;IACH,CAAC;IAED;;;;;OAKG;IACH,GAAG,CACD,IAAkB;QAElB,MAAM,CAAC,UAAU,EAAE,UAAU,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;QAEpD,MAA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