@kawapress/plugin-shiki 0.0.1-beta.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/LICENSE +21 -0
- package/README.md +145 -0
- package/README.zh-CN.md +145 -0
- package/package.json +58 -0
- package/src/TwoslashMenu.vue +19 -0
- package/src/index.ts +242 -0
- package/src/renderer-floating-vue.ts +165 -0
- package/src/runtime-plugin.ts +41 -0
- package/src/twoslash.css +117 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) KawaPress contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<picture>
|
|
3
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/ShenQingchuan/kawapress/main/docs/public/kawapress-logo-dark.png">
|
|
4
|
+
<img src="https://raw.githubusercontent.com/ShenQingchuan/kawapress/main/docs/public/kawapress-logo.png" alt="KawaPress" width="180">
|
|
5
|
+
</picture>
|
|
6
|
+
</p>
|
|
7
|
+
|
|
8
|
+
<h1 align="center">KawaPress</h1>
|
|
9
|
+
|
|
10
|
+
<p align="center">
|
|
11
|
+
<strong>A Vue-first static site generator for documentation and content-focused websites.</strong>
|
|
12
|
+
</p>
|
|
13
|
+
|
|
14
|
+
<p align="center">
|
|
15
|
+
Write in Markdown. Develop with real SSR. Extend everything through public APIs.
|
|
16
|
+
</p>
|
|
17
|
+
|
|
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>
|
|
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
|
+
<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
|
+
<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">
|
|
23
|
+
</p>
|
|
24
|
+
|
|
25
|
+
<p align="center">
|
|
26
|
+
<a href="https://shenqingchuan.github.io/kawapress/en/">Documentation</a>
|
|
27
|
+
·
|
|
28
|
+
<a href="https://github.com/ShenQingchuan/kawapress/blob/main/README.zh-CN.md">简体中文</a>
|
|
29
|
+
</p>
|
|
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.
|
|
33
|
+
|
|
34
|
+
## Why KawaPress?
|
|
35
|
+
|
|
36
|
+
KawaPress turns Markdown into pre-rendered Vue websites. It keeps the familiar simplicity of a documentation generator while giving themes and plugins the same public extension points used by the official experience.
|
|
37
|
+
|
|
38
|
+
- **Real SSR during development** — every initial request is server-rendered, so SSR-only problems appear before build or deployment.
|
|
39
|
+
- **A complete default experience** — the built-in nagi (凪) preset includes responsive documentation layouts, dark mode, local search, syntax highlighting, Twoslash, code groups, multilingual navigation, and more.
|
|
40
|
+
- **Vue from end to end** — Markdown becomes Vue components, Vue Router handles navigation, and regular Vue SFCs fit naturally into content.
|
|
41
|
+
- **AI-ready output** — nagi generates page-level Markdown, locale-aware `llms.txt` and `llms-full.txt`, plus built-in copy actions.
|
|
42
|
+
- **One extension model** — Generator Plugins, Runtime Plugins, and Presets cover build-time behavior, the Vue runtime, themes, and reusable product setups without private theme hooks.
|
|
43
|
+
|
|
44
|
+
KawaPress is an independent project. It is not a VitePress fork or a drop-in replacement, and it intentionally does not use VitePress configuration.
|
|
45
|
+
|
|
46
|
+
## Quick Start
|
|
47
|
+
|
|
48
|
+
You need [Node.js](https://nodejs.org/) 22.12 or newer.
|
|
49
|
+
|
|
50
|
+
```sh
|
|
51
|
+
mkdir my-kawapress-site
|
|
52
|
+
cd my-kawapress-site
|
|
53
|
+
pnpm init
|
|
54
|
+
pnpm add --save-dev kawapress
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Create `kawapress.config.ts`:
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
import { nagi } from 'kawapress/nagi'
|
|
61
|
+
|
|
62
|
+
export default nagi({
|
|
63
|
+
title: 'My Docs',
|
|
64
|
+
})
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Create `index.md`:
|
|
68
|
+
|
|
69
|
+
```md
|
|
70
|
+
---
|
|
71
|
+
layout: home
|
|
72
|
+
title: My Docs
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
# My Docs
|
|
76
|
+
|
|
77
|
+
Welcome to my KawaPress site.
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Start the development server:
|
|
81
|
+
|
|
82
|
+
```sh
|
|
83
|
+
pnpm exec kawapress dev
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Build static files into `dist`:
|
|
87
|
+
|
|
88
|
+
```sh
|
|
89
|
+
pnpm exec kawapress build
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
The deployed output is static and does not require a Node.js server. npm and Yarn commands are available in the [Getting Started guide](https://shenqingchuan.github.io/kawapress/en/guide/getting-started).
|
|
93
|
+
|
|
94
|
+
> If your site directly imports Vue APIs or Vue components, also install `vue` as a development dependency.
|
|
95
|
+
|
|
96
|
+
## What You Get
|
|
97
|
+
|
|
98
|
+
| Area | Included capability |
|
|
99
|
+
| --- | --- |
|
|
100
|
+
| Authoring | Markdown, frontmatter, Vue in Markdown, file-based routing, data loaders |
|
|
101
|
+
| Rendering | Shared development/build SSR semantics, hydration, Vue Router navigation |
|
|
102
|
+
| Documentation UI | nagi layouts, responsive sidebar, page outline, dark mode, i18n |
|
|
103
|
+
| Content | Shiki, Twoslash, code groups, code copy, containers, GitHub alerts |
|
|
104
|
+
| Discovery | Lazy local search and locale-aware navigation |
|
|
105
|
+
| AI consumption | Page `.md`, `llms.txt`, `llms-full.txt`, copy actions |
|
|
106
|
+
| Styling | UnoCSS integration with sensible nagi defaults |
|
|
107
|
+
|
|
108
|
+
The `kawapress` package includes nagi and its official plugins. A basic site only needs this one package; advanced users can compose the individual `@kawapress/*` packages directly.
|
|
109
|
+
|
|
110
|
+
## Extension Model
|
|
111
|
+
|
|
112
|
+
KawaPress keeps extension boundaries explicit:
|
|
113
|
+
|
|
114
|
+
- a **Generator Plugin** extends configuration, Markdown, page data, Vite, and build artifacts;
|
|
115
|
+
- a **Runtime Plugin** extends the real Vue App and Vue Router in both SSR and the browser;
|
|
116
|
+
- a **Preset** combines configuration and plugins into a ready-to-use experience such as nagi.
|
|
117
|
+
|
|
118
|
+
A logical plugin is installed once and can provide both generator and runtime behavior. Learn more in the [Plugin System guide](https://shenqingchuan.github.io/kawapress/en/guide/plugin-system).
|
|
119
|
+
|
|
120
|
+
## Documentation
|
|
121
|
+
|
|
122
|
+
- [Getting Started](https://shenqingchuan.github.io/kawapress/en/guide/getting-started)
|
|
123
|
+
- [What is KawaPress?](https://shenqingchuan.github.io/kawapress/en/guide/what-is-kawapress)
|
|
124
|
+
- [Markdown Extensions](https://shenqingchuan.github.io/kawapress/en/guide/markdown-extensions)
|
|
125
|
+
- [Internationalization](https://shenqingchuan.github.io/kawapress/en/guide/internationalization)
|
|
126
|
+
- [Plugin System](https://shenqingchuan.github.io/kawapress/en/guide/plugin-system)
|
|
127
|
+
- [Theme Customization](https://shenqingchuan.github.io/kawapress/en/guide/theme-customization)
|
|
128
|
+
|
|
129
|
+
## Contributing
|
|
130
|
+
|
|
131
|
+
Issues and pull requests are welcome. For a large feature, please open an issue first so the direction can be agreed on before implementation.
|
|
132
|
+
|
|
133
|
+
```sh
|
|
134
|
+
pnpm install
|
|
135
|
+
pnpm lint
|
|
136
|
+
pnpm typecheck
|
|
137
|
+
pnpm test
|
|
138
|
+
pnpm build
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
KawaPress uses Node.js 22.12 or newer and pnpm 11.22.0 for repository development.
|
|
142
|
+
|
|
143
|
+
## License
|
|
144
|
+
|
|
145
|
+
[MIT](https://github.com/ShenQingchuan/kawapress/blob/main/LICENSE) © KawaPress contributors
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<picture>
|
|
3
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/ShenQingchuan/kawapress/main/docs/public/kawapress-logo-dark.png">
|
|
4
|
+
<img src="https://raw.githubusercontent.com/ShenQingchuan/kawapress/main/docs/public/kawapress-logo.png" alt="KawaPress" width="180">
|
|
5
|
+
</picture>
|
|
6
|
+
</p>
|
|
7
|
+
|
|
8
|
+
<h1 align="center">KawaPress</h1>
|
|
9
|
+
|
|
10
|
+
<p align="center">
|
|
11
|
+
<strong>以 Vue 为核心,面向文档与内容型网站的静态站点生成器。</strong>
|
|
12
|
+
</p>
|
|
13
|
+
|
|
14
|
+
<p align="center">
|
|
15
|
+
用 Markdown 安心写作,在真实 SSR 中开发,通过公开能力自由扩展。
|
|
16
|
+
</p>
|
|
17
|
+
|
|
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>
|
|
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
|
+
<a href="https://github.com/ShenQingchuan/kawapress/blob/main/LICENSE"><img src="https://img.shields.io/github/license/ShenQingchuan/kawapress" alt="MIT 许可"></a>
|
|
22
|
+
<img src="https://img.shields.io/badge/Node.js-%E2%89%A522.12-339933?logo=nodedotjs&logoColor=white" alt="Node.js 22.12 或更高版本">
|
|
23
|
+
</p>
|
|
24
|
+
|
|
25
|
+
<p align="center">
|
|
26
|
+
<a href="https://shenqingchuan.github.io/kawapress/">中文文档</a>
|
|
27
|
+
·
|
|
28
|
+
<a href="https://github.com/ShenQingchuan/kawapress/blob/main/README.md">English</a>
|
|
29
|
+
</p>
|
|
30
|
+
|
|
31
|
+
> [!IMPORTANT]
|
|
32
|
+
> KawaPress 目前处于 beta 阶段,适合试用和早期项目。0.1.0 之前,公开 API 仍可能调整;现阶段使用时请固定具体版本。
|
|
33
|
+
|
|
34
|
+
## 为什么选择 KawaPress?
|
|
35
|
+
|
|
36
|
+
KawaPress 会把 Markdown 编译成预渲染的 Vue 网站。它保留了文档生成器简单、轻快的写作方式,同时让官方主题和第三方扩展使用完全相同的公开能力。
|
|
37
|
+
|
|
38
|
+
- **开发时也执行真实 SSR**:每次首次请求都会在服务端渲染。只在 SSR 中出现的问题,不必等到构建或上线后才发现。
|
|
39
|
+
- **默认体验完整**:内置 nagi(凪)预设,包含响应式文档布局、深浅色模式、本地搜索、代码高亮、Twoslash、代码组和多语言导航等常用能力。
|
|
40
|
+
- **从头到尾使用 Vue**:Markdown 会变成 Vue 组件,页面跳转交给 Vue Router;需要交互时,也可以自然地使用普通 Vue SFC。
|
|
41
|
+
- **面向 AI 的文档产物**:nagi 默认生成每页 `.md`、各语言的 `llms.txt` 与 `llms-full.txt`,并提供复制正文和链接的操作。
|
|
42
|
+
- **统一的扩展模型**:Generator Plugin、Runtime Plugin 与 Preset 分别覆盖生成阶段、Vue 运行时和能力组合,不依赖主题私有入口。
|
|
43
|
+
|
|
44
|
+
KawaPress 是一个独立项目,不是 VitePress 的分支或配置兼容层,也不能直接使用 VitePress 配置。
|
|
45
|
+
|
|
46
|
+
## 快速开始
|
|
47
|
+
|
|
48
|
+
请先准备 [Node.js](https://nodejs.org/) 22.12 或更高版本。
|
|
49
|
+
|
|
50
|
+
```sh
|
|
51
|
+
mkdir my-kawapress-site
|
|
52
|
+
cd my-kawapress-site
|
|
53
|
+
pnpm init
|
|
54
|
+
pnpm add --save-dev kawapress
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
创建 `kawapress.config.ts`:
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
import { nagi } from 'kawapress/nagi'
|
|
61
|
+
|
|
62
|
+
export default nagi({
|
|
63
|
+
title: 'My Docs',
|
|
64
|
+
})
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
创建 `index.md`:
|
|
68
|
+
|
|
69
|
+
```md
|
|
70
|
+
---
|
|
71
|
+
layout: home
|
|
72
|
+
title: My Docs
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
# My Docs
|
|
76
|
+
|
|
77
|
+
欢迎来到我的 KawaPress 站点。
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
启动开发服务器:
|
|
81
|
+
|
|
82
|
+
```sh
|
|
83
|
+
pnpm exec kawapress dev
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
构建静态文件到 `dist`:
|
|
87
|
+
|
|
88
|
+
```sh
|
|
89
|
+
pnpm exec kawapress build
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
部署产物是普通静态文件,不需要在服务器上继续运行 Node.js。npm 和 Yarn 的完整命令可以查看[快速开始](https://shenqingchuan.github.io/kawapress/guide/getting-started)。
|
|
93
|
+
|
|
94
|
+
> 如果站点会直接导入 Vue API 或 Vue 组件,还需要把 `vue` 安装为开发依赖。
|
|
95
|
+
|
|
96
|
+
## 默认包含什么?
|
|
97
|
+
|
|
98
|
+
| 范围 | 内置能力 |
|
|
99
|
+
| --- | --- |
|
|
100
|
+
| 内容编写 | Markdown、Frontmatter、在 Markdown 中使用 Vue、文件路由、Data Loader |
|
|
101
|
+
| 渲染 | 开发与构建共享 SSR 语义、Hydration、Vue Router 站内导航 |
|
|
102
|
+
| 文档界面 | nagi 布局、响应式 Sidebar、本页目录、深浅色模式、多语言 |
|
|
103
|
+
| 内容增强 | Shiki、Twoslash、代码组、代码复制、提示容器、GitHub Alerts |
|
|
104
|
+
| 内容发现 | 按需加载的本地搜索与多语言导航 |
|
|
105
|
+
| AI 读取 | 页面 `.md`、`llms.txt`、`llms-full.txt`、页面复制操作 |
|
|
106
|
+
| 样式 | UnoCSS 集成与 nagi 默认配置 |
|
|
107
|
+
|
|
108
|
+
`kawapress` 已经包含 nagi 和它使用的官方插件。普通文档站只需要安装这一个包;需要自行组合能力时,也可以直接使用独立的 `@kawapress/*` 包。
|
|
109
|
+
|
|
110
|
+
## 扩展模型
|
|
111
|
+
|
|
112
|
+
KawaPress 把扩展边界分得很清楚:
|
|
113
|
+
|
|
114
|
+
- **Generator Plugin** 负责配置、Markdown、页面数据、Vite 与构建产物;
|
|
115
|
+
- **Runtime Plugin** 在 SSR 和浏览器中扩展真实的 Vue App 与 Vue Router;
|
|
116
|
+
- **Preset** 把配置和一组插件组合成可以直接使用的产品体验,例如 nagi。
|
|
117
|
+
|
|
118
|
+
一个逻辑插件只需要安装一次,同时可以提供生成侧和运行侧能力。更多内容请查看[插件体系](https://shenqingchuan.github.io/kawapress/guide/plugin-system)。
|
|
119
|
+
|
|
120
|
+
## 文档
|
|
121
|
+
|
|
122
|
+
- [快速开始](https://shenqingchuan.github.io/kawapress/guide/getting-started)
|
|
123
|
+
- [KawaPress 是什么?](https://shenqingchuan.github.io/kawapress/guide/what-is-kawapress)
|
|
124
|
+
- [Markdown 语法扩展](https://shenqingchuan.github.io/kawapress/guide/markdown-extensions)
|
|
125
|
+
- [国际化](https://shenqingchuan.github.io/kawapress/guide/internationalization)
|
|
126
|
+
- [插件体系](https://shenqingchuan.github.io/kawapress/guide/plugin-system)
|
|
127
|
+
- [主题定制](https://shenqingchuan.github.io/kawapress/guide/theme-customization)
|
|
128
|
+
|
|
129
|
+
## 参与贡献
|
|
130
|
+
|
|
131
|
+
欢迎提交 Issue 和 Pull Request。如果准备增加较大的功能,请先创建 Issue,把目标和方案聊清楚后再开始实现。
|
|
132
|
+
|
|
133
|
+
```sh
|
|
134
|
+
pnpm install
|
|
135
|
+
pnpm lint
|
|
136
|
+
pnpm typecheck
|
|
137
|
+
pnpm test
|
|
138
|
+
pnpm build
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
KawaPress 仓库使用 Node.js 22.12 或更高版本,以及 pnpm 11.22.0 进行开发。
|
|
142
|
+
|
|
143
|
+
## 开源许可
|
|
144
|
+
|
|
145
|
+
[MIT](https://github.com/ShenQingchuan/kawapress/blob/main/LICENSE) © KawaPress 贡献者
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@kawapress/plugin-shiki",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.0.1-beta.1",
|
|
5
|
+
"description": "Shiki and Twoslash plugin for KawaPress",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"homepage": "https://shenqingchuan.github.io/kawapress/",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/ShenQingchuan/kawapress.git",
|
|
11
|
+
"directory": "packages/plugin-shiki"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/ShenQingchuan/kawapress/issues"
|
|
15
|
+
},
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./src/index.ts",
|
|
19
|
+
"import": "./src/index.ts",
|
|
20
|
+
"default": "./src/index.ts"
|
|
21
|
+
},
|
|
22
|
+
"./runtime-plugin": {
|
|
23
|
+
"types": "./src/runtime-plugin.ts",
|
|
24
|
+
"import": "./src/runtime-plugin.ts",
|
|
25
|
+
"default": "./src/runtime-plugin.ts"
|
|
26
|
+
},
|
|
27
|
+
"./package.json": "./package.json"
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"src"
|
|
31
|
+
],
|
|
32
|
+
"engines": {
|
|
33
|
+
"node": ">=22.12.0"
|
|
34
|
+
},
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public",
|
|
37
|
+
"registry": "https://registry.npmjs.org/"
|
|
38
|
+
},
|
|
39
|
+
"peerDependencies": {
|
|
40
|
+
"vue": "^3.5.41",
|
|
41
|
+
"kawapress": "0.0.1-beta.1"
|
|
42
|
+
},
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"@shikijs/transformers": "^4.4.3",
|
|
45
|
+
"@shikijs/twoslash": "^4.4.3",
|
|
46
|
+
"floating-vue": "^5.2.2",
|
|
47
|
+
"mdast-util-from-markdown": "^2.0.3",
|
|
48
|
+
"mdast-util-gfm": "^3.1.0",
|
|
49
|
+
"mdast-util-to-hast": "^13.2.1",
|
|
50
|
+
"shiki": "^4.4.3",
|
|
51
|
+
"twoslash-vue": "^0.3.9",
|
|
52
|
+
"typescript": "^6.0.3"
|
|
53
|
+
},
|
|
54
|
+
"devDependencies": {
|
|
55
|
+
"markdown-exit": "^1.3.0",
|
|
56
|
+
"vue": "^3.5.41"
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { Menu } from 'floating-vue'
|
|
3
|
+
import { useId } from 'vue'
|
|
4
|
+
|
|
5
|
+
defineOptions({
|
|
6
|
+
name: 'KawaTwoslashMenu',
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
const ariaId = useId()
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<template>
|
|
13
|
+
<Menu :aria-id="ariaId">
|
|
14
|
+
<slot />
|
|
15
|
+
<template #popper="slotProps">
|
|
16
|
+
<slot name="popper" v-bind="slotProps" />
|
|
17
|
+
</template>
|
|
18
|
+
</Menu>
|
|
19
|
+
</template>
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
TransformerTwoslashOptions,
|
|
3
|
+
} from '@shikijs/twoslash'
|
|
4
|
+
import type { KawaPressPlugin } from 'kawapress'
|
|
5
|
+
import type { ShikiTransformer } from 'shiki'
|
|
6
|
+
import {
|
|
7
|
+
transformerMetaHighlight,
|
|
8
|
+
transformerNotationDiff,
|
|
9
|
+
transformerNotationErrorLevel,
|
|
10
|
+
transformerNotationFocus,
|
|
11
|
+
transformerNotationHighlight,
|
|
12
|
+
} from '@shikijs/transformers'
|
|
13
|
+
import { createTransformerFactory } from '@shikijs/twoslash'
|
|
14
|
+
import { definePlugin } from 'kawapress'
|
|
15
|
+
import { createHighlighter } from 'shiki'
|
|
16
|
+
import { createTwoslasher } from 'twoslash-vue'
|
|
17
|
+
import { rendererFloatingVue } from './renderer-floating-vue'
|
|
18
|
+
|
|
19
|
+
export type TwoslashOptions = Omit<
|
|
20
|
+
TransformerTwoslashOptions,
|
|
21
|
+
'renderer' | 'twoslasher'
|
|
22
|
+
>
|
|
23
|
+
|
|
24
|
+
interface ShikiPluginBaseOptions {
|
|
25
|
+
langs?: string[]
|
|
26
|
+
transformers?: ShikiTransformer[]
|
|
27
|
+
twoslash?: boolean | TwoslashOptions
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface ShikiThemePair extends Record<string, string> {
|
|
31
|
+
light: string
|
|
32
|
+
dark: string
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export type ShikiPluginOptions = ShikiPluginBaseOptions & (
|
|
36
|
+
| { theme?: string, themes?: never }
|
|
37
|
+
| { theme?: never, themes: ShikiThemePair }
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
const V_PRE_TRANSFORMER_NAME = 'kawapress:v-pre'
|
|
41
|
+
const RUNTIME_DEPENDENCIES = ['floating-vue']
|
|
42
|
+
const TWOSLASH_LANGS = ['ts', 'tsx', 'js', 'jsx', 'json', 'vue']
|
|
43
|
+
const PRELOADED_LANGS = [
|
|
44
|
+
'bash',
|
|
45
|
+
'css',
|
|
46
|
+
'diff',
|
|
47
|
+
'html',
|
|
48
|
+
'js',
|
|
49
|
+
'json',
|
|
50
|
+
'jsx',
|
|
51
|
+
'md',
|
|
52
|
+
'shell',
|
|
53
|
+
'ts',
|
|
54
|
+
'tsx',
|
|
55
|
+
'vue',
|
|
56
|
+
'yaml',
|
|
57
|
+
]
|
|
58
|
+
|
|
59
|
+
export function shikiPlugin(options: ShikiPluginOptions = {}): KawaPressPlugin {
|
|
60
|
+
const theme = options.theme ?? 'github-light'
|
|
61
|
+
const themes = options.themes
|
|
62
|
+
const transformers = createTransformers(options)
|
|
63
|
+
|
|
64
|
+
return definePlugin({
|
|
65
|
+
name: '@kawapress/plugin-shiki',
|
|
66
|
+
setup(api) {
|
|
67
|
+
api.markdown(async (markdown) => {
|
|
68
|
+
const highlighter = await createHighlighter({
|
|
69
|
+
themes: themes ? Object.values(themes) : [theme],
|
|
70
|
+
langs: options.langs ?? PRELOADED_LANGS,
|
|
71
|
+
})
|
|
72
|
+
markdown.options.highlight = (str, lang, attrs) =>
|
|
73
|
+
highlightCode(highlighter, str, lang, attrs, {
|
|
74
|
+
theme,
|
|
75
|
+
themes,
|
|
76
|
+
}, transformers)
|
|
77
|
+
})
|
|
78
|
+
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
|
+
]
|
|
91
|
+
})
|
|
92
|
+
},
|
|
93
|
+
})
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export default shikiPlugin
|
|
97
|
+
|
|
98
|
+
type Highlighter = Awaited<ReturnType<typeof createHighlighter>>
|
|
99
|
+
|
|
100
|
+
function createTransformers(
|
|
101
|
+
options: ShikiPluginOptions,
|
|
102
|
+
): ShikiTransformer[] {
|
|
103
|
+
const transformers: ShikiTransformer[] = [
|
|
104
|
+
transformerMetaHighlight(),
|
|
105
|
+
transformerNotationDiff(),
|
|
106
|
+
transformerNotationFocus({
|
|
107
|
+
classActiveLine: 'has-focus',
|
|
108
|
+
classActivePre: 'has-focused-lines',
|
|
109
|
+
}),
|
|
110
|
+
transformerNotationHighlight(),
|
|
111
|
+
transformerNotationErrorLevel(),
|
|
112
|
+
createSemanticAnnotationTransformer(),
|
|
113
|
+
createVPreTransformer(),
|
|
114
|
+
]
|
|
115
|
+
|
|
116
|
+
if (options.twoslash) {
|
|
117
|
+
const twoslashOptions = options.twoslash === true
|
|
118
|
+
? {}
|
|
119
|
+
: options.twoslash
|
|
120
|
+
transformers.push(createTwoslashTransformer(twoslashOptions))
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
transformers.push(...(options.transformers ?? []))
|
|
124
|
+
transformers.push(createRenderedLineCountTransformer())
|
|
125
|
+
return transformers
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function createSemanticAnnotationTransformer(): ShikiTransformer {
|
|
129
|
+
return {
|
|
130
|
+
name: 'kawapress:semantic-code-annotations',
|
|
131
|
+
code(node) {
|
|
132
|
+
for (const child of node.children) {
|
|
133
|
+
if (child.type !== 'element') {
|
|
134
|
+
continue
|
|
135
|
+
}
|
|
136
|
+
const classes = child.properties.class
|
|
137
|
+
const classNames = new Set(Array.isArray(classes)
|
|
138
|
+
? classes.map(String)
|
|
139
|
+
: classes ? [String(classes)] : [])
|
|
140
|
+
if (!classNames.has('line')) {
|
|
141
|
+
continue
|
|
142
|
+
}
|
|
143
|
+
if (classNames.has('diff') && classNames.has('remove')) {
|
|
144
|
+
child.tagName = 'del'
|
|
145
|
+
}
|
|
146
|
+
else if (classNames.has('diff') && classNames.has('add')) {
|
|
147
|
+
child.tagName = 'ins'
|
|
148
|
+
}
|
|
149
|
+
else if (classNames.has('highlighted') || classNames.has('has-focus')) {
|
|
150
|
+
child.tagName = 'mark'
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function createRenderedLineCountTransformer(): ShikiTransformer {
|
|
158
|
+
return {
|
|
159
|
+
name: 'kawapress:rendered-line-count',
|
|
160
|
+
code(node) {
|
|
161
|
+
const lineCount = node.children.filter((child) => {
|
|
162
|
+
if (child.type !== 'element') {
|
|
163
|
+
return false
|
|
164
|
+
}
|
|
165
|
+
const classes = child.properties.class
|
|
166
|
+
return Array.isArray(classes)
|
|
167
|
+
? classes.map(String).includes('line')
|
|
168
|
+
: typeof classes === 'string'
|
|
169
|
+
&& classes.split(/\s+/).includes('line')
|
|
170
|
+
}).length
|
|
171
|
+
this.pre.properties['data-kawa-line-count'] = Math.max(1, lineCount)
|
|
172
|
+
},
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function createVPreTransformer(): ShikiTransformer {
|
|
177
|
+
return {
|
|
178
|
+
name: V_PRE_TRANSFORMER_NAME,
|
|
179
|
+
pre(node) {
|
|
180
|
+
if (!this.meta.twoslash) {
|
|
181
|
+
node.properties['v-pre'] = ''
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function createTwoslashTransformer(
|
|
188
|
+
options: TwoslashOptions,
|
|
189
|
+
): ShikiTransformer {
|
|
190
|
+
const transformer = createTransformerFactory(
|
|
191
|
+
createTwoslasher(options.twoslashOptions),
|
|
192
|
+
rendererFloatingVue(),
|
|
193
|
+
)({
|
|
194
|
+
langs: TWOSLASH_LANGS,
|
|
195
|
+
...options,
|
|
196
|
+
explicitTrigger: options.explicitTrigger ?? true,
|
|
197
|
+
})
|
|
198
|
+
|
|
199
|
+
return {
|
|
200
|
+
...transformer,
|
|
201
|
+
name: 'kawapress:twoslash',
|
|
202
|
+
postprocess(html) {
|
|
203
|
+
if (this.meta.twoslash) {
|
|
204
|
+
return html.replaceAll('{', '{')
|
|
205
|
+
}
|
|
206
|
+
return html
|
|
207
|
+
},
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
function highlightCode(
|
|
212
|
+
highlighter: Highlighter,
|
|
213
|
+
str: string,
|
|
214
|
+
lang: string,
|
|
215
|
+
attrs: string,
|
|
216
|
+
themeOptions: {
|
|
217
|
+
theme: string
|
|
218
|
+
themes?: ShikiThemePair
|
|
219
|
+
},
|
|
220
|
+
transformers: ShikiTransformer[],
|
|
221
|
+
): string {
|
|
222
|
+
const langName = (lang || 'txt').toLowerCase()
|
|
223
|
+
const loaded = highlighter.getLoadedLanguages().includes(langName)
|
|
224
|
+
const commonOptions = {
|
|
225
|
+
lang: loaded ? langName : 'txt',
|
|
226
|
+
transformers,
|
|
227
|
+
meta: { __raw: attrs },
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
const code = str.replace(/\r?\n$/, '')
|
|
231
|
+
|
|
232
|
+
return themeOptions.themes
|
|
233
|
+
? highlighter.codeToHtml(code, {
|
|
234
|
+
...commonOptions,
|
|
235
|
+
themes: themeOptions.themes,
|
|
236
|
+
defaultColor: 'light-dark()',
|
|
237
|
+
})
|
|
238
|
+
: highlighter.codeToHtml(code, {
|
|
239
|
+
...commonOptions,
|
|
240
|
+
theme: themeOptions.theme,
|
|
241
|
+
})
|
|
242
|
+
}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
RendererRichOptions,
|
|
3
|
+
TwoslashRenderer,
|
|
4
|
+
} from '@shikijs/twoslash'
|
|
5
|
+
import { rendererRich } from '@shikijs/twoslash'
|
|
6
|
+
import { fromMarkdown } from 'mdast-util-from-markdown'
|
|
7
|
+
import { gfmFromMarkdown } from 'mdast-util-gfm'
|
|
8
|
+
import { defaultHandlers, toHast } from 'mdast-util-to-hast'
|
|
9
|
+
|
|
10
|
+
type HastOptions = NonNullable<RendererRichOptions['hast']>
|
|
11
|
+
type PopupCompose = NonNullable<HastOptions['hoverCompose']>
|
|
12
|
+
type CompletionCompose = NonNullable<HastOptions['completionCompose']>
|
|
13
|
+
type PopupElement = Parameters<PopupCompose>[0]['popup']
|
|
14
|
+
type PopupNode = ReturnType<PopupCompose>[number]
|
|
15
|
+
type RenderMarkdown = NonNullable<RendererRichOptions['renderMarkdown']>
|
|
16
|
+
type RenderMarkdownInline = NonNullable<RendererRichOptions['renderMarkdownInline']>
|
|
17
|
+
|
|
18
|
+
const JSDOC_LINK_RE = /\{@link ([^}]*)\}/g
|
|
19
|
+
const PARAM_NAME_RE = /^([\w$-]+)/
|
|
20
|
+
const TWOSLASH_MENU_TAG = 'kawa-twoslash-menu'
|
|
21
|
+
|
|
22
|
+
const composePopup: PopupCompose = ({ popup, token }) => [
|
|
23
|
+
{
|
|
24
|
+
type: 'element',
|
|
25
|
+
tagName: 'span',
|
|
26
|
+
properties: {},
|
|
27
|
+
children: [token],
|
|
28
|
+
},
|
|
29
|
+
createPopperSlot(popup),
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
const composeCompletion: CompletionCompose = ({ popup, cursor }) => [{
|
|
33
|
+
type: 'element',
|
|
34
|
+
tagName: TWOSLASH_MENU_TAG,
|
|
35
|
+
properties: {
|
|
36
|
+
'popper-class': 'shiki twoslash-floating twoslash-completion',
|
|
37
|
+
'theme': 'twoslash-completion',
|
|
38
|
+
':shown': 'true',
|
|
39
|
+
},
|
|
40
|
+
children: [cursor, createPopperSlot(popup)],
|
|
41
|
+
}]
|
|
42
|
+
|
|
43
|
+
const renderMarkdown: RenderMarkdown = function (markdown) {
|
|
44
|
+
const tree = fromMarkdown(
|
|
45
|
+
markdown.replace(JSDOC_LINK_RE, '$1'),
|
|
46
|
+
{ mdastExtensions: [gfmFromMarkdown()] },
|
|
47
|
+
)
|
|
48
|
+
const hast = toHast(tree, {
|
|
49
|
+
handlers: {
|
|
50
|
+
code: (state, node) => {
|
|
51
|
+
const lang = node.lang ?? ''
|
|
52
|
+
if (!lang) {
|
|
53
|
+
return defaultHandlers.code(state, node)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const highlighted = this.codeToHast(node.value, {
|
|
57
|
+
...this.options,
|
|
58
|
+
transformers: [],
|
|
59
|
+
lang,
|
|
60
|
+
structure: node.value.trim().includes('\n')
|
|
61
|
+
? 'classic'
|
|
62
|
+
: 'inline',
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
return {
|
|
66
|
+
type: 'element',
|
|
67
|
+
tagName: 'code',
|
|
68
|
+
properties: {},
|
|
69
|
+
children: highlighted.children.filter(
|
|
70
|
+
child => child.type !== 'doctype',
|
|
71
|
+
),
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
if (hast.type === 'root') {
|
|
78
|
+
return hast.children.filter(child => child.type !== 'doctype')
|
|
79
|
+
}
|
|
80
|
+
if (hast.type === 'doctype') {
|
|
81
|
+
return []
|
|
82
|
+
}
|
|
83
|
+
return [hast]
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const renderMarkdownInline: RenderMarkdownInline = function (
|
|
87
|
+
markdown,
|
|
88
|
+
context,
|
|
89
|
+
) {
|
|
90
|
+
const source = context === 'tag:param'
|
|
91
|
+
? markdown.replace(PARAM_NAME_RE, '`$1` ')
|
|
92
|
+
: markdown
|
|
93
|
+
const children = renderMarkdown.call(this, source)
|
|
94
|
+
const first = children[0]
|
|
95
|
+
|
|
96
|
+
return children.length === 1
|
|
97
|
+
&& first?.type === 'element'
|
|
98
|
+
&& first.tagName === 'p'
|
|
99
|
+
? first.children
|
|
100
|
+
: children
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export function rendererFloatingVue(
|
|
104
|
+
options: RendererRichOptions = {},
|
|
105
|
+
): TwoslashRenderer {
|
|
106
|
+
const menuProperties = {
|
|
107
|
+
'class': 'twoslash-hover',
|
|
108
|
+
'popper-class': 'shiki twoslash-floating',
|
|
109
|
+
'theme': 'twoslash',
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return rendererRich({
|
|
113
|
+
...options,
|
|
114
|
+
renderMarkdown,
|
|
115
|
+
renderMarkdownInline,
|
|
116
|
+
hast: {
|
|
117
|
+
hoverToken: {
|
|
118
|
+
tagName: TWOSLASH_MENU_TAG,
|
|
119
|
+
properties: menuProperties,
|
|
120
|
+
},
|
|
121
|
+
hoverCompose: composePopup,
|
|
122
|
+
queryToken: {
|
|
123
|
+
tagName: TWOSLASH_MENU_TAG,
|
|
124
|
+
properties: {
|
|
125
|
+
...menuProperties,
|
|
126
|
+
':shown': 'true',
|
|
127
|
+
'theme': 'twoslash-query',
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
queryCompose: composePopup,
|
|
131
|
+
popupDocs: { class: 'twoslash-popup-docs' },
|
|
132
|
+
popupDocsTags: {
|
|
133
|
+
class: 'twoslash-popup-docs twoslash-popup-docs-tags',
|
|
134
|
+
},
|
|
135
|
+
popupError: { class: 'twoslash-popup-error' },
|
|
136
|
+
errorToken: options.errorRendering === 'hover'
|
|
137
|
+
? {
|
|
138
|
+
tagName: TWOSLASH_MENU_TAG,
|
|
139
|
+
properties: {
|
|
140
|
+
...menuProperties,
|
|
141
|
+
class: 'twoslash-error twoslash-error-hover',
|
|
142
|
+
},
|
|
143
|
+
}
|
|
144
|
+
: undefined,
|
|
145
|
+
errorCompose: composePopup,
|
|
146
|
+
completionCompose: composeCompletion,
|
|
147
|
+
},
|
|
148
|
+
})
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function createPopperSlot(popup: PopupElement): PopupNode {
|
|
152
|
+
popup.properties ??= {}
|
|
153
|
+
popup.properties['v-pre'] = ''
|
|
154
|
+
|
|
155
|
+
return {
|
|
156
|
+
type: 'element',
|
|
157
|
+
tagName: 'template',
|
|
158
|
+
properties: { 'v-slot:popper': '' },
|
|
159
|
+
content: {
|
|
160
|
+
type: 'root',
|
|
161
|
+
children: [popup],
|
|
162
|
+
},
|
|
163
|
+
children: [],
|
|
164
|
+
} as PopupNode
|
|
165
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import FloatingVue from 'floating-vue'
|
|
2
|
+
import { defineRuntimePlugin } from 'kawapress'
|
|
3
|
+
import TwoslashMenu from './TwoslashMenu.vue'
|
|
4
|
+
import '@shikijs/twoslash/style-rich.css'
|
|
5
|
+
import 'floating-vue/dist/style.css'
|
|
6
|
+
import './twoslash.css'
|
|
7
|
+
|
|
8
|
+
export default defineRuntimePlugin({
|
|
9
|
+
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
|
+
},
|
|
41
|
+
})
|
package/src/twoslash.css
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
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);
|
|
117
|
+
}
|