Comparing version 1.0.0-beta.1 to 1.0.0-beta.2
# FastBoot Changelog | ||
### 1.0.0-beta.2 | ||
* Adds support for the "shoebox"‑a place to put data that should be | ||
shared from the server-rendered app to the browser-rendered version. | ||
### 1.0.0-beta.1 | ||
@@ -4,0 +9,0 @@ |
@@ -58,2 +58,3 @@ 'use strict'; | ||
* @param {Boolean} [options.resilient] whether to reject the returned promise if there is an error during rendering. Overrides the instance's `resilient` setting | ||
* @param {string} [options.html] the HTML document to insert the rendered app into. Uses the built app's index.html by default. | ||
* @returns {Promise<Result>} result | ||
@@ -60,0 +61,0 @@ */ |
@@ -5,2 +5,3 @@ 'use strict'; | ||
const path = require('path'); | ||
const RSVP = require('rsvp'); | ||
@@ -192,2 +193,3 @@ const najax = require('najax'); | ||
* @param {Object} options | ||
* @param {string} [options.html] the HTML document to insert the rendered app into | ||
* @param {ClientRequest} | ||
@@ -223,2 +225,3 @@ * @returns {Promise<Result>} result | ||
.then(() => waitForApp(instance)) | ||
.then(() => createShoebox(doc, fastbootInfo)) | ||
.catch(error => result.error = error) | ||
@@ -293,2 +296,30 @@ .then(() => result._finalize()) | ||
/* | ||
* Writes the shoebox into the DOM for the browser rendered app to consume. | ||
* Uses a script tag with custom type so that the browser will treat as plain | ||
* text, and not expend effort trying to parse contents of the script tag. | ||
* Each key is written separately so that the browser rendered app can | ||
* parse the specific item at the time it is needed instead of everything | ||
* all at once. | ||
*/ | ||
function createShoebox(doc, fastbootInfo) { | ||
let shoebox = fastbootInfo.shoebox; | ||
if (!shoebox) { return RSVP.resolve(); } | ||
for (let key in shoebox) { | ||
if (!shoebox.hasOwnProperty(key)) { continue; } | ||
let value = shoebox[key]; | ||
let scriptText = doc.createTextNode(JSON.stringify(value)); | ||
let scriptEl = doc.createElement('script'); | ||
scriptEl.setAttribute('type', 'fastboot/shoebox'); | ||
scriptEl.setAttribute('id', `shoebox-${key}`); | ||
scriptEl.appendChild(scriptText); | ||
doc.body.appendChild(scriptEl); | ||
} | ||
return RSVP.resolve(); | ||
} | ||
/* | ||
* Builds a new FastBootInfo instance with the request and response and injects | ||
@@ -295,0 +326,0 @@ * it into the application instance. |
{ | ||
"name": "fastboot", | ||
"version": "1.0.0-beta.1", | ||
"version": "1.0.0-beta.2", | ||
"description": "Library for rendering Ember apps in node.js", | ||
"scripts": { | ||
"test": "mocha" | ||
"test": "mocha", | ||
"preversion": "npm test", | ||
"postversion": "git push origin master --tags" | ||
}, | ||
@@ -8,0 +10,0 @@ "repository": { |
# FastBoot | ||
[![Build Status](https://travis-ci.org/ember-fastboot/ember-fastboot-server.svg?branch=master)](https://travis-ci.org/ember-fastboot/ember-fastboot-server) | ||
[![Build Status](https://travis-ci.org/ember-fastboot/fastboot.svg?branch=master)](https://travis-ci.org/ember-fastboot/ember-fastboot-server) | ||
@@ -5,0 +5,0 @@ FastBoot is a library for rendering Ember.js applications in Node.js. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28717496
71
496978
10