@glutinum/cli 0.14.0 → 0.14.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.
Files changed (144) hide show
  1. package/dist/fable_modules/Fable.Promise.3.2.1/AsyncIterable.fs +89 -0
  2. package/dist/fable_modules/Fable.Promise.3.2.1/AsyncIterable.fs.js +105 -0
  3. package/dist/fable_modules/Fable.Promise.3.2.1/Fable.Promise.fableproj +25 -0
  4. package/dist/fable_modules/Fable.Promise.3.2.1/Promise.fs +842 -0
  5. package/dist/fable_modules/Fable.Promise.3.2.1/Promise.fs.js +232 -0
  6. package/dist/fable_modules/Fable.Promise.3.2.1/PromiseImpl.fs +31 -0
  7. package/dist/fable_modules/Fable.Promise.3.2.1/PromiseImpl.fs.js +20 -0
  8. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Array.fs +235 -0
  9. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Array.fs.js +384 -0
  10. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AssemblyInfo.fs +19 -0
  11. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Async.fs +287 -0
  12. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Async.fs.js +128 -0
  13. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncOption.fs +127 -0
  14. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncOptionCE.fs +174 -0
  15. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncOptionCE.fs.js +37 -0
  16. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncOptionOp.fs +24 -0
  17. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResult.fs +483 -0
  18. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultCE.fs +201 -0
  19. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultCE.fs.js +18 -0
  20. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultOp.fs +24 -0
  21. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultOption.fs +87 -0
  22. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultOption.fs.js +26 -0
  23. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultOptionCE.fs +236 -0
  24. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultOptionCE.fs.js +18 -0
  25. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultOptionOp.fs +24 -0
  26. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncValidation.fs +185 -0
  27. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncValidationCE.fs +186 -0
  28. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncValidationCE.fs.js +18 -0
  29. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncValidationOp.fs +35 -0
  30. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/FsToolkit.ErrorHandling.fableproj +69 -0
  31. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/List.fs +276 -0
  32. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/List.fs.js +364 -0
  33. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Nullness.fs +81 -0
  34. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Option.fs +462 -0
  35. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/OptionCE.fs +139 -0
  36. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/OptionCE.fs.js +48 -0
  37. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/OptionOp.fs +21 -0
  38. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncResult.fs +88 -0
  39. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncResult.fs.js +30 -0
  40. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncResultCE.fs +200 -0
  41. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncResultCE.fs.js +18 -0
  42. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncValidation.fs +34 -0
  43. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncValidationCE.fs +244 -0
  44. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncValidationCE.fs.js +18 -0
  45. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Result.fs +731 -0
  46. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Result.fs.js +45 -0
  47. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultCE.fs +140 -0
  48. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultCE.fs.js +23 -0
  49. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultOp.fs +45 -0
  50. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultOption.fs +201 -0
  51. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultOption.fs.js +65 -0
  52. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultOptionCE.fs +135 -0
  53. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultOptionCE.fs.js +18 -0
  54. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultOptionOp.fs +57 -0
  55. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Seq.fs +503 -0
  56. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Seq.fs.js +295 -0
  57. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Validation.fs +167 -0
  58. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValidationCE.fs +142 -0
  59. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValidationCE.fs.js +18 -0
  60. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValidationOp.fs +35 -0
  61. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValueOption.fs +148 -0
  62. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValueTaskValueOption.fs +102 -0
  63. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValueTaskValueOptionCE.fs +587 -0
  64. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValueTaskValueOptionOp.fs +10 -0
  65. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Debug/netstandard2.1/.NETStandard,Version=v2.1.AssemblyAttributes.fs +3 -0
  66. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Debug/netstandard2.1/FsToolkit.ErrorHandling.AssemblyInfo.fs +20 -0
  67. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Release/net9.0/.NETCoreApp,Version=v9.0.AssemblyAttributes.fs +3 -0
  68. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Release/net9.0/FsToolkit.ErrorHandling.AssemblyInfo.fs +20 -0
  69. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Release/netstandard2.0/.NETStandard,Version=v2.0.AssemblyAttributes.fs +3 -0
  70. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Release/netstandard2.0/FsToolkit.ErrorHandling.AssemblyInfo.fs +20 -0
  71. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Release/netstandard2.1/.NETStandard,Version=v2.1.AssemblyAttributes.fs +3 -0
  72. package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/obj/Release/netstandard2.1/FsToolkit.ErrorHandling.AssemblyInfo.fs +20 -0
  73. package/dist/fable_modules/fable-library-js.5.17.2/Array.js +1348 -0
  74. package/dist/fable_modules/fable-library-js.5.17.2/Async.js +163 -0
  75. package/dist/fable_modules/fable-library-js.5.17.2/AsyncBuilder.js +204 -0
  76. package/dist/fable_modules/fable-library-js.5.17.2/BigInt.js +307 -0
  77. package/dist/fable_modules/fable-library-js.5.17.2/BitConverter.js +138 -0
  78. package/dist/fable_modules/fable-library-js.5.17.2/Boolean.js +22 -0
  79. package/dist/fable_modules/fable-library-js.5.17.2/CHANGELOG.md +348 -0
  80. package/dist/fable_modules/fable-library-js.5.17.2/Char.js +202 -0
  81. package/dist/fable_modules/fable-library-js.5.17.2/Choice.js +184 -0
  82. package/dist/fable_modules/fable-library-js.5.17.2/CollectionUtil.js +182 -0
  83. package/dist/fable_modules/fable-library-js.5.17.2/ConditionalWeakTable.js +21 -0
  84. package/dist/fable_modules/fable-library-js.5.17.2/Date.js +834 -0
  85. package/dist/fable_modules/fable-library-js.5.17.2/DateOffset.js +252 -0
  86. package/dist/fable_modules/fable-library-js.5.17.2/DateOnly.js +124 -0
  87. package/dist/fable_modules/fable-library-js.5.17.2/DateOnlyTemporal.js +146 -0
  88. package/dist/fable_modules/fable-library-js.5.17.2/DateTimeFormat.js +523 -0
  89. package/dist/fable_modules/fable-library-js.5.17.2/DateTimeOffsetTemporal.js +283 -0
  90. package/dist/fable_modules/fable-library-js.5.17.2/DateTimeTemporal.js +243 -0
  91. package/dist/fable_modules/fable-library-js.5.17.2/Decimal.js +238 -0
  92. package/dist/fable_modules/fable-library-js.5.17.2/Directory.js +11 -0
  93. package/dist/fable_modules/fable-library-js.5.17.2/Double.js +53 -0
  94. package/dist/fable_modules/fable-library-js.5.17.2/Encoding.js +185 -0
  95. package/dist/fable_modules/fable-library-js.5.17.2/Environment.js +3 -0
  96. package/dist/fable_modules/fable-library-js.5.17.2/Event.js +102 -0
  97. package/dist/fable_modules/fable-library-js.5.17.2/FSharp.Collections.js +45 -0
  98. package/dist/fable_modules/fable-library-js.5.17.2/FSharp.Core.CompilerServices.js +27 -0
  99. package/dist/fable_modules/fable-library-js.5.17.2/FSharp.Core.js +156 -0
  100. package/dist/fable_modules/fable-library-js.5.17.2/File.js +27 -0
  101. package/dist/fable_modules/fable-library-js.5.17.2/Global.js +29 -0
  102. package/dist/fable_modules/fable-library-js.5.17.2/Guid.js +163 -0
  103. package/dist/fable_modules/fable-library-js.5.17.2/Int32.js +135 -0
  104. package/dist/fable_modules/fable-library-js.5.17.2/List.js +1337 -0
  105. package/dist/fable_modules/fable-library-js.5.17.2/Long.js +38 -0
  106. package/dist/fable_modules/fable-library-js.5.17.2/MailboxProcessor.js +100 -0
  107. package/dist/fable_modules/fable-library-js.5.17.2/Map.js +1400 -0
  108. package/dist/fable_modules/fable-library-js.5.17.2/MapUtil.js +130 -0
  109. package/dist/fable_modules/fable-library-js.5.17.2/MutableMap.js +339 -0
  110. package/dist/fable_modules/fable-library-js.5.17.2/MutableSet.js +233 -0
  111. package/dist/fable_modules/fable-library-js.5.17.2/Native.js +14 -0
  112. package/dist/fable_modules/fable-library-js.5.17.2/Numeric.js +112 -0
  113. package/dist/fable_modules/fable-library-js.5.17.2/Observable.js +115 -0
  114. package/dist/fable_modules/fable-library-js.5.17.2/Option.js +87 -0
  115. package/dist/fable_modules/fable-library-js.5.17.2/Path.js +31 -0
  116. package/dist/fable_modules/fable-library-js.5.17.2/README.md +3 -0
  117. package/dist/fable_modules/fable-library-js.5.17.2/Random.js +172 -0
  118. package/dist/fable_modules/fable-library-js.5.17.2/Range.js +45 -0
  119. package/dist/fable_modules/fable-library-js.5.17.2/Reflection.js +489 -0
  120. package/dist/fable_modules/fable-library-js.5.17.2/RegExp.js +170 -0
  121. package/dist/fable_modules/fable-library-js.5.17.2/Result.js +165 -0
  122. package/dist/fable_modules/fable-library-js.5.17.2/Seq.js +1504 -0
  123. package/dist/fable_modules/fable-library-js.5.17.2/Seq2.js +111 -0
  124. package/dist/fable_modules/fable-library-js.5.17.2/Set.js +1829 -0
  125. package/dist/fable_modules/fable-library-js.5.17.2/String.js +731 -0
  126. package/dist/fable_modules/fable-library-js.5.17.2/System.Collections.Generic.js +333 -0
  127. package/dist/fable_modules/fable-library-js.5.17.2/System.Text.js +200 -0
  128. package/dist/fable_modules/fable-library-js.5.17.2/System.js +289 -0
  129. package/dist/fable_modules/fable-library-js.5.17.2/Task.js +27 -0
  130. package/dist/fable_modules/fable-library-js.5.17.2/TaskBuilder.js +72 -0
  131. package/dist/fable_modules/fable-library-js.5.17.2/TimeOnly.js +122 -0
  132. package/dist/fable_modules/fable-library-js.5.17.2/TimeOnlyTemporal.js +142 -0
  133. package/dist/fable_modules/fable-library-js.5.17.2/TimeSpan.js +180 -0
  134. package/dist/fable_modules/fable-library-js.5.17.2/TimeSpanTemporal.js +259 -0
  135. package/dist/fable_modules/fable-library-js.5.17.2/Timer.js +67 -0
  136. package/dist/fable_modules/fable-library-js.5.17.2/Types.js +198 -0
  137. package/dist/fable_modules/fable-library-js.5.17.2/Unicode.13.0.0.js +4 -0
  138. package/dist/fable_modules/fable-library-js.5.17.2/Uri.js +165 -0
  139. package/dist/fable_modules/fable-library-js.5.17.2/Util.js +807 -0
  140. package/dist/fable_modules/fable-library-js.5.17.2/big.d.ts +338 -0
  141. package/dist/fable_modules/fable-library-js.5.17.2/lib/big.js +829 -0
  142. package/dist/fable_modules/fable-library-js.5.17.2/package.json +24 -0
  143. package/dist/fable_modules/fable-library-js.5.17.2/quotation.js +682 -0
  144. package/package.json +1 -1
@@ -0,0 +1,180 @@
1
+ import { Exception, comparePrimitives, padLeftAndRightWithZeros, padWithZeros } from "./Util.js";
2
+ import { toInt64, fromFloat64 } from "./BigInt.js";
3
+ /**
4
+ * Calls:
5
+ * - `Math.ceil` if the `value` is **negative**
6
+ * - `Math.floor` if the `value` is **positive**
7
+ * @param value Value to round
8
+ */
9
+ function signedRound(value) {
10
+ return value < 0 ? Math.ceil(value) : Math.floor(value);
11
+ }
12
+ export function create(d = 0, h = 0, m = 0, s = 0, ms = 0) {
13
+ switch (arguments.length) {
14
+ case 1:
15
+ // ticks
16
+ return fromTicks(arguments[0]);
17
+ case 3:
18
+ // h,m,s
19
+ d = 0, h = arguments[0], m = arguments[1], s = arguments[2], ms = 0;
20
+ break;
21
+ default:
22
+ // d,h,m,s,ms
23
+ break;
24
+ }
25
+ return d * 86400000 + h * 3600000 + m * 60000 + s * 1000 + ms;
26
+ }
27
+ export function fromTicks(ticks) {
28
+ return Number(BigInt(ticks) / 10000n);
29
+ }
30
+ export function fromDays(d, h = 0, m = 0n, s = 0n, ms = 0n) {
31
+ return create(d, h, Number(m), Number(s), Number(ms));
32
+ }
33
+ export function fromHours(h, m = 0n, s = 0n, ms = 0n) {
34
+ return create(0, h, Number(m), Number(s), Number(ms));
35
+ }
36
+ export function fromMinutes(m, s = 0n, ms = 0n) {
37
+ return create(0, 0, Number(m), Number(s), Number(ms));
38
+ }
39
+ export function fromSeconds(s, ms = 0n) {
40
+ return create(0, 0, 0, Number(s), Number(ms));
41
+ }
42
+ export function fromMilliseconds(ms) {
43
+ return Number(ms);
44
+ }
45
+ export function days(ts) {
46
+ return signedRound(ts / 86400000);
47
+ }
48
+ export function hours(ts) {
49
+ return signedRound(ts % 86400000 / 3600000);
50
+ }
51
+ export function minutes(ts) {
52
+ return signedRound(ts % 3600000 / 60000);
53
+ }
54
+ export function seconds(ts) {
55
+ return signedRound(ts % 60000 / 1000);
56
+ }
57
+ export function milliseconds(ts) {
58
+ return signedRound(ts % 1000);
59
+ }
60
+ export function ticks(ts) {
61
+ return toInt64(fromFloat64(ts * 10000));
62
+ }
63
+ export function totalDays(ts) {
64
+ return ts / 86400000;
65
+ }
66
+ export function totalHours(ts) {
67
+ return ts / 3600000;
68
+ }
69
+ export function totalMinutes(ts) {
70
+ return ts / 60000;
71
+ }
72
+ export function totalSeconds(ts) {
73
+ return ts / 1000;
74
+ }
75
+ export function negate(ts) {
76
+ return ts * -1;
77
+ }
78
+ export function add(ts1, ts2) {
79
+ return ts1 + ts2;
80
+ }
81
+ export function subtract(ts1, ts2) {
82
+ return ts1 - ts2;
83
+ }
84
+ export function multiply(ts, factor) {
85
+ return ts * factor;
86
+ }
87
+ export function divide(ts, b) {
88
+ return ts / b;
89
+ }
90
+ export const op_Addition = add;
91
+ export const op_Subtraction = subtract;
92
+ export const op_Multiply = multiply;
93
+ export const op_Division = divide;
94
+ export const compare = comparePrimitives;
95
+ export const compareTo = comparePrimitives;
96
+ export function duration(x) {
97
+ return Math.abs(x);
98
+ }
99
+ export function toString(ts, format = "c", _provider) {
100
+ if (["c", "g", "G"].indexOf(format) === -1) {
101
+ throw new Exception("Custom formats are not supported");
102
+ }
103
+ const d = Math.abs(days(ts));
104
+ const h = Math.abs(hours(ts));
105
+ const m = Math.abs(minutes(ts));
106
+ const s = Math.abs(seconds(ts));
107
+ const ms = Math.abs(milliseconds(ts));
108
+ const sign = ts < 0 ? "-" : "";
109
+ return `${sign}${d === 0 && (format === "c" || format === "g") ? "" : format === "c" ? d + "." : d + ":"}${format === "g" ? h : padWithZeros(h, 2)}:${padWithZeros(m, 2)}:${padWithZeros(s, 2)}${ms === 0 && (format === "c" || format === "g") ? "" : format === "g" ? "." + padWithZeros(ms, 3) : "." + padLeftAndRightWithZeros(ms, 3, 7)}`;
110
+ }
111
+ export function parse(str) {
112
+ const firstDot = str.search("\\.");
113
+ const firstColon = str.search("\\:");
114
+ if (firstDot === -1 && firstColon === -1) { // There is only a day ex: 4
115
+ const d = parseInt(str, 0);
116
+ if (isNaN(d)) {
117
+ throw new Exception(`String '${str}' was not recognized as a valid TimeSpan.`);
118
+ }
119
+ else {
120
+ return create(d, 0, 0, 0, 0);
121
+ }
122
+ }
123
+ if (firstColon > 0) { // process time part
124
+ // WIP: (-?)(((\d+)\.)?([0-9]|0[0-9]|1[0-9]|2[0-3]):(\d+)(:\d+(\.\d{1,7})?)?|\d+(?:(?!\.)))
125
+ const r = /^(-?)((\d+)\.)?(?:0*)([0-9]|0[0-9]|1[0-9]|2[0-3]):(?:0*)([0-5][0-9]|[0-9])(:(?:0*)([0-5][0-9]|[0-9]))?\.?(\d+)?$/.exec(str);
126
+ if (r != null && r[4] != null && r[5] != null) {
127
+ let d = 0;
128
+ let ms = 0;
129
+ let s = 0;
130
+ const sign = r[1] != null && r[1] === "-" ? -1 : 1;
131
+ const h = +r[4];
132
+ const m = +r[5];
133
+ if (r[3] != null) {
134
+ d = +r[3];
135
+ }
136
+ if (r[7] != null) {
137
+ s = +r[7];
138
+ }
139
+ if (r[8] != null) {
140
+ // Depending on the number of decimals passed, we need to adapt the numbers
141
+ switch (r[8].length) {
142
+ case 1:
143
+ ms = +r[8] * 100;
144
+ break;
145
+ case 2:
146
+ ms = +r[8] * 10;
147
+ break;
148
+ case 3:
149
+ ms = +r[8];
150
+ break;
151
+ case 4:
152
+ ms = +r[8] / 10;
153
+ break;
154
+ case 5:
155
+ ms = +r[8] / 100;
156
+ break;
157
+ case 6:
158
+ ms = +r[8] / 1000;
159
+ break;
160
+ case 7:
161
+ ms = +r[8] / 10000;
162
+ break;
163
+ default:
164
+ throw new Exception(`String '${str}' was not recognized as a valid TimeSpan.`);
165
+ }
166
+ }
167
+ return sign * create(d, h, m, s, ms);
168
+ }
169
+ }
170
+ throw new Exception(`String '${str}' was not recognized as a valid TimeSpan.`);
171
+ }
172
+ export function tryParse(v, defValue) {
173
+ try {
174
+ defValue.contents = parse(v);
175
+ return true;
176
+ }
177
+ catch {
178
+ return false;
179
+ }
180
+ }
@@ -0,0 +1,259 @@
1
+ import { toInt64 } from "./BigInt.js";
2
+ import { Exception, padWithZeros } from "./Util.js";
3
+ export const Duration = Temporal.Duration;
4
+ // The generic equality/comparison/hashing helpers in Util.ts dispatch at runtime
5
+ // on .NET-style Equals/CompareTo/GetHashCode methods. Attach them so TimeSpan
6
+ // also works in generic contexts: records, tuples, erased generics, etc.
7
+ const proto = Temporal.Duration.prototype;
8
+ proto.Equals = function (other) { return Temporal.Duration.compare(this, other) === 0; };
9
+ proto.CompareTo = function (other) { return Temporal.Duration.compare(this, other); };
10
+ proto.GetHashCode = function () { return hash(this); };
11
+ // Lets String.Format format this value without String.ts importing this module (see String.ts)
12
+ proto[Symbol.for("Fable.DateTimeFormattable")] = function (format) { return toString(this, format); };
13
+ const nsPerMillisecond = 1000000n;
14
+ const nsPerSecond = 1000000000n;
15
+ const nsPerMinute = 60000000000n;
16
+ const nsPerHour = 3600000000000n;
17
+ const nsPerDay = 86400000000000n;
18
+ export function totalNanoseconds(ts) {
19
+ return BigInt(ts.days) * nsPerDay
20
+ + BigInt(ts.hours) * nsPerHour
21
+ + BigInt(ts.minutes) * nsPerMinute
22
+ + BigInt(ts.seconds) * nsPerSecond
23
+ + BigInt(ts.milliseconds) * nsPerMillisecond
24
+ + BigInt(ts.microseconds) * 1000n
25
+ + BigInt(ts.nanoseconds);
26
+ }
27
+ function fromNanoseconds(totalNs) {
28
+ const negative = totalNs < 0n;
29
+ // A .NET TimeSpan is a whole number of 100ns ticks, so anything finer than a
30
+ // tick is dropped (toward zero, as .NET does) rather than carried in the
31
+ // Duration's nanosecond field — otherwise values that cannot exist in .NET
32
+ // would leak out of Parse/FromMilliseconds/arithmetic.
33
+ let n = (negative ? -totalNs : totalNs) / 100n * 100n;
34
+ const days = Number(n / nsPerDay);
35
+ n %= nsPerDay;
36
+ const hours = Number(n / nsPerHour);
37
+ n %= nsPerHour;
38
+ const minutes = Number(n / nsPerMinute);
39
+ n %= nsPerMinute;
40
+ const seconds = Number(n / nsPerSecond);
41
+ n %= nsPerSecond;
42
+ const milliseconds = Number(n / nsPerMillisecond);
43
+ n %= nsPerMillisecond;
44
+ const microseconds = Number(n / 1000n);
45
+ n %= 1000n;
46
+ const d = new Temporal.Duration(0, 0, 0, days, hours, minutes, seconds, milliseconds, microseconds, Number(n));
47
+ return negative ? d.negated() : d;
48
+ }
49
+ // Converts a possibly fractional unit count into an exact nanosecond amount,
50
+ // keeping the integer part exact for the full Int64 tick range.
51
+ function unitToNanoseconds(value, nsPerUnit) {
52
+ const whole = Math.trunc(value);
53
+ const frac = value - whole;
54
+ return BigInt(whole) * nsPerUnit + BigInt(Math.round(frac * Number(nsPerUnit)));
55
+ }
56
+ export function create(d = 0, h = 0, m = 0, s = 0, ms = 0, us = 0) {
57
+ switch (arguments.length) {
58
+ case 1:
59
+ // ticks
60
+ return fromTicks(arguments[0]);
61
+ case 3:
62
+ // h,m,s
63
+ d = 0, h = arguments[0], m = arguments[1], s = arguments[2], ms = 0;
64
+ break;
65
+ default:
66
+ // d,h,m,s,ms,us
67
+ break;
68
+ }
69
+ return fromNanoseconds(unitToNanoseconds(d, nsPerDay) + unitToNanoseconds(h, nsPerHour) + unitToNanoseconds(m, nsPerMinute)
70
+ + unitToNanoseconds(s, nsPerSecond) + unitToNanoseconds(ms, nsPerMillisecond) + unitToNanoseconds(us, 1000n));
71
+ }
72
+ export function fromTicks(ticks) {
73
+ return fromNanoseconds(BigInt(ticks) * 100n);
74
+ }
75
+ export function zero() {
76
+ return new Temporal.Duration();
77
+ }
78
+ const ticksPerUnit = {
79
+ days: 864000000000,
80
+ hours: 36000000000,
81
+ minutes: 600000000,
82
+ seconds: 10000000,
83
+ milliseconds: 10000,
84
+ };
85
+ // The DateTime/DateTimeOffset/TimeOnly Add* members take a double and are
86
+ // tick-precise in .NET: the value is scaled to ticks and rounded, so
87
+ // AddSeconds(0.0000001) moves exactly one tick and AddDays(1.5) exactly 36 hours.
88
+ // Temporal's own `add({ days: 1.5 })` rejects non-integers, so the scaling has to
89
+ // happen here.
90
+ export function fromUnits(value, unit) {
91
+ return fromTicks(BigInt(Math.round(value * ticksPerUnit[unit])));
92
+ }
93
+ export function fromDays(d, h = 0, m = 0n, s = 0n, ms = 0n) {
94
+ return create(d, h, Number(m), Number(s), Number(ms));
95
+ }
96
+ export function fromHours(h, m = 0n, s = 0n, ms = 0n) {
97
+ return create(0, h, Number(m), Number(s), Number(ms));
98
+ }
99
+ export function fromMinutes(m, s = 0n, ms = 0n) {
100
+ return create(0, 0, Number(m), Number(s), Number(ms));
101
+ }
102
+ export function fromSeconds(s, ms = 0n) {
103
+ return create(0, 0, 0, Number(s), Number(ms));
104
+ }
105
+ export function fromMilliseconds(ms) {
106
+ return fromNanoseconds(unitToNanoseconds(Number(ms), nsPerMillisecond));
107
+ }
108
+ export function ticks(ts) {
109
+ return toInt64(totalNanoseconds(ts) / 100n);
110
+ }
111
+ // .NET computes each total as (double)Ticks / TicksPerUnit; match that exactly
112
+ // (Temporal's own .total() balances differently and can be 1 ULP off).
113
+ function totalTicks(ts) {
114
+ return Number(totalNanoseconds(ts) / 100n);
115
+ }
116
+ export function totalDays(ts) {
117
+ return totalTicks(ts) / 864000000000;
118
+ }
119
+ export function totalHours(ts) {
120
+ return totalTicks(ts) / 36000000000;
121
+ }
122
+ export function totalMinutes(ts) {
123
+ return totalTicks(ts) / 600000000;
124
+ }
125
+ export function totalSeconds(ts) {
126
+ return totalTicks(ts) / 10000000;
127
+ }
128
+ export function totalMilliseconds(ts) {
129
+ return totalTicks(ts) / 10000;
130
+ }
131
+ export function negate(ts) {
132
+ return ts.negated();
133
+ }
134
+ export function add(ts1, ts2) {
135
+ return fromNanoseconds(totalNanoseconds(ts1) + totalNanoseconds(ts2));
136
+ }
137
+ export function subtract(ts1, ts2) {
138
+ return fromNanoseconds(totalNanoseconds(ts1) - totalNanoseconds(ts2));
139
+ }
140
+ // .NET scales the tick count as a double and rounds: `new TimeSpan((long)Math
141
+ // .Round(Ticks * factor))`. Scaling ticks rather than nanoseconds keeps the
142
+ // magnitude — and so the rounding — identical to .NET's.
143
+ export function multiply(ts, factor) {
144
+ return fromTicks(BigInt(Math.round(Number(ticks(ts)) * factor)));
145
+ }
146
+ export function divide(ts, factor) {
147
+ return fromTicks(BigInt(Math.round(Number(ticks(ts)) / factor)));
148
+ }
149
+ export function divideByTimeSpan(ts, other) {
150
+ return Number(ticks(ts)) / Number(ticks(other));
151
+ }
152
+ export const op_Addition = add;
153
+ export const op_Subtraction = subtract;
154
+ export const op_Multiply = multiply;
155
+ export const op_UnaryNegation = negate;
156
+ export function compare(x, y) {
157
+ return Temporal.Duration.compare(x, y);
158
+ }
159
+ export const compareTo = compare;
160
+ export function equals(x, y) {
161
+ return Temporal.Duration.compare(x, y) === 0;
162
+ }
163
+ export function hash(ts) {
164
+ return Number(totalNanoseconds(ts) % 2147483647n);
165
+ }
166
+ export function duration(ts) {
167
+ return ts.abs();
168
+ }
169
+ export function toString(ts, format = "c", _provider) {
170
+ if (["c", "g", "G"].indexOf(format) === -1) {
171
+ throw new Exception("Custom formats are not supported");
172
+ }
173
+ const d = Math.abs(ts.days);
174
+ const h = Math.abs(ts.hours);
175
+ const m = Math.abs(ts.minutes);
176
+ const s = Math.abs(ts.seconds);
177
+ const ticks = Math.abs(ts.milliseconds) * 10000
178
+ + Math.abs(ts.microseconds) * 10
179
+ + Math.trunc(Math.abs(ts.nanoseconds) / 100);
180
+ const sign = ts.sign < 0 ? "-" : "";
181
+ const days = d === 0 && format !== "G" ? "" : format === "c" ? d + "." : d + ":";
182
+ const time = `${format === "g" ? h : padWithZeros(h, 2)}:${padWithZeros(m, 2)}:${padWithZeros(s, 2)}`;
183
+ // .NET prints seven tick digits for "c" and "G", trims trailing zeros for "g", and omits a zero fraction for "c" and "g".
184
+ const fraction = format === "g"
185
+ ? (ticks === 0 ? "" : "." + padWithZeros(ticks, 7).replace(/0+$/, ""))
186
+ : (ticks === 0 && format === "c" ? "" : "." + padWithZeros(ticks, 7));
187
+ return `${sign}${days}${time}${fraction}`;
188
+ }
189
+ export function parse(str) {
190
+ const firstDot = str.search("\\.");
191
+ const firstColon = str.search("\\:");
192
+ if (firstDot === -1 && firstColon === -1) { // There is only a day ex: 4
193
+ const d = parseInt(str, 0);
194
+ if (isNaN(d)) {
195
+ throw new Exception(`String '${str}' was not recognized as a valid TimeSpan.`);
196
+ }
197
+ else {
198
+ return create(d, 0, 0, 0, 0);
199
+ }
200
+ }
201
+ if (firstColon > 0) { // process time part
202
+ // WIP: (-?)(((\d+)\.)?([0-9]|0[0-9]|1[0-9]|2[0-3]):(\d+)(:\d+(\.\d{1,7})?)?|\d+(?:(?!\.)))
203
+ const r = /^(-?)((\d+)\.)?(?:0*)([0-9]|0[0-9]|1[0-9]|2[0-3]):(?:0*)([0-5][0-9]|[0-9])(:(?:0*)([0-5][0-9]|[0-9]))?\.?(\d+)?$/.exec(str);
204
+ if (r != null && r[4] != null && r[5] != null) {
205
+ let d = 0;
206
+ let ms = 0;
207
+ let s = 0;
208
+ const sign = r[1] != null && r[1] === "-" ? -1 : 1;
209
+ const h = +r[4];
210
+ const m = +r[5];
211
+ if (r[3] != null) {
212
+ d = +r[3];
213
+ }
214
+ if (r[7] != null) {
215
+ s = +r[7];
216
+ }
217
+ if (r[8] != null) {
218
+ // Depending on the number of decimals passed, we need to adapt the numbers
219
+ switch (r[8].length) {
220
+ case 1:
221
+ ms = +r[8] * 100;
222
+ break;
223
+ case 2:
224
+ ms = +r[8] * 10;
225
+ break;
226
+ case 3:
227
+ ms = +r[8];
228
+ break;
229
+ case 4:
230
+ ms = +r[8] / 10;
231
+ break;
232
+ case 5:
233
+ ms = +r[8] / 100;
234
+ break;
235
+ case 6:
236
+ ms = +r[8] / 1000;
237
+ break;
238
+ case 7:
239
+ ms = +r[8] / 10000;
240
+ break;
241
+ default:
242
+ throw new Exception(`String '${str}' was not recognized as a valid TimeSpan.`);
243
+ }
244
+ }
245
+ const ts = create(d, h, m, s, ms);
246
+ return sign < 0 ? negate(ts) : ts;
247
+ }
248
+ }
249
+ throw new Exception(`String '${str}' was not recognized as a valid TimeSpan.`);
250
+ }
251
+ export function tryParse(v, defValue) {
252
+ try {
253
+ defValue.contents = parse(v);
254
+ return true;
255
+ }
256
+ catch {
257
+ return false;
258
+ }
259
+ }
@@ -0,0 +1,67 @@
1
+ import { Event } from "./Event.js";
2
+ export class Timer {
3
+ constructor(interval) {
4
+ this._enabled = false;
5
+ this._isDisposed = false;
6
+ this._intervalId = 0;
7
+ this._timeoutId = 0;
8
+ this.Interval = interval && interval > 0 ? interval : 100;
9
+ this.AutoReset = true;
10
+ this._elapsed = new Event();
11
+ }
12
+ Elapsed() {
13
+ return this._elapsed.Publish;
14
+ }
15
+ get Enabled() {
16
+ return this._enabled;
17
+ }
18
+ set Enabled(x) {
19
+ if (!this._isDisposed && this._enabled !== x) {
20
+ this._enabled = x;
21
+ if (this._enabled) {
22
+ if (this.AutoReset) {
23
+ this._intervalId = setInterval(() => {
24
+ if (!this.AutoReset) {
25
+ this.Enabled = false;
26
+ }
27
+ this._elapsed.Trigger(new Date());
28
+ }, this.Interval);
29
+ }
30
+ else {
31
+ this._timeoutId = setTimeout(() => {
32
+ this.Enabled = false;
33
+ this._timeoutId = 0;
34
+ if (this.AutoReset) {
35
+ this.Enabled = true;
36
+ }
37
+ this._elapsed.Trigger(new Date());
38
+ }, this.Interval);
39
+ }
40
+ }
41
+ else {
42
+ if (this._timeoutId) {
43
+ clearTimeout(this._timeoutId);
44
+ this._timeoutId = 0;
45
+ }
46
+ if (this._intervalId) {
47
+ clearInterval(this._intervalId);
48
+ this._intervalId = 0;
49
+ }
50
+ }
51
+ }
52
+ }
53
+ Dispose() {
54
+ this.Enabled = false;
55
+ this._isDisposed = true;
56
+ }
57
+ Close() {
58
+ this.Dispose();
59
+ }
60
+ Start() {
61
+ this.Enabled = true;
62
+ }
63
+ Stop() {
64
+ this.Enabled = false;
65
+ }
66
+ }
67
+ export default Timer;
@@ -0,0 +1,198 @@
1
+ import { Exception, combineHashCodes, compare, compareArrays, equalArrays, equals, sameConstructor, numberHash, structuralHash } from "./Util.js";
2
+ export function seqToString(self) {
3
+ let count = 0;
4
+ let str = "[";
5
+ for (const x of self) {
6
+ if (count === 0) {
7
+ str += toStringQuoted(x);
8
+ }
9
+ else if (count === 100) {
10
+ str += "; ...";
11
+ break;
12
+ }
13
+ else {
14
+ str += "; " + toStringQuoted(x);
15
+ }
16
+ count++;
17
+ }
18
+ return str + "]";
19
+ }
20
+ // Structured (%A-style) rendering of a value used as an element/field of a
21
+ // container. F#'s structured formatting (which records, unions, lists, etc.
22
+ // use in their ToString) quotes strings, e.g. `["a"; "b"]` and `{ Name = "John" }`.
23
+ function toStringQuoted(x, callStack = 0) {
24
+ return typeof x === "string" ? "\"" + x + "\"" : toString(x, callStack);
25
+ }
26
+ export function toString(x, callStack = 0) {
27
+ if (x != null && typeof x === "object") {
28
+ if (typeof x.toString === "function" && x.toString !== Object.prototype.toString) {
29
+ return x.toString();
30
+ }
31
+ else if (Symbol.iterator in x) {
32
+ return seqToString(x);
33
+ }
34
+ else { // TODO: Date?
35
+ const cons = Object.getPrototypeOf(x)?.constructor;
36
+ return cons === Object && callStack < 10
37
+ // Same format as recordToString
38
+ ? "{ " + Object.entries(x).map(([k, v]) => k + " = " + toStringQuoted(v, callStack + 1)).join("\n ") + " }"
39
+ : cons?.name ?? "";
40
+ }
41
+ }
42
+ return String(x);
43
+ }
44
+ export function unionToString(name, fields) {
45
+ if (fields.length === 0) {
46
+ return name;
47
+ }
48
+ else {
49
+ let fieldStr;
50
+ let withParens = true;
51
+ if (fields.length === 1) {
52
+ fieldStr = toStringQuoted(fields[0]);
53
+ withParens = fieldStr.indexOf(" ") >= 0;
54
+ }
55
+ else {
56
+ fieldStr = fields.map((x) => toStringQuoted(x)).join(", ");
57
+ }
58
+ return name + (withParens ? " (" : " ") + fieldStr + (withParens ? ")" : "");
59
+ }
60
+ }
61
+ export class Union {
62
+ get name() {
63
+ return this.cases()[this.tag];
64
+ }
65
+ toJSON() {
66
+ return this.fields.length === 0 ? this.name : [this.name].concat(this.fields);
67
+ }
68
+ toString() {
69
+ return unionToString(this.name, this.fields);
70
+ }
71
+ GetHashCode() {
72
+ const hashes = this.fields.map((x) => structuralHash(x));
73
+ hashes.splice(0, 0, numberHash(this.tag));
74
+ return combineHashCodes(hashes);
75
+ }
76
+ Equals(other) {
77
+ if (this === other) {
78
+ return true;
79
+ }
80
+ else if (!sameConstructor(this, other)) {
81
+ return false;
82
+ }
83
+ else if (this.tag === other.tag) {
84
+ return equalArrays(this.fields, other.fields);
85
+ }
86
+ else {
87
+ return false;
88
+ }
89
+ }
90
+ CompareTo(other) {
91
+ if (this === other) {
92
+ return 0;
93
+ }
94
+ else if (!sameConstructor(this, other)) {
95
+ return -1;
96
+ }
97
+ else if (this.tag === other.tag) {
98
+ return compareArrays(this.fields, other.fields);
99
+ }
100
+ else {
101
+ return this.tag < other.tag ? -1 : 1;
102
+ }
103
+ }
104
+ }
105
+ function recordToJSON(self) {
106
+ const o = {};
107
+ const keys = Object.keys(self);
108
+ for (let i = 0; i < keys.length; i++) {
109
+ o[keys[i]] = self[keys[i]];
110
+ }
111
+ return o;
112
+ }
113
+ function recordToString(self) {
114
+ return "{ " + Object.entries(self).map(([k, v]) => k + " = " + toStringQuoted(v)).join("\n ") + " }";
115
+ }
116
+ function recordGetHashCode(self) {
117
+ const hashes = Object.values(self).map((v) => structuralHash(v));
118
+ return combineHashCodes(hashes);
119
+ }
120
+ function recordEquals(self, other) {
121
+ if (self === other) {
122
+ return true;
123
+ }
124
+ else if (!sameConstructor(self, other)) {
125
+ return false;
126
+ }
127
+ else {
128
+ const thisNames = Object.keys(self);
129
+ for (let i = 0; i < thisNames.length; i++) {
130
+ if (!equals(self[thisNames[i]], other[thisNames[i]])) {
131
+ return false;
132
+ }
133
+ }
134
+ return true;
135
+ }
136
+ }
137
+ function recordCompareTo(self, other) {
138
+ if (self === other) {
139
+ return 0;
140
+ }
141
+ else if (!sameConstructor(self, other)) {
142
+ return -1;
143
+ }
144
+ else {
145
+ const thisNames = Object.keys(self);
146
+ for (let i = 0; i < thisNames.length; i++) {
147
+ const result = compare(self[thisNames[i]], other[thisNames[i]]);
148
+ if (result !== 0) {
149
+ return result;
150
+ }
151
+ }
152
+ return 0;
153
+ }
154
+ }
155
+ export class Record {
156
+ toJSON() { return recordToJSON(this); }
157
+ toString() { return recordToString(this); }
158
+ GetHashCode() { return recordGetHashCode(this); }
159
+ Equals(other) { return recordEquals(this, other); }
160
+ CompareTo(other) { return recordCompareTo(this, other); }
161
+ }
162
+ export class FSharpRef {
163
+ get contents() {
164
+ return this.getter();
165
+ }
166
+ set contents(v) {
167
+ this.setter(v);
168
+ }
169
+ constructor(contentsOrGetter, setter) {
170
+ if (typeof setter === "function") {
171
+ this.getter = contentsOrGetter;
172
+ this.setter = setter;
173
+ }
174
+ else {
175
+ this.getter = () => contentsOrGetter;
176
+ this.setter = (v) => { contentsOrGetter = v; };
177
+ }
178
+ }
179
+ }
180
+ // EXCEPTIONS
181
+ export class FSharpException extends Exception {
182
+ toJSON() { return recordToJSON(this); }
183
+ toString() { return recordToString(this); }
184
+ GetHashCode() { return recordGetHashCode(this); }
185
+ Equals(other) { return recordEquals(this, other); }
186
+ CompareTo(other) { return recordCompareTo(this, other); }
187
+ }
188
+ export class MatchFailureException extends FSharpException {
189
+ constructor(arg1, arg2, arg3) {
190
+ super();
191
+ this.arg1 = arg1;
192
+ this.arg2 = arg2 | 0;
193
+ this.arg3 = arg3 | 0;
194
+ this.message = "The match cases were incomplete";
195
+ }
196
+ }
197
+ export class Attribute {
198
+ }