@xyd-js/plugin-docs 0.1.0-build.160
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 +21 -0
- package/dist/index.d.ts +50 -0
- package/dist/index.js +4605 -0
- package/dist/index.js.map +1 -0
- package/package.json +57 -0
- package/src/const.ts +7 -0
- package/src/declarations.d.ts +29 -0
- package/src/index.ts +386 -0
- package/src/pages/context.tsx +9 -0
- package/src/pages/layout.tsx +340 -0
- package/src/pages/metatags.ts +96 -0
- package/src/pages/page.tsx +463 -0
- package/src/presets/docs/index.ts +317 -0
- package/src/presets/docs/settings.ts +262 -0
- package/src/presets/graphql/index.ts +69 -0
- package/src/presets/openapi/index.ts +66 -0
- package/src/presets/sources/index.ts +74 -0
- package/src/presets/uniform/index.ts +832 -0
- package/src/types.ts +40 -0
- package/src/utils.ts +19 -0
package/src/types.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import {Plugin as VitePlugin} from "vite"
|
|
2
|
+
import {RouteConfigEntry} from "@react-router/dev/routes";
|
|
3
|
+
|
|
4
|
+
import {Settings} from "@xyd-js/core";
|
|
5
|
+
|
|
6
|
+
type VitePluginData = {
|
|
7
|
+
preinstall: any // TODO: fix any
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface PresetData {
|
|
11
|
+
routes: RouteConfigEntry[]
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type Preset<T> = (
|
|
15
|
+
settings?: Settings,
|
|
16
|
+
options?: T
|
|
17
|
+
) => {
|
|
18
|
+
// TODO: args and return should be based on passed preinstall plugin
|
|
19
|
+
preinstall: ((options?: any) => (settings: Settings, data: PresetData) => Promise<any>)[]
|
|
20
|
+
routes: RouteConfigEntry[]
|
|
21
|
+
// TODO: 'data' comes from merged object of preinstall
|
|
22
|
+
vitePlugins: (() => (data: VitePluginData) => Promise<VitePlugin>)[]
|
|
23
|
+
basePath: string
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface PluginOutput {
|
|
27
|
+
vitePlugins: VitePlugin[],
|
|
28
|
+
|
|
29
|
+
settings: Settings,
|
|
30
|
+
|
|
31
|
+
routes: RouteConfigEntry[]
|
|
32
|
+
|
|
33
|
+
basePath: string
|
|
34
|
+
|
|
35
|
+
pagePathMapping: {[page: string]: string}
|
|
36
|
+
|
|
37
|
+
hasIndexPage: boolean
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export type Plugin = () => Promise<PluginOutput | null>
|
package/src/utils.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
|
|
4
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
5
|
+
const __dirname = path.dirname(__filename);
|
|
6
|
+
|
|
7
|
+
export const HOST_FOLDER_PATH = ".xyd/host"
|
|
8
|
+
|
|
9
|
+
// TODO: share with documan
|
|
10
|
+
export function getHostPath() {
|
|
11
|
+
if (process.env.XYD_DEV_MODE) {
|
|
12
|
+
return path.join(__dirname, "../../../", HOST_FOLDER_PATH)
|
|
13
|
+
}
|
|
14
|
+
return path.join(process.cwd(), HOST_FOLDER_PATH)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function getDocsPluginBasePath() {
|
|
18
|
+
return path.join(getHostPath(), "./plugins/xyd-plugin-docs")
|
|
19
|
+
}
|