@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.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* TsUtilsLib v1.
|
|
1
|
+
/* TsUtilsLib v1.18.0 | (c) 2023 PahkaSoft | Licensed under the MIT License */
|
|
2
2
|
"use strict";
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -23,9 +23,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
23
23
|
// src/index.ts
|
|
24
24
|
var index_exports = {};
|
|
25
25
|
__export(index_exports, {
|
|
26
|
-
Assert: () =>
|
|
27
|
-
Cookies: () =>
|
|
28
|
-
Device: () =>
|
|
26
|
+
Assert: () => assert_exports,
|
|
27
|
+
Cookies: () => cookies_exports,
|
|
28
|
+
Device: () => device_exports,
|
|
29
|
+
DivRect: () => DivRect,
|
|
30
|
+
Guard: () => guard_exports,
|
|
29
31
|
IndexArray: () => IndexArray,
|
|
30
32
|
LRUCache: () => LRUCache,
|
|
31
33
|
Map1: () => Map1,
|
|
@@ -36,60 +38,57 @@ __export(index_exports, {
|
|
|
36
38
|
SmallIntCache: () => SmallIntCache,
|
|
37
39
|
Stack: () => Stack,
|
|
38
40
|
Utils: () => utils_exports,
|
|
41
|
+
Vec: () => Vec,
|
|
39
42
|
Vec2: () => Vec2,
|
|
40
43
|
asMulti: () => asMulti
|
|
41
44
|
});
|
|
42
45
|
module.exports = __toCommonJS(index_exports);
|
|
43
46
|
|
|
44
|
-
// src/
|
|
45
|
-
var
|
|
46
|
-
__export(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
getSequenceArray: () => getSequenceArray,
|
|
66
|
-
isArray: () => isArray,
|
|
67
|
-
mapRangeArray: () => mapRangeArray,
|
|
68
|
-
mapSequenceArray: () => mapSequenceArray,
|
|
69
|
-
removeDuplicates: () => removeDuplicates,
|
|
70
|
-
removeDuplicatesCmp: () => removeDuplicatesCmp,
|
|
71
|
-
toArray: () => toArray
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
// src/utils/is/index.ts
|
|
75
|
-
var is_exports = {};
|
|
76
|
-
__export(is_exports, {
|
|
47
|
+
// src/assert/index.ts
|
|
48
|
+
var assert_exports = {};
|
|
49
|
+
__export(assert_exports, {
|
|
50
|
+
array_elem: () => array_elem,
|
|
51
|
+
array_id: () => array_id,
|
|
52
|
+
assert: () => assert,
|
|
53
|
+
assertEnum: () => assertEnum,
|
|
54
|
+
eq: () => eq,
|
|
55
|
+
even: () => even,
|
|
56
|
+
fail: () => fail,
|
|
57
|
+
finite: () => finite,
|
|
58
|
+
in_group: () => in_group,
|
|
59
|
+
int: () => int,
|
|
60
|
+
int_between: () => int_between,
|
|
61
|
+
int_between_exclusive: () => int_between_exclusive,
|
|
62
|
+
int_eq: () => int_eq,
|
|
63
|
+
int_gt: () => int_gt,
|
|
64
|
+
int_gte: () => int_gte,
|
|
65
|
+
int_lt: () => int_lt,
|
|
66
|
+
int_lte: () => int_lte,
|
|
67
|
+
interrupt: () => interrupt,
|
|
77
68
|
isArray: () => isArray,
|
|
69
|
+
isArrayIndex: () => isArrayIndex,
|
|
78
70
|
isArrayOrUndefined: () => isArrayOrUndefined,
|
|
79
71
|
isBoolean: () => isBoolean,
|
|
80
72
|
isBooleanOrUndefined: () => isBooleanOrUndefined,
|
|
73
|
+
isDeepEqual: () => isDeepEqual,
|
|
81
74
|
isEmptyArray: () => isEmptyArray,
|
|
82
75
|
isEmptyArrayOrUndefined: () => isEmptyArrayOrUndefined,
|
|
83
76
|
isEmptyString: () => isEmptyString,
|
|
84
77
|
isEmptyStringOrUndefined: () => isEmptyStringOrUndefined,
|
|
85
78
|
isEnumValue: () => isEnumValue,
|
|
86
79
|
isEnumValueOrUndefined: () => isEnumValueOrUndefined,
|
|
80
|
+
isEqual: () => isEqual,
|
|
81
|
+
isEvenNumber: () => isEvenNumber,
|
|
82
|
+
isFalse: () => isFalse,
|
|
83
|
+
isFalseOrUndefined: () => isFalseOrUndefined,
|
|
87
84
|
isFinite: () => isFinite2,
|
|
88
85
|
isFunction: () => isFunction,
|
|
89
86
|
isFunctionOrUndefined: () => isFunctionOrUndefined,
|
|
87
|
+
isIncluded: () => isIncluded,
|
|
90
88
|
isInfinity: () => isInfinity,
|
|
91
89
|
isInteger: () => isInteger,
|
|
92
90
|
isIntegerBetween: () => isIntegerBetween,
|
|
91
|
+
isIntegerBetweenExclusive: () => isIntegerBetweenExclusive,
|
|
93
92
|
isIntegerEq: () => isIntegerEq,
|
|
94
93
|
isIntegerGt: () => isIntegerGt,
|
|
95
94
|
isIntegerGte: () => isIntegerGte,
|
|
@@ -105,143 +104,936 @@ __export(is_exports, {
|
|
|
105
104
|
isNull: () => isNull,
|
|
106
105
|
isNullish: () => isNullish,
|
|
107
106
|
isNumber: () => isNumber,
|
|
107
|
+
isNumberBetween: () => isNumberBetween,
|
|
108
|
+
isNumberBetweenExclusive: () => isNumberBetweenExclusive,
|
|
108
109
|
isNumberOrUndefined: () => isNumberOrUndefined,
|
|
109
110
|
isObject: () => isObject,
|
|
110
111
|
isObjectOrUndefined: () => isObjectOrUndefined,
|
|
112
|
+
isOddNumber: () => isOddNumber,
|
|
111
113
|
isPosInfinity: () => isPosInfinity,
|
|
112
114
|
isString: () => isString,
|
|
113
115
|
isStringOrUndefined: () => isStringOrUndefined,
|
|
114
|
-
|
|
116
|
+
isThrowing: () => isThrowing,
|
|
117
|
+
isTrue: () => isTrue,
|
|
118
|
+
isTrueOrUndefined: () => isTrueOrUndefined,
|
|
119
|
+
isTypedObject: () => isTypedObject,
|
|
120
|
+
isUndefined: () => isUndefined,
|
|
121
|
+
odd: () => odd,
|
|
122
|
+
require: () => require2,
|
|
123
|
+
requireDefined: () => requireDefined,
|
|
124
|
+
setErrorClass: () => setErrorClass
|
|
115
125
|
});
|
|
126
|
+
var errorConstructor = Error;
|
|
127
|
+
function setErrorClass(errorClass) {
|
|
128
|
+
errorConstructor = errorClass ?? Error;
|
|
129
|
+
}
|
|
130
|
+
function _fail(...msgs) {
|
|
131
|
+
let msg = msgs.join(", ");
|
|
132
|
+
throw new errorConstructor("Assertion Failed!" + (msg === "" ? "" : " " + msg));
|
|
133
|
+
}
|
|
134
|
+
function interrupt(msg) {
|
|
135
|
+
_fail("Interrupted!");
|
|
136
|
+
}
|
|
137
|
+
function assertEnum(enumVal, enumObj, name = "value") {
|
|
138
|
+
if (!guard_exports.isEnumValue(enumVal, enumObj))
|
|
139
|
+
_fail(`Invalid enum value ${enumVal}.`);
|
|
140
|
+
}
|
|
141
|
+
function int(value, msg) {
|
|
142
|
+
if (!guard_exports.isInteger(value))
|
|
143
|
+
_fail(`Expected ${value} to be integer.`, msg);
|
|
144
|
+
return value;
|
|
145
|
+
}
|
|
146
|
+
function eq(value1, value2, msg) {
|
|
147
|
+
if (value1 !== value2)
|
|
148
|
+
_fail(`Expected ${value1} to equal ${value2}.`, msg);
|
|
149
|
+
return value1;
|
|
150
|
+
}
|
|
151
|
+
function int_eq(value, compareTo, msg) {
|
|
152
|
+
if (!guard_exports.isIntegerEq(value, compareTo))
|
|
153
|
+
_fail(`Expected ${value} to be integer equal to ${compareTo}.`, msg);
|
|
154
|
+
return value;
|
|
155
|
+
}
|
|
156
|
+
function int_lt(value, compareTo, msg) {
|
|
157
|
+
if (!guard_exports.isIntegerLt(value, compareTo))
|
|
158
|
+
_fail(`Expected ${value} to be integer less than ${compareTo}.`, msg);
|
|
159
|
+
return value;
|
|
160
|
+
}
|
|
161
|
+
function int_lte(value, compareTo, msg) {
|
|
162
|
+
if (!guard_exports.isIntegerLte(value, compareTo))
|
|
163
|
+
_fail(`Expected ${value} to be integer less than or equal to ${compareTo}.`, msg);
|
|
164
|
+
return value;
|
|
165
|
+
}
|
|
166
|
+
function int_gt(value, compareTo, msg) {
|
|
167
|
+
if (!guard_exports.isIntegerGt(value, compareTo))
|
|
168
|
+
_fail(`Expected ${value} to be integer greater than ${compareTo}.`, msg);
|
|
169
|
+
return value;
|
|
170
|
+
}
|
|
171
|
+
function int_gte(value, compareTo, msg) {
|
|
172
|
+
if (!guard_exports.isIntegerGte(value, compareTo))
|
|
173
|
+
_fail(`Expected ${value} to be integer greater than or equal to ${compareTo}.`, msg);
|
|
174
|
+
return value;
|
|
175
|
+
}
|
|
176
|
+
function int_between(value, min, max, msg) {
|
|
177
|
+
if (!guard_exports.isIntegerBetween(value, min, max))
|
|
178
|
+
_fail(`Expected integer between ${min} <= ${value} <= ${max}.`, msg);
|
|
179
|
+
return value;
|
|
180
|
+
}
|
|
181
|
+
function int_between_exclusive(value, min, max, msg) {
|
|
182
|
+
if (!guard_exports.isIntegerBetweenExclusive(value, min, max))
|
|
183
|
+
_fail(`Expected integer between ${min} < ${value} < ${max}.`, msg);
|
|
184
|
+
return value;
|
|
185
|
+
}
|
|
186
|
+
function odd(value, msg) {
|
|
187
|
+
if (!guard_exports.isOddNumber(value))
|
|
188
|
+
_fail(`Expected ${value} to be odd number.`, msg);
|
|
189
|
+
return value;
|
|
190
|
+
}
|
|
191
|
+
function even(value, msg) {
|
|
192
|
+
if (!guard_exports.isEvenNumber(value))
|
|
193
|
+
_fail(`Expected ${value} to be even number.`, msg);
|
|
194
|
+
return value;
|
|
195
|
+
}
|
|
196
|
+
function in_group(value, group, msg) {
|
|
197
|
+
if (!group.some((e) => e === value))
|
|
198
|
+
_fail(`Expected ${value} to be in group [${group.map((v) => String(v)).join(", ")}].`, msg);
|
|
199
|
+
return value;
|
|
200
|
+
}
|
|
201
|
+
function finite(value, msg) {
|
|
202
|
+
if (!guard_exports.isFinite(value))
|
|
203
|
+
_fail(`Expected ${value} to be finite number.`, msg);
|
|
204
|
+
return value;
|
|
205
|
+
}
|
|
206
|
+
function array_id(array, index, msg) {
|
|
207
|
+
if (!guard_exports.isInteger(index) || !guard_exports.isArray(array) || index < 0 || index >= array.length)
|
|
208
|
+
_fail(`Expected ${index} to be array index in bounds [0..${array.length - 1}].`, msg);
|
|
209
|
+
return index;
|
|
210
|
+
}
|
|
211
|
+
function array_elem(array, index, msg) {
|
|
212
|
+
return array[array_id(array, index, msg)];
|
|
213
|
+
}
|
|
214
|
+
function assert(condition, msg) {
|
|
215
|
+
if (!condition) {
|
|
216
|
+
_fail(msg);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
function require2(value, msg) {
|
|
220
|
+
if (value == null) {
|
|
221
|
+
_fail(`Expected ${value} not to be nullish`, msg);
|
|
222
|
+
}
|
|
223
|
+
return value;
|
|
224
|
+
}
|
|
225
|
+
function requireDefined(value, msg) {
|
|
226
|
+
if (value === void 0) {
|
|
227
|
+
_fail(`Expected ${value} not to be undefined`, msg);
|
|
228
|
+
}
|
|
229
|
+
return value;
|
|
230
|
+
}
|
|
231
|
+
function fail(msg) {
|
|
232
|
+
_fail(msg);
|
|
233
|
+
}
|
|
234
|
+
function isEqual(value1, value2, msg) {
|
|
235
|
+
if (!guard_exports.isEqual(value1, value2))
|
|
236
|
+
_fail(`Expected ${value1} to equal with ${value2}`, msg);
|
|
237
|
+
return true;
|
|
238
|
+
}
|
|
239
|
+
function isDeepEqual(value1, value2, msg) {
|
|
240
|
+
if (!guard_exports.isDeepEqual(value1, value2))
|
|
241
|
+
_fail(`Expected ${value1} to deep equal with ${value2}`, msg);
|
|
242
|
+
return true;
|
|
243
|
+
}
|
|
244
|
+
function isUndefined(value, msg) {
|
|
245
|
+
if (!guard_exports.isUndefined(value))
|
|
246
|
+
_fail(`Expected ${value} to be undefined`, msg);
|
|
247
|
+
return true;
|
|
248
|
+
}
|
|
249
|
+
function isNull(value, msg) {
|
|
250
|
+
if (!guard_exports.isNull(value))
|
|
251
|
+
_fail(`Expected ${value} to be null`, msg);
|
|
252
|
+
return true;
|
|
253
|
+
}
|
|
254
|
+
function isNullish(value, msg) {
|
|
255
|
+
if (!guard_exports.isNullish(value))
|
|
256
|
+
_fail(`Expected ${value} to be null or undefined`, msg);
|
|
257
|
+
return true;
|
|
258
|
+
}
|
|
259
|
+
function isObject(value, msg) {
|
|
260
|
+
if (!guard_exports.isObject(value))
|
|
261
|
+
_fail(`Expected ${value} to be object`, msg);
|
|
262
|
+
return true;
|
|
263
|
+
}
|
|
264
|
+
function isObjectOrUndefined(value, msg) {
|
|
265
|
+
if (!guard_exports.isObjectOrUndefined(value))
|
|
266
|
+
_fail(`Expected ${value} to be object or undefined`, msg);
|
|
267
|
+
return true;
|
|
268
|
+
}
|
|
269
|
+
function isTypedObject(obj, keys, msg) {
|
|
270
|
+
if (!guard_exports.isTypedObject(obj, keys))
|
|
271
|
+
_fail(`Expected ${obj} to be object with keys [${keys.map((key) => `'${String(key)}'`).join(", ")}]`, msg);
|
|
272
|
+
return true;
|
|
273
|
+
}
|
|
274
|
+
function isArray(value, msg) {
|
|
275
|
+
if (!guard_exports.isArray(value))
|
|
276
|
+
_fail(`Expected ${value} to be array`, msg);
|
|
277
|
+
return true;
|
|
278
|
+
}
|
|
279
|
+
function isArrayOrUndefined(value, msg) {
|
|
280
|
+
if (!guard_exports.isArrayOrUndefined(value))
|
|
281
|
+
_fail(`Expected ${value} to be array or undefined`, msg);
|
|
282
|
+
return true;
|
|
283
|
+
}
|
|
284
|
+
function isEmptyArray(value, msg) {
|
|
285
|
+
if (!guard_exports.isEmptyArray(value))
|
|
286
|
+
_fail(`Expected ${value} to be empty array`, msg);
|
|
287
|
+
return true;
|
|
288
|
+
}
|
|
289
|
+
function isNonEmptyArray(value, msg) {
|
|
290
|
+
if (!guard_exports.isNonEmptyArray(value))
|
|
291
|
+
_fail(`Expected ${value} to be non-empty array`, msg);
|
|
292
|
+
return true;
|
|
293
|
+
}
|
|
294
|
+
function isEmptyArrayOrUndefined(value, msg) {
|
|
295
|
+
if (!guard_exports.isEmptyArrayOrUndefined(value))
|
|
296
|
+
_fail(`Expected ${value} to be empty array or undefined`, msg);
|
|
297
|
+
return true;
|
|
298
|
+
}
|
|
299
|
+
function isNonEmptyArrayOrUndefined(value, msg) {
|
|
300
|
+
if (!guard_exports.isNonEmptyArrayOrUndefined(value))
|
|
301
|
+
_fail(`Expected ${value} to be non-empty array or undefined`, msg);
|
|
302
|
+
return true;
|
|
303
|
+
}
|
|
304
|
+
function isString(value, msg) {
|
|
305
|
+
if (!guard_exports.isString(value))
|
|
306
|
+
_fail(`Expected ${value} to be string`, msg);
|
|
307
|
+
return true;
|
|
308
|
+
}
|
|
309
|
+
function isEmptyString(value, msg) {
|
|
310
|
+
if (!guard_exports.isEmptyString(value))
|
|
311
|
+
_fail(`Expected ${value} to be empty string`, msg);
|
|
312
|
+
return true;
|
|
313
|
+
}
|
|
314
|
+
function isNonEmptyString(value, msg) {
|
|
315
|
+
if (!guard_exports.isNonEmptyString(value))
|
|
316
|
+
_fail(`Expected ${value} to be non-empty string`, msg);
|
|
317
|
+
return true;
|
|
318
|
+
}
|
|
319
|
+
function isStringOrUndefined(value, msg) {
|
|
320
|
+
if (!guard_exports.isStringOrUndefined(value))
|
|
321
|
+
_fail(`Expected ${value} to be string or undefined`, msg);
|
|
322
|
+
return true;
|
|
323
|
+
}
|
|
324
|
+
function isEmptyStringOrUndefined(value, msg) {
|
|
325
|
+
if (!guard_exports.isEmptyStringOrUndefined(value))
|
|
326
|
+
_fail(`Expected ${value} to be empty string or undefined`, msg);
|
|
327
|
+
return true;
|
|
328
|
+
}
|
|
329
|
+
function isNonEmptyStringOrUndefined(value, msg) {
|
|
330
|
+
if (!guard_exports.isNonEmptyStringOrUndefined(value))
|
|
331
|
+
_fail(`Expected ${value} to be non-empty string or undefined`, msg);
|
|
332
|
+
return true;
|
|
333
|
+
}
|
|
334
|
+
function isBoolean(value, msg) {
|
|
335
|
+
if (!guard_exports.isBoolean(value))
|
|
336
|
+
_fail(`Expected ${value} to be boolean`, msg);
|
|
337
|
+
return true;
|
|
338
|
+
}
|
|
339
|
+
function isBooleanOrUndefined(value, msg) {
|
|
340
|
+
if (!guard_exports.isBooleanOrUndefined(value))
|
|
341
|
+
_fail(`Expected ${value} to be boolean or undefined`, msg);
|
|
342
|
+
return true;
|
|
343
|
+
}
|
|
344
|
+
function isTrue(value, msg) {
|
|
345
|
+
if (!guard_exports.isTrue(value))
|
|
346
|
+
_fail(`Expected ${value} to be true`, msg);
|
|
347
|
+
return true;
|
|
348
|
+
}
|
|
349
|
+
function isTrueOrUndefined(value, msg) {
|
|
350
|
+
if (!guard_exports.isTrueOrUndefined(value))
|
|
351
|
+
_fail(`Expected ${value} to be true or undefined`, msg);
|
|
352
|
+
return true;
|
|
353
|
+
}
|
|
354
|
+
function isFalse(value, msg) {
|
|
355
|
+
if (!guard_exports.isFalse(value))
|
|
356
|
+
_fail(`Expected ${value} to be false`, msg);
|
|
357
|
+
return true;
|
|
358
|
+
}
|
|
359
|
+
function isFalseOrUndefined(value, msg) {
|
|
360
|
+
if (!guard_exports.isFalseOrUndefined(value))
|
|
361
|
+
_fail(`Expected ${value} to be false or undefined`, msg);
|
|
362
|
+
return true;
|
|
363
|
+
}
|
|
364
|
+
function isFunction(value, msg) {
|
|
365
|
+
if (!guard_exports.isFunction(value))
|
|
366
|
+
_fail(`Expected ${value} to be function`, msg);
|
|
367
|
+
return true;
|
|
368
|
+
}
|
|
369
|
+
function isFunctionOrUndefined(value, msg) {
|
|
370
|
+
if (!guard_exports.isFunctionOrUndefined(value))
|
|
371
|
+
_fail(`Expected ${value} to be function or undefined`, msg);
|
|
372
|
+
return true;
|
|
373
|
+
}
|
|
374
|
+
function isEnumValue(enumValue, enumObject, msg) {
|
|
375
|
+
if (!guard_exports.isEnumValue(enumValue, enumObject))
|
|
376
|
+
_fail(`Expected ${enumValue} to be enum value`, msg);
|
|
377
|
+
return true;
|
|
378
|
+
}
|
|
379
|
+
function isEnumValueOrUndefined(enumValue, enumObject, msg) {
|
|
380
|
+
if (!guard_exports.isEnumValueOrUndefined(enumValue, enumObject))
|
|
381
|
+
_fail(`Expected ${enumValue} to be enum value or undefined`, msg);
|
|
382
|
+
return true;
|
|
383
|
+
}
|
|
384
|
+
function isNumber(value, msg) {
|
|
385
|
+
if (!guard_exports.isNumber(value))
|
|
386
|
+
_fail(`Expected ${value} to be number`, msg);
|
|
387
|
+
return true;
|
|
388
|
+
}
|
|
389
|
+
function isNumberOrUndefined(value, msg) {
|
|
390
|
+
if (!guard_exports.isNumberOrUndefined(value))
|
|
391
|
+
_fail(`Expected ${value} to be number or undefined`, msg);
|
|
392
|
+
return true;
|
|
393
|
+
}
|
|
394
|
+
function isFinite2(value, msg) {
|
|
395
|
+
if (!guard_exports.isFinite(value))
|
|
396
|
+
_fail(`Expected ${value} to be finite`, msg);
|
|
397
|
+
return true;
|
|
398
|
+
}
|
|
399
|
+
function isInteger(value, msg) {
|
|
400
|
+
if (!guard_exports.isInteger(value))
|
|
401
|
+
_fail(`Expected ${value} to be integer`, msg);
|
|
402
|
+
return true;
|
|
403
|
+
}
|
|
404
|
+
function isIntegerOrUndefined(value, msg) {
|
|
405
|
+
if (!guard_exports.isIntegerOrUndefined(value))
|
|
406
|
+
_fail(`Expected ${value} to be integer or undefined`, msg);
|
|
407
|
+
return true;
|
|
408
|
+
}
|
|
409
|
+
function isIntegerEq(value, compareTo, msg) {
|
|
410
|
+
if (!guard_exports.isIntegerEq(value, compareTo))
|
|
411
|
+
_fail(`Expected ${value} to be integer equal to ${compareTo}`, msg);
|
|
412
|
+
return true;
|
|
413
|
+
}
|
|
414
|
+
function isIntegerGt(value, compareTo, msg) {
|
|
415
|
+
if (!guard_exports.isIntegerGt(value, compareTo))
|
|
416
|
+
_fail(`Expected ${value} to be integer > ${compareTo}`, msg);
|
|
417
|
+
return true;
|
|
418
|
+
}
|
|
419
|
+
function isIntegerGte(value, compareTo, msg) {
|
|
420
|
+
if (!guard_exports.isIntegerGte(value, compareTo))
|
|
421
|
+
_fail(`Expected ${value} to be integer >= ${compareTo}`, msg);
|
|
422
|
+
return true;
|
|
423
|
+
}
|
|
424
|
+
function isIntegerLt(value, compareTo, msg) {
|
|
425
|
+
if (!guard_exports.isIntegerLt(value, compareTo))
|
|
426
|
+
_fail(`Expected ${value} to be integer < ${compareTo}`, msg);
|
|
427
|
+
return true;
|
|
428
|
+
}
|
|
429
|
+
function isIntegerLte(value, compareTo, msg) {
|
|
430
|
+
if (!guard_exports.isIntegerLte(value, compareTo))
|
|
431
|
+
_fail(`Expected ${value} to be integer <= ${compareTo}`, msg);
|
|
432
|
+
return true;
|
|
433
|
+
}
|
|
434
|
+
function isIntegerBetween(value, min, max, msg) {
|
|
435
|
+
if (!guard_exports.isIntegerBetween(value, min, max))
|
|
436
|
+
_fail(`Expected integer ${min} <= ${value} <= ${max}.`, msg);
|
|
437
|
+
return true;
|
|
438
|
+
}
|
|
439
|
+
function isIntegerBetweenExclusive(value, min, max, msg) {
|
|
440
|
+
if (!guard_exports.isIntegerBetweenExclusive(value, min, max))
|
|
441
|
+
_fail(`Expected integer ${min} < ${value} < ${max}.`, msg);
|
|
442
|
+
return true;
|
|
443
|
+
}
|
|
444
|
+
function isNumberBetween(value, min, max, msg) {
|
|
445
|
+
if (!guard_exports.isNumberBetween(value, min, max))
|
|
446
|
+
_fail(`Expected number ${min} <= ${value} <= ${max}.`, msg);
|
|
447
|
+
return true;
|
|
448
|
+
}
|
|
449
|
+
function isNumberBetweenExclusive(value, min, max, msg) {
|
|
450
|
+
if (!guard_exports.isNumberBetweenExclusive(value, min, max))
|
|
451
|
+
_fail(`Expected number ${min} < ${value} < ${max}.`, msg);
|
|
452
|
+
return true;
|
|
453
|
+
}
|
|
454
|
+
function isNaNValue(value, msg) {
|
|
455
|
+
if (!guard_exports.isNaNValue(value))
|
|
456
|
+
_fail(`Expected ${value} to be NaN.`, msg);
|
|
457
|
+
return true;
|
|
458
|
+
}
|
|
459
|
+
function isInfinity(value, msg) {
|
|
460
|
+
if (!guard_exports.isInfinity(value))
|
|
461
|
+
_fail(`Expected ${value} to be +-Infinity.`, msg);
|
|
462
|
+
return true;
|
|
463
|
+
}
|
|
464
|
+
function isPosInfinity(value, msg) {
|
|
465
|
+
if (!guard_exports.isPosInfinity(value))
|
|
466
|
+
_fail(`Expected ${value} to be +Infinity.`, msg);
|
|
467
|
+
return true;
|
|
468
|
+
}
|
|
469
|
+
function isNegInfinity(value, msg) {
|
|
470
|
+
if (!guard_exports.isNegInfinity(value))
|
|
471
|
+
_fail(`Expected ${value} to be -Infinity.`, msg);
|
|
472
|
+
return true;
|
|
473
|
+
}
|
|
474
|
+
function isOddNumber(value, msg) {
|
|
475
|
+
if (!guard_exports.isOddNumber(value))
|
|
476
|
+
_fail(`Expected ${value} to odd number.`, msg);
|
|
477
|
+
return true;
|
|
478
|
+
}
|
|
479
|
+
function isEvenNumber(value, msg) {
|
|
480
|
+
if (!guard_exports.isEvenNumber(value))
|
|
481
|
+
_fail(`Expected ${value} to even number.`, msg);
|
|
482
|
+
return true;
|
|
483
|
+
}
|
|
484
|
+
function isIncluded(value, array, msg) {
|
|
485
|
+
if (!guard_exports.isIncluded(value, array))
|
|
486
|
+
_fail(`Expected ${value} to be included in [${array.map((v) => String(v)).join(", ")}].`, msg);
|
|
487
|
+
return true;
|
|
488
|
+
}
|
|
489
|
+
function isArrayIndex(index, array, msg) {
|
|
490
|
+
if (!guard_exports.isArrayIndex(index, array))
|
|
491
|
+
_fail(`Expected ${index} to be index for array [${array.map((v) => String(v)).join(", ")}]`, msg);
|
|
492
|
+
return true;
|
|
493
|
+
}
|
|
494
|
+
function isThrowing(throwTestFn, msg) {
|
|
495
|
+
if (!guard_exports.isThrowing(throwTestFn))
|
|
496
|
+
_fail(`Expected to throw`, msg);
|
|
497
|
+
return true;
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
// src/web/cookies.ts
|
|
501
|
+
var cookies_exports = {};
|
|
502
|
+
__export(cookies_exports, {
|
|
503
|
+
accept: () => accept,
|
|
504
|
+
decline: () => decline,
|
|
505
|
+
erase: () => erase,
|
|
506
|
+
eraseAll: () => eraseAll,
|
|
507
|
+
isConsentPending: () => isConsentPending,
|
|
508
|
+
read: () => read,
|
|
509
|
+
readBool: () => readBool,
|
|
510
|
+
readInt: () => readInt,
|
|
511
|
+
save: () => save,
|
|
512
|
+
setExpireDays: () => setExpireDays
|
|
513
|
+
});
|
|
514
|
+
var ConsentCookieName = "ConsentCookie";
|
|
515
|
+
var _consent;
|
|
516
|
+
var _expires;
|
|
517
|
+
var str = _read(ConsentCookieName);
|
|
518
|
+
_consent = str === "accept" /* Accept */ || str === "decline" /* Decline */ ? str : void 0;
|
|
519
|
+
function setExpireDays(days) {
|
|
520
|
+
_expires = /* @__PURE__ */ new Date();
|
|
521
|
+
_expires.setDate(_expires.getDate() + days);
|
|
522
|
+
}
|
|
523
|
+
function isConsentPending() {
|
|
524
|
+
return _consent === void 0;
|
|
525
|
+
}
|
|
526
|
+
function accept() {
|
|
527
|
+
_consent = "accept" /* Accept */;
|
|
528
|
+
_save(ConsentCookieName, _consent);
|
|
529
|
+
}
|
|
530
|
+
function decline() {
|
|
531
|
+
_consent = "decline" /* Decline */;
|
|
532
|
+
_save(ConsentCookieName, _consent);
|
|
533
|
+
}
|
|
534
|
+
function _getList() {
|
|
535
|
+
let s = document.cookie;
|
|
536
|
+
return s.split(";").map((c) => c.trim());
|
|
537
|
+
}
|
|
538
|
+
function _save(name, value) {
|
|
539
|
+
let cookie = name + "=" + value.toString() + ";sameSite=Lax;";
|
|
540
|
+
if (_expires) {
|
|
541
|
+
cookie += "expires=" + _expires.toUTCString() + ";";
|
|
542
|
+
}
|
|
543
|
+
document.cookie = cookie;
|
|
544
|
+
return value;
|
|
545
|
+
}
|
|
546
|
+
function _read(name, defaultValue) {
|
|
547
|
+
let str2 = _getList().find((c) => c.startsWith(name + "="));
|
|
548
|
+
return str2 === void 0 ? defaultValue : str2.substring(name.length + 1);
|
|
549
|
+
}
|
|
550
|
+
function _erase(name) {
|
|
551
|
+
document.cookie = name + "=;expires=Thu, 01 Jan 1970 00:00:00 UTC;";
|
|
552
|
+
}
|
|
553
|
+
function save(name, value) {
|
|
554
|
+
if (_consent === "accept" /* Accept */) {
|
|
555
|
+
_save(name, value);
|
|
556
|
+
}
|
|
557
|
+
return value;
|
|
558
|
+
}
|
|
559
|
+
function read(name, defaultValue) {
|
|
560
|
+
if (_consent === "accept" /* Accept */) {
|
|
561
|
+
return _read(name, defaultValue) || defaultValue;
|
|
562
|
+
} else {
|
|
563
|
+
return defaultValue;
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
function readInt(name, defaultValue) {
|
|
567
|
+
if (_consent === "accept" /* Accept */) {
|
|
568
|
+
let str2 = _read(name);
|
|
569
|
+
return str2 === void 0 ? defaultValue : parseInt(str2);
|
|
570
|
+
} else {
|
|
571
|
+
return defaultValue;
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
function readBool(name, defaultValue) {
|
|
575
|
+
if (_consent === "accept" /* Accept */) {
|
|
576
|
+
let str2 = _read(name);
|
|
577
|
+
return str2 === void 0 ? defaultValue : /true|1/i.test(str2);
|
|
578
|
+
} else {
|
|
579
|
+
return defaultValue;
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
function erase(name) {
|
|
583
|
+
if (_consent === "accept" /* Accept */ || name === ConsentCookieName) {
|
|
584
|
+
_erase(name);
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
function eraseAll() {
|
|
588
|
+
document.cookie.split(";").forEach((c) => erase(c.trim().split("=")[0]));
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
// src/web/device.ts
|
|
592
|
+
var device_exports = {};
|
|
593
|
+
__export(device_exports, {
|
|
594
|
+
DPI: () => DPI,
|
|
595
|
+
FontSize: () => FontSize,
|
|
596
|
+
HostAddress: () => HostAddress,
|
|
597
|
+
IsMobileDevice: () => IsMobileDevice,
|
|
598
|
+
IsTouchDevice: () => IsTouchDevice,
|
|
599
|
+
PxPerMm: () => PxPerMm,
|
|
600
|
+
ScrollbarWidth: () => ScrollbarWidth,
|
|
601
|
+
mmToPx: () => mmToPx,
|
|
602
|
+
pxToMm: () => pxToMm,
|
|
603
|
+
toPx: () => toPx
|
|
604
|
+
});
|
|
605
|
+
function getDPI() {
|
|
606
|
+
let el = document.createElement("div");
|
|
607
|
+
el.style.width = "1in";
|
|
608
|
+
document.body.appendChild(el);
|
|
609
|
+
let dpi = el.offsetWidth;
|
|
610
|
+
el.remove();
|
|
611
|
+
return dpi || 96;
|
|
612
|
+
}
|
|
613
|
+
function getScrollBarWidth() {
|
|
614
|
+
try {
|
|
615
|
+
let outer = document.createElement("div");
|
|
616
|
+
outer.style.visibility = "hidden";
|
|
617
|
+
outer.style.width = "100px";
|
|
618
|
+
document.body.appendChild(outer);
|
|
619
|
+
let widthNoScroll = outer.offsetWidth;
|
|
620
|
+
outer.style.overflow = "scroll";
|
|
621
|
+
let inner = document.createElement("div");
|
|
622
|
+
inner.style.width = "100%";
|
|
623
|
+
outer.appendChild(inner);
|
|
624
|
+
let widthWithScroll = inner.offsetWidth;
|
|
625
|
+
if (outer.parentNode) {
|
|
626
|
+
outer.parentNode.removeChild(outer);
|
|
627
|
+
}
|
|
628
|
+
return widthNoScroll - widthWithScroll;
|
|
629
|
+
} catch (e) {
|
|
630
|
+
return 0;
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
function getSystemFontSize() {
|
|
634
|
+
let tmpDiv = document.createElement("div");
|
|
635
|
+
tmpDiv.style.cssText = "display:inline-block; padding:0; line-height:1; position:absolute; visibility:hidden; font-size:1em";
|
|
636
|
+
tmpDiv.appendChild(document.createTextNode("M"));
|
|
637
|
+
document.body.appendChild(tmpDiv);
|
|
638
|
+
let fontsize = tmpDiv.offsetHeight;
|
|
639
|
+
document.body.removeChild(tmpDiv);
|
|
640
|
+
return fontsize;
|
|
641
|
+
}
|
|
642
|
+
function getIsTouchDevice() {
|
|
643
|
+
if ("ontouchstart" in window || "DocumentTouch" in window || "createTouch" in document && "createTouchList" in document) {
|
|
644
|
+
return true;
|
|
645
|
+
}
|
|
646
|
+
var prefixes = " -webkit- -moz- -o- -ms- ".split(" ");
|
|
647
|
+
var mq = function(query2) {
|
|
648
|
+
return window.matchMedia(query2).matches;
|
|
649
|
+
};
|
|
650
|
+
var query = ["(", prefixes.join("touch-enabled),("), "heartz", ")"].join("");
|
|
651
|
+
return mq(query);
|
|
652
|
+
}
|
|
653
|
+
function getIsMobileDevice() {
|
|
654
|
+
let a = navigator.userAgent || navigator.vendor || window.opera;
|
|
655
|
+
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));
|
|
656
|
+
}
|
|
657
|
+
function getHostAddress() {
|
|
658
|
+
return location.protocol + "//" + location.host;
|
|
659
|
+
}
|
|
660
|
+
var UnitRegExp = /^(mm|cm|in|inch|px|em)$/;
|
|
661
|
+
var ValueUnitRegExp = /^([0-9\\.]+)(.*)$/;
|
|
662
|
+
var DPI = getDPI();
|
|
663
|
+
var PxPerMm = DPI / 25.4;
|
|
664
|
+
var ScrollbarWidth = getScrollBarWidth();
|
|
665
|
+
var FontSize = getSystemFontSize();
|
|
666
|
+
var IsTouchDevice = getIsTouchDevice();
|
|
667
|
+
var IsMobileDevice = getIsMobileDevice();
|
|
668
|
+
var HostAddress = getHostAddress();
|
|
669
|
+
function pxToMm(px) {
|
|
670
|
+
return px / PxPerMm;
|
|
671
|
+
}
|
|
672
|
+
function mmToPx(mm) {
|
|
673
|
+
return mm * PxPerMm;
|
|
674
|
+
}
|
|
675
|
+
function toPx(input) {
|
|
676
|
+
if (typeof input === "number") {
|
|
677
|
+
return input;
|
|
678
|
+
}
|
|
679
|
+
let value = NaN;
|
|
680
|
+
let unit = void 0;
|
|
681
|
+
let match = input.toString().match(ValueUnitRegExp);
|
|
682
|
+
if (match && match[1]) {
|
|
683
|
+
value = parseFloat(match[1]);
|
|
684
|
+
let unitStr = match[2] ? match[2].toLowerCase() : "undefined";
|
|
685
|
+
let unitStrOk = UnitRegExp.test(unitStr);
|
|
686
|
+
unit = unitStrOk ? unitStr : void 0;
|
|
687
|
+
if (!unit) {
|
|
688
|
+
console.log("Unknown unit '" + unitStr + "' => using 'px'.");
|
|
689
|
+
}
|
|
690
|
+
} else {
|
|
691
|
+
value = parseFloat(input);
|
|
692
|
+
}
|
|
693
|
+
assert_exports.finite(value, "value in function toPx");
|
|
694
|
+
switch (unit) {
|
|
695
|
+
case "mm":
|
|
696
|
+
return mmToPx(value);
|
|
697
|
+
case "cm":
|
|
698
|
+
return mmToPx(value) * 10;
|
|
699
|
+
case "in":
|
|
700
|
+
case "inch":
|
|
701
|
+
return mmToPx(value) * 25.4;
|
|
702
|
+
case "em":
|
|
703
|
+
return FontSize * value;
|
|
704
|
+
default:
|
|
705
|
+
case "px":
|
|
706
|
+
return value;
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
// src/guard/index.ts
|
|
711
|
+
var guard_exports = {};
|
|
712
|
+
__export(guard_exports, {
|
|
713
|
+
isArray: () => isArray2,
|
|
714
|
+
isArrayIndex: () => isArrayIndex2,
|
|
715
|
+
isArrayOrUndefined: () => isArrayOrUndefined2,
|
|
716
|
+
isBoolean: () => isBoolean2,
|
|
717
|
+
isBooleanOrUndefined: () => isBooleanOrUndefined2,
|
|
718
|
+
isDeepEqual: () => isDeepEqual2,
|
|
719
|
+
isEmptyArray: () => isEmptyArray2,
|
|
720
|
+
isEmptyArrayOrUndefined: () => isEmptyArrayOrUndefined2,
|
|
721
|
+
isEmptyString: () => isEmptyString2,
|
|
722
|
+
isEmptyStringOrUndefined: () => isEmptyStringOrUndefined2,
|
|
723
|
+
isEnumValue: () => isEnumValue3,
|
|
724
|
+
isEnumValueOrUndefined: () => isEnumValueOrUndefined2,
|
|
725
|
+
isEqual: () => isEqual2,
|
|
726
|
+
isEvenNumber: () => isEvenNumber2,
|
|
727
|
+
isFalse: () => isFalse2,
|
|
728
|
+
isFalseOrUndefined: () => isFalseOrUndefined2,
|
|
729
|
+
isFinite: () => isFinite3,
|
|
730
|
+
isFunction: () => isFunction2,
|
|
731
|
+
isFunctionOrUndefined: () => isFunctionOrUndefined2,
|
|
732
|
+
isIncluded: () => isIncluded2,
|
|
733
|
+
isInfinity: () => isInfinity2,
|
|
734
|
+
isInteger: () => isInteger2,
|
|
735
|
+
isIntegerBetween: () => isIntegerBetween2,
|
|
736
|
+
isIntegerBetweenExclusive: () => isIntegerBetweenExclusive2,
|
|
737
|
+
isIntegerEq: () => isIntegerEq2,
|
|
738
|
+
isIntegerGt: () => isIntegerGt2,
|
|
739
|
+
isIntegerGte: () => isIntegerGte2,
|
|
740
|
+
isIntegerLt: () => isIntegerLt2,
|
|
741
|
+
isIntegerLte: () => isIntegerLte2,
|
|
742
|
+
isIntegerOrUndefined: () => isIntegerOrUndefined2,
|
|
743
|
+
isNaNValue: () => isNaNValue2,
|
|
744
|
+
isNegInfinity: () => isNegInfinity2,
|
|
745
|
+
isNonEmptyArray: () => isNonEmptyArray2,
|
|
746
|
+
isNonEmptyArrayOrUndefined: () => isNonEmptyArrayOrUndefined2,
|
|
747
|
+
isNonEmptyString: () => isNonEmptyString2,
|
|
748
|
+
isNonEmptyStringOrUndefined: () => isNonEmptyStringOrUndefined2,
|
|
749
|
+
isNull: () => isNull2,
|
|
750
|
+
isNullish: () => isNullish2,
|
|
751
|
+
isNumber: () => isNumber2,
|
|
752
|
+
isNumberBetween: () => isNumberBetween2,
|
|
753
|
+
isNumberBetweenExclusive: () => isNumberBetweenExclusive2,
|
|
754
|
+
isNumberOrUndefined: () => isNumberOrUndefined2,
|
|
755
|
+
isObject: () => isObject2,
|
|
756
|
+
isObjectOrUndefined: () => isObjectOrUndefined2,
|
|
757
|
+
isOddNumber: () => isOddNumber2,
|
|
758
|
+
isPosInfinity: () => isPosInfinity2,
|
|
759
|
+
isString: () => isString2,
|
|
760
|
+
isStringOrUndefined: () => isStringOrUndefined2,
|
|
761
|
+
isThrowing: () => isThrowing2,
|
|
762
|
+
isTrue: () => isTrue2,
|
|
763
|
+
isTrueOrUndefined: () => isTrueOrUndefined2,
|
|
764
|
+
isTypedObject: () => isTypedObject2,
|
|
765
|
+
isUndefined: () => isUndefined2,
|
|
766
|
+
tryOr: () => tryOr
|
|
767
|
+
});
|
|
768
|
+
|
|
769
|
+
// src/utils/obj/index.ts
|
|
770
|
+
var obj_exports = {};
|
|
771
|
+
__export(obj_exports, {
|
|
772
|
+
deepEqual: () => deepEqual,
|
|
773
|
+
hasProperties: () => hasProperties,
|
|
774
|
+
isObject: () => isObject2
|
|
775
|
+
});
|
|
776
|
+
function hasProperties(obj, props) {
|
|
777
|
+
return isObject2(obj) && props.every((p) => p in obj);
|
|
778
|
+
}
|
|
779
|
+
function deepEqual(a, b) {
|
|
780
|
+
if (a === b) return true;
|
|
781
|
+
if (a === null || b === null) return false;
|
|
782
|
+
if (typeof a !== "object" || typeof b !== "object") return false;
|
|
783
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
784
|
+
if (a.length !== b.length) return false;
|
|
785
|
+
return a.every((val, i) => deepEqual(val, b[i]));
|
|
786
|
+
}
|
|
787
|
+
if (Array.isArray(a) !== Array.isArray(b)) return false;
|
|
788
|
+
const keysA = Object.keys(a);
|
|
789
|
+
const keysB = Object.keys(b);
|
|
790
|
+
if (keysA.length !== keysB.length) return false;
|
|
791
|
+
for (const key of keysA) {
|
|
792
|
+
if (!Object.prototype.hasOwnProperty.call(b, key)) return false;
|
|
793
|
+
if (!deepEqual(a[key], b[key])) return false;
|
|
794
|
+
}
|
|
795
|
+
return true;
|
|
796
|
+
}
|
|
116
797
|
|
|
117
798
|
// src/utils/enum/index.ts
|
|
118
799
|
var enum_exports = {};
|
|
119
800
|
__export(enum_exports, {
|
|
120
|
-
|
|
801
|
+
assertEnumValue: () => assertEnumValue,
|
|
802
|
+
forEachEnum: () => forEachEnum,
|
|
803
|
+
getEnumEntries: () => getEnumEntries,
|
|
804
|
+
getEnumKey: () => getEnumKey,
|
|
805
|
+
getEnumKeys: () => getEnumKeys,
|
|
806
|
+
getEnumValues: () => getEnumValues,
|
|
807
|
+
isEnumValue: () => isEnumValue2
|
|
121
808
|
});
|
|
809
|
+
function getEnumKeys(e) {
|
|
810
|
+
return Object.keys(e).filter((k) => isNaN(Number(k)));
|
|
811
|
+
}
|
|
122
812
|
function getEnumValues(e) {
|
|
123
|
-
return
|
|
813
|
+
return getEnumKeys(e).map((k) => e[k]);
|
|
814
|
+
}
|
|
815
|
+
function getEnumEntries(e) {
|
|
816
|
+
return getEnumKeys(e).map((k) => [k, e[k]]);
|
|
817
|
+
}
|
|
818
|
+
function getEnumKey(e, value) {
|
|
819
|
+
return getEnumKeys(e).find((k) => e[k] === value);
|
|
820
|
+
}
|
|
821
|
+
function forEachEnum(e, callback) {
|
|
822
|
+
for (const [k, v] of getEnumEntries(e)) callback(k, v);
|
|
823
|
+
}
|
|
824
|
+
function isEnumValue2(e, value) {
|
|
825
|
+
return getEnumValues(e).includes(value);
|
|
826
|
+
}
|
|
827
|
+
function assertEnumValue(e, value) {
|
|
828
|
+
if (!isEnumValue2(e, value)) {
|
|
829
|
+
throw new TypeError(`Invalid enum value: ${String(value)}`);
|
|
830
|
+
}
|
|
124
831
|
}
|
|
125
832
|
|
|
126
|
-
// src/
|
|
127
|
-
function
|
|
833
|
+
// src/guard/index.ts
|
|
834
|
+
function isEqual2(value1, value2) {
|
|
835
|
+
return value1 === value2;
|
|
836
|
+
}
|
|
837
|
+
function isDeepEqual2(value1, value2) {
|
|
838
|
+
return deepEqual(value1, value2);
|
|
839
|
+
}
|
|
840
|
+
function isUndefined2(value) {
|
|
128
841
|
return value === void 0;
|
|
129
842
|
}
|
|
130
|
-
function
|
|
843
|
+
function isNull2(value) {
|
|
131
844
|
return value === null;
|
|
132
845
|
}
|
|
133
|
-
function
|
|
846
|
+
function isNullish2(value) {
|
|
134
847
|
return value === void 0 || value === null;
|
|
135
848
|
}
|
|
136
|
-
function
|
|
137
|
-
return typeof value === "object" && value !== null && !
|
|
849
|
+
function isObject2(value) {
|
|
850
|
+
return typeof value === "object" && value !== null && !isArray2(value);
|
|
851
|
+
}
|
|
852
|
+
function isObjectOrUndefined2(value) {
|
|
853
|
+
return value === void 0 || isObject2(value);
|
|
138
854
|
}
|
|
139
|
-
function
|
|
140
|
-
return
|
|
855
|
+
function isTypedObject2(obj, keys) {
|
|
856
|
+
return isObject2(obj) && keys.every((k) => k in obj);
|
|
141
857
|
}
|
|
142
|
-
function
|
|
858
|
+
function isArray2(a) {
|
|
143
859
|
return !!a && Object.prototype.toString.call(a) === "[object Array]";
|
|
144
860
|
}
|
|
145
|
-
function
|
|
146
|
-
return value === void 0 ||
|
|
861
|
+
function isArrayOrUndefined2(value) {
|
|
862
|
+
return value === void 0 || isArray2(value);
|
|
147
863
|
}
|
|
148
|
-
function
|
|
149
|
-
return
|
|
864
|
+
function isEmptyArray2(a) {
|
|
865
|
+
return isArray2(a) && a.length === 0;
|
|
150
866
|
}
|
|
151
|
-
function
|
|
152
|
-
return
|
|
867
|
+
function isNonEmptyArray2(a) {
|
|
868
|
+
return isArray2(a) && a.length > 0;
|
|
153
869
|
}
|
|
154
|
-
function
|
|
155
|
-
return
|
|
870
|
+
function isEmptyArrayOrUndefined2(a) {
|
|
871
|
+
return isArray2(a) && a.length === 0 || a === void 0;
|
|
156
872
|
}
|
|
157
|
-
function
|
|
158
|
-
return
|
|
873
|
+
function isNonEmptyArrayOrUndefined2(a) {
|
|
874
|
+
return isArray2(a) && a.length > 0 || a === void 0;
|
|
159
875
|
}
|
|
160
|
-
function
|
|
876
|
+
function isString2(value) {
|
|
161
877
|
return typeof value === "string";
|
|
162
878
|
}
|
|
163
|
-
function
|
|
879
|
+
function isEmptyString2(value) {
|
|
164
880
|
return typeof value === "string" && value.length === 0;
|
|
165
881
|
}
|
|
166
|
-
function
|
|
882
|
+
function isNonEmptyString2(value) {
|
|
167
883
|
return typeof value === "string" && value.length > 0;
|
|
168
884
|
}
|
|
169
|
-
function
|
|
885
|
+
function isStringOrUndefined2(value) {
|
|
170
886
|
return value === void 0 || typeof value === "string";
|
|
171
887
|
}
|
|
172
|
-
function
|
|
888
|
+
function isEmptyStringOrUndefined2(value) {
|
|
173
889
|
return typeof value === "string" && value.length === 0 || value === void 0;
|
|
174
890
|
}
|
|
175
|
-
function
|
|
891
|
+
function isNonEmptyStringOrUndefined2(value) {
|
|
176
892
|
return typeof value === "string" && value.length > 0 || value === void 0;
|
|
177
893
|
}
|
|
178
|
-
function
|
|
894
|
+
function isBoolean2(value) {
|
|
179
895
|
return typeof value === "boolean";
|
|
180
896
|
}
|
|
181
|
-
function
|
|
897
|
+
function isBooleanOrUndefined2(value) {
|
|
182
898
|
return value === void 0 || typeof value === "boolean";
|
|
183
899
|
}
|
|
184
|
-
function
|
|
900
|
+
function isTrue2(value) {
|
|
901
|
+
return value === true;
|
|
902
|
+
}
|
|
903
|
+
function isTrueOrUndefined2(value) {
|
|
904
|
+
return value === true || value === void 0;
|
|
905
|
+
}
|
|
906
|
+
function isFalse2(value) {
|
|
907
|
+
return value === false;
|
|
908
|
+
}
|
|
909
|
+
function isFalseOrUndefined2(value) {
|
|
910
|
+
return value === false || value === void 0;
|
|
911
|
+
}
|
|
912
|
+
function isFunction2(value) {
|
|
185
913
|
return typeof value === "function";
|
|
186
914
|
}
|
|
187
|
-
function
|
|
915
|
+
function isFunctionOrUndefined2(value) {
|
|
188
916
|
return value === void 0 || typeof value === "function";
|
|
189
917
|
}
|
|
190
|
-
function
|
|
918
|
+
function isEnumValue3(value, enumObj, name = "value") {
|
|
191
919
|
return getEnumValues(enumObj).some((v) => v === value);
|
|
192
920
|
}
|
|
193
|
-
function
|
|
921
|
+
function isEnumValueOrUndefined2(value, enumObj, name = "value") {
|
|
194
922
|
return value === void 0 || getEnumValues(enumObj).some((v) => v === value);
|
|
195
923
|
}
|
|
196
|
-
function
|
|
924
|
+
function isNumber2(value) {
|
|
197
925
|
return typeof value === "number";
|
|
198
926
|
}
|
|
199
|
-
function
|
|
927
|
+
function isNumberOrUndefined2(value) {
|
|
200
928
|
return typeof value === "number" || value === void 0;
|
|
201
929
|
}
|
|
202
|
-
function
|
|
930
|
+
function isFinite3(value) {
|
|
203
931
|
return typeof value === "number" && Number.isFinite(value);
|
|
204
932
|
}
|
|
205
|
-
function
|
|
206
|
-
return typeof n === "number" &&
|
|
933
|
+
function isInteger2(n) {
|
|
934
|
+
return typeof n === "number" && isFinite3(n) && n === Math.trunc(n);
|
|
935
|
+
}
|
|
936
|
+
function isIntegerOrUndefined2(n) {
|
|
937
|
+
return typeof n === "number" && isFinite3(n) && n === Math.trunc(n) || n === void 0;
|
|
207
938
|
}
|
|
208
|
-
function
|
|
209
|
-
return
|
|
939
|
+
function isIntegerEq2(value, compareTo) {
|
|
940
|
+
return isInteger2(value) && value === compareTo;
|
|
210
941
|
}
|
|
211
|
-
function
|
|
212
|
-
return
|
|
942
|
+
function isIntegerGt2(value, compareTo) {
|
|
943
|
+
return isInteger2(value) && isNumber2(compareTo) && value > compareTo;
|
|
213
944
|
}
|
|
214
|
-
function
|
|
215
|
-
return
|
|
945
|
+
function isIntegerGte2(value, compareTo) {
|
|
946
|
+
return isInteger2(value) && isNumber2(compareTo) && value >= compareTo;
|
|
216
947
|
}
|
|
217
|
-
function
|
|
218
|
-
return
|
|
948
|
+
function isIntegerLt2(value, compareTo) {
|
|
949
|
+
return isInteger2(value) && isNumber2(compareTo) && value < compareTo;
|
|
219
950
|
}
|
|
220
|
-
function
|
|
221
|
-
return
|
|
951
|
+
function isIntegerLte2(value, compareTo) {
|
|
952
|
+
return isInteger2(value) && isNumber2(compareTo) && value <= compareTo;
|
|
222
953
|
}
|
|
223
|
-
function
|
|
224
|
-
return
|
|
954
|
+
function isIntegerBetween2(value, min, max) {
|
|
955
|
+
return isInteger2(value) && isNumber2(min) && isNumber2(max) && value >= min && value <= max;
|
|
225
956
|
}
|
|
226
|
-
function
|
|
227
|
-
return
|
|
957
|
+
function isIntegerBetweenExclusive2(value, min, max) {
|
|
958
|
+
return isInteger2(value) && isNumber2(min) && isNumber2(max) && value > min && value < max;
|
|
228
959
|
}
|
|
229
|
-
function
|
|
960
|
+
function isNumberBetween2(value, min, max) {
|
|
961
|
+
return isNumber2(value) && isNumber2(min) && isNumber2(max) && value >= min && value <= max;
|
|
962
|
+
}
|
|
963
|
+
function isNumberBetweenExclusive2(value, min, max) {
|
|
964
|
+
return isNumber2(value) && isNumber2(min) && isNumber2(max) && value > min && value < max;
|
|
965
|
+
}
|
|
966
|
+
function isNaNValue2(value) {
|
|
230
967
|
return typeof value === "number" && Number.isNaN(value);
|
|
231
968
|
}
|
|
232
|
-
function
|
|
969
|
+
function isInfinity2(value) {
|
|
233
970
|
return typeof value === "number" && Math.abs(value) === Infinity;
|
|
234
971
|
}
|
|
235
|
-
function
|
|
972
|
+
function isPosInfinity2(value) {
|
|
236
973
|
return typeof value === "number" && value === Infinity;
|
|
237
974
|
}
|
|
238
|
-
function
|
|
975
|
+
function isNegInfinity2(value) {
|
|
239
976
|
return typeof value === "number" && value === -Infinity;
|
|
240
977
|
}
|
|
978
|
+
function isOddNumber2(value) {
|
|
979
|
+
return isInteger2(value) && value % 2 === 1;
|
|
980
|
+
}
|
|
981
|
+
function isEvenNumber2(value) {
|
|
982
|
+
return isInteger2(value) && value % 2 === 0;
|
|
983
|
+
}
|
|
984
|
+
function isIncluded2(value, array) {
|
|
985
|
+
return array.includes(value);
|
|
986
|
+
}
|
|
987
|
+
function isArrayIndex2(index, array) {
|
|
988
|
+
return isInteger2(index) && isArray2(array) && index >= 0 && index < array.length;
|
|
989
|
+
}
|
|
990
|
+
function isThrowing2(throwTestFn) {
|
|
991
|
+
try {
|
|
992
|
+
throwTestFn();
|
|
993
|
+
return false;
|
|
994
|
+
} catch (err) {
|
|
995
|
+
return true;
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
function tryOr(tryFn, orVal) {
|
|
999
|
+
try {
|
|
1000
|
+
return tryFn();
|
|
1001
|
+
} catch (err) {
|
|
1002
|
+
return isFunction2(orVal) ? orVal() : orVal;
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
// src/utils/index.ts
|
|
1007
|
+
var utils_exports = {};
|
|
1008
|
+
__export(utils_exports, {
|
|
1009
|
+
Arr: () => arr_exports,
|
|
1010
|
+
Dom: () => dom_exports,
|
|
1011
|
+
Enum: () => enum_exports,
|
|
1012
|
+
Is: () => Is,
|
|
1013
|
+
Map: () => map_exports,
|
|
1014
|
+
Math: () => math_exports,
|
|
1015
|
+
Obj: () => obj_exports,
|
|
1016
|
+
Str: () => str_exports
|
|
1017
|
+
});
|
|
241
1018
|
|
|
242
1019
|
// src/utils/arr/index.ts
|
|
1020
|
+
var arr_exports = {};
|
|
1021
|
+
__export(arr_exports, {
|
|
1022
|
+
arrayContains: () => arrayContains,
|
|
1023
|
+
chunckArray: () => chunckArray,
|
|
1024
|
+
duplicate: () => duplicate,
|
|
1025
|
+
fillArray: () => fillArray,
|
|
1026
|
+
getRangeArray: () => getRangeArray,
|
|
1027
|
+
getSequenceArray: () => getSequenceArray,
|
|
1028
|
+
isArray: () => isArray2,
|
|
1029
|
+
mapRangeArray: () => mapRangeArray,
|
|
1030
|
+
mapSequenceArray: () => mapSequenceArray,
|
|
1031
|
+
removeDuplicates: () => removeDuplicates,
|
|
1032
|
+
removeDuplicatesCmp: () => removeDuplicatesCmp,
|
|
1033
|
+
toArray: () => toArray
|
|
1034
|
+
});
|
|
243
1035
|
function toArray(a) {
|
|
244
|
-
return
|
|
1036
|
+
return isArray2(a) ? a : [a];
|
|
245
1037
|
}
|
|
246
1038
|
function duplicate(a) {
|
|
247
1039
|
return a === void 0 ? a : a.slice();
|
|
@@ -253,13 +1045,13 @@ function removeDuplicatesCmp(arr, cmp2) {
|
|
|
253
1045
|
return arr.filter((t1, index, self) => index === self.findIndex((t2) => cmp2(t1, t2)));
|
|
254
1046
|
}
|
|
255
1047
|
function fillArray(fillValue, fillCount) {
|
|
256
|
-
if (!
|
|
1048
|
+
if (!isInteger2(fillCount) || fillCount < 0) {
|
|
257
1049
|
throw new Error("fillArray: Invalid fillCount = " + fillCount);
|
|
258
1050
|
}
|
|
259
1051
|
return new Array(fillCount).fill(fillValue);
|
|
260
1052
|
}
|
|
261
1053
|
function mapSequenceArray(len, fn) {
|
|
262
|
-
if (!
|
|
1054
|
+
if (!isInteger2(len) || len < 0) {
|
|
263
1055
|
throw new Error("mapSequenceArray: Invalid len = " + len);
|
|
264
1056
|
}
|
|
265
1057
|
let arr = new Array(len);
|
|
@@ -272,10 +1064,10 @@ function getSequenceArray(len) {
|
|
|
272
1064
|
return mapSequenceArray(len, (i) => i);
|
|
273
1065
|
}
|
|
274
1066
|
function mapRangeArray(start, end, fn) {
|
|
275
|
-
if (!
|
|
1067
|
+
if (!isInteger2(start)) {
|
|
276
1068
|
throw new Error("mapRangeArray: Invalid start = " + end);
|
|
277
1069
|
}
|
|
278
|
-
if (!
|
|
1070
|
+
if (!isInteger2(end)) {
|
|
279
1071
|
throw new Error("mapRangeArray: Invalid end = " + end);
|
|
280
1072
|
}
|
|
281
1073
|
let len = Math.abs(end - start) + 1;
|
|
@@ -292,7 +1084,7 @@ function arrayContains(arg, item) {
|
|
|
292
1084
|
return arg.indexOf(item) >= 0;
|
|
293
1085
|
}
|
|
294
1086
|
function chunckArray(arr, chunckSize) {
|
|
295
|
-
if (!
|
|
1087
|
+
if (!isInteger2(chunckSize) || chunckSize < 1) {
|
|
296
1088
|
throw new Error("chunckArray: Invalid chunckSize = " + chunckSize);
|
|
297
1089
|
}
|
|
298
1090
|
let result = [];
|
|
@@ -325,261 +1117,8 @@ __export(dom_exports, {
|
|
|
325
1117
|
setWidth: () => setWidth,
|
|
326
1118
|
styleLayoutChanged: () => styleLayoutChanged
|
|
327
1119
|
});
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
var Assert;
|
|
331
|
-
((Assert2) => {
|
|
332
|
-
let errorConstructor = Error;
|
|
333
|
-
function setErrorClass(ec) {
|
|
334
|
-
errorConstructor = ec ?? Error;
|
|
335
|
-
}
|
|
336
|
-
Assert2.setErrorClass = setErrorClass;
|
|
337
|
-
function throwError(errorMsg, userMsg) {
|
|
338
|
-
throw new errorConstructor("Assertion Error: " + errorMsg + (userMsg ? " " + userMsg : ""));
|
|
339
|
-
}
|
|
340
|
-
function is_int(a) {
|
|
341
|
-
return typeof a === "number" && isFinite(a) && a === Math.trunc(a);
|
|
342
|
-
}
|
|
343
|
-
function is_number(a) {
|
|
344
|
-
return typeof a === "number";
|
|
345
|
-
}
|
|
346
|
-
function assert(a, userMsg) {
|
|
347
|
-
if (!a) {
|
|
348
|
-
throwError(userMsg ?? "Assertion failed!");
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
Assert2.assert = assert;
|
|
352
|
-
function assertEnum(value, enumObj, name = "value") {
|
|
353
|
-
if (!getEnumValues(enumObj).some((v) => v === value)) {
|
|
354
|
-
throw new TypeError(`Invalid ${name} enum value: ${value}`);
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
Assert2.assertEnum = assertEnum;
|
|
358
|
-
function interrupt(userMsg) {
|
|
359
|
-
throwError(userMsg ?? "Interrupted!");
|
|
360
|
-
}
|
|
361
|
-
Assert2.interrupt = interrupt;
|
|
362
|
-
function int(a, userMsg) {
|
|
363
|
-
if (!is_int(a)) {
|
|
364
|
-
throwError(`Expected ${a} to be integer.`, userMsg);
|
|
365
|
-
}
|
|
366
|
-
return a;
|
|
367
|
-
}
|
|
368
|
-
Assert2.int = int;
|
|
369
|
-
function eq(a, b, userMsg) {
|
|
370
|
-
if (a !== b) {
|
|
371
|
-
throwError(`Expected ${a} to equal ${b}.`, userMsg);
|
|
372
|
-
}
|
|
373
|
-
return a;
|
|
374
|
-
}
|
|
375
|
-
Assert2.eq = eq;
|
|
376
|
-
function int_eq(a, b, userMsg) {
|
|
377
|
-
if (!(is_int(a) && is_number(b) && a === b)) {
|
|
378
|
-
throwError(`Expected ${a} to be integer equal to ${b}.`, userMsg);
|
|
379
|
-
}
|
|
380
|
-
return a;
|
|
381
|
-
}
|
|
382
|
-
Assert2.int_eq = int_eq;
|
|
383
|
-
function int_lt(a, b, userMsg) {
|
|
384
|
-
if (!(is_int(a) && is_number(b) && a < b)) {
|
|
385
|
-
throwError(`Expected ${a} to be integer less than ${b}.`, userMsg);
|
|
386
|
-
}
|
|
387
|
-
return a;
|
|
388
|
-
}
|
|
389
|
-
Assert2.int_lt = int_lt;
|
|
390
|
-
function int_lte(a, b, userMsg) {
|
|
391
|
-
if (!(is_int(a) && is_number(b) && a <= b)) {
|
|
392
|
-
throwError(`Expected ${a} to be integer less than or equal to ${b}.`, userMsg);
|
|
393
|
-
}
|
|
394
|
-
return a;
|
|
395
|
-
}
|
|
396
|
-
Assert2.int_lte = int_lte;
|
|
397
|
-
function int_gt(a, b, userMsg) {
|
|
398
|
-
if (!(is_int(a) && is_number(b) && a > b)) {
|
|
399
|
-
throwError(`Expected ${a} to be integer greater than ${b}.`, userMsg);
|
|
400
|
-
}
|
|
401
|
-
return a;
|
|
402
|
-
}
|
|
403
|
-
Assert2.int_gt = int_gt;
|
|
404
|
-
function int_gte(a, b, userMsg) {
|
|
405
|
-
if (!(is_int(a) && is_number(b) && a >= b)) {
|
|
406
|
-
throwError(`Expected ${a} to be integer greater than or equal to ${b}.`, userMsg);
|
|
407
|
-
}
|
|
408
|
-
return a;
|
|
409
|
-
}
|
|
410
|
-
Assert2.int_gte = int_gte;
|
|
411
|
-
function int_between(a, min, max, userMsg) {
|
|
412
|
-
if (!(is_int(a) && is_number(min) && is_number(max) && a >= min && a <= max)) {
|
|
413
|
-
throwError(`Expected ${a} to be integer between ${min} and ${max}.`, userMsg);
|
|
414
|
-
}
|
|
415
|
-
return a;
|
|
416
|
-
}
|
|
417
|
-
Assert2.int_between = int_between;
|
|
418
|
-
function odd(a, userMsg) {
|
|
419
|
-
if (!(is_int(a) && a % 2 === 1)) {
|
|
420
|
-
throwError(`Expected ${a} to be odd number.`, userMsg);
|
|
421
|
-
}
|
|
422
|
-
return a;
|
|
423
|
-
}
|
|
424
|
-
Assert2.odd = odd;
|
|
425
|
-
function even(a, userMsg) {
|
|
426
|
-
if (!(is_int(a) && a % 2 === 0)) {
|
|
427
|
-
throwError(`Expected ${a} to be even number.`, userMsg);
|
|
428
|
-
}
|
|
429
|
-
return a;
|
|
430
|
-
}
|
|
431
|
-
Assert2.even = even;
|
|
432
|
-
function in_group(a, group, userMsg) {
|
|
433
|
-
if (!group.some((e) => e === a)) {
|
|
434
|
-
let strGroup = group.map((v) => String(v)).join(", ");
|
|
435
|
-
throwError(`Expected ${a} to be in group [${strGroup}].`, userMsg);
|
|
436
|
-
}
|
|
437
|
-
return a;
|
|
438
|
-
}
|
|
439
|
-
Assert2.in_group = in_group;
|
|
440
|
-
function finite(a, userMsg) {
|
|
441
|
-
if (!(is_number(a) && isFinite(a))) {
|
|
442
|
-
throwError(`Expected ${a} to be finite number.`, userMsg);
|
|
443
|
-
}
|
|
444
|
-
return a;
|
|
445
|
-
}
|
|
446
|
-
Assert2.finite = finite;
|
|
447
|
-
function array_id(arr, id, userMsg) {
|
|
448
|
-
if (!(is_int(id) && id >= 0 && id < arr.length)) {
|
|
449
|
-
throwError(`Expected ${id} to be array index in bounds [0..${arr.length - 1}].`, userMsg);
|
|
450
|
-
}
|
|
451
|
-
return id;
|
|
452
|
-
}
|
|
453
|
-
Assert2.array_id = array_id;
|
|
454
|
-
function array_elem(arr, id, userMsg) {
|
|
455
|
-
return arr[array_id(arr, id, userMsg)];
|
|
456
|
-
}
|
|
457
|
-
Assert2.array_elem = array_elem;
|
|
458
|
-
function require2(arg, userMsg) {
|
|
459
|
-
if (arg === void 0) {
|
|
460
|
-
throwError("Required value is undefined.", userMsg);
|
|
461
|
-
} else {
|
|
462
|
-
return arg;
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
Assert2.require = require2;
|
|
466
|
-
})(Assert || (Assert = {}));
|
|
467
|
-
|
|
468
|
-
// src/modules/device.ts
|
|
469
|
-
var Device;
|
|
470
|
-
((Device2) => {
|
|
471
|
-
function getDPI() {
|
|
472
|
-
let el = document.createElement("div");
|
|
473
|
-
el.style.width = "1in";
|
|
474
|
-
document.body.appendChild(el);
|
|
475
|
-
let dpi = el.offsetWidth;
|
|
476
|
-
el.remove();
|
|
477
|
-
return dpi || 96;
|
|
478
|
-
}
|
|
479
|
-
function getScrollBarWidth() {
|
|
480
|
-
try {
|
|
481
|
-
let outer = document.createElement("div");
|
|
482
|
-
outer.style.visibility = "hidden";
|
|
483
|
-
outer.style.width = "100px";
|
|
484
|
-
document.body.appendChild(outer);
|
|
485
|
-
let widthNoScroll = outer.offsetWidth;
|
|
486
|
-
outer.style.overflow = "scroll";
|
|
487
|
-
let inner = document.createElement("div");
|
|
488
|
-
inner.style.width = "100%";
|
|
489
|
-
outer.appendChild(inner);
|
|
490
|
-
let widthWithScroll = inner.offsetWidth;
|
|
491
|
-
if (outer.parentNode) {
|
|
492
|
-
outer.parentNode.removeChild(outer);
|
|
493
|
-
}
|
|
494
|
-
return widthNoScroll - widthWithScroll;
|
|
495
|
-
} catch (e) {
|
|
496
|
-
return 0;
|
|
497
|
-
}
|
|
498
|
-
}
|
|
499
|
-
function getSystemFontSize() {
|
|
500
|
-
let tmpDiv = document.createElement("div");
|
|
501
|
-
tmpDiv.style.cssText = "display:inline-block; padding:0; line-height:1; position:absolute; visibility:hidden; font-size:1em";
|
|
502
|
-
tmpDiv.appendChild(document.createTextNode("M"));
|
|
503
|
-
document.body.appendChild(tmpDiv);
|
|
504
|
-
let fontsize = tmpDiv.offsetHeight;
|
|
505
|
-
document.body.removeChild(tmpDiv);
|
|
506
|
-
return fontsize;
|
|
507
|
-
}
|
|
508
|
-
function getIsTouchDevice() {
|
|
509
|
-
if ("ontouchstart" in window || "DocumentTouch" in window || "createTouch" in document && "createTouchList" in document) {
|
|
510
|
-
return true;
|
|
511
|
-
}
|
|
512
|
-
var prefixes = " -webkit- -moz- -o- -ms- ".split(" ");
|
|
513
|
-
var mq = function(query2) {
|
|
514
|
-
return window.matchMedia(query2).matches;
|
|
515
|
-
};
|
|
516
|
-
var query = ["(", prefixes.join("touch-enabled),("), "heartz", ")"].join("");
|
|
517
|
-
return mq(query);
|
|
518
|
-
}
|
|
519
|
-
function getIsMobileDevice() {
|
|
520
|
-
let a = navigator.userAgent || navigator.vendor || window.opera;
|
|
521
|
-
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));
|
|
522
|
-
}
|
|
523
|
-
function getHostAddress() {
|
|
524
|
-
return location.protocol + "//" + location.host;
|
|
525
|
-
}
|
|
526
|
-
const UnitRegExp = /^(mm|cm|in|inch|px|em)$/;
|
|
527
|
-
const ValueUnitRegExp = /^([0-9\\.]+)(.*)$/;
|
|
528
|
-
Device2.DPI = getDPI();
|
|
529
|
-
Device2.PxPerMm = Device2.DPI / 25.4;
|
|
530
|
-
Device2.ScrollbarWidth = getScrollBarWidth();
|
|
531
|
-
Device2.FontSize = getSystemFontSize();
|
|
532
|
-
Device2.IsTouchDevice = getIsTouchDevice();
|
|
533
|
-
Device2.IsMobileDevice = getIsMobileDevice();
|
|
534
|
-
Device2.HostAddress = getHostAddress();
|
|
535
|
-
function pxToMm(px) {
|
|
536
|
-
return px / Device2.PxPerMm;
|
|
537
|
-
}
|
|
538
|
-
Device2.pxToMm = pxToMm;
|
|
539
|
-
function mmToPx(mm) {
|
|
540
|
-
return mm * Device2.PxPerMm;
|
|
541
|
-
}
|
|
542
|
-
Device2.mmToPx = mmToPx;
|
|
543
|
-
function toPx2(input) {
|
|
544
|
-
if (typeof input === "number") {
|
|
545
|
-
return input;
|
|
546
|
-
}
|
|
547
|
-
let value = NaN;
|
|
548
|
-
let unit = void 0;
|
|
549
|
-
let match = input.toString().match(ValueUnitRegExp);
|
|
550
|
-
if (match && match[1]) {
|
|
551
|
-
value = parseFloat(match[1]);
|
|
552
|
-
let unitStr = match[2] ? match[2].toLowerCase() : "undefined";
|
|
553
|
-
let unitStrOk = UnitRegExp.test(unitStr);
|
|
554
|
-
unit = unitStrOk ? unitStr : void 0;
|
|
555
|
-
if (!unit) {
|
|
556
|
-
console.log("Unknown unit '" + unitStr + "' => using 'px'.");
|
|
557
|
-
}
|
|
558
|
-
} else {
|
|
559
|
-
value = parseFloat(input);
|
|
560
|
-
}
|
|
561
|
-
Assert.finite(value, "value in function toPx");
|
|
562
|
-
switch (unit) {
|
|
563
|
-
case "mm":
|
|
564
|
-
return mmToPx(value);
|
|
565
|
-
case "cm":
|
|
566
|
-
return mmToPx(value) * 10;
|
|
567
|
-
case "in":
|
|
568
|
-
case "inch":
|
|
569
|
-
return mmToPx(value) * 25.4;
|
|
570
|
-
case "em":
|
|
571
|
-
return Device2.FontSize * value;
|
|
572
|
-
default:
|
|
573
|
-
case "px":
|
|
574
|
-
return value;
|
|
575
|
-
}
|
|
576
|
-
}
|
|
577
|
-
Device2.toPx = toPx2;
|
|
578
|
-
})(Device || (Device = {}));
|
|
579
|
-
|
|
580
|
-
// src/utils/dom/index.ts
|
|
581
|
-
function toPx(value) {
|
|
582
|
-
return value === void 0 ? void 0 : Device.toPx(value);
|
|
1120
|
+
function toPx2(value) {
|
|
1121
|
+
return value === void 0 ? void 0 : device_exports.toPx(value);
|
|
583
1122
|
}
|
|
584
1123
|
function hasClass(el, className) {
|
|
585
1124
|
if (className.length === 0) {
|
|
@@ -670,38 +1209,38 @@ function getPadding(style) {
|
|
|
670
1209
|
if (!style) {
|
|
671
1210
|
return { top: 0, right: 0, bottom: 0, left: 0 };
|
|
672
1211
|
}
|
|
673
|
-
let top =
|
|
674
|
-
let right =
|
|
675
|
-
let bottom =
|
|
676
|
-
let left =
|
|
1212
|
+
let top = toPx2(style.paddingTop);
|
|
1213
|
+
let right = toPx2(style.paddingRight);
|
|
1214
|
+
let bottom = toPx2(style.paddingBottom);
|
|
1215
|
+
let left = toPx2(style.paddingLeft);
|
|
677
1216
|
let padding = (style.padding ?? "").toString().split(" ").filter((s) => s.length > 0);
|
|
678
1217
|
switch (padding.length) {
|
|
679
1218
|
case 0:
|
|
680
1219
|
break;
|
|
681
1220
|
case 1:
|
|
682
|
-
top ?? (top =
|
|
683
|
-
right ?? (right =
|
|
684
|
-
bottom ?? (bottom =
|
|
685
|
-
left ?? (left =
|
|
1221
|
+
top ?? (top = toPx2(padding[0]));
|
|
1222
|
+
right ?? (right = toPx2(padding[0]));
|
|
1223
|
+
bottom ?? (bottom = toPx2(padding[0]));
|
|
1224
|
+
left ?? (left = toPx2(padding[0]));
|
|
686
1225
|
break;
|
|
687
1226
|
case 2:
|
|
688
|
-
top ?? (top =
|
|
689
|
-
right ?? (right =
|
|
690
|
-
bottom ?? (bottom =
|
|
691
|
-
left ?? (left =
|
|
1227
|
+
top ?? (top = toPx2(padding[0]));
|
|
1228
|
+
right ?? (right = toPx2(padding[1]));
|
|
1229
|
+
bottom ?? (bottom = toPx2(padding[0]));
|
|
1230
|
+
left ?? (left = toPx2(padding[1]));
|
|
692
1231
|
break;
|
|
693
1232
|
case 3:
|
|
694
|
-
top ?? (top =
|
|
695
|
-
right ?? (right =
|
|
696
|
-
bottom ?? (bottom =
|
|
697
|
-
left ?? (left =
|
|
1233
|
+
top ?? (top = toPx2(padding[0]));
|
|
1234
|
+
right ?? (right = toPx2(padding[1]));
|
|
1235
|
+
bottom ?? (bottom = toPx2(padding[2]));
|
|
1236
|
+
left ?? (left = toPx2(padding[1]));
|
|
698
1237
|
break;
|
|
699
1238
|
case 4:
|
|
700
1239
|
default:
|
|
701
|
-
top ?? (top =
|
|
702
|
-
right ?? (right =
|
|
703
|
-
bottom ?? (bottom =
|
|
704
|
-
left ?? (left =
|
|
1240
|
+
top ?? (top = toPx2(padding[0]));
|
|
1241
|
+
right ?? (right = toPx2(padding[1]));
|
|
1242
|
+
bottom ?? (bottom = toPx2(padding[2]));
|
|
1243
|
+
left ?? (left = toPx2(padding[3]));
|
|
705
1244
|
break;
|
|
706
1245
|
}
|
|
707
1246
|
top ?? (top = 0);
|
|
@@ -711,12 +1250,12 @@ function getPadding(style) {
|
|
|
711
1250
|
return { top, right, bottom, left };
|
|
712
1251
|
}
|
|
713
1252
|
function getDimension(style) {
|
|
714
|
-
let left =
|
|
715
|
-
let right =
|
|
716
|
-
let top =
|
|
717
|
-
let bottom =
|
|
718
|
-
let width =
|
|
719
|
-
let height =
|
|
1253
|
+
let left = toPx2(style?.left);
|
|
1254
|
+
let right = toPx2(style?.right);
|
|
1255
|
+
let top = toPx2(style?.top);
|
|
1256
|
+
let bottom = toPx2(style?.bottom);
|
|
1257
|
+
let width = toPx2(style?.width);
|
|
1258
|
+
let height = toPx2(style?.height);
|
|
720
1259
|
if (width === void 0 && left !== void 0 && right !== void 0) {
|
|
721
1260
|
width = right - left;
|
|
722
1261
|
}
|
|
@@ -751,9 +1290,7 @@ __export(map_exports, {
|
|
|
751
1290
|
getMapKeys: () => getMapKeys
|
|
752
1291
|
});
|
|
753
1292
|
function getMapKeys(map) {
|
|
754
|
-
|
|
755
|
-
map.forEach((value, key) => keys.push(key));
|
|
756
|
-
return keys;
|
|
1293
|
+
return [...map.keys()];
|
|
757
1294
|
}
|
|
758
1295
|
|
|
759
1296
|
// src/utils/math/index.ts
|
|
@@ -765,8 +1302,8 @@ __export(math_exports, {
|
|
|
765
1302
|
cmp: () => cmp,
|
|
766
1303
|
interpolateCoord: () => interpolateCoord,
|
|
767
1304
|
interpolateY: () => interpolateY,
|
|
768
|
-
isInteger: () =>
|
|
769
|
-
isNumber: () =>
|
|
1305
|
+
isInteger: () => isInteger2,
|
|
1306
|
+
isNumber: () => isNumber2,
|
|
770
1307
|
linearToDecibels: () => linearToDecibels,
|
|
771
1308
|
mod: () => mod,
|
|
772
1309
|
romanize: () => romanize,
|
|
@@ -786,7 +1323,7 @@ function mod(m, n) {
|
|
|
786
1323
|
return (m % n + n) % n;
|
|
787
1324
|
}
|
|
788
1325
|
function romanize(n) {
|
|
789
|
-
if (!
|
|
1326
|
+
if (!isInteger2(n) || n < 0) {
|
|
790
1327
|
throw new Error("romanize: Invalid n = " + n);
|
|
791
1328
|
}
|
|
792
1329
|
var digits = String(+n).split("");
|
|
@@ -827,7 +1364,7 @@ function romanize(n) {
|
|
|
827
1364
|
return Array(+digits.join("") + 1).join("M") + roman;
|
|
828
1365
|
}
|
|
829
1366
|
function toOrdinalNumber(n) {
|
|
830
|
-
if (!
|
|
1367
|
+
if (!isInteger2(n)) {
|
|
831
1368
|
throw new Error("toOrdinalNumber: Invalid n = " + n);
|
|
832
1369
|
}
|
|
833
1370
|
const nStr = n.toString();
|
|
@@ -880,87 +1417,58 @@ function cmp(a, b) {
|
|
|
880
1417
|
return a < b ? -1 : a > b ? 1 : 0;
|
|
881
1418
|
}
|
|
882
1419
|
|
|
883
|
-
// src/utils/obj/index.ts
|
|
884
|
-
var obj_exports = {};
|
|
885
|
-
__export(obj_exports, {
|
|
886
|
-
deepEqual: () => deepEqual,
|
|
887
|
-
hasProperties: () => hasProperties,
|
|
888
|
-
isObject: () => isObject
|
|
889
|
-
});
|
|
890
|
-
function hasProperties(obj, props) {
|
|
891
|
-
return isObject(obj) && props.every((p) => p in obj);
|
|
892
|
-
}
|
|
893
|
-
function deepEqual(a, b) {
|
|
894
|
-
if (a === b) return true;
|
|
895
|
-
if (a === null || b === null) return false;
|
|
896
|
-
if (typeof a !== "object" || typeof b !== "object") return false;
|
|
897
|
-
if (Array.isArray(a) && Array.isArray(b)) {
|
|
898
|
-
if (a.length !== b.length) return false;
|
|
899
|
-
return a.every((val, i) => deepEqual(val, b[i]));
|
|
900
|
-
}
|
|
901
|
-
if (Array.isArray(a) !== Array.isArray(b)) return false;
|
|
902
|
-
const keysA = Object.keys(a);
|
|
903
|
-
const keysB = Object.keys(b);
|
|
904
|
-
if (keysA.length !== keysB.length) return false;
|
|
905
|
-
for (const key of keysA) {
|
|
906
|
-
if (!Object.prototype.hasOwnProperty.call(b, key)) return false;
|
|
907
|
-
if (!deepEqual(a[key], b[key])) return false;
|
|
908
|
-
}
|
|
909
|
-
return true;
|
|
910
|
-
}
|
|
911
|
-
|
|
912
1420
|
// src/utils/str/index.ts
|
|
913
1421
|
var str_exports = {};
|
|
914
1422
|
__export(str_exports, {
|
|
915
1423
|
charCount: () => charCount,
|
|
916
1424
|
chunkString: () => chunkString,
|
|
917
1425
|
insertAt: () => insertAt,
|
|
918
|
-
isString: () =>
|
|
1426
|
+
isString: () => isString2,
|
|
919
1427
|
makeSentenceFromPascal: () => makeSentenceFromPascal,
|
|
920
1428
|
removeAt: () => removeAt,
|
|
921
1429
|
repeatString: () => repeatString,
|
|
922
1430
|
replaceAt: () => replaceAt,
|
|
923
1431
|
toCharArray: () => toCharArray
|
|
924
1432
|
});
|
|
925
|
-
function toCharArray(
|
|
926
|
-
return
|
|
1433
|
+
function toCharArray(str2) {
|
|
1434
|
+
return str2.split("");
|
|
927
1435
|
}
|
|
928
1436
|
function repeatString(repeatString2, repeatCount) {
|
|
929
|
-
if (!
|
|
1437
|
+
if (!isInteger2(repeatCount) || repeatCount < 0) {
|
|
930
1438
|
throw new Error("repeatStr: Invalid repeatCount = " + repeatCount);
|
|
931
1439
|
}
|
|
932
1440
|
return new Array(repeatCount + 1).join(repeatString2);
|
|
933
1441
|
}
|
|
934
|
-
function chunkString(
|
|
935
|
-
if (!
|
|
1442
|
+
function chunkString(str2, chunkSize) {
|
|
1443
|
+
if (!isInteger2(chunkSize) || chunkSize < 1) {
|
|
936
1444
|
throw new Error("chunckString: Invalid chuckSize = " + chunkSize);
|
|
937
1445
|
}
|
|
938
1446
|
let result = [];
|
|
939
|
-
for (let i = 0; i <
|
|
940
|
-
result.push(
|
|
1447
|
+
for (let i = 0; i < str2.length; i += chunkSize) {
|
|
1448
|
+
result.push(str2.slice(i, i + chunkSize));
|
|
941
1449
|
}
|
|
942
1450
|
return result;
|
|
943
1451
|
}
|
|
944
|
-
function replaceAt(
|
|
945
|
-
if (!
|
|
1452
|
+
function replaceAt(str2, pos, removeCount, insert) {
|
|
1453
|
+
if (!isInteger2(removeCount) || removeCount < 0) {
|
|
946
1454
|
throw new Error("replaceAt: Invalid removeCount = " + removeCount);
|
|
947
|
-
} else if (!
|
|
948
|
-
throw new Error("replaceAt: Invalid pos = " + pos + ", removeCount = " + removeCount + ", str.length = " +
|
|
1455
|
+
} else if (!isInteger2(pos) || pos < 0 || pos + removeCount > str2.length) {
|
|
1456
|
+
throw new Error("replaceAt: Invalid pos = " + pos + ", removeCount = " + removeCount + ", str.length = " + str2.length);
|
|
949
1457
|
} else {
|
|
950
|
-
return
|
|
1458
|
+
return str2.substring(0, pos) + insert + str2.substring(pos + removeCount);
|
|
951
1459
|
}
|
|
952
1460
|
}
|
|
953
|
-
function insertAt(
|
|
954
|
-
return replaceAt(
|
|
1461
|
+
function insertAt(str2, pos, insertStr) {
|
|
1462
|
+
return replaceAt(str2, pos, 0, insertStr);
|
|
955
1463
|
}
|
|
956
|
-
function removeAt(
|
|
957
|
-
return replaceAt(
|
|
1464
|
+
function removeAt(str2, pos, removeCount) {
|
|
1465
|
+
return replaceAt(str2, pos, removeCount, "");
|
|
958
1466
|
}
|
|
959
|
-
function charCount(
|
|
960
|
-
if (ch.length !== 1 ||
|
|
1467
|
+
function charCount(str2, ch) {
|
|
1468
|
+
if (ch.length !== 1 || str2.length === 0) return 0;
|
|
961
1469
|
let count = 0;
|
|
962
|
-
for (let i = 0; i <
|
|
963
|
-
if (
|
|
1470
|
+
for (let i = 0; i < str2.length; i++) {
|
|
1471
|
+
if (str2[i] === ch) count++;
|
|
964
1472
|
}
|
|
965
1473
|
return count;
|
|
966
1474
|
}
|
|
@@ -990,155 +1498,488 @@ function makeSentenceFromPascal(PascalString) {
|
|
|
990
1498
|
}
|
|
991
1499
|
word += c.toLowerCase();
|
|
992
1500
|
}
|
|
993
|
-
addWord();
|
|
994
|
-
return sentence;
|
|
995
|
-
}
|
|
996
|
-
|
|
997
|
-
// src/
|
|
998
|
-
var
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
(
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1501
|
+
addWord();
|
|
1502
|
+
return sentence;
|
|
1503
|
+
}
|
|
1504
|
+
|
|
1505
|
+
// src/utils/index.ts
|
|
1506
|
+
var Is = guard_exports;
|
|
1507
|
+
|
|
1508
|
+
// src/core/stack.ts
|
|
1509
|
+
var Stack = class {
|
|
1510
|
+
constructor() {
|
|
1511
|
+
__publicField(this, "list", []);
|
|
1512
|
+
}
|
|
1513
|
+
push(e) {
|
|
1514
|
+
this.list.push(e);
|
|
1515
|
+
return e;
|
|
1516
|
+
}
|
|
1517
|
+
pop() {
|
|
1518
|
+
assert_exports.int_gt(this.list.length, 0);
|
|
1519
|
+
return this.list.pop();
|
|
1520
|
+
}
|
|
1521
|
+
top() {
|
|
1522
|
+
return assert_exports.array_elem(this.list, this.list.length - 1, "Stack is empty!");
|
|
1523
|
+
}
|
|
1524
|
+
toArray() {
|
|
1525
|
+
return this.list;
|
|
1526
|
+
}
|
|
1527
|
+
get length() {
|
|
1528
|
+
return this.list.length;
|
|
1529
|
+
}
|
|
1530
|
+
clear() {
|
|
1531
|
+
this.list.length = 0;
|
|
1532
|
+
}
|
|
1533
|
+
};
|
|
1534
|
+
|
|
1535
|
+
// src/core/vec.ts
|
|
1536
|
+
var Vec = class _Vec {
|
|
1537
|
+
constructor(...coords) {
|
|
1538
|
+
__publicField(this, "coords");
|
|
1539
|
+
if (coords.length < 2) {
|
|
1540
|
+
throw new TypeError("Vec needs minumum two coords!");
|
|
1541
|
+
}
|
|
1542
|
+
this.coords = coords;
|
|
1543
|
+
}
|
|
1544
|
+
static vec2(x, y) {
|
|
1545
|
+
return new _Vec(x, y);
|
|
1546
|
+
}
|
|
1547
|
+
static vec3(x, y, z) {
|
|
1548
|
+
return new _Vec(x, y, z);
|
|
1549
|
+
}
|
|
1550
|
+
static zero(dim) {
|
|
1551
|
+
if (dim < 2) {
|
|
1552
|
+
throw new TypeError("Vec.zero requires dimension >= 2");
|
|
1553
|
+
}
|
|
1554
|
+
return new _Vec(...Array(dim).fill(0));
|
|
1555
|
+
}
|
|
1556
|
+
get dim() {
|
|
1557
|
+
return this.coords.length;
|
|
1558
|
+
}
|
|
1559
|
+
get length() {
|
|
1560
|
+
return Math.hypot(...this.coords);
|
|
1561
|
+
}
|
|
1562
|
+
magnitude() {
|
|
1563
|
+
return this.length;
|
|
1040
1564
|
}
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
return str2 === void 0 ? defaultValue : str2.substring(name.length + 1);
|
|
1565
|
+
get x() {
|
|
1566
|
+
return this.coords[0];
|
|
1044
1567
|
}
|
|
1045
|
-
|
|
1046
|
-
|
|
1568
|
+
get y() {
|
|
1569
|
+
return this.coords[1];
|
|
1047
1570
|
}
|
|
1048
|
-
|
|
1049
|
-
if (
|
|
1050
|
-
|
|
1571
|
+
get z() {
|
|
1572
|
+
if (this.coords[2] === void 0) {
|
|
1573
|
+
throw new TypeError("Vec z-coord not available!");
|
|
1051
1574
|
}
|
|
1052
|
-
return
|
|
1575
|
+
return this.coords[2];
|
|
1053
1576
|
}
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
if (
|
|
1057
|
-
|
|
1058
|
-
} else {
|
|
1059
|
-
return defaultValue;
|
|
1577
|
+
add(...args) {
|
|
1578
|
+
const otherCoords = args[0] instanceof _Vec ? args[0].coords : args;
|
|
1579
|
+
if (this.coords.length !== otherCoords.length) {
|
|
1580
|
+
throw new TypeError("Coordinate length mismatch!");
|
|
1060
1581
|
}
|
|
1582
|
+
return new _Vec(...this.coords.map((coord, i) => coord + otherCoords[i]));
|
|
1061
1583
|
}
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
if (
|
|
1065
|
-
|
|
1066
|
-
return str2 === void 0 ? defaultValue : parseInt(str2);
|
|
1067
|
-
} else {
|
|
1068
|
-
return defaultValue;
|
|
1584
|
+
sub(...args) {
|
|
1585
|
+
const otherCoords = args[0] instanceof _Vec ? args[0].coords : args;
|
|
1586
|
+
if (this.coords.length !== otherCoords.length) {
|
|
1587
|
+
throw new TypeError("Coordinate length mismatch!");
|
|
1069
1588
|
}
|
|
1589
|
+
return new _Vec(...this.coords.map((coord, i) => coord - otherCoords[i]));
|
|
1070
1590
|
}
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1591
|
+
mul(scalar) {
|
|
1592
|
+
return new _Vec(...this.coords.map((coord) => coord * scalar));
|
|
1593
|
+
}
|
|
1594
|
+
div(scalar) {
|
|
1595
|
+
return new _Vec(...this.coords.map((coord) => coord / scalar));
|
|
1596
|
+
}
|
|
1597
|
+
dot(other) {
|
|
1598
|
+
if (this.coords.length !== other.coords.length) {
|
|
1599
|
+
throw new TypeError("Coordinate length mismatch!");
|
|
1078
1600
|
}
|
|
1601
|
+
return this.coords.reduce((sum2, c, i) => sum2 + c * other.coords[i], 0);
|
|
1079
1602
|
}
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
_erase(name);
|
|
1603
|
+
distance(other) {
|
|
1604
|
+
if (this.coords.length !== other.coords.length) {
|
|
1605
|
+
throw new TypeError("Coordinate length mismatch!");
|
|
1084
1606
|
}
|
|
1607
|
+
return Math.hypot(...this.coords.map((c, i) => c - other.coords[i]));
|
|
1085
1608
|
}
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1609
|
+
normalize() {
|
|
1610
|
+
const len = this.length;
|
|
1611
|
+
if (len === 0) {
|
|
1612
|
+
throw new TypeError("Cannot normalize zero-length vector!");
|
|
1613
|
+
}
|
|
1614
|
+
return this.div(len);
|
|
1089
1615
|
}
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1616
|
+
static lerp(a, b, t) {
|
|
1617
|
+
if (a.coords.length !== b.coords.length) {
|
|
1618
|
+
throw new TypeError("Coordinate length mismatch!");
|
|
1619
|
+
}
|
|
1620
|
+
if (!isFinite3(t)) {
|
|
1621
|
+
throw new TypeError("Lerp t is not finite!");
|
|
1622
|
+
}
|
|
1623
|
+
return a.add(b.sub(a).mul(t));
|
|
1097
1624
|
}
|
|
1098
|
-
|
|
1099
|
-
this.
|
|
1100
|
-
return
|
|
1625
|
+
toLength(len) {
|
|
1626
|
+
const mag = this.length;
|
|
1627
|
+
return mag === 0 ? this : this.mul(len / mag);
|
|
1101
1628
|
}
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1629
|
+
clamp(minLength, maxLength, defaultDir) {
|
|
1630
|
+
const mag = this.length;
|
|
1631
|
+
if (mag === 0) {
|
|
1632
|
+
if (minLength !== void 0) {
|
|
1633
|
+
if (defaultDir && defaultDir.coords.length !== this.coords.length)
|
|
1634
|
+
throw new TypeError("Coordinate length mismatch!");
|
|
1635
|
+
const dir = defaultDir && defaultDir.length !== 0 ? defaultDir.normalize() : new _Vec(1, ...Array(this.coords.length - 1).fill(0));
|
|
1636
|
+
return dir.mul(minLength);
|
|
1637
|
+
}
|
|
1638
|
+
return this;
|
|
1639
|
+
}
|
|
1640
|
+
if (maxLength !== void 0 && mag > maxLength) {
|
|
1641
|
+
return this.normalize().mul(maxLength);
|
|
1642
|
+
}
|
|
1643
|
+
if (minLength !== void 0 && mag < minLength) {
|
|
1644
|
+
return this.normalize().mul(minLength);
|
|
1645
|
+
}
|
|
1646
|
+
return this;
|
|
1105
1647
|
}
|
|
1106
|
-
|
|
1107
|
-
return
|
|
1648
|
+
equals(other) {
|
|
1649
|
+
return this.coords.length === other.coords.length && this.coords.every((v, i) => v === other.coords[i]);
|
|
1108
1650
|
}
|
|
1109
|
-
|
|
1110
|
-
return this.
|
|
1651
|
+
clone() {
|
|
1652
|
+
return new _Vec(...this.coords);
|
|
1111
1653
|
}
|
|
1112
|
-
|
|
1113
|
-
return this.
|
|
1654
|
+
toObject() {
|
|
1655
|
+
return { x: this.x, y: this.y, z: this.z };
|
|
1114
1656
|
}
|
|
1115
|
-
|
|
1116
|
-
this.
|
|
1657
|
+
[Symbol.iterator]() {
|
|
1658
|
+
return this.coords[Symbol.iterator]();
|
|
1659
|
+
}
|
|
1660
|
+
toString() {
|
|
1661
|
+
return `Vec(${this.coords.join(", ")})`;
|
|
1117
1662
|
}
|
|
1118
1663
|
};
|
|
1119
1664
|
|
|
1120
|
-
// src/core/
|
|
1121
|
-
var
|
|
1122
|
-
constructor(
|
|
1123
|
-
__publicField(this, "
|
|
1124
|
-
__publicField(this, "
|
|
1125
|
-
this
|
|
1126
|
-
this
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1665
|
+
// src/core/div-rect.ts
|
|
1666
|
+
var DivRect = class _DivRect {
|
|
1667
|
+
constructor(...args) {
|
|
1668
|
+
__publicField(this, "left");
|
|
1669
|
+
__publicField(this, "anchorX");
|
|
1670
|
+
__publicField(this, "right");
|
|
1671
|
+
__publicField(this, "top");
|
|
1672
|
+
__publicField(this, "anchorY");
|
|
1673
|
+
__publicField(this, "bottom");
|
|
1674
|
+
if (args.length === 6) {
|
|
1675
|
+
this.left = args[0];
|
|
1676
|
+
this.anchorX = args[1];
|
|
1677
|
+
this.right = args[2];
|
|
1678
|
+
this.top = args[3];
|
|
1679
|
+
this.anchorY = args[4];
|
|
1680
|
+
this.bottom = args[5];
|
|
1681
|
+
} else if (args.length === 4) {
|
|
1682
|
+
this.left = args[0];
|
|
1683
|
+
this.right = args[1];
|
|
1684
|
+
this.anchorX = (this.left + this.right) / 2;
|
|
1685
|
+
this.top = args[2];
|
|
1686
|
+
this.bottom = args[3];
|
|
1687
|
+
this.anchorY = (this.top + this.bottom) / 2;
|
|
1688
|
+
} else if (args.length === 0) {
|
|
1689
|
+
this.left = this.anchorX = this.right = 0;
|
|
1690
|
+
this.top = this.anchorY = this.bottom = 0;
|
|
1691
|
+
} else {
|
|
1692
|
+
throw new TypeError(`Invalid DivRect args: ${args}`);
|
|
1693
|
+
}
|
|
1694
|
+
}
|
|
1695
|
+
/**
|
|
1696
|
+
* Create rect from basic left, top, width and height arguments.
|
|
1697
|
+
*
|
|
1698
|
+
* @param left - Left coordinate.
|
|
1699
|
+
* @param top - Top coordinate.
|
|
1700
|
+
* @param width - Width.
|
|
1701
|
+
* @param height - Height.
|
|
1702
|
+
* @returns - DivRect.
|
|
1703
|
+
*/
|
|
1704
|
+
static create(left, top, width, height) {
|
|
1705
|
+
return new _DivRect(left, left + width, top, top + height);
|
|
1706
|
+
}
|
|
1707
|
+
/**
|
|
1708
|
+
* Create rect from anchorX, anchorY, width, height arguments.
|
|
1709
|
+
*
|
|
1710
|
+
* @param centerX - Center x-coordinate.
|
|
1711
|
+
* @param centerY - Center y-coordinate.
|
|
1712
|
+
* @param width - Width.
|
|
1713
|
+
* @param height - Height.
|
|
1714
|
+
* @returns - DivRect.
|
|
1715
|
+
*/
|
|
1716
|
+
static createCentered(centerX, centerY, width, height) {
|
|
1717
|
+
return new _DivRect(
|
|
1718
|
+
centerX - width / 2,
|
|
1719
|
+
centerX,
|
|
1720
|
+
centerX + width / 2,
|
|
1721
|
+
centerY - height / 2,
|
|
1722
|
+
centerY,
|
|
1723
|
+
centerY + height / 2
|
|
1724
|
+
);
|
|
1725
|
+
}
|
|
1726
|
+
/**
|
|
1727
|
+
* Create rect from sections.
|
|
1728
|
+
*
|
|
1729
|
+
* @param leftw - Left section width.
|
|
1730
|
+
* @param rightw - Right section width.
|
|
1731
|
+
* @param toph - Top section height.
|
|
1732
|
+
* @param bottomh - Bottomsection height.
|
|
1733
|
+
* @returns - DivRect.
|
|
1734
|
+
*/
|
|
1735
|
+
static createSections(leftw, rightw, toph, bottomh) {
|
|
1736
|
+
return new _DivRect(-leftw, 0, rightw, -toph, 0, bottomh);
|
|
1737
|
+
}
|
|
1738
|
+
/** @deprecated - Renamed to anchorX. */
|
|
1739
|
+
get centerX() {
|
|
1740
|
+
return this.anchorX;
|
|
1741
|
+
}
|
|
1742
|
+
/** @deprecated - Renamed to anchorX. */
|
|
1743
|
+
set centerX(x) {
|
|
1744
|
+
this.anchorX = x;
|
|
1745
|
+
}
|
|
1746
|
+
/** @deprecated - Renamed to anchorY. */
|
|
1747
|
+
get centerY() {
|
|
1748
|
+
return this.anchorY;
|
|
1749
|
+
}
|
|
1750
|
+
/** @deprecated - Renamed to anchorY. */
|
|
1751
|
+
set centerY(y) {
|
|
1752
|
+
this.anchorY = y;
|
|
1753
|
+
}
|
|
1754
|
+
/**
|
|
1755
|
+
* Width getter.
|
|
1756
|
+
*/
|
|
1757
|
+
get width() {
|
|
1758
|
+
return this.right - this.left;
|
|
1759
|
+
}
|
|
1760
|
+
/**
|
|
1761
|
+
* Height getter.
|
|
1762
|
+
*/
|
|
1763
|
+
get height() {
|
|
1764
|
+
return this.bottom - this.top;
|
|
1765
|
+
}
|
|
1766
|
+
/**
|
|
1767
|
+
* Left section width getter.
|
|
1768
|
+
*/
|
|
1769
|
+
get leftw() {
|
|
1770
|
+
return this.anchorX - this.left;
|
|
1771
|
+
}
|
|
1772
|
+
/**
|
|
1773
|
+
* Right section width getter.
|
|
1774
|
+
*/
|
|
1775
|
+
get rightw() {
|
|
1776
|
+
return this.right - this.anchorX;
|
|
1777
|
+
}
|
|
1778
|
+
/**
|
|
1779
|
+
* Top section height getter.
|
|
1780
|
+
*/
|
|
1781
|
+
get toph() {
|
|
1782
|
+
return this.anchorY - this.top;
|
|
1783
|
+
}
|
|
1784
|
+
/**
|
|
1785
|
+
* Bottom section height getter.
|
|
1786
|
+
*/
|
|
1787
|
+
get bottomh() {
|
|
1788
|
+
return this.bottom - this.anchorY;
|
|
1789
|
+
}
|
|
1790
|
+
/**
|
|
1791
|
+
* Does this Rect contain given (x, y)-point?
|
|
1792
|
+
*
|
|
1793
|
+
* @param x - X-coordinate.
|
|
1794
|
+
* @param y - Y-coordinate.
|
|
1795
|
+
* @returns - True/false.
|
|
1796
|
+
*/
|
|
1797
|
+
contains(x, y) {
|
|
1798
|
+
return x >= this.left && x <= this.right && y >= this.top && y <= this.bottom;
|
|
1799
|
+
}
|
|
1800
|
+
/**
|
|
1801
|
+
* Do a and b rects overlap?
|
|
1802
|
+
*
|
|
1803
|
+
* @param a - DivRect a.
|
|
1804
|
+
* @param b - DivRect b.
|
|
1805
|
+
* @returns - True/false.
|
|
1806
|
+
*/
|
|
1807
|
+
static overlap(a, b) {
|
|
1808
|
+
return a.right > b.left && a.left < b.right && a.bottom > b.top && a.top < b.bottom;
|
|
1809
|
+
}
|
|
1810
|
+
/**
|
|
1811
|
+
* Do horizontal measures of a and b rects overlap?
|
|
1812
|
+
*
|
|
1813
|
+
* @param a - DivRect a.
|
|
1814
|
+
* @param b - DivRect b.
|
|
1815
|
+
* @returns - True/false.
|
|
1816
|
+
*/
|
|
1817
|
+
static overlapX(a, b) {
|
|
1818
|
+
return a.right > b.left && a.left < b.right;
|
|
1819
|
+
}
|
|
1820
|
+
/**
|
|
1821
|
+
* Check if given rects are equal.
|
|
1822
|
+
* @param a - DivRect a.
|
|
1823
|
+
* @param b - DivRect b.
|
|
1824
|
+
* @returns - True/false.
|
|
1825
|
+
*/
|
|
1826
|
+
static equals(a, b) {
|
|
1827
|
+
if (a == null && b == null) {
|
|
1828
|
+
return true;
|
|
1829
|
+
} else if (a == null || b == null) {
|
|
1830
|
+
return false;
|
|
1831
|
+
} else {
|
|
1832
|
+
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;
|
|
1833
|
+
}
|
|
1834
|
+
}
|
|
1835
|
+
/**
|
|
1836
|
+
* Check if this rect equals with another rect.
|
|
1837
|
+
* @param other - The other rect.
|
|
1838
|
+
* @returns - True/false.
|
|
1839
|
+
*/
|
|
1840
|
+
equals(other) {
|
|
1841
|
+
return _DivRect.equals(this, other);
|
|
1842
|
+
}
|
|
1843
|
+
/**
|
|
1844
|
+
* Check if edges of given rects are equal, ignoring anchorX and anchorY.
|
|
1845
|
+
*
|
|
1846
|
+
* @param a - DivRect a.
|
|
1847
|
+
* @param b - DivRect b.
|
|
1848
|
+
* @returns - True/false.
|
|
1849
|
+
*/
|
|
1850
|
+
static equalsEdges(a, b) {
|
|
1851
|
+
if (a == null && b == null) {
|
|
1852
|
+
return true;
|
|
1853
|
+
} else if (a == null || b == null) {
|
|
1854
|
+
return false;
|
|
1855
|
+
} else {
|
|
1856
|
+
return a === b || a.left === b.left && a.right === b.right && a.top === b.top && a.bottom === b.bottom;
|
|
1857
|
+
}
|
|
1858
|
+
}
|
|
1859
|
+
/**
|
|
1860
|
+
* Check if edges of this Rect equals with given Rect, ignoring anchorX and anchorY.
|
|
1861
|
+
*
|
|
1862
|
+
* @param other - The other DivRect.
|
|
1863
|
+
* @returns - True/false.
|
|
1864
|
+
*/
|
|
1865
|
+
equalsEdges(other) {
|
|
1866
|
+
return _DivRect.equalsEdges(this, other);
|
|
1867
|
+
}
|
|
1868
|
+
/** @deprecated - Use `DivRect.equalsEdges()` instead. */
|
|
1869
|
+
static equalsFrame(a, b) {
|
|
1870
|
+
return _DivRect.equalsEdges(a, b);
|
|
1871
|
+
}
|
|
1872
|
+
/**
|
|
1873
|
+
* Created duplicate of this Rect.
|
|
1874
|
+
*
|
|
1875
|
+
* @returns - Duplicate.
|
|
1876
|
+
*/
|
|
1877
|
+
copy() {
|
|
1878
|
+
return new _DivRect(this.left, this.anchorX, this.right, this.top, this.anchorY, this.bottom);
|
|
1879
|
+
}
|
|
1880
|
+
/**
|
|
1881
|
+
* Move this rect by (dx, dy). Modifies this Rect.
|
|
1882
|
+
*
|
|
1883
|
+
* @param dx - Offset amount in x-direction.
|
|
1884
|
+
* @param dy - Offset amount in y-direction.
|
|
1885
|
+
* @returns - This DivRect instance.
|
|
1886
|
+
*/
|
|
1887
|
+
offsetInPlace(dx, dy) {
|
|
1888
|
+
this.left += dx;
|
|
1889
|
+
this.anchorX += dx;
|
|
1890
|
+
this.right += dx;
|
|
1891
|
+
this.top += dy;
|
|
1892
|
+
this.anchorY += dy;
|
|
1893
|
+
this.bottom += dy;
|
|
1894
|
+
return this;
|
|
1130
1895
|
}
|
|
1131
|
-
|
|
1132
|
-
|
|
1896
|
+
/**
|
|
1897
|
+
* Move this rect by (dx, dy). Immutable, returns modified copy.
|
|
1898
|
+
*
|
|
1899
|
+
* @param dx - Offset amount in x-direction.
|
|
1900
|
+
* @param dy - Offset amount in y-direction.
|
|
1901
|
+
* @returns - DivRect copy with applied offset.
|
|
1902
|
+
*/
|
|
1903
|
+
offsetCopy(dx, dy) {
|
|
1904
|
+
return this.copy().offsetInPlace(dx, dy);
|
|
1905
|
+
}
|
|
1906
|
+
/**
|
|
1907
|
+
* Expand this Rect by given Rect. Modifies this Rect.
|
|
1908
|
+
*
|
|
1909
|
+
* @param rect - DivRect to expand this instance with.
|
|
1910
|
+
* @returns - This DivRect instance.
|
|
1911
|
+
*/
|
|
1912
|
+
expandInPlace(rect) {
|
|
1913
|
+
this.left = Math.min(this.left, rect.left);
|
|
1914
|
+
this.right = Math.max(this.right, rect.right);
|
|
1915
|
+
this.top = Math.min(this.top, rect.top);
|
|
1916
|
+
this.bottom = Math.max(this.bottom, rect.bottom);
|
|
1917
|
+
return this;
|
|
1133
1918
|
}
|
|
1134
|
-
|
|
1135
|
-
|
|
1919
|
+
/**
|
|
1920
|
+
* Expand this Rect by given Rect. Immutable, returns modified copy.
|
|
1921
|
+
*
|
|
1922
|
+
* @param rect - DivRect to expand this instance with.
|
|
1923
|
+
* @returns - Expanded copy of this DivRect.
|
|
1924
|
+
*/
|
|
1925
|
+
expandCopy(rect) {
|
|
1926
|
+
return this.copy().expandInPlace(rect);
|
|
1927
|
+
}
|
|
1928
|
+
/**
|
|
1929
|
+
* Clip this Rect by given Rect. Mmodifies this Rect.
|
|
1930
|
+
*
|
|
1931
|
+
* @param clipRect - DivRect to clip this instance with.
|
|
1932
|
+
* @returns - This DivRect instance.
|
|
1933
|
+
*/
|
|
1934
|
+
clipInPlace(clipRect) {
|
|
1935
|
+
this.left = Math.max(this.left, clipRect.left);
|
|
1936
|
+
this.right = Math.min(this.right, clipRect.right);
|
|
1937
|
+
this.anchorX = clamp(this.anchorX, this.left, this.right);
|
|
1938
|
+
this.top = Math.max(this.top, clipRect.top);
|
|
1939
|
+
this.bottom = Math.min(this.bottom, clipRect.bottom);
|
|
1940
|
+
this.anchorY = clamp(this.anchorY, this.top, this.bottom);
|
|
1941
|
+
return this;
|
|
1136
1942
|
}
|
|
1137
|
-
|
|
1138
|
-
|
|
1943
|
+
/**
|
|
1944
|
+
* Clip this Rect by given Rect. Immutable, return modified copy.
|
|
1945
|
+
*
|
|
1946
|
+
* @param clipRect - DivRecto to clip this instance with.
|
|
1947
|
+
* @returns - Clipped DivRect copy.
|
|
1948
|
+
*/
|
|
1949
|
+
clipCopy(clipRect) {
|
|
1950
|
+
return this.copy().clipInPlace(clipRect);
|
|
1951
|
+
}
|
|
1952
|
+
/**
|
|
1953
|
+
* Scale Rect. Anchor pos is (anchorX, anchorY). Modifies this Rect.
|
|
1954
|
+
*
|
|
1955
|
+
* @param scaleX - Scale x-amount.
|
|
1956
|
+
* @param scaleY - Scale y-amount. If undefined then scale x-amount is used.
|
|
1957
|
+
* @returns This DivRect instance.
|
|
1958
|
+
*/
|
|
1959
|
+
scaleInPlace(scaleX, scaleY) {
|
|
1960
|
+
scaleY = scaleY ?? scaleX;
|
|
1961
|
+
this.left = this.anchorX - this.leftw * scaleX;
|
|
1962
|
+
this.right = this.anchorX + this.rightw * scaleX;
|
|
1963
|
+
this.top = this.anchorY - this.toph * scaleY;
|
|
1964
|
+
this.bottom = this.anchorY + this.bottomh * scaleY;
|
|
1965
|
+
return this;
|
|
1139
1966
|
}
|
|
1140
|
-
|
|
1141
|
-
|
|
1967
|
+
/**
|
|
1968
|
+
* Scale Rect. Anchor pos is (anchorX, anchorY). Immutable, returns modified copy.
|
|
1969
|
+
*
|
|
1970
|
+
* @param scaleX - Scale x-amount.
|
|
1971
|
+
* @param scaleY - Scale y-amount. If undefined then scale x-amount is used.
|
|
1972
|
+
* @returns Scaled copy of this DivRect.
|
|
1973
|
+
*/
|
|
1974
|
+
scaleCopy(scaleX, scaleY) {
|
|
1975
|
+
return this.copy().scaleInPlace(scaleX, scaleY);
|
|
1976
|
+
}
|
|
1977
|
+
/**
|
|
1978
|
+
* Get this DivRect instance.
|
|
1979
|
+
* @returns - This DivRect instance.
|
|
1980
|
+
*/
|
|
1981
|
+
getRect() {
|
|
1982
|
+
return this;
|
|
1142
1983
|
}
|
|
1143
1984
|
};
|
|
1144
1985
|
|
|
@@ -1239,93 +2080,37 @@ var LRUCache = class {
|
|
|
1239
2080
|
}
|
|
1240
2081
|
};
|
|
1241
2082
|
|
|
1242
|
-
// src/core/small-int-cache.ts
|
|
1243
|
-
var SmallIntCache = class {
|
|
1244
|
-
// for keys < 0
|
|
1245
|
-
constructor() {
|
|
1246
|
-
__publicField(this, "pos");
|
|
1247
|
-
// for keys >= 0
|
|
1248
|
-
__publicField(this, "neg");
|
|
1249
|
-
this.pos = [];
|
|
1250
|
-
this.neg = [];
|
|
1251
|
-
}
|
|
1252
|
-
set(key, value) {
|
|
1253
|
-
if (!isInteger(key)) {
|
|
1254
|
-
throw new Error("Key must be an integer");
|
|
1255
|
-
} else if (key >= 0) {
|
|
1256
|
-
this.pos[key] = value;
|
|
1257
|
-
} else {
|
|
1258
|
-
this.neg[-key - 1] = value;
|
|
1259
|
-
}
|
|
1260
|
-
}
|
|
1261
|
-
get(key) {
|
|
1262
|
-
if (!isInteger(key)) {
|
|
1263
|
-
throw new Error("Key must be an integer");
|
|
1264
|
-
} else if (key >= 0) {
|
|
1265
|
-
return this.pos[key];
|
|
1266
|
-
} else {
|
|
1267
|
-
return this.neg[-key - 1];
|
|
1268
|
-
}
|
|
1269
|
-
}
|
|
1270
|
-
has(key) {
|
|
1271
|
-
if (!isInteger(key)) {
|
|
1272
|
-
return false;
|
|
1273
|
-
} else if (key >= 0) {
|
|
1274
|
-
return key in this.pos;
|
|
1275
|
-
} else {
|
|
1276
|
-
return -key - 1 in this.neg;
|
|
1277
|
-
}
|
|
1278
|
-
}
|
|
1279
|
-
delete(key) {
|
|
1280
|
-
if (!isInteger(key)) {
|
|
1281
|
-
return;
|
|
1282
|
-
} else if (key >= 0) {
|
|
1283
|
-
delete this.pos[key];
|
|
1284
|
-
} else {
|
|
1285
|
-
delete this.neg[-key - 1];
|
|
1286
|
-
}
|
|
1287
|
-
}
|
|
1288
|
-
clear() {
|
|
1289
|
-
this.pos = [];
|
|
1290
|
-
this.neg = [];
|
|
1291
|
-
}
|
|
1292
|
-
};
|
|
1293
|
-
|
|
1294
2083
|
// src/core/index-array.ts
|
|
1295
2084
|
var IndexArray = class _IndexArray {
|
|
1296
2085
|
constructor(entries) {
|
|
1297
|
-
|
|
1298
|
-
__publicField(this, "posEl");
|
|
2086
|
+
__publicField(this, "posVal");
|
|
1299
2087
|
__publicField(this, "hasPos");
|
|
1300
|
-
//
|
|
1301
|
-
__publicField(this, "
|
|
2088
|
+
// Number of values
|
|
2089
|
+
__publicField(this, "valCount");
|
|
1302
2090
|
if (entries instanceof _IndexArray) {
|
|
1303
|
-
this.
|
|
2091
|
+
this.posVal = entries.posVal.slice();
|
|
1304
2092
|
this.hasPos = entries.hasPos.slice();
|
|
1305
|
-
this.
|
|
2093
|
+
this.valCount = entries.valCount;
|
|
1306
2094
|
} else {
|
|
1307
|
-
this.
|
|
2095
|
+
this.posVal = [];
|
|
1308
2096
|
this.hasPos = [];
|
|
1309
|
-
this.
|
|
2097
|
+
this.valCount = 0;
|
|
1310
2098
|
if (entries) {
|
|
1311
|
-
for (const [id,
|
|
1312
|
-
this.set(id,
|
|
2099
|
+
for (const [id, value] of entries) {
|
|
2100
|
+
this.set(id, value);
|
|
1313
2101
|
}
|
|
1314
2102
|
}
|
|
1315
2103
|
}
|
|
1316
2104
|
}
|
|
1317
|
-
static toNegIndex(id) {
|
|
1318
|
-
return -id - 1;
|
|
1319
|
-
}
|
|
1320
2105
|
static validateIndex(id) {
|
|
1321
|
-
if (!
|
|
2106
|
+
if (!isIntegerGte2(id, 0)) throw new Error(`Invalid index ${id} - must be an integer >= 0!`);
|
|
1322
2107
|
return id;
|
|
1323
2108
|
}
|
|
1324
2109
|
get posLen() {
|
|
1325
2110
|
return this.hasPos.length;
|
|
1326
2111
|
}
|
|
1327
2112
|
get size() {
|
|
1328
|
-
return this.
|
|
2113
|
+
return this.valCount;
|
|
1329
2114
|
}
|
|
1330
2115
|
isEmpty() {
|
|
1331
2116
|
return this.size === 0;
|
|
@@ -1334,22 +2119,22 @@ var IndexArray = class _IndexArray {
|
|
|
1334
2119
|
_IndexArray.validateIndex(id);
|
|
1335
2120
|
return this.hasPos[id] === true;
|
|
1336
2121
|
}
|
|
1337
|
-
set(id,
|
|
2122
|
+
set(id, value) {
|
|
1338
2123
|
_IndexArray.validateIndex(id);
|
|
1339
|
-
if (this.hasPos[id] !== true) this.
|
|
1340
|
-
this.
|
|
2124
|
+
if (this.hasPos[id] !== true) this.valCount++;
|
|
2125
|
+
this.posVal[id] = value;
|
|
1341
2126
|
this.hasPos[id] = true;
|
|
1342
2127
|
}
|
|
1343
2128
|
get(id) {
|
|
1344
2129
|
_IndexArray.validateIndex(id);
|
|
1345
|
-
return this.hasPos[id] ? this.
|
|
2130
|
+
return this.hasPos[id] ? this.posVal[id] : void 0;
|
|
1346
2131
|
}
|
|
1347
2132
|
getOrDefault(id, defaultValue) {
|
|
1348
2133
|
return this.get(id) ?? defaultValue;
|
|
1349
2134
|
}
|
|
1350
2135
|
getOrCreate(id, creatorOrValue) {
|
|
1351
2136
|
if (!this.has(id)) {
|
|
1352
|
-
const value =
|
|
2137
|
+
const value = isFunction2(creatorOrValue) ? creatorOrValue() : creatorOrValue;
|
|
1353
2138
|
this.set(id, value);
|
|
1354
2139
|
return value;
|
|
1355
2140
|
}
|
|
@@ -1358,19 +2143,19 @@ var IndexArray = class _IndexArray {
|
|
|
1358
2143
|
delete(id) {
|
|
1359
2144
|
_IndexArray.validateIndex(id);
|
|
1360
2145
|
if (!this.hasPos[id]) return false;
|
|
1361
|
-
this.
|
|
2146
|
+
this.posVal[id] = void 0;
|
|
1362
2147
|
this.hasPos[id] = false;
|
|
1363
|
-
this.
|
|
2148
|
+
this.valCount--;
|
|
1364
2149
|
return true;
|
|
1365
2150
|
}
|
|
1366
2151
|
clear() {
|
|
1367
|
-
this.
|
|
2152
|
+
this.posVal = [];
|
|
1368
2153
|
this.hasPos = [];
|
|
1369
|
-
this.
|
|
2154
|
+
this.valCount = 0;
|
|
1370
2155
|
}
|
|
1371
2156
|
forEach(callbackfn, thisArg) {
|
|
1372
|
-
for (const [id,
|
|
1373
|
-
callbackfn.call(thisArg,
|
|
2157
|
+
for (const [id, value] of this.entries()) {
|
|
2158
|
+
callbackfn.call(thisArg, value, id, this);
|
|
1374
2159
|
}
|
|
1375
2160
|
}
|
|
1376
2161
|
*indices() {
|
|
@@ -1380,12 +2165,12 @@ var IndexArray = class _IndexArray {
|
|
|
1380
2165
|
}
|
|
1381
2166
|
*values() {
|
|
1382
2167
|
for (let id = 0; id < this.posLen; id++) {
|
|
1383
|
-
if (this.hasPos[id]) yield this.
|
|
2168
|
+
if (this.hasPos[id]) yield this.posVal[id];
|
|
1384
2169
|
}
|
|
1385
2170
|
}
|
|
1386
2171
|
*entries() {
|
|
1387
2172
|
for (let id = 0; id < this.posLen; id++) {
|
|
1388
|
-
if (this.hasPos[id]) yield [id, this.
|
|
2173
|
+
if (this.hasPos[id]) yield [id, this.posVal[id]];
|
|
1389
2174
|
}
|
|
1390
2175
|
}
|
|
1391
2176
|
indicesArray() {
|
|
@@ -1403,13 +2188,13 @@ var IndexArray = class _IndexArray {
|
|
|
1403
2188
|
}
|
|
1404
2189
|
}
|
|
1405
2190
|
*kvValues() {
|
|
1406
|
-
for (const
|
|
1407
|
-
yield
|
|
2191
|
+
for (const value of this.values()) {
|
|
2192
|
+
yield value;
|
|
1408
2193
|
}
|
|
1409
2194
|
}
|
|
1410
2195
|
*kvEntries() {
|
|
1411
|
-
for (const [id,
|
|
1412
|
-
yield [[id],
|
|
2196
|
+
for (const [id, value] of this.entries()) {
|
|
2197
|
+
yield [[id], value];
|
|
1413
2198
|
}
|
|
1414
2199
|
}
|
|
1415
2200
|
*[Symbol.iterator]() {
|
|
@@ -1429,21 +2214,21 @@ var IndexArray = class _IndexArray {
|
|
|
1429
2214
|
return this;
|
|
1430
2215
|
}
|
|
1431
2216
|
some(fn) {
|
|
1432
|
-
for (const [id,
|
|
1433
|
-
if (fn(
|
|
2217
|
+
for (const [id, value] of this.entries()) {
|
|
2218
|
+
if (fn(value, id)) return true;
|
|
1434
2219
|
}
|
|
1435
2220
|
return false;
|
|
1436
2221
|
}
|
|
1437
2222
|
every(fn) {
|
|
1438
|
-
for (const [id,
|
|
1439
|
-
if (!fn(
|
|
2223
|
+
for (const [id, value] of this.entries()) {
|
|
2224
|
+
if (!fn(value, id)) return false;
|
|
1440
2225
|
}
|
|
1441
2226
|
return true;
|
|
1442
2227
|
}
|
|
1443
|
-
filter(
|
|
1444
|
-
|
|
1445
|
-
for (const [id,
|
|
1446
|
-
if (
|
|
2228
|
+
filter(predicate) {
|
|
2229
|
+
const result = new this.constructor();
|
|
2230
|
+
for (const [id, value] of this.entries()) {
|
|
2231
|
+
if (predicate(value, id, this)) result.set(id, value);
|
|
1447
2232
|
}
|
|
1448
2233
|
return result;
|
|
1449
2234
|
}
|
|
@@ -1466,40 +2251,40 @@ var IndexArray = class _IndexArray {
|
|
|
1466
2251
|
start = first;
|
|
1467
2252
|
}
|
|
1468
2253
|
for (let current = start; !current.done; current = iterator.next()) {
|
|
1469
|
-
const [id,
|
|
1470
|
-
acc = fn(acc,
|
|
2254
|
+
const [id, value] = current.value;
|
|
2255
|
+
acc = fn(acc, value, id);
|
|
1471
2256
|
}
|
|
1472
2257
|
return acc;
|
|
1473
2258
|
}
|
|
1474
2259
|
mapToArray(fn) {
|
|
1475
2260
|
let result = [];
|
|
1476
|
-
for (const [id,
|
|
1477
|
-
result.push(fn(
|
|
2261
|
+
for (const [id, value] of this.entries()) {
|
|
2262
|
+
result.push(fn(value, id));
|
|
1478
2263
|
}
|
|
1479
2264
|
return result;
|
|
1480
2265
|
}
|
|
1481
2266
|
map(fn) {
|
|
1482
2267
|
let result = new _IndexArray();
|
|
1483
|
-
for (const [id,
|
|
1484
|
-
result.set(id, fn(
|
|
2268
|
+
for (const [id, value] of this.entries()) {
|
|
2269
|
+
result.set(id, fn(value, id));
|
|
1485
2270
|
}
|
|
1486
2271
|
return result;
|
|
1487
2272
|
}
|
|
1488
|
-
equals(other,
|
|
2273
|
+
equals(other, eq2) {
|
|
1489
2274
|
if (this.size !== other.size) return false;
|
|
1490
|
-
|
|
2275
|
+
eq2 ?? (eq2 = (a, b) => a === b);
|
|
1491
2276
|
const posLen = Math.max(this.posLen, other.posLen);
|
|
1492
2277
|
for (let i = 0; i < posLen; ++i) {
|
|
1493
2278
|
const hasA = this.hasPos[i];
|
|
1494
2279
|
const hasB = other.hasPos[i];
|
|
1495
2280
|
if (hasA !== hasB) return false;
|
|
1496
|
-
if (hasA && !
|
|
2281
|
+
if (hasA && !eq2(this.posVal[i], other.posVal[i])) return false;
|
|
1497
2282
|
}
|
|
1498
2283
|
return true;
|
|
1499
2284
|
}
|
|
1500
2285
|
toString() {
|
|
1501
2286
|
if (this.size === 0) return `IndexArray[ ]`;
|
|
1502
|
-
const entries = this.entriesArray().map(([id,
|
|
2287
|
+
const entries = this.entriesArray().map(([id, value]) => `${id}: ${value}`).join(", ");
|
|
1503
2288
|
return `IndexArray[ ${entries} ]`;
|
|
1504
2289
|
}
|
|
1505
2290
|
};
|
|
@@ -1507,29 +2292,29 @@ var IndexArray = class _IndexArray {
|
|
|
1507
2292
|
// src/core/signed-index-array.ts
|
|
1508
2293
|
var SignedIndexArray = class _SignedIndexArray {
|
|
1509
2294
|
constructor(entries) {
|
|
1510
|
-
//
|
|
1511
|
-
__publicField(this, "
|
|
2295
|
+
// For indexes >= 0
|
|
2296
|
+
__publicField(this, "posVal");
|
|
1512
2297
|
__publicField(this, "hasPos");
|
|
1513
|
-
//
|
|
1514
|
-
__publicField(this, "
|
|
2298
|
+
// For indexes < 0
|
|
2299
|
+
__publicField(this, "negVal");
|
|
1515
2300
|
__publicField(this, "hasNeg");
|
|
1516
|
-
//
|
|
1517
|
-
__publicField(this, "
|
|
2301
|
+
// Number of values
|
|
2302
|
+
__publicField(this, "valCount");
|
|
1518
2303
|
if (entries instanceof _SignedIndexArray) {
|
|
1519
|
-
this.
|
|
2304
|
+
this.negVal = entries.negVal.slice();
|
|
1520
2305
|
this.hasNeg = entries.hasNeg.slice();
|
|
1521
|
-
this.
|
|
2306
|
+
this.posVal = entries.posVal.slice();
|
|
1522
2307
|
this.hasPos = entries.hasPos.slice();
|
|
1523
|
-
this.
|
|
2308
|
+
this.valCount = entries.valCount;
|
|
1524
2309
|
} else {
|
|
1525
|
-
this.
|
|
2310
|
+
this.negVal = [];
|
|
1526
2311
|
this.hasNeg = [];
|
|
1527
|
-
this.
|
|
2312
|
+
this.posVal = [];
|
|
1528
2313
|
this.hasPos = [];
|
|
1529
|
-
this.
|
|
2314
|
+
this.valCount = 0;
|
|
1530
2315
|
if (entries) {
|
|
1531
|
-
for (const [id,
|
|
1532
|
-
this.set(id,
|
|
2316
|
+
for (const [id, value] of entries) {
|
|
2317
|
+
this.set(id, value);
|
|
1533
2318
|
}
|
|
1534
2319
|
}
|
|
1535
2320
|
}
|
|
@@ -1538,11 +2323,11 @@ var SignedIndexArray = class _SignedIndexArray {
|
|
|
1538
2323
|
return -id - 1;
|
|
1539
2324
|
}
|
|
1540
2325
|
static validateIndex(id) {
|
|
1541
|
-
if (!
|
|
2326
|
+
if (!isInteger2(id)) throw new Error(`Invalid index ${id} - must be an integer!`);
|
|
1542
2327
|
return id;
|
|
1543
2328
|
}
|
|
1544
2329
|
get size() {
|
|
1545
|
-
return this.
|
|
2330
|
+
return this.valCount;
|
|
1546
2331
|
}
|
|
1547
2332
|
isEmpty() {
|
|
1548
2333
|
return this.size === 0;
|
|
@@ -1561,26 +2346,26 @@ var SignedIndexArray = class _SignedIndexArray {
|
|
|
1561
2346
|
return this.hasNeg[_SignedIndexArray.toNegIndex(id)] === true;
|
|
1562
2347
|
}
|
|
1563
2348
|
}
|
|
1564
|
-
set(id,
|
|
2349
|
+
set(id, value) {
|
|
1565
2350
|
_SignedIndexArray.validateIndex(id);
|
|
1566
2351
|
if (id >= 0) {
|
|
1567
|
-
if (this.hasPos[id] !== true) this.
|
|
1568
|
-
this.
|
|
2352
|
+
if (this.hasPos[id] !== true) this.valCount++;
|
|
2353
|
+
this.posVal[id] = value;
|
|
1569
2354
|
this.hasPos[id] = true;
|
|
1570
2355
|
} else {
|
|
1571
2356
|
let negId = _SignedIndexArray.toNegIndex(id);
|
|
1572
|
-
if (this.hasNeg[negId] !== true) this.
|
|
1573
|
-
this.
|
|
2357
|
+
if (this.hasNeg[negId] !== true) this.valCount++;
|
|
2358
|
+
this.negVal[negId] = value;
|
|
1574
2359
|
this.hasNeg[negId] = true;
|
|
1575
2360
|
}
|
|
1576
2361
|
}
|
|
1577
2362
|
get(id) {
|
|
1578
2363
|
_SignedIndexArray.validateIndex(id);
|
|
1579
2364
|
if (id >= 0) {
|
|
1580
|
-
return this.hasPos[id] ? this.
|
|
2365
|
+
return this.hasPos[id] ? this.posVal[id] : void 0;
|
|
1581
2366
|
} else {
|
|
1582
2367
|
let negId = _SignedIndexArray.toNegIndex(id);
|
|
1583
|
-
return this.hasNeg[negId] ? this.
|
|
2368
|
+
return this.hasNeg[negId] ? this.negVal[negId] : void 0;
|
|
1584
2369
|
}
|
|
1585
2370
|
}
|
|
1586
2371
|
getOrDefault(id, defaultValue) {
|
|
@@ -1588,7 +2373,7 @@ var SignedIndexArray = class _SignedIndexArray {
|
|
|
1588
2373
|
}
|
|
1589
2374
|
getOrCreate(id, creatorOrValue) {
|
|
1590
2375
|
if (!this.has(id)) {
|
|
1591
|
-
const value =
|
|
2376
|
+
const value = isFunction2(creatorOrValue) ? creatorOrValue() : creatorOrValue;
|
|
1592
2377
|
this.set(id, value);
|
|
1593
2378
|
return value;
|
|
1594
2379
|
}
|
|
@@ -1597,25 +2382,25 @@ var SignedIndexArray = class _SignedIndexArray {
|
|
|
1597
2382
|
delete(id) {
|
|
1598
2383
|
_SignedIndexArray.validateIndex(id);
|
|
1599
2384
|
const isPos = id >= 0;
|
|
1600
|
-
const arr = isPos ? this.
|
|
2385
|
+
const arr = isPos ? this.posVal : this.negVal;
|
|
1601
2386
|
const has = isPos ? this.hasPos : this.hasNeg;
|
|
1602
2387
|
const idx = isPos ? id : _SignedIndexArray.toNegIndex(id);
|
|
1603
2388
|
if (!has[idx]) return false;
|
|
1604
2389
|
arr[idx] = void 0;
|
|
1605
2390
|
has[idx] = false;
|
|
1606
|
-
this.
|
|
2391
|
+
this.valCount--;
|
|
1607
2392
|
return true;
|
|
1608
2393
|
}
|
|
1609
2394
|
clear() {
|
|
1610
|
-
this.
|
|
2395
|
+
this.negVal = [];
|
|
1611
2396
|
this.hasNeg = [];
|
|
1612
|
-
this.
|
|
2397
|
+
this.posVal = [];
|
|
1613
2398
|
this.hasPos = [];
|
|
1614
|
-
this.
|
|
2399
|
+
this.valCount = 0;
|
|
1615
2400
|
}
|
|
1616
2401
|
forEach(callbackfn, thisArg) {
|
|
1617
|
-
for (const [id,
|
|
1618
|
-
callbackfn.call(thisArg,
|
|
2402
|
+
for (const [id, value] of this.entries()) {
|
|
2403
|
+
callbackfn.call(thisArg, value, id, this);
|
|
1619
2404
|
}
|
|
1620
2405
|
}
|
|
1621
2406
|
*indices() {
|
|
@@ -1628,18 +2413,18 @@ var SignedIndexArray = class _SignedIndexArray {
|
|
|
1628
2413
|
}
|
|
1629
2414
|
*values() {
|
|
1630
2415
|
for (let id = this.negLen - 1; id >= 0; id--) {
|
|
1631
|
-
if (this.hasNeg[id]) yield this.
|
|
2416
|
+
if (this.hasNeg[id]) yield this.negVal[id];
|
|
1632
2417
|
}
|
|
1633
2418
|
for (let id = 0; id < this.posLen; id++) {
|
|
1634
|
-
if (this.hasPos[id]) yield this.
|
|
2419
|
+
if (this.hasPos[id]) yield this.posVal[id];
|
|
1635
2420
|
}
|
|
1636
2421
|
}
|
|
1637
2422
|
*entries() {
|
|
1638
2423
|
for (let id = this.negLen - 1; id >= 0; id--) {
|
|
1639
|
-
if (this.hasNeg[id]) yield [_SignedIndexArray.toNegIndex(id), this.
|
|
2424
|
+
if (this.hasNeg[id]) yield [_SignedIndexArray.toNegIndex(id), this.negVal[id]];
|
|
1640
2425
|
}
|
|
1641
2426
|
for (let id = 0; id < this.posLen; id++) {
|
|
1642
|
-
if (this.hasPos[id]) yield [id, this.
|
|
2427
|
+
if (this.hasPos[id]) yield [id, this.posVal[id]];
|
|
1643
2428
|
}
|
|
1644
2429
|
}
|
|
1645
2430
|
indicesArray() {
|
|
@@ -1657,13 +2442,13 @@ var SignedIndexArray = class _SignedIndexArray {
|
|
|
1657
2442
|
}
|
|
1658
2443
|
}
|
|
1659
2444
|
*kvValues() {
|
|
1660
|
-
for (const
|
|
1661
|
-
yield
|
|
2445
|
+
for (const value of this.values()) {
|
|
2446
|
+
yield value;
|
|
1662
2447
|
}
|
|
1663
2448
|
}
|
|
1664
2449
|
*kvEntries() {
|
|
1665
|
-
for (const [id,
|
|
1666
|
-
yield [[id],
|
|
2450
|
+
for (const [id, value] of this.entries()) {
|
|
2451
|
+
yield [[id], value];
|
|
1667
2452
|
}
|
|
1668
2453
|
}
|
|
1669
2454
|
*[Symbol.iterator]() {
|
|
@@ -1683,21 +2468,21 @@ var SignedIndexArray = class _SignedIndexArray {
|
|
|
1683
2468
|
return this;
|
|
1684
2469
|
}
|
|
1685
2470
|
some(fn) {
|
|
1686
|
-
for (const [id,
|
|
1687
|
-
if (fn(
|
|
2471
|
+
for (const [id, value] of this.entries()) {
|
|
2472
|
+
if (fn(value, id)) return true;
|
|
1688
2473
|
}
|
|
1689
2474
|
return false;
|
|
1690
2475
|
}
|
|
1691
2476
|
every(fn) {
|
|
1692
|
-
for (const [id,
|
|
1693
|
-
if (!fn(
|
|
2477
|
+
for (const [id, value] of this.entries()) {
|
|
2478
|
+
if (!fn(value, id)) return false;
|
|
1694
2479
|
}
|
|
1695
2480
|
return true;
|
|
1696
2481
|
}
|
|
1697
|
-
filter(
|
|
1698
|
-
|
|
1699
|
-
for (const [id,
|
|
1700
|
-
if (
|
|
2482
|
+
filter(predicate) {
|
|
2483
|
+
const result = new this.constructor();
|
|
2484
|
+
for (const [id, value] of this.entries()) {
|
|
2485
|
+
if (predicate(value, id, this)) result.set(id, value);
|
|
1701
2486
|
}
|
|
1702
2487
|
return result;
|
|
1703
2488
|
}
|
|
@@ -1720,52 +2505,52 @@ var SignedIndexArray = class _SignedIndexArray {
|
|
|
1720
2505
|
start = first;
|
|
1721
2506
|
}
|
|
1722
2507
|
for (let current = start; !current.done; current = iterator.next()) {
|
|
1723
|
-
const [id,
|
|
1724
|
-
acc = fn(acc,
|
|
2508
|
+
const [id, value] = current.value;
|
|
2509
|
+
acc = fn(acc, value, id);
|
|
1725
2510
|
}
|
|
1726
2511
|
return acc;
|
|
1727
2512
|
}
|
|
1728
2513
|
mapToArray(fn) {
|
|
1729
2514
|
let result = [];
|
|
1730
|
-
for (const [id,
|
|
1731
|
-
result.push(fn(
|
|
2515
|
+
for (const [id, value] of this.entries()) {
|
|
2516
|
+
result.push(fn(value, id));
|
|
1732
2517
|
}
|
|
1733
2518
|
return result;
|
|
1734
2519
|
}
|
|
1735
2520
|
map(fn) {
|
|
1736
2521
|
let result = new _SignedIndexArray();
|
|
1737
|
-
for (const [id,
|
|
1738
|
-
result.set(id, fn(
|
|
2522
|
+
for (const [id, value] of this.entries()) {
|
|
2523
|
+
result.set(id, fn(value, id));
|
|
1739
2524
|
}
|
|
1740
2525
|
return result;
|
|
1741
2526
|
}
|
|
1742
|
-
equals(other,
|
|
2527
|
+
equals(other, eq2) {
|
|
1743
2528
|
if (this.size !== other.size) return false;
|
|
1744
|
-
|
|
2529
|
+
eq2 ?? (eq2 = (a, b) => a === b);
|
|
1745
2530
|
const posLen = Math.max(this.posLen, other.posLen);
|
|
1746
2531
|
for (let i = 0; i < posLen; ++i) {
|
|
1747
2532
|
const hasA = this.hasPos[i];
|
|
1748
2533
|
const hasB = other.hasPos[i];
|
|
1749
2534
|
if (hasA !== hasB) return false;
|
|
1750
|
-
if (hasA && !
|
|
2535
|
+
if (hasA && !eq2(this.posVal[i], other.posVal[i])) return false;
|
|
1751
2536
|
}
|
|
1752
2537
|
const negLen = Math.max(this.negLen, other.negLen);
|
|
1753
2538
|
for (let i = 0; i < negLen; ++i) {
|
|
1754
2539
|
const hasA = this.hasNeg[i];
|
|
1755
2540
|
const hasB = other.hasNeg[i];
|
|
1756
2541
|
if (hasA !== hasB) return false;
|
|
1757
|
-
if (hasA && !
|
|
2542
|
+
if (hasA && !eq2(this.negVal[i], other.negVal[i])) return false;
|
|
1758
2543
|
}
|
|
1759
2544
|
return true;
|
|
1760
2545
|
}
|
|
1761
2546
|
toString() {
|
|
1762
2547
|
if (this.size === 0) return `SignedIndexArray[ ]`;
|
|
1763
|
-
const entries = this.entriesArray().map(([id,
|
|
2548
|
+
const entries = this.entriesArray().map(([id, value]) => `${id}: ${value}`).join(", ");
|
|
1764
2549
|
return `SignedIndexArray[ ${entries} ]`;
|
|
1765
2550
|
}
|
|
1766
2551
|
};
|
|
1767
2552
|
|
|
1768
|
-
// src/core/
|
|
2553
|
+
// src/core/map1.ts
|
|
1769
2554
|
var Map1 = class _Map1 {
|
|
1770
2555
|
constructor(entries) {
|
|
1771
2556
|
__publicField(this, "map1");
|
|
@@ -1786,7 +2571,7 @@ var Map1 = class _Map1 {
|
|
|
1786
2571
|
}
|
|
1787
2572
|
getOrCreate(key1, creatorOrValue) {
|
|
1788
2573
|
if (!this.has(key1)) {
|
|
1789
|
-
const value =
|
|
2574
|
+
const value = isFunction2(creatorOrValue) ? creatorOrValue() : creatorOrValue;
|
|
1790
2575
|
this.set(key1, value);
|
|
1791
2576
|
return value;
|
|
1792
2577
|
}
|
|
@@ -1869,16 +2654,33 @@ var Map1 = class _Map1 {
|
|
|
1869
2654
|
}
|
|
1870
2655
|
return true;
|
|
1871
2656
|
}
|
|
1872
|
-
filter(
|
|
1873
|
-
|
|
2657
|
+
filter(predicate) {
|
|
2658
|
+
const result = new this.constructor();
|
|
1874
2659
|
for (const [key1, value] of this.map1) {
|
|
1875
|
-
if (
|
|
2660
|
+
if (predicate(value, key1, this)) result.set(key1, value);
|
|
1876
2661
|
}
|
|
1877
2662
|
return result;
|
|
1878
2663
|
}
|
|
1879
2664
|
reduce(fn, init) {
|
|
1880
|
-
let
|
|
1881
|
-
|
|
2665
|
+
let iterator = this.entries();
|
|
2666
|
+
let first = iterator.next();
|
|
2667
|
+
if (first.done) {
|
|
2668
|
+
if (arguments.length < 2) {
|
|
2669
|
+
throw new TypeError("Reduce of empty Map1 with no initial value!");
|
|
2670
|
+
}
|
|
2671
|
+
return init;
|
|
2672
|
+
}
|
|
2673
|
+
let acc;
|
|
2674
|
+
let start;
|
|
2675
|
+
if (arguments.length < 2) {
|
|
2676
|
+
acc = first.value[1];
|
|
2677
|
+
start = iterator.next();
|
|
2678
|
+
} else {
|
|
2679
|
+
acc = init;
|
|
2680
|
+
start = first;
|
|
2681
|
+
}
|
|
2682
|
+
for (let current = start; !current.done; current = iterator.next()) {
|
|
2683
|
+
const [key1, value] = current.value;
|
|
1882
2684
|
acc = fn(acc, value, key1);
|
|
1883
2685
|
}
|
|
1884
2686
|
return acc;
|
|
@@ -1902,9 +2704,11 @@ var Map1 = class _Map1 {
|
|
|
1902
2704
|
}
|
|
1903
2705
|
toString() {
|
|
1904
2706
|
const entries = [...this.map1].map(([k, v]) => `${k} => ${v}`).join(", ");
|
|
1905
|
-
return `Map1(${this.
|
|
2707
|
+
return entries.length === 0 ? `Map1(0){ }` : `Map1(${this.size}){ ${entries} }`;
|
|
1906
2708
|
}
|
|
1907
2709
|
};
|
|
2710
|
+
|
|
2711
|
+
// src/core/map2.ts
|
|
1908
2712
|
var Map2 = class _Map2 {
|
|
1909
2713
|
constructor(entries) {
|
|
1910
2714
|
__publicField(this, "map1", /* @__PURE__ */ new Map());
|
|
@@ -1934,7 +2738,7 @@ var Map2 = class _Map2 {
|
|
|
1934
2738
|
}
|
|
1935
2739
|
getOrCreate(key1, key2, creatorOrValue) {
|
|
1936
2740
|
if (!this.has(key1, key2)) {
|
|
1937
|
-
const value =
|
|
2741
|
+
const value = isFunction2(creatorOrValue) ? creatorOrValue() : creatorOrValue;
|
|
1938
2742
|
this.set(key1, key2, value);
|
|
1939
2743
|
return value;
|
|
1940
2744
|
}
|
|
@@ -2030,21 +2834,36 @@ var Map2 = class _Map2 {
|
|
|
2030
2834
|
}
|
|
2031
2835
|
return true;
|
|
2032
2836
|
}
|
|
2033
|
-
filter(
|
|
2034
|
-
|
|
2837
|
+
filter(predicate) {
|
|
2838
|
+
const result = new this.constructor();
|
|
2035
2839
|
for (const [key1, map2] of this.map1) {
|
|
2036
2840
|
for (const [key2, value] of map2) {
|
|
2037
|
-
if (
|
|
2841
|
+
if (predicate(value, key1, key2, this)) result.set(key1, key2, value);
|
|
2038
2842
|
}
|
|
2039
2843
|
}
|
|
2040
2844
|
return result;
|
|
2041
2845
|
}
|
|
2042
2846
|
reduce(fn, init) {
|
|
2043
|
-
let
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2847
|
+
let iterator = this.entries();
|
|
2848
|
+
let first = iterator.next();
|
|
2849
|
+
if (first.done) {
|
|
2850
|
+
if (arguments.length < 2) {
|
|
2851
|
+
throw new TypeError("Reduce of empty Map2 with no initial value!");
|
|
2047
2852
|
}
|
|
2853
|
+
return init;
|
|
2854
|
+
}
|
|
2855
|
+
let acc;
|
|
2856
|
+
let start;
|
|
2857
|
+
if (arguments.length < 2) {
|
|
2858
|
+
acc = first.value[2];
|
|
2859
|
+
start = iterator.next();
|
|
2860
|
+
} else {
|
|
2861
|
+
acc = init;
|
|
2862
|
+
start = first;
|
|
2863
|
+
}
|
|
2864
|
+
for (let current = start; !current.done; current = iterator.next()) {
|
|
2865
|
+
const [key1, key2, value] = current.value;
|
|
2866
|
+
acc = fn(acc, value, key1, key2);
|
|
2048
2867
|
}
|
|
2049
2868
|
return acc;
|
|
2050
2869
|
}
|
|
@@ -2081,9 +2900,11 @@ var Map2 = class _Map2 {
|
|
|
2081
2900
|
const inner = [...map2].map(([key2, v]) => `${key2} => ${v}`).join(", ");
|
|
2082
2901
|
entries.push(`${key1} => { ${inner} }`);
|
|
2083
2902
|
}
|
|
2084
|
-
return `Map2(${this.size})
|
|
2903
|
+
return entries.length === 0 ? `Map2(0){ }` : `Map2(${this.size}){ ${entries} }`;
|
|
2085
2904
|
}
|
|
2086
2905
|
};
|
|
2906
|
+
|
|
2907
|
+
// src/core/map3.ts
|
|
2087
2908
|
var Map3 = class _Map3 {
|
|
2088
2909
|
constructor(entries) {
|
|
2089
2910
|
__publicField(this, "map1", /* @__PURE__ */ new Map());
|
|
@@ -2120,7 +2941,7 @@ var Map3 = class _Map3 {
|
|
|
2120
2941
|
}
|
|
2121
2942
|
getOrCreate(key1, key2, key3, creatorOrValue) {
|
|
2122
2943
|
if (!this.has(key1, key2, key3)) {
|
|
2123
|
-
const value =
|
|
2944
|
+
const value = isFunction2(creatorOrValue) ? creatorOrValue() : creatorOrValue;
|
|
2124
2945
|
this.set(key1, key2, key3, value);
|
|
2125
2946
|
return value;
|
|
2126
2947
|
}
|
|
@@ -2232,25 +3053,38 @@ var Map3 = class _Map3 {
|
|
|
2232
3053
|
}
|
|
2233
3054
|
return true;
|
|
2234
3055
|
}
|
|
2235
|
-
filter(
|
|
2236
|
-
|
|
3056
|
+
filter(predicate) {
|
|
3057
|
+
const result = new this.constructor();
|
|
2237
3058
|
for (const [key1, map2] of this.map1) {
|
|
2238
3059
|
for (const [key2, map3] of map2) {
|
|
2239
3060
|
for (const [key3, value] of map3) {
|
|
2240
|
-
if (
|
|
3061
|
+
if (predicate(value, key1, key2, key3, this)) result.set(key1, key2, key3, value);
|
|
2241
3062
|
}
|
|
2242
3063
|
}
|
|
2243
3064
|
}
|
|
2244
3065
|
return result;
|
|
2245
3066
|
}
|
|
2246
3067
|
reduce(fn, init) {
|
|
2247
|
-
let
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
}
|
|
3068
|
+
let iterator = this.entries();
|
|
3069
|
+
let first = iterator.next();
|
|
3070
|
+
if (first.done) {
|
|
3071
|
+
if (arguments.length < 2) {
|
|
3072
|
+
throw new TypeError("Reduce of empty Map3 with no initial value!");
|
|
2253
3073
|
}
|
|
3074
|
+
return init;
|
|
3075
|
+
}
|
|
3076
|
+
let acc;
|
|
3077
|
+
let start;
|
|
3078
|
+
if (arguments.length < 2) {
|
|
3079
|
+
acc = first.value[3];
|
|
3080
|
+
start = iterator.next();
|
|
3081
|
+
} else {
|
|
3082
|
+
acc = init;
|
|
3083
|
+
start = first;
|
|
3084
|
+
}
|
|
3085
|
+
for (let current = start; !current.done; current = iterator.next()) {
|
|
3086
|
+
const [key1, key2, key3, value] = current.value;
|
|
3087
|
+
acc = fn(acc, value, key1, key2, key3);
|
|
2254
3088
|
}
|
|
2255
3089
|
return acc;
|
|
2256
3090
|
}
|
|
@@ -2295,7 +3129,7 @@ var Map3 = class _Map3 {
|
|
|
2295
3129
|
entries.push(`${key1} => ${key2} => { ${inner} }`);
|
|
2296
3130
|
}
|
|
2297
3131
|
}
|
|
2298
|
-
return `Map3(${this.size})
|
|
3132
|
+
return entries.length === 0 ? `Map3(0){ }` : `Map3(${this.size}){ ${entries.join(", ")} }`;
|
|
2299
3133
|
}
|
|
2300
3134
|
};
|
|
2301
3135
|
|
|
@@ -2367,11 +3201,90 @@ var MultiContainer = class {
|
|
|
2367
3201
|
function asMulti(base) {
|
|
2368
3202
|
return new MultiContainer(base);
|
|
2369
3203
|
}
|
|
3204
|
+
|
|
3205
|
+
// src/deprecated/vec2.ts
|
|
3206
|
+
var Vec2 = class _Vec2 {
|
|
3207
|
+
constructor(x, y) {
|
|
3208
|
+
__publicField(this, "x");
|
|
3209
|
+
__publicField(this, "y");
|
|
3210
|
+
this.x = x ?? 0;
|
|
3211
|
+
this.y = y ?? 0;
|
|
3212
|
+
}
|
|
3213
|
+
length() {
|
|
3214
|
+
return Math.sqrt(this.x * this.x + this.y * this.y);
|
|
3215
|
+
}
|
|
3216
|
+
add(a) {
|
|
3217
|
+
return new _Vec2(this.x + a.x, this.y + a.y);
|
|
3218
|
+
}
|
|
3219
|
+
sub(a) {
|
|
3220
|
+
return new _Vec2(this.x - a.x, this.y - a.y);
|
|
3221
|
+
}
|
|
3222
|
+
mul(a) {
|
|
3223
|
+
return new _Vec2(this.x * a, this.y * a);
|
|
3224
|
+
}
|
|
3225
|
+
div(a) {
|
|
3226
|
+
return new _Vec2(this.x / a, this.y / a);
|
|
3227
|
+
}
|
|
3228
|
+
};
|
|
3229
|
+
|
|
3230
|
+
// src/deprecated/small-int-cache.ts
|
|
3231
|
+
var SmallIntCache = class {
|
|
3232
|
+
// for keys < 0
|
|
3233
|
+
constructor() {
|
|
3234
|
+
__publicField(this, "pos");
|
|
3235
|
+
// for keys >= 0
|
|
3236
|
+
__publicField(this, "neg");
|
|
3237
|
+
this.pos = [];
|
|
3238
|
+
this.neg = [];
|
|
3239
|
+
}
|
|
3240
|
+
set(key, value) {
|
|
3241
|
+
if (!guard_exports.isInteger(key)) {
|
|
3242
|
+
throw new Error("Key must be an integer");
|
|
3243
|
+
} else if (key >= 0) {
|
|
3244
|
+
this.pos[key] = value;
|
|
3245
|
+
} else {
|
|
3246
|
+
this.neg[-key - 1] = value;
|
|
3247
|
+
}
|
|
3248
|
+
}
|
|
3249
|
+
get(key) {
|
|
3250
|
+
if (!guard_exports.isInteger(key)) {
|
|
3251
|
+
throw new Error("Key must be an integer");
|
|
3252
|
+
} else if (key >= 0) {
|
|
3253
|
+
return this.pos[key];
|
|
3254
|
+
} else {
|
|
3255
|
+
return this.neg[-key - 1];
|
|
3256
|
+
}
|
|
3257
|
+
}
|
|
3258
|
+
has(key) {
|
|
3259
|
+
if (!guard_exports.isInteger(key)) {
|
|
3260
|
+
return false;
|
|
3261
|
+
} else if (key >= 0) {
|
|
3262
|
+
return key in this.pos;
|
|
3263
|
+
} else {
|
|
3264
|
+
return -key - 1 in this.neg;
|
|
3265
|
+
}
|
|
3266
|
+
}
|
|
3267
|
+
delete(key) {
|
|
3268
|
+
if (!guard_exports.isInteger(key)) {
|
|
3269
|
+
return;
|
|
3270
|
+
} else if (key >= 0) {
|
|
3271
|
+
delete this.pos[key];
|
|
3272
|
+
} else {
|
|
3273
|
+
delete this.neg[-key - 1];
|
|
3274
|
+
}
|
|
3275
|
+
}
|
|
3276
|
+
clear() {
|
|
3277
|
+
this.pos = [];
|
|
3278
|
+
this.neg = [];
|
|
3279
|
+
}
|
|
3280
|
+
};
|
|
2370
3281
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2371
3282
|
0 && (module.exports = {
|
|
2372
3283
|
Assert,
|
|
2373
3284
|
Cookies,
|
|
2374
3285
|
Device,
|
|
3286
|
+
DivRect,
|
|
3287
|
+
Guard,
|
|
2375
3288
|
IndexArray,
|
|
2376
3289
|
LRUCache,
|
|
2377
3290
|
Map1,
|
|
@@ -2382,6 +3295,7 @@ function asMulti(base) {
|
|
|
2382
3295
|
SmallIntCache,
|
|
2383
3296
|
Stack,
|
|
2384
3297
|
Utils,
|
|
3298
|
+
Vec,
|
|
2385
3299
|
Vec2,
|
|
2386
3300
|
asMulti
|
|
2387
3301
|
});
|