Primeiro commit do projeto Angular
This commit is contained in:
+56
@@ -0,0 +1,56 @@
|
||||
|
||||
import {createRequire as __cjsCompatRequire} from 'module';
|
||||
const require = __cjsCompatRequire(import.meta.url);
|
||||
|
||||
|
||||
// packages/compiler-cli/src/ngtsc/logging/src/logger.js
|
||||
var LogLevel;
|
||||
(function(LogLevel2) {
|
||||
LogLevel2[LogLevel2["debug"] = 0] = "debug";
|
||||
LogLevel2[LogLevel2["info"] = 1] = "info";
|
||||
LogLevel2[LogLevel2["warn"] = 2] = "warn";
|
||||
LogLevel2[LogLevel2["error"] = 3] = "error";
|
||||
})(LogLevel || (LogLevel = {}));
|
||||
|
||||
// packages/compiler-cli/src/ngtsc/logging/src/console_logger.js
|
||||
var RESET = "\x1B[0m";
|
||||
var RED = "\x1B[31m";
|
||||
var YELLOW = "\x1B[33m";
|
||||
var BLUE = "\x1B[36m";
|
||||
var DEBUG = `${BLUE}Debug:${RESET}`;
|
||||
var WARN = `${YELLOW}Warning:${RESET}`;
|
||||
var ERROR = `${RED}Error:${RESET}`;
|
||||
var ConsoleLogger = class {
|
||||
level;
|
||||
constructor(level) {
|
||||
this.level = level;
|
||||
}
|
||||
debug(...args) {
|
||||
if (this.level <= LogLevel.debug)
|
||||
console.debug(DEBUG, ...args);
|
||||
}
|
||||
info(...args) {
|
||||
if (this.level <= LogLevel.info)
|
||||
console.info(...args);
|
||||
}
|
||||
warn(...args) {
|
||||
if (this.level <= LogLevel.warn)
|
||||
console.warn(WARN, ...args);
|
||||
}
|
||||
error(...args) {
|
||||
if (this.level <= LogLevel.error)
|
||||
console.error(ERROR, ...args);
|
||||
}
|
||||
};
|
||||
|
||||
export {
|
||||
LogLevel,
|
||||
ConsoleLogger
|
||||
};
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
+373
@@ -0,0 +1,373 @@
|
||||
|
||||
import {createRequire as __cjsCompatRequire} from 'module';
|
||||
const require = __cjsCompatRequire(import.meta.url);
|
||||
|
||||
|
||||
// packages/compiler-cli/src/ngtsc/file_system/src/invalid_file_system.js
|
||||
var InvalidFileSystem = class {
|
||||
exists(path) {
|
||||
throw makeError();
|
||||
}
|
||||
readFile(path) {
|
||||
throw makeError();
|
||||
}
|
||||
readFileBuffer(path) {
|
||||
throw makeError();
|
||||
}
|
||||
writeFile(path, data, exclusive) {
|
||||
throw makeError();
|
||||
}
|
||||
removeFile(path) {
|
||||
throw makeError();
|
||||
}
|
||||
symlink(target, path) {
|
||||
throw makeError();
|
||||
}
|
||||
readdir(path) {
|
||||
throw makeError();
|
||||
}
|
||||
lstat(path) {
|
||||
throw makeError();
|
||||
}
|
||||
stat(path) {
|
||||
throw makeError();
|
||||
}
|
||||
pwd() {
|
||||
throw makeError();
|
||||
}
|
||||
chdir(path) {
|
||||
throw makeError();
|
||||
}
|
||||
extname(path) {
|
||||
throw makeError();
|
||||
}
|
||||
copyFile(from, to) {
|
||||
throw makeError();
|
||||
}
|
||||
moveFile(from, to) {
|
||||
throw makeError();
|
||||
}
|
||||
ensureDir(path) {
|
||||
throw makeError();
|
||||
}
|
||||
removeDeep(path) {
|
||||
throw makeError();
|
||||
}
|
||||
isCaseSensitive() {
|
||||
throw makeError();
|
||||
}
|
||||
resolve(...paths) {
|
||||
throw makeError();
|
||||
}
|
||||
dirname(file) {
|
||||
throw makeError();
|
||||
}
|
||||
join(basePath, ...paths) {
|
||||
throw makeError();
|
||||
}
|
||||
isRoot(path) {
|
||||
throw makeError();
|
||||
}
|
||||
isRooted(path) {
|
||||
throw makeError();
|
||||
}
|
||||
relative(from, to) {
|
||||
throw makeError();
|
||||
}
|
||||
basename(filePath, extension) {
|
||||
throw makeError();
|
||||
}
|
||||
realpath(filePath) {
|
||||
throw makeError();
|
||||
}
|
||||
getDefaultLibLocation() {
|
||||
throw makeError();
|
||||
}
|
||||
normalize(path) {
|
||||
throw makeError();
|
||||
}
|
||||
};
|
||||
function makeError() {
|
||||
return new Error("FileSystem has not been configured. Please call `setFileSystem()` before calling this method.");
|
||||
}
|
||||
|
||||
// packages/compiler-cli/src/ngtsc/file_system/src/util.js
|
||||
var TS_DTS_TSX_JS_EXTENSION = /(?:\.d)?\.ts$|\.tsx$|\.js$/;
|
||||
function normalizeSeparators(path) {
|
||||
return path.replace(/\\/g, "/");
|
||||
}
|
||||
function stripExtension(path) {
|
||||
return path.replace(TS_DTS_TSX_JS_EXTENSION, "");
|
||||
}
|
||||
function getSourceFileOrError(program, fileName) {
|
||||
const sf = program.getSourceFile(fileName);
|
||||
if (sf === void 0) {
|
||||
throw new Error(`Program does not contain "${fileName}" - available files are ${program.getSourceFiles().map((sf2) => sf2.fileName).join(", ")}`);
|
||||
}
|
||||
return sf;
|
||||
}
|
||||
|
||||
// packages/compiler-cli/src/ngtsc/file_system/src/helpers.js
|
||||
var fs = new InvalidFileSystem();
|
||||
function getFileSystem() {
|
||||
return fs;
|
||||
}
|
||||
function setFileSystem(fileSystem) {
|
||||
fs = fileSystem;
|
||||
}
|
||||
function absoluteFrom(path) {
|
||||
if (!fs.isRooted(path)) {
|
||||
throw new Error(`Internal Error: absoluteFrom(${path}): path is not absolute`);
|
||||
}
|
||||
return fs.resolve(path);
|
||||
}
|
||||
var ABSOLUTE_PATH = Symbol("AbsolutePath");
|
||||
function absoluteFromSourceFile(sf) {
|
||||
const sfWithPatch = sf;
|
||||
if (sfWithPatch[ABSOLUTE_PATH] === void 0) {
|
||||
sfWithPatch[ABSOLUTE_PATH] = fs.resolve(sfWithPatch.fileName);
|
||||
}
|
||||
return sfWithPatch[ABSOLUTE_PATH];
|
||||
}
|
||||
function relativeFrom(path) {
|
||||
const normalized = normalizeSeparators(path);
|
||||
if (fs.isRooted(normalized)) {
|
||||
throw new Error(`Internal Error: relativeFrom(${path}): path is not relative`);
|
||||
}
|
||||
return normalized;
|
||||
}
|
||||
function dirname(file) {
|
||||
return fs.dirname(file);
|
||||
}
|
||||
function join(basePath, ...paths) {
|
||||
return fs.join(basePath, ...paths);
|
||||
}
|
||||
function resolve(basePath, ...paths) {
|
||||
return fs.resolve(basePath, ...paths);
|
||||
}
|
||||
function isRoot(path) {
|
||||
return fs.isRoot(path);
|
||||
}
|
||||
function isRooted(path) {
|
||||
return fs.isRooted(path);
|
||||
}
|
||||
function relative(from, to) {
|
||||
return fs.relative(from, to);
|
||||
}
|
||||
function basename(filePath, extension) {
|
||||
return fs.basename(filePath, extension);
|
||||
}
|
||||
function isLocalRelativePath(relativePath) {
|
||||
return !isRooted(relativePath) && !relativePath.startsWith("..");
|
||||
}
|
||||
function toRelativeImport(relativePath) {
|
||||
return isLocalRelativePath(relativePath) ? `./${relativePath}` : relativePath;
|
||||
}
|
||||
|
||||
// packages/compiler-cli/src/ngtsc/file_system/src/compiler_host.js
|
||||
import * as os from "os";
|
||||
import ts from "typescript";
|
||||
var NgtscCompilerHost = class {
|
||||
fs;
|
||||
options;
|
||||
constructor(fs2, options = {}) {
|
||||
this.fs = fs2;
|
||||
this.options = options;
|
||||
}
|
||||
getSourceFile(fileName, languageVersion) {
|
||||
const text = this.readFile(fileName);
|
||||
return text !== void 0 ? ts.createSourceFile(fileName, text, languageVersion, true) : void 0;
|
||||
}
|
||||
getDefaultLibFileName(options) {
|
||||
return this.fs.join(this.getDefaultLibLocation(), ts.getDefaultLibFileName(options));
|
||||
}
|
||||
getDefaultLibLocation() {
|
||||
return this.fs.getDefaultLibLocation();
|
||||
}
|
||||
writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles) {
|
||||
const path = absoluteFrom(fileName);
|
||||
this.fs.ensureDir(this.fs.dirname(path));
|
||||
this.fs.writeFile(path, data);
|
||||
}
|
||||
getCurrentDirectory() {
|
||||
return this.fs.pwd();
|
||||
}
|
||||
getCanonicalFileName(fileName) {
|
||||
return this.useCaseSensitiveFileNames() ? fileName : fileName.toLowerCase();
|
||||
}
|
||||
useCaseSensitiveFileNames() {
|
||||
return this.fs.isCaseSensitive();
|
||||
}
|
||||
getNewLine() {
|
||||
switch (this.options.newLine) {
|
||||
case ts.NewLineKind.CarriageReturnLineFeed:
|
||||
return "\r\n";
|
||||
case ts.NewLineKind.LineFeed:
|
||||
return "\n";
|
||||
default:
|
||||
return os.EOL;
|
||||
}
|
||||
}
|
||||
fileExists(fileName) {
|
||||
const absPath = this.fs.resolve(fileName);
|
||||
return this.fs.exists(absPath) && this.fs.stat(absPath).isFile();
|
||||
}
|
||||
readFile(fileName) {
|
||||
const absPath = this.fs.resolve(fileName);
|
||||
if (!this.fileExists(absPath)) {
|
||||
return void 0;
|
||||
}
|
||||
return this.fs.readFile(absPath);
|
||||
}
|
||||
realpath(path) {
|
||||
return this.fs.realpath(this.fs.resolve(path));
|
||||
}
|
||||
};
|
||||
|
||||
// packages/compiler-cli/src/ngtsc/file_system/src/logical.js
|
||||
var LogicalProjectPath = {
|
||||
/**
|
||||
* Get the relative path between two `LogicalProjectPath`s.
|
||||
*
|
||||
* This will return a `PathSegment` which would be a valid module specifier to use in `from` when
|
||||
* importing from `to`.
|
||||
*/
|
||||
relativePathBetween: function(from, to) {
|
||||
const relativePath = relative(dirname(resolve(from)), resolve(to));
|
||||
return toRelativeImport(relativePath);
|
||||
}
|
||||
};
|
||||
var LogicalFileSystem = class {
|
||||
compilerHost;
|
||||
/**
|
||||
* The root directories of the project, sorted with the longest path first.
|
||||
*/
|
||||
rootDirs;
|
||||
/**
|
||||
* The same root directories as `rootDirs` but with each one converted to its
|
||||
* canonical form for matching in case-insensitive file-systems.
|
||||
*/
|
||||
canonicalRootDirs;
|
||||
/**
|
||||
* A cache of file paths to project paths, because computation of these paths is slightly
|
||||
* expensive.
|
||||
*/
|
||||
cache = /* @__PURE__ */ new Map();
|
||||
constructor(rootDirs, compilerHost) {
|
||||
this.compilerHost = compilerHost;
|
||||
this.rootDirs = rootDirs.concat([]).sort((a, b) => b.length - a.length);
|
||||
this.canonicalRootDirs = this.rootDirs.map((dir) => this.compilerHost.getCanonicalFileName(dir));
|
||||
}
|
||||
/**
|
||||
* Get the logical path in the project of a `ts.SourceFile`.
|
||||
*
|
||||
* This method is provided as a convenient alternative to calling
|
||||
* `logicalPathOfFile(absoluteFromSourceFile(sf))`.
|
||||
*/
|
||||
logicalPathOfSf(sf) {
|
||||
return this.logicalPathOfFile(absoluteFromSourceFile(sf));
|
||||
}
|
||||
/**
|
||||
* Get the logical path in the project of a source file.
|
||||
*
|
||||
* @returns A `LogicalProjectPath` to the source file, or `null` if the source file is not in any
|
||||
* of the TS project's root directories.
|
||||
*/
|
||||
logicalPathOfFile(physicalFile) {
|
||||
if (!this.cache.has(physicalFile)) {
|
||||
const canonicalFilePath = this.compilerHost.getCanonicalFileName(physicalFile);
|
||||
let logicalFile = null;
|
||||
for (let i = 0; i < this.rootDirs.length; i++) {
|
||||
const rootDir = this.rootDirs[i];
|
||||
const canonicalRootDir = this.canonicalRootDirs[i];
|
||||
if (isWithinBasePath(canonicalRootDir, canonicalFilePath)) {
|
||||
logicalFile = this.createLogicalProjectPath(physicalFile, rootDir);
|
||||
if (logicalFile.indexOf("/node_modules/") !== -1) {
|
||||
logicalFile = null;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.cache.set(physicalFile, logicalFile);
|
||||
}
|
||||
return this.cache.get(physicalFile);
|
||||
}
|
||||
createLogicalProjectPath(file, rootDir) {
|
||||
const logicalPath = stripExtension(file.slice(rootDir.length));
|
||||
return logicalPath.startsWith("/") ? logicalPath : "/" + logicalPath;
|
||||
}
|
||||
};
|
||||
function isWithinBasePath(base, path) {
|
||||
return isLocalRelativePath(relative(base, path));
|
||||
}
|
||||
|
||||
// packages/compiler-cli/src/ngtsc/file_system/src/ts_read_directory.js
|
||||
import ts2 from "typescript";
|
||||
function createFileSystemTsReadDirectoryFn(fs2) {
|
||||
if (ts2.matchFiles === void 0) {
|
||||
throw Error("Unable to read directory in configured file system. This means that TypeScript changed its file matching internals.\n\nPlease consider downgrading your TypeScript version, and report an issue in the Angular framework repository.");
|
||||
}
|
||||
const matchFilesFn = ts2.matchFiles.bind(ts2);
|
||||
return (rootDir, extensions, excludes, includes, depth) => {
|
||||
const directoryExists = (p) => {
|
||||
const resolvedPath = fs2.resolve(p);
|
||||
return fs2.exists(resolvedPath) && fs2.stat(resolvedPath).isDirectory();
|
||||
};
|
||||
return matchFilesFn(rootDir, extensions, excludes, includes, fs2.isCaseSensitive(), fs2.pwd(), depth, (p) => {
|
||||
const resolvedPath = fs2.resolve(p);
|
||||
if (!directoryExists(resolvedPath)) {
|
||||
return { directories: [], files: [] };
|
||||
}
|
||||
const children = fs2.readdir(resolvedPath);
|
||||
const files = [];
|
||||
const directories = [];
|
||||
for (const child of children) {
|
||||
try {
|
||||
if (fs2.stat(fs2.join(resolvedPath, child))?.isDirectory()) {
|
||||
directories.push(child);
|
||||
} else {
|
||||
files.push(child);
|
||||
}
|
||||
} catch (error) {
|
||||
if (error instanceof Error && error.message.includes("ENOENT")) {
|
||||
continue;
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
return { files, directories };
|
||||
}, (p) => fs2.resolve(p), (p) => directoryExists(p));
|
||||
};
|
||||
}
|
||||
|
||||
export {
|
||||
InvalidFileSystem,
|
||||
stripExtension,
|
||||
getSourceFileOrError,
|
||||
getFileSystem,
|
||||
setFileSystem,
|
||||
absoluteFrom,
|
||||
absoluteFromSourceFile,
|
||||
relativeFrom,
|
||||
dirname,
|
||||
join,
|
||||
resolve,
|
||||
isRoot,
|
||||
isRooted,
|
||||
relative,
|
||||
basename,
|
||||
isLocalRelativePath,
|
||||
toRelativeImport,
|
||||
NgtscCompilerHost,
|
||||
LogicalProjectPath,
|
||||
LogicalFileSystem,
|
||||
createFileSystemTsReadDirectoryFn
|
||||
};
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
+313
@@ -0,0 +1,313 @@
|
||||
|
||||
import {createRequire as __cjsCompatRequire} from 'module';
|
||||
const require = __cjsCompatRequire(import.meta.url);
|
||||
|
||||
|
||||
// packages/compiler-cli/src/ngtsc/translator/src/context.js
|
||||
var Context = class _Context {
|
||||
isStatement;
|
||||
constructor(isStatement) {
|
||||
this.isStatement = isStatement;
|
||||
}
|
||||
get withExpressionMode() {
|
||||
return this.isStatement ? new _Context(false) : this;
|
||||
}
|
||||
get withStatementMode() {
|
||||
return !this.isStatement ? new _Context(true) : this;
|
||||
}
|
||||
};
|
||||
|
||||
// packages/compiler-cli/src/ngtsc/translator/src/translator.js
|
||||
import * as o from "@angular/compiler";
|
||||
var UNARY_OPERATORS = /* @__PURE__ */ new Map([
|
||||
[o.UnaryOperator.Minus, "-"],
|
||||
[o.UnaryOperator.Plus, "+"]
|
||||
]);
|
||||
var BINARY_OPERATORS = /* @__PURE__ */ new Map([
|
||||
[o.BinaryOperator.And, "&&"],
|
||||
[o.BinaryOperator.Bigger, ">"],
|
||||
[o.BinaryOperator.BiggerEquals, ">="],
|
||||
[o.BinaryOperator.BitwiseAnd, "&"],
|
||||
[o.BinaryOperator.BitwiseOr, "|"],
|
||||
[o.BinaryOperator.Divide, "/"],
|
||||
[o.BinaryOperator.Equals, "=="],
|
||||
[o.BinaryOperator.Identical, "==="],
|
||||
[o.BinaryOperator.Lower, "<"],
|
||||
[o.BinaryOperator.LowerEquals, "<="],
|
||||
[o.BinaryOperator.Minus, "-"],
|
||||
[o.BinaryOperator.Modulo, "%"],
|
||||
[o.BinaryOperator.Multiply, "*"],
|
||||
[o.BinaryOperator.NotEquals, "!="],
|
||||
[o.BinaryOperator.NotIdentical, "!=="],
|
||||
[o.BinaryOperator.Or, "||"],
|
||||
[o.BinaryOperator.Plus, "+"],
|
||||
[o.BinaryOperator.NullishCoalesce, "??"],
|
||||
[o.BinaryOperator.Exponentiation, "**"],
|
||||
[o.BinaryOperator.In, "in"],
|
||||
[o.BinaryOperator.InstanceOf, "instanceof"],
|
||||
[o.BinaryOperator.Assign, "="],
|
||||
[o.BinaryOperator.AdditionAssignment, "+="],
|
||||
[o.BinaryOperator.SubtractionAssignment, "-="],
|
||||
[o.BinaryOperator.MultiplicationAssignment, "*="],
|
||||
[o.BinaryOperator.DivisionAssignment, "/="],
|
||||
[o.BinaryOperator.RemainderAssignment, "%="],
|
||||
[o.BinaryOperator.ExponentiationAssignment, "**="],
|
||||
[o.BinaryOperator.AndAssignment, "&&="],
|
||||
[o.BinaryOperator.OrAssignment, "||="],
|
||||
[o.BinaryOperator.NullishCoalesceAssignment, "??="]
|
||||
]);
|
||||
var ExpressionTranslatorVisitor = class {
|
||||
factory;
|
||||
imports;
|
||||
contextFile;
|
||||
downlevelTaggedTemplates;
|
||||
downlevelVariableDeclarations;
|
||||
recordWrappedNode;
|
||||
constructor(factory, imports, contextFile, options) {
|
||||
this.factory = factory;
|
||||
this.imports = imports;
|
||||
this.contextFile = contextFile;
|
||||
this.downlevelTaggedTemplates = options.downlevelTaggedTemplates === true;
|
||||
this.downlevelVariableDeclarations = options.downlevelVariableDeclarations === true;
|
||||
this.recordWrappedNode = options.recordWrappedNode || (() => {
|
||||
});
|
||||
}
|
||||
visitDeclareVarStmt(stmt, context) {
|
||||
const varType = this.downlevelVariableDeclarations ? "var" : stmt.hasModifier(o.StmtModifier.Final) ? "const" : "let";
|
||||
return this.attachComments(this.factory.createVariableDeclaration(stmt.name, stmt.value?.visitExpression(this, context.withExpressionMode), varType), stmt.leadingComments);
|
||||
}
|
||||
visitDeclareFunctionStmt(stmt, context) {
|
||||
return this.attachComments(this.factory.createFunctionDeclaration(stmt.name, stmt.params.map((param) => param.name), this.factory.createBlock(this.visitStatements(stmt.statements, context.withStatementMode))), stmt.leadingComments);
|
||||
}
|
||||
visitExpressionStmt(stmt, context) {
|
||||
return this.attachComments(this.factory.createExpressionStatement(stmt.expr.visitExpression(this, context.withStatementMode)), stmt.leadingComments);
|
||||
}
|
||||
visitReturnStmt(stmt, context) {
|
||||
return this.attachComments(this.factory.createReturnStatement(stmt.value.visitExpression(this, context.withExpressionMode)), stmt.leadingComments);
|
||||
}
|
||||
visitIfStmt(stmt, context) {
|
||||
return this.attachComments(this.factory.createIfStatement(stmt.condition.visitExpression(this, context), this.factory.createBlock(this.visitStatements(stmt.trueCase, context.withStatementMode)), stmt.falseCase.length > 0 ? this.factory.createBlock(this.visitStatements(stmt.falseCase, context.withStatementMode)) : null), stmt.leadingComments);
|
||||
}
|
||||
visitReadVarExpr(ast, _context) {
|
||||
const identifier = this.factory.createIdentifier(ast.name);
|
||||
this.setSourceMapRange(identifier, ast.sourceSpan);
|
||||
return identifier;
|
||||
}
|
||||
visitInvokeFunctionExpr(ast, context) {
|
||||
return this.setSourceMapRange(this.factory.createCallExpression(ast.fn.visitExpression(this, context), ast.args.map((arg) => arg.visitExpression(this, context)), ast.pure), ast.sourceSpan);
|
||||
}
|
||||
visitTaggedTemplateLiteralExpr(ast, context) {
|
||||
return this.setSourceMapRange(this.createTaggedTemplateExpression(ast.tag.visitExpression(this, context), this.getTemplateLiteralFromAst(ast.template, context)), ast.sourceSpan);
|
||||
}
|
||||
visitTemplateLiteralExpr(ast, context) {
|
||||
return this.setSourceMapRange(this.factory.createTemplateLiteral(this.getTemplateLiteralFromAst(ast, context)), ast.sourceSpan);
|
||||
}
|
||||
visitInstantiateExpr(ast, context) {
|
||||
return this.factory.createNewExpression(ast.classExpr.visitExpression(this, context), ast.args.map((arg) => arg.visitExpression(this, context)));
|
||||
}
|
||||
visitLiteralExpr(ast, _context) {
|
||||
return this.setSourceMapRange(this.factory.createLiteral(ast.value), ast.sourceSpan);
|
||||
}
|
||||
visitRegularExpressionLiteral(ast, context) {
|
||||
return this.setSourceMapRange(this.factory.createRegularExpressionLiteral(ast.body, ast.flags), ast.sourceSpan);
|
||||
}
|
||||
visitLocalizedString(ast, context) {
|
||||
const elements = [createTemplateElement(ast.serializeI18nHead())];
|
||||
const expressions = [];
|
||||
for (let i = 0; i < ast.expressions.length; i++) {
|
||||
const placeholder = this.setSourceMapRange(ast.expressions[i].visitExpression(this, context), ast.getPlaceholderSourceSpan(i));
|
||||
expressions.push(placeholder);
|
||||
elements.push(createTemplateElement(ast.serializeI18nTemplatePart(i + 1)));
|
||||
}
|
||||
const localizeTag = this.factory.createIdentifier("$localize");
|
||||
return this.setSourceMapRange(this.createTaggedTemplateExpression(localizeTag, { elements, expressions }), ast.sourceSpan);
|
||||
}
|
||||
createTaggedTemplateExpression(tag, template) {
|
||||
return this.downlevelTaggedTemplates ? this.createES5TaggedTemplateFunctionCall(tag, template) : this.factory.createTaggedTemplate(tag, template);
|
||||
}
|
||||
/**
|
||||
* Translate the tagged template literal into a call that is compatible with ES5, using the
|
||||
* imported `__makeTemplateObject` helper for ES5 formatted output.
|
||||
*/
|
||||
createES5TaggedTemplateFunctionCall(tagHandler, { elements, expressions }) {
|
||||
const __makeTemplateObjectHelper = this.imports.addImport({
|
||||
exportModuleSpecifier: "tslib",
|
||||
exportSymbolName: "__makeTemplateObject",
|
||||
requestedFile: this.contextFile
|
||||
});
|
||||
const cooked = [];
|
||||
const raw = [];
|
||||
for (const element of elements) {
|
||||
cooked.push(this.factory.setSourceMapRange(this.factory.createLiteral(element.cooked), element.range));
|
||||
raw.push(this.factory.setSourceMapRange(this.factory.createLiteral(element.raw), element.range));
|
||||
}
|
||||
const templateHelperCall = this.factory.createCallExpression(
|
||||
__makeTemplateObjectHelper,
|
||||
[this.factory.createArrayLiteral(cooked), this.factory.createArrayLiteral(raw)],
|
||||
/* pure */
|
||||
false
|
||||
);
|
||||
return this.factory.createCallExpression(
|
||||
tagHandler,
|
||||
[templateHelperCall, ...expressions],
|
||||
/* pure */
|
||||
false
|
||||
);
|
||||
}
|
||||
visitExternalExpr(ast, _context) {
|
||||
if (ast.value.name === null) {
|
||||
if (ast.value.moduleName === null) {
|
||||
throw new Error("Invalid import without name nor moduleName");
|
||||
}
|
||||
return this.imports.addImport({
|
||||
exportModuleSpecifier: ast.value.moduleName,
|
||||
exportSymbolName: null,
|
||||
requestedFile: this.contextFile
|
||||
});
|
||||
}
|
||||
if (ast.value.moduleName !== null) {
|
||||
return this.imports.addImport({
|
||||
exportModuleSpecifier: ast.value.moduleName,
|
||||
exportSymbolName: ast.value.name,
|
||||
requestedFile: this.contextFile
|
||||
});
|
||||
} else {
|
||||
return this.factory.createIdentifier(ast.value.name);
|
||||
}
|
||||
}
|
||||
visitConditionalExpr(ast, context) {
|
||||
return this.factory.createConditional(ast.condition.visitExpression(this, context), ast.trueCase.visitExpression(this, context), ast.falseCase.visitExpression(this, context));
|
||||
}
|
||||
visitDynamicImportExpr(ast, context) {
|
||||
const urlExpression = typeof ast.url === "string" ? this.factory.createLiteral(ast.url) : ast.url.visitExpression(this, context);
|
||||
if (ast.urlComment) {
|
||||
this.factory.attachComments(urlExpression, [o.leadingComment(ast.urlComment, true)]);
|
||||
}
|
||||
return this.factory.createDynamicImport(urlExpression);
|
||||
}
|
||||
visitNotExpr(ast, context) {
|
||||
return this.factory.createUnaryExpression("!", ast.condition.visitExpression(this, context));
|
||||
}
|
||||
visitFunctionExpr(ast, context) {
|
||||
return this.factory.createFunctionExpression(ast.name ?? null, ast.params.map((param) => param.name), this.factory.createBlock(this.visitStatements(ast.statements, context)));
|
||||
}
|
||||
visitArrowFunctionExpr(ast, context) {
|
||||
return this.factory.createArrowFunctionExpression(ast.params.map((param) => param.name), Array.isArray(ast.body) ? this.factory.createBlock(this.visitStatements(ast.body, context)) : ast.body.visitExpression(this, context));
|
||||
}
|
||||
visitBinaryOperatorExpr(ast, context) {
|
||||
if (!BINARY_OPERATORS.has(ast.operator)) {
|
||||
throw new Error(`Unknown binary operator: ${o.BinaryOperator[ast.operator]}`);
|
||||
}
|
||||
const operator = BINARY_OPERATORS.get(ast.operator);
|
||||
if (ast.isAssignment()) {
|
||||
return this.factory.createAssignment(ast.lhs.visitExpression(this, context), operator, ast.rhs.visitExpression(this, context));
|
||||
}
|
||||
return this.factory.createBinaryExpression(ast.lhs.visitExpression(this, context), operator, ast.rhs.visitExpression(this, context));
|
||||
}
|
||||
visitReadPropExpr(ast, context) {
|
||||
return this.factory.createPropertyAccess(ast.receiver.visitExpression(this, context), ast.name);
|
||||
}
|
||||
visitReadKeyExpr(ast, context) {
|
||||
return this.factory.createElementAccess(ast.receiver.visitExpression(this, context), ast.index.visitExpression(this, context));
|
||||
}
|
||||
visitLiteralArrayExpr(ast, context) {
|
||||
return this.factory.createArrayLiteral(ast.entries.map((expr) => this.setSourceMapRange(expr.visitExpression(this, context), ast.sourceSpan)));
|
||||
}
|
||||
visitLiteralMapExpr(ast, context) {
|
||||
const properties = ast.entries.map((entry) => {
|
||||
return entry instanceof o.LiteralMapPropertyAssignment ? {
|
||||
kind: "property",
|
||||
propertyName: entry.key,
|
||||
quoted: entry.quoted,
|
||||
value: entry.value.visitExpression(this, context)
|
||||
} : {
|
||||
kind: "spread",
|
||||
expression: entry.expression.visitExpression(this, context)
|
||||
};
|
||||
});
|
||||
return this.setSourceMapRange(this.factory.createObjectLiteral(properties), ast.sourceSpan);
|
||||
}
|
||||
visitCommaExpr(ast, context) {
|
||||
throw new Error("Method not implemented.");
|
||||
}
|
||||
visitTemplateLiteralElementExpr(ast, context) {
|
||||
throw new Error("Method not implemented");
|
||||
}
|
||||
visitSpreadElementExpr(ast, context) {
|
||||
const expression = ast.expression.visitExpression(this, context);
|
||||
return this.setSourceMapRange(this.factory.createSpreadElement(expression), ast.sourceSpan);
|
||||
}
|
||||
visitWrappedNodeExpr(ast, _context) {
|
||||
this.recordWrappedNode(ast);
|
||||
return ast.node;
|
||||
}
|
||||
visitTypeofExpr(ast, context) {
|
||||
return this.factory.createTypeOfExpression(ast.expr.visitExpression(this, context));
|
||||
}
|
||||
visitVoidExpr(ast, context) {
|
||||
return this.factory.createVoidExpression(ast.expr.visitExpression(this, context));
|
||||
}
|
||||
visitUnaryOperatorExpr(ast, context) {
|
||||
if (!UNARY_OPERATORS.has(ast.operator)) {
|
||||
throw new Error(`Unknown unary operator: ${o.UnaryOperator[ast.operator]}`);
|
||||
}
|
||||
return this.factory.createUnaryExpression(UNARY_OPERATORS.get(ast.operator), ast.expr.visitExpression(this, context));
|
||||
}
|
||||
visitParenthesizedExpr(ast, context) {
|
||||
const result = ast.expr.visitExpression(this, context);
|
||||
return this.factory.createParenthesizedExpression(result);
|
||||
}
|
||||
visitStatements(statements, context) {
|
||||
return statements.map((stmt) => stmt.visitStatement(this, context)).filter((stmt) => stmt !== void 0);
|
||||
}
|
||||
setSourceMapRange(ast, span) {
|
||||
return this.factory.setSourceMapRange(ast, createRange(span));
|
||||
}
|
||||
attachComments(statement, leadingComments) {
|
||||
if (leadingComments !== void 0) {
|
||||
this.factory.attachComments(statement, leadingComments);
|
||||
}
|
||||
return statement;
|
||||
}
|
||||
getTemplateLiteralFromAst(ast, context) {
|
||||
return {
|
||||
elements: ast.elements.map((e) => createTemplateElement({
|
||||
cooked: e.text,
|
||||
raw: e.rawText,
|
||||
range: e.sourceSpan ?? ast.sourceSpan
|
||||
})),
|
||||
expressions: ast.expressions.map((e) => e.visitExpression(this, context))
|
||||
};
|
||||
}
|
||||
};
|
||||
function createTemplateElement({ cooked, raw, range }) {
|
||||
return { cooked, raw, range: createRange(range) };
|
||||
}
|
||||
function createRange(span) {
|
||||
if (span === null) {
|
||||
return null;
|
||||
}
|
||||
const { start, end } = span;
|
||||
const { url, content } = start.file;
|
||||
if (!url) {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
url,
|
||||
content,
|
||||
start: { offset: start.offset, line: start.line, column: start.col },
|
||||
end: { offset: end.offset, line: end.line, column: end.col }
|
||||
};
|
||||
}
|
||||
|
||||
export {
|
||||
Context,
|
||||
ExpressionTranslatorVisitor
|
||||
};
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
+1365
File diff suppressed because it is too large
Load Diff
+15
@@ -0,0 +1,15 @@
|
||||
|
||||
import {createRequire as __cjsCompatRequire} from 'module';
|
||||
const require = __cjsCompatRequire(import.meta.url);
|
||||
|
||||
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
||||
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
||||
}) : x)(function(x) {
|
||||
if (typeof require !== "undefined")
|
||||
return require.apply(this, arguments);
|
||||
throw Error('Dynamic require of "' + x + '" is not supported');
|
||||
});
|
||||
|
||||
export {
|
||||
__require
|
||||
};
|
||||
+542
@@ -0,0 +1,542 @@
|
||||
|
||||
import {createRequire as __cjsCompatRequire} from 'module';
|
||||
const require = __cjsCompatRequire(import.meta.url);
|
||||
|
||||
|
||||
// packages/compiler-cli/src/ngtsc/sourcemaps/src/source_file.js
|
||||
import { decode, encode } from "@jridgewell/sourcemap-codec";
|
||||
import mapHelpers from "convert-source-map";
|
||||
|
||||
// packages/compiler-cli/src/ngtsc/sourcemaps/src/segment_marker.js
|
||||
function compareSegments(a, b) {
|
||||
return a.position - b.position;
|
||||
}
|
||||
function offsetSegment(startOfLinePositions, marker, offset) {
|
||||
if (offset === 0) {
|
||||
return marker;
|
||||
}
|
||||
let line = marker.line;
|
||||
const position = marker.position + offset;
|
||||
while (line < startOfLinePositions.length - 1 && startOfLinePositions[line + 1] <= position) {
|
||||
line++;
|
||||
}
|
||||
while (line > 0 && startOfLinePositions[line] > position) {
|
||||
line--;
|
||||
}
|
||||
const column = position - startOfLinePositions[line];
|
||||
return { line, column, position, next: void 0 };
|
||||
}
|
||||
|
||||
// packages/compiler-cli/src/ngtsc/sourcemaps/src/source_file.js
|
||||
function removeSourceMapComments(contents) {
|
||||
return mapHelpers.removeMapFileComments(mapHelpers.removeComments(contents)).replace(/\n\n$/, "\n");
|
||||
}
|
||||
var SourceFile = class {
|
||||
sourcePath;
|
||||
contents;
|
||||
rawMap;
|
||||
sources;
|
||||
fs;
|
||||
/**
|
||||
* The parsed mappings that have been flattened so that any intermediate source mappings have been
|
||||
* flattened.
|
||||
*
|
||||
* The result is that any source file mentioned in the flattened mappings have no source map (are
|
||||
* pure original source files).
|
||||
*/
|
||||
flattenedMappings;
|
||||
startOfLinePositions;
|
||||
constructor(sourcePath, contents, rawMap, sources, fs) {
|
||||
this.sourcePath = sourcePath;
|
||||
this.contents = contents;
|
||||
this.rawMap = rawMap;
|
||||
this.sources = sources;
|
||||
this.fs = fs;
|
||||
this.contents = removeSourceMapComments(contents);
|
||||
this.startOfLinePositions = computeStartOfLinePositions(this.contents);
|
||||
this.flattenedMappings = this.flattenMappings();
|
||||
}
|
||||
/**
|
||||
* Render the raw source map generated from the flattened mappings.
|
||||
*/
|
||||
renderFlattenedSourceMap() {
|
||||
const sources = new IndexedMap();
|
||||
const names = new IndexedSet();
|
||||
const mappings = [];
|
||||
const sourcePathDir = this.fs.dirname(this.sourcePath);
|
||||
const relativeSourcePathCache = new Cache((input) => this.fs.relative(sourcePathDir, input));
|
||||
for (const mapping of this.flattenedMappings) {
|
||||
const sourceIndex = sources.set(relativeSourcePathCache.get(mapping.originalSource.sourcePath), mapping.originalSource.contents);
|
||||
const mappingArray = [
|
||||
mapping.generatedSegment.column,
|
||||
sourceIndex,
|
||||
mapping.originalSegment.line,
|
||||
mapping.originalSegment.column
|
||||
];
|
||||
if (mapping.name !== void 0) {
|
||||
const nameIndex = names.add(mapping.name);
|
||||
mappingArray.push(nameIndex);
|
||||
}
|
||||
const line = mapping.generatedSegment.line;
|
||||
while (line >= mappings.length) {
|
||||
mappings.push([]);
|
||||
}
|
||||
mappings[line].push(mappingArray);
|
||||
}
|
||||
const sourceMap = {
|
||||
version: 3,
|
||||
file: this.fs.relative(sourcePathDir, this.sourcePath),
|
||||
sources: sources.keys,
|
||||
names: names.values,
|
||||
mappings: encode(mappings),
|
||||
sourcesContent: sources.values
|
||||
};
|
||||
return sourceMap;
|
||||
}
|
||||
/**
|
||||
* Find the original mapped location for the given `line` and `column` in the generated file.
|
||||
*
|
||||
* First we search for a mapping whose generated segment is at or directly before the given
|
||||
* location. Then we compute the offset between the given location and the matching generated
|
||||
* segment. Finally we apply this offset to the original source segment to get the desired
|
||||
* original location.
|
||||
*/
|
||||
getOriginalLocation(line, column) {
|
||||
if (this.flattenedMappings.length === 0) {
|
||||
return null;
|
||||
}
|
||||
let position;
|
||||
if (line < this.startOfLinePositions.length) {
|
||||
position = this.startOfLinePositions[line] + column;
|
||||
} else {
|
||||
position = this.contents.length;
|
||||
}
|
||||
const locationSegment = { line, column, position, next: void 0 };
|
||||
let mappingIndex = findLastMappingIndexBefore(this.flattenedMappings, locationSegment, false, 0);
|
||||
if (mappingIndex < 0) {
|
||||
mappingIndex = 0;
|
||||
}
|
||||
const { originalSegment, originalSource, generatedSegment } = this.flattenedMappings[mappingIndex];
|
||||
const offset = locationSegment.position - generatedSegment.position;
|
||||
const offsetOriginalSegment = offsetSegment(originalSource.startOfLinePositions, originalSegment, offset);
|
||||
return {
|
||||
file: originalSource.sourcePath,
|
||||
line: offsetOriginalSegment.line,
|
||||
column: offsetOriginalSegment.column
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Flatten the parsed mappings for this source file, so that all the mappings are to pure original
|
||||
* source files with no transitive source maps.
|
||||
*/
|
||||
flattenMappings() {
|
||||
const mappings = parseMappings(this.rawMap && this.rawMap.map, this.sources, this.startOfLinePositions);
|
||||
ensureOriginalSegmentLinks(mappings);
|
||||
const flattenedMappings = [];
|
||||
for (let mappingIndex = 0; mappingIndex < mappings.length; mappingIndex++) {
|
||||
const aToBmapping = mappings[mappingIndex];
|
||||
const bSource = aToBmapping.originalSource;
|
||||
if (bSource.flattenedMappings.length === 0) {
|
||||
flattenedMappings.push(aToBmapping);
|
||||
continue;
|
||||
}
|
||||
const incomingStart = aToBmapping.originalSegment;
|
||||
const incomingEnd = incomingStart.next;
|
||||
let outgoingStartIndex = findLastMappingIndexBefore(bSource.flattenedMappings, incomingStart, false, 0);
|
||||
if (outgoingStartIndex < 0) {
|
||||
outgoingStartIndex = 0;
|
||||
}
|
||||
const outgoingEndIndex = incomingEnd !== void 0 ? findLastMappingIndexBefore(bSource.flattenedMappings, incomingEnd, true, outgoingStartIndex) : bSource.flattenedMappings.length - 1;
|
||||
for (let bToCmappingIndex = outgoingStartIndex; bToCmappingIndex <= outgoingEndIndex; bToCmappingIndex++) {
|
||||
const bToCmapping = bSource.flattenedMappings[bToCmappingIndex];
|
||||
flattenedMappings.push(mergeMappings(this, aToBmapping, bToCmapping));
|
||||
}
|
||||
}
|
||||
return flattenedMappings;
|
||||
}
|
||||
};
|
||||
function findLastMappingIndexBefore(mappings, marker, exclusive, lowerIndex) {
|
||||
let upperIndex = mappings.length - 1;
|
||||
const test = exclusive ? -1 : 0;
|
||||
if (compareSegments(mappings[lowerIndex].generatedSegment, marker) > test) {
|
||||
return -1;
|
||||
}
|
||||
let matchingIndex = -1;
|
||||
while (lowerIndex <= upperIndex) {
|
||||
const index = upperIndex + lowerIndex >> 1;
|
||||
if (compareSegments(mappings[index].generatedSegment, marker) <= test) {
|
||||
matchingIndex = index;
|
||||
lowerIndex = index + 1;
|
||||
} else {
|
||||
upperIndex = index - 1;
|
||||
}
|
||||
}
|
||||
return matchingIndex;
|
||||
}
|
||||
function mergeMappings(generatedSource, ab, bc) {
|
||||
const name = bc.name || ab.name;
|
||||
const diff = compareSegments(bc.generatedSegment, ab.originalSegment);
|
||||
if (diff > 0) {
|
||||
return {
|
||||
name,
|
||||
generatedSegment: offsetSegment(generatedSource.startOfLinePositions, ab.generatedSegment, diff),
|
||||
originalSource: bc.originalSource,
|
||||
originalSegment: bc.originalSegment
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
name,
|
||||
generatedSegment: ab.generatedSegment,
|
||||
originalSource: bc.originalSource,
|
||||
originalSegment: offsetSegment(bc.originalSource.startOfLinePositions, bc.originalSegment, -diff)
|
||||
};
|
||||
}
|
||||
}
|
||||
function parseMappings(rawMap, sources, generatedSourceStartOfLinePositions) {
|
||||
if (rawMap === null) {
|
||||
return [];
|
||||
}
|
||||
const rawMappings = decode(rawMap.mappings);
|
||||
if (rawMappings === null) {
|
||||
return [];
|
||||
}
|
||||
const mappings = [];
|
||||
for (let generatedLine = 0; generatedLine < rawMappings.length; generatedLine++) {
|
||||
const generatedLineMappings = rawMappings[generatedLine];
|
||||
for (const rawMapping of generatedLineMappings) {
|
||||
if (rawMapping.length >= 4) {
|
||||
const originalSource = sources[rawMapping[1]];
|
||||
if (originalSource === null || originalSource === void 0) {
|
||||
continue;
|
||||
}
|
||||
const generatedColumn = rawMapping[0];
|
||||
const name = rawMapping.length === 5 ? rawMap.names[rawMapping[4]] : void 0;
|
||||
const line = rawMapping[2];
|
||||
const column = rawMapping[3];
|
||||
const generatedSegment = {
|
||||
line: generatedLine,
|
||||
column: generatedColumn,
|
||||
position: generatedSourceStartOfLinePositions[generatedLine] + generatedColumn,
|
||||
next: void 0
|
||||
};
|
||||
const originalSegment = {
|
||||
line,
|
||||
column,
|
||||
position: originalSource.startOfLinePositions[line] + column,
|
||||
next: void 0
|
||||
};
|
||||
mappings.push({ name, generatedSegment, originalSegment, originalSource });
|
||||
}
|
||||
}
|
||||
}
|
||||
return mappings;
|
||||
}
|
||||
function extractOriginalSegments(mappings) {
|
||||
const originalSegments = /* @__PURE__ */ new Map();
|
||||
for (const mapping of mappings) {
|
||||
const originalSource = mapping.originalSource;
|
||||
if (!originalSegments.has(originalSource)) {
|
||||
originalSegments.set(originalSource, []);
|
||||
}
|
||||
const segments = originalSegments.get(originalSource);
|
||||
segments.push(mapping.originalSegment);
|
||||
}
|
||||
originalSegments.forEach((segmentMarkers) => segmentMarkers.sort(compareSegments));
|
||||
return originalSegments;
|
||||
}
|
||||
function ensureOriginalSegmentLinks(mappings) {
|
||||
const segmentsBySource = extractOriginalSegments(mappings);
|
||||
segmentsBySource.forEach((markers) => {
|
||||
for (let i = 0; i < markers.length - 1; i++) {
|
||||
markers[i].next = markers[i + 1];
|
||||
}
|
||||
});
|
||||
}
|
||||
function computeStartOfLinePositions(str) {
|
||||
const NEWLINE_MARKER_OFFSET = 1;
|
||||
const lineLengths = computeLineLengths(str);
|
||||
const startPositions = [0];
|
||||
for (let i = 0; i < lineLengths.length - 1; i++) {
|
||||
startPositions.push(startPositions[i] + lineLengths[i] + NEWLINE_MARKER_OFFSET);
|
||||
}
|
||||
return startPositions;
|
||||
}
|
||||
function computeLineLengths(str) {
|
||||
return str.split(/\n/).map((s) => s.length);
|
||||
}
|
||||
var IndexedMap = class {
|
||||
map = /* @__PURE__ */ new Map();
|
||||
/**
|
||||
* An array of keys added to this map.
|
||||
*
|
||||
* This array is guaranteed to be in the order of the first time the key was added to the map.
|
||||
*/
|
||||
keys = [];
|
||||
/**
|
||||
* An array of values added to this map.
|
||||
*
|
||||
* This array is guaranteed to be in the order of the first time the associated key was added to
|
||||
* the map.
|
||||
*/
|
||||
values = [];
|
||||
/**
|
||||
* Associate the `value` with the `key` and return the index of the key in the collection.
|
||||
*
|
||||
* If the `key` already exists then the `value` is not set and the index of that `key` is
|
||||
* returned; otherwise the `key` and `value` are stored and the index of the new `key` is
|
||||
* returned.
|
||||
*
|
||||
* @param key the key to associated with the `value`.
|
||||
* @param value the value to associated with the `key`.
|
||||
* @returns the index of the `key` in the `keys` array.
|
||||
*/
|
||||
set(key, value) {
|
||||
if (this.map.has(key)) {
|
||||
return this.map.get(key);
|
||||
}
|
||||
const index = this.values.push(value) - 1;
|
||||
this.keys.push(key);
|
||||
this.map.set(key, index);
|
||||
return index;
|
||||
}
|
||||
};
|
||||
var IndexedSet = class {
|
||||
map = /* @__PURE__ */ new Map();
|
||||
/**
|
||||
* An array of values added to this set.
|
||||
* This array is guaranteed to be in the order of the first time the value was added to the set.
|
||||
*/
|
||||
values = [];
|
||||
/**
|
||||
* Add the `value` to the `values` array, if it doesn't already exist; returning the index of the
|
||||
* `value` in the `values` array.
|
||||
*
|
||||
* If the `value` already exists then the index of that `value` is returned, otherwise the new
|
||||
* `value` is stored and the new index returned.
|
||||
*
|
||||
* @param value the value to add to the set.
|
||||
* @returns the index of the `value` in the `values` array.
|
||||
*/
|
||||
add(value) {
|
||||
if (this.map.has(value)) {
|
||||
return this.map.get(value);
|
||||
}
|
||||
const index = this.values.push(value) - 1;
|
||||
this.map.set(value, index);
|
||||
return index;
|
||||
}
|
||||
};
|
||||
var Cache = class {
|
||||
computeFn;
|
||||
map = /* @__PURE__ */ new Map();
|
||||
constructor(computeFn) {
|
||||
this.computeFn = computeFn;
|
||||
}
|
||||
get(input) {
|
||||
if (!this.map.has(input)) {
|
||||
this.map.set(input, this.computeFn(input));
|
||||
}
|
||||
return this.map.get(input);
|
||||
}
|
||||
};
|
||||
|
||||
// packages/compiler-cli/src/ngtsc/sourcemaps/src/source_file_loader.js
|
||||
import mapHelpers2 from "convert-source-map";
|
||||
|
||||
// packages/compiler-cli/src/ngtsc/sourcemaps/src/content_origin.js
|
||||
var ContentOrigin;
|
||||
(function(ContentOrigin2) {
|
||||
ContentOrigin2[ContentOrigin2["Provided"] = 0] = "Provided";
|
||||
ContentOrigin2[ContentOrigin2["Inline"] = 1] = "Inline";
|
||||
ContentOrigin2[ContentOrigin2["FileSystem"] = 2] = "FileSystem";
|
||||
})(ContentOrigin || (ContentOrigin = {}));
|
||||
|
||||
// packages/compiler-cli/src/ngtsc/sourcemaps/src/source_file_loader.js
|
||||
var SCHEME_MATCHER = /^([a-z][a-z0-9.-]*):\/\//i;
|
||||
var SourceFileLoader = class {
|
||||
fs;
|
||||
logger;
|
||||
schemeMap;
|
||||
currentPaths = [];
|
||||
constructor(fs, logger, schemeMap) {
|
||||
this.fs = fs;
|
||||
this.logger = logger;
|
||||
this.schemeMap = schemeMap;
|
||||
}
|
||||
loadSourceFile(sourcePath, contents = null, mapAndPath = null) {
|
||||
const contentsOrigin = contents !== null ? ContentOrigin.Provided : ContentOrigin.FileSystem;
|
||||
const sourceMapInfo = mapAndPath && {
|
||||
origin: ContentOrigin.Provided,
|
||||
...mapAndPath
|
||||
};
|
||||
return this.loadSourceFileInternal(sourcePath, contents, contentsOrigin, sourceMapInfo);
|
||||
}
|
||||
/**
|
||||
* The overload used internally to load source files referenced in a source-map.
|
||||
*
|
||||
* In this case there is no guarantee that it will return a non-null SourceMap.
|
||||
*
|
||||
* @param sourcePath The path to the source file to load.
|
||||
* @param contents The contents of the source file to load, if provided inline. If `null`,
|
||||
* the contents will be read from the file at the `sourcePath`.
|
||||
* @param sourceOrigin Describes where the source content came from.
|
||||
* @param sourceMapInfo The raw contents and path of the source-map file. If `null` the
|
||||
* source-map will be computed from the contents of the source file, either inline or loaded
|
||||
* from the file-system.
|
||||
*
|
||||
* @returns a SourceFile if the content for one was provided or was able to be loaded from disk,
|
||||
* `null` otherwise.
|
||||
*/
|
||||
loadSourceFileInternal(sourcePath, contents, sourceOrigin, sourceMapInfo) {
|
||||
const previousPaths = this.currentPaths.slice();
|
||||
try {
|
||||
if (contents === null) {
|
||||
if (!this.fs.exists(sourcePath)) {
|
||||
return null;
|
||||
}
|
||||
contents = this.readSourceFile(sourcePath);
|
||||
}
|
||||
if (sourceMapInfo === null) {
|
||||
sourceMapInfo = this.loadSourceMap(sourcePath, contents, sourceOrigin);
|
||||
}
|
||||
let sources = [];
|
||||
if (sourceMapInfo !== null) {
|
||||
const basePath = sourceMapInfo.mapPath || sourcePath;
|
||||
sources = this.processSources(basePath, sourceMapInfo);
|
||||
}
|
||||
return new SourceFile(sourcePath, contents, sourceMapInfo, sources, this.fs);
|
||||
} catch (e) {
|
||||
this.logger.warn(`Unable to fully load ${sourcePath} for source-map flattening: ${e.message}`);
|
||||
return null;
|
||||
} finally {
|
||||
this.currentPaths = previousPaths;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Find the source map associated with the source file whose `sourcePath` and `contents` are
|
||||
* provided.
|
||||
*
|
||||
* Source maps can be inline, as part of a base64 encoded comment, or external as a separate file
|
||||
* whose path is indicated in a comment or implied from the name of the source file itself.
|
||||
*
|
||||
* @param sourcePath the path to the source file.
|
||||
* @param sourceContents the contents of the source file.
|
||||
* @param sourceOrigin where the content of the source file came from.
|
||||
* @returns the parsed contents and path of the source-map, if loading was successful, null
|
||||
* otherwise.
|
||||
*/
|
||||
loadSourceMap(sourcePath, sourceContents, sourceOrigin) {
|
||||
const lastLine = this.getLastNonEmptyLine(sourceContents);
|
||||
const inline = mapHelpers2.commentRegex.exec(lastLine);
|
||||
if (inline !== null) {
|
||||
return {
|
||||
map: mapHelpers2.fromComment(inline.pop()).sourcemap,
|
||||
mapPath: null,
|
||||
origin: ContentOrigin.Inline
|
||||
};
|
||||
}
|
||||
if (sourceOrigin === ContentOrigin.Inline) {
|
||||
return null;
|
||||
}
|
||||
const external = mapHelpers2.mapFileCommentRegex.exec(lastLine);
|
||||
if (external) {
|
||||
try {
|
||||
const fileName = external[1] || external[2];
|
||||
const externalMapPath = this.fs.resolve(this.fs.dirname(sourcePath), fileName);
|
||||
return {
|
||||
map: this.readRawSourceMap(externalMapPath),
|
||||
mapPath: externalMapPath,
|
||||
origin: ContentOrigin.FileSystem
|
||||
};
|
||||
} catch (e) {
|
||||
this.logger.warn(`Unable to fully load ${sourcePath} for source-map flattening: ${e.message}`);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
const impliedMapPath = this.fs.resolve(sourcePath + ".map");
|
||||
if (this.fs.exists(impliedMapPath)) {
|
||||
return {
|
||||
map: this.readRawSourceMap(impliedMapPath),
|
||||
mapPath: impliedMapPath,
|
||||
origin: ContentOrigin.FileSystem
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Iterate over each of the "sources" for this source file's source map, recursively loading each
|
||||
* source file and its associated source map.
|
||||
*/
|
||||
processSources(basePath, { map, origin: sourceMapOrigin }) {
|
||||
const sourceRoot = this.fs.resolve(this.fs.dirname(basePath), this.replaceSchemeWithPath(map.sourceRoot || ""));
|
||||
return map.sources.map((source, index) => {
|
||||
const path = this.fs.resolve(sourceRoot, this.replaceSchemeWithPath(source));
|
||||
const content = map.sourcesContent && map.sourcesContent[index] || null;
|
||||
const sourceOrigin = content !== null && sourceMapOrigin !== ContentOrigin.Provided ? ContentOrigin.Inline : ContentOrigin.FileSystem;
|
||||
return this.loadSourceFileInternal(path, content, sourceOrigin, null);
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Load the contents of the source file from disk.
|
||||
*
|
||||
* @param sourcePath The path to the source file.
|
||||
*/
|
||||
readSourceFile(sourcePath) {
|
||||
this.trackPath(sourcePath);
|
||||
return this.fs.readFile(sourcePath);
|
||||
}
|
||||
/**
|
||||
* Load the source map from the file at `mapPath`, parsing its JSON contents into a `RawSourceMap`
|
||||
* object.
|
||||
*
|
||||
* @param mapPath The path to the source-map file.
|
||||
*/
|
||||
readRawSourceMap(mapPath) {
|
||||
this.trackPath(mapPath);
|
||||
return JSON.parse(this.fs.readFile(mapPath));
|
||||
}
|
||||
/**
|
||||
* Track source file paths if we have loaded them from disk so that we don't get into an infinite
|
||||
* recursion.
|
||||
*/
|
||||
trackPath(path) {
|
||||
if (this.currentPaths.includes(path)) {
|
||||
throw new Error(`Circular source file mapping dependency: ${this.currentPaths.join(" -> ")} -> ${path}`);
|
||||
}
|
||||
this.currentPaths.push(path);
|
||||
}
|
||||
getLastNonEmptyLine(contents) {
|
||||
let trailingWhitespaceIndex = contents.length - 1;
|
||||
while (trailingWhitespaceIndex > 0 && (contents[trailingWhitespaceIndex] === "\n" || contents[trailingWhitespaceIndex] === "\r")) {
|
||||
trailingWhitespaceIndex--;
|
||||
}
|
||||
let lastRealLineIndex = contents.lastIndexOf("\n", trailingWhitespaceIndex - 1);
|
||||
if (lastRealLineIndex === -1) {
|
||||
lastRealLineIndex = 0;
|
||||
}
|
||||
return contents.slice(lastRealLineIndex + 1);
|
||||
}
|
||||
/**
|
||||
* Replace any matched URL schemes with their corresponding path held in the schemeMap.
|
||||
*
|
||||
* Some build tools replace real file paths with scheme prefixed paths - e.g. `webpack://`.
|
||||
* We use the `schemeMap` passed to this class to convert such paths to "real" file paths.
|
||||
* In some cases, this is not possible, since the file was actually synthesized by the build tool.
|
||||
* But the end result is better than prefixing the sourceRoot in front of the scheme.
|
||||
*/
|
||||
replaceSchemeWithPath(path) {
|
||||
return path.replace(SCHEME_MATCHER, (_, scheme) => this.schemeMap[scheme.toLowerCase()] || "");
|
||||
}
|
||||
};
|
||||
|
||||
export {
|
||||
SourceFile,
|
||||
SourceFileLoader
|
||||
};
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
+23204
File diff suppressed because it is too large
Load Diff
+5376
File diff suppressed because it is too large
Load Diff
+644
@@ -0,0 +1,644 @@
|
||||
|
||||
import {createRequire as __cjsCompatRequire} from 'module';
|
||||
const require = __cjsCompatRequire(import.meta.url);
|
||||
|
||||
import {
|
||||
NgCompiler,
|
||||
NgCompilerHost,
|
||||
TrackedIncrementalBuildStrategy,
|
||||
freshCompilationTicket,
|
||||
incrementalFromCompilerTicket
|
||||
} from "./chunk-PW54LIP6.js";
|
||||
import {
|
||||
ActivePerfRecorder,
|
||||
OptimizeFor,
|
||||
PerfCheckpoint,
|
||||
PerfEvent,
|
||||
PerfPhase,
|
||||
TsCreateProgramDriver,
|
||||
replaceTsWithNgInErrors,
|
||||
retagAllTsFiles
|
||||
} from "./chunk-IG22BDVK.js";
|
||||
import {
|
||||
absoluteFrom,
|
||||
createFileSystemTsReadDirectoryFn,
|
||||
getFileSystem,
|
||||
resolve
|
||||
} from "./chunk-CEBE44Q5.js";
|
||||
|
||||
// packages/compiler-cli/src/transformers/api.js
|
||||
var DEFAULT_ERROR_CODE = 100;
|
||||
var UNKNOWN_ERROR_CODE = 500;
|
||||
var SOURCE = "angular";
|
||||
function isTsDiagnostic(diagnostic) {
|
||||
return diagnostic != null && diagnostic.source !== "angular";
|
||||
}
|
||||
var EmitFlags;
|
||||
(function(EmitFlags2) {
|
||||
EmitFlags2[EmitFlags2["DTS"] = 1] = "DTS";
|
||||
EmitFlags2[EmitFlags2["JS"] = 2] = "JS";
|
||||
EmitFlags2[EmitFlags2["Metadata"] = 4] = "Metadata";
|
||||
EmitFlags2[EmitFlags2["I18nBundle"] = 8] = "I18nBundle";
|
||||
EmitFlags2[EmitFlags2["Codegen"] = 16] = "Codegen";
|
||||
EmitFlags2[EmitFlags2["Default"] = 19] = "Default";
|
||||
EmitFlags2[EmitFlags2["All"] = 31] = "All";
|
||||
})(EmitFlags || (EmitFlags = {}));
|
||||
|
||||
// packages/compiler-cli/src/transformers/compiler_host.js
|
||||
import ts from "typescript";
|
||||
var wrapHostForTest = null;
|
||||
function createCompilerHost({ options, tsHost = ts.createCompilerHost(options, true) }) {
|
||||
if (wrapHostForTest !== null) {
|
||||
tsHost = wrapHostForTest(tsHost);
|
||||
}
|
||||
return tsHost;
|
||||
}
|
||||
|
||||
// packages/compiler-cli/src/ngtsc/program.js
|
||||
import { HtmlParser, MessageBundle } from "@angular/compiler";
|
||||
import ts3 from "typescript";
|
||||
|
||||
// packages/compiler-cli/src/transformers/i18n.js
|
||||
import { Xliff, Xliff2, Xmb } from "@angular/compiler";
|
||||
import * as path from "path";
|
||||
function i18nGetExtension(formatName) {
|
||||
const format = formatName.toLowerCase();
|
||||
switch (format) {
|
||||
case "xmb":
|
||||
return "xmb";
|
||||
case "xlf":
|
||||
case "xlif":
|
||||
case "xliff":
|
||||
case "xlf2":
|
||||
case "xliff2":
|
||||
return "xlf";
|
||||
}
|
||||
throw new Error(`Unsupported format "${formatName}"`);
|
||||
}
|
||||
function i18nExtract(formatName, outFile, host, options, bundle, pathResolve = path.resolve) {
|
||||
formatName = formatName || "xlf";
|
||||
const ext = i18nGetExtension(formatName);
|
||||
const content = i18nSerialize(bundle, formatName, options);
|
||||
const dstFile = outFile || `messages.${ext}`;
|
||||
const dstPath = pathResolve(options.outDir || options.basePath, dstFile);
|
||||
host.writeFile(dstPath, content, false, void 0, []);
|
||||
return [dstPath];
|
||||
}
|
||||
function i18nSerialize(bundle, formatName, options) {
|
||||
const format = formatName.toLowerCase();
|
||||
let serializer;
|
||||
switch (format) {
|
||||
case "xmb":
|
||||
serializer = new Xmb();
|
||||
break;
|
||||
case "xliff2":
|
||||
case "xlf2":
|
||||
serializer = new Xliff2();
|
||||
break;
|
||||
case "xlf":
|
||||
case "xliff":
|
||||
default:
|
||||
serializer = new Xliff();
|
||||
}
|
||||
return bundle.write(serializer, getPathNormalizer(options.basePath));
|
||||
}
|
||||
function getPathNormalizer(basePath) {
|
||||
return (sourcePath) => {
|
||||
sourcePath = basePath ? path.relative(basePath, sourcePath) : sourcePath;
|
||||
return sourcePath.split(path.sep).join("/");
|
||||
};
|
||||
}
|
||||
|
||||
// packages/compiler-cli/src/typescript_support.js
|
||||
import ts2 from "typescript";
|
||||
|
||||
// packages/compiler-cli/src/version_helpers.js
|
||||
function toNumbers(value) {
|
||||
const suffixIndex = value.lastIndexOf("-");
|
||||
return value.slice(0, suffixIndex === -1 ? value.length : suffixIndex).split(".").map((segment) => {
|
||||
const parsed = parseInt(segment, 10);
|
||||
if (isNaN(parsed)) {
|
||||
throw Error(`Unable to parse version string ${value}.`);
|
||||
}
|
||||
return parsed;
|
||||
});
|
||||
}
|
||||
function compareNumbers(a, b) {
|
||||
const max = Math.max(a.length, b.length);
|
||||
const min = Math.min(a.length, b.length);
|
||||
for (let i = 0; i < min; i++) {
|
||||
if (a[i] > b[i])
|
||||
return 1;
|
||||
if (a[i] < b[i])
|
||||
return -1;
|
||||
}
|
||||
if (min !== max) {
|
||||
const longestArray = a.length === max ? a : b;
|
||||
const comparisonResult = a.length === max ? 1 : -1;
|
||||
for (let i = min; i < max; i++) {
|
||||
if (longestArray[i] > 0) {
|
||||
return comparisonResult;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
function compareVersions(v1, v2) {
|
||||
return compareNumbers(toNumbers(v1), toNumbers(v2));
|
||||
}
|
||||
|
||||
// packages/compiler-cli/src/typescript_support.js
|
||||
var MIN_TS_VERSION = "5.9.0";
|
||||
var MAX_TS_VERSION = "6.1.0";
|
||||
var tsVersion = ts2.version;
|
||||
function checkVersion(version, minVersion, maxVersion) {
|
||||
if (compareVersions(version, minVersion) < 0 || compareVersions(version, maxVersion) >= 0) {
|
||||
throw new Error(`The Angular Compiler requires TypeScript >=${minVersion} and <${maxVersion} but ${version} was found instead.`);
|
||||
}
|
||||
}
|
||||
function verifySupportedTypeScriptVersion() {
|
||||
checkVersion(tsVersion, MIN_TS_VERSION, MAX_TS_VERSION);
|
||||
}
|
||||
|
||||
// packages/compiler-cli/src/ngtsc/program.js
|
||||
var NgtscProgram = class {
|
||||
options;
|
||||
compiler;
|
||||
/**
|
||||
* The primary TypeScript program, which is used for analysis and emit.
|
||||
*/
|
||||
tsProgram;
|
||||
host;
|
||||
incrementalStrategy;
|
||||
constructor(rootNames, options, delegateHost, oldProgram) {
|
||||
this.options = options;
|
||||
const perfRecorder = ActivePerfRecorder.zeroedToNow();
|
||||
perfRecorder.phase(PerfPhase.Setup);
|
||||
if (!options.disableTypeScriptVersionCheck) {
|
||||
verifySupportedTypeScriptVersion();
|
||||
}
|
||||
if (options.compilationMode === "experimental-local") {
|
||||
options.noEmitOnError = false;
|
||||
}
|
||||
const reuseProgram = oldProgram?.compiler.getCurrentProgram();
|
||||
this.host = NgCompilerHost.wrap(delegateHost, rootNames, options, reuseProgram ?? null);
|
||||
if (reuseProgram !== void 0) {
|
||||
retagAllTsFiles(reuseProgram);
|
||||
}
|
||||
this.tsProgram = perfRecorder.inPhase(PerfPhase.TypeScriptProgramCreate, () => ts3.createProgram(this.host.inputFiles, options, this.host, reuseProgram));
|
||||
perfRecorder.phase(PerfPhase.Unaccounted);
|
||||
perfRecorder.memory(PerfCheckpoint.TypeScriptProgramCreate);
|
||||
this.host.postProgramCreationCleanup();
|
||||
const programDriver = new TsCreateProgramDriver(this.tsProgram, this.host, this.options, this.host.shimExtensionPrefixes);
|
||||
this.incrementalStrategy = oldProgram !== void 0 ? oldProgram.incrementalStrategy.toNextBuildStrategy() : new TrackedIncrementalBuildStrategy();
|
||||
const modifiedResourceFiles = /* @__PURE__ */ new Set();
|
||||
if (this.host.getModifiedResourceFiles !== void 0) {
|
||||
const strings = this.host.getModifiedResourceFiles();
|
||||
if (strings !== void 0) {
|
||||
for (const fileString of strings) {
|
||||
modifiedResourceFiles.add(absoluteFrom(fileString));
|
||||
}
|
||||
}
|
||||
}
|
||||
let ticket;
|
||||
if (oldProgram === void 0) {
|
||||
ticket = freshCompilationTicket(
|
||||
this.tsProgram,
|
||||
options,
|
||||
this.incrementalStrategy,
|
||||
programDriver,
|
||||
perfRecorder,
|
||||
/* enableTemplateTypeChecker */
|
||||
false,
|
||||
/* usePoisonedData */
|
||||
false
|
||||
);
|
||||
} else {
|
||||
ticket = incrementalFromCompilerTicket(oldProgram.compiler, this.tsProgram, this.incrementalStrategy, programDriver, modifiedResourceFiles, perfRecorder);
|
||||
}
|
||||
this.compiler = NgCompiler.fromTicket(ticket, this.host);
|
||||
}
|
||||
getTsProgram() {
|
||||
return this.tsProgram;
|
||||
}
|
||||
getReuseTsProgram() {
|
||||
return this.compiler.getCurrentProgram();
|
||||
}
|
||||
getTsOptionDiagnostics(cancellationToken) {
|
||||
return this.compiler.perfRecorder.inPhase(PerfPhase.TypeScriptDiagnostics, () => this.tsProgram.getOptionsDiagnostics(cancellationToken));
|
||||
}
|
||||
getTsSyntacticDiagnostics(sourceFile, cancellationToken) {
|
||||
return this.compiler.perfRecorder.inPhase(PerfPhase.TypeScriptDiagnostics, () => {
|
||||
const ignoredFiles = this.compiler.ignoreForDiagnostics;
|
||||
let res;
|
||||
if (sourceFile !== void 0) {
|
||||
if (ignoredFiles.has(sourceFile)) {
|
||||
return [];
|
||||
}
|
||||
res = this.tsProgram.getSyntacticDiagnostics(sourceFile, cancellationToken);
|
||||
} else {
|
||||
const diagnostics = [];
|
||||
for (const sf of this.tsProgram.getSourceFiles()) {
|
||||
if (!ignoredFiles.has(sf)) {
|
||||
diagnostics.push(...this.tsProgram.getSyntacticDiagnostics(sf, cancellationToken));
|
||||
}
|
||||
}
|
||||
res = diagnostics;
|
||||
}
|
||||
return res;
|
||||
});
|
||||
}
|
||||
getTsSemanticDiagnostics(sourceFile, cancellationToken) {
|
||||
if (this.options.compilationMode === "experimental-local") {
|
||||
return [];
|
||||
}
|
||||
return this.compiler.perfRecorder.inPhase(PerfPhase.TypeScriptDiagnostics, () => {
|
||||
const ignoredFiles = this.compiler.ignoreForDiagnostics;
|
||||
let res;
|
||||
if (sourceFile !== void 0) {
|
||||
if (ignoredFiles.has(sourceFile)) {
|
||||
return [];
|
||||
}
|
||||
res = this.tsProgram.getSemanticDiagnostics(sourceFile, cancellationToken);
|
||||
} else {
|
||||
const diagnostics = [];
|
||||
for (const sf of this.tsProgram.getSourceFiles()) {
|
||||
if (!ignoredFiles.has(sf)) {
|
||||
diagnostics.push(...this.tsProgram.getSemanticDiagnostics(sf, cancellationToken));
|
||||
}
|
||||
}
|
||||
res = diagnostics;
|
||||
}
|
||||
return res;
|
||||
});
|
||||
}
|
||||
getNgOptionDiagnostics(cancellationToken) {
|
||||
return this.compiler.getOptionDiagnostics();
|
||||
}
|
||||
getNgStructuralDiagnostics(cancellationToken) {
|
||||
return [];
|
||||
}
|
||||
getNgSemanticDiagnostics(fileName, cancellationToken) {
|
||||
let sf = void 0;
|
||||
if (fileName !== void 0) {
|
||||
sf = this.tsProgram.getSourceFile(fileName);
|
||||
if (sf === void 0) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
if (sf === void 0) {
|
||||
return this.compiler.getDiagnostics();
|
||||
} else {
|
||||
return this.compiler.getDiagnosticsForFile(sf, OptimizeFor.WholeProgram);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Ensure that the `NgCompiler` has properly analyzed the program, and allow for the asynchronous
|
||||
* loading of any resources during the process.
|
||||
*
|
||||
* This is used by the Angular CLI to allow for spawning (async) child compilations for things
|
||||
* like SASS files used in `styleUrls`.
|
||||
*/
|
||||
loadNgStructureAsync() {
|
||||
return this.compiler.analyzeAsync();
|
||||
}
|
||||
listLazyRoutes(entryRoute) {
|
||||
return [];
|
||||
}
|
||||
emitXi18n() {
|
||||
const ctx = new MessageBundle(new HtmlParser(), [], {}, this.options.i18nOutLocale ?? null, this.options.i18nPreserveWhitespaceForLegacyExtraction);
|
||||
this.compiler.xi18n(ctx);
|
||||
i18nExtract(this.options.i18nOutFormat ?? null, this.options.i18nOutFile ?? null, this.host, this.options, ctx, resolve);
|
||||
}
|
||||
emit(opts) {
|
||||
if (opts !== void 0 && opts.emitFlags !== void 0 && opts.emitFlags & EmitFlags.I18nBundle) {
|
||||
this.emitXi18n();
|
||||
if (!(opts.emitFlags & EmitFlags.JS)) {
|
||||
return {
|
||||
diagnostics: [],
|
||||
emitSkipped: true,
|
||||
emittedFiles: []
|
||||
};
|
||||
}
|
||||
}
|
||||
const forceEmit = opts?.forceEmit ?? false;
|
||||
this.compiler.perfRecorder.memory(PerfCheckpoint.PreEmit);
|
||||
const res = this.compiler.perfRecorder.inPhase(PerfPhase.TypeScriptEmit, () => {
|
||||
const { transformers } = this.compiler.prepareEmit();
|
||||
const ignoreFiles = this.compiler.ignoreForEmit;
|
||||
const emitCallback = opts?.emitCallback ?? defaultEmitCallback;
|
||||
const writeFile = (fileName, data, writeByteOrderMark, onError, sourceFiles) => {
|
||||
if (sourceFiles !== void 0) {
|
||||
for (const writtenSf of sourceFiles) {
|
||||
if (writtenSf.isDeclarationFile) {
|
||||
continue;
|
||||
}
|
||||
this.compiler.incrementalCompilation.recordSuccessfulEmit(writtenSf);
|
||||
}
|
||||
}
|
||||
this.host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles);
|
||||
};
|
||||
const customTransforms = opts && opts.customTransformers;
|
||||
const beforeTransforms = transformers.before || [];
|
||||
const afterDeclarationsTransforms = transformers.afterDeclarations;
|
||||
if (customTransforms !== void 0 && customTransforms.beforeTs !== void 0) {
|
||||
beforeTransforms.push(...customTransforms.beforeTs);
|
||||
}
|
||||
const emitResults = [];
|
||||
for (const targetSourceFile of this.tsProgram.getSourceFiles()) {
|
||||
if (targetSourceFile.isDeclarationFile || ignoreFiles.has(targetSourceFile)) {
|
||||
continue;
|
||||
}
|
||||
if (!forceEmit && this.compiler.incrementalCompilation.safeToSkipEmit(targetSourceFile)) {
|
||||
this.compiler.perfRecorder.eventCount(PerfEvent.EmitSkipSourceFile);
|
||||
continue;
|
||||
}
|
||||
this.compiler.perfRecorder.eventCount(PerfEvent.EmitSourceFile);
|
||||
emitResults.push(emitCallback({
|
||||
targetSourceFile,
|
||||
program: this.tsProgram,
|
||||
host: this.host,
|
||||
options: this.options,
|
||||
emitOnlyDtsFiles: false,
|
||||
writeFile,
|
||||
customTransformers: {
|
||||
before: beforeTransforms,
|
||||
after: customTransforms && customTransforms.afterTs,
|
||||
afterDeclarations: afterDeclarationsTransforms
|
||||
}
|
||||
}));
|
||||
}
|
||||
this.compiler.perfRecorder.memory(PerfCheckpoint.Emit);
|
||||
return (opts && opts.mergeEmitResultsCallback || mergeEmitResults)(emitResults);
|
||||
});
|
||||
if (this.options.tracePerformance !== void 0) {
|
||||
const perf = this.compiler.perfRecorder.finalize();
|
||||
getFileSystem().writeFile(getFileSystem().resolve(this.options.tracePerformance), JSON.stringify(perf, null, 2));
|
||||
}
|
||||
return res;
|
||||
}
|
||||
getIndexedComponents() {
|
||||
return this.compiler.getIndexedComponents();
|
||||
}
|
||||
/**
|
||||
* Gets information for the current program that may be used to generate API
|
||||
* reference documentation. This includes Angular-specific information, such
|
||||
* as component inputs and outputs.
|
||||
*
|
||||
* @param entryPoint Path to the entry point for the package for which API
|
||||
* docs should be extracted.
|
||||
*/
|
||||
getApiDocumentation(entryPoint, privateModules) {
|
||||
return this.compiler.getApiDocumentation(entryPoint, privateModules);
|
||||
}
|
||||
getEmittedSourceFiles() {
|
||||
throw new Error("Method not implemented.");
|
||||
}
|
||||
};
|
||||
var defaultEmitCallback = ({ program, targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers }) => program.emit(targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers);
|
||||
function mergeEmitResults(emitResults) {
|
||||
const diagnostics = [];
|
||||
let emitSkipped = false;
|
||||
const emittedFiles = [];
|
||||
for (const er of emitResults) {
|
||||
diagnostics.push(...er.diagnostics);
|
||||
emitSkipped = emitSkipped || er.emitSkipped;
|
||||
emittedFiles.push(...er.emittedFiles || []);
|
||||
}
|
||||
return { diagnostics, emitSkipped, emittedFiles };
|
||||
}
|
||||
|
||||
// packages/compiler-cli/src/transformers/program.js
|
||||
function createProgram({ rootNames, options, host, oldProgram }) {
|
||||
return new NgtscProgram(rootNames, options, host, oldProgram);
|
||||
}
|
||||
|
||||
// packages/compiler-cli/src/perform_compile.js
|
||||
import ts5 from "typescript";
|
||||
|
||||
// packages/compiler-cli/src/transformers/util.js
|
||||
import ts4 from "typescript";
|
||||
function createMessageDiagnostic(messageText) {
|
||||
return {
|
||||
file: void 0,
|
||||
start: void 0,
|
||||
length: void 0,
|
||||
category: ts4.DiagnosticCategory.Message,
|
||||
messageText,
|
||||
code: DEFAULT_ERROR_CODE,
|
||||
source: SOURCE
|
||||
};
|
||||
}
|
||||
|
||||
// packages/compiler-cli/src/perform_compile.js
|
||||
var defaultFormatHost = {
|
||||
getCurrentDirectory: () => ts5.sys.getCurrentDirectory(),
|
||||
getCanonicalFileName: (fileName) => fileName,
|
||||
getNewLine: () => ts5.sys.newLine
|
||||
};
|
||||
function formatDiagnostics(diags, host = defaultFormatHost) {
|
||||
if (diags && diags.length) {
|
||||
return diags.map((diagnostic) => replaceTsWithNgInErrors(ts5.formatDiagnosticsWithColorAndContext([diagnostic], host))).join("");
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
function calcProjectFileAndBasePath(project, host = getFileSystem()) {
|
||||
const absProject = host.resolve(project);
|
||||
const projectIsDir = host.lstat(absProject).isDirectory();
|
||||
const projectFile = projectIsDir ? host.join(absProject, "tsconfig.json") : absProject;
|
||||
const projectDir = projectIsDir ? absProject : host.dirname(absProject);
|
||||
const basePath = host.resolve(projectDir);
|
||||
return { projectFile, basePath };
|
||||
}
|
||||
function readConfiguration(project, existingOptions, host = getFileSystem()) {
|
||||
try {
|
||||
const fs = getFileSystem();
|
||||
const readConfigFile = (configFile) => ts5.readConfigFile(configFile, (file) => host.readFile(host.resolve(file)));
|
||||
const readAngularCompilerOptions = (configFile, parentOptions = {}) => {
|
||||
const { config: config2, error: error2 } = readConfigFile(configFile);
|
||||
if (error2) {
|
||||
return parentOptions;
|
||||
}
|
||||
const angularCompilerOptions = config2.angularCompilerOptions ?? config2.bazelOptions?.angularCompilerOptions;
|
||||
let existingNgCompilerOptions = { ...angularCompilerOptions, ...parentOptions };
|
||||
if (!config2.extends) {
|
||||
return existingNgCompilerOptions;
|
||||
}
|
||||
const extendsPaths = typeof config2.extends === "string" ? [config2.extends] : config2.extends;
|
||||
return [...extendsPaths].reverse().reduce((prevOptions, extendsPath) => {
|
||||
const extendedConfigPath = getExtendedConfigPath(configFile, extendsPath, host, fs);
|
||||
return extendedConfigPath === null ? prevOptions : readAngularCompilerOptions(extendedConfigPath, prevOptions);
|
||||
}, existingNgCompilerOptions);
|
||||
};
|
||||
const { projectFile, basePath } = calcProjectFileAndBasePath(project, host);
|
||||
const configFileName = host.resolve(host.pwd(), projectFile);
|
||||
const { config, error } = readConfigFile(projectFile);
|
||||
if (error) {
|
||||
return {
|
||||
project,
|
||||
errors: [error],
|
||||
rootNames: [],
|
||||
options: {},
|
||||
emitFlags: EmitFlags.Default
|
||||
};
|
||||
}
|
||||
const existingCompilerOptions = {
|
||||
genDir: basePath,
|
||||
basePath,
|
||||
...readAngularCompilerOptions(configFileName),
|
||||
...existingOptions
|
||||
};
|
||||
const parseConfigHost = createParseConfigHost(host, fs);
|
||||
const { options, errors, fileNames: rootNames, projectReferences } = ts5.parseJsonConfigFileContent(config, parseConfigHost, basePath, existingCompilerOptions, configFileName);
|
||||
let emitFlags = EmitFlags.Default;
|
||||
if (!(options["skipMetadataEmit"] || options["flatModuleOutFile"])) {
|
||||
emitFlags |= EmitFlags.Metadata;
|
||||
}
|
||||
if (options["skipTemplateCodegen"]) {
|
||||
emitFlags = emitFlags & ~EmitFlags.Codegen;
|
||||
}
|
||||
return { project: projectFile, rootNames, projectReferences, options, errors, emitFlags };
|
||||
} catch (e) {
|
||||
const errors = [
|
||||
{
|
||||
category: ts5.DiagnosticCategory.Error,
|
||||
messageText: e.stack ?? e.message,
|
||||
file: void 0,
|
||||
start: void 0,
|
||||
length: void 0,
|
||||
source: "angular",
|
||||
code: UNKNOWN_ERROR_CODE
|
||||
}
|
||||
];
|
||||
return { project: "", errors, rootNames: [], options: {}, emitFlags: EmitFlags.Default };
|
||||
}
|
||||
}
|
||||
function createParseConfigHost(host, fs = getFileSystem()) {
|
||||
return {
|
||||
fileExists: host.exists.bind(host),
|
||||
readDirectory: createFileSystemTsReadDirectoryFn(fs),
|
||||
readFile: host.readFile.bind(host),
|
||||
useCaseSensitiveFileNames: fs.isCaseSensitive()
|
||||
};
|
||||
}
|
||||
function getExtendedConfigPath(configFile, extendsValue, host, fs) {
|
||||
const result = getExtendedConfigPathWorker(configFile, extendsValue, host, fs);
|
||||
if (result !== null) {
|
||||
return result;
|
||||
}
|
||||
return getExtendedConfigPathWorker(configFile, `${extendsValue}.json`, host, fs);
|
||||
}
|
||||
function getExtendedConfigPathWorker(configFile, extendsValue, host, fs) {
|
||||
if (extendsValue.startsWith(".") || fs.isRooted(extendsValue)) {
|
||||
const extendedConfigPath = host.resolve(host.dirname(configFile), extendsValue);
|
||||
if (host.exists(extendedConfigPath)) {
|
||||
return extendedConfigPath;
|
||||
}
|
||||
} else {
|
||||
const parseConfigHost = createParseConfigHost(host, fs);
|
||||
const { resolvedModule } = ts5.nodeModuleNameResolver(extendsValue, configFile, { moduleResolution: ts5.ModuleResolutionKind.NodeNext, resolveJsonModule: true }, parseConfigHost);
|
||||
if (resolvedModule) {
|
||||
return absoluteFrom(resolvedModule.resolvedFileName);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
function exitCodeFromResult(diags) {
|
||||
if (!diags)
|
||||
return 0;
|
||||
if (diags.every((diag) => diag.category !== ts5.DiagnosticCategory.Error)) {
|
||||
return 0;
|
||||
}
|
||||
return diags.some((d) => d.source === "angular" && d.code === UNKNOWN_ERROR_CODE) ? 2 : 1;
|
||||
}
|
||||
function performCompilation({ rootNames, options, host, oldProgram, emitCallback, mergeEmitResultsCallback, gatherDiagnostics = defaultGatherDiagnostics, customTransformers, emitFlags = EmitFlags.Default, forceEmit = false, modifiedResourceFiles = null }) {
|
||||
let program;
|
||||
let emitResult;
|
||||
let allDiagnostics = [];
|
||||
try {
|
||||
if (!host) {
|
||||
host = createCompilerHost({ options });
|
||||
}
|
||||
if (modifiedResourceFiles) {
|
||||
host.getModifiedResourceFiles = () => modifiedResourceFiles;
|
||||
}
|
||||
program = createProgram({ rootNames, host, options, oldProgram });
|
||||
const beforeDiags = Date.now();
|
||||
allDiagnostics.push(...gatherDiagnostics(program));
|
||||
if (options.diagnostics) {
|
||||
const afterDiags = Date.now();
|
||||
allDiagnostics.push(createMessageDiagnostic(`Time for diagnostics: ${afterDiags - beforeDiags}ms.`));
|
||||
}
|
||||
if (!hasErrors(allDiagnostics)) {
|
||||
emitResult = program.emit({
|
||||
emitCallback,
|
||||
mergeEmitResultsCallback,
|
||||
customTransformers,
|
||||
emitFlags,
|
||||
forceEmit
|
||||
});
|
||||
allDiagnostics.push(...emitResult.diagnostics);
|
||||
return { diagnostics: allDiagnostics, program, emitResult };
|
||||
}
|
||||
return { diagnostics: allDiagnostics, program };
|
||||
} catch (e) {
|
||||
program = void 0;
|
||||
allDiagnostics.push({
|
||||
category: ts5.DiagnosticCategory.Error,
|
||||
messageText: e.stack ?? e.message,
|
||||
code: UNKNOWN_ERROR_CODE,
|
||||
file: void 0,
|
||||
start: void 0,
|
||||
length: void 0
|
||||
});
|
||||
return { diagnostics: allDiagnostics, program };
|
||||
}
|
||||
}
|
||||
function defaultGatherDiagnostics(program) {
|
||||
const allDiagnostics = [];
|
||||
function checkDiagnostics(diags) {
|
||||
if (diags) {
|
||||
allDiagnostics.push(...diags);
|
||||
return !hasErrors(diags);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
let checkOtherDiagnostics = true;
|
||||
checkOtherDiagnostics = checkOtherDiagnostics && checkDiagnostics([...program.getTsOptionDiagnostics(), ...program.getNgOptionDiagnostics()]);
|
||||
checkOtherDiagnostics = checkOtherDiagnostics && checkDiagnostics(program.getTsSyntacticDiagnostics());
|
||||
checkOtherDiagnostics = checkOtherDiagnostics && checkDiagnostics([
|
||||
...program.getTsSemanticDiagnostics(),
|
||||
...program.getNgStructuralDiagnostics()
|
||||
]);
|
||||
checkOtherDiagnostics = checkOtherDiagnostics && checkDiagnostics(program.getNgSemanticDiagnostics());
|
||||
return allDiagnostics;
|
||||
}
|
||||
function hasErrors(diags) {
|
||||
return diags.some((d) => d.category === ts5.DiagnosticCategory.Error);
|
||||
}
|
||||
|
||||
export {
|
||||
DEFAULT_ERROR_CODE,
|
||||
UNKNOWN_ERROR_CODE,
|
||||
SOURCE,
|
||||
isTsDiagnostic,
|
||||
EmitFlags,
|
||||
createCompilerHost,
|
||||
NgtscProgram,
|
||||
createProgram,
|
||||
createMessageDiagnostic,
|
||||
formatDiagnostics,
|
||||
calcProjectFileAndBasePath,
|
||||
readConfiguration,
|
||||
exitCodeFromResult,
|
||||
performCompilation,
|
||||
defaultGatherDiagnostics
|
||||
};
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
+378
@@ -0,0 +1,378 @@
|
||||
|
||||
import {createRequire as __cjsCompatRequire} from 'module';
|
||||
const require = __cjsCompatRequire(import.meta.url);
|
||||
|
||||
import {
|
||||
DEFAULT_ERROR_CODE,
|
||||
EmitFlags,
|
||||
SOURCE,
|
||||
createCompilerHost,
|
||||
createMessageDiagnostic,
|
||||
exitCodeFromResult,
|
||||
formatDiagnostics,
|
||||
performCompilation,
|
||||
readConfiguration
|
||||
} from "./chunk-VO3Q626H.js";
|
||||
|
||||
// packages/compiler-cli/src/main.js
|
||||
import ts2 from "typescript";
|
||||
import yargs from "yargs";
|
||||
|
||||
// packages/compiler-cli/src/perform_watch.js
|
||||
import * as chokidar from "chokidar";
|
||||
import * as path from "path";
|
||||
import ts from "typescript";
|
||||
function totalCompilationTimeDiagnostic(timeInMillis) {
|
||||
let duration;
|
||||
if (timeInMillis > 1e3) {
|
||||
duration = `${(timeInMillis / 1e3).toPrecision(2)}s`;
|
||||
} else {
|
||||
duration = `${timeInMillis}ms`;
|
||||
}
|
||||
return {
|
||||
category: ts.DiagnosticCategory.Message,
|
||||
messageText: `Total time: ${duration}`,
|
||||
code: DEFAULT_ERROR_CODE,
|
||||
source: SOURCE,
|
||||
file: void 0,
|
||||
start: void 0,
|
||||
length: void 0
|
||||
};
|
||||
}
|
||||
var FileChangeEvent;
|
||||
(function(FileChangeEvent2) {
|
||||
FileChangeEvent2[FileChangeEvent2["Change"] = 0] = "Change";
|
||||
FileChangeEvent2[FileChangeEvent2["CreateDelete"] = 1] = "CreateDelete";
|
||||
FileChangeEvent2[FileChangeEvent2["CreateDeleteDir"] = 2] = "CreateDeleteDir";
|
||||
})(FileChangeEvent || (FileChangeEvent = {}));
|
||||
function createPerformWatchHost(configFileName, reportDiagnostics, existingOptions, createEmitCallback) {
|
||||
return {
|
||||
reportDiagnostics,
|
||||
createCompilerHost: (options) => createCompilerHost({ options }),
|
||||
readConfiguration: () => readConfiguration(configFileName, existingOptions),
|
||||
createEmitCallback: (options) => createEmitCallback ? createEmitCallback(options) : void 0,
|
||||
onFileChange: (options, listener, ready) => {
|
||||
if (!options.basePath) {
|
||||
reportDiagnostics([
|
||||
{
|
||||
category: ts.DiagnosticCategory.Error,
|
||||
messageText: "Invalid configuration option. baseDir not specified",
|
||||
source: SOURCE,
|
||||
code: DEFAULT_ERROR_CODE,
|
||||
file: void 0,
|
||||
start: void 0,
|
||||
length: void 0
|
||||
}
|
||||
]);
|
||||
return { close: () => {
|
||||
} };
|
||||
}
|
||||
const watcher = chokidar.watch(options.basePath, {
|
||||
// ignore .dotfiles, .js and .map files.
|
||||
// can't ignore other files as we e.g. want to recompile if an `.html` file changes as well.
|
||||
ignored: (path2) => /((^[\/\\])\..)|(\.js$)|(\.map$)|(\.metadata\.json|node_modules)/.test(path2),
|
||||
ignoreInitial: true,
|
||||
persistent: true
|
||||
});
|
||||
watcher.on("all", (event, path2) => {
|
||||
switch (event) {
|
||||
case "change":
|
||||
listener(FileChangeEvent.Change, path2);
|
||||
break;
|
||||
case "unlink":
|
||||
case "add":
|
||||
listener(FileChangeEvent.CreateDelete, path2);
|
||||
break;
|
||||
case "unlinkDir":
|
||||
case "addDir":
|
||||
listener(FileChangeEvent.CreateDeleteDir, path2);
|
||||
break;
|
||||
}
|
||||
});
|
||||
watcher.on("ready", ready);
|
||||
return { close: () => watcher.close(), ready };
|
||||
},
|
||||
setTimeout: ts.sys.clearTimeout && ts.sys.setTimeout || setTimeout,
|
||||
clearTimeout: ts.sys.setTimeout && ts.sys.clearTimeout || clearTimeout
|
||||
};
|
||||
}
|
||||
function performWatchCompilation(host) {
|
||||
let cachedProgram;
|
||||
let cachedCompilerHost;
|
||||
let cachedOptions;
|
||||
let timerHandleForRecompilation;
|
||||
const ignoreFilesForWatch = /* @__PURE__ */ new Set();
|
||||
const fileCache = /* @__PURE__ */ new Map();
|
||||
const firstCompileResult = doCompilation();
|
||||
let resolveReadyPromise;
|
||||
const readyPromise = new Promise((resolve) => resolveReadyPromise = resolve);
|
||||
const fileWatcher = host.onFileChange(cachedOptions.options, watchedFileChanged, resolveReadyPromise);
|
||||
return { close, ready: (cb) => readyPromise.then(cb), firstCompileResult };
|
||||
function cacheEntry(fileName) {
|
||||
fileName = path.normalize(fileName);
|
||||
let entry = fileCache.get(fileName);
|
||||
if (!entry) {
|
||||
entry = {};
|
||||
fileCache.set(fileName, entry);
|
||||
}
|
||||
return entry;
|
||||
}
|
||||
function close() {
|
||||
fileWatcher.close();
|
||||
if (timerHandleForRecompilation) {
|
||||
host.clearTimeout(timerHandleForRecompilation.timerHandle);
|
||||
timerHandleForRecompilation = void 0;
|
||||
}
|
||||
}
|
||||
function doCompilation() {
|
||||
if (!cachedOptions) {
|
||||
cachedOptions = host.readConfiguration();
|
||||
}
|
||||
if (cachedOptions.errors && cachedOptions.errors.length) {
|
||||
host.reportDiagnostics(cachedOptions.errors);
|
||||
return cachedOptions.errors;
|
||||
}
|
||||
const startTime = Date.now();
|
||||
if (!cachedCompilerHost) {
|
||||
cachedCompilerHost = host.createCompilerHost(cachedOptions.options);
|
||||
const originalWriteFileCallback = cachedCompilerHost.writeFile;
|
||||
cachedCompilerHost.writeFile = function(fileName, data, writeByteOrderMark, onError, sourceFiles = []) {
|
||||
ignoreFilesForWatch.add(path.normalize(fileName));
|
||||
return originalWriteFileCallback(fileName, data, writeByteOrderMark, onError, sourceFiles);
|
||||
};
|
||||
const originalFileExists = cachedCompilerHost.fileExists;
|
||||
cachedCompilerHost.fileExists = function(fileName) {
|
||||
const ce = cacheEntry(fileName);
|
||||
if (ce.exists == null) {
|
||||
ce.exists = originalFileExists.call(this, fileName);
|
||||
}
|
||||
return ce.exists;
|
||||
};
|
||||
const originalGetSourceFile = cachedCompilerHost.getSourceFile;
|
||||
cachedCompilerHost.getSourceFile = function(fileName, languageVersion) {
|
||||
const ce = cacheEntry(fileName);
|
||||
if (!ce.sf) {
|
||||
ce.sf = originalGetSourceFile.call(this, fileName, languageVersion);
|
||||
}
|
||||
return ce.sf;
|
||||
};
|
||||
const originalReadFile = cachedCompilerHost.readFile;
|
||||
cachedCompilerHost.readFile = function(fileName) {
|
||||
const ce = cacheEntry(fileName);
|
||||
if (ce.content == null) {
|
||||
ce.content = originalReadFile.call(this, fileName);
|
||||
}
|
||||
return ce.content;
|
||||
};
|
||||
cachedCompilerHost.getModifiedResourceFiles = function() {
|
||||
if (timerHandleForRecompilation === void 0) {
|
||||
return void 0;
|
||||
}
|
||||
return timerHandleForRecompilation.modifiedResourceFiles;
|
||||
};
|
||||
}
|
||||
ignoreFilesForWatch.clear();
|
||||
const oldProgram = cachedProgram;
|
||||
cachedProgram = void 0;
|
||||
const compileResult = performCompilation({
|
||||
rootNames: cachedOptions.rootNames,
|
||||
options: cachedOptions.options,
|
||||
host: cachedCompilerHost,
|
||||
oldProgram,
|
||||
emitCallback: host.createEmitCallback(cachedOptions.options)
|
||||
});
|
||||
if (compileResult.diagnostics.length) {
|
||||
host.reportDiagnostics(compileResult.diagnostics);
|
||||
}
|
||||
const endTime = Date.now();
|
||||
if (cachedOptions.options.diagnostics) {
|
||||
const totalTime = (endTime - startTime) / 1e3;
|
||||
host.reportDiagnostics([totalCompilationTimeDiagnostic(endTime - startTime)]);
|
||||
}
|
||||
const exitCode = exitCodeFromResult(compileResult.diagnostics);
|
||||
if (exitCode == 0) {
|
||||
cachedProgram = compileResult.program;
|
||||
host.reportDiagnostics([
|
||||
createMessageDiagnostic("Compilation complete. Watching for file changes.")
|
||||
]);
|
||||
} else {
|
||||
host.reportDiagnostics([
|
||||
createMessageDiagnostic("Compilation failed. Watching for file changes.")
|
||||
]);
|
||||
}
|
||||
return compileResult.diagnostics;
|
||||
}
|
||||
function resetOptions() {
|
||||
cachedProgram = void 0;
|
||||
cachedCompilerHost = void 0;
|
||||
cachedOptions = void 0;
|
||||
}
|
||||
function watchedFileChanged(event, fileName) {
|
||||
const normalizedPath = path.normalize(fileName);
|
||||
if (cachedOptions && event === FileChangeEvent.Change && // TODO(chuckj): validate that this is sufficient to skip files that were written.
|
||||
// This assumes that the file path we write is the same file path we will receive in the
|
||||
// change notification.
|
||||
normalizedPath === path.normalize(cachedOptions.project)) {
|
||||
resetOptions();
|
||||
} else if (event === FileChangeEvent.CreateDelete || event === FileChangeEvent.CreateDeleteDir) {
|
||||
cachedOptions = void 0;
|
||||
}
|
||||
if (event === FileChangeEvent.CreateDeleteDir) {
|
||||
fileCache.clear();
|
||||
} else {
|
||||
fileCache.delete(normalizedPath);
|
||||
}
|
||||
if (!ignoreFilesForWatch.has(normalizedPath)) {
|
||||
startTimerForRecompilation(normalizedPath);
|
||||
}
|
||||
}
|
||||
function startTimerForRecompilation(changedPath) {
|
||||
if (timerHandleForRecompilation) {
|
||||
host.clearTimeout(timerHandleForRecompilation.timerHandle);
|
||||
} else {
|
||||
timerHandleForRecompilation = {
|
||||
modifiedResourceFiles: /* @__PURE__ */ new Set(),
|
||||
timerHandle: void 0
|
||||
};
|
||||
}
|
||||
timerHandleForRecompilation.timerHandle = host.setTimeout(recompile, 250);
|
||||
timerHandleForRecompilation.modifiedResourceFiles.add(changedPath);
|
||||
}
|
||||
function recompile() {
|
||||
host.reportDiagnostics([
|
||||
createMessageDiagnostic("File change detected. Starting incremental compilation.")
|
||||
]);
|
||||
doCompilation();
|
||||
timerHandleForRecompilation = void 0;
|
||||
}
|
||||
}
|
||||
|
||||
// packages/compiler-cli/src/main.js
|
||||
function main(args, consoleError = console.error, config, customTransformers, programReuse, modifiedResourceFiles) {
|
||||
let { project, rootNames, options, errors: configErrors, watch: watch2, emitFlags } = config || readNgcCommandLineAndConfiguration(args);
|
||||
if (configErrors.length) {
|
||||
return reportErrorsAndExit(
|
||||
configErrors,
|
||||
/*options*/
|
||||
void 0,
|
||||
consoleError
|
||||
);
|
||||
}
|
||||
if (watch2) {
|
||||
const result = watchMode(project, options, consoleError);
|
||||
return reportErrorsAndExit(result.firstCompileResult, options, consoleError);
|
||||
}
|
||||
let oldProgram;
|
||||
if (programReuse !== void 0) {
|
||||
oldProgram = programReuse.program;
|
||||
}
|
||||
const { diagnostics: compileDiags, program } = performCompilation({
|
||||
rootNames,
|
||||
options,
|
||||
emitFlags,
|
||||
oldProgram,
|
||||
customTransformers,
|
||||
modifiedResourceFiles
|
||||
});
|
||||
if (programReuse !== void 0) {
|
||||
programReuse.program = program;
|
||||
}
|
||||
return reportErrorsAndExit(compileDiags, options, consoleError);
|
||||
}
|
||||
function readNgcCommandLineAndConfiguration(args) {
|
||||
const options = {};
|
||||
const parsedArgs = yargs(args).parserConfiguration({ "strip-aliased": true }).option("i18nFile", { type: "string" }).option("i18nFormat", { type: "string" }).option("locale", { type: "string" }).option("missingTranslation", { type: "string", choices: ["error", "warning", "ignore"] }).option("outFile", { type: "string" }).option("watch", { type: "boolean", alias: ["w"] }).parseSync();
|
||||
if (parsedArgs.i18nFile)
|
||||
options.i18nInFile = parsedArgs.i18nFile;
|
||||
if (parsedArgs.i18nFormat)
|
||||
options.i18nInFormat = parsedArgs.i18nFormat;
|
||||
if (parsedArgs.locale)
|
||||
options.i18nInLocale = parsedArgs.locale;
|
||||
if (parsedArgs.missingTranslation)
|
||||
options.i18nInMissingTranslations = parsedArgs.missingTranslation;
|
||||
const config = readCommandLineAndConfiguration(args, options, [
|
||||
"i18nFile",
|
||||
"i18nFormat",
|
||||
"locale",
|
||||
"missingTranslation",
|
||||
"watch"
|
||||
]);
|
||||
return { ...config, watch: parsedArgs.watch };
|
||||
}
|
||||
function readCommandLineAndConfiguration(args, existingOptions = {}, ngCmdLineOptions = []) {
|
||||
let cmdConfig = ts2.parseCommandLine(args);
|
||||
const project = cmdConfig.options.project || ".";
|
||||
const cmdErrors = cmdConfig.errors.filter((e) => {
|
||||
if (typeof e.messageText === "string") {
|
||||
const msg = e.messageText;
|
||||
return !ngCmdLineOptions.some((o) => msg.indexOf(o) >= 0);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
if (cmdErrors.length) {
|
||||
return {
|
||||
project,
|
||||
rootNames: [],
|
||||
options: cmdConfig.options,
|
||||
errors: cmdErrors,
|
||||
emitFlags: EmitFlags.Default
|
||||
};
|
||||
}
|
||||
const config = readConfiguration(project, cmdConfig.options);
|
||||
const options = { ...config.options, ...existingOptions };
|
||||
if (options.locale) {
|
||||
options.i18nInLocale = options.locale;
|
||||
}
|
||||
return {
|
||||
project,
|
||||
rootNames: config.rootNames,
|
||||
options,
|
||||
errors: config.errors,
|
||||
emitFlags: config.emitFlags
|
||||
};
|
||||
}
|
||||
function getFormatDiagnosticsHost(options) {
|
||||
const basePath = options ? options.basePath : void 0;
|
||||
return {
|
||||
getCurrentDirectory: () => basePath || ts2.sys.getCurrentDirectory(),
|
||||
// We need to normalize the path separators here because by default, TypeScript
|
||||
// compiler hosts use posix canonical paths. In order to print consistent diagnostics,
|
||||
// we also normalize the paths.
|
||||
getCanonicalFileName: (fileName) => fileName.replace(/\\/g, "/"),
|
||||
getNewLine: () => {
|
||||
if (options && options.newLine !== void 0) {
|
||||
return options.newLine === ts2.NewLineKind.LineFeed ? "\n" : "\r\n";
|
||||
}
|
||||
return ts2.sys.newLine;
|
||||
}
|
||||
};
|
||||
}
|
||||
function reportErrorsAndExit(allDiagnostics, options, consoleError = console.error) {
|
||||
const errorsAndWarnings = allDiagnostics.filter((d) => d.category !== ts2.DiagnosticCategory.Message);
|
||||
printDiagnostics(errorsAndWarnings, options, consoleError);
|
||||
return exitCodeFromResult(allDiagnostics);
|
||||
}
|
||||
function watchMode(project, options, consoleError) {
|
||||
return performWatchCompilation(createPerformWatchHost(project, (diagnostics) => {
|
||||
printDiagnostics(diagnostics, options, consoleError);
|
||||
}, options, void 0));
|
||||
}
|
||||
function printDiagnostics(diagnostics, options, consoleError) {
|
||||
if (diagnostics.length === 0) {
|
||||
return;
|
||||
}
|
||||
const formatHost = getFormatDiagnosticsHost(options);
|
||||
consoleError(formatDiagnostics(diagnostics, formatHost));
|
||||
}
|
||||
|
||||
export {
|
||||
main,
|
||||
readCommandLineAndConfiguration
|
||||
};
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
+122
@@ -0,0 +1,122 @@
|
||||
|
||||
import {createRequire as __cjsCompatRequire} from 'module';
|
||||
const require = __cjsCompatRequire(import.meta.url);
|
||||
|
||||
import {
|
||||
__require
|
||||
} from "./chunk-G7GFT6BU.js";
|
||||
|
||||
// packages/compiler-cli/src/ngtsc/file_system/src/node_js_file_system.js
|
||||
import fs from "fs";
|
||||
import { createRequire } from "module";
|
||||
import * as p from "path";
|
||||
import * as url from "url";
|
||||
var NodeJSPathManipulation = class {
|
||||
pwd() {
|
||||
return this.normalize(process.cwd());
|
||||
}
|
||||
chdir(dir) {
|
||||
process.chdir(dir);
|
||||
}
|
||||
resolve(...paths) {
|
||||
return this.normalize(p.resolve(...paths));
|
||||
}
|
||||
dirname(file) {
|
||||
return this.normalize(p.dirname(file));
|
||||
}
|
||||
join(basePath, ...paths) {
|
||||
return this.normalize(p.join(basePath, ...paths));
|
||||
}
|
||||
isRoot(path) {
|
||||
return this.dirname(path) === this.normalize(path);
|
||||
}
|
||||
isRooted(path) {
|
||||
return p.isAbsolute(path);
|
||||
}
|
||||
relative(from, to) {
|
||||
return this.normalize(p.relative(from, to));
|
||||
}
|
||||
basename(filePath, extension) {
|
||||
return p.basename(filePath, extension);
|
||||
}
|
||||
extname(path) {
|
||||
return p.extname(path);
|
||||
}
|
||||
normalize(path) {
|
||||
return path.replace(/\\/g, "/");
|
||||
}
|
||||
};
|
||||
var isCommonJS = typeof __filename !== "undefined";
|
||||
var currentFileUrl = isCommonJS ? null : import.meta.url;
|
||||
var currentFileName = isCommonJS ? __filename : url.fileURLToPath?.(currentFileUrl) ?? null;
|
||||
var NodeJSReadonlyFileSystem = class extends NodeJSPathManipulation {
|
||||
_caseSensitive = void 0;
|
||||
isCaseSensitive() {
|
||||
if (this._caseSensitive === void 0) {
|
||||
this._caseSensitive = currentFileName !== null ? !fs.existsSync(this.normalize(toggleCase(currentFileName))) : true;
|
||||
}
|
||||
return this._caseSensitive;
|
||||
}
|
||||
exists(path) {
|
||||
return fs.existsSync(path);
|
||||
}
|
||||
readFile(path) {
|
||||
return fs.readFileSync(path, "utf8");
|
||||
}
|
||||
readFileBuffer(path) {
|
||||
return fs.readFileSync(path);
|
||||
}
|
||||
readdir(path) {
|
||||
return fs.readdirSync(path);
|
||||
}
|
||||
lstat(path) {
|
||||
return fs.lstatSync(path);
|
||||
}
|
||||
stat(path) {
|
||||
return fs.statSync(path);
|
||||
}
|
||||
realpath(path) {
|
||||
return this.resolve(fs.realpathSync(path));
|
||||
}
|
||||
getDefaultLibLocation() {
|
||||
const requireFn = isCommonJS ? __require : createRequire(currentFileUrl);
|
||||
return this.resolve(requireFn.resolve("typescript"), "..");
|
||||
}
|
||||
};
|
||||
var NodeJSFileSystem = class extends NodeJSReadonlyFileSystem {
|
||||
writeFile(path, data, exclusive = false) {
|
||||
fs.writeFileSync(path, data, exclusive ? { flag: "wx" } : void 0);
|
||||
}
|
||||
removeFile(path) {
|
||||
fs.unlinkSync(path);
|
||||
}
|
||||
symlink(target, path) {
|
||||
fs.symlinkSync(target, path);
|
||||
}
|
||||
copyFile(from, to) {
|
||||
fs.copyFileSync(from, to);
|
||||
}
|
||||
moveFile(from, to) {
|
||||
fs.renameSync(from, to);
|
||||
}
|
||||
ensureDir(path) {
|
||||
fs.mkdirSync(path, { recursive: true });
|
||||
}
|
||||
removeDeep(path) {
|
||||
fs.rmdirSync(path, { recursive: true });
|
||||
}
|
||||
};
|
||||
function toggleCase(str) {
|
||||
return str.replace(/\w/g, (ch) => ch.toUpperCase() === ch ? ch.toLowerCase() : ch.toUpperCase());
|
||||
}
|
||||
|
||||
export {
|
||||
NodeJSFileSystem
|
||||
};
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
+244
@@ -0,0 +1,244 @@
|
||||
|
||||
import {createRequire as __cjsCompatRequire} from 'module';
|
||||
const require = __cjsCompatRequire(import.meta.url);
|
||||
|
||||
import {
|
||||
DEFAULT_ERROR_CODE,
|
||||
EmitFlags,
|
||||
NgtscProgram,
|
||||
SOURCE,
|
||||
UNKNOWN_ERROR_CODE,
|
||||
calcProjectFileAndBasePath,
|
||||
createCompilerHost,
|
||||
createProgram,
|
||||
defaultGatherDiagnostics,
|
||||
exitCodeFromResult,
|
||||
formatDiagnostics,
|
||||
isTsDiagnostic,
|
||||
performCompilation,
|
||||
readConfiguration
|
||||
} from "./chunk-VO3Q626H.js";
|
||||
import {
|
||||
ConsoleLogger,
|
||||
LogLevel
|
||||
} from "./chunk-6HOSNZU5.js";
|
||||
import {
|
||||
DecoratorType,
|
||||
DocsExtractor,
|
||||
EntryType,
|
||||
MemberTags,
|
||||
MemberType,
|
||||
NgCompiler,
|
||||
NgCompilerHost,
|
||||
PatchedProgramIncrementalBuildStrategy,
|
||||
freshCompilationTicket,
|
||||
incrementalFromStateTicket,
|
||||
isDocEntryWithSourceInfo
|
||||
} from "./chunk-PW54LIP6.js";
|
||||
import {
|
||||
ActivePerfRecorder,
|
||||
ErrorCode,
|
||||
OptimizeFor,
|
||||
PerfPhase,
|
||||
TsCreateProgramDriver,
|
||||
angularJitApplicationTransform,
|
||||
getDownlevelDecoratorsTransform,
|
||||
getInitializerApiJitTransform,
|
||||
isLocalCompilationDiagnostics,
|
||||
ngErrorCode
|
||||
} from "./chunk-IG22BDVK.js";
|
||||
import "./chunk-CSUVPNMK.js";
|
||||
import {
|
||||
InvalidFileSystem,
|
||||
LogicalFileSystem,
|
||||
LogicalProjectPath,
|
||||
NgtscCompilerHost,
|
||||
absoluteFrom,
|
||||
absoluteFromSourceFile,
|
||||
basename,
|
||||
createFileSystemTsReadDirectoryFn,
|
||||
dirname,
|
||||
getFileSystem,
|
||||
getSourceFileOrError,
|
||||
isLocalRelativePath,
|
||||
isRoot,
|
||||
isRooted,
|
||||
join,
|
||||
relative,
|
||||
relativeFrom,
|
||||
resolve,
|
||||
setFileSystem,
|
||||
toRelativeImport
|
||||
} from "./chunk-CEBE44Q5.js";
|
||||
import {
|
||||
NodeJSFileSystem
|
||||
} from "./chunk-XYYEESKY.js";
|
||||
import "./chunk-G7GFT6BU.js";
|
||||
|
||||
// packages/compiler-cli/src/version.js
|
||||
import { Version } from "@angular/compiler";
|
||||
var VERSION = new Version("21.2.1");
|
||||
|
||||
// packages/compiler-cli/private/tooling.js
|
||||
var GLOBAL_DEFS_FOR_TERSER = {
|
||||
ngDevMode: false,
|
||||
ngI18nClosureMode: false
|
||||
};
|
||||
var GLOBAL_DEFS_FOR_TERSER_WITH_AOT = {
|
||||
...GLOBAL_DEFS_FOR_TERSER,
|
||||
ngJitMode: false
|
||||
};
|
||||
var constructorParametersDownlevelTransform = (program, isCore = false) => {
|
||||
return angularJitApplicationTransform(program, isCore);
|
||||
};
|
||||
|
||||
// packages/compiler-cli/src/ngtsc/tsc_plugin.js
|
||||
var NgTscPlugin = class {
|
||||
ngOptions;
|
||||
name = "ngtsc";
|
||||
options = null;
|
||||
host = null;
|
||||
_compiler = null;
|
||||
get compiler() {
|
||||
if (this._compiler === null) {
|
||||
throw new Error("Lifecycle error: setupCompilation() must be called first.");
|
||||
}
|
||||
return this._compiler;
|
||||
}
|
||||
constructor(ngOptions) {
|
||||
this.ngOptions = ngOptions;
|
||||
setFileSystem(new NodeJSFileSystem());
|
||||
}
|
||||
wrapHost(host, inputFiles, options) {
|
||||
this.options = { ...this.ngOptions, ...options };
|
||||
this.host = NgCompilerHost.wrap(
|
||||
host,
|
||||
inputFiles,
|
||||
this.options,
|
||||
/* oldProgram */
|
||||
null
|
||||
);
|
||||
return this.host;
|
||||
}
|
||||
setupCompilation(program, oldProgram) {
|
||||
const perfRecorder = ActivePerfRecorder.zeroedToNow();
|
||||
if (this.host === null || this.options === null) {
|
||||
throw new Error("Lifecycle error: setupCompilation() before wrapHost().");
|
||||
}
|
||||
this.host.postProgramCreationCleanup();
|
||||
const programDriver = new TsCreateProgramDriver(program, this.host, this.options, this.host.shimExtensionPrefixes);
|
||||
const strategy = new PatchedProgramIncrementalBuildStrategy();
|
||||
const oldState = oldProgram !== void 0 ? strategy.getIncrementalState(oldProgram) : null;
|
||||
let ticket;
|
||||
const modifiedResourceFiles = /* @__PURE__ */ new Set();
|
||||
if (this.host.getModifiedResourceFiles !== void 0) {
|
||||
for (const resourceFile of this.host.getModifiedResourceFiles() ?? []) {
|
||||
modifiedResourceFiles.add(resolve(resourceFile));
|
||||
}
|
||||
}
|
||||
if (oldProgram === void 0 || oldState === null) {
|
||||
ticket = freshCompilationTicket(
|
||||
program,
|
||||
this.options,
|
||||
strategy,
|
||||
programDriver,
|
||||
perfRecorder,
|
||||
/* enableTemplateTypeChecker */
|
||||
false,
|
||||
/* usePoisonedData */
|
||||
false
|
||||
);
|
||||
} else {
|
||||
strategy.toNextBuildStrategy().getIncrementalState(oldProgram);
|
||||
ticket = incrementalFromStateTicket(oldProgram, oldState, program, this.options, strategy, programDriver, modifiedResourceFiles, perfRecorder, false, false);
|
||||
}
|
||||
this._compiler = NgCompiler.fromTicket(ticket, this.host);
|
||||
return {
|
||||
ignoreForDiagnostics: this._compiler.ignoreForDiagnostics,
|
||||
ignoreForEmit: this._compiler.ignoreForEmit
|
||||
};
|
||||
}
|
||||
getDiagnostics(file) {
|
||||
if (file === void 0) {
|
||||
return this.compiler.getDiagnostics();
|
||||
}
|
||||
return this.compiler.getDiagnosticsForFile(file, OptimizeFor.WholeProgram);
|
||||
}
|
||||
getOptionDiagnostics() {
|
||||
return this.compiler.getOptionDiagnostics();
|
||||
}
|
||||
getNextProgram() {
|
||||
return this.compiler.getCurrentProgram();
|
||||
}
|
||||
createTransformers() {
|
||||
this.compiler.perfRecorder.phase(PerfPhase.TypeScriptEmit);
|
||||
return this.compiler.prepareEmit().transformers;
|
||||
}
|
||||
};
|
||||
|
||||
// packages/compiler-cli/index.ts
|
||||
setFileSystem(new NodeJSFileSystem());
|
||||
export {
|
||||
ConsoleLogger,
|
||||
DEFAULT_ERROR_CODE,
|
||||
DecoratorType,
|
||||
DocsExtractor,
|
||||
EmitFlags,
|
||||
EntryType,
|
||||
ErrorCode,
|
||||
GLOBAL_DEFS_FOR_TERSER,
|
||||
GLOBAL_DEFS_FOR_TERSER_WITH_AOT,
|
||||
InvalidFileSystem,
|
||||
LogLevel,
|
||||
LogicalFileSystem,
|
||||
LogicalProjectPath,
|
||||
MemberTags,
|
||||
MemberType,
|
||||
NgTscPlugin,
|
||||
NgtscCompilerHost,
|
||||
NgtscProgram,
|
||||
NodeJSFileSystem,
|
||||
OptimizeFor,
|
||||
SOURCE,
|
||||
UNKNOWN_ERROR_CODE,
|
||||
VERSION,
|
||||
absoluteFrom,
|
||||
absoluteFromSourceFile,
|
||||
angularJitApplicationTransform,
|
||||
basename,
|
||||
calcProjectFileAndBasePath,
|
||||
constructorParametersDownlevelTransform,
|
||||
createCompilerHost,
|
||||
createFileSystemTsReadDirectoryFn,
|
||||
createProgram,
|
||||
defaultGatherDiagnostics,
|
||||
dirname,
|
||||
exitCodeFromResult,
|
||||
formatDiagnostics,
|
||||
getDownlevelDecoratorsTransform,
|
||||
getFileSystem,
|
||||
getInitializerApiJitTransform,
|
||||
getSourceFileOrError,
|
||||
isDocEntryWithSourceInfo,
|
||||
isLocalCompilationDiagnostics,
|
||||
isLocalRelativePath,
|
||||
isRoot,
|
||||
isRooted,
|
||||
isTsDiagnostic,
|
||||
join,
|
||||
ngErrorCode,
|
||||
performCompilation,
|
||||
readConfiguration,
|
||||
relative,
|
||||
relativeFrom,
|
||||
resolve,
|
||||
setFileSystem,
|
||||
toRelativeImport
|
||||
};
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
+510
@@ -0,0 +1,510 @@
|
||||
|
||||
import {createRequire as __cjsCompatRequire} from 'module';
|
||||
const require = __cjsCompatRequire(import.meta.url);
|
||||
|
||||
import {
|
||||
FatalLinkerError,
|
||||
FileLinker,
|
||||
LinkerEnvironment,
|
||||
assert,
|
||||
isFatalLinkerError
|
||||
} from "../../chunk-FLWAEX6T.js";
|
||||
import {
|
||||
ConsoleLogger,
|
||||
LogLevel
|
||||
} from "../../chunk-6HOSNZU5.js";
|
||||
import "../../chunk-HYJ2H3FU.js";
|
||||
import "../../chunk-CSUVPNMK.js";
|
||||
import {
|
||||
NodeJSFileSystem
|
||||
} from "../../chunk-XYYEESKY.js";
|
||||
import "../../chunk-G7GFT6BU.js";
|
||||
|
||||
// packages/compiler-cli/linker/babel/src/es2015_linker_plugin.js
|
||||
import { types as t4 } from "@babel/core";
|
||||
|
||||
// packages/compiler-cli/linker/babel/src/ast/babel_ast_factory.js
|
||||
import { types as t } from "@babel/core";
|
||||
var BabelAstFactory = class {
|
||||
sourceUrl;
|
||||
constructor(sourceUrl) {
|
||||
this.sourceUrl = sourceUrl;
|
||||
}
|
||||
attachComments(statement, leadingComments) {
|
||||
for (let i = leadingComments.length - 1; i >= 0; i--) {
|
||||
const comment = leadingComments[i];
|
||||
t.addComment(statement, "leading", comment.toString(), !comment.multiline);
|
||||
}
|
||||
}
|
||||
createArrayLiteral = t.arrayExpression;
|
||||
createAssignment(target, operator, value) {
|
||||
assert(target, isLExpression, "must be a left hand side expression");
|
||||
return t.assignmentExpression(operator, target, value);
|
||||
}
|
||||
createBinaryExpression(leftOperand, operator, rightOperand) {
|
||||
switch (operator) {
|
||||
case "&&":
|
||||
case "||":
|
||||
case "??":
|
||||
return t.logicalExpression(operator, leftOperand, rightOperand);
|
||||
case "=":
|
||||
case "+=":
|
||||
case "-=":
|
||||
case "*=":
|
||||
case "/=":
|
||||
case "%=":
|
||||
case "**=":
|
||||
case "&&=":
|
||||
case "||=":
|
||||
case "??=":
|
||||
throw new Error(`Unexpected assignment operator ${operator}`);
|
||||
default:
|
||||
return t.binaryExpression(operator, leftOperand, rightOperand);
|
||||
}
|
||||
}
|
||||
createBlock = t.blockStatement;
|
||||
createCallExpression(callee, args, pure) {
|
||||
const call = t.callExpression(callee, args);
|
||||
if (pure) {
|
||||
t.addComment(
|
||||
call,
|
||||
"leading",
|
||||
" @__PURE__ ",
|
||||
/* line */
|
||||
false
|
||||
);
|
||||
}
|
||||
return call;
|
||||
}
|
||||
createConditional = t.conditionalExpression;
|
||||
createElementAccess(expression, element) {
|
||||
return t.memberExpression(
|
||||
expression,
|
||||
element,
|
||||
/* computed */
|
||||
true
|
||||
);
|
||||
}
|
||||
createExpressionStatement = t.expressionStatement;
|
||||
createSpreadElement(expression) {
|
||||
return t.spreadElement(expression);
|
||||
}
|
||||
createFunctionDeclaration(functionName, parameters, body) {
|
||||
assert(body, t.isBlockStatement, "a block");
|
||||
return t.functionDeclaration(t.identifier(functionName), parameters.map((param) => t.identifier(param)), body);
|
||||
}
|
||||
createArrowFunctionExpression(parameters, body) {
|
||||
if (t.isStatement(body)) {
|
||||
assert(body, t.isBlockStatement, "a block");
|
||||
}
|
||||
return t.arrowFunctionExpression(parameters.map((param) => t.identifier(param)), body);
|
||||
}
|
||||
createFunctionExpression(functionName, parameters, body) {
|
||||
assert(body, t.isBlockStatement, "a block");
|
||||
const name = functionName !== null ? t.identifier(functionName) : null;
|
||||
return t.functionExpression(name, parameters.map((param) => t.identifier(param)), body);
|
||||
}
|
||||
createIdentifier = t.identifier;
|
||||
createIfStatement = t.ifStatement;
|
||||
createDynamicImport(url) {
|
||||
return this.createCallExpression(
|
||||
t.import(),
|
||||
[typeof url === "string" ? t.stringLiteral(url) : url],
|
||||
false
|
||||
/* pure */
|
||||
);
|
||||
}
|
||||
createLiteral(value) {
|
||||
if (typeof value === "string") {
|
||||
return t.stringLiteral(value);
|
||||
} else if (typeof value === "number") {
|
||||
return t.numericLiteral(value);
|
||||
} else if (typeof value === "boolean") {
|
||||
return t.booleanLiteral(value);
|
||||
} else if (value === void 0) {
|
||||
return t.identifier("undefined");
|
||||
} else if (value === null) {
|
||||
return t.nullLiteral();
|
||||
} else {
|
||||
throw new Error(`Invalid literal: ${value} (${typeof value})`);
|
||||
}
|
||||
}
|
||||
createNewExpression(expression, args) {
|
||||
return t.newExpression(expression, args);
|
||||
}
|
||||
createObjectLiteral(properties) {
|
||||
return t.objectExpression(properties.map((prop) => {
|
||||
if (prop.kind === "spread") {
|
||||
return t.spreadElement(prop.expression);
|
||||
}
|
||||
const key = prop.quoted ? t.stringLiteral(prop.propertyName) : t.identifier(prop.propertyName);
|
||||
return t.objectProperty(key, prop.value);
|
||||
}));
|
||||
}
|
||||
createParenthesizedExpression = t.parenthesizedExpression;
|
||||
createPropertyAccess(expression, propertyName) {
|
||||
return t.memberExpression(
|
||||
expression,
|
||||
t.identifier(propertyName),
|
||||
/* computed */
|
||||
false
|
||||
);
|
||||
}
|
||||
createReturnStatement(expression) {
|
||||
return t.returnStatement(expression);
|
||||
}
|
||||
createTaggedTemplate(tag, template) {
|
||||
return t.taggedTemplateExpression(tag, this.createTemplateLiteral(template));
|
||||
}
|
||||
createTemplateLiteral(template) {
|
||||
const elements = template.elements.map((element, i) => this.setSourceMapRange(t.templateElement(element, i === template.elements.length - 1), element.range));
|
||||
return t.templateLiteral(elements, template.expressions);
|
||||
}
|
||||
createThrowStatement = t.throwStatement;
|
||||
createTypeOfExpression(expression) {
|
||||
return t.unaryExpression("typeof", expression);
|
||||
}
|
||||
createVoidExpression(expression) {
|
||||
return t.unaryExpression("void", expression);
|
||||
}
|
||||
createUnaryExpression = t.unaryExpression;
|
||||
createVariableDeclaration(variableName, initializer, type) {
|
||||
return t.variableDeclaration(type, [
|
||||
t.variableDeclarator(t.identifier(variableName), initializer)
|
||||
]);
|
||||
}
|
||||
createRegularExpressionLiteral(body, flags) {
|
||||
return t.regExpLiteral(body, flags ?? void 0);
|
||||
}
|
||||
setSourceMapRange(node, sourceMapRange) {
|
||||
if (sourceMapRange === null) {
|
||||
return node;
|
||||
}
|
||||
node.loc = {
|
||||
// Add in the filename so that we can map to external template files.
|
||||
// Note that Babel gets confused if you specify a filename when it is the original source
|
||||
// file. This happens when the template is inline, in which case just use `undefined`.
|
||||
filename: sourceMapRange.url !== this.sourceUrl ? sourceMapRange.url : void 0,
|
||||
start: {
|
||||
line: sourceMapRange.start.line + 1,
|
||||
// lines are 1-based in Babel.
|
||||
column: sourceMapRange.start.column
|
||||
},
|
||||
end: {
|
||||
line: sourceMapRange.end.line + 1,
|
||||
// lines are 1-based in Babel.
|
||||
column: sourceMapRange.end.column
|
||||
}
|
||||
};
|
||||
node.start = sourceMapRange.start.offset;
|
||||
node.end = sourceMapRange.end.offset;
|
||||
return node;
|
||||
}
|
||||
};
|
||||
function isLExpression(expr) {
|
||||
return t.isLVal(expr);
|
||||
}
|
||||
|
||||
// packages/compiler-cli/linker/babel/src/ast/babel_ast_host.js
|
||||
import { types as t2 } from "@babel/core";
|
||||
var BabelAstHost = class {
|
||||
getSymbolName(node) {
|
||||
if (t2.isIdentifier(node)) {
|
||||
return node.name;
|
||||
} else if (t2.isMemberExpression(node) && t2.isIdentifier(node.property)) {
|
||||
return node.property.name;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
isStringLiteral = t2.isStringLiteral;
|
||||
parseStringLiteral(str) {
|
||||
assert(str, t2.isStringLiteral, "a string literal");
|
||||
return str.value;
|
||||
}
|
||||
isNumericLiteral = t2.isNumericLiteral;
|
||||
parseNumericLiteral(num) {
|
||||
assert(num, t2.isNumericLiteral, "a numeric literal");
|
||||
return num.value;
|
||||
}
|
||||
isBooleanLiteral(bool) {
|
||||
return t2.isBooleanLiteral(bool) || isMinifiedBooleanLiteral(bool);
|
||||
}
|
||||
parseBooleanLiteral(bool) {
|
||||
if (t2.isBooleanLiteral(bool)) {
|
||||
return bool.value;
|
||||
} else if (isMinifiedBooleanLiteral(bool)) {
|
||||
return !bool.argument.value;
|
||||
} else {
|
||||
throw new FatalLinkerError(bool, "Unsupported syntax, expected a boolean literal.");
|
||||
}
|
||||
}
|
||||
isNull(node) {
|
||||
return t2.isNullLiteral(node);
|
||||
}
|
||||
isArrayLiteral = t2.isArrayExpression;
|
||||
parseArrayLiteral(array) {
|
||||
assert(array, t2.isArrayExpression, "an array literal");
|
||||
return array.elements.map((element) => {
|
||||
assert(element, isNotEmptyElement, "element in array not to be empty");
|
||||
assert(element, isNotSpreadElement, "element in array not to use spread syntax");
|
||||
return element;
|
||||
});
|
||||
}
|
||||
isObjectLiteral = t2.isObjectExpression;
|
||||
parseObjectLiteral(obj) {
|
||||
assert(obj, t2.isObjectExpression, "an object literal");
|
||||
const result = /* @__PURE__ */ new Map();
|
||||
for (const property of obj.properties) {
|
||||
assert(property, t2.isObjectProperty, "a property assignment");
|
||||
assert(property.value, t2.isExpression, "an expression");
|
||||
assert(property.key, isObjectExpressionPropertyName, "a property name");
|
||||
const key = t2.isIdentifier(property.key) ? property.key.name : property.key.value;
|
||||
result.set(`${key}`, property.value);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
isFunctionExpression(node) {
|
||||
return t2.isFunction(node) || t2.isArrowFunctionExpression(node);
|
||||
}
|
||||
parseReturnValue(fn) {
|
||||
assert(fn, this.isFunctionExpression, "a function");
|
||||
if (!t2.isBlockStatement(fn.body)) {
|
||||
return fn.body;
|
||||
}
|
||||
if (fn.body.body.length !== 1) {
|
||||
throw new FatalLinkerError(fn.body, "Unsupported syntax, expected a function body with a single return statement.");
|
||||
}
|
||||
const stmt = fn.body.body[0];
|
||||
assert(stmt, t2.isReturnStatement, "a function body with a single return statement");
|
||||
if (stmt.argument === null || stmt.argument === void 0) {
|
||||
throw new FatalLinkerError(stmt, "Unsupported syntax, expected function to return a value.");
|
||||
}
|
||||
return stmt.argument;
|
||||
}
|
||||
parseParameters(fn) {
|
||||
assert(fn, this.isFunctionExpression, "a function");
|
||||
return fn.params.map((param) => {
|
||||
assert(param, t2.isIdentifier, "an identifier");
|
||||
return param;
|
||||
});
|
||||
}
|
||||
isCallExpression = t2.isCallExpression;
|
||||
parseCallee(call) {
|
||||
assert(call, t2.isCallExpression, "a call expression");
|
||||
assert(call.callee, t2.isExpression, "an expression");
|
||||
return call.callee;
|
||||
}
|
||||
parseArguments(call) {
|
||||
assert(call, t2.isCallExpression, "a call expression");
|
||||
return call.arguments.map((arg) => {
|
||||
assert(arg, isNotSpreadArgument, "argument not to use spread syntax");
|
||||
assert(arg, t2.isExpression, "argument to be an expression");
|
||||
return arg;
|
||||
});
|
||||
}
|
||||
getRange(node) {
|
||||
if (node.loc == null || node.start == null || node.end == null) {
|
||||
throw new FatalLinkerError(node, "Unable to read range for node - it is missing location information.");
|
||||
}
|
||||
return {
|
||||
startLine: node.loc.start.line - 1,
|
||||
// Babel lines are 1-based
|
||||
startCol: node.loc.start.column,
|
||||
startPos: node.start,
|
||||
endPos: node.end
|
||||
};
|
||||
}
|
||||
};
|
||||
function isNotEmptyElement(e) {
|
||||
return e !== null;
|
||||
}
|
||||
function isNotSpreadElement(e) {
|
||||
return !t2.isSpreadElement(e);
|
||||
}
|
||||
function isObjectExpressionPropertyName(n) {
|
||||
return t2.isIdentifier(n) || t2.isStringLiteral(n) || t2.isNumericLiteral(n);
|
||||
}
|
||||
function isNotSpreadArgument(arg) {
|
||||
return !t2.isSpreadElement(arg);
|
||||
}
|
||||
function isMinifiedBooleanLiteral(node) {
|
||||
return t2.isUnaryExpression(node) && node.prefix && node.operator === "!" && t2.isNumericLiteral(node.argument) && (node.argument.value === 0 || node.argument.value === 1);
|
||||
}
|
||||
|
||||
// packages/compiler-cli/linker/babel/src/babel_declaration_scope.js
|
||||
import { types as t3 } from "@babel/core";
|
||||
var BabelDeclarationScope = class {
|
||||
declarationScope;
|
||||
/**
|
||||
* Construct a new `BabelDeclarationScope`.
|
||||
*
|
||||
* @param declarationScope the Babel scope containing the declaration call expression.
|
||||
*/
|
||||
constructor(declarationScope) {
|
||||
this.declarationScope = declarationScope;
|
||||
}
|
||||
/**
|
||||
* Compute the Babel `NodePath` that can be used to reference the lexical scope where any
|
||||
* shared constant statements would be inserted.
|
||||
*
|
||||
* There will only be a shared constant scope if the expression is in an ECMAScript module, or a
|
||||
* UMD module. Otherwise `null` is returned to indicate that constant statements must be emitted
|
||||
* locally to the generated linked definition, to avoid polluting the global scope.
|
||||
*
|
||||
* @param expression the expression that points to the Angular core framework import.
|
||||
*/
|
||||
getConstantScopeRef(expression) {
|
||||
let bindingExpression = expression;
|
||||
while (t3.isMemberExpression(bindingExpression)) {
|
||||
bindingExpression = bindingExpression.object;
|
||||
}
|
||||
if (!t3.isIdentifier(bindingExpression)) {
|
||||
return null;
|
||||
}
|
||||
const binding = this.declarationScope.getBinding(bindingExpression.name);
|
||||
if (binding === void 0) {
|
||||
return null;
|
||||
}
|
||||
const path = binding.scope.path;
|
||||
if (!path.isFunctionDeclaration() && !path.isFunctionExpression() && !(path.isProgram() && path.node.sourceType === "module")) {
|
||||
return null;
|
||||
}
|
||||
return path;
|
||||
}
|
||||
};
|
||||
|
||||
// packages/compiler-cli/linker/babel/src/es2015_linker_plugin.js
|
||||
function createEs2015LinkerPlugin({ fileSystem, logger, ...options }) {
|
||||
let fileLinker = null;
|
||||
return {
|
||||
visitor: {
|
||||
Program: {
|
||||
/**
|
||||
* Create a new `FileLinker` as we enter each file (`t.Program` in Babel).
|
||||
*/
|
||||
enter(_, state) {
|
||||
assertNull(fileLinker);
|
||||
const file = state.file;
|
||||
const filename = file.opts.filename ?? file.opts.filenameRelative;
|
||||
if (!filename) {
|
||||
throw new Error("No filename (nor filenameRelative) provided by Babel. This is required for the linking of partially compiled directives and components.");
|
||||
}
|
||||
const sourceUrl = fileSystem.resolve(file.opts.cwd ?? ".", filename);
|
||||
const linkerEnvironment = LinkerEnvironment.create(fileSystem, logger, new BabelAstHost(), new BabelAstFactory(sourceUrl), options);
|
||||
fileLinker = new FileLinker(linkerEnvironment, sourceUrl, file.code);
|
||||
},
|
||||
/**
|
||||
* On exiting the file, insert any shared constant statements that were generated during
|
||||
* linking of the partial declarations.
|
||||
*/
|
||||
exit() {
|
||||
assertNotNull(fileLinker);
|
||||
for (const { constantScope, statements } of fileLinker.getConstantStatements()) {
|
||||
insertStatements(constantScope, statements);
|
||||
}
|
||||
fileLinker = null;
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Test each call expression to see if it is a partial declaration; it if is then replace it
|
||||
* with the results of linking the declaration.
|
||||
*/
|
||||
CallExpression(call, state) {
|
||||
if (fileLinker === null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const calleeName = getCalleeName(call);
|
||||
if (calleeName === null) {
|
||||
return;
|
||||
}
|
||||
const args = call.node.arguments;
|
||||
if (!fileLinker.isPartialDeclaration(calleeName) || !isExpressionArray(args)) {
|
||||
return;
|
||||
}
|
||||
const declarationScope = new BabelDeclarationScope(call.scope);
|
||||
const replacement = fileLinker.linkPartialDeclaration(calleeName, args, declarationScope);
|
||||
call.replaceWith(replacement);
|
||||
} catch (e) {
|
||||
const node = isFatalLinkerError(e) ? e.node : call.node;
|
||||
throw buildCodeFrameError(state.file, e.message, node);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
function insertStatements(path, statements) {
|
||||
if (path.isProgram()) {
|
||||
insertIntoProgram(path, statements);
|
||||
} else {
|
||||
insertIntoFunction(path, statements);
|
||||
}
|
||||
}
|
||||
function insertIntoFunction(fn, statements) {
|
||||
const body = fn.get("body");
|
||||
body.unshiftContainer("body", statements);
|
||||
}
|
||||
function insertIntoProgram(program, statements) {
|
||||
const body = program.get("body");
|
||||
const insertBeforeIndex = body.findIndex((statement) => !statement.isImportDeclaration());
|
||||
if (insertBeforeIndex === -1) {
|
||||
program.unshiftContainer("body", statements);
|
||||
} else {
|
||||
body[insertBeforeIndex].insertBefore(statements);
|
||||
}
|
||||
}
|
||||
function getCalleeName(call) {
|
||||
const callee = call.node.callee;
|
||||
if (t4.isIdentifier(callee)) {
|
||||
return callee.name;
|
||||
} else if (t4.isMemberExpression(callee) && t4.isIdentifier(callee.property)) {
|
||||
return callee.property.name;
|
||||
} else if (t4.isMemberExpression(callee) && t4.isStringLiteral(callee.property)) {
|
||||
return callee.property.value;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
function isExpressionArray(nodes) {
|
||||
return nodes.every((node) => t4.isExpression(node));
|
||||
}
|
||||
function assertNull(obj) {
|
||||
if (obj !== null) {
|
||||
throw new Error("BUG - expected `obj` to be null");
|
||||
}
|
||||
}
|
||||
function assertNotNull(obj) {
|
||||
if (obj === null) {
|
||||
throw new Error("BUG - expected `obj` not to be null");
|
||||
}
|
||||
}
|
||||
function buildCodeFrameError(file, message, node) {
|
||||
const filename = file.opts.filename || "(unknown file)";
|
||||
const error = file.hub.buildError(node, message);
|
||||
return `${filename}: ${error.message}`;
|
||||
}
|
||||
|
||||
// packages/compiler-cli/linker/babel/src/babel_plugin.js
|
||||
function defaultLinkerPlugin(api, options) {
|
||||
api.assertVersion(7);
|
||||
return createEs2015LinkerPlugin({
|
||||
...options,
|
||||
fileSystem: new NodeJSFileSystem(),
|
||||
logger: new ConsoleLogger(LogLevel.info)
|
||||
});
|
||||
}
|
||||
|
||||
// packages/compiler-cli/linker/babel/index.ts
|
||||
var babel_default = defaultLinkerPlugin;
|
||||
export {
|
||||
createEs2015LinkerPlugin,
|
||||
babel_default as default
|
||||
};
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
|
||||
import {createRequire as __cjsCompatRequire} from 'module';
|
||||
const require = __cjsCompatRequire(import.meta.url);
|
||||
|
||||
import {
|
||||
DEFAULT_LINKER_OPTIONS,
|
||||
FatalLinkerError,
|
||||
FileLinker,
|
||||
LinkerEnvironment,
|
||||
assert,
|
||||
isFatalLinkerError,
|
||||
needsLinking
|
||||
} from "../chunk-FLWAEX6T.js";
|
||||
import "../chunk-HYJ2H3FU.js";
|
||||
import "../chunk-CSUVPNMK.js";
|
||||
import "../chunk-G7GFT6BU.js";
|
||||
export {
|
||||
DEFAULT_LINKER_OPTIONS,
|
||||
FatalLinkerError,
|
||||
FileLinker,
|
||||
LinkerEnvironment,
|
||||
assert,
|
||||
isFatalLinkerError,
|
||||
needsLinking
|
||||
};
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
|
||||
import {createRequire as __cjsCompatRequire} from 'module';
|
||||
const require = __cjsCompatRequire(import.meta.url);
|
||||
|
||||
import {
|
||||
ConsoleLogger,
|
||||
LogLevel
|
||||
} from "../chunk-6HOSNZU5.js";
|
||||
import {
|
||||
SourceFile,
|
||||
SourceFileLoader
|
||||
} from "../chunk-HYJ2H3FU.js";
|
||||
import {
|
||||
InvalidFileSystem,
|
||||
LogicalFileSystem,
|
||||
LogicalProjectPath,
|
||||
NgtscCompilerHost,
|
||||
absoluteFrom,
|
||||
absoluteFromSourceFile,
|
||||
basename,
|
||||
createFileSystemTsReadDirectoryFn,
|
||||
dirname,
|
||||
getFileSystem,
|
||||
getSourceFileOrError,
|
||||
isLocalRelativePath,
|
||||
isRoot,
|
||||
isRooted,
|
||||
join,
|
||||
relative,
|
||||
relativeFrom,
|
||||
resolve,
|
||||
setFileSystem,
|
||||
toRelativeImport
|
||||
} from "../chunk-CEBE44Q5.js";
|
||||
import {
|
||||
NodeJSFileSystem
|
||||
} from "../chunk-XYYEESKY.js";
|
||||
import "../chunk-G7GFT6BU.js";
|
||||
export {
|
||||
ConsoleLogger,
|
||||
InvalidFileSystem,
|
||||
LogLevel,
|
||||
LogicalFileSystem,
|
||||
LogicalProjectPath,
|
||||
NgtscCompilerHost,
|
||||
NodeJSFileSystem,
|
||||
SourceFile,
|
||||
SourceFileLoader,
|
||||
absoluteFrom,
|
||||
absoluteFromSourceFile,
|
||||
basename,
|
||||
createFileSystemTsReadDirectoryFn,
|
||||
dirname,
|
||||
getFileSystem,
|
||||
getSourceFileOrError,
|
||||
isLocalRelativePath,
|
||||
isRoot,
|
||||
isRooted,
|
||||
join,
|
||||
relative,
|
||||
relativeFrom,
|
||||
resolve,
|
||||
setFileSystem,
|
||||
toRelativeImport
|
||||
};
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
|
||||
import {createRequire as __cjsCompatRequire} from 'module';
|
||||
const require = __cjsCompatRequire(import.meta.url);
|
||||
|
||||
import {
|
||||
DiagnosticCategoryLabel,
|
||||
NgCompiler
|
||||
} from "../chunk-PW54LIP6.js";
|
||||
import {
|
||||
CompilationMode,
|
||||
DtsMetadataReader,
|
||||
DynamicValue,
|
||||
FatalDiagnosticError,
|
||||
ImportManager,
|
||||
PartialEvaluator,
|
||||
PotentialImportKind,
|
||||
PotentialImportMode,
|
||||
Reference,
|
||||
ReferenceEmitKind,
|
||||
ReferenceEmitter,
|
||||
StaticInterpreter,
|
||||
SymbolKind,
|
||||
TypeScriptReflectionHost,
|
||||
createForwardRefResolver,
|
||||
extractDecoratorQueryMetadata,
|
||||
extractTemplate,
|
||||
findAngularDecorator,
|
||||
getAngularDecorators,
|
||||
getRootDirs,
|
||||
isShim,
|
||||
parseDecoratorInputTransformFunction,
|
||||
queryDecoratorNames,
|
||||
reflectObjectLiteral,
|
||||
unwrapExpression
|
||||
} from "../chunk-IG22BDVK.js";
|
||||
import "../chunk-CSUVPNMK.js";
|
||||
import {
|
||||
getFileSystem,
|
||||
isLocalRelativePath
|
||||
} from "../chunk-CEBE44Q5.js";
|
||||
import {
|
||||
NodeJSFileSystem
|
||||
} from "../chunk-XYYEESKY.js";
|
||||
import "../chunk-G7GFT6BU.js";
|
||||
export {
|
||||
CompilationMode,
|
||||
DiagnosticCategoryLabel,
|
||||
DtsMetadataReader,
|
||||
DynamicValue,
|
||||
FatalDiagnosticError,
|
||||
ImportManager,
|
||||
NgCompiler,
|
||||
NodeJSFileSystem,
|
||||
PartialEvaluator,
|
||||
PotentialImportKind,
|
||||
PotentialImportMode,
|
||||
Reference,
|
||||
ReferenceEmitKind,
|
||||
ReferenceEmitter,
|
||||
StaticInterpreter,
|
||||
SymbolKind,
|
||||
TypeScriptReflectionHost,
|
||||
createForwardRefResolver,
|
||||
extractDecoratorQueryMetadata,
|
||||
extractTemplate,
|
||||
findAngularDecorator,
|
||||
getAngularDecorators,
|
||||
getFileSystem,
|
||||
getRootDirs,
|
||||
isLocalRelativePath,
|
||||
isShim,
|
||||
parseDecoratorInputTransformFunction,
|
||||
queryDecoratorNames,
|
||||
reflectObjectLiteral,
|
||||
unwrapExpression
|
||||
};
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
+527
@@ -0,0 +1,527 @@
|
||||
|
||||
import {createRequire as __cjsCompatRequire} from 'module';
|
||||
const require = __cjsCompatRequire(import.meta.url);
|
||||
|
||||
import {
|
||||
ImportedSymbolsTracker,
|
||||
TypeScriptReflectionHost,
|
||||
getInitializerApiJitTransform
|
||||
} from "../chunk-IG22BDVK.js";
|
||||
import "../chunk-CSUVPNMK.js";
|
||||
import {
|
||||
InvalidFileSystem,
|
||||
absoluteFrom,
|
||||
basename,
|
||||
dirname,
|
||||
resolve,
|
||||
setFileSystem
|
||||
} from "../chunk-CEBE44Q5.js";
|
||||
import {
|
||||
NodeJSFileSystem
|
||||
} from "../chunk-XYYEESKY.js";
|
||||
import "../chunk-G7GFT6BU.js";
|
||||
|
||||
// packages/compiler-cli/src/ngtsc/file_system/testing/src/mock_file_system.js
|
||||
var MockFileSystem = class {
|
||||
_isCaseSensitive;
|
||||
_fileTree = {};
|
||||
_cwd;
|
||||
constructor(_isCaseSensitive = false, cwd = "/") {
|
||||
this._isCaseSensitive = _isCaseSensitive;
|
||||
this._cwd = this.normalize(cwd);
|
||||
}
|
||||
isCaseSensitive() {
|
||||
return this._isCaseSensitive;
|
||||
}
|
||||
exists(path) {
|
||||
return this.findFromPath(path).entity !== null;
|
||||
}
|
||||
readFile(path) {
|
||||
const { entity } = this.findFromPath(path);
|
||||
if (isFile(entity)) {
|
||||
if (entity instanceof Uint8Array) {
|
||||
return new TextDecoder().decode(entity);
|
||||
}
|
||||
return entity.toString();
|
||||
} else {
|
||||
throw new MockFileSystemError("ENOENT", path, `File "${path}" does not exist.`);
|
||||
}
|
||||
}
|
||||
readFileBuffer(path) {
|
||||
const { entity } = this.findFromPath(path);
|
||||
if (isFile(entity)) {
|
||||
if (entity instanceof Uint8Array) {
|
||||
return entity;
|
||||
}
|
||||
const encoder = new TextEncoder();
|
||||
return encoder.encode(entity);
|
||||
} else {
|
||||
throw new MockFileSystemError("ENOENT", path, `File "${path}" does not exist.`);
|
||||
}
|
||||
}
|
||||
writeFile(path, data, exclusive = false) {
|
||||
const [folderPath, basename2] = this.splitIntoFolderAndFile(path);
|
||||
const { entity } = this.findFromPath(folderPath);
|
||||
if (entity === null || !isFolder(entity)) {
|
||||
throw new MockFileSystemError("ENOENT", path, `Unable to write file "${path}". The containing folder does not exist.`);
|
||||
}
|
||||
if (exclusive && entity[basename2] !== void 0) {
|
||||
throw new MockFileSystemError("EEXIST", path, `Unable to exclusively write file "${path}". The file already exists.`);
|
||||
}
|
||||
entity[basename2] = data;
|
||||
}
|
||||
removeFile(path) {
|
||||
const [folderPath, basename2] = this.splitIntoFolderAndFile(path);
|
||||
const { entity } = this.findFromPath(folderPath);
|
||||
if (entity === null || !isFolder(entity)) {
|
||||
throw new MockFileSystemError("ENOENT", path, `Unable to remove file "${path}". The containing folder does not exist.`);
|
||||
}
|
||||
if (isFolder(entity[basename2])) {
|
||||
throw new MockFileSystemError("EISDIR", path, `Unable to remove file "${path}". The path to remove is a folder.`);
|
||||
}
|
||||
delete entity[basename2];
|
||||
}
|
||||
symlink(target, path) {
|
||||
const [folderPath, basename2] = this.splitIntoFolderAndFile(path);
|
||||
const { entity } = this.findFromPath(folderPath);
|
||||
if (entity === null || !isFolder(entity)) {
|
||||
throw new MockFileSystemError("ENOENT", path, `Unable to create symlink at "${path}". The containing folder does not exist.`);
|
||||
}
|
||||
entity[basename2] = new SymLink(target);
|
||||
}
|
||||
readdir(path) {
|
||||
const { entity } = this.findFromPath(path);
|
||||
if (entity === null) {
|
||||
throw new MockFileSystemError("ENOENT", path, `Unable to read directory "${path}". It does not exist.`);
|
||||
}
|
||||
if (isFile(entity)) {
|
||||
throw new MockFileSystemError("ENOTDIR", path, `Unable to read directory "${path}". It is a file.`);
|
||||
}
|
||||
return Object.keys(entity);
|
||||
}
|
||||
lstat(path) {
|
||||
const { entity } = this.findFromPath(path);
|
||||
if (entity === null) {
|
||||
throw new MockFileSystemError("ENOENT", path, `File "${path}" does not exist.`);
|
||||
}
|
||||
return new MockFileStats(entity);
|
||||
}
|
||||
stat(path) {
|
||||
const { entity } = this.findFromPath(path, { followSymLinks: true });
|
||||
if (entity === null) {
|
||||
throw new MockFileSystemError("ENOENT", path, `File "${path}" does not exist.`);
|
||||
}
|
||||
return new MockFileStats(entity);
|
||||
}
|
||||
copyFile(from, to) {
|
||||
this.writeFile(to, this.readFile(from));
|
||||
}
|
||||
moveFile(from, to) {
|
||||
this.writeFile(to, this.readFile(from));
|
||||
const result = this.findFromPath(dirname(from));
|
||||
const folder = result.entity;
|
||||
const name = basename(from);
|
||||
delete folder[name];
|
||||
}
|
||||
ensureDir(path) {
|
||||
const segments = this.splitPath(path).map((segment) => this.getCanonicalPath(segment));
|
||||
segments[0] = "";
|
||||
if (segments.length > 1 && segments[segments.length - 1] === "") {
|
||||
segments.pop();
|
||||
}
|
||||
let current = this._fileTree;
|
||||
for (const segment of segments) {
|
||||
if (isFile(current[segment])) {
|
||||
throw new Error(`Folder already exists as a file.`);
|
||||
}
|
||||
if (!current[segment]) {
|
||||
current[segment] = {};
|
||||
}
|
||||
current = current[segment];
|
||||
}
|
||||
return current;
|
||||
}
|
||||
removeDeep(path) {
|
||||
const [folderPath, basename2] = this.splitIntoFolderAndFile(path);
|
||||
const { entity } = this.findFromPath(folderPath);
|
||||
if (entity === null || !isFolder(entity)) {
|
||||
throw new MockFileSystemError("ENOENT", path, `Unable to remove folder "${path}". The containing folder does not exist.`);
|
||||
}
|
||||
delete entity[basename2];
|
||||
}
|
||||
isRoot(path) {
|
||||
return this.dirname(path) === path;
|
||||
}
|
||||
extname(path) {
|
||||
const match = /.+(\.[^.]*)$/.exec(path);
|
||||
return match !== null ? match[1] : "";
|
||||
}
|
||||
realpath(filePath) {
|
||||
const result = this.findFromPath(filePath, { followSymLinks: true });
|
||||
if (result.entity === null) {
|
||||
throw new MockFileSystemError("ENOENT", filePath, `Unable to find the real path of "${filePath}". It does not exist.`);
|
||||
} else {
|
||||
return result.path;
|
||||
}
|
||||
}
|
||||
pwd() {
|
||||
return this._cwd;
|
||||
}
|
||||
chdir(path) {
|
||||
this._cwd = this.normalize(path);
|
||||
}
|
||||
getDefaultLibLocation() {
|
||||
let path = "node_modules/typescript/lib";
|
||||
let resolvedPath = this.resolve(path);
|
||||
const topLevelNodeModules = this.resolve("/" + path);
|
||||
while (resolvedPath !== topLevelNodeModules) {
|
||||
if (this.exists(resolvedPath)) {
|
||||
return resolvedPath;
|
||||
}
|
||||
path = "../" + path;
|
||||
resolvedPath = this.resolve(path);
|
||||
}
|
||||
return topLevelNodeModules;
|
||||
}
|
||||
dump() {
|
||||
const { entity } = this.findFromPath(this.resolve("/"));
|
||||
if (entity === null || !isFolder(entity)) {
|
||||
return {};
|
||||
}
|
||||
return this.cloneFolder(entity);
|
||||
}
|
||||
init(folder) {
|
||||
this.mount(this.resolve("/"), folder);
|
||||
}
|
||||
mount(path, folder) {
|
||||
if (this.exists(path)) {
|
||||
throw new Error(`Unable to mount in '${path}' as it already exists.`);
|
||||
}
|
||||
const mountFolder = this.ensureDir(path);
|
||||
this.copyInto(folder, mountFolder);
|
||||
}
|
||||
cloneFolder(folder) {
|
||||
const clone = {};
|
||||
this.copyInto(folder, clone);
|
||||
return clone;
|
||||
}
|
||||
copyInto(from, to) {
|
||||
for (const path in from) {
|
||||
const item = from[path];
|
||||
const canonicalPath = this.getCanonicalPath(path);
|
||||
if (isSymLink(item)) {
|
||||
to[canonicalPath] = new SymLink(this.getCanonicalPath(item.path));
|
||||
} else if (isFolder(item)) {
|
||||
to[canonicalPath] = this.cloneFolder(item);
|
||||
} else {
|
||||
to[canonicalPath] = from[path];
|
||||
}
|
||||
}
|
||||
}
|
||||
findFromPath(path, options) {
|
||||
const followSymLinks = !!options && options.followSymLinks;
|
||||
const segments = this.splitPath(path);
|
||||
if (segments.length > 1 && segments[segments.length - 1] === "") {
|
||||
segments.pop();
|
||||
}
|
||||
segments[0] = "";
|
||||
let current = this._fileTree;
|
||||
while (segments.length) {
|
||||
current = current[this.getCanonicalPath(segments.shift())];
|
||||
if (current === void 0) {
|
||||
return { path, entity: null };
|
||||
}
|
||||
if (segments.length > 0) {
|
||||
if (isFile(current)) {
|
||||
current = null;
|
||||
break;
|
||||
}
|
||||
if (isSymLink(current)) {
|
||||
return this.findFromPath(resolve(current.path, ...segments), { followSymLinks });
|
||||
}
|
||||
}
|
||||
if (isFile(current)) {
|
||||
break;
|
||||
}
|
||||
if (isSymLink(current)) {
|
||||
if (followSymLinks) {
|
||||
return this.findFromPath(resolve(current.path, ...segments), { followSymLinks });
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return { path, entity: current };
|
||||
}
|
||||
splitIntoFolderAndFile(path) {
|
||||
const segments = this.splitPath(this.getCanonicalPath(path));
|
||||
const file = segments.pop();
|
||||
return [path.substring(0, path.length - file.length - 1), file];
|
||||
}
|
||||
getCanonicalPath(p3) {
|
||||
return this.isCaseSensitive() ? p3 : p3.toLowerCase();
|
||||
}
|
||||
};
|
||||
var SymLink = class {
|
||||
path;
|
||||
constructor(path) {
|
||||
this.path = path;
|
||||
}
|
||||
};
|
||||
var MockFileStats = class {
|
||||
entity;
|
||||
constructor(entity) {
|
||||
this.entity = entity;
|
||||
}
|
||||
isFile() {
|
||||
return isFile(this.entity);
|
||||
}
|
||||
isDirectory() {
|
||||
return isFolder(this.entity);
|
||||
}
|
||||
isSymbolicLink() {
|
||||
return isSymLink(this.entity);
|
||||
}
|
||||
};
|
||||
var MockFileSystemError = class extends Error {
|
||||
code;
|
||||
path;
|
||||
constructor(code, path, message) {
|
||||
super(message);
|
||||
this.code = code;
|
||||
this.path = path;
|
||||
}
|
||||
};
|
||||
function isFile(item) {
|
||||
return item instanceof Uint8Array || typeof item === "string";
|
||||
}
|
||||
function isSymLink(item) {
|
||||
return item instanceof SymLink;
|
||||
}
|
||||
function isFolder(item) {
|
||||
return item !== null && !isFile(item) && !isSymLink(item);
|
||||
}
|
||||
|
||||
// packages/compiler-cli/src/ngtsc/file_system/testing/src/mock_file_system_native.js
|
||||
import * as os from "os";
|
||||
var isWindows = os.platform?.() === "win32";
|
||||
var MockFileSystemNative = class extends MockFileSystem {
|
||||
constructor(cwd = "/") {
|
||||
super(void 0, cwd);
|
||||
}
|
||||
// Delegate to the real NodeJSFileSystem for these path related methods
|
||||
resolve(...paths) {
|
||||
return NodeJSFileSystem.prototype.resolve.call(this, this.pwd(), ...paths);
|
||||
}
|
||||
dirname(file) {
|
||||
return NodeJSFileSystem.prototype.dirname.call(this, file);
|
||||
}
|
||||
join(basePath, ...paths) {
|
||||
return NodeJSFileSystem.prototype.join.call(this, basePath, ...paths);
|
||||
}
|
||||
relative(from, to) {
|
||||
return NodeJSFileSystem.prototype.relative.call(this, from, to);
|
||||
}
|
||||
basename(filePath, extension) {
|
||||
return NodeJSFileSystem.prototype.basename.call(this, filePath, extension);
|
||||
}
|
||||
isCaseSensitive() {
|
||||
return NodeJSFileSystem.prototype.isCaseSensitive.call(this);
|
||||
}
|
||||
isRooted(path) {
|
||||
return NodeJSFileSystem.prototype.isRooted.call(this, path);
|
||||
}
|
||||
isRoot(path) {
|
||||
return NodeJSFileSystem.prototype.isRoot.call(this, path);
|
||||
}
|
||||
normalize(path) {
|
||||
if (isWindows) {
|
||||
path = path.replace(/^[\/\\]/i, "C:/");
|
||||
}
|
||||
return NodeJSFileSystem.prototype.normalize.call(this, path);
|
||||
}
|
||||
splitPath(path) {
|
||||
return path.split(/[\\\/]/);
|
||||
}
|
||||
};
|
||||
|
||||
// packages/compiler-cli/src/ngtsc/file_system/testing/src/mock_file_system_posix.js
|
||||
import * as p from "path";
|
||||
var MockFileSystemPosix = class extends MockFileSystem {
|
||||
resolve(...paths) {
|
||||
const resolved = p.posix.resolve(this.pwd(), ...paths);
|
||||
return this.normalize(resolved);
|
||||
}
|
||||
dirname(file) {
|
||||
return this.normalize(p.posix.dirname(file));
|
||||
}
|
||||
join(basePath, ...paths) {
|
||||
return this.normalize(p.posix.join(basePath, ...paths));
|
||||
}
|
||||
relative(from, to) {
|
||||
return this.normalize(p.posix.relative(from, to));
|
||||
}
|
||||
basename(filePath, extension) {
|
||||
return p.posix.basename(filePath, extension);
|
||||
}
|
||||
isRooted(path) {
|
||||
return path.startsWith("/");
|
||||
}
|
||||
splitPath(path) {
|
||||
return path.split("/");
|
||||
}
|
||||
normalize(path) {
|
||||
return path.replace(/^[a-z]:\//i, "/").replace(/\\/g, "/");
|
||||
}
|
||||
};
|
||||
|
||||
// packages/compiler-cli/src/ngtsc/file_system/testing/src/mock_file_system_windows.js
|
||||
import * as p2 from "path";
|
||||
var MockFileSystemWindows = class extends MockFileSystem {
|
||||
resolve(...paths) {
|
||||
const resolved = p2.win32.resolve(this.pwd(), ...paths);
|
||||
return this.normalize(resolved);
|
||||
}
|
||||
dirname(path) {
|
||||
return this.normalize(p2.win32.dirname(path));
|
||||
}
|
||||
join(basePath, ...paths) {
|
||||
return this.normalize(p2.win32.join(basePath, ...paths));
|
||||
}
|
||||
relative(from, to) {
|
||||
return this.normalize(p2.win32.relative(from, to));
|
||||
}
|
||||
basename(filePath, extension) {
|
||||
return p2.win32.basename(filePath, extension);
|
||||
}
|
||||
isRooted(path) {
|
||||
return /^([A-Z]:)?([\\\/]|$)/i.test(path);
|
||||
}
|
||||
splitPath(path) {
|
||||
return path.split(/[\\\/]/);
|
||||
}
|
||||
normalize(path) {
|
||||
return path.replace(/^[\/\\]/i, "C:/").replace(/\\/g, "/");
|
||||
}
|
||||
};
|
||||
|
||||
// packages/compiler-cli/src/ngtsc/file_system/testing/src/test_helper.js
|
||||
import ts from "typescript";
|
||||
var FS_NATIVE = "Native";
|
||||
var FS_OS_X = "OS/X";
|
||||
var FS_UNIX = "Unix";
|
||||
var FS_WINDOWS = "Windows";
|
||||
var FS_ALL = [FS_OS_X, FS_WINDOWS, FS_UNIX, FS_NATIVE];
|
||||
function runInEachFileSystemFn(callback) {
|
||||
FS_ALL.forEach((os2) => runInFileSystem(os2, callback, false));
|
||||
}
|
||||
var counter = 0;
|
||||
function runInFileSystem(os2, callback, error) {
|
||||
describe(`<<FileSystem: ${os2}>>/${counter++}`, () => {
|
||||
beforeEach(() => initMockFileSystem(os2));
|
||||
afterEach(() => setFileSystem(new InvalidFileSystem()));
|
||||
callback(os2);
|
||||
if (error) {
|
||||
afterAll(() => {
|
||||
throw new Error(`runInFileSystem limited to ${os2}, cannot pass`);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
var runInEachFileSystem = runInEachFileSystemFn;
|
||||
runInEachFileSystem.native = (callback) => runInFileSystem(FS_NATIVE, callback, true);
|
||||
runInEachFileSystem.osX = (callback) => runInFileSystem(FS_OS_X, callback, true);
|
||||
runInEachFileSystem.unix = (callback) => runInFileSystem(FS_UNIX, callback, true);
|
||||
runInEachFileSystem.windows = (callback) => runInFileSystem(FS_WINDOWS, callback, true);
|
||||
function initMockFileSystem(os2, cwd) {
|
||||
const fs = createMockFileSystem(os2, cwd);
|
||||
setFileSystem(fs);
|
||||
monkeyPatchTypeScript(fs);
|
||||
return fs;
|
||||
}
|
||||
function createMockFileSystem(os2, cwd) {
|
||||
switch (os2) {
|
||||
case "OS/X":
|
||||
return new MockFileSystemPosix(
|
||||
/* isCaseSensitive */
|
||||
false,
|
||||
cwd
|
||||
);
|
||||
case "Unix":
|
||||
return new MockFileSystemPosix(
|
||||
/* isCaseSensitive */
|
||||
true,
|
||||
cwd
|
||||
);
|
||||
case "Windows":
|
||||
return new MockFileSystemWindows(
|
||||
/* isCaseSensitive*/
|
||||
false,
|
||||
cwd
|
||||
);
|
||||
case "Native":
|
||||
return new MockFileSystemNative(cwd);
|
||||
default:
|
||||
throw new Error("FileSystem not supported");
|
||||
}
|
||||
}
|
||||
function monkeyPatchTypeScript(fs) {
|
||||
ts.sys.fileExists = (path) => {
|
||||
const absPath = fs.resolve(path);
|
||||
return fs.exists(absPath) && fs.stat(absPath).isFile();
|
||||
};
|
||||
ts.sys.getCurrentDirectory = () => fs.pwd();
|
||||
ts.sys.getDirectories = getDirectories;
|
||||
ts.sys.readFile = fs.readFile.bind(fs);
|
||||
ts.sys.resolvePath = fs.resolve.bind(fs);
|
||||
ts.sys.writeFile = fs.writeFile.bind(fs);
|
||||
ts.sys.directoryExists = directoryExists;
|
||||
ts.sys.readDirectory = readDirectory;
|
||||
function getDirectories(path) {
|
||||
return fs.readdir(absoluteFrom(path)).filter((p3) => fs.stat(fs.resolve(path, p3)).isDirectory());
|
||||
}
|
||||
function getFileSystemEntries(path) {
|
||||
const files = [];
|
||||
const directories = [];
|
||||
const absPath = fs.resolve(path);
|
||||
const entries = fs.readdir(absPath);
|
||||
for (const entry of entries) {
|
||||
if (entry == "." || entry === "..") {
|
||||
continue;
|
||||
}
|
||||
const absPath2 = fs.resolve(path, entry);
|
||||
const stat = fs.stat(absPath2);
|
||||
if (stat.isDirectory()) {
|
||||
directories.push(absPath2);
|
||||
} else if (stat.isFile()) {
|
||||
files.push(absPath2);
|
||||
}
|
||||
}
|
||||
return { files, directories };
|
||||
}
|
||||
function realPath(path) {
|
||||
return fs.realpath(fs.resolve(path));
|
||||
}
|
||||
function directoryExists(path) {
|
||||
const absPath = fs.resolve(path);
|
||||
return fs.exists(absPath) && fs.stat(absPath).isDirectory();
|
||||
}
|
||||
const tsMatchFiles = ts.matchFiles;
|
||||
function readDirectory(path, extensions, excludes, includes, depth) {
|
||||
return tsMatchFiles(path, extensions, excludes, includes, fs.isCaseSensitive(), fs.pwd(), depth, getFileSystemEntries, realPath, directoryExists);
|
||||
}
|
||||
}
|
||||
export {
|
||||
ImportedSymbolsTracker,
|
||||
MockFileSystem,
|
||||
TypeScriptReflectionHost,
|
||||
getInitializerApiJitTransform,
|
||||
initMockFileSystem
|
||||
};
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
|
||||
import {createRequire as __cjsCompatRequire} from 'module';
|
||||
const require = __cjsCompatRequire(import.meta.url);
|
||||
|
||||
import {
|
||||
angularJitApplicationTransform
|
||||
} from "../chunk-IG22BDVK.js";
|
||||
import "../chunk-CSUVPNMK.js";
|
||||
import "../chunk-CEBE44Q5.js";
|
||||
import "../chunk-XYYEESKY.js";
|
||||
import "../chunk-G7GFT6BU.js";
|
||||
|
||||
// packages/compiler-cli/private/tooling.ts
|
||||
var GLOBAL_DEFS_FOR_TERSER = {
|
||||
ngDevMode: false,
|
||||
ngI18nClosureMode: false
|
||||
};
|
||||
var GLOBAL_DEFS_FOR_TERSER_WITH_AOT = {
|
||||
...GLOBAL_DEFS_FOR_TERSER,
|
||||
ngJitMode: false
|
||||
};
|
||||
var constructorParametersDownlevelTransform = (program, isCore = false) => {
|
||||
return angularJitApplicationTransform(program, isCore);
|
||||
};
|
||||
export {
|
||||
GLOBAL_DEFS_FOR_TERSER,
|
||||
GLOBAL_DEFS_FOR_TERSER_WITH_AOT,
|
||||
constructorParametersDownlevelTransform
|
||||
};
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import {createRequire as __cjsCompatRequire} from 'module';
|
||||
const require = __cjsCompatRequire(import.meta.url);
|
||||
|
||||
import {
|
||||
main,
|
||||
readCommandLineAndConfiguration
|
||||
} from "../../chunk-WBUBKNAO.js";
|
||||
import {
|
||||
EmitFlags
|
||||
} from "../../chunk-VO3Q626H.js";
|
||||
import "../../chunk-PW54LIP6.js";
|
||||
import "../../chunk-IG22BDVK.js";
|
||||
import "../../chunk-CSUVPNMK.js";
|
||||
import {
|
||||
setFileSystem
|
||||
} from "../../chunk-CEBE44Q5.js";
|
||||
import {
|
||||
NodeJSFileSystem
|
||||
} from "../../chunk-XYYEESKY.js";
|
||||
import "../../chunk-G7GFT6BU.js";
|
||||
|
||||
// packages/compiler-cli/src/bin/ng_xi18n.ts
|
||||
import "reflect-metadata";
|
||||
|
||||
// packages/compiler-cli/src/extract_i18n.js
|
||||
import yargs from "yargs";
|
||||
function mainXi18n(args2, consoleError = console.error) {
|
||||
const config = readXi18nCommandLineAndConfiguration(args2);
|
||||
return main(args2, consoleError, config, void 0, void 0, void 0);
|
||||
}
|
||||
function readXi18nCommandLineAndConfiguration(args2) {
|
||||
const options = {};
|
||||
const parsedArgs = yargs(args2).option("i18nFormat", { type: "string" }).option("locale", { type: "string" }).option("outFile", { type: "string" }).parseSync();
|
||||
if (parsedArgs.outFile)
|
||||
options.i18nOutFile = parsedArgs.outFile;
|
||||
if (parsedArgs.i18nFormat)
|
||||
options.i18nOutFormat = parsedArgs.i18nFormat;
|
||||
if (parsedArgs.locale)
|
||||
options.i18nOutLocale = parsedArgs.locale;
|
||||
const config = readCommandLineAndConfiguration(args2, options, [
|
||||
"outFile",
|
||||
"i18nFormat",
|
||||
"locale"
|
||||
]);
|
||||
return { ...config, emitFlags: EmitFlags.I18nBundle };
|
||||
}
|
||||
|
||||
// packages/compiler-cli/src/bin/ng_xi18n.ts
|
||||
process.title = "Angular i18n Message Extractor (ng-xi18n)";
|
||||
var args = process.argv.slice(2);
|
||||
setFileSystem(new NodeJSFileSystem());
|
||||
process.exitCode = mainXi18n(args);
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import {createRequire as __cjsCompatRequire} from 'module';
|
||||
const require = __cjsCompatRequire(import.meta.url);
|
||||
|
||||
import {
|
||||
main
|
||||
} from "../../chunk-WBUBKNAO.js";
|
||||
import "../../chunk-VO3Q626H.js";
|
||||
import "../../chunk-PW54LIP6.js";
|
||||
import "../../chunk-IG22BDVK.js";
|
||||
import "../../chunk-CSUVPNMK.js";
|
||||
import {
|
||||
setFileSystem
|
||||
} from "../../chunk-CEBE44Q5.js";
|
||||
import {
|
||||
NodeJSFileSystem
|
||||
} from "../../chunk-XYYEESKY.js";
|
||||
import "../../chunk-G7GFT6BU.js";
|
||||
|
||||
// packages/compiler-cli/src/bin/ngc.ts
|
||||
import "reflect-metadata";
|
||||
async function runNgcComamnd() {
|
||||
process.title = "Angular Compiler (ngc)";
|
||||
const args = process.argv.slice(2);
|
||||
setFileSystem(new NodeJSFileSystem());
|
||||
process.exitCode = main(args, void 0, void 0, void 0, void 0, void 0);
|
||||
}
|
||||
runNgcComamnd().catch((e) => {
|
||||
console.error(e);
|
||||
process.exitCode = 1;
|
||||
});
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
export { VERSION } from './src/version';
|
||||
export * from './src/ngtsc/transform/jit';
|
||||
export * from './src/transformers/api';
|
||||
export * from './src/transformers/entry_points';
|
||||
export * from './src/perform_compile';
|
||||
export { CompilerOptions as AngularCompilerOptions } from './src/transformers/api';
|
||||
export * from './private/tooling';
|
||||
export * from './src/ngtsc/logging';
|
||||
export * from './src/ngtsc/file_system';
|
||||
export { NgTscPlugin, PluginCompilerHost } from './src/ngtsc/tsc_plugin';
|
||||
export { NgtscProgram } from './src/ngtsc/program';
|
||||
export { OptimizeFor } from './src/ngtsc/typecheck/api';
|
||||
export { ConsoleLogger, Logger, LogLevel } from './src/ngtsc/logging';
|
||||
export { NodeJSFileSystem, absoluteFrom, FileSystem, AbsoluteFsPath, NgtscCompilerHost, getFileSystem, setFileSystem, isLocalRelativePath, } from './src/ngtsc/file_system';
|
||||
export * from './src/ngtsc/docs';
|
||||
export { isLocalCompilationDiagnostics, ErrorCode, ngErrorCode } from './src/ngtsc/diagnostics';
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* @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 { defaultLinkerPlugin } from './src/babel_plugin';
|
||||
export { createEs2015LinkerPlugin } from './src/es2015_linker_plugin';
|
||||
export default defaultLinkerPlugin;
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* @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 { types as t } from '@babel/core';
|
||||
import { AstFactory, BinaryOperator, LeadingComment, ObjectLiteralProperty, SourceMapRange, TemplateLiteral, VariableDeclarationType } from '../../../../src/ngtsc/translator/src/api/ast_factory';
|
||||
/**
|
||||
* A Babel flavored implementation of the AstFactory.
|
||||
*/
|
||||
export declare class BabelAstFactory implements AstFactory<t.Statement, t.Expression | t.SpreadElement> {
|
||||
/** The absolute path to the source file being compiled. */
|
||||
private sourceUrl;
|
||||
constructor(
|
||||
/** The absolute path to the source file being compiled. */
|
||||
sourceUrl: string);
|
||||
attachComments(statement: t.Statement | t.Expression, leadingComments: LeadingComment[]): void;
|
||||
createArrayLiteral: typeof t.arrayExpression;
|
||||
createAssignment(target: t.Expression, operator: BinaryOperator, value: t.Expression): t.Expression;
|
||||
createBinaryExpression(leftOperand: t.Expression, operator: BinaryOperator, rightOperand: t.Expression): t.Expression;
|
||||
createBlock: typeof t.blockStatement;
|
||||
createCallExpression(callee: t.Expression, args: (t.Expression | t.SpreadElement)[], pure: boolean): t.Expression;
|
||||
createConditional: typeof t.conditionalExpression;
|
||||
createElementAccess(expression: t.Expression, element: t.Expression): t.Expression;
|
||||
createExpressionStatement: typeof t.expressionStatement;
|
||||
createSpreadElement(expression: t.Expression): t.SpreadElement;
|
||||
createFunctionDeclaration(functionName: string, parameters: string[], body: t.Statement): t.Statement;
|
||||
createArrowFunctionExpression(parameters: string[], body: t.Statement | t.Expression): t.Expression;
|
||||
createFunctionExpression(functionName: string | null, parameters: string[], body: t.Statement): t.Expression;
|
||||
createIdentifier: typeof t.identifier;
|
||||
createIfStatement: typeof t.ifStatement;
|
||||
createDynamicImport(url: string | t.Expression): t.Expression;
|
||||
createLiteral(value: string | number | boolean | null | undefined): t.Expression;
|
||||
createNewExpression(expression: t.Expression, args: t.Expression[]): t.Expression;
|
||||
createObjectLiteral(properties: ObjectLiteralProperty<t.Expression>[]): t.Expression;
|
||||
createParenthesizedExpression: typeof t.parenthesizedExpression;
|
||||
createPropertyAccess(expression: t.Expression, propertyName: string): t.Expression;
|
||||
createReturnStatement(expression: t.Expression | null): t.Statement;
|
||||
createTaggedTemplate(tag: t.Expression, template: TemplateLiteral<t.Expression>): t.Expression;
|
||||
createTemplateLiteral(template: TemplateLiteral<t.Expression>): t.TemplateLiteral;
|
||||
createThrowStatement: typeof t.throwStatement;
|
||||
createTypeOfExpression(expression: t.Expression): t.Expression;
|
||||
createVoidExpression(expression: t.Expression): t.Expression;
|
||||
createUnaryExpression: typeof t.unaryExpression;
|
||||
createVariableDeclaration(variableName: string, initializer: t.Expression | null, type: VariableDeclarationType): t.Statement;
|
||||
createRegularExpressionLiteral(body: string, flags: string | null): t.Expression;
|
||||
setSourceMapRange<T extends t.Statement | t.Expression | t.TemplateElement | t.SpreadElement>(node: T, sourceMapRange: SourceMapRange | null): T;
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* @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 { types as t } from '@babel/core';
|
||||
import { AstHost, Range } from '../../../../linker';
|
||||
/**
|
||||
* This implementation of `AstHost` is able to get information from Babel AST nodes.
|
||||
*/
|
||||
export declare class BabelAstHost implements AstHost<t.Expression> {
|
||||
getSymbolName(node: t.Expression): string | null;
|
||||
isStringLiteral: typeof t.isStringLiteral;
|
||||
parseStringLiteral(str: t.Expression): string;
|
||||
isNumericLiteral: typeof t.isNumericLiteral;
|
||||
parseNumericLiteral(num: t.Expression): number;
|
||||
isBooleanLiteral(bool: t.Expression): boolean;
|
||||
parseBooleanLiteral(bool: t.Expression): boolean;
|
||||
isNull(node: t.Expression): boolean;
|
||||
isArrayLiteral: typeof t.isArrayExpression;
|
||||
parseArrayLiteral(array: t.Expression): t.Expression[];
|
||||
isObjectLiteral: typeof t.isObjectExpression;
|
||||
parseObjectLiteral(obj: t.Expression): Map<string, t.Expression>;
|
||||
isFunctionExpression(node: t.Expression): node is Extract<t.Function | t.ArrowFunctionExpression, t.Expression>;
|
||||
parseReturnValue(fn: t.Expression): t.Expression;
|
||||
parseParameters(fn: t.Expression): t.Expression[];
|
||||
isCallExpression: typeof t.isCallExpression;
|
||||
parseCallee(call: t.Expression): t.Expression;
|
||||
parseArguments(call: t.Expression): t.Expression[];
|
||||
getRange(node: t.Expression): Range;
|
||||
}
|
||||
+36
@@ -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 { NodePath, types as t } from '@babel/core';
|
||||
import { DeclarationScope } from '../../../linker';
|
||||
export type ConstantScopePath = NodePath<t.FunctionDeclaration> | NodePath<t.FunctionExpression> | NodePath<t.Program>;
|
||||
/**
|
||||
* This class represents the lexical scope of a partial declaration in Babel source code.
|
||||
*
|
||||
* Its only responsibility is to compute a reference object for the scope of shared constant
|
||||
* statements that will be generated during partial linking.
|
||||
*/
|
||||
export declare class BabelDeclarationScope implements DeclarationScope<ConstantScopePath, t.Expression> {
|
||||
private declarationScope;
|
||||
/**
|
||||
* Construct a new `BabelDeclarationScope`.
|
||||
*
|
||||
* @param declarationScope the Babel scope containing the declaration call expression.
|
||||
*/
|
||||
constructor(declarationScope: NodePath['scope']);
|
||||
/**
|
||||
* Compute the Babel `NodePath` that can be used to reference the lexical scope where any
|
||||
* shared constant statements would be inserted.
|
||||
*
|
||||
* There will only be a shared constant scope if the expression is in an ECMAScript module, or a
|
||||
* UMD module. Otherwise `null` is returned to indicate that constant statements must be emitted
|
||||
* locally to the generated linked definition, to avoid polluting the global scope.
|
||||
*
|
||||
* @param expression the expression that points to the Angular core framework import.
|
||||
*/
|
||||
getConstantScopeRef(expression: t.Expression): ConstantScopePath | null;
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* @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 { ConfigAPI, PluginObj } from '@babel/core';
|
||||
import { LinkerOptions } from '../../src/file_linker/linker_options';
|
||||
/**
|
||||
* This is the Babel plugin definition that is provided as a default export from the package, such
|
||||
* that the plugin can be used using the module specifier of the package. This is the recommended
|
||||
* way of integrating the Angular Linker into a build pipeline other than the Angular CLI.
|
||||
*
|
||||
* When the module specifier `@angular/compiler-cli/linker/babel` is used as a plugin in a Babel
|
||||
* configuration, Babel invokes this function (by means of the default export) to create the plugin
|
||||
* instance according to the provided options.
|
||||
*
|
||||
* The linker plugin that is created uses the native NodeJS filesystem APIs to interact with the
|
||||
* filesystem. Any logging output is printed to the console.
|
||||
*
|
||||
* @param api Provides access to the Babel environment that is configuring this plugin.
|
||||
* @param options The plugin options that have been configured.
|
||||
*/
|
||||
export declare function defaultLinkerPlugin(api: ConfigAPI, options: Partial<LinkerOptions>): PluginObj;
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* @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 { PluginObj } from '@babel/core';
|
||||
import { LinkerPluginOptions } from './linker_plugin_options';
|
||||
/**
|
||||
* Create a Babel plugin that visits the program, identifying and linking partial declarations.
|
||||
*
|
||||
* The plugin delegates most of its work to a generic `FileLinker` for each file (`t.Program` in
|
||||
* Babel) that is visited.
|
||||
*/
|
||||
export declare function createEs2015LinkerPlugin({ fileSystem, logger, ...options }: LinkerPluginOptions): PluginObj;
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* @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 { LinkerOptions } from '../..';
|
||||
import { ReadonlyFileSystem } from '../../../src/ngtsc/file_system/src/types';
|
||||
import { Logger } from '../../../src/ngtsc/logging';
|
||||
export interface LinkerPluginOptions extends Partial<LinkerOptions> {
|
||||
/**
|
||||
* File-system, used to load up the input source-map and content.
|
||||
*/
|
||||
fileSystem: ReadonlyFileSystem;
|
||||
/**
|
||||
* Logger used by the linker.
|
||||
*/
|
||||
logger: Logger;
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* @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 { AstHost, Range } from './src/ast/ast_host';
|
||||
export { assert } from './src/ast/utils';
|
||||
export { FatalLinkerError, isFatalLinkerError } from './src/fatal_linker_error';
|
||||
export { DeclarationScope } from './src/file_linker/declaration_scope';
|
||||
export { FileLinker } from './src/file_linker/file_linker';
|
||||
export { LinkerEnvironment } from './src/file_linker/linker_environment';
|
||||
export { DEFAULT_LINKER_OPTIONS, LinkerOptions } from './src/file_linker/linker_options';
|
||||
export { needsLinking } from './src/file_linker/needs_linking';
|
||||
+114
@@ -0,0 +1,114 @@
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
/**
|
||||
* An abstraction for getting information from an AST while being agnostic to the underlying AST
|
||||
* implementation.
|
||||
*/
|
||||
export interface AstHost<TExpression> {
|
||||
/**
|
||||
* Get the name of the symbol represented by the given expression node, or `null` if it is not a
|
||||
* symbol.
|
||||
*/
|
||||
getSymbolName(node: TExpression): string | null;
|
||||
/**
|
||||
* Return `true` if the given expression is a string literal, or false otherwise.
|
||||
*/
|
||||
isStringLiteral(node: TExpression): boolean;
|
||||
/**
|
||||
* Parse the string value from the given expression, or throw if it is not a string literal.
|
||||
*/
|
||||
parseStringLiteral(str: TExpression): string;
|
||||
/**
|
||||
* Return `true` if the given expression is a numeric literal, or false otherwise.
|
||||
*/
|
||||
isNumericLiteral(node: TExpression): boolean;
|
||||
/**
|
||||
* Parse the numeric value from the given expression, or throw if it is not a numeric literal.
|
||||
*/
|
||||
parseNumericLiteral(num: TExpression): number;
|
||||
/**
|
||||
* Return `true` if the given expression can be considered a boolean literal, or false otherwise.
|
||||
*
|
||||
* Note that this should also cover the special case of some minified code where `true` and
|
||||
* `false` are replaced by `!0` and `!1` respectively.
|
||||
*/
|
||||
isBooleanLiteral(node: TExpression): boolean;
|
||||
/**
|
||||
* Parse the boolean value from the given expression, or throw if it is not a boolean literal.
|
||||
*
|
||||
* Note that this should also cover the special case of some minified code where `true` and
|
||||
* `false` are replaced by `!0` and `!1` respectively.
|
||||
*/
|
||||
parseBooleanLiteral(bool: TExpression): boolean;
|
||||
/**
|
||||
* Returns `true` if the value corresponds to `null`.
|
||||
*/
|
||||
isNull(node: TExpression): boolean;
|
||||
/**
|
||||
* Return `true` if the given expression is an array literal, or false otherwise.
|
||||
*/
|
||||
isArrayLiteral(node: TExpression): boolean;
|
||||
/**
|
||||
* Parse an array of expressions from the given expression, or throw if it is not an array
|
||||
* literal.
|
||||
*/
|
||||
parseArrayLiteral(array: TExpression): TExpression[];
|
||||
/**
|
||||
* Return `true` if the given expression is an object literal, or false otherwise.
|
||||
*/
|
||||
isObjectLiteral(node: TExpression): boolean;
|
||||
/**
|
||||
* Parse the given expression into a map of object property names to property expressions, or
|
||||
* throw if it is not an object literal.
|
||||
*/
|
||||
parseObjectLiteral(obj: TExpression): Map<string, TExpression>;
|
||||
/**
|
||||
* Return `true` if the given expression is a function, or false otherwise.
|
||||
*/
|
||||
isFunctionExpression(node: TExpression): boolean;
|
||||
/**
|
||||
* Compute the "value" of a function expression by parsing its body for a single `return`
|
||||
* statement, extracting the returned expression, or throw if it is not possible.
|
||||
*/
|
||||
parseReturnValue(fn: TExpression): TExpression;
|
||||
/**
|
||||
* Returns the parameter expressions for the function, or throw if it is not a function.
|
||||
*/
|
||||
parseParameters(fn: TExpression): TExpression[];
|
||||
/**
|
||||
* Return true if the given expression is a call expression, or false otherwise.
|
||||
*/
|
||||
isCallExpression(node: TExpression): boolean;
|
||||
/**
|
||||
* Returns the expression that is called in the provided call expression, or throw if it is not
|
||||
* a call expression.
|
||||
*/
|
||||
parseCallee(call: TExpression): TExpression;
|
||||
/**
|
||||
* Returns the argument expressions for the provided call expression, or throw if it is not
|
||||
* a call expression.
|
||||
*/
|
||||
parseArguments(call: TExpression): TExpression[];
|
||||
/**
|
||||
* Compute the location range of the expression in the source file, to be used for source-mapping.
|
||||
*/
|
||||
getRange(node: TExpression): Range;
|
||||
}
|
||||
/**
|
||||
* The location of the start and end of an expression in the original source file.
|
||||
*/
|
||||
export interface Range {
|
||||
/** 0-based character position of the range start in the source file text. */
|
||||
startPos: number;
|
||||
/** 0-based line index of the range start in the source file text. */
|
||||
startLine: number;
|
||||
/** 0-based column position of the range start in the source file text. */
|
||||
startCol: number;
|
||||
/** 0-based character position of the range end in the source file text. */
|
||||
endPos: number;
|
||||
}
|
||||
+208
@@ -0,0 +1,208 @@
|
||||
/**
|
||||
* @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 o from '@angular/compiler';
|
||||
import { AstHost, Range } from './ast_host';
|
||||
/**
|
||||
* Represents only those types in `T` that are object types.
|
||||
*
|
||||
* Note: Excluding `Array` types as we consider object literals are "objects"
|
||||
* in the AST.
|
||||
*/
|
||||
type ObjectType<T> = T extends Array<any> ? never : T extends Record<string, any> ? T : never;
|
||||
/**
|
||||
* Represents the value type of an object literal.
|
||||
*/
|
||||
type ObjectValueType<T> = T extends Record<string, infer R> ? R : never;
|
||||
/**
|
||||
* Represents the value type of an array literal.
|
||||
*/
|
||||
type ArrayValueType<T> = T extends Array<infer R> ? R : never;
|
||||
/**
|
||||
* Ensures that `This` has its generic type `Actual` conform to the expected generic type in
|
||||
* `Expected`, to disallow calling a method if the generic type does not conform.
|
||||
*/
|
||||
type ConformsTo<This, Actual, Expected> = Actual extends Expected ? This : never;
|
||||
/**
|
||||
* Represents only the string keys of type `T`.
|
||||
*/
|
||||
type PropertyKey<T> = keyof T & string;
|
||||
/**
|
||||
* This helper class wraps an object expression along with an `AstHost` object, exposing helper
|
||||
* methods that make it easier to extract the properties of the object.
|
||||
*
|
||||
* The generic `T` is used as reference type of the expected structure that is represented by this
|
||||
* object. It does not achieve full type-safety for the provided operations in correspondence with
|
||||
* `T`; its main goal is to provide references to a documented type and ensure that the properties
|
||||
* that are read from the object are present.
|
||||
*
|
||||
* Unfortunately, the generic types are unable to prevent reading an optional property from the
|
||||
* object without first having called `has` to ensure that the property exists. This is one example
|
||||
* of where full type-safety is not achieved.
|
||||
*/
|
||||
export declare class AstObject<T extends object, TExpression> {
|
||||
readonly expression: TExpression;
|
||||
private obj;
|
||||
private host;
|
||||
/**
|
||||
* Create a new `AstObject` from the given `expression` and `host`.
|
||||
*/
|
||||
static parse<T extends object, TExpression>(expression: TExpression, host: AstHost<TExpression>): AstObject<T, TExpression>;
|
||||
private constructor();
|
||||
/**
|
||||
* Returns true if the object has a property called `propertyName`.
|
||||
*/
|
||||
has(propertyName: PropertyKey<T>): boolean;
|
||||
/**
|
||||
* Returns the number value of the property called `propertyName`.
|
||||
*
|
||||
* Throws an error if there is no such property or the property is not a number.
|
||||
*/
|
||||
getNumber<K extends PropertyKey<T>>(this: ConformsTo<this, T[K], number>, propertyName: K): number;
|
||||
/**
|
||||
* Returns the string value of the property called `propertyName`.
|
||||
*
|
||||
* Throws an error if there is no such property or the property is not a string.
|
||||
*/
|
||||
getString<K extends PropertyKey<T>>(this: ConformsTo<this, T[K], string>, propertyName: K): string;
|
||||
/**
|
||||
* Returns the boolean value of the property called `propertyName`.
|
||||
*
|
||||
* Throws an error if there is no such property or the property is not a boolean.
|
||||
*/
|
||||
getBoolean<K extends PropertyKey<T>>(this: ConformsTo<this, T[K], boolean>, propertyName: K): boolean;
|
||||
/**
|
||||
* Returns the nested `AstObject` parsed from the property called `propertyName`.
|
||||
*
|
||||
* Throws an error if there is no such property or the property is not an object.
|
||||
*/
|
||||
getObject<K extends PropertyKey<T>>(this: ConformsTo<this, T[K], object>, propertyName: K): AstObject<ObjectType<T[K]>, TExpression>;
|
||||
/**
|
||||
* Returns an array of `AstValue` objects parsed from the property called `propertyName`.
|
||||
*
|
||||
* Throws an error if there is no such property or the property is not an array.
|
||||
*/
|
||||
getArray<K extends PropertyKey<T>>(this: ConformsTo<this, T[K], unknown[]>, propertyName: K): AstValue<ArrayValueType<T[K]>, TExpression>[];
|
||||
/**
|
||||
* Returns a `WrappedNodeExpr` object that wraps the expression at the property called
|
||||
* `propertyName`.
|
||||
*
|
||||
* Throws an error if there is no such property.
|
||||
*/
|
||||
getOpaque(propertyName: PropertyKey<T>): o.WrappedNodeExpr<TExpression>;
|
||||
/**
|
||||
* Returns the raw `TExpression` value of the property called `propertyName`.
|
||||
*
|
||||
* Throws an error if there is no such property.
|
||||
*/
|
||||
getNode(propertyName: PropertyKey<T>): TExpression;
|
||||
/**
|
||||
* Returns an `AstValue` that wraps the value of the property called `propertyName`.
|
||||
*
|
||||
* Throws an error if there is no such property.
|
||||
*/
|
||||
getValue<K extends PropertyKey<T>>(propertyName: K): AstValue<T[K], TExpression>;
|
||||
/**
|
||||
* Converts the AstObject to a raw JavaScript object, mapping each property value (as an
|
||||
* `AstValue`) to the generic type (`T`) via the `mapper` function.
|
||||
*/
|
||||
toLiteral<V>(mapper: (value: AstValue<ObjectValueType<T>, TExpression>, key: string) => V): Record<string, V>;
|
||||
/**
|
||||
* Converts the AstObject to a JavaScript Map, mapping each property value (as an
|
||||
* `AstValue`) to the generic type (`T`) via the `mapper` function.
|
||||
*/
|
||||
toMap<V>(mapper: (value: AstValue<ObjectValueType<T>, TExpression>) => V): Map<string, V>;
|
||||
private getRequiredProperty;
|
||||
}
|
||||
/**
|
||||
* This helper class wraps an `expression`, exposing methods that use the `host` to give
|
||||
* access to the underlying value of the wrapped expression.
|
||||
*
|
||||
* The generic `T` is used as reference type of the expected type that is represented by this value.
|
||||
* It does not achieve full type-safety for the provided operations in correspondence with `T`; its
|
||||
* main goal is to provide references to a documented type.
|
||||
*/
|
||||
export declare class AstValue<T, TExpression> {
|
||||
readonly expression: TExpression;
|
||||
private host;
|
||||
/** Type brand that ensures that the `T` type is respected for assignability. */
|
||||
ɵtypeBrand: T;
|
||||
constructor(expression: TExpression, host: AstHost<TExpression>);
|
||||
/**
|
||||
* Get the name of the symbol represented by the given expression node, or `null` if it is not a
|
||||
* symbol.
|
||||
*/
|
||||
getSymbolName(): string | null;
|
||||
/**
|
||||
* Is this value a number?
|
||||
*/
|
||||
isNumber(): boolean;
|
||||
/**
|
||||
* Parse the number from this value, or error if it is not a number.
|
||||
*/
|
||||
getNumber(this: ConformsTo<this, T, number>): number;
|
||||
/**
|
||||
* Is this value a string?
|
||||
*/
|
||||
isString(): boolean;
|
||||
/**
|
||||
* Parse the string from this value, or error if it is not a string.
|
||||
*/
|
||||
getString(this: ConformsTo<this, T, string>): string;
|
||||
/**
|
||||
* Is this value a boolean?
|
||||
*/
|
||||
isBoolean(): boolean;
|
||||
/**
|
||||
* Parse the boolean from this value, or error if it is not a boolean.
|
||||
*/
|
||||
getBoolean(this: ConformsTo<this, T, boolean>): boolean;
|
||||
/**
|
||||
* Is this value an object literal?
|
||||
*/
|
||||
isObject(): boolean;
|
||||
/**
|
||||
* Parse this value into an `AstObject`, or error if it is not an object literal.
|
||||
*/
|
||||
getObject(this: ConformsTo<this, T, object>): AstObject<ObjectType<T>, TExpression>;
|
||||
/**
|
||||
* Is this value an array literal?
|
||||
*/
|
||||
isArray(): boolean;
|
||||
/** Whether the value is explicitly set to `null`. */
|
||||
isNull(): boolean;
|
||||
/**
|
||||
* Parse this value into an array of `AstValue` objects, or error if it is not an array literal.
|
||||
*/
|
||||
getArray(this: ConformsTo<this, T, unknown[]>): AstValue<ArrayValueType<T>, TExpression>[];
|
||||
/**
|
||||
* Is this value a function expression?
|
||||
*/
|
||||
isFunction(): boolean;
|
||||
/**
|
||||
* Extract the return value as an `AstValue` from this value as a function expression, or error if
|
||||
* it is not a function expression.
|
||||
*/
|
||||
getFunctionReturnValue<R>(this: ConformsTo<this, T, Function>): AstValue<R, TExpression>;
|
||||
/**
|
||||
* Extract the parameters from this value as a function expression, or error if it is not a
|
||||
* function expression.
|
||||
*/
|
||||
getFunctionParameters<R>(this: ConformsTo<this, T, Function>): AstValue<R, TExpression>[];
|
||||
isCallExpression(): boolean;
|
||||
getCallee(): AstValue<unknown, TExpression>;
|
||||
getArguments(): AstValue<unknown, TExpression>[];
|
||||
/**
|
||||
* Return the `TExpression` of this value wrapped in a `WrappedNodeExpr`.
|
||||
*/
|
||||
getOpaque(): o.WrappedNodeExpr<TExpression>;
|
||||
/**
|
||||
* Get the range of the location of this value in the original source.
|
||||
*/
|
||||
getRange(): Range;
|
||||
}
|
||||
export {};
|
||||
Generated
Vendored
+39
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* @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 ts from 'typescript';
|
||||
import { AstHost, Range } from '../ast_host';
|
||||
/**
|
||||
* This implementation of `AstHost` is able to get information from TypeScript AST nodes.
|
||||
*
|
||||
* This host is not actually used at runtime in the current code.
|
||||
*
|
||||
* It is implemented here to ensure that the `AstHost` abstraction is not unfairly skewed towards
|
||||
* the Babel implementation. It could also provide a basis for a 3rd TypeScript compiler plugin to
|
||||
* do linking in the future.
|
||||
*/
|
||||
export declare class TypeScriptAstHost implements AstHost<ts.Expression> {
|
||||
getSymbolName(node: ts.Expression): string | null;
|
||||
isStringLiteral: typeof ts.isStringLiteral;
|
||||
parseStringLiteral(str: ts.Expression): string;
|
||||
isNull(node: ts.Expression): boolean;
|
||||
isNumericLiteral: typeof ts.isNumericLiteral;
|
||||
parseNumericLiteral(num: ts.Expression): number;
|
||||
isBooleanLiteral(node: ts.Expression): boolean;
|
||||
parseBooleanLiteral(bool: ts.Expression): boolean;
|
||||
isArrayLiteral: typeof ts.isArrayLiteralExpression;
|
||||
parseArrayLiteral(array: ts.Expression): ts.Expression[];
|
||||
isObjectLiteral: typeof ts.isObjectLiteralExpression;
|
||||
parseObjectLiteral(obj: ts.Expression): Map<string, ts.Expression>;
|
||||
isFunctionExpression(node: ts.Expression): node is ts.FunctionExpression | ts.ArrowFunction;
|
||||
parseReturnValue(fn: ts.Expression): ts.Expression;
|
||||
parseParameters(fn: ts.Expression): ts.Expression[];
|
||||
isCallExpression: typeof ts.isCallExpression;
|
||||
parseCallee(call: ts.Expression): ts.Expression;
|
||||
parseArguments(call: ts.Expression): ts.Expression[];
|
||||
getRange(node: ts.Expression): Range;
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
/**
|
||||
* Assert that the given `node` is of the type guarded by the `predicate` function.
|
||||
*/
|
||||
export declare function assert<T, K extends T>(node: T, predicate: (node: T) => node is K, expected: string): asserts node is K;
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
/**
|
||||
* An unrecoverable error during linking.
|
||||
*/
|
||||
export declare class FatalLinkerError extends Error {
|
||||
node: unknown;
|
||||
readonly type = "FatalLinkerError";
|
||||
/**
|
||||
* Create a new FatalLinkerError.
|
||||
*
|
||||
* @param node The AST node where the error occurred.
|
||||
* @param message A description of the error.
|
||||
*/
|
||||
constructor(node: unknown, message: string);
|
||||
}
|
||||
/**
|
||||
* Whether the given object `e` is a FatalLinkerError.
|
||||
*/
|
||||
export declare function isFatalLinkerError(e: any): e is FatalLinkerError;
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
/**
|
||||
* This interface represents the lexical scope of a partial declaration in the source code.
|
||||
*
|
||||
* For example, if you had the following code:
|
||||
*
|
||||
* ```ts
|
||||
* function foo() {
|
||||
* function bar () {
|
||||
* ɵɵngDeclareDirective({...});
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* The `DeclarationScope` of the `ɵɵngDeclareDirective()` call is the body of the `bar()` function.
|
||||
*
|
||||
* The `FileLinker` uses this object to identify the lexical scope of any constant statements that
|
||||
* might be generated by the linking process (i.e. where the `ConstantPool` lives for a set of
|
||||
* partial linkers).
|
||||
*/
|
||||
export interface DeclarationScope<TSharedConstantScope, TExpression> {
|
||||
/**
|
||||
* Get a `TSharedConstantScope` object that can be used to reference the lexical scope where any
|
||||
* shared constant statements would be inserted.
|
||||
*
|
||||
* This object is generic because different AST implementations will need different
|
||||
* `TConstantScope` types to be able to insert shared constant statements. For example in Babel
|
||||
* this would be a `NodePath` object; in TS it would just be a `Node` object.
|
||||
*
|
||||
* If it is not possible to find such a shared scope, then constant statements will be wrapped up
|
||||
* with their generated linked definition expression, in the form of an IIFE.
|
||||
*
|
||||
* @param expression the expression that points to the Angular core framework import.
|
||||
* @returns a reference to a reference object for where the shared constant statements will be
|
||||
* inserted, or `null` if it is not possible to have a shared scope.
|
||||
*/
|
||||
getConstantScopeRef(expression: TExpression): TSharedConstantScope | null;
|
||||
}
|
||||
Generated
Vendored
+38
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* @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 { ConstantPool } from '@angular/compiler';
|
||||
import { AstFactory } from '../../../../src/ngtsc/translator';
|
||||
import { LinkedDefinition } from '../partial_linkers/partial_linker';
|
||||
import { Translator } from '../translator';
|
||||
/**
|
||||
* This class represents (from the point of view of the `FileLinker`) the scope in which
|
||||
* statements and expressions related to a linked partial declaration will be emitted.
|
||||
*
|
||||
* It holds a copy of a `ConstantPool` that is used to capture any constant statements that need to
|
||||
* be emitted in this context.
|
||||
*
|
||||
* This implementation will emit the definition and the constant statements separately.
|
||||
*/
|
||||
export declare class EmitScope<TStatement, TExpression> {
|
||||
protected readonly ngImport: TExpression;
|
||||
protected readonly translator: Translator<TStatement, TExpression>;
|
||||
private readonly factory;
|
||||
readonly constantPool: ConstantPool;
|
||||
constructor(ngImport: TExpression, translator: Translator<TStatement, TExpression>, factory: AstFactory<TStatement, TExpression>);
|
||||
/**
|
||||
* Translate the given Output AST definition expression into a generic `TExpression`.
|
||||
*
|
||||
* Use a `LinkerImportGenerator` to handle any imports in the definition.
|
||||
*/
|
||||
translateDefinition(definition: LinkedDefinition): TExpression;
|
||||
/**
|
||||
* Return any constant statements that are shared between all uses of this `EmitScope`.
|
||||
*/
|
||||
getConstantStatements(): TStatement[];
|
||||
private wrapInIifeWithStatements;
|
||||
}
|
||||
Generated
Vendored
+28
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
* @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 { LinkedDefinition } from '../partial_linkers/partial_linker';
|
||||
import { EmitScope } from './emit_scope';
|
||||
/**
|
||||
* This class is a specialization of the `EmitScope` class that is designed for the situation where
|
||||
* there is no clear shared scope for constant statements. In this case they are bundled with the
|
||||
* translated definition and will be emitted into an IIFE.
|
||||
*/
|
||||
export declare class LocalEmitScope<TStatement, TExpression> extends EmitScope<TStatement, TExpression> {
|
||||
/**
|
||||
* Translate the given Output AST definition expression into a generic `TExpression`.
|
||||
*
|
||||
* Merges the `ConstantPool` statements with the definition statements when generating the
|
||||
* definition expression. This means that `ConstantPool` statements will be emitted into an IIFE.
|
||||
*/
|
||||
translateDefinition(definition: LinkedDefinition): TExpression;
|
||||
/**
|
||||
* It is not valid to call this method, since there will be no shared constant statements - they
|
||||
* are already emitted in the IIFE alongside the translated definition.
|
||||
*/
|
||||
getConstantStatements(): TStatement[];
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
import { DeclarationScope } from './declaration_scope';
|
||||
import { LinkerEnvironment } from './linker_environment';
|
||||
import { AbsoluteFsPath } from '../../../src/ngtsc/file_system/src/types';
|
||||
export declare const NO_STATEMENTS: Readonly<any[]>;
|
||||
/**
|
||||
* This class is responsible for linking all the partial declarations found in a single file.
|
||||
*/
|
||||
export declare class FileLinker<TConstantScope, TStatement, TExpression> {
|
||||
private linkerEnvironment;
|
||||
private linkerSelector;
|
||||
private emitScopes;
|
||||
constructor(linkerEnvironment: LinkerEnvironment<TStatement, TExpression>, sourceUrl: AbsoluteFsPath, code: string);
|
||||
/**
|
||||
* Return true if the given callee name matches a partial declaration that can be linked.
|
||||
*/
|
||||
isPartialDeclaration(calleeName: string): boolean;
|
||||
/**
|
||||
* Link the metadata extracted from the args of a call to a partial declaration function.
|
||||
*
|
||||
* The `declarationScope` is used to determine the scope and strategy of emission of the linked
|
||||
* definition and any shared constant statements.
|
||||
*
|
||||
* @param declarationFn the name of the function used to declare the partial declaration - e.g.
|
||||
* `ɵɵngDeclareDirective`.
|
||||
* @param args the arguments passed to the declaration function, should be a single object that
|
||||
* corresponds to the `R3DeclareDirectiveMetadata` or `R3DeclareComponentMetadata` interfaces.
|
||||
* @param declarationScope the scope that contains this call to the declaration function.
|
||||
*/
|
||||
linkPartialDeclaration(declarationFn: string, args: TExpression[], declarationScope: DeclarationScope<TConstantScope, TExpression>): TExpression;
|
||||
/**
|
||||
* Return all the shared constant statements and their associated constant scope references, so
|
||||
* that they can be inserted into the source code.
|
||||
*/
|
||||
getConstantStatements(): {
|
||||
constantScope: TConstantScope;
|
||||
statements: TStatement[];
|
||||
}[];
|
||||
private getEmitScope;
|
||||
}
|
||||
+18
@@ -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 { AbsoluteFsPath } from '../../../src/ngtsc/file_system/src/types';
|
||||
import { SourceFile, SourceFileLoader } from '../../../src/ngtsc/sourcemaps';
|
||||
/**
|
||||
* A function that will return a `SourceFile` object (or null) for the current file being linked.
|
||||
*/
|
||||
export type GetSourceFileFn = () => SourceFile | null;
|
||||
/**
|
||||
* Create a `GetSourceFileFn` that will return the `SourceFile` being linked or `null`, if not
|
||||
* available.
|
||||
*/
|
||||
export declare function createGetSourceFile(sourceUrl: AbsoluteFsPath, code: string, loader: SourceFileLoader | null): GetSourceFileFn;
|
||||
Generated
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* @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 { ReadonlyFileSystem } from '../../../src/ngtsc/file_system/src/types';
|
||||
import { Logger } from '../../../src/ngtsc/logging';
|
||||
import { SourceFileLoader } from '../../../src/ngtsc/sourcemaps';
|
||||
import { AstFactory } from '../../../src/ngtsc/translator';
|
||||
import { AstHost } from '../ast/ast_host';
|
||||
import { LinkerOptions } from './linker_options';
|
||||
import { Translator } from './translator';
|
||||
export declare class LinkerEnvironment<TStatement, TExpression> {
|
||||
readonly fileSystem: ReadonlyFileSystem;
|
||||
readonly logger: Logger;
|
||||
readonly host: AstHost<TExpression>;
|
||||
readonly factory: AstFactory<TStatement, TExpression>;
|
||||
readonly options: LinkerOptions;
|
||||
readonly translator: Translator<TStatement, TExpression>;
|
||||
readonly sourceFileLoader: SourceFileLoader | null;
|
||||
private constructor();
|
||||
static create<TStatement, TExpression>(fileSystem: ReadonlyFileSystem, logger: Logger, host: AstHost<TExpression>, factory: AstFactory<TStatement, TExpression>, options: Partial<LinkerOptions>): LinkerEnvironment<TStatement, TExpression>;
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
/**
|
||||
* Options to configure the linking behavior.
|
||||
*/
|
||||
export interface LinkerOptions {
|
||||
/**
|
||||
* Whether to use source-mapping to compute the original source for external templates.
|
||||
* The default is `true`.
|
||||
*/
|
||||
sourceMapping: boolean;
|
||||
/**
|
||||
* This option tells the linker to generate information used by a downstream JIT compiler.
|
||||
*
|
||||
* Specifically, in JIT mode, NgModule definitions must describe the `declarations`, `imports`,
|
||||
* `exports`, etc, which are otherwise not needed.
|
||||
*/
|
||||
linkerJitMode: boolean;
|
||||
/**
|
||||
* How to handle a situation where a partial declaration matches none of the supported
|
||||
* partial-linker versions.
|
||||
*
|
||||
* - `error` - the version mismatch is a fatal error.
|
||||
* - `warn` - a warning is sent to the logger but the most recent partial-linker
|
||||
* will attempt to process the declaration anyway.
|
||||
* - `ignore` - the most recent partial-linker will, silently, attempt to process
|
||||
* the declaration.
|
||||
*
|
||||
* The default is `error`.
|
||||
*/
|
||||
unknownDeclarationVersionHandling: 'ignore' | 'warn' | 'error';
|
||||
}
|
||||
/**
|
||||
* The default linker options to use if properties are not provided.
|
||||
*/
|
||||
export declare const DEFAULT_LINKER_OPTIONS: LinkerOptions;
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
/**
|
||||
* Determines if the provided source file may need to be processed by the linker, i.e. whether it
|
||||
* potentially contains any declarations. If true is returned, then the source file should be
|
||||
* processed by the linker as it may contain declarations that need to be fully compiled. If false
|
||||
* is returned, parsing and processing of the source file can safely be skipped to improve
|
||||
* performance.
|
||||
*
|
||||
* This function may return true even for source files that don't actually contain any declarations
|
||||
* that need to be compiled.
|
||||
*
|
||||
* @param path the absolute path of the source file for which to determine whether linking may be
|
||||
* needed.
|
||||
* @param source the source file content as a string.
|
||||
* @returns whether the source file may contain declarations that need to be linked.
|
||||
*/
|
||||
export declare function needsLinking(path: string, source: string): boolean;
|
||||
Generated
Vendored
+16
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* @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 { ConstantPool, R3DeclareClassMetadataAsync } from '@angular/compiler';
|
||||
import { AstObject } from '../../ast/ast_value';
|
||||
import { LinkedDefinition, PartialLinker } from './partial_linker';
|
||||
/**
|
||||
* A `PartialLinker` that is designed to process `ɵɵngDeclareClassMetadataAsync()` call expressions.
|
||||
*/
|
||||
export declare class PartialClassMetadataAsyncLinkerVersion1<TExpression> implements PartialLinker<TExpression> {
|
||||
linkPartialDeclaration(constantPool: ConstantPool, metaObj: AstObject<R3DeclareClassMetadataAsync, TExpression>): LinkedDefinition;
|
||||
}
|
||||
Generated
Vendored
+20
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* @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 { ConstantPool, R3ClassMetadata, R3DeclareClassMetadata, R3PartialDeclaration } from '@angular/compiler';
|
||||
import { AstObject } from '../../ast/ast_value';
|
||||
import { LinkedDefinition, PartialLinker } from './partial_linker';
|
||||
/**
|
||||
* A `PartialLinker` that is designed to process `ɵɵngDeclareClassMetadata()` call expressions.
|
||||
*/
|
||||
export declare class PartialClassMetadataLinkerVersion1<TExpression> implements PartialLinker<TExpression> {
|
||||
linkPartialDeclaration(constantPool: ConstantPool, metaObj: AstObject<R3PartialDeclaration, TExpression>): LinkedDefinition;
|
||||
}
|
||||
/**
|
||||
* Derives the `R3ClassMetadata` structure from the AST object.
|
||||
*/
|
||||
export declare function toR3ClassMetadata<TExpression>(metaObj: AstObject<R3DeclareClassMetadata, TExpression>): R3ClassMetadata;
|
||||
Generated
Vendored
+33
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* @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 { ConstantPool, R3PartialDeclaration } from '@angular/compiler';
|
||||
import { AstObject } from '../../ast/ast_value';
|
||||
import { GetSourceFileFn } from '../get_source_file';
|
||||
import { LinkedDefinition, PartialLinker } from './partial_linker';
|
||||
import { AbsoluteFsPath } from '../../../../src/ngtsc/file_system/src/types';
|
||||
/**
|
||||
* A `PartialLinker` that is designed to process `ɵɵngDeclareComponent()` call expressions.
|
||||
*/
|
||||
export declare class PartialComponentLinkerVersion1<TStatement, TExpression> implements PartialLinker<TExpression> {
|
||||
private readonly getSourceFile;
|
||||
private sourceUrl;
|
||||
private code;
|
||||
constructor(getSourceFile: GetSourceFileFn, sourceUrl: AbsoluteFsPath, code: string);
|
||||
linkPartialDeclaration(constantPool: ConstantPool, metaObj: AstObject<R3PartialDeclaration, TExpression>, version: string): LinkedDefinition;
|
||||
/**
|
||||
* This function derives the `R3ComponentMetadata` from the provided AST object.
|
||||
*/
|
||||
private toR3ComponentMeta;
|
||||
/**
|
||||
* Update the range to remove the start and end chars, which should be quotes around the template.
|
||||
*/
|
||||
private getTemplateInfo;
|
||||
private tryExternalTemplate;
|
||||
private templateFromPartialCode;
|
||||
private createR3ComponentDeferMetadata;
|
||||
}
|
||||
Generated
Vendored
+26
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* @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 { ConstantPool, ParseSourceSpan, R3DeclareDirectiveMetadata, R3DirectiveMetadata, R3PartialDeclaration } from '@angular/compiler';
|
||||
import { Range } from '../../ast/ast_host';
|
||||
import { AstObject } from '../../ast/ast_value';
|
||||
import { LinkedDefinition, PartialLinker } from './partial_linker';
|
||||
import { AbsoluteFsPath } from '../../../../src/ngtsc/file_system/src/types';
|
||||
/**
|
||||
* A `PartialLinker` that is designed to process `ɵɵngDeclareDirective()` call expressions.
|
||||
*/
|
||||
export declare class PartialDirectiveLinkerVersion1<TExpression> implements PartialLinker<TExpression> {
|
||||
private sourceUrl;
|
||||
private code;
|
||||
constructor(sourceUrl: AbsoluteFsPath, code: string);
|
||||
linkPartialDeclaration(constantPool: ConstantPool, metaObj: AstObject<R3PartialDeclaration, TExpression>, version: string): LinkedDefinition;
|
||||
}
|
||||
/**
|
||||
* Derives the `R3DirectiveMetadata` structure from the AST object.
|
||||
*/
|
||||
export declare function toR3DirectiveMeta<TExpression>(metaObj: AstObject<R3DeclareDirectiveMetadata, TExpression>, code: string, sourceUrl: AbsoluteFsPath, version: string): R3DirectiveMetadata;
|
||||
export declare function createSourceSpan(range: Range, code: string, sourceUrl: string): ParseSourceSpan;
|
||||
Generated
Vendored
+20
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* @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 { ConstantPool, R3DeclareFactoryMetadata, R3FactoryMetadata, R3PartialDeclaration } from '@angular/compiler';
|
||||
import { AstObject } from '../../ast/ast_value';
|
||||
import { LinkedDefinition, PartialLinker } from './partial_linker';
|
||||
/**
|
||||
* A `PartialLinker` that is designed to process `ɵɵngDeclareFactory()` call expressions.
|
||||
*/
|
||||
export declare class PartialFactoryLinkerVersion1<TExpression> implements PartialLinker<TExpression> {
|
||||
linkPartialDeclaration(constantPool: ConstantPool, metaObj: AstObject<R3PartialDeclaration, TExpression>): LinkedDefinition;
|
||||
}
|
||||
/**
|
||||
* Derives the `R3FactoryMetadata` structure from the AST object.
|
||||
*/
|
||||
export declare function toR3FactoryMeta<TExpression>(metaObj: AstObject<R3DeclareFactoryMetadata, TExpression>): R3FactoryMetadata;
|
||||
Generated
Vendored
+20
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* @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 { ConstantPool, R3DeclareInjectableMetadata, R3InjectableMetadata, R3PartialDeclaration } from '@angular/compiler';
|
||||
import { AstObject } from '../../ast/ast_value';
|
||||
import { LinkedDefinition, PartialLinker } from './partial_linker';
|
||||
/**
|
||||
* A `PartialLinker` that is designed to process `ɵɵngDeclareInjectable()` call expressions.
|
||||
*/
|
||||
export declare class PartialInjectableLinkerVersion1<TExpression> implements PartialLinker<TExpression> {
|
||||
linkPartialDeclaration(constantPool: ConstantPool, metaObj: AstObject<R3PartialDeclaration, TExpression>): LinkedDefinition;
|
||||
}
|
||||
/**
|
||||
* Derives the `R3InjectableMetadata` structure from the AST object.
|
||||
*/
|
||||
export declare function toR3InjectableMeta<TExpression>(metaObj: AstObject<R3DeclareInjectableMetadata, TExpression>): R3InjectableMetadata;
|
||||
Generated
Vendored
+20
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* @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 { ConstantPool, R3DeclareInjectorMetadata, R3InjectorMetadata, R3PartialDeclaration } from '@angular/compiler';
|
||||
import { AstObject } from '../../ast/ast_value';
|
||||
import { LinkedDefinition, PartialLinker } from './partial_linker';
|
||||
/**
|
||||
* A `PartialLinker` that is designed to process `ɵɵngDeclareInjector()` call expressions.
|
||||
*/
|
||||
export declare class PartialInjectorLinkerVersion1<TExpression> implements PartialLinker<TExpression> {
|
||||
linkPartialDeclaration(constantPool: ConstantPool, metaObj: AstObject<R3PartialDeclaration, TExpression>): LinkedDefinition;
|
||||
}
|
||||
/**
|
||||
* Derives the `R3InjectorMetadata` structure from the AST object.
|
||||
*/
|
||||
export declare function toR3InjectorMeta<TExpression>(metaObj: AstObject<R3DeclareInjectorMetadata, TExpression>): R3InjectorMetadata;
|
||||
Generated
Vendored
+28
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
* @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 { ConstantPool, outputAst as o, R3PartialDeclaration } from '@angular/compiler';
|
||||
import { AstObject } from '../../ast/ast_value';
|
||||
/**
|
||||
* A definition generated by a `PartialLinker`, ready to emit.
|
||||
*/
|
||||
export interface LinkedDefinition {
|
||||
expression: o.Expression;
|
||||
statements: o.Statement[];
|
||||
}
|
||||
/**
|
||||
* An interface for classes that can link partial declarations into full definitions.
|
||||
*/
|
||||
export interface PartialLinker<TExpression> {
|
||||
/**
|
||||
* Link the partial declaration `metaObj` information to generate a full definition expression.
|
||||
*
|
||||
* @param metaObj An object that fits one of the `R3DeclareDirectiveMetadata` or
|
||||
* `R3DeclareComponentMetadata` interfaces.
|
||||
*/
|
||||
linkPartialDeclaration(constantPool: ConstantPool, metaObj: AstObject<R3PartialDeclaration, TExpression>, version: string): LinkedDefinition;
|
||||
}
|
||||
Generated
Vendored
+81
@@ -0,0 +1,81 @@
|
||||
/**
|
||||
* @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 semver from 'semver';
|
||||
import { Logger } from '../../../../src/ngtsc/logging';
|
||||
import { LinkerEnvironment } from '../linker_environment';
|
||||
import { PartialLinker } from './partial_linker';
|
||||
import { AbsoluteFsPath } from '../../../../src/ngtsc/file_system/src/types';
|
||||
export declare const ɵɵngDeclareDirective = "\u0275\u0275ngDeclareDirective";
|
||||
export declare const ɵɵngDeclareClassMetadata = "\u0275\u0275ngDeclareClassMetadata";
|
||||
export declare const ɵɵngDeclareComponent = "\u0275\u0275ngDeclareComponent";
|
||||
export declare const ɵɵngDeclareFactory = "\u0275\u0275ngDeclareFactory";
|
||||
export declare const ɵɵngDeclareInjectable = "\u0275\u0275ngDeclareInjectable";
|
||||
export declare const ɵɵngDeclareInjector = "\u0275\u0275ngDeclareInjector";
|
||||
export declare const ɵɵngDeclareNgModule = "\u0275\u0275ngDeclareNgModule";
|
||||
export declare const ɵɵngDeclarePipe = "\u0275\u0275ngDeclarePipe";
|
||||
export declare const ɵɵngDeclareClassMetadataAsync = "\u0275\u0275ngDeclareClassMetadataAsync";
|
||||
export declare const declarationFunctions: string[];
|
||||
export interface LinkerRange<TExpression> {
|
||||
range: semver.Range;
|
||||
linker: PartialLinker<TExpression>;
|
||||
}
|
||||
/**
|
||||
* Create a mapping between partial-declaration call name and collections of partial-linkers.
|
||||
*
|
||||
* Each collection of partial-linkers will contain a version range that will be matched against the
|
||||
* `minVersion` of the partial-declaration. (Additionally, a partial-linker may modify its behaviour
|
||||
* internally based on the `version` property of the declaration.)
|
||||
*
|
||||
* Versions should be sorted in ascending order. The most recent partial-linker will be used as the
|
||||
* fallback linker if none of the other version ranges match. For example:
|
||||
*
|
||||
* ```
|
||||
* {range: getRange('<=', '13.0.0'), linker PartialDirectiveLinkerVersion2(...) },
|
||||
* {range: getRange('<=', '13.1.0'), linker PartialDirectiveLinkerVersion3(...) },
|
||||
* {range: getRange('<=', '14.0.0'), linker PartialDirectiveLinkerVersion4(...) },
|
||||
* {range: LATEST_VERSION_RANGE, linker: new PartialDirectiveLinkerVersion1(...)},
|
||||
* ```
|
||||
*
|
||||
* If the `LATEST_VERSION_RANGE` is `<=15.0.0` then the fallback linker would be
|
||||
* `PartialDirectiveLinkerVersion1` for any version greater than `15.0.0`.
|
||||
*
|
||||
* When there is a change to a declaration interface that requires a new partial-linker, the
|
||||
* `minVersion` of the partial-declaration should be updated, the new linker implementation should
|
||||
* be added to the end of the collection, and the version of the previous linker should be updated.
|
||||
*/
|
||||
export declare function createLinkerMap<TStatement, TExpression>(environment: LinkerEnvironment<TStatement, TExpression>, sourceUrl: AbsoluteFsPath, code: string): Map<string, LinkerRange<TExpression>[]>;
|
||||
/**
|
||||
* A helper that selects the appropriate `PartialLinker` for a given declaration.
|
||||
*
|
||||
* The selection is made from a database of linker instances, chosen if their given semver range
|
||||
* satisfies the `minVersion` of the partial declaration to be linked.
|
||||
*
|
||||
* Note that the ranges are checked in order, and the first matching range will be selected. So
|
||||
* ranges should be most restrictive first. In practice, since ranges are always `<=X.Y.Z` this
|
||||
* means that ranges should be in ascending order.
|
||||
*
|
||||
* Note that any "pre-release" versions are stripped from ranges. Therefore if a `minVersion` is
|
||||
* `11.1.0-next.1` then this would match `11.1.0-next.2` and also `12.0.0-next.1`. (This is
|
||||
* different to standard semver range checking, where pre-release versions do not cross full version
|
||||
* boundaries.)
|
||||
*/
|
||||
export declare class PartialLinkerSelector<TExpression> {
|
||||
private readonly linkers;
|
||||
private readonly logger;
|
||||
private readonly unknownDeclarationVersionHandling;
|
||||
constructor(linkers: Map<string, LinkerRange<TExpression>[]>, logger: Logger, unknownDeclarationVersionHandling: 'ignore' | 'warn' | 'error');
|
||||
/**
|
||||
* Returns true if there are `PartialLinker` classes that can handle functions with this name.
|
||||
*/
|
||||
supportsDeclaration(functionName: string): boolean;
|
||||
/**
|
||||
* Returns the `PartialLinker` that can handle functions with the given name and version.
|
||||
* Throws an error if there is none.
|
||||
*/
|
||||
getLinker(functionName: string, minVersion: string, version: string): PartialLinker<TExpression>;
|
||||
}
|
||||
Generated
Vendored
+31
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* @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 { ConstantPool, R3DeclareNgModuleMetadata, R3NgModuleMetadata, R3PartialDeclaration } from '@angular/compiler';
|
||||
import { AstObject } from '../../ast/ast_value';
|
||||
import { LinkedDefinition, PartialLinker } from './partial_linker';
|
||||
/**
|
||||
* A `PartialLinker` that is designed to process `ɵɵngDeclareNgModule()` call expressions.
|
||||
*/
|
||||
export declare class PartialNgModuleLinkerVersion1<TExpression> implements PartialLinker<TExpression> {
|
||||
/**
|
||||
* If true then emit the additional declarations, imports, exports, etc in the NgModule
|
||||
* definition. These are only used by JIT compilation.
|
||||
*/
|
||||
private emitInline;
|
||||
constructor(
|
||||
/**
|
||||
* If true then emit the additional declarations, imports, exports, etc in the NgModule
|
||||
* definition. These are only used by JIT compilation.
|
||||
*/
|
||||
emitInline: boolean);
|
||||
linkPartialDeclaration(constantPool: ConstantPool, metaObj: AstObject<R3PartialDeclaration, TExpression>): LinkedDefinition;
|
||||
}
|
||||
/**
|
||||
* Derives the `R3NgModuleMetadata` structure from the AST object.
|
||||
*/
|
||||
export declare function toR3NgModuleMeta<TExpression>(metaObj: AstObject<R3DeclareNgModuleMetadata, TExpression>, supportJit: boolean): R3NgModuleMetadata;
|
||||
node_modules/@angular/compiler-cli/linker/src/file_linker/partial_linkers/partial_pipe_linker_1.d.ts
Generated
Vendored
+21
@@ -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
|
||||
*/
|
||||
import { ConstantPool, R3DeclarePipeMetadata, R3PartialDeclaration, R3PipeMetadata } from '@angular/compiler';
|
||||
import { AstObject } from '../../ast/ast_value';
|
||||
import { LinkedDefinition, PartialLinker } from './partial_linker';
|
||||
/**
|
||||
* A `PartialLinker` that is designed to process `ɵɵngDeclarePipe()` call expressions.
|
||||
*/
|
||||
export declare class PartialPipeLinkerVersion1<TExpression> implements PartialLinker<TExpression> {
|
||||
constructor();
|
||||
linkPartialDeclaration(constantPool: ConstantPool, metaObj: AstObject<R3PartialDeclaration, TExpression>, version: string): LinkedDefinition;
|
||||
}
|
||||
/**
|
||||
* Derives the `R3PipeMetadata` structure from the AST object.
|
||||
*/
|
||||
export declare function toR3PipeMeta<TExpression>(metaObj: AstObject<R3DeclarePipeMetadata, TExpression>, version: string): R3PipeMetadata;
|
||||
Generated
Vendored
+31
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* @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 { MaybeForwardRefExpression, outputAst as o, R3DeclareDependencyMetadata, R3DependencyMetadata, R3Reference } from '@angular/compiler';
|
||||
import { AstObject, AstValue } from '../../ast/ast_value';
|
||||
export declare const PLACEHOLDER_VERSION = "21.2.1";
|
||||
export declare function wrapReference<TExpression>(wrapped: o.WrappedNodeExpr<TExpression>): R3Reference;
|
||||
/**
|
||||
* Parses the value of an enum from the AST value's symbol name.
|
||||
*/
|
||||
export declare function parseEnum<TExpression, TEnum>(value: AstValue<unknown, TExpression>, Enum: TEnum): TEnum[keyof TEnum];
|
||||
/**
|
||||
* Parse a dependency structure from an AST object.
|
||||
*/
|
||||
export declare function getDependency<TExpression>(depObj: AstObject<R3DeclareDependencyMetadata, TExpression>): R3DependencyMetadata;
|
||||
/**
|
||||
* Return an `R3ProviderExpression` that represents either the extracted type reference expression
|
||||
* from a `forwardRef` function call, or the type itself.
|
||||
*
|
||||
* For example, the expression `forwardRef(function() { return FooDir; })` returns `FooDir`. Note
|
||||
* that this expression is required to be wrapped in a closure, as otherwise the forward reference
|
||||
* would be resolved before initialization.
|
||||
*
|
||||
* If there is no forwardRef call expression then we just return the opaque type.
|
||||
*/
|
||||
export declare function extractForwardRef<TExpression>(expr: AstValue<unknown, TExpression>): MaybeForwardRefExpression<o.WrappedNodeExpr<TExpression>>;
|
||||
export declare function getDefaultStandaloneValue(version: string): boolean;
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* @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 o from '@angular/compiler';
|
||||
import { TranslatorOptions } from '../../../src/ngtsc/translator/src/translator';
|
||||
import { ImportGenerator } from '../../../src/ngtsc/translator/src/api/import_generator';
|
||||
import { AstFactory } from '../../../src/ngtsc/translator/src/api/ast_factory';
|
||||
/**
|
||||
* Generic translator helper class, which exposes methods for translating expressions and
|
||||
* statements.
|
||||
*/
|
||||
export declare class Translator<TStatement, TExpression> {
|
||||
private factory;
|
||||
constructor(factory: AstFactory<TStatement, TExpression>);
|
||||
/**
|
||||
* Translate the given output AST in the context of an expression.
|
||||
*/
|
||||
translateExpression(expression: o.Expression, imports: ImportGenerator<null, TExpression>, options?: TranslatorOptions<TExpression>): TExpression;
|
||||
/**
|
||||
* Translate the given output AST in the context of a statement.
|
||||
*/
|
||||
translateStatement(statement: o.Statement, imports: ImportGenerator<null, TExpression>, options?: TranslatorOptions<TExpression>): TStatement;
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* @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 { AstFactory, ImportGenerator, ImportRequest } from '../../src/ngtsc/translator';
|
||||
/**
|
||||
* A class that is used to generate imports when translating from Angular Output AST to an AST to
|
||||
* render, such as Babel.
|
||||
*
|
||||
* Note that, in the linker, there can only be imports from `@angular/core` and that these imports
|
||||
* must be achieved by property access on an `ng` namespace identifier, which is passed in via the
|
||||
* constructor.
|
||||
*/
|
||||
export declare class LinkerImportGenerator<TStatement, TExpression> implements ImportGenerator<null, TExpression> {
|
||||
private factory;
|
||||
private ngImport;
|
||||
constructor(factory: AstFactory<TStatement, TExpression>, ngImport: TExpression);
|
||||
addImport(request: ImportRequest<null>): TExpression;
|
||||
private assertModuleName;
|
||||
}
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
{
|
||||
"name": "@angular/compiler-cli",
|
||||
"version": "21.2.1",
|
||||
"description": "Angular - the compiler CLI for Node.js",
|
||||
"typings": "index.d.ts",
|
||||
"bin": {
|
||||
"ngc": "./bundles/src/bin/ngc.js",
|
||||
"ng-xi18n": "./bundles/src/bin/ng_xi18n.js"
|
||||
},
|
||||
"type": "module",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./index.d.ts",
|
||||
"default": "./bundles/index.js"
|
||||
},
|
||||
"./package.json": {
|
||||
"default": "./package.json"
|
||||
},
|
||||
"./linker": {
|
||||
"types": "./linker/index.d.ts",
|
||||
"default": "./bundles/linker/index.js"
|
||||
},
|
||||
"./linker/babel": {
|
||||
"types": "./linker/babel/index.d.ts",
|
||||
"default": "./bundles/linker/babel/index.js"
|
||||
},
|
||||
"./private/*": {
|
||||
"types": "./private/*.d.ts",
|
||||
"default": "./bundles/private/*.js"
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/core": "7.29.0",
|
||||
"@jridgewell/sourcemap-codec": "^1.4.14",
|
||||
"reflect-metadata": "^0.2.0",
|
||||
"chokidar": "^5.0.0",
|
||||
"convert-source-map": "^1.5.1",
|
||||
"semver": "^7.0.0",
|
||||
"tslib": "^2.3.0",
|
||||
"yargs": "^18.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "5.9.3"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@angular/compiler": "21.2.1",
|
||||
"typescript": ">=5.9 <6.1"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"typescript": {
|
||||
"optional": true
|
||||
}
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/angular/angular.git",
|
||||
"directory": "packages/compiler-cli"
|
||||
},
|
||||
"keywords": [
|
||||
"angular",
|
||||
"compiler"
|
||||
],
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": "^20.19.0 || ^22.12.0 || >=24.0.0"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/angular/angular/issues"
|
||||
},
|
||||
"homepage": "https://github.com/angular/angular/tree/main/packages/compiler-cli",
|
||||
"ng-update": {
|
||||
"packageGroup": [
|
||||
"@angular/core",
|
||||
"@angular/bazel",
|
||||
"@angular/common",
|
||||
"@angular/compiler",
|
||||
"@angular/compiler-cli",
|
||||
"@angular/animations",
|
||||
"@angular/elements",
|
||||
"@angular/platform-browser",
|
||||
"@angular/platform-browser-dynamic",
|
||||
"@angular/forms",
|
||||
"@angular/platform-server",
|
||||
"@angular/upgrade",
|
||||
"@angular/router",
|
||||
"@angular/language-service",
|
||||
"@angular/localize",
|
||||
"@angular/service-worker"
|
||||
]
|
||||
}
|
||||
}
|
||||
+14
@@ -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
|
||||
*/
|
||||
/**
|
||||
* @fileoverview The API from compiler-cli that the `@angular/localize`
|
||||
* package requires.
|
||||
*/
|
||||
export * from '../src/ngtsc/logging';
|
||||
export * from '../src/ngtsc/file_system';
|
||||
export { SourceFile, SourceFileLoader } from '../src/ngtsc/sourcemaps';
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
/**
|
||||
* @fileoverview The API from compiler-cli that the `@angular/core`
|
||||
* package requires for migration schematics.
|
||||
*/
|
||||
export { createForwardRefResolver, ExternalTemplateDeclaration, extractDecoratorQueryMetadata, extractTemplate, findAngularDecorator, getAngularDecorators, InlineTemplateDeclaration, queryDecoratorNames, QueryFunctionName, ResourceLoader, unwrapExpression, parseDecoratorInputTransformFunction, } from '../src/ngtsc/annotations';
|
||||
export { AbsoluteFsPath, FileSystem, getFileSystem, isLocalRelativePath, NodeJSFileSystem, } from '../src/ngtsc/file_system';
|
||||
export { CompilationMode } from '../src/ngtsc/transform';
|
||||
export { DiagnosticCategoryLabel, NgCompiler, NgCompilerOptions, UnifiedModulesHost, } from '../src/ngtsc/core';
|
||||
export { Reference, ReferenceEmitter, ReferenceEmitKind } from '../src/ngtsc/imports';
|
||||
export { DecoratorInputTransform, DtsMetadataReader, MetadataReader, DirectiveMeta, InputMapping, } from '../src/ngtsc/metadata';
|
||||
export { DynamicValue, PartialEvaluator, ResolvedValue, ResolvedValueMap, StaticInterpreter, } from '../src/ngtsc/partial_evaluator';
|
||||
export { ClassDeclaration, Decorator, ReflectionHost, reflectObjectLiteral, TypeScriptReflectionHost, } from '../src/ngtsc/reflection';
|
||||
export { PotentialImport, PotentialImportKind, PotentialImportMode, SymbolKind, TemplateTypeChecker, } from '../src/ngtsc/typecheck/api';
|
||||
export { getRootDirs } from '../src/ngtsc/util/src/typescript';
|
||||
export { FatalDiagnosticError } from '../src/ngtsc/diagnostics';
|
||||
export { isShim } from '../src/ngtsc/shims';
|
||||
export { ImportManager } from '../src/ngtsc/translator';
|
||||
+11
@@ -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
|
||||
*/
|
||||
export { ImportedSymbolsTracker } from '../src/ngtsc/imports';
|
||||
export { TypeScriptReflectionHost } from '../src/ngtsc/reflection';
|
||||
export { getInitializerApiJitTransform } from '../src/ngtsc/transform/jit';
|
||||
export { initMockFileSystem, MockFileSystem } from '../src/ngtsc/file_system/testing';
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
/**
|
||||
* @fileoverview
|
||||
* This file is used as a private API channel to shared Angular FW APIs with @angular/cli.
|
||||
*
|
||||
* Any changes to this file should be discussed with the Angular CLI team.
|
||||
*/
|
||||
import ts from 'typescript';
|
||||
/**
|
||||
* Known values for global variables in `@angular/core` that Terser should set using
|
||||
* https://github.com/terser-js/terser#conditional-compilation
|
||||
*/
|
||||
export declare const GLOBAL_DEFS_FOR_TERSER: {
|
||||
ngDevMode: boolean;
|
||||
ngI18nClosureMode: boolean;
|
||||
};
|
||||
export declare const GLOBAL_DEFS_FOR_TERSER_WITH_AOT: {
|
||||
ngJitMode: boolean;
|
||||
ngDevMode: boolean;
|
||||
ngI18nClosureMode: boolean;
|
||||
};
|
||||
/**
|
||||
* JIT transform used by the Angular CLI.
|
||||
*
|
||||
* NOTE: Signature is explicitly captured here to highlight the
|
||||
* contract various Angular CLI versions are relying on.
|
||||
*/
|
||||
export declare const constructorParametersDownlevelTransform: (program: ts.Program, isCore?: boolean) => ts.TransformerFactory<ts.SourceFile>;
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* @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 'reflect-metadata';
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* @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 'reflect-metadata';
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* @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 declare function mainXi18n(args: string[], consoleError?: (msg: string) => void): number;
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* @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 ts from 'typescript';
|
||||
import { ParsedConfiguration } from './perform_compile';
|
||||
import * as api from './transformers/api';
|
||||
export declare function main(args: string[], consoleError?: (s: string) => void, config?: NgcParsedConfiguration, customTransformers?: api.CustomTransformers, programReuse?: {
|
||||
program: api.Program | undefined;
|
||||
}, modifiedResourceFiles?: Set<string> | null): number;
|
||||
export declare function mainDiagnosticsForTest(args: string[], config?: NgcParsedConfiguration, programReuse?: {
|
||||
program: api.Program | undefined;
|
||||
}, modifiedResourceFiles?: Set<string> | null): {
|
||||
exitCode: number;
|
||||
diagnostics: ReadonlyArray<ts.Diagnostic>;
|
||||
};
|
||||
export interface NgcParsedConfiguration extends ParsedConfiguration {
|
||||
watch?: boolean;
|
||||
}
|
||||
export declare function readNgcCommandLineAndConfiguration(args: string[]): NgcParsedConfiguration;
|
||||
export declare function readCommandLineAndConfiguration(args: string[], existingOptions?: api.CompilerOptions, ngCmdLineOptions?: string[]): ParsedConfiguration;
|
||||
export declare function watchMode(project: string, options: api.CompilerOptions, consoleError: (s: string) => void): {
|
||||
close: () => void;
|
||||
ready: (cb: () => void) => void;
|
||||
firstCompileResult: ReadonlyArray<ts.Diagnostic>;
|
||||
};
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* @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 * from './src/api';
|
||||
export * from './src/di';
|
||||
export * from './src/diagnostics';
|
||||
export * from './src/evaluation';
|
||||
export * from './src/factory';
|
||||
export * from './src/injectable_registry';
|
||||
export * from './src/metadata';
|
||||
export * from './src/debug_info';
|
||||
export * from './src/references_registry';
|
||||
export * from './src/schema';
|
||||
export * from './src/util';
|
||||
export * from './src/input_transforms';
|
||||
export * from './src/jit_declaration_registry';
|
||||
+96
@@ -0,0 +1,96 @@
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
/**
|
||||
* Resolves and loads resource files that are referenced in Angular metadata.
|
||||
*
|
||||
* Note that `preload()` and `load()` take a `resolvedUrl`, which can be found
|
||||
* by calling `resolve()`. These two steps are separated because sometimes the
|
||||
* resolved URL to the resource is needed as well as its contents.
|
||||
*/
|
||||
export interface ResourceLoader {
|
||||
/**
|
||||
* True if this resource loader can preload resources.
|
||||
*
|
||||
* Sometimes a `ResourceLoader` is not able to do asynchronous pre-loading of resources.
|
||||
*/
|
||||
canPreload: boolean;
|
||||
/**
|
||||
* If true, the resource loader is able to preprocess inline resources.
|
||||
*/
|
||||
canPreprocess: boolean;
|
||||
/**
|
||||
* Resolve the url of a resource relative to the file that contains the reference to it.
|
||||
* The return value of this method can be used in the `load()` and `preload()` methods.
|
||||
*
|
||||
* @param url The, possibly relative, url of the resource.
|
||||
* @param fromFile The path to the file that contains the URL of the resource.
|
||||
* @returns A resolved url of resource.
|
||||
* @throws An error if the resource cannot be resolved.
|
||||
*/
|
||||
resolve(file: string, basePath: string): string;
|
||||
/**
|
||||
* Preload the specified resource, asynchronously. Once the resource is loaded, its value
|
||||
* should be cached so it can be accessed synchronously via the `load()` method.
|
||||
*
|
||||
* @param resolvedUrl The url (resolved by a call to `resolve()`) of the resource to preload.
|
||||
* @param context Information regarding the resource such as the type and containing file.
|
||||
* @returns A Promise that is resolved once the resource has been loaded or `undefined`
|
||||
* if the file has already been loaded.
|
||||
* @throws An Error if pre-loading is not available.
|
||||
*/
|
||||
preload(resolvedUrl: string, context: ResourceLoaderContext): Promise<void> | undefined;
|
||||
/**
|
||||
* Preprocess the content data of an inline resource, asynchronously.
|
||||
*
|
||||
* @param data The existing content data from the inline resource.
|
||||
* @param context Information regarding the resource such as the type and containing file.
|
||||
* @returns A Promise that resolves to the processed data. If no processing occurs, the
|
||||
* same data string that was passed to the function will be resolved.
|
||||
*/
|
||||
preprocessInline(data: string, context: ResourceLoaderContext): Promise<string>;
|
||||
/**
|
||||
* Load the resource at the given url, synchronously.
|
||||
*
|
||||
* The contents of the resource may have been cached by a previous call to `preload()`.
|
||||
*
|
||||
* @param resolvedUrl The url (resolved by a call to `resolve()`) of the resource to load.
|
||||
* @returns The contents of the resource.
|
||||
*/
|
||||
load(resolvedUrl: string): string;
|
||||
}
|
||||
/**
|
||||
* Contextual information used by members of the ResourceLoader interface.
|
||||
*/
|
||||
export interface ResourceLoaderContext {
|
||||
/**
|
||||
* The type of the component resource.
|
||||
* * Resources referenced via a component's `styles` or `styleUrls` properties are of
|
||||
* type `style`.
|
||||
* * Resources referenced via a component's `template` or `templateUrl` properties are of type
|
||||
* `template`.
|
||||
*/
|
||||
type: 'style' | 'template';
|
||||
/**
|
||||
* The absolute path to the file that contains the resource or reference to the resource.
|
||||
*/
|
||||
containingFile: string;
|
||||
/**
|
||||
* For style resources, the placement of the style within the containing file with lower numbers
|
||||
* being before higher numbers.
|
||||
* The value is primarily used by the Angular CLI to create a deterministic identifier for each
|
||||
* style in HMR scenarios.
|
||||
* This is undefined for templates.
|
||||
*/
|
||||
order?: number;
|
||||
/**
|
||||
* The name of the class that defines the component using the resource.
|
||||
* This allows identifying the source usage of a resource in cases where multiple components are
|
||||
* contained in a single source file.
|
||||
*/
|
||||
className: string;
|
||||
}
|
||||
Generated
Vendored
+11
@@ -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 { R3ClassDebugInfo } from '@angular/compiler';
|
||||
import ts from 'typescript';
|
||||
import { DeclarationNode, ReflectionHost } from '../../../reflection';
|
||||
export declare function extractClassDebugInfo(clazz: DeclarationNode, reflection: ReflectionHost, compilerHost: Pick<ts.CompilerHost, 'getCanonicalFileName'>, rootDirs: ReadonlyArray<string>, forbidOrphanRendering: boolean): R3ClassDebugInfo | null;
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* @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 { R3DependencyMetadata } from '@angular/compiler';
|
||||
import { ClassDeclaration, CtorParameter, ReflectionHost, UnavailableValue } from '../../../reflection';
|
||||
export type ConstructorDeps = {
|
||||
deps: R3DependencyMetadata[];
|
||||
} | {
|
||||
deps: null;
|
||||
errors: ConstructorDepError[];
|
||||
};
|
||||
export interface ConstructorDepError {
|
||||
index: number;
|
||||
param: CtorParameter;
|
||||
reason: UnavailableValue;
|
||||
}
|
||||
export declare function getConstructorDependencies(clazz: ClassDeclaration, reflector: ReflectionHost, isCore: boolean): ConstructorDeps | null;
|
||||
/**
|
||||
* Convert `ConstructorDeps` into the `R3DependencyMetadata` array for those deps if they're valid,
|
||||
* or into an `'invalid'` signal if they're not.
|
||||
*
|
||||
* This is a companion function to `validateConstructorDependencies` which accepts invalid deps.
|
||||
*/
|
||||
export declare function unwrapConstructorDependencies(deps: ConstructorDeps | null): R3DependencyMetadata[] | 'invalid' | null;
|
||||
export declare function getValidConstructorDependencies(clazz: ClassDeclaration, reflector: ReflectionHost, isCore: boolean): R3DependencyMetadata[] | null;
|
||||
/**
|
||||
* Validate that `ConstructorDeps` does not have any invalid dependencies and convert them into the
|
||||
* `R3DependencyMetadata` array if so, or raise a diagnostic if some deps are invalid.
|
||||
*
|
||||
* This is a companion function to `unwrapConstructorDependencies` which does not accept invalid
|
||||
* deps.
|
||||
*/
|
||||
export declare function validateConstructorDependencies(clazz: ClassDeclaration, deps: ConstructorDeps | null): R3DependencyMetadata[] | null;
|
||||
Generated
Vendored
+63
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
* @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 ts from 'typescript';
|
||||
import { FatalDiagnosticError } from '../../../diagnostics';
|
||||
import { Reference } from '../../../imports';
|
||||
import { HostDirectiveMeta, MetadataReader } from '../../../metadata';
|
||||
import { PartialEvaluator, ResolvedValue } from '../../../partial_evaluator';
|
||||
import { ClassDeclaration, ReflectionHost } from '../../../reflection';
|
||||
import { DeclarationData, LocalModuleScopeRegistry } from '../../../scope';
|
||||
import { InjectableClassRegistry } from './injectable_registry';
|
||||
import { CompilationMode } from '../../../transform';
|
||||
/**
|
||||
* Create a `ts.Diagnostic` which indicates the given class is part of the declarations of two or
|
||||
* more NgModules.
|
||||
*
|
||||
* The resulting `ts.Diagnostic` will have a context entry for each NgModule showing the point where
|
||||
* the directive/pipe exists in its `declarations` (if possible).
|
||||
*/
|
||||
export declare function makeDuplicateDeclarationError(node: ClassDeclaration, data: DeclarationData[], kind: string): ts.Diagnostic;
|
||||
/**
|
||||
* Creates a `FatalDiagnosticError` for a node that did not evaluate to the expected type. The
|
||||
* diagnostic that is created will include details on why the value is incorrect, i.e. it includes
|
||||
* a representation of the actual type that was unsupported, or in the case of a dynamic value the
|
||||
* trace to the node where the dynamic value originated.
|
||||
*
|
||||
* @param node The node for which the diagnostic should be produced.
|
||||
* @param value The evaluated value that has the wrong type.
|
||||
* @param messageText The message text of the error.
|
||||
*/
|
||||
export declare function createValueHasWrongTypeError(node: ts.Node, value: ResolvedValue, messageText: string): FatalDiagnosticError;
|
||||
/**
|
||||
* Gets the diagnostics for a set of provider classes.
|
||||
* @param providerClasses Classes that should be checked.
|
||||
* @param providersDeclaration Node that declares the providers array.
|
||||
* @param registry Registry that keeps track of the registered injectable classes.
|
||||
*/
|
||||
export declare function getProviderDiagnostics(providerClasses: Set<Reference<ClassDeclaration>>, providersDeclaration: ts.Expression, registry: InjectableClassRegistry): ts.Diagnostic[];
|
||||
export declare function getDirectiveDiagnostics(node: ClassDeclaration, injectableRegistry: InjectableClassRegistry, evaluator: PartialEvaluator, reflector: ReflectionHost, scopeRegistry: LocalModuleScopeRegistry, strictInjectionParameters: boolean, kind: 'Directive' | 'Component'): ts.Diagnostic[] | null;
|
||||
export declare function validateHostDirectives(origin: ts.Expression, hostDirectives: HostDirectiveMeta[], metaReader: MetadataReader): ts.DiagnosticWithLocation[];
|
||||
export declare function getUndecoratedClassWithAngularFeaturesDiagnostic(node: ClassDeclaration): ts.Diagnostic;
|
||||
export declare function checkInheritanceOfInjectable(node: ClassDeclaration, injectableRegistry: InjectableClassRegistry, reflector: ReflectionHost, evaluator: PartialEvaluator, strictInjectionParameters: boolean, kind: 'Directive' | 'Component' | 'Pipe' | 'Injectable'): ts.Diagnostic | null;
|
||||
interface ClassWithCtor {
|
||||
ref: Reference<ClassDeclaration>;
|
||||
isCtorValid: boolean;
|
||||
isDecorated: boolean;
|
||||
}
|
||||
export declare function findInheritedCtor(node: ClassDeclaration, injectableRegistry: InjectableClassRegistry, reflector: ReflectionHost, evaluator: PartialEvaluator): ClassWithCtor | null;
|
||||
/**
|
||||
* Throws `FatalDiagnosticError` with error code `LOCAL_COMPILATION_UNRESOLVED_CONST`
|
||||
* if the compilation mode is local and the value is not resolved due to being imported
|
||||
* from external files. This is a common scenario for errors in local compilation mode,
|
||||
* and so this helper can be used to quickly generate the relevant errors.
|
||||
*
|
||||
* @param nodeToHighlight Node to be highlighted in teh error message.
|
||||
* Will default to value.node if not provided.
|
||||
*/
|
||||
export declare function assertLocalCompilationUnresolvedConst(compilationMode: CompilationMode, value: ResolvedValue, nodeToHighlight: ts.Node | null, errorMessage: string): void;
|
||||
export {};
|
||||
Generated
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* @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 ts from 'typescript';
|
||||
import { Reference } from '../../../imports';
|
||||
import { PartialEvaluator, ResolvedValue } from '../../../partial_evaluator';
|
||||
import { ClassDeclaration, Decorator } from '../../../reflection';
|
||||
export declare function resolveEnumValue(evaluator: PartialEvaluator, metadata: Map<string, ts.Expression>, field: string, enumSymbolName: string, isCore: boolean): number | null;
|
||||
/**
|
||||
* Resolves a EncapsulationEnum expression locally on best effort without having to calculate the
|
||||
* reference. This suites local compilation mode where each file is compiled individually.
|
||||
*
|
||||
* The static analysis is still needed in local compilation mode since the value of this enum will
|
||||
* be used later to decide the generated code for styles.
|
||||
*/
|
||||
export declare function resolveEncapsulationEnumValueLocally(expr?: ts.Expression): number | null;
|
||||
/** Determines if the result of an evaluation is a string array. */
|
||||
export declare function isStringArray(resolvedValue: ResolvedValue): resolvedValue is string[];
|
||||
export declare function isClassReferenceArray(resolvedValue: ResolvedValue): resolvedValue is Reference<ClassDeclaration>[];
|
||||
export declare function isArray(value: ResolvedValue): value is Array<ResolvedValue>;
|
||||
export declare function resolveLiteral(decorator: Decorator, literalCache: Map<Decorator, ts.ObjectLiteralExpression>): ts.ObjectLiteralExpression;
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
/**
|
||||
* @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 { R3FactoryMetadata } from '@angular/compiler';
|
||||
import { CompileResult } from '../../../transform';
|
||||
export type CompileFactoryFn = (metadata: R3FactoryMetadata) => CompileResult;
|
||||
export declare function compileNgFactoryDefField(metadata: R3FactoryMetadata): CompileResult;
|
||||
export declare function compileDeclareFactory(metadata: R3FactoryMetadata): CompileResult;
|
||||
Generated
Vendored
+24
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* @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 { R3DependencyMetadata } from '@angular/compiler';
|
||||
import { ClassDeclaration, ReflectionHost } from '../../../reflection';
|
||||
export interface InjectableMeta {
|
||||
ctorDeps: R3DependencyMetadata[] | 'invalid' | null;
|
||||
}
|
||||
/**
|
||||
* Registry that keeps track of classes that can be constructed via dependency injection (e.g.
|
||||
* injectables, directives, pipes).
|
||||
*/
|
||||
export declare class InjectableClassRegistry {
|
||||
private host;
|
||||
private isCore;
|
||||
private classes;
|
||||
constructor(host: ReflectionHost, isCore: boolean);
|
||||
registerInjectable(declaration: ClassDeclaration, meta: InjectableMeta): void;
|
||||
getInjectableMeta(declaration: ClassDeclaration): InjectableMeta | null;
|
||||
}
|
||||
Generated
Vendored
+11
@@ -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 { ClassPropertyMapping, InputMapping } from '../../../metadata';
|
||||
import { CompileResult } from '../../../transform';
|
||||
/** Generates additional fields to be added to a class that has inputs with transform functions. */
|
||||
export declare function compileInputTransformFields(inputs: ClassPropertyMapping<InputMapping>): CompileResult[];
|
||||
Generated
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* @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 { ClassDeclaration } from '../../../reflection';
|
||||
/**
|
||||
* Registry that keeps track of Angular declarations that are explicitly
|
||||
* marked for JIT compilation and are skipping compilation by trait handlers.
|
||||
*/
|
||||
export declare class JitDeclarationRegistry {
|
||||
jitDeclarations: Set<ClassDeclaration>;
|
||||
}
|
||||
Generated
Vendored
+27
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* @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 { LiteralArrayExpr, R3ClassMetadata } from '@angular/compiler';
|
||||
import ts from 'typescript';
|
||||
import { ClassMember, DeclarationNode, Decorator, ReflectionHost } from '../../../reflection';
|
||||
/** Function that extracts metadata from an undercorated class member. */
|
||||
export type UndecoratedMetadataExtractor = (member: ClassMember) => LiteralArrayExpr | null;
|
||||
/**
|
||||
* Given a class declaration, generate a call to `setClassMetadata` with the Angular metadata
|
||||
* present on the class or its member fields. An ngDevMode guard is used to allow the call to be
|
||||
* tree-shaken away, as the `setClassMetadata` invocation is only needed for testing purposes.
|
||||
*
|
||||
* If no such metadata is present, this function returns `null`. Otherwise, the call is returned
|
||||
* as a `Statement` for inclusion along with the class.
|
||||
*/
|
||||
export declare function extractClassMetadata(clazz: DeclarationNode, reflection: ReflectionHost, isCore: boolean, annotateForClosureCompiler?: boolean, angularDecoratorTransform?: (dec: Decorator) => Decorator, undecoratedMetadataExtractor?: UndecoratedMetadataExtractor): R3ClassMetadata | null;
|
||||
/**
|
||||
* Recursively recreates all of the `Identifier` descendant nodes with a particular name inside
|
||||
* of an AST node, thus removing any references to them. Useful if a particular node has to be
|
||||
* taken from one place any emitted to another one exactly as it has been written.
|
||||
*/
|
||||
export declare function removeIdentifierReferences<T extends ts.Node>(node: T, names: string | Set<string>): T;
|
||||
Generated
Vendored
+26
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* @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 { Reference } from '../../../imports';
|
||||
import { DeclarationNode } from '../../../reflection';
|
||||
/**
|
||||
* Implement this interface if you want DecoratorHandlers to register
|
||||
* references that they find in their analysis of the code.
|
||||
*/
|
||||
export interface ReferencesRegistry {
|
||||
/**
|
||||
* Register one or more references in the registry.
|
||||
* @param references A collection of references to register.
|
||||
*/
|
||||
add(source: DeclarationNode, ...references: Reference<DeclarationNode>[]): void;
|
||||
}
|
||||
/**
|
||||
* This registry does nothing.
|
||||
*/
|
||||
export declare class NoopReferencesRegistry implements ReferencesRegistry {
|
||||
add(source: DeclarationNode, ...references: Reference<DeclarationNode>[]): void;
|
||||
}
|
||||
+11
@@ -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 { SchemaMetadata } from '@angular/compiler';
|
||||
import ts from 'typescript';
|
||||
import { PartialEvaluator } from '../../../partial_evaluator';
|
||||
export declare function extractSchemas(rawExpr: ts.Expression, evaluator: PartialEvaluator, context: string): SchemaMetadata[];
|
||||
+122
@@ -0,0 +1,122 @@
|
||||
/**
|
||||
* @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 { Expression, FactoryTarget, ParseSourceSpan, R3CompiledExpression, R3FactoryMetadata, R3Reference, Statement, WrappedNodeExpr } from '@angular/compiler';
|
||||
import ts from 'typescript';
|
||||
import { ImportedFile, ModuleResolver, Reference, ReferenceEmitter } from '../../../imports';
|
||||
import { ForeignFunctionResolver, PartialEvaluator } from '../../../partial_evaluator';
|
||||
import { ClassDeclaration, Decorator, Import, ImportedTypeValueReference, LocalTypeValueReference, ReflectionHost, TypeValueReference } from '../../../reflection';
|
||||
import { CompileResult } from '../../../transform';
|
||||
/** Module name of the framework core. */
|
||||
export declare const CORE_MODULE = "@angular/core";
|
||||
/**
|
||||
* Convert a `TypeValueReference` to an `Expression` which refers to the type as a value.
|
||||
*
|
||||
* Local references are converted to a `WrappedNodeExpr` of the TypeScript expression, and non-local
|
||||
* references are converted to an `ExternalExpr`. Note that this is only valid in the context of the
|
||||
* file in which the `TypeValueReference` originated.
|
||||
*/
|
||||
export declare function valueReferenceToExpression(valueRef: LocalTypeValueReference | ImportedTypeValueReference): Expression;
|
||||
export declare function valueReferenceToExpression(valueRef: TypeValueReference): Expression | null;
|
||||
export declare function toR3Reference(origin: ts.Node, ref: Reference, context: ts.SourceFile, refEmitter: ReferenceEmitter): R3Reference;
|
||||
export declare function isAngularCore(decorator: Decorator): decorator is Decorator & {
|
||||
import: Import;
|
||||
};
|
||||
/**
|
||||
* This function is used for verifying that a given reference is declared
|
||||
* inside `@angular/core` and corresponds to the given symbol name.
|
||||
*
|
||||
* In some cases, due to the compiler face duplicating many symbols as
|
||||
* an independent bridge between core and the compiler, the dts bundler may
|
||||
* decide to alias declarations in the `.d.ts`, to avoid conflicts.
|
||||
*
|
||||
* e.g.
|
||||
*
|
||||
* ```
|
||||
* declare enum ViewEncapsulation {} // from the facade
|
||||
* declare enum ViewEncapsulation$1 {} // the real one exported to users.
|
||||
* ```
|
||||
*
|
||||
* This function accounts for such potential re-namings.
|
||||
*/
|
||||
export declare function isAngularCoreReferenceWithPotentialAliasing(reference: Reference, symbolName: string, isCore: boolean): boolean;
|
||||
export declare function findAngularDecorator(decorators: Decorator[], name: string, isCore: boolean): Decorator | undefined;
|
||||
export declare function isAngularDecorator(decorator: Decorator, name: string, isCore: boolean): boolean;
|
||||
export declare function getAngularDecorators(decorators: Decorator[], names: readonly string[], isCore: boolean): Decorator[];
|
||||
/**
|
||||
* Unwrap a `ts.Expression`, removing outer type-casts or parentheses until the expression is in its
|
||||
* lowest level form.
|
||||
*
|
||||
* For example, the expression "(foo as Type)" unwraps to "foo".
|
||||
*/
|
||||
export declare function unwrapExpression(node: ts.Expression): ts.Expression;
|
||||
/**
|
||||
* If the given `node` is a forwardRef() expression then resolve its inner value, otherwise return
|
||||
* `null`.
|
||||
*
|
||||
* @param node the forwardRef() expression to resolve
|
||||
* @param reflector a ReflectionHost
|
||||
* @returns the resolved expression, if the original expression was a forwardRef(), or `null`
|
||||
* otherwise.
|
||||
*/
|
||||
export declare function tryUnwrapForwardRef(node: ts.Expression, reflector: ReflectionHost): ts.Expression | null;
|
||||
/**
|
||||
* A foreign function resolver for `staticallyResolve` which unwraps forwardRef() expressions.
|
||||
*
|
||||
* @param ref a Reference to the declaration of the function being called (which might be
|
||||
* forwardRef)
|
||||
* @param args the arguments to the invocation of the forwardRef expression
|
||||
* @returns an unwrapped argument if `ref` pointed to forwardRef, or null otherwise
|
||||
*/
|
||||
export declare function createForwardRefResolver(isCore: boolean): ForeignFunctionResolver;
|
||||
/**
|
||||
* Combines an array of resolver functions into a one.
|
||||
* @param resolvers Resolvers to be combined.
|
||||
*/
|
||||
export declare function combineResolvers(resolvers: ForeignFunctionResolver[]): ForeignFunctionResolver;
|
||||
export declare function isExpressionForwardReference(expr: Expression, context: ts.Node, contextSource: ts.SourceFile): boolean;
|
||||
export declare function isWrappedTsNodeExpr(expr: Expression): expr is WrappedNodeExpr<ts.Node>;
|
||||
export declare function readBaseClass(node: ClassDeclaration, reflector: ReflectionHost, evaluator: PartialEvaluator): Reference<ClassDeclaration> | 'dynamic' | null;
|
||||
/**
|
||||
* Wraps all functions in a given expression in parentheses. This is needed to avoid problems
|
||||
* where Tsickle annotations added between analyse and transform phases in Angular may trigger
|
||||
* automatic semicolon insertion, e.g. if a function is the expression in a `return` statement.
|
||||
* More
|
||||
* info can be found in Tsickle source code here:
|
||||
* https://github.com/angular/tsickle/blob/d7974262571c8a17d684e5ba07680e1b1993afdd/src/jsdoc_transformer.ts#L1021
|
||||
*
|
||||
* @param expression Expression where functions should be wrapped in parentheses
|
||||
*/
|
||||
export declare function wrapFunctionExpressionsInParens(expression: ts.Expression): ts.Expression;
|
||||
/**
|
||||
* Resolves the given `rawProviders` into `ClassDeclarations` and returns
|
||||
* a set containing those that are known to require a factory definition.
|
||||
* @param rawProviders Expression that declared the providers array in the source.
|
||||
*/
|
||||
export declare function resolveProvidersRequiringFactory(rawProviders: ts.Expression, reflector: ReflectionHost, evaluator: PartialEvaluator): Set<Reference<ClassDeclaration>>;
|
||||
/**
|
||||
* Create an R3Reference for a class.
|
||||
*
|
||||
* The `value` is the exported declaration of the class from its source file.
|
||||
* The `type` is an expression that would be used in the typings (.d.ts) files.
|
||||
*/
|
||||
export declare function wrapTypeReference(clazz: ClassDeclaration): R3Reference;
|
||||
/** Creates a ParseSourceSpan for a TypeScript node. */
|
||||
export declare function createSourceSpan(node: ts.Node): ParseSourceSpan;
|
||||
/**
|
||||
* Collate the factory and definition compiled results into an array of CompileResult objects.
|
||||
*/
|
||||
export declare function compileResults(fac: CompileResult, def: R3CompiledExpression, metadataStmt: Statement | null, propName: string, additionalFields: CompileResult[] | null, deferrableImports: Set<ts.ImportDeclaration> | null, debugInfo?: Statement | null, hmrInitializer?: Statement | null): CompileResult[];
|
||||
export declare function toFactoryMetadata(meta: Omit<R3FactoryMetadata, 'target'>, target: FactoryTarget): R3FactoryMetadata;
|
||||
export declare function resolveImportedFile(moduleResolver: ModuleResolver, importedFile: ImportedFile, expr: Expression, origin: ts.SourceFile): ts.SourceFile | null;
|
||||
/**
|
||||
* Determines the most appropriate expression for diagnostic reporting purposes. If `expr` is
|
||||
* contained within `container` then `expr` is used as origin node, otherwise `container` itself is
|
||||
* used.
|
||||
*/
|
||||
export declare function getOriginNodeForDiagnostics(expr: ts.Expression, container: ts.Expression): ts.Expression;
|
||||
export declare function isAbstractClassDeclaration(clazz: ClassDeclaration): boolean;
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* @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 { ComponentDecoratorHandler } from './src/handler';
|
||||
Generated
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
/*!
|
||||
* @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 { TmplAstNode } from '@angular/compiler';
|
||||
/**
|
||||
* Analyzes a component's template to determine if it's using animate.enter
|
||||
* or animate.leave syntax.
|
||||
*/
|
||||
export declare function analyzeTemplateForAnimations(template: TmplAstNode[]): {
|
||||
hasAnimations: boolean;
|
||||
};
|
||||
Generated
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* @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 ts from 'typescript';
|
||||
import { Cycle } from '../../../cycles';
|
||||
import { Reference } from '../../../imports';
|
||||
/**
|
||||
* Generate a diagnostic related information object that describes a potential cyclic import path.
|
||||
*/
|
||||
export declare function makeCyclicImportInfo(ref: Reference, type: string, cycle: Cycle): ts.DiagnosticRelatedInformation;
|
||||
/**
|
||||
* Checks whether a selector is a valid custom element tag name.
|
||||
* Based loosely on https://github.com/sindresorhus/validate-element-name.
|
||||
*/
|
||||
export declare function checkCustomElementSelectorForErrors(selector: string): string | null;
|
||||
Generated
Vendored
+161
@@ -0,0 +1,161 @@
|
||||
/**
|
||||
* @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 { ConstantPool } from '@angular/compiler';
|
||||
import ts from 'typescript';
|
||||
import { CycleAnalyzer, CycleHandlingStrategy } from '../../../cycles';
|
||||
import { DeferredSymbolTracker, ImportedSymbolsTracker, LocalCompilationExtraImportsTracker, ModuleResolver, ReferenceEmitter } from '../../../imports';
|
||||
import { DependencyTracker } from '../../../incremental/api';
|
||||
import { SemanticDepGraphUpdater } from '../../../incremental/semantic_graph';
|
||||
import { IndexingContext } from '../../../indexer';
|
||||
import { HostDirectivesResolver, MetadataReader, MetadataRegistry, ResourceRegistry } from '../../../metadata';
|
||||
import { PartialEvaluator } from '../../../partial_evaluator';
|
||||
import { PerfRecorder } from '../../../perf';
|
||||
import { ClassDeclaration, Decorator, ReflectionHost } from '../../../reflection';
|
||||
import { ComponentScopeReader, LocalModuleScopeRegistry, TypeCheckScopeRegistry } from '../../../scope';
|
||||
import { AnalysisOutput, CompilationMode, CompileResult, DecoratorHandler, DetectResult, HandlerPrecedence, ResolveResult } from '../../../transform';
|
||||
import { TypeCheckContext } from '../../../typecheck/api';
|
||||
import { ExtendedTemplateChecker } from '../../../typecheck/extended/api';
|
||||
import { TemplateSemanticsChecker } from '../../../typecheck/template_semantics/api/api';
|
||||
import { Xi18nContext } from '../../../xi18n';
|
||||
import { InjectableClassRegistry, ReferencesRegistry, ResourceLoader } from '../../common';
|
||||
import { ComponentAnalysisData, ComponentResolutionData } from './metadata';
|
||||
import { ComponentSymbol } from './symbol';
|
||||
import { JitDeclarationRegistry } from '../../common/src/jit_declaration_registry';
|
||||
/**
|
||||
* `DecoratorHandler` which handles the `@Component` annotation.
|
||||
*/
|
||||
export declare class ComponentDecoratorHandler implements DecoratorHandler<Decorator, ComponentAnalysisData, ComponentSymbol, ComponentResolutionData> {
|
||||
private reflector;
|
||||
private evaluator;
|
||||
private metaRegistry;
|
||||
private metaReader;
|
||||
private scopeReader;
|
||||
private compilerHost;
|
||||
private scopeRegistry;
|
||||
private typeCheckScopeRegistry;
|
||||
private resourceRegistry;
|
||||
private isCore;
|
||||
private strictCtorDeps;
|
||||
private resourceLoader;
|
||||
private rootDirs;
|
||||
private defaultPreserveWhitespaces;
|
||||
private i18nUseExternalIds;
|
||||
private enableI18nLegacyMessageIdFormat;
|
||||
private usePoisonedData;
|
||||
private i18nNormalizeLineEndingsInICUs;
|
||||
private moduleResolver;
|
||||
private cycleAnalyzer;
|
||||
private cycleHandlingStrategy;
|
||||
private refEmitter;
|
||||
private referencesRegistry;
|
||||
private depTracker;
|
||||
private injectableRegistry;
|
||||
private semanticDepGraphUpdater;
|
||||
private annotateForClosureCompiler;
|
||||
private perf;
|
||||
private hostDirectivesResolver;
|
||||
private importTracker;
|
||||
private includeClassMetadata;
|
||||
private readonly compilationMode;
|
||||
private readonly deferredSymbolTracker;
|
||||
private readonly forbidOrphanRendering;
|
||||
private readonly enableBlockSyntax;
|
||||
private readonly enableLetSyntax;
|
||||
private readonly externalRuntimeStyles;
|
||||
private readonly localCompilationExtraImportsTracker;
|
||||
private readonly jitDeclarationRegistry;
|
||||
private readonly i18nPreserveSignificantWhitespace;
|
||||
private readonly strictStandalone;
|
||||
private readonly enableHmr;
|
||||
private readonly implicitStandaloneValue;
|
||||
private readonly typeCheckHostBindings;
|
||||
private readonly enableSelectorless;
|
||||
private readonly emitDeclarationOnly;
|
||||
constructor(reflector: ReflectionHost, evaluator: PartialEvaluator, metaRegistry: MetadataRegistry, metaReader: MetadataReader, scopeReader: ComponentScopeReader, compilerHost: Pick<ts.CompilerHost, 'getCanonicalFileName'>, scopeRegistry: LocalModuleScopeRegistry, typeCheckScopeRegistry: TypeCheckScopeRegistry, resourceRegistry: ResourceRegistry, isCore: boolean, strictCtorDeps: boolean, resourceLoader: ResourceLoader, rootDirs: ReadonlyArray<string>, defaultPreserveWhitespaces: boolean, i18nUseExternalIds: boolean, enableI18nLegacyMessageIdFormat: boolean, usePoisonedData: boolean, i18nNormalizeLineEndingsInICUs: boolean, moduleResolver: ModuleResolver, cycleAnalyzer: CycleAnalyzer, cycleHandlingStrategy: CycleHandlingStrategy, refEmitter: ReferenceEmitter, referencesRegistry: ReferencesRegistry, depTracker: DependencyTracker | null, injectableRegistry: InjectableClassRegistry, semanticDepGraphUpdater: SemanticDepGraphUpdater | null, annotateForClosureCompiler: boolean, perf: PerfRecorder, hostDirectivesResolver: HostDirectivesResolver, importTracker: ImportedSymbolsTracker, includeClassMetadata: boolean, compilationMode: CompilationMode, deferredSymbolTracker: DeferredSymbolTracker, forbidOrphanRendering: boolean, enableBlockSyntax: boolean, enableLetSyntax: boolean, externalRuntimeStyles: boolean, localCompilationExtraImportsTracker: LocalCompilationExtraImportsTracker | null, jitDeclarationRegistry: JitDeclarationRegistry, i18nPreserveSignificantWhitespace: boolean, strictStandalone: boolean, enableHmr: boolean, implicitStandaloneValue: boolean, typeCheckHostBindings: boolean, enableSelectorless: boolean, emitDeclarationOnly: boolean);
|
||||
private literalCache;
|
||||
private elementSchemaRegistry;
|
||||
private readonly undecoratedMetadataExtractor;
|
||||
/**
|
||||
* During the asynchronous preanalyze phase, it's necessary to parse the template to extract
|
||||
* any potential <link> tags which might need to be loaded. This cache ensures that work is not
|
||||
* thrown away, and the parsed template is reused during the analyze phase.
|
||||
*/
|
||||
private preanalyzeTemplateCache;
|
||||
private preanalyzeStylesCache;
|
||||
/** Whether generated code for a component can defer its dependencies. */
|
||||
private readonly canDeferDeps;
|
||||
private extractTemplateOptions;
|
||||
readonly precedence = HandlerPrecedence.PRIMARY;
|
||||
readonly name = "ComponentDecoratorHandler";
|
||||
detect(node: ClassDeclaration, decorators: Decorator[] | null): DetectResult<Decorator> | undefined;
|
||||
preanalyze(node: ClassDeclaration, decorator: Readonly<Decorator>): Promise<void> | undefined;
|
||||
analyze(node: ClassDeclaration, decorator: Readonly<Decorator>): AnalysisOutput<ComponentAnalysisData>;
|
||||
symbol(node: ClassDeclaration, analysis: Readonly<ComponentAnalysisData>): ComponentSymbol;
|
||||
register(node: ClassDeclaration, analysis: ComponentAnalysisData): void;
|
||||
index(context: IndexingContext, node: ClassDeclaration, analysis: Readonly<ComponentAnalysisData>): null;
|
||||
typeCheck(ctx: TypeCheckContext, node: ClassDeclaration, meta: Readonly<ComponentAnalysisData>): void;
|
||||
extendedTemplateCheck(component: ts.ClassDeclaration, extendedTemplateChecker: ExtendedTemplateChecker): ts.Diagnostic[];
|
||||
templateSemanticsCheck(component: ts.ClassDeclaration, templateSemanticsChecker: TemplateSemanticsChecker): ts.Diagnostic[];
|
||||
resolve(node: ClassDeclaration, analysis: Readonly<ComponentAnalysisData>, symbol: ComponentSymbol): ResolveResult<ComponentResolutionData>;
|
||||
xi18n(ctx: Xi18nContext, node: ClassDeclaration, analysis: Readonly<ComponentAnalysisData>): void;
|
||||
updateResources(node: ClassDeclaration, analysis: ComponentAnalysisData): void;
|
||||
compileFull(node: ClassDeclaration, analysis: Readonly<ComponentAnalysisData>, resolution: Readonly<ComponentResolutionData>, pool: ConstantPool): CompileResult[];
|
||||
compilePartial(node: ClassDeclaration, analysis: Readonly<ComponentAnalysisData>, resolution: Readonly<ComponentResolutionData>): CompileResult[];
|
||||
compileLocal(node: ClassDeclaration, analysis: Readonly<ComponentAnalysisData>, resolution: Readonly<Partial<ComponentResolutionData>>, pool: ConstantPool): CompileResult[];
|
||||
compileHmrUpdateDeclaration(node: ClassDeclaration, analysis: Readonly<ComponentAnalysisData>, resolution: Readonly<ComponentResolutionData>): ts.FunctionDeclaration | null;
|
||||
/**
|
||||
* Determines the dependencies of a component and
|
||||
* categorizes them based on how they were introduced.
|
||||
*/
|
||||
private resolveComponentDependencies;
|
||||
/**
|
||||
* Converts component dependencies into declarations by
|
||||
* resolving their metadata and deduplicating them.
|
||||
*/
|
||||
private componentDependenciesToDeclarations;
|
||||
/** Handles any cycles in the dependencies of a component. */
|
||||
private handleDependencyCycles;
|
||||
/** Produces diagnostics that require more than local information. */
|
||||
private getNonLocalDiagnostics;
|
||||
/**
|
||||
* Locates defer blocks in case scope information is not available.
|
||||
* For example, this happens in the local compilation mode.
|
||||
*/
|
||||
private locateDeferBlocksWithoutScope;
|
||||
/**
|
||||
* Computes a list of deferrable symbols based on dependencies from
|
||||
* the `@Component.imports` field and their usage in `@defer` blocks.
|
||||
*/
|
||||
private resolveAllDeferredDependencies;
|
||||
/**
|
||||
* Collects deferrable symbols from the `@Component.deferredImports` field.
|
||||
*/
|
||||
private collectExplicitlyDeferredSymbols;
|
||||
/**
|
||||
* Check whether adding an import from `origin` to the source-file corresponding to `expr` would
|
||||
* create a cyclic import.
|
||||
*
|
||||
* @returns a `Cycle` object if a cycle would be created, otherwise `null`.
|
||||
*/
|
||||
private _checkForCyclicImport;
|
||||
private maybeRecordSyntheticImport;
|
||||
/**
|
||||
* Resolves information about defer blocks dependencies to make it
|
||||
* available for the final `compile` step.
|
||||
*/
|
||||
private resolveDeferBlocks;
|
||||
/**
|
||||
* Inspects provided imports expression (either `@Component.imports` or
|
||||
* `@Component.deferredImports`) and registers imported types as deferrable
|
||||
* candidates.
|
||||
*/
|
||||
private registerDeferrableCandidate;
|
||||
private compileDeferBlocks;
|
||||
/** Creates a new binding parser. */
|
||||
private getNewBindingParser;
|
||||
}
|
||||
Generated
Vendored
+117
@@ -0,0 +1,117 @@
|
||||
/**
|
||||
* @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 { LegacyAnimationTriggerNames, DeclarationListEmitMode, DeferBlockDepsEmitMode, R3ClassDebugInfo, R3ClassMetadata, R3ComponentMetadata, R3DeferPerBlockDependency, R3DeferPerComponentDependency, R3TemplateDependencyMetadata, SchemaMetadata, TmplAstDeferredBlock } from '@angular/compiler';
|
||||
import ts from 'typescript';
|
||||
import { Reference } from '../../../imports';
|
||||
import { ClassPropertyMapping, DirectiveResources, DirectiveTypeCheckMeta, HostDirectiveMeta, InputMapping } from '../../../metadata';
|
||||
import { ClassDeclaration, Import } from '../../../reflection';
|
||||
import { SubsetOfKeys } from '../../../util/src/typescript';
|
||||
import { ParsedTemplateWithSource, StyleUrlMeta } from './resources';
|
||||
import { HostBindingNodes } from '../../directive';
|
||||
/**
|
||||
* These fields of `R3ComponentMetadata` are updated in the `resolve` phase.
|
||||
*
|
||||
* The `keyof R3ComponentMetadata &` condition ensures that only fields of `R3ComponentMetadata` can
|
||||
* be included here.
|
||||
*/
|
||||
export type ComponentMetadataResolvedFields = SubsetOfKeys<R3ComponentMetadata<R3TemplateDependencyMetadata>, 'declarations' | 'declarationListEmitMode' | 'defer' | 'hasDirectiveDependencies'>;
|
||||
export interface ComponentAnalysisData {
|
||||
/**
|
||||
* `meta` includes those fields of `R3ComponentMetadata` which are calculated at `analyze` time
|
||||
* (not during resolve).
|
||||
*/
|
||||
meta: Omit<R3ComponentMetadata<R3TemplateDependencyMetadata>, ComponentMetadataResolvedFields>;
|
||||
baseClass: Reference<ClassDeclaration> | 'dynamic' | null;
|
||||
typeCheckMeta: DirectiveTypeCheckMeta;
|
||||
template: ParsedTemplateWithSource;
|
||||
classMetadata: R3ClassMetadata | null;
|
||||
classDebugInfo: R3ClassDebugInfo | null;
|
||||
inputs: ClassPropertyMapping<InputMapping>;
|
||||
inputFieldNamesFromMetadataArray: Set<string>;
|
||||
outputs: ClassPropertyMapping;
|
||||
/**
|
||||
* Providers extracted from the `providers` field of the component annotation which will require
|
||||
* an Angular factory definition at runtime.
|
||||
*/
|
||||
providersRequiringFactory: Set<Reference<ClassDeclaration>> | null;
|
||||
/**
|
||||
* Providers extracted from the `viewProviders` field of the component annotation which will
|
||||
* require an Angular factory definition at runtime.
|
||||
*/
|
||||
viewProvidersRequiringFactory: Set<Reference<ClassDeclaration>> | null;
|
||||
resources: DirectiveResources;
|
||||
/**
|
||||
* `styleUrls` extracted from the decorator, if present.
|
||||
*/
|
||||
styleUrls: StyleUrlMeta[] | null;
|
||||
/**
|
||||
* Inline stylesheets extracted from the decorator, if present.
|
||||
*/
|
||||
inlineStyles: string[] | null;
|
||||
isPoisoned: boolean;
|
||||
legacyAnimationTriggerNames: LegacyAnimationTriggerNames | null;
|
||||
rawImports: ts.Expression | null;
|
||||
resolvedImports: Reference<ClassDeclaration>[] | null;
|
||||
rawDeferredImports: ts.Expression | null;
|
||||
resolvedDeferredImports: Reference<ClassDeclaration>[] | null;
|
||||
/**
|
||||
* Map of symbol name -> import path for types from `@Component.deferredImports` field.
|
||||
*/
|
||||
explicitlyDeferredTypes: R3DeferPerComponentDependency[] | null;
|
||||
schemas: SchemaMetadata[] | null;
|
||||
decorator: ts.Decorator | null;
|
||||
/** Additional directives applied to the component host. */
|
||||
hostDirectives: HostDirectiveMeta[] | null;
|
||||
/** Raw expression that defined the host directives array. Used for diagnostics. */
|
||||
rawHostDirectives: ts.Expression | null;
|
||||
/** Raw nodes representing the host bindings of the directive. */
|
||||
hostBindingNodes: HostBindingNodes;
|
||||
/** Whether selectorless is enabled for the specific component. */
|
||||
selectorlessEnabled: boolean;
|
||||
/**
|
||||
* Names of the symbols within the source file that are referenced directly inside the template.
|
||||
* Used to reduce the amount of lookups when determining which dependencies to expose.
|
||||
*/
|
||||
localReferencedSymbols: Set<string> | null;
|
||||
}
|
||||
export interface ComponentResolutionData {
|
||||
declarations: R3TemplateDependencyMetadata[];
|
||||
declarationListEmitMode: DeclarationListEmitMode;
|
||||
/**
|
||||
* Map of all types that can be defer loaded (ts.ClassDeclaration) ->
|
||||
* corresponding import information (reflection `Import`) within
|
||||
* the current source file. The `Import` preserves the exported name
|
||||
* as seen by the importing module so aliasing is handled correctly.
|
||||
*/
|
||||
deferrableDeclToImportDecl: Map<ClassDeclaration, Import>;
|
||||
/**
|
||||
* Map of `@defer` blocks -> their corresponding dependencies.
|
||||
* Required to compile the defer resolver function in `PerBlock` mode.
|
||||
*/
|
||||
deferPerBlockDependencies: Map<TmplAstDeferredBlock, DeferredComponentDependency[]>;
|
||||
/**
|
||||
* Defines how dynamic imports for deferred dependencies should be grouped:
|
||||
* - either in a function on per-component basis (in case of local compilation)
|
||||
* - or in a function on per-block basis (in full compilation mode)
|
||||
*/
|
||||
deferBlockDepsEmitMode: DeferBlockDepsEmitMode;
|
||||
/**
|
||||
* List of deferrable dependencies in the entire component. Used to compile the
|
||||
* defer resolver function in `PerComponent` mode.
|
||||
*/
|
||||
deferPerComponentDependencies: R3DeferPerComponentDependency[];
|
||||
/** Whether the component is standalone and has any directly-imported directive dependencies. */
|
||||
hasDirectiveDependencies: boolean;
|
||||
}
|
||||
/**
|
||||
* Describes a dependency used within a `@defer` block.
|
||||
*/
|
||||
export type DeferredComponentDependency = R3DeferPerBlockDependency & {
|
||||
/** Reference to the declaration that defines the dependency. */
|
||||
declaration: Reference<ClassDeclaration>;
|
||||
};
|
||||
Generated
Vendored
+127
@@ -0,0 +1,127 @@
|
||||
/**
|
||||
* @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 { ParsedTemplate, ParseSourceFile, TmplAstNode } from '@angular/compiler';
|
||||
import ts from 'typescript';
|
||||
import { FatalDiagnosticError } from '../../../diagnostics';
|
||||
import { DependencyTracker } from '../../../incremental/api';
|
||||
import { Resource } from '../../../metadata';
|
||||
import { PartialEvaluator } from '../../../partial_evaluator';
|
||||
import { ClassDeclaration, DeclarationNode, Decorator } from '../../../reflection';
|
||||
import { CompilationMode } from '../../../transform';
|
||||
import { SourceMapping } from '../../../typecheck/api';
|
||||
import { ResourceLoader } from '../../common';
|
||||
/**
|
||||
* The literal style url extracted from the decorator, along with metadata for diagnostics.
|
||||
*/
|
||||
export interface StyleUrlMeta {
|
||||
url: string;
|
||||
expression: ts.Expression;
|
||||
source: ResourceTypeForDiagnostics.StylesheetFromTemplate | ResourceTypeForDiagnostics.StylesheetFromDecorator;
|
||||
}
|
||||
/**
|
||||
* Information about the origin of a resource in the application code. This is used for creating
|
||||
* diagnostics, so we can point to the root cause of an error in the application code.
|
||||
*
|
||||
* A template resource comes from the `templateUrl` property on the component decorator.
|
||||
*
|
||||
* Stylesheets resources can come from either the `styleUrls` property on the component decorator,
|
||||
* or from inline `style` tags and style links on the external template.
|
||||
*/
|
||||
export declare const enum ResourceTypeForDiagnostics {
|
||||
Template = 0,
|
||||
StylesheetFromTemplate = 1,
|
||||
StylesheetFromDecorator = 2
|
||||
}
|
||||
/**
|
||||
* Information about the template which was extracted during parsing.
|
||||
*
|
||||
* This contains the actual parsed template as well as any metadata collected during its parsing,
|
||||
* some of which might be useful for re-parsing the template with different options.
|
||||
*/
|
||||
export interface ParsedComponentTemplate extends ParsedTemplate {
|
||||
/**
|
||||
* The template AST, parsed in a manner which preserves source map information for diagnostics.
|
||||
*
|
||||
* Not useful for emit.
|
||||
*/
|
||||
diagNodes: TmplAstNode[];
|
||||
/**
|
||||
* The `ParseSourceFile` for the template.
|
||||
*/
|
||||
file: ParseSourceFile;
|
||||
}
|
||||
export interface ParsedTemplateWithSource extends ParsedComponentTemplate {
|
||||
/** The string contents of the template. */
|
||||
content: string;
|
||||
sourceMapping: SourceMapping;
|
||||
declaration: TemplateDeclaration;
|
||||
}
|
||||
/**
|
||||
* Common fields extracted from the declaration of a template.
|
||||
*/
|
||||
interface CommonTemplateDeclaration {
|
||||
preserveWhitespaces: boolean;
|
||||
templateUrl: string;
|
||||
resolvedTemplateUrl: string;
|
||||
}
|
||||
/**
|
||||
* Information extracted from the declaration of an inline template.
|
||||
*/
|
||||
export interface InlineTemplateDeclaration extends CommonTemplateDeclaration {
|
||||
isInline: true;
|
||||
expression: ts.Expression;
|
||||
}
|
||||
/**
|
||||
* Information extracted from the declaration of an external template.
|
||||
*/
|
||||
export interface ExternalTemplateDeclaration extends CommonTemplateDeclaration {
|
||||
isInline: false;
|
||||
templateUrlExpression: ts.Expression;
|
||||
}
|
||||
/**
|
||||
* The declaration of a template extracted from a component decorator.
|
||||
*
|
||||
* This data is extracted and stored separately to facilitate re-interpreting the template
|
||||
* declaration whenever the compiler is notified of a change to a template file. With this
|
||||
* information, `ComponentDecoratorHandler` is able to re-read the template and update the component
|
||||
* record without needing to parse the original decorator again.
|
||||
*/
|
||||
export type TemplateDeclaration = InlineTemplateDeclaration | ExternalTemplateDeclaration;
|
||||
/** Determines the node to use for debugging purposes for the given TemplateDeclaration. */
|
||||
export declare function getTemplateDeclarationNodeForError(declaration: TemplateDeclaration): ts.Expression;
|
||||
export interface ExtractTemplateOptions {
|
||||
usePoisonedData: boolean;
|
||||
enableI18nLegacyMessageIdFormat: boolean;
|
||||
i18nNormalizeLineEndingsInICUs: boolean;
|
||||
enableBlockSyntax: boolean;
|
||||
enableLetSyntax: boolean;
|
||||
enableSelectorless: boolean;
|
||||
preserveSignificantWhitespace?: boolean;
|
||||
}
|
||||
export declare function extractTemplate(node: ClassDeclaration, template: TemplateDeclaration, evaluator: PartialEvaluator, depTracker: DependencyTracker | null, resourceLoader: ResourceLoader, options: ExtractTemplateOptions, compilationMode: CompilationMode): ParsedTemplateWithSource;
|
||||
export declare function createEmptyTemplate(componentClass: ClassDeclaration, component: Map<string, ts.Expression>, containingFile: string): ParsedTemplateWithSource;
|
||||
export declare function parseTemplateDeclaration(node: ClassDeclaration, decorator: Decorator, component: Map<string, ts.Expression>, containingFile: string, evaluator: PartialEvaluator, depTracker: DependencyTracker | null, resourceLoader: ResourceLoader, defaultPreserveWhitespaces: boolean): TemplateDeclaration;
|
||||
export declare function preloadAndParseTemplate(evaluator: PartialEvaluator, resourceLoader: ResourceLoader, depTracker: DependencyTracker | null, preanalyzeTemplateCache: Map<DeclarationNode, ParsedTemplateWithSource>, node: ClassDeclaration, decorator: Decorator, component: Map<string, ts.Expression>, containingFile: string, defaultPreserveWhitespaces: boolean, options: ExtractTemplateOptions, compilationMode: CompilationMode): Promise<ParsedTemplateWithSource | null>;
|
||||
export declare function makeResourceNotFoundError(file: string, nodeForError: ts.Node, resourceType: ResourceTypeForDiagnostics): FatalDiagnosticError;
|
||||
/**
|
||||
* Transforms the given decorator to inline external resources. i.e. if the decorator
|
||||
* resolves to `@Component`, the `templateUrl` and `styleUrls` metadata fields will be
|
||||
* transformed to their semantically-equivalent inline variants.
|
||||
*
|
||||
* This method is used for serializing decorators into the class metadata. The emitted
|
||||
* class metadata should not refer to external resources as this would be inconsistent
|
||||
* with the component definitions/declarations which already inline external resources.
|
||||
*
|
||||
* Additionally, the references to external resources would require libraries to ship
|
||||
* external resources exclusively for the class metadata.
|
||||
*/
|
||||
export declare function transformDecoratorResources(dec: Decorator, component: Map<string, ts.Expression>, styles: string[], template: ParsedTemplateWithSource): Decorator;
|
||||
export declare function extractComponentStyleUrls(evaluator: PartialEvaluator, component: Map<string, ts.Expression>): StyleUrlMeta[];
|
||||
export declare function extractInlineStyleResources(component: Map<string, ts.Expression>): Set<Resource>;
|
||||
export declare function _extractTemplateStyleUrls(template: ParsedTemplateWithSource): StyleUrlMeta[];
|
||||
export {};
|
||||
Generated
Vendored
+16
@@ -0,0 +1,16 @@
|
||||
/*!
|
||||
* @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 { TmplAstNode } from '@angular/compiler';
|
||||
/**
|
||||
* Analyzes a component's template to determine if it's using selectorless syntax
|
||||
* and to extract the names of the selectorless symbols that are referenced.
|
||||
*/
|
||||
export declare function analyzeTemplateForSelectorless(template: TmplAstNode[]): {
|
||||
isSelectorless: boolean;
|
||||
localReferencedSymbols: Set<string> | null;
|
||||
};
|
||||
Generated
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* @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 { SemanticReference, SemanticSymbol } from '../../../incremental/semantic_graph';
|
||||
import { DirectiveSymbol } from '../../directive';
|
||||
/**
|
||||
* Represents an Angular component.
|
||||
*/
|
||||
export declare class ComponentSymbol extends DirectiveSymbol {
|
||||
usedDirectives: SemanticReference[];
|
||||
usedPipes: SemanticReference[];
|
||||
isRemotelyScoped: boolean;
|
||||
isEmitAffected(previousSymbol: SemanticSymbol, publicApiAffected: Set<SemanticSymbol>): boolean;
|
||||
isTypeCheckBlockAffected(previousSymbol: SemanticSymbol, typeCheckApiAffected: Set<SemanticSymbol>): boolean;
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* @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 { LegacyAnimationTriggerNames } from '@angular/compiler';
|
||||
import ts from 'typescript';
|
||||
import { Reference } from '../../../imports';
|
||||
import { ForeignFunctionResolver, ResolvedValue } from '../../../partial_evaluator';
|
||||
import { ClassDeclaration } from '../../../reflection';
|
||||
/**
|
||||
* Collect the animation names from the static evaluation result.
|
||||
* @param value the static evaluation result of the animations
|
||||
* @param legacyAnimationTriggerNames the animation names collected and whether some names could not be
|
||||
* statically evaluated.
|
||||
*/
|
||||
export declare function collectLegacyAnimationNames(value: ResolvedValue, legacyAnimationTriggerNames: LegacyAnimationTriggerNames): void;
|
||||
export declare function isLegacyAngularAnimationsReference(reference: Reference, symbolName: string): boolean;
|
||||
export declare const legacyAnimationTriggerResolver: ForeignFunctionResolver;
|
||||
export declare function validateAndFlattenComponentImports(imports: ResolvedValue, expr: ts.Expression, isDeferred: boolean): {
|
||||
imports: Reference<ClassDeclaration>[];
|
||||
diagnostics: ts.Diagnostic[];
|
||||
};
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* @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 { DirectiveDecoratorHandler } from './src/handler';
|
||||
export { DirectiveSymbol } from './src/symbol';
|
||||
export * from './src/shared';
|
||||
export * from './src/input_function';
|
||||
export * from './src/output_function';
|
||||
export * from './src/query_functions';
|
||||
export * from './src/model_function';
|
||||
export * from './src/initializer_functions';
|
||||
Generated
Vendored
+85
@@ -0,0 +1,85 @@
|
||||
/**
|
||||
* @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 { ConstantPool, R3ClassMetadata, R3DirectiveMetadata } from '@angular/compiler';
|
||||
import ts from 'typescript';
|
||||
import { ImportedSymbolsTracker, Reference, ReferenceEmitter } from '../../../imports';
|
||||
import { SemanticDepGraphUpdater } from '../../../incremental/semantic_graph';
|
||||
import { ClassPropertyMapping, DirectiveResources, DirectiveTypeCheckMeta, HostDirectiveMeta, InputMapping, MetadataReader, MetadataRegistry, ResourceRegistry } from '../../../metadata';
|
||||
import { PartialEvaluator } from '../../../partial_evaluator';
|
||||
import { PerfRecorder } from '../../../perf';
|
||||
import { ClassDeclaration, Decorator, ReflectionHost } from '../../../reflection';
|
||||
import { LocalModuleScopeRegistry, TypeCheckScopeRegistry } from '../../../scope';
|
||||
import { AnalysisOutput, CompilationMode, CompileResult, DecoratorHandler, DetectResult, HandlerPrecedence, ResolveResult } from '../../../transform';
|
||||
import { InjectableClassRegistry, ReferencesRegistry } from '../../common';
|
||||
import { HostBindingNodes } from './shared';
|
||||
import { DirectiveSymbol } from './symbol';
|
||||
import { JitDeclarationRegistry } from '../../common/src/jit_declaration_registry';
|
||||
import { TypeCheckContext } from '../../../typecheck/api';
|
||||
export interface DirectiveHandlerData {
|
||||
baseClass: Reference<ClassDeclaration> | 'dynamic' | null;
|
||||
typeCheckMeta: DirectiveTypeCheckMeta;
|
||||
meta: R3DirectiveMetadata;
|
||||
classMetadata: R3ClassMetadata | null;
|
||||
providersRequiringFactory: Set<Reference<ClassDeclaration>> | null;
|
||||
inputs: ClassPropertyMapping<InputMapping>;
|
||||
inputFieldNamesFromMetadataArray: Set<string>;
|
||||
outputs: ClassPropertyMapping;
|
||||
isPoisoned: boolean;
|
||||
isStructural: boolean;
|
||||
decorator: ts.Decorator | null;
|
||||
hostDirectives: HostDirectiveMeta[] | null;
|
||||
rawHostDirectives: ts.Expression | null;
|
||||
hostBindingNodes: HostBindingNodes;
|
||||
resources: DirectiveResources;
|
||||
}
|
||||
export declare class DirectiveDecoratorHandler implements DecoratorHandler<Decorator | null, DirectiveHandlerData, DirectiveSymbol, unknown> {
|
||||
private reflector;
|
||||
private evaluator;
|
||||
private metaRegistry;
|
||||
private scopeRegistry;
|
||||
private metaReader;
|
||||
private injectableRegistry;
|
||||
private refEmitter;
|
||||
private referencesRegistry;
|
||||
private isCore;
|
||||
private strictCtorDeps;
|
||||
private semanticDepGraphUpdater;
|
||||
private annotateForClosureCompiler;
|
||||
private perf;
|
||||
private importTracker;
|
||||
private includeClassMetadata;
|
||||
private typeCheckScopeRegistry;
|
||||
private readonly compilationMode;
|
||||
private readonly jitDeclarationRegistry;
|
||||
private readonly resourceRegistry;
|
||||
private readonly strictStandalone;
|
||||
private readonly implicitStandaloneValue;
|
||||
private readonly usePoisonedData;
|
||||
private readonly typeCheckHostBindings;
|
||||
private readonly emitDeclarationOnly;
|
||||
constructor(reflector: ReflectionHost, evaluator: PartialEvaluator, metaRegistry: MetadataRegistry, scopeRegistry: LocalModuleScopeRegistry, metaReader: MetadataReader, injectableRegistry: InjectableClassRegistry, refEmitter: ReferenceEmitter, referencesRegistry: ReferencesRegistry, isCore: boolean, strictCtorDeps: boolean, semanticDepGraphUpdater: SemanticDepGraphUpdater | null, annotateForClosureCompiler: boolean, perf: PerfRecorder, importTracker: ImportedSymbolsTracker, includeClassMetadata: boolean, typeCheckScopeRegistry: TypeCheckScopeRegistry, compilationMode: CompilationMode, jitDeclarationRegistry: JitDeclarationRegistry, resourceRegistry: ResourceRegistry, strictStandalone: boolean, implicitStandaloneValue: boolean, usePoisonedData: boolean, typeCheckHostBindings: boolean, emitDeclarationOnly: boolean);
|
||||
readonly precedence = HandlerPrecedence.PRIMARY;
|
||||
readonly name = "DirectiveDecoratorHandler";
|
||||
private readonly undecoratedMetadataExtractor;
|
||||
detect(node: ClassDeclaration, decorators: Decorator[] | null): DetectResult<Decorator | null> | undefined;
|
||||
analyze(node: ClassDeclaration, decorator: Readonly<Decorator | null>): AnalysisOutput<DirectiveHandlerData>;
|
||||
symbol(node: ClassDeclaration, analysis: Readonly<DirectiveHandlerData>): DirectiveSymbol;
|
||||
register(node: ClassDeclaration, analysis: Readonly<DirectiveHandlerData>): void;
|
||||
typeCheck(ctx: TypeCheckContext, node: ClassDeclaration, meta: Readonly<DirectiveHandlerData>): void;
|
||||
resolve(node: ClassDeclaration, analysis: DirectiveHandlerData, symbol: DirectiveSymbol): ResolveResult<unknown>;
|
||||
compileFull(node: ClassDeclaration, analysis: Readonly<DirectiveHandlerData>, resolution: Readonly<unknown>, pool: ConstantPool): CompileResult[];
|
||||
compilePartial(node: ClassDeclaration, analysis: Readonly<DirectiveHandlerData>, resolution: Readonly<unknown>): CompileResult[];
|
||||
compileLocal(node: ClassDeclaration, analysis: Readonly<DirectiveHandlerData>, resolution: Readonly<unknown>, pool: ConstantPool): CompileResult[];
|
||||
/**
|
||||
* Checks if a given class uses Angular features and returns the TypeScript node
|
||||
* that indicated the usage. Classes are considered using Angular features if they
|
||||
* contain class members that are either decorated with a known Angular decorator,
|
||||
* or if they correspond to a known Angular lifecycle hook.
|
||||
*/
|
||||
private findClassFieldWithAngularFeatures;
|
||||
}
|
||||
Generated
Vendored
+17
@@ -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 { ClassMember } from '../../../reflection';
|
||||
import { InitializerFunctionMetadata } from './initializer_functions';
|
||||
/**
|
||||
* Validates that the initializer member is compatible with the given class
|
||||
* member in terms of field access and visibility.
|
||||
*
|
||||
* @throws {FatalDiagnosticError} If the recognized initializer API is
|
||||
* incompatible.
|
||||
*/
|
||||
export declare function validateAccessOfInitializerApiMember({ api, call }: InitializerFunctionMetadata, member: Pick<ClassMember, 'accessLevel'>): void;
|
||||
Generated
Vendored
+52
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* @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 ts from 'typescript';
|
||||
import { ImportedSymbolsTracker } from '../../../imports';
|
||||
import { ClassMemberAccessLevel, ReflectionHost } from '../../../reflection';
|
||||
/**
|
||||
* @fileoverview
|
||||
*
|
||||
* Angular exposes functions that can be used as class member initializers
|
||||
* to make use of various APIs. Those are called initializer APIs.
|
||||
*
|
||||
* Signal-based inputs are relying on initializer APIs because such inputs
|
||||
* are declared using `input` and `input.required` intersection functions.
|
||||
* Similarly, signal-based queries follow the same pattern and are also
|
||||
* declared through initializer APIs.
|
||||
*/
|
||||
export interface InitializerApiFunction {
|
||||
/** Module name where the initializer function is imported from. */
|
||||
owningModule: '@angular/core' | '@angular/core/rxjs-interop';
|
||||
/** Export name of the initializer function. */
|
||||
functionName: 'input' | 'model' | 'output' | 'outputFromObservable' | 'viewChild' | 'viewChildren' | 'contentChild' | 'contentChildren';
|
||||
/** Class member access levels compatible with the API. */
|
||||
allowedAccessLevels: ClassMemberAccessLevel[];
|
||||
}
|
||||
/**
|
||||
* Metadata describing an Angular class member that was recognized through
|
||||
* a function initializer. Like `input`, `input.required` or `viewChild`.
|
||||
*/
|
||||
export interface InitializerFunctionMetadata {
|
||||
/** Initializer API function that was recognized. */
|
||||
api: InitializerApiFunction;
|
||||
/** Node referring to the call expression. */
|
||||
call: ts.CallExpression;
|
||||
/** Whether the initializer is required or not. E.g. `input.required` was used. */
|
||||
isRequired: boolean;
|
||||
}
|
||||
/**
|
||||
* Attempts to identify an Angular initializer function call.
|
||||
*
|
||||
* Note that multiple possible initializer API function names can be specified,
|
||||
* allowing for checking multiple types in one pass.
|
||||
*
|
||||
* @returns The parsed initializer API, or null if none was found.
|
||||
*/
|
||||
export declare function tryParseInitializerApi<Functions extends InitializerApiFunction[]>(functions: Functions, expression: ts.Expression, reflector: ReflectionHost, importTracker: ImportedSymbolsTracker): (InitializerFunctionMetadata & {
|
||||
api: Functions[number];
|
||||
}) | null;
|
||||
Generated
Vendored
+18
@@ -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 { ImportedSymbolsTracker } from '../../../imports';
|
||||
import { InputMapping } from '../../../metadata';
|
||||
import { ClassMember, ReflectionHost } from '../../../reflection';
|
||||
import { InitializerApiFunction } from './initializer_functions';
|
||||
/** Represents a function that can declare an input. */
|
||||
export declare const INPUT_INITIALIZER_FN: InitializerApiFunction;
|
||||
/**
|
||||
* Attempts to parse a signal input class member. Returns the parsed
|
||||
* input mapping if possible.
|
||||
*/
|
||||
export declare function tryParseSignalInputMapping(member: Pick<ClassMember, 'name' | 'value' | 'accessLevel'>, reflector: ReflectionHost, importTracker: ImportedSymbolsTracker): InputMapping | null;
|
||||
Generated
Vendored
+18
@@ -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 ts from 'typescript';
|
||||
/**
|
||||
* Parses and validates input and output initializer function options.
|
||||
*
|
||||
* This currently only parses the `alias` option and returns it. The other
|
||||
* options for signal inputs are runtime constructs that aren't relevant at
|
||||
* compile time.
|
||||
*/
|
||||
export declare function parseAndValidateInputAndOutputOptions(optionsNode: ts.Expression): {
|
||||
alias: string | undefined;
|
||||
};
|
||||
Generated
Vendored
+17
@@ -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 { ImportedSymbolsTracker } from '../../../imports';
|
||||
import { ModelMapping } from '../../../metadata';
|
||||
import { ClassMember, ReflectionHost } from '../../../reflection';
|
||||
import { InitializerApiFunction } from './initializer_functions';
|
||||
/** Represents a function that can declare a model. */
|
||||
export declare const MODEL_INITIALIZER_FN: InitializerApiFunction;
|
||||
/**
|
||||
* Attempts to parse a model class member. Returns the parsed model mapping if possible.
|
||||
*/
|
||||
export declare function tryParseSignalModelMapping(member: Pick<ClassMember, 'name' | 'value' | 'accessLevel'>, reflector: ReflectionHost, importTracker: ImportedSymbolsTracker): ModelMapping | null;
|
||||
Generated
Vendored
+22
@@ -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 ts from 'typescript';
|
||||
import { ImportedSymbolsTracker } from '../../../imports';
|
||||
import { InputOrOutput } from '../../../metadata';
|
||||
import { ClassMember, ReflectionHost } from '../../../reflection';
|
||||
import { InitializerApiFunction } from './initializer_functions';
|
||||
/** Possible functions that can declare an output. */
|
||||
export declare const OUTPUT_INITIALIZER_FNS: InitializerApiFunction[];
|
||||
/**
|
||||
* Attempts to parse a signal output class member. Returns the parsed
|
||||
* input mapping if possible.
|
||||
*/
|
||||
export declare function tryParseInitializerBasedOutput(member: Pick<ClassMember, 'name' | 'value' | 'accessLevel'>, reflector: ReflectionHost, importTracker: ImportedSymbolsTracker): {
|
||||
call: ts.CallExpression;
|
||||
metadata: InputOrOutput;
|
||||
} | null;
|
||||
Generated
Vendored
+31
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* @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 { R3QueryMetadata } from '@angular/compiler';
|
||||
import ts from 'typescript';
|
||||
import { ImportedSymbolsTracker } from '../../../imports';
|
||||
import { ClassMember, ReflectionHost } from '../../../reflection';
|
||||
import { InitializerApiFunction } from './initializer_functions';
|
||||
/** Possible query initializer API functions. */
|
||||
export type QueryFunctionName = 'viewChild' | 'contentChild' | 'viewChildren' | 'contentChildren';
|
||||
/** Possible query initializer API functions. */
|
||||
export declare const QUERY_INITIALIZER_FNS: (InitializerApiFunction & {
|
||||
functionName: QueryFunctionName;
|
||||
})[];
|
||||
/**
|
||||
* Attempts to detect a possible query definition for the given class member.
|
||||
*
|
||||
* This function checks for all possible variants of queries and matches the
|
||||
* first one. The query is then analyzed and its resolved metadata is returned.
|
||||
*
|
||||
* @returns Resolved query metadata, or null if no query is declared.
|
||||
*/
|
||||
export declare function tryParseSignalQueryFromInitializer(member: Pick<ClassMember, 'name' | 'value' | 'accessLevel'>, reflector: ReflectionHost, importTracker: ImportedSymbolsTracker): {
|
||||
name: QueryFunctionName;
|
||||
metadata: R3QueryMetadata;
|
||||
call: ts.CallExpression;
|
||||
} | null;
|
||||
Generated
Vendored
+64
@@ -0,0 +1,64 @@
|
||||
/**
|
||||
* @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 { R3DirectiveMetadata, R3QueryMetadata } from '@angular/compiler';
|
||||
import ts from 'typescript';
|
||||
import { ImportedSymbolsTracker, Reference, ReferenceEmitter } from '../../../imports';
|
||||
import { ClassPropertyMapping, DecoratorInputTransform, HostDirectiveMeta, InputMapping, Resource } from '../../../metadata';
|
||||
import { DynamicValue, PartialEvaluator } from '../../../partial_evaluator';
|
||||
import { ClassDeclaration, Decorator, ReflectionHost } from '../../../reflection';
|
||||
import { CompilationMode } from '../../../transform';
|
||||
import { ReferencesRegistry, UndecoratedMetadataExtractor } from '../../common';
|
||||
type QueryDecoratorName = 'ViewChild' | 'ViewChildren' | 'ContentChild' | 'ContentChildren';
|
||||
export declare const queryDecoratorNames: QueryDecoratorName[];
|
||||
export interface HostBindingNodes {
|
||||
literal: ts.ObjectLiteralExpression | null;
|
||||
bindingDecorators: Set<ts.Decorator>;
|
||||
listenerDecorators: Set<ts.Decorator>;
|
||||
}
|
||||
/**
|
||||
* Helper function to extract metadata from a `Directive` or `Component`. `Directive`s without a
|
||||
* selector are allowed to be used for abstract base classes. These abstract directives should not
|
||||
* appear in the declarations of an `NgModule` and additional verification is done when processing
|
||||
* the module.
|
||||
*/
|
||||
export declare function extractDirectiveMetadata(clazz: ClassDeclaration, decorator: Readonly<Decorator>, reflector: ReflectionHost, importTracker: ImportedSymbolsTracker, evaluator: PartialEvaluator, refEmitter: ReferenceEmitter, referencesRegistry: ReferencesRegistry, isCore: boolean, annotateForClosureCompiler: boolean, compilationMode: CompilationMode, defaultSelector: string | null, strictStandalone: boolean, implicitStandaloneValue: boolean, emitDeclarationOnly: boolean): {
|
||||
jitForced: false;
|
||||
decorator: Map<string, ts.Expression>;
|
||||
metadata: R3DirectiveMetadata;
|
||||
inputs: ClassPropertyMapping<InputMapping>;
|
||||
outputs: ClassPropertyMapping;
|
||||
isStructural: boolean;
|
||||
hostDirectives: HostDirectiveMeta[] | null;
|
||||
rawHostDirectives: ts.Expression | null;
|
||||
inputFieldNamesFromMetadataArray: Set<string>;
|
||||
hostBindingNodes: HostBindingNodes;
|
||||
} | {
|
||||
jitForced: true;
|
||||
};
|
||||
export declare function extractDecoratorQueryMetadata(exprNode: ts.Node, name: string, args: ReadonlyArray<ts.Expression>, propertyName: string, reflector: ReflectionHost, evaluator: PartialEvaluator): R3QueryMetadata;
|
||||
export declare function parseDirectiveStyles(directive: Map<string, ts.Expression>, evaluator: PartialEvaluator, compilationMode: CompilationMode): null | string[];
|
||||
export declare function parseFieldStringArrayValue(directive: Map<string, ts.Expression>, field: string, evaluator: PartialEvaluator): null | string[];
|
||||
/**
|
||||
* Returns a function that can be used to extract data for the `setClassMetadata`
|
||||
* calls from undecorated directive class members.
|
||||
*/
|
||||
export declare function getDirectiveUndecoratedMetadataExtractor(reflector: ReflectionHost, importTracker: ImportedSymbolsTracker): UndecoratedMetadataExtractor;
|
||||
/**
|
||||
* Parses the `transform` function and its type for a decorator `@Input`.
|
||||
*
|
||||
* This logic verifies feasibility of extracting the transform write type
|
||||
* into a different place, so that the input write type can be captured at
|
||||
* a later point in a static acceptance member.
|
||||
*
|
||||
* Note: This is not needed for signal inputs where the transform type is
|
||||
* automatically captured in the type of the `InputSignal`.
|
||||
*
|
||||
*/
|
||||
export declare function parseDecoratorInputTransformFunction(clazz: ClassDeclaration, classPropertyName: string, value: DynamicValue | Reference, reflector: ReflectionHost, refEmitter: ReferenceEmitter, compilationMode: CompilationMode, emitDeclarationOnly: boolean): DecoratorInputTransform;
|
||||
export declare function extractHostBindingResources(nodes: HostBindingNodes): ReadonlySet<Resource>;
|
||||
export {};
|
||||
Generated
Vendored
+26
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* @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 { SemanticSymbol, SemanticTypeParameter } from '../../../incremental/semantic_graph';
|
||||
import { ClassPropertyMapping, DirectiveTypeCheckMeta, InputMapping } from '../../../metadata';
|
||||
import { ClassDeclaration } from '../../../reflection';
|
||||
/**
|
||||
* Represents an Angular directive. Components are represented by `ComponentSymbol`, which inherits
|
||||
* from this symbol.
|
||||
*/
|
||||
export declare class DirectiveSymbol extends SemanticSymbol {
|
||||
readonly selector: string | null;
|
||||
readonly inputs: ClassPropertyMapping<InputMapping>;
|
||||
readonly outputs: ClassPropertyMapping;
|
||||
readonly exportAs: string[] | null;
|
||||
readonly typeCheckMeta: DirectiveTypeCheckMeta;
|
||||
readonly typeParameters: SemanticTypeParameter[] | null;
|
||||
baseClass: SemanticSymbol | null;
|
||||
constructor(decl: ClassDeclaration, selector: string | null, inputs: ClassPropertyMapping<InputMapping>, outputs: ClassPropertyMapping, exportAs: string[] | null, typeCheckMeta: DirectiveTypeCheckMeta, typeParameters: SemanticTypeParameter[] | null);
|
||||
isPublicApiAffected(previousSymbol: SemanticSymbol): boolean;
|
||||
isTypeCheckApiAffected(previousSymbol: SemanticSymbol): boolean;
|
||||
}
|
||||
+14
@@ -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
|
||||
*/
|
||||
export { createForwardRefResolver, findAngularDecorator, getAngularDecorators, isAngularDecorator, NoopReferencesRegistry, ReferencesRegistry, ResourceLoader, ResourceLoaderContext, JitDeclarationRegistry, unwrapExpression, } from './common';
|
||||
export { ComponentDecoratorHandler } from './component';
|
||||
export { extractTemplate, ExternalTemplateDeclaration, InlineTemplateDeclaration, } from './component/src/resources';
|
||||
export { DirectiveDecoratorHandler, InitializerApiFunction, INPUT_INITIALIZER_FN, MODEL_INITIALIZER_FN, OUTPUT_INITIALIZER_FNS, QUERY_INITIALIZER_FNS, queryDecoratorNames, QueryFunctionName, tryParseInitializerApi, tryParseInitializerBasedOutput, tryParseSignalInputMapping, tryParseSignalModelMapping, tryParseSignalQueryFromInitializer, extractDecoratorQueryMetadata, parseDecoratorInputTransformFunction, } from './directive';
|
||||
export { NgModuleDecoratorHandler } from './ng_module';
|
||||
export { InjectableDecoratorHandler } from './src/injectable';
|
||||
export { PipeDecoratorHandler } from './src/pipe';
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user