Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 0 additions & 29 deletions SSRtest/LRUCache.js

This file was deleted.

42 changes: 36 additions & 6 deletions SSRtest/developmentBuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -2750,18 +2750,28 @@ function createCacheStream(cache, streamingStart) {
var tagEnd = void 0;

do {
if (!tagStart) tagStart = streamingStart[component];else tagStart = html[tagEnd] === '<' ? tagEnd : html.indexOf('<', tagEnd);
if (!tagStart) {
tagStart = streamingStart[component];
} else {
tagStart = html[tagEnd] === '<' ? tagEnd : html.indexOf('<', tagEnd);
}
tagEnd = html.indexOf('>', tagStart) + 1;
// Skip stack logic for void/self-closing elements and HTML comments
if (html[tagEnd - 2] !== '/' && html[tagStart + 1] !== '!') {
// Push opening tags onto stack; pop closing tags off of stack
if (html[tagStart + 1] !== '/') tagStack.push(html.slice(tagStart, tagEnd));else tagStack.pop();
if (html[tagStart + 1] !== '/') {
tagStack.push(html.slice(tagStart, tagEnd));
} else {
tagStack.pop();
}
}
} while (tagStack.length !== 0);
// cache component by slicing 'html'
if (memLife) {
cache.set(component, html.slice(streamingStart[component], tagEnd), memLife, function (err) {
if (err) console.log(err);
if (err) {
console.log(err);
}
});
} else {
cache.set(component, html.slice(streamingStart[component], tagEnd));
Expand All @@ -2782,7 +2792,7 @@ function originalRenderToNodeStream(element, cache, streamingStart) {
return new ReactMarkupReadableStream(element, false, cache, streamingStart, memLife);
}

function renderToNodeStream(compo, cache, res) {
function renderToNodeStream(element, cache, res) {

var htmlStart = '<html><head><title>Page</title></head><body><div id="react-root">';

Expand All @@ -2796,7 +2806,7 @@ function renderToNodeStream(compo, cache, res) {
cacheStream.pipe(res);
cacheStream.write(htmlStart);

var stream$$1 = originalRenderToNodeStream(compo, cache, streamingStart);
var stream$$1 = originalRenderToNodeStream(element, cache, streamingStart);
stream$$1.pipe(cacheStream, { end: false });
stream$$1.on("end", function () {
cacheStream.end(htmlEnd);
Expand All @@ -2808,12 +2818,32 @@ function renderToNodeStream(compo, cache, res) {
* such as data-react-id that React uses internally.
* See https://reactjs.org/docs/react-dom-stream.html#rendertostaticnodestream
*/
function renderToStaticNodeStream(element, cache, streamingStart) {
function originalRenderToStaticNodeStream(element, cache, streamingStart) {
var memLife = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;

return new ReactMarkupReadableStream(element, true, cache, streamingStart, memLife);
}

function renderToStaticNodeStream(element, cache, res) {
var htmlStart = '<html><head><title>Page</title></head><body><div id="react-root">';

var htmlEnd = '</div></body></html>';

var streamingStart = {
sliceStartCount: htmlStart.length
};

var cacheStream = createCacheStream(cache, streamingStart);
cacheStream.pipe(res);
cacheStream.write(htmlStart);

var stream$$1 = originalRenderToStaticNodeStream(element, cache, streamingStart);
stream$$1.pipe(cacheStream, { end: false });
stream$$1.on("end", function () {
cacheStream.end(htmlEnd);
});
}

function createCommonjsModule(fn, module) {
return module = { exports: {} }, fn(module, module.exports), module.exports;
}
Expand Down
42 changes: 36 additions & 6 deletions SSRtest/productionBuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -1646,18 +1646,28 @@ function createCacheStream(cache, streamingStart) {
var tagEnd = void 0;

do {
if (!tagStart) tagStart = streamingStart[component];else tagStart = html[tagEnd] === '<' ? tagEnd : html.indexOf('<', tagEnd);
if (!tagStart) {
tagStart = streamingStart[component];
} else {
tagStart = html[tagEnd] === '<' ? tagEnd : html.indexOf('<', tagEnd);
}
tagEnd = html.indexOf('>', tagStart) + 1;
// Skip stack logic for void/self-closing elements and HTML comments
if (html[tagEnd - 2] !== '/' && html[tagStart + 1] !== '!') {
// Push opening tags onto stack; pop closing tags off of stack
if (html[tagStart + 1] !== '/') tagStack.push(html.slice(tagStart, tagEnd));else tagStack.pop();
if (html[tagStart + 1] !== '/') {
tagStack.push(html.slice(tagStart, tagEnd));
} else {
tagStack.pop();
}
}
} while (tagStack.length !== 0);
// cache component by slicing 'html'
if (memLife) {
cache.set(component, html.slice(streamingStart[component], tagEnd), memLife, function (err) {
if (err) console.log(err);
if (err) {
console.log(err);
}
});
} else {
cache.set(component, html.slice(streamingStart[component], tagEnd));
Expand All @@ -1678,7 +1688,7 @@ function originalRenderToNodeStream(element, cache, streamingStart) {
return new ReactMarkupReadableStream(element, false, cache, streamingStart, memLife);
}

function renderToNodeStream(compo, cache, res) {
function renderToNodeStream(element, cache, res) {

var htmlStart = '<html><head><title>Page</title></head><body><div id="react-root">';

Expand All @@ -1692,7 +1702,7 @@ function renderToNodeStream(compo, cache, res) {
cacheStream.pipe(res);
cacheStream.write(htmlStart);

var stream$$1 = originalRenderToNodeStream(compo, cache, streamingStart);
var stream$$1 = originalRenderToNodeStream(element, cache, streamingStart);
stream$$1.pipe(cacheStream, { end: false });
stream$$1.on("end", function () {
cacheStream.end(htmlEnd);
Expand All @@ -1704,12 +1714,32 @@ function renderToNodeStream(compo, cache, res) {
* such as data-react-id that React uses internally.
* See https://reactjs.org/docs/react-dom-stream.html#rendertostaticnodestream
*/
function renderToStaticNodeStream(element, cache, streamingStart) {
function originalRenderToStaticNodeStream(element, cache, streamingStart) {
var memLife = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;

return new ReactMarkupReadableStream(element, true, cache, streamingStart, memLife);
}

function renderToStaticNodeStream(element, cache, res) {
var htmlStart = '<html><head><title>Page</title></head><body><div id="react-root">';

var htmlEnd = '</div></body></html>';

var streamingStart = {
sliceStartCount: htmlStart.length
};

var cacheStream = createCacheStream(cache, streamingStart);
cacheStream.pipe(res);
cacheStream.write(htmlStart);

var stream$$1 = originalRenderToStaticNodeStream(element, cache, streamingStart);
stream$$1.pipe(cacheStream, { end: false });
stream$$1.on("end", function () {
cacheStream.end(htmlEnd);
});
}

function createCommonjsModule(fn, module) {
return module = { exports: {} }, fn(module, module.exports), module.exports;
}
Expand Down
10 changes: 2 additions & 8 deletions SSRtest/src/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,6 @@ export default ({ clientStats }) => async (req, res) => {
// cacheStream.pipe(res);
// cacheStream.write(htmlStart);

// const stream = ReactCC.renderToNodeStream(<App />, cache, streamingStart);
// stream.pipe(cacheStream, { end: false });
// stream.on("end", () => {
// cacheStream.end(htmlEnd);
// });

}
else if (false){
const app = <App />;
Expand All @@ -67,6 +61,6 @@ export default ({ clientStats }) => async (req, res) => {
styles,
cssHash
});
// }
}

};
};
5 changes: 2 additions & 3 deletions SSRtest/src/shared/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ export default class App extends Component {
<div>
<h1>THIS IS AN APP</h1>
<Button />
<BlogPost />
<BlogPost />

<BlogPost />
<BlogPost />
<List />

</div>
Expand Down
Loading