Releases: donejs/done-ssr
v1.3.2
1.3.1
1.3.0
done-ssr 1.3.0 is a major milestone in this project. It represents a refactor of almost the entire codebase while remaining API compatible. The refactor was to enable the new, lower-level, zones API as described before.
Zones API
The new Zones API exposes plugins that can be used with can-zone to handle rendering in a more customizable way. For example, there are 2 DOM implementations to choose from; can-simple-dom (the default used by done-ssr) and can-zone-jsdom.
A few of the zones included are:
- requests: a Zone that handles rerouting APIs to the local server;
/api/todos
becomeshttp://10.0.0.1:8080/api/todos
. - cookies: Handles copying over cookies from an HTTP Request into the local DOM's
document.cookies
string. - push-images: A Zone that will estable a PUSH Promise when on an HTTP/2 server.
Using the Zones API allows you to do server-rendering in your own HTTP handlers; without using done-ssr to take over a request. An example usage is:
var Zone = require("can-zone");
var requests = require("done-ssr/zones/requests");
var dom = require("can-zone-jsdom")
var pushFetch = require("done-ssr/zones/push-fetch");
var pushImages = require("done-ssr/zones/push-images");
var app = require("./app");
require("spdy").createServer(options, async function(request, response){
var zone = new Zone([
// Overrides XHR, fetch
requests(request),
// Sets up a DOM
dom(request),
pushFetch(response),
pushImages(response)
]);
let {html} = await zone.run(app);
// The full HTML after all async tasks are complete
response.end(html);
});
v1.2.0-beta.12
This is the final beta release for the new Zones API of done-ssr.
1.2.0-beta.1
This is the second beta version of done-ssr 1.2.0.
Pull Requests
1.2.0-beta.0
This is a beta release of 1.2.0, which introduces SSR Zones as a public API in done-ssr. It's unknown whether these zones will remain in done-ssr for 1.2.0 or if they are going to be moved to their own repositories, hence why this is a beta release.
For normal done-ssr users nothing has changed, and there's probably no reason to use the beta release. But for those who want a little more control, you can use the new Zones API. You can read about the API here.
This is a typical example of usage:
var Zone = require("can-zone");
var requests = require("done-ssr/zones/requests");
var dom = require("done-ssr/zones/can-simple-dom");
var pushFetch = require("done-ssr/zones/push-fetch");
var pushImages = require("done-ssr/zones/push-images");
var app = require("./app");
require("spdy").createServer(options, function(request, response){
var zone = new Zone([
// Overrides XHR, fetch
requests(request),
// Sets up a DOM
dom(request),
pushFetch(response),
pushImages(response)
]);
zone.run(app).then(function(data){
// The full HTML after all async tasks are complete
response.end(data.html);
});
});
Where app.js
looks like:
module.exports = function(){
// can-zone-jsdom provides a global `document`
var main = document.createElement("main");
var ul = document.createElement("ul");
main.appendChild(ul);
// This will be PUSHed
var img = document.createElement("img");
img.src = "/images/cat.png";
main.appendChild(img);
// This will be PUSHed
fetch("/api/todos").then(res => res.json()).then(todos => {
todos.forEach(todo => {
var li = document.createElement("li");
li.textContent = todo;
ul.appendChild(li);
});
});
};
1.1.5
1.1.4
1.1.3
This is a patch release, fixing an issue with a FOUC upon the first page load when using the incremental rendering strategy.