Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lego-bigpipe

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lego-bigpipe - npm Package Compare versions

Comparing version 0.1.6 to 0.1.7

44

index.js

@@ -35,3 +35,3 @@ 'use strict';

/*jshint evil: true */
(new Function('module', data.data))(module);
(new Function('module', 'var exports=module.exports;' + data.data)).call(module, module);
pagelet.html = ejs.render(data.source, {locals: module.exports});

@@ -61,4 +61,5 @@ } else if (data.source) {

if (!data.code) data.code = uuid();
config = config || {urlPattern: '%s'};
var pre = '<!DOCTYPE html>\n<html>\n<head>\n <meta charset="utf-8">\n';
var pre = '<!DOCTYPE html>\n<!--STATUS OK-->\n<html>\n<head>\n <meta charset="utf-8">\n';
if (data.head) {

@@ -84,23 +85,28 @@ // meta

// put units' css in head
if (data.body && data.mode !== 'inline') {
var comboIds = {};
if (data.body) {
var ids = {};
each(data.body.units, function (unit) {
each(unit.css, function (c) {
comboIds[c] = 1;
each(unit.css, function (m) {ids[m + '.css'] = 1;});
if (data.mode === 'inline') each(unit.js, function (m) {ids[m + '.js'] = 1;});
});
ids = Object.keys(ids);
// inline mode: put all mods' content in head
if (data.mode === 'inline') {
each(ids, function (id) {
pre += tpl.script({
content: data.mods[id]
});
});
});
comboIds = Object.keys(comboIds);
if (comboIds.length) {
if (config.combo) {
// combo mode: put all mods' css combo in head
} else if (config.combo && ids.length) {
pre += tpl.scriptLink({
url: genUrl(ids, '.js', config)
});
// put all mods' css in head
} else {
each(ids, function (id) {
pre += tpl.scriptLink({
url: genUrl(comboIds, '.css.js', config)
url: genUrl(id, '.js', config)
});
} else {
each(comboIds, function (id) {
pre += tpl.scriptLink({
url: genUrl(id, '.css.js', config)
});
});
}
});
}

@@ -107,0 +113,0 @@ }

{
"name": "lego-bigpipe",
"version": "0.1.6",
"version": "0.1.7",
"description": "a bigpipe builder for scrat-lego",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -78,3 +78,3 @@ // (╯°□°)╯︵oƃǝ˥

});
v.should.have.property('pre', '<!DOCTYPE html>\n<html>\n<head>\n <meta charset="utf-8">\n <meta name="HandheldFriendly" content="true">\n <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0">\n </head>\n<body>\n');
v.should.have.property('pre', '<!DOCTYPE html>\n<!--STATUS OK-->\n<html>\n<head>\n <meta charset="utf-8">\n <meta name="HandheldFriendly" content="true">\n <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0">\n </head>\n<body>\n');
});

@@ -89,3 +89,3 @@

});
v.should.have.property('pre', '<!DOCTYPE html>\n<html>\n<head>\n <meta charset="utf-8">\n <title>Hello</title>\n </head>\n<body>\n');
v.should.have.property('pre', '<!DOCTYPE html>\n<!--STATUS OK-->\n<html>\n<head>\n <meta charset="utf-8">\n <title>Hello</title>\n </head>\n<body>\n');
});

@@ -104,3 +104,3 @@

});
v.should.have.property('pre', '<!DOCTYPE html>\n<html>\n<head>\n <meta charset="utf-8">\n <link rel="stylesheet" type="text/css" href="a.css">\n <style>html { display: none; }</style>\n </head>\n<body>\n');
v.should.have.property('pre', '<!DOCTYPE html>\n<!--STATUS OK-->\n<html>\n<head>\n <meta charset="utf-8">\n <link rel="stylesheet" type="text/css" href="a.css">\n <style>html { display: none; }</style>\n </head>\n<body>\n');
});

@@ -119,3 +119,3 @@

});
v.should.have.property('pre', '<!DOCTYPE html>\n<html>\n<head>\n <meta charset="utf-8">\n <script src="a.js"></script>\n <script>console.log(\'Hello\');</script>\n </head>\n<body>\n');
v.should.have.property('pre', '<!DOCTYPE html>\n<!--STATUS OK-->\n<html>\n<head>\n <meta charset="utf-8">\n <script src="a.js"></script>\n <script>console.log(\'Hello\');</script>\n </head>\n<body>\n');
});

@@ -168,3 +168,3 @@

});
v.should.have.property('pre', '<!DOCTYPE html>\n<html>\n<head>\n <meta charset="utf-8">\n <script src="/u/u1/u11.css.js"></script>\n <script src="/u/u1/u12.css.js"></script>\n <script src="/u/u2/u21.css.js"></script>\n </head>\n<body>\n');
v.should.have.property('pre', '<!DOCTYPE html>\n<!--STATUS OK-->\n<html>\n<head>\n <meta charset="utf-8">\n <script src="/u/u1/u11.css.js"></script>\n <script src="/u/u1/u12.css.js"></script>\n <script src="/u/u2/u21.css.js"></script>\n </head>\n<body>\n');
});

@@ -189,4 +189,33 @@

});
v.should.have.property('pre', '<!DOCTYPE html>\n<html>\n<head>\n <meta charset="utf-8">\n <script src="/c/u/u1/u11.css.js;u/u1/u12.css.js;u/u2/u21.css.js"></script>\n </head>\n<body>\n');
v.should.have.property('pre', '<!DOCTYPE html>\n<!--STATUS OK-->\n<html>\n<head>\n <meta charset="utf-8">\n <script src="/c/u/u1/u11.css.js;u/u1/u12.css.js;u/u2/u21.css.js"></script>\n </head>\n<body>\n');
});
it('should inline all mods\' css and js in head properly when mode="inline"', function () {
var v = lego.view({
code: 'view',
mode: 'inline',
body: {
units: [{
code: 'unit1',
css: ['u/u1/u11', 'u/u1/u12'],
js: ['u/u1/u11']
}, {
code: 'unit2',
css: ['u/u2/u21', 'u/u2/u21', 'u/u1/u11'],
js: ['u/u1/u11']
}]
},
mods: {
'u/u1/u11.css': 'lego.defineCSS("u/u1/u11.css.js", "html { display: none; }");',
'u/u1/u12.css': 'lego.defineCSS("u/u1/u12.css.js", "html { display: block; }");',
'u/u1/u11.js': 'lego.define("u/u1/u11.js", "console.log(\"Hello\");");',
'u/u2/u21.css': 'lego.defineCSS("u/u2/u21.css.js", "body { display: none; }");'
}
}, {
combo: true,
urlPattern: '/%s',
comboPattern: '/c/%s'
});
v.should.have.property('pre', '<!DOCTYPE html>\n<!--STATUS OK-->\n<html>\n<head>\n <meta charset="utf-8">\n <script>lego.defineCSS("u/u1/u11.css.js", "html { display: none; }");</script>\n <script>lego.defineCSS("u/u1/u12.css.js", "html { display: block; }");</script>\n <script>lego.define("u/u1/u11.js", "console.log("Hello");");</script>\n <script>lego.defineCSS("u/u2/u21.css.js", "body { display: none; }");</script>\n </head>\n<body>\n');
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc