chore: cleanup reexports

This commit is contained in:
Nathan Walker
2020-07-05 14:53:34 -07:00
parent 1525c89733
commit 8f2900ad0b
306 changed files with 1197 additions and 1534 deletions

13
.prettierignore Normal file
View File

@@ -0,0 +1,13 @@
# Ignore artifacts:
build
coverage
dist
e2e
js-libs
platforms
tests
tns-core-modules-package
tns-core-modules-widgets
tns-platform-declarations
temp
unit-tests

6
.prettierrc.json Normal file
View File

@@ -0,0 +1,6 @@
{
"extends": [
"tslint:latest",
"tslint-config-prettier"
]
}

View File

@@ -15,7 +15,7 @@
"tns-core-modules": "file:../tns-core-modules"
},
"devDependencies": {
"nativescript-dev-webpack": "next",
"@nativescript/webpack": "^2.0.0-alpha.3",
"node-sass": "^4.12.0",
"typescript": "~3.4.1"
},

View File

@@ -41,7 +41,7 @@ readdirp(inputFolder, {
} else if (shouldReplace) {
console.log("[Cleared]", fullPath);
try {
fs.writeFileSync(fullPath, newContent, "utf8");
fs.writeFileSync(fullPath, newContent || '', "utf8");
} catch (error) {
console.log("ERROR writing file: " + fullPath, error);
process.exit(1);

View File

@@ -28,7 +28,7 @@
"mocha": "~5.2.0",
"mochawesome": "~3.1.2",
"nativescript-dev-appium": "next",
"nativescript-dev-webpack": "next",
"@nativescript/webpack": "^2.0.0-alpha.3",
"typescript": "~3.4.1"
},
"scripts": {

View File

@@ -17,7 +17,7 @@
"tns-core-modules": "file:../../dist/tns-core-modules"
},
"devDependencies": {
"nativescript-dev-webpack": "next",
"@nativescript/webpack": "^2.0.0-alpha.3",
"typescript": "3.4.5"
},
"gitHead": "8c1a4866a66daab09bf5ef8e5a96472687192373",

View File

@@ -18,7 +18,7 @@
"tns-core-modules": "file:../../dist/tns-core-modules"
},
"devDependencies": {
"nativescript-dev-webpack": "next",
"@nativescript/webpack": "^2.0.0-alpha.3",
"typescript": "3.4.5"
}
}

View File

@@ -24,7 +24,7 @@
"mocha": "~5.2.0",
"mochawesome": "~3.1.2",
"nativescript-dev-appium": "next",
"nativescript-dev-webpack": "next",
"@nativescript/webpack": "^2.0.0-alpha.3",
"rimraf": "^2.6.2",
"tns-platform-declarations": "file:../../tns-platform-declarations",
"typescript": "~3.4.1"

View File

@@ -24,7 +24,7 @@
"mocha": "~5.2.0",
"mochawesome": "~3.1.2",
"nativescript-dev-appium": "next",
"nativescript-dev-webpack": "next",
"@nativescript/webpack": "^2.0.0-alpha.3",
"rimraf": "^2.6.2",
"typescript": "~3.4.1"
},

View File

@@ -18,7 +18,7 @@
"tns-core-modules": "file:../../dist/tns-core-modules-6.6.0.tgz"
},
"devDependencies": {
"nativescript-dev-webpack": "~1.2.0",
"@nativescript/webpack": "^2.0.0-alpha.3",
"typescript": "~3.5.3"
},
"gitHead": "5fa096231ded5351b53700f0d111d60160e52ebc",

View File

@@ -28,7 +28,7 @@
"mocha-typescript": "^1.1.17",
"mochawesome": "~3.1.2",
"nativescript-dev-appium": "next",
"nativescript-dev-webpack": "next",
"@nativescript/webpack": "^2.0.0-alpha.3",
"tns-platform-declarations": "file:../../tns-platform-declarations",
"typescript": "~3.4.1"
},

View File

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

View File

@@ -333,21 +333,21 @@ function initLifecycleCallbacks() {
});
const lifecycleCallbacks = new android.app.Application.ActivityLifecycleCallbacks({
onActivityCreated: profile("onActivityCreated", function (activity: androidx.appcompat.app.AppCompatActivity, savedInstanceState: android.os.Bundle) {
setThemeOnLaunch(activity);
onActivityCreated: <any>profile("onActivityCreated", function (activity: androidx.appcompat.app.AppCompatActivity, savedInstanceState: android.os.Bundle) {
setThemeOnLaunch(activity, undefined, undefined);
if (!androidApp.startActivity) {
androidApp.startActivity = activity;
}
notifyActivityCreated(activity, savedInstanceState);
notifyActivityCreated(activity, <any>savedInstanceState, undefined);
if (hasListeners(displayedEvent)) {
subscribeForGlobalLayout(activity);
subscribeForGlobalLayout(activity, undefined, undefined);
}
}),
onActivityDestroyed: profile("onActivityDestroyed", function (activity: androidx.appcompat.app.AppCompatActivity) {
onActivityDestroyed: <any>profile("onActivityDestroyed", function (activity: androidx.appcompat.app.AppCompatActivity) {
if (activity === androidApp.foregroundActivity) {
androidApp.foregroundActivity = undefined;
}
@@ -361,7 +361,7 @@ function initLifecycleCallbacks() {
gc();
}),
onActivityPaused: profile("onActivityPaused", function (activity: androidx.appcompat.app.AppCompatActivity) {
onActivityPaused: <any>profile("onActivityPaused", function (activity: androidx.appcompat.app.AppCompatActivity) {
if ((<any>activity).isNativeScriptActivity) {
androidApp.paused = true;
notify(<ApplicationEventData>{ eventName: suspendEvent, object: androidApp, android: activity });
@@ -370,21 +370,21 @@ function initLifecycleCallbacks() {
androidApp.notify(<AndroidActivityEventData>{ eventName: ActivityPaused, object: androidApp, activity: activity });
}),
onActivityResumed: profile("onActivityResumed", function (activity: androidx.appcompat.app.AppCompatActivity) {
onActivityResumed: <any>profile("onActivityResumed", function (activity: androidx.appcompat.app.AppCompatActivity) {
androidApp.foregroundActivity = activity;
androidApp.notify(<AndroidActivityEventData>{ eventName: ActivityResumed, object: androidApp, activity: activity });
}),
onActivitySaveInstanceState: profile("onActivitySaveInstanceState", function (activity: androidx.appcompat.app.AppCompatActivity, outState: android.os.Bundle) {
onActivitySaveInstanceState: <any>profile("onActivitySaveInstanceState", function (activity: androidx.appcompat.app.AppCompatActivity, outState: android.os.Bundle) {
androidApp.notify(<AndroidActivityBundleEventData>{ eventName: SaveActivityState, object: androidApp, activity: activity, bundle: outState });
}),
onActivityStarted: profile("onActivityStarted", function (activity: androidx.appcompat.app.AppCompatActivity) {
onActivityStarted: <any>profile("onActivityStarted", function (activity: androidx.appcompat.app.AppCompatActivity) {
androidApp.notify(<AndroidActivityEventData>{ eventName: ActivityStarted, object: androidApp, activity: activity });
}),
onActivityStopped: profile("onActivityStopped", function (activity: androidx.appcompat.app.AppCompatActivity) {
onActivityStopped: <any>profile("onActivityStopped", function (activity: androidx.appcompat.app.AppCompatActivity) {
androidApp.notify(<AndroidActivityEventData>{ eventName: ActivityStopped, object: androidApp, activity: activity });
})
});
@@ -394,17 +394,17 @@ function initLifecycleCallbacks() {
function initComponentCallbacks() {
let componentCallbacks = new android.content.ComponentCallbacks2({
onLowMemory: profile("onLowMemory", function () {
onLowMemory: <any>profile("onLowMemory", function () {
gc();
java.lang.System.gc();
notify(<ApplicationEventData>{ eventName: lowMemoryEvent, object: this, android: this });
}),
onTrimMemory: profile("onTrimMemory", function (level: number) {
onTrimMemory: <any>profile("onTrimMemory", function (level: number) {
// TODO: This is skipped for now, test carefully for OutOfMemory exceptions
}),
onConfigurationChanged: profile("onConfigurationChanged", function (newConfiguration: android.content.res.Configuration) {
onConfigurationChanged: <any>profile("onConfigurationChanged", function (newConfiguration: android.content.res.Configuration) {
const rootView = getRootView();
const newOrientation = getOrientationValue(newConfiguration);

View File

@@ -28,8 +28,8 @@ import {
pushToSystemCssClasses,
ROOT_VIEW_CSS_CLASS
} from "../css/system-classes";
import { ios as iosViewHelper } from "../ui/core/view/view-helper";
import { device } from "../platform/platform";
import { IOSHelper } from "../ui/core/view/view-helper";
import { device } from "../platform";
import { profile } from "../profiling";
import { ios } from "../utils/utils";
@@ -176,7 +176,7 @@ export class iOSApplication implements iOSApplicationDefinition {
}
}
@profile
@profile()
private didFinishLaunchingWithOptions(notification: NSNotification) {
if (!displayedOnce) {
displayedLinkTarget = CADisplayLinkTarget.new();
@@ -210,7 +210,7 @@ export class iOSApplication implements iOSApplicationDefinition {
}
}
@profile
@profile()
private didBecomeActive(notification: NSNotification) {
const ios = UIApplication.sharedApplication;
const object = this;
@@ -310,7 +310,7 @@ export class iOSApplication implements iOSApplicationDefinition {
this._window.makeKeyAndVisible();
}
rootView.on(iosViewHelper.traitCollectionColorAppearanceChangedEvent, () => {
rootView.on(IOSHelper.traitCollectionColorAppearanceChangedEvent, () => {
const userInterfaceStyle = controller.traitCollection.userInterfaceStyle;
const newSystemAppearance = getSystemAppearanceValue(userInterfaceStyle);
@@ -396,7 +396,7 @@ export function run(entry?: string | NavigationEntry) {
// Mind root view CSS classes in future work
// on embedding NativeScript applications
setRootViewsSystemAppearanceCssClass(rootView);
rootView.on(iosViewHelper.traitCollectionColorAppearanceChangedEvent, () => {
rootView.on(IOSHelper.traitCollectionColorAppearanceChangedEvent, () => {
const userInterfaceStyle = controller.traitCollection.userInterfaceStyle;
const newSystemAppearance = getSystemAppearanceValue(userInterfaceStyle);
@@ -453,7 +453,7 @@ function getViewController(rootView: View): UIViewController {
if (!(viewController instanceof UIViewController)) {
// We set UILayoutViewController dynamically to the root view if it doesn't have a view controller
// At the moment the root view doesn't have its native view created. We set it in the setViewControllerView func
viewController = iosViewHelper.UILayoutViewController.initWithOwner(new WeakRef(rootView)) as UIViewController;
viewController = IOSHelper.UILayoutViewController.initWithOwner(new WeakRef(rootView)) as UIViewController;
rootView.viewController = viewController;
}
@@ -468,7 +468,7 @@ function setViewControllerView(view: View): void {
throw new Error("Root should be either UIViewController or UIView");
}
if (viewController instanceof iosViewHelper.UILayoutViewController) {
if (viewController instanceof IOSHelper.UILayoutViewController) {
viewController.view.addSubview(nativeView);
}
}

View File

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

View File

@@ -1,5 +1,6 @@
if (global.TNS_WEBPACK) {
require("./globals");
const g = require("./globals");
g.initGlobal();
// Register "dynamically" loaded module that need to be resolved by the
// XML/component builders.

View File

@@ -1,6 +1,6 @@
const semver = require("semver");
const webpackPackageName = "nativescript-dev-webpack";
const webpackPackageName = "@nativescript/webpack";
module.exports = function ($staticConfig, hookArgs) {
const cliVersion = semver.parse($staticConfig.version);

View File

@@ -1,2 +1,2 @@
const path = require('path');
require('nativescript-hook')(path.join(__dirname, "..")).postinstall();
require('@nativescript/hook')(path.join(__dirname, "..")).postinstall();

View File

@@ -1,2 +1,2 @@
const path = require('path');
require('nativescript-hook')(path.join(__dirname, "..")).preuninstall();
require('@nativescript/hook')(path.join(__dirname, "..")).preuninstall();

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,131 @@
Object.defineProperty(exports, "__esModule", { value: true });
exports.cssTreeParse = void 0;
var css_tree_1 = require("css-tree");
function mapSelectors(selector) {
if (!selector) {
return [];
}
return selector.split(/\s*(?![^(]*\)),\s*/).map(function (s) { return s.replace(/\u200C/g, ","); });
}
function mapPosition(node, css) {
var res = {
start: {
line: node.loc.start.line,
column: node.loc.start.column
},
end: {
line: node.loc.end.line,
column: node.loc.end.column
},
content: css
};
if (node.loc.source && node.loc.source !== "<unknown>") {
res.source = node.loc.source;
}
return res;
}
function transformAst(node, css, type) {
if (type === void 0) { type = null; }
if (!node) {
return;
}
if (node.type === "StyleSheet") {
return {
type: "stylesheet",
stylesheet: {
rules: node.children.map(function (child) { return transformAst(child, css); }).filter(function (child) { return child !== null; }).toArray(),
parsingErrors: []
}
};
}
if (node.type === "Atrule") {
var atrule = {
type: node.name,
};
if (node.name === "supports" || node.name === "media") {
atrule[node.name] = node.prelude.value;
atrule.rules = transformAst(node.block, css);
}
else if (node.name === "page") {
atrule.selectors = node.prelude ? mapSelectors(node.prelude.value) : [];
atrule.declarations = transformAst(node.block, css);
}
else if (node.name === "document") {
atrule.document = node.prelude ? node.prelude.value : "";
atrule.vendor = "";
atrule.rules = transformAst(node.block, css);
}
else if (node.name === "font-face") {
atrule.declarations = transformAst(node.block, css);
}
else if (node.name === "import" || node.name === "charset" || node.name === "namespace") {
atrule[node.name] = node.prelude ? node.prelude.value : "";
}
else if (node.name === "keyframes") {
atrule.name = node.prelude ? node.prelude.value : "";
atrule.keyframes = transformAst(node.block, css, "keyframe");
atrule.vendor = undefined;
}
else {
atrule.rules = transformAst(node.block, css);
}
atrule.position = mapPosition(node, css);
return atrule;
}
if (node.type === "Block") {
return node.children.map(function (child) { return transformAst(child, css, type); }).filter(function (child) { return child !== null; }).toArray();
}
if (node.type === "Rule") {
var value = node.prelude.value;
var res = {
type: type != null ? type : "rule",
declarations: transformAst(node.block, css),
position: mapPosition(node, css)
};
if (type === "keyframe") {
res.values = mapSelectors(value);
}
else {
res.selectors = mapSelectors(value);
}
return res;
}
if (node.type === "Comment") {
return {
type: "comment",
comment: node.value,
position: mapPosition(node, css)
};
}
if (node.type === "Declaration") {
return {
type: "declaration",
property: node.property,
value: node.value.value ? node.value.value.trim() : "",
position: mapPosition(node, css)
};
}
if (node.type === "Raw") {
return null;
}
throw Error("Unknown node type " + node.type);
}
function cssTreeParse(css, source) {
var errors = [];
var ast = css_tree_1.parse(css, {
parseValue: false,
parseAtrulePrelude: false,
parseRulePrelude: false,
positions: true,
filename: source,
onParseError: function (error) {
errors.push(source + ":" + error.line + ":" + error.column + ": " + error.formattedMessage);
}
});
if (errors.length > 0) {
throw new Error(errors[0]);
}
return transformAst(ast, css);
}
exports.cssTreeParse = cssTreeParse;
//# sourceMappingURL=css-tree-parser.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"css-tree-parser.js","sourceRoot":"","sources":["css-tree-parser.ts"],"names":[],"mappings":";;AAAA,qCAEkB;AAElB,SAAS,YAAY,CAAC,QAAgB;IAClC,IAAI,CAAC,QAAQ,EAAE;QACX,OAAO,EAAE,CAAC;KACb;IAED,OAAO,QAAQ,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC,GAAG,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC,EAAzB,CAAyB,CAAC,CAAC;AACpF,CAAC;AAED,SAAS,WAAW,CAAC,IAAI,EAAE,GAAG;IAC1B,IAAI,GAAG,GAAQ;QACX,KAAK,EAAE;YACH,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI;YACzB,MAAM,EAAE,IAA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C,GAAG,EAAE,GAAG,CAAC,CAAC;AAClC,CAAC;AAlBD,oCAkBC"}

View File

@@ -1,25 +1,59 @@
import * as observable from "../observable";
import * as observableArrayDef from ".";
import { Observable, EventData } from "../observable";
import * as types from "../../utils/types";
export class ChangeType implements observableArrayDef.ChangeType {
export class ChangeType {
static Add = "add";
static Delete = "delete";
static Update = "update";
static Splice = "splice";
static Change = "change";
}
/**
* Event args for "changed" event.
*/
export interface ChangedData<T> extends EventData {
/**
* Change type.
*/
action: string;
/**
* Start index.
*/
index: number;
/**
* Removed items.
*/
removed: Array<T>;
/**
* Number of added items.
*/
addedCount: number;
}
const CHANGE = "change";
export class ObservableArray<T> extends observable.Observable implements observableArrayDef.ObservableArray<T> { // implements Array<T> {
/**
* Advanced array like class used when you want to be notified when a change occurs.
*/
export class ObservableArray<T> extends Observable {
/**
* String value used when hooking to change event.
*/
public static changeEvent = CHANGE;
private _array: Array<any>;
private _addArgs: observableArrayDef.ChangedData<T>;
private _deleteArgs: observableArrayDef.ChangedData<T>;
private _addArgs: ChangedData<T>;
private _deleteArgs: ChangedData<T>;
constructor(_args?: any) {
/**
* Create ObservableArray<T> with specified length or from source Array<T>.
*/
constructor(_args?: number | T[]) {
super();
if (arguments.length === 1 && Array.isArray(arguments[0])) {
@@ -46,15 +80,21 @@ export class ObservableArray<T> extends observable.Observable implements observa
};
}
/**
* Returns item at specified index.
*/
getItem(index: number): T {
return this._array[index];
}
/**
* Sets item at specified index.
*/
setItem(index: number, value: T) {
let oldValue = this._array[index];
this._array[index] = value;
this.notify(<observableArrayDef.ChangedData<T>>{
this.notify(<ChangedData<T>>{
eventName: CHANGE, object: this,
action: ChangeType.Update,
index: index,
@@ -202,7 +242,7 @@ export class ObservableArray<T> extends observable.Observable implements observa
const length = this._array.length;
const result = this._array.splice.apply(this._array, arguments);
this.notify(<observableArrayDef.ChangedData<T>>{
this.notify(<ChangedData<T>>{
eventName: CHANGE, object: this,
action: ChangeType.Splice,
index: start,
@@ -331,7 +371,13 @@ export class ObservableArray<T> extends observable.Observable implements observa
}
export interface ObservableArray<T> {
on(eventNames: string, callback: (data: observable.EventData) => void, thisArg?: any);
/**
* A basic method signature to hook an event listener (shortcut alias to the addEventListener method).
* @param eventNames - String corresponding to events (e.g. "propertyChange"). Optionally could be used more events separated by `,` (e.g. "propertyChange", "change").
* @param callback - Callback function which will be executed when event is raised.
* @param thisArg - An optional parameter which will be used as `this` context for callback execution.
*/
on(eventNames: string, callback: (data: EventData) => void, thisArg?: any): void;
on(event: "change", callback: (args: observableArrayDef.ChangedData<T>) => void, thisArg?: any);
on(event: "change", callback: (args: ChangedData<T>) => void, thisArg?: any): void;
}

View File

@@ -1,239 +0,0 @@
// Test: http://jsperf.com/array-vs-observable-array-vs-array-observe
import { Observable, EventData } from "../observable";
/**
* Event args for "changed" event.
*/
export interface ChangedData<T> extends EventData {
/**
* Change type.
*/
action: string;
/**
* Start index.
*/
index: number;
/**
* Removed items.
*/
removed: Array<T>;
/**
* Number of added items.
*/
addedCount: number;
}
/**
* Change types.
*/
export class ChangeType {
static Add: string;
static Delete: string;
static Update: string;
static Splice: string;
}
/**
* Advanced array like class used when you want to be notified when a change occurs.
*/
export class ObservableArray<T> extends Observable {
/**
* String value used when hooking to change event.
*/
public static changeEvent: string;
/**
* A basic method signature to hook an event listener (shortcut alias to the addEventListener method).
* @param eventNames - String corresponding to events (e.g. "propertyChange"). Optionally could be used more events separated by `,` (e.g. "propertyChange", "change").
* @param callback - Callback function which will be executed when event is raised.
* @param thisArg - An optional parameter which will be used as `this` context for callback execution.
*/
on(eventNames: string, callback: (data: EventData) => void, thisArg?: any);
/**
* Raised when a change occurs.
*/
on(event: "change", callback: (args: ChangedData<T>) => void, thisArg?: any);
/**
* Create ObservableArray<T> with specified length.
*/
constructor(arrayLength?: number);
/**
* Create ObservableArray<T> from source Array<T>.
*/
constructor(items: T[]);
/**
* Create ObservableArray<T> from T items.
*/
constructor(...items: T[]);
/**
* Returns item at specified index.
*/
getItem(index: number): T;
/**
* Sets item at specified index.
*/
setItem(index: number, value: T): void;
/**
* Returns a string representation of an array.
*/
toString(): string;
toLocaleString(): string;
/**
* Combines two or more arrays.
* @param items Additional items to add to the end of array1.
*/
concat<U extends T[]>(...items: U[]): T[];
/**
* Combines two or more arrays.
* @param items Additional items to add to the end of array1.
*/
concat(...items: T[]): T[];
/**
* Adds all the elements of an array separated by the specified separator string.
* @param separator A string used to separate one element of an array from the next in the resulting String. If omitted, the array elements are separated with a comma.
*/
join(separator?: string): string;
/**
* Removes the last element from an array and returns it.
*/
pop(): T;
/**
* Appends new elements to an array, and returns the new length of the array.
* @param items New elements of the Array.
*/
push(items: T[]): number;
/**
* Appends new elements to an array, and returns the new length of the array.
* @param items New elements of the Array.
*/
push(...items: T[]): number;
/**
* Reverses the elements in an Array.
*/
reverse(): T[];
/**
* Removes the first element from an array and returns it.
*/
shift(): T;
/**
* Returns a section of an array.
* @param start The beginning of the specified portion of the array.
* @param end The end of the specified portion of the array.
*/
slice(start?: number, end?: number): T[];
/**
* Sorts an array.
* @param compareFn The name of the function used to determine the order of the elements. If omitted, the elements are sorted in ascending, ASCII character order.
*/
sort(compareFn?: (a: T, b: T) => number): T[];
/**
* Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements.
* @param start The zero-based location in the array from which to start removing elements.
*/
splice(start: number): T[];
/**
* Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements.
* @param start The zero-based location in the array from which to start removing elements.
* @param deleteCount The number of elements to remove.
* @param items Elements to insert into the array in place of the deleted elements.
*/
splice(start: number, deleteCount: number, ...items: T[]): T[];
/**
* Inserts new elements at the start of an array.
* @param items Elements to insert at the start of the Array.
*/
unshift(...items: T[]): number;
/**
* Returns the index of the first occurrence of a value in an array.
* @param searchElement The value to locate in the array.
* @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0.
*/
indexOf(searchElement: T, fromIndex?: number): number;
/**
* Returns the index of the last occurrence of a specified value in an array.
* @param searchElement The value to locate in the array.
* @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at the last index in the array.
*/
lastIndexOf(searchElement: T, fromIndex?: number): number;
/**
* Determines whether all the members of an array satisfy the specified test.
* @param callbackfn A function that accepts up to three arguments. The every method calls the callbackfn function for each element in array1 until the callbackfn returns false, or until the end of the array.
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
*/
every(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean;
/**
* Determines whether the specified callback function returns true for any element of an array.
* @param callbackfn A function that accepts up to three arguments. The some method calls the callbackfn function for each element in array1 until the callbackfn returns true, or until the end of the array.
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
*/
some(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean;
/**
* Performs the specified action for each element in an array.
* @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array.
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
*/
forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void;
/**
* Calls a defined callback function on each element of an array, and returns an array that contains the results.
* @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
*/
map<U>(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[];
/**
* Returns the elements of an array that meet the condition specified in a callback function.
* @param callbackfn A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array.
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
*/
filter(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): T[];
/**
* Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.
* @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array.
* @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value.
*/
reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue?: T): T;
/**
* Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.
* @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array.
* @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value.
*/
reduce<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U;
/**
* Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.
* @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array.
* @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value.
*/
reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue?: T): T;
/**
* Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.
* @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array.
* @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value.
*/
reduceRight<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U;
/**
* Gets or sets the length of the array. This is a number one higher than the highest element defined in an array.
*/
length: number;
}

View File

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

View File

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

View File

@@ -1,3 +0,0 @@
{
"nativescript": {}
}

View File

@@ -0,0 +1,226 @@
import { Observable, EventData } from "../observable";
import { ObservableArray, ChangedData, ChangeType } from "../observable-array";
/**
* Event args for "itemsLoading" event.
*/
export interface ItemsLoading extends EventData {
/**
* Start index.
*/
index: number;
/**
* Number of items to load.
*/
count: number;
}
/**
* Advanced array like class that helps loading items on demand.
*/
export class VirtualArray<T> extends Observable {
/**
* String value used when hooking to change event.
*/
public static changeEvent = ChangeType.Change;
/**
* String value used when hooking to itemsLoading event.
*/
public static itemsLoadingEvent = "itemsLoading";
private _requestedIndexes: Array<number>;
private _loadedIndexes: Array<number>;
private _length: number;
private _cache: {};
constructor(length = 0) {
super();
this._length = length;
this._cache = {};
this._requestedIndexes = [];
this._loadedIndexes = [];
}
/**
* Gets or sets length for the virtual array.
*/
get length(): number {
return this._length;
}
set length(value: number) {
if (this._length !== value) {
const index = this._length;
const count = value - this._length;
this._length = value;
this.notify({
eventName: ChangeType.Change,
object: this,
action: count > 0 ? ChangeType.Add : ChangeType.Delete,
index: index,
removed: new Array(count < 0 ? Math.abs(count) : 0),
addedCount: count > 0 ? count : 0,
});
}
}
/**
* Gets or sets load size for the virtual array.
*/
private _loadSize: number;
get loadSize(): number {
return this._loadSize;
}
set loadSize(value: number) {
this._loadSize = value;
}
getItem(index: number): T {
const item = this._cache[index];
if (item === undefined) {
if (
index >= 0 &&
index < this.length &&
this._requestedIndexes.indexOf(index) < 0 &&
this._loadedIndexes.indexOf(index) < 0
) {
this.requestItems(index);
}
}
return item;
}
setItem(index: number, value: T) {
if (this._cache[index] !== value) {
this.load(index, [value]);
}
}
/**
* Loads items from an array starting at index.
*/
load(index: number, items: T[]): void {
for (let i = 0; i < items.length; i++) {
const itemIndex = index + i;
this._cache[itemIndex] = items[i];
this._requestedIndexes.splice(
this._requestedIndexes.indexOf(itemIndex),
1
);
if (this._loadedIndexes.indexOf(itemIndex) < 0) {
this._loadedIndexes.push(itemIndex);
}
}
// Remove requested but never loaded indexes.
if (this._requestedIndexes.length > 0) {
for (let i = 0; i < this.loadSize - items.length; i++) {
this._requestedIndexes.splice(
this._requestedIndexes.indexOf(index + i),
1
);
}
}
this.notify({
eventName: ChangeType.Change,
object: this,
action: ChangeType.Update,
index: index,
removed: new Array(items.length),
addedCount: items.length,
});
}
private requestItems(index: number): void {
const indexesToLoad = [];
const pageIndex =
this._loadSize > 0
? this._loadSize * Math.floor(index / this._loadSize)
: index;
let count = 0;
let start = -1;
for (let i = 0; i < this.loadSize; i++) {
const itemIndex = pageIndex + i;
if (itemIndex >= this._length) {
break;
}
if (this._loadedIndexes.indexOf(itemIndex) < 0) {
if (start < 0) {
start = itemIndex;
}
indexesToLoad.push(itemIndex);
if (this._requestedIndexes.indexOf(itemIndex) < 0) {
this._requestedIndexes.push(itemIndex);
}
count++;
} else {
if (count > 0) {
this.notify({
eventName: VirtualArray.itemsLoadingEvent,
object: this,
index: start,
count: count,
});
}
start = -1;
count = 0;
}
}
if (start >= 0 && count > 0) {
this.notify({
eventName: VirtualArray.itemsLoadingEvent,
object: this,
index: start,
count: count,
});
}
}
}
export interface VirtualArray<T> {
/**
* A basic method signature to hook an event listener (shortcut alias to the addEventListener method).
* @param eventNames - String corresponding to events (e.g. "propertyChange"). Optionally could be used more events separated by `,` (e.g. "propertyChange", "change").
* @param callback - Callback function which will be executed when event is raised.
* @param thisArg - An optional parameter which will be used as `this` context for callback execution.
*/
on(
eventNames: string,
callback: (data: EventData) => void,
thisArg?: any
): void;
/**
* Raised when still not loaded items are requested.
*/
on(
event: "itemsLoading",
callback: (args: ItemsLoading) => void,
thisArg?: any
): void;
/**
* Raised when a change occurs.
*/
on(
event: "change",
callback: (args: ChangedData<T>) => void,
thisArg?: any
): void;
}

View File

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

View File

@@ -1,77 +0,0 @@
import { Observable, EventData } from "../observable";
import { ObservableArray, ChangedData, ChangeType } from "../observable-array";
/**
* Advanced array like class that helps loading items on demand.
*/
export class VirtualArray<T> extends Observable {
/**
* String value used when hooking to change event.
*/
public static changeEvent: string;
/**
* String value used when hooking to itemsLoading event.
*/
public static itemsLoadingEvent: string;
constructor(arrayLength?: number);
/**
* Gets or sets length for the virtual array.
*/
length: number;
/**
* Gets or sets load size for the virtual array.
*/
loadSize: number;
/**
* Returns item at specified index.
*/
getItem(index: number): T;
/**
* Sets item at specified index.
*/
setItem(index: number, value: T): void;
/**
* Loads items from an array starting at index.
*/
load(index: number, items: T[]): void;
/**
* A basic method signature to hook an event listener (shortcut alias to the addEventListener method).
* @param eventNames - String corresponding to events (e.g. "propertyChange"). Optionally could be used more events separated by `,` (e.g. "propertyChange", "change").
* @param callback - Callback function which will be executed when event is raised.
* @param thisArg - An optional parameter which will be used as `this` context for callback execution.
*/
on(eventNames: string, callback: (data: EventData) => void, thisArg?: any);
/**
* Raised when still not loaded items are requested.
*/
on(event: "itemsLoading", callback: (args: ItemsLoading) => void, thisArg?: any);
/**
* Raised when a change occurs.
*/
on(event: "change", callback: (args: ChangedData<T>) => void, thisArg?: any);
}
/**
* Event args for "itemsLoading" event.
*/
export interface ItemsLoading extends EventData {
/**
* Start index.
*/
index: number;
/**
* Number of items to load.
*/
count: number;
}

View File

@@ -1,165 +0,0 @@
import { Observable, EventData } from "../observable";
import * as virtualArrayDef from ".";
const CHANGE = "change";
const UPDATE = "update";
const DELETE = "delete";
const ADD = "add";
export class ChangeType implements virtualArrayDef.ChangeType {
static Add = ADD;
static Delete = DELETE;
static Update = UPDATE;
static Splice = CHANGE;
}
export class VirtualArray<T> extends Observable implements virtualArrayDef.VirtualArray<T> {
public static changeEvent = CHANGE;
public static itemsLoadingEvent = "itemsLoading";
private _requestedIndexes: Array<number>;
private _loadedIndexes: Array<number>;
private _length: number;
private _cache: {};
constructor(length = 0) {
super();
this._length = length;
this._cache = {};
this._requestedIndexes = [];
this._loadedIndexes = [];
}
get length(): number {
return this._length;
}
set length(value: number) {
if (this._length !== value) {
const index = this._length;
const count = value - this._length;
this._length = value;
this.notify({
eventName: CHANGE, object: this,
action: count > 0 ? ADD : DELETE,
index: index,
removed: new Array(count < 0 ? Math.abs(count) : 0),
addedCount: count > 0 ? count : 0
});
}
}
private _loadSize: number;
get loadSize(): number {
return this._loadSize;
}
set loadSize(value: number) {
this._loadSize = value;
}
getItem(index: number): T {
const item = this._cache[index];
if (item === undefined) {
if (index >= 0 && index < this.length && this._requestedIndexes.indexOf(index) < 0 && this._loadedIndexes.indexOf(index) < 0) {
this.requestItems(index);
}
}
return item;
}
setItem(index: number, value: T) {
if (this._cache[index] !== value) {
this.load(index, [value]);
}
}
load(index: number, items: T[]): void {
for (let i = 0; i < items.length; i++) {
const itemIndex = index + i;
this._cache[itemIndex] = items[i];
this._requestedIndexes.splice(this._requestedIndexes.indexOf(itemIndex), 1);
if (this._loadedIndexes.indexOf(itemIndex) < 0) {
this._loadedIndexes.push(itemIndex);
}
}
// Remove requested but never loaded indexes.
if (this._requestedIndexes.length > 0) {
for (let i = 0; i < this.loadSize - items.length; i++) {
this._requestedIndexes.splice(this._requestedIndexes.indexOf(index + i), 1);
}
}
this.notify({
eventName: CHANGE, object: this,
action: UPDATE,
index: index,
removed: new Array(items.length),
addedCount: items.length
});
}
private requestItems(index: number): void {
const indexesToLoad = [];
const pageIndex = this._loadSize > 0 ? this._loadSize * Math.floor(index / this._loadSize) : index;
let count = 0;
let start = -1;
for (let i = 0; i < this.loadSize; i++) {
const itemIndex = pageIndex + i;
if (itemIndex >= this._length) {
break;
}
if (this._loadedIndexes.indexOf(itemIndex) < 0) {
if (start < 0) {
start = itemIndex;
}
indexesToLoad.push(itemIndex);
if (this._requestedIndexes.indexOf(itemIndex) < 0) {
this._requestedIndexes.push(itemIndex);
}
count++;
} else {
if (count > 0) {
this.notify({
eventName: VirtualArray.itemsLoadingEvent, object: this,
index: start,
count: count
});
}
start = -1;
count = 0;
}
}
if (start >= 0 && count > 0) {
this.notify({
eventName: VirtualArray.itemsLoadingEvent, object: this,
index: start,
count: count
});
}
}
}
export interface VirtualArray<T> {
on(eventNames: string, callback: (data: EventData) => void, thisArg?: any);
on(event: "itemsLoading", callback: (args: virtualArrayDef.ItemsLoading) => void, thisArg?: any);
on(event: "change", callback: (args: virtualArrayDef.ChangedData<T>) => void, thisArg?: any);
}

View File

@@ -1,6 +1,11 @@
import { ViewBase } from "../ui/core/view";
import { ViewBase } from "../ui/core/view-base";
import { CSSComputedStyleProperty } from "./css-agent";
export declare function getNodeById(id: number): DOMNode;
declare class WeakRef<T> {
constructor(obj: T);
get(): T;
clear(): void;
}
export declare class DOMNode {
nodeId: any;
nodeType: any;

View File

@@ -2,7 +2,7 @@ import { CSSComputedStyleProperty } from "./css-agent";
import { InspectorEvents } from "./devtools-elements-interfaces";
// Needed for typings only
import { ViewBase } from "../ui/core/view";
import { ViewBase } from "../ui/core/view-base";
const registeredDomNodes = {};
const ELEMENT_NODE_TYPE = 1;

View File

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

View File

@@ -1,7 +1,7 @@
import * as inspectorCommandTypes from "./InspectorBackendCommands.ios";
const inspectorCommands: typeof inspectorCommandTypes = require("./InspectorBackendCommands");
import * as debuggerDomains from "./debugger";
import * as debuggerDomains from ".";
import { attachCSSInspectorCommandCallbacks } from "./devtools-elements";

View File

@@ -1,7 +1,7 @@
import * as inspectorCommandTypes from "./InspectorBackendCommands.ios";
const inspectorCommands: typeof inspectorCommandTypes = require("./InspectorBackendCommands");
import * as debuggerDomains from "./debugger";
import * as debuggerDomains from ".";
import { attachDOMInspectorEventCallbacks, attachDOMInspectorCommandCallbacks } from "./devtools-elements";

View File

@@ -1,7 +1,7 @@
import * as inspectorCommandTypes from "./InspectorBackendCommands.ios";
const inspectorCommands: typeof inspectorCommandTypes = require("./InspectorBackendCommands");
import * as debuggerDomains from "./debugger";
import * as debuggerDomains from ".";
declare var __inspectorSendEvent;

View File

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

View File

@@ -1,10 +0,0 @@
import { PlatformContext } from "../../module-name-resolver/qualifier-matcher";
export class FileNameResolver {
constructor(context: PlatformContext);
resolveFileName(path: string, ext: string): string;
clearCache(): void;
}
export function resolveFileName(path: string, ext: string): string;
export function clearCache(): void;

View File

@@ -1,10 +1,11 @@
import { PlatformContext, FileNameResolver as FileNameResolverDefinition } from ".";
import { FileNameResolver as FileNameResolverDefinition } from ".";
import { PlatformContext } from "../../module-name-resolver/qualifier-matcher";
import { screen, device } from "../../platform";
import { path as fsPath, Folder, File } from "../file-system";
import * as trace from "../../trace";
import { path as fsPath, Folder, File } from "..";
import { Trace } from "../../trace";
import * as appCommonModule from "../../application/application-common";
import { findMatch, stripQualifiers } from "../../module-name-resolver/qualifier-matcher/qualifier-matcher";
import { findMatch, stripQualifiers } from "../../module-name-resolver/qualifier-matcher";
export class FileNameResolver implements FileNameResolverDefinition {
private _context: PlatformContext;
@@ -63,8 +64,8 @@ export class FileNameResolver implements FileNameResolverDefinition {
});
}
else {
if (trace.isEnabled()) {
trace.write("Could not find folder " + folderPath + " when loading " + path + ext, trace.categories.Navigation);
if (Trace.isEnabled()) {
Trace.write("Could not find folder " + folderPath + " when loading " + path + ext, Trace.categories.Navigation);
}
}

View File

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

View File

@@ -323,7 +323,7 @@ export class File extends FileSystemEntity {
});
}
@profile
@profile()
public readTextSync(onError?: (error: any) => any, encoding?: string): string {
this.checkAccess();

View File

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

View File

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

View File

@@ -1,4 +1,4 @@
/**
* Register globals such as setTimeout, setInterval, console etc.
*/
export function initGlobal();
export declare var hasInitGlobal: boolean;
export function installPolyfills(moduleName: string, exportNames: string[]): void;
export function initGlobal(): void;

View File

@@ -5,7 +5,7 @@ import * as platformModule from "../../platform";
import * as fsModule from "../../file-system";
import { getFilenameFromUrl } from "./http-request-common";
import { NetworkAgent } from "../../debugger/debugger";
import { NetworkAgent } from "../../debugger";
export enum HttpResponseEncoding {
UTF8,

View File

@@ -4,7 +4,7 @@ import * as imageSourceModule from "../../image-source";
import * as fsModule from "../../file-system";
import * as types from "../../utils/types";
import * as domainDebugger from "../../debugger/debugger";
import * as domainDebugger from "../../debugger";
import { getFilenameFromUrl } from "./http-request-common";
export enum HttpResponseEncoding {

View File

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

View File

@@ -1,7 +1,105 @@
import { ImageSource } from "../image-source";
import { File } from "../file-system";
import * as httpRequest from "./http-request";
export * from "./http-request";
/**
* Provides options for the http requests.
*/
export interface HttpRequestOptions {
/**
* Gets or sets the request url.
*/
url: string;
/**
* Gets or sets the request method.
*/
method: string;
/**
* Gets or sets the request headers in JSON format.
*/
headers?: any;
/**
* Gets or sets the request body.
*/
content?: string | FormData | ArrayBuffer;
/**
* Gets or sets the request timeout in milliseconds.
*/
timeout?: number;
/**
* Gets or sets wether to *not* follow server's redirection responses.
*/
dontFollowRedirects?: boolean;
}
/**
* Encapsulates HTTP-response information from an HTTP-request.
*/
export interface HttpResponse {
/**
* Gets the response status code.
*/
statusCode: number;
/**
* Gets the response headers.
*/
headers: Headers;
/**
* Gets the response content.
*/
content?: HttpContent;
}
export type Headers = { [key: string]: string | string[] };
export enum HttpResponseEncoding {
UTF8,
GBK
}
/**
* Encapsulates the content of an HttpResponse.
*/
export interface HttpContent {
/**
* Gets the response body as raw data.
*/
raw: any;
/**
* Gets the response body as ArrayBuffer
*/
toArrayBuffer: () => ArrayBuffer;
/**
* Gets the response body as string.
*/
toString: (encoding?: HttpResponseEncoding) => string;
/**
* Gets the response body as JSON object.
*/
toJSON: (encoding?: HttpResponseEncoding) => any;
/**
* Gets the response body as ImageSource.
*/
toImage: () => Promise<ImageSource>;
/**
* Gets the response body as file.
*/
toFile: (destinationFilePath?: string) => File;
}
export function getString(arg: any): Promise<string> {
return new Promise<string>((resolve, reject) => {
httpRequest.request(typeof arg === "string" ? { url: arg, method: "GET" } : arg)

View File

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

View File

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

View File

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

View File

@@ -80,23 +80,8 @@ export declare const Profiling: {
stopCPUProfile: typeof stopCPUProfile;
};
export { encoding } from "./text";
export { DefaultErrorHandler, ErrorHandler, TraceWriter } from "./trace";
import { messageType, categories, setCategories, addCategories, addWriter, removeWriter, clearWriters, setErrorHandler, write, error, enable, disable, isEnabled } from "./trace";
export declare const Trace: {
messageType: typeof messageType;
categories: typeof categories;
setCategories: typeof setCategories;
addCategories: typeof addCategories;
addWriter: typeof addWriter;
removeWriter: typeof removeWriter;
clearWriters: typeof clearWriters;
setErrorHandler: typeof setErrorHandler;
write: typeof write;
error: typeof error;
enable: typeof enable;
disable: typeof disable;
isEnabled: typeof isEnabled;
};
export * from "./trace";
export * from "./ui";
import { GC, isFontIconURI, isDataURI, isFileOrResourcePath, executeOnMainThread, mainThreadify, isMainThread, dispatchToMainThread, releaseNativeObject, getModuleName, openFile, openUrl, isRealDevice, layout, ad as androidUtils, ios as iosUtils } from "./utils/utils";
export declare const Utils: {

View File

@@ -80,22 +80,9 @@ export const Profiling = {
export { encoding } from "./text";
export { DefaultErrorHandler, ErrorHandler, TraceWriter } from "./trace";
import {
messageType, categories, setCategories, addCategories,
addWriter, removeWriter, clearWriters,
setErrorHandler,
write, error, enable, disable, isEnabled
} from "./trace";
export * from "./trace";
export const Trace = {
messageType, categories, setCategories, addCategories,
addWriter, removeWriter, clearWriters,
setErrorHandler,
write, error, enable, disable, isEnabled
};
export * from "./ui"; // Barrel export
export * from "./ui";
import {
GC, isFontIconURI, isDataURI, isFileOrResourcePath,

View File

@@ -4,7 +4,7 @@
* may be changed in a non-major version.
*/
import { TransformFunctionsInfo } from "../ui/animation/animation";
import { TransformFunctionsInfo } from "../ui/animation";
/**
* Returns the affine matrix representation of the transformation.

View File

@@ -1,4 +1,4 @@
import { TransformFunctionsInfo } from "../ui/animation/animation";
import { TransformFunctionsInfo } from "../ui/animation";
import { radiansToDegrees, degreesToRadians } from "../utils/number-utils";

View File

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

View File

@@ -1,5 +1,5 @@
import { ModuleNameResolver as ModuleNameResolverDefinition, ModuleListProvider } from "./";
import { screen, device } from "../platform/platform";
import { ModuleNameResolver as ModuleNameResolverDefinition } from "./";
import { screen, device } from "../platform";
import * as appCommonModule from "../application/application-common";
import { PlatformContext, findMatch, stripQualifiers } from "./qualifier-matcher";
import { registerModulesFromFileSystem } from "./non-bundle-workflow-compat";
@@ -7,6 +7,8 @@ import {
Trace
} from "../trace";
export type ModuleListProvider = () => string[];
export class ModuleNameResolver implements ModuleNameResolverDefinition {
private _cache = {};

View File

@@ -1,4 +1,4 @@
import * as fs from "../file-system/file-system";
import * as fs from "../file-system";
import * as appCommonModule from "../application/application-common";
import {
Trace

View File

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

View File

@@ -1,9 +1,15 @@
import { PlatformContext } from "./";
const MIN_WH: string = "minWH";
const MIN_W: string = "minW";
const MIN_H: string = "minH";
const PRIORITY_STEP = 10000;
export interface PlatformContext {
width: number;
height: number;
os: string;
deviceType: string;
}
interface QualifierSpec {
isMatch(path: string): boolean;
getMatchOccurences(path: string): Array<string>;

View File

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

View File

@@ -1,4 +1,4 @@
declare var global: NodeJS.Global;
declare var global: NodeJS.Global & typeof globalThis;
interface ModuleResolver {
/**

View File

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

View File

@@ -1,8 +1,6 @@
declare var __startCPUProfiler: any;
declare var __stopCPUProfiler: any;
import { TimerInfo as TimerInfoDefinition, InstrumentationMode } from ".";
export function uptime() {
return global.android ? (<any>org).nativescript.Process.getUpTime() : (<any>global).__tns_uptime();
}
@@ -14,7 +12,9 @@ export function log(message: string): void {
console.log(message);
}
interface TimerInfo extends TimerInfoDefinition {
export type InstrumentationMode = "counters" | "timeline" | "lifecycle";
export interface TimerInfo {
totalTime: number;
lastTime?: number;
count: number;
@@ -239,7 +239,7 @@ const voidMethodDecorator = () => {
// no op
};
export function profile(nameFnOrTarget?: string | Function | Object, fnOrKey?: Function | string | symbol, descriptor?: PropertyDescriptor): Function | MethodDecorator {
export function profile(nameFnOrTarget?: string | Function | Object, fnOrKey?: Function | string | symbol, descriptor?: PropertyDescriptor, attrs?: any): Function | MethodDecorator {
if (typeof nameFnOrTarget === "object" && (typeof fnOrKey === "string" || typeof fnOrKey === "symbol")) {
if (!profileFunctionFactory) {
return;

View File

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

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