Housekeeping node tests, renamed to unit-tests (#4936)

Add parsers for the background css shorthand property, make ViewBase unit testable in node environment

Add background parser and linear-gradient parser

Use sticky regexes

Simplify some types, introduce generic Parsed<T> instead of & TokenRange

Apply each parser to return a { start, end, value } object

Move the css selector parser to the css/parser and unify types

Add the first steps toward building homegrown css parser

Add somewhat standards compliant tokenizer, add baseline, rework and shady css parsers

Enable all tests again, skip flaky perf test

Improve css parser tokenizer by converting some char token types to simple string

Implement 'parse a stylesheet'

Add gonzales css-parser

Add parseLib and css-tree perf

Add a thin parser layer that will convert CSS3 tokens to values, for now output is compatible with rework

Make root tsc green

Return the requires of tns-core-modules to use relative paths for webpack to work

Implement support for '@import 'url-string';

Fix function parser, function-token is no-longer neglected

Make the style-scope be able to load from "css" and "css-ast" modules

Add a loadAppCss event so theme can be added to snapshot separately from loaded
This commit is contained in:
Panayot Cankov
2017-10-20 10:42:07 +03:00
committed by Hristo Hristov
parent 2eba7c66e4
commit f7a3a36b9c
64 changed files with 2875 additions and 1281 deletions

View File

@@ -85,7 +85,7 @@ export function isRunning(name: string): boolean {
return !!(info && info.runCount);
}
function countersProfileFunctionFactory<F extends Function>(fn: F, name: string): F {
function countersProfileFunctionFactory<F extends Function>(fn: F, name: string, type: MemberType = MemberType.Instance): F {
profileNames.push(name);
return <any>function() {
start(name);
@@ -97,8 +97,8 @@ function countersProfileFunctionFactory<F extends Function>(fn: F, name: string)
}
}
function timelineProfileFunctionFactory<F extends Function>(fn: F, name: string): F {
return <any>function() {
function timelineProfileFunctionFactory<F extends Function>(fn: F, name: string, type: MemberType = MemberType.Instance): F {
return type === MemberType.Instance ? <any>function() {
const start = time();
try {
return fn.apply(this, arguments);
@@ -106,10 +106,23 @@ function timelineProfileFunctionFactory<F extends Function>(fn: F, name: string)
const end = time();
console.log(`Timeline: Modules: ${name} ${this} (${start}ms. - ${end}ms.)`);
}
}
} : function() {
const start = time();
try {
return fn.apply(this, arguments);
} finally {
const end = time();
console.log(`Timeline: Modules: ${name} (${start}ms. - ${end}ms.)`);
}
};
}
let profileFunctionFactory: <F extends Function>(fn: F, name: string) => F;
const enum MemberType {
Static,
Instance
}
let profileFunctionFactory: <F extends Function>(fn: F, name: string, type?: MemberType) => F;
export function enable(mode: InstrumentationMode = "counters") {
profileFunctionFactory = mode && {
counters: countersProfileFunctionFactory,
@@ -154,7 +167,28 @@ const profileMethodUnnamed = (target, key, descriptor) => {
let name = className + key;
//editing the descriptor/value parameter
descriptor.value = profileFunctionFactory(originalMethod, name);
descriptor.value = profileFunctionFactory(originalMethod, name, MemberType.Instance);
// return edited descriptor as opposed to overwriting the descriptor
return descriptor;
}
const profileStaticMethodUnnamed = (ctor, key, descriptor) => {
// save a reference to the original method this way we keep the values currently in the
// descriptor and don't overwrite what another decorator might have done to the descriptor.
if (descriptor === undefined) {
descriptor = Object.getOwnPropertyDescriptor(ctor, key);
}
var originalMethod = descriptor.value;
let className = "";
if (ctor && ctor.name) {
className = ctor.name + ".";
}
let name = className + key;
//editing the descriptor/value parameter
descriptor.value = profileFunctionFactory(originalMethod, name, MemberType.Static);
// return edited descriptor as opposed to overwriting the descriptor
return descriptor;
@@ -188,6 +222,11 @@ export function profile(nameFnOrTarget?: string | Function | Object, fnOrKey?: F
return;
}
return profileMethodUnnamed(nameFnOrTarget, fnOrKey, descriptor);
} else if (typeof nameFnOrTarget === "function" && (typeof fnOrKey === "string" || typeof fnOrKey === "symbol")) {
if (!profileFunctionFactory) {
return;
}
return profileStaticMethodUnnamed(nameFnOrTarget, fnOrKey, descriptor);
} else if (typeof nameFnOrTarget === "string" && typeof fnOrKey === "function") {
if (!profileFunctionFactory) {
return fnOrKey;