@glutinum/cli 0.14.0 → 1.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Glutinum.Converter/FsharpAST.js +38 -4
- package/dist/Glutinum.Converter/Generate.js +15 -7
- package/dist/Glutinum.Converter/GlueAST.js +45 -36
- package/dist/Glutinum.Converter/Hosting.js +918 -0
- package/dist/Glutinum.Converter/Merge.js +218 -82
- package/dist/Glutinum.Converter/Packages.js +44 -8
- package/dist/Glutinum.Converter/Printer.js +77 -49
- package/dist/Glutinum.Converter/Read.js +8 -8
- package/dist/Glutinum.Converter/Reader/ClassDeclaration.js +7 -7
- package/dist/Glutinum.Converter/Reader/Declaration.js +26 -26
- package/dist/Glutinum.Converter/Reader/Documentation.js +37 -36
- package/dist/Glutinum.Converter/Reader/ExportAssignment.js +5 -5
- package/dist/Glutinum.Converter/Reader/ExportDeclaration.js +31 -19
- package/dist/Glutinum.Converter/Reader/FunctionDeclaration.js +6 -7
- package/dist/Glutinum.Converter/Reader/IndexedAccessType.js +36 -29
- package/dist/Glutinum.Converter/Reader/InterfaceDeclaration.js +3 -3
- package/dist/Glutinum.Converter/Reader/MappedTypeNode.js +82 -4
- package/dist/Glutinum.Converter/Reader/ModuleDeclaration.js +3 -3
- package/dist/Glutinum.Converter/Reader/Node.js +20 -20
- package/dist/Glutinum.Converter/Reader/Parameters.js +7 -7
- package/dist/Glutinum.Converter/Reader/TypeAliasDeclaration.js +5 -5
- package/dist/Glutinum.Converter/Reader/TypeNode.js +291 -232
- package/dist/Glutinum.Converter/Reader/TypeOperatorNode.js +8 -8
- package/dist/Glutinum.Converter/Reader/TypeQueryNode.js +108 -40
- package/dist/Glutinum.Converter/Reader/TypeScriptReader.js +2 -2
- package/dist/Glutinum.Converter/Reader/Types.js +6 -6
- package/dist/Glutinum.Converter/Reader/UnionTypeNode.js +7 -6
- package/dist/Glutinum.Converter/Reader/Utils.js +106 -56
- package/dist/Glutinum.Converter/Transform.js +2057 -700
- package/dist/Glutinum.Converter/TypeScript.Extensions.js +194 -202
- package/dist/Glutinum.Converter/Utils/Naming.js +7 -0
- package/dist/Glutinum.Converter/Utils/String.js +2 -2
- package/dist/Program.js +38 -26
- package/dist/fable_modules/Fable.Promise.3.2.1/AsyncIterable.fs +89 -0
- package/dist/fable_modules/Fable.Promise.3.2.1/AsyncIterable.fs.js +105 -0
- package/dist/fable_modules/Fable.Promise.3.2.1/Fable.Promise.fableproj +25 -0
- package/dist/fable_modules/Fable.Promise.3.2.1/Promise.fs +842 -0
- package/dist/fable_modules/Fable.Promise.3.2.1/Promise.fs.js +232 -0
- package/dist/fable_modules/Fable.Promise.3.2.1/PromiseImpl.fs +31 -0
- package/dist/fable_modules/Fable.Promise.3.2.1/PromiseImpl.fs.js +20 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Array.fs +235 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Array.fs.js +384 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AssemblyInfo.fs +19 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Async.fs +287 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Async.fs.js +128 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncOption.fs +127 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncOptionCE.fs +174 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncOptionCE.fs.js +37 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncOptionOp.fs +24 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResult.fs +483 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultCE.fs +201 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultCE.fs.js +18 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultOp.fs +24 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultOption.fs +87 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultOption.fs.js +26 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultOptionCE.fs +236 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultOptionCE.fs.js +18 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultOptionOp.fs +24 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncValidation.fs +185 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncValidationCE.fs +186 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncValidationCE.fs.js +18 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncValidationOp.fs +35 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/FsToolkit.ErrorHandling.fableproj +69 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/List.fs +276 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/List.fs.js +364 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Nullness.fs +81 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Option.fs +462 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/OptionCE.fs +139 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/OptionCE.fs.js +48 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/OptionOp.fs +21 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncResult.fs +88 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncResult.fs.js +30 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncResultCE.fs +200 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncResultCE.fs.js +18 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncValidation.fs +34 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncValidationCE.fs +244 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncValidationCE.fs.js +18 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Result.fs +731 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Result.fs.js +45 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultCE.fs +140 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultCE.fs.js +23 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultOp.fs +45 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultOption.fs +201 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultOption.fs.js +65 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultOptionCE.fs +135 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultOptionCE.fs.js +18 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultOptionOp.fs +57 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Seq.fs +503 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Seq.fs.js +295 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Validation.fs +167 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValidationCE.fs +142 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValidationCE.fs.js +18 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValidationOp.fs +35 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValueOption.fs +148 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValueTaskValueOption.fs +102 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValueTaskValueOptionCE.fs +587 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValueTaskValueOptionOp.fs +10 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Debug/netstandard2.1/.NETStandard,Version=v2.1.AssemblyAttributes.fs +3 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Debug/netstandard2.1/FsToolkit.ErrorHandling.AssemblyInfo.fs +20 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Release/net9.0/.NETCoreApp,Version=v9.0.AssemblyAttributes.fs +3 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Release/net9.0/FsToolkit.ErrorHandling.AssemblyInfo.fs +20 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Release/netstandard2.0/.NETStandard,Version=v2.0.AssemblyAttributes.fs +3 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Release/netstandard2.0/FsToolkit.ErrorHandling.AssemblyInfo.fs +20 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Release/netstandard2.1/.NETStandard,Version=v2.1.AssemblyAttributes.fs +3 -0
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Release/netstandard2.1/FsToolkit.ErrorHandling.AssemblyInfo.fs +20 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Array.js +1348 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Async.js +163 -0
- package/dist/fable_modules/fable-library-js.5.17.2/AsyncBuilder.js +204 -0
- package/dist/fable_modules/fable-library-js.5.17.2/BigInt.js +307 -0
- package/dist/fable_modules/fable-library-js.5.17.2/BitConverter.js +138 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Boolean.js +22 -0
- package/dist/fable_modules/fable-library-js.5.17.2/CHANGELOG.md +348 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Char.js +202 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Choice.js +184 -0
- package/dist/fable_modules/fable-library-js.5.17.2/CollectionUtil.js +182 -0
- package/dist/fable_modules/fable-library-js.5.17.2/ConditionalWeakTable.js +21 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Date.js +834 -0
- package/dist/fable_modules/fable-library-js.5.17.2/DateOffset.js +252 -0
- package/dist/fable_modules/fable-library-js.5.17.2/DateOnly.js +124 -0
- package/dist/fable_modules/fable-library-js.5.17.2/DateOnlyTemporal.js +146 -0
- package/dist/fable_modules/fable-library-js.5.17.2/DateTimeFormat.js +523 -0
- package/dist/fable_modules/fable-library-js.5.17.2/DateTimeOffsetTemporal.js +283 -0
- package/dist/fable_modules/fable-library-js.5.17.2/DateTimeTemporal.js +243 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Decimal.js +238 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Directory.js +11 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Double.js +53 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Encoding.js +185 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Environment.js +3 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Event.js +102 -0
- package/dist/fable_modules/fable-library-js.5.17.2/FSharp.Collections.js +45 -0
- package/dist/fable_modules/fable-library-js.5.17.2/FSharp.Core.CompilerServices.js +27 -0
- package/dist/fable_modules/fable-library-js.5.17.2/FSharp.Core.js +156 -0
- package/dist/fable_modules/fable-library-js.5.17.2/File.js +27 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Global.js +29 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Guid.js +163 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Int32.js +135 -0
- package/dist/fable_modules/fable-library-js.5.17.2/List.js +1337 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Long.js +38 -0
- package/dist/fable_modules/fable-library-js.5.17.2/MailboxProcessor.js +100 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Map.js +1400 -0
- package/dist/fable_modules/fable-library-js.5.17.2/MapUtil.js +130 -0
- package/dist/fable_modules/fable-library-js.5.17.2/MutableMap.js +339 -0
- package/dist/fable_modules/fable-library-js.5.17.2/MutableSet.js +233 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Native.js +14 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Numeric.js +112 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Observable.js +115 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Option.js +87 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Path.js +31 -0
- package/dist/fable_modules/fable-library-js.5.17.2/README.md +3 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Random.js +172 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Range.js +45 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Reflection.js +489 -0
- package/dist/fable_modules/fable-library-js.5.17.2/RegExp.js +170 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Result.js +165 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Seq.js +1504 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Seq2.js +111 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Set.js +1829 -0
- package/dist/fable_modules/fable-library-js.5.17.2/String.js +731 -0
- package/dist/fable_modules/fable-library-js.5.17.2/System.Collections.Generic.js +333 -0
- package/dist/fable_modules/fable-library-js.5.17.2/System.Text.js +200 -0
- package/dist/fable_modules/fable-library-js.5.17.2/System.js +289 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Task.js +27 -0
- package/dist/fable_modules/fable-library-js.5.17.2/TaskBuilder.js +72 -0
- package/dist/fable_modules/fable-library-js.5.17.2/TimeOnly.js +122 -0
- package/dist/fable_modules/fable-library-js.5.17.2/TimeOnlyTemporal.js +142 -0
- package/dist/fable_modules/fable-library-js.5.17.2/TimeSpan.js +180 -0
- package/dist/fable_modules/fable-library-js.5.17.2/TimeSpanTemporal.js +259 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Timer.js +67 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Types.js +198 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Unicode.13.0.0.js +4 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Uri.js +165 -0
- package/dist/fable_modules/fable-library-js.5.17.2/Util.js +807 -0
- package/dist/fable_modules/fable-library-js.5.17.2/big.d.ts +338 -0
- package/dist/fable_modules/fable-library-js.5.17.2/lib/big.js +829 -0
- package/dist/fable_modules/fable-library-js.5.17.2/package.json +24 -0
- package/dist/fable_modules/fable-library-js.5.17.2/quotation.js +682 -0
- package/package.json +2 -2
- package/dist/Glutinum.Converter/TypeScript.js +0 -12
- package/src/Glutinum.Converter/js/bootstrap.js +0 -123
- package/src/Glutinum.Converter/js/host.js +0 -144
- package/src/Glutinum.Converter/js/npm.js +0 -137
- package/src/Glutinum.Converter/js/resolve.js +0 -402
|
@@ -0,0 +1,918 @@
|
|
|
1
|
+
|
|
2
|
+
import { concat, replace as replace_1, substring, join, split as split_1 } from "../fable_modules/fable-library-js.5.17.2/String.js";
|
|
3
|
+
import { contains, map as map_1, addRangeInPlace, tryFind, choose, item } from "../fable_modules/fable-library-js.5.17.2/Array.js";
|
|
4
|
+
import { singleton, collect, filter, tryFind as tryFind_1, exists as exists_1, delay, toList, map, toArray } from "../fable_modules/fable-library-js.5.17.2/Seq.js";
|
|
5
|
+
import { ts, InMemoryFileSystemHost, createProjectSync } from "@ts-morph/bootstrap";
|
|
6
|
+
import * as path_1 from "path";
|
|
7
|
+
import * as fs from "fs";
|
|
8
|
+
import { replace, split as split_2, match, isMatch } from "../fable_modules/fable-library-js.5.17.2/RegExp.js";
|
|
9
|
+
import { stringHash, Exception, disposeSafe, getEnumerator } from "../fable_modules/fable-library-js.5.17.2/Util.js";
|
|
10
|
+
import { ofArray, exists } from "../fable_modules/fable-library-js.5.17.2/List.js";
|
|
11
|
+
import { tryParse } from "../fable_modules/fable-library-js.5.17.2/Int32.js";
|
|
12
|
+
import { FSharpRef } from "../fable_modules/fable-library-js.5.17.2/Types.js";
|
|
13
|
+
import { toNullable, value as value_2, some } from "../fable_modules/fable-library-js.5.17.2/Option.js";
|
|
14
|
+
import { PromiseBuilder__For_1565554B, PromiseBuilder__While_2044D34, PromiseBuilder__Delay_62FBFDE1, PromiseBuilder__Run_212F1D4B } from "../fable_modules/Fable.Promise.3.2.1/Promise.fs.js";
|
|
15
|
+
import { promise } from "../fable_modules/Fable.Promise.3.2.1/PromiseImpl.fs.js";
|
|
16
|
+
import { addToSet, getItemFromDict } from "../fable_modules/fable-library-js.5.17.2/MapUtil.js";
|
|
17
|
+
import { rangeDouble } from "../fable_modules/fable-library-js.5.17.2/Range.js";
|
|
18
|
+
|
|
19
|
+
const declarationFile = /\.d\.[cm]?ts$/gu;
|
|
20
|
+
|
|
21
|
+
const javaScriptFile = /\.[cm]?js$/gu;
|
|
22
|
+
|
|
23
|
+
export function PosixPath_normalize(p) {
|
|
24
|
+
const absolute = p.startsWith("/");
|
|
25
|
+
const segments = [];
|
|
26
|
+
const arr = split_1(p, ["/"], undefined, 0);
|
|
27
|
+
for (let idx = 0; idx <= (arr.length - 1); idx++) {
|
|
28
|
+
const segment = item(idx, arr);
|
|
29
|
+
if ((segment === "") ? true : (segment === ".")) {
|
|
30
|
+
}
|
|
31
|
+
else if (segment === "..") {
|
|
32
|
+
if ((segments.length > 0) && (item(segments.length - 1, segments) !== "..")) {
|
|
33
|
+
segments.splice(segments.length - 1, 1);
|
|
34
|
+
}
|
|
35
|
+
else if (!absolute) {
|
|
36
|
+
void (segments.push(".."));
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
void (segments.push(segment));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
const joined = join("/", segments);
|
|
44
|
+
if (absolute) {
|
|
45
|
+
return "/" + joined;
|
|
46
|
+
}
|
|
47
|
+
else if (joined === "") {
|
|
48
|
+
return ".";
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
return joined;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function PosixPath_join(parts) {
|
|
56
|
+
return PosixPath_normalize(join("/", parts.filter((part) => (part !== ""))));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function PosixPath_dirname(p) {
|
|
60
|
+
const normalized = PosixPath_normalize(p);
|
|
61
|
+
const index = normalized.lastIndexOf("/") | 0;
|
|
62
|
+
switch (index) {
|
|
63
|
+
case -1:
|
|
64
|
+
return ".";
|
|
65
|
+
case 0:
|
|
66
|
+
return "/";
|
|
67
|
+
default:
|
|
68
|
+
return substring(normalized, 0, index);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export function PosixPath_basename(p) {
|
|
73
|
+
const normalized = PosixPath_normalize(p);
|
|
74
|
+
return substring(normalized, normalized.lastIndexOf("/") + 1);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function PosixPath_resolve(parts) {
|
|
78
|
+
let result = "/";
|
|
79
|
+
for (let idx = 0; idx <= (parts.length - 1); idx++) {
|
|
80
|
+
const part = item(idx, parts);
|
|
81
|
+
result = (part.startsWith("/") ? part : ((result + "/") + part));
|
|
82
|
+
}
|
|
83
|
+
return PosixPath_normalize(result);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const posixPath = {
|
|
87
|
+
join(parts) {
|
|
88
|
+
return PosixPath_join(parts);
|
|
89
|
+
},
|
|
90
|
+
dirname(p) {
|
|
91
|
+
return PosixPath_dirname(p);
|
|
92
|
+
},
|
|
93
|
+
basename(p_1) {
|
|
94
|
+
return PosixPath_basename(p_1);
|
|
95
|
+
},
|
|
96
|
+
resolve(parts_1) {
|
|
97
|
+
return PosixPath_resolve(parts_1);
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* A host over a ts-morph file system, the in-memory one in the browser
|
|
103
|
+
*/
|
|
104
|
+
export function createFileSystemHost(fileSystem, cwd) {
|
|
105
|
+
return new (class {
|
|
106
|
+
get cwd() {
|
|
107
|
+
return cwd;
|
|
108
|
+
}
|
|
109
|
+
get fileSystem() {
|
|
110
|
+
return fileSystem;
|
|
111
|
+
}
|
|
112
|
+
get path() {
|
|
113
|
+
return posixPath;
|
|
114
|
+
}
|
|
115
|
+
get fs() {
|
|
116
|
+
return {
|
|
117
|
+
fileExists(p) {
|
|
118
|
+
return fileSystem.fileExistsSync(p);
|
|
119
|
+
},
|
|
120
|
+
directoryExists(p_1) {
|
|
121
|
+
return fileSystem.directoryExistsSync(p_1);
|
|
122
|
+
},
|
|
123
|
+
readFile(p_2) {
|
|
124
|
+
return fileSystem.readFileSync(p_2, "utf8");
|
|
125
|
+
},
|
|
126
|
+
readDirectory(p_3) {
|
|
127
|
+
return toArray(map((entry) => entry.name, fileSystem.readDirSync(p_3)));
|
|
128
|
+
},
|
|
129
|
+
realPath(p_4) {
|
|
130
|
+
try {
|
|
131
|
+
return fileSystem.realpathSync(p_4);
|
|
132
|
+
}
|
|
133
|
+
catch (matchValue) {
|
|
134
|
+
return p_4;
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
createProject(compilerOptions) {
|
|
140
|
+
return createProjectSync({
|
|
141
|
+
compilerOptions: compilerOptions,
|
|
142
|
+
fileSystem: fileSystem,
|
|
143
|
+
skipAddingFilesFromTsConfig: true,
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
)();
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export function createInMemoryHost(cwd) {
|
|
151
|
+
return createFileSystemHost(new InMemoryFileSystemHost(), cwd);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* The host of the CLI, over the disk
|
|
156
|
+
*/
|
|
157
|
+
export function createNodeHost(cwd) {
|
|
158
|
+
return new (class {
|
|
159
|
+
get cwd() {
|
|
160
|
+
return cwd;
|
|
161
|
+
}
|
|
162
|
+
get path() {
|
|
163
|
+
return {
|
|
164
|
+
join(parts) {
|
|
165
|
+
return path_1.join(...parts);
|
|
166
|
+
},
|
|
167
|
+
dirname(p) {
|
|
168
|
+
return path_1.dirname(p);
|
|
169
|
+
},
|
|
170
|
+
basename(p_1) {
|
|
171
|
+
return path_1.basename(p_1);
|
|
172
|
+
},
|
|
173
|
+
resolve(parts_1) {
|
|
174
|
+
return path_1.resolve(...parts_1);
|
|
175
|
+
},
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
get fs() {
|
|
179
|
+
return {
|
|
180
|
+
fileExists(p_2) {
|
|
181
|
+
return fs.existsSync(p_2) && fs.statSync(p_2).isFile();
|
|
182
|
+
},
|
|
183
|
+
directoryExists(p_3) {
|
|
184
|
+
return fs.existsSync(p_3) && fs.statSync(p_3).isDirectory();
|
|
185
|
+
},
|
|
186
|
+
readFile(p_4) {
|
|
187
|
+
return fs.readFileSync(p_4, "utf8");
|
|
188
|
+
},
|
|
189
|
+
readDirectory(p_5) {
|
|
190
|
+
return fs.readdirSync(p_5);
|
|
191
|
+
},
|
|
192
|
+
realPath(p_6) {
|
|
193
|
+
try {
|
|
194
|
+
return fs.realpathSync(p_6);
|
|
195
|
+
}
|
|
196
|
+
catch (matchValue) {
|
|
197
|
+
return p_6;
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
createProject(compilerOptions) {
|
|
203
|
+
return createProjectSync({
|
|
204
|
+
compilerOptions: compilerOptions,
|
|
205
|
+
skipAddingFilesFromTsConfig: true,
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
)();
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
function Dynamic_replaceFirst(value, search, replacement) {
|
|
213
|
+
const index = value.indexOf(search) | 0;
|
|
214
|
+
if (index < 0) {
|
|
215
|
+
return value;
|
|
216
|
+
}
|
|
217
|
+
else {
|
|
218
|
+
return (substring(value, 0, index) + replacement) + substring(value, index + search.length);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
export function Resolve_findNodeModules(host, cwd) {
|
|
223
|
+
let dir = host.path.resolve([cwd]);
|
|
224
|
+
let result = undefined;
|
|
225
|
+
let go = true;
|
|
226
|
+
while (go) {
|
|
227
|
+
const candidate = host.path.join([dir, "node_modules"]);
|
|
228
|
+
if (host.fs.directoryExists(candidate)) {
|
|
229
|
+
result = candidate;
|
|
230
|
+
go = false;
|
|
231
|
+
}
|
|
232
|
+
else {
|
|
233
|
+
const parent = host.path.dirname(dir);
|
|
234
|
+
if (parent === dir) {
|
|
235
|
+
go = false;
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
dir = parent;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
return result;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
export function Resolve_findPackageDir(host, file) {
|
|
246
|
+
let dir = host.path.dirname(host.path.resolve([file]));
|
|
247
|
+
let result = undefined;
|
|
248
|
+
let go = true;
|
|
249
|
+
while (go) {
|
|
250
|
+
let x, o;
|
|
251
|
+
const packageJsonPath = host.path.join([dir, "package.json"]);
|
|
252
|
+
if (host.fs.fileExists(packageJsonPath) && !((x = ((o = JSON.parse(host.fs.readFile(packageJsonPath)), o["name"])), x === null || x === undefined))) {
|
|
253
|
+
result = host.fs.realPath(dir);
|
|
254
|
+
go = false;
|
|
255
|
+
}
|
|
256
|
+
else {
|
|
257
|
+
const parent = host.path.dirname(dir);
|
|
258
|
+
if (parent === dir) {
|
|
259
|
+
go = false;
|
|
260
|
+
}
|
|
261
|
+
else {
|
|
262
|
+
dir = parent;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
return result;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
function Resolve_collectExportsTypes(exportsField) {
|
|
270
|
+
const result = [];
|
|
271
|
+
const visit = (subpath, node) => {
|
|
272
|
+
if (node === null || node === undefined) {
|
|
273
|
+
}
|
|
274
|
+
else if ((typeof node) === "string") {
|
|
275
|
+
const text = node;
|
|
276
|
+
if (isMatch(declarationFile, text)) {
|
|
277
|
+
void (result.push([subpath, text]));
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
else if ((typeof node) === "object") {
|
|
281
|
+
const arr = Object.entries(node);
|
|
282
|
+
for (let idx = 0; idx <= (arr.length - 1); idx++) {
|
|
283
|
+
const forLoopVar = item(idx, arr);
|
|
284
|
+
const value = forLoopVar[1];
|
|
285
|
+
const key = forLoopVar[0];
|
|
286
|
+
if (key.startsWith(".")) {
|
|
287
|
+
visit(key, value);
|
|
288
|
+
}
|
|
289
|
+
else {
|
|
290
|
+
visit(subpath, value);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
};
|
|
295
|
+
visit(".", exportsField);
|
|
296
|
+
const bySubpath = new Map([]);
|
|
297
|
+
let enumerator = getEnumerator(result);
|
|
298
|
+
try {
|
|
299
|
+
while (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
|
|
300
|
+
const forLoopVar_1 = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]();
|
|
301
|
+
const subpath_1 = forLoopVar_1[0];
|
|
302
|
+
if (!bySubpath.has(subpath_1)) {
|
|
303
|
+
bySubpath.set(subpath_1, forLoopVar_1[1]);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
finally {
|
|
308
|
+
disposeSafe(enumerator);
|
|
309
|
+
}
|
|
310
|
+
return toList(delay(() => map((entry) => [entry[0], entry[1]], bySubpath)));
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
function Resolve_exportsRuntimeFile(node) {
|
|
314
|
+
if ((typeof node) === "string") {
|
|
315
|
+
return !isMatch(declarationFile, node);
|
|
316
|
+
}
|
|
317
|
+
else if (!(node === null || node === undefined) && ((typeof node) === "object")) {
|
|
318
|
+
const array = Object.values(node);
|
|
319
|
+
return array.some(Resolve_exportsRuntimeFile);
|
|
320
|
+
}
|
|
321
|
+
else {
|
|
322
|
+
return false;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
function Resolve_hasRuntime(host, packageDir, pkg) {
|
|
327
|
+
const declared = (field) => {
|
|
328
|
+
if ((typeof field) === "string") {
|
|
329
|
+
return field !== "";
|
|
330
|
+
}
|
|
331
|
+
else {
|
|
332
|
+
return !(field === null || field === undefined);
|
|
333
|
+
}
|
|
334
|
+
};
|
|
335
|
+
if (((declared(pkg["main"]) ? true : declared(pkg["module"])) ? true : declared(pkg["bin"])) ? true : declared(pkg["browser"])) {
|
|
336
|
+
return true;
|
|
337
|
+
}
|
|
338
|
+
else if (Resolve_exportsRuntimeFile(pkg["exports"])) {
|
|
339
|
+
return true;
|
|
340
|
+
}
|
|
341
|
+
else {
|
|
342
|
+
return exists((file) => host.fs.fileExists(host.path.join([packageDir, file])), ofArray(["index.js", "index.mjs", "index.cjs", ".glutinum-runtime"]));
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
function Resolve_parseVersion(version) {
|
|
347
|
+
const parts = split_1(version, ["."], undefined, 0);
|
|
348
|
+
const at = (i) => {
|
|
349
|
+
if (i < parts.length) {
|
|
350
|
+
let matchValue;
|
|
351
|
+
let outArg = 0;
|
|
352
|
+
matchValue = [tryParse(item(i, parts), 511, false, 32, new FSharpRef(() => (outArg | 0), (v) => {
|
|
353
|
+
outArg = (v | 0);
|
|
354
|
+
})), outArg];
|
|
355
|
+
if (matchValue[0]) {
|
|
356
|
+
return matchValue[1] | 0;
|
|
357
|
+
}
|
|
358
|
+
else {
|
|
359
|
+
return 0;
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
else {
|
|
363
|
+
return 0;
|
|
364
|
+
}
|
|
365
|
+
};
|
|
366
|
+
return new Int32Array([at(0), at(1), at(2)]);
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
function Resolve_compareVersions(a, b) {
|
|
370
|
+
let result = 0;
|
|
371
|
+
let i = 0;
|
|
372
|
+
while ((i < 3) && (result === 0)) {
|
|
373
|
+
if (item(i, a) !== item(i, b)) {
|
|
374
|
+
result = ((item(i, a) - item(i, b)) | 0);
|
|
375
|
+
}
|
|
376
|
+
i = ((i + 1) | 0);
|
|
377
|
+
}
|
|
378
|
+
return result | 0;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
function Resolve_satisfiesComparator(version, comparator) {
|
|
382
|
+
const m = match(/^(>=|<=|>|<|=|\^|~)?\s*(.+)$/gu, comparator);
|
|
383
|
+
if (!(m != null)) {
|
|
384
|
+
return false;
|
|
385
|
+
}
|
|
386
|
+
else {
|
|
387
|
+
const operator = ((m[1] != null) && ((m[1] || "") !== "")) ? (m[1] || "") : "=";
|
|
388
|
+
const text = m[2] || "";
|
|
389
|
+
if ((text === "*") ? true : (text === "x")) {
|
|
390
|
+
return true;
|
|
391
|
+
}
|
|
392
|
+
else {
|
|
393
|
+
const parts = choose((part) => {
|
|
394
|
+
let matchValue;
|
|
395
|
+
let outArg = 0;
|
|
396
|
+
matchValue = [tryParse(part, 511, false, 32, new FSharpRef(() => (outArg | 0), (v) => {
|
|
397
|
+
outArg = (v | 0);
|
|
398
|
+
})), outArg];
|
|
399
|
+
if (matchValue[0]) {
|
|
400
|
+
return matchValue[1];
|
|
401
|
+
}
|
|
402
|
+
else {
|
|
403
|
+
return undefined;
|
|
404
|
+
}
|
|
405
|
+
}, split_1(text, ["."], undefined, 0), Int32Array);
|
|
406
|
+
const g = (i) => {
|
|
407
|
+
if (i < parts.length) {
|
|
408
|
+
return item(i, parts) | 0;
|
|
409
|
+
}
|
|
410
|
+
else {
|
|
411
|
+
return 0;
|
|
412
|
+
}
|
|
413
|
+
};
|
|
414
|
+
const lower = new Int32Array([g(0), g(1), g(2)]);
|
|
415
|
+
let upper;
|
|
416
|
+
const matchValue_1 = parts.length | 0;
|
|
417
|
+
upper = ((matchValue_1 === 1) ? (new Int32Array([item(0, lower) + 1, 0, 0])) : ((matchValue_1 === 2) ? (new Int32Array([item(0, lower), item(1, lower) + 1, 0])) : (new Int32Array([item(0, lower), item(1, lower), item(2, lower) + 1]))));
|
|
418
|
+
switch (operator) {
|
|
419
|
+
case ">=":
|
|
420
|
+
return Resolve_compareVersions(version, lower) >= 0;
|
|
421
|
+
case ">":
|
|
422
|
+
return Resolve_compareVersions(version, upper) >= 0;
|
|
423
|
+
case "<":
|
|
424
|
+
return Resolve_compareVersions(version, lower) < 0;
|
|
425
|
+
case "<=":
|
|
426
|
+
return Resolve_compareVersions(version, upper) < 0;
|
|
427
|
+
case "^":
|
|
428
|
+
if (Resolve_compareVersions(version, lower) >= 0) {
|
|
429
|
+
return Resolve_compareVersions(version, new Int32Array([item(0, lower) + 1, 0, 0])) < 0;
|
|
430
|
+
}
|
|
431
|
+
else {
|
|
432
|
+
return false;
|
|
433
|
+
}
|
|
434
|
+
case "~":
|
|
435
|
+
if (Resolve_compareVersions(version, lower) >= 0) {
|
|
436
|
+
return Resolve_compareVersions(version, new Int32Array([item(0, lower), item(1, lower) + 1, 0])) < 0;
|
|
437
|
+
}
|
|
438
|
+
else {
|
|
439
|
+
return false;
|
|
440
|
+
}
|
|
441
|
+
default:
|
|
442
|
+
if (Resolve_compareVersions(version, lower) >= 0) {
|
|
443
|
+
return Resolve_compareVersions(version, upper) < 0;
|
|
444
|
+
}
|
|
445
|
+
else {
|
|
446
|
+
return false;
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
function Resolve_satisfiesRange(version, range) {
|
|
454
|
+
const parsed = Resolve_parseVersion(version);
|
|
455
|
+
const array_1 = split_1(range, ["||"], undefined, 0);
|
|
456
|
+
return array_1.some((alternative) => {
|
|
457
|
+
const array = split_2(alternative.trim(), "\\s+");
|
|
458
|
+
return array.every((comparator) => Resolve_satisfiesComparator(parsed, comparator));
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
function Resolve_applyTypesVersions(typesVersions, file) {
|
|
463
|
+
if (typesVersions === null || typesVersions === undefined) {
|
|
464
|
+
return file;
|
|
465
|
+
}
|
|
466
|
+
else {
|
|
467
|
+
let paths;
|
|
468
|
+
const option_1 = tryFind((tupledArg) => Resolve_satisfiesRange(ts.version, tupledArg[0]), Object.entries(typesVersions));
|
|
469
|
+
paths = ((option_1 != null) ? some(option_1[1]) : undefined);
|
|
470
|
+
if (paths != null) {
|
|
471
|
+
const paths_1 = value_2(paths);
|
|
472
|
+
const normalized = replace(file, "^\\./", "");
|
|
473
|
+
let found = undefined;
|
|
474
|
+
const arr = Object.entries(paths_1);
|
|
475
|
+
for (let idx = 0; idx <= (arr.length - 1); idx++) {
|
|
476
|
+
const forLoopVar = item(idx, arr);
|
|
477
|
+
if (found == null) {
|
|
478
|
+
const split = split_1(forLoopVar[0], ["*"], undefined, 0);
|
|
479
|
+
const prefix = item(0, split);
|
|
480
|
+
const suffix = (split.length > 1) ? item(1, split) : "";
|
|
481
|
+
const targets_1 = forLoopVar[1];
|
|
482
|
+
if ((normalized.startsWith(prefix) && normalized.endsWith(suffix)) && (targets_1.length > 0)) {
|
|
483
|
+
const captured = substring(normalized, prefix.length, (normalized.length - suffix.length) - prefix.length);
|
|
484
|
+
found = replace_1(item(0, targets_1), "*", captured);
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
if (found == null) {
|
|
489
|
+
return file;
|
|
490
|
+
}
|
|
491
|
+
else {
|
|
492
|
+
return found;
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
else {
|
|
496
|
+
return file;
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
export function Resolve_describePackage(host, packageDir) {
|
|
502
|
+
const packageJsonPath = host.path.join([packageDir, "package.json"]);
|
|
503
|
+
if (!host.fs.fileExists(packageJsonPath)) {
|
|
504
|
+
return undefined;
|
|
505
|
+
}
|
|
506
|
+
else {
|
|
507
|
+
const pkg = JSON.parse(host.fs.readFile(packageJsonPath));
|
|
508
|
+
let name;
|
|
509
|
+
const matchValue = pkg["name"];
|
|
510
|
+
name = (!(matchValue === null || matchValue === undefined) ? matchValue : host.path.basename(packageDir));
|
|
511
|
+
let runtimeName = name;
|
|
512
|
+
if (name.startsWith("@types/")) {
|
|
513
|
+
const typed = substring(name, "@types/".length);
|
|
514
|
+
runtimeName = ((typed.indexOf("__") >= 0) ? ("@" + replace_1(typed, "__", "/")) : typed);
|
|
515
|
+
}
|
|
516
|
+
const candidates = [];
|
|
517
|
+
let typesField;
|
|
518
|
+
const matchValue_1 = pkg["types"];
|
|
519
|
+
typesField = (!(matchValue_1 === null || matchValue_1 === undefined) ? matchValue_1 : (pkg["typings"]));
|
|
520
|
+
if ((typeof typesField) === "string") {
|
|
521
|
+
void (candidates.push([".", typesField]));
|
|
522
|
+
}
|
|
523
|
+
addRangeInPlace(Resolve_collectExportsTypes(pkg["exports"]), candidates);
|
|
524
|
+
const mainField = pkg["main"];
|
|
525
|
+
if ((typeof mainField) === "string") {
|
|
526
|
+
void (candidates.push([".", replace(mainField, "\\.[cm]?js$", ".d.ts")]));
|
|
527
|
+
}
|
|
528
|
+
void (candidates.push([".", "index.d.ts"]));
|
|
529
|
+
const entries = [];
|
|
530
|
+
let enumerator = getEnumerator(candidates);
|
|
531
|
+
try {
|
|
532
|
+
while (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
|
|
533
|
+
const forLoopVar = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]();
|
|
534
|
+
const subpath = forLoopVar[0];
|
|
535
|
+
const candidateFile = forLoopVar[1];
|
|
536
|
+
const mappedFile = Resolve_applyTypesVersions(pkg["typesVersions"], candidateFile);
|
|
537
|
+
let file = host.path.resolve([packageDir, mappedFile]);
|
|
538
|
+
if (!isMatch(declarationFile, file) && host.fs.fileExists(file + ".d.ts")) {
|
|
539
|
+
file = (file + ".d.ts");
|
|
540
|
+
}
|
|
541
|
+
if (host.fs.fileExists(file) && isMatch(declarationFile, file)) {
|
|
542
|
+
if (!exists_1((entry) => {
|
|
543
|
+
if (entry.subpath === subpath) {
|
|
544
|
+
return true;
|
|
545
|
+
}
|
|
546
|
+
else {
|
|
547
|
+
return entry.file === file;
|
|
548
|
+
}
|
|
549
|
+
}, entries)) {
|
|
550
|
+
void (entries.push({
|
|
551
|
+
file: file,
|
|
552
|
+
isMapped: mappedFile !== candidateFile,
|
|
553
|
+
subpath: subpath,
|
|
554
|
+
}));
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
finally {
|
|
560
|
+
disposeSafe(enumerator);
|
|
561
|
+
}
|
|
562
|
+
const matchValue_2 = tryFind_1((entry_1) => (entry_1.subpath === "."), entries);
|
|
563
|
+
if (matchValue_2 != null) {
|
|
564
|
+
const main = matchValue_2;
|
|
565
|
+
return new (class {
|
|
566
|
+
get name() {
|
|
567
|
+
return name;
|
|
568
|
+
}
|
|
569
|
+
get runtimeName() {
|
|
570
|
+
return runtimeName;
|
|
571
|
+
}
|
|
572
|
+
get hasRuntime() {
|
|
573
|
+
return name.startsWith("@types/") ? true : Resolve_hasRuntime(host, packageDir, pkg);
|
|
574
|
+
}
|
|
575
|
+
get dir() {
|
|
576
|
+
return packageDir;
|
|
577
|
+
}
|
|
578
|
+
get typesRoot() {
|
|
579
|
+
return main.isMapped ? host.path.dirname(main.file) : packageDir;
|
|
580
|
+
}
|
|
581
|
+
get entryFile() {
|
|
582
|
+
return main.file;
|
|
583
|
+
}
|
|
584
|
+
get subpathEntries() {
|
|
585
|
+
return toArray(map((entry_3) => (new (class {
|
|
586
|
+
get subpath() {
|
|
587
|
+
return replace(entry_3.subpath, "^\\./", "");
|
|
588
|
+
}
|
|
589
|
+
get file() {
|
|
590
|
+
return entry_3.file;
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
)()), filter((entry_2) => (entry_2.subpath !== "."), entries)));
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
)();
|
|
597
|
+
}
|
|
598
|
+
else {
|
|
599
|
+
return undefined;
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
function Resolve_resolvedFile(file) {
|
|
605
|
+
return {
|
|
606
|
+
kind: "file",
|
|
607
|
+
file: file,
|
|
608
|
+
packageDir: "",
|
|
609
|
+
};
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
function Resolve_resolvedPackage(packageDir) {
|
|
613
|
+
return {
|
|
614
|
+
kind: "package",
|
|
615
|
+
file: "",
|
|
616
|
+
packageDir: packageDir,
|
|
617
|
+
};
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
export function Resolve_resolveInput(host, input) {
|
|
621
|
+
const asPath = host.path.resolve([host.cwd, input]);
|
|
622
|
+
if (isMatch(declarationFile, input) && host.fs.fileExists(asPath)) {
|
|
623
|
+
return Resolve_resolvedFile(asPath);
|
|
624
|
+
}
|
|
625
|
+
else if (host.fs.directoryExists(asPath)) {
|
|
626
|
+
return Resolve_resolvedPackage(host.fs.realPath(asPath));
|
|
627
|
+
}
|
|
628
|
+
else {
|
|
629
|
+
const matchValue = Resolve_findNodeModules(host, host.cwd);
|
|
630
|
+
if (matchValue == null) {
|
|
631
|
+
throw new Exception(concat("Could not find \'", input, "\': it is neither a declaration file, a package directory, nor a package installed in node_modules."));
|
|
632
|
+
}
|
|
633
|
+
else {
|
|
634
|
+
const nodeModules = matchValue;
|
|
635
|
+
const segments = split_1(input, ["/"], undefined, 0);
|
|
636
|
+
const packageName = input.startsWith("@") ? join("/", segments.slice(0, 1 + 1)) : item(0, segments);
|
|
637
|
+
const typesPackage = host.path.join(["@types", Dynamic_replaceFirst(replace(packageName, "^@", ""), "/", "__")]);
|
|
638
|
+
let withoutDeclaration = undefined;
|
|
639
|
+
let result = undefined;
|
|
640
|
+
const enumerator = getEnumerator([packageName, typesPackage]);
|
|
641
|
+
try {
|
|
642
|
+
while (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
|
|
643
|
+
const candidate = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]();
|
|
644
|
+
if (result == null) {
|
|
645
|
+
const packageDir = host.fs.realPath(host.path.join([nodeModules, candidate]));
|
|
646
|
+
if (host.fs.fileExists(host.path.join([packageDir, "package.json"]))) {
|
|
647
|
+
if (Resolve_describePackage(host, packageDir) != null) {
|
|
648
|
+
result = Resolve_resolvedPackage(packageDir);
|
|
649
|
+
}
|
|
650
|
+
else if (withoutDeclaration == null) {
|
|
651
|
+
withoutDeclaration = candidate;
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
finally {
|
|
658
|
+
disposeSafe(enumerator);
|
|
659
|
+
}
|
|
660
|
+
if (result == null) {
|
|
661
|
+
if (withoutDeclaration == null) {
|
|
662
|
+
throw new Exception(concat("Could not find \'", input, "\': it is neither a declaration file, a package directory, nor a package installed in node_modules."));
|
|
663
|
+
}
|
|
664
|
+
else {
|
|
665
|
+
throw new Exception(`'${value_2(withoutDeclaration)}' ships no type declaration, install '${typesPackage}' and generate that instead.`);
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
else {
|
|
669
|
+
return result;
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
export function Resolve_listInstalledPackages(host) {
|
|
676
|
+
let source_1, objectArg;
|
|
677
|
+
const matchValue = Resolve_findNodeModules(host, host.cwd);
|
|
678
|
+
if (matchValue != null) {
|
|
679
|
+
const nodeModules = matchValue;
|
|
680
|
+
const result = [];
|
|
681
|
+
const arr = host.fs.readDirectory(nodeModules);
|
|
682
|
+
for (let idx = 0; idx <= (arr.length - 1); idx++) {
|
|
683
|
+
const entry = item(idx, arr);
|
|
684
|
+
if (!entry.startsWith(".")) {
|
|
685
|
+
const entryPath = host.path.join([nodeModules, entry]);
|
|
686
|
+
if (entry.startsWith("@")) {
|
|
687
|
+
const arr_1 = host.fs.readDirectory(entryPath);
|
|
688
|
+
for (let idx_1 = 0; idx_1 <= (arr_1.length - 1); idx_1++) {
|
|
689
|
+
const scoped = item(idx_1, arr_1);
|
|
690
|
+
void (result.push(host.path.join([entryPath, scoped])));
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
else {
|
|
694
|
+
void (result.push(entryPath));
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
return toArray(filter((dir_1) => (Resolve_describePackage(host, dir_1) != null), (source_1 = filter((dir) => host.fs.fileExists(host.path.join([dir, "package.json"])), result), map((objectArg = host.fs, (path) => objectArg.realPath(path)), source_1))));
|
|
699
|
+
}
|
|
700
|
+
else {
|
|
701
|
+
return [];
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
/**
|
|
706
|
+
* `@types/foo` for `foo`, `@types/scope__foo` for `@scope/foo`
|
|
707
|
+
*/
|
|
708
|
+
export function Npm_typesPackageName(name) {
|
|
709
|
+
return "@types/" + Dynamic_replaceFirst(replace(name, "^@", ""), "/", "__");
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
/**
|
|
713
|
+
* `chalk`, `chalk@5`, `@scope/name@^1.2`
|
|
714
|
+
*/
|
|
715
|
+
export function Npm_parsePackageSpec(spec) {
|
|
716
|
+
const at = spec.indexOf("@", 1) | 0;
|
|
717
|
+
if (at === -1) {
|
|
718
|
+
return {
|
|
719
|
+
name: spec,
|
|
720
|
+
range: "latest",
|
|
721
|
+
};
|
|
722
|
+
}
|
|
723
|
+
else {
|
|
724
|
+
const range = substring(spec, at + 1);
|
|
725
|
+
return {
|
|
726
|
+
name: substring(spec, 0, at),
|
|
727
|
+
range: (range === "") ? "latest" : range,
|
|
728
|
+
};
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
/**
|
|
733
|
+
* Download the declaration files of a package and of the packages it depends on into
|
|
734
|
+
* `/node_modules` of the file system, like `npm install` would, from jsDelivr
|
|
735
|
+
*/
|
|
736
|
+
export function Npm_installPackage(fileSystem, spec, options) {
|
|
737
|
+
let matchValue_2;
|
|
738
|
+
let fetchImpl;
|
|
739
|
+
const matchValue = options["fetch"];
|
|
740
|
+
fetchImpl = (!(matchValue === null || matchValue === undefined) ? matchValue : (globalThis.fetch));
|
|
741
|
+
let onProgress;
|
|
742
|
+
const matchValue_1 = options["onProgress"];
|
|
743
|
+
onProgress = (!(matchValue_1 === null || matchValue_1 === undefined) ? matchValue_1 : ((value) => {
|
|
744
|
+
}));
|
|
745
|
+
const skip = new Set((matchValue_2 = (options["skip"]), !(matchValue_2 === null || matchValue_2 === undefined) ? matchValue_2 : ["@types/node"]));
|
|
746
|
+
const installed = new Map([]);
|
|
747
|
+
const ignoreP = (p) => PromiseBuilder__Run_212F1D4B(promise, PromiseBuilder__Delay_62FBFDE1(promise, () => (p.then((_arg) => (Promise.resolve(undefined))))));
|
|
748
|
+
const install = (name, range) => PromiseBuilder__Run_212F1D4B(promise, PromiseBuilder__Delay_62FBFDE1(promise, () => ((installed.has(name) ? true : skip.has(name)) ? (Promise.resolve(installed.has(name) ? getItemFromDict(installed, name) : undefined)) : (fetchImpl(`${"https://data.jsdelivr.com/v1/package"}/resolve/npm/${name}@${encodeURIComponent(range)}`).then((_arg_3) => {
|
|
749
|
+
const resolveResponse = _arg_3;
|
|
750
|
+
return (resolveResponse.status === 404) ? (Promise.resolve((() => {
|
|
751
|
+
throw new Exception(concat("No package named \'", name, "\' on npm"));
|
|
752
|
+
})())) : (!resolveResponse.ok ? (Promise.resolve((() => {
|
|
753
|
+
throw new Exception(`${resolveResponse.url}: ${resolveResponse.status}`);
|
|
754
|
+
})())) : (resolveResponse.json().then((_arg_4) => {
|
|
755
|
+
let x_3, url;
|
|
756
|
+
const resolved = _arg_4;
|
|
757
|
+
if ((x_3 = (resolved["version"]), x_3 === null || x_3 === undefined)) {
|
|
758
|
+
return Promise.resolve((() => {
|
|
759
|
+
throw new Exception(`No version of '${name}' matches '${range}'`);
|
|
760
|
+
})());
|
|
761
|
+
}
|
|
762
|
+
else {
|
|
763
|
+
const version = resolved["version"];
|
|
764
|
+
installed.set(name, {
|
|
765
|
+
name: name,
|
|
766
|
+
version: version,
|
|
767
|
+
});
|
|
768
|
+
onProgress(concat(name, "@", version, ": listing files"));
|
|
769
|
+
return ((url = (`${"https://data.jsdelivr.com/v1/package"}/npm/${name}@${version}/flat`), PromiseBuilder__Run_212F1D4B(promise, PromiseBuilder__Delay_62FBFDE1(promise, () => (fetchImpl(url).then((_arg_1) => {
|
|
770
|
+
const response = _arg_1;
|
|
771
|
+
return !response.ok ? (Promise.resolve((() => {
|
|
772
|
+
throw new Exception(`${url}: ${response.status}`);
|
|
773
|
+
})())) : (response.json());
|
|
774
|
+
})))))).then((_arg_5) => {
|
|
775
|
+
let array_1;
|
|
776
|
+
const files = _arg_5["files"];
|
|
777
|
+
const wanted = Array.from((array_1 = map_1((file) => (file["name"]), files), array_1.filter((file_1) => {
|
|
778
|
+
if (isMatch(declarationFile, file_1)) {
|
|
779
|
+
return true;
|
|
780
|
+
}
|
|
781
|
+
else {
|
|
782
|
+
return file_1.endsWith("/package.json");
|
|
783
|
+
}
|
|
784
|
+
})));
|
|
785
|
+
let doneCount = 0;
|
|
786
|
+
return (Promise.all(toArray(delay(() => collect((matchValue_3) => singleton(PromiseBuilder__Run_212F1D4B(promise, PromiseBuilder__Delay_62FBFDE1(promise, () => PromiseBuilder__While_2044D34(promise, () => (wanted.length > 0), PromiseBuilder__Delay_62FBFDE1(promise, () => {
|
|
787
|
+
let url_1;
|
|
788
|
+
const file_2 = item(0, wanted);
|
|
789
|
+
wanted.splice(0, 1);
|
|
790
|
+
return ((url_1 = (`${"https://cdn.jsdelivr.net/npm"}/${name}@${version}${file_2}`), PromiseBuilder__Run_212F1D4B(promise, PromiseBuilder__Delay_62FBFDE1(promise, () => (fetchImpl(url_1).then((_arg_2) => {
|
|
791
|
+
const response_1 = _arg_2;
|
|
792
|
+
return !response_1.ok ? (Promise.resolve((() => {
|
|
793
|
+
throw new Exception(`${url_1}: ${response_1.status}`);
|
|
794
|
+
})())) : (response_1.text());
|
|
795
|
+
})))))).then((_arg_6) => {
|
|
796
|
+
fileSystem.writeFileSync(concat("/node_modules/", name, file_2), _arg_6);
|
|
797
|
+
doneCount = ((doneCount + 1) | 0);
|
|
798
|
+
onProgress(`${name}@${version}: ${doneCount} files`);
|
|
799
|
+
return Promise.resolve();
|
|
800
|
+
});
|
|
801
|
+
}))))), rangeDouble(1, 1, 8)))))).then((_arg_7) => {
|
|
802
|
+
const packageJson = JSON.parse(fileSystem.readFileSync(concat("/node_modules/", name, "/package.json"), "utf8"));
|
|
803
|
+
return (files.some((file_3) => isMatch(javaScriptFile, file_3["name"])) ? ((fileSystem.writeFileSync(concat("/node_modules/", name, "/", ".glutinum-runtime"), ""), Promise.resolve())) : (Promise.resolve())).then(() => PromiseBuilder__Delay_62FBFDE1(promise, () => {
|
|
804
|
+
const hasDeclarations = files.some((file_4) => isMatch(declarationFile, file_4["name"]));
|
|
805
|
+
return ((!hasDeclarations && !name.startsWith("@types/")) ? (PromiseBuilder__Delay_62FBFDE1(promise, () => (ignoreP(install(Npm_typesPackageName(name), "latest")).then(() => (Promise.resolve(undefined))))).catch((_arg_9) => {
|
|
806
|
+
return Promise.resolve();
|
|
807
|
+
})) : (Promise.resolve())).then(() => PromiseBuilder__Delay_62FBFDE1(promise, () => {
|
|
808
|
+
let dependencies;
|
|
809
|
+
const matchValue_4 = packageJson["dependencies"];
|
|
810
|
+
dependencies = (!(matchValue_4 === null || matchValue_4 === undefined) ? matchValue_4 : {});
|
|
811
|
+
return PromiseBuilder__For_1565554B(promise, Object.entries(dependencies), (_arg_10) => (ignoreP(install(_arg_10[0], _arg_10[1])).then(() => (Promise.resolve(undefined))))).then(() => PromiseBuilder__Delay_62FBFDE1(promise, () => (Promise.resolve(installed.has(name) ? getItemFromDict(installed, name) : undefined))));
|
|
812
|
+
}));
|
|
813
|
+
}));
|
|
814
|
+
});
|
|
815
|
+
});
|
|
816
|
+
}
|
|
817
|
+
})));
|
|
818
|
+
})))));
|
|
819
|
+
return PromiseBuilder__Run_212F1D4B(promise, PromiseBuilder__Delay_62FBFDE1(promise, () => {
|
|
820
|
+
const parsed = Npm_parsePackageSpec(spec);
|
|
821
|
+
return install(parsed.name, parsed.range).then((_arg_12) => (Promise.resolve(toNullable(_arg_12))));
|
|
822
|
+
}));
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
export function Bootstrap_createProgramForCLI(_fileName, source) {
|
|
826
|
+
const project = createProjectSync({
|
|
827
|
+
compilerOptions: {
|
|
828
|
+
strict: true,
|
|
829
|
+
},
|
|
830
|
+
});
|
|
831
|
+
project.createSourceFile(_fileName, source);
|
|
832
|
+
return project.createProgram();
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
/**
|
|
836
|
+
* Create a program from declaration files of the host, following their imports
|
|
837
|
+
*/
|
|
838
|
+
export function Bootstrap_createProgramFromFiles(host, entryFiles, withoutDomLib, noLib) {
|
|
839
|
+
const compilerOptions = {
|
|
840
|
+
target: 99,
|
|
841
|
+
module: 99,
|
|
842
|
+
moduleResolution: 100,
|
|
843
|
+
types: [],
|
|
844
|
+
strict: true,
|
|
845
|
+
};
|
|
846
|
+
if (withoutDomLib) {
|
|
847
|
+
compilerOptions.lib = ["lib.esnext.d.ts", "lib.decorators.d.ts", "lib.decorators.legacy.d.ts"];
|
|
848
|
+
}
|
|
849
|
+
if (noLib) {
|
|
850
|
+
compilerOptions.noLib = true;
|
|
851
|
+
}
|
|
852
|
+
const project = host.createProject(compilerOptions);
|
|
853
|
+
for (let idx = 0; idx <= (entryFiles.length - 1); idx++) {
|
|
854
|
+
const entryFile = item(idx, entryFiles);
|
|
855
|
+
project.addSourceFileAtPathSync(entryFile);
|
|
856
|
+
}
|
|
857
|
+
project.resolveSourceFileDependencies();
|
|
858
|
+
return project.createProgram();
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
/**
|
|
862
|
+
* The files reachable from the entry files through imports and references, without going
|
|
863
|
+
* through a package of `excludedRuntimeNames` (`node` for `@types/node`)
|
|
864
|
+
*/
|
|
865
|
+
export function Bootstrap_reachableFiles(host, program, entryFiles, excludedRuntimeNames) {
|
|
866
|
+
const runtimeNames = new Map([]);
|
|
867
|
+
const seen = new Set([]);
|
|
868
|
+
const queue = Array.from(entryFiles);
|
|
869
|
+
const visit = (fileName_1) => {
|
|
870
|
+
let matchValue, dir, option_1, d, matchValue_1;
|
|
871
|
+
if ((!(fileName_1 === null || fileName_1 === undefined) && !seen.has(fileName_1)) && !((matchValue = Resolve_findPackageDir(host, fileName_1), (matchValue != null) && ((dir = matchValue, (!runtimeNames.has(dir) ? runtimeNames.set(dir, (option_1 = Resolve_describePackage(host, dir), (option_1 != null) ? ((d = option_1, d.runtimeName)) : undefined)) : undefined, (matchValue_1 = getItemFromDict(runtimeNames, dir), (matchValue_1 == null) ? false : contains(matchValue_1, excludedRuntimeNames, {
|
|
872
|
+
Equals: (x, y) => (x === y),
|
|
873
|
+
GetHashCode: (x) => (stringHash(x) | 0),
|
|
874
|
+
})))))))) {
|
|
875
|
+
void (queue.push(fileName_1));
|
|
876
|
+
}
|
|
877
|
+
};
|
|
878
|
+
while (queue.length > 0) {
|
|
879
|
+
const fileName_2 = item(queue.length - 1, queue);
|
|
880
|
+
queue.splice(queue.length - 1, 1);
|
|
881
|
+
if (!seen.has(fileName_2)) {
|
|
882
|
+
const matchValue_2 = program.getSourceFile(fileName_2);
|
|
883
|
+
if (matchValue_2 != null) {
|
|
884
|
+
const sourceFile = matchValue_2;
|
|
885
|
+
addToSet(fileName_2, seen);
|
|
886
|
+
let imports;
|
|
887
|
+
const matchValue_3 = sourceFile.imports;
|
|
888
|
+
imports = (!(matchValue_3 === null || matchValue_3 === undefined) ? matchValue_3 : []);
|
|
889
|
+
for (let idx = 0; idx <= (imports.length - 1); idx++) {
|
|
890
|
+
const usage = item(idx, imports);
|
|
891
|
+
visit(program.getResolvedModuleFromModuleSpecifier(usage, sourceFile)?.resolvedModule?.resolvedFileName);
|
|
892
|
+
}
|
|
893
|
+
const enumerator = getEnumerator(sourceFile.referencedFiles);
|
|
894
|
+
try {
|
|
895
|
+
while (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
|
|
896
|
+
const reference = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]();
|
|
897
|
+
visit(host.path.resolve([host.path.dirname(sourceFile.fileName), reference.fileName]));
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
finally {
|
|
901
|
+
disposeSafe(enumerator);
|
|
902
|
+
}
|
|
903
|
+
const enumerator_1 = getEnumerator(sourceFile.typeReferenceDirectives);
|
|
904
|
+
try {
|
|
905
|
+
while (enumerator_1["System.Collections.IEnumerator.MoveNext"]()) {
|
|
906
|
+
const reference_1 = enumerator_1["System.Collections.Generic.IEnumerator`1.get_Current"]();
|
|
907
|
+
visit(program.getResolvedTypeReferenceDirective(sourceFile, reference_1.fileName, reference_1.resolutionMode)?.resolvedTypeReferenceDirective?.resolvedFileName);
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
finally {
|
|
911
|
+
disposeSafe(enumerator_1);
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
return toArray(seen);
|
|
917
|
+
}
|
|
918
|
+
|