@taujs/server 0.1.8 → 0.1.9
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 +7 -9
- package/dist/data.js +2 -1
- package/dist/index.js +83 -12
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -18,9 +18,9 @@ Supported application structure and composition:
|
|
|
18
18
|
|
|
19
19
|
- Single-page Application (SPA)
|
|
20
20
|
- Multi-page Application (MPA)
|
|
21
|
-
- Build-time Micro-Frontends, server orchestration and delivery
|
|
21
|
+
- Build-time Micro-Frontends (MFE), with server orchestration and delivery
|
|
22
22
|
|
|
23
|
-
Assemble
|
|
23
|
+
Assemble independent frontends at build time incorporating flexible per-route SPA-MPA hybrid with CSR, SSR, and Streaming SSR, rendering options.
|
|
24
24
|
|
|
25
25
|
Fastify Plugin for integration with taujs [ τjs ] template https://github.com/aoede3/taujs
|
|
26
26
|
|
|
@@ -30,17 +30,15 @@ Fastify Plugin for integration with taujs [ τjs ] template https://github.com/a
|
|
|
30
30
|
- TypeScript-first
|
|
31
31
|
- ESM-only focus
|
|
32
32
|
|
|
33
|
-
## τjs - Developer
|
|
33
|
+
## τjs - DX Developer Experience
|
|
34
34
|
|
|
35
|
-
Integrated
|
|
35
|
+
Integrated Vite HMR run alongside tsx (TS eXecute) providing fast responsive dev reload times for universal backend / frontend changes
|
|
36
36
|
|
|
37
37
|
- Fastify https://fastify.dev/
|
|
38
38
|
- React https://reactjs.org/
|
|
39
39
|
- tsx https://tsx.is/
|
|
40
40
|
- Vite https://vitejs.dev/guide/ssr#building-for-production
|
|
41
41
|
|
|
42
|
-
- ViteDevServer HMR https://vitejs.dev/guide/ssr#setting-up-the-dev-server
|
|
43
|
-
- Vite Runtime API https://vitejs.dev/guide/api-vite-runtime
|
|
44
42
|
- ESBuild https://esbuild.github.io/
|
|
45
43
|
- Rollup https://rollupjs.org/
|
|
46
44
|
- ESM https://nodejs.org/api/esm.html
|
|
@@ -85,8 +83,8 @@ Integral to τjs is its internal routing:
|
|
|
85
83
|
|
|
86
84
|
In ensuring a particular 'route' receives data for hydration there are two options:
|
|
87
85
|
|
|
88
|
-
1. An HTTP call
|
|
89
|
-
2.
|
|
86
|
+
1. An HTTP call syntactically not unlike 'fetch' providing params to a 'fetch' call
|
|
87
|
+
2. Internal service call returning data as per your architecture
|
|
90
88
|
|
|
91
89
|
In supporting Option 2. there is a registry of services. More detail in 'Service Registry'.
|
|
92
90
|
|
|
@@ -96,7 +94,7 @@ https://github.com/aoede3/taujs/blob/main/src/shared/routes/Routes.ts
|
|
|
96
94
|
|
|
97
95
|
### Service Registry
|
|
98
96
|
|
|
99
|
-
In supporting internal calls via τjs a registry of available services and methods
|
|
97
|
+
In supporting internal calls via τjs a registry of available services and methods can provide linkage to your own architectural setup and developmental patterns
|
|
100
98
|
|
|
101
99
|
https://github.com/aoede3/taujs/blob/main/src/server/services/ServiceRegistry.ts
|
|
102
100
|
|
package/dist/data.js
CHANGED
|
@@ -110,7 +110,8 @@ var hydrateApp = ({ appComponent, initialDataKey = "__INITIAL_DATA__", rootEleme
|
|
|
110
110
|
};
|
|
111
111
|
|
|
112
112
|
// src/SSRRender.tsx
|
|
113
|
-
import
|
|
113
|
+
import "http";
|
|
114
|
+
import { Writable } from "stream";
|
|
114
115
|
import "react";
|
|
115
116
|
import { renderToPipeableStream, renderToString } from "react-dom/server";
|
|
116
117
|
import { jsx as jsx3 } from "react/jsx-runtime";
|
package/dist/index.js
CHANGED
|
@@ -114,11 +114,84 @@ var require_plugin = __commonJS({
|
|
|
114
114
|
}
|
|
115
115
|
});
|
|
116
116
|
|
|
117
|
+
// node_modules/picocolors/picocolors.js
|
|
118
|
+
var require_picocolors = __commonJS({
|
|
119
|
+
"node_modules/picocolors/picocolors.js"(exports, module) {
|
|
120
|
+
"use strict";
|
|
121
|
+
var p = process || {};
|
|
122
|
+
var argv = p.argv || [];
|
|
123
|
+
var env = p.env || {};
|
|
124
|
+
var isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
|
|
125
|
+
var formatter = (open, close, replace = open) => (input) => {
|
|
126
|
+
let string = "" + input, index = string.indexOf(close, open.length);
|
|
127
|
+
return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
|
|
128
|
+
};
|
|
129
|
+
var replaceClose = (string, close, replace, index) => {
|
|
130
|
+
let result = "", cursor = 0;
|
|
131
|
+
do {
|
|
132
|
+
result += string.substring(cursor, index) + replace;
|
|
133
|
+
cursor = index + close.length;
|
|
134
|
+
index = string.indexOf(close, cursor);
|
|
135
|
+
} while (~index);
|
|
136
|
+
return result + string.substring(cursor);
|
|
137
|
+
};
|
|
138
|
+
var createColors = (enabled = isColorSupported) => {
|
|
139
|
+
let f = enabled ? formatter : () => String;
|
|
140
|
+
return {
|
|
141
|
+
isColorSupported: enabled,
|
|
142
|
+
reset: f("\x1B[0m", "\x1B[0m"),
|
|
143
|
+
bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
|
|
144
|
+
dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
|
|
145
|
+
italic: f("\x1B[3m", "\x1B[23m"),
|
|
146
|
+
underline: f("\x1B[4m", "\x1B[24m"),
|
|
147
|
+
inverse: f("\x1B[7m", "\x1B[27m"),
|
|
148
|
+
hidden: f("\x1B[8m", "\x1B[28m"),
|
|
149
|
+
strikethrough: f("\x1B[9m", "\x1B[29m"),
|
|
150
|
+
black: f("\x1B[30m", "\x1B[39m"),
|
|
151
|
+
red: f("\x1B[31m", "\x1B[39m"),
|
|
152
|
+
green: f("\x1B[32m", "\x1B[39m"),
|
|
153
|
+
yellow: f("\x1B[33m", "\x1B[39m"),
|
|
154
|
+
blue: f("\x1B[34m", "\x1B[39m"),
|
|
155
|
+
magenta: f("\x1B[35m", "\x1B[39m"),
|
|
156
|
+
cyan: f("\x1B[36m", "\x1B[39m"),
|
|
157
|
+
white: f("\x1B[37m", "\x1B[39m"),
|
|
158
|
+
gray: f("\x1B[90m", "\x1B[39m"),
|
|
159
|
+
bgBlack: f("\x1B[40m", "\x1B[49m"),
|
|
160
|
+
bgRed: f("\x1B[41m", "\x1B[49m"),
|
|
161
|
+
bgGreen: f("\x1B[42m", "\x1B[49m"),
|
|
162
|
+
bgYellow: f("\x1B[43m", "\x1B[49m"),
|
|
163
|
+
bgBlue: f("\x1B[44m", "\x1B[49m"),
|
|
164
|
+
bgMagenta: f("\x1B[45m", "\x1B[49m"),
|
|
165
|
+
bgCyan: f("\x1B[46m", "\x1B[49m"),
|
|
166
|
+
bgWhite: f("\x1B[47m", "\x1B[49m"),
|
|
167
|
+
blackBright: f("\x1B[90m", "\x1B[39m"),
|
|
168
|
+
redBright: f("\x1B[91m", "\x1B[39m"),
|
|
169
|
+
greenBright: f("\x1B[92m", "\x1B[39m"),
|
|
170
|
+
yellowBright: f("\x1B[93m", "\x1B[39m"),
|
|
171
|
+
blueBright: f("\x1B[94m", "\x1B[39m"),
|
|
172
|
+
magentaBright: f("\x1B[95m", "\x1B[39m"),
|
|
173
|
+
cyanBright: f("\x1B[96m", "\x1B[39m"),
|
|
174
|
+
whiteBright: f("\x1B[97m", "\x1B[39m"),
|
|
175
|
+
bgBlackBright: f("\x1B[100m", "\x1B[49m"),
|
|
176
|
+
bgRedBright: f("\x1B[101m", "\x1B[49m"),
|
|
177
|
+
bgGreenBright: f("\x1B[102m", "\x1B[49m"),
|
|
178
|
+
bgYellowBright: f("\x1B[103m", "\x1B[49m"),
|
|
179
|
+
bgBlueBright: f("\x1B[104m", "\x1B[49m"),
|
|
180
|
+
bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
|
|
181
|
+
bgCyanBright: f("\x1B[106m", "\x1B[49m"),
|
|
182
|
+
bgWhiteBright: f("\x1B[107m", "\x1B[49m")
|
|
183
|
+
};
|
|
184
|
+
};
|
|
185
|
+
module.exports = createColors();
|
|
186
|
+
module.exports.createColors = createColors;
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
|
|
117
190
|
// src/SSRServer.ts
|
|
118
191
|
var import_fastify_plugin = __toESM(require_plugin(), 1);
|
|
119
|
-
|
|
120
|
-
import
|
|
121
|
-
import
|
|
192
|
+
var import_picocolors = __toESM(require_picocolors(), 1);
|
|
193
|
+
import { readFile } from "fs/promises";
|
|
194
|
+
import path2 from "path";
|
|
122
195
|
|
|
123
196
|
// src/constants.ts
|
|
124
197
|
var RENDERTYPE = {
|
|
@@ -136,9 +209,9 @@ var TEMPLATE = {
|
|
|
136
209
|
};
|
|
137
210
|
|
|
138
211
|
// src/utils/Utils.ts
|
|
139
|
-
import { dirname, join } from "
|
|
140
|
-
import "
|
|
141
|
-
import { fileURLToPath } from "
|
|
212
|
+
import { dirname, join } from "path";
|
|
213
|
+
import "path";
|
|
214
|
+
import { fileURLToPath } from "url";
|
|
142
215
|
import { match } from "path-to-regexp";
|
|
143
216
|
var isDevelopment = process.env.NODE_ENV === "development";
|
|
144
217
|
var __filename = fileURLToPath(import.meta.url);
|
|
@@ -341,7 +414,6 @@ var SSRServer = (0, import_fastify_plugin.default)(
|
|
|
341
414
|
}
|
|
342
415
|
}
|
|
343
416
|
let viteDevServer;
|
|
344
|
-
let viteRuntime;
|
|
345
417
|
await app.register(import("@fastify/static"), {
|
|
346
418
|
index: false,
|
|
347
419
|
prefix: "/",
|
|
@@ -365,10 +437,10 @@ var SSRServer = (0, import_fastify_plugin.default)(
|
|
|
365
437
|
{
|
|
366
438
|
name: "taujs-development-server-debug-logging",
|
|
367
439
|
configureServer(server) {
|
|
368
|
-
console.log("\u03C4js development server debug started.");
|
|
440
|
+
console.log(import_picocolors.default.green("\u03C4js development server debug started."));
|
|
369
441
|
server.middlewares.use((req, res, next) => {
|
|
370
|
-
console.log(
|
|
371
|
-
res.on("finish", () => console.log(
|
|
442
|
+
console.log(import_picocolors.default.cyan(`\u2190 rx: ${req.url}`));
|
|
443
|
+
res.on("finish", () => console.log(import_picocolors.default.yellow(`\u2192 tx: ${req.url}`)));
|
|
372
444
|
next();
|
|
373
445
|
});
|
|
374
446
|
}
|
|
@@ -391,7 +463,6 @@ var SSRServer = (0, import_fastify_plugin.default)(
|
|
|
391
463
|
}
|
|
392
464
|
}
|
|
393
465
|
});
|
|
394
|
-
viteRuntime = await createViteRuntime(viteDevServer);
|
|
395
466
|
overrideCSSHMRConsoleError();
|
|
396
467
|
app.addHook("onRequest", async (request, reply) => {
|
|
397
468
|
await new Promise((resolve) => {
|
|
@@ -426,7 +497,7 @@ var SSRServer = (0, import_fastify_plugin.default)(
|
|
|
426
497
|
template = template.replace(/<script type="module" src="\/@vite\/client"><\/script>/g, "");
|
|
427
498
|
template = template.replace(/<style type="text\/css">[\s\S]*?<\/style>/g, "");
|
|
428
499
|
const entryServerPath = path2.join(clientRoot, `${entryServer}.tsx`);
|
|
429
|
-
const executedModule = await
|
|
500
|
+
const executedModule = await viteDevServer.ssrLoadModule(entryServerPath);
|
|
430
501
|
renderModule = executedModule;
|
|
431
502
|
const styles = await collectStyle(viteDevServer, [entryServerPath]);
|
|
432
503
|
template = template?.replace("</head>", `<style type="text/css">${styles}</style></head>`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@taujs/server",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"description": "taujs | τjs",
|
|
5
5
|
"author": "Aoede <taujs@aoede.uk.net> (https://www.aoede.uk.net)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"@types/react": "^19.0.2",
|
|
53
53
|
"@types/react-dom": "^19.0.2",
|
|
54
54
|
"@vitest/coverage-v8": "^2.1.0",
|
|
55
|
-
"fastify": "^5.
|
|
55
|
+
"fastify": "^5.3.3",
|
|
56
56
|
"jsdom": "^25.0.0",
|
|
57
57
|
"prettier": "^3.3.3",
|
|
58
58
|
"react-dom": "^19.0.0",
|
|
@@ -62,11 +62,11 @@
|
|
|
62
62
|
"vitest": "^2.0.5"
|
|
63
63
|
},
|
|
64
64
|
"peerDependencies": {
|
|
65
|
-
"fastify": "^5.
|
|
65
|
+
"fastify": "^5.3.3",
|
|
66
66
|
"react": "^19.0.0",
|
|
67
67
|
"react-dom": "^19.0.0",
|
|
68
68
|
"typescript": "^5.5.4",
|
|
69
|
-
"vite": "^
|
|
69
|
+
"vite": "^6.2.5"
|
|
70
70
|
},
|
|
71
71
|
"scripts": {
|
|
72
72
|
"build": "tsup",
|