@shikijs/vitepress-twoslash 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +18 -0
- package/package.json +5 -4
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createTransformerFactory } from '@shikijs/twoslash/core';
|
|
2
2
|
import { createTwoslasher } from 'twoslash-vue';
|
|
3
|
+
import { removeTwoslashNotations } from 'twoslash';
|
|
3
4
|
import { rendererRich } from '@shikijs/twoslash';
|
|
4
5
|
export { defaultHoverInfoProcessor } from '@shikijs/twoslash';
|
|
5
6
|
import { gfmFromMarkdown } from 'mdast-util-gfm';
|
|
@@ -166,6 +167,23 @@ function transformerTwoslash(options = {}) {
|
|
|
166
167
|
)({
|
|
167
168
|
langs: ["ts", "tsx", "js", "jsx", "json", "vue"],
|
|
168
169
|
renderer: rendererFloatingVue(options),
|
|
170
|
+
onTwoslashError: (error, code) => {
|
|
171
|
+
const isCI = typeof process !== "undefined" && process?.env?.CI;
|
|
172
|
+
const isDev = typeof process !== "undefined" && process?.env?.NODE_ENV === "development";
|
|
173
|
+
console.error(String(error), `
|
|
174
|
+
|
|
175
|
+
--------
|
|
176
|
+
Twoslash error in code:
|
|
177
|
+
--------
|
|
178
|
+
${code.split(/\n/g).slice(0, 15).join("\n").trim()}
|
|
179
|
+
--------
|
|
180
|
+
`);
|
|
181
|
+
if (isCI || !isDev || options.throws)
|
|
182
|
+
throw error;
|
|
183
|
+
if (typeof process !== "undefined")
|
|
184
|
+
process.exitCode = 1;
|
|
185
|
+
return removeTwoslashNotations(code);
|
|
186
|
+
},
|
|
169
187
|
...options,
|
|
170
188
|
explicitTrigger
|
|
171
189
|
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shikijs/vitepress-twoslash",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.1",
|
|
5
5
|
"description": "Enable Twoslash support in VitePress",
|
|
6
6
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -52,10 +52,11 @@
|
|
|
52
52
|
"mdast-util-from-markdown": "^2.0.0",
|
|
53
53
|
"mdast-util-gfm": "^3.0.0",
|
|
54
54
|
"mdast-util-to-hast": "^13.1.0",
|
|
55
|
-
"twoslash
|
|
55
|
+
"twoslash": "^0.2.1",
|
|
56
|
+
"twoslash-vue": "^0.2.1",
|
|
56
57
|
"vue": "^3.4.18",
|
|
57
|
-
"@shikijs/twoslash": "1.1.
|
|
58
|
-
"shiki": "1.1.
|
|
58
|
+
"@shikijs/twoslash": "1.1.1",
|
|
59
|
+
"shiki": "1.1.1"
|
|
59
60
|
},
|
|
60
61
|
"scripts": {
|
|
61
62
|
"build": "unbuild",
|