@magmacomputing/tempo-plugin-geo 0.1.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -2
- package/README.md +112 -17
- package/dist/index.d.ts +51 -18
- package/dist/index.global.min.js +1 -1
- package/dist/index.js +1429 -333
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -257,31 +257,55 @@ var init_type_library = __esm({
|
|
|
257
257
|
});
|
|
258
258
|
|
|
259
259
|
// ../../library/dist/common/primitives/assertion.library.js
|
|
260
|
-
|
|
260
|
+
function isNumeric(str) {
|
|
261
|
+
const type = typeof str;
|
|
262
|
+
switch (type) {
|
|
263
|
+
case "number":
|
|
264
|
+
return Number.isFinite(str);
|
|
265
|
+
case "bigint":
|
|
266
|
+
return true;
|
|
267
|
+
case "string": {
|
|
268
|
+
const val = str.trim();
|
|
269
|
+
if (val.length === 0)
|
|
270
|
+
return false;
|
|
271
|
+
return RE_BIGINT_LITERAL.test(val) || isNumber(Number(val));
|
|
272
|
+
}
|
|
273
|
+
default:
|
|
274
|
+
return false;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
var isType, isPrimitive, isReference, isIterable, isString, isText, isNumber, RE_BIGINT_LITERAL, isInteger, isArray, isArrayLike, isObject, isDate, isRegExp, isSymbol, isSymbolFor, isSafeKey, isNullish, isUndefined, isDefined, isFunction, isCallable, isMap, isSet, isError, isLocale, isEmpty;
|
|
261
278
|
var init_assertion_library = __esm({
|
|
262
279
|
"../../library/dist/common/primitives/assertion.library.js"() {
|
|
263
280
|
"use strict";
|
|
264
281
|
init_symbol_library();
|
|
265
282
|
init_type_library();
|
|
266
283
|
isType = (obj, ...types) => types.includes(getType(obj));
|
|
267
|
-
isPrimitive = (obj) =>
|
|
284
|
+
isPrimitive = (obj) => obj === null || typeof obj !== "object" && typeof obj !== "function";
|
|
268
285
|
isReference = (obj) => !isPrimitive(obj);
|
|
269
|
-
|
|
286
|
+
isIterable = (obj) => Symbol.iterator in Object(obj) && !isString(obj);
|
|
287
|
+
isString = (obj) => typeof obj === "string";
|
|
288
|
+
isText = (obj) => typeof obj === "string" && obj.trim().length > 0;
|
|
270
289
|
isNumber = (obj) => Number.isFinite(obj);
|
|
271
|
-
|
|
272
|
-
|
|
290
|
+
RE_BIGINT_LITERAL = /^[+-]?[0-9]+n$/;
|
|
291
|
+
isInteger = (obj) => typeof obj === "bigint";
|
|
292
|
+
isArray = (obj) => Array.isArray(obj);
|
|
293
|
+
isArrayLike = (obj) => protoType(obj) === "Object" && "length" in obj && Object.keys(obj).every((key) => key === "length" || isNumber(Number(key)));
|
|
273
294
|
isObject = (obj) => isType(obj, "Object");
|
|
274
295
|
isDate = (obj) => isType(obj, "Date");
|
|
275
|
-
|
|
276
|
-
|
|
296
|
+
isRegExp = (obj) => isType(obj, "RegExp");
|
|
297
|
+
isSymbol = (obj) => typeof obj === "symbol";
|
|
298
|
+
isSymbolFor = (obj) => typeof obj === "symbol" && Symbol.keyFor(obj) !== void 0;
|
|
277
299
|
isSafeKey = (key) => key !== "__proto__" && key !== "constructor" && key !== "prototype";
|
|
278
|
-
isNullish = (obj) => isType(obj, "
|
|
279
|
-
isUndefined = (obj) => isType(obj, "
|
|
280
|
-
isDefined = (obj) => !isNullish(obj);
|
|
300
|
+
isNullish = (obj) => obj === null || obj === void 0 || isType(obj, "Void", "Empty");
|
|
301
|
+
isUndefined = (obj) => obj === void 0 || isType(obj, "Void", "Empty");
|
|
302
|
+
isDefined = (obj) => obj !== null && obj !== void 0 && !isNullish(obj);
|
|
281
303
|
isFunction = (obj) => isType(obj, "Function", "AsyncFunction", "GeneratorFunction", "AsyncGeneratorFunction");
|
|
304
|
+
isCallable = (obj) => typeof obj === "function";
|
|
282
305
|
isMap = (obj) => isType(obj, "Map");
|
|
283
306
|
isSet = (obj) => isType(obj, "Set");
|
|
284
307
|
isError = (err, constructor) => isType(err, "Error") && (constructor ? err instanceof constructor : true);
|
|
308
|
+
isLocale = (obj) => typeof Intl !== "undefined" && typeof Intl.Locale === "function" && obj instanceof Intl.Locale;
|
|
285
309
|
isEmpty = (obj) => isNullish(obj) || isObject(obj) && Reflect.ownKeys(obj).length === 0 || isString(obj) && obj.trim().length === 0 || typeof obj === "number" && Number.isNaN(obj) || isArray(obj) && obj.length === 0 || isSet(obj) && obj.size === 0 || isMap(obj) && obj.size === 0 || ArrayBuffer.isView(obj) && obj.byteLength === 0 || isDate(obj) && Number.isNaN(obj.getTime());
|
|
286
310
|
}
|
|
287
311
|
});
|
|
@@ -340,37 +364,6 @@ var init_utility_library = __esm({
|
|
|
340
364
|
}
|
|
341
365
|
});
|
|
342
366
|
|
|
343
|
-
// ../../library/dist/common/primitives/object.library.js
|
|
344
|
-
function looseIndex(arg) {
|
|
345
|
-
if (isDefined(arg))
|
|
346
|
-
return isFunction(arg) ? arg() : arg;
|
|
347
|
-
return (obj) => isFunction(obj) ? obj() : obj;
|
|
348
|
-
}
|
|
349
|
-
var asObject;
|
|
350
|
-
var init_object_library = __esm({
|
|
351
|
-
"../../library/dist/common/primitives/object.library.js"() {
|
|
352
|
-
"use strict";
|
|
353
|
-
init_primitive_library();
|
|
354
|
-
init_assertion_library();
|
|
355
|
-
init_type_library();
|
|
356
|
-
asObject = (obj) => {
|
|
357
|
-
if (isNullish(obj) || !isObject(obj))
|
|
358
|
-
return obj;
|
|
359
|
-
const temp = isArray(obj) ? [] : {};
|
|
360
|
-
ownKeys(obj).forEach((key) => {
|
|
361
|
-
if (!isSafeKey(key))
|
|
362
|
-
return;
|
|
363
|
-
temp[key] = asObject(obj[key]);
|
|
364
|
-
});
|
|
365
|
-
return temp;
|
|
366
|
-
};
|
|
367
|
-
looseIndex.stringSymbol = looseIndex();
|
|
368
|
-
looseIndex.symbolRegExp = looseIndex();
|
|
369
|
-
looseIndex.symbolString = looseIndex();
|
|
370
|
-
looseIndex.stringString = looseIndex();
|
|
371
|
-
}
|
|
372
|
-
});
|
|
373
|
-
|
|
374
367
|
// ../../library/dist/common/runtime/reflection.library.js
|
|
375
368
|
function allObject(json) {
|
|
376
369
|
return Object.fromEntries(ownEntries(json, true));
|
|
@@ -544,6 +537,8 @@ function serialize(val, seen = /* @__PURE__ */ new WeakSet()) {
|
|
|
544
537
|
if (seen.has(value2))
|
|
545
538
|
return "<Circular>";
|
|
546
539
|
seen.add(value2);
|
|
540
|
+
if (isLocale(value2))
|
|
541
|
+
return value2.toString();
|
|
547
542
|
if (isMap(value2))
|
|
548
543
|
return `map:[${Array.from(value2.entries()).map((e) => serialize(e, seen)).sort().join(",")}]`;
|
|
549
544
|
if (isSet(value2))
|
|
@@ -600,15 +595,86 @@ var init_function_library = __esm({
|
|
|
600
595
|
});
|
|
601
596
|
|
|
602
597
|
// ../../library/dist/common/runtime/json.library.js
|
|
598
|
+
function cleanify(obj) {
|
|
599
|
+
try {
|
|
600
|
+
return JSON.parse(JSON.stringify(obj));
|
|
601
|
+
} catch (error) {
|
|
602
|
+
console.warn("Could not clean object:", error?.message ?? error);
|
|
603
|
+
throw error;
|
|
604
|
+
}
|
|
605
|
+
}
|
|
603
606
|
var init_json_library = __esm({
|
|
604
607
|
"../../library/dist/common/runtime/json.library.js"() {
|
|
605
608
|
"use strict";
|
|
609
|
+
init_assertion_library();
|
|
610
|
+
}
|
|
611
|
+
});
|
|
612
|
+
|
|
613
|
+
// ../../library/dist/common/primitives/object.library.js
|
|
614
|
+
function looseIndex(arg) {
|
|
615
|
+
if (isDefined(arg))
|
|
616
|
+
return isFunction(arg) ? arg() : arg;
|
|
617
|
+
return (obj) => isFunction(obj) ? obj() : obj;
|
|
618
|
+
}
|
|
619
|
+
var getObjectKeys, asObject;
|
|
620
|
+
var init_object_library = __esm({
|
|
621
|
+
"../../library/dist/common/primitives/object.library.js"() {
|
|
622
|
+
"use strict";
|
|
623
|
+
init_primitive_library();
|
|
624
|
+
init_assertion_library();
|
|
625
|
+
init_type_library();
|
|
626
|
+
getObjectKeys = (obj) => {
|
|
627
|
+
const keys = /* @__PURE__ */ new Set();
|
|
628
|
+
let curr = obj;
|
|
629
|
+
let depth = 0;
|
|
630
|
+
while (curr && curr !== Object.prototype && depth++ < 10) {
|
|
631
|
+
const descs = Object.getOwnPropertyDescriptors(curr);
|
|
632
|
+
for (const [key, desc] of Object.entries(descs)) {
|
|
633
|
+
if (!isSafeKey(key))
|
|
634
|
+
continue;
|
|
635
|
+
if (desc.enumerable || isFunction(desc.get)) {
|
|
636
|
+
keys.add(key);
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
curr = Object.getPrototypeOf(curr);
|
|
640
|
+
}
|
|
641
|
+
return Array.from(keys);
|
|
642
|
+
};
|
|
643
|
+
asObject = (obj) => {
|
|
644
|
+
if (isPrimitive(obj) || isFunction(obj))
|
|
645
|
+
return obj;
|
|
646
|
+
if (isArray(obj))
|
|
647
|
+
return obj.map((item) => asObject(item));
|
|
648
|
+
if (isDate(obj) || isRegExp(obj) || isMap(obj) || isSet(obj))
|
|
649
|
+
return obj;
|
|
650
|
+
try {
|
|
651
|
+
if (isFunction(obj.toJSON))
|
|
652
|
+
return asObject(obj.toJSON());
|
|
653
|
+
} catch {
|
|
654
|
+
}
|
|
655
|
+
const temp = {};
|
|
656
|
+
for (const key of getObjectKeys(obj)) {
|
|
657
|
+
try {
|
|
658
|
+
temp[key] = asObject(obj[key]);
|
|
659
|
+
} catch {
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
return temp;
|
|
663
|
+
};
|
|
664
|
+
looseIndex.stringSymbol = looseIndex();
|
|
665
|
+
looseIndex.symbolRegExp = looseIndex();
|
|
666
|
+
looseIndex.symbolString = looseIndex();
|
|
667
|
+
looseIndex.stringString = looseIndex();
|
|
606
668
|
}
|
|
607
669
|
});
|
|
608
670
|
|
|
609
671
|
// ../../library/dist/common/runtime/serialize.library.js
|
|
610
|
-
function
|
|
611
|
-
|
|
672
|
+
function clone(obj, opts) {
|
|
673
|
+
try {
|
|
674
|
+
return globalThis.structuredClone(obj, opts);
|
|
675
|
+
} catch {
|
|
676
|
+
return cleanify(obj);
|
|
677
|
+
}
|
|
612
678
|
}
|
|
613
679
|
function reviver(_key, val) {
|
|
614
680
|
return decode(val);
|
|
@@ -654,19 +720,34 @@ function toSymbol(value2) {
|
|
|
654
720
|
return Symbol(desc);
|
|
655
721
|
}
|
|
656
722
|
}
|
|
657
|
-
function stringify(obj) {
|
|
658
|
-
|
|
723
|
+
function stringify(obj, options) {
|
|
724
|
+
const prevCompact = activeCompact;
|
|
725
|
+
activeCompact = options?.compact !== false;
|
|
726
|
+
try {
|
|
727
|
+
const str = stringize(obj, false);
|
|
728
|
+
if (options?.signed) {
|
|
729
|
+
if (!isString(options.secret) || !options.secret)
|
|
730
|
+
throw new TypeError("stringify: signed serialization requires an explicit secret string");
|
|
731
|
+
return `$sig:${fastDigest(str, options.secret)}:${str}`;
|
|
732
|
+
}
|
|
733
|
+
return str;
|
|
734
|
+
} finally {
|
|
735
|
+
activeCompact = prevCompact;
|
|
736
|
+
}
|
|
659
737
|
}
|
|
660
738
|
function stringize(obj, recurse = true) {
|
|
661
739
|
const arg = asType(obj);
|
|
662
740
|
const one = curry(oneKey)(arg.type);
|
|
663
741
|
switch (arg.type) {
|
|
664
|
-
case "String":
|
|
742
|
+
case "String": {
|
|
743
|
+
let strVal = arg.value;
|
|
744
|
+
if (strVal.startsWith("~"))
|
|
745
|
+
strVal = `~${strVal}`;
|
|
665
746
|
if (!recurse) {
|
|
666
|
-
recurse =
|
|
747
|
+
recurse = strVal === "true" || strVal === "false" || strVal === "null" || parseFloat(strVal).toString() === strVal || strVal.startsWith("~");
|
|
667
748
|
}
|
|
668
|
-
return recurse ? JSON.stringify(encode(
|
|
669
|
-
|
|
749
|
+
return recurse ? JSON.stringify(encode(strVal)) : encode(strVal);
|
|
750
|
+
}
|
|
670
751
|
case "Boolean":
|
|
671
752
|
case "Null":
|
|
672
753
|
case "Number":
|
|
@@ -674,11 +755,13 @@ function stringize(obj, recurse = true) {
|
|
|
674
755
|
// JSON.stringify will correctly handle these
|
|
675
756
|
case "Void":
|
|
676
757
|
case "Undefined":
|
|
677
|
-
return one(JSON.stringify("void"));
|
|
758
|
+
return activeCompact ? JSON.stringify("~u") : one(JSON.stringify("void"));
|
|
678
759
|
// preserve 'undefined' values
|
|
679
760
|
case "BigInt":
|
|
680
|
-
return one(arg.value.toString());
|
|
761
|
+
return activeCompact ? JSON.stringify(`~n${arg.value.toString()}`) : one(arg.value.toString());
|
|
681
762
|
// even though BigInt has a toString method, it is not supported in JSON.stringify
|
|
763
|
+
case "Date":
|
|
764
|
+
return activeCompact ? JSON.stringify(`~t${arg.value.getTime()}`) : one(stringize(arg.value.toJSON()));
|
|
682
765
|
case "Object": {
|
|
683
766
|
const obj2 = ownEntries(arg.value).filter(([, val]) => isStringable(val)).map(([key, val]) => `${fromSymbol(key)}: ${stringize(val)}`).join(",");
|
|
684
767
|
return `{${obj2}}`;
|
|
@@ -695,8 +778,10 @@ function stringize(obj, recurse = true) {
|
|
|
695
778
|
const set = Array.from(arg.value.values()).filter((val) => isStringable(val)).map((val) => stringize(val)).join(",");
|
|
696
779
|
return one(`[${set}]`);
|
|
697
780
|
}
|
|
698
|
-
case "Symbol":
|
|
699
|
-
|
|
781
|
+
case "Symbol": {
|
|
782
|
+
const symStr = `${isSymbolFor(arg.value) ? "@" : ""}@(${arg.value.description ?? ""})`;
|
|
783
|
+
return activeCompact ? JSON.stringify(`~y${symStr}`) : one(JSON.stringify(symStr));
|
|
784
|
+
}
|
|
700
785
|
case "RegExp":
|
|
701
786
|
return one(stringize({ source: arg.value.source, flags: arg.value.flags }));
|
|
702
787
|
case "Class":
|
|
@@ -707,21 +792,55 @@ function stringize(obj, recurse = true) {
|
|
|
707
792
|
return void 0;
|
|
708
793
|
case isFunction(value2.toJSON):
|
|
709
794
|
return one(stringize(value2.toJSON()));
|
|
710
|
-
case isFunction(value2.toString): {
|
|
795
|
+
case (isFunction(value2.toString) && value2.toString !== Object.prototype.toString): {
|
|
711
796
|
const str = value2.toString();
|
|
712
797
|
return one(str.includes('"') ? str : JSON.stringify(str));
|
|
713
798
|
}
|
|
714
|
-
case isFunction(value2.valueOf):
|
|
799
|
+
case (isFunction(value2.valueOf) && value2.valueOf !== Object.prototype.valueOf):
|
|
715
800
|
return one(JSON.stringify(value2.valueOf()));
|
|
716
|
-
default:
|
|
717
|
-
|
|
801
|
+
default: {
|
|
802
|
+
const plain = asObject(value2);
|
|
803
|
+
return isReference(plain) && Object.keys(plain).length > 0 ? stringize(plain) : one(JSON.stringify(value2, (key, o) => isEmpty(key) ? o : stringize(o)));
|
|
804
|
+
}
|
|
718
805
|
}
|
|
719
806
|
}
|
|
720
807
|
}
|
|
721
808
|
}
|
|
722
|
-
function objectify(str,
|
|
809
|
+
function objectify(str, optionsOrSentinel) {
|
|
723
810
|
if (!isString(str))
|
|
724
811
|
return str;
|
|
812
|
+
const options = isFunction(optionsOrSentinel) ? { sentinel: optionsOrSentinel } : optionsOrSentinel ?? {};
|
|
813
|
+
if (str.startsWith("$sig:")) {
|
|
814
|
+
const secondColon = str.indexOf(":", 5);
|
|
815
|
+
if (secondColon !== -1) {
|
|
816
|
+
const sig = str.substring(5, secondColon);
|
|
817
|
+
const payload = str.substring(secondColon + 1);
|
|
818
|
+
if (!isString(options.secret) || !options.secret) {
|
|
819
|
+
console.warn("objectify: signature verification requires an explicit secret string");
|
|
820
|
+
if (options.throwOnError)
|
|
821
|
+
throw new TypeError("objectify: signature verification requires an explicit secret string");
|
|
822
|
+
return str;
|
|
823
|
+
}
|
|
824
|
+
const expectedSig = fastDigest(payload, options.secret);
|
|
825
|
+
if (!constantTimeEqual(sig, expectedSig)) {
|
|
826
|
+
console.warn("objectify: signature verification failed");
|
|
827
|
+
if (options.throwOnError)
|
|
828
|
+
throw new Error("objectify: signature verification failed");
|
|
829
|
+
return str;
|
|
830
|
+
}
|
|
831
|
+
str = payload;
|
|
832
|
+
} else if (options.requireSigned) {
|
|
833
|
+
console.warn("objectify: malformed signed payload");
|
|
834
|
+
if (options.throwOnError)
|
|
835
|
+
throw new Error("objectify: malformed signed payload");
|
|
836
|
+
return str;
|
|
837
|
+
}
|
|
838
|
+
} else if (options.requireSigned) {
|
|
839
|
+
console.warn("objectify: unsigned string rejected by requireSigned policy");
|
|
840
|
+
if (options.throwOnError)
|
|
841
|
+
throw new Error("objectify: unsigned string rejected by requireSigned policy");
|
|
842
|
+
return str;
|
|
843
|
+
}
|
|
725
844
|
let parse;
|
|
726
845
|
try {
|
|
727
846
|
parse = JSON.parse(str, reviver);
|
|
@@ -730,28 +849,50 @@ function objectify(str, sentinel) {
|
|
|
730
849
|
console.warn(`objectify.parse: -> ${str}, ${error.message}`);
|
|
731
850
|
return str;
|
|
732
851
|
} else
|
|
733
|
-
return objectify(`"${str}"`,
|
|
852
|
+
return objectify(`"${str}"`, options.requireSigned ? { ...options, requireSigned: false } : options);
|
|
734
853
|
}
|
|
735
854
|
switch (true) {
|
|
736
855
|
case (str.startsWith("{") && str.endsWith("}")):
|
|
737
856
|
// looks like Object
|
|
738
857
|
case (str.startsWith("[") && str.endsWith("]")):
|
|
739
|
-
return traverse(parse,
|
|
858
|
+
return traverse(parse, options, 0);
|
|
740
859
|
// recurse into object
|
|
741
860
|
default:
|
|
742
|
-
return parse;
|
|
861
|
+
return typeify(parse, options);
|
|
743
862
|
}
|
|
744
863
|
}
|
|
745
|
-
function traverse(obj,
|
|
864
|
+
function traverse(obj, options, depth = 0) {
|
|
865
|
+
const maxDepth = options.maxDepth ?? MAX_TRAVERSE_DEPTH;
|
|
866
|
+
if (depth >= maxDepth)
|
|
867
|
+
return obj;
|
|
746
868
|
if (isObject(obj)) {
|
|
747
|
-
return typeify(ownEntries(obj).reduce((acc, [key, val]) => Object.assign(acc, { [toSymbol(key)]: typeify(traverse(val,
|
|
869
|
+
return typeify(ownEntries(obj).filter(([key]) => isSafeKey(key)).reduce((acc, [key, val]) => Object.assign(acc, { [toSymbol(key)]: typeify(traverse(val, options, depth + 1), options) }), {}), options);
|
|
748
870
|
}
|
|
749
871
|
if (isArray(obj)) {
|
|
750
|
-
return ownValues(obj).map((val) => typeify(traverse(val,
|
|
872
|
+
return ownValues(obj).map((val) => typeify(traverse(val, options, depth + 1), options));
|
|
751
873
|
}
|
|
752
|
-
return obj;
|
|
874
|
+
return typeify(obj, options);
|
|
753
875
|
}
|
|
754
|
-
function typeify(json,
|
|
876
|
+
function typeify(json, options) {
|
|
877
|
+
if (isString(json) && json.startsWith("~")) {
|
|
878
|
+
try {
|
|
879
|
+
if (json.startsWith("~~"))
|
|
880
|
+
return json.substring(1);
|
|
881
|
+
if (json.startsWith("~n"))
|
|
882
|
+
return BigInt(json.substring(2));
|
|
883
|
+
if (json.startsWith("~t")) {
|
|
884
|
+
const timeVal = json.substring(2);
|
|
885
|
+
const d = new Date(isNumeric(timeVal) ? Number(timeVal) : timeVal);
|
|
886
|
+
return isNaN(d.getTime()) ? json : d;
|
|
887
|
+
}
|
|
888
|
+
if (json === "~u")
|
|
889
|
+
return options.sentinel?.();
|
|
890
|
+
if (json.startsWith("~y"))
|
|
891
|
+
return toSymbol(json.substring(2));
|
|
892
|
+
} catch {
|
|
893
|
+
return json;
|
|
894
|
+
}
|
|
895
|
+
}
|
|
755
896
|
if (!isObject(json) || ownKeys(json).length !== 1)
|
|
756
897
|
return json;
|
|
757
898
|
const [$type, value2] = ownEntries(json)[0];
|
|
@@ -775,12 +916,14 @@ function typeify(json, sentinel) {
|
|
|
775
916
|
case "Undefined":
|
|
776
917
|
case "Empty":
|
|
777
918
|
case "Void":
|
|
778
|
-
return sentinel?.();
|
|
919
|
+
return options.sentinel?.();
|
|
779
920
|
// run Sentinel function to handle undefined values
|
|
780
921
|
case "Date":
|
|
781
922
|
return new Date(value2);
|
|
782
923
|
case "RegExp":
|
|
783
|
-
if (
|
|
924
|
+
if (options.allowRegExp === false)
|
|
925
|
+
return json;
|
|
926
|
+
if (!isObject(value2) || !isString(value2.source) || value2.source.length > MAX_REGEXP_SOURCE_LENGTH)
|
|
784
927
|
return json;
|
|
785
928
|
return new RegExp(value2.source, value2.flags);
|
|
786
929
|
case "Symbol":
|
|
@@ -793,25 +936,34 @@ function typeify(json, sentinel) {
|
|
|
793
936
|
if (!isArray(value2))
|
|
794
937
|
return json;
|
|
795
938
|
return new Set(value2);
|
|
796
|
-
default:
|
|
939
|
+
default: {
|
|
940
|
+
if (options.allowClasses === false)
|
|
941
|
+
return json;
|
|
942
|
+
if (options.allowedClasses) {
|
|
943
|
+
const allowed = options.allowedClasses instanceof Set ? options.allowedClasses.has($type) || options.allowedClasses.has(type) : options.allowedClasses.includes($type) || options.allowedClasses.includes(type);
|
|
944
|
+
if (!allowed)
|
|
945
|
+
return json;
|
|
946
|
+
}
|
|
797
947
|
const cls = Registry.get($type);
|
|
798
948
|
if (!cls) {
|
|
799
949
|
console.warn(`objectify: dont know how to deserialize '${type}'`);
|
|
800
950
|
return json;
|
|
801
951
|
}
|
|
802
952
|
return Reflect.construct(cls, [value2]);
|
|
953
|
+
}
|
|
803
954
|
}
|
|
804
955
|
} catch {
|
|
805
956
|
return json;
|
|
806
957
|
}
|
|
807
958
|
}
|
|
808
|
-
var Registry, getSafeTag2, registerSerializable, SAFE_URI_MAP, RE_SAFE_URI_CODES, symKey;
|
|
959
|
+
var Registry, getSafeTag2, registerSerializable, SAFE_URI_MAP, RE_SAFE_URI_CODES, symKey, RUNTIME_SALT, fastDigest, constantTimeEqual, activeCompact, MAX_TRAVERSE_DEPTH, MAX_REGEXP_SOURCE_LENGTH;
|
|
809
960
|
var init_serialize_library = __esm({
|
|
810
961
|
"../../library/dist/common/runtime/serialize.library.js"() {
|
|
811
962
|
"use strict";
|
|
812
963
|
init_function_library();
|
|
813
964
|
init_primitive_library();
|
|
814
965
|
init_json_library();
|
|
966
|
+
init_object_library();
|
|
815
967
|
init_type_library();
|
|
816
968
|
init_assertion_library();
|
|
817
969
|
init_symbol_library();
|
|
@@ -854,6 +1006,582 @@ var init_serialize_library = __esm({
|
|
|
854
1006
|
};
|
|
855
1007
|
RE_SAFE_URI_CODES = new RegExp(Object.keys(SAFE_URI_MAP).join("|"), "gi");
|
|
856
1008
|
symKey = /^@(@)?\(([^\)]*)\)$/;
|
|
1009
|
+
RUNTIME_SALT = globalThis.crypto?.randomUUID ? globalThis.crypto.randomUUID().split("-")[0] : Math.random().toString(36).slice(2, 10);
|
|
1010
|
+
fastDigest = (str, secret = RUNTIME_SALT) => {
|
|
1011
|
+
let h1 = 2166136261;
|
|
1012
|
+
let h2 = 2654435769;
|
|
1013
|
+
const input = `${secret}:${str}`;
|
|
1014
|
+
for (let i = 0; i < input.length; i++) {
|
|
1015
|
+
const c = input.charCodeAt(i);
|
|
1016
|
+
h1 = Math.imul(h1 ^ c, 16777619);
|
|
1017
|
+
h2 = Math.imul(h2 ^ c, 2246822507);
|
|
1018
|
+
}
|
|
1019
|
+
return (h1 >>> 0).toString(16).padStart(8, "0") + (h2 >>> 0).toString(16).padStart(8, "0");
|
|
1020
|
+
};
|
|
1021
|
+
constantTimeEqual = (a, b) => {
|
|
1022
|
+
if (!isString(a) || !isString(b))
|
|
1023
|
+
return false;
|
|
1024
|
+
if (a.length !== b.length)
|
|
1025
|
+
return false;
|
|
1026
|
+
let result = 0;
|
|
1027
|
+
for (let i = 0; i < a.length; i++)
|
|
1028
|
+
result |= a.charCodeAt(i) ^ b.charCodeAt(i);
|
|
1029
|
+
return result === 0;
|
|
1030
|
+
};
|
|
1031
|
+
activeCompact = true;
|
|
1032
|
+
MAX_TRAVERSE_DEPTH = 64;
|
|
1033
|
+
MAX_REGEXP_SOURCE_LENGTH = 512;
|
|
1034
|
+
}
|
|
1035
|
+
});
|
|
1036
|
+
|
|
1037
|
+
// ../../../node_modules/tslib/tslib.es6.mjs
|
|
1038
|
+
function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
1039
|
+
function accept(f) {
|
|
1040
|
+
if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected");
|
|
1041
|
+
return f;
|
|
1042
|
+
}
|
|
1043
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
1044
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
1045
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
1046
|
+
var _, done = false;
|
|
1047
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
1048
|
+
var context3 = {};
|
|
1049
|
+
for (var p in contextIn) context3[p] = p === "access" ? {} : contextIn[p];
|
|
1050
|
+
for (var p in contextIn.access) context3.access[p] = contextIn.access[p];
|
|
1051
|
+
context3.addInitializer = function(f) {
|
|
1052
|
+
if (done) throw new TypeError("Cannot add initializers after decoration has completed");
|
|
1053
|
+
extraInitializers.push(accept(f || null));
|
|
1054
|
+
};
|
|
1055
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context3);
|
|
1056
|
+
if (kind === "accessor") {
|
|
1057
|
+
if (result === void 0) continue;
|
|
1058
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
1059
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
1060
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
1061
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
1062
|
+
} else if (_ = accept(result)) {
|
|
1063
|
+
if (kind === "field") initializers.unshift(_);
|
|
1064
|
+
else descriptor[key] = _;
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
1067
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
1068
|
+
done = true;
|
|
1069
|
+
}
|
|
1070
|
+
function __runInitializers(thisArg, initializers, value2) {
|
|
1071
|
+
var useValue = arguments.length > 2;
|
|
1072
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
1073
|
+
value2 = useValue ? initializers[i].call(thisArg, value2) : initializers[i].call(thisArg);
|
|
1074
|
+
}
|
|
1075
|
+
return useValue ? value2 : void 0;
|
|
1076
|
+
}
|
|
1077
|
+
var init_tslib_es6 = __esm({
|
|
1078
|
+
"../../../node_modules/tslib/tslib.es6.mjs"() {
|
|
1079
|
+
"use strict";
|
|
1080
|
+
}
|
|
1081
|
+
});
|
|
1082
|
+
|
|
1083
|
+
// ../../library/dist/common/runtime/decorator.library.js
|
|
1084
|
+
function getClassName(value2, contextName) {
|
|
1085
|
+
return getSafeTag(value2) ?? (isUndefined(contextName) ? value2.name || void 0 : String(contextName));
|
|
1086
|
+
}
|
|
1087
|
+
function Serializable(value2, { kind, name, addInitializer }) {
|
|
1088
|
+
const finalName = getClassName(value2, name);
|
|
1089
|
+
if (finalName)
|
|
1090
|
+
registerType(value2, finalName);
|
|
1091
|
+
switch (kind) {
|
|
1092
|
+
case "class":
|
|
1093
|
+
if (finalName)
|
|
1094
|
+
addInitializer(() => registerSerializable(finalName, value2));
|
|
1095
|
+
return value2;
|
|
1096
|
+
default:
|
|
1097
|
+
throw new Error(`@Serializable decorating unknown 'kind': ${kind} (${name})`);
|
|
1098
|
+
}
|
|
1099
|
+
}
|
|
1100
|
+
function StringTag(tagOrValue, context3) {
|
|
1101
|
+
const applyTag = (value2, customTag, contextName) => {
|
|
1102
|
+
const proto = value2.prototype;
|
|
1103
|
+
const tagName = customTag ?? getClassName(value2, contextName);
|
|
1104
|
+
if (tagName) {
|
|
1105
|
+
if (proto && !Object.hasOwn(proto, Symbol.toStringTag)) {
|
|
1106
|
+
Object.defineProperty(proto, Symbol.toStringTag, {
|
|
1107
|
+
value: tagName,
|
|
1108
|
+
configurable: true,
|
|
1109
|
+
writable: false,
|
|
1110
|
+
enumerable: false
|
|
1111
|
+
});
|
|
1112
|
+
}
|
|
1113
|
+
if (!value2.name || value2.name !== tagName) {
|
|
1114
|
+
try {
|
|
1115
|
+
Object.defineProperty(value2, "name", {
|
|
1116
|
+
value: tagName,
|
|
1117
|
+
configurable: true,
|
|
1118
|
+
writable: false,
|
|
1119
|
+
enumerable: false
|
|
1120
|
+
});
|
|
1121
|
+
} catch {
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1124
|
+
}
|
|
1125
|
+
return value2;
|
|
1126
|
+
};
|
|
1127
|
+
if (isCallable(tagOrValue) && context3?.kind === "class")
|
|
1128
|
+
return applyTag(tagOrValue, void 0, context3.name);
|
|
1129
|
+
return (value2, ctx) => {
|
|
1130
|
+
return applyTag(value2, isString(tagOrValue) ? tagOrValue : void 0, ctx?.name);
|
|
1131
|
+
};
|
|
1132
|
+
}
|
|
1133
|
+
var init_decorator_library = __esm({
|
|
1134
|
+
"../../library/dist/common/runtime/decorator.library.js"() {
|
|
1135
|
+
"use strict";
|
|
1136
|
+
init_symbol_library();
|
|
1137
|
+
init_proxy_library();
|
|
1138
|
+
init_assertion_library();
|
|
1139
|
+
init_serialize_library();
|
|
1140
|
+
init_type_library();
|
|
1141
|
+
}
|
|
1142
|
+
});
|
|
1143
|
+
|
|
1144
|
+
// ../../library/dist/common/runtime/cache.class.js
|
|
1145
|
+
var BoundedCache;
|
|
1146
|
+
var init_cache_class = __esm({
|
|
1147
|
+
"../../library/dist/common/runtime/cache.class.js"() {
|
|
1148
|
+
"use strict";
|
|
1149
|
+
init_tslib_es6();
|
|
1150
|
+
init_assertion_library();
|
|
1151
|
+
init_decorator_library();
|
|
1152
|
+
BoundedCache = (() => {
|
|
1153
|
+
let _classDecorators = [StringTag("BoundedCache")];
|
|
1154
|
+
let _classDescriptor;
|
|
1155
|
+
let _classExtraInitializers = [];
|
|
1156
|
+
let _classThis;
|
|
1157
|
+
let _classSuper = Map;
|
|
1158
|
+
var BoundedCache2 = class extends _classSuper {
|
|
1159
|
+
static {
|
|
1160
|
+
_classThis = this;
|
|
1161
|
+
}
|
|
1162
|
+
static {
|
|
1163
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
1164
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
1165
|
+
BoundedCache2 = _classThis = _classDescriptor.value;
|
|
1166
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
1167
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
1168
|
+
}
|
|
1169
|
+
#expires = /* @__PURE__ */ new Map();
|
|
1170
|
+
#staticKeys = /* @__PURE__ */ new Set();
|
|
1171
|
+
#ttls = /* @__PURE__ */ new Map();
|
|
1172
|
+
maxSize;
|
|
1173
|
+
ttl;
|
|
1174
|
+
/**
|
|
1175
|
+
* Creates a bounded cache with configurable capacity and entry lifetime.
|
|
1176
|
+
*
|
|
1177
|
+
* @param maxSize - Maximum number of non-static entries retained
|
|
1178
|
+
* @param ttl - Default time-to-live for entries in milliseconds
|
|
1179
|
+
*/
|
|
1180
|
+
constructor(maxSize = 1e3, ttl = 24 * 60 * 60 * 1e3) {
|
|
1181
|
+
super();
|
|
1182
|
+
this.maxSize = maxSize;
|
|
1183
|
+
this.ttl = ttl;
|
|
1184
|
+
}
|
|
1185
|
+
/**
|
|
1186
|
+
* Returns true to identify this instance as a BoundedCache.
|
|
1187
|
+
*/
|
|
1188
|
+
get isBoundedCache() {
|
|
1189
|
+
return true;
|
|
1190
|
+
}
|
|
1191
|
+
/**
|
|
1192
|
+
* Determines whether a cache entry has passed its expiration deadline.
|
|
1193
|
+
*
|
|
1194
|
+
* @param key - Cache key to inspect
|
|
1195
|
+
* @returns True when the entry has expired, otherwise false
|
|
1196
|
+
*/
|
|
1197
|
+
#isExpired(key) {
|
|
1198
|
+
const deadline = this.#expires.get(key);
|
|
1199
|
+
if (deadline === void 0)
|
|
1200
|
+
return false;
|
|
1201
|
+
return Date.now() > deadline;
|
|
1202
|
+
}
|
|
1203
|
+
/**
|
|
1204
|
+
* Purges TTL-expired entries.
|
|
1205
|
+
*/
|
|
1206
|
+
evictExpired() {
|
|
1207
|
+
if (this.#expires.size === 0)
|
|
1208
|
+
return;
|
|
1209
|
+
const now = Date.now();
|
|
1210
|
+
for (const [key, deadline] of this.#expires.entries()) {
|
|
1211
|
+
if (now > deadline) {
|
|
1212
|
+
this.delete(key);
|
|
1213
|
+
}
|
|
1214
|
+
}
|
|
1215
|
+
}
|
|
1216
|
+
/**
|
|
1217
|
+
* Register an immortal static key (e.g. business glossary term).
|
|
1218
|
+
* Static keys bypass TTL expiration and LRU capacity eviction.
|
|
1219
|
+
*/
|
|
1220
|
+
setStatic(key, value2) {
|
|
1221
|
+
if (super.has(key))
|
|
1222
|
+
super.delete(key);
|
|
1223
|
+
super.set(key, value2);
|
|
1224
|
+
this.#staticKeys.add(key);
|
|
1225
|
+
this.#expires.delete(key);
|
|
1226
|
+
this.#ttls.delete(key);
|
|
1227
|
+
return this;
|
|
1228
|
+
}
|
|
1229
|
+
/**
|
|
1230
|
+
* Check if a key is a static key.
|
|
1231
|
+
*/
|
|
1232
|
+
isStatic(key) {
|
|
1233
|
+
return this.#staticKeys.has(key);
|
|
1234
|
+
}
|
|
1235
|
+
/**
|
|
1236
|
+
* Retrieves a value from the cache by key. Evaluates TTL expiration via `#expires`
|
|
1237
|
+
* specifically for the requested key, and updates LRU ordering by deleting and re-inserting
|
|
1238
|
+
* the key in the underlying Map. Leaves the expiration deadline unchanged.
|
|
1239
|
+
*
|
|
1240
|
+
* @param key - The cache key to retrieve
|
|
1241
|
+
* @returns The cached value, or undefined if not found or expired
|
|
1242
|
+
*/
|
|
1243
|
+
get(key) {
|
|
1244
|
+
if (this.#isExpired(key)) {
|
|
1245
|
+
this.delete(key);
|
|
1246
|
+
return void 0;
|
|
1247
|
+
}
|
|
1248
|
+
if (!super.has(key))
|
|
1249
|
+
return void 0;
|
|
1250
|
+
const val = super.get(key);
|
|
1251
|
+
super.delete(key);
|
|
1252
|
+
super.set(key, val);
|
|
1253
|
+
return val;
|
|
1254
|
+
}
|
|
1255
|
+
/**
|
|
1256
|
+
* Checks if a key exists in the cache and is not expired.
|
|
1257
|
+
* Automatically evicts expired entries on access.
|
|
1258
|
+
*
|
|
1259
|
+
* @param key - The cache key to check
|
|
1260
|
+
* @returns True if the key exists and is not expired, false otherwise
|
|
1261
|
+
*/
|
|
1262
|
+
has(key) {
|
|
1263
|
+
if (this.#isExpired(key)) {
|
|
1264
|
+
this.delete(key);
|
|
1265
|
+
return false;
|
|
1266
|
+
}
|
|
1267
|
+
return super.has(key);
|
|
1268
|
+
}
|
|
1269
|
+
/**
|
|
1270
|
+
* Returns the number of entries in the cache after evicting expired entries.
|
|
1271
|
+
*/
|
|
1272
|
+
get size() {
|
|
1273
|
+
this.evictExpired();
|
|
1274
|
+
return super.size;
|
|
1275
|
+
}
|
|
1276
|
+
/**
|
|
1277
|
+
* Executes a callback for each cache entry after evicting expired entries.
|
|
1278
|
+
*
|
|
1279
|
+
* @param callbackfn - Function to execute for each entry
|
|
1280
|
+
* @param thisArg - Optional value to use as `this` when executing the callback
|
|
1281
|
+
*/
|
|
1282
|
+
forEach(callbackfn, thisArg) {
|
|
1283
|
+
this.evictExpired();
|
|
1284
|
+
super.forEach(callbackfn, thisArg);
|
|
1285
|
+
}
|
|
1286
|
+
/**
|
|
1287
|
+
* Sets a key-value pair in the cache, enforcing LRU eviction.
|
|
1288
|
+
* If finite-TTL is configured, entries retain their original absolute expiration deadline
|
|
1289
|
+
* unless an explicit `ttl` override is passed.
|
|
1290
|
+
* If the cache exceeds maxSize, the oldest non-static entry is removed.
|
|
1291
|
+
*
|
|
1292
|
+
* @param key - The cache key to set
|
|
1293
|
+
* @param value - The value to store
|
|
1294
|
+
* @param ttl - Optional custom time-to-live in milliseconds for this specific entry
|
|
1295
|
+
* @returns This cache instance for chaining
|
|
1296
|
+
*/
|
|
1297
|
+
set(key, value2, ttl) {
|
|
1298
|
+
this.evictExpired();
|
|
1299
|
+
const existingDeadline = this.#expires.get(key);
|
|
1300
|
+
if (super.has(key))
|
|
1301
|
+
super.delete(key);
|
|
1302
|
+
super.set(key, value2);
|
|
1303
|
+
this.#staticKeys.delete(key);
|
|
1304
|
+
if (isDefined(ttl)) {
|
|
1305
|
+
if (ttl !== Infinity) {
|
|
1306
|
+
this.#expires.set(key, Date.now() + ttl);
|
|
1307
|
+
this.#ttls.set(key, ttl);
|
|
1308
|
+
} else {
|
|
1309
|
+
this.#expires.delete(key);
|
|
1310
|
+
this.#ttls.delete(key);
|
|
1311
|
+
}
|
|
1312
|
+
} else if (existingDeadline !== void 0) {
|
|
1313
|
+
this.#expires.set(key, existingDeadline);
|
|
1314
|
+
} else if (this.ttl !== Infinity) {
|
|
1315
|
+
this.#expires.set(key, Date.now() + this.ttl);
|
|
1316
|
+
this.#ttls.delete(key);
|
|
1317
|
+
} else {
|
|
1318
|
+
this.#expires.delete(key);
|
|
1319
|
+
this.#ttls.delete(key);
|
|
1320
|
+
}
|
|
1321
|
+
while (this.size - this.#staticKeys.size > this.maxSize) {
|
|
1322
|
+
let evicted = false;
|
|
1323
|
+
const keysIter = super.keys();
|
|
1324
|
+
let res = keysIter.next();
|
|
1325
|
+
while (!res.done) {
|
|
1326
|
+
const k = res.value;
|
|
1327
|
+
if (!this.#staticKeys.has(k)) {
|
|
1328
|
+
this.delete(k);
|
|
1329
|
+
evicted = true;
|
|
1330
|
+
break;
|
|
1331
|
+
}
|
|
1332
|
+
res = keysIter.next();
|
|
1333
|
+
}
|
|
1334
|
+
if (!evicted)
|
|
1335
|
+
break;
|
|
1336
|
+
}
|
|
1337
|
+
return this;
|
|
1338
|
+
}
|
|
1339
|
+
/**
|
|
1340
|
+
* Deletes a key from the cache, removing its expiration and static key markers.
|
|
1341
|
+
*
|
|
1342
|
+
* @param key - The cache key to delete
|
|
1343
|
+
* @returns True if the key was deleted, false if it did not exist
|
|
1344
|
+
*/
|
|
1345
|
+
delete(key) {
|
|
1346
|
+
this.#staticKeys.delete(key);
|
|
1347
|
+
this.#expires.delete(key);
|
|
1348
|
+
this.#ttls.delete(key);
|
|
1349
|
+
return super.delete(key);
|
|
1350
|
+
}
|
|
1351
|
+
/**
|
|
1352
|
+
* Deletes all cache entries whose keys start with the specified prefix.
|
|
1353
|
+
* The prefix comparison is case-insensitive.
|
|
1354
|
+
*
|
|
1355
|
+
* @param prefix - The prefix string to match against cache keys
|
|
1356
|
+
* @returns The number of entries deleted
|
|
1357
|
+
*/
|
|
1358
|
+
deletePrefix(prefix) {
|
|
1359
|
+
const normalizedPrefix = String(prefix).trim().toLowerCase();
|
|
1360
|
+
if (isEmpty(normalizedPrefix))
|
|
1361
|
+
return 0;
|
|
1362
|
+
const toDelete = [];
|
|
1363
|
+
for (const key of super.keys()) {
|
|
1364
|
+
if (isString(key) && key.toLowerCase().startsWith(normalizedPrefix))
|
|
1365
|
+
toDelete.push(key);
|
|
1366
|
+
}
|
|
1367
|
+
for (const k of toDelete)
|
|
1368
|
+
this.delete(k);
|
|
1369
|
+
return toDelete.length;
|
|
1370
|
+
}
|
|
1371
|
+
/**
|
|
1372
|
+
* Purges cache entries.
|
|
1373
|
+
* If `count` is specified, evicts up to `count` oldest non-static entries.
|
|
1374
|
+
* If omitted, clears all entries, including static entries.
|
|
1375
|
+
*
|
|
1376
|
+
* @param count - Optional number of entries to evict. If omitted, clears all entries.
|
|
1377
|
+
*/
|
|
1378
|
+
clear(count) {
|
|
1379
|
+
if (count === void 0) {
|
|
1380
|
+
this.#staticKeys.clear();
|
|
1381
|
+
this.#expires.clear();
|
|
1382
|
+
this.#ttls.clear();
|
|
1383
|
+
super.clear();
|
|
1384
|
+
return;
|
|
1385
|
+
}
|
|
1386
|
+
let evicted = 0;
|
|
1387
|
+
for (const key of super.keys()) {
|
|
1388
|
+
if (evicted >= count)
|
|
1389
|
+
break;
|
|
1390
|
+
if (!this.#staticKeys.has(key)) {
|
|
1391
|
+
this.delete(key);
|
|
1392
|
+
evicted++;
|
|
1393
|
+
}
|
|
1394
|
+
}
|
|
1395
|
+
}
|
|
1396
|
+
/**
|
|
1397
|
+
* Returns an iterator of cache keys after evicting expired entries.
|
|
1398
|
+
*
|
|
1399
|
+
* @returns Iterator of cache keys
|
|
1400
|
+
*/
|
|
1401
|
+
keys() {
|
|
1402
|
+
this.evictExpired();
|
|
1403
|
+
return super.keys();
|
|
1404
|
+
}
|
|
1405
|
+
/**
|
|
1406
|
+
* Returns an iterator of cache values after evicting expired entries.
|
|
1407
|
+
*
|
|
1408
|
+
* @returns Iterator of cache values
|
|
1409
|
+
*/
|
|
1410
|
+
values() {
|
|
1411
|
+
this.evictExpired();
|
|
1412
|
+
return super.values();
|
|
1413
|
+
}
|
|
1414
|
+
/**
|
|
1415
|
+
* Returns an iterator of cache entries after evicting expired entries.
|
|
1416
|
+
*
|
|
1417
|
+
* @returns Iterator of [key, value] pairs
|
|
1418
|
+
*/
|
|
1419
|
+
entries() {
|
|
1420
|
+
this.evictExpired();
|
|
1421
|
+
return super.entries();
|
|
1422
|
+
}
|
|
1423
|
+
/**
|
|
1424
|
+
* Returns an iterator of cache entries after evicting expired entries, making the cache iterable.
|
|
1425
|
+
*
|
|
1426
|
+
* @returns Iterator of [key, value] pairs
|
|
1427
|
+
*/
|
|
1428
|
+
[Symbol.iterator]() {
|
|
1429
|
+
this.evictExpired();
|
|
1430
|
+
return super[Symbol.iterator]();
|
|
1431
|
+
}
|
|
1432
|
+
/**
|
|
1433
|
+
* Returns a plain key-value object of all active non-expired cache entries.
|
|
1434
|
+
* Filters out non-string keys to prevent lossy key conversions or collisions (e.g. numeric 1 vs string "1").
|
|
1435
|
+
*/
|
|
1436
|
+
toJSON() {
|
|
1437
|
+
this.evictExpired();
|
|
1438
|
+
const stringEntries = [];
|
|
1439
|
+
for (const [k, v] of super.entries()) {
|
|
1440
|
+
if (isString(k))
|
|
1441
|
+
stringEntries.push([k, v]);
|
|
1442
|
+
}
|
|
1443
|
+
return Object.fromEntries(stringEntries);
|
|
1444
|
+
}
|
|
1445
|
+
/**
|
|
1446
|
+
* Creates a BoundedCache from an iterable of key-value pairs.
|
|
1447
|
+
*
|
|
1448
|
+
* @param entries - Iterable of [key, value] pairs to populate the cache
|
|
1449
|
+
* @param maxSize - Maximum number of entries (default: 1000)
|
|
1450
|
+
* @param ttl - Time-to-live in milliseconds (default: 24 hours)
|
|
1451
|
+
* @returns A new BoundedCache instance
|
|
1452
|
+
*/
|
|
1453
|
+
static fromEntries(entries, maxSize = 1e3, ttl = 24 * 60 * 60 * 1e3) {
|
|
1454
|
+
const cache = new BoundedCache2(maxSize, ttl);
|
|
1455
|
+
for (const [k, v] of entries) {
|
|
1456
|
+
cache.set(k, v);
|
|
1457
|
+
}
|
|
1458
|
+
return cache;
|
|
1459
|
+
}
|
|
1460
|
+
};
|
|
1461
|
+
return BoundedCache2 = _classThis;
|
|
1462
|
+
})();
|
|
1463
|
+
}
|
|
1464
|
+
});
|
|
1465
|
+
|
|
1466
|
+
// ../../library/dist/common/runtime/storage.library.js
|
|
1467
|
+
function getStorage(key, dflt) {
|
|
1468
|
+
let store;
|
|
1469
|
+
if (isUndefined(key))
|
|
1470
|
+
return dflt ?? {};
|
|
1471
|
+
switch (context.type) {
|
|
1472
|
+
case CONTEXT.Browser:
|
|
1473
|
+
store = storage.getItem(key);
|
|
1474
|
+
break;
|
|
1475
|
+
case CONTEXT.NodeJS:
|
|
1476
|
+
store = nodeStorage.has(key) ? nodeStorage.get(key) : getEnvVar(key);
|
|
1477
|
+
break;
|
|
1478
|
+
case CONTEXT.Deno:
|
|
1479
|
+
store = context.global.Deno.env.get(key);
|
|
1480
|
+
break;
|
|
1481
|
+
case CONTEXT.GoogleAppsScript:
|
|
1482
|
+
store = context.global.PropertiesService?.getUserProperties().getProperty(key);
|
|
1483
|
+
break;
|
|
1484
|
+
case CONTEXT.WebWorker:
|
|
1485
|
+
case CONTEXT.Unknown:
|
|
1486
|
+
store = void 0;
|
|
1487
|
+
break;
|
|
1488
|
+
default:
|
|
1489
|
+
throw new Error(`Cannot determine Javascript context: ${context.type}`);
|
|
1490
|
+
}
|
|
1491
|
+
return isString(store) ? objectify(store) : dflt;
|
|
1492
|
+
}
|
|
1493
|
+
function setStorage(key, val, options) {
|
|
1494
|
+
const stash = isDefined(val) ? stringify(val) : void 0;
|
|
1495
|
+
const set = isDefined(stash);
|
|
1496
|
+
switch (context.type) {
|
|
1497
|
+
case CONTEXT.Browser:
|
|
1498
|
+
try {
|
|
1499
|
+
set ? storage.setItem(key, stash) : storage.removeItem(key);
|
|
1500
|
+
} catch (e) {
|
|
1501
|
+
console.warn(`[Storage] Failed to ${set ? "setItem" : "removeItem"} for key '${key}':`, e);
|
|
1502
|
+
}
|
|
1503
|
+
break;
|
|
1504
|
+
case CONTEXT.NodeJS:
|
|
1505
|
+
if (!set) {
|
|
1506
|
+
nodeStorage.set(key, void 0, options?.ttl);
|
|
1507
|
+
} else if (options?.static) {
|
|
1508
|
+
nodeStorage.setStatic(key, stash);
|
|
1509
|
+
} else {
|
|
1510
|
+
nodeStorage.set(key, stash, options?.ttl);
|
|
1511
|
+
}
|
|
1512
|
+
break;
|
|
1513
|
+
case CONTEXT.Deno:
|
|
1514
|
+
set ? context.global.Deno.env.set(key, stash) : context.global.Deno.env.delete(key);
|
|
1515
|
+
break;
|
|
1516
|
+
case CONTEXT.GoogleAppsScript:
|
|
1517
|
+
set ? context.global.PropertiesService?.getUserProperties().setProperty(key, stash) : context.global.PropertiesService?.getUserProperties().deleteProperty(key);
|
|
1518
|
+
break;
|
|
1519
|
+
case CONTEXT.WebWorker:
|
|
1520
|
+
case CONTEXT.Unknown:
|
|
1521
|
+
break;
|
|
1522
|
+
default:
|
|
1523
|
+
throw new Error(`Cannot determine Javascript context: ${context.type}`);
|
|
1524
|
+
}
|
|
1525
|
+
}
|
|
1526
|
+
var context, createMemoryStorage, memoryStores, getMemoryStorage, getSafeStorage, storage, nodeStorage, getEnvVar;
|
|
1527
|
+
var init_storage_library = __esm({
|
|
1528
|
+
"../../library/dist/common/runtime/storage.library.js"() {
|
|
1529
|
+
"use strict";
|
|
1530
|
+
init_serialize_library();
|
|
1531
|
+
init_utility_library();
|
|
1532
|
+
init_assertion_library();
|
|
1533
|
+
init_cache_class();
|
|
1534
|
+
context = getContext();
|
|
1535
|
+
createMemoryStorage = (maxSize = 1e3, ttl = Infinity) => {
|
|
1536
|
+
const map = new BoundedCache(maxSize, ttl);
|
|
1537
|
+
return {
|
|
1538
|
+
get length() {
|
|
1539
|
+
return map.size;
|
|
1540
|
+
},
|
|
1541
|
+
clear: () => map.clear(),
|
|
1542
|
+
getItem: (key) => map.get(key) ?? null,
|
|
1543
|
+
key: (index) => Array.from(map.keys())[index] ?? null,
|
|
1544
|
+
removeItem: (key) => {
|
|
1545
|
+
map.delete(key);
|
|
1546
|
+
},
|
|
1547
|
+
setItem: (key, value2) => {
|
|
1548
|
+
map.set(key, String(value2));
|
|
1549
|
+
}
|
|
1550
|
+
};
|
|
1551
|
+
};
|
|
1552
|
+
memoryStores = /* @__PURE__ */ new Map();
|
|
1553
|
+
getMemoryStorage = (name) => {
|
|
1554
|
+
let store = memoryStores.get(name);
|
|
1555
|
+
if (!store) {
|
|
1556
|
+
store = createMemoryStorage();
|
|
1557
|
+
memoryStores.set(name, store);
|
|
1558
|
+
}
|
|
1559
|
+
return store;
|
|
1560
|
+
};
|
|
1561
|
+
getSafeStorage = (name = "localStorage") => {
|
|
1562
|
+
try {
|
|
1563
|
+
const target = globalThis?.[name];
|
|
1564
|
+
if (target && isCallable(target.getItem) && isCallable(target.setItem) && isCallable(target.removeItem) && isCallable(target.clear) && isCallable(target.key) && isNumber(target.length))
|
|
1565
|
+
return target;
|
|
1566
|
+
} catch {
|
|
1567
|
+
}
|
|
1568
|
+
return getMemoryStorage(name);
|
|
1569
|
+
};
|
|
1570
|
+
storage = context.type === CONTEXT.Browser ? getSafeStorage() : createMemoryStorage();
|
|
1571
|
+
nodeStorage = new BoundedCache(1e3, Infinity);
|
|
1572
|
+
getEnvVar = (key) => {
|
|
1573
|
+
try {
|
|
1574
|
+
const proc = Reflect.get(context.global, "process");
|
|
1575
|
+
if (!proc || typeof proc !== "object")
|
|
1576
|
+
return void 0;
|
|
1577
|
+
const env = Reflect.get(proc, "env");
|
|
1578
|
+
if (!env || typeof env !== "object")
|
|
1579
|
+
return void 0;
|
|
1580
|
+
return Reflect.get(env, key);
|
|
1581
|
+
} catch {
|
|
1582
|
+
return void 0;
|
|
1583
|
+
}
|
|
1584
|
+
};
|
|
857
1585
|
}
|
|
858
1586
|
});
|
|
859
1587
|
|
|
@@ -867,6 +1595,10 @@ var init_string_library = __esm({
|
|
|
867
1595
|
});
|
|
868
1596
|
|
|
869
1597
|
// ../../library/dist/common/primitives/coercion.library.js
|
|
1598
|
+
function asArray(arr = [], fill) {
|
|
1599
|
+
const mapFn = (val) => isUndefined(fill) || isDefined(val) ? val : clone(fill);
|
|
1600
|
+
return isArrayLike(arr) || isIterable(arr) && !isString(arr) ? Array.from(arr, mapFn) : [arr];
|
|
1601
|
+
}
|
|
870
1602
|
function asError(err) {
|
|
871
1603
|
if (isError(err))
|
|
872
1604
|
return err;
|
|
@@ -934,169 +1666,223 @@ var init_temporal_library = __esm({
|
|
|
934
1666
|
});
|
|
935
1667
|
|
|
936
1668
|
// ../../library/dist/common/runtime/international.library.js
|
|
937
|
-
function
|
|
938
|
-
|
|
939
|
-
}
|
|
940
|
-
function getHemisphere(timeZone = getDateTimeFormat().timeZone) {
|
|
941
|
-
try {
|
|
942
|
-
const { jan, jul } = getOffsets(timeZone);
|
|
943
|
-
const southPrefixes = ["Australia", "Antarctica", "Africa/Johannesburg", "America/Argentina/Buenos_Aires", "America/Sao_Paulo"];
|
|
944
|
-
const isSouthZone = southPrefixes.some((p) => timeZone.startsWith(p));
|
|
945
|
-
switch (true) {
|
|
946
|
-
case jul > jan:
|
|
947
|
-
return "north";
|
|
948
|
-
case jul < jan:
|
|
949
|
-
return "south";
|
|
950
|
-
default:
|
|
951
|
-
return isSouthZone ? "south" : void 0;
|
|
952
|
-
}
|
|
953
|
-
} catch (e) {
|
|
1669
|
+
function getPropOrCall(obj, method, fallbackProp) {
|
|
1670
|
+
if (!obj)
|
|
954
1671
|
return void 0;
|
|
955
|
-
|
|
1672
|
+
if (isCallable(obj[method]))
|
|
1673
|
+
return obj[method]();
|
|
1674
|
+
if (fallbackProp && fallbackProp in obj)
|
|
1675
|
+
return obj[fallbackProp];
|
|
1676
|
+
return void 0;
|
|
1677
|
+
}
|
|
1678
|
+
function getFallbackFirstDay(region) {
|
|
1679
|
+
if (!region)
|
|
1680
|
+
return 1;
|
|
1681
|
+
if (FRIDAY_START_REGIONS.has(region))
|
|
1682
|
+
return 5;
|
|
1683
|
+
if (SATURDAY_START_REGIONS.has(region))
|
|
1684
|
+
return 6;
|
|
1685
|
+
if (SUNDAY_START_REGIONS.has(region))
|
|
1686
|
+
return 7;
|
|
1687
|
+
return 1;
|
|
956
1688
|
}
|
|
957
|
-
|
|
1689
|
+
function getFallbackWeekend(region) {
|
|
1690
|
+
if (!region)
|
|
1691
|
+
return WEEKEND_SAT_SUN;
|
|
1692
|
+
if (region === "IR")
|
|
1693
|
+
return WEEKEND_FRI;
|
|
1694
|
+
if (region === "AF")
|
|
1695
|
+
return WEEKEND_THU_FRI;
|
|
1696
|
+
if (FRI_SAT_WEEKEND_REGIONS.has(region))
|
|
1697
|
+
return WEEKEND_FRI_SAT;
|
|
1698
|
+
return WEEKEND_SAT_SUN;
|
|
1699
|
+
}
|
|
1700
|
+
function getFallbackDirection(loc, language) {
|
|
1701
|
+
const script = loc?.script ?? (isCallable(loc?.maximize) ? loc.maximize().script : void 0);
|
|
1702
|
+
return script && RTL_SCRIPTS.has(script) || language && RTL_LANGUAGES.has(language) ? "rtl" : "ltr";
|
|
1703
|
+
}
|
|
1704
|
+
var RE_UNDERSCORE, RE_LOCALE_CLEANSE, hasIntl, cleanLocaleTag, getRTF, getLF, getDTF, getPR, getNF, getDF, SUNDAY_START_REGIONS, SATURDAY_START_REGIONS, FRIDAY_START_REGIONS, FRI_SAT_WEEKEND_REGIONS, RTL_LANGUAGES, RTL_SCRIPTS, WEEKEND_SAT_SUN, WEEKEND_FRI_SAT, WEEKEND_FRI, WEEKEND_THU_FRI, getLC, getLI, getDigitsMap, FALLBACK_DTF_OPTIONS, getDateTimeFormat, canonicalLocale, canonicalLocales, getHemisphere, probeMDY;
|
|
958
1705
|
var init_international_library = __esm({
|
|
959
1706
|
"../../library/dist/common/runtime/international.library.js"() {
|
|
960
1707
|
"use strict";
|
|
961
1708
|
init_temporal_library();
|
|
962
1709
|
init_function_library();
|
|
963
1710
|
init_assertion_library();
|
|
964
|
-
|
|
965
|
-
|
|
1711
|
+
init_coercion_library();
|
|
1712
|
+
RE_UNDERSCORE = /_/g;
|
|
1713
|
+
RE_LOCALE_CLEANSE = /[.@]/;
|
|
1714
|
+
hasIntl = (feature) => typeof Intl !== "undefined" && (!feature || Object.hasOwn(Intl, feature) && isCallable(Intl[feature]));
|
|
1715
|
+
cleanLocaleTag = (tag2) => {
|
|
1716
|
+
if (isLocale(tag2))
|
|
1717
|
+
tag2 = tag2.toString();
|
|
1718
|
+
if (!isString(tag2))
|
|
1719
|
+
return void 0;
|
|
1720
|
+
const trimmed = tag2.trim();
|
|
1721
|
+
if (isEmpty(trimmed))
|
|
1722
|
+
return void 0;
|
|
1723
|
+
const stripped = trimmed.split(RE_LOCALE_CLEANSE)[0];
|
|
1724
|
+
if (isEmpty(stripped))
|
|
1725
|
+
return void 0;
|
|
1726
|
+
return stripped.replace(RE_UNDERSCORE, "-");
|
|
1727
|
+
};
|
|
1728
|
+
getRTF = memoizeFunction((locale, options) => {
|
|
1729
|
+
return new Intl.RelativeTimeFormat(cleanLocaleTag(locale), options);
|
|
966
1730
|
});
|
|
967
|
-
getLF = memoizeFunction((locale,
|
|
968
|
-
return new Intl.ListFormat(locale,
|
|
1731
|
+
getLF = memoizeFunction((locale, options) => {
|
|
1732
|
+
return new Intl.ListFormat(cleanLocaleTag(locale), options);
|
|
969
1733
|
});
|
|
970
1734
|
getDTF = memoizeFunction((locale, options) => {
|
|
971
|
-
return new Intl.DateTimeFormat(locale, options);
|
|
1735
|
+
return new Intl.DateTimeFormat(cleanLocaleTag(locale), options);
|
|
972
1736
|
});
|
|
973
1737
|
getPR = memoizeFunction((locale, options) => {
|
|
974
1738
|
try {
|
|
975
|
-
return new Intl.PluralRules(locale, options);
|
|
1739
|
+
return new Intl.PluralRules(cleanLocaleTag(locale), options);
|
|
976
1740
|
} catch (e) {
|
|
977
1741
|
return { select: () => "other" };
|
|
978
1742
|
}
|
|
979
1743
|
});
|
|
980
|
-
getNF = memoizeFunction((locale, options) => {
|
|
981
|
-
return new Intl.NumberFormat(locale, options);
|
|
1744
|
+
getNF = memoizeFunction((locale, options) => {
|
|
1745
|
+
return new Intl.NumberFormat(cleanLocaleTag(locale), options);
|
|
1746
|
+
});
|
|
1747
|
+
getDF = memoizeFunction((locale, options) => {
|
|
1748
|
+
try {
|
|
1749
|
+
const df = new Intl.DurationFormat(cleanLocaleTag(locale), options);
|
|
1750
|
+
if (isFunction(df.format))
|
|
1751
|
+
return df;
|
|
1752
|
+
throw new Error("No format method");
|
|
1753
|
+
} catch (e) {
|
|
1754
|
+
return { format: (duration) => String(duration) };
|
|
1755
|
+
}
|
|
1756
|
+
});
|
|
1757
|
+
SUNDAY_START_REGIONS = /* @__PURE__ */ new Set(["US", "CA", "MX", "BR", "IL", "JP", "TW", "HK", "MO", "PH", "SG", "TH", "IN", "KR", "CO", "PE", "VE", "ZA"]);
|
|
1758
|
+
SATURDAY_START_REGIONS = /* @__PURE__ */ new Set(["SA", "AF", "BH", "DJ", "DZ", "EG", "IQ", "IR", "JO", "KW", "LY", "OM", "QA", "SD", "SY", "YE"]);
|
|
1759
|
+
FRIDAY_START_REGIONS = /* @__PURE__ */ new Set(["MV"]);
|
|
1760
|
+
FRI_SAT_WEEKEND_REGIONS = /* @__PURE__ */ new Set(["SA", "BH", "DJ", "DZ", "EG", "IQ", "JO", "KW", "LY", "OM", "QA", "SD", "SY", "YE"]);
|
|
1761
|
+
RTL_LANGUAGES = /* @__PURE__ */ new Set(["ar", "he", "fa", "ur", "yi", "ps", "sd", "ug", "ckb"]);
|
|
1762
|
+
RTL_SCRIPTS = /* @__PURE__ */ new Set(["Arab", "Hebr", "Thaa", "Syrc", "Mand", "Samr", "Nkoo"]);
|
|
1763
|
+
WEEKEND_SAT_SUN = Object.freeze([6, 7]);
|
|
1764
|
+
WEEKEND_FRI_SAT = Object.freeze([5, 6]);
|
|
1765
|
+
WEEKEND_FRI = Object.freeze([5]);
|
|
1766
|
+
WEEKEND_THU_FRI = Object.freeze([4, 5]);
|
|
1767
|
+
getLC = memoizeFunction((localeTag) => {
|
|
1768
|
+
if (isLocale(localeTag))
|
|
1769
|
+
return localeTag;
|
|
1770
|
+
if (!hasIntl("Locale"))
|
|
1771
|
+
return void 0;
|
|
1772
|
+
try {
|
|
1773
|
+
const cleaned = cleanLocaleTag(localeTag);
|
|
1774
|
+
return new Intl.Locale(cleaned || "en-US");
|
|
1775
|
+
} catch {
|
|
1776
|
+
return void 0;
|
|
1777
|
+
}
|
|
1778
|
+
});
|
|
1779
|
+
getLI = memoizeFunction((localeTag) => {
|
|
1780
|
+
const loc = getLC(localeTag) ?? getLC("en-US");
|
|
1781
|
+
const baseName = loc?.baseName ?? canonicalLocale(localeTag) ?? "en-US";
|
|
1782
|
+
const language = loc?.language ?? baseName.split("-")[0]?.toLowerCase();
|
|
1783
|
+
const regionSubtags = [];
|
|
1784
|
+
for (const sub of baseName.split("-").slice(1)) {
|
|
1785
|
+
if (sub.length === 1)
|
|
1786
|
+
break;
|
|
1787
|
+
regionSubtags.push(sub);
|
|
1788
|
+
}
|
|
1789
|
+
const region = loc?.region ?? (isCallable(loc?.maximize) ? loc.maximize().region : void 0) ?? regionSubtags.find((subtag) => /^[a-zA-Z]{2}$|^\d{3}$/.test(subtag))?.toUpperCase();
|
|
1790
|
+
const script = loc?.script ?? (isCallable(loc?.maximize) ? loc.maximize().script : void 0);
|
|
1791
|
+
const rawWeek = getPropOrCall(loc, "getWeekInfo", "weekInfo");
|
|
1792
|
+
const firstDay = rawWeek?.firstDay ?? getFallbackFirstDay(region);
|
|
1793
|
+
const weekend = Array.isArray(rawWeek?.weekend) ? Object.freeze([...rawWeek.weekend]) : getFallbackWeekend(region);
|
|
1794
|
+
const rawCycles = getPropOrCall(loc, "getHourCycles", "hourCycles") ?? loc?.hourCycle;
|
|
1795
|
+
const resolvedHc = rawCycles ?? (hasIntl("DateTimeFormat") ? getDTF(baseName, { hour: "numeric" }).resolvedOptions().hourCycle : void 0);
|
|
1796
|
+
const hourCycles = Array.isArray(resolvedHc) && resolvedHc.length > 0 ? Object.freeze([...resolvedHc]) : isString(resolvedHc) ? Object.freeze([resolvedHc]) : Object.freeze(["h23"]);
|
|
1797
|
+
const rawText = getPropOrCall(loc, "getTextInfo", "textInfo");
|
|
1798
|
+
const direction = rawText?.direction === "rtl" || rawText?.direction === "ltr" ? rawText.direction : getFallbackDirection(loc, language);
|
|
1799
|
+
const rawSystems = getPropOrCall(loc, "getNumberingSystems", "numberingSystems") ?? loc?.numberingSystem;
|
|
1800
|
+
const resolvedNs = rawSystems ?? (hasIntl("NumberFormat") ? getNF(baseName).resolvedOptions().numberingSystem : void 0);
|
|
1801
|
+
const numberingSystems = Array.isArray(resolvedNs) && resolvedNs.length > 0 ? Object.freeze([...resolvedNs]) : isString(resolvedNs) ? Object.freeze([resolvedNs]) : Object.freeze(["latn"]);
|
|
1802
|
+
const rawTimeZones = getPropOrCall(loc, "getTimeZones", "timeZones");
|
|
1803
|
+
const timeZones = Array.isArray(rawTimeZones) && rawTimeZones.length > 0 ? Object.freeze([...rawTimeZones]) : Object.freeze([]);
|
|
1804
|
+
const weekInfo = Object.freeze({ firstDay, weekend });
|
|
1805
|
+
return Object.freeze({
|
|
1806
|
+
locale: loc,
|
|
1807
|
+
baseName,
|
|
1808
|
+
language,
|
|
1809
|
+
region,
|
|
1810
|
+
script,
|
|
1811
|
+
weekInfo,
|
|
1812
|
+
firstDay,
|
|
1813
|
+
weekend,
|
|
1814
|
+
hourCycle: hourCycles[0],
|
|
1815
|
+
hourCycles,
|
|
1816
|
+
direction,
|
|
1817
|
+
numberingSystem: numberingSystems[0],
|
|
1818
|
+
numberingSystems,
|
|
1819
|
+
timeZones
|
|
1820
|
+
});
|
|
1821
|
+
});
|
|
1822
|
+
getDigitsMap = memoizeFunction((numberingSystem = "latn") => {
|
|
1823
|
+
if (!numberingSystem || numberingSystem === "latn" || !hasIntl("NumberFormat"))
|
|
1824
|
+
return void 0;
|
|
1825
|
+
try {
|
|
1826
|
+
const nf = new Intl.NumberFormat(`en-u-nu-${numberingSystem}`, { useGrouping: false });
|
|
1827
|
+
const digits = Array.from({ length: 10 }, (_, i) => nf.format(i));
|
|
1828
|
+
if (digits[0] === "0" && digits[9] === "9")
|
|
1829
|
+
return void 0;
|
|
1830
|
+
return Object.freeze(digits);
|
|
1831
|
+
} catch {
|
|
1832
|
+
return void 0;
|
|
1833
|
+
}
|
|
1834
|
+
});
|
|
1835
|
+
FALLBACK_DTF_OPTIONS = Object.freeze({
|
|
1836
|
+
locale: "en-US",
|
|
1837
|
+
calendar: "iso8601",
|
|
1838
|
+
numberingSystem: "latn",
|
|
1839
|
+
timeZone: "UTC"
|
|
1840
|
+
});
|
|
1841
|
+
getDateTimeFormat = memoizeFunction(() => {
|
|
1842
|
+
return hasIntl("DateTimeFormat") ? Object.freeze(getDTF().resolvedOptions()) : FALLBACK_DTF_OPTIONS;
|
|
1843
|
+
});
|
|
1844
|
+
canonicalLocale = memoizeFunction((locale) => {
|
|
1845
|
+
const cleaned = cleanLocaleTag(locale);
|
|
1846
|
+
if (!cleaned)
|
|
1847
|
+
return void 0;
|
|
1848
|
+
if (hasIntl("getCanonicalLocales")) {
|
|
1849
|
+
try {
|
|
1850
|
+
return Intl.getCanonicalLocales(cleaned)[0];
|
|
1851
|
+
} catch {
|
|
1852
|
+
return void 0;
|
|
1853
|
+
}
|
|
1854
|
+
}
|
|
1855
|
+
return getLC(cleaned)?.baseName ?? cleaned;
|
|
1856
|
+
});
|
|
1857
|
+
canonicalLocales = memoizeFunction((locales) => {
|
|
1858
|
+
return Object.freeze(asArray(locales).map((l) => canonicalLocale(l)).filter(Boolean));
|
|
982
1859
|
});
|
|
983
|
-
|
|
1860
|
+
getHemisphere = memoizeFunction((timeZone = getDateTimeFormat().timeZone) => {
|
|
984
1861
|
try {
|
|
985
|
-
const
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
1862
|
+
const { jan, jul } = getOffsets(timeZone);
|
|
1863
|
+
const southPrefixes = ["Australia", "Antarctica", "Africa/Johannesburg", "America/Argentina/Buenos_Aires", "America/Sao_Paulo"];
|
|
1864
|
+
const isSouthZone = southPrefixes.some((p) => timeZone.startsWith(p));
|
|
1865
|
+
switch (true) {
|
|
1866
|
+
case jul > jan:
|
|
1867
|
+
return "north";
|
|
1868
|
+
case jul < jan:
|
|
1869
|
+
return "south";
|
|
1870
|
+
default:
|
|
1871
|
+
return isSouthZone ? "south" : void 0;
|
|
1872
|
+
}
|
|
989
1873
|
} catch (e) {
|
|
990
|
-
return
|
|
1874
|
+
return void 0;
|
|
991
1875
|
}
|
|
992
1876
|
});
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
return f;
|
|
1001
|
-
}
|
|
1002
|
-
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
1003
|
-
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
1004
|
-
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
1005
|
-
var _, done = false;
|
|
1006
|
-
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
1007
|
-
var context3 = {};
|
|
1008
|
-
for (var p in contextIn) context3[p] = p === "access" ? {} : contextIn[p];
|
|
1009
|
-
for (var p in contextIn.access) context3.access[p] = contextIn.access[p];
|
|
1010
|
-
context3.addInitializer = function(f) {
|
|
1011
|
-
if (done) throw new TypeError("Cannot add initializers after decoration has completed");
|
|
1012
|
-
extraInitializers.push(accept(f || null));
|
|
1013
|
-
};
|
|
1014
|
-
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context3);
|
|
1015
|
-
if (kind === "accessor") {
|
|
1016
|
-
if (result === void 0) continue;
|
|
1017
|
-
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
1018
|
-
if (_ = accept(result.get)) descriptor.get = _;
|
|
1019
|
-
if (_ = accept(result.set)) descriptor.set = _;
|
|
1020
|
-
if (_ = accept(result.init)) initializers.unshift(_);
|
|
1021
|
-
} else if (_ = accept(result)) {
|
|
1022
|
-
if (kind === "field") initializers.unshift(_);
|
|
1023
|
-
else descriptor[key] = _;
|
|
1024
|
-
}
|
|
1025
|
-
}
|
|
1026
|
-
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
1027
|
-
done = true;
|
|
1028
|
-
}
|
|
1029
|
-
function __runInitializers(thisArg, initializers, value2) {
|
|
1030
|
-
var useValue = arguments.length > 2;
|
|
1031
|
-
for (var i = 0; i < initializers.length; i++) {
|
|
1032
|
-
value2 = useValue ? initializers[i].call(thisArg, value2) : initializers[i].call(thisArg);
|
|
1033
|
-
}
|
|
1034
|
-
return useValue ? value2 : void 0;
|
|
1035
|
-
}
|
|
1036
|
-
var init_tslib_es6 = __esm({
|
|
1037
|
-
"../../../node_modules/tslib/tslib.es6.mjs"() {
|
|
1038
|
-
"use strict";
|
|
1039
|
-
}
|
|
1040
|
-
});
|
|
1041
|
-
|
|
1042
|
-
// ../../library/dist/common/runtime/decorator.library.js
|
|
1043
|
-
function getClassName(value2, contextName) {
|
|
1044
|
-
return getSafeTag(value2) ?? (isUndefined(contextName) ? value2.name || void 0 : String(contextName));
|
|
1045
|
-
}
|
|
1046
|
-
function Serializable(value2, { kind, name, addInitializer }) {
|
|
1047
|
-
const finalName = getClassName(value2, name);
|
|
1048
|
-
if (finalName)
|
|
1049
|
-
registerType(value2, finalName);
|
|
1050
|
-
switch (kind) {
|
|
1051
|
-
case "class":
|
|
1052
|
-
if (finalName)
|
|
1053
|
-
addInitializer(() => registerSerializable(finalName, value2));
|
|
1054
|
-
return value2;
|
|
1055
|
-
default:
|
|
1056
|
-
throw new Error(`@Serializable decorating unknown 'kind': ${kind} (${name})`);
|
|
1057
|
-
}
|
|
1058
|
-
}
|
|
1059
|
-
function StringTag(tagOrValue, context3) {
|
|
1060
|
-
const applyTag = (value2, customTag, contextName) => {
|
|
1061
|
-
const proto = value2.prototype;
|
|
1062
|
-
const tagName = customTag ?? getClassName(value2, contextName);
|
|
1063
|
-
if (tagName) {
|
|
1064
|
-
if (proto && !Object.hasOwn(proto, Symbol.toStringTag)) {
|
|
1065
|
-
Object.defineProperty(proto, Symbol.toStringTag, {
|
|
1066
|
-
value: tagName,
|
|
1067
|
-
configurable: true,
|
|
1068
|
-
writable: false,
|
|
1069
|
-
enumerable: false
|
|
1070
|
-
});
|
|
1071
|
-
}
|
|
1072
|
-
if (!value2.name || value2.name !== tagName) {
|
|
1073
|
-
try {
|
|
1074
|
-
Object.defineProperty(value2, "name", {
|
|
1075
|
-
value: tagName,
|
|
1076
|
-
configurable: true,
|
|
1077
|
-
writable: false,
|
|
1078
|
-
enumerable: false
|
|
1079
|
-
});
|
|
1080
|
-
} catch {
|
|
1081
|
-
}
|
|
1877
|
+
probeMDY = memoizeFunction((locale) => {
|
|
1878
|
+
try {
|
|
1879
|
+
const date = new Date(2024, 11, 24);
|
|
1880
|
+
const parts = getDTF(locale).formatToParts(date);
|
|
1881
|
+
return parts[0].type === "month" && parts[0].value === "12";
|
|
1882
|
+
} catch {
|
|
1883
|
+
return false;
|
|
1082
1884
|
}
|
|
1083
|
-
}
|
|
1084
|
-
return value2;
|
|
1085
|
-
};
|
|
1086
|
-
if (typeof tagOrValue === "function" && context3?.kind === "class")
|
|
1087
|
-
return applyTag(tagOrValue, void 0, context3.name);
|
|
1088
|
-
return (value2, ctx) => {
|
|
1089
|
-
return applyTag(value2, isString(tagOrValue) ? tagOrValue : void 0, ctx?.name);
|
|
1090
|
-
};
|
|
1091
|
-
}
|
|
1092
|
-
var init_decorator_library = __esm({
|
|
1093
|
-
"../../library/dist/common/runtime/decorator.library.js"() {
|
|
1094
|
-
"use strict";
|
|
1095
|
-
init_symbol_library();
|
|
1096
|
-
init_proxy_library();
|
|
1097
|
-
init_assertion_library();
|
|
1098
|
-
init_serialize_library();
|
|
1099
|
-
init_type_library();
|
|
1885
|
+
});
|
|
1100
1886
|
}
|
|
1101
1887
|
});
|
|
1102
1888
|
|
|
@@ -1329,54 +2115,6 @@ var init_logger_class = __esm({
|
|
|
1329
2115
|
}
|
|
1330
2116
|
});
|
|
1331
2117
|
|
|
1332
|
-
// ../../library/dist/common/runtime/storage.library.js
|
|
1333
|
-
var context, createMemoryStorage, memoryStores, getMemoryStorage, getSafeStorage, storage;
|
|
1334
|
-
var init_storage_library = __esm({
|
|
1335
|
-
"../../library/dist/common/runtime/storage.library.js"() {
|
|
1336
|
-
"use strict";
|
|
1337
|
-
init_serialize_library();
|
|
1338
|
-
init_utility_library();
|
|
1339
|
-
init_assertion_library();
|
|
1340
|
-
context = getContext();
|
|
1341
|
-
createMemoryStorage = () => {
|
|
1342
|
-
const map = /* @__PURE__ */ new Map();
|
|
1343
|
-
return {
|
|
1344
|
-
get length() {
|
|
1345
|
-
return map.size;
|
|
1346
|
-
},
|
|
1347
|
-
clear: () => map.clear(),
|
|
1348
|
-
getItem: (key) => map.get(key) ?? null,
|
|
1349
|
-
key: (index) => Array.from(map.keys())[index] ?? null,
|
|
1350
|
-
removeItem: (key) => {
|
|
1351
|
-
map.delete(key);
|
|
1352
|
-
},
|
|
1353
|
-
setItem: (key, value2) => {
|
|
1354
|
-
map.set(key, String(value2));
|
|
1355
|
-
}
|
|
1356
|
-
};
|
|
1357
|
-
};
|
|
1358
|
-
memoryStores = /* @__PURE__ */ new Map();
|
|
1359
|
-
getMemoryStorage = (name) => {
|
|
1360
|
-
let store = memoryStores.get(name);
|
|
1361
|
-
if (!store) {
|
|
1362
|
-
store = createMemoryStorage();
|
|
1363
|
-
memoryStores.set(name, store);
|
|
1364
|
-
}
|
|
1365
|
-
return store;
|
|
1366
|
-
};
|
|
1367
|
-
getSafeStorage = (name = "localStorage") => {
|
|
1368
|
-
try {
|
|
1369
|
-
const target = globalThis?.[name];
|
|
1370
|
-
if (target && typeof target.getItem === "function" && typeof target.setItem === "function" && typeof target.removeItem === "function" && typeof target.clear === "function" && typeof target.key === "function" && typeof target.length === "number")
|
|
1371
|
-
return target;
|
|
1372
|
-
} catch {
|
|
1373
|
-
}
|
|
1374
|
-
return getMemoryStorage(name);
|
|
1375
|
-
};
|
|
1376
|
-
storage = context.type === CONTEXT.Browser ? getSafeStorage() : createMemoryStorage();
|
|
1377
|
-
}
|
|
1378
|
-
});
|
|
1379
|
-
|
|
1380
2118
|
// ../../library/dist/browser/webstore.class.js
|
|
1381
2119
|
var webstore_class_exports = {};
|
|
1382
2120
|
__export(webstore_class_exports, {
|
|
@@ -1622,7 +2360,7 @@ var init_mapper_library = __esm({
|
|
|
1622
2360
|
defaults = { catch: true, debug: 0 };
|
|
1623
2361
|
context2 = getContext();
|
|
1624
2362
|
mapStore = {};
|
|
1625
|
-
MAP_KEY = "
|
|
2363
|
+
MAP_KEY = "_magma_browser_map_";
|
|
1626
2364
|
log = new Logger("[Mapper]");
|
|
1627
2365
|
storePromise = null;
|
|
1628
2366
|
getStore = () => {
|
|
@@ -1631,7 +2369,12 @@ var init_mapper_library = __esm({
|
|
|
1631
2369
|
if (context2.type === CONTEXT.Browser) {
|
|
1632
2370
|
Promise.resolve().then(() => (init_webstore_class(), webstore_class_exports)).then(({ WebStore: WebStore2 }) => {
|
|
1633
2371
|
const local = new WebStore2("local");
|
|
1634
|
-
|
|
2372
|
+
const stashed = local.get(MAP_KEY, {});
|
|
2373
|
+
if (isReference(stashed)) {
|
|
2374
|
+
if (stashed.geolocation && (!stashed.geolocation.coords || stashed.geolocation.$GeolocationPosition))
|
|
2375
|
+
delete stashed.geolocation;
|
|
2376
|
+
Object.assign(mapStore, stashed);
|
|
2377
|
+
}
|
|
1635
2378
|
resolve(local);
|
|
1636
2379
|
}).catch(reject);
|
|
1637
2380
|
} else {
|
|
@@ -1685,7 +2428,7 @@ var init_mapper_library = __esm({
|
|
|
1685
2428
|
const fulfil = opts.catch ? resolve : reject;
|
|
1686
2429
|
geoCoords(coords).then((loc) => {
|
|
1687
2430
|
switch (true) {
|
|
1688
|
-
case
|
|
2431
|
+
case (context2.type !== CONTEXT.Browser || !window["google"]?.maps):
|
|
1689
2432
|
throw new Error("Google Maps API not configured");
|
|
1690
2433
|
case isNullish(loc):
|
|
1691
2434
|
throw new Error("Cannot determine Coordinates");
|
|
@@ -1929,7 +2672,7 @@ __export(mapper_library_exports2, {
|
|
|
1929
2672
|
serverGeoLocation: () => serverGeoLocation,
|
|
1930
2673
|
serverMapHemisphere: () => serverMapHemisphere
|
|
1931
2674
|
});
|
|
1932
|
-
var log2, defaults2, requestModulePromise, getRequestModule, serverGeoLocation, serverGeoCoords, serverMapHemisphere;
|
|
2675
|
+
var log2, DEFAULT_GEO_ENDPOINT, defaults2, requestModulePromise, getRequestModule, serverGeoLocation, serverGeoCoords, serverMapHemisphere;
|
|
1933
2676
|
var init_mapper_library2 = __esm({
|
|
1934
2677
|
"../../library/dist/server/mapper.library.js"() {
|
|
1935
2678
|
"use strict";
|
|
@@ -1937,8 +2680,9 @@ var init_mapper_library2 = __esm({
|
|
|
1937
2680
|
init_international_library();
|
|
1938
2681
|
init_logger_class();
|
|
1939
2682
|
log2 = new Logger("[ServerMapper]");
|
|
2683
|
+
DEFAULT_GEO_ENDPOINT = "https://ipwho.is";
|
|
1940
2684
|
defaults2 = {
|
|
1941
|
-
endpoint:
|
|
2685
|
+
endpoint: `${DEFAULT_GEO_ENDPOINT}/`,
|
|
1942
2686
|
timeout: 3e3,
|
|
1943
2687
|
catch: true,
|
|
1944
2688
|
debug: 0
|
|
@@ -1953,7 +2697,18 @@ var init_mapper_library2 = __esm({
|
|
|
1953
2697
|
const options = { ...defaults2, ...opts };
|
|
1954
2698
|
const fulfil = options.catch !== false;
|
|
1955
2699
|
try {
|
|
1956
|
-
|
|
2700
|
+
let endpoint = options.endpoint || defaults2.endpoint;
|
|
2701
|
+
if (isString(options.ip)) {
|
|
2702
|
+
const cleanIp = encodeURIComponent(options.ip.trim());
|
|
2703
|
+
const normalized = endpoint.endsWith("/") ? endpoint.slice(0, -1) : endpoint;
|
|
2704
|
+
if (normalized === DEFAULT_GEO_ENDPOINT) {
|
|
2705
|
+
endpoint = `${DEFAULT_GEO_ENDPOINT}/${cleanIp}`;
|
|
2706
|
+
} else if (endpoint.includes("{ip}")) {
|
|
2707
|
+
endpoint = endpoint.replace("{ip}", cleanIp);
|
|
2708
|
+
} else if (cleanIp !== "") {
|
|
2709
|
+
throw new Error(`Custom endpoint must include an '{ip}' placeholder to resolve a specific IP: ${endpoint}`);
|
|
2710
|
+
}
|
|
2711
|
+
}
|
|
1957
2712
|
const timeout = options.timeout ?? defaults2.timeout;
|
|
1958
2713
|
const { fetchRequest: fetchRequest2 } = await getRequestModule();
|
|
1959
2714
|
const data = await fetchRequest2(endpoint, {}, { ...isNumber(timeout) ? { timeout } : {}, maxBytes: 64 * 1024 });
|
|
@@ -2019,145 +2774,486 @@ __export(sdk_exports, {
|
|
|
2019
2774
|
__reExport(sdk_exports, sdk_star);
|
|
2020
2775
|
import * as sdk_star from "@magmacomputing/tempo/plugin/sdk";
|
|
2021
2776
|
import { definePlugin as originalPlugin, defineTerm as originalTerm } from "@magmacomputing/tempo/plugin/sdk";
|
|
2022
|
-
var definePlugin = (config) => originalPlugin({ ...config, version: "
|
|
2023
|
-
var defineTerm = (config) => originalTerm({ ...config, version: "
|
|
2777
|
+
var definePlugin = (config) => originalPlugin({ ...config, version: "1.1.0" });
|
|
2778
|
+
var defineTerm = (config) => originalTerm({ ...config, version: "1.1.0" });
|
|
2024
2779
|
|
|
2025
2780
|
// ../../library/dist/common/runtime/mapper.library.js
|
|
2026
2781
|
init_utility_library();
|
|
2027
2782
|
init_assertion_library();
|
|
2783
|
+
init_storage_library();
|
|
2784
|
+
|
|
2785
|
+
// ../../library/dist/common/runtime/evaluation.library.js
|
|
2786
|
+
init_assertion_library();
|
|
2787
|
+
function evaluate(...values) {
|
|
2788
|
+
for (const val of values) {
|
|
2789
|
+
const resolved = isFunction(val) ? val() : val;
|
|
2790
|
+
if (resolved !== void 0)
|
|
2791
|
+
return resolved;
|
|
2792
|
+
}
|
|
2793
|
+
return void 0;
|
|
2794
|
+
}
|
|
2795
|
+
|
|
2796
|
+
// ../../library/dist/common/runtime/mapper.library.js
|
|
2797
|
+
var MAP_KEY2 = "_magma_geo_";
|
|
2798
|
+
var DEFAULT_GEO_TTL = 24 * 60 * 60 * 1e3;
|
|
2799
|
+
var GEO_PROPERTIES = [
|
|
2800
|
+
"latitude",
|
|
2801
|
+
"lat",
|
|
2802
|
+
"longitude",
|
|
2803
|
+
"lng",
|
|
2804
|
+
"lon",
|
|
2805
|
+
"long",
|
|
2806
|
+
"elevation",
|
|
2807
|
+
"sphere",
|
|
2808
|
+
"country",
|
|
2809
|
+
"city",
|
|
2810
|
+
"timezone",
|
|
2811
|
+
"tz"
|
|
2812
|
+
];
|
|
2813
|
+
var normalizeLat = (lat) => isNumber(lat) && lat >= -90 && lat <= 90 ? Math.round(lat * 1e3) / 1e3 : void 0;
|
|
2814
|
+
var normalizeLng = (lng) => isNumber(lng) && lng >= -180 && lng <= 180 ? Math.round(lng * 1e3) / 1e3 : void 0;
|
|
2815
|
+
var normalizeCoords = (lat, lng) => {
|
|
2816
|
+
const nLat = normalizeLat(lat);
|
|
2817
|
+
const nLng = normalizeLng(lng);
|
|
2818
|
+
return nLat !== void 0 && nLng !== void 0 ? { lat: nLat, lng: nLng } : void 0;
|
|
2819
|
+
};
|
|
2820
|
+
var resolveSphere = (sphere, lat) => {
|
|
2821
|
+
if (sphere === "north" || sphere === "south" || sphere === "equator")
|
|
2822
|
+
return sphere;
|
|
2823
|
+
if (isNumber(lat))
|
|
2824
|
+
return lat > 1e-3 ? "north" : lat < -1e-3 ? "south" : "equator";
|
|
2825
|
+
return void 0;
|
|
2826
|
+
};
|
|
2028
2827
|
var coerceGeo = (input) => {
|
|
2029
|
-
if (
|
|
2828
|
+
if (isString(input) && input.includes(",")) {
|
|
2829
|
+
const segments = input.split(",").map((s) => s.trim());
|
|
2830
|
+
const parts = segments.map((s) => s === "" ? NaN : Number(s));
|
|
2831
|
+
if (parts.length >= 2 && !isNaN(parts[0]) && !isNaN(parts[1])) {
|
|
2832
|
+
const coords = normalizeCoords(parts[0], parts[1]);
|
|
2833
|
+
if (coords) {
|
|
2834
|
+
const result2 = { latitude: coords.lat, longitude: coords.lng };
|
|
2835
|
+
const sphere2 = resolveSphere(void 0, coords.lat);
|
|
2836
|
+
if (sphere2)
|
|
2837
|
+
result2.sphere = sphere2;
|
|
2838
|
+
return result2;
|
|
2839
|
+
}
|
|
2840
|
+
}
|
|
2841
|
+
return void 0;
|
|
2842
|
+
}
|
|
2843
|
+
if (isPrimitive(input))
|
|
2844
|
+
return void 0;
|
|
2845
|
+
if (Array.isArray(input) && input.length >= 2) {
|
|
2846
|
+
const coords = normalizeCoords(input[0], input[1]);
|
|
2847
|
+
if (coords) {
|
|
2848
|
+
const result2 = { latitude: coords.lat, longitude: coords.lng };
|
|
2849
|
+
const sphere2 = resolveSphere(void 0, coords.lat);
|
|
2850
|
+
if (sphere2)
|
|
2851
|
+
result2.sphere = sphere2;
|
|
2852
|
+
return result2;
|
|
2853
|
+
}
|
|
2030
2854
|
return void 0;
|
|
2031
|
-
|
|
2032
|
-
const
|
|
2033
|
-
const
|
|
2034
|
-
const
|
|
2035
|
-
const
|
|
2036
|
-
const
|
|
2037
|
-
const
|
|
2038
|
-
const
|
|
2855
|
+
}
|
|
2856
|
+
const geo = input.geo ?? input;
|
|
2857
|
+
const cfg = input.config?.geo ?? input.config;
|
|
2858
|
+
const lat = evaluate(geo?.latitude, geo?.lat, input.latitude, input.lat, cfg?.latitude, cfg?.lat);
|
|
2859
|
+
const lng = evaluate(geo?.longitude, geo?.lng, geo?.lon, geo?.long, input.longitude, input.lng, input.lon, input.long, cfg?.longitude, cfg?.lng, cfg?.lon, cfg?.long);
|
|
2860
|
+
const elevation = evaluate(geo?.elevation, input.elevation, cfg?.elevation);
|
|
2861
|
+
const sphere = evaluate(geo?.sphere, input.sphere, cfg?.sphere);
|
|
2862
|
+
const country = evaluate(geo?.country, input.country, cfg?.country);
|
|
2863
|
+
const city = evaluate(geo?.city, input.city, cfg?.city);
|
|
2864
|
+
const timezone = evaluate(geo?.timezone, geo?.tz, input.timezone, input.tz, cfg?.timezone, cfg?.tz);
|
|
2039
2865
|
const result = {};
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
if (
|
|
2043
|
-
result.
|
|
2866
|
+
const nLat = normalizeLat(lat);
|
|
2867
|
+
const nLng = normalizeLng(lng);
|
|
2868
|
+
if (nLat !== void 0)
|
|
2869
|
+
result.latitude = nLat;
|
|
2870
|
+
if (nLng !== void 0)
|
|
2871
|
+
result.longitude = nLng;
|
|
2044
2872
|
if (isNumber(elevation))
|
|
2045
|
-
result.elevation = elevation;
|
|
2046
|
-
|
|
2047
|
-
|
|
2873
|
+
result.elevation = Math.round(elevation * 1e3) / 1e3;
|
|
2874
|
+
const resolvedSphere = resolveSphere(sphere, result.latitude);
|
|
2875
|
+
if (resolvedSphere)
|
|
2876
|
+
result.sphere = resolvedSphere;
|
|
2048
2877
|
if (isString(country))
|
|
2049
2878
|
result.country = country;
|
|
2050
2879
|
if (isString(city))
|
|
2051
2880
|
result.city = city;
|
|
2052
|
-
if (
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2881
|
+
if (isString(timezone))
|
|
2882
|
+
result.timezone = timezone;
|
|
2883
|
+
const explicitGeo = isReference(input.geo) ? input.geo : isReference(input.config?.geo) ? input.config.geo : void 0;
|
|
2884
|
+
if (isReference(explicitGeo)) {
|
|
2885
|
+
for (const key of Object.keys(explicitGeo)) {
|
|
2886
|
+
if (isSafeKey(key) && !GEO_PROPERTIES.includes(key))
|
|
2887
|
+
result[key] = explicitGeo[key];
|
|
2056
2888
|
}
|
|
2057
2889
|
}
|
|
2058
2890
|
return Object.keys(result).length > 0 ? result : void 0;
|
|
2059
2891
|
};
|
|
2060
|
-
var
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2892
|
+
var resolveCacheKey = (keyOrOpts) => {
|
|
2893
|
+
if (isString(keyOrOpts) && !isEmpty(keyOrOpts)) {
|
|
2894
|
+
const trimmed = keyOrOpts.trim();
|
|
2895
|
+
return trimmed.startsWith(MAP_KEY2) ? trimmed : `${MAP_KEY2}:${trimmed}`;
|
|
2896
|
+
}
|
|
2897
|
+
if (keyOrOpts && isObject(keyOrOpts)) {
|
|
2898
|
+
const k = keyOrOpts.key ?? keyOrOpts.ip ?? keyOrOpts.query;
|
|
2899
|
+
if (isString(k) && !isEmpty(k))
|
|
2900
|
+
return `${MAP_KEY2}:${k.trim()}`;
|
|
2901
|
+
}
|
|
2902
|
+
return MAP_KEY2;
|
|
2903
|
+
};
|
|
2904
|
+
var getStashedGeo = (keyOrOpts) => {
|
|
2905
|
+
const cacheKey = resolveCacheKey(keyOrOpts);
|
|
2906
|
+
try {
|
|
2907
|
+
const raw = getStorage(cacheKey) ?? (typeof localStorage !== "undefined" ? localStorage.getItem(cacheKey) : void 0);
|
|
2908
|
+
if (!raw)
|
|
2909
|
+
return void 0;
|
|
2910
|
+
const parsed = isString(raw) && (raw.startsWith("{") || raw.startsWith("[")) ? JSON.parse(raw) : raw;
|
|
2911
|
+
if (isObject(parsed)) {
|
|
2912
|
+
if (isNumber(parsed._expires) && Date.now() > parsed._expires) {
|
|
2913
|
+
clearStashedGeo(keyOrOpts);
|
|
2914
|
+
return void 0;
|
|
2915
|
+
}
|
|
2916
|
+
}
|
|
2917
|
+
if (isString(parsed) && parsed.includes(",")) {
|
|
2918
|
+
const parts = parsed.split(",").map((s) => parseFloat(s.trim()));
|
|
2919
|
+
const coords = normalizeCoords(parts[0], parts[1]);
|
|
2920
|
+
if (coords) {
|
|
2921
|
+
return {
|
|
2922
|
+
latitude: coords.lat,
|
|
2923
|
+
longitude: coords.lng,
|
|
2924
|
+
sphere: resolveSphere(void 0, coords.lat)
|
|
2925
|
+
};
|
|
2926
|
+
}
|
|
2927
|
+
}
|
|
2928
|
+
if (isObject(parsed)) {
|
|
2929
|
+
const rawCoords = parsed.geolocation?.coords ?? parsed.coords ?? parsed;
|
|
2930
|
+
const lat = rawCoords?.latitude ?? rawCoords?.lat;
|
|
2931
|
+
const lng = rawCoords?.longitude ?? rawCoords?.lng ?? rawCoords?.lon ?? rawCoords?.long;
|
|
2932
|
+
const coords = normalizeCoords(lat, lng);
|
|
2933
|
+
if (coords) {
|
|
2934
|
+
const result = { latitude: coords.lat, longitude: coords.lng };
|
|
2935
|
+
const elevation = parsed.elevation ?? rawCoords.elevation;
|
|
2936
|
+
if (isNumber(elevation))
|
|
2937
|
+
result.elevation = Math.round(elevation * 1e3) / 1e3;
|
|
2938
|
+
result.sphere = resolveSphere(parsed.sphere, coords.lat);
|
|
2939
|
+
if (isString(parsed.country))
|
|
2940
|
+
result.country = parsed.country;
|
|
2941
|
+
if (isString(parsed.city))
|
|
2942
|
+
result.city = parsed.city;
|
|
2943
|
+
if (isString(parsed.timezone))
|
|
2944
|
+
result.timezone = parsed.timezone;
|
|
2945
|
+
return result;
|
|
2073
2946
|
}
|
|
2074
|
-
} catch {
|
|
2075
2947
|
}
|
|
2948
|
+
} catch {
|
|
2076
2949
|
}
|
|
2077
2950
|
return void 0;
|
|
2078
2951
|
};
|
|
2952
|
+
var stashGeo = (coords, ttl = DEFAULT_GEO_TTL, keyOrOpts) => {
|
|
2953
|
+
const cacheKey = resolveCacheKey(keyOrOpts);
|
|
2954
|
+
const payload = isNumber(ttl) && ttl > 0 ? { ...coords, _expires: Date.now() + ttl } : coords;
|
|
2955
|
+
setStorage(cacheKey, payload, { ttl });
|
|
2956
|
+
};
|
|
2957
|
+
var clearStashedGeo = (keyOrOpts) => {
|
|
2958
|
+
const cacheKey = resolveCacheKey(keyOrOpts);
|
|
2959
|
+
setStorage(cacheKey, void 0);
|
|
2960
|
+
};
|
|
2079
2961
|
var geoLookup = async (opts = {}) => {
|
|
2962
|
+
const useCache = opts.refresh !== true;
|
|
2963
|
+
if (useCache) {
|
|
2964
|
+
const stashed = getStashedGeo(opts);
|
|
2965
|
+
if (stashed && isNumber(stashed.latitude) && isNumber(stashed.longitude)) {
|
|
2966
|
+
const { latitude, longitude, ...rest } = stashed;
|
|
2967
|
+
return {
|
|
2968
|
+
...rest,
|
|
2969
|
+
status: "cached",
|
|
2970
|
+
lat: latitude,
|
|
2971
|
+
lng: longitude,
|
|
2972
|
+
latitude,
|
|
2973
|
+
longitude
|
|
2974
|
+
};
|
|
2975
|
+
}
|
|
2976
|
+
}
|
|
2080
2977
|
const { type } = getContext();
|
|
2978
|
+
let res;
|
|
2081
2979
|
switch (type) {
|
|
2082
2980
|
case CONTEXT.Browser: {
|
|
2083
2981
|
const { geoLocation: geoLocation2 } = await Promise.resolve().then(() => (init_mapper_library(), mapper_library_exports));
|
|
2084
|
-
const
|
|
2085
|
-
if (
|
|
2086
|
-
return { error:
|
|
2087
|
-
const lat =
|
|
2088
|
-
const lng =
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
case CONTEXT.WebWorker: {
|
|
2092
|
-
const stashed = getStashedGeo();
|
|
2093
|
-
if (stashed && isNumber(stashed.latitude) && isNumber(stashed.longitude))
|
|
2094
|
-
return { lat: stashed.latitude, lng: stashed.longitude, latitude: stashed.latitude, longitude: stashed.longitude };
|
|
2095
|
-
const { serverGeoLocation: serverGeoLocation2 } = await Promise.resolve().then(() => (init_mapper_library2(), mapper_library_exports2));
|
|
2096
|
-
return serverGeoLocation2(opts);
|
|
2982
|
+
const browserRes = await geoLocation2(opts);
|
|
2983
|
+
if (browserRes.error)
|
|
2984
|
+
return { error: browserRes.error };
|
|
2985
|
+
const lat = browserRes.coords?.latitude;
|
|
2986
|
+
const lng = browserRes.coords?.longitude;
|
|
2987
|
+
res = { ...browserRes, lat, lng, latitude: lat, longitude: lng };
|
|
2988
|
+
break;
|
|
2097
2989
|
}
|
|
2990
|
+
case CONTEXT.WebWorker:
|
|
2098
2991
|
case CONTEXT.NodeJS:
|
|
2099
2992
|
case CONTEXT.Deno:
|
|
2100
2993
|
default: {
|
|
2101
2994
|
const { serverGeoLocation: serverGeoLocation2 } = await Promise.resolve().then(() => (init_mapper_library2(), mapper_library_exports2));
|
|
2102
|
-
|
|
2995
|
+
res = await serverGeoLocation2(opts);
|
|
2996
|
+
break;
|
|
2997
|
+
}
|
|
2998
|
+
}
|
|
2999
|
+
const rawLat = res.latitude ?? res.lat;
|
|
3000
|
+
const rawLng = res.longitude ?? res.lng;
|
|
3001
|
+
const coords = normalizeCoords(rawLat, rawLng);
|
|
3002
|
+
if (isNullish(res.error) && coords) {
|
|
3003
|
+
const sphere = resolveSphere(res.sphere, coords.lat);
|
|
3004
|
+
res.lat = coords.lat;
|
|
3005
|
+
res.lng = coords.lng;
|
|
3006
|
+
res.latitude = coords.lat;
|
|
3007
|
+
res.longitude = coords.lng;
|
|
3008
|
+
res.sphere = sphere;
|
|
3009
|
+
const stashPayload = {
|
|
3010
|
+
latitude: coords.lat,
|
|
3011
|
+
longitude: coords.lng,
|
|
3012
|
+
sphere,
|
|
3013
|
+
...isString(res.city) ? { city: res.city } : {},
|
|
3014
|
+
...isString(res.country) ? { country: res.country } : {},
|
|
3015
|
+
...isNumber(res.elevation) ? { elevation: Math.round(res.elevation * 1e3) / 1e3 } : {},
|
|
3016
|
+
...isString(res.timezone) ? { timezone: res.timezone } : {}
|
|
3017
|
+
};
|
|
3018
|
+
try {
|
|
3019
|
+
const ttl = isNumber(opts.ttl) ? opts.ttl : DEFAULT_GEO_TTL;
|
|
3020
|
+
stashGeo(stashPayload, ttl, opts);
|
|
3021
|
+
} catch {
|
|
2103
3022
|
}
|
|
2104
3023
|
}
|
|
3024
|
+
return res;
|
|
2105
3025
|
};
|
|
2106
3026
|
var resolveGeoCoordinates = async (input, opts = {}) => {
|
|
2107
3027
|
const coerced = coerceGeo(input);
|
|
2108
3028
|
if (coerced && isNumber(coerced.latitude) && isNumber(coerced.longitude))
|
|
2109
|
-
return {
|
|
2110
|
-
|
|
3029
|
+
return {
|
|
3030
|
+
...coerced,
|
|
3031
|
+
lat: coerced.latitude,
|
|
3032
|
+
lng: coerced.longitude
|
|
3033
|
+
};
|
|
3034
|
+
const stashed = opts.refresh === true ? void 0 : getStashedGeo(opts);
|
|
2111
3035
|
if (stashed && isNumber(stashed.latitude) && isNumber(stashed.longitude))
|
|
2112
|
-
return {
|
|
3036
|
+
return {
|
|
3037
|
+
...stashed,
|
|
3038
|
+
lat: stashed.latitude,
|
|
3039
|
+
lng: stashed.longitude
|
|
3040
|
+
};
|
|
2113
3041
|
const lookup = await geoLookup(opts);
|
|
2114
|
-
|
|
2115
|
-
|
|
3042
|
+
const coords = normalizeCoords(lookup.lat, lookup.lng);
|
|
3043
|
+
if (isNullish(lookup.error) && coords) {
|
|
3044
|
+
const sphere = resolveSphere(lookup.sphere, coords.lat);
|
|
3045
|
+
return {
|
|
3046
|
+
...lookup,
|
|
3047
|
+
lat: coords.lat,
|
|
3048
|
+
lng: coords.lng,
|
|
3049
|
+
latitude: coords.lat,
|
|
3050
|
+
longitude: coords.lng,
|
|
3051
|
+
sphere
|
|
3052
|
+
};
|
|
3053
|
+
}
|
|
2116
3054
|
return null;
|
|
2117
3055
|
};
|
|
3056
|
+
function haversineDistance(from, to, unit = "km") {
|
|
3057
|
+
const c1 = coerceGeo(from);
|
|
3058
|
+
const c2 = coerceGeo(to);
|
|
3059
|
+
if (!c1 || !c2 || !isNumber(c1.latitude) || !isNumber(c1.longitude) || !isNumber(c2.latitude) || !isNumber(c2.longitude)) {
|
|
3060
|
+
return NaN;
|
|
3061
|
+
}
|
|
3062
|
+
const toRad = Math.PI / 180;
|
|
3063
|
+
const lat1 = c1.latitude * toRad;
|
|
3064
|
+
const lng1 = c1.longitude * toRad;
|
|
3065
|
+
const lat2 = c2.latitude * toRad;
|
|
3066
|
+
const lng2 = c2.longitude * toRad;
|
|
3067
|
+
const dLat = lat2 - lat1;
|
|
3068
|
+
const dLng = lng2 - lng1;
|
|
3069
|
+
const a = Math.sin(dLat / 2) ** 2 + Math.cos(lat1) * Math.cos(lat2) * Math.sin(dLng / 2) ** 2;
|
|
3070
|
+
const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
|
|
3071
|
+
let radius;
|
|
3072
|
+
if (unit === "miles") {
|
|
3073
|
+
radius = 3958.7613;
|
|
3074
|
+
} else if (unit === "m") {
|
|
3075
|
+
radius = 63710088e-1;
|
|
3076
|
+
} else {
|
|
3077
|
+
radius = 6371.0088;
|
|
3078
|
+
}
|
|
3079
|
+
const dist = radius * c;
|
|
3080
|
+
return unit === "m" ? Math.round(dist) : Math.round(dist * 1e3) / 1e3;
|
|
3081
|
+
}
|
|
3082
|
+
var resolveCivilTimezoneOffset = (tz, epochMs) => {
|
|
3083
|
+
try {
|
|
3084
|
+
if (typeof Temporal !== "undefined" && typeof Temporal.Instant?.fromEpochMilliseconds === "function") {
|
|
3085
|
+
const zdt = Temporal.Instant.fromEpochMilliseconds(epochMs).toZonedDateTimeISO(tz);
|
|
3086
|
+
return zdt.offsetNanoseconds / 6e10;
|
|
3087
|
+
}
|
|
3088
|
+
const parts = new Intl.DateTimeFormat("en-US", {
|
|
3089
|
+
timeZone: tz,
|
|
3090
|
+
timeZoneName: "longOffset",
|
|
3091
|
+
year: "numeric"
|
|
3092
|
+
}).formatToParts(new Date(epochMs));
|
|
3093
|
+
const tzPart = parts.find((p) => p.type === "timeZoneName")?.value;
|
|
3094
|
+
if (tzPart) {
|
|
3095
|
+
if (tzPart === "GMT" || tzPart === "UTC")
|
|
3096
|
+
return 0;
|
|
3097
|
+
const match = tzPart.match(/GMT([+-])(\d{2}):(\d{2})/);
|
|
3098
|
+
if (match) {
|
|
3099
|
+
const sign = match[1] === "-" ? -1 : 1;
|
|
3100
|
+
return sign * (parseInt(match[2], 10) * 60 + parseInt(match[3], 10));
|
|
3101
|
+
}
|
|
3102
|
+
}
|
|
3103
|
+
} catch {
|
|
3104
|
+
}
|
|
3105
|
+
return void 0;
|
|
3106
|
+
};
|
|
3107
|
+
function solarOffset(coords, options) {
|
|
3108
|
+
const geo = coerceGeo(coords);
|
|
3109
|
+
if (!geo || !isNumber(geo.latitude) || !isNumber(geo.longitude) || isNaN(geo.latitude) || isNaN(geo.longitude)) {
|
|
3110
|
+
return NaN;
|
|
3111
|
+
}
|
|
3112
|
+
const lng = geo.longitude;
|
|
3113
|
+
const tz = options?.timeZone ?? (isReference(coords) ? coords.timezone ?? coords.tz : void 0) ?? geo.timezone;
|
|
3114
|
+
const dateVal = options?.date ?? (isReference(coords) && isNumber(coords.epoch?.ms) ? coords.epoch.ms : Date.now());
|
|
3115
|
+
const epochMs = typeof dateVal === "number" ? dateVal : isString(dateVal) ? Date.parse(dateVal) : isDate(dateVal) ? dateVal.getTime() : isReference(dateVal) && isNumber(dateVal?.epoch?.ms) ? dateVal.epoch.ms : Date.now();
|
|
3116
|
+
if (!Number.isFinite(epochMs))
|
|
3117
|
+
return NaN;
|
|
3118
|
+
const offsetMinutes = isText(tz) ? resolveCivilTimezoneOffset(tz, epochMs) : void 0;
|
|
3119
|
+
const refMeridian = offsetMinutes !== void 0 ? offsetMinutes / 60 * 15 : Math.round(lng / 15) * 15;
|
|
3120
|
+
const deltaLng = lng - refMeridian;
|
|
3121
|
+
let offsetMin = deltaLng * 4;
|
|
3122
|
+
if (options?.apparent) {
|
|
3123
|
+
const d = new Date(epochMs);
|
|
3124
|
+
const startOfYear = Date.UTC(d.getUTCFullYear(), 0, 1);
|
|
3125
|
+
const dayOfYear = Math.floor((epochMs - startOfYear) / 864e5) + 1;
|
|
3126
|
+
const gamma = 2 * Math.PI / 365 * (dayOfYear - 1);
|
|
3127
|
+
const eqTime = 229.18 * (75e-6 + 1868e-6 * Math.cos(gamma) - 0.032077 * Math.sin(gamma) - 0.014615 * Math.cos(2 * gamma) - 0.040849 * Math.sin(2 * gamma));
|
|
3128
|
+
offsetMin += eqTime;
|
|
3129
|
+
}
|
|
3130
|
+
const unit = options?.unit ?? "minutes";
|
|
3131
|
+
let res;
|
|
3132
|
+
if (unit === "seconds") {
|
|
3133
|
+
res = offsetMin * 60;
|
|
3134
|
+
} else if (unit === "hours") {
|
|
3135
|
+
res = offsetMin / 60;
|
|
3136
|
+
} else {
|
|
3137
|
+
res = offsetMin;
|
|
3138
|
+
}
|
|
3139
|
+
const precision = options?.precision ?? 2;
|
|
3140
|
+
const factor = Math.pow(10, precision);
|
|
3141
|
+
return Math.round(res * factor) / factor;
|
|
3142
|
+
}
|
|
2118
3143
|
|
|
2119
3144
|
// src/index.ts
|
|
2120
3145
|
init_mapper_library2();
|
|
2121
3146
|
init_mapper_library();
|
|
3147
|
+
init_assertion_library();
|
|
2122
3148
|
var GeoPlugin = definePlugin({
|
|
2123
3149
|
name: "geo",
|
|
2124
|
-
install(TempoClass) {
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
3150
|
+
install(TempoClass, options) {
|
|
3151
|
+
const installedClass = TempoClass || this;
|
|
3152
|
+
const getEffectiveOptions = (callSiteOpts, instance) => {
|
|
3153
|
+
const classOpts = installedClass.config?.pluginOptions?.geo;
|
|
3154
|
+
const instanceOpts = instance?.config?.pluginOptions?.geo;
|
|
3155
|
+
return {
|
|
3156
|
+
...isObject(options) ? options : {},
|
|
3157
|
+
...isObject(classOpts) ? classOpts : {},
|
|
3158
|
+
...isObject(instanceOpts) ? instanceOpts : {},
|
|
3159
|
+
...isObject(callSiteOpts) ? callSiteOpts : {}
|
|
3160
|
+
};
|
|
3161
|
+
};
|
|
3162
|
+
if (!Object.hasOwn(installedClass, "geo")) {
|
|
3163
|
+
const geoNamespace = {
|
|
3164
|
+
lookup: (opts) => geoLookup(getEffectiveOptions(opts)),
|
|
3165
|
+
resolve: (target, opts) => resolveGeoCoordinates(target, getEffectiveOptions(opts, target)),
|
|
3166
|
+
coerce: coerceGeo,
|
|
3167
|
+
distance: haversineDistance,
|
|
3168
|
+
solarOffset,
|
|
3169
|
+
stash: stashGeo,
|
|
3170
|
+
clear: clearStashedGeo,
|
|
3171
|
+
get: getStashedGeo,
|
|
3172
|
+
server: serverGeoLocation,
|
|
3173
|
+
browser: geoLocation,
|
|
3174
|
+
get current() {
|
|
3175
|
+
return getStashedGeo() ?? installedClass.config?.geo;
|
|
3176
|
+
}
|
|
3177
|
+
};
|
|
3178
|
+
Object.defineProperty(installedClass, "geo", {
|
|
3179
|
+
value: (0, sdk_exports.deepFreeze)(geoNamespace),
|
|
3180
|
+
writable: false,
|
|
3181
|
+
configurable: false,
|
|
3182
|
+
enumerable: false
|
|
3183
|
+
});
|
|
3184
|
+
}
|
|
2129
3185
|
TempoClass.prototype.geoLocate = async function(opts) {
|
|
2130
|
-
const
|
|
3186
|
+
const effectiveOpts = getEffectiveOptions(opts, this);
|
|
3187
|
+
const setTimezone = effectiveOpts?.setTimezone !== false;
|
|
3188
|
+
const coords = await resolveGeoCoordinates(this, effectiveOpts);
|
|
2131
3189
|
if (coords) {
|
|
2132
|
-
const existingGeo =
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
3190
|
+
const existingGeo = isObject(this.config.geo) ? this.config.geo : {};
|
|
3191
|
+
const customKeys = {};
|
|
3192
|
+
for (const key of Object.keys(existingGeo)) {
|
|
3193
|
+
if (isSafeKey(key) && !GEO_PROPERTIES.includes(key))
|
|
3194
|
+
customKeys[key] = existingGeo[key];
|
|
3195
|
+
}
|
|
3196
|
+
const callSiteGeo = coerceGeo(opts) ?? {};
|
|
3197
|
+
if (isObject(opts)) {
|
|
3198
|
+
for (const key of Object.keys(opts)) {
|
|
3199
|
+
if (isSafeKey(key) && !["setTimezone", "refresh", "ttl", "endpoint", "timeout", "catch", "debug", "geo"].includes(key)) {
|
|
3200
|
+
if (!GEO_PROPERTIES.includes(key))
|
|
3201
|
+
customKeys[key] = opts[key];
|
|
3202
|
+
}
|
|
2139
3203
|
}
|
|
3204
|
+
}
|
|
3205
|
+
const preservedElevation = isNumber(coords?.elevation) ? coords.elevation : isNumber(existingGeo.elevation) ? existingGeo.elevation : void 0;
|
|
3206
|
+
const mergedGeo = {
|
|
3207
|
+
...customKeys,
|
|
3208
|
+
...coords,
|
|
3209
|
+
...isNumber(preservedElevation) ? { elevation: preservedElevation } : {},
|
|
3210
|
+
...callSiteGeo
|
|
3211
|
+
};
|
|
3212
|
+
if (isNumber(mergedGeo.latitude)) mergedGeo.latitude = Math.round(mergedGeo.latitude * 1e3) / 1e3;
|
|
3213
|
+
if (isNumber(mergedGeo.longitude)) mergedGeo.longitude = Math.round(mergedGeo.longitude * 1e3) / 1e3;
|
|
3214
|
+
if (!mergedGeo.sphere && isNumber(mergedGeo.latitude)) {
|
|
3215
|
+
mergedGeo.sphere = mergedGeo.latitude > 1e-3 ? "north" : mergedGeo.latitude < -1e-3 ? "south" : "equator";
|
|
3216
|
+
}
|
|
3217
|
+
let instance = this;
|
|
3218
|
+
const targetTz = mergedGeo.timezone;
|
|
3219
|
+
if (setTimezone && isString(targetTz) && !isEmpty(targetTz))
|
|
3220
|
+
instance = this.set({ timeZone: targetTz });
|
|
3221
|
+
return new TempoClass(instance, {
|
|
3222
|
+
...instance.config,
|
|
3223
|
+
geo: (0, sdk_exports.deepFreeze)(mergedGeo),
|
|
3224
|
+
...mergedGeo.sphere ? { sphere: mergedGeo.sphere } : {}
|
|
2140
3225
|
});
|
|
2141
3226
|
}
|
|
2142
3227
|
return this;
|
|
2143
3228
|
};
|
|
2144
3229
|
TempoClass.prototype.geoLookup = async function(opts) {
|
|
2145
|
-
return resolveGeoCoordinates(this, opts);
|
|
3230
|
+
return resolveGeoCoordinates(this, getEffectiveOptions(opts, this));
|
|
3231
|
+
};
|
|
3232
|
+
TempoClass.prototype.geoDistance = function(other, unit) {
|
|
3233
|
+
return haversineDistance(this, other, unit);
|
|
3234
|
+
};
|
|
3235
|
+
TempoClass.prototype.geoSolarOffset = function(options2) {
|
|
3236
|
+
return solarOffset(this, options2);
|
|
2146
3237
|
};
|
|
2147
3238
|
}
|
|
2148
3239
|
});
|
|
2149
3240
|
var geoPlugin = GeoPlugin;
|
|
2150
3241
|
var index_default = GeoPlugin;
|
|
2151
3242
|
export {
|
|
3243
|
+
GEO_PROPERTIES,
|
|
2152
3244
|
GeoPlugin,
|
|
3245
|
+
clearStashedGeo,
|
|
2153
3246
|
coerceGeo,
|
|
2154
3247
|
index_default as default,
|
|
2155
3248
|
geoLocation,
|
|
2156
3249
|
geoLookup,
|
|
2157
3250
|
geoPlugin,
|
|
2158
3251
|
getStashedGeo,
|
|
3252
|
+
haversineDistance,
|
|
2159
3253
|
resolveGeoCoordinates,
|
|
2160
3254
|
serverGeoCoords,
|
|
2161
3255
|
serverGeoLocation,
|
|
2162
|
-
serverMapHemisphere
|
|
3256
|
+
serverMapHemisphere,
|
|
3257
|
+
solarOffset,
|
|
3258
|
+
stashGeo
|
|
2163
3259
|
};
|