mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
feat: Scoped Packages (#7911)
* 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
This commit is contained in:
committed by
GitHub
parent
6c7139477e
commit
cc97a16800
9
nativescript-core/css/LICENSE
Normal file
9
nativescript-core/css/LICENSE
Normal file
@@ -0,0 +1,9 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2012 TJ Holowaychuk <tj@vision-media.ca>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
278
nativescript-core/css/Readme.md
Normal file
278
nativescript-core/css/Readme.md
Normal file
@@ -0,0 +1,278 @@
|
||||
# css [](https://travis-ci.org/reworkcss/css)
|
||||
|
||||
CSS parser / stringifier.
|
||||
|
||||
## Installation
|
||||
|
||||
$ npm install css
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
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
|
||||
|
||||
```js
|
||||
var ast = css.parse('body { font-size: 12px; }', { source: 'source.css' });
|
||||
|
||||
```
|
||||
|
||||
### Errors
|
||||
|
||||
Errors will have `error.position`, just like [`node.position`](#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](https://github.com/reworkcss/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`.
|
||||
- end: `Object`:
|
||||
- line: `Number`.
|
||||
- column: `Number`.
|
||||
- source: `String` or `undefined`. The value of `options.source` if passed to
|
||||
`css.parse`. Otherwise `undefined`.
|
||||
- content: `String`. The full source string passed to `css.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 types `rule`, `comment` and any of the
|
||||
at-rule types.
|
||||
|
||||
#### rule
|
||||
|
||||
- selectors: `Array` of `String`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 types `declaration` and `comment`.
|
||||
|
||||
#### 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` or `undefined`. The vendor prefix in `@document`, or
|
||||
`undefined` if there is none.
|
||||
- rules: `Array` of nodes with the types `rule`, `comment` and any of the
|
||||
at-rule types.
|
||||
|
||||
#### font-face
|
||||
|
||||
The `@font-face` at-rule.
|
||||
|
||||
- declarations: `Array` of nodes with the types `declaration` and `comment`.
|
||||
|
||||
#### host
|
||||
|
||||
The `@host` at-rule.
|
||||
|
||||
- rules: `Array` of nodes with the types `rule`, `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` or `undefined`. The vendor prefix in `@keyframes`, or
|
||||
`undefined` if there is none.
|
||||
- keyframes: `Array` of nodes with the types `keyframe` and `comment`.
|
||||
|
||||
#### keyframe
|
||||
|
||||
- values: `Array` of `String`s. The list of “selectors” of the keyframe rule,
|
||||
split on commas. Each “selector” is trimmed from whitespace.
|
||||
- declarations: `Array` of nodes with the types `declaration` and `comment`.
|
||||
|
||||
#### media
|
||||
|
||||
The `@media` at-rule.
|
||||
|
||||
- media: `String`. The part following `@media `.
|
||||
- rules: `Array` of nodes with the types `rule`, `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` of `String`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 types `declaration` and `comment`.
|
||||
|
||||
#### supports
|
||||
|
||||
The `@supports` at-rule.
|
||||
|
||||
- supports: `String`. The part following `@supports `.
|
||||
- rules: `Array` of nodes with the types `rule`, `comment` and any of the
|
||||
at-rule types.
|
||||
|
||||
### Example
|
||||
|
||||
CSS:
|
||||
|
||||
```css
|
||||
body {
|
||||
background: #eee;
|
||||
color: #888;
|
||||
}
|
||||
```
|
||||
|
||||
Parse tree:
|
||||
|
||||
```json
|
||||
{
|
||||
"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
|
||||
602
nativescript-core/css/lib/parse/index.js
Normal file
602
nativescript-core/css/lib/parse/index.js
Normal file
@@ -0,0 +1,602 @@
|
||||
// http://www.w3.org/TR/CSS21/grammar.html
|
||||
// https://github.com/visionmedia/css-parse/pull/49#issuecomment-30088027
|
||||
var commentre = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//g
|
||||
|
||||
module.exports = function(css, options){
|
||||
options = options || {};
|
||||
|
||||
/**
|
||||
* Positional.
|
||||
*/
|
||||
|
||||
var lineno = 1;
|
||||
var column = 1;
|
||||
|
||||
/**
|
||||
* Update lineno and column based on `str`.
|
||||
*/
|
||||
|
||||
function updatePosition(str) {
|
||||
var lines = str.match(/\n/g);
|
||||
if (lines) lineno += lines.length;
|
||||
var i = str.lastIndexOf('\n');
|
||||
column = ~i ? str.length - i : column + str.length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark position and patch `node.position`.
|
||||
*/
|
||||
|
||||
function position() {
|
||||
var start = { line: lineno, column: column };
|
||||
return function(node){
|
||||
node.position = new Position(start);
|
||||
whitespace();
|
||||
return node;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Store position information for a node
|
||||
*/
|
||||
|
||||
function Position(start) {
|
||||
this.start = start;
|
||||
this.end = { line: lineno, column: column };
|
||||
this.source = options.source;
|
||||
}
|
||||
|
||||
/**
|
||||
* Non-enumerable source string
|
||||
*/
|
||||
|
||||
Position.prototype.content = css;
|
||||
|
||||
/**
|
||||
* Error `msg`.
|
||||
*/
|
||||
|
||||
var errorsList = [];
|
||||
|
||||
function error(msg) {
|
||||
var err = new Error(options.source + ':' + lineno + ':' + column + ': ' + msg);
|
||||
err.reason = msg;
|
||||
err.filename = options.source;
|
||||
err.line = lineno;
|
||||
err.column = column;
|
||||
err.source = css;
|
||||
|
||||
if (options.silent) {
|
||||
errorsList.push(err);
|
||||
} else {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse stylesheet.
|
||||
*/
|
||||
|
||||
function stylesheet() {
|
||||
var rulesList = rules();
|
||||
|
||||
return {
|
||||
type: 'stylesheet',
|
||||
stylesheet: {
|
||||
rules: rulesList,
|
||||
parsingErrors: errorsList
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Opening brace.
|
||||
*/
|
||||
|
||||
function open() {
|
||||
return match(/^{\s*/);
|
||||
}
|
||||
|
||||
/**
|
||||
* Closing brace.
|
||||
*/
|
||||
|
||||
function close() {
|
||||
return match(/^}/);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse ruleset.
|
||||
*/
|
||||
|
||||
function rules() {
|
||||
var node;
|
||||
var rules = [];
|
||||
whitespace();
|
||||
comments(rules);
|
||||
while (css.length && css.charAt(0) != '}' && (node = atrule() || rule())) {
|
||||
if (node !== false) {
|
||||
rules.push(node);
|
||||
comments(rules);
|
||||
}
|
||||
}
|
||||
return rules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Match `re` and return captures.
|
||||
*/
|
||||
|
||||
function match(re) {
|
||||
var m = re.exec(css);
|
||||
if (!m) return;
|
||||
var str = m[0];
|
||||
updatePosition(str);
|
||||
css = css.slice(str.length);
|
||||
return m;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse whitespace.
|
||||
*/
|
||||
|
||||
function whitespace() {
|
||||
match(/^\s*/);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse comments;
|
||||
*/
|
||||
|
||||
function comments(rules) {
|
||||
var c;
|
||||
rules = rules || [];
|
||||
while (c = comment()) {
|
||||
if (c !== false) {
|
||||
rules.push(c);
|
||||
}
|
||||
}
|
||||
return rules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse comment.
|
||||
*/
|
||||
|
||||
function comment() {
|
||||
var pos = position();
|
||||
if ('/' != css.charAt(0) || '*' != css.charAt(1)) return;
|
||||
|
||||
var i = 2;
|
||||
while ("" != css.charAt(i) && ('*' != css.charAt(i) || '/' != css.charAt(i + 1))) ++i;
|
||||
i += 2;
|
||||
|
||||
if ("" === css.charAt(i-1)) {
|
||||
return error('End of comment missing');
|
||||
}
|
||||
|
||||
var str = css.slice(2, i - 2);
|
||||
column += 2;
|
||||
updatePosition(str);
|
||||
css = css.slice(i);
|
||||
column += 2;
|
||||
|
||||
return pos({
|
||||
type: 'comment',
|
||||
comment: str
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse selector.
|
||||
*/
|
||||
|
||||
function selector() {
|
||||
var m = match(/^([^{]+)/);
|
||||
if (!m) return;
|
||||
/* @fix Remove all comments from selectors
|
||||
* http://ostermiller.org/findcomment.html */
|
||||
return trim(m[0])
|
||||
.replace(/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*\/+/g, '')
|
||||
.replace(/"(?:\\"|[^"])*"|'(?:\\'|[^'])*'/g, function(m) {
|
||||
return m.replace(/,/g, '\u200C');
|
||||
})
|
||||
.split(/\s*(?![^(]*\)),\s*/)
|
||||
.map(function(s) {
|
||||
return s.replace(/\u200C/g, ',');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse declaration.
|
||||
*/
|
||||
|
||||
function declaration() {
|
||||
var pos = position();
|
||||
|
||||
// prop
|
||||
var prop = match(/^(\*?[-#\/\*\\\w]+(\[[0-9a-z_-]+\])?)\s*/);
|
||||
if (!prop) return;
|
||||
prop = trim(prop[0]);
|
||||
|
||||
// :
|
||||
if (!match(/^:\s*/)) return error("property missing ':'");
|
||||
|
||||
// val
|
||||
var val = match(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};])+)/);
|
||||
|
||||
var ret = pos({
|
||||
type: 'declaration',
|
||||
property: prop.replace(commentre, ''),
|
||||
value: val ? trim(val[0]).replace(commentre, '') : ''
|
||||
});
|
||||
|
||||
// ;
|
||||
match(/^[;\s]*/);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse declarations.
|
||||
*/
|
||||
|
||||
function declarations() {
|
||||
var decls = [];
|
||||
|
||||
if (!open()) return error("missing '{'");
|
||||
comments(decls);
|
||||
|
||||
// declarations
|
||||
var decl;
|
||||
while (decl = declaration()) {
|
||||
if (decl !== false) {
|
||||
decls.push(decl);
|
||||
comments(decls);
|
||||
}
|
||||
}
|
||||
|
||||
if (!close()) return error("missing '}'");
|
||||
return decls;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse keyframe.
|
||||
*/
|
||||
|
||||
function keyframe() {
|
||||
var m;
|
||||
var vals = [];
|
||||
var pos = position();
|
||||
|
||||
while (m = match(/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/)) {
|
||||
vals.push(m[1]);
|
||||
match(/^,\s*/);
|
||||
}
|
||||
|
||||
if (!vals.length) return;
|
||||
|
||||
return pos({
|
||||
type: 'keyframe',
|
||||
values: vals,
|
||||
declarations: declarations()
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse keyframes.
|
||||
*/
|
||||
|
||||
function atkeyframes() {
|
||||
var pos = position();
|
||||
var m = match(/^@([-\w]+)?keyframes\s*/);
|
||||
|
||||
if (!m) return;
|
||||
var vendor = m[1];
|
||||
|
||||
// identifier
|
||||
var m = match(/^([-\w]+)\s*/);
|
||||
if (!m) return error("@keyframes missing name");
|
||||
var name = m[1];
|
||||
|
||||
if (!open()) return error("@keyframes missing '{'");
|
||||
|
||||
var frame;
|
||||
var frames = comments();
|
||||
while (frame = keyframe()) {
|
||||
frames.push(frame);
|
||||
frames = frames.concat(comments());
|
||||
}
|
||||
|
||||
if (!close()) return error("@keyframes missing '}'");
|
||||
|
||||
return pos({
|
||||
type: 'keyframes',
|
||||
name: name,
|
||||
vendor: vendor,
|
||||
keyframes: frames
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse supports.
|
||||
*/
|
||||
|
||||
function atsupports() {
|
||||
var pos = position();
|
||||
var m = match(/^@supports *([^{]+)/);
|
||||
|
||||
if (!m) return;
|
||||
var supports = trim(m[1]);
|
||||
|
||||
if (!open()) return error("@supports missing '{'");
|
||||
|
||||
var style = comments().concat(rules());
|
||||
|
||||
if (!close()) return error("@supports missing '}'");
|
||||
|
||||
return pos({
|
||||
type: 'supports',
|
||||
supports: supports,
|
||||
rules: style
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse host.
|
||||
*/
|
||||
|
||||
function athost() {
|
||||
var pos = position();
|
||||
var m = match(/^@host\s*/);
|
||||
|
||||
if (!m) return;
|
||||
|
||||
if (!open()) return error("@host missing '{'");
|
||||
|
||||
var style = comments().concat(rules());
|
||||
|
||||
if (!close()) return error("@host missing '}'");
|
||||
|
||||
return pos({
|
||||
type: 'host',
|
||||
rules: style
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse media.
|
||||
*/
|
||||
|
||||
function atmedia() {
|
||||
var pos = position();
|
||||
var m = match(/^@media *([^{]+)/);
|
||||
|
||||
if (!m) return;
|
||||
var media = trim(m[1]);
|
||||
|
||||
if (!open()) return error("@media missing '{'");
|
||||
|
||||
var style = comments().concat(rules());
|
||||
|
||||
if (!close()) return error("@media missing '}'");
|
||||
|
||||
return pos({
|
||||
type: 'media',
|
||||
media: media,
|
||||
rules: style
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Parse custom-media.
|
||||
*/
|
||||
|
||||
function atcustommedia() {
|
||||
var pos = position();
|
||||
var m = match(/^@custom-media\s+(--[^\s]+)\s*([^{;]+);/);
|
||||
if (!m) return;
|
||||
|
||||
return pos({
|
||||
type: 'custom-media',
|
||||
name: trim(m[1]),
|
||||
media: trim(m[2])
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse paged media.
|
||||
*/
|
||||
|
||||
function atpage() {
|
||||
var pos = position();
|
||||
var m = match(/^@page */);
|
||||
if (!m) return;
|
||||
|
||||
var sel = selector() || [];
|
||||
|
||||
if (!open()) return error("@page missing '{'");
|
||||
var decls = comments();
|
||||
|
||||
// declarations
|
||||
var decl;
|
||||
while (decl = declaration()) {
|
||||
decls.push(decl);
|
||||
decls = decls.concat(comments());
|
||||
}
|
||||
|
||||
if (!close()) return error("@page missing '}'");
|
||||
|
||||
return pos({
|
||||
type: 'page',
|
||||
selectors: sel,
|
||||
declarations: decls
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse document.
|
||||
*/
|
||||
|
||||
function atdocument() {
|
||||
var pos = position();
|
||||
var m = match(/^@([-\w]+)?document *([^{]+)/);
|
||||
if (!m) return;
|
||||
|
||||
var vendor = trim(m[1]);
|
||||
var doc = trim(m[2]);
|
||||
|
||||
if (!open()) return error("@document missing '{'");
|
||||
|
||||
var style = comments().concat(rules());
|
||||
|
||||
if (!close()) return error("@document missing '}'");
|
||||
|
||||
return pos({
|
||||
type: 'document',
|
||||
document: doc,
|
||||
vendor: vendor,
|
||||
rules: style
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse font-face.
|
||||
*/
|
||||
|
||||
function atfontface() {
|
||||
var pos = position();
|
||||
var m = match(/^@font-face\s*/);
|
||||
if (!m) return;
|
||||
|
||||
if (!open()) return error("@font-face missing '{'");
|
||||
var decls = comments();
|
||||
|
||||
// declarations
|
||||
var decl;
|
||||
while (decl = declaration()) {
|
||||
decls.push(decl);
|
||||
decls = decls.concat(comments());
|
||||
}
|
||||
|
||||
if (!close()) return error("@font-face missing '}'");
|
||||
|
||||
return pos({
|
||||
type: 'font-face',
|
||||
declarations: decls
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse import
|
||||
*/
|
||||
|
||||
var atimport = _compileAtrule('import');
|
||||
|
||||
/**
|
||||
* Parse charset
|
||||
*/
|
||||
|
||||
var atcharset = _compileAtrule('charset');
|
||||
|
||||
/**
|
||||
* Parse namespace
|
||||
*/
|
||||
|
||||
var atnamespace = _compileAtrule('namespace');
|
||||
|
||||
/**
|
||||
* Parse non-block at-rules
|
||||
*/
|
||||
|
||||
|
||||
function _compileAtrule(name) {
|
||||
var re = new RegExp('^@' + name + '\\s*([^;]+);');
|
||||
return function() {
|
||||
var pos = position();
|
||||
var m = match(re);
|
||||
if (!m) return;
|
||||
var ret = { type: name };
|
||||
ret[name] = m[1].trim();
|
||||
return pos(ret);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse at rule.
|
||||
*/
|
||||
|
||||
function atrule() {
|
||||
if (css[0] != '@') return;
|
||||
|
||||
return atkeyframes()
|
||||
|| atmedia()
|
||||
|| atcustommedia()
|
||||
|| atsupports()
|
||||
|| atimport()
|
||||
|| atcharset()
|
||||
|| atnamespace()
|
||||
|| atdocument()
|
||||
|| atpage()
|
||||
|| athost()
|
||||
|| atfontface();
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse rule.
|
||||
*/
|
||||
|
||||
function rule() {
|
||||
var pos = position();
|
||||
var sel = selector();
|
||||
|
||||
if (!sel) return error('selector missing');
|
||||
comments();
|
||||
|
||||
return pos({
|
||||
type: 'rule',
|
||||
selectors: sel,
|
||||
declarations: declarations()
|
||||
});
|
||||
}
|
||||
|
||||
return addParent(stylesheet());
|
||||
};
|
||||
|
||||
/**
|
||||
* Trim `str`.
|
||||
*/
|
||||
|
||||
function trim(str) {
|
||||
return str ? str.replace(/^\s+|\s+$/g, '') : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds non-enumerable parent node reference to each node.
|
||||
*/
|
||||
|
||||
function addParent(obj, parent) {
|
||||
var isNode = obj && typeof obj.type === 'string';
|
||||
var childParent = isNode ? obj : parent;
|
||||
|
||||
for (var k in obj) {
|
||||
var value = obj[k];
|
||||
if (Array.isArray(value)) {
|
||||
value.forEach(function(v) { addParent(v, childParent); });
|
||||
} else if (value && typeof value === 'object') {
|
||||
addParent(value, childParent);
|
||||
}
|
||||
}
|
||||
|
||||
if (isNode) {
|
||||
Object.defineProperty(obj, 'parent', {
|
||||
configurable: true,
|
||||
writable: true,
|
||||
enumerable: false,
|
||||
value: parent || null
|
||||
});
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
36
nativescript-core/css/package.json
Normal file
36
nativescript-core/css/package.json
Normal file
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"name": "css",
|
||||
"version": "2.2.1",
|
||||
"description": "CSS parser / stringifier",
|
||||
"main": "reworkcss",
|
||||
"types": "reworkcss.d.ts",
|
||||
"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>",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/reworkcss/css.git"
|
||||
},
|
||||
"keywords": [
|
||||
"css",
|
||||
"parser",
|
||||
"stringifier",
|
||||
"stylesheet"
|
||||
],
|
||||
"nativescript": {}
|
||||
}
|
||||
1690
nativescript-core/css/parser.ts
Normal file
1690
nativescript-core/css/parser.ts
Normal file
File diff suppressed because it is too large
Load Diff
37
nativescript-core/css/reworkcss.d.ts
vendored
Normal file
37
nativescript-core/css/reworkcss.d.ts
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* @module "css"
|
||||
*/ /** */
|
||||
|
||||
export interface Position {
|
||||
start: { line: number; column: number };
|
||||
end: { line: number; column: number };
|
||||
}
|
||||
|
||||
export interface Node {
|
||||
type: "rule" | "keyframes" | "declaration" | "import";
|
||||
position: Position;
|
||||
}
|
||||
|
||||
export interface Declaration extends Node {
|
||||
property: string;
|
||||
value: string;
|
||||
}
|
||||
|
||||
export interface Rule extends Node {
|
||||
selectors: string[];
|
||||
declarations: Node[];
|
||||
}
|
||||
|
||||
export interface Keyframes extends Rule {
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface StyleSheet {
|
||||
rules: Node[];
|
||||
}
|
||||
|
||||
export interface SyntaxTree {
|
||||
stylesheet: StyleSheet;
|
||||
}
|
||||
|
||||
export function parse(css: string, options: any): SyntaxTree;
|
||||
1
nativescript-core/css/reworkcss.js
Normal file
1
nativescript-core/css/reworkcss.js
Normal file
@@ -0,0 +1 @@
|
||||
exports.parse = require('./lib/parse');
|
||||
35
nativescript-core/css/system-classes.d.ts
vendored
Normal file
35
nativescript-core/css/system-classes.d.ts
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* @module "system-classes"
|
||||
*/ /** */
|
||||
|
||||
/**
|
||||
* String value "ns-" used for CSS system class prefix.
|
||||
*/
|
||||
export const CLASS_PREFIX: string;
|
||||
|
||||
/**
|
||||
* Gets CSS system class for modal root view.
|
||||
*/
|
||||
export function getModalRootViewCssClass(): string;
|
||||
|
||||
/**
|
||||
* Gets CSS system classes for root view.
|
||||
*/
|
||||
export function getRootViewCssClasses(): string[];
|
||||
|
||||
/**
|
||||
* Appends new CSS class to the system classes and returns the new length of the array.
|
||||
* @param value New CSS system class.
|
||||
*/
|
||||
export function pushToRootViewCssClasses(value: string): number;
|
||||
|
||||
/**
|
||||
* Removes CSS class from the system classes and returns it.
|
||||
* @param value
|
||||
*/
|
||||
export function removeFromRootViewCssClasses(value: string): string;
|
||||
|
||||
/**
|
||||
* Resets CSS classes for root view.
|
||||
*/
|
||||
export function resetRootViewCssClasses(): string[];
|
||||
37
nativescript-core/css/system-classes.ts
Normal file
37
nativescript-core/css/system-classes.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
const MODAL = "modal";
|
||||
const ROOT = "root";
|
||||
|
||||
export const CLASS_PREFIX = "ns-";
|
||||
|
||||
const modalRootViewCssClass = `${CLASS_PREFIX}${MODAL}`;
|
||||
const rootViewCssClasses = [`${CLASS_PREFIX}${ROOT}`];
|
||||
|
||||
export function getModalRootViewCssClass(): string {
|
||||
return modalRootViewCssClass;
|
||||
}
|
||||
|
||||
export function getRootViewCssClasses(): string[] {
|
||||
return rootViewCssClasses;
|
||||
}
|
||||
|
||||
export function pushToRootViewCssClasses(value: string): number {
|
||||
rootViewCssClasses.push(value);
|
||||
|
||||
return rootViewCssClasses.length;
|
||||
}
|
||||
|
||||
export function removeFromRootViewCssClasses(value: string): string {
|
||||
const index = rootViewCssClasses.indexOf(value);
|
||||
let removedElement;
|
||||
|
||||
if (index > -1) {
|
||||
removedElement = rootViewCssClasses.splice(index, 1);
|
||||
}
|
||||
|
||||
return removedElement;
|
||||
}
|
||||
|
||||
export function resetRootViewCssClasses(): string[] {
|
||||
// Preserve the default `ns-root` CSS class
|
||||
return rootViewCssClasses.splice(1);
|
||||
}
|
||||
Reference in New Issue
Block a user