@xyd-js/documan 0.1.0-xyd.25 → 0.1.0-xyd.28
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/build.js +2 -1
- package/dist/build.js.map +1 -1
- package/dist/dev.js +24 -3
- package/dist/dev.js.map +1 -1
- package/dist/index.js +26 -5
- package/dist/index.js.map +1 -1
- package/dist/serve.js +4 -3
- package/dist/serve.js.map +1 -1
- package/package.json +5 -5
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/dist/build.js
CHANGED
|
@@ -100,6 +100,7 @@ async function build() {
|
|
|
100
100
|
// src/run/dev.ts
|
|
101
101
|
import path2 from "node:path";
|
|
102
102
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
103
|
+
import fs2 from "node:fs";
|
|
103
104
|
import { createServer, searchForWorkspaceRoot } from "vite";
|
|
104
105
|
import { reactRouter as reactRouter2 } from "@xyd-js/react-router-dev/vite";
|
|
105
106
|
import { vitePlugins as xydContentVitePlugins2 } from "@xyd-js/content/vite";
|
|
@@ -109,7 +110,7 @@ var __dirname2 = path2.dirname(__filename2);
|
|
|
109
110
|
var port = process.env.XYD_PORT ? parseInt(process.env.XYD_PORT) : 5175;
|
|
110
111
|
|
|
111
112
|
// src/run/serve.ts
|
|
112
|
-
import
|
|
113
|
+
import fs3 from "node:fs";
|
|
113
114
|
import os from "node:os";
|
|
114
115
|
import path3 from "node:path";
|
|
115
116
|
import url from "node:url";
|
package/dist/build.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/run/build.ts","../src/run/dev.ts","../src/run/serve.ts","../src/commands/build.ts"],"sourcesContent":["import path from \"node:path\";\nimport fs from \"node:fs\";\nimport {fileURLToPath} from \"node:url\";\nimport {execSync} from 'child_process';\n\nimport {build as viteBuild} from 'vite';\nimport tsconfigPaths from \"vite-tsconfig-paths\";\n\nimport {reactRouter} from \"@xyd-js/react-router-dev/vite\";\n\nimport {vitePlugins as xydContentVitePlugins} from \"@xyd-js/content/vite\"\nimport {pluginZero} from \"@xyd-js/plugin-zero\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\n// Define the main function to run the builds\nexport async function build() {\n const resp = await pluginZero()\n if (!resp) {\n throw new Error(\"PluginZero not found\")\n }\n\n const buildDir = path.join(process.cwd(), \".xyd/build\");\n\n {\n // TODO: probably we should have better mechanism - maybe bundle?\n\n const packageJsonPath = path.join(buildDir, 'package.json');\n\n const packageJsonContent = {\n type: \"module\",\n scripts: {},\n dependencies: { // TODO: better\n \"@xyd-js/content\": \"latest\",\n \"@xyd-js/components\": \"latest\",\n \"@xyd-js/framework\": \"latest\",\n \"@xyd-js/theme-poetry\": \"latest\",\n\n\n \"@react-router/node\": \"7.1.1\",\n \"isbot\": \"^5\"\n },\n devDependencies: {}\n };\n\n if (process.env.XYD_DEV_MODE) {\n Object.keys(packageJsonContent.dependencies).forEach((key) => {\n if (key.startsWith(\"@xyd-js/\")) {\n packageJsonContent.dependencies[key] = \"workspace:*\";\n }\n })\n }\n\n // Ensure the build directory exists\n if (!fs.existsSync(buildDir)) {\n fs.mkdirSync(buildDir, {recursive: true});\n }\n\n // Write the package.json file\n fs.writeFileSync(packageJsonPath, JSON.stringify(packageJsonContent, null, 2), 'utf8');\n\n // Install packages inside buildDir\n if (process.env.XYD_DEV_MODE) {\n execSync('pnpm i', {cwd: buildDir, stdio: 'inherit'});\n } else {\n execSync('npm install', {cwd: buildDir, stdio: 'inherit'});\n }\n }\n\n try {\n // Build the client-side bundle\n await viteBuild({\n root: process.env.XYD_CLI ? __dirname : process.env.XYD_DOCUMAN_HOST || path.join(__dirname, \"../host\"),\n plugins: [\n ...(xydContentVitePlugins({\n toc: {\n minDepth: 2,\n }\n }) as Plugin[]),\n reactRouter({\n outDir: buildDir,\n routes: resp.routes\n }),\n tsconfigPaths(),\n ...resp.vitePlugins\n ],\n optimizeDeps: {\n include: [\"react/jsx-runtime\"],\n },\n });\n\n // Build the SSR bundle\n await viteBuild({\n root: process.env.XYD_CLI ? __dirname : process.env.XYD_DOCUMAN_HOST || path.join(__dirname, \"../host\"),\n build: {\n ssr: true,\n },\n plugins: [\n ...(xydContentVitePlugins({\n toc: {\n minDepth: 2,\n }\n }) as Plugin[]),\n reactRouter({\n outDir: buildDir,\n routes: resp.routes\n }),\n tsconfigPaths(),\n ...resp.vitePlugins\n ],\n optimizeDeps: {\n include: [\"react/jsx-runtime\"],\n },\n });\n\n console.log('Build completed successfully.'); // TODO: better message\n } catch (error) {\n console.error('Build failed:', error); // TODO: better message\n }\n}\n\n","import path from \"node:path\";\nimport {fileURLToPath} from \"node:url\";\nimport {createServer, searchForWorkspaceRoot} from \"vite\";\n\nimport {reactRouter} from \"@xyd-js/react-router-dev/vite\";\n\nimport {vitePlugins as xydContentVitePlugins} from \"@xyd-js/content/vite\";\nimport {pluginZero} from \"@xyd-js/plugin-zero\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\nconst port = process.env.XYD_PORT ? parseInt(process.env.XYD_PORT) : 5175;\n\nexport async function dev() {\n const respPluginZero = await pluginZero()\n if (!respPluginZero) {\n throw new Error(\"PluginZero not found\")\n }\n\n const allowCwd = searchForWorkspaceRoot(process.cwd())\n\n const preview = await createServer({\n root: process.env.XYD_CLI ? __dirname : process.env.XYD_DOCUMAN_HOST || path.join(__dirname, \"../host\"), // TODO: bundler?\n server: {\n port: port,\n fs: {\n allow: [\n allowCwd,\n process.env.XYD_CLI ? path.join(__dirname, \"../../\") : \"\",\n // path.join(__dirname, \"../node_modules\") // Ensure node_modules from xyd-documan is included\n ]\n }\n },\n build: {\n rollupOptions: {\n // Exclude package `B` from the client-side bundle\n external: [\"@xyd-js/uniform\", \"@xyd-js/uniform/content\", \"@xyd-js/plugin-zero\"],\n },\n },\n ssr: {\n external: [\"@xyd-js/uniform\", \"@xyd-js/uniform/content\", \"@xyd-js/plugin-zero\"],\n },\n optimizeDeps: {\n include: [\"react/jsx-runtime\"],\n },\n plugins: [ // TODO: fix plugin ts\n ...(xydContentVitePlugins({\n toc: {\n minDepth: 2,\n }\n }) as Plugin[]),\n reactRouter({\n routes: respPluginZero.routes\n }),\n ...respPluginZero.vitePlugins,\n ],\n });\n\n await preview.listen(port);\n\n preview.printUrls();\n preview.bindCLIShortcuts({print: true});\n\n}","import fs from \"node:fs\";\nimport os from \"node:os\";\nimport path from \"node:path\";\nimport url from \"node:url\";\n\nimport type {ServerBuild} from \"react-router\";\nimport {createRequestHandler} from \"@react-router/express\";\nimport compression from \"compression\";\nimport express from \"express\";\nimport morgan from \"morgan\";\nimport sourceMapSupport from \"source-map-support\";\nimport getPort from \"get-port\";\n\nfunction parseNumber(raw?: string) {\n if (raw === undefined) return undefined;\n let maybe = Number(raw);\n if (Number.isNaN(maybe)) return undefined;\n return maybe;\n}\n\nexport async function serve() {\n process.env.NODE_ENV = process.env.NODE_ENV ?? \"production\";\n\n sourceMapSupport.install({\n retrieveSourceMap: function (source) {\n let match = source.startsWith(\"file://\");\n if (match) {\n let filePath = url.fileURLToPath(source);\n let sourceMapPath = `${filePath}.map`;\n if (fs.existsSync(sourceMapPath)) {\n return {\n url: source,\n map: fs.readFileSync(sourceMapPath, \"utf8\"),\n };\n }\n }\n return null;\n },\n });\n\n let port = parseNumber(process.env.PORT) ?? (await getPort({port: 3000}));\n\n let buildPathArg = path.join(process.cwd(), \".xyd/build/server/index.js\")\n\n if (!buildPathArg) {\n console.error(`\n Usage: react-router-serve <server-build-path> - e.g. react-router-serve build/server/index.js`);\n process.exit(1);\n }\n\n let buildPath = path.resolve(buildPathArg);\n\n let build: ServerBuild = await import(url.pathToFileURL(buildPath).href);\n\n let onListen = () => {\n let address =\n process.env.HOST ||\n Object.values(os.networkInterfaces())\n .flat()\n .find((ip) => String(ip?.family).includes(\"4\") && !ip?.internal)\n ?.address;\n\n if (!address) {\n console.log(`[xyd-serve] http://localhost:${port}`);\n } else {\n console.log(\n `[xyd-serve] http://localhost:${port} (http://${address}:${port})`\n );\n }\n };\n\n build = {\n ...build,\n assetsBuildDirectory: path.join(process.cwd(), \".xyd/build/client\")\n }\n\n let app = express();\n app.disable(\"x-powered-by\");\n app.use(compression());\n app.use(\n path.posix.join(build.publicPath, \"assets\"),\n express.static(path.join(build.assetsBuildDirectory, \"assets\"), {\n immutable: true,\n maxAge: \"1y\",\n })\n );\n app.use(build.publicPath, express.static(build.assetsBuildDirectory));\n app.use(express.static(\"public\", {maxAge: \"1h\"}));\n app.use(morgan(\"tiny\"));\n\n app.all(\n \"*\",\n createRequestHandler({\n build,\n mode: process.env.NODE_ENV,\n })\n );\n\n let server = process.env.HOST\n ? app.listen(port, process.env.HOST, onListen)\n : app.listen(port, onListen);\n\n [\"SIGTERM\", \"SIGINT\"].forEach((signal) => {\n process.once(signal, () => server?.close(console.error));\n });\n}\n","import {build} from \"../\"\n\n// Execute the build function\nawait build();"],"mappings":";AAAA,OAAO,UAAU;AACjB,OAAO,QAAQ;AACf,SAAQ,qBAAoB;AAC5B,SAAQ,gBAAe;AAEvB,SAAQ,SAAS,iBAAgB;AACjC,OAAO,mBAAmB;AAE1B,SAAQ,mBAAkB;AAE1B,SAAQ,eAAe,6BAA4B;AACnD,SAAQ,kBAAiB;AAEzB,IAAM,aAAa,cAAc,YAAY,GAAG;AAChD,IAAM,YAAY,KAAK,QAAQ,UAAU;AAGzC,eAAsB,QAAQ;AAC1B,QAAM,OAAO,MAAM,WAAW;AAC9B,MAAI,CAAC,MAAM;AACP,UAAM,IAAI,MAAM,sBAAsB;AAAA,EAC1C;AAEA,QAAM,WAAW,KAAK,KAAK,QAAQ,IAAI,GAAG,YAAY;AAEtD;AAGI,UAAM,kBAAkB,KAAK,KAAK,UAAU,cAAc;AAE1D,UAAM,qBAAqB;AAAA,MACvB,MAAM;AAAA,MACN,SAAS,CAAC;AAAA,MACV,cAAc;AAAA;AAAA,QACV,mBAAmB;AAAA,QACnB,sBAAsB;AAAA,QACtB,qBAAqB;AAAA,QACrB,wBAAwB;AAAA,QAGxB,sBAAsB;AAAA,QACtB,SAAS;AAAA,MACb;AAAA,MACA,iBAAiB,CAAC;AAAA,IACtB;AAEA,QAAI,QAAQ,IAAI,cAAc;AAC1B,aAAO,KAAK,mBAAmB,YAAY,EAAE,QAAQ,CAAC,QAAQ;AAC1D,YAAI,IAAI,WAAW,UAAU,GAAG;AAC5B,6BAAmB,aAAa,GAAG,IAAI;AAAA,QAC3C;AAAA,MACJ,CAAC;AAAA,IACL;AAGA,QAAI,CAAC,GAAG,WAAW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AED,YAAQ,IAAI,+BAA+B;AAAA,EAC/C,SAAS,OAAO;AACZ,YAAQ,MAAM,iBAAiB,KAAK;AAAA,EACxC;AACJ;;;ACxHA,OAAOA,WAAU;AACjB,SAAQ,iBAAAC,sBAAoB;AAC5B,SAAQ,cAAc,8BAA6B;AAEnD,SAAQ,eAAAC,oBAAkB;AAE1B,SAAQ,eAAeC,8BAA4B;AACnD,SAAQ,cAAAC,mBAAiB;AAEzB,IAAMC,cAAaJ,eAAc,YAAY,GAAG;AAChD,IAAMK,aAAYN,MAAK,QAAQK,WAAU;AAEzC,IAAM,OAAO,QAAQ,IAAI,WAAW,SAAS,QAAQ,IAAI,QAAQ,IAAI;;;ACZrE,OAAOE,SAAQ;AACf,OAAO,QAAQ;AACf,OAAOC,WAAU;AACjB,OAAO,SAAS;AAGhB,SAAQ,4BAA2B;AACnC,OAAO,iBAAiB;AACxB,OAAO,aAAa;AACpB,OAAO,YAAY;AACnB,OAAO,sBAAsB;AAC7B,OAAO,aAAa;;;ACRpB,MAAM,MAAM;","names":["path","fileURLToPath","reactRouter","xydContentVitePlugins","pluginZero","__filename","__dirname","fs","path"]}
|
|
1
|
+
{"version":3,"sources":["../src/run/build.ts","../src/run/dev.ts","../src/run/serve.ts","../src/commands/build.ts"],"sourcesContent":["import path from \"node:path\";\nimport fs from \"node:fs\";\nimport {fileURLToPath} from \"node:url\";\nimport {execSync} from 'child_process';\n\nimport {build as viteBuild} from 'vite';\nimport tsconfigPaths from \"vite-tsconfig-paths\";\n\nimport {reactRouter} from \"@xyd-js/react-router-dev/vite\";\n\nimport {vitePlugins as xydContentVitePlugins} from \"@xyd-js/content/vite\"\nimport {pluginZero} from \"@xyd-js/plugin-zero\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\n// Define the main function to run the builds\nexport async function build() {\n const resp = await pluginZero()\n if (!resp) {\n throw new Error(\"PluginZero not found\")\n }\n\n const buildDir = path.join(process.cwd(), \".xyd/build\");\n\n {\n // TODO: probably we should have better mechanism - maybe bundle?\n\n const packageJsonPath = path.join(buildDir, 'package.json');\n\n const packageJsonContent = {\n type: \"module\",\n scripts: {},\n dependencies: { // TODO: better\n \"@xyd-js/content\": \"latest\",\n \"@xyd-js/components\": \"latest\",\n \"@xyd-js/framework\": \"latest\",\n \"@xyd-js/theme-poetry\": \"latest\",\n\n\n \"@react-router/node\": \"7.1.1\",\n \"isbot\": \"^5\"\n },\n devDependencies: {}\n };\n\n if (process.env.XYD_DEV_MODE) {\n Object.keys(packageJsonContent.dependencies).forEach((key) => {\n if (key.startsWith(\"@xyd-js/\")) {\n packageJsonContent.dependencies[key] = \"workspace:*\";\n }\n })\n }\n\n // Ensure the build directory exists\n if (!fs.existsSync(buildDir)) {\n fs.mkdirSync(buildDir, {recursive: true});\n }\n\n // Write the package.json file\n fs.writeFileSync(packageJsonPath, JSON.stringify(packageJsonContent, null, 2), 'utf8');\n\n // Install packages inside buildDir\n if (process.env.XYD_DEV_MODE) {\n execSync('pnpm i', {cwd: buildDir, stdio: 'inherit'});\n } else {\n execSync('npm install', {cwd: buildDir, stdio: 'inherit'});\n }\n }\n\n try {\n // Build the client-side bundle\n await viteBuild({\n root: process.env.XYD_CLI ? __dirname : process.env.XYD_DOCUMAN_HOST || path.join(__dirname, \"../host\"),\n plugins: [\n ...(xydContentVitePlugins({\n toc: {\n minDepth: 2,\n }\n }) as Plugin[]),\n reactRouter({\n outDir: buildDir,\n routes: resp.routes\n }),\n tsconfigPaths(),\n ...resp.vitePlugins\n ],\n optimizeDeps: {\n include: [\"react/jsx-runtime\"],\n },\n });\n\n // Build the SSR bundle\n await viteBuild({\n root: process.env.XYD_CLI ? __dirname : process.env.XYD_DOCUMAN_HOST || path.join(__dirname, \"../host\"),\n build: {\n ssr: true,\n },\n plugins: [\n ...(xydContentVitePlugins({\n toc: {\n minDepth: 2,\n }\n }) as Plugin[]),\n reactRouter({\n outDir: buildDir,\n routes: resp.routes\n }),\n tsconfigPaths(),\n ...resp.vitePlugins\n ],\n optimizeDeps: {\n include: [\"react/jsx-runtime\"],\n },\n });\n\n console.log('Build completed successfully.'); // TODO: better message\n } catch (error) {\n console.error('Build failed:', error); // TODO: better message\n }\n}\n\n","import path from \"node:path\";\nimport {fileURLToPath} from \"node:url\";\nimport fs from \"node:fs\";\n\nimport {createServer, searchForWorkspaceRoot} from \"vite\";\n\nimport {reactRouter} from \"@xyd-js/react-router-dev/vite\";\n\nimport {vitePlugins as xydContentVitePlugins} from \"@xyd-js/content/vite\";\nimport {pluginZero} from \"@xyd-js/plugin-zero\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\nconst port = process.env.XYD_PORT ? parseInt(process.env.XYD_PORT) : 5175;\n\nexport async function dev() {\n const respPluginZero = await pluginZero()\n if (!respPluginZero) {\n throw new Error(\"PluginZero not found\")\n }\n\n const allowCwd = searchForWorkspaceRoot(process.cwd())\n\n const preview = await createServer({\n root: process.env.XYD_CLI ? __dirname : process.env.XYD_DOCUMAN_HOST || path.join(__dirname, \"../host\"), // TODO: bundler?\n server: {\n port: port,\n fs: {\n allow: [\n allowCwd,\n process.env.XYD_CLI ? __dirname : path.join(__dirname, \"../host\"),\n ]\n }\n },\n build: {\n rollupOptions: {\n // Exclude package `B` from the client-side bundle\n external: [\"@xyd-js/uniform\", \"@xyd-js/uniform/content\", \"@xyd-js/plugin-zero\"],\n },\n },\n ssr: {\n external: [\"@xyd-js/uniform\", \"@xyd-js/uniform/content\", \"@xyd-js/plugin-zero\"],\n },\n optimizeDeps: {\n include: [\"react/jsx-runtime\"],\n },\n plugins: [ // TODO: fix plugin ts\n ...(xydContentVitePlugins({\n toc: {\n minDepth: 2,\n }\n }) as Plugin[]),\n reactRouter({\n routes: respPluginZero.routes\n }),\n ...respPluginZero.vitePlugins,\n ]\n });\n\n // Set up manual file watcher for markdown files TODO: better way? + HMR only for specific components instead or reload a pag\n const watcher = fs.watch(allowCwd, { recursive: true }, (eventType, filename) => {\n if (!filename) {\n console.log(\"[xyd:dev] Received empty filename\");\n return;\n }\n \n const filePath = path.join(allowCwd, filename);\n \n if (filePath.endsWith('.md') || filePath.endsWith('.mdx')) {\n const relativePath = path.relative(allowCwd, filePath);\n const urlPath = '/' + relativePath.replace(/\\\\/g, '/');\n \n preview.ws.send({\n type: 'full-reload',\n path: urlPath\n });\n }\n });\n\n // Log any watcher errors\n watcher.on('error', (error) => {\n console.error(\"[xyd:dev] File watcher error:\", error);\n });\n\n await preview.listen(port);\n\n preview.printUrls();\n preview.bindCLIShortcuts({print: true});\n\n // Clean up watcher when server is closed\n preview.httpServer?.once('close', () => {\n watcher.close();\n });\n}","import fs from \"node:fs\";\nimport os from \"node:os\";\nimport path from \"node:path\";\nimport url from \"node:url\";\n\nimport type {ServerBuild} from \"react-router\";\nimport {createRequestHandler} from \"@react-router/express\";\nimport compression from \"compression\";\nimport express from \"express\";\nimport morgan from \"morgan\";\nimport sourceMapSupport from \"source-map-support\";\nimport getPort from \"get-port\";\n\nfunction parseNumber(raw?: string) {\n if (raw === undefined) return undefined;\n let maybe = Number(raw);\n if (Number.isNaN(maybe)) return undefined;\n return maybe;\n}\n\nexport async function serve() {\n process.env.NODE_ENV = process.env.NODE_ENV ?? \"production\";\n\n sourceMapSupport.install({\n retrieveSourceMap: function (source) {\n let match = source.startsWith(\"file://\");\n if (match) {\n let filePath = url.fileURLToPath(source);\n let sourceMapPath = `${filePath}.map`;\n if (fs.existsSync(sourceMapPath)) {\n return {\n url: source,\n map: fs.readFileSync(sourceMapPath, \"utf8\"),\n };\n }\n }\n return null;\n },\n });\n\n let port = parseNumber(process.env.PORT) ?? (await getPort({port: 3000}));\n\n let buildPathArg = path.join(process.cwd(), \".xyd/build/server/index.js\")\n\n if (!buildPathArg) {\n console.error(`\n Usage: react-router-serve <server-build-path> - e.g. react-router-serve build/server/index.js`);\n process.exit(1);\n }\n\n let buildPath = path.resolve(buildPathArg);\n\n let build: ServerBuild = await import(url.pathToFileURL(buildPath).href);\n\n let onListen = () => {\n let address =\n process.env.HOST ||\n Object.values(os.networkInterfaces())\n .flat()\n .find((ip) => String(ip?.family).includes(\"4\") && !ip?.internal)\n ?.address;\n\n if (!address) {\n console.log(`[xyd-serve] http://localhost:${port}`);\n } else {\n console.log(\n `[xyd-serve] http://localhost:${port} (http://${address}:${port})`\n );\n }\n };\n\n build = {\n ...build,\n assetsBuildDirectory: path.join(process.cwd(), \".xyd/build/client\")\n }\n\n let app = express();\n app.disable(\"x-powered-by\");\n app.use(compression());\n app.use(\n path.posix.join(build.publicPath, \"assets\"),\n express.static(path.join(build.assetsBuildDirectory, \"assets\"), {\n immutable: true,\n maxAge: \"1y\",\n })\n );\n app.use(build.publicPath, express.static(build.assetsBuildDirectory));\n app.use(express.static(\"public\", {maxAge: \"1h\"}));\n app.use(morgan(\"tiny\"));\n\n app.all(\n \"*\",\n createRequestHandler({\n build,\n mode: process.env.NODE_ENV,\n })\n );\n\n let server = process.env.HOST\n ? app.listen(port, process.env.HOST, onListen)\n : app.listen(port, onListen);\n\n [\"SIGTERM\", \"SIGINT\"].forEach((signal) => {\n process.once(signal, () => server?.close(console.error));\n });\n}\n","import {build} from \"../\"\n\n// Execute the build function\nawait build();"],"mappings":";AAAA,OAAO,UAAU;AACjB,OAAO,QAAQ;AACf,SAAQ,qBAAoB;AAC5B,SAAQ,gBAAe;AAEvB,SAAQ,SAAS,iBAAgB;AACjC,OAAO,mBAAmB;AAE1B,SAAQ,mBAAkB;AAE1B,SAAQ,eAAe,6BAA4B;AACnD,SAAQ,kBAAiB;AAEzB,IAAM,aAAa,cAAc,YAAY,GAAG;AAChD,IAAM,YAAY,KAAK,QAAQ,UAAU;AAGzC,eAAsB,QAAQ;AAC1B,QAAM,OAAO,MAAM,WAAW;AAC9B,MAAI,CAAC,MAAM;AACP,UAAM,IAAI,MAAM,sBAAsB;AAAA,EAC1C;AAEA,QAAM,WAAW,KAAK,KAAK,QAAQ,IAAI,GAAG,YAAY;AAEtD;AAGI,UAAM,kBA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__dirname","fs","path"]}
|
package/dist/dev.js
CHANGED
|
@@ -13,6 +13,7 @@ var __dirname = path.dirname(__filename);
|
|
|
13
13
|
// src/run/dev.ts
|
|
14
14
|
import path2 from "node:path";
|
|
15
15
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
16
|
+
import fs2 from "node:fs";
|
|
16
17
|
import { createServer, searchForWorkspaceRoot } from "vite";
|
|
17
18
|
import { reactRouter as reactRouter2 } from "@xyd-js/react-router-dev/vite";
|
|
18
19
|
import { vitePlugins as xydContentVitePlugins2 } from "@xyd-js/content/vite";
|
|
@@ -34,8 +35,7 @@ async function dev() {
|
|
|
34
35
|
fs: {
|
|
35
36
|
allow: [
|
|
36
37
|
allowCwd,
|
|
37
|
-
process.env.XYD_CLI ? path2.join(__dirname2, "
|
|
38
|
-
// path.join(__dirname, "../node_modules") // Ensure node_modules from xyd-documan is included
|
|
38
|
+
process.env.XYD_CLI ? __dirname2 : path2.join(__dirname2, "../host")
|
|
39
39
|
]
|
|
40
40
|
}
|
|
41
41
|
},
|
|
@@ -64,13 +64,34 @@ async function dev() {
|
|
|
64
64
|
...respPluginZero.vitePlugins
|
|
65
65
|
]
|
|
66
66
|
});
|
|
67
|
+
const watcher = fs2.watch(allowCwd, { recursive: true }, (eventType, filename) => {
|
|
68
|
+
if (!filename) {
|
|
69
|
+
console.log("[xyd:dev] Received empty filename");
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
const filePath = path2.join(allowCwd, filename);
|
|
73
|
+
if (filePath.endsWith(".md") || filePath.endsWith(".mdx")) {
|
|
74
|
+
const relativePath = path2.relative(allowCwd, filePath);
|
|
75
|
+
const urlPath = "/" + relativePath.replace(/\\/g, "/");
|
|
76
|
+
preview.ws.send({
|
|
77
|
+
type: "full-reload",
|
|
78
|
+
path: urlPath
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
watcher.on("error", (error) => {
|
|
83
|
+
console.error("[xyd:dev] File watcher error:", error);
|
|
84
|
+
});
|
|
67
85
|
await preview.listen(port);
|
|
68
86
|
preview.printUrls();
|
|
69
87
|
preview.bindCLIShortcuts({ print: true });
|
|
88
|
+
preview.httpServer?.once("close", () => {
|
|
89
|
+
watcher.close();
|
|
90
|
+
});
|
|
70
91
|
}
|
|
71
92
|
|
|
72
93
|
// src/run/serve.ts
|
|
73
|
-
import
|
|
94
|
+
import fs3 from "node:fs";
|
|
74
95
|
import os from "node:os";
|
|
75
96
|
import path3 from "node:path";
|
|
76
97
|
import url from "node:url";
|
package/dist/dev.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/run/build.ts","../src/run/dev.ts","../src/run/serve.ts","../src/commands/dev.ts"],"sourcesContent":["import path from \"node:path\";\nimport fs from \"node:fs\";\nimport {fileURLToPath} from \"node:url\";\nimport {execSync} from 'child_process';\n\nimport {build as viteBuild} from 'vite';\nimport tsconfigPaths from \"vite-tsconfig-paths\";\n\nimport {reactRouter} from \"@xyd-js/react-router-dev/vite\";\n\nimport {vitePlugins as xydContentVitePlugins} from \"@xyd-js/content/vite\"\nimport {pluginZero} from \"@xyd-js/plugin-zero\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\n// Define the main function to run the builds\nexport async function build() {\n const resp = await pluginZero()\n if (!resp) {\n throw new Error(\"PluginZero not found\")\n }\n\n const buildDir = path.join(process.cwd(), \".xyd/build\");\n\n {\n // TODO: probably we should have better mechanism - maybe bundle?\n\n const packageJsonPath = path.join(buildDir, 'package.json');\n\n const packageJsonContent = {\n type: \"module\",\n scripts: {},\n dependencies: { // TODO: better\n \"@xyd-js/content\": \"latest\",\n \"@xyd-js/components\": \"latest\",\n \"@xyd-js/framework\": \"latest\",\n \"@xyd-js/theme-poetry\": \"latest\",\n\n\n \"@react-router/node\": \"7.1.1\",\n \"isbot\": \"^5\"\n },\n devDependencies: {}\n };\n\n if (process.env.XYD_DEV_MODE) {\n Object.keys(packageJsonContent.dependencies).forEach((key) => {\n if (key.startsWith(\"@xyd-js/\")) {\n packageJsonContent.dependencies[key] = \"workspace:*\";\n }\n })\n }\n\n // Ensure the build directory exists\n if (!fs.existsSync(buildDir)) {\n fs.mkdirSync(buildDir, {recursive: true});\n }\n\n // Write the package.json file\n fs.writeFileSync(packageJsonPath, JSON.stringify(packageJsonContent, null, 2), 'utf8');\n\n // Install packages inside buildDir\n if (process.env.XYD_DEV_MODE) {\n execSync('pnpm i', {cwd: buildDir, stdio: 'inherit'});\n } else {\n execSync('npm install', {cwd: buildDir, stdio: 'inherit'});\n }\n }\n\n try {\n // Build the client-side bundle\n await viteBuild({\n root: process.env.XYD_CLI ? __dirname : process.env.XYD_DOCUMAN_HOST || path.join(__dirname, \"../host\"),\n plugins: [\n ...(xydContentVitePlugins({\n toc: {\n minDepth: 2,\n }\n }) as Plugin[]),\n reactRouter({\n outDir: buildDir,\n routes: resp.routes\n }),\n tsconfigPaths(),\n ...resp.vitePlugins\n ],\n optimizeDeps: {\n include: [\"react/jsx-runtime\"],\n },\n });\n\n // Build the SSR bundle\n await viteBuild({\n root: process.env.XYD_CLI ? __dirname : process.env.XYD_DOCUMAN_HOST || path.join(__dirname, \"../host\"),\n build: {\n ssr: true,\n },\n plugins: [\n ...(xydContentVitePlugins({\n toc: {\n minDepth: 2,\n }\n }) as Plugin[]),\n reactRouter({\n outDir: buildDir,\n routes: resp.routes\n }),\n tsconfigPaths(),\n ...resp.vitePlugins\n ],\n optimizeDeps: {\n include: [\"react/jsx-runtime\"],\n },\n });\n\n console.log('Build completed successfully.'); // TODO: better message\n } catch (error) {\n console.error('Build failed:', error); // TODO: better message\n }\n}\n\n","import path from \"node:path\";\nimport {fileURLToPath} from \"node:url\";\nimport {createServer, searchForWorkspaceRoot} from \"vite\";\n\nimport {reactRouter} from \"@xyd-js/react-router-dev/vite\";\n\nimport {vitePlugins as xydContentVitePlugins} from \"@xyd-js/content/vite\";\nimport {pluginZero} from \"@xyd-js/plugin-zero\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\nconst port = process.env.XYD_PORT ? parseInt(process.env.XYD_PORT) : 5175;\n\nexport async function dev() {\n const respPluginZero = await pluginZero()\n if (!respPluginZero) {\n throw new Error(\"PluginZero not found\")\n }\n\n const allowCwd = searchForWorkspaceRoot(process.cwd())\n\n const preview = await createServer({\n root: process.env.XYD_CLI ? __dirname : process.env.XYD_DOCUMAN_HOST || path.join(__dirname, \"../host\"), // TODO: bundler?\n server: {\n port: port,\n fs: {\n allow: [\n allowCwd,\n process.env.XYD_CLI ? path.join(__dirname, \"../../\") : \"\",\n // path.join(__dirname, \"../node_modules\") // Ensure node_modules from xyd-documan is included\n ]\n }\n },\n build: {\n rollupOptions: {\n // Exclude package `B` from the client-side bundle\n external: [\"@xyd-js/uniform\", \"@xyd-js/uniform/content\", \"@xyd-js/plugin-zero\"],\n },\n },\n ssr: {\n external: [\"@xyd-js/uniform\", \"@xyd-js/uniform/content\", \"@xyd-js/plugin-zero\"],\n },\n optimizeDeps: {\n include: [\"react/jsx-runtime\"],\n },\n plugins: [ // TODO: fix plugin ts\n ...(xydContentVitePlugins({\n toc: {\n minDepth: 2,\n }\n }) as Plugin[]),\n reactRouter({\n routes: respPluginZero.routes\n }),\n ...respPluginZero.vitePlugins,\n ],\n });\n\n await preview.listen(port);\n\n preview.printUrls();\n preview.bindCLIShortcuts({print: true});\n\n}","import fs from \"node:fs\";\nimport os from \"node:os\";\nimport path from \"node:path\";\nimport url from \"node:url\";\n\nimport type {ServerBuild} from \"react-router\";\nimport {createRequestHandler} from \"@react-router/express\";\nimport compression from \"compression\";\nimport express from \"express\";\nimport morgan from \"morgan\";\nimport sourceMapSupport from \"source-map-support\";\nimport getPort from \"get-port\";\n\nfunction parseNumber(raw?: string) {\n if (raw === undefined) return undefined;\n let maybe = Number(raw);\n if (Number.isNaN(maybe)) return undefined;\n return maybe;\n}\n\nexport async function serve() {\n process.env.NODE_ENV = process.env.NODE_ENV ?? \"production\";\n\n sourceMapSupport.install({\n retrieveSourceMap: function (source) {\n let match = source.startsWith(\"file://\");\n if (match) {\n let filePath = url.fileURLToPath(source);\n let sourceMapPath = `${filePath}.map`;\n if (fs.existsSync(sourceMapPath)) {\n return {\n url: source,\n map: fs.readFileSync(sourceMapPath, \"utf8\"),\n };\n }\n }\n return null;\n },\n });\n\n let port = parseNumber(process.env.PORT) ?? (await getPort({port: 3000}));\n\n let buildPathArg = path.join(process.cwd(), \".xyd/build/server/index.js\")\n\n if (!buildPathArg) {\n console.error(`\n Usage: react-router-serve <server-build-path> - e.g. react-router-serve build/server/index.js`);\n process.exit(1);\n }\n\n let buildPath = path.resolve(buildPathArg);\n\n let build: ServerBuild = await import(url.pathToFileURL(buildPath).href);\n\n let onListen = () => {\n let address =\n process.env.HOST ||\n Object.values(os.networkInterfaces())\n .flat()\n .find((ip) => String(ip?.family).includes(\"4\") && !ip?.internal)\n ?.address;\n\n if (!address) {\n console.log(`[xyd-serve] http://localhost:${port}`);\n } else {\n console.log(\n `[xyd-serve] http://localhost:${port} (http://${address}:${port})`\n );\n }\n };\n\n build = {\n ...build,\n assetsBuildDirectory: path.join(process.cwd(), \".xyd/build/client\")\n }\n\n let app = express();\n app.disable(\"x-powered-by\");\n app.use(compression());\n app.use(\n path.posix.join(build.publicPath, \"assets\"),\n express.static(path.join(build.assetsBuildDirectory, \"assets\"), {\n immutable: true,\n maxAge: \"1y\",\n })\n );\n app.use(build.publicPath, express.static(build.assetsBuildDirectory));\n app.use(express.static(\"public\", {maxAge: \"1h\"}));\n app.use(morgan(\"tiny\"));\n\n app.all(\n \"*\",\n createRequestHandler({\n build,\n mode: process.env.NODE_ENV,\n })\n );\n\n let server = process.env.HOST\n ? app.listen(port, process.env.HOST, onListen)\n : app.listen(port, onListen);\n\n [\"SIGTERM\", \"SIGINT\"].forEach((signal) => {\n process.once(signal, () => server?.close(console.error));\n });\n}\n","import {dev} from \"../\"\n\n// Execute the dev function\nawait dev();\n\n"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BAA2B,qBAAqB;AAAA,IAClF;AAAA,IACA,cAAc;AAAA,MACV,SAAS,CAAC,mBAAmB;AAAA,IACjC;AAAA,IACA,SAAS;AAAA;AAAA,MACL,GAAIH,uBAAsB;AAAA,QACtB,KAAK;AAAA,UACD,UAAU;AAAA,QACd;AAAA,MACJ,CAAC;AAAA,MACDD,aAAY;AAAA,QACR,QAAQ,eAAe;AAAA,MAC3B,CAAC;AAAA,MACD,GAAG,eAAe;AAAA,IACtB;AAAA,EACJ,CAAC;AAED,QAAM,QAAQ,OAAO,IAAI;AAEzB,UAAQ,UAAU;AAClB,UAAQ,iBAAiB,EAAC,OAAO,KAAI,CAAC;AAE1C;;;AChEA,OAAOK,SAAQ;AACf,OAAO,QAAQ;AACf,OAAOC,WAAU;AACjB,OAAO,SAAS;AAGhB,SAAQ,4BAA2B;AACnC,OAAO,iBAAiB;AACxB,OAAO,aAAa;AACpB,OAAO,YAAY;AACnB,OAAO,sBAAsB;AAC7B,OAAO,aAAa;;;ACRpB,MAAM,IAAI;","names":["path","fileURLToPath","reactRouter","xydContentVitePlugins","pluginZero","__filename","__dirname","fs","path"]}
|
|
1
|
+
{"version":3,"sources":["../src/run/build.ts","../src/run/dev.ts","../src/run/serve.ts","../src/commands/dev.ts"],"sourcesContent":["import path from \"node:path\";\nimport fs from \"node:fs\";\nimport {fileURLToPath} from \"node:url\";\nimport {execSync} from 'child_process';\n\nimport {build as viteBuild} from 'vite';\nimport tsconfigPaths from \"vite-tsconfig-paths\";\n\nimport {reactRouter} from \"@xyd-js/react-router-dev/vite\";\n\nimport {vitePlugins as xydContentVitePlugins} from \"@xyd-js/content/vite\"\nimport {pluginZero} from \"@xyd-js/plugin-zero\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\n// Define the main function to run the builds\nexport async function build() {\n const resp = await pluginZero()\n if (!resp) {\n throw new Error(\"PluginZero not found\")\n }\n\n const buildDir = path.join(process.cwd(), \".xyd/build\");\n\n {\n // TODO: probably we should have better mechanism - maybe bundle?\n\n const packageJsonPath = path.join(buildDir, 'package.json');\n\n const packageJsonContent = {\n type: \"module\",\n scripts: {},\n dependencies: { // TODO: better\n \"@xyd-js/content\": \"latest\",\n \"@xyd-js/components\": \"latest\",\n \"@xyd-js/framework\": \"latest\",\n \"@xyd-js/theme-poetry\": \"latest\",\n\n\n \"@react-router/node\": \"7.1.1\",\n \"isbot\": \"^5\"\n },\n devDependencies: {}\n };\n\n if (process.env.XYD_DEV_MODE) {\n Object.keys(packageJsonContent.dependencies).forEach((key) => {\n if (key.startsWith(\"@xyd-js/\")) {\n packageJsonContent.dependencies[key] = \"workspace:*\";\n }\n })\n }\n\n // Ensure the build directory exists\n if (!fs.existsSync(buildDir)) {\n fs.mkdirSync(buildDir, {recursive: true});\n }\n\n // Write the package.json file\n fs.writeFileSync(packageJsonPath, JSON.stringify(packageJsonContent, null, 2), 'utf8');\n\n // Install packages inside buildDir\n if (process.env.XYD_DEV_MODE) {\n execSync('pnpm i', {cwd: buildDir, stdio: 'inherit'});\n } else {\n execSync('npm install', {cwd: buildDir, stdio: 'inherit'});\n }\n }\n\n try {\n // Build the client-side bundle\n await viteBuild({\n root: process.env.XYD_CLI ? __dirname : process.env.XYD_DOCUMAN_HOST || path.join(__dirname, \"../host\"),\n plugins: [\n ...(xydContentVitePlugins({\n toc: {\n minDepth: 2,\n }\n }) as Plugin[]),\n reactRouter({\n outDir: buildDir,\n routes: resp.routes\n }),\n tsconfigPaths(),\n ...resp.vitePlugins\n ],\n optimizeDeps: {\n include: [\"react/jsx-runtime\"],\n },\n });\n\n // Build the SSR bundle\n await viteBuild({\n root: process.env.XYD_CLI ? __dirname : process.env.XYD_DOCUMAN_HOST || path.join(__dirname, \"../host\"),\n build: {\n ssr: true,\n },\n plugins: [\n ...(xydContentVitePlugins({\n toc: {\n minDepth: 2,\n }\n }) as Plugin[]),\n reactRouter({\n outDir: buildDir,\n routes: resp.routes\n }),\n tsconfigPaths(),\n ...resp.vitePlugins\n ],\n optimizeDeps: {\n include: [\"react/jsx-runtime\"],\n },\n });\n\n console.log('Build completed successfully.'); // TODO: better message\n } catch (error) {\n console.error('Build failed:', error); // TODO: better message\n }\n}\n\n","import path from \"node:path\";\nimport {fileURLToPath} from \"node:url\";\nimport fs from \"node:fs\";\n\nimport {createServer, searchForWorkspaceRoot} from \"vite\";\n\nimport {reactRouter} from \"@xyd-js/react-router-dev/vite\";\n\nimport {vitePlugins as xydContentVitePlugins} from \"@xyd-js/content/vite\";\nimport {pluginZero} from \"@xyd-js/plugin-zero\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\nconst port = process.env.XYD_PORT ? parseInt(process.env.XYD_PORT) : 5175;\n\nexport async function dev() {\n const respPluginZero = await pluginZero()\n if (!respPluginZero) {\n throw new Error(\"PluginZero not found\")\n }\n\n const allowCwd = searchForWorkspaceRoot(process.cwd())\n\n const preview = await createServer({\n root: process.env.XYD_CLI ? __dirname : process.env.XYD_DOCUMAN_HOST || path.join(__dirname, \"../host\"), // TODO: bundler?\n server: {\n port: port,\n fs: {\n allow: [\n allowCwd,\n process.env.XYD_CLI ? __dirname : path.join(__dirname, \"../host\"),\n ]\n }\n },\n build: {\n rollupOptions: {\n // Exclude package `B` from the client-side bundle\n external: [\"@xyd-js/uniform\", \"@xyd-js/uniform/content\", \"@xyd-js/plugin-zero\"],\n },\n },\n ssr: {\n external: [\"@xyd-js/uniform\", \"@xyd-js/uniform/content\", \"@xyd-js/plugin-zero\"],\n },\n optimizeDeps: {\n include: [\"react/jsx-runtime\"],\n },\n plugins: [ // TODO: fix plugin ts\n ...(xydContentVitePlugins({\n toc: {\n minDepth: 2,\n }\n }) as Plugin[]),\n reactRouter({\n routes: respPluginZero.routes\n }),\n ...respPluginZero.vitePlugins,\n ]\n });\n\n // Set up manual file watcher for markdown files TODO: better way? + HMR only for specific components instead or reload a pag\n const watcher = fs.watch(allowCwd, { recursive: true }, (eventType, filename) => {\n if (!filename) {\n console.log(\"[xyd:dev] Received empty filename\");\n return;\n }\n \n const filePath = path.join(allowCwd, filename);\n \n if (filePath.endsWith('.md') || filePath.endsWith('.mdx')) {\n const relativePath = path.relative(allowCwd, filePath);\n const urlPath = '/' + relativePath.replace(/\\\\/g, '/');\n \n preview.ws.send({\n type: 'full-reload',\n path: urlPath\n });\n }\n });\n\n // Log any watcher errors\n watcher.on('error', (error) => {\n console.error(\"[xyd:dev] File watcher error:\", error);\n });\n\n await preview.listen(port);\n\n preview.printUrls();\n preview.bindCLIShortcuts({print: true});\n\n // Clean up watcher when server is closed\n preview.httpServer?.once('close', () => {\n watcher.close();\n });\n}","import fs from \"node:fs\";\nimport os from \"node:os\";\nimport path from \"node:path\";\nimport url from \"node:url\";\n\nimport type {ServerBuild} from \"react-router\";\nimport {createRequestHandler} from \"@react-router/express\";\nimport compression from \"compression\";\nimport express from \"express\";\nimport morgan from \"morgan\";\nimport sourceMapSupport from \"source-map-support\";\nimport getPort from \"get-port\";\n\nfunction parseNumber(raw?: string) {\n if (raw === undefined) return undefined;\n let maybe = Number(raw);\n if (Number.isNaN(maybe)) return undefined;\n return maybe;\n}\n\nexport async function serve() {\n process.env.NODE_ENV = process.env.NODE_ENV ?? \"production\";\n\n sourceMapSupport.install({\n retrieveSourceMap: function (source) {\n let match = source.startsWith(\"file://\");\n if (match) {\n let filePath = url.fileURLToPath(source);\n let sourceMapPath = `${filePath}.map`;\n if (fs.existsSync(sourceMapPath)) {\n return {\n url: source,\n map: fs.readFileSync(sourceMapPath, \"utf8\"),\n };\n }\n }\n return null;\n },\n });\n\n let port = parseNumber(process.env.PORT) ?? (await getPort({port: 3000}));\n\n let buildPathArg = path.join(process.cwd(), \".xyd/build/server/index.js\")\n\n if (!buildPathArg) {\n console.error(`\n Usage: react-router-serve <server-build-path> - e.g. react-router-serve build/server/index.js`);\n process.exit(1);\n }\n\n let buildPath = path.resolve(buildPathArg);\n\n let build: ServerBuild = await import(url.pathToFileURL(buildPath).href);\n\n let onListen = () => {\n let address =\n process.env.HOST ||\n Object.values(os.networkInterfaces())\n .flat()\n .find((ip) => String(ip?.family).includes(\"4\") && !ip?.internal)\n ?.address;\n\n if (!address) {\n console.log(`[xyd-serve] http://localhost:${port}`);\n } else {\n console.log(\n `[xyd-serve] http://localhost:${port} (http://${address}:${port})`\n );\n }\n };\n\n build = {\n ...build,\n assetsBuildDirectory: path.join(process.cwd(), \".xyd/build/client\")\n }\n\n let app = express();\n app.disable(\"x-powered-by\");\n app.use(compression());\n app.use(\n path.posix.join(build.publicPath, \"assets\"),\n express.static(path.join(build.assetsBuildDirectory, \"assets\"), {\n immutable: true,\n maxAge: \"1y\",\n })\n );\n app.use(build.publicPath, express.static(build.assetsBuildDirectory));\n app.use(express.static(\"public\", {maxAge: \"1h\"}));\n app.use(morgan(\"tiny\"));\n\n app.all(\n \"*\",\n createRequestHandler({\n build,\n mode: process.env.NODE_ENV,\n })\n );\n\n let server = process.env.HOST\n ? app.listen(port, process.env.HOST, onListen)\n : app.listen(port, onListen);\n\n [\"SIGTERM\", \"SIGINT\"].forEach((signal) => {\n process.once(signal, () => server?.close(console.error));\n });\n}\n","import {dev} from \"../\"\n\n// Execute the dev function\nawait dev();\n\n"],"mappings":";AAAA,OAAO,UAAU;AACjB,OAAO,QAAQ;AACf,SAAQ,qBAAoB;AAG5B,SAAQ,SAAS,iBAAgB;AACjC,OAAO,mBAAmB;AAE1B,SAAQ,mBAAkB;AAE1B,SAAQ,eAAe,6BAA4B;AACnD,SAAQ,kBAAiB;AAEzB,IAAM,aAAa,cAAc,YAAY,GAAG;AAChD,IAAM,YAAY,KAAK,QAAQ,UAAU;;;ACdzC,OAAOA,WAAU;AACjB,SAAQ,iBAAAC,sBAAoB;AAC5B,OAAOC,SAAQ;AAEf,SAAQ,cAAc,8BAA6B;AAEnD,SAAQ,eAAAC,oBAAkB;AAE1B,SAAQ,eAAeC,8BAA4B;AACnD,SAAQ,cAAAC,mBAAiB;AAEzB,IAAMC,cAAaL,eAAc,Y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UAAM,WAAWF,MAAK,KAAK,UAAU,QAAQ;AAE7C,QAAI,SAAS,SAAS,KAAK,KAAK,SAAS,SAAS,MAAM,GAAG;AACvD,YAAM,eAAeA,MAAK,SAAS,UAAU,QAAQ;AACrD,YAAM,UAAU,MAAM,aAAa,QAAQ,OAAO,GAAG;AAErD,cAAQ,GAAG,KAAK;AAAA,QACZ,MAAM;AAAA,QACN,MAAM;AAAA,MACV,CAAC;AAAA,IACL;AAAA,EACJ,CAAC;AAGD,UAAQ,GAAG,SAAS,CAAC,UAAU;AAC3B,YAAQ,MAAM,iCAAiC,KAAK;AAAA,EACxD,CAAC;AAED,QAAM,QAAQ,OAAO,IAAI;AAEzB,UAAQ,UAAU;AAClB,UAAQ,iBAAiB,EAAC,OAAO,KAAI,CAAC;AAGtC,UAAQ,YAAY,KAAK,SAAS,MAAM;AACpC,YAAQ,MAAM;AAAA,EAClB,CAAC;AACL;;;AC9FA,OAAOQ,SAAQ;AACf,OAAO,QAAQ;AACf,OAAOC,WAAU;AACjB,OAAO,SAAS;AAGhB,SAAQ,4BAA2B;AACnC,OAAO,iBAAiB;AACxB,OAAO,aAAa;AACpB,OAAO,YAAY;AACnB,OAAO,sBAAsB;AAC7B,OAAO,aAAa;;;ACRpB,MAAM,IAAI;","names":["path","fileURLToPath","fs","reactRouter","xydContentVitePlugins","pluginZero","__filename","__dirname","fs","path"]}
|
package/dist/index.js
CHANGED
|
@@ -100,6 +100,7 @@ async function build() {
|
|
|
100
100
|
// src/run/dev.ts
|
|
101
101
|
import path2 from "node:path";
|
|
102
102
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
103
|
+
import fs2 from "node:fs";
|
|
103
104
|
import { createServer, searchForWorkspaceRoot } from "vite";
|
|
104
105
|
import { reactRouter as reactRouter2 } from "@xyd-js/react-router-dev/vite";
|
|
105
106
|
import { vitePlugins as xydContentVitePlugins2 } from "@xyd-js/content/vite";
|
|
@@ -121,8 +122,7 @@ async function dev() {
|
|
|
121
122
|
fs: {
|
|
122
123
|
allow: [
|
|
123
124
|
allowCwd,
|
|
124
|
-
process.env.XYD_CLI ? path2.join(__dirname2, "
|
|
125
|
-
// path.join(__dirname, "../node_modules") // Ensure node_modules from xyd-documan is included
|
|
125
|
+
process.env.XYD_CLI ? __dirname2 : path2.join(__dirname2, "../host")
|
|
126
126
|
]
|
|
127
127
|
}
|
|
128
128
|
},
|
|
@@ -151,13 +151,34 @@ async function dev() {
|
|
|
151
151
|
...respPluginZero.vitePlugins
|
|
152
152
|
]
|
|
153
153
|
});
|
|
154
|
+
const watcher = fs2.watch(allowCwd, { recursive: true }, (eventType, filename) => {
|
|
155
|
+
if (!filename) {
|
|
156
|
+
console.log("[xyd:dev] Received empty filename");
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
const filePath = path2.join(allowCwd, filename);
|
|
160
|
+
if (filePath.endsWith(".md") || filePath.endsWith(".mdx")) {
|
|
161
|
+
const relativePath = path2.relative(allowCwd, filePath);
|
|
162
|
+
const urlPath = "/" + relativePath.replace(/\\/g, "/");
|
|
163
|
+
preview.ws.send({
|
|
164
|
+
type: "full-reload",
|
|
165
|
+
path: urlPath
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
watcher.on("error", (error) => {
|
|
170
|
+
console.error("[xyd:dev] File watcher error:", error);
|
|
171
|
+
});
|
|
154
172
|
await preview.listen(port);
|
|
155
173
|
preview.printUrls();
|
|
156
174
|
preview.bindCLIShortcuts({ print: true });
|
|
175
|
+
preview.httpServer?.once("close", () => {
|
|
176
|
+
watcher.close();
|
|
177
|
+
});
|
|
157
178
|
}
|
|
158
179
|
|
|
159
180
|
// src/run/serve.ts
|
|
160
|
-
import
|
|
181
|
+
import fs3 from "node:fs";
|
|
161
182
|
import os from "node:os";
|
|
162
183
|
import path3 from "node:path";
|
|
163
184
|
import url from "node:url";
|
|
@@ -181,10 +202,10 @@ async function serve() {
|
|
|
181
202
|
if (match) {
|
|
182
203
|
let filePath = url.fileURLToPath(source);
|
|
183
204
|
let sourceMapPath = `${filePath}.map`;
|
|
184
|
-
if (
|
|
205
|
+
if (fs3.existsSync(sourceMapPath)) {
|
|
185
206
|
return {
|
|
186
207
|
url: source,
|
|
187
|
-
map:
|
|
208
|
+
map: fs3.readFileSync(sourceMapPath, "utf8")
|
|
188
209
|
};
|
|
189
210
|
}
|
|
190
211
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/run/build.ts","../src/run/dev.ts","../src/run/serve.ts"],"sourcesContent":["import path from \"node:path\";\nimport fs from \"node:fs\";\nimport {fileURLToPath} from \"node:url\";\nimport {execSync} from 'child_process';\n\nimport {build as viteBuild} from 'vite';\nimport tsconfigPaths from \"vite-tsconfig-paths\";\n\nimport {reactRouter} from \"@xyd-js/react-router-dev/vite\";\n\nimport {vitePlugins as xydContentVitePlugins} from \"@xyd-js/content/vite\"\nimport {pluginZero} from \"@xyd-js/plugin-zero\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\n// Define the main function to run the builds\nexport async function build() {\n const resp = await pluginZero()\n if (!resp) {\n throw new Error(\"PluginZero not found\")\n }\n\n const buildDir = path.join(process.cwd(), \".xyd/build\");\n\n {\n // TODO: probably we should have better mechanism - maybe bundle?\n\n const packageJsonPath = path.join(buildDir, 'package.json');\n\n const packageJsonContent = {\n type: \"module\",\n scripts: {},\n dependencies: { // TODO: better\n \"@xyd-js/content\": \"latest\",\n \"@xyd-js/components\": \"latest\",\n \"@xyd-js/framework\": \"latest\",\n \"@xyd-js/theme-poetry\": \"latest\",\n\n\n \"@react-router/node\": \"7.1.1\",\n \"isbot\": \"^5\"\n },\n devDependencies: {}\n };\n\n if (process.env.XYD_DEV_MODE) {\n Object.keys(packageJsonContent.dependencies).forEach((key) => {\n if (key.startsWith(\"@xyd-js/\")) {\n packageJsonContent.dependencies[key] = \"workspace:*\";\n }\n })\n }\n\n // Ensure the build directory exists\n if (!fs.existsSync(buildDir)) {\n fs.mkdirSync(buildDir, {recursive: true});\n }\n\n // Write the package.json file\n fs.writeFileSync(packageJsonPath, JSON.stringify(packageJsonContent, null, 2), 'utf8');\n\n // Install packages inside buildDir\n if (process.env.XYD_DEV_MODE) {\n execSync('pnpm i', {cwd: buildDir, stdio: 'inherit'});\n } else {\n execSync('npm install', {cwd: buildDir, stdio: 'inherit'});\n }\n }\n\n try {\n // Build the client-side bundle\n await viteBuild({\n root: process.env.XYD_CLI ? __dirname : process.env.XYD_DOCUMAN_HOST || path.join(__dirname, \"../host\"),\n plugins: [\n ...(xydContentVitePlugins({\n toc: {\n minDepth: 2,\n }\n }) as Plugin[]),\n reactRouter({\n outDir: buildDir,\n routes: resp.routes\n }),\n tsconfigPaths(),\n ...resp.vitePlugins\n ],\n optimizeDeps: {\n include: [\"react/jsx-runtime\"],\n },\n });\n\n // Build the SSR bundle\n await viteBuild({\n root: process.env.XYD_CLI ? __dirname : process.env.XYD_DOCUMAN_HOST || path.join(__dirname, \"../host\"),\n build: {\n ssr: true,\n },\n plugins: [\n ...(xydContentVitePlugins({\n toc: {\n minDepth: 2,\n }\n }) as Plugin[]),\n reactRouter({\n outDir: buildDir,\n routes: resp.routes\n }),\n tsconfigPaths(),\n ...resp.vitePlugins\n ],\n optimizeDeps: {\n include: [\"react/jsx-runtime\"],\n },\n });\n\n console.log('Build completed successfully.'); // TODO: better message\n } catch (error) {\n console.error('Build failed:', error); // TODO: better message\n }\n}\n\n","import path from \"node:path\";\nimport {fileURLToPath} from \"node:url\";\nimport {createServer, searchForWorkspaceRoot} from \"vite\";\n\nimport {reactRouter} from \"@xyd-js/react-router-dev/vite\";\n\nimport {vitePlugins as xydContentVitePlugins} from \"@xyd-js/content/vite\";\nimport {pluginZero} from \"@xyd-js/plugin-zero\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\nconst port = process.env.XYD_PORT ? parseInt(process.env.XYD_PORT) : 5175;\n\nexport async function dev() {\n const respPluginZero = await pluginZero()\n if (!respPluginZero) {\n throw new Error(\"PluginZero not found\")\n }\n\n const allowCwd = searchForWorkspaceRoot(process.cwd())\n\n const preview = await createServer({\n root: process.env.XYD_CLI ? __dirname : process.env.XYD_DOCUMAN_HOST || path.join(__dirname, \"../host\"), // TODO: bundler?\n server: {\n port: port,\n fs: {\n allow: [\n allowCwd,\n process.env.XYD_CLI ? path.join(__dirname, \"../../\") : \"\",\n // path.join(__dirname, \"../node_modules\") // Ensure node_modules from xyd-documan is included\n ]\n }\n },\n build: {\n rollupOptions: {\n // Exclude package `B` from the client-side bundle\n external: [\"@xyd-js/uniform\", \"@xyd-js/uniform/content\", \"@xyd-js/plugin-zero\"],\n },\n },\n ssr: {\n external: [\"@xyd-js/uniform\", \"@xyd-js/uniform/content\", \"@xyd-js/plugin-zero\"],\n },\n optimizeDeps: {\n include: [\"react/jsx-runtime\"],\n },\n plugins: [ // TODO: fix plugin ts\n ...(xydContentVitePlugins({\n toc: {\n minDepth: 2,\n }\n }) as Plugin[]),\n reactRouter({\n routes: respPluginZero.routes\n }),\n ...respPluginZero.vitePlugins,\n ],\n });\n\n await preview.listen(port);\n\n preview.printUrls();\n preview.bindCLIShortcuts({print: true});\n\n}","import fs from \"node:fs\";\nimport os from \"node:os\";\nimport path from \"node:path\";\nimport url from \"node:url\";\n\nimport type {ServerBuild} from \"react-router\";\nimport {createRequestHandler} from \"@react-router/express\";\nimport compression from \"compression\";\nimport express from \"express\";\nimport morgan from \"morgan\";\nimport sourceMapSupport from \"source-map-support\";\nimport getPort from \"get-port\";\n\nfunction parseNumber(raw?: string) {\n if (raw === undefined) return undefined;\n let maybe = Number(raw);\n if (Number.isNaN(maybe)) return undefined;\n return maybe;\n}\n\nexport async function serve() {\n process.env.NODE_ENV = process.env.NODE_ENV ?? \"production\";\n\n sourceMapSupport.install({\n retrieveSourceMap: function (source) {\n let match = source.startsWith(\"file://\");\n if (match) {\n let filePath = url.fileURLToPath(source);\n let sourceMapPath = `${filePath}.map`;\n if (fs.existsSync(sourceMapPath)) {\n return {\n url: source,\n map: fs.readFileSync(sourceMapPath, \"utf8\"),\n };\n }\n }\n return null;\n },\n });\n\n let port = parseNumber(process.env.PORT) ?? (await getPort({port: 3000}));\n\n let buildPathArg = path.join(process.cwd(), \".xyd/build/server/index.js\")\n\n if (!buildPathArg) {\n console.error(`\n Usage: react-router-serve <server-build-path> - e.g. react-router-serve build/server/index.js`);\n process.exit(1);\n }\n\n let buildPath = path.resolve(buildPathArg);\n\n let build: ServerBuild = await import(url.pathToFileURL(buildPath).href);\n\n let onListen = () => {\n let address =\n process.env.HOST ||\n Object.values(os.networkInterfaces())\n .flat()\n .find((ip) => String(ip?.family).includes(\"4\") && !ip?.internal)\n ?.address;\n\n if (!address) {\n console.log(`[xyd-serve] http://localhost:${port}`);\n } else {\n console.log(\n `[xyd-serve] http://localhost:${port} (http://${address}:${port})`\n );\n }\n };\n\n build = {\n ...build,\n assetsBuildDirectory: path.join(process.cwd(), \".xyd/build/client\")\n }\n\n let app = express();\n app.disable(\"x-powered-by\");\n app.use(compression());\n app.use(\n path.posix.join(build.publicPath, \"assets\"),\n express.static(path.join(build.assetsBuildDirectory, \"assets\"), {\n immutable: true,\n maxAge: \"1y\",\n })\n );\n app.use(build.publicPath, express.static(build.assetsBuildDirectory));\n app.use(express.static(\"public\", {maxAge: \"1h\"}));\n app.use(morgan(\"tiny\"));\n\n app.all(\n \"*\",\n createRequestHandler({\n build,\n mode: process.env.NODE_ENV,\n })\n );\n\n let server = process.env.HOST\n ? app.listen(port, process.env.HOST, onListen)\n : app.listen(port, onListen);\n\n [\"SIGTERM\", \"SIGINT\"].forEach((signal) => {\n process.once(signal, () => server?.close(console.error));\n });\n}\n"],"mappings":";AAAA,OAAO,UAAU;AACjB,OAAO,QAAQ;AACf,SAAQ,qBAAoB;AAC5B,SAAQ,gBAAe;AAEvB,SAAQ,SAAS,iBAAgB;AACjC,OAAO,mBAAmB;AAE1B,SAAQ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I,gCAAgCD,KAAI,EAAE;AAAA,IACtD,OAAO;AACH,cAAQ;AAAA,QACJ,gCAAgCA,KAAI,YAAY,OAAO,IAAIA,KAAI;AAAA,MACnE;AAAA,IACJ;AAAA,EACJ;AAEA,EAAAC,SAAQ;AAAA,IACJ,GAAGA;AAAA,IACH,sBAAsBF,MAAK,KAAK,QAAQ,IAAI,GAAG,mBAAmB;AAAA,EACtE;AAEA,MAAI,MAAM,QAAQ;AAClB,MAAI,QAAQ,cAAc;AAC1B,MAAI,IAAI,YAAY,CAAC;AACrB,MAAI;AAAA,IACAA,MAAK,MAAM,KAAKE,OAAM,YAAY,QAAQ;AAAA,IAC1C,QAAQ,OAAOF,MAAK,KAAKE,OAAM,sBAAsB,QAAQ,GAAG;AAAA,MAC5D,WAAW;AAAA,MACX,QAAQ;AAAA,IACZ,CAAC;AAAA,EACL;AACA,MAAI,IAAIA,OAAM,YAAY,QAAQ,OAAOA,OAAM,oBAAoB,CAAC;AACpE,MAAI,IAAI,QAAQ,OAAO,UAAU,EAAC,QAAQ,KAAI,CAAC,CAAC;AAChD,MAAI,IAAI,OAAO,MAAM,CAAC;AAEtB,MAAI;AAAA,IACA;AAAA,IACA,qBAAqB;AAAA,MACjB,OAAAA;AAAA,MACA,MAAM,QAAQ,IAAI;AAAA,IACtB,CAAC;AAAA,EACL;AAEA,MAAI,SAAS,QAAQ,IAAI,OACnB,IAAI,OAAOD,OAAM,QAAQ,IAAI,MAAM,QAAQ,IAC3C,IAAI,OAAOA,OAAM,QAAQ;AAE/B,GAAC,WAAW,QAAQ,EAAE,QAAQ,CAAC,WAAW;AACtC,YAAQ,KAAK,QAAQ,MAAM,QAAQ,MAAM,QAAQ,KAAK,CAAC;AAAA,EAC3D,CAAC;AACL;","names":["path","fileURLToPath","reactRouter","xydContentVitePlugins","pluginZero","__filename","__dirname","fs","path","port","build"]}
|
|
1
|
+
{"version":3,"sources":["../src/run/build.ts","../src/run/dev.ts","../src/run/serve.ts"],"sourcesContent":["import path from \"node:path\";\nimport fs from \"node:fs\";\nimport {fileURLToPath} from \"node:url\";\nimport {execSync} from 'child_process';\n\nimport {build as viteBuild} from 'vite';\nimport tsconfigPaths from \"vite-tsconfig-paths\";\n\nimport {reactRouter} from \"@xyd-js/react-router-dev/vite\";\n\nimport {vitePlugins as xydContentVitePlugins} from \"@xyd-js/content/vite\"\nimport {pluginZero} from \"@xyd-js/plugin-zero\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\n// Define the main function to run the builds\nexport async function build() {\n const resp = await pluginZero()\n if (!resp) {\n throw new Error(\"PluginZero not found\")\n }\n\n const buildDir = path.join(process.cwd(), \".xyd/build\");\n\n {\n // TODO: probably we should have better mechanism - maybe bundle?\n\n const packageJsonPath = path.join(buildDir, 'package.json');\n\n const packageJsonContent = {\n type: \"module\",\n scripts: {},\n dependencies: { // TODO: better\n \"@xyd-js/content\": \"latest\",\n \"@xyd-js/components\": \"latest\",\n \"@xyd-js/framework\": \"latest\",\n \"@xyd-js/theme-poetry\": \"latest\",\n\n\n \"@react-router/node\": \"7.1.1\",\n \"isbot\": \"^5\"\n },\n devDependencies: {}\n };\n\n if (process.env.XYD_DEV_MODE) {\n Object.keys(packageJsonContent.dependencies).forEach((key) => {\n if (key.startsWith(\"@xyd-js/\")) {\n packageJsonContent.dependencies[key] = \"workspace:*\";\n }\n })\n }\n\n // Ensure the build directory exists\n if (!fs.existsSync(buildDir)) {\n fs.mkdirSync(buildDir, {recursive: true});\n }\n\n // Write the package.json file\n fs.writeFileSync(packageJsonPath, JSON.stringify(packageJsonContent, null, 2), 'utf8');\n\n // Install packages inside buildDir\n if (process.env.XYD_DEV_MODE) {\n execSync('pnpm i', {cwd: buildDir, stdio: 'inherit'});\n } else {\n execSync('npm install', {cwd: buildDir, stdio: 'inherit'});\n }\n }\n\n try {\n // Build the client-side bundle\n await viteBuild({\n root: process.env.XYD_CLI ? __dirname : process.env.XYD_DOCUMAN_HOST || path.join(__dirname, \"../host\"),\n plugins: [\n ...(xydContentVitePlugins({\n toc: {\n minDepth: 2,\n }\n }) as Plugin[]),\n reactRouter({\n outDir: buildDir,\n routes: resp.routes\n }),\n tsconfigPaths(),\n ...resp.vitePlugins\n ],\n optimizeDeps: {\n include: [\"react/jsx-runtime\"],\n },\n });\n\n // Build the SSR bundle\n await viteBuild({\n root: process.env.XYD_CLI ? __dirname : process.env.XYD_DOCUMAN_HOST || path.join(__dirname, \"../host\"),\n build: {\n ssr: true,\n },\n plugins: [\n ...(xydContentVitePlugins({\n toc: {\n minDepth: 2,\n }\n }) as Plugin[]),\n reactRouter({\n outDir: buildDir,\n routes: resp.routes\n }),\n tsconfigPaths(),\n ...resp.vitePlugins\n ],\n optimizeDeps: {\n include: [\"react/jsx-runtime\"],\n },\n });\n\n console.log('Build completed successfully.'); // TODO: better message\n } catch (error) {\n console.error('Build failed:', error); // TODO: better message\n }\n}\n\n","import path from \"node:path\";\nimport {fileURLToPath} from \"node:url\";\nimport fs from \"node:fs\";\n\nimport {createServer, searchForWorkspaceRoot} from \"vite\";\n\nimport {reactRouter} from \"@xyd-js/react-router-dev/vite\";\n\nimport {vitePlugins as xydContentVitePlugins} from \"@xyd-js/content/vite\";\nimport {pluginZero} from \"@xyd-js/plugin-zero\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\nconst port = process.env.XYD_PORT ? parseInt(process.env.XYD_PORT) : 5175;\n\nexport async function dev() {\n const respPluginZero = await pluginZero()\n if (!respPluginZero) {\n throw new Error(\"PluginZero not found\")\n }\n\n const allowCwd = searchForWorkspaceRoot(process.cwd())\n\n const preview = await createServer({\n root: process.env.XYD_CLI ? __dirname : process.env.XYD_DOCUMAN_HOST || path.join(__dirname, \"../host\"), // TODO: bundler?\n server: {\n port: port,\n fs: {\n allow: [\n allowCwd,\n process.env.XYD_CLI ? __dirname : path.join(__dirname, \"../host\"),\n ]\n }\n },\n build: {\n rollupOptions: {\n // Exclude package `B` from the client-side bundle\n external: [\"@xyd-js/uniform\", \"@xyd-js/uniform/content\", \"@xyd-js/plugin-zero\"],\n },\n },\n ssr: {\n external: [\"@xyd-js/uniform\", \"@xyd-js/uniform/content\", \"@xyd-js/plugin-zero\"],\n },\n optimizeDeps: {\n include: [\"react/jsx-runtime\"],\n },\n plugins: [ // TODO: fix plugin ts\n ...(xydContentVitePlugins({\n toc: {\n minDepth: 2,\n }\n }) as Plugin[]),\n reactRouter({\n routes: respPluginZero.routes\n }),\n ...respPluginZero.vitePlugins,\n ]\n });\n\n // Set up manual file watcher for markdown files TODO: better way? + HMR only for specific components instead or reload a pag\n const watcher = fs.watch(allowCwd, { recursive: true }, (eventType, filename) => {\n if (!filename) {\n console.log(\"[xyd:dev] Received empty filename\");\n return;\n }\n \n const filePath = path.join(allowCwd, filename);\n \n if (filePath.endsWith('.md') || filePath.endsWith('.mdx')) {\n const relativePath = path.relative(allowCwd, filePath);\n const urlPath = '/' + relativePath.replace(/\\\\/g, '/');\n \n preview.ws.send({\n type: 'full-reload',\n path: urlPath\n });\n }\n });\n\n // Log any watcher errors\n watcher.on('error', (error) => {\n console.error(\"[xyd:dev] File watcher error:\", error);\n });\n\n await preview.listen(port);\n\n preview.printUrls();\n preview.bindCLIShortcuts({print: true});\n\n // Clean up watcher when server is closed\n preview.httpServer?.once('close', () => {\n watcher.close();\n });\n}","import fs from \"node:fs\";\nimport os from \"node:os\";\nimport path from \"node:path\";\nimport url from \"node:url\";\n\nimport type {ServerBuild} from \"react-router\";\nimport {createRequestHandler} from \"@react-router/express\";\nimport compression from \"compression\";\nimport express from \"express\";\nimport morgan from \"morgan\";\nimport sourceMapSupport from \"source-map-support\";\nimport getPort from \"get-port\";\n\nfunction parseNumber(raw?: string) {\n if (raw === undefined) return undefined;\n let maybe = Number(raw);\n if (Number.isNaN(maybe)) return undefined;\n return maybe;\n}\n\nexport async function serve() {\n process.env.NODE_ENV = process.env.NODE_ENV ?? \"production\";\n\n sourceMapSupport.install({\n retrieveSourceMap: function (source) {\n let match = source.startsWith(\"file://\");\n if (match) {\n let filePath = url.fileURLToPath(source);\n let sourceMapPath = `${filePath}.map`;\n if (fs.existsSync(sourceMapPath)) {\n return {\n url: source,\n map: fs.readFileSync(sourceMapPath, \"utf8\"),\n };\n }\n }\n return null;\n },\n });\n\n let port = parseNumber(process.env.PORT) ?? (await getPort({port: 3000}));\n\n let buildPathArg = path.join(process.cwd(), \".xyd/build/server/index.js\")\n\n if (!buildPathArg) {\n console.error(`\n Usage: react-router-serve <server-build-path> - e.g. react-router-serve build/server/index.js`);\n process.exit(1);\n }\n\n let buildPath = path.resolve(buildPathArg);\n\n let build: ServerBuild = await import(url.pathToFileURL(buildPath).href);\n\n let onListen = () => {\n let address =\n process.env.HOST ||\n Object.values(os.networkInterfaces())\n .flat()\n .find((ip) => String(ip?.family).includes(\"4\") && !ip?.internal)\n ?.address;\n\n if (!address) {\n console.log(`[xyd-serve] http://localhost:${port}`);\n } else {\n console.log(\n `[xyd-serve] http://localhost:${port} (http://${address}:${port})`\n );\n }\n };\n\n build = {\n ...build,\n assetsBuildDirectory: path.join(process.cwd(), \".xyd/build/client\")\n }\n\n let app = express();\n app.disable(\"x-powered-by\");\n app.use(compression());\n app.use(\n path.posix.join(build.publicPath, \"assets\"),\n express.static(path.join(build.assetsBuildDirectory, \"assets\"), {\n immutable: true,\n maxAge: \"1y\",\n })\n );\n app.use(build.publicPath, express.static(build.assetsBuildDirectory));\n app.use(express.static(\"public\", {maxAge: \"1h\"}));\n app.use(morgan(\"tiny\"));\n\n app.all(\n \"*\",\n createRequestHandler({\n build,\n mode: process.env.NODE_ENV,\n })\n );\n\n let server = process.env.HOST\n ? app.listen(port, process.env.HOST, onListen)\n : app.listen(port, onListen);\n\n [\"SIGTERM\", \"SIGINT\"].forEach((signal) => {\n process.once(signal, () => server?.close(console.error));\n });\n}\n"],"mappings":";AAAA,OAAO,UAAU;AACjB,OAAO,QAAQ;AACf,SAAQ,qBAAoB;AAC5B,SAAQ,gBAAe;A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A,MAAI,IAAIA,OAAM,YAAY,QAAQ,OAAOA,OAAM,oBAAoB,CAAC;AACpE,MAAI,IAAI,QAAQ,OAAO,UAAU,EAAC,QAAQ,KAAI,CAAC,CAAC;AAChD,MAAI,IAAI,OAAO,MAAM,CAAC;AAEtB,MAAI;AAAA,IACA;AAAA,IACA,qBAAqB;AAAA,MACjB,OAAAA;AAAA,MACA,MAAM,QAAQ,IAAI;AAAA,IACtB,CAAC;AAAA,EACL;AAEA,MAAI,SAAS,QAAQ,IAAI,OACnB,IAAI,OAAOD,OAAM,QAAQ,IAAI,MAAM,QAAQ,IAC3C,IAAI,OAAOA,OAAM,QAAQ;AAE/B,GAAC,WAAW,QAAQ,EAAE,QAAQ,CAAC,WAAW;AACtC,YAAQ,KAAK,QAAQ,MAAM,QAAQ,MAAM,QAAQ,KAAK,CAAC;AAAA,EAC3D,CAAC;AACL;","names":["path","fileURLToPath","fs","reactRouter","xydContentVitePlugins","pluginZero","__filename","__dirname","fs","path","port","build"]}
|
package/dist/serve.js
CHANGED
|
@@ -13,6 +13,7 @@ var __dirname = path.dirname(__filename);
|
|
|
13
13
|
// src/run/dev.ts
|
|
14
14
|
import path2 from "node:path";
|
|
15
15
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
16
|
+
import fs2 from "node:fs";
|
|
16
17
|
import { createServer, searchForWorkspaceRoot } from "vite";
|
|
17
18
|
import { reactRouter as reactRouter2 } from "@xyd-js/react-router-dev/vite";
|
|
18
19
|
import { vitePlugins as xydContentVitePlugins2 } from "@xyd-js/content/vite";
|
|
@@ -22,7 +23,7 @@ var __dirname2 = path2.dirname(__filename2);
|
|
|
22
23
|
var port = process.env.XYD_PORT ? parseInt(process.env.XYD_PORT) : 5175;
|
|
23
24
|
|
|
24
25
|
// src/run/serve.ts
|
|
25
|
-
import
|
|
26
|
+
import fs3 from "node:fs";
|
|
26
27
|
import os from "node:os";
|
|
27
28
|
import path3 from "node:path";
|
|
28
29
|
import url from "node:url";
|
|
@@ -46,10 +47,10 @@ async function serve() {
|
|
|
46
47
|
if (match) {
|
|
47
48
|
let filePath = url.fileURLToPath(source);
|
|
48
49
|
let sourceMapPath = `${filePath}.map`;
|
|
49
|
-
if (
|
|
50
|
+
if (fs3.existsSync(sourceMapPath)) {
|
|
50
51
|
return {
|
|
51
52
|
url: source,
|
|
52
|
-
map:
|
|
53
|
+
map: fs3.readFileSync(sourceMapPath, "utf8")
|
|
53
54
|
};
|
|
54
55
|
}
|
|
55
56
|
}
|
package/dist/serve.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/run/build.ts","../src/run/dev.ts","../src/run/serve.ts","../src/commands/serve.ts"],"sourcesContent":["import path from \"node:path\";\nimport fs from \"node:fs\";\nimport {fileURLToPath} from \"node:url\";\nimport {execSync} from 'child_process';\n\nimport {build as viteBuild} from 'vite';\nimport tsconfigPaths from \"vite-tsconfig-paths\";\n\nimport {reactRouter} from \"@xyd-js/react-router-dev/vite\";\n\nimport {vitePlugins as xydContentVitePlugins} from \"@xyd-js/content/vite\"\nimport {pluginZero} from \"@xyd-js/plugin-zero\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\n// Define the main function to run the builds\nexport async function build() {\n const resp = await pluginZero()\n if (!resp) {\n throw new Error(\"PluginZero not found\")\n }\n\n const buildDir = path.join(process.cwd(), \".xyd/build\");\n\n {\n // TODO: probably we should have better mechanism - maybe bundle?\n\n const packageJsonPath = path.join(buildDir, 'package.json');\n\n const packageJsonContent = {\n type: \"module\",\n scripts: {},\n dependencies: { // TODO: better\n \"@xyd-js/content\": \"latest\",\n \"@xyd-js/components\": \"latest\",\n \"@xyd-js/framework\": \"latest\",\n \"@xyd-js/theme-poetry\": \"latest\",\n\n\n \"@react-router/node\": \"7.1.1\",\n \"isbot\": \"^5\"\n },\n devDependencies: {}\n };\n\n if (process.env.XYD_DEV_MODE) {\n Object.keys(packageJsonContent.dependencies).forEach((key) => {\n if (key.startsWith(\"@xyd-js/\")) {\n packageJsonContent.dependencies[key] = \"workspace:*\";\n }\n })\n }\n\n // Ensure the build directory exists\n if (!fs.existsSync(buildDir)) {\n fs.mkdirSync(buildDir, {recursive: true});\n }\n\n // Write the package.json file\n fs.writeFileSync(packageJsonPath, JSON.stringify(packageJsonContent, null, 2), 'utf8');\n\n // Install packages inside buildDir\n if (process.env.XYD_DEV_MODE) {\n execSync('pnpm i', {cwd: buildDir, stdio: 'inherit'});\n } else {\n execSync('npm install', {cwd: buildDir, stdio: 'inherit'});\n }\n }\n\n try {\n // Build the client-side bundle\n await viteBuild({\n root: process.env.XYD_CLI ? __dirname : process.env.XYD_DOCUMAN_HOST || path.join(__dirname, \"../host\"),\n plugins: [\n ...(xydContentVitePlugins({\n toc: {\n minDepth: 2,\n }\n }) as Plugin[]),\n reactRouter({\n outDir: buildDir,\n routes: resp.routes\n }),\n tsconfigPaths(),\n ...resp.vitePlugins\n ],\n optimizeDeps: {\n include: [\"react/jsx-runtime\"],\n },\n });\n\n // Build the SSR bundle\n await viteBuild({\n root: process.env.XYD_CLI ? __dirname : process.env.XYD_DOCUMAN_HOST || path.join(__dirname, \"../host\"),\n build: {\n ssr: true,\n },\n plugins: [\n ...(xydContentVitePlugins({\n toc: {\n minDepth: 2,\n }\n }) as Plugin[]),\n reactRouter({\n outDir: buildDir,\n routes: resp.routes\n }),\n tsconfigPaths(),\n ...resp.vitePlugins\n ],\n optimizeDeps: {\n include: [\"react/jsx-runtime\"],\n },\n });\n\n console.log('Build completed successfully.'); // TODO: better message\n } catch (error) {\n console.error('Build failed:', error); // TODO: better message\n }\n}\n\n","import path from \"node:path\";\nimport {fileURLToPath} from \"node:url\";\nimport {createServer, searchForWorkspaceRoot} from \"vite\";\n\nimport {reactRouter} from \"@xyd-js/react-router-dev/vite\";\n\nimport {vitePlugins as xydContentVitePlugins} from \"@xyd-js/content/vite\";\nimport {pluginZero} from \"@xyd-js/plugin-zero\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\nconst port = process.env.XYD_PORT ? parseInt(process.env.XYD_PORT) : 5175;\n\nexport async function dev() {\n const respPluginZero = await pluginZero()\n if (!respPluginZero) {\n throw new Error(\"PluginZero not found\")\n }\n\n const allowCwd = searchForWorkspaceRoot(process.cwd())\n\n const preview = await createServer({\n root: process.env.XYD_CLI ? __dirname : process.env.XYD_DOCUMAN_HOST || path.join(__dirname, \"../host\"), // TODO: bundler?\n server: {\n port: port,\n fs: {\n allow: [\n allowCwd,\n process.env.XYD_CLI ? path.join(__dirname, \"../../\") : \"\",\n // path.join(__dirname, \"../node_modules\") // Ensure node_modules from xyd-documan is included\n ]\n }\n },\n build: {\n rollupOptions: {\n // Exclude package `B` from the client-side bundle\n external: [\"@xyd-js/uniform\", \"@xyd-js/uniform/content\", \"@xyd-js/plugin-zero\"],\n },\n },\n ssr: {\n external: [\"@xyd-js/uniform\", \"@xyd-js/uniform/content\", \"@xyd-js/plugin-zero\"],\n },\n optimizeDeps: {\n include: [\"react/jsx-runtime\"],\n },\n plugins: [ // TODO: fix plugin ts\n ...(xydContentVitePlugins({\n toc: {\n minDepth: 2,\n }\n }) as Plugin[]),\n reactRouter({\n routes: respPluginZero.routes\n }),\n ...respPluginZero.vitePlugins,\n ],\n });\n\n await preview.listen(port);\n\n preview.printUrls();\n preview.bindCLIShortcuts({print: true});\n\n}","import fs from \"node:fs\";\nimport os from \"node:os\";\nimport path from \"node:path\";\nimport url from \"node:url\";\n\nimport type {ServerBuild} from \"react-router\";\nimport {createRequestHandler} from \"@react-router/express\";\nimport compression from \"compression\";\nimport express from \"express\";\nimport morgan from \"morgan\";\nimport sourceMapSupport from \"source-map-support\";\nimport getPort from \"get-port\";\n\nfunction parseNumber(raw?: string) {\n if (raw === undefined) return undefined;\n let maybe = Number(raw);\n if (Number.isNaN(maybe)) return undefined;\n return maybe;\n}\n\nexport async function serve() {\n process.env.NODE_ENV = process.env.NODE_ENV ?? \"production\";\n\n sourceMapSupport.install({\n retrieveSourceMap: function (source) {\n let match = source.startsWith(\"file://\");\n if (match) {\n let filePath = url.fileURLToPath(source);\n let sourceMapPath = `${filePath}.map`;\n if (fs.existsSync(sourceMapPath)) {\n return {\n url: source,\n map: fs.readFileSync(sourceMapPath, \"utf8\"),\n };\n }\n }\n return null;\n },\n });\n\n let port = parseNumber(process.env.PORT) ?? (await getPort({port: 3000}));\n\n let buildPathArg = path.join(process.cwd(), \".xyd/build/server/index.js\")\n\n if (!buildPathArg) {\n console.error(`\n Usage: react-router-serve <server-build-path> - e.g. react-router-serve build/server/index.js`);\n process.exit(1);\n }\n\n let buildPath = path.resolve(buildPathArg);\n\n let build: ServerBuild = await import(url.pathToFileURL(buildPath).href);\n\n let onListen = () => {\n let address =\n process.env.HOST ||\n Object.values(os.networkInterfaces())\n .flat()\n .find((ip) => String(ip?.family).includes(\"4\") && !ip?.internal)\n ?.address;\n\n if (!address) {\n console.log(`[xyd-serve] http://localhost:${port}`);\n } else {\n console.log(\n `[xyd-serve] http://localhost:${port} (http://${address}:${port})`\n );\n }\n };\n\n build = {\n ...build,\n assetsBuildDirectory: path.join(process.cwd(), \".xyd/build/client\")\n }\n\n let app = express();\n app.disable(\"x-powered-by\");\n app.use(compression());\n app.use(\n path.posix.join(build.publicPath, \"assets\"),\n express.static(path.join(build.assetsBuildDirectory, \"assets\"), {\n immutable: true,\n maxAge: \"1y\",\n })\n );\n app.use(build.publicPath, express.static(build.assetsBuildDirectory));\n app.use(express.static(\"public\", {maxAge: \"1h\"}));\n app.use(morgan(\"tiny\"));\n\n app.all(\n \"*\",\n createRequestHandler({\n build,\n mode: process.env.NODE_ENV,\n })\n );\n\n let server = process.env.HOST\n ? app.listen(port, process.env.HOST, onListen)\n : app.listen(port, onListen);\n\n [\"SIGTERM\", \"SIGINT\"].forEach((signal) => {\n process.once(signal, () => server?.close(console.error));\n });\n}\n","import {serve} from \"../\"\n\n// Execute the serve function\nawait serve();\n\n"],"mappings":";AAAA,OAAO,UAAU;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IA,OAAM,YAAY,QAAQ,OAAOA,OAAM,oBAAoB,CAAC;AACpE,MAAI,IAAI,QAAQ,OAAO,UAAU,EAAC,QAAQ,KAAI,CAAC,CAAC;AAChD,MAAI,IAAI,OAAO,MAAM,CAAC;AAEtB,MAAI;AAAA,IACA;AAAA,IACA,qBAAqB;AAAA,MACjB,OAAAA;AAAA,MACA,MAAM,QAAQ,IAAI;AAAA,IACtB,CAAC;AAAA,EACL;AAEA,MAAI,SAAS,QAAQ,IAAI,OACnB,IAAI,OAAOD,OAAM,QAAQ,IAAI,MAAM,QAAQ,IAC3C,IAAI,OAAOA,OAAM,QAAQ;AAE/B,GAAC,WAAW,QAAQ,EAAE,QAAQ,CAAC,WAAW;AACtC,YAAQ,KAAK,QAAQ,MAAM,QAAQ,MAAM,QAAQ,KAAK,CAAC;AAAA,EAC3D,CAAC;AACL;;;ACtGA,MAAM,MAAM;","names":["path","fileURLToPath","reactRouter","xydContentVitePlugins","pluginZero","__filename","__dirname","fs","path","port","build"]}
|
|
1
|
+
{"version":3,"sources":["../src/run/build.ts","../src/run/dev.ts","../src/run/serve.ts","../src/commands/serve.ts"],"sourcesContent":["import path from \"node:path\";\nimport fs from \"node:fs\";\nimport {fileURLToPath} from \"node:url\";\nimport {execSync} from 'child_process';\n\nimport {build as viteBuild} from 'vite';\nimport tsconfigPaths from \"vite-tsconfig-paths\";\n\nimport {reactRouter} from \"@xyd-js/react-router-dev/vite\";\n\nimport {vitePlugins as xydContentVitePlugins} from \"@xyd-js/content/vite\"\nimport {pluginZero} from \"@xyd-js/plugin-zero\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\n// Define the main function to run the builds\nexport async function build() {\n const resp = await pluginZero()\n if (!resp) {\n throw new Error(\"PluginZero not found\")\n }\n\n const buildDir = path.join(process.cwd(), \".xyd/build\");\n\n {\n // TODO: probably we should have better mechanism - maybe bundle?\n\n const packageJsonPath = path.join(buildDir, 'package.json');\n\n const packageJsonContent = {\n type: \"module\",\n scripts: {},\n dependencies: { // TODO: better\n \"@xyd-js/content\": \"latest\",\n \"@xyd-js/components\": \"latest\",\n \"@xyd-js/framework\": \"latest\",\n \"@xyd-js/theme-poetry\": \"latest\",\n\n\n \"@react-router/node\": \"7.1.1\",\n \"isbot\": \"^5\"\n },\n devDependencies: {}\n };\n\n if (process.env.XYD_DEV_MODE) {\n Object.keys(packageJsonContent.dependencies).forEach((key) => {\n if (key.startsWith(\"@xyd-js/\")) {\n packageJsonContent.dependencies[key] = \"workspace:*\";\n }\n })\n }\n\n // Ensure the build directory exists\n if (!fs.existsSync(buildDir)) {\n fs.mkdirSync(buildDir, {recursive: true});\n }\n\n // Write the package.json file\n fs.writeFileSync(packageJsonPath, JSON.stringify(packageJsonContent, null, 2), 'utf8');\n\n // Install packages inside buildDir\n if (process.env.XYD_DEV_MODE) {\n execSync('pnpm i', {cwd: buildDir, stdio: 'inherit'});\n } else {\n execSync('npm install', {cwd: buildDir, stdio: 'inherit'});\n }\n }\n\n try {\n // Build the client-side bundle\n await viteBuild({\n root: process.env.XYD_CLI ? __dirname : process.env.XYD_DOCUMAN_HOST || path.join(__dirname, \"../host\"),\n plugins: [\n ...(xydContentVitePlugins({\n toc: {\n minDepth: 2,\n }\n }) as Plugin[]),\n reactRouter({\n outDir: buildDir,\n routes: resp.routes\n }),\n tsconfigPaths(),\n ...resp.vitePlugins\n ],\n optimizeDeps: {\n include: [\"react/jsx-runtime\"],\n },\n });\n\n // Build the SSR bundle\n await viteBuild({\n root: process.env.XYD_CLI ? __dirname : process.env.XYD_DOCUMAN_HOST || path.join(__dirname, \"../host\"),\n build: {\n ssr: true,\n },\n plugins: [\n ...(xydContentVitePlugins({\n toc: {\n minDepth: 2,\n }\n }) as Plugin[]),\n reactRouter({\n outDir: buildDir,\n routes: resp.routes\n }),\n tsconfigPaths(),\n ...resp.vitePlugins\n ],\n optimizeDeps: {\n include: [\"react/jsx-runtime\"],\n },\n });\n\n console.log('Build completed successfully.'); // TODO: better message\n } catch (error) {\n console.error('Build failed:', error); // TODO: better message\n }\n}\n\n","import path from \"node:path\";\nimport {fileURLToPath} from \"node:url\";\nimport fs from \"node:fs\";\n\nimport {createServer, searchForWorkspaceRoot} from \"vite\";\n\nimport {reactRouter} from \"@xyd-js/react-router-dev/vite\";\n\nimport {vitePlugins as xydContentVitePlugins} from \"@xyd-js/content/vite\";\nimport {pluginZero} from \"@xyd-js/plugin-zero\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\nconst port = process.env.XYD_PORT ? parseInt(process.env.XYD_PORT) : 5175;\n\nexport async function dev() {\n const respPluginZero = await pluginZero()\n if (!respPluginZero) {\n throw new Error(\"PluginZero not found\")\n }\n\n const allowCwd = searchForWorkspaceRoot(process.cwd())\n\n const preview = await createServer({\n root: process.env.XYD_CLI ? __dirname : process.env.XYD_DOCUMAN_HOST || path.join(__dirname, \"../host\"), // TODO: bundler?\n server: {\n port: port,\n fs: {\n allow: [\n allowCwd,\n process.env.XYD_CLI ? __dirname : path.join(__dirname, \"../host\"),\n ]\n }\n },\n build: {\n rollupOptions: {\n // Exclude package `B` from the client-side bundle\n external: [\"@xyd-js/uniform\", \"@xyd-js/uniform/content\", \"@xyd-js/plugin-zero\"],\n },\n },\n ssr: {\n external: [\"@xyd-js/uniform\", \"@xyd-js/uniform/content\", \"@xyd-js/plugin-zero\"],\n },\n optimizeDeps: {\n include: [\"react/jsx-runtime\"],\n },\n plugins: [ // TODO: fix plugin ts\n ...(xydContentVitePlugins({\n toc: {\n minDepth: 2,\n }\n }) as Plugin[]),\n reactRouter({\n routes: respPluginZero.routes\n }),\n ...respPluginZero.vitePlugins,\n ]\n });\n\n // Set up manual file watcher for markdown files TODO: better way? + HMR only for specific components instead or reload a pag\n const watcher = fs.watch(allowCwd, { recursive: true }, (eventType, filename) => {\n if (!filename) {\n console.log(\"[xyd:dev] Received empty filename\");\n return;\n }\n \n const filePath = path.join(allowCwd, filename);\n \n if (filePath.endsWith('.md') || filePath.endsWith('.mdx')) {\n const relativePath = path.relative(allowCwd, filePath);\n const urlPath = '/' + relativePath.replace(/\\\\/g, '/');\n \n preview.ws.send({\n type: 'full-reload',\n path: urlPath\n });\n }\n });\n\n // Log any watcher errors\n watcher.on('error', (error) => {\n console.error(\"[xyd:dev] File watcher error:\", error);\n });\n\n await preview.listen(port);\n\n preview.printUrls();\n preview.bindCLIShortcuts({print: true});\n\n // Clean up watcher when server is closed\n preview.httpServer?.once('close', () => {\n watcher.close();\n });\n}","import fs from \"node:fs\";\nimport os from \"node:os\";\nimport path from \"node:path\";\nimport url from \"node:url\";\n\nimport type {ServerBuild} from \"react-router\";\nimport {createRequestHandler} from \"@react-router/express\";\nimport compression from \"compression\";\nimport express from \"express\";\nimport morgan from \"morgan\";\nimport sourceMapSupport from \"source-map-support\";\nimport getPort from \"get-port\";\n\nfunction parseNumber(raw?: string) {\n if (raw === undefined) return undefined;\n let maybe = Number(raw);\n if (Number.isNaN(maybe)) return undefined;\n return maybe;\n}\n\nexport async function serve() {\n process.env.NODE_ENV = process.env.NODE_ENV ?? \"production\";\n\n sourceMapSupport.install({\n retrieveSourceMap: function (source) {\n let match = source.startsWith(\"file://\");\n if (match) {\n let filePath = url.fileURLToPath(source);\n let sourceMapPath = `${filePath}.map`;\n if (fs.existsSync(sourceMapPath)) {\n return {\n url: source,\n map: fs.readFileSync(sourceMapPath, \"utf8\"),\n };\n }\n }\n return null;\n },\n });\n\n let port = parseNumber(process.env.PORT) ?? (await getPort({port: 3000}));\n\n let buildPathArg = path.join(process.cwd(), \".xyd/build/server/index.js\")\n\n if (!buildPathArg) {\n console.error(`\n Usage: react-router-serve <server-build-path> - e.g. react-router-serve build/server/index.js`);\n process.exit(1);\n }\n\n let buildPath = path.resolve(buildPathArg);\n\n let build: ServerBuild = await import(url.pathToFileURL(buildPath).href);\n\n let onListen = () => {\n let address =\n process.env.HOST ||\n Object.values(os.networkInterfaces())\n .flat()\n .find((ip) => String(ip?.family).includes(\"4\") && !ip?.internal)\n ?.address;\n\n if (!address) {\n console.log(`[xyd-serve] http://localhost:${port}`);\n } else {\n console.log(\n `[xyd-serve] http://localhost:${port} (http://${address}:${port})`\n );\n }\n };\n\n build = {\n ...build,\n assetsBuildDirectory: path.join(process.cwd(), \".xyd/build/client\")\n }\n\n let app = express();\n app.disable(\"x-powered-by\");\n app.use(compression());\n app.use(\n path.posix.join(build.publicPath, \"assets\"),\n express.static(path.join(build.assetsBuildDirectory, \"assets\"), {\n immutable: true,\n maxAge: \"1y\",\n })\n );\n app.use(build.publicPath, express.static(build.assetsBuildDirectory));\n app.use(express.static(\"public\", {maxAge: \"1h\"}));\n app.use(morgan(\"tiny\"));\n\n app.all(\n \"*\",\n createRequestHandler({\n build,\n mode: process.env.NODE_ENV,\n })\n );\n\n let server = process.env.HOST\n ? app.listen(port, process.env.HOST, onListen)\n : app.listen(port, onListen);\n\n [\"SIGTERM\", \"SIGINT\"].forEach((signal) => {\n process.once(signal, () => server?.close(console.error));\n });\n}\n","import {serve} from \"../\"\n\n// Execute the serve function\nawait serve();\n\n"],"mappings":";AAAA,OAAO,UAAU;AACjB,OAAO,QAAQ;AACf,SAAQ,qBAAoB;AAG5B,SAAQ,SAAS,iBAAgB;AACjC,OAAO,mBAAmB;AAE1B,SAAQ,mBAAkB;AAE1B,SAAQ,eAAe,6BAA4B;AACnD,SAAQ,kBAAiB;AAEzB,IAAM,aAAa,cAAc,YAAY,GAAG;AAChD,IAAM,YAAY,KAAK,QAAQ,UAAU;;;ACdzC,OAAOA,WAAU;AACjB,SAAQ,iBAAAC,sBAAoB;AAC5B,OAAOC,SAAQ;AAEf,SAAQ,cAAc,8BAA6B;AAEnD,SAAQ,eAAAC,oBAAkB;AAE1B,SAAQ,eAAeC,8BAA4B;AACnD,SAAQ,cAAAC,mBAAiB;AAEzB,IAAMC,cAAaL,eAAc,YAAY,GAAG;AAChD,IAAMM,aAAYP,MAAK,QAAQM,WAAU;AAEzC,IAAM,OAAO,QAAQ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A,EAC3D,CAAC;AACL;;;ACtGA,MAAM,MAAM;","names":["path","fileURLToPath","fs","reactRouter","xydContentVitePlugins","pluginZero","__filename","__dirname","fs","path","port","build"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyd-js/documan",
|
|
3
|
-
"version": "0.1.0-xyd.
|
|
3
|
+
"version": "0.1.0-xyd.28",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./package.json": "./package.json",
|
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
"package.json"
|
|
15
15
|
],
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@
|
|
17
|
+
"@react-router/dev": "7.1.1",
|
|
18
18
|
"@react-router/node": "7.1.1",
|
|
19
19
|
"@react-router/serve": "7.1.1",
|
|
20
|
-
"@react-router
|
|
20
|
+
"@xyd-js/react-router-dev": "7.1.1-xyd.4",
|
|
21
21
|
"codehike": "^1.0.3",
|
|
22
22
|
"compression": "^1.7.5",
|
|
23
23
|
"express": "^4.21.2",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"typescript": "^5.6.3",
|
|
37
37
|
"vfile": "^6.0.3",
|
|
38
38
|
"yaml": "^2.6.0",
|
|
39
|
-
"@xyd-js/content": "0.1.0-xyd.
|
|
40
|
-
"@xyd-js/plugin-zero": "0.1.0-xyd.
|
|
39
|
+
"@xyd-js/content": "0.1.0-xyd.13",
|
|
40
|
+
"@xyd-js/plugin-zero": "0.1.0-xyd.21"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@mdx-js/rollup": "^3.1.0",
|