1 | (function (factory) {
|
---|
2 | if (typeof module === "object" && typeof module.exports === "object") {
|
---|
3 | var v = factory(require, exports);
|
---|
4 | if (v !== undefined) module.exports = v;
|
---|
5 | }
|
---|
6 | else if (typeof define === "function" && define.amd) {
|
---|
7 | define("@angular/compiler-cli/linker/src/file_linker/file_linker", ["require", "exports", "tslib", "@angular/compiler-cli/linker/src/ast/ast_value", "@angular/compiler-cli/linker/src/file_linker/emit_scopes/emit_scope", "@angular/compiler-cli/linker/src/file_linker/emit_scopes/iife_emit_scope", "@angular/compiler-cli/linker/src/file_linker/partial_linkers/partial_linker_selector"], factory);
|
---|
8 | }
|
---|
9 | })(function (require, exports) {
|
---|
10 | "use strict";
|
---|
11 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
12 | exports.FileLinker = exports.NO_STATEMENTS = void 0;
|
---|
13 | var tslib_1 = require("tslib");
|
---|
14 | var ast_value_1 = require("@angular/compiler-cli/linker/src/ast/ast_value");
|
---|
15 | var emit_scope_1 = require("@angular/compiler-cli/linker/src/file_linker/emit_scopes/emit_scope");
|
---|
16 | var iife_emit_scope_1 = require("@angular/compiler-cli/linker/src/file_linker/emit_scopes/iife_emit_scope");
|
---|
17 | var partial_linker_selector_1 = require("@angular/compiler-cli/linker/src/file_linker/partial_linkers/partial_linker_selector");
|
---|
18 | exports.NO_STATEMENTS = [];
|
---|
19 | /**
|
---|
20 | * This class is responsible for linking all the partial declarations found in a single file.
|
---|
21 | */
|
---|
22 | var FileLinker = /** @class */ (function () {
|
---|
23 | function FileLinker(linkerEnvironment, sourceUrl, code) {
|
---|
24 | this.linkerEnvironment = linkerEnvironment;
|
---|
25 | this.emitScopes = new Map();
|
---|
26 | this.linkerSelector = new partial_linker_selector_1.PartialLinkerSelector(partial_linker_selector_1.createLinkerMap(this.linkerEnvironment, sourceUrl, code), this.linkerEnvironment.logger, this.linkerEnvironment.options.unknownDeclarationVersionHandling);
|
---|
27 | }
|
---|
28 | /**
|
---|
29 | * Return true if the given callee name matches a partial declaration that can be linked.
|
---|
30 | */
|
---|
31 | FileLinker.prototype.isPartialDeclaration = function (calleeName) {
|
---|
32 | return this.linkerSelector.supportsDeclaration(calleeName);
|
---|
33 | };
|
---|
34 | /**
|
---|
35 | * Link the metadata extracted from the args of a call to a partial declaration function.
|
---|
36 | *
|
---|
37 | * The `declarationScope` is used to determine the scope and strategy of emission of the linked
|
---|
38 | * definition and any shared constant statements.
|
---|
39 | *
|
---|
40 | * @param declarationFn the name of the function used to declare the partial declaration - e.g.
|
---|
41 | * `ɵɵngDeclareDirective`.
|
---|
42 | * @param args the arguments passed to the declaration function, should be a single object that
|
---|
43 | * corresponds to the `R3DeclareDirectiveMetadata` or `R3DeclareComponentMetadata` interfaces.
|
---|
44 | * @param declarationScope the scope that contains this call to the declaration function.
|
---|
45 | */
|
---|
46 | FileLinker.prototype.linkPartialDeclaration = function (declarationFn, args, declarationScope) {
|
---|
47 | if (args.length !== 1) {
|
---|
48 | throw new Error("Invalid function call: It should have only a single object literal argument, but contained " + args.length + ".");
|
---|
49 | }
|
---|
50 | var metaObj = ast_value_1.AstObject.parse(args[0], this.linkerEnvironment.host);
|
---|
51 | var ngImport = metaObj.getNode('ngImport');
|
---|
52 | var emitScope = this.getEmitScope(ngImport, declarationScope);
|
---|
53 | var minVersion = metaObj.getString('minVersion');
|
---|
54 | var version = metaObj.getString('version');
|
---|
55 | var linker = this.linkerSelector.getLinker(declarationFn, minVersion, version);
|
---|
56 | var definition = linker.linkPartialDeclaration(emitScope.constantPool, metaObj);
|
---|
57 | return emitScope.translateDefinition(definition);
|
---|
58 | };
|
---|
59 | /**
|
---|
60 | * Return all the shared constant statements and their associated constant scope references, so
|
---|
61 | * that they can be inserted into the source code.
|
---|
62 | */
|
---|
63 | FileLinker.prototype.getConstantStatements = function () {
|
---|
64 | var e_1, _a;
|
---|
65 | var results = [];
|
---|
66 | try {
|
---|
67 | for (var _b = tslib_1.__values(this.emitScopes.entries()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
---|
68 | var _d = tslib_1.__read(_c.value, 2), constantScope = _d[0], emitScope = _d[1];
|
---|
69 | var statements = emitScope.getConstantStatements();
|
---|
70 | results.push({ constantScope: constantScope, statements: statements });
|
---|
71 | }
|
---|
72 | }
|
---|
73 | catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
---|
74 | finally {
|
---|
75 | try {
|
---|
76 | if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
---|
77 | }
|
---|
78 | finally { if (e_1) throw e_1.error; }
|
---|
79 | }
|
---|
80 | return results;
|
---|
81 | };
|
---|
82 | FileLinker.prototype.getEmitScope = function (ngImport, declarationScope) {
|
---|
83 | var constantScope = declarationScope.getConstantScopeRef(ngImport);
|
---|
84 | if (constantScope === null) {
|
---|
85 | // There is no constant scope so we will emit extra statements into the definition IIFE.
|
---|
86 | return new iife_emit_scope_1.IifeEmitScope(ngImport, this.linkerEnvironment.translator, this.linkerEnvironment.factory);
|
---|
87 | }
|
---|
88 | if (!this.emitScopes.has(constantScope)) {
|
---|
89 | this.emitScopes.set(constantScope, new emit_scope_1.EmitScope(ngImport, this.linkerEnvironment.translator));
|
---|
90 | }
|
---|
91 | return this.emitScopes.get(constantScope);
|
---|
92 | };
|
---|
93 | return FileLinker;
|
---|
94 | }());
|
---|
95 | exports.FileLinker = FileLinker;
|
---|
96 | });
|
---|
97 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmlsZV9saW5rZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi8uLi8uLi9wYWNrYWdlcy9jb21waWxlci1jbGkvbGlua2VyL3NyYy9maWxlX2xpbmtlci9maWxlX2xpbmtlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7O0lBU0EsNEVBQTJDO0lBRTNDLGtHQUFtRDtJQUNuRCw0R0FBNEQ7SUFFNUQsZ0lBQWlHO0l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