@tspro/ts-utils-lib 1.16.0 → 1.18.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/CHANGELOG.md +24 -0
- package/README.md +4 -4
- package/dist/index.d.mts +718 -261
- package/dist/index.d.ts +718 -261
- package/dist/index.js +1662 -748
- package/dist/index.mjs +1659 -748
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* TsUtilsLib v1.
|
|
1
|
+
/* TsUtilsLib v1.18.0 | (c) 2023 PahkaSoft | Licensed under the MIT License */
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
4
|
var __export = (target, all) => {
|
|
@@ -7,55 +7,51 @@ var __export = (target, all) => {
|
|
|
7
7
|
};
|
|
8
8
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
9
9
|
|
|
10
|
-
// src/
|
|
11
|
-
var
|
|
12
|
-
__export(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
getSequenceArray: () => getSequenceArray,
|
|
32
|
-
isArray: () => isArray,
|
|
33
|
-
mapRangeArray: () => mapRangeArray,
|
|
34
|
-
mapSequenceArray: () => mapSequenceArray,
|
|
35
|
-
removeDuplicates: () => removeDuplicates,
|
|
36
|
-
removeDuplicatesCmp: () => removeDuplicatesCmp,
|
|
37
|
-
toArray: () => toArray
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
// src/utils/is/index.ts
|
|
41
|
-
var is_exports = {};
|
|
42
|
-
__export(is_exports, {
|
|
10
|
+
// src/assert/index.ts
|
|
11
|
+
var assert_exports = {};
|
|
12
|
+
__export(assert_exports, {
|
|
13
|
+
array_elem: () => array_elem,
|
|
14
|
+
array_id: () => array_id,
|
|
15
|
+
assert: () => assert,
|
|
16
|
+
assertEnum: () => assertEnum,
|
|
17
|
+
eq: () => eq,
|
|
18
|
+
even: () => even,
|
|
19
|
+
fail: () => fail,
|
|
20
|
+
finite: () => finite,
|
|
21
|
+
in_group: () => in_group,
|
|
22
|
+
int: () => int,
|
|
23
|
+
int_between: () => int_between,
|
|
24
|
+
int_between_exclusive: () => int_between_exclusive,
|
|
25
|
+
int_eq: () => int_eq,
|
|
26
|
+
int_gt: () => int_gt,
|
|
27
|
+
int_gte: () => int_gte,
|
|
28
|
+
int_lt: () => int_lt,
|
|
29
|
+
int_lte: () => int_lte,
|
|
30
|
+
interrupt: () => interrupt,
|
|
43
31
|
isArray: () => isArray,
|
|
32
|
+
isArrayIndex: () => isArrayIndex,
|
|
44
33
|
isArrayOrUndefined: () => isArrayOrUndefined,
|
|
45
34
|
isBoolean: () => isBoolean,
|
|
46
35
|
isBooleanOrUndefined: () => isBooleanOrUndefined,
|
|
36
|
+
isDeepEqual: () => isDeepEqual,
|
|
47
37
|
isEmptyArray: () => isEmptyArray,
|
|
48
38
|
isEmptyArrayOrUndefined: () => isEmptyArrayOrUndefined,
|
|
49
39
|
isEmptyString: () => isEmptyString,
|
|
50
40
|
isEmptyStringOrUndefined: () => isEmptyStringOrUndefined,
|
|
51
41
|
isEnumValue: () => isEnumValue,
|
|
52
42
|
isEnumValueOrUndefined: () => isEnumValueOrUndefined,
|
|
43
|
+
isEqual: () => isEqual,
|
|
44
|
+
isEvenNumber: () => isEvenNumber,
|
|
45
|
+
isFalse: () => isFalse,
|
|
46
|
+
isFalseOrUndefined: () => isFalseOrUndefined,
|
|
53
47
|
isFinite: () => isFinite2,
|
|
54
48
|
isFunction: () => isFunction,
|
|
55
49
|
isFunctionOrUndefined: () => isFunctionOrUndefined,
|
|
50
|
+
isIncluded: () => isIncluded,
|
|
56
51
|
isInfinity: () => isInfinity,
|
|
57
52
|
isInteger: () => isInteger,
|
|
58
53
|
isIntegerBetween: () => isIntegerBetween,
|
|
54
|
+
isIntegerBetweenExclusive: () => isIntegerBetweenExclusive,
|
|
59
55
|
isIntegerEq: () => isIntegerEq,
|
|
60
56
|
isIntegerGt: () => isIntegerGt,
|
|
61
57
|
isIntegerGte: () => isIntegerGte,
|
|
@@ -71,143 +67,936 @@ __export(is_exports, {
|
|
|
71
67
|
isNull: () => isNull,
|
|
72
68
|
isNullish: () => isNullish,
|
|
73
69
|
isNumber: () => isNumber,
|
|
70
|
+
isNumberBetween: () => isNumberBetween,
|
|
71
|
+
isNumberBetweenExclusive: () => isNumberBetweenExclusive,
|
|
74
72
|
isNumberOrUndefined: () => isNumberOrUndefined,
|
|
75
73
|
isObject: () => isObject,
|
|
76
74
|
isObjectOrUndefined: () => isObjectOrUndefined,
|
|
75
|
+
isOddNumber: () => isOddNumber,
|
|
77
76
|
isPosInfinity: () => isPosInfinity,
|
|
78
77
|
isString: () => isString,
|
|
79
78
|
isStringOrUndefined: () => isStringOrUndefined,
|
|
80
|
-
|
|
79
|
+
isThrowing: () => isThrowing,
|
|
80
|
+
isTrue: () => isTrue,
|
|
81
|
+
isTrueOrUndefined: () => isTrueOrUndefined,
|
|
82
|
+
isTypedObject: () => isTypedObject,
|
|
83
|
+
isUndefined: () => isUndefined,
|
|
84
|
+
odd: () => odd,
|
|
85
|
+
require: () => require2,
|
|
86
|
+
requireDefined: () => requireDefined,
|
|
87
|
+
setErrorClass: () => setErrorClass
|
|
81
88
|
});
|
|
89
|
+
var errorConstructor = Error;
|
|
90
|
+
function setErrorClass(errorClass) {
|
|
91
|
+
errorConstructor = errorClass ?? Error;
|
|
92
|
+
}
|
|
93
|
+
function _fail(...msgs) {
|
|
94
|
+
let msg = msgs.join(", ");
|
|
95
|
+
throw new errorConstructor("Assertion Failed!" + (msg === "" ? "" : " " + msg));
|
|
96
|
+
}
|
|
97
|
+
function interrupt(msg) {
|
|
98
|
+
_fail("Interrupted!");
|
|
99
|
+
}
|
|
100
|
+
function assertEnum(enumVal, enumObj, name = "value") {
|
|
101
|
+
if (!guard_exports.isEnumValue(enumVal, enumObj))
|
|
102
|
+
_fail(`Invalid enum value ${enumVal}.`);
|
|
103
|
+
}
|
|
104
|
+
function int(value, msg) {
|
|
105
|
+
if (!guard_exports.isInteger(value))
|
|
106
|
+
_fail(`Expected ${value} to be integer.`, msg);
|
|
107
|
+
return value;
|
|
108
|
+
}
|
|
109
|
+
function eq(value1, value2, msg) {
|
|
110
|
+
if (value1 !== value2)
|
|
111
|
+
_fail(`Expected ${value1} to equal ${value2}.`, msg);
|
|
112
|
+
return value1;
|
|
113
|
+
}
|
|
114
|
+
function int_eq(value, compareTo, msg) {
|
|
115
|
+
if (!guard_exports.isIntegerEq(value, compareTo))
|
|
116
|
+
_fail(`Expected ${value} to be integer equal to ${compareTo}.`, msg);
|
|
117
|
+
return value;
|
|
118
|
+
}
|
|
119
|
+
function int_lt(value, compareTo, msg) {
|
|
120
|
+
if (!guard_exports.isIntegerLt(value, compareTo))
|
|
121
|
+
_fail(`Expected ${value} to be integer less than ${compareTo}.`, msg);
|
|
122
|
+
return value;
|
|
123
|
+
}
|
|
124
|
+
function int_lte(value, compareTo, msg) {
|
|
125
|
+
if (!guard_exports.isIntegerLte(value, compareTo))
|
|
126
|
+
_fail(`Expected ${value} to be integer less than or equal to ${compareTo}.`, msg);
|
|
127
|
+
return value;
|
|
128
|
+
}
|
|
129
|
+
function int_gt(value, compareTo, msg) {
|
|
130
|
+
if (!guard_exports.isIntegerGt(value, compareTo))
|
|
131
|
+
_fail(`Expected ${value} to be integer greater than ${compareTo}.`, msg);
|
|
132
|
+
return value;
|
|
133
|
+
}
|
|
134
|
+
function int_gte(value, compareTo, msg) {
|
|
135
|
+
if (!guard_exports.isIntegerGte(value, compareTo))
|
|
136
|
+
_fail(`Expected ${value} to be integer greater than or equal to ${compareTo}.`, msg);
|
|
137
|
+
return value;
|
|
138
|
+
}
|
|
139
|
+
function int_between(value, min, max, msg) {
|
|
140
|
+
if (!guard_exports.isIntegerBetween(value, min, max))
|
|
141
|
+
_fail(`Expected integer between ${min} <= ${value} <= ${max}.`, msg);
|
|
142
|
+
return value;
|
|
143
|
+
}
|
|
144
|
+
function int_between_exclusive(value, min, max, msg) {
|
|
145
|
+
if (!guard_exports.isIntegerBetweenExclusive(value, min, max))
|
|
146
|
+
_fail(`Expected integer between ${min} < ${value} < ${max}.`, msg);
|
|
147
|
+
return value;
|
|
148
|
+
}
|
|
149
|
+
function odd(value, msg) {
|
|
150
|
+
if (!guard_exports.isOddNumber(value))
|
|
151
|
+
_fail(`Expected ${value} to be odd number.`, msg);
|
|
152
|
+
return value;
|
|
153
|
+
}
|
|
154
|
+
function even(value, msg) {
|
|
155
|
+
if (!guard_exports.isEvenNumber(value))
|
|
156
|
+
_fail(`Expected ${value} to be even number.`, msg);
|
|
157
|
+
return value;
|
|
158
|
+
}
|
|
159
|
+
function in_group(value, group, msg) {
|
|
160
|
+
if (!group.some((e) => e === value))
|
|
161
|
+
_fail(`Expected ${value} to be in group [${group.map((v) => String(v)).join(", ")}].`, msg);
|
|
162
|
+
return value;
|
|
163
|
+
}
|
|
164
|
+
function finite(value, msg) {
|
|
165
|
+
if (!guard_exports.isFinite(value))
|
|
166
|
+
_fail(`Expected ${value} to be finite number.`, msg);
|
|
167
|
+
return value;
|
|
168
|
+
}
|
|
169
|
+
function array_id(array, index, msg) {
|
|
170
|
+
if (!guard_exports.isInteger(index) || !guard_exports.isArray(array) || index < 0 || index >= array.length)
|
|
171
|
+
_fail(`Expected ${index} to be array index in bounds [0..${array.length - 1}].`, msg);
|
|
172
|
+
return index;
|
|
173
|
+
}
|
|
174
|
+
function array_elem(array, index, msg) {
|
|
175
|
+
return array[array_id(array, index, msg)];
|
|
176
|
+
}
|
|
177
|
+
function assert(condition, msg) {
|
|
178
|
+
if (!condition) {
|
|
179
|
+
_fail(msg);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
function require2(value, msg) {
|
|
183
|
+
if (value == null) {
|
|
184
|
+
_fail(`Expected ${value} not to be nullish`, msg);
|
|
185
|
+
}
|
|
186
|
+
return value;
|
|
187
|
+
}
|
|
188
|
+
function requireDefined(value, msg) {
|
|
189
|
+
if (value === void 0) {
|
|
190
|
+
_fail(`Expected ${value} not to be undefined`, msg);
|
|
191
|
+
}
|
|
192
|
+
return value;
|
|
193
|
+
}
|
|
194
|
+
function fail(msg) {
|
|
195
|
+
_fail(msg);
|
|
196
|
+
}
|
|
197
|
+
function isEqual(value1, value2, msg) {
|
|
198
|
+
if (!guard_exports.isEqual(value1, value2))
|
|
199
|
+
_fail(`Expected ${value1} to equal with ${value2}`, msg);
|
|
200
|
+
return true;
|
|
201
|
+
}
|
|
202
|
+
function isDeepEqual(value1, value2, msg) {
|
|
203
|
+
if (!guard_exports.isDeepEqual(value1, value2))
|
|
204
|
+
_fail(`Expected ${value1} to deep equal with ${value2}`, msg);
|
|
205
|
+
return true;
|
|
206
|
+
}
|
|
207
|
+
function isUndefined(value, msg) {
|
|
208
|
+
if (!guard_exports.isUndefined(value))
|
|
209
|
+
_fail(`Expected ${value} to be undefined`, msg);
|
|
210
|
+
return true;
|
|
211
|
+
}
|
|
212
|
+
function isNull(value, msg) {
|
|
213
|
+
if (!guard_exports.isNull(value))
|
|
214
|
+
_fail(`Expected ${value} to be null`, msg);
|
|
215
|
+
return true;
|
|
216
|
+
}
|
|
217
|
+
function isNullish(value, msg) {
|
|
218
|
+
if (!guard_exports.isNullish(value))
|
|
219
|
+
_fail(`Expected ${value} to be null or undefined`, msg);
|
|
220
|
+
return true;
|
|
221
|
+
}
|
|
222
|
+
function isObject(value, msg) {
|
|
223
|
+
if (!guard_exports.isObject(value))
|
|
224
|
+
_fail(`Expected ${value} to be object`, msg);
|
|
225
|
+
return true;
|
|
226
|
+
}
|
|
227
|
+
function isObjectOrUndefined(value, msg) {
|
|
228
|
+
if (!guard_exports.isObjectOrUndefined(value))
|
|
229
|
+
_fail(`Expected ${value} to be object or undefined`, msg);
|
|
230
|
+
return true;
|
|
231
|
+
}
|
|
232
|
+
function isTypedObject(obj, keys, msg) {
|
|
233
|
+
if (!guard_exports.isTypedObject(obj, keys))
|
|
234
|
+
_fail(`Expected ${obj} to be object with keys [${keys.map((key) => `'${String(key)}'`).join(", ")}]`, msg);
|
|
235
|
+
return true;
|
|
236
|
+
}
|
|
237
|
+
function isArray(value, msg) {
|
|
238
|
+
if (!guard_exports.isArray(value))
|
|
239
|
+
_fail(`Expected ${value} to be array`, msg);
|
|
240
|
+
return true;
|
|
241
|
+
}
|
|
242
|
+
function isArrayOrUndefined(value, msg) {
|
|
243
|
+
if (!guard_exports.isArrayOrUndefined(value))
|
|
244
|
+
_fail(`Expected ${value} to be array or undefined`, msg);
|
|
245
|
+
return true;
|
|
246
|
+
}
|
|
247
|
+
function isEmptyArray(value, msg) {
|
|
248
|
+
if (!guard_exports.isEmptyArray(value))
|
|
249
|
+
_fail(`Expected ${value} to be empty array`, msg);
|
|
250
|
+
return true;
|
|
251
|
+
}
|
|
252
|
+
function isNonEmptyArray(value, msg) {
|
|
253
|
+
if (!guard_exports.isNonEmptyArray(value))
|
|
254
|
+
_fail(`Expected ${value} to be non-empty array`, msg);
|
|
255
|
+
return true;
|
|
256
|
+
}
|
|
257
|
+
function isEmptyArrayOrUndefined(value, msg) {
|
|
258
|
+
if (!guard_exports.isEmptyArrayOrUndefined(value))
|
|
259
|
+
_fail(`Expected ${value} to be empty array or undefined`, msg);
|
|
260
|
+
return true;
|
|
261
|
+
}
|
|
262
|
+
function isNonEmptyArrayOrUndefined(value, msg) {
|
|
263
|
+
if (!guard_exports.isNonEmptyArrayOrUndefined(value))
|
|
264
|
+
_fail(`Expected ${value} to be non-empty array or undefined`, msg);
|
|
265
|
+
return true;
|
|
266
|
+
}
|
|
267
|
+
function isString(value, msg) {
|
|
268
|
+
if (!guard_exports.isString(value))
|
|
269
|
+
_fail(`Expected ${value} to be string`, msg);
|
|
270
|
+
return true;
|
|
271
|
+
}
|
|
272
|
+
function isEmptyString(value, msg) {
|
|
273
|
+
if (!guard_exports.isEmptyString(value))
|
|
274
|
+
_fail(`Expected ${value} to be empty string`, msg);
|
|
275
|
+
return true;
|
|
276
|
+
}
|
|
277
|
+
function isNonEmptyString(value, msg) {
|
|
278
|
+
if (!guard_exports.isNonEmptyString(value))
|
|
279
|
+
_fail(`Expected ${value} to be non-empty string`, msg);
|
|
280
|
+
return true;
|
|
281
|
+
}
|
|
282
|
+
function isStringOrUndefined(value, msg) {
|
|
283
|
+
if (!guard_exports.isStringOrUndefined(value))
|
|
284
|
+
_fail(`Expected ${value} to be string or undefined`, msg);
|
|
285
|
+
return true;
|
|
286
|
+
}
|
|
287
|
+
function isEmptyStringOrUndefined(value, msg) {
|
|
288
|
+
if (!guard_exports.isEmptyStringOrUndefined(value))
|
|
289
|
+
_fail(`Expected ${value} to be empty string or undefined`, msg);
|
|
290
|
+
return true;
|
|
291
|
+
}
|
|
292
|
+
function isNonEmptyStringOrUndefined(value, msg) {
|
|
293
|
+
if (!guard_exports.isNonEmptyStringOrUndefined(value))
|
|
294
|
+
_fail(`Expected ${value} to be non-empty string or undefined`, msg);
|
|
295
|
+
return true;
|
|
296
|
+
}
|
|
297
|
+
function isBoolean(value, msg) {
|
|
298
|
+
if (!guard_exports.isBoolean(value))
|
|
299
|
+
_fail(`Expected ${value} to be boolean`, msg);
|
|
300
|
+
return true;
|
|
301
|
+
}
|
|
302
|
+
function isBooleanOrUndefined(value, msg) {
|
|
303
|
+
if (!guard_exports.isBooleanOrUndefined(value))
|
|
304
|
+
_fail(`Expected ${value} to be boolean or undefined`, msg);
|
|
305
|
+
return true;
|
|
306
|
+
}
|
|
307
|
+
function isTrue(value, msg) {
|
|
308
|
+
if (!guard_exports.isTrue(value))
|
|
309
|
+
_fail(`Expected ${value} to be true`, msg);
|
|
310
|
+
return true;
|
|
311
|
+
}
|
|
312
|
+
function isTrueOrUndefined(value, msg) {
|
|
313
|
+
if (!guard_exports.isTrueOrUndefined(value))
|
|
314
|
+
_fail(`Expected ${value} to be true or undefined`, msg);
|
|
315
|
+
return true;
|
|
316
|
+
}
|
|
317
|
+
function isFalse(value, msg) {
|
|
318
|
+
if (!guard_exports.isFalse(value))
|
|
319
|
+
_fail(`Expected ${value} to be false`, msg);
|
|
320
|
+
return true;
|
|
321
|
+
}
|
|
322
|
+
function isFalseOrUndefined(value, msg) {
|
|
323
|
+
if (!guard_exports.isFalseOrUndefined(value))
|
|
324
|
+
_fail(`Expected ${value} to be false or undefined`, msg);
|
|
325
|
+
return true;
|
|
326
|
+
}
|
|
327
|
+
function isFunction(value, msg) {
|
|
328
|
+
if (!guard_exports.isFunction(value))
|
|
329
|
+
_fail(`Expected ${value} to be function`, msg);
|
|
330
|
+
return true;
|
|
331
|
+
}
|
|
332
|
+
function isFunctionOrUndefined(value, msg) {
|
|
333
|
+
if (!guard_exports.isFunctionOrUndefined(value))
|
|
334
|
+
_fail(`Expected ${value} to be function or undefined`, msg);
|
|
335
|
+
return true;
|
|
336
|
+
}
|
|
337
|
+
function isEnumValue(enumValue, enumObject, msg) {
|
|
338
|
+
if (!guard_exports.isEnumValue(enumValue, enumObject))
|
|
339
|
+
_fail(`Expected ${enumValue} to be enum value`, msg);
|
|
340
|
+
return true;
|
|
341
|
+
}
|
|
342
|
+
function isEnumValueOrUndefined(enumValue, enumObject, msg) {
|
|
343
|
+
if (!guard_exports.isEnumValueOrUndefined(enumValue, enumObject))
|
|
344
|
+
_fail(`Expected ${enumValue} to be enum value or undefined`, msg);
|
|
345
|
+
return true;
|
|
346
|
+
}
|
|
347
|
+
function isNumber(value, msg) {
|
|
348
|
+
if (!guard_exports.isNumber(value))
|
|
349
|
+
_fail(`Expected ${value} to be number`, msg);
|
|
350
|
+
return true;
|
|
351
|
+
}
|
|
352
|
+
function isNumberOrUndefined(value, msg) {
|
|
353
|
+
if (!guard_exports.isNumberOrUndefined(value))
|
|
354
|
+
_fail(`Expected ${value} to be number or undefined`, msg);
|
|
355
|
+
return true;
|
|
356
|
+
}
|
|
357
|
+
function isFinite2(value, msg) {
|
|
358
|
+
if (!guard_exports.isFinite(value))
|
|
359
|
+
_fail(`Expected ${value} to be finite`, msg);
|
|
360
|
+
return true;
|
|
361
|
+
}
|
|
362
|
+
function isInteger(value, msg) {
|
|
363
|
+
if (!guard_exports.isInteger(value))
|
|
364
|
+
_fail(`Expected ${value} to be integer`, msg);
|
|
365
|
+
return true;
|
|
366
|
+
}
|
|
367
|
+
function isIntegerOrUndefined(value, msg) {
|
|
368
|
+
if (!guard_exports.isIntegerOrUndefined(value))
|
|
369
|
+
_fail(`Expected ${value} to be integer or undefined`, msg);
|
|
370
|
+
return true;
|
|
371
|
+
}
|
|
372
|
+
function isIntegerEq(value, compareTo, msg) {
|
|
373
|
+
if (!guard_exports.isIntegerEq(value, compareTo))
|
|
374
|
+
_fail(`Expected ${value} to be integer equal to ${compareTo}`, msg);
|
|
375
|
+
return true;
|
|
376
|
+
}
|
|
377
|
+
function isIntegerGt(value, compareTo, msg) {
|
|
378
|
+
if (!guard_exports.isIntegerGt(value, compareTo))
|
|
379
|
+
_fail(`Expected ${value} to be integer > ${compareTo}`, msg);
|
|
380
|
+
return true;
|
|
381
|
+
}
|
|
382
|
+
function isIntegerGte(value, compareTo, msg) {
|
|
383
|
+
if (!guard_exports.isIntegerGte(value, compareTo))
|
|
384
|
+
_fail(`Expected ${value} to be integer >= ${compareTo}`, msg);
|
|
385
|
+
return true;
|
|
386
|
+
}
|
|
387
|
+
function isIntegerLt(value, compareTo, msg) {
|
|
388
|
+
if (!guard_exports.isIntegerLt(value, compareTo))
|
|
389
|
+
_fail(`Expected ${value} to be integer < ${compareTo}`, msg);
|
|
390
|
+
return true;
|
|
391
|
+
}
|
|
392
|
+
function isIntegerLte(value, compareTo, msg) {
|
|
393
|
+
if (!guard_exports.isIntegerLte(value, compareTo))
|
|
394
|
+
_fail(`Expected ${value} to be integer <= ${compareTo}`, msg);
|
|
395
|
+
return true;
|
|
396
|
+
}
|
|
397
|
+
function isIntegerBetween(value, min, max, msg) {
|
|
398
|
+
if (!guard_exports.isIntegerBetween(value, min, max))
|
|
399
|
+
_fail(`Expected integer ${min} <= ${value} <= ${max}.`, msg);
|
|
400
|
+
return true;
|
|
401
|
+
}
|
|
402
|
+
function isIntegerBetweenExclusive(value, min, max, msg) {
|
|
403
|
+
if (!guard_exports.isIntegerBetweenExclusive(value, min, max))
|
|
404
|
+
_fail(`Expected integer ${min} < ${value} < ${max}.`, msg);
|
|
405
|
+
return true;
|
|
406
|
+
}
|
|
407
|
+
function isNumberBetween(value, min, max, msg) {
|
|
408
|
+
if (!guard_exports.isNumberBetween(value, min, max))
|
|
409
|
+
_fail(`Expected number ${min} <= ${value} <= ${max}.`, msg);
|
|
410
|
+
return true;
|
|
411
|
+
}
|
|
412
|
+
function isNumberBetweenExclusive(value, min, max, msg) {
|
|
413
|
+
if (!guard_exports.isNumberBetweenExclusive(value, min, max))
|
|
414
|
+
_fail(`Expected number ${min} < ${value} < ${max}.`, msg);
|
|
415
|
+
return true;
|
|
416
|
+
}
|
|
417
|
+
function isNaNValue(value, msg) {
|
|
418
|
+
if (!guard_exports.isNaNValue(value))
|
|
419
|
+
_fail(`Expected ${value} to be NaN.`, msg);
|
|
420
|
+
return true;
|
|
421
|
+
}
|
|
422
|
+
function isInfinity(value, msg) {
|
|
423
|
+
if (!guard_exports.isInfinity(value))
|
|
424
|
+
_fail(`Expected ${value} to be +-Infinity.`, msg);
|
|
425
|
+
return true;
|
|
426
|
+
}
|
|
427
|
+
function isPosInfinity(value, msg) {
|
|
428
|
+
if (!guard_exports.isPosInfinity(value))
|
|
429
|
+
_fail(`Expected ${value} to be +Infinity.`, msg);
|
|
430
|
+
return true;
|
|
431
|
+
}
|
|
432
|
+
function isNegInfinity(value, msg) {
|
|
433
|
+
if (!guard_exports.isNegInfinity(value))
|
|
434
|
+
_fail(`Expected ${value} to be -Infinity.`, msg);
|
|
435
|
+
return true;
|
|
436
|
+
}
|
|
437
|
+
function isOddNumber(value, msg) {
|
|
438
|
+
if (!guard_exports.isOddNumber(value))
|
|
439
|
+
_fail(`Expected ${value} to odd number.`, msg);
|
|
440
|
+
return true;
|
|
441
|
+
}
|
|
442
|
+
function isEvenNumber(value, msg) {
|
|
443
|
+
if (!guard_exports.isEvenNumber(value))
|
|
444
|
+
_fail(`Expected ${value} to even number.`, msg);
|
|
445
|
+
return true;
|
|
446
|
+
}
|
|
447
|
+
function isIncluded(value, array, msg) {
|
|
448
|
+
if (!guard_exports.isIncluded(value, array))
|
|
449
|
+
_fail(`Expected ${value} to be included in [${array.map((v) => String(v)).join(", ")}].`, msg);
|
|
450
|
+
return true;
|
|
451
|
+
}
|
|
452
|
+
function isArrayIndex(index, array, msg) {
|
|
453
|
+
if (!guard_exports.isArrayIndex(index, array))
|
|
454
|
+
_fail(`Expected ${index} to be index for array [${array.map((v) => String(v)).join(", ")}]`, msg);
|
|
455
|
+
return true;
|
|
456
|
+
}
|
|
457
|
+
function isThrowing(throwTestFn, msg) {
|
|
458
|
+
if (!guard_exports.isThrowing(throwTestFn))
|
|
459
|
+
_fail(`Expected to throw`, msg);
|
|
460
|
+
return true;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
// src/web/cookies.ts
|
|
464
|
+
var cookies_exports = {};
|
|
465
|
+
__export(cookies_exports, {
|
|
466
|
+
accept: () => accept,
|
|
467
|
+
decline: () => decline,
|
|
468
|
+
erase: () => erase,
|
|
469
|
+
eraseAll: () => eraseAll,
|
|
470
|
+
isConsentPending: () => isConsentPending,
|
|
471
|
+
read: () => read,
|
|
472
|
+
readBool: () => readBool,
|
|
473
|
+
readInt: () => readInt,
|
|
474
|
+
save: () => save,
|
|
475
|
+
setExpireDays: () => setExpireDays
|
|
476
|
+
});
|
|
477
|
+
var ConsentCookieName = "ConsentCookie";
|
|
478
|
+
var _consent;
|
|
479
|
+
var _expires;
|
|
480
|
+
var str = _read(ConsentCookieName);
|
|
481
|
+
_consent = str === "accept" /* Accept */ || str === "decline" /* Decline */ ? str : void 0;
|
|
482
|
+
function setExpireDays(days) {
|
|
483
|
+
_expires = /* @__PURE__ */ new Date();
|
|
484
|
+
_expires.setDate(_expires.getDate() + days);
|
|
485
|
+
}
|
|
486
|
+
function isConsentPending() {
|
|
487
|
+
return _consent === void 0;
|
|
488
|
+
}
|
|
489
|
+
function accept() {
|
|
490
|
+
_consent = "accept" /* Accept */;
|
|
491
|
+
_save(ConsentCookieName, _consent);
|
|
492
|
+
}
|
|
493
|
+
function decline() {
|
|
494
|
+
_consent = "decline" /* Decline */;
|
|
495
|
+
_save(ConsentCookieName, _consent);
|
|
496
|
+
}
|
|
497
|
+
function _getList() {
|
|
498
|
+
let s = document.cookie;
|
|
499
|
+
return s.split(";").map((c) => c.trim());
|
|
500
|
+
}
|
|
501
|
+
function _save(name, value) {
|
|
502
|
+
let cookie = name + "=" + value.toString() + ";sameSite=Lax;";
|
|
503
|
+
if (_expires) {
|
|
504
|
+
cookie += "expires=" + _expires.toUTCString() + ";";
|
|
505
|
+
}
|
|
506
|
+
document.cookie = cookie;
|
|
507
|
+
return value;
|
|
508
|
+
}
|
|
509
|
+
function _read(name, defaultValue) {
|
|
510
|
+
let str2 = _getList().find((c) => c.startsWith(name + "="));
|
|
511
|
+
return str2 === void 0 ? defaultValue : str2.substring(name.length + 1);
|
|
512
|
+
}
|
|
513
|
+
function _erase(name) {
|
|
514
|
+
document.cookie = name + "=;expires=Thu, 01 Jan 1970 00:00:00 UTC;";
|
|
515
|
+
}
|
|
516
|
+
function save(name, value) {
|
|
517
|
+
if (_consent === "accept" /* Accept */) {
|
|
518
|
+
_save(name, value);
|
|
519
|
+
}
|
|
520
|
+
return value;
|
|
521
|
+
}
|
|
522
|
+
function read(name, defaultValue) {
|
|
523
|
+
if (_consent === "accept" /* Accept */) {
|
|
524
|
+
return _read(name, defaultValue) || defaultValue;
|
|
525
|
+
} else {
|
|
526
|
+
return defaultValue;
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
function readInt(name, defaultValue) {
|
|
530
|
+
if (_consent === "accept" /* Accept */) {
|
|
531
|
+
let str2 = _read(name);
|
|
532
|
+
return str2 === void 0 ? defaultValue : parseInt(str2);
|
|
533
|
+
} else {
|
|
534
|
+
return defaultValue;
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
function readBool(name, defaultValue) {
|
|
538
|
+
if (_consent === "accept" /* Accept */) {
|
|
539
|
+
let str2 = _read(name);
|
|
540
|
+
return str2 === void 0 ? defaultValue : /true|1/i.test(str2);
|
|
541
|
+
} else {
|
|
542
|
+
return defaultValue;
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
function erase(name) {
|
|
546
|
+
if (_consent === "accept" /* Accept */ || name === ConsentCookieName) {
|
|
547
|
+
_erase(name);
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
function eraseAll() {
|
|
551
|
+
document.cookie.split(";").forEach((c) => erase(c.trim().split("=")[0]));
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
// src/web/device.ts
|
|
555
|
+
var device_exports = {};
|
|
556
|
+
__export(device_exports, {
|
|
557
|
+
DPI: () => DPI,
|
|
558
|
+
FontSize: () => FontSize,
|
|
559
|
+
HostAddress: () => HostAddress,
|
|
560
|
+
IsMobileDevice: () => IsMobileDevice,
|
|
561
|
+
IsTouchDevice: () => IsTouchDevice,
|
|
562
|
+
PxPerMm: () => PxPerMm,
|
|
563
|
+
ScrollbarWidth: () => ScrollbarWidth,
|
|
564
|
+
mmToPx: () => mmToPx,
|
|
565
|
+
pxToMm: () => pxToMm,
|
|
566
|
+
toPx: () => toPx
|
|
567
|
+
});
|
|
568
|
+
function getDPI() {
|
|
569
|
+
let el = document.createElement("div");
|
|
570
|
+
el.style.width = "1in";
|
|
571
|
+
document.body.appendChild(el);
|
|
572
|
+
let dpi = el.offsetWidth;
|
|
573
|
+
el.remove();
|
|
574
|
+
return dpi || 96;
|
|
575
|
+
}
|
|
576
|
+
function getScrollBarWidth() {
|
|
577
|
+
try {
|
|
578
|
+
let outer = document.createElement("div");
|
|
579
|
+
outer.style.visibility = "hidden";
|
|
580
|
+
outer.style.width = "100px";
|
|
581
|
+
document.body.appendChild(outer);
|
|
582
|
+
let widthNoScroll = outer.offsetWidth;
|
|
583
|
+
outer.style.overflow = "scroll";
|
|
584
|
+
let inner = document.createElement("div");
|
|
585
|
+
inner.style.width = "100%";
|
|
586
|
+
outer.appendChild(inner);
|
|
587
|
+
let widthWithScroll = inner.offsetWidth;
|
|
588
|
+
if (outer.parentNode) {
|
|
589
|
+
outer.parentNode.removeChild(outer);
|
|
590
|
+
}
|
|
591
|
+
return widthNoScroll - widthWithScroll;
|
|
592
|
+
} catch (e) {
|
|
593
|
+
return 0;
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
function getSystemFontSize() {
|
|
597
|
+
let tmpDiv = document.createElement("div");
|
|
598
|
+
tmpDiv.style.cssText = "display:inline-block; padding:0; line-height:1; position:absolute; visibility:hidden; font-size:1em";
|
|
599
|
+
tmpDiv.appendChild(document.createTextNode("M"));
|
|
600
|
+
document.body.appendChild(tmpDiv);
|
|
601
|
+
let fontsize = tmpDiv.offsetHeight;
|
|
602
|
+
document.body.removeChild(tmpDiv);
|
|
603
|
+
return fontsize;
|
|
604
|
+
}
|
|
605
|
+
function getIsTouchDevice() {
|
|
606
|
+
if ("ontouchstart" in window || "DocumentTouch" in window || "createTouch" in document && "createTouchList" in document) {
|
|
607
|
+
return true;
|
|
608
|
+
}
|
|
609
|
+
var prefixes = " -webkit- -moz- -o- -ms- ".split(" ");
|
|
610
|
+
var mq = function(query2) {
|
|
611
|
+
return window.matchMedia(query2).matches;
|
|
612
|
+
};
|
|
613
|
+
var query = ["(", prefixes.join("touch-enabled),("), "heartz", ")"].join("");
|
|
614
|
+
return mq(query);
|
|
615
|
+
}
|
|
616
|
+
function getIsMobileDevice() {
|
|
617
|
+
let a = navigator.userAgent || navigator.vendor || window.opera;
|
|
618
|
+
return /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4));
|
|
619
|
+
}
|
|
620
|
+
function getHostAddress() {
|
|
621
|
+
return location.protocol + "//" + location.host;
|
|
622
|
+
}
|
|
623
|
+
var UnitRegExp = /^(mm|cm|in|inch|px|em)$/;
|
|
624
|
+
var ValueUnitRegExp = /^([0-9\\.]+)(.*)$/;
|
|
625
|
+
var DPI = getDPI();
|
|
626
|
+
var PxPerMm = DPI / 25.4;
|
|
627
|
+
var ScrollbarWidth = getScrollBarWidth();
|
|
628
|
+
var FontSize = getSystemFontSize();
|
|
629
|
+
var IsTouchDevice = getIsTouchDevice();
|
|
630
|
+
var IsMobileDevice = getIsMobileDevice();
|
|
631
|
+
var HostAddress = getHostAddress();
|
|
632
|
+
function pxToMm(px) {
|
|
633
|
+
return px / PxPerMm;
|
|
634
|
+
}
|
|
635
|
+
function mmToPx(mm) {
|
|
636
|
+
return mm * PxPerMm;
|
|
637
|
+
}
|
|
638
|
+
function toPx(input) {
|
|
639
|
+
if (typeof input === "number") {
|
|
640
|
+
return input;
|
|
641
|
+
}
|
|
642
|
+
let value = NaN;
|
|
643
|
+
let unit = void 0;
|
|
644
|
+
let match = input.toString().match(ValueUnitRegExp);
|
|
645
|
+
if (match && match[1]) {
|
|
646
|
+
value = parseFloat(match[1]);
|
|
647
|
+
let unitStr = match[2] ? match[2].toLowerCase() : "undefined";
|
|
648
|
+
let unitStrOk = UnitRegExp.test(unitStr);
|
|
649
|
+
unit = unitStrOk ? unitStr : void 0;
|
|
650
|
+
if (!unit) {
|
|
651
|
+
console.log("Unknown unit '" + unitStr + "' => using 'px'.");
|
|
652
|
+
}
|
|
653
|
+
} else {
|
|
654
|
+
value = parseFloat(input);
|
|
655
|
+
}
|
|
656
|
+
assert_exports.finite(value, "value in function toPx");
|
|
657
|
+
switch (unit) {
|
|
658
|
+
case "mm":
|
|
659
|
+
return mmToPx(value);
|
|
660
|
+
case "cm":
|
|
661
|
+
return mmToPx(value) * 10;
|
|
662
|
+
case "in":
|
|
663
|
+
case "inch":
|
|
664
|
+
return mmToPx(value) * 25.4;
|
|
665
|
+
case "em":
|
|
666
|
+
return FontSize * value;
|
|
667
|
+
default:
|
|
668
|
+
case "px":
|
|
669
|
+
return value;
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
// src/guard/index.ts
|
|
674
|
+
var guard_exports = {};
|
|
675
|
+
__export(guard_exports, {
|
|
676
|
+
isArray: () => isArray2,
|
|
677
|
+
isArrayIndex: () => isArrayIndex2,
|
|
678
|
+
isArrayOrUndefined: () => isArrayOrUndefined2,
|
|
679
|
+
isBoolean: () => isBoolean2,
|
|
680
|
+
isBooleanOrUndefined: () => isBooleanOrUndefined2,
|
|
681
|
+
isDeepEqual: () => isDeepEqual2,
|
|
682
|
+
isEmptyArray: () => isEmptyArray2,
|
|
683
|
+
isEmptyArrayOrUndefined: () => isEmptyArrayOrUndefined2,
|
|
684
|
+
isEmptyString: () => isEmptyString2,
|
|
685
|
+
isEmptyStringOrUndefined: () => isEmptyStringOrUndefined2,
|
|
686
|
+
isEnumValue: () => isEnumValue3,
|
|
687
|
+
isEnumValueOrUndefined: () => isEnumValueOrUndefined2,
|
|
688
|
+
isEqual: () => isEqual2,
|
|
689
|
+
isEvenNumber: () => isEvenNumber2,
|
|
690
|
+
isFalse: () => isFalse2,
|
|
691
|
+
isFalseOrUndefined: () => isFalseOrUndefined2,
|
|
692
|
+
isFinite: () => isFinite3,
|
|
693
|
+
isFunction: () => isFunction2,
|
|
694
|
+
isFunctionOrUndefined: () => isFunctionOrUndefined2,
|
|
695
|
+
isIncluded: () => isIncluded2,
|
|
696
|
+
isInfinity: () => isInfinity2,
|
|
697
|
+
isInteger: () => isInteger2,
|
|
698
|
+
isIntegerBetween: () => isIntegerBetween2,
|
|
699
|
+
isIntegerBetweenExclusive: () => isIntegerBetweenExclusive2,
|
|
700
|
+
isIntegerEq: () => isIntegerEq2,
|
|
701
|
+
isIntegerGt: () => isIntegerGt2,
|
|
702
|
+
isIntegerGte: () => isIntegerGte2,
|
|
703
|
+
isIntegerLt: () => isIntegerLt2,
|
|
704
|
+
isIntegerLte: () => isIntegerLte2,
|
|
705
|
+
isIntegerOrUndefined: () => isIntegerOrUndefined2,
|
|
706
|
+
isNaNValue: () => isNaNValue2,
|
|
707
|
+
isNegInfinity: () => isNegInfinity2,
|
|
708
|
+
isNonEmptyArray: () => isNonEmptyArray2,
|
|
709
|
+
isNonEmptyArrayOrUndefined: () => isNonEmptyArrayOrUndefined2,
|
|
710
|
+
isNonEmptyString: () => isNonEmptyString2,
|
|
711
|
+
isNonEmptyStringOrUndefined: () => isNonEmptyStringOrUndefined2,
|
|
712
|
+
isNull: () => isNull2,
|
|
713
|
+
isNullish: () => isNullish2,
|
|
714
|
+
isNumber: () => isNumber2,
|
|
715
|
+
isNumberBetween: () => isNumberBetween2,
|
|
716
|
+
isNumberBetweenExclusive: () => isNumberBetweenExclusive2,
|
|
717
|
+
isNumberOrUndefined: () => isNumberOrUndefined2,
|
|
718
|
+
isObject: () => isObject2,
|
|
719
|
+
isObjectOrUndefined: () => isObjectOrUndefined2,
|
|
720
|
+
isOddNumber: () => isOddNumber2,
|
|
721
|
+
isPosInfinity: () => isPosInfinity2,
|
|
722
|
+
isString: () => isString2,
|
|
723
|
+
isStringOrUndefined: () => isStringOrUndefined2,
|
|
724
|
+
isThrowing: () => isThrowing2,
|
|
725
|
+
isTrue: () => isTrue2,
|
|
726
|
+
isTrueOrUndefined: () => isTrueOrUndefined2,
|
|
727
|
+
isTypedObject: () => isTypedObject2,
|
|
728
|
+
isUndefined: () => isUndefined2,
|
|
729
|
+
tryOr: () => tryOr
|
|
730
|
+
});
|
|
731
|
+
|
|
732
|
+
// src/utils/obj/index.ts
|
|
733
|
+
var obj_exports = {};
|
|
734
|
+
__export(obj_exports, {
|
|
735
|
+
deepEqual: () => deepEqual,
|
|
736
|
+
hasProperties: () => hasProperties,
|
|
737
|
+
isObject: () => isObject2
|
|
738
|
+
});
|
|
739
|
+
function hasProperties(obj, props) {
|
|
740
|
+
return isObject2(obj) && props.every((p) => p in obj);
|
|
741
|
+
}
|
|
742
|
+
function deepEqual(a, b) {
|
|
743
|
+
if (a === b) return true;
|
|
744
|
+
if (a === null || b === null) return false;
|
|
745
|
+
if (typeof a !== "object" || typeof b !== "object") return false;
|
|
746
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
747
|
+
if (a.length !== b.length) return false;
|
|
748
|
+
return a.every((val, i) => deepEqual(val, b[i]));
|
|
749
|
+
}
|
|
750
|
+
if (Array.isArray(a) !== Array.isArray(b)) return false;
|
|
751
|
+
const keysA = Object.keys(a);
|
|
752
|
+
const keysB = Object.keys(b);
|
|
753
|
+
if (keysA.length !== keysB.length) return false;
|
|
754
|
+
for (const key of keysA) {
|
|
755
|
+
if (!Object.prototype.hasOwnProperty.call(b, key)) return false;
|
|
756
|
+
if (!deepEqual(a[key], b[key])) return false;
|
|
757
|
+
}
|
|
758
|
+
return true;
|
|
759
|
+
}
|
|
82
760
|
|
|
83
761
|
// src/utils/enum/index.ts
|
|
84
762
|
var enum_exports = {};
|
|
85
763
|
__export(enum_exports, {
|
|
86
|
-
|
|
764
|
+
assertEnumValue: () => assertEnumValue,
|
|
765
|
+
forEachEnum: () => forEachEnum,
|
|
766
|
+
getEnumEntries: () => getEnumEntries,
|
|
767
|
+
getEnumKey: () => getEnumKey,
|
|
768
|
+
getEnumKeys: () => getEnumKeys,
|
|
769
|
+
getEnumValues: () => getEnumValues,
|
|
770
|
+
isEnumValue: () => isEnumValue2
|
|
87
771
|
});
|
|
772
|
+
function getEnumKeys(e) {
|
|
773
|
+
return Object.keys(e).filter((k) => isNaN(Number(k)));
|
|
774
|
+
}
|
|
88
775
|
function getEnumValues(e) {
|
|
89
|
-
return
|
|
776
|
+
return getEnumKeys(e).map((k) => e[k]);
|
|
777
|
+
}
|
|
778
|
+
function getEnumEntries(e) {
|
|
779
|
+
return getEnumKeys(e).map((k) => [k, e[k]]);
|
|
780
|
+
}
|
|
781
|
+
function getEnumKey(e, value) {
|
|
782
|
+
return getEnumKeys(e).find((k) => e[k] === value);
|
|
783
|
+
}
|
|
784
|
+
function forEachEnum(e, callback) {
|
|
785
|
+
for (const [k, v] of getEnumEntries(e)) callback(k, v);
|
|
786
|
+
}
|
|
787
|
+
function isEnumValue2(e, value) {
|
|
788
|
+
return getEnumValues(e).includes(value);
|
|
789
|
+
}
|
|
790
|
+
function assertEnumValue(e, value) {
|
|
791
|
+
if (!isEnumValue2(e, value)) {
|
|
792
|
+
throw new TypeError(`Invalid enum value: ${String(value)}`);
|
|
793
|
+
}
|
|
90
794
|
}
|
|
91
795
|
|
|
92
|
-
// src/
|
|
93
|
-
function
|
|
796
|
+
// src/guard/index.ts
|
|
797
|
+
function isEqual2(value1, value2) {
|
|
798
|
+
return value1 === value2;
|
|
799
|
+
}
|
|
800
|
+
function isDeepEqual2(value1, value2) {
|
|
801
|
+
return deepEqual(value1, value2);
|
|
802
|
+
}
|
|
803
|
+
function isUndefined2(value) {
|
|
94
804
|
return value === void 0;
|
|
95
805
|
}
|
|
96
|
-
function
|
|
806
|
+
function isNull2(value) {
|
|
97
807
|
return value === null;
|
|
98
808
|
}
|
|
99
|
-
function
|
|
809
|
+
function isNullish2(value) {
|
|
100
810
|
return value === void 0 || value === null;
|
|
101
811
|
}
|
|
102
|
-
function
|
|
103
|
-
return typeof value === "object" && value !== null && !
|
|
812
|
+
function isObject2(value) {
|
|
813
|
+
return typeof value === "object" && value !== null && !isArray2(value);
|
|
814
|
+
}
|
|
815
|
+
function isObjectOrUndefined2(value) {
|
|
816
|
+
return value === void 0 || isObject2(value);
|
|
104
817
|
}
|
|
105
|
-
function
|
|
106
|
-
return
|
|
818
|
+
function isTypedObject2(obj, keys) {
|
|
819
|
+
return isObject2(obj) && keys.every((k) => k in obj);
|
|
107
820
|
}
|
|
108
|
-
function
|
|
821
|
+
function isArray2(a) {
|
|
109
822
|
return !!a && Object.prototype.toString.call(a) === "[object Array]";
|
|
110
823
|
}
|
|
111
|
-
function
|
|
112
|
-
return value === void 0 ||
|
|
824
|
+
function isArrayOrUndefined2(value) {
|
|
825
|
+
return value === void 0 || isArray2(value);
|
|
113
826
|
}
|
|
114
|
-
function
|
|
115
|
-
return
|
|
827
|
+
function isEmptyArray2(a) {
|
|
828
|
+
return isArray2(a) && a.length === 0;
|
|
116
829
|
}
|
|
117
|
-
function
|
|
118
|
-
return
|
|
830
|
+
function isNonEmptyArray2(a) {
|
|
831
|
+
return isArray2(a) && a.length > 0;
|
|
119
832
|
}
|
|
120
|
-
function
|
|
121
|
-
return
|
|
833
|
+
function isEmptyArrayOrUndefined2(a) {
|
|
834
|
+
return isArray2(a) && a.length === 0 || a === void 0;
|
|
122
835
|
}
|
|
123
|
-
function
|
|
124
|
-
return
|
|
836
|
+
function isNonEmptyArrayOrUndefined2(a) {
|
|
837
|
+
return isArray2(a) && a.length > 0 || a === void 0;
|
|
125
838
|
}
|
|
126
|
-
function
|
|
839
|
+
function isString2(value) {
|
|
127
840
|
return typeof value === "string";
|
|
128
841
|
}
|
|
129
|
-
function
|
|
842
|
+
function isEmptyString2(value) {
|
|
130
843
|
return typeof value === "string" && value.length === 0;
|
|
131
844
|
}
|
|
132
|
-
function
|
|
845
|
+
function isNonEmptyString2(value) {
|
|
133
846
|
return typeof value === "string" && value.length > 0;
|
|
134
847
|
}
|
|
135
|
-
function
|
|
848
|
+
function isStringOrUndefined2(value) {
|
|
136
849
|
return value === void 0 || typeof value === "string";
|
|
137
850
|
}
|
|
138
|
-
function
|
|
851
|
+
function isEmptyStringOrUndefined2(value) {
|
|
139
852
|
return typeof value === "string" && value.length === 0 || value === void 0;
|
|
140
853
|
}
|
|
141
|
-
function
|
|
854
|
+
function isNonEmptyStringOrUndefined2(value) {
|
|
142
855
|
return typeof value === "string" && value.length > 0 || value === void 0;
|
|
143
856
|
}
|
|
144
|
-
function
|
|
857
|
+
function isBoolean2(value) {
|
|
145
858
|
return typeof value === "boolean";
|
|
146
859
|
}
|
|
147
|
-
function
|
|
860
|
+
function isBooleanOrUndefined2(value) {
|
|
148
861
|
return value === void 0 || typeof value === "boolean";
|
|
149
862
|
}
|
|
150
|
-
function
|
|
863
|
+
function isTrue2(value) {
|
|
864
|
+
return value === true;
|
|
865
|
+
}
|
|
866
|
+
function isTrueOrUndefined2(value) {
|
|
867
|
+
return value === true || value === void 0;
|
|
868
|
+
}
|
|
869
|
+
function isFalse2(value) {
|
|
870
|
+
return value === false;
|
|
871
|
+
}
|
|
872
|
+
function isFalseOrUndefined2(value) {
|
|
873
|
+
return value === false || value === void 0;
|
|
874
|
+
}
|
|
875
|
+
function isFunction2(value) {
|
|
151
876
|
return typeof value === "function";
|
|
152
877
|
}
|
|
153
|
-
function
|
|
878
|
+
function isFunctionOrUndefined2(value) {
|
|
154
879
|
return value === void 0 || typeof value === "function";
|
|
155
880
|
}
|
|
156
|
-
function
|
|
881
|
+
function isEnumValue3(value, enumObj, name = "value") {
|
|
157
882
|
return getEnumValues(enumObj).some((v) => v === value);
|
|
158
883
|
}
|
|
159
|
-
function
|
|
884
|
+
function isEnumValueOrUndefined2(value, enumObj, name = "value") {
|
|
160
885
|
return value === void 0 || getEnumValues(enumObj).some((v) => v === value);
|
|
161
886
|
}
|
|
162
|
-
function
|
|
887
|
+
function isNumber2(value) {
|
|
163
888
|
return typeof value === "number";
|
|
164
889
|
}
|
|
165
|
-
function
|
|
890
|
+
function isNumberOrUndefined2(value) {
|
|
166
891
|
return typeof value === "number" || value === void 0;
|
|
167
892
|
}
|
|
168
|
-
function
|
|
893
|
+
function isFinite3(value) {
|
|
169
894
|
return typeof value === "number" && Number.isFinite(value);
|
|
170
895
|
}
|
|
171
|
-
function
|
|
172
|
-
return typeof n === "number" &&
|
|
896
|
+
function isInteger2(n) {
|
|
897
|
+
return typeof n === "number" && isFinite3(n) && n === Math.trunc(n);
|
|
898
|
+
}
|
|
899
|
+
function isIntegerOrUndefined2(n) {
|
|
900
|
+
return typeof n === "number" && isFinite3(n) && n === Math.trunc(n) || n === void 0;
|
|
173
901
|
}
|
|
174
|
-
function
|
|
175
|
-
return
|
|
902
|
+
function isIntegerEq2(value, compareTo) {
|
|
903
|
+
return isInteger2(value) && value === compareTo;
|
|
176
904
|
}
|
|
177
|
-
function
|
|
178
|
-
return
|
|
905
|
+
function isIntegerGt2(value, compareTo) {
|
|
906
|
+
return isInteger2(value) && isNumber2(compareTo) && value > compareTo;
|
|
179
907
|
}
|
|
180
|
-
function
|
|
181
|
-
return
|
|
908
|
+
function isIntegerGte2(value, compareTo) {
|
|
909
|
+
return isInteger2(value) && isNumber2(compareTo) && value >= compareTo;
|
|
182
910
|
}
|
|
183
|
-
function
|
|
184
|
-
return
|
|
911
|
+
function isIntegerLt2(value, compareTo) {
|
|
912
|
+
return isInteger2(value) && isNumber2(compareTo) && value < compareTo;
|
|
185
913
|
}
|
|
186
|
-
function
|
|
187
|
-
return
|
|
914
|
+
function isIntegerLte2(value, compareTo) {
|
|
915
|
+
return isInteger2(value) && isNumber2(compareTo) && value <= compareTo;
|
|
188
916
|
}
|
|
189
|
-
function
|
|
190
|
-
return
|
|
917
|
+
function isIntegerBetween2(value, min, max) {
|
|
918
|
+
return isInteger2(value) && isNumber2(min) && isNumber2(max) && value >= min && value <= max;
|
|
191
919
|
}
|
|
192
|
-
function
|
|
193
|
-
return
|
|
920
|
+
function isIntegerBetweenExclusive2(value, min, max) {
|
|
921
|
+
return isInteger2(value) && isNumber2(min) && isNumber2(max) && value > min && value < max;
|
|
194
922
|
}
|
|
195
|
-
function
|
|
923
|
+
function isNumberBetween2(value, min, max) {
|
|
924
|
+
return isNumber2(value) && isNumber2(min) && isNumber2(max) && value >= min && value <= max;
|
|
925
|
+
}
|
|
926
|
+
function isNumberBetweenExclusive2(value, min, max) {
|
|
927
|
+
return isNumber2(value) && isNumber2(min) && isNumber2(max) && value > min && value < max;
|
|
928
|
+
}
|
|
929
|
+
function isNaNValue2(value) {
|
|
196
930
|
return typeof value === "number" && Number.isNaN(value);
|
|
197
931
|
}
|
|
198
|
-
function
|
|
932
|
+
function isInfinity2(value) {
|
|
199
933
|
return typeof value === "number" && Math.abs(value) === Infinity;
|
|
200
934
|
}
|
|
201
|
-
function
|
|
935
|
+
function isPosInfinity2(value) {
|
|
202
936
|
return typeof value === "number" && value === Infinity;
|
|
203
937
|
}
|
|
204
|
-
function
|
|
938
|
+
function isNegInfinity2(value) {
|
|
205
939
|
return typeof value === "number" && value === -Infinity;
|
|
206
940
|
}
|
|
941
|
+
function isOddNumber2(value) {
|
|
942
|
+
return isInteger2(value) && value % 2 === 1;
|
|
943
|
+
}
|
|
944
|
+
function isEvenNumber2(value) {
|
|
945
|
+
return isInteger2(value) && value % 2 === 0;
|
|
946
|
+
}
|
|
947
|
+
function isIncluded2(value, array) {
|
|
948
|
+
return array.includes(value);
|
|
949
|
+
}
|
|
950
|
+
function isArrayIndex2(index, array) {
|
|
951
|
+
return isInteger2(index) && isArray2(array) && index >= 0 && index < array.length;
|
|
952
|
+
}
|
|
953
|
+
function isThrowing2(throwTestFn) {
|
|
954
|
+
try {
|
|
955
|
+
throwTestFn();
|
|
956
|
+
return false;
|
|
957
|
+
} catch (err) {
|
|
958
|
+
return true;
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
function tryOr(tryFn, orVal) {
|
|
962
|
+
try {
|
|
963
|
+
return tryFn();
|
|
964
|
+
} catch (err) {
|
|
965
|
+
return isFunction2(orVal) ? orVal() : orVal;
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
|
|
969
|
+
// src/utils/index.ts
|
|
970
|
+
var utils_exports = {};
|
|
971
|
+
__export(utils_exports, {
|
|
972
|
+
Arr: () => arr_exports,
|
|
973
|
+
Dom: () => dom_exports,
|
|
974
|
+
Enum: () => enum_exports,
|
|
975
|
+
Is: () => Is,
|
|
976
|
+
Map: () => map_exports,
|
|
977
|
+
Math: () => math_exports,
|
|
978
|
+
Obj: () => obj_exports,
|
|
979
|
+
Str: () => str_exports
|
|
980
|
+
});
|
|
207
981
|
|
|
208
982
|
// src/utils/arr/index.ts
|
|
983
|
+
var arr_exports = {};
|
|
984
|
+
__export(arr_exports, {
|
|
985
|
+
arrayContains: () => arrayContains,
|
|
986
|
+
chunckArray: () => chunckArray,
|
|
987
|
+
duplicate: () => duplicate,
|
|
988
|
+
fillArray: () => fillArray,
|
|
989
|
+
getRangeArray: () => getRangeArray,
|
|
990
|
+
getSequenceArray: () => getSequenceArray,
|
|
991
|
+
isArray: () => isArray2,
|
|
992
|
+
mapRangeArray: () => mapRangeArray,
|
|
993
|
+
mapSequenceArray: () => mapSequenceArray,
|
|
994
|
+
removeDuplicates: () => removeDuplicates,
|
|
995
|
+
removeDuplicatesCmp: () => removeDuplicatesCmp,
|
|
996
|
+
toArray: () => toArray
|
|
997
|
+
});
|
|
209
998
|
function toArray(a) {
|
|
210
|
-
return
|
|
999
|
+
return isArray2(a) ? a : [a];
|
|
211
1000
|
}
|
|
212
1001
|
function duplicate(a) {
|
|
213
1002
|
return a === void 0 ? a : a.slice();
|
|
@@ -219,13 +1008,13 @@ function removeDuplicatesCmp(arr, cmp2) {
|
|
|
219
1008
|
return arr.filter((t1, index, self) => index === self.findIndex((t2) => cmp2(t1, t2)));
|
|
220
1009
|
}
|
|
221
1010
|
function fillArray(fillValue, fillCount) {
|
|
222
|
-
if (!
|
|
1011
|
+
if (!isInteger2(fillCount) || fillCount < 0) {
|
|
223
1012
|
throw new Error("fillArray: Invalid fillCount = " + fillCount);
|
|
224
1013
|
}
|
|
225
1014
|
return new Array(fillCount).fill(fillValue);
|
|
226
1015
|
}
|
|
227
1016
|
function mapSequenceArray(len, fn) {
|
|
228
|
-
if (!
|
|
1017
|
+
if (!isInteger2(len) || len < 0) {
|
|
229
1018
|
throw new Error("mapSequenceArray: Invalid len = " + len);
|
|
230
1019
|
}
|
|
231
1020
|
let arr = new Array(len);
|
|
@@ -238,10 +1027,10 @@ function getSequenceArray(len) {
|
|
|
238
1027
|
return mapSequenceArray(len, (i) => i);
|
|
239
1028
|
}
|
|
240
1029
|
function mapRangeArray(start, end, fn) {
|
|
241
|
-
if (!
|
|
1030
|
+
if (!isInteger2(start)) {
|
|
242
1031
|
throw new Error("mapRangeArray: Invalid start = " + end);
|
|
243
1032
|
}
|
|
244
|
-
if (!
|
|
1033
|
+
if (!isInteger2(end)) {
|
|
245
1034
|
throw new Error("mapRangeArray: Invalid end = " + end);
|
|
246
1035
|
}
|
|
247
1036
|
let len = Math.abs(end - start) + 1;
|
|
@@ -258,7 +1047,7 @@ function arrayContains(arg, item) {
|
|
|
258
1047
|
return arg.indexOf(item) >= 0;
|
|
259
1048
|
}
|
|
260
1049
|
function chunckArray(arr, chunckSize) {
|
|
261
|
-
if (!
|
|
1050
|
+
if (!isInteger2(chunckSize) || chunckSize < 1) {
|
|
262
1051
|
throw new Error("chunckArray: Invalid chunckSize = " + chunckSize);
|
|
263
1052
|
}
|
|
264
1053
|
let result = [];
|
|
@@ -291,261 +1080,8 @@ __export(dom_exports, {
|
|
|
291
1080
|
setWidth: () => setWidth,
|
|
292
1081
|
styleLayoutChanged: () => styleLayoutChanged
|
|
293
1082
|
});
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
var Assert;
|
|
297
|
-
((Assert2) => {
|
|
298
|
-
let errorConstructor = Error;
|
|
299
|
-
function setErrorClass(ec) {
|
|
300
|
-
errorConstructor = ec ?? Error;
|
|
301
|
-
}
|
|
302
|
-
Assert2.setErrorClass = setErrorClass;
|
|
303
|
-
function throwError(errorMsg, userMsg) {
|
|
304
|
-
throw new errorConstructor("Assertion Error: " + errorMsg + (userMsg ? " " + userMsg : ""));
|
|
305
|
-
}
|
|
306
|
-
function is_int(a) {
|
|
307
|
-
return typeof a === "number" && isFinite(a) && a === Math.trunc(a);
|
|
308
|
-
}
|
|
309
|
-
function is_number(a) {
|
|
310
|
-
return typeof a === "number";
|
|
311
|
-
}
|
|
312
|
-
function assert(a, userMsg) {
|
|
313
|
-
if (!a) {
|
|
314
|
-
throwError(userMsg ?? "Assertion failed!");
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
Assert2.assert = assert;
|
|
318
|
-
function assertEnum(value, enumObj, name = "value") {
|
|
319
|
-
if (!getEnumValues(enumObj).some((v) => v === value)) {
|
|
320
|
-
throw new TypeError(`Invalid ${name} enum value: ${value}`);
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
Assert2.assertEnum = assertEnum;
|
|
324
|
-
function interrupt(userMsg) {
|
|
325
|
-
throwError(userMsg ?? "Interrupted!");
|
|
326
|
-
}
|
|
327
|
-
Assert2.interrupt = interrupt;
|
|
328
|
-
function int(a, userMsg) {
|
|
329
|
-
if (!is_int(a)) {
|
|
330
|
-
throwError(`Expected ${a} to be integer.`, userMsg);
|
|
331
|
-
}
|
|
332
|
-
return a;
|
|
333
|
-
}
|
|
334
|
-
Assert2.int = int;
|
|
335
|
-
function eq(a, b, userMsg) {
|
|
336
|
-
if (a !== b) {
|
|
337
|
-
throwError(`Expected ${a} to equal ${b}.`, userMsg);
|
|
338
|
-
}
|
|
339
|
-
return a;
|
|
340
|
-
}
|
|
341
|
-
Assert2.eq = eq;
|
|
342
|
-
function int_eq(a, b, userMsg) {
|
|
343
|
-
if (!(is_int(a) && is_number(b) && a === b)) {
|
|
344
|
-
throwError(`Expected ${a} to be integer equal to ${b}.`, userMsg);
|
|
345
|
-
}
|
|
346
|
-
return a;
|
|
347
|
-
}
|
|
348
|
-
Assert2.int_eq = int_eq;
|
|
349
|
-
function int_lt(a, b, userMsg) {
|
|
350
|
-
if (!(is_int(a) && is_number(b) && a < b)) {
|
|
351
|
-
throwError(`Expected ${a} to be integer less than ${b}.`, userMsg);
|
|
352
|
-
}
|
|
353
|
-
return a;
|
|
354
|
-
}
|
|
355
|
-
Assert2.int_lt = int_lt;
|
|
356
|
-
function int_lte(a, b, userMsg) {
|
|
357
|
-
if (!(is_int(a) && is_number(b) && a <= b)) {
|
|
358
|
-
throwError(`Expected ${a} to be integer less than or equal to ${b}.`, userMsg);
|
|
359
|
-
}
|
|
360
|
-
return a;
|
|
361
|
-
}
|
|
362
|
-
Assert2.int_lte = int_lte;
|
|
363
|
-
function int_gt(a, b, userMsg) {
|
|
364
|
-
if (!(is_int(a) && is_number(b) && a > b)) {
|
|
365
|
-
throwError(`Expected ${a} to be integer greater than ${b}.`, userMsg);
|
|
366
|
-
}
|
|
367
|
-
return a;
|
|
368
|
-
}
|
|
369
|
-
Assert2.int_gt = int_gt;
|
|
370
|
-
function int_gte(a, b, userMsg) {
|
|
371
|
-
if (!(is_int(a) && is_number(b) && a >= b)) {
|
|
372
|
-
throwError(`Expected ${a} to be integer greater than or equal to ${b}.`, userMsg);
|
|
373
|
-
}
|
|
374
|
-
return a;
|
|
375
|
-
}
|
|
376
|
-
Assert2.int_gte = int_gte;
|
|
377
|
-
function int_between(a, min, max, userMsg) {
|
|
378
|
-
if (!(is_int(a) && is_number(min) && is_number(max) && a >= min && a <= max)) {
|
|
379
|
-
throwError(`Expected ${a} to be integer between ${min} and ${max}.`, userMsg);
|
|
380
|
-
}
|
|
381
|
-
return a;
|
|
382
|
-
}
|
|
383
|
-
Assert2.int_between = int_between;
|
|
384
|
-
function odd(a, userMsg) {
|
|
385
|
-
if (!(is_int(a) && a % 2 === 1)) {
|
|
386
|
-
throwError(`Expected ${a} to be odd number.`, userMsg);
|
|
387
|
-
}
|
|
388
|
-
return a;
|
|
389
|
-
}
|
|
390
|
-
Assert2.odd = odd;
|
|
391
|
-
function even(a, userMsg) {
|
|
392
|
-
if (!(is_int(a) && a % 2 === 0)) {
|
|
393
|
-
throwError(`Expected ${a} to be even number.`, userMsg);
|
|
394
|
-
}
|
|
395
|
-
return a;
|
|
396
|
-
}
|
|
397
|
-
Assert2.even = even;
|
|
398
|
-
function in_group(a, group, userMsg) {
|
|
399
|
-
if (!group.some((e) => e === a)) {
|
|
400
|
-
let strGroup = group.map((v) => String(v)).join(", ");
|
|
401
|
-
throwError(`Expected ${a} to be in group [${strGroup}].`, userMsg);
|
|
402
|
-
}
|
|
403
|
-
return a;
|
|
404
|
-
}
|
|
405
|
-
Assert2.in_group = in_group;
|
|
406
|
-
function finite(a, userMsg) {
|
|
407
|
-
if (!(is_number(a) && isFinite(a))) {
|
|
408
|
-
throwError(`Expected ${a} to be finite number.`, userMsg);
|
|
409
|
-
}
|
|
410
|
-
return a;
|
|
411
|
-
}
|
|
412
|
-
Assert2.finite = finite;
|
|
413
|
-
function array_id(arr, id, userMsg) {
|
|
414
|
-
if (!(is_int(id) && id >= 0 && id < arr.length)) {
|
|
415
|
-
throwError(`Expected ${id} to be array index in bounds [0..${arr.length - 1}].`, userMsg);
|
|
416
|
-
}
|
|
417
|
-
return id;
|
|
418
|
-
}
|
|
419
|
-
Assert2.array_id = array_id;
|
|
420
|
-
function array_elem(arr, id, userMsg) {
|
|
421
|
-
return arr[array_id(arr, id, userMsg)];
|
|
422
|
-
}
|
|
423
|
-
Assert2.array_elem = array_elem;
|
|
424
|
-
function require2(arg, userMsg) {
|
|
425
|
-
if (arg === void 0) {
|
|
426
|
-
throwError("Required value is undefined.", userMsg);
|
|
427
|
-
} else {
|
|
428
|
-
return arg;
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
Assert2.require = require2;
|
|
432
|
-
})(Assert || (Assert = {}));
|
|
433
|
-
|
|
434
|
-
// src/modules/device.ts
|
|
435
|
-
var Device;
|
|
436
|
-
((Device2) => {
|
|
437
|
-
function getDPI() {
|
|
438
|
-
let el = document.createElement("div");
|
|
439
|
-
el.style.width = "1in";
|
|
440
|
-
document.body.appendChild(el);
|
|
441
|
-
let dpi = el.offsetWidth;
|
|
442
|
-
el.remove();
|
|
443
|
-
return dpi || 96;
|
|
444
|
-
}
|
|
445
|
-
function getScrollBarWidth() {
|
|
446
|
-
try {
|
|
447
|
-
let outer = document.createElement("div");
|
|
448
|
-
outer.style.visibility = "hidden";
|
|
449
|
-
outer.style.width = "100px";
|
|
450
|
-
document.body.appendChild(outer);
|
|
451
|
-
let widthNoScroll = outer.offsetWidth;
|
|
452
|
-
outer.style.overflow = "scroll";
|
|
453
|
-
let inner = document.createElement("div");
|
|
454
|
-
inner.style.width = "100%";
|
|
455
|
-
outer.appendChild(inner);
|
|
456
|
-
let widthWithScroll = inner.offsetWidth;
|
|
457
|
-
if (outer.parentNode) {
|
|
458
|
-
outer.parentNode.removeChild(outer);
|
|
459
|
-
}
|
|
460
|
-
return widthNoScroll - widthWithScroll;
|
|
461
|
-
} catch (e) {
|
|
462
|
-
return 0;
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
function getSystemFontSize() {
|
|
466
|
-
let tmpDiv = document.createElement("div");
|
|
467
|
-
tmpDiv.style.cssText = "display:inline-block; padding:0; line-height:1; position:absolute; visibility:hidden; font-size:1em";
|
|
468
|
-
tmpDiv.appendChild(document.createTextNode("M"));
|
|
469
|
-
document.body.appendChild(tmpDiv);
|
|
470
|
-
let fontsize = tmpDiv.offsetHeight;
|
|
471
|
-
document.body.removeChild(tmpDiv);
|
|
472
|
-
return fontsize;
|
|
473
|
-
}
|
|
474
|
-
function getIsTouchDevice() {
|
|
475
|
-
if ("ontouchstart" in window || "DocumentTouch" in window || "createTouch" in document && "createTouchList" in document) {
|
|
476
|
-
return true;
|
|
477
|
-
}
|
|
478
|
-
var prefixes = " -webkit- -moz- -o- -ms- ".split(" ");
|
|
479
|
-
var mq = function(query2) {
|
|
480
|
-
return window.matchMedia(query2).matches;
|
|
481
|
-
};
|
|
482
|
-
var query = ["(", prefixes.join("touch-enabled),("), "heartz", ")"].join("");
|
|
483
|
-
return mq(query);
|
|
484
|
-
}
|
|
485
|
-
function getIsMobileDevice() {
|
|
486
|
-
let a = navigator.userAgent || navigator.vendor || window.opera;
|
|
487
|
-
return /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4));
|
|
488
|
-
}
|
|
489
|
-
function getHostAddress() {
|
|
490
|
-
return location.protocol + "//" + location.host;
|
|
491
|
-
}
|
|
492
|
-
const UnitRegExp = /^(mm|cm|in|inch|px|em)$/;
|
|
493
|
-
const ValueUnitRegExp = /^([0-9\\.]+)(.*)$/;
|
|
494
|
-
Device2.DPI = getDPI();
|
|
495
|
-
Device2.PxPerMm = Device2.DPI / 25.4;
|
|
496
|
-
Device2.ScrollbarWidth = getScrollBarWidth();
|
|
497
|
-
Device2.FontSize = getSystemFontSize();
|
|
498
|
-
Device2.IsTouchDevice = getIsTouchDevice();
|
|
499
|
-
Device2.IsMobileDevice = getIsMobileDevice();
|
|
500
|
-
Device2.HostAddress = getHostAddress();
|
|
501
|
-
function pxToMm(px) {
|
|
502
|
-
return px / Device2.PxPerMm;
|
|
503
|
-
}
|
|
504
|
-
Device2.pxToMm = pxToMm;
|
|
505
|
-
function mmToPx(mm) {
|
|
506
|
-
return mm * Device2.PxPerMm;
|
|
507
|
-
}
|
|
508
|
-
Device2.mmToPx = mmToPx;
|
|
509
|
-
function toPx2(input) {
|
|
510
|
-
if (typeof input === "number") {
|
|
511
|
-
return input;
|
|
512
|
-
}
|
|
513
|
-
let value = NaN;
|
|
514
|
-
let unit = void 0;
|
|
515
|
-
let match = input.toString().match(ValueUnitRegExp);
|
|
516
|
-
if (match && match[1]) {
|
|
517
|
-
value = parseFloat(match[1]);
|
|
518
|
-
let unitStr = match[2] ? match[2].toLowerCase() : "undefined";
|
|
519
|
-
let unitStrOk = UnitRegExp.test(unitStr);
|
|
520
|
-
unit = unitStrOk ? unitStr : void 0;
|
|
521
|
-
if (!unit) {
|
|
522
|
-
console.log("Unknown unit '" + unitStr + "' => using 'px'.");
|
|
523
|
-
}
|
|
524
|
-
} else {
|
|
525
|
-
value = parseFloat(input);
|
|
526
|
-
}
|
|
527
|
-
Assert.finite(value, "value in function toPx");
|
|
528
|
-
switch (unit) {
|
|
529
|
-
case "mm":
|
|
530
|
-
return mmToPx(value);
|
|
531
|
-
case "cm":
|
|
532
|
-
return mmToPx(value) * 10;
|
|
533
|
-
case "in":
|
|
534
|
-
case "inch":
|
|
535
|
-
return mmToPx(value) * 25.4;
|
|
536
|
-
case "em":
|
|
537
|
-
return Device2.FontSize * value;
|
|
538
|
-
default:
|
|
539
|
-
case "px":
|
|
540
|
-
return value;
|
|
541
|
-
}
|
|
542
|
-
}
|
|
543
|
-
Device2.toPx = toPx2;
|
|
544
|
-
})(Device || (Device = {}));
|
|
545
|
-
|
|
546
|
-
// src/utils/dom/index.ts
|
|
547
|
-
function toPx(value) {
|
|
548
|
-
return value === void 0 ? void 0 : Device.toPx(value);
|
|
1083
|
+
function toPx2(value) {
|
|
1084
|
+
return value === void 0 ? void 0 : device_exports.toPx(value);
|
|
549
1085
|
}
|
|
550
1086
|
function hasClass(el, className) {
|
|
551
1087
|
if (className.length === 0) {
|
|
@@ -636,38 +1172,38 @@ function getPadding(style) {
|
|
|
636
1172
|
if (!style) {
|
|
637
1173
|
return { top: 0, right: 0, bottom: 0, left: 0 };
|
|
638
1174
|
}
|
|
639
|
-
let top =
|
|
640
|
-
let right =
|
|
641
|
-
let bottom =
|
|
642
|
-
let left =
|
|
1175
|
+
let top = toPx2(style.paddingTop);
|
|
1176
|
+
let right = toPx2(style.paddingRight);
|
|
1177
|
+
let bottom = toPx2(style.paddingBottom);
|
|
1178
|
+
let left = toPx2(style.paddingLeft);
|
|
643
1179
|
let padding = (style.padding ?? "").toString().split(" ").filter((s) => s.length > 0);
|
|
644
1180
|
switch (padding.length) {
|
|
645
1181
|
case 0:
|
|
646
1182
|
break;
|
|
647
1183
|
case 1:
|
|
648
|
-
top ?? (top =
|
|
649
|
-
right ?? (right =
|
|
650
|
-
bottom ?? (bottom =
|
|
651
|
-
left ?? (left =
|
|
1184
|
+
top ?? (top = toPx2(padding[0]));
|
|
1185
|
+
right ?? (right = toPx2(padding[0]));
|
|
1186
|
+
bottom ?? (bottom = toPx2(padding[0]));
|
|
1187
|
+
left ?? (left = toPx2(padding[0]));
|
|
652
1188
|
break;
|
|
653
1189
|
case 2:
|
|
654
|
-
top ?? (top =
|
|
655
|
-
right ?? (right =
|
|
656
|
-
bottom ?? (bottom =
|
|
657
|
-
left ?? (left =
|
|
1190
|
+
top ?? (top = toPx2(padding[0]));
|
|
1191
|
+
right ?? (right = toPx2(padding[1]));
|
|
1192
|
+
bottom ?? (bottom = toPx2(padding[0]));
|
|
1193
|
+
left ?? (left = toPx2(padding[1]));
|
|
658
1194
|
break;
|
|
659
1195
|
case 3:
|
|
660
|
-
top ?? (top =
|
|
661
|
-
right ?? (right =
|
|
662
|
-
bottom ?? (bottom =
|
|
663
|
-
left ?? (left =
|
|
1196
|
+
top ?? (top = toPx2(padding[0]));
|
|
1197
|
+
right ?? (right = toPx2(padding[1]));
|
|
1198
|
+
bottom ?? (bottom = toPx2(padding[2]));
|
|
1199
|
+
left ?? (left = toPx2(padding[1]));
|
|
664
1200
|
break;
|
|
665
1201
|
case 4:
|
|
666
1202
|
default:
|
|
667
|
-
top ?? (top =
|
|
668
|
-
right ?? (right =
|
|
669
|
-
bottom ?? (bottom =
|
|
670
|
-
left ?? (left =
|
|
1203
|
+
top ?? (top = toPx2(padding[0]));
|
|
1204
|
+
right ?? (right = toPx2(padding[1]));
|
|
1205
|
+
bottom ?? (bottom = toPx2(padding[2]));
|
|
1206
|
+
left ?? (left = toPx2(padding[3]));
|
|
671
1207
|
break;
|
|
672
1208
|
}
|
|
673
1209
|
top ?? (top = 0);
|
|
@@ -677,12 +1213,12 @@ function getPadding(style) {
|
|
|
677
1213
|
return { top, right, bottom, left };
|
|
678
1214
|
}
|
|
679
1215
|
function getDimension(style) {
|
|
680
|
-
let left =
|
|
681
|
-
let right =
|
|
682
|
-
let top =
|
|
683
|
-
let bottom =
|
|
684
|
-
let width =
|
|
685
|
-
let height =
|
|
1216
|
+
let left = toPx2(style?.left);
|
|
1217
|
+
let right = toPx2(style?.right);
|
|
1218
|
+
let top = toPx2(style?.top);
|
|
1219
|
+
let bottom = toPx2(style?.bottom);
|
|
1220
|
+
let width = toPx2(style?.width);
|
|
1221
|
+
let height = toPx2(style?.height);
|
|
686
1222
|
if (width === void 0 && left !== void 0 && right !== void 0) {
|
|
687
1223
|
width = right - left;
|
|
688
1224
|
}
|
|
@@ -717,9 +1253,7 @@ __export(map_exports, {
|
|
|
717
1253
|
getMapKeys: () => getMapKeys
|
|
718
1254
|
});
|
|
719
1255
|
function getMapKeys(map) {
|
|
720
|
-
|
|
721
|
-
map.forEach((value, key) => keys.push(key));
|
|
722
|
-
return keys;
|
|
1256
|
+
return [...map.keys()];
|
|
723
1257
|
}
|
|
724
1258
|
|
|
725
1259
|
// src/utils/math/index.ts
|
|
@@ -731,8 +1265,8 @@ __export(math_exports, {
|
|
|
731
1265
|
cmp: () => cmp,
|
|
732
1266
|
interpolateCoord: () => interpolateCoord,
|
|
733
1267
|
interpolateY: () => interpolateY,
|
|
734
|
-
isInteger: () =>
|
|
735
|
-
isNumber: () =>
|
|
1268
|
+
isInteger: () => isInteger2,
|
|
1269
|
+
isNumber: () => isNumber2,
|
|
736
1270
|
linearToDecibels: () => linearToDecibels,
|
|
737
1271
|
mod: () => mod,
|
|
738
1272
|
romanize: () => romanize,
|
|
@@ -752,7 +1286,7 @@ function mod(m, n) {
|
|
|
752
1286
|
return (m % n + n) % n;
|
|
753
1287
|
}
|
|
754
1288
|
function romanize(n) {
|
|
755
|
-
if (!
|
|
1289
|
+
if (!isInteger2(n) || n < 0) {
|
|
756
1290
|
throw new Error("romanize: Invalid n = " + n);
|
|
757
1291
|
}
|
|
758
1292
|
var digits = String(+n).split("");
|
|
@@ -793,7 +1327,7 @@ function romanize(n) {
|
|
|
793
1327
|
return Array(+digits.join("") + 1).join("M") + roman;
|
|
794
1328
|
}
|
|
795
1329
|
function toOrdinalNumber(n) {
|
|
796
|
-
if (!
|
|
1330
|
+
if (!isInteger2(n)) {
|
|
797
1331
|
throw new Error("toOrdinalNumber: Invalid n = " + n);
|
|
798
1332
|
}
|
|
799
1333
|
const nStr = n.toString();
|
|
@@ -846,87 +1380,58 @@ function cmp(a, b) {
|
|
|
846
1380
|
return a < b ? -1 : a > b ? 1 : 0;
|
|
847
1381
|
}
|
|
848
1382
|
|
|
849
|
-
// src/utils/obj/index.ts
|
|
850
|
-
var obj_exports = {};
|
|
851
|
-
__export(obj_exports, {
|
|
852
|
-
deepEqual: () => deepEqual,
|
|
853
|
-
hasProperties: () => hasProperties,
|
|
854
|
-
isObject: () => isObject
|
|
855
|
-
});
|
|
856
|
-
function hasProperties(obj, props) {
|
|
857
|
-
return isObject(obj) && props.every((p) => p in obj);
|
|
858
|
-
}
|
|
859
|
-
function deepEqual(a, b) {
|
|
860
|
-
if (a === b) return true;
|
|
861
|
-
if (a === null || b === null) return false;
|
|
862
|
-
if (typeof a !== "object" || typeof b !== "object") return false;
|
|
863
|
-
if (Array.isArray(a) && Array.isArray(b)) {
|
|
864
|
-
if (a.length !== b.length) return false;
|
|
865
|
-
return a.every((val, i) => deepEqual(val, b[i]));
|
|
866
|
-
}
|
|
867
|
-
if (Array.isArray(a) !== Array.isArray(b)) return false;
|
|
868
|
-
const keysA = Object.keys(a);
|
|
869
|
-
const keysB = Object.keys(b);
|
|
870
|
-
if (keysA.length !== keysB.length) return false;
|
|
871
|
-
for (const key of keysA) {
|
|
872
|
-
if (!Object.prototype.hasOwnProperty.call(b, key)) return false;
|
|
873
|
-
if (!deepEqual(a[key], b[key])) return false;
|
|
874
|
-
}
|
|
875
|
-
return true;
|
|
876
|
-
}
|
|
877
|
-
|
|
878
1383
|
// src/utils/str/index.ts
|
|
879
1384
|
var str_exports = {};
|
|
880
1385
|
__export(str_exports, {
|
|
881
1386
|
charCount: () => charCount,
|
|
882
1387
|
chunkString: () => chunkString,
|
|
883
1388
|
insertAt: () => insertAt,
|
|
884
|
-
isString: () =>
|
|
1389
|
+
isString: () => isString2,
|
|
885
1390
|
makeSentenceFromPascal: () => makeSentenceFromPascal,
|
|
886
1391
|
removeAt: () => removeAt,
|
|
887
1392
|
repeatString: () => repeatString,
|
|
888
1393
|
replaceAt: () => replaceAt,
|
|
889
1394
|
toCharArray: () => toCharArray
|
|
890
1395
|
});
|
|
891
|
-
function toCharArray(
|
|
892
|
-
return
|
|
1396
|
+
function toCharArray(str2) {
|
|
1397
|
+
return str2.split("");
|
|
893
1398
|
}
|
|
894
1399
|
function repeatString(repeatString2, repeatCount) {
|
|
895
|
-
if (!
|
|
1400
|
+
if (!isInteger2(repeatCount) || repeatCount < 0) {
|
|
896
1401
|
throw new Error("repeatStr: Invalid repeatCount = " + repeatCount);
|
|
897
1402
|
}
|
|
898
1403
|
return new Array(repeatCount + 1).join(repeatString2);
|
|
899
1404
|
}
|
|
900
|
-
function chunkString(
|
|
901
|
-
if (!
|
|
1405
|
+
function chunkString(str2, chunkSize) {
|
|
1406
|
+
if (!isInteger2(chunkSize) || chunkSize < 1) {
|
|
902
1407
|
throw new Error("chunckString: Invalid chuckSize = " + chunkSize);
|
|
903
1408
|
}
|
|
904
1409
|
let result = [];
|
|
905
|
-
for (let i = 0; i <
|
|
906
|
-
result.push(
|
|
1410
|
+
for (let i = 0; i < str2.length; i += chunkSize) {
|
|
1411
|
+
result.push(str2.slice(i, i + chunkSize));
|
|
907
1412
|
}
|
|
908
1413
|
return result;
|
|
909
1414
|
}
|
|
910
|
-
function replaceAt(
|
|
911
|
-
if (!
|
|
1415
|
+
function replaceAt(str2, pos, removeCount, insert) {
|
|
1416
|
+
if (!isInteger2(removeCount) || removeCount < 0) {
|
|
912
1417
|
throw new Error("replaceAt: Invalid removeCount = " + removeCount);
|
|
913
|
-
} else if (!
|
|
914
|
-
throw new Error("replaceAt: Invalid pos = " + pos + ", removeCount = " + removeCount + ", str.length = " +
|
|
1418
|
+
} else if (!isInteger2(pos) || pos < 0 || pos + removeCount > str2.length) {
|
|
1419
|
+
throw new Error("replaceAt: Invalid pos = " + pos + ", removeCount = " + removeCount + ", str.length = " + str2.length);
|
|
915
1420
|
} else {
|
|
916
|
-
return
|
|
1421
|
+
return str2.substring(0, pos) + insert + str2.substring(pos + removeCount);
|
|
917
1422
|
}
|
|
918
1423
|
}
|
|
919
|
-
function insertAt(
|
|
920
|
-
return replaceAt(
|
|
1424
|
+
function insertAt(str2, pos, insertStr) {
|
|
1425
|
+
return replaceAt(str2, pos, 0, insertStr);
|
|
921
1426
|
}
|
|
922
|
-
function removeAt(
|
|
923
|
-
return replaceAt(
|
|
1427
|
+
function removeAt(str2, pos, removeCount) {
|
|
1428
|
+
return replaceAt(str2, pos, removeCount, "");
|
|
924
1429
|
}
|
|
925
|
-
function charCount(
|
|
926
|
-
if (ch.length !== 1 ||
|
|
1430
|
+
function charCount(str2, ch) {
|
|
1431
|
+
if (ch.length !== 1 || str2.length === 0) return 0;
|
|
927
1432
|
let count = 0;
|
|
928
|
-
for (let i = 0; i <
|
|
929
|
-
if (
|
|
1433
|
+
for (let i = 0; i < str2.length; i++) {
|
|
1434
|
+
if (str2[i] === ch) count++;
|
|
930
1435
|
}
|
|
931
1436
|
return count;
|
|
932
1437
|
}
|
|
@@ -956,155 +1461,488 @@ function makeSentenceFromPascal(PascalString) {
|
|
|
956
1461
|
}
|
|
957
1462
|
word += c.toLowerCase();
|
|
958
1463
|
}
|
|
959
|
-
addWord();
|
|
960
|
-
return sentence;
|
|
961
|
-
}
|
|
962
|
-
|
|
963
|
-
// src/
|
|
964
|
-
var
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
(
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1464
|
+
addWord();
|
|
1465
|
+
return sentence;
|
|
1466
|
+
}
|
|
1467
|
+
|
|
1468
|
+
// src/utils/index.ts
|
|
1469
|
+
var Is = guard_exports;
|
|
1470
|
+
|
|
1471
|
+
// src/core/stack.ts
|
|
1472
|
+
var Stack = class {
|
|
1473
|
+
constructor() {
|
|
1474
|
+
__publicField(this, "list", []);
|
|
1475
|
+
}
|
|
1476
|
+
push(e) {
|
|
1477
|
+
this.list.push(e);
|
|
1478
|
+
return e;
|
|
1479
|
+
}
|
|
1480
|
+
pop() {
|
|
1481
|
+
assert_exports.int_gt(this.list.length, 0);
|
|
1482
|
+
return this.list.pop();
|
|
1483
|
+
}
|
|
1484
|
+
top() {
|
|
1485
|
+
return assert_exports.array_elem(this.list, this.list.length - 1, "Stack is empty!");
|
|
1486
|
+
}
|
|
1487
|
+
toArray() {
|
|
1488
|
+
return this.list;
|
|
1489
|
+
}
|
|
1490
|
+
get length() {
|
|
1491
|
+
return this.list.length;
|
|
1492
|
+
}
|
|
1493
|
+
clear() {
|
|
1494
|
+
this.list.length = 0;
|
|
1495
|
+
}
|
|
1496
|
+
};
|
|
1497
|
+
|
|
1498
|
+
// src/core/vec.ts
|
|
1499
|
+
var Vec = class _Vec {
|
|
1500
|
+
constructor(...coords) {
|
|
1501
|
+
__publicField(this, "coords");
|
|
1502
|
+
if (coords.length < 2) {
|
|
1503
|
+
throw new TypeError("Vec needs minumum two coords!");
|
|
1504
|
+
}
|
|
1505
|
+
this.coords = coords;
|
|
1506
|
+
}
|
|
1507
|
+
static vec2(x, y) {
|
|
1508
|
+
return new _Vec(x, y);
|
|
1509
|
+
}
|
|
1510
|
+
static vec3(x, y, z) {
|
|
1511
|
+
return new _Vec(x, y, z);
|
|
1512
|
+
}
|
|
1513
|
+
static zero(dim) {
|
|
1514
|
+
if (dim < 2) {
|
|
1515
|
+
throw new TypeError("Vec.zero requires dimension >= 2");
|
|
1516
|
+
}
|
|
1517
|
+
return new _Vec(...Array(dim).fill(0));
|
|
1518
|
+
}
|
|
1519
|
+
get dim() {
|
|
1520
|
+
return this.coords.length;
|
|
1521
|
+
}
|
|
1522
|
+
get length() {
|
|
1523
|
+
return Math.hypot(...this.coords);
|
|
1524
|
+
}
|
|
1525
|
+
magnitude() {
|
|
1526
|
+
return this.length;
|
|
1006
1527
|
}
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
return str2 === void 0 ? defaultValue : str2.substring(name.length + 1);
|
|
1528
|
+
get x() {
|
|
1529
|
+
return this.coords[0];
|
|
1010
1530
|
}
|
|
1011
|
-
|
|
1012
|
-
|
|
1531
|
+
get y() {
|
|
1532
|
+
return this.coords[1];
|
|
1013
1533
|
}
|
|
1014
|
-
|
|
1015
|
-
if (
|
|
1016
|
-
|
|
1534
|
+
get z() {
|
|
1535
|
+
if (this.coords[2] === void 0) {
|
|
1536
|
+
throw new TypeError("Vec z-coord not available!");
|
|
1017
1537
|
}
|
|
1018
|
-
return
|
|
1538
|
+
return this.coords[2];
|
|
1019
1539
|
}
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
if (
|
|
1023
|
-
|
|
1024
|
-
} else {
|
|
1025
|
-
return defaultValue;
|
|
1540
|
+
add(...args) {
|
|
1541
|
+
const otherCoords = args[0] instanceof _Vec ? args[0].coords : args;
|
|
1542
|
+
if (this.coords.length !== otherCoords.length) {
|
|
1543
|
+
throw new TypeError("Coordinate length mismatch!");
|
|
1026
1544
|
}
|
|
1545
|
+
return new _Vec(...this.coords.map((coord, i) => coord + otherCoords[i]));
|
|
1027
1546
|
}
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
if (
|
|
1031
|
-
|
|
1032
|
-
return str2 === void 0 ? defaultValue : parseInt(str2);
|
|
1033
|
-
} else {
|
|
1034
|
-
return defaultValue;
|
|
1547
|
+
sub(...args) {
|
|
1548
|
+
const otherCoords = args[0] instanceof _Vec ? args[0].coords : args;
|
|
1549
|
+
if (this.coords.length !== otherCoords.length) {
|
|
1550
|
+
throw new TypeError("Coordinate length mismatch!");
|
|
1035
1551
|
}
|
|
1552
|
+
return new _Vec(...this.coords.map((coord, i) => coord - otherCoords[i]));
|
|
1036
1553
|
}
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1554
|
+
mul(scalar) {
|
|
1555
|
+
return new _Vec(...this.coords.map((coord) => coord * scalar));
|
|
1556
|
+
}
|
|
1557
|
+
div(scalar) {
|
|
1558
|
+
return new _Vec(...this.coords.map((coord) => coord / scalar));
|
|
1559
|
+
}
|
|
1560
|
+
dot(other) {
|
|
1561
|
+
if (this.coords.length !== other.coords.length) {
|
|
1562
|
+
throw new TypeError("Coordinate length mismatch!");
|
|
1044
1563
|
}
|
|
1564
|
+
return this.coords.reduce((sum2, c, i) => sum2 + c * other.coords[i], 0);
|
|
1045
1565
|
}
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
_erase(name);
|
|
1566
|
+
distance(other) {
|
|
1567
|
+
if (this.coords.length !== other.coords.length) {
|
|
1568
|
+
throw new TypeError("Coordinate length mismatch!");
|
|
1050
1569
|
}
|
|
1570
|
+
return Math.hypot(...this.coords.map((c, i) => c - other.coords[i]));
|
|
1051
1571
|
}
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1572
|
+
normalize() {
|
|
1573
|
+
const len = this.length;
|
|
1574
|
+
if (len === 0) {
|
|
1575
|
+
throw new TypeError("Cannot normalize zero-length vector!");
|
|
1576
|
+
}
|
|
1577
|
+
return this.div(len);
|
|
1055
1578
|
}
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1579
|
+
static lerp(a, b, t) {
|
|
1580
|
+
if (a.coords.length !== b.coords.length) {
|
|
1581
|
+
throw new TypeError("Coordinate length mismatch!");
|
|
1582
|
+
}
|
|
1583
|
+
if (!isFinite3(t)) {
|
|
1584
|
+
throw new TypeError("Lerp t is not finite!");
|
|
1585
|
+
}
|
|
1586
|
+
return a.add(b.sub(a).mul(t));
|
|
1063
1587
|
}
|
|
1064
|
-
|
|
1065
|
-
this.
|
|
1066
|
-
return
|
|
1588
|
+
toLength(len) {
|
|
1589
|
+
const mag = this.length;
|
|
1590
|
+
return mag === 0 ? this : this.mul(len / mag);
|
|
1067
1591
|
}
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1592
|
+
clamp(minLength, maxLength, defaultDir) {
|
|
1593
|
+
const mag = this.length;
|
|
1594
|
+
if (mag === 0) {
|
|
1595
|
+
if (minLength !== void 0) {
|
|
1596
|
+
if (defaultDir && defaultDir.coords.length !== this.coords.length)
|
|
1597
|
+
throw new TypeError("Coordinate length mismatch!");
|
|
1598
|
+
const dir = defaultDir && defaultDir.length !== 0 ? defaultDir.normalize() : new _Vec(1, ...Array(this.coords.length - 1).fill(0));
|
|
1599
|
+
return dir.mul(minLength);
|
|
1600
|
+
}
|
|
1601
|
+
return this;
|
|
1602
|
+
}
|
|
1603
|
+
if (maxLength !== void 0 && mag > maxLength) {
|
|
1604
|
+
return this.normalize().mul(maxLength);
|
|
1605
|
+
}
|
|
1606
|
+
if (minLength !== void 0 && mag < minLength) {
|
|
1607
|
+
return this.normalize().mul(minLength);
|
|
1608
|
+
}
|
|
1609
|
+
return this;
|
|
1071
1610
|
}
|
|
1072
|
-
|
|
1073
|
-
return
|
|
1611
|
+
equals(other) {
|
|
1612
|
+
return this.coords.length === other.coords.length && this.coords.every((v, i) => v === other.coords[i]);
|
|
1074
1613
|
}
|
|
1075
|
-
|
|
1076
|
-
return this.
|
|
1614
|
+
clone() {
|
|
1615
|
+
return new _Vec(...this.coords);
|
|
1077
1616
|
}
|
|
1078
|
-
|
|
1079
|
-
return this.
|
|
1617
|
+
toObject() {
|
|
1618
|
+
return { x: this.x, y: this.y, z: this.z };
|
|
1080
1619
|
}
|
|
1081
|
-
|
|
1082
|
-
this.
|
|
1620
|
+
[Symbol.iterator]() {
|
|
1621
|
+
return this.coords[Symbol.iterator]();
|
|
1622
|
+
}
|
|
1623
|
+
toString() {
|
|
1624
|
+
return `Vec(${this.coords.join(", ")})`;
|
|
1083
1625
|
}
|
|
1084
1626
|
};
|
|
1085
1627
|
|
|
1086
|
-
// src/core/
|
|
1087
|
-
var
|
|
1088
|
-
constructor(
|
|
1089
|
-
__publicField(this, "
|
|
1090
|
-
__publicField(this, "
|
|
1091
|
-
this
|
|
1092
|
-
this
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1628
|
+
// src/core/div-rect.ts
|
|
1629
|
+
var DivRect = class _DivRect {
|
|
1630
|
+
constructor(...args) {
|
|
1631
|
+
__publicField(this, "left");
|
|
1632
|
+
__publicField(this, "anchorX");
|
|
1633
|
+
__publicField(this, "right");
|
|
1634
|
+
__publicField(this, "top");
|
|
1635
|
+
__publicField(this, "anchorY");
|
|
1636
|
+
__publicField(this, "bottom");
|
|
1637
|
+
if (args.length === 6) {
|
|
1638
|
+
this.left = args[0];
|
|
1639
|
+
this.anchorX = args[1];
|
|
1640
|
+
this.right = args[2];
|
|
1641
|
+
this.top = args[3];
|
|
1642
|
+
this.anchorY = args[4];
|
|
1643
|
+
this.bottom = args[5];
|
|
1644
|
+
} else if (args.length === 4) {
|
|
1645
|
+
this.left = args[0];
|
|
1646
|
+
this.right = args[1];
|
|
1647
|
+
this.anchorX = (this.left + this.right) / 2;
|
|
1648
|
+
this.top = args[2];
|
|
1649
|
+
this.bottom = args[3];
|
|
1650
|
+
this.anchorY = (this.top + this.bottom) / 2;
|
|
1651
|
+
} else if (args.length === 0) {
|
|
1652
|
+
this.left = this.anchorX = this.right = 0;
|
|
1653
|
+
this.top = this.anchorY = this.bottom = 0;
|
|
1654
|
+
} else {
|
|
1655
|
+
throw new TypeError(`Invalid DivRect args: ${args}`);
|
|
1656
|
+
}
|
|
1657
|
+
}
|
|
1658
|
+
/**
|
|
1659
|
+
* Create rect from basic left, top, width and height arguments.
|
|
1660
|
+
*
|
|
1661
|
+
* @param left - Left coordinate.
|
|
1662
|
+
* @param top - Top coordinate.
|
|
1663
|
+
* @param width - Width.
|
|
1664
|
+
* @param height - Height.
|
|
1665
|
+
* @returns - DivRect.
|
|
1666
|
+
*/
|
|
1667
|
+
static create(left, top, width, height) {
|
|
1668
|
+
return new _DivRect(left, left + width, top, top + height);
|
|
1669
|
+
}
|
|
1670
|
+
/**
|
|
1671
|
+
* Create rect from anchorX, anchorY, width, height arguments.
|
|
1672
|
+
*
|
|
1673
|
+
* @param centerX - Center x-coordinate.
|
|
1674
|
+
* @param centerY - Center y-coordinate.
|
|
1675
|
+
* @param width - Width.
|
|
1676
|
+
* @param height - Height.
|
|
1677
|
+
* @returns - DivRect.
|
|
1678
|
+
*/
|
|
1679
|
+
static createCentered(centerX, centerY, width, height) {
|
|
1680
|
+
return new _DivRect(
|
|
1681
|
+
centerX - width / 2,
|
|
1682
|
+
centerX,
|
|
1683
|
+
centerX + width / 2,
|
|
1684
|
+
centerY - height / 2,
|
|
1685
|
+
centerY,
|
|
1686
|
+
centerY + height / 2
|
|
1687
|
+
);
|
|
1688
|
+
}
|
|
1689
|
+
/**
|
|
1690
|
+
* Create rect from sections.
|
|
1691
|
+
*
|
|
1692
|
+
* @param leftw - Left section width.
|
|
1693
|
+
* @param rightw - Right section width.
|
|
1694
|
+
* @param toph - Top section height.
|
|
1695
|
+
* @param bottomh - Bottomsection height.
|
|
1696
|
+
* @returns - DivRect.
|
|
1697
|
+
*/
|
|
1698
|
+
static createSections(leftw, rightw, toph, bottomh) {
|
|
1699
|
+
return new _DivRect(-leftw, 0, rightw, -toph, 0, bottomh);
|
|
1700
|
+
}
|
|
1701
|
+
/** @deprecated - Renamed to anchorX. */
|
|
1702
|
+
get centerX() {
|
|
1703
|
+
return this.anchorX;
|
|
1704
|
+
}
|
|
1705
|
+
/** @deprecated - Renamed to anchorX. */
|
|
1706
|
+
set centerX(x) {
|
|
1707
|
+
this.anchorX = x;
|
|
1708
|
+
}
|
|
1709
|
+
/** @deprecated - Renamed to anchorY. */
|
|
1710
|
+
get centerY() {
|
|
1711
|
+
return this.anchorY;
|
|
1712
|
+
}
|
|
1713
|
+
/** @deprecated - Renamed to anchorY. */
|
|
1714
|
+
set centerY(y) {
|
|
1715
|
+
this.anchorY = y;
|
|
1716
|
+
}
|
|
1717
|
+
/**
|
|
1718
|
+
* Width getter.
|
|
1719
|
+
*/
|
|
1720
|
+
get width() {
|
|
1721
|
+
return this.right - this.left;
|
|
1722
|
+
}
|
|
1723
|
+
/**
|
|
1724
|
+
* Height getter.
|
|
1725
|
+
*/
|
|
1726
|
+
get height() {
|
|
1727
|
+
return this.bottom - this.top;
|
|
1728
|
+
}
|
|
1729
|
+
/**
|
|
1730
|
+
* Left section width getter.
|
|
1731
|
+
*/
|
|
1732
|
+
get leftw() {
|
|
1733
|
+
return this.anchorX - this.left;
|
|
1734
|
+
}
|
|
1735
|
+
/**
|
|
1736
|
+
* Right section width getter.
|
|
1737
|
+
*/
|
|
1738
|
+
get rightw() {
|
|
1739
|
+
return this.right - this.anchorX;
|
|
1740
|
+
}
|
|
1741
|
+
/**
|
|
1742
|
+
* Top section height getter.
|
|
1743
|
+
*/
|
|
1744
|
+
get toph() {
|
|
1745
|
+
return this.anchorY - this.top;
|
|
1746
|
+
}
|
|
1747
|
+
/**
|
|
1748
|
+
* Bottom section height getter.
|
|
1749
|
+
*/
|
|
1750
|
+
get bottomh() {
|
|
1751
|
+
return this.bottom - this.anchorY;
|
|
1752
|
+
}
|
|
1753
|
+
/**
|
|
1754
|
+
* Does this Rect contain given (x, y)-point?
|
|
1755
|
+
*
|
|
1756
|
+
* @param x - X-coordinate.
|
|
1757
|
+
* @param y - Y-coordinate.
|
|
1758
|
+
* @returns - True/false.
|
|
1759
|
+
*/
|
|
1760
|
+
contains(x, y) {
|
|
1761
|
+
return x >= this.left && x <= this.right && y >= this.top && y <= this.bottom;
|
|
1762
|
+
}
|
|
1763
|
+
/**
|
|
1764
|
+
* Do a and b rects overlap?
|
|
1765
|
+
*
|
|
1766
|
+
* @param a - DivRect a.
|
|
1767
|
+
* @param b - DivRect b.
|
|
1768
|
+
* @returns - True/false.
|
|
1769
|
+
*/
|
|
1770
|
+
static overlap(a, b) {
|
|
1771
|
+
return a.right > b.left && a.left < b.right && a.bottom > b.top && a.top < b.bottom;
|
|
1772
|
+
}
|
|
1773
|
+
/**
|
|
1774
|
+
* Do horizontal measures of a and b rects overlap?
|
|
1775
|
+
*
|
|
1776
|
+
* @param a - DivRect a.
|
|
1777
|
+
* @param b - DivRect b.
|
|
1778
|
+
* @returns - True/false.
|
|
1779
|
+
*/
|
|
1780
|
+
static overlapX(a, b) {
|
|
1781
|
+
return a.right > b.left && a.left < b.right;
|
|
1782
|
+
}
|
|
1783
|
+
/**
|
|
1784
|
+
* Check if given rects are equal.
|
|
1785
|
+
* @param a - DivRect a.
|
|
1786
|
+
* @param b - DivRect b.
|
|
1787
|
+
* @returns - True/false.
|
|
1788
|
+
*/
|
|
1789
|
+
static equals(a, b) {
|
|
1790
|
+
if (a == null && b == null) {
|
|
1791
|
+
return true;
|
|
1792
|
+
} else if (a == null || b == null) {
|
|
1793
|
+
return false;
|
|
1794
|
+
} else {
|
|
1795
|
+
return a === b || a.left === b.left && a.anchorX === b.anchorX && a.right === b.right && a.top === b.top && a.anchorY === b.anchorY && a.bottom === b.bottom;
|
|
1796
|
+
}
|
|
1797
|
+
}
|
|
1798
|
+
/**
|
|
1799
|
+
* Check if this rect equals with another rect.
|
|
1800
|
+
* @param other - The other rect.
|
|
1801
|
+
* @returns - True/false.
|
|
1802
|
+
*/
|
|
1803
|
+
equals(other) {
|
|
1804
|
+
return _DivRect.equals(this, other);
|
|
1805
|
+
}
|
|
1806
|
+
/**
|
|
1807
|
+
* Check if edges of given rects are equal, ignoring anchorX and anchorY.
|
|
1808
|
+
*
|
|
1809
|
+
* @param a - DivRect a.
|
|
1810
|
+
* @param b - DivRect b.
|
|
1811
|
+
* @returns - True/false.
|
|
1812
|
+
*/
|
|
1813
|
+
static equalsEdges(a, b) {
|
|
1814
|
+
if (a == null && b == null) {
|
|
1815
|
+
return true;
|
|
1816
|
+
} else if (a == null || b == null) {
|
|
1817
|
+
return false;
|
|
1818
|
+
} else {
|
|
1819
|
+
return a === b || a.left === b.left && a.right === b.right && a.top === b.top && a.bottom === b.bottom;
|
|
1820
|
+
}
|
|
1821
|
+
}
|
|
1822
|
+
/**
|
|
1823
|
+
* Check if edges of this Rect equals with given Rect, ignoring anchorX and anchorY.
|
|
1824
|
+
*
|
|
1825
|
+
* @param other - The other DivRect.
|
|
1826
|
+
* @returns - True/false.
|
|
1827
|
+
*/
|
|
1828
|
+
equalsEdges(other) {
|
|
1829
|
+
return _DivRect.equalsEdges(this, other);
|
|
1830
|
+
}
|
|
1831
|
+
/** @deprecated - Use `DivRect.equalsEdges()` instead. */
|
|
1832
|
+
static equalsFrame(a, b) {
|
|
1833
|
+
return _DivRect.equalsEdges(a, b);
|
|
1834
|
+
}
|
|
1835
|
+
/**
|
|
1836
|
+
* Created duplicate of this Rect.
|
|
1837
|
+
*
|
|
1838
|
+
* @returns - Duplicate.
|
|
1839
|
+
*/
|
|
1840
|
+
copy() {
|
|
1841
|
+
return new _DivRect(this.left, this.anchorX, this.right, this.top, this.anchorY, this.bottom);
|
|
1842
|
+
}
|
|
1843
|
+
/**
|
|
1844
|
+
* Move this rect by (dx, dy). Modifies this Rect.
|
|
1845
|
+
*
|
|
1846
|
+
* @param dx - Offset amount in x-direction.
|
|
1847
|
+
* @param dy - Offset amount in y-direction.
|
|
1848
|
+
* @returns - This DivRect instance.
|
|
1849
|
+
*/
|
|
1850
|
+
offsetInPlace(dx, dy) {
|
|
1851
|
+
this.left += dx;
|
|
1852
|
+
this.anchorX += dx;
|
|
1853
|
+
this.right += dx;
|
|
1854
|
+
this.top += dy;
|
|
1855
|
+
this.anchorY += dy;
|
|
1856
|
+
this.bottom += dy;
|
|
1857
|
+
return this;
|
|
1096
1858
|
}
|
|
1097
|
-
|
|
1098
|
-
|
|
1859
|
+
/**
|
|
1860
|
+
* Move this rect by (dx, dy). Immutable, returns modified copy.
|
|
1861
|
+
*
|
|
1862
|
+
* @param dx - Offset amount in x-direction.
|
|
1863
|
+
* @param dy - Offset amount in y-direction.
|
|
1864
|
+
* @returns - DivRect copy with applied offset.
|
|
1865
|
+
*/
|
|
1866
|
+
offsetCopy(dx, dy) {
|
|
1867
|
+
return this.copy().offsetInPlace(dx, dy);
|
|
1868
|
+
}
|
|
1869
|
+
/**
|
|
1870
|
+
* Expand this Rect by given Rect. Modifies this Rect.
|
|
1871
|
+
*
|
|
1872
|
+
* @param rect - DivRect to expand this instance with.
|
|
1873
|
+
* @returns - This DivRect instance.
|
|
1874
|
+
*/
|
|
1875
|
+
expandInPlace(rect) {
|
|
1876
|
+
this.left = Math.min(this.left, rect.left);
|
|
1877
|
+
this.right = Math.max(this.right, rect.right);
|
|
1878
|
+
this.top = Math.min(this.top, rect.top);
|
|
1879
|
+
this.bottom = Math.max(this.bottom, rect.bottom);
|
|
1880
|
+
return this;
|
|
1099
1881
|
}
|
|
1100
|
-
|
|
1101
|
-
|
|
1882
|
+
/**
|
|
1883
|
+
* Expand this Rect by given Rect. Immutable, returns modified copy.
|
|
1884
|
+
*
|
|
1885
|
+
* @param rect - DivRect to expand this instance with.
|
|
1886
|
+
* @returns - Expanded copy of this DivRect.
|
|
1887
|
+
*/
|
|
1888
|
+
expandCopy(rect) {
|
|
1889
|
+
return this.copy().expandInPlace(rect);
|
|
1890
|
+
}
|
|
1891
|
+
/**
|
|
1892
|
+
* Clip this Rect by given Rect. Mmodifies this Rect.
|
|
1893
|
+
*
|
|
1894
|
+
* @param clipRect - DivRect to clip this instance with.
|
|
1895
|
+
* @returns - This DivRect instance.
|
|
1896
|
+
*/
|
|
1897
|
+
clipInPlace(clipRect) {
|
|
1898
|
+
this.left = Math.max(this.left, clipRect.left);
|
|
1899
|
+
this.right = Math.min(this.right, clipRect.right);
|
|
1900
|
+
this.anchorX = clamp(this.anchorX, this.left, this.right);
|
|
1901
|
+
this.top = Math.max(this.top, clipRect.top);
|
|
1902
|
+
this.bottom = Math.min(this.bottom, clipRect.bottom);
|
|
1903
|
+
this.anchorY = clamp(this.anchorY, this.top, this.bottom);
|
|
1904
|
+
return this;
|
|
1102
1905
|
}
|
|
1103
|
-
|
|
1104
|
-
|
|
1906
|
+
/**
|
|
1907
|
+
* Clip this Rect by given Rect. Immutable, return modified copy.
|
|
1908
|
+
*
|
|
1909
|
+
* @param clipRect - DivRecto to clip this instance with.
|
|
1910
|
+
* @returns - Clipped DivRect copy.
|
|
1911
|
+
*/
|
|
1912
|
+
clipCopy(clipRect) {
|
|
1913
|
+
return this.copy().clipInPlace(clipRect);
|
|
1914
|
+
}
|
|
1915
|
+
/**
|
|
1916
|
+
* Scale Rect. Anchor pos is (anchorX, anchorY). Modifies this Rect.
|
|
1917
|
+
*
|
|
1918
|
+
* @param scaleX - Scale x-amount.
|
|
1919
|
+
* @param scaleY - Scale y-amount. If undefined then scale x-amount is used.
|
|
1920
|
+
* @returns This DivRect instance.
|
|
1921
|
+
*/
|
|
1922
|
+
scaleInPlace(scaleX, scaleY) {
|
|
1923
|
+
scaleY = scaleY ?? scaleX;
|
|
1924
|
+
this.left = this.anchorX - this.leftw * scaleX;
|
|
1925
|
+
this.right = this.anchorX + this.rightw * scaleX;
|
|
1926
|
+
this.top = this.anchorY - this.toph * scaleY;
|
|
1927
|
+
this.bottom = this.anchorY + this.bottomh * scaleY;
|
|
1928
|
+
return this;
|
|
1105
1929
|
}
|
|
1106
|
-
|
|
1107
|
-
|
|
1930
|
+
/**
|
|
1931
|
+
* Scale Rect. Anchor pos is (anchorX, anchorY). Immutable, returns modified copy.
|
|
1932
|
+
*
|
|
1933
|
+
* @param scaleX - Scale x-amount.
|
|
1934
|
+
* @param scaleY - Scale y-amount. If undefined then scale x-amount is used.
|
|
1935
|
+
* @returns Scaled copy of this DivRect.
|
|
1936
|
+
*/
|
|
1937
|
+
scaleCopy(scaleX, scaleY) {
|
|
1938
|
+
return this.copy().scaleInPlace(scaleX, scaleY);
|
|
1939
|
+
}
|
|
1940
|
+
/**
|
|
1941
|
+
* Get this DivRect instance.
|
|
1942
|
+
* @returns - This DivRect instance.
|
|
1943
|
+
*/
|
|
1944
|
+
getRect() {
|
|
1945
|
+
return this;
|
|
1108
1946
|
}
|
|
1109
1947
|
};
|
|
1110
1948
|
|
|
@@ -1205,93 +2043,37 @@ var LRUCache = class {
|
|
|
1205
2043
|
}
|
|
1206
2044
|
};
|
|
1207
2045
|
|
|
1208
|
-
// src/core/small-int-cache.ts
|
|
1209
|
-
var SmallIntCache = class {
|
|
1210
|
-
// for keys < 0
|
|
1211
|
-
constructor() {
|
|
1212
|
-
__publicField(this, "pos");
|
|
1213
|
-
// for keys >= 0
|
|
1214
|
-
__publicField(this, "neg");
|
|
1215
|
-
this.pos = [];
|
|
1216
|
-
this.neg = [];
|
|
1217
|
-
}
|
|
1218
|
-
set(key, value) {
|
|
1219
|
-
if (!isInteger(key)) {
|
|
1220
|
-
throw new Error("Key must be an integer");
|
|
1221
|
-
} else if (key >= 0) {
|
|
1222
|
-
this.pos[key] = value;
|
|
1223
|
-
} else {
|
|
1224
|
-
this.neg[-key - 1] = value;
|
|
1225
|
-
}
|
|
1226
|
-
}
|
|
1227
|
-
get(key) {
|
|
1228
|
-
if (!isInteger(key)) {
|
|
1229
|
-
throw new Error("Key must be an integer");
|
|
1230
|
-
} else if (key >= 0) {
|
|
1231
|
-
return this.pos[key];
|
|
1232
|
-
} else {
|
|
1233
|
-
return this.neg[-key - 1];
|
|
1234
|
-
}
|
|
1235
|
-
}
|
|
1236
|
-
has(key) {
|
|
1237
|
-
if (!isInteger(key)) {
|
|
1238
|
-
return false;
|
|
1239
|
-
} else if (key >= 0) {
|
|
1240
|
-
return key in this.pos;
|
|
1241
|
-
} else {
|
|
1242
|
-
return -key - 1 in this.neg;
|
|
1243
|
-
}
|
|
1244
|
-
}
|
|
1245
|
-
delete(key) {
|
|
1246
|
-
if (!isInteger(key)) {
|
|
1247
|
-
return;
|
|
1248
|
-
} else if (key >= 0) {
|
|
1249
|
-
delete this.pos[key];
|
|
1250
|
-
} else {
|
|
1251
|
-
delete this.neg[-key - 1];
|
|
1252
|
-
}
|
|
1253
|
-
}
|
|
1254
|
-
clear() {
|
|
1255
|
-
this.pos = [];
|
|
1256
|
-
this.neg = [];
|
|
1257
|
-
}
|
|
1258
|
-
};
|
|
1259
|
-
|
|
1260
2046
|
// src/core/index-array.ts
|
|
1261
2047
|
var IndexArray = class _IndexArray {
|
|
1262
2048
|
constructor(entries) {
|
|
1263
|
-
|
|
1264
|
-
__publicField(this, "posEl");
|
|
2049
|
+
__publicField(this, "posVal");
|
|
1265
2050
|
__publicField(this, "hasPos");
|
|
1266
|
-
//
|
|
1267
|
-
__publicField(this, "
|
|
2051
|
+
// Number of values
|
|
2052
|
+
__publicField(this, "valCount");
|
|
1268
2053
|
if (entries instanceof _IndexArray) {
|
|
1269
|
-
this.
|
|
2054
|
+
this.posVal = entries.posVal.slice();
|
|
1270
2055
|
this.hasPos = entries.hasPos.slice();
|
|
1271
|
-
this.
|
|
2056
|
+
this.valCount = entries.valCount;
|
|
1272
2057
|
} else {
|
|
1273
|
-
this.
|
|
2058
|
+
this.posVal = [];
|
|
1274
2059
|
this.hasPos = [];
|
|
1275
|
-
this.
|
|
2060
|
+
this.valCount = 0;
|
|
1276
2061
|
if (entries) {
|
|
1277
|
-
for (const [id,
|
|
1278
|
-
this.set(id,
|
|
2062
|
+
for (const [id, value] of entries) {
|
|
2063
|
+
this.set(id, value);
|
|
1279
2064
|
}
|
|
1280
2065
|
}
|
|
1281
2066
|
}
|
|
1282
2067
|
}
|
|
1283
|
-
static toNegIndex(id) {
|
|
1284
|
-
return -id - 1;
|
|
1285
|
-
}
|
|
1286
2068
|
static validateIndex(id) {
|
|
1287
|
-
if (!
|
|
2069
|
+
if (!isIntegerGte2(id, 0)) throw new Error(`Invalid index ${id} - must be an integer >= 0!`);
|
|
1288
2070
|
return id;
|
|
1289
2071
|
}
|
|
1290
2072
|
get posLen() {
|
|
1291
2073
|
return this.hasPos.length;
|
|
1292
2074
|
}
|
|
1293
2075
|
get size() {
|
|
1294
|
-
return this.
|
|
2076
|
+
return this.valCount;
|
|
1295
2077
|
}
|
|
1296
2078
|
isEmpty() {
|
|
1297
2079
|
return this.size === 0;
|
|
@@ -1300,22 +2082,22 @@ var IndexArray = class _IndexArray {
|
|
|
1300
2082
|
_IndexArray.validateIndex(id);
|
|
1301
2083
|
return this.hasPos[id] === true;
|
|
1302
2084
|
}
|
|
1303
|
-
set(id,
|
|
2085
|
+
set(id, value) {
|
|
1304
2086
|
_IndexArray.validateIndex(id);
|
|
1305
|
-
if (this.hasPos[id] !== true) this.
|
|
1306
|
-
this.
|
|
2087
|
+
if (this.hasPos[id] !== true) this.valCount++;
|
|
2088
|
+
this.posVal[id] = value;
|
|
1307
2089
|
this.hasPos[id] = true;
|
|
1308
2090
|
}
|
|
1309
2091
|
get(id) {
|
|
1310
2092
|
_IndexArray.validateIndex(id);
|
|
1311
|
-
return this.hasPos[id] ? this.
|
|
2093
|
+
return this.hasPos[id] ? this.posVal[id] : void 0;
|
|
1312
2094
|
}
|
|
1313
2095
|
getOrDefault(id, defaultValue) {
|
|
1314
2096
|
return this.get(id) ?? defaultValue;
|
|
1315
2097
|
}
|
|
1316
2098
|
getOrCreate(id, creatorOrValue) {
|
|
1317
2099
|
if (!this.has(id)) {
|
|
1318
|
-
const value =
|
|
2100
|
+
const value = isFunction2(creatorOrValue) ? creatorOrValue() : creatorOrValue;
|
|
1319
2101
|
this.set(id, value);
|
|
1320
2102
|
return value;
|
|
1321
2103
|
}
|
|
@@ -1324,19 +2106,19 @@ var IndexArray = class _IndexArray {
|
|
|
1324
2106
|
delete(id) {
|
|
1325
2107
|
_IndexArray.validateIndex(id);
|
|
1326
2108
|
if (!this.hasPos[id]) return false;
|
|
1327
|
-
this.
|
|
2109
|
+
this.posVal[id] = void 0;
|
|
1328
2110
|
this.hasPos[id] = false;
|
|
1329
|
-
this.
|
|
2111
|
+
this.valCount--;
|
|
1330
2112
|
return true;
|
|
1331
2113
|
}
|
|
1332
2114
|
clear() {
|
|
1333
|
-
this.
|
|
2115
|
+
this.posVal = [];
|
|
1334
2116
|
this.hasPos = [];
|
|
1335
|
-
this.
|
|
2117
|
+
this.valCount = 0;
|
|
1336
2118
|
}
|
|
1337
2119
|
forEach(callbackfn, thisArg) {
|
|
1338
|
-
for (const [id,
|
|
1339
|
-
callbackfn.call(thisArg,
|
|
2120
|
+
for (const [id, value] of this.entries()) {
|
|
2121
|
+
callbackfn.call(thisArg, value, id, this);
|
|
1340
2122
|
}
|
|
1341
2123
|
}
|
|
1342
2124
|
*indices() {
|
|
@@ -1346,12 +2128,12 @@ var IndexArray = class _IndexArray {
|
|
|
1346
2128
|
}
|
|
1347
2129
|
*values() {
|
|
1348
2130
|
for (let id = 0; id < this.posLen; id++) {
|
|
1349
|
-
if (this.hasPos[id]) yield this.
|
|
2131
|
+
if (this.hasPos[id]) yield this.posVal[id];
|
|
1350
2132
|
}
|
|
1351
2133
|
}
|
|
1352
2134
|
*entries() {
|
|
1353
2135
|
for (let id = 0; id < this.posLen; id++) {
|
|
1354
|
-
if (this.hasPos[id]) yield [id, this.
|
|
2136
|
+
if (this.hasPos[id]) yield [id, this.posVal[id]];
|
|
1355
2137
|
}
|
|
1356
2138
|
}
|
|
1357
2139
|
indicesArray() {
|
|
@@ -1369,13 +2151,13 @@ var IndexArray = class _IndexArray {
|
|
|
1369
2151
|
}
|
|
1370
2152
|
}
|
|
1371
2153
|
*kvValues() {
|
|
1372
|
-
for (const
|
|
1373
|
-
yield
|
|
2154
|
+
for (const value of this.values()) {
|
|
2155
|
+
yield value;
|
|
1374
2156
|
}
|
|
1375
2157
|
}
|
|
1376
2158
|
*kvEntries() {
|
|
1377
|
-
for (const [id,
|
|
1378
|
-
yield [[id],
|
|
2159
|
+
for (const [id, value] of this.entries()) {
|
|
2160
|
+
yield [[id], value];
|
|
1379
2161
|
}
|
|
1380
2162
|
}
|
|
1381
2163
|
*[Symbol.iterator]() {
|
|
@@ -1395,21 +2177,21 @@ var IndexArray = class _IndexArray {
|
|
|
1395
2177
|
return this;
|
|
1396
2178
|
}
|
|
1397
2179
|
some(fn) {
|
|
1398
|
-
for (const [id,
|
|
1399
|
-
if (fn(
|
|
2180
|
+
for (const [id, value] of this.entries()) {
|
|
2181
|
+
if (fn(value, id)) return true;
|
|
1400
2182
|
}
|
|
1401
2183
|
return false;
|
|
1402
2184
|
}
|
|
1403
2185
|
every(fn) {
|
|
1404
|
-
for (const [id,
|
|
1405
|
-
if (!fn(
|
|
2186
|
+
for (const [id, value] of this.entries()) {
|
|
2187
|
+
if (!fn(value, id)) return false;
|
|
1406
2188
|
}
|
|
1407
2189
|
return true;
|
|
1408
2190
|
}
|
|
1409
|
-
filter(
|
|
1410
|
-
|
|
1411
|
-
for (const [id,
|
|
1412
|
-
if (
|
|
2191
|
+
filter(predicate) {
|
|
2192
|
+
const result = new this.constructor();
|
|
2193
|
+
for (const [id, value] of this.entries()) {
|
|
2194
|
+
if (predicate(value, id, this)) result.set(id, value);
|
|
1413
2195
|
}
|
|
1414
2196
|
return result;
|
|
1415
2197
|
}
|
|
@@ -1432,40 +2214,40 @@ var IndexArray = class _IndexArray {
|
|
|
1432
2214
|
start = first;
|
|
1433
2215
|
}
|
|
1434
2216
|
for (let current = start; !current.done; current = iterator.next()) {
|
|
1435
|
-
const [id,
|
|
1436
|
-
acc = fn(acc,
|
|
2217
|
+
const [id, value] = current.value;
|
|
2218
|
+
acc = fn(acc, value, id);
|
|
1437
2219
|
}
|
|
1438
2220
|
return acc;
|
|
1439
2221
|
}
|
|
1440
2222
|
mapToArray(fn) {
|
|
1441
2223
|
let result = [];
|
|
1442
|
-
for (const [id,
|
|
1443
|
-
result.push(fn(
|
|
2224
|
+
for (const [id, value] of this.entries()) {
|
|
2225
|
+
result.push(fn(value, id));
|
|
1444
2226
|
}
|
|
1445
2227
|
return result;
|
|
1446
2228
|
}
|
|
1447
2229
|
map(fn) {
|
|
1448
2230
|
let result = new _IndexArray();
|
|
1449
|
-
for (const [id,
|
|
1450
|
-
result.set(id, fn(
|
|
2231
|
+
for (const [id, value] of this.entries()) {
|
|
2232
|
+
result.set(id, fn(value, id));
|
|
1451
2233
|
}
|
|
1452
2234
|
return result;
|
|
1453
2235
|
}
|
|
1454
|
-
equals(other,
|
|
2236
|
+
equals(other, eq2) {
|
|
1455
2237
|
if (this.size !== other.size) return false;
|
|
1456
|
-
|
|
2238
|
+
eq2 ?? (eq2 = (a, b) => a === b);
|
|
1457
2239
|
const posLen = Math.max(this.posLen, other.posLen);
|
|
1458
2240
|
for (let i = 0; i < posLen; ++i) {
|
|
1459
2241
|
const hasA = this.hasPos[i];
|
|
1460
2242
|
const hasB = other.hasPos[i];
|
|
1461
2243
|
if (hasA !== hasB) return false;
|
|
1462
|
-
if (hasA && !
|
|
2244
|
+
if (hasA && !eq2(this.posVal[i], other.posVal[i])) return false;
|
|
1463
2245
|
}
|
|
1464
2246
|
return true;
|
|
1465
2247
|
}
|
|
1466
2248
|
toString() {
|
|
1467
2249
|
if (this.size === 0) return `IndexArray[ ]`;
|
|
1468
|
-
const entries = this.entriesArray().map(([id,
|
|
2250
|
+
const entries = this.entriesArray().map(([id, value]) => `${id}: ${value}`).join(", ");
|
|
1469
2251
|
return `IndexArray[ ${entries} ]`;
|
|
1470
2252
|
}
|
|
1471
2253
|
};
|
|
@@ -1473,29 +2255,29 @@ var IndexArray = class _IndexArray {
|
|
|
1473
2255
|
// src/core/signed-index-array.ts
|
|
1474
2256
|
var SignedIndexArray = class _SignedIndexArray {
|
|
1475
2257
|
constructor(entries) {
|
|
1476
|
-
//
|
|
1477
|
-
__publicField(this, "
|
|
2258
|
+
// For indexes >= 0
|
|
2259
|
+
__publicField(this, "posVal");
|
|
1478
2260
|
__publicField(this, "hasPos");
|
|
1479
|
-
//
|
|
1480
|
-
__publicField(this, "
|
|
2261
|
+
// For indexes < 0
|
|
2262
|
+
__publicField(this, "negVal");
|
|
1481
2263
|
__publicField(this, "hasNeg");
|
|
1482
|
-
//
|
|
1483
|
-
__publicField(this, "
|
|
2264
|
+
// Number of values
|
|
2265
|
+
__publicField(this, "valCount");
|
|
1484
2266
|
if (entries instanceof _SignedIndexArray) {
|
|
1485
|
-
this.
|
|
2267
|
+
this.negVal = entries.negVal.slice();
|
|
1486
2268
|
this.hasNeg = entries.hasNeg.slice();
|
|
1487
|
-
this.
|
|
2269
|
+
this.posVal = entries.posVal.slice();
|
|
1488
2270
|
this.hasPos = entries.hasPos.slice();
|
|
1489
|
-
this.
|
|
2271
|
+
this.valCount = entries.valCount;
|
|
1490
2272
|
} else {
|
|
1491
|
-
this.
|
|
2273
|
+
this.negVal = [];
|
|
1492
2274
|
this.hasNeg = [];
|
|
1493
|
-
this.
|
|
2275
|
+
this.posVal = [];
|
|
1494
2276
|
this.hasPos = [];
|
|
1495
|
-
this.
|
|
2277
|
+
this.valCount = 0;
|
|
1496
2278
|
if (entries) {
|
|
1497
|
-
for (const [id,
|
|
1498
|
-
this.set(id,
|
|
2279
|
+
for (const [id, value] of entries) {
|
|
2280
|
+
this.set(id, value);
|
|
1499
2281
|
}
|
|
1500
2282
|
}
|
|
1501
2283
|
}
|
|
@@ -1504,11 +2286,11 @@ var SignedIndexArray = class _SignedIndexArray {
|
|
|
1504
2286
|
return -id - 1;
|
|
1505
2287
|
}
|
|
1506
2288
|
static validateIndex(id) {
|
|
1507
|
-
if (!
|
|
2289
|
+
if (!isInteger2(id)) throw new Error(`Invalid index ${id} - must be an integer!`);
|
|
1508
2290
|
return id;
|
|
1509
2291
|
}
|
|
1510
2292
|
get size() {
|
|
1511
|
-
return this.
|
|
2293
|
+
return this.valCount;
|
|
1512
2294
|
}
|
|
1513
2295
|
isEmpty() {
|
|
1514
2296
|
return this.size === 0;
|
|
@@ -1527,26 +2309,26 @@ var SignedIndexArray = class _SignedIndexArray {
|
|
|
1527
2309
|
return this.hasNeg[_SignedIndexArray.toNegIndex(id)] === true;
|
|
1528
2310
|
}
|
|
1529
2311
|
}
|
|
1530
|
-
set(id,
|
|
2312
|
+
set(id, value) {
|
|
1531
2313
|
_SignedIndexArray.validateIndex(id);
|
|
1532
2314
|
if (id >= 0) {
|
|
1533
|
-
if (this.hasPos[id] !== true) this.
|
|
1534
|
-
this.
|
|
2315
|
+
if (this.hasPos[id] !== true) this.valCount++;
|
|
2316
|
+
this.posVal[id] = value;
|
|
1535
2317
|
this.hasPos[id] = true;
|
|
1536
2318
|
} else {
|
|
1537
2319
|
let negId = _SignedIndexArray.toNegIndex(id);
|
|
1538
|
-
if (this.hasNeg[negId] !== true) this.
|
|
1539
|
-
this.
|
|
2320
|
+
if (this.hasNeg[negId] !== true) this.valCount++;
|
|
2321
|
+
this.negVal[negId] = value;
|
|
1540
2322
|
this.hasNeg[negId] = true;
|
|
1541
2323
|
}
|
|
1542
2324
|
}
|
|
1543
2325
|
get(id) {
|
|
1544
2326
|
_SignedIndexArray.validateIndex(id);
|
|
1545
2327
|
if (id >= 0) {
|
|
1546
|
-
return this.hasPos[id] ? this.
|
|
2328
|
+
return this.hasPos[id] ? this.posVal[id] : void 0;
|
|
1547
2329
|
} else {
|
|
1548
2330
|
let negId = _SignedIndexArray.toNegIndex(id);
|
|
1549
|
-
return this.hasNeg[negId] ? this.
|
|
2331
|
+
return this.hasNeg[negId] ? this.negVal[negId] : void 0;
|
|
1550
2332
|
}
|
|
1551
2333
|
}
|
|
1552
2334
|
getOrDefault(id, defaultValue) {
|
|
@@ -1554,7 +2336,7 @@ var SignedIndexArray = class _SignedIndexArray {
|
|
|
1554
2336
|
}
|
|
1555
2337
|
getOrCreate(id, creatorOrValue) {
|
|
1556
2338
|
if (!this.has(id)) {
|
|
1557
|
-
const value =
|
|
2339
|
+
const value = isFunction2(creatorOrValue) ? creatorOrValue() : creatorOrValue;
|
|
1558
2340
|
this.set(id, value);
|
|
1559
2341
|
return value;
|
|
1560
2342
|
}
|
|
@@ -1563,25 +2345,25 @@ var SignedIndexArray = class _SignedIndexArray {
|
|
|
1563
2345
|
delete(id) {
|
|
1564
2346
|
_SignedIndexArray.validateIndex(id);
|
|
1565
2347
|
const isPos = id >= 0;
|
|
1566
|
-
const arr = isPos ? this.
|
|
2348
|
+
const arr = isPos ? this.posVal : this.negVal;
|
|
1567
2349
|
const has = isPos ? this.hasPos : this.hasNeg;
|
|
1568
2350
|
const idx = isPos ? id : _SignedIndexArray.toNegIndex(id);
|
|
1569
2351
|
if (!has[idx]) return false;
|
|
1570
2352
|
arr[idx] = void 0;
|
|
1571
2353
|
has[idx] = false;
|
|
1572
|
-
this.
|
|
2354
|
+
this.valCount--;
|
|
1573
2355
|
return true;
|
|
1574
2356
|
}
|
|
1575
2357
|
clear() {
|
|
1576
|
-
this.
|
|
2358
|
+
this.negVal = [];
|
|
1577
2359
|
this.hasNeg = [];
|
|
1578
|
-
this.
|
|
2360
|
+
this.posVal = [];
|
|
1579
2361
|
this.hasPos = [];
|
|
1580
|
-
this.
|
|
2362
|
+
this.valCount = 0;
|
|
1581
2363
|
}
|
|
1582
2364
|
forEach(callbackfn, thisArg) {
|
|
1583
|
-
for (const [id,
|
|
1584
|
-
callbackfn.call(thisArg,
|
|
2365
|
+
for (const [id, value] of this.entries()) {
|
|
2366
|
+
callbackfn.call(thisArg, value, id, this);
|
|
1585
2367
|
}
|
|
1586
2368
|
}
|
|
1587
2369
|
*indices() {
|
|
@@ -1594,18 +2376,18 @@ var SignedIndexArray = class _SignedIndexArray {
|
|
|
1594
2376
|
}
|
|
1595
2377
|
*values() {
|
|
1596
2378
|
for (let id = this.negLen - 1; id >= 0; id--) {
|
|
1597
|
-
if (this.hasNeg[id]) yield this.
|
|
2379
|
+
if (this.hasNeg[id]) yield this.negVal[id];
|
|
1598
2380
|
}
|
|
1599
2381
|
for (let id = 0; id < this.posLen; id++) {
|
|
1600
|
-
if (this.hasPos[id]) yield this.
|
|
2382
|
+
if (this.hasPos[id]) yield this.posVal[id];
|
|
1601
2383
|
}
|
|
1602
2384
|
}
|
|
1603
2385
|
*entries() {
|
|
1604
2386
|
for (let id = this.negLen - 1; id >= 0; id--) {
|
|
1605
|
-
if (this.hasNeg[id]) yield [_SignedIndexArray.toNegIndex(id), this.
|
|
2387
|
+
if (this.hasNeg[id]) yield [_SignedIndexArray.toNegIndex(id), this.negVal[id]];
|
|
1606
2388
|
}
|
|
1607
2389
|
for (let id = 0; id < this.posLen; id++) {
|
|
1608
|
-
if (this.hasPos[id]) yield [id, this.
|
|
2390
|
+
if (this.hasPos[id]) yield [id, this.posVal[id]];
|
|
1609
2391
|
}
|
|
1610
2392
|
}
|
|
1611
2393
|
indicesArray() {
|
|
@@ -1623,13 +2405,13 @@ var SignedIndexArray = class _SignedIndexArray {
|
|
|
1623
2405
|
}
|
|
1624
2406
|
}
|
|
1625
2407
|
*kvValues() {
|
|
1626
|
-
for (const
|
|
1627
|
-
yield
|
|
2408
|
+
for (const value of this.values()) {
|
|
2409
|
+
yield value;
|
|
1628
2410
|
}
|
|
1629
2411
|
}
|
|
1630
2412
|
*kvEntries() {
|
|
1631
|
-
for (const [id,
|
|
1632
|
-
yield [[id],
|
|
2413
|
+
for (const [id, value] of this.entries()) {
|
|
2414
|
+
yield [[id], value];
|
|
1633
2415
|
}
|
|
1634
2416
|
}
|
|
1635
2417
|
*[Symbol.iterator]() {
|
|
@@ -1649,21 +2431,21 @@ var SignedIndexArray = class _SignedIndexArray {
|
|
|
1649
2431
|
return this;
|
|
1650
2432
|
}
|
|
1651
2433
|
some(fn) {
|
|
1652
|
-
for (const [id,
|
|
1653
|
-
if (fn(
|
|
2434
|
+
for (const [id, value] of this.entries()) {
|
|
2435
|
+
if (fn(value, id)) return true;
|
|
1654
2436
|
}
|
|
1655
2437
|
return false;
|
|
1656
2438
|
}
|
|
1657
2439
|
every(fn) {
|
|
1658
|
-
for (const [id,
|
|
1659
|
-
if (!fn(
|
|
2440
|
+
for (const [id, value] of this.entries()) {
|
|
2441
|
+
if (!fn(value, id)) return false;
|
|
1660
2442
|
}
|
|
1661
2443
|
return true;
|
|
1662
2444
|
}
|
|
1663
|
-
filter(
|
|
1664
|
-
|
|
1665
|
-
for (const [id,
|
|
1666
|
-
if (
|
|
2445
|
+
filter(predicate) {
|
|
2446
|
+
const result = new this.constructor();
|
|
2447
|
+
for (const [id, value] of this.entries()) {
|
|
2448
|
+
if (predicate(value, id, this)) result.set(id, value);
|
|
1667
2449
|
}
|
|
1668
2450
|
return result;
|
|
1669
2451
|
}
|
|
@@ -1686,52 +2468,52 @@ var SignedIndexArray = class _SignedIndexArray {
|
|
|
1686
2468
|
start = first;
|
|
1687
2469
|
}
|
|
1688
2470
|
for (let current = start; !current.done; current = iterator.next()) {
|
|
1689
|
-
const [id,
|
|
1690
|
-
acc = fn(acc,
|
|
2471
|
+
const [id, value] = current.value;
|
|
2472
|
+
acc = fn(acc, value, id);
|
|
1691
2473
|
}
|
|
1692
2474
|
return acc;
|
|
1693
2475
|
}
|
|
1694
2476
|
mapToArray(fn) {
|
|
1695
2477
|
let result = [];
|
|
1696
|
-
for (const [id,
|
|
1697
|
-
result.push(fn(
|
|
2478
|
+
for (const [id, value] of this.entries()) {
|
|
2479
|
+
result.push(fn(value, id));
|
|
1698
2480
|
}
|
|
1699
2481
|
return result;
|
|
1700
2482
|
}
|
|
1701
2483
|
map(fn) {
|
|
1702
2484
|
let result = new _SignedIndexArray();
|
|
1703
|
-
for (const [id,
|
|
1704
|
-
result.set(id, fn(
|
|
2485
|
+
for (const [id, value] of this.entries()) {
|
|
2486
|
+
result.set(id, fn(value, id));
|
|
1705
2487
|
}
|
|
1706
2488
|
return result;
|
|
1707
2489
|
}
|
|
1708
|
-
equals(other,
|
|
2490
|
+
equals(other, eq2) {
|
|
1709
2491
|
if (this.size !== other.size) return false;
|
|
1710
|
-
|
|
2492
|
+
eq2 ?? (eq2 = (a, b) => a === b);
|
|
1711
2493
|
const posLen = Math.max(this.posLen, other.posLen);
|
|
1712
2494
|
for (let i = 0; i < posLen; ++i) {
|
|
1713
2495
|
const hasA = this.hasPos[i];
|
|
1714
2496
|
const hasB = other.hasPos[i];
|
|
1715
2497
|
if (hasA !== hasB) return false;
|
|
1716
|
-
if (hasA && !
|
|
2498
|
+
if (hasA && !eq2(this.posVal[i], other.posVal[i])) return false;
|
|
1717
2499
|
}
|
|
1718
2500
|
const negLen = Math.max(this.negLen, other.negLen);
|
|
1719
2501
|
for (let i = 0; i < negLen; ++i) {
|
|
1720
2502
|
const hasA = this.hasNeg[i];
|
|
1721
2503
|
const hasB = other.hasNeg[i];
|
|
1722
2504
|
if (hasA !== hasB) return false;
|
|
1723
|
-
if (hasA && !
|
|
2505
|
+
if (hasA && !eq2(this.negVal[i], other.negVal[i])) return false;
|
|
1724
2506
|
}
|
|
1725
2507
|
return true;
|
|
1726
2508
|
}
|
|
1727
2509
|
toString() {
|
|
1728
2510
|
if (this.size === 0) return `SignedIndexArray[ ]`;
|
|
1729
|
-
const entries = this.entriesArray().map(([id,
|
|
2511
|
+
const entries = this.entriesArray().map(([id, value]) => `${id}: ${value}`).join(", ");
|
|
1730
2512
|
return `SignedIndexArray[ ${entries} ]`;
|
|
1731
2513
|
}
|
|
1732
2514
|
};
|
|
1733
2515
|
|
|
1734
|
-
// src/core/
|
|
2516
|
+
// src/core/map1.ts
|
|
1735
2517
|
var Map1 = class _Map1 {
|
|
1736
2518
|
constructor(entries) {
|
|
1737
2519
|
__publicField(this, "map1");
|
|
@@ -1752,7 +2534,7 @@ var Map1 = class _Map1 {
|
|
|
1752
2534
|
}
|
|
1753
2535
|
getOrCreate(key1, creatorOrValue) {
|
|
1754
2536
|
if (!this.has(key1)) {
|
|
1755
|
-
const value =
|
|
2537
|
+
const value = isFunction2(creatorOrValue) ? creatorOrValue() : creatorOrValue;
|
|
1756
2538
|
this.set(key1, value);
|
|
1757
2539
|
return value;
|
|
1758
2540
|
}
|
|
@@ -1835,16 +2617,33 @@ var Map1 = class _Map1 {
|
|
|
1835
2617
|
}
|
|
1836
2618
|
return true;
|
|
1837
2619
|
}
|
|
1838
|
-
filter(
|
|
1839
|
-
|
|
2620
|
+
filter(predicate) {
|
|
2621
|
+
const result = new this.constructor();
|
|
1840
2622
|
for (const [key1, value] of this.map1) {
|
|
1841
|
-
if (
|
|
2623
|
+
if (predicate(value, key1, this)) result.set(key1, value);
|
|
1842
2624
|
}
|
|
1843
2625
|
return result;
|
|
1844
2626
|
}
|
|
1845
2627
|
reduce(fn, init) {
|
|
1846
|
-
let
|
|
1847
|
-
|
|
2628
|
+
let iterator = this.entries();
|
|
2629
|
+
let first = iterator.next();
|
|
2630
|
+
if (first.done) {
|
|
2631
|
+
if (arguments.length < 2) {
|
|
2632
|
+
throw new TypeError("Reduce of empty Map1 with no initial value!");
|
|
2633
|
+
}
|
|
2634
|
+
return init;
|
|
2635
|
+
}
|
|
2636
|
+
let acc;
|
|
2637
|
+
let start;
|
|
2638
|
+
if (arguments.length < 2) {
|
|
2639
|
+
acc = first.value[1];
|
|
2640
|
+
start = iterator.next();
|
|
2641
|
+
} else {
|
|
2642
|
+
acc = init;
|
|
2643
|
+
start = first;
|
|
2644
|
+
}
|
|
2645
|
+
for (let current = start; !current.done; current = iterator.next()) {
|
|
2646
|
+
const [key1, value] = current.value;
|
|
1848
2647
|
acc = fn(acc, value, key1);
|
|
1849
2648
|
}
|
|
1850
2649
|
return acc;
|
|
@@ -1868,9 +2667,11 @@ var Map1 = class _Map1 {
|
|
|
1868
2667
|
}
|
|
1869
2668
|
toString() {
|
|
1870
2669
|
const entries = [...this.map1].map(([k, v]) => `${k} => ${v}`).join(", ");
|
|
1871
|
-
return `Map1(${this.
|
|
2670
|
+
return entries.length === 0 ? `Map1(0){ }` : `Map1(${this.size}){ ${entries} }`;
|
|
1872
2671
|
}
|
|
1873
2672
|
};
|
|
2673
|
+
|
|
2674
|
+
// src/core/map2.ts
|
|
1874
2675
|
var Map2 = class _Map2 {
|
|
1875
2676
|
constructor(entries) {
|
|
1876
2677
|
__publicField(this, "map1", /* @__PURE__ */ new Map());
|
|
@@ -1900,7 +2701,7 @@ var Map2 = class _Map2 {
|
|
|
1900
2701
|
}
|
|
1901
2702
|
getOrCreate(key1, key2, creatorOrValue) {
|
|
1902
2703
|
if (!this.has(key1, key2)) {
|
|
1903
|
-
const value =
|
|
2704
|
+
const value = isFunction2(creatorOrValue) ? creatorOrValue() : creatorOrValue;
|
|
1904
2705
|
this.set(key1, key2, value);
|
|
1905
2706
|
return value;
|
|
1906
2707
|
}
|
|
@@ -1996,21 +2797,36 @@ var Map2 = class _Map2 {
|
|
|
1996
2797
|
}
|
|
1997
2798
|
return true;
|
|
1998
2799
|
}
|
|
1999
|
-
filter(
|
|
2000
|
-
|
|
2800
|
+
filter(predicate) {
|
|
2801
|
+
const result = new this.constructor();
|
|
2001
2802
|
for (const [key1, map2] of this.map1) {
|
|
2002
2803
|
for (const [key2, value] of map2) {
|
|
2003
|
-
if (
|
|
2804
|
+
if (predicate(value, key1, key2, this)) result.set(key1, key2, value);
|
|
2004
2805
|
}
|
|
2005
2806
|
}
|
|
2006
2807
|
return result;
|
|
2007
2808
|
}
|
|
2008
2809
|
reduce(fn, init) {
|
|
2009
|
-
let
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2810
|
+
let iterator = this.entries();
|
|
2811
|
+
let first = iterator.next();
|
|
2812
|
+
if (first.done) {
|
|
2813
|
+
if (arguments.length < 2) {
|
|
2814
|
+
throw new TypeError("Reduce of empty Map2 with no initial value!");
|
|
2013
2815
|
}
|
|
2816
|
+
return init;
|
|
2817
|
+
}
|
|
2818
|
+
let acc;
|
|
2819
|
+
let start;
|
|
2820
|
+
if (arguments.length < 2) {
|
|
2821
|
+
acc = first.value[2];
|
|
2822
|
+
start = iterator.next();
|
|
2823
|
+
} else {
|
|
2824
|
+
acc = init;
|
|
2825
|
+
start = first;
|
|
2826
|
+
}
|
|
2827
|
+
for (let current = start; !current.done; current = iterator.next()) {
|
|
2828
|
+
const [key1, key2, value] = current.value;
|
|
2829
|
+
acc = fn(acc, value, key1, key2);
|
|
2014
2830
|
}
|
|
2015
2831
|
return acc;
|
|
2016
2832
|
}
|
|
@@ -2047,9 +2863,11 @@ var Map2 = class _Map2 {
|
|
|
2047
2863
|
const inner = [...map2].map(([key2, v]) => `${key2} => ${v}`).join(", ");
|
|
2048
2864
|
entries.push(`${key1} => { ${inner} }`);
|
|
2049
2865
|
}
|
|
2050
|
-
return `Map2(${this.size})
|
|
2866
|
+
return entries.length === 0 ? `Map2(0){ }` : `Map2(${this.size}){ ${entries} }`;
|
|
2051
2867
|
}
|
|
2052
2868
|
};
|
|
2869
|
+
|
|
2870
|
+
// src/core/map3.ts
|
|
2053
2871
|
var Map3 = class _Map3 {
|
|
2054
2872
|
constructor(entries) {
|
|
2055
2873
|
__publicField(this, "map1", /* @__PURE__ */ new Map());
|
|
@@ -2086,7 +2904,7 @@ var Map3 = class _Map3 {
|
|
|
2086
2904
|
}
|
|
2087
2905
|
getOrCreate(key1, key2, key3, creatorOrValue) {
|
|
2088
2906
|
if (!this.has(key1, key2, key3)) {
|
|
2089
|
-
const value =
|
|
2907
|
+
const value = isFunction2(creatorOrValue) ? creatorOrValue() : creatorOrValue;
|
|
2090
2908
|
this.set(key1, key2, key3, value);
|
|
2091
2909
|
return value;
|
|
2092
2910
|
}
|
|
@@ -2198,25 +3016,38 @@ var Map3 = class _Map3 {
|
|
|
2198
3016
|
}
|
|
2199
3017
|
return true;
|
|
2200
3018
|
}
|
|
2201
|
-
filter(
|
|
2202
|
-
|
|
3019
|
+
filter(predicate) {
|
|
3020
|
+
const result = new this.constructor();
|
|
2203
3021
|
for (const [key1, map2] of this.map1) {
|
|
2204
3022
|
for (const [key2, map3] of map2) {
|
|
2205
3023
|
for (const [key3, value] of map3) {
|
|
2206
|
-
if (
|
|
3024
|
+
if (predicate(value, key1, key2, key3, this)) result.set(key1, key2, key3, value);
|
|
2207
3025
|
}
|
|
2208
3026
|
}
|
|
2209
3027
|
}
|
|
2210
3028
|
return result;
|
|
2211
3029
|
}
|
|
2212
3030
|
reduce(fn, init) {
|
|
2213
|
-
let
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
}
|
|
3031
|
+
let iterator = this.entries();
|
|
3032
|
+
let first = iterator.next();
|
|
3033
|
+
if (first.done) {
|
|
3034
|
+
if (arguments.length < 2) {
|
|
3035
|
+
throw new TypeError("Reduce of empty Map3 with no initial value!");
|
|
2219
3036
|
}
|
|
3037
|
+
return init;
|
|
3038
|
+
}
|
|
3039
|
+
let acc;
|
|
3040
|
+
let start;
|
|
3041
|
+
if (arguments.length < 2) {
|
|
3042
|
+
acc = first.value[3];
|
|
3043
|
+
start = iterator.next();
|
|
3044
|
+
} else {
|
|
3045
|
+
acc = init;
|
|
3046
|
+
start = first;
|
|
3047
|
+
}
|
|
3048
|
+
for (let current = start; !current.done; current = iterator.next()) {
|
|
3049
|
+
const [key1, key2, key3, value] = current.value;
|
|
3050
|
+
acc = fn(acc, value, key1, key2, key3);
|
|
2220
3051
|
}
|
|
2221
3052
|
return acc;
|
|
2222
3053
|
}
|
|
@@ -2261,7 +3092,7 @@ var Map3 = class _Map3 {
|
|
|
2261
3092
|
entries.push(`${key1} => ${key2} => { ${inner} }`);
|
|
2262
3093
|
}
|
|
2263
3094
|
}
|
|
2264
|
-
return `Map3(${this.size})
|
|
3095
|
+
return entries.length === 0 ? `Map3(0){ }` : `Map3(${this.size}){ ${entries.join(", ")} }`;
|
|
2265
3096
|
}
|
|
2266
3097
|
};
|
|
2267
3098
|
|
|
@@ -2333,10 +3164,89 @@ var MultiContainer = class {
|
|
|
2333
3164
|
function asMulti(base) {
|
|
2334
3165
|
return new MultiContainer(base);
|
|
2335
3166
|
}
|
|
3167
|
+
|
|
3168
|
+
// src/deprecated/vec2.ts
|
|
3169
|
+
var Vec2 = class _Vec2 {
|
|
3170
|
+
constructor(x, y) {
|
|
3171
|
+
__publicField(this, "x");
|
|
3172
|
+
__publicField(this, "y");
|
|
3173
|
+
this.x = x ?? 0;
|
|
3174
|
+
this.y = y ?? 0;
|
|
3175
|
+
}
|
|
3176
|
+
length() {
|
|
3177
|
+
return Math.sqrt(this.x * this.x + this.y * this.y);
|
|
3178
|
+
}
|
|
3179
|
+
add(a) {
|
|
3180
|
+
return new _Vec2(this.x + a.x, this.y + a.y);
|
|
3181
|
+
}
|
|
3182
|
+
sub(a) {
|
|
3183
|
+
return new _Vec2(this.x - a.x, this.y - a.y);
|
|
3184
|
+
}
|
|
3185
|
+
mul(a) {
|
|
3186
|
+
return new _Vec2(this.x * a, this.y * a);
|
|
3187
|
+
}
|
|
3188
|
+
div(a) {
|
|
3189
|
+
return new _Vec2(this.x / a, this.y / a);
|
|
3190
|
+
}
|
|
3191
|
+
};
|
|
3192
|
+
|
|
3193
|
+
// src/deprecated/small-int-cache.ts
|
|
3194
|
+
var SmallIntCache = class {
|
|
3195
|
+
// for keys < 0
|
|
3196
|
+
constructor() {
|
|
3197
|
+
__publicField(this, "pos");
|
|
3198
|
+
// for keys >= 0
|
|
3199
|
+
__publicField(this, "neg");
|
|
3200
|
+
this.pos = [];
|
|
3201
|
+
this.neg = [];
|
|
3202
|
+
}
|
|
3203
|
+
set(key, value) {
|
|
3204
|
+
if (!guard_exports.isInteger(key)) {
|
|
3205
|
+
throw new Error("Key must be an integer");
|
|
3206
|
+
} else if (key >= 0) {
|
|
3207
|
+
this.pos[key] = value;
|
|
3208
|
+
} else {
|
|
3209
|
+
this.neg[-key - 1] = value;
|
|
3210
|
+
}
|
|
3211
|
+
}
|
|
3212
|
+
get(key) {
|
|
3213
|
+
if (!guard_exports.isInteger(key)) {
|
|
3214
|
+
throw new Error("Key must be an integer");
|
|
3215
|
+
} else if (key >= 0) {
|
|
3216
|
+
return this.pos[key];
|
|
3217
|
+
} else {
|
|
3218
|
+
return this.neg[-key - 1];
|
|
3219
|
+
}
|
|
3220
|
+
}
|
|
3221
|
+
has(key) {
|
|
3222
|
+
if (!guard_exports.isInteger(key)) {
|
|
3223
|
+
return false;
|
|
3224
|
+
} else if (key >= 0) {
|
|
3225
|
+
return key in this.pos;
|
|
3226
|
+
} else {
|
|
3227
|
+
return -key - 1 in this.neg;
|
|
3228
|
+
}
|
|
3229
|
+
}
|
|
3230
|
+
delete(key) {
|
|
3231
|
+
if (!guard_exports.isInteger(key)) {
|
|
3232
|
+
return;
|
|
3233
|
+
} else if (key >= 0) {
|
|
3234
|
+
delete this.pos[key];
|
|
3235
|
+
} else {
|
|
3236
|
+
delete this.neg[-key - 1];
|
|
3237
|
+
}
|
|
3238
|
+
}
|
|
3239
|
+
clear() {
|
|
3240
|
+
this.pos = [];
|
|
3241
|
+
this.neg = [];
|
|
3242
|
+
}
|
|
3243
|
+
};
|
|
2336
3244
|
export {
|
|
2337
|
-
Assert,
|
|
2338
|
-
Cookies,
|
|
2339
|
-
Device,
|
|
3245
|
+
assert_exports as Assert,
|
|
3246
|
+
cookies_exports as Cookies,
|
|
3247
|
+
device_exports as Device,
|
|
3248
|
+
DivRect,
|
|
3249
|
+
guard_exports as Guard,
|
|
2340
3250
|
IndexArray,
|
|
2341
3251
|
LRUCache,
|
|
2342
3252
|
Map1,
|
|
@@ -2347,6 +3257,7 @@ export {
|
|
|
2347
3257
|
SmallIntCache,
|
|
2348
3258
|
Stack,
|
|
2349
3259
|
utils_exports as Utils,
|
|
3260
|
+
Vec,
|
|
2350
3261
|
Vec2,
|
|
2351
3262
|
asMulti
|
|
2352
3263
|
};
|