zeed 0.7.113 → 0.7.117

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.
@@ -1,3 +1,3 @@
1
- export { bZ as ArgumentsType, c4 as AsyncMutex, M as BinInput, by as Channel, bx as ChannelMessageEvent, bM as CryptoEncoder, ai as Currency, ag as CurrencyInput, au as DAY_MS, aw as Day, av as DayInput, bE as DefaultListener, bi as Disposable, bh as Disposer, bg as DisposerFunction, bF as Emitter, bC as EmitterAllHandler, bB as EmitterHandler, bJ as Encoder, cF as Json, bL as JsonEncoder, bD as ListenerSignature, bz as LocalChannel, bt as LoggerConsoleHandler, cz as MemStorage, cy as MemStorageOptions, bP as Message, bN as MessageAction, bT as MessageDefinitions, bU as MessageHub, bO as MessageResult, bR as MessagesDefaultMethods, bS as MessagesMethods, bQ as MessagesOptions, c3 as Mutex, cH as NestedArray, bK as NoopEncoder, cG as ObjectStorage, cl as Pool, aE as Primitive, bX as PubSub, cw as QueueTask, c0 as RPCFn, b$ as RPCOptions, c1 as RPCReturn, ac as RenderMessagesOptions, b_ as ReturnType, aj as RoundingMode, cx as SerialQueue, b0 as SortableItem, X as Uint8ArrayToJson, U as Uint8ArrayToString, bn as UseDefer, bk as UseDispose, N as _decodeUtf8Polyfill, _ as _encodeUtf8Polyfill, p as arrayEmptyInPlace, n as arrayFilterInPlace, i as arrayFlatten, j as arrayIntersection, t as arrayIsEqual, y as arrayMax, z as arrayMin, g as arrayMinus, x as arrayRandomElement, l as arrayRemoveElement, m as arraySetElement, v as arrayShuffle, w as arrayShuffleForce, u as arrayShuffleInPlace, q as arraySorted, s as arraySortedNumbers, k as arraySymmetricDifference, o as arrayToggleInPlace, h as arrayUnion, f as arrayUnique, aV as between, bf as cloneJsonObject, be as cloneObject, aY as cmp, aX as composeOrderby, A as createArray, bV as createPromiseProxy, c as csv, ah as currency, az as day, cB as debounce, D as decodeBase16, F as decodeBase32, H as decodeBase58, J as decodeBase62, L as decodeBase64, b as decrypt, aA as deepEqual, aB as deepMerge, a as deriveKeyPbkdf2, cg as detect, d as digest, bd as empty, C as encodeBase16, E as encodeBase32, G as encodeBase58, I as encodeBase62, K as encodeBase64, b7 as encodeQuery, e as encrypt, b2 as endSortWeight, b9 as ensureKey, ba as ensureKeyAsync, V as equalBinary, aC as escapeHTML, a$ as escapeRegExp, bA as fakeWorkerPair, c8 as fetchBasic, c9 as fetchJson, ca as fetchOptionsFormURLEncoded, cb as fetchOptionsJson, cc as fetchText, af as fixBrokenUth8String, ax as forEachDay, ad as formatMessages, cD as formatMilliseconds, T as fromBase64, a0 as fromCamelCase, cf as getGlobal, br as getGlobalContext, bG as getGlobalEmitter, bu as getNamespaceFilterString, ce as getNavigator, aQ as getSecureRandom, aR as getSecureRandomIfPossible, cC as getTimestamp, cd as getWindow, c7 as httpMethod, cn as immediate, aH as isArray, aN as isBoolean, ch as isBrowser, al as isEven, ak as isHalf, aL as isInteger, bs as isLocalHost, aO as isNullOrUndefined, aK as isNumber, aF as isObject, aG as isPrimitive, cu as isPromise, aI as isRecord, aM as isSafeInteger, aJ as isString, cr as isTimeout, aP as jsonStringify, W as jsonToUint8Array, bc as last, bI as lazyListener, b5 as linkifyPlainText, bH as messages, b3 as moveSortWeight, cE as parseDate, aW as parseOrderby, b8 as parseQuery, ci as platform, cv as promisify, cP as qid, aS as randomBoolean, aU as randomFloat, aT as randomInt, r as randomUint8Array, ae as renderMessages, an as roundDown, aq as roundHalfAwayFromZero, ar as roundHalfDown, as as roundHalfEven, ap as roundHalfOdd, at as roundHalfTowardsZero, ao as roundHalfUp, am as roundUp, bb as size, cm as sleep, b4 as sortedItems, aZ as sortedOrderby, b1 as startSortWeight, a1 as stringToBoolean, a3 as stringToFloat, a2 as stringToInteger, O as stringToUInt8Array, cS as suid, cR as suidBytes, cU as suidBytesDate, cT as suidDate, cA as throttle, cp as timeout, co as timeoutReached, cq as timoutError, R as toBase64, S as toBase64Url, ab as toBool, Y as toCamelCase, Z as toCapitalize, $ as toCapitalizeWords, a8 as toFloat, Q as toHex, b6 as toHumanReadableUrl, a9 as toInt, aa as toString, P as toUint8Array, a_ as toValidFilename, ay as today, cs as tryTimeout, cO as uname, aD as unescapeHTML, c6 as useAsyncMutex, B as useBase, bm as useDefer, bj as useDispose, bl as useDisposer, bq as useEventListener, cj as useExitHandler, bp as useInterval, bw as useLevelFilter, bW as useMessageHub, c5 as useMutex, bv as useNamespaceFilter, ck as usePool, bY as usePubSub, c2 as useRPC, bo as useTimeout, cK as uuid, cJ as uuid32bit, cN as uuidB32, cI as uuidBytes, cM as uuidDecode, cL as uuidEncode, cQ as uuidv4, a4 as valueToBoolean, a6 as valueToFloat, a5 as valueToInteger, a7 as valueToString, ct as waitOn } from './uuid-7c205442';
1
+ export { c6 as ArgumentsType, cd as AsyncMutex, P as BinInput, bH as Channel, bG as ChannelMessageEvent, bV as CryptoEncoder, al as Currency, aj as CurrencyInput, ax as DAY_MS, az as Day, ay as DayInput, bN as DefaultListener, br as Disposable, bq as Disposer, bp as DisposerFunction, bO as Emitter, bL as EmitterAllHandler, bK as EmitterHandler, bS as Encoder, cO as Json, bU as JsonEncoder, bM as ListenerSignature, bI as LocalChannel, bC as LoggerConsoleHandler, cI as MemStorage, cH as MemStorageOptions, bY as Message, bW as MessageAction, c0 as MessageDefinitions, c1 as MessageHub, bX as MessageResult, b_ as MessagesDefaultMethods, b$ as MessagesMethods, bZ as MessagesOptions, cc as Mutex, cQ as NestedArray, bT as NoopEncoder, cP as ObjectStorage, cu as Pool, aH as Primitive, c4 as PubSub, cF as QueueTask, c9 as RPCFn, c8 as RPCOptions, ca as RPCReturn, af as RenderMessagesOptions, c7 as ReturnType, am as RoundingMode, cG as SerialQueue, b5 as SortableItem, $ as Uint8ArrayToJson, U as Uint8ArrayToString, bw as UseDefer, bt as UseDispose, bo as XRX, Q as _decodeUtf8Polyfill, _ as _encodeUtf8Polyfill, B as arrayAvg, C as arrayBatches, p as arrayEmptyInPlace, n as arrayFilterInPlace, i as arrayFlatten, j as arrayIntersection, t as arrayIsEqual, y as arrayMax, z as arrayMin, g as arrayMinus, x as arrayRandomElement, l as arrayRemoveElement, m as arraySetElement, v as arrayShuffle, w as arrayShuffleForce, u as arrayShuffleInPlace, q as arraySorted, s as arraySortedNumbers, A as arraySum, k as arraySymmetricDifference, o as arrayToggleInPlace, h as arrayUnion, f as arrayUnique, a_ as avg, aY as between, bk as cloneJsonObject, bj as cloneObject, b1 as cmp, b0 as composeOrderby, D as createArray, c2 as createPromiseProxy, c as csv, ak as currency, aC as day, cK as debounce, G as decodeBase16, I as decodeBase32, K as decodeBase58, M as decodeBase62, O as decodeBase64, b as decrypt, aD as deepEqual, aE as deepMerge, a as deriveKeyPbkdf2, cp as detect, d as digest, bi as empty, F as encodeBase16, H as encodeBase32, J as encodeBase58, L as encodeBase62, N as encodeBase64, bc as encodeQuery, e as encrypt, b7 as endSortWeight, be as ensureKey, bf as ensureKeyAsync, Y as equalBinary, aF as escapeHTML, b4 as escapeRegExp, bJ as fakeWorkerPair, ch as fetchBasic, ci as fetchJson, cj as fetchOptionsFormURLEncoded, ck as fetchOptionsJson, cl as fetchText, ai as fixBrokenUth8String, aA as forEachDay, ag as formatMessages, cM as formatMilliseconds, X as fromBase64, a3 as fromCamelCase, co as getGlobal, bA as getGlobalContext, bP as getGlobalEmitter, bD as getNamespaceFilterString, cn as getNavigator, aT as getSecureRandom, aU as getSecureRandomIfPossible, cL as getTimestamp, cm as getWindow, cg as httpMethod, cw as immediate, aK as isArray, aQ as isBoolean, cq as isBrowser, ao as isEven, an as isHalf, aO as isInteger, bB as isLocalHost, aR as isNullOrUndefined, aN as isNumber, aI as isObject, aJ as isPrimitive, cD as isPromise, aL as isRecord, aP as isSafeInteger, aM as isString, cA as isTimeout, aS as jsonStringify, Z as jsonToUint8Array, bh as last, bR as lazyListener, ba as linkifyPlainText, bl as memoize, bQ as messages, b8 as moveSortWeight, cN as parseDate, a$ as parseOrderby, bd as parseQuery, cr as platform, cE as promisify, cY as qid, aV as randomBoolean, aX as randomFloat, aW as randomInt, r as randomUint8Array, bn as regExpEscape, bm as regExpString, ah as renderMessages, aq as roundDown, at as roundHalfAwayFromZero, au as roundHalfDown, av as roundHalfEven, as as roundHalfOdd, aw as roundHalfTowardsZero, ar as roundHalfUp, ap as roundUp, bg as size, cv as sleep, b9 as sortedItems, b2 as sortedOrderby, b6 as startSortWeight, a4 as stringToBoolean, a6 as stringToFloat, a5 as stringToInteger, R as stringToUInt8Array, c$ as suid, c_ as suidBytes, d1 as suidBytesDate, d0 as suidDate, aZ as sum, cJ as throttle, cy as timeout, cx as timeoutReached, cz as timoutError, V as toBase64, W as toBase64Url, ae as toBool, a0 as toCamelCase, a1 as toCapitalize, a2 as toCapitalizeWords, ab as toFloat, T as toHex, bb as toHumanReadableUrl, ac as toInt, ad as toString, S as toUint8Array, b3 as toValidFilename, aB as today, cB as tryTimeout, cX as uname, aG as unescapeHTML, cf as useAsyncMutex, E as useBase, bv as useDefer, bs as useDispose, bu as useDisposer, bz as useEventListener, cs as useExitHandler, by as useInterval, bF as useLevelFilter, c3 as useMessageHub, ce as useMutex, bE as useNamespaceFilter, ct as usePool, c5 as usePubSub, cb as useRPC, bx as useTimeout, cT as uuid, cS as uuid32bit, cW as uuidB32, cR as uuidBytes, cV as uuidDecode, cU as uuidEncode, cZ as uuidv4, a7 as valueToBoolean, a9 as valueToFloat, a8 as valueToInteger, aa as valueToString, cC as waitOn } from './uuid-c834ecf8';
2
2
  export { d as LogHandler, g as LogHandlerOptions, a as LogLevel, b as LogLevelAlias, c as LogMessage, L as Logger, h as LoggerContext, f as LoggerContextInterface, e as LoggerInterface } from './log-b80164f3';
3
- export { b as FileStorage, F as FileStorageOptions, L as LoggerFileHandler, e as LoggerNodeHandler, c as colorString, d as colorStringList, f as getSourceLocation, j as getSourceLocationByPrecedingPattern, h as getStack, g as getStackLlocationList, i as isTTY, l as loggerStackTraceDebug, a as setupEnv, s as stringToPath, t as toPath, v as valueToPath } from './log-util-baebadc8';
3
+ export { b as FileStorage, F as FileStorageOptions, L as LoggerFileHandler, e as LoggerNodeHandler, c as colorString, d as colorStringList, f as getSourceLocation, j as getSourceLocationByPrecedingPattern, h as getStack, g as getStackLlocationList, i as isTTY, l as loggerStackTraceDebug, p as pbcopy, a as setupEnv, s as stringToPath, t as toPath, v as valueToPath } from './log-util-42a95b2b';
@@ -10,11 +10,12 @@ import {
10
10
  getStackLlocationList,
11
11
  isTTY,
12
12
  loggerStackTraceDebug,
13
+ pbcopy,
13
14
  setupEnv,
14
15
  stringToPath,
15
16
  toPath,
16
17
  valueToPath
17
- } from "./chunk-HERPZYOG.js";
18
+ } from "./chunk-C3WHNRRT.js";
18
19
  import {
19
20
  Channel,
20
21
  CryptoEncoder,
@@ -30,8 +31,11 @@ import {
30
31
  SerialQueue,
31
32
  Uint8ArrayToJson,
32
33
  Uint8ArrayToString,
34
+ XRX,
33
35
  _decodeUtf8Polyfill,
34
36
  _encodeUtf8Polyfill,
37
+ arrayAvg,
38
+ arrayBatches,
35
39
  arrayEmptyInPlace,
36
40
  arrayFilterInPlace,
37
41
  arrayFlatten,
@@ -48,10 +52,12 @@ import {
48
52
  arrayShuffleInPlace,
49
53
  arraySorted,
50
54
  arraySortedNumbers,
55
+ arraySum,
51
56
  arraySymmetricDifference,
52
57
  arrayToggleInPlace,
53
58
  arrayUnion,
54
59
  arrayUnique,
60
+ avg,
55
61
  between,
56
62
  cloneJsonObject,
57
63
  cloneObject,
@@ -115,6 +121,7 @@ import {
115
121
  last,
116
122
  lazyListener,
117
123
  linkifyPlainText,
124
+ memoize,
118
125
  messages,
119
126
  moveSortWeight,
120
127
  parseOrderby,
@@ -126,6 +133,8 @@ import {
126
133
  randomFloat,
127
134
  randomInt,
128
135
  randomUint8Array,
136
+ regExpEscape,
137
+ regExpString,
129
138
  renderMessages,
130
139
  roundDown,
131
140
  roundHalfAwayFromZero,
@@ -148,6 +157,7 @@ import {
148
157
  suidBytes,
149
158
  suidBytesDate,
150
159
  suidDate,
160
+ sum,
151
161
  throttle,
152
162
  timeout,
153
163
  timeoutReached,
@@ -195,7 +205,7 @@ import {
195
205
  valueToInteger,
196
206
  valueToString,
197
207
  waitOn
198
- } from "./chunk-MN2DIK4K.js";
208
+ } from "./chunk-AYKBI7RN.js";
199
209
  import {
200
210
  LogLevel,
201
211
  LogLevelAlias,
@@ -221,7 +231,7 @@ import {
221
231
  parseDate,
222
232
  useLevelFilter,
223
233
  useNamespaceFilter
224
- } from "./chunk-DUGVRMRT.js";
234
+ } from "./chunk-G3LBBVZT.js";
225
235
  export {
226
236
  Channel,
227
237
  CryptoEncoder,
@@ -245,8 +255,11 @@ export {
245
255
  SerialQueue,
246
256
  Uint8ArrayToJson,
247
257
  Uint8ArrayToString,
258
+ XRX,
248
259
  _decodeUtf8Polyfill,
249
260
  _encodeUtf8Polyfill,
261
+ arrayAvg,
262
+ arrayBatches,
250
263
  arrayEmptyInPlace,
251
264
  arrayFilterInPlace,
252
265
  arrayFlatten,
@@ -263,10 +276,12 @@ export {
263
276
  arrayShuffleInPlace,
264
277
  arraySorted,
265
278
  arraySortedNumbers,
279
+ arraySum,
266
280
  arraySymmetricDifference,
267
281
  arrayToggleInPlace,
268
282
  arrayUnion,
269
283
  arrayUnique,
284
+ avg,
270
285
  between,
271
286
  cloneJsonObject,
272
287
  cloneObject,
@@ -354,11 +369,13 @@ export {
354
369
  lazyListener,
355
370
  linkifyPlainText,
356
371
  loggerStackTraceDebug,
372
+ memoize,
357
373
  messages,
358
374
  moveSortWeight,
359
375
  parseDate,
360
376
  parseOrderby,
361
377
  parseQuery,
378
+ pbcopy,
362
379
  platform,
363
380
  promisify,
364
381
  qid,
@@ -366,6 +383,8 @@ export {
366
383
  randomFloat,
367
384
  randomInt,
368
385
  randomUint8Array,
386
+ regExpEscape,
387
+ regExpString,
369
388
  renderMessages,
370
389
  roundDown,
371
390
  roundHalfAwayFromZero,
@@ -390,6 +409,7 @@ export {
390
409
  suidBytes,
391
410
  suidBytesDate,
392
411
  suidDate,
412
+ sum,
393
413
  throttle,
394
414
  timeout,
395
415
  timeoutReached,
@@ -1,4 +1,4 @@
1
- import { cF as Json, cG as ObjectStorage } from './uuid-7c205442';
1
+ import { cO as Json, cP as ObjectStorage } from './uuid-c834ecf8';
2
2
  import { a as LogLevel, g as LogHandlerOptions, d as LogHandler } from './log-b80164f3';
3
3
 
4
4
  declare function urlBase64ToUint8Array(base64String: string): Uint8Array | undefined;
@@ -1,6 +1,9 @@
1
- import { cF as Json, cG as ObjectStorage } from './uuid-7c205442';
1
+ import { cO as Json, cP as ObjectStorage } from './uuid-c834ecf8';
2
2
  import { g as LogHandlerOptions, c as LogMessage, d as LogHandler } from './log-b80164f3';
3
3
 
4
+ /** Copy string to clipboard */
5
+ declare function pbcopy(data: string): Promise<unknown>;
6
+
4
7
  declare type csvOptions = {
5
8
  /** @deprecated will probably be replaced by logLevel */
6
9
  debug?: boolean;
@@ -73,4 +76,4 @@ declare function getSourceLocation(level?: number, stripCwd?: boolean): string;
73
76
  declare function getStack(): string;
74
77
  declare function getSourceLocationByPrecedingPattern(patterns: string[], stripCwd?: boolean): string;
75
78
 
76
- export { FileStorageOptions as F, LoggerFileHandler as L, setupEnv as a, FileStorage as b, colorString as c, colorStringList as d, LoggerNodeHandler as e, getSourceLocation as f, getStackLlocationList as g, getStack as h, isTTY as i, getSourceLocationByPrecedingPattern as j, loggerStackTraceDebug as l, stringToPath as s, toPath as t, valueToPath as v };
79
+ export { FileStorageOptions as F, LoggerFileHandler as L, setupEnv as a, FileStorage as b, colorString as c, colorStringList as d, LoggerNodeHandler as e, getSourceLocation as f, getStackLlocationList as g, getStack as h, isTTY as i, getSourceLocationByPrecedingPattern as j, loggerStackTraceDebug as l, pbcopy as p, stringToPath as s, toPath as t, valueToPath as v };
@@ -61,6 +61,9 @@ declare function arrayShuffleForce<T>(array: T[]): T[];
61
61
  declare function arrayRandomElement<T>(array: T[]): T;
62
62
  declare function arrayMax<T>(...array: NestedArray<T>[]): T;
63
63
  declare function arrayMin<T>(...array: NestedArray<T>[]): T;
64
+ declare function arraySum(...array: NestedArray<number>[]): number;
65
+ declare function arrayAvg(...array: NestedArray<number>[]): number;
66
+ declare function arrayBatches<T>(array: T[], chunckLength: number): T[][];
64
67
  declare function createArray<T>(size?: number, item?: T | ((index: number) => T)): T[];
65
68
 
66
69
  declare function useBase(alphaOrBase: string | number): {
@@ -140,6 +143,7 @@ declare class Currency {
140
143
  toJSON(): number;
141
144
  static zero: Currency;
142
145
  static one: Currency;
146
+ static hundred: Currency;
143
147
  static sum(...array: (CurrencyInput | CurrencyInput[])[]): Currency;
144
148
  static avg(...array: (CurrencyInput | CurrencyInput[])[]): Currency;
145
149
  }
@@ -233,6 +237,10 @@ declare function randomBoolean(bias?: number): boolean;
233
237
  declare function randomInt(max?: number, min?: number): number;
234
238
  declare function randomFloat(max?: number, min?: number): number;
235
239
  declare function between(min: number, value: number, max: number): number;
240
+ /** See also arraySum */
241
+ declare function sum(array: number[]): number;
242
+ /** See also arrayAvg */
243
+ declare function avg(array: number[]): number;
236
244
 
237
245
  declare function parseOrderby(value?: string): {
238
246
  field: string;
@@ -284,6 +292,27 @@ declare function last<T>(array?: T[]): T | undefined;
284
292
  declare function empty(value: any): boolean;
285
293
  declare function cloneObject<T>(obj: T): T;
286
294
  declare function cloneJsonObject<T = Json>(obj: T): T;
295
+ /** Cache result of a function. Same arguments have to always return the same result in order to get expected optimization! */
296
+ declare function memoize<In extends any, Out extends any>(fn: (arg: In) => Out): (arg: In) => Out;
297
+
298
+ declare function regExpString(rx: string | RegExp): string;
299
+ declare function regExpEscape(str: string): string;
300
+ declare class XRX {
301
+ lookBehind: {
302
+ rx: RegExp;
303
+ expect: boolean;
304
+ } | undefined;
305
+ namedGroups: Record<string, number>;
306
+ names: string[];
307
+ rx: RegExp;
308
+ constructor(pattern: string | RegExp, flags?: string);
309
+ get lastIndex(): number;
310
+ set lastIndex(index: number);
311
+ _handleMatch(m: any): any;
312
+ exec(str: string): any;
313
+ execAll(str: string): any[];
314
+ replace(str: string, replacement: string | Function): string;
315
+ }
287
316
 
288
317
  declare type DisposerFunction = () => any | Promise<any>;
289
318
  declare type Disposer = DisposerFunction | {
@@ -640,13 +669,21 @@ declare function isPromise<T>(value: Promise<T> | T): value is Promise<T>;
640
669
  declare function promisify<T>(value: Promise<T> | T): Promise<T>;
641
670
 
642
671
  declare type QueueTask<T = any> = () => Promise<T>;
672
+ interface SerialQueueEvents {
673
+ didUpdate(max: number, resolved: number): void;
674
+ didStart(max: number): void;
675
+ didCancel(max: number): void;
676
+ didFinish(max: number): void;
677
+ }
643
678
  /** Guarentee serial execution of tasks. Able to wait, pause, resume and cancel all. */
644
- declare class SerialQueue {
679
+ declare class SerialQueue extends Emitter<SerialQueueEvents> {
645
680
  private queue;
646
681
  private isPaused;
647
682
  private waitToFinish;
648
683
  private currentTask?;
649
684
  private log;
685
+ private max;
686
+ private resolved;
650
687
  name: string;
651
688
  constructor(opt?: {
652
689
  name?: string;
@@ -738,4 +775,4 @@ declare function suid(): string;
738
775
  declare function suidDate(id: string): Date;
739
776
  declare function suidBytesDate(id: Uint8Array): Date;
740
777
 
741
- export { toCapitalizeWords as $, createArray as A, useBase as B, encodeBase16 as C, decodeBase16 as D, encodeBase32 as E, decodeBase32 as F, encodeBase58 as G, decodeBase58 as H, encodeBase62 as I, decodeBase62 as J, encodeBase64 as K, decodeBase64 as L, BinInput as M, _decodeUtf8Polyfill as N, stringToUInt8Array as O, toUint8Array as P, toHex as Q, toBase64 as R, toBase64Url as S, fromBase64 as T, Uint8ArrayToString as U, equalBinary as V, jsonToUint8Array as W, Uint8ArrayToJson as X, toCamelCase as Y, toCapitalize as Z, _encodeUtf8Polyfill as _, deriveKeyPbkdf2 as a, escapeRegExp as a$, fromCamelCase as a0, stringToBoolean as a1, stringToInteger as a2, stringToFloat as a3, valueToBoolean as a4, valueToInteger as a5, valueToFloat as a6, valueToString as a7, toFloat as a8, toInt as a9, deepEqual as aA, deepMerge as aB, escapeHTML as aC, unescapeHTML as aD, Primitive as aE, isObject as aF, isPrimitive as aG, isArray as aH, isRecord as aI, isString as aJ, isNumber as aK, isInteger as aL, isSafeInteger as aM, isBoolean as aN, isNullOrUndefined as aO, jsonStringify as aP, getSecureRandom as aQ, getSecureRandomIfPossible as aR, randomBoolean as aS, randomInt as aT, randomFloat as aU, between as aV, parseOrderby as aW, composeOrderby as aX, cmp as aY, sortedOrderby as aZ, toValidFilename as a_, toString as aa, toBool as ab, RenderMessagesOptions as ac, formatMessages as ad, renderMessages as ae, fixBrokenUth8String as af, CurrencyInput as ag, currency as ah, Currency as ai, RoundingMode as aj, isHalf as ak, isEven as al, roundUp as am, roundDown as an, roundHalfUp as ao, roundHalfOdd as ap, roundHalfAwayFromZero as aq, roundHalfDown as ar, roundHalfEven as as, roundHalfTowardsZero as at, DAY_MS as au, DayInput as av, Day as aw, forEachDay as ax, today as ay, day as az, decrypt as b, RPCOptions as b$, SortableItem as b0, startSortWeight as b1, endSortWeight as b2, moveSortWeight as b3, sortedItems as b4, linkifyPlainText as b5, toHumanReadableUrl as b6, encodeQuery as b7, parseQuery as b8, ensureKey as b9, fakeWorkerPair as bA, EmitterHandler as bB, EmitterAllHandler as bC, ListenerSignature as bD, DefaultListener as bE, Emitter as bF, getGlobalEmitter as bG, messages as bH, lazyListener as bI, Encoder as bJ, NoopEncoder as bK, JsonEncoder as bL, CryptoEncoder as bM, MessageAction as bN, MessageResult as bO, Message as bP, MessagesOptions as bQ, MessagesDefaultMethods as bR, MessagesMethods as bS, MessageDefinitions as bT, MessageHub as bU, createPromiseProxy as bV, useMessageHub as bW, PubSub as bX, usePubSub as bY, ArgumentsType as bZ, ReturnType$1 as b_, ensureKeyAsync as ba, size as bb, last as bc, empty as bd, cloneObject as be, cloneJsonObject as bf, DisposerFunction as bg, Disposer as bh, Disposable as bi, useDispose as bj, UseDispose as bk, useDisposer as bl, useDefer as bm, UseDefer as bn, useTimeout as bo, useInterval as bp, useEventListener as bq, getGlobalContext as br, isLocalHost as bs, LoggerConsoleHandler as bt, getNamespaceFilterString as bu, useNamespaceFilter as bv, useLevelFilter as bw, ChannelMessageEvent as bx, Channel as by, LocalChannel as bz, csv as c, RPCFn as c0, RPCReturn as c1, useRPC as c2, Mutex as c3, AsyncMutex as c4, useMutex as c5, useAsyncMutex as c6, httpMethod as c7, fetchBasic as c8, fetchJson as c9, throttle as cA, debounce as cB, getTimestamp as cC, formatMilliseconds as cD, parseDate as cE, Json as cF, ObjectStorage as cG, NestedArray as cH, uuidBytes as cI, uuid32bit as cJ, uuid as cK, uuidEncode as cL, uuidDecode as cM, uuidB32 as cN, uname as cO, qid as cP, uuidv4 as cQ, suidBytes as cR, suid as cS, suidDate as cT, suidBytesDate as cU, fetchOptionsFormURLEncoded as ca, fetchOptionsJson as cb, fetchText as cc, getWindow as cd, getNavigator as ce, getGlobal as cf, detect as cg, isBrowser as ch, platform as ci, useExitHandler as cj, usePool as ck, Pool as cl, sleep as cm, immediate as cn, timeoutReached as co, timeout as cp, timoutError as cq, isTimeout as cr, tryTimeout as cs, waitOn as ct, isPromise as cu, promisify as cv, QueueTask as cw, SerialQueue as cx, MemStorageOptions as cy, MemStorage as cz, digest as d, encrypt as e, arrayUnique as f, arrayMinus as g, arrayUnion as h, arrayFlatten as i, arrayIntersection as j, arraySymmetricDifference as k, arrayRemoveElement as l, arraySetElement as m, arrayFilterInPlace as n, arrayToggleInPlace as o, arrayEmptyInPlace as p, arraySorted as q, randomUint8Array as r, arraySortedNumbers as s, arrayIsEqual as t, arrayShuffleInPlace as u, arrayShuffle as v, arrayShuffleForce as w, arrayRandomElement as x, arrayMax as y, arrayMin as z };
778
+ export { Uint8ArrayToJson as $, arraySum as A, arrayAvg as B, arrayBatches as C, createArray as D, useBase as E, encodeBase16 as F, decodeBase16 as G, encodeBase32 as H, decodeBase32 as I, encodeBase58 as J, decodeBase58 as K, encodeBase62 as L, decodeBase62 as M, encodeBase64 as N, decodeBase64 as O, BinInput as P, _decodeUtf8Polyfill as Q, stringToUInt8Array as R, toUint8Array as S, toHex as T, Uint8ArrayToString as U, toBase64 as V, toBase64Url as W, fromBase64 as X, equalBinary as Y, jsonToUint8Array as Z, _encodeUtf8Polyfill as _, deriveKeyPbkdf2 as a, parseOrderby as a$, toCamelCase as a0, toCapitalize as a1, toCapitalizeWords as a2, fromCamelCase as a3, stringToBoolean as a4, stringToInteger as a5, stringToFloat as a6, valueToBoolean as a7, valueToInteger as a8, valueToFloat as a9, forEachDay as aA, today as aB, day as aC, deepEqual as aD, deepMerge as aE, escapeHTML as aF, unescapeHTML as aG, Primitive as aH, isObject as aI, isPrimitive as aJ, isArray as aK, isRecord as aL, isString as aM, isNumber as aN, isInteger as aO, isSafeInteger as aP, isBoolean as aQ, isNullOrUndefined as aR, jsonStringify as aS, getSecureRandom as aT, getSecureRandomIfPossible as aU, randomBoolean as aV, randomInt as aW, randomFloat as aX, between as aY, sum as aZ, avg as a_, valueToString as aa, toFloat as ab, toInt as ac, toString as ad, toBool as ae, RenderMessagesOptions as af, formatMessages as ag, renderMessages as ah, fixBrokenUth8String as ai, CurrencyInput as aj, currency as ak, Currency as al, RoundingMode as am, isHalf as an, isEven as ao, roundUp as ap, roundDown as aq, roundHalfUp as ar, roundHalfOdd as as, roundHalfAwayFromZero as at, roundHalfDown as au, roundHalfEven as av, roundHalfTowardsZero as aw, DAY_MS as ax, DayInput as ay, Day as az, decrypt as b, MessagesMethods as b$, composeOrderby as b0, cmp as b1, sortedOrderby as b2, toValidFilename as b3, escapeRegExp as b4, SortableItem as b5, startSortWeight as b6, endSortWeight as b7, moveSortWeight as b8, sortedItems as b9, getGlobalContext as bA, isLocalHost as bB, LoggerConsoleHandler as bC, getNamespaceFilterString as bD, useNamespaceFilter as bE, useLevelFilter as bF, ChannelMessageEvent as bG, Channel as bH, LocalChannel as bI, fakeWorkerPair as bJ, EmitterHandler as bK, EmitterAllHandler as bL, ListenerSignature as bM, DefaultListener as bN, Emitter as bO, getGlobalEmitter as bP, messages as bQ, lazyListener as bR, Encoder as bS, NoopEncoder as bT, JsonEncoder as bU, CryptoEncoder as bV, MessageAction as bW, MessageResult as bX, Message as bY, MessagesOptions as bZ, MessagesDefaultMethods as b_, linkifyPlainText as ba, toHumanReadableUrl as bb, encodeQuery as bc, parseQuery as bd, ensureKey as be, ensureKeyAsync as bf, size as bg, last as bh, empty as bi, cloneObject as bj, cloneJsonObject as bk, memoize as bl, regExpString as bm, regExpEscape as bn, XRX as bo, DisposerFunction as bp, Disposer as bq, Disposable as br, useDispose as bs, UseDispose as bt, useDisposer as bu, useDefer as bv, UseDefer as bw, useTimeout as bx, useInterval as by, useEventListener as bz, csv as c, suid as c$, MessageDefinitions as c0, MessageHub as c1, createPromiseProxy as c2, useMessageHub as c3, PubSub as c4, usePubSub as c5, ArgumentsType as c6, ReturnType$1 as c7, RPCOptions as c8, RPCFn as c9, isTimeout as cA, tryTimeout as cB, waitOn as cC, isPromise as cD, promisify as cE, QueueTask as cF, SerialQueue as cG, MemStorageOptions as cH, MemStorage as cI, throttle as cJ, debounce as cK, getTimestamp as cL, formatMilliseconds as cM, parseDate as cN, Json as cO, ObjectStorage as cP, NestedArray as cQ, uuidBytes as cR, uuid32bit as cS, uuid as cT, uuidEncode as cU, uuidDecode as cV, uuidB32 as cW, uname as cX, qid as cY, uuidv4 as cZ, suidBytes as c_, RPCReturn as ca, useRPC as cb, Mutex as cc, AsyncMutex as cd, useMutex as ce, useAsyncMutex as cf, httpMethod as cg, fetchBasic as ch, fetchJson as ci, fetchOptionsFormURLEncoded as cj, fetchOptionsJson as ck, fetchText as cl, getWindow as cm, getNavigator as cn, getGlobal as co, detect as cp, isBrowser as cq, platform as cr, useExitHandler as cs, usePool as ct, Pool as cu, sleep as cv, immediate as cw, timeoutReached as cx, timeout as cy, timoutError as cz, digest as d, suidDate as d0, suidBytesDate as d1, encrypt as e, arrayUnique as f, arrayMinus as g, arrayUnion as h, arrayFlatten as i, arrayIntersection as j, arraySymmetricDifference as k, arrayRemoveElement as l, arraySetElement as m, arrayFilterInPlace as n, arrayToggleInPlace as o, arrayEmptyInPlace as p, arraySorted as q, randomUint8Array as r, arraySortedNumbers as s, arrayIsEqual as t, arrayShuffleInPlace as u, arrayShuffle as v, arrayShuffleForce as w, arrayRandomElement as x, arrayMax as y, arrayMin as z };
package/package.json CHANGED
@@ -1,22 +1,31 @@
1
1
  {
2
2
  "name": "zeed",
3
- "version": "0.7.113",
3
+ "version": "0.7.117",
4
4
  "description": "🌱 Simple foundation library",
5
+ "license": "MIT",
5
6
  "keywords": [
6
7
  "foundation",
7
8
  "typescript",
8
9
  "event",
9
10
  "logging"
10
11
  ],
11
- "funding": {
12
- "type": "GitHub Sponsors ❤",
13
- "url": "https://github.com/sponsors/holtwick"
14
- },
15
- "license": "MIT",
16
12
  "author": {
17
13
  "name": "Dirk Holtwick",
14
+ "email": "dirk.holtwick@gmail.com",
18
15
  "url": "https://holtwick.de"
19
16
  },
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "https://github.com/holtwick/zeed.git"
20
+ },
21
+ "bugs": {
22
+ "url": "https://github.com/holtwick/zeed/issues"
23
+ },
24
+ "funding": {
25
+ "type": "GitHub Sponsors ❤",
26
+ "url": "https://github.com/sponsors/holtwick"
27
+ },
28
+ "homepage": "https://github.com/holtwick/zeed",
20
29
  "type": "module",
21
30
  "typings": "dist/index.all.d.ts",
22
31
  "exports": {
@@ -35,6 +44,16 @@
35
44
  "engines": {
36
45
  "node": ">=14.13.1"
37
46
  },
47
+ "scripts": {
48
+ "start": "npm run watch",
49
+ "clean": "rm -rf dist",
50
+ "build": "npm run clean && npm run build:tsup",
51
+ "build:tsup": "tsup src/index.*.ts --format esm,cjs --dts --sourcemap --keep-names",
52
+ "watch": "npm run build:tsup -- --watch",
53
+ "prepublishOnly": "npm run build && npm run test:publish",
54
+ "test": "jest src --coverage",
55
+ "test:publish": "jest src --detectOpenHandles"
56
+ },
38
57
  "devDependencies": {
39
58
  "@types/jest": "^27.4.0",
40
59
  "@types/node": "^17.0.17",
@@ -43,14 +62,5 @@
43
62
  "ts-jest": "^27.1.3",
44
63
  "tsup": "^5.11.13",
45
64
  "typescript": "^4.5.5"
46
- },
47
- "scripts": {
48
- "start": "npm run watch",
49
- "clean": "rm -rf dist",
50
- "build": "npm run clean && npm run build:tsup",
51
- "build:tsup": "tsup src/index.*.ts --format esm,cjs --dts --sourcemap --keep-names",
52
- "watch": "npm run build:tsup -- --watch",
53
- "test": "jest src --coverage"
54
- },
55
- "readme": "# 🌱 Zeed Library\n\n> Plant the \"zeed\" for your next Typescript project and let it grow with this useful lib, providing basic functionalities handy in most projects.\n\n- Strict TypeScript\n- No dependencies and lightweight\n- Covered by tests\n- Universal for node.js and browsers\n- Modern ESM, fallback to CommonJS\n\nGet started like this:\n\n```sh\nnpm i zeed\n```\n\n## Universal Logging\n\nPowerful logging for browser and terminal.\n\n```js\nimport { Logger } from \"zeed\"\n\nconst log = Logger(\"demo\")\n\nlog(\"Hello World\")\nlog.info(\"Info\")\nlog.warn(\"Warning\")\nlog.error(\"Error\")\n```\n\nSample output on a terminal:\n\n<img src=\".assets/node-console@2x.png\" width=\"566\" style=\"max-width:100%\">\n\nSample output in Safari:\n\n<img src=\".assets/safari-console.png\" style=\"max-width:100%\">\n\nBy default, the most appropriate log handlers are activated. By default, a colorful output is applied for better orientation. Each line has trace info to allow direct jumps back into the code where the log has been issued. Logs can easily be filtered by level.\n\n### Filtering\n\n**By default logs are muted!** Show the logs by applying filters. On the browser enter this an the web inspector console:\n\n```js\nlocalStorage.zeed = \"*\"\n```\n\nOn node set an environment variable like this\n\n```sh\nZEED=* node myapp.js\n```\n\nInstead of the `*` more advanced filters can be applied compatible to the well known [debug syntax](https://github.com/visionmedia/debug#wildcards). Instead of `ZEED` variable you may also use `DEBUG`. Please note that `ZEED` will supersede `DEBUG`.\n\nFiltering by level is possible by setting `ZEED_LEVEL`, `LEVEL` or `DEBUG_LEVEL` to set the filter e.g. `ZEED_LEVEL=info` to hide debug logs.\n\nTo also write logs to a file you may set `ZEED_LOG` to the file path. All levels will be written to the file, no matter what other filtering has been chosen.\n\n### Log handlers\n\nIt is also possible to set (`Logger.setHandlers([handlers])`) or add (`Logger.registerHandler(handler)`) new log handlers. You can choose from:\n\n- `LoggerConsoleHandler(opt)`: Plain basic output via `console` (default) - _(muted by default)_\n- `LoggerBrowserHandler(opt)`: Colorful log entries - _(muted by default)_\n- `LoggerNodeHandler(opt)`: Colorful logging for node.js - _(muted by default)_\n- `LoggerFileHandler(path, opt)`: Write to file\n\n`opt` are general options like `level` for the log level or `filter` for custom filtering (see below). But it can also hold individual settings specific for a log handler.\n\nExamples for custom loggers are [breadcrumb tracking in Sentry.io](https://gist.github.com/holtwick/949d04151586cec529a671859ebbb650) or showing notifications to users on errors in a UI.\n\n### Global logging context\n\nYou can use `Logger` in submodules and Zeed will make sure all logging goes through the same handlers, no matter what bundler is used. With `Logger.setLock(true)` any further changes to handlers, factories and log levels can be forbidden, to ensure no conflicting settings with submodules. You should set up the Logging very early in your main project before loading submodules.\n\nLoggers can be extended. `const newLog = log.extend(\"demo\")` will append `:demo` to the current namespace.\n\n### Traces to source code\n\nZeed tries to identify the origin in the source code of the log being issued. To get appropriate results in Node environments consider using the Source Map option:\n\n```sh\nnode --enable-source-maps myapp.js\n```\n\n> Alternative logging solutions: [debug](https://github.com/visionmedia/debug), [tslog](https://github.com/fullstack-build/tslog), [consola](https://github.com/unjs/consola), [pino](https://getpino.io) or [winston](https://github.com/winstonjs/winston) to name just a few.\n\n## Promise / async / await utilities\n\nWait for an event via `on` or `addEventListener`, useful in unit tests.\n\n```js\nawait waitOn(emitter, \"action\", 1000) // 1000 is optional timeout in ms\n```\n\nWait for milliseconds.\n\n```js\nawait sleep(1000) // wait 1s\n```\n\nThrow an error after timeout of 1 second.\n\n```js\nawait timeout(asynFn, 1000)\n```\n\nIf a value is not yet a Promise, wrap it to become one.\n\n```js\nawait promisify(returnValue)\n```\n\n## Unique ID\n\nGet a random unique ID of fixed length of 22 chars (these are 16 bytes = 128 bit, encoded in Base62). According to [Nano ID Collision Calculator](https://zelark.github.io/nano-id-cc/): \"~597 billion years needed, in order to have a 1% probability of at least one collision.\"\n\n```js\nconst id1 = uuid() // base62 encoded => 22 chars\nconst id2 = uuidB32() // base32 encoded => 26 chars\n```\n\nGet an incremental unique ID for current process with named groups, great for debugging.\n\n```js\nuname(\"something\") // => 'something-0'\nuname(\"other\") // => 'other-0'\nuname(\"something\") // => 'something-1'\n```\n\nSortable unique ID inspired by [go-uuid](https://github.com/rsms/go-uuid). 6 bytes encode time and 10 bytes are random. String is Base62 encoded. Date can be extracted from the ID.\n\n```js\nconst shortSortableId = suid() // = '000iMi10bt6YK8buKlYPsd'\nsuidDate(shortSortableId) // = 2021-07-03T22:42:40.727Z\nshortSortableId < suid() // = true\n```\n\nOverview of available IDs:\n\n- `uuid`\n- `uuidB32`\n- `suid`\n- `quid`: Quick ID great for UI purposes of patter `id-1`, `id-2`, ...\n- `uuidv4`: The _classic_ UID like `a7755f8d-ef6f-45e9-8db3-d29347a4a2a1`\n\n## Typed event emitter\n\nTyped and async emitter:\n\n```ts\ninterface MyEvents {\n inc(count: number): number\n}\n\nlet counter = 0\n\nconst e = new Emitter() < MyEvents > e.on(\"inc\", async (count) => counter + 1)\nawait e.emit(\"inc\", 1) // counter === 1\n```\n\nIt is also possible to alternatively use a Proxy called `.call` that makes nice dynamic function calls of the events:\n\n```ts\nawait e.call.inc(1)\n```\n\nWe can also alternatively declare the listeners this way:\n\n```ts\ne.onCall({\n async inc(count: number): number {\n return counter + 1\n },\n})\n```\n\nYou can also use a global emitter that will be available even over module boundaries:\n\n```ts\ndeclare global {\n interface ZeedGlobalEmitter {\n test(x: string): void\n }\n}\n\ngetGlobalEmitter().emit(\"test\", \"Hello World\") // or\ngetGlobalEmitter().call.test(\"Hello World\")\n```\n\n## Messaging\n\nCommunicating to servers or other remote parts through messages as if they were methods on a local object in a type safe way:\n\n```ts\nlet m = useMessageHub({ cannel }).send<MyMessages>()\nm.echo({ hello: \"world\" })\n```\n\n> But there is much more basic infrastructure for communication available in `zeed`. More details at [src/common/msg/README.md](./src/common/msg/README.md)\n\n## CRDT compatible sorting\n\nA conflict free sorting algorithm with minimal data changes. Just extend an object from `SortableItem`, which will provide an additional property of type number called `sort_weight`.\n\n```ts\ninterface Row extends SortedItem {\n id: string\n title: string\n}\n\nlet rows: Row[] = []\n\nconst getSortedRows = () => sortedItems(rows)\n```\n\nUse `startSortWeight`, `endSortWeight` and `moveSortWeight` to get initial values for new entries or manipulate existing ones.\n\n> Essays:\n>\n> - [Holtwick: Smart Reordering for UITableView](https://holtwick.de/en/blog/smart-table-reordering)\n> - [Figma: Fractional Indexing](https://www.figma.com/blog/realtime-editing-of-ordered-sequences/#fractional-indexing)\n>\n> The implementation in Zeed is pretty straight forward, but there are also more sophisticated approaches available as alternatives:\n>\n> - [Implementing Fractional Indexing](https://observablehq.com/@dgreensp/implementing-fractional-indexing)\n> - [fractional-indexing](https://github.com/rocicorp/fractional-indexing) - npm module\n\n## Custom binary data encoding / decoding\n\nIntegration of the [base-x](https://github.com/cryptocoinjs/base-x) code to support encoding and decoding to any alphabet, but especially base2, base16 (hex), base32, base62, base64.\nHuman-readable yet efficient encoding of binary data.\n\n```js\nconst sample = new UInt8Array([1, 2, 3])\nconst { encode, decode } = useBase(62)\ndecode(encode(sample)) === sample // = true\n```\n\n## Deeply nested object utilities\n\nHandle complex objects.\n\n```js\ndeepEqual({ a: { b: 1 } }, { a: { b: 2 } }) // false\ndeepMerge({ a: { b: 1 } }, { c: 3, a: { d: 4 } }) // {a:{b:1, d:4}, c:4}\n```\n\n## Disposer\n\n`useDisposer` will simplify cleaning up objects. You just need to `track` a function or and object with `dispose` method to be called for cleanup. This can also be nested. A simple example is a timer:\n\n```ts\nconst disposableTimer = () => {\n const timout = setTimeout(() => console.log('hello world')), 1000)\n return () => clearTimeout(timeout)\n}\n\nlet disposer = useDisposer()\n\nconst obj = disposableTimer()\ndisposer.track(obj)\n\n// or\n\nconst untrackTimer = disposer.track(disposableTimer())\n\n// then later one of these\n\ndisposer.untrack(obj) // dispose single object\nuntrackTimer() // dispose single object by return value of .track\ndisposer.dispose() // will dispose all tracked elements\n```\n\nYou can also `untrack` single entries. Entries are untracked LIFO. Disposers can also return a Promise and therefore `await` async disposals.\n\nThe disposer itself is also a call to dispose i.e. for convenience you can add it to objects and provide `dispose` easily like this:\n\n```ts\nclass DisposeExample {\n // the trick is to assign to member `dispose`, will be both\n // the destructor and the registration point for disposables\n dispose = useDisposer()\n\n constructor() {\n this.dispose.track(disposableTimer())\n }\n}\n\nlet obj = new DisposeExample()\n// ...\nobj.dispose()\n```\n\n## Related and Links\n\nRelated projects:\n\n- [zeed-dom](https://github.com/holtwick/zeed-dom)\n- [zerva](https://github.com/holtwick/zerva)\n\nRecommended other collections of common JS utils:\n\n- [lib0](https://github.com/dmonad/lib0)\n- [antfu/utils](https://github.com/antfu/utils)\n- [vueuse](https://vueuse.org/)\n- [unjs](https://github.com/unjs/)\n\nCode integrated from other sources:\n\n- [base-x](https://github.com/cryptocoinjs/base-x/blob/master/ts_src/index.ts) MIT\n- [debug](https://github.com/visionmedia/debug) MIT\n- [dotenv](https://github.com/motdotla/dotenv) BSD-2\n- [filenamify](https://github.com/sindresorhus/filenamify) MIT\n- [gravatar](https://github.com/mazondo/gravatarjs/blob/master/gravatar.js) MIT\n- [lib0](https://github.com/dmonad/lib0)\n"
56
- }
65
+ }
66
+ }
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/node/env.ts","../src/node/filestorage.ts","../src/node/log-file.ts","../src/node/log-util.ts","../src/node/log-node.ts","../src/node/crypto.ts","../src/node/log-context-node.ts"],"sourcesContent":["// (C)opyright 2021-07-15 Dirk Holtwick, holtwick.it. All rights reserved.\n\n// Adopted from https://github.com/motdotla/dotenv BSD-2\n\nimport { LogLevel } from \"../common/log-base\"\nimport { Logger } from \"../common/log\"\n\nimport fs from \"fs\"\nimport { resolve } from \"path\"\n\nconst log = Logger(\"zeed:env\")\n\nconst NEWLINE = \"\\n\"\nconst RE_INI_KEY_VAL = /^\\s*([\\w_.-]+)\\s*=\\s*(.*)?\\s*$/\nconst RE_NEWLINES = /\\\\n/g\nconst NEWLINES_MATCH = /\\n|\\r|\\r\\n/\n\ntype csvOptions = {\n /** @deprecated will probably be replaced by logLevel */\n debug?: boolean\n path?: string\n filename?: string\n encoding?: BufferEncoding\n prefix?: string\n env?: Record<string, string>\n}\n\n// Parses src into an Object\nfunction parse(src: string, options: csvOptions = {}) {\n let obj: Record<string, string> = {}\n\n // convert Buffers before splitting into lines and processing\n src\n .toString()\n .split(NEWLINES_MATCH)\n .forEach(function (line, idx) {\n // matching \"KEY' and 'VAL' in 'KEY=VAL'\n const keyValueArr = line.match(RE_INI_KEY_VAL)\n // matched?\n\n // log.debug(\"keyValueArr\", keyValueArr)\n\n if (keyValueArr != null) {\n const key = keyValueArr[1]\n // default undefined or missing values to empty string\n let val = keyValueArr[2] || \"\"\n const end = val.length - 1\n const isDoubleQuoted = val[0] === '\"' && val[end] === '\"'\n const isSingleQuoted = val[0] === \"'\" && val[end] === \"'\"\n\n // if single or double quoted, remove quotes\n if (isSingleQuoted || isDoubleQuoted) {\n val = val.substring(1, end)\n\n // if double quoted, expand newlines\n if (isDoubleQuoted) {\n val = val.replace(RE_NEWLINES, NEWLINE)\n }\n } else {\n // remove surrounding whitespace\n val = val.trim()\n }\n obj[key] = val\n } else {\n log.debug(\n `did not match key and value when parsing line ${idx + 1}: ${line}`\n )\n }\n })\n\n // log.debug(\"obj\", obj)\n return obj\n}\n\n/**\n * Return a path relative to the current working directory\n */\nexport function stringToPath(\n value?: string,\n defaultValue: string = \".\"\n): string {\n return resolve(process.cwd(), value ?? defaultValue)\n}\n\nexport function valueToPath(value?: any, defaultValue = \"\"): string {\n if (value == null) value = defaultValue\n return stringToPath(String(value).trim(), defaultValue)\n}\n\nexport const toPath = valueToPath\n\n// Populates process.env from .env file\nexport function setupEnv(options: csvOptions = {}) {\n const dotenvPath: string =\n options?.path ?? toPath(options?.filename ?? \".env\")\n const encoding: BufferEncoding = options?.encoding ?? \"utf8\"\n const debug = options?.debug || false\n\n if (debug !== true) log.level = LogLevel.off\n\n try {\n // specifying an encoding returns a string instead of a buffer\n const parsedEnv = fs.existsSync(dotenvPath)\n ? parse(fs.readFileSync(dotenvPath, { encoding }), { debug })\n : {}\n const parsedEnvLocal = fs.existsSync(dotenvPath + \".local\")\n ? parse(fs.readFileSync(dotenvPath + \".local\", { encoding }), { debug })\n : {}\n\n const parsed: Record<string, string> = Object.assign(\n {},\n parsedEnv,\n parsedEnvLocal\n )\n let env = options?.env ?? process.env\n\n Object.entries(parsed).forEach(([key, value]) => {\n if (typeof options?.prefix === \"string\") {\n key = options?.prefix + key\n }\n if (!Object.prototype.hasOwnProperty.call(env, key)) {\n if (value != null) {\n log.info(`set env.${key} = ${value}`)\n env[key] = value\n }\n } else {\n log.debug(`\"${key}\" is already defined and will not be overwritten`)\n }\n })\n return { parsed }\n } catch (e) {\n log.error(e)\n return { error: e }\n }\n}\n","// (C)opyright 2021-07-15 Dirk Holtwick, holtwick.it. All rights reserved.\n\nimport {\n mkdirSync,\n readdirSync,\n readFileSync,\n rmSync,\n unlinkSync,\n writeFileSync,\n} from \"fs\"\nimport { dirname, resolve } from \"path\"\nimport { toValidFilename } from \"../common/data/path\"\nimport { cloneObject } from \"../common/data/utils\"\nimport { Logger } from \"../common/log\"\nimport { Json, ObjectStorage } from \"../common/types\"\n\nconst log = Logger(\"zeed:filestorage\")\n\nexport interface FileStorageOptions {\n pretty?: boolean\n path?: string\n extension?: string\n objectFromString?: (data: string) => any\n objectToString?: (data: any) => string\n keyToFilename?: (key: string) => string\n}\n\nexport class FileStorage<T = Json> implements ObjectStorage<T> {\n private store: Record<string, T | null> = {}\n private dirname: string\n private fileKeys?: string[] = undefined\n private pretty: boolean = false\n private extension: string\n private extensionLength: number\n private objectFromString: (data: string) => any\n private objectToString: (data: any) => string\n private keyToFilename: (key: string) => string\n\n constructor(opt: FileStorageOptions = {}) {\n this.dirname = resolve(process.cwd(), opt.path || \".fileStorage\")\n this.pretty = !!opt.pretty\n this.extension = opt.extension ?? \".json\"\n\n if (opt.extension && !this.extension.startsWith(\".\")) {\n this.extension = \".\" + this.extension\n }\n this.extensionLength = this.extension.length\n\n this.objectToString =\n opt.objectToString ??\n ((data: any): string => {\n return this.pretty\n ? JSON.stringify(data, null, 2)\n : JSON.stringify(data)\n })\n\n this.objectFromString =\n opt.objectFromString ??\n ((data: string) => {\n try {\n return JSON.parse(data)\n } catch (err) {\n log.warn(`fileStorage parse error '${err}' in`, data)\n }\n })\n\n this.keyToFilename = opt.keyToFilename ?? toValidFilename\n }\n\n setItem(key: string, value: T): void {\n this.store[key] = cloneObject(value)\n try {\n const data = this.objectToString(value)\n const path = this.getPath(key)\n mkdirSync(dirname(path), { recursive: true })\n writeFileSync(path, data, \"utf8\")\n } catch (err) {\n log.error(\"setItem error\", err)\n }\n }\n\n getPath(key: string): string {\n return resolve(this.dirname, this.keyToFilename(key) + this.extension)\n }\n\n getBuffer(key: string): Buffer {\n const path = this.getPath(key)\n return Buffer.from(readFileSync(path))\n }\n\n getItem(key: string): T | undefined {\n let value = this.store[key]\n\n // null is an indicator for not existing!\n if (value === null) return\n\n if (value != null) {\n return cloneObject(value) // this.objectFromString(value)\n }\n\n try {\n const path = this.getPath(key)\n const data = readFileSync(path, \"utf8\")\n if (data != null) {\n const value = this.objectFromString(data)\n this.store[key] = value\n return value\n }\n } catch (err) {\n log.warn(\"getItem error\", err)\n this.store[key] = null // do not retry next time\n }\n }\n\n removeItem(key: string): void {\n delete this.store[key]\n if (this.fileKeys != null) {\n const index: number = this.fileKeys.indexOf(key)\n if (index !== -1) {\n this.fileKeys.splice(index, 1)\n }\n }\n try {\n const path = this.getPath(key)\n unlinkSync(path)\n } catch (err) {}\n }\n\n clear(): void {\n this.fileKeys = []\n this.store = {}\n rmSync(this.dirname, { recursive: true, force: true })\n }\n\n allKeys(): string[] {\n if (this.fileKeys == null) {\n try {\n this.fileKeys =\n readdirSync(this.dirname, { withFileTypes: true })\n .filter(\n (item) =>\n !item.isDirectory() && item.name.endsWith(this.extension)\n )\n .map((item) => item.name.slice(0, -this.extensionLength)) || []\n } catch (err) {}\n }\n let keys = [...(this.fileKeys || [])]\n for (let key of Object.keys(this.store)) {\n if (!keys.includes(key)) {\n keys.push(key)\n }\n }\n keys.sort()\n return keys\n }\n}\n","// (C)opyright 2021-07-15 Dirk Holtwick, holtwick.it. All rights reserved.\n\nimport { createWriteStream, mkdirSync } from \"fs\"\nimport { dirname, resolve } from \"path\"\nimport { renderMessages } from \"../common/data/convert\"\nimport { LogHandlerOptions, LogLevel, LogMessage } from \"../common/log-base\"\nimport { useLevelFilter, useNamespaceFilter } from \"../common/log-filter\"\n\nlet namespaces: Record<string, any> = {}\n\nexport function LoggerFileHandler(path: string, opt: LogHandlerOptions = {}) {\n const { level = LogLevel.all, filter = \"*\" } = opt\n path = resolve(process.cwd(), path)\n mkdirSync(dirname(path), { recursive: true })\n var stream = createWriteStream(path, { flags: \"a\" })\n // stream.end()\n const matchesNamespace = useNamespaceFilter(filter)\n const matchesLevel = useLevelFilter(level)\n return (msg: LogMessage) => {\n if (!matchesLevel(msg.level)) return\n if (!matchesNamespace(msg.name)) return\n\n const time = new Date().toISOString()\n let name = msg.name || \"\"\n let ninfo = namespaces[name || \"\"]\n if (ninfo == null) {\n namespaces[name] = ninfo\n }\n\n let args: string[] = [\n `[${name || \"*\"}]`,\n renderMessages(msg.messages, { pretty: false }),\n ]\n\n function write(...args: string[]): void {\n stream.write(args.join(\"\\t\") + \"\\n\")\n }\n\n switch (msg.level) {\n case LogLevel.info:\n write(time, `I|* `, ...args)\n break\n case LogLevel.warn:\n write(time, `W|** `, ...args)\n break\n case LogLevel.error:\n write(time, `E|***`, ...args)\n break\n default:\n write(time, `D| `, ...args)\n break\n }\n }\n}\n","// (C)opyright 2021-07-15 Dirk Holtwick, holtwick.it. All rights reserved.\n\nimport { resolve } from \"path\"\n\nexport function getStackLlocationList(stack: string): any[] {\n if (typeof stack !== \"string\") return []\n // console.log(\"stack\", stack)\n return (\n stack\n ?.split(\"\\n\")\n ?.map((rawLine) => {\n let m = rawLine.match(/^\\s+at.*(\\((.*)\\)|file:\\/\\/(.*)$)/)\n if (m) {\n let line = m[3] || m[2]\n if (line.endsWith(\")\")) line = line.slice(0, -1)\n return line\n }\n })\n ?.filter((v) => v != null) || []\n )\n}\n\nconst cwd = resolve(process.cwd())\nconst home = process.env?.HOME ? resolve(process.env?.HOME) : \"\"\n// console.log(`cwd = ${cwd}, home = ${home}}`)\n\nfunction pathStripCwd(path: string) {\n // console.log(\">\", path)\n\n if (path.includes(\"/node_modules/\")) {\n return \"\"\n }\n\n const fileURL = \"file://\"\n if (path.startsWith(fileURL)) {\n return path.substr(fileURL.length)\n }\n\n if (cwd && path.startsWith(cwd)) {\n return path.substr(cwd.length + 1)\n }\n\n if (home && path.startsWith(home)) {\n path = \"~/\" + path.substr(home.length + 1)\n }\n\n return path\n}\n\nfunction extractFileInfo(stackLine: string): string {\n let m = stackLine.match(/^\\s*at.*(\\((.*)\\)|file:\\/\\/(.*)$)/)\n if (m) {\n let line = m[3] || m[2]\n if (line.endsWith(\")\")) line = line.slice(0, -1)\n return line\n }\n return \"\"\n}\n\n/**\n * Get the source code location of the caller\n * https://stackoverflow.com/a/47296370/140927\n *\n * @param level Number of levels to go down the stack trace\n * @param stripCwd Strip the current working directory, only reasonable for Node.js environment\n * @returns\n */\nexport function getSourceLocation(level = 2, stripCwd = true): string {\n let stack = new Error().stack || \"\"\n let line: string | undefined = getStackLlocationList(stack)?.[level]\n if (line && stripCwd) {\n line = pathStripCwd(line)\n }\n return line || \"\"\n}\n\nexport function getStack(): string {\n return new Error().stack || \"\"\n}\n\nexport function getSourceLocationByPrecedingPattern(\n patterns: string[],\n stripCwd = true\n) {\n let line = \"\"\n let stack = new Error().stack || \"\"\n if (typeof stack === \"string\") {\n const lines = stack.split(\"\\n\").map((l) => l.trim())\n // console.log(lines)\n const index = lines.findIndex((l) => patterns.some((p) => l.startsWith(p)))\n line = lines[index + 1]\n if (line) {\n line = extractFileInfo(line)\n }\n if (line && stripCwd) {\n line = pathStripCwd(line)\n }\n }\n return line\n}\n","// (C)opyright 2021-07-15 Dirk Holtwick, holtwick.it. All rights reserved.\n\nimport tty from \"tty\"\nimport { renderMessages } from \"../common/data/convert\"\nimport {\n LogHandler,\n LogHandlerOptions,\n LogLevel,\n LogMessage,\n} from \"../common/log-base\"\nimport { useLevelFilter, useNamespaceFilter } from \"../common/log-filter\"\nimport {\n getSourceLocation,\n getSourceLocationByPrecedingPattern,\n getStack,\n} from \"./log-util\"\nimport { formatMilliseconds, getTimestamp } from \"../common/time\"\n\nexport function isTTY(): boolean {\n try {\n return tty.isatty(process.stdout.fd)\n } catch (err) {}\n return false\n}\n\nconst colors = [6, 2, 3, 4, 5, 1]\n\nfunction selectColor(namespace: string) {\n let hash = 0\n for (let i = 0; i < namespace.length; i++) {\n hash = (hash << 5) - hash + namespace.charCodeAt(i)\n hash |= 0 // Convert to 32bit integer\n }\n return colors[Math.abs(hash) % colors.length]\n}\n\nlet namespaces: Record<string, any> = {}\n\nlet time = getTimestamp()\n\nconst useColors = tty.isatty(process.stderr.fd)\n\nfunction log(...args: any[]) {\n return process.stderr.write(renderMessages(args) + \"\\n\")\n}\n\n// export const BOLD = Symbol()\n// export const UNBOLD = Symbol()\n// export const BLUE = Symbol()\n// export const GREY = Symbol()\n// export const GREEN = Symbol()\n// export const RED = Symbol()\n// export const PURPLE = Symbol()\n// export const ORANGE = Symbol()\n// export const UNCOLOR = Symbol()\n\n// const _browserStyleMap = {\n// [BOLD]: pair.create(\"font-weight\", \"bold\"),\n// [UNBOLD]: pair.create(\"font-weight\", \"normal\"),\n// [BLUE]: pair.create(\"color\", \"blue\"),\n// [GREEN]: pair.create(\"color\", \"green\"),\n// [GREY]: pair.create(\"color\", \"grey\"),\n// [RED]: pair.create(\"color\", \"red\"),\n// [PURPLE]: pair.create(\"color\", \"purple\"),\n// [ORANGE]: pair.create(\"color\", \"orange\"), // not well supported in chrome when debugging node with inspector - TODO: deprecate\n// [UNCOLOR]: pair.create(\"color\", \"black\"),\n// }\n\nconst TTY_STYLE = {\n BOLD: \"\\u001b[1m\",\n UNBOLD: \"\\u001b[2m\",\n RED: \"\\u001b[31m\",\n GREEN: \"\\u001b[32m\",\n BLUE: \"\\u001b[34m\",\n PURPLE: \"\\u001b[35m\",\n GRAY: \"\\u001b[37m\",\n ORANGE: \"\\u001b[38;5;208m\",\n UNCOLOR: \"\\u001b[0m\",\n}\n\nenum COLOR {\n RED = 1,\n GREEN = 2,\n BLUE = 4,\n PURPLE = 5,\n GRAY = 7,\n ORANGE = 8,\n}\n\nconst colorEnd = \"\\u001B[0m\"\n\nexport function colorString(value: string, colorCode: number) {\n const colorStart =\n colorCode === COLOR.ORANGE\n ? TTY_STYLE.ORANGE\n : \"\\u001B[3\" + (colorCode < 8 ? colorCode : \"8;5;\" + colorCode) + \"m\"\n return `${colorStart}${value}${colorEnd}`\n}\n\nexport function colorStringList(\n list: Array<any>,\n style: string,\n bold: boolean = true\n) {\n return list.map((value) => {\n if (typeof value !== \"string\") return value\n let start = style\n let end = colorEnd\n if (bold) {\n start = `${TTY_STYLE.BOLD}${start}`\n end = `${end}${TTY_STYLE.BOLD}`\n }\n return `${start}${value}${end}`\n })\n}\n\nexport const loggerStackTraceDebug =\n \"loggerStackTraceDebug-7d38e5a9214b58d29734374cdb9521fd964d7485\"\n\nexport function LoggerNodeHandler(opt: LogHandlerOptions = {}): LogHandler {\n const {\n level = undefined,\n filter = undefined,\n colors = isTTY(),\n levelHelper = true,\n nameBrackets = true,\n padding = 0,\n fill = 0,\n stack = true,\n } = opt\n const matchesNamespace = useNamespaceFilter(filter)\n const matchesLevel = useLevelFilter(level)\n return (msg: LogMessage) => {\n if (!matchesLevel(msg.level)) return\n if (!matchesNamespace(msg.name)) return\n const timeNow = getTimestamp()\n let name = msg.name || \"\"\n let ninfo = namespaces[name || \"\"]\n if (ninfo == null) {\n ninfo = {\n color: selectColor(name),\n // time: timeNow\n }\n namespaces[name] = ninfo\n }\n const diff = formatMilliseconds(timeNow - time)\n\n let args: string[]\n\n let displayName = nameBrackets ? `[${name}]` : name\n\n if (padding > 0) {\n displayName = displayName.padStart(padding, \" \")\n }\n\n if (fill > 0) {\n displayName = displayName.padEnd(fill, \" \")\n }\n\n if (colors && useColors) {\n const c = ninfo.color\n args = [colorString(displayName, c) + ` | `] // nameBrackets ? [`%c[${name}]`] : [`%c${name}`]\n if (msg.level === LogLevel.warn) {\n args.push(...colorStringList(msg.messages, TTY_STYLE.ORANGE))\n } else if (msg.level === LogLevel.error) {\n args.push(...colorStringList(msg.messages, TTY_STYLE.RED))\n } else {\n args.push(...msg.messages)\n }\n args.push(colorString(`+${diff}`, c))\n } else {\n args = [displayName, ...msg.messages]\n args.push(`+${diff}`)\n }\n\n if (msg.messages?.[0] === loggerStackTraceDebug) {\n console.log(getStack())\n }\n\n if (stack) {\n let line: string = \"\"\n if (typeof stack === \"boolean\") {\n line = getSourceLocationByPrecedingPattern(\n [\"at Function.\", \"at null.log (\", \"at log (\"],\n true\n )\n if (!line) {\n line = getSourceLocation(0, true)\n }\n } else {\n const depth = typeof stack === \"number\" ? stack : 3\n line = getSourceLocation(depth, true)\n }\n if (line) {\n args.push(colorString(`(${line})`, COLOR.GRAY))\n }\n }\n switch (msg.level) {\n case LogLevel.info:\n if (levelHelper) args[0] = `I|* ` + args[0]\n log(...args)\n break\n case LogLevel.warn:\n if (levelHelper)\n args[0] =\n (colors && useColors\n ? colorString(`W|** `, COLOR.ORANGE)\n : `W|** `) + args[0]\n log(...args)\n break\n case LogLevel.error:\n if (levelHelper)\n args[0] =\n (colors && useColors\n ? colorString(`E|*** `, COLOR.RED)\n : `E|*** `) + args[0]\n log(...args)\n break\n default:\n if (levelHelper) args[0] = `D| ` + args[0]\n log(...args)\n break\n }\n }\n}\n","// https://nodejs.org/api/webcrypto.html\nimport nodeCrypto from \"crypto\"\n\nexport {}\n\ndeclare module NodeJS {\n interface Global {\n crypto: Crypto\n }\n}\n\ntry {\n if (\n nodeCrypto &&\n nodeCrypto.webcrypto &&\n typeof globalThis !== \"undefined\" &&\n typeof globalThis.crypto === \"undefined\"\n ) {\n // @ts-ignore\n globalThis.crypto = nodeCrypto.webcrypto\n }\n} catch (err) {\n console.warn(\"Failed to polyfill webcrypto\", err)\n}\n","import { Logger } from \"../common/log\"\nimport { toPath } from \"./env\"\nimport { LoggerFileHandler } from \"./log-file\"\nimport { LoggerNodeHandler } from \"./log-node\"\n\nfunction setupLogContextNode() {\n let handlers = [\n LoggerNodeHandler({\n padding: 32,\n nameBrackets: false,\n // levelHelper: false,\n }),\n ]\n\n let logFilePath = process.env.ZEED_LOG ?? process.env.LOG\n if (logFilePath) {\n handlers.unshift(LoggerFileHandler(toPath(logFilePath)))\n }\n\n Logger.setHandlers(handlers)\n}\n\nsetupLogContextNode()\n"],"mappings":";;;;;;;;;;;;;;;AAOA;AACA;AAEA,IAAM,MAAM,OAAO;AAEnB,IAAM,UAAU;AAChB,IAAM,iBAAiB;AACvB,IAAM,cAAc;AACpB,IAAM,iBAAiB;AAavB,eAAe,KAAa,UAAsB,IAAI;AACpD,MAAI,MAA8B;AAGlC,MACG,WACA,MAAM,gBACN,QAAQ,SAAU,MAAM,KAAK;AAE5B,UAAM,cAAc,KAAK,MAAM;AAK/B,QAAI,eAAe,MAAM;AACvB,YAAM,MAAM,YAAY;AAExB,UAAI,MAAM,YAAY,MAAM;AAC5B,YAAM,MAAM,IAAI,SAAS;AACzB,YAAM,iBAAiB,IAAI,OAAO,OAAO,IAAI,SAAS;AACtD,YAAM,iBAAiB,IAAI,OAAO,OAAO,IAAI,SAAS;AAGtD,UAAI,kBAAkB,gBAAgB;AACpC,cAAM,IAAI,UAAU,GAAG;AAGvB,YAAI,gBAAgB;AAClB,gBAAM,IAAI,QAAQ,aAAa;AAAA;AAAA,aAE5B;AAEL,cA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