@nuxt/ui 3.0.0-alpha.7 → 3.0.0-alpha.8
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/.nuxt/ui/accordion.ts +20 -0
- package/.nuxt/ui/alert.ts +242 -0
- package/.nuxt/ui/avatar-group.ts +40 -0
- package/.nuxt/ui/avatar.ts +42 -0
- package/.nuxt/ui/badge.ts +194 -0
- package/.nuxt/ui/breadcrumb.ts +45 -0
- package/.nuxt/ui/button-group.ts +16 -0
- package/.nuxt/ui/button.ts +344 -0
- package/.nuxt/ui/card.ts +8 -0
- package/.nuxt/ui/carousel.ts +41 -0
- package/.nuxt/ui/checkbox.ts +105 -0
- package/.nuxt/ui/chip.ts +67 -0
- package/.nuxt/ui/collapsible.ts +6 -0
- package/.nuxt/ui/command-palette.ts +40 -0
- package/.nuxt/ui/container.ts +3 -0
- package/.nuxt/ui/context-menu.ts +198 -0
- package/.nuxt/ui/drawer.ts +55 -0
- package/.nuxt/ui/dropdown-menu.ts +199 -0
- package/.nuxt/ui/form-field.ts +40 -0
- package/.nuxt/ui/form.ts +3 -0
- package/.nuxt/ui/index.ts +43 -0
- package/.nuxt/ui/input-menu.ts +411 -0
- package/.nuxt/ui/input.ts +263 -0
- package/.nuxt/ui/kbd.ts +19 -0
- package/.nuxt/ui/link.ts +15 -0
- package/.nuxt/ui/modal.ts +28 -0
- package/.nuxt/ui/navigation-menu.ts +390 -0
- package/.nuxt/ui/pagination.ts +8 -0
- package/.nuxt/ui/popover.ts +6 -0
- package/.nuxt/ui/progress.ts +258 -0
- package/.nuxt/ui/radio-group.ts +112 -0
- package/.nuxt/ui/select-menu.ts +321 -0
- package/.nuxt/ui/select.ts +314 -0
- package/.nuxt/ui/separator.ts +143 -0
- package/.nuxt/ui/skeleton.ts +3 -0
- package/.nuxt/ui/slideover.ts +63 -0
- package/.nuxt/ui/slider.ts +148 -0
- package/.nuxt/ui/switch.ts +113 -0
- package/.nuxt/ui/table.ts +128 -0
- package/.nuxt/ui/tabs.ts +227 -0
- package/.nuxt/ui/textarea.ts +263 -0
- package/.nuxt/ui/toast.ts +66 -0
- package/.nuxt/ui/toaster.ts +75 -0
- package/.nuxt/ui/tooltip.ts +9 -0
- package/cli/templates.mjs +1 -1
- package/dist/chunks/component-meta.cjs +73264 -0
- package/dist/chunks/component-meta.mjs +73262 -0
- package/dist/client/devtools/200.html +1 -0
- package/dist/client/devtools/404.html +1 -0
- package/dist/client/devtools/_fonts/rP2Wp2ywxg089UriCZaSExd86J3t9jz86MvyyKK58UfivUw4aw-SK92LTmKP0.woff2 +0 -0
- package/dist/client/devtools/_fonts/rP2Wp2ywxg089UriCZaSExd86J3t9jz86MvyyKy58UfivUw-9uYm8d48E4.woff2 +0 -0
- package/dist/client/devtools/_fonts/rP2Yp2ywxg089UriI5-g4vlH9VoD8Cmcqbu0-K6z9mXg-VNw7NHvqnp.woff2 +0 -0
- package/dist/client/devtools/_fonts/rP2Yp2ywxg089UriI5-g4vlH9VoD8Cmcqbu6-K6z9mXgjU0-EkYdMs3MAX.woff2 +0 -0
- package/dist/client/devtools/_fonts/rP2rp2ywxg089UriCZaSExd86J3t9jz86Mvy4qCRAL19DksVat-7DW3w-R7n06NbhGy.woff +0 -0
- package/dist/client/devtools/_fonts/rP2rp2ywxg089UriCZaSExd86J3t9jz86Mvy4qCRAL19DksVat-JDG3w-leGNfkTmsj.woff +0 -0
- package/dist/client/devtools/_fonts/rP2rp2ywxg089UriCZaSExd86J3t9jz86Mvy4qCRAL19DksVat-JDW3w-ciElMF03ku.woff +0 -0
- package/dist/client/devtools/_fonts/rP2rp2ywxg089UriCZaSExd86J3t9jz86Mvy4qCRAL19DksVat8JCm3w-sB722Uoa0f.woff +0 -0
- package/dist/client/devtools/_fonts/rP2rp2ywxg089UriCZaSExd86J3t9jz86Mvy4qCRAL19DksVat8JDW3w-PBDI1JDjwV.woff +0 -0
- package/dist/client/devtools/_fonts/rP2rp2ywxg089UriCZaSExd86J3t9jz86Mvy4qCRAL19DksVat8gCm3w-0q1hqVn09O.woff +0 -0
- package/dist/client/devtools/_fonts/rP2rp2ywxg089UriCZaSExd86J3t9jz86Mvy4qCRAL19DksVat9XCm3w-ByvzuLy2fa.woff +0 -0
- package/dist/client/devtools/_fonts/rP2rp2ywxg089UriCZaSExd86J3t9jz86Mvy4qCRAL19DksVat9uCm3w-5TKCIs6EEw.woff +0 -0
- package/dist/client/devtools/_fonts/rP2rp2ywxg089UriCZaSExd86J3t9jz86Mvy4qCRAL19DksVat_XDW3w-r2swRDGfn2.woff +0 -0
- package/dist/client/devtools/_fonts/rP2tp2ywxg089UriI5-g4vlH9VoD8CmcqZG40F9JadbnoEwAC5thTQ-ldB60l5U8r.woff +0 -0
- package/dist/client/devtools/_fonts/rP2tp2ywxg089UriI5-g4vlH9VoD8CmcqZG40F9JadbnoEwAIpthTQ-wbFKGFDrgo.woff +0 -0
- package/dist/client/devtools/_fonts/rP2tp2ywxg089UriI5-g4vlH9VoD8CmcqZG40F9JadbnoEwAIpxhTQ-LLUBv5jskj.woff +0 -0
- package/dist/client/devtools/_fonts/rP2tp2ywxg089UriI5-g4vlH9VoD8CmcqZG40F9JadbnoEwARZthTQ-F71RdTRbNg.woff +0 -0
- package/dist/client/devtools/_fonts/rP2tp2ywxg089UriI5-g4vlH9VoD8CmcqZG40F9JadbnoEwA_JxhTQ-6nh65gZkc0.woff +0 -0
- package/dist/client/devtools/_fonts/rP2tp2ywxg089UriI5-g4vlH9VoD8CmcqZG40F9JadbnoEwAfJthTQ-aMoWEJLmTt.woff +0 -0
- package/dist/client/devtools/_fonts/rP2tp2ywxg089UriI5-g4vlH9VoD8CmcqZG40F9JadbnoEwAkJxhTQ-WMBvmLOgKm.woff +0 -0
- package/dist/client/devtools/_fonts/rP2tp2ywxg089UriI5-g4vlH9VoD8CmcqZG40F9JadbnoEwAop1hTQ-utGC2hnWq2.woff +0 -0
- package/dist/client/devtools/_fonts/rP2tp2ywxg089UriI5-g4vlH9VoD8CmcqZG40F9JadbnoEwAopxhTQ-YpyTieVa5B.woff +0 -0
- package/dist/client/devtools/_nuxt/Bj9hdafK.js +1 -0
- package/dist/client/devtools/_nuxt/DM3_wAgz.js +62 -0
- package/dist/client/devtools/_nuxt/builds/latest.json +1 -0
- package/dist/client/devtools/_nuxt/builds/meta/e6b425f7-b919-4014-915b-0ea07c316790.json +1 -0
- package/dist/client/devtools/_nuxt/entry.DaJP-ZMB.css +24 -0
- package/dist/client/devtools/_nuxt/error-404.B0Nmv3fV.css +1 -0
- package/dist/client/devtools/_nuxt/error-500.C8fgTxVz.css +1 -0
- package/dist/client/devtools/_nuxt/hKiujHsR.js +1 -0
- package/dist/client/devtools/favicon.svg +1 -0
- package/dist/client/devtools/index.html +1 -0
- package/dist/devtools/runtime/DevtoolsRenderer.vue +53 -0
- package/dist/devtools/runtime/examples/AvatarGroupExample.vue +7 -0
- package/dist/devtools/runtime/examples/ButtonGroupExample.vue +8 -0
- package/dist/devtools/runtime/examples/CardExample.vue +13 -0
- package/dist/devtools/runtime/examples/CarouselExample.vue +13 -0
- package/dist/devtools/runtime/examples/ChipExample.vue +5 -0
- package/dist/devtools/runtime/examples/CollapsibleExample.vue +8 -0
- package/dist/devtools/runtime/examples/CommandPaletteExample.vue +29 -0
- package/dist/devtools/runtime/examples/ContainerExample.vue +5 -0
- package/dist/devtools/runtime/examples/ContextMenuExample.vue +5 -0
- package/dist/devtools/runtime/examples/DrawerExample.vue +8 -0
- package/dist/devtools/runtime/examples/DropdownMenuExample.vue +5 -0
- package/dist/devtools/runtime/examples/FormExample.vue +30 -0
- package/dist/devtools/runtime/examples/FormFieldExample.vue +5 -0
- package/dist/devtools/runtime/examples/LinkExample.vue +5 -0
- package/dist/devtools/runtime/examples/ModalExample.vue +8 -0
- package/dist/devtools/runtime/examples/PopoverExample.vue +8 -0
- package/dist/devtools/runtime/examples/SkeletonExample.vue +3 -0
- package/dist/devtools/runtime/examples/SlideoverExample.vue +8 -0
- package/dist/devtools/runtime/examples/ToasterExample.vue +11 -0
- package/dist/devtools/runtime/examples/TooltipExample.vue +5 -0
- package/dist/module.cjs +222 -4
- package/dist/module.d.cts +54 -0
- package/dist/module.d.mts +10 -0
- package/dist/module.d.ts +10 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +157 -2763
- package/dist/runtime/components/Accordion.vue +32 -1
- package/dist/runtime/components/Alert.vue +4 -0
- package/dist/runtime/components/App.vue +8 -0
- package/dist/runtime/components/Avatar.vue +23 -5
- package/dist/runtime/components/AvatarGroup.vue +3 -0
- package/dist/runtime/components/Badge.vue +33 -3
- package/dist/runtime/components/Breadcrumb.vue +25 -1
- package/dist/runtime/components/Button.vue +6 -1
- package/dist/runtime/components/ButtonGroup.vue +4 -1
- package/dist/runtime/components/Card.vue +3 -0
- package/dist/runtime/components/Carousel.vue +7 -2
- package/dist/runtime/components/Checkbox.vue +4 -0
- package/dist/runtime/components/Chip.vue +9 -2
- package/dist/runtime/components/Collapsible.vue +3 -0
- package/dist/runtime/components/CommandPalette.vue +3 -1
- package/dist/runtime/components/Container.vue +3 -0
- package/dist/runtime/components/ContextMenu.vue +64 -3
- package/dist/runtime/components/ContextMenuContent.vue +8 -8
- package/dist/runtime/components/Drawer.vue +3 -0
- package/dist/runtime/components/DropdownMenu.vue +52 -3
- package/dist/runtime/components/DropdownMenuContent.vue +8 -8
- package/dist/runtime/components/Form.vue +3 -0
- package/dist/runtime/components/FormField.vue +3 -0
- package/dist/runtime/components/Input.vue +1 -0
- package/dist/runtime/components/InputMenu.vue +23 -12
- package/dist/runtime/components/Kbd.vue +2 -0
- package/dist/runtime/components/Link.vue +50 -1
- package/dist/runtime/components/Modal.vue +3 -0
- package/dist/runtime/components/NavigationMenu.vue +91 -44
- package/dist/runtime/components/Pagination.vue +5 -1
- package/dist/runtime/components/Popover.vue +3 -0
- package/dist/runtime/components/Progress.vue +1 -1
- package/dist/runtime/components/RadioGroup.vue +4 -1
- package/dist/runtime/components/Select.vue +24 -13
- package/dist/runtime/components/SelectMenu.vue +29 -17
- package/dist/runtime/components/Separator.vue +1 -1
- package/dist/runtime/components/Skeleton.vue +3 -0
- package/dist/runtime/components/Slideover.vue +3 -0
- package/dist/runtime/components/Slider.vue +1 -1
- package/dist/runtime/components/Switch.vue +5 -1
- package/dist/runtime/components/Table.vue +16 -7
- package/dist/runtime/components/Tabs.vue +20 -1
- package/dist/runtime/components/Toast.vue +4 -0
- package/dist/runtime/components/Toaster.vue +7 -0
- package/dist/runtime/components/Tooltip.vue +3 -0
- package/dist/runtime/composables/defineShortcuts.js +0 -6
- package/dist/runtime/composables/extendDevtoolsMeta.d.ts +7 -0
- package/dist/runtime/composables/extendDevtoolsMeta.js +2 -0
- package/dist/runtime/composables/useKbd.d.ts +10 -3
- package/dist/runtime/composables/useKbd.js +14 -8
- package/dist/runtime/types/utils.d.ts +7 -0
- package/dist/runtime/utils/index.js +1 -1
- package/dist/runtime/utils/link.d.ts +1 -1
- package/dist/runtime/vue/components/Icon.vue +15 -0
- package/dist/runtime/vue/components/Link.vue +195 -0
- package/dist/runtime/vue/plugins/color-mode.d.ts +4 -0
- package/dist/runtime/vue/plugins/color-mode.js +6 -0
- package/dist/runtime/vue/plugins/head.d.ts +4 -0
- package/dist/runtime/vue/plugins/head.js +6 -0
- package/dist/runtime/vue/stubs.d.ts +15 -0
- package/dist/runtime/vue/stubs.js +27 -0
- package/dist/shared/ui.BU7wzH0D.cjs +2872 -0
- package/dist/shared/ui.BufKhDiD.mjs +2865 -0
- package/dist/unplugin.cjs +192 -0
- package/dist/unplugin.d.cts +47 -0
- package/dist/unplugin.d.mts +47 -0
- package/dist/unplugin.d.ts +47 -0
- package/dist/unplugin.mjs +181 -0
- package/dist/vite.cjs +22 -0
- package/dist/vite.d.cts +13 -0
- package/dist/vite.d.mts +13 -0
- package/dist/vite.d.ts +13 -0
- package/dist/vite.mjs +20 -0
- package/package.json +68 -30
- package/vue-plugin.d.ts +5 -0
- package/cli/node_modules/.ignored/citty/LICENSE +0 -36
- package/cli/node_modules/.ignored/citty/README.md +0 -134
- package/cli/node_modules/.ignored/citty/dist/index.cjs +0 -475
- package/cli/node_modules/.ignored/citty/dist/index.d.cts +0 -80
- package/cli/node_modules/.ignored/citty/dist/index.d.mts +0 -80
- package/cli/node_modules/.ignored/citty/dist/index.d.ts +0 -80
- package/cli/node_modules/.ignored/citty/dist/index.mjs +0 -463
- package/cli/node_modules/.ignored/citty/package.json +0 -49
- package/cli/node_modules/.ignored/consola/LICENSE +0 -47
- package/cli/node_modules/.ignored/consola/README.md +0 -318
- package/cli/node_modules/.ignored/consola/core.d.ts +0 -1
- package/cli/node_modules/.ignored/consola/dist/basic.cjs +0 -32
- package/cli/node_modules/.ignored/consola/dist/basic.d.ts +0 -9
- package/cli/node_modules/.ignored/consola/dist/basic.mjs +0 -24
- package/cli/node_modules/.ignored/consola/dist/browser.cjs +0 -80
- package/cli/node_modules/.ignored/consola/dist/browser.d.ts +0 -7
- package/cli/node_modules/.ignored/consola/dist/browser.mjs +0 -72
- package/cli/node_modules/.ignored/consola/dist/chunks/prompt.cjs +0 -436
- package/cli/node_modules/.ignored/consola/dist/chunks/prompt.mjs +0 -429
- package/cli/node_modules/.ignored/consola/dist/core.cjs +0 -415
- package/cli/node_modules/.ignored/consola/dist/core.d.ts +0 -124
- package/cli/node_modules/.ignored/consola/dist/core.mjs +0 -410
- package/cli/node_modules/.ignored/consola/dist/index.cjs +0 -21
- package/cli/node_modules/.ignored/consola/dist/index.d.ts +0 -9
- package/cli/node_modules/.ignored/consola/dist/index.mjs +0 -8
- package/cli/node_modules/.ignored/consola/dist/shared/consola.06ad8a64.mjs +0 -62
- package/cli/node_modules/.ignored/consola/dist/shared/consola.36c0034f.mjs +0 -636
- package/cli/node_modules/.ignored/consola/dist/shared/consola.4bbae468.cjs +0 -645
- package/cli/node_modules/.ignored/consola/dist/shared/consola.deac7d5a.cjs +0 -65
- package/cli/node_modules/.ignored/consola/dist/utils.cjs +0 -308
- package/cli/node_modules/.ignored/consola/dist/utils.d.ts +0 -169
- package/cli/node_modules/.ignored/consola/dist/utils.mjs +0 -284
- package/cli/node_modules/.ignored/consola/lib/index.cjs +0 -9
- package/cli/node_modules/.ignored/consola/package.json +0 -101
- package/cli/node_modules/.ignored/consola/utils.d.ts +0 -1
- package/cli/node_modules/.ignored/pathe/LICENSE +0 -44
- package/cli/node_modules/.ignored/pathe/README.md +0 -69
- package/cli/node_modules/.ignored/pathe/dist/index.cjs +0 -23
- package/cli/node_modules/.ignored/pathe/dist/index.d.cts +0 -36
- package/cli/node_modules/.ignored/pathe/dist/index.d.mts +0 -36
- package/cli/node_modules/.ignored/pathe/dist/index.d.ts +0 -36
- package/cli/node_modules/.ignored/pathe/dist/index.mjs +0 -1
- package/cli/node_modules/.ignored/pathe/dist/shared/pathe.1f0a373c.cjs +0 -238
- package/cli/node_modules/.ignored/pathe/dist/shared/pathe.ff20891b.mjs +0 -221
- package/cli/node_modules/.ignored/pathe/dist/utils.cjs +0 -58
- package/cli/node_modules/.ignored/pathe/dist/utils.d.cts +0 -5
- package/cli/node_modules/.ignored/pathe/dist/utils.d.mts +0 -5
- package/cli/node_modules/.ignored/pathe/dist/utils.d.ts +0 -5
- package/cli/node_modules/.ignored/pathe/dist/utils.mjs +0 -54
- package/cli/node_modules/.ignored/pathe/package.json +0 -48
- package/cli/node_modules/.ignored/pathe/utils.d.ts +0 -1
- package/cli/node_modules/.ignored/scule/LICENSE +0 -21
- package/cli/node_modules/.ignored/scule/README.md +0 -149
- package/cli/node_modules/.ignored/scule/dist/index.cjs +0 -92
- package/cli/node_modules/.ignored/scule/dist/index.d.cts +0 -57
- package/cli/node_modules/.ignored/scule/dist/index.d.mts +0 -57
- package/cli/node_modules/.ignored/scule/dist/index.d.ts +0 -57
- package/cli/node_modules/.ignored/scule/dist/index.mjs +0 -80
- package/cli/node_modules/.ignored/scule/package.json +0 -43
- package/cli/node_modules/.package-lock.json +0 -33
|
@@ -1,318 +0,0 @@
|
|
|
1
|
-
# 🐨 Consola
|
|
2
|
-
|
|
3
|
-
> Elegant Console Wrapper
|
|
4
|
-
|
|
5
|
-
[![npm version][npm-version-src]][npm-version-href]
|
|
6
|
-
[![npm downloads][npm-downloads-src]][npm-downloads-href]
|
|
7
|
-
[![bundle][bundle-src]][bundle-href]
|
|
8
|
-
|
|
9
|
-
<!-- [![Codecov][codecov-src]][codecov-href] -->
|
|
10
|
-
|
|
11
|
-
## Why Consola?
|
|
12
|
-
|
|
13
|
-
👌 Easy to use<br>
|
|
14
|
-
💅 Fancy output with fallback for minimal environments<br>
|
|
15
|
-
🔌 Pluggable reporters<br>
|
|
16
|
-
💻 Consistent command line interface (CLI) experience<br>
|
|
17
|
-
🏷 Tag support<br>
|
|
18
|
-
🚏 Redirect `console` and `stdout/stderr` to consola and easily restore redirect.<br>
|
|
19
|
-
🌐 Browser support<br>
|
|
20
|
-
⏯ Pause/Resume support<br>
|
|
21
|
-
👻 Mocking support<br>
|
|
22
|
-
👮♂️ Spam prevention by throttling logs<br>
|
|
23
|
-
❯ Interactive prompt support powered by [`clack`](https://github.com/natemoo-re/clack)<br>
|
|
24
|
-
|
|
25
|
-
## Installation
|
|
26
|
-
|
|
27
|
-
Using npm:
|
|
28
|
-
|
|
29
|
-
```bash
|
|
30
|
-
npm i consola
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
Using yarn:
|
|
34
|
-
|
|
35
|
-
```bash
|
|
36
|
-
yarn add consola
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
Using pnpm:
|
|
40
|
-
|
|
41
|
-
```bash
|
|
42
|
-
pnpm i consola
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
## Getting Started
|
|
46
|
-
|
|
47
|
-
```js
|
|
48
|
-
// ESM
|
|
49
|
-
import { consola, createConsola } from "consola";
|
|
50
|
-
|
|
51
|
-
// CommonJS
|
|
52
|
-
const { consola, createConsola } = require("consola");
|
|
53
|
-
|
|
54
|
-
consola.info("Using consola 3.0.0");
|
|
55
|
-
consola.start("Building project...");
|
|
56
|
-
consola.warn("A new version of consola is available: 3.0.1");
|
|
57
|
-
consola.success("Project built!");
|
|
58
|
-
consola.error(new Error("This is an example error. Everything is fine!"));
|
|
59
|
-
consola.box("I am a simple box");
|
|
60
|
-
await consola.prompt("Deploy to the production?", {
|
|
61
|
-
type: "confirm",
|
|
62
|
-
});
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
Will display in the terminal:
|
|
66
|
-
|
|
67
|
-
<img width="760" alt="image" src="https://user-images.githubusercontent.com/5158436/231029244-abc79f48-ca16-4eaa-b592-7abd271ecb1f.png">
|
|
68
|
-
|
|
69
|
-
You can use smaller core builds without fancy reporter to save 80% of the bundle size:
|
|
70
|
-
|
|
71
|
-
```ts
|
|
72
|
-
import { consola, createConsola } from "consola/basic";
|
|
73
|
-
import { consola, createConsola } from "consola/browser";
|
|
74
|
-
import { createConsola } from "consola/core";
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
## Consola Methods
|
|
78
|
-
|
|
79
|
-
#### `<type>(logObject)` `<type>(args...)`
|
|
80
|
-
|
|
81
|
-
Log to all reporters.
|
|
82
|
-
|
|
83
|
-
Example: `consola.info('Message')`
|
|
84
|
-
|
|
85
|
-
#### `await prompt(message, { type })`
|
|
86
|
-
|
|
87
|
-
Show an input prompt. Type can either of `text`, `confirm`, `select` or `multiselect`.
|
|
88
|
-
|
|
89
|
-
See [examples/prompt.ts](./examples/prompt.ts) for usage examples.
|
|
90
|
-
|
|
91
|
-
#### `addReporter(reporter)`
|
|
92
|
-
|
|
93
|
-
- Aliases: `add`
|
|
94
|
-
|
|
95
|
-
Register a custom reporter instance.
|
|
96
|
-
|
|
97
|
-
#### `removeReporter(reporter?)`
|
|
98
|
-
|
|
99
|
-
- Aliases: `remove`, `clear`
|
|
100
|
-
|
|
101
|
-
Remove a registered reporter.
|
|
102
|
-
|
|
103
|
-
If no arguments are passed all reporters will be removed.
|
|
104
|
-
|
|
105
|
-
#### `setReporters(reporter|reporter[])`
|
|
106
|
-
|
|
107
|
-
Replace all reporters.
|
|
108
|
-
|
|
109
|
-
#### `create(options)`
|
|
110
|
-
|
|
111
|
-
Create a new `Consola` instance and inherit all parent options for defaults.
|
|
112
|
-
|
|
113
|
-
#### `withDefaults(defaults)`
|
|
114
|
-
|
|
115
|
-
Create a new `Consola` instance with provided defaults
|
|
116
|
-
|
|
117
|
-
#### `withTag(tag)`
|
|
118
|
-
|
|
119
|
-
- Aliases: `withScope`
|
|
120
|
-
|
|
121
|
-
Create a new `Consola` instance with that tag.
|
|
122
|
-
|
|
123
|
-
#### `wrapConsole()` `restoreConsole()`
|
|
124
|
-
|
|
125
|
-
Globally redirect all `console.log`, etc calls to consola handlers.
|
|
126
|
-
|
|
127
|
-
#### `wrapStd()` `restoreStd()`
|
|
128
|
-
|
|
129
|
-
Globally redirect all stdout/stderr outputs to consola.
|
|
130
|
-
|
|
131
|
-
#### `wrapAll()` `restoreAll()`
|
|
132
|
-
|
|
133
|
-
Wrap both, std and console.
|
|
134
|
-
|
|
135
|
-
console uses std in the underlying so calling `wrapStd` redirects console too.
|
|
136
|
-
Benefit of this function is that things like `console.info` will be correctly redirected to the corresponding type.
|
|
137
|
-
|
|
138
|
-
#### `pauseLogs()` `resumeLogs()`
|
|
139
|
-
|
|
140
|
-
- Aliases: `pause`/`resume`
|
|
141
|
-
|
|
142
|
-
**Globally** pause and resume logs.
|
|
143
|
-
|
|
144
|
-
Consola will enqueue all logs when paused and then sends them to the reported when resumed.
|
|
145
|
-
|
|
146
|
-
#### `mockTypes`
|
|
147
|
-
|
|
148
|
-
- Aliases: `mock`
|
|
149
|
-
|
|
150
|
-
Mock all types. Useful for using with tests.
|
|
151
|
-
|
|
152
|
-
The first argument passed to `mockTypes` should be a callback function accepting `(typeName, type)` and returning the mocked value:
|
|
153
|
-
|
|
154
|
-
```js
|
|
155
|
-
consola.mockTypes((typeName, type) => jest.fn());
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
Please note that with the example above, everything is mocked independently for each type. If you need one mocked fn create it outside:
|
|
159
|
-
|
|
160
|
-
```js
|
|
161
|
-
const fn = jest.fn();
|
|
162
|
-
consola.mockTypes(() => fn);
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
If callback function returns a _falsy_ value, that type won't be mocked.
|
|
166
|
-
|
|
167
|
-
For example if you just need to mock `consola.fatal`:
|
|
168
|
-
|
|
169
|
-
```js
|
|
170
|
-
consola.mockTypes((typeName) => typeName === "fatal" && jest.fn());
|
|
171
|
-
```
|
|
172
|
-
|
|
173
|
-
**NOTE:** Any instance of consola that inherits the mocked instance, will apply provided callback again.
|
|
174
|
-
This way, mocking works for `withTag` scoped loggers without need to extra efforts.
|
|
175
|
-
|
|
176
|
-
## Custom Reporters
|
|
177
|
-
|
|
178
|
-
Consola ships with 3 built-in reporters out of the box. A fancy colored reporter by default and fallsback to a basic reporter if running in a testing or CI environment detected using [unjs/std-env](https://github.com/unjs/std-env) and a basic browser reporter.
|
|
179
|
-
|
|
180
|
-
You can create a new reporter object that implements `{ log(logObject): () => { } }` interface.
|
|
181
|
-
|
|
182
|
-
**Example:** Simple JSON reporter
|
|
183
|
-
|
|
184
|
-
```ts
|
|
185
|
-
import { createConsola } from "consola";
|
|
186
|
-
|
|
187
|
-
const consola = createConsola({
|
|
188
|
-
reporters: [
|
|
189
|
-
{
|
|
190
|
-
log: (logObj) => {
|
|
191
|
-
console.log(JSON.stringify(logObj));
|
|
192
|
-
},
|
|
193
|
-
},
|
|
194
|
-
],
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
// Prints {"date":"2023-04-18T12:43:38.693Z","args":["foo bar"],"type":"log","level":2,"tag":""}
|
|
198
|
-
consola.log("foo bar");
|
|
199
|
-
```
|
|
200
|
-
|
|
201
|
-
## Log Level
|
|
202
|
-
|
|
203
|
-
Consola only shows logs with configured log level or below. (Default is `3`)
|
|
204
|
-
|
|
205
|
-
Available log levels:
|
|
206
|
-
|
|
207
|
-
- `0`: Fatal and Error
|
|
208
|
-
- `1`: Warnings
|
|
209
|
-
- `2`: Normal logs
|
|
210
|
-
- `3`: Informational logs, success, fail, ready, start, ...
|
|
211
|
-
- `4`: Debug logs
|
|
212
|
-
- `5`: Trace logs
|
|
213
|
-
- `-999`: Silent
|
|
214
|
-
- `+999`: Verbose logs
|
|
215
|
-
|
|
216
|
-
You can set the log level by either:
|
|
217
|
-
|
|
218
|
-
- Passing `level` option to `createConsola`
|
|
219
|
-
- Setting `consola.level` on instance
|
|
220
|
-
- Using the `CONSOLA_LEVEL` environment variable (not supported for browser and core builds).
|
|
221
|
-
|
|
222
|
-
## Log Types
|
|
223
|
-
|
|
224
|
-
Log types are exposed as `consola.[type](...)` and each is a preset of styles and log level.
|
|
225
|
-
|
|
226
|
-
A list of all available built-in types is [available here](./src/constants.ts).
|
|
227
|
-
|
|
228
|
-
## Creating a new instance
|
|
229
|
-
|
|
230
|
-
Consola has a global instance and is recommended to use everywhere.
|
|
231
|
-
In case more control is needed, create a new instance.
|
|
232
|
-
|
|
233
|
-
```js
|
|
234
|
-
import { createConsola } from "consola";
|
|
235
|
-
|
|
236
|
-
const logger = createConsola({
|
|
237
|
-
// level: 4,
|
|
238
|
-
// fancy: true | false
|
|
239
|
-
// formatOptions: {
|
|
240
|
-
// columns: 80,
|
|
241
|
-
// colors: false,
|
|
242
|
-
// compact: false,
|
|
243
|
-
// date: false,
|
|
244
|
-
// },
|
|
245
|
-
});
|
|
246
|
-
```
|
|
247
|
-
|
|
248
|
-
## Integrations
|
|
249
|
-
|
|
250
|
-
### With jest or vitest
|
|
251
|
-
|
|
252
|
-
```js
|
|
253
|
-
describe("your-consola-mock-test", () => {
|
|
254
|
-
beforeAll(() => {
|
|
255
|
-
// Redirect std and console to consola too
|
|
256
|
-
// Calling this once is sufficient
|
|
257
|
-
consola.wrapAll();
|
|
258
|
-
});
|
|
259
|
-
|
|
260
|
-
beforeEach(() => {
|
|
261
|
-
// Re-mock consola before each test call to remove
|
|
262
|
-
// calls from before
|
|
263
|
-
consola.mockTypes(() => jest.fn());
|
|
264
|
-
});
|
|
265
|
-
|
|
266
|
-
test("your test", async () => {
|
|
267
|
-
// Some code here
|
|
268
|
-
|
|
269
|
-
// Let's retrieve all messages of `consola.log`
|
|
270
|
-
// Get the mock and map all calls to their first argument
|
|
271
|
-
const consolaMessages = consola.log.mock.calls.map((c) => c[0]);
|
|
272
|
-
expect(consolaMessages).toContain("your message");
|
|
273
|
-
});
|
|
274
|
-
});
|
|
275
|
-
```
|
|
276
|
-
|
|
277
|
-
### With jsdom
|
|
278
|
-
|
|
279
|
-
```js
|
|
280
|
-
{
|
|
281
|
-
virtualConsole: new jsdom.VirtualConsole().sendTo(consola);
|
|
282
|
-
}
|
|
283
|
-
```
|
|
284
|
-
|
|
285
|
-
## Console Utils
|
|
286
|
-
|
|
287
|
-
```ts
|
|
288
|
-
// ESM
|
|
289
|
-
import {
|
|
290
|
-
stripAnsi,
|
|
291
|
-
centerAlign,
|
|
292
|
-
rightAlign,
|
|
293
|
-
leftAlign,
|
|
294
|
-
align,
|
|
295
|
-
box,
|
|
296
|
-
colors,
|
|
297
|
-
getColor,
|
|
298
|
-
colorize,
|
|
299
|
-
} from "consola/utils";
|
|
300
|
-
|
|
301
|
-
// CommonJS
|
|
302
|
-
const { stripAnsi } = require("consola/utils");
|
|
303
|
-
```
|
|
304
|
-
|
|
305
|
-
## License
|
|
306
|
-
|
|
307
|
-
MIT
|
|
308
|
-
|
|
309
|
-
<!-- Badges -->
|
|
310
|
-
|
|
311
|
-
[npm-version-src]: https://img.shields.io/npm/v/consola?style=flat&colorA=18181B&colorB=F0DB4F
|
|
312
|
-
[npm-version-href]: https://npmjs.com/package/consola
|
|
313
|
-
[npm-downloads-src]: https://img.shields.io/npm/dm/consola?style=flat&colorA=18181B&colorB=F0DB4F
|
|
314
|
-
[npm-downloads-href]: https://npmjs.com/package/consola
|
|
315
|
-
[codecov-src]: https://img.shields.io/codecov/c/gh/unjs/consola/main?style=flat&colorA=18181B&colorB=F0DB4F
|
|
316
|
-
[codecov-href]: https://codecov.io/gh/unjs/consola
|
|
317
|
-
[bundle-src]: https://img.shields.io/bundlephobia/min/consola?style=flat&colorA=18181B&colorB=F0DB4F
|
|
318
|
-
[bundle-href]: https://bundlephobia.com/result?p=consola
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./dist/core";
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
const core = require('./core.cjs');
|
|
6
|
-
const basic = require('./shared/consola.deac7d5a.cjs');
|
|
7
|
-
require('node:util');
|
|
8
|
-
require('node:path');
|
|
9
|
-
|
|
10
|
-
function createConsola(options = {}) {
|
|
11
|
-
let level = core.LogLevels.info;
|
|
12
|
-
if (process.env.CONSOLA_LEVEL) {
|
|
13
|
-
level = Number.parseInt(process.env.CONSOLA_LEVEL) ?? level;
|
|
14
|
-
}
|
|
15
|
-
const consola2 = core.createConsola({
|
|
16
|
-
level,
|
|
17
|
-
defaults: { level },
|
|
18
|
-
stdout: process.stdout,
|
|
19
|
-
stderr: process.stderr,
|
|
20
|
-
reporters: options.reporters || [new basic.BasicReporter()],
|
|
21
|
-
...options
|
|
22
|
-
});
|
|
23
|
-
return consola2;
|
|
24
|
-
}
|
|
25
|
-
const consola = createConsola();
|
|
26
|
-
|
|
27
|
-
exports.Consola = core.Consola;
|
|
28
|
-
exports.LogLevels = core.LogLevels;
|
|
29
|
-
exports.LogTypes = core.LogTypes;
|
|
30
|
-
exports.consola = consola;
|
|
31
|
-
exports.createConsola = createConsola;
|
|
32
|
-
exports.default = consola;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { ConsolaOptions, ConsolaInstance } from './core.js';
|
|
2
|
-
export { Consola, ConsolaReporter, FormatOptions, InputLogObject, LogLevel, LogLevels, LogObject, LogType, LogTypes } from './core.js';
|
|
3
|
-
|
|
4
|
-
declare function createConsola(options?: Partial<ConsolaOptions & {
|
|
5
|
-
fancy: boolean;
|
|
6
|
-
}>): ConsolaInstance;
|
|
7
|
-
declare const consola: ConsolaInstance;
|
|
8
|
-
|
|
9
|
-
export { ConsolaInstance, ConsolaOptions, consola, createConsola, consola as default };
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { LogLevels, createConsola as createConsola$1 } from './core.mjs';
|
|
2
|
-
export { Consola, LogTypes } from './core.mjs';
|
|
3
|
-
import { B as BasicReporter } from './shared/consola.06ad8a64.mjs';
|
|
4
|
-
import 'node:util';
|
|
5
|
-
import 'node:path';
|
|
6
|
-
|
|
7
|
-
function createConsola(options = {}) {
|
|
8
|
-
let level = LogLevels.info;
|
|
9
|
-
if (process.env.CONSOLA_LEVEL) {
|
|
10
|
-
level = Number.parseInt(process.env.CONSOLA_LEVEL) ?? level;
|
|
11
|
-
}
|
|
12
|
-
const consola2 = createConsola$1({
|
|
13
|
-
level,
|
|
14
|
-
defaults: { level },
|
|
15
|
-
stdout: process.stdout,
|
|
16
|
-
stderr: process.stderr,
|
|
17
|
-
reporters: options.reporters || [new BasicReporter()],
|
|
18
|
-
...options
|
|
19
|
-
});
|
|
20
|
-
return consola2;
|
|
21
|
-
}
|
|
22
|
-
const consola = createConsola();
|
|
23
|
-
|
|
24
|
-
export { LogLevels, consola, createConsola, consola as default };
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
const core = require('./core.cjs');
|
|
6
|
-
|
|
7
|
-
class BrowserReporter {
|
|
8
|
-
constructor(options) {
|
|
9
|
-
this.options = { ...options };
|
|
10
|
-
this.defaultColor = "#7f8c8d";
|
|
11
|
-
this.levelColorMap = {
|
|
12
|
-
0: "#c0392b",
|
|
13
|
-
// Red
|
|
14
|
-
1: "#f39c12",
|
|
15
|
-
// Yellow
|
|
16
|
-
3: "#00BCD4"
|
|
17
|
-
// Cyan
|
|
18
|
-
};
|
|
19
|
-
this.typeColorMap = {
|
|
20
|
-
success: "#2ecc71"
|
|
21
|
-
// Green
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
_getLogFn(level) {
|
|
25
|
-
if (level < 1) {
|
|
26
|
-
return console.__error || console.error;
|
|
27
|
-
}
|
|
28
|
-
if (level === 1) {
|
|
29
|
-
return console.__warn || console.warn;
|
|
30
|
-
}
|
|
31
|
-
return console.__log || console.log;
|
|
32
|
-
}
|
|
33
|
-
log(logObj) {
|
|
34
|
-
const consoleLogFn = this._getLogFn(logObj.level);
|
|
35
|
-
const type = logObj.type === "log" ? "" : logObj.type;
|
|
36
|
-
const tag = logObj.tag || "";
|
|
37
|
-
const color = this.typeColorMap[logObj.type] || this.levelColorMap[logObj.level] || this.defaultColor;
|
|
38
|
-
const style = `
|
|
39
|
-
background: ${color};
|
|
40
|
-
border-radius: 0.5em;
|
|
41
|
-
color: white;
|
|
42
|
-
font-weight: bold;
|
|
43
|
-
padding: 2px 0.5em;
|
|
44
|
-
`;
|
|
45
|
-
const badge = `%c${[tag, type].filter(Boolean).join(":")}`;
|
|
46
|
-
if (typeof logObj.args[0] === "string") {
|
|
47
|
-
consoleLogFn(
|
|
48
|
-
`${badge}%c ${logObj.args[0]}`,
|
|
49
|
-
style,
|
|
50
|
-
// Empty string as style resets to default console style
|
|
51
|
-
"",
|
|
52
|
-
...logObj.args.slice(1)
|
|
53
|
-
);
|
|
54
|
-
} else {
|
|
55
|
-
consoleLogFn(badge, style, ...logObj.args);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function createConsola(options = {}) {
|
|
61
|
-
const consola2 = core.createConsola({
|
|
62
|
-
reporters: options.reporters || [new BrowserReporter({})],
|
|
63
|
-
prompt(message, options2 = {}) {
|
|
64
|
-
if (options2.type === "confirm") {
|
|
65
|
-
return Promise.resolve(confirm(message));
|
|
66
|
-
}
|
|
67
|
-
return Promise.resolve(prompt(message));
|
|
68
|
-
},
|
|
69
|
-
...options
|
|
70
|
-
});
|
|
71
|
-
return consola2;
|
|
72
|
-
}
|
|
73
|
-
const consola = createConsola();
|
|
74
|
-
|
|
75
|
-
exports.Consola = core.Consola;
|
|
76
|
-
exports.LogLevels = core.LogLevels;
|
|
77
|
-
exports.LogTypes = core.LogTypes;
|
|
78
|
-
exports.consola = consola;
|
|
79
|
-
exports.createConsola = createConsola;
|
|
80
|
-
exports.default = consola;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { ConsolaOptions, ConsolaInstance } from './core.js';
|
|
2
|
-
export { Consola, ConsolaReporter, FormatOptions, InputLogObject, LogLevel, LogLevels, LogObject, LogType, LogTypes } from './core.js';
|
|
3
|
-
|
|
4
|
-
declare function createConsola(options?: Partial<ConsolaOptions>): ConsolaInstance;
|
|
5
|
-
declare const consola: ConsolaInstance;
|
|
6
|
-
|
|
7
|
-
export { ConsolaInstance, ConsolaOptions, consola, createConsola, consola as default };
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { createConsola as createConsola$1 } from './core.mjs';
|
|
2
|
-
export { Consola, LogLevels, LogTypes } from './core.mjs';
|
|
3
|
-
|
|
4
|
-
class BrowserReporter {
|
|
5
|
-
constructor(options) {
|
|
6
|
-
this.options = { ...options };
|
|
7
|
-
this.defaultColor = "#7f8c8d";
|
|
8
|
-
this.levelColorMap = {
|
|
9
|
-
0: "#c0392b",
|
|
10
|
-
// Red
|
|
11
|
-
1: "#f39c12",
|
|
12
|
-
// Yellow
|
|
13
|
-
3: "#00BCD4"
|
|
14
|
-
// Cyan
|
|
15
|
-
};
|
|
16
|
-
this.typeColorMap = {
|
|
17
|
-
success: "#2ecc71"
|
|
18
|
-
// Green
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
_getLogFn(level) {
|
|
22
|
-
if (level < 1) {
|
|
23
|
-
return console.__error || console.error;
|
|
24
|
-
}
|
|
25
|
-
if (level === 1) {
|
|
26
|
-
return console.__warn || console.warn;
|
|
27
|
-
}
|
|
28
|
-
return console.__log || console.log;
|
|
29
|
-
}
|
|
30
|
-
log(logObj) {
|
|
31
|
-
const consoleLogFn = this._getLogFn(logObj.level);
|
|
32
|
-
const type = logObj.type === "log" ? "" : logObj.type;
|
|
33
|
-
const tag = logObj.tag || "";
|
|
34
|
-
const color = this.typeColorMap[logObj.type] || this.levelColorMap[logObj.level] || this.defaultColor;
|
|
35
|
-
const style = `
|
|
36
|
-
background: ${color};
|
|
37
|
-
border-radius: 0.5em;
|
|
38
|
-
color: white;
|
|
39
|
-
font-weight: bold;
|
|
40
|
-
padding: 2px 0.5em;
|
|
41
|
-
`;
|
|
42
|
-
const badge = `%c${[tag, type].filter(Boolean).join(":")}`;
|
|
43
|
-
if (typeof logObj.args[0] === "string") {
|
|
44
|
-
consoleLogFn(
|
|
45
|
-
`${badge}%c ${logObj.args[0]}`,
|
|
46
|
-
style,
|
|
47
|
-
// Empty string as style resets to default console style
|
|
48
|
-
"",
|
|
49
|
-
...logObj.args.slice(1)
|
|
50
|
-
);
|
|
51
|
-
} else {
|
|
52
|
-
consoleLogFn(badge, style, ...logObj.args);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function createConsola(options = {}) {
|
|
58
|
-
const consola2 = createConsola$1({
|
|
59
|
-
reporters: options.reporters || [new BrowserReporter({})],
|
|
60
|
-
prompt(message, options2 = {}) {
|
|
61
|
-
if (options2.type === "confirm") {
|
|
62
|
-
return Promise.resolve(confirm(message));
|
|
63
|
-
}
|
|
64
|
-
return Promise.resolve(prompt(message));
|
|
65
|
-
},
|
|
66
|
-
...options
|
|
67
|
-
});
|
|
68
|
-
return consola2;
|
|
69
|
-
}
|
|
70
|
-
const consola = createConsola();
|
|
71
|
-
|
|
72
|
-
export { consola, createConsola, consola as default };
|