Comparing version 0.8.1 to 0.9.0
@@ -60,3 +60,5 @@ 'use strict'; | ||
// 合并 tpl 流 和 bigpipe 流。 | ||
.pipe(combine(prototols)) | ||
.pipe(combine(prototols, { | ||
customFilter: res.customFilter | ||
})) | ||
// 设置默认content-type | ||
@@ -63,0 +65,0 @@ .on('data', function () { |
var Transform = require('stream').Transform; | ||
module.exports = function (layer) { | ||
module.exports = function (layer, settings) { | ||
var stream = new Transform(); | ||
@@ -15,3 +15,14 @@ var bigpipe = layer.bigpipe; | ||
stream._transform = function (chunk, encoding, done) { | ||
var output = isQuicklingMode ? '' : layer.filter(chunk.toString()); | ||
var output; | ||
if (isQuicklingMode){ | ||
output = ''; | ||
} else { | ||
if (settings.customFilter) { | ||
output = settings.customFilter(chunk.toString(), layer.getDepsInfo()); | ||
} else { | ||
output = layer.filter(chunk.toString()); | ||
} | ||
} | ||
var idx = identify ? output.indexOf(identify) : -1; | ||
@@ -34,3 +45,3 @@ var clouser = ''; | ||
// chain error. | ||
.on('error', stream.emit.bind(stream, 'error')) | ||
.on('error', stream.emit.bind(stream, 'error')) | ||
@@ -37,0 +48,0 @@ .on('data', function (chunk) { |
@@ -499,2 +499,20 @@ var path = require('path'); | ||
getDepsInfo: function () { | ||
this.preparePageResource(); | ||
var resourceMap = this.getResourceMap(); | ||
var embedJs = this.getScripts(); | ||
var jsDeps = jsList; | ||
var embedCss = this.getStyles(); | ||
var cssDeps = cssList; | ||
var framework = framework; | ||
return { | ||
resourceMap: resourceMap, | ||
embedJs: embedJs, | ||
jsDeps: jsDeps, | ||
embedCss: embedCss, | ||
cssDeps: cssDeps, | ||
framework: framework | ||
} | ||
}, | ||
filter: function (content) { | ||
@@ -501,0 +519,0 @@ content = this.filterJs(content); |
{ | ||
"name": "yog-view", | ||
"version": "0.8.1", | ||
"version": "0.9.0", | ||
"description": "An express.js middleware for optimizing the order of js\\css output, and enabling render template in bigpipe mode.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
26054
668