New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

node-cube

Package Overview
Dependencies
Maintainers
4
Versions
190
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-cube - npm Package Compare versions

Comparing version 3.0.1 to 3.0.2

runtime/cube_clean_cache.js

28

lib/cube/cache.js

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

function placeHolder(module) {
return `Cube("tmp_${new Date().getTime()}", ["${module}"], function(){});`;
return `Cube("no-cached", ${JSON.stringify(module)}, function(){});`;
}

@@ -39,2 +39,7 @@

}
clean(cb) {
this._cache = [];
this._modulemap = {};
fs.rm(this.tmpDir, cb);
}
saveToDisk(key, v) {

@@ -72,3 +77,3 @@ fs.save(path.join(this.tmpDir, key), JSON.stringify(v), () => {});

let mods = Object.keys(modules);
let rest = {};
/**

@@ -82,2 +87,5 @@ * 规则:

let node = modules[key];
if (!node) {
return cb();
}
fs.lstat(node.absPath, (err, stats) => {

@@ -94,5 +102,12 @@ if (err) {

delete this._cache[key];
process(placeHolder(node.queryPath));
rest[node.queryPath] = true;
return cb();
}
if (
node.modifyTime >= new Date().getTime() - 10800000 &&
!/node_modules\//.test(node.queryPath)
) {
rest[node.queryPath] = true;
return cb();
}
if (!node.codeWraped) {

@@ -104,3 +119,3 @@ return cb();

if (!modulesMap[v]) {
process(placeHolder(v));
rest[v] = true;
}

@@ -111,3 +126,6 @@ });

});
}, done);
}, () => {
process(placeHolder(Object.keys(rest)));
done();
});
}

@@ -114,0 +132,0 @@ }

4

lib/cube/ext_api_process.js

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

wrapScript(data, callback) {
var header = 'Cube($$filepath$$, $$requires$$, function (module, exports, require, load, __dirname, __filename) {';
var header = 'Cube($$filepath$$, $$requires$$, function (module, exports, require, load, process, global) {';
var footer = '\nreturn module.exports;});';

@@ -824,3 +824,3 @@ // var config = cube.config;

let wrapedCode = 'Cube(' + JSON.stringify(finalQpath) +
',' + JSON.stringify(requires) + ',function(module,exports,require){' + code + '; return module.exports});';
',' + JSON.stringify(requires) + ',function(module,exports,require, load, process, global){' + code + '; return module.exports});';
let flagCompress = data.compress !== undefined ? data.compress : config.compress;

@@ -827,0 +827,0 @@

@@ -5,3 +5,3 @@ {

"description": "a new way to write js in browser",
"version": "3.0.1",
"version": "3.0.2",
"homepage": "https://github.com/fishbar/cube",

@@ -8,0 +8,0 @@ "repository": {

@@ -27,2 +27,7 @@ /*!

var mockedProcess = {
env: {NODE_ENV: 'production'}
};
var mockedGlobal = undefined;
var installedModules = {/*exports, fn, loaded, fired*/}; // The module cache

@@ -190,3 +195,3 @@ var loading = {};

m.fired = true;
m.exports = m.fn.apply(global, [m, m.exports, __cube_require__, __cube_load_creator__(module)]);
m.exports = m.fn.apply(global, [m, m.exports, __cube_require__, __cube_load_creator__(module), mockedProcess, mockedGlobal]);
}

@@ -291,2 +296,8 @@

}
if (config.env) {
mockedProcess.env.NODE_ENV = config.env;
}
if (config.global) {
mockedGlobal = config.global;
}

@@ -293,0 +304,0 @@ inited = true;

/*!
* Cube v3.0.1
* Cube v3.0.2
*/
(function(a,b){function c(){}function d(a,b){if(1===arguments.length)return j(a);var c=j(a);return l.css(c,b,a),a}function e(a){return function(b,c,d){2===arguments.length&&'function'==typeof c?(d=c,c=null,l.use(b,a,d)):l.use(b,a,function(a){a=l.css(a,c,b),d&&d(a)})}}function f(a){var b=a.indexOf(s);return 0<b?q[a.substr(0,b)]+a.substr(b+1):''}function g(a){for(var b,c=a.length,d=0;d<c;d++)b=a[d],-1===b.indexOf(s)&&(0===b.indexOf('./')?a[d]=b.substr(1):'/'!==b[0]&&(a[d]='/'+b));return a}function h(){if(B.length)return!1;for(var a in y)if(y.hasOwnProperty(a))return!1;return!0}function i(a,b){return'string'==typeof a&&(a=[a]),A?void(a.forEach(function(a){if(!x[a]){var c=o.createElement('script');c.type='text/javascript',c.async='true',c.charset=t;var d=f(a),e=d||r+a,g=[];m&&g.push(m),v&&(g.push('m'),g.push('ref='+b)),c.src=g.length?e+'?'+g.join('&'):e,z.appendChild(c),x[a]={exports:{},loaded:!1,fired:!1},y[a]=!0}}),h()&&k()):void B.push([a,b])}function j(b){function c(){var c=x[b];if(!c)throw new Error('Cube Error: Cannot find module \''+b+'\'');return c.fired||(c.fired=!0,c.exports=c.fn.apply(a,[c,c.exports,d,e(b)])),c.exports}if(u)return c();try{return c()}catch(a){return p.error(a),{}}}function k(){var a,b;for(a in w)w.hasOwnProperty(a)&&(b=a.split(','),b.forEach(function(b){var c=0;j(b),w[a].forEach(function(a){var d=a(x[b].exports);d&&c++}),w[a].length===c&&delete w[a]}))}function l(a,b,c){x[a]||(x[a]={exports:{},loaded:!1,fired:!1});var d=x[a];d.fn=c,d.loaded=!0,delete y[a],i(b,a)}var m,n=window,o=document,p=console,r='',q={},s=':',t='utf-8',u=!0,v=!0,w={},x={},y={},z=o.querySelector('head'),A=!1,B=[];l.toString=function(){return'Cube:v3.0.1'},l.init=function(a){if(a.base&&'/'!==a.base&&(r=a.base.replace(/\/$/,'')),a.remoteBase)for(var b in a.remoteBase)a.remoteBase.hasOwnProperty(b)&&(q[b]=a.remoteBase[b].replace(/\/$/,''));for(a.charset&&(t=a.charset),a.version&&(m=a.version),void 0!==a.debug&&(v=a.debug),void 0!==a.strict&&(u=a.strict),A=!0;B.length;){var c=B.shift();i(c[0],c[1])}return this},l.use=function(b,d,e,f){if(!b)throw new Error('Cube.use(moduleName) moduleName is undefined!');return'function'==typeof d&&(f=e,e=d,d=void 0),d||(d='Cube.use'),e=e||c,'string'==typeof b&&(b=[b]),f||(b=g(b)),w[b]||(w[b]=[]),w[b].push(function(){var c=[],d=b.length,f=!1;return function(b){if(!f)return(c.push(b),c.length===d)?(f=!0,e.apply(a,c),!0):void 0}}()),i(b,d),this},l.register=function(a,b){return x[a]?p.error('Cube Error: Module \''+a+'\' already registered'):(x[a]={exports:b,fn:c,loaded:!0,fired:!0},this)};var C=/([^};]+)(\{[^}]+\})/g,D={};l.css=function(a,b,c){if(a){var d=c+'@'+b;if(!D[d]){D[d]=!0,b&&(a=a.replace(C,function(a,c,d){var e=c.split(',').map(function(a){return b+' '+a.trim()});return e.join(',')+d}));var e=o.createElement('style');return e.setAttribute('type','text/css'),e.setAttribute('mod',c),b&&e.setAttribute('ns',b),z.appendChild(e),e.innerHTML=a,a}}},l.debug=function(){n.localStorage&&n.addEventListener?(localStorage.cube='debug',location.reload()):p.error('Cube Error: Cannot debug, your browser does not support localStorage or addEventListener')},l.cache=function(){var a,b,c={},d={};for(a in x)x.hasOwnProperty(a)&&(b=x[a],b.loaded||(c[a]=b),b.fired||(d[a]=b));p.info('modules:',x),p.info('unloaded:',c),p.info('unfired:',d)},n.localStorage&&'debug'===localStorage.cube&&(v=!0,n.addEventListener('load',l.cache)),b=b||'Cube',a[b]?p.error('Cube Error: window.'+b+' already in using, replace the last "null" param in cube.js'):a[b]=l;var E=o.currentScript;if(E){var F=E.dataset;F.base&&(l.init(F),l.use(F.main||'index.js',function(a){a.run&&a.run()}))}})(window,null);
(function(a,b){function c(){}function d(a,b){if(1===arguments.length)return j(a);var c=j(a);return l.css(c,b,a),a}function e(a){return function(b,c,d){2===arguments.length&&'function'===typeof c?(d=c,c=null,l.use(b,a,d)):l.use(b,a,function(a){a=l.css(a,c,b),d&&d(a)})}}function f(a){var b=a.indexOf(t);return 0<b?s[a.substr(0,b)]+a.substr(b+1):''}function g(a){for(var b,c=a.length,d=0;d<c;d++)b=a[d],-1===b.indexOf(t)&&(0===b.indexOf('./')?a[d]=b.substr(1):'/'!==b[0]&&(a[d]='/'+b));return a}function h(){if(D.length)return!1;for(var a in A)if(A.hasOwnProperty(a))return!1;return!0}function i(a,b){return'string'===typeof a&&(a=[a]),C?void(a.forEach(function(a){if(!z[a]){var c=p.createElement('script');c.type='text/javascript',c.async='true',c.charset=u;var d=f(a),e=d||r+a,g=[];m&&g.push(m),w&&(g.push('m'),g.push('ref='+b)),c.src=g.length?e+'?'+g.join('&'):e,B.appendChild(c),z[a]={exports:{},loaded:!1,fired:!1},A[a]=!0}}),h()&&k()):void D.push([a,b])}function j(b){function c(){var c=z[b];if(!c)throw new Error('Cube Error: Cannot find module \''+b+'\'');return c.fired||(c.fired=!0,c.exports=c.fn.apply(a,[c,c.exports,d,e(b),y,n])),c.exports}if(v)return c();try{return c()}catch(a){return q.error(a),{}}}function k(){var a,b;for(a in x)x.hasOwnProperty(a)&&(b=a.split(','),b.forEach(function(b){var c=0;j(b),x[a].forEach(function(a){var d=a(z[b].exports);d&&c++}),x[a].length===c&&delete x[a]}))}function l(a,b,c){z[a]||(z[a]={exports:{},loaded:!1,fired:!1});var d=z[a];d.fn=c,d.loaded=!0,delete A[a],i(b,a)}var m,n,o=window,p=document,q=console,r='',s={},t=':',u='utf-8',v=!0,w=!0,x={},y={env:{NODE_ENV:'production'}},z={},A={},B=p.querySelector('head'),C=!1,D=[];l.toString=function(){return'Cube:v3.0.2'},l.init=function(a){if(a.base&&'/'!==a.base&&(r=a.base.replace(/\/$/,'')),a.remoteBase)for(var b in a.remoteBase)a.remoteBase.hasOwnProperty(b)&&(s[b]=a.remoteBase[b].replace(/\/$/,''));for(a.charset&&(u=a.charset),a.version&&(m=a.version),void 0!==a.debug&&(w=a.debug),void 0!==a.strict&&(v=a.strict),a.env&&(y.env.NODE_ENV=a.env),a.global&&(n=a.global),C=!0;D.length;){var c=D.shift();i(c[0],c[1])}return this},l.use=function(b,d,e,f){if(!b)throw new Error('Cube.use(moduleName) moduleName is undefined!');return'function'===typeof d&&(f=e,e=d,d=void 0),d||(d='Cube.use'),e=e||c,'string'===typeof b&&(b=[b]),f||(b=g(b)),x[b]||(x[b]=[]),x[b].push(function(){var c=[],d=b.length,f=!1;return function(b){if(!f)return(c.push(b),c.length===d)?(f=!0,e.apply(a,c),!0):void 0}}()),i(b,d),this},l.register=function(a,b){return z[a]?q.error('Cube Error: Module \''+a+'\' already registered'):(z[a]={exports:b,fn:c,loaded:!0,fired:!0},this)};var E=/([^};]+)(\{[^}]+\})/g,F={};l.css=function(a,b,c){if(a){var d=c+'@'+b;if(!F[d]){F[d]=!0,b&&(a=a.replace(E,function(a,c,d){var e=c.split(',').map(function(a){return b+' '+a.trim()});return e.join(',')+d}));var e=p.createElement('style');return e.setAttribute('type','text/css'),e.setAttribute('mod',c),b&&e.setAttribute('ns',b),B.appendChild(e),e.innerHTML=a,a}}},l.debug=function(){o.localStorage&&o.addEventListener?(localStorage.cube='debug',location.reload()):q.error('Cube Error: Cannot debug, your browser does not support localStorage or addEventListener')},l.cache=function(){var a,b,c={},d={};for(a in z)z.hasOwnProperty(a)&&(b=z[a],b.loaded||(c[a]=b),b.fired||(d[a]=b));q.info('modules:',z),q.info('unloaded:',c),q.info('unfired:',d)},o.localStorage&&'debug'===localStorage.cube&&(w=!0,o.addEventListener('load',l.cache)),b=b||'Cube',a[b]?q.error('Cube Error: window.'+b+' already in using, replace the last "null" param in cube.js'):a[b]=l;var G=p.currentScript;if(G){var H=G.dataset;H.base&&(l.init(H),l.use(H.main||'index.js',function(a){a.run&&a.run()}))}})(window,null);

@@ -38,15 +38,30 @@ /*!

res.write('\n');
if (cube.config.optimize === false) {
xfs.readFile(path.join(__dirname, './runtime/cube_clean_cache.js'), (err, data) => {
res.write(data);
res.write('\n');
if (cube.config.optimize === false) {
res.end('');
} else {
cube.caches.getNodeModules(function (code) {
res.write(code);
res.write('\n');
}, function () {
res.end('');
});
}
});
});
return;
} else if (qpath === '/__clean_cache__') {
return cube.caches.clean((err) => {
res.setHeader('content-type', 'image/png');
if (err) {
res.statusCode = 500;
res.end(err.message);
} else {
res.statusCode = 200;
res.end('');
} else {
cube.caches.getNodeModules(function (code) {
res.write(code);
res.write('\n');
}, function () {
res.end('');
});
}
});
return;
}

@@ -112,3 +127,3 @@

data.genCode(function (err, data) {
if (config.devCache) {
if (!err && config.devCache) {
debug('cache processed file: %s, %s', data.queryPath, data.modifyTime);

@@ -115,0 +130,0 @@ delete data.ast;

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