mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
chore: cleanup reexports
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
// Deifinitions.
|
||||
import { Background as BackgroundDefinition } from "./background";
|
||||
import { BackgroundRepeat } from "../core/view";
|
||||
import { BackgroundRepeat } from "../styling/style-properties";
|
||||
import { LinearGradient } from "./linear-gradient";
|
||||
// Types.
|
||||
import { Color } from "../../color";
|
||||
|
||||
@@ -281,7 +281,7 @@ function onLivesync(args): void {
|
||||
}
|
||||
application.on("livesync", onLivesync);
|
||||
|
||||
application.android.on("activityStarted", profile("initImageCache", args => {
|
||||
application.android.on("activityStarted", <any>profile("initImageCache", args => {
|
||||
if (!imageFetcher) {
|
||||
initImageCache(args.activity);
|
||||
} else {
|
||||
@@ -289,7 +289,7 @@ application.android.on("activityStarted", profile("initImageCache", args => {
|
||||
}
|
||||
}));
|
||||
|
||||
application.android.on("activityStopped", profile("closeImageCache", args => {
|
||||
application.android.on("activityStopped", <any>profile("closeImageCache", args => {
|
||||
if (imageFetcher) {
|
||||
imageFetcher.closeCache();
|
||||
}
|
||||
|
||||
@@ -11,13 +11,13 @@ import { timeConverter, animationTimingFunctionConverter } from "../styling/conv
|
||||
import { transformConverter } from "../styling/style-properties";
|
||||
|
||||
const ANIMATION_PROPERTY_HANDLERS = Object.freeze({
|
||||
"animation-name": (info, value) => info.name = value,
|
||||
"animation-duration": (info, value) => info.duration = timeConverter(value),
|
||||
"animation-delay": (info, value) => info.delay = timeConverter(value),
|
||||
"animation-timing-function": (info, value) => info.curve = animationTimingFunctionConverter(value),
|
||||
"animation-iteration-count": (info, value) => info.iterations = value === "infinite" ? Number.MAX_VALUE : parseFloat(value),
|
||||
"animation-direction": (info, value) => info.isReverse = value === "reverse",
|
||||
"animation-fill-mode": (info, value) => info.isForwards = value === "forwards"
|
||||
"animation-name": (info: any, value: any) => info.name = value,
|
||||
"animation-duration": (info: any, value: any) => info.duration = timeConverter(value),
|
||||
"animation-delay": (info: any, value: any) => info.delay = timeConverter(value),
|
||||
"animation-timing-function": (info: any, value: any) => info.curve = animationTimingFunctionConverter(value),
|
||||
"animation-iteration-count": (info: any, value: any) => info.iterations = value === "infinite" ? Number.MAX_VALUE : parseFloat(value),
|
||||
"animation-direction": (info: any, value: any) => info.isReverse = value === "reverse",
|
||||
"animation-fill-mode": (info: any, value: any) => info.isForwards = value === "forwards"
|
||||
});
|
||||
|
||||
export class CssAnimationParser {
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
Transformation,
|
||||
TransformationValue,
|
||||
TransformFunctionsInfo,
|
||||
} from "../animation/animation";
|
||||
} from "../animation";
|
||||
|
||||
import { dip, px, percent } from "../core/view";
|
||||
|
||||
@@ -600,15 +600,15 @@ function convertToTransform(value: string): [CssProperty<any, any>, any][] {
|
||||
const { translate, rotate, scale } = transformConverter(value);
|
||||
|
||||
return [
|
||||
[translateXProperty, translate.x],
|
||||
[translateYProperty, translate.y],
|
||||
[<any>translateXProperty, translate.x],
|
||||
[<any>translateYProperty, translate.y],
|
||||
|
||||
[scaleXProperty, scale.x],
|
||||
[scaleYProperty, scale.y],
|
||||
[<any>scaleXProperty, scale.x],
|
||||
[<any>scaleYProperty, scale.y],
|
||||
|
||||
[rotateProperty, rotate.z],
|
||||
[rotateXProperty, rotate.x],
|
||||
[rotateYProperty, rotate.y],
|
||||
[<any>rotateProperty, rotate.z],
|
||||
[<any>rotateXProperty, rotate.x],
|
||||
[<any>rotateYProperty, rotate.y],
|
||||
];
|
||||
}
|
||||
|
||||
@@ -775,14 +775,14 @@ function convertToBackgrounds(this: void, value: string): [CssProperty<any, any>
|
||||
const backgroundPosition = backgrounds.position ? backgrounds.position.text : unsetValue;
|
||||
|
||||
return [
|
||||
[backgroundColorProperty, backgroundColor],
|
||||
[<any>backgroundColorProperty, backgroundColor],
|
||||
[backgroundImageProperty, backgroundImage],
|
||||
[backgroundRepeatProperty, backgroundRepeat],
|
||||
[backgroundPositionProperty, backgroundPosition]
|
||||
];
|
||||
} else {
|
||||
return [
|
||||
[backgroundColorProperty, unsetValue],
|
||||
[<any>backgroundColorProperty, unsetValue],
|
||||
[backgroundImageProperty, unsetValue],
|
||||
[backgroundRepeatProperty, unsetValue],
|
||||
[backgroundPositionProperty, unsetValue]
|
||||
|
||||
@@ -177,7 +177,7 @@ class CSSSource {
|
||||
return new CSSSource(undefined, url, file, keyframes, undefined);
|
||||
}
|
||||
|
||||
@profile
|
||||
@profile()
|
||||
public static resolveCSSPathFromURL(url: string, importSource?: string): string {
|
||||
const app = knownFolders.currentApp().path;
|
||||
const file = resolveFileNameFromUrl(url, app, File.exists, importSource);
|
||||
@@ -196,13 +196,13 @@ class CSSSource {
|
||||
get selectors(): RuleSet[] { return this._selectors; }
|
||||
get source(): string { return this._source; }
|
||||
|
||||
@profile
|
||||
@profile()
|
||||
private load(): void {
|
||||
const file = File.fromPath(this._file);
|
||||
this._source = file.readTextSync();
|
||||
}
|
||||
|
||||
@profile
|
||||
@profile()
|
||||
private parse(): void {
|
||||
try {
|
||||
if (!this._ast) {
|
||||
@@ -225,7 +225,7 @@ class CSSSource {
|
||||
}
|
||||
}
|
||||
|
||||
@profile
|
||||
@profile()
|
||||
private parseCSSAst() {
|
||||
if (this._source) {
|
||||
switch (parser) {
|
||||
@@ -248,7 +248,7 @@ class CSSSource {
|
||||
}
|
||||
}
|
||||
|
||||
@profile
|
||||
@profile()
|
||||
private createSelectors() {
|
||||
if (this._ast) {
|
||||
this._selectors = [
|
||||
@@ -351,12 +351,12 @@ const onCssChanged = profile("\"style-scope\".onCssChanged", (args: application.
|
||||
mergeCssSelectors();
|
||||
}
|
||||
} else if (args.cssFile) {
|
||||
loadCss(args.cssFile);
|
||||
loadCss(args.cssFile, null, null);
|
||||
}
|
||||
});
|
||||
|
||||
function onLiveSync(args: application.CssChangedEventData): void {
|
||||
loadCss(application.getCssFileName());
|
||||
loadCss(application.getCssFileName(), null, null);
|
||||
}
|
||||
|
||||
const loadCss = profile(`"style-scope".loadCss`, (cssModule: string) => {
|
||||
@@ -376,7 +376,7 @@ const loadCss = profile(`"style-scope".loadCss`, (cssModule: string) => {
|
||||
}
|
||||
});
|
||||
|
||||
application.on("cssChanged", onCssChanged);
|
||||
application.on("cssChanged", <any>onCssChanged);
|
||||
application.on("livesync", onLiveSync);
|
||||
|
||||
// Call to this method is injected in the application in:
|
||||
@@ -385,14 +385,14 @@ application.on("livesync", onLiveSync);
|
||||
// Having the app.css loaded in snapshot provides significant boost in startup (when using the ns-theme ~150 ms). However, because app.css is resolved at build-time,
|
||||
// when the snapshot is created - there is no way to use file qualifiers or change the name of on app.css
|
||||
export const loadAppCSS = profile("\"style-scope\".loadAppCSS", (args: application.LoadAppCSSEventData) => {
|
||||
loadCss(args.cssFile);
|
||||
loadCss(args.cssFile, null, null);
|
||||
application.off("loadAppCss", loadAppCSS);
|
||||
});
|
||||
|
||||
if (application.hasLaunched()) {
|
||||
loadAppCSS({ eventName: "loadAppCss", object: <any>application, cssFile: application.getCssFileName() });
|
||||
loadAppCSS({ eventName: "loadAppCss", object: <any>application, cssFile: application.getCssFileName() }, null, null);
|
||||
} else {
|
||||
application.on("loadAppCss", loadAppCSS);
|
||||
application.on("loadAppCss", <any>loadAppCSS);
|
||||
}
|
||||
|
||||
export class CssState {
|
||||
@@ -439,7 +439,7 @@ export class CssState {
|
||||
return false;
|
||||
}
|
||||
|
||||
return this.viewRef.get()._styleScope._getSelectorsVersion() === this._appliedSelectorsVersion;
|
||||
return this.viewRef.get()._styleScope.getSelectorsVersion() === this._appliedSelectorsVersion;
|
||||
}
|
||||
|
||||
public onLoaded(): void {
|
||||
@@ -454,12 +454,12 @@ export class CssState {
|
||||
this.unsubscribeFromDynamicUpdates();
|
||||
}
|
||||
|
||||
@profile
|
||||
@profile()
|
||||
private updateMatch() {
|
||||
const view = this.viewRef.get();
|
||||
if (view && view._styleScope) {
|
||||
this._match = view._styleScope.matchSelectors(view);
|
||||
this._appliedSelectorsVersion = view._styleScope._getSelectorsVersion();
|
||||
this._appliedSelectorsVersion = view._styleScope.getSelectorsVersion();
|
||||
} else {
|
||||
this._match = CssState.emptyMatch;
|
||||
}
|
||||
@@ -467,7 +467,7 @@ export class CssState {
|
||||
this._matchInvalid = false;
|
||||
}
|
||||
|
||||
@profile
|
||||
@profile()
|
||||
private updateDynamicState(): void {
|
||||
const view = this.viewRef.get();
|
||||
if (!view) {
|
||||
@@ -726,7 +726,7 @@ export class StyleScope {
|
||||
this.ensureSelectors();
|
||||
}
|
||||
|
||||
@profile
|
||||
@profile()
|
||||
private setCss(cssString: string, cssFileName?): void {
|
||||
this._css = cssString;
|
||||
|
||||
@@ -736,7 +736,7 @@ export class StyleScope {
|
||||
this.ensureSelectors();
|
||||
}
|
||||
|
||||
@profile
|
||||
@profile()
|
||||
private appendCss(cssString: string, cssFileName?): void {
|
||||
if (!cssString && !cssFileName) {
|
||||
return;
|
||||
@@ -772,7 +772,7 @@ export class StyleScope {
|
||||
this._createSelectors();
|
||||
}
|
||||
|
||||
return this._getSelectorsVersion();
|
||||
return this.getSelectorsVersion();
|
||||
}
|
||||
|
||||
public _increaseApplicationCssSelectorVersion(): void {
|
||||
@@ -787,7 +787,7 @@ export class StyleScope {
|
||||
return this._localCssSelectorsAppliedVersion === this._localCssSelectorVersion;
|
||||
}
|
||||
|
||||
@profile
|
||||
@profile()
|
||||
private _createSelectors() {
|
||||
let toMerge: RuleSet[][] = [];
|
||||
toMerge.push(applicationCssSelectors);
|
||||
@@ -807,7 +807,7 @@ export class StyleScope {
|
||||
|
||||
// HACK: This @profile decorator creates a circular dependency
|
||||
// HACK: because the function parameter type is evaluated with 'typeof'
|
||||
@profile
|
||||
@profile()
|
||||
public matchSelectors(view: any): SelectorsMatch<ViewBase> { // should be (view: ViewBase): SelectorsMatch<ViewBase>
|
||||
this.ensureSelectors();
|
||||
|
||||
@@ -820,7 +820,7 @@ export class StyleScope {
|
||||
return this._selectors.query(node).selectors;
|
||||
}
|
||||
|
||||
private _getSelectorsVersion() {
|
||||
getSelectorsVersion() {
|
||||
// The counters can only go up. So we can return just appVersion + localVersion
|
||||
// The 100000 * appVersion is just for easier debugging
|
||||
return 100000 * this._applicationCssSelectorsAppliedVersion + this._localCssSelectorsAppliedVersion;
|
||||
|
||||
@@ -26,6 +26,27 @@ import {
|
||||
} from "../../../trace";
|
||||
import { TextAlignment, TextDecoration, TextTransform, WhiteSpace } from "../../text-base";
|
||||
|
||||
export interface CommonLayoutParams {
|
||||
width: number;
|
||||
height: number;
|
||||
|
||||
widthPercent: number;
|
||||
heightPercent: number;
|
||||
|
||||
leftMargin: number;
|
||||
topMargin: number;
|
||||
rightMargin: number;
|
||||
bottomMargin: number;
|
||||
|
||||
leftMarginPercent: number;
|
||||
topMarginPercent: number;
|
||||
rightMarginPercent: number;
|
||||
bottomMarginPercent: number;
|
||||
|
||||
horizontalAlignment: HorizontalAlignment;
|
||||
verticalAlignment: VerticalAlignment;
|
||||
}
|
||||
|
||||
export class Style extends Observable implements StyleDefinition {
|
||||
private unscopedCssVariables = new Map<string, string>();
|
||||
private scopedCssVariables = new Map<string, string>();
|
||||
|
||||
Reference in New Issue
Block a user