@shikijs/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/core.d.mts CHANGED
@@ -58,7 +58,7 @@ interface TransformerTwoslashOptions {
58
58
  * Custom error handler for Shiki errors
59
59
  * When specified, `throws` will be ignored
60
60
  */
61
- onShikiError?: (error: unknown) => void;
61
+ onShikiError?: (error: unknown, code: string, lang: string) => void;
62
62
  }
63
63
  interface TwoslashRenderer {
64
64
  lineError?: (this: ShikiTransformerContext, error: NodeError) => ElementContent[];
package/dist/core.d.ts CHANGED
@@ -58,7 +58,7 @@ interface TransformerTwoslashOptions {
58
58
  * Custom error handler for Shiki errors
59
59
  * When specified, `throws` will be ignored
60
60
  */
61
- onShikiError?: (error: unknown) => void;
61
+ onShikiError?: (error: unknown, code: string, lang: string) => void;
62
62
  }
63
63
  interface TwoslashRenderer {
64
64
  lineError?: (this: ShikiTransformerContext, error: NodeError) => ElementContent[];
package/dist/core.mjs CHANGED
@@ -1051,7 +1051,7 @@ function createTransformerFactory(defaultTwoslasher, defaultRenderer) {
1051
1051
  const lineEl = this.lines[line];
1052
1052
  index = codeEl.children.indexOf(lineEl);
1053
1053
  if (index === -1) {
1054
- onShikiError(new ShikiTwoslashError(`Cannot find line ${line} in code element`));
1054
+ onShikiError(new ShikiTwoslashError(`Cannot find line ${line} in code element`), this.source, this.options.lang);
1055
1055
  return;
1056
1056
  }
1057
1057
  }
@@ -1089,7 +1089,7 @@ function createTransformerFactory(defaultTwoslasher, defaultRenderer) {
1089
1089
  }
1090
1090
  const tokens = locateTextTokens(node.line, node.character, node.length);
1091
1091
  if (!tokens.length && !(node.type === "error" && renderer.nodesError)) {
1092
- onShikiError(new ShikiTwoslashError(`Cannot find tokens for node: ${JSON.stringify(node)}`));
1092
+ onShikiError(new ShikiTwoslashError(`Cannot find tokens for node: ${JSON.stringify(node)}`), this.source, this.options.lang);
1093
1093
  continue;
1094
1094
  }
1095
1095
  const wrapTokens = (fn) => {
@@ -1177,7 +1177,7 @@ function createTransformerFactory(defaultTwoslasher, defaultRenderer) {
1177
1177
  break;
1178
1178
  }
1179
1179
  default: {
1180
- onShikiError(new ShikiTwoslashError(`Unknown node type: ${node?.type}`));
1180
+ onShikiError(new ShikiTwoslashError(`Unknown node type: ${node?.type}`), this.source, this.options.lang);
1181
1181
  }
1182
1182
  }
1183
1183
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@shikijs/twoslash",
3
3
  "type": "module",
4
- "version": "1.1.1",
4
+ "version": "1.1.3",
5
5
  "description": "Shiki transformer for twoslash",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -49,11 +49,11 @@
49
49
  "dist"
50
50
  ],
51
51
  "dependencies": {
52
- "twoslash": "^0.2.1",
53
- "@shikijs/core": "1.1.1"
52
+ "twoslash": "^0.2.3",
53
+ "@shikijs/core": "1.1.3"
54
54
  },
55
55
  "devDependencies": {
56
- "@iconify-json/carbon": "^1.1.29",
56
+ "@iconify-json/carbon": "^1.1.30",
57
57
  "@iconify-json/codicon": "^1.1.41",
58
58
  "@shikijs/twoslash": "^3.1.2",
59
59
  "hast-util-from-html": "^2.0.1",