chunk-K2U2VZ7S.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410
  1. import {createRequire as __cjsCompatRequire} from 'module';
  2. const require = __cjsCompatRequire(import.meta.url);
  3. import {
  4. __require
  5. } from "./chunk-SRFZMXHZ.js";
  6. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/file_system/src/util.mjs
  7. var TS_DTS_JS_EXTENSION = /(?:\.d)?\.ts$|\.js$/;
  8. function normalizeSeparators(path) {
  9. return path.replace(/\\/g, "/");
  10. }
  11. function stripExtension(path) {
  12. return path.replace(TS_DTS_JS_EXTENSION, "");
  13. }
  14. function getSourceFileOrError(program, fileName) {
  15. const sf = program.getSourceFile(fileName);
  16. if (sf === void 0) {
  17. throw new Error(`Program does not contain "${fileName}" - available files are ${program.getSourceFiles().map((sf2) => sf2.fileName).join(", ")}`);
  18. }
  19. return sf;
  20. }
  21. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/file_system/src/invalid_file_system.mjs
  22. var InvalidFileSystem = class {
  23. exists(path) {
  24. throw makeError();
  25. }
  26. readFile(path) {
  27. throw makeError();
  28. }
  29. readFileBuffer(path) {
  30. throw makeError();
  31. }
  32. writeFile(path, data, exclusive) {
  33. throw makeError();
  34. }
  35. removeFile(path) {
  36. throw makeError();
  37. }
  38. symlink(target, path) {
  39. throw makeError();
  40. }
  41. readdir(path) {
  42. throw makeError();
  43. }
  44. lstat(path) {
  45. throw makeError();
  46. }
  47. stat(path) {
  48. throw makeError();
  49. }
  50. pwd() {
  51. throw makeError();
  52. }
  53. chdir(path) {
  54. throw makeError();
  55. }
  56. extname(path) {
  57. throw makeError();
  58. }
  59. copyFile(from, to) {
  60. throw makeError();
  61. }
  62. moveFile(from, to) {
  63. throw makeError();
  64. }
  65. ensureDir(path) {
  66. throw makeError();
  67. }
  68. removeDeep(path) {
  69. throw makeError();
  70. }
  71. isCaseSensitive() {
  72. throw makeError();
  73. }
  74. resolve(...paths) {
  75. throw makeError();
  76. }
  77. dirname(file) {
  78. throw makeError();
  79. }
  80. join(basePath, ...paths) {
  81. throw makeError();
  82. }
  83. isRoot(path) {
  84. throw makeError();
  85. }
  86. isRooted(path) {
  87. throw makeError();
  88. }
  89. relative(from, to) {
  90. throw makeError();
  91. }
  92. basename(filePath, extension) {
  93. throw makeError();
  94. }
  95. realpath(filePath) {
  96. throw makeError();
  97. }
  98. getDefaultLibLocation() {
  99. throw makeError();
  100. }
  101. normalize(path) {
  102. throw makeError();
  103. }
  104. };
  105. function makeError() {
  106. return new Error("FileSystem has not been configured. Please call `setFileSystem()` before calling this method.");
  107. }
  108. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/file_system/src/helpers.mjs
  109. var fs = new InvalidFileSystem();
  110. function getFileSystem() {
  111. return fs;
  112. }
  113. function setFileSystem(fileSystem) {
  114. fs = fileSystem;
  115. }
  116. function absoluteFrom(path) {
  117. if (!fs.isRooted(path)) {
  118. throw new Error(`Internal Error: absoluteFrom(${path}): path is not absolute`);
  119. }
  120. return fs.resolve(path);
  121. }
  122. var ABSOLUTE_PATH = Symbol("AbsolutePath");
  123. function absoluteFromSourceFile(sf) {
  124. const sfWithPatch = sf;
  125. if (sfWithPatch[ABSOLUTE_PATH] === void 0) {
  126. sfWithPatch[ABSOLUTE_PATH] = fs.resolve(sfWithPatch.fileName);
  127. }
  128. return sfWithPatch[ABSOLUTE_PATH];
  129. }
  130. function relativeFrom(path) {
  131. const normalized = normalizeSeparators(path);
  132. if (fs.isRooted(normalized)) {
  133. throw new Error(`Internal Error: relativeFrom(${path}): path is not relative`);
  134. }
  135. return normalized;
  136. }
  137. function dirname(file) {
  138. return fs.dirname(file);
  139. }
  140. function join(basePath, ...paths) {
  141. return fs.join(basePath, ...paths);
  142. }
  143. function resolve(basePath, ...paths) {
  144. return fs.resolve(basePath, ...paths);
  145. }
  146. function isRoot(path) {
  147. return fs.isRoot(path);
  148. }
  149. function isRooted(path) {
  150. return fs.isRooted(path);
  151. }
  152. function relative(from, to) {
  153. return fs.relative(from, to);
  154. }
  155. function basename(filePath, extension) {
  156. return fs.basename(filePath, extension);
  157. }
  158. function isLocalRelativePath(relativePath) {
  159. return !isRooted(relativePath) && !relativePath.startsWith("..");
  160. }
  161. function toRelativeImport(relativePath) {
  162. return isLocalRelativePath(relativePath) ? `./${relativePath}` : relativePath;
  163. }
  164. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/file_system/src/compiler_host.mjs
  165. import * as os from "os";
  166. import ts from "typescript";
  167. var NgtscCompilerHost = class {
  168. constructor(fs3, options = {}) {
  169. this.fs = fs3;
  170. this.options = options;
  171. }
  172. getSourceFile(fileName, languageVersion) {
  173. const text = this.readFile(fileName);
  174. return text !== void 0 ? ts.createSourceFile(fileName, text, languageVersion, true) : void 0;
  175. }
  176. getDefaultLibFileName(options) {
  177. return this.fs.join(this.getDefaultLibLocation(), ts.getDefaultLibFileName(options));
  178. }
  179. getDefaultLibLocation() {
  180. return this.fs.getDefaultLibLocation();
  181. }
  182. writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles) {
  183. const path = absoluteFrom(fileName);
  184. this.fs.ensureDir(this.fs.dirname(path));
  185. this.fs.writeFile(path, data);
  186. }
  187. getCurrentDirectory() {
  188. return this.fs.pwd();
  189. }
  190. getCanonicalFileName(fileName) {
  191. return this.useCaseSensitiveFileNames() ? fileName : fileName.toLowerCase();
  192. }
  193. useCaseSensitiveFileNames() {
  194. return this.fs.isCaseSensitive();
  195. }
  196. getNewLine() {
  197. switch (this.options.newLine) {
  198. case ts.NewLineKind.CarriageReturnLineFeed:
  199. return "\r\n";
  200. case ts.NewLineKind.LineFeed:
  201. return "\n";
  202. default:
  203. return os.EOL;
  204. }
  205. }
  206. fileExists(fileName) {
  207. const absPath = this.fs.resolve(fileName);
  208. return this.fs.exists(absPath) && this.fs.stat(absPath).isFile();
  209. }
  210. readFile(fileName) {
  211. const absPath = this.fs.resolve(fileName);
  212. if (!this.fileExists(absPath)) {
  213. return void 0;
  214. }
  215. return this.fs.readFile(absPath);
  216. }
  217. realpath(path) {
  218. return this.fs.realpath(this.fs.resolve(path));
  219. }
  220. };
  221. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/file_system/src/logical.mjs
  222. var LogicalProjectPath = {
  223. relativePathBetween: function(from, to) {
  224. const relativePath = relative(dirname(resolve(from)), resolve(to));
  225. return toRelativeImport(relativePath);
  226. }
  227. };
  228. var LogicalFileSystem = class {
  229. constructor(rootDirs, compilerHost) {
  230. this.compilerHost = compilerHost;
  231. this.cache = /* @__PURE__ */ new Map();
  232. this.rootDirs = rootDirs.concat([]).sort((a, b) => b.length - a.length);
  233. this.canonicalRootDirs = this.rootDirs.map((dir) => this.compilerHost.getCanonicalFileName(dir));
  234. }
  235. logicalPathOfSf(sf) {
  236. return this.logicalPathOfFile(absoluteFromSourceFile(sf));
  237. }
  238. logicalPathOfFile(physicalFile) {
  239. if (!this.cache.has(physicalFile)) {
  240. const canonicalFilePath = this.compilerHost.getCanonicalFileName(physicalFile);
  241. let logicalFile = null;
  242. for (let i = 0; i < this.rootDirs.length; i++) {
  243. const rootDir = this.rootDirs[i];
  244. const canonicalRootDir = this.canonicalRootDirs[i];
  245. if (isWithinBasePath(canonicalRootDir, canonicalFilePath)) {
  246. logicalFile = this.createLogicalProjectPath(physicalFile, rootDir);
  247. if (logicalFile.indexOf("/node_modules/") !== -1) {
  248. logicalFile = null;
  249. } else {
  250. break;
  251. }
  252. }
  253. }
  254. this.cache.set(physicalFile, logicalFile);
  255. }
  256. return this.cache.get(physicalFile);
  257. }
  258. createLogicalProjectPath(file, rootDir) {
  259. const logicalPath = stripExtension(file.slice(rootDir.length));
  260. return logicalPath.startsWith("/") ? logicalPath : "/" + logicalPath;
  261. }
  262. };
  263. function isWithinBasePath(base, path) {
  264. return isLocalRelativePath(relative(base, path));
  265. }
  266. // bazel-out/darwin-fastbuild/bin/packages/compiler-cli/src/ngtsc/file_system/src/node_js_file_system.mjs
  267. import fs2 from "fs";
  268. import module from "module";
  269. import * as p from "path";
  270. import { fileURLToPath } from "url";
  271. var NodeJSPathManipulation = class {
  272. pwd() {
  273. return this.normalize(process.cwd());
  274. }
  275. chdir(dir) {
  276. process.chdir(dir);
  277. }
  278. resolve(...paths) {
  279. return this.normalize(p.resolve(...paths));
  280. }
  281. dirname(file) {
  282. return this.normalize(p.dirname(file));
  283. }
  284. join(basePath, ...paths) {
  285. return this.normalize(p.join(basePath, ...paths));
  286. }
  287. isRoot(path) {
  288. return this.dirname(path) === this.normalize(path);
  289. }
  290. isRooted(path) {
  291. return p.isAbsolute(path);
  292. }
  293. relative(from, to) {
  294. return this.normalize(p.relative(from, to));
  295. }
  296. basename(filePath, extension) {
  297. return p.basename(filePath, extension);
  298. }
  299. extname(path) {
  300. return p.extname(path);
  301. }
  302. normalize(path) {
  303. return path.replace(/\\/g, "/");
  304. }
  305. };
  306. var isCommonJS = typeof __filename !== "undefined";
  307. var currentFileUrl = isCommonJS ? null : import.meta.url;
  308. var currentFileName = isCommonJS ? __filename : fileURLToPath(currentFileUrl);
  309. var NodeJSReadonlyFileSystem = class extends NodeJSPathManipulation {
  310. constructor() {
  311. super(...arguments);
  312. this._caseSensitive = void 0;
  313. }
  314. isCaseSensitive() {
  315. if (this._caseSensitive === void 0) {
  316. this._caseSensitive = !fs2.existsSync(this.normalize(toggleCase(currentFileName)));
  317. }
  318. return this._caseSensitive;
  319. }
  320. exists(path) {
  321. return fs2.existsSync(path);
  322. }
  323. readFile(path) {
  324. return fs2.readFileSync(path, "utf8");
  325. }
  326. readFileBuffer(path) {
  327. return fs2.readFileSync(path);
  328. }
  329. readdir(path) {
  330. return fs2.readdirSync(path);
  331. }
  332. lstat(path) {
  333. return fs2.lstatSync(path);
  334. }
  335. stat(path) {
  336. return fs2.statSync(path);
  337. }
  338. realpath(path) {
  339. return this.resolve(fs2.realpathSync(path));
  340. }
  341. getDefaultLibLocation() {
  342. const requireFn = isCommonJS ? __require : module.createRequire(currentFileUrl);
  343. return this.resolve(requireFn.resolve("typescript"), "..");
  344. }
  345. };
  346. var NodeJSFileSystem = class extends NodeJSReadonlyFileSystem {
  347. writeFile(path, data, exclusive = false) {
  348. fs2.writeFileSync(path, data, exclusive ? { flag: "wx" } : void 0);
  349. }
  350. removeFile(path) {
  351. fs2.unlinkSync(path);
  352. }
  353. symlink(target, path) {
  354. fs2.symlinkSync(target, path);
  355. }
  356. copyFile(from, to) {
  357. fs2.copyFileSync(from, to);
  358. }
  359. moveFile(from, to) {
  360. fs2.renameSync(from, to);
  361. }
  362. ensureDir(path) {
  363. fs2.mkdirSync(path, { recursive: true });
  364. }
  365. removeDeep(path) {
  366. fs2.rmdirSync(path, { recursive: true });
  367. }
  368. };
  369. function toggleCase(str) {
  370. return str.replace(/\w/g, (ch) => ch.toUpperCase() === ch ? ch.toLowerCase() : ch.toUpperCase());
  371. }
  372. export {
  373. stripExtension,
  374. getSourceFileOrError,
  375. getFileSystem,
  376. setFileSystem,
  377. absoluteFrom,
  378. absoluteFromSourceFile,
  379. relativeFrom,
  380. dirname,
  381. join,
  382. resolve,
  383. isRoot,
  384. isRooted,
  385. relative,
  386. basename,
  387. isLocalRelativePath,
  388. toRelativeImport,
  389. NgtscCompilerHost,
  390. LogicalProjectPath,
  391. LogicalFileSystem,
  392. NodeJSFileSystem
  393. };
  394. /**
  395. * @license
  396. * Copyright Google LLC All Rights Reserved.
  397. *
  398. * Use of this source code is governed by an MIT-style license that can be
  399. * found in the LICENSE file at https://angular.io/license
  400. */
  401. //# sourceMappingURL=chunk-K2U2VZ7S.js.map