@shikijs/twoslash 1.17.7 → 1.18.0

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
@@ -22,13 +22,19 @@ interface TransformerTwoslashOptions {
22
22
  * @default false
23
23
  */
24
24
  explicitTrigger?: boolean | RegExp;
25
+ /**
26
+ * Triggers that skip Twoslash transformation on the code block meta
27
+ *
28
+ * @default ['notwoslash', 'no-twoslash']
29
+ */
30
+ disableTriggers?: (string | RegExp)[];
25
31
  /**
26
32
  * Mapping from language alias to language name
27
33
  */
28
34
  langAlias?: Record<string, string>;
29
35
  /**
30
36
  * Custom filter function to apply this transformer to
31
- * When specified, `langs` and `explicitTrigger` will be ignored
37
+ * When specified, `langs`, `explicitTrigger`, and `disableTriggers` will be ignored
32
38
  */
33
39
  filter?: (lang: string, code: string, options: CodeToHastOptions) => boolean;
34
40
  /**
package/dist/core.d.ts CHANGED
@@ -22,13 +22,19 @@ interface TransformerTwoslashOptions {
22
22
  * @default false
23
23
  */
24
24
  explicitTrigger?: boolean | RegExp;
25
+ /**
26
+ * Triggers that skip Twoslash transformation on the code block meta
27
+ *
28
+ * @default ['notwoslash', 'no-twoslash']
29
+ */
30
+ disableTriggers?: (string | RegExp)[];
25
31
  /**
26
32
  * Mapping from language alias to language name
27
33
  */
28
34
  langAlias?: Record<string, string>;
29
35
  /**
30
36
  * Custom filter function to apply this transformer to
31
- * When specified, `langs` and `explicitTrigger` will be ignored
37
+ * When specified, `langs`, `explicitTrigger`, and `disableTriggers` will be ignored
32
38
  */
33
39
  filter?: (lang: string, code: string, options: CodeToHastOptions) => boolean;
34
40
  /**
package/dist/core.mjs CHANGED
@@ -1092,6 +1092,7 @@ function createTransformerFactory(defaultTwoslasher, defaultRenderer) {
1092
1092
  },
1093
1093
  twoslasher = defaultTwoslasher,
1094
1094
  explicitTrigger = false,
1095
+ disableTriggers = ["notwoslash", "no-twoslash"],
1095
1096
  renderer = defaultRenderer,
1096
1097
  throws = true,
1097
1098
  includesMap = /* @__PURE__ */ new Map()
@@ -1106,7 +1107,11 @@ function createTransformerFactory(defaultTwoslasher, defaultRenderer) {
1106
1107
  if (!renderer)
1107
1108
  throw new ShikiTwoslashError("Missing renderer");
1108
1109
  const map = /* @__PURE__ */ new WeakMap();
1109
- const filter = options.filter || ((lang, _, options2) => langs.includes(lang) && (!explicitTrigger || trigger.test(options2.meta?.__raw || "")));
1110
+ const {
1111
+ filter = (lang, _, options2) => {
1112
+ return langs.includes(lang) && (!explicitTrigger || trigger.test(options2.meta?.__raw || "")) && !disableTriggers.some((i) => typeof i === "string" ? options2.meta?.__raw?.includes(i) : i.test(options2.meta?.__raw || ""));
1113
+ }
1114
+ } = options;
1110
1115
  const includes = new TwoslashIncludesManager(includesMap);
1111
1116
  return {
1112
1117
  preprocess(code) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@shikijs/twoslash",
3
3
  "type": "module",
4
- "version": "1.17.7",
4
+ "version": "1.18.0",
5
5
  "description": "Shiki transformer for twoslash",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -50,15 +50,15 @@
50
50
  ],
51
51
  "dependencies": {
52
52
  "twoslash": "^0.2.11",
53
- "@shikijs/core": "1.17.7",
54
- "@shikijs/types": "1.17.7"
53
+ "@shikijs/core": "1.18.0",
54
+ "@shikijs/types": "1.18.0"
55
55
  },
56
56
  "devDependencies": {
57
57
  "@iconify-json/carbon": "^1.2.1",
58
58
  "@iconify-json/codicon": "^1.2.0",
59
- "hast-util-from-html": "^2.0.2",
59
+ "hast-util-from-html": "^2.0.3",
60
60
  "typescript": "^5.6.2",
61
- "@shikijs/twoslash": "1.17.7"
61
+ "@shikijs/twoslash": "1.18.0"
62
62
  },
63
63
  "scripts": {
64
64
  "build": "unbuild",