mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 20:11:24 +08:00
Upgrade to latest reworkcss sans the stringify module.
This commit is contained in:
1
css/index.js
Normal file
1
css/index.js
Normal file
@ -0,0 +1 @@
|
|||||||
|
exports.parse = require('./lib/parse');
|
@ -2,7 +2,7 @@
|
|||||||
// https://github.com/visionmedia/css-parse/pull/49#issuecomment-30088027
|
// https://github.com/visionmedia/css-parse/pull/49#issuecomment-30088027
|
||||||
var commentre = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//g
|
var commentre = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//g
|
||||||
|
|
||||||
module.exports.parse = function(css, options){
|
module.exports = function(css, options){
|
||||||
options = options || {};
|
options = options || {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -56,26 +56,21 @@ module.exports.parse = function(css, options){
|
|||||||
* Error `msg`.
|
* Error `msg`.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
var errorsList = [];
|
||||||
|
|
||||||
function error(msg) {
|
function error(msg) {
|
||||||
if (options.silent === true) {
|
var err = new Error(options.source + ':' + lineno + ':' + column + ': ' + msg);
|
||||||
return false;
|
err.reason = msg;
|
||||||
};
|
err.filename = options.source;
|
||||||
|
err.line = lineno;
|
||||||
|
err.column = column;
|
||||||
|
err.source = css;
|
||||||
|
|
||||||
var errorMessage;
|
if (options.silent) {
|
||||||
if (options.source) {
|
errorsList.push(err);
|
||||||
errorMessage = options.source + ':' + lineno + ':' + column + ': ' + msg;
|
} else {
|
||||||
}
|
|
||||||
else {
|
|
||||||
errorMessage = "Parsing '" + css + "' issue an error: " + msg;
|
|
||||||
}
|
|
||||||
|
|
||||||
var err = new Error(errorMessage);
|
|
||||||
err.reason = msg;
|
|
||||||
err.filename = options.source;
|
|
||||||
err.line = lineno;
|
|
||||||
err.column = column;
|
|
||||||
err.source = css;
|
|
||||||
throw err;
|
throw err;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -83,10 +78,13 @@ module.exports.parse = function(css, options){
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
function stylesheet() {
|
function stylesheet() {
|
||||||
|
var rulesList = rules();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
type: 'stylesheet',
|
type: 'stylesheet',
|
||||||
stylesheet: {
|
stylesheet: {
|
||||||
rules: rules()
|
rules: rulesList,
|
||||||
|
parsingErrors: errorsList
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -200,7 +198,7 @@ module.exports.parse = function(css, options){
|
|||||||
* http://ostermiller.org/findcomment.html */
|
* http://ostermiller.org/findcomment.html */
|
||||||
return trim(m[0])
|
return trim(m[0])
|
||||||
.replace(/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*\/+/g, '')
|
.replace(/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*\/+/g, '')
|
||||||
.replace(/(?:"[^"]*"|'[^']*')/g, function(m) {
|
.replace(/"(?:\\"|[^"])*"|'(?:\\'|[^'])*'/g, function(m) {
|
||||||
return m.replace(/,/g, '\u200C');
|
return m.replace(/,/g, '\u200C');
|
||||||
})
|
})
|
||||||
.split(/\s*(?![^(]*\)),\s*/)
|
.split(/\s*(?![^(]*\)),\s*/)
|
||||||
@ -291,7 +289,7 @@ module.exports.parse = function(css, options){
|
|||||||
|
|
||||||
function atkeyframes() {
|
function atkeyframes() {
|
||||||
var pos = position();
|
var pos = position();
|
||||||
var m = match(/^@([-\w]+)?keyframes */);
|
var m = match(/^@([-\w]+)?keyframes\s*/);
|
||||||
|
|
||||||
if (!m) return;
|
if (!m) return;
|
||||||
var vendor = m[1];
|
var vendor = m[1];
|
||||||
@ -350,7 +348,7 @@ module.exports.parse = function(css, options){
|
|||||||
|
|
||||||
function athost() {
|
function athost() {
|
||||||
var pos = position();
|
var pos = position();
|
||||||
var m = match(/^@host */);
|
var m = match(/^@host\s*/);
|
||||||
|
|
||||||
if (!m) return;
|
if (!m) return;
|
||||||
|
|
||||||
@ -397,7 +395,7 @@ module.exports.parse = function(css, options){
|
|||||||
|
|
||||||
function atcustommedia() {
|
function atcustommedia() {
|
||||||
var pos = position();
|
var pos = position();
|
||||||
var m = match(/^@custom-media (--[^\s]+) *([^{;]+);/);
|
var m = match(/^@custom-media\s+(--[^\s]+)\s*([^{;]+);/);
|
||||||
if (!m) return;
|
if (!m) return;
|
||||||
|
|
||||||
return pos({
|
return pos({
|
||||||
@ -469,7 +467,7 @@ module.exports.parse = function(css, options){
|
|||||||
|
|
||||||
function atfontface() {
|
function atfontface() {
|
||||||
var pos = position();
|
var pos = position();
|
||||||
var m = match(/^@font-face */);
|
var m = match(/^@font-face\s*/);
|
||||||
if (!m) return;
|
if (!m) return;
|
||||||
|
|
||||||
if (!open()) return error("@font-face missing '{'");
|
if (!open()) return error("@font-face missing '{'");
|
||||||
@ -514,7 +512,7 @@ module.exports.parse = function(css, options){
|
|||||||
|
|
||||||
|
|
||||||
function _compileAtrule(name) {
|
function _compileAtrule(name) {
|
||||||
var re = new RegExp('^@' + name + ' *([^;\\n]+);');
|
var re = new RegExp('^@' + name + '\\s*([^;]+);');
|
||||||
return function() {
|
return function() {
|
||||||
var pos = position();
|
var pos = position();
|
||||||
var m = match(re);
|
var m = match(re);
|
@ -1,8 +1,28 @@
|
|||||||
{
|
{
|
||||||
"name": "css",
|
"name": "css",
|
||||||
"version": "2.1.0",
|
"version": "2.2.1",
|
||||||
"description": "CSS parser",
|
"description": "CSS parser / stringifier",
|
||||||
"main": "reworkcss.js",
|
"main": "index",
|
||||||
|
"files": [
|
||||||
|
"index.js",
|
||||||
|
"lib"
|
||||||
|
],
|
||||||
|
"dependencies": {
|
||||||
|
"source-map": "^0.1.38",
|
||||||
|
"source-map-resolve": "^0.3.0",
|
||||||
|
"urix": "^0.1.0",
|
||||||
|
"inherits": "^2.0.1"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"mocha": "^1.21.3",
|
||||||
|
"should": "^4.0.4",
|
||||||
|
"matcha": "^0.5.0",
|
||||||
|
"bytes": "^1.0.0"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"benchmark": "matcha",
|
||||||
|
"test": "mocha --require should --reporter spec --bail test/*.js"
|
||||||
|
},
|
||||||
"author": "TJ Holowaychuk <tj@vision-media.ca>",
|
"author": "TJ Holowaychuk <tj@vision-media.ca>",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
Reference in New Issue
Block a user