This commit is contained in:
CHEVALLIER Abel
2025-11-13 16:23:22 +01:00
parent de9c515a47
commit cb235644dc
34924 changed files with 3811102 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import * as ts from 'typescript';
import { Import } from './imports';
export type CallExpressionDecorator = ts.Decorator & {
expression: ts.CallExpression;
};
export interface NgDecorator {
name: string;
node: CallExpressionDecorator;
}
/**
* Gets all decorators which are imported from an Angular package
* (e.g. "@angular/core") from a list of decorators.
*/
export declare function getAngularDecorators(typeChecker: ts.TypeChecker, decorators: readonly ts.Decorator[]): readonly NgDecorator[];
export declare function getCallDecoratorImport(typeChecker: ts.TypeChecker, decorator: ts.Decorator): Import | null;

View File

@@ -0,0 +1,41 @@
"use strict";
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.getAngularDecorators = getAngularDecorators;
exports.getCallDecoratorImport = getCallDecoratorImport;
const ts = require("typescript");
const imports_1 = require("./imports");
/**
* Gets all decorators which are imported from an Angular package
* (e.g. "@angular/core") from a list of decorators.
*/
function getAngularDecorators(typeChecker, decorators) {
return decorators
.map(node => ({ node, importData: getCallDecoratorImport(typeChecker, node) }))
.filter(({ importData }) => importData && importData.moduleName.startsWith('@angular/'))
.map(({ node, importData }) => ({
node: node,
name: importData.symbolName,
}));
}
function getCallDecoratorImport(typeChecker, decorator) {
if (!ts.isCallExpression(decorator.expression)) {
return null;
}
const valueExpr = decorator.expression.expression;
let identifier = null;
if (ts.isIdentifier(valueExpr)) {
identifier = valueExpr;
}
else if (ts.isPropertyAccessExpression(valueExpr) && ts.isIdentifier(valueExpr.name)) {
identifier = valueExpr.name;
}
return identifier ? (0, imports_1.getImportOfIdentifier)(identifier, typeChecker) : null;
}
//# sourceMappingURL=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AO,UAAU,CAAC,CAAC,CAAC,IAAA,+BAAqB,EAAC,UAAU,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAC5E,CAAC"}

View File

@@ -0,0 +1,11 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import * as ts from 'typescript';
import { FileSystem } from '../file-system';
/** Formats the specified diagnostics with respect to the given file system. */
export declare function formatDiagnostics(diagnostics: ts.Diagnostic[], fileSystem: FileSystem): string;

View File

@@ -0,0 +1,18 @@
"use strict";
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.formatDiagnostics = formatDiagnostics;
const ts = require("typescript");
const virtual_host_1 = require("./virtual-host");
/** Formats the specified diagnostics with respect to the given file system. */
function formatDiagnostics(diagnostics, fileSystem) {
const formatHost = (0, virtual_host_1.createFormatDiagnosticHost)(fileSystem);
return ts.formatDiagnosticsWithColorAndContext(diagnostics, formatHost);
}
//# sourceMappingURL=diagnostics.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"diagnostics.js","sourceRoot":"","sources":["diagnostics.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAOH,8CAGC;AARD,iCAAiC;AAEjC,iDAA0D;AAE1D,+EAA+E;AAC/E,SAAgB,iBAAiB,CAAC,WAA4B,EAAE,UAAsB;IACpF,MAAM,UAAU,GAAG,IAAA,yCAA0B,EAAC,UAAU,CAAC,CAAC;IAC1D,OAAO,EAAE,CAAC,oCAAoC,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;AAC1E,CAAC"}

View File

@@ -0,0 +1,14 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import * as ts from 'typescript';
/**
* Unwraps a given expression TypeScript node. Expressions can be wrapped within multiple
* parentheses. e.g. "(((({exp}))))()". The function should return the TypeScript node
* referring to the inner expression. e.g "exp".
*/
export declare function unwrapExpression(node: ts.Expression | ts.ParenthesizedExpression): ts.Expression;

View File

@@ -0,0 +1,20 @@
"use strict";
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.unwrapExpression = unwrapExpression;
const ts = require("typescript");
/**
* Unwraps a given expression TypeScript node. Expressions can be wrapped within multiple
* parentheses. e.g. "(((({exp}))))()". The function should return the TypeScript node
* referring to the inner expression. e.g "exp".
*/
function unwrapExpression(node) {
return ts.isParenthesizedExpression(node) ? unwrapExpression(node.expression) : node;
}
//# sourceMappingURL=functions.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"functions.js","sourceRoot":"","sources":["functions.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AASH,4CAEC;AATD,iCAAiC;AAEjC;;;;GAIG;AACH,SAAgB,gBAAgB,CAAC,IAAgD;IAC/E,OAAO,EAAE,CAAC,yBAAyB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AACvF,CAAC"}

View File

@@ -0,0 +1,17 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import * as ts from 'typescript';
/** Interface describing a resolved import. */
export interface Import {
/** Name of the imported symbol. */
symbolName: string;
/** Module name from which the symbol has been imported. */
moduleName: string;
}
/** Resolves the import of the specified identifier. */
export declare function getImportOfIdentifier(node: ts.Identifier, typeChecker: ts.TypeChecker): Import | null;

View File

@@ -0,0 +1,110 @@
"use strict";
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.getImportOfIdentifier = getImportOfIdentifier;
const ts = require("typescript");
/** Resolves the import of the specified identifier. */
function getImportOfIdentifier(node, typeChecker) {
// Free standing identifiers which resolve to an import will be handled
// as direct imports. e.g. "@Component()" where "Component" is an identifier
// referring to an import specifier.
const directImport = getSpecificImportOfIdentifier(node, typeChecker);
if (directImport !== null) {
return directImport;
}
else if (ts.isQualifiedName(node.parent) && node.parent.right === node) {
// Determines the import of a qualified name. e.g. "let t: core.Component". In that
// case, the import of the most left identifier will be determined ("core").
const qualifierRoot = getQualifiedNameRoot(node.parent);
if (qualifierRoot) {
const moduleName = getImportOfNamespacedIdentifier(qualifierRoot, typeChecker);
if (moduleName) {
return { moduleName, symbolName: node.text };
}
}
}
else if (ts.isPropertyAccessExpression(node.parent) && node.parent.name === node) {
// Determines the import of a property expression. e.g. "@core.Component". In that
// case, the import of the most left identifier will be determined ("core").
const rootIdentifier = getPropertyAccessRoot(node.parent);
if (rootIdentifier) {
const moduleName = getImportOfNamespacedIdentifier(rootIdentifier, typeChecker);
if (moduleName) {
return { moduleName, symbolName: node.text };
}
}
}
return null;
}
/**
* Resolves the import of the specified identifier. Expects the identifier to resolve
* to a fine-grained import declaration with import specifiers.
*/
function getSpecificImportOfIdentifier(node, typeChecker) {
const symbol = typeChecker.getSymbolAtLocation(node);
if (!symbol || !symbol.declarations || !symbol.declarations.length) {
return null;
}
const declaration = symbol.declarations[0];
if (!ts.isImportSpecifier(declaration)) {
return null;
}
// Since the declaration is an import specifier, we can walk up three times to get a reference
// to the import declaration node (NamedImports -> ImportClause -> ImportDeclaration).
const importDecl = declaration.parent.parent.parent;
if (!ts.isStringLiteral(importDecl.moduleSpecifier)) {
return null;
}
return {
moduleName: importDecl.moduleSpecifier.text,
symbolName: declaration.propertyName ? declaration.propertyName.text : declaration.name.text,
};
}
/**
* Resolves the import of the specified identifier. Expects the identifier to
* resolve to a namespaced import declaration. e.g. "import * as core from ...".
*/
function getImportOfNamespacedIdentifier(node, typeChecker) {
const symbol = typeChecker.getSymbolAtLocation(node);
if (!symbol || !symbol.declarations || !symbol.declarations.length) {
return null;
}
const declaration = symbol.declarations[0];
if (!ts.isNamespaceImport(declaration)) {
return null;
}
// Since the declaration is a namespace import, we can walk up three times to get a reference
// to the import declaration node (NamespaceImport -> ImportClause -> ImportDeclaration).
const importDecl = declaration.parent.parent;
if (!ts.isStringLiteral(importDecl.moduleSpecifier)) {
return null;
}
return importDecl.moduleSpecifier.text;
}
/**
* Gets the root identifier of a qualified type chain. For example: "core.GestureConfig"
* will return the "core" identifier. Allowing us to find the import of "core".
*/
function getQualifiedNameRoot(name) {
while (ts.isQualifiedName(name.left)) {
name = name.left;
}
return ts.isIdentifier(name.left) ? name.left : null;
}
/**
* Gets the root identifier of a property access chain. For example: "core.GestureConfig"
* will return the "core" identifier. Allowing us to find the import of "core".
*/
function getPropertyAccessRoot(node) {
while (ts.isPropertyAccessExpression(node.expression)) {
node = node.expression;
}
return ts.isIdentifier(node.expression) ? node.expression : null;
}
//# sourceMappingURL=imports.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"imports.js","sourceRoot":"","sources":["imports.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAaH,sDAgCC;AA3CD,iCAAiC;AAUjC,uDAAuD;AACvD,SAAgB,qBAAqB,CACnC,IAAmB,EACnB,WAA2B;IAE3B,uEAAuE;IACvE,4EAA4E;IAC5E,oCAAoC;IACpC,MAAM,YAAY,GAAG,6BAA6B,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;IACtE,IAAI,YAAY,KAAK,IAAI,EAAE,CAAC;QAC1B,OAAO,YAAY,CAAC;IACtB,CAAC;SAAM,IAAI,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,KAAK,KAAK,IAAI,EAAE,CAAC;QACzE,mFAAmF;QACnF,4EAA4E;QAC5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IAAI,CAAC,EAAE,CAAC;QACrC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IACD,OAAO,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;AACvD,CAAC;AAED;;;GAGG;AACH,SAAS,qBAAqB,CAAC,IAAiC;IAC9D,OAAO,EAAE,CAAC,0BAA0B,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;QACtD,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IACD,OAAO,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC;AACnE,CAAC"}

View File

@@ -0,0 +1,21 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
export interface LineAndCharacter {
character: number;
line: number;
}
/** Gets the line and character for the given position from the line starts map. */
export declare function getLineAndCharacterFromPosition(lineStartsMap: number[], position: number): {
character: number;
line: number;
};
/**
* Computes the line start map of the given text. This can be used in order to
* retrieve the line and character of a given text position index.
*/
export declare function computeLineStartsMap(text: string): number[];

View File

@@ -0,0 +1,75 @@
"use strict";
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.getLineAndCharacterFromPosition = getLineAndCharacterFromPosition;
exports.computeLineStartsMap = computeLineStartsMap;
/*
* Line mapping utilities which can be used to retrieve line and character based
* on an absolute character position in a given file. This functionality is similar
* to TypeScript's "ts.getLineAndCharacterFromPosition" utility, but we cannot leverage
* their logic for line mappings as it's internal and we need to generate line mappings
* for non-TypeScript files such as HTML templates or stylesheets.
*
* Line and character can be retrieved by splitting a given source text based on
* line breaks into line start entries. Later when a specific position is requested,
* the closest line-start position is determined based on the given position.
*/
const LF_CHAR = 10;
const CR_CHAR = 13;
const LINE_SEP_CHAR = 8232;
const PARAGRAPH_CHAR = 8233;
/** Gets the line and character for the given position from the line starts map. */
function getLineAndCharacterFromPosition(lineStartsMap, position) {
const lineIndex = findClosestLineStartPosition(lineStartsMap, position);
return { character: position - lineStartsMap[lineIndex], line: lineIndex };
}
/**
* Computes the line start map of the given text. This can be used in order to
* retrieve the line and character of a given text position index.
*/
function computeLineStartsMap(text) {
const result = [0];
let pos = 0;
while (pos < text.length) {
const char = text.charCodeAt(pos++);
// Handles the "CRLF" line break. In that case we peek the character
// after the "CR" and check if it is a line feed.
if (char === CR_CHAR) {
if (text.charCodeAt(pos) === LF_CHAR) {
pos++;
}
result.push(pos);
}
else if (char === LF_CHAR || char === LINE_SEP_CHAR || char === PARAGRAPH_CHAR) {
result.push(pos);
}
}
result.push(pos);
return result;
}
/** Finds the closest line start for the given position. */
function findClosestLineStartPosition(linesMap, position, low = 0, high = linesMap.length - 1) {
while (low <= high) {
const pivotIndex = Math.floor((low + high) / 2);
const pivotEl = linesMap[pivotIndex];
if (pivotEl === position) {
return pivotIndex;
}
else if (position > pivotEl) {
low = pivotIndex + 1;
}
else {
high = pivotIndex - 1;
}
}
// In case there was no exact match, return the closest "lower" line index. We also
// subtract the index by one because want the index of the previous line start.
return low - 1;
}
//# sourceMappingURL=line-mappings.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"line-mappings.js","sourceRoot":"","sources":["line-mappings.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAyBH,0EAGC;AAMD,oDAkBC;AAlDD;;;;;;;;;;GAUG;AAEH,MAAM,OAAO,GAAG,EAAE,CAAC;AACnB,MAAM,OAAO,GAAG,EAAE,CAAC;AACnB,MAAM,aAAa,GAAG,IAAI,CAAC;AAC3B,MAAM,cAAc,GAAG,IAAI,CAAC;AAO5B,mFAAmF;AACn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C,CAAC,CAAC;QAChD,MAAM,OAAO,GAAG,QAAQ,CAAC,UAAU,CAAC,CAAC;QAErC,IAAI,OAAO,KAAK,QAAQ,EAAE,CAAC;YACzB,OAAO,UAAU,CAAC;QACpB,CAAC;aAAM,IAAI,QAAQ,GAAG,OAAO,EAAE,CAAC;YAC9B,GAAG,GAAG,UAAU,GAAG,CAAC,CAAC;QACvB,CAAC;aAAM,CAAC;YACN,IAAI,GAAG,UAAU,GAAG,CAAC,CAAC;QACxB,CAAC;IACH,CAAC;IAED,mFAAmF;IACnF,+EAA+E;IAC/E,OAAO,GAAG,GAAG,CAAC,CAAC;AACjB,CAAC"}

View File

@@ -0,0 +1,18 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import * as ts from 'typescript';
import { FileSystem, WorkspacePath } from '../file-system';
/** Class capturing a tsconfig parse error. */
export declare class TsconfigParseError extends Error {
}
/**
* Attempts to parse the specified tsconfig file.
*
* @throws {TsconfigParseError} If the tsconfig could not be read or parsed.
*/
export declare function parseTsconfigFile(tsconfigPath: WorkspacePath, fileSystem: FileSystem): ts.ParsedCommandLine;

View File

@@ -0,0 +1,45 @@
"use strict";
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.TsconfigParseError = void 0;
exports.parseTsconfigFile = parseTsconfigFile;
const ts = require("typescript");
const virtual_host_1 = require("./virtual-host");
const path_1 = require("path");
const diagnostics_1 = require("./diagnostics");
/** Code of the error raised by TypeScript when a tsconfig doesn't match any files. */
const NO_INPUTS_ERROR_CODE = 18003;
/** Class capturing a tsconfig parse error. */
class TsconfigParseError extends Error {
}
exports.TsconfigParseError = TsconfigParseError;
/**
* Attempts to parse the specified tsconfig file.
*
* @throws {TsconfigParseError} If the tsconfig could not be read or parsed.
*/
function parseTsconfigFile(tsconfigPath, fileSystem) {
if (!fileSystem.fileExists(tsconfigPath)) {
throw new TsconfigParseError(`Tsconfig cannot not be read: ${tsconfigPath}`);
}
const { config, error } = ts.readConfigFile(tsconfigPath, p => fileSystem.read(fileSystem.resolve(p)));
// If there is a config reading error, we never attempt to parse the config.
if (error) {
throw new TsconfigParseError((0, diagnostics_1.formatDiagnostics)([error], fileSystem));
}
const parsed = ts.parseJsonConfigFileContent(config, new virtual_host_1.FileSystemHost(fileSystem), (0, path_1.dirname)(tsconfigPath), {});
// Skip the "No inputs found..." error since we don't want to interrupt the migration if a
// tsconfig doesn't match a file. This will result in an empty `Program` which is still valid.
const errors = parsed.errors.filter(diag => diag.code !== NO_INPUTS_ERROR_CODE);
if (errors.length) {
throw new TsconfigParseError((0, diagnostics_1.formatDiagnostics)(errors, fileSystem));
}
return parsed;
}
//# sourceMappingURL=parse-tsconfig.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"parse-tsconfig.js","sourceRoot":"","sources":["parse-tsconfig.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAmBH,8CAkCC;AAnDD,iCAAiC;AAEjC,iDAA8C;AAC9C,+BAA6B;AAC7B,+CAAgD;AAEhD,sFAAsF;AACtF,MAAM,oBAAoB,GAAG,KAAK,CAAC;AAEnC,8CAA8C;AAC9C,MAAa,kBAAmB,SAAQ,KAAK;CAAG;AAAhD,gDAAgD;AAEhD;;;;GAIG;AACH,SAAgB,iBAAiB,CAC/B,YAA2B,EAC3B,UAAsB;IAEtB,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;QACzC,MAAM,IAAI,kBAAkB,CAAC,gCAAgC,YAAY,EAAE,CAAC,CAAC;IAC/E,CAAC;IAED,MAAM,EAAC,MAAM,EAAE,KAAK,EAAC,GAAG,EAAE,CAAC,cAAc,CACvC,YAAY,EACZ,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAE,CAC7C,CAAC;IAEF,4EAA4E;IAC5E,IAAI,KAAK,EAAE,CAAC;QACV,MAAM,IAAI,kBAAkB,CAAC,IAAA,+BAAiB,EAAC,CAAC,KAAK,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC;IACvE,CAAC;IAED,MAAM,MAAM,GAAG,EAAE,CAAC,0BAA0B,CAC1C,MAAM,EACN,IAAI,6BAAc,CAAC,UAAU,CAAC,EAC9B,IAAA,cAAO,EAAC,YAAY,CAAC,EACrB,EAAE,CACH,CAAC;IAEF,0FAA0F;IAC1F,8FAA8F;IAC9F,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,oBAAoB,CAAC,CAAC;IAEhF,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;QAClB,MAAM,IAAI,kBAAkB,CAAC,IAAA,+BAAiB,EAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;IACtE,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}

View File

@@ -0,0 +1,18 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import * as ts from 'typescript';
/** Type that describes a property name with an obtainable text. */
type PropertyNameWithText = Exclude<ts.PropertyName, ts.ComputedPropertyName>;
/**
* Gets the text of the given property name. Returns null if the property
* name couldn't be determined statically.
*/
export declare function getPropertyNameText(node: ts.PropertyName): string | null;
/** Checks whether the given property name has a text. */
export declare function hasPropertyNameText(node: ts.PropertyName): node is PropertyNameWithText;
export {};

View File

@@ -0,0 +1,27 @@
"use strict";
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.getPropertyNameText = getPropertyNameText;
exports.hasPropertyNameText = hasPropertyNameText;
const ts = require("typescript");
/**
* Gets the text of the given property name. Returns null if the property
* name couldn't be determined statically.
*/
function getPropertyNameText(node) {
if (ts.isIdentifier(node) || ts.isStringLiteralLike(node)) {
return node.text;
}
return null;
}
/** Checks whether the given property name has a text. */
function hasPropertyNameText(node) {
return ts.isStringLiteral(node) || ts.isNumericLiteral(node) || ts.isIdentifier(node);
}
//# sourceMappingURL=property-name.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"property-name.js","sourceRoot":"","sources":["property-name.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAWH,kDAKC;AAGD,kDAEC;AAnBD,iCAAiC;AAKjC;;;GAGG;AACH,SAAgB,mBAAmB,CAAC,IAAqB;IACvD,IAAI,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,mBAAmB,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1D,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,yDAAyD;AACzD,SAAgB,mBAAmB,CAAC,IAAqB;IACvD,OAAO,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;AACxF,CAAC"}

View File

@@ -0,0 +1,36 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import * as ts from 'typescript';
import { FileSystem } from '../file-system';
declare module 'typescript' {
interface FileSystemEntries {
readonly files: readonly string[];
readonly directories: readonly string[];
}
const matchFiles: undefined | ((path: string, extensions: readonly string[] | undefined, excludes: readonly string[] | undefined, includes: readonly string[] | undefined, useCaseSensitiveFileNames: boolean, currentDirectory: string, depth: number | undefined, getFileSystemEntries: (path: string) => FileSystemEntries, realpath: (path: string) => string, directoryExists: (path: string) => boolean) => string[]);
}
/**
* Implementation of a TypeScript parse config host that relies fully on
* a given virtual file system.
*/
export declare class FileSystemHost implements ts.ParseConfigHost {
private _fileSystem;
useCaseSensitiveFileNames: boolean;
constructor(_fileSystem: FileSystem);
fileExists(path: string): boolean;
readFile(path: string): string | undefined;
readDirectory(rootDir: string, extensions: string[], excludes: string[] | undefined, includes: string[], depth?: number): string[];
private _getFileSystemEntries;
}
/**
* Creates a TypeScript compiler host that fully relies fully on the given
* virtual file system. i.e. no interactions with the working directory.
*/
export declare function createFileSystemCompilerHost(options: ts.CompilerOptions, fileSystem: FileSystem): ts.CompilerHost;
/** Creates a format diagnostic host that works with the given file system. */
export declare function createFormatDiagnosticHost(fileSystem: FileSystem): ts.FormatDiagnosticsHost;

View File

@@ -0,0 +1,71 @@
"use strict";
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.FileSystemHost = void 0;
exports.createFileSystemCompilerHost = createFileSystemCompilerHost;
exports.createFormatDiagnosticHost = createFormatDiagnosticHost;
const ts = require("typescript");
/**
* Implementation of a TypeScript parse config host that relies fully on
* a given virtual file system.
*/
class FileSystemHost {
constructor(_fileSystem) {
this._fileSystem = _fileSystem;
this.useCaseSensitiveFileNames = ts.sys.useCaseSensitiveFileNames;
}
fileExists(path) {
return this._fileSystem.fileExists(this._fileSystem.resolve(path));
}
readFile(path) {
const content = this._fileSystem.read(this._fileSystem.resolve(path));
if (content === null) {
return undefined;
}
// Strip BOM as otherwise TSC methods (e.g. "getWidth") will return an offset which
// which breaks the CLI UpdateRecorder. https://github.com/angular/angular/pull/30719
return content.replace(/^\uFEFF/, '');
}
readDirectory(rootDir, extensions, excludes, includes, depth) {
if (ts.matchFiles === undefined) {
throw Error('Unable to read directory in virtual file system host. This means that ' +
'TypeScript changed its file matching internals.\n\nPlease consider downgrading your ' +
'TypeScript version, and report an issue in the Angular Components repository.');
}
return ts.matchFiles(rootDir, extensions, extensions, includes, this.useCaseSensitiveFileNames, '/', depth, p => this._getFileSystemEntries(p), p => this._fileSystem.resolve(p), p => this._fileSystem.directoryExists(this._fileSystem.resolve(p)));
}
_getFileSystemEntries(path) {
return this._fileSystem.readDirectory(this._fileSystem.resolve(path));
}
}
exports.FileSystemHost = FileSystemHost;
/**
* Creates a TypeScript compiler host that fully relies fully on the given
* virtual file system. i.e. no interactions with the working directory.
*/
function createFileSystemCompilerHost(options, fileSystem) {
const host = ts.createCompilerHost(options, true);
const virtualHost = new FileSystemHost(fileSystem);
host.readFile = virtualHost.readFile.bind(virtualHost);
host.readDirectory = virtualHost.readDirectory.bind(virtualHost);
host.fileExists = virtualHost.fileExists.bind(virtualHost);
host.directoryExists = dirPath => fileSystem.directoryExists(fileSystem.resolve(dirPath));
host.getCurrentDirectory = () => '/';
host.getCanonicalFileName = p => fileSystem.resolve(p);
return host;
}
/** Creates a format diagnostic host that works with the given file system. */
function createFormatDiagnosticHost(fileSystem) {
return {
getCanonicalFileName: p => fileSystem.resolve(p),
getCurrentDirectory: () => '/',
getNewLine: () => '\n',
};
}
//# sourceMappingURL=virtual-host.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"virtual-host.js","sourceRoot":"","sources":["virtual-host.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AA8FH,oEAeC;AAGD,gEAMC;AApHD,iCAAiC;AAgCjC;;;GAGG;AACH,MAAa,cAAc;IAGzB,YAAoB,WAAuB;QAAvB,gBAAW,GAAX,WAAW,CAAY;QAF3C,8BAAyB,GAAG,EAAE,CAAC,GAAG,CAAC,yBAAyB,CAAC;IAEf,CAAC;IAE/C,UAAU,CAAC,IAAY;QACrB,OAAO,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;IACrE,CAAC;IAED,QAAQ,CAAC,IAAY;QACnB,MAAM,OAAO,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