@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.
Files changed (2) hide show
  1. package/dist/index.mjs +18 -15
  2. 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 twoslash = createTransformerFactory(
166
- createTwoslasher()
167
- )({
168
- langs: ["ts", "tsx", "js", "jsx", "json", "vue"],
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), `
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
- if (isCI || !isDev || options.throws)
182
- throw error;
183
- if (typeof process !== "undefined")
184
- process.exitCode = 1;
185
- return removeTwoslashNotations(code);
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.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.1",
56
- "twoslash-vue": "^0.2.1",
57
- "vue": "^3.4.18",
58
- "@shikijs/twoslash": "1.1.1",
59
- "shiki": "1.1.1"
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",