@shikijs/vitepress-twoslash 1.1.1 → 1.1.3
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 -15
- package/package.json +6 -6
package/dist/index.mjs
CHANGED
|
@@ -162,15 +162,11 @@ function transformerTwoslash(options = {}) {
|
|
|
162
162
|
const {
|
|
163
163
|
explicitTrigger = true
|
|
164
164
|
} = options;
|
|
165
|
-
const
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
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), `
|
|
165
|
+
const onError = (error, code) => {
|
|
166
|
+
const isCI = typeof process !== "undefined" && process?.env?.CI;
|
|
167
|
+
const isDev = typeof process !== "undefined" && process?.env?.NODE_ENV === "development";
|
|
168
|
+
const shouldThrow = (options.throws || isCI || !isDev) && options.throws !== false;
|
|
169
|
+
console.error(`
|
|
174
170
|
|
|
175
171
|
--------
|
|
176
172
|
Twoslash error in code:
|
|
@@ -178,12 +174,19 @@ Twoslash error in code:
|
|
|
178
174
|
${code.split(/\n/g).slice(0, 15).join("\n").trim()}
|
|
179
175
|
--------
|
|
180
176
|
`);
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
177
|
+
if (shouldThrow)
|
|
178
|
+
throw error;
|
|
179
|
+
else
|
|
180
|
+
console.error(error);
|
|
181
|
+
return removeTwoslashNotations(code);
|
|
182
|
+
};
|
|
183
|
+
const twoslash = createTransformerFactory(
|
|
184
|
+
createTwoslasher()
|
|
185
|
+
)({
|
|
186
|
+
langs: ["ts", "tsx", "js", "jsx", "json", "vue"],
|
|
187
|
+
renderer: rendererFloatingVue(options),
|
|
188
|
+
onTwoslashError: onError,
|
|
189
|
+
onShikiError: onError,
|
|
187
190
|
...options,
|
|
188
191
|
explicitTrigger
|
|
189
192
|
});
|
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.3",
|
|
5
5
|
"description": "Enable Twoslash support in VitePress",
|
|
6
6
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -52,11 +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": "^0.2.
|
|
56
|
-
"twoslash-vue": "^0.2.
|
|
57
|
-
"vue": "^3.4.
|
|
58
|
-
"
|
|
59
|
-
"
|
|
55
|
+
"twoslash": "^0.2.3",
|
|
56
|
+
"twoslash-vue": "^0.2.2",
|
|
57
|
+
"vue": "^3.4.19",
|
|
58
|
+
"shiki": "1.1.3",
|
|
59
|
+
"@shikijs/twoslash": "1.1.3"
|
|
60
60
|
},
|
|
61
61
|
"scripts": {
|
|
62
62
|
"build": "unbuild",
|