
* chore: move tns-core-modules to nativescript-core * chore: preparing compat generate script * chore: add missing definitions * chore: no need for http-request to be private * chore: packages chore * test: generate tests for tns-core-modules * chore: add anroid module for consistency * chore: add .npmignore * chore: added privateModulesWhitelist * chore(webpack): added bundle-entry-points * chore: scripts * chore: tests changed to use @ns/core * test: add scoped-packages test project * test: fix types * test: update test project * chore: build scripts * chore: update build script * chore: npm scripts cleanup * chore: make the compat pgk work with old wp config * test: generate diff friendly tests * chore: create barrel exports * chore: move files after rebase * chore: typedoc config * chore: compat mode * chore: review of barrels * chore: remove tns-core-modules import after rebase * chore: dev workflow setup * chore: update developer-workflow * docs: experiment with API extractor * chore: api-extractor and barrel exports * chore: api-extractor configs * chore: generate d.ts rollup with api-extractor * refactor: move methods inside Frame * chore: fic tests to use Frame static methods * refactor: create Builder class * refactor: use Builder class in tests * refactor: include Style in ui barrel * chore: separate compat build script * chore: fix tslint errors * chore: update NATIVESCRIPT_CORE_ARGS * chore: fix compat pack * chore: fix ui-test-app build with linked modules * chore: Application, ApplicationSettings, Connectivity and Http * chore: export Trace, Profiling and Utils * refactor: Static create methods for ImageSource * chore: fix deprecated usages of ImageSource * chore: move Span and FormattedString to ui * chore: add events-args and ImageSource to index files * chore: check for CLI >= 6.2 when building for IOS * chore: update travis build * chore: copy Pod file to compat package * chore: update error msg ui-tests-app * refactor: Apply suggestions from code review Co-Authored-By: Martin Yankov <m.i.yankov@gmail.com> * chore: typings and refs * chore: add missing d.ts files for public API * chore: adress code review FB * chore: update api-report * chore: dev-workflow for other apps * chore: api update * chore: update api-report
css 
CSS parser / stringifier.
Installation
$ npm install css
Usage
var css = require('css');
var obj = css.parse('body { font-size: 12px; }', options);
css.stringify(obj, options);
API
css.parse(code, [options])
Accepts a CSS string and returns an AST object
.
options
:
- silent: silently fail on parse errors.
- source: the path to the file containing
css
. Makes errors and source maps more helpful, by letting them know where code comes from.
Example
var ast = css.parse('body { font-size: 12px; }', { source: 'source.css' });
Errors
Errors will have error.position
, just like node.position
. The
error contains the source position in the message. To get the error message
without the position use error.reason
.
If you create any errors in plugins such as in
rework, you must set the position
as well for consistency.
AST
Common properties
All nodes have the following properties.
position
Information about the position in the source string that corresponds to the node.
Object
:
- start:
Object
:- line:
Number
. - column:
Number
.
- line:
- end:
Object
:- line:
Number
. - column:
Number
.
- line:
- source:
String
orundefined
. The value ofoptions.source
if passed tocss.parse
. Otherwiseundefined
. - content:
String
. The full source string passed tocss.parse
.
The line and column numbers are 1-based: The first line is 1 and the first column of a line is 1 (not 0).
The position
property lets you know from which source file the node comes
from (if available), what that file contains, and what part of that file was
parsed into the node.
type
String
. The possible values are the ones listed in the Types section below.
parent
A reference to the parent node, or null
if the node has no parent.
Types
The available values of node.type
are listed below, as well as the available
properties of each node (other than the common properties listed above.)
stylesheet
The root node returned by css.parse
.
- stylesheet:
Object
:- rules:
Array
of nodes with the typesrule
,comment
and any of the at-rule types.
- rules:
rule
- selectors:
Array
ofString
s. The list of selectors of the rule, split on commas. Each selector is trimmed from whitespace and comments. - declarations:
Array
of nodes with the typesdeclaration
andcomment
.
declaration
- property:
String
. The property name, trimmed from whitespace and comments. May not be empty. - value:
String
. The value of the property, trimmed from whitespace and comments. Empty values are allowed.
comment
A rule-level or declaration-level comment. Comments inside selectors, properties and values etc. are lost.
- comment:
String
. The part between the starting/*
and the ending*/
of the comment, including whitespace.
charset
The @charset
at-rule.
- charset:
String
. The part following@charset
.
custom-media
The @custom-media
at-rule.
- name:
String
. The--
-prefixed name. - media:
String
. The part following the name.
document
The @document
at-rule.
- document:
String
. The part following@document
. - vendor:
String
orundefined
. The vendor prefix in@document
, orundefined
if there is none. - rules:
Array
of nodes with the typesrule
,comment
and any of the at-rule types.
font-face
The @font-face
at-rule.
- declarations:
Array
of nodes with the typesdeclaration
andcomment
.
host
The @host
at-rule.
- rules:
Array
of nodes with the typesrule
,comment
and any of the at-rule types.
import
The @import
at-rule.
- import:
String
. The part following@import
.
keyframes
The @keyframes
at-rule.
- name:
String
. The name of the keyframes rule. - vendor:
String
orundefined
. The vendor prefix in@keyframes
, orundefined
if there is none. - keyframes:
Array
of nodes with the typeskeyframe
andcomment
.
keyframe
- values:
Array
ofString
s. The list of “selectors” of the keyframe rule, split on commas. Each “selector” is trimmed from whitespace. - declarations:
Array
of nodes with the typesdeclaration
andcomment
.
media
The @media
at-rule.
- media:
String
. The part following@media
. - rules:
Array
of nodes with the typesrule
,comment
and any of the at-rule types.
namespace
The @namespace
at-rule.
- namespace:
String
. The part following@namespace
.
page
The @page
at-rule.
- selectors:
Array
ofString
s. The list of selectors of the rule, split on commas. Each selector is trimmed from whitespace and comments. - declarations:
Array
of nodes with the typesdeclaration
andcomment
.
supports
The @supports
at-rule.
- supports:
String
. The part following@supports
. - rules:
Array
of nodes with the typesrule
,comment
and any of the at-rule types.
Example
CSS:
body {
background: #eee;
color: #888;
}
Parse tree:
{
"type": "stylesheet",
"stylesheet": {
"rules": [
{
"type": "rule",
"selectors": [
"body"
],
"declarations": [
{
"type": "declaration",
"property": "background",
"value": "#eee",
"position": {
"start": {
"line": 2,
"column": 3
},
"end": {
"line": 2,
"column": 19
}
}
},
{
"type": "declaration",
"property": "color",
"value": "#888",
"position": {
"start": {
"line": 3,
"column": 3
},
"end": {
"line": 3,
"column": 14
}
}
}
],
"position": {
"start": {
"line": 1,
"column": 1
},
"end": {
"line": 4,
"column": 2
}
}
}
]
}
}
License
MIT