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

56
node_modules/@angular/compiler-cli/bundles/chunk-6HOSNZU5.js generated vendored Executable file
View File

@@ -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
*/

1373
node_modules/@angular/compiler-cli/bundles/chunk-BPDNYZBC.js generated vendored Executable file

File diff suppressed because it is too large Load Diff

378
node_modules/@angular/compiler-cli/bundles/chunk-ERIHYHWB.js generated vendored Executable file
View File

@@ -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-VLDYFQRU.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
*/

15
node_modules/@angular/compiler-cli/bundles/chunk-G7GFT6BU.js generated vendored Executable file
View File

@@ -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
};

366
node_modules/@angular/compiler-cli/bundles/chunk-GWZQLAGK.js generated vendored Executable file
View File

@@ -0,0 +1,366 @@
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_JS_EXTENSION = /(?:\.d)?\.ts$|\.js$/;
function normalizeSeparators(path) {
return path.replace(/\\/g, "/");
}
function stripExtension(path) {
return path.replace(TS_DTS_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) {
if (fs2.stat(fs2.join(resolvedPath, child))?.isDirectory()) {
directories.push(child);
} else {
files.push(child);
}
}
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
*/

542
node_modules/@angular/compiler-cli/bundles/chunk-HYJ2H3FU.js generated vendored Executable file
View File

@@ -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
*/

301
node_modules/@angular/compiler-cli/bundles/chunk-I2BHWRAU.js generated vendored Executable file
View File

@@ -0,0 +1,301 @@
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.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);
}
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 {
propertyName: entry.key,
quoted: entry.quoted,
value: entry.value.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");
}
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
*/

5742
node_modules/@angular/compiler-cli/bundles/chunk-VLDYFQRU.js generated vendored Executable file

File diff suppressed because it is too large Load Diff

548
node_modules/@angular/compiler-cli/bundles/chunk-XC6P36QJ.js generated vendored Executable file
View File

@@ -0,0 +1,548 @@
import {createRequire as __cjsCompatRequire} from 'module';
const require = __cjsCompatRequire(import.meta.url);
import {
ImportManager,
ImportedSymbolsTracker,
TypeScriptReflectionHost,
getAngularDecorators,
isAliasImportDeclaration,
isAngularDecorator,
loadIsReferencedAliasDeclarationPatch,
queryDecoratorNames,
reflectClassMember,
tryParseInitializerBasedOutput,
tryParseSignalInputMapping,
tryParseSignalModelMapping,
tryParseSignalQueryFromInitializer
} from "./chunk-YDQJH54W.js";
// packages/compiler-cli/src/ngtsc/transform/jit/src/downlevel_decorators_transform.js
import ts from "typescript";
function isAngularDecorator2(decorator, isCore) {
return isCore || decorator.import !== null && decorator.import.from === "@angular/core";
}
var DECORATOR_INVOCATION_JSDOC_TYPE = "!Array<{type: !Function, args: (undefined|!Array<?>)}>";
function extractMetadataFromSingleDecorator(decorator, diagnostics) {
const metadataProperties = [];
const expr = decorator.expression;
switch (expr.kind) {
case ts.SyntaxKind.Identifier:
metadataProperties.push(ts.factory.createPropertyAssignment("type", expr));
break;
case ts.SyntaxKind.CallExpression:
const call = expr;
metadataProperties.push(ts.factory.createPropertyAssignment("type", call.expression));
if (call.arguments.length) {
const args = [];
for (const arg of call.arguments) {
args.push(arg);
}
const argsArrayLiteral = ts.factory.createArrayLiteralExpression(ts.factory.createNodeArray(args, true));
metadataProperties.push(ts.factory.createPropertyAssignment("args", argsArrayLiteral));
}
break;
default:
diagnostics.push({
file: decorator.getSourceFile(),
start: decorator.getStart(),
length: decorator.getEnd() - decorator.getStart(),
messageText: `${ts.SyntaxKind[decorator.kind]} not implemented in gathering decorator metadata.`,
category: ts.DiagnosticCategory.Error,
code: 0
});
break;
}
return ts.factory.createObjectLiteralExpression(metadataProperties);
}
function createCtorParametersClassProperty(diagnostics, entityNameToExpression, ctorParameters, isClosureCompilerEnabled) {
const params = [];
for (const ctorParam of ctorParameters) {
if (!ctorParam.type && ctorParam.decorators.length === 0) {
params.push(ts.factory.createNull());
continue;
}
const paramType = ctorParam.type ? typeReferenceToExpression(entityNameToExpression, ctorParam.type) : void 0;
const members = [
ts.factory.createPropertyAssignment("type", paramType || ts.factory.createIdentifier("undefined"))
];
const decorators = [];
for (const deco of ctorParam.decorators) {
decorators.push(extractMetadataFromSingleDecorator(deco, diagnostics));
}
if (decorators.length) {
members.push(ts.factory.createPropertyAssignment("decorators", ts.factory.createArrayLiteralExpression(decorators)));
}
params.push(ts.factory.createObjectLiteralExpression(members));
}
const initializer = ts.factory.createArrowFunction(void 0, void 0, [], void 0, ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken), ts.factory.createArrayLiteralExpression(params, true));
const ctorProp = ts.factory.createPropertyDeclaration([ts.factory.createToken(ts.SyntaxKind.StaticKeyword)], "ctorParameters", void 0, void 0, initializer);
if (isClosureCompilerEnabled) {
ts.setSyntheticLeadingComments(ctorProp, [
{
kind: ts.SyntaxKind.MultiLineCommentTrivia,
text: [
`*`,
` * @type {function(): !Array<(null|{`,
` * type: ?,`,
` * decorators: (undefined|${DECORATOR_INVOCATION_JSDOC_TYPE}),`,
` * })>}`,
` * @nocollapse`,
` `
].join("\n"),
pos: -1,
end: -1,
hasTrailingNewLine: true
}
]);
}
return ctorProp;
}
function typeReferenceToExpression(entityNameToExpression, node) {
let kind = node.kind;
if (ts.isLiteralTypeNode(node)) {
kind = node.literal.kind;
}
switch (kind) {
case ts.SyntaxKind.FunctionType:
case ts.SyntaxKind.ConstructorType:
return ts.factory.createIdentifier("Function");
case ts.SyntaxKind.ArrayType:
case ts.SyntaxKind.TupleType:
return ts.factory.createIdentifier("Array");
case ts.SyntaxKind.TypePredicate:
case ts.SyntaxKind.TrueKeyword:
case ts.SyntaxKind.FalseKeyword:
case ts.SyntaxKind.BooleanKeyword:
return ts.factory.createIdentifier("Boolean");
case ts.SyntaxKind.StringLiteral:
case ts.SyntaxKind.StringKeyword:
return ts.factory.createIdentifier("String");
case ts.SyntaxKind.ObjectKeyword:
return ts.factory.createIdentifier("Object");
case ts.SyntaxKind.NumberKeyword:
case ts.SyntaxKind.NumericLiteral:
return ts.factory.createIdentifier("Number");
case ts.SyntaxKind.TypeReference:
const typeRef = node;
return entityNameToExpression(typeRef.typeName);
case ts.SyntaxKind.UnionType:
const childTypeNodes = node.types.filter((t) => !(ts.isLiteralTypeNode(t) && t.literal.kind === ts.SyntaxKind.NullKeyword));
return childTypeNodes.length === 1 ? typeReferenceToExpression(entityNameToExpression, childTypeNodes[0]) : void 0;
default:
return void 0;
}
}
function symbolIsRuntimeValue(typeChecker, symbol) {
if (symbol.flags & ts.SymbolFlags.Alias) {
symbol = typeChecker.getAliasedSymbol(symbol);
}
return (symbol.flags & ts.SymbolFlags.Value & ts.SymbolFlags.ConstEnumExcludes) !== 0;
}
function getDownlevelDecoratorsTransform(typeChecker, host, diagnostics, isCore, isClosureCompilerEnabled, shouldTransformClass) {
function addJSDocTypeAnnotation(node, jsdocType) {
if (!isClosureCompilerEnabled) {
return;
}
ts.setSyntheticLeadingComments(node, [
{
kind: ts.SyntaxKind.MultiLineCommentTrivia,
text: `* @type {${jsdocType}} `,
pos: -1,
end: -1,
hasTrailingNewLine: true
}
]);
}
function createPropDecoratorsClassProperty(diagnostics2, properties) {
const entries = [];
for (const [name, decorators] of properties.entries()) {
entries.push(ts.factory.createPropertyAssignment(name, ts.factory.createArrayLiteralExpression(decorators.map((deco) => extractMetadataFromSingleDecorator(deco, diagnostics2)))));
}
const initializer = ts.factory.createObjectLiteralExpression(entries, true);
const prop = ts.factory.createPropertyDeclaration([ts.factory.createToken(ts.SyntaxKind.StaticKeyword)], "propDecorators", void 0, void 0, initializer);
addJSDocTypeAnnotation(prop, `!Object<string, ${DECORATOR_INVOCATION_JSDOC_TYPE}>`);
return prop;
}
return (context) => {
const referencedParameterTypes = loadIsReferencedAliasDeclarationPatch(context);
function entityNameToExpression(name) {
const symbol = typeChecker.getSymbolAtLocation(name);
if (!symbol || !symbolIsRuntimeValue(typeChecker, symbol) || !symbol.declarations || symbol.declarations.length === 0) {
return void 0;
}
if (ts.isQualifiedName(name)) {
const containerExpr = entityNameToExpression(name.left);
if (containerExpr === void 0) {
return void 0;
}
return ts.factory.createPropertyAccessExpression(containerExpr, name.right);
}
const decl = symbol.declarations[0];
if (isAliasImportDeclaration(decl)) {
referencedParameterTypes?.add(decl);
if (decl.name !== void 0) {
return ts.setOriginalNode(ts.factory.createIdentifier(decl.name.text), decl.name);
}
}
return ts.setOriginalNode(ts.factory.createIdentifier(name.text), name);
}
function transformClassElement(element) {
element = ts.visitEachChild(element, decoratorDownlevelVisitor, context);
const decoratorsToKeep = [];
const toLower = [];
const decorators = host.getDecoratorsOfDeclaration(element) || [];
for (const decorator of decorators) {
const decoratorNode = decorator.node;
if (!isAngularDecorator2(decorator, isCore)) {
decoratorsToKeep.push(decoratorNode);
continue;
}
toLower.push(decoratorNode);
}
if (!toLower.length)
return [void 0, element, []];
if (!element.name || !ts.isIdentifier(element.name)) {
diagnostics.push({
file: element.getSourceFile(),
start: element.getStart(),
length: element.getEnd() - element.getStart(),
messageText: `Cannot process decorators for class element with non-analyzable name.`,
category: ts.DiagnosticCategory.Error,
code: 0
});
return [void 0, element, []];
}
const elementModifiers = ts.canHaveModifiers(element) ? ts.getModifiers(element) : void 0;
let modifiers;
if (decoratorsToKeep.length || elementModifiers?.length) {
modifiers = ts.setTextRange(ts.factory.createNodeArray([...decoratorsToKeep, ...elementModifiers || []]), element.modifiers);
}
return [element.name.text, cloneClassElementWithModifiers(element, modifiers), toLower];
}
function transformConstructor(ctor) {
ctor = ts.visitEachChild(ctor, decoratorDownlevelVisitor, context);
const newParameters = [];
const oldParameters = ctor.parameters;
const parametersInfo = [];
for (const param of oldParameters) {
const decoratorsToKeep = [];
const paramInfo = { decorators: [], type: null };
const decorators = host.getDecoratorsOfDeclaration(param) || [];
for (const decorator of decorators) {
const decoratorNode = decorator.node;
if (!isAngularDecorator2(decorator, isCore)) {
decoratorsToKeep.push(decoratorNode);
continue;
}
paramInfo.decorators.push(decoratorNode);
}
if (param.type) {
paramInfo.type = param.type;
}
parametersInfo.push(paramInfo);
let modifiers;
const paramModifiers = ts.getModifiers(param);
if (decoratorsToKeep.length || paramModifiers?.length) {
modifiers = [...decoratorsToKeep, ...paramModifiers || []];
}
const newParam = ts.factory.updateParameterDeclaration(param, modifiers, param.dotDotDotToken, param.name, param.questionToken, param.type, param.initializer);
newParameters.push(newParam);
}
const updated = ts.factory.updateConstructorDeclaration(ctor, ts.getModifiers(ctor), newParameters, ctor.body);
return [updated, parametersInfo];
}
function transformClassDeclaration(classDecl) {
const newMembers = [];
const decoratedProperties = /* @__PURE__ */ new Map();
let classParameters = null;
for (const member of classDecl.members) {
switch (member.kind) {
case ts.SyntaxKind.PropertyDeclaration:
case ts.SyntaxKind.GetAccessor:
case ts.SyntaxKind.SetAccessor:
case ts.SyntaxKind.MethodDeclaration: {
const [name, newMember, decorators] = transformClassElement(member);
newMembers.push(newMember);
if (name)
decoratedProperties.set(name, decorators);
continue;
}
case ts.SyntaxKind.Constructor: {
const ctor = member;
if (!ctor.body)
break;
const [newMember, parametersInfo] = transformConstructor(member);
classParameters = parametersInfo;
newMembers.push(newMember);
continue;
}
default:
break;
}
newMembers.push(ts.visitEachChild(member, decoratorDownlevelVisitor, context));
}
const possibleAngularDecorators = host.getDecoratorsOfDeclaration(classDecl) || [];
const hasAngularDecorator = possibleAngularDecorators.some((d) => isAngularDecorator2(d, isCore));
if (classParameters) {
if (hasAngularDecorator || classParameters.some((p) => !!p.decorators.length)) {
newMembers.push(createCtorParametersClassProperty(diagnostics, entityNameToExpression, classParameters, isClosureCompilerEnabled));
}
}
if (decoratedProperties.size) {
newMembers.push(createPropDecoratorsClassProperty(diagnostics, decoratedProperties));
}
const members = ts.setTextRange(ts.factory.createNodeArray(newMembers, classDecl.members.hasTrailingComma), classDecl.members);
return ts.factory.updateClassDeclaration(classDecl, classDecl.modifiers, classDecl.name, classDecl.typeParameters, classDecl.heritageClauses, members);
}
function decoratorDownlevelVisitor(node) {
if (ts.isClassDeclaration(node) && (shouldTransformClass === void 0 || shouldTransformClass(node))) {
return transformClassDeclaration(node);
}
return ts.visitEachChild(node, decoratorDownlevelVisitor, context);
}
return (sf) => {
return ts.visitEachChild(sf, decoratorDownlevelVisitor, context);
};
};
}
function cloneClassElementWithModifiers(node, modifiers) {
let clone;
if (ts.isMethodDeclaration(node)) {
clone = ts.factory.createMethodDeclaration(modifiers, node.asteriskToken, node.name, node.questionToken, node.typeParameters, node.parameters, node.type, node.body);
} else if (ts.isPropertyDeclaration(node)) {
clone = ts.factory.createPropertyDeclaration(modifiers, node.name, node.questionToken, node.type, node.initializer);
} else if (ts.isGetAccessor(node)) {
clone = ts.factory.createGetAccessorDeclaration(modifiers, node.name, node.parameters, node.type, node.body);
} else if (ts.isSetAccessor(node)) {
clone = ts.factory.createSetAccessorDeclaration(modifiers, node.name, node.parameters, node.body);
} else {
throw new Error(`Unsupported decorated member with kind ${ts.SyntaxKind[node.kind]}`);
}
return ts.setOriginalNode(clone, node);
}
// packages/compiler-cli/src/ngtsc/transform/jit/src/initializer_api_transforms/transform.js
import ts4 from "typescript";
// packages/compiler-cli/src/ngtsc/transform/jit/src/initializer_api_transforms/transform_api.js
import ts2 from "typescript";
function createSyntheticAngularCoreDecoratorAccess(factory, importManager, ngClassDecorator, sourceFile, decoratorName) {
const classDecoratorIdentifier = ts2.isIdentifier(ngClassDecorator.identifier) ? ngClassDecorator.identifier : ngClassDecorator.identifier.expression;
return factory.createPropertyAccessExpression(
importManager.addImport({
exportModuleSpecifier: "@angular/core",
exportSymbolName: null,
requestedFile: sourceFile
}),
// The synthetic identifier may be checked later by the downlevel decorators
// transform to resolve to an Angular import using `getSymbolAtLocation`. We trick
// the transform to think it's not synthetic and comes from Angular core.
ts2.setOriginalNode(factory.createIdentifier(decoratorName), classDecoratorIdentifier)
);
}
function castAsAny(factory, expr) {
return factory.createAsExpression(expr, factory.createKeywordTypeNode(ts2.SyntaxKind.AnyKeyword));
}
// packages/compiler-cli/src/ngtsc/transform/jit/src/initializer_api_transforms/input_function.js
var signalInputsTransform = (member, sourceFile, host, factory, importTracker, importManager, classDecorator, isCore) => {
if (host.getDecoratorsOfDeclaration(member.node)?.some((d) => isAngularDecorator(d, "Input", isCore))) {
return member.node;
}
const inputMapping = tryParseSignalInputMapping(member, host, importTracker);
if (inputMapping === null) {
return member.node;
}
const fields = {
"isSignal": factory.createTrue(),
"alias": factory.createStringLiteral(inputMapping.bindingPropertyName),
"required": inputMapping.required ? factory.createTrue() : factory.createFalse(),
// For signal inputs, transforms are captured by the input signal. The runtime will
// determine whether a transform needs to be run via the input signal, so the `transform`
// option is always `undefined`.
"transform": factory.createIdentifier("undefined")
};
const newDecorator = factory.createDecorator(factory.createCallExpression(createSyntheticAngularCoreDecoratorAccess(factory, importManager, classDecorator, sourceFile, "Input"), void 0, [
// Cast to `any` because `isSignal` will be private, and in case this
// transform is used directly as a pre-compilation step, the decorator should
// not fail. It is already validated now due to us parsing the input metadata.
castAsAny(factory, factory.createObjectLiteralExpression(Object.entries(fields).map(([name, value]) => factory.createPropertyAssignment(name, value))))
]));
return factory.updatePropertyDeclaration(member.node, [newDecorator, ...member.node.modifiers ?? []], member.name, member.node.questionToken, member.node.type, member.node.initializer);
};
// packages/compiler-cli/src/ngtsc/transform/jit/src/initializer_api_transforms/model_function.js
import ts3 from "typescript";
var signalModelTransform = (member, sourceFile, host, factory, importTracker, importManager, classDecorator, isCore) => {
if (host.getDecoratorsOfDeclaration(member.node)?.some((d) => {
return isAngularDecorator(d, "Input", isCore) || isAngularDecorator(d, "Output", isCore);
})) {
return member.node;
}
const modelMapping = tryParseSignalModelMapping(member, host, importTracker);
if (modelMapping === null) {
return member.node;
}
const inputConfig = factory.createObjectLiteralExpression([
factory.createPropertyAssignment("isSignal", modelMapping.input.isSignal ? factory.createTrue() : factory.createFalse()),
factory.createPropertyAssignment("alias", factory.createStringLiteral(modelMapping.input.bindingPropertyName)),
factory.createPropertyAssignment("required", modelMapping.input.required ? factory.createTrue() : factory.createFalse())
]);
const inputDecorator = createDecorator(
"Input",
// Config is cast to `any` because `isSignal` will be private, and in case this
// transform is used directly as a pre-compilation step, the decorator should
// not fail. It is already validated now due to us parsing the input metadata.
factory.createAsExpression(inputConfig, factory.createKeywordTypeNode(ts3.SyntaxKind.AnyKeyword)),
classDecorator,
factory,
sourceFile,
importManager
);
const outputDecorator = createDecorator("Output", factory.createStringLiteral(modelMapping.output.bindingPropertyName), classDecorator, factory, sourceFile, importManager);
return factory.updatePropertyDeclaration(member.node, [inputDecorator, outputDecorator, ...member.node.modifiers ?? []], member.node.name, member.node.questionToken, member.node.type, member.node.initializer);
};
function createDecorator(name, config, classDecorator, factory, sourceFile, importManager) {
const callTarget = createSyntheticAngularCoreDecoratorAccess(factory, importManager, classDecorator, sourceFile, name);
return factory.createDecorator(factory.createCallExpression(callTarget, void 0, [config]));
}
// packages/compiler-cli/src/ngtsc/transform/jit/src/initializer_api_transforms/output_function.js
var initializerApiOutputTransform = (member, sourceFile, host, factory, importTracker, importManager, classDecorator, isCore) => {
if (host.getDecoratorsOfDeclaration(member.node)?.some((d) => isAngularDecorator(d, "Output", isCore))) {
return member.node;
}
const output = tryParseInitializerBasedOutput(member, host, importTracker);
if (output === null) {
return member.node;
}
const newDecorator = factory.createDecorator(factory.createCallExpression(createSyntheticAngularCoreDecoratorAccess(factory, importManager, classDecorator, sourceFile, "Output"), void 0, [factory.createStringLiteral(output.metadata.bindingPropertyName)]));
return factory.updatePropertyDeclaration(member.node, [newDecorator, ...member.node.modifiers ?? []], member.node.name, member.node.questionToken, member.node.type, member.node.initializer);
};
// packages/compiler-cli/src/ngtsc/transform/jit/src/initializer_api_transforms/query_functions.js
var queryFunctionToDecorator = {
"viewChild": "ViewChild",
"viewChildren": "ViewChildren",
"contentChild": "ContentChild",
"contentChildren": "ContentChildren"
};
var queryFunctionsTransforms = (member, sourceFile, host, factory, importTracker, importManager, classDecorator, isCore) => {
const decorators = host.getDecoratorsOfDeclaration(member.node);
const queryDecorators = decorators && getAngularDecorators(decorators, queryDecoratorNames, isCore);
if (queryDecorators !== null && queryDecorators.length > 0) {
return member.node;
}
const queryDefinition = tryParseSignalQueryFromInitializer(member, host, importTracker);
if (queryDefinition === null) {
return member.node;
}
const callArgs = queryDefinition.call.arguments;
const newDecorator = factory.createDecorator(factory.createCallExpression(
createSyntheticAngularCoreDecoratorAccess(factory, importManager, classDecorator, sourceFile, queryFunctionToDecorator[queryDefinition.name]),
void 0,
// All positional arguments of the query functions can be mostly re-used as is
// for the decorator. i.e. predicate is always first argument. Options are second.
[
queryDefinition.call.arguments[0],
// Note: Casting as `any` because `isSignal` is not publicly exposed and this
// transform might pre-transform TS sources.
castAsAny(factory, factory.createObjectLiteralExpression([
...callArgs.length > 1 ? [factory.createSpreadAssignment(callArgs[1])] : [],
factory.createPropertyAssignment("isSignal", factory.createTrue())
]))
]
));
return factory.updatePropertyDeclaration(member.node, [newDecorator, ...member.node.modifiers ?? []], member.node.name, member.node.questionToken, member.node.type, member.node.initializer);
};
// packages/compiler-cli/src/ngtsc/transform/jit/src/initializer_api_transforms/transform.js
var decoratorsWithInputs = ["Directive", "Component"];
var propertyTransforms = [
signalInputsTransform,
initializerApiOutputTransform,
queryFunctionsTransforms,
signalModelTransform
];
function getInitializerApiJitTransform(host, importTracker, isCore, shouldTransformClass) {
return (ctx) => {
return (sourceFile) => {
const importManager = new ImportManager();
sourceFile = ts4.visitNode(sourceFile, createTransformVisitor(ctx, host, importManager, importTracker, isCore, shouldTransformClass), ts4.isSourceFile);
return importManager.transformTsFile(ctx, sourceFile);
};
};
}
function createTransformVisitor(ctx, host, importManager, importTracker, isCore, shouldTransformClass) {
const visitor = (node) => {
if (ts4.isClassDeclaration(node) && node.name !== void 0) {
const originalNode = ts4.getOriginalNode(node, ts4.isClassDeclaration);
const angularDecorator = host.getDecoratorsOfDeclaration(originalNode)?.find((d) => decoratorsWithInputs.some((name) => isAngularDecorator(d, name, isCore)));
if (angularDecorator !== void 0 && (shouldTransformClass === void 0 || shouldTransformClass(node))) {
let hasChanged = false;
const sourceFile = originalNode.getSourceFile();
const members = node.members.map((memberNode) => {
if (!ts4.isPropertyDeclaration(memberNode)) {
return memberNode;
}
const member = reflectClassMember(memberNode);
if (member === null) {
return memberNode;
}
for (const transform of propertyTransforms) {
const newNode = transform({ ...member, node: memberNode }, sourceFile, host, ctx.factory, importTracker, importManager, angularDecorator, isCore);
if (newNode !== member.node) {
hasChanged = true;
return newNode;
}
}
return memberNode;
});
if (hasChanged) {
return ctx.factory.updateClassDeclaration(node, node.modifiers, node.name, node.typeParameters, node.heritageClauses, members);
}
}
}
return ts4.visitEachChild(node, visitor, ctx);
};
return visitor;
}
// packages/compiler-cli/src/ngtsc/transform/jit/src/index.js
function angularJitApplicationTransform(program, isCore = false, shouldTransformClass) {
const typeChecker = program.getTypeChecker();
const reflectionHost = new TypeScriptReflectionHost(typeChecker);
const importTracker = new ImportedSymbolsTracker();
const downlevelDecoratorTransform = getDownlevelDecoratorsTransform(
typeChecker,
reflectionHost,
[],
isCore,
/* enableClosureCompiler */
false,
shouldTransformClass
);
const initializerApisJitTransform = getInitializerApiJitTransform(reflectionHost, importTracker, isCore, shouldTransformClass);
return (ctx) => {
return (sourceFile) => {
sourceFile = initializerApisJitTransform(ctx)(sourceFile);
sourceFile = downlevelDecoratorTransform(ctx)(sourceFile);
return sourceFile;
};
};
}
export {
getDownlevelDecoratorsTransform,
getInitializerApiJitTransform,
angularJitApplicationTransform
};
/**
* @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
node_modules/@angular/compiler-cli/bundles/chunk-XYYEESKY.js generated vendored Executable file
View File

@@ -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
*/

22066
node_modules/@angular/compiler-cli/bundles/chunk-YDQJH54W.js generated vendored Executable file

File diff suppressed because it is too large Load Diff

244
node_modules/@angular/compiler-cli/bundles/index.js generated vendored Executable file
View File

@@ -0,0 +1,244 @@
import {createRequire as __cjsCompatRequire} from 'module';
const require = __cjsCompatRequire(import.meta.url);
import {
DEFAULT_ERROR_CODE,
DecoratorType,
DocsExtractor,
EmitFlags,
EntryType,
MemberTags,
MemberType,
NgCompiler,
NgCompilerHost,
NgtscProgram,
PatchedProgramIncrementalBuildStrategy,
SOURCE,
UNKNOWN_ERROR_CODE,
calcProjectFileAndBasePath,
createCompilerHost,
createProgram,
defaultGatherDiagnostics,
exitCodeFromResult,
formatDiagnostics,
freshCompilationTicket,
incrementalFromStateTicket,
isDocEntryWithSourceInfo,
isTsDiagnostic,
performCompilation,
readConfiguration
} from "./chunk-VLDYFQRU.js";
import {
ConsoleLogger,
LogLevel
} from "./chunk-6HOSNZU5.js";
import {
angularJitApplicationTransform,
getDownlevelDecoratorsTransform,
getInitializerApiJitTransform
} from "./chunk-XC6P36QJ.js";
import {
ActivePerfRecorder,
ErrorCode,
OptimizeFor,
PerfPhase,
TsCreateProgramDriver,
isLocalCompilationDiagnostics,
ngErrorCode
} from "./chunk-YDQJH54W.js";
import "./chunk-I2BHWRAU.js";
import {
InvalidFileSystem,
LogicalFileSystem,
LogicalProjectPath,
NgtscCompilerHost,
absoluteFrom,
absoluteFromSourceFile,
basename,
createFileSystemTsReadDirectoryFn,
dirname,
getFileSystem,
getSourceFileOrError,
isLocalRelativePath,
isRoot,
isRooted,
join,
relative,
relativeFrom,
resolve,
setFileSystem,
toRelativeImport
} from "./chunk-GWZQLAGK.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("20.3.11");
// 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
*/

View File

@@ -0,0 +1,497 @@
import {createRequire as __cjsCompatRequire} from 'module';
const require = __cjsCompatRequire(import.meta.url);
import {
FatalLinkerError,
FileLinker,
LinkerEnvironment,
assert,
isFatalLinkerError
} from "../../chunk-BPDNYZBC.js";
import {
ConsoleLogger,
LogLevel
} from "../../chunk-6HOSNZU5.js";
import "../../chunk-HYJ2H3FU.js";
import "../../chunk-I2BHWRAU.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;
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 = t.newExpression;
createObjectLiteral(properties) {
return t.objectExpression(properties.map((prop) => {
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 = t.returnStatement;
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)
]);
}
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
node_modules/@angular/compiler-cli/bundles/linker/index.js generated vendored Executable file
View File

@@ -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-BPDNYZBC.js";
import "../chunk-HYJ2H3FU.js";
import "../chunk-I2BHWRAU.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
*/

View File

@@ -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-GWZQLAGK.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
*/

View File

@@ -0,0 +1,39 @@
import {createRequire as __cjsCompatRequire} from 'module';
const require = __cjsCompatRequire(import.meta.url);
import {
DynamicValue,
ImportManager,
PartialEvaluator,
PotentialImportKind,
PotentialImportMode,
Reference,
StaticInterpreter,
TypeScriptReflectionHost,
createForwardRefResolver,
reflectObjectLiteral
} from "../chunk-YDQJH54W.js";
import "../chunk-I2BHWRAU.js";
import "../chunk-GWZQLAGK.js";
import "../chunk-XYYEESKY.js";
import "../chunk-G7GFT6BU.js";
export {
DynamicValue,
ImportManager,
PartialEvaluator,
PotentialImportKind,
PotentialImportMode,
Reference,
StaticInterpreter,
TypeScriptReflectionHost,
createForwardRefResolver,
reflectObjectLiteral
};
/**
* @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
*/

View File

@@ -0,0 +1,37 @@
import {createRequire as __cjsCompatRequire} from 'module';
const require = __cjsCompatRequire(import.meta.url);
import {
angularJitApplicationTransform
} from "../chunk-XC6P36QJ.js";
import "../chunk-YDQJH54W.js";
import "../chunk-I2BHWRAU.js";
import "../chunk-GWZQLAGK.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
*/

View File

@@ -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-ERIHYHWB.js";
import {
EmitFlags
} from "../../chunk-VLDYFQRU.js";
import "../../chunk-XC6P36QJ.js";
import "../../chunk-YDQJH54W.js";
import "../../chunk-I2BHWRAU.js";
import {
setFileSystem
} from "../../chunk-GWZQLAGK.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
node_modules/@angular/compiler-cli/bundles/src/bin/ngc.js generated vendored Executable file
View File

@@ -0,0 +1,39 @@
#!/usr/bin/env node
import {createRequire as __cjsCompatRequire} from 'module';
const require = __cjsCompatRequire(import.meta.url);
import {
main
} from "../../chunk-ERIHYHWB.js";
import "../../chunk-VLDYFQRU.js";
import "../../chunk-XC6P36QJ.js";
import "../../chunk-YDQJH54W.js";
import "../../chunk-I2BHWRAU.js";
import {
setFileSystem
} from "../../chunk-GWZQLAGK.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
*/