@taujs/server 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +15 -12
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,12 +8,19 @@
|
|
|
8
8
|
|
|
9
9
|
## CSR; SSR; Streaming SSR; Hydration; Fastify + React 18
|
|
10
10
|
|
|
11
|
+
Supports rendering modes:
|
|
12
|
+
|
|
13
|
+
- Client-side rendering (CSR)
|
|
14
|
+
- Server-side rendering (SSR)
|
|
15
|
+
- Streaming SSR
|
|
16
|
+
|
|
11
17
|
Fastify Plugin for integration with taujs [ τjs ] template https://github.com/aoede3/taujs
|
|
12
18
|
|
|
13
19
|
- Production: Fastify, React
|
|
14
20
|
- Development: Fastify, React, tsx, Vite
|
|
15
21
|
|
|
16
|
-
TypeScript
|
|
22
|
+
- TypeScript-first
|
|
23
|
+
- ESM-only focus
|
|
17
24
|
|
|
18
25
|
## τjs - Developer eXperience
|
|
19
26
|
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -121,6 +121,16 @@ import { readFile } from "node:fs/promises";
|
|
|
121
121
|
import path from "node:path";
|
|
122
122
|
import { createViteRuntime } from "vite";
|
|
123
123
|
|
|
124
|
+
// src/constants.ts
|
|
125
|
+
var RENDERTYPE = {
|
|
126
|
+
ssr: "ssr",
|
|
127
|
+
streaming: "streaming"
|
|
128
|
+
};
|
|
129
|
+
var SSRTAG = {
|
|
130
|
+
ssrHead: "<!--ssr-head-->",
|
|
131
|
+
ssrHtml: "<!--ssr-html-->"
|
|
132
|
+
};
|
|
133
|
+
|
|
124
134
|
// src/utils/Utils.ts
|
|
125
135
|
import { fileURLToPath } from "node:url";
|
|
126
136
|
import { dirname, join } from "node:path";
|
|
@@ -257,16 +267,6 @@ var overrideCSSHMRConsoleError = () => {
|
|
|
257
267
|
};
|
|
258
268
|
};
|
|
259
269
|
|
|
260
|
-
// src/constants.ts
|
|
261
|
-
var RENDERTYPE = {
|
|
262
|
-
ssr: "ssr",
|
|
263
|
-
streaming: "streaming"
|
|
264
|
-
};
|
|
265
|
-
var SSRTAG = {
|
|
266
|
-
ssrHead: "<!--ssr-head-->",
|
|
267
|
-
ssrHtml: "<!--ssr-html-->"
|
|
268
|
-
};
|
|
269
|
-
|
|
270
270
|
// src/SSRServer.ts
|
|
271
271
|
var SSRServer = (0, import_fastify_plugin.default)(
|
|
272
272
|
async (app, opts) => {
|
|
@@ -311,7 +311,7 @@ var SSRServer = (0, import_fastify_plugin.default)(
|
|
|
311
311
|
server.middlewares.use((req, res, next) => {
|
|
312
312
|
console.log(`rx: ${req.url}`);
|
|
313
313
|
res.on("finish", () => {
|
|
314
|
-
console.log(`
|
|
314
|
+
console.log(`tx: ${req.url}`);
|
|
315
315
|
});
|
|
316
316
|
next();
|
|
317
317
|
});
|
|
@@ -378,7 +378,10 @@ var SSRServer = (0, import_fastify_plugin.default)(
|
|
|
378
378
|
const initialDataResolved = await initialDataPromise;
|
|
379
379
|
const initialDataScript = `<script>window.__INITIAL_DATA__ = ${JSON.stringify(initialDataResolved).replace(/</g, "\\u003c")}</script>`;
|
|
380
380
|
const { headContent, appHtml } = await renderSSR(initialDataResolved, req.url, attr?.meta);
|
|
381
|
-
|
|
381
|
+
let aggregateHeadContent = headContent;
|
|
382
|
+
if (ssrManifest) aggregateHeadContent += preloadLinks;
|
|
383
|
+
if (manifest) aggregateHeadContent += cssLinks;
|
|
384
|
+
const fullHtml = template.replace(SSRTAG.ssrHead, aggregateHeadContent).replace(SSRTAG.ssrHtml, `${appHtml}${initialDataScript}<script type="module" src="${bootstrapModules}" async=""></script>`);
|
|
382
385
|
return reply.status(200).header("Content-Type", "text/html").send(fullHtml);
|
|
383
386
|
} else {
|
|
384
387
|
const { renderStream } = renderModule;
|