@bikariya/shiki 0.0.4 → 0.0.6
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/README.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# @bikariya/shiki
|
|
2
|
+
|
|
3
|
+
Shiki 集成,基于 [Pinia](https://pinia.vuejs.org)。
|
|
4
|
+
|
|
5
|
+
## 安装
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm i -D @bikariya/shiki
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## 使用方式
|
|
12
|
+
|
|
13
|
+
1. 在 `nuxt.config.ts` 中添加模块:
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
export default defineNuxtConfig({
|
|
17
|
+
modules: [
|
|
18
|
+
"@bikariya/shiki",
|
|
19
|
+
],
|
|
20
|
+
});
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
2. 在 `app` 目录下创建 `shiki.config.ts`:
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import { defineConfig } from "#shiki/config";
|
|
27
|
+
|
|
28
|
+
export default defineConfig({
|
|
29
|
+
themes: {
|
|
30
|
+
light: () => import("shiki/themes/min-light.mjs"),
|
|
31
|
+
dark: () => import("shiki/themes/min-dark.mjs"),
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
3. 参照[集成示例](/playground/app/components/simple-shiki.vue)。
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineNuxtModule, createResolver,
|
|
1
|
+
import { defineNuxtModule, createResolver, addImportsSources } from '@nuxt/kit';
|
|
2
2
|
|
|
3
3
|
const name = "@bikariya/shiki";
|
|
4
4
|
const packageJson = {
|
|
@@ -14,7 +14,12 @@ const module$1 = defineNuxtModule({
|
|
|
14
14
|
},
|
|
15
15
|
setup(options, nuxt) {
|
|
16
16
|
const resolver = createResolver(import.meta.url);
|
|
17
|
-
|
|
17
|
+
addImportsSources({
|
|
18
|
+
from: resolver.resolve("runtime/store"),
|
|
19
|
+
imports: [
|
|
20
|
+
"useShikiStore"
|
|
21
|
+
]
|
|
22
|
+
});
|
|
18
23
|
nuxt.options.alias["#shiki/config"] = resolver.resolve("runtime/config");
|
|
19
24
|
}
|
|
20
25
|
});
|
|
@@ -28,11 +28,16 @@ export const useShikiStore = defineStore("shiki", () => {
|
|
|
28
28
|
]);
|
|
29
29
|
let engine;
|
|
30
30
|
try {
|
|
31
|
-
void
|
|
31
|
+
void new RegExp("(?i: )");
|
|
32
32
|
engine = createJavaScriptRegexEngine();
|
|
33
33
|
} catch {
|
|
34
|
-
const { createOnigurumaEngine } = await
|
|
35
|
-
|
|
34
|
+
const [{ createOnigurumaEngine }, wasm] = await Promise.all([
|
|
35
|
+
// @ts-expect-error TS2307
|
|
36
|
+
import("https://esm.sh/shiki/engine-oniguruma.mjs"),
|
|
37
|
+
// @ts-expect-error TS2307
|
|
38
|
+
import("https://esm.sh/shiki/wasm")
|
|
39
|
+
]);
|
|
40
|
+
engine = await createOnigurumaEngine(wasm);
|
|
36
41
|
}
|
|
37
42
|
Object.assign(options, {
|
|
38
43
|
...config,
|
package/package.json
CHANGED
|
File without changes
|