@taujs/server 0.1.0 → 0.1.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.
- package/README.md +2 -2
- package/dist/data.js +12 -10
- package/dist/index.d.ts +2 -2
- package/dist/index.js +7 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
`pnpm add @taujs/server`
|
|
8
8
|
|
|
9
|
-
##
|
|
9
|
+
## CSR; SSR; Streaming SSR; Hydration; Fastify + React 18
|
|
10
10
|
|
|
11
11
|
Fastify Plugin for integration with taujs [ τjs ] template https://github.com/aoede3/taujs
|
|
12
12
|
|
|
@@ -40,7 +40,7 @@ Integrated ViteDevServer HMR + Vite Runtime API run alongside tsx (TS eXecute) p
|
|
|
40
40
|
|
|
41
41
|
https://github.com/aoede3/taujs/blob/main/src/server/index.ts
|
|
42
42
|
|
|
43
|
-
Not utilising taujs [ τjs ] template? Add in your own `alias` object for your own particular setup e.g. `alias: { object }`
|
|
43
|
+
Not utilising taujs [ τjs ] template? Add in your own ts `alias` object for your own particular directory setup e.g. `alias: { object }`
|
|
44
44
|
|
|
45
45
|
### React 'entry-client.tsx'
|
|
46
46
|
|
package/dist/data.js
CHANGED
|
@@ -59,7 +59,7 @@ var useSSRStore = () => {
|
|
|
59
59
|
|
|
60
60
|
// src/SSRHydration.tsx
|
|
61
61
|
import React2 from "react";
|
|
62
|
-
import { hydrateRoot } from "react-dom/client";
|
|
62
|
+
import { createRoot, hydrateRoot } from "react-dom/client";
|
|
63
63
|
|
|
64
64
|
// src/utils/Logger.ts
|
|
65
65
|
var createLogger = (debug) => ({
|
|
@@ -87,18 +87,20 @@ var hydrateApp = ({ appComponent, initialDataKey = "__INITIAL_DATA__", rootEleme
|
|
|
87
87
|
}
|
|
88
88
|
const initialData = window[initialDataKey];
|
|
89
89
|
if (!initialData) {
|
|
90
|
-
warn(`Initial data key "${initialDataKey}" is undefined on window
|
|
90
|
+
warn(`Initial data key "${initialDataKey}" is undefined on window. Defaulting to SPA createRoot`);
|
|
91
|
+
const root = createRoot(rootElement);
|
|
92
|
+
root.render(/* @__PURE__ */ jsx2(React2.StrictMode, { children: appComponent }));
|
|
91
93
|
} else {
|
|
92
94
|
log("Initial data loaded:", initialData);
|
|
95
|
+
const initialDataPromise = Promise.resolve(initialData);
|
|
96
|
+
const store = createSSRStore(initialDataPromise);
|
|
97
|
+
log("Store created:", store);
|
|
98
|
+
hydrateRoot(
|
|
99
|
+
rootElement,
|
|
100
|
+
/* @__PURE__ */ jsx2(React2.StrictMode, { children: /* @__PURE__ */ jsx2(SSRStoreProvider, { store, children: appComponent }) })
|
|
101
|
+
);
|
|
102
|
+
log("Hydration completed");
|
|
93
103
|
}
|
|
94
|
-
const initialDataPromise = Promise.resolve(initialData);
|
|
95
|
-
const store = createSSRStore(initialDataPromise);
|
|
96
|
-
log("Store created:", store);
|
|
97
|
-
hydrateRoot(
|
|
98
|
-
rootElement,
|
|
99
|
-
/* @__PURE__ */ jsx2(React2.StrictMode, { children: /* @__PURE__ */ jsx2(SSRStoreProvider, { store, children: appComponent }) })
|
|
100
|
-
);
|
|
101
|
-
log("Hydration completed");
|
|
102
104
|
};
|
|
103
105
|
if (document.readyState !== "loading") {
|
|
104
106
|
bootstrap();
|
package/dist/index.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ type RenderCallbacks = {
|
|
|
20
20
|
type FetchConfig = {
|
|
21
21
|
url?: string;
|
|
22
22
|
options: RequestInit & {
|
|
23
|
-
params?:
|
|
23
|
+
params?: Record<string, unknown>;
|
|
24
24
|
};
|
|
25
25
|
serviceName?: string;
|
|
26
26
|
serviceMethod?: string;
|
|
@@ -56,7 +56,7 @@ type RenderModule = {
|
|
|
56
56
|
renderStream: RenderStream;
|
|
57
57
|
};
|
|
58
58
|
type RouteAttributes<Params = {}> = {
|
|
59
|
-
fetch
|
|
59
|
+
fetch?: (params?: Params, options?: RequestInit & {
|
|
60
60
|
params?: Record<string, unknown>;
|
|
61
61
|
}) => Promise<{
|
|
62
62
|
options: RequestInit & {
|
package/dist/index.js
CHANGED
|
@@ -295,6 +295,13 @@ var SSRServer = (0, import_fastify_plugin.default)(
|
|
|
295
295
|
const { createServer } = await import("vite");
|
|
296
296
|
viteDevServer = await createServer({
|
|
297
297
|
appType: "custom",
|
|
298
|
+
css: {
|
|
299
|
+
preprocessorOptions: {
|
|
300
|
+
scss: {
|
|
301
|
+
api: "modern-compiler"
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
},
|
|
298
305
|
mode: "development",
|
|
299
306
|
plugins: [
|
|
300
307
|
...isDebug ? [
|