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,8 +1,3 @@
/**
* Allows you to create, cancel and react to listeners to animation frames.
* @module "animation-frame"
*/ /** */
/**
* Callback called on frame rendered
* @argument time Time of the current frame in milliseconds

View File

@@ -1,9 +1,4 @@
/**
* Allows you to save and restore any kind of information related to your application.
* @module "application-settings"
*/ /** */
/**
* Checks whether such a key exists.
* @param key The key to check for.
*/

View File

@@ -1,11 +1,6 @@
/**
* Contains the application abstraction with all related methods.
* @module "application"
*/ /** */
/// <reference path="../tns-core-modules.d.ts" />
import { NavigationEntry, View, Observable, EventData } from "../ui/frame";
import { NavigationEntry } from "../ui/frame";
import { View } from '../ui/core/view';
import { Observable, EventData } from '../data/observable';
/**
* String value used when hooking to launch event.

View File

@@ -1,9 +1,4 @@
/**
* Allows creating colors to be used when styling the UI.
* @module "color"
*/ /** */
/**
* Represents a color object. Stores all color components (alpha (opacity), red, green, blue) in a [0..255] range.
*/
export class Color {

View File

@@ -1,8 +1,4 @@
/**
* @module "color/known-colors"
*/ /** */
export const AliceBlue;
export const AliceBlue;
export const AntiqueWhite;
export const Aqua;
export const Aquamarine;

View File

@@ -1,9 +1,4 @@
/**
* Contains connectivity utility methods.
* @module "connectivity"
*/ /** */
/**
* Gets the type of connection.
* Returns a value from the connectivity.connectionType enumeration.
* To use this method on Android you need to have the android.permission.ACCESS_NETWORK_STATE permission added to the AndroidManifest.xml file.

View File

@@ -1,7 +1,3 @@
/**
* @module "css-value"
*/ /** */
interface CSSValue {
type: string;
string: string;

View File

@@ -1,7 +1,3 @@
/**
* @module "css"
*/ /** */
export interface Position {
start: { line: number; column: number };
end: { line: number; column: number };

View File

@@ -1,8 +1,3 @@
/**
* @module "system-classes"
* This is an internal module.
*/ /** */
/**
* String value "ns-" used for CSS system class prefix.
*/

View File

@@ -1,9 +1,4 @@
/**
* Contains the ObservableArray class, which is capable of detecting and responding to changes of a collection of objects.
* @module "data/observable-array"
*/ /** */
// Test: http://jsperf.com/array-vs-observable-array-vs-array-observe
// Test: http://jsperf.com/array-vs-observable-array-vs-array-observe
import { Observable, EventData } from "../observable";
/**

View File

@@ -1,9 +1,4 @@
/**
* Contains the Observable class, which represents an observable object, or "data" in the model-view paradigm.
* @module "data/observable"
*/ /** */
/**
* Base event data.
*/
export interface EventData {

View File

@@ -1,11 +1,5 @@
/**
* Contains the VirtualArray class, which is an advanced array like class that helps loading items on demand.
* @module "data/virtual-array"
*/ /** */
import { Observable, EventData } from "../observable";
import { Observable, EventData } from "../observable";
import { ObservableArray, ChangedData, ChangeType } from "../observable-array";
export { ChangedData, ChangeType } from "../observable-array";
/**
* Advanced array like class that helps loading items on demand.

View File

@@ -1,10 +1,4 @@
/**
* Provides FileNameResolver class used for loading files based on device capabilities.
* @module "file-system/file-name-resolver"
*/ /** */
import { PlatformContext } from "../../module-name-resolver/qualifier-matcher";
export { PlatformContext } from "../../module-name-resolver/qualifier-matcher";
import { PlatformContext } from "../../module-name-resolver/qualifier-matcher";
export class FileNameResolver {
constructor(context: PlatformContext);

View File

@@ -1,8 +1,4 @@
/**
* @module "file-system/file-system-access"
*/ /** */
/**
* An utility class used to provide methods to access and work with the file system.
*/
export class FileSystemAccess {

View File

@@ -1,9 +1,4 @@
/**
* Provides high-level abstractions for file system entities such as files, folders, known folders, paths, separators, etc.
* @module "file-system"
*/ /** */
/**
* Represents a single entity on the file system.
*/
export class FileSystemEntity {

View File

@@ -1,9 +1,4 @@
/**
* Allows you to capture the frames-per-second metrics of your application.
* @module "fps-meter"
*/ /** */
/**
* Starts the frames-per-second meter.
*/
export function start(): void;

View File

@@ -1,8 +1,4 @@
/**
* @module "fps-meter/fps-native"
*/ /** */
/**
* An utility class used to measure frames per second.
*/
export class FPSCallback {

View File

@@ -1,9 +0,0 @@
Globals module for defining functions part of the global context - you need only to call *require* for this module and all globals will be registered. For example:
```js
require("globals");
setTimeout(function(){ console.log("Test"); }, 2000);
```
Global functions/objects are: setTimeout, clearTimeout, setInterval, clearInterval and console.

View File

@@ -1,6 +1,5 @@
// Required by TypeScript compiler
import "../ts-helpers";
import "../register-module-helpers";
// This method iterates all the keys in the source exports object and copies them to the destination exports one.

View File

@@ -1,6 +0,0 @@
/**
* Nothing exported. Side effects: registers ts-helpers and module-helpers
* @module "globals/core"
*/ /** */
import "../ts-helpers";
import "../register-module-helpers";

View File

@@ -1,6 +0,0 @@
{
"name": "core",
"main": "globals-core",
"types": "globals-core.d.ts",
"nativescript": {}
}

View File

@@ -1,10 +0,0 @@
import "./core";
import "./polyfills/timers";
import "./polyfills/animation";
import "./polyfills/dialogs";
import "./polyfills/text";
import "./polyfills/xhr";
import "./polyfills/fetch";
import "./decorators";

View File

@@ -1,4 +1,4 @@
/**
* Register globals such as setTimeout, setInterval, console etc.
*/
export function install();
export function initGlobal();

View File

@@ -0,0 +1,78 @@
export let hasInitGlobal = false;
function registerOnGlobalContext(moduleName: string, exportName: string): void {
Object.defineProperty(global, exportName, {
get: function () {
// We do not need to cache require() call since it is already cached in the runtime.
let m = global.loadModule(moduleName);
// Redefine the property to make sure the above code is executed only once.
let resolvedValue = m[exportName];
Object.defineProperty(global, exportName, { value: resolvedValue, configurable: true, writable: true });
return resolvedValue;
},
configurable: true
});
}
export function installPolyfills(moduleName: string, exportNames: string[]) {
if (global.__snapshot) {
const loadedModule = global.loadModule(moduleName);
exportNames.forEach(exportName => global[exportName] = loadedModule[exportName]);
} else {
exportNames.forEach(exportName => registerOnGlobalContext(moduleName, exportName));
}
}
export function initGlobal() {
console.log("initPolyfills called, init:", hasInitGlobal);
if (!hasInitGlobal) {
hasInitGlobal = true;
// apply global polyfills first
require("./core");
// DOM api polyfills
global.registerModule("timer", () => require("../timer"));
installPolyfills("timer", [
"setTimeout",
"clearTimeout",
"setInterval",
"clearInterval",
]);
global.registerModule("animation", () => require("../animation-frame"));
installPolyfills("animation", [
"requestAnimationFrame",
"cancelAnimationFrame",
]);
global.registerModule("ui-dialogs", () => require("../ui/dialogs"));
installPolyfills("ui-dialogs", [
"alert",
"confirm",
"prompt",
"login",
"action",
]);
global.registerModule("text", () => require("../text"));
installPolyfills("text", ["TextDecoder", "TextEncoder"]);
global.registerModule("xhr", () => require("../xhr"));
installPolyfills("xhr", [
"XMLHttpRequest",
"FormData",
"Blob",
"File",
"FileReader",
]);
global.registerModule("fetch", () => require("../fetch"));
installPolyfills("fetch", ["fetch", "Headers", "Request", "Response"]);
// Custom decorators
require("./decorators");
}
}

View File

@@ -1,6 +0,0 @@
{
"name": "globals",
"main": "globals",
"types": "globals.d.ts",
"nativescript": {}
}

View File

@@ -1,5 +0,0 @@
/**
* Installs animations polyfill.
* @module "globals/polyfills/animations"
*/ /** */
import "../../core";

View File

@@ -1,6 +0,0 @@
import "../../core";
import { installPolyfills } from "../polyfill-helpers";
global.registerModule("animation", () => require("../../../animation-frame"));
installPolyfills("animation", ["requestAnimationFrame", "cancelAnimationFrame"]);

View File

@@ -1,6 +0,0 @@
{
"name": "animation",
"main": "animation",
"types": "animation.d.ts",
"nativescript": {}
}

View File

@@ -1,5 +0,0 @@
/**
* Installs dialogs polyfill.
* @module "globals/polyfills/dialogs"
*/ /** */
import "../../core";

View File

@@ -1,6 +0,0 @@
import "../../core";
import { installPolyfills } from "../polyfill-helpers";
global.registerModule("ui-dialogs", () => require("../../../ui/dialogs"));
installPolyfills("ui-dialogs", ["alert", "confirm", "prompt", "login", "action"]);

View File

@@ -1,6 +0,0 @@
{
"name": "dialogs",
"main": "dialogs",
"types": "dialogs.d.ts",
"nativescript": {}
}

View File

@@ -1,6 +0,0 @@
/**
* Installs fetch polyfill.
* @module "globals/polyfills/fetch"
*/ /** */
import "../../core";
import "../../polyfills/xhr";

View File

@@ -1,8 +0,0 @@
import "../../core";
import "../../polyfills/xhr";
import { installPolyfills } from "../polyfill-helpers";
global.registerModule("fetch", () => require("../../../fetch"));
installPolyfills("fetch", ["fetch", "Headers", "Request", "Response"]);

View File

@@ -1,6 +0,0 @@
{
"name": "fetch",
"main": "fetch",
"types": "fetch.d.ts",
"nativescript": {}
}

View File

@@ -1,6 +0,0 @@
{
"name": "polyfill-helpers",
"main": "polyfill-helpers",
"types": "polyfill-helpers.d.ts",
"nativescript": {}
}

View File

@@ -1,6 +0,0 @@
/**
* Global polyfills helpers.
* @module "globals/polyfills/polyfill-helpers"
*/ /** */
import "../../core";
export declare function installPolyfills(moduleName: string, exportNames: string[]): void;

View File

@@ -1,26 +0,0 @@
import "../../core";
function registerOnGlobalContext(moduleName: string, exportName: string): void {
Object.defineProperty(global, exportName, {
get: function () {
// We do not need to cache require() call since it is already cached in the runtime.
let m = global.loadModule(moduleName);
// Redefine the property to make sure the above code is executed only once.
let resolvedValue = m[exportName];
Object.defineProperty(global, exportName, { value: resolvedValue, configurable: true, writable: true });
return resolvedValue;
},
configurable: true
});
}
export function installPolyfills(moduleName: string, exportNames: string[]) {
if (global.__snapshot) {
const loadedModule = global.loadModule(moduleName);
exportNames.forEach(exportName => global[exportName] = loadedModule[exportName]);
} else {
exportNames.forEach(exportName => registerOnGlobalContext(moduleName, exportName));
}
}

View File

@@ -1,5 +0,0 @@
{
"name" : "text",
"main" : "text",
"nativescript": {}
}

View File

@@ -1,8 +0,0 @@
import "../../core";
import "../../polyfills/xhr";
import { installPolyfills } from "../polyfill-helpers";
global.registerModule("text", () => require("../../../text"));
installPolyfills("text", ["TextDecoder", "TextEncoder"]);

View File

@@ -1,6 +0,0 @@
{
"name": "timers",
"main": "timers",
"types": "timers.d.ts",
"nativescript": {}
}

View File

@@ -1,5 +0,0 @@
/**
* Installs timers polyfill.
* @module "globals/polyfills/fetch"
*/ /** */
import "../../core";

View File

@@ -1,6 +0,0 @@
import "../../core";
import { installPolyfills } from "../polyfill-helpers";
global.registerModule("timer", () => require("../../../timer"));
installPolyfills("timer", ["setTimeout", "clearTimeout", "setInterval", "clearInterval"]);

View File

@@ -1,6 +0,0 @@
{
"name": "xhr",
"main": "xhr",
"types": "xhr.d.ts",
"nativescript": {}
}

View File

@@ -1,5 +0,0 @@
/**
* Installs xhr polyfill.
* @module "globals/polyfills/fetch"
*/ /** */
import "../../core";

View File

@@ -1,6 +0,0 @@
import "../../core";
import { installPolyfills } from "../polyfill-helpers";
global.registerModule("xhr", () => require("../../../xhr"));
installPolyfills("xhr", ["XMLHttpRequest", "FormData", "Blob", "File", "FileReader"]);

View File

@@ -1,7 +1,3 @@
/**
* @module "http/http-request"
*/ /** */
import { HttpRequestOptions, HttpResponse, Headers } from "..";
import { HttpRequestOptions, HttpResponse, Headers } from "..";
export const request: (options: HttpRequestOptions) => Promise<HttpResponse>;
export function addHeader(headers: Headers, key: string, value: string): void;

View File

@@ -1,9 +1,4 @@
/**
* Allows you to send web requests and receive the responses.
* @module "http"
*/ /** */
import { ImageSource } from "../image-source";
import { ImageSource } from "../image-source";
import { File } from "../file-system";
/**

View File

@@ -1,7 +1,3 @@
/**
* @module "image-asset"
*/ /** */
import { Observable } from "../data/observable";
export class ImageAsset extends Observable {

View File

@@ -1,9 +1,4 @@
/**
* Contains the ImageSource class, which encapsulates the common abstraction behind a platform specific object (typically a Bitmap) that is used as a source for images.
* @module "image-source"
*/ /** */
import { ImageAsset } from "../image-asset";
import { ImageAsset } from "../image-asset";
import { Font } from "../ui/styling/font";
import { Color } from "../color";
/**

View File

@@ -1,5 +1,3 @@
/// <reference path="./tns-core-modules.d.ts" />
export { ApplicationEventData, LaunchEventData, OrientationChangedEventData, UnhandledErrorEventData, DiscardedErrorEventData, CssChangedEventData, LoadAppCSSEventData, iOSApplication, AndroidApplication, AndroidActivityEventData, AndroidActivityBundleEventData, AndroidActivityRequestPermissionsEventData, AndroidActivityResultEventData, AndroidActivityNewIntentEventData, AndroidActivityBackPressedEventData, } from "./application";
import { getMainEntry, getRootView, setResources, setCssFileName, getCssFileName, loadAppCss, addCss, on, off, run, orientation, getNativeApplication, hasLaunched, AndroidApplication, iOSApplication } from "./application";
export declare const Application: {

View File

@@ -1,4 +1,8 @@
/// <reference path="./tns-core-modules.d.ts" />
// apply polyfills first
import { initGlobal, hasInitGlobal } from './globals';
if (!hasInitGlobal) {
initGlobal();
}
// Export all interfaces from "application" module
export {

View File

@@ -1,9 +1,4 @@
/**
* @module "js-libs/easysax"
* @private
*/ /** */
//@private
//@private
export class EasySAXParser {
constructor();
parse(xml: string): void;

View File

@@ -1,8 +1,4 @@
/**
* @module "js-libs/esprima"
*/ /** */
/* tslint:disable */
/* tslint:disable */
// Type definitions for Esprima v1.2.0
// Project: http://esprima.org

View File

@@ -1,9 +1,4 @@
/**
* @module "js-libs/polymer-expressions"
* @private
*/ /** */
//@private
//@private
export class PolymerExpressions {
static getExpression(expression: string): Expression;
}

View File

@@ -2,8 +2,7 @@
* Contains utility methods for transforming css matrixes.
* All methods in this module are experimental and
* may be changed in a non-major version.
* @module "matrix"
*/ /** */
*/
import { TransformFunctionsInfo } from "../ui/animation/animation";

View File

@@ -1,10 +1,9 @@
/**
* Provides ModuleNameResolver class used for loading files based on device capabilities.
* @module "module-name-resolver"
*/ /** */
import { PlatformContext } from "./qualifier-matcher";
export { PlatformContext } from "./qualifier-matcher";
// export { PlatformContext } from "./qualifier-matcher";
export type ModuleListProvider = () => string[];

View File

@@ -4,9 +4,7 @@ import * as appCommonModule from "../application/application-common";
import { PlatformContext, findMatch, stripQualifiers } from "./qualifier-matcher";
import { registerModulesFromFileSystem } from "./non-bundle-workflow-compat";
import {
isEnabled as traceEnabled,
write as traceWrite,
categories as traceCategories
Trace
} from "../trace";
export class ModuleNameResolver implements ModuleNameResolverDefinition {
@@ -23,8 +21,8 @@ export class ModuleNameResolver implements ModuleNameResolverDefinition {
this._cache[key] = result;
}
if (traceEnabled()) {
traceWrite(`path: '${path}' with ext: '${ext}' resolved: '${result}'`, traceCategories.ModuleNameResolver);
if (Trace.isEnabled()) {
Trace.write(`path: '${path}' with ext: '${ext}' resolved: '${result}'`, Trace.categories.ModuleNameResolver);
}
return result;
@@ -81,7 +79,7 @@ export function resolveModuleName(path: string, ext: string): string {
}
function resolveModuleSnapshot(path, ext) {
traceWrite(`Resolving module in SNAPSHOT context - path: '${path}' with ext: '${ext}'`, traceCategories.ModuleNameResolver);
Trace.write(`Resolving module in SNAPSHOT context - path: '${path}' with ext: '${ext}'`, Trace.categories.ModuleNameResolver);
// Platform module when in snapshot. So resolve modules with default android phone.
// NB: The only module name that should ever be resolved while in snapshot is app.css, because it is

View File

@@ -1,24 +1,22 @@
import * as fs from "../file-system/file-system";
import * as appCommonModule from "../application/application-common";
import {
isEnabled as traceEnabled,
write as traceWrite,
categories as traceCategories
Trace
} from "../trace";
const cache = new Set<string>();
let initialized = false;
function register(name: string, loader: (name?: string) => void) {
if (traceEnabled()) {
traceWrite(`[Compat] Register module: ${name}`, traceCategories.ModuleNameResolver);
if (Trace.isEnabled()) {
Trace.write(`[Compat] Register module: ${name}`, Trace.categories.ModuleNameResolver);
}
global.registerModule(name, loader);
if (name.startsWith("tns_modules")) {
const nonTnsModulesName = name.substr("tns_modules".length + 1);
if (traceEnabled()) {
traceWrite(`[Compat] Register module: ${nonTnsModulesName}`, traceCategories.ModuleNameResolver);
if (Trace.isEnabled()) {
Trace.write(`[Compat] Register module: ${nonTnsModulesName}`, Trace.categories.ModuleNameResolver);
}
global.registerModule(nonTnsModulesName, loader);
}
@@ -66,8 +64,8 @@ function processFolder(path: string): boolean {
}
cache.add(path);
if (traceEnabled()) {
traceWrite(`[Compat] Processing folder: ${path}`, traceCategories.ModuleNameResolver);
if (Trace.isEnabled()) {
Trace.write(`[Compat] Processing folder: ${path}`, Trace.categories.ModuleNameResolver);
}
let folderEmpty = true;

View File

@@ -1,7 +1,6 @@
/**
* Provides ModuleNameResolver class used for loading files based on device capabilities.
* @module "module-name-resolver/qualifier-matcher"
*/ /** */
*/
export interface PlatformContext {
width: number;

View File

@@ -1,4 +1,3 @@
/// <reference path="./nativescript-error.d.ts" />
declare var global: NodeJS.Global;
interface ModuleResolver {

View File

@@ -19,17 +19,17 @@
],
"license": "Apache-2.0",
"dependencies": {
"css-tree": "^1.0.0-alpha.37",
"nativescript-hook": "0.2.5",
"@nativescript/hook": "~1.0.0",
"css-tree": "^1.0.0-alpha.39",
"reduce-css-calc": "^2.1.6",
"semver": "6.3.0",
"tns-core-modules-widgets": "6.5.10",
"tslib": "1.10.0"
"semver": "~7.3.2",
"tns-core-modules-widgets": "~6.5.2",
"tslib": "~2.0.0"
},
"devDependencies": {
"@types/chai": "~4.2.5",
"@types/node": "~10.12.18",
"tns-platform-declarations": "6.5.10"
"@types/chai": "~4.2.11",
"@types/node": "~14.0.14",
"tns-platform-declarations": "~6.5.8"
},
"scripts": {
"version": "conventional-changelog -p angular -i ../CHANGELOG.md -s && git add ../CHANGELOG.md",
@@ -49,15 +49,5 @@
"inject": true
}
]
},
"snapshot": {
"android": {
"tns-java-classes": {
"modules": [
"ui/frame/activity",
"ui/frame/fragment"
]
}
}
}
}

View File

@@ -1,7 +1,6 @@
/**
* Contains all kinds of information about the device, its operating system and software.
* @module "platform"
*/ /** */
*/
/* tslint:disable:class-name */

View File

@@ -1,8 +1,7 @@
/**
* Contains contains utility methods for profiling.
* All methods in this module are experimental and may be changed in a non-major version.
* @module "profiling"
*/ /** */
*/
interface TimerInfo {
totalTime: number;

View File

@@ -1,3 +1,5 @@
/// <reference path="../tns-platform-declarations/ios.d.ts" />
/// <reference path="../tns-platform-declarations/android.d.ts" />
/// <reference path="platforms/ios/typings/objc!MaterialComponents.d.ts" />
/// <reference path="./tns-core-modules.d.ts" />
/// <reference path="./nativescript-error.d.ts" />

View File

@@ -1,6 +1 @@
/**
* Contains the FormattedString and Span classes, which are used to create a formatted (rich text) strings.
* @module "text/formatted-string"
*/ /** */
export * from "../ui/text-base/formatted-string";
export * from "../ui/text-base/formatted-string";

View File

@@ -1,5 +1 @@
/**
* @module "text/span"
*/ /** */
export * from "../ui/text-base/span";
export * from "../ui/text-base/span";

View File

@@ -1,9 +1,4 @@
/**
* Defines specific text related enumerations.
* @module "text"
*/ /** */
export * from "./text-common";
export * from "./text-common";
/**
* Defines the supported character encodings.

View File

@@ -1,9 +1,4 @@
/**
* Allows you to create, start, stop and react to timers.
* @module "timer"
*/ /** */
/**
* Calls a function after a specified delay.
* @param callback The function to be called.
* @param milliseconds The time to wait before the function is called. Defaults to 0.

View File

@@ -1,6 +1,3 @@
/* tslint:disable:no-unused-variable */
///<reference path="./module.d.ts" />
declare enum RequestContext {
"audio", "beacon", "cspreport", "download", "embed", "eventsource", "favicon", "fetch",
"font", "form", "frame", "hyperlink", "iframe", "image", "imageset", "import",

View File

@@ -2,8 +2,8 @@ The trace module is used to track code execution and to receive notifications fo
It is disabled by default and to enable it you will need to call its enable() method.
```js
import * as trace from "trace";
trace.enable();
import { Trace } from "@nativescript/core";
Trace.enable();
```
The module writes its output through a collection of TraceWriter objects. By default there is one ConsoleWriter instance added to the module. There is a filtering functionality which is implemented by the `setCategories(string)` method. The method argument is a string containing one or more comma-delimited categories: `"Layout,VisualTreeEvents"`.
@@ -11,28 +11,28 @@ The module writes its output through a collection of TraceWriter objects. By def
How to specify category(s):
```js
import * as trace from "trace";
import { Trace } from "@nativescript/core";
// only the Layout messages are traced
trace.setCategories(traceCategories.Layout);
Trace.setCategories(Trace.categories.Layout);
```
```js
import * as trace from "trace";
import { Trace } from "@nativescript/core";
// set Layout + VisualTreeEvents categories
trace.setCategories(traceCategories.concat(traceCategories.Layout, traceCategories.VisualTreeEvents));
Trace.setCategories(Trace.categories.concat(Trace.categories.Layout, Trace.categories.VisualTreeEvents));
```
```js
import * as trace from "trace";
import { Trace } from "@nativescript/core";
// trace everything
trace.setCategories(traceCategories.All);
Trace.setCategories(Trace.categories.All);
```
How to trace:
```js
import * as trace from "trace";
traceWrite("tracing message", traceCategories.Layout);
import { Trace } from "@nativescript/core";
Trace.write("tracing message", Trace.categories.Layout);
```
The module also supports events notifications through the EventListener interface. You may call the `trace.notifyEvent` method and all registered listeners will receive a notification for the event.
@@ -40,9 +40,9 @@ The module also supports events notifications through the EventListener interfac
How to create and register a listener:
```js
import * as trace from "trace";
import { Trace } from "@nativescript/core";
class Listener implements trace.EventListener {
class Listener implements Trace.EventListener {
public filter: string;
public receivedEvents: Array<{ sender: Object; name: string }> = [];
@@ -63,15 +63,14 @@ class Listener implements trace.EventListener {
var listener = new Listener("_onAttached");
// register the listener
trace.addEventListener(listener);
Trace.addEventListener(listener);
```
How to raise events:
```js
import * as trace from "trace";
import * as view from "ui/core/view";
import { Trace, View } from "@nativescript/core";
var newView = new view.View();
trace.notifyEvent(newView, "_viewCreated");
var newView = new View();
Trace.notifyEvent(newView, "_viewCreated");
```

View File

@@ -0,0 +1,299 @@
/**
* An interface used to define a writer used by trace to print (log).
*/
export interface TraceWriter {
write(message: any, category: string, type?: number): void;
}
/**
* An interface used to trace information about specific event.
*/
export interface EventListener {
filter: string;
on(object: Object, name: string, data?: any): void;
}
/**
* An interface used to for handling trace error
*/
export interface ErrorHandler {
handlerError(error: Error): any;
}
let enabled = false;
let _categories = {};
let _writers: Array<TraceWriter> = [];
let _eventListeners: Array<EventListener> = [];
let _errorHandler: ErrorHandler;
export namespace Trace {
/**
* Enables the trace module.
*/
export function enable() {
enabled = true;
}
/**
* Disables the trace module.
*/
export function disable() {
enabled = false;
}
/**
* A function that returns whether the tracer is enabled and there is a point in writing messages.
* Check this to avoid writing complex string templates.
* Send error messages even if tracing is disabled.
*/
export function isEnabled() {
return enabled;
}
/**
* Adds a TraceWriter instance to the trace module.
* @param writer The TraceWriter instance to add.
*/
export function addWriter(writer: TraceWriter) {
_writers.push(writer);
}
/**
* Removes a TraceWriter instance from the trace module.
* @param writer The TraceWriter instance to remove.
*/
export function removeWriter(writer: TraceWriter) {
let index = _writers.indexOf(writer);
if (index >= 0) {
_writers.splice(index, 1);
}
}
/**
* Clears all the writers from the trace module.
*/
export function clearWriters() {
if (_writers.length > 0) {
_writers.splice(0, _writers.length);
}
}
/**
* Sets the categories the module will trace.
* @param categories The comma-separated list of categories. If not specified all messages from all categories will be traced.
*/
export function setCategories(categories: string) {
_categories = {};
addCategories(categories);
}
/**
* Adds categories to existing categories the module will trace.
* @param categories The comma-separated list of categories. If not specified all messages from all categories will be traced.
*/
export function addCategories(categories: string) {
let split = categories.split(",");
for (let i = 0; i < split.length; i++) {
_categories[split[i].trim()] = true;
}
}
/**
* Check if category is already set in trace module.
* @param category The category to check.
*/
export function isCategorySet(category: string): boolean {
return category in _categories;
}
/**
* Writes a message using the available writers.
* @param message The message to be written.
* @param category The category of the message.
* @param type Optional, the type of the message - info, warning, error.
*/
export function write(message: any, category: string, type?: number) {
// print error no matter what
let i;
if (type === messageType.error) {
for (i = 0; i < _writers.length; i++) {
_writers[i].write(message, category, type);
}
return;
}
if (!enabled) {
return;
}
if (!(category in _categories)) {
return;
}
for (i = 0; i < _writers.length; i++) {
_writers[i].write(message, category, type);
}
}
/**
* Notifies all the attached listeners for an event that has occurred in the sender object.
* @param object The Object instance that raised the event.
* @param name The name of the raised event.
* @param data An optional parameter that passes the data associated with the event.
*/
export function notifyEvent(object: Object, name: string, data?: any) {
if (!enabled) {
return;
}
let i, listener: EventListener, filters: Array<string>;
for (i = 0; i < _eventListeners.length; i++) {
listener = _eventListeners[i];
if (listener.filter) {
filters = listener.filter.split(",");
filters.forEach((value: string) => {
if (value.trim() === name) {
listener.on(object, name, data);
}
});
} else {
listener.on(object, name, data);
}
}
}
export function addEventListener(listener: EventListener) {
_eventListeners.push(listener);
}
export function removeEventListener(listener: EventListener) {
const index = _eventListeners.indexOf(listener);
if (index >= 0) {
_eventListeners.splice(index, 1);
}
}
export module messageType {
export const log = 0;
export const info = 1;
export const warn = 2;
export const error = 3;
}
/**
* all predefined categories.
*/
export module categories {
export const VisualTreeEvents = "VisualTreeEvents";
export const Layout = "Layout";
export const Style = "Style";
export const ViewHierarchy = "ViewHierarchy";
export const NativeLifecycle = "NativeLifecycle";
export const Debug = "Debug";
export const Navigation = "Navigation";
export const Test = "Test";
export const Binding = "Binding";
export const BindingError = "BindingError";
export const Error = "Error";
export const Animation = "Animation";
export const Transition = "Transition";
export const Livesync = "Livesync";
export const ModuleNameResolver = "ModuleNameResolver";
export const separator = ",";
export const All = [
VisualTreeEvents,
Layout,
Style,
ViewHierarchy,
NativeLifecycle,
Debug,
Navigation,
Test,
Binding,
Error,
Animation,
Transition,
Livesync,
ModuleNameResolver,
].join(separator);
export function concat(): string {
let result: string;
for (let i = 0; i < arguments.length; i++) {
if (!result) {
result = arguments[i];
continue;
}
result = result.concat(separator, arguments[i]);
}
return result;
}
}
class ConsoleWriter implements TraceWriter {
public write(message: any, category: string, type?: number) {
if (!console) {
return;
}
let msgType;
if (type === undefined) {
msgType = messageType.log;
} else {
msgType = type;
}
switch (msgType) {
case messageType.log:
console.log(category + ": " + message);
break;
case messageType.info:
console.info(category + ": " + message);
break;
case messageType.warn:
console.warn(category + ": " + message);
break;
case messageType.error:
console.error(category + ": " + message);
break;
}
}
}
// register a ConsoleWriter by default
addWriter(new ConsoleWriter());
export class DefaultErrorHandler implements ErrorHandler {
handlerError(error) {
throw error;
}
}
setErrorHandler(new DefaultErrorHandler());
export function getErrorHandler(): ErrorHandler {
return _errorHandler;
}
export function setErrorHandler(handler: ErrorHandler) {
_errorHandler = handler;
}
/**
* Passes an error to the registered ErrorHandler
* @param error The error to be handled.
*/
export function error(error: string | Error) {
if (!_errorHandler) {
return;
}
if (typeof error === "string") {
error = new Error(error);
}
_errorHandler.handlerError(error);
}
}

View File

@@ -1,6 +0,0 @@
{
"name": "trace",
"main": "trace",
"types": "trace.d.ts",
"nativescript": {}
}

View File

@@ -1,146 +0,0 @@
/**
* Allows you to trace and print specific information based on categories.
* @module "trace"
*/ /** */
/**
* Enables the trace module.
*/
export function enable(): void;
/**
* Disables the trace module.
*/
export function disable(): void;
/**
* A function that returns whether the tracer is enabled and there is a point in writing messages.
* Check this to avoid writing complex string templates.
* Send error messages even if tracing is disabled.
*/
export function isEnabled(): boolean;
/**
* Adds a TraceWriter instance to the trace module.
* @param writer The TraceWriter instance to add.
*/
export function addWriter(writer: TraceWriter);
/**
* Removes a TraceWriter instance from the trace module.
* @param writer The TraceWriter instance to remove.
*/
export function removeWriter(writer: TraceWriter);
/**
* Clears all the writers from the trace module.
*/
export function clearWriters();
/**
* Sets the categories the module will trace.
* @param categories The comma-separated list of categories. If not specified all messages from all categories will be traced.
*/
export function setCategories(categories: string);
/**
* Adds categories to existing categories the module will trace.
* @param categories The comma-separated list of categories. If not specified all messages from all categories will be traced.
*/
export function addCategories(categories: string);
/**
* Check if category is already set in trace module.
* @param category The category to check.
*/
export function isCategorySet(category: string): boolean;
/**
* Writes a message using the available writers.
* @param message The message to be written.
* @param category The category of the message.
* @param type Optional, the type of the message - info, warning, error.
*/
export function write(message: any, category: string, type?: number);
/**
* Passes an error to the registered ErrorHandler
* @param error The error to be handled.
*/
export function error(error: string | Error);
/**
* Notifies all the attached listeners for an event that has occurred in the sender object.
* @param object The Object instance that raised the event.
* @param name The name of the raised event.
* @param data An optional parameter that passes the data associated with the event.
*/
export function notifyEvent(object: Object, name: string, data?: any);
export function addEventListener(listener: EventListener);
export function removeEventListener(listener: EventListener);
export function getErrorHandler(): ErrorHandler;
export function setErrorHandler(handler: ErrorHandler);
/**
* An enum that defines all predefined categories.
*/
export module categories {
export const VisualTreeEvents: string;
export const Layout: string;
export const Style: string;
export const ViewHierarchy: string;
export const NativeLifecycle: string;
export const Debug: string;
export const Navigation: string;
export const Test: string;
export const Binding: string;
export const Error: string;
export const Animation: string;
export const Transition: string;
export const Livesync: string;
export const ModuleNameResolver: string;
export const separator: string;
export const All: string;
export function concat(...categories: string[]): string;
}
/**
* An enum that defines all predefined message types.
*/
export module messageType {
export const log: number;
export const info: number;
export const warn: number;
export const error: number;
}
/**
* An interface used to define a writer used by trace to print (log).
*/
export interface TraceWriter {
write(message: any, category: string, type?: number);
}
/**
* An interface used to trace information about specific event.
*/
export interface EventListener {
filter: string;
on(object: Object, name: string, data?: any);
}
/**
* An interface used to for handling trace error
*/
export interface ErrorHandler {
handlerError(error: Error);
}
export class DefaultErrorHandler implements ErrorHandler {
handlerError(error);
}

View File

@@ -1,216 +0,0 @@
import { EventListener, TraceWriter, ErrorHandler } from ".";
let enabled = false;
let _categories = {};
let _writers: Array<TraceWriter> = [];
let _eventListeners: Array<EventListener> = [];
let _errorHandler: ErrorHandler;
export function enable() {
enabled = true;
}
export function disable() {
enabled = false;
}
export function isEnabled() {
return enabled;
}
export function isCategorySet(category: string): boolean {
return category in _categories;
}
export function addWriter(writer: TraceWriter) {
_writers.push(writer);
}
export function removeWriter(writer: TraceWriter) {
let index = _writers.indexOf(writer);
if (index >= 0) {
_writers.splice(index, 1);
}
}
export function clearWriters() {
if (_writers.length > 0) {
_writers.splice(0, _writers.length);
}
}
export function setCategories(categories: string) {
_categories = {};
addCategories(categories);
}
export function addCategories(categories: string) {
let split = categories.split(",");
for (let i = 0; i < split.length; i++) {
_categories[split[i].trim()] = true;
}
}
export function write(message: any, category: string, type?: number) {
// print error no matter what
let i;
if (type === messageType.error) {
for (i = 0; i < _writers.length; i++) {
_writers[i].write(message, category, type);
}
return;
}
if (!enabled) {
return;
}
if (!(category in _categories)) {
return;
}
for (i = 0; i < _writers.length; i++) {
_writers[i].write(message, category, type);
}
}
export function notifyEvent(object: Object, name: string, data?: any) {
if (!enabled) {
return;
}
let i,
listener: EventListener,
filters: Array<string>;
for (i = 0; i < _eventListeners.length; i++) {
listener = _eventListeners[i];
if (listener.filter) {
filters = listener.filter.split(",");
filters.forEach((value: string) => {
if (value.trim() === name) {
listener.on(object, name, data);
}
});
} else {
listener.on(object, name, data);
}
}
}
export function addEventListener(listener: EventListener) {
_eventListeners.push(listener);
}
export function removeEventListener(listener: EventListener) {
const index = _eventListeners.indexOf(listener);
if (index >= 0) {
_eventListeners.splice(index, 1);
}
}
export module messageType {
export const log = 0;
export const info = 1;
export const warn = 2;
export const error = 3;
}
export module categories {
export const VisualTreeEvents = "VisualTreeEvents";
export const Layout = "Layout";
export const Style = "Style";
export const ViewHierarchy = "ViewHierarchy";
export const NativeLifecycle = "NativeLifecycle";
export const Debug = "Debug";
export const Navigation = "Navigation";
export const Test = "Test";
export const Binding = "Binding";
export const BindingError = "BindingError";
export const Error = "Error";
export const Animation = "Animation";
export const Transition = "Transition";
export const Livesync = "Livesync";
export const ModuleNameResolver = "ModuleNameResolver";
export const separator = ",";
export const All = [
VisualTreeEvents, Layout, Style,
ViewHierarchy, NativeLifecycle,
Debug, Navigation, Test, Binding,
Error, Animation, Transition, Livesync,
ModuleNameResolver]
.join(separator);
export function concat(): string {
let result: string;
for (let i = 0; i < arguments.length; i++) {
if (!result) {
result = arguments[i];
continue;
}
result = result.concat(separator, arguments[i]);
}
return result;
}
}
class ConsoleWriter implements TraceWriter {
public write(message: any, category: string, type?: number) {
if (!console) {
return;
}
let msgType;
if (type === undefined) {
msgType = messageType.log;
} else {
msgType = type;
}
switch (msgType) {
case messageType.log:
console.log(category + ": " + message);
break;
case messageType.info:
console.info(category + ": " + message);
break;
case messageType.warn:
console.warn(category + ": " + message);
break;
case messageType.error:
console.error(category + ": " + message);
break;
}
}
}
// register a ConsoleWriter by default
addWriter(new ConsoleWriter());
export class DefaultErrorHandler implements ErrorHandler {
handlerError(error) {
throw error;
}
}
setErrorHandler(new DefaultErrorHandler());
export function getErrorHandler(): ErrorHandler {
return _errorHandler;
}
export function setErrorHandler(handler: ErrorHandler) {
_errorHandler = handler;
}
export function error(error: string | Error) {
if (!_errorHandler) {
return;
}
if (typeof error === "string") {
error = new Error(error);
}
_errorHandler.handlerError(error);
}

View File

@@ -6,14 +6,7 @@
"outDir": "../temp/dts-out"
},
"files": [
"index.ts",
"ui/index.ts",
"ui/layouts/index.ts"
],
"include": [
"index.ts",
"ui/index.ts",
"ui/layouts/index.ts"
"index.ts"
],
"exclude": [
"tns-core-modules/node_modules/"

View File

@@ -20,12 +20,7 @@
"chai",
"mocha"
],
"baseUrl": ".",
"paths": {
"@nativescript/core/*": [
"nativescript-core/*"
]
}
"baseUrl": "."
},
"include": [
"**/*.ts"

View File

@@ -7,23 +7,16 @@ import {
import { profile } from "../../profiling";
export * from "../core/view";
import {
View,
ViewBase,
Property,
unsetValue,
booleanConverter,
horizontalAlignmentProperty,
verticalAlignmentProperty,
CSSType,
traceWrite,
traceCategories,
traceMessageType
} from "../core/view";
import { ShorthandProperty, CssProperty, Style } from "../core/properties/properties";
import { Length } from "../core/view";
import { ViewBase, booleanConverter } from "../core/view-base";
import { Trace } from "../../trace";
import { ShorthandProperty, CssProperty, Property, unsetValue } from "../core/properties";
import { Length, horizontalAlignmentProperty,
verticalAlignmentProperty } from "../styling/style-properties";
import { Style } from '../styling/style';
export module knownCollections {
export const actionItems = "actionItems";
@@ -378,9 +371,9 @@ function onVisibilityChanged(item: ActionItemBase, oldValue: string, newValue: s
}
export function traceMissingIcon(icon: string) {
traceWrite("Could not load action bar icon: " + icon,
traceCategories.Error,
traceMessageType.error);
Trace.write("Could not load action bar icon: " + icon,
Trace.categories.Error,
Trace.messageType.error);
}
function convertToContentInset(this: void, value: string | Length): [CssProperty<any, any>, any][] {
@@ -436,7 +429,7 @@ export const androidContentInsetLeftProperty = new CssProperty<Style, Length>({
if (view) {
view.effectiveContentInsetLeft = Length.toDevicePixels(newValue);
} else {
traceWrite(`${newValue} not set to view's property because ".viewRef" is cleared`, traceCategories.Style, traceMessageType.warn);
Trace.write(`${newValue} not set to view's property because ".viewRef" is cleared`, Trace.categories.Style, Trace.messageType.warn);
}
}, valueConverter: Length.parse
});
@@ -450,7 +443,7 @@ export const androidContentInsetRightProperty = new CssProperty<Style, Length>({
if (view) {
view.effectiveContentInsetRight = Length.toDevicePixels(newValue);
} else {
traceWrite(`${newValue} not set to view's property because ".viewRef" is cleared`, traceCategories.Style, traceMessageType.warn);
Trace.write(`${newValue} not set to view's property because ".viewRef" is cleared`, Trace.categories.Style, Trace.messageType.warn);
}
}, valueConverter: Length.parse
});

View File

@@ -1,9 +1,13 @@
import { AndroidActionItemSettings, AndroidActionBarSettings as AndroidActionBarSettingsDefinition, ActionItem as ActionItemDefinition } from ".";
import {
ActionItemBase, ActionBarBase, isVisible,
View, layout, colorProperty, flatProperty, Color,
flatProperty,
traceMissingIcon, androidContentInsetLeftProperty, androidContentInsetRightProperty
} from "./action-bar-common";
import { View} from '../core/view';
import { Color} from '../../color';
import { layout} from '../../utils/utils';
import { colorProperty} from '../core/bindable';
import { RESOURCE_PREFIX, isFontIconURI } from "../../utils/utils";
import { ImageSource } from "../../image-source";
import * as application from "../../application";

View File

@@ -1,9 +1,6 @@
/**
* Contains the action bar related classes.
* @module "ui/action-bar"
*/ /** */
import { EventData, ViewBase, View } from "../core/view";
import { View } from "../core/view";
import { ViewBase } from "../core/view-base";
import { EventData } from "../../data/observable";
/**
* Provides an abstraction over the ActionBar (android) and NavigationBar (iOS).

View File

@@ -1,8 +1,6 @@
import { ActivityIndicator as ActivityIndicatorDefinition } from ".";
import { View, Property, booleanConverter, CSSType } from "../core/view";
export * from "../core/view";
@CSSType("ActivityIndicator")
export class ActivityIndicatorBase extends View implements ActivityIndicatorDefinition {
public busy: boolean;

View File

@@ -1,9 +1,4 @@
/**
* Contains the ActivityIndicator class, which represents a widget for showing that something is currently busy.
* @module "ui/activity-indicator"
*/ /** */
import { View } from "../core/view";
import { View } from "../core/view";
/**
* Represents a UI widget which displays a progress indicator hinting the user for some background operation running.

View File

@@ -12,12 +12,10 @@ import {
// Requires.
import { Color } from "../../color";
import {
isEnabled as traceEnabled, write as traceWrite,
categories as traceCategories, messageType as traceType
Trace
} from "../../trace";
import { PercentLength } from "../styling/style-properties";
export { Color, traceEnabled, traceWrite, traceCategories, traceType };
export * from "./animation-interfaces";
export module Properties {
@@ -57,8 +55,8 @@ export abstract class AnimationBase implements AnimationBaseDefinition {
throw new Error("No animation definitions specified");
}
if (traceEnabled()) {
traceWrite("Analyzing " + animationDefinitions.length + " animation definitions...", traceCategories.Animation);
if (Trace.isEnabled()) {
Trace.write("Analyzing " + animationDefinitions.length + " animation definitions...", Trace.categories.Animation);
}
this._propertyAnimations = new Array<PropertyAnimation>();
@@ -72,8 +70,8 @@ export abstract class AnimationBase implements AnimationBaseDefinition {
if (this._propertyAnimations.length === 0) {
throw new Error("Nothing to animate.");
}
if (traceEnabled()) {
traceWrite("Created " + this._propertyAnimations.length + " individual property animations.", traceCategories.Animation);
if (Trace.isEnabled()) {
Trace.write("Created " + this._propertyAnimations.length + " individual property animations.", Trace.categories.Animation);
}
this._playSequentially = playSequentially;
@@ -83,7 +81,7 @@ export abstract class AnimationBase implements AnimationBaseDefinition {
protected _rejectAlreadyPlaying(): AnimationPromiseDefinition {
const reason = "Animation is already playing.";
traceWrite(reason, traceCategories.Animation, traceType.warn);
Trace.write(reason, Trace.categories.Animation, Trace.messageType.warn);
return <AnimationPromiseDefinition>new Promise<void>((resolve, reject) => {
reject(reason);

View File

@@ -4,9 +4,10 @@ import { View } from "../core/view";
// Requires
import {
AnimationBase, Properties, CubicBezierAnimationCurve, Color, traceWrite,
traceEnabled, traceCategories, traceType
AnimationBase, Properties, CubicBezierAnimationCurve
} from "./animation-common";
import { Color } from "../../color";
import { Trace } from "../../trace";
import {
opacityProperty, backgroundColorProperty, rotateProperty, rotateXProperty, rotateYProperty,
translateXProperty, translateYProperty, scaleXProperty, scaleYProperty,
@@ -44,40 +45,40 @@ propertyKeys[Properties.width] = Symbol(keyPrefix + Properties.width);
export function _resolveAnimationCurve(curve: string | CubicBezierAnimationCurve | android.view.animation.Interpolator | android.view.animation.LinearInterpolator): android.view.animation.Interpolator {
switch (curve) {
case "easeIn":
if (traceEnabled()) {
traceWrite("Animation curve resolved to android.view.animation.AccelerateInterpolator(1).", traceCategories.Animation);
if (Trace.isEnabled()) {
Trace.write("Animation curve resolved to android.view.animation.AccelerateInterpolator(1).", Trace.categories.Animation);
}
return easeIn();
case "easeOut":
if (traceEnabled()) {
traceWrite("Animation curve resolved to android.view.animation.DecelerateInterpolator(1).", traceCategories.Animation);
if (Trace.isEnabled()) {
Trace.write("Animation curve resolved to android.view.animation.DecelerateInterpolator(1).", Trace.categories.Animation);
}
return easeOut();
case "easeInOut":
if (traceEnabled()) {
traceWrite("Animation curve resolved to android.view.animation.AccelerateDecelerateInterpolator().", traceCategories.Animation);
if (Trace.isEnabled()) {
Trace.write("Animation curve resolved to android.view.animation.AccelerateDecelerateInterpolator().", Trace.categories.Animation);
}
return easeInOut();
case "linear":
if (traceEnabled()) {
traceWrite("Animation curve resolved to android.view.animation.LinearInterpolator().", traceCategories.Animation);
if (Trace.isEnabled()) {
Trace.write("Animation curve resolved to android.view.animation.LinearInterpolator().", Trace.categories.Animation);
}
return linear();
case "spring":
if (traceEnabled()) {
traceWrite("Animation curve resolved to android.view.animation.BounceInterpolator().", traceCategories.Animation);
if (Trace.isEnabled()) {
Trace.write("Animation curve resolved to android.view.animation.BounceInterpolator().", Trace.categories.Animation);
}
return bounce();
case "ease":
return (<any>androidx).core.view.animation.PathInterpolatorCompat.create(0.25, 0.1, 0.25, 1.0);
default:
if (traceEnabled()) {
traceWrite("Animation curve resolved to original: " + curve, traceCategories.Animation);
if (Trace.isEnabled()) {
Trace.write("Animation curve resolved to original: " + curve, Trace.categories.Animation);
}
if (curve instanceof CubicBezierAnimationCurve) {
return (<any>androidx).core.view.animation.PathInterpolatorCompat.create(curve.x1, curve.y1, curve.x2, curve.y2);
@@ -143,18 +144,18 @@ export class Animation extends AnimationBase {
let that = new WeakRef(this);
this._animatorListener = new android.animation.Animator.AnimatorListener({
onAnimationStart: function (animator: android.animation.Animator): void {
if (traceEnabled()) {
traceWrite("MainAnimatorListener.onAndroidAnimationStart(" + animator + ")", traceCategories.Animation);
if (Trace.isEnabled()) {
Trace.write("MainAnimatorListener.onAndroidAnimationStart(" + animator + ")", Trace.categories.Animation);
}
},
onAnimationRepeat: function (animator: android.animation.Animator): void {
if (traceEnabled()) {
traceWrite("MainAnimatorListener.onAnimationRepeat(" + animator + ")", traceCategories.Animation);
if (Trace.isEnabled()) {
Trace.write("MainAnimatorListener.onAnimationRepeat(" + animator + ")", Trace.categories.Animation);
}
},
onAnimationEnd: function (animator: android.animation.Animator): void {
if (traceEnabled()) {
traceWrite("MainAnimatorListener.onAnimationEnd(" + animator + ")", traceCategories.Animation);
if (Trace.isEnabled()) {
Trace.write("MainAnimatorListener.onAnimationEnd(" + animator + ")", Trace.categories.Animation);
}
const thisRef = that.get();
if (thisRef) {
@@ -162,8 +163,8 @@ export class Animation extends AnimationBase {
}
},
onAnimationCancel: function (animator: android.animation.Animator): void {
if (traceEnabled()) {
traceWrite("MainAnimatorListener.onAnimationCancel(" + animator + ")", traceCategories.Animation);
if (Trace.isEnabled()) {
Trace.write("MainAnimatorListener.onAnimationCancel(" + animator + ")", Trace.categories.Animation);
}
const thisRef = that.get();
if (thisRef) {
@@ -207,12 +208,12 @@ export class Animation extends AnimationBase {
public cancel(): void {
if (!this.isPlaying) {
traceWrite("Animation is not currently playing.", traceCategories.Animation, traceType.warn);
Trace.write("Animation is not currently playing.", Trace.categories.Animation, Trace.messageType.warn);
return;
}
traceWrite("Cancelling AnimatorSet.", traceCategories.Animation);
Trace.write("Cancelling AnimatorSet.", Trace.categories.Animation);
this._animatorSet.cancel();
}
@@ -238,8 +239,8 @@ export class Animation extends AnimationBase {
}
}
if (traceEnabled()) {
traceWrite("Starting " + this._nativeAnimatorsArray.length + " animations " + (this._playSequentially ? "sequentially." : "together."), traceCategories.Animation);
if (Trace.isEnabled()) {
Trace.write("Starting " + this._nativeAnimatorsArray.length + " animations " + (this._playSequentially ? "sequentially." : "together."), Trace.categories.Animation);
}
this._animatorSet.setupStartValues();
@@ -276,8 +277,8 @@ export class Animation extends AnimationBase {
return;
}
if (traceEnabled()) {
traceWrite("Creating ObjectAnimator(s) for animation: " + Animation._getAnimationInfo(propertyAnimation) + "...", traceCategories.Animation);
if (Trace.isEnabled()) {
Trace.write("Creating ObjectAnimator(s) for animation: " + Animation._getAnimationInfo(propertyAnimation) + "...", Trace.categories.Animation);
}
if (propertyAnimation.target === null || propertyAnimation.target === undefined) {
@@ -546,8 +547,8 @@ export class Animation extends AnimationBase {
animators[i].setInterpolator(propertyAnimation.curve);
}
if (traceEnabled()) {
traceWrite("Animator created: " + animators[i], traceCategories.Animation);
if (Trace.isEnabled()) {
Trace.write("Animator created: " + animators[i], Trace.categories.Animation);
}
}

View File

@@ -1,8 +1,5 @@
/**
* @module "ui/animation"
*/ /** */
import { View, Color } from "../core/view";
import { View } from "../core/view";
import { Color } from "../../color";
import { PercentLength } from "../styling/style-properties";
/**

View File

@@ -7,9 +7,9 @@ import { View } from "../core/view";
// Requires
import {
AnimationBase, Properties, CubicBezierAnimationCurve,
traceWrite, traceEnabled, traceCategories, traceType
AnimationBase, Properties, CubicBezierAnimationCurve
} from "./animation-common";
import { Trace } from "../../trace";
import {
opacityProperty, backgroundColorProperty, rotateProperty, rotateXProperty, rotateYProperty,
translateXProperty, translateYProperty, scaleXProperty, scaleYProperty,
@@ -167,12 +167,12 @@ export class Animation extends AnimationBase {
}
if (!playSequentially) {
if (traceEnabled()) {
traceWrite("Non-merged Property Animations: " + this._propertyAnimations.length, traceCategories.Animation);
if (Trace.isEnabled()) {
Trace.write("Non-merged Property Animations: " + this._propertyAnimations.length, Trace.categories.Animation);
}
this._mergedPropertyAnimations = Animation._mergeAffineTransformAnimations(this._propertyAnimations);
if (traceEnabled()) {
traceWrite("Merged Property Animations: " + this._mergedPropertyAnimations.length, traceCategories.Animation);
if (Trace.isEnabled()) {
Trace.write("Merged Property Animations: " + this._mergedPropertyAnimations.length, Trace.categories.Animation);
}
}
else {
@@ -200,14 +200,14 @@ export class Animation extends AnimationBase {
}
if (that._cancelledAnimations > 0 && (that._cancelledAnimations + that._finishedAnimations) === that._mergedPropertyAnimations.length) {
if (traceEnabled()) {
traceWrite(that._cancelledAnimations + " animations cancelled.", traceCategories.Animation);
if (Trace.isEnabled()) {
Trace.write(that._cancelledAnimations + " animations cancelled.", Trace.categories.Animation);
}
that._rejectAnimationFinishedPromise();
}
else if (that._finishedAnimations === that._mergedPropertyAnimations.length) {
if (traceEnabled()) {
traceWrite(that._finishedAnimations + " animations finished.", traceCategories.Animation);
if (Trace.isEnabled()) {
Trace.write(that._finishedAnimations + " animations finished.", Trace.categories.Animation);
}
that._resolveAnimationFinishedPromise();
}
@@ -232,7 +232,7 @@ export class Animation extends AnimationBase {
public cancel(): void {
if (!this.isPlaying) {
traceWrite("Animation is not currently playing.", traceCategories.Animation, traceType.warn);
Trace.write("Animation is not currently playing.", Trace.categories.Animation, Trace.messageType.warn);
return;
}
@@ -256,8 +256,8 @@ export class Animation extends AnimationBase {
return (cancelled?: boolean) => {
if (cancelled && finishedCallback) {
if (traceEnabled()) {
traceWrite("Animation " + (index - 1).toString() + " was cancelled. Will skip the rest of animations and call finishedCallback(true).", traceCategories.Animation);
if (Trace.isEnabled()) {
Trace.write("Animation " + (index - 1).toString() + " was cancelled. Will skip the rest of animations and call finishedCallback(true).", Trace.categories.Animation);
}
finishedCallback(cancelled);
@@ -664,12 +664,12 @@ export class Animation extends AnimationBase {
iterations: propertyAnimations[i].iterations,
curve: propertyAnimations[i].curve
};
if (traceEnabled()) {
traceWrite("Curve: " + propertyAnimations[i].curve, traceCategories.Animation);
if (Trace.isEnabled()) {
Trace.write("Curve: " + propertyAnimations[i].curve, Trace.categories.Animation);
}
newTransformAnimation.value[propertyAnimations[i].property] = propertyAnimations[i].value;
if (traceEnabled()) {
traceWrite("Created new transform animation: " + Animation._getAnimationInfo(newTransformAnimation), traceCategories.Animation);
if (Trace.isEnabled()) {
Trace.write("Created new transform animation: " + Animation._getAnimationInfo(newTransformAnimation), Trace.categories.Animation);
}
// Merge all compatible affine transform animations to the right into this new animation.
@@ -677,8 +677,8 @@ export class Animation extends AnimationBase {
if (j < length) {
for (; j < length; j++) {
if (Animation._canBeMerged(propertyAnimations[i], propertyAnimations[j])) {
if (traceEnabled()) {
traceWrite("Merging animations: " + Animation._getAnimationInfo(newTransformAnimation) + " + " + Animation._getAnimationInfo(propertyAnimations[j]) + ";", traceCategories.Animation);
if (Trace.isEnabled()) {
Trace.write("Merging animations: " + Animation._getAnimationInfo(newTransformAnimation) + " + " + Animation._getAnimationInfo(propertyAnimations[j]) + ";", Trace.categories.Animation);
}
newTransformAnimation.value[propertyAnimations[j].property] = propertyAnimations[j].value;
// Mark that it has been merged so we can skip it on our outer loop.

View File

@@ -1,7 +1,3 @@
/**
* @module "ui/animation/keyframe-animation"
*/ /** */
import { View } from "../core/view";
export declare const ANIMATION_PROPERTIES;

View File

@@ -8,11 +8,12 @@ import {
KeyframeAnimation as KeyframeAnimationDefinition,
} from "./keyframe-animation";
import { View, Color } from "../core/view";
import { View } from "../core/view";
import { Color } from "../../color";
import { AnimationCurve } from "../enums";
import { write as traceWrite, categories as traceCategories, messageType as traceType } from "../../trace";
import { Trace } from "../../trace";
// Types.
import { unsetValue } from "../core/properties";
@@ -148,7 +149,7 @@ export class KeyframeAnimation implements KeyframeAnimationDefinition {
public cancel() {
if (!this.isPlaying) {
traceWrite("Keyframe animation is already playing.", traceCategories.Animation, traceType.warn);
Trace.write("Keyframe animation is already playing.", Trace.categories.Animation, Trace.messageType.warn);
return;
}
@@ -169,7 +170,7 @@ export class KeyframeAnimation implements KeyframeAnimationDefinition {
public play(view: View): Promise<void> {
if (this._isPlaying) {
traceWrite("Keyframe animation is already playing.", traceCategories.Animation, traceType.warn);
Trace.write("Keyframe animation is already playing.", Trace.categories.Animation, Trace.messageType.warn);
return new Promise<void>(resolve => {
resolve();
@@ -262,9 +263,9 @@ export class KeyframeAnimation implements KeyframeAnimationDefinition {
animation.play(isLastIteration).then(() => {
this.animate(view, index + 1, iterations);
}, (error: any) => {
traceWrite(typeof error === "string" ? error : error.message, traceCategories.Animation, traceType.warn);
Trace.write(typeof error === "string" ? error : error.message, Trace.categories.Animation, Trace.messageType.warn);
}).catch((error: any) => {
traceWrite(typeof error === "string" ? error : error.message, traceCategories.Animation, traceType.warn);
Trace.write(typeof error === "string" ? error : error.message, Trace.categories.Animation, Trace.messageType.warn);
}); // tslint:disable-line
}
}

View File

@@ -1,9 +1,4 @@
/**
* Contains the Border class, which represents a UI border component.
* @module "ui/animation/keyframe-animation"
*/ /** */
import { ContentView } from "../content-view";
import { ContentView } from "../content-view";
/**
* Represents a UI border component.

View File

@@ -8,8 +8,9 @@ import { TextTransform } from "../text-base";
import * as application from "../../application";
import { ImageSource } from "../../image-source";
import { ad, isFontIconURI, layout, RESOURCE_PREFIX } from "../../utils/utils";
import { Color, CSSType } from "../core/view";
import { Frame, View } from "../frame";
import { CSSType, View } from "../core/view";
import { Color } from "../../color";
import { Frame } from "../frame";
import { Font } from "../styling/font";
import {
getIconSpecSize, itemsProperty, selectedIndexProperty, TabNavigationBase, tabStripProperty
@@ -17,7 +18,7 @@ import {
import { getTransformedText } from "../text-base";
// TODO: Impl trace
// import { isEnabled as traceEnabled, write as traceWrite } from "../../../trace";
// import { Trace } from "../../../trace";
const PRIMARY_COLOR = "colorPrimary";
const DEFAULT_ELEVATION = 8;
@@ -278,8 +279,8 @@ export class BottomNavigation extends TabNavigationBase {
public createNativeView() {
initializeNativeClasses();
// if (traceEnabled()) {
// traceWrite("BottomNavigation._createUI(" + this + ");", traceCategory);
// if (Trace.isEnabled()) {
// Trace.write("BottomNavigation._createUI(" + this + ");", traceCategory);
// }
const context: android.content.Context = this._context;
@@ -848,8 +849,8 @@ export class BottomNavigation extends TabNavigationBase {
[selectedIndexProperty.setNative](value: number) {
// const smoothScroll = false;
// if (traceEnabled()) {
// traceWrite("TabView this._viewPager.setCurrentItem(" + value + ", " + smoothScroll + ");", traceCategory);
// if (Trace.isEnabled()) {
// Trace.write("TabView this._viewPager.setCurrentItem(" + value + ", " + smoothScroll + ");", traceCategory);
// }
if (this.tabStrip) {

View File

@@ -1,12 +1,8 @@
/**
* Contains the BottomNavigation class, which represents a tab navigation widget with static tabs at the bottom.
* @module "ui/tab-navigation/bottom-navigation"
*/ /** */
import { TabNavigationBase } from "../tab-navigation-base/tab-navigation-base";
import { TabNavigationBase } from "../tab-navigation-base/tab-navigation-base";
import { TabContentItem } from "../tab-navigation-base/tab-content-item";
import { TabStrip } from "../tab-navigation-base/tab-strip";
import { Property, CoercibleProperty, EventData } from "../core/view";
import { Property, CoercibleProperty } from "../core/properties";
import { EventData } from "../../data/observable";
/**
* Defines the data for the TabView.selectedIndexChanged event.

View File

@@ -110,8 +110,8 @@ class UITabBarControllerDelegateImpl extends NSObject implements UITabBarControl
public tabBarControllerShouldSelectViewController(tabBarController: UITabBarController, viewController: UIViewController): boolean {
// TODO
// if (traceEnabled()) {
// traceWrite("TabView.delegate.SHOULD_select(" + tabBarController + ", " + viewController + ");", traceCategories.Debug);
// if (Trace.isEnabled()) {
// Trace.write("TabView.delegate.SHOULD_select(" + tabBarController + ", " + viewController + ");", Trace.categories.Debug);
// }
let owner = this._owner.get();
@@ -145,8 +145,8 @@ class UITabBarControllerDelegateImpl extends NSObject implements UITabBarControl
public tabBarControllerDidSelectViewController(tabBarController: UITabBarController, viewController: UIViewController): void {
// TODO
// if (traceEnabled()) {
// traceWrite("TabView.delegate.DID_select(" + tabBarController + ", " + viewController + ");", traceCategories.Debug);
// if (Trace.isEnabled()) {
// Trace.write("TabView.delegate.DID_select(" + tabBarController + ", " + viewController + ");", Trace.categories.Debug);
// }
const owner = this._owner.get();
@@ -172,8 +172,8 @@ class UINavigationControllerDelegateImpl extends NSObject implements UINavigatio
navigationControllerWillShowViewControllerAnimated(navigationController: UINavigationController, viewController: UIViewController, animated: boolean): void {
// TODO
// if (traceEnabled()) {
// traceWrite("TabView.moreNavigationController.WILL_show(" + navigationController + ", " + viewController + ", " + animated + ");", traceCategories.Debug);
// if (Trace.isEnabled()) {
// Trace.write("TabView.moreNavigationController.WILL_show(" + navigationController + ", " + viewController + ", " + animated + ");", Trace.categories.Debug);
// }
let owner = this._owner.get();
@@ -187,8 +187,8 @@ class UINavigationControllerDelegateImpl extends NSObject implements UINavigatio
navigationControllerDidShowViewControllerAnimated(navigationController: UINavigationController, viewController: UIViewController, animated: boolean): void {
// TODO
// if (traceEnabled()) {
// traceWrite("TabView.moreNavigationController.DID_show(" + navigationController + ", " + viewController + ", " + animated + ");", traceCategories.Debug);
// if (Trace.isEnabled()) {
// Trace.write("TabView.moreNavigationController.DID_show(" + navigationController + ", " + viewController + ", " + animated + ");", Trace.categories.Debug);
// }
// We don't need Edit button in More screen.
navigationController.navigationBar.topItem.rightBarButtonItem = null;
@@ -454,15 +454,15 @@ export class BottomNavigation extends TabNavigationBase {
public _onViewControllerShown(viewController: UIViewController) {
// This method could be called with the moreNavigationController or its list controller, so we have to check.
// TODO
// if (traceEnabled()) {
// traceWrite("TabView._onViewControllerShown(" + viewController + ");", traceCategories.Debug);
// if (Trace.isEnabled()) {
// Trace.write("TabView._onViewControllerShown(" + viewController + ");", Trace.categories.Debug);
// }
if (this._ios.viewControllers && this._ios.viewControllers.containsObject(viewController)) {
this.selectedIndex = this._ios.viewControllers.indexOfObject(viewController);
} else {
// TODO
// if (traceEnabled()) {
// traceWrite("TabView._onViewControllerShown: viewController is not one of our viewControllers", traceCategories.Debug);
// if (Trace.isEnabled()) {
// Trace.write("TabView._onViewControllerShown: viewController is not one of our viewControllers", Trace.categories.Debug);
// }
}
}
@@ -470,8 +470,8 @@ export class BottomNavigation extends TabNavigationBase {
private _actionBarHiddenByTabView: boolean;
public _handleTwoNavigationBars(backToMoreWillBeVisible: boolean) {
// TODO
// if (traceEnabled()) {
// traceWrite(`TabView._handleTwoNavigationBars(backToMoreWillBeVisible: ${backToMoreWillBeVisible})`, traceCategories.Debug);
// if (Trace.isEnabled()) {
// Trace.write(`TabView._handleTwoNavigationBars(backToMoreWillBeVisible: ${backToMoreWillBeVisible})`, Trace.categories.Debug);
// }
// The "< Back" and "< More" navigation bars should not be visible simultaneously.
@@ -489,8 +489,8 @@ export class BottomNavigation extends TabNavigationBase {
this._actionBarHiddenByTabView = true;
// TODO
// if (traceEnabled()) {
// traceWrite(`TabView hid action bar`, traceCategories.Debug);
// if (Trace.isEnabled()) {
// Trace.write(`TabView hid action bar`, Trace.categories.Debug);
// }
return;
}
@@ -502,8 +502,8 @@ export class BottomNavigation extends TabNavigationBase {
this._actionBarHiddenByTabView = undefined;
// TODO
// if (traceEnabled()) {
// traceWrite(`TabView restored action bar`, traceCategories.Debug);
// if (Trace.isEnabled()) {
// Trace.write(`TabView restored action bar`, Trace.categories.Debug);
// }
return;
}
@@ -729,8 +729,8 @@ export class BottomNavigation extends TabNavigationBase {
[selectedIndexProperty.setNative](value: number) {
// TODO
// if (traceEnabled()) {
// traceWrite("TabView._onSelectedIndexPropertyChangedSetNativeValue(" + value + ")", traceCategories.Debug);
// if (Trace.isEnabled()) {
// Trace.write("TabView._onSelectedIndexPropertyChangedSetNativeValue(" + value + ")", Trace.categories.Debug);
// }
if (value > -1) {

View File

@@ -1,9 +1,4 @@
/**
* @module "ui/builder/binding-builder"
* @private
*/ /** */
//@private
//@private
export module bindingConstants {
export const sourceProperty: string;
export const targetProperty: string;

View File

@@ -1,8 +1,4 @@
/**
* @module "ui/builder"
*/ /** */
import { View, Template, KeyedTemplate } from "../core/view";
import { View, Template, KeyedTemplate } from "../core/view";
import { Page } from "../page";
import { NavigationEntry } from "../frame";

View File

@@ -1,7 +1,3 @@
/**
* @module "ui/builder/component-builder"
*/ /** */
import { View } from "../../core/view";
export interface ComponentModule {

View File

@@ -1,5 +1 @@
/**
* @module "ui/builder/module-name-sanitizer"
*/ /** */
export function sanitizeModuleName(moduleName: string, removeExtension?: boolean): string;

View File

@@ -1,5 +1,7 @@
import { Button as ButtonDefinition } from ".";
import { TextBase, booleanConverter, CSSType } from "../text-base";
import { TextBase } from "../text-base";
import { CSSType } from "../core/view";
import { booleanConverter } from "../core/view-base";
@CSSType("Button")
export abstract class ButtonBase extends TextBase implements ButtonDefinition {

View File

@@ -1,9 +1,5 @@
/**
* Contains the Button class, which represents a standard button widget.
* @module "ui/button"
*/ /** */
import { TextBase, EventData } from "../text-base";
import { TextBase } from "../text-base";
import { EventData } from "../../data/observable";
/**
* Represents a standard Button widget.

View File

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

Some files were not shown because too many files have changed in this diff Show More