@magnusopera/fscript 0.75.0
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/README.md +5 -0
- package/dist/FScript.Language/Ast.js +234 -0
- package/dist/FScript.Language/BuiltinFunctions.js +2039 -0
- package/dist/FScript.Language/BuiltinSignatures.js +24 -0
- package/dist/FScript.Language/BuiltinTypes.js +13 -0
- package/dist/FScript.Language/Error.js +74 -0
- package/dist/FScript.Language/Eval.js +2404 -0
- package/dist/FScript.Language/IncludeResolver.js +806 -0
- package/dist/FScript.Language/Lexer.js +1067 -0
- package/dist/FScript.Language/Library.js +28 -0
- package/dist/FScript.Language/Parser.js +2368 -0
- package/dist/FScript.Language/Pretty.js +115 -0
- package/dist/FScript.Language/Span.js +33 -0
- package/dist/FScript.Language/Token.js +32 -0
- package/dist/FScript.Language/TypeInfer.js +2561 -0
- package/dist/FScript.Language/Types.js +205 -0
- package/dist/FScript.Language/Value.js +91 -0
- package/dist/Library.js +732 -0
- package/dist/fable_modules/fable-library-js.5.2.0/Array.js +1347 -0
- package/dist/fable_modules/fable-library-js.5.2.0/Async.js +134 -0
- package/dist/fable_modules/fable-library-js.5.2.0/AsyncBuilder.js +183 -0
- package/dist/fable_modules/fable-library-js.5.2.0/BigInt.js +306 -0
- package/dist/fable_modules/fable-library-js.5.2.0/BitConverter.js +138 -0
- package/dist/fable_modules/fable-library-js.5.2.0/Boolean.js +22 -0
- package/dist/fable_modules/fable-library-js.5.2.0/CHANGELOG.md +234 -0
- package/dist/fable_modules/fable-library-js.5.2.0/Char.js +202 -0
- package/dist/fable_modules/fable-library-js.5.2.0/Choice.js +184 -0
- package/dist/fable_modules/fable-library-js.5.2.0/CollectionUtil.js +182 -0
- package/dist/fable_modules/fable-library-js.5.2.0/ConditionalWeakTable.js +21 -0
- package/dist/fable_modules/fable-library-js.5.2.0/Date.js +841 -0
- package/dist/fable_modules/fable-library-js.5.2.0/DateOffset.js +261 -0
- package/dist/fable_modules/fable-library-js.5.2.0/DateOnly.js +124 -0
- package/dist/fable_modules/fable-library-js.5.2.0/Decimal.js +238 -0
- package/dist/fable_modules/fable-library-js.5.2.0/Double.js +47 -0
- package/dist/fable_modules/fable-library-js.5.2.0/Encoding.js +185 -0
- package/dist/fable_modules/fable-library-js.5.2.0/Event.js +93 -0
- package/dist/fable_modules/fable-library-js.5.2.0/FSharp.Collections.js +45 -0
- package/dist/fable_modules/fable-library-js.5.2.0/FSharp.Core.CompilerServices.js +27 -0
- package/dist/fable_modules/fable-library-js.5.2.0/FSharp.Core.js +156 -0
- package/dist/fable_modules/fable-library-js.5.2.0/Global.js +29 -0
- package/dist/fable_modules/fable-library-js.5.2.0/Guid.js +161 -0
- package/dist/fable_modules/fable-library-js.5.2.0/Int32.js +135 -0
- package/dist/fable_modules/fable-library-js.5.2.0/List.js +1323 -0
- package/dist/fable_modules/fable-library-js.5.2.0/Long.js +47 -0
- package/dist/fable_modules/fable-library-js.5.2.0/MailboxProcessor.js +94 -0
- package/dist/fable_modules/fable-library-js.5.2.0/Map.js +1396 -0
- package/dist/fable_modules/fable-library-js.5.2.0/MapUtil.js +130 -0
- package/dist/fable_modules/fable-library-js.5.2.0/MutableMap.js +339 -0
- package/dist/fable_modules/fable-library-js.5.2.0/MutableSet.js +233 -0
- package/dist/fable_modules/fable-library-js.5.2.0/Native.js +14 -0
- package/dist/fable_modules/fable-library-js.5.2.0/Numeric.js +75 -0
- package/dist/fable_modules/fable-library-js.5.2.0/Observable.js +113 -0
- package/dist/fable_modules/fable-library-js.5.2.0/Option.js +104 -0
- package/dist/fable_modules/fable-library-js.5.2.0/README.md +3 -0
- package/dist/fable_modules/fable-library-js.5.2.0/Random.js +172 -0
- package/dist/fable_modules/fable-library-js.5.2.0/Range.js +45 -0
- package/dist/fable_modules/fable-library-js.5.2.0/Reflection.js +479 -0
- package/dist/fable_modules/fable-library-js.5.2.0/RegExp.js +141 -0
- package/dist/fable_modules/fable-library-js.5.2.0/Result.js +165 -0
- package/dist/fable_modules/fable-library-js.5.2.0/Seq.js +1417 -0
- package/dist/fable_modules/fable-library-js.5.2.0/Seq2.js +111 -0
- package/dist/fable_modules/fable-library-js.5.2.0/Set.js +1816 -0
- package/dist/fable_modules/fable-library-js.5.2.0/String.js +674 -0
- package/dist/fable_modules/fable-library-js.5.2.0/System.Collections.Generic.js +333 -0
- package/dist/fable_modules/fable-library-js.5.2.0/System.Text.js +200 -0
- package/dist/fable_modules/fable-library-js.5.2.0/System.js +283 -0
- package/dist/fable_modules/fable-library-js.5.2.0/TimeOnly.js +122 -0
- package/dist/fable_modules/fable-library-js.5.2.0/TimeSpan.js +180 -0
- package/dist/fable_modules/fable-library-js.5.2.0/Timer.js +67 -0
- package/dist/fable_modules/fable-library-js.5.2.0/Types.js +198 -0
- package/dist/fable_modules/fable-library-js.5.2.0/Unicode.13.0.0.js +4 -0
- package/dist/fable_modules/fable-library-js.5.2.0/Uri.js +165 -0
- package/dist/fable_modules/fable-library-js.5.2.0/Util.js +795 -0
- package/dist/fable_modules/fable-library-js.5.2.0/big.d.ts +338 -0
- package/dist/fable_modules/fable-library-js.5.2.0/lib/big.js +825 -0
- package/dist/fable_modules/fable-library-js.5.2.0/package.json +24 -0
- package/dist/fable_modules/fable-library-js.5.2.0/quotation.js +618 -0
- package/dist/fable_modules/project_cracked.json +1 -0
- package/package.json +36 -0
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
const littleEndian = true;
|
|
2
|
+
function utf16le_encode(str) {
|
|
3
|
+
const bytes = new Uint8Array(str.length * 2);
|
|
4
|
+
const view = new DataView(bytes.buffer);
|
|
5
|
+
for (let i = 0; i < str.length; i++) {
|
|
6
|
+
const code = str.charCodeAt(i);
|
|
7
|
+
view.setUint16(i * 2, code, littleEndian);
|
|
8
|
+
}
|
|
9
|
+
return bytes;
|
|
10
|
+
}
|
|
11
|
+
function utf16le_decode(bytes) {
|
|
12
|
+
const array = ArrayBuffer.isView(bytes) ? bytes : Uint8Array.from(bytes);
|
|
13
|
+
const view = new DataView(array.buffer, array.byteOffset, array.byteLength);
|
|
14
|
+
const chars = new Array(view.byteLength / 2);
|
|
15
|
+
for (let i = 0; i < chars.length; i++) {
|
|
16
|
+
const code = view.getUint16(i * 2, littleEndian);
|
|
17
|
+
chars[i] = String.fromCharCode(code);
|
|
18
|
+
}
|
|
19
|
+
return chars.join("");
|
|
20
|
+
}
|
|
21
|
+
function utf8_encode(str) {
|
|
22
|
+
let pos = 0;
|
|
23
|
+
let buf = new Uint8Array(str.length * 3);
|
|
24
|
+
for (let i = 0; i < str.length; i++) {
|
|
25
|
+
let code = str.charCodeAt(i);
|
|
26
|
+
if (code >= 0xD800 && code <= 0xDBFF) {
|
|
27
|
+
const nextCode = (i < str.length) ? str.charCodeAt(i + 1) : 0;
|
|
28
|
+
if (nextCode >= 0xDC00 && nextCode <= 0xDFFF) {
|
|
29
|
+
i += 1;
|
|
30
|
+
code = (code - 0xD800) * 0x400 + nextCode - 0xDC00 + 0x10000;
|
|
31
|
+
if (code > 0xFFFF) {
|
|
32
|
+
buf[pos++] = (0x1E << 3) | (code >>> 18);
|
|
33
|
+
buf[pos++] = (0x2 << 6) | ((code >>> 12) & 0x3F);
|
|
34
|
+
buf[pos++] = (0x2 << 6) | ((code >>> 6) & 0x3F);
|
|
35
|
+
buf[pos++] = (0x2 << 6) | (code & 0x3F);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
buf[pos++] = 0xEF;
|
|
40
|
+
buf[pos++] = 0xBF;
|
|
41
|
+
buf[pos++] = 0xBD;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
else if (code <= 0x007F) {
|
|
45
|
+
buf[pos++] = (0x0 << 7) | code;
|
|
46
|
+
}
|
|
47
|
+
else if (code <= 0x07FF) {
|
|
48
|
+
buf[pos++] = (0x6 << 5) | (code >>> 6);
|
|
49
|
+
buf[pos++] = (0x2 << 6) | (code & 0x3F);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
buf[pos++] = (0xE << 4) | (code >>> 12);
|
|
53
|
+
buf[pos++] = (0x2 << 6) | ((code >>> 6) & 0x3F);
|
|
54
|
+
buf[pos++] = (0x2 << 6) | (code & 0x3F);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
buf = new Uint8Array(buf.buffer.slice(0, pos));
|
|
58
|
+
return buf;
|
|
59
|
+
}
|
|
60
|
+
function utf8_decode(bytes) {
|
|
61
|
+
let pos = 0;
|
|
62
|
+
const decodeUtf8 = () => {
|
|
63
|
+
const i1 = bytes[pos++];
|
|
64
|
+
if ((i1 & 0x80) === 0) {
|
|
65
|
+
return i1;
|
|
66
|
+
}
|
|
67
|
+
else if ((i1 & 0xE0) === 0xC0) {
|
|
68
|
+
const i2 = bytes[pos++];
|
|
69
|
+
return ((i1 & 0x1F) << 6) | (i2 & 0x3F);
|
|
70
|
+
}
|
|
71
|
+
else if ((i1 & 0xF0) === 0xE0) {
|
|
72
|
+
const i2 = bytes[pos++];
|
|
73
|
+
const i3 = bytes[pos++];
|
|
74
|
+
return ((i1 & 0x0F) << 12) | ((i2 & 0x3F) << 6) | (i3 & 0x3F);
|
|
75
|
+
}
|
|
76
|
+
else if ((i1 & 0xF8) === 0xF0) {
|
|
77
|
+
const i2 = bytes[pos++];
|
|
78
|
+
const i3 = bytes[pos++];
|
|
79
|
+
const i4 = bytes[pos++];
|
|
80
|
+
return ((i1 & 0x07) << 18) | ((i2 & 0x3F) << 12) | ((i3 & 0x3F) << 6) | (i4 & 0x3F);
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
throw new RangeError("Invalid UTF8 byte: " + i1);
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
const chars = new Array();
|
|
87
|
+
while (pos < bytes.length) {
|
|
88
|
+
const code = decodeUtf8();
|
|
89
|
+
chars.push(String.fromCodePoint(code));
|
|
90
|
+
}
|
|
91
|
+
return chars.join("");
|
|
92
|
+
}
|
|
93
|
+
class UTF16LE {
|
|
94
|
+
getBytes(str, index, count) {
|
|
95
|
+
str = Array.isArray(str) ? str.join("") : str;
|
|
96
|
+
if (index != null && count != null) {
|
|
97
|
+
str = str.substring(index, index + count);
|
|
98
|
+
}
|
|
99
|
+
else if (index != null) {
|
|
100
|
+
str = str.substring(index);
|
|
101
|
+
}
|
|
102
|
+
// Allow to compile for Browser environment without @types/node being installed
|
|
103
|
+
// See https://github.com/fable-compiler/Fable/issues/4368
|
|
104
|
+
const g = globalThis;
|
|
105
|
+
if (typeof g.Buffer !== "undefined") {
|
|
106
|
+
const bytes = g.Buffer.from(str, "utf16le");
|
|
107
|
+
return new Uint8Array(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
return utf16le_encode(str); // polyfill
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
getString(bytes, index, count) {
|
|
114
|
+
const array = ArrayBuffer.isView(bytes) ? bytes : Uint8Array.from(bytes);
|
|
115
|
+
let buffer = new Uint8Array(array.buffer, array.byteOffset, array.byteLength);
|
|
116
|
+
if (index != null && count != null) {
|
|
117
|
+
buffer = buffer.subarray(index, index + count);
|
|
118
|
+
}
|
|
119
|
+
else if (index != null) {
|
|
120
|
+
buffer = buffer.subarray(index);
|
|
121
|
+
}
|
|
122
|
+
// Allow to compile for Browser environment without @types/node being installed
|
|
123
|
+
// See https://github.com/fable-compiler/Fable/issues/4368
|
|
124
|
+
const g = globalThis;
|
|
125
|
+
if (typeof TextDecoder !== "undefined") {
|
|
126
|
+
return new TextDecoder("utf-16le").decode(buffer);
|
|
127
|
+
}
|
|
128
|
+
else if (typeof g.Buffer !== "undefined") {
|
|
129
|
+
return g.Buffer.from(buffer).toString("utf16le");
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
return utf16le_decode(buffer); // polyfill
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
class UTF8 {
|
|
137
|
+
getBytes(str, index, count) {
|
|
138
|
+
str = Array.isArray(str) ? str.join("") : str;
|
|
139
|
+
if (index != null && count != null) {
|
|
140
|
+
str = str.substring(index, index + count);
|
|
141
|
+
}
|
|
142
|
+
else if (index != null) {
|
|
143
|
+
str = str.substring(index);
|
|
144
|
+
}
|
|
145
|
+
// Allow to compile for Browser environment without @types/node being installed
|
|
146
|
+
// See https://github.com/fable-compiler/Fable/issues/4368
|
|
147
|
+
const g = globalThis;
|
|
148
|
+
if (typeof TextEncoder !== "undefined") {
|
|
149
|
+
return new TextEncoder().encode(str);
|
|
150
|
+
}
|
|
151
|
+
else if (typeof g.Buffer !== "undefined") {
|
|
152
|
+
const bytes = g.Buffer.from(str, "utf8");
|
|
153
|
+
return new Uint8Array(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
return utf8_encode(str); // polyfill
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
getString(bytes, index, count) {
|
|
160
|
+
const array = ArrayBuffer.isView(bytes) ? bytes : Uint8Array.from(bytes);
|
|
161
|
+
let buffer = new Uint8Array(array.buffer, array.byteOffset, array.byteLength);
|
|
162
|
+
if (index != null && count != null) {
|
|
163
|
+
buffer = buffer.subarray(index, index + count);
|
|
164
|
+
}
|
|
165
|
+
else if (index != null) {
|
|
166
|
+
buffer = buffer.subarray(index);
|
|
167
|
+
}
|
|
168
|
+
// Allow to compile for Browser environment without @types/node being installed
|
|
169
|
+
// See https://github.com/fable-compiler/Fable/issues/4368
|
|
170
|
+
const g = globalThis;
|
|
171
|
+
if (typeof TextDecoder !== "undefined") {
|
|
172
|
+
return new TextDecoder().decode(buffer);
|
|
173
|
+
}
|
|
174
|
+
else if (typeof g.Buffer !== "undefined") {
|
|
175
|
+
return g.Buffer.from(buffer).toString("utf8");
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
return utf8_decode(buffer); // polyfill
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
const _UTF16 = new UTF16LE();
|
|
183
|
+
const _UTF8 = new UTF8();
|
|
184
|
+
export function get_Unicode() { return _UTF16; }
|
|
185
|
+
export function get_UTF8() { return _UTF8; }
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { subscribe } from "./Observable.js";
|
|
2
|
+
import { some, value } from "./Option.js";
|
|
3
|
+
import { Choice_tryValueIfChoice1Of2, Choice_tryValueIfChoice2Of2 } from "./Choice.js";
|
|
4
|
+
export class Event$2 {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.delegates = [];
|
|
7
|
+
}
|
|
8
|
+
_add(d) {
|
|
9
|
+
this.delegates.push(d);
|
|
10
|
+
}
|
|
11
|
+
_remove(d) {
|
|
12
|
+
const index = this.delegates.indexOf(d);
|
|
13
|
+
if (index > -1) {
|
|
14
|
+
this.delegates.splice(index, 1);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
get Publish() {
|
|
18
|
+
return createEvent(h => { this._add(h); }, h => { this._remove(h); });
|
|
19
|
+
}
|
|
20
|
+
Trigger(senderOrValue, valueOrUndefined) {
|
|
21
|
+
let sender = null;
|
|
22
|
+
const value = valueOrUndefined === undefined ? senderOrValue : (sender = senderOrValue, valueOrUndefined);
|
|
23
|
+
this.delegates.forEach(f => { f(sender, value); });
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export class Event extends Event$2 {
|
|
27
|
+
}
|
|
28
|
+
export function add(callback, sourceEvent) {
|
|
29
|
+
subscribe(callback, sourceEvent);
|
|
30
|
+
}
|
|
31
|
+
export function choose(chooser, sourceEvent) {
|
|
32
|
+
const ev = new Event();
|
|
33
|
+
add((t) => {
|
|
34
|
+
const u = chooser(t);
|
|
35
|
+
if (u != null) {
|
|
36
|
+
ev.Trigger(value(u));
|
|
37
|
+
}
|
|
38
|
+
}, sourceEvent);
|
|
39
|
+
return ev.Publish;
|
|
40
|
+
}
|
|
41
|
+
export function filter(predicate, sourceEvent) {
|
|
42
|
+
return choose((x) => predicate(x) ? some(x) : undefined, sourceEvent);
|
|
43
|
+
}
|
|
44
|
+
export function map(mapping, sourceEvent) {
|
|
45
|
+
const ev = new Event();
|
|
46
|
+
add((t) => ev.Trigger(mapping(t)), sourceEvent);
|
|
47
|
+
return ev.Publish;
|
|
48
|
+
}
|
|
49
|
+
export function merge(event1, event2) {
|
|
50
|
+
const ev = new Event();
|
|
51
|
+
const fn = (x) => ev.Trigger(x);
|
|
52
|
+
add(fn, event1);
|
|
53
|
+
add(fn, event2);
|
|
54
|
+
return ev.Publish;
|
|
55
|
+
}
|
|
56
|
+
export function pairwise(sourceEvent) {
|
|
57
|
+
const ev = new Event();
|
|
58
|
+
let last;
|
|
59
|
+
let haveLast = false;
|
|
60
|
+
add((next) => {
|
|
61
|
+
if (haveLast) {
|
|
62
|
+
ev.Trigger([last, next]);
|
|
63
|
+
}
|
|
64
|
+
last = next;
|
|
65
|
+
haveLast = true;
|
|
66
|
+
}, sourceEvent);
|
|
67
|
+
return ev.Publish;
|
|
68
|
+
}
|
|
69
|
+
export function partition(predicate, sourceEvent) {
|
|
70
|
+
return [filter(predicate, sourceEvent), filter((x) => !predicate(x), sourceEvent)];
|
|
71
|
+
}
|
|
72
|
+
export function scan(collector, state, sourceEvent) {
|
|
73
|
+
return map((t) => state = collector(state, t), sourceEvent);
|
|
74
|
+
}
|
|
75
|
+
export function split(splitter, sourceEvent) {
|
|
76
|
+
return [
|
|
77
|
+
choose((v) => Choice_tryValueIfChoice1Of2(splitter(v)), sourceEvent),
|
|
78
|
+
choose((v) => Choice_tryValueIfChoice2Of2(splitter(v)), sourceEvent),
|
|
79
|
+
];
|
|
80
|
+
}
|
|
81
|
+
export function createEvent(addHandler, removeHandler) {
|
|
82
|
+
return {
|
|
83
|
+
AddHandler(h) { addHandler(h); },
|
|
84
|
+
RemoveHandler(h) { removeHandler(h); },
|
|
85
|
+
Subscribe(r) {
|
|
86
|
+
const h = ((_, args) => r.OnNext(args));
|
|
87
|
+
addHandler(h);
|
|
88
|
+
return {
|
|
89
|
+
Dispose() { removeHandler(h); }
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { compare, physicalHash, equals as equals_1, structuralHash } from "./Util.js";
|
|
2
|
+
export function HashIdentity_FromFunctions(hasher, equals) {
|
|
3
|
+
return {
|
|
4
|
+
GetHashCode(x) {
|
|
5
|
+
return hasher(x) | 0;
|
|
6
|
+
},
|
|
7
|
+
Equals(x_1, y) {
|
|
8
|
+
return (x_1 == null) ? (y == null) : ((y == null) ? false : equals(x_1, y));
|
|
9
|
+
},
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export function HashIdentity_Structural() {
|
|
13
|
+
return {
|
|
14
|
+
GetHashCode(x) {
|
|
15
|
+
return structuralHash(x) | 0;
|
|
16
|
+
},
|
|
17
|
+
Equals(x_1, y) {
|
|
18
|
+
return equals_1(x_1, y);
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export function HashIdentity_Reference() {
|
|
23
|
+
return {
|
|
24
|
+
GetHashCode(x) {
|
|
25
|
+
return physicalHash(x) | 0;
|
|
26
|
+
},
|
|
27
|
+
Equals(x_1, y) {
|
|
28
|
+
return equals_1(x_1, y);
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export function ComparisonIdentity_FromFunction(comparer) {
|
|
33
|
+
return {
|
|
34
|
+
Compare(x, y) {
|
|
35
|
+
return ((x == null) ? ((y == null) ? 0 : -1) : ((y == null) ? 1 : comparer(x, y))) | 0;
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
export function ComparisonIdentity_Structural() {
|
|
40
|
+
return {
|
|
41
|
+
Compare(x, y) {
|
|
42
|
+
return compare(x, y) | 0;
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { class_type } from "./Reflection.js";
|
|
2
|
+
import { addRangeInPlace } from "./Array.js";
|
|
3
|
+
import { toList } from "./Seq.js";
|
|
4
|
+
export class ListCollector$1 {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.collector = [];
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export function ListCollector$1_$reflection(gen0) {
|
|
10
|
+
return class_type("Microsoft.FSharp.Core.CompilerServices.ListCollector`1", [gen0], ListCollector$1);
|
|
11
|
+
}
|
|
12
|
+
export function ListCollector$1_$ctor() {
|
|
13
|
+
return new ListCollector$1();
|
|
14
|
+
}
|
|
15
|
+
export function ListCollector$1__Add_2B595(this$, value) {
|
|
16
|
+
void (this$.collector.push(value));
|
|
17
|
+
}
|
|
18
|
+
export function ListCollector$1__AddMany_BB573A(this$, values) {
|
|
19
|
+
addRangeInPlace(values, this$.collector);
|
|
20
|
+
}
|
|
21
|
+
export function ListCollector$1__AddManyAndClose_BB573A(this$, values) {
|
|
22
|
+
addRangeInPlace(values, this$.collector);
|
|
23
|
+
return toList(this$.collector);
|
|
24
|
+
}
|
|
25
|
+
export function ListCollector$1__Close(this$) {
|
|
26
|
+
return toList(this$.collector);
|
|
27
|
+
}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { disposeSafe, defaultOf, Exception, structuralHash, equals } from "./Util.js";
|
|
2
|
+
import { HashIdentity_Structural, ComparisonIdentity_Structural } from "./FSharp.Collections.js";
|
|
3
|
+
import { nonNullValue } from "./Option.js";
|
|
4
|
+
import { NullReferenceException_$ctor, ArgumentNullException_$ctor_Z721C83C5 } from "./System.js";
|
|
5
|
+
import { FSharpChoice$2_Choice2Of2, FSharpChoice$2_Choice1Of2 } from "./Choice.js";
|
|
6
|
+
import { StringBuilder__Append_Z721C83C5 } from "./System.Text.js";
|
|
7
|
+
export const LanguagePrimitives_GenericEqualityComparer = {
|
|
8
|
+
Equals(x, y) {
|
|
9
|
+
return equals(x, y);
|
|
10
|
+
},
|
|
11
|
+
GetHashCode(x_1) {
|
|
12
|
+
return structuralHash(x_1) | 0;
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
export const LanguagePrimitives_GenericEqualityERComparer = {
|
|
16
|
+
Equals(x, y) {
|
|
17
|
+
return equals(x, y);
|
|
18
|
+
},
|
|
19
|
+
GetHashCode(x_1) {
|
|
20
|
+
return structuralHash(x_1) | 0;
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
export function LanguagePrimitives_FastGenericComparer() {
|
|
24
|
+
return ComparisonIdentity_Structural();
|
|
25
|
+
}
|
|
26
|
+
export function LanguagePrimitives_FastGenericComparerFromTable() {
|
|
27
|
+
return ComparisonIdentity_Structural();
|
|
28
|
+
}
|
|
29
|
+
export function LanguagePrimitives_FastGenericEqualityComparer() {
|
|
30
|
+
return HashIdentity_Structural();
|
|
31
|
+
}
|
|
32
|
+
export function LanguagePrimitives_FastGenericEqualityComparerFromTable() {
|
|
33
|
+
return HashIdentity_Structural();
|
|
34
|
+
}
|
|
35
|
+
export function Operators_Failure(message) {
|
|
36
|
+
return new Exception(message);
|
|
37
|
+
}
|
|
38
|
+
export function Operators_FailurePattern(exn) {
|
|
39
|
+
return exn.message;
|
|
40
|
+
}
|
|
41
|
+
export function Operators_NullArg(argumentName) {
|
|
42
|
+
throw ArgumentNullException_$ctor_Z721C83C5(argumentName);
|
|
43
|
+
}
|
|
44
|
+
export function Operators_Using(resource, action) {
|
|
45
|
+
try {
|
|
46
|
+
return action(resource);
|
|
47
|
+
}
|
|
48
|
+
finally {
|
|
49
|
+
if (equals(resource, defaultOf())) {
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
let copyOfStruct = resource;
|
|
53
|
+
disposeSafe(copyOfStruct);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
export function Operators_Lock(_lockObj, action) {
|
|
58
|
+
return action();
|
|
59
|
+
}
|
|
60
|
+
export function Operators_IsNull(value) {
|
|
61
|
+
if (equals(value, defaultOf())) {
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
export function Operators_IsNotNull(value) {
|
|
69
|
+
if (equals(value, defaultOf())) {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
export function Operators_IsNullV(value) {
|
|
77
|
+
return !(value != null);
|
|
78
|
+
}
|
|
79
|
+
export function Operators_NonNull(value) {
|
|
80
|
+
if (equals(value, defaultOf())) {
|
|
81
|
+
throw NullReferenceException_$ctor();
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
return value;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
export function Operators_NonNullV(value) {
|
|
88
|
+
if (value != null) {
|
|
89
|
+
return nonNullValue(value);
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
throw NullReferenceException_$ctor();
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
export function Operators_NullMatchPattern(value) {
|
|
96
|
+
if (equals(value, defaultOf())) {
|
|
97
|
+
return FSharpChoice$2_Choice1Of2(undefined);
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
return FSharpChoice$2_Choice2Of2(value);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
export function Operators_NullValueMatchPattern(value) {
|
|
104
|
+
if (value != null) {
|
|
105
|
+
return FSharpChoice$2_Choice2Of2(nonNullValue(value));
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
return FSharpChoice$2_Choice1Of2(undefined);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
export function Operators_NonNullQuickPattern(value) {
|
|
112
|
+
if (equals(value, defaultOf())) {
|
|
113
|
+
throw NullReferenceException_$ctor();
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
return value;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
export function Operators_NonNullQuickValuePattern(value) {
|
|
120
|
+
if (value != null) {
|
|
121
|
+
return nonNullValue(value);
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
throw NullReferenceException_$ctor();
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
export function Operators_WithNull(value) {
|
|
128
|
+
return value;
|
|
129
|
+
}
|
|
130
|
+
export function Operators_WithNullV(value) {
|
|
131
|
+
return value;
|
|
132
|
+
}
|
|
133
|
+
export function Operators_NullV() {
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
export function Operators_NullArgCheck(argumentName, value) {
|
|
137
|
+
if (equals(value, defaultOf())) {
|
|
138
|
+
throw ArgumentNullException_$ctor_Z721C83C5(argumentName);
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
return value;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
export function ExtraTopLevelOperators_LazyPattern(input) {
|
|
145
|
+
return input.Value;
|
|
146
|
+
}
|
|
147
|
+
export function PrintfModule_PrintFormatToStringBuilderThen(continuation, builder, format) {
|
|
148
|
+
return format.cont((s) => {
|
|
149
|
+
StringBuilder__Append_Z721C83C5(builder, s);
|
|
150
|
+
return continuation();
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
export function PrintfModule_PrintFormatToStringBuilder(builder, format) {
|
|
154
|
+
return PrintfModule_PrintFormatToStringBuilderThen(() => {
|
|
155
|
+
}, builder, format);
|
|
156
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export const SR_indexOutOfBounds = "The index was outside the range of elements in the collection.";
|
|
2
|
+
export const SR_inputWasEmpty = "Collection was empty.";
|
|
3
|
+
export const SR_inputMustBeNonNegative = "The input must be non-negative.";
|
|
4
|
+
export const SR_inputSequenceEmpty = "The input sequence was empty.";
|
|
5
|
+
export const SR_inputSequenceTooLong = "The input sequence contains more than one element.";
|
|
6
|
+
export const SR_keyNotFoundAlt = "An index satisfying the predicate was not found in the collection.";
|
|
7
|
+
export const SR_differentLengths = "The collections had different lengths.";
|
|
8
|
+
export const SR_notEnoughElements = "The input sequence has an insufficient number of elements.";
|
|
9
|
+
export const SR_Arg_ApplicationException = "Error in the application.";
|
|
10
|
+
export const SR_Arg_ArgumentException = "Value does not fall within the expected range.";
|
|
11
|
+
export const SR_Arg_ArgumentOutOfRangeException = "Specified argument was out of the range of valid values.";
|
|
12
|
+
export const SR_ArgumentNull_Generic = "Value cannot be null.";
|
|
13
|
+
export const SR_Arg_ParamName_Name = " (Parameter \'";
|
|
14
|
+
export const SR_Arg_ArithmeticException = "Overflow or underflow in the arithmetic operation.";
|
|
15
|
+
export const SR_Arg_DivideByZero = "Attempted to divide by zero.";
|
|
16
|
+
export const SR_Arg_FormatException = "One of the identified items was in an invalid format.";
|
|
17
|
+
export const SR_Arg_IndexOutOfRangeException = "Index was outside the bounds of the array.";
|
|
18
|
+
export const SR_Arg_InvalidOperationException = "Operation is not valid due to the current state of the object.";
|
|
19
|
+
export const SR_Arg_KeyNotFound = "The given key was not present in the dictionary.";
|
|
20
|
+
export const SR_Arg_NotFiniteNumberException = "Number encountered was not a finite quantity.";
|
|
21
|
+
export const SR_Arg_NotImplementedException = "The method or operation is not implemented.";
|
|
22
|
+
export const SR_Arg_NotSupportedException = "Specified method is not supported.";
|
|
23
|
+
export const SR_Arg_NullReferenceException = "Object reference not set to an instance of an object.";
|
|
24
|
+
export const SR_Arg_OutOfMemoryException = "Insufficient memory to continue the execution of the program.";
|
|
25
|
+
export const SR_Arg_OverflowException = "Arithmetic operation resulted in an overflow.";
|
|
26
|
+
export const SR_Arg_RankException = "Attempted to operate on an array with the incorrect number of dimensions.";
|
|
27
|
+
export const SR_Arg_StackOverflowException = "Operation caused a stack overflow.";
|
|
28
|
+
export const SR_Arg_SystemException = "System error.";
|
|
29
|
+
export const SR_Arg_TimeoutException = "The operation has timed out.";
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { trim } from "./String.js";
|
|
2
|
+
import { Exception } from "./Util.js";
|
|
3
|
+
// RFC 4122 compliant. From https://stackoverflow.com/a/13653180/3922220
|
|
4
|
+
// const guidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
|
|
5
|
+
// Relax GUID parsing, see #1637
|
|
6
|
+
const guidRegex = /^[\(\{]{0,2}[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}[\)\}]{0,2}$/;
|
|
7
|
+
const guidRegexNoHyphen = /^([0-9a-f]{8})([0-9a-f]{4})([0-9a-f]{4})([0-9a-f]{4})([0-9a-f]{12})$/;
|
|
8
|
+
const guidRegexHex = /^\{0x[0-9a-f]{8},(0x[0-9a-f]{4},){2}\{(0x[0-9a-f]{2},){7}0x[0-9a-f]{2}\}\}$/;
|
|
9
|
+
const guidHexCaptures = /^([0-9a-f]{8})-(([0-9a-f]{4})-)(([0-9a-f]{4})-)([0-9a-f]{2})([0-9a-f]{2})-([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/;
|
|
10
|
+
export function toString(str, format, _provider) {
|
|
11
|
+
if (format && format?.length > 0) {
|
|
12
|
+
switch (format) {
|
|
13
|
+
case "N":
|
|
14
|
+
return str.replace(/-/g, '');
|
|
15
|
+
case "D":
|
|
16
|
+
return str;
|
|
17
|
+
case "B":
|
|
18
|
+
return "{" + str + "}";
|
|
19
|
+
case "P":
|
|
20
|
+
return "(" + str + ")";
|
|
21
|
+
case "X":
|
|
22
|
+
return str.replace(guidHexCaptures, "{0x$1,0x$3,0x$5,{0x$6,0x$7,0x$8,0x$9,0x$10,0x$11,0x$12,0x$13}}");
|
|
23
|
+
default:
|
|
24
|
+
throw new Exception("Unrecognized Guid print format");
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
return str;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/** Validates UUID as specified in RFC4122 (versions 1-5). */
|
|
32
|
+
export function parse(str) {
|
|
33
|
+
function hyphenateGuid(str) {
|
|
34
|
+
return str.replace(guidRegexNoHyphen, "$1-$2-$3-$4-$5");
|
|
35
|
+
}
|
|
36
|
+
const wsTrimAndLowered = str.trim().toLowerCase();
|
|
37
|
+
if (guidRegex.test(wsTrimAndLowered)) {
|
|
38
|
+
return trim(wsTrimAndLowered, "{", "}", "(", ")");
|
|
39
|
+
}
|
|
40
|
+
else if (guidRegexNoHyphen.test(wsTrimAndLowered)) {
|
|
41
|
+
return hyphenateGuid(wsTrimAndLowered);
|
|
42
|
+
}
|
|
43
|
+
else if (guidRegexHex.test(wsTrimAndLowered)) {
|
|
44
|
+
return hyphenateGuid(wsTrimAndLowered.replace(/[\{\},]|0x/g, ''));
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
throw new Exception("Guid should contain 32 digits with 4 dashes: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx");
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
export function tryParse(str, defValue) {
|
|
51
|
+
try {
|
|
52
|
+
defValue.contents = parse(str);
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
export function newGuid() {
|
|
60
|
+
const bytes = new Uint8Array(16);
|
|
61
|
+
crypto.getRandomValues(bytes);
|
|
62
|
+
bytes[6] = (bytes[6] & 0x0f) | 0x40; // version 4
|
|
63
|
+
bytes[8] = (bytes[8] & 0x3f) | 0x80; // variant 1
|
|
64
|
+
const hex = Array.from(bytes, b => b.toString(16).padStart(2, "0")).join("");
|
|
65
|
+
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
|
|
66
|
+
}
|
|
67
|
+
// RFC 9562 UUID v7
|
|
68
|
+
export function createVersion7(timestamp) {
|
|
69
|
+
const ms = timestamp != null ? timestamp.getTime() : Date.now();
|
|
70
|
+
// 48-bit timestamp as hex
|
|
71
|
+
const msHex = Math.floor(ms).toString(16).padStart(12, "0");
|
|
72
|
+
// random bits
|
|
73
|
+
const bytes = new Uint8Array(10);
|
|
74
|
+
crypto.getRandomValues(bytes);
|
|
75
|
+
const view = new DataView(bytes.buffer);
|
|
76
|
+
const randA = view.getUint16(0) & 0x0fff; // 12 bits
|
|
77
|
+
const randB1 = view.getUint16(2) & 0x3fff; // 14 bits
|
|
78
|
+
const randB2 = view.getUint32(4); // 32 bits
|
|
79
|
+
const randB3 = view.getUint16(8); // 16 bits
|
|
80
|
+
const timeLow = msHex.slice(0, 8);
|
|
81
|
+
const timeMid = msHex.slice(8, 12);
|
|
82
|
+
const ver = (0x7000 | randA).toString(16).padStart(4, "0");
|
|
83
|
+
const variantAndRandB = (0x8000 | randB1).toString(16).padStart(4, "0");
|
|
84
|
+
const node = randB2.toString(16).padStart(8, "0") + randB3.toString(16).padStart(4, "0");
|
|
85
|
+
return `${timeLow}-${timeMid}-${ver}-${variantAndRandB}-${node}`;
|
|
86
|
+
}
|
|
87
|
+
// Maps for number <-> hex string conversion
|
|
88
|
+
let _convertMapsInitialized = false;
|
|
89
|
+
let _byteToHex;
|
|
90
|
+
let _hexToByte;
|
|
91
|
+
function initConvertMaps() {
|
|
92
|
+
_byteToHex = new Array(256);
|
|
93
|
+
_hexToByte = {};
|
|
94
|
+
for (let i = 0; i < 256; i++) {
|
|
95
|
+
_byteToHex[i] = i.toString(16).padStart(2, '0');
|
|
96
|
+
_hexToByte[_byteToHex[i]] = i;
|
|
97
|
+
}
|
|
98
|
+
_convertMapsInitialized = true;
|
|
99
|
+
}
|
|
100
|
+
/** Parse a UUID into it's component bytes */
|
|
101
|
+
// Adapted from https://github.com/zefferus/uuid-parse
|
|
102
|
+
export function guidToArray(s) {
|
|
103
|
+
if (!_convertMapsInitialized) {
|
|
104
|
+
initConvertMaps();
|
|
105
|
+
}
|
|
106
|
+
let i = 0;
|
|
107
|
+
const buf = new Uint8Array(16);
|
|
108
|
+
s.toLowerCase().replace(/[0-9a-f]{2}/g, ((oct) => {
|
|
109
|
+
switch (i) {
|
|
110
|
+
// .NET saves first three byte groups with different endianness
|
|
111
|
+
// See https://stackoverflow.com/a/16722909/3922220
|
|
112
|
+
case 0:
|
|
113
|
+
case 1:
|
|
114
|
+
case 2:
|
|
115
|
+
case 3:
|
|
116
|
+
buf[3 - i++] = _hexToByte[oct];
|
|
117
|
+
break;
|
|
118
|
+
case 4:
|
|
119
|
+
case 5:
|
|
120
|
+
buf[9 - i++] = _hexToByte[oct];
|
|
121
|
+
break;
|
|
122
|
+
case 6:
|
|
123
|
+
case 7:
|
|
124
|
+
buf[13 - i++] = _hexToByte[oct];
|
|
125
|
+
break;
|
|
126
|
+
case 8:
|
|
127
|
+
case 9:
|
|
128
|
+
case 10:
|
|
129
|
+
case 11:
|
|
130
|
+
case 12:
|
|
131
|
+
case 13:
|
|
132
|
+
case 14:
|
|
133
|
+
case 15:
|
|
134
|
+
buf[i++] = _hexToByte[oct];
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
}));
|
|
138
|
+
// Zero out remaining bytes if string was short
|
|
139
|
+
while (i < 16) {
|
|
140
|
+
buf[i++] = 0;
|
|
141
|
+
}
|
|
142
|
+
return buf;
|
|
143
|
+
}
|
|
144
|
+
/** Convert UUID byte array into a string */
|
|
145
|
+
export function arrayToGuid(buf) {
|
|
146
|
+
if (buf.length !== 16) {
|
|
147
|
+
throw new Exception("Byte array for GUID must be exactly 16 bytes long");
|
|
148
|
+
}
|
|
149
|
+
if (!_convertMapsInitialized) {
|
|
150
|
+
initConvertMaps();
|
|
151
|
+
}
|
|
152
|
+
const guid = _byteToHex[buf[3]] + _byteToHex[buf[2]] +
|
|
153
|
+
_byteToHex[buf[1]] + _byteToHex[buf[0]] + "-" +
|
|
154
|
+
_byteToHex[buf[5]] + _byteToHex[buf[4]] + "-" +
|
|
155
|
+
_byteToHex[buf[7]] + _byteToHex[buf[6]] + "-" +
|
|
156
|
+
_byteToHex[buf[8]] + _byteToHex[buf[9]] + "-" +
|
|
157
|
+
_byteToHex[buf[10]] + _byteToHex[buf[11]] +
|
|
158
|
+
_byteToHex[buf[12]] + _byteToHex[buf[13]] +
|
|
159
|
+
_byteToHex[buf[14]] + _byteToHex[buf[15]];
|
|
160
|
+
return guid;
|
|
161
|
+
}
|