@xyd-js/cli 0.1.0-xyd.30 → 0.1.0-xyd.33

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/.cli/index.js CHANGED
@@ -111,7 +111,7 @@ var require_package = __commonJS({
111
111
  "package.json"(exports2, module2) {
112
112
  module2.exports = {
113
113
  name: "@xyd-js/cli",
114
- version: "0.1.0-xyd.29",
114
+ version: "0.1.0-xyd.32",
115
115
  keywords: [],
116
116
  author: "",
117
117
  description: "",
@@ -45363,9 +45363,10 @@ async function pluginZero() {
45363
45363
  // ../xyd-documan/dist/index.js
45364
45364
  import path23 from "node:path";
45365
45365
  import { fileURLToPath as fileURLToPath22 } from "node:url";
45366
+ import fs23 from "node:fs";
45366
45367
  import { createServer as createServer3, searchForWorkspaceRoot } from "vite";
45367
45368
  import { reactRouter as reactRouter2 } from "@xyd-js/react-router-dev/vite";
45368
- import fs23 from "node:fs";
45369
+ import fs33 from "node:fs";
45369
45370
  import os from "node:os";
45370
45371
  import path33 from "node:path";
45371
45372
  import url from "node:url";
@@ -45480,8 +45481,7 @@ async function dev() {
45480
45481
  fs: {
45481
45482
  allow: [
45482
45483
  allowCwd,
45483
- process.env.XYD_CLI ? path23.join(__dirname2, "../../") : ""
45484
- // path.join(__dirname, "../node_modules") // Ensure node_modules from xyd-documan is included
45484
+ process.env.XYD_CLI ? __dirname2 : path23.join(__dirname2, "../host")
45485
45485
  ]
45486
45486
  }
45487
45487
  },
@@ -45510,9 +45510,30 @@ async function dev() {
45510
45510
  ...respPluginZero.vitePlugins
45511
45511
  ]
45512
45512
  });
45513
+ const watcher = fs23.watch(allowCwd, { recursive: true }, (eventType, filename) => {
45514
+ if (!filename) {
45515
+ console.log("[xyd:dev] Received empty filename");
45516
+ return;
45517
+ }
45518
+ const filePath = path23.join(allowCwd, filename);
45519
+ if (filePath.endsWith(".md") || filePath.endsWith(".mdx")) {
45520
+ const relativePath = path23.relative(allowCwd, filePath);
45521
+ const urlPath = "/" + relativePath.replace(/\\/g, "/");
45522
+ preview.ws.send({
45523
+ type: "full-reload",
45524
+ path: urlPath
45525
+ });
45526
+ }
45527
+ });
45528
+ watcher.on("error", (error) => {
45529
+ console.error("[xyd:dev] File watcher error:", error);
45530
+ });
45513
45531
  await preview.listen(port);
45514
45532
  preview.printUrls();
45515
45533
  preview.bindCLIShortcuts({ print: true });
45534
+ preview.httpServer?.once("close", () => {
45535
+ watcher.close();
45536
+ });
45516
45537
  }
45517
45538
  function parseNumber(raw) {
45518
45539
  if (raw === void 0) return void 0;
@@ -45528,10 +45549,10 @@ async function serve() {
45528
45549
  if (match) {
45529
45550
  let filePath = url.fileURLToPath(source);
45530
45551
  let sourceMapPath = `${filePath}.map`;
45531
- if (fs23.existsSync(sourceMapPath)) {
45552
+ if (fs33.existsSync(sourceMapPath)) {
45532
45553
  return {
45533
45554
  url: source,
45534
- map: fs23.readFileSync(sourceMapPath, "utf8")
45555
+ map: fs33.readFileSync(sourceMapPath, "utf8")
45535
45556
  };
45536
45557
  }
45537
45558
  }
package/.cli/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  },
10
10
  "scripts": {},
11
11
  "dependencies": {
12
- "@xyd-js/theme-poetry": "0.1.0-xyd.22",
12
+ "@xyd-js/theme-poetry": "0.1.0-xyd.25",
13
13
  "@xyd-js/react-router-dev": "7.1.1-xyd.4",
14
14
  "@readme/oas-to-snippet": "^26.0.1",
15
15
  "@react-router/node": "7.1.1",
@@ -248,34 +248,6 @@ function mdxContent(code: string) {
248
248
  }
249
249
  }
250
250
 
251
- // TODO: below is a concept only
252
- // class MyThemeSettings extends BaseThemeSettings {
253
- // private constructor() {
254
- // super();
255
- //
256
- // this.toc.hide(true)
257
- // this.sidebar.clientSideRouting(true)
258
- // this.layout.size("large")
259
- // }
260
- //
261
- // override abc() {
262
- //
263
- // }
264
- //
265
- // static new() {
266
- // return new MyThemeSettings()
267
- // }
268
- // }
269
-
270
-
271
- // TODO: below is a concept only
272
- // const themeSettings = new ThemeSettings()
273
- // .toc.hide()
274
- // .sidebar({
275
- // clientSideRouting: true
276
- // })
277
- // .layout.size("large")
278
-
279
251
  // TODO: in the future more smoother loader - first fast server render then move to ideal position of client and then replace and 3 items at start
280
252
  export default function APIReference({loaderData}: { loaderData: loaderData }) {
281
253
  const content = mdxContent(loaderData.code)
@@ -285,25 +257,13 @@ export default function APIReference({loaderData}: { loaderData: loaderData }) {
285
257
 
286
258
  const memoizedServerComponent = MemoMDXComponent(serverComponent)
287
259
 
288
- console.log("memoizedServerComponent", memoizedServerComponent)
289
-
290
260
  return <Framework
291
261
  settings={settings}
292
262
  sidebarGroups={loaderData.sidebarGroups || []}
293
263
  breadcrumbs={loaderData.breadcrumbs || []}
294
264
  navlinks={loaderData.navlinks}
295
265
  >
296
- <Theme
297
- themeSettings={{
298
- hideToc: true,
299
- sidebar: {
300
- clientSideRouting: true
301
- },
302
- layout: {
303
- size: "large"
304
- }
305
- }}
306
- >
266
+ <Theme>
307
267
  <AtlasIndex
308
268
  data={memoizedServerComponent?.references[0]}
309
269
  />
@@ -12,6 +12,7 @@ import {recmaCodeHike, remarkCodeHike} from "codehike/mdx";
12
12
  import {compile as mdxCompile} from "@mdx-js/mdx";
13
13
 
14
14
  import {PageFrontMatter} from "@xyd-js/core";
15
+ import {BaseThemeSettings} from "@xyd-js/themes";
15
16
  import getContentComponents from "@xyd-js/components/content";
16
17
  import {mapSettingsToProps} from "@xyd-js/framework/hydration";
17
18
  import {Framework, type FwSidebarGroupProps} from "@xyd-js/framework/react";
@@ -73,7 +74,7 @@ const codeHikeOptions = {
73
74
  // },
74
75
  };
75
76
 
76
- const compiledBySlug = {}
77
+ const compiledBySlug = {}
77
78
 
78
79
  // TODO: map every file and merge them or load via client-side ?
79
80
  async function compileBySlug(slug: string) {
@@ -249,13 +250,14 @@ function mdxContent(code: string) {
249
250
  }
250
251
  }
251
252
 
252
- // TODO: below is a concept only
253
- // const themeSettings = new ThemeSettings()
254
- // .toc.hide()
255
- // .sidebar({
256
- // clientSideRouting: true
257
- // })
258
- // .layout.size("large")
253
+ // TODO: get settings from md files??
254
+ function themeSettings(
255
+ this: BaseThemeSettings,
256
+ ) {
257
+ return this
258
+ .layout.size("large")
259
+ .toc.hide()
260
+ }
259
261
 
260
262
  // TODO: in the future more smoother loader - first fast server render then move to ideal position of client and then replace and 3 items at start
261
263
  export default function APIReference({loaderData}: { loaderData: loaderData }) {
@@ -272,17 +274,7 @@ export default function APIReference({loaderData}: { loaderData: loaderData }) {
272
274
  breadcrumbs={loaderData.breadcrumbs || []}
273
275
  navlinks={loaderData.navlinks}
274
276
  >
275
- <Theme
276
- themeSettings={{
277
- hideToc: true,
278
- sidebar: {
279
- clientSideRouting: true
280
- },
281
- layout: {
282
- size: "large"
283
- }
284
- }}
285
- >
277
+ <Theme settings={themeSettings}>
286
278
  <AtlasLazy
287
279
  references={memoizedServerComponent?.references || []}
288
280
  slug={loaderData.slug.startsWith("/") ? loaderData.slug : `/${loaderData.slug}`}
@@ -173,9 +173,7 @@ export default function CustomPage({loaderData, ...rest}: { loaderData: loaderDa
173
173
  }}
174
174
  />
175
175
  } else {
176
- component = <Theme
177
- themeSettings={content.themeSettings}
178
- >
176
+ component = <Theme>
179
177
  <Content
180
178
  components={{
181
179
  ...contentComponents,
@@ -1,4 +1,4 @@
1
- import {defineConfig} from 'vite';
1
+ import { defineConfig } from 'vite';
2
2
 
3
3
  // DO NOT DELETE
4
4
  // This file is needed for host `vite` to run
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 xyd
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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xyd-js/cli",
3
- "version": "0.1.0-xyd.30",
3
+ "version": "0.1.0-xyd.33",
4
4
  "keywords": [],
5
5
  "author": "",
6
6
  "description": "",
@@ -62,7 +62,7 @@
62
62
  "colors": "^1.4.0",
63
63
  "semver": "^7.6.3",
64
64
  "vite-tsconfig-paths": "^5.1.4",
65
- "@xyd-js/documan": "0.1.0-xyd.25"
65
+ "@xyd-js/documan": "0.1.0-xyd.28"
66
66
  },
67
67
  "scripts": {
68
68
  "build": "tsup",