zeed 0.7.147 → 0.7.151
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/dist/{chunk-WG7HOP7M.js → chunk-BPJRSPRG.js} +8 -9
- package/dist/{chunk-WG7HOP7M.js.map → chunk-BPJRSPRG.js.map} +1 -1
- package/dist/{chunk-7W3LTMPP.js → chunk-CLY4VF5A.js} +28 -18
- package/dist/chunk-CLY4VF5A.js.map +1 -0
- package/dist/{chunk-XWMV2GEI.js → chunk-LMZGFDSJ.js} +3 -5
- package/dist/{chunk-XWMV2GEI.js.map → chunk-LMZGFDSJ.js.map} +1 -1
- package/dist/{chunk-2KDHZAAM.js → chunk-T5YP6WMZ.js} +5 -6
- package/dist/{chunk-2KDHZAAM.js.map → chunk-T5YP6WMZ.js.map} +1 -1
- package/dist/{chunk-Z7MQRVMT.js → chunk-XX52WKOZ.js} +45 -46
- package/dist/chunk-XX52WKOZ.js.map +1 -0
- package/dist/index.all.cjs +100 -93
- package/dist/index.all.cjs.map +1 -1
- package/dist/index.all.d.ts +3 -3
- package/dist/index.all.js +11 -7
- package/dist/index.browser.cjs +63 -68
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.d.ts +2 -2
- package/dist/index.browser.js +4 -4
- package/dist/index.log.cjs +5 -8
- package/dist/index.log.cjs.map +1 -1
- package/dist/index.log.js +2 -2
- package/dist/index.node.cjs +93 -84
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.d.ts +2 -2
- package/dist/index.node.js +9 -5
- package/dist/{log-colors-7dcdbd62.d.ts → log-colors-5aa66e3b.d.ts} +1 -1
- package/dist/{log-util-5f7dcfd6.d.ts → log-util-3742711f.d.ts} +4 -2
- package/dist/{uuid-19af3724.d.ts → uuid-ab0c5451.d.ts} +11 -5
- package/package.json +8 -7
- package/dist/chunk-7W3LTMPP.js.map +0 -1
- package/dist/chunk-Z7MQRVMT.js.map +0 -1
package/dist/index.node.cjs
CHANGED
|
@@ -223,6 +223,7 @@ __export(index_node_exports, {
|
|
|
223
223
|
randomFloat: () => randomFloat,
|
|
224
224
|
randomInt: () => randomInt,
|
|
225
225
|
randomUint8Array: () => randomUint8Array,
|
|
226
|
+
readText: () => readText,
|
|
226
227
|
regExpEscape: () => regExpEscape,
|
|
227
228
|
regExpString: () => regExpString,
|
|
228
229
|
removeFolder: () => removeFolder,
|
|
@@ -303,7 +304,8 @@ __export(index_node_exports, {
|
|
|
303
304
|
valueToInteger: () => valueToInteger,
|
|
304
305
|
valueToPath: () => valueToPath,
|
|
305
306
|
valueToString: () => valueToString,
|
|
306
|
-
waitOn: () => waitOn
|
|
307
|
+
waitOn: () => waitOn,
|
|
308
|
+
writeText: () => writeText
|
|
307
309
|
});
|
|
308
310
|
module.exports = __toCommonJS(index_node_exports);
|
|
309
311
|
|
|
@@ -425,8 +427,7 @@ function getNamespaceFilterString(defaultNamespaceFilter2) {
|
|
|
425
427
|
return defaultNamespaceFilter2;
|
|
426
428
|
}
|
|
427
429
|
__name(getNamespaceFilterString, "getNamespaceFilterString");
|
|
428
|
-
var
|
|
429
|
-
var defaultNamespaceFilter = getNamespaceFilterString(typeof process !== "undefined" ? (_a = process.env.ZEED) != null ? _a : process.env.DEBUG : typeof localStorage !== "undefined" ? (_b = localStorage.zeed) != null ? _b : localStorage.debug : "*");
|
|
430
|
+
var defaultNamespaceFilter = getNamespaceFilterString(typeof process !== "undefined" ? process.env.ZEED ?? process.env.DEBUG : typeof localStorage !== "undefined" ? localStorage.zeed ?? localStorage.debug : "*");
|
|
430
431
|
function useNamespaceFilter(filter = defaultNamespaceFilter) {
|
|
431
432
|
let fn;
|
|
432
433
|
let reject = [];
|
|
@@ -478,8 +479,7 @@ function useNamespaceFilter(filter = defaultNamespaceFilter) {
|
|
|
478
479
|
return fn;
|
|
479
480
|
}
|
|
480
481
|
__name(useNamespaceFilter, "useNamespaceFilter");
|
|
481
|
-
var
|
|
482
|
-
var defaultLevelFilter = typeof process !== "undefined" ? (_b2 = (_a2 = process.env.ZEED_LEVEL) != null ? _a2 : process.env.LEVEL) != null ? _b2 : process.env.DEBUG_LEVEL : typeof localStorage !== "undefined" ? (_d = (_c = localStorage.zeed_level) != null ? _c : localStorage.level) != null ? _d : localStorage.debug_level : void 0;
|
|
482
|
+
var defaultLevelFilter = typeof process !== "undefined" ? process.env.ZEED_LEVEL ?? process.env.LEVEL ?? process.env.DEBUG_LEVEL : typeof localStorage !== "undefined" ? localStorage.zeed_level ?? localStorage.level ?? localStorage.debug_level : void 0;
|
|
483
483
|
function useLevelFilter(filter = defaultLevelFilter) {
|
|
484
484
|
let filterLevel = -1 /* all */;
|
|
485
485
|
if (typeof filter === "string") {
|
|
@@ -895,13 +895,12 @@ async function digest(message, algorithm = DEFAULT_HASH_ALG) {
|
|
|
895
895
|
}
|
|
896
896
|
__name(digest, "digest");
|
|
897
897
|
async function deriveKeyPbkdf2(secret, opt = {}) {
|
|
898
|
-
var _a4;
|
|
899
898
|
const secretBuffer = toUint8Array(secret);
|
|
900
899
|
const keyMaterial = await crypto.subtle.importKey("raw", secretBuffer, DEFAULT_DERIVE_ALG, false, ["deriveKey"]);
|
|
901
900
|
return await crypto.subtle.deriveKey({
|
|
902
901
|
name: DEFAULT_DERIVE_ALG,
|
|
903
902
|
salt: opt.salt ? toUint8Array(opt.salt) : new Uint8Array(0),
|
|
904
|
-
iterations:
|
|
903
|
+
iterations: opt.iterations ?? 1e5,
|
|
905
904
|
hash: DEFAULT_HASH_ALG
|
|
906
905
|
}, keyMaterial, {
|
|
907
906
|
name: DEFAULT_CRYPTO_ALG,
|
|
@@ -1390,17 +1389,15 @@ function stringToBoolean(value, defaultValue = false) {
|
|
|
1390
1389
|
}
|
|
1391
1390
|
__name(stringToBoolean, "stringToBoolean");
|
|
1392
1391
|
function stringToInteger(value, defaultValue = 0) {
|
|
1393
|
-
var _a4;
|
|
1394
1392
|
if (value == null || typeof value !== "string")
|
|
1395
1393
|
return defaultValue;
|
|
1396
|
-
return
|
|
1394
|
+
return parseInt(value.trim(), 10) ?? defaultValue;
|
|
1397
1395
|
}
|
|
1398
1396
|
__name(stringToInteger, "stringToInteger");
|
|
1399
1397
|
function stringToFloat(value, defaultValue = 0) {
|
|
1400
|
-
var _a4;
|
|
1401
1398
|
if (value == null || typeof value !== "string")
|
|
1402
1399
|
return defaultValue;
|
|
1403
|
-
return
|
|
1400
|
+
return parseFloat(value.trim()) ?? defaultValue;
|
|
1404
1401
|
}
|
|
1405
1402
|
__name(stringToFloat, "stringToFloat");
|
|
1406
1403
|
function valueToBoolean(value, defaultValue = false) {
|
|
@@ -1414,32 +1411,29 @@ function valueToBoolean(value, defaultValue = false) {
|
|
|
1414
1411
|
}
|
|
1415
1412
|
__name(valueToBoolean, "valueToBoolean");
|
|
1416
1413
|
function valueToInteger(value, defaultValue = 0) {
|
|
1417
|
-
var _a4;
|
|
1418
1414
|
if (value == null)
|
|
1419
1415
|
return defaultValue;
|
|
1420
1416
|
if (typeof value === "boolean")
|
|
1421
1417
|
return value ? 1 : 0;
|
|
1422
1418
|
if (typeof value === "number")
|
|
1423
1419
|
return Math.floor(value);
|
|
1424
|
-
return
|
|
1420
|
+
return parseInt(String(value).trim(), 10) ?? defaultValue;
|
|
1425
1421
|
}
|
|
1426
1422
|
__name(valueToInteger, "valueToInteger");
|
|
1427
1423
|
function valueToFloat(value, defaultValue = 0) {
|
|
1428
|
-
var _a4;
|
|
1429
1424
|
if (value == null)
|
|
1430
1425
|
return defaultValue;
|
|
1431
1426
|
if (typeof value === "boolean")
|
|
1432
1427
|
return value ? 1 : 0;
|
|
1433
1428
|
if (typeof value === "number")
|
|
1434
1429
|
return Math.floor(value);
|
|
1435
|
-
return
|
|
1430
|
+
return parseFloat(String(value).trim()) ?? defaultValue;
|
|
1436
1431
|
}
|
|
1437
1432
|
__name(valueToFloat, "valueToFloat");
|
|
1438
1433
|
function valueToString(value, defaultValue = "") {
|
|
1439
|
-
var _a4;
|
|
1440
1434
|
if (value == null)
|
|
1441
1435
|
return defaultValue;
|
|
1442
|
-
return
|
|
1436
|
+
return String(value) ?? defaultValue;
|
|
1443
1437
|
}
|
|
1444
1438
|
__name(valueToString, "valueToString");
|
|
1445
1439
|
var toFloat = valueToFloat;
|
|
@@ -1499,9 +1493,8 @@ function currency(value, opts = {}) {
|
|
|
1499
1493
|
__name(currency, "currency");
|
|
1500
1494
|
var _Currency = class {
|
|
1501
1495
|
constructor(value, opts = {}) {
|
|
1502
|
-
var _a4;
|
|
1503
1496
|
let settings = Object.assign({}, defaults, opts);
|
|
1504
|
-
let precision = pow(
|
|
1497
|
+
let precision = pow(settings.precision ?? 2);
|
|
1505
1498
|
let v = parse(value, settings);
|
|
1506
1499
|
this.intValue = v;
|
|
1507
1500
|
this.value = v / precision;
|
|
@@ -1824,13 +1817,13 @@ var Day = class {
|
|
|
1824
1817
|
return this.days;
|
|
1825
1818
|
}
|
|
1826
1819
|
constructor(days) {
|
|
1827
|
-
var
|
|
1820
|
+
var _a2;
|
|
1828
1821
|
if (typeof days === "number") {
|
|
1829
1822
|
this.days = days;
|
|
1830
1823
|
return;
|
|
1831
1824
|
}
|
|
1832
1825
|
if (days != null) {
|
|
1833
|
-
days = (
|
|
1826
|
+
days = (_a2 = Day.from(days)) == null ? void 0 : _a2.days;
|
|
1834
1827
|
}
|
|
1835
1828
|
if (days == null) {
|
|
1836
1829
|
const date = new Date();
|
|
@@ -1912,8 +1905,8 @@ var Day = class {
|
|
|
1912
1905
|
return Day.from([this.year + yy, mm, this.day]);
|
|
1913
1906
|
}
|
|
1914
1907
|
daysUntil(otherDay) {
|
|
1915
|
-
var
|
|
1916
|
-
return Math.round((((
|
|
1908
|
+
var _a2;
|
|
1909
|
+
return Math.round((((_a2 = new Day(otherDay)) == null ? void 0 : _a2.toDateGMT().getTime()) - this.toDateGMT().getTime()) / DAY_MS);
|
|
1917
1910
|
}
|
|
1918
1911
|
yesterday() {
|
|
1919
1912
|
return this.dayOffset(-1);
|
|
@@ -2230,7 +2223,7 @@ var XRX = class {
|
|
|
2230
2223
|
constructor(pattern2, flags) {
|
|
2231
2224
|
this.namedGroups = {};
|
|
2232
2225
|
this.names = [];
|
|
2233
|
-
let _flags = flags
|
|
2226
|
+
let _flags = flags ?? "";
|
|
2234
2227
|
let _rx;
|
|
2235
2228
|
if (pattern2 instanceof RegExp) {
|
|
2236
2229
|
if (flags == null) {
|
|
@@ -2343,7 +2336,7 @@ async function callDisposer(disposable) {
|
|
|
2343
2336
|
}
|
|
2344
2337
|
__name(callDisposer, "callDisposer");
|
|
2345
2338
|
function useDispose(config) {
|
|
2346
|
-
const { name } = typeof config === "string" ? { name: config } : config
|
|
2339
|
+
const { name } = typeof config === "string" ? { name: config } : config ?? {};
|
|
2347
2340
|
let tracked = [];
|
|
2348
2341
|
const untrack = /* @__PURE__ */ __name(async (disposable) => {
|
|
2349
2342
|
if (disposable != null && tracked.includes(disposable)) {
|
|
@@ -2505,12 +2498,17 @@ var Emitter = class {
|
|
|
2505
2498
|
constructor() {
|
|
2506
2499
|
this.subscribers = {};
|
|
2507
2500
|
this.subscribersOnAny = [];
|
|
2501
|
+
this.dispose = useDispose("emitter");
|
|
2508
2502
|
this.call = new Proxy({}, {
|
|
2509
2503
|
get: (target, name) => (...args) => this.emit(name, ...args)
|
|
2510
2504
|
});
|
|
2511
2505
|
}
|
|
2512
2506
|
async emit(event, ...args) {
|
|
2513
2507
|
let ok = false;
|
|
2508
|
+
this.dispose.add(() => {
|
|
2509
|
+
this.subscribers = {};
|
|
2510
|
+
this.subscribersOnAny = [];
|
|
2511
|
+
});
|
|
2514
2512
|
try {
|
|
2515
2513
|
let subscribers = this.subscribers[event] || [];
|
|
2516
2514
|
this.subscribersOnAny.forEach((fn) => fn(event, ...args));
|
|
@@ -2564,10 +2562,6 @@ var Emitter = class {
|
|
|
2564
2562
|
this.subscribers = {};
|
|
2565
2563
|
return this;
|
|
2566
2564
|
}
|
|
2567
|
-
dispose() {
|
|
2568
|
-
this.subscribers = {};
|
|
2569
|
-
this.subscribersOnAny = [];
|
|
2570
|
-
}
|
|
2571
2565
|
};
|
|
2572
2566
|
__name(Emitter, "Emitter");
|
|
2573
2567
|
function getGlobalEmitter() {
|
|
@@ -2859,12 +2853,11 @@ function usePool(config = {}) {
|
|
|
2859
2853
|
}
|
|
2860
2854
|
__name(cancelAll, "cancelAll");
|
|
2861
2855
|
function enqueue(task, config2 = {}) {
|
|
2862
|
-
var _a4, _b4, _c2, _d2;
|
|
2863
2856
|
let done;
|
|
2864
2857
|
let promise = new Promise((resolve5) => done = resolve5);
|
|
2865
|
-
let id =
|
|
2858
|
+
let id = config2.id ?? uuid();
|
|
2866
2859
|
if (tasks[id] != null) {
|
|
2867
|
-
const resolution =
|
|
2860
|
+
const resolution = config2.idConflictResolution ?? 1 /* memoize */;
|
|
2868
2861
|
if (resolution === 0 /* replace */) {
|
|
2869
2862
|
cancel(id);
|
|
2870
2863
|
} else if (resolution === 1 /* memoize */) {
|
|
@@ -2888,8 +2881,8 @@ function usePool(config = {}) {
|
|
|
2888
2881
|
task,
|
|
2889
2882
|
priority: ++priority,
|
|
2890
2883
|
state: 0 /* waiting */,
|
|
2891
|
-
max:
|
|
2892
|
-
resolved:
|
|
2884
|
+
max: config2.max ?? 1,
|
|
2885
|
+
resolved: config2.resolved ?? 0,
|
|
2893
2886
|
done,
|
|
2894
2887
|
payload: config2.payload,
|
|
2895
2888
|
setMax(max) {
|
|
@@ -2939,7 +2932,7 @@ var SerialQueue = class extends Emitter {
|
|
|
2939
2932
|
const { name = uname("queue"), logLevel } = opt;
|
|
2940
2933
|
this.name = name;
|
|
2941
2934
|
this.log = Logger(`zeed:queue:${name}`);
|
|
2942
|
-
this.log.level = logLevel
|
|
2935
|
+
this.log.level = logLevel ?? Infinity /* off */;
|
|
2943
2936
|
}
|
|
2944
2937
|
async performNext() {
|
|
2945
2938
|
this.log(`performNext, queue.length =`, this.queue.length);
|
|
@@ -3137,7 +3130,7 @@ function debounce(callback, opt = {}) {
|
|
|
3137
3130
|
__name(debounce, "debounce");
|
|
3138
3131
|
|
|
3139
3132
|
// src/common/localhost.ts
|
|
3140
|
-
function isLocalHost(hostname = ((
|
|
3133
|
+
function isLocalHost(hostname = ((_a2) => (_a2 = globalThis == null ? void 0 : globalThis.location) == null ? void 0 : _a2.hostname)() ?? "") {
|
|
3141
3134
|
return ["localhost", "127.0.0.1", "", "::1", "::"].includes(hostname) || hostname.startsWith("192.168.") || hostname.startsWith("10.0.") || hostname.endsWith(".local");
|
|
3142
3135
|
}
|
|
3143
3136
|
__name(isLocalHost, "isLocalHost");
|
|
@@ -3173,8 +3166,8 @@ var LocalChannel = class extends Channel {
|
|
|
3173
3166
|
this.isConnected = true;
|
|
3174
3167
|
}
|
|
3175
3168
|
postMessage(data) {
|
|
3176
|
-
var
|
|
3177
|
-
(
|
|
3169
|
+
var _a2;
|
|
3170
|
+
(_a2 = this.other) == null ? void 0 : _a2.emit("message", {
|
|
3178
3171
|
data,
|
|
3179
3172
|
origin: "local",
|
|
3180
3173
|
lastEventId: uuid()
|
|
@@ -3368,7 +3361,6 @@ __name(useMessageHub, "useMessageHub");
|
|
|
3368
3361
|
// src/common/msg/pubsub.ts
|
|
3369
3362
|
var PubSub = class extends Emitter {
|
|
3370
3363
|
constructor(opt) {
|
|
3371
|
-
var _a4;
|
|
3372
3364
|
super();
|
|
3373
3365
|
this.publish = this.emit;
|
|
3374
3366
|
this.subscribe = this.on;
|
|
@@ -3376,7 +3368,7 @@ var PubSub = class extends Emitter {
|
|
|
3376
3368
|
this.channel = channel;
|
|
3377
3369
|
this.encoder = encoder;
|
|
3378
3370
|
this.debug = debug;
|
|
3379
|
-
this.name =
|
|
3371
|
+
this.name = name ?? this.channel.id ?? uname("pubsub");
|
|
3380
3372
|
this.log = Logger(`${this.shortId}`);
|
|
3381
3373
|
if (this.debug) {
|
|
3382
3374
|
this.channel.on("connect", () => {
|
|
@@ -3407,9 +3399,9 @@ var PubSub = class extends Emitter {
|
|
|
3407
3399
|
async emit(event, ...args) {
|
|
3408
3400
|
try {
|
|
3409
3401
|
if (this.debug)
|
|
3410
|
-
this.log(`emit(${event})`, event);
|
|
3402
|
+
this.log(`emit(${String(event)})`, event);
|
|
3411
3403
|
else
|
|
3412
|
-
this.log(`emit(${event})`, args.length);
|
|
3404
|
+
this.log(`emit(${String(event)})`, args.length);
|
|
3413
3405
|
if (!this.channel.isConnected) {
|
|
3414
3406
|
this.log.warn("channel not connected");
|
|
3415
3407
|
return false;
|
|
@@ -3418,7 +3410,7 @@ var PubSub = class extends Emitter {
|
|
|
3418
3410
|
this.channel.postMessage(data);
|
|
3419
3411
|
return true;
|
|
3420
3412
|
} catch (err) {
|
|
3421
|
-
this.log.warn(`emit(${event})`, err);
|
|
3413
|
+
this.log.warn(`emit(${String(event)})`, err);
|
|
3422
3414
|
}
|
|
3423
3415
|
return false;
|
|
3424
3416
|
}
|
|
@@ -3431,13 +3423,15 @@ __name(usePubSub, "usePubSub");
|
|
|
3431
3423
|
|
|
3432
3424
|
// src/common/msg/rpc.ts
|
|
3433
3425
|
var rpcCounter = 1;
|
|
3426
|
+
var defaultSerialize = /* @__PURE__ */ __name((i) => i, "defaultSerialize");
|
|
3427
|
+
var defaultDeserialize = defaultSerialize;
|
|
3434
3428
|
function useRPC(functions, options) {
|
|
3435
3429
|
const {
|
|
3436
3430
|
post,
|
|
3437
3431
|
on,
|
|
3438
3432
|
eventNames = [],
|
|
3439
|
-
serialize =
|
|
3440
|
-
deserialize =
|
|
3433
|
+
serialize = defaultSerialize,
|
|
3434
|
+
deserialize = defaultDeserialize
|
|
3441
3435
|
} = options;
|
|
3442
3436
|
const rpcPromiseMap = /* @__PURE__ */ new Map();
|
|
3443
3437
|
on(async (data) => {
|
|
@@ -3445,10 +3439,14 @@ function useRPC(functions, options) {
|
|
|
3445
3439
|
const [mode, args, id, method] = msg;
|
|
3446
3440
|
if (mode === 1 /* request */ || mode === 2 /* event */) {
|
|
3447
3441
|
let result, error;
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3442
|
+
if (method != null) {
|
|
3443
|
+
try {
|
|
3444
|
+
result = await functions[method](...args);
|
|
3445
|
+
} catch (e) {
|
|
3446
|
+
error = String(e);
|
|
3447
|
+
}
|
|
3448
|
+
} else {
|
|
3449
|
+
error = "Method implementation missing";
|
|
3452
3450
|
}
|
|
3453
3451
|
if (mode === 1 /* request */ && id) {
|
|
3454
3452
|
if (error) {
|
|
@@ -3459,10 +3457,12 @@ function useRPC(functions, options) {
|
|
|
3459
3457
|
}
|
|
3460
3458
|
} else if (id) {
|
|
3461
3459
|
const promise = rpcPromiseMap.get(id);
|
|
3462
|
-
if (
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
|
|
3460
|
+
if (promise != null) {
|
|
3461
|
+
if (mode === 4 /* reject */)
|
|
3462
|
+
promise.reject(args);
|
|
3463
|
+
else
|
|
3464
|
+
promise.resolve(args);
|
|
3465
|
+
}
|
|
3466
3466
|
rpcPromiseMap.delete(id);
|
|
3467
3467
|
}
|
|
3468
3468
|
});
|
|
@@ -3578,8 +3578,7 @@ function getNavigator() {
|
|
|
3578
3578
|
}
|
|
3579
3579
|
__name(getNavigator, "getNavigator");
|
|
3580
3580
|
function getGlobal() {
|
|
3581
|
-
|
|
3582
|
-
return ((_a4 = getWindow()) != null ? _a4 : typeof WorkerGlobalScope !== "undefined") ? self : typeof global !== "undefined" ? global : Function("return this;")();
|
|
3581
|
+
return getWindow() ?? typeof WorkerGlobalScope !== "undefined" ? self : typeof global !== "undefined" ? global : Function("return this;")();
|
|
3583
3582
|
}
|
|
3584
3583
|
__name(getGlobal, "getGlobal");
|
|
3585
3584
|
var _navigator = getNavigator();
|
|
@@ -3603,12 +3602,12 @@ function detect(info = {
|
|
|
3603
3602
|
appleNative: false,
|
|
3604
3603
|
touch: false
|
|
3605
3604
|
}) {
|
|
3606
|
-
var
|
|
3607
|
-
info.ios = ((
|
|
3608
|
-
info.macos = !!((
|
|
3609
|
-
info.windows = !!((
|
|
3605
|
+
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i;
|
|
3606
|
+
info.ios = ((_a2 = _navigator == null ? void 0 : _navigator.platform) == null ? void 0 : _a2.match(/(iPhone|iPod|iPad)/i)) != null;
|
|
3607
|
+
info.macos = !!((_b2 = _navigator == null ? void 0 : _navigator.platform) == null ? void 0 : _b2.startsWith("Mac"));
|
|
3608
|
+
info.windows = !!((_c = _navigator == null ? void 0 : _navigator.platform) == null ? void 0 : _c.startsWith("Win"));
|
|
3610
3609
|
info.beaker = (_window == null ? void 0 : _window["beaker"]) != null;
|
|
3611
|
-
info.electron = (((_e = (
|
|
3610
|
+
info.electron = (((_e = (_d = _navigator == null ? void 0 : _navigator.userAgent) == null ? void 0 : _d.toLowerCase()) == null ? void 0 : _e.indexOf(" electron/")) || -1) > -1 && !info.beaker;
|
|
3612
3611
|
info.wkwebview = ((_f = _window == null ? void 0 : _window.webkit) == null ? void 0 : _f["messageHandlers"]) != null;
|
|
3613
3612
|
info.pwa = (_navigator == null ? void 0 : _navigator.serviceWorker) != null;
|
|
3614
3613
|
info.pwaInstalled = (_navigator == null ? void 0 : _navigator.standalone) || ((_h = (_g = _window == null ? void 0 : _window.matchMedia) == null ? void 0 : _g.call(_window, "(display-mode: standalone)")) == null ? void 0 : _h.matches);
|
|
@@ -3719,7 +3718,7 @@ function parse2(src, options = {}) {
|
|
|
3719
3718
|
}
|
|
3720
3719
|
__name(parse2, "parse");
|
|
3721
3720
|
function stringToPath(value, defaultValue = ".") {
|
|
3722
|
-
return (0, import_path.resolve)(process.cwd(), value
|
|
3721
|
+
return (0, import_path.resolve)(process.cwd(), value ?? defaultValue);
|
|
3723
3722
|
}
|
|
3724
3723
|
__name(stringToPath, "stringToPath");
|
|
3725
3724
|
function valueToPath(value, defaultValue = "") {
|
|
@@ -3730,9 +3729,8 @@ function valueToPath(value, defaultValue = "") {
|
|
|
3730
3729
|
__name(valueToPath, "valueToPath");
|
|
3731
3730
|
var toPath = valueToPath;
|
|
3732
3731
|
function setupEnv(options = {}) {
|
|
3733
|
-
|
|
3734
|
-
const
|
|
3735
|
-
const encoding = (_c2 = options == null ? void 0 : options.encoding) != null ? _c2 : "utf8";
|
|
3732
|
+
const dotenvPath = (options == null ? void 0 : options.path) ?? toPath((options == null ? void 0 : options.filename) ?? ".env");
|
|
3733
|
+
const encoding = (options == null ? void 0 : options.encoding) ?? "utf8";
|
|
3736
3734
|
const debug = (options == null ? void 0 : options.debug) || false;
|
|
3737
3735
|
if (debug !== true)
|
|
3738
3736
|
log10.level = Infinity /* off */;
|
|
@@ -3740,7 +3738,7 @@ function setupEnv(options = {}) {
|
|
|
3740
3738
|
const parsedEnv = import_fs.default.existsSync(dotenvPath) ? parse2(import_fs.default.readFileSync(dotenvPath, { encoding }), { debug }) : {};
|
|
3741
3739
|
const parsedEnvLocal = import_fs.default.existsSync(dotenvPath + ".local") ? parse2(import_fs.default.readFileSync(dotenvPath + ".local", { encoding }), { debug }) : {};
|
|
3742
3740
|
const parsed = Object.assign({}, parsedEnv, parsedEnvLocal);
|
|
3743
|
-
let env = (
|
|
3741
|
+
let env = (options == null ? void 0 : options.env) ?? process.env;
|
|
3744
3742
|
Object.entries(parsed).forEach(([key, value]) => {
|
|
3745
3743
|
if (typeof (options == null ? void 0 : options.prefix) === "string") {
|
|
3746
3744
|
key = (options == null ? void 0 : options.prefix) + key;
|
|
@@ -3771,25 +3769,24 @@ var FileStorage = class {
|
|
|
3771
3769
|
this.store = {};
|
|
3772
3770
|
this.fileKeys = void 0;
|
|
3773
3771
|
this.pretty = false;
|
|
3774
|
-
var _a4, _b4, _c2, _d2;
|
|
3775
3772
|
this.dirname = (0, import_path2.resolve)(process.cwd(), opt.path || ".fileStorage");
|
|
3776
3773
|
this.pretty = !!opt.pretty;
|
|
3777
|
-
this.extension =
|
|
3774
|
+
this.extension = opt.extension ?? ".json";
|
|
3778
3775
|
if (opt.extension && !this.extension.startsWith(".")) {
|
|
3779
3776
|
this.extension = "." + this.extension;
|
|
3780
3777
|
}
|
|
3781
3778
|
this.extensionLength = this.extension.length;
|
|
3782
|
-
this.objectToString =
|
|
3779
|
+
this.objectToString = opt.objectToString ?? ((data) => {
|
|
3783
3780
|
return this.pretty ? JSON.stringify(data, null, 2) : JSON.stringify(data);
|
|
3784
|
-
};
|
|
3785
|
-
this.objectFromString =
|
|
3781
|
+
});
|
|
3782
|
+
this.objectFromString = opt.objectFromString ?? ((data) => {
|
|
3786
3783
|
try {
|
|
3787
3784
|
return JSON.parse(data);
|
|
3788
3785
|
} catch (err) {
|
|
3789
3786
|
log11.warn(`fileStorage parse error '${err}' in`, data);
|
|
3790
3787
|
}
|
|
3791
|
-
};
|
|
3792
|
-
this.keyToFilename =
|
|
3788
|
+
});
|
|
3789
|
+
this.keyToFilename = opt.keyToFilename ?? toValidFilename;
|
|
3793
3790
|
}
|
|
3794
3791
|
setItem(key, value) {
|
|
3795
3792
|
this.store[key] = cloneObject(value);
|
|
@@ -3895,6 +3892,17 @@ async function removeFolder(...parts) {
|
|
|
3895
3892
|
return path;
|
|
3896
3893
|
}
|
|
3897
3894
|
__name(removeFolder, "removeFolder");
|
|
3895
|
+
async function readText(...parts) {
|
|
3896
|
+
const path = (0, import_node_path.join)(...parts);
|
|
3897
|
+
if (await exists(path)) {
|
|
3898
|
+
return await (0, import_promises.readFile)(path, "utf-8");
|
|
3899
|
+
}
|
|
3900
|
+
}
|
|
3901
|
+
__name(readText, "readText");
|
|
3902
|
+
async function writeText(path, content) {
|
|
3903
|
+
await (0, import_promises.writeFile)(path, content, "utf-8");
|
|
3904
|
+
}
|
|
3905
|
+
__name(writeText, "writeText");
|
|
3898
3906
|
|
|
3899
3907
|
// src/node/log-file.ts
|
|
3900
3908
|
var import_fs3 = require("fs");
|
|
@@ -3950,10 +3958,10 @@ var import_tty = __toESM(require("tty"), 1);
|
|
|
3950
3958
|
// src/node/log-util.ts
|
|
3951
3959
|
var import_path5 = require("path");
|
|
3952
3960
|
function getStackLlocationList(stack) {
|
|
3953
|
-
var
|
|
3961
|
+
var _a2, _b2;
|
|
3954
3962
|
if (typeof stack !== "string")
|
|
3955
3963
|
return [];
|
|
3956
|
-
return ((
|
|
3964
|
+
return ((_b2 = (_a2 = stack == null ? void 0 : stack.split("\n")) == null ? void 0 : _a2.map((rawLine) => {
|
|
3957
3965
|
let m = rawLine.match(/^\s+at.*(\((.*)\)|file:\/\/(.*)$)|\s*at\s(\/.*)$/);
|
|
3958
3966
|
if (m) {
|
|
3959
3967
|
let line = m[3] || m[2] || m[4];
|
|
@@ -3961,12 +3969,12 @@ function getStackLlocationList(stack) {
|
|
|
3961
3969
|
line = line.slice(0, -1);
|
|
3962
3970
|
return line;
|
|
3963
3971
|
}
|
|
3964
|
-
})) == null ? void 0 :
|
|
3972
|
+
})) == null ? void 0 : _b2.filter((v) => v != null)) || [];
|
|
3965
3973
|
}
|
|
3966
3974
|
__name(getStackLlocationList, "getStackLlocationList");
|
|
3967
3975
|
var cwd = (0, import_path5.resolve)(process.cwd());
|
|
3968
|
-
var
|
|
3969
|
-
var home = ((
|
|
3976
|
+
var _a, _b;
|
|
3977
|
+
var home = ((_a = process.env) == null ? void 0 : _a.HOME) ? (0, import_path5.resolve)((_b = process.env) == null ? void 0 : _b.HOME) : "";
|
|
3970
3978
|
function pathStripCwd(path) {
|
|
3971
3979
|
if (path.includes("/node_modules/")) {
|
|
3972
3980
|
return "";
|
|
@@ -3996,9 +4004,9 @@ function extractFileInfo(stackLine) {
|
|
|
3996
4004
|
}
|
|
3997
4005
|
__name(extractFileInfo, "extractFileInfo");
|
|
3998
4006
|
function getSourceLocation(level = 2, stripCwd = true) {
|
|
3999
|
-
var
|
|
4007
|
+
var _a2;
|
|
4000
4008
|
let stack = new Error().stack || "";
|
|
4001
|
-
let line = (
|
|
4009
|
+
let line = (_a2 = getStackLlocationList(stack)) == null ? void 0 : _a2[level];
|
|
4002
4010
|
if (line && stripCwd) {
|
|
4003
4011
|
line = pathStripCwd(line);
|
|
4004
4012
|
}
|
|
@@ -4099,7 +4107,7 @@ function LoggerNodeHandler(opt = {}) {
|
|
|
4099
4107
|
const matchesNamespace = useNamespaceFilter(filter);
|
|
4100
4108
|
const matchesLevel = useLevelFilter(level);
|
|
4101
4109
|
return (msg) => {
|
|
4102
|
-
var
|
|
4110
|
+
var _a2;
|
|
4103
4111
|
if (!matchesLevel(msg.level))
|
|
4104
4112
|
return;
|
|
4105
4113
|
if (!matchesNamespace(msg.name))
|
|
@@ -4137,7 +4145,7 @@ function LoggerNodeHandler(opt = {}) {
|
|
|
4137
4145
|
args = [displayName, ...msg.messages];
|
|
4138
4146
|
args.push(`+${diff}`);
|
|
4139
4147
|
}
|
|
4140
|
-
if (((
|
|
4148
|
+
if (((_a2 = msg.messages) == null ? void 0 : _a2[0]) === loggerStackTraceDebug) {
|
|
4141
4149
|
console.log(getStack());
|
|
4142
4150
|
}
|
|
4143
4151
|
if (stack) {
|
|
@@ -4183,14 +4191,13 @@ __name(LoggerNodeHandler, "LoggerNodeHandler");
|
|
|
4183
4191
|
|
|
4184
4192
|
// src/node/log-context-node.ts
|
|
4185
4193
|
function setupLogContextNode() {
|
|
4186
|
-
var _a4;
|
|
4187
4194
|
let handlers = [
|
|
4188
4195
|
LoggerNodeHandler({
|
|
4189
4196
|
padding: 32,
|
|
4190
4197
|
nameBrackets: false
|
|
4191
4198
|
})
|
|
4192
4199
|
];
|
|
4193
|
-
let logFilePath =
|
|
4200
|
+
let logFilePath = process.env.ZEED_LOG ?? process.env.LOG;
|
|
4194
4201
|
if (logFilePath) {
|
|
4195
4202
|
handlers.unshift(LoggerFileHandler(toPath(logFilePath)));
|
|
4196
4203
|
}
|
|
@@ -4383,6 +4390,7 @@ setupLogContextNode();
|
|
|
4383
4390
|
randomFloat,
|
|
4384
4391
|
randomInt,
|
|
4385
4392
|
randomUint8Array,
|
|
4393
|
+
readText,
|
|
4386
4394
|
regExpEscape,
|
|
4387
4395
|
regExpString,
|
|
4388
4396
|
removeFolder,
|
|
@@ -4463,6 +4471,7 @@ setupLogContextNode();
|
|
|
4463
4471
|
valueToInteger,
|
|
4464
4472
|
valueToPath,
|
|
4465
4473
|
valueToString,
|
|
4466
|
-
waitOn
|
|
4474
|
+
waitOn,
|
|
4475
|
+
writeText
|
|
4467
4476
|
});
|
|
4468
4477
|
//# sourceMappingURL=index.node.cjs.map
|