mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 19:26:42 +08:00
chore: remove critical circular dependencies (#8114)
* chore: remove critical circular dependencies * chore: fix tslint errors * chore: remove platform specific types from interfaces * chore: update unit tests polyfills * fix: incorrect null check * chore: update api.md file * test: improve test case * chore: apply comments * test: avoid page style leaks in tests
This commit is contained in:

committed by
Alexander Vakrilov

parent
5b647bd809
commit
0ffc790d82
@ -1,7 +1,9 @@
|
||||
import * as types from "./types";
|
||||
import { dispatchToMainThread, isMainThread } from "./mainthread-helper";
|
||||
import { sanitizeModuleName } from "../ui/builder/module-name-sanitizer";
|
||||
import * as layout from "./layout-helper";
|
||||
|
||||
export { layout };
|
||||
export * from "./mainthread-helper";
|
||||
|
||||
export const RESOURCE_PREFIX = "res://";
|
||||
@ -39,70 +41,6 @@ export function getModuleName(path: string): string {
|
||||
return sanitizeModuleName(moduleName);
|
||||
}
|
||||
|
||||
export module layoutCommon {
|
||||
const MODE_SHIFT = 30;
|
||||
const MODE_MASK = 0x3 << MODE_SHIFT;
|
||||
|
||||
export const UNSPECIFIED = 0 << MODE_SHIFT;
|
||||
export const EXACTLY = 1 << MODE_SHIFT;
|
||||
export const AT_MOST = 2 << MODE_SHIFT;
|
||||
|
||||
export const MEASURED_HEIGHT_STATE_SHIFT = 0x00000010; /* 16 */
|
||||
export const MEASURED_STATE_TOO_SMALL = 0x01000000;
|
||||
export const MEASURED_STATE_MASK = 0xff000000;
|
||||
export const MEASURED_SIZE_MASK = 0x00ffffff;
|
||||
|
||||
export function getMode(mode: number): string {
|
||||
switch (mode) {
|
||||
case layoutCommon.EXACTLY:
|
||||
return "Exact";
|
||||
case layoutCommon.AT_MOST:
|
||||
return "AtMost";
|
||||
default:
|
||||
return "Unspecified";
|
||||
}
|
||||
}
|
||||
|
||||
export function getMeasureSpecMode(spec: number): number {
|
||||
return (spec & MODE_MASK);
|
||||
}
|
||||
|
||||
export function getMeasureSpecSize(spec: number): number {
|
||||
return (spec & ~MODE_MASK);
|
||||
}
|
||||
|
||||
export function measureSpecToString(measureSpec: number): string {
|
||||
const mode = getMeasureSpecMode(measureSpec);
|
||||
const size = getMeasureSpecSize(measureSpec);
|
||||
|
||||
let text = "MeasureSpec: ";
|
||||
if (mode === UNSPECIFIED) {
|
||||
text += "UNSPECIFIED ";
|
||||
} else if (mode === EXACTLY) {
|
||||
text += "EXACTLY ";
|
||||
} else if (mode === AT_MOST) {
|
||||
text += "AT_MOST ";
|
||||
}
|
||||
|
||||
text += size;
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
export function round(value: number): number {
|
||||
const res = Math.floor(value + 0.5);
|
||||
if (res !== 0) {
|
||||
return res;
|
||||
} else if (value === 0) {
|
||||
return 0;
|
||||
} else if (value > 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
export function isFileOrResourcePath(path: string): boolean {
|
||||
if (!types.isString(path)) {
|
||||
return false;
|
||||
|
Reference in New Issue
Block a user