zeed 1.4.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{args-FLoL3OKJ.d.cts → args-CEjib9V9.d.mts} +1 -1
- package/dist/{args-WC9q5kz2.d.mts → args-DEig-jw4.d.cts} +1 -1
- package/dist/{clipboard-BkUO-syY.d.mts → clipboard-BusqmLLY.d.cts} +1 -1
- package/dist/{clipboard-Cfpr331X.d.cts → clipboard-DcuuFRwa.d.mts} +1 -1
- package/dist/common/exec/index.d.cts +2 -2
- package/dist/common/exec/index.d.mts +2 -2
- package/dist/common/exec/promise.d.cts +1 -1
- package/dist/common/exec/promise.d.mts +1 -1
- package/dist/common/exec/throttle-debounce.d.cts +1 -1
- package/dist/common/exec/throttle-debounce.d.mts +1 -1
- package/dist/common/index.cjs +21 -0
- package/dist/common/index.d.cts +14 -11
- package/dist/common/index.d.mts +15 -12
- package/dist/common/index.mjs +4 -1
- package/dist/common/msg/rpc.cjs +8 -8
- package/dist/common/msg/rpc.cjs.map +1 -1
- package/dist/common/msg/rpc.mjs +8 -8
- package/dist/common/msg/rpc.mjs.map +1 -1
- package/dist/common/schema/export-json-schema.cjs +40 -31
- package/dist/common/schema/export-json-schema.cjs.map +1 -1
- package/dist/common/schema/export-json-schema.mjs +40 -31
- package/dist/common/schema/export-json-schema.mjs.map +1 -1
- package/dist/common/schema/index.cjs +21 -0
- package/dist/common/schema/index.d.cts +6 -3
- package/dist/common/schema/index.d.mts +7 -4
- package/dist/common/schema/index.mjs +4 -1
- package/dist/common/schema/sql/expr.cjs +128 -0
- package/dist/common/schema/sql/expr.cjs.map +1 -0
- package/dist/common/schema/sql/expr.d.cts +2 -0
- package/dist/common/schema/sql/expr.d.mts +2 -0
- package/dist/common/schema/sql/expr.mjs +115 -0
- package/dist/common/schema/sql/expr.mjs.map +1 -0
- package/dist/common/schema/sql/index.cjs +23 -0
- package/dist/common/schema/sql/index.d.cts +4 -0
- package/dist/common/schema/sql/index.d.mts +4 -0
- package/dist/common/schema/sql/index.mjs +5 -0
- package/dist/common/schema/sql/select.cjs +143 -0
- package/dist/common/schema/sql/select.cjs.map +1 -0
- package/dist/common/schema/sql/select.d.cts +2 -0
- package/dist/common/schema/sql/select.d.mts +2 -0
- package/dist/common/schema/sql/select.mjs +139 -0
- package/dist/common/schema/sql/select.mjs.map +1 -0
- package/dist/common/schema/sql/table.cjs +23 -0
- package/dist/common/schema/sql/table.cjs.map +1 -0
- package/dist/common/schema/sql/table.d.cts +2 -0
- package/dist/common/schema/sql/table.d.mts +2 -0
- package/dist/common/schema/sql/table.mjs +20 -0
- package/dist/common/schema/sql/table.mjs.map +1 -0
- package/dist/common/schema/type-test.d.cts +1 -1
- package/dist/common/schema/type-test.d.mts +1 -1
- package/dist/common/schema/utils.d.cts +1 -1
- package/dist/common/schema/utils.d.mts +1 -1
- package/dist/common/schema/z.d.mts +1 -1
- package/dist/common/storage/index.d.cts +1 -1
- package/dist/common/storage/index.d.mts +1 -1
- package/dist/common/storage/memstorage.d.cts +1 -1
- package/dist/common/storage/memstorage.d.mts +1 -1
- package/dist/common/test.d.cts +1 -1
- package/dist/common/test.d.mts +1 -1
- package/dist/common/time.d.cts +1 -1
- package/dist/common/time.d.mts +1 -1
- package/dist/common/timeout.d.cts +1 -1
- package/dist/common/timeout.d.mts +1 -1
- package/dist/common/utils.d.cts +1 -1
- package/dist/common/utils.d.mts +1 -1
- package/dist/common/uuid.d.cts +1 -1
- package/dist/common/uuid.d.mts +1 -1
- package/dist/{crypto-CyTV7Qce.d.cts → crypto-D68rVmvU.d.mts} +1 -1
- package/dist/{crypto-LT7EC5_d.d.mts → crypto-KzGHoCJE.d.cts} +1 -1
- package/dist/{env-B3vOiVY8.d.cts → env-BJXdwBKq.d.mts} +1 -1
- package/dist/{env-C3npYe8w.d.mts → env-HsOnA_yK.d.cts} +1 -1
- package/dist/expr-CCKrqOw1.d.mts +25 -0
- package/dist/expr-yYgSeBZ3.d.cts +25 -0
- package/dist/{files-CDNKX9VI.d.mts → files-4O-PxnAC.d.cts} +1 -1
- package/dist/{files-DdI9UZvg.d.cts → files-BlpxqSTT.d.mts} +1 -1
- package/dist/{files-async-1V0bu_ca.d.cts → files-async-DFLC-Nkd.d.cts} +1 -1
- package/dist/{files-async-cBMkRwsu.d.mts → files-async-DfuEEDjH.d.mts} +1 -1
- package/dist/{filestorage-CXQ9MzeW.d.cts → filestorage-BjeBZEAs.d.cts} +1 -1
- package/dist/{filestorage-YzM2z9sU.d.mts → filestorage-CmfztpWm.d.mts} +1 -1
- package/dist/{fs-DHJ9AqUk.d.cts → fs-D837bjRT.d.cts} +1 -1
- package/dist/{fs-DgjZdpuF.d.mts → fs-DlYLapik.d.mts} +1 -1
- package/dist/{glob-Bfs7ZS_i.d.mts → glob-5yW09dkR.d.mts} +1 -1
- package/dist/{glob-Bt150jOY.d.cts → glob-CZaZPqiy.d.cts} +1 -1
- package/dist/index.all.cjs +21 -0
- package/dist/index.all.d.cts +28 -25
- package/dist/index.all.d.mts +29 -26
- package/dist/index.all.mjs +4 -1
- package/dist/index.browser.cjs +21 -0
- package/dist/index.browser.d.cts +14 -11
- package/dist/index.browser.d.mts +15 -12
- package/dist/index.browser.mjs +4 -1
- package/dist/index.jsr.d.cts +4 -4
- package/dist/index.jsr.d.mts +4 -4
- package/dist/index.node.cjs +21 -0
- package/dist/index.node.d.cts +28 -25
- package/dist/index.node.d.mts +29 -26
- package/dist/index.node.mjs +4 -1
- package/dist/{log-file-bsTsc9KM.d.cts → log-file-DwEDms1F.d.cts} +2 -2
- package/dist/{log-file-DTuImomJ.d.mts → log-file-QV1unm3z.d.mts} +2 -2
- package/dist/{log-file-rotation-_YruAcNc.d.cts → log-file-rotation-BpZxXYlU.d.cts} +2 -2
- package/dist/{log-file-rotation-FBmtp_Uz.d.mts → log-file-rotation-DanrO_2y.d.mts} +2 -2
- package/dist/{log-node-DlrXl3QO.d.mts → log-node-BSn7RqAc.d.mts} +1 -1
- package/dist/{log-node-Dk948mHX.d.cts → log-node-D_fiJL6x.d.cts} +1 -1
- package/dist/{log-rotation-CkyjZbK5.d.mts → log-rotation-BdGakFya.d.cts} +1 -1
- package/dist/{log-rotation-_d7iRm9s.d.cts → log-rotation-Ce4e-8LN.d.mts} +1 -1
- package/dist/{log-util-2Ls76P-0.d.cts → log-util-C0U3zCjw.d.cts} +1 -1
- package/dist/{log-util-Da_d19f8.d.mts → log-util-Da_UCcmt.d.mts} +1 -1
- package/dist/{memstorage-D5A9FwiP.d.mts → memstorage-BhWXthO8.d.mts} +1 -1
- package/dist/{memstorage-BcjQLdaQ.d.cts → memstorage-tvlWDYgS.d.cts} +1 -1
- package/dist/node/args.d.cts +1 -1
- package/dist/node/args.d.mts +1 -1
- package/dist/node/clipboard.d.cts +1 -1
- package/dist/node/clipboard.d.mts +1 -1
- package/dist/node/crypto.d.cts +1 -1
- package/dist/node/crypto.d.mts +1 -1
- package/dist/node/env.d.cts +1 -1
- package/dist/node/env.d.mts +1 -1
- package/dist/node/files-async.d.cts +1 -1
- package/dist/node/files-async.d.mts +1 -1
- package/dist/node/files.d.cts +1 -1
- package/dist/node/files.d.mts +1 -1
- package/dist/node/filestorage.d.cts +1 -1
- package/dist/node/filestorage.d.mts +1 -1
- package/dist/node/fs.d.cts +1 -1
- package/dist/node/fs.d.mts +1 -1
- package/dist/node/glob.d.cts +1 -1
- package/dist/node/glob.d.mts +1 -1
- package/dist/node/index.d.cts +14 -14
- package/dist/node/index.d.mts +14 -14
- package/dist/node/log/index.d.cts +5 -5
- package/dist/node/log/index.d.mts +5 -5
- package/dist/node/log/log-file-rotation.d.cts +1 -1
- package/dist/node/log/log-file-rotation.d.mts +1 -1
- package/dist/node/log/log-file.d.cts +1 -1
- package/dist/node/log/log-file.d.mts +1 -1
- package/dist/node/log/log-node.cjs +4 -13
- package/dist/node/log/log-node.cjs.map +1 -1
- package/dist/node/log/log-node.d.cts +1 -1
- package/dist/node/log/log-node.d.mts +1 -1
- package/dist/node/log/log-node.mjs +4 -13
- package/dist/node/log/log-node.mjs.map +1 -1
- package/dist/node/log/log-rotation.d.cts +1 -1
- package/dist/node/log/log-rotation.d.mts +1 -1
- package/dist/node/log/log-util.d.cts +1 -1
- package/dist/node/log/log-util.d.mts +1 -1
- package/dist/{promise-DGgiRckN.d.cts → promise-CU_CENbU.d.cts} +1 -1
- package/dist/{promise-MH3xAy4S.d.mts → promise-CoWXgo4w.d.mts} +1 -1
- package/dist/select-DrciHdk_.d.cts +52 -0
- package/dist/select-F2KpP6mo.d.mts +52 -0
- package/dist/table-Cr8tjDIL.d.mts +19 -0
- package/dist/table-IkLXirT-.d.cts +19 -0
- package/dist/{test-CAhm15f4.d.mts → test-DcXa0MeX.d.cts} +1 -1
- package/dist/{test-D2plOVHF.d.cts → test-jZsc7P2c.d.mts} +1 -1
- package/dist/{throttle-debounce-BLFxAZ8W.d.mts → throttle-debounce-CCh0F100.d.mts} +1 -1
- package/dist/{throttle-debounce-Psb0ay1r.d.cts → throttle-debounce-DyFiyoAk.d.cts} +1 -1
- package/dist/{time-BfKJBbym.d.cts → time-BgFZe9ys.d.cts} +1 -1
- package/dist/{time-DxE-vjjw.d.mts → time-DSV_k3mG.d.mts} +1 -1
- package/dist/{timeout-CnUk6Ruj.d.mts → timeout-DDSSNZY8.d.mts} +1 -1
- package/dist/{timeout-CpFcK8MD.d.cts → timeout-E3ZQbJgK.d.cts} +1 -1
- package/dist/{type-test-BiKyEZkc.d.mts → type-test-BvzWDJz3.d.mts} +1 -1
- package/dist/{type-test-sM7QpfQU.d.cts → type-test-CBK-iJ9d.d.cts} +1 -1
- package/dist/{utils-B8DsVgFr.d.mts → utils-1RyCGkpQ.d.mts} +1 -1
- package/dist/{utils-BfZkD2Pt.d.mts → utils-6Culwiaf.d.cts} +1 -1
- package/dist/{utils-DHQBNh-Z.d.cts → utils-CDJihcg3.d.mts} +1 -1
- package/dist/{utils-Bctk_WhH.d.cts → utils-nCQklGHV.d.cts} +1 -1
- package/dist/{uuid-Cusm2nIK.d.cts → uuid-CKFZfSff.d.mts} +1 -1
- package/dist/{uuid-ININPGKB.d.mts → uuid-D42A8UdP.d.cts} +1 -1
- package/dist/z-C0fpNWZg.d.cts +1 -0
- package/dist/z-D_jezYmm.d.mts +1 -0
- package/dist/{z-collection-BmuBin--.d.mts → z-collection-BSfgRU0Q.d.mts} +1 -1
- package/package.json +7 -8
- package/src/common/schema/export-json-schema.spec.ts +11 -7
- package/src/common/schema/export-json-schema.ts +59 -52
- package/src/common/schema/index.ts +1 -0
- package/src/common/schema/sql/README.md +254 -0
- package/src/common/schema/sql/expr.ts +99 -0
- package/src/common/schema/sql/index.ts +3 -0
- package/src/common/schema/sql/select.spec.ts +144 -0
- package/src/common/schema/sql/select.ts +207 -0
- package/src/common/schema/sql/table.ts +36 -0
- /package/dist/{index-BH1nuHdZ.d.cts → index-CIABef8t.d.mts} +0 -0
- /package/dist/{index-BL7o4fG9.d.cts → index-CliqZ9rj.d.mts} +0 -0
- /package/dist/{index-CP2eJYlK.d.mts → index-D6xqj1Qx.d.cts} +0 -0
- /package/dist/{index-DjOaHFU3.d.mts → index-DHFfG4yr.d.cts} +0 -0
- /package/dist/{index-sViox9YW.d.mts → index-N-OgGgfF.d.mts} +0 -0
- /package/dist/{z-ClMox7qS.d.mts → index-WOw4GVZo.d.cts} +0 -0
- /package/dist/{z-dtM4F8Lo.d.cts → index-luywJTzJ.d.mts} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log-node.cjs","names":["valueToBoolean","process","tty","renderMessages","getTimestamp","useNamespaceFilter","useLevelFilter","formatMilliseconds","getStack","getSourceLocationByPrecedingPattern","getSourceLocation"],"sources":["../../../src/node/log/log-node.ts"],"sourcesContent":["import type { LogHandler, LogHandlerOptions, LogMessage } from '../../common/log/log-base'\nimport process from 'node:process'\nimport tty from 'node:tty'\nimport { valueToBoolean } from '../../common/data/convert'\nimport { renderMessages } from '../../common/data/message'\nimport { LogLevelError, LogLevelInfo, LogLevelWarn } from '../../common/log/log-base'\nimport { useLevelFilter, useNamespaceFilter } from '../../common/log/log-filter'\nimport { formatMilliseconds, getTimestamp } from '../../common/time'\nimport { getSourceLocation, getSourceLocationByPrecedingPattern, getStack } from './log-util'\n\nfunction shouldUseColor(): boolean {\n try {\n return valueToBoolean(process.env.ZEED_COLOR, tty.isatty(process.stdout.fd))\n }\n catch (err) {}\n return false\n}\n\nlet defaultUseColor: boolean | undefined\n\nconst colors = [6, 2, 3, 4, 5, 1]\n\nfunction nodeSelectColorByName(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\nconst namespaces: Record<string, any> = {}\n\nlet startTime: number | undefined\n\nfunction log(...args: any[]) {\n process.stdout.write(`${renderMessages(args)}\\n`)\n}\n\n// const _browserStyleMap = {\n// [BOLD]: { \"font-weight\": \"bold\" },\n// [UNBOLD]: { \"font-weight\": \"normal\" },\n// [BLUE]: { color: \"blue\" },\n// [GREEN]: { color: \"green\" },\n// [GREY]: { color: \"grey\" },\n// [RED]: { color: \"red\" },\n// [PURPLE]: { color: \"purple\" },\n// [ORANGE]: { color: \"orange\" },\n// [UNCOLOR]: { 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(text: string, colorCode: number) {\n const colorStart = colorCode === COLOR.ORANGE\n ? TTY_STYLE.ORANGE\n : `\\u001B[3${colorCode < 8 ? colorCode : `8;5;${colorCode}`}m`\n return `${colorStart}${text}${colorEnd}`\n}\n\nexport function colorStringList(\n list: Array<any>,\n style: string,\n bold = true,\n) {\n return list.map((value) => {\n if (typeof value !== 'string')\n 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\nfunction shouldUseStack(): boolean {\n try {\n return valueToBoolean(process.env.ZEED_STACK, false)\n }\n catch (err) {}\n return false\n}\n\nlet defaultUseStack: boolean | undefined\n\nexport const loggerStackTraceDebug = 'loggerStackTraceDebug-7d38e5a9214b58d29734374cdb9521fd964d7485'\n\nexport function LoggerNodeHandler(opt: LogHandlerOptions = {}): LogHandler {\n defaultUseColor ??= shouldUseColor()\n\n defaultUseStack ??= shouldUseStack()\n\n startTime ??= getTimestamp()\n\n const {\n level = undefined,\n filter = undefined,\n colors = defaultUseColor,\n levelHelper = true,\n nameBrackets = true,\n padding = 0,\n fill = 0,\n stack = defaultUseStack,\n time = true,\n } = opt\n const matchesNamespace = useNamespaceFilter(filter)\n const matchesLevel = useLevelFilter(level)\n return (msg: LogMessage) => {\n if (!matchesLevel(msg.level))\n return\n if (!matchesNamespace(msg.name))\n return\n const timeNow = getTimestamp()\n const name = msg.name || ''\n let ninfo = namespaces[name || '']\n if (ninfo == null) {\n ninfo = {\n color: nodeSelectColorByName(name),\n // time: timeNow\n }\n namespaces[name] = ninfo\n }\n const timeDiffString = formatMilliseconds(timeNow - startTime!)\n\n let args: string[]\n\n let displayName = nameBrackets ? `[${name}]` : name\n\n if (padding > 0)\n displayName = displayName.padStart(padding, ' ')\n\n if (fill > 0)\n displayName = displayName.padEnd(fill, ' ')\n\n if (colors) {\n const c = ninfo.color\n args = [`${colorString(displayName, c)} | `] // nameBrackets ? [`%c[${name}]`] : [`%c${name}`]\n if (msg.level === LogLevelWarn)\n args.push(...colorStringList(msg.messages, TTY_STYLE.ORANGE))\n else if (msg.level === LogLevelError)\n args.push(...colorStringList(msg.messages, TTY_STYLE.RED))\n else\n args.push(...msg.messages)\n if (time)\n args.push(colorString(`+${timeDiffString}`, c))\n }\n else {\n args = [displayName, ...msg.messages]\n if (time)\n args.push(`+${timeDiffString}`)\n }\n\n if (msg.messages?.[0] === loggerStackTraceDebug) {\n try {\n // eslint-disable-next-line no-console\n console.log(getStack())\n }\n catch (err) { }\n }\n\n // Probably time consuming\n if (stack) {\n let line = ''\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 const sep = '|'\n const charLevel = '.'\n\n switch (msg.level) {\n case LogLevelInfo:\n if (levelHelper)\n args[0] = `I${sep}${charLevel} ${args[0]}`\n log(...args)\n break\n case LogLevelWarn:\n if (levelHelper) {\n args[0] = (colors\n ? colorString(`W${sep}${charLevel}${charLevel} `, COLOR.ORANGE)\n : `W${sep}${charLevel}${charLevel} `) + args[0]\n }\n log(...args)\n break\n case LogLevelError:\n if (levelHelper) {\n args[0] = (colors\n ? colorString(`E${sep}${charLevel}${charLevel}${charLevel} `, COLOR.RED)\n : `E${sep}${charLevel}${charLevel}${charLevel} `) + args[0]\n }\n log(...args)\n break\n default:\n if (levelHelper)\n args[0] = `D${sep} ${args[0]}`\n log(...args)\n break\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAUA,SAAS,iBAA0B;AACjC,KAAI;AACF,SAAOA,2CAAeC,qBAAQ,IAAI,YAAYC,iBAAI,OAAOD,qBAAQ,OAAO,GAAG,CAAC;UAEvE,KAAK;AACZ,QAAO;;AAGT,IAAI;AAEJ,MAAM,SAAS;CAAC;CAAG;CAAG;CAAG;CAAG;CAAG;CAAE;AAEjC,SAAS,sBAAsB,WAAmB;CAChD,IAAI,OAAO;AACX,MAAK,IAAI,IAAI,GAAG,IAAI,UAAU,QAAQ,KAAK;AACzC,UAAQ,QAAQ,KAAK,OAAO,UAAU,WAAW,EAAE;AACnD,UAAQ;;AAEV,QAAO,OAAO,KAAK,IAAI,KAAK,GAAG,OAAO;;AAGxC,MAAM,aAAkC,EAAE;AAE1C,IAAI;AAEJ,SAAS,IAAI,GAAG,MAAa;AAC3B,sBAAQ,OAAO,MAAM,GAAGE,2CAAe,KAAK,CAAC,IAAI;;AAenD,MAAM,YAAY;CAChB,MAAM;CACN,QAAQ;CACR,KAAK;CACL,OAAO;CACP,MAAM;CACN,QAAQ;CACR,MAAM;CACN,QAAQ;CACR,SAAS;CACV;
|
|
1
|
+
{"version":3,"file":"log-node.cjs","names":["valueToBoolean","process","tty","renderMessages","getTimestamp","useNamespaceFilter","useLevelFilter","formatMilliseconds","getStack","getSourceLocationByPrecedingPattern","getSourceLocation"],"sources":["../../../src/node/log/log-node.ts"],"sourcesContent":["import type { LogHandler, LogHandlerOptions, LogMessage } from '../../common/log/log-base'\nimport process from 'node:process'\nimport tty from 'node:tty'\nimport { valueToBoolean } from '../../common/data/convert'\nimport { renderMessages } from '../../common/data/message'\nimport { LogLevelError, LogLevelInfo, LogLevelWarn } from '../../common/log/log-base'\nimport { useLevelFilter, useNamespaceFilter } from '../../common/log/log-filter'\nimport { formatMilliseconds, getTimestamp } from '../../common/time'\nimport { getSourceLocation, getSourceLocationByPrecedingPattern, getStack } from './log-util'\n\nfunction shouldUseColor(): boolean {\n try {\n return valueToBoolean(process.env.ZEED_COLOR, tty.isatty(process.stdout.fd))\n }\n catch (err) {}\n return false\n}\n\nlet defaultUseColor: boolean | undefined\n\nconst colors = [6, 2, 3, 4, 5, 1]\n\nfunction nodeSelectColorByName(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\nconst namespaces: Record<string, any> = {}\n\nlet startTime: number | undefined\n\nfunction log(...args: any[]) {\n process.stdout.write(`${renderMessages(args)}\\n`)\n}\n\n// const _browserStyleMap = {\n// [BOLD]: { \"font-weight\": \"bold\" },\n// [UNBOLD]: { \"font-weight\": \"normal\" },\n// [BLUE]: { color: \"blue\" },\n// [GREEN]: { color: \"green\" },\n// [GREY]: { color: \"grey\" },\n// [RED]: { color: \"red\" },\n// [PURPLE]: { color: \"purple\" },\n// [ORANGE]: { color: \"orange\" },\n// [UNCOLOR]: { 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(text: string, colorCode: number) {\n const colorStart = colorCode === COLOR.ORANGE\n ? TTY_STYLE.ORANGE\n : `\\u001B[3${colorCode < 8 ? colorCode : `8;5;${colorCode}`}m`\n return `${colorStart}${text}${colorEnd}`\n}\n\nexport function colorStringList(\n list: Array<any>,\n style: string,\n bold = true,\n) {\n return list.map((value) => {\n if (typeof value !== 'string')\n 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\nfunction shouldUseStack(): boolean {\n try {\n return valueToBoolean(process.env.ZEED_STACK, false)\n }\n catch (err) {}\n return false\n}\n\nlet defaultUseStack: boolean | undefined\n\nexport const loggerStackTraceDebug = 'loggerStackTraceDebug-7d38e5a9214b58d29734374cdb9521fd964d7485'\n\nexport function LoggerNodeHandler(opt: LogHandlerOptions = {}): LogHandler {\n defaultUseColor ??= shouldUseColor()\n\n defaultUseStack ??= shouldUseStack()\n\n startTime ??= getTimestamp()\n\n const {\n level = undefined,\n filter = undefined,\n colors = defaultUseColor,\n levelHelper = true,\n nameBrackets = true,\n padding = 0,\n fill = 0,\n stack = defaultUseStack,\n time = true,\n } = opt\n const matchesNamespace = useNamespaceFilter(filter)\n const matchesLevel = useLevelFilter(level)\n return (msg: LogMessage) => {\n if (!matchesLevel(msg.level))\n return\n if (!matchesNamespace(msg.name))\n return\n const timeNow = getTimestamp()\n const name = msg.name || ''\n let ninfo = namespaces[name || '']\n if (ninfo == null) {\n ninfo = {\n color: nodeSelectColorByName(name),\n // time: timeNow\n }\n namespaces[name] = ninfo\n }\n const timeDiffString = formatMilliseconds(timeNow - startTime!)\n\n let args: string[]\n\n let displayName = nameBrackets ? `[${name}]` : name\n\n if (padding > 0)\n displayName = displayName.padStart(padding, ' ')\n\n if (fill > 0)\n displayName = displayName.padEnd(fill, ' ')\n\n if (colors) {\n const c = ninfo.color\n args = [`${colorString(displayName, c)} | `] // nameBrackets ? [`%c[${name}]`] : [`%c${name}`]\n if (msg.level === LogLevelWarn)\n args.push(...colorStringList(msg.messages, TTY_STYLE.ORANGE))\n else if (msg.level === LogLevelError)\n args.push(...colorStringList(msg.messages, TTY_STYLE.RED))\n else\n args.push(...msg.messages)\n if (time)\n args.push(colorString(`+${timeDiffString}`, c))\n }\n else {\n args = [displayName, ...msg.messages]\n if (time)\n args.push(`+${timeDiffString}`)\n }\n\n if (msg.messages?.[0] === loggerStackTraceDebug) {\n try {\n // eslint-disable-next-line no-console\n console.log(getStack())\n }\n catch (err) { }\n }\n\n // Probably time consuming\n if (stack) {\n let line = ''\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 const sep = '|'\n const charLevel = '.'\n\n switch (msg.level) {\n case LogLevelInfo:\n if (levelHelper)\n args[0] = `I${sep}${charLevel} ${args[0]}`\n log(...args)\n break\n case LogLevelWarn:\n if (levelHelper) {\n args[0] = (colors\n ? colorString(`W${sep}${charLevel}${charLevel} `, COLOR.ORANGE)\n : `W${sep}${charLevel}${charLevel} `) + args[0]\n }\n log(...args)\n break\n case LogLevelError:\n if (levelHelper) {\n args[0] = (colors\n ? colorString(`E${sep}${charLevel}${charLevel}${charLevel} `, COLOR.RED)\n : `E${sep}${charLevel}${charLevel}${charLevel} `) + args[0]\n }\n log(...args)\n break\n default:\n if (levelHelper)\n args[0] = `D${sep} ${args[0]}`\n log(...args)\n break\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAUA,SAAS,iBAA0B;AACjC,KAAI;AACF,SAAOA,2CAAeC,qBAAQ,IAAI,YAAYC,iBAAI,OAAOD,qBAAQ,OAAO,GAAG,CAAC;UAEvE,KAAK;AACZ,QAAO;;AAGT,IAAI;AAEJ,MAAM,SAAS;CAAC;CAAG;CAAG;CAAG;CAAG;CAAG;CAAE;AAEjC,SAAS,sBAAsB,WAAmB;CAChD,IAAI,OAAO;AACX,MAAK,IAAI,IAAI,GAAG,IAAI,UAAU,QAAQ,KAAK;AACzC,UAAQ,QAAQ,KAAK,OAAO,UAAU,WAAW,EAAE;AACnD,UAAQ;;AAEV,QAAO,OAAO,KAAK,IAAI,KAAK,GAAG,OAAO;;AAGxC,MAAM,aAAkC,EAAE;AAE1C,IAAI;AAEJ,SAAS,IAAI,GAAG,MAAa;AAC3B,sBAAQ,OAAO,MAAM,GAAGE,2CAAe,KAAK,CAAC,IAAI;;AAenD,MAAM,YAAY;CAChB,MAAM;CACN,QAAQ;CACR,KAAK;CACL,OAAO;CACP,MA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AY,UAAU,OAAO,KAAK;AAElD,QAAI,GAAG,KAAK;AACZ;GACF;AACE,QAAI,YACF,MAAK,MAAM,SACP,YAAY,IAAI,MAAM,YAAY,YAAY,UAAU,MAAc,GACtE,IAAI,MAAM,YAAY,YAAY,UAAU,MAAM,KAAK;AAE7D,QAAI,GAAG,KAAK;AACZ;GACF;AACE,QAAI,YACF,MAAK,KAAK,IAAI,IAAI,MAAM,KAAK;AAC/B,QAAI,GAAG,KAAK;AACZ"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as loggerStackTraceDebug, n as colorString, r as colorStringList, t as LoggerNodeHandler } from "../../log-node-
|
|
1
|
+
import { i as loggerStackTraceDebug, n as colorString, r as colorStringList, t as LoggerNodeHandler } from "../../log-node-D_fiJL6x.cjs";
|
|
2
2
|
export { LoggerNodeHandler, colorString, colorStringList, loggerStackTraceDebug };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as loggerStackTraceDebug, n as colorString, r as colorStringList, t as LoggerNodeHandler } from "../../log-node-
|
|
1
|
+
import { i as loggerStackTraceDebug, n as colorString, r as colorStringList, t as LoggerNodeHandler } from "../../log-node-BSn7RqAc.mjs";
|
|
2
2
|
export { LoggerNodeHandler, colorString, colorStringList, loggerStackTraceDebug };
|
|
@@ -47,18 +47,9 @@ const TTY_STYLE = {
|
|
|
47
47
|
ORANGE: "\x1B[38;5;208m",
|
|
48
48
|
UNCOLOR: "\x1B[0m"
|
|
49
49
|
};
|
|
50
|
-
var COLOR = /* @__PURE__ */ function(COLOR) {
|
|
51
|
-
COLOR[COLOR["RED"] = 1] = "RED";
|
|
52
|
-
COLOR[COLOR["GREEN"] = 2] = "GREEN";
|
|
53
|
-
COLOR[COLOR["BLUE"] = 4] = "BLUE";
|
|
54
|
-
COLOR[COLOR["PURPLE"] = 5] = "PURPLE";
|
|
55
|
-
COLOR[COLOR["GRAY"] = 7] = "GRAY";
|
|
56
|
-
COLOR[COLOR["ORANGE"] = 8] = "ORANGE";
|
|
57
|
-
return COLOR;
|
|
58
|
-
}(COLOR || {});
|
|
59
50
|
const colorEnd = "\x1B[0m";
|
|
60
51
|
function colorString(text, colorCode) {
|
|
61
|
-
return `${colorCode ===
|
|
52
|
+
return `${colorCode === 8 ? TTY_STYLE.ORANGE : `\u001B[3${colorCode < 8 ? colorCode : `8;5;${colorCode}`}m`}${text}${colorEnd}`;
|
|
62
53
|
}
|
|
63
54
|
function colorStringList(list, style, bold = true) {
|
|
64
55
|
return list.map((value) => {
|
|
@@ -126,7 +117,7 @@ function LoggerNodeHandler(opt = {}) {
|
|
|
126
117
|
], true);
|
|
127
118
|
if (!line) line = getSourceLocation(0, true);
|
|
128
119
|
} else line = getSourceLocation(typeof stack === "number" ? stack : 3, true);
|
|
129
|
-
if (line) args.push(colorString(`(${line})`,
|
|
120
|
+
if (line) args.push(colorString(`(${line})`, 7));
|
|
130
121
|
}
|
|
131
122
|
const sep = "|";
|
|
132
123
|
const charLevel = ".";
|
|
@@ -136,11 +127,11 @@ function LoggerNodeHandler(opt = {}) {
|
|
|
136
127
|
log(...args);
|
|
137
128
|
break;
|
|
138
129
|
case 2:
|
|
139
|
-
if (levelHelper) args[0] = (colors ? colorString(`W${sep}${charLevel}${charLevel} `,
|
|
130
|
+
if (levelHelper) args[0] = (colors ? colorString(`W${sep}${charLevel}${charLevel} `, 8) : `W${sep}${charLevel}${charLevel} `) + args[0];
|
|
140
131
|
log(...args);
|
|
141
132
|
break;
|
|
142
133
|
case 3:
|
|
143
|
-
if (levelHelper) args[0] = (colors ? colorString(`E${sep}${charLevel}${charLevel}${charLevel} `,
|
|
134
|
+
if (levelHelper) args[0] = (colors ? colorString(`E${sep}${charLevel}${charLevel}${charLevel} `, 1) : `E${sep}${charLevel}${charLevel}${charLevel} `) + args[0];
|
|
144
135
|
log(...args);
|
|
145
136
|
break;
|
|
146
137
|
default:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log-node.mjs","names":[],"sources":["../../../src/node/log/log-node.ts"],"sourcesContent":["import type { LogHandler, LogHandlerOptions, LogMessage } from '../../common/log/log-base'\nimport process from 'node:process'\nimport tty from 'node:tty'\nimport { valueToBoolean } from '../../common/data/convert'\nimport { renderMessages } from '../../common/data/message'\nimport { LogLevelError, LogLevelInfo, LogLevelWarn } from '../../common/log/log-base'\nimport { useLevelFilter, useNamespaceFilter } from '../../common/log/log-filter'\nimport { formatMilliseconds, getTimestamp } from '../../common/time'\nimport { getSourceLocation, getSourceLocationByPrecedingPattern, getStack } from './log-util'\n\nfunction shouldUseColor(): boolean {\n try {\n return valueToBoolean(process.env.ZEED_COLOR, tty.isatty(process.stdout.fd))\n }\n catch (err) {}\n return false\n}\n\nlet defaultUseColor: boolean | undefined\n\nconst colors = [6, 2, 3, 4, 5, 1]\n\nfunction nodeSelectColorByName(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\nconst namespaces: Record<string, any> = {}\n\nlet startTime: number | undefined\n\nfunction log(...args: any[]) {\n process.stdout.write(`${renderMessages(args)}\\n`)\n}\n\n// const _browserStyleMap = {\n// [BOLD]: { \"font-weight\": \"bold\" },\n// [UNBOLD]: { \"font-weight\": \"normal\" },\n// [BLUE]: { color: \"blue\" },\n// [GREEN]: { color: \"green\" },\n// [GREY]: { color: \"grey\" },\n// [RED]: { color: \"red\" },\n// [PURPLE]: { color: \"purple\" },\n// [ORANGE]: { color: \"orange\" },\n// [UNCOLOR]: { 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(text: string, colorCode: number) {\n const colorStart = colorCode === COLOR.ORANGE\n ? TTY_STYLE.ORANGE\n : `\\u001B[3${colorCode < 8 ? colorCode : `8;5;${colorCode}`}m`\n return `${colorStart}${text}${colorEnd}`\n}\n\nexport function colorStringList(\n list: Array<any>,\n style: string,\n bold = true,\n) {\n return list.map((value) => {\n if (typeof value !== 'string')\n 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\nfunction shouldUseStack(): boolean {\n try {\n return valueToBoolean(process.env.ZEED_STACK, false)\n }\n catch (err) {}\n return false\n}\n\nlet defaultUseStack: boolean | undefined\n\nexport const loggerStackTraceDebug = 'loggerStackTraceDebug-7d38e5a9214b58d29734374cdb9521fd964d7485'\n\nexport function LoggerNodeHandler(opt: LogHandlerOptions = {}): LogHandler {\n defaultUseColor ??= shouldUseColor()\n\n defaultUseStack ??= shouldUseStack()\n\n startTime ??= getTimestamp()\n\n const {\n level = undefined,\n filter = undefined,\n colors = defaultUseColor,\n levelHelper = true,\n nameBrackets = true,\n padding = 0,\n fill = 0,\n stack = defaultUseStack,\n time = true,\n } = opt\n const matchesNamespace = useNamespaceFilter(filter)\n const matchesLevel = useLevelFilter(level)\n return (msg: LogMessage) => {\n if (!matchesLevel(msg.level))\n return\n if (!matchesNamespace(msg.name))\n return\n const timeNow = getTimestamp()\n const name = msg.name || ''\n let ninfo = namespaces[name || '']\n if (ninfo == null) {\n ninfo = {\n color: nodeSelectColorByName(name),\n // time: timeNow\n }\n namespaces[name] = ninfo\n }\n const timeDiffString = formatMilliseconds(timeNow - startTime!)\n\n let args: string[]\n\n let displayName = nameBrackets ? `[${name}]` : name\n\n if (padding > 0)\n displayName = displayName.padStart(padding, ' ')\n\n if (fill > 0)\n displayName = displayName.padEnd(fill, ' ')\n\n if (colors) {\n const c = ninfo.color\n args = [`${colorString(displayName, c)} | `] // nameBrackets ? [`%c[${name}]`] : [`%c${name}`]\n if (msg.level === LogLevelWarn)\n args.push(...colorStringList(msg.messages, TTY_STYLE.ORANGE))\n else if (msg.level === LogLevelError)\n args.push(...colorStringList(msg.messages, TTY_STYLE.RED))\n else\n args.push(...msg.messages)\n if (time)\n args.push(colorString(`+${timeDiffString}`, c))\n }\n else {\n args = [displayName, ...msg.messages]\n if (time)\n args.push(`+${timeDiffString}`)\n }\n\n if (msg.messages?.[0] === loggerStackTraceDebug) {\n try {\n // eslint-disable-next-line no-console\n console.log(getStack())\n }\n catch (err) { }\n }\n\n // Probably time consuming\n if (stack) {\n let line = ''\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 const sep = '|'\n const charLevel = '.'\n\n switch (msg.level) {\n case LogLevelInfo:\n if (levelHelper)\n args[0] = `I${sep}${charLevel} ${args[0]}`\n log(...args)\n break\n case LogLevelWarn:\n if (levelHelper) {\n args[0] = (colors\n ? colorString(`W${sep}${charLevel}${charLevel} `, COLOR.ORANGE)\n : `W${sep}${charLevel}${charLevel} `) + args[0]\n }\n log(...args)\n break\n case LogLevelError:\n if (levelHelper) {\n args[0] = (colors\n ? colorString(`E${sep}${charLevel}${charLevel}${charLevel} `, COLOR.RED)\n : `E${sep}${charLevel}${charLevel}${charLevel} `) + args[0]\n }\n log(...args)\n break\n default:\n if (levelHelper)\n args[0] = `D${sep} ${args[0]}`\n log(...args)\n break\n }\n }\n}\n"],"mappings":";;;;;;;;;;AAUA,SAAS,iBAA0B;AACjC,KAAI;AACF,SAAO,eAAe,QAAQ,IAAI,YAAY,IAAI,OAAO,QAAQ,OAAO,GAAG,CAAC;UAEvE,KAAK;AACZ,QAAO;;AAGT,IAAI;AAEJ,MAAM,SAAS;CAAC;CAAG;CAAG;CAAG;CAAG;CAAG;CAAE;AAEjC,SAAS,sBAAsB,WAAmB;CAChD,IAAI,OAAO;AACX,MAAK,IAAI,IAAI,GAAG,IAAI,UAAU,QAAQ,KAAK;AACzC,UAAQ,QAAQ,KAAK,OAAO,UAAU,WAAW,EAAE;AACnD,UAAQ;;AAEV,QAAO,OAAO,KAAK,IAAI,KAAK,GAAG,OAAO;;AAGxC,MAAM,aAAkC,EAAE;AAE1C,IAAI;AAEJ,SAAS,IAAI,GAAG,MAAa;AAC3B,SAAQ,OAAO,MAAM,GAAG,eAAe,KAAK,CAAC,IAAI;;AAenD,MAAM,YAAY;CAChB,MAAM;CACN,QAAQ;CACR,KAAK;CACL,OAAO;CACP,MAAM;CACN,QAAQ;CACR,MAAM;CACN,QAAQ;CACR,SAAS;CACV;
|
|
1
|
+
{"version":3,"file":"log-node.mjs","names":[],"sources":["../../../src/node/log/log-node.ts"],"sourcesContent":["import type { LogHandler, LogHandlerOptions, LogMessage } from '../../common/log/log-base'\nimport process from 'node:process'\nimport tty from 'node:tty'\nimport { valueToBoolean } from '../../common/data/convert'\nimport { renderMessages } from '../../common/data/message'\nimport { LogLevelError, LogLevelInfo, LogLevelWarn } from '../../common/log/log-base'\nimport { useLevelFilter, useNamespaceFilter } from '../../common/log/log-filter'\nimport { formatMilliseconds, getTimestamp } from '../../common/time'\nimport { getSourceLocation, getSourceLocationByPrecedingPattern, getStack } from './log-util'\n\nfunction shouldUseColor(): boolean {\n try {\n return valueToBoolean(process.env.ZEED_COLOR, tty.isatty(process.stdout.fd))\n }\n catch (err) {}\n return false\n}\n\nlet defaultUseColor: boolean | undefined\n\nconst colors = [6, 2, 3, 4, 5, 1]\n\nfunction nodeSelectColorByName(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\nconst namespaces: Record<string, any> = {}\n\nlet startTime: number | undefined\n\nfunction log(...args: any[]) {\n process.stdout.write(`${renderMessages(args)}\\n`)\n}\n\n// const _browserStyleMap = {\n// [BOLD]: { \"font-weight\": \"bold\" },\n// [UNBOLD]: { \"font-weight\": \"normal\" },\n// [BLUE]: { color: \"blue\" },\n// [GREEN]: { color: \"green\" },\n// [GREY]: { color: \"grey\" },\n// [RED]: { color: \"red\" },\n// [PURPLE]: { color: \"purple\" },\n// [ORANGE]: { color: \"orange\" },\n// [UNCOLOR]: { 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(text: string, colorCode: number) {\n const colorStart = colorCode === COLOR.ORANGE\n ? TTY_STYLE.ORANGE\n : `\\u001B[3${colorCode < 8 ? colorCode : `8;5;${colorCode}`}m`\n return `${colorStart}${text}${colorEnd}`\n}\n\nexport function colorStringList(\n list: Array<any>,\n style: string,\n bold = true,\n) {\n return list.map((value) => {\n if (typeof value !== 'string')\n 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\nfunction shouldUseStack(): boolean {\n try {\n return valueToBoolean(process.env.ZEED_STACK, false)\n }\n catch (err) {}\n return false\n}\n\nlet defaultUseStack: boolean | undefined\n\nexport const loggerStackTraceDebug = 'loggerStackTraceDebug-7d38e5a9214b58d29734374cdb9521fd964d7485'\n\nexport function LoggerNodeHandler(opt: LogHandlerOptions = {}): LogHandler {\n defaultUseColor ??= shouldUseColor()\n\n defaultUseStack ??= shouldUseStack()\n\n startTime ??= getTimestamp()\n\n const {\n level = undefined,\n filter = undefined,\n colors = defaultUseColor,\n levelHelper = true,\n nameBrackets = true,\n padding = 0,\n fill = 0,\n stack = defaultUseStack,\n time = true,\n } = opt\n const matchesNamespace = useNamespaceFilter(filter)\n const matchesLevel = useLevelFilter(level)\n return (msg: LogMessage) => {\n if (!matchesLevel(msg.level))\n return\n if (!matchesNamespace(msg.name))\n return\n const timeNow = getTimestamp()\n const name = msg.name || ''\n let ninfo = namespaces[name || '']\n if (ninfo == null) {\n ninfo = {\n color: nodeSelectColorByName(name),\n // time: timeNow\n }\n namespaces[name] = ninfo\n }\n const timeDiffString = formatMilliseconds(timeNow - startTime!)\n\n let args: string[]\n\n let displayName = nameBrackets ? `[${name}]` : name\n\n if (padding > 0)\n displayName = displayName.padStart(padding, ' ')\n\n if (fill > 0)\n displayName = displayName.padEnd(fill, ' ')\n\n if (colors) {\n const c = ninfo.color\n args = [`${colorString(displayName, c)} | `] // nameBrackets ? [`%c[${name}]`] : [`%c${name}`]\n if (msg.level === LogLevelWarn)\n args.push(...colorStringList(msg.messages, TTY_STYLE.ORANGE))\n else if (msg.level === LogLevelError)\n args.push(...colorStringList(msg.messages, TTY_STYLE.RED))\n else\n args.push(...msg.messages)\n if (time)\n args.push(colorString(`+${timeDiffString}`, c))\n }\n else {\n args = [displayName, ...msg.messages]\n if (time)\n args.push(`+${timeDiffString}`)\n }\n\n if (msg.messages?.[0] === loggerStackTraceDebug) {\n try {\n // eslint-disable-next-line no-console\n console.log(getStack())\n }\n catch (err) { }\n }\n\n // Probably time consuming\n if (stack) {\n let line = ''\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 const sep = '|'\n const charLevel = '.'\n\n switch (msg.level) {\n case LogLevelInfo:\n if (levelHelper)\n args[0] = `I${sep}${charLevel} ${args[0]}`\n log(...args)\n break\n case LogLevelWarn:\n if (levelHelper) {\n args[0] = (colors\n ? colorString(`W${sep}${charLevel}${charLevel} `, COLOR.ORANGE)\n : `W${sep}${charLevel}${charLevel} `) + args[0]\n }\n log(...args)\n break\n case LogLevelError:\n if (levelHelper) {\n args[0] = (colors\n ? colorString(`E${sep}${charLevel}${charLevel}${charLevel} `, COLOR.RED)\n : `E${sep}${charLevel}${charLevel}${charLevel} `) + args[0]\n }\n log(...args)\n break\n default:\n if (levelHelper)\n args[0] = `D${sep} ${args[0]}`\n log(...args)\n break\n }\n }\n}\n"],"mappings":";;;;;;;;;;AAUA,SAAS,iBAA0B;AACjC,KAAI;AACF,SAAO,eAAe,QAAQ,IAAI,YAAY,IAAI,OAAO,QAAQ,OAAO,GAAG,CAAC;UAEvE,KAAK;AACZ,QAAO;;AAGT,IAAI;AAEJ,MAAM,SAAS;CAAC;CAAG;CAAG;CAAG;CAAG;CAAG;CAAE;AAEjC,SAAS,sBAAsB,WAAmB;CAChD,IAAI,OAAO;AACX,MAAK,IAAI,IAAI,GAAG,IAAI,UAAU,QAAQ,KAAK;AACzC,UAAQ,QAAQ,KAAK,OAAO,UAAU,WAAW,EAAE;AACnD,UAAQ;;AAEV,QAAO,OAAO,KAAK,IAAI,KAAK,GAAG,OAAO;;AAGxC,MAAM,aAAkC,EAAE;AAE1C,IAAI;AAEJ,SAAS,IAAI,GAAG,MAAa;AAC3B,SAAQ,OAAO,MAAM,GAAG,eAAe,KAAK,CAAC,IAAI;;AAenD,MAAM,YAAY;CAChB,MAAM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GAC9D,IAAI,MAAM,YAAY,UAAU,OAAO,KAAK;AAElD,QAAI,GAAG,KAAK;AACZ;GACF;AACE,QAAI,YACF,MAAK,MAAM,SACP,YAAY,IAAI,MAAM,YAAY,YAAY,UAAU,MAAc,GACtE,IAAI,MAAM,YAAY,YAAY,UAAU,MAAM,KAAK;AAE7D,QAAI,GAAG,KAAK;AACZ;GACF;AACE,QAAI,YACF,MAAK,KAAK,IAAI,IAAI,MAAM,KAAK;AAC/B,QAAI,GAAG,KAAK;AACZ"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as RotationFileSizeUnit, c as RotationIntervalUnit, i as RotationFileSize, l as RotationOptions, n as RotatingFileStreamError, o as RotationGenerator, r as RotationCompressor, s as RotationInterval, t as RotatingFileStream, u as createRotationStream } from "../../log-rotation-
|
|
1
|
+
import { a as RotationFileSizeUnit, c as RotationIntervalUnit, i as RotationFileSize, l as RotationOptions, n as RotatingFileStreamError, o as RotationGenerator, r as RotationCompressor, s as RotationInterval, t as RotatingFileStream, u as createRotationStream } from "../../log-rotation-BdGakFya.cjs";
|
|
2
2
|
export { RotatingFileStream, RotatingFileStreamError, RotationCompressor, RotationFileSize, RotationFileSizeUnit, RotationGenerator, RotationInterval, RotationIntervalUnit, RotationOptions, createRotationStream };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as RotationFileSizeUnit, c as RotationIntervalUnit, i as RotationFileSize, l as RotationOptions, n as RotatingFileStreamError, o as RotationGenerator, r as RotationCompressor, s as RotationInterval, t as RotatingFileStream, u as createRotationStream } from "../../log-rotation-
|
|
1
|
+
import { a as RotationFileSizeUnit, c as RotationIntervalUnit, i as RotationFileSize, l as RotationOptions, n as RotatingFileStreamError, o as RotationGenerator, r as RotationCompressor, s as RotationInterval, t as RotatingFileStream, u as createRotationStream } from "../../log-rotation-Ce4e-8LN.mjs";
|
|
2
2
|
export { RotatingFileStream, RotatingFileStreamError, RotationCompressor, RotationFileSize, RotationFileSizeUnit, RotationGenerator, RotationInterval, RotationIntervalUnit, RotationOptions, createRotationStream };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as getStackLlocationList, n as getSourceLocationByPrecedingPattern, r as getStack, t as getSourceLocation } from "../../log-util-
|
|
1
|
+
import { i as getStackLlocationList, n as getSourceLocationByPrecedingPattern, r as getStack, t as getSourceLocation } from "../../log-util-C0U3zCjw.cjs";
|
|
2
2
|
export { getSourceLocation, getSourceLocationByPrecedingPattern, getStack, getStackLlocationList };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as getStackLlocationList, n as getSourceLocationByPrecedingPattern, r as getStack, t as getSourceLocation } from "../../log-util-
|
|
1
|
+
import { i as getStackLlocationList, n as getSourceLocationByPrecedingPattern, r as getStack, t as getSourceLocation } from "../../log-util-Da_UCcmt.mjs";
|
|
2
2
|
export { getSourceLocation, getSourceLocationByPrecedingPattern, getStack, getStackLlocationList };
|
|
@@ -33,4 +33,4 @@ declare function promisify<T>(value: Promise<T> | T): Promise<T>;
|
|
|
33
33
|
type AsyncReturnType<T extends (...args: any) => any> = T extends ((...args: any) => Promise<infer U>) ? U : T extends ((...args: any) => infer U) ? U : any;
|
|
34
34
|
//#endregion
|
|
35
35
|
export { isTimeout as a, timeout as c, isPromise as i, tryTimeout as l, createPromise as n, promisify as o, immediate as r, sleep as s, AsyncReturnType as t, waitOn as u };
|
|
36
|
-
//# sourceMappingURL=promise-
|
|
36
|
+
//# sourceMappingURL=promise-CU_CENbU.d.cts.map
|
|
@@ -33,4 +33,4 @@ declare function promisify<T>(value: Promise<T> | T): Promise<T>;
|
|
|
33
33
|
type AsyncReturnType<T extends (...args: any) => any> = T extends ((...args: any) => Promise<infer U>) ? U : T extends ((...args: any) => infer U) ? U : any;
|
|
34
34
|
//#endregion
|
|
35
35
|
export { isTimeout as a, timeout as c, isPromise as i, tryTimeout as l, createPromise as n, promisify as o, immediate as r, sleep as s, AsyncReturnType as t, waitOn as u };
|
|
36
|
-
//# sourceMappingURL=promise-
|
|
36
|
+
//# sourceMappingURL=promise-CoWXgo4w.d.mts.map
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { n as Type, t as Infer } from "./schema-BNke0iHR.cjs";
|
|
2
|
+
import { n as TableColumns, r as TableShape, t as Column } from "./table-IkLXirT-.cjs";
|
|
3
|
+
import { t as Expr } from "./expr-yYgSeBZ3.cjs";
|
|
4
|
+
|
|
5
|
+
//#region src/common/schema/sql/select.d.ts
|
|
6
|
+
type RowFromTable<T> = T extends TableColumns<any, infer S> ? { [K in keyof S]: Infer<S[K]> } : never;
|
|
7
|
+
type RowFromSelection<S> = { [K in keyof S]: S[K] extends Column<infer T> ? T : never };
|
|
8
|
+
interface QueryDependencies {
|
|
9
|
+
readonly table: string;
|
|
10
|
+
readonly select: readonly string[];
|
|
11
|
+
readonly where: readonly string[];
|
|
12
|
+
readonly orderBy: readonly string[];
|
|
13
|
+
readonly all: readonly string[];
|
|
14
|
+
}
|
|
15
|
+
interface CompiledQuery<Row> {
|
|
16
|
+
readonly sql: string;
|
|
17
|
+
readonly params: readonly unknown[];
|
|
18
|
+
readonly dependencies: readonly QueryDependencies[];
|
|
19
|
+
readonly __row?: Row;
|
|
20
|
+
}
|
|
21
|
+
interface OrderByEntry {
|
|
22
|
+
col: Column;
|
|
23
|
+
dir: 'ASC' | 'DESC';
|
|
24
|
+
}
|
|
25
|
+
interface SelectState {
|
|
26
|
+
selection?: Record<string, Column>;
|
|
27
|
+
from?: TableColumns<any, any>;
|
|
28
|
+
where?: Expr;
|
|
29
|
+
orderBy: OrderByEntry[];
|
|
30
|
+
limit?: number;
|
|
31
|
+
offset?: number;
|
|
32
|
+
}
|
|
33
|
+
type ShapeRow<S> = { [K in keyof S]: S[K] extends Type<infer T> ? T : never };
|
|
34
|
+
declare class SelectBuilder<Row, Shape = unknown> {
|
|
35
|
+
private _state;
|
|
36
|
+
constructor(state: SelectState);
|
|
37
|
+
from<N extends string, S extends TableShape>(t: TableColumns<N, S>): SelectBuilder<Row extends void ? ShapeRow<S> : Row, S>;
|
|
38
|
+
pick<K extends Extract<keyof Shape, string>>(...keys: K[]): SelectBuilder<{ [P in K]: Shape[P] extends Type<infer T> ? T : never }, Shape>;
|
|
39
|
+
where(expr: Expr): this;
|
|
40
|
+
orderBy(col: Column, dir?: 'ASC' | 'DESC'): this;
|
|
41
|
+
limit(n: number): this;
|
|
42
|
+
offset(n: number): this;
|
|
43
|
+
toSQL(): CompiledQuery<Row>;
|
|
44
|
+
dependencies(): readonly QueryDependencies[];
|
|
45
|
+
}
|
|
46
|
+
declare function select(): SelectBuilder<void>;
|
|
47
|
+
declare function select<S extends Record<string, Column<any>>>(selection: S): SelectBuilder<RowFromSelection<S>>;
|
|
48
|
+
declare function from<N extends string, S extends TableShape>(t: TableColumns<N, S>): SelectBuilder<ShapeRow<S>, S>;
|
|
49
|
+
type InferRow<Q> = Q extends SelectBuilder<infer R> ? R : Q extends CompiledQuery<infer R> ? R : never;
|
|
50
|
+
//#endregion
|
|
51
|
+
export { RowFromTable as a, select as c, RowFromSelection as i, InferRow as n, SelectBuilder as o, QueryDependencies as r, from as s, CompiledQuery as t };
|
|
52
|
+
//# sourceMappingURL=select-DrciHdk_.d.cts.map
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { n as Type, t as Infer } from "./schema-eMFkYY24.mjs";
|
|
2
|
+
import { n as TableColumns, r as TableShape, t as Column } from "./table-Cr8tjDIL.mjs";
|
|
3
|
+
import { t as Expr } from "./expr-CCKrqOw1.mjs";
|
|
4
|
+
|
|
5
|
+
//#region src/common/schema/sql/select.d.ts
|
|
6
|
+
type RowFromTable<T> = T extends TableColumns<any, infer S> ? { [K in keyof S]: Infer<S[K]> } : never;
|
|
7
|
+
type RowFromSelection<S> = { [K in keyof S]: S[K] extends Column<infer T> ? T : never };
|
|
8
|
+
interface QueryDependencies {
|
|
9
|
+
readonly table: string;
|
|
10
|
+
readonly select: readonly string[];
|
|
11
|
+
readonly where: readonly string[];
|
|
12
|
+
readonly orderBy: readonly string[];
|
|
13
|
+
readonly all: readonly string[];
|
|
14
|
+
}
|
|
15
|
+
interface CompiledQuery<Row> {
|
|
16
|
+
readonly sql: string;
|
|
17
|
+
readonly params: readonly unknown[];
|
|
18
|
+
readonly dependencies: readonly QueryDependencies[];
|
|
19
|
+
readonly __row?: Row;
|
|
20
|
+
}
|
|
21
|
+
interface OrderByEntry {
|
|
22
|
+
col: Column;
|
|
23
|
+
dir: 'ASC' | 'DESC';
|
|
24
|
+
}
|
|
25
|
+
interface SelectState {
|
|
26
|
+
selection?: Record<string, Column>;
|
|
27
|
+
from?: TableColumns<any, any>;
|
|
28
|
+
where?: Expr;
|
|
29
|
+
orderBy: OrderByEntry[];
|
|
30
|
+
limit?: number;
|
|
31
|
+
offset?: number;
|
|
32
|
+
}
|
|
33
|
+
type ShapeRow<S> = { [K in keyof S]: S[K] extends Type<infer T> ? T : never };
|
|
34
|
+
declare class SelectBuilder<Row, Shape = unknown> {
|
|
35
|
+
private _state;
|
|
36
|
+
constructor(state: SelectState);
|
|
37
|
+
from<N extends string, S extends TableShape>(t: TableColumns<N, S>): SelectBuilder<Row extends void ? ShapeRow<S> : Row, S>;
|
|
38
|
+
pick<K extends Extract<keyof Shape, string>>(...keys: K[]): SelectBuilder<{ [P in K]: Shape[P] extends Type<infer T> ? T : never }, Shape>;
|
|
39
|
+
where(expr: Expr): this;
|
|
40
|
+
orderBy(col: Column, dir?: 'ASC' | 'DESC'): this;
|
|
41
|
+
limit(n: number): this;
|
|
42
|
+
offset(n: number): this;
|
|
43
|
+
toSQL(): CompiledQuery<Row>;
|
|
44
|
+
dependencies(): readonly QueryDependencies[];
|
|
45
|
+
}
|
|
46
|
+
declare function select(): SelectBuilder<void>;
|
|
47
|
+
declare function select<S extends Record<string, Column<any>>>(selection: S): SelectBuilder<RowFromSelection<S>>;
|
|
48
|
+
declare function from<N extends string, S extends TableShape>(t: TableColumns<N, S>): SelectBuilder<ShapeRow<S>, S>;
|
|
49
|
+
type InferRow<Q> = Q extends SelectBuilder<infer R> ? R : Q extends CompiledQuery<infer R> ? R : never;
|
|
50
|
+
//#endregion
|
|
51
|
+
export { RowFromTable as a, select as c, RowFromSelection as i, InferRow as n, SelectBuilder as o, QueryDependencies as r, from as s, CompiledQuery as t };
|
|
52
|
+
//# sourceMappingURL=select-F2KpP6mo.d.mts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { n as Type, t as Infer } from "./schema-eMFkYY24.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/common/schema/sql/table.d.ts
|
|
4
|
+
interface Column<T = unknown> {
|
|
5
|
+
readonly _table: string;
|
|
6
|
+
readonly _name: string;
|
|
7
|
+
readonly _type: Type<T>;
|
|
8
|
+
readonly __row?: T;
|
|
9
|
+
}
|
|
10
|
+
type TableShape = Record<string, Type<any>>;
|
|
11
|
+
type TableColumns<N extends string, S extends TableShape> = { readonly [K in keyof S & string]: Column<Infer<S[K]>> } & {
|
|
12
|
+
readonly _name: N;
|
|
13
|
+
readonly _shape: S;
|
|
14
|
+
};
|
|
15
|
+
declare function table<N extends string, S extends TableShape>(name: N, shape: S): TableColumns<N, S>;
|
|
16
|
+
declare function isColumn(v: any): v is Column;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { table as a, isColumn as i, TableColumns as n, TableShape as r, Column as t };
|
|
19
|
+
//# sourceMappingURL=table-Cr8tjDIL.d.mts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { n as Type, t as Infer } from "./schema-BNke0iHR.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/common/schema/sql/table.d.ts
|
|
4
|
+
interface Column<T = unknown> {
|
|
5
|
+
readonly _table: string;
|
|
6
|
+
readonly _name: string;
|
|
7
|
+
readonly _type: Type<T>;
|
|
8
|
+
readonly __row?: T;
|
|
9
|
+
}
|
|
10
|
+
type TableShape = Record<string, Type<any>>;
|
|
11
|
+
type TableColumns<N extends string, S extends TableShape> = { readonly [K in keyof S & string]: Column<Infer<S[K]>> } & {
|
|
12
|
+
readonly _name: N;
|
|
13
|
+
readonly _shape: S;
|
|
14
|
+
};
|
|
15
|
+
declare function table<N extends string, S extends TableShape>(name: N, shape: S): TableColumns<N, S>;
|
|
16
|
+
declare function isColumn(v: any): v is Column;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { table as a, isColumn as i, TableColumns as n, TableShape as r, Column as t };
|
|
19
|
+
//# sourceMappingURL=table-IkLXirT-.d.cts.map
|
|
@@ -137,4 +137,4 @@ declare function getBuildNumber(): string;
|
|
|
137
137
|
declare function getSecondsFromBuildNumber(buildNumber: string): number;
|
|
138
138
|
//#endregion
|
|
139
139
|
export { parseDate as C, timestampSecondsToMilliseconds as E, getTimestampInSeconds as S, timestampMillisecondsToSeconds as T, formatMilliseconds as _, TIME_MINUTE_MS as a, getSecondsFromBuildNumber as b, TIME_MONTH_S as c, TIME_YEAR_MS as d, TIME_YEAR_S as f, duration as g, datetimeToUTC as h, TIME_HOUR_S as i, TIME_WEEK_MS as l, datetimeToLocal as m, TIME_DAY_S as n, TIME_MINUTE_S as o, dateFromSeconds as p, TIME_HOUR_MS as r, TIME_MONTH_MS as s, TIME_DAY_MS as t, TIME_WEEK_S as u, getBuildNumber as v, setTimestampTest as w, getTimestamp as x, getPerformanceTimestamp as y };
|
|
140
|
-
//# sourceMappingURL=time-
|
|
140
|
+
//# sourceMappingURL=time-BgFZe9ys.d.cts.map
|
|
@@ -137,4 +137,4 @@ declare function getBuildNumber(): string;
|
|
|
137
137
|
declare function getSecondsFromBuildNumber(buildNumber: string): number;
|
|
138
138
|
//#endregion
|
|
139
139
|
export { parseDate as C, timestampSecondsToMilliseconds as E, getTimestampInSeconds as S, timestampMillisecondsToSeconds as T, formatMilliseconds as _, TIME_MINUTE_MS as a, getSecondsFromBuildNumber as b, TIME_MONTH_S as c, TIME_YEAR_MS as d, TIME_YEAR_S as f, duration as g, datetimeToUTC as h, TIME_HOUR_S as i, TIME_WEEK_MS as l, datetimeToLocal as m, TIME_DAY_S as n, TIME_MINUTE_S as o, dateFromSeconds as p, TIME_HOUR_MS as r, TIME_MONTH_MS as s, TIME_DAY_MS as t, TIME_WEEK_S as u, getBuildNumber as v, setTimestampTest as w, getTimestamp as x, getPerformanceTimestamp as y };
|
|
140
|
-
//# sourceMappingURL=time-
|
|
140
|
+
//# sourceMappingURL=time-DSV_k3mG.d.mts.map
|
|
@@ -3,4 +3,4 @@ type Expect<T extends true> = T;
|
|
|
3
3
|
type IsEqual<X, Y> = (<T>() => T extends X ? true : false) extends (<T>() => T extends Y ? true : false) ? true : false;
|
|
4
4
|
//#endregion
|
|
5
5
|
export { IsEqual as n, Expect as t };
|
|
6
|
-
//# sourceMappingURL=type-test-
|
|
6
|
+
//# sourceMappingURL=type-test-BvzWDJz3.d.mts.map
|
|
@@ -3,4 +3,4 @@ type Expect<T extends true> = T;
|
|
|
3
3
|
type IsEqual<X, Y> = (<T>() => T extends X ? true : false) extends (<T>() => T extends Y ? true : false) ? true : false;
|
|
4
4
|
//#endregion
|
|
5
5
|
export { IsEqual as n, Expect as t };
|
|
6
|
-
//# sourceMappingURL=type-test-
|
|
6
|
+
//# sourceMappingURL=type-test-CBK-iJ9d.d.cts.map
|
|
@@ -8,4 +8,4 @@ declare function isSchemaPrimitive(schema: Type<any>): boolean;
|
|
|
8
8
|
declare function isSchemaObjectFlat(schema: Type<any>): boolean;
|
|
9
9
|
//#endregion
|
|
10
10
|
export { isSchemaPrimitive as a, isSchemaOptional as i, isSchemaObject as n, isSchemaObjectFlat as r, isSchemaDefault as t };
|
|
11
|
-
//# sourceMappingURL=utils-
|
|
11
|
+
//# sourceMappingURL=utils-1RyCGkpQ.d.mts.map
|
|
@@ -8,4 +8,4 @@ declare function isSchemaPrimitive(schema: Type<any>): boolean;
|
|
|
8
8
|
declare function isSchemaObjectFlat(schema: Type<any>): boolean;
|
|
9
9
|
//#endregion
|
|
10
10
|
export { isSchemaPrimitive as a, isSchemaOptional as i, isSchemaObject as n, isSchemaObjectFlat as r, isSchemaDefault as t };
|
|
11
|
-
//# sourceMappingURL=utils-
|
|
11
|
+
//# sourceMappingURL=utils-nCQklGHV.d.cts.map
|
|
@@ -193,4 +193,4 @@ declare function unameReset(name?: string): void;
|
|
|
193
193
|
declare function qid(): string;
|
|
194
194
|
//#endregion
|
|
195
195
|
export { uuidv4 as C, uuidIsValid as S, uuidDecodeV4 as _, suidBytesDate as a, uuidEncodeB62 as b, unameReset as c, uuidB32 as d, uuidB62 as f, uuidDecodeB62 as g, uuidDecodeB32 as h, suidBytes as i, uuid as l, uuidDecode as m, setUuidDefaultEncoding as n, suidDate as o, uuidBytes as p, suid as r, uname as s, qid as t, uuid32bit as u, uuidEncode as v, uuidEncodeV4 as x, uuidEncodeB32 as y };
|
|
196
|
-
//# sourceMappingURL=uuid-
|
|
196
|
+
//# sourceMappingURL=uuid-CKFZfSff.d.mts.map
|
|
@@ -193,4 +193,4 @@ declare function unameReset(name?: string): void;
|
|
|
193
193
|
declare function qid(): string;
|
|
194
194
|
//#endregion
|
|
195
195
|
export { uuidv4 as C, uuidIsValid as S, uuidDecodeV4 as _, suidBytesDate as a, uuidEncodeB62 as b, unameReset as c, uuidB32 as d, uuidB62 as f, uuidDecodeB62 as g, uuidDecodeB32 as h, suidBytes as i, uuid as l, uuidDecode as m, setUuidDefaultEncoding as n, suidDate as o, uuidBytes as p, suid as r, uname as s, qid as t, uuid32bit as u, uuidEncode as v, uuidEncodeV4 as x, uuidEncodeB32 as y };
|
|
196
|
-
//# sourceMappingURL=uuid-
|
|
196
|
+
//# sourceMappingURL=uuid-D42A8UdP.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zeed",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.5.0",
|
|
5
5
|
"packageManager": "pnpm@10.33.0",
|
|
6
6
|
"description": "🌱 Simple foundation library",
|
|
7
7
|
"author": {
|
|
@@ -65,8 +65,7 @@
|
|
|
65
65
|
"upload:docs": "nr build:docs && rsync -avz docs/* cy:public_html/zeed.holtwick.de",
|
|
66
66
|
"clean": "rm -rf dist",
|
|
67
67
|
"coverage": "vitest --run --coverage",
|
|
68
|
-
"lint": "eslint .",
|
|
69
|
-
"lint:fix": "eslint . --fix",
|
|
68
|
+
"lint": "eslint . --fix",
|
|
70
69
|
"prepublishOnly": "nr build && nr circles",
|
|
71
70
|
"start": "nr watch",
|
|
72
71
|
"test": "nr check && vitest --run",
|
|
@@ -74,11 +73,11 @@
|
|
|
74
73
|
"test:firefox": "BROWSER=firefox vitest",
|
|
75
74
|
"test:webkit": "BROWSER=webkit vitest",
|
|
76
75
|
"test:chromium": "BROWSER=chromium vitest",
|
|
77
|
-
"test:release": "nr lint
|
|
76
|
+
"test:release": "nr lint && nr check && vitest --run",
|
|
78
77
|
"post:release": "nr upload:docs && nr npm:release",
|
|
79
78
|
"npm:release": "npm login && npm publish --access public",
|
|
80
79
|
"watch": "nr build -- --watch src",
|
|
81
|
-
"prep": "nr lint
|
|
80
|
+
"prep": "nr lint && nr check && nr test:release && nr upload:docs"
|
|
82
81
|
},
|
|
83
82
|
"devDependencies": {
|
|
84
83
|
"@antfu/eslint-config": "^8.2.0",
|
|
@@ -88,11 +87,11 @@
|
|
|
88
87
|
"@vitest/browser": "^4.1.4",
|
|
89
88
|
"@vitest/coverage-v8": "^4.1.4",
|
|
90
89
|
"esbuild": "^0.28.0",
|
|
91
|
-
"eslint": "^10.2.
|
|
90
|
+
"eslint": "^10.2.1",
|
|
92
91
|
"playwright": "^1.59.1",
|
|
93
92
|
"pnpm": "^10.32.1",
|
|
94
|
-
"tsdown": "^0.21.
|
|
95
|
-
"typescript": "^6.0.
|
|
93
|
+
"tsdown": "^0.21.9",
|
|
94
|
+
"typescript": "^6.0.3",
|
|
96
95
|
"vite": "^8.0.8",
|
|
97
96
|
"vitest": "^4.1.4"
|
|
98
97
|
}
|
|
@@ -171,11 +171,15 @@ describe('json-schema.spec', () => {
|
|
|
171
171
|
"type": "string",
|
|
172
172
|
},
|
|
173
173
|
"value": Object {
|
|
174
|
-
"
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
174
|
+
"anyOf": Array [
|
|
175
|
+
Object {
|
|
176
|
+
"type": "string",
|
|
177
|
+
},
|
|
178
|
+
Object {
|
|
179
|
+
"type": "number",
|
|
180
|
+
},
|
|
178
181
|
],
|
|
182
|
+
"description": "The value to compare against",
|
|
179
183
|
},
|
|
180
184
|
},
|
|
181
185
|
"required": Array [
|
|
@@ -233,9 +237,9 @@ describe('json-schema.spec', () => {
|
|
|
233
237
|
description: 'A comparison operator',
|
|
234
238
|
},
|
|
235
239
|
value: {
|
|
236
|
-
|
|
237
|
-
'string',
|
|
238
|
-
'number',
|
|
240
|
+
anyOf: [
|
|
241
|
+
{ type: 'string' },
|
|
242
|
+
{ type: 'number' },
|
|
239
243
|
],
|
|
240
244
|
description: 'The value to compare against',
|
|
241
245
|
},
|