@xyd-js/plugin-docs 0.1.0-xyd.2 → 0.1.0-xyd.4

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/src/types.ts ADDED
@@ -0,0 +1,38 @@
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
+
38
+ 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
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "compilerOptions": {
3
+ "paths": {
4
+ "@xyd-js/atlas": [
5
+ "../xyd-atlas"
6
+ ],
7
+ "@xyd-js/core": [
8
+ "../xyd-core/index.ts"
9
+ ],
10
+ "@xyd-js/themes": [
11
+ "../xyd-themes/src/index.ts"
12
+ ],
13
+ "@xyd-js/components/content": [
14
+ "../xyd-components/content.ts"
15
+ ],
16
+ "@xyd-js/framework/react": [
17
+ "../xyd-framework/packages/react/index.ts"
18
+ ]
19
+ },
20
+ "types": [
21
+ "unplugin-icons/types/react"
22
+ ],
23
+ "module": "esnext",
24
+ "esModuleInterop": true,
25
+ "moduleResolution": "bundler",
26
+ "target": "esnext",
27
+ "baseUrl": ".",
28
+ "lib": [
29
+ "dom",
30
+ "dom.iterable",
31
+ "esnext"
32
+ ],
33
+ "allowJs": true,
34
+ "skipLibCheck": true,
35
+ "strict": false,
36
+ "noEmit": true,
37
+ "incremental": false,
38
+ "resolveJsonModule": true,
39
+ "isolatedModules": true,
40
+ "jsx": "preserve",
41
+ "plugins": [],
42
+ "strictNullChecks": true
43
+ },
44
+ "include": [
45
+ "src/**/*.ts",
46
+ "src/**/*.tsx"
47
+ ],
48
+ "exclude": [
49
+ "node_modules"
50
+ ]
51
+ }
package/tsup.config.ts ADDED
@@ -0,0 +1,74 @@
1
+ import {defineConfig, Options} from 'tsup';
2
+
3
+ import pkg from './package.json';
4
+
5
+ const deps = [
6
+ ...Object.keys(pkg.dependencies || {}),
7
+ ...Object.keys(pkg.devDependencies || {}),
8
+ ].filter((dep) => [
9
+
10
+ ].indexOf(dep) === -1)
11
+
12
+ const config: Options = {
13
+ entry: {
14
+ index: 'src/index.ts',
15
+ },
16
+ dts: {
17
+ entry: {
18
+ index: 'src/index.ts',
19
+ },
20
+ resolve: true, // Resolve external types
21
+ },
22
+ format: ['esm'],
23
+ platform: 'node',
24
+ shims: false,
25
+ splitting: false,
26
+ sourcemap: true,
27
+ clean: true,
28
+ external: [
29
+ ...deps,
30
+
31
+ // "@graphql-markdown/core": "^1.12.0",
32
+ // "@graphql-markdown/graphql": "^1.1.4",
33
+ // "@graphql-markdown/types": "^1.4.0",
34
+ // "graphql-config": "^5.1.2",
35
+ // "gray-matter": "^4.0.3",
36
+ // "json-to-graphql-query": "^2.3.0"
37
+
38
+ // Externalize gql modules
39
+ // '@graphql-markdown/core',
40
+ // '@graphql-markdown/graphql',
41
+ // '@graphql-markdown/types',
42
+ // 'graphql-config',
43
+ // 'gray-matter',
44
+ // 'json-to-graphql-query',
45
+
46
+ // Externalize Node.js built-in modules
47
+ /^node:.*/,
48
+ 'fs',
49
+ 'path',
50
+ 'url',
51
+ 'os',
52
+ 'http',
53
+ 'https',
54
+ 'stream',
55
+ 'zlib',
56
+ 'util',
57
+ 'crypto',
58
+ 'tty',
59
+ // Add other built-in modules as needed
60
+ ],
61
+ esbuildPlugins: [
62
+ {
63
+ name: 'external-node-builtins',
64
+ setup(build) {
65
+ const filter = /^node:/;
66
+ build.onResolve({filter}, args => {
67
+ return {path: args.path, external: true};
68
+ });
69
+ },
70
+ },
71
+ ],
72
+ }
73
+
74
+ export default defineConfig(config);
package/dist/index.d.ts DELETED
@@ -1,42 +0,0 @@
1
- import { Plugin as Plugin$1 } from 'vite';
2
- import { RouteConfigEntry } from '@react-router/dev/routes';
3
- import { Settings } from '@xyd-js/core';
4
-
5
- interface PluginOutput {
6
- vitePlugins: Plugin$1[];
7
- settings: Settings;
8
- routes: RouteConfigEntry[];
9
- basePath: string;
10
- pagePathMapping: {
11
- [page: string]: string;
12
- };
13
- }
14
- type Plugin = () => Promise<PluginOutput | null>;
15
-
16
- /**
17
- * Reads `xyd` settings from the current working directory.
18
- *
19
- * This function searches for a file named 'xyd' with one of the supported extensions
20
- * (tsx, jsx, js, ts, json) in the current working directory. If found, it loads the
21
- * settings from that file.
22
- *
23
- * For React-based settings files (tsx, jsx, js, ts), it uses Vite's SSR module loading
24
- * to evaluate the file and extract the default export. For JSON files, it simply
25
- * parses the JSON content.
26
- *
27
- * @returns A Promise that resolves to:
28
- * - The Settings object if a valid settings file was found and loaded
29
- * - A string if the settings file contains a string value
30
- * - null if no settings file was found or an error occurred
31
- *
32
- * @throws May throw errors if file reading or parsing fails
33
- */
34
- declare function readSettings(): Promise<Settings | null>;
35
-
36
- interface PluginDocsOptions {
37
- disableAPIGeneration?: boolean;
38
- disableFSWrite?: boolean;
39
- }
40
- declare function pluginDocs(options?: PluginDocsOptions): Promise<PluginOutput | null>;
41
-
42
- export { type Plugin, type PluginDocsOptions, type PluginOutput, pluginDocs, readSettings };