@shikijs/vitepress-twoslash 4.3.0 → 4.4.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/cache-fs.d.mts +0 -1
- package/dist/cache-fs.mjs +6 -2
- package/dist/cache-inline/index.d.mts +2 -6
- package/dist/cache-inline/index.mjs +6 -3
- package/dist/client.d.mts +0 -1
- package/dist/index.d.mts +1 -2
- package/dist/index.mjs +2 -1
- package/dist/{types-BygG6v6M.d.mts → types-6hqHJcLR.d.mts} +0 -1
- package/package.json +5 -5
package/dist/cache-fs.d.mts
CHANGED
package/dist/cache-fs.mjs
CHANGED
|
@@ -10,12 +10,16 @@ function createFileSystemTypesCache(options = {}) {
|
|
|
10
10
|
mkdirSync(dir, { recursive: true });
|
|
11
11
|
},
|
|
12
12
|
read(code) {
|
|
13
|
-
const
|
|
13
|
+
const hash = createHash("SHA256").update(code).digest("hex").slice(0, 12);
|
|
14
|
+
const filePath = join(dir, `${hash}.json`);
|
|
14
15
|
if (!existsSync(filePath)) return null;
|
|
15
16
|
return JSON.parse(readFileSync(filePath, { encoding: "utf-8" }));
|
|
16
17
|
},
|
|
17
18
|
write(code, data) {
|
|
18
|
-
|
|
19
|
+
const hash = createHash("SHA256").update(code).digest("hex").slice(0, 12);
|
|
20
|
+
const filePath = join(dir, `${hash}.json`);
|
|
21
|
+
const json = JSON.stringify(data);
|
|
22
|
+
writeFileSync(filePath, json, { encoding: "utf-8" });
|
|
19
23
|
}
|
|
20
24
|
};
|
|
21
25
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { t as VitePressPluginTwoslashOptions } from "../types-
|
|
1
|
+
import { t as VitePressPluginTwoslashOptions } from "../types-6hqHJcLR.mjs";
|
|
2
2
|
import { UserConfig } from "vitepress";
|
|
3
|
-
|
|
4
3
|
//#region src/cache-inline/markdown-fence.d.ts
|
|
5
4
|
interface MarkdownFenceSourceMap {
|
|
6
5
|
path: string;
|
|
@@ -41,9 +40,6 @@ interface TwoslashInlineCacheOptions {
|
|
|
41
40
|
/**
|
|
42
41
|
* @experimental This API is experimental and may be changed in the future.
|
|
43
42
|
*/
|
|
44
|
-
declare function createTwoslashWithInlineCache(twoslashOptions?: VitePressPluginTwoslashOptions, {
|
|
45
|
-
sourceMapper,
|
|
46
|
-
sourceMapCodec
|
|
47
|
-
}?: TwoslashInlineCacheOptions): (config: UserConfig) => UserConfig;
|
|
43
|
+
declare function createTwoslashWithInlineCache(twoslashOptions?: VitePressPluginTwoslashOptions, { sourceMapper, sourceMapCodec }?: TwoslashInlineCacheOptions): (config: UserConfig) => UserConfig;
|
|
48
44
|
//#endregion
|
|
49
45
|
export { TwoslashInlineCacheOptions, createTwoslashWithInlineCache };
|
|
@@ -35,7 +35,8 @@ var FilePatcher = class {
|
|
|
35
35
|
if (to !== void 0) s.update(from, to, value);
|
|
36
36
|
else s.appendRight(from, value);
|
|
37
37
|
}
|
|
38
|
-
|
|
38
|
+
const content = s.toString();
|
|
39
|
+
writeFileSync(path, content, { encoding: "utf-8" });
|
|
39
40
|
}
|
|
40
41
|
this.files.delete(path);
|
|
41
42
|
}
|
|
@@ -137,7 +138,8 @@ function createInlineTypesCache({ remove, ignoreCache } = {}) {
|
|
|
137
138
|
meta?.__patch?.("");
|
|
138
139
|
return;
|
|
139
140
|
}
|
|
140
|
-
const
|
|
141
|
+
const twoslashShiki = simplifyTwoslashReturn(data);
|
|
142
|
+
const cacheStr = `// ${CODE_INLINE_CACHE_KEY}: ${stringifyCachePayload(twoslashShiki, code, lang, options)}`;
|
|
141
143
|
meta?.__patch?.(cacheStr);
|
|
142
144
|
}
|
|
143
145
|
},
|
|
@@ -176,7 +178,8 @@ function createMarkdownFenceSourceCodec(mapper) {
|
|
|
176
178
|
const FENCE_SOURCE_WRAP = `<fsm-${Math.random().toString(36).slice(2)}>`;
|
|
177
179
|
const FENCE_SOURCE_REGEX = new RegExp(`\/\/ ${FENCE_SOURCE_WRAP}(.+?)${FENCE_SOURCE_WRAP}\\n`);
|
|
178
180
|
function stringifyFenceSourceMap(sourceMap) {
|
|
179
|
-
|
|
181
|
+
const data = JSON.stringify(sourceMap);
|
|
182
|
+
return `// ${FENCE_SOURCE_WRAP}${data}${FENCE_SOURCE_WRAP}\n`;
|
|
180
183
|
}
|
|
181
184
|
function injectToMarkdown(code, path) {
|
|
182
185
|
const injects = mapper(code, path);
|
package/dist/client.d.mts
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { a as rendererFloatingVue, i as defaultHoverInfoProcessor, n as TwoslashFloatingVueOptions, r as TwoslashFloatingVueRendererOptions, t as VitePressPluginTwoslashOptions } from "./types-
|
|
1
|
+
import { a as rendererFloatingVue, i as defaultHoverInfoProcessor, n as TwoslashFloatingVueOptions, r as TwoslashFloatingVueRendererOptions, t as VitePressPluginTwoslashOptions } from "./types-6hqHJcLR.mjs";
|
|
2
2
|
import { ShikiTransformer } from "shiki";
|
|
3
|
-
|
|
4
3
|
//#region src/index.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* Create a Shiki transformer for VitePress to enable twoslash integration
|
package/dist/index.mjs
CHANGED
|
@@ -86,7 +86,8 @@ function vPre(el) {
|
|
|
86
86
|
return el;
|
|
87
87
|
}
|
|
88
88
|
function renderMarkdown(md) {
|
|
89
|
-
|
|
89
|
+
const mdast = fromMarkdown(md.replace(RE_JSDOC_LINK, "$1"), { mdastExtensions: [gfmFromMarkdown()] });
|
|
90
|
+
return toHast(mdast, { handlers: { code: (state, node) => {
|
|
90
91
|
const lang = node.lang || "";
|
|
91
92
|
if (lang) return {
|
|
92
93
|
type: "element",
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { TransformerTwoslashOptions } from "@shikijs/twoslash/core";
|
|
2
2
|
import { VueSpecificOptions } from "twoslash-vue";
|
|
3
3
|
import { RendererRichOptions, TwoslashRenderer, defaultHoverInfoProcessor } from "@shikijs/twoslash";
|
|
4
|
-
|
|
5
4
|
//#region src/renderer-floating-vue.d.ts
|
|
6
5
|
interface TwoslashFloatingVueOptions {
|
|
7
6
|
classCopyIgnore?: string;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shikijs/vitepress-twoslash",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.4.0",
|
|
5
5
|
"description": "Enable Twoslash support in VitePress",
|
|
6
6
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -40,16 +40,16 @@
|
|
|
40
40
|
"floating-vue": "^5.2.2",
|
|
41
41
|
"lz-string": "^1.5.0",
|
|
42
42
|
"magic-string": "^0.30.21",
|
|
43
|
-
"markdown-it": "^14.
|
|
43
|
+
"markdown-it": "^14.3.0",
|
|
44
44
|
"mdast-util-from-markdown": "^2.0.3",
|
|
45
45
|
"mdast-util-gfm": "^3.1.0",
|
|
46
46
|
"mdast-util-to-hast": "^13.2.1",
|
|
47
47
|
"ohash": "^2.0.11",
|
|
48
48
|
"twoslash": "^0.3.9",
|
|
49
49
|
"twoslash-vue": "^0.3.9",
|
|
50
|
-
"vue": "^3.5.
|
|
51
|
-
"@shikijs/twoslash": "4.
|
|
52
|
-
"shiki": "4.
|
|
50
|
+
"vue": "^3.5.40",
|
|
51
|
+
"@shikijs/twoslash": "4.4.0",
|
|
52
|
+
"shiki": "4.4.0"
|
|
53
53
|
},
|
|
54
54
|
"scripts": {
|
|
55
55
|
"build": "tsdown",
|