@xyd-js/documan 0.1.0-xyd.0 → 0.1.0-xyd.10

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.
Files changed (90) hide show
  1. package/dist/build.js +2 -2
  2. package/dist/build.js.map +1 -1
  3. package/dist/dev.js +1 -1
  4. package/dist/dev.js.map +1 -1
  5. package/dist/index.js +3 -3
  6. package/dist/index.js.map +1 -1
  7. package/dist/serve.js.map +1 -1
  8. package/package.json +7 -10
  9. package/host/.react-router/types/app/+types/root.ts +0 -40
  10. package/host/app/root.tsx +0 -23
  11. package/host/app/routes.ts +0 -5
  12. package/host/node_modules/.vite/deps/@mdx-js_mdx.js +0 -81
  13. package/host/node_modules/.vite/deps/@mdx-js_mdx.js.map +0 -7
  14. package/host/node_modules/.vite/deps/@mdx-js_rollup.js +0 -4003
  15. package/host/node_modules/.vite/deps/@mdx-js_rollup.js.map +0 -7
  16. package/host/node_modules/.vite/deps/@radix-ui_react-icons.js +0 -7531
  17. package/host/node_modules/.vite/deps/@radix-ui_react-icons.js.map +0 -7
  18. package/host/node_modules/.vite/deps/@radix-ui_react-tabs.js +0 -917
  19. package/host/node_modules/.vite/deps/@radix-ui_react-tabs.js.map +0 -7
  20. package/host/node_modules/.vite/deps/_metadata.json +0 -157
  21. package/host/node_modules/.vite/deps/chunk-2TUXWMP5.js +0 -46
  22. package/host/node_modules/.vite/deps/chunk-2TUXWMP5.js.map +0 -7
  23. package/host/node_modules/.vite/deps/chunk-A76PLWFF.js +0 -23875
  24. package/host/node_modules/.vite/deps/chunk-A76PLWFF.js.map +0 -7
  25. package/host/node_modules/.vite/deps/chunk-B2TCFXA3.js +0 -27
  26. package/host/node_modules/.vite/deps/chunk-B2TCFXA3.js.map +0 -7
  27. package/host/node_modules/.vite/deps/chunk-CZACBYAQ.js +0 -3461
  28. package/host/node_modules/.vite/deps/chunk-CZACBYAQ.js.map +0 -7
  29. package/host/node_modules/.vite/deps/chunk-IVP26VTC.js +0 -21
  30. package/host/node_modules/.vite/deps/chunk-IVP26VTC.js.map +0 -7
  31. package/host/node_modules/.vite/deps/chunk-NSHFRFAV.js +0 -894
  32. package/host/node_modules/.vite/deps/chunk-NSHFRFAV.js.map +0 -7
  33. package/host/node_modules/.vite/deps/chunk-O6QCC74R.js +0 -205
  34. package/host/node_modules/.vite/deps/chunk-O6QCC74R.js.map +0 -7
  35. package/host/node_modules/.vite/deps/chunk-SBIFJFEH.js +0 -894
  36. package/host/node_modules/.vite/deps/chunk-SBIFJFEH.js.map +0 -7
  37. package/host/node_modules/.vite/deps/chunk-SURLKOJ2.js +0 -12
  38. package/host/node_modules/.vite/deps/chunk-SURLKOJ2.js.map +0 -7
  39. package/host/node_modules/.vite/deps/chunk-VENRSTQF.js +0 -21628
  40. package/host/node_modules/.vite/deps/chunk-VENRSTQF.js.map +0 -7
  41. package/host/node_modules/.vite/deps/chunk-XCGROZNW.js +0 -10609
  42. package/host/node_modules/.vite/deps/chunk-XCGROZNW.js.map +0 -7
  43. package/host/node_modules/.vite/deps/chunk-ZFDQJWTH.js +0 -928
  44. package/host/node_modules/.vite/deps/chunk-ZFDQJWTH.js.map +0 -7
  45. package/host/node_modules/.vite/deps/chunk-ZFOARUJI.js +0 -1906
  46. package/host/node_modules/.vite/deps/chunk-ZFOARUJI.js.map +0 -7
  47. package/host/node_modules/.vite/deps/gray-matter.js +0 -3492
  48. package/host/node_modules/.vite/deps/gray-matter.js.map +0 -7
  49. package/host/node_modules/.vite/deps/lucide-react.js +0 -34742
  50. package/host/node_modules/.vite/deps/lucide-react.js.map +0 -7
  51. package/host/node_modules/.vite/deps/package.json +0 -3
  52. package/host/node_modules/.vite/deps/react-dom.js +0 -7
  53. package/host/node_modules/.vite/deps/react-dom.js.map +0 -7
  54. package/host/node_modules/.vite/deps/react-dom_client.js +0 -39
  55. package/host/node_modules/.vite/deps/react-dom_client.js.map +0 -7
  56. package/host/node_modules/.vite/deps/react-router.js +0 -243
  57. package/host/node_modules/.vite/deps/react-router.js.map +0 -7
  58. package/host/node_modules/.vite/deps/react-router_dom.js +0 -212
  59. package/host/node_modules/.vite/deps/react-router_dom.js.map +0 -7
  60. package/host/node_modules/.vite/deps/react.js +0 -6
  61. package/host/node_modules/.vite/deps/react.js.map +0 -7
  62. package/host/node_modules/.vite/deps/react_jsx-dev-runtime.js +0 -913
  63. package/host/node_modules/.vite/deps/react_jsx-dev-runtime.js.map +0 -7
  64. package/host/node_modules/.vite/deps/react_jsx-runtime.js +0 -7
  65. package/host/node_modules/.vite/deps/react_jsx-runtime.js.map +0 -7
  66. package/host/node_modules/.vite/deps/remark-frontmatter.js +0 -428
  67. package/host/node_modules/.vite/deps/remark-frontmatter.js.map +0 -7
  68. package/host/node_modules/.vite/deps/remark-gfm.js +0 -3122
  69. package/host/node_modules/.vite/deps/remark-gfm.js.map +0 -7
  70. package/host/node_modules/.vite/deps/remark-mdx-frontmatter.js +0 -10482
  71. package/host/node_modules/.vite/deps/remark-mdx-frontmatter.js.map +0 -7
  72. package/host/node_modules/.vite/deps/unist-util-visit.js +0 -14
  73. package/host/node_modules/.vite/deps/unist-util-visit.js.map +0 -7
  74. package/host/node_modules/.vite/deps/vfile.js +0 -8
  75. package/host/node_modules/.vite/deps/vfile.js.map +0 -7
  76. package/host/package.json +0 -43
  77. package/host/postcss.config.cjs +0 -5
  78. package/host/react-router.config.ts +0 -8
  79. package/host/tsconfig.json +0 -22
  80. package/host/vite.config.ts +0 -9
  81. package/src/commands/build.ts +0 -4
  82. package/src/commands/dev.ts +0 -5
  83. package/src/commands/serve.ts +0 -5
  84. package/src/index.ts +0 -7
  85. package/src/run/build.ts +0 -98
  86. package/src/run/dev.ts +0 -76
  87. package/src/run/index.ts +0 -6
  88. package/src/run/serve.ts +0 -106
  89. package/tsconfig.json +0 -22
  90. package/tsup.config.ts +0 -81
package/dist/build.js CHANGED
@@ -30,7 +30,7 @@ async function build() {
30
30
  }
31
31
  try {
32
32
  await viteBuild({
33
- root: path.join(__dirname, "../host"),
33
+ root: process.env.XYD_CLI ? __dirname : process.env.XYD_DOCUMAN_HOST || path.join(__dirname, "../host"),
34
34
  // @ts-ignore
35
35
  plugins: [
36
36
  ...xydContentVitePlugins({
@@ -50,7 +50,7 @@ async function build() {
50
50
  }
51
51
  });
52
52
  await viteBuild({
53
- root: path.join(__dirname, "../host"),
53
+ root: process.env.XYD_CLI ? __dirname : process.env.XYD_DOCUMAN_HOST || path.join(__dirname, "../host"),
54
54
  build: {
55
55
  ssr: true
56
56
  },
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\";\n\nimport {build as viteBuild} from 'vite';\nimport tsconfigPaths from \"vite-tsconfig-paths\";\n\nimport {reactRouter} from \"@xyd-js/react-router-dev/vite\";\n// import { reactRouter } from \"@react-router/dev/vite\";\n\nimport {vitePlugins as xydContentVitePlugins} from \"@xyd-js/content\"\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 const packageJsonPath = path.join(buildDir, 'package.json');\n\n const packageJsonContent = {\n type: \"module\",\n scripts: {},\n dependencies: {},\n devDependencies: {}\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\n try {\n // Build the client-side bundle\n await viteBuild({\n root: path.join(__dirname, \"../host\"),\n // @ts-ignore\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: path.join(__dirname, \"../host\"),\n build: {\n ssr: true,\n },\n // @ts-ignore\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// import { reactRouter } from \"@react-router/dev/vite\";\n\nimport {vitePlugins as xydContentVitePlugins} from \"@xyd-js/content\";\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 resp = await pluginZero()\n if (!resp) {\n throw new Error(\"PluginZero not found\")\n }\n\n const allowCwd = searchForWorkspaceRoot(process.cwd())\n\n const preview = await createServer({\n // any valid user config options, plus `mode` and `configFile`\n // configFile: path.join(__dirname, \"../src/vite/empty-config.ts\"), // TODO: bundler??\n // configFile: path.join(__dirname, \"../\"), // TODO: bundler??\n // root: path.join(__dirname, \"../\"), // TODO: bundler?\n root: 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 // noExternal: [\n // \"@xyd-js/uniform\",\n // \"@xyd-js/uniform/content\",\n // \"@xyd-js/plugin-zero\"\n // ],\n },\n optimizeDeps: {\n include: [\"react/jsx-runtime\"],\n },\n // @ts-ignore\n plugins: [ // TODO: fix plugin ts\n ...(xydContentVitePlugins({\n toc: {\n minDepth: 2,\n }\n }) as Plugin[]),\n reactRouter({\n routes: resp.routes\n }),\n ...resp.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;AAE5B,SAAQ,SAAS,iBAAgB;AACjC,OAAO,mBAAmB;AAE1B,SAAQ,mBAAkB;AAG1B,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,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AAAA,QACV,SAAS,CAAC,mBAAmB;AAAA,MACjC;AAAA,IACJ,CAAC;AAED,YAAQ,IAAI,+BAA+B;AAAA,EAC/C,SAAS,OAAO;AACZ,YAAQ,MAAM,iBAAiB,KAAK;AAAA,EACxC;AACJ;;;AChGA,OAAOA,WAAU;AACjB,SAAQ,iBAAAC,sBAAoB;AAC5B,SAAQ,cAAc,8BAA6B;AAEnD,SAAQ,eAAAC,oBAAkB;AAG1B,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;;;ACbrE,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\";\n\nimport {build as viteBuild} from 'vite';\nimport tsconfigPaths from \"vite-tsconfig-paths\";\n\nimport {reactRouter} from \"@xyd-js/react-router-dev/vite\";\n// import { reactRouter } from \"@react-router/dev/vite\";\n\nimport {vitePlugins as xydContentVitePlugins} from \"@xyd-js/content\"\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 const packageJsonPath = path.join(buildDir, 'package.json');\n\n const packageJsonContent = {\n type: \"module\",\n scripts: {},\n dependencies: {},\n devDependencies: {}\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\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 // @ts-ignore\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 // @ts-ignore\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// import { reactRouter } from \"@react-router/dev/vite\";\n\nimport {vitePlugins as xydContentVitePlugins} from \"@xyd-js/content\";\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 resp = await pluginZero()\n if (!resp) {\n throw new Error(\"PluginZero not found\")\n }\n\n const allowCwd = searchForWorkspaceRoot(process.cwd())\n\n const preview = await createServer({\n // any valid user config options, plus `mode` and `configFile`\n // configFile: path.join(__dirname, \"../src/vite/empty-config.ts\"), // TODO: bundler??\n // configFile: path.join(__dirname, \"../\"), // TODO: bundler??\n // root: path.join(__dirname, \"../\"), // TODO: bundler?\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 // noExternal: [\n // \"@xyd-js/uniform\",\n // \"@xyd-js/uniform/content\",\n // \"@xyd-js/plugin-zero\"\n // ],\n },\n optimizeDeps: {\n include: [\"react/jsx-runtime\"],\n },\n // @ts-ignore\n plugins: [ // TODO: fix plugin ts\n ...(xydContentVitePlugins({\n toc: {\n minDepth: 2,\n }\n }) as Plugin[]),\n reactRouter({\n routes: resp.routes\n }),\n ...resp.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;AAE5B,SAAQ,SAAS,iBAAgB;AACjC,OAAO,mBAAmB;AAE1B,SAAQ,mBAAkB;AAG1B,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;AACI,UAAM,kBAAkB,KAAK,KAAK,UAAU,cAAc;AAE1D,UAAM,qBAAqB;AAAA,MACvB,MAAM;AAAA,MACN,SAAS,CAAC;AAAA,MACV,cAAc,CAAC;AAAA,MACf,iBAAiB,CAAC;AAAA,IACtB;AAGA,QAAI,CAAC,GAAG,WAAW,QAAQ,GAAG;AAC1B,SAAG,UAAU,UAAU,EAAC,WAAW,KAAI,CAAC;AAAA,IAC5C;AAGA,OAAG,cAAc,iBAAiB,KAAK,UAAU,oBAAoB,MAAM,CAAC,GAAG,MAAM;AAAA,EACzF;AAEA,MAAI;AAEA,UAAM,UAAU;AAAA,MACZ,MAAM,QAAQ,IAAI,UAAU,YAAY,QAAQ,IAAI,oBAAoB,KAAK,KAAK,WAAW,SAAS;AAAA;AAAA,MAEtG,SAAS;AAAA,QACL,GAAI,sBAAsB;AAAA,UACtB,KAAK;AAAA,YACD,UAAU;AAAA,UACd;AAAA,Q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AiB;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"]}
package/dist/dev.js CHANGED
@@ -31,7 +31,7 @@ async function dev() {
31
31
  // configFile: path.join(__dirname, "../src/vite/empty-config.ts"), // TODO: bundler??
32
32
  // configFile: path.join(__dirname, "../"), // TODO: bundler??
33
33
  // root: path.join(__dirname, "../"), // TODO: bundler?
34
- root: process.env.XYD_DOCUMAN_HOST || path2.join(__dirname2, "../host"),
34
+ root: process.env.XYD_CLI ? __dirname2 : process.env.XYD_DOCUMAN_HOST || path2.join(__dirname2, "../host"),
35
35
  // TODO: bundler?
36
36
  server: {
37
37
  port,
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\";\n\nimport {build as viteBuild} from 'vite';\nimport tsconfigPaths from \"vite-tsconfig-paths\";\n\nimport {reactRouter} from \"@xyd-js/react-router-dev/vite\";\n// import { reactRouter } from \"@react-router/dev/vite\";\n\nimport {vitePlugins as xydContentVitePlugins} from \"@xyd-js/content\"\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 const packageJsonPath = path.join(buildDir, 'package.json');\n\n const packageJsonContent = {\n type: \"module\",\n scripts: {},\n dependencies: {},\n devDependencies: {}\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\n try {\n // Build the client-side bundle\n await viteBuild({\n root: path.join(__dirname, \"../host\"),\n // @ts-ignore\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: path.join(__dirname, \"../host\"),\n build: {\n ssr: true,\n },\n // @ts-ignore\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// import { reactRouter } from \"@react-router/dev/vite\";\n\nimport {vitePlugins as xydContentVitePlugins} from \"@xyd-js/content\";\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 resp = await pluginZero()\n if (!resp) {\n throw new Error(\"PluginZero not found\")\n }\n\n const allowCwd = searchForWorkspaceRoot(process.cwd())\n\n const preview = await createServer({\n // any valid user config options, plus `mode` and `configFile`\n // configFile: path.join(__dirname, \"../src/vite/empty-config.ts\"), // TODO: bundler??\n // configFile: path.join(__dirname, \"../\"), // TODO: bundler??\n // root: path.join(__dirname, \"../\"), // TODO: bundler?\n root: 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 // noExternal: [\n // \"@xyd-js/uniform\",\n // \"@xyd-js/uniform/content\",\n // \"@xyd-js/plugin-zero\"\n // ],\n },\n optimizeDeps: {\n include: [\"react/jsx-runtime\"],\n },\n // @ts-ignore\n plugins: [ // TODO: fix plugin ts\n ...(xydContentVitePlugins({\n toc: {\n minDepth: 2,\n }\n }) as Plugin[]),\n reactRouter({\n routes: resp.routes\n }),\n ...resp.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"],"mappings":";AAAA,OAAO,UAAU;AACjB,OAAO,QAAQ;AACf,SAAQ,qBAAoB;AAE5B,SAAQ,SAAS,iBAAgB;AACjC,OAAO,mBAAmB;AAE1B,SA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IAEA,SAAS;AAAA;AAAA,MACL,GAAIH,uBAAsB;AAAA,QACtB,KAAK;AAAA,UACD,UAAU;AAAA,QACd;AAAA,MACJ,CAAC;AAAA,MACDD,aAAY;AAAA,QACR,QAAQ,KAAK;AAAA,MACjB,CAAC;AAAA,MACD,GAAG,KAAK;AAAA,IACZ;AAAA,EACJ,CAAC;AAED,QAAM,QAAQ,OAAO,IAAI;AAEzB,UAAQ,UAAU;AAClB,UAAQ,iBAAiB,EAAC,OAAO,KAAI,CAAC;AAE1C;;;AC3EA,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\";\n\nimport {build as viteBuild} from 'vite';\nimport tsconfigPaths from \"vite-tsconfig-paths\";\n\nimport {reactRouter} from \"@xyd-js/react-router-dev/vite\";\n// import { reactRouter } from \"@react-router/dev/vite\";\n\nimport {vitePlugins as xydContentVitePlugins} from \"@xyd-js/content\"\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 const packageJsonPath = path.join(buildDir, 'package.json');\n\n const packageJsonContent = {\n type: \"module\",\n scripts: {},\n dependencies: {},\n devDependencies: {}\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\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 // @ts-ignore\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 // @ts-ignore\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// import { reactRouter } from \"@react-router/dev/vite\";\n\nimport {vitePlugins as xydContentVitePlugins} from \"@xyd-js/content\";\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 resp = await pluginZero()\n if (!resp) {\n throw new Error(\"PluginZero not found\")\n }\n\n const allowCwd = searchForWorkspaceRoot(process.cwd())\n\n const preview = await createServer({\n // any valid user config options, plus `mode` and `configFile`\n // configFile: path.join(__dirname, \"../src/vite/empty-config.ts\"), // TODO: bundler??\n // configFile: path.join(__dirname, \"../\"), // TODO: bundler??\n // root: path.join(__dirname, \"../\"), // TODO: bundler?\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 // noExternal: [\n // \"@xyd-js/uniform\",\n // \"@xyd-js/uniform/content\",\n // \"@xyd-js/plugin-zero\"\n // ],\n },\n optimizeDeps: {\n include: [\"react/jsx-runtime\"],\n },\n // @ts-ignore\n plugins: [ // TODO: fix plugin ts\n ...(xydContentVitePlugins({\n toc: {\n minDepth: 2,\n }\n }) as Plugin[]),\n reactRouter({\n routes: resp.routes\n }),\n ...resp.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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AAAA,MAClF;AAAA,IACJ;AAAA,IACA,KAAK;AAAA,MACD,UAAU,CAAC,mBAAmB,2BAA2B,qBAAqB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAMlF;AAAA,IACA,cAAc;AAAA,MACV,SAAS,CAAC,mBAAmB;AAAA,IACjC;AAAA;AAAA,IAEA,SAAS;AAAA;AAAA,MACL,GAAIH,uBAAsB;AAAA,QACtB,KAAK;AAAA,UACD,UAAU;AAAA,QACd;AAAA,MACJ,CAAC;AAAA,MACDD,aAAY;AAAA,QACR,QAAQ,KAAK;AAAA,MACjB,CAAC;AAAA,MACD,GAAG,KAAK;AAAA,IACZ;AAAA,EACJ,CAAC;AAED,QAAM,QAAQ,OAAO,IAAI;AAEzB,UAAQ,UAAU;AAClB,UAAQ,iBAAiB,EAAC,OAAO,KAAI,CAAC;AAE1C;;;AC3EA,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"]}
package/dist/index.js CHANGED
@@ -30,7 +30,7 @@ async function build() {
30
30
  }
31
31
  try {
32
32
  await viteBuild({
33
- root: path.join(__dirname, "../host"),
33
+ root: process.env.XYD_CLI ? __dirname : process.env.XYD_DOCUMAN_HOST || path.join(__dirname, "../host"),
34
34
  // @ts-ignore
35
35
  plugins: [
36
36
  ...xydContentVitePlugins({
@@ -50,7 +50,7 @@ async function build() {
50
50
  }
51
51
  });
52
52
  await viteBuild({
53
- root: path.join(__dirname, "../host"),
53
+ root: process.env.XYD_CLI ? __dirname : process.env.XYD_DOCUMAN_HOST || path.join(__dirname, "../host"),
54
54
  build: {
55
55
  ssr: true
56
56
  },
@@ -99,7 +99,7 @@ async function dev() {
99
99
  // configFile: path.join(__dirname, "../src/vite/empty-config.ts"), // TODO: bundler??
100
100
  // configFile: path.join(__dirname, "../"), // TODO: bundler??
101
101
  // root: path.join(__dirname, "../"), // TODO: bundler?
102
- root: process.env.XYD_DOCUMAN_HOST || path2.join(__dirname2, "../host"),
102
+ root: process.env.XYD_CLI ? __dirname2 : process.env.XYD_DOCUMAN_HOST || path2.join(__dirname2, "../host"),
103
103
  // TODO: bundler?
104
104
  server: {
105
105
  port,
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\";\n\nimport {build as viteBuild} from 'vite';\nimport tsconfigPaths from \"vite-tsconfig-paths\";\n\nimport {reactRouter} from \"@xyd-js/react-router-dev/vite\";\n// import { reactRouter } from \"@react-router/dev/vite\";\n\nimport {vitePlugins as xydContentVitePlugins} from \"@xyd-js/content\"\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 const packageJsonPath = path.join(buildDir, 'package.json');\n\n const packageJsonContent = {\n type: \"module\",\n scripts: {},\n dependencies: {},\n devDependencies: {}\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\n try {\n // Build the client-side bundle\n await viteBuild({\n root: path.join(__dirname, \"../host\"),\n // @ts-ignore\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: path.join(__dirname, \"../host\"),\n build: {\n ssr: true,\n },\n // @ts-ignore\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// import { reactRouter } from \"@react-router/dev/vite\";\n\nimport {vitePlugins as xydContentVitePlugins} from \"@xyd-js/content\";\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 resp = await pluginZero()\n if (!resp) {\n throw new Error(\"PluginZero not found\")\n }\n\n const allowCwd = searchForWorkspaceRoot(process.cwd())\n\n const preview = await createServer({\n // any valid user config options, plus `mode` and `configFile`\n // configFile: path.join(__dirname, \"../src/vite/empty-config.ts\"), // TODO: bundler??\n // configFile: path.join(__dirname, \"../\"), // TODO: bundler??\n // root: path.join(__dirname, \"../\"), // TODO: bundler?\n root: 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 // noExternal: [\n // \"@xyd-js/uniform\",\n // \"@xyd-js/uniform/content\",\n // \"@xyd-js/plugin-zero\"\n // ],\n },\n optimizeDeps: {\n include: [\"react/jsx-runtime\"],\n },\n // @ts-ignore\n plugins: [ // TODO: fix plugin ts\n ...(xydContentVitePlugins({\n toc: {\n minDepth: 2,\n }\n }) as Plugin[]),\n reactRouter({\n routes: resp.routes\n }),\n ...resp.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;AAE5B,SAAQ,SAAS,iBAAgB;AACjC,OAAO,mBAAmB;AAE1B,SAAQ,mBAAkB;AAG1B,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;AA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ACtB,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\";\n\nimport {build as viteBuild} from 'vite';\nimport tsconfigPaths from \"vite-tsconfig-paths\";\n\nimport {reactRouter} from \"@xyd-js/react-router-dev/vite\";\n// import { reactRouter } from \"@react-router/dev/vite\";\n\nimport {vitePlugins as xydContentVitePlugins} from \"@xyd-js/content\"\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 const packageJsonPath = path.join(buildDir, 'package.json');\n\n const packageJsonContent = {\n type: \"module\",\n scripts: {},\n dependencies: {},\n devDependencies: {}\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\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 // @ts-ignore\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 // @ts-ignore\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// import { reactRouter } from \"@react-router/dev/vite\";\n\nimport {vitePlugins as xydContentVitePlugins} from \"@xyd-js/content\";\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 resp = await pluginZero()\n if (!resp) {\n throw new Error(\"PluginZero not found\")\n }\n\n const allowCwd = searchForWorkspaceRoot(process.cwd())\n\n const preview = await createServer({\n // any valid user config options, plus `mode` and `configFile`\n // configFile: path.join(__dirname, \"../src/vite/empty-config.ts\"), // TODO: bundler??\n // configFile: path.join(__dirname, \"../\"), // TODO: bundler??\n // root: path.join(__dirname, \"../\"), // TODO: bundler?\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 // noExternal: [\n // \"@xyd-js/uniform\",\n // \"@xyd-js/uniform/content\",\n // \"@xyd-js/plugin-zero\"\n // ],\n },\n optimizeDeps: {\n include: [\"react/jsx-runtime\"],\n },\n // @ts-ignore\n plugins: [ // TODO: fix plugin ts\n ...(xydContentVitePlugins({\n toc: {\n minDepth: 2,\n }\n }) as Plugin[]),\n reactRouter({\n routes: resp.routes\n }),\n ...resp.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;AAE5B,SAAQ,SAAS,iBAAgB;AACjC,OAAO,mBAAmB;AAE1B,SAAQ,mBAAkB;AAG1B,SAAQ,eAAe,6BAA4B;AACnD,SAAQ,kBAAiB;AAEzB,IAAM,aAAa,cAAc,YAAY,GAAG;AAChD,IAAM,YAAY,KAAK,QAAQ,UAAU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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"]}
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\";\n\nimport {build as viteBuild} from 'vite';\nimport tsconfigPaths from \"vite-tsconfig-paths\";\n\nimport {reactRouter} from \"@xyd-js/react-router-dev/vite\";\n// import { reactRouter } from \"@react-router/dev/vite\";\n\nimport {vitePlugins as xydContentVitePlugins} from \"@xyd-js/content\"\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 const packageJsonPath = path.join(buildDir, 'package.json');\n\n const packageJsonContent = {\n type: \"module\",\n scripts: {},\n dependencies: {},\n devDependencies: {}\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\n try {\n // Build the client-side bundle\n await viteBuild({\n root: path.join(__dirname, \"../host\"),\n // @ts-ignore\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: path.join(__dirname, \"../host\"),\n build: {\n ssr: true,\n },\n // @ts-ignore\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// import { reactRouter } from \"@react-router/dev/vite\";\n\nimport {vitePlugins as xydContentVitePlugins} from \"@xyd-js/content\";\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 resp = await pluginZero()\n if (!resp) {\n throw new Error(\"PluginZero not found\")\n }\n\n const allowCwd = searchForWorkspaceRoot(process.cwd())\n\n const preview = await createServer({\n // any valid user config options, plus `mode` and `configFile`\n // configFile: path.join(__dirname, \"../src/vite/empty-config.ts\"), // TODO: bundler??\n // configFile: path.join(__dirname, \"../\"), // TODO: bundler??\n // root: path.join(__dirname, \"../\"), // TODO: bundler?\n root: 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 // noExternal: [\n // \"@xyd-js/uniform\",\n // \"@xyd-js/uniform/content\",\n // \"@xyd-js/plugin-zero\"\n // ],\n },\n optimizeDeps: {\n include: [\"react/jsx-runtime\"],\n },\n // @ts-ignore\n plugins: [ // TODO: fix plugin ts\n ...(xydContentVitePlugins({\n toc: {\n minDepth: 2,\n }\n }) as Plugin[]),\n reactRouter({\n routes: resp.routes\n }),\n ...resp.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;AACjB,OAAO,QAAQ;AACf,SA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OA,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\";\n\nimport {build as viteBuild} from 'vite';\nimport tsconfigPaths from \"vite-tsconfig-paths\";\n\nimport {reactRouter} from \"@xyd-js/react-router-dev/vite\";\n// import { reactRouter } from \"@react-router/dev/vite\";\n\nimport {vitePlugins as xydContentVitePlugins} from \"@xyd-js/content\"\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 const packageJsonPath = path.join(buildDir, 'package.json');\n\n const packageJsonContent = {\n type: \"module\",\n scripts: {},\n dependencies: {},\n devDependencies: {}\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\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 // @ts-ignore\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 // @ts-ignore\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// import { reactRouter } from \"@react-router/dev/vite\";\n\nimport {vitePlugins as xydContentVitePlugins} from \"@xyd-js/content\";\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 resp = await pluginZero()\n if (!resp) {\n throw new Error(\"PluginZero not found\")\n }\n\n const allowCwd = searchForWorkspaceRoot(process.cwd())\n\n const preview = await createServer({\n // any valid user config options, plus `mode` and `configFile`\n // configFile: path.join(__dirname, \"../src/vite/empty-config.ts\"), // TODO: bundler??\n // configFile: path.join(__dirname, \"../\"), // TODO: bundler??\n // root: path.join(__dirname, \"../\"), // TODO: bundler?\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 // noExternal: [\n // \"@xyd-js/uniform\",\n // \"@xyd-js/uniform/content\",\n // \"@xyd-js/plugin-zero\"\n // ],\n },\n optimizeDeps: {\n include: [\"react/jsx-runtime\"],\n },\n // @ts-ignore\n plugins: [ // TODO: fix plugin ts\n ...(xydContentVitePlugins({\n toc: {\n minDepth: 2,\n }\n }) as Plugin[]),\n reactRouter({\n routes: resp.routes\n }),\n ...resp.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}\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5D,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;;;ACtGA,MAAM,MAAM;","names":["path","fileURLToPath","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.0",
3
+ "version": "0.1.0-xyd.10",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  "./package.json": "./package.json",
@@ -9,6 +9,10 @@
9
9
  "./build": "./dist/build.js",
10
10
  "./serve": "./dist/serve.js"
11
11
  },
12
+ "files": [
13
+ "dist",
14
+ "package.json"
15
+ ],
12
16
  "dependencies": {
13
17
  "@xyd-js/react-router-dev": "7.1.1-xyd.3",
14
18
  "@react-router/node": "^7.1.1",
@@ -32,15 +36,8 @@
32
36
  "typescript": "^5.6.3",
33
37
  "vfile": "^6.0.3",
34
38
  "yaml": "^2.6.0",
35
- "@xyd-js/core": "0.1.0-xyd.0",
36
- "@xyd-js/content": "0.1.0-xyd.2",
37
- "@xyd-js/openapi": "0.1.0-xyd.0",
38
- "@xyd-js/plugin-zero": "0.1.0-xyd.0",
39
- "@xyd-js/gql": "0.1.0-xyd.0",
40
- "@xyd-js/atlas": "0.1.0-xyd.1",
41
- "@xyd-js/framework": "0.1.0-xyd.1",
42
- "@xyd-js/theme-poetry": "0.1.0-xyd.1",
43
- "@xyd-js/uniform": "0.1.0-xyd.2"
39
+ "@xyd-js/content": "0.1.0-xyd.4",
40
+ "@xyd-js/plugin-zero": "0.1.0-xyd.8"
44
41
  },
45
42
  "devDependencies": {
46
43
  "@mdx-js/rollup": "^3.1.0",
@@ -1,40 +0,0 @@
1
- // React Router generated types for route:
2
- // root.tsx
3
-
4
- import type * as T from "react-router/route-module"
5
-
6
-
7
-
8
- type Module = typeof import("../root.js")
9
-
10
- export type Info = {
11
- parents: [],
12
- id: "root"
13
- file: "root.tsx"
14
- path: ""
15
- params: {} & { [key: string]: string | undefined }
16
- module: Module
17
- loaderData: T.CreateLoaderData<Module>
18
- actionData: T.CreateActionData<Module>
19
- }
20
-
21
- export namespace Route {
22
- export type LinkDescriptors = T.LinkDescriptors
23
- export type LinksFunction = () => LinkDescriptors
24
-
25
- export type MetaArgs = T.CreateMetaArgs<Info>
26
- export type MetaDescriptors = T.MetaDescriptors
27
- export type MetaFunction = (args: MetaArgs) => MetaDescriptors
28
-
29
- export type HeadersArgs = T.HeadersArgs
30
- export type HeadersFunction = (args: HeadersArgs) => Headers | HeadersInit
31
-
32
- export type LoaderArgs = T.CreateServerLoaderArgs<Info>
33
- export type ClientLoaderArgs = T.CreateClientLoaderArgs<Info>
34
- export type ActionArgs = T.CreateServerActionArgs<Info>
35
- export type ClientActionArgs = T.CreateClientActionArgs<Info>
36
-
37
- export type HydrateFallbackProps = T.CreateHydrateFallbackProps<Info>
38
- export type ComponentProps = T.CreateComponentProps<Info>
39
- export type ErrorBoundaryProps = T.CreateErrorBoundaryProps<Info>
40
- }
package/host/app/root.tsx DELETED
@@ -1,23 +0,0 @@
1
- import { Links, Meta, Outlet, Scripts, ScrollRestoration } from "react-router";
2
-
3
- export function Layout({ children }: { children: React.ReactNode }) {
4
- return (
5
- <html lang="en">
6
- <head>
7
- <meta charSet="utf-8" />
8
- <meta name="viewport" content="width=device-width, initial-scale=1" />
9
- <Meta />
10
- <Links />
11
- </head>
12
- <body>
13
- {children}
14
- <ScrollRestoration />
15
- <Scripts />
16
- </body>
17
- </html>
18
- );
19
- }
20
-
21
- export default function App() {
22
- return <Outlet />;
23
- }
@@ -1,5 +0,0 @@
1
- // we export empty routes because rr7 need this file and we load routes via xyd plugins
2
-
3
- export const routes = []
4
-
5
- export default routes
@@ -1,81 +0,0 @@
1
- import {
2
- createProcessor,
3
- nodeTypes,
4
- resolveFileAndOptions
5
- } from "./chunk-A76PLWFF.js";
6
- import "./chunk-SBIFJFEH.js";
7
- import "./chunk-B2TCFXA3.js";
8
- import "./chunk-CZACBYAQ.js";
9
- import "./chunk-NSHFRFAV.js";
10
- import "./chunk-O6QCC74R.js";
11
- import "./chunk-2TUXWMP5.js";
12
-
13
- // ../node_modules/.pnpm/@mdx-js+mdx@3.1.0_acorn@8.14.0/node_modules/@mdx-js/mdx/lib/compile.js
14
- function compile(vfileCompatible, compileOptions) {
15
- const { file, options } = resolveFileAndOptions(vfileCompatible, compileOptions);
16
- return createProcessor(options).process(file);
17
- }
18
- function compileSync(vfileCompatible, compileOptions) {
19
- const { file, options } = resolveFileAndOptions(vfileCompatible, compileOptions);
20
- return createProcessor(options).processSync(file);
21
- }
22
-
23
- // ../node_modules/.pnpm/@mdx-js+mdx@3.1.0_acorn@8.14.0/node_modules/@mdx-js/mdx/lib/util/resolve-evaluate-options.js
24
- function resolveEvaluateOptions(options) {
25
- const {
26
- Fragment,
27
- baseUrl,
28
- development,
29
- jsx,
30
- jsxDEV,
31
- jsxs,
32
- useMDXComponents,
33
- ...rest
34
- } = options || {};
35
- if (!Fragment) throw new Error("Expected `Fragment` given to `evaluate`");
36
- if (development) {
37
- if (!jsxDEV) throw new Error("Expected `jsxDEV` given to `evaluate`");
38
- } else {
39
- if (!jsx) throw new Error("Expected `jsx` given to `evaluate`");
40
- if (!jsxs) throw new Error("Expected `jsxs` given to `evaluate`");
41
- }
42
- return {
43
- compiletime: {
44
- ...rest,
45
- development,
46
- outputFormat: "function-body",
47
- providerImportSource: useMDXComponents ? "#" : void 0
48
- },
49
- runtime: { Fragment, baseUrl, jsx, jsxDEV, jsxs, useMDXComponents }
50
- };
51
- }
52
-
53
- // ../node_modules/.pnpm/@mdx-js+mdx@3.1.0_acorn@8.14.0/node_modules/@mdx-js/mdx/lib/run.js
54
- var AsyncFunction = Object.getPrototypeOf(run).constructor;
55
- async function run(code, options) {
56
- return new AsyncFunction(String(code))(options);
57
- }
58
- function runSync(code, options) {
59
- return new Function(String(code))(options);
60
- }
61
-
62
- // ../node_modules/.pnpm/@mdx-js+mdx@3.1.0_acorn@8.14.0/node_modules/@mdx-js/mdx/lib/evaluate.js
63
- async function evaluate(file, options) {
64
- const { compiletime, runtime } = resolveEvaluateOptions(options);
65
- return run(await compile(file, compiletime), runtime);
66
- }
67
- function evaluateSync(file, options) {
68
- const { compiletime, runtime } = resolveEvaluateOptions(options);
69
- return runSync(compileSync(file, compiletime), runtime);
70
- }
71
- export {
72
- compile,
73
- compileSync,
74
- createProcessor,
75
- evaluate,
76
- evaluateSync,
77
- nodeTypes,
78
- run,
79
- runSync
80
- };
81
- //# sourceMappingURL=@mdx-js_mdx.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../../../node_modules/.pnpm/@mdx-js+mdx@3.1.0_acorn@8.14.0/node_modules/@mdx-js/mdx/lib/compile.js", "../../../../../../node_modules/.pnpm/@mdx-js+mdx@3.1.0_acorn@8.14.0/node_modules/@mdx-js/mdx/lib/util/resolve-evaluate-options.js", "../../../../../../node_modules/.pnpm/@mdx-js+mdx@3.1.0_acorn@8.14.0/node_modules/@mdx-js/mdx/lib/run.js", "../../../../../../node_modules/.pnpm/@mdx-js+mdx@3.1.0_acorn@8.14.0/node_modules/@mdx-js/mdx/lib/evaluate.js"],
4
- "sourcesContent": ["/**\n * @import {Compatible, VFile} from 'vfile'\n * @import {ProcessorOptions} from './core.js'\n */\n\n/**\n * @typedef {Omit<ProcessorOptions, 'format'>} CoreProcessorOptions\n * Core configuration.\n *\n * @typedef ExtraOptions\n * Extra configuration.\n * @property {'detect' | 'md' | 'mdx' | null | undefined} [format='detect']\n * Format of `file` (default: `'detect'`).\n *\n * @typedef {CoreProcessorOptions & ExtraOptions} CompileOptions\n * Configuration for `compile`.\n *\n * `CompileOptions` is the same as `ProcessorOptions` with the exception that\n * the `format` option supports a `'detect'` value, which is the default.\n * The `'detect'` format means to use `'md'` for files with an extension in\n * `mdExtensions` and `'mdx'` otherwise.\n */\n\nimport {resolveFileAndOptions} from './util/resolve-file-and-options.js'\nimport {createProcessor} from './core.js'\n\n/**\n * Compile MDX to JS.\n *\n * @param {Readonly<Compatible>} vfileCompatible\n * MDX document to parse.\n * @param {Readonly<CompileOptions> | null | undefined} [compileOptions]\n * Compile configuration (optional).\n * @return {Promise<VFile>}\n * Promise to compiled file.\n */\nexport function compile(vfileCompatible, compileOptions) {\n const {file, options} = resolveFileAndOptions(vfileCompatible, compileOptions)\n return createProcessor(options).process(file)\n}\n\n/**\n * Synchronously compile MDX to JS.\n *\n * When possible please use the async `compile`.\n *\n * @param {Readonly<Compatible>} vfileCompatible\n * MDX document to parse.\n * @param {Readonly<CompileOptions> | null | undefined} [compileOptions]\n * Compile configuration (optional).\n * @return {VFile}\n * Compiled file.\n */\nexport function compileSync(vfileCompatible, compileOptions) {\n const {file, options} = resolveFileAndOptions(vfileCompatible, compileOptions)\n return createProcessor(options).processSync(file)\n}\n", "/**\n * @import {Fragment, Jsx, JsxDev} from 'hast-util-to-jsx-runtime'\n * @import {MDXComponents} from 'mdx/types.js'\n * @import {CompileOptions} from '../compile.js'\n */\n\n/**\n * @typedef {EvaluateProcessorOptions & RunOptions} EvaluateOptions\n * Configuration for `evaluate`.\n *\n * @typedef {Omit<CompileOptions, 'baseUrl' | 'jsx' | 'jsxImportSource' | 'jsxRuntime' | 'outputFormat' | 'pragma' | 'pragmaFrag' | 'pragmaImportSource' | 'providerImportSource'> } EvaluateProcessorOptions\n * Compile configuration without JSX options for evaluation.\n *\n * @typedef RunOptions\n * Configuration to run compiled code.\n *\n * `Fragment`, `jsx`, and `jsxs` are used when the code is compiled in\n * production mode (`development: false`).\n * `Fragment` and `jsxDEV` are used when compiled in development mode\n * (`development: true`).\n * `useMDXComponents` is used when the code is compiled with\n * `providerImportSource: '#'` (the exact value of this compile option\n * doesn’t matter).\n * @property {URL | string | null | undefined} [baseUrl]\n * Use this URL as `import.meta.url` and resolve `import` and `export … from`\n * relative to it (optional, example: `import.meta.url`);\n * this option can also be given at compile time in `CompileOptions`;\n * you should pass this (likely at runtime), as you might get runtime errors\n * when using `import.meta.url` / `import` / `export … from ` otherwise.\n * @property {Fragment} Fragment\n * Symbol to use for fragments (**required**).\n * @property {Jsx | null | undefined} [jsx]\n * Function to generate an element with static children in production mode.\n * @property {JsxDev | null | undefined} [jsxDEV]\n * Function to generate an element in development mode.\n * @property {Jsx | null | undefined} [jsxs]\n * Function to generate an element with dynamic children in production mode.\n * @property {UseMdxComponents | null | undefined} [useMDXComponents]\n * Function to get components from context.\n *\n * @callback UseMdxComponents\n * Get components from context.\n * @returns {MDXComponents}\n * Current components.\n */\n\n// Fix to show references to above types in VS Code.\n''\n\n/**\n * Split compiletime options from runtime options.\n *\n * @param {Readonly<EvaluateOptions> | null | undefined} options\n * Configuration.\n * @returns {{compiletime: CompileOptions, runtime: RunOptions}}\n * Split options.\n */\nexport function resolveEvaluateOptions(options) {\n const {\n Fragment,\n baseUrl,\n development,\n jsx,\n jsxDEV,\n jsxs,\n useMDXComponents,\n ...rest\n } = options || {}\n\n if (!Fragment) throw new Error('Expected `Fragment` given to `evaluate`')\n if (development) {\n if (!jsxDEV) throw new Error('Expected `jsxDEV` given to `evaluate`')\n } else {\n if (!jsx) throw new Error('Expected `jsx` given to `evaluate`')\n if (!jsxs) throw new Error('Expected `jsxs` given to `evaluate`')\n }\n\n return {\n compiletime: {\n ...rest,\n development,\n outputFormat: 'function-body',\n providerImportSource: useMDXComponents ? '#' : undefined\n },\n runtime: {Fragment, baseUrl, jsx, jsxDEV, jsxs, useMDXComponents}\n }\n}\n", "/**\n * @import {MDXModule} from 'mdx/types.js'\n * @import {RunOptions} from './util/resolve-evaluate-options.js'\n */\n\n/** @type {new (code: string, ...args: Array<unknown>) => Function} **/\nconst AsyncFunction = Object.getPrototypeOf(run).constructor\n\n/**\n * Run code compiled with `outputFormat: 'function-body'`.\n *\n * > ☢️ **Danger**: this `eval`s JavaScript.\n *\n * @param {{toString(): string}} code\n * JavaScript function body to run.\n * @param {RunOptions} options\n * Configuration (**required**).\n * @return {Promise<MDXModule>}\n * Promise to a module;\n * the result is an object with a `default` field set to the component;\n * anything else that was exported is available too.\n */\nexport async function run(code, options) {\n return new AsyncFunction(String(code))(options)\n}\n\n/**\n * Run code, synchronously.\n *\n * When possible please use the async `run`.\n *\n * > ☢️ **Danger**: this `eval`s JavaScript.\n *\n * @param {{toString(): string}} code\n * JavaScript function body to run.\n * @param {RunOptions} options\n * Configuration (**required**).\n * @return {MDXModule}\n * Module.\n */\nexport function runSync(code, options) {\n // eslint-disable-next-line no-new-func\n return new Function(String(code))(options)\n}\n", "/**\n * @import {MDXModule} from 'mdx/types.js'\n * @import {Compatible} from 'vfile'\n * @import {EvaluateOptions} from './util/resolve-evaluate-options.js'\n */\n\nimport {resolveEvaluateOptions} from './util/resolve-evaluate-options.js'\nimport {compile, compileSync} from './compile.js'\nimport {run, runSync} from './run.js'\n\n/**\n * Compile and run MDX.\n *\n * When you trust your content, `evaluate` can work.\n * When possible, use `compile`, write to a file, and then run with Node or use\n * one of the integrations.\n *\n * > ☢️ **Danger**: it’s called **evaluate** because it `eval`s JavaScript.\n *\n * ###### Notes\n *\n * Compiling (and running) MDX takes time.\n *\n * If you are live-rendering a string of MDX that often changes using a virtual\n * DOM based framework (such as React), one performance improvement is to call\n * the `MDXContent` component yourself.\n * The reason is that the `evaluate` creates a new function each time, which\n * cannot be diffed:\n *\n * ```diff\n * const {default: MDXContent} = await evaluate('…')\n *\n * -<MDXContent {...props} />\n * +MDXContent(props)\n * ```\n *\n * @param {Readonly<Compatible>} file\n * MDX document to parse.\n * @param {Readonly<EvaluateOptions>} options\n * Configuration (**required**).\n * @return {Promise<MDXModule>}\n * Promise to a module;\n * the result is an object with a `default` field set to the component;\n * anything else that was exported is available too.\n\n */\nexport async function evaluate(file, options) {\n const {compiletime, runtime} = resolveEvaluateOptions(options)\n return run(await compile(file, compiletime), runtime)\n}\n\n/**\n * Compile and run MDX, synchronously.\n *\n * When possible please use the async `evaluate`.\n *\n * > ☢️ **Danger**: it’s called **evaluate** because it `eval`s JavaScript.\n *\n * @param {Readonly<Compatible>} file\n * MDX document to parse.\n * @param {Readonly<EvaluateOptions>} options\n * Configuration (**required**).\n * @return {MDXModule}\n * Module.\n */\nexport function evaluateSync(file, options) {\n const {compiletime, runtime} = resolveEvaluateOptions(options)\n return runSync(compileSync(file, compiletime), runtime)\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;AAoCO,SAAS,QAAQ,iBAAiB,gBAAgB;AACvD,QAAM,EAAC,MAAM,QAAO,IAAI,sBAAsB,iBAAiB,cAAc;AAC7E,SAAO,gBAAgB,OAAO,EAAE,QAAQ,IAAI;AAC9C;AAcO,SAAS,YAAY,iBAAiB,gBAAgB;AAC3D,QAAM,EAAC,MAAM,QAAO,IAAI,sBAAsB,iBAAiB,cAAc;AAC7E,SAAO,gBAAgB,OAAO,EAAE,YAAY,IAAI;AAClD;;;ACCO,SAAS,uBAAuB,SAAS;AAC9C,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,IAAI,WAAW,CAAC;AAEhB,MA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