Comparing version 0.10.1 to 0.10.2
@@ -1,30 +0,16 @@ | ||
function isEmptyObject( obj ) { | ||
for(var name in obj ) { | ||
return false; | ||
function clone(obj) { | ||
var o = Array.isArray(obj) ? [] : {}; | ||
for(var i in obj) { | ||
if(obj.hasOwnProperty(i)) { | ||
o[i] = typeof obj[i] === 'object' ? clone(obj[i]) : obj[i]; | ||
} | ||
} | ||
return true; | ||
return o; | ||
} | ||
function clone(obj) { | ||
exports.default=function(obj) { | ||
if(typeof obj != 'object') { | ||
return obj; | ||
} | ||
var re = {}; | ||
if(obj.constructor == Array) { | ||
re = []; | ||
} | ||
Object.keys(obj).forEach(function(i) { | ||
if(!isEmptyObject(obj[i])) { | ||
re[i] = clone(obj[i]); | ||
} | ||
else if(typeof obj[i] != 'object') { | ||
re[i] = obj[i]; | ||
} | ||
else { | ||
re[i] = {}; | ||
} | ||
}); | ||
return re; | ||
} | ||
exports.default=clone; | ||
return clone(obj); | ||
}; |
113
build/Fn.js
@@ -8,3 +8,4 @@ var homunculus=function(){var _0=require('homunculus');return _0.hasOwnProperty("homunculus")?_0.homunculus:_0.hasOwnProperty("default")?_0.default:_0}(); | ||
var operate=function(){var _6=require('./operate');return _6.hasOwnProperty("operate")?_6.operate:_6.hasOwnProperty("default")?_6.default:_6}(); | ||
var Tree=function(){var _7=require('./Tree');return _7.hasOwnProperty("Tree")?_7.Tree:_7.hasOwnProperty("default")?_7.default:_7}(); | ||
var exprstmt=function(){var _7=require('./exprstmt');return _7.hasOwnProperty("exprstmt")?_7.exprstmt:_7.hasOwnProperty("default")?_7.default:_7}(); | ||
var Tree=function(){var _8=require('./Tree');return _8.hasOwnProperty("Tree")?_8.Tree:_8.hasOwnProperty("default")?_8.default:_8}(); | ||
@@ -15,11 +16,11 @@ var Token = homunculus.getClass('token', 'css'); | ||
function Fn(node, ignores, index) { | ||
function Fn(node, ignores, index, fnHash, globalFn, file) { | ||
this.node = node; | ||
this.ignores = ignores; | ||
this.index = index; | ||
this.index2 = index; | ||
this.fnHash = fnHash; | ||
this.globalFn = globalFn; | ||
this.file = file; | ||
this.params = []; | ||
this.flag = false; | ||
this.autoSplit = false; | ||
this.res = ''; | ||
this.preCompiler(node, ignores); | ||
@@ -36,8 +37,4 @@ } | ||
} | ||
Fn.prototype.compile = function(cParams, ignores, index, varHash, globalHash) { | ||
Fn.prototype.compile = function(cParams, index, varHash, globalHash, first) { | ||
var self = this; | ||
self.index2 = self.index; | ||
self.flag = false; | ||
this.autoSplit = false; | ||
self.res = ''; | ||
var newVarHash = clone(varHash); | ||
@@ -52,2 +49,9 @@ var leaves = cParams.leaves(); | ||
switch(leaf.name()) { | ||
case Node.ARRLTR: | ||
case Node.DIR: | ||
newVarHash[k] = { | ||
value: exprstmt(leaf, varHash, globalHash, self.file), | ||
unit: '' | ||
}; | ||
break; | ||
case Node.UNBOX: | ||
@@ -60,3 +64,3 @@ newVarHash[k] = { | ||
default: | ||
newVarHash[k] = calculate(leaf, ignores, index, varHash, globalHash); | ||
newVarHash[k] = calculate(leaf, self.ignores, index, varHash, globalHash, self.file); | ||
break; | ||
@@ -66,59 +70,36 @@ } | ||
} | ||
index = ignore(leaf, ignores, index).index; | ||
index = ignore(leaf, self.ignores, index).index; | ||
}); | ||
self.recursion(self.node, ignores, newVarHash, globalHash); | ||
return self.res.replace(/^{/, '').replace(/}$/, ''); | ||
} | ||
Fn.prototype.recursion = function(node, ignores, newVarHash, globalHash) { | ||
var self = this; | ||
if(node.isToken()) { | ||
var token = node.token(); | ||
if(!token.isVirtual()) { | ||
if(self.flag) { | ||
if(token.content() == '~' && token.type() != Token.HACK) { | ||
self.autoSplit = true; | ||
} | ||
else { | ||
var s = getVar(token, newVarHash, globalHash); | ||
if(self.autoSplit && token.type() == Token.STRING) { | ||
var c = s.charAt(0); | ||
if(c != "'" && c != '"') { | ||
c = '"'; | ||
s = c + s + c; | ||
} | ||
s = s.replace(/,\s*/g, c + ',' + c); | ||
} | ||
self.res += s; | ||
self.autoSplit = false; | ||
} | ||
} | ||
while(self.ignores[++self.index2]) { | ||
var s = self.ignores[self.index2].content(); | ||
if(self.flag && s != '\n') { | ||
self.res += s; | ||
} | ||
} | ||
index = self.index; | ||
index = ignore(self.node.first(), self.ignores, index).index; | ||
index = ignore(self.node.leaf(1), self.ignores, index).index; | ||
var block = self.node.leaf(2); | ||
index = ignore(block.first(), self.ignores, index).index; | ||
var temp; | ||
var res = ''; | ||
for(var j = 1, len = block.size(); j < len - 1; j++) { | ||
var l = block.leaf(j); | ||
if(l.isToken() && l.token().isVirtual()) { | ||
continue; | ||
} | ||
var tree = new Tree( | ||
self.ignores, | ||
index, | ||
newVarHash, | ||
globalHash, | ||
self.fnHash, | ||
self.globalFn, | ||
{}, | ||
0, | ||
[], | ||
{}, | ||
true, | ||
first, | ||
self.file | ||
); | ||
temp = tree.join(l); | ||
res += temp.res; | ||
index = temp.index; | ||
} | ||
else { | ||
switch(node.name()) { | ||
case Node.BLOCK: | ||
self.flag = true; | ||
break; | ||
case Node.ADDEXPR: | ||
case Node.MTPLEXPR: | ||
case Node.PRMREXPR: | ||
var parent = node.parent(); | ||
if(parent.name() != Node.CALC && parent.parent().name() != Node.EXPR) { | ||
var opt = operate(node, newVarHash, globalHash); | ||
self.res += opt.value + opt.unit; | ||
self.index2 = ignore(node, ignores, self.index2).index; | ||
return; | ||
} | ||
break; | ||
} | ||
node.leaves().forEach(function(leaf) { | ||
self.recursion(leaf, ignores, newVarHash, globalHash); | ||
}); | ||
} | ||
return res; | ||
} | ||
@@ -125,0 +106,0 @@ |
@@ -16,3 +16,3 @@ var homunculus=function(){var _0=require('homunculus');return _0.hasOwnProperty("homunculus")?_0.homunculus:_0.hasOwnProperty("default")?_0.default:_0}(); | ||
while(ignores[++i]){} | ||
var res = fn.compile(node.leaf(1), ignores, i, varHash, globalVar).trim().replace(/\n/g, ''); | ||
var res = fn.compile(node.leaf(1), i, varHash, globalVar).trim().replace(/[\r\n]/g, ''); | ||
return res; | ||
@@ -19,0 +19,0 @@ } |
@@ -124,3 +124,6 @@ var homunculus=function(){var _0=require('homunculus');return _0.hasOwnProperty("homunculus")?_0.homunculus:_0.hasOwnProperty("default")?_0.default:_0}(); | ||
} | ||
else { | ||
res = s; | ||
} | ||
return { res:res, index:index }; | ||
}; |
@@ -37,2 +37,3 @@ var fs=function(){var _0=require('fs');return _0.hasOwnProperty("fs")?_0.fs:_0.hasOwnProperty("default")?_0.default:_0}(); | ||
this.index = 0; | ||
this.ignores = {}; | ||
this.msg = null; | ||
@@ -163,3 +164,3 @@ this.autoSplit = false; | ||
preVar(this.node, this.ignores, this.index, this.varHash, global.vars, this.file || global.file); | ||
preFn(this.node, this.ignores, this.index, this.fnHash); | ||
preFn(this.node, this.ignores, this.index, this.fnHash, global.fns, this.file || global.file); | ||
} | ||
@@ -166,0 +167,0 @@ More.prototype.parseOn = function() { |
@@ -11,3 +11,3 @@ var homunculus=function(){var _0=require('homunculus');return _0.hasOwnProperty("homunculus")?_0.homunculus:_0.hasOwnProperty("default")?_0.default:_0}(); | ||
function recursion(node, ignores, res) { | ||
function recursion(node, ignores, fnHash, globalFn, file) { | ||
if(!node.isToken()) { | ||
@@ -17,3 +17,3 @@ if(node.name() == Node.FN) { | ||
var k = leaves[0].token().content(); | ||
res[k] = new Fn(node, ignores, index); | ||
fnHash[k] = new Fn(node, ignores, index, fnHash, globalFn, file); | ||
index = ignore(node, ignores, index).index; | ||
@@ -23,3 +23,3 @@ } | ||
node.leaves().forEach(function(leaf) { | ||
recursion(leaf, ignores, res); | ||
recursion(leaf, ignores, fnHash, globalFn, file); | ||
}); | ||
@@ -33,5 +33,5 @@ } | ||
exports.default=function(node, ignores, i, fnHash) { | ||
exports.default=function(node, ignores, i, fnHash, globalFn, file) { | ||
index = i; | ||
recursion(node, ignores, fnHash); | ||
recursion(node, ignores, fnHash, globalFn, file); | ||
} |
@@ -116,3 +116,3 @@ var homunculus=function(){var _0=require('homunculus');return _0.hasOwnProperty("homunculus")?_0.homunculus:_0.hasOwnProperty("default")?_0.default:_0}(); | ||
case Node.FNC: | ||
self.res += getFn(node, self.ignores, self.index, self.fnHash, self.globalFn, self.varHash, self.globalVar); | ||
self.res += getFn(node, self.ignores, self.index, self.fnHash, self.globalFn, self.varHash, self.globalVar, self.first); | ||
var temp = ignore(node, self.ignores, self.index, true); | ||
@@ -119,0 +119,0 @@ self.res += temp.res.replace(/[^\n]/g, ''); |
{ | ||
"name": "more-css", | ||
"version": "0.10.1", | ||
"version": "0.10.2", | ||
"description": "a css pre-compiler&agressive compressor", | ||
@@ -34,3 +34,3 @@ "maintainers": [ | ||
"clean-css": "~3.0.10", | ||
"homunculus": "~0.8.12", | ||
"homunculus": "~0.8.13", | ||
"glob": "~5.0.3", | ||
@@ -37,0 +37,0 @@ "images": "~2.1.3" |
@@ -1,30 +0,16 @@ | ||
function isEmptyObject( obj ) { | ||
for(var name in obj ) { | ||
return false; | ||
function clone(obj) { | ||
var o = Array.isArray(obj) ? [] : {}; | ||
for(var i in obj) { | ||
if(obj.hasOwnProperty(i)) { | ||
o[i] = typeof obj[i] === 'object' ? clone(obj[i]) : obj[i]; | ||
} | ||
} | ||
return true; | ||
return o; | ||
} | ||
function clone(obj) { | ||
export default function(obj) { | ||
if(typeof obj != 'object') { | ||
return obj; | ||
} | ||
var re = {}; | ||
if(obj.constructor == Array) { | ||
re = []; | ||
} | ||
Object.keys(obj).forEach(function(i) { | ||
if(!isEmptyObject(obj[i])) { | ||
re[i] = clone(obj[i]); | ||
} | ||
else if(typeof obj[i] != 'object') { | ||
re[i] = obj[i]; | ||
} | ||
else { | ||
re[i] = {}; | ||
} | ||
}); | ||
return re; | ||
} | ||
export default clone; | ||
return clone(obj); | ||
}; |
111
src/Fn.js
@@ -8,2 +8,3 @@ import homunculus from 'homunculus'; | ||
import operate from './operate'; | ||
import exprstmt from './exprstmt'; | ||
import Tree from './Tree'; | ||
@@ -15,11 +16,11 @@ | ||
class Fn { | ||
constructor(node, ignores, index) { | ||
constructor(node, ignores, index, fnHash, globalFn, file) { | ||
this.node = node; | ||
this.ignores = ignores; | ||
this.index = index; | ||
this.index2 = index; | ||
this.fnHash = fnHash; | ||
this.globalFn = globalFn; | ||
this.file = file; | ||
this.params = []; | ||
this.flag = false; | ||
this.autoSplit = false; | ||
this.res = ''; | ||
this.preCompiler(node, ignores); | ||
@@ -36,8 +37,4 @@ } | ||
} | ||
compile(cParams, ignores, index, varHash, globalHash) { | ||
compile(cParams, index, varHash, globalHash, first) { | ||
var self = this; | ||
self.index2 = self.index; | ||
self.flag = false; | ||
this.autoSplit = false; | ||
self.res = ''; | ||
var newVarHash = clone(varHash); | ||
@@ -52,2 +49,9 @@ var leaves = cParams.leaves(); | ||
switch(leaf.name()) { | ||
case Node.ARRLTR: | ||
case Node.DIR: | ||
newVarHash[k] = { | ||
value: exprstmt(leaf, varHash, globalHash, self.file), | ||
unit: '' | ||
}; | ||
break; | ||
case Node.UNBOX: | ||
@@ -60,3 +64,3 @@ newVarHash[k] = { | ||
default: | ||
newVarHash[k] = calculate(leaf, ignores, index, varHash, globalHash); | ||
newVarHash[k] = calculate(leaf, self.ignores, index, varHash, globalHash, self.file); | ||
break; | ||
@@ -66,59 +70,36 @@ } | ||
} | ||
index = ignore(leaf, ignores, index).index; | ||
index = ignore(leaf, self.ignores, index).index; | ||
}); | ||
self.recursion(self.node, ignores, newVarHash, globalHash); | ||
return self.res.replace(/^{/, '').replace(/}$/, ''); | ||
} | ||
recursion(node, ignores, newVarHash, globalHash) { | ||
var self = this; | ||
if(node.isToken()) { | ||
var token = node.token(); | ||
if(!token.isVirtual()) { | ||
if(self.flag) { | ||
if(token.content() == '~' && token.type() != Token.HACK) { | ||
self.autoSplit = true; | ||
} | ||
else { | ||
var s = getVar(token, newVarHash, globalHash); | ||
if(self.autoSplit && token.type() == Token.STRING) { | ||
var c = s.charAt(0); | ||
if(c != "'" && c != '"') { | ||
c = '"'; | ||
s = c + s + c; | ||
} | ||
s = s.replace(/,\s*/g, c + ',' + c); | ||
} | ||
self.res += s; | ||
self.autoSplit = false; | ||
} | ||
} | ||
while(self.ignores[++self.index2]) { | ||
var s = self.ignores[self.index2].content(); | ||
if(self.flag && s != '\n') { | ||
self.res += s; | ||
} | ||
} | ||
index = self.index; | ||
index = ignore(self.node.first(), self.ignores, index).index; | ||
index = ignore(self.node.leaf(1), self.ignores, index).index; | ||
var block = self.node.leaf(2); | ||
index = ignore(block.first(), self.ignores, index).index; | ||
var temp; | ||
var res = ''; | ||
for(var j = 1, len = block.size(); j < len - 1; j++) { | ||
var l = block.leaf(j); | ||
if(l.isToken() && l.token().isVirtual()) { | ||
continue; | ||
} | ||
var tree = new Tree( | ||
self.ignores, | ||
index, | ||
newVarHash, | ||
globalHash, | ||
self.fnHash, | ||
self.globalFn, | ||
{}, | ||
0, | ||
[], | ||
{}, | ||
true, | ||
first, | ||
self.file | ||
); | ||
temp = tree.join(l); | ||
res += temp.res; | ||
index = temp.index; | ||
} | ||
else { | ||
switch(node.name()) { | ||
case Node.BLOCK: | ||
self.flag = true; | ||
break; | ||
case Node.ADDEXPR: | ||
case Node.MTPLEXPR: | ||
case Node.PRMREXPR: | ||
var parent = node.parent(); | ||
if(parent.name() != Node.CALC && parent.parent().name() != Node.EXPR) { | ||
var opt = operate(node, newVarHash, globalHash); | ||
self.res += opt.value + opt.unit; | ||
self.index2 = ignore(node, ignores, self.index2).index; | ||
return; | ||
} | ||
break; | ||
} | ||
node.leaves().forEach(function(leaf) { | ||
self.recursion(leaf, ignores, newVarHash, globalHash); | ||
}); | ||
} | ||
return res; | ||
} | ||
@@ -125,0 +106,0 @@ } |
@@ -16,3 +16,3 @@ import homunculus from 'homunculus'; | ||
while(ignores[++i]){} | ||
var res = fn.compile(node.leaf(1), ignores, i, varHash, globalVar).trim().replace(/\n/g, ''); | ||
var res = fn.compile(node.leaf(1), i, varHash, globalVar).trim().replace(/[\r\n]/g, ''); | ||
return res; | ||
@@ -19,0 +19,0 @@ } |
@@ -124,3 +124,6 @@ import homunculus from 'homunculus'; | ||
} | ||
else { | ||
res = s; | ||
} | ||
return { res, index }; | ||
}; |
@@ -37,2 +37,3 @@ import fs from 'fs'; | ||
this.index = 0; | ||
this.ignores = {}; | ||
this.msg = null; | ||
@@ -163,3 +164,3 @@ this.autoSplit = false; | ||
preVar(this.node, this.ignores, this.index, this.varHash, global.vars, this.file || global.file); | ||
preFn(this.node, this.ignores, this.index, this.fnHash); | ||
preFn(this.node, this.ignores, this.index, this.fnHash, global.fns, this.file || global.file); | ||
} | ||
@@ -166,0 +167,0 @@ parseOn() { |
@@ -11,3 +11,3 @@ import homunculus from 'homunculus'; | ||
function recursion(node, ignores, res) { | ||
function recursion(node, ignores, fnHash, globalFn, file) { | ||
if(!node.isToken()) { | ||
@@ -17,3 +17,3 @@ if(node.name() == Node.FN) { | ||
var k = leaves[0].token().content(); | ||
res[k] = new Fn(node, ignores, index); | ||
fnHash[k] = new Fn(node, ignores, index, fnHash, globalFn, file); | ||
index = ignore(node, ignores, index).index; | ||
@@ -23,3 +23,3 @@ } | ||
node.leaves().forEach(function(leaf) { | ||
recursion(leaf, ignores, res); | ||
recursion(leaf, ignores, fnHash, globalFn, file); | ||
}); | ||
@@ -33,5 +33,5 @@ } | ||
export default function(node, ignores, i, fnHash) { | ||
export default function(node, ignores, i, fnHash, globalFn, file) { | ||
index = i; | ||
recursion(node, ignores, fnHash); | ||
recursion(node, ignores, fnHash, globalFn, file); | ||
} |
@@ -116,3 +116,3 @@ import homunculus from 'homunculus'; | ||
case Node.FNC: | ||
self.res += getFn(node, self.ignores, self.index, self.fnHash, self.globalFn, self.varHash, self.globalVar); | ||
self.res += getFn(node, self.ignores, self.index, self.fnHash, self.globalFn, self.varHash, self.globalVar, self.first); | ||
var temp = ignore(node, self.ignores, self.index, true); | ||
@@ -119,0 +119,0 @@ self.res += temp.res.replace(/[^\n]/g, ''); |
@@ -1,30 +0,16 @@ | ||
define(function(require, exports, module){function isEmptyObject( obj ) { | ||
for(var name in obj ) { | ||
return false; | ||
define(function(require, exports, module){function clone(obj) { | ||
var o = Array.isArray(obj) ? [] : {}; | ||
for(var i in obj) { | ||
if(obj.hasOwnProperty(i)) { | ||
o[i] = typeof obj[i] === 'object' ? clone(obj[i]) : obj[i]; | ||
} | ||
} | ||
return true; | ||
return o; | ||
} | ||
function clone(obj) { | ||
exports.default=function(obj) { | ||
if(typeof obj != 'object') { | ||
return obj; | ||
} | ||
var re = {}; | ||
if(obj.constructor == Array) { | ||
re = []; | ||
} | ||
Object.keys(obj).forEach(function(i) { | ||
if(!isEmptyObject(obj[i])) { | ||
re[i] = clone(obj[i]); | ||
} | ||
else if(typeof obj[i] != 'object') { | ||
re[i] = obj[i]; | ||
} | ||
else { | ||
re[i] = {}; | ||
} | ||
}); | ||
return re; | ||
} | ||
exports.default=clone;}); | ||
return clone(obj); | ||
};}); |
113
web/Fn.js
@@ -8,3 +8,4 @@ define(function(require, exports, module){var homunculus=function(){var _0=require('homunculus');return _0.hasOwnProperty("homunculus")?_0.homunculus:_0.hasOwnProperty("default")?_0.default:_0}(); | ||
var operate=function(){var _6=require('./operate');return _6.hasOwnProperty("operate")?_6.operate:_6.hasOwnProperty("default")?_6.default:_6}(); | ||
var Tree=function(){var _7=require('./Tree');return _7.hasOwnProperty("Tree")?_7.Tree:_7.hasOwnProperty("default")?_7.default:_7}(); | ||
var exprstmt=function(){var _7=require('./exprstmt');return _7.hasOwnProperty("exprstmt")?_7.exprstmt:_7.hasOwnProperty("default")?_7.default:_7}(); | ||
var Tree=function(){var _8=require('./Tree');return _8.hasOwnProperty("Tree")?_8.Tree:_8.hasOwnProperty("default")?_8.default:_8}(); | ||
@@ -15,11 +16,11 @@ var Token = homunculus.getClass('token', 'css'); | ||
function Fn(node, ignores, index) { | ||
function Fn(node, ignores, index, fnHash, globalFn, file) { | ||
this.node = node; | ||
this.ignores = ignores; | ||
this.index = index; | ||
this.index2 = index; | ||
this.fnHash = fnHash; | ||
this.globalFn = globalFn; | ||
this.file = file; | ||
this.params = []; | ||
this.flag = false; | ||
this.autoSplit = false; | ||
this.res = ''; | ||
this.preCompiler(node, ignores); | ||
@@ -36,8 +37,4 @@ } | ||
} | ||
Fn.prototype.compile = function(cParams, ignores, index, varHash, globalHash) { | ||
Fn.prototype.compile = function(cParams, index, varHash, globalHash, first) { | ||
var self = this; | ||
self.index2 = self.index; | ||
self.flag = false; | ||
this.autoSplit = false; | ||
self.res = ''; | ||
var newVarHash = clone(varHash); | ||
@@ -52,2 +49,9 @@ var leaves = cParams.leaves(); | ||
switch(leaf.name()) { | ||
case Node.ARRLTR: | ||
case Node.DIR: | ||
newVarHash[k] = { | ||
value: exprstmt(leaf, varHash, globalHash, self.file), | ||
unit: '' | ||
}; | ||
break; | ||
case Node.UNBOX: | ||
@@ -60,3 +64,3 @@ newVarHash[k] = { | ||
default: | ||
newVarHash[k] = calculate(leaf, ignores, index, varHash, globalHash); | ||
newVarHash[k] = calculate(leaf, self.ignores, index, varHash, globalHash, self.file); | ||
break; | ||
@@ -66,59 +70,36 @@ } | ||
} | ||
index = ignore(leaf, ignores, index).index; | ||
index = ignore(leaf, self.ignores, index).index; | ||
}); | ||
self.recursion(self.node, ignores, newVarHash, globalHash); | ||
return self.res.replace(/^{/, '').replace(/}$/, ''); | ||
} | ||
Fn.prototype.recursion = function(node, ignores, newVarHash, globalHash) { | ||
var self = this; | ||
if(node.isToken()) { | ||
var token = node.token(); | ||
if(!token.isVirtual()) { | ||
if(self.flag) { | ||
if(token.content() == '~' && token.type() != Token.HACK) { | ||
self.autoSplit = true; | ||
} | ||
else { | ||
var s = getVar(token, newVarHash, globalHash); | ||
if(self.autoSplit && token.type() == Token.STRING) { | ||
var c = s.charAt(0); | ||
if(c != "'" && c != '"') { | ||
c = '"'; | ||
s = c + s + c; | ||
} | ||
s = s.replace(/,\s*/g, c + ',' + c); | ||
} | ||
self.res += s; | ||
self.autoSplit = false; | ||
} | ||
} | ||
while(self.ignores[++self.index2]) { | ||
var s = self.ignores[self.index2].content(); | ||
if(self.flag && s != '\n') { | ||
self.res += s; | ||
} | ||
} | ||
index = self.index; | ||
index = ignore(self.node.first(), self.ignores, index).index; | ||
index = ignore(self.node.leaf(1), self.ignores, index).index; | ||
var block = self.node.leaf(2); | ||
index = ignore(block.first(), self.ignores, index).index; | ||
var temp; | ||
var res = ''; | ||
for(var j = 1, len = block.size(); j < len - 1; j++) { | ||
var l = block.leaf(j); | ||
if(l.isToken() && l.token().isVirtual()) { | ||
continue; | ||
} | ||
var tree = new Tree( | ||
self.ignores, | ||
index, | ||
newVarHash, | ||
globalHash, | ||
self.fnHash, | ||
self.globalFn, | ||
{}, | ||
0, | ||
[], | ||
{}, | ||
true, | ||
first, | ||
self.file | ||
); | ||
temp = tree.join(l); | ||
res += temp.res; | ||
index = temp.index; | ||
} | ||
else { | ||
switch(node.name()) { | ||
case Node.BLOCK: | ||
self.flag = true; | ||
break; | ||
case Node.ADDEXPR: | ||
case Node.MTPLEXPR: | ||
case Node.PRMREXPR: | ||
var parent = node.parent(); | ||
if(parent.name() != Node.CALC && parent.parent().name() != Node.EXPR) { | ||
var opt = operate(node, newVarHash, globalHash); | ||
self.res += opt.value + opt.unit; | ||
self.index2 = ignore(node, ignores, self.index2).index; | ||
return; | ||
} | ||
break; | ||
} | ||
node.leaves().forEach(function(leaf) { | ||
self.recursion(leaf, ignores, newVarHash, globalHash); | ||
}); | ||
} | ||
return res; | ||
} | ||
@@ -125,0 +106,0 @@ |
@@ -16,3 +16,3 @@ define(function(require, exports, module){var homunculus=function(){var _0=require('homunculus');return _0.hasOwnProperty("homunculus")?_0.homunculus:_0.hasOwnProperty("default")?_0.default:_0}(); | ||
while(ignores[++i]){} | ||
var res = fn.compile(node.leaf(1), ignores, i, varHash, globalVar).trim().replace(/\n/g, ''); | ||
var res = fn.compile(node.leaf(1), i, varHash, globalVar).trim().replace(/[\r\n]/g, ''); | ||
return res; | ||
@@ -19,0 +19,0 @@ } |
@@ -124,3 +124,6 @@ define(function(require, exports, module){var homunculus=function(){var _0=require('homunculus');return _0.hasOwnProperty("homunculus")?_0.homunculus:_0.hasOwnProperty("default")?_0.default:_0}(); | ||
} | ||
else { | ||
res = s; | ||
} | ||
return { res:res, index:index }; | ||
};}); |
@@ -37,2 +37,3 @@ define(function(require, exports, module){var fs=function(){var _0=require('fs');return _0.hasOwnProperty("fs")?_0.fs:_0.hasOwnProperty("default")?_0.default:_0}(); | ||
this.index = 0; | ||
this.ignores = {}; | ||
this.msg = null; | ||
@@ -163,3 +164,3 @@ this.autoSplit = false; | ||
preVar(this.node, this.ignores, this.index, this.varHash, global.vars, this.file || global.file); | ||
preFn(this.node, this.ignores, this.index, this.fnHash); | ||
preFn(this.node, this.ignores, this.index, this.fnHash, global.fns, this.file || global.file); | ||
} | ||
@@ -166,0 +167,0 @@ More.prototype.parseOn = function() { |
@@ -11,3 +11,3 @@ define(function(require, exports, module){var homunculus=function(){var _0=require('homunculus');return _0.hasOwnProperty("homunculus")?_0.homunculus:_0.hasOwnProperty("default")?_0.default:_0}(); | ||
function recursion(node, ignores, res) { | ||
function recursion(node, ignores, fnHash, globalFn, file) { | ||
if(!node.isToken()) { | ||
@@ -17,3 +17,3 @@ if(node.name() == Node.FN) { | ||
var k = leaves[0].token().content(); | ||
res[k] = new Fn(node, ignores, index); | ||
fnHash[k] = new Fn(node, ignores, index, fnHash, globalFn, file); | ||
index = ignore(node, ignores, index).index; | ||
@@ -23,3 +23,3 @@ } | ||
node.leaves().forEach(function(leaf) { | ||
recursion(leaf, ignores, res); | ||
recursion(leaf, ignores, fnHash, globalFn, file); | ||
}); | ||
@@ -33,5 +33,5 @@ } | ||
exports.default=function(node, ignores, i, fnHash) { | ||
exports.default=function(node, ignores, i, fnHash, globalFn, file) { | ||
index = i; | ||
recursion(node, ignores, fnHash); | ||
recursion(node, ignores, fnHash, globalFn, file); | ||
}}); |
@@ -116,3 +116,3 @@ define(function(require, exports, module){var homunculus=function(){var _0=require('homunculus');return _0.hasOwnProperty("homunculus")?_0.homunculus:_0.hasOwnProperty("default")?_0.default:_0}(); | ||
case Node.FNC: | ||
self.res += getFn(node, self.ignores, self.index, self.fnHash, self.globalFn, self.varHash, self.globalVar); | ||
self.res += getFn(node, self.ignores, self.index, self.fnHash, self.globalFn, self.varHash, self.globalVar, self.first); | ||
var temp = ignore(node, self.ignores, self.index, true); | ||
@@ -119,0 +119,0 @@ self.res += temp.res.replace(/[^\n]/g, ''); |
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
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0
385614
10077
Updatedhomunculus@~0.8.13