@angular/compiler-cli 13.1.0-next.2 → 13.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/{chunk-2DL256T3.js → chunk-5TY44ZS3.js} +426 -434
- package/bundles/chunk-5TY44ZS3.js.map +6 -0
- package/bundles/{chunk-EP5JHXG2.js → chunk-676MI6WZ.js} +33 -54
- package/bundles/chunk-676MI6WZ.js.map +6 -0
- package/bundles/{chunk-WOC6KEUY.js → chunk-6VRWTEQB.js} +28 -30
- package/bundles/chunk-6VRWTEQB.js.map +6 -0
- package/bundles/{chunk-S3QIIFH7.js → chunk-7PY7XEFH.js} +9 -6
- package/bundles/chunk-7PY7XEFH.js.map +6 -0
- package/bundles/{chunk-PBA67OV4.js → chunk-A5PL3TE6.js} +30 -6
- package/bundles/chunk-A5PL3TE6.js.map +6 -0
- package/bundles/{chunk-QL6ZC3U3.js → chunk-ADHVDA4A.js} +6 -6
- package/bundles/{chunk-QL6ZC3U3.js.map → chunk-ADHVDA4A.js.map} +1 -1
- package/bundles/{chunk-MIQ5UCHZ.js → chunk-FUZ3CSDO.js} +306 -389
- package/bundles/chunk-FUZ3CSDO.js.map +6 -0
- package/bundles/{chunk-BUHTODFL.js → chunk-JOLPJ2E4.js} +21 -19
- package/bundles/chunk-JOLPJ2E4.js.map +6 -0
- package/bundles/{chunk-UMUIU7TE.js → chunk-O4XVCXRT.js} +2 -2
- package/bundles/{chunk-UMUIU7TE.js.map → chunk-O4XVCXRT.js.map} +0 -0
- package/bundles/{chunk-WYO7JO2T.js → chunk-QBU7RUKB.js} +259 -85
- package/bundles/chunk-QBU7RUKB.js.map +6 -0
- package/bundles/{chunk-VKIZ4TCJ.js → chunk-TUNE6DP3.js} +6370 -10786
- package/bundles/chunk-TUNE6DP3.js.map +6 -0
- package/bundles/{chunk-JNWO3JB2.js → chunk-UESD6FVI.js} +13 -15
- package/bundles/chunk-UESD6FVI.js.map +6 -0
- package/bundles/{chunk-XA5IZLLC.js → chunk-WQ3TNYTD.js} +6 -6
- package/bundles/{chunk-XA5IZLLC.js.map → chunk-WQ3TNYTD.js.map} +0 -0
- package/bundles/index.js +9 -73
- package/bundles/index.js.map +2 -2
- package/bundles/linker/babel/index.js +77 -77
- package/bundles/linker/babel/index.js.map +1 -1
- package/bundles/linker/index.js +5 -5
- package/bundles/ngcc/index.js +9 -10
- package/bundles/ngcc/index.js.map +1 -1
- package/bundles/ngcc/main-ngcc.js +10 -11
- package/bundles/ngcc/main-ngcc.js.map +1 -1
- package/bundles/ngcc/src/execution/cluster/ngcc_cluster_worker.js +9 -10
- package/bundles/ngcc/src/execution/cluster/ngcc_cluster_worker.js.map +1 -1
- package/bundles/ngcc/src/locking/lock_file_with_child_process/ngcc_lock_unlocker.js +2 -2
- package/bundles/private/bazel.js +1 -1
- package/bundles/private/localize.js +3 -3
- package/bundles/private/migrations.js +5 -5
- package/bundles/private/tooling.js +3 -4
- package/bundles/src/bin/ng_xi18n.js +7 -8
- package/bundles/src/bin/ng_xi18n.js.map +1 -1
- package/bundles/src/bin/ngc.js +9 -10
- package/bundles/src/bin/ngc.js.map +1 -1
- package/bundles_metadata.json +1 -1
- package/index.d.ts +2 -3
- package/ngcc/src/host/delegating_host.d.ts +1 -2
- package/ngcc/src/host/esm2015_host.d.ts +1 -8
- package/ngcc/src/host/ngcc_host.d.ts +0 -13
- package/ngcc/src/host/umd_host.d.ts +3 -0
- package/ngcc/src/packages/build_marker.d.ts +1 -1
- package/ngcc/src/packages/transformer.d.ts +0 -2
- package/ngcc/src/rendering/esm_rendering_formatter.d.ts +1 -5
- package/ngcc/src/rendering/renderer.d.ts +2 -3
- package/ngcc/src/rendering/rendering_formatter.d.ts +0 -2
- package/ngcc/src/utils.d.ts +0 -7
- package/package.json +3 -3
- package/src/main.d.ts +3 -3
- package/src/ngtsc/annotations/src/util.d.ts +1 -1
- package/src/ngtsc/core/api/src/options.d.ts +3 -2
- package/src/ngtsc/core/api/src/public_options.d.ts +38 -0
- package/src/ngtsc/core/src/host.d.ts +2 -1
- package/src/ngtsc/diagnostics/index.d.ts +2 -1
- package/src/ngtsc/diagnostics/src/error.d.ts +1 -0
- package/src/ngtsc/diagnostics/src/error_code.d.ts +7 -0
- package/src/ngtsc/diagnostics/src/error_details_base_url.d.ts +1 -1
- package/src/ngtsc/diagnostics/src/extended_template_diagnostic_name.d.ts +21 -0
- package/src/ngtsc/file_system/src/compiler_host.d.ts +1 -0
- package/src/ngtsc/imports/index.d.ts +1 -1
- package/src/ngtsc/imports/src/emitter.d.ts +40 -8
- package/src/ngtsc/partial_evaluator/src/builtin.d.ts +5 -0
- package/src/ngtsc/program.d.ts +3 -6
- package/src/ngtsc/program_driver/src/ts_create_program_driver.d.ts +2 -1
- package/src/ngtsc/reflection/src/host.d.ts +1 -1
- package/src/ngtsc/translator/src/translator.d.ts +0 -5
- package/src/ngtsc/translator/src/type_translator.d.ts +0 -2
- package/src/ngtsc/typecheck/extended/api/api.d.ts +30 -10
- package/src/ngtsc/typecheck/extended/checks/invalid_banana_in_box/index.d.ts +3 -14
- package/src/ngtsc/typecheck/extended/checks/nullish_coalescing_not_nullable/index.d.ts +3 -15
- package/src/ngtsc/typecheck/extended/index.d.ts +3 -0
- package/src/ngtsc/typecheck/extended/src/extended_template_checker.d.ts +5 -4
- package/src/ngtsc/typecheck/src/environment.d.ts +3 -1
- package/src/ngtsc/typecheck/src/tcb_util.d.ts +10 -2
- package/src/ngtsc/typecheck/src/type_constructor.d.ts +3 -2
- package/src/ngtsc/typecheck/src/type_emitter.d.ts +7 -21
- package/src/ngtsc/typecheck/src/type_parameter_emitter.d.ts +2 -2
- package/src/ngtsc/util/src/typescript.d.ts +5 -0
- package/src/perform_compile.d.ts +5 -10
- package/src/perform_watch.d.ts +4 -4
- package/src/transformers/api.d.ts +3 -30
- package/src/transformers/compiler_host.d.ts +1 -97
- package/src/transformers/program.d.ts +0 -19
- package/src/transformers/util.d.ts +1 -20
- package/src/{diagnostics/typescript_version.d.ts → version_helpers.d.ts} +1 -1
- package/bundles/chunk-2DL256T3.js.map +0 -6
- package/bundles/chunk-ACINBTQB.js +0 -43
- package/bundles/chunk-ACINBTQB.js.map +0 -6
- package/bundles/chunk-BUHTODFL.js.map +0 -6
- package/bundles/chunk-EP5JHXG2.js.map +0 -6
- package/bundles/chunk-JNWO3JB2.js.map +0 -6
- package/bundles/chunk-MIQ5UCHZ.js.map +0 -6
- package/bundles/chunk-PBA67OV4.js.map +0 -6
- package/bundles/chunk-S3QIIFH7.js.map +0 -6
- package/bundles/chunk-VKIZ4TCJ.js.map +0 -6
- package/bundles/chunk-WOC6KEUY.js.map +0 -6
- package/bundles/chunk-WYO7JO2T.js.map +0 -6
- package/ngcc/src/analysis/switch_marker_analyzer.d.ts +0 -35
- package/src/diagnostics/translate_diagnostics.d.ts +0 -18
- package/src/language_services.d.ts +0 -11
- package/src/metadata/bundle_index_host.d.ts +0 -16
- package/src/metadata/bundler.d.ts +0 -66
- package/src/metadata/collector.d.ts +0 -44
- package/src/metadata/evaluator.d.ts +0 -58
- package/src/metadata/index.d.ts +0 -11
- package/src/metadata/index_writer.d.ts +0 -10
- package/src/metadata/schema.d.ts +0 -182
- package/src/metadata/symbols.d.ts +0 -22
- package/src/ngtsc/switch/index.d.ts +0 -9
- package/src/ngtsc/switch/src/switch.d.ts +0 -10
- package/src/transformers/inline_resources.d.ts +0 -26
- package/src/transformers/lower_expressions.d.ts +0 -30
- package/src/transformers/metadata_cache.d.ts +0 -27
- package/src/transformers/metadata_reader.d.ts +0 -19
- package/src/transformers/node_emitter.d.ts +0 -105
- package/src/transformers/node_emitter_transform.d.ts +0 -19
- package/src/transformers/r3_metadata_transform.d.ts +0 -16
- package/src/transformers/r3_transform.d.ts +0 -16
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
MetadataDtsModuleScopeResolver,
|
|
11
11
|
TypeCheckScopeRegistry,
|
|
12
12
|
readConfiguration
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-TUNE6DP3.js";
|
|
14
14
|
import {
|
|
15
15
|
CompilationMode,
|
|
16
16
|
ComponentDecoratorHandler,
|
|
@@ -30,10 +30,8 @@ import {
|
|
|
30
30
|
TraitCompiler,
|
|
31
31
|
TraitState,
|
|
32
32
|
forwardRefResolver,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
replaceTsWithNgInErrors
|
|
36
|
-
} from "./chunk-MIQ5UCHZ.js";
|
|
33
|
+
readBaseClass
|
|
34
|
+
} from "./chunk-FUZ3CSDO.js";
|
|
37
35
|
import {
|
|
38
36
|
ClassMemberKind,
|
|
39
37
|
KnownDeclaration,
|
|
@@ -44,7 +42,7 @@ import {
|
|
|
44
42
|
isNamedFunctionDeclaration,
|
|
45
43
|
isNamedVariableDeclaration,
|
|
46
44
|
reflectObjectLiteral
|
|
47
|
-
} from "./chunk-
|
|
45
|
+
} from "./chunk-7PY7XEFH.js";
|
|
48
46
|
import {
|
|
49
47
|
ConsoleLogger,
|
|
50
48
|
LogLevel
|
|
@@ -52,7 +50,7 @@ import {
|
|
|
52
50
|
import {
|
|
53
51
|
ContentOrigin,
|
|
54
52
|
SourceFileLoader
|
|
55
|
-
} from "./chunk-
|
|
53
|
+
} from "./chunk-ADHVDA4A.js";
|
|
56
54
|
import {
|
|
57
55
|
AbsoluteModuleStrategy,
|
|
58
56
|
ImportManager,
|
|
@@ -66,12 +64,14 @@ import {
|
|
|
66
64
|
ReferenceEmitter,
|
|
67
65
|
isAssignment,
|
|
68
66
|
isDtsPath,
|
|
67
|
+
isFatalDiagnosticError,
|
|
69
68
|
isFromDtsFile,
|
|
70
69
|
isSymbolWithValueDeclaration,
|
|
70
|
+
replaceTsWithNgInErrors,
|
|
71
71
|
translateStatement,
|
|
72
72
|
translateType,
|
|
73
73
|
validateAndRewriteCoreSymbol
|
|
74
|
-
} from "./chunk-
|
|
74
|
+
} from "./chunk-QBU7RUKB.js";
|
|
75
75
|
import {
|
|
76
76
|
LogicalFileSystem,
|
|
77
77
|
NgtscCompilerHost,
|
|
@@ -83,23 +83,23 @@ import {
|
|
|
83
83
|
isRooted,
|
|
84
84
|
relative,
|
|
85
85
|
toRelativeImport
|
|
86
|
-
} from "./chunk-
|
|
86
|
+
} from "./chunk-676MI6WZ.js";
|
|
87
87
|
import {
|
|
88
88
|
NOOP_PERF_RECORDER
|
|
89
89
|
} from "./chunk-GLCRIILX.js";
|
|
90
90
|
import {
|
|
91
91
|
__spreadProps,
|
|
92
92
|
__spreadValues
|
|
93
|
-
} from "./chunk-
|
|
93
|
+
} from "./chunk-WQ3TNYTD.js";
|
|
94
94
|
|
|
95
95
|
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/ngcc/src/execution/create_compile_function.mjs
|
|
96
|
-
import
|
|
96
|
+
import ts22 from "typescript";
|
|
97
97
|
|
|
98
98
|
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/ngcc/src/packages/entry_point.mjs
|
|
99
|
-
import
|
|
99
|
+
import ts7 from "typescript";
|
|
100
100
|
|
|
101
101
|
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/ngcc/src/host/umd_host.mjs
|
|
102
|
-
import
|
|
102
|
+
import ts6 from "typescript";
|
|
103
103
|
|
|
104
104
|
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/ngcc/src/utils.mjs
|
|
105
105
|
import ts from "typescript";
|
|
@@ -109,18 +109,6 @@ function isDefined(value) {
|
|
|
109
109
|
function getNameText(name) {
|
|
110
110
|
return ts.isIdentifier(name) || ts.isLiteralExpression(name) ? name.text : name.getText();
|
|
111
111
|
}
|
|
112
|
-
function findAll(node, test) {
|
|
113
|
-
const nodes = [];
|
|
114
|
-
findAllVisitor(node);
|
|
115
|
-
return nodes;
|
|
116
|
-
function findAllVisitor(n) {
|
|
117
|
-
if (test(n)) {
|
|
118
|
-
nodes.push(n);
|
|
119
|
-
} else {
|
|
120
|
-
n.forEachChild((child) => findAllVisitor(child));
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
112
|
function hasNameIdentifier(declaration) {
|
|
125
113
|
const namedDeclaration = declaration;
|
|
126
114
|
return namedDeclaration.name !== void 0 && ts.isIdentifier(namedDeclaration.name);
|
|
@@ -271,7 +259,7 @@ function skipAliases(node) {
|
|
|
271
259
|
}
|
|
272
260
|
|
|
273
261
|
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/ngcc/src/host/esm2015_host.mjs
|
|
274
|
-
import
|
|
262
|
+
import ts4 from "typescript";
|
|
275
263
|
|
|
276
264
|
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/ngcc/src/analysis/util.mjs
|
|
277
265
|
function isWithinPackage(packagePath, filePath) {
|
|
@@ -288,18 +276,10 @@ var NoopDependencyTracker = class {
|
|
|
288
276
|
};
|
|
289
277
|
var NOOP_DEPENDENCY_TRACKER = new NoopDependencyTracker();
|
|
290
278
|
|
|
291
|
-
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/ngcc/src/host/ngcc_host.mjs
|
|
292
|
-
import ts3 from "typescript";
|
|
293
|
-
var PRE_R3_MARKER = "__PRE_R3__";
|
|
294
|
-
var POST_R3_MARKER = "__POST_R3__";
|
|
295
|
-
function isSwitchableVariableDeclaration(node) {
|
|
296
|
-
return ts3.isVariableDeclaration(node) && !!node.initializer && ts3.isIdentifier(node.initializer) && node.initializer.text.endsWith(PRE_R3_MARKER);
|
|
297
|
-
}
|
|
298
|
-
|
|
299
279
|
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/ngcc/src/host/utils.mjs
|
|
300
|
-
import
|
|
280
|
+
import ts3 from "typescript";
|
|
301
281
|
function stripParentheses(node) {
|
|
302
|
-
return
|
|
282
|
+
return ts3.isParenthesizedExpression(node) ? node.expression : node;
|
|
303
283
|
}
|
|
304
284
|
|
|
305
285
|
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/ngcc/src/host/esm2015_host.mjs
|
|
@@ -316,9 +296,9 @@ var Esm2015ReflectionHost = class extends TypeScriptReflectionHost {
|
|
|
316
296
|
this.dts = dts;
|
|
317
297
|
this.publicDtsDeclarationMap = null;
|
|
318
298
|
this.privateDtsDeclarationMap = null;
|
|
319
|
-
this.preprocessedSourceFiles = new Set();
|
|
320
|
-
this.aliasedClassDeclarations = new Map();
|
|
321
|
-
this.decoratorCache = new Map();
|
|
299
|
+
this.preprocessedSourceFiles = /* @__PURE__ */ new Set();
|
|
300
|
+
this.aliasedClassDeclarations = /* @__PURE__ */ new Map();
|
|
301
|
+
this.decoratorCache = /* @__PURE__ */ new Map();
|
|
322
302
|
}
|
|
323
303
|
getClassSymbol(declaration) {
|
|
324
304
|
const symbol = this.getClassSymbolFromOuterDeclaration(declaration);
|
|
@@ -402,7 +382,7 @@ ${declaration.getText()}`);
|
|
|
402
382
|
let declarationNode = superDeclaration.node;
|
|
403
383
|
if (isNamedVariableDeclaration(superDeclaration.node) && !isTopLevel(superDeclaration.node)) {
|
|
404
384
|
const variableValue = this.getVariableValue(superDeclaration.node);
|
|
405
|
-
if (variableValue !== null &&
|
|
385
|
+
if (variableValue !== null && ts4.isClassExpression(variableValue)) {
|
|
406
386
|
declarationNode = getContainingStatement(variableValue);
|
|
407
387
|
}
|
|
408
388
|
}
|
|
@@ -415,7 +395,7 @@ ${declaration.getText()}`);
|
|
|
415
395
|
if (aliasedIdentifier !== null) {
|
|
416
396
|
return this.getDeclarationOfIdentifier(aliasedIdentifier);
|
|
417
397
|
}
|
|
418
|
-
if (isConcreteDeclaration(declaration) &&
|
|
398
|
+
if (isConcreteDeclaration(declaration) && ts4.isVariableDeclaration(declaration.node)) {
|
|
419
399
|
const enumMembers = this.resolveEnumMembers(declaration.node);
|
|
420
400
|
if (enumMembers !== null) {
|
|
421
401
|
declaration.identity = { kind: 0, enumMembers };
|
|
@@ -430,9 +410,6 @@ ${declaration.getText()}`);
|
|
|
430
410
|
}
|
|
431
411
|
return Array.from(classDecorators);
|
|
432
412
|
}
|
|
433
|
-
getSwitchableDeclarations(module) {
|
|
434
|
-
return module.getText().indexOf(PRE_R3_MARKER) >= 0 ? findAll(module, isSwitchableVariableDeclaration) : [];
|
|
435
|
-
}
|
|
436
413
|
getVariableValue(declaration) {
|
|
437
414
|
const value = super.getVariableValue(declaration);
|
|
438
415
|
if (value) {
|
|
@@ -440,16 +417,16 @@ ${declaration.getText()}`);
|
|
|
440
417
|
}
|
|
441
418
|
const block = declaration.parent.parent.parent;
|
|
442
419
|
const symbol = this.checker.getSymbolAtLocation(declaration.name);
|
|
443
|
-
if (symbol && (
|
|
420
|
+
if (symbol && (ts4.isBlock(block) || ts4.isSourceFile(block))) {
|
|
444
421
|
const decorateCall = this.findDecoratedVariableValue(block, symbol);
|
|
445
422
|
const target = decorateCall && decorateCall.arguments[1];
|
|
446
|
-
if (target &&
|
|
423
|
+
if (target && ts4.isIdentifier(target)) {
|
|
447
424
|
const targetSymbol = this.checker.getSymbolAtLocation(target);
|
|
448
425
|
const targetDeclaration = targetSymbol && targetSymbol.valueDeclaration;
|
|
449
426
|
if (targetDeclaration) {
|
|
450
|
-
if (
|
|
427
|
+
if (ts4.isClassDeclaration(targetDeclaration) || ts4.isFunctionDeclaration(targetDeclaration)) {
|
|
451
428
|
return targetDeclaration.name || null;
|
|
452
|
-
} else if (
|
|
429
|
+
} else if (ts4.isVariableDeclaration(targetDeclaration)) {
|
|
453
430
|
let targetValue = targetDeclaration.initializer;
|
|
454
431
|
while (targetValue && isAssignment2(targetValue)) {
|
|
455
432
|
targetValue = targetValue.right;
|
|
@@ -464,13 +441,13 @@ ${declaration.getText()}`);
|
|
|
464
441
|
return null;
|
|
465
442
|
}
|
|
466
443
|
findClassSymbols(sourceFile) {
|
|
467
|
-
const classes = new Map();
|
|
444
|
+
const classes = /* @__PURE__ */ new Map();
|
|
468
445
|
this.getModuleStatements(sourceFile).forEach((statement) => this.addClassSymbolsFromStatement(classes, statement));
|
|
469
446
|
return Array.from(classes.values());
|
|
470
447
|
}
|
|
471
448
|
getGenericArityOfClass(clazz) {
|
|
472
449
|
const dtsDeclaration = this.getDtsDeclaration(clazz);
|
|
473
|
-
if (dtsDeclaration &&
|
|
450
|
+
if (dtsDeclaration && ts4.isClassDeclaration(dtsDeclaration)) {
|
|
474
451
|
return dtsDeclaration.typeParameters ? dtsDeclaration.typeParameters.length : 0;
|
|
475
452
|
}
|
|
476
453
|
return null;
|
|
@@ -507,13 +484,13 @@ ${declaration.getText()}`);
|
|
|
507
484
|
if (implementationStatement === null)
|
|
508
485
|
return last;
|
|
509
486
|
const container = implementationStatement.parent;
|
|
510
|
-
if (
|
|
511
|
-
const returnStatementIndex = container.statements.findIndex(
|
|
487
|
+
if (ts4.isBlock(container)) {
|
|
488
|
+
const returnStatementIndex = container.statements.findIndex(ts4.isReturnStatement);
|
|
512
489
|
if (returnStatementIndex === -1) {
|
|
513
490
|
throw new Error(`Compiled class wrapper IIFE does not have a return statement: ${classSymbol.name} in ${classSymbol.declaration.valueDeclaration.getSourceFile().fileName}`);
|
|
514
491
|
}
|
|
515
492
|
last = container.statements[returnStatementIndex - 1];
|
|
516
|
-
} else if (
|
|
493
|
+
} else if (ts4.isSourceFile(container)) {
|
|
517
494
|
if (implementation.exports !== void 0) {
|
|
518
495
|
implementation.exports.forEach((exportSymbol) => {
|
|
519
496
|
if (exportSymbol.valueDeclaration === void 0) {
|
|
@@ -542,14 +519,14 @@ ${declaration.getText()}`);
|
|
|
542
519
|
return decl;
|
|
543
520
|
}
|
|
544
521
|
addClassSymbolsFromStatement(classes, statement) {
|
|
545
|
-
if (
|
|
522
|
+
if (ts4.isVariableStatement(statement)) {
|
|
546
523
|
statement.declarationList.declarations.forEach((declaration) => {
|
|
547
524
|
const classSymbol = this.getClassSymbol(declaration);
|
|
548
525
|
if (classSymbol) {
|
|
549
526
|
classes.set(classSymbol.implementation, classSymbol);
|
|
550
527
|
}
|
|
551
528
|
});
|
|
552
|
-
} else if (
|
|
529
|
+
} else if (ts4.isClassDeclaration(statement)) {
|
|
553
530
|
const classSymbol = this.getClassSymbol(statement);
|
|
554
531
|
if (classSymbol) {
|
|
555
532
|
classes.set(classSymbol.implementation, classSymbol);
|
|
@@ -580,7 +557,7 @@ ${declaration.getText()}`);
|
|
|
580
557
|
}
|
|
581
558
|
getClassSymbolFromInnerDeclaration(declaration) {
|
|
582
559
|
let outerDeclaration = void 0;
|
|
583
|
-
if (
|
|
560
|
+
if (ts4.isClassExpression(declaration) && hasNameIdentifier(declaration)) {
|
|
584
561
|
outerDeclaration = getFarLeftHandSideOfAssignment(declaration);
|
|
585
562
|
if (outerDeclaration !== void 0 && !isTopLevel(outerDeclaration)) {
|
|
586
563
|
outerDeclaration = getContainingVariableDeclaration(outerDeclaration);
|
|
@@ -622,7 +599,7 @@ ${declaration.getText()}`);
|
|
|
622
599
|
return void 0;
|
|
623
600
|
}
|
|
624
601
|
const innerDeclaration = implementationSymbol.valueDeclaration;
|
|
625
|
-
if (!
|
|
602
|
+
if (!ts4.isClassExpression(innerDeclaration) && !ts4.isFunctionExpression(innerDeclaration)) {
|
|
626
603
|
return void 0;
|
|
627
604
|
}
|
|
628
605
|
const adjacentDeclaration = getFarLeftHandSideOfAssignment(innerDeclaration);
|
|
@@ -655,7 +632,7 @@ ${declaration.getText()}`);
|
|
|
655
632
|
}
|
|
656
633
|
}
|
|
657
634
|
preprocessStatement(statement) {
|
|
658
|
-
if (!
|
|
635
|
+
if (!ts4.isVariableStatement(statement)) {
|
|
659
636
|
return;
|
|
660
637
|
}
|
|
661
638
|
const declarations = statement.declarationList.declarations;
|
|
@@ -664,7 +641,7 @@ ${declaration.getText()}`);
|
|
|
664
641
|
}
|
|
665
642
|
const declaration = declarations[0];
|
|
666
643
|
const initializer = declaration.initializer;
|
|
667
|
-
if (!
|
|
644
|
+
if (!ts4.isIdentifier(declaration.name) || !initializer || !isAssignment2(initializer) || !ts4.isIdentifier(initializer.left) || !this.isClass(declaration)) {
|
|
668
645
|
return;
|
|
669
646
|
}
|
|
670
647
|
const aliasedIdentifier = initializer.left;
|
|
@@ -681,11 +658,11 @@ ${declaration.getText()}`);
|
|
|
681
658
|
if (!node) {
|
|
682
659
|
return null;
|
|
683
660
|
}
|
|
684
|
-
if (
|
|
661
|
+
if (ts4.isBinaryExpression(node) && node.operatorToken.kind === ts4.SyntaxKind.EqualsToken) {
|
|
685
662
|
const left = node.left;
|
|
686
663
|
const right = node.right;
|
|
687
|
-
if (
|
|
688
|
-
return
|
|
664
|
+
if (ts4.isIdentifier(left) && this.checker.getSymbolAtLocation(left) === symbol) {
|
|
665
|
+
return ts4.isCallExpression(right) && getCalleeName(right) === "__decorate" ? right : null;
|
|
689
666
|
}
|
|
690
667
|
return this.findDecoratedVariableValue(right, symbol);
|
|
691
668
|
}
|
|
@@ -731,7 +708,7 @@ ${declaration.getText()}`);
|
|
|
731
708
|
getClassDecoratorsFromStaticProperty(decoratorsSymbol) {
|
|
732
709
|
const decoratorsIdentifier = decoratorsSymbol.valueDeclaration;
|
|
733
710
|
if (decoratorsIdentifier && decoratorsIdentifier.parent) {
|
|
734
|
-
if (
|
|
711
|
+
if (ts4.isBinaryExpression(decoratorsIdentifier.parent) && decoratorsIdentifier.parent.operatorToken.kind === ts4.SyntaxKind.EqualsToken) {
|
|
735
712
|
const decoratorsArray = decoratorsIdentifier.parent.right;
|
|
736
713
|
return this.reflectDecorators(decoratorsArray).filter((decorator) => this.isFromCore(decorator));
|
|
737
714
|
}
|
|
@@ -762,7 +739,7 @@ ${declaration.getText()}`);
|
|
|
762
739
|
}
|
|
763
740
|
});
|
|
764
741
|
}
|
|
765
|
-
if (
|
|
742
|
+
if (ts4.isVariableDeclaration(symbol.declaration.valueDeclaration)) {
|
|
766
743
|
if (symbol.declaration.exports) {
|
|
767
744
|
symbol.declaration.exports.forEach((value, key) => {
|
|
768
745
|
const decorators = decoratorsMap.get(key);
|
|
@@ -775,7 +752,7 @@ ${declaration.getText()}`);
|
|
|
775
752
|
}
|
|
776
753
|
}
|
|
777
754
|
if (symbol.adjacent !== void 0) {
|
|
778
|
-
if (
|
|
755
|
+
if (ts4.isVariableDeclaration(symbol.adjacent.valueDeclaration)) {
|
|
779
756
|
if (symbol.adjacent.exports !== void 0) {
|
|
780
757
|
symbol.adjacent.exports.forEach((value, key) => {
|
|
781
758
|
const decorators = decoratorsMap.get(key);
|
|
@@ -804,9 +781,9 @@ ${declaration.getText()}`);
|
|
|
804
781
|
return members;
|
|
805
782
|
}
|
|
806
783
|
getMemberDecoratorsFromStaticProperty(decoratorsProperty) {
|
|
807
|
-
const memberDecorators = new Map();
|
|
784
|
+
const memberDecorators = /* @__PURE__ */ new Map();
|
|
808
785
|
const propDecoratorsMap = getPropertyValueFromSymbol(decoratorsProperty);
|
|
809
|
-
if (propDecoratorsMap &&
|
|
786
|
+
if (propDecoratorsMap && ts4.isObjectLiteralExpression(propDecoratorsMap)) {
|
|
810
787
|
const propertiesMap = reflectObjectLiteral(propDecoratorsMap);
|
|
811
788
|
propertiesMap.forEach((value, name) => {
|
|
812
789
|
const decorators = this.reflectDecorators(value).filter((decorator) => this.isFromCore(decorator));
|
|
@@ -819,7 +796,7 @@ ${declaration.getText()}`);
|
|
|
819
796
|
}
|
|
820
797
|
computeDecoratorInfoFromHelperCalls(classSymbol) {
|
|
821
798
|
let classDecorators = null;
|
|
822
|
-
const memberDecorators = new Map();
|
|
799
|
+
const memberDecorators = /* @__PURE__ */ new Map();
|
|
823
800
|
const constructorParamInfo = [];
|
|
824
801
|
const getConstructorParamInfo = (index) => {
|
|
825
802
|
let param = constructorParamInfo[index];
|
|
@@ -877,18 +854,18 @@ ${declaration.getText()}`);
|
|
|
877
854
|
return { classDecorators, memberDecorators, constructorParamInfo };
|
|
878
855
|
}
|
|
879
856
|
reflectDecorateHelperEntry(expression) {
|
|
880
|
-
if (!
|
|
857
|
+
if (!ts4.isCallExpression(expression)) {
|
|
881
858
|
return null;
|
|
882
859
|
}
|
|
883
860
|
const call = expression;
|
|
884
861
|
const helperName = getCalleeName(call);
|
|
885
862
|
if (helperName === "__metadata") {
|
|
886
863
|
const key = call.arguments[0];
|
|
887
|
-
if (key === void 0 || !
|
|
864
|
+
if (key === void 0 || !ts4.isStringLiteral(key) || key.text !== "design:paramtypes") {
|
|
888
865
|
return null;
|
|
889
866
|
}
|
|
890
867
|
const value = call.arguments[1];
|
|
891
|
-
if (value === void 0 || !
|
|
868
|
+
if (value === void 0 || !ts4.isArrayLiteralExpression(value)) {
|
|
892
869
|
return null;
|
|
893
870
|
}
|
|
894
871
|
return {
|
|
@@ -898,12 +875,12 @@ ${declaration.getText()}`);
|
|
|
898
875
|
}
|
|
899
876
|
if (helperName === "__param") {
|
|
900
877
|
const indexArg = call.arguments[0];
|
|
901
|
-
const index = indexArg &&
|
|
878
|
+
const index = indexArg && ts4.isNumericLiteral(indexArg) ? parseInt(indexArg.text, 10) : NaN;
|
|
902
879
|
if (isNaN(index)) {
|
|
903
880
|
return null;
|
|
904
881
|
}
|
|
905
882
|
const decoratorCall = call.arguments[1];
|
|
906
|
-
if (decoratorCall === void 0 || !
|
|
883
|
+
if (decoratorCall === void 0 || !ts4.isCallExpression(decoratorCall)) {
|
|
907
884
|
return null;
|
|
908
885
|
}
|
|
909
886
|
const decorator2 = this.reflectDecoratorCall(decoratorCall);
|
|
@@ -930,7 +907,7 @@ ${declaration.getText()}`);
|
|
|
930
907
|
if (!isDecoratorIdentifier(decoratorExpression)) {
|
|
931
908
|
return null;
|
|
932
909
|
}
|
|
933
|
-
const decoratorIdentifier =
|
|
910
|
+
const decoratorIdentifier = ts4.isIdentifier(decoratorExpression) ? decoratorExpression : decoratorExpression.name;
|
|
934
911
|
return {
|
|
935
912
|
name: decoratorIdentifier.text,
|
|
936
913
|
identifier: decoratorExpression,
|
|
@@ -940,12 +917,12 @@ ${declaration.getText()}`);
|
|
|
940
917
|
};
|
|
941
918
|
}
|
|
942
919
|
getHelperCall(statement, helperNames) {
|
|
943
|
-
if ((
|
|
920
|
+
if ((ts4.isExpressionStatement(statement) || ts4.isReturnStatement(statement)) && statement.expression) {
|
|
944
921
|
let expression = statement.expression;
|
|
945
922
|
while (isAssignment2(expression)) {
|
|
946
923
|
expression = expression.right;
|
|
947
924
|
}
|
|
948
|
-
if (
|
|
925
|
+
if (ts4.isCallExpression(expression)) {
|
|
949
926
|
const calleeName = getCalleeName(expression);
|
|
950
927
|
if (calleeName !== null && helperNames.includes(calleeName)) {
|
|
951
928
|
return expression;
|
|
@@ -956,14 +933,14 @@ ${declaration.getText()}`);
|
|
|
956
933
|
}
|
|
957
934
|
reflectDecorators(decoratorsArray) {
|
|
958
935
|
const decorators = [];
|
|
959
|
-
if (
|
|
936
|
+
if (ts4.isArrayLiteralExpression(decoratorsArray)) {
|
|
960
937
|
decoratorsArray.elements.forEach((node) => {
|
|
961
|
-
if (
|
|
938
|
+
if (ts4.isObjectLiteralExpression(node)) {
|
|
962
939
|
const decorator = reflectObjectLiteral(node);
|
|
963
940
|
if (decorator.has("type")) {
|
|
964
941
|
let decoratorType = decorator.get("type");
|
|
965
942
|
if (isDecoratorIdentifier(decoratorType)) {
|
|
966
|
-
const decoratorIdentifier =
|
|
943
|
+
const decoratorIdentifier = ts4.isIdentifier(decoratorType) ? decoratorType : decoratorType.name;
|
|
967
944
|
decorators.push({
|
|
968
945
|
name: decoratorIdentifier.text,
|
|
969
946
|
identifier: decoratorType,
|
|
@@ -979,10 +956,10 @@ ${declaration.getText()}`);
|
|
|
979
956
|
return decorators;
|
|
980
957
|
}
|
|
981
958
|
reflectMembers(symbol, decorators, isStatic) {
|
|
982
|
-
if (symbol.flags &
|
|
959
|
+
if (symbol.flags & ts4.SymbolFlags.Accessor) {
|
|
983
960
|
const members = [];
|
|
984
|
-
const setter = symbol.declarations && symbol.declarations.find(
|
|
985
|
-
const getter = symbol.declarations && symbol.declarations.find(
|
|
961
|
+
const setter = symbol.declarations && symbol.declarations.find(ts4.isSetAccessor);
|
|
962
|
+
const getter = symbol.declarations && symbol.declarations.find(ts4.isGetAccessor);
|
|
986
963
|
const setterMember = setter && this.reflectMember(setter, ClassMemberKind.Setter, decorators, isStatic);
|
|
987
964
|
if (setterMember) {
|
|
988
965
|
members.push(setterMember);
|
|
@@ -995,9 +972,9 @@ ${declaration.getText()}`);
|
|
|
995
972
|
return members;
|
|
996
973
|
}
|
|
997
974
|
let kind = null;
|
|
998
|
-
if (symbol.flags &
|
|
975
|
+
if (symbol.flags & ts4.SymbolFlags.Method) {
|
|
999
976
|
kind = ClassMemberKind.Method;
|
|
1000
|
-
} else if (symbol.flags &
|
|
977
|
+
} else if (symbol.flags & ts4.SymbolFlags.Property) {
|
|
1001
978
|
kind = ClassMemberKind.Property;
|
|
1002
979
|
}
|
|
1003
980
|
const node = symbol.valueDeclaration || symbol.declarations && symbol.declarations[0];
|
|
@@ -1025,7 +1002,7 @@ ${declaration.getText()}`);
|
|
|
1025
1002
|
name = node.left.name.text;
|
|
1026
1003
|
value = node.right;
|
|
1027
1004
|
isStatic = false;
|
|
1028
|
-
} else if (
|
|
1005
|
+
} else if (ts4.isConstructorDeclaration(node)) {
|
|
1029
1006
|
kind = ClassMemberKind.Constructor;
|
|
1030
1007
|
name = "constructor";
|
|
1031
1008
|
isStatic = false;
|
|
@@ -1043,7 +1020,7 @@ ${declaration.getText()}`);
|
|
|
1043
1020
|
}
|
|
1044
1021
|
}
|
|
1045
1022
|
if (isStatic === void 0) {
|
|
1046
|
-
isStatic = node.modifiers !== void 0 && node.modifiers.some((mod) => mod.kind ===
|
|
1023
|
+
isStatic = node.modifiers !== void 0 && node.modifiers.some((mod) => mod.kind === ts4.SyntaxKind.StaticKeyword);
|
|
1047
1024
|
}
|
|
1048
1025
|
const type = node.type || null;
|
|
1049
1026
|
return {
|
|
@@ -1116,9 +1093,9 @@ ${declaration.getText()}`);
|
|
|
1116
1093
|
};
|
|
1117
1094
|
}
|
|
1118
1095
|
getImportOfExpression(expression) {
|
|
1119
|
-
if (
|
|
1096
|
+
if (ts4.isIdentifier(expression)) {
|
|
1120
1097
|
return this.getImportOfIdentifier(expression);
|
|
1121
|
-
} else if (
|
|
1098
|
+
} else if (ts4.isPropertyAccessExpression(expression) && ts4.isIdentifier(expression.name)) {
|
|
1122
1099
|
return this.getImportOfIdentifier(expression.name);
|
|
1123
1100
|
} else {
|
|
1124
1101
|
return null;
|
|
@@ -1127,10 +1104,10 @@ ${declaration.getText()}`);
|
|
|
1127
1104
|
getParamInfoFromStaticProperty(paramDecoratorsProperty) {
|
|
1128
1105
|
const paramDecorators = getPropertyValueFromSymbol(paramDecoratorsProperty);
|
|
1129
1106
|
if (paramDecorators) {
|
|
1130
|
-
const container =
|
|
1131
|
-
if (
|
|
1107
|
+
const container = ts4.isArrowFunction(paramDecorators) ? paramDecorators.body : paramDecorators;
|
|
1108
|
+
if (ts4.isArrayLiteralExpression(container)) {
|
|
1132
1109
|
const elements = container.elements;
|
|
1133
|
-
return elements.map((element) =>
|
|
1110
|
+
return elements.map((element) => ts4.isObjectLiteralExpression(element) ? reflectObjectLiteral(element) : null).map((paramInfo) => {
|
|
1134
1111
|
const typeExpression = paramInfo && paramInfo.has("type") ? paramInfo.get("type") : null;
|
|
1135
1112
|
const decoratorInfo = paramInfo && paramInfo.has("decorators") ? paramInfo.get("decorators") : null;
|
|
1136
1113
|
const decorators = decoratorInfo && this.reflectDecorators(decoratorInfo).filter((decorator) => this.isFromCore(decorator));
|
|
@@ -1151,7 +1128,7 @@ ${declaration.getText()}`);
|
|
|
1151
1128
|
return this.getModuleStatements(classNode.getSourceFile());
|
|
1152
1129
|
}
|
|
1153
1130
|
const statement = getContainingStatement(classNode);
|
|
1154
|
-
if (
|
|
1131
|
+
if (ts4.isBlock(statement.parent)) {
|
|
1155
1132
|
return Array.from(statement.parent.statements);
|
|
1156
1133
|
}
|
|
1157
1134
|
throw new Error(`Unable to find adjacent statements for ${classSymbol.name}`);
|
|
@@ -1164,8 +1141,8 @@ ${declaration.getText()}`);
|
|
|
1164
1141
|
}
|
|
1165
1142
|
}
|
|
1166
1143
|
computePublicDtsDeclarationMap(src, dts) {
|
|
1167
|
-
const declarationMap = new Map();
|
|
1168
|
-
const dtsDeclarationMap = new Map();
|
|
1144
|
+
const declarationMap = /* @__PURE__ */ new Map();
|
|
1145
|
+
const dtsDeclarationMap = /* @__PURE__ */ new Map();
|
|
1169
1146
|
const rootDts = getRootFileOrFail(dts);
|
|
1170
1147
|
this.collectDtsExportedDeclarations(dtsDeclarationMap, rootDts, dts.program.getTypeChecker());
|
|
1171
1148
|
const rootSrc = getRootFileOrFail(src);
|
|
@@ -1173,8 +1150,8 @@ ${declaration.getText()}`);
|
|
|
1173
1150
|
return declarationMap;
|
|
1174
1151
|
}
|
|
1175
1152
|
computePrivateDtsDeclarationMap(src, dts) {
|
|
1176
|
-
const declarationMap = new Map();
|
|
1177
|
-
const dtsDeclarationMap = new Map();
|
|
1153
|
+
const declarationMap = /* @__PURE__ */ new Map();
|
|
1154
|
+
const dtsDeclarationMap = /* @__PURE__ */ new Map();
|
|
1178
1155
|
const typeChecker = dts.program.getTypeChecker();
|
|
1179
1156
|
const dtsFiles = getNonRootPackageFiles(dts);
|
|
1180
1157
|
for (const dtsFile of dtsFiles) {
|
|
@@ -1192,7 +1169,7 @@ ${declaration.getText()}`);
|
|
|
1192
1169
|
if (moduleExports) {
|
|
1193
1170
|
moduleExports.forEach((exportedSymbol) => {
|
|
1194
1171
|
const name = exportedSymbol.name;
|
|
1195
|
-
if (exportedSymbol.flags &
|
|
1172
|
+
if (exportedSymbol.flags & ts4.SymbolFlags.Alias) {
|
|
1196
1173
|
exportedSymbol = checker.getAliasedSymbol(exportedSymbol);
|
|
1197
1174
|
}
|
|
1198
1175
|
const declaration = exportedSymbol.valueDeclaration;
|
|
@@ -1213,14 +1190,14 @@ ${declaration.getText()}`);
|
|
|
1213
1190
|
}
|
|
1214
1191
|
}
|
|
1215
1192
|
getDeclarationOfExpression(expression) {
|
|
1216
|
-
if (
|
|
1193
|
+
if (ts4.isIdentifier(expression)) {
|
|
1217
1194
|
return this.getDeclarationOfIdentifier(expression);
|
|
1218
1195
|
}
|
|
1219
|
-
if (!
|
|
1196
|
+
if (!ts4.isPropertyAccessExpression(expression) || !ts4.isIdentifier(expression.expression)) {
|
|
1220
1197
|
return null;
|
|
1221
1198
|
}
|
|
1222
1199
|
const namespaceDecl = this.getDeclarationOfIdentifier(expression.expression);
|
|
1223
|
-
if (!namespaceDecl || !
|
|
1200
|
+
if (!namespaceDecl || !ts4.isSourceFile(namespaceDecl.node)) {
|
|
1224
1201
|
return null;
|
|
1225
1202
|
}
|
|
1226
1203
|
const namespaceExports = this.getExportsOfModule(namespaceDecl.node);
|
|
@@ -1235,11 +1212,11 @@ ${declaration.getText()}`);
|
|
|
1235
1212
|
}
|
|
1236
1213
|
isJavaScriptObjectDeclaration(decl) {
|
|
1237
1214
|
const node = decl.node;
|
|
1238
|
-
if (!
|
|
1215
|
+
if (!ts4.isVariableDeclaration(node) || !ts4.isIdentifier(node.name) || node.name.text !== "Object" || node.type === void 0) {
|
|
1239
1216
|
return false;
|
|
1240
1217
|
}
|
|
1241
1218
|
const typeNode = node.type;
|
|
1242
|
-
if (!
|
|
1219
|
+
if (!ts4.isTypeReferenceNode(typeNode) || !ts4.isIdentifier(typeNode.typeName) || typeNode.typeName.text !== "ObjectConstructor") {
|
|
1243
1220
|
return false;
|
|
1244
1221
|
}
|
|
1245
1222
|
return this.src.program.isSourceFileDefaultLibrary(node.getSourceFile());
|
|
@@ -1248,22 +1225,22 @@ ${declaration.getText()}`);
|
|
|
1248
1225
|
if (declaration.initializer !== void 0)
|
|
1249
1226
|
return null;
|
|
1250
1227
|
const variableStmt = declaration.parent.parent;
|
|
1251
|
-
if (!
|
|
1228
|
+
if (!ts4.isVariableStatement(variableStmt))
|
|
1252
1229
|
return null;
|
|
1253
1230
|
const block = variableStmt.parent;
|
|
1254
|
-
if (!
|
|
1231
|
+
if (!ts4.isBlock(block) && !ts4.isSourceFile(block))
|
|
1255
1232
|
return null;
|
|
1256
1233
|
const declarationIndex = block.statements.findIndex((statement) => statement === variableStmt);
|
|
1257
1234
|
if (declarationIndex === -1 || declarationIndex === block.statements.length - 1)
|
|
1258
1235
|
return null;
|
|
1259
1236
|
const subsequentStmt = block.statements[declarationIndex + 1];
|
|
1260
|
-
if (!
|
|
1237
|
+
if (!ts4.isExpressionStatement(subsequentStmt))
|
|
1261
1238
|
return null;
|
|
1262
1239
|
const iife = stripParentheses(subsequentStmt.expression);
|
|
1263
|
-
if (!
|
|
1240
|
+
if (!ts4.isCallExpression(iife) || !isEnumDeclarationIife(iife))
|
|
1264
1241
|
return null;
|
|
1265
1242
|
const fn = stripParentheses(iife.expression);
|
|
1266
|
-
if (!
|
|
1243
|
+
if (!ts4.isFunctionExpression(fn))
|
|
1267
1244
|
return null;
|
|
1268
1245
|
return this.reflectEnumMembers(fn);
|
|
1269
1246
|
}
|
|
@@ -1271,7 +1248,7 @@ ${declaration.getText()}`);
|
|
|
1271
1248
|
if (fn.parameters.length !== 1)
|
|
1272
1249
|
return null;
|
|
1273
1250
|
const enumName = fn.parameters[0].name;
|
|
1274
|
-
if (!
|
|
1251
|
+
if (!ts4.isIdentifier(enumName))
|
|
1275
1252
|
return null;
|
|
1276
1253
|
const enumMembers = [];
|
|
1277
1254
|
for (const statement of fn.body.statements) {
|
|
@@ -1284,7 +1261,7 @@ ${declaration.getText()}`);
|
|
|
1284
1261
|
return enumMembers;
|
|
1285
1262
|
}
|
|
1286
1263
|
reflectEnumMember(enumName, statement) {
|
|
1287
|
-
if (!
|
|
1264
|
+
if (!ts4.isExpressionStatement(statement))
|
|
1288
1265
|
return null;
|
|
1289
1266
|
const expression = statement.expression;
|
|
1290
1267
|
if (!isEnumAssignment(enumName, expression)) {
|
|
@@ -1312,78 +1289,78 @@ function isEnumDeclarationIife(iife) {
|
|
|
1312
1289
|
if (iife.arguments.length !== 1)
|
|
1313
1290
|
return false;
|
|
1314
1291
|
const arg = iife.arguments[0];
|
|
1315
|
-
if (!
|
|
1292
|
+
if (!ts4.isBinaryExpression(arg) || arg.operatorToken.kind !== ts4.SyntaxKind.BarBarToken || !ts4.isParenthesizedExpression(arg.right)) {
|
|
1316
1293
|
return false;
|
|
1317
1294
|
}
|
|
1318
1295
|
const right = arg.right.expression;
|
|
1319
|
-
if (!
|
|
1296
|
+
if (!ts4.isBinaryExpression(right) || right.operatorToken.kind !== ts4.SyntaxKind.EqualsToken) {
|
|
1320
1297
|
return false;
|
|
1321
1298
|
}
|
|
1322
|
-
if (!
|
|
1299
|
+
if (!ts4.isObjectLiteralExpression(right.right) || right.right.properties.length !== 0) {
|
|
1323
1300
|
return false;
|
|
1324
1301
|
}
|
|
1325
1302
|
return true;
|
|
1326
1303
|
}
|
|
1327
1304
|
function isEnumAssignment(enumName, expression) {
|
|
1328
|
-
if (!
|
|
1305
|
+
if (!ts4.isBinaryExpression(expression) || expression.operatorToken.kind !== ts4.SyntaxKind.EqualsToken || !ts4.isElementAccessExpression(expression.left)) {
|
|
1329
1306
|
return false;
|
|
1330
1307
|
}
|
|
1331
1308
|
const enumIdentifier = expression.left.expression;
|
|
1332
|
-
return
|
|
1309
|
+
return ts4.isIdentifier(enumIdentifier) && enumIdentifier.text === enumName.text;
|
|
1333
1310
|
}
|
|
1334
1311
|
function reflectEnumAssignment(expression) {
|
|
1335
1312
|
const memberName = expression.left.argumentExpression;
|
|
1336
|
-
if (!
|
|
1313
|
+
if (!ts4.isPropertyName(memberName))
|
|
1337
1314
|
return null;
|
|
1338
1315
|
return { name: memberName, initializer: expression.right };
|
|
1339
1316
|
}
|
|
1340
1317
|
function isAssignmentStatement(statement) {
|
|
1341
|
-
return
|
|
1318
|
+
return ts4.isExpressionStatement(statement) && isAssignment2(statement.expression) && ts4.isIdentifier(statement.expression.left);
|
|
1342
1319
|
}
|
|
1343
1320
|
function getIifeBody(expression) {
|
|
1344
1321
|
const call = stripParentheses(expression);
|
|
1345
|
-
if (!
|
|
1322
|
+
if (!ts4.isCallExpression(call)) {
|
|
1346
1323
|
return void 0;
|
|
1347
1324
|
}
|
|
1348
1325
|
const fn = stripParentheses(call.expression);
|
|
1349
|
-
if (!
|
|
1326
|
+
if (!ts4.isFunctionExpression(fn) && !ts4.isArrowFunction(fn)) {
|
|
1350
1327
|
return void 0;
|
|
1351
1328
|
}
|
|
1352
1329
|
return fn.body;
|
|
1353
1330
|
}
|
|
1354
1331
|
function isAssignment2(node) {
|
|
1355
|
-
return
|
|
1332
|
+
return ts4.isBinaryExpression(node) && node.operatorToken.kind === ts4.SyntaxKind.EqualsToken;
|
|
1356
1333
|
}
|
|
1357
1334
|
function isClassDecorateCall(call, matches) {
|
|
1358
1335
|
const helperArgs = call.arguments[0];
|
|
1359
|
-
if (helperArgs === void 0 || !
|
|
1336
|
+
if (helperArgs === void 0 || !ts4.isArrayLiteralExpression(helperArgs)) {
|
|
1360
1337
|
return false;
|
|
1361
1338
|
}
|
|
1362
1339
|
const target = call.arguments[1];
|
|
1363
|
-
return target !== void 0 &&
|
|
1340
|
+
return target !== void 0 && ts4.isIdentifier(target) && matches(target);
|
|
1364
1341
|
}
|
|
1365
1342
|
function isMemberDecorateCall(call, matches) {
|
|
1366
1343
|
const helperArgs = call.arguments[0];
|
|
1367
|
-
if (helperArgs === void 0 || !
|
|
1344
|
+
if (helperArgs === void 0 || !ts4.isArrayLiteralExpression(helperArgs)) {
|
|
1368
1345
|
return false;
|
|
1369
1346
|
}
|
|
1370
1347
|
const target = call.arguments[1];
|
|
1371
|
-
if (target === void 0 || !
|
|
1348
|
+
if (target === void 0 || !ts4.isPropertyAccessExpression(target) || !ts4.isIdentifier(target.expression) || !matches(target.expression) || target.name.text !== "prototype") {
|
|
1372
1349
|
return false;
|
|
1373
1350
|
}
|
|
1374
1351
|
const memberName = call.arguments[2];
|
|
1375
|
-
return memberName !== void 0 &&
|
|
1352
|
+
return memberName !== void 0 && ts4.isStringLiteral(memberName);
|
|
1376
1353
|
}
|
|
1377
1354
|
function getPropertyValueFromSymbol(propSymbol) {
|
|
1378
1355
|
const propIdentifier = propSymbol.valueDeclaration;
|
|
1379
1356
|
const parent = propIdentifier && propIdentifier.parent;
|
|
1380
|
-
return parent &&
|
|
1357
|
+
return parent && ts4.isBinaryExpression(parent) ? parent.right : void 0;
|
|
1381
1358
|
}
|
|
1382
1359
|
function getCalleeName(call) {
|
|
1383
|
-
if (
|
|
1360
|
+
if (ts4.isIdentifier(call.expression)) {
|
|
1384
1361
|
return stripDollarSuffix(call.expression.text);
|
|
1385
1362
|
}
|
|
1386
|
-
if (
|
|
1363
|
+
if (ts4.isPropertyAccessExpression(call.expression)) {
|
|
1387
1364
|
return stripDollarSuffix(call.expression.name.text);
|
|
1388
1365
|
}
|
|
1389
1366
|
return null;
|
|
@@ -1399,25 +1376,25 @@ function skipClassAliases(node) {
|
|
|
1399
1376
|
return expression;
|
|
1400
1377
|
}
|
|
1401
1378
|
function getInnerClassDeclaration(expression) {
|
|
1402
|
-
if (
|
|
1379
|
+
if (ts4.isClassExpression(expression) && hasNameIdentifier(expression)) {
|
|
1403
1380
|
return expression;
|
|
1404
1381
|
}
|
|
1405
1382
|
const iifeBody = getIifeBody(expression);
|
|
1406
1383
|
if (iifeBody === void 0) {
|
|
1407
1384
|
return null;
|
|
1408
1385
|
}
|
|
1409
|
-
if (!
|
|
1410
|
-
return
|
|
1386
|
+
if (!ts4.isBlock(iifeBody)) {
|
|
1387
|
+
return ts4.isClassExpression(iifeBody) && isNamedDeclaration(iifeBody) ? iifeBody : null;
|
|
1411
1388
|
} else {
|
|
1412
1389
|
for (const statement of iifeBody.statements) {
|
|
1413
1390
|
if (isNamedClassDeclaration(statement) || isNamedFunctionDeclaration(statement)) {
|
|
1414
1391
|
return statement;
|
|
1415
1392
|
}
|
|
1416
|
-
if (
|
|
1393
|
+
if (ts4.isVariableStatement(statement)) {
|
|
1417
1394
|
for (const declaration of statement.declarationList.declarations) {
|
|
1418
1395
|
if (isInitializedVariableClassDeclaration(declaration)) {
|
|
1419
1396
|
const expression2 = skipClassAliases(declaration);
|
|
1420
|
-
if (
|
|
1397
|
+
if (ts4.isClassExpression(expression2) && hasNameIdentifier(expression2)) {
|
|
1421
1398
|
return expression2;
|
|
1422
1399
|
}
|
|
1423
1400
|
}
|
|
@@ -1428,29 +1405,29 @@ function getInnerClassDeclaration(expression) {
|
|
|
1428
1405
|
return null;
|
|
1429
1406
|
}
|
|
1430
1407
|
function getDecoratorArgs(node) {
|
|
1431
|
-
const argsProperty = node.properties.filter(
|
|
1408
|
+
const argsProperty = node.properties.filter(ts4.isPropertyAssignment).find((property2) => getNameText(property2.name) === "args");
|
|
1432
1409
|
const argsExpression = argsProperty && argsProperty.initializer;
|
|
1433
|
-
return argsExpression &&
|
|
1410
|
+
return argsExpression && ts4.isArrayLiteralExpression(argsExpression) ? Array.from(argsExpression.elements) : [];
|
|
1434
1411
|
}
|
|
1435
1412
|
function isPropertyAccess(node) {
|
|
1436
|
-
return !!node.parent &&
|
|
1413
|
+
return !!node.parent && ts4.isBinaryExpression(node.parent) && ts4.isPropertyAccessExpression(node);
|
|
1437
1414
|
}
|
|
1438
1415
|
function isThisAssignment(node) {
|
|
1439
|
-
return
|
|
1416
|
+
return ts4.isBinaryExpression(node) && ts4.isPropertyAccessExpression(node.left) && node.left.expression.kind === ts4.SyntaxKind.ThisKeyword;
|
|
1440
1417
|
}
|
|
1441
1418
|
function isNamedDeclaration(node) {
|
|
1442
1419
|
const anyNode = node;
|
|
1443
|
-
return !!anyNode.name &&
|
|
1420
|
+
return !!anyNode.name && ts4.isIdentifier(anyNode.name);
|
|
1444
1421
|
}
|
|
1445
1422
|
function isClassMemberType(node) {
|
|
1446
|
-
return (
|
|
1423
|
+
return (ts4.isClassElement(node) || isPropertyAccess(node) || ts4.isBinaryExpression(node)) && !ts4.isIndexSignatureDeclaration(node);
|
|
1447
1424
|
}
|
|
1448
1425
|
function getFarLeftHandSideOfAssignment(declaration) {
|
|
1449
1426
|
let node = declaration.parent;
|
|
1450
|
-
if (isAssignment2(node) &&
|
|
1427
|
+
if (isAssignment2(node) && ts4.isIdentifier(node.left)) {
|
|
1451
1428
|
node = node.parent;
|
|
1452
1429
|
}
|
|
1453
|
-
return
|
|
1430
|
+
return ts4.isVariableDeclaration(node) ? node : void 0;
|
|
1454
1431
|
}
|
|
1455
1432
|
function getContainingVariableDeclaration(node) {
|
|
1456
1433
|
node = node.parent;
|
|
@@ -1466,23 +1443,23 @@ function isSynthesizedConstructor(constructor) {
|
|
|
1466
1443
|
if (!constructor.body)
|
|
1467
1444
|
return false;
|
|
1468
1445
|
const firstStatement = constructor.body.statements[0];
|
|
1469
|
-
if (!firstStatement || !
|
|
1446
|
+
if (!firstStatement || !ts4.isExpressionStatement(firstStatement))
|
|
1470
1447
|
return false;
|
|
1471
1448
|
return isSynthesizedSuperCall(firstStatement.expression);
|
|
1472
1449
|
}
|
|
1473
1450
|
function isSynthesizedSuperCall(expression) {
|
|
1474
|
-
if (!
|
|
1451
|
+
if (!ts4.isCallExpression(expression))
|
|
1475
1452
|
return false;
|
|
1476
|
-
if (expression.expression.kind !==
|
|
1453
|
+
if (expression.expression.kind !== ts4.SyntaxKind.SuperKeyword)
|
|
1477
1454
|
return false;
|
|
1478
1455
|
if (expression.arguments.length !== 1)
|
|
1479
1456
|
return false;
|
|
1480
1457
|
const argument = expression.arguments[0];
|
|
1481
|
-
return
|
|
1458
|
+
return ts4.isSpreadElement(argument) && ts4.isIdentifier(argument.expression) && argument.expression.text === "arguments";
|
|
1482
1459
|
}
|
|
1483
1460
|
function getContainingStatement(node) {
|
|
1484
1461
|
while (node.parent) {
|
|
1485
|
-
if (
|
|
1462
|
+
if (ts4.isBlock(node.parent) || ts4.isSourceFile(node.parent)) {
|
|
1486
1463
|
break;
|
|
1487
1464
|
}
|
|
1488
1465
|
node = node.parent;
|
|
@@ -1502,30 +1479,30 @@ function getNonRootPackageFiles(bundle) {
|
|
|
1502
1479
|
}
|
|
1503
1480
|
function isTopLevel(node) {
|
|
1504
1481
|
while (node = node.parent) {
|
|
1505
|
-
if (
|
|
1482
|
+
if (ts4.isBlock(node)) {
|
|
1506
1483
|
return false;
|
|
1507
1484
|
}
|
|
1508
1485
|
}
|
|
1509
1486
|
return true;
|
|
1510
1487
|
}
|
|
1511
1488
|
function getOuterNodeFromInnerDeclaration(node) {
|
|
1512
|
-
if (!
|
|
1489
|
+
if (!ts4.isFunctionDeclaration(node) && !ts4.isClassDeclaration(node) && !ts4.isVariableStatement(node)) {
|
|
1513
1490
|
return null;
|
|
1514
1491
|
}
|
|
1515
1492
|
let outerNode = node.parent;
|
|
1516
|
-
if (!outerNode || !
|
|
1493
|
+
if (!outerNode || !ts4.isBlock(outerNode))
|
|
1517
1494
|
return null;
|
|
1518
1495
|
outerNode = outerNode.parent;
|
|
1519
|
-
if (!outerNode || !
|
|
1496
|
+
if (!outerNode || !ts4.isFunctionExpression(outerNode) && !ts4.isArrowFunction(outerNode)) {
|
|
1520
1497
|
return null;
|
|
1521
1498
|
}
|
|
1522
1499
|
outerNode = outerNode.parent;
|
|
1523
|
-
if (outerNode &&
|
|
1500
|
+
if (outerNode && ts4.isParenthesizedExpression(outerNode))
|
|
1524
1501
|
outerNode = outerNode.parent;
|
|
1525
|
-
if (!outerNode || !
|
|
1502
|
+
if (!outerNode || !ts4.isCallExpression(outerNode))
|
|
1526
1503
|
return null;
|
|
1527
1504
|
outerNode = outerNode.parent;
|
|
1528
|
-
if (outerNode &&
|
|
1505
|
+
if (outerNode && ts4.isParenthesizedExpression(outerNode))
|
|
1529
1506
|
outerNode = outerNode.parent;
|
|
1530
1507
|
while (isAssignment2(outerNode.parent)) {
|
|
1531
1508
|
outerNode = outerNode.parent;
|
|
@@ -1534,7 +1511,7 @@ function getOuterNodeFromInnerDeclaration(node) {
|
|
|
1534
1511
|
}
|
|
1535
1512
|
|
|
1536
1513
|
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/ngcc/src/host/esm5_host.mjs
|
|
1537
|
-
import
|
|
1514
|
+
import ts5 from "typescript";
|
|
1538
1515
|
var Esm5ReflectionHost = class extends Esm2015ReflectionHost {
|
|
1539
1516
|
getBaseClassExpression(clazz) {
|
|
1540
1517
|
const superBaseClassExpression = super.getBaseClassExpression(clazz);
|
|
@@ -1547,7 +1524,7 @@ var Esm5ReflectionHost = class extends Esm2015ReflectionHost {
|
|
|
1547
1524
|
if (iife.parameters.length !== 1 || !isSuperIdentifier(iife.parameters[0].name)) {
|
|
1548
1525
|
return null;
|
|
1549
1526
|
}
|
|
1550
|
-
if (!
|
|
1527
|
+
if (!ts5.isCallExpression(iife.parent)) {
|
|
1551
1528
|
return null;
|
|
1552
1529
|
}
|
|
1553
1530
|
return iife.parent.arguments[0];
|
|
@@ -1568,14 +1545,14 @@ var Esm5ReflectionHost = class extends Esm2015ReflectionHost {
|
|
|
1568
1545
|
if (declaration === null || declaration.node === null || declaration.known !== null) {
|
|
1569
1546
|
return declaration;
|
|
1570
1547
|
}
|
|
1571
|
-
if (!
|
|
1548
|
+
if (!ts5.isVariableDeclaration(declaration.node) || declaration.node.initializer !== void 0 || !ts5.isBlock(declaration.node.parent.parent.parent)) {
|
|
1572
1549
|
return declaration;
|
|
1573
1550
|
}
|
|
1574
1551
|
const block = declaration.node.parent.parent.parent;
|
|
1575
1552
|
const aliasSymbol = this.checker.getSymbolAtLocation(declaration.node.name);
|
|
1576
1553
|
for (let i = 0; i < block.statements.length; i++) {
|
|
1577
1554
|
const statement = block.statements[i];
|
|
1578
|
-
if (isAssignmentStatement(statement) &&
|
|
1555
|
+
if (isAssignmentStatement(statement) && ts5.isIdentifier(statement.expression.left) && ts5.isIdentifier(statement.expression.right) && this.checker.getSymbolAtLocation(statement.expression.left) === aliasSymbol) {
|
|
1579
1556
|
return this.getDeclarationOfIdentifier(statement.expression.right);
|
|
1580
1557
|
}
|
|
1581
1558
|
}
|
|
@@ -1619,7 +1596,7 @@ var Esm5ReflectionHost = class extends Esm2015ReflectionHost {
|
|
|
1619
1596
|
}
|
|
1620
1597
|
getConstructorParameterDeclarations(classSymbol) {
|
|
1621
1598
|
const constructor = classSymbol.implementation.valueDeclaration;
|
|
1622
|
-
if (!
|
|
1599
|
+
if (!ts5.isFunctionDeclaration(constructor))
|
|
1623
1600
|
return null;
|
|
1624
1601
|
if (constructor.parameters.length > 0) {
|
|
1625
1602
|
return Array.from(constructor.parameters);
|
|
@@ -1633,7 +1610,7 @@ var Esm5ReflectionHost = class extends Esm2015ReflectionHost {
|
|
|
1633
1610
|
const paramDecorators = getPropertyValueFromSymbol(paramDecoratorsProperty);
|
|
1634
1611
|
const returnStatement = getReturnStatement(paramDecorators);
|
|
1635
1612
|
const expression = returnStatement ? returnStatement.expression : paramDecorators;
|
|
1636
|
-
if (expression &&
|
|
1613
|
+
if (expression && ts5.isArrayLiteralExpression(expression)) {
|
|
1637
1614
|
const elements = expression.elements;
|
|
1638
1615
|
return elements.map(reflectArrayElement).map((paramInfo) => {
|
|
1639
1616
|
const typeExpression = paramInfo && paramInfo.has("type") ? paramInfo.get("type") : null;
|
|
@@ -1682,7 +1659,7 @@ var Esm5ReflectionHost = class extends Esm2015ReflectionHost {
|
|
|
1682
1659
|
}
|
|
1683
1660
|
const members = super.reflectMembers(symbol, decorators, isStatic);
|
|
1684
1661
|
members && members.forEach((member) => {
|
|
1685
|
-
if (member && member.kind === ClassMemberKind.Method && member.isStatic && member.node &&
|
|
1662
|
+
if (member && member.kind === ClassMemberKind.Method && member.isStatic && member.node && ts5.isPropertyAccessExpression(member.node) && member.node.parent && ts5.isBinaryExpression(member.node.parent) && ts5.isFunctionExpression(member.node.parent.right)) {
|
|
1686
1663
|
member.implementation = member.node.parent.right;
|
|
1687
1664
|
}
|
|
1688
1665
|
});
|
|
@@ -1690,7 +1667,7 @@ var Esm5ReflectionHost = class extends Esm2015ReflectionHost {
|
|
|
1690
1667
|
}
|
|
1691
1668
|
getStatementsForClass(classSymbol) {
|
|
1692
1669
|
const classDeclarationParent = classSymbol.implementation.valueDeclaration.parent;
|
|
1693
|
-
return
|
|
1670
|
+
return ts5.isBlock(classDeclarationParent) ? Array.from(classDeclarationParent.statements) : [];
|
|
1694
1671
|
}
|
|
1695
1672
|
isSynthesizedConstructor(constructor) {
|
|
1696
1673
|
if (!constructor.body)
|
|
@@ -1701,13 +1678,13 @@ var Esm5ReflectionHost = class extends Esm2015ReflectionHost {
|
|
|
1701
1678
|
return this.isSynthesizedSuperThisAssignment(firstStatement) || this.isSynthesizedSuperReturnStatement(firstStatement);
|
|
1702
1679
|
}
|
|
1703
1680
|
isSynthesizedSuperThisAssignment(statement) {
|
|
1704
|
-
if (!
|
|
1681
|
+
if (!ts5.isVariableStatement(statement))
|
|
1705
1682
|
return false;
|
|
1706
1683
|
const variableDeclarations = statement.declarationList.declarations;
|
|
1707
1684
|
if (variableDeclarations.length !== 1)
|
|
1708
1685
|
return false;
|
|
1709
1686
|
const variableDeclaration = variableDeclarations[0];
|
|
1710
|
-
if (!
|
|
1687
|
+
if (!ts5.isIdentifier(variableDeclaration.name) || !variableDeclaration.name.text.startsWith("_this"))
|
|
1711
1688
|
return false;
|
|
1712
1689
|
const initializer = variableDeclaration.initializer;
|
|
1713
1690
|
if (!initializer)
|
|
@@ -1715,7 +1692,7 @@ var Esm5ReflectionHost = class extends Esm2015ReflectionHost {
|
|
|
1715
1692
|
return this.isSynthesizedDefaultSuperCall(initializer);
|
|
1716
1693
|
}
|
|
1717
1694
|
isSynthesizedSuperReturnStatement(statement) {
|
|
1718
|
-
if (!
|
|
1695
|
+
if (!ts5.isReturnStatement(statement))
|
|
1719
1696
|
return false;
|
|
1720
1697
|
const expression = statement.expression;
|
|
1721
1698
|
if (!expression)
|
|
@@ -1723,29 +1700,29 @@ var Esm5ReflectionHost = class extends Esm2015ReflectionHost {
|
|
|
1723
1700
|
return this.isSynthesizedDefaultSuperCall(expression);
|
|
1724
1701
|
}
|
|
1725
1702
|
isSynthesizedDefaultSuperCall(expression) {
|
|
1726
|
-
if (!isBinaryExpr(expression,
|
|
1703
|
+
if (!isBinaryExpr(expression, ts5.SyntaxKind.BarBarToken))
|
|
1727
1704
|
return false;
|
|
1728
|
-
if (expression.right.kind !==
|
|
1705
|
+
if (expression.right.kind !== ts5.SyntaxKind.ThisKeyword)
|
|
1729
1706
|
return false;
|
|
1730
1707
|
const left = expression.left;
|
|
1731
|
-
if (isBinaryExpr(left,
|
|
1708
|
+
if (isBinaryExpr(left, ts5.SyntaxKind.AmpersandAmpersandToken)) {
|
|
1732
1709
|
return isSuperNotNull(left.left) && this.isSuperApplyCall(left.right);
|
|
1733
1710
|
} else {
|
|
1734
1711
|
return this.isSuperApplyCall(left);
|
|
1735
1712
|
}
|
|
1736
1713
|
}
|
|
1737
1714
|
isSuperApplyCall(expression) {
|
|
1738
|
-
if (!
|
|
1715
|
+
if (!ts5.isCallExpression(expression) || expression.arguments.length !== 2)
|
|
1739
1716
|
return false;
|
|
1740
1717
|
const targetFn = expression.expression;
|
|
1741
|
-
if (!
|
|
1718
|
+
if (!ts5.isPropertyAccessExpression(targetFn))
|
|
1742
1719
|
return false;
|
|
1743
1720
|
if (!isSuperIdentifier(targetFn.expression))
|
|
1744
1721
|
return false;
|
|
1745
1722
|
if (targetFn.name.text !== "apply")
|
|
1746
1723
|
return false;
|
|
1747
1724
|
const thisArgument = expression.arguments[0];
|
|
1748
|
-
if (thisArgument.kind !==
|
|
1725
|
+
if (thisArgument.kind !== ts5.SyntaxKind.ThisKeyword)
|
|
1749
1726
|
return false;
|
|
1750
1727
|
const argumentsExpr = expression.arguments[1];
|
|
1751
1728
|
if (isArgumentsIdentifier(argumentsExpr)) {
|
|
@@ -1765,7 +1742,7 @@ var Esm5ReflectionHost = class extends Esm2015ReflectionHost {
|
|
|
1765
1742
|
return false;
|
|
1766
1743
|
}
|
|
1767
1744
|
const firstArg = call.args[0];
|
|
1768
|
-
if (!
|
|
1745
|
+
if (!ts5.isArrayLiteralExpression(firstArg) || firstArg.elements.length !== 0) {
|
|
1769
1746
|
return false;
|
|
1770
1747
|
}
|
|
1771
1748
|
const secondArg = this.extractKnownHelperCall(call.args[1]);
|
|
@@ -1778,14 +1755,14 @@ var Esm5ReflectionHost = class extends Esm2015ReflectionHost {
|
|
|
1778
1755
|
}
|
|
1779
1756
|
}
|
|
1780
1757
|
extractKnownHelperCall(expression) {
|
|
1781
|
-
if (!
|
|
1758
|
+
if (!ts5.isCallExpression(expression)) {
|
|
1782
1759
|
return null;
|
|
1783
1760
|
}
|
|
1784
1761
|
const receiverExpr = expression.expression;
|
|
1785
1762
|
let receiver = null;
|
|
1786
|
-
if (
|
|
1763
|
+
if (ts5.isIdentifier(receiverExpr)) {
|
|
1787
1764
|
receiver = this.getDeclarationOfIdentifier(receiverExpr);
|
|
1788
|
-
} else if (
|
|
1765
|
+
} else if (ts5.isPropertyAccessExpression(receiverExpr) && ts5.isIdentifier(receiverExpr.name)) {
|
|
1789
1766
|
receiver = this.getDeclarationOfIdentifier(receiverExpr.name);
|
|
1790
1767
|
}
|
|
1791
1768
|
if (receiver === null || receiver.known === null) {
|
|
@@ -1798,13 +1775,13 @@ var Esm5ReflectionHost = class extends Esm2015ReflectionHost {
|
|
|
1798
1775
|
}
|
|
1799
1776
|
};
|
|
1800
1777
|
function getPropertyDefinition(node) {
|
|
1801
|
-
if (!
|
|
1778
|
+
if (!ts5.isCallExpression(node))
|
|
1802
1779
|
return null;
|
|
1803
1780
|
const fn = node.expression;
|
|
1804
|
-
if (!
|
|
1781
|
+
if (!ts5.isPropertyAccessExpression(fn) || !ts5.isIdentifier(fn.expression) || fn.expression.text !== "Object" || fn.name.text !== "defineProperty")
|
|
1805
1782
|
return null;
|
|
1806
1783
|
const descriptor = node.arguments[2];
|
|
1807
|
-
if (!descriptor || !
|
|
1784
|
+
if (!descriptor || !ts5.isObjectLiteralExpression(descriptor))
|
|
1808
1785
|
return null;
|
|
1809
1786
|
return {
|
|
1810
1787
|
setter: readPropertyFunctionExpression(descriptor, "set"),
|
|
@@ -1812,29 +1789,29 @@ function getPropertyDefinition(node) {
|
|
|
1812
1789
|
};
|
|
1813
1790
|
}
|
|
1814
1791
|
function readPropertyFunctionExpression(object, name) {
|
|
1815
|
-
const property2 = object.properties.find((p) =>
|
|
1816
|
-
return property2 &&
|
|
1792
|
+
const property2 = object.properties.find((p) => ts5.isPropertyAssignment(p) && ts5.isIdentifier(p.name) && p.name.text === name);
|
|
1793
|
+
return property2 && ts5.isFunctionExpression(property2.initializer) && property2.initializer || null;
|
|
1817
1794
|
}
|
|
1818
1795
|
function getReturnStatement(declaration) {
|
|
1819
|
-
return declaration &&
|
|
1796
|
+
return declaration && ts5.isFunctionExpression(declaration) ? declaration.body.statements.find(ts5.isReturnStatement) : void 0;
|
|
1820
1797
|
}
|
|
1821
1798
|
function reflectArrayElement(element) {
|
|
1822
|
-
return
|
|
1799
|
+
return ts5.isObjectLiteralExpression(element) ? reflectObjectLiteral(element) : null;
|
|
1823
1800
|
}
|
|
1824
1801
|
function isArgumentsIdentifier(expression) {
|
|
1825
|
-
return
|
|
1802
|
+
return ts5.isIdentifier(expression) && expression.text === "arguments";
|
|
1826
1803
|
}
|
|
1827
1804
|
function isSuperNotNull(expression) {
|
|
1828
|
-
return isBinaryExpr(expression,
|
|
1805
|
+
return isBinaryExpr(expression, ts5.SyntaxKind.ExclamationEqualsEqualsToken) && isSuperIdentifier(expression.left);
|
|
1829
1806
|
}
|
|
1830
1807
|
function isBinaryExpr(expression, operator) {
|
|
1831
|
-
return
|
|
1808
|
+
return ts5.isBinaryExpression(expression) && expression.operatorToken.kind === operator;
|
|
1832
1809
|
}
|
|
1833
1810
|
function isSuperIdentifier(node) {
|
|
1834
|
-
return
|
|
1811
|
+
return ts5.isIdentifier(node) && node.text.startsWith("_super");
|
|
1835
1812
|
}
|
|
1836
1813
|
function captureParamInitializer(statement, parameters) {
|
|
1837
|
-
if (
|
|
1814
|
+
if (ts5.isIfStatement(statement) && isUndefinedComparison(statement.expression) && ts5.isBlock(statement.thenStatement) && statement.thenStatement.statements.length === 1) {
|
|
1838
1815
|
const ifStatementComparison = statement.expression;
|
|
1839
1816
|
const thenStatement = statement.thenStatement.statements[0];
|
|
1840
1817
|
if (isAssignmentStatement(thenStatement)) {
|
|
@@ -1852,7 +1829,7 @@ function captureParamInitializer(statement, parameters) {
|
|
|
1852
1829
|
return false;
|
|
1853
1830
|
}
|
|
1854
1831
|
function isUndefinedComparison(expression) {
|
|
1855
|
-
return
|
|
1832
|
+
return ts5.isBinaryExpression(expression) && expression.operatorToken.kind === ts5.SyntaxKind.EqualsEqualsEqualsToken && ts5.isVoidExpression(expression.right) && ts5.isIdentifier(expression.left);
|
|
1856
1833
|
}
|
|
1857
1834
|
function getIifeFn(classSymbol) {
|
|
1858
1835
|
if (classSymbol === void 0) {
|
|
@@ -1860,11 +1837,11 @@ function getIifeFn(classSymbol) {
|
|
|
1860
1837
|
}
|
|
1861
1838
|
const innerDeclaration = classSymbol.implementation.valueDeclaration;
|
|
1862
1839
|
const iifeBody = innerDeclaration.parent;
|
|
1863
|
-
if (!
|
|
1840
|
+
if (!ts5.isBlock(iifeBody)) {
|
|
1864
1841
|
return null;
|
|
1865
1842
|
}
|
|
1866
1843
|
const iifeWrapper = iifeBody.parent;
|
|
1867
|
-
return iifeWrapper &&
|
|
1844
|
+
return iifeWrapper && ts5.isFunctionExpression(iifeWrapper) ? iifeWrapper : null;
|
|
1868
1845
|
}
|
|
1869
1846
|
|
|
1870
1847
|
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/ngcc/src/host/umd_host.mjs
|
|
@@ -1932,7 +1909,7 @@ var UmdReflectionHost = class extends Esm5ReflectionHost {
|
|
|
1932
1909
|
return void 0;
|
|
1933
1910
|
}
|
|
1934
1911
|
let initializer = skipAliases(declaration.parent.right);
|
|
1935
|
-
if (
|
|
1912
|
+
if (ts6.isIdentifier(initializer)) {
|
|
1936
1913
|
const implementation = this.getDeclarationOfIdentifier(initializer);
|
|
1937
1914
|
if (implementation !== null) {
|
|
1938
1915
|
const implementationSymbol = this.getClassSymbol(implementation.node);
|
|
@@ -1977,7 +1954,7 @@ var UmdReflectionHost = class extends Esm5ReflectionHost {
|
|
|
1977
1954
|
}
|
|
1978
1955
|
const declaration = statement.expression.left;
|
|
1979
1956
|
const initializer = statement.expression.right;
|
|
1980
|
-
if (!isAssignment2(initializer) || !
|
|
1957
|
+
if (!isAssignment2(initializer) || !ts6.isIdentifier(initializer.left) || !this.isClass(declaration)) {
|
|
1981
1958
|
return;
|
|
1982
1959
|
}
|
|
1983
1960
|
const aliasedIdentifier = initializer.left;
|
|
@@ -1994,7 +1971,7 @@ var UmdReflectionHost = class extends Esm5ReflectionHost {
|
|
|
1994
1971
|
return parseStatementForUmdModule(sourceFile.statements[0]);
|
|
1995
1972
|
}
|
|
1996
1973
|
computeExportsOfUmdModule(sourceFile) {
|
|
1997
|
-
const moduleMap = new Map();
|
|
1974
|
+
const moduleMap = /* @__PURE__ */ new Map();
|
|
1998
1975
|
for (const statement of this.getModuleStatements(sourceFile)) {
|
|
1999
1976
|
if (isExportsStatement(statement)) {
|
|
2000
1977
|
const exportDeclaration = this.extractBasicUmdExportDeclaration(statement);
|
|
@@ -2048,11 +2025,11 @@ var UmdReflectionHost = class extends Esm5ReflectionHost {
|
|
|
2048
2025
|
}
|
|
2049
2026
|
extractUmdWildcardReexports(statement, containingFile) {
|
|
2050
2027
|
const reexportArg = statement.expression.arguments[0];
|
|
2051
|
-
const requireCall = isRequireCall(reexportArg) ? reexportArg :
|
|
2028
|
+
const requireCall = isRequireCall(reexportArg) ? reexportArg : ts6.isIdentifier(reexportArg) ? findRequireCallReference(reexportArg, this.checker) : null;
|
|
2052
2029
|
let importPath = null;
|
|
2053
2030
|
if (requireCall !== null) {
|
|
2054
2031
|
importPath = requireCall.arguments[0].text;
|
|
2055
|
-
} else if (
|
|
2032
|
+
} else if (ts6.isIdentifier(reexportArg)) {
|
|
2056
2033
|
const importParameter = this.findUmdImportParameter(reexportArg);
|
|
2057
2034
|
importPath = importParameter && this.getUmdImportPath(importParameter);
|
|
2058
2035
|
}
|
|
@@ -2097,7 +2074,7 @@ var UmdReflectionHost = class extends Esm5ReflectionHost {
|
|
|
2097
2074
|
findUmdImportParameter(id) {
|
|
2098
2075
|
const symbol = id && this.checker.getSymbolAtLocation(id) || null;
|
|
2099
2076
|
const declaration = symbol && symbol.valueDeclaration;
|
|
2100
|
-
return declaration &&
|
|
2077
|
+
return declaration && ts6.isParameter(declaration) ? declaration : null;
|
|
2101
2078
|
}
|
|
2102
2079
|
getUmdDeclaration(id) {
|
|
2103
2080
|
const nsIdentifier = findNamespaceOfIdentifier(id);
|
|
@@ -2106,7 +2083,7 @@ var UmdReflectionHost = class extends Esm5ReflectionHost {
|
|
|
2106
2083
|
}
|
|
2107
2084
|
if (nsIdentifier.parent.parent && isExportsAssignment(nsIdentifier.parent.parent)) {
|
|
2108
2085
|
const initializer = nsIdentifier.parent.parent.right;
|
|
2109
|
-
if (
|
|
2086
|
+
if (ts6.isIdentifier(initializer)) {
|
|
2110
2087
|
return this.getDeclarationOfIdentifier(initializer);
|
|
2111
2088
|
}
|
|
2112
2089
|
return this.detectKnownDeclaration({
|
|
@@ -2118,7 +2095,7 @@ var UmdReflectionHost = class extends Esm5ReflectionHost {
|
|
|
2118
2095
|
});
|
|
2119
2096
|
}
|
|
2120
2097
|
const moduleDeclaration = this.getUmdModuleDeclaration(nsIdentifier);
|
|
2121
|
-
if (moduleDeclaration === null || moduleDeclaration.node === null || !
|
|
2098
|
+
if (moduleDeclaration === null || moduleDeclaration.node === null || !ts6.isSourceFile(moduleDeclaration.node)) {
|
|
2122
2099
|
return null;
|
|
2123
2100
|
}
|
|
2124
2101
|
const moduleExports = this.getExportsOfModule(moduleDeclaration.node);
|
|
@@ -2136,8 +2113,8 @@ var UmdReflectionHost = class extends Esm5ReflectionHost {
|
|
|
2136
2113
|
if (!isExportsIdentifier(id)) {
|
|
2137
2114
|
return null;
|
|
2138
2115
|
}
|
|
2139
|
-
const exportsSymbol = this.checker.getSymbolsInScope(id,
|
|
2140
|
-
const node = (exportsSymbol == null ? void 0 : exportsSymbol.valueDeclaration) !== void 0 && !
|
|
2116
|
+
const exportsSymbol = this.checker.getSymbolsInScope(id, ts6.SymbolFlags.Variable).find((symbol) => symbol.name === "exports");
|
|
2117
|
+
const node = (exportsSymbol == null ? void 0 : exportsSymbol.valueDeclaration) !== void 0 && !ts6.isFunctionExpression(exportsSymbol.valueDeclaration.parent) ? exportsSymbol.valueDeclaration : id.getSourceFile();
|
|
2141
2118
|
return {
|
|
2142
2119
|
kind: 0,
|
|
2143
2120
|
node,
|
|
@@ -2193,7 +2170,7 @@ var UmdReflectionHost = class extends Esm5ReflectionHost {
|
|
|
2193
2170
|
const moduleInfo = this.compilerHost.resolveModuleNames([moduleName], containingFile.fileName, void 0, void 0, this.program.getCompilerOptions())[0];
|
|
2194
2171
|
return moduleInfo && this.program.getSourceFile(absoluteFrom(moduleInfo.resolvedFileName));
|
|
2195
2172
|
} else {
|
|
2196
|
-
const moduleInfo =
|
|
2173
|
+
const moduleInfo = ts6.resolveModuleName(moduleName, containingFile.fileName, this.program.getCompilerOptions(), this.compilerHost);
|
|
2197
2174
|
return moduleInfo.resolvedModule && this.program.getSourceFile(absoluteFrom(moduleInfo.resolvedModule.resolvedFileName));
|
|
2198
2175
|
}
|
|
2199
2176
|
}
|
|
@@ -2202,60 +2179,169 @@ function parseStatementForUmdModule(statement) {
|
|
|
2202
2179
|
const wrapper = getUmdWrapper(statement);
|
|
2203
2180
|
if (wrapper === null)
|
|
2204
2181
|
return null;
|
|
2205
|
-
const factoryFnParamIndex = wrapper.fn.parameters.findIndex((parameter) =>
|
|
2182
|
+
const factoryFnParamIndex = wrapper.fn.parameters.findIndex((parameter) => ts6.isIdentifier(parameter.name) && parameter.name.text === "factory");
|
|
2206
2183
|
if (factoryFnParamIndex === -1)
|
|
2207
2184
|
return null;
|
|
2208
2185
|
const factoryFn = stripParentheses(wrapper.call.arguments[factoryFnParamIndex]);
|
|
2209
|
-
if (!factoryFn || !
|
|
2186
|
+
if (!factoryFn || !ts6.isFunctionExpression(factoryFn))
|
|
2210
2187
|
return null;
|
|
2211
|
-
|
|
2188
|
+
let factoryCalls = null;
|
|
2189
|
+
return {
|
|
2190
|
+
wrapperFn: wrapper.fn,
|
|
2191
|
+
factoryFn,
|
|
2192
|
+
get factoryCalls() {
|
|
2193
|
+
if (factoryCalls === null) {
|
|
2194
|
+
factoryCalls = parseUmdWrapperFunction(this.wrapperFn);
|
|
2195
|
+
}
|
|
2196
|
+
return factoryCalls;
|
|
2197
|
+
}
|
|
2198
|
+
};
|
|
2212
2199
|
}
|
|
2213
2200
|
function getUmdWrapper(statement) {
|
|
2214
|
-
if (!
|
|
2201
|
+
if (!ts6.isExpressionStatement(statement))
|
|
2215
2202
|
return null;
|
|
2216
|
-
if (
|
|
2203
|
+
if (ts6.isParenthesizedExpression(statement.expression) && ts6.isCallExpression(statement.expression.expression) && ts6.isFunctionExpression(statement.expression.expression.expression)) {
|
|
2217
2204
|
const call = statement.expression.expression;
|
|
2218
2205
|
const fn = statement.expression.expression.expression;
|
|
2219
2206
|
return { call, fn };
|
|
2220
2207
|
}
|
|
2221
|
-
if (
|
|
2208
|
+
if (ts6.isCallExpression(statement.expression) && ts6.isParenthesizedExpression(statement.expression.expression) && ts6.isFunctionExpression(statement.expression.expression.expression)) {
|
|
2222
2209
|
const call = statement.expression;
|
|
2223
2210
|
const fn = statement.expression.expression.expression;
|
|
2224
2211
|
return { call, fn };
|
|
2225
2212
|
}
|
|
2226
2213
|
return null;
|
|
2227
2214
|
}
|
|
2228
|
-
function
|
|
2229
|
-
const
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2215
|
+
function parseUmdWrapperFunction(wrapperFn) {
|
|
2216
|
+
const stmt = wrapperFn.body.statements[0];
|
|
2217
|
+
let conditionalFactoryCalls;
|
|
2218
|
+
if (ts6.isExpressionStatement(stmt) && ts6.isConditionalExpression(stmt.expression)) {
|
|
2219
|
+
conditionalFactoryCalls = extractFactoryCallsFromConditionalExpression(stmt.expression);
|
|
2220
|
+
} else if (ts6.isIfStatement(stmt)) {
|
|
2221
|
+
conditionalFactoryCalls = extractFactoryCallsFromIfStatement(stmt);
|
|
2222
|
+
} else {
|
|
2223
|
+
throw new Error("UMD wrapper body is not in a supported format (expected a conditional expression or if statement):\n" + wrapperFn.body.getText());
|
|
2224
|
+
}
|
|
2225
|
+
const amdDefine = getAmdDefineCall(conditionalFactoryCalls);
|
|
2226
|
+
const commonJs = getCommonJsFactoryCall(conditionalFactoryCalls);
|
|
2227
|
+
const commonJs2 = getCommonJs2FactoryCall(conditionalFactoryCalls);
|
|
2228
|
+
const global = getGlobalFactoryCall(conditionalFactoryCalls);
|
|
2229
|
+
const cjsCallForImports = commonJs2 || commonJs;
|
|
2230
|
+
if (cjsCallForImports === null) {
|
|
2231
|
+
throw new Error("Unable to find a CommonJS or CommonJS2 factory call inside the UMD wrapper function:\n" + stmt.getText());
|
|
2232
|
+
}
|
|
2233
|
+
return { amdDefine, commonJs, commonJs2, global, cjsCallForImports };
|
|
2234
|
+
}
|
|
2235
|
+
function extractFactoryCallsFromConditionalExpression(node) {
|
|
2236
|
+
const factoryCalls = [];
|
|
2237
|
+
let currentNode = node;
|
|
2238
|
+
while (ts6.isConditionalExpression(currentNode)) {
|
|
2239
|
+
if (!ts6.isBinaryExpression(currentNode.condition)) {
|
|
2240
|
+
throw new Error("Condition inside UMD wrapper is not a binary expression:\n" + currentNode.condition.getText());
|
|
2241
|
+
}
|
|
2242
|
+
factoryCalls.push({
|
|
2243
|
+
condition: currentNode.condition,
|
|
2244
|
+
factoryCall: getFunctionCallFromExpression(currentNode.whenTrue)
|
|
2234
2245
|
});
|
|
2246
|
+
currentNode = currentNode.whenFalse;
|
|
2235
2247
|
}
|
|
2236
|
-
|
|
2248
|
+
factoryCalls.push({
|
|
2249
|
+
condition: null,
|
|
2250
|
+
factoryCall: getFunctionCallFromExpression(currentNode)
|
|
2251
|
+
});
|
|
2252
|
+
return factoryCalls;
|
|
2237
2253
|
}
|
|
2238
|
-
function
|
|
2239
|
-
const
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
+
function extractFactoryCallsFromIfStatement(node) {
|
|
2255
|
+
const factoryCalls = [];
|
|
2256
|
+
let currentNode = node;
|
|
2257
|
+
while (currentNode && ts6.isIfStatement(currentNode)) {
|
|
2258
|
+
if (!ts6.isBinaryExpression(currentNode.expression)) {
|
|
2259
|
+
throw new Error("Condition inside UMD wrapper is not a binary expression:\n" + currentNode.expression.getText());
|
|
2260
|
+
}
|
|
2261
|
+
if (!ts6.isExpressionStatement(currentNode.thenStatement)) {
|
|
2262
|
+
throw new Error("Then-statement inside UMD wrapper is not an expression statement:\n" + currentNode.thenStatement.getText());
|
|
2263
|
+
}
|
|
2264
|
+
factoryCalls.push({
|
|
2265
|
+
condition: currentNode.expression,
|
|
2266
|
+
factoryCall: getFunctionCallFromExpression(currentNode.thenStatement.expression)
|
|
2267
|
+
});
|
|
2268
|
+
currentNode = currentNode.elseStatement;
|
|
2269
|
+
}
|
|
2270
|
+
if (currentNode) {
|
|
2271
|
+
if (!ts6.isExpressionStatement(currentNode)) {
|
|
2272
|
+
throw new Error("Else-statement inside UMD wrapper is not an expression statement:\n" + currentNode.getText());
|
|
2273
|
+
}
|
|
2274
|
+
factoryCalls.push({
|
|
2275
|
+
condition: null,
|
|
2276
|
+
factoryCall: getFunctionCallFromExpression(currentNode.expression)
|
|
2277
|
+
});
|
|
2278
|
+
}
|
|
2279
|
+
return factoryCalls;
|
|
2280
|
+
}
|
|
2281
|
+
function getFunctionCallFromExpression(node) {
|
|
2282
|
+
if (ts6.isParenthesizedExpression(node)) {
|
|
2283
|
+
return getFunctionCallFromExpression(node.expression);
|
|
2284
|
+
}
|
|
2285
|
+
if (ts6.isBinaryExpression(node) && [ts6.SyntaxKind.CommaToken, ts6.SyntaxKind.EqualsToken].includes(node.operatorToken.kind)) {
|
|
2286
|
+
return getFunctionCallFromExpression(node.right);
|
|
2287
|
+
}
|
|
2288
|
+
if (!ts6.isCallExpression(node)) {
|
|
2289
|
+
throw new Error("Expression inside UMD wrapper is not a call expression:\n" + node.getText());
|
|
2290
|
+
}
|
|
2291
|
+
return node;
|
|
2292
|
+
}
|
|
2293
|
+
function getAmdDefineCall(calls) {
|
|
2294
|
+
var _a;
|
|
2295
|
+
const amdConditionalCall = calls.find((call) => {
|
|
2296
|
+
var _a2;
|
|
2297
|
+
return ((_a2 = call.condition) == null ? void 0 : _a2.operatorToken.kind) === ts6.SyntaxKind.AmpersandAmpersandToken && oneOfBinaryConditions(call.condition, (exp) => isTypeOf(exp, "define")) && ts6.isIdentifier(call.factoryCall.expression) && call.factoryCall.expression.text === "define";
|
|
2298
|
+
});
|
|
2299
|
+
return (_a = amdConditionalCall == null ? void 0 : amdConditionalCall.factoryCall) != null ? _a : null;
|
|
2300
|
+
}
|
|
2301
|
+
function getCommonJsFactoryCall(calls) {
|
|
2302
|
+
var _a;
|
|
2303
|
+
const cjsConditionalCall = calls.find((call) => {
|
|
2304
|
+
var _a2;
|
|
2305
|
+
return ((_a2 = call.condition) == null ? void 0 : _a2.operatorToken.kind) === ts6.SyntaxKind.EqualsEqualsEqualsToken && isTypeOf(call.condition, "exports") && ts6.isIdentifier(call.factoryCall.expression) && call.factoryCall.expression.text === "factory";
|
|
2306
|
+
});
|
|
2307
|
+
return (_a = cjsConditionalCall == null ? void 0 : cjsConditionalCall.factoryCall) != null ? _a : null;
|
|
2308
|
+
}
|
|
2309
|
+
function getCommonJs2FactoryCall(calls) {
|
|
2310
|
+
var _a;
|
|
2311
|
+
const cjs2ConditionalCall = calls.find((call) => {
|
|
2312
|
+
var _a2;
|
|
2313
|
+
return ((_a2 = call.condition) == null ? void 0 : _a2.operatorToken.kind) === ts6.SyntaxKind.AmpersandAmpersandToken && oneOfBinaryConditions(call.condition, (exp) => isTypeOf(exp, "exports", "module")) && ts6.isIdentifier(call.factoryCall.expression) && call.factoryCall.expression.text === "factory";
|
|
2314
|
+
});
|
|
2315
|
+
return (_a = cjs2ConditionalCall == null ? void 0 : cjs2ConditionalCall.factoryCall) != null ? _a : null;
|
|
2316
|
+
}
|
|
2317
|
+
function getGlobalFactoryCall(calls) {
|
|
2318
|
+
var _a;
|
|
2319
|
+
const globalConditionalCall = calls.find((call) => call.condition === null);
|
|
2320
|
+
return (_a = globalConditionalCall == null ? void 0 : globalConditionalCall.factoryCall) != null ? _a : null;
|
|
2321
|
+
}
|
|
2322
|
+
function oneOfBinaryConditions(node, test) {
|
|
2323
|
+
return test(node.left) || test(node.right);
|
|
2324
|
+
}
|
|
2325
|
+
function isTypeOf(node, ...types) {
|
|
2326
|
+
return ts6.isBinaryExpression(node) && ts6.isTypeOfExpression(node.left) && ts6.isIdentifier(node.left.expression) && types.includes(node.left.expression.text);
|
|
2327
|
+
}
|
|
2328
|
+
function getImportsOfUmdModule(umdModule) {
|
|
2329
|
+
const imports = [];
|
|
2330
|
+
const factoryFnParams = umdModule.factoryFn.parameters;
|
|
2331
|
+
const cjsFactoryCallArgs = umdModule.factoryCalls.cjsCallForImports.arguments;
|
|
2332
|
+
for (let i = 0; i < factoryFnParams.length; i++) {
|
|
2333
|
+
const arg = cjsFactoryCallArgs[i];
|
|
2334
|
+
if (arg !== void 0 && isRequireCall(arg)) {
|
|
2335
|
+
imports.push({
|
|
2336
|
+
parameter: factoryFnParams[i],
|
|
2337
|
+
path: arg.arguments[0].text
|
|
2338
|
+
});
|
|
2254
2339
|
}
|
|
2255
2340
|
}
|
|
2341
|
+
return imports;
|
|
2256
2342
|
}
|
|
2257
2343
|
function isExportsIdentifier(node) {
|
|
2258
|
-
return
|
|
2344
|
+
return ts6.isIdentifier(node) && node.text === "exports";
|
|
2259
2345
|
}
|
|
2260
2346
|
|
|
2261
2347
|
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/ngcc/src/packages/entry_point.mjs
|
|
@@ -2356,11 +2442,11 @@ function sniffModuleFormat(fs, sourceFilePath) {
|
|
|
2356
2442
|
if (resolvedPath === null) {
|
|
2357
2443
|
return void 0;
|
|
2358
2444
|
}
|
|
2359
|
-
const sourceFile =
|
|
2445
|
+
const sourceFile = ts7.createSourceFile(sourceFilePath, fs.readFile(resolvedPath), ts7.ScriptTarget.ES5);
|
|
2360
2446
|
if (sourceFile.statements.length === 0) {
|
|
2361
2447
|
return void 0;
|
|
2362
2448
|
}
|
|
2363
|
-
if (
|
|
2449
|
+
if (ts7.isExternalModule(sourceFile)) {
|
|
2364
2450
|
return "esm5";
|
|
2365
2451
|
} else if (parseStatementForUmdModule(sourceFile.statements[0]) !== null) {
|
|
2366
2452
|
return "umd";
|
|
@@ -2427,20 +2513,20 @@ var DtsProcessing;
|
|
|
2427
2513
|
var TaskDependencies = Map;
|
|
2428
2514
|
|
|
2429
2515
|
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/ngcc/src/packages/bundle_program.mjs
|
|
2430
|
-
import
|
|
2516
|
+
import ts9 from "typescript";
|
|
2431
2517
|
|
|
2432
2518
|
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/ngcc/src/packages/patch_ts_expando_initializer.mjs
|
|
2433
|
-
import
|
|
2519
|
+
import ts8 from "typescript";
|
|
2434
2520
|
function patchTsGetExpandoInitializer() {
|
|
2435
2521
|
if (isTs31778GetExpandoInitializerFixed()) {
|
|
2436
2522
|
return null;
|
|
2437
2523
|
}
|
|
2438
|
-
const originalGetExpandoInitializer =
|
|
2524
|
+
const originalGetExpandoInitializer = ts8.getExpandoInitializer;
|
|
2439
2525
|
if (originalGetExpandoInitializer === void 0) {
|
|
2440
2526
|
throw makeUnsupportedTypeScriptError();
|
|
2441
2527
|
}
|
|
2442
|
-
|
|
2443
|
-
if (
|
|
2528
|
+
ts8.getExpandoInitializer = (initializer, isPrototypeAssignment) => {
|
|
2529
|
+
if (ts8.isParenthesizedExpression(initializer) && ts8.isCallExpression(initializer.expression)) {
|
|
2444
2530
|
initializer = initializer.expression;
|
|
2445
2531
|
}
|
|
2446
2532
|
return originalGetExpandoInitializer(initializer, isPrototypeAssignment);
|
|
@@ -2449,7 +2535,7 @@ function patchTsGetExpandoInitializer() {
|
|
|
2449
2535
|
}
|
|
2450
2536
|
function restoreGetExpandoInitializer(originalGetExpandoInitializer) {
|
|
2451
2537
|
if (originalGetExpandoInitializer !== null) {
|
|
2452
|
-
|
|
2538
|
+
ts8.getExpandoInitializer = originalGetExpandoInitializer;
|
|
2453
2539
|
}
|
|
2454
2540
|
}
|
|
2455
2541
|
var ts31778FixedResult = null;
|
|
@@ -2480,7 +2566,7 @@ function checkIfExpandoPropertyIsPresent() {
|
|
|
2480
2566
|
}());
|
|
2481
2567
|
A.expando = true;
|
|
2482
2568
|
}());`;
|
|
2483
|
-
const sourceFile =
|
|
2569
|
+
const sourceFile = ts8.createSourceFile("test.js", sourceText, ts8.ScriptTarget.ES5, true, ts8.ScriptKind.JS);
|
|
2484
2570
|
const host = {
|
|
2485
2571
|
getSourceFile() {
|
|
2486
2572
|
return sourceFile;
|
|
@@ -2513,14 +2599,14 @@ function checkIfExpandoPropertyIsPresent() {
|
|
|
2513
2599
|
}
|
|
2514
2600
|
};
|
|
2515
2601
|
const options = { noResolve: true, noLib: true, noEmit: true, allowJs: true };
|
|
2516
|
-
const program =
|
|
2602
|
+
const program = ts8.createProgram(["test.js"], options, host);
|
|
2517
2603
|
function visitor(node) {
|
|
2518
|
-
if (
|
|
2604
|
+
if (ts8.isVariableDeclaration(node) && hasNameIdentifier(node) && node.name.text === "A") {
|
|
2519
2605
|
return node;
|
|
2520
2606
|
}
|
|
2521
|
-
return
|
|
2607
|
+
return ts8.forEachChild(node, visitor);
|
|
2522
2608
|
}
|
|
2523
|
-
const declaration =
|
|
2609
|
+
const declaration = ts8.forEachChild(sourceFile, visitor);
|
|
2524
2610
|
if (declaration === void 0) {
|
|
2525
2611
|
throw new Error("Unable to find declaration of outer A");
|
|
2526
2612
|
}
|
|
@@ -2539,7 +2625,7 @@ function makeBundleProgram(fs, isCore, pkg, path, r3FileName, options, host, add
|
|
|
2539
2625
|
const r3SymbolsPath = isCore ? findR3SymbolsPath(fs, fs.dirname(path), r3FileName) : null;
|
|
2540
2626
|
let rootPaths = r3SymbolsPath ? [path, r3SymbolsPath, ...additionalFiles] : [path, ...additionalFiles];
|
|
2541
2627
|
const originalGetExpandoInitializer = patchTsGetExpandoInitializer();
|
|
2542
|
-
const program =
|
|
2628
|
+
const program = ts9.createProgram(rootPaths, options, host);
|
|
2543
2629
|
program.getTypeChecker();
|
|
2544
2630
|
restoreGetExpandoInitializer(originalGetExpandoInitializer);
|
|
2545
2631
|
const file = program.getSourceFile(path);
|
|
@@ -2565,7 +2651,7 @@ function findR3SymbolsPath(fs, directory, filename) {
|
|
|
2565
2651
|
}
|
|
2566
2652
|
|
|
2567
2653
|
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/ngcc/src/packages/ngcc_compiler_host.mjs
|
|
2568
|
-
import
|
|
2654
|
+
import ts10 from "typescript";
|
|
2569
2655
|
var NgccSourcesCompilerHost = class extends NgtscCompilerHost {
|
|
2570
2656
|
constructor(fs, options, cache, moduleResolutionCache, packagePath) {
|
|
2571
2657
|
super(fs, options);
|
|
@@ -2578,14 +2664,14 @@ var NgccSourcesCompilerHost = class extends NgtscCompilerHost {
|
|
|
2578
2664
|
}
|
|
2579
2665
|
resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference) {
|
|
2580
2666
|
return moduleNames.map((moduleName) => {
|
|
2581
|
-
const { resolvedModule } =
|
|
2582
|
-
if ((resolvedModule == null ? void 0 : resolvedModule.extension) ===
|
|
2667
|
+
const { resolvedModule } = ts10.resolveModuleName(moduleName, containingFile, this.options, this, this.moduleResolutionCache, redirectedReference);
|
|
2668
|
+
if ((resolvedModule == null ? void 0 : resolvedModule.extension) === ts10.Extension.Dts && containingFile.endsWith(".js") && isRelativePath(moduleName)) {
|
|
2583
2669
|
const jsFile = resolvedModule.resolvedFileName.replace(/\.d\.ts$/, ".js");
|
|
2584
2670
|
if (this.fileExists(jsFile)) {
|
|
2585
|
-
return __spreadProps(__spreadValues({}, resolvedModule), { resolvedFileName: jsFile, extension:
|
|
2671
|
+
return __spreadProps(__spreadValues({}, resolvedModule), { resolvedFileName: jsFile, extension: ts10.Extension.Js });
|
|
2586
2672
|
}
|
|
2587
2673
|
}
|
|
2588
|
-
if ((resolvedModule == null ? void 0 : resolvedModule.extension) ===
|
|
2674
|
+
if ((resolvedModule == null ? void 0 : resolvedModule.extension) === ts10.Extension.Js && !isWithinPackage(this.packagePath, this.fs.resolve(resolvedModule.resolvedFileName))) {
|
|
2589
2675
|
return void 0;
|
|
2590
2676
|
}
|
|
2591
2677
|
return resolvedModule;
|
|
@@ -2603,18 +2689,18 @@ var NgccDtsCompilerHost = class extends NgtscCompilerHost {
|
|
|
2603
2689
|
}
|
|
2604
2690
|
resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference) {
|
|
2605
2691
|
return moduleNames.map((moduleName) => {
|
|
2606
|
-
const { resolvedModule } =
|
|
2692
|
+
const { resolvedModule } = ts10.resolveModuleName(moduleName, containingFile, this.options, this, this.moduleResolutionCache, redirectedReference);
|
|
2607
2693
|
return resolvedModule;
|
|
2608
2694
|
});
|
|
2609
2695
|
}
|
|
2610
2696
|
};
|
|
2611
2697
|
|
|
2612
2698
|
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/ngcc/src/packages/source_file_cache.mjs
|
|
2613
|
-
import
|
|
2699
|
+
import ts11 from "typescript";
|
|
2614
2700
|
var SharedFileCache = class {
|
|
2615
2701
|
constructor(fs) {
|
|
2616
2702
|
this.fs = fs;
|
|
2617
|
-
this.sfCache = new Map();
|
|
2703
|
+
this.sfCache = /* @__PURE__ */ new Map();
|
|
2618
2704
|
}
|
|
2619
2705
|
getCachedSourceFile(fileName) {
|
|
2620
2706
|
const absPath = this.fs.resolve(fileName);
|
|
@@ -2632,7 +2718,7 @@ var SharedFileCache = class {
|
|
|
2632
2718
|
if (content === void 0) {
|
|
2633
2719
|
return void 0;
|
|
2634
2720
|
}
|
|
2635
|
-
const sf =
|
|
2721
|
+
const sf = ts11.createSourceFile(absPath, content, ts11.ScriptTarget.ES2015);
|
|
2636
2722
|
this.sfCache.set(absPath, sf);
|
|
2637
2723
|
}
|
|
2638
2724
|
return this.sfCache.get(absPath);
|
|
@@ -2643,7 +2729,7 @@ var SharedFileCache = class {
|
|
|
2643
2729
|
return void 0;
|
|
2644
2730
|
}
|
|
2645
2731
|
if (!this.sfCache.has(absPath) || this.sfCache.get(absPath).text !== content) {
|
|
2646
|
-
const sf =
|
|
2732
|
+
const sf = ts11.createSourceFile(absPath, content, ts11.ScriptTarget.ES2015);
|
|
2647
2733
|
this.sfCache.set(absPath, sf);
|
|
2648
2734
|
}
|
|
2649
2735
|
return this.sfCache.get(absPath);
|
|
@@ -2678,7 +2764,7 @@ var EntryPointFileCache = class {
|
|
|
2678
2764
|
constructor(fs, sharedFileCache) {
|
|
2679
2765
|
this.fs = fs;
|
|
2680
2766
|
this.sharedFileCache = sharedFileCache;
|
|
2681
|
-
this.sfCache = new Map();
|
|
2767
|
+
this.sfCache = /* @__PURE__ */ new Map();
|
|
2682
2768
|
}
|
|
2683
2769
|
getCachedSourceFile(fileName, languageVersion) {
|
|
2684
2770
|
const staticSf = this.sharedFileCache.getCachedSourceFile(fileName);
|
|
@@ -2693,7 +2779,7 @@ var EntryPointFileCache = class {
|
|
|
2693
2779
|
if (content === void 0) {
|
|
2694
2780
|
return void 0;
|
|
2695
2781
|
}
|
|
2696
|
-
const sf =
|
|
2782
|
+
const sf = ts11.createSourceFile(fileName, content, languageVersion);
|
|
2697
2783
|
this.sfCache.set(absPath, sf);
|
|
2698
2784
|
return sf;
|
|
2699
2785
|
}
|
|
@@ -2705,7 +2791,7 @@ function readFile(absPath, fs) {
|
|
|
2705
2791
|
return fs.readFile(absPath);
|
|
2706
2792
|
}
|
|
2707
2793
|
function createModuleResolutionCache(fs) {
|
|
2708
|
-
return
|
|
2794
|
+
return ts11.createModuleResolutionCache(fs.pwd(), (fileName) => {
|
|
2709
2795
|
return fs.isCaseSensitive() ? fileName : fileName.toLowerCase();
|
|
2710
2796
|
});
|
|
2711
2797
|
}
|
|
@@ -2752,13 +2838,13 @@ function computePotentialDtsFilesFromJsFiles(fs, srcProgram, formatPath, typings
|
|
|
2752
2838
|
}
|
|
2753
2839
|
|
|
2754
2840
|
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/ngcc/src/packages/transformer.mjs
|
|
2755
|
-
import
|
|
2841
|
+
import ts21 from "typescript";
|
|
2756
2842
|
|
|
2757
2843
|
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/ngcc/src/analysis/decoration_analyzer.mjs
|
|
2758
2844
|
import { ConstantPool } from "@angular/compiler";
|
|
2759
2845
|
|
|
2760
2846
|
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/ngcc/src/migrations/utils.mjs
|
|
2761
|
-
import
|
|
2847
|
+
import ts12 from "typescript";
|
|
2762
2848
|
function isClassDeclaration(clazz) {
|
|
2763
2849
|
return isNamedClassDeclaration(clazz) || isNamedFunctionDeclaration(clazz) || isNamedVariableDeclaration(clazz);
|
|
2764
2850
|
}
|
|
@@ -2783,7 +2869,7 @@ function createDirectiveDecorator(clazz, metadata) {
|
|
|
2783
2869
|
if (metadata.exportAs !== null) {
|
|
2784
2870
|
metaArgs.push(property("exportAs", metadata.exportAs.join(", ")));
|
|
2785
2871
|
}
|
|
2786
|
-
args.push(reifySourceFile(
|
|
2872
|
+
args.push(reifySourceFile(ts12.createObjectLiteral(metaArgs)));
|
|
2787
2873
|
}
|
|
2788
2874
|
return {
|
|
2789
2875
|
name: "Directive",
|
|
@@ -2811,7 +2897,7 @@ function createComponentDecorator(clazz, metadata) {
|
|
|
2811
2897
|
node: null,
|
|
2812
2898
|
synthesizedFor: clazz.name,
|
|
2813
2899
|
args: [
|
|
2814
|
-
reifySourceFile(
|
|
2900
|
+
reifySourceFile(ts12.createObjectLiteral(metaArgs))
|
|
2815
2901
|
]
|
|
2816
2902
|
};
|
|
2817
2903
|
}
|
|
@@ -2826,16 +2912,16 @@ function createInjectableDecorator(clazz) {
|
|
|
2826
2912
|
};
|
|
2827
2913
|
}
|
|
2828
2914
|
function property(name, value) {
|
|
2829
|
-
return
|
|
2915
|
+
return ts12.createPropertyAssignment(name, ts12.createStringLiteral(value));
|
|
2830
2916
|
}
|
|
2831
|
-
var EMPTY_SF =
|
|
2917
|
+
var EMPTY_SF = ts12.createSourceFile("(empty)", "", ts12.ScriptTarget.Latest);
|
|
2832
2918
|
function reifySourceFile(expr) {
|
|
2833
|
-
const printer =
|
|
2834
|
-
const exprText = printer.printNode(
|
|
2835
|
-
const sf =
|
|
2919
|
+
const printer = ts12.createPrinter();
|
|
2920
|
+
const exprText = printer.printNode(ts12.EmitHint.Unspecified, expr, EMPTY_SF);
|
|
2921
|
+
const sf = ts12.createSourceFile("(synthetic)", `const expr = ${exprText};`, ts12.ScriptTarget.Latest, true, ts12.ScriptKind.JS);
|
|
2836
2922
|
const stmt = sf.statements[0];
|
|
2837
|
-
if (!
|
|
2838
|
-
throw new Error(`Expected VariableStatement, got ${
|
|
2923
|
+
if (!ts12.isVariableStatement(stmt)) {
|
|
2924
|
+
throw new Error(`Expected VariableStatement, got ${ts12.SyntaxKind[stmt.kind]}`);
|
|
2839
2925
|
}
|
|
2840
2926
|
return stmt.declarationList.declarations[0].initializer;
|
|
2841
2927
|
}
|
|
@@ -2924,7 +3010,7 @@ function migrateProviderClass(provider, host) {
|
|
|
2924
3010
|
host.injectSyntheticDecorator(clazz, createInjectableDecorator(clazz));
|
|
2925
3011
|
}
|
|
2926
3012
|
}
|
|
2927
|
-
var NO_MIGRATE_DECORATORS = new Set(["Injectable", "Directive", "Component", "Pipe"]);
|
|
3013
|
+
var NO_MIGRATE_DECORATORS = /* @__PURE__ */ new Set(["Injectable", "Directive", "Component", "Pipe"]);
|
|
2928
3014
|
function needsInjectableDecorator(clazz, host) {
|
|
2929
3015
|
const decorators = host.getAllDecorators(clazz);
|
|
2930
3016
|
if (decorators === null) {
|
|
@@ -3014,7 +3100,7 @@ function determineBaseClass(clazz, host) {
|
|
|
3014
3100
|
}
|
|
3015
3101
|
|
|
3016
3102
|
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/ngcc/src/analysis/migration_host.mjs
|
|
3017
|
-
import
|
|
3103
|
+
import ts13 from "typescript";
|
|
3018
3104
|
var DefaultMigrationHost = class {
|
|
3019
3105
|
constructor(reflectionHost, metadata, evaluator, compiler, entryPointPath) {
|
|
3020
3106
|
this.reflectionHost = reflectionHost;
|
|
@@ -3045,14 +3131,14 @@ function createMigrationDiagnostic(diagnostic, source, decorator) {
|
|
|
3045
3131
|
const clone = __spreadValues({}, diagnostic);
|
|
3046
3132
|
const chain = [{
|
|
3047
3133
|
messageText: `Occurs for @${decorator.name} decorator inserted by an automatic migration`,
|
|
3048
|
-
category:
|
|
3134
|
+
category: ts13.DiagnosticCategory.Message,
|
|
3049
3135
|
code: 0
|
|
3050
3136
|
}];
|
|
3051
3137
|
if (decorator.args !== null) {
|
|
3052
3138
|
const args = decorator.args.map((arg) => arg.getText()).join(", ");
|
|
3053
3139
|
chain.push({
|
|
3054
3140
|
messageText: `@${decorator.name}(${args})`,
|
|
3055
|
-
category:
|
|
3141
|
+
category: ts13.DiagnosticCategory.Message,
|
|
3056
3142
|
code: 0
|
|
3057
3143
|
});
|
|
3058
3144
|
}
|
|
@@ -3278,7 +3364,7 @@ var DecorationAnalyzer = class {
|
|
|
3278
3364
|
};
|
|
3279
3365
|
|
|
3280
3366
|
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/ngcc/src/analysis/module_with_providers_analyzer.mjs
|
|
3281
|
-
import
|
|
3367
|
+
import ts14 from "typescript";
|
|
3282
3368
|
var ModuleWithProvidersAnalyses = Map;
|
|
3283
3369
|
var ModuleWithProvidersAnalyzer = class {
|
|
3284
3370
|
constructor(host, typeChecker, referencesRegistry, processDts) {
|
|
@@ -3300,7 +3386,7 @@ var ModuleWithProvidersAnalyzer = class {
|
|
|
3300
3386
|
if (this.processDts) {
|
|
3301
3387
|
const dtsFn = this.getDtsModuleWithProvidersFunction(fn);
|
|
3302
3388
|
const dtsFnType = dtsFn.declaration.type;
|
|
3303
|
-
const typeParam = dtsFnType &&
|
|
3389
|
+
const typeParam = dtsFnType && ts14.isTypeReferenceNode(dtsFnType) && dtsFnType.typeArguments && dtsFnType.typeArguments[0] || null;
|
|
3304
3390
|
if (!typeParam || isAnyKeyword(typeParam)) {
|
|
3305
3391
|
const dtsFile = dtsFn.declaration.getSourceFile();
|
|
3306
3392
|
const analysis = analyses.has(dtsFile) ? analyses.get(dtsFile) : [];
|
|
@@ -3345,7 +3431,7 @@ var ModuleWithProvidersAnalyzer = class {
|
|
|
3345
3431
|
return infos;
|
|
3346
3432
|
}
|
|
3347
3433
|
parseForModuleWithProviders(name, node, implementation = node, container = null) {
|
|
3348
|
-
if (implementation === null || !
|
|
3434
|
+
if (implementation === null || !ts14.isFunctionDeclaration(implementation) && !ts14.isMethodDeclaration(implementation) && !ts14.isFunctionExpression(implementation)) {
|
|
3349
3435
|
return null;
|
|
3350
3436
|
}
|
|
3351
3437
|
const declaration = implementation;
|
|
@@ -3358,7 +3444,7 @@ var ModuleWithProvidersAnalyzer = class {
|
|
|
3358
3444
|
return null;
|
|
3359
3445
|
}
|
|
3360
3446
|
const lastStatement = body[body.length - 1];
|
|
3361
|
-
if (!
|
|
3447
|
+
if (!ts14.isReturnStatement(lastStatement) || lastStatement.expression === void 0) {
|
|
3362
3448
|
return null;
|
|
3363
3449
|
}
|
|
3364
3450
|
const result = this.evaluator.evaluate(lastStatement.expression);
|
|
@@ -3380,7 +3466,7 @@ var ModuleWithProvidersAnalyzer = class {
|
|
|
3380
3466
|
const containerClass = fn.container && this.host.getClassSymbol(fn.container);
|
|
3381
3467
|
if (containerClass) {
|
|
3382
3468
|
const dtsClass = this.host.getDtsDeclaration(containerClass.declaration.valueDeclaration);
|
|
3383
|
-
dtsFn = dtsClass &&
|
|
3469
|
+
dtsFn = dtsClass && ts14.isClassDeclaration(dtsClass) ? dtsClass.members.find((member) => ts14.isMethodDeclaration(member) && ts14.isIdentifier(member.name) && member.name.text === fn.name) : null;
|
|
3384
3470
|
} else {
|
|
3385
3471
|
dtsFn = this.host.getDtsDeclaration(fn.declaration);
|
|
3386
3472
|
}
|
|
@@ -3410,17 +3496,17 @@ var ModuleWithProvidersAnalyzer = class {
|
|
|
3410
3496
|
}
|
|
3411
3497
|
};
|
|
3412
3498
|
function isFunctionOrMethod(declaration) {
|
|
3413
|
-
return
|
|
3499
|
+
return ts14.isFunctionDeclaration(declaration) || ts14.isMethodDeclaration(declaration);
|
|
3414
3500
|
}
|
|
3415
3501
|
function isAnyKeyword(typeParam) {
|
|
3416
|
-
return typeParam.kind ===
|
|
3502
|
+
return typeParam.kind === ts14.SyntaxKind.AnyKeyword;
|
|
3417
3503
|
}
|
|
3418
3504
|
|
|
3419
3505
|
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/ngcc/src/analysis/ngcc_references_registry.mjs
|
|
3420
3506
|
var NgccReferencesRegistry = class {
|
|
3421
3507
|
constructor(host) {
|
|
3422
3508
|
this.host = host;
|
|
3423
|
-
this.map = new Map();
|
|
3509
|
+
this.map = /* @__PURE__ */ new Map();
|
|
3424
3510
|
}
|
|
3425
3511
|
add(source, ...references) {
|
|
3426
3512
|
references.forEach((ref) => {
|
|
@@ -3478,27 +3564,8 @@ var PrivateDeclarationsAnalyzer = class {
|
|
|
3478
3564
|
}
|
|
3479
3565
|
};
|
|
3480
3566
|
|
|
3481
|
-
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/ngcc/src/analysis/switch_marker_analyzer.mjs
|
|
3482
|
-
var SwitchMarkerAnalyses = Map;
|
|
3483
|
-
var SwitchMarkerAnalyzer = class {
|
|
3484
|
-
constructor(host, packagePath) {
|
|
3485
|
-
this.host = host;
|
|
3486
|
-
this.packagePath = packagePath;
|
|
3487
|
-
}
|
|
3488
|
-
analyzeProgram(program) {
|
|
3489
|
-
const analyzedFiles = new SwitchMarkerAnalyses();
|
|
3490
|
-
program.getSourceFiles().filter((sourceFile) => isWithinPackage(this.packagePath, absoluteFromSourceFile(sourceFile))).forEach((sourceFile) => {
|
|
3491
|
-
const declarations = this.host.getSwitchableDeclarations(sourceFile);
|
|
3492
|
-
if (declarations.length) {
|
|
3493
|
-
analyzedFiles.set(sourceFile, { sourceFile, declarations });
|
|
3494
|
-
}
|
|
3495
|
-
});
|
|
3496
|
-
return analyzedFiles;
|
|
3497
|
-
}
|
|
3498
|
-
};
|
|
3499
|
-
|
|
3500
3567
|
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/ngcc/src/host/commonjs_host.mjs
|
|
3501
|
-
import
|
|
3568
|
+
import ts15 from "typescript";
|
|
3502
3569
|
var CommonJsReflectionHost = class extends Esm5ReflectionHost {
|
|
3503
3570
|
constructor(logger, isCore, src, dts = null) {
|
|
3504
3571
|
super(logger, isCore, src, dts);
|
|
@@ -3538,7 +3605,7 @@ var CommonJsReflectionHost = class extends Esm5ReflectionHost {
|
|
|
3538
3605
|
return calls;
|
|
3539
3606
|
}
|
|
3540
3607
|
computeExportsOfCommonJsModule(sourceFile) {
|
|
3541
|
-
const moduleMap = new Map();
|
|
3608
|
+
const moduleMap = /* @__PURE__ */ new Map();
|
|
3542
3609
|
for (const statement of this.getModuleStatements(sourceFile)) {
|
|
3543
3610
|
if (isExportsStatement(statement)) {
|
|
3544
3611
|
const exportDeclaration = this.extractBasicCommonJsExportDeclaration(statement);
|
|
@@ -3572,7 +3639,7 @@ var CommonJsReflectionHost = class extends Esm5ReflectionHost {
|
|
|
3572
3639
|
}
|
|
3573
3640
|
extractCommonJsWildcardReexports(statement, containingFile) {
|
|
3574
3641
|
const reexportArg = statement.expression.arguments[0];
|
|
3575
|
-
const requireCall = isRequireCall(reexportArg) ? reexportArg :
|
|
3642
|
+
const requireCall = isRequireCall(reexportArg) ? reexportArg : ts15.isIdentifier(reexportArg) ? findRequireCallReference(reexportArg, this.checker) : null;
|
|
3576
3643
|
if (requireCall === null) {
|
|
3577
3644
|
return [];
|
|
3578
3645
|
}
|
|
@@ -3655,7 +3722,7 @@ var CommonJsReflectionHost = class extends Esm5ReflectionHost {
|
|
|
3655
3722
|
const moduleInfo = this.compilerHost.resolveModuleNames([moduleName], containingFile.fileName, void 0, void 0, this.program.getCompilerOptions())[0];
|
|
3656
3723
|
return moduleInfo && this.program.getSourceFile(absoluteFrom(moduleInfo.resolvedFileName));
|
|
3657
3724
|
} else {
|
|
3658
|
-
const moduleInfo =
|
|
3725
|
+
const moduleInfo = ts15.resolveModuleName(moduleName, containingFile.fileName, this.program.getCompilerOptions(), this.compilerHost);
|
|
3659
3726
|
return moduleInfo.resolvedModule && this.program.getSourceFile(absoluteFrom(moduleInfo.resolvedModule.resolvedFileName));
|
|
3660
3727
|
}
|
|
3661
3728
|
}
|
|
@@ -3771,9 +3838,6 @@ var DelegatingReflectionHost = class {
|
|
|
3771
3838
|
getDecoratorsOfSymbol(symbol) {
|
|
3772
3839
|
return this.ngccHost.getDecoratorsOfSymbol(symbol);
|
|
3773
3840
|
}
|
|
3774
|
-
getSwitchableDeclarations(module) {
|
|
3775
|
-
return this.ngccHost.getSwitchableDeclarations(module);
|
|
3776
|
-
}
|
|
3777
3841
|
getEndOfClass(classSymbol) {
|
|
3778
3842
|
return this.ngccHost.getEndOfClass(classSymbol);
|
|
3779
3843
|
}
|
|
@@ -3786,13 +3850,13 @@ var DelegatingReflectionHost = class {
|
|
|
3786
3850
|
};
|
|
3787
3851
|
|
|
3788
3852
|
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/ngcc/src/rendering/commonjs_rendering_formatter.mjs
|
|
3789
|
-
import
|
|
3853
|
+
import ts18 from "typescript";
|
|
3790
3854
|
|
|
3791
3855
|
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/ngcc/src/rendering/esm5_rendering_formatter.mjs
|
|
3792
|
-
import
|
|
3856
|
+
import ts17 from "typescript";
|
|
3793
3857
|
|
|
3794
3858
|
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/ngcc/src/rendering/esm_rendering_formatter.mjs
|
|
3795
|
-
import
|
|
3859
|
+
import ts16 from "typescript";
|
|
3796
3860
|
|
|
3797
3861
|
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/ngcc/src/rendering/ngcc_import_rewriter.mjs
|
|
3798
3862
|
var NgccFlatImportRewriter = class {
|
|
@@ -3835,7 +3899,7 @@ var EsmRenderingFormatter = class {
|
|
|
3835
3899
|
this.fs = fs;
|
|
3836
3900
|
this.host = host;
|
|
3837
3901
|
this.isCore = isCore;
|
|
3838
|
-
this.printer =
|
|
3902
|
+
this.printer = ts16.createPrinter({ newLine: ts16.NewLineKind.LineFeed });
|
|
3839
3903
|
}
|
|
3840
3904
|
addImports(output, imports, sf) {
|
|
3841
3905
|
if (imports.length === 0) {
|
|
@@ -3895,14 +3959,14 @@ export {${e.symbolName} as ${e.asAlias}} from '${e.fromModule}';`;
|
|
|
3895
3959
|
}
|
|
3896
3960
|
removeDecorators(output, decoratorsToRemove) {
|
|
3897
3961
|
decoratorsToRemove.forEach((nodesToRemove, containerNode) => {
|
|
3898
|
-
if (
|
|
3962
|
+
if (ts16.isArrayLiteralExpression(containerNode)) {
|
|
3899
3963
|
const items = containerNode.elements;
|
|
3900
3964
|
if (items.length === nodesToRemove.length) {
|
|
3901
3965
|
const statement = findStatement(containerNode);
|
|
3902
3966
|
if (statement) {
|
|
3903
|
-
if (
|
|
3967
|
+
if (ts16.isExpressionStatement(statement)) {
|
|
3904
3968
|
output.remove(statement.getFullStart(), statement.getEnd());
|
|
3905
|
-
} else if (
|
|
3969
|
+
} else if (ts16.isReturnStatement(statement) && statement.expression && isAssignment2(statement.expression)) {
|
|
3906
3970
|
const startOfRemoval = statement.expression.left.getEnd();
|
|
3907
3971
|
const endOfRemoval = getEndExceptSemicolon(statement);
|
|
3908
3972
|
output.remove(startOfRemoval, endOfRemoval);
|
|
@@ -3925,14 +3989,6 @@ export {${e.symbolName} as ${e.asAlias}} from '${e.fromModule}';`;
|
|
|
3925
3989
|
}
|
|
3926
3990
|
});
|
|
3927
3991
|
}
|
|
3928
|
-
rewriteSwitchableDeclarations(outputText, sourceFile, declarations) {
|
|
3929
|
-
declarations.forEach((declaration) => {
|
|
3930
|
-
const start = declaration.initializer.getStart();
|
|
3931
|
-
const end = declaration.initializer.getEnd();
|
|
3932
|
-
const replacement = declaration.initializer.text.replace(PRE_R3_MARKER, POST_R3_MARKER);
|
|
3933
|
-
outputText.overwrite(start, end, replacement);
|
|
3934
|
-
});
|
|
3935
|
-
}
|
|
3936
3992
|
addModuleWithProvidersParams(outputText, moduleWithProviders, importManager) {
|
|
3937
3993
|
moduleWithProviders.forEach((info) => {
|
|
3938
3994
|
const ngModuleName = info.ngModule.node.name.text;
|
|
@@ -3943,7 +3999,7 @@ export {${e.symbolName} as ${e.asAlias}} from '${e.fromModule}';`;
|
|
|
3943
3999
|
const importPath = info.ngModule.ownedByModuleGuess || (declarationFile !== ngModuleFile ? stripExtension2(relativeImport) : null);
|
|
3944
4000
|
const ngModule = generateImportString(importManager, importPath, ngModuleName);
|
|
3945
4001
|
if (info.declaration.type) {
|
|
3946
|
-
const typeName = info.declaration.type &&
|
|
4002
|
+
const typeName = info.declaration.type && ts16.isTypeReferenceNode(info.declaration.type) ? info.declaration.type.typeName : null;
|
|
3947
4003
|
if (this.isCoreModuleWithProvidersType(typeName)) {
|
|
3948
4004
|
outputText.overwrite(info.declaration.type.getStart(), info.declaration.type.getEnd(), `ModuleWithProviders<${ngModule}>`);
|
|
3949
4005
|
} else {
|
|
@@ -3952,32 +4008,32 @@ export {${e.symbolName} as ${e.asAlias}} from '${e.fromModule}';`;
|
|
|
3952
4008
|
}
|
|
3953
4009
|
} else {
|
|
3954
4010
|
const lastToken = info.declaration.getLastToken();
|
|
3955
|
-
const insertPoint = lastToken && lastToken.kind ===
|
|
4011
|
+
const insertPoint = lastToken && lastToken.kind === ts16.SyntaxKind.SemicolonToken ? lastToken.getStart() : info.declaration.getEnd();
|
|
3956
4012
|
outputText.appendLeft(insertPoint, `: ${generateImportString(importManager, "@angular/core", "ModuleWithProviders")}<${ngModule}>`);
|
|
3957
4013
|
}
|
|
3958
4014
|
});
|
|
3959
4015
|
}
|
|
3960
4016
|
printStatement(stmt, sourceFile, importManager) {
|
|
3961
4017
|
const node = translateStatement(stmt, importManager);
|
|
3962
|
-
const code = this.printer.printNode(
|
|
4018
|
+
const code = this.printer.printNode(ts16.EmitHint.Unspecified, node, sourceFile);
|
|
3963
4019
|
return code;
|
|
3964
4020
|
}
|
|
3965
4021
|
findEndOfImports(sf) {
|
|
3966
4022
|
for (const stmt of sf.statements) {
|
|
3967
|
-
if (!
|
|
4023
|
+
if (!ts16.isImportDeclaration(stmt) && !ts16.isImportEqualsDeclaration(stmt) && !ts16.isNamespaceImport(stmt)) {
|
|
3968
4024
|
return stmt.getStart();
|
|
3969
4025
|
}
|
|
3970
4026
|
}
|
|
3971
4027
|
return 0;
|
|
3972
4028
|
}
|
|
3973
4029
|
isCoreModuleWithProvidersType(typeName) {
|
|
3974
|
-
const id = typeName &&
|
|
4030
|
+
const id = typeName && ts16.isIdentifier(typeName) ? this.host.getImportOfIdentifier(typeName) : null;
|
|
3975
4031
|
return id && id.name === "ModuleWithProviders" && (this.isCore || id.from === "@angular/core");
|
|
3976
4032
|
}
|
|
3977
4033
|
};
|
|
3978
4034
|
function findStatement(node) {
|
|
3979
4035
|
while (node) {
|
|
3980
|
-
if (
|
|
4036
|
+
if (ts16.isExpressionStatement(node) || ts16.isReturnStatement(node)) {
|
|
3981
4037
|
return node;
|
|
3982
4038
|
}
|
|
3983
4039
|
node = node.parent;
|
|
@@ -3994,7 +4050,7 @@ function getNextSiblingInArray(node, array) {
|
|
|
3994
4050
|
}
|
|
3995
4051
|
function getEndExceptSemicolon(statement) {
|
|
3996
4052
|
const lastToken = statement.getLastToken();
|
|
3997
|
-
return lastToken && lastToken.kind ===
|
|
4053
|
+
return lastToken && lastToken.kind === ts16.SyntaxKind.SemicolonToken ? statement.getEnd() - 1 : statement.getEnd();
|
|
3998
4054
|
}
|
|
3999
4055
|
|
|
4000
4056
|
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/ngcc/src/rendering/esm5_rendering_formatter.mjs
|
|
@@ -4008,10 +4064,10 @@ Expected an ES5 IIFE wrapped function. But got:
|
|
|
4008
4064
|
}
|
|
4009
4065
|
const declarationStatement = getContainingStatement(classSymbol.implementation.valueDeclaration);
|
|
4010
4066
|
const iifeBody = declarationStatement.parent;
|
|
4011
|
-
if (!iifeBody || !
|
|
4067
|
+
if (!iifeBody || !ts17.isBlock(iifeBody)) {
|
|
4012
4068
|
throw new Error(`Compiled class declaration is not inside an IIFE: ${compiledClass.name} in ${compiledClass.declaration.getSourceFile().fileName}`);
|
|
4013
4069
|
}
|
|
4014
|
-
const returnStatement = iifeBody.statements.find(
|
|
4070
|
+
const returnStatement = iifeBody.statements.find(ts17.isReturnStatement);
|
|
4015
4071
|
if (!returnStatement) {
|
|
4016
4072
|
throw new Error(`Compiled class wrapper IIFE does not have a return statement: ${compiledClass.name} in ${compiledClass.declaration.getSourceFile().fileName}`);
|
|
4017
4073
|
}
|
|
@@ -4020,7 +4076,7 @@ Expected an ES5 IIFE wrapped function. But got:
|
|
|
4020
4076
|
}
|
|
4021
4077
|
printStatement(stmt, sourceFile, importManager) {
|
|
4022
4078
|
const node = translateStatement(stmt, importManager, { downlevelTaggedTemplates: true, downlevelVariableDeclarations: true });
|
|
4023
|
-
const code = this.printer.printNode(
|
|
4079
|
+
const code = this.printer.printNode(ts17.EmitHint.Unspecified, node, sourceFile);
|
|
4024
4080
|
return code;
|
|
4025
4081
|
}
|
|
4026
4082
|
};
|
|
@@ -4062,10 +4118,10 @@ exports.${e.asAlias} = ${importNamespace}${namedImport.symbol};`;
|
|
|
4062
4118
|
}
|
|
4063
4119
|
findEndOfImports(sf) {
|
|
4064
4120
|
for (const statement of sf.statements) {
|
|
4065
|
-
if (
|
|
4121
|
+
if (ts18.isExpressionStatement(statement) && isRequireCall(statement.expression)) {
|
|
4066
4122
|
continue;
|
|
4067
4123
|
}
|
|
4068
|
-
const declarations =
|
|
4124
|
+
const declarations = ts18.isVariableStatement(statement) ? Array.from(statement.declarationList.declarations) : [];
|
|
4069
4125
|
if (declarations.some((d) => !d.initializer || !isRequireCall(d.initializer))) {
|
|
4070
4126
|
return statement.getStart();
|
|
4071
4127
|
}
|
|
@@ -4076,7 +4132,7 @@ exports.${e.asAlias} = ${importNamespace}${namedImport.symbol};`;
|
|
|
4076
4132
|
|
|
4077
4133
|
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/ngcc/src/rendering/dts_renderer.mjs
|
|
4078
4134
|
import MagicString from "magic-string";
|
|
4079
|
-
import
|
|
4135
|
+
import ts19 from "typescript";
|
|
4080
4136
|
|
|
4081
4137
|
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/ngcc/src/constants.mjs
|
|
4082
4138
|
var IMPORT_PREFIX = "\u0275ngcc";
|
|
@@ -4147,14 +4203,14 @@ var DtsRenderer = class {
|
|
|
4147
4203
|
}
|
|
4148
4204
|
renderDtsFile(dtsFile, renderInfo) {
|
|
4149
4205
|
const outputText = new MagicString(dtsFile.text);
|
|
4150
|
-
const printer =
|
|
4206
|
+
const printer = ts19.createPrinter();
|
|
4151
4207
|
const importManager = new ImportManager(getImportRewriter(this.bundle.dts.r3SymbolsFile, this.bundle.isCore, false), IMPORT_PREFIX);
|
|
4152
4208
|
renderInfo.classInfo.forEach((dtsClass) => {
|
|
4153
4209
|
const endOfClass = dtsClass.dtsDeclaration.getEnd();
|
|
4154
4210
|
dtsClass.compilation.forEach((declaration) => {
|
|
4155
4211
|
const type = translateType(declaration.type, importManager);
|
|
4156
4212
|
markForEmitAsSingleLine(type);
|
|
4157
|
-
const typeStr = printer.printNode(
|
|
4213
|
+
const typeStr = printer.printNode(ts19.EmitHint.Unspecified, type, dtsFile);
|
|
4158
4214
|
const newStatement = ` static ${declaration.name}: ${typeStr};
|
|
4159
4215
|
`;
|
|
4160
4216
|
outputText.appendRight(endOfClass - 1, newStatement);
|
|
@@ -4173,7 +4229,7 @@ export {${e.symbolName} as ${e.asAlias}} from '${e.fromModule}';`;
|
|
|
4173
4229
|
return renderSourceAndMap(this.logger, this.fs, dtsFile, outputText);
|
|
4174
4230
|
}
|
|
4175
4231
|
getTypingsFilesToRender(decorationAnalyses, privateDeclarationsAnalyses, moduleWithProvidersAnalyses) {
|
|
4176
|
-
const dtsMap = new Map();
|
|
4232
|
+
const dtsMap = /* @__PURE__ */ new Map();
|
|
4177
4233
|
decorationAnalyses.forEach((compiledFile) => {
|
|
4178
4234
|
let appliedReexports = false;
|
|
4179
4235
|
compiledFile.compiledClasses.forEach((compiledClass) => {
|
|
@@ -4214,8 +4270,8 @@ The simplest fix for this is to ensure that this class is exported from the pack
|
|
|
4214
4270
|
}
|
|
4215
4271
|
};
|
|
4216
4272
|
function markForEmitAsSingleLine(node) {
|
|
4217
|
-
|
|
4218
|
-
|
|
4273
|
+
ts19.setEmitFlags(node, ts19.EmitFlags.SingleLine);
|
|
4274
|
+
ts19.forEachChild(node, markForEmitAsSingleLine);
|
|
4219
4275
|
}
|
|
4220
4276
|
|
|
4221
4277
|
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/ngcc/src/rendering/renderer.mjs
|
|
@@ -4235,23 +4291,19 @@ var Renderer = class {
|
|
|
4235
4291
|
this.bundle = bundle;
|
|
4236
4292
|
this.tsConfig = tsConfig;
|
|
4237
4293
|
}
|
|
4238
|
-
renderProgram(decorationAnalyses,
|
|
4294
|
+
renderProgram(decorationAnalyses, privateDeclarationsAnalyses) {
|
|
4239
4295
|
const renderedFiles = [];
|
|
4240
4296
|
this.bundle.src.program.getSourceFiles().forEach((sourceFile) => {
|
|
4241
|
-
if (decorationAnalyses.has(sourceFile) ||
|
|
4297
|
+
if (decorationAnalyses.has(sourceFile) || sourceFile === this.bundle.src.file) {
|
|
4242
4298
|
const compiledFile = decorationAnalyses.get(sourceFile);
|
|
4243
|
-
|
|
4244
|
-
renderedFiles.push(...this.renderFile(sourceFile, compiledFile, switchMarkerAnalysis, privateDeclarationsAnalyses));
|
|
4299
|
+
renderedFiles.push(...this.renderFile(sourceFile, compiledFile, privateDeclarationsAnalyses));
|
|
4245
4300
|
}
|
|
4246
4301
|
});
|
|
4247
4302
|
return renderedFiles;
|
|
4248
4303
|
}
|
|
4249
|
-
renderFile(sourceFile, compiledFile,
|
|
4304
|
+
renderFile(sourceFile, compiledFile, privateDeclarationsAnalyses) {
|
|
4250
4305
|
const isEntryPoint2 = sourceFile === this.bundle.src.file;
|
|
4251
4306
|
const outputText = new MagicString2(sourceFile.text);
|
|
4252
|
-
if (switchMarkerAnalysis) {
|
|
4253
|
-
this.srcFormatter.rewriteSwitchableDeclarations(outputText, switchMarkerAnalysis.sourceFile, switchMarkerAnalysis.declarations);
|
|
4254
|
-
}
|
|
4255
4307
|
const importManager = new ImportManager(getImportRewriter(this.bundle.src.r3SymbolsFile, this.bundle.isCore, this.bundle.isFlatCore), IMPORT_PREFIX);
|
|
4256
4308
|
if (compiledFile) {
|
|
4257
4309
|
const decoratorsToRemove = this.computeDecoratorsToRemove(compiledFile.compiledClasses);
|
|
@@ -4275,7 +4327,7 @@ var Renderer = class {
|
|
|
4275
4327
|
if (isEntryPoint2 || compiledFile) {
|
|
4276
4328
|
this.srcFormatter.addImports(outputText, importManager.getAllImports(sourceFile.fileName), sourceFile);
|
|
4277
4329
|
}
|
|
4278
|
-
if (compiledFile ||
|
|
4330
|
+
if (compiledFile || isEntryPoint2) {
|
|
4279
4331
|
return renderSourceAndMap(this.logger, this.fs, sourceFile, outputText);
|
|
4280
4332
|
} else {
|
|
4281
4333
|
return [];
|
|
@@ -4333,7 +4385,7 @@ function createAssignmentStatement(receiverName, propName, initializer, leadingC
|
|
|
4333
4385
|
}
|
|
4334
4386
|
|
|
4335
4387
|
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/ngcc/src/rendering/umd_rendering_formatter.mjs
|
|
4336
|
-
import
|
|
4388
|
+
import ts20 from "typescript";
|
|
4337
4389
|
var UmdRenderingFormatter = class extends Esm5RenderingFormatter {
|
|
4338
4390
|
constructor(fs, umdHost, isCore) {
|
|
4339
4391
|
super(fs, umdHost, isCore);
|
|
@@ -4347,10 +4399,11 @@ var UmdRenderingFormatter = class extends Esm5RenderingFormatter {
|
|
|
4347
4399
|
if (!umdModule) {
|
|
4348
4400
|
return;
|
|
4349
4401
|
}
|
|
4350
|
-
const {
|
|
4351
|
-
renderCommonJsDependencies(output,
|
|
4352
|
-
|
|
4353
|
-
|
|
4402
|
+
const { factoryFn, factoryCalls } = umdModule;
|
|
4403
|
+
renderCommonJsDependencies(output, factoryCalls.commonJs, imports);
|
|
4404
|
+
renderCommonJsDependencies(output, factoryCalls.commonJs2, imports);
|
|
4405
|
+
renderAmdDependencies(output, factoryCalls.amdDefine, imports);
|
|
4406
|
+
renderGlobalDependencies(output, factoryCalls.global, imports);
|
|
4354
4407
|
renderFactoryParameters(output, factoryFn, imports);
|
|
4355
4408
|
}
|
|
4356
4409
|
addExports(output, entryPointBasePath, exports, importManager, file) {
|
|
@@ -4401,26 +4454,22 @@ exports.${e.asAlias} = ${importNamespace}${namedImport.symbol};`;
|
|
|
4401
4454
|
output.appendLeft(insertionPoint, "\n" + constants + "\n");
|
|
4402
4455
|
}
|
|
4403
4456
|
};
|
|
4404
|
-
function renderCommonJsDependencies(output,
|
|
4405
|
-
|
|
4406
|
-
if (!conditional) {
|
|
4457
|
+
function renderCommonJsDependencies(output, factoryCall, imports) {
|
|
4458
|
+
if (factoryCall === null) {
|
|
4407
4459
|
return;
|
|
4408
4460
|
}
|
|
4409
|
-
const factoryCall = conditional.whenTrue;
|
|
4410
4461
|
const injectionPoint = factoryCall.arguments.length > 0 ? factoryCall.arguments[0].getFullStart() : factoryCall.getEnd() - 1;
|
|
4411
4462
|
const importString = imports.map((i) => `require('${i.specifier}')`).join(",");
|
|
4412
4463
|
output.appendLeft(injectionPoint, importString + (factoryCall.arguments.length > 0 ? "," : ""));
|
|
4413
4464
|
}
|
|
4414
|
-
function renderAmdDependencies(output,
|
|
4415
|
-
|
|
4416
|
-
if (!conditional) {
|
|
4465
|
+
function renderAmdDependencies(output, amdDefineCall, imports) {
|
|
4466
|
+
if (amdDefineCall === null) {
|
|
4417
4467
|
return;
|
|
4418
4468
|
}
|
|
4419
|
-
const amdDefineCall = conditional.whenTrue;
|
|
4420
4469
|
const importString = imports.map((i) => `'${i.specifier}'`).join(",");
|
|
4421
4470
|
const factoryIndex = amdDefineCall.arguments.length - 1;
|
|
4422
4471
|
const dependencyArray = amdDefineCall.arguments[factoryIndex - 1];
|
|
4423
|
-
if (dependencyArray === void 0 || !
|
|
4472
|
+
if (dependencyArray === void 0 || !ts20.isArrayLiteralExpression(dependencyArray)) {
|
|
4424
4473
|
const injectionPoint = amdDefineCall.arguments[factoryIndex].getFullStart();
|
|
4425
4474
|
output.appendLeft(injectionPoint, `[${importString}],`);
|
|
4426
4475
|
} else {
|
|
@@ -4428,14 +4477,13 @@ function renderAmdDependencies(output, wrapperFunction, imports) {
|
|
|
4428
4477
|
output.appendLeft(injectionPoint, importString + (dependencyArray.elements.length > 0 ? "," : ""));
|
|
4429
4478
|
}
|
|
4430
4479
|
}
|
|
4431
|
-
function renderGlobalDependencies(output,
|
|
4432
|
-
|
|
4433
|
-
if (!globalFactoryCall) {
|
|
4480
|
+
function renderGlobalDependencies(output, factoryCall, imports) {
|
|
4481
|
+
if (factoryCall === null) {
|
|
4434
4482
|
return;
|
|
4435
4483
|
}
|
|
4436
|
-
const injectionPoint =
|
|
4484
|
+
const injectionPoint = factoryCall.arguments.length > 0 ? factoryCall.arguments[0].getFullStart() : factoryCall.getEnd() - 1;
|
|
4437
4485
|
const importString = imports.map((i) => `global.${getGlobalIdentifier(i)}`).join(",");
|
|
4438
|
-
output.appendLeft(injectionPoint, importString + (
|
|
4486
|
+
output.appendLeft(injectionPoint, importString + (factoryCall.arguments.length > 0 ? "," : ""));
|
|
4439
4487
|
}
|
|
4440
4488
|
function renderFactoryParameters(output, factoryFunction, imports) {
|
|
4441
4489
|
const parameters = factoryFunction.parameters;
|
|
@@ -4448,60 +4496,9 @@ function renderFactoryParameters(output, factoryFunction, imports) {
|
|
|
4448
4496
|
output.appendLeft(injectionPoint, parameterString);
|
|
4449
4497
|
}
|
|
4450
4498
|
}
|
|
4451
|
-
function isCommonJSConditional(value) {
|
|
4452
|
-
if (!ts21.isConditionalExpression(value)) {
|
|
4453
|
-
return false;
|
|
4454
|
-
}
|
|
4455
|
-
if (!ts21.isBinaryExpression(value.condition) || value.condition.operatorToken.kind !== ts21.SyntaxKind.AmpersandAmpersandToken) {
|
|
4456
|
-
return false;
|
|
4457
|
-
}
|
|
4458
|
-
if (!oneOfBinaryConditions(value.condition, (exp) => isTypeOf(exp, "exports", "module"))) {
|
|
4459
|
-
return false;
|
|
4460
|
-
}
|
|
4461
|
-
if (!ts21.isCallExpression(value.whenTrue) || !ts21.isIdentifier(value.whenTrue.expression)) {
|
|
4462
|
-
return false;
|
|
4463
|
-
}
|
|
4464
|
-
return value.whenTrue.expression.text === "factory";
|
|
4465
|
-
}
|
|
4466
|
-
function isAmdConditional(value) {
|
|
4467
|
-
if (!ts21.isConditionalExpression(value)) {
|
|
4468
|
-
return false;
|
|
4469
|
-
}
|
|
4470
|
-
if (!ts21.isBinaryExpression(value.condition) || value.condition.operatorToken.kind !== ts21.SyntaxKind.AmpersandAmpersandToken) {
|
|
4471
|
-
return false;
|
|
4472
|
-
}
|
|
4473
|
-
if (!oneOfBinaryConditions(value.condition, (exp) => isTypeOf(exp, "define"))) {
|
|
4474
|
-
return false;
|
|
4475
|
-
}
|
|
4476
|
-
if (!ts21.isCallExpression(value.whenTrue) || !ts21.isIdentifier(value.whenTrue.expression)) {
|
|
4477
|
-
return false;
|
|
4478
|
-
}
|
|
4479
|
-
return value.whenTrue.expression.text === "define";
|
|
4480
|
-
}
|
|
4481
|
-
function isGlobalFactoryCall(value) {
|
|
4482
|
-
if (ts21.isCallExpression(value) && !!value.parent) {
|
|
4483
|
-
value = isCommaExpression(value.parent) ? value.parent : value;
|
|
4484
|
-
value = ts21.isParenthesizedExpression(value.parent) ? value.parent : value;
|
|
4485
|
-
return !!value.parent && ts21.isConditionalExpression(value.parent) && value.parent.whenFalse === value;
|
|
4486
|
-
} else {
|
|
4487
|
-
return false;
|
|
4488
|
-
}
|
|
4489
|
-
}
|
|
4490
|
-
function isCommaExpression(value) {
|
|
4491
|
-
return ts21.isBinaryExpression(value) && value.operatorToken.kind === ts21.SyntaxKind.CommaToken;
|
|
4492
|
-
}
|
|
4493
4499
|
function getGlobalIdentifier(i) {
|
|
4494
4500
|
return i.specifier.replace(/^@angular\//, "ng.").replace(/^@/, "").replace(/\//g, ".").replace(/[-_]+(.?)/g, (_, c) => c.toUpperCase()).replace(/^./, (c) => c.toLowerCase());
|
|
4495
4501
|
}
|
|
4496
|
-
function find(node, test) {
|
|
4497
|
-
return test(node) ? node : node.forEachChild((child) => find(child, test));
|
|
4498
|
-
}
|
|
4499
|
-
function oneOfBinaryConditions(node, test) {
|
|
4500
|
-
return test(node.left) || test(node.right);
|
|
4501
|
-
}
|
|
4502
|
-
function isTypeOf(node, ...types) {
|
|
4503
|
-
return ts21.isBinaryExpression(node) && ts21.isTypeOfExpression(node.left) && ts21.isIdentifier(node.left.expression) && types.indexOf(node.left.expression.text) !== -1;
|
|
4504
|
-
}
|
|
4505
4502
|
|
|
4506
4503
|
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/ngcc/src/packages/transformer.mjs
|
|
4507
4504
|
var Transformer = class {
|
|
@@ -4514,7 +4511,7 @@ var Transformer = class {
|
|
|
4514
4511
|
const ngccReflectionHost = this.getHost(bundle);
|
|
4515
4512
|
const tsReflectionHost = new TypeScriptReflectionHost(bundle.src.program.getTypeChecker());
|
|
4516
4513
|
const reflectionHost = new DelegatingReflectionHost(tsReflectionHost, ngccReflectionHost);
|
|
4517
|
-
const { decorationAnalyses,
|
|
4514
|
+
const { decorationAnalyses, privateDeclarationsAnalyses, moduleWithProvidersAnalyses, diagnostics } = this.analyzeProgram(reflectionHost, bundle);
|
|
4518
4515
|
if (hasErrors(diagnostics)) {
|
|
4519
4516
|
return { success: false, diagnostics };
|
|
4520
4517
|
}
|
|
@@ -4522,7 +4519,7 @@ var Transformer = class {
|
|
|
4522
4519
|
if (bundle.dtsProcessing !== DtsProcessing.Only) {
|
|
4523
4520
|
const srcFormatter = this.getRenderingFormatter(ngccReflectionHost, bundle);
|
|
4524
4521
|
const renderer = new Renderer(reflectionHost, srcFormatter, this.fs, this.logger, bundle, this.tsConfig);
|
|
4525
|
-
renderedFiles = renderer.renderProgram(decorationAnalyses,
|
|
4522
|
+
renderedFiles = renderer.renderProgram(decorationAnalyses, privateDeclarationsAnalyses);
|
|
4526
4523
|
}
|
|
4527
4524
|
if (bundle.dts) {
|
|
4528
4525
|
const dtsFormatter = new EsmRenderingFormatter(this.fs, reflectionHost, bundle.isCore);
|
|
@@ -4565,8 +4562,6 @@ var Transformer = class {
|
|
|
4565
4562
|
}
|
|
4566
4563
|
analyzeProgram(reflectionHost, bundle) {
|
|
4567
4564
|
const referencesRegistry = new NgccReferencesRegistry(reflectionHost);
|
|
4568
|
-
const switchMarkerAnalyzer = new SwitchMarkerAnalyzer(reflectionHost, bundle.entryPoint.packagePath);
|
|
4569
|
-
const switchMarkerAnalyses = switchMarkerAnalyzer.analyzeProgram(bundle.src.program);
|
|
4570
4565
|
const diagnostics = [];
|
|
4571
4566
|
const decorationAnalyzer = new DecorationAnalyzer(this.fs, bundle, reflectionHost, referencesRegistry, (diagnostic) => diagnostics.push(diagnostic), this.tsConfig);
|
|
4572
4567
|
const decorationAnalyses = decorationAnalyzer.analyzeProgram();
|
|
@@ -4576,7 +4571,6 @@ var Transformer = class {
|
|
|
4576
4571
|
const privateDeclarationsAnalyses = privateDeclarationsAnalyzer.analyzeProgram(bundle.src.program);
|
|
4577
4572
|
return {
|
|
4578
4573
|
decorationAnalyses,
|
|
4579
|
-
switchMarkerAnalyses,
|
|
4580
4574
|
privateDeclarationsAnalyses,
|
|
4581
4575
|
moduleWithProvidersAnalyses,
|
|
4582
4576
|
diagnostics
|
|
@@ -4584,7 +4578,7 @@ var Transformer = class {
|
|
|
4584
4578
|
}
|
|
4585
4579
|
};
|
|
4586
4580
|
function hasErrors(diagnostics) {
|
|
4587
|
-
return diagnostics.some((d) => d.category ===
|
|
4581
|
+
return diagnostics.some((d) => d.category === ts21.DiagnosticCategory.Error);
|
|
4588
4582
|
}
|
|
4589
4583
|
|
|
4590
4584
|
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/ngcc/src/execution/create_compile_function.mjs
|
|
@@ -4608,7 +4602,7 @@ function getCreateCompileFn(fileSystem, logger, fileWriter, enableI18nLegacyMess
|
|
|
4608
4602
|
const result = transformer.transform(bundle);
|
|
4609
4603
|
if (result.success) {
|
|
4610
4604
|
if (result.diagnostics.length > 0) {
|
|
4611
|
-
logger.warn(replaceTsWithNgInErrors(
|
|
4605
|
+
logger.warn(replaceTsWithNgInErrors(ts22.formatDiagnosticsWithColorAndContext(result.diagnostics, bundle.src.host)));
|
|
4612
4606
|
}
|
|
4613
4607
|
const writeBundle = () => {
|
|
4614
4608
|
fileWriter.writeBundle(bundle, result.transformedFiles, formatPropertiesToMarkAsProcessed);
|
|
@@ -4618,7 +4612,7 @@ function getCreateCompileFn(fileSystem, logger, fileWriter, enableI18nLegacyMess
|
|
|
4618
4612
|
const beforeWritingResult = beforeWritingFiles(result.transformedFiles);
|
|
4619
4613
|
return beforeWritingResult instanceof Promise ? beforeWritingResult.then(writeBundle) : writeBundle();
|
|
4620
4614
|
} else {
|
|
4621
|
-
const errors = replaceTsWithNgInErrors(
|
|
4615
|
+
const errors = replaceTsWithNgInErrors(ts22.formatDiagnosticsWithColorAndContext(result.diagnostics, bundle.src.host));
|
|
4622
4616
|
onTaskCompleted(task, 1, `compilation errors:
|
|
4623
4617
|
${errors}`);
|
|
4624
4618
|
}
|
|
@@ -4627,9 +4621,7 @@ ${errors}`);
|
|
|
4627
4621
|
}
|
|
4628
4622
|
|
|
4629
4623
|
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/ngcc/src/ngcc_options.mjs
|
|
4630
|
-
import
|
|
4631
|
-
cpus
|
|
4632
|
-
} from "os";
|
|
4624
|
+
import * as os from "os";
|
|
4633
4625
|
|
|
4634
4626
|
// bazel-out/k8-fastbuild/bin/packages/compiler-cli/ngcc/src/path_mappings.mjs
|
|
4635
4627
|
function getPathMappingsFromTsConfig(fs, tsConfig, projectPath) {
|
|
@@ -4863,7 +4855,7 @@ If you did intend to use this file, then you can hide this warning by providing
|
|
|
4863
4855
|
function getMaxNumberOfWorkers() {
|
|
4864
4856
|
const maxWorkers = process.env.NGCC_MAX_WORKERS;
|
|
4865
4857
|
if (maxWorkers === void 0) {
|
|
4866
|
-
return Math.max(1, Math.min(4, cpus().length - 1));
|
|
4858
|
+
return Math.max(1, Math.min(4, os.cpus().length - 1));
|
|
4867
4859
|
}
|
|
4868
4860
|
const numericMaxWorkers = +maxWorkers.trim();
|
|
4869
4861
|
if (!Number.isInteger(numericMaxWorkers)) {
|
|
@@ -4878,7 +4870,7 @@ function getMaxNumberOfWorkers() {
|
|
|
4878
4870
|
var stringifyTask = (task) => `{entryPoint: ${task.entryPoint.name}, formatProperty: ${task.formatProperty}, processDts: ${DtsProcessing[task.processDts]}}`;
|
|
4879
4871
|
function computeTaskDependencies(tasks, graph) {
|
|
4880
4872
|
const dependencies = new TaskDependencies();
|
|
4881
|
-
const candidateDependencies = new Map();
|
|
4873
|
+
const candidateDependencies = /* @__PURE__ */ new Map();
|
|
4882
4874
|
tasks.forEach((task) => {
|
|
4883
4875
|
const entryPointPath = task.entryPoint.path;
|
|
4884
4876
|
const deps = graph.dependenciesOf(entryPointPath);
|
|
@@ -4909,12 +4901,12 @@ function computeTaskDependencies(tasks, graph) {
|
|
|
4909
4901
|
}
|
|
4910
4902
|
function getDependentsSet(map, task) {
|
|
4911
4903
|
if (!map.has(task)) {
|
|
4912
|
-
map.set(task, new Set());
|
|
4904
|
+
map.set(task, /* @__PURE__ */ new Set());
|
|
4913
4905
|
}
|
|
4914
4906
|
return map.get(task);
|
|
4915
4907
|
}
|
|
4916
4908
|
function getBlockedTasks(dependencies) {
|
|
4917
|
-
const blockedTasks = new Map();
|
|
4909
|
+
const blockedTasks = /* @__PURE__ */ new Map();
|
|
4918
4910
|
for (const [dependency, dependents] of dependencies) {
|
|
4919
4911
|
for (const dependent of dependents) {
|
|
4920
4912
|
const dependentSet = getDependentsSet(blockedTasks, dependent);
|
|
@@ -4924,7 +4916,7 @@ function getBlockedTasks(dependencies) {
|
|
|
4924
4916
|
return blockedTasks;
|
|
4925
4917
|
}
|
|
4926
4918
|
function sortTasksByPriority(tasks, dependencies) {
|
|
4927
|
-
const priorityPerTask = new Map();
|
|
4919
|
+
const priorityPerTask = /* @__PURE__ */ new Map();
|
|
4928
4920
|
const computePriority = (task, idx) => [dependencies.has(task) ? dependencies.get(task).size : 0, idx];
|
|
4929
4921
|
tasks.forEach((task, i) => priorityPerTask.set(task, computePriority(task, i)));
|
|
4930
4922
|
return tasks.slice().sort((task1, task2) => {
|
|
@@ -5102,4 +5094,4 @@ export {
|
|
|
5102
5094
|
* Use of this source code is governed by an MIT-style license that can be
|
|
5103
5095
|
* found in the LICENSE file at https://angular.io/license
|
|
5104
5096
|
*/
|
|
5105
|
-
//# sourceMappingURL=chunk-
|
|
5097
|
+
//# sourceMappingURL=chunk-5TY44ZS3.js.map
|