mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-18 22:01:42 +08:00
Merge branch 'master' of github.com:NativeScript/NativeScript
# Conflicts: # packages/core/css/parser.ts
This commit is contained in:
14
.github/workflows/npm_release.yml
vendored
14
.github/workflows/npm_release.yml
vendored
@ -1,9 +1,12 @@
|
|||||||
name: Release @nativescript/core to NPM
|
name: '@nativescript/core -> npm'
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ 'feat/monorepo' ]
|
branches: [ 'master' ]
|
||||||
|
|
||||||
|
env:
|
||||||
|
NPM_TAG: 'next'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
release:
|
release:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@ -16,7 +19,8 @@ jobs:
|
|||||||
|
|
||||||
- name: Generate Version
|
- name: Generate Version
|
||||||
working-directory: packages/core
|
working-directory: packages/core
|
||||||
run: echo ::set-env name=NPM_VERSION::$(node -e "console.log(require('./package.json').version);")--$(date +"%m-%d-%Y-%s")-$GITHUB_RUN_NUMBER
|
run: |
|
||||||
|
echo NPM_VERSION=$(node -e "console.log(require('./package.json').version);")-$NPM_TAG-$(date +"%m-%d-%Y")-$GITHUB_RUN_ID >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Bump Version
|
- name: Bump Version
|
||||||
working-directory: packages/core
|
working-directory: packages/core
|
||||||
@ -31,5 +35,5 @@ jobs:
|
|||||||
NPM_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
|
NPM_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc
|
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc
|
||||||
echo "Publishing @nativescript/core@$NPM_VERSION to NPM..."
|
echo "Publishing @nativescript/core@$NPM_VERSION to NPM with tag $NPM_TAG..."
|
||||||
npm publish nativescript-core-$NPM_VERSION.tgz --tag ci --dry-run
|
npm publish nativescript-core-$NPM_VERSION.tgz --tag $NPM_TAG --dry-run
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { queueMacrotask } from '../utils/macrotask-scheduler';
|
import { queueMacrotask } from '../utils/macrotask-scheduler';
|
||||||
import { FPSCallback } from '../fps-meter/fps-native';
|
import { FPSCallback } from '../fps-meter/fps-native';
|
||||||
import { getTimeInFrameBase } from './animation-native';
|
import { getTimeInFrameBase } from './animation-native';
|
||||||
import { Trace } from 'trace';
|
import { Trace } from '../trace';
|
||||||
|
|
||||||
export interface FrameRequestCallback {
|
export interface FrameRequestCallback {
|
||||||
(time: number): void;
|
(time: number): void;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { getKnownColor } from "../color/known-colors";
|
import { getKnownColor } from '../color/known-colors';
|
||||||
|
|
||||||
export type Parsed<V> = { start: number; end: number; value: V };
|
export type Parsed<V> = { start: number; end: number; value: V };
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ export interface BackgroundPosition {
|
|||||||
text?: string;
|
text?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const urlRegEx = /\s*url\((?:('|")([^\1]*)\1|([^)]*))\)\s*/gy;
|
const urlRegEx = /\s*url\((?:(['"])([^\1]*)\1|([^)]*))\)\s*/gy;
|
||||||
export function parseURL(text: string, start = 0): Parsed<URL> {
|
export function parseURL(text: string, start = 0): Parsed<URL> {
|
||||||
urlRegEx.lastIndex = start;
|
urlRegEx.lastIndex = start;
|
||||||
const result = urlRegEx.exec(text);
|
const result = urlRegEx.exec(text);
|
||||||
@ -130,7 +130,7 @@ export function convertHSLToRGBColor(hue: number, saturation: number, lightness:
|
|||||||
|
|
||||||
const chroma = ((1 - Math.abs(2 * lightness - 1)) * saturation) / 100,
|
const chroma = ((1 - Math.abs(2 * lightness - 1)) * saturation) / 100,
|
||||||
X = chroma * (1 - Math.abs((hue % 2) - 1));
|
X = chroma * (1 - Math.abs((hue % 2) - 1));
|
||||||
// Add lightness match to all RGB components beforehand
|
// Add lightness match to all RGB components beforehand
|
||||||
let { m: r, m: g, m: b } = { m: lightness - chroma / 2 };
|
let { m: r, m: g, m: b } = { m: lightness - chroma / 2 };
|
||||||
|
|
||||||
if (0 <= hue && hue < 1) {
|
if (0 <= hue && hue < 1) {
|
||||||
@ -162,12 +162,7 @@ export function convertHSLToRGBColor(hue: number, saturation: number, lightness:
|
|||||||
|
|
||||||
function hslaToArgbNumber(h: number, s: number, l: number, a = 1): number | undefined {
|
function hslaToArgbNumber(h: number, s: number, l: number, a = 1): number | undefined {
|
||||||
const { r, g, b } = convertHSLToRGBColor(h, s, l);
|
const { r, g, b } = convertHSLToRGBColor(h, s, l);
|
||||||
|
return rgbaToArgbNumber(r, g, b, a);
|
||||||
if (r >= 0 && r <= 255 && g >= 0 && g <= 255 && b >= 0 && b <= 255 && a >= 0 && a <= 1) {
|
|
||||||
return Math.round(a * 0xff) * 0x01000000 + r * 0x010000 + g * 0x000100 + b;
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const hslColorRegEx = /\s*(hsl\(\s*([\d.]*)\s*,\s*([\d.]*)%\s*,\s*([\d.]*)%\s*\))/gy;
|
const hslColorRegEx = /\s*(hsl\(\s*([\d.]*)\s*,\s*([\d.]*)%\s*,\s*([\d.]*)%\s*\))/gy;
|
||||||
@ -196,15 +191,13 @@ export function parseHSLAColor(text: string, start = 0): Parsed<ARGB> {
|
|||||||
return { start, end, value };
|
return { start, end, value };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export function parseColorKeyword(value, start: number, keyword = parseKeyword(value, start)): Parsed<ARGB> {
|
export function parseColorKeyword(value, start: number, keyword = parseKeyword(value, start)): Parsed<ARGB> {
|
||||||
const parseColor = keyword && getKnownColor(keyword.value);
|
const parseColor = keyword && getKnownColor(keyword.value);
|
||||||
if (parseColor !== undefined) {
|
if (parseColor != null) {
|
||||||
const end = keyword.end;
|
const end = keyword.end;
|
||||||
const value = parseColor;
|
const value = parseColor;
|
||||||
return { start, end, value };
|
return { start, end, value };
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -212,7 +205,7 @@ export function parseColor(value: string, start = 0, keyword = parseKeyword(valu
|
|||||||
return parseHexColor(value, start) || parseColorKeyword(value, start, keyword) || parseRGBColor(value, start) || parseRGBAColor(value, start) || parseHSLColor(value, start) || parseHSLAColor(value, start);
|
return parseHexColor(value, start) || parseColorKeyword(value, start, keyword) || parseRGBColor(value, start) || parseRGBAColor(value, start) || parseHSLColor(value, start) || parseHSLAColor(value, start);
|
||||||
}
|
}
|
||||||
|
|
||||||
const keywordRegEx = /\s*([a-z][\w-]*)\s*/giy;
|
const keywordRegEx = /\s*([a-z][\w\-]*)\s*/giy;
|
||||||
function parseKeyword(text: string, start = 0): Parsed<Keyword> {
|
function parseKeyword(text: string, start = 0): Parsed<Keyword> {
|
||||||
keywordRegEx.lastIndex = start;
|
keywordRegEx.lastIndex = start;
|
||||||
const result = keywordRegEx.exec(text);
|
const result = keywordRegEx.exec(text);
|
||||||
@ -237,7 +230,7 @@ export function parseRepeat(value: string, start = 0, keyword = parseKeyword(val
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const unitRegEx = /\s*([\+\-]?(?:\d+\.\d+|\d+|\.\d+)(?:[eE][\+\-]?\d+)?)([a-zA-Z]+|%)?\s*/gy;
|
const unitRegEx = /\s*([+\-]?(?:\d+\.\d+|\d+|\.\d+)(?:[eE][+\-]?\d+)?)([a-zA-Z]+|%)?\s*/gy;
|
||||||
export function parseUnit(text: string, start = 0): Parsed<Unit<string>> {
|
export function parseUnit(text: string, start = 0): Parsed<Unit<string>> {
|
||||||
unitRegEx.lastIndex = start;
|
unitRegEx.lastIndex = start;
|
||||||
const result = unitRegEx.exec(text);
|
const result = unitRegEx.exec(text);
|
||||||
@ -512,7 +505,7 @@ function parseDirection(text: string, start = 0): Parsed<Angle> {
|
|||||||
|
|
||||||
const openingBracketRegEx = /\s*\(\s*/gy;
|
const openingBracketRegEx = /\s*\(\s*/gy;
|
||||||
const closingBracketRegEx = /\s*\)\s*/gy;
|
const closingBracketRegEx = /\s*\)\s*/gy;
|
||||||
const closingBracketOrCommaRegEx = /\s*(\)|,)\s*/gy;
|
const closingBracketOrCommaRegEx = /\s*([),])\s*/gy;
|
||||||
function parseArgumentsList<T>(text: string, start: number, argument: (value: string, lastIndex: number, index: number) => Parsed<T>): Parsed<Parsed<T>[]> {
|
function parseArgumentsList<T>(text: string, start: number, argument: (value: string, lastIndex: number, index: number) => Parsed<T>): Parsed<Parsed<T>[]> {
|
||||||
openingBracketRegEx.lastIndex = start;
|
openingBracketRegEx.lastIndex = start;
|
||||||
const openingBracket = openingBracketRegEx.exec(text);
|
const openingBracket = openingBracketRegEx.exec(text);
|
||||||
@ -541,6 +534,7 @@ function parseArgumentsList<T>(text: string, start: number, argument: (value: st
|
|||||||
if (closingBracketOrComma) {
|
if (closingBracketOrComma) {
|
||||||
end = closingBracketOrCommaRegEx.lastIndex;
|
end = closingBracketOrCommaRegEx.lastIndex;
|
||||||
if (closingBracketOrComma[1] === ',') {
|
if (closingBracketOrComma[1] === ',') {
|
||||||
|
// noinspection UnnecessaryContinueJS
|
||||||
continue;
|
continue;
|
||||||
} else if (closingBracketOrComma[1] === ')') {
|
} else if (closingBracketOrComma[1] === ')') {
|
||||||
return { start, end, value };
|
return { start, end, value };
|
||||||
@ -702,7 +696,7 @@ export interface PseudoClassSelector {
|
|||||||
type: ':';
|
type: ':';
|
||||||
identifier: string;
|
identifier: string;
|
||||||
}
|
}
|
||||||
export type AttributeSelectorTest = '=' | '^=' | '$=' | '*=' | '=' | '~=' | '|=';
|
export type AttributeSelectorTest = '=' | '^=' | '$=' | '*=' | '~=' | '|=';
|
||||||
export interface AttributeSelector {
|
export interface AttributeSelector {
|
||||||
type: '[]';
|
type: '[]';
|
||||||
property: string;
|
property: string;
|
||||||
@ -743,7 +737,7 @@ export function parseSimpleIdentifierSelector(text: string, start = 0): Parsed<T
|
|||||||
return { start, end, value };
|
return { start, end, value };
|
||||||
}
|
}
|
||||||
|
|
||||||
const attributeSelectorRegEx = /\[\s*([_-\w][_-\w\d]*)\s*(?:(=|\^=|\$=|\*=|\~=|\|=)\s*(?:([_-\w][_-\w\d]*)|"((?:[^\\"]|\\(?:"|n|r|f|\\|0-9a-f))*)"|'((?:[^\\']|\\(?:'|n|r|f|\\|0-9a-f))*)')\s*)?\]/gy;
|
const attributeSelectorRegEx = /\[\s*([_\-\w][_\-\w\d]*)\s*(?:(=|\^=|\$=|\*=|\~=|\|=)\s*(?:([_\-\w][_\-\w\d]*)|"((?:[^\\"]|\\(?:"|n|r|f|\\|0-9a-f))*)"|'((?:[^\\']|\\(?:'|n|r|f|\\|0-9a-f))*)')\s*)?\]/gy;
|
||||||
export function parseAttributeSelector(text: string, start: number): Parsed<AttributeSelector> {
|
export function parseAttributeSelector(text: string, start: number): Parsed<AttributeSelector> {
|
||||||
attributeSelectorRegEx.lastIndex = start;
|
attributeSelectorRegEx.lastIndex = start;
|
||||||
const result = attributeSelectorRegEx.exec(text);
|
const result = attributeSelectorRegEx.exec(text);
|
||||||
@ -782,7 +776,7 @@ export function parseSimpleSelectorSequence(text: string, start: number): Parsed
|
|||||||
return { start, end, value };
|
return { start, end, value };
|
||||||
}
|
}
|
||||||
|
|
||||||
const combinatorRegEx = /\s*(\+|~|>)?\s*/gy;
|
const combinatorRegEx = /\s*([+~>])?\s*/gy;
|
||||||
export function parseCombinator(text: string, start = 0): Parsed<Combinator> {
|
export function parseCombinator(text: string, start = 0): Parsed<Combinator> {
|
||||||
combinatorRegEx.lastIndex = start;
|
combinatorRegEx.lastIndex = start;
|
||||||
const result = combinatorRegEx.exec(text);
|
const result = combinatorRegEx.exec(text);
|
||||||
@ -818,6 +812,10 @@ export function parseSelector(text: string, start = 0): Parsed<Selector> {
|
|||||||
}
|
}
|
||||||
end = simpleSelectorSequence.end;
|
end = simpleSelectorSequence.end;
|
||||||
if (combinator) {
|
if (combinator) {
|
||||||
|
// This logic looks weird; this `if` statement would occur on the next LOOP, so it effects the prior `pair`
|
||||||
|
// variable which is already pushed into the `value` array is going to have its `undefined` set to this
|
||||||
|
// value before the following statement creates a new `pair` memory variable.
|
||||||
|
// noinspection JSUnusedAssignment
|
||||||
pair[1] = combinator.value;
|
pair[1] = combinator.value;
|
||||||
}
|
}
|
||||||
pair = [simpleSelectorSequence.value, undefined];
|
pair = [simpleSelectorSequence.value, undefined];
|
||||||
@ -944,7 +942,7 @@ interface SimpleBlock extends InputTokenObject {
|
|||||||
values: InputToken[];
|
values: InputToken[];
|
||||||
}
|
}
|
||||||
|
|
||||||
type AtKeywordToken = InputTokenObject
|
type AtKeywordToken = InputTokenObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CSS parser following relatively close:
|
* CSS parser following relatively close:
|
||||||
@ -1316,11 +1314,9 @@ export class CSS3Parser {
|
|||||||
*/
|
*/
|
||||||
public parseAStylesheet(): Stylesheet {
|
public parseAStylesheet(): Stylesheet {
|
||||||
this.topLevelFlag = true;
|
this.topLevelFlag = true;
|
||||||
const stylesheet: Stylesheet = {
|
return {
|
||||||
rules: this.consumeAListOfRules(),
|
rules: this.consumeAListOfRules(),
|
||||||
};
|
};
|
||||||
|
|
||||||
return stylesheet;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1335,7 +1331,7 @@ export class CSS3Parser {
|
|||||||
case ' ':
|
case ' ':
|
||||||
continue;
|
continue;
|
||||||
case '<!--':
|
case '<!--':
|
||||||
case '-->':{
|
case '-->': {
|
||||||
if (this.topLevelFlag) {
|
if (this.topLevelFlag) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -1345,7 +1341,7 @@ export class CSS3Parser {
|
|||||||
rules.push(atRule);
|
rules.push(atRule);
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((<InputTokenObject>inputToken).type === TokenObjectType.atKeyword) {
|
if ((<InputTokenObject>inputToken).type === TokenObjectType.atKeyword) {
|
||||||
this.reconsumeTheCurrentInputToken(inputToken);
|
this.reconsumeTheCurrentInputToken(inputToken);
|
||||||
@ -1412,8 +1408,7 @@ export class CSS3Parser {
|
|||||||
let inputToken: InputToken;
|
let inputToken: InputToken;
|
||||||
while ((inputToken = this.consumeAToken())) {
|
while ((inputToken = this.consumeAToken())) {
|
||||||
if (inputToken === '{') {
|
if (inputToken === '{') {
|
||||||
const block = this.consumeASimpleBlock(inputToken);
|
qualifiedRule.block = this.consumeASimpleBlock(inputToken);
|
||||||
qualifiedRule.block = block;
|
|
||||||
|
|
||||||
return qualifiedRule;
|
return qualifiedRule;
|
||||||
} else if ((<InputTokenObject>inputToken).type === TokenObjectType.simpleBlock) {
|
} else if ((<InputTokenObject>inputToken).type === TokenObjectType.simpleBlock) {
|
||||||
@ -1513,14 +1508,14 @@ export class CSS3Parser {
|
|||||||
}
|
}
|
||||||
const nextInputToken = this.text[this.nextInputCodePointIndex];
|
const nextInputToken = this.text[this.nextInputCodePointIndex];
|
||||||
switch (nextInputToken) {
|
switch (nextInputToken) {
|
||||||
case ')':{
|
case ')': {
|
||||||
this.nextInputCodePointIndex++;
|
this.nextInputCodePointIndex++;
|
||||||
const end = this.nextInputCodePointIndex;
|
const end = this.nextInputCodePointIndex;
|
||||||
funcToken.text = name + '(' + this.text.substring(start, end);
|
funcToken.text = name + '(' + this.text.substring(start, end);
|
||||||
|
|
||||||
return funcToken;
|
return funcToken;
|
||||||
}
|
}
|
||||||
default:{
|
default: {
|
||||||
const component = this.consumeAComponentValue();
|
const component = this.consumeAComponentValue();
|
||||||
if (component) {
|
if (component) {
|
||||||
funcToken.components.push(component);
|
funcToken.components.push(component);
|
||||||
@ -1560,7 +1555,7 @@ export class CSSNativeScript {
|
|||||||
|
|
||||||
private parseAtRule(rule: AtRule): any {
|
private parseAtRule(rule: AtRule): any {
|
||||||
if (rule.name === 'import') {
|
if (rule.name === 'import') {
|
||||||
// TODO: We have used an "@improt { url('path somewhere'); }" at few places.
|
// TODO: We have used an "@import { url('path somewhere'); }" at few places.
|
||||||
return {
|
return {
|
||||||
import: rule.prelude
|
import: rule.prelude
|
||||||
.map((m) => (typeof m === 'string' ? m : m.text))
|
.map((m) => (typeof m === 'string' ? m : m.text))
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { Trace } from 'trace';
|
import { Trace } from '../trace';
|
||||||
import { dispatchToMainThread } from './mainthread-helper';
|
import { dispatchToMainThread } from './mainthread-helper';
|
||||||
|
|
||||||
let scheduled = false;
|
let scheduled = false;
|
||||||
|
Reference in New Issue
Block a user