usage-board 3.1.0 → 3.1.1
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/index.mjs +1 -1
- package/dist/public/_nuxt/{BuL2_OVR.js → B6C9KBQ4.js} +1 -1
- package/dist/public/_nuxt/{CbwePq4F.js → Bv6agYS5.js} +1 -1
- package/dist/public/_nuxt/{LYzk-FvL.js → BvRyOET7.js} +1 -1
- package/dist/public/_nuxt/{CF27djws.js → CMWftE4h.js} +1 -1
- package/dist/public/_nuxt/{CoVMsEv_.js → COIbUy5w.js} +1 -1
- package/dist/public/_nuxt/{DS17D0R7.js → CXLmM1yO.js} +1 -1
- package/dist/public/_nuxt/{Bz0aA7IQ.js → DFqWEFN4.js} +1 -1
- package/dist/public/_nuxt/{WjVGlVHF.js → DUoLvn3A.js} +1 -1
- package/dist/public/_nuxt/{Dzuxw4nD.js → D_W11Quh.js} +1 -1
- package/dist/public/_nuxt/{D7Qebc1i.js → DgKrPjze.js} +2 -2
- package/dist/public/_nuxt/{CEZpUSPI.js → DkxY2YMp.js} +1 -1
- package/dist/public/_nuxt/{Dr4nyTE3.js → DtbPvE6R.js} +1 -1
- package/dist/public/_nuxt/{BJUAqwzD.js → HiqUua3-.js} +1 -1
- package/dist/public/_nuxt/builds/latest.json +1 -1
- package/dist/public/_nuxt/builds/meta/6f98f1cb-266c-475e-a249-dad346a55f24.json +1 -0
- package/dist/public/_nuxt/error-404.CFBEg71j.css +1 -0
- package/dist/public/_nuxt/error-500.BqCnH31G.css +1 -0
- package/dist/public/_nuxt/{Cd5S9Sm2.js → uHQwCIHg.js} +1 -1
- package/dist/server/chunks/_/error-500.mjs +2 -20
- package/dist/server/chunks/build/client.precomputed.mjs +1 -1
- package/dist/server/chunks/nitro/nitro.mjs +1885 -3648
- package/dist/server/chunks/routes/api/analysis/agent/session.json.mjs +8 -9
- package/dist/server/chunks/routes/api/analysis/agent/token.json.mjs +8 -9
- package/dist/server/chunks/routes/api/analysis/cache.json.mjs +8 -9
- package/dist/server/chunks/routes/api/analysis/hot-project.json.mjs +8 -9
- package/dist/server/chunks/routes/api/analysis/model.json.mjs +8 -9
- package/dist/server/chunks/routes/api/analysis/overview-cards.json.mjs +8 -9
- package/dist/server/chunks/routes/api/analysis/session.json.mjs +8 -9
- package/dist/server/chunks/routes/api/analysis/token/daily.json.mjs +8 -9
- package/dist/server/chunks/routes/api/analysis/token.json.mjs +8 -9
- package/dist/server/chunks/routes/api/payload.json.mjs +8 -9
- package/dist/server/chunks/routes/api/projects/_project/modules.get.mjs +8 -9
- package/dist/server/chunks/routes/api/projects/catalog.get.mjs +8 -9
- package/dist/server/chunks/routes/renderer.mjs +17 -39183
- package/dist/server/chunks/routes/ws.mjs +8 -9
- package/dist/server/index.mjs +9 -10
- package/dist/server/node_modules/@babel/parser/lib/index.js +14582 -0
- package/dist/server/node_modules/@babel/parser/package.json +50 -0
- package/dist/server/node_modules/@iconify/utils/lib/colors/index.js +292 -0
- package/dist/server/node_modules/@iconify/utils/lib/colors/keywords.js +702 -0
- package/dist/server/node_modules/@iconify/utils/lib/css/common.js +76 -0
- package/dist/server/node_modules/@iconify/utils/lib/css/format.js +40 -0
- package/dist/server/node_modules/@iconify/utils/lib/css/icon.js +52 -0
- package/dist/server/node_modules/@iconify/utils/lib/css/icons.js +133 -0
- package/dist/server/node_modules/@iconify/utils/lib/customisations/bool.js +20 -0
- package/dist/server/node_modules/@iconify/utils/lib/customisations/defaults.js +15 -0
- package/dist/server/node_modules/@iconify/utils/lib/customisations/flip.js +18 -0
- package/dist/server/node_modules/@iconify/utils/lib/customisations/merge.js +18 -0
- package/dist/server/node_modules/@iconify/utils/lib/customisations/rotate.js +31 -0
- package/dist/server/node_modules/@iconify/utils/lib/emoji/cleanup.js +80 -0
- package/dist/server/node_modules/@iconify/utils/lib/emoji/convert.js +102 -0
- package/dist/server/node_modules/@iconify/utils/lib/emoji/data.js +29 -0
- package/dist/server/node_modules/@iconify/utils/lib/emoji/format.js +60 -0
- package/dist/server/node_modules/@iconify/utils/lib/emoji/parse.js +50 -0
- package/dist/server/node_modules/@iconify/utils/lib/emoji/regex/base.js +204 -0
- package/dist/server/node_modules/@iconify/utils/lib/emoji/regex/create.js +35 -0
- package/dist/server/node_modules/@iconify/utils/lib/emoji/regex/numbers.js +134 -0
- package/dist/server/node_modules/@iconify/utils/lib/emoji/regex/similar.js +167 -0
- package/dist/server/node_modules/@iconify/utils/lib/emoji/regex/tree.js +81 -0
- package/dist/server/node_modules/@iconify/utils/lib/emoji/replace/find.js +94 -0
- package/dist/server/node_modules/@iconify/utils/lib/emoji/replace/replace.js +28 -0
- package/dist/server/node_modules/@iconify/utils/lib/emoji/test/components.js +78 -0
- package/dist/server/node_modules/@iconify/utils/lib/emoji/test/missing.js +68 -0
- package/dist/server/node_modules/@iconify/utils/lib/emoji/test/name.js +47 -0
- package/dist/server/node_modules/@iconify/utils/lib/emoji/test/parse.js +105 -0
- package/dist/server/node_modules/@iconify/utils/lib/emoji/test/similar.js +38 -0
- package/dist/server/node_modules/@iconify/utils/lib/emoji/test/tree.js +94 -0
- package/dist/server/node_modules/@iconify/utils/lib/emoji/test/variations.js +64 -0
- package/dist/server/node_modules/@iconify/utils/lib/icon/defaults.js +26 -0
- package/dist/server/node_modules/@iconify/utils/lib/icon/merge.js +18 -0
- package/dist/server/node_modules/@iconify/utils/lib/icon/name.js +58 -0
- package/dist/server/node_modules/@iconify/utils/lib/icon/square.js +34 -0
- package/dist/server/node_modules/@iconify/utils/lib/icon/transformations.js +13 -0
- package/dist/server/node_modules/@iconify/utils/lib/icon-set/convert-info.js +126 -0
- package/dist/server/node_modules/@iconify/utils/lib/icon-set/expand.js +21 -0
- package/dist/server/node_modules/@iconify/utils/lib/icon-set/get-icon.js +27 -0
- package/dist/server/node_modules/@iconify/utils/lib/icon-set/get-icons.js +38 -0
- package/dist/server/node_modules/@iconify/utils/lib/icon-set/minify.js +93 -0
- package/dist/server/node_modules/@iconify/utils/lib/icon-set/parse.js +48 -0
- package/dist/server/node_modules/@iconify/utils/lib/icon-set/tree.js +24 -0
- package/dist/server/node_modules/@iconify/utils/lib/icon-set/validate-basic.js +44 -0
- package/dist/server/node_modules/@iconify/utils/lib/icon-set/validate.js +125 -0
- package/dist/server/node_modules/@iconify/utils/lib/index.js +53 -0
- package/dist/server/node_modules/@iconify/utils/lib/loader/custom.js +32 -0
- package/dist/server/node_modules/@iconify/utils/lib/loader/loader.js +28 -0
- package/dist/server/node_modules/@iconify/utils/lib/loader/modern.js +42 -0
- package/dist/server/node_modules/@iconify/utils/lib/loader/utils.js +63 -0
- package/dist/server/node_modules/@iconify/utils/lib/misc/objects.js +27 -0
- package/dist/server/node_modules/@iconify/utils/lib/misc/strings.js +27 -0
- package/dist/server/node_modules/@iconify/utils/lib/misc/title.js +10 -0
- package/dist/server/node_modules/@iconify/utils/lib/svg/build.js +115 -0
- package/dist/server/node_modules/@iconify/utils/lib/svg/defs.js +32 -0
- package/dist/server/node_modules/@iconify/utils/lib/svg/encode-svg-for-css.js +15 -0
- package/dist/server/node_modules/@iconify/utils/lib/svg/html.js +10 -0
- package/dist/server/node_modules/@iconify/utils/lib/svg/id.js +42 -0
- package/dist/server/node_modules/@iconify/utils/lib/svg/inner-html.js +23 -0
- package/dist/server/node_modules/@iconify/utils/lib/svg/parse.js +69 -0
- package/dist/server/node_modules/@iconify/utils/lib/svg/pretty.js +55 -0
- package/dist/server/node_modules/@iconify/utils/lib/svg/size.js +28 -0
- package/dist/server/node_modules/@iconify/utils/lib/svg/trim.js +8 -0
- package/dist/server/node_modules/@iconify/utils/lib/svg/url.js +23 -0
- package/dist/server/node_modules/@iconify/utils/lib/svg/viewbox.js +9 -0
- package/dist/server/node_modules/@iconify/utils/package.json +118 -0
- package/dist/server/node_modules/@lonewolfyx/utils/dist/index.mjs +63 -0
- package/dist/server/node_modules/@lonewolfyx/utils/package.json +64 -0
- package/dist/server/node_modules/@vue/compiler-core/dist/compiler-core.cjs.prod.js +6763 -0
- package/dist/server/node_modules/@vue/compiler-core/package.json +58 -0
- package/dist/server/node_modules/@vue/compiler-dom/dist/compiler-dom.cjs.prod.js +689 -0
- package/dist/server/node_modules/@vue/compiler-dom/package.json +57 -0
- package/dist/server/node_modules/@vue/compiler-ssr/dist/compiler-ssr.cjs.js +1413 -0
- package/dist/server/node_modules/@vue/compiler-ssr/package.json +34 -0
- package/dist/server/node_modules/@vue/reactivity/dist/reactivity.cjs.prod.js +1877 -0
- package/dist/server/node_modules/@vue/reactivity/package.json +55 -0
- package/dist/server/node_modules/@vue/runtime-core/dist/runtime-core.cjs.prod.js +6856 -0
- package/dist/server/node_modules/@vue/runtime-core/package.json +52 -0
- package/dist/server/node_modules/@vue/runtime-dom/dist/runtime-dom.cjs.prod.js +1796 -0
- package/dist/server/node_modules/@vue/runtime-dom/package.json +60 -0
- package/dist/server/node_modules/@vue/server-renderer/dist/server-renderer.cjs.prod.js +883 -0
- package/dist/server/node_modules/@vue/server-renderer/package.json +55 -0
- package/dist/server/{chunks/_/shared.cjs.prod.mjs → node_modules/@vue/shared/dist/shared.cjs.prod.js} +76 -81
- package/dist/server/node_modules/@vue/shared/package.json +47 -0
- package/dist/server/node_modules/better-sqlite3/build/Release/better_sqlite3.node +0 -0
- package/dist/server/node_modules/better-sqlite3/lib/database.js +90 -0
- package/dist/server/node_modules/better-sqlite3/lib/index.js +3 -0
- package/dist/server/node_modules/better-sqlite3/lib/methods/aggregate.js +43 -0
- package/dist/server/node_modules/better-sqlite3/lib/methods/backup.js +67 -0
- package/dist/server/node_modules/better-sqlite3/lib/methods/function.js +31 -0
- package/dist/server/node_modules/better-sqlite3/lib/methods/inspect.js +7 -0
- package/dist/server/node_modules/better-sqlite3/lib/methods/pragma.js +12 -0
- package/dist/server/node_modules/better-sqlite3/lib/methods/serialize.js +16 -0
- package/dist/server/node_modules/better-sqlite3/lib/methods/table.js +189 -0
- package/dist/server/node_modules/better-sqlite3/lib/methods/transaction.js +78 -0
- package/dist/server/node_modules/better-sqlite3/lib/methods/wrappers.js +54 -0
- package/dist/server/node_modules/better-sqlite3/lib/sqlite-error.js +20 -0
- package/dist/server/node_modules/better-sqlite3/lib/util.js +12 -0
- package/dist/server/node_modules/better-sqlite3/package.json +59 -0
- package/dist/server/node_modules/bindings/bindings.js +221 -0
- package/dist/server/node_modules/bindings/package.json +28 -0
- package/dist/server/node_modules/chokidar/handler.js +632 -0
- package/dist/server/node_modules/chokidar/index.js +822 -0
- package/dist/server/node_modules/chokidar/package.json +63 -0
- package/dist/server/{chunks/_ → node_modules/consola/dist/chunks}/prompt.mjs +2 -1
- package/dist/server/node_modules/consola/dist/core.mjs +512 -0
- package/dist/server/node_modules/consola/dist/index.mjs +651 -0
- package/dist/server/node_modules/consola/dist/shared/consola.DRwqZj3T.mjs +72 -0
- package/dist/server/node_modules/consola/dist/shared/consola.DXBYu-KD.mjs +288 -0
- package/dist/server/node_modules/consola/package.json +136 -0
- package/dist/server/node_modules/devalue/index.js +4 -0
- package/dist/server/node_modules/devalue/package.json +40 -0
- package/dist/server/node_modules/devalue/src/base64.js +60 -0
- package/dist/server/node_modules/devalue/src/constants.js +7 -0
- package/dist/server/node_modules/devalue/src/parse.js +268 -0
- package/dist/server/node_modules/devalue/src/stringify.js +335 -0
- package/dist/server/node_modules/devalue/src/uneval.js +552 -0
- package/dist/server/node_modules/devalue/src/utils.js +144 -0
- package/dist/server/node_modules/entities/dist/commonjs/decode-codepoint.js +77 -0
- package/dist/server/node_modules/entities/dist/commonjs/decode.js +568 -0
- package/dist/server/node_modules/entities/dist/commonjs/generated/decode-data-html.js +7 -0
- package/dist/server/node_modules/entities/dist/commonjs/generated/decode-data-xml.js +7 -0
- package/dist/server/node_modules/entities/dist/commonjs/internal/bin-trie-flags.js +21 -0
- package/dist/server/node_modules/entities/dist/commonjs/internal/decode-shared.js +31 -0
- package/dist/server/node_modules/entities/dist/commonjs/package.json +3 -0
- package/dist/server/node_modules/entities/package.json +120 -0
- package/dist/server/node_modules/estree-walker/dist/umd/estree-walker.js +344 -0
- package/dist/server/node_modules/estree-walker/package.json +37 -0
- package/dist/server/node_modules/file-uri-to-path/index.js +66 -0
- package/dist/server/node_modules/file-uri-to-path/package.json +32 -0
- package/dist/server/node_modules/glob/dist/esm/index.min.js +4 -0
- package/dist/server/node_modules/glob/dist/esm/package.json +3 -0
- package/dist/server/node_modules/glob/package.json +98 -0
- package/dist/server/node_modules/hookable/dist/index.mjs +257 -0
- package/dist/server/node_modules/hookable/package.json +53 -0
- package/dist/server/node_modules/md5-typescript/dist/bundles/bundle.umd.js +208 -0
- package/dist/server/node_modules/md5-typescript/package.json +31 -0
- package/dist/server/node_modules/path-type/index.js +42 -0
- package/dist/server/node_modules/path-type/package.json +51 -0
- package/dist/server/node_modules/readdirp/index.js +272 -0
- package/dist/server/node_modules/readdirp/package.json +66 -0
- package/dist/server/node_modules/source-map-js/lib/array-set.js +121 -0
- package/dist/server/node_modules/source-map-js/lib/base64-vlq.js +140 -0
- package/dist/server/node_modules/source-map-js/lib/base64.js +67 -0
- package/dist/server/node_modules/source-map-js/lib/binary-search.js +111 -0
- package/dist/server/node_modules/source-map-js/lib/mapping-list.js +79 -0
- package/dist/server/node_modules/source-map-js/lib/quick-sort.js +132 -0
- package/dist/server/node_modules/source-map-js/lib/source-map-consumer.js +1188 -0
- package/dist/server/node_modules/source-map-js/lib/source-map-generator.js +444 -0
- package/dist/server/node_modules/source-map-js/lib/source-node.js +413 -0
- package/dist/server/node_modules/source-map-js/lib/util.js +594 -0
- package/dist/server/node_modules/source-map-js/package.json +71 -0
- package/dist/server/node_modules/source-map-js/source-map.js +8 -0
- package/dist/server/node_modules/ufo/dist/index.mjs +645 -0
- package/dist/server/node_modules/ufo/package.json +48 -0
- package/dist/server/node_modules/unhead/dist/parser.mjs +508 -0
- package/dist/server/node_modules/unhead/dist/plugins.mjs +101 -0
- package/dist/server/node_modules/unhead/dist/server.mjs +180 -0
- package/dist/server/node_modules/unhead/dist/shared/unhead.B5FWS6X0.mjs +207 -0
- package/dist/server/node_modules/unhead/dist/shared/unhead.BYvz9V1x.mjs +43 -0
- package/dist/server/node_modules/unhead/dist/shared/unhead.CbpEuj3y.mjs +71 -0
- package/dist/server/node_modules/unhead/dist/shared/unhead.Ct24BOby.mjs +182 -0
- package/dist/server/node_modules/unhead/dist/shared/unhead.D4vSFytZ.mjs +236 -0
- package/dist/server/node_modules/unhead/dist/shared/unhead.DQc16pHI.mjs +196 -0
- package/dist/server/node_modules/unhead/dist/shared/unhead.TxTMM7cM.mjs +166 -0
- package/dist/server/node_modules/unhead/dist/shared/unhead.yem5I2v_.mjs +38 -0
- package/dist/server/node_modules/unhead/dist/utils.mjs +5 -0
- package/dist/server/node_modules/unhead/package.json +105 -0
- package/dist/server/node_modules/vue/dist/vue.cjs.js +80 -0
- package/dist/server/node_modules/vue/dist/vue.cjs.prod.js +66 -0
- package/dist/server/node_modules/vue/index.js +7 -0
- package/dist/server/node_modules/vue/index.mjs +1 -0
- package/dist/server/node_modules/vue/package.json +112 -0
- package/dist/server/node_modules/vue/server-renderer/index.mjs +1 -0
- package/dist/server/node_modules/vue-bundle-renderer/dist/runtime.mjs +301 -0
- package/dist/server/node_modules/vue-bundle-renderer/package.json +55 -0
- package/dist/server/package.json +37 -0
- package/package.json +3 -1
- package/dist/public/_nuxt/builds/meta/5b933d30-47b4-45ca-8d5a-cba3255174fa.json +0 -1
- package/dist/public/_nuxt/error-404.B0EXnOcv.css +0 -1
- package/dist/public/_nuxt/error-500.CnSNZoEG.css +0 -1
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "chokidar",
|
|
3
|
+
"description": "Minimal and efficient cross-platform file watching library",
|
|
4
|
+
"version": "5.0.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"homepage": "https://github.com/paulmillr/chokidar",
|
|
7
|
+
"author": "Paul Miller (https://paulmillr.com)",
|
|
8
|
+
"files": [
|
|
9
|
+
"index.js",
|
|
10
|
+
"index.d.ts",
|
|
11
|
+
"handler.js",
|
|
12
|
+
"handler.d.ts"
|
|
13
|
+
],
|
|
14
|
+
"main": "./index.js",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"default": "./index.js"
|
|
18
|
+
},
|
|
19
|
+
"./handler.js": {
|
|
20
|
+
"default": "./handler.js"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"readdirp": "^5.0.0"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@paulmillr/jsbt": "0.4.5",
|
|
28
|
+
"@types/node": "24.10.1",
|
|
29
|
+
"prettier": "3.5.2",
|
|
30
|
+
"tinyspy": "3.0.2",
|
|
31
|
+
"typescript": "5.9.2",
|
|
32
|
+
"upath": "2.0.1"
|
|
33
|
+
},
|
|
34
|
+
"sideEffects": false,
|
|
35
|
+
"engines": {
|
|
36
|
+
"node": ">= 20.19.0"
|
|
37
|
+
},
|
|
38
|
+
"repository": {
|
|
39
|
+
"type": "git",
|
|
40
|
+
"url": "git+https://github.com/paulmillr/chokidar.git"
|
|
41
|
+
},
|
|
42
|
+
"bugs": {
|
|
43
|
+
"url": "https://github.com/paulmillr/chokidar/issues"
|
|
44
|
+
},
|
|
45
|
+
"license": "MIT",
|
|
46
|
+
"scripts": {
|
|
47
|
+
"build": "tsc",
|
|
48
|
+
"lint": "prettier --check src",
|
|
49
|
+
"format": "prettier --write src",
|
|
50
|
+
"test": "node index.test.js",
|
|
51
|
+
"test:bun1": "bun index.test.js"
|
|
52
|
+
},
|
|
53
|
+
"keywords": [
|
|
54
|
+
"fs",
|
|
55
|
+
"watch",
|
|
56
|
+
"watchFile",
|
|
57
|
+
"watcher",
|
|
58
|
+
"watching",
|
|
59
|
+
"file",
|
|
60
|
+
"fsevents"
|
|
61
|
+
],
|
|
62
|
+
"funding": "https://paulmillr.com/funding/"
|
|
63
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import 'node:util';
|
|
1
2
|
import g, { stdin, stdout } from 'node:process';
|
|
2
3
|
import f from 'node:readline';
|
|
3
4
|
import { WriteStream } from 'node:tty';
|
|
@@ -170,7 +171,7 @@ function J({onlyFirst:t=false}={}){const F=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(
|
|
|
170
171
|
`).map(e=>oD(e,u,F)).join(`
|
|
171
172
|
`)}const aD=["up","down","left","right","space","enter","cancel"],c={actions:new Set(aD),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["","cancel"],["escape","cancel"]])};function k$1(t,u){if(typeof t=="string")return c.aliases.get(t)===u;for(const F of t)if(F!==void 0&&k$1(F,u))return true;return false}function lD(t,u){if(t===u)return;const F=t.split(`
|
|
172
173
|
`),e=u.split(`
|
|
173
|
-
`),s=[];for(let i=0;i<Math.max(F.length,e.length);i++)F[i]!==e[i]&&s.push(i);return s}process.platform.startsWith("win");const S=Symbol("clack:cancel");function d$1(t,u){const F=t;F.isTTY&&F.setRawMode(u);}var AD=Object.defineProperty,pD=(t,u,F)=>u in t?AD(t,u,{enumerable:true,configurable:true,writable:true,value:F}):t[u]=F,h=(t,u,F)=>(pD(t,typeof u!="symbol"?u+"":u,F),F);class x{constructor(u,F=true){h(this,"input"),h(this,"output"),h(this,"_abortSignal"),h(this,"rl"),h(this,"opts"),h(this,"_render"),h(this,"_track",false),h(this,"_prevFrame",""),h(this,"_subscribers",new Map),h(this,"_cursor",0),h(this,"state","initial"),h(this,"error",""),h(this,"value");const{input:e=stdin,output:s=stdout,render:i,signal:D,...C}=u;this.opts=C,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=i.bind(this),this._track=F,this._abortSignal=D,this.input=e,this.output=s;}unsubscribe(){this._subscribers.clear();}setSubscriber(u,F){const e=this._subscribers.get(u)??[];e.push(F),this._subscribers.set(u,e);}on(u,F){this.setSubscriber(u,{cb:F});}once(u,F){this.setSubscriber(u,{cb:F,once:true});}emit(u,...F){const e=this._subscribers.get(u)??[],s=[];for(const i of e)i.cb(...F),i.once&&s.push(()=>e.splice(e.indexOf(i),1));for(const i of s)i();}prompt(){return new Promise((u,F)=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),u(S);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close();},{once:true});}const e=new WriteStream(0);e._write=(s,i,D)=>{this._track&&(this.value=this.rl?.line.replace(/\t/g,""),this._cursor=this.rl?.cursor??0,this.emit("value",this.value)),D();},this.input.pipe(e),this.rl=f.createInterface({input:this.input,output:e,tabSize:2,prompt:"",escapeCodeTimeout:50}),f.emitKeypressEvents(this.input,this.rl),this.rl.prompt(),this.opts.initialValue!==void 0&&this._track&&this.rl.write(this.opts.initialValue),this.input.on("keypress",this.onKeypress),d$1(this.input,true),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(srcExports.cursor.show),this.output.off("resize",this.render),d$1(this.input,false),u(this.value);}),this.once("cancel",()=>{this.output.write(srcExports.cursor.show),this.output.off("resize",this.render),d$1(this.input,false),u(S);});})}onKeypress(u,F){if(this.state==="error"&&(this.state="active"),F?.name&&(!this._track&&c.aliases.has(F.name)&&this.emit("cursor",c.aliases.get(F.name)),c.actions.has(F.name)&&this.emit("cursor",F.name)),u&&(u.toLowerCase()==="y"||u.toLowerCase()==="n")&&this.emit("confirm",u.toLowerCase()==="y"),u===" "&&this.opts.placeholder&&(this.value||(this.rl?.write(this.opts.placeholder),this.emit("value",this.opts.placeholder))),u&&this.emit("key",u.toLowerCase()),F?.name==="return"){if(this.opts.validate){const e=this.opts.validate(this.value);e&&(this.error=e instanceof Error?e.message:e,this.state="error",this.rl?.write(this.value));}this.state!=="error"&&(this.state="submit");}k$1([u,F?.name,F?.sequence],"cancel")&&(this.state="cancel"),(this.state==="submit"||this.state==="cancel")&&this.emit("finalize"),this.render(),(this.state==="submit"||this.state==="cancel")&&this.close();}close(){this.input.unpipe(),this.input.removeListener("keypress",this.onKeypress),this.output.write(`
|
|
174
|
+
`),s=[];for(let i=0;i<Math.max(F.length,e.length);i++)F[i]!==e[i]&&s.push(i);return s}globalThis.process.platform.startsWith("win");const S=Symbol("clack:cancel");function d$1(t,u){const F=t;F.isTTY&&F.setRawMode(u);}var AD=Object.defineProperty,pD=(t,u,F)=>u in t?AD(t,u,{enumerable:true,configurable:true,writable:true,value:F}):t[u]=F,h=(t,u,F)=>(pD(t,typeof u!="symbol"?u+"":u,F),F);class x{constructor(u,F=true){h(this,"input"),h(this,"output"),h(this,"_abortSignal"),h(this,"rl"),h(this,"opts"),h(this,"_render"),h(this,"_track",false),h(this,"_prevFrame",""),h(this,"_subscribers",new Map),h(this,"_cursor",0),h(this,"state","initial"),h(this,"error",""),h(this,"value");const{input:e=stdin,output:s=stdout,render:i,signal:D,...C}=u;this.opts=C,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=i.bind(this),this._track=F,this._abortSignal=D,this.input=e,this.output=s;}unsubscribe(){this._subscribers.clear();}setSubscriber(u,F){const e=this._subscribers.get(u)??[];e.push(F),this._subscribers.set(u,e);}on(u,F){this.setSubscriber(u,{cb:F});}once(u,F){this.setSubscriber(u,{cb:F,once:true});}emit(u,...F){const e=this._subscribers.get(u)??[],s=[];for(const i of e)i.cb(...F),i.once&&s.push(()=>e.splice(e.indexOf(i),1));for(const i of s)i();}prompt(){return new Promise((u,F)=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),u(S);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close();},{once:true});}const e=new WriteStream(0);e._write=(s,i,D)=>{this._track&&(this.value=this.rl?.line.replace(/\t/g,""),this._cursor=this.rl?.cursor??0,this.emit("value",this.value)),D();},this.input.pipe(e),this.rl=f.createInterface({input:this.input,output:e,tabSize:2,prompt:"",escapeCodeTimeout:50}),f.emitKeypressEvents(this.input,this.rl),this.rl.prompt(),this.opts.initialValue!==void 0&&this._track&&this.rl.write(this.opts.initialValue),this.input.on("keypress",this.onKeypress),d$1(this.input,true),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(srcExports.cursor.show),this.output.off("resize",this.render),d$1(this.input,false),u(this.value);}),this.once("cancel",()=>{this.output.write(srcExports.cursor.show),this.output.off("resize",this.render),d$1(this.input,false),u(S);});})}onKeypress(u,F){if(this.state==="error"&&(this.state="active"),F?.name&&(!this._track&&c.aliases.has(F.name)&&this.emit("cursor",c.aliases.get(F.name)),c.actions.has(F.name)&&this.emit("cursor",F.name)),u&&(u.toLowerCase()==="y"||u.toLowerCase()==="n")&&this.emit("confirm",u.toLowerCase()==="y"),u===" "&&this.opts.placeholder&&(this.value||(this.rl?.write(this.opts.placeholder),this.emit("value",this.opts.placeholder))),u&&this.emit("key",u.toLowerCase()),F?.name==="return"){if(this.opts.validate){const e=this.opts.validate(this.value);e&&(this.error=e instanceof Error?e.message:e,this.state="error",this.rl?.write(this.value));}this.state!=="error"&&(this.state="submit");}k$1([u,F?.name,F?.sequence],"cancel")&&(this.state="cancel"),(this.state==="submit"||this.state==="cancel")&&this.emit("finalize"),this.render(),(this.state==="submit"||this.state==="cancel")&&this.close();}close(){this.input.unpipe(),this.input.removeListener("keypress",this.onKeypress),this.output.write(`
|
|
174
175
|
`),d$1(this.input,false),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe();}restoreCursor(){const u=G(this._prevFrame,process.stdout.columns,{hard:true}).split(`
|
|
175
176
|
`).length-1;this.output.write(srcExports.cursor.move(-999,u*-1));}render(){const u=G(this._render(this)??"",process.stdout.columns,{hard:true});if(u!==this._prevFrame){if(this.state==="initial")this.output.write(srcExports.cursor.hide);else {const F=lD(this._prevFrame,u);if(this.restoreCursor(),F&&F?.length===1){const e=F[0];this.output.write(srcExports.cursor.move(0,e)),this.output.write(srcExports.erase.lines(1));const s=u.split(`
|
|
176
177
|
`);this.output.write(s[e]),this._prevFrame=u,this.output.write(srcExports.cursor.move(0,s.length-e-1));return}if(F&&F?.length>1){const e=F[0];this.output.write(srcExports.cursor.move(0,e)),this.output.write(srcExports.erase.down());const s=u.split(`
|
|
@@ -0,0 +1,512 @@
|
|
|
1
|
+
const LogLevels = {
|
|
2
|
+
silent: Number.NEGATIVE_INFINITY,
|
|
3
|
+
fatal: 0,
|
|
4
|
+
error: 0,
|
|
5
|
+
warn: 1,
|
|
6
|
+
log: 2,
|
|
7
|
+
info: 3,
|
|
8
|
+
success: 3,
|
|
9
|
+
fail: 3,
|
|
10
|
+
ready: 3,
|
|
11
|
+
start: 3,
|
|
12
|
+
box: 3,
|
|
13
|
+
debug: 4,
|
|
14
|
+
trace: 5,
|
|
15
|
+
verbose: Number.POSITIVE_INFINITY
|
|
16
|
+
};
|
|
17
|
+
const LogTypes = {
|
|
18
|
+
// Silent
|
|
19
|
+
silent: {
|
|
20
|
+
level: -1
|
|
21
|
+
},
|
|
22
|
+
// Level 0
|
|
23
|
+
fatal: {
|
|
24
|
+
level: LogLevels.fatal
|
|
25
|
+
},
|
|
26
|
+
error: {
|
|
27
|
+
level: LogLevels.error
|
|
28
|
+
},
|
|
29
|
+
// Level 1
|
|
30
|
+
warn: {
|
|
31
|
+
level: LogLevels.warn
|
|
32
|
+
},
|
|
33
|
+
// Level 2
|
|
34
|
+
log: {
|
|
35
|
+
level: LogLevels.log
|
|
36
|
+
},
|
|
37
|
+
// Level 3
|
|
38
|
+
info: {
|
|
39
|
+
level: LogLevels.info
|
|
40
|
+
},
|
|
41
|
+
success: {
|
|
42
|
+
level: LogLevels.success
|
|
43
|
+
},
|
|
44
|
+
fail: {
|
|
45
|
+
level: LogLevels.fail
|
|
46
|
+
},
|
|
47
|
+
ready: {
|
|
48
|
+
level: LogLevels.info
|
|
49
|
+
},
|
|
50
|
+
start: {
|
|
51
|
+
level: LogLevels.info
|
|
52
|
+
},
|
|
53
|
+
box: {
|
|
54
|
+
level: LogLevels.info
|
|
55
|
+
},
|
|
56
|
+
// Level 4
|
|
57
|
+
debug: {
|
|
58
|
+
level: LogLevels.debug
|
|
59
|
+
},
|
|
60
|
+
// Level 5
|
|
61
|
+
trace: {
|
|
62
|
+
level: LogLevels.trace
|
|
63
|
+
},
|
|
64
|
+
// Verbose
|
|
65
|
+
verbose: {
|
|
66
|
+
level: LogLevels.verbose
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
function isPlainObject$1(value) {
|
|
71
|
+
if (value === null || typeof value !== "object") {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
const prototype = Object.getPrototypeOf(value);
|
|
75
|
+
if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) {
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
if (Symbol.iterator in value) {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
if (Symbol.toStringTag in value) {
|
|
82
|
+
return Object.prototype.toString.call(value) === "[object Module]";
|
|
83
|
+
}
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function _defu(baseObject, defaults, namespace = ".", merger) {
|
|
88
|
+
if (!isPlainObject$1(defaults)) {
|
|
89
|
+
return _defu(baseObject, {}, namespace, merger);
|
|
90
|
+
}
|
|
91
|
+
const object = Object.assign({}, defaults);
|
|
92
|
+
for (const key in baseObject) {
|
|
93
|
+
if (key === "__proto__" || key === "constructor") {
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
const value = baseObject[key];
|
|
97
|
+
if (value === null || value === void 0) {
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
if (merger && merger(object, key, value, namespace)) {
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
if (Array.isArray(value) && Array.isArray(object[key])) {
|
|
104
|
+
object[key] = [...value, ...object[key]];
|
|
105
|
+
} else if (isPlainObject$1(value) && isPlainObject$1(object[key])) {
|
|
106
|
+
object[key] = _defu(
|
|
107
|
+
value,
|
|
108
|
+
object[key],
|
|
109
|
+
(namespace ? `${namespace}.` : "") + key.toString(),
|
|
110
|
+
merger
|
|
111
|
+
);
|
|
112
|
+
} else {
|
|
113
|
+
object[key] = value;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return object;
|
|
117
|
+
}
|
|
118
|
+
function createDefu(merger) {
|
|
119
|
+
return (...arguments_) => (
|
|
120
|
+
// eslint-disable-next-line unicorn/no-array-reduce
|
|
121
|
+
arguments_.reduce((p, c) => _defu(p, c, "", merger), {})
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
const defu = createDefu();
|
|
125
|
+
|
|
126
|
+
function isPlainObject(obj) {
|
|
127
|
+
return Object.prototype.toString.call(obj) === "[object Object]";
|
|
128
|
+
}
|
|
129
|
+
function isLogObj(arg) {
|
|
130
|
+
if (!isPlainObject(arg)) {
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
if (!arg.message && !arg.args) {
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
if (arg.stack) {
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
return true;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
let paused = false;
|
|
143
|
+
const queue = [];
|
|
144
|
+
class Consola {
|
|
145
|
+
options;
|
|
146
|
+
_lastLog;
|
|
147
|
+
_mockFn;
|
|
148
|
+
/**
|
|
149
|
+
* Creates an instance of Consola with specified options or defaults.
|
|
150
|
+
*
|
|
151
|
+
* @param {Partial<ConsolaOptions>} [options={}] - Configuration options for the Consola instance.
|
|
152
|
+
*/
|
|
153
|
+
constructor(options = {}) {
|
|
154
|
+
const types = options.types || LogTypes;
|
|
155
|
+
this.options = defu(
|
|
156
|
+
{
|
|
157
|
+
...options,
|
|
158
|
+
defaults: { ...options.defaults },
|
|
159
|
+
level: _normalizeLogLevel(options.level, types),
|
|
160
|
+
reporters: [...options.reporters || []]
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
types: LogTypes,
|
|
164
|
+
throttle: 1e3,
|
|
165
|
+
throttleMin: 5,
|
|
166
|
+
formatOptions: {
|
|
167
|
+
date: true,
|
|
168
|
+
colors: false,
|
|
169
|
+
compact: true
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
);
|
|
173
|
+
for (const type in types) {
|
|
174
|
+
const defaults = {
|
|
175
|
+
type,
|
|
176
|
+
...this.options.defaults,
|
|
177
|
+
...types[type]
|
|
178
|
+
};
|
|
179
|
+
this[type] = this._wrapLogFn(defaults);
|
|
180
|
+
this[type].raw = this._wrapLogFn(
|
|
181
|
+
defaults,
|
|
182
|
+
true
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
if (this.options.mockFn) {
|
|
186
|
+
this.mockTypes();
|
|
187
|
+
}
|
|
188
|
+
this._lastLog = {};
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Gets the current log level of the Consola instance.
|
|
192
|
+
*
|
|
193
|
+
* @returns {number} The current log level.
|
|
194
|
+
*/
|
|
195
|
+
get level() {
|
|
196
|
+
return this.options.level;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Sets the minimum log level that will be output by the instance.
|
|
200
|
+
*
|
|
201
|
+
* @param {number} level - The new log level to set.
|
|
202
|
+
*/
|
|
203
|
+
set level(level) {
|
|
204
|
+
this.options.level = _normalizeLogLevel(
|
|
205
|
+
level,
|
|
206
|
+
this.options.types,
|
|
207
|
+
this.options.level
|
|
208
|
+
);
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Displays a prompt to the user and returns the response.
|
|
212
|
+
* Throw an error if `prompt` is not supported by the current configuration.
|
|
213
|
+
*
|
|
214
|
+
* @template T
|
|
215
|
+
* @param {string} message - The message to display in the prompt.
|
|
216
|
+
* @param {T} [opts] - Optional options for the prompt. See {@link PromptOptions}.
|
|
217
|
+
* @returns {promise<T>} A promise that infer with the prompt options. See {@link PromptOptions}.
|
|
218
|
+
*/
|
|
219
|
+
prompt(message, opts) {
|
|
220
|
+
if (!this.options.prompt) {
|
|
221
|
+
throw new Error("prompt is not supported!");
|
|
222
|
+
}
|
|
223
|
+
return this.options.prompt(message, opts);
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Creates a new instance of Consola, inheriting options from the current instance, with possible overrides.
|
|
227
|
+
*
|
|
228
|
+
* @param {Partial<ConsolaOptions>} options - Optional overrides for the new instance. See {@link ConsolaOptions}.
|
|
229
|
+
* @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.
|
|
230
|
+
*/
|
|
231
|
+
create(options) {
|
|
232
|
+
const instance = new Consola({
|
|
233
|
+
...this.options,
|
|
234
|
+
...options
|
|
235
|
+
});
|
|
236
|
+
if (this._mockFn) {
|
|
237
|
+
instance.mockTypes(this._mockFn);
|
|
238
|
+
}
|
|
239
|
+
return instance;
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Creates a new Consola instance with the specified default log object properties.
|
|
243
|
+
*
|
|
244
|
+
* @param {InputLogObject} defaults - Default properties to include in any log from the new instance. See {@link InputLogObject}.
|
|
245
|
+
* @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.
|
|
246
|
+
*/
|
|
247
|
+
withDefaults(defaults) {
|
|
248
|
+
return this.create({
|
|
249
|
+
...this.options,
|
|
250
|
+
defaults: {
|
|
251
|
+
...this.options.defaults,
|
|
252
|
+
...defaults
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Creates a new Consola instance with a specified tag, which will be included in every log.
|
|
258
|
+
*
|
|
259
|
+
* @param {string} tag - The tag to include in each log of the new instance.
|
|
260
|
+
* @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.
|
|
261
|
+
*/
|
|
262
|
+
withTag(tag) {
|
|
263
|
+
return this.withDefaults({
|
|
264
|
+
tag: this.options.defaults.tag ? this.options.defaults.tag + ":" + tag : tag
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Adds a custom reporter to the Consola instance.
|
|
269
|
+
* Reporters will be called for each log message, depending on their implementation and log level.
|
|
270
|
+
*
|
|
271
|
+
* @param {ConsolaReporter} reporter - The reporter to add. See {@link ConsolaReporter}.
|
|
272
|
+
* @returns {Consola} The current Consola instance.
|
|
273
|
+
*/
|
|
274
|
+
addReporter(reporter) {
|
|
275
|
+
this.options.reporters.push(reporter);
|
|
276
|
+
return this;
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Removes a custom reporter from the Consola instance.
|
|
280
|
+
* If no reporter is specified, all reporters will be removed.
|
|
281
|
+
*
|
|
282
|
+
* @param {ConsolaReporter} reporter - The reporter to remove. See {@link ConsolaReporter}.
|
|
283
|
+
* @returns {Consola} The current Consola instance.
|
|
284
|
+
*/
|
|
285
|
+
removeReporter(reporter) {
|
|
286
|
+
if (reporter) {
|
|
287
|
+
const i = this.options.reporters.indexOf(reporter);
|
|
288
|
+
if (i !== -1) {
|
|
289
|
+
return this.options.reporters.splice(i, 1);
|
|
290
|
+
}
|
|
291
|
+
} else {
|
|
292
|
+
this.options.reporters.splice(0);
|
|
293
|
+
}
|
|
294
|
+
return this;
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Replaces all reporters of the Consola instance with the specified array of reporters.
|
|
298
|
+
*
|
|
299
|
+
* @param {ConsolaReporter[]} reporters - The new reporters to set. See {@link ConsolaReporter}.
|
|
300
|
+
* @returns {Consola} The current Consola instance.
|
|
301
|
+
*/
|
|
302
|
+
setReporters(reporters) {
|
|
303
|
+
this.options.reporters = Array.isArray(reporters) ? reporters : [reporters];
|
|
304
|
+
return this;
|
|
305
|
+
}
|
|
306
|
+
wrapAll() {
|
|
307
|
+
this.wrapConsole();
|
|
308
|
+
this.wrapStd();
|
|
309
|
+
}
|
|
310
|
+
restoreAll() {
|
|
311
|
+
this.restoreConsole();
|
|
312
|
+
this.restoreStd();
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Overrides console methods with Consola logging methods for consistent logging.
|
|
316
|
+
*/
|
|
317
|
+
wrapConsole() {
|
|
318
|
+
for (const type in this.options.types) {
|
|
319
|
+
if (!console["__" + type]) {
|
|
320
|
+
console["__" + type] = console[type];
|
|
321
|
+
}
|
|
322
|
+
console[type] = this[type].raw;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* Restores the original console methods, removing Consola overrides.
|
|
327
|
+
*/
|
|
328
|
+
restoreConsole() {
|
|
329
|
+
for (const type in this.options.types) {
|
|
330
|
+
if (console["__" + type]) {
|
|
331
|
+
console[type] = console["__" + type];
|
|
332
|
+
delete console["__" + type];
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Overrides standard output and error streams to redirect them through Consola.
|
|
338
|
+
*/
|
|
339
|
+
wrapStd() {
|
|
340
|
+
this._wrapStream(this.options.stdout, "log");
|
|
341
|
+
this._wrapStream(this.options.stderr, "log");
|
|
342
|
+
}
|
|
343
|
+
_wrapStream(stream, type) {
|
|
344
|
+
if (!stream) {
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
if (!stream.__write) {
|
|
348
|
+
stream.__write = stream.write;
|
|
349
|
+
}
|
|
350
|
+
stream.write = (data) => {
|
|
351
|
+
this[type].raw(String(data).trim());
|
|
352
|
+
};
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Restores the original standard output and error streams, removing the Consola redirection.
|
|
356
|
+
*/
|
|
357
|
+
restoreStd() {
|
|
358
|
+
this._restoreStream(this.options.stdout);
|
|
359
|
+
this._restoreStream(this.options.stderr);
|
|
360
|
+
}
|
|
361
|
+
_restoreStream(stream) {
|
|
362
|
+
if (!stream) {
|
|
363
|
+
return;
|
|
364
|
+
}
|
|
365
|
+
if (stream.__write) {
|
|
366
|
+
stream.write = stream.__write;
|
|
367
|
+
delete stream.__write;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* Pauses logging, queues incoming logs until resumed.
|
|
372
|
+
*/
|
|
373
|
+
pauseLogs() {
|
|
374
|
+
paused = true;
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Resumes logging, processing any queued logs.
|
|
378
|
+
*/
|
|
379
|
+
resumeLogs() {
|
|
380
|
+
paused = false;
|
|
381
|
+
const _queue = queue.splice(0);
|
|
382
|
+
for (const item of _queue) {
|
|
383
|
+
item[0]._logFn(item[1], item[2]);
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* Replaces logging methods with mocks if a mock function is provided.
|
|
388
|
+
*
|
|
389
|
+
* @param {ConsolaOptions["mockFn"]} mockFn - The function to use for mocking logging methods. See {@link ConsolaOptions["mockFn"]}.
|
|
390
|
+
*/
|
|
391
|
+
mockTypes(mockFn) {
|
|
392
|
+
const _mockFn = mockFn || this.options.mockFn;
|
|
393
|
+
this._mockFn = _mockFn;
|
|
394
|
+
if (typeof _mockFn !== "function") {
|
|
395
|
+
return;
|
|
396
|
+
}
|
|
397
|
+
for (const type in this.options.types) {
|
|
398
|
+
this[type] = _mockFn(type, this.options.types[type]) || this[type];
|
|
399
|
+
this[type].raw = this[type];
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
_wrapLogFn(defaults, isRaw) {
|
|
403
|
+
return (...args) => {
|
|
404
|
+
if (paused) {
|
|
405
|
+
queue.push([this, defaults, args, isRaw]);
|
|
406
|
+
return;
|
|
407
|
+
}
|
|
408
|
+
return this._logFn(defaults, args, isRaw);
|
|
409
|
+
};
|
|
410
|
+
}
|
|
411
|
+
_logFn(defaults, args, isRaw) {
|
|
412
|
+
if ((defaults.level || 0) > this.level) {
|
|
413
|
+
return false;
|
|
414
|
+
}
|
|
415
|
+
const logObj = {
|
|
416
|
+
date: /* @__PURE__ */ new Date(),
|
|
417
|
+
args: [],
|
|
418
|
+
...defaults,
|
|
419
|
+
level: _normalizeLogLevel(defaults.level, this.options.types)
|
|
420
|
+
};
|
|
421
|
+
if (!isRaw && args.length === 1 && isLogObj(args[0])) {
|
|
422
|
+
Object.assign(logObj, args[0]);
|
|
423
|
+
} else {
|
|
424
|
+
logObj.args = [...args];
|
|
425
|
+
}
|
|
426
|
+
if (logObj.message) {
|
|
427
|
+
logObj.args.unshift(logObj.message);
|
|
428
|
+
delete logObj.message;
|
|
429
|
+
}
|
|
430
|
+
if (logObj.additional) {
|
|
431
|
+
if (!Array.isArray(logObj.additional)) {
|
|
432
|
+
logObj.additional = logObj.additional.split("\n");
|
|
433
|
+
}
|
|
434
|
+
logObj.args.push("\n" + logObj.additional.join("\n"));
|
|
435
|
+
delete logObj.additional;
|
|
436
|
+
}
|
|
437
|
+
logObj.type = typeof logObj.type === "string" ? logObj.type.toLowerCase() : "log";
|
|
438
|
+
logObj.tag = typeof logObj.tag === "string" ? logObj.tag : "";
|
|
439
|
+
const resolveLog = (newLog = false) => {
|
|
440
|
+
const repeated = (this._lastLog.count || 0) - this.options.throttleMin;
|
|
441
|
+
if (this._lastLog.object && repeated > 0) {
|
|
442
|
+
const args2 = [...this._lastLog.object.args];
|
|
443
|
+
if (repeated > 1) {
|
|
444
|
+
args2.push(`(repeated ${repeated} times)`);
|
|
445
|
+
}
|
|
446
|
+
this._log({ ...this._lastLog.object, args: args2 });
|
|
447
|
+
this._lastLog.count = 1;
|
|
448
|
+
}
|
|
449
|
+
if (newLog) {
|
|
450
|
+
this._lastLog.object = logObj;
|
|
451
|
+
this._log(logObj);
|
|
452
|
+
}
|
|
453
|
+
};
|
|
454
|
+
clearTimeout(this._lastLog.timeout);
|
|
455
|
+
const diffTime = this._lastLog.time && logObj.date ? logObj.date.getTime() - this._lastLog.time.getTime() : 0;
|
|
456
|
+
this._lastLog.time = logObj.date;
|
|
457
|
+
if (diffTime < this.options.throttle) {
|
|
458
|
+
try {
|
|
459
|
+
const serializedLog = JSON.stringify([
|
|
460
|
+
logObj.type,
|
|
461
|
+
logObj.tag,
|
|
462
|
+
logObj.args
|
|
463
|
+
]);
|
|
464
|
+
const isSameLog = this._lastLog.serialized === serializedLog;
|
|
465
|
+
this._lastLog.serialized = serializedLog;
|
|
466
|
+
if (isSameLog) {
|
|
467
|
+
this._lastLog.count = (this._lastLog.count || 0) + 1;
|
|
468
|
+
if (this._lastLog.count > this.options.throttleMin) {
|
|
469
|
+
this._lastLog.timeout = setTimeout(
|
|
470
|
+
resolveLog,
|
|
471
|
+
this.options.throttle
|
|
472
|
+
);
|
|
473
|
+
return;
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
} catch {
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
resolveLog(true);
|
|
480
|
+
}
|
|
481
|
+
_log(logObj) {
|
|
482
|
+
for (const reporter of this.options.reporters) {
|
|
483
|
+
reporter.log(logObj, {
|
|
484
|
+
options: this.options
|
|
485
|
+
});
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
function _normalizeLogLevel(input, types = {}, defaultLevel = 3) {
|
|
490
|
+
if (input === void 0) {
|
|
491
|
+
return defaultLevel;
|
|
492
|
+
}
|
|
493
|
+
if (typeof input === "number") {
|
|
494
|
+
return input;
|
|
495
|
+
}
|
|
496
|
+
if (types[input] && types[input].level !== void 0) {
|
|
497
|
+
return types[input].level;
|
|
498
|
+
}
|
|
499
|
+
return defaultLevel;
|
|
500
|
+
}
|
|
501
|
+
Consola.prototype.add = Consola.prototype.addReporter;
|
|
502
|
+
Consola.prototype.remove = Consola.prototype.removeReporter;
|
|
503
|
+
Consola.prototype.clear = Consola.prototype.removeReporter;
|
|
504
|
+
Consola.prototype.withScope = Consola.prototype.withTag;
|
|
505
|
+
Consola.prototype.mock = Consola.prototype.mockTypes;
|
|
506
|
+
Consola.prototype.pause = Consola.prototype.pauseLogs;
|
|
507
|
+
Consola.prototype.resume = Consola.prototype.resumeLogs;
|
|
508
|
+
function createConsola(options = {}) {
|
|
509
|
+
return new Consola(options);
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
export { Consola, LogLevels, LogTypes, createConsola };
|