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/src/aot/summary_serializer", ["require", "exports", "tslib", "@angular/compiler/src/compile_metadata", "@angular/compiler/src/output/output_ast", "@angular/compiler/src/util", "@angular/compiler/src/aot/static_symbol", "@angular/compiler/src/aot/static_symbol_resolver", "@angular/compiler/src/aot/util"], factory);
|
---|
8 | }
|
---|
9 | })(function (require, exports) {
|
---|
10 | "use strict";
|
---|
11 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
12 | exports.createForJitStub = exports.deserializeSummaries = exports.serializeSummaries = void 0;
|
---|
13 | var tslib_1 = require("tslib");
|
---|
14 | /**
|
---|
15 | * @license
|
---|
16 | * Copyright Google LLC All Rights Reserved.
|
---|
17 | *
|
---|
18 | * Use of this source code is governed by an MIT-style license that can be
|
---|
19 | * found in the LICENSE file at https://angular.io/license
|
---|
20 | */
|
---|
21 | var compile_metadata_1 = require("@angular/compiler/src/compile_metadata");
|
---|
22 | var o = require("@angular/compiler/src/output/output_ast");
|
---|
23 | var util_1 = require("@angular/compiler/src/util");
|
---|
24 | var static_symbol_1 = require("@angular/compiler/src/aot/static_symbol");
|
---|
25 | var static_symbol_resolver_1 = require("@angular/compiler/src/aot/static_symbol_resolver");
|
---|
26 | var util_2 = require("@angular/compiler/src/aot/util");
|
---|
27 | function serializeSummaries(srcFileName, forJitCtx, summaryResolver, symbolResolver, symbols, types, createExternalSymbolReexports) {
|
---|
28 | if (createExternalSymbolReexports === void 0) { createExternalSymbolReexports = false; }
|
---|
29 | var toJsonSerializer = new ToJsonSerializer(symbolResolver, summaryResolver, srcFileName);
|
---|
30 | // for symbols, we use everything except for the class metadata itself
|
---|
31 | // (we keep the statics though), as the class metadata is contained in the
|
---|
32 | // CompileTypeSummary.
|
---|
33 | symbols.forEach(function (resolvedSymbol) { return toJsonSerializer.addSummary({ symbol: resolvedSymbol.symbol, metadata: resolvedSymbol.metadata }); });
|
---|
34 | // Add type summaries.
|
---|
35 | types.forEach(function (_a) {
|
---|
36 | var summary = _a.summary, metadata = _a.metadata;
|
---|
37 | toJsonSerializer.addSummary({ symbol: summary.type.reference, metadata: undefined, type: summary });
|
---|
38 | });
|
---|
39 | var _a = toJsonSerializer.serialize(createExternalSymbolReexports), json = _a.json, exportAs = _a.exportAs;
|
---|
40 | if (forJitCtx) {
|
---|
41 | var forJitSerializer_1 = new ForJitSerializer(forJitCtx, symbolResolver, summaryResolver);
|
---|
42 | types.forEach(function (_a) {
|
---|
43 | var summary = _a.summary, metadata = _a.metadata;
|
---|
44 | forJitSerializer_1.addSourceType(summary, metadata);
|
---|
45 | });
|
---|
46 | toJsonSerializer.unprocessedSymbolSummariesBySymbol.forEach(function (summary) {
|
---|
47 | if (summaryResolver.isLibraryFile(summary.symbol.filePath) && summary.type) {
|
---|
48 | forJitSerializer_1.addLibType(summary.type);
|
---|
49 | }
|
---|
50 | });
|
---|
51 | forJitSerializer_1.serialize(exportAs);
|
---|
52 | }
|
---|
53 | return { json: json, exportAs: exportAs };
|
---|
54 | }
|
---|
55 | exports.serializeSummaries = serializeSummaries;
|
---|
56 | function deserializeSummaries(symbolCache, summaryResolver, libraryFileName, json) {
|
---|
57 | var deserializer = new FromJsonDeserializer(symbolCache, summaryResolver);
|
---|
58 | return deserializer.deserialize(libraryFileName, json);
|
---|
59 | }
|
---|
60 | exports.deserializeSummaries = deserializeSummaries;
|
---|
61 | function createForJitStub(outputCtx, reference) {
|
---|
62 | return createSummaryForJitFunction(outputCtx, reference, o.NULL_EXPR);
|
---|
63 | }
|
---|
64 | exports.createForJitStub = createForJitStub;
|
---|
65 | function createSummaryForJitFunction(outputCtx, reference, value) {
|
---|
66 | var fnName = util_2.summaryForJitName(reference.name);
|
---|
67 | outputCtx.statements.push(o.fn([], [new o.ReturnStatement(value)], new o.ArrayType(o.DYNAMIC_TYPE)).toDeclStmt(fnName, [
|
---|
68 | o.StmtModifier.Final, o.StmtModifier.Exported
|
---|
69 | ]));
|
---|
70 | }
|
---|
71 | var ToJsonSerializer = /** @class */ (function (_super) {
|
---|
72 | tslib_1.__extends(ToJsonSerializer, _super);
|
---|
73 | function ToJsonSerializer(symbolResolver, summaryResolver, srcFileName) {
|
---|
74 | var _this = _super.call(this) || this;
|
---|
75 | _this.symbolResolver = symbolResolver;
|
---|
76 | _this.summaryResolver = summaryResolver;
|
---|
77 | _this.srcFileName = srcFileName;
|
---|
78 | // Note: This only contains symbols without members.
|
---|
79 | _this.symbols = [];
|
---|
80 | _this.indexBySymbol = new Map();
|
---|
81 | _this.reexportedBy = new Map();
|
---|
82 | // This now contains a `__symbol: number` in the place of
|
---|
83 | // StaticSymbols, but otherwise has the same shape as the original objects.
|
---|
84 | _this.processedSummaryBySymbol = new Map();
|
---|
85 | _this.processedSummaries = [];
|
---|
86 | _this.unprocessedSymbolSummariesBySymbol = new Map();
|
---|
87 | _this.moduleName = symbolResolver.getKnownModuleName(srcFileName);
|
---|
88 | return _this;
|
---|
89 | }
|
---|
90 | ToJsonSerializer.prototype.addSummary = function (summary) {
|
---|
91 | var _this = this;
|
---|
92 | var unprocessedSummary = this.unprocessedSymbolSummariesBySymbol.get(summary.symbol);
|
---|
93 | var processedSummary = this.processedSummaryBySymbol.get(summary.symbol);
|
---|
94 | if (!unprocessedSummary) {
|
---|
95 | unprocessedSummary = { symbol: summary.symbol, metadata: undefined };
|
---|
96 | this.unprocessedSymbolSummariesBySymbol.set(summary.symbol, unprocessedSummary);
|
---|
97 | processedSummary = { symbol: this.processValue(summary.symbol, 0 /* None */) };
|
---|
98 | this.processedSummaries.push(processedSummary);
|
---|
99 | this.processedSummaryBySymbol.set(summary.symbol, processedSummary);
|
---|
100 | }
|
---|
101 | if (!unprocessedSummary.metadata && summary.metadata) {
|
---|
102 | var metadata_1 = summary.metadata || {};
|
---|
103 | if (metadata_1.__symbolic === 'class') {
|
---|
104 | // For classes, we keep everything except their class decorators.
|
---|
105 | // We need to keep e.g. the ctor args, method names, method decorators
|
---|
106 | // so that the class can be extended in another compilation unit.
|
---|
107 | // We don't keep the class decorators as
|
---|
108 | // 1) they refer to data
|
---|
109 | // that should not cause a rebuild of downstream compilation units
|
---|
110 | // (e.g. inline templates of @Component, or @NgModule.declarations)
|
---|
111 | // 2) their data is already captured in TypeSummaries, e.g. DirectiveSummary.
|
---|
112 | var clone_1 = {};
|
---|
113 | Object.keys(metadata_1).forEach(function (propName) {
|
---|
114 | if (propName !== 'decorators') {
|
---|
115 | clone_1[propName] = metadata_1[propName];
|
---|
116 | }
|
---|
117 | });
|
---|
118 | metadata_1 = clone_1;
|
---|
119 | }
|
---|
120 | else if (isCall(metadata_1)) {
|
---|
121 | if (!isFunctionCall(metadata_1) && !isMethodCallOnVariable(metadata_1)) {
|
---|
122 | // Don't store complex calls as we won't be able to simplify them anyways later on.
|
---|
123 | metadata_1 = {
|
---|
124 | __symbolic: 'error',
|
---|
125 | message: 'Complex function calls are not supported.',
|
---|
126 | };
|
---|
127 | }
|
---|
128 | }
|
---|
129 | // Note: We need to keep storing ctor calls for e.g.
|
---|
130 | // `export const x = new InjectionToken(...)`
|
---|
131 | unprocessedSummary.metadata = metadata_1;
|
---|
132 | processedSummary.metadata = this.processValue(metadata_1, 1 /* ResolveValue */);
|
---|
133 | if (metadata_1 instanceof static_symbol_1.StaticSymbol &&
|
---|
134 | this.summaryResolver.isLibraryFile(metadata_1.filePath)) {
|
---|
135 | var declarationSymbol = this.symbols[this.indexBySymbol.get(metadata_1)];
|
---|
136 | if (!util_2.isLoweredSymbol(declarationSymbol.name)) {
|
---|
137 | // Note: symbols that were introduced during codegen in the user file can have a reexport
|
---|
138 | // if a user used `export *`. However, we can't rely on this as tsickle will change
|
---|
139 | // `export *` into named exports, using only the information from the typechecker.
|
---|
140 | // As we introduce the new symbols after typecheck, Tsickle does not know about them,
|
---|
141 | // and omits them when expanding `export *`.
|
---|
142 | // So we have to keep reexporting these symbols manually via .ngfactory files.
|
---|
143 | this.reexportedBy.set(declarationSymbol, summary.symbol);
|
---|
144 | }
|
---|
145 | }
|
---|
146 | }
|
---|
147 | if (!unprocessedSummary.type && summary.type) {
|
---|
148 | unprocessedSummary.type = summary.type;
|
---|
149 | // Note: We don't add the summaries of all referenced symbols as for the ResolvedSymbols,
|
---|
150 | // as the type summaries already contain the transitive data that they require
|
---|
151 | // (in a minimal way).
|
---|
152 | processedSummary.type = this.processValue(summary.type, 0 /* None */);
|
---|
153 | // except for reexported directives / pipes, so we need to store
|
---|
154 | // their summaries explicitly.
|
---|
155 | if (summary.type.summaryKind === compile_metadata_1.CompileSummaryKind.NgModule) {
|
---|
156 | var ngModuleSummary = summary.type;
|
---|
157 | ngModuleSummary.exportedDirectives.concat(ngModuleSummary.exportedPipes).forEach(function (id) {
|
---|
158 | var symbol = id.reference;
|
---|
159 | if (_this.summaryResolver.isLibraryFile(symbol.filePath) &&
|
---|
160 | !_this.unprocessedSymbolSummariesBySymbol.has(symbol)) {
|
---|
161 | var summary_1 = _this.summaryResolver.resolveSummary(symbol);
|
---|
162 | if (summary_1) {
|
---|
163 | _this.addSummary(summary_1);
|
---|
164 | }
|
---|
165 | }
|
---|
166 | });
|
---|
167 | }
|
---|
168 | }
|
---|
169 | };
|
---|
170 | /**
|
---|
171 | * @param createExternalSymbolReexports Whether external static symbols should be re-exported.
|
---|
172 | * This can be enabled if external symbols should be re-exported by the current module in
|
---|
173 | * order to avoid dynamically generated module dependencies which can break strict dependency
|
---|
174 | * enforcements (as in Google3). Read more here: https://github.com/angular/angular/issues/25644
|
---|
175 | */
|
---|
176 | ToJsonSerializer.prototype.serialize = function (createExternalSymbolReexports) {
|
---|
177 | var _this = this;
|
---|
178 | var exportAs = [];
|
---|
179 | var json = JSON.stringify({
|
---|
180 | moduleName: this.moduleName,
|
---|
181 | summaries: this.processedSummaries,
|
---|
182 | symbols: this.symbols.map(function (symbol, index) {
|
---|
183 | symbol.assertNoMembers();
|
---|
184 | var importAs = undefined;
|
---|
185 | if (_this.summaryResolver.isLibraryFile(symbol.filePath)) {
|
---|
186 | var reexportSymbol = _this.reexportedBy.get(symbol);
|
---|
187 | if (reexportSymbol) {
|
---|
188 | // In case the given external static symbol is already manually exported by the
|
---|
189 | // user, we just proxy the external static symbol reference to the manual export.
|
---|
190 | // This ensures that the AOT compiler imports the external symbol through the
|
---|
191 | // user export and does not introduce another dependency which is not needed.
|
---|
192 | importAs = _this.indexBySymbol.get(reexportSymbol);
|
---|
193 | }
|
---|
194 | else if (createExternalSymbolReexports) {
|
---|
195 | // In this case, the given external static symbol is *not* manually exported by
|
---|
196 | // the user, and we manually create a re-export in the factory file so that we
|
---|
197 | // don't introduce another module dependency. This is useful when running within
|
---|
198 | // Bazel so that the AOT compiler does not introduce any module dependencies
|
---|
199 | // which can break the strict dependency enforcement. (e.g. as in Google3)
|
---|
200 | // Read more about this here: https://github.com/angular/angular/issues/25644
|
---|
201 | var summary = _this.unprocessedSymbolSummariesBySymbol.get(symbol);
|
---|
202 | if (!summary || !summary.metadata || summary.metadata.__symbolic !== 'interface') {
|
---|
203 | importAs = symbol.name + "_" + index;
|
---|
204 | exportAs.push({ symbol: symbol, exportAs: importAs });
|
---|
205 | }
|
---|
206 | }
|
---|
207 | }
|
---|
208 | return {
|
---|
209 | __symbol: index,
|
---|
210 | name: symbol.name,
|
---|
211 | filePath: _this.summaryResolver.toSummaryFileName(symbol.filePath, _this.srcFileName),
|
---|
212 | importAs: importAs
|
---|
213 | };
|
---|
214 | })
|
---|
215 | });
|
---|
216 | return { json: json, exportAs: exportAs };
|
---|
217 | };
|
---|
218 | ToJsonSerializer.prototype.processValue = function (value, flags) {
|
---|
219 | return util_1.visitValue(value, this, flags);
|
---|
220 | };
|
---|
221 | ToJsonSerializer.prototype.visitOther = function (value, context) {
|
---|
222 | if (value instanceof static_symbol_1.StaticSymbol) {
|
---|
223 | var baseSymbol = this.symbolResolver.getStaticSymbol(value.filePath, value.name);
|
---|
224 | var index = this.visitStaticSymbol(baseSymbol, context);
|
---|
225 | return { __symbol: index, members: value.members };
|
---|
226 | }
|
---|
227 | };
|
---|
228 | /**
|
---|
229 | * Strip line and character numbers from ngsummaries.
|
---|
230 | * Emitting them causes white spaces changes to retrigger upstream
|
---|
231 | * recompilations in bazel.
|
---|
232 | * TODO: find out a way to have line and character numbers in errors without
|
---|
233 | * excessive recompilation in bazel.
|
---|
234 | */
|
---|
235 | ToJsonSerializer.prototype.visitStringMap = function (map, context) {
|
---|
236 | if (map['__symbolic'] === 'resolved') {
|
---|
237 | return util_1.visitValue(map['symbol'], this, context);
|
---|
238 | }
|
---|
239 | if (map['__symbolic'] === 'error') {
|
---|
240 | delete map['line'];
|
---|
241 | delete map['character'];
|
---|
242 | }
|
---|
243 | return _super.prototype.visitStringMap.call(this, map, context);
|
---|
244 | };
|
---|
245 | /**
|
---|
246 | * Returns null if the options.resolveValue is true, and the summary for the symbol
|
---|
247 | * resolved to a type or could not be resolved.
|
---|
248 | */
|
---|
249 | ToJsonSerializer.prototype.visitStaticSymbol = function (baseSymbol, flags) {
|
---|
250 | var index = this.indexBySymbol.get(baseSymbol);
|
---|
251 | var summary = null;
|
---|
252 | if (flags & 1 /* ResolveValue */ &&
|
---|
253 | this.summaryResolver.isLibraryFile(baseSymbol.filePath)) {
|
---|
254 | if (this.unprocessedSymbolSummariesBySymbol.has(baseSymbol)) {
|
---|
255 | // the summary for this symbol was already added
|
---|
256 | // -> nothing to do.
|
---|
257 | return index;
|
---|
258 | }
|
---|
259 | summary = this.loadSummary(baseSymbol);
|
---|
260 | if (summary && summary.metadata instanceof static_symbol_1.StaticSymbol) {
|
---|
261 | // The summary is a reexport
|
---|
262 | index = this.visitStaticSymbol(summary.metadata, flags);
|
---|
263 | // reset the summary as it is just a reexport, so we don't want to store it.
|
---|
264 | summary = null;
|
---|
265 | }
|
---|
266 | }
|
---|
267 | else if (index != null) {
|
---|
268 | // Note: == on purpose to compare with undefined!
|
---|
269 | // No summary and the symbol is already added -> nothing to do.
|
---|
270 | return index;
|
---|
271 | }
|
---|
272 | // Note: == on purpose to compare with undefined!
|
---|
273 | if (index == null) {
|
---|
274 | index = this.symbols.length;
|
---|
275 | this.symbols.push(baseSymbol);
|
---|
276 | }
|
---|
277 | this.indexBySymbol.set(baseSymbol, index);
|
---|
278 | if (summary) {
|
---|
279 | this.addSummary(summary);
|
---|
280 | }
|
---|
281 | return index;
|
---|
282 | };
|
---|
283 | ToJsonSerializer.prototype.loadSummary = function (symbol) {
|
---|
284 | var summary = this.summaryResolver.resolveSummary(symbol);
|
---|
285 | if (!summary) {
|
---|
286 | // some symbols might originate from a plain typescript library
|
---|
287 | // that just exported .d.ts and .metadata.json files, i.e. where no summary
|
---|
288 | // files were created.
|
---|
289 | var resolvedSymbol = this.symbolResolver.resolveSymbol(symbol);
|
---|
290 | if (resolvedSymbol) {
|
---|
291 | summary = { symbol: resolvedSymbol.symbol, metadata: resolvedSymbol.metadata };
|
---|
292 | }
|
---|
293 | }
|
---|
294 | return summary;
|
---|
295 | };
|
---|
296 | return ToJsonSerializer;
|
---|
297 | }(util_1.ValueTransformer));
|
---|
298 | var ForJitSerializer = /** @class */ (function () {
|
---|
299 | function ForJitSerializer(outputCtx, symbolResolver, summaryResolver) {
|
---|
300 | this.outputCtx = outputCtx;
|
---|
301 | this.symbolResolver = symbolResolver;
|
---|
302 | this.summaryResolver = summaryResolver;
|
---|
303 | this.data = [];
|
---|
304 | }
|
---|
305 | ForJitSerializer.prototype.addSourceType = function (summary, metadata) {
|
---|
306 | this.data.push({ summary: summary, metadata: metadata, isLibrary: false });
|
---|
307 | };
|
---|
308 | ForJitSerializer.prototype.addLibType = function (summary) {
|
---|
309 | this.data.push({ summary: summary, metadata: null, isLibrary: true });
|
---|
310 | };
|
---|
311 | ForJitSerializer.prototype.serialize = function (exportAsArr) {
|
---|
312 | var e_1, _a, e_2, _b, e_3, _c;
|
---|
313 | var _this = this;
|
---|
314 | var exportAsBySymbol = new Map();
|
---|
315 | try {
|
---|
316 | for (var exportAsArr_1 = tslib_1.__values(exportAsArr), exportAsArr_1_1 = exportAsArr_1.next(); !exportAsArr_1_1.done; exportAsArr_1_1 = exportAsArr_1.next()) {
|
---|
317 | var _d = exportAsArr_1_1.value, symbol = _d.symbol, exportAs = _d.exportAs;
|
---|
318 | exportAsBySymbol.set(symbol, exportAs);
|
---|
319 | }
|
---|
320 | }
|
---|
321 | catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
---|
322 | finally {
|
---|
323 | try {
|
---|
324 | if (exportAsArr_1_1 && !exportAsArr_1_1.done && (_a = exportAsArr_1.return)) _a.call(exportAsArr_1);
|
---|
325 | }
|
---|
326 | finally { if (e_1) throw e_1.error; }
|
---|
327 | }
|
---|
328 | var ngModuleSymbols = new Set();
|
---|
329 | try {
|
---|
330 | for (var _e = tslib_1.__values(this.data), _f = _e.next(); !_f.done; _f = _e.next()) {
|
---|
331 | var _g = _f.value, summary = _g.summary, metadata = _g.metadata, isLibrary = _g.isLibrary;
|
---|
332 | if (summary.summaryKind === compile_metadata_1.CompileSummaryKind.NgModule) {
|
---|
333 | // collect the symbols that refer to NgModule classes.
|
---|
334 | // Note: we can't just rely on `summary.type.summaryKind` to determine this as
|
---|
335 | // we don't add the summaries of all referenced symbols when we serialize type summaries.
|
---|
336 | // See serializeSummaries for details.
|
---|
337 | ngModuleSymbols.add(summary.type.reference);
|
---|
338 | var modSummary = summary;
|
---|
339 | try {
|
---|
340 | for (var _h = (e_3 = void 0, tslib_1.__values(modSummary.modules)), _j = _h.next(); !_j.done; _j = _h.next()) {
|
---|
341 | var mod = _j.value;
|
---|
342 | ngModuleSymbols.add(mod.reference);
|
---|
343 | }
|
---|
344 | }
|
---|
345 | catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
---|
346 | finally {
|
---|
347 | try {
|
---|
348 | if (_j && !_j.done && (_c = _h.return)) _c.call(_h);
|
---|
349 | }
|
---|
350 | finally { if (e_3) throw e_3.error; }
|
---|
351 | }
|
---|
352 | }
|
---|
353 | if (!isLibrary) {
|
---|
354 | var fnName = util_2.summaryForJitName(summary.type.reference.name);
|
---|
355 | createSummaryForJitFunction(this.outputCtx, summary.type.reference, this.serializeSummaryWithDeps(summary, metadata));
|
---|
356 | }
|
---|
357 | }
|
---|
358 | }
|
---|
359 | catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
---|
360 | finally {
|
---|
361 | try {
|
---|
362 | if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
---|
363 | }
|
---|
364 | finally { if (e_2) throw e_2.error; }
|
---|
365 | }
|
---|
366 | ngModuleSymbols.forEach(function (ngModuleSymbol) {
|
---|
367 | if (_this.summaryResolver.isLibraryFile(ngModuleSymbol.filePath)) {
|
---|
368 | var exportAs = exportAsBySymbol.get(ngModuleSymbol) || ngModuleSymbol.name;
|
---|
369 | var jitExportAsName = util_2.summaryForJitName(exportAs);
|
---|
370 | _this.outputCtx.statements.push(o.variable(jitExportAsName)
|
---|
371 | .set(_this.serializeSummaryRef(ngModuleSymbol))
|
---|
372 | .toDeclStmt(null, [o.StmtModifier.Exported]));
|
---|
373 | }
|
---|
374 | });
|
---|
375 | };
|
---|
376 | ForJitSerializer.prototype.serializeSummaryWithDeps = function (summary, metadata) {
|
---|
377 | var _this = this;
|
---|
378 | var expressions = [this.serializeSummary(summary)];
|
---|
379 | var providers = [];
|
---|
380 | if (metadata instanceof compile_metadata_1.CompileNgModuleMetadata) {
|
---|
381 | expressions.push.apply(expressions, tslib_1.__spreadArray([], tslib_1.__read(
|
---|
382 | // For directives / pipes, we only add the declared ones,
|
---|
383 | // and rely on transitively importing NgModules to get the transitive
|
---|
384 | // summaries.
|
---|
385 | metadata.declaredDirectives.concat(metadata.declaredPipes)
|
---|
386 | .map(function (type) { return type.reference; })
|
---|
387 | // For modules,
|
---|
388 | // we also add the summaries for modules
|
---|
389 | // from libraries.
|
---|
390 | // This is ok as we produce reexports for all transitive modules.
|
---|
391 | .concat(metadata.transitiveModule.modules.map(function (type) { return type.reference; })
|
---|
392 | .filter(function (ref) { return ref !== metadata.type.reference; }))
|
---|
393 | .map(function (ref) { return _this.serializeSummaryRef(ref); }))));
|
---|
394 | // Note: We don't use `NgModuleSummary.providers`, as that one is transitive,
|
---|
395 | // and we already have transitive modules.
|
---|
396 | providers = metadata.providers;
|
---|
397 | }
|
---|
398 | else if (summary.summaryKind === compile_metadata_1.CompileSummaryKind.Directive) {
|
---|
399 | var dirSummary = summary;
|
---|
400 | providers = dirSummary.providers.concat(dirSummary.viewProviders);
|
---|
401 | }
|
---|
402 | // Note: We can't just refer to the `ngsummary.ts` files for `useClass` providers (as we do for
|
---|
403 | // declaredDirectives / declaredPipes), as we allow
|
---|
404 | // providers without ctor arguments to skip the `@Injectable` decorator,
|
---|
405 | // i.e. we didn't generate .ngsummary.ts files for these.
|
---|
406 | expressions.push.apply(expressions, tslib_1.__spreadArray([], tslib_1.__read(providers.filter(function (provider) { return !!provider.useClass; }).map(function (provider) { return _this.serializeSummary({
|
---|
407 | summaryKind: compile_metadata_1.CompileSummaryKind.Injectable,
|
---|
408 | type: provider.useClass
|
---|
409 | }); }))));
|
---|
410 | return o.literalArr(expressions);
|
---|
411 | };
|
---|
412 | ForJitSerializer.prototype.serializeSummaryRef = function (typeSymbol) {
|
---|
413 | var jitImportedSymbol = this.symbolResolver.getStaticSymbol(util_2.summaryForJitFileName(typeSymbol.filePath), util_2.summaryForJitName(typeSymbol.name));
|
---|
414 | return this.outputCtx.importExpr(jitImportedSymbol);
|
---|
415 | };
|
---|
416 | ForJitSerializer.prototype.serializeSummary = function (data) {
|
---|
417 | var outputCtx = this.outputCtx;
|
---|
418 | var Transformer = /** @class */ (function () {
|
---|
419 | function Transformer() {
|
---|
420 | }
|
---|
421 | Transformer.prototype.visitArray = function (arr, context) {
|
---|
422 | var _this = this;
|
---|
423 | return o.literalArr(arr.map(function (entry) { return util_1.visitValue(entry, _this, context); }));
|
---|
424 | };
|
---|
425 | Transformer.prototype.visitStringMap = function (map, context) {
|
---|
426 | var _this = this;
|
---|
427 | return new o.LiteralMapExpr(Object.keys(map).map(function (key) { return new o.LiteralMapEntry(key, util_1.visitValue(map[key], _this, context), false); }));
|
---|
428 | };
|
---|
429 | Transformer.prototype.visitPrimitive = function (value, context) {
|
---|
430 | return o.literal(value);
|
---|
431 | };
|
---|
432 | Transformer.prototype.visitOther = function (value, context) {
|
---|
433 | if (value instanceof static_symbol_1.StaticSymbol) {
|
---|
434 | return outputCtx.importExpr(value);
|
---|
435 | }
|
---|
436 | else {
|
---|
437 | throw new Error("Illegal State: Encountered value " + value);
|
---|
438 | }
|
---|
439 | };
|
---|
440 | return Transformer;
|
---|
441 | }());
|
---|
442 | return util_1.visitValue(data, new Transformer(), null);
|
---|
443 | };
|
---|
444 | return ForJitSerializer;
|
---|
445 | }());
|
---|
446 | var FromJsonDeserializer = /** @class */ (function (_super) {
|
---|
447 | tslib_1.__extends(FromJsonDeserializer, _super);
|
---|
448 | function FromJsonDeserializer(symbolCache, summaryResolver) {
|
---|
449 | var _this = _super.call(this) || this;
|
---|
450 | _this.symbolCache = symbolCache;
|
---|
451 | _this.summaryResolver = summaryResolver;
|
---|
452 | return _this;
|
---|
453 | }
|
---|
454 | FromJsonDeserializer.prototype.deserialize = function (libraryFileName, json) {
|
---|
455 | var _this = this;
|
---|
456 | var data = JSON.parse(json);
|
---|
457 | var allImportAs = [];
|
---|
458 | this.symbols = data.symbols.map(function (serializedSymbol) { return _this.symbolCache.get(_this.summaryResolver.fromSummaryFileName(serializedSymbol.filePath, libraryFileName), serializedSymbol.name); });
|
---|
459 | data.symbols.forEach(function (serializedSymbol, index) {
|
---|
460 | var symbol = _this.symbols[index];
|
---|
461 | var importAs = serializedSymbol.importAs;
|
---|
462 | if (typeof importAs === 'number') {
|
---|
463 | allImportAs.push({ symbol: symbol, importAs: _this.symbols[importAs] });
|
---|
464 | }
|
---|
465 | else if (typeof importAs === 'string') {
|
---|
466 | allImportAs.push({ symbol: symbol, importAs: _this.symbolCache.get(util_2.ngfactoryFilePath(libraryFileName), importAs) });
|
---|
467 | }
|
---|
468 | });
|
---|
469 | var summaries = util_1.visitValue(data.summaries, this, null);
|
---|
470 | return { moduleName: data.moduleName, summaries: summaries, importAs: allImportAs };
|
---|
471 | };
|
---|
472 | FromJsonDeserializer.prototype.visitStringMap = function (map, context) {
|
---|
473 | if ('__symbol' in map) {
|
---|
474 | var baseSymbol = this.symbols[map['__symbol']];
|
---|
475 | var members = map['members'];
|
---|
476 | return members.length ? this.symbolCache.get(baseSymbol.filePath, baseSymbol.name, members) :
|
---|
477 | baseSymbol;
|
---|
478 | }
|
---|
479 | else {
|
---|
480 | return _super.prototype.visitStringMap.call(this, map, context);
|
---|
481 | }
|
---|
482 | };
|
---|
483 | return FromJsonDeserializer;
|
---|
484 | }(util_1.ValueTransformer));
|
---|
485 | function isCall(metadata) {
|
---|
486 | return metadata && metadata.__symbolic === 'call';
|
---|
487 | }
|
---|
488 | function isFunctionCall(metadata) {
|
---|
489 | return isCall(metadata) && static_symbol_resolver_1.unwrapResolvedMetadata(metadata.expression) instanceof static_symbol_1.StaticSymbol;
|
---|
490 | }
|
---|
491 | function isMethodCallOnVariable(metadata) {
|
---|
492 | return isCall(metadata) && metadata.expression && metadata.expression.__symbolic === 'select' &&
|
---|
493 | static_symbol_resolver_1.unwrapResolvedMetadata(metadata.expression.expression) instanceof static_symbol_1.StaticSymbol;
|
---|
494 | }
|
---|
495 | });
|
---|
496 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3VtbWFyeV9zZXJpYWxpemVyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vLi4vcGFja2FnZXMvY29tcGlsZXIvc3JjL2FvdC9zdW1tYXJ5X3NlcmlhbGl6ZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7OztJQU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8gc3VtbWFyaWVzLlxuICAgICAgICAgICAgICAgICAgICAgICBtZXRhZGF0YS5kZWNsYXJlZERpcmVjdGl2ZXMuY29uY2F0KG1ldGFkYXRhLmRlY2xhcmVkUGlwZXMpXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAubWFwKHR5cGUgPT4gdHlwZS5yZWZlcmVuY2UpXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBGb3IgbW9kdWxlcyxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIHdlIGFsc28gYWRkIHRoZSBzdW1tYXJpZXMgZm9yIG1vZHVsZXNcbiAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIGZyb20gbGlicmFyaWVzLlxuICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gVGhpcyBpcyBvayBhcyB3ZSBwcm9kdWNlIHJlZXhwb3J0cyBmb3IgYWxsIHRyYW5zaXRpdmUgbW9kdWxlcy5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgIC5jb25jYXQobWV0YWRhdGEudHJhbnNpdGl2ZU1vZHVsZS5tb2R1bGVzLm1hcCh0eXBlID0+IHR5cGUucmVmZXJlbmNlKVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmZpbHRlcihyZWYgPT4gcmVmICE9PSBtZXRhZGF0YS50eXBlLnJlZmVyZW5jZSkpXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAubWFwKChyZWYpID0+IHRoaXMuc2VyaWFsaXplU3VtbWFyeVJlZihyZWYpKSk7XG4gICAgICAvLyBOb3RlOiBXZSBkb24ndCB1c2UgYE5nTW9kdWxlU3VtbWFyeS5wcm92aWRlcnNgLCBhcyB0aGF0IG9uZSBpcyB0cmFuc2l0aXZlLFxuICAgICAgLy8gYW5kIHdlIGFscmVhZHkgaGF2ZSB0cmFuc2l0aXZlIG1vZHVsZXMuXG4gICAgICBwcm92aWRlcnMgPSBtZXRhZGF0YS5wcm92aWRlcnM7XG4gICAgfSB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