@magmacomputing/tempo-plugin-geo 0.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 +21 -0
- package/LICENSE +21 -0
- package/README.md +55 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.global.min.js +1 -0
- package/dist/index.js +2163 -0
- package/package.json +56 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,2163 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __esm = (fn, res, err) => function __init() {
|
|
6
|
+
if (err) throw err[0];
|
|
7
|
+
try {
|
|
8
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
9
|
+
} catch (e) {
|
|
10
|
+
throw err = [e], e;
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
var __export = (target, all) => {
|
|
14
|
+
for (var name in all)
|
|
15
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
16
|
+
};
|
|
17
|
+
var __copyProps = (to, from, except, desc) => {
|
|
18
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
19
|
+
for (let key of __getOwnPropNames(from))
|
|
20
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
21
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
22
|
+
}
|
|
23
|
+
return to;
|
|
24
|
+
};
|
|
25
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
26
|
+
|
|
27
|
+
// ../../library/dist/common/primitives/symbol.library.js
|
|
28
|
+
var $Target, $Discover, $Extensible, $Inspect, $LogConfig, $Registry, $Register, $SerializerRegistry, $Mutable, $Identity, $Unwrapped, sym;
|
|
29
|
+
var init_symbol_library = __esm({
|
|
30
|
+
"../../library/dist/common/primitives/symbol.library.js"() {
|
|
31
|
+
"use strict";
|
|
32
|
+
$Target = /* @__PURE__ */ Symbol.for("$LibraryTarget");
|
|
33
|
+
$Discover = /* @__PURE__ */ Symbol.for("$LibraryDiscover");
|
|
34
|
+
$Extensible = /* @__PURE__ */ Symbol.for("$LibraryExtensible");
|
|
35
|
+
$Inspect = /* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom");
|
|
36
|
+
$LogConfig = /* @__PURE__ */ Symbol.for("$LibraryLogConfig");
|
|
37
|
+
$Registry = /* @__PURE__ */ Symbol.for("$LibraryRegistry");
|
|
38
|
+
$Register = /* @__PURE__ */ Symbol.for("$LibraryRegister");
|
|
39
|
+
$SerializerRegistry = /* @__PURE__ */ Symbol.for("$LibrarySerializerRegistry");
|
|
40
|
+
$Mutable = /* @__PURE__ */ Symbol.for("$LibraryMutable");
|
|
41
|
+
$Identity = /* @__PURE__ */ Symbol.for("$LibraryIdentity");
|
|
42
|
+
$Unwrapped = /* @__PURE__ */ Symbol.for("$LibraryUnwrapped");
|
|
43
|
+
sym = {
|
|
44
|
+
$Target,
|
|
45
|
+
$Discover,
|
|
46
|
+
$Extensible,
|
|
47
|
+
$Inspect,
|
|
48
|
+
$LogConfig,
|
|
49
|
+
$Registry,
|
|
50
|
+
$Register,
|
|
51
|
+
$SerializerRegistry,
|
|
52
|
+
$Identity,
|
|
53
|
+
$Mutable,
|
|
54
|
+
$Unwrapped
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
// ../../library/dist/common/primitives/primitive.library.js
|
|
60
|
+
function unwrap(obj) {
|
|
61
|
+
let curr = obj;
|
|
62
|
+
let depth = 0;
|
|
63
|
+
const maxDepth = 50;
|
|
64
|
+
while (curr) {
|
|
65
|
+
const next = curr[sym.$Target];
|
|
66
|
+
if (!next || depth >= maxDepth)
|
|
67
|
+
break;
|
|
68
|
+
curr = next;
|
|
69
|
+
depth++;
|
|
70
|
+
}
|
|
71
|
+
return curr;
|
|
72
|
+
}
|
|
73
|
+
function ownEntries(json, all = false) {
|
|
74
|
+
if (!json || typeof json !== "object")
|
|
75
|
+
return [];
|
|
76
|
+
const tgt = unwrap(json);
|
|
77
|
+
if (!all) {
|
|
78
|
+
const keys = Reflect.ownKeys(tgt);
|
|
79
|
+
const entries2 = [];
|
|
80
|
+
for (const k of keys) {
|
|
81
|
+
const desc = Object.getOwnPropertyDescriptor(tgt, k);
|
|
82
|
+
if (desc && desc.enumerable)
|
|
83
|
+
entries2.push([k, tgt[k]]);
|
|
84
|
+
}
|
|
85
|
+
return entries2;
|
|
86
|
+
}
|
|
87
|
+
const levels = [];
|
|
88
|
+
const limit = 50;
|
|
89
|
+
let depth = 0;
|
|
90
|
+
let curr = tgt;
|
|
91
|
+
while (curr && curr !== Object.prototype && depth++ < limit) {
|
|
92
|
+
levels.push(unwrap(curr));
|
|
93
|
+
curr = Object.getPrototypeOf(curr);
|
|
94
|
+
}
|
|
95
|
+
const entries = [];
|
|
96
|
+
const seen = /* @__PURE__ */ new Set();
|
|
97
|
+
for (const level of levels.reverse()) {
|
|
98
|
+
const keys = Reflect.ownKeys(level);
|
|
99
|
+
for (const k of keys) {
|
|
100
|
+
if (seen.has(k))
|
|
101
|
+
continue;
|
|
102
|
+
const desc = Object.getOwnPropertyDescriptor(level, k);
|
|
103
|
+
if (!desc || !desc.enumerable)
|
|
104
|
+
continue;
|
|
105
|
+
seen.add(k);
|
|
106
|
+
entries.push([k, tgt[k]]);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return entries;
|
|
110
|
+
}
|
|
111
|
+
function ownKeys(json, all = false) {
|
|
112
|
+
return ownEntries(json, all).map(([key]) => key);
|
|
113
|
+
}
|
|
114
|
+
function ownValues(json, all = false) {
|
|
115
|
+
return ownEntries(json, all).map(([_, value2]) => value2);
|
|
116
|
+
}
|
|
117
|
+
function distinct(arr, mapfn, thisArg) {
|
|
118
|
+
return mapfn ? distinct(arr.map(mapfn, thisArg)) : Array.from(new Set(arr));
|
|
119
|
+
}
|
|
120
|
+
var init_primitive_library = __esm({
|
|
121
|
+
"../../library/dist/common/primitives/primitive.library.js"() {
|
|
122
|
+
"use strict";
|
|
123
|
+
init_symbol_library();
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
// ../../library/dist/common/primitives/type.library.js
|
|
128
|
+
var registry, protoType, getSafeTag, getType, asType, classRegex, isClassConstructor, registerType;
|
|
129
|
+
var init_type_library = __esm({
|
|
130
|
+
"../../library/dist/common/primitives/type.library.js"() {
|
|
131
|
+
"use strict";
|
|
132
|
+
init_symbol_library();
|
|
133
|
+
init_primitive_library();
|
|
134
|
+
registry = [];
|
|
135
|
+
protoType = (obj) => {
|
|
136
|
+
if (obj === null)
|
|
137
|
+
return "Null";
|
|
138
|
+
if (obj === void 0)
|
|
139
|
+
return "Undefined";
|
|
140
|
+
const t = typeof obj;
|
|
141
|
+
if (t === "string")
|
|
142
|
+
return "String";
|
|
143
|
+
if (t === "number")
|
|
144
|
+
return "Number";
|
|
145
|
+
if (t === "boolean")
|
|
146
|
+
return "Boolean";
|
|
147
|
+
if (t === "bigint")
|
|
148
|
+
return "BigInt";
|
|
149
|
+
if (t === "symbol")
|
|
150
|
+
return "Symbol";
|
|
151
|
+
try {
|
|
152
|
+
const raw = t === "object" ? unwrap(obj) : obj;
|
|
153
|
+
return Object.prototype.toString.call(raw).slice(8, -1);
|
|
154
|
+
} catch {
|
|
155
|
+
return t === "function" ? "Function" : "Object";
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
getSafeTag = (obj) => {
|
|
159
|
+
try {
|
|
160
|
+
const tag2 = obj?.[Symbol.toStringTag] ?? obj?.prototype?.[Symbol.toStringTag];
|
|
161
|
+
if (typeof tag2 === "string")
|
|
162
|
+
return tag2;
|
|
163
|
+
} catch {
|
|
164
|
+
}
|
|
165
|
+
return void 0;
|
|
166
|
+
};
|
|
167
|
+
getType = (obj, ...instances) => {
|
|
168
|
+
let raw = obj;
|
|
169
|
+
try {
|
|
170
|
+
raw = obj?.[sym.$Target] ?? obj;
|
|
171
|
+
} catch {
|
|
172
|
+
raw = obj;
|
|
173
|
+
}
|
|
174
|
+
const type = protoType(raw);
|
|
175
|
+
switch (type) {
|
|
176
|
+
case "Function":
|
|
177
|
+
try {
|
|
178
|
+
return isClassConstructor(raw) ? "Class" : "Function";
|
|
179
|
+
} catch {
|
|
180
|
+
return "Function";
|
|
181
|
+
}
|
|
182
|
+
case "Object": {
|
|
183
|
+
try {
|
|
184
|
+
if ("length" in raw && Object.keys(raw).every((key) => key === "length" || Number.isFinite(Number(key))))
|
|
185
|
+
return "ArrayLike";
|
|
186
|
+
for (const inst of instances) {
|
|
187
|
+
const instRaw = inst.class?.[sym.$Target] ?? inst.class;
|
|
188
|
+
if (raw === instRaw || instRaw && raw instanceof instRaw)
|
|
189
|
+
return inst.type;
|
|
190
|
+
}
|
|
191
|
+
const globalRegistry = globalThis[sym.$Registry] ?? [];
|
|
192
|
+
for (const inst of [...registry, ...globalRegistry]) {
|
|
193
|
+
const instRaw = inst.class?.[sym.$Target] ?? inst.class;
|
|
194
|
+
if (raw === instRaw || instRaw && raw instanceof instRaw)
|
|
195
|
+
return inst.type;
|
|
196
|
+
}
|
|
197
|
+
} catch {
|
|
198
|
+
return "Object";
|
|
199
|
+
}
|
|
200
|
+
return "Object";
|
|
201
|
+
}
|
|
202
|
+
default:
|
|
203
|
+
return type;
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
asType = (value2, ...instances) => ({ type: getType(value2, ...instances), value: value2 });
|
|
207
|
+
classRegex = /^\s*(class\s|\[native code\])/;
|
|
208
|
+
isClassConstructor = (obj) => {
|
|
209
|
+
if (typeof obj !== "function")
|
|
210
|
+
return false;
|
|
211
|
+
const raw = obj?.[sym.$Target] ?? obj;
|
|
212
|
+
if (!("prototype" in raw))
|
|
213
|
+
return false;
|
|
214
|
+
const name = raw?.name;
|
|
215
|
+
const tag2 = getSafeTag(raw);
|
|
216
|
+
if (raw?.[sym.$Identity] || raw?.prototype?.[sym.$Identity]) {
|
|
217
|
+
return true;
|
|
218
|
+
}
|
|
219
|
+
if (typeof tag2 === "string" && tag2.startsWith("Temporal.")) {
|
|
220
|
+
return true;
|
|
221
|
+
}
|
|
222
|
+
if (typeof tag2 === "string" && tag2.endsWith("Function"))
|
|
223
|
+
return false;
|
|
224
|
+
const globalRegistry = globalThis[sym.$Registry] ?? [];
|
|
225
|
+
if (globalRegistry.some((inst) => (inst.class?.[sym.$Target] ?? inst.class) === raw || name && inst.type === name || tag2 && inst.type === tag2)) {
|
|
226
|
+
return true;
|
|
227
|
+
}
|
|
228
|
+
try {
|
|
229
|
+
const str = Function.prototype.toString.call(raw);
|
|
230
|
+
if (classRegex.test(str)) {
|
|
231
|
+
return true;
|
|
232
|
+
}
|
|
233
|
+
const descriptor = Object.getOwnPropertyDescriptor(raw, "prototype");
|
|
234
|
+
if (descriptor && descriptor.writable === false && !Object.isFrozen(raw)) {
|
|
235
|
+
return true;
|
|
236
|
+
}
|
|
237
|
+
const proto = raw.prototype;
|
|
238
|
+
if (proto && Object.getOwnPropertyNames(proto).length > 2) {
|
|
239
|
+
return true;
|
|
240
|
+
}
|
|
241
|
+
} catch {
|
|
242
|
+
return false;
|
|
243
|
+
}
|
|
244
|
+
return false;
|
|
245
|
+
};
|
|
246
|
+
registerType = (cls, type) => {
|
|
247
|
+
if (typeof cls !== "function")
|
|
248
|
+
return;
|
|
249
|
+
const tag2 = getSafeTag(cls);
|
|
250
|
+
const name = type ?? tag2 ?? cls.name;
|
|
251
|
+
if (name && !["Object", "Function", ""].includes(name)) {
|
|
252
|
+
if (!registry.some((inst) => inst.class === cls))
|
|
253
|
+
registry.push({ class: cls, type: name });
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
// ../../library/dist/common/primitives/assertion.library.js
|
|
260
|
+
var isType, isPrimitive, isReference, isString, isNumber, isInteger, isArray, isObject, isDate, isSymbol, isSymbolFor, isSafeKey, isNullish, isUndefined, isDefined, isFunction, isMap, isSet, isError, isEmpty;
|
|
261
|
+
var init_assertion_library = __esm({
|
|
262
|
+
"../../library/dist/common/primitives/assertion.library.js"() {
|
|
263
|
+
"use strict";
|
|
264
|
+
init_symbol_library();
|
|
265
|
+
init_type_library();
|
|
266
|
+
isType = (obj, ...types) => types.includes(getType(obj));
|
|
267
|
+
isPrimitive = (obj) => isType(obj, "String", "Number", "BigInt", "Boolean", "Symbol", "Undefined", "Void", "Null", "Empty");
|
|
268
|
+
isReference = (obj) => !isPrimitive(obj);
|
|
269
|
+
isString = (obj) => isType(obj, "String");
|
|
270
|
+
isNumber = (obj) => Number.isFinite(obj);
|
|
271
|
+
isInteger = (obj) => isType(obj, "BigInt");
|
|
272
|
+
isArray = (obj) => isType(obj, "Array");
|
|
273
|
+
isObject = (obj) => isType(obj, "Object");
|
|
274
|
+
isDate = (obj) => isType(obj, "Date");
|
|
275
|
+
isSymbol = (obj) => isType(obj, "Symbol");
|
|
276
|
+
isSymbolFor = (obj) => isType(obj, "Symbol") && Symbol.keyFor(obj) !== void 0;
|
|
277
|
+
isSafeKey = (key) => key !== "__proto__" && key !== "constructor" && key !== "prototype";
|
|
278
|
+
isNullish = (obj) => isType(obj, "Null", "Undefined", "Void", "Empty");
|
|
279
|
+
isUndefined = (obj) => isType(obj, "Undefined", "Void", "Empty");
|
|
280
|
+
isDefined = (obj) => !isNullish(obj);
|
|
281
|
+
isFunction = (obj) => isType(obj, "Function", "AsyncFunction", "GeneratorFunction", "AsyncGeneratorFunction");
|
|
282
|
+
isMap = (obj) => isType(obj, "Map");
|
|
283
|
+
isSet = (obj) => isType(obj, "Set");
|
|
284
|
+
isError = (err, constructor) => isType(err, "Error") && (constructor ? err instanceof constructor : true);
|
|
285
|
+
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
|
+
}
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
// ../../library/dist/common/runtime/utility.library.js
|
|
290
|
+
function deepFreeze(obj, options, seen = /* @__PURE__ */ new WeakSet()) {
|
|
291
|
+
const skip = options instanceof WeakSet ? options : options?.skip ?? EMPTY_SKIP;
|
|
292
|
+
if (isPrimitive(obj) || seen.has(obj) || skip.has(obj))
|
|
293
|
+
return obj;
|
|
294
|
+
if (obj instanceof Date || obj instanceof RegExp || obj instanceof Error || obj instanceof Map || obj instanceof Set || obj instanceof Promise)
|
|
295
|
+
return obj;
|
|
296
|
+
if (obj?.[Symbol.toStringTag] === "Enumify")
|
|
297
|
+
return obj;
|
|
298
|
+
if (obj[sym.$Extensible])
|
|
299
|
+
return obj;
|
|
300
|
+
seen.add(obj);
|
|
301
|
+
ownEntries(obj).forEach(([key, val]) => {
|
|
302
|
+
if (isSafeKey(key))
|
|
303
|
+
deepFreeze(val, { skip }, seen);
|
|
304
|
+
});
|
|
305
|
+
return Object.freeze(obj);
|
|
306
|
+
}
|
|
307
|
+
var CONTEXT, getContext, EMPTY_SKIP;
|
|
308
|
+
var init_utility_library = __esm({
|
|
309
|
+
"../../library/dist/common/runtime/utility.library.js"() {
|
|
310
|
+
"use strict";
|
|
311
|
+
init_primitive_library();
|
|
312
|
+
init_assertion_library();
|
|
313
|
+
init_symbol_library();
|
|
314
|
+
CONTEXT = {
|
|
315
|
+
"Unknown": "unknown",
|
|
316
|
+
"Browser": "browser",
|
|
317
|
+
"WebWorker": "web-worker",
|
|
318
|
+
"NodeJS": "nodejs",
|
|
319
|
+
"Deno": "deno",
|
|
320
|
+
"GoogleAppsScript": "google-apps-script"
|
|
321
|
+
};
|
|
322
|
+
getContext = () => {
|
|
323
|
+
const global = globalThis;
|
|
324
|
+
try {
|
|
325
|
+
if (isDefined(global.SpreadsheetApp))
|
|
326
|
+
return { global, type: CONTEXT.GoogleAppsScript };
|
|
327
|
+
if (isDefined(global.window?.document))
|
|
328
|
+
return { global, type: CONTEXT.Browser };
|
|
329
|
+
if (isFunction(global.importScripts) || isDefined(global.WorkerGlobalScope) && global instanceof global.WorkerGlobalScope)
|
|
330
|
+
return { global, type: CONTEXT.WebWorker };
|
|
331
|
+
if (isDefined(global.Deno))
|
|
332
|
+
return { global, type: CONTEXT.Deno };
|
|
333
|
+
if (isDefined(global.process?.versions?.node) && global.process?.release?.name === "node")
|
|
334
|
+
return { global, type: CONTEXT.NodeJS };
|
|
335
|
+
} catch {
|
|
336
|
+
}
|
|
337
|
+
return { global, type: CONTEXT.Unknown };
|
|
338
|
+
};
|
|
339
|
+
EMPTY_SKIP = /* @__PURE__ */ new WeakSet();
|
|
340
|
+
}
|
|
341
|
+
});
|
|
342
|
+
|
|
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
|
+
// ../../library/dist/common/runtime/reflection.library.js
|
|
375
|
+
function allObject(json) {
|
|
376
|
+
return Object.fromEntries(ownEntries(json, true));
|
|
377
|
+
}
|
|
378
|
+
var init_reflection_library = __esm({
|
|
379
|
+
"../../library/dist/common/runtime/reflection.library.js"() {
|
|
380
|
+
"use strict";
|
|
381
|
+
init_primitive_library();
|
|
382
|
+
init_type_library();
|
|
383
|
+
init_assertion_library();
|
|
384
|
+
}
|
|
385
|
+
});
|
|
386
|
+
|
|
387
|
+
// ../../library/dist/common/runtime/proxy.library.js
|
|
388
|
+
function factory(target, options = {}, isRevocable = false) {
|
|
389
|
+
const { frozen, lock, appendOnly, onGet, keys, bind, skip } = options;
|
|
390
|
+
const pending = /* @__PURE__ */ new Set();
|
|
391
|
+
let cachedJSON;
|
|
392
|
+
let result;
|
|
393
|
+
const tgt = unwrap(target);
|
|
394
|
+
if (lock)
|
|
395
|
+
deepFreeze(tgt, skip ? { skip } : void 0);
|
|
396
|
+
registerType(tgt);
|
|
397
|
+
const handler = {
|
|
398
|
+
isExtensible: (t) => Reflect.isExtensible(t),
|
|
399
|
+
getPrototypeOf: (t) => Reflect.getPrototypeOf(t),
|
|
400
|
+
setPrototypeOf: (t, proto) => {
|
|
401
|
+
if (frozen)
|
|
402
|
+
throw new TypeError("Security: Prototype mutation attempt on protected object");
|
|
403
|
+
return Reflect.setPrototypeOf(t, proto);
|
|
404
|
+
},
|
|
405
|
+
getOwnPropertyDescriptor: (t, k) => {
|
|
406
|
+
if (keys && !keys.includes(k))
|
|
407
|
+
return void 0;
|
|
408
|
+
if (keys) {
|
|
409
|
+
if (onGet && !isSymbol(k) && !pending.has(k)) {
|
|
410
|
+
pending.add(k);
|
|
411
|
+
try {
|
|
412
|
+
const value2 = onGet(k, t);
|
|
413
|
+
if (isDefined(value2))
|
|
414
|
+
return { enumerable: true, configurable: true, value: value2 };
|
|
415
|
+
} finally {
|
|
416
|
+
pending.delete(k);
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
return { enumerable: true, configurable: true };
|
|
420
|
+
}
|
|
421
|
+
return Reflect.getOwnPropertyDescriptor(t, k);
|
|
422
|
+
},
|
|
423
|
+
ownKeys: (t) => {
|
|
424
|
+
if (keys)
|
|
425
|
+
return keys;
|
|
426
|
+
if (onGet && !pending.has(sym.$Discover)) {
|
|
427
|
+
pending.add(sym.$Discover);
|
|
428
|
+
try {
|
|
429
|
+
onGet(sym.$Discover, t);
|
|
430
|
+
} finally {
|
|
431
|
+
pending.delete(sym.$Discover);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
return Reflect.ownKeys(t);
|
|
435
|
+
},
|
|
436
|
+
has: (t, k) => keys ? keys.includes(k) : Reflect.has(t, k),
|
|
437
|
+
deleteProperty: (t, k) => {
|
|
438
|
+
if (frozen)
|
|
439
|
+
throw new TypeError(`Cannot delete property '${String(k)}' from a protected object.`);
|
|
440
|
+
if (appendOnly && Reflect.has(t, k))
|
|
441
|
+
throw new Error(`Security: Deletion attempt on protected key '${String(k)}'`);
|
|
442
|
+
return Reflect.deleteProperty(t, k);
|
|
443
|
+
},
|
|
444
|
+
defineProperty: (t, k, d) => {
|
|
445
|
+
if (frozen && !Object.isFrozen(t))
|
|
446
|
+
throw new TypeError(`Cannot define property '${String(k)}' on a frozen object.`);
|
|
447
|
+
if (appendOnly && Reflect.has(t, k))
|
|
448
|
+
throw new Error(`Security: Mutation attempt on protected key '${String(k)}'`);
|
|
449
|
+
return Reflect.defineProperty(t, k, d);
|
|
450
|
+
},
|
|
451
|
+
set: (t, k, v, r) => {
|
|
452
|
+
if (frozen && r === result)
|
|
453
|
+
throw new TypeError(`Cannot set property '${String(k)}' on a frozen object.`);
|
|
454
|
+
if (appendOnly) {
|
|
455
|
+
const isTruncating = Array.isArray(t) && k === "length" && v < t.length;
|
|
456
|
+
if (isTruncating)
|
|
457
|
+
throw new Error("Security: Truncation attempt on protected array.");
|
|
458
|
+
if (!(Array.isArray(t) && k === "length") && Reflect.has(t, k))
|
|
459
|
+
throw new Error(`Security: Mutation attempt on protected key '${String(k)}'`);
|
|
460
|
+
}
|
|
461
|
+
return Reflect.set(t, k, v, r);
|
|
462
|
+
},
|
|
463
|
+
get: (t, k, r) => {
|
|
464
|
+
if (k === sym.$Target)
|
|
465
|
+
return r === result ? t : void 0;
|
|
466
|
+
if (frozen && (k === sym.$Inspect || k === "toJSON")) {
|
|
467
|
+
const own = Object.getOwnPropertyDescriptor(t, k);
|
|
468
|
+
if (own && isFunction(own.value))
|
|
469
|
+
return own.value;
|
|
470
|
+
if (!cachedJSON)
|
|
471
|
+
cachedJSON = () => allObject(t);
|
|
472
|
+
return cachedJSON;
|
|
473
|
+
}
|
|
474
|
+
if (keys && !keys.includes(k))
|
|
475
|
+
return void 0;
|
|
476
|
+
if (onGet && !isSymbol(k) && !Reflect.has(t, k) && !pending.has(k)) {
|
|
477
|
+
pending.add(k);
|
|
478
|
+
try {
|
|
479
|
+
const val2 = onGet(k, t);
|
|
480
|
+
if (isDefined(val2))
|
|
481
|
+
return val2;
|
|
482
|
+
} finally {
|
|
483
|
+
pending.delete(k);
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
const val = Reflect.get(t, k, r);
|
|
487
|
+
if (bind && k !== "constructor" && isFunction(val)) {
|
|
488
|
+
const desc = Object.getOwnPropertyDescriptor(t, k);
|
|
489
|
+
if (desc && !desc.configurable && !desc.writable)
|
|
490
|
+
return val;
|
|
491
|
+
let perTargetCache = boundMethodCache.get(val);
|
|
492
|
+
if (!perTargetCache) {
|
|
493
|
+
perTargetCache = /* @__PURE__ */ new WeakMap();
|
|
494
|
+
boundMethodCache.set(val, perTargetCache);
|
|
495
|
+
}
|
|
496
|
+
const cachedBound = perTargetCache.get(t);
|
|
497
|
+
if (cachedBound)
|
|
498
|
+
return cachedBound;
|
|
499
|
+
const bound = val.bind(t);
|
|
500
|
+
perTargetCache.set(t, bound);
|
|
501
|
+
return bound;
|
|
502
|
+
}
|
|
503
|
+
return val;
|
|
504
|
+
}
|
|
505
|
+
};
|
|
506
|
+
if (isRevocable) {
|
|
507
|
+
const revocableResult = Proxy.revocable(tgt, handler);
|
|
508
|
+
result = revocableResult.proxy;
|
|
509
|
+
return { proxy: revocableResult.proxy, revoke: revocableResult.revoke };
|
|
510
|
+
}
|
|
511
|
+
result = new Proxy(tgt, handler);
|
|
512
|
+
return result;
|
|
513
|
+
}
|
|
514
|
+
function proxify(target, frozen = true, lock = frozen, skip = /* @__PURE__ */ new WeakSet()) {
|
|
515
|
+
return factory(target, { frozen, lock, skip, bind: frozen });
|
|
516
|
+
}
|
|
517
|
+
function secure(obj, skip = /* @__PURE__ */ new WeakSet()) {
|
|
518
|
+
return factory(obj, { frozen: true, lock: true, skip, bind: true });
|
|
519
|
+
}
|
|
520
|
+
var boundMethodCache;
|
|
521
|
+
var init_proxy_library = __esm({
|
|
522
|
+
"../../library/dist/common/runtime/proxy.library.js"() {
|
|
523
|
+
"use strict";
|
|
524
|
+
init_symbol_library();
|
|
525
|
+
init_reflection_library();
|
|
526
|
+
init_utility_library();
|
|
527
|
+
init_primitive_library();
|
|
528
|
+
init_assertion_library();
|
|
529
|
+
init_type_library();
|
|
530
|
+
boundMethodCache = /* @__PURE__ */ new WeakMap();
|
|
531
|
+
}
|
|
532
|
+
});
|
|
533
|
+
|
|
534
|
+
// ../../library/dist/common/runtime/function.library.js
|
|
535
|
+
function serialize(val, seen = /* @__PURE__ */ new WeakSet()) {
|
|
536
|
+
return JSON.stringify(val, function(key, value2) {
|
|
537
|
+
if (value2 === void 0)
|
|
538
|
+
return "\0__undefined__\0";
|
|
539
|
+
if (isInteger(value2))
|
|
540
|
+
return `\0__bigint:${value2}__\0`;
|
|
541
|
+
if (isFunction(value2))
|
|
542
|
+
return `function:${value2.name || "anonymous"}`;
|
|
543
|
+
if (isReference(value2)) {
|
|
544
|
+
if (seen.has(value2))
|
|
545
|
+
return "<Circular>";
|
|
546
|
+
seen.add(value2);
|
|
547
|
+
if (isMap(value2))
|
|
548
|
+
return `map:[${Array.from(value2.entries()).map((e) => serialize(e, seen)).sort().join(",")}]`;
|
|
549
|
+
if (isSet(value2))
|
|
550
|
+
return `set:[${Array.from(value2).map((v) => serialize(v, seen)).sort().join(",")}]`;
|
|
551
|
+
}
|
|
552
|
+
return value2;
|
|
553
|
+
});
|
|
554
|
+
}
|
|
555
|
+
function curry(fn) {
|
|
556
|
+
return function curried(...args) {
|
|
557
|
+
return args.length >= fn.length ? fn(...args) : (...nextArgs) => curried(...args, ...nextArgs);
|
|
558
|
+
};
|
|
559
|
+
}
|
|
560
|
+
function memoizeFunction(fn) {
|
|
561
|
+
const cache = /* @__PURE__ */ new Map();
|
|
562
|
+
return function(...args) {
|
|
563
|
+
const key = this !== void 0 && this !== globalThis ? serialize([this, ...args]) : serialize(args);
|
|
564
|
+
if (!cache.has(key)) {
|
|
565
|
+
const result = fn.apply(this, args);
|
|
566
|
+
cache.set(key, result);
|
|
567
|
+
}
|
|
568
|
+
return cache.get(key);
|
|
569
|
+
};
|
|
570
|
+
}
|
|
571
|
+
function memoizeMethod(name, fn) {
|
|
572
|
+
return {
|
|
573
|
+
enumerable: false,
|
|
574
|
+
configurable: false,
|
|
575
|
+
writable: false,
|
|
576
|
+
value: function(...args) {
|
|
577
|
+
const key = `${String(name)},${serialize(args)}`;
|
|
578
|
+
let cache = wm.get(this);
|
|
579
|
+
if (!cache) {
|
|
580
|
+
cache = /* @__PURE__ */ new Map();
|
|
581
|
+
wm.set(this, cache);
|
|
582
|
+
}
|
|
583
|
+
if (!cache.has(key)) {
|
|
584
|
+
const result = fn.apply(this, args);
|
|
585
|
+
secure(result);
|
|
586
|
+
cache.set(key, result);
|
|
587
|
+
}
|
|
588
|
+
return cache.get(key);
|
|
589
|
+
}
|
|
590
|
+
};
|
|
591
|
+
}
|
|
592
|
+
var wm;
|
|
593
|
+
var init_function_library = __esm({
|
|
594
|
+
"../../library/dist/common/runtime/function.library.js"() {
|
|
595
|
+
"use strict";
|
|
596
|
+
init_proxy_library();
|
|
597
|
+
init_assertion_library();
|
|
598
|
+
wm = /* @__PURE__ */ new WeakMap();
|
|
599
|
+
}
|
|
600
|
+
});
|
|
601
|
+
|
|
602
|
+
// ../../library/dist/common/runtime/json.library.js
|
|
603
|
+
var init_json_library = __esm({
|
|
604
|
+
"../../library/dist/common/runtime/json.library.js"() {
|
|
605
|
+
"use strict";
|
|
606
|
+
}
|
|
607
|
+
});
|
|
608
|
+
|
|
609
|
+
// ../../library/dist/common/runtime/serialize.library.js
|
|
610
|
+
function replacer(key, obj) {
|
|
611
|
+
return isEmpty(key) ? obj : stringize(obj);
|
|
612
|
+
}
|
|
613
|
+
function reviver(_key, val) {
|
|
614
|
+
return decode(val);
|
|
615
|
+
}
|
|
616
|
+
function encode(val) {
|
|
617
|
+
let enc = encodeURI(val);
|
|
618
|
+
if (enc.includes("%"))
|
|
619
|
+
enc = enc.replace(RE_SAFE_URI_CODES, (match) => SAFE_URI_MAP[match.toUpperCase()] ?? decodeURI(match));
|
|
620
|
+
return enc;
|
|
621
|
+
}
|
|
622
|
+
function decode(val) {
|
|
623
|
+
if (isString(val)) {
|
|
624
|
+
try {
|
|
625
|
+
return decodeURI(val);
|
|
626
|
+
} catch (error) {
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
return val;
|
|
630
|
+
}
|
|
631
|
+
function isStringable(val) {
|
|
632
|
+
return !isType(val, "Function", "AsyncFunction", "WeakMap", "WeakSet", "WeakRef");
|
|
633
|
+
}
|
|
634
|
+
function oneKey(type, value2) {
|
|
635
|
+
return `{"$${type}":${value2}}`;
|
|
636
|
+
}
|
|
637
|
+
function fromSymbol(key) {
|
|
638
|
+
return stringize(isSymbol(key) ? `${isSymbolFor(key) ? "@" : ""}@(${key.description ?? ""})` : key);
|
|
639
|
+
}
|
|
640
|
+
function toSymbol(value2) {
|
|
641
|
+
const [pat, keyFor, desc] = value2.toString().match(symKey) || [null, void 0, void 0];
|
|
642
|
+
switch (true) {
|
|
643
|
+
case isSymbol(value2):
|
|
644
|
+
// already a Symbol
|
|
645
|
+
case isNullish(pat):
|
|
646
|
+
// incorrectly encoded Symbol
|
|
647
|
+
case (isDefined(keyFor) && isUndefined(desc)):
|
|
648
|
+
return value2;
|
|
649
|
+
case isDefined(keyFor):
|
|
650
|
+
return Symbol.for(desc);
|
|
651
|
+
case isUndefined(keyFor):
|
|
652
|
+
// local Symbol
|
|
653
|
+
default:
|
|
654
|
+
return Symbol(desc);
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
function stringify(obj) {
|
|
658
|
+
return stringize(obj, false);
|
|
659
|
+
}
|
|
660
|
+
function stringize(obj, recurse = true) {
|
|
661
|
+
const arg = asType(obj);
|
|
662
|
+
const one = curry(oneKey)(arg.type);
|
|
663
|
+
switch (arg.type) {
|
|
664
|
+
case "String":
|
|
665
|
+
if (!recurse) {
|
|
666
|
+
recurse = arg.value === "true" || arg.value === "false" || arg.value === "null" || parseFloat(arg.value).toString() === arg.value;
|
|
667
|
+
}
|
|
668
|
+
return recurse ? JSON.stringify(encode(arg.value)) : encode(arg.value);
|
|
669
|
+
// dont JSON.stringify a top-level string
|
|
670
|
+
case "Boolean":
|
|
671
|
+
case "Null":
|
|
672
|
+
case "Number":
|
|
673
|
+
return JSON.stringify(arg.value);
|
|
674
|
+
// JSON.stringify will correctly handle these
|
|
675
|
+
case "Void":
|
|
676
|
+
case "Undefined":
|
|
677
|
+
return one(JSON.stringify("void"));
|
|
678
|
+
// preserve 'undefined' values
|
|
679
|
+
case "BigInt":
|
|
680
|
+
return one(arg.value.toString());
|
|
681
|
+
// even though BigInt has a toString method, it is not supported in JSON.stringify
|
|
682
|
+
case "Object": {
|
|
683
|
+
const obj2 = ownEntries(arg.value).filter(([, val]) => isStringable(val)).map(([key, val]) => `${fromSymbol(key)}: ${stringize(val)}`).join(",");
|
|
684
|
+
return `{${obj2}}`;
|
|
685
|
+
}
|
|
686
|
+
case "Array": {
|
|
687
|
+
const arr = arg.value.filter((val) => isStringable(val)).map((val) => stringize(val)).join(",");
|
|
688
|
+
return `[${arr}]`;
|
|
689
|
+
}
|
|
690
|
+
case "Map": {
|
|
691
|
+
const map = Array.from(arg.value.entries()).filter(([, val]) => isStringable(val)).map(([key, val]) => `[${stringize(key)}, ${stringize(val)}]`).join(",");
|
|
692
|
+
return one(`[${map}]`);
|
|
693
|
+
}
|
|
694
|
+
case "Set": {
|
|
695
|
+
const set = Array.from(arg.value.values()).filter((val) => isStringable(val)).map((val) => stringize(val)).join(",");
|
|
696
|
+
return one(`[${set}]`);
|
|
697
|
+
}
|
|
698
|
+
case "Symbol":
|
|
699
|
+
return one(fromSymbol(arg.value));
|
|
700
|
+
case "RegExp":
|
|
701
|
+
return one(stringize({ source: arg.value.source, flags: arg.value.flags }));
|
|
702
|
+
case "Class":
|
|
703
|
+
default: {
|
|
704
|
+
const value2 = arg.value;
|
|
705
|
+
switch (true) {
|
|
706
|
+
case !isStringable(value2):
|
|
707
|
+
return void 0;
|
|
708
|
+
case isFunction(value2.toJSON):
|
|
709
|
+
return one(stringize(value2.toJSON()));
|
|
710
|
+
case isFunction(value2.toString): {
|
|
711
|
+
const str = value2.toString();
|
|
712
|
+
return one(str.includes('"') ? str : JSON.stringify(str));
|
|
713
|
+
}
|
|
714
|
+
case isFunction(value2.valueOf):
|
|
715
|
+
return one(JSON.stringify(value2.valueOf()));
|
|
716
|
+
default:
|
|
717
|
+
return one(JSON.stringify(value2, replacer));
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
function objectify(str, sentinel) {
|
|
723
|
+
if (!isString(str))
|
|
724
|
+
return str;
|
|
725
|
+
let parse;
|
|
726
|
+
try {
|
|
727
|
+
parse = JSON.parse(str, reviver);
|
|
728
|
+
} catch (error) {
|
|
729
|
+
if (str.startsWith('"') && str.endsWith('"')) {
|
|
730
|
+
console.warn(`objectify.parse: -> ${str}, ${error.message}`);
|
|
731
|
+
return str;
|
|
732
|
+
} else
|
|
733
|
+
return objectify(`"${str}"`, sentinel);
|
|
734
|
+
}
|
|
735
|
+
switch (true) {
|
|
736
|
+
case (str.startsWith("{") && str.endsWith("}")):
|
|
737
|
+
// looks like Object
|
|
738
|
+
case (str.startsWith("[") && str.endsWith("]")):
|
|
739
|
+
return traverse(parse, sentinel);
|
|
740
|
+
// recurse into object
|
|
741
|
+
default:
|
|
742
|
+
return parse;
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
function traverse(obj, sentinel) {
|
|
746
|
+
if (isObject(obj)) {
|
|
747
|
+
return typeify(ownEntries(obj).reduce((acc, [key, val]) => Object.assign(acc, { [toSymbol(key)]: typeify(traverse(val, sentinel)) }), {}), sentinel);
|
|
748
|
+
}
|
|
749
|
+
if (isArray(obj)) {
|
|
750
|
+
return ownValues(obj).map((val) => typeify(traverse(val, sentinel)));
|
|
751
|
+
}
|
|
752
|
+
return obj;
|
|
753
|
+
}
|
|
754
|
+
function typeify(json, sentinel) {
|
|
755
|
+
if (!isObject(json) || ownKeys(json).length !== 1)
|
|
756
|
+
return json;
|
|
757
|
+
const [$type, value2] = ownEntries(json)[0];
|
|
758
|
+
if (!String($type).startsWith("$"))
|
|
759
|
+
return json;
|
|
760
|
+
const type = $type.substring(1);
|
|
761
|
+
try {
|
|
762
|
+
switch (type) {
|
|
763
|
+
case "String":
|
|
764
|
+
case "Boolean":
|
|
765
|
+
case "Object":
|
|
766
|
+
case "Array":
|
|
767
|
+
return value2;
|
|
768
|
+
// these types are already handled by traverse()
|
|
769
|
+
case "Number":
|
|
770
|
+
return Number(value2);
|
|
771
|
+
case "BigInt":
|
|
772
|
+
return BigInt(value2);
|
|
773
|
+
case "Null":
|
|
774
|
+
return null;
|
|
775
|
+
case "Undefined":
|
|
776
|
+
case "Empty":
|
|
777
|
+
case "Void":
|
|
778
|
+
return sentinel?.();
|
|
779
|
+
// run Sentinel function to handle undefined values
|
|
780
|
+
case "Date":
|
|
781
|
+
return new Date(value2);
|
|
782
|
+
case "RegExp":
|
|
783
|
+
if (!isObject(value2) || !isString(value2.source))
|
|
784
|
+
return json;
|
|
785
|
+
return new RegExp(value2.source, value2.flags);
|
|
786
|
+
case "Symbol":
|
|
787
|
+
return toSymbol(value2);
|
|
788
|
+
case "Map":
|
|
789
|
+
if (!isArray(value2))
|
|
790
|
+
return json;
|
|
791
|
+
return new Map(value2);
|
|
792
|
+
case "Set":
|
|
793
|
+
if (!isArray(value2))
|
|
794
|
+
return json;
|
|
795
|
+
return new Set(value2);
|
|
796
|
+
default:
|
|
797
|
+
const cls = Registry.get($type);
|
|
798
|
+
if (!cls) {
|
|
799
|
+
console.warn(`objectify: dont know how to deserialize '${type}'`);
|
|
800
|
+
return json;
|
|
801
|
+
}
|
|
802
|
+
return Reflect.construct(cls, [value2]);
|
|
803
|
+
}
|
|
804
|
+
} catch {
|
|
805
|
+
return json;
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
var Registry, getSafeTag2, registerSerializable, SAFE_URI_MAP, RE_SAFE_URI_CODES, symKey;
|
|
809
|
+
var init_serialize_library = __esm({
|
|
810
|
+
"../../library/dist/common/runtime/serialize.library.js"() {
|
|
811
|
+
"use strict";
|
|
812
|
+
init_function_library();
|
|
813
|
+
init_primitive_library();
|
|
814
|
+
init_json_library();
|
|
815
|
+
init_type_library();
|
|
816
|
+
init_assertion_library();
|
|
817
|
+
init_symbol_library();
|
|
818
|
+
Registry = globalThis[sym.$SerializerRegistry] ??= /* @__PURE__ */ new Map();
|
|
819
|
+
getSafeTag2 = (c) => {
|
|
820
|
+
try {
|
|
821
|
+
const tag2 = c?.prototype?.[Symbol.toStringTag] ?? c?.[Symbol.toStringTag];
|
|
822
|
+
return isString(tag2) ? tag2 : void 0;
|
|
823
|
+
} catch {
|
|
824
|
+
return void 0;
|
|
825
|
+
}
|
|
826
|
+
};
|
|
827
|
+
registerSerializable = (name, cls) => {
|
|
828
|
+
const key = name.startsWith("$") ? name : `$${name}`;
|
|
829
|
+
if (Registry.has(key)) {
|
|
830
|
+
const existingCls = Registry.get(key);
|
|
831
|
+
const existingTag = getSafeTag2(existingCls);
|
|
832
|
+
const clsTag = getSafeTag2(cls);
|
|
833
|
+
const existingName = existingCls.name || existingTag;
|
|
834
|
+
const currentName = cls.name || clsTag || (name.startsWith("$") ? name.slice(1) : name);
|
|
835
|
+
const isSameConstructor = existingCls === cls || existingCls.toString() === cls.toString() || Boolean(cls[sym.$Identity]) && existingCls[sym.$Identity] === cls[sym.$Identity] || Boolean(cls[sym.$Target]) && existingCls[sym.$Target] === cls[sym.$Target] || Boolean(existingName) && Boolean(currentName) && existingName === currentName;
|
|
836
|
+
if (isSameConstructor)
|
|
837
|
+
return;
|
|
838
|
+
throw new Error(`[registerSerializable] Collision: '${key}' is already registered with ${existingCls.name || "anonymous constructor"}`);
|
|
839
|
+
}
|
|
840
|
+
Registry.set(key, cls);
|
|
841
|
+
};
|
|
842
|
+
SAFE_URI_MAP = {
|
|
843
|
+
"%20": " ",
|
|
844
|
+
"%22": '"',
|
|
845
|
+
"%3B": ";",
|
|
846
|
+
"%3C": "<",
|
|
847
|
+
"%3E": ">",
|
|
848
|
+
"%5B": "[",
|
|
849
|
+
"%5D": "]",
|
|
850
|
+
"%5E": "^",
|
|
851
|
+
"%7B": "{",
|
|
852
|
+
"%7C": "|",
|
|
853
|
+
"%7D": "}"
|
|
854
|
+
};
|
|
855
|
+
RE_SAFE_URI_CODES = new RegExp(Object.keys(SAFE_URI_MAP).join("|"), "gi");
|
|
856
|
+
symKey = /^@(@)?\(([^\)]*)\)$/;
|
|
857
|
+
}
|
|
858
|
+
});
|
|
859
|
+
|
|
860
|
+
// ../../library/dist/common/primitives/string.library.js
|
|
861
|
+
var init_string_library = __esm({
|
|
862
|
+
"../../library/dist/common/primitives/string.library.js"() {
|
|
863
|
+
"use strict";
|
|
864
|
+
init_serialize_library();
|
|
865
|
+
init_assertion_library();
|
|
866
|
+
}
|
|
867
|
+
});
|
|
868
|
+
|
|
869
|
+
// ../../library/dist/common/primitives/coercion.library.js
|
|
870
|
+
function asError(err) {
|
|
871
|
+
if (isError(err))
|
|
872
|
+
return err;
|
|
873
|
+
const error = new Error(isObject(err) && isString(err.message) ? err.message : String(err));
|
|
874
|
+
if (isObject(err)) {
|
|
875
|
+
error.name = isString(err.name) ? err.name : "Error";
|
|
876
|
+
if ("code" in err && (isString(err.code) || isNumber(err.code)))
|
|
877
|
+
error.code = err.code;
|
|
878
|
+
if ("stack" in err && isString(err.stack))
|
|
879
|
+
error.stack = err.stack;
|
|
880
|
+
}
|
|
881
|
+
return error;
|
|
882
|
+
}
|
|
883
|
+
var MAX_SAFE_INTEGER_BIGINT, MIN_SAFE_INTEGER_BIGINT;
|
|
884
|
+
var init_coercion_library = __esm({
|
|
885
|
+
"../../library/dist/common/primitives/coercion.library.js"() {
|
|
886
|
+
"use strict";
|
|
887
|
+
init_serialize_library();
|
|
888
|
+
init_type_library();
|
|
889
|
+
init_assertion_library();
|
|
890
|
+
init_string_library();
|
|
891
|
+
MAX_SAFE_INTEGER_BIGINT = BigInt(Number.MAX_SAFE_INTEGER);
|
|
892
|
+
MIN_SAFE_INTEGER_BIGINT = BigInt(Number.MIN_SAFE_INTEGER);
|
|
893
|
+
}
|
|
894
|
+
});
|
|
895
|
+
|
|
896
|
+
// ../../library/dist/common/temporal/temporal.polyfill.js
|
|
897
|
+
var init_temporal_polyfill = __esm({
|
|
898
|
+
"../../library/dist/common/temporal/temporal.polyfill.js"() {
|
|
899
|
+
"use strict";
|
|
900
|
+
init_coercion_library();
|
|
901
|
+
if (typeof globalThis.Temporal === "undefined") {
|
|
902
|
+
throw new Error("Temporal API is not available. Node 20+ with a polyfill (e.g. @js-temporal/polyfill) is highly recommended. Native Temporal is fully reliable only on Node 26+ (while Node 22 may have instabilities).");
|
|
903
|
+
}
|
|
904
|
+
try {
|
|
905
|
+
if (typeof Temporal.Now.zonedDateTimeISO === "function") {
|
|
906
|
+
const zdt = Temporal.Now.zonedDateTimeISO();
|
|
907
|
+
if (typeof zdt.add !== "function")
|
|
908
|
+
throw new Error("Incomplete Temporal implementation");
|
|
909
|
+
}
|
|
910
|
+
} catch (err) {
|
|
911
|
+
const error = asError(err);
|
|
912
|
+
console.warn("Tempo: Native Temporal implementation appears incomplete. Consider loading a polyfill.", error);
|
|
913
|
+
if (error.message !== "Incomplete Temporal implementation")
|
|
914
|
+
throw error;
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
});
|
|
918
|
+
|
|
919
|
+
// ../../library/dist/common/temporal/temporal.library.js
|
|
920
|
+
function instant() {
|
|
921
|
+
return Temporal.Now.instant();
|
|
922
|
+
}
|
|
923
|
+
function getOffsets(timeZone, year = 2024) {
|
|
924
|
+
const jan = Temporal.ZonedDateTime.from({ year, month: 1, day: 1, hour: 0, minute: 0, second: 0, timeZone }).offsetNanoseconds;
|
|
925
|
+
const jul = Temporal.ZonedDateTime.from({ year, month: 7, day: 1, hour: 0, minute: 0, second: 0, timeZone }).offsetNanoseconds;
|
|
926
|
+
return { jan, jul };
|
|
927
|
+
}
|
|
928
|
+
var init_temporal_library = __esm({
|
|
929
|
+
"../../library/dist/common/temporal/temporal.library.js"() {
|
|
930
|
+
"use strict";
|
|
931
|
+
init_temporal_polyfill();
|
|
932
|
+
init_assertion_library();
|
|
933
|
+
}
|
|
934
|
+
});
|
|
935
|
+
|
|
936
|
+
// ../../library/dist/common/runtime/international.library.js
|
|
937
|
+
function getDateTimeFormat() {
|
|
938
|
+
return getDTF().resolvedOptions();
|
|
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) {
|
|
954
|
+
return void 0;
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
var getRTF, getLF, getDTF, getPR, getNF, getDF;
|
|
958
|
+
var init_international_library = __esm({
|
|
959
|
+
"../../library/dist/common/runtime/international.library.js"() {
|
|
960
|
+
"use strict";
|
|
961
|
+
init_temporal_library();
|
|
962
|
+
init_function_library();
|
|
963
|
+
init_assertion_library();
|
|
964
|
+
getRTF = memoizeFunction((locale, style = "narrow", numeric = "always") => {
|
|
965
|
+
return new Intl.RelativeTimeFormat(locale, { style, numeric });
|
|
966
|
+
});
|
|
967
|
+
getLF = memoizeFunction((locale, type = "conjunction", style = "long") => {
|
|
968
|
+
return new Intl.ListFormat(locale, { type, style });
|
|
969
|
+
});
|
|
970
|
+
getDTF = memoizeFunction((locale, options) => {
|
|
971
|
+
return new Intl.DateTimeFormat(locale, options);
|
|
972
|
+
});
|
|
973
|
+
getPR = memoizeFunction((locale, options) => {
|
|
974
|
+
try {
|
|
975
|
+
return new Intl.PluralRules(locale, options);
|
|
976
|
+
} catch (e) {
|
|
977
|
+
return { select: () => "other" };
|
|
978
|
+
}
|
|
979
|
+
});
|
|
980
|
+
getNF = memoizeFunction((locale, options) => {
|
|
981
|
+
return new Intl.NumberFormat(locale, options);
|
|
982
|
+
});
|
|
983
|
+
getDF = memoizeFunction((locale, options) => {
|
|
984
|
+
try {
|
|
985
|
+
const df = new Intl.DurationFormat(locale, options);
|
|
986
|
+
if (isFunction(df.format))
|
|
987
|
+
return df;
|
|
988
|
+
throw new Error("No format method");
|
|
989
|
+
} catch (e) {
|
|
990
|
+
return { format: (duration) => String(duration) };
|
|
991
|
+
}
|
|
992
|
+
});
|
|
993
|
+
}
|
|
994
|
+
});
|
|
995
|
+
|
|
996
|
+
// ../../../node_modules/tslib/tslib.es6.mjs
|
|
997
|
+
function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
998
|
+
function accept(f) {
|
|
999
|
+
if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected");
|
|
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
|
+
}
|
|
1082
|
+
}
|
|
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();
|
|
1100
|
+
}
|
|
1101
|
+
});
|
|
1102
|
+
|
|
1103
|
+
// ../../library/dist/common/runtime/enumerate.library.js
|
|
1104
|
+
function value(val) {
|
|
1105
|
+
return { enumerable: false, configurable: false, writable: false, value: val };
|
|
1106
|
+
}
|
|
1107
|
+
function enumify(list, frozen = true) {
|
|
1108
|
+
const type = getType(this);
|
|
1109
|
+
const proto = type !== "Module" && isFunction(this?.has) ? this : ENUM;
|
|
1110
|
+
const arg = asType(list);
|
|
1111
|
+
const target = Object.create(proto);
|
|
1112
|
+
switch (arg.type) {
|
|
1113
|
+
case "Enumify":
|
|
1114
|
+
case "Object":
|
|
1115
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(arg.value));
|
|
1116
|
+
break;
|
|
1117
|
+
case "Array":
|
|
1118
|
+
arg.value.forEach((key, index) => {
|
|
1119
|
+
if (isNumber(key))
|
|
1120
|
+
throw new Error("Enumify: numeric keys are not supported");
|
|
1121
|
+
target[key] = index;
|
|
1122
|
+
});
|
|
1123
|
+
break;
|
|
1124
|
+
default:
|
|
1125
|
+
throw new Error(`Enumify: invalid argument type: ${arg.type}`);
|
|
1126
|
+
}
|
|
1127
|
+
return proxify(target, true, frozen);
|
|
1128
|
+
}
|
|
1129
|
+
var tag, ENUM, Enumify;
|
|
1130
|
+
var init_enumerate_library = __esm({
|
|
1131
|
+
"../../library/dist/common/runtime/enumerate.library.js"() {
|
|
1132
|
+
"use strict";
|
|
1133
|
+
init_tslib_es6();
|
|
1134
|
+
init_type_library();
|
|
1135
|
+
init_assertion_library();
|
|
1136
|
+
init_primitive_library();
|
|
1137
|
+
init_proxy_library();
|
|
1138
|
+
init_decorator_library();
|
|
1139
|
+
init_function_library();
|
|
1140
|
+
tag = "Enumify";
|
|
1141
|
+
ENUM = secure(Object.create(null, {
|
|
1142
|
+
keys: memoizeMethod("keys", function() {
|
|
1143
|
+
return ownEntries(this, true).map(([key]) => key);
|
|
1144
|
+
}),
|
|
1145
|
+
values: memoizeMethod("values", function() {
|
|
1146
|
+
return ownEntries(this, true).map(([_, val]) => val);
|
|
1147
|
+
}),
|
|
1148
|
+
entries: memoizeMethod("entries", function() {
|
|
1149
|
+
return ownEntries(this, true).map(([key, val]) => Object.freeze([key, val]));
|
|
1150
|
+
}),
|
|
1151
|
+
invert: memoizeMethod("invert", function() {
|
|
1152
|
+
return Object.fromEntries(this.entries().map(([key, val]) => [val, key]));
|
|
1153
|
+
}),
|
|
1154
|
+
has: value(function(key) {
|
|
1155
|
+
return this.keys().includes(key);
|
|
1156
|
+
}),
|
|
1157
|
+
count: value(function() {
|
|
1158
|
+
return this.keys().length;
|
|
1159
|
+
}),
|
|
1160
|
+
includes: value(function(search) {
|
|
1161
|
+
return this.values().includes(search);
|
|
1162
|
+
}),
|
|
1163
|
+
keyOf: value(function(search) {
|
|
1164
|
+
return this.invert()[search];
|
|
1165
|
+
}),
|
|
1166
|
+
extend: value(function(list, frozen) {
|
|
1167
|
+
return enumify.call(this, list, frozen);
|
|
1168
|
+
}),
|
|
1169
|
+
forEach: value(function(fn, thisArg) {
|
|
1170
|
+
this.entries().forEach((entry, index) => fn.call(thisArg, entry, index, this));
|
|
1171
|
+
}),
|
|
1172
|
+
filter: value(function(fn, thisArg) {
|
|
1173
|
+
return enumify(this.entries().reduce((acc, entry, index) => fn.call(thisArg, entry, index, this) ? Object.assign(acc, { [entry[0]]: entry[1] }) : acc, {}));
|
|
1174
|
+
}),
|
|
1175
|
+
map: value(function(fn, thisArg) {
|
|
1176
|
+
return enumify(this.entries().reduce((acc, entry, index) => Object.assign(acc, { [entry[0]]: fn.call(thisArg, entry, index, this) }), {}));
|
|
1177
|
+
}),
|
|
1178
|
+
[Symbol.iterator]: value(function* () {
|
|
1179
|
+
for (const entry of this.entries())
|
|
1180
|
+
yield entry;
|
|
1181
|
+
}),
|
|
1182
|
+
[Symbol.toStringTag]: { enumerable: false, configurable: false, writable: false, value: tag }
|
|
1183
|
+
}));
|
|
1184
|
+
Enumify = (() => {
|
|
1185
|
+
let _classDecorators = [Serializable, StringTag("Enumify")];
|
|
1186
|
+
let _classDescriptor;
|
|
1187
|
+
let _classExtraInitializers = [];
|
|
1188
|
+
let _classThis;
|
|
1189
|
+
var Enumify2 = class {
|
|
1190
|
+
static {
|
|
1191
|
+
_classThis = this;
|
|
1192
|
+
}
|
|
1193
|
+
static {
|
|
1194
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? /* @__PURE__ */ Object.create(null) : void 0;
|
|
1195
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
1196
|
+
Enumify2 = _classThis = _classDescriptor.value;
|
|
1197
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
1198
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
1199
|
+
}
|
|
1200
|
+
constructor(list) {
|
|
1201
|
+
return enumify(list);
|
|
1202
|
+
}
|
|
1203
|
+
};
|
|
1204
|
+
return Enumify2 = _classThis;
|
|
1205
|
+
})();
|
|
1206
|
+
}
|
|
1207
|
+
});
|
|
1208
|
+
|
|
1209
|
+
// ../../library/dist/common/runtime/logger.class.js
|
|
1210
|
+
function parseLogLevel(level, fallback = LOG.Info) {
|
|
1211
|
+
if (isNumber(level))
|
|
1212
|
+
return level >= LOG.Off && level <= LOG.Trace ? level : fallback;
|
|
1213
|
+
if (isString(level))
|
|
1214
|
+
return Level[level.toLowerCase()] ?? fallback;
|
|
1215
|
+
return fallback;
|
|
1216
|
+
}
|
|
1217
|
+
var LOG, Method, Level, Logger;
|
|
1218
|
+
var init_logger_class = __esm({
|
|
1219
|
+
"../../library/dist/common/runtime/logger.class.js"() {
|
|
1220
|
+
"use strict";
|
|
1221
|
+
init_tslib_es6();
|
|
1222
|
+
init_assertion_library();
|
|
1223
|
+
init_enumerate_library();
|
|
1224
|
+
init_symbol_library();
|
|
1225
|
+
init_decorator_library();
|
|
1226
|
+
LOG = enumify(["Off", "Error", "Warn", "Info", "Debug", "Trace"]);
|
|
1227
|
+
Method = {
|
|
1228
|
+
Off: "off",
|
|
1229
|
+
Log: "log",
|
|
1230
|
+
Info: "info",
|
|
1231
|
+
Warn: "warn",
|
|
1232
|
+
Debug: "debug",
|
|
1233
|
+
Trace: "trace",
|
|
1234
|
+
Error: "error"
|
|
1235
|
+
};
|
|
1236
|
+
Level = {
|
|
1237
|
+
[Method.Off]: LOG.Off,
|
|
1238
|
+
[Method.Error]: LOG.Error,
|
|
1239
|
+
[Method.Warn]: LOG.Warn,
|
|
1240
|
+
[Method.Info]: LOG.Info,
|
|
1241
|
+
[Method.Log]: LOG.Info,
|
|
1242
|
+
[Method.Debug]: LOG.Debug,
|
|
1243
|
+
[Method.Trace]: LOG.Trace
|
|
1244
|
+
};
|
|
1245
|
+
Logger = (() => {
|
|
1246
|
+
let _classDecorators = [StringTag("Logger")];
|
|
1247
|
+
let _classDescriptor;
|
|
1248
|
+
let _classExtraInitializers = [];
|
|
1249
|
+
let _classThis;
|
|
1250
|
+
var Logger2 = class {
|
|
1251
|
+
static {
|
|
1252
|
+
_classThis = this;
|
|
1253
|
+
}
|
|
1254
|
+
static {
|
|
1255
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? /* @__PURE__ */ Object.create(null) : void 0;
|
|
1256
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
1257
|
+
Logger2 = _classThis = _classDescriptor.value;
|
|
1258
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
1259
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
1260
|
+
}
|
|
1261
|
+
#namespace;
|
|
1262
|
+
/** The current verbosity level */
|
|
1263
|
+
level;
|
|
1264
|
+
constructor(namespace, level = LOG.Info) {
|
|
1265
|
+
this.#namespace = namespace.startsWith("[") ? namespace : `[${namespace}]`;
|
|
1266
|
+
this.level = level;
|
|
1267
|
+
}
|
|
1268
|
+
#emit(method, ...msg) {
|
|
1269
|
+
let config;
|
|
1270
|
+
if (msg.length > 0 && isObject(msg[0])) {
|
|
1271
|
+
try {
|
|
1272
|
+
if (msg[0][sym.$LogConfig]) {
|
|
1273
|
+
config = msg.shift();
|
|
1274
|
+
}
|
|
1275
|
+
} catch {
|
|
1276
|
+
}
|
|
1277
|
+
}
|
|
1278
|
+
let activeLevel = this.level;
|
|
1279
|
+
if (config) {
|
|
1280
|
+
if (config.silent === true)
|
|
1281
|
+
return;
|
|
1282
|
+
if (config.debug !== void 0) {
|
|
1283
|
+
activeLevel = parseLogLevel(config.debug, activeLevel);
|
|
1284
|
+
}
|
|
1285
|
+
}
|
|
1286
|
+
if (activeLevel === LOG.Off)
|
|
1287
|
+
return;
|
|
1288
|
+
const methodLevel = Level[method] ?? 0;
|
|
1289
|
+
if (methodLevel > activeLevel)
|
|
1290
|
+
return;
|
|
1291
|
+
const output = msg.map((m) => {
|
|
1292
|
+
if (isError(m))
|
|
1293
|
+
return m.message;
|
|
1294
|
+
if (isObject(m)) {
|
|
1295
|
+
try {
|
|
1296
|
+
const name = m.constructor?.name ?? "Object";
|
|
1297
|
+
if (name === "Object") {
|
|
1298
|
+
const keys = Object.keys(m);
|
|
1299
|
+
const summary = keys.slice(0, 3).join(", ");
|
|
1300
|
+
return `{ ${summary}${keys.length > 3 ? `, ... (+${keys.length - 3} more)` : ""} }`;
|
|
1301
|
+
}
|
|
1302
|
+
return `[${name}]`;
|
|
1303
|
+
} catch {
|
|
1304
|
+
return "[Object]";
|
|
1305
|
+
}
|
|
1306
|
+
}
|
|
1307
|
+
return String(m);
|
|
1308
|
+
}).filter((s) => !isEmpty(s)).join(" ");
|
|
1309
|
+
if (!isEmpty(output)) {
|
|
1310
|
+
const consoleMethod = method;
|
|
1311
|
+
console[consoleMethod](`${this.#namespace} ${output}`);
|
|
1312
|
+
}
|
|
1313
|
+
}
|
|
1314
|
+
/** console.log */
|
|
1315
|
+
log = (...msg) => this.#emit(Method.Log, ...msg);
|
|
1316
|
+
/** console.info */
|
|
1317
|
+
info = (...msg) => this.#emit(Method.Info, ...msg);
|
|
1318
|
+
/** console.warn */
|
|
1319
|
+
warn = (...msg) => this.#emit(Method.Warn, ...msg);
|
|
1320
|
+
/** console.debug */
|
|
1321
|
+
debug = (...msg) => this.#emit(Method.Debug, ...msg);
|
|
1322
|
+
/** console.trace */
|
|
1323
|
+
trace = (...msg) => this.#emit(Method.Trace, ...msg);
|
|
1324
|
+
/** console.error */
|
|
1325
|
+
error = (...msg) => this.#emit(Method.Error, ...msg);
|
|
1326
|
+
};
|
|
1327
|
+
return Logger2 = _classThis;
|
|
1328
|
+
})();
|
|
1329
|
+
}
|
|
1330
|
+
});
|
|
1331
|
+
|
|
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
|
+
// ../../library/dist/browser/webstore.class.js
|
|
1381
|
+
var webstore_class_exports = {};
|
|
1382
|
+
__export(webstore_class_exports, {
|
|
1383
|
+
WebStore: () => WebStore
|
|
1384
|
+
});
|
|
1385
|
+
var STORAGE, WebStore;
|
|
1386
|
+
var init_webstore_class = __esm({
|
|
1387
|
+
"../../library/dist/browser/webstore.class.js"() {
|
|
1388
|
+
"use strict";
|
|
1389
|
+
init_tslib_es6();
|
|
1390
|
+
init_primitive_library();
|
|
1391
|
+
init_serialize_library();
|
|
1392
|
+
init_type_library();
|
|
1393
|
+
init_assertion_library();
|
|
1394
|
+
init_storage_library();
|
|
1395
|
+
init_decorator_library();
|
|
1396
|
+
STORAGE = {
|
|
1397
|
+
Local: "local",
|
|
1398
|
+
Session: "session"
|
|
1399
|
+
};
|
|
1400
|
+
WebStore = (() => {
|
|
1401
|
+
let _classDecorators = [StringTag("WebStore")];
|
|
1402
|
+
let _classDescriptor;
|
|
1403
|
+
let _classExtraInitializers = [];
|
|
1404
|
+
let _classThis;
|
|
1405
|
+
var WebStore2 = class {
|
|
1406
|
+
static {
|
|
1407
|
+
_classThis = this;
|
|
1408
|
+
}
|
|
1409
|
+
static {
|
|
1410
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? /* @__PURE__ */ Object.create(null) : void 0;
|
|
1411
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
1412
|
+
WebStore2 = _classThis = _classDescriptor.value;
|
|
1413
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
1414
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
1415
|
+
}
|
|
1416
|
+
static _localInstance;
|
|
1417
|
+
static _sessionInstance;
|
|
1418
|
+
/**
|
|
1419
|
+
* Lazy getter for the localStorage wrapper instance.
|
|
1420
|
+
*
|
|
1421
|
+
* @returns The WebStore instance for localStorage
|
|
1422
|
+
*/
|
|
1423
|
+
static get local() {
|
|
1424
|
+
return WebStore2._localInstance ??= new WebStore2(STORAGE.Local);
|
|
1425
|
+
}
|
|
1426
|
+
/**
|
|
1427
|
+
* Lazy getter for the sessionStorage wrapper instance.
|
|
1428
|
+
*
|
|
1429
|
+
* @returns The WebStore instance for sessionStorage
|
|
1430
|
+
*/
|
|
1431
|
+
static get session() {
|
|
1432
|
+
return WebStore2._sessionInstance ??= new WebStore2(STORAGE.Session);
|
|
1433
|
+
}
|
|
1434
|
+
#type;
|
|
1435
|
+
#resolvedStorage;
|
|
1436
|
+
/** Resolved Storage object (resolved safely on access with memory fallback) */
|
|
1437
|
+
get #storage() {
|
|
1438
|
+
if (this.#resolvedStorage)
|
|
1439
|
+
return this.#resolvedStorage;
|
|
1440
|
+
const name = this.#type === STORAGE.Local ? "localStorage" : "sessionStorage";
|
|
1441
|
+
return this.#resolvedStorage = getSafeStorage(name);
|
|
1442
|
+
}
|
|
1443
|
+
#exec(op) {
|
|
1444
|
+
try {
|
|
1445
|
+
return op(this.#storage);
|
|
1446
|
+
} catch (e) {
|
|
1447
|
+
const name = this.#type === STORAGE.Local ? "localStorage" : "sessionStorage";
|
|
1448
|
+
const fallback = getMemoryStorage(name);
|
|
1449
|
+
this.#resolvedStorage = fallback;
|
|
1450
|
+
return op(fallback);
|
|
1451
|
+
}
|
|
1452
|
+
}
|
|
1453
|
+
constructor(storage2 = STORAGE.Local) {
|
|
1454
|
+
this.#type = storage2;
|
|
1455
|
+
}
|
|
1456
|
+
/**
|
|
1457
|
+
* Retrieve a value from storage, optionally providing a default.
|
|
1458
|
+
*
|
|
1459
|
+
* @param key - The property key to retrieve
|
|
1460
|
+
* @param dflt - An optional default value if the key does not exist
|
|
1461
|
+
* @returns The parsed object from storage, or the default/null if not found
|
|
1462
|
+
*/
|
|
1463
|
+
get(key, dflt) {
|
|
1464
|
+
const str = this.#exec((storage2) => storage2.getItem(stringify(key)));
|
|
1465
|
+
return isString(str) ? objectify(str) : dflt ?? null;
|
|
1466
|
+
}
|
|
1467
|
+
/**
|
|
1468
|
+
* Store or merge a value into storage for a given key.
|
|
1469
|
+
*
|
|
1470
|
+
* @param key - The property key to set. If nullish, clears the store.
|
|
1471
|
+
* @param obj - The value to store
|
|
1472
|
+
* @param opt - Options (merge behavior)
|
|
1473
|
+
* @returns The WebStore instance for chaining
|
|
1474
|
+
*/
|
|
1475
|
+
set(key, obj, opt = { merge: true }) {
|
|
1476
|
+
if (isNullish(key))
|
|
1477
|
+
return this.clear();
|
|
1478
|
+
let prev = this.get(key);
|
|
1479
|
+
const arg = asType(obj);
|
|
1480
|
+
switch (arg.type) {
|
|
1481
|
+
case "Undefined":
|
|
1482
|
+
return this.del(key);
|
|
1483
|
+
// synonym for 'removeItem'
|
|
1484
|
+
case "Object":
|
|
1485
|
+
prev ??= {};
|
|
1486
|
+
return this.#upd(key, opt.merge ? Object.assign(prev, arg.value) : arg.value);
|
|
1487
|
+
case "Array":
|
|
1488
|
+
prev ??= [];
|
|
1489
|
+
return this.#upd(key, opt.merge ? distinct(prev.concat(arg.value)) : obj);
|
|
1490
|
+
case "Map":
|
|
1491
|
+
prev ??= /* @__PURE__ */ new Map();
|
|
1492
|
+
if (opt.merge) {
|
|
1493
|
+
arg.value.forEach((val, key2) => prev.set(key2, val));
|
|
1494
|
+
return this.#upd(key, prev);
|
|
1495
|
+
}
|
|
1496
|
+
return this.#upd(key, arg.value);
|
|
1497
|
+
// else overwrite new Map
|
|
1498
|
+
case "Set":
|
|
1499
|
+
prev ??= /* @__PURE__ */ new Set();
|
|
1500
|
+
if (opt.merge) {
|
|
1501
|
+
arg.value.forEach((itm) => prev.add(itm));
|
|
1502
|
+
return this.#upd(key, prev);
|
|
1503
|
+
}
|
|
1504
|
+
return this.#upd(key, arg.value);
|
|
1505
|
+
// else overwrite new Set
|
|
1506
|
+
default:
|
|
1507
|
+
return this.#upd(key, arg.value);
|
|
1508
|
+
}
|
|
1509
|
+
}
|
|
1510
|
+
/**
|
|
1511
|
+
* Clear all items from this storage instance.
|
|
1512
|
+
*
|
|
1513
|
+
* @returns The WebStore instance for chaining
|
|
1514
|
+
*/
|
|
1515
|
+
clear() {
|
|
1516
|
+
try {
|
|
1517
|
+
this.#exec((storage2) => storage2.clear());
|
|
1518
|
+
} catch (e) {
|
|
1519
|
+
console.warn("[WebStore] Failed to clear storage:", e);
|
|
1520
|
+
}
|
|
1521
|
+
return this;
|
|
1522
|
+
}
|
|
1523
|
+
/**
|
|
1524
|
+
* Delete specific keys from storage.
|
|
1525
|
+
*
|
|
1526
|
+
* @param keys - The keys to remove
|
|
1527
|
+
* @returns The WebStore instance for chaining
|
|
1528
|
+
*/
|
|
1529
|
+
del(...keys) {
|
|
1530
|
+
keys.forEach((key) => {
|
|
1531
|
+
try {
|
|
1532
|
+
this.#exec((storage2) => storage2.removeItem(stringify(key)));
|
|
1533
|
+
} catch (e) {
|
|
1534
|
+
console.warn(`[WebStore] Failed to removeItem for key '${String(key)}':`, e);
|
|
1535
|
+
}
|
|
1536
|
+
});
|
|
1537
|
+
return this;
|
|
1538
|
+
}
|
|
1539
|
+
/**
|
|
1540
|
+
* Get an array of keys currently in storage. If specific keys are provided, filters by those.
|
|
1541
|
+
*
|
|
1542
|
+
* @param keys - Optional keys to filter by
|
|
1543
|
+
* @returns An array of string/symbol keys
|
|
1544
|
+
*/
|
|
1545
|
+
keys(...keys) {
|
|
1546
|
+
return this.entries(...keys).map(([key]) => key);
|
|
1547
|
+
}
|
|
1548
|
+
/**
|
|
1549
|
+
* Get an array of values currently in storage.
|
|
1550
|
+
*
|
|
1551
|
+
* @param keys - Optional keys to retrieve values for
|
|
1552
|
+
* @returns An array of parsed values
|
|
1553
|
+
*/
|
|
1554
|
+
values(...keys) {
|
|
1555
|
+
return this.entries(...keys).map(([, val]) => val);
|
|
1556
|
+
}
|
|
1557
|
+
/**
|
|
1558
|
+
* Get an array of [key, value] entries currently in storage.
|
|
1559
|
+
*
|
|
1560
|
+
* @param keys - Optional keys to filter the entries by
|
|
1561
|
+
* @returns An array of key-value tuples
|
|
1562
|
+
*/
|
|
1563
|
+
entries(...keys) {
|
|
1564
|
+
const wanted = new Set(keys.map((key) => stringify(key)));
|
|
1565
|
+
const result = [];
|
|
1566
|
+
this.#exec((storage2) => {
|
|
1567
|
+
for (let i = 0; i < storage2.length; i++) {
|
|
1568
|
+
const rawKey = storage2.key(i);
|
|
1569
|
+
if (rawKey === null)
|
|
1570
|
+
continue;
|
|
1571
|
+
if (isEmpty(keys) || wanted.has(rawKey)) {
|
|
1572
|
+
const rawVal = storage2.getItem(rawKey);
|
|
1573
|
+
result.push([objectify(rawKey), objectify(rawVal)]);
|
|
1574
|
+
}
|
|
1575
|
+
}
|
|
1576
|
+
});
|
|
1577
|
+
return result;
|
|
1578
|
+
}
|
|
1579
|
+
/**
|
|
1580
|
+
* Populate the storage from an existing object map.
|
|
1581
|
+
*
|
|
1582
|
+
* @param store - The object/dictionary to populate from
|
|
1583
|
+
* @returns The WebStore instance for chaining
|
|
1584
|
+
*/
|
|
1585
|
+
from(store) {
|
|
1586
|
+
ownEntries(store).forEach(([key, val]) => this.set(key, val));
|
|
1587
|
+
return this;
|
|
1588
|
+
}
|
|
1589
|
+
#upd(key, obj) {
|
|
1590
|
+
try {
|
|
1591
|
+
this.#exec((storage2) => storage2.setItem(stringify(key), stringify(obj)));
|
|
1592
|
+
} catch (e) {
|
|
1593
|
+
console.warn(`[WebStore] Failed to setItem for key '${String(key)}':`, e);
|
|
1594
|
+
}
|
|
1595
|
+
return this;
|
|
1596
|
+
}
|
|
1597
|
+
};
|
|
1598
|
+
return WebStore2 = _classThis;
|
|
1599
|
+
})();
|
|
1600
|
+
}
|
|
1601
|
+
});
|
|
1602
|
+
|
|
1603
|
+
// ../../library/dist/browser/mapper.library.js
|
|
1604
|
+
var mapper_library_exports = {};
|
|
1605
|
+
__export(mapper_library_exports, {
|
|
1606
|
+
geoCoords: () => geoCoords,
|
|
1607
|
+
geoLocation: () => geoLocation,
|
|
1608
|
+
mapAddress: () => mapAddress,
|
|
1609
|
+
mapHemisphere: () => mapHemisphere,
|
|
1610
|
+
mapQuery: () => mapQuery
|
|
1611
|
+
});
|
|
1612
|
+
var defaults, context2, mapStore, MAP_KEY, log, storePromise, getStore, geoLocation, geoCoords, mapQuery, mapHemisphere, mapAddress;
|
|
1613
|
+
var init_mapper_library = __esm({
|
|
1614
|
+
"../../library/dist/browser/mapper.library.js"() {
|
|
1615
|
+
"use strict";
|
|
1616
|
+
init_object_library();
|
|
1617
|
+
init_utility_library();
|
|
1618
|
+
init_assertion_library();
|
|
1619
|
+
init_temporal_library();
|
|
1620
|
+
init_international_library();
|
|
1621
|
+
init_logger_class();
|
|
1622
|
+
defaults = { catch: true, debug: 0 };
|
|
1623
|
+
context2 = getContext();
|
|
1624
|
+
mapStore = {};
|
|
1625
|
+
MAP_KEY = "_map_";
|
|
1626
|
+
log = new Logger("[Mapper]");
|
|
1627
|
+
storePromise = null;
|
|
1628
|
+
getStore = () => {
|
|
1629
|
+
if (!storePromise) {
|
|
1630
|
+
storePromise = new Promise((resolve, reject) => {
|
|
1631
|
+
if (context2.type === CONTEXT.Browser) {
|
|
1632
|
+
Promise.resolve().then(() => (init_webstore_class(), webstore_class_exports)).then(({ WebStore: WebStore2 }) => {
|
|
1633
|
+
const local = new WebStore2("local");
|
|
1634
|
+
Object.assign(mapStore, local.get(MAP_KEY, {}));
|
|
1635
|
+
resolve(local);
|
|
1636
|
+
}).catch(reject);
|
|
1637
|
+
} else {
|
|
1638
|
+
resolve(void 0);
|
|
1639
|
+
}
|
|
1640
|
+
});
|
|
1641
|
+
}
|
|
1642
|
+
return storePromise;
|
|
1643
|
+
};
|
|
1644
|
+
geoLocation = (opts = {}) => getStore().then(() => new Promise((resolve, reject) => {
|
|
1645
|
+
opts = Object.assign({}, defaults, opts);
|
|
1646
|
+
const fulfil = opts.catch ? resolve : reject;
|
|
1647
|
+
if (typeof navigator !== "undefined" && "geolocation" in navigator) {
|
|
1648
|
+
navigator["geolocation"].getCurrentPosition((value2) => {
|
|
1649
|
+
const coords = mapStore.geolocation?.coords;
|
|
1650
|
+
const prevLat = coords?.latitude?.toFixed(3);
|
|
1651
|
+
const prevLng = coords?.longitude?.toFixed(3);
|
|
1652
|
+
const prevTime = mapStore.geolocation?.timestamp ?? 0;
|
|
1653
|
+
const test1 = value2.coords.latitude.toFixed(3) !== prevLat;
|
|
1654
|
+
const test2 = value2.coords.longitude.toFixed(3) !== prevLng;
|
|
1655
|
+
const test3 = prevTime < instant().epochMilliseconds - 36e5;
|
|
1656
|
+
if (test1 || test2 || test3) {
|
|
1657
|
+
Object.assign(mapStore, { georesponse: null });
|
|
1658
|
+
log.info(opts, "GeoLocation: device update");
|
|
1659
|
+
}
|
|
1660
|
+
Object.assign(mapStore, { geolocation: asObject(value2) });
|
|
1661
|
+
resolve(mapStore.geolocation);
|
|
1662
|
+
}, (error) => {
|
|
1663
|
+
Object.assign(mapStore, { geolocation: { error: error.message }, georesponse: null });
|
|
1664
|
+
fulfil(mapStore.geolocation);
|
|
1665
|
+
});
|
|
1666
|
+
} else {
|
|
1667
|
+
Object.assign(mapStore, { geolocation: { error: "Not Supported" }, georesponse: null });
|
|
1668
|
+
fulfil(mapStore.geolocation);
|
|
1669
|
+
}
|
|
1670
|
+
})).finally(() => {
|
|
1671
|
+
const fn = mapStore.geolocation?.error ? log.error : log.info;
|
|
1672
|
+
fn(opts, "geoLocation: ", mapStore.geolocation);
|
|
1673
|
+
getStore().then((store) => store?.set(MAP_KEY, mapStore));
|
|
1674
|
+
});
|
|
1675
|
+
geoCoords = (coords) => new Promise((resolve, reject) => {
|
|
1676
|
+
if (!isNullish(coords))
|
|
1677
|
+
return resolve(coords);
|
|
1678
|
+
geoLocation().then(
|
|
1679
|
+
(geo) => isNullish(geo.error) ? { location: { lat: geo.coords.latitude, lng: geo.coords.longitude } } : null
|
|
1680
|
+
// unsuccessful geolocation
|
|
1681
|
+
).then((loc) => resolve(loc)).catch((err) => reject(err));
|
|
1682
|
+
});
|
|
1683
|
+
mapQuery = (coords, opts = {}) => getStore().then(() => new Promise((resolve, reject) => {
|
|
1684
|
+
opts = Object.assign({}, defaults, opts);
|
|
1685
|
+
const fulfil = opts.catch ? resolve : reject;
|
|
1686
|
+
geoCoords(coords).then((loc) => {
|
|
1687
|
+
switch (true) {
|
|
1688
|
+
case !(typeof window !== "undefined" && "google" in window && "maps" in window["google"]):
|
|
1689
|
+
throw new Error("Google Maps API not configured");
|
|
1690
|
+
case isNullish(loc):
|
|
1691
|
+
throw new Error("Cannot determine Coordinates");
|
|
1692
|
+
case isNullish(coords): {
|
|
1693
|
+
const test1 = mapStore.geolocation && mapStore.georesponse;
|
|
1694
|
+
const test2 = isNullish(mapStore.geolocation?.error) && isNullish(mapStore.georesponse?.error);
|
|
1695
|
+
if (test1 && test2) {
|
|
1696
|
+
if (opts.debug)
|
|
1697
|
+
log.debug(opts, "mapQuery: cache");
|
|
1698
|
+
return resolve(mapStore.georesponse);
|
|
1699
|
+
}
|
|
1700
|
+
}
|
|
1701
|
+
// drop through to default:
|
|
1702
|
+
default:
|
|
1703
|
+
new window["google"]["maps"].Geocoder().geocode(loc).then((res) => resolve(mapStore.georesponse = asObject(res)));
|
|
1704
|
+
}
|
|
1705
|
+
}).catch((error) => {
|
|
1706
|
+
Object.assign(mapStore, { georesponse: { error: error.message } });
|
|
1707
|
+
fulfil(mapStore.georesponse);
|
|
1708
|
+
});
|
|
1709
|
+
})).finally(() => {
|
|
1710
|
+
if (opts.debug) {
|
|
1711
|
+
const fn = mapStore.georesponse?.error ? log.error : log.debug;
|
|
1712
|
+
fn(opts, "mapQuery: ", mapStore.georesponse);
|
|
1713
|
+
}
|
|
1714
|
+
getStore().then((store) => store?.set(MAP_KEY, mapStore));
|
|
1715
|
+
});
|
|
1716
|
+
mapHemisphere = (coords, opts = {}) => mapQuery(coords, opts).then((response) => {
|
|
1717
|
+
opts = Object.assign({}, defaults, opts);
|
|
1718
|
+
if (isNullish(response.error)) {
|
|
1719
|
+
if (opts.debug)
|
|
1720
|
+
log.debug(opts, "sphere: ", response);
|
|
1721
|
+
return response.results[0].geometry.location.lat() >= 0 ? "north" : "south";
|
|
1722
|
+
}
|
|
1723
|
+
const sphere = getHemisphere();
|
|
1724
|
+
if (isNullish(sphere) && opts.catch === false)
|
|
1725
|
+
throw new Error("Cannot determine Hemisphere");
|
|
1726
|
+
return sphere;
|
|
1727
|
+
}).catch((error) => {
|
|
1728
|
+
if (opts.debug)
|
|
1729
|
+
log.warn(opts, "mapHemisphere: ", error.message);
|
|
1730
|
+
if (opts.catch === false)
|
|
1731
|
+
throw error;
|
|
1732
|
+
return null;
|
|
1733
|
+
});
|
|
1734
|
+
mapAddress = (coords, opts = {}) => mapQuery(coords, opts).then((response) => {
|
|
1735
|
+
if (!isNullish(response.error))
|
|
1736
|
+
throw new Error(response.error);
|
|
1737
|
+
return response.results[0];
|
|
1738
|
+
}).then(({ formatted_address, address_components }) => address_components.reduce((acc, itm) => {
|
|
1739
|
+
itm.types.filter((type) => type !== "political").forEach((type) => acc[type] = (acc[type] ? acc[type] + "," : "").concat(itm.short_name));
|
|
1740
|
+
return acc;
|
|
1741
|
+
}, { formatted_address })).catch((error) => {
|
|
1742
|
+
opts = Object.assign({}, defaults, opts);
|
|
1743
|
+
if (opts.debug)
|
|
1744
|
+
log.warn(opts, "mapAddress: ", error.message);
|
|
1745
|
+
if (opts.catch === false)
|
|
1746
|
+
throw error;
|
|
1747
|
+
return null;
|
|
1748
|
+
});
|
|
1749
|
+
}
|
|
1750
|
+
});
|
|
1751
|
+
|
|
1752
|
+
// ../../library/dist/common/runtime/request.library.js
|
|
1753
|
+
var request_library_exports = {};
|
|
1754
|
+
__export(request_library_exports, {
|
|
1755
|
+
HTTP: () => HTTP,
|
|
1756
|
+
HttpError: () => HttpError,
|
|
1757
|
+
METHOD: () => METHOD,
|
|
1758
|
+
fetchHead: () => fetchHead,
|
|
1759
|
+
fetchRequest: () => fetchRequest
|
|
1760
|
+
});
|
|
1761
|
+
var TWO_SECONDS, RE_TRAILING_CLOSURE, HTTP, METHOD, HttpError, readBoundedBody, fetchRequest, fetchHead;
|
|
1762
|
+
var init_request_library = __esm({
|
|
1763
|
+
"../../library/dist/common/runtime/request.library.js"() {
|
|
1764
|
+
"use strict";
|
|
1765
|
+
init_assertion_library();
|
|
1766
|
+
TWO_SECONDS = 2e3;
|
|
1767
|
+
RE_TRAILING_CLOSURE = /\);?$/;
|
|
1768
|
+
HTTP = {
|
|
1769
|
+
Ok: 200,
|
|
1770
|
+
PermRedirect: 301,
|
|
1771
|
+
TempRedirect: 302,
|
|
1772
|
+
BadRequest: 400,
|
|
1773
|
+
Unauthorised: 401,
|
|
1774
|
+
Forbidden: 403
|
|
1775
|
+
};
|
|
1776
|
+
METHOD = {
|
|
1777
|
+
Head: "HEAD",
|
|
1778
|
+
Get: "GET",
|
|
1779
|
+
Put: "PUT",
|
|
1780
|
+
Delete: "DELETE",
|
|
1781
|
+
Post: "POST"
|
|
1782
|
+
};
|
|
1783
|
+
HttpError = class extends Error {
|
|
1784
|
+
status;
|
|
1785
|
+
statusText;
|
|
1786
|
+
body;
|
|
1787
|
+
constructor(status, statusText, body) {
|
|
1788
|
+
super(`${status}: ${statusText}`);
|
|
1789
|
+
this.status = status;
|
|
1790
|
+
this.statusText = statusText;
|
|
1791
|
+
this.body = body;
|
|
1792
|
+
this.name = "HttpError";
|
|
1793
|
+
}
|
|
1794
|
+
};
|
|
1795
|
+
readBoundedBody = async (res, maxBytes) => {
|
|
1796
|
+
const contentLength = res.headers?.get?.("Content-Length") || res.headers?.get?.("content-length");
|
|
1797
|
+
if (contentLength) {
|
|
1798
|
+
const bytes = parseInt(contentLength, 10);
|
|
1799
|
+
if (isNumber(bytes) && bytes > maxBytes) {
|
|
1800
|
+
try {
|
|
1801
|
+
await res.body?.cancel();
|
|
1802
|
+
} catch {
|
|
1803
|
+
}
|
|
1804
|
+
throw new HttpError(413, `Content-Length (${bytes}) exceeds limit (${maxBytes} bytes)`, null);
|
|
1805
|
+
}
|
|
1806
|
+
}
|
|
1807
|
+
if (!res.body) {
|
|
1808
|
+
let rawText2;
|
|
1809
|
+
if (isFunction(res.text)) {
|
|
1810
|
+
rawText2 = await res.text();
|
|
1811
|
+
} else if (isFunction(res.json)) {
|
|
1812
|
+
const obj = await res.json();
|
|
1813
|
+
rawText2 = JSON.stringify(obj) ?? "";
|
|
1814
|
+
} else {
|
|
1815
|
+
rawText2 = "";
|
|
1816
|
+
}
|
|
1817
|
+
const byteLength = new TextEncoder().encode(rawText2).byteLength;
|
|
1818
|
+
if (byteLength > maxBytes)
|
|
1819
|
+
throw new HttpError(413, `Payload length (${byteLength}) exceeds limit (${maxBytes} bytes)`, null);
|
|
1820
|
+
return rawText2;
|
|
1821
|
+
}
|
|
1822
|
+
const reader = res.body.getReader();
|
|
1823
|
+
const decoder = new TextDecoder();
|
|
1824
|
+
let totalBytes = 0;
|
|
1825
|
+
let rawText = "";
|
|
1826
|
+
try {
|
|
1827
|
+
while (true) {
|
|
1828
|
+
const { done, value: value2 } = await reader.read();
|
|
1829
|
+
if (done)
|
|
1830
|
+
break;
|
|
1831
|
+
if (value2) {
|
|
1832
|
+
totalBytes += value2.byteLength;
|
|
1833
|
+
if (totalBytes > maxBytes) {
|
|
1834
|
+
try {
|
|
1835
|
+
await reader.cancel();
|
|
1836
|
+
} catch {
|
|
1837
|
+
}
|
|
1838
|
+
throw new HttpError(413, `Streamed payload exceeded limit (${maxBytes} bytes)`, null);
|
|
1839
|
+
}
|
|
1840
|
+
rawText += decoder.decode(value2, { stream: true });
|
|
1841
|
+
}
|
|
1842
|
+
}
|
|
1843
|
+
rawText += decoder.decode();
|
|
1844
|
+
return rawText;
|
|
1845
|
+
} finally {
|
|
1846
|
+
try {
|
|
1847
|
+
reader.releaseLock();
|
|
1848
|
+
} catch {
|
|
1849
|
+
}
|
|
1850
|
+
}
|
|
1851
|
+
};
|
|
1852
|
+
fetchRequest = (url, init = {}, config = {}) => {
|
|
1853
|
+
const signallingInit = {
|
|
1854
|
+
...init,
|
|
1855
|
+
signal: init.signal ? AbortSignal.any([init.signal, AbortSignal.timeout(config.timeout ?? TWO_SECONDS)]) : AbortSignal.timeout(config.timeout ?? TWO_SECONDS)
|
|
1856
|
+
};
|
|
1857
|
+
return fetch(url, signallingInit).then(async (res) => {
|
|
1858
|
+
if (res.ok) {
|
|
1859
|
+
const contentType = res.headers?.get?.("Content-Type") || res.headers?.get?.("content-type") || "";
|
|
1860
|
+
const isJson = contentType.includes("application/json");
|
|
1861
|
+
if (isDefined(config.maxBytes)) {
|
|
1862
|
+
const rawText = await readBoundedBody(res, config.maxBytes);
|
|
1863
|
+
if (config.rawText)
|
|
1864
|
+
return rawText;
|
|
1865
|
+
if (config.prefix) {
|
|
1866
|
+
const json = rawText.startsWith(config.prefix) ? rawText.substring(config.prefix.length).replace(RE_TRAILING_CLOSURE, "") : rawText;
|
|
1867
|
+
return JSON.parse(json);
|
|
1868
|
+
}
|
|
1869
|
+
if (isJson)
|
|
1870
|
+
return JSON.parse(rawText);
|
|
1871
|
+
try {
|
|
1872
|
+
return JSON.parse(rawText);
|
|
1873
|
+
} catch {
|
|
1874
|
+
return rawText;
|
|
1875
|
+
}
|
|
1876
|
+
}
|
|
1877
|
+
if (config.rawText) {
|
|
1878
|
+
const text = isFunction(res.text) ? await res.text() : "";
|
|
1879
|
+
return text;
|
|
1880
|
+
}
|
|
1881
|
+
if (config.prefix) {
|
|
1882
|
+
const rawPrefixText = await res.text();
|
|
1883
|
+
const json = rawPrefixText.startsWith(config.prefix) ? rawPrefixText.substring(config.prefix.length).replace(RE_TRAILING_CLOSURE, "") : rawPrefixText;
|
|
1884
|
+
return JSON.parse(json);
|
|
1885
|
+
}
|
|
1886
|
+
if (isFunction(res.text)) {
|
|
1887
|
+
const text = await res.text();
|
|
1888
|
+
try {
|
|
1889
|
+
return JSON.parse(text);
|
|
1890
|
+
} catch {
|
|
1891
|
+
return text;
|
|
1892
|
+
}
|
|
1893
|
+
}
|
|
1894
|
+
if (isFunction(res.json))
|
|
1895
|
+
return await res.json();
|
|
1896
|
+
return "";
|
|
1897
|
+
}
|
|
1898
|
+
let errorBody = null;
|
|
1899
|
+
try {
|
|
1900
|
+
const errorText = isDefined(config.maxBytes) ? await readBoundedBody(res, config.maxBytes) : isFunction(res.text) ? await res.text() : "";
|
|
1901
|
+
try {
|
|
1902
|
+
errorBody = JSON.parse(errorText);
|
|
1903
|
+
} catch {
|
|
1904
|
+
errorBody = errorText;
|
|
1905
|
+
}
|
|
1906
|
+
} catch (err) {
|
|
1907
|
+
if (err instanceof HttpError && err.status === 413)
|
|
1908
|
+
throw err;
|
|
1909
|
+
}
|
|
1910
|
+
throw new HttpError(res.status, res.statusText, errorBody);
|
|
1911
|
+
});
|
|
1912
|
+
};
|
|
1913
|
+
fetchHead = (url) => {
|
|
1914
|
+
const signal = AbortSignal.timeout(TWO_SECONDS);
|
|
1915
|
+
const init = { method: METHOD.Head, signal };
|
|
1916
|
+
return fetch(url, init).then(({ ok, status, statusText, headers }) => {
|
|
1917
|
+
if (ok || status === HTTP.Forbidden)
|
|
1918
|
+
return { status, headers };
|
|
1919
|
+
throw new HttpError(status, statusText, null);
|
|
1920
|
+
});
|
|
1921
|
+
};
|
|
1922
|
+
}
|
|
1923
|
+
});
|
|
1924
|
+
|
|
1925
|
+
// ../../library/dist/server/mapper.library.js
|
|
1926
|
+
var mapper_library_exports2 = {};
|
|
1927
|
+
__export(mapper_library_exports2, {
|
|
1928
|
+
serverGeoCoords: () => serverGeoCoords,
|
|
1929
|
+
serverGeoLocation: () => serverGeoLocation,
|
|
1930
|
+
serverMapHemisphere: () => serverMapHemisphere
|
|
1931
|
+
});
|
|
1932
|
+
var log2, defaults2, requestModulePromise, getRequestModule, serverGeoLocation, serverGeoCoords, serverMapHemisphere;
|
|
1933
|
+
var init_mapper_library2 = __esm({
|
|
1934
|
+
"../../library/dist/server/mapper.library.js"() {
|
|
1935
|
+
"use strict";
|
|
1936
|
+
init_assertion_library();
|
|
1937
|
+
init_international_library();
|
|
1938
|
+
init_logger_class();
|
|
1939
|
+
log2 = new Logger("[ServerMapper]");
|
|
1940
|
+
defaults2 = {
|
|
1941
|
+
endpoint: "https://ipwho.is/",
|
|
1942
|
+
timeout: 3e3,
|
|
1943
|
+
catch: true,
|
|
1944
|
+
debug: 0
|
|
1945
|
+
};
|
|
1946
|
+
requestModulePromise = null;
|
|
1947
|
+
getRequestModule = () => {
|
|
1948
|
+
if (!requestModulePromise)
|
|
1949
|
+
requestModulePromise = Promise.resolve().then(() => (init_request_library(), request_library_exports));
|
|
1950
|
+
return requestModulePromise;
|
|
1951
|
+
};
|
|
1952
|
+
serverGeoLocation = async (opts = {}) => {
|
|
1953
|
+
const options = { ...defaults2, ...opts };
|
|
1954
|
+
const fulfil = options.catch !== false;
|
|
1955
|
+
try {
|
|
1956
|
+
const endpoint = options.endpoint || defaults2.endpoint;
|
|
1957
|
+
const timeout = options.timeout ?? defaults2.timeout;
|
|
1958
|
+
const { fetchRequest: fetchRequest2 } = await getRequestModule();
|
|
1959
|
+
const data = await fetchRequest2(endpoint, {}, { ...isNumber(timeout) ? { timeout } : {}, maxBytes: 64 * 1024 });
|
|
1960
|
+
if (typeof data !== "object" || isNullish(data))
|
|
1961
|
+
throw new Error("Geolocation lookup failed");
|
|
1962
|
+
if (data.status === "fail" || data.success === false)
|
|
1963
|
+
throw new Error(data.message || data.reason || "Geolocation lookup failed");
|
|
1964
|
+
const lat = isNumber(data.lat) ? data.lat : data.latitude;
|
|
1965
|
+
const lng = isNumber(data.lon) ? data.lon : data.lng ?? data.longitude;
|
|
1966
|
+
if (!isNumber(lat) || !isNumber(lng))
|
|
1967
|
+
throw new Error("Geolocation lookup failed");
|
|
1968
|
+
const tz = isString(data.timezone) ? data.timezone : data.timezone?.id ?? data.timeZone;
|
|
1969
|
+
const result = {
|
|
1970
|
+
lat,
|
|
1971
|
+
lng,
|
|
1972
|
+
latitude: lat,
|
|
1973
|
+
longitude: lng,
|
|
1974
|
+
...isString(data.country || data.countryName || data.country_name) ? { country: data.country || data.countryName || data.country_name } : {},
|
|
1975
|
+
...isString(data.city || data.cityName || data.city_name) ? { city: data.city || data.cityName || data.city_name } : {},
|
|
1976
|
+
...isString(tz) ? { timezone: tz } : {},
|
|
1977
|
+
...isString(data.query || data.ip || data.ip_address) ? { query: data.query || data.ip || data.ip_address } : {},
|
|
1978
|
+
status: "success"
|
|
1979
|
+
};
|
|
1980
|
+
if (options.debug)
|
|
1981
|
+
log2.info(options, "serverGeoLocation success: ", result);
|
|
1982
|
+
return result;
|
|
1983
|
+
} catch (err) {
|
|
1984
|
+
const errorMsg = err?.message || "Server geolocation error";
|
|
1985
|
+
if (options.debug)
|
|
1986
|
+
log2.error(options, "serverGeoLocation error: ", errorMsg);
|
|
1987
|
+
if (!fulfil)
|
|
1988
|
+
throw err;
|
|
1989
|
+
return { error: errorMsg, status: "fail" };
|
|
1990
|
+
}
|
|
1991
|
+
};
|
|
1992
|
+
serverGeoCoords = async (coords, opts) => {
|
|
1993
|
+
if (!isNullish(coords)) {
|
|
1994
|
+
const lat = coords.latitude ?? coords.lat;
|
|
1995
|
+
const lng = coords.longitude ?? coords.lng ?? coords.lon ?? coords.long;
|
|
1996
|
+
if (isNumber(lat) && isNumber(lng))
|
|
1997
|
+
return { lat, lng };
|
|
1998
|
+
}
|
|
1999
|
+
const geo = await serverGeoLocation(opts);
|
|
2000
|
+
if (isNullish(geo.error) && isNumber(geo.lat) && isNumber(geo.lng))
|
|
2001
|
+
return { lat: geo.lat, lng: geo.lng };
|
|
2002
|
+
return null;
|
|
2003
|
+
};
|
|
2004
|
+
serverMapHemisphere = async (coords, opts) => {
|
|
2005
|
+
const resolved = await serverGeoCoords(coords, opts);
|
|
2006
|
+
if (resolved)
|
|
2007
|
+
return resolved.lat >= 0 ? "north" : "south";
|
|
2008
|
+
return getHemisphere() ?? null;
|
|
2009
|
+
};
|
|
2010
|
+
}
|
|
2011
|
+
});
|
|
2012
|
+
|
|
2013
|
+
// auto-inject-version:@magmacomputing/tempo/plugin/sdk
|
|
2014
|
+
var sdk_exports = {};
|
|
2015
|
+
__export(sdk_exports, {
|
|
2016
|
+
definePlugin: () => definePlugin,
|
|
2017
|
+
defineTerm: () => defineTerm
|
|
2018
|
+
});
|
|
2019
|
+
__reExport(sdk_exports, sdk_star);
|
|
2020
|
+
import * as sdk_star from "@magmacomputing/tempo/plugin/sdk";
|
|
2021
|
+
import { definePlugin as originalPlugin, defineTerm as originalTerm } from "@magmacomputing/tempo/plugin/sdk";
|
|
2022
|
+
var definePlugin = (config) => originalPlugin({ ...config, version: "0.1.0" });
|
|
2023
|
+
var defineTerm = (config) => originalTerm({ ...config, version: "0.1.0" });
|
|
2024
|
+
|
|
2025
|
+
// ../../library/dist/common/runtime/mapper.library.js
|
|
2026
|
+
init_utility_library();
|
|
2027
|
+
init_assertion_library();
|
|
2028
|
+
var coerceGeo = (input) => {
|
|
2029
|
+
if (isNullish(input) || typeof input !== "object")
|
|
2030
|
+
return void 0;
|
|
2031
|
+
const geoObj = input.geo ?? input;
|
|
2032
|
+
const cfgGeo = input.config?.geo ?? input.config;
|
|
2033
|
+
const lat = geoObj?.latitude ?? geoObj?.lat ?? input.latitude ?? input.lat ?? cfgGeo?.latitude ?? cfgGeo?.lat;
|
|
2034
|
+
const lng = geoObj?.longitude ?? geoObj?.lng ?? geoObj?.lon ?? geoObj?.long ?? input.longitude ?? input.lng ?? input.lon ?? input.long ?? cfgGeo?.longitude ?? cfgGeo?.lng ?? cfgGeo?.lon ?? cfgGeo?.long;
|
|
2035
|
+
const elevation = geoObj?.elevation ?? input.elevation ?? cfgGeo?.elevation;
|
|
2036
|
+
const sphere = geoObj?.sphere ?? input.sphere ?? cfgGeo?.sphere;
|
|
2037
|
+
const country = geoObj?.country ?? input.country ?? cfgGeo?.country;
|
|
2038
|
+
const city = geoObj?.city ?? input.city ?? cfgGeo?.city;
|
|
2039
|
+
const result = {};
|
|
2040
|
+
if (isNumber(lat))
|
|
2041
|
+
result.latitude = lat;
|
|
2042
|
+
if (isNumber(lng))
|
|
2043
|
+
result.longitude = lng;
|
|
2044
|
+
if (isNumber(elevation))
|
|
2045
|
+
result.elevation = elevation;
|
|
2046
|
+
if (sphere === "north" || sphere === "south")
|
|
2047
|
+
result.sphere = sphere;
|
|
2048
|
+
if (isString(country))
|
|
2049
|
+
result.country = country;
|
|
2050
|
+
if (isString(city))
|
|
2051
|
+
result.city = city;
|
|
2052
|
+
if (geoObj && typeof geoObj === "object") {
|
|
2053
|
+
for (const key of Object.keys(geoObj)) {
|
|
2054
|
+
if (isSafeKey(key) && !["latitude", "lat", "longitude", "lng", "lon", "long", "elevation", "sphere", "country", "city"].includes(key))
|
|
2055
|
+
result[key] = geoObj[key];
|
|
2056
|
+
}
|
|
2057
|
+
}
|
|
2058
|
+
return Object.keys(result).length > 0 ? result : void 0;
|
|
2059
|
+
};
|
|
2060
|
+
var getStashedGeo = () => {
|
|
2061
|
+
const { type } = getContext();
|
|
2062
|
+
if (type === CONTEXT.Browser || type === CONTEXT.WebWorker) {
|
|
2063
|
+
try {
|
|
2064
|
+
if (typeof localStorage !== "undefined") {
|
|
2065
|
+
const raw = localStorage.getItem("_map_");
|
|
2066
|
+
if (raw) {
|
|
2067
|
+
const parsed = JSON.parse(raw);
|
|
2068
|
+
const coords = parsed?.geolocation?.coords;
|
|
2069
|
+
if (isNumber(coords?.latitude) && isNumber(coords?.longitude)) {
|
|
2070
|
+
return { latitude: coords.latitude, longitude: coords.longitude };
|
|
2071
|
+
}
|
|
2072
|
+
}
|
|
2073
|
+
}
|
|
2074
|
+
} catch {
|
|
2075
|
+
}
|
|
2076
|
+
}
|
|
2077
|
+
return void 0;
|
|
2078
|
+
};
|
|
2079
|
+
var geoLookup = async (opts = {}) => {
|
|
2080
|
+
const { type } = getContext();
|
|
2081
|
+
switch (type) {
|
|
2082
|
+
case CONTEXT.Browser: {
|
|
2083
|
+
const { geoLocation: geoLocation2 } = await Promise.resolve().then(() => (init_mapper_library(), mapper_library_exports));
|
|
2084
|
+
const res = await geoLocation2(opts);
|
|
2085
|
+
if (res.error)
|
|
2086
|
+
return { error: res.error };
|
|
2087
|
+
const lat = res.coords?.latitude;
|
|
2088
|
+
const lng = res.coords?.longitude;
|
|
2089
|
+
return { lat, lng, latitude: lat, longitude: lng, ...res };
|
|
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);
|
|
2097
|
+
}
|
|
2098
|
+
case CONTEXT.NodeJS:
|
|
2099
|
+
case CONTEXT.Deno:
|
|
2100
|
+
default: {
|
|
2101
|
+
const { serverGeoLocation: serverGeoLocation2 } = await Promise.resolve().then(() => (init_mapper_library2(), mapper_library_exports2));
|
|
2102
|
+
return serverGeoLocation2(opts);
|
|
2103
|
+
}
|
|
2104
|
+
}
|
|
2105
|
+
};
|
|
2106
|
+
var resolveGeoCoordinates = async (input, opts = {}) => {
|
|
2107
|
+
const coerced = coerceGeo(input);
|
|
2108
|
+
if (coerced && isNumber(coerced.latitude) && isNumber(coerced.longitude))
|
|
2109
|
+
return { lat: coerced.latitude, lng: coerced.longitude };
|
|
2110
|
+
const stashed = getStashedGeo();
|
|
2111
|
+
if (stashed && isNumber(stashed.latitude) && isNumber(stashed.longitude))
|
|
2112
|
+
return { lat: stashed.latitude, lng: stashed.longitude };
|
|
2113
|
+
const lookup = await geoLookup(opts);
|
|
2114
|
+
if (isNullish(lookup.error) && isNumber(lookup.lat) && isNumber(lookup.lng))
|
|
2115
|
+
return { lat: lookup.lat, lng: lookup.lng };
|
|
2116
|
+
return null;
|
|
2117
|
+
};
|
|
2118
|
+
|
|
2119
|
+
// src/index.ts
|
|
2120
|
+
init_mapper_library2();
|
|
2121
|
+
init_mapper_library();
|
|
2122
|
+
var GeoPlugin = definePlugin({
|
|
2123
|
+
name: "geo",
|
|
2124
|
+
install(TempoClass) {
|
|
2125
|
+
TempoClass.geoLookup = geoLookup;
|
|
2126
|
+
TempoClass.resolveGeoCoordinates = resolveGeoCoordinates;
|
|
2127
|
+
TempoClass.serverGeoLocation = serverGeoLocation;
|
|
2128
|
+
TempoClass.geoLocation = geoLocation;
|
|
2129
|
+
TempoClass.prototype.geoLocate = async function(opts) {
|
|
2130
|
+
const coords = await resolveGeoCoordinates(this, opts);
|
|
2131
|
+
if (coords) {
|
|
2132
|
+
const existingGeo = typeof this.config.geo === "object" && this.config.geo !== null ? this.config.geo : {};
|
|
2133
|
+
return new TempoClass(this, {
|
|
2134
|
+
...this.config,
|
|
2135
|
+
geo: {
|
|
2136
|
+
...existingGeo,
|
|
2137
|
+
latitude: coords.lat,
|
|
2138
|
+
longitude: coords.lng
|
|
2139
|
+
}
|
|
2140
|
+
});
|
|
2141
|
+
}
|
|
2142
|
+
return this;
|
|
2143
|
+
};
|
|
2144
|
+
TempoClass.prototype.geoLookup = async function(opts) {
|
|
2145
|
+
return resolveGeoCoordinates(this, opts);
|
|
2146
|
+
};
|
|
2147
|
+
}
|
|
2148
|
+
});
|
|
2149
|
+
var geoPlugin = GeoPlugin;
|
|
2150
|
+
var index_default = GeoPlugin;
|
|
2151
|
+
export {
|
|
2152
|
+
GeoPlugin,
|
|
2153
|
+
coerceGeo,
|
|
2154
|
+
index_default as default,
|
|
2155
|
+
geoLocation,
|
|
2156
|
+
geoLookup,
|
|
2157
|
+
geoPlugin,
|
|
2158
|
+
getStashedGeo,
|
|
2159
|
+
resolveGeoCoordinates,
|
|
2160
|
+
serverGeoCoords,
|
|
2161
|
+
serverGeoLocation,
|
|
2162
|
+
serverMapHemisphere
|
|
2163
|
+
};
|