@vixt/vitepress 0.1.19

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 SoulLyoko
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,31 @@
1
+ import * as vite from 'vite';
2
+ import * as _vixt_core from '@vixt/core';
3
+ import { Vixt, PluginOptions, VixtOptions } from '@vixt/core';
4
+ import { AppOptions } from '@vixt/vue';
5
+ import UnoCSS from 'unocss/vite';
6
+ import AutoImport from 'unplugin-auto-import/vite';
7
+ import Components from 'unplugin-vue-components/vite';
8
+ import VueDevTools from 'vite-plugin-vue-devtools';
9
+
10
+ declare function generateMainTs(options: AppOptions, vixt: Vixt): string;
11
+ declare const appVitepress: _vixt_core.VixtModule<AppOptions>;
12
+
13
+ declare module '@vixt/core' {
14
+ interface VixtOptions {
15
+ /** https://github.com/antfu/unplugin-vue-components */
16
+ components?: PluginOptions<typeof Components>;
17
+ /** https://github.com/antfu/unplugin-auto-import */
18
+ imports?: PluginOptions<typeof AutoImport>;
19
+ /** https://github.com/antfu/unocss */
20
+ unocss?: PluginOptions<typeof UnoCSS>;
21
+ /** https://github.com/webfansplz/vite-plugin-vue-devtools */
22
+ devtools?: PluginOptions<typeof VueDevTools> & {
23
+ enabled?: boolean;
24
+ };
25
+ }
26
+ }
27
+ declare const presetVitepress: _vixt_core.VixtModule<VixtOptions>;
28
+
29
+ declare const _default: (options?: VixtOptions | undefined) => vite.PluginOption;
30
+
31
+ export { appVitepress, _default as default, generateMainTs, presetVitepress };
@@ -0,0 +1,31 @@
1
+ import * as vite from 'vite';
2
+ import * as _vixt_core from '@vixt/core';
3
+ import { Vixt, PluginOptions, VixtOptions } from '@vixt/core';
4
+ import { AppOptions } from '@vixt/vue';
5
+ import UnoCSS from 'unocss/vite';
6
+ import AutoImport from 'unplugin-auto-import/vite';
7
+ import Components from 'unplugin-vue-components/vite';
8
+ import VueDevTools from 'vite-plugin-vue-devtools';
9
+
10
+ declare function generateMainTs(options: AppOptions, vixt: Vixt): string;
11
+ declare const appVitepress: _vixt_core.VixtModule<AppOptions>;
12
+
13
+ declare module '@vixt/core' {
14
+ interface VixtOptions {
15
+ /** https://github.com/antfu/unplugin-vue-components */
16
+ components?: PluginOptions<typeof Components>;
17
+ /** https://github.com/antfu/unplugin-auto-import */
18
+ imports?: PluginOptions<typeof AutoImport>;
19
+ /** https://github.com/antfu/unocss */
20
+ unocss?: PluginOptions<typeof UnoCSS>;
21
+ /** https://github.com/webfansplz/vite-plugin-vue-devtools */
22
+ devtools?: PluginOptions<typeof VueDevTools> & {
23
+ enabled?: boolean;
24
+ };
25
+ }
26
+ }
27
+ declare const presetVitepress: _vixt_core.VixtModule<VixtOptions>;
28
+
29
+ declare const _default: (options?: VixtOptions | undefined) => vite.PluginOption;
30
+
31
+ export { appVitepress, _default as default, generateMainTs, presetVitepress };
package/dist/index.mjs ADDED
@@ -0,0 +1,107 @@
1
+ import { defineVixtModule, resolveLayersDirs, createVixtPlugin } from '@vixt/core';
2
+ import { generateCss, generateAppConfig, generatePlugins } from '@vixt/vue';
3
+ import fs from 'fs-extra';
4
+ import path from 'pathe';
5
+ import defu from 'defu';
6
+ import UnoCSS from 'unocss/vite';
7
+ import AutoImport from 'unplugin-auto-import/vite';
8
+ import Components from 'unplugin-vue-components/vite';
9
+ import VueDevTools from 'vite-plugin-vue-devtools';
10
+
11
+ function generateMainTs(options, vixt) {
12
+ const { buildDir, buildDirName } = 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 '${buildDirName}/main.ts'
17
+ `);
18
+ const cssTemplate = generateCss(options);
19
+ const appConfigTemplate = generateAppConfig(vixt);
20
+ const pluginsTemplate = generatePlugins(vixt);
21
+ const code = `// Generated by Vixt
22
+ // This file transform to '.vitepress/theme/index.ts'
23
+ // @ts-nocheck
24
+ ${cssTemplate}
25
+ ${appConfigTemplate}
26
+ ${pluginsTemplate}
27
+
28
+ import 'uno.css'
29
+ import DefaultTheme from 'vitepress/theme'
30
+
31
+ export default {
32
+ extends: DefaultTheme,
33
+ enhanceApp(ctx) {
34
+ usePlugins({ ...ctx, appConfig })
35
+ },
36
+ }
37
+ `;
38
+ fs.outputFileSync(path.resolve(buildDir, "main.ts"), code);
39
+ return code;
40
+ }
41
+ const name = "vixt:app";
42
+ const defaults$1 = {
43
+ css: []
44
+ };
45
+ const appVitepress = defineVixtModule({
46
+ meta: { name, configKey: "app" },
47
+ defaults: defaults$1,
48
+ setup(options, vixt) {
49
+ let mainTsCode;
50
+ const mainTsPath = path.resolve(".vitepress/theme/index.ts");
51
+ return {
52
+ name,
53
+ configResolved() {
54
+ mainTsCode = generateMainTs(options, vixt);
55
+ },
56
+ transform: {
57
+ order: "pre",
58
+ handler(_, id) {
59
+ if (id !== mainTsPath)
60
+ return;
61
+ return mainTsCode;
62
+ }
63
+ }
64
+ };
65
+ }
66
+ });
67
+
68
+ const presetVitepress = defineVixtModule({
69
+ async setup(_, vixt) {
70
+ const { components, composables = [], constants = [], utils = [], stores = [] } = resolveLayersDirs(vixt._layers, vixt.options);
71
+ const { buildTypesDir, buildImportsDir } = vixt.options;
72
+ const defaultOptions = {
73
+ components: {
74
+ dts: `${buildTypesDir}/components.d.ts`,
75
+ dirs: components,
76
+ directoryAsNamespace: true,
77
+ collapseSamePrefixes: true,
78
+ extensions: ["vue", "md"],
79
+ include: [/\.vue$/, /\.vue\?vue/, /\.md$/]
80
+ },
81
+ imports: {
82
+ imports: ["vue", "@vueuse/core"],
83
+ dts: `${buildTypesDir}/auto-imports.d.ts`,
84
+ dirs: [...composables, ...constants, ...stores, ...utils, buildImportsDir],
85
+ vueTemplate: true
86
+ },
87
+ unocss: {},
88
+ devtools: { enabled: false }
89
+ };
90
+ const options = vixt.options = defu(vixt.options, defaultOptions);
91
+ const plugins = [
92
+ Components(options.components),
93
+ AutoImport(options.imports),
94
+ UnoCSS(options.unocss),
95
+ options.devtools?.enabled && VueDevTools(options.devtools)
96
+ ];
97
+ return plugins;
98
+ }
99
+ });
100
+
101
+ const defaults = {
102
+ modules: [appVitepress, presetVitepress],
103
+ srcDirName: ""
104
+ };
105
+ const index = createVixtPlugin({ defaults });
106
+
107
+ export { appVitepress, index as default, generateMainTs, presetVitepress };
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@vixt/vitepress",
3
+ "type": "module",
4
+ "version": "0.1.19",
5
+ "author": "SoulLyoko<https://github.com/SoulLyoko>",
6
+ "license": "MIT",
7
+ "homepage": "https://github.com/SoulLyoko/vixt#readme",
8
+ "repository": "https://github.com/SoulLyoko/vixt.git",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.mjs"
13
+ }
14
+ },
15
+ "main": "dist/index.mjs",
16
+ "types": "dist/index.d.ts",
17
+ "files": [
18
+ "dist"
19
+ ],
20
+ "dependencies": {
21
+ "@vueuse/core": "^11.0.3",
22
+ "unocss": "0.61.6",
23
+ "unplugin-auto-import": "^0.18.2",
24
+ "unplugin-vue-components": "^0.27.4",
25
+ "vite-plugin-vue-devtools": "^7.4.4",
26
+ "vitepress": "^1.3.4",
27
+ "vue": "^3.5.3",
28
+ "@vixt/core": "0.1.19",
29
+ "@vixt/vue": "0.1.19"
30
+ },
31
+ "scripts": {
32
+ "build": "unbuild"
33
+ }
34
+ }