@nguniversal/common
Advanced tools
Comparing version 11.0.1 to 11.1.0-next.0
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('fs'), require('util'), require('@angular/compiler'), require('@angular/core'), require('@angular/platform-server')) : | ||
typeof define === 'function' && define.amd ? define('@nguniversal/common/engine', ['exports', 'fs', 'util', '@angular/compiler', '@angular/core', '@angular/platform-server'], factory) : | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.nguniversal = global.nguniversal || {}, global.nguniversal.common = global.nguniversal.common || {}, global.nguniversal.common.engine = {}), global.fs, global.util, global.ng.compiler, global.ng.core, global.ng.platformServer)); | ||
}(this, (function (exports, fs, util, compiler, core, platformServer) { 'use strict'; | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/compiler'), require('@angular/core'), require('@angular/platform-server'), require('path'), require('fs'), require('util'), require('critters')) : | ||
typeof define === 'function' && define.amd ? define('@nguniversal/common/engine', ['exports', '@angular/compiler', '@angular/core', '@angular/platform-server', 'path', 'fs', 'util', 'critters'], factory) : | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.nguniversal = global.nguniversal || {}, global.nguniversal.common = global.nguniversal.common || {}, global.nguniversal.common.engine = {}), global.ng.compiler, global.ng.core, global.ng.platformServer, global.path, global.fs, global.util, global.critters)); | ||
}(this, (function (exports, compiler, core, platformServer, path, fs, util, Critters) { 'use strict'; | ||
/** | ||
* @license | ||
* Copyright Google LLC All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
*/ | ||
var readFile = util.promisify(fs.readFile); | ||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
/** ResourceLoader implementation for loading files */ | ||
var FileLoader = /** @class */ (function () { | ||
function FileLoader() { | ||
} | ||
FileLoader.prototype.get = function (url) { | ||
return readFile(url, 'utf-8'); | ||
}; | ||
return FileLoader; | ||
}()); | ||
var Critters__default = /*#__PURE__*/_interopDefaultLegacy(Critters); | ||
@@ -328,2 +313,93 @@ /*! ***************************************************************************** | ||
/** | ||
* @license | ||
* Copyright Google LLC All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
*/ | ||
var readFile = util.promisify(fs.readFile); | ||
/** ResourceLoader implementation for loading files */ | ||
var FileLoader = /** @class */ (function () { | ||
function FileLoader() { | ||
} | ||
FileLoader.prototype.get = function (url) { | ||
return readFile(url, 'utf-8'); | ||
}; | ||
return FileLoader; | ||
}()); | ||
var CrittersExtended = /** @class */ (function (_super) { | ||
__extends(CrittersExtended, _super); | ||
function CrittersExtended(optionsExtended, resourceCache) { | ||
var _this = _super.call(this, { | ||
logger: { | ||
warn: function (s) { return _this.warnings.push(s); }, | ||
error: function (s) { return _this.errors.push(s); }, | ||
log: function () { }, | ||
info: function () { }, | ||
}, | ||
path: optionsExtended.outputPath, | ||
publicPath: optionsExtended.deployUrl, | ||
compress: !!optionsExtended.minify, | ||
pruneSource: false, | ||
reduceInlineStyles: false, | ||
mergeStylesheets: false, | ||
preload: 'media', | ||
noscriptFallback: true, | ||
}) || this; | ||
_this.optionsExtended = optionsExtended; | ||
_this.resourceCache = resourceCache; | ||
_this.warnings = []; | ||
_this.errors = []; | ||
return _this; | ||
} | ||
CrittersExtended.prototype.readFile = function (path) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var resourceContent; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
resourceContent = this.resourceCache.get(path); | ||
if (!(resourceContent === undefined)) return [3 /*break*/, 2]; | ||
return [4 /*yield*/, readFile(path, 'utf-8')]; | ||
case 1: | ||
resourceContent = _a.sent(); | ||
this.resourceCache.set(path, resourceContent); | ||
_a.label = 2; | ||
case 2: return [2 /*return*/, resourceContent]; | ||
} | ||
}); | ||
}); | ||
}; | ||
return CrittersExtended; | ||
}(Critters__default['default'])); | ||
var InlineCriticalCssProcessor = /** @class */ (function () { | ||
function InlineCriticalCssProcessor(options) { | ||
this.options = options; | ||
this.resourceCache = new Map(); | ||
} | ||
InlineCriticalCssProcessor.prototype.process = function (html, options) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var critters, content; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
critters = new CrittersExtended(Object.assign(Object.assign({}, this.options), options), this.resourceCache); | ||
return [4 /*yield*/, critters.process(html)]; | ||
case 1: | ||
content = _a.sent(); | ||
return [2 /*return*/, { | ||
content: content, | ||
errors: critters.errors, | ||
warnings: critters.warnings, | ||
}]; | ||
} | ||
}); | ||
}); | ||
}; | ||
return InlineCriticalCssProcessor; | ||
}()); | ||
/** | ||
* A common rendering engine utility. This abstracts the logic | ||
@@ -340,2 +416,5 @@ * for handling the platformServer compiler, the module cache, and | ||
this.templateCache = new Map(); | ||
this.inlineCriticalCssProcessor = new InlineCriticalCssProcessor({ | ||
minify: true, | ||
}); | ||
} | ||
@@ -354,34 +433,48 @@ /** Return an instance of the platformServer compiler */ | ||
CommonEngine.prototype.render = function (opts) { | ||
var _a; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var doc, _a, _b, extraProviders, moduleOrFactory, factory; | ||
var extraProviders, doc, moduleOrFactory, factory, html, _b, content, errors, warnings; | ||
return __generator(this, function (_c) { | ||
switch (_c.label) { | ||
case 0: | ||
_a = opts.document; | ||
if (_a) return [3 /*break*/, 3]; | ||
_b = opts.documentFilePath; | ||
if (!_b) return [3 /*break*/, 2]; | ||
extraProviders = __spread((opts.providers || []), (this.providers || [])); | ||
doc = opts.document; | ||
if (!(!doc && opts.documentFilePath)) return [3 /*break*/, 2]; | ||
return [4 /*yield*/, this.getDocument(opts.documentFilePath)]; | ||
case 1: | ||
_b = (_c.sent()); | ||
doc = _c.sent(); | ||
_c.label = 2; | ||
case 2: | ||
_a = _b; | ||
_c.label = 3; | ||
case 3: | ||
doc = _a; | ||
extraProviders = __spread((opts.providers || []), (this.providers || []), [ | ||
{ | ||
if (doc) { | ||
extraProviders.push({ | ||
provide: platformServer.INITIAL_CONFIG, | ||
useValue: { | ||
document: doc, | ||
document: opts.inlineCriticalCss | ||
// Workaround for https://github.com/GoogleChromeLabs/critters/issues/64 | ||
? doc.replace(/ media=\"print\" onload=\"this\.media='all'"><noscript><link .+?><\/noscript>/g, '>') | ||
: doc, | ||
url: opts.url | ||
} | ||
} | ||
]); | ||
}); | ||
} | ||
moduleOrFactory = this.moduleOrFactory || opts.bootstrap; | ||
return [4 /*yield*/, this.getFactory(moduleOrFactory)]; | ||
case 3: | ||
factory = _c.sent(); | ||
return [4 /*yield*/, platformServer.renderModuleFactory(factory, { extraProviders: extraProviders })]; | ||
case 4: | ||
factory = _c.sent(); | ||
return [2 /*return*/, platformServer.renderModuleFactory(factory, { extraProviders: extraProviders })]; | ||
html = _c.sent(); | ||
if (!opts.inlineCriticalCss) { | ||
return [2 /*return*/, html]; | ||
} | ||
return [4 /*yield*/, this.inlineCriticalCssProcessor.process(html, { | ||
outputPath: (_a = opts.publicPath) !== null && _a !== void 0 ? _a : (opts.documentFilePath ? path.dirname(opts.documentFilePath) : undefined), | ||
})]; | ||
case 5: | ||
_b = _c.sent(), content = _b.content, errors = _b.errors, warnings = _b.warnings; | ||
// tslint:disable-next-line: no-console | ||
warnings.forEach(function (m) { return console.warn(m); }); | ||
// tslint:disable-next-line: no-console | ||
errors.forEach(function (m) { return console.error(m); }); | ||
return [2 /*return*/, content]; | ||
} | ||
@@ -395,4 +488,4 @@ }); | ||
var moduleFactory, factory; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
@@ -409,3 +502,3 @@ if (!(moduleOrFactory instanceof core.NgModuleFactory)) return [3 /*break*/, 1]; | ||
case 2: | ||
factory = _a.sent(); | ||
factory = _b.sent(); | ||
this.factoryCacheMap.set(moduleOrFactory, factory); | ||
@@ -421,4 +514,4 @@ return [2 /*return*/, factory]; | ||
var doc; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
@@ -429,5 +522,5 @@ doc = this.templateCache.get(filePath); | ||
case 1: | ||
doc = _a.sent(); | ||
doc = _b.sent(); | ||
this.templateCache.set(filePath, doc); | ||
_a.label = 2; | ||
_b.label = 2; | ||
case 2: return [2 /*return*/, doc]; | ||
@@ -466,10 +559,2 @@ } | ||
/** | ||
* @license | ||
* Copyright Google LLC All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
*/ | ||
/** | ||
* Generated bundle index. Do not edit. | ||
@@ -480,2 +565,3 @@ */ | ||
exports.ɵFileLoader = FileLoader; | ||
exports.ɵInlineCriticalCssProcessor = InlineCriticalCssProcessor; | ||
@@ -482,0 +568,0 @@ Object.defineProperty(exports, '__esModule', { value: true }); |
@@ -1,2 +0,16 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("fs"),require("util"),require("@angular/compiler"),require("@angular/core"),require("@angular/platform-server")):"function"==typeof define&&define.amd?define("@nguniversal/common/engine",["exports","fs","util","@angular/compiler","@angular/core","@angular/platform-server"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).nguniversal=e.nguniversal||{},e.nguniversal.common=e.nguniversal.common||{},e.nguniversal.common.engine={}),e.fs,e.util,e.ng.compiler,e.ng.core,e.ng.platformServer)}(this,(function(e,t,r,n,o,i){"use strict"; | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/compiler"),require("@angular/core"),require("@angular/platform-server"),require("path"),require("fs"),require("util"),require("critters")):"function"==typeof define&&define.amd?define("@nguniversal/common/engine",["exports","@angular/compiler","@angular/core","@angular/platform-server","path","fs","util","critters"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).nguniversal=e.nguniversal||{},e.nguniversal.common=e.nguniversal.common||{},e.nguniversal.common.engine={}),e.ng.compiler,e.ng.core,e.ng.platformServer,e.path,e.fs,e.util,e.critters)}(this,(function(e,t,r,n,o,i,c,u){"use strict";function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=a(u),l=function(e,t){return(l=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)}; | ||
/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */function f(e,t,r,n){return new(r||(r=Promise))((function(o,i){function c(e){try{a(n.next(e))}catch(e){i(e)}}function u(e){try{a(n.throw(e))}catch(e){i(e)}}function a(e){e.done?o(e.value):function t(e){return e instanceof r?e:new r((function(t){t(e)}))}(e.value).then(c,u)}a((n=n.apply(e,t||[])).next())}))}function p(e,t){var r,n,o,i,c={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function a(i){if(r)throw new TypeError("Generator is already executing.");for(;c;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return c.label++,{value:i[1],done:!1};case 5:c.label++,n=i[1],i=[0];continue;case 7:i=c.ops.pop(),c.trys.pop();continue;default:if(!((o=(o=c.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){c=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){c.label=i[1];break}if(6===i[0]&&c.label<o[1]){c.label=o[1],o=i;break}if(o&&c.label<o[2]){c.label=o[2],c.ops.push(i);break}o[2]&&c.ops.pop(),c.trys.pop();continue}i=t.call(e,c)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}function h(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),c=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)c.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return c} | ||
/** | ||
@@ -8,3 +22,4 @@ * @license | ||
* found in the LICENSE file at https://angular.io/license | ||
*/var a=r.promisify(t.readFile),u=function(){function e(){}return e.prototype.get=function(e){return a(e,"utf-8")},e}();function c(e,t,r,n){return new(r||(r=Promise))((function(o,i){function a(e){try{c(n.next(e))}catch(e){i(e)}}function u(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){e.done?o(e.value):function t(e){return e instanceof r?e:new r((function(t){t(e)}))}(e.value).then(a,u)}c((n=n.apply(e,t||[])).next())}))}function l(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function c(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}function s(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a}var f=function(){function e(e,t){void 0===t&&(t=[]),this.moduleOrFactory=e,this.providers=t,this.factoryCacheMap=new Map,this.templateCache=new Map}return e.prototype.getCompiler=function(){return i.platformDynamicServer().injector.get(o.CompilerFactory).createCompiler([{providers:[{provide:n.ResourceLoader,useClass:u,deps:[]}]}])},e.prototype.render=function(e){return c(this,void 0,void 0,(function(){var t,r,n,o;return l(this,(function(a){switch(a.label){case 0:return(t=e.document)?[3,3]:(r=e.documentFilePath)?[4,this.getDocument(e.documentFilePath)]:[3,2];case 1:r=a.sent(),a.label=2;case 2:t=r,a.label=3;case 3:return n=function u(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(s(arguments[t]));return e}(e.providers||[],this.providers||[],[{provide:i.INITIAL_CONFIG,useValue:{document:t,url:e.url}}]),[4,this.getFactory(this.moduleOrFactory||e.bootstrap)];case 4:return o=a.sent(),[2,i.renderModuleFactory(o,{extraProviders:n})]}}))}))},e.prototype.getFactory=function(e){return c(this,void 0,void 0,(function(){var t,r;return l(this,(function(n){switch(n.label){case 0:return e instanceof o.NgModuleFactory?[2,e]:[3,1];case 1:return(t=this.factoryCacheMap.get(e))?[2,t]:[4,this.getCompiler().compileModuleAsync(e)];case 2:return r=n.sent(),this.factoryCacheMap.set(e,r),[2,r]}}))}))},e.prototype.getDocument=function(e){return c(this,void 0,void 0,(function(){var t;return l(this,(function(r){switch(r.label){case 0:return(t=this.templateCache.get(e))?[3,2]:[4,a(e,"utf-8")];case 1:t=r.sent(),this.templateCache.set(e,t),r.label=2;case 2:return[2,t]}}))}))},e}(); | ||
*/ | ||
var d=c.promisify(i.readFile),y=function(){function e(){}return e.prototype.get=function(e){return d(e,"utf-8")},e}(),v=function(e){function t(t,r){var n=e.call(this,{logger:{warn:function(e){return n.warnings.push(e)},error:function(e){return n.errors.push(e)},log:function(){},info:function(){}},path:t.outputPath,publicPath:t.deployUrl,compress:!!t.minify,pruneSource:!1,reduceInlineStyles:!1,mergeStylesheets:!1,preload:"media",noscriptFallback:!0})||this;return n.optionsExtended=t,n.resourceCache=r,n.warnings=[],n.errors=[],n}return function r(e,t){function r(){this.constructor=e}l(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}(t,e),t.prototype.readFile=function(e){return f(this,void 0,void 0,(function(){var t;return p(this,(function(r){switch(r.label){case 0:return void 0!==(t=this.resourceCache.get(e))?[3,2]:[4,d(e,"utf-8")];case 1:t=r.sent(),this.resourceCache.set(e,t),r.label=2;case 2:return[2,t]}}))}))},t}(s.default),m=function(){function e(e){this.options=e,this.resourceCache=new Map}return e.prototype.process=function(e,t){return f(this,void 0,void 0,(function(){var r;return p(this,(function(n){switch(n.label){case 0:return[4,(r=new v(Object.assign(Object.assign({},this.options),t),this.resourceCache)).process(e)];case 1:return[2,{content:n.sent(),errors:r.errors,warnings:r.warnings}]}}))}))},e}(),g=function(){function e(e,t){void 0===t&&(t=[]),this.moduleOrFactory=e,this.providers=t,this.factoryCacheMap=new Map,this.templateCache=new Map,this.inlineCriticalCssProcessor=new m({minify:!0})}return e.prototype.getCompiler=function(){return n.platformDynamicServer().injector.get(r.CompilerFactory).createCompiler([{providers:[{provide:t.ResourceLoader,useClass:y,deps:[]}]}])},e.prototype.render=function(e){var t;return f(this,void 0,void 0,(function(){var r,i,c,u,a,s,l;return p(this,(function(f){switch(f.label){case 0:return r=function p(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(h(arguments[t]));return e}(e.providers||[],this.providers||[]),(i=e.document)||!e.documentFilePath?[3,2]:[4,this.getDocument(e.documentFilePath)];case 1:i=f.sent(),f.label=2;case 2:return i&&r.push({provide:n.INITIAL_CONFIG,useValue:{document:e.inlineCriticalCss?i.replace(/ media=\"print\" onload=\"this\.media='all'"><noscript><link .+?><\/noscript>/g,">"):i,url:e.url}}),[4,this.getFactory(this.moduleOrFactory||e.bootstrap)];case 3:return c=f.sent(),[4,n.renderModuleFactory(c,{extraProviders:r})];case 4:return u=f.sent(),e.inlineCriticalCss?[4,this.inlineCriticalCssProcessor.process(u,{outputPath:null!==(t=e.publicPath)&&void 0!==t?t:e.documentFilePath?o.dirname(e.documentFilePath):void 0})]:[2,u];case 5:return a=f.sent(),s=a.content,l=a.errors,a.warnings.forEach((function(e){return console.warn(e)})),l.forEach((function(e){return console.error(e)})),[2,s]}}))}))},e.prototype.getFactory=function(e){return f(this,void 0,void 0,(function(){var t,n;return p(this,(function(o){switch(o.label){case 0:return e instanceof r.NgModuleFactory?[2,e]:[3,1];case 1:return(t=this.factoryCacheMap.get(e))?[2,t]:[4,this.getCompiler().compileModuleAsync(e)];case 2:return n=o.sent(),this.factoryCacheMap.set(e,n),[2,n]}}))}))},e.prototype.getDocument=function(e){return f(this,void 0,void 0,(function(){var t;return p(this,(function(r){switch(r.label){case 0:return(t=this.templateCache.get(e))?[3,2]:[4,d(e,"utf-8")];case 1:t=r.sent(),this.templateCache.set(e,t),r.label=2;case 2:return[2,t]}}))}))},e}(); | ||
/** | ||
@@ -31,8 +46,2 @@ * @license | ||
*/ | ||
/** | ||
* @license | ||
* Copyright Google LLC All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
*/e.ɵCommonEngine=f,e.ɵFileLoader=u,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
e.ɵCommonEngine=g,e.ɵFileLoader=y,e.ɵInlineCriticalCssProcessor=m,Object.defineProperty(e,"__esModule",{value:!0})})); |
@@ -8,2 +8,12 @@ | ||
declare interface InlineCriticalCssProcessOptions { | ||
outputPath?: string; | ||
} | ||
declare interface InlineCriticalCssProcessorOptions { | ||
minify?: boolean; | ||
deployUrl?: string; | ||
} | ||
/** | ||
@@ -21,2 +31,3 @@ * A common rendering engine utility. This abstracts the logic | ||
private templateCache; | ||
private inlineCriticalCssProcessor; | ||
constructor(moduleOrFactory?: Type<{}> | NgModuleFactory<{}> | undefined, providers?: StaticProvider[]); | ||
@@ -39,2 +50,13 @@ /** | ||
export declare class ɵInlineCriticalCssProcessor { | ||
protected readonly options: InlineCriticalCssProcessorOptions; | ||
private readonly resourceCache; | ||
constructor(options: InlineCriticalCssProcessorOptions); | ||
process(html: string, options: InlineCriticalCssProcessOptions): Promise<{ | ||
content: string; | ||
warnings: string[]; | ||
errors: string[]; | ||
}>; | ||
} | ||
/** These are the allowed options for the render */ | ||
@@ -47,4 +69,14 @@ export declare interface ɵRenderOptions { | ||
documentFilePath?: string; | ||
/** | ||
* Reduce render blocking requests by inlining critical CSS. | ||
* Defaults to false. | ||
*/ | ||
inlineCriticalCss?: boolean; | ||
/** | ||
* Base path location of index file. | ||
* Defaults to the 'documentFilePath' dirname when not provided. | ||
*/ | ||
publicPath?: string; | ||
} | ||
export { } |
@@ -1,1 +0,1 @@ | ||
{"__symbolic":"module","version":4,"metadata":{"ɵFileLoader":{"__symbolic":"class","members":{"get":[{"__symbolic":"method"}]}},"ɵCommonEngine":{"__symbolic":"class","members":{"getCompiler":[{"__symbolic":"method"}],"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"Type","module":"@angular/core","arguments":[{"__symbolic":"error","message":"Expression form not supported","line":42,"character":45,"module":"./engine"}]},{"__symbolic":"reference","name":"Array","arguments":[{"__symbolic":"reference","module":"@angular/core","name":"StaticProvider","line":43,"character":33}]}]}],"render":[{"__symbolic":"method"}],"getFactory":[{"__symbolic":"method"}],"getDocument":[{"__symbolic":"method"}]}},"ɵRenderOptions":{"__symbolic":"interface"}},"origins":{"ɵFileLoader":"./engine","ɵCommonEngine":"./engine","ɵRenderOptions":"./engine"},"importAs":"@nguniversal/common/engine"} | ||
{"__symbolic":"module","version":4,"metadata":{"ɵCommonEngine":{"__symbolic":"class","members":{"getCompiler":[{"__symbolic":"method"}],"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"Type","module":"@angular/core","arguments":[{"__symbolic":"error","message":"Expression form not supported","line":55,"character":45,"module":"./engine"}]},{"__symbolic":"reference","name":"Array","arguments":[{"__symbolic":"reference","module":"@angular/core","name":"StaticProvider","line":56,"character":33}]}]}],"render":[{"__symbolic":"method"}],"getFactory":[{"__symbolic":"method"}],"getDocument":[{"__symbolic":"method"}]}},"ɵRenderOptions":{"__symbolic":"interface"},"ɵFileLoader":{"__symbolic":"class","members":{"get":[{"__symbolic":"method"}]}},"ɵInlineCriticalCssProcessor":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"any"}]}],"process":[{"__symbolic":"method"}]}}},"origins":{"ɵCommonEngine":"./engine","ɵRenderOptions":"./engine","ɵFileLoader":"./engine","ɵInlineCriticalCssProcessor":"./engine"},"importAs":"@nguniversal/common/engine"} |
@@ -8,3 +8,5 @@ /** | ||
*/ | ||
export { FileLoader as ɵFileLoader, CommonEngine as ɵCommonEngine, } from './src/index'; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJpdmF0ZV9hcGkuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi9tb2R1bGVzL2NvbW1vbi9lbmdpbmUvcHJpdmF0ZV9hcGkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7OztHQU1HO0FBRUgsT0FBTyxFQUNMLFVBQVUsSUFBSSxXQUFXLEVBQ3pCLFlBQVksSUFBSSxhQUFhLEdBRTlCLE1BQU0sYUFBYSxDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiLyoqXG4gKiBAbGljZW5zZVxuICogQ29weXJpZ2h0IEdvb2dsZSBMTEMgQWxsIFJpZ2h0cyBSZXNlcnZlZC5cbiAqXG4gKiBVc2Ugb2YgdGhpcyBzb3VyY2UgY29kZSBpcyBnb3Zlcm5lZCBieSBhbiBNSVQtc3R5bGUgbGljZW5zZSB0aGF0IGNhbiBiZVxuICogZm91bmQgaW4gdGhlIExJQ0VOU0UgZmlsZSBhdCBodHRwczovL2FuZ3VsYXIuaW8vbGljZW5zZVxuICovXG5cbmV4cG9ydCB7XG4gIEZpbGVMb2FkZXIgYXMgybVGaWxlTG9hZGVyLFxuICBDb21tb25FbmdpbmUgYXMgybVDb21tb25FbmdpbmUsXG4gIFJlbmRlck9wdGlvbnMgYXMgybVSZW5kZXJPcHRpb25zLFxufSBmcm9tICcuL3NyYy9pbmRleCc7XG4iXX0= | ||
export { CommonEngine as ɵCommonEngine, } from './src/engine'; | ||
export { FileLoader as ɵFileLoader, } from './src/file-loader'; | ||
export { InlineCriticalCssProcessor as ɵInlineCriticalCssProcessor, } from './src/inline-css-processor'; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJpdmF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NzLXByb2Nlc3Nvcic7XG4iXX0= |
@@ -12,3 +12,5 @@ import { __awaiter } from "tslib"; | ||
import { INITIAL_CONFIG, platformDynamicServer, renderModuleFactory } from '@angular/platform-server'; | ||
import { dirname } from 'path'; | ||
import { FileLoader } from './file-loader'; | ||
import { InlineCriticalCssProcessor } from './inline-css-processor'; | ||
import { readFile } from './utils'; | ||
@@ -26,2 +28,5 @@ /** | ||
this.templateCache = new Map(); | ||
this.inlineCriticalCssProcessor = new InlineCriticalCssProcessor({ | ||
minify: true, | ||
}); | ||
} | ||
@@ -40,19 +45,39 @@ /** Return an instance of the platformServer compiler */ | ||
render(opts) { | ||
var _a; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
// if opts.document dosen't exist then opts.documentFilePath must | ||
const doc = opts.document || opts.documentFilePath && (yield this.getDocument(opts.documentFilePath)); | ||
const extraProviders = [ | ||
...(opts.providers || []), | ||
...(this.providers || []), | ||
{ | ||
]; | ||
let doc = opts.document; | ||
if (!doc && opts.documentFilePath) { | ||
doc = yield this.getDocument(opts.documentFilePath); | ||
} | ||
if (doc) { | ||
extraProviders.push({ | ||
provide: INITIAL_CONFIG, | ||
useValue: { | ||
document: doc, | ||
document: opts.inlineCriticalCss | ||
// Workaround for https://github.com/GoogleChromeLabs/critters/issues/64 | ||
? doc.replace(/ media=\"print\" onload=\"this\.media='all'"><noscript><link .+?><\/noscript>/g, '>') | ||
: doc, | ||
url: opts.url | ||
} | ||
} | ||
]; | ||
}); | ||
} | ||
const moduleOrFactory = this.moduleOrFactory || opts.bootstrap; | ||
const factory = yield this.getFactory(moduleOrFactory); | ||
return renderModuleFactory(factory, { extraProviders }); | ||
const html = yield renderModuleFactory(factory, { extraProviders }); | ||
if (!opts.inlineCriticalCss) { | ||
return html; | ||
} | ||
const { content, errors, warnings } = yield this.inlineCriticalCssProcessor.process(html, { | ||
outputPath: (_a = opts.publicPath) !== null && _a !== void 0 ? _a : (opts.documentFilePath ? dirname(opts.documentFilePath) : undefined), | ||
}); | ||
// tslint:disable-next-line: no-console | ||
warnings.forEach(m => console.warn(m)); | ||
// tslint:disable-next-line: no-console | ||
errors.forEach(m => console.error(m)); | ||
return content; | ||
}); | ||
@@ -93,2 +118,2 @@ } | ||
} | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZW5naW5lLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vLi4vbW9kdWxlcy9jb21tb24vZW5naW5lL3NyYy9lbmdpbmUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBOzs7Ozs7R0FNRztBQUNILE9BQU8sRUFBRSxjQUFjLEVBQUUsTUFBTSxtQkFBbUIsQ0FBQztBQUNuRCxPQUFPLEVBQVksZUFBZSxFQUFFLGVBQWUsRUFBd0IsTUFBTSxlQUFlLENBQUM7QUFDakcsT0FBTyxFQUFFLGNBQWMsRUFBRSxxQkFBcUIsRUFBRSxtQkFBbUIsRUFBRSxNQUFNLDBCQUEwQixDQUFDO0FBRXRHLE9BQU8sRUFBRSxVQUFVLEVBQUUsTUFBTSxlQUFlLENBQUM7QUFDM0MsT0FBTyxFQUFFLFFBQVEsRUFBRSxNQUFNLFNBQVMsQ0FBQztBQVduQzs7OztHQUlHO0FBQ0gsTUFBTSxPQUFPLFlBQVk7SUFjdkIsWUFBb0IsZUFBZ0QsRUFDaEQsWUFBOEIsRUFBRTtRQURoQyxvQkFBZSxHQUFmLGVBQWUsQ0FBaUM7UUFDaEQsY0FBUyxHQUFULFNBQVMsQ0FBdUI7UUFKNUMsb0JBQWUsR0FBRyxJQUFJLEdBQUcsRUFBaUMsQ0FBQztRQUMzRCxrQkFBYSxHQUFHLElBQUksR0FBRyxFQUFrQixDQUFDO0lBR0ssQ0FBQztJQWJ4RCx3REFBd0Q7SUFDeEQsV0FBVztRQUNULE1BQU0sZUFBZSxHQUFvQixxQkFBcUIsRUFBRSxDQUFDLFF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CByZWFkRmlsZShmaWxlUGF0aCwgJ3V0Zi04Jyk7XG4gICAgICB0aGlzLnRlbXBsYXRlQ2FjaGUuc2V0KGZpbGVQYXRoLCBkb2MpO1xuICAgIH1cblxuICAgIHJldHVybiBkb2M7XG4gIH1cbn1cbiJdfQ== |
@@ -1,3 +0,1 @@ | ||
import { readFile as readFile$1 } from 'fs'; | ||
import { promisify } from 'util'; | ||
import { __awaiter } from 'tslib'; | ||
@@ -7,2 +5,6 @@ import { ResourceLoader } from '@angular/compiler'; | ||
import { platformDynamicServer, INITIAL_CONFIG, renderModuleFactory } from '@angular/platform-server'; | ||
import { dirname } from 'path'; | ||
import { readFile as readFile$1 } from 'fs'; | ||
import { promisify } from 'util'; | ||
import Critters from 'critters'; | ||
@@ -26,2 +28,61 @@ /** | ||
/** | ||
* @license | ||
* Copyright Google LLC All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
*/ | ||
class CrittersExtended extends Critters { | ||
constructor(optionsExtended, resourceCache) { | ||
super({ | ||
logger: { | ||
warn: (s) => this.warnings.push(s), | ||
error: (s) => this.errors.push(s), | ||
log: () => { }, | ||
info: () => { }, | ||
}, | ||
path: optionsExtended.outputPath, | ||
publicPath: optionsExtended.deployUrl, | ||
compress: !!optionsExtended.minify, | ||
pruneSource: false, | ||
reduceInlineStyles: false, | ||
mergeStylesheets: false, | ||
preload: 'media', | ||
noscriptFallback: true, | ||
}); | ||
this.optionsExtended = optionsExtended; | ||
this.resourceCache = resourceCache; | ||
this.warnings = []; | ||
this.errors = []; | ||
} | ||
readFile(path) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let resourceContent = this.resourceCache.get(path); | ||
if (resourceContent === undefined) { | ||
resourceContent = yield readFile(path, 'utf-8'); | ||
this.resourceCache.set(path, resourceContent); | ||
} | ||
return resourceContent; | ||
}); | ||
} | ||
} | ||
class InlineCriticalCssProcessor { | ||
constructor(options) { | ||
this.options = options; | ||
this.resourceCache = new Map(); | ||
} | ||
process(html, options) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const critters = new CrittersExtended(Object.assign(Object.assign({}, this.options), options), this.resourceCache); | ||
const content = yield critters.process(html); | ||
return { | ||
content, | ||
errors: critters.errors, | ||
warnings: critters.warnings, | ||
}; | ||
}); | ||
} | ||
} | ||
/** | ||
* A common rendering engine utility. This abstracts the logic | ||
@@ -37,2 +98,5 @@ * for handling the platformServer compiler, the module cache, and | ||
this.templateCache = new Map(); | ||
this.inlineCriticalCssProcessor = new InlineCriticalCssProcessor({ | ||
minify: true, | ||
}); | ||
} | ||
@@ -51,19 +115,39 @@ /** Return an instance of the platformServer compiler */ | ||
render(opts) { | ||
var _a; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
// if opts.document dosen't exist then opts.documentFilePath must | ||
const doc = opts.document || opts.documentFilePath && (yield this.getDocument(opts.documentFilePath)); | ||
const extraProviders = [ | ||
...(opts.providers || []), | ||
...(this.providers || []), | ||
{ | ||
]; | ||
let doc = opts.document; | ||
if (!doc && opts.documentFilePath) { | ||
doc = yield this.getDocument(opts.documentFilePath); | ||
} | ||
if (doc) { | ||
extraProviders.push({ | ||
provide: INITIAL_CONFIG, | ||
useValue: { | ||
document: doc, | ||
document: opts.inlineCriticalCss | ||
// Workaround for https://github.com/GoogleChromeLabs/critters/issues/64 | ||
? doc.replace(/ media=\"print\" onload=\"this\.media='all'"><noscript><link .+?><\/noscript>/g, '>') | ||
: doc, | ||
url: opts.url | ||
} | ||
} | ||
]; | ||
}); | ||
} | ||
const moduleOrFactory = this.moduleOrFactory || opts.bootstrap; | ||
const factory = yield this.getFactory(moduleOrFactory); | ||
return renderModuleFactory(factory, { extraProviders }); | ||
const html = yield renderModuleFactory(factory, { extraProviders }); | ||
if (!opts.inlineCriticalCss) { | ||
return html; | ||
} | ||
const { content, errors, warnings } = yield this.inlineCriticalCssProcessor.process(html, { | ||
outputPath: (_a = opts.publicPath) !== null && _a !== void 0 ? _a : (opts.documentFilePath ? dirname(opts.documentFilePath) : undefined), | ||
}); | ||
// tslint:disable-next-line: no-console | ||
warnings.forEach(m => console.warn(m)); | ||
// tslint:disable-next-line: no-console | ||
errors.forEach(m => console.error(m)); | ||
return content; | ||
}); | ||
@@ -130,14 +214,6 @@ } | ||
/** | ||
* @license | ||
* Copyright Google LLC All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
*/ | ||
/** | ||
* Generated bundle index. Do not edit. | ||
*/ | ||
export { CommonEngine as ɵCommonEngine, FileLoader as ɵFileLoader }; | ||
export { CommonEngine as ɵCommonEngine, FileLoader as ɵFileLoader, InlineCriticalCssProcessor as ɵInlineCriticalCssProcessor }; | ||
//# sourceMappingURL=engine.js.map |
{ | ||
"name": "@nguniversal/common", | ||
"version": "11.0.1", | ||
"version": "11.1.0-next.0", | ||
"description": "Angular Universal common utilities", | ||
@@ -14,7 +14,8 @@ "license": "MIT", | ||
"dependencies": { | ||
"critters": "0.0.6", | ||
"tslib": "^2.0.0" | ||
}, | ||
"peerDependencies": { | ||
"@angular/common": "^11.0.3", | ||
"@angular/core": "^11.0.3" | ||
"@angular/common": "^11.1.0-next.2", | ||
"@angular/core": "^11.1.0-next.2" | ||
}, | ||
@@ -21,0 +22,0 @@ "ng-update": { |
@@ -225,3 +225,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
type: dependencies_1.NodeDependencyType.Dev, | ||
version: '^11.0.1', | ||
version: '^11.1.0-next.0', | ||
}); | ||
@@ -228,0 +228,0 @@ return host; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
378087
2649
4
3
+ Addedcritters@0.0.6
+ Addedansi-styles@4.3.0(transitive)
+ Addedatob@2.1.2(transitive)
+ Addedchalk@4.1.2(transitive)
+ Addedcolor-convert@2.0.1(transitive)
+ Addedcolor-name@1.1.4(transitive)
+ Addedcritters@0.0.6(transitive)
+ Addedcss@3.0.0(transitive)
+ Addeddecode-uri-component@0.2.2(transitive)
+ Addedhas-flag@4.0.0(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedparse5@6.0.1(transitive)
+ Addedparse5-htmlparser2-tree-adapter@6.0.1(transitive)
+ Addedpretty-bytes@5.6.0(transitive)
+ Addedsource-map@0.6.1(transitive)
+ Addedsource-map-resolve@0.6.0(transitive)
+ Addedsupports-color@7.2.0(transitive)