@fuma-content/studio 1.0.1 → 1.0.2

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.
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,71 @@
1
+ import path from "node:path";
2
+ import url from "node:url";
3
+ import os from "node:os";
4
+ import { createRequestHandler } from "@react-router/express";
5
+ import { createRequestListener } from "@mjackson/node-fetch-server";
6
+ import express from "express";
7
+
8
+ //#region src/bin/cli.ts
9
+ /**
10
+ * cloned from https://github.com/remix-run/react-router/blob/main/packages/react-router-serve/cli.ts as it is not exported from their package
11
+ */
12
+ Object.assign(process.env, { NODE_ENV: process.env.NODE_ENV ?? "production" });
13
+ run();
14
+ function isRSCServerBuild(build) {
15
+ return Boolean(typeof build === "object" && build && "default" in build && typeof build.default === "object" && build.default && "fetch" in build.default && typeof build.default.fetch === "function");
16
+ }
17
+ function parseNumber(raw) {
18
+ if (raw === void 0) return void 0;
19
+ let maybe = Number(raw);
20
+ if (Number.isNaN(maybe)) return void 0;
21
+ return maybe;
22
+ }
23
+ async function run() {
24
+ let port = parseNumber(process.env.PORT) ?? 3e3;
25
+ let buildPathArg = process.argv[2];
26
+ if (!buildPathArg) {
27
+ console.error(`
28
+ Usage: react-router-serve <server-build-path> - e.g. react-router-serve build/server/index.js`);
29
+ process.exit(1);
30
+ }
31
+ let buildPath = path.resolve(buildPathArg);
32
+ let buildModule = await import(url.pathToFileURL(buildPath).href);
33
+ let build;
34
+ if (isRSCServerBuild(buildModule)) {
35
+ const config = {
36
+ publicPath: "/",
37
+ assetsBuildDirectory: "../client",
38
+ ...buildModule.unstable_reactRouterServeConfig || {}
39
+ };
40
+ build = {
41
+ fetch: buildModule.default.fetch,
42
+ publicPath: config.publicPath,
43
+ assetsBuildDirectory: path.resolve(path.dirname(buildPath), config.assetsBuildDirectory)
44
+ };
45
+ } else build = buildModule;
46
+ let onListen = () => {
47
+ let address = process.env.HOST || Object.values(os.networkInterfaces()).flat().find((ip) => String(ip?.family).includes("4") && !ip?.internal)?.address;
48
+ if (!address) console.log(`[react-router-serve] http://localhost:${port}`);
49
+ else console.log(`[react-router-serve] http://localhost:${port} (http://${address}:${port})`);
50
+ };
51
+ let app = express();
52
+ app.disable("x-powered-by");
53
+ app.use(path.posix.join(build.publicPath, "assets"), express.static(path.join(build.assetsBuildDirectory, "assets"), {
54
+ immutable: true,
55
+ maxAge: "1y"
56
+ }));
57
+ app.use(build.publicPath, express.static(build.assetsBuildDirectory));
58
+ app.use(express.static("public", { maxAge: "1h" }));
59
+ if (build.fetch) app.all("/{*splat}", createRequestListener(build.fetch));
60
+ else app.all("/{*splat}", createRequestHandler({
61
+ build: buildModule,
62
+ mode: process.env.NODE_ENV
63
+ }));
64
+ let server = process.env.HOST ? app.listen(port, process.env.HOST, onListen) : app.listen(port, onListen);
65
+ ["SIGTERM", "SIGINT"].forEach((signal) => {
66
+ process.once(signal, () => server?.close(console.error));
67
+ });
68
+ }
69
+
70
+ //#endregion
71
+ export { };
package/dist/bin.mjs CHANGED
@@ -16,7 +16,7 @@ main();
16
16
  async function main() {
17
17
  const isCI = process.env.CI === "1";
18
18
  const { bind: HOST, port: PORT } = options;
19
- const serveBinPath = path.join(__dirname, "../node_modules/@react-router/serve/bin.js");
19
+ const serveBinPath = path.join(__dirname, "./bin/cli.mjs");
20
20
  const rootDir = path.join(__dirname, "../");
21
21
  const studioConfig = path.resolve("content.config.ts");
22
22
  intro(`Fuma Content ${version}`);
@@ -46,11 +46,13 @@ async function main() {
46
46
  });
47
47
  for await (const message of serverProcess) {
48
48
  if (message.includes(`[react-router-serve]`) && !isCI) {
49
+ const url$1 = `http://${HOST}:${PORT}`;
50
+ log.success(`Started studio at ${url$1}`);
49
51
  const shouldOpen = await confirm({ message: "Do you want to open on browser?" });
50
52
  if (isCancel(shouldOpen)) process.exit();
51
53
  if (shouldOpen) {
52
- log.message(`Opening browser at http://${HOST}:${PORT}`, { spacing: 0 });
53
- open(`http://${HOST}:${PORT}`);
54
+ log.message(`Opening browser at ${url$1}`, { spacing: 0 });
55
+ open(url$1);
54
56
  }
55
57
  continue;
56
58
  }
package/dist/package.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  //#region package.json
2
2
  var name = "@fuma-content/studio";
3
- var version = "1.0.1";
3
+ var version = "1.0.2";
4
4
 
5
5
  //#endregion
6
6
  export { name, version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fuma-content/studio",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "The studio integration of Fuma Content",
5
5
  "keywords": [
6
6
  "Contentlayer",
@@ -28,6 +28,7 @@
28
28
  "@base-ui/utils": "^0.2.4",
29
29
  "@clack/prompts": "^1.0.0",
30
30
  "@emoji-mart/data": "1.2.1",
31
+ "@mjackson/node-fetch-server": "^0.7.0",
31
32
  "@monaco-editor/react": "^4.7.0",
32
33
  "@platejs/ai": "^52.1.0",
33
34
  "@platejs/autoformat": "^52.0.11",
@@ -54,8 +55,8 @@
54
55
  "@platejs/slash-command": "^52.0.15",
55
56
  "@platejs/suggestion": "^52.0.11",
56
57
  "@platejs/table": "^52.0.11",
58
+ "@react-router/express": "^7.13.0",
57
59
  "@react-router/node": "^7.13.0",
58
- "@react-router/serve": "^7.13.0",
59
60
  "@standard-schema/spec": "^1.1.0",
60
61
  "@tanstack/query-db-collection": "^1.0.21",
61
62
  "@tanstack/react-db": "^0.1.68",
@@ -68,6 +69,7 @@
68
69
  "cmdk": "^1.1.1",
69
70
  "commander": "^14.0.2",
70
71
  "date-fns": "^4.1.0",
72
+ "express": "^5.2.1",
71
73
  "gray-matter": "^4.0.3",
72
74
  "highlight.js": "^11.11.1",
73
75
  "isbot": "^5.1.34",
@@ -99,6 +101,7 @@
99
101
  "devDependencies": {
100
102
  "@react-router/dev": "^7.13.0",
101
103
  "@tailwindcss/vite": "^4.1.18",
104
+ "@types/express": "^5.0.6",
102
105
  "@types/lodash.debounce": "^4.0.9",
103
106
  "@types/node": "^25.1.0",
104
107
  "@types/react": "^19.2.10",