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.3.1 to 0.4.0

101

index.js

@@ -127,5 +127,6 @@ (function (global, factory) {

function elem(node) {
var res = ''; //open和selfClose逻辑复用
var res = '';
var tag = selfClose(node.first()); //open和selfClose逻辑复用
res += selfClose(node.first());
res += tag.res;
res += ',[';

@@ -180,4 +181,10 @@ var comma = false;

res += '])';
res += ']';
if (tag.isCp && tag.name) {
res += ',"' + tag.name + '"';
}
res += ')';
if (node.last().name() === Node$1.CSXClosingElement) {

@@ -190,3 +197,3 @@ res += parse(node.last(), true).res;

function selfClose(node) {
function selfClose(node, isClose) {
var res = '';

@@ -206,3 +213,5 @@ var name;

if (/^[A-Z]/.test(name)) {
var isCp = /^[A-Z]/.test(name);
if (isCp) {
res += 'karas.createCp(';

@@ -218,3 +227,3 @@ res += name;

res += ',[';
res += ',{';

@@ -243,4 +252,13 @@ for (var _i = 2, _len = node.size(); _i < _len - 1; _i++) {

res += ']';
return res;
res += '}';
if (isClose && isCp) {
res += ',[],"' + name + '"';
}
return {
res: res,
isCp: isCp,
name: name
};
}

@@ -251,6 +269,3 @@

var key = node.first().token().content();
var name = node.parent().leaf(1).token().content();
var isCp = /^[A-Z]/.test(name);
var k = '["' + key + '"';
res += k + ',';
res += '"' + key + '":';
var v = node.last();

@@ -265,3 +280,2 @@

res += ']';
return res;

@@ -278,2 +292,56 @@ }

function fragment(node) {
var res = 'karas.createFg([';
var comma = false;
for (var i = 2, len = node.size(); i < len - 2; i++) {
var leaf = node.leaf(i);
switch (leaf.name()) {
case Node$1.CSXChild:
if (comma) {
res += ',';
comma = false;
}
res += child(leaf);
comma = true;
break;
case Node$1.TOKEN:
var s = leaf.token().content(); //open和close之间的空白不能忽略
if (/^\s+$/.test(s)) {
if (leaf.prev().name() === Node$1.CSXOpeningElement && leaf.next().name() === Node$1.CSXClosingElement) {
res += '"' + s.replace(/"/g, '\\"').replace(/\r/g, '\\r').replace(/\n/g, '\\n\\\n') + '"';
} else {
res += s;
}
} else {
if (comma) {
res += ',';
comma = false;
}
res += '"' + s.replace(/"/g, '\\"').replace(/\r/g, '\\r').replace(/\n/g, '\\n\\\n') + '"';
comma = true;
}
break;
default:
if (comma) {
res += ',';
comma = false;
}
res += parse$1(leaf);
comma = true;
}
}
res += '])';
return res;
}
function parse$1(node) {

@@ -288,5 +356,9 @@ var res = '';

case Node$1.CSXSelfClosingElement:
res += selfClose(node);
res += selfClose(node, true).res;
res += ')';
break;
case Node$1.CSXFragment:
res += fragment(node);
break;
}

@@ -346,2 +418,3 @@

case Node$2.CSXSelfClosingElement:
case Node$2.CSXFragment:
this.res += parse$1(node);

@@ -348,0 +421,0 @@ return;

4

package.json
{
"name": "yurine",
"version": "0.3.1",
"version": "0.4.0",
"description": "A csx transformer for karas",

@@ -28,3 +28,3 @@ "author": "army8735 <army8735@qq.com>",

"dependencies": {
"homunculus": "~1.6.0"
"homunculus": "~1.6.5"
},

@@ -31,0 +31,0 @@ "devDependencies": {

@@ -11,4 +11,5 @@ import homunculus from 'homunculus';

let res = '';
let tag = selfClose(node.first());
//open和selfClose逻辑复用
res += selfClose(node.first());
res += tag.res;
res += ',[';

@@ -56,3 +57,7 @@ let comma = false;

}
res += '])';
res += ']';
if(tag.isCp && tag.name) {
res += ',"' + tag.name + '"';
}
res += ')';
if(node.last().name() === Node.CSXClosingElement) {

@@ -63,3 +68,4 @@ res += ignore(node.last(), true).res;

}
function selfClose(node) {
function selfClose(node, isClose) {
let res = '';

@@ -77,3 +83,4 @@ let name;

}
if(/^[A-Z]/.test(name)) {
let isCp = /^[A-Z]/.test(name);
if(isCp) {
res += 'karas.createCp(';

@@ -90,3 +97,3 @@ res += name;

}
res += ',[';
res += ',{';
for(let i = 2, len = node.size(); i < len - 1; i++) {

@@ -109,12 +116,17 @@ let leaf = node.leaf(i);

}
res += ']';
return res;
res += '}';
if(isClose && isCp) {
res += ',[],"' + name + '"';
}
return {
res,
isCp,
name,
};
}
function attr(node) {
let res = '';
let key = node.first().token().content();
let name = node.parent().leaf(1).token().content();
let isCp = /^[A-Z]/.test(name);
let k = '["' + key + '"';
res += k + ',';
res += '"' + key + '":';
let v = node.last();

@@ -128,8 +140,9 @@ if(v.isToken()) {

}
res += ']';
return res;
}
function spread(node) {
return join(node.leaf(2));
}
function child(node) {

@@ -139,2 +152,49 @@ return new Tree().parse(node).replace(/^(\s*){/, '$1').replace(/}(\s*)$/, '$1');

function fragment(node) {
let res = 'karas.createFg([';
let comma = false;
for(let i = 2, len = node.size(); i < len - 2; i++) {
let leaf = node.leaf(i);
switch(leaf.name()) {
case Node.CSXChild:
if(comma) {
res += ',';
comma = false;
}
res += child(leaf);
comma = true;
break;
case Node.TOKEN:
let s = leaf.token().content();
//open和close之间的空白不能忽略
if(/^\s+$/.test(s)) {
if(leaf.prev().name() === Node.CSXOpeningElement && leaf.next().name() === Node.CSXClosingElement) {
res += '"' + s.replace(/"/g, '\\"').replace(/\r/g, '\\r').replace(/\n/g, '\\n\\\n') + '"';
}
else {
res += s;
}
}
else {
if(comma) {
res += ',';
comma = false;
}
res += '"' + s.replace(/"/g, '\\"').replace(/\r/g, '\\r').replace(/\n/g, '\\n\\\n') + '"';
comma = true;
}
break;
default:
if(comma) {
res += ',';
comma = false;
}
res += parse(leaf);
comma = true;
}
}
res += '])';
return res;
}
function parse(node) {

@@ -147,5 +207,8 @@ let res = '';

case Node.CSXSelfClosingElement:
res += selfClose(node);
res += selfClose(node, true).res;
res += ')';
break;
case Node.CSXFragment:
res += fragment(node);
break;
}

@@ -152,0 +215,0 @@ return res;

@@ -40,2 +40,3 @@ import homunculus from 'homunculus';

case Node.CSXSelfClosingElement:
case Node.CSXFragment:
this.res += csx(node, {});

@@ -42,0 +43,0 @@ return;

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