chore: cleanup

This commit is contained in:
Nathan Walker
2020-07-04 01:12:55 -07:00
parent 9341cd9554
commit 1525c89733
274 changed files with 1755 additions and 2733 deletions

View File

@@ -1,23 +1,55 @@
import * as reduceCSSCalc from "reduce-css-calc";
// Definitions.
import * as definitions from "../view-base";
import { ViewBase } from "../view-base";
// Types.
import { WrappedValue, PropertyChangeData } from "../../../data/observable";
import {
write as traceWrite,
categories as traceCategories,
messageType as traceMessageType,
Trace
} from "../../../trace";
import { Style } from "../../styling/style";
import { profile } from "../../../profiling";
/**
* Value specifing that Property should be set to its initial value.
*/
export const unsetValue: any = new Object();
export interface PropertyOptions<T, U> {
readonly name: string;
readonly defaultValue?: U;
readonly affectsLayout?: boolean;
readonly equalityComparer?: (x: U, y: U) => boolean;
readonly valueChanged?: (target: T, oldValue: U, newValue: U) => void;
readonly valueConverter?: (value: string) => U;
}
export interface CoerciblePropertyOptions<T, U> extends PropertyOptions<T, U> {
readonly coerceValue: (t: T, u: U) => U;
}
export interface CssPropertyOptions<T extends Style, U> extends PropertyOptions<T, U> {
readonly cssName: string;
}
export interface ShorthandPropertyOptions<P> {
readonly name: string,
readonly cssName: string;
readonly converter: (value: string | P) => [CssProperty<any, any> | CssAnimationProperty<any, any>, any][],
readonly getter: (this: Style) => string | P
}
export interface CssAnimationPropertyOptions<T, U> {
readonly name: string;
readonly cssName?: string;
readonly defaultValue?: U;
readonly equalityComparer?: (x: U, y: U) => boolean;
readonly valueChanged?: (target: T, oldValue: U, newValue: U) => void;
readonly valueConverter?: (value: string) => U;
}
let cssPropertyNames: string[] = [];
let symbolPropertyMap = {};
let cssSymbolPropertyMap = {};
@@ -132,7 +164,7 @@ function getPropertiesFromMap(map): Property<any, any>[] | CssProperty<any, any>
return props;
}
export class Property<T extends ViewBase, U> implements TypedPropertyDescriptor<U>, definitions.Property<T, U> {
export class Property<T extends ViewBase, U> implements TypedPropertyDescriptor<U>, Property<T, U> {
private registered: boolean;
public readonly name: string;
@@ -152,7 +184,7 @@ export class Property<T extends ViewBase, U> implements TypedPropertyDescriptor<
public enumerable: boolean = true;
public configurable: boolean = true;
constructor(options: definitions.PropertyOptions<T, U>) {
constructor(options: PropertyOptions<T, U>) {
const propertyName = options.name;
this.name = propertyName;
@@ -302,10 +334,10 @@ export class Property<T extends ViewBase, U> implements TypedPropertyDescriptor<
}
Property.prototype.isStyleProperty = false;
export class CoercibleProperty<T extends ViewBase, U> extends Property<T, U> implements definitions.CoercibleProperty<T, U> {
export class CoercibleProperty<T extends ViewBase, U> extends Property<T, U> implements CoercibleProperty<T, U> {
public readonly coerce: (target: T) => void;
constructor(options: definitions.CoerciblePropertyOptions<T, U>) {
constructor(options: CoerciblePropertyOptions<T, U>) {
super(options);
const propertyName = options.name;
@@ -415,11 +447,11 @@ export class CoercibleProperty<T extends ViewBase, U> extends Property<T, U> imp
}
}
export class InheritedProperty<T extends ViewBase, U> extends Property<T, U> implements definitions.InheritedProperty<T, U> {
export class InheritedProperty<T extends ViewBase, U> extends Property<T, U> implements InheritedProperty<T, U> {
public readonly sourceKey: symbol;
public readonly setInheritedValue: (value: U) => void;
constructor(options: definitions.PropertyOptions<T, U>) {
constructor(options: PropertyOptions<T, U>) {
super(options);
const name = options.name;
const key = this.key;
@@ -488,7 +520,7 @@ export class InheritedProperty<T extends ViewBase, U> extends Property<T, U> imp
}
}
export class CssProperty<T extends Style, U> implements definitions.CssProperty<T, U> {
export class CssProperty<T extends Style, U> implements CssProperty<T, U> {
private registered: boolean;
public readonly name: string;
@@ -507,7 +539,7 @@ export class CssProperty<T extends Style, U> implements definitions.CssProperty<
public readonly defaultValueKey: symbol;
public readonly defaultValue: U;
constructor(options: definitions.CssPropertyOptions<T, U>) {
constructor(options: CssPropertyOptions<T, U>) {
const propertyName = options.name;
this.name = propertyName;
@@ -545,7 +577,7 @@ export class CssProperty<T extends Style, U> implements definitions.CssProperty<
function setLocalValue(this: T, newValue: U | string): void {
const view = this.viewRef.get();
if (!view) {
traceWrite(`${newValue} not set to view because ".viewRef" is cleared`, traceCategories.Style, traceMessageType.warn);
Trace.write(`${newValue} not set to view because ".viewRef" is cleared`, Trace.categories.Style, Trace.messageType.warn);
return;
}
@@ -619,7 +651,7 @@ export class CssProperty<T extends Style, U> implements definitions.CssProperty<
function setCssValue(this: T, newValue: U | string): void {
const view = this.viewRef.get();
if (!view) {
traceWrite(`${newValue} not set to view because ".viewRef" is cleared`, traceCategories.Style, traceMessageType.warn);
Trace.write(`${newValue} not set to view because ".viewRef" is cleared`, Trace.categories.Style, Trace.messageType.warn);
return;
}
@@ -736,7 +768,7 @@ export class CssProperty<T extends Style, U> implements definitions.CssProperty<
}
CssProperty.prototype.isStyleProperty = true;
export class CssAnimationProperty<T extends Style, U> implements definitions.CssAnimationProperty<T, U> {
export class CssAnimationProperty<T extends Style, U> implements CssAnimationProperty<T, U> {
public readonly name: string;
public readonly cssName: string;
public readonly cssLocalName: string;
@@ -759,7 +791,7 @@ export class CssAnimationProperty<T extends Style, U> implements definitions.Css
public _valueConverter?: (value: string) => any;
constructor(options: definitions.CssAnimationPropertyOptions<T, U>) {
constructor(options: CssAnimationPropertyOptions<T, U>) {
const { valueConverter, equalityComparer, valueChanged, defaultValue } = options;
const propertyName = options.name;
this.name = propertyName;
@@ -809,7 +841,7 @@ export class CssAnimationProperty<T extends Style, U> implements definitions.Css
set(this: T, boxedValue: U | string) {
const view = this.viewRef.get();
if (!view) {
traceWrite(`${boxedValue} not set to view because ".viewRef" is cleared`, traceCategories.Animation, traceMessageType.warn);
Trace.write(`${boxedValue} not set to view because ".viewRef" is cleared`, Trace.categories.Animation, Trace.messageType.warn);
return;
}
@@ -912,7 +944,7 @@ export class CssAnimationProperty<T extends Style, U> implements definitions.Css
public _initDefaultNativeValue(target: T): void {
const view = target.viewRef.get();
if (!view) {
traceWrite(`_initDefaultNativeValue not executed to view because ".viewRef" is cleared`, traceCategories.Animation, traceMessageType.warn);
Trace.write(`_initDefaultNativeValue not executed to view because ".viewRef" is cleared`, Trace.categories.Animation, Trace.messageType.warn);
return;
}
@@ -939,10 +971,10 @@ export class CssAnimationProperty<T extends Style, U> implements definitions.Css
}
CssAnimationProperty.prototype.isStyleProperty = true;
export class InheritedCssProperty<T extends Style, U> extends CssProperty<T, U> implements definitions.InheritedCssProperty<T, U> {
export class InheritedCssProperty<T extends Style, U> extends CssProperty<T, U> implements InheritedCssProperty<T, U> {
public setInheritedValue: (value: U) => void;
constructor(options: definitions.CssPropertyOptions<T, U>) {
constructor(options: CssPropertyOptions<T, U>) {
super(options);
const propertyName = options.name;
@@ -964,7 +996,7 @@ export class InheritedCssProperty<T extends Style, U> extends CssProperty<T, U>
const setFunc = (valueSource: ValueSource) => function (this: T, boxedValue: any): void {
const view = this.viewRef.get();
if (!view) {
traceWrite(`${boxedValue} not set to view's property because ".viewRef" is cleared`, traceCategories.Style, traceMessageType.warn);
Trace.write(`${boxedValue} not set to view's property because ".viewRef" is cleared`, Trace.categories.Style, Trace.messageType.warn);
return;
}
@@ -1077,7 +1109,7 @@ export class InheritedCssProperty<T extends Style, U> extends CssProperty<T, U>
}
}
export class ShorthandProperty<T extends Style, P> implements definitions.ShorthandProperty<T, P> {
export class ShorthandProperty<T extends Style, P> implements ShorthandProperty<T, P> {
private registered: boolean;
public readonly key: symbol;
@@ -1091,7 +1123,7 @@ export class ShorthandProperty<T extends Style, P> implements definitions.Shorth
public readonly sourceKey: symbol;
constructor(options: definitions.ShorthandPropertyOptions<P>) {
constructor(options: ShorthandPropertyOptions<P>) {
this.name = options.name;
const key = Symbol(this.name + ":propertyKey");
@@ -1105,7 +1137,7 @@ export class ShorthandProperty<T extends Style, P> implements definitions.Shorth
function setLocalValue(this: T, value: string | P): void {
const view = this.viewRef.get();
if (!view) {
traceWrite(`setLocalValue not executed to view because ".viewRef" is cleared`, traceCategories.Animation, traceMessageType.warn);
Trace.write(`setLocalValue not executed to view because ".viewRef" is cleared`, Trace.categories.Animation, Trace.messageType.warn);
return;
}
@@ -1120,7 +1152,7 @@ export class ShorthandProperty<T extends Style, P> implements definitions.Shorth
function setCssValue(this: T, value: string): void {
const view = this.viewRef.get();
if (!view) {
traceWrite(`setCssValue not executed to view because ".viewRef" is cleared`, traceCategories.Animation, traceMessageType.warn);
Trace.write(`setCssValue not executed to view because ".viewRef" is cleared`, Trace.categories.Animation, Trace.messageType.warn);
return;
}

View File

@@ -1,5 +0,0 @@
{
"name": "properties",
"main": "properties",
"types": "properties.d.ts"
}

View File

@@ -1,165 +0,0 @@
/**
* @module "ui/core/properties"
*/ /** */
import { ViewBase } from "../view-base";
import { Style } from "../../styling/style";
export { Style };
/**
* Value specifing that Property should be set to its initial value.
*/
export const unsetValue: any;
export interface PropertyOptions<T, U> {
readonly name: string;
readonly defaultValue?: U;
readonly affectsLayout?: boolean;
readonly equalityComparer?: (x: U, y: U) => boolean;
readonly valueChanged?: (target: T, oldValue: U, newValue: U) => void;
readonly valueConverter?: (value: string) => U;
}
export interface CoerciblePropertyOptions<T, U> extends PropertyOptions<T, U> {
readonly coerceValue: (t: T, u: U) => U;
}
export interface CssPropertyOptions<T extends Style, U> extends PropertyOptions<T, U> {
readonly cssName: string;
}
export interface ShorthandPropertyOptions<P> {
readonly name: string,
readonly cssName: string;
readonly converter: (value: string | P) => [CssProperty<any, any> | CssAnimationProperty<any, any>, any][],
readonly getter: (this: Style) => string | P
}
export interface CssAnimationPropertyOptions<T, U> {
readonly name: string;
readonly cssName?: string;
readonly defaultValue?: U;
readonly equalityComparer?: (x: U, y: U) => boolean;
readonly valueChanged?: (target: T, oldValue: U, newValue: U) => void;
readonly valueConverter?: (value: string) => U;
}
export class Property<T extends ViewBase, U> {
constructor(options: PropertyOptions<T, U>);
public readonly getDefault: symbol;
public readonly setNative: symbol;
public readonly defaultValue: U;
public register(cls: { prototype: T }): void;
public nativeValueChange(owner: T, value: U): void;
public isSet(instance: T): boolean;
}
export interface Property<T extends ViewBase, U> extends TypedPropertyDescriptor<U> {
}
export class CoercibleProperty<T extends ViewBase, U> extends Property<T, U> {
constructor(options: CoerciblePropertyOptions<T, U>);
public readonly coerce: (target: T) => void;
}
export interface CoercibleProperty<T extends ViewBase, U> extends TypedPropertyDescriptor<U> {
}
export class InheritedProperty<T extends ViewBase, U> extends Property<T, U> {
constructor(options: PropertyOptions<T, U>);
}
export class CssProperty<T extends Style, U> {
constructor(options: CssPropertyOptions<T, U>);
public readonly getDefault: symbol;
public readonly setNative: symbol;
public readonly name: string;
public readonly cssName: string;
public readonly cssLocalName: string;
public readonly defaultValue: U;
public register(cls: { prototype: T }): void;
public isSet(instance: T): boolean;
}
export class InheritedCssProperty<T extends Style, U> extends CssProperty<T, U> {
constructor(options: CssPropertyOptions<T, U>);
}
export class ShorthandProperty<T extends Style, P> {
constructor(options: ShorthandPropertyOptions<P>);
public readonly name: string;
public readonly cssName: string;
public register(cls: typeof Style): void;
}
export class CssAnimationProperty<T extends Style, U> {
constructor(options: CssAnimationPropertyOptions<T, U>);
public readonly getDefault: symbol;
public readonly setNative: symbol;
public readonly name: string;
public readonly cssName: string;
public readonly cssLocalName: string;
readonly keyframe: string;
public readonly defaultValue: U;
public register(cls: { prototype: T }): void;
public isSet(instance: T): boolean;
/**
* @private
*/
public _initDefaultNativeValue(target: T): void;
/**
* @private
*/
public _valueConverter?: (value: string) => any;
/**
* @private
*/
public static _getByCssName(name: string): CssAnimationProperty<any, any>;
/**
* @private
*/
public static _getPropertyNames(): string[];
}
export function initNativeView(view: ViewBase): void;
export function resetNativeView(view: ViewBase): void;
export function resetCSSProperties(style: Style): void;
export function propagateInheritableProperties(view: ViewBase, childView: ViewBase): void;
export function propagateInheritableCssProperties(parentStyle: Style, childStyle: Style): void;
export function clearInheritedProperties(view: ViewBase): void;
export function makeValidator<T>(...values: T[]): (value: any) => value is T;
export function makeParser<T>(isValid: (value: any) => boolean): (value: any) => T;
export function getSetProperties(view: ViewBase): [string, any][];
export function getComputedCssValues(view: ViewBase): [string, any][];
export function isCssVariable(property: string): boolean;
export function isCssCalcExpression(value: string): boolean;
export function isCssVariableExpression(value: string): boolean;
//@private
/**
* @private get all properties defined on ViewBase
*/
export function _getProperties(): Property<any, any>[];
/**
* @private get all properties defined on Style
*/
export function _getStyleProperties(): CssProperty<any, any>[];
export function _evaluateCssVariableExpression(view: ViewBase, cssName: string, value: string): string;
export function _evaluateCssCalcExpression(value: string): string;
//@endprivate