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