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

yurine

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

yurine - npm Package Compare versions

Comparing version 0.1.3 to 0.2.0

2

package.json
{
"name": "yurine",
"version": "0.1.3",
"version": "0.2.0",
"description": "A CSX transformer for karas",

@@ -5,0 +5,0 @@ "author": "army8735 <army8735@qq.com>",

@@ -16,5 +16,6 @@ import babel from 'rollup-plugin-babel';

babel({
exclude: 'node_modules/**' // 只编译我们的源代码
exclude: 'node_modules/**', // 只编译我们的源代码
runtimeHelpers: true
}),
],
};

@@ -9,9 +9,31 @@ (function (global, factory) {

let ES6Token = homunculus.getClass('token', 'js');
let Token = homunculus.getClass('token', 'csx');
let Node = homunculus.getClass('node', 'csx');
let S = {};
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
return Constructor;
}
var ES6Token = homunculus.getClass('token', 'js');
var Token = homunculus.getClass('token', 'csx');
var Node = homunculus.getClass('node', 'csx');
var S = {};
S[Token.LINE] = S[Token.COMMENT] = S[Token.BLANK] = true;
let res;
let append;
var res;
var append;

@@ -32,3 +54,3 @@ function ignore(node, includeLine) {

let s = node.content();
var s = node.content();
res += s;

@@ -55,4 +77,4 @@ append += s;

return {
res,
append
res: res,
append: append
};

@@ -63,4 +85,4 @@ }

let Token$1 = homunculus.getClass('token', 'csx');
let Node$1 = homunculus.getClass('node', 'csx');
var Token$1 = homunculus.getClass('token', 'csx');
var Node$1 = homunculus.getClass('node', 'csx');

@@ -70,3 +92,3 @@ function parse$1(node, res, param, opt) {

case Node$1.EXPRSTMT:
linkage(node.first(), param, opt).arr.forEach(item => {
linkage(node.first(), param, opt).arr.forEach(function (item) {
res[item] = true;

@@ -77,7 +99,7 @@ });

case Node$1.VARSTMT:
node.leaves().forEach((leaf, i) => {
node.leaves().forEach(function (leaf, i) {
if (i % 2 === 1) {
let initlz = leaf.leaf(1);
let temp = linkage(initlz.leaf(1), param, opt);
temp.arr.forEach(item => {
var initlz = leaf.leaf(1);
var temp = linkage(initlz.leaf(1), param, opt);
temp.arr.forEach(function (item) {
res[item] = true;

@@ -90,6 +112,6 @@ });

case Node$1.BLOCKSTMT:
let block = node.first();
var block = node.first();
for (let i = 1, leaves = block.leaves(); i < leaves.length - 1; i++) {
parse$1(leaves[i], res, param, opt);
for (var i = 1, _leaves = block.leaves(); i < _leaves.length - 1; i++) {
parse$1(_leaves[i], res, param, opt);
}

@@ -100,4 +122,4 @@

case Node$1.IFSTMT:
let condition = node.leaf(2);
linkage(condition, param, opt).arr.forEach(item => {
var condition = node.leaf(2);
linkage(condition, param, opt).arr.forEach(function (item) {
res[item] = true;

@@ -109,6 +131,6 @@ });

case Node$1.ITERSTMT:
let peek = node.first().token().content();
var peek = node.first().token().content();
if (peek === 'for') {
let first = node.leaf(2); // for(;...
var first = node.leaf(2); // for(;...

@@ -123,7 +145,7 @@ if (first.isToken()) ; else {

let second = node.leaf(3); // for(;;...
var second = node.leaf(3); // for(;;...
if (second.isToken()) ; else {
let temp = linkage(second, param, opt);
temp.arr.forEach(item => {
var temp = linkage(second, param, opt);
temp.arr.forEach(function (item) {
res[item] = true;

@@ -133,3 +155,3 @@ });

let third = node.leaf(4);
var third = node.leaf(4);

@@ -140,4 +162,5 @@ if (third.isToken()) {

if (third.isToken()) ; else {
let temp = linkage(third, param, opt);
temp.arr.forEach(item => {
var _temp = linkage(third, param, opt);
_temp.arr.forEach(function (item) {
res[item] = true;

@@ -147,4 +170,5 @@ });

} else {
let temp = linkage(third, param, opt);
temp.arr.forEach(item => {
var _temp2 = linkage(third, param, opt);
_temp2.arr.forEach(function (item) {
res[item] = true;

@@ -154,14 +178,19 @@ });

} else if (peek === 'do') {
let blockstmt = node.leaf(1);
parse$1(blockstmt, res, param, opt);
let temp = linkage(node.leaf(4), param, opt);
temp.arr.forEach(item => {
var _blockstmt = node.leaf(1);
parse$1(_blockstmt, res, param, opt);
var _temp3 = linkage(node.leaf(4), param, opt);
_temp3.arr.forEach(function (item) {
res[item] = true;
});
} else if (peek === 'while') {
let temp = linkage(node.leaf(2), param, opt);
temp.arr.forEach(item => {
var _temp4 = linkage(node.leaf(2), param, opt);
_temp4.arr.forEach(function (item) {
res[item] = true;
});
let stmt = node.last();
var stmt = node.last();
parse$1(stmt, res, param, opt);

@@ -173,7 +202,9 @@ }

case Node$1.LEXDECL:
node.leaves().forEach((leaf, i) => {
node.leaves().forEach(function (leaf, i) {
if (i % 2 === 1) {
let initlz = leaf.leaf(1);
let temp = linkage(initlz.leaf(1), param, opt);
temp.arr.forEach(item => {
var initlz = leaf.leaf(1);
var _temp5 = linkage(initlz.leaf(1), param, opt);
_temp5.arr.forEach(function (item) {
res[item] = true;

@@ -188,6 +219,6 @@ });

if (opt.arrowFn.length > 0) {
let allReturn = true;
var allReturn = true;
for (let i = 0, len = opt.arrowFn.length; i < len; i++) {
if (!opt.arrowFn[i]) {
for (var _i = 0, len = opt.arrowFn.length; _i < len; _i++) {
if (!opt.arrowFn[_i]) {
allReturn = false;

@@ -199,3 +230,3 @@ break;

if (!allReturn) {
linkage(node.leaf(1), param, opt).arr.forEach(item => {
linkage(node.leaf(1), param, opt).arr.forEach(function (item) {
res[item] = true;

@@ -209,6 +240,6 @@ });

case Node$1.WITHSTMT:
linkage(node.leaf(2), param, opt).arr.forEach(item => {
linkage(node.leaf(2), param, opt).arr.forEach(function (item) {
res[item] = true;
});
let blockstmt = node.last();
var blockstmt = node.last();
parse$1(blockstmt, res, param, opt);

@@ -218,6 +249,6 @@ break;

case Node$1.SWCHSTMT:
linkage(node.leaf(2), param, opt).arr.forEach(item => {
linkage(node.leaf(2), param, opt).arr.forEach(function (item) {
res[item] = true;
});
let caseblock = node.last();
var caseblock = node.last();
parse$1(caseblock, res, param, opt);

@@ -227,13 +258,16 @@ break;

case Node$1.CASEBLOCK:
let leaves = node.leaves();
var leaves = node.leaves();
for (let i = 1; i < leaves.length - 1; i++) {
let leaf = leaves[i];
for (var _i2 = 1; _i2 < leaves.length - 1; _i2++) {
var leaf = leaves[_i2];
if (leaf.name() === Node$1.CASECLAUSE) {
let expr = leaf.leaf(1);
let temp = linkage(expr, param, opt);
temp.arr.forEach(item => {
var expr = leaf.leaf(1);
var _temp6 = linkage(expr, param, opt);
_temp6.arr.forEach(function (item) {
res[item] = true;
});
parse$1(leaf.last(), res, param, opt);

@@ -250,3 +284,3 @@ } else if (leaf.name() === Node$1.DFTCLAUSE) {

function arrowfn (node, res, param, opt) {
node.leaves().forEach(leaf => {
node.leaves().forEach(function (leaf) {
parse$1(leaf, res, param, opt);

@@ -256,4 +290,4 @@ });

let Token$2 = homunculus.getClass('token', 'csx');
let Node$2 = homunculus.getClass('node', 'csx');
var Token$2 = homunculus.getClass('token', 'csx');
var Node$2 = homunculus.getClass('node', 'csx');

@@ -266,3 +300,3 @@ function parse$2(node, res, param, opt) {

for (let i = 2, leaves = node.leaves(), len = leaves.length; i < len; i += 2) {
for (var i = 2, leaves = node.leaves(), len = leaves.length; i < len; i += 2) {
parse$2(node.leaf(i), res, param, opt);

@@ -299,4 +333,4 @@ }

for (let i = 2, leaves = node.leaves(), len = leaves.length; i < len; i += 2) {
parse$2(node.leaf(i), res, param, opt);
for (var _i = 2, _leaves = node.leaves(), _len = _leaves.length; _i < _len; _i += 2) {
parse$2(node.leaf(_i), res, param, opt);
}

@@ -333,4 +367,4 @@

case Node$2.TEMPLATE:
for (let i = 0, leaves = node.leaves(), len = leaves.length; i < len; i++) {
let leaf = node.leaf(i);
for (var _i2 = 0, _leaves2 = node.leaves(), _len2 = _leaves2.length; _i2 < _len2; _i2++) {
var leaf = node.leaf(_i2);

@@ -346,3 +380,3 @@ if (!leaf.isToken()) {

opt.arrowFn = opt.arrowFn || [];
let temp = node.parent();
var temp = node.parent();

@@ -356,7 +390,8 @@ if (temp && temp.name() === Node$2.ARGLIST) {

if (temp && temp.name() === Node$2.MMBEXPR) {
let callexpr = temp.parent();
var _callexpr = temp.parent();
temp = temp.leaf(2);
if (temp.isToken() && temp.token().content() === 'map') {
let body = node.last().leaf(1);
var body = node.last().leaf(1);

@@ -366,3 +401,3 @@ if (opt.arrowFn.length === 0) {

} else {
opt.arrowFn.push(callexpr.parent().name() === Node$2.RETSTMT);
opt.arrowFn.push(_callexpr.parent().name() === Node$2.RETSTMT);
}

@@ -382,4 +417,4 @@

for (let i = 1, leaves = node.leaves(); i < leaves.length - 1; i++) {
parse$2(leaves[i], res, param, opt);
for (var _i3 = 1, _leaves3 = node.leaves(); _i3 < _leaves3.length - 1; _i3++) {
parse$2(_leaves3[_i3], res, param, opt);
}

@@ -391,4 +426,4 @@

case Node$2.CSXOpeningElement:
for (let i = 1, leaves = node.leaves(); i < leaves.length - 1; i++) {
parse$2(leaves[i], res, param, opt);
for (var _i4 = 1, _leaves4 = node.leaves(); _i4 < _leaves4.length - 1; _i4++) {
parse$2(_leaves4[_i4], res, param, opt);
}

@@ -399,6 +434,6 @@

case Node$2.CSXAttribute:
let value = node.last();
var value = node.last();
if (value.name() === Node$2.CSXAttributeValue) {
let first = value.first();
var first = value.first();

@@ -413,3 +448,3 @@ if (first.isToken() && first.token().content() === '{') {

case Node$2.CSXChild:
node.leaves().forEach(leaf => {
node.leaves().forEach(function (leaf) {
parse$2(leaf, res, param, opt);

@@ -423,21 +458,21 @@ });

function mmbexpr(node, res, param, opt) {
let prmr = node.first();
var prmr = node.first();
if (prmr.name() === Node$2.PRMREXPR) {
let first = prmr.first();
var first = prmr.first();
if (first.isToken()) {
let me = first.token().content();
var me = first.token().content();
if (me === 'this') {
let dot = node.leaf(1);
var dot = node.leaf(1);
if (dot.isToken()) {
if (dot.token().content() === '.') {
let token = dot.next();
let id = token.token().content();
var token = dot.next();
var id = token.token().content();
if (id === 'model') {
if (node.name() === Node$2.MMBEXPR) {
let next = node.next();
var next = node.next();

@@ -449,10 +484,11 @@ if (next.isToken()) {

if (next.isToken()) {
let token = next.token();
res['model.' + token.content()] = true;
var _token = next.token();
res['model.' + _token.content()] = true;
}
} else if (next.token().content() === '[') {
let expr = next.next();
var expr = next.next();
if (expr.name() === Node$2.PRMREXPR) {
let s = expr.first();
var s = expr.first();

@@ -474,18 +510,18 @@ if (s.isToken()) {

} else if (dot.token().content() === '[') {
let expr = dot.next();
var _expr = dot.next();
if (expr.name() === Node$2.EXPR) {
parse$2(expr.last(), res, param, opt);
} else if (expr.name() === Node$2.PRMREXPR) {
let s = expr.first();
if (_expr.name() === Node$2.EXPR) {
parse$2(_expr.last(), res, param, opt);
} else if (_expr.name() === Node$2.PRMREXPR) {
var _s = _expr.first();
if (s.isToken()) {
s = s.token();
if (_s.isToken()) {
_s = _s.token();
if (s.type() === Token$2.STRING) {
res[s.val()] = true;
if (_s.type() === Token$2.STRING) {
res[_s.val()] = true;
}
}
} else {
parse$2(expr, res, param, opt);
parse$2(_expr, res, param, opt);
}

@@ -495,12 +531,12 @@ }

} else {
let bracket = node.leaf(1);
var bracket = node.leaf(1);
if (bracket.isToken()) {
if (bracket.token().content() === '[') {
let expr = bracket.next();
var _expr2 = bracket.next();
if (expr.name() === Node$2.EXPR) {
parse$2(expr.last(), res, param, opt);
if (_expr2.name() === Node$2.EXPR) {
parse$2(_expr2.last(), res, param, opt);
} else {
parse$2(expr, res, param, opt);
parse$2(_expr2, res, param, opt);
}

@@ -515,21 +551,22 @@ }

mmbexpr(prmr, res, param, opt);
let dot = prmr.next();
if (dot.isToken() && dot.token().content() === '[') {
let expr = dot.next();
var _dot = prmr.next();
if (expr.name() === Node$2.EXPR) {
parse$2(expr.last(), res, param, opt);
} else if (expr.name() === Node$2.PRMREXPR) {
let s = expr.first();
if (_dot.isToken() && _dot.token().content() === '[') {
var _expr3 = _dot.next();
if (s.isToken()) {
s = s.token();
if (_expr3.name() === Node$2.EXPR) {
parse$2(_expr3.last(), res, param, opt);
} else if (_expr3.name() === Node$2.PRMREXPR) {
var _s2 = _expr3.first();
if (s.type() === Token$2.STRING) {
res[s.val()] = true;
if (_s2.isToken()) {
_s2 = _s2.token();
if (_s2.type() === Token$2.STRING) {
res[_s2.val()] = true;
}
}
} else {
parse$2(expr, res, param, opt);
parse$2(_expr3, res, param, opt);
}

@@ -544,3 +581,3 @@ }

parse$2(node.first(), res, param, opt);
let args = node.last();
var args = node.last();

@@ -568,3 +605,3 @@ if (args.name() === Node$2.ARGS) {

if (node.size() > 2) {
let leaf = node.leaf(1);
var leaf = node.leaf(1);

@@ -578,7 +615,7 @@ if (!leaf.isToken()) {

function linkage (node, param, opt) {
let res = {}; // 取得全部this.xxx
var res = {}; // 取得全部this.xxx
parse$2(node, res, param, opt);
let arr = Object.keys(res);
let bind = false;
var arr = Object.keys(res);
var bind = false;
arr = arr.filter(function (item) {

@@ -600,3 +637,3 @@ //model.xxx全部通过

arr.forEach(item => {
arr.forEach(function (item) {
if ((param.bindHash || {}).hasOwnProperty(item)) {

@@ -608,3 +645,3 @@ bind = true;

let single = false;
var single = false;

@@ -616,19 +653,19 @@ if (node.name() === Node$2.MMBEXPR && node.leaves().length === 3 && node.first().name() === Node$2.PRMREXPR) {

} else if (node.name() === Node$2.PRMREXPR && node.first().name() === Node$2.CPEAPL) {
let cpeapl = node.first();
var _cpeapl = node.first();
if (cpeapl.leaves().length === 3 && cpeapl.leaf(1).name() === Node$2.EXPR) {
let expr = cpeapl.leaf(1);
if (_cpeapl.leaves().length === 3 && _cpeapl.leaf(1).name() === Node$2.EXPR) {
var expr = _cpeapl.leaf(1);
if (expr.last().name() === Node$2.MMBEXPR) {
let mmbexpr = expr.last();
var _mmbexpr = expr.last();
if (mmbexpr.leaves().length === 3 && mmbexpr.first().name() === Node$2.PRMREXPR && mmbexpr.last().isToken()) {
single = arr.length && mmbexpr.first().first().isToken() && mmbexpr.first().first().token().content() === 'this' && mmbexpr.last().token().content() === arr[arr.length - 1];
if (_mmbexpr.leaves().length === 3 && _mmbexpr.first().name() === Node$2.PRMREXPR && _mmbexpr.last().isToken()) {
single = arr.length && _mmbexpr.first().first().isToken() && _mmbexpr.first().first().token().content() === 'this' && _mmbexpr.last().token().content() === arr[arr.length - 1];
}
}
} else if (cpeapl.leaves().length === 3 && cpeapl.leaf(1).name() === Node$2.MMBEXPR && cpeapl.first().isToken() && cpeapl.first().token().content() === '(') {
let mmbexpr = cpeapl.leaf(1);
} else if (_cpeapl.leaves().length === 3 && _cpeapl.leaf(1).name() === Node$2.MMBEXPR && _cpeapl.first().isToken() && _cpeapl.first().token().content() === '(') {
var _mmbexpr2 = _cpeapl.leaf(1);
if (mmbexpr.leaves().length === 3 && mmbexpr.first().name() === Node$2.PRMREXPR && mmbexpr.last().isToken()) {
single = arr.length && mmbexpr.first().first().isToken() && mmbexpr.first().first().token().content() === 'this' && mmbexpr.last().token().content() === arr[arr.length - 1];
if (_mmbexpr2.leaves().length === 3 && _mmbexpr2.first().name() === Node$2.PRMREXPR && _mmbexpr2.last().isToken()) {
single = arr.length && _mmbexpr2.first().first().isToken() && _mmbexpr2.first().first().token().content() === 'this' && _mmbexpr2.last().token().content() === arr[arr.length - 1];
}

@@ -639,16 +676,16 @@ }

return {
arr,
single,
bind
arr: arr,
single: single,
bind: bind
};
}
let Token$3 = homunculus.getClass('token', 'csx');
let S$1 = {};
var Token$3 = homunculus.getClass('token', 'csx');
var S$1 = {};
S$1[Token$3.LINE] = S$1[Token$3.COMMENT] = S$1[Token$3.BLANK] = true;
let res$1;
var res$1;
function recursion(node, excludeLine) {
if (node.isToken()) {
let token = node.token();
var token = node.token();

@@ -665,3 +702,3 @@ if (!token.isVirtual()) {

let s = token.content();
var s = token.content();

@@ -686,7 +723,14 @@ if (!excludeLine || s != '\n') {

let Token$4 = homunculus.getClass('token', 'csx');
let Node$3 = homunculus.getClass('node', 'csx');
var Token$4 = homunculus.getClass('token', 'csx');
var Node$3 = homunculus.getClass('node', 'csx');
class InnerTree {
constructor(opt = {}, param = {}) {
var InnerTree =
/*#__PURE__*/
function () {
function InnerTree() {
var opt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var param = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
_classCallCheck(this, InnerTree);
this.res = '';

@@ -697,120 +741,127 @@ this.opt = opt;

parse(node) {
this.recursion(node);
return this.res;
}
_createClass(InnerTree, [{
key: "parse",
value: function parse(node) {
this.recursion(node);
return this.res;
}
}, {
key: "recursion",
value: function recursion(node) {
var self = this;
var isToken = node.isToken();
recursion(node) {
let self = this;
let isToken = node.isToken();
if (isToken) {
var token = node.token();
if (isToken) {
let token = node.token();
if (token.isVirtual()) {
return;
}
if (token.isVirtual()) {
return;
}
if (!token.ignore) {
this.res += token.content();
}
if (!token.ignore) {
this.res += token.content();
}
while (token.next()) {
token = token.next();
while (token.next()) {
token = token.next();
if (token.isVirtual() || !parse.S.hasOwnProperty(token.type())) {
break;
}
if (token.isVirtual() || !parse.S.hasOwnProperty(token.type())) {
break;
if (!token.ignore) {
this.res += token.content();
}
}
} else {
switch (node.name()) {
case Node$3.CSXElement:
case Node$3.CSXSelfClosingElement:
this.res += parse$4(node, {
isInBind: self.opt.isInBind || self.opt.isBind,
arrowFn: self.opt.arrowFn
}, self.param);
return;
if (!token.ignore) {
this.res += token.content();
}
}
} else {
switch (node.name()) {
case Node$3.CSXElement:
case Node$3.CSXSelfClosingElement:
this.res += parse$4(node, {
isInBind: self.opt.isInBind || self.opt.isBind,
arrowFn: self.opt.arrowFn
}, self.param);
return;
case Node$3.RETSTMT:
if (self.opt.isBind || self.opt.isInBind) {
var allReturn = true;
self.opt.arrowFn = self.opt.arrowFn || [];
case Node$3.RETSTMT:
if (self.opt.isBind || self.opt.isInBind) {
let allReturn = true;
self.opt.arrowFn = self.opt.arrowFn || [];
for (let i = 0, len = self.opt.arrowFn.length; i < len; i++) {
if (!self.opt.arrowFn[i]) {
allReturn = false;
break;
for (var i = 0, len = self.opt.arrowFn.length; i < len; i++) {
if (!self.opt.arrowFn[i]) {
allReturn = false;
break;
}
}
}
if (allReturn) {
let temp = linkage(node.leaf(1), self.param, {
arrowFn: self.opt.arrowFn
});
let list = temp.arr;
let listener = list.length === 1 ? '"' + list[0] + '"' : JSON.stringify(list);
if (allReturn) {
var temp = linkage(node.leaf(1), self.param, {
arrowFn: self.opt.arrowFn
});
var list = temp.arr;
var listener = list.length === 1 ? '"' + list[0] + '"' : JSON.stringify(list);
if (list.length) {
return this.res += join2(node.first()) + 'new yurine.Obj(' + listener + ',()=>{return(' + new InnerTree(self.opt, self.param).parse(node.leaf(1)).replace(/^(\s*){/, '$1').replace(/}(\s*)$/, '$1') + ')})';
if (list.length) {
return this.res += join2(node.first()) + 'new yurine.Obj(' + listener + ',()=>{return(' + new InnerTree(self.opt, self.param).parse(node.leaf(1)).replace(/^(\s*){/, '$1').replace(/}(\s*)$/, '$1') + ')})';
}
}
}
}
break;
break;
case Node$3.ARROWFN:
self.opt.arrowFn = self.opt.arrowFn || [];
case Node$3.ARROWFN:
self.opt.arrowFn = self.opt.arrowFn || [];
if (self.opt.arrowFn.length === 0) {
self.opt.arrowFn.push(true);
} else {
let is = false;
let temp = node.parent();
if (self.opt.arrowFn.length === 0) {
self.opt.arrowFn.push(true);
} else {
var is = false;
if (temp && temp.name() === Node$3.ARGLIST) {
temp = temp.parent();
var _temp = node.parent();
if (temp && temp.name() === Node$3.ARGS) {
let callexpr = temp.parent();
temp = temp.prev();
if (_temp && _temp.name() === Node$3.ARGLIST) {
_temp = _temp.parent();
if (temp && temp.name() === Node$3.MMBEXPR) {
temp = temp.leaf(2);
if (_temp && _temp.name() === Node$3.ARGS) {
var callexpr = _temp.parent();
if (temp.isToken() && temp.token().content() === 'map') {
is = callexpr.parent().name() === Node$3.RETSTMT;
_temp = _temp.prev();
if (_temp && _temp.name() === Node$3.MMBEXPR) {
_temp = _temp.leaf(2);
if (_temp.isToken() && _temp.token().content() === 'map') {
is = callexpr.parent().name() === Node$3.RETSTMT;
}
}
}
}
self.opt.arrowFn.push(is);
}
self.opt.arrowFn.push(is);
}
break;
}
break;
}
node.leaves().forEach(function (leaf) {
self.recursion(leaf);
});
node.leaves().forEach(function (leaf) {
self.recursion(leaf);
});
switch (node.name()) {
case Node$3.ARROWFN:
self.opt.arrowFn.pop();
break;
switch (node.name()) {
case Node$3.ARROWFN:
self.opt.arrowFn.pop();
break;
}
}
}
}
}]);
}
return InnerTree;
}();
let JsNode = homunculus.getClass('Node', 'es6');
let Token$5 = homunculus.getClass('Token');
var JsNode = homunculus.getClass('Node', 'es6');
var Token$5 = homunculus.getClass('Token');
function join (node, word) {
let res = recursion$1(node, {
var res = recursion$1(node, {
's': '',

@@ -823,7 +874,7 @@ 'word': word

function recursion$1(node, res) {
let isToken = node.name() === JsNode.TOKEN;
let isVirtual = isToken && node.token().type() === Token$5.VIRTUAL;
var isToken = node.name() === JsNode.TOKEN;
var isVirtual = isToken && node.token().type() === Token$5.VIRTUAL;
if (isToken) {
let token = node.token();
var token = node.token();

@@ -854,19 +905,20 @@ if (!isVirtual) {

let Token$6 = homunculus.getClass('token', 'csx');
let Node$4 = homunculus.getClass('node', 'csx');
let S$2 = {};
var Token$6 = homunculus.getClass('token', 'csx');
var Node$4 = homunculus.getClass('node', 'csx');
var S$2 = {};
S$2[Token$6.LINE] = S$2[Token$6.COMMENT] = S$2[Token$6.BLANK] = true;
let res$2 = '';
var res$2 = '';
function parse$3(node) {
let prmr = node.leaf(1);
var prmr = node.leaf(1);
if (prmr && prmr.name() === Node$4.PRMREXPR) {
let objltr = prmr.first();
let tree = new InnerTree();
var objltr = prmr.first();
var tree = new InnerTree();
res$2 = tree.parse(node);
res$2 = res$2.replace(/^(\s*){/, '$1').replace(/}(\s*)$/, '$1');
} else {
let tree = new InnerTree();
res$2 = tree.parse(node);
var _tree = new InnerTree();
res$2 = _tree.parse(node);
res$2 = res$2.replace(/^(\s*){/, '$1').replace(/}(\s*)$/, '$1');

@@ -878,14 +930,14 @@ }

let Token$7 = homunculus.getClass('token', 'csx');
let Node$5 = homunculus.getClass('node', 'csx');
var Token$7 = homunculus.getClass('token', 'csx');
var Node$5 = homunculus.getClass('node', 'csx');
function elem(node, opt, param) {
let res = ''; //open和selfClose逻辑复用
var res = ''; //open和selfClose逻辑复用
res += selfClose(node.first(), opt, param);
res += ',[';
let comma = false;
var comma = false;
for (let i = 1, len = node.size(); i < len - 1; i++) {
let leaf = node.leaf(i);
for (var i = 1, len = node.size(); i < len - 1; i++) {
var leaf = node.leaf(i);

@@ -904,3 +956,3 @@ switch (leaf.name()) {

case Node$5.TOKEN:
let s = leaf.token().content(); //open和close之间的空白不能忽略
var s = leaf.token().content(); //open和close之间的空白不能忽略

@@ -946,5 +998,5 @@ if (/^\s+$/.test(s)) {

function selfClose(node, opt, param) {
let res = '';
let name;
let first = node.leaf(1);
var res = '';
var name;
var first = node.leaf(1);

@@ -956,3 +1008,3 @@ if (first.isToken()) {

for (let i = 1, len = first.size(); i < len; i++) {
for (var i = 1, len = first.size(); i < len; i++) {
name += first.leaf(i).token().content();

@@ -975,6 +1027,6 @@ }

for (let i = 2, len = node.size(); i < len - 1; i++) {
let leaf = node.leaf(i);
for (var _i = 2, _len = node.size(); _i < _len - 1; _i++) {
var leaf = node.leaf(_i);
if (i !== 2) {
if (_i !== 2) {
res += ',';

@@ -1003,6 +1055,6 @@ }

function attr(node, opt, param) {
let res = '';
let key = node.first().token().content();
let name = node.parent().leaf(1).token().content();
let isCp = /^[A-Z]/.test(name);
var res = '';
var key = node.first().token().content();
var name = node.parent().leaf(1).token().content();
var isCp = /^[A-Z]/.test(name);

@@ -1016,5 +1068,5 @@ if (key.charAt(0) === '@') {

let k = '["' + key + '"';
var k = '["' + key + '"';
res += k + ',';
let v = node.last();
var v = node.last();

@@ -1043,26 +1095,26 @@ if (v.isToken()) {

function child(node, opt, param, isAttr) {
let callexpr = node.leaf(1);
var callexpr = node.leaf(1);
if (opt.isBind) {
let temp = linkage(callexpr, param, {
var temp = linkage(callexpr, param, {
arrowFn: opt.arrowFn
});
let list = temp.arr;
let single = temp.single;
let bind = temp.bind;
var list = temp.arr;
var single = temp.single;
var bind = temp.bind;
if (list.length) {
let listener = list.length === 1 ? '"' + list[0] + '"' : JSON.stringify(list);
var listener = list.length === 1 ? '"' + list[0] + '"' : JSON.stringify(list);
if (isAttr) {
let key = node.prev().prev().token().content();
var key = node.prev().prev().token().content();
if (key === 'value' || key === 'checked' || key === 'selected') {
let tag = node.parent().parent().leaf(1).token().content();
var tag = node.parent().parent().leaf(1).token().content();
if (tag === 'input' || tag === 'select' || tag === 'option') {
let value = node.leaf(1); // 单独值mmbexpr非运算符双向绑定,其余单向
var value = node.leaf(1); // 单独值mmbexpr非运算符双向绑定,其余单向
if (value.name() === Node$5.MMBEXPR) {
let v = join2(value);
var v = join2(value);
return 'new yurine.Obj(' + listener + ',()=>{return(' + new InnerTree(opt, param).parse(node).replace(/^(\s*){/, '$1').replace(/}(\s*)$/, '$1') + ')}' + (single ? ',true' : ',false') + (bind ? ',(v)=>{v!==' + v + '&&(' + v + '=v)})' : ')');

@@ -1075,10 +1127,11 @@ }

} else if (node.prev() && node.prev().name() === Node$5.CSXOpeningElement) {
let key = node.prev().leaf(1).token().content();
var _key = node.prev().leaf(1).token().content();
if (key === 'textarea') {
let value = node.leaf(1);
if (_key === 'textarea') {
var _value = node.leaf(1);
if (value.name() === Node$5.MMBEXPR) {
let v = join2(value);
return 'new yurine.Obj(' + listener + ',()=>{return(' + new InnerTree(opt, param).parse(node).replace(/^(\s*){/, '$1').replace(/}(\s*)$/, '$1') + ')}' + (single ? ',true' : ',false') + (bind ? ',(v)=>{v!==' + v + '&&(' + v + '=v)})' : ')');
if (_value.name() === Node$5.MMBEXPR) {
var _v = join2(_value);
return 'new yurine.Obj(' + listener + ',()=>{return(' + new InnerTree(opt, param).parse(node).replace(/^(\s*){/, '$1').replace(/}(\s*)$/, '$1') + ')}' + (single ? ',true' : ',false') + (bind ? ',(v)=>{v!==' + _v + '&&(' + _v + '=v)})' : ')');
}

@@ -1093,24 +1146,27 @@ }

if (isAttr) {
let key = node.prev().prev().token().content();
var _key2 = node.prev().prev().token().content();
if (key === 'value') {
let tag = node.parent().parent().leaf(1).token().content();
if (_key2 === 'value') {
var _tag = node.parent().parent().leaf(1).token().content();
if (tag === 'input' || tag === 'select') {
let temp = linkage(callexpr, param, {
if (_tag === 'input' || _tag === 'select') {
var _temp = linkage(callexpr, param, {
arrowFn: opt.arrowFn
});
let list = temp.arr;
let bind = temp.bind;
if (list.length) {
let value = node.leaf(1);
let listener = list.length === 1 ? '"' + list[0] + '"' : JSON.stringify(list);
var _list = _temp.arr;
var _bind = _temp.bind;
if (value.name() === Node$5.MMBEXPR) {
let v = join2(value);
return 'new yurine.Obj(' + listener + ',()=>{return(' + new InnerTree(opt, param).parse(node).replace(/^(\s*){/, '$1').replace(/}(\s*)$/, '$1') + ')}' + ',false' + (bind ? ',(v)=>{v!==' + v + '&&(' + v + '=v)})' : ')');
if (_list.length) {
var _value2 = node.leaf(1);
var _listener = _list.length === 1 ? '"' + _list[0] + '"' : JSON.stringify(_list);
if (_value2.name() === Node$5.MMBEXPR) {
var _v2 = join2(_value2);
return 'new yurine.Obj(' + _listener + ',()=>{return(' + new InnerTree(opt, param).parse(node).replace(/^(\s*){/, '$1').replace(/}(\s*)$/, '$1') + ')}' + ',false' + (_bind ? ',(v)=>{v!==' + _v2 + '&&(' + _v2 + '=v)})' : ')');
}
return 'new yurine.Obj(' + listener + ',()=>{return(' + new InnerTree(opt, param).parse(node).replace(/^(\s*){/, '$1').replace(/}(\s*)$/, '$1') + ')})';
return 'new yurine.Obj(' + _listener + ',()=>{return(' + new InnerTree(opt, param).parse(node).replace(/^(\s*){/, '$1').replace(/}(\s*)$/, '$1') + ')})';
}

@@ -1120,21 +1176,24 @@ }

} else if (node.prev() && node.prev().name() === Node$5.CSXOpeningElement) {
let key = node.prev().leaf(1).token().content();
var _key3 = node.prev().leaf(1).token().content();
if (key === 'textarea') {
let temp = linkage(callexpr, param, {
if (_key3 === 'textarea') {
var _temp2 = linkage(callexpr, param, {
arrowFn: opt.arrowFn
});
let list = temp.arr;
let bind = temp.bind;
if (list.length) {
let value = node.leaf(1);
let listener = list.length === 1 ? '"' + list[0] + '"' : JSON.stringify(list);
var _list2 = _temp2.arr;
var _bind2 = _temp2.bind;
if (value.name() === Node$5.MMBEXPR) {
let v = join2(value);
return 'new yurine.Obj(' + listener + ',()=>{return(' + new InnerTree(opt, param).parse(node).replace(/^(\s*){/, '$1').replace(/}(\s*)$/, '$1') + ')}' + ',false' + (bind ? ',(v)=>{v!==' + v + '&&(' + v + '=v)})' : ')');
if (_list2.length) {
var _value3 = node.leaf(1);
var _listener2 = _list2.length === 1 ? '"' + _list2[0] + '"' : JSON.stringify(_list2);
if (_value3.name() === Node$5.MMBEXPR) {
var _v3 = join2(_value3);
return 'new yurine.Obj(' + _listener2 + ',()=>{return(' + new InnerTree(opt, param).parse(node).replace(/^(\s*){/, '$1').replace(/}(\s*)$/, '$1') + ')}' + ',false' + (_bind2 ? ',(v)=>{v!==' + _v3 + '&&(' + _v3 + '=v)})' : ')');
}
return 'new yurine.Obj(' + listener + ',()=>{return(' + new InnerTree(opt, param).parse(node).replace(/^(\s*){/, '$1').replace(/}(\s*)$/, '$1') + ')})';
return 'new yurine.Obj(' + _listener2 + ',()=>{return(' + new InnerTree(opt, param).parse(node).replace(/^(\s*){/, '$1').replace(/}(\s*)$/, '$1') + ')})';
}

@@ -1149,3 +1208,3 @@ }

function parse$4(node, opt, param) {
let res = '';
var res = '';

@@ -1166,5 +1225,5 @@ switch (node.name()) {

let Token$8 = homunculus.getClass('token', 'csx');
let Node$6 = homunculus.getClass('node', 'csx');
let res$3;
var Token$8 = homunculus.getClass('token', 'csx');
var Node$6 = homunculus.getClass('node', 'csx');
var res$3;

@@ -1177,3 +1236,3 @@ function stmt(node, param) {

if (node.isToken()) {
let token = node.token();
var token = node.token();

@@ -1211,3 +1270,3 @@ if (token.isVirtual()) {

case Node$6.CLASSEXPR:
let tree = new InnerTree();
var tree = new InnerTree();
res$3 += tree.parse(node);

@@ -1225,3 +1284,3 @@ return;

res$3 = '';
let len = node.size();
var len = node.size();
node.leaves().forEach(function (leaf, i) {

@@ -1240,34 +1299,30 @@ //fnbody

let Node$7 = homunculus.getClass('node', 'csx');
var Node$7 = homunculus.getClass('node', 'csx');
class Tree {
constructor() {
var Tree =
/*#__PURE__*/
function () {
function Tree() {
_classCallCheck(this, Tree);
this.res = '';
}
parse(node) {
this.recursion(node, false);
return this.res;
}
_createClass(Tree, [{
key: "parse",
value: function parse(node) {
this.recursion(node, false);
return this.res;
}
}, {
key: "recursion",
value: function recursion(node, inClass) {
var self = this;
var isToken = node.isToken();
recursion(node, inClass) {
let self = this;
let isToken = node.isToken();
if (isToken) {
var token = node.token();
if (isToken) {
let token = node.token();
if (token.isVirtual()) {
return;
}
if (!token.ignore) {
this.res += token.content();
}
while (token.next()) {
token = token.next();
if (token.isVirtual() || !parse.S.hasOwnProperty(token.type())) {
break;
if (token.isVirtual()) {
return;
}

@@ -1278,106 +1333,119 @@

}
}
} else {
switch (node.name()) {
case Node$7.CSXElement:
case Node$7.CSXSelfClosingElement:
this.res += parse$4(node, {}, this.param);
return;
case Node$7.CLASSDECL:
inClass = this.klass(node);
break;
while (token.next()) {
token = token.next();
case Node$7.CLASSEXPR:
inClass = this.klass(node);
break;
if (token.isVirtual() || !parse.S.hasOwnProperty(token.type())) {
break;
}
case Node$7.CLASSBODY:
if (inClass) {
this.param = {
getHash: {},
setHash: {},
evalHash: {},
bindHash: {},
linkHash: {},
linkedHash: {}
};
this.list(node);
if (!token.ignore) {
this.res += token.content();
}
}
} else {
switch (node.name()) {
case Node$7.CSXElement:
case Node$7.CSXSelfClosingElement:
this.res += parse$4(node, {}, this.param);
return;
break;
case Node$7.CLASSDECL:
inClass = this.klass(node);
break;
case Node$7.METHOD:
let isRender = this.method(node);
case Node$7.CLASSEXPR:
inClass = this.klass(node);
break;
if (isRender) {
this.res += parse$5(node, this.param || {});
return;
}
case Node$7.CLASSBODY:
if (inClass) {
this.param = {
getHash: {},
setHash: {},
evalHash: {},
bindHash: {},
linkHash: {},
linkedHash: {}
};
this.list(node);
}
break;
break;
case Node$7.ANNOT:
if (['@bind', '@eval', '@link'].indexOf(node.first().token().content()) > -1) {
this.res += parse(node, true).res;
} else {
this.res += join2(node);
}
case Node$7.METHOD:
var isRender = this.method(node);
return;
if (isRender) {
this.res += parse$5(node, this.param || {});
return;
}
case Node$7.LEXBIND:
if (inClass && node.parent().name() === Node$7.CLASSELEM) {
this.res += this.bindLex(node);
break;
case Node$7.ANNOT:
if (['@bind', '@eval', '@link'].indexOf(node.first().token().content()) > -1) {
this.res += parse(node, true).res;
} else {
this.res += join2(node);
}
return;
}
break;
}
case Node$7.LEXBIND:
if (inClass && node.parent().name() === Node$7.CLASSELEM) {
this.res += this.bindLex(node);
return;
}
node.leaves().forEach(function (leaf) {
self.recursion(leaf, inClass);
});
break;
}
switch (node.name()) {
case Node$7.FNBODY:
this.fnbody(node, inClass);
break;
node.leaves().forEach(function (leaf) {
self.recursion(leaf, inClass);
});
case Node$7.CLASSDECL:
inClass = false;
break;
switch (node.name()) {
case Node$7.FNBODY:
this.fnbody(node, inClass);
break;
case Node$7.CLASSEXPR:
inClass = false;
break;
case Node$7.CLASSDECL:
inClass = false;
break;
case Node$7.CLASSEXPR:
inClass = false;
break;
}
}
}
}
}, {
key: "klass",
value: function klass(node) {
var heritage = node.leaf(2);
klass(node) {
let heritage = node.leaf(2);
if (heritage && heritage.name() === Node$7.HERITAGE) {
var body = node.last().prev();
var leaves = body.leaves();
if (heritage && heritage.name() === Node$7.HERITAGE) {
let body = node.last().prev();
let leaves = body.leaves();
for (var i = 0, len = leaves.length; i < len; i++) {
var leaf = leaves[i];
var method = leaf.first();
for (let i = 0, len = leaves.length; i < len; i++) {
let leaf = leaves[i];
let method = leaf.first();
if (method.name() === Node$7.METHOD) {
var first = method.first();
if (method.name() === Node$7.METHOD) {
let first = method.first();
if (first.name() === Node$7.PROPTNAME) {
var id = first.first();
if (first.name() === Node$7.PROPTNAME) {
let id = first.first();
if (id.name() === Node$7.LTRPROPT) {
id = id.first();
if (id.name() === Node$7.LTRPROPT) {
id = id.first();
if (id.isToken()) {
id = id.token().content();
if (id.isToken()) {
id = id.token().content();
if (id === 'constructor') {
return true;
if (id === 'constructor') {
return true;
}
}

@@ -1389,241 +1457,255 @@ }

}
return false;
}
}, {
key: "method",
value: function method(node) {
var first = node.first();
return false;
}
if (first.name() === Node$7.PROPTNAME) {
first = first.first();
method(node) {
let first = node.first();
if (first.name() === Node$7.LTRPROPT) {
first = first.first();
if (first.name() === Node$7.PROPTNAME) {
first = first.first();
if (first.name() === Node$7.LTRPROPT) {
first = first.first();
if (first.isToken() && first.token().content() === 'render') {
return true;
if (first.isToken() && first.token().content() === 'render') {
return true;
}
}
}
}
}
}, {
key: "fnbody",
value: function fnbody(node, inClass) {
if (!inClass) {
return;
}
fnbody(node, inClass) {
if (!inClass) {
return;
}
var parent = node.parent();
let parent = node.parent();
if (parent.name() === Node$7.METHOD) {
var setV;
var first = parent.first();
if (parent.name() === Node$7.METHOD) {
let setV;
let first = parent.first();
if (first.isToken() && first.token().content() === 'set') {
var fmparams = parent.leaf(3);
if (first.isToken() && first.token().content() === 'set') {
let fmparams = parent.leaf(3);
if (fmparams && fmparams.name() === Node$7.FMPARAMS) {
var single = fmparams.first();
if (fmparams && fmparams.name() === Node$7.FMPARAMS) {
let single = fmparams.first();
if (single && single.name() === Node$7.SINGLENAME) {
var bindid = single.first();
if (single && single.name() === Node$7.SINGLENAME) {
let bindid = single.first();
if (bindid && bindid.name() === Node$7.BINDID) {
setV = bindid.first().token().content();
if (bindid && bindid.name() === Node$7.BINDID) {
setV = bindid.first().token().content();
}
}
}
}
let name = parent.leaf(1).first().first().token().content();
let prev = parent.parent().prev();
let ids = [];
var name = parent.leaf(1).first().first().token().content();
var prev = parent.parent().prev();
var ids = [];
if (prev) {
prev = prev.first();
if (prev) {
prev = prev.first();
if (prev.name() === Node$7.ANNOT && ['@bind', '@eval'].indexOf(prev.first().token().content()) > -1) {
ids.push(name);
if (prev.name() === Node$7.ANNOT && ['@bind', '@eval'].indexOf(prev.first().token().content()) > -1) {
ids.push(name);
}
}
}
ids = ids.concat(this.param.linkedHash[name] || []);
ids = ids.concat(this.param.linkedHash[name] || []);
if (ids.length) {
if (setV) {
if (ids.length) {
if (setV) {
if (ids.length === 1) {
this.res += ';this.__array("';
this.res += ids[0] + '",';
this.res += setV;
this.res += ')';
} else {
this.res += ';this.__array(["';
this.res += ids.join('","') + '"],';
this.res += setV;
this.res += ')';
}
}
if (ids.length === 1) {
this.res += ';this.__array("';
this.res += ids[0] + '",';
this.res += setV;
this.res += ')';
this.res += ';this.__data("';
this.res += ids[0];
this.res += '")';
} else {
this.res += ';this.__array(["';
this.res += ids.join('","') + '"],';
this.res += setV;
this.res += ')';
this.res += ';this.__data(["';
this.res += ids.join('","');
this.res += '"])';
}
}
if (ids.length === 1) {
this.res += ';this.__data("';
this.res += ids[0];
this.res += '")';
} else {
this.res += ';this.__data(["';
this.res += ids.join('","');
this.res += '"])';
}
}
}
}
}
}, {
key: "list",
value: function list(node) {
var _this = this;
list(node) {
let leaves = node.leaves();
let length = leaves.length;
var leaves = node.leaves();
var length = leaves.length;
for (let i = 0; i < length; i++) {
let item = leaves[i].first();
for (var i = 0; i < length; i++) {
var item = leaves[i].first();
if (item.name() === Node$7.ANNOT) {
let annot = item.first().token().content();
let method = leaves[i + 1] ? leaves[i + 1].first() : null;
if (item.name() === Node$7.ANNOT) {
var annot = item.first().token().content();
var method = leaves[i + 1] ? leaves[i + 1].first() : null;
if (method && method.name() === Node$7.METHOD) {
let first = method.first();
if (method && method.name() === Node$7.METHOD) {
var first = method.first();
if (first.isToken()) {
let token = first.token().content();
if (first.isToken()) {
var token = first.token().content();
if (token === 'set' && annot === '@bind') {
let name = first.next().first().first().token().content();
this.param.bindHash[name] = true;
} else if (token === 'set' && annot === '@eval') {
let name = first.next().first().first().token().content();
this.param.evalHash[name] = true;
} else if (token === 'get' && annot === '@link') {
let name = first.next().first().first().token().content();
this.param.linkHash[name] = this.param.linkHash[name] || [];
let params = item.leaf(2);
if (token === 'set' && annot === '@bind') {
var name = first.next().first().first().token().content();
this.param.bindHash[name] = true;
} else if (token === 'set' && annot === '@eval') {
var _name = first.next().first().first().token().content();
if (params && params.name() === Node$7.FMPARAMS) {
params.leaves().forEach(function (param) {
if (param.name() === Node$7.SINGLENAME) {
param = param.first();
this.param.evalHash[_name] = true;
} else if (token === 'get' && annot === '@link') {
(function () {
var name = first.next().first().first().token().content();
_this.param.linkHash[name] = _this.param.linkHash[name] || [];
var params = item.leaf(2);
if (param.name() === Node$7.BINDID) {
param = param.first();
if (params && params.name() === Node$7.FMPARAMS) {
params.leaves().forEach(function (param) {
if (param.name() === Node$7.SINGLENAME) {
param = param.first();
if (param.isToken()) {
param = param.token().content();
this.param.linkHash[name].push(param);
this.param.linkedHash[param] = this.param.linkedHash[param] || [];
this.param.linkedHash[param].push(name);
if (param.name() === Node$7.BINDID) {
param = param.first();
if (param.isToken()) {
param = param.token().content();
this.param.linkHash[name].push(param);
this.param.linkedHash[param] = this.param.linkedHash[param] || [];
this.param.linkedHash[param].push(name);
}
}
}
}
}.bind(_this));
}
}.bind(this));
})();
}
}
}
} else if (method && method.name() === Node$7.LEXBIND) {
let first = method.first();
} else if (method && method.name() === Node$7.LEXBIND) {
var _first = method.first();
if (first.name() === Node$7.BINDID) {
let name = first.first().token().content();
parseLex(this.param, name, item, annot);
}
} //连续2个
else if (method && method.name() === Node$7.ANNOT) {
let item2 = method;
let annot2 = method.first().token().content();
method = leaves[i + 2] ? leaves[i + 2].first() : null;
if (_first.name() === Node$7.BINDID) {
var _name2 = _first.first().token().content();
if (method && method.name() === Node$7.LEXBIND) {
let first = method.first();
parseLex(this.param, _name2, item, annot);
}
} //连续2个
else if (method && method.name() === Node$7.ANNOT) {
var item2 = method;
var annot2 = method.first().token().content();
method = leaves[i + 2] ? leaves[i + 2].first() : null;
if (first.name() === Node$7.BINDID) {
let name = first.first().token().content();
parseLex(this.param, name, item, annot);
parseLex(this.param, name, item2, annot2);
if (method && method.name() === Node$7.LEXBIND) {
var _first2 = method.first();
if (_first2.name() === Node$7.BINDID) {
var _name3 = _first2.first().token().content();
parseLex(this.param, _name3, item, annot);
parseLex(this.param, _name3, item2, annot2);
}
}
}
} else if (item.name() === Node$7.METHOD) {
var _first3 = item.first();
if (_first3.isToken()) {
var _token = _first3.token().content();
var _name4 = _first3.next().first().first().token().content();
if (_token === 'get') {
this.param.getHash[_name4] = true;
} else if (_token === 'set') {
this.param.setHash[_name4] = true;
}
}
} else if (item.name() === Node$7.METHOD) {
let first = item.first();
} else if (item.name() === Node$7.LEXBIND) {
var _first4 = item.first();
if (first.isToken()) {
let token = first.token().content();
let name = first.next().first().first().token().content();
if (_first4.name() === Node$7.BINDID) {
var _name5 = _first4.first().token().content();
if (token === 'get') {
this.param.getHash[name] = true;
} else if (token === 'set') {
this.param.setHash[name] = true;
this.param.getHash[_name5] = true;
this.param.setHash[_name5] = true;
}
}
} else if (item.name() === Node$7.LEXBIND) {
let first = item.first();
if (first.name() === Node$7.BINDID) {
let name = first.first().token().content();
this.param.getHash[name] = true;
this.param.setHash[name] = true;
}
}
}
}
}, {
key: "bindLex",
value: function bindLex(node) {
var parent = node.parent();
var bindid = node.first();
bindLex(node) {
let parent = node.parent();
let bindid = node.first();
if (bindid.name() === Node$7.BINDID) {
var token = bindid.first();
var name = token.token().content();
var init = node.leaf(1);
var ids = [];
var prev = parent.prev();
if (bindid.name() === Node$7.BINDID) {
let token = bindid.first();
let name = token.token().content();
let init = node.leaf(1);
let ids = [];
let prev = parent.prev();
if (prev) {
prev = prev.first();
if (prev) {
prev = prev.first();
if (prev.name() === Node$7.ANNOT && ['@bind', '@eval'].indexOf(prev.first().token().content()) > -1) {
ids.push(name);
}
}
if (prev.name() === Node$7.ANNOT && ['@bind', '@eval'].indexOf(prev.first().token().content()) > -1) {
ids.push(name);
ids = ids.concat(this.param.linkedHash[name] || []);
var s = '';
s += 'set ' + name + '(v){';
s += 'this.__setBind("' + name + '",v)';
if (ids.length) {
if (ids.length === 1) {
s += ';this.__data("';
s += ids[0];
s += '")';
} else {
s += ';this.__data(["';
s += ids.join('","');
s += '"])';
}
}
}
ids = ids.concat(this.param.linkedHash[name] || []);
let s = '';
s += 'set ' + name + '(v){';
s += 'this.__setBind("' + name + '",v)';
s += '}get ' + name + '(){';
s += parse(token).res;
if (ids.length) {
if (ids.length === 1) {
s += ';this.__data("';
s += ids[0];
s += '")';
} else {
s += ';this.__data(["';
s += ids.join('","');
s += '"])';
if (init) {
s += 'if(this.__initBind("' + name + '"))';
s += 'this.__setBind("' + name + '",';
s += parse(init.first()).res;
s += join2(init.last());
s += ');';
}
}
s += '}get ' + name + '(){';
s += parse(token).res;
if (init) {
s += 'if(this.__initBind("' + name + '"))';
s += 'this.__setBind("' + name + '",';
s += parse(init.first()).res;
s += join2(init.last());
s += ');';
s += 'return this.__getBind("' + name + '")}';
return s;
}
s += 'return this.__getBind("' + name + '")}';
return s;
}
}
}]);
}
return Tree;
}();

@@ -1637,3 +1719,3 @@ function parseLex(param, name, item, annot) {

param.linkHash[name] = param.linkHash[name] || [];
let params = item.leaf(2);
var params = item.leaf(2);

@@ -1661,4 +1743,8 @@ if (params && params.name() === Node$7.FMPARAMS) {

class Yurine {
constructor() {
var Yurine =
/*#__PURE__*/
function () {
function Yurine() {
_classCallCheck(this, Yurine);
this.parser = null;

@@ -1668,23 +1754,30 @@ this.node = null;

parse(code) {
this.parser = homunculus.getParser('csx');
this.node = this.parser.parse(code);
let tree = new Tree();
return tree.parse(this.node);
}
_createClass(Yurine, [{
key: "parse",
value: function parse(code) {
this.parser = homunculus.getParser('csx');
this.node = this.parser.parse(code);
var tree = new Tree();
return tree.parse(this.node);
}
}, {
key: "tokens",
value: function tokens() {
return this.ast ? this.parser.lexer.tokens() : null;
}
}, {
key: "ast",
value: function ast() {
return this.node;
}
}], [{
key: "parse",
value: function parse(code) {
return new Yurine().parse(code);
}
}]);
tokens() {
return this.ast ? this.parser.lexer.tokens() : null;
}
return Yurine;
}();
ast() {
return this.node;
}
static parse(code) {
return new Yurine().parse(code);
}
}
var Yurine$1 = new Yurine();

@@ -1691,0 +1784,0 @@

Sorry, the diff of this file is not supported yet

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