@vixt/react 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.
- package/dist/client/App.d.ts +7 -0
- package/dist/client/App.js +14 -0
- package/dist/client/entry.d.ts +8 -0
- package/dist/client/entry.js +29 -0
- package/dist/index.d.mts +6 -46
- package/dist/index.mjs +8864 -244
- package/dist/types/client.d.ts +12 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/node.d.ts +20 -0
- package/package.json +14 -21
- package/src/client/App.ts +15 -0
- package/src/client/entry.ts +31 -0
- package/src/index.ts +31 -0
- package/src/modules/components.ts +33 -0
- package/src/modules/preset-react.ts +53 -0
- package/src/modules/route-block.ts +52 -0
- package/src/modules/virtual-root-component.ts +40 -0
- package/src/modules/virtual-setup-layouts.ts +42 -0
- package/src/types/client.d.ts +12 -0
- package/src/types/index.d.ts +2 -0
- package/src/types/node.d.ts +20 -0
- package/tsdown.config.ts +15 -0
- package/dist/index.d.ts +0 -47
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Root } from 'react-dom/client'
|
|
2
|
+
import type { RouteObject } from 'react-router'
|
|
3
|
+
|
|
4
|
+
declare module '@vixt/core/client' {
|
|
5
|
+
interface VixtAppConfig { }
|
|
6
|
+
|
|
7
|
+
interface VixtApp {
|
|
8
|
+
app: Root
|
|
9
|
+
routes: RouteObject[]
|
|
10
|
+
appConfig: VixtAppConfig
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type React from '@vitejs/plugin-react'
|
|
2
|
+
import type { ExtractPluginOptions } from '@vixt/core'
|
|
3
|
+
import type UnoCSS from 'unocss/vite'
|
|
4
|
+
import type AutoImport from 'unplugin-auto-import/vite'
|
|
5
|
+
import type Pages from 'vite-plugin-pages'
|
|
6
|
+
import type Layouts from 'vite-plugin-vue-layouts'
|
|
7
|
+
|
|
8
|
+
declare module '@vixt/core' {
|
|
9
|
+
interface VixtOptions {
|
|
10
|
+
react?: ExtractPluginOptions<typeof React>
|
|
11
|
+
/** https://github.com/hannoeru/vite-plugin-pages */
|
|
12
|
+
pages?: ExtractPluginOptions<typeof Pages>
|
|
13
|
+
/** https://github.com/JohnCampionJr/vite-plugin-vue-layouts */
|
|
14
|
+
layouts?: ExtractPluginOptions<typeof Layouts>
|
|
15
|
+
/** https://github.com/unplugin/unplugin-auto-import */
|
|
16
|
+
imports?: ExtractPluginOptions<typeof AutoImport>
|
|
17
|
+
/** https://github.com/unocss/unocss */
|
|
18
|
+
unocss?: ExtractPluginOptions<typeof UnoCSS>
|
|
19
|
+
}
|
|
20
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vixt/react",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
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,36 +12,29 @@
|
|
|
12
12
|
"react"
|
|
13
13
|
],
|
|
14
14
|
"exports": {
|
|
15
|
-
".":
|
|
16
|
-
|
|
17
|
-
|
|
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",
|
|
22
|
-
"files": [
|
|
23
|
-
"dist"
|
|
24
|
-
],
|
|
20
|
+
"main": "./dist/index.mjs",
|
|
21
|
+
"types": "./dist/types/index.d.ts",
|
|
25
22
|
"dependencies": {
|
|
26
23
|
"@types/react": "^19.2.7",
|
|
27
24
|
"@types/react-dom": "^19.2.3",
|
|
28
|
-
"@vitejs/plugin-react": "^5.1.
|
|
25
|
+
"@vitejs/plugin-react": "^5.1.2",
|
|
29
26
|
"ahooks": "^3.9.6",
|
|
30
27
|
"extract-comments": "^1.1.0",
|
|
31
28
|
"fast-glob": "^3.3.3",
|
|
32
|
-
"react": "^19.2.
|
|
33
|
-
"react-dom": "^19.2.
|
|
34
|
-
"react-router": "^7.
|
|
35
|
-
"unocss": "^66.5.
|
|
29
|
+
"react": "^19.2.3",
|
|
30
|
+
"react-dom": "^19.2.3",
|
|
31
|
+
"react-router": "^7.11.0",
|
|
32
|
+
"unocss": "^66.5.11",
|
|
36
33
|
"unplugin-auto-import": "^20.3.0",
|
|
37
34
|
"unplugin-vue-components": "28.0.0",
|
|
38
|
-
"vite-plugin-pages": "^0.33.
|
|
35
|
+
"vite-plugin-pages": "^0.33.2",
|
|
39
36
|
"vite-plugin-vue-layouts": "^0.11.0",
|
|
40
37
|
"yaml": "^2.8.2",
|
|
41
|
-
"@vixt/core": "0.
|
|
42
|
-
},
|
|
43
|
-
"scripts": {
|
|
44
|
-
"build": "unbuild",
|
|
45
|
-
"dev": "unbuild --stub"
|
|
38
|
+
"@vixt/core": "0.6.0"
|
|
46
39
|
}
|
|
47
40
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// @ts-expect-error virtual file
|
|
2
|
+
import routes from '~react-pages'
|
|
3
|
+
import { createElement } from 'react'
|
|
4
|
+
import { createBrowserRouter, RouterProvider } from 'react-router'
|
|
5
|
+
// @ts-expect-error virtual file
|
|
6
|
+
import appConfig from 'virtual:vixt:app-config'
|
|
7
|
+
// @ts-expect-error virtual file
|
|
8
|
+
import { setupLayouts } from 'virtual:vixt:setup-layouts'
|
|
9
|
+
|
|
10
|
+
function App() {
|
|
11
|
+
const router = createBrowserRouter(setupLayouts(routes), { basename: appConfig.baseURL })
|
|
12
|
+
return createElement(RouterProvider, { router })
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export default App
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import 'virtual:vixt:css'
|
|
2
|
+
import 'virtual:uno.css'
|
|
3
|
+
import { applyPlugins, createVixtApp } from '@vixt/core/client'
|
|
4
|
+
import { createElement } from 'react'
|
|
5
|
+
import { createRoot } from 'react-dom/client'
|
|
6
|
+
// @ts-expect-error virtual file
|
|
7
|
+
import appConfig from 'virtual:vixt:app-config'
|
|
8
|
+
// @ts-expect-error virtual file
|
|
9
|
+
import plugins from 'virtual:vixt:plugins'
|
|
10
|
+
// @ts-expect-error virtual file
|
|
11
|
+
import RootComponent from 'virtual:vixt:root-component'
|
|
12
|
+
|
|
13
|
+
async function entry() {
|
|
14
|
+
const app = createRoot(document.getElementById(appConfig.rootId || 'app')!)
|
|
15
|
+
const vixt = createVixtApp({ app, appConfig })
|
|
16
|
+
|
|
17
|
+
try {
|
|
18
|
+
await applyPlugins(vixt, plugins)
|
|
19
|
+
}
|
|
20
|
+
catch (err) {
|
|
21
|
+
console.error(err)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
app.render(createElement(RootComponent))
|
|
25
|
+
|
|
26
|
+
return app
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
entry()
|
|
30
|
+
|
|
31
|
+
export default entry
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { createVixtPlugin } from '@vixt/core'
|
|
2
|
+
import fs from 'fs-extra'
|
|
3
|
+
import { resolvePathSync } from 'mlly'
|
|
4
|
+
|
|
5
|
+
import presetReact from './modules/preset-react'
|
|
6
|
+
import virtualRootComponent from './modules/virtual-root-component'
|
|
7
|
+
import virtualSetupLayouts from './modules/virtual-setup-layouts'
|
|
8
|
+
|
|
9
|
+
export default createVixtPlugin({
|
|
10
|
+
defaults: {
|
|
11
|
+
modules: [presetReact, virtualRootComponent, virtualSetupLayouts],
|
|
12
|
+
app: {
|
|
13
|
+
entryFile: 'main.tsx',
|
|
14
|
+
entryCode: fs.readFileSync(resolvePathSync('@vixt/react/client/entry'), 'utf-8'),
|
|
15
|
+
head: {
|
|
16
|
+
meta: [
|
|
17
|
+
{ charset: 'utf-8' },
|
|
18
|
+
{ name: 'viewport', content: 'width=device-width, initial-scale=1.0' },
|
|
19
|
+
],
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
typescript: {
|
|
23
|
+
tsConfig: {
|
|
24
|
+
compilerOptions: {
|
|
25
|
+
jsxImportSource: 'react',
|
|
26
|
+
types: ['@vixt/react/types', 'vite-plugin-pages/client-react'],
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
})
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { ImportsMap } from 'unplugin-auto-import/types'
|
|
2
|
+
|
|
3
|
+
import { cwd } from 'node:process'
|
|
4
|
+
|
|
5
|
+
import fg from 'fast-glob'
|
|
6
|
+
import { pascalCase } from 'unplugin-vue-components'
|
|
7
|
+
|
|
8
|
+
export interface ComponentResolverOptions {
|
|
9
|
+
dirs?: string[]
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function componentsResolver(options: ComponentResolverOptions = {}) {
|
|
13
|
+
const { dirs = ['src/components'] } = options
|
|
14
|
+
|
|
15
|
+
const files = fg.sync(dirs.map(c => `${c}/**/*.(t|j)sx`), {
|
|
16
|
+
ignore: ['node_modules'],
|
|
17
|
+
onlyFiles: true,
|
|
18
|
+
cwd: cwd(),
|
|
19
|
+
absolute: true,
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
const imports: ImportsMap = {}
|
|
23
|
+
files.forEach((componentPath) => {
|
|
24
|
+
let componentName = componentPath.replace(/\/index\.(t|j)sx$/, '').replace(/\.(t|j)sx$/, '')
|
|
25
|
+
for (const dir of dirs) {
|
|
26
|
+
componentName = componentName.replace(dir, '')
|
|
27
|
+
}
|
|
28
|
+
componentName = pascalCase(componentName.replace(/\//g, '-'))
|
|
29
|
+
imports[componentPath] = [['default', componentName]]
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
return imports
|
|
33
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { VixtOptions } from '@vixt/core'
|
|
2
|
+
|
|
3
|
+
import React from '@vitejs/plugin-react'
|
|
4
|
+
import { defineVixtModule, resolveLayersDirs, VixtClientAutoImports } from '@vixt/core'
|
|
5
|
+
import defu from 'defu'
|
|
6
|
+
import UnoCSS from 'unocss/vite'
|
|
7
|
+
import AutoImport from 'unplugin-auto-import/vite'
|
|
8
|
+
import Pages from 'vite-plugin-pages'
|
|
9
|
+
import Layouts from 'vite-plugin-vue-layouts'
|
|
10
|
+
|
|
11
|
+
import { componentsResolver } from './components'
|
|
12
|
+
import { extendRoute } from './route-block'
|
|
13
|
+
|
|
14
|
+
const name = 'vixt:preset-react'
|
|
15
|
+
export default defineVixtModule<VixtOptions>({
|
|
16
|
+
meta: { name },
|
|
17
|
+
async setup(_, vixt) {
|
|
18
|
+
const { components = [], constants = [], hooks = [], layouts = [], pages = [], stores = [], utils = [] } = resolveLayersDirs([...vixt._layers].reverse())
|
|
19
|
+
const { buildTypesDir } = vixt.options
|
|
20
|
+
|
|
21
|
+
const defaultOptions: VixtOptions = {
|
|
22
|
+
react: {},
|
|
23
|
+
pages: {
|
|
24
|
+
dirs: pages,
|
|
25
|
+
extendRoute,
|
|
26
|
+
},
|
|
27
|
+
layouts: {
|
|
28
|
+
layoutsDirs: layouts,
|
|
29
|
+
pagesDirs: pages,
|
|
30
|
+
extensions: ['jsx', 'tsx'],
|
|
31
|
+
importMode: () => 'sync',
|
|
32
|
+
},
|
|
33
|
+
imports: {
|
|
34
|
+
imports: ['react', 'react-router', 'ahooks', componentsResolver({ dirs: components }), VixtClientAutoImports],
|
|
35
|
+
dts: `${buildTypesDir}/auto-imports.d.ts`,
|
|
36
|
+
dirs: [constants, hooks, stores, utils].flat(),
|
|
37
|
+
},
|
|
38
|
+
unocss: {},
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const options = vixt.options = defu(vixt.options, defaultOptions)
|
|
42
|
+
|
|
43
|
+
const plugins = [
|
|
44
|
+
UnoCSS(options.unocss),
|
|
45
|
+
React(options.react),
|
|
46
|
+
Pages(options.pages),
|
|
47
|
+
Layouts(options.layouts),
|
|
48
|
+
AutoImport(options.imports!),
|
|
49
|
+
]
|
|
50
|
+
|
|
51
|
+
return plugins
|
|
52
|
+
},
|
|
53
|
+
})
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Support route block in react
|
|
3
|
+
* @link https://github.com/hannoeru/vite-plugin-pages?tab=readme-ov-file#jsxtsx-yaml-format-comments-for-route-datain-vue
|
|
4
|
+
* @link https://github.com/hannoeru/vite-plugin-pages/blob/main/src/customBlock.ts
|
|
5
|
+
*/
|
|
6
|
+
import type { CustomBlock, ParsedJSX, ReactRoute } from 'vite-plugin-pages'
|
|
7
|
+
|
|
8
|
+
// @ts-expect-error
|
|
9
|
+
import extractComments from 'extract-comments'
|
|
10
|
+
import fs from 'fs-extra'
|
|
11
|
+
import { parse as YAMLParser } from 'yaml'
|
|
12
|
+
|
|
13
|
+
const routeJSXReg = /^\s+(route)\s+/gm
|
|
14
|
+
|
|
15
|
+
function parseJSX(code: string): ParsedJSX[] {
|
|
16
|
+
return extractComments(code).slice(0, 1).filter((comment: ParsedJSX) => routeJSXReg.test(comment.value) && comment.value.includes(':') && comment.loc.start.line === 1)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function parseYamlComment(code: ParsedJSX[], path: string): CustomBlock {
|
|
20
|
+
return code.reduce((memo, item) => {
|
|
21
|
+
const { value } = item
|
|
22
|
+
const v = value.replace(routeJSXReg, '')
|
|
23
|
+
try {
|
|
24
|
+
const yamlResult = YAMLParser(v)
|
|
25
|
+
|
|
26
|
+
return {
|
|
27
|
+
...memo,
|
|
28
|
+
...yamlResult,
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
catch (err: any) {
|
|
32
|
+
throw new Error(`Invalid YAML format of comment in ${path}\n${err.message}`)
|
|
33
|
+
}
|
|
34
|
+
}, {})
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function getRouteBlock(path: string) {
|
|
38
|
+
const code = fs.readFileSync(path, 'utf-8')
|
|
39
|
+
const parsedJSX = parseJSX(code)
|
|
40
|
+
const block = parseYamlComment(parsedJSX, path)
|
|
41
|
+
return block
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function extendRoute(route: ReactRoute) {
|
|
45
|
+
if (!route.element)
|
|
46
|
+
return
|
|
47
|
+
|
|
48
|
+
const codePath = route.element.startsWith('/') ? route.element.slice(1) : route.element
|
|
49
|
+
const block = getRouteBlock(codePath)
|
|
50
|
+
|
|
51
|
+
return { ...route, ...block }
|
|
52
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { Vixt } from '@vixt/core'
|
|
2
|
+
|
|
3
|
+
import { defineVixtModule } from '@vixt/core'
|
|
4
|
+
import fs from 'fs-extra'
|
|
5
|
+
import { resolvePathSync } from 'mlly'
|
|
6
|
+
import path from 'pathe'
|
|
7
|
+
|
|
8
|
+
function resolveRootComponentPath(vixt: Vixt) {
|
|
9
|
+
for (const layer of vixt._layers) {
|
|
10
|
+
const layerRootComponentPath = path.resolve(layer.config!.srcDir!, 'App.tsx')
|
|
11
|
+
if (fs.existsSync(layerRootComponentPath))
|
|
12
|
+
return layerRootComponentPath
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return resolvePathSync('@vixt/react/client/App')
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const name = 'virtual:vixt:root-component'
|
|
19
|
+
const virtualModuleId = name
|
|
20
|
+
const resolvedVirtualModuleId = `\0${virtualModuleId}`
|
|
21
|
+
export default defineVixtModule({
|
|
22
|
+
meta: { name },
|
|
23
|
+
setup(_, vixt) {
|
|
24
|
+
return {
|
|
25
|
+
name,
|
|
26
|
+
resolveId(id) {
|
|
27
|
+
if (id === virtualModuleId) {
|
|
28
|
+
return resolvedVirtualModuleId
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
load(id) {
|
|
32
|
+
if (id === resolvedVirtualModuleId) {
|
|
33
|
+
const rootComponentPath = resolveRootComponentPath(vixt)
|
|
34
|
+
const rootComponentCode = fs.readFileSync(rootComponentPath, 'utf-8')
|
|
35
|
+
return rootComponentCode
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
})
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { defineVixtModule } from '@vixt/core'
|
|
2
|
+
|
|
3
|
+
const name = 'virtual:vixt:setup-layouts'
|
|
4
|
+
const virtualModuleId = name
|
|
5
|
+
const resolvedVirtualModuleId = `\0${virtualModuleId}`
|
|
6
|
+
export default defineVixtModule({
|
|
7
|
+
meta: { name },
|
|
8
|
+
setup(_, vixt) {
|
|
9
|
+
return {
|
|
10
|
+
name,
|
|
11
|
+
resolveId(id) {
|
|
12
|
+
if (id === virtualModuleId) {
|
|
13
|
+
return resolvedVirtualModuleId
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
load(id) {
|
|
17
|
+
if (id === resolvedVirtualModuleId) {
|
|
18
|
+
const { defaultLayout = 'default' } = vixt.options.layouts ?? {}
|
|
19
|
+
const setupLayoutCode = `import { createElement } from 'react'
|
|
20
|
+
import { layouts } from 'virtual:generated-layouts'
|
|
21
|
+
|
|
22
|
+
export function setupLayouts(routes) {
|
|
23
|
+
return routes.map(route => {
|
|
24
|
+
if (route.children?.length > 0) {
|
|
25
|
+
route.children = setupLayouts(route.children)
|
|
26
|
+
}
|
|
27
|
+
if(route.element && route.meta?.layout !== false) {
|
|
28
|
+
return {
|
|
29
|
+
path: route.path,
|
|
30
|
+
element: createElement(layouts[route.meta?.layout ?? '${defaultLayout}']),
|
|
31
|
+
children: [{ ...route, path: '' }]
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return route
|
|
35
|
+
});
|
|
36
|
+
}`
|
|
37
|
+
return setupLayoutCode
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
})
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Root } from 'react-dom/client'
|
|
2
|
+
import type { RouteObject } from 'react-router'
|
|
3
|
+
|
|
4
|
+
declare module '@vixt/core/client' {
|
|
5
|
+
interface VixtAppConfig { }
|
|
6
|
+
|
|
7
|
+
interface VixtApp {
|
|
8
|
+
app: Root
|
|
9
|
+
routes: RouteObject[]
|
|
10
|
+
appConfig: VixtAppConfig
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type React from '@vitejs/plugin-react'
|
|
2
|
+
import type { ExtractPluginOptions } from '@vixt/core'
|
|
3
|
+
import type UnoCSS from 'unocss/vite'
|
|
4
|
+
import type AutoImport from 'unplugin-auto-import/vite'
|
|
5
|
+
import type Pages from 'vite-plugin-pages'
|
|
6
|
+
import type Layouts from 'vite-plugin-vue-layouts'
|
|
7
|
+
|
|
8
|
+
declare module '@vixt/core' {
|
|
9
|
+
interface VixtOptions {
|
|
10
|
+
react?: ExtractPluginOptions<typeof React>
|
|
11
|
+
/** https://github.com/hannoeru/vite-plugin-pages */
|
|
12
|
+
pages?: ExtractPluginOptions<typeof Pages>
|
|
13
|
+
/** https://github.com/JohnCampionJr/vite-plugin-vue-layouts */
|
|
14
|
+
layouts?: ExtractPluginOptions<typeof Layouts>
|
|
15
|
+
/** https://github.com/unplugin/unplugin-auto-import */
|
|
16
|
+
imports?: ExtractPluginOptions<typeof AutoImport>
|
|
17
|
+
/** https://github.com/unocss/unocss */
|
|
18
|
+
unocss?: ExtractPluginOptions<typeof UnoCSS>
|
|
19
|
+
}
|
|
20
|
+
}
|
package/tsdown.config.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { defineConfig } from 'tsdown'
|
|
2
|
+
|
|
3
|
+
export default defineConfig([
|
|
4
|
+
{
|
|
5
|
+
entry: 'src/index.ts',
|
|
6
|
+
platform: 'node',
|
|
7
|
+
copy: ['src/types'],
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
entry: 'src/client/**/*',
|
|
11
|
+
platform: 'browser',
|
|
12
|
+
outDir: 'dist/client',
|
|
13
|
+
external: [/virtual:/],
|
|
14
|
+
},
|
|
15
|
+
])
|
package/dist/index.d.ts
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import * as vite from 'vite';
|
|
2
|
-
import * as _vixt_core from '@vixt/core';
|
|
3
|
-
import { AppOptions, Vixt, PluginOptions, VixtOptions } from '@vixt/core';
|
|
4
|
-
import { Root } from 'react-dom/client';
|
|
5
|
-
import { RouteObject } from 'react-router';
|
|
6
|
-
import React from '@vitejs/plugin-react';
|
|
7
|
-
import UnoCSS from 'unocss/vite';
|
|
8
|
-
import AutoImport from 'unplugin-auto-import/vite';
|
|
9
|
-
import Pages from 'vite-plugin-pages';
|
|
10
|
-
import Layouts from 'vite-plugin-vue-layouts';
|
|
11
|
-
|
|
12
|
-
declare module '@vixt/core/client' {
|
|
13
|
-
interface VixtAppConfig { }
|
|
14
|
-
|
|
15
|
-
interface VixtApp {
|
|
16
|
-
app: Root
|
|
17
|
-
routes: RouteObject[]
|
|
18
|
-
appConfig: VixtAppConfig
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
declare const app: _vixt_core.VixtModule<AppOptions>;
|
|
23
|
-
|
|
24
|
-
declare function getAppComponentPath(vixt: Vixt): string | undefined;
|
|
25
|
-
declare function generateSetupLayouts(vixt: Vixt): void;
|
|
26
|
-
declare function genarateAppComponent(vixt: Vixt): string;
|
|
27
|
-
|
|
28
|
-
declare function generateMainFile(options: AppOptions, vixt: Vixt): string;
|
|
29
|
-
|
|
30
|
-
declare module '@vixt/core' {
|
|
31
|
-
interface VixtOptions {
|
|
32
|
-
react?: PluginOptions<typeof React>;
|
|
33
|
-
/** https://github.com/hannoeru/vite-plugin-pages */
|
|
34
|
-
pages?: PluginOptions<typeof Pages>;
|
|
35
|
-
/** https://github.com/JohnCampionJr/vite-plugin-vue-layouts */
|
|
36
|
-
layouts?: PluginOptions<typeof Layouts>;
|
|
37
|
-
/** https://github.com/unplugin/unplugin-auto-import */
|
|
38
|
-
imports?: PluginOptions<typeof AutoImport>;
|
|
39
|
-
/** https://github.com/unocss/unocss */
|
|
40
|
-
unocss?: PluginOptions<typeof UnoCSS>;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
declare const presetReact: _vixt_core.VixtModule<VixtOptions>;
|
|
44
|
-
|
|
45
|
-
declare const _default: (options?: VixtOptions | undefined) => vite.PluginOption;
|
|
46
|
-
|
|
47
|
-
export { app, _default as default, genarateAppComponent, generateMainFile, generateSetupLayouts, getAppComponentPath, presetReact };
|