dinou 1.7.0 → 1.7.1

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.
@@ -20,7 +20,7 @@ addHook({
20
20
  const result = createScopedName(localName, filepath);
21
21
  return result + ".[ext]";
22
22
  },
23
- publicPath: "images/",
23
+ publicPath: "/images/",
24
24
  });
25
25
 
26
26
  const { renderToPipeableStream } = require("react-dom/server");
package/dinou/server.js CHANGED
@@ -2,13 +2,7 @@ require("dotenv/config");
2
2
  require("./register-paths");
3
3
  const webpackRegister = require("react-server-dom-webpack/node-register");
4
4
  const path = require("path");
5
- const {
6
- readFileSync,
7
- existsSync,
8
- // mkdirSync,
9
- // createWriteStream,
10
- createReadStream,
11
- } = require("fs");
5
+ const { readFileSync, existsSync, createReadStream } = require("fs");
12
6
  const { renderToPipeableStream } = require("react-server-dom-webpack/server");
13
7
  const express = require("express");
14
8
  const getSSGJSXOrJSX = require("./get-ssg-jsx-or-jsx.js");
@@ -35,9 +29,8 @@ addHook({
35
29
  const result = createScopedName(localName, filepath);
36
30
  return result + ".[ext]";
37
31
  },
38
- publicPath: "images/",
32
+ publicPath: "/images/",
39
33
  });
40
- // const { PassThrough } = require("stream");
41
34
  const generateStatic = require("./generate-static.js");
42
35
  const renderAppToHtml = require("./render-app-to-html.js");
43
36
  const revalidating = require("./revalidating.js");
@@ -67,7 +60,6 @@ app.get(/^\/____rsc_payload____\/.*\/?$/, async (req, res) => {
67
60
  if (!isDevelopment) {
68
61
  const payloadPath = path.join("dist2", reqPath, "rsc.rsc");
69
62
  if (existsSync(payloadPath)) {
70
- // console.log(`[RSC] Serving existing payload for ${reqPath}`);
71
63
  res.setHeader("Content-Type", "application/octet-stream");
72
64
  const readStream = createReadStream(payloadPath);
73
65
  readStream.on("error", (err) => {
@@ -78,8 +70,6 @@ app.get(/^\/____rsc_payload____\/.*\/?$/, async (req, res) => {
78
70
  }
79
71
  }
80
72
 
81
- // console.log(`[RSC] Payload not found, generating new one for ${reqPath}`);
82
-
83
73
  const jsx = await getSSGJSXOrJSX(reqPath, { ...req.query });
84
74
 
85
75
  const manifest = JSON.parse(
@@ -89,17 +79,8 @@ app.get(/^\/____rsc_payload____\/.*\/?$/, async (req, res) => {
89
79
  )
90
80
  );
91
81
 
92
- // mkdirSync(path.dirname(payloadPath), { recursive: true });
93
- // const fileWriteStream = createWriteStream(payloadPath);
94
-
95
82
  const { pipe } = renderToPipeableStream(jsx, manifest);
96
83
  pipe(res);
97
-
98
- // Pipe both to response and file
99
- // const passThrough = new PassThrough();
100
- // pipe(passThrough);
101
- // passThrough.pipe(res);
102
- // passThrough.pipe(fileWriteStream);
103
84
  } catch (error) {
104
85
  console.error("Error rendering RSC:", error);
105
86
  res.status(500).send("Internal Server Error");
@@ -128,13 +109,12 @@ app.post(/^\/____rsc_payload_error____\/.*\/?$/, async (req, res) => {
128
109
  app.get(/^\/.*\/?$/, async (req, res) => {
129
110
  try {
130
111
  const reqPath = req.path.endsWith("/") ? req.path : req.path + "/";
131
- const htmlPath = path.join("dist2", reqPath, "index.html");
132
112
 
133
113
  if (!isDevelopment) {
134
114
  revalidating(reqPath);
115
+ const htmlPath = path.join("dist2", reqPath, "index.html");
135
116
 
136
117
  if (existsSync(htmlPath)) {
137
- // console.log("Serving cached HTML:", htmlPath);
138
118
  res.setHeader("Content-Type", "text/html");
139
119
  return createReadStream(htmlPath).pipe(res);
140
120
  }
@@ -145,21 +125,13 @@ app.get(/^\/.*\/?$/, async (req, res) => {
145
125
  JSON.stringify({ ...req.query })
146
126
  );
147
127
 
148
- // mkdirSync(path.dirname(htmlPath), { recursive: true });
149
-
150
- // const fileStream = createWriteStream(htmlPath);
151
128
  res.setHeader("Content-Type", "text/html");
152
129
  appHtmlStream.pipe(res);
153
- // appHtmlStream.pipe(fileStream);
154
130
 
155
131
  appHtmlStream.on("error", (error) => {
156
132
  console.error("Stream error:", error);
157
133
  res.status(500).send("Internal Server Error");
158
134
  });
159
-
160
- // fileStream.on("error", (error) => {
161
- // console.error("File write error:", error);
162
- // });
163
135
  } catch (error) {
164
136
  console.error("Error rendering React app:", error);
165
137
  res.status(500).send("Internal Server Error");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dinou",
3
- "version": "1.7.0",
3
+ "version": "1.7.1",
4
4
  "description": "Minimal React 19 Framework",
5
5
  "main": "index.js",
6
6
  "bin": {