starlight-fsharp-oracle 0.1.0 → 0.1.2

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.
Files changed (167) hide show
  1. package/dist/Extensions/StringBuilder.js +2 -5
  2. package/dist/Extensions/TextNode.js +29 -54
  3. package/dist/FSharp.Oracle.Schema/Schema.js +113 -218
  4. package/dist/Generate.js +33 -63
  5. package/dist/Helpers.js +1 -2
  6. package/dist/Plugin.js +17 -31
  7. package/dist/Render/Documentation.js +1 -2
  8. package/dist/Render/Entries.js +29 -34
  9. package/dist/Render/Pages.js +10 -19
  10. package/dist/Render/Primitives.js +19 -32
  11. package/dist/Themes.js +3 -5
  12. package/dist/fable_modules/Fable.Promise.3.2.0/AsyncIterable.fs +57 -0
  13. package/dist/fable_modules/Fable.Promise.3.2.0/AsyncIterable.fs.js +105 -0
  14. package/dist/fable_modules/Fable.Promise.3.2.0/Fable.Promise.fableproj +20 -0
  15. package/dist/fable_modules/Fable.Promise.3.2.0/Promise.fs +766 -0
  16. package/dist/fable_modules/Fable.Promise.3.2.0/Promise.fs.js +232 -0
  17. package/dist/fable_modules/Fable.Promise.3.2.0/PromiseImpl.fs +31 -0
  18. package/dist/fable_modules/Fable.Promise.3.2.0/PromiseImpl.fs.js +20 -0
  19. package/dist/fable_modules/Thoth.Json.Core.0.9.0/Decode.fs +1592 -0
  20. package/dist/fable_modules/Thoth.Json.Core.0.9.0/Decode.fs.js +1417 -0
  21. package/dist/fable_modules/Thoth.Json.Core.0.9.0/DecoderCE.fs +106 -0
  22. package/dist/fable_modules/Thoth.Json.Core.0.9.0/DecoderCE.fs.js +63 -0
  23. package/dist/fable_modules/Thoth.Json.Core.0.9.0/Encode.fs +380 -0
  24. package/dist/fable_modules/Thoth.Json.Core.0.9.0/Encode.fs.js +289 -0
  25. package/dist/fable_modules/Thoth.Json.Core.0.9.0/Thoth.Json.Core.fableproj +37 -0
  26. package/dist/fable_modules/Thoth.Json.Core.0.9.0/Types.fs +76 -0
  27. package/dist/fable_modules/Thoth.Json.Core.0.9.0/Types.fs.js +37 -0
  28. package/dist/fable_modules/Thoth.Json.Core.Auto.0.1.0/Casing.fs +113 -0
  29. package/dist/fable_modules/Thoth.Json.Core.Auto.0.1.0/Casing.fs.js +173 -0
  30. package/dist/fable_modules/Thoth.Json.Core.Auto.0.1.0/Decode.fs +1153 -0
  31. package/dist/fable_modules/Thoth.Json.Core.Auto.0.1.0/Decode.fs.js +622 -0
  32. package/dist/fable_modules/Thoth.Json.Core.Auto.0.1.0/Domain.fs +91 -0
  33. package/dist/fable_modules/Thoth.Json.Core.Auto.0.1.0/Domain.fs.js +103 -0
  34. package/dist/fable_modules/Thoth.Json.Core.Auto.0.1.0/Encode.fs +893 -0
  35. package/dist/fable_modules/Thoth.Json.Core.Auto.0.1.0/Encode.fs.js +836 -0
  36. package/dist/fable_modules/Thoth.Json.Core.Auto.0.1.0/Prelude.fs +435 -0
  37. package/dist/fable_modules/Thoth.Json.Core.Auto.0.1.0/Prelude.fs.js +389 -0
  38. package/dist/fable_modules/Thoth.Json.Core.Auto.0.1.0/Thoth.Json.Core.Auto.fableproj +43 -0
  39. package/dist/fable_modules/Thoth.Json.JavaScript.0.5.0/Decode.fs +88 -0
  40. package/dist/fable_modules/Thoth.Json.JavaScript.0.5.0/Decode.fs.js +102 -0
  41. package/dist/fable_modules/Thoth.Json.JavaScript.0.5.0/Encode.fs +40 -0
  42. package/dist/fable_modules/Thoth.Json.JavaScript.0.5.0/Encode.fs.js +59 -0
  43. package/dist/fable_modules/Thoth.Json.JavaScript.0.5.0/Thoth.Json.JavaScript.fableproj +31 -0
  44. package/dist/fable_modules/fable-library-js.5.0.0-rc.7/Array.js +1347 -0
  45. package/dist/fable_modules/fable-library-js.5.0.0-rc.7/Async.js +134 -0
  46. package/dist/fable_modules/fable-library-js.5.0.0-rc.7/AsyncBuilder.js +183 -0
  47. package/dist/fable_modules/fable-library-js.5.0.0-rc.7/BigInt.js +306 -0
  48. package/dist/fable_modules/fable-library-js.5.0.0-rc.7/BitConverter.js +138 -0
  49. package/dist/fable_modules/fable-library-js.5.0.0-rc.7/Boolean.js +22 -0
  50. package/dist/fable_modules/fable-library-js.5.0.0-rc.7/CHANGELOG.md +191 -0
  51. package/dist/fable_modules/fable-library-js.5.0.0-rc.7/Char.js +202 -0
  52. package/dist/fable_modules/fable-library-js.5.0.0-rc.7/Choice.js +184 -0
  53. package/dist/fable_modules/fable-library-js.5.0.0-rc.7/CollectionUtil.js +182 -0
  54. package/dist/fable_modules/fable-library-js.5.0.0-rc.7/ConditionalWeakTable.js +21 -0
  55. package/dist/fable_modules/fable-library-js.5.0.0-rc.7/Date.js +755 -0
  56. package/dist/fable_modules/fable-library-js.5.0.0-rc.7/DateOffset.js +261 -0
  57. package/dist/fable_modules/fable-library-js.5.0.0-rc.7/DateOnly.js +124 -0
  58. package/dist/fable_modules/fable-library-js.5.0.0-rc.7/Decimal.js +236 -0
  59. package/dist/fable_modules/fable-library-js.5.0.0-rc.7/Double.js +47 -0
  60. package/dist/fable_modules/fable-library-js.5.0.0-rc.7/Encoding.js +185 -0
  61. package/dist/fable_modules/fable-library-js.5.0.0-rc.7/Event.js +93 -0
  62. package/dist/fable_modules/fable-library-js.5.0.0-rc.7/FSharp.Collections.js +45 -0
  63. package/dist/fable_modules/fable-library-js.5.0.0-rc.7/FSharp.Core.CompilerServices.js +27 -0
  64. package/dist/fable_modules/fable-library-js.5.0.0-rc.7/FSharp.Core.js +156 -0
  65. package/dist/fable_modules/fable-library-js.5.0.0-rc.7/Global.js +29 -0
  66. package/dist/fable_modules/fable-library-js.5.0.0-rc.7/Guid.js +161 -0
  67. package/dist/fable_modules/fable-library-js.5.0.0-rc.7/Int32.js +135 -0
  68. package/dist/fable_modules/fable-library-js.5.0.0-rc.7/List.js +1323 -0
  69. package/dist/fable_modules/fable-library-js.5.0.0-rc.7/Long.js +47 -0
  70. package/dist/fable_modules/fable-library-js.5.0.0-rc.7/MailboxProcessor.js +94 -0
  71. package/dist/fable_modules/fable-library-js.5.0.0-rc.7/Map.js +1396 -0
  72. package/dist/fable_modules/fable-library-js.5.0.0-rc.7/MapUtil.js +130 -0
  73. package/dist/fable_modules/fable-library-js.5.0.0-rc.7/MutableMap.js +339 -0
  74. package/dist/fable_modules/fable-library-js.5.0.0-rc.7/MutableSet.js +233 -0
  75. package/dist/fable_modules/fable-library-js.5.0.0-rc.7/Native.js +14 -0
  76. package/dist/fable_modules/fable-library-js.5.0.0-rc.7/Numeric.js +75 -0
  77. package/dist/fable_modules/fable-library-js.5.0.0-rc.7/Observable.js +113 -0
  78. package/dist/fable_modules/fable-library-js.5.0.0-rc.7/Option.js +104 -0
  79. package/dist/fable_modules/fable-library-js.5.0.0-rc.7/README.md +3 -0
  80. package/dist/fable_modules/fable-library-js.5.0.0-rc.7/Random.js +172 -0
  81. package/dist/fable_modules/fable-library-js.5.0.0-rc.7/Range.js +45 -0
  82. package/dist/fable_modules/fable-library-js.5.0.0-rc.7/Reflection.js +460 -0
  83. package/dist/fable_modules/fable-library-js.5.0.0-rc.7/RegExp.js +141 -0
  84. package/dist/fable_modules/fable-library-js.5.0.0-rc.7/Result.js +165 -0
  85. package/dist/fable_modules/fable-library-js.5.0.0-rc.7/Seq.js +1409 -0
  86. package/dist/fable_modules/fable-library-js.5.0.0-rc.7/Seq2.js +111 -0
  87. package/dist/fable_modules/fable-library-js.5.0.0-rc.7/Set.js +1788 -0
  88. package/dist/fable_modules/fable-library-js.5.0.0-rc.7/String.js +649 -0
  89. package/dist/fable_modules/fable-library-js.5.0.0-rc.7/System.Collections.Generic.js +333 -0
  90. package/dist/fable_modules/fable-library-js.5.0.0-rc.7/System.Text.js +168 -0
  91. package/dist/fable_modules/fable-library-js.5.0.0-rc.7/System.js +283 -0
  92. package/dist/fable_modules/fable-library-js.5.0.0-rc.7/TimeOnly.js +122 -0
  93. package/dist/fable_modules/fable-library-js.5.0.0-rc.7/TimeSpan.js +180 -0
  94. package/dist/fable_modules/fable-library-js.5.0.0-rc.7/Timer.js +67 -0
  95. package/dist/fable_modules/fable-library-js.5.0.0-rc.7/Types.js +198 -0
  96. package/dist/fable_modules/fable-library-js.5.0.0-rc.7/Unicode.13.0.0.js +4 -0
  97. package/dist/fable_modules/fable-library-js.5.0.0-rc.7/Uri.js +165 -0
  98. package/dist/fable_modules/fable-library-js.5.0.0-rc.7/Util.js +792 -0
  99. package/dist/fable_modules/fable-library-js.5.0.0-rc.7/big.d.ts +338 -0
  100. package/dist/fable_modules/fable-library-js.5.0.0-rc.7/lib/big.js +825 -0
  101. package/dist/fable_modules/fable-library-js.5.0.0-rc.7/package.json +24 -0
  102. package/dist/fable_modules/fable-library-js.5.0.0-rc.7/quotation.js +618 -0
  103. package/package.json +4 -5
  104. package/packages/FSharp.Oracle/XmlDoc.fs +12 -1
  105. package/packages/FSharp.Oracle/obj/Debug/net10.0/.NETCoreApp,Version=v10.0.AssemblyAttributes.fs +3 -0
  106. package/packages/FSharp.Oracle/obj/Debug/net10.0/FSharp.Oracle.AssemblyInfo.fs +17 -0
  107. package/packages/FSharp.Oracle/obj/Release/net10.0/.NETCoreApp,Version=v10.0.AssemblyAttributes.fs +3 -0
  108. package/packages/FSharp.Oracle/obj/Release/net10.0/FSharp.Oracle.AssemblyInfo.fs +17 -0
  109. package/packages/FSharp.Oracle.Schema/obj/Debug/net10.0/.NETCoreApp,Version=v10.0.AssemblyAttributes.fs +3 -0
  110. package/packages/FSharp.Oracle.Schema/obj/Debug/net10.0/FSharp.Oracle.Schema.AssemblyInfo.fs +17 -0
  111. package/packages/FSharp.Oracle.Schema/obj/Release/net10.0/.NETCoreApp,Version=v10.0.AssemblyAttributes.fs +3 -0
  112. package/packages/FSharp.Oracle.Schema/obj/Release/net10.0/FSharp.Oracle.Schema.AssemblyInfo.fs +17 -0
  113. package/oracle-bin/FSharp.Compiler.Service.dll +0 -0
  114. package/oracle-bin/FSharp.Core.dll +0 -0
  115. package/oracle-bin/FSharp.DependencyManager.Nuget.dll +0 -0
  116. package/oracle-bin/FSharp.Oracle.Schema.dll +0 -0
  117. package/oracle-bin/FSharp.Oracle.Schema.pdb +0 -0
  118. package/oracle-bin/FSharp.Oracle.Schema.xml +0 -219
  119. package/oracle-bin/Fable.Core.dll +0 -0
  120. package/oracle-bin/Oracle +0 -0
  121. package/oracle-bin/Oracle.deps.json +0 -280
  122. package/oracle-bin/Oracle.dll +0 -0
  123. package/oracle-bin/Oracle.pdb +0 -0
  124. package/oracle-bin/Oracle.runtimeconfig.json +0 -13
  125. package/oracle-bin/Oracle.xml +0 -111
  126. package/oracle-bin/Thoth.Json.Core.Auto.dll +0 -0
  127. package/oracle-bin/Thoth.Json.Core.dll +0 -0
  128. package/oracle-bin/Thoth.Json.System.Text.Json.dll +0 -0
  129. package/oracle-bin/cs/FSharp.Compiler.Service.resources.dll +0 -0
  130. package/oracle-bin/cs/FSharp.Core.resources.dll +0 -0
  131. package/oracle-bin/cs/FSharp.DependencyManager.Nuget.resources.dll +0 -0
  132. package/oracle-bin/de/FSharp.Compiler.Service.resources.dll +0 -0
  133. package/oracle-bin/de/FSharp.Core.resources.dll +0 -0
  134. package/oracle-bin/de/FSharp.DependencyManager.Nuget.resources.dll +0 -0
  135. package/oracle-bin/es/FSharp.Compiler.Service.resources.dll +0 -0
  136. package/oracle-bin/es/FSharp.Core.resources.dll +0 -0
  137. package/oracle-bin/es/FSharp.DependencyManager.Nuget.resources.dll +0 -0
  138. package/oracle-bin/fr/FSharp.Compiler.Service.resources.dll +0 -0
  139. package/oracle-bin/fr/FSharp.Core.resources.dll +0 -0
  140. package/oracle-bin/fr/FSharp.DependencyManager.Nuget.resources.dll +0 -0
  141. package/oracle-bin/it/FSharp.Compiler.Service.resources.dll +0 -0
  142. package/oracle-bin/it/FSharp.Core.resources.dll +0 -0
  143. package/oracle-bin/it/FSharp.DependencyManager.Nuget.resources.dll +0 -0
  144. package/oracle-bin/ja/FSharp.Compiler.Service.resources.dll +0 -0
  145. package/oracle-bin/ja/FSharp.Core.resources.dll +0 -0
  146. package/oracle-bin/ja/FSharp.DependencyManager.Nuget.resources.dll +0 -0
  147. package/oracle-bin/ko/FSharp.Compiler.Service.resources.dll +0 -0
  148. package/oracle-bin/ko/FSharp.Core.resources.dll +0 -0
  149. package/oracle-bin/ko/FSharp.DependencyManager.Nuget.resources.dll +0 -0
  150. package/oracle-bin/pl/FSharp.Compiler.Service.resources.dll +0 -0
  151. package/oracle-bin/pl/FSharp.Core.resources.dll +0 -0
  152. package/oracle-bin/pl/FSharp.DependencyManager.Nuget.resources.dll +0 -0
  153. package/oracle-bin/pt-BR/FSharp.Compiler.Service.resources.dll +0 -0
  154. package/oracle-bin/pt-BR/FSharp.Core.resources.dll +0 -0
  155. package/oracle-bin/pt-BR/FSharp.DependencyManager.Nuget.resources.dll +0 -0
  156. package/oracle-bin/ru/FSharp.Compiler.Service.resources.dll +0 -0
  157. package/oracle-bin/ru/FSharp.Core.resources.dll +0 -0
  158. package/oracle-bin/ru/FSharp.DependencyManager.Nuget.resources.dll +0 -0
  159. package/oracle-bin/tr/FSharp.Compiler.Service.resources.dll +0 -0
  160. package/oracle-bin/tr/FSharp.Core.resources.dll +0 -0
  161. package/oracle-bin/tr/FSharp.DependencyManager.Nuget.resources.dll +0 -0
  162. package/oracle-bin/zh-Hans/FSharp.Compiler.Service.resources.dll +0 -0
  163. package/oracle-bin/zh-Hans/FSharp.Core.resources.dll +0 -0
  164. package/oracle-bin/zh-Hans/FSharp.DependencyManager.Nuget.resources.dll +0 -0
  165. package/oracle-bin/zh-Hant/FSharp.Compiler.Service.resources.dll +0 -0
  166. package/oracle-bin/zh-Hant/FSharp.Core.resources.dll +0 -0
  167. package/oracle-bin/zh-Hant/FSharp.DependencyManager.Nuget.resources.dll +0 -0
@@ -0,0 +1,460 @@
1
+ import { Record, Union } from "./Types.js";
2
+ import { Exception, combineHashCodes, equalArraysWith, stringHash } from "./Util.js";
3
+ import Decimal from "./Decimal.js";
4
+ export class CaseInfo {
5
+ constructor(declaringType, tag, name, fields) {
6
+ this.declaringType = declaringType;
7
+ this.tag = tag;
8
+ this.name = name;
9
+ this.fields = fields;
10
+ }
11
+ }
12
+ export class MethodInfo {
13
+ constructor(name, parameters, returnType) {
14
+ this.name = name;
15
+ this.parameters = parameters;
16
+ this.returnType = returnType;
17
+ }
18
+ }
19
+ export class TypeInfo {
20
+ constructor(fullname, generics, construct, parent, fields, cases, enumCases) {
21
+ this.fullname = fullname;
22
+ this.generics = generics;
23
+ this.construct = construct;
24
+ this.parent = parent;
25
+ this.fields = fields;
26
+ this.cases = cases;
27
+ this.enumCases = enumCases;
28
+ }
29
+ toString() {
30
+ return fullName(this);
31
+ }
32
+ GetHashCode() {
33
+ return getHashCode(this);
34
+ }
35
+ Equals(other) {
36
+ return equals(this, other);
37
+ }
38
+ }
39
+ export class GenericParameter extends TypeInfo {
40
+ constructor(name) {
41
+ super(name);
42
+ }
43
+ }
44
+ export function getGenerics(t) {
45
+ return t.generics != null ? t.generics : [];
46
+ }
47
+ export function getHashCode(t) {
48
+ const fullnameHash = stringHash(t.fullname);
49
+ const genHashes = getGenerics(t).map(getHashCode);
50
+ return combineHashCodes([fullnameHash, ...genHashes]);
51
+ }
52
+ export function equals(t1, t2) {
53
+ if (t1.fullname === "") { // Anonymous records
54
+ return t2.fullname === ""
55
+ && equalArraysWith(getRecordElements(t1), getRecordElements(t2), ([k1, v1], [k2, v2]) => k1 === k2 && equals(v1, v2));
56
+ }
57
+ else {
58
+ return t1.fullname === t2.fullname
59
+ && equalArraysWith(getGenerics(t1), getGenerics(t2), equals);
60
+ }
61
+ }
62
+ export function class_type(fullname, generics, construct, parent) {
63
+ return new TypeInfo(fullname, generics, construct, parent);
64
+ }
65
+ export function record_type(fullname, generics, construct, fields) {
66
+ return new TypeInfo(fullname, generics, construct, undefined, fields);
67
+ }
68
+ export function anonRecord_type(...fields) {
69
+ return new TypeInfo("", undefined, undefined, undefined, () => fields);
70
+ }
71
+ export function union_type(fullname, generics, construct, cases) {
72
+ const t = new TypeInfo(fullname, generics, construct, undefined, undefined, () => {
73
+ const caseNames = construct.prototype.cases();
74
+ return cases().map((fields, i) => new CaseInfo(t, i, caseNames[i], fields));
75
+ });
76
+ return t;
77
+ }
78
+ export function tuple_type(...generics) {
79
+ return new TypeInfo("System.Tuple`" + generics.length, generics);
80
+ }
81
+ export function delegate_type(...generics) {
82
+ return new TypeInfo("System.Func`" + generics.length, generics);
83
+ }
84
+ export function lambda_type(argType, returnType) {
85
+ return new TypeInfo("Microsoft.FSharp.Core.FSharpFunc`2", [argType, returnType]);
86
+ }
87
+ export function option_type(generic) {
88
+ return new TypeInfo("Microsoft.FSharp.Core.FSharpOption`1", [generic]);
89
+ }
90
+ export function list_type(generic) {
91
+ return new TypeInfo("Microsoft.FSharp.Collections.FSharpList`1", [generic]);
92
+ }
93
+ export function array_type(generic) {
94
+ return new TypeInfo("[]", [generic]);
95
+ }
96
+ export function enum_type(fullname, underlyingType, enumCases) {
97
+ return new TypeInfo(fullname, [underlyingType], undefined, undefined, undefined, undefined, enumCases);
98
+ }
99
+ export function measure_type(fullname) {
100
+ return new TypeInfo(fullname);
101
+ }
102
+ export function generic_type(name) {
103
+ return new GenericParameter(name);
104
+ }
105
+ export const obj_type = new TypeInfo("System.Object");
106
+ export const unit_type = new TypeInfo("Microsoft.FSharp.Core.Unit");
107
+ export const char_type = new TypeInfo("System.Char");
108
+ export const string_type = new TypeInfo("System.String");
109
+ export const bool_type = new TypeInfo("System.Boolean");
110
+ export const int8_type = new TypeInfo("System.SByte");
111
+ export const uint8_type = new TypeInfo("System.Byte");
112
+ export const int16_type = new TypeInfo("System.Int16");
113
+ export const uint16_type = new TypeInfo("System.UInt16");
114
+ export const int32_type = new TypeInfo("System.Int32");
115
+ export const uint32_type = new TypeInfo("System.UInt32");
116
+ export const int64_type = new TypeInfo("System.Int64");
117
+ export const uint64_type = new TypeInfo("System.UInt64");
118
+ export const int128_type = new TypeInfo("System.Int128");
119
+ export const uint128_type = new TypeInfo("System.UInt128");
120
+ export const nativeint_type = new TypeInfo("System.IntPtr");
121
+ export const unativeint_type = new TypeInfo("System.UIntPtr");
122
+ export const float16_type = new TypeInfo("System.Half");
123
+ export const float32_type = new TypeInfo("System.Single");
124
+ export const float64_type = new TypeInfo("System.Double");
125
+ export const decimal_type = new TypeInfo("System.Decimal");
126
+ export const bigint_type = new TypeInfo("System.Numerics.BigInteger");
127
+ export function name(info) {
128
+ if (Array.isArray(info)) {
129
+ return info[0];
130
+ }
131
+ else if (info instanceof TypeInfo) {
132
+ const elemType = getElementType(info);
133
+ if (elemType != null) {
134
+ return name(elemType) + "[]";
135
+ }
136
+ else {
137
+ const i = info.fullname.lastIndexOf(".");
138
+ return i === -1 ? info.fullname : info.fullname.slice(i + 1);
139
+ }
140
+ }
141
+ else {
142
+ return info.name;
143
+ }
144
+ }
145
+ export function fullName(t) {
146
+ const elemType = getElementType(t);
147
+ if (elemType != null) {
148
+ return fullName(elemType) + "[]";
149
+ }
150
+ else if (t.generics == null || t.generics.length === 0) {
151
+ return t.fullname;
152
+ }
153
+ else {
154
+ return t.fullname + "[" + t.generics.map((x) => fullName(x)).join(",") + "]";
155
+ }
156
+ }
157
+ export function namespace(t) {
158
+ const elemType = getElementType(t);
159
+ if (elemType != null) {
160
+ return namespace(elemType);
161
+ }
162
+ else {
163
+ const i = t.fullname.lastIndexOf(".");
164
+ return i === -1 ? "" : t.fullname.slice(0, i);
165
+ }
166
+ }
167
+ export function isArray(t) {
168
+ return getElementType(t) != null;
169
+ }
170
+ export function getElementType(t) {
171
+ return t.fullname === "[]" && t.generics?.length === 1 ? t.generics[0] : undefined;
172
+ }
173
+ export function isGenericType(t) {
174
+ return t.generics != null && t.generics.length > 0;
175
+ }
176
+ export function isGenericParameter(t) {
177
+ return t instanceof GenericParameter;
178
+ }
179
+ export function isEnum(t) {
180
+ return t.enumCases != null && t.enumCases.length > 0;
181
+ }
182
+ export function isSubclassOf(t1, t2) {
183
+ return (t2.fullname === obj_type.fullname) || (t1.parent != null && (t1.parent.Equals(t2) || isSubclassOf(t1.parent, t2)));
184
+ }
185
+ function isErasedToNumber(t) {
186
+ return isEnum(t) || [
187
+ int8_type.fullname,
188
+ uint8_type.fullname,
189
+ int16_type.fullname,
190
+ uint16_type.fullname,
191
+ int32_type.fullname,
192
+ uint32_type.fullname,
193
+ float16_type.fullname,
194
+ float32_type.fullname,
195
+ float64_type.fullname,
196
+ ].includes(t.fullname);
197
+ }
198
+ function isErasedToBigInt(t) {
199
+ return isEnum(t) || [
200
+ int64_type.fullname,
201
+ uint64_type.fullname,
202
+ int128_type.fullname,
203
+ uint128_type.fullname,
204
+ nativeint_type.fullname,
205
+ unativeint_type.fullname,
206
+ bigint_type.fullname,
207
+ ].includes(t.fullname);
208
+ }
209
+ export function isInstanceOfType(t, o) {
210
+ if (t.fullname === obj_type.fullname)
211
+ return true;
212
+ switch (typeof o) {
213
+ case "boolean":
214
+ return t.fullname === bool_type.fullname;
215
+ case "string":
216
+ return t.fullname === string_type.fullname;
217
+ case "function":
218
+ return isFunction(t);
219
+ case "number":
220
+ return isErasedToNumber(t);
221
+ case "bigint":
222
+ return isErasedToBigInt(t);
223
+ default:
224
+ return t.construct != null && o instanceof t.construct;
225
+ }
226
+ }
227
+ /**
228
+ * This doesn't replace types for fields (records) or cases (unions)
229
+ * but it should be enough for type comparison purposes
230
+ */
231
+ export function getGenericTypeDefinition(t) {
232
+ return t.generics == null ? t : new TypeInfo(t.fullname, t.generics.map(() => obj_type));
233
+ }
234
+ export function getEnumUnderlyingType(t) {
235
+ return t.generics?.[0];
236
+ }
237
+ export function getEnumValues(t) {
238
+ if (isEnum(t) && t.enumCases != null) {
239
+ return t.enumCases.map((kv) => kv[1]);
240
+ }
241
+ else {
242
+ throw new Exception(`${t.fullname} is not an enum type`);
243
+ }
244
+ }
245
+ export function getEnumNames(t) {
246
+ if (isEnum(t) && t.enumCases != null) {
247
+ return t.enumCases.map((kv) => kv[0]);
248
+ }
249
+ else {
250
+ throw new Exception(`${t.fullname} is not an enum type`);
251
+ }
252
+ }
253
+ function getEnumCase(t, v) {
254
+ if (t.enumCases != null) {
255
+ if (typeof v === "string") {
256
+ for (const kv of t.enumCases) {
257
+ if (kv[0] === v) {
258
+ return kv;
259
+ }
260
+ }
261
+ throw new Exception(`'${v}' was not found in ${t.fullname}`);
262
+ }
263
+ else {
264
+ for (const kv of t.enumCases) {
265
+ if (kv[1] === v) {
266
+ return kv;
267
+ }
268
+ }
269
+ // .NET returns the number even if it doesn't match any of the cases
270
+ return ["", v];
271
+ }
272
+ }
273
+ else {
274
+ throw new Exception(`${t.fullname} is not an enum type`);
275
+ }
276
+ }
277
+ export function parseEnum(t, str) {
278
+ // TODO: better int parsing here, parseInt ceils floats: "4.8" -> 4
279
+ const value = parseInt(str, 10);
280
+ return getEnumCase(t, isNaN(value) ? str : value)[1];
281
+ }
282
+ export function tryParseEnum(t, str, defValue) {
283
+ try {
284
+ defValue.contents = parseEnum(t, str);
285
+ return true;
286
+ }
287
+ catch {
288
+ return false;
289
+ }
290
+ }
291
+ export function getEnumName(t, v) {
292
+ return getEnumCase(t, v)[0];
293
+ }
294
+ export function isEnumDefined(t, v) {
295
+ try {
296
+ const kv = getEnumCase(t, v);
297
+ return kv[0] != null && kv[0] !== "";
298
+ }
299
+ catch {
300
+ // supress error
301
+ }
302
+ return false;
303
+ }
304
+ // FSharpType
305
+ export function getUnionCases(t) {
306
+ if (t.cases != null) {
307
+ return t.cases();
308
+ }
309
+ else {
310
+ throw new Exception(`${t.fullname} is not an F# union type`);
311
+ }
312
+ }
313
+ export function getRecordElements(t) {
314
+ if (t.fields != null) {
315
+ return t.fields();
316
+ }
317
+ else {
318
+ throw new Exception(`${t.fullname} is not an F# record type`);
319
+ }
320
+ }
321
+ export function getTupleElements(t) {
322
+ if (isTuple(t) && t.generics != null) {
323
+ return t.generics;
324
+ }
325
+ else {
326
+ throw new Exception(`${t.fullname} is not a tuple type`);
327
+ }
328
+ }
329
+ export function getFunctionElements(t) {
330
+ if (isFunction(t) && t.generics != null) {
331
+ const gen = t.generics;
332
+ return [gen[0], gen[1]];
333
+ }
334
+ else {
335
+ throw new Exception(`${t.fullname} is not an F# function type`);
336
+ }
337
+ }
338
+ export function isUnion(t) {
339
+ return t instanceof TypeInfo ? t.cases != null : t instanceof Union;
340
+ }
341
+ export function isRecord(t) {
342
+ return t instanceof TypeInfo ? t.fields != null : t instanceof Record;
343
+ }
344
+ export function isTuple(t) {
345
+ return t.fullname.startsWith("System.Tuple");
346
+ }
347
+ // In .NET this is false for delegates
348
+ export function isFunction(t) {
349
+ return t.fullname === "Microsoft.FSharp.Core.FSharpFunc`2";
350
+ }
351
+ // FSharpValue
352
+ export function getUnionFields(v, t) {
353
+ const cases = getUnionCases(t);
354
+ const case_ = cases[v.tag];
355
+ if (case_ == null) {
356
+ throw new Exception(`Cannot find case ${v.name} in union type`);
357
+ }
358
+ return [case_, v.fields];
359
+ }
360
+ export function getUnionCaseFields(uci) {
361
+ return uci.fields == null ? [] : uci.fields;
362
+ }
363
+ // This is used as replacement of `FSharpValue.GetRecordFields`
364
+ // For `FSharpTypes.GetRecordFields` see `getRecordElements`
365
+ // Object.keys returns keys in the order they were added to the object
366
+ export function getRecordFields(v) {
367
+ return Object.keys(v).map((k) => v[k]);
368
+ }
369
+ export function getRecordField(v, field) {
370
+ return v[field[0]];
371
+ }
372
+ export function getTupleFields(v) {
373
+ return v;
374
+ }
375
+ export function getTupleField(v, i) {
376
+ return v[i];
377
+ }
378
+ export function makeUnion(uci, values) {
379
+ const expectedLength = (uci.fields || []).length;
380
+ if (values.length !== expectedLength) {
381
+ throw new Exception(`Expected an array of length ${expectedLength} but got ${values.length}`);
382
+ }
383
+ const construct = uci.declaringType.construct;
384
+ if (construct == null) {
385
+ return {};
386
+ }
387
+ const isSingleCase = uci.declaringType.cases ? uci.declaringType.cases().length == 1 : false;
388
+ if (isSingleCase) {
389
+ return new construct(...values);
390
+ }
391
+ else {
392
+ return new construct(uci.tag, values);
393
+ }
394
+ }
395
+ export function makeRecord(t, values) {
396
+ const fields = getRecordElements(t);
397
+ if (fields.length !== values.length) {
398
+ throw new Exception(`Expected an array of length ${fields.length} but got ${values.length}`);
399
+ }
400
+ return t.construct != null
401
+ ? new t.construct(...values)
402
+ : fields.reduce((obj, [key, _t], i) => {
403
+ obj[key] = values[i];
404
+ return obj;
405
+ }, {});
406
+ }
407
+ export function makeTuple(values, _t) {
408
+ return values;
409
+ }
410
+ export function makeGenericType(t, generics) {
411
+ return new TypeInfo(t.fullname, generics, t.construct, t.parent, t.fields, t.cases);
412
+ }
413
+ export function createInstance(t, consArgs) {
414
+ // TODO: Check if consArgs length is same as t.construct?
415
+ // (Arg types can still be different)
416
+ if (typeof t.construct === "function") {
417
+ return new t.construct(...(consArgs ?? []));
418
+ }
419
+ else if (isErasedToNumber(t)) {
420
+ return 0;
421
+ }
422
+ else if (isErasedToBigInt(t)) {
423
+ return 0n;
424
+ }
425
+ else {
426
+ switch (t.fullname) {
427
+ case obj_type.fullname:
428
+ return {};
429
+ case bool_type.fullname:
430
+ return false;
431
+ case decimal_type.fullname:
432
+ return new Decimal(0);
433
+ case char_type.fullname:
434
+ return "\0";
435
+ default:
436
+ throw new Exception(`Cannot access constructor of ${t.fullname}`);
437
+ }
438
+ }
439
+ }
440
+ export function getValue(propertyInfo, v) {
441
+ return v[propertyInfo[0]];
442
+ }
443
+ // Fable.Core.Reflection
444
+ function assertUnion(x) {
445
+ if (!(x instanceof Union)) {
446
+ throw new Exception(`Value is not an F# union type`);
447
+ }
448
+ }
449
+ export function getCaseTag(x) {
450
+ assertUnion(x);
451
+ return x.tag;
452
+ }
453
+ export function getCaseName(x) {
454
+ assertUnion(x);
455
+ return x.cases()[x.tag];
456
+ }
457
+ export function getCaseFields(x) {
458
+ assertUnion(x);
459
+ return x.fields;
460
+ }
@@ -0,0 +1,141 @@
1
+ import { Exception } from "./Util.js";
2
+ export function create(pattern, options = 0) {
3
+ // Supported RegexOptions
4
+ // * IgnoreCase: 0x0001
5
+ // * Multiline: 0x0002
6
+ // * Compiled: 0x0008 (ignored)
7
+ // * Singleline: 0x0010
8
+ // * ECMAScript: 0x0100 (ignored)
9
+ if ((options & ~(1 ^ 2 ^ 8 ^ 16 ^ 256)) !== 0) {
10
+ throw new Exception("RegexOptions only supports: IgnoreCase, Multiline, Compiled, Singleline and ECMAScript");
11
+ }
12
+ // Set always global and unicode flags for compatibility with dotnet, see #2925
13
+ let flags = "gu";
14
+ flags += options & 1 ? "i" : ""; // 0x0001 RegexOptions.IgnoreCase
15
+ flags += options & 2 ? "m" : "";
16
+ flags += options & 16 ? "s" : "";
17
+ return new RegExp(pattern, flags);
18
+ }
19
+ // From http://stackoverflow.com/questions/3446170/escape-string-for-use-in-javascript-regex
20
+ export function escape(str) {
21
+ // Matches the characters escaped by .NET's Regex.Escape.
22
+ // Note:
23
+ //
24
+ // .NET also escapes space and # (relevant for IgnorePatternWhitespace mode),
25
+ // but JS unicode-mode regex rejects \ and \# as invalid escapes, and we don't
26
+ // support IgnorePatternWhitespace, so we omit them.
27
+ //
28
+ // .NET does not escape ] and } but JS unicode-mode regex rejects bare ] and }
29
+ // as invalid, so we escape them too for compatibility.
30
+ return str.replace(/[$()*+.?[\\\^{|}\]]/g, "\\$&");
31
+ }
32
+ export function unescape(str) {
33
+ return str.replace(/\\([$()*+.?[\\\^{|}\]])/g, "$1");
34
+ }
35
+ export function isMatch(reg, input, startAt = 0) {
36
+ reg.lastIndex = startAt;
37
+ return reg.test(input);
38
+ }
39
+ export function match(reg, input, startAt = 0) {
40
+ reg.lastIndex = startAt;
41
+ return reg.exec(input);
42
+ }
43
+ export function matches(reg, input, startAt = 0) {
44
+ if (input == null) {
45
+ throw new Exception("Input cannot ve null");
46
+ }
47
+ if (!reg.global) {
48
+ throw new Exception("Non-global RegExp"); // Prevent infinite loop
49
+ }
50
+ reg.lastIndex = startAt;
51
+ const matches = [];
52
+ let m;
53
+ let lastMatchIndex = -1;
54
+ while ((m = reg.exec(input)) != null) {
55
+ // It can happen even global regex get stuck, see #2845
56
+ if (m.index === lastMatchIndex) {
57
+ reg.lastIndex++;
58
+ }
59
+ else {
60
+ lastMatchIndex = m.index;
61
+ matches.push(m);
62
+ }
63
+ }
64
+ return matches;
65
+ }
66
+ export function options(reg) {
67
+ let options = 256; // ECMAScript
68
+ options |= reg.ignoreCase ? 1 : 0;
69
+ options |= reg.multiline ? 2 : 0;
70
+ return options;
71
+ }
72
+ export function replace(reg, input, replacement, limit, offset = 0) {
73
+ function replacer() {
74
+ let res = arguments[0];
75
+ if (limit) {
76
+ limit--;
77
+ const match = [];
78
+ const len = arguments.length;
79
+ // arguments: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#specifying_a_function_as_a_parameter
80
+ // * match: matched substring
81
+ // * p1, p2, ...: nth capture group string
82
+ // * offset: offset of matched substring
83
+ // * string: whole string examined
84
+ // * groups: named capturing groups
85
+ // ONLY if regex contains a named capture group AND browser supports named groups
86
+ // -> last element can be groups OR input string
87
+ // -> check if last element is string
88
+ const withGroups = typeof arguments[len - 1] !== "string";
89
+ let pLast = withGroups ? len - 3 : len - 2;
90
+ for (let i = 0; i < pLast; i++) {
91
+ match.push(arguments[i]);
92
+ }
93
+ match.index = arguments[pLast++];
94
+ match.input = arguments[pLast++];
95
+ if (withGroups) {
96
+ match.groups = arguments[pLast];
97
+ }
98
+ res = replacement(match);
99
+ }
100
+ return res;
101
+ }
102
+ if (typeof reg === "string") {
103
+ const tmp = reg;
104
+ reg = create(input, limit ?? 0);
105
+ input = tmp;
106
+ limit = undefined;
107
+ }
108
+ if (typeof replacement === "function") {
109
+ limit = limit == null ? -1 : limit;
110
+ return input.substring(0, offset) + input.substring(offset).replace(reg, replacer);
111
+ }
112
+ else {
113
+ replacement =
114
+ replacement
115
+ // $0 doesn't work with JS regex, see #1155
116
+ .replace(/\$0/g, (_s) => "$&")
117
+ // named groups in replacement are `${name}` in .Net, but `$<name>` in JS (in regex: groups are `(?<name>...)` in both)
118
+ .replace(/\${([^}]+)}/g, "\$<$1>");
119
+ if (limit != null) {
120
+ let m;
121
+ const sub1 = input.substring(offset);
122
+ const _matches = matches(reg, sub1);
123
+ const sub2 = matches.length > limit ? (m = _matches[limit - 1], sub1.substring(0, m.index + m[0].length)) : sub1;
124
+ return input.substring(0, offset) + sub2.replace(reg, replacement)
125
+ + input.substring(offset + sub2.length);
126
+ }
127
+ else {
128
+ return input.replace(reg, replacement);
129
+ }
130
+ }
131
+ }
132
+ export function split(reg, input, limit, offset = 0) {
133
+ if (typeof reg === "string") {
134
+ const tmp = reg;
135
+ reg = create(input, limit ?? 0);
136
+ input = tmp;
137
+ limit = undefined;
138
+ }
139
+ input = input.substring(offset);
140
+ return input.split(reg, limit);
141
+ }