mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 11:42:04 +08:00
Added "External Ambient Module Declarations" for most modules.
Now they are required by module name e.g require("file-system") instead of by file name.
This commit is contained in:
@ -9,7 +9,7 @@
|
||||
|
||||
*/
|
||||
|
||||
import Application = require("application/application");
|
||||
import Application = require("application");
|
||||
import timer = require("timer/timer");
|
||||
|
||||
var runTest = function (test, testName) {
|
||||
|
@ -4,7 +4,7 @@
|
||||
// It is the main BCL module and is required for other BCL modules to work properly.
|
||||
// The default bootstrap.js implementation for each platform loads and initializes this module.
|
||||
// ``` JavaScript
|
||||
import app = require("application/application");
|
||||
import app = require("application");
|
||||
// ```
|
||||
// The pre-required `app` module is used throughout the following code snippets.
|
||||
// </snippet>
|
||||
|
@ -1,4 +1,4 @@
|
||||
import app = require("application/application");
|
||||
import app = require("application");
|
||||
import TKUnit = require("Tests/TKUnit");
|
||||
import commonTests = require("Tests/application-tests-common");
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
// Using the file system requires the FileSystem module.
|
||||
// TODO: var fs = require("file-system"); => this will break the intellisense of the tests
|
||||
// ``` JavaScript
|
||||
import fs = require("file-system/file-system");
|
||||
import fs = require("file-system");
|
||||
// ```
|
||||
// The pre-required `fs` module is used throughout the following code snippets.
|
||||
// </snippet>
|
||||
|
@ -1,5 +1,5 @@
|
||||
import TKUnit = require("Tests/TKUnit");
|
||||
import http = require("http/http");
|
||||
import http = require("http");
|
||||
require("globals");
|
||||
|
||||
// <snippet name="http">
|
||||
|
@ -13,8 +13,8 @@
|
||||
// </snippet>
|
||||
|
||||
import imageSource = require("image-source/image-source");
|
||||
import fs = require("file-system/file-system");
|
||||
import app = require("application/application");
|
||||
import fs = require("file-system");
|
||||
import app = require("application");
|
||||
import TKUnit = require("Tests/TKUnit");
|
||||
|
||||
export var testFromResource = function () {
|
||||
|
204
application/application.d.ts
vendored
204
application/application.d.ts
vendored
@ -1,130 +1,134 @@
|
||||
/**
|
||||
* The main entry point event. This method is expected to return an instance of the root UI for the application.
|
||||
* This will be an Activity extends for Android and a RootViewController for iOS.
|
||||
*/
|
||||
export declare function onLaunch(): any;
|
||||
|
||||
/**
|
||||
* This method will be called when the Application is suspended.
|
||||
*/
|
||||
export declare function onSuspend();
|
||||
|
||||
/**
|
||||
* This method will be called when the Application is resumed after it has been suspended.
|
||||
*/
|
||||
export declare function onResume();
|
||||
|
||||
/**
|
||||
* This method will be called when the Application is about to exit.
|
||||
*/
|
||||
export declare function onExit();
|
||||
|
||||
/**
|
||||
* This method will be called when there is low memory on the target device.
|
||||
*/
|
||||
export declare function onLowMemory();
|
||||
|
||||
/**
|
||||
* This is the Android-specific application object instance.
|
||||
* Encapsulates methods and properties specific to the Android platform.
|
||||
* Will be undefined when TargetOS is iOS.
|
||||
*/
|
||||
export declare var android: AndroidApplication;
|
||||
|
||||
/**
|
||||
* This is the iOS-specific application object instance.
|
||||
* Encapsulates methods and properties specific to the iOS platform.
|
||||
* Will be undefined when TargetOS is Android.
|
||||
*/
|
||||
export declare var ios: iOSApplication;
|
||||
|
||||
/**
|
||||
* The abstraction of an Android-specific application object.
|
||||
*/
|
||||
export declare class AndroidApplication {
|
||||
/**
|
||||
* The android.app.Application object instance provided to the init of the module.
|
||||
*/
|
||||
public nativeApp: android.app.Application;
|
||||
|
||||
declare module "application" {
|
||||
|
||||
/**
|
||||
* The application android.content.Context object instance.
|
||||
* The main entry point event. This method is expected to return an instance of the root UI for the application.
|
||||
* This will be an Activity extends for Android and a RootViewController for iOS.
|
||||
*/
|
||||
public context: android.content.Context;
|
||||
function onLaunch(): any;
|
||||
|
||||
/**
|
||||
* The currently active (loaded) android.app.Activity. This property is automatically updated upon Activity events.
|
||||
* This method will be called when the Application is suspended.
|
||||
*/
|
||||
public currentActivity: android.app.Activity;
|
||||
function onSuspend();
|
||||
|
||||
/**
|
||||
* The main (start) Activity for the application.
|
||||
* This method will be called when the Application is resumed after it has been suspended.
|
||||
*/
|
||||
public startActivity: android.app.Activity;
|
||||
function onResume();
|
||||
|
||||
/**
|
||||
* The name of the application package.
|
||||
* This method will be called when the Application is about to exit.
|
||||
*/
|
||||
public packageName: string;
|
||||
function onExit();
|
||||
|
||||
/**
|
||||
* This method is called by the JavaScript Bridge when navigation to a new activity is triggered.
|
||||
* The return value of this method should be com.tns.NativeScriptActivity.extends implementation.
|
||||
* This method will be called when there is low memory on the target device.
|
||||
*/
|
||||
public getActivity: (intent: android.content.Intent) => any;
|
||||
function onLowMemory();
|
||||
|
||||
/**
|
||||
* Direct handler of the android.app.Application.ActivityLifecycleCallbacks.onActivityCreated method.
|
||||
* This is the Android-specific application object instance.
|
||||
* Encapsulates methods and properties specific to the Android platform.
|
||||
* Will be undefined when TargetOS is iOS.
|
||||
*/
|
||||
public onActivityCreated: (activity: android.app.Activity, bundle: android.os.Bundle) => void;
|
||||
var android: AndroidApplication;
|
||||
|
||||
/**
|
||||
* Direct handler of the android.app.Application.ActivityLifecycleCallbacks.onActivityDestroyed method.
|
||||
* This is the iOS-specific application object instance.
|
||||
* Encapsulates methods and properties specific to the iOS platform.
|
||||
* Will be undefined when TargetOS is Android.
|
||||
*/
|
||||
public onActivityDestroyed: (activity: android.app.Activity) => void;
|
||||
var ios: iOSApplication;
|
||||
|
||||
/**
|
||||
* Direct handler of the android.app.Application.ActivityLifecycleCallbacks.onActivityDestroyed method.
|
||||
* The abstraction of an Android-specific application object.
|
||||
*/
|
||||
public onActivityStarted: (activity: android.app.Activity) => void;
|
||||
class AndroidApplication {
|
||||
/**
|
||||
* The android.app.Application object instance provided to the init of the module.
|
||||
*/
|
||||
public nativeApp: android.app.Application;
|
||||
|
||||
/**
|
||||
* The application android.content.Context object instance.
|
||||
*/
|
||||
public context: android.content.Context;
|
||||
|
||||
/**
|
||||
* The currently active (loaded) android.app.Activity. This property is automatically updated upon Activity events.
|
||||
*/
|
||||
public currentActivity: android.app.Activity;
|
||||
|
||||
/**
|
||||
* The main (start) Activity for the application.
|
||||
*/
|
||||
public startActivity: android.app.Activity;
|
||||
|
||||
/**
|
||||
* The name of the application package.
|
||||
*/
|
||||
public packageName: string;
|
||||
|
||||
/**
|
||||
* This method is called by the JavaScript Bridge when navigation to a new activity is triggered.
|
||||
* The return value of this method should be com.tns.NativeScriptActivity.extends implementation.
|
||||
*/
|
||||
public getActivity: (intent: android.content.Intent) => any;
|
||||
|
||||
/**
|
||||
* Direct handler of the android.app.Application.ActivityLifecycleCallbacks.onActivityCreated method.
|
||||
*/
|
||||
public onActivityCreated: (activity: android.app.Activity, bundle: android.os.Bundle) => void;
|
||||
|
||||
/**
|
||||
* Direct handler of the android.app.Application.ActivityLifecycleCallbacks.onActivityDestroyed method.
|
||||
*/
|
||||
public onActivityDestroyed: (activity: android.app.Activity) => void;
|
||||
|
||||
/**
|
||||
* Direct handler of the android.app.Application.ActivityLifecycleCallbacks.onActivityDestroyed method.
|
||||
*/
|
||||
public onActivityStarted: (activity: android.app.Activity) => void;
|
||||
|
||||
/**
|
||||
* Direct handler of the android.app.Application.ActivityLifecycleCallbacks.onActivityPaused method.
|
||||
*/
|
||||
public onActivityPaused: (activity: android.app.Activity) => void;
|
||||
|
||||
/**
|
||||
* Direct handler of the android.app.Application.ActivityLifecycleCallbacks.onActivityResumed method.
|
||||
*/
|
||||
public onActivityResumed: (activity: android.app.Activity) => void;
|
||||
|
||||
/**
|
||||
* Direct handler of the android.app.Application.ActivityLifecycleCallbacks.onActivityStopped method.
|
||||
*/
|
||||
public onActivityStopped: (activity: android.app.Activity) => void;
|
||||
|
||||
/**
|
||||
* Direct handler of the android.app.Application.ActivityLifecycleCallbacks.onSaveActivityState method.
|
||||
*/
|
||||
public onSaveActivityState: (activity: android.app.Activity, bundle: android.os.Bundle) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Direct handler of the android.app.Application.ActivityLifecycleCallbacks.onActivityPaused method.
|
||||
* The abstraction of an iOS-specific application object.
|
||||
*/
|
||||
public onActivityPaused: (activity: android.app.Activity) => void;
|
||||
class iOSApplication {
|
||||
/**
|
||||
* The root view controller for the application.
|
||||
*/
|
||||
public rootController: UIKit.UIViewController;
|
||||
|
||||
/**
|
||||
* The android.app.Application object instance provided to the init of the module.
|
||||
*/
|
||||
public nativeApp: UIKit.UIApplication;
|
||||
}
|
||||
|
||||
/**
|
||||
* Direct handler of the android.app.Application.ActivityLifecycleCallbacks.onActivityResumed method.
|
||||
* Entry point for the module. Initializes the Application singleton and hooks application lifecycle events.
|
||||
*/
|
||||
public onActivityResumed: (activity: android.app.Activity) => void;
|
||||
|
||||
/**
|
||||
* Direct handler of the android.app.Application.ActivityLifecycleCallbacks.onActivityStopped method.
|
||||
*/
|
||||
public onActivityStopped: (activity: android.app.Activity) => void;
|
||||
|
||||
/**
|
||||
* Direct handler of the android.app.Application.ActivityLifecycleCallbacks.onSaveActivityState method.
|
||||
*/
|
||||
public onSaveActivityState: (activity: android.app.Activity, bundle: android.os.Bundle) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* The abstraction of an iOS-specific application object.
|
||||
*/
|
||||
export declare class iOSApplication {
|
||||
/**
|
||||
* The root view controller for the application.
|
||||
*/
|
||||
public rootController: UIKit.UIViewController;
|
||||
|
||||
/**
|
||||
* The android.app.Application object instance provided to the init of the module.
|
||||
*/
|
||||
public nativeApp: UIKit.UIApplication;
|
||||
}
|
||||
|
||||
/**
|
||||
* Entry point for the module. Initializes the Application singleton and hooks application lifecycle events.
|
||||
*/
|
||||
export declare function init(nativeApp: any);
|
||||
function init(nativeApp: any);
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
/*
|
||||
Current launch sequence for iOS looks like:
|
||||
|
||||
var app = require("application/application");
|
||||
var app = require("application");
|
||||
|
||||
app.tk.ui.Application.current.onLaunch = function() {
|
||||
log("tk.ui.Application.current.onLaunch");
|
||||
|
@ -1,2 +1,2 @@
|
||||
declare var module, require;
|
||||
module.exports = require("application/application");
|
||||
module.exports = require("application");
|
||||
|
@ -1,4 +1,4 @@
|
||||
import appModule = require("application/application");
|
||||
import appModule = require("application");
|
||||
|
||||
var REQUEST_IMAGE_CAPTURE: number = 1;
|
||||
var REQUEST_SELECT_PICTURE: number = 2;
|
||||
|
69
camera/camera.d.ts
vendored
69
camera/camera.d.ts
vendored
@ -1,36 +1,39 @@
|
||||
|
||||
import promises = require("promises/promises");
|
||||
import imageSource = require("image-source/image-source");
|
||||
declare module "camera" {
|
||||
|
||||
export declare enum CameraPosition {
|
||||
FRONT = 0,
|
||||
BACK = 1,
|
||||
import promises = require("promises/promises");
|
||||
import imageSource = require("image-source/image-source");
|
||||
|
||||
enum CameraPosition {
|
||||
FRONT = 0,
|
||||
BACK = 1,
|
||||
}
|
||||
|
||||
enum FlashMode {
|
||||
AUTO = 0, // default
|
||||
ON = 1,
|
||||
OFF = 2
|
||||
}
|
||||
|
||||
interface Options {
|
||||
/**
|
||||
* Specifies which Camera to use.
|
||||
*/
|
||||
cameraPosition?: CameraPosition;
|
||||
|
||||
/**
|
||||
* Specifies flash mode.
|
||||
*/
|
||||
flashMode?: FlashMode;
|
||||
}
|
||||
|
||||
// TODO most of hardware related parts need to handle onPause and onResume of the calling activities
|
||||
class CameraManager {
|
||||
takePicture(params: any, onSuccess: (imageData: any) => any, onError?: (error: any) => any);
|
||||
|
||||
// options { useSavedPhotos: true }
|
||||
pictureFromLibrary(params: any, onSuccess: (imageData: any) => any, onError?: (error: any) => any);
|
||||
}
|
||||
|
||||
var takePicture: (options?: Options) => promises.Promise<imageSource.ImageSource>;
|
||||
}
|
||||
|
||||
export declare enum FlashMode {
|
||||
AUTO = 0, // default
|
||||
ON = 1,
|
||||
OFF = 2
|
||||
}
|
||||
|
||||
export interface Options {
|
||||
/**
|
||||
* Specifies which Camera to use
|
||||
*/
|
||||
cameraPosition?: CameraPosition;
|
||||
|
||||
/**
|
||||
* Specifies flash mode
|
||||
*/
|
||||
flashMode?: FlashMode;
|
||||
}
|
||||
|
||||
// TODO most of hardware related parts need to handle onPause and onResume of the calling activities
|
||||
export declare class CameraManager {
|
||||
takePicture(params: any, onSuccess: (imageData: any) => any, onError?: (error: any) => any);
|
||||
|
||||
// options { useSavedPhotos: true }
|
||||
pictureFromLibrary(params: any, onSuccess: (imageData: any) => any, onError?: (error: any) => any);
|
||||
}
|
||||
|
||||
export declare var takePicture: (options?: Options) => promises.Promise<imageSource.ImageSource>;
|
||||
|
@ -1,4 +1,4 @@
|
||||
import appModule = require("application/application");
|
||||
import appModule = require("application");
|
||||
import textModule = require("text/text");
|
||||
|
||||
export class FileSystemAccess {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import app_module = require("application/application");
|
||||
import app_module = require("application");
|
||||
import utilsModule = require("utils/utils_ios");
|
||||
import textModule = require("text/text");
|
||||
|
||||
|
290
file-system/file-system.d.ts
vendored
290
file-system/file-system.d.ts
vendored
@ -1,152 +1,156 @@
|
||||
import promises = require("promises/promises");
|
||||
|
||||
declare module "file-system" {
|
||||
|
||||
import promises = require("promises/promises");
|
||||
|
||||
class FileSystemEntity {
|
||||
/**
|
||||
* Gets the Date object specifying the last time this entity was modified.
|
||||
*/
|
||||
public lastModified: Date;
|
||||
|
||||
/**
|
||||
* Gets the name of the entity.
|
||||
*/
|
||||
public name: string;
|
||||
|
||||
/**
|
||||
* Gets the fully-qualified path (including the extension for a File) of the entity.
|
||||
*/
|
||||
public path: string;
|
||||
|
||||
/**
|
||||
* Gets the Folder object representing the parent of this entity.
|
||||
* Will be null for a root folder like Documents or Temporary.
|
||||
* This property is readonly.
|
||||
*/
|
||||
public parent: Folder;
|
||||
|
||||
/**
|
||||
* Removes (deletes) the current Entity from the file system.
|
||||
*/
|
||||
public remove(): promises.Promise<any>;
|
||||
|
||||
/**
|
||||
* Renames the current entity using the specified name.
|
||||
*/
|
||||
public rename(newName: string): promises.Promise<any>;
|
||||
}
|
||||
|
||||
class File extends FileSystemEntity {
|
||||
/**
|
||||
* Checks whether a File with the specified path already exists.
|
||||
*/
|
||||
public static exists(path: string): boolean;
|
||||
|
||||
/**
|
||||
* Gets the extension of the file.
|
||||
*/
|
||||
public extension: string;
|
||||
|
||||
/**
|
||||
* Gets a value indicating whether the file is currently locked, meaning a background operation associated with this file is running.
|
||||
*/
|
||||
public isLocked: boolean;
|
||||
|
||||
/**
|
||||
* Gets or creates a File entity at the specified path.
|
||||
*/
|
||||
public static fromPath(path: string): File;
|
||||
|
||||
/**
|
||||
* Reads the content of the file as a string using the specified encoding (defaults to UTF-8).
|
||||
*/
|
||||
public readText(encoding?: string): promises.Promise<string>;
|
||||
|
||||
/**
|
||||
* Writes the provided string to the file, using the specified encoding (defaults to UTF-8).
|
||||
*/
|
||||
public writeText(content: string, encoding?: string): promises.Promise<any>;
|
||||
}
|
||||
|
||||
class Folder extends FileSystemEntity {
|
||||
/**
|
||||
* Determines whether this instance is a KnownFolder (accessed through the KnownFolders object).
|
||||
*/
|
||||
public isKnown: boolean;
|
||||
|
||||
/**
|
||||
* Gets or creates a Folder entity at the specified path.
|
||||
*/
|
||||
public static fromPath(path: string): Folder;
|
||||
|
||||
/**
|
||||
* Checks whether a Folder with the specified path already exists.
|
||||
*/
|
||||
public static exists(path: string): boolean;
|
||||
|
||||
/**
|
||||
Checks whether this Folder contains an Entity with the specified name.
|
||||
The path of the folder is added to the name to resolve the complete path to check for.
|
||||
*/
|
||||
public contains(name: string): boolean;
|
||||
|
||||
/**
|
||||
* Deletes all the files and folders (recursively), contained within this Folder.
|
||||
*/
|
||||
public clear(): promises.Promise<any>;
|
||||
|
||||
/**
|
||||
* Gets or creates a File entity with the specified name within this Folder.
|
||||
*/
|
||||
public getFile(name: string): File;
|
||||
|
||||
/**
|
||||
* Gets or creates a Folder entity with the specified name within this Folder.
|
||||
*/
|
||||
public getFolder(name: string): Folder;
|
||||
|
||||
/**
|
||||
* Gets all the top-level entities residing within this folder.
|
||||
*/
|
||||
public getEntities(): promises.Promise<Array<FileSystemEntity>>;
|
||||
|
||||
/**
|
||||
Enumerates all the top-level FileSystem entities residing within this folder.
|
||||
The first parameter is a callback that receives the current entity.
|
||||
If the callback returns false this will mean for the iteration to stop.
|
||||
*/
|
||||
public eachEntity(onEntity: (entity: FileSystemEntity) => boolean);
|
||||
}
|
||||
|
||||
export declare class FileSystemEntity {
|
||||
/**
|
||||
* Gets the Date object specifying the last time this entity was modified.
|
||||
* Provides access to the top-level Folders instances that are accessible from the application. Use these as entry points to access the FileSystem.
|
||||
*/
|
||||
public lastModified: Date;
|
||||
module knownFolders {
|
||||
/**
|
||||
* Gets the Documents folder available for the current application. This Folder is private for the application and not accessible from Users/External apps.
|
||||
*/
|
||||
export function documents(): Folder;
|
||||
|
||||
/**
|
||||
* Gets the Temporary (Caches) folder available for the current application. This Folder is private for the application and not accessible from Users/External apps.
|
||||
*/
|
||||
export function temp(): Folder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name of the entity.
|
||||
*/
|
||||
public name: string;
|
||||
|
||||
/**
|
||||
* Gets the fully-qualified path (including the extension for a File) of the entity.
|
||||
*/
|
||||
public path: string;
|
||||
|
||||
/**
|
||||
* Gets the Folder object representing the parent of this entity.
|
||||
* Will be null for a root folder like Documents or Temporary.
|
||||
* This property is readonly.
|
||||
* Enables path-specific operations like join, extension, etc.
|
||||
*/
|
||||
public parent: Folder;
|
||||
module path {
|
||||
/**
|
||||
* Normalizes a path, taking care of occurrances like ".." and "//"
|
||||
*/
|
||||
export function normalize(path: string): string;
|
||||
|
||||
/**
|
||||
* Removes (deletes) the current Entity from the file system.
|
||||
*/
|
||||
public remove(): promises.Promise<any>;
|
||||
/**
|
||||
* Joins all the provided string components, forming a valid and normalized path.
|
||||
*/
|
||||
export function join(...paths: string[]): string;
|
||||
|
||||
/**
|
||||
* Renames the current entity using the specified name.
|
||||
*/
|
||||
public rename(newName: string): promises.Promise<any>;
|
||||
}
|
||||
|
||||
export declare class File extends FileSystemEntity {
|
||||
/**
|
||||
* Checks whether a File with the specified path already exists.
|
||||
*/
|
||||
public static exists(path: string): boolean;
|
||||
|
||||
/**
|
||||
* Gets the extension of the file.
|
||||
*/
|
||||
public extension: string;
|
||||
|
||||
/**
|
||||
* Gets a value indicating whether the file is currently locked, meaning a background operation associated with this file is running.
|
||||
*/
|
||||
public isLocked: boolean;
|
||||
|
||||
/**
|
||||
* Gets or creates a File entity at the specified path.
|
||||
*/
|
||||
public static fromPath(path: string): File;
|
||||
|
||||
/**
|
||||
* Reads the content of the file as a string using the specified encoding (defaults to UTF-8).
|
||||
*/
|
||||
public readText(encoding?: string): promises.Promise<string>;
|
||||
|
||||
/**
|
||||
* Writes the provided string to the file, using the specified encoding (defaults to UTF-8).
|
||||
*/
|
||||
public writeText(content: string, encoding?: string): promises.Promise<any>;
|
||||
}
|
||||
|
||||
export declare class Folder extends FileSystemEntity {
|
||||
/**
|
||||
* Determines whether this instance is a KnownFolder (accessed through the KnownFolders object).
|
||||
*/
|
||||
public isKnown: boolean;
|
||||
|
||||
/**
|
||||
* Gets or creates a Folder entity at the specified path.
|
||||
*/
|
||||
public static fromPath(path: string): Folder;
|
||||
|
||||
/**
|
||||
* Checks whether a Folder with the specified path already exists.
|
||||
*/
|
||||
public static exists(path: string): boolean;
|
||||
|
||||
/**
|
||||
Checks whether this Folder contains an Entity with the specified name.
|
||||
The path of the folder is added to the name to resolve the complete path to check for.
|
||||
*/
|
||||
public contains(name: string): boolean;
|
||||
|
||||
/**
|
||||
* Deletes all the files and folders (recursively), contained within this Folder.
|
||||
*/
|
||||
public clear(): promises.Promise<any>;
|
||||
|
||||
/**
|
||||
* Gets or creates a File entity with the specified name within this Folder.
|
||||
*/
|
||||
public getFile(name: string): File;
|
||||
|
||||
/**
|
||||
* Gets or creates a Folder entity with the specified name within this Folder.
|
||||
*/
|
||||
public getFolder(name: string): Folder;
|
||||
|
||||
/**
|
||||
* Gets all the top-level entities residing within this folder.
|
||||
*/
|
||||
public getEntities(): promises.Promise<Array<FileSystemEntity>>;
|
||||
|
||||
/**
|
||||
Enumerates all the top-level FileSystem entities residing within this folder.
|
||||
The first parameter is a callback that receives the current entity.
|
||||
If the callback returns false this will mean for the iteration to stop.
|
||||
*/
|
||||
public eachEntity(onEntity: (entity: FileSystemEntity) => boolean);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides access to the top-level Folders instances that are accessible from the application. Use these as entry points to access the FileSystem.
|
||||
*/
|
||||
export declare module knownFolders {
|
||||
/**
|
||||
* Gets the Documents folder available for the current application. This Folder is private for the application and not accessible from Users/External apps.
|
||||
*/
|
||||
export function documents(): Folder;
|
||||
|
||||
/**
|
||||
* Gets the Temporary (Caches) folder available for the current application. This Folder is private for the application and not accessible from Users/External apps.
|
||||
*/
|
||||
export function temp(): Folder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables path-specific operations like join, extension, etc.
|
||||
*/
|
||||
export declare module path {
|
||||
/**
|
||||
* Normalizes a path, taking care of occurrances like ".." and "//"
|
||||
*/
|
||||
export function normalize(path: string): string;
|
||||
|
||||
/**
|
||||
* Joins all the provided string components, forming a valid and normalized path.
|
||||
*/
|
||||
export function join(...paths: string[]): string;
|
||||
|
||||
/**
|
||||
* Gets the string used to separate file paths.
|
||||
*/
|
||||
export var separator: string;
|
||||
/**
|
||||
* Gets the string used to separate file paths.
|
||||
*/
|
||||
export var separator: string;
|
||||
}
|
||||
}
|
@ -1,2 +1,2 @@
|
||||
declare var module, require;
|
||||
module.exports = require("file-system/file-system");
|
||||
module.exports = require("file-system");
|
||||
|
@ -7,4 +7,5 @@ clearTimeout = timer.clearTimeout;
|
||||
setInterval = timer.setInterval;
|
||||
clearInterval = timer.clearInterval;
|
||||
|
||||
console = new consoleModule.Console();
|
||||
console = new consoleModule.Console();
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import image = require("image-source/image-source");
|
||||
import promises = require("promises/promises");
|
||||
import http = require("http/http");
|
||||
import http = require("http");
|
||||
|
||||
/**
|
||||
* Gets string from url.
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Android specific http request implementation.
|
||||
*/
|
||||
import promises = require("promises/promises");
|
||||
import http = require("http/http");
|
||||
import http = require("http");
|
||||
|
||||
declare var exports;
|
||||
require("utils/module-merge").merge(require("http/http-common"), exports);
|
||||
|
55
http/http.d.ts
vendored
55
http/http.d.ts
vendored
@ -1,34 +1,37 @@
|
||||
import image = require("image-source/image-source");
|
||||
import promises = require("promises/promises");
|
||||
|
||||
declare module "http" {
|
||||
import image = require("image-source/image-source");
|
||||
import promises = require("promises/promises");
|
||||
|
||||
export declare function getString(url: string): promises.Promise<string>
|
||||
export declare function getString(options: HttpRequestOptions): promises.Promise<string>
|
||||
function getString(url: string): promises.Promise<string>
|
||||
function getString(options: HttpRequestOptions): promises.Promise<string>
|
||||
|
||||
export declare function getJSON<T>(url: string): promises.Promise<T>
|
||||
export declare function getJSON<T>(options: HttpRequestOptions): promises.Promise<T>
|
||||
function getJSON<T>(url: string): promises.Promise<T>
|
||||
function getJSON<T>(options: HttpRequestOptions): promises.Promise<T>
|
||||
|
||||
export declare function getImage(url: string): promises.Promise<image.ImageSource>
|
||||
export declare function getImage(options: HttpRequestOptions): promises.Promise<image.ImageSource>
|
||||
function getImage(url: string): promises.Promise<image.ImageSource>
|
||||
function getImage(options: HttpRequestOptions): promises.Promise<image.ImageSource>
|
||||
|
||||
export declare function request(options: HttpRequestOptions): promises.Promise<HttpResponse>;
|
||||
function request(options: HttpRequestOptions): promises.Promise<HttpResponse>;
|
||||
|
||||
export interface HttpRequestOptions {
|
||||
url: string;
|
||||
method: string;
|
||||
headers?: any;
|
||||
content?: any;
|
||||
timeout?: number;
|
||||
}
|
||||
interface HttpRequestOptions {
|
||||
url: string;
|
||||
method: string;
|
||||
headers?: any;
|
||||
content?: any;
|
||||
timeout?: number;
|
||||
}
|
||||
|
||||
export interface HttpResponse {
|
||||
statusCode: number;
|
||||
headers: any;
|
||||
content?: HttpContent;
|
||||
}
|
||||
interface HttpResponse {
|
||||
statusCode: number;
|
||||
headers: any;
|
||||
content?: HttpContent;
|
||||
}
|
||||
|
||||
export interface HttpContent {
|
||||
raw: any;
|
||||
toString: () => string;
|
||||
toJSON: () => any;
|
||||
toImage: () => image.ImageSource;
|
||||
interface HttpContent {
|
||||
raw: any;
|
||||
toString: () => string;
|
||||
toJSON: () => any;
|
||||
toImage: () => image.ImageSource;
|
||||
}
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
* iOS specific http request implementation.
|
||||
*/
|
||||
import promises = require("promises/promises");
|
||||
import http = require("http/http");
|
||||
import http = require("http");
|
||||
|
||||
declare var exports;
|
||||
require("utils/module-merge").merge(require("http/http-common"), exports);
|
||||
|
@ -1,4 +1,4 @@
|
||||
import appModule = require("application/application");
|
||||
import appModule = require("application");
|
||||
|
||||
export var fromResource = function (name: string) {
|
||||
var androidApp = appModule.android;
|
||||
|
133
image-source/image-source.d.ts
vendored
133
image-source/image-source.d.ts
vendored
@ -1,86 +1,89 @@
|
||||
import promises = require("promises/promises");
|
||||
|
||||
/**
|
||||
* Defines the recognized image formats.
|
||||
*/
|
||||
export declare enum ImageFormat {
|
||||
PNG,
|
||||
JPEG,
|
||||
}
|
||||
|
||||
/**
|
||||
* Encapsulates the common abstraction behind a platform specific object (typically a Bitmap) that is used as a source for images.
|
||||
*/
|
||||
export declare class ImageSource {
|
||||
/**
|
||||
* Gets the height of this instance. This is a read-only property.
|
||||
*/
|
||||
height: number;
|
||||
|
||||
declare module "image-source" {
|
||||
import promises = require("promises/promises");
|
||||
|
||||
/**
|
||||
* Gets the width of this instance. This is a read-only property.
|
||||
* Defines the recognized image formats.
|
||||
*/
|
||||
width: number;
|
||||
enum ImageFormat {
|
||||
PNG,
|
||||
JPEG,
|
||||
}
|
||||
|
||||
/**
|
||||
* The iOS-specific image instance. Will be undefined when running on Android.
|
||||
* Encapsulates the common abstraction behind a platform specific object (typically a Bitmap) that is used as a source for images.
|
||||
*/
|
||||
ios: UIKit.UIImage;
|
||||
class ImageSource {
|
||||
/**
|
||||
* Gets the height of this instance. This is a read-only property.
|
||||
*/
|
||||
height: number;
|
||||
|
||||
/**
|
||||
* Gets the width of this instance. This is a read-only property.
|
||||
*/
|
||||
width: number;
|
||||
|
||||
/**
|
||||
* The iOS-specific image instance. Will be undefined when running on Android.
|
||||
*/
|
||||
ios: UIKit.UIImage;
|
||||
|
||||
/**
|
||||
* The Android-specific image instance. Will be undefined when running on iOS.
|
||||
*/
|
||||
android: android.graphics.Bitmap;
|
||||
|
||||
/**
|
||||
* Loads this instance from the specified resource name.
|
||||
*/
|
||||
loadFromResource(name: string): boolean;
|
||||
|
||||
/**
|
||||
* Loads this instance from the specified file.
|
||||
*/
|
||||
loadFromFile(path: string): boolean;
|
||||
|
||||
/**
|
||||
* Loads this instance from the specified native image data.
|
||||
*/
|
||||
loadFromData(data: any): boolean;
|
||||
|
||||
/**
|
||||
* Sets the provided native source object (typically a Bitmap).
|
||||
* This will update either the android or ios properties, depending on the target os.
|
||||
*/
|
||||
setNativeSource(source: any): boolean;
|
||||
|
||||
/**
|
||||
* Saves this instance to the specified file, using the provided image format and quality.
|
||||
*/
|
||||
saveToFile(path: string, format: ImageFormat, quality?: number): boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* The Android-specific image instance. Will be undefined when running on iOS.
|
||||
* Creates a new Image instance and loads it from the specified resource name.
|
||||
*/
|
||||
android: android.graphics.Bitmap;
|
||||
function fromResource(name: string): ImageSource;
|
||||
|
||||
/**
|
||||
* Loads this instance from the specified resource name.
|
||||
* Creates a new Image instance and loads it from the specified file.
|
||||
*/
|
||||
loadFromResource(name: string): boolean;
|
||||
function fromFile(path: string): ImageSource;
|
||||
|
||||
/**
|
||||
* Loads this instance from the specified file.
|
||||
* Creates a new Image instance and loads it from the specified resource name.
|
||||
*/
|
||||
loadFromFile(path: string): boolean;
|
||||
function fromData(data: any): ImageSource;
|
||||
|
||||
/**
|
||||
* Loads this instance from the specified native image data.
|
||||
* Creates a new Image instance and sets the provided native source object (typically a Bitmap).
|
||||
* The native source object will update either the android or ios properties, depending on the target os.
|
||||
*/
|
||||
loadFromData(data: any): boolean;
|
||||
function fromNativeSource(source: any): ImageSource;
|
||||
|
||||
/**
|
||||
* Sets the provided native source object (typically a Bitmap).
|
||||
* This will update either the android or ios properties, depending on the target os.
|
||||
* Downloads the image from the provided Url and creates a new Image instance from it.
|
||||
*/
|
||||
setNativeSource(source: any): boolean;
|
||||
|
||||
/**
|
||||
* Saves this instance to the specified file, using the provided image format and quality.
|
||||
*/
|
||||
saveToFile(path: string, format: ImageFormat, quality?: number): boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new Image instance and loads it from the specified resource name.
|
||||
*/
|
||||
export declare function fromResource(name: string): ImageSource;
|
||||
|
||||
/**
|
||||
* Creates a new Image instance and loads it from the specified file.
|
||||
*/
|
||||
export declare function fromFile(path: string): ImageSource;
|
||||
|
||||
/**
|
||||
* Creates a new Image instance and loads it from the specified resource name.
|
||||
*/
|
||||
export declare function fromData(data: any): ImageSource;
|
||||
|
||||
/**
|
||||
* Creates a new Image instance and sets the provided native source object (typically a Bitmap).
|
||||
* The native source object will update either the android or ios properties, depending on the target os.
|
||||
*/
|
||||
export declare function fromNativeSource(source: any): ImageSource;
|
||||
|
||||
/**
|
||||
* Downloads the image from the provided Url and creates a new Image instance from it.
|
||||
*/
|
||||
export declare function fromUrl(url: string): promises.Promise<ImageSource>;
|
||||
function fromUrl(url: string): promises.Promise<ImageSource>;
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
import app = require("application/application");
|
||||
import app = require("application");
|
||||
import native = require("image-source/image-source-native");
|
||||
import promises = require("promises/promises");
|
||||
import http = require("http/http");
|
||||
import http = require("http");
|
||||
|
||||
export enum ImageFormat {
|
||||
PNG,
|
||||
|
@ -1,4 +1,4 @@
|
||||
import appModule = require("application/application");
|
||||
import appModule = require("application");
|
||||
import Common = require("local-settings/local-settings-common");
|
||||
|
||||
var sharedPreferences = appModule.android.context.getSharedPreferences("prefs.db", 0);
|
||||
|
119
local-settings/local-settings.d.ts
vendored
119
local-settings/local-settings.d.ts
vendored
@ -1,73 +1,72 @@
|
||||
/**
|
||||
* report does such key exist
|
||||
*/
|
||||
export declare var hasKey: (key: string) => boolean;
|
||||
|
||||
declare module "local-settings" {
|
||||
/**
|
||||
* report does such key exist
|
||||
*/
|
||||
var hasKey: (key: string) => boolean;
|
||||
|
||||
// getters
|
||||
/**
|
||||
* gets value of the key as boolean, user can provide default value in case there is no value for the key
|
||||
*/
|
||||
var getBoolean: (key: string, defaultValue?: boolean) => boolean;
|
||||
|
||||
/**
|
||||
* gets value of the key as boolean, user can provide default value in case there is no value for the key
|
||||
*/
|
||||
export declare var getBoolean: (key: string, defaultValue?: boolean) => boolean;
|
||||
/**
|
||||
* gets value of the key as string, user can provide default value in case there is no value for the key
|
||||
*/
|
||||
var getString: (key: string, defaultValue?: string) => string;
|
||||
|
||||
/**
|
||||
* gets value of the key as string, user can provide default value in case there is no value for the key
|
||||
*/
|
||||
export declare var getString: (key: string, defaultValue?: string) => string;
|
||||
/**
|
||||
* gets value of the key as string array, user can provide default value in case there is no value for the key
|
||||
*/
|
||||
var getStringArray: (key: string, defaultValue?: string[]) => string[];
|
||||
|
||||
/**
|
||||
* gets value of the key as string array, user can provide default value in case there is no value for the key
|
||||
*/
|
||||
export declare var getStringArray: (key: string, defaultValue?: string[]) => string[];
|
||||
/**
|
||||
* gets value of the key as number (double), user can provide default value in case there is no value for the key
|
||||
*/
|
||||
var getNumber: (key: string, defaultValue?: number) => number;
|
||||
|
||||
/**
|
||||
* gets value of the key as number (double), user can provide default value in case there is no value for the key
|
||||
*/
|
||||
export declare var getNumber: (key: string, defaultValue?: number) => number;
|
||||
/**
|
||||
* gets value of the key as integer, user can provide default value in case there is no value for the key
|
||||
*/
|
||||
var getInt: (key: string, defaultValue?: number) => number;
|
||||
|
||||
/**
|
||||
* gets value of the key as integer, user can provide default value in case there is no value for the key
|
||||
*/
|
||||
export declare var getInt: (key: string, defaultValue?: number) => number;
|
||||
/**
|
||||
* gets value of the key as long integer (not fully supported by JS), user can provide default value in case there is no value for the key
|
||||
*/
|
||||
var getLong: (key: string, defaultValue?: number) => number;
|
||||
|
||||
/**
|
||||
* gets value of the key as long integer (not fully supported by JS), user can provide default value in case there is no value for the key
|
||||
*/
|
||||
export declare var getLong: (key: string, defaultValue?: number) => number;
|
||||
/**
|
||||
* sets value for a key as boolean
|
||||
*/
|
||||
var setBoolean: (key: string, value: boolean) => void;
|
||||
|
||||
// setters
|
||||
/**
|
||||
* sets value for a key as string
|
||||
*/
|
||||
var setString: (key: string, value: string) => void;
|
||||
|
||||
/**
|
||||
* sets value for a key as boolean
|
||||
*/
|
||||
export declare var setBoolean: (key: string, value: boolean) => void;
|
||||
/**
|
||||
* sets value for a key as string array
|
||||
*/
|
||||
var setStringArray: (key: string, value: string[]) => void;
|
||||
|
||||
/**
|
||||
* sets value for a key as string
|
||||
*/
|
||||
export declare var setString: (key: string, value: string) => void;
|
||||
/**
|
||||
* sets value for a key as JS number (double)
|
||||
*/
|
||||
var setNumber: (key: string, value: number) => void;
|
||||
|
||||
/**
|
||||
* sets value for a key as string array
|
||||
*/
|
||||
export declare var setStringArray: (key: string, value: string[]) => void;
|
||||
/**
|
||||
* sets value for a key as integer
|
||||
*/
|
||||
var setInt: (key: string, value: number) => void;
|
||||
|
||||
/**
|
||||
* sets value for a key as JS number (double)
|
||||
*/
|
||||
export declare var setNumber: (key: string, value: number) => void;
|
||||
/**
|
||||
* sets value for a key as long integer
|
||||
*/
|
||||
var setLong: (key: string, value: number) => void;
|
||||
|
||||
/**
|
||||
* sets value for a key as integer
|
||||
*/
|
||||
export declare var setInt: (key: string, value: number) => void;
|
||||
|
||||
/**
|
||||
* sets value for a key as long integer
|
||||
*/
|
||||
export declare var setLong: (key: string, value: number) => void;
|
||||
|
||||
/**
|
||||
* removes a value for key
|
||||
*/
|
||||
export declare var remove: (key: string) => void;
|
||||
/**
|
||||
* removes a value for key
|
||||
*/
|
||||
var remove: (key: string) => void;
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
import types = require("location/location-types");
|
||||
import appModule = require("application/application");
|
||||
import appModule = require("application");
|
||||
|
||||
export class LocationManager {
|
||||
// in meters
|
||||
|
@ -2,7 +2,7 @@
|
||||
import promises = require("promises/promises");
|
||||
import timer = require("timer/timer");
|
||||
import types = require("location/location-types");
|
||||
import locationManagerModule = require("location/location-manager");
|
||||
import locationManagerModule = require("location");
|
||||
|
||||
// merge the exports of the types module with the exports of this file
|
||||
declare var exports;
|
||||
|
@ -9,7 +9,6 @@
|
||||
/**
|
||||
Returns a new "Deferred" value that may be resolved or rejected.
|
||||
*/
|
||||
|
||||
export function defer<Value>(): Deferred<Value> {
|
||||
return new DeferredI<Value>();
|
||||
}
|
||||
@ -17,7 +16,6 @@ export function defer<Value>(): Deferred<Value> {
|
||||
/**
|
||||
Converts a value to a resolved promise.
|
||||
*/
|
||||
|
||||
export function resolve<Value>(v: Value): Promise<Value> {
|
||||
return defer<Value>().resolve(v).promise();
|
||||
}
|
||||
@ -25,7 +23,6 @@ export function resolve<Value>(v: Value): Promise<Value> {
|
||||
/**
|
||||
Returns a rejected promise.
|
||||
*/
|
||||
|
||||
export function reject<Value>(err: Rejection): Promise<Value> {
|
||||
return defer<Value>().reject(err).promise();
|
||||
}
|
||||
@ -39,7 +36,6 @@ export function reject<Value>(err: Rejection): Promise<Value> {
|
||||
All the values of all promise results are collected into the resulting promise which is resolved as soon
|
||||
the last generated element value is resolved.
|
||||
*/
|
||||
|
||||
export function unfold<Seed, Element>(
|
||||
unspool: (current: Seed) => { promise: Promise<Element>; next?: Seed },
|
||||
seed: Seed)
|
||||
@ -94,7 +90,6 @@ function unfoldCore<Seed, Element>(
|
||||
Once a promise is either Rejected or Resolved, it can not change its
|
||||
status anymore.
|
||||
*/
|
||||
|
||||
export enum Status {
|
||||
Unfulfilled,
|
||||
Rejected,
|
||||
@ -105,7 +100,6 @@ export enum Status {
|
||||
If a promise gets rejected, at least a message that indicates the error or
|
||||
reason for the rejection must be provided.
|
||||
*/
|
||||
|
||||
export interface Rejection {
|
||||
message: string;
|
||||
}
|
||||
@ -113,7 +107,6 @@ export interface Rejection {
|
||||
/**
|
||||
Both Promise<T> and Deferred<T> share these properties.
|
||||
*/
|
||||
|
||||
export interface PromiseState<Value> {
|
||||
/// The current status of the promise.
|
||||
status: Status;
|
||||
@ -132,7 +125,6 @@ export interface PromiseState<Value> {
|
||||
When multiple handlers are registered with done(), fail(), or always(), they are called in the
|
||||
same order.
|
||||
*/
|
||||
|
||||
export interface Promise<Value> extends PromiseState<Value> {
|
||||
/**
|
||||
Returns a promise that represents a promise chain that consists of this
|
||||
@ -161,7 +153,6 @@ export interface Promise<Value> extends PromiseState<Value> {
|
||||
an asynchronous process. Callers of that function should only see the Promise<Value> that
|
||||
is returned by promise().
|
||||
*/
|
||||
|
||||
export interface Deferred<Value> extends PromiseState<Value> {
|
||||
/// Returns the encapsulated promise of this deferred instance.
|
||||
/// The returned promise supports composition but removes the ability to resolve or reject
|
||||
@ -183,7 +174,6 @@ export interface Deferred<Value> extends PromiseState<Value> {
|
||||
As soon one of the arguments gets rejected, the resulting promise gets rejected.
|
||||
If no promises were provided, the resulting promise is immediately resolved.
|
||||
*/
|
||||
|
||||
export function when(...promises: Promise<any>[]): Promise<any[]> {
|
||||
var allDone = defer<any[]>();
|
||||
if (!promises.length) {
|
||||
@ -216,7 +206,6 @@ export function when(...promises: Promise<any>[]): Promise<any[]> {
|
||||
|
||||
The Promise<Value> instance is a proxy to the Deferred<Value> instance.
|
||||
*/
|
||||
|
||||
class PromiseI<Value> implements Promise<Value>
|
||||
{
|
||||
constructor(public deferred: DeferredI<Value>)
|
||||
@ -249,7 +238,6 @@ class PromiseI<Value> implements Promise<Value>
|
||||
/**
|
||||
Implementation of a deferred.
|
||||
*/
|
||||
|
||||
class DeferredI<Value> implements Deferred<Value>{
|
||||
|
||||
private _resolved: (v: Value) => void = _ => { };
|
||||
@ -379,7 +367,6 @@ class DeferredI<Value> implements Deferred<Value>{
|
||||
/**
|
||||
Promise Generators and Iterators.
|
||||
*/
|
||||
|
||||
export interface Generator<E> {
|
||||
(): Iterator<E>;
|
||||
}
|
||||
@ -419,7 +406,6 @@ class IteratorI<E> implements Iterator<E>
|
||||
/**
|
||||
Iterator functions.
|
||||
*/
|
||||
|
||||
export function each<E>(gen: Generator<E>, f: (e: E) => void): Promise<{}> {
|
||||
var d = defer();
|
||||
eachCore(d, gen(), f);
|
||||
@ -443,7 +429,6 @@ function eachCore<E>(fin: Deferred<{}>, it: Iterator<E>, f: (e: E) => void): voi
|
||||
/**
|
||||
std
|
||||
*/
|
||||
|
||||
export function isUndefined(v) {
|
||||
return typeof v === 'undefined';
|
||||
}
|
||||
|
3
text/text.d.ts
vendored
3
text/text.d.ts
vendored
@ -8,4 +8,5 @@ export declare module encoding {
|
||||
export var UTF_16BE: any;
|
||||
export var UTF_16LE: any;
|
||||
export var UTF_8: any;
|
||||
}
|
||||
}
|
||||
|
||||
|
2
timer/timer.d.ts
vendored
2
timer/timer.d.ts
vendored
@ -4,4 +4,4 @@
|
||||
export declare function setTimeout(callback: Function, milliseconds?: number): number;
|
||||
export declare function clearTimeout(id: number): void;
|
||||
export declare function setInterval(callback: Function, milliseconds?: number): number;
|
||||
export declare function clearInterval(id: number): void;
|
||||
export declare function clearInterval(id: number): void;
|
||||
|
Reference in New Issue
Block a user