@vmz/plugin-shiki 0.2.3 → 0.2.5
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/components/Shiki.vmz +10 -11
- package/dist/runtime.d.ts +3 -1
- package/dist/runtime.js +3 -2
- package/package.json +3 -3
package/components/Shiki.vmz
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
|
|
2
|
+
<div v-html="html != null ? html : highlightSync(code, lang, theme)" class="shiki-host" />
|
|
3
3
|
</template>
|
|
4
|
-
|
|
5
4
|
<script client>
|
|
6
|
-
import { highlight, highlightSync } from
|
|
5
|
+
import { highlight, highlightSync } from "@vmz/plugin-shiki/runtime";
|
|
7
6
|
|
|
8
7
|
export default class Shiki {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
public code: string = "";
|
|
9
|
+
public lang: string = "text";
|
|
10
|
+
public theme: string = "vitesse-dark";
|
|
12
11
|
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
/** null → sync fallback / prewarm cache; set after async highlight. */
|
|
13
|
+
html: string | null = null;
|
|
15
14
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
async onMount() {
|
|
16
|
+
this.html = await highlight(this.code, this.lang, this.theme);
|
|
17
|
+
}
|
|
19
18
|
}
|
|
20
19
|
</script>
|
package/dist/runtime.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export type ShikiRuntimeConfig = {
|
|
|
9
9
|
/** Default themes passed to the textmate highlighter factory. */
|
|
10
10
|
themes?: string[];
|
|
11
11
|
};
|
|
12
|
+
type CodeHighlighter = Pick<Highlighter, 'codeToHtml'>;
|
|
12
13
|
/** @internal test hook */
|
|
13
14
|
export declare function getShikiRuntimeConfig(): Readonly<ShikiRuntimeConfig>;
|
|
14
15
|
/** Reset module state (tests). */
|
|
@@ -19,7 +20,8 @@ export declare function resetShikiRuntimeForTests(): void;
|
|
|
19
20
|
export declare function configureShiki(opts: ShikiRuntimeConfig): void;
|
|
20
21
|
export declare function prewarmShiki(opts?: {
|
|
21
22
|
themes?: string[];
|
|
22
|
-
}): Promise<
|
|
23
|
+
}): Promise<CodeHighlighter>;
|
|
23
24
|
export declare function highlight(code: string, lang?: string, theme?: string): Promise<string>;
|
|
24
25
|
/** Sync highlight when prewarmed; otherwise escaped `<pre><code>`. */
|
|
25
26
|
export declare function highlightSync(code: string, lang?: string, theme?: string): string;
|
|
27
|
+
export {};
|
package/dist/runtime.js
CHANGED
|
@@ -80,7 +80,7 @@ function textmateSpec() {
|
|
|
80
80
|
async function loadTextmateHighlighter(themes) {
|
|
81
81
|
const spec = textmateSpec();
|
|
82
82
|
try {
|
|
83
|
-
const mod = (await import(/* webpackIgnore: true */ spec));
|
|
83
|
+
const mod = (spec === DEFAULT_TEXTMATE ? await import('vmz-textmate/shiki') : await import(/* webpackIgnore: true */ spec));
|
|
84
84
|
const factory = mod.createVmzHighlighter ?? mod.createHighlighter ?? mod.default?.createVmzHighlighter;
|
|
85
85
|
if (typeof factory === 'function') {
|
|
86
86
|
return factory({ themes, langs: [] });
|
|
@@ -92,7 +92,8 @@ async function loadTextmateHighlighter(themes) {
|
|
|
92
92
|
return null;
|
|
93
93
|
}
|
|
94
94
|
async function loadGenericHighlighter(themes) {
|
|
95
|
-
const
|
|
95
|
+
const genericPackage = 'shiki';
|
|
96
|
+
const { createHighlighter } = await import(genericPackage);
|
|
96
97
|
return createHighlighter({
|
|
97
98
|
themes,
|
|
98
99
|
langs: ['javascript', 'typescript', 'tsx', 'jsx', 'json', 'html', 'css', 'markdown', 'bash', 'text'],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vmz/plugin-shiki",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "VMZ Shiki adapter - <Shiki> + code engine registration",
|
|
6
6
|
"license": "MIT",
|
|
@@ -25,11 +25,11 @@
|
|
|
25
25
|
"build": "tsc -p tsconfig.json"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@vmz/plugin": "0.2.
|
|
28
|
+
"@vmz/plugin": "0.2.5"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"shiki": ">=3",
|
|
32
|
-
"vmz-textmate": "0.2.
|
|
32
|
+
"vmz-textmate": "0.2.5"
|
|
33
33
|
},
|
|
34
34
|
"peerDependenciesMeta": {
|
|
35
35
|
"shiki": {
|