@vixt/vitepress 0.5.16 → 0.6.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.
@@ -0,0 +1,8 @@
1
+ import "virtual:vixt:css";
2
+ import "uno.css";
3
+ import { Theme } from "vitepress";
4
+
5
+ //#region src/client/entry.d.ts
6
+ declare const _default: Theme;
7
+ //#endregion
8
+ export { _default as default };
@@ -0,0 +1,25 @@
1
+ import "virtual:vixt:css";
2
+ import "uno.css";
3
+ import { applyPlugins, createVixtApp } from "@vixt/core/client";
4
+ import appConfig from "virtual:vixt:app-config";
5
+ import plugins from "virtual:vixt:plugins";
6
+ import DefaultTheme from "vitepress/theme";
7
+
8
+ //#region src/client/entry.ts
9
+ var entry_default = {
10
+ extends: DefaultTheme,
11
+ async enhanceApp(ctx) {
12
+ const vixt = createVixtApp({
13
+ ...ctx,
14
+ appConfig
15
+ });
16
+ try {
17
+ await applyPlugins(vixt, plugins);
18
+ } catch (err) {
19
+ console.error(err);
20
+ }
21
+ }
22
+ };
23
+
24
+ //#endregion
25
+ export { entry_default as default };
package/dist/index.d.mts CHANGED
@@ -1,46 +1,7 @@
1
- import * as vite from 'vite';
2
- import * as _vixt_core from '@vixt/core';
3
- import { AppOptions, Vixt, PluginOptions as PluginOptions$1, VixtOptions } from '@vixt/core';
4
- import { Pinia } from 'pinia';
5
- import { PluginOptions } from 'pinia-plugin-persistedstate';
6
- import { EnhanceAppContext } from 'vitepress';
7
- import UnoCSS from 'unocss/vite';
8
- import AutoImport from 'unplugin-auto-import/vite';
9
- import Components from 'unplugin-vue-components/vite';
10
- import VueDevTools from 'vite-plugin-vue-devtools';
1
+ import * as _vixt_core0 from "@vixt/core";
2
+ import * as vite0 from "vite";
11
3
 
12
- declare module '@vixt/core/client' {
13
- interface VixtAppConfig {
14
- /** https://github.com/prazdevs/pinia-plugin-persistedstate */
15
- piniaPersistedState?: PluginOptions
16
- }
17
-
18
- interface VixtApp extends EnhanceAppContext {
19
- pinia: Pinia
20
- appConfig: VixtAppConfig
21
- }
22
- }
23
-
24
- declare const appVitepress: _vixt_core.VixtModule<AppOptions>;
25
-
26
- declare function generateMainTs(options: AppOptions, vixt: Vixt): string;
27
-
28
- declare module '@vixt/core' {
29
- interface VixtOptions {
30
- /** https://github.com/antfu/unplugin-vue-components */
31
- components?: PluginOptions$1<typeof Components>;
32
- /** https://github.com/antfu/unplugin-auto-import */
33
- imports?: PluginOptions$1<typeof AutoImport>;
34
- /** https://github.com/antfu/unocss */
35
- unocss?: PluginOptions$1<typeof UnoCSS>;
36
- /** https://github.com/webfansplz/vite-plugin-vue-devtools */
37
- devtools?: PluginOptions$1<typeof VueDevTools> & {
38
- enabled?: boolean;
39
- };
40
- }
41
- }
42
- declare const presetVitepress: _vixt_core.VixtModule<VixtOptions>;
43
-
44
- declare const _default: (options?: VixtOptions | undefined) => vite.PluginOption;
45
-
46
- export { appVitepress, _default as default, generateMainTs, presetVitepress };
4
+ //#region src/index.d.ts
5
+ declare const _default: (options?: _vixt_core0.VixtOptions | undefined) => vite0.PluginOption;
6
+ //#endregion
7
+ export { _default as default };
package/dist/index.mjs CHANGED
@@ -1,116 +1,100 @@
1
- import { generateClient, generateCss, generateAppConfig, generatePlugins, defineVixtModule, resolveLayersDirs, createVixtPlugin } from '@vixt/core';
2
- import path from 'pathe';
3
- import fs from 'fs-extra';
4
- import defu from 'defu';
5
- import UnoCSS from 'unocss/vite';
6
- import AutoImport from 'unplugin-auto-import/vite';
7
- import Components from 'unplugin-vue-components/vite';
8
- import { VueRouterAutoImports } from 'unplugin-vue-router';
9
- import VueDevTools from 'vite-plugin-vue-devtools';
1
+ import { cwd } from "node:process";
2
+ import { VixtClientAutoImports, createVixtPlugin, defineVitePlugin, defineVixtModule, resolveLayersDirs } from "@vixt/core";
3
+ import fs from "fs-extra";
4
+ import { resolvePathSync } from "mlly";
5
+ import path from "pathe";
6
+ import defu from "defu";
7
+ import UnoCSS from "unocss/vite";
8
+ import AutoImport from "unplugin-auto-import/vite";
9
+ import Components from "unplugin-vue-components/vite";
10
+ import { VueRouterAutoImports } from "unplugin-vue-router";
11
+ import VueDevTools from "vite-plugin-vue-devtools";
10
12
 
11
- function generateMainTs(options, vixt) {
12
- const { buildDir } = vixt.options;
13
- const mainTsPath = path.resolve(".vitepress/theme/index.ts");
14
- if (!fs.existsSync(mainTsPath))
15
- fs.outputFileSync(mainTsPath, `// Generated by Vixt
16
- // This file transform from '${path.basename(buildDir)}/main.ts'
17
- `);
18
- generateClient(vixt);
19
- const cssTemplate = generateCss(options);
20
- const appConfigTemplate = generateAppConfig(vixt);
21
- const pluginsTemplate = generatePlugins(vixt);
22
- const code = `// Generated by Vixt
23
- // This file transform to '.vitepress/theme/index.ts'
24
- // @ts-nocheck
25
- ${cssTemplate}
26
- ${appConfigTemplate}
27
- ${pluginsTemplate}
28
-
29
- import 'uno.css'
30
- import { createPinia } from 'pinia'
31
- import { createPersistedState } from 'pinia-plugin-persistedstate'
32
- import DefaultTheme from 'vitepress/theme'
33
-
34
- export default {
35
- extends: DefaultTheme,
36
- enhanceApp(ctx) {
37
- const pinia = createPinia()
38
- pinia.use(createPersistedState(appConfig.piniaPersistedState))
39
- ctx.app.use(pinia)
40
- usePlugins({ ...ctx, pinia, appConfig })
41
- },
42
- }
43
- `;
44
- fs.outputFileSync(path.resolve(buildDir, "main.ts"), code);
45
- return code;
46
- }
47
-
48
- const name$1 = "vixt:app-vitepress";
49
- const defaults$1 = {
50
- css: []
51
- };
52
- const appVitepress = defineVixtModule({
53
- meta: { name: name$1, configKey: "app" },
54
- defaults: defaults$1,
55
- setup(options, vixt) {
56
- let mainTsCode;
57
- const mainTsPath = path.resolve(".vitepress/theme/index.ts");
58
- return {
59
- name: name$1,
60
- configResolved() {
61
- mainTsCode = generateMainTs(options, vixt);
62
- },
63
- transform: {
64
- order: "pre",
65
- handler(_, id) {
66
- if (id !== mainTsPath)
67
- return;
68
- return mainTsCode;
69
- }
70
- }
71
- };
72
- }
13
+ //#region src/modules/config-patch.ts
14
+ var config_patch_default = defineVitePlugin(() => {
15
+ return {
16
+ name: "vixt:config-patch",
17
+ config(config) {
18
+ const siteBase = config.vitepress?.userConfig?.base;
19
+ if (siteBase) return { base: siteBase };
20
+ },
21
+ configResolved(config) {
22
+ for (const plugin of config.plugins) if (plugin.name === "vixt:app") delete plugin.transformIndexHtml;
23
+ }
24
+ };
73
25
  });
74
26
 
27
+ //#endregion
28
+ //#region src/modules/preset-vitepress.ts
75
29
  const name = "vixt:preset-vitepress";
76
- const presetVitepress = defineVixtModule({
77
- meta: { name },
78
- async setup(_, vixt) {
79
- const { components = [], composables = [], constants = [], utils = [], stores = [] } = resolveLayersDirs([...vixt._layers].reverse());
80
- const { buildTypesDir, buildImportsDir } = vixt.options;
81
- const defaultOptions = {
82
- components: {
83
- dts: `${buildTypesDir}/components.d.ts`,
84
- dirs: [...components].reverse(),
85
- directoryAsNamespace: true,
86
- collapseSamePrefixes: true,
87
- extensions: ["vue", "md"],
88
- include: [/\.vue$/, /\.vue\?vue/, /\.md$/]
89
- },
90
- imports: {
91
- include: [/\.[jt]sx?$/, /\.vue$/, /\.vue\?vue/, /\.md/, /\.md\?md/],
92
- imports: ["vue", "@vueuse/core", "pinia", VueRouterAutoImports],
93
- dts: `${buildTypesDir}/auto-imports.d.ts`,
94
- dirs: [composables, constants, stores, utils, buildImportsDir].flat(),
95
- vueTemplate: true
96
- },
97
- unocss: {},
98
- devtools: { enabled: false }
99
- };
100
- const options = vixt.options = defu(vixt.options, defaultOptions);
101
- const plugins = [
102
- Components(options.components),
103
- AutoImport(options.imports),
104
- UnoCSS(options.unocss),
105
- options.devtools?.enabled && VueDevTools(options.devtools)
106
- ];
107
- return plugins;
108
- }
30
+ var preset_vitepress_default = defineVixtModule({
31
+ meta: { name },
32
+ async setup(_, vixt) {
33
+ const { components = [], composables = [], constants = [], utils = [], stores = [] } = resolveLayersDirs([...vixt._layers].reverse());
34
+ const { buildTypesDir } = vixt.options;
35
+ const defaultOptions = {
36
+ components: {
37
+ dts: `${buildTypesDir}/components.d.ts`,
38
+ dirs: [...components].reverse(),
39
+ directoryAsNamespace: true,
40
+ collapseSamePrefixes: true,
41
+ extensions: ["vue", "md"],
42
+ include: [
43
+ /\.vue$/,
44
+ /\.vue\?vue/,
45
+ /\.md$/
46
+ ]
47
+ },
48
+ imports: {
49
+ include: [
50
+ /\.[jt]sx?$/,
51
+ /\.vue$/,
52
+ /\.vue\?vue/,
53
+ /\.md/,
54
+ /\.md\?md/
55
+ ],
56
+ imports: [
57
+ "vue",
58
+ "@vueuse/core",
59
+ "pinia",
60
+ VueRouterAutoImports,
61
+ VixtClientAutoImports
62
+ ],
63
+ dts: `${buildTypesDir}/auto-imports.d.ts`,
64
+ dirs: [
65
+ composables,
66
+ constants,
67
+ stores,
68
+ utils
69
+ ].flat(),
70
+ vueTemplate: true
71
+ },
72
+ unocss: {},
73
+ devtools: { enabled: false }
74
+ };
75
+ const options = vixt.options = defu(vixt.options, defaultOptions);
76
+ return [
77
+ Components(options.components),
78
+ AutoImport(options.imports),
79
+ UnoCSS(options.unocss),
80
+ options.devtools?.enabled && VueDevTools(options.devtools),
81
+ config_patch_default()
82
+ ];
83
+ }
109
84
  });
110
85
 
111
- const defaults = {
112
- modules: [appVitepress, presetVitepress]
113
- };
114
- const index = createVixtPlugin({ defaults });
86
+ //#endregion
87
+ //#region src/index.ts
88
+ var src_default = createVixtPlugin({ defaults: {
89
+ srcDir: path.resolve(cwd(), ".vitepress/theme"),
90
+ modules: [preset_vitepress_default],
91
+ plugins: ["@vixt/vitepress/client/plugins/pinia"],
92
+ app: {
93
+ entryFile: "index.ts",
94
+ entryCode: fs.readFileSync(resolvePathSync("@vixt/vitepress/client/entry"), "utf-8")
95
+ },
96
+ typescript: { tsConfig: { compilerOptions: { types: ["@vixt/vitepress/types"] } } }
97
+ } });
115
98
 
116
- export { appVitepress, index as default, generateMainTs, presetVitepress };
99
+ //#endregion
100
+ export { src_default as default };
@@ -0,0 +1,15 @@
1
+ import type { Pinia } from 'pinia'
2
+ import type { PluginOptions as PersistedStateOptions } from 'pinia-plugin-persistedstate'
3
+ import type { EnhanceAppContext } from 'vitepress'
4
+
5
+ declare module '@vixt/core/client' {
6
+ interface VixtAppConfig {
7
+ /** https://github.com/prazdevs/pinia-plugin-persistedstate */
8
+ piniaPersistedState?: PersistedStateOptions
9
+ }
10
+
11
+ interface VixtApp extends EnhanceAppContext {
12
+ pinia: Pinia
13
+ appConfig: VixtAppConfig
14
+ }
15
+ }
@@ -0,0 +1,2 @@
1
+ import './client.d'
2
+ import './node.d'
@@ -0,0 +1,25 @@
1
+ import type { ExtractPluginOptions } from '@vixt/core'
2
+ import type UnoCSS from 'unocss/vite'
3
+ import type AutoImport from 'unplugin-auto-import/vite'
4
+ import type Components from 'unplugin-vue-components/vite'
5
+ import type VueDevTools from 'vite-plugin-vue-devtools'
6
+ import type { SiteConfig } from 'vitepress'
7
+
8
+ declare module '@vixt/core' {
9
+ interface VixtOptions {
10
+ /** https://github.com/antfu/unplugin-vue-components */
11
+ components?: ExtractPluginOptions<typeof Components>
12
+ /** https://github.com/antfu/unplugin-auto-import */
13
+ imports?: ExtractPluginOptions<typeof AutoImport>
14
+ /** https://github.com/antfu/unocss */
15
+ unocss?: ExtractPluginOptions<typeof UnoCSS>
16
+ /** https://github.com/webfansplz/vite-plugin-vue-devtools */
17
+ devtools?: ExtractPluginOptions<typeof VueDevTools> & { enabled?: boolean }
18
+ }
19
+ }
20
+
21
+ declare module 'vite' {
22
+ interface UserConfig {
23
+ vitepress?: SiteConfig
24
+ }
25
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vixt/vitepress",
3
3
  "type": "module",
4
- "version": "0.5.16",
4
+ "version": "0.6.0",
5
5
  "author": "SoulLyoko<https://github.com/SoulLyoko>",
6
6
  "license": "MIT",
7
7
  "homepage": "https://soullyoko.github.io/vixt/",
@@ -12,23 +12,19 @@
12
12
  "vitepress"
13
13
  ],
14
14
  "exports": {
15
- ".": {
16
- "types": "./dist/index.d.ts",
17
- "import": "./dist/index.mjs"
18
- }
15
+ ".": "./dist/index.mjs",
16
+ "./client/*": "./dist/client/*.js",
17
+ "./types": "./dist/types/index.d.ts",
18
+ "./package.json": "./package.json"
19
19
  },
20
- "main": "dist/index.mjs",
21
- "types": "dist/index.d.ts",
20
+ "main": "./dist/index.mjs",
21
+ "types": "./dist/types/index.d.ts",
22
22
  "files": [
23
23
  "dist"
24
24
  ],
25
25
  "dependencies": {
26
26
  "vitepress": "^1.6.4",
27
- "@vixt/core": "0.5.16",
28
- "@vixt/vue": "0.5.16"
29
- },
30
- "scripts": {
31
- "build": "unbuild",
32
- "dev": "unbuild --stub"
27
+ "@vixt/vue": "0.6.0",
28
+ "@vixt/core": "0.6.0"
33
29
  }
34
30
  }
package/dist/index.d.ts DELETED
@@ -1,46 +0,0 @@
1
- import * as vite from 'vite';
2
- import * as _vixt_core from '@vixt/core';
3
- import { AppOptions, Vixt, PluginOptions as PluginOptions$1, VixtOptions } from '@vixt/core';
4
- import { Pinia } from 'pinia';
5
- import { PluginOptions } from 'pinia-plugin-persistedstate';
6
- import { EnhanceAppContext } from 'vitepress';
7
- import UnoCSS from 'unocss/vite';
8
- import AutoImport from 'unplugin-auto-import/vite';
9
- import Components from 'unplugin-vue-components/vite';
10
- import VueDevTools from 'vite-plugin-vue-devtools';
11
-
12
- declare module '@vixt/core/client' {
13
- interface VixtAppConfig {
14
- /** https://github.com/prazdevs/pinia-plugin-persistedstate */
15
- piniaPersistedState?: PluginOptions
16
- }
17
-
18
- interface VixtApp extends EnhanceAppContext {
19
- pinia: Pinia
20
- appConfig: VixtAppConfig
21
- }
22
- }
23
-
24
- declare const appVitepress: _vixt_core.VixtModule<AppOptions>;
25
-
26
- declare function generateMainTs(options: AppOptions, vixt: Vixt): string;
27
-
28
- declare module '@vixt/core' {
29
- interface VixtOptions {
30
- /** https://github.com/antfu/unplugin-vue-components */
31
- components?: PluginOptions$1<typeof Components>;
32
- /** https://github.com/antfu/unplugin-auto-import */
33
- imports?: PluginOptions$1<typeof AutoImport>;
34
- /** https://github.com/antfu/unocss */
35
- unocss?: PluginOptions$1<typeof UnoCSS>;
36
- /** https://github.com/webfansplz/vite-plugin-vue-devtools */
37
- devtools?: PluginOptions$1<typeof VueDevTools> & {
38
- enabled?: boolean;
39
- };
40
- }
41
- }
42
- declare const presetVitepress: _vixt_core.VixtModule<VixtOptions>;
43
-
44
- declare const _default: (options?: VixtOptions | undefined) => vite.PluginOption;
45
-
46
- export { appVitepress, _default as default, generateMainTs, presetVitepress };