@taujs/server 0.0.3 → 0.0.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.
Files changed (2) hide show
  1. package/README.md +18 -33
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -90,11 +90,10 @@ Extended pipe object with callbacks to @taujs/server enabling additional manipul
90
90
 
91
91
  ```
92
92
  import { ServerResponse } from 'node:http';
93
- import { Writable } from 'node:stream';
94
93
 
95
94
  import React from 'react';
96
- import { renderToPipeableStream } from 'react-dom/server';
97
95
  import { createSSRStore, SSRStoreProvider } from '@taujs/server/data-store';
96
+ import { createStreamRenderer } from '@taujs/server/render';
98
97
 
99
98
  import AppBootstrap from '@client/AppBootstrap';
100
99
 
@@ -108,38 +107,24 @@ export const streamRender = (
108
107
  ) => {
109
108
  const store = createSSRStore(initialDataPromise);
110
109
 
111
- const { pipe } = renderToPipeableStream(
112
- <SSRStoreProvider store={store}>
113
- <AppBootstrap />
114
- </SSRStoreProvider>,
115
- {
116
- bootstrapModules: [bootstrapModules],
117
- onShellReady() {
118
- const headContent = `
119
- <meta name="description" content="taujs [ τjs ]">
120
- <link rel="icon" type="image/svg+xml" href="/taujs.svg" />
121
- <title>taujs [ τjs ]</title>
122
- `;
123
- onHead(headContent);
124
-
125
- pipe(
126
- new Writable({
127
- write(chunk, _encoding, callback) {
128
- serverResponse.write(chunk, callback);
129
- },
130
- final(callback) {
131
- onFinish(store.getSnapshot());
132
- callback();
133
- },
134
- }),
135
- );
136
- },
137
-
138
- onAllReady() {},
110
+ const headContent = `
111
+ <meta name="description" content="taujs [ τjs ]">
112
+ <link rel="icon" type="image/svg+xml" href="/taujs.svg" />
113
+ <title>taujs [ τjs ]</title>
114
+ `;
139
115
 
140
- onError(error) {
141
- onError(error);
142
- },
116
+ createStreamRenderer(
117
+ serverResponse,
118
+ { onHead, onFinish, onError },
119
+ {
120
+ appElement: (
121
+ <SSRStoreProvider store={store}>
122
+ <AppBootstrap />
123
+ </SSRStoreProvider>
124
+ ),
125
+ bootstrapModules,
126
+ getStoreSnapshot: store.getSnapshot,
127
+ headContent,
143
128
  },
144
129
  );
145
130
  };
package/package.json CHANGED
@@ -20,7 +20,7 @@
20
20
  "type": "git",
21
21
  "url": "git+https://github.com/aoede3/taujs-server.git"
22
22
  },
23
- "version": "0.0.3",
23
+ "version": "0.0.4",
24
24
  "exports": {
25
25
  ".": {
26
26
  "import": "./dist/SSRServer.js",