@tspro/ts-utils-lib 1.17.0 → 1.19.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 +20 -0
- package/README.md +4 -4
- package/dist/index.d.mts +470 -177
- package/dist/index.d.ts +470 -177
- package/dist/index.js +1144 -609
- package/dist/index.mjs +1143 -609
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* TsUtilsLib v1.
|
|
1
|
+
/* TsUtilsLib v1.19.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,10 +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
29
|
DivRect: () => DivRect,
|
|
30
|
+
Guard: () => guard_exports,
|
|
30
31
|
IndexArray: () => IndexArray,
|
|
31
32
|
LRUCache: () => LRUCache,
|
|
32
33
|
Map1: () => Map1,
|
|
@@ -43,55 +44,51 @@ __export(index_exports, {
|
|
|
43
44
|
});
|
|
44
45
|
module.exports = __toCommonJS(index_exports);
|
|
45
46
|
|
|
46
|
-
// src/
|
|
47
|
-
var
|
|
48
|
-
__export(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
getSequenceArray: () => getSequenceArray,
|
|
68
|
-
isArray: () => isArray,
|
|
69
|
-
mapRangeArray: () => mapRangeArray,
|
|
70
|
-
mapSequenceArray: () => mapSequenceArray,
|
|
71
|
-
removeDuplicates: () => removeDuplicates,
|
|
72
|
-
removeDuplicatesCmp: () => removeDuplicatesCmp,
|
|
73
|
-
toArray: () => toArray
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
// src/utils/is/index.ts
|
|
77
|
-
var is_exports = {};
|
|
78
|
-
__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,
|
|
79
68
|
isArray: () => isArray,
|
|
69
|
+
isArrayIndex: () => isArrayIndex,
|
|
80
70
|
isArrayOrUndefined: () => isArrayOrUndefined,
|
|
81
71
|
isBoolean: () => isBoolean,
|
|
82
72
|
isBooleanOrUndefined: () => isBooleanOrUndefined,
|
|
73
|
+
isDeepEqual: () => isDeepEqual,
|
|
83
74
|
isEmptyArray: () => isEmptyArray,
|
|
84
75
|
isEmptyArrayOrUndefined: () => isEmptyArrayOrUndefined,
|
|
85
76
|
isEmptyString: () => isEmptyString,
|
|
86
77
|
isEmptyStringOrUndefined: () => isEmptyStringOrUndefined,
|
|
87
78
|
isEnumValue: () => isEnumValue,
|
|
88
79
|
isEnumValueOrUndefined: () => isEnumValueOrUndefined,
|
|
80
|
+
isEqual: () => isEqual,
|
|
81
|
+
isEvenNumber: () => isEvenNumber,
|
|
82
|
+
isFalse: () => isFalse,
|
|
83
|
+
isFalseOrUndefined: () => isFalseOrUndefined,
|
|
89
84
|
isFinite: () => isFinite2,
|
|
90
85
|
isFunction: () => isFunction,
|
|
91
86
|
isFunctionOrUndefined: () => isFunctionOrUndefined,
|
|
87
|
+
isIncluded: () => isIncluded,
|
|
92
88
|
isInfinity: () => isInfinity,
|
|
93
89
|
isInteger: () => isInteger,
|
|
94
90
|
isIntegerBetween: () => isIntegerBetween,
|
|
91
|
+
isIntegerBetweenExclusive: () => isIntegerBetweenExclusive,
|
|
95
92
|
isIntegerEq: () => isIntegerEq,
|
|
96
93
|
isIntegerGt: () => isIntegerGt,
|
|
97
94
|
isIntegerGte: () => isIntegerGte,
|
|
@@ -107,161 +104,951 @@ __export(is_exports, {
|
|
|
107
104
|
isNull: () => isNull,
|
|
108
105
|
isNullish: () => isNullish,
|
|
109
106
|
isNumber: () => isNumber,
|
|
107
|
+
isNumberBetween: () => isNumberBetween,
|
|
108
|
+
isNumberBetweenExclusive: () => isNumberBetweenExclusive,
|
|
110
109
|
isNumberOrUndefined: () => isNumberOrUndefined,
|
|
111
110
|
isObject: () => isObject,
|
|
112
111
|
isObjectOrUndefined: () => isObjectOrUndefined,
|
|
112
|
+
isOddNumber: () => isOddNumber,
|
|
113
113
|
isPosInfinity: () => isPosInfinity,
|
|
114
114
|
isString: () => isString,
|
|
115
115
|
isStringOrUndefined: () => isStringOrUndefined,
|
|
116
|
-
|
|
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
|
|
117
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 _getList() {
|
|
520
|
+
let s = document.cookie;
|
|
521
|
+
return s.split(";").map((c) => c.trim());
|
|
522
|
+
}
|
|
523
|
+
function _save(name, value) {
|
|
524
|
+
let cookie = name + "=" + value.toString() + ";sameSite=Lax;";
|
|
525
|
+
if (_expires) {
|
|
526
|
+
cookie += "expires=" + _expires.toUTCString() + ";";
|
|
527
|
+
}
|
|
528
|
+
document.cookie = cookie;
|
|
529
|
+
return value;
|
|
530
|
+
}
|
|
531
|
+
function _read(name, defaultValue) {
|
|
532
|
+
let str2 = _getList().find((c) => c.startsWith(name + "="));
|
|
533
|
+
return str2 === void 0 ? defaultValue : str2.substring(name.length + 1);
|
|
534
|
+
}
|
|
535
|
+
function _erase(name) {
|
|
536
|
+
document.cookie = name + "=;expires=Thu, 01 Jan 1970 00:00:00 UTC;";
|
|
537
|
+
}
|
|
538
|
+
function setExpireDays(days) {
|
|
539
|
+
_expires = /* @__PURE__ */ new Date();
|
|
540
|
+
_expires.setDate(_expires.getDate() + days);
|
|
541
|
+
}
|
|
542
|
+
function isConsentPending() {
|
|
543
|
+
return _consent === void 0;
|
|
544
|
+
}
|
|
545
|
+
function accept() {
|
|
546
|
+
_consent = "accept" /* Accept */;
|
|
547
|
+
_save(ConsentCookieName, _consent);
|
|
548
|
+
}
|
|
549
|
+
function decline() {
|
|
550
|
+
_consent = "decline" /* Decline */;
|
|
551
|
+
_save(ConsentCookieName, _consent);
|
|
552
|
+
}
|
|
553
|
+
function save(name, value) {
|
|
554
|
+
if (_consent === "accept" /* Accept */)
|
|
555
|
+
_save(name, value);
|
|
556
|
+
return value;
|
|
557
|
+
}
|
|
558
|
+
function read(name, defaultValue) {
|
|
559
|
+
if (_consent === "accept" /* Accept */)
|
|
560
|
+
return _read(name, defaultValue) ?? defaultValue;
|
|
561
|
+
else
|
|
562
|
+
return defaultValue;
|
|
563
|
+
}
|
|
564
|
+
function readInt(name, defaultValue) {
|
|
565
|
+
if (_consent === "accept" /* Accept */) {
|
|
566
|
+
let str2 = _read(name);
|
|
567
|
+
return str2 === void 0 ? defaultValue : parseInt(str2);
|
|
568
|
+
} else {
|
|
569
|
+
return defaultValue;
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
function readBool(name, defaultValue) {
|
|
573
|
+
if (_consent === "accept" /* Accept */) {
|
|
574
|
+
let str2 = _read(name);
|
|
575
|
+
return str2 === void 0 ? defaultValue : /true|1/i.test(str2);
|
|
576
|
+
} else {
|
|
577
|
+
return defaultValue;
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
function erase(name) {
|
|
581
|
+
if (_consent === "accept" /* Accept */ || name === ConsentCookieName)
|
|
582
|
+
_erase(name);
|
|
583
|
+
}
|
|
584
|
+
function eraseAll() {
|
|
585
|
+
document.cookie.split(";").forEach((c) => erase(c.trim().split("=")[0]));
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
// src/web/device.ts
|
|
589
|
+
var device_exports = {};
|
|
590
|
+
__export(device_exports, {
|
|
591
|
+
DPI: () => DPI,
|
|
592
|
+
FontSize: () => FontSize,
|
|
593
|
+
HostAddress: () => HostAddress,
|
|
594
|
+
IsMobileDevice: () => IsMobileDevice,
|
|
595
|
+
IsTouchDevice: () => IsTouchDevice,
|
|
596
|
+
PxPerMm: () => PxPerMm,
|
|
597
|
+
ScrollbarWidth: () => ScrollbarWidth,
|
|
598
|
+
mmToPx: () => mmToPx,
|
|
599
|
+
pxToMm: () => pxToMm,
|
|
600
|
+
toPx: () => toPx
|
|
601
|
+
});
|
|
602
|
+
function getDPI() {
|
|
603
|
+
let el = document.createElement("div");
|
|
604
|
+
el.style.width = "1in";
|
|
605
|
+
document.body.appendChild(el);
|
|
606
|
+
let dpi = el.offsetWidth;
|
|
607
|
+
el.remove();
|
|
608
|
+
return dpi || 96;
|
|
609
|
+
}
|
|
610
|
+
function getScrollBarWidth() {
|
|
611
|
+
try {
|
|
612
|
+
let outer = document.createElement("div");
|
|
613
|
+
outer.style.visibility = "hidden";
|
|
614
|
+
outer.style.width = "100px";
|
|
615
|
+
document.body.appendChild(outer);
|
|
616
|
+
let widthNoScroll = outer.offsetWidth;
|
|
617
|
+
outer.style.overflow = "scroll";
|
|
618
|
+
let inner = document.createElement("div");
|
|
619
|
+
inner.style.width = "100%";
|
|
620
|
+
outer.appendChild(inner);
|
|
621
|
+
let widthWithScroll = inner.offsetWidth;
|
|
622
|
+
if (outer.parentNode) {
|
|
623
|
+
outer.parentNode.removeChild(outer);
|
|
624
|
+
}
|
|
625
|
+
return widthNoScroll - widthWithScroll;
|
|
626
|
+
} catch (e) {
|
|
627
|
+
return 0;
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
function getSystemFontSize() {
|
|
631
|
+
let tmpDiv = document.createElement("div");
|
|
632
|
+
tmpDiv.style.cssText = "display:inline-block; padding:0; line-height:1; position:absolute; visibility:hidden; font-size:1em";
|
|
633
|
+
tmpDiv.appendChild(document.createTextNode("M"));
|
|
634
|
+
document.body.appendChild(tmpDiv);
|
|
635
|
+
let fontsize = tmpDiv.offsetHeight;
|
|
636
|
+
document.body.removeChild(tmpDiv);
|
|
637
|
+
return fontsize;
|
|
638
|
+
}
|
|
639
|
+
function getIsTouchDevice() {
|
|
640
|
+
if ("ontouchstart" in window || "DocumentTouch" in window || "createTouch" in document && "createTouchList" in document) {
|
|
641
|
+
return true;
|
|
642
|
+
}
|
|
643
|
+
var prefixes = " -webkit- -moz- -o- -ms- ".split(" ");
|
|
644
|
+
var mq = function(query2) {
|
|
645
|
+
return window.matchMedia(query2).matches;
|
|
646
|
+
};
|
|
647
|
+
var query = ["(", prefixes.join("touch-enabled),("), "heartz", ")"].join("");
|
|
648
|
+
return mq(query);
|
|
649
|
+
}
|
|
650
|
+
function getIsMobileDevice() {
|
|
651
|
+
let a = navigator.userAgent || navigator.vendor || window.opera;
|
|
652
|
+
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));
|
|
653
|
+
}
|
|
654
|
+
function getHostAddress() {
|
|
655
|
+
return location.protocol + "//" + location.host;
|
|
656
|
+
}
|
|
657
|
+
var UnitRegExp = /^(mm|cm|in|inch|px|em)$/;
|
|
658
|
+
var ValueUnitRegExp = /^([0-9\\.]+)(.*)$/;
|
|
659
|
+
var DPI = getDPI();
|
|
660
|
+
var PxPerMm = DPI / 25.4;
|
|
661
|
+
var ScrollbarWidth = getScrollBarWidth();
|
|
662
|
+
var FontSize = getSystemFontSize();
|
|
663
|
+
var IsTouchDevice = getIsTouchDevice();
|
|
664
|
+
var IsMobileDevice = getIsMobileDevice();
|
|
665
|
+
var HostAddress = getHostAddress();
|
|
666
|
+
function pxToMm(px) {
|
|
667
|
+
return px / PxPerMm;
|
|
668
|
+
}
|
|
669
|
+
function mmToPx(mm) {
|
|
670
|
+
return mm * PxPerMm;
|
|
671
|
+
}
|
|
672
|
+
function toPx(input) {
|
|
673
|
+
if (typeof input === "number") {
|
|
674
|
+
return input;
|
|
675
|
+
}
|
|
676
|
+
let value = NaN;
|
|
677
|
+
let unit = void 0;
|
|
678
|
+
let match = input.toString().match(ValueUnitRegExp);
|
|
679
|
+
if (match && match[1]) {
|
|
680
|
+
value = parseFloat(match[1]);
|
|
681
|
+
let unitStr = match[2] ? match[2].toLowerCase() : "undefined";
|
|
682
|
+
let unitStrOk = UnitRegExp.test(unitStr);
|
|
683
|
+
unit = unitStrOk ? unitStr : void 0;
|
|
684
|
+
if (!unit) {
|
|
685
|
+
console.log("Unknown unit '" + unitStr + "' => using 'px'.");
|
|
686
|
+
}
|
|
687
|
+
} else {
|
|
688
|
+
value = parseFloat(input);
|
|
689
|
+
}
|
|
690
|
+
assert_exports.isFinite(value, "value in function toPx");
|
|
691
|
+
switch (unit) {
|
|
692
|
+
case "mm":
|
|
693
|
+
return mmToPx(value);
|
|
694
|
+
case "cm":
|
|
695
|
+
return mmToPx(value) * 10;
|
|
696
|
+
case "in":
|
|
697
|
+
case "inch":
|
|
698
|
+
return mmToPx(value) * 25.4;
|
|
699
|
+
case "em":
|
|
700
|
+
return FontSize * value;
|
|
701
|
+
default:
|
|
702
|
+
case "px":
|
|
703
|
+
return value;
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
// src/guard/index.ts
|
|
708
|
+
var guard_exports = {};
|
|
709
|
+
__export(guard_exports, {
|
|
710
|
+
isArray: () => isArray2,
|
|
711
|
+
isArrayIndex: () => isArrayIndex2,
|
|
712
|
+
isArrayOrUndefined: () => isArrayOrUndefined2,
|
|
713
|
+
isBoolean: () => isBoolean2,
|
|
714
|
+
isBooleanOrUndefined: () => isBooleanOrUndefined2,
|
|
715
|
+
isDeepEqual: () => isDeepEqual2,
|
|
716
|
+
isEmptyArray: () => isEmptyArray2,
|
|
717
|
+
isEmptyArrayOrUndefined: () => isEmptyArrayOrUndefined2,
|
|
718
|
+
isEmptyString: () => isEmptyString2,
|
|
719
|
+
isEmptyStringOrUndefined: () => isEmptyStringOrUndefined2,
|
|
720
|
+
isEnumValue: () => isEnumValue3,
|
|
721
|
+
isEnumValueOrUndefined: () => isEnumValueOrUndefined2,
|
|
722
|
+
isEqual: () => isEqual2,
|
|
723
|
+
isEvenNumber: () => isEvenNumber2,
|
|
724
|
+
isFalse: () => isFalse2,
|
|
725
|
+
isFalseOrUndefined: () => isFalseOrUndefined2,
|
|
726
|
+
isFinite: () => isFinite3,
|
|
727
|
+
isFunction: () => isFunction2,
|
|
728
|
+
isFunctionOrUndefined: () => isFunctionOrUndefined2,
|
|
729
|
+
isIncluded: () => isIncluded2,
|
|
730
|
+
isInfinity: () => isInfinity2,
|
|
731
|
+
isInteger: () => isInteger2,
|
|
732
|
+
isIntegerBetween: () => isIntegerBetween2,
|
|
733
|
+
isIntegerBetweenExclusive: () => isIntegerBetweenExclusive2,
|
|
734
|
+
isIntegerEq: () => isIntegerEq2,
|
|
735
|
+
isIntegerGt: () => isIntegerGt2,
|
|
736
|
+
isIntegerGte: () => isIntegerGte2,
|
|
737
|
+
isIntegerLt: () => isIntegerLt2,
|
|
738
|
+
isIntegerLte: () => isIntegerLte2,
|
|
739
|
+
isIntegerOrUndefined: () => isIntegerOrUndefined2,
|
|
740
|
+
isNaNValue: () => isNaNValue2,
|
|
741
|
+
isNegInfinity: () => isNegInfinity2,
|
|
742
|
+
isNonEmptyArray: () => isNonEmptyArray2,
|
|
743
|
+
isNonEmptyArrayOrUndefined: () => isNonEmptyArrayOrUndefined2,
|
|
744
|
+
isNonEmptyString: () => isNonEmptyString2,
|
|
745
|
+
isNonEmptyStringOrUndefined: () => isNonEmptyStringOrUndefined2,
|
|
746
|
+
isNull: () => isNull2,
|
|
747
|
+
isNullish: () => isNullish2,
|
|
748
|
+
isNumber: () => isNumber2,
|
|
749
|
+
isNumberBetween: () => isNumberBetween2,
|
|
750
|
+
isNumberBetweenExclusive: () => isNumberBetweenExclusive2,
|
|
751
|
+
isNumberOrUndefined: () => isNumberOrUndefined2,
|
|
752
|
+
isObject: () => isObject2,
|
|
753
|
+
isObjectOrUndefined: () => isObjectOrUndefined2,
|
|
754
|
+
isOddNumber: () => isOddNumber2,
|
|
755
|
+
isPosInfinity: () => isPosInfinity2,
|
|
756
|
+
isString: () => isString2,
|
|
757
|
+
isStringOrUndefined: () => isStringOrUndefined2,
|
|
758
|
+
isThrowing: () => isThrowing2,
|
|
759
|
+
isTrue: () => isTrue2,
|
|
760
|
+
isTrueOrUndefined: () => isTrueOrUndefined2,
|
|
761
|
+
isTypedObject: () => isTypedObject2,
|
|
762
|
+
isUndefined: () => isUndefined2,
|
|
763
|
+
tryOr: () => tryOr
|
|
764
|
+
});
|
|
765
|
+
|
|
766
|
+
// src/utils/obj/index.ts
|
|
767
|
+
var obj_exports = {};
|
|
768
|
+
__export(obj_exports, {
|
|
769
|
+
deepEqual: () => deepEqual,
|
|
770
|
+
hasProperties: () => hasProperties,
|
|
771
|
+
isObject: () => isObject2
|
|
772
|
+
});
|
|
773
|
+
function hasProperties(obj, props) {
|
|
774
|
+
return isObject2(obj) && props.every((p) => p in obj);
|
|
775
|
+
}
|
|
776
|
+
function deepEqual(a, b) {
|
|
777
|
+
if (a === b) return true;
|
|
778
|
+
if (a === null || b === null) return false;
|
|
779
|
+
if (typeof a !== "object" || typeof b !== "object") return false;
|
|
780
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
781
|
+
if (a.length !== b.length) return false;
|
|
782
|
+
return a.every((val, i) => deepEqual(val, b[i]));
|
|
783
|
+
}
|
|
784
|
+
if (Array.isArray(a) !== Array.isArray(b)) return false;
|
|
785
|
+
const keysA = Object.keys(a);
|
|
786
|
+
const keysB = Object.keys(b);
|
|
787
|
+
if (keysA.length !== keysB.length) return false;
|
|
788
|
+
for (const key of keysA) {
|
|
789
|
+
if (!Object.prototype.hasOwnProperty.call(b, key)) return false;
|
|
790
|
+
if (!deepEqual(a[key], b[key])) return false;
|
|
791
|
+
}
|
|
792
|
+
return true;
|
|
793
|
+
}
|
|
118
794
|
|
|
119
795
|
// src/utils/enum/index.ts
|
|
120
796
|
var enum_exports = {};
|
|
121
797
|
__export(enum_exports, {
|
|
122
|
-
|
|
798
|
+
assertEnumValue: () => assertEnumValue,
|
|
799
|
+
forEachEnum: () => forEachEnum,
|
|
800
|
+
getEnumEntries: () => getEnumEntries,
|
|
801
|
+
getEnumKey: () => getEnumKey,
|
|
802
|
+
getEnumKeys: () => getEnumKeys,
|
|
803
|
+
getEnumValues: () => getEnumValues,
|
|
804
|
+
isEnumValue: () => isEnumValue2
|
|
123
805
|
});
|
|
806
|
+
function getEnumKeys(e) {
|
|
807
|
+
return Object.keys(e).filter((k) => isNaN(Number(k)));
|
|
808
|
+
}
|
|
124
809
|
function getEnumValues(e) {
|
|
125
|
-
return
|
|
810
|
+
return getEnumKeys(e).map((k) => e[k]);
|
|
811
|
+
}
|
|
812
|
+
function getEnumEntries(e) {
|
|
813
|
+
return getEnumKeys(e).map((k) => [k, e[k]]);
|
|
814
|
+
}
|
|
815
|
+
function getEnumKey(e, value) {
|
|
816
|
+
return getEnumKeys(e).find((k) => e[k] === value);
|
|
817
|
+
}
|
|
818
|
+
function forEachEnum(e, callback) {
|
|
819
|
+
for (const [k, v] of getEnumEntries(e)) callback(k, v);
|
|
820
|
+
}
|
|
821
|
+
function isEnumValue2(e, value) {
|
|
822
|
+
return getEnumValues(e).includes(value);
|
|
823
|
+
}
|
|
824
|
+
function assertEnumValue(e, value) {
|
|
825
|
+
if (!isEnumValue2(e, value)) {
|
|
826
|
+
throw new TypeError(`Invalid enum value: ${String(value)}`);
|
|
827
|
+
}
|
|
126
828
|
}
|
|
127
829
|
|
|
128
|
-
// src/
|
|
129
|
-
function
|
|
830
|
+
// src/guard/index.ts
|
|
831
|
+
function isEqual2(value1, value2) {
|
|
832
|
+
return value1 === value2;
|
|
833
|
+
}
|
|
834
|
+
function isDeepEqual2(value1, value2) {
|
|
835
|
+
return deepEqual(value1, value2);
|
|
836
|
+
}
|
|
837
|
+
function isUndefined2(value) {
|
|
130
838
|
return value === void 0;
|
|
131
839
|
}
|
|
132
|
-
function
|
|
840
|
+
function isNull2(value) {
|
|
133
841
|
return value === null;
|
|
134
842
|
}
|
|
135
|
-
function
|
|
843
|
+
function isNullish2(value) {
|
|
136
844
|
return value === void 0 || value === null;
|
|
137
845
|
}
|
|
138
|
-
function
|
|
139
|
-
return typeof value === "object" && value !== null && !
|
|
846
|
+
function isObject2(value) {
|
|
847
|
+
return typeof value === "object" && value !== null && !isArray2(value);
|
|
140
848
|
}
|
|
141
|
-
function
|
|
142
|
-
return value === void 0 ||
|
|
849
|
+
function isObjectOrUndefined2(value) {
|
|
850
|
+
return value === void 0 || isObject2(value);
|
|
143
851
|
}
|
|
144
|
-
function
|
|
852
|
+
function isTypedObject2(obj, keys) {
|
|
853
|
+
return isObject2(obj) && keys.every((k) => k in obj);
|
|
854
|
+
}
|
|
855
|
+
function isArray2(a) {
|
|
145
856
|
return !!a && Object.prototype.toString.call(a) === "[object Array]";
|
|
146
857
|
}
|
|
147
|
-
function
|
|
148
|
-
return value === void 0 ||
|
|
858
|
+
function isArrayOrUndefined2(value) {
|
|
859
|
+
return value === void 0 || isArray2(value);
|
|
149
860
|
}
|
|
150
|
-
function
|
|
151
|
-
return
|
|
861
|
+
function isEmptyArray2(a) {
|
|
862
|
+
return isArray2(a) && a.length === 0;
|
|
152
863
|
}
|
|
153
|
-
function
|
|
154
|
-
return
|
|
864
|
+
function isNonEmptyArray2(a) {
|
|
865
|
+
return isArray2(a) && a.length > 0;
|
|
155
866
|
}
|
|
156
|
-
function
|
|
157
|
-
return
|
|
867
|
+
function isEmptyArrayOrUndefined2(a) {
|
|
868
|
+
return isArray2(a) && a.length === 0 || a === void 0;
|
|
158
869
|
}
|
|
159
|
-
function
|
|
160
|
-
return
|
|
870
|
+
function isNonEmptyArrayOrUndefined2(a) {
|
|
871
|
+
return isArray2(a) && a.length > 0 || a === void 0;
|
|
161
872
|
}
|
|
162
|
-
function
|
|
873
|
+
function isString2(value) {
|
|
163
874
|
return typeof value === "string";
|
|
164
875
|
}
|
|
165
|
-
function
|
|
876
|
+
function isEmptyString2(value) {
|
|
166
877
|
return typeof value === "string" && value.length === 0;
|
|
167
878
|
}
|
|
168
|
-
function
|
|
879
|
+
function isNonEmptyString2(value) {
|
|
169
880
|
return typeof value === "string" && value.length > 0;
|
|
170
881
|
}
|
|
171
|
-
function
|
|
882
|
+
function isStringOrUndefined2(value) {
|
|
172
883
|
return value === void 0 || typeof value === "string";
|
|
173
884
|
}
|
|
174
|
-
function
|
|
885
|
+
function isEmptyStringOrUndefined2(value) {
|
|
175
886
|
return typeof value === "string" && value.length === 0 || value === void 0;
|
|
176
887
|
}
|
|
177
|
-
function
|
|
888
|
+
function isNonEmptyStringOrUndefined2(value) {
|
|
178
889
|
return typeof value === "string" && value.length > 0 || value === void 0;
|
|
179
890
|
}
|
|
180
|
-
function
|
|
891
|
+
function isBoolean2(value) {
|
|
181
892
|
return typeof value === "boolean";
|
|
182
893
|
}
|
|
183
|
-
function
|
|
894
|
+
function isBooleanOrUndefined2(value) {
|
|
184
895
|
return value === void 0 || typeof value === "boolean";
|
|
185
896
|
}
|
|
186
|
-
function
|
|
897
|
+
function isTrue2(value) {
|
|
898
|
+
return value === true;
|
|
899
|
+
}
|
|
900
|
+
function isTrueOrUndefined2(value) {
|
|
901
|
+
return value === true || value === void 0;
|
|
902
|
+
}
|
|
903
|
+
function isFalse2(value) {
|
|
904
|
+
return value === false;
|
|
905
|
+
}
|
|
906
|
+
function isFalseOrUndefined2(value) {
|
|
907
|
+
return value === false || value === void 0;
|
|
908
|
+
}
|
|
909
|
+
function isFunction2(value) {
|
|
187
910
|
return typeof value === "function";
|
|
188
911
|
}
|
|
189
|
-
function
|
|
912
|
+
function isFunctionOrUndefined2(value) {
|
|
190
913
|
return value === void 0 || typeof value === "function";
|
|
191
914
|
}
|
|
192
|
-
function
|
|
915
|
+
function isEnumValue3(value, enumObj, name = "value") {
|
|
193
916
|
return getEnumValues(enumObj).some((v) => v === value);
|
|
194
917
|
}
|
|
195
|
-
function
|
|
918
|
+
function isEnumValueOrUndefined2(value, enumObj, name = "value") {
|
|
196
919
|
return value === void 0 || getEnumValues(enumObj).some((v) => v === value);
|
|
197
920
|
}
|
|
198
|
-
function
|
|
921
|
+
function isNumber2(value) {
|
|
199
922
|
return typeof value === "number";
|
|
200
923
|
}
|
|
201
|
-
function
|
|
924
|
+
function isNumberOrUndefined2(value) {
|
|
202
925
|
return typeof value === "number" || value === void 0;
|
|
203
926
|
}
|
|
204
|
-
function
|
|
927
|
+
function isFinite3(value) {
|
|
205
928
|
return typeof value === "number" && Number.isFinite(value);
|
|
206
929
|
}
|
|
207
|
-
function
|
|
208
|
-
return typeof n === "number" &&
|
|
930
|
+
function isInteger2(n) {
|
|
931
|
+
return typeof n === "number" && isFinite3(n) && n === Math.trunc(n);
|
|
932
|
+
}
|
|
933
|
+
function isIntegerOrUndefined2(n) {
|
|
934
|
+
return typeof n === "number" && isFinite3(n) && n === Math.trunc(n) || n === void 0;
|
|
209
935
|
}
|
|
210
|
-
function
|
|
211
|
-
return
|
|
936
|
+
function isIntegerEq2(value, compareTo) {
|
|
937
|
+
return isInteger2(value) && value === compareTo;
|
|
212
938
|
}
|
|
213
|
-
function
|
|
214
|
-
return
|
|
939
|
+
function isIntegerGt2(value, compareTo) {
|
|
940
|
+
return isInteger2(value) && isNumber2(compareTo) && value > compareTo;
|
|
215
941
|
}
|
|
216
|
-
function
|
|
217
|
-
return
|
|
942
|
+
function isIntegerGte2(value, compareTo) {
|
|
943
|
+
return isInteger2(value) && isNumber2(compareTo) && value >= compareTo;
|
|
218
944
|
}
|
|
219
|
-
function
|
|
220
|
-
return
|
|
945
|
+
function isIntegerLt2(value, compareTo) {
|
|
946
|
+
return isInteger2(value) && isNumber2(compareTo) && value < compareTo;
|
|
221
947
|
}
|
|
222
|
-
function
|
|
223
|
-
return
|
|
948
|
+
function isIntegerLte2(value, compareTo) {
|
|
949
|
+
return isInteger2(value) && isNumber2(compareTo) && value <= compareTo;
|
|
224
950
|
}
|
|
225
|
-
function
|
|
226
|
-
return
|
|
951
|
+
function isIntegerBetween2(value, min, max) {
|
|
952
|
+
return isInteger2(value) && isNumber2(min) && isNumber2(max) && value >= min && value <= max;
|
|
227
953
|
}
|
|
228
|
-
function
|
|
229
|
-
return
|
|
954
|
+
function isIntegerBetweenExclusive2(value, min, max) {
|
|
955
|
+
return isInteger2(value) && isNumber2(min) && isNumber2(max) && value > min && value < max;
|
|
230
956
|
}
|
|
231
|
-
function
|
|
957
|
+
function isNumberBetween2(value, min, max) {
|
|
958
|
+
return isNumber2(value) && isNumber2(min) && isNumber2(max) && value >= min && value <= max;
|
|
959
|
+
}
|
|
960
|
+
function isNumberBetweenExclusive2(value, min, max) {
|
|
961
|
+
return isNumber2(value) && isNumber2(min) && isNumber2(max) && value > min && value < max;
|
|
962
|
+
}
|
|
963
|
+
function isNaNValue2(value) {
|
|
232
964
|
return typeof value === "number" && Number.isNaN(value);
|
|
233
965
|
}
|
|
234
|
-
function
|
|
966
|
+
function isInfinity2(value) {
|
|
235
967
|
return typeof value === "number" && Math.abs(value) === Infinity;
|
|
236
968
|
}
|
|
237
|
-
function
|
|
969
|
+
function isPosInfinity2(value) {
|
|
238
970
|
return typeof value === "number" && value === Infinity;
|
|
239
971
|
}
|
|
240
|
-
function
|
|
972
|
+
function isNegInfinity2(value) {
|
|
241
973
|
return typeof value === "number" && value === -Infinity;
|
|
242
974
|
}
|
|
975
|
+
function isOddNumber2(value) {
|
|
976
|
+
return isInteger2(value) && value % 2 === 1;
|
|
977
|
+
}
|
|
978
|
+
function isEvenNumber2(value) {
|
|
979
|
+
return isInteger2(value) && value % 2 === 0;
|
|
980
|
+
}
|
|
981
|
+
function isIncluded2(value, array) {
|
|
982
|
+
return array.includes(value);
|
|
983
|
+
}
|
|
984
|
+
function isArrayIndex2(index, array) {
|
|
985
|
+
return isInteger2(index) && isArray2(array) && index >= 0 && index < array.length;
|
|
986
|
+
}
|
|
987
|
+
function isThrowing2(throwTestFn) {
|
|
988
|
+
try {
|
|
989
|
+
throwTestFn();
|
|
990
|
+
return false;
|
|
991
|
+
} catch (err) {
|
|
992
|
+
return true;
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
function tryOr(tryFn, orVal) {
|
|
996
|
+
try {
|
|
997
|
+
return tryFn();
|
|
998
|
+
} catch (err) {
|
|
999
|
+
return isFunction2(orVal) ? orVal() : orVal;
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
// src/utils/index.ts
|
|
1004
|
+
var utils_exports = {};
|
|
1005
|
+
__export(utils_exports, {
|
|
1006
|
+
Arr: () => arr_exports,
|
|
1007
|
+
Dom: () => dom_exports,
|
|
1008
|
+
Enum: () => enum_exports,
|
|
1009
|
+
Is: () => Is,
|
|
1010
|
+
Map: () => map_exports,
|
|
1011
|
+
Math: () => math_exports,
|
|
1012
|
+
Obj: () => obj_exports,
|
|
1013
|
+
Str: () => str_exports
|
|
1014
|
+
});
|
|
243
1015
|
|
|
244
1016
|
// src/utils/arr/index.ts
|
|
1017
|
+
var arr_exports = {};
|
|
1018
|
+
__export(arr_exports, {
|
|
1019
|
+
arrayContains: () => arrayContains,
|
|
1020
|
+
chunckArray: () => chunckArray,
|
|
1021
|
+
duplicate: () => duplicate,
|
|
1022
|
+
fillArray: () => fillArray,
|
|
1023
|
+
getRangeArray: () => getRangeArray,
|
|
1024
|
+
getSequenceArray: () => getSequenceArray,
|
|
1025
|
+
isArray: () => isArray2,
|
|
1026
|
+
mapRangeArray: () => mapRangeArray,
|
|
1027
|
+
mapSequenceArray: () => mapSequenceArray,
|
|
1028
|
+
removeDuplicates: () => removeDuplicates,
|
|
1029
|
+
removeDuplicatesCmp: () => removeDuplicatesCmp,
|
|
1030
|
+
toArray: () => toArray
|
|
1031
|
+
});
|
|
245
1032
|
function toArray(a) {
|
|
246
|
-
return
|
|
1033
|
+
return isArray2(a) ? a : [a];
|
|
247
1034
|
}
|
|
248
1035
|
function duplicate(a) {
|
|
249
1036
|
return a === void 0 ? a : a.slice();
|
|
250
1037
|
}
|
|
251
|
-
function removeDuplicates(
|
|
252
|
-
return
|
|
1038
|
+
function removeDuplicates(arr, compareFn) {
|
|
1039
|
+
return compareFn !== void 0 ? arr.filter((a, id, self) => id === self.findIndex((b) => compareFn(a, b))) : arr.filter((a, id, self) => id === self.indexOf(a));
|
|
253
1040
|
}
|
|
254
|
-
function removeDuplicatesCmp(arr,
|
|
255
|
-
return arr.filter((
|
|
1041
|
+
function removeDuplicatesCmp(arr, compareFn) {
|
|
1042
|
+
return arr.filter((a, id, self) => id === self.findIndex((b) => compareFn(a, b)));
|
|
256
1043
|
}
|
|
257
1044
|
function fillArray(fillValue, fillCount) {
|
|
258
|
-
if (!
|
|
1045
|
+
if (!isInteger2(fillCount) || fillCount < 0) {
|
|
259
1046
|
throw new Error("fillArray: Invalid fillCount = " + fillCount);
|
|
260
1047
|
}
|
|
261
1048
|
return new Array(fillCount).fill(fillValue);
|
|
262
1049
|
}
|
|
263
1050
|
function mapSequenceArray(len, fn) {
|
|
264
|
-
if (!
|
|
1051
|
+
if (!isInteger2(len) || len < 0) {
|
|
265
1052
|
throw new Error("mapSequenceArray: Invalid len = " + len);
|
|
266
1053
|
}
|
|
267
1054
|
let arr = new Array(len);
|
|
@@ -274,10 +1061,10 @@ function getSequenceArray(len) {
|
|
|
274
1061
|
return mapSequenceArray(len, (i) => i);
|
|
275
1062
|
}
|
|
276
1063
|
function mapRangeArray(start, end, fn) {
|
|
277
|
-
if (!
|
|
1064
|
+
if (!isInteger2(start)) {
|
|
278
1065
|
throw new Error("mapRangeArray: Invalid start = " + end);
|
|
279
1066
|
}
|
|
280
|
-
if (!
|
|
1067
|
+
if (!isInteger2(end)) {
|
|
281
1068
|
throw new Error("mapRangeArray: Invalid end = " + end);
|
|
282
1069
|
}
|
|
283
1070
|
let len = Math.abs(end - start) + 1;
|
|
@@ -294,7 +1081,7 @@ function arrayContains(arg, item) {
|
|
|
294
1081
|
return arg.indexOf(item) >= 0;
|
|
295
1082
|
}
|
|
296
1083
|
function chunckArray(arr, chunckSize) {
|
|
297
|
-
if (!
|
|
1084
|
+
if (!isInteger2(chunckSize) || chunckSize < 1) {
|
|
298
1085
|
throw new Error("chunckArray: Invalid chunckSize = " + chunckSize);
|
|
299
1086
|
}
|
|
300
1087
|
let result = [];
|
|
@@ -327,261 +1114,8 @@ __export(dom_exports, {
|
|
|
327
1114
|
setWidth: () => setWidth,
|
|
328
1115
|
styleLayoutChanged: () => styleLayoutChanged
|
|
329
1116
|
});
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
var Assert;
|
|
333
|
-
((Assert2) => {
|
|
334
|
-
let errorConstructor = Error;
|
|
335
|
-
function setErrorClass(ec) {
|
|
336
|
-
errorConstructor = ec ?? Error;
|
|
337
|
-
}
|
|
338
|
-
Assert2.setErrorClass = setErrorClass;
|
|
339
|
-
function throwError(errorMsg, userMsg) {
|
|
340
|
-
throw new errorConstructor("Assertion Error: " + errorMsg + (userMsg ? " " + userMsg : ""));
|
|
341
|
-
}
|
|
342
|
-
function is_int(a) {
|
|
343
|
-
return typeof a === "number" && isFinite(a) && a === Math.trunc(a);
|
|
344
|
-
}
|
|
345
|
-
function is_number(a) {
|
|
346
|
-
return typeof a === "number";
|
|
347
|
-
}
|
|
348
|
-
function assert(a, userMsg) {
|
|
349
|
-
if (!a) {
|
|
350
|
-
throwError(userMsg ?? "Assertion failed!");
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
Assert2.assert = assert;
|
|
354
|
-
function assertEnum(value, enumObj, name = "value") {
|
|
355
|
-
if (!getEnumValues(enumObj).some((v) => v === value)) {
|
|
356
|
-
throw new TypeError(`Invalid ${name} enum value: ${value}`);
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
Assert2.assertEnum = assertEnum;
|
|
360
|
-
function interrupt(userMsg) {
|
|
361
|
-
throwError(userMsg ?? "Interrupted!");
|
|
362
|
-
}
|
|
363
|
-
Assert2.interrupt = interrupt;
|
|
364
|
-
function int(a, userMsg) {
|
|
365
|
-
if (!is_int(a)) {
|
|
366
|
-
throwError(`Expected ${a} to be integer.`, userMsg);
|
|
367
|
-
}
|
|
368
|
-
return a;
|
|
369
|
-
}
|
|
370
|
-
Assert2.int = int;
|
|
371
|
-
function eq(a, b, userMsg) {
|
|
372
|
-
if (a !== b) {
|
|
373
|
-
throwError(`Expected ${a} to equal ${b}.`, userMsg);
|
|
374
|
-
}
|
|
375
|
-
return a;
|
|
376
|
-
}
|
|
377
|
-
Assert2.eq = eq;
|
|
378
|
-
function int_eq(a, b, userMsg) {
|
|
379
|
-
if (!(is_int(a) && is_number(b) && a === b)) {
|
|
380
|
-
throwError(`Expected ${a} to be integer equal to ${b}.`, userMsg);
|
|
381
|
-
}
|
|
382
|
-
return a;
|
|
383
|
-
}
|
|
384
|
-
Assert2.int_eq = int_eq;
|
|
385
|
-
function int_lt(a, b, userMsg) {
|
|
386
|
-
if (!(is_int(a) && is_number(b) && a < b)) {
|
|
387
|
-
throwError(`Expected ${a} to be integer less than ${b}.`, userMsg);
|
|
388
|
-
}
|
|
389
|
-
return a;
|
|
390
|
-
}
|
|
391
|
-
Assert2.int_lt = int_lt;
|
|
392
|
-
function int_lte(a, b, userMsg) {
|
|
393
|
-
if (!(is_int(a) && is_number(b) && a <= b)) {
|
|
394
|
-
throwError(`Expected ${a} to be integer less than or equal to ${b}.`, userMsg);
|
|
395
|
-
}
|
|
396
|
-
return a;
|
|
397
|
-
}
|
|
398
|
-
Assert2.int_lte = int_lte;
|
|
399
|
-
function int_gt(a, b, userMsg) {
|
|
400
|
-
if (!(is_int(a) && is_number(b) && a > b)) {
|
|
401
|
-
throwError(`Expected ${a} to be integer greater than ${b}.`, userMsg);
|
|
402
|
-
}
|
|
403
|
-
return a;
|
|
404
|
-
}
|
|
405
|
-
Assert2.int_gt = int_gt;
|
|
406
|
-
function int_gte(a, b, userMsg) {
|
|
407
|
-
if (!(is_int(a) && is_number(b) && a >= b)) {
|
|
408
|
-
throwError(`Expected ${a} to be integer greater than or equal to ${b}.`, userMsg);
|
|
409
|
-
}
|
|
410
|
-
return a;
|
|
411
|
-
}
|
|
412
|
-
Assert2.int_gte = int_gte;
|
|
413
|
-
function int_between(a, min, max, userMsg) {
|
|
414
|
-
if (!(is_int(a) && is_number(min) && is_number(max) && a >= min && a <= max)) {
|
|
415
|
-
throwError(`Expected ${a} to be integer between ${min} and ${max}.`, userMsg);
|
|
416
|
-
}
|
|
417
|
-
return a;
|
|
418
|
-
}
|
|
419
|
-
Assert2.int_between = int_between;
|
|
420
|
-
function odd(a, userMsg) {
|
|
421
|
-
if (!(is_int(a) && a % 2 === 1)) {
|
|
422
|
-
throwError(`Expected ${a} to be odd number.`, userMsg);
|
|
423
|
-
}
|
|
424
|
-
return a;
|
|
425
|
-
}
|
|
426
|
-
Assert2.odd = odd;
|
|
427
|
-
function even(a, userMsg) {
|
|
428
|
-
if (!(is_int(a) && a % 2 === 0)) {
|
|
429
|
-
throwError(`Expected ${a} to be even number.`, userMsg);
|
|
430
|
-
}
|
|
431
|
-
return a;
|
|
432
|
-
}
|
|
433
|
-
Assert2.even = even;
|
|
434
|
-
function in_group(a, group, userMsg) {
|
|
435
|
-
if (!group.some((e) => e === a)) {
|
|
436
|
-
let strGroup = group.map((v) => String(v)).join(", ");
|
|
437
|
-
throwError(`Expected ${a} to be in group [${strGroup}].`, userMsg);
|
|
438
|
-
}
|
|
439
|
-
return a;
|
|
440
|
-
}
|
|
441
|
-
Assert2.in_group = in_group;
|
|
442
|
-
function finite(a, userMsg) {
|
|
443
|
-
if (!(is_number(a) && isFinite(a))) {
|
|
444
|
-
throwError(`Expected ${a} to be finite number.`, userMsg);
|
|
445
|
-
}
|
|
446
|
-
return a;
|
|
447
|
-
}
|
|
448
|
-
Assert2.finite = finite;
|
|
449
|
-
function array_id(arr, id, userMsg) {
|
|
450
|
-
if (!(is_int(id) && id >= 0 && id < arr.length)) {
|
|
451
|
-
throwError(`Expected ${id} to be array index in bounds [0..${arr.length - 1}].`, userMsg);
|
|
452
|
-
}
|
|
453
|
-
return id;
|
|
454
|
-
}
|
|
455
|
-
Assert2.array_id = array_id;
|
|
456
|
-
function array_elem(arr, id, userMsg) {
|
|
457
|
-
return arr[array_id(arr, id, userMsg)];
|
|
458
|
-
}
|
|
459
|
-
Assert2.array_elem = array_elem;
|
|
460
|
-
function require2(arg, userMsg) {
|
|
461
|
-
if (arg === void 0) {
|
|
462
|
-
throwError("Required value is undefined.", userMsg);
|
|
463
|
-
} else {
|
|
464
|
-
return arg;
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
Assert2.require = require2;
|
|
468
|
-
})(Assert || (Assert = {}));
|
|
469
|
-
|
|
470
|
-
// src/modules/device.ts
|
|
471
|
-
var Device;
|
|
472
|
-
((Device2) => {
|
|
473
|
-
function getDPI() {
|
|
474
|
-
let el = document.createElement("div");
|
|
475
|
-
el.style.width = "1in";
|
|
476
|
-
document.body.appendChild(el);
|
|
477
|
-
let dpi = el.offsetWidth;
|
|
478
|
-
el.remove();
|
|
479
|
-
return dpi || 96;
|
|
480
|
-
}
|
|
481
|
-
function getScrollBarWidth() {
|
|
482
|
-
try {
|
|
483
|
-
let outer = document.createElement("div");
|
|
484
|
-
outer.style.visibility = "hidden";
|
|
485
|
-
outer.style.width = "100px";
|
|
486
|
-
document.body.appendChild(outer);
|
|
487
|
-
let widthNoScroll = outer.offsetWidth;
|
|
488
|
-
outer.style.overflow = "scroll";
|
|
489
|
-
let inner = document.createElement("div");
|
|
490
|
-
inner.style.width = "100%";
|
|
491
|
-
outer.appendChild(inner);
|
|
492
|
-
let widthWithScroll = inner.offsetWidth;
|
|
493
|
-
if (outer.parentNode) {
|
|
494
|
-
outer.parentNode.removeChild(outer);
|
|
495
|
-
}
|
|
496
|
-
return widthNoScroll - widthWithScroll;
|
|
497
|
-
} catch (e) {
|
|
498
|
-
return 0;
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
function getSystemFontSize() {
|
|
502
|
-
let tmpDiv = document.createElement("div");
|
|
503
|
-
tmpDiv.style.cssText = "display:inline-block; padding:0; line-height:1; position:absolute; visibility:hidden; font-size:1em";
|
|
504
|
-
tmpDiv.appendChild(document.createTextNode("M"));
|
|
505
|
-
document.body.appendChild(tmpDiv);
|
|
506
|
-
let fontsize = tmpDiv.offsetHeight;
|
|
507
|
-
document.body.removeChild(tmpDiv);
|
|
508
|
-
return fontsize;
|
|
509
|
-
}
|
|
510
|
-
function getIsTouchDevice() {
|
|
511
|
-
if ("ontouchstart" in window || "DocumentTouch" in window || "createTouch" in document && "createTouchList" in document) {
|
|
512
|
-
return true;
|
|
513
|
-
}
|
|
514
|
-
var prefixes = " -webkit- -moz- -o- -ms- ".split(" ");
|
|
515
|
-
var mq = function(query2) {
|
|
516
|
-
return window.matchMedia(query2).matches;
|
|
517
|
-
};
|
|
518
|
-
var query = ["(", prefixes.join("touch-enabled),("), "heartz", ")"].join("");
|
|
519
|
-
return mq(query);
|
|
520
|
-
}
|
|
521
|
-
function getIsMobileDevice() {
|
|
522
|
-
let a = navigator.userAgent || navigator.vendor || window.opera;
|
|
523
|
-
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));
|
|
524
|
-
}
|
|
525
|
-
function getHostAddress() {
|
|
526
|
-
return location.protocol + "//" + location.host;
|
|
527
|
-
}
|
|
528
|
-
const UnitRegExp = /^(mm|cm|in|inch|px|em)$/;
|
|
529
|
-
const ValueUnitRegExp = /^([0-9\\.]+)(.*)$/;
|
|
530
|
-
Device2.DPI = getDPI();
|
|
531
|
-
Device2.PxPerMm = Device2.DPI / 25.4;
|
|
532
|
-
Device2.ScrollbarWidth = getScrollBarWidth();
|
|
533
|
-
Device2.FontSize = getSystemFontSize();
|
|
534
|
-
Device2.IsTouchDevice = getIsTouchDevice();
|
|
535
|
-
Device2.IsMobileDevice = getIsMobileDevice();
|
|
536
|
-
Device2.HostAddress = getHostAddress();
|
|
537
|
-
function pxToMm(px) {
|
|
538
|
-
return px / Device2.PxPerMm;
|
|
539
|
-
}
|
|
540
|
-
Device2.pxToMm = pxToMm;
|
|
541
|
-
function mmToPx(mm) {
|
|
542
|
-
return mm * Device2.PxPerMm;
|
|
543
|
-
}
|
|
544
|
-
Device2.mmToPx = mmToPx;
|
|
545
|
-
function toPx2(input) {
|
|
546
|
-
if (typeof input === "number") {
|
|
547
|
-
return input;
|
|
548
|
-
}
|
|
549
|
-
let value = NaN;
|
|
550
|
-
let unit = void 0;
|
|
551
|
-
let match = input.toString().match(ValueUnitRegExp);
|
|
552
|
-
if (match && match[1]) {
|
|
553
|
-
value = parseFloat(match[1]);
|
|
554
|
-
let unitStr = match[2] ? match[2].toLowerCase() : "undefined";
|
|
555
|
-
let unitStrOk = UnitRegExp.test(unitStr);
|
|
556
|
-
unit = unitStrOk ? unitStr : void 0;
|
|
557
|
-
if (!unit) {
|
|
558
|
-
console.log("Unknown unit '" + unitStr + "' => using 'px'.");
|
|
559
|
-
}
|
|
560
|
-
} else {
|
|
561
|
-
value = parseFloat(input);
|
|
562
|
-
}
|
|
563
|
-
Assert.finite(value, "value in function toPx");
|
|
564
|
-
switch (unit) {
|
|
565
|
-
case "mm":
|
|
566
|
-
return mmToPx(value);
|
|
567
|
-
case "cm":
|
|
568
|
-
return mmToPx(value) * 10;
|
|
569
|
-
case "in":
|
|
570
|
-
case "inch":
|
|
571
|
-
return mmToPx(value) * 25.4;
|
|
572
|
-
case "em":
|
|
573
|
-
return Device2.FontSize * value;
|
|
574
|
-
default:
|
|
575
|
-
case "px":
|
|
576
|
-
return value;
|
|
577
|
-
}
|
|
578
|
-
}
|
|
579
|
-
Device2.toPx = toPx2;
|
|
580
|
-
})(Device || (Device = {}));
|
|
581
|
-
|
|
582
|
-
// src/utils/dom/index.ts
|
|
583
|
-
function toPx(value) {
|
|
584
|
-
return value === void 0 ? void 0 : Device.toPx(value);
|
|
1117
|
+
function toPx2(value) {
|
|
1118
|
+
return value === void 0 ? void 0 : device_exports.toPx(value);
|
|
585
1119
|
}
|
|
586
1120
|
function hasClass(el, className) {
|
|
587
1121
|
if (className.length === 0) {
|
|
@@ -672,38 +1206,38 @@ function getPadding(style) {
|
|
|
672
1206
|
if (!style) {
|
|
673
1207
|
return { top: 0, right: 0, bottom: 0, left: 0 };
|
|
674
1208
|
}
|
|
675
|
-
let top =
|
|
676
|
-
let right =
|
|
677
|
-
let bottom =
|
|
678
|
-
let left =
|
|
1209
|
+
let top = toPx2(style.paddingTop);
|
|
1210
|
+
let right = toPx2(style.paddingRight);
|
|
1211
|
+
let bottom = toPx2(style.paddingBottom);
|
|
1212
|
+
let left = toPx2(style.paddingLeft);
|
|
679
1213
|
let padding = (style.padding ?? "").toString().split(" ").filter((s) => s.length > 0);
|
|
680
1214
|
switch (padding.length) {
|
|
681
1215
|
case 0:
|
|
682
1216
|
break;
|
|
683
1217
|
case 1:
|
|
684
|
-
top ?? (top =
|
|
685
|
-
right ?? (right =
|
|
686
|
-
bottom ?? (bottom =
|
|
687
|
-
left ?? (left =
|
|
1218
|
+
top ?? (top = toPx2(padding[0]));
|
|
1219
|
+
right ?? (right = toPx2(padding[0]));
|
|
1220
|
+
bottom ?? (bottom = toPx2(padding[0]));
|
|
1221
|
+
left ?? (left = toPx2(padding[0]));
|
|
688
1222
|
break;
|
|
689
1223
|
case 2:
|
|
690
|
-
top ?? (top =
|
|
691
|
-
right ?? (right =
|
|
692
|
-
bottom ?? (bottom =
|
|
693
|
-
left ?? (left =
|
|
1224
|
+
top ?? (top = toPx2(padding[0]));
|
|
1225
|
+
right ?? (right = toPx2(padding[1]));
|
|
1226
|
+
bottom ?? (bottom = toPx2(padding[0]));
|
|
1227
|
+
left ?? (left = toPx2(padding[1]));
|
|
694
1228
|
break;
|
|
695
1229
|
case 3:
|
|
696
|
-
top ?? (top =
|
|
697
|
-
right ?? (right =
|
|
698
|
-
bottom ?? (bottom =
|
|
699
|
-
left ?? (left =
|
|
1230
|
+
top ?? (top = toPx2(padding[0]));
|
|
1231
|
+
right ?? (right = toPx2(padding[1]));
|
|
1232
|
+
bottom ?? (bottom = toPx2(padding[2]));
|
|
1233
|
+
left ?? (left = toPx2(padding[1]));
|
|
700
1234
|
break;
|
|
701
1235
|
case 4:
|
|
702
1236
|
default:
|
|
703
|
-
top ?? (top =
|
|
704
|
-
right ?? (right =
|
|
705
|
-
bottom ?? (bottom =
|
|
706
|
-
left ?? (left =
|
|
1237
|
+
top ?? (top = toPx2(padding[0]));
|
|
1238
|
+
right ?? (right = toPx2(padding[1]));
|
|
1239
|
+
bottom ?? (bottom = toPx2(padding[2]));
|
|
1240
|
+
left ?? (left = toPx2(padding[3]));
|
|
707
1241
|
break;
|
|
708
1242
|
}
|
|
709
1243
|
top ?? (top = 0);
|
|
@@ -713,12 +1247,12 @@ function getPadding(style) {
|
|
|
713
1247
|
return { top, right, bottom, left };
|
|
714
1248
|
}
|
|
715
1249
|
function getDimension(style) {
|
|
716
|
-
let left =
|
|
717
|
-
let right =
|
|
718
|
-
let top =
|
|
719
|
-
let bottom =
|
|
720
|
-
let width =
|
|
721
|
-
let height =
|
|
1250
|
+
let left = toPx2(style?.left);
|
|
1251
|
+
let right = toPx2(style?.right);
|
|
1252
|
+
let top = toPx2(style?.top);
|
|
1253
|
+
let bottom = toPx2(style?.bottom);
|
|
1254
|
+
let width = toPx2(style?.width);
|
|
1255
|
+
let height = toPx2(style?.height);
|
|
722
1256
|
if (width === void 0 && left !== void 0 && right !== void 0) {
|
|
723
1257
|
width = right - left;
|
|
724
1258
|
}
|
|
@@ -753,9 +1287,7 @@ __export(map_exports, {
|
|
|
753
1287
|
getMapKeys: () => getMapKeys
|
|
754
1288
|
});
|
|
755
1289
|
function getMapKeys(map) {
|
|
756
|
-
|
|
757
|
-
map.forEach((value, key) => keys.push(key));
|
|
758
|
-
return keys;
|
|
1290
|
+
return [...map.keys()];
|
|
759
1291
|
}
|
|
760
1292
|
|
|
761
1293
|
// src/utils/math/index.ts
|
|
@@ -767,8 +1299,8 @@ __export(math_exports, {
|
|
|
767
1299
|
cmp: () => cmp,
|
|
768
1300
|
interpolateCoord: () => interpolateCoord,
|
|
769
1301
|
interpolateY: () => interpolateY,
|
|
770
|
-
isInteger: () =>
|
|
771
|
-
isNumber: () =>
|
|
1302
|
+
isInteger: () => isInteger2,
|
|
1303
|
+
isNumber: () => isNumber2,
|
|
772
1304
|
linearToDecibels: () => linearToDecibels,
|
|
773
1305
|
mod: () => mod,
|
|
774
1306
|
romanize: () => romanize,
|
|
@@ -788,7 +1320,7 @@ function mod(m, n) {
|
|
|
788
1320
|
return (m % n + n) % n;
|
|
789
1321
|
}
|
|
790
1322
|
function romanize(n) {
|
|
791
|
-
if (!
|
|
1323
|
+
if (!isInteger2(n) || n < 0) {
|
|
792
1324
|
throw new Error("romanize: Invalid n = " + n);
|
|
793
1325
|
}
|
|
794
1326
|
var digits = String(+n).split("");
|
|
@@ -829,7 +1361,7 @@ function romanize(n) {
|
|
|
829
1361
|
return Array(+digits.join("") + 1).join("M") + roman;
|
|
830
1362
|
}
|
|
831
1363
|
function toOrdinalNumber(n) {
|
|
832
|
-
if (!
|
|
1364
|
+
if (!isInteger2(n)) {
|
|
833
1365
|
throw new Error("toOrdinalNumber: Invalid n = " + n);
|
|
834
1366
|
}
|
|
835
1367
|
const nStr = n.toString();
|
|
@@ -882,87 +1414,58 @@ function cmp(a, b) {
|
|
|
882
1414
|
return a < b ? -1 : a > b ? 1 : 0;
|
|
883
1415
|
}
|
|
884
1416
|
|
|
885
|
-
// src/utils/obj/index.ts
|
|
886
|
-
var obj_exports = {};
|
|
887
|
-
__export(obj_exports, {
|
|
888
|
-
deepEqual: () => deepEqual,
|
|
889
|
-
hasProperties: () => hasProperties,
|
|
890
|
-
isObject: () => isObject
|
|
891
|
-
});
|
|
892
|
-
function hasProperties(obj, props) {
|
|
893
|
-
return isObject(obj) && props.every((p) => p in obj);
|
|
894
|
-
}
|
|
895
|
-
function deepEqual(a, b) {
|
|
896
|
-
if (a === b) return true;
|
|
897
|
-
if (a === null || b === null) return false;
|
|
898
|
-
if (typeof a !== "object" || typeof b !== "object") return false;
|
|
899
|
-
if (Array.isArray(a) && Array.isArray(b)) {
|
|
900
|
-
if (a.length !== b.length) return false;
|
|
901
|
-
return a.every((val, i) => deepEqual(val, b[i]));
|
|
902
|
-
}
|
|
903
|
-
if (Array.isArray(a) !== Array.isArray(b)) return false;
|
|
904
|
-
const keysA = Object.keys(a);
|
|
905
|
-
const keysB = Object.keys(b);
|
|
906
|
-
if (keysA.length !== keysB.length) return false;
|
|
907
|
-
for (const key of keysA) {
|
|
908
|
-
if (!Object.prototype.hasOwnProperty.call(b, key)) return false;
|
|
909
|
-
if (!deepEqual(a[key], b[key])) return false;
|
|
910
|
-
}
|
|
911
|
-
return true;
|
|
912
|
-
}
|
|
913
|
-
|
|
914
1417
|
// src/utils/str/index.ts
|
|
915
1418
|
var str_exports = {};
|
|
916
1419
|
__export(str_exports, {
|
|
917
1420
|
charCount: () => charCount,
|
|
918
1421
|
chunkString: () => chunkString,
|
|
919
1422
|
insertAt: () => insertAt,
|
|
920
|
-
isString: () =>
|
|
1423
|
+
isString: () => isString2,
|
|
921
1424
|
makeSentenceFromPascal: () => makeSentenceFromPascal,
|
|
922
1425
|
removeAt: () => removeAt,
|
|
923
1426
|
repeatString: () => repeatString,
|
|
924
1427
|
replaceAt: () => replaceAt,
|
|
925
1428
|
toCharArray: () => toCharArray
|
|
926
1429
|
});
|
|
927
|
-
function toCharArray(
|
|
928
|
-
return
|
|
1430
|
+
function toCharArray(str2) {
|
|
1431
|
+
return str2.split("");
|
|
929
1432
|
}
|
|
930
1433
|
function repeatString(repeatString2, repeatCount) {
|
|
931
|
-
if (!
|
|
1434
|
+
if (!isInteger2(repeatCount) || repeatCount < 0) {
|
|
932
1435
|
throw new Error("repeatStr: Invalid repeatCount = " + repeatCount);
|
|
933
1436
|
}
|
|
934
1437
|
return new Array(repeatCount + 1).join(repeatString2);
|
|
935
1438
|
}
|
|
936
|
-
function chunkString(
|
|
937
|
-
if (!
|
|
1439
|
+
function chunkString(str2, chunkSize) {
|
|
1440
|
+
if (!isInteger2(chunkSize) || chunkSize < 1) {
|
|
938
1441
|
throw new Error("chunckString: Invalid chuckSize = " + chunkSize);
|
|
939
1442
|
}
|
|
940
1443
|
let result = [];
|
|
941
|
-
for (let i = 0; i <
|
|
942
|
-
result.push(
|
|
1444
|
+
for (let i = 0; i < str2.length; i += chunkSize) {
|
|
1445
|
+
result.push(str2.slice(i, i + chunkSize));
|
|
943
1446
|
}
|
|
944
1447
|
return result;
|
|
945
1448
|
}
|
|
946
|
-
function replaceAt(
|
|
947
|
-
if (!
|
|
1449
|
+
function replaceAt(str2, pos, removeCount, insert) {
|
|
1450
|
+
if (!isInteger2(removeCount) || removeCount < 0) {
|
|
948
1451
|
throw new Error("replaceAt: Invalid removeCount = " + removeCount);
|
|
949
|
-
} else if (!
|
|
950
|
-
throw new Error("replaceAt: Invalid pos = " + pos + ", removeCount = " + removeCount + ", str.length = " +
|
|
1452
|
+
} else if (!isInteger2(pos) || pos < 0 || pos + removeCount > str2.length) {
|
|
1453
|
+
throw new Error("replaceAt: Invalid pos = " + pos + ", removeCount = " + removeCount + ", str.length = " + str2.length);
|
|
951
1454
|
} else {
|
|
952
|
-
return
|
|
1455
|
+
return str2.substring(0, pos) + insert + str2.substring(pos + removeCount);
|
|
953
1456
|
}
|
|
954
1457
|
}
|
|
955
|
-
function insertAt(
|
|
956
|
-
return replaceAt(
|
|
1458
|
+
function insertAt(str2, pos, insertStr) {
|
|
1459
|
+
return replaceAt(str2, pos, 0, insertStr);
|
|
957
1460
|
}
|
|
958
|
-
function removeAt(
|
|
959
|
-
return replaceAt(
|
|
1461
|
+
function removeAt(str2, pos, removeCount) {
|
|
1462
|
+
return replaceAt(str2, pos, removeCount, "");
|
|
960
1463
|
}
|
|
961
|
-
function charCount(
|
|
962
|
-
if (ch.length !== 1 ||
|
|
1464
|
+
function charCount(str2, ch) {
|
|
1465
|
+
if (ch.length !== 1 || str2.length === 0) return 0;
|
|
963
1466
|
let count = 0;
|
|
964
|
-
for (let i = 0; i <
|
|
965
|
-
if (
|
|
1467
|
+
for (let i = 0; i < str2.length; i++) {
|
|
1468
|
+
if (str2[i] === ch) count++;
|
|
966
1469
|
}
|
|
967
1470
|
return count;
|
|
968
1471
|
}
|
|
@@ -996,126 +1499,86 @@ function makeSentenceFromPascal(PascalString) {
|
|
|
996
1499
|
return sentence;
|
|
997
1500
|
}
|
|
998
1501
|
|
|
999
|
-
// src/
|
|
1000
|
-
var
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
((
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
function setExpireDays(days) {
|
|
1013
|
-
_expires = /* @__PURE__ */ new Date();
|
|
1014
|
-
_expires.setDate(_expires.getDate() + days);
|
|
1015
|
-
}
|
|
1016
|
-
Cookies2.setExpireDays = setExpireDays;
|
|
1017
|
-
function isConsentPending() {
|
|
1018
|
-
return _consent === void 0;
|
|
1019
|
-
}
|
|
1020
|
-
Cookies2.isConsentPending = isConsentPending;
|
|
1021
|
-
function accept() {
|
|
1022
|
-
_consent = "accept" /* Accept */;
|
|
1023
|
-
_save(ConsentCookieName, _consent);
|
|
1024
|
-
}
|
|
1025
|
-
Cookies2.accept = accept;
|
|
1026
|
-
function decline() {
|
|
1027
|
-
_consent = "decline" /* Decline */;
|
|
1028
|
-
_save(ConsentCookieName, _consent);
|
|
1029
|
-
}
|
|
1030
|
-
Cookies2.decline = decline;
|
|
1031
|
-
function _getList() {
|
|
1032
|
-
let s = document.cookie;
|
|
1033
|
-
return s.split(";").map((c) => c.trim());
|
|
1034
|
-
}
|
|
1035
|
-
function _save(name, value) {
|
|
1036
|
-
let cookie = name + "=" + value.toString() + ";sameSite=Lax;";
|
|
1037
|
-
if (_expires) {
|
|
1038
|
-
cookie += "expires=" + _expires.toUTCString() + ";";
|
|
1039
|
-
}
|
|
1040
|
-
document.cookie = cookie;
|
|
1041
|
-
return value;
|
|
1502
|
+
// src/utils/index.ts
|
|
1503
|
+
var Is = guard_exports;
|
|
1504
|
+
|
|
1505
|
+
// src/core/format-value.ts
|
|
1506
|
+
function formatValue(value) {
|
|
1507
|
+
if (isString2(value)) {
|
|
1508
|
+
return `"${value}"`;
|
|
1509
|
+
} else if (isArray2(value)) {
|
|
1510
|
+
return `[ ${value.map((e) => formatValue(e)).join(", ")} ]`.replaceAll(" ", " ");
|
|
1511
|
+
} else if (isFunction2(value.toString)) {
|
|
1512
|
+
return value.toString();
|
|
1513
|
+
} else {
|
|
1514
|
+
return JSON.stringify(value);
|
|
1042
1515
|
}
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1516
|
+
}
|
|
1517
|
+
|
|
1518
|
+
// src/core/stack.ts
|
|
1519
|
+
var Stack = class {
|
|
1520
|
+
constructor() {
|
|
1521
|
+
__publicField(this, "data", []);
|
|
1046
1522
|
}
|
|
1047
|
-
|
|
1048
|
-
|
|
1523
|
+
assertId(id) {
|
|
1524
|
+
assert_exports.isIntegerBetween(id, 0, this.length - 1, `Stack index ${id} out of range.`);
|
|
1525
|
+
return id;
|
|
1049
1526
|
}
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
_save(name, value);
|
|
1053
|
-
}
|
|
1054
|
-
return value;
|
|
1527
|
+
get length() {
|
|
1528
|
+
return this.data.length;
|
|
1055
1529
|
}
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
return _read(name, defaultValue) || defaultValue;
|
|
1060
|
-
} else {
|
|
1061
|
-
return defaultValue;
|
|
1062
|
-
}
|
|
1530
|
+
push(el) {
|
|
1531
|
+
this.data.push(el);
|
|
1532
|
+
return el;
|
|
1063
1533
|
}
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
let str2 = _read(name);
|
|
1068
|
-
return str2 === void 0 ? defaultValue : parseInt(str2);
|
|
1069
|
-
} else {
|
|
1070
|
-
return defaultValue;
|
|
1071
|
-
}
|
|
1534
|
+
pop() {
|
|
1535
|
+
this.assertId(this.length - 1);
|
|
1536
|
+
return this.data.pop();
|
|
1072
1537
|
}
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
if (_consent === "accept" /* Accept */) {
|
|
1076
|
-
let str2 = _read(name);
|
|
1077
|
-
return str2 === void 0 ? defaultValue : /true|1/i.test(str2);
|
|
1078
|
-
} else {
|
|
1079
|
-
return defaultValue;
|
|
1080
|
-
}
|
|
1538
|
+
popOrUndef() {
|
|
1539
|
+
return this.data.pop();
|
|
1081
1540
|
}
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
if (_consent === "accept" /* Accept */ || name === ConsentCookieName) {
|
|
1085
|
-
_erase(name);
|
|
1086
|
-
}
|
|
1541
|
+
popOr(defaultValueOrCreator) {
|
|
1542
|
+
return this.isEmpty() ? isFunction2(defaultValueOrCreator) ? defaultValueOrCreator() : defaultValueOrCreator : this.data.pop();
|
|
1087
1543
|
}
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
document.cookie.split(";").forEach((c) => erase(c.trim().split("=")[0]));
|
|
1544
|
+
top() {
|
|
1545
|
+
return this.data[this.assertId(this.length - 1)];
|
|
1091
1546
|
}
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
// src/core/stack.ts
|
|
1096
|
-
var Stack = class {
|
|
1097
|
-
constructor() {
|
|
1098
|
-
__publicField(this, "list", []);
|
|
1547
|
+
topOrUndef() {
|
|
1548
|
+
return this.data[this.length - 1];
|
|
1099
1549
|
}
|
|
1100
|
-
|
|
1101
|
-
this.
|
|
1102
|
-
return e;
|
|
1550
|
+
topOr(defaultValueOrCreator) {
|
|
1551
|
+
return this.isEmpty() ? isFunction2(defaultValueOrCreator) ? defaultValueOrCreator() : defaultValueOrCreator : this.data[this.length - 1];
|
|
1103
1552
|
}
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
return this.list.pop();
|
|
1553
|
+
peek(depth = 0) {
|
|
1554
|
+
return this.data[this.assertId(this.data.length - 1 - depth)];
|
|
1107
1555
|
}
|
|
1108
|
-
|
|
1109
|
-
return
|
|
1556
|
+
peekOrUndef(depth = 0) {
|
|
1557
|
+
return this.data[this.data.length - 1 - depth];
|
|
1558
|
+
}
|
|
1559
|
+
peekOr(depth = 0, defaultValueOrCreator) {
|
|
1560
|
+
const id = this.data.length - 1 - depth;
|
|
1561
|
+
const value = id < 0 ? void 0 : this.data[id];
|
|
1562
|
+
return value === void 0 ? isFunction2(defaultValueOrCreator) ? defaultValueOrCreator() : defaultValueOrCreator : value;
|
|
1563
|
+
}
|
|
1564
|
+
*values() {
|
|
1565
|
+
for (let id = this.data.length - 1; id >= 0; id--)
|
|
1566
|
+
yield this.data[id];
|
|
1567
|
+
}
|
|
1568
|
+
*[Symbol.iterator]() {
|
|
1569
|
+
yield* this.values();
|
|
1110
1570
|
}
|
|
1111
1571
|
toArray() {
|
|
1112
|
-
return this.
|
|
1572
|
+
return [...this.data];
|
|
1113
1573
|
}
|
|
1114
|
-
|
|
1115
|
-
return this.
|
|
1574
|
+
isEmpty() {
|
|
1575
|
+
return this.length === 0;
|
|
1116
1576
|
}
|
|
1117
1577
|
clear() {
|
|
1118
|
-
this.
|
|
1578
|
+
this.data.length = 0;
|
|
1579
|
+
}
|
|
1580
|
+
toString() {
|
|
1581
|
+
return `Stack(${this.length})${formatValue(this.data)}`;
|
|
1119
1582
|
}
|
|
1120
1583
|
};
|
|
1121
1584
|
|
|
@@ -1140,9 +1603,15 @@ var Vec = class _Vec {
|
|
|
1140
1603
|
}
|
|
1141
1604
|
return new _Vec(...Array(dim).fill(0));
|
|
1142
1605
|
}
|
|
1606
|
+
get dim() {
|
|
1607
|
+
return this.coords.length;
|
|
1608
|
+
}
|
|
1143
1609
|
get length() {
|
|
1144
1610
|
return Math.hypot(...this.coords);
|
|
1145
1611
|
}
|
|
1612
|
+
magnitude() {
|
|
1613
|
+
return this.length;
|
|
1614
|
+
}
|
|
1146
1615
|
get x() {
|
|
1147
1616
|
return this.coords[0];
|
|
1148
1617
|
}
|
|
@@ -1194,6 +1663,38 @@ var Vec = class _Vec {
|
|
|
1194
1663
|
}
|
|
1195
1664
|
return this.div(len);
|
|
1196
1665
|
}
|
|
1666
|
+
static lerp(a, b, t) {
|
|
1667
|
+
if (a.coords.length !== b.coords.length) {
|
|
1668
|
+
throw new TypeError("Coordinate length mismatch!");
|
|
1669
|
+
}
|
|
1670
|
+
if (!isFinite3(t)) {
|
|
1671
|
+
throw new TypeError("Lerp t is not finite!");
|
|
1672
|
+
}
|
|
1673
|
+
return a.add(b.sub(a).mul(t));
|
|
1674
|
+
}
|
|
1675
|
+
toLength(len) {
|
|
1676
|
+
const mag = this.length;
|
|
1677
|
+
return mag === 0 ? this : this.mul(len / mag);
|
|
1678
|
+
}
|
|
1679
|
+
clamp(minLength, maxLength, defaultDir) {
|
|
1680
|
+
const mag = this.length;
|
|
1681
|
+
if (mag === 0) {
|
|
1682
|
+
if (minLength !== void 0) {
|
|
1683
|
+
if (defaultDir && defaultDir.coords.length !== this.coords.length)
|
|
1684
|
+
throw new TypeError("Coordinate length mismatch!");
|
|
1685
|
+
const dir = defaultDir && defaultDir.length !== 0 ? defaultDir.normalize() : new _Vec(1, ...Array(this.coords.length - 1).fill(0));
|
|
1686
|
+
return dir.mul(minLength);
|
|
1687
|
+
}
|
|
1688
|
+
return this;
|
|
1689
|
+
}
|
|
1690
|
+
if (maxLength !== void 0 && mag > maxLength) {
|
|
1691
|
+
return this.normalize().mul(maxLength);
|
|
1692
|
+
}
|
|
1693
|
+
if (minLength !== void 0 && mag < minLength) {
|
|
1694
|
+
return this.normalize().mul(minLength);
|
|
1695
|
+
}
|
|
1696
|
+
return this;
|
|
1697
|
+
}
|
|
1197
1698
|
equals(other) {
|
|
1198
1699
|
return this.coords.length === other.coords.length && this.coords.every((v, i) => v === other.coords[i]);
|
|
1199
1700
|
}
|
|
@@ -1215,28 +1716,28 @@ var Vec = class _Vec {
|
|
|
1215
1716
|
var DivRect = class _DivRect {
|
|
1216
1717
|
constructor(...args) {
|
|
1217
1718
|
__publicField(this, "left");
|
|
1218
|
-
__publicField(this, "
|
|
1719
|
+
__publicField(this, "anchorX");
|
|
1219
1720
|
__publicField(this, "right");
|
|
1220
1721
|
__publicField(this, "top");
|
|
1221
|
-
__publicField(this, "
|
|
1722
|
+
__publicField(this, "anchorY");
|
|
1222
1723
|
__publicField(this, "bottom");
|
|
1223
1724
|
if (args.length === 6) {
|
|
1224
1725
|
this.left = args[0];
|
|
1225
|
-
this.
|
|
1726
|
+
this.anchorX = args[1];
|
|
1226
1727
|
this.right = args[2];
|
|
1227
1728
|
this.top = args[3];
|
|
1228
|
-
this.
|
|
1729
|
+
this.anchorY = args[4];
|
|
1229
1730
|
this.bottom = args[5];
|
|
1230
1731
|
} else if (args.length === 4) {
|
|
1231
1732
|
this.left = args[0];
|
|
1232
1733
|
this.right = args[1];
|
|
1233
|
-
this.
|
|
1734
|
+
this.anchorX = (this.left + this.right) / 2;
|
|
1234
1735
|
this.top = args[2];
|
|
1235
1736
|
this.bottom = args[3];
|
|
1236
|
-
this.
|
|
1737
|
+
this.anchorY = (this.top + this.bottom) / 2;
|
|
1237
1738
|
} else if (args.length === 0) {
|
|
1238
|
-
this.left = this.
|
|
1239
|
-
this.top = this.
|
|
1739
|
+
this.left = this.anchorX = this.right = 0;
|
|
1740
|
+
this.top = this.anchorY = this.bottom = 0;
|
|
1240
1741
|
} else {
|
|
1241
1742
|
throw new TypeError(`Invalid DivRect args: ${args}`);
|
|
1242
1743
|
}
|
|
@@ -1254,7 +1755,7 @@ var DivRect = class _DivRect {
|
|
|
1254
1755
|
return new _DivRect(left, left + width, top, top + height);
|
|
1255
1756
|
}
|
|
1256
1757
|
/**
|
|
1257
|
-
* Create rect from
|
|
1758
|
+
* Create rect from anchorX, anchorY, width, height arguments.
|
|
1258
1759
|
*
|
|
1259
1760
|
* @param centerX - Center x-coordinate.
|
|
1260
1761
|
* @param centerY - Center y-coordinate.
|
|
@@ -1284,6 +1785,22 @@ var DivRect = class _DivRect {
|
|
|
1284
1785
|
static createSections(leftw, rightw, toph, bottomh) {
|
|
1285
1786
|
return new _DivRect(-leftw, 0, rightw, -toph, 0, bottomh);
|
|
1286
1787
|
}
|
|
1788
|
+
/** @deprecated - Renamed to anchorX. */
|
|
1789
|
+
get centerX() {
|
|
1790
|
+
return this.anchorX;
|
|
1791
|
+
}
|
|
1792
|
+
/** @deprecated - Renamed to anchorX. */
|
|
1793
|
+
set centerX(x) {
|
|
1794
|
+
this.anchorX = x;
|
|
1795
|
+
}
|
|
1796
|
+
/** @deprecated - Renamed to anchorY. */
|
|
1797
|
+
get centerY() {
|
|
1798
|
+
return this.anchorY;
|
|
1799
|
+
}
|
|
1800
|
+
/** @deprecated - Renamed to anchorY. */
|
|
1801
|
+
set centerY(y) {
|
|
1802
|
+
this.anchorY = y;
|
|
1803
|
+
}
|
|
1287
1804
|
/**
|
|
1288
1805
|
* Width getter.
|
|
1289
1806
|
*/
|
|
@@ -1300,25 +1817,25 @@ var DivRect = class _DivRect {
|
|
|
1300
1817
|
* Left section width getter.
|
|
1301
1818
|
*/
|
|
1302
1819
|
get leftw() {
|
|
1303
|
-
return this.
|
|
1820
|
+
return this.anchorX - this.left;
|
|
1304
1821
|
}
|
|
1305
1822
|
/**
|
|
1306
1823
|
* Right section width getter.
|
|
1307
1824
|
*/
|
|
1308
1825
|
get rightw() {
|
|
1309
|
-
return this.right - this.
|
|
1826
|
+
return this.right - this.anchorX;
|
|
1310
1827
|
}
|
|
1311
1828
|
/**
|
|
1312
1829
|
* Top section height getter.
|
|
1313
1830
|
*/
|
|
1314
1831
|
get toph() {
|
|
1315
|
-
return this.
|
|
1832
|
+
return this.anchorY - this.top;
|
|
1316
1833
|
}
|
|
1317
1834
|
/**
|
|
1318
1835
|
* Bottom section height getter.
|
|
1319
1836
|
*/
|
|
1320
1837
|
get bottomh() {
|
|
1321
|
-
return this.bottom - this.
|
|
1838
|
+
return this.bottom - this.anchorY;
|
|
1322
1839
|
}
|
|
1323
1840
|
/**
|
|
1324
1841
|
* Does this Rect contain given (x, y)-point?
|
|
@@ -1362,7 +1879,7 @@ var DivRect = class _DivRect {
|
|
|
1362
1879
|
} else if (a == null || b == null) {
|
|
1363
1880
|
return false;
|
|
1364
1881
|
} else {
|
|
1365
|
-
return a === b || a.left === b.left && a.
|
|
1882
|
+
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;
|
|
1366
1883
|
}
|
|
1367
1884
|
}
|
|
1368
1885
|
/**
|
|
@@ -1374,7 +1891,7 @@ var DivRect = class _DivRect {
|
|
|
1374
1891
|
return _DivRect.equals(this, other);
|
|
1375
1892
|
}
|
|
1376
1893
|
/**
|
|
1377
|
-
* Check if edges of given rects are equal, ignoring
|
|
1894
|
+
* Check if edges of given rects are equal, ignoring anchorX and anchorY.
|
|
1378
1895
|
*
|
|
1379
1896
|
* @param a - DivRect a.
|
|
1380
1897
|
* @param b - DivRect b.
|
|
@@ -1390,7 +1907,7 @@ var DivRect = class _DivRect {
|
|
|
1390
1907
|
}
|
|
1391
1908
|
}
|
|
1392
1909
|
/**
|
|
1393
|
-
* Check if edges of this Rect equals with given Rect, ignoring
|
|
1910
|
+
* Check if edges of this Rect equals with given Rect, ignoring anchorX and anchorY.
|
|
1394
1911
|
*
|
|
1395
1912
|
* @param other - The other DivRect.
|
|
1396
1913
|
* @returns - True/false.
|
|
@@ -1398,13 +1915,17 @@ var DivRect = class _DivRect {
|
|
|
1398
1915
|
equalsEdges(other) {
|
|
1399
1916
|
return _DivRect.equalsEdges(this, other);
|
|
1400
1917
|
}
|
|
1918
|
+
/** @deprecated - Use `DivRect.equalsEdges()` instead. */
|
|
1919
|
+
static equalsFrame(a, b) {
|
|
1920
|
+
return _DivRect.equalsEdges(a, b);
|
|
1921
|
+
}
|
|
1401
1922
|
/**
|
|
1402
1923
|
* Created duplicate of this Rect.
|
|
1403
1924
|
*
|
|
1404
1925
|
* @returns - Duplicate.
|
|
1405
1926
|
*/
|
|
1406
1927
|
copy() {
|
|
1407
|
-
return new _DivRect(this.left, this.
|
|
1928
|
+
return new _DivRect(this.left, this.anchorX, this.right, this.top, this.anchorY, this.bottom);
|
|
1408
1929
|
}
|
|
1409
1930
|
/**
|
|
1410
1931
|
* Move this rect by (dx, dy). Modifies this Rect.
|
|
@@ -1415,10 +1936,10 @@ var DivRect = class _DivRect {
|
|
|
1415
1936
|
*/
|
|
1416
1937
|
offsetInPlace(dx, dy) {
|
|
1417
1938
|
this.left += dx;
|
|
1418
|
-
this.
|
|
1939
|
+
this.anchorX += dx;
|
|
1419
1940
|
this.right += dx;
|
|
1420
1941
|
this.top += dy;
|
|
1421
|
-
this.
|
|
1942
|
+
this.anchorY += dy;
|
|
1422
1943
|
this.bottom += dy;
|
|
1423
1944
|
return this;
|
|
1424
1945
|
}
|
|
@@ -1463,10 +1984,10 @@ var DivRect = class _DivRect {
|
|
|
1463
1984
|
clipInPlace(clipRect) {
|
|
1464
1985
|
this.left = Math.max(this.left, clipRect.left);
|
|
1465
1986
|
this.right = Math.min(this.right, clipRect.right);
|
|
1466
|
-
this.
|
|
1987
|
+
this.anchorX = clamp(this.anchorX, this.left, this.right);
|
|
1467
1988
|
this.top = Math.max(this.top, clipRect.top);
|
|
1468
1989
|
this.bottom = Math.min(this.bottom, clipRect.bottom);
|
|
1469
|
-
this.
|
|
1990
|
+
this.anchorY = clamp(this.anchorY, this.top, this.bottom);
|
|
1470
1991
|
return this;
|
|
1471
1992
|
}
|
|
1472
1993
|
/**
|
|
@@ -1479,7 +2000,7 @@ var DivRect = class _DivRect {
|
|
|
1479
2000
|
return this.copy().clipInPlace(clipRect);
|
|
1480
2001
|
}
|
|
1481
2002
|
/**
|
|
1482
|
-
* Scale Rect. Anchor pos is (
|
|
2003
|
+
* Scale Rect. Anchor pos is (anchorX, anchorY). Modifies this Rect.
|
|
1483
2004
|
*
|
|
1484
2005
|
* @param scaleX - Scale x-amount.
|
|
1485
2006
|
* @param scaleY - Scale y-amount. If undefined then scale x-amount is used.
|
|
@@ -1487,14 +2008,14 @@ var DivRect = class _DivRect {
|
|
|
1487
2008
|
*/
|
|
1488
2009
|
scaleInPlace(scaleX, scaleY) {
|
|
1489
2010
|
scaleY = scaleY ?? scaleX;
|
|
1490
|
-
this.left = this.
|
|
1491
|
-
this.right = this.
|
|
1492
|
-
this.top = this.
|
|
1493
|
-
this.bottom = this.
|
|
2011
|
+
this.left = this.anchorX - this.leftw * scaleX;
|
|
2012
|
+
this.right = this.anchorX + this.rightw * scaleX;
|
|
2013
|
+
this.top = this.anchorY - this.toph * scaleY;
|
|
2014
|
+
this.bottom = this.anchorY + this.bottomh * scaleY;
|
|
1494
2015
|
return this;
|
|
1495
2016
|
}
|
|
1496
2017
|
/**
|
|
1497
|
-
* Scale Rect. Anchor pos is (
|
|
2018
|
+
* Scale Rect. Anchor pos is (anchorX, anchorY). Immutable, returns modified copy.
|
|
1498
2019
|
*
|
|
1499
2020
|
* @param scaleX - Scale x-amount.
|
|
1500
2021
|
* @param scaleY - Scale y-amount. If undefined then scale x-amount is used.
|
|
@@ -1632,7 +2153,7 @@ var IndexArray = class _IndexArray {
|
|
|
1632
2153
|
}
|
|
1633
2154
|
}
|
|
1634
2155
|
static validateIndex(id) {
|
|
1635
|
-
if (!
|
|
2156
|
+
if (!isIntegerGte2(id, 0)) throw new Error(`Invalid index ${id} - must be an integer >= 0!`);
|
|
1636
2157
|
return id;
|
|
1637
2158
|
}
|
|
1638
2159
|
get posLen() {
|
|
@@ -1641,6 +2162,14 @@ var IndexArray = class _IndexArray {
|
|
|
1641
2162
|
get size() {
|
|
1642
2163
|
return this.valCount;
|
|
1643
2164
|
}
|
|
2165
|
+
get length() {
|
|
2166
|
+
return this.hasPos.length;
|
|
2167
|
+
}
|
|
2168
|
+
trimRight() {
|
|
2169
|
+
let newLength = this.length;
|
|
2170
|
+
while (newLength > 0 && this.hasPos[newLength - 1] !== true) newLength--;
|
|
2171
|
+
if (newLength < this.length) this.posVal.length = this.hasPos.length = newLength;
|
|
2172
|
+
}
|
|
1644
2173
|
isEmpty() {
|
|
1645
2174
|
return this.size === 0;
|
|
1646
2175
|
}
|
|
@@ -1663,7 +2192,7 @@ var IndexArray = class _IndexArray {
|
|
|
1663
2192
|
}
|
|
1664
2193
|
getOrCreate(id, creatorOrValue) {
|
|
1665
2194
|
if (!this.has(id)) {
|
|
1666
|
-
const value =
|
|
2195
|
+
const value = isFunction2(creatorOrValue) ? creatorOrValue() : creatorOrValue;
|
|
1667
2196
|
this.set(id, value);
|
|
1668
2197
|
return value;
|
|
1669
2198
|
}
|
|
@@ -1675,6 +2204,7 @@ var IndexArray = class _IndexArray {
|
|
|
1675
2204
|
this.posVal[id] = void 0;
|
|
1676
2205
|
this.hasPos[id] = false;
|
|
1677
2206
|
this.valCount--;
|
|
2207
|
+
this.trimRight();
|
|
1678
2208
|
return true;
|
|
1679
2209
|
}
|
|
1680
2210
|
clear() {
|
|
@@ -1799,22 +2329,24 @@ var IndexArray = class _IndexArray {
|
|
|
1799
2329
|
}
|
|
1800
2330
|
return result;
|
|
1801
2331
|
}
|
|
1802
|
-
equals(other,
|
|
2332
|
+
equals(other, eq2) {
|
|
1803
2333
|
if (this.size !== other.size) return false;
|
|
1804
|
-
|
|
2334
|
+
eq2 ?? (eq2 = (a, b) => a === b);
|
|
1805
2335
|
const posLen = Math.max(this.posLen, other.posLen);
|
|
1806
2336
|
for (let i = 0; i < posLen; ++i) {
|
|
1807
2337
|
const hasA = this.hasPos[i];
|
|
1808
2338
|
const hasB = other.hasPos[i];
|
|
1809
2339
|
if (hasA !== hasB) return false;
|
|
1810
|
-
if (hasA && !
|
|
2340
|
+
if (hasA && !eq2(this.posVal[i], other.posVal[i])) return false;
|
|
1811
2341
|
}
|
|
1812
2342
|
return true;
|
|
1813
2343
|
}
|
|
2344
|
+
toArray() {
|
|
2345
|
+
return this.valuesArray();
|
|
2346
|
+
}
|
|
1814
2347
|
toString() {
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
return `IndexArray[ ${entries} ]`;
|
|
2348
|
+
const entries = this.entriesArray().map(([id, v]) => `${formatValue(id)}: ${formatValue(v)}`).join(", ");
|
|
2349
|
+
return `IndexArray[ ${entries} ]`.replaceAll(" ", " ");
|
|
1818
2350
|
}
|
|
1819
2351
|
};
|
|
1820
2352
|
|
|
@@ -1852,7 +2384,7 @@ var SignedIndexArray = class _SignedIndexArray {
|
|
|
1852
2384
|
return -id - 1;
|
|
1853
2385
|
}
|
|
1854
2386
|
static validateIndex(id) {
|
|
1855
|
-
if (!
|
|
2387
|
+
if (!isInteger2(id)) throw new Error(`Invalid index ${id} - must be an integer!`);
|
|
1856
2388
|
return id;
|
|
1857
2389
|
}
|
|
1858
2390
|
get size() {
|
|
@@ -1902,7 +2434,7 @@ var SignedIndexArray = class _SignedIndexArray {
|
|
|
1902
2434
|
}
|
|
1903
2435
|
getOrCreate(id, creatorOrValue) {
|
|
1904
2436
|
if (!this.has(id)) {
|
|
1905
|
-
const value =
|
|
2437
|
+
const value = isFunction2(creatorOrValue) ? creatorOrValue() : creatorOrValue;
|
|
1906
2438
|
this.set(id, value);
|
|
1907
2439
|
return value;
|
|
1908
2440
|
}
|
|
@@ -2053,29 +2585,31 @@ var SignedIndexArray = class _SignedIndexArray {
|
|
|
2053
2585
|
}
|
|
2054
2586
|
return result;
|
|
2055
2587
|
}
|
|
2056
|
-
equals(other,
|
|
2588
|
+
equals(other, eq2) {
|
|
2057
2589
|
if (this.size !== other.size) return false;
|
|
2058
|
-
|
|
2590
|
+
eq2 ?? (eq2 = (a, b) => a === b);
|
|
2059
2591
|
const posLen = Math.max(this.posLen, other.posLen);
|
|
2060
2592
|
for (let i = 0; i < posLen; ++i) {
|
|
2061
2593
|
const hasA = this.hasPos[i];
|
|
2062
2594
|
const hasB = other.hasPos[i];
|
|
2063
2595
|
if (hasA !== hasB) return false;
|
|
2064
|
-
if (hasA && !
|
|
2596
|
+
if (hasA && !eq2(this.posVal[i], other.posVal[i])) return false;
|
|
2065
2597
|
}
|
|
2066
2598
|
const negLen = Math.max(this.negLen, other.negLen);
|
|
2067
2599
|
for (let i = 0; i < negLen; ++i) {
|
|
2068
2600
|
const hasA = this.hasNeg[i];
|
|
2069
2601
|
const hasB = other.hasNeg[i];
|
|
2070
2602
|
if (hasA !== hasB) return false;
|
|
2071
|
-
if (hasA && !
|
|
2603
|
+
if (hasA && !eq2(this.negVal[i], other.negVal[i])) return false;
|
|
2072
2604
|
}
|
|
2073
2605
|
return true;
|
|
2074
2606
|
}
|
|
2607
|
+
toArray() {
|
|
2608
|
+
return this.valuesArray();
|
|
2609
|
+
}
|
|
2075
2610
|
toString() {
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
return `SignedIndexArray[ ${entries} ]`;
|
|
2611
|
+
const entries = this.entriesArray().map(([id, v]) => `${formatValue(id)}: ${formatValue(v)}`).join(", ");
|
|
2612
|
+
return `SignedIndexArray[ ${entries} ]`.replaceAll(" ", " ");
|
|
2079
2613
|
}
|
|
2080
2614
|
};
|
|
2081
2615
|
|
|
@@ -2100,7 +2634,7 @@ var Map1 = class _Map1 {
|
|
|
2100
2634
|
}
|
|
2101
2635
|
getOrCreate(key1, creatorOrValue) {
|
|
2102
2636
|
if (!this.has(key1)) {
|
|
2103
|
-
const value =
|
|
2637
|
+
const value = isFunction2(creatorOrValue) ? creatorOrValue() : creatorOrValue;
|
|
2104
2638
|
this.set(key1, value);
|
|
2105
2639
|
return value;
|
|
2106
2640
|
}
|
|
@@ -2232,8 +2766,8 @@ var Map1 = class _Map1 {
|
|
|
2232
2766
|
return new Map(this.map1);
|
|
2233
2767
|
}
|
|
2234
2768
|
toString() {
|
|
2235
|
-
const entries = [...this.map1].map(([k, v]) => `${k} => ${v}`).join(", ");
|
|
2236
|
-
return
|
|
2769
|
+
const entries = [...this.map1].map(([k, v]) => `${formatValue(k)} => ${formatValue(v)}`).join(", ");
|
|
2770
|
+
return `Map1(${this.size}){ ${entries} }`.replaceAll(" ", " ");
|
|
2237
2771
|
}
|
|
2238
2772
|
};
|
|
2239
2773
|
|
|
@@ -2267,7 +2801,7 @@ var Map2 = class _Map2 {
|
|
|
2267
2801
|
}
|
|
2268
2802
|
getOrCreate(key1, key2, creatorOrValue) {
|
|
2269
2803
|
if (!this.has(key1, key2)) {
|
|
2270
|
-
const value =
|
|
2804
|
+
const value = isFunction2(creatorOrValue) ? creatorOrValue() : creatorOrValue;
|
|
2271
2805
|
this.set(key1, key2, value);
|
|
2272
2806
|
return value;
|
|
2273
2807
|
}
|
|
@@ -2426,10 +2960,10 @@ var Map2 = class _Map2 {
|
|
|
2426
2960
|
toString() {
|
|
2427
2961
|
const entries = [];
|
|
2428
2962
|
for (const [key1, map2] of this.map1) {
|
|
2429
|
-
const inner = [...map2].map(([key2, v]) => `${key2} => ${v}`).join(", ");
|
|
2430
|
-
entries.push(`${key1} => { ${inner} }`);
|
|
2963
|
+
const inner = [...map2].map(([key2, v]) => `${formatValue(key2)} => ${formatValue(v)}`).join(", ");
|
|
2964
|
+
entries.push(`${formatValue(key1)} => { ${inner} }`);
|
|
2431
2965
|
}
|
|
2432
|
-
return
|
|
2966
|
+
return `Map2(${this.size}){ ${entries} }`.replaceAll(" ", " ");
|
|
2433
2967
|
}
|
|
2434
2968
|
};
|
|
2435
2969
|
|
|
@@ -2470,7 +3004,7 @@ var Map3 = class _Map3 {
|
|
|
2470
3004
|
}
|
|
2471
3005
|
getOrCreate(key1, key2, key3, creatorOrValue) {
|
|
2472
3006
|
if (!this.has(key1, key2, key3)) {
|
|
2473
|
-
const value =
|
|
3007
|
+
const value = isFunction2(creatorOrValue) ? creatorOrValue() : creatorOrValue;
|
|
2474
3008
|
this.set(key1, key2, key3, value);
|
|
2475
3009
|
return value;
|
|
2476
3010
|
}
|
|
@@ -2654,11 +3188,11 @@ var Map3 = class _Map3 {
|
|
|
2654
3188
|
const entries = [];
|
|
2655
3189
|
for (const [key1, map2] of this.map1) {
|
|
2656
3190
|
for (const [key2, map3] of map2) {
|
|
2657
|
-
const inner = [...map3].map(([key3, v]) => `${key3} => ${v}`).join(", ");
|
|
2658
|
-
entries.push(`${key1} => ${key2} => { ${inner} }`);
|
|
3191
|
+
const inner = [...map3].map(([key3, v]) => `${formatValue(key3)} => ${formatValue(v)}`).join(", ");
|
|
3192
|
+
entries.push(`${formatValue(key1)} => ${formatValue(key2)} => { ${inner} }`);
|
|
2659
3193
|
}
|
|
2660
3194
|
}
|
|
2661
|
-
return
|
|
3195
|
+
return `Map3(${this.size}){ ${entries.join(", ")} }`.replaceAll(" ", " ");
|
|
2662
3196
|
}
|
|
2663
3197
|
};
|
|
2664
3198
|
|
|
@@ -2720,18 +3254,18 @@ var MultiContainer = class {
|
|
|
2720
3254
|
const entries = [];
|
|
2721
3255
|
for (const keys of this.keys()) {
|
|
2722
3256
|
const arr = this.getAll(...keys);
|
|
2723
|
-
const keyStr = Array.isArray(keys) ?
|
|
2724
|
-
const valuesStr = Array.isArray(arr) ?
|
|
3257
|
+
const keyStr = Array.isArray(keys) ? formatValue(keys) : "[ ]";
|
|
3258
|
+
const valuesStr = Array.isArray(arr) ? formatValue(arr) : "[ ]";
|
|
2725
3259
|
entries.push(`${keyStr} => ${valuesStr}`);
|
|
2726
3260
|
}
|
|
2727
|
-
return `MultiContainer{ ${entries.join(", ")} }
|
|
3261
|
+
return `MultiContainer{ ${entries.join(", ")} }`.replaceAll(" ", " ");
|
|
2728
3262
|
}
|
|
2729
3263
|
};
|
|
2730
3264
|
function asMulti(base) {
|
|
2731
3265
|
return new MultiContainer(base);
|
|
2732
3266
|
}
|
|
2733
3267
|
|
|
2734
|
-
// src/
|
|
3268
|
+
// src/deprecated/vec2.ts
|
|
2735
3269
|
var Vec2 = class _Vec2 {
|
|
2736
3270
|
constructor(x, y) {
|
|
2737
3271
|
__publicField(this, "x");
|
|
@@ -2756,7 +3290,7 @@ var Vec2 = class _Vec2 {
|
|
|
2756
3290
|
}
|
|
2757
3291
|
};
|
|
2758
3292
|
|
|
2759
|
-
// src/
|
|
3293
|
+
// src/deprecated/small-int-cache.ts
|
|
2760
3294
|
var SmallIntCache = class {
|
|
2761
3295
|
// for keys < 0
|
|
2762
3296
|
constructor() {
|
|
@@ -2767,7 +3301,7 @@ var SmallIntCache = class {
|
|
|
2767
3301
|
this.neg = [];
|
|
2768
3302
|
}
|
|
2769
3303
|
set(key, value) {
|
|
2770
|
-
if (!isInteger(key)) {
|
|
3304
|
+
if (!guard_exports.isInteger(key)) {
|
|
2771
3305
|
throw new Error("Key must be an integer");
|
|
2772
3306
|
} else if (key >= 0) {
|
|
2773
3307
|
this.pos[key] = value;
|
|
@@ -2776,7 +3310,7 @@ var SmallIntCache = class {
|
|
|
2776
3310
|
}
|
|
2777
3311
|
}
|
|
2778
3312
|
get(key) {
|
|
2779
|
-
if (!isInteger(key)) {
|
|
3313
|
+
if (!guard_exports.isInteger(key)) {
|
|
2780
3314
|
throw new Error("Key must be an integer");
|
|
2781
3315
|
} else if (key >= 0) {
|
|
2782
3316
|
return this.pos[key];
|
|
@@ -2785,7 +3319,7 @@ var SmallIntCache = class {
|
|
|
2785
3319
|
}
|
|
2786
3320
|
}
|
|
2787
3321
|
has(key) {
|
|
2788
|
-
if (!isInteger(key)) {
|
|
3322
|
+
if (!guard_exports.isInteger(key)) {
|
|
2789
3323
|
return false;
|
|
2790
3324
|
} else if (key >= 0) {
|
|
2791
3325
|
return key in this.pos;
|
|
@@ -2794,7 +3328,7 @@ var SmallIntCache = class {
|
|
|
2794
3328
|
}
|
|
2795
3329
|
}
|
|
2796
3330
|
delete(key) {
|
|
2797
|
-
if (!isInteger(key)) {
|
|
3331
|
+
if (!guard_exports.isInteger(key)) {
|
|
2798
3332
|
return;
|
|
2799
3333
|
} else if (key >= 0) {
|
|
2800
3334
|
delete this.pos[key];
|
|
@@ -2813,6 +3347,7 @@ var SmallIntCache = class {
|
|
|
2813
3347
|
Cookies,
|
|
2814
3348
|
Device,
|
|
2815
3349
|
DivRect,
|
|
3350
|
+
Guard,
|
|
2816
3351
|
IndexArray,
|
|
2817
3352
|
LRUCache,
|
|
2818
3353
|
Map1,
|