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.
@@ -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 _a, _b;
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 _a2, _b2, _c, _d;
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: (_a4 = opt.iterations) != null ? _a4 : 1e5,
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 (_a4 = parseInt(value.trim(), 10)) != null ? _a4 : defaultValue;
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 (_a4 = parseFloat(value.trim())) != null ? _a4 : defaultValue;
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 (_a4 = parseInt(String(value).trim(), 10)) != null ? _a4 : defaultValue;
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 (_a4 = parseFloat(String(value).trim())) != null ? _a4 : defaultValue;
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 (_a4 = String(value)) != null ? _a4 : defaultValue;
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((_a4 = settings.precision) != null ? _a4 : 2);
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 _a4;
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 = (_a4 = Day.from(days)) == null ? void 0 : _a4.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 _a4;
1916
- return Math.round((((_a4 = new Day(otherDay)) == null ? void 0 : _a4.toDateGMT().getTime()) - this.toDateGMT().getTime()) / DAY_MS);
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 != null ? 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 != null ? 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 = (_a4 = config2.id) != null ? _a4 : uuid();
2858
+ let id = config2.id ?? uuid();
2866
2859
  if (tasks[id] != null) {
2867
- const resolution = (_b4 = config2.idConflictResolution) != null ? _b4 : 1 /* memoize */;
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: (_c2 = config2.max) != null ? _c2 : 1,
2892
- resolved: (_d2 = config2.resolved) != null ? _d2 : 0,
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 != null ? logLevel : Infinity /* off */;
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 = ((_b4) => (_b4 = ((_a4) => (_a4 = globalThis == null ? void 0 : globalThis.location) == null ? void 0 : _a4.hostname)()) != null ? _b4 : "")()) {
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 _a4;
3177
- (_a4 = this.other) == null ? void 0 : _a4.emit("message", {
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 = (_a4 = name != null ? name : this.channel.id) != null ? _a4 : uname("pubsub");
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 = /* @__PURE__ */ __name((i) => i, "serialize"),
3440
- deserialize = /* @__PURE__ */ __name((i) => i, "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
- try {
3449
- result = await functions[method](...args);
3450
- } catch (e) {
3451
- error = String(e);
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 (mode === 4 /* reject */)
3463
- promise == null ? void 0 : promise.reject(args);
3464
- else
3465
- promise == null ? void 0 : promise.resolve(args);
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
- var _a4;
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 _a4, _b4, _c2, _d2, _e, _f, _g, _h, _i;
3607
- info.ios = ((_a4 = _navigator == null ? void 0 : _navigator.platform) == null ? void 0 : _a4.match(/(iPhone|iPod|iPad)/i)) != null;
3608
- info.macos = !!((_b4 = _navigator == null ? void 0 : _navigator.platform) == null ? void 0 : _b4.startsWith("Mac"));
3609
- info.windows = !!((_c2 = _navigator == null ? void 0 : _navigator.platform) == null ? void 0 : _c2.startsWith("Win"));
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 = (_d2 = _navigator == null ? void 0 : _navigator.userAgent) == null ? void 0 : _d2.toLowerCase()) == null ? void 0 : _e.indexOf(" electron/")) || -1) > -1 && !info.beaker;
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 != null ? value : defaultValue);
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
- var _a4, _b4, _c2, _d2;
3734
- const dotenvPath = (_b4 = options == null ? void 0 : options.path) != null ? _b4 : toPath((_a4 = options == null ? void 0 : options.filename) != null ? _a4 : ".env");
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 = (_d2 = options == null ? void 0 : options.env) != null ? _d2 : process.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 = (_a4 = opt.extension) != null ? _a4 : ".json";
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 = (_b4 = opt.objectToString) != null ? _b4 : (data) => {
3779
+ this.objectToString = opt.objectToString ?? ((data) => {
3783
3780
  return this.pretty ? JSON.stringify(data, null, 2) : JSON.stringify(data);
3784
- };
3785
- this.objectFromString = (_c2 = opt.objectFromString) != null ? _c2 : (data) => {
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 = (_d2 = opt.keyToFilename) != null ? _d2 : toValidFilename;
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 _a4, _b4;
3961
+ var _a2, _b2;
3954
3962
  if (typeof stack !== "string")
3955
3963
  return [];
3956
- return ((_b4 = (_a4 = stack == null ? void 0 : stack.split("\n")) == null ? void 0 : _a4.map((rawLine) => {
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 : _b4.filter((v) => v != null)) || [];
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 _a3, _b3;
3969
- var home = ((_a3 = process.env) == null ? void 0 : _a3.HOME) ? (0, import_path5.resolve)((_b3 = process.env) == null ? void 0 : _b3.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 _a4;
4007
+ var _a2;
4000
4008
  let stack = new Error().stack || "";
4001
- let line = (_a4 = getStackLlocationList(stack)) == null ? void 0 : _a4[level];
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 _a4;
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 (((_a4 = msg.messages) == null ? void 0 : _a4[0]) === loggerStackTraceDebug) {
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 = (_a4 = process.env.ZEED_LOG) != null ? _a4 : process.env.LOG;
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