@xyd-js/plugin-docs 0.1.0-xyd.44 → 0.1.0-xyd.5
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/index.js +7 -24
- package/dist/index.js.map +1 -1
- package/package.json +21 -21
- package/src/declarations.d.ts +1 -7
- package/src/pages/layout.tsx +51 -72
- package/src/pages/page.tsx +1 -0
- package/src/presets/docs/index.ts +7 -62
- package/src/presets/docs/settings.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyd-js/plugin-docs",
|
|
3
|
-
"version": "0.1.0-xyd.
|
|
3
|
+
"version": "0.1.0-xyd.5",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -17,33 +17,33 @@
|
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"codehike": "^1.0.3",
|
|
19
19
|
"@code-hike/lighter": "^1.0.3",
|
|
20
|
-
"@xyd-js/openapi": "0.1.0-xyd.
|
|
21
|
-
"@xyd-js/gql": "0.1.0-xyd.
|
|
22
|
-
"@xyd-js/
|
|
23
|
-
"@xyd-js/
|
|
20
|
+
"@xyd-js/openapi": "0.1.0-xyd.13",
|
|
21
|
+
"@xyd-js/gql": "0.1.0-xyd.15",
|
|
22
|
+
"@xyd-js/sources": "0.1.1-xyd.5",
|
|
23
|
+
"@xyd-js/uniform": "0.1.0-xyd.17"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
|
-
"@react-router/dev": "^7.
|
|
27
|
-
"@react-router/node": "^7.
|
|
28
|
-
"@react-router/serve": "^7.
|
|
29
|
-
"react": "^19.
|
|
30
|
-
"react-dom": "^19.
|
|
31
|
-
"react-router": "^7.
|
|
32
|
-
"@xyd-js/framework": "0.1.0-xyd.
|
|
33
|
-
"@xyd-js/
|
|
34
|
-
"@xyd-js/
|
|
35
|
-
"@xyd-js/
|
|
36
|
-
"@xyd-js/
|
|
37
|
-
"@xyd-js/core": "0.1.0-xyd.
|
|
26
|
+
"@react-router/dev": "^7.5.0",
|
|
27
|
+
"@react-router/node": "^7.5.0",
|
|
28
|
+
"@react-router/serve": "^7.5.0",
|
|
29
|
+
"react": "^19.0.0",
|
|
30
|
+
"react-dom": "^19.0.0",
|
|
31
|
+
"react-router": "^7.5.0",
|
|
32
|
+
"@xyd-js/framework": "0.1.0-xyd.34",
|
|
33
|
+
"@xyd-js/components": "0.1.0-xyd.13",
|
|
34
|
+
"@xyd-js/composer": "0.1.0-xyd.2",
|
|
35
|
+
"@xyd-js/themes": "0.1.1-xyd.5",
|
|
36
|
+
"@xyd-js/content": "0.1.0-xyd.16",
|
|
37
|
+
"@xyd-js/core": "0.1.0-xyd.15"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@types/react-dom": "^19.
|
|
41
|
-
"@types/react": "^19.
|
|
40
|
+
"@types/react-dom": "^19.0.0",
|
|
41
|
+
"@types/react": "^19.0.0",
|
|
42
42
|
"@vitejs/plugin-react": "^4.3.2",
|
|
43
43
|
"tsup": "^8.3.0",
|
|
44
44
|
"typescript": "^5.6.2",
|
|
45
|
-
"vite": "^
|
|
46
|
-
"vite-tsconfig-paths": "^5.1
|
|
45
|
+
"vite": "^6.1.0",
|
|
46
|
+
"vite-tsconfig-paths": "^5.0.1",
|
|
47
47
|
"rimraf": "^3.0.2"
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
package/src/declarations.d.ts
CHANGED
package/src/pages/layout.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {useMemo} from "react";
|
|
1
|
+
import { useMemo } from "react";
|
|
2
2
|
import {
|
|
3
3
|
Outlet,
|
|
4
4
|
useLoaderData,
|
|
@@ -8,50 +8,41 @@ import {
|
|
|
8
8
|
useMatches
|
|
9
9
|
} from "react-router";
|
|
10
10
|
|
|
11
|
-
import {mapSettingsToProps} from "@xyd-js/framework/hydration";
|
|
11
|
+
import { mapSettingsToProps } from "@xyd-js/framework/hydration";
|
|
12
12
|
|
|
13
|
-
import type {Metadata, MetadataMap, Theme as ThemeSettings} from "@xyd-js/core";
|
|
14
|
-
import type {INavLinks, IBreadcrumb} from "@xyd-js/ui";
|
|
15
|
-
import {Framework, FwLink, useSettings, type FwSidebarGroupProps} from "@xyd-js/framework/react";
|
|
16
|
-
import {ReactContent} from "@xyd-js/components/content";
|
|
17
|
-
import {Atlas, AtlasContext, type VariantToggleConfig} from "@xyd-js/atlas";
|
|
13
|
+
import type { Metadata, MetadataMap, Theme as ThemeSettings } from "@xyd-js/core";
|
|
14
|
+
import type { INavLinks, IBreadcrumb } from "@xyd-js/ui";
|
|
15
|
+
import { Framework, FwLink, useSettings, type FwSidebarGroupProps } from "@xyd-js/framework/react";
|
|
16
|
+
import { ReactContent } from "@xyd-js/components/content";
|
|
17
|
+
import { Atlas, AtlasContext, type VariantToggleConfig } from "@xyd-js/atlas";
|
|
18
18
|
import AtlasXydPlugin from "@xyd-js/atlas/xydPlugin";
|
|
19
19
|
|
|
20
|
-
import {Surfaces} from "@xyd-js/framework";
|
|
21
|
-
import {Composer} from "@xyd-js/composer";
|
|
22
|
-
import {XYDAnalytics} from "@xyd-js/analytics";
|
|
20
|
+
import { Surfaces } from "@xyd-js/framework/react";
|
|
21
|
+
import { Composer } from "@xyd-js/composer";
|
|
23
22
|
// @ts-ignore
|
|
24
|
-
import {iconSet} from 'virtual:xyd-icon-set';
|
|
23
|
+
import { iconSet } from 'virtual:xyd-icon-set';
|
|
25
24
|
|
|
26
25
|
// @ts-ignore
|
|
27
26
|
import virtualSettings from "virtual:xyd-settings";
|
|
28
|
-
// @ts-
|
|
29
|
-
const {settings: getSettings} = virtualSettings
|
|
27
|
+
// @ts-ignore
|
|
28
|
+
const { settings: getSettings } = virtualSettings
|
|
30
29
|
// const settings = globalThis.__xydSettings
|
|
31
30
|
import Theme from "virtual:xyd-theme";
|
|
32
|
-
// @ts-ignore
|
|
33
|
-
import {loadProvider} from 'virtual:xyd-analytics-providers'
|
|
34
31
|
|
|
35
32
|
// @ts-ignore
|
|
36
33
|
import "virtual:xyd-theme/index.css"
|
|
37
34
|
import "virtual:xyd-theme-override/index.css"
|
|
38
35
|
|
|
39
|
-
|
|
40
|
-
import {components as userComponents} from 'virtual:xyd-user-components';
|
|
41
|
-
|
|
42
|
-
import {PageContext} from "./context";
|
|
36
|
+
import { PageContext } from "./context";
|
|
43
37
|
import React from "react";
|
|
44
|
-
|
|
45
|
-
import {
|
|
46
|
-
import {
|
|
47
|
-
import {
|
|
48
|
-
import {CoderProvider} from "@xyd-js/components/coder";
|
|
49
|
-
import {SearchButton} from "@xyd-js/components/system"
|
|
38
|
+
import { markdownPlugins } from "@xyd-js/content/md";
|
|
39
|
+
import { ContentFS } from "@xyd-js/content";
|
|
40
|
+
import { IconProvider } from "@xyd-js/components/writer";
|
|
41
|
+
import { CoderProvider } from "@xyd-js/components/coder";
|
|
50
42
|
|
|
51
43
|
globalThis.__xydSettings = getSettings
|
|
52
|
-
globalThis.__xydUserComponents = userComponents // Add user components to global scope TODO: problematic
|
|
53
44
|
|
|
54
|
-
new Composer() // TODO: better API
|
|
45
|
+
new Composer() // TODO: better API
|
|
55
46
|
const settings = globalThis.__xydSettings
|
|
56
47
|
|
|
57
48
|
const surfaces = new Surfaces()
|
|
@@ -80,8 +71,7 @@ globalThis.__xydSurfaces = surfaces
|
|
|
80
71
|
|
|
81
72
|
const theme = new Theme()
|
|
82
73
|
|
|
83
|
-
const {Layout: BaseThemeLayout} = theme
|
|
84
|
-
|
|
74
|
+
const { Layout: BaseThemeLayout } = theme
|
|
85
75
|
|
|
86
76
|
interface LoaderData {
|
|
87
77
|
sidebarGroups: FwSidebarGroupProps[]
|
|
@@ -93,7 +83,7 @@ interface LoaderData {
|
|
|
93
83
|
bannerContentCode?: string
|
|
94
84
|
}
|
|
95
85
|
|
|
96
|
-
export async function loader({request}: { request: any }) {
|
|
86
|
+
export async function loader({ request }: { request: any }) {
|
|
97
87
|
const slug = getPathname(request.url || "index") || "index"
|
|
98
88
|
|
|
99
89
|
const {
|
|
@@ -141,12 +131,12 @@ export default function Layout() {
|
|
|
141
131
|
// TODO: BETTER HANDLE THAT
|
|
142
132
|
if (loaderData.metadata?.openapi) {
|
|
143
133
|
atlasVariantToggles = [
|
|
144
|
-
{key: "status", defaultValue: "200"},
|
|
145
|
-
{key: "contentType", defaultValue: "application/json"}
|
|
134
|
+
{ key: "status", defaultValue: "200" },
|
|
135
|
+
{ key: "contentType", defaultValue: "application/json" }
|
|
146
136
|
];
|
|
147
137
|
} else {
|
|
148
138
|
atlasVariantToggles = [
|
|
149
|
-
{key: "symbolName", defaultValue: ""}
|
|
139
|
+
{ key: "symbolName", defaultValue: "" }
|
|
150
140
|
];
|
|
151
141
|
}
|
|
152
142
|
|
|
@@ -157,49 +147,38 @@ export default function Layout() {
|
|
|
157
147
|
const BannerContent = MemoMDXComponent(content.component)
|
|
158
148
|
|
|
159
149
|
bannerContent = function () {
|
|
160
|
-
return <BannerContent components={theme.reactContentComponents()}/>
|
|
150
|
+
return <BannerContent components={theme.reactContentComponents()} />
|
|
161
151
|
}
|
|
162
152
|
}
|
|
163
153
|
|
|
164
|
-
const userComponents = (globalThis.__xydUserComponents || []).reduce((acc, component) => {
|
|
165
|
-
acc[component.name] = component.component;
|
|
166
|
-
return acc;
|
|
167
|
-
}, {});
|
|
168
|
-
|
|
169
154
|
return <>
|
|
170
|
-
<
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
155
|
+
<IconProvider value={{
|
|
156
|
+
iconSet: iconSet
|
|
157
|
+
}}>
|
|
158
|
+
<Framework
|
|
159
|
+
settings={settings || globalThis.__xydSettings}
|
|
160
|
+
sidebarGroups={loaderData.sidebarGroups || []}
|
|
161
|
+
metadata={loaderData.metadata || {}}
|
|
162
|
+
surfaces={surfaces}
|
|
163
|
+
BannerContent={bannerContent}
|
|
164
|
+
>
|
|
165
|
+
<AtlasContext
|
|
166
|
+
value={{
|
|
167
|
+
syntaxHighlight: settings?.theme?.coder?.syntaxHighlight || null,
|
|
168
|
+
baseMatch: lastMatchId || "",
|
|
169
|
+
variantToggles: atlasVariantToggles
|
|
183
170
|
}}
|
|
184
171
|
>
|
|
185
|
-
<
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
>
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
<Outlet/>
|
|
196
|
-
</PageContext>
|
|
197
|
-
</BaseThemeLayout>
|
|
198
|
-
</CoderProvider>
|
|
199
|
-
</AtlasContext>
|
|
200
|
-
</Framework>
|
|
201
|
-
</IconProvider>
|
|
202
|
-
</XYDAnalytics>
|
|
172
|
+
<CoderProvider lines={settings?.theme?.coder?.lines} scroll={settings?.theme?.coder?.scroll}>
|
|
173
|
+
<BaseThemeLayout>
|
|
174
|
+
<PageContext value={{ theme }}>
|
|
175
|
+
<Outlet />
|
|
176
|
+
</PageContext>
|
|
177
|
+
</BaseThemeLayout>
|
|
178
|
+
</CoderProvider>
|
|
179
|
+
</AtlasContext>
|
|
180
|
+
</Framework>
|
|
181
|
+
</IconProvider>
|
|
203
182
|
</>
|
|
204
183
|
}
|
|
205
184
|
|
|
@@ -242,7 +221,7 @@ const createElementWithKeys = (type: any, props: any) => {
|
|
|
242
221
|
return childrenArray.map((child, index) => {
|
|
243
222
|
// If the child is a React element and doesn't have a key, add one
|
|
244
223
|
if (React.isValidElement(child) && !child.key) {
|
|
245
|
-
return React.cloneElement(child, {key: `mdx-${index}`});
|
|
224
|
+
return React.cloneElement(child, { key: `mdx-${index}` });
|
|
246
225
|
}
|
|
247
226
|
// If the child is an array, process it recursively
|
|
248
227
|
if (Array.isArray(child)) {
|
|
@@ -260,7 +239,7 @@ const createElementWithKeys = (type: any, props: any) => {
|
|
|
260
239
|
processedChildren = processChildren(props.children);
|
|
261
240
|
} else if (React.isValidElement(props.children) && !props.children.key) {
|
|
262
241
|
// Single child without key
|
|
263
|
-
processedChildren = React.cloneElement(props.children, {key: 'mdx-child'});
|
|
242
|
+
processedChildren = React.cloneElement(props.children, { key: 'mdx-child' });
|
|
264
243
|
} else {
|
|
265
244
|
// Single child with key or non-React element
|
|
266
245
|
processedChildren = props.children;
|
package/src/pages/page.tsx
CHANGED
|
@@ -43,7 +43,7 @@ function preinstall() {
|
|
|
43
43
|
name: DEFAULT_THEME
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
|
|
46
|
+
|
|
47
47
|
let themeRoutesExists = false
|
|
48
48
|
try {
|
|
49
49
|
await fs.access(path.join(root, THEME_CONFIG_FOLDER, "./routes.ts"))
|
|
@@ -68,85 +68,30 @@ function preinstall() {
|
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
// TODO: maybe later as a separate plugin?
|
|
71
|
-
// function vitePluginSettings() {
|
|
72
|
-
// return async function ({ preinstall }): Promise<VitePlugin> {
|
|
73
|
-
// return {
|
|
74
|
-
// name: 'virtual:xyd-settings',
|
|
75
|
-
// resolveId(id) {
|
|
76
|
-
// if (id === 'virtual:xyd-settings') {
|
|
77
|
-
// return id + '.jsx'; // Return the module with .jsx extension
|
|
78
|
-
// }
|
|
79
|
-
// return null;
|
|
80
|
-
// },
|
|
81
|
-
// async load(id) { // TODO: better cuz we probably dont neeed `get settings()`
|
|
82
|
-
// if (id === 'virtual:xyd-settings.jsx') {
|
|
83
|
-
// return `
|
|
84
|
-
// export default {
|
|
85
|
-
// get settings() {
|
|
86
|
-
// return globalThis.__xydSettings || ${typeof preinstall.settings === "string" ? preinstall.settings : JSON.stringify(preinstall.settings)}
|
|
87
|
-
// }
|
|
88
|
-
// }
|
|
89
|
-
// `
|
|
90
|
-
// }
|
|
91
|
-
// return null;
|
|
92
|
-
// },
|
|
93
|
-
// };
|
|
94
|
-
// }
|
|
95
|
-
// }
|
|
96
|
-
|
|
97
|
-
|
|
98
71
|
function vitePluginSettings() {
|
|
99
72
|
return async function ({ preinstall }): Promise<VitePlugin> {
|
|
100
|
-
const virtualId = 'virtual:xyd-settings';
|
|
101
|
-
const resolvedId = virtualId + '.jsx';
|
|
102
|
-
|
|
103
|
-
let currentSettings = globalThis.__xydSettings
|
|
104
|
-
if (!currentSettings && preinstall?.settings) {
|
|
105
|
-
currentSettings = typeof preinstall?.settings === "string" ? preinstall?.settings : JSON.stringify(preinstall?.settings || {})
|
|
106
|
-
}
|
|
107
|
-
|
|
108
73
|
return {
|
|
109
|
-
name: 'xyd
|
|
110
|
-
|
|
74
|
+
name: 'virtual:xyd-settings',
|
|
111
75
|
resolveId(id) {
|
|
112
|
-
if (id ===
|
|
113
|
-
return
|
|
76
|
+
if (id === 'virtual:xyd-settings') {
|
|
77
|
+
return id + '.jsx'; // Return the module with .jsx extension
|
|
114
78
|
}
|
|
115
79
|
return null;
|
|
116
80
|
},
|
|
117
|
-
|
|
118
|
-
|
|
119
81
|
async load(id) { // TODO: better cuz we probably dont neeed `get settings()`
|
|
120
82
|
if (id === 'virtual:xyd-settings.jsx') {
|
|
121
83
|
return `
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
84
|
+
export default {
|
|
85
|
+
get settings() {
|
|
86
|
+
return globalThis.__xydSettings || ${typeof preinstall.settings === "string" ? preinstall.settings : JSON.stringify(preinstall.settings)}
|
|
125
87
|
}
|
|
126
88
|
}
|
|
127
89
|
`
|
|
128
90
|
}
|
|
129
91
|
return null;
|
|
130
92
|
},
|
|
131
|
-
|
|
132
|
-
async hotUpdate(ctx) {
|
|
133
|
-
const isPageFileChanged = ctx.file.includes('xyd-plugin-docs/src/pages/layout.tsx')
|
|
134
|
-
|| ctx.file.includes('xyd-plugin-docs/src/pages/page.tsx')
|
|
135
|
-
|
|
136
|
-
if (!isPageFileChanged) {
|
|
137
|
-
return
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
const newSettings = await readSettings();
|
|
141
|
-
if (!newSettings) {
|
|
142
|
-
return
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
globalThis.__xydSettings = newSettings;
|
|
146
|
-
},
|
|
147
93
|
};
|
|
148
94
|
}
|
|
149
|
-
|
|
150
95
|
}
|
|
151
96
|
|
|
152
97
|
|