@angular/core 19.0.0-next.3 → 19.0.0-next.4
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/fesm2022/core.mjs +3 -3
- package/fesm2022/core.mjs.map +1 -1
- package/fesm2022/primitives/event-dispatch.mjs +1 -1
- package/fesm2022/primitives/signals.mjs +1 -1
- package/fesm2022/rxjs-interop.mjs +1 -1
- package/fesm2022/testing.mjs +4 -4
- package/index.d.ts +1 -1
- package/package.json +1 -1
- package/primitives/event-dispatch/index.d.ts +1 -1
- package/primitives/signals/index.d.ts +1 -1
- package/rxjs-interop/index.d.ts +1 -1
- package/schematics/bundles/{compiler_host-bbb5d8fd.js → compiler_host-ca7ba733.js} +15 -15
- package/schematics/bundles/control-flow-migration.js +2 -2
- package/schematics/bundles/explicit-standalone-flag.js +157 -0
- package/schematics/bundles/{nodes-ddfa1613.js → imports-4ac08251.js} +1 -42
- package/schematics/bundles/inject-migration.js +6 -5
- package/schematics/bundles/nodes-0e7d45ca.js +56 -0
- package/schematics/bundles/project_tsconfig_paths-e9ccccbf.js +1 -1
- package/schematics/bundles/route-lazy-loading.js +2 -2
- package/schematics/bundles/standalone-migration.js +871 -769
- package/schematics/migrations.json +7 -1
- package/testing/index.d.ts +1 -1
package/fesm2022/testing.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v19.0.0-next.
|
|
2
|
+
* @license Angular v19.0.0-next.4
|
|
3
3
|
* (c) 2010-2024 Google LLC. https://angular.io/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -175,10 +175,10 @@ class TestBedApplicationErrorHandler {
|
|
|
175
175
|
throw e;
|
|
176
176
|
}
|
|
177
177
|
}
|
|
178
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0-next.
|
|
179
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.0-next.
|
|
178
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0-next.4", ngImport: i0, type: TestBedApplicationErrorHandler, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
179
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.0-next.4", ngImport: i0, type: TestBedApplicationErrorHandler }); }
|
|
180
180
|
}
|
|
181
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0-next.
|
|
181
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0-next.4", ngImport: i0, type: TestBedApplicationErrorHandler, decorators: [{
|
|
182
182
|
type: Injectable
|
|
183
183
|
}] });
|
|
184
184
|
|
package/index.d.ts
CHANGED
package/package.json
CHANGED
package/rxjs-interop/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
/**
|
|
3
|
-
* @license Angular v19.0.0-next.
|
|
3
|
+
* @license Angular v19.0.0-next.4
|
|
4
4
|
* (c) 2010-2024 Google LLC. https://angular.io/
|
|
5
5
|
* License: MIT
|
|
6
6
|
*/
|
|
@@ -25639,7 +25639,7 @@ function createForLoop(ast, connectedBlocks, visitor, bindingParser) {
|
|
|
25639
25639
|
if (params.trackBy === null) {
|
|
25640
25640
|
// TODO: We should not fail here, and instead try to produce some AST for the language
|
|
25641
25641
|
// service.
|
|
25642
|
-
errors.push(new ParseError(ast.
|
|
25642
|
+
errors.push(new ParseError(ast.startSourceSpan, '@for loop must have a "track" expression'));
|
|
25643
25643
|
}
|
|
25644
25644
|
else {
|
|
25645
25645
|
// The `for` block has a main span that includes the `empty` branch. For only the span of the
|
|
@@ -25690,7 +25690,7 @@ function createSwitchBlock(ast, visitor, bindingParser) {
|
|
|
25690
25690
|
/** Parses the parameters of a `for` loop block. */
|
|
25691
25691
|
function parseForLoopParameters(block, errors, bindingParser) {
|
|
25692
25692
|
if (block.parameters.length === 0) {
|
|
25693
|
-
errors.push(new ParseError(block.
|
|
25693
|
+
errors.push(new ParseError(block.startSourceSpan, '@for loop does not have an expression'));
|
|
25694
25694
|
return null;
|
|
25695
25695
|
}
|
|
25696
25696
|
const [expressionParam, ...secondaryParams] = block.parameters;
|
|
@@ -25734,7 +25734,7 @@ function parseForLoopParameters(block, errors, bindingParser) {
|
|
|
25734
25734
|
else {
|
|
25735
25735
|
const expression = parseBlockParameterToBinding(param, bindingParser, trackMatch[1]);
|
|
25736
25736
|
if (expression.ast instanceof EmptyExpr$1) {
|
|
25737
|
-
errors.push(new ParseError(
|
|
25737
|
+
errors.push(new ParseError(block.startSourceSpan, '@for loop must have a "track" expression'));
|
|
25738
25738
|
}
|
|
25739
25739
|
const keywordSpan = new ParseSourceSpan(param.sourceSpan.start, param.sourceSpan.start.moveBy('track'.length));
|
|
25740
25740
|
result.trackBy = { expression, keywordSpan };
|
|
@@ -25799,18 +25799,18 @@ function validateIfConnectedBlocks(connectedBlocks) {
|
|
|
25799
25799
|
const block = connectedBlocks[i];
|
|
25800
25800
|
if (block.name === 'else') {
|
|
25801
25801
|
if (hasElse) {
|
|
25802
|
-
errors.push(new ParseError(block.
|
|
25802
|
+
errors.push(new ParseError(block.startSourceSpan, 'Conditional can only have one @else block'));
|
|
25803
25803
|
}
|
|
25804
25804
|
else if (connectedBlocks.length > 1 && i < connectedBlocks.length - 1) {
|
|
25805
|
-
errors.push(new ParseError(block.
|
|
25805
|
+
errors.push(new ParseError(block.startSourceSpan, '@else block must be last inside the conditional'));
|
|
25806
25806
|
}
|
|
25807
25807
|
else if (block.parameters.length > 0) {
|
|
25808
|
-
errors.push(new ParseError(block.
|
|
25808
|
+
errors.push(new ParseError(block.startSourceSpan, '@else block cannot have parameters'));
|
|
25809
25809
|
}
|
|
25810
25810
|
hasElse = true;
|
|
25811
25811
|
}
|
|
25812
25812
|
else if (!ELSE_IF_PATTERN.test(block.name)) {
|
|
25813
|
-
errors.push(new ParseError(block.
|
|
25813
|
+
errors.push(new ParseError(block.startSourceSpan, `Unrecognized conditional block @${block.name}`));
|
|
25814
25814
|
}
|
|
25815
25815
|
}
|
|
25816
25816
|
return errors;
|
|
@@ -25820,7 +25820,7 @@ function validateSwitchBlock(ast) {
|
|
|
25820
25820
|
const errors = [];
|
|
25821
25821
|
let hasDefault = false;
|
|
25822
25822
|
if (ast.parameters.length !== 1) {
|
|
25823
|
-
errors.push(new ParseError(ast.
|
|
25823
|
+
errors.push(new ParseError(ast.startSourceSpan, '@switch block must have exactly one parameter'));
|
|
25824
25824
|
return errors;
|
|
25825
25825
|
}
|
|
25826
25826
|
for (const node of ast.children) {
|
|
@@ -25836,15 +25836,15 @@ function validateSwitchBlock(ast) {
|
|
|
25836
25836
|
}
|
|
25837
25837
|
if (node.name === 'default') {
|
|
25838
25838
|
if (hasDefault) {
|
|
25839
|
-
errors.push(new ParseError(node.
|
|
25839
|
+
errors.push(new ParseError(node.startSourceSpan, '@switch block can only have one @default block'));
|
|
25840
25840
|
}
|
|
25841
25841
|
else if (node.parameters.length > 0) {
|
|
25842
|
-
errors.push(new ParseError(node.
|
|
25842
|
+
errors.push(new ParseError(node.startSourceSpan, '@default block cannot have parameters'));
|
|
25843
25843
|
}
|
|
25844
25844
|
hasDefault = true;
|
|
25845
25845
|
}
|
|
25846
25846
|
else if (node.name === 'case' && node.parameters.length !== 1) {
|
|
25847
|
-
errors.push(new ParseError(node.
|
|
25847
|
+
errors.push(new ParseError(node.startSourceSpan, '@case block must have exactly one parameter'));
|
|
25848
25848
|
}
|
|
25849
25849
|
}
|
|
25850
25850
|
return errors;
|
|
@@ -25876,7 +25876,7 @@ function parseBlockParameterToBinding(ast, bindingParser, part) {
|
|
|
25876
25876
|
/** Parses the parameter of a conditional block (`if` or `else if`). */
|
|
25877
25877
|
function parseConditionalBlockParameters(block, errors, bindingParser) {
|
|
25878
25878
|
if (block.parameters.length === 0) {
|
|
25879
|
-
errors.push(new ParseError(block.
|
|
25879
|
+
errors.push(new ParseError(block.startSourceSpan, 'Conditional block does not have an expression'));
|
|
25880
25880
|
return null;
|
|
25881
25881
|
}
|
|
25882
25882
|
const expression = parseBlockParameterToBinding(block.parameters[0], bindingParser);
|
|
@@ -29070,7 +29070,7 @@ function publishFacade(global) {
|
|
|
29070
29070
|
* @description
|
|
29071
29071
|
* Entry point for all public APIs of the compiler package.
|
|
29072
29072
|
*/
|
|
29073
|
-
new Version('19.0.0-next.
|
|
29073
|
+
new Version('19.0.0-next.4');
|
|
29074
29074
|
|
|
29075
29075
|
const _I18N_ATTR = 'i18n';
|
|
29076
29076
|
const _I18N_ATTR_PREFIX = 'i18n-';
|
|
@@ -30414,7 +30414,7 @@ class NodeJSPathManipulation {
|
|
|
30414
30414
|
// G3-ESM-MARKER: G3 uses CommonJS, but externally everything in ESM.
|
|
30415
30415
|
// CommonJS/ESM interop for determining the current file name and containing dir.
|
|
30416
30416
|
const isCommonJS = typeof __filename !== 'undefined';
|
|
30417
|
-
const currentFileUrl = isCommonJS ? null : (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('compiler_host-
|
|
30417
|
+
const currentFileUrl = isCommonJS ? null : (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('compiler_host-ca7ba733.js', document.baseURI).href));
|
|
30418
30418
|
const currentFileName = isCommonJS ? __filename : url.fileURLToPath(currentFileUrl);
|
|
30419
30419
|
/**
|
|
30420
30420
|
* A wrapper around the Node.js file-system that supports readonly operations and path manipulation.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
/**
|
|
3
|
-
* @license Angular v19.0.0-next.
|
|
3
|
+
* @license Angular v19.0.0-next.4
|
|
4
4
|
* (c) 2010-2024 Google LLC. https://angular.io/
|
|
5
5
|
* License: MIT
|
|
6
6
|
*/
|
|
@@ -10,7 +10,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
10
10
|
|
|
11
11
|
var schematics = require('@angular-devkit/schematics');
|
|
12
12
|
var p = require('path');
|
|
13
|
-
var compiler_host = require('./compiler_host-
|
|
13
|
+
var compiler_host = require('./compiler_host-ca7ba733.js');
|
|
14
14
|
var ts = require('typescript');
|
|
15
15
|
require('os');
|
|
16
16
|
require('fs');
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/**
|
|
3
|
+
* @license Angular v19.0.0-next.4
|
|
4
|
+
* (c) 2010-2024 Google LLC. https://angular.io/
|
|
5
|
+
* License: MIT
|
|
6
|
+
*/
|
|
7
|
+
'use strict';
|
|
8
|
+
|
|
9
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
10
|
+
|
|
11
|
+
var schematics = require('@angular-devkit/schematics');
|
|
12
|
+
var p = require('path');
|
|
13
|
+
var project_tsconfig_paths = require('./project_tsconfig_paths-e9ccccbf.js');
|
|
14
|
+
var compiler_host = require('./compiler_host-ca7ba733.js');
|
|
15
|
+
var ts = require('typescript');
|
|
16
|
+
var imports = require('./imports-4ac08251.js');
|
|
17
|
+
require('@angular-devkit/core');
|
|
18
|
+
require('os');
|
|
19
|
+
require('fs');
|
|
20
|
+
require('module');
|
|
21
|
+
require('url');
|
|
22
|
+
|
|
23
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
24
|
+
|
|
25
|
+
var ts__default = /*#__PURE__*/_interopDefaultLegacy(ts);
|
|
26
|
+
|
|
27
|
+
const CORE = '@angular/core';
|
|
28
|
+
const DIRECTIVE = 'Directive';
|
|
29
|
+
const COMPONENT = 'Component';
|
|
30
|
+
const PIPE = 'Pipe';
|
|
31
|
+
function migrateFile(sourceFile, rewriteFn) {
|
|
32
|
+
const changeTracker = new compiler_host.ChangeTracker(ts__default["default"].createPrinter());
|
|
33
|
+
// Check if there are any imports of the `AfterRenderPhase` enum.
|
|
34
|
+
const coreImports = imports.getNamedImports(sourceFile, CORE);
|
|
35
|
+
if (!coreImports) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const directive = imports.getImportSpecifier(sourceFile, CORE, DIRECTIVE);
|
|
39
|
+
const component = imports.getImportSpecifier(sourceFile, CORE, COMPONENT);
|
|
40
|
+
const pipe = imports.getImportSpecifier(sourceFile, CORE, PIPE);
|
|
41
|
+
if (!directive && !component && !pipe) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
ts__default["default"].forEachChild(sourceFile, function visit(node) {
|
|
45
|
+
ts__default["default"].forEachChild(node, visit);
|
|
46
|
+
// First we need to check for class declarations
|
|
47
|
+
// Decorators will come after
|
|
48
|
+
if (!ts__default["default"].isClassDeclaration(node)) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
ts__default["default"].getDecorators(node)?.forEach((decorator) => {
|
|
52
|
+
if (!ts__default["default"].isDecorator(decorator)) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
const callExpression = decorator.expression;
|
|
56
|
+
if (!ts__default["default"].isCallExpression(callExpression)) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const decoratorIdentifier = callExpression.expression;
|
|
60
|
+
if (!ts__default["default"].isIdentifier(decoratorIdentifier)) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
// Checking the identifier of the decorator by comparing to the import specifier
|
|
64
|
+
switch (decoratorIdentifier.text) {
|
|
65
|
+
case directive?.name.text:
|
|
66
|
+
case component?.name.text:
|
|
67
|
+
case pipe?.name.text:
|
|
68
|
+
break;
|
|
69
|
+
default:
|
|
70
|
+
// It's not a decorator to migrate
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
const [firstArg] = callExpression.arguments;
|
|
74
|
+
if (!firstArg || !ts__default["default"].isObjectLiteralExpression(firstArg)) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const properties = firstArg.properties;
|
|
78
|
+
const standaloneProp = getStandaloneProperty(properties);
|
|
79
|
+
// Need to take care of 3 cases
|
|
80
|
+
// - standalone: true => remove the property
|
|
81
|
+
// - standalone: false => nothing
|
|
82
|
+
// - No standalone property => add a standalone: false property
|
|
83
|
+
let newProperties;
|
|
84
|
+
if (!standaloneProp) {
|
|
85
|
+
const standaloneFalseProperty = ts__default["default"].factory.createPropertyAssignment('standalone', ts__default["default"].factory.createFalse());
|
|
86
|
+
newProperties = [...properties, standaloneFalseProperty];
|
|
87
|
+
}
|
|
88
|
+
else if (standaloneProp.value === ts__default["default"].SyntaxKind.TrueKeyword) {
|
|
89
|
+
newProperties = properties.filter((p) => p !== standaloneProp.property);
|
|
90
|
+
}
|
|
91
|
+
if (newProperties) {
|
|
92
|
+
// At this point we know that we need to add standalone: false or
|
|
93
|
+
// remove an existing standalone: true property.
|
|
94
|
+
const newPropsArr = ts__default["default"].factory.createNodeArray(newProperties);
|
|
95
|
+
const newFirstArg = ts__default["default"].factory.createObjectLiteralExpression(newPropsArr, true);
|
|
96
|
+
changeTracker.replaceNode(firstArg, newFirstArg);
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
// Write the changes.
|
|
101
|
+
for (const changesInFile of changeTracker.recordChanges().values()) {
|
|
102
|
+
for (const change of changesInFile) {
|
|
103
|
+
rewriteFn(change.start, change.removeLength ?? 0, change.text);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
function getStandaloneProperty(properties) {
|
|
108
|
+
for (const prop of properties) {
|
|
109
|
+
if (ts__default["default"].isPropertyAssignment(prop) &&
|
|
110
|
+
ts__default["default"].isIdentifier(prop.name) &&
|
|
111
|
+
prop.name.text === 'standalone' &&
|
|
112
|
+
(prop.initializer.kind === ts__default["default"].SyntaxKind.TrueKeyword ||
|
|
113
|
+
prop.initializer.kind === ts__default["default"].SyntaxKind.FalseKeyword)) {
|
|
114
|
+
return { property: prop, value: prop.initializer.kind };
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return undefined;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function migrate() {
|
|
121
|
+
return async (tree) => {
|
|
122
|
+
const { buildPaths, testPaths } = await project_tsconfig_paths.getProjectTsConfigPaths(tree);
|
|
123
|
+
const basePath = process.cwd();
|
|
124
|
+
const allPaths = [...buildPaths, ...testPaths];
|
|
125
|
+
if (!allPaths.length) {
|
|
126
|
+
throw new schematics.SchematicsException('Could not find any tsconfig file. Cannot run the standalone:false migration.');
|
|
127
|
+
}
|
|
128
|
+
for (const tsconfigPath of allPaths) {
|
|
129
|
+
runMigration(tree, tsconfigPath, basePath);
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
function runMigration(tree, tsconfigPath, basePath) {
|
|
134
|
+
const program = compiler_host.createMigrationProgram(tree, tsconfigPath, basePath);
|
|
135
|
+
const sourceFiles = program
|
|
136
|
+
.getSourceFiles()
|
|
137
|
+
.filter((sourceFile) => compiler_host.canMigrateFile(basePath, sourceFile, program));
|
|
138
|
+
for (const sourceFile of sourceFiles) {
|
|
139
|
+
let update = null;
|
|
140
|
+
const rewriter = (startPos, width, text) => {
|
|
141
|
+
if (update === null) {
|
|
142
|
+
// Lazily initialize update, because most files will not require migration.
|
|
143
|
+
update = tree.beginUpdate(p.relative(basePath, sourceFile.fileName));
|
|
144
|
+
}
|
|
145
|
+
update.remove(startPos, width);
|
|
146
|
+
if (text !== null) {
|
|
147
|
+
update.insertLeft(startPos, text);
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
migrateFile(sourceFile, rewriter);
|
|
151
|
+
if (update !== null) {
|
|
152
|
+
tree.commitUpdate(update);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
exports.migrate = migrate;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
/**
|
|
3
|
-
* @license Angular v19.0.0-next.
|
|
3
|
+
* @license Angular v19.0.0-next.4
|
|
4
4
|
* (c) 2010-2024 Google LLC. https://angular.io/
|
|
5
5
|
* License: MIT
|
|
6
6
|
*/
|
|
@@ -105,47 +105,6 @@ function findImportSpecifier(nodes, specifierName) {
|
|
|
105
105
|
});
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
function getCallDecoratorImport(typeChecker, decorator) {
|
|
109
|
-
// Note that this does not cover the edge case where decorators are called from
|
|
110
|
-
// a namespace import: e.g. "@core.Component()". This is not handled by Ngtsc either.
|
|
111
|
-
if (!ts__default["default"].isCallExpression(decorator.expression) ||
|
|
112
|
-
!ts__default["default"].isIdentifier(decorator.expression.expression)) {
|
|
113
|
-
return null;
|
|
114
|
-
}
|
|
115
|
-
const identifier = decorator.expression.expression;
|
|
116
|
-
return getImportOfIdentifier(typeChecker, identifier);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Gets all decorators which are imported from an Angular package (e.g. "@angular/core")
|
|
121
|
-
* from a list of decorators.
|
|
122
|
-
*/
|
|
123
|
-
function getAngularDecorators(typeChecker, decorators) {
|
|
124
|
-
return decorators
|
|
125
|
-
.map((node) => ({ node, importData: getCallDecoratorImport(typeChecker, node) }))
|
|
126
|
-
.filter(({ importData }) => importData && importData.importModule.startsWith('@angular/'))
|
|
127
|
-
.map(({ node, importData }) => ({
|
|
128
|
-
node: node,
|
|
129
|
-
name: importData.name,
|
|
130
|
-
moduleName: importData.importModule,
|
|
131
|
-
importNode: importData.node,
|
|
132
|
-
}));
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
/** Find the closest parent node of a particular kind. */
|
|
136
|
-
function closestNode(node, predicate) {
|
|
137
|
-
let current = node.parent;
|
|
138
|
-
while (current && !ts__default["default"].isSourceFile(current)) {
|
|
139
|
-
if (predicate(current)) {
|
|
140
|
-
return current;
|
|
141
|
-
}
|
|
142
|
-
current = current.parent;
|
|
143
|
-
}
|
|
144
|
-
return null;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
exports.closestNode = closestNode;
|
|
148
|
-
exports.getAngularDecorators = getAngularDecorators;
|
|
149
108
|
exports.getImportOfIdentifier = getImportOfIdentifier;
|
|
150
109
|
exports.getImportSpecifier = getImportSpecifier;
|
|
151
110
|
exports.getNamedImports = getNamedImports;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
/**
|
|
3
|
-
* @license Angular v19.0.0-next.
|
|
3
|
+
* @license Angular v19.0.0-next.4
|
|
4
4
|
* (c) 2010-2024 Google LLC. https://angular.io/
|
|
5
5
|
* License: MIT
|
|
6
6
|
*/
|
|
@@ -10,9 +10,10 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
10
10
|
|
|
11
11
|
var schematics = require('@angular-devkit/schematics');
|
|
12
12
|
var p = require('path');
|
|
13
|
-
var compiler_host = require('./compiler_host-
|
|
13
|
+
var compiler_host = require('./compiler_host-ca7ba733.js');
|
|
14
14
|
var ts = require('typescript');
|
|
15
|
-
var nodes = require('./nodes-
|
|
15
|
+
var nodes = require('./nodes-0e7d45ca.js');
|
|
16
|
+
var imports = require('./imports-4ac08251.js');
|
|
16
17
|
require('os');
|
|
17
18
|
require('fs');
|
|
18
19
|
require('module');
|
|
@@ -53,7 +54,7 @@ const DI_PARAM_SYMBOLS = new Set([
|
|
|
53
54
|
* @param localTypeChecker Type checker scoped to the specific file.
|
|
54
55
|
*/
|
|
55
56
|
function analyzeFile(sourceFile, localTypeChecker) {
|
|
56
|
-
const coreSpecifiers =
|
|
57
|
+
const coreSpecifiers = imports.getNamedImports(sourceFile, '@angular/core');
|
|
57
58
|
// Exit early if there are no Angular imports.
|
|
58
59
|
if (coreSpecifiers === null || coreSpecifiers.elements.length === 0) {
|
|
59
60
|
return null;
|
|
@@ -748,7 +749,7 @@ function migrateInjectDecorator(firstArg, type, localTypeChecker) {
|
|
|
748
749
|
else if (ts__default["default"].isCallExpression(firstArg) &&
|
|
749
750
|
ts__default["default"].isIdentifier(firstArg.expression) &&
|
|
750
751
|
firstArg.arguments.length === 1) {
|
|
751
|
-
const callImport =
|
|
752
|
+
const callImport = imports.getImportOfIdentifier(localTypeChecker, firstArg.expression);
|
|
752
753
|
const arrowFn = firstArg.arguments[0];
|
|
753
754
|
// If the first parameter is a `forwardRef`, unwrap it for a more
|
|
754
755
|
// accurate type and because it's no longer necessary.
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/**
|
|
3
|
+
* @license Angular v19.0.0-next.4
|
|
4
|
+
* (c) 2010-2024 Google LLC. https://angular.io/
|
|
5
|
+
* License: MIT
|
|
6
|
+
*/
|
|
7
|
+
'use strict';
|
|
8
|
+
|
|
9
|
+
var ts = require('typescript');
|
|
10
|
+
var imports = require('./imports-4ac08251.js');
|
|
11
|
+
|
|
12
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
13
|
+
|
|
14
|
+
var ts__default = /*#__PURE__*/_interopDefaultLegacy(ts);
|
|
15
|
+
|
|
16
|
+
function getCallDecoratorImport(typeChecker, decorator) {
|
|
17
|
+
// Note that this does not cover the edge case where decorators are called from
|
|
18
|
+
// a namespace import: e.g. "@core.Component()". This is not handled by Ngtsc either.
|
|
19
|
+
if (!ts__default["default"].isCallExpression(decorator.expression) ||
|
|
20
|
+
!ts__default["default"].isIdentifier(decorator.expression.expression)) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
const identifier = decorator.expression.expression;
|
|
24
|
+
return imports.getImportOfIdentifier(typeChecker, identifier);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Gets all decorators which are imported from an Angular package (e.g. "@angular/core")
|
|
29
|
+
* from a list of decorators.
|
|
30
|
+
*/
|
|
31
|
+
function getAngularDecorators(typeChecker, decorators) {
|
|
32
|
+
return decorators
|
|
33
|
+
.map((node) => ({ node, importData: getCallDecoratorImport(typeChecker, node) }))
|
|
34
|
+
.filter(({ importData }) => importData && importData.importModule.startsWith('@angular/'))
|
|
35
|
+
.map(({ node, importData }) => ({
|
|
36
|
+
node: node,
|
|
37
|
+
name: importData.name,
|
|
38
|
+
moduleName: importData.importModule,
|
|
39
|
+
importNode: importData.node,
|
|
40
|
+
}));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Find the closest parent node of a particular kind. */
|
|
44
|
+
function closestNode(node, predicate) {
|
|
45
|
+
let current = node.parent;
|
|
46
|
+
while (current && !ts__default["default"].isSourceFile(current)) {
|
|
47
|
+
if (predicate(current)) {
|
|
48
|
+
return current;
|
|
49
|
+
}
|
|
50
|
+
current = current.parent;
|
|
51
|
+
}
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
exports.closestNode = closestNode;
|
|
56
|
+
exports.getAngularDecorators = getAngularDecorators;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
/**
|
|
3
|
-
* @license Angular v19.0.0-next.
|
|
3
|
+
* @license Angular v19.0.0-next.4
|
|
4
4
|
* (c) 2010-2024 Google LLC. https://angular.io/
|
|
5
5
|
* License: MIT
|
|
6
6
|
*/
|
|
@@ -11,7 +11,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
11
11
|
var schematics = require('@angular-devkit/schematics');
|
|
12
12
|
var fs = require('fs');
|
|
13
13
|
var p = require('path');
|
|
14
|
-
var compiler_host = require('./compiler_host-
|
|
14
|
+
var compiler_host = require('./compiler_host-ca7ba733.js');
|
|
15
15
|
var project_tsconfig_paths = require('./project_tsconfig_paths-e9ccccbf.js');
|
|
16
16
|
var ts = require('typescript');
|
|
17
17
|
require('os');
|