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

@dcloudio/uni-nvue-styler

Package Overview
Dependencies
Maintainers
9
Versions
424
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dcloudio/uni-nvue-styler - npm Package Compare versions

Comparing version 0.0.1-nvue3.3040020220215001 to 0.0.1-nvue3.3040020220217001

99

dist/uni-nvue-styler.cjs.js

@@ -50,2 +50,3 @@ 'use strict';

const COMBINATORS_RE = /^((?:(?:\.[A-Za-z0-9_\-]+)+[\+\~\> ])*)((?:\.[A-Za-z0-9_\-\:]+)+)$/;
function createDecl(prop, value, important, raws, source) {

@@ -924,5 +925,2 @@ return {

function normalize(opts = {}) {
if (!hasOwn(opts, 'descendant')) {
opts.descendant = false;
}
if (!hasOwn(opts, 'logLevel')) {

@@ -936,7 +934,7 @@ opts.logLevel = 'WARNING';

{
plugin.Rule = createRuleProcessor(opts);
plugin.Rule = createRuleProcessor();
}
return plugin;
}
function createRuleProcessor({ descendant }) {
function createRuleProcessor() {
return (rule, helper) => {

@@ -946,9 +944,9 @@ if (rule[normalized]) {

}
const regx = descendant
? /^((?:(?:\.[A-Za-z0-9_\-]+)+[\+\~\> ])*)((?:\.[A-Za-z0-9_\-\:]+)+)$/
: /^(\.)([A-Za-z0-9_\-:]+)$/;
rule.selector = rule.selectors
.filter((selector) => {
if (regx.test(selector)) {
return true;
.map((selector) => {
selector = selector
.replace(/\s*([\+\~\>])\s*/g, '$1')
.replace(/\s+/, ' ');
if (COMBINATORS_RE.test(selector)) {
return selector;
}

@@ -958,4 +956,5 @@ rule.warn(helper.result, 'ERROR: Selector `' +

'` is not supported. nvue only support classname selector');
return false;
return '';
})
.filter(Boolean)
.join(', ');

@@ -1041,3 +1040,6 @@ if (!rule.selector) {

}
const context = { 'FONT-FACE': [], TRANSITION: {} };
const context = {
'FONT-FACE': [],
TRANSITION: {},
};
const result = transform(node, context);

@@ -1066,24 +1068,16 @@ if (context['FONT-FACE'].length) {

child.selectors.forEach((selector) => {
let className = selector.slice(1);
const pseudoIndex = className.indexOf(':');
if (pseudoIndex > -1) {
const pseudoClass = className.slice(pseudoIndex);
className = className.slice(0, pseudoIndex);
Object.keys(body).forEach(function (name) {
body[name + pseudoClass] = body[name];
delete body[name];
});
}
transition(className, body, context);
if (result[className]) {
// clone
result[className] = extend({}, result[className], body);
}
else {
result[className] = body;
}
transformSelector(selector, body, result, context);
});
}
else if (child.type === 'decl') {
result[child.prop] = child.value;
if (child.important) {
result['!' + child.prop] = child.value;
// !important的值域优先级高,故删除非!important的值域
delete result[child.prop];
}
else {
if (!hasOwn(result, '!' + child.prop)) {
result[child.prop] = child.value;
}
}
}

@@ -1093,2 +1087,43 @@ });

}
function transformSelector(selector, body, result, context) {
const res = selector.match(COMBINATORS_RE);
if (!res) {
return;
}
let parentSelector = res[1].trim();
let curSelector = res[2].trim().substring(1);
const pseudoIndex = curSelector.indexOf(':');
if (pseudoIndex > -1) {
const pseudoClass = curSelector.slice(pseudoIndex);
curSelector = curSelector.slice(0, pseudoIndex);
Object.keys(body).forEach(function (name) {
body[name + pseudoClass] = body[name];
delete body[name];
});
}
transition(curSelector, body, context);
if (!Object.keys(body).length) {
return;
}
result = (result[curSelector] || (result[curSelector] = {}));
if (result[parentSelector]) {
// clone
result[parentSelector] = processImportant(extend({}, result[parentSelector], body));
}
else {
result[parentSelector] = body;
}
}
/**
* 处理 important 属性,如果某个属性是 important,需要将非 important 的该属性移除掉
* @param body
*/
function processImportant(body) {
Object.keys(body).forEach((name) => {
if (name.startsWith('!')) {
delete body[name.substring(1)];
}
});
return body;
}
function transition(className, body, { TRANSITION }) {

@@ -1095,0 +1130,0 @@ Object.keys(body).forEach((prop) => {

@@ -12,3 +12,2 @@ import { Container } from 'postcss';

declare interface NormalizeOptions {
descendant?: boolean;
logLevel?: 'NOTE' | 'WARNING' | 'ERROR';

@@ -15,0 +14,0 @@ }

{
"name": "@dcloudio/uni-nvue-styler",
"version": "0.0.1-nvue3.3040020220215001",
"version": "0.0.1-nvue3.3040020220217001",
"description": "uni-nvue-styler",

@@ -20,2 +20,3 @@ "main": "./dist/uni-nvue-styler.cjs.js",

"dependencies": {
"@vue/shared": "3.2.30",
"parse-css-font": "^4.0.0",

@@ -22,0 +23,0 @@ "postcss": "^8.4.5"

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