@kawapress/plugin-shiki 0.0.1 → 0.1.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/README.md CHANGED
@@ -16,7 +16,7 @@
16
16
  </p>
17
17
 
18
18
  <p align="center">
19
- <a href="https://www.npmjs.com/package/kawapress"><img src="https://img.shields.io/npm/v/kawapress/beta?label=npm%20beta&color=42b883" alt="npm beta version"></a>
19
+ <a href="https://www.npmjs.com/package/kawapress"><img src="https://img.shields.io/npm/v/kawapress?label=npm&color=42b883" alt="npm version"></a>
20
20
  <a href="https://github.com/ShenQingchuan/kawapress/actions/workflows/deploy-pages.yml"><img src="https://github.com/ShenQingchuan/kawapress/actions/workflows/deploy-pages.yml/badge.svg" alt="documentation build"></a>
21
21
  <a href="https://github.com/ShenQingchuan/kawapress/blob/main/LICENSE"><img src="https://img.shields.io/github/license/ShenQingchuan/kawapress" alt="MIT license"></a>
22
22
  <img src="https://img.shields.io/badge/Node.js-%E2%89%A522.12-339933?logo=nodedotjs&logoColor=white" alt="Node.js 22.12 or newer">
@@ -28,8 +28,7 @@
28
28
  <a href="https://github.com/ShenQingchuan/kawapress/blob/main/README.zh-CN.md">简体中文</a>
29
29
  </p>
30
30
 
31
- > [!IMPORTANT]
32
- > KawaPress is in beta. It is ready for testing and early projects, but APIs may change before 0.1.0. Please pin the version when adopting it today.
31
+ If you run into any problems while using KawaPress, please [open an issue](https://github.com/ShenQingchuan/kawapress/issues). Your feedback helps shape the project during its early development.
33
32
 
34
33
  ## Why KawaPress?
35
34
 
@@ -47,6 +46,18 @@ KawaPress is an independent project. It is not a VitePress fork or a drop-in rep
47
46
 
48
47
  You need [Node.js](https://nodejs.org/) 22.12 or newer.
49
48
 
49
+ Create a new site with the scaffolder:
50
+
51
+ ```sh
52
+ npm create kawapress@latest my-kawapress-site
53
+ cd my-kawapress-site
54
+ npm run dev
55
+ ```
56
+
57
+ `pnpm create kawapress my-kawapress-site` and `yarn create kawapress my-kawapress-site` do the same thing. The scaffolder asks for a site title and a default language, and can install dependencies for you.
58
+
59
+ If you would rather see every file from the start, set the site up by hand:
60
+
50
61
  ```sh
51
62
  mkdir my-kawapress-site
52
63
  cd my-kawapress-site
package/README.zh-CN.md CHANGED
@@ -16,7 +16,7 @@
16
16
  </p>
17
17
 
18
18
  <p align="center">
19
- <a href="https://www.npmjs.com/package/kawapress"><img src="https://img.shields.io/npm/v/kawapress/beta?label=npm%20beta&color=42b883" alt="npm beta 版本"></a>
19
+ <a href="https://www.npmjs.com/package/kawapress"><img src="https://img.shields.io/npm/v/kawapress?label=npm&color=42b883" alt="npm 版本"></a>
20
20
  <a href="https://github.com/ShenQingchuan/kawapress/actions/workflows/deploy-pages.yml"><img src="https://github.com/ShenQingchuan/kawapress/actions/workflows/deploy-pages.yml/badge.svg" alt="文档构建状态"></a>
21
21
  <a href="https://github.com/ShenQingchuan/kawapress/blob/main/LICENSE"><img src="https://img.shields.io/github/license/ShenQingchuan/kawapress" alt="MIT 许可"></a>
22
22
  <img src="https://img.shields.io/badge/Node.js-%E2%89%A522.12-339933?logo=nodedotjs&logoColor=white" alt="Node.js 22.12 或更高版本">
@@ -28,8 +28,7 @@
28
28
  <a href="https://github.com/ShenQingchuan/kawapress/blob/main/README.md">English</a>
29
29
  </p>
30
30
 
31
- > [!IMPORTANT]
32
- > KawaPress 目前处于 beta 阶段,适合试用和早期项目。0.1.0 之前,公开 API 仍可能调整;现阶段使用时请固定具体版本。
31
+ 使用 KawaPress 时遇到任何问题,欢迎到 [提交 Issue](https://github.com/ShenQingchuan/kawapress/issues) 反馈,一起参与本项目的早期建设。
33
32
 
34
33
  ## 为什么选择 KawaPress?
35
34
 
@@ -47,6 +46,18 @@ KawaPress 是一个独立项目,不是 VitePress 的分支或配置兼容层
47
46
 
48
47
  请先准备 [Node.js](https://nodejs.org/) 22.12 或更高版本。
49
48
 
49
+ 用脚手架创建新站点:
50
+
51
+ ```sh
52
+ npm create kawapress@latest my-kawapress-site
53
+ cd my-kawapress-site
54
+ npm run dev
55
+ ```
56
+
57
+ `pnpm create kawapress my-kawapress-site` 和 `yarn create kawapress my-kawapress-site` 的作用完全一样。脚手架会询问站点标题和默认语言,也可以顺便帮你安装依赖。
58
+
59
+ 如果你更想从零看清每个文件,可以手动创建:
60
+
50
61
  ```sh
51
62
  mkdir my-kawapress-site
52
63
  cd my-kawapress-site
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kawapress/plugin-shiki",
3
3
  "type": "module",
4
- "version": "0.0.1",
4
+ "version": "0.1.0",
5
5
  "description": "Shiki and Twoslash plugin for KawaPress",
6
6
  "license": "MIT",
7
7
  "homepage": "https://shenqingchuan.github.io/kawapress/",
@@ -24,6 +24,11 @@
24
24
  "import": "./src/runtime-plugin.ts",
25
25
  "default": "./src/runtime-plugin.ts"
26
26
  },
27
+ "./twoslash-menu": {
28
+ "types": "./src/twoslash-menu.ts",
29
+ "import": "./src/twoslash-menu.ts",
30
+ "default": "./src/twoslash-menu.ts"
31
+ },
27
32
  "./package.json": "./package.json"
28
33
  },
29
34
  "files": [
@@ -38,7 +43,7 @@
38
43
  },
39
44
  "peerDependencies": {
40
45
  "vue": "^3.5.41",
41
- "kawapress": "0.0.1"
46
+ "kawapress": "0.1.0"
42
47
  },
43
48
  "dependencies": {
44
49
  "@shikijs/transformers": "^4.4.3",
package/src/index.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  import type {
2
2
  TransformerTwoslashOptions,
3
3
  } from '@shikijs/twoslash'
4
- import type { KawaPressPlugin } from 'kawapress'
4
+ import type { KawaPressPlugin, PageComponentEnv } from 'kawapress'
5
5
  import type { ShikiTransformer } from 'shiki'
6
+ import { createRequire } from 'node:module'
6
7
  import {
7
8
  transformerMetaHighlight,
8
9
  transformerNotationDiff,
@@ -11,10 +12,11 @@ import {
11
12
  transformerNotationHighlight,
12
13
  } from '@shikijs/transformers'
13
14
  import { createTransformerFactory } from '@shikijs/twoslash'
14
- import { definePlugin } from 'kawapress'
15
+ import { addPageComponent, definePlugin } from 'kawapress'
16
+ import { useRuntimeDependencies } from 'kawapress/generator'
15
17
  import { createHighlighter } from 'shiki'
16
18
  import { createTwoslasher } from 'twoslash-vue'
17
- import { rendererFloatingVue } from './renderer-floating-vue'
19
+ import { rendererFloatingVue, TWOSLASH_MENU_TAG } from './renderer-floating-vue'
18
20
 
19
21
  export type TwoslashOptions = Omit<
20
22
  TransformerTwoslashOptions,
@@ -37,8 +39,13 @@ export type ShikiPluginOptions = ShikiPluginBaseOptions & (
37
39
  | { theme?: never, themes: ShikiThemePair }
38
40
  )
39
41
 
42
+ const require = createRequire(import.meta.url)
43
+
44
+ const PLUGIN_NAME = '@kawapress/plugin-shiki'
40
45
  const V_PRE_TRANSFORMER_NAME = 'kawapress:v-pre'
41
46
  const RUNTIME_DEPENDENCIES = ['floating-vue']
47
+ const TWOSLASH_MENU_COMPONENT = 'KawaTwoslashMenu'
48
+ const TWOSLASH_MENU_MODULE = resolveTwoslashMenuModule()
42
49
  const TWOSLASH_LANGS = ['ts', 'tsx', 'js', 'jsx', 'json', 'vue']
43
50
  const PRELOADED_LANGS = [
44
51
  'bash',
@@ -62,32 +69,21 @@ export function shikiPlugin(options: ShikiPluginOptions = {}): KawaPressPlugin {
62
69
  const transformers = createTransformers(options)
63
70
 
64
71
  return definePlugin({
65
- name: '@kawapress/plugin-shiki',
72
+ name: PLUGIN_NAME,
66
73
  setup(api) {
67
74
  api.markdown(async (markdown) => {
68
75
  const highlighter = await createHighlighter({
69
76
  themes: themes ? Object.values(themes) : [theme],
70
77
  langs: options.langs ?? PRELOADED_LANGS,
71
78
  })
72
- markdown.options.highlight = (str, lang, attrs) =>
73
- highlightCode(highlighter, str, lang, attrs, {
79
+ markdown.options.highlight = (str, lang, attrs, env) =>
80
+ highlightCode(highlighter, str, lang, attrs, env, {
74
81
  theme,
75
82
  themes,
76
83
  }, transformers)
77
84
  })
78
85
  api.vite((config) => {
79
- const noExternal = config.ssr?.noExternal
80
- if (noExternal === true) {
81
- return
82
- }
83
-
84
- config.ssr ??= {}
85
- config.ssr.noExternal = [
86
- ...(Array.isArray(noExternal)
87
- ? noExternal
88
- : noExternal ? [noExternal] : []),
89
- ...RUNTIME_DEPENDENCIES,
90
- ]
86
+ useRuntimeDependencies(config, PLUGIN_NAME, RUNTIME_DEPENDENCIES)
91
87
  })
92
88
  },
93
89
  })
@@ -97,6 +93,23 @@ export default shikiPlugin
97
93
 
98
94
  type Highlighter = Awaited<ReturnType<typeof createHighlighter>>
99
95
 
96
+ /**
97
+ * Absolute path of the module that default-exports the Twoslash menu.
98
+ *
99
+ * The page SFC imports it, and a page cannot resolve a package that only the
100
+ * preset depends on, so the export map is resolved from this package instead of
101
+ * relying on the package manager layout of the site.
102
+ */
103
+ function resolveTwoslashMenuModule(): string {
104
+ const specifier = '@kawapress/plugin-shiki/twoslash-menu'
105
+ try {
106
+ return require.resolve(specifier)
107
+ }
108
+ catch {
109
+ return specifier
110
+ }
111
+ }
112
+
100
113
  function createTransformers(
101
114
  options: ShikiPluginOptions,
102
115
  ): ShikiTransformer[] {
@@ -213,6 +226,7 @@ function highlightCode(
213
226
  str: string,
214
227
  lang: string,
215
228
  attrs: string,
229
+ env: PageComponentEnv,
216
230
  themeOptions: {
217
231
  theme: string
218
232
  themes?: ShikiThemePair
@@ -228,8 +242,7 @@ function highlightCode(
228
242
  }
229
243
 
230
244
  const code = str.replace(/\r?\n$/, '')
231
-
232
- return themeOptions.themes
245
+ const html = themeOptions.themes
233
246
  ? highlighter.codeToHtml(code, {
234
247
  ...commonOptions,
235
248
  themes: themeOptions.themes,
@@ -239,4 +252,21 @@ function highlightCode(
239
252
  ...commonOptions,
240
253
  theme: themeOptions.theme,
241
254
  })
255
+
256
+ declareTwoslashMenu(env, html)
257
+ return html
258
+ }
259
+
260
+ /**
261
+ * A page only imports the menu component when a code block really rendered one,
262
+ * so pages without Twoslash never download floating-vue.
263
+ */
264
+ function declareTwoslashMenu(env: PageComponentEnv, html: string): void {
265
+ if (!html.includes(`<${TWOSLASH_MENU_TAG}`)) {
266
+ return
267
+ }
268
+ addPageComponent(env, {
269
+ name: TWOSLASH_MENU_COMPONENT,
270
+ from: TWOSLASH_MENU_MODULE,
271
+ })
242
272
  }
@@ -17,7 +17,8 @@ type RenderMarkdownInline = NonNullable<RendererRichOptions['renderMarkdownInlin
17
17
 
18
18
  const JSDOC_LINK_RE = /\{@link ([^}]*)\}/g
19
19
  const PARAM_NAME_RE = /^([\w$-]+)/
20
- const TWOSLASH_MENU_TAG = 'kawa-twoslash-menu'
20
+ /** Tag of the popup component in the page template. */
21
+ export const TWOSLASH_MENU_TAG = 'kawa-twoslash-menu'
21
22
 
22
23
  const composePopup: PopupCompose = ({ popup, token }) => [
23
24
  {
@@ -1,41 +1,15 @@
1
- import FloatingVue from 'floating-vue'
2
1
  import { defineRuntimePlugin } from 'kawapress'
3
- import TwoslashMenu from './TwoslashMenu.vue'
4
- import '@shikijs/twoslash/style-rich.css'
5
- import 'floating-vue/dist/style.css'
2
+ import './vendor.css'
3
+ import './shiki.css'
6
4
  import './twoslash.css'
7
5
 
6
+ /**
7
+ * The Twoslash popups render through `KawaTwoslashMenu`, which the Markdown
8
+ * plugin imports into the pages that contain a Twoslash code block. That
9
+ * component brings its own floating-vue dependency, so this runtime plugin only
10
+ * contributes the styles both sides need from the first paint.
11
+ */
8
12
  export default defineRuntimePlugin({
9
13
  name: '@kawapress/plugin-shiki',
10
- setup(api) {
11
- api.vueApp((app) => {
12
- app.use(FloatingVue, {
13
- strategy: 'fixed',
14
- themes: {
15
- 'twoslash': {
16
- $extend: 'dropdown',
17
- triggers: ['hover', 'touch'],
18
- popperTriggers: ['hover', 'touch'],
19
- placement: 'bottom-start',
20
- delay: { show: 0, hide: 100 },
21
- autoHide: true,
22
- instantMove: true,
23
- flip: false,
24
- },
25
- 'twoslash-query': {
26
- $extend: 'twoslash',
27
- triggers: ['click'],
28
- popperTriggers: ['click'],
29
- autoHide: false,
30
- },
31
- 'twoslash-completion': {
32
- $extend: 'twoslash-query',
33
- distance: 0,
34
- arrowOverflow: false,
35
- },
36
- },
37
- })
38
- app.component('KawaTwoslashMenu', TwoslashMenu)
39
- })
40
- },
14
+ setup() {},
41
15
  })
package/src/shiki.css ADDED
@@ -0,0 +1,19 @@
1
+ @layer kawa.plugin {
2
+ /*
3
+ * Shiki emits `<pre class="shiki"><code>…`. A theme that never heard of Shiki
4
+ * still needs the block to scroll instead of overflowing the page, and the
5
+ * line wrappers to span the full width.
6
+ */
7
+ pre.shiki {
8
+ overflow-x: auto;
9
+ tab-size: 4;
10
+ }
11
+
12
+ pre.shiki > code {
13
+ display: block;
14
+ width: fit-content;
15
+ min-width: 100%;
16
+ font-size: 0.875em;
17
+ line-height: 1.5;
18
+ }
19
+ }
@@ -0,0 +1,36 @@
1
+ import { options } from 'floating-vue'
2
+ import TwoslashMenu from './TwoslashMenu.vue'
3
+
4
+ /**
5
+ * floating-vue keeps its themes in one module-level config that `app.use()`
6
+ * normally fills in. KawaPress no longer installs floating-vue on the Vue app,
7
+ * because the Twoslash popups are the only consumer, so the menu applies the
8
+ * same config itself when this module loads. That happens per page that has a
9
+ * Twoslash code block, before any menu renders.
10
+ */
11
+ options.strategy = 'fixed'
12
+ Object.assign(options.themes, {
13
+ 'twoslash': {
14
+ $extend: 'dropdown',
15
+ triggers: ['hover', 'touch'],
16
+ popperTriggers: ['hover', 'touch'],
17
+ placement: 'bottom-start',
18
+ delay: { show: 0, hide: 100 },
19
+ autoHide: true,
20
+ instantMove: true,
21
+ flip: false,
22
+ },
23
+ 'twoslash-query': {
24
+ $extend: 'twoslash',
25
+ triggers: ['click'],
26
+ popperTriggers: ['click'],
27
+ autoHide: false,
28
+ },
29
+ 'twoslash-completion': {
30
+ $extend: 'twoslash-query',
31
+ distance: 0,
32
+ arrowOverflow: false,
33
+ },
34
+ })
35
+
36
+ export default TwoslashMenu
package/src/twoslash.css CHANGED
@@ -1,117 +1,158 @@
1
- .twoslash .v-popper {
2
- display: inline-block;
3
- vertical-align: baseline;
4
- }
5
-
6
- .twoslash .twoslash-hover {
7
- margin-block: -2px;
8
- padding-block: 2px;
9
- border-color: var(--twoslash-underline-color);
10
- }
11
-
12
- .twoslash .twoslash-error-line {
13
- box-sizing: border-box;
14
- width: 100%;
15
- min-width: 0;
16
- overflow-wrap: anywhere;
17
- white-space: pre-wrap;
18
- }
19
-
20
- .v-popper--theme-twoslash {
21
- z-index: 19;
22
- }
23
-
24
- .v-popper--theme-twoslash .v-popper__inner {
25
- overflow: hidden;
26
- color: var(--twoslash-popup-color);
27
- background: var(--twoslash-popup-bg);
28
- border: 1px solid var(--twoslash-border-color);
29
- border-radius: var(--twoslash-popup-radius, 8px);
30
- box-shadow: var(--twoslash-popup-shadow);
31
- }
32
-
33
- .v-popper--theme-twoslash .v-popper__arrow-outer {
34
- border-color: var(--twoslash-border-color);
35
- }
36
-
37
- .v-popper--theme-twoslash .v-popper__arrow-inner {
38
- border-color: var(--twoslash-popup-bg);
39
- }
40
-
41
- .twoslash-floating .twoslash-popup-arrow {
42
- display: none;
43
- }
44
-
45
- .twoslash-floating .twoslash-popup-code {
46
- display: block;
47
- box-sizing: border-box;
48
- width: max-content;
49
- min-width: 100%;
50
- max-width: min(700px, calc(100vw - 32px));
51
- padding: var(--twoslash-popup-code-padding, 8px 12px);
52
- overflow-x: auto;
53
- font-family: var(--twoslash-code-font);
54
- font-size: var(--twoslash-code-font-size);
55
- line-height: var(--twoslash-popup-code-line-height, 1.2);
56
- white-space: pre-wrap;
57
- }
58
-
59
- .twoslash-floating .twoslash-popup-docs,
60
- .twoslash-floating .twoslash-popup-error {
61
- box-sizing: border-box;
62
- max-width: min(700px, calc(100vw - 32px));
63
- max-height: 500px;
64
- padding: var(--twoslash-popup-docs-padding, 12px);
65
- overflow: auto;
66
- font-family: var(--twoslash-docs-font);
67
- font-size: var(--twoslash-popup-docs-font-size, 0.9em);
68
- line-height: var(--twoslash-popup-docs-line-height, 1.6);
69
- text-align: start;
70
- }
71
-
72
- .twoslash-floating .twoslash-popup-docs {
73
- color: var(--twoslash-docs-color);
74
- border-top: 1px solid var(--twoslash-border-color);
75
- }
76
-
77
- .twoslash-floating .twoslash-popup-docs:first-child {
78
- border-top: 0;
79
- }
80
-
81
- .twoslash-floating .twoslash-popup-docs p,
82
- .twoslash-floating .twoslash-popup-error p {
83
- margin: 0 0 8px;
84
- }
85
-
86
- .twoslash-floating .twoslash-popup-docs p:last-child,
87
- .twoslash-floating .twoslash-popup-error p:last-child {
88
- margin-bottom: 0;
89
- }
90
-
91
- .twoslash-floating .twoslash-popup-docs code,
92
- .twoslash-floating .twoslash-popup-error code {
93
- padding: 0.15em 0.35em;
94
- font-family: var(--twoslash-code-font);
95
- font-size: var(--twoslash-popup-docs-font-size, 0.9em);
96
- background: var(--twoslash-popup-inline-code-bg, rgb(175 184 193 / 20%));
97
- border-radius: var(--twoslash-popup-inline-code-radius, 4px);
98
- }
99
-
100
- .twoslash-floating .twoslash-popup-docs a,
101
- .twoslash-floating .twoslash-popup-error a {
102
- color: var(--twoslash-matched-color);
103
- text-decoration: underline;
104
- text-underline-offset: 2px;
105
- }
106
-
107
- .twoslash-floating .twoslash-popup-docs-tags {
108
- display: flex;
109
- flex-direction: column;
110
- gap: 4px;
111
- }
112
-
113
- .twoslash-floating .twoslash-popup-docs-tag-name {
114
- margin-inline-end: 0.5em;
115
- font-family: var(--twoslash-code-font);
116
- color: var(--twoslash-unmatched-color);
1
+ @layer kawa.plugin {
2
+ /*
3
+ * Twoslash popups are drawn by third-party CSS that reads its own variables.
4
+ * Mapping them onto the shared tokens once keeps the popup themeable.
5
+ */
6
+ :root {
7
+ --twoslash-border-color: var(--kawa-c-border);
8
+ --twoslash-underline-color: var(--kawa-c-brand);
9
+ --twoslash-popup-bg: var(--kawa-c-bg-elv);
10
+ --twoslash-popup-color: var(--kawa-c-text-1);
11
+ --twoslash-popup-shadow: var(--kawa-shadow-overlay);
12
+ --twoslash-popup-radius: 8px;
13
+ --twoslash-docs-color: var(--kawa-c-text-2);
14
+ --twoslash-docs-font: var(--kawa-font-sans);
15
+ --twoslash-code-font: var(--kawa-font-mono);
16
+ --twoslash-code-font-size: 0.875em;
17
+ --twoslash-popup-code-line-height: 1.2;
18
+ --twoslash-popup-code-padding: 8px 12px;
19
+ --twoslash-popup-docs-padding: 12px;
20
+ --twoslash-popup-docs-font-size: 0.9em;
21
+ --twoslash-popup-docs-line-height: 1.6;
22
+ --twoslash-popup-inline-code-bg: var(--kawa-c-bg-soft);
23
+ --twoslash-popup-inline-code-radius: 4px;
24
+ --twoslash-cursor-color: var(--kawa-c-brand);
25
+ --twoslash-matched-color: var(--kawa-c-brand);
26
+ --twoslash-unmatched-color: var(--kawa-c-text-2);
27
+ --twoslash-error-color: var(--kawa-c-danger);
28
+ --twoslash-error-bg: color-mix(
29
+ in oklab,
30
+ var(--kawa-c-danger) 14%,
31
+ transparent
32
+ );
33
+ --twoslash-warn-color: var(--kawa-c-warning);
34
+ --twoslash-warn-bg: color-mix(
35
+ in oklab,
36
+ var(--kawa-c-warning) 14%,
37
+ transparent
38
+ );
39
+ }
40
+
41
+ .twoslash .v-popper {
42
+ display: inline-block;
43
+ vertical-align: baseline;
44
+ }
45
+
46
+ .twoslash .twoslash-hover {
47
+ margin-block: -2px;
48
+ padding-block: 2px;
49
+ border-color: var(--twoslash-underline-color);
50
+ }
51
+
52
+ .twoslash .twoslash-error-line {
53
+ box-sizing: border-box;
54
+ width: 100%;
55
+ min-width: 0;
56
+ overflow-wrap: anywhere;
57
+ white-space: pre-wrap;
58
+ }
59
+
60
+ .v-popper--theme-twoslash {
61
+ z-index: 19;
62
+ }
63
+
64
+ .v-popper--theme-twoslash .v-popper__inner {
65
+ overflow: hidden;
66
+ color: var(--twoslash-popup-color);
67
+ background: var(--twoslash-popup-bg);
68
+ border: 1px solid var(--twoslash-border-color);
69
+ border-radius: var(--twoslash-popup-radius, 8px);
70
+ box-shadow: var(--twoslash-popup-shadow);
71
+ }
72
+
73
+ .v-popper--theme-twoslash .v-popper__arrow-outer {
74
+ border-color: var(--twoslash-border-color);
75
+ }
76
+
77
+ .v-popper--theme-twoslash .v-popper__arrow-inner {
78
+ border-color: var(--twoslash-popup-bg);
79
+ }
80
+
81
+ .twoslash-floating .twoslash-popup-arrow {
82
+ display: none;
83
+ }
84
+
85
+ .twoslash-floating .twoslash-popup-code {
86
+ display: block;
87
+ box-sizing: border-box;
88
+ width: max-content;
89
+ min-width: 100%;
90
+ max-width: min(700px, calc(100vw - 32px));
91
+ padding: var(--twoslash-popup-code-padding, 8px 12px);
92
+ overflow-x: auto;
93
+ font-family: var(--twoslash-code-font);
94
+ font-size: var(--twoslash-code-font-size);
95
+ line-height: var(--twoslash-popup-code-line-height, 1.2);
96
+ white-space: pre-wrap;
97
+ }
98
+
99
+ .twoslash-floating .twoslash-popup-docs,
100
+ .twoslash-floating .twoslash-popup-error {
101
+ box-sizing: border-box;
102
+ max-width: min(700px, calc(100vw - 32px));
103
+ max-height: 500px;
104
+ padding: var(--twoslash-popup-docs-padding, 12px);
105
+ overflow: auto;
106
+ font-family: var(--twoslash-docs-font);
107
+ font-size: var(--twoslash-popup-docs-font-size, 0.9em);
108
+ line-height: var(--twoslash-popup-docs-line-height, 1.6);
109
+ text-align: start;
110
+ }
111
+
112
+ .twoslash-floating .twoslash-popup-docs {
113
+ color: var(--twoslash-docs-color);
114
+ border-top: 1px solid var(--twoslash-border-color);
115
+ }
116
+
117
+ .twoslash-floating .twoslash-popup-docs:first-child {
118
+ border-top: 0;
119
+ }
120
+
121
+ .twoslash-floating .twoslash-popup-docs p,
122
+ .twoslash-floating .twoslash-popup-error p {
123
+ margin: 0 0 8px;
124
+ }
125
+
126
+ .twoslash-floating .twoslash-popup-docs p:last-child,
127
+ .twoslash-floating .twoslash-popup-error p:last-child {
128
+ margin-bottom: 0;
129
+ }
130
+
131
+ .twoslash-floating .twoslash-popup-docs code,
132
+ .twoslash-floating .twoslash-popup-error code {
133
+ padding: 0.15em 0.35em;
134
+ font-family: var(--twoslash-code-font);
135
+ font-size: var(--twoslash-popup-docs-font-size, 0.9em);
136
+ background: var(--twoslash-popup-inline-code-bg, rgb(175 184 193 / 20%));
137
+ border-radius: var(--twoslash-popup-inline-code-radius, 4px);
138
+ }
139
+
140
+ .twoslash-floating .twoslash-popup-docs a,
141
+ .twoslash-floating .twoslash-popup-error a {
142
+ color: var(--twoslash-matched-color);
143
+ text-decoration: underline;
144
+ text-underline-offset: 2px;
145
+ }
146
+
147
+ .twoslash-floating .twoslash-popup-docs-tags {
148
+ display: flex;
149
+ flex-direction: column;
150
+ gap: 4px;
151
+ }
152
+
153
+ .twoslash-floating .twoslash-popup-docs-tag-name {
154
+ margin-inline-end: 0.5em;
155
+ font-family: var(--twoslash-code-font);
156
+ color: var(--twoslash-unmatched-color);
157
+ }
117
158
  }
package/src/vendor.css ADDED
@@ -0,0 +1,6 @@
1
+ /*
2
+ * Third-party CSS that Shiki and Twoslash expect. It must name a layer,
3
+ * otherwise it lands outside every layer and outranks the site theme.
4
+ */
5
+ @import url('@shikijs/twoslash/style-rich.css') layer(kawa.plugin);
6
+ @import url('floating-vue/dist/style.css') layer(kawa.plugin);