mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-10 11:40:16 +08:00
Merge branch 'master' of https://github.com/borisyankov/DefinitelyTyped
This commit is contained in:
Vendored
+3
-1
@@ -18,7 +18,9 @@ declare module AceAjax {
|
||||
|
||||
bindKey:any;
|
||||
|
||||
exec:Function;
|
||||
exec: Function;
|
||||
|
||||
readOnly?: boolean;
|
||||
}
|
||||
|
||||
export interface CommandManager {
|
||||
|
||||
Vendored
+1
@@ -29,6 +29,7 @@ interface amplifyDecoders {
|
||||
|
||||
interface amplifyAjaxSettings extends JQueryAjaxSettings {
|
||||
cache?: any;
|
||||
dataMap?: {} | ((data: any) => {});
|
||||
decoder?: any /* string or amplifyDecoder */;
|
||||
}
|
||||
|
||||
|
||||
@@ -197,3 +197,12 @@ users = odataResourceClass.odata()
|
||||
var countResult = odataResourceClass.odata().count();
|
||||
var total = countResult.result;
|
||||
|
||||
|
||||
|
||||
|
||||
var usersSelect1 = odataResourceClass.odata()
|
||||
.select('name', 'user');
|
||||
|
||||
|
||||
var usersSelect2 = odataResourceClass.odata()
|
||||
.select(['name', 'user']);
|
||||
+9
-5
@@ -267,6 +267,7 @@ declare module OData {
|
||||
|
||||
interface ICountResult{
|
||||
result: number;
|
||||
$promise: angular.IPromise<any>;
|
||||
}
|
||||
|
||||
class Provider<T> {
|
||||
@@ -278,14 +279,17 @@ declare module OData {
|
||||
private expandables;
|
||||
constructor(callback: ProviderCallback<T>);
|
||||
filter(operand1: any, operand2?: any, operand3?: any): Provider<T>;
|
||||
orderBy(arg1: any, arg2?: any): Provider<T>;
|
||||
orderBy(arg1: string, arg2?: string): Provider<T>;
|
||||
take(amount: number): Provider<T>;
|
||||
skip(amount: number): Provider<T>;
|
||||
private execute();
|
||||
query(success?: any, error?: any): T[];
|
||||
single(success?: any, error?: any): T;
|
||||
get(data: any, success?: any, error?: any): T;
|
||||
expand(params: any, otherParam1?: any, otherParam2?: any, otherParam3?: any, otherParam4?: any, otherParam5?: any, otherParam6?: any, otherParam7?: any): Provider<T>;
|
||||
query(success?: ((p:T[])=>void), error?: (()=>void)): T[];
|
||||
single(success?: ((p:T)=>void), error?: (()=>void)): T;
|
||||
get(key: any, success?: ((p:T)=>void), error?: (()=>void)): T;
|
||||
expand(...params: string[]): Provider<T>;
|
||||
expand(params: string[]): Provider<T>;
|
||||
select(...params: string[]): Provider<T>;
|
||||
select(params: string[]): Provider<T>;
|
||||
count(success?: (result: ICountResult) => any, error?: () => any):ICountResult;
|
||||
withInlineCount(): Provider<T>;
|
||||
}
|
||||
|
||||
+15
-1
@@ -1228,7 +1228,21 @@ declare module protractor {
|
||||
row(index: number): LocatorWithColumn;
|
||||
}
|
||||
|
||||
interface IProtractorLocatorStrategy extends webdriver.ILocatorStrategy {
|
||||
interface IProtractorLocatorStrategy {
|
||||
/**
|
||||
* webdriver's By is an enum of locator functions, so we must set it to
|
||||
* a prototype before inheriting from it.
|
||||
*/
|
||||
className: typeof webdriver.By.className;
|
||||
css: typeof webdriver.By.css;
|
||||
id: typeof webdriver.By.id;
|
||||
linkText: typeof webdriver.By.linkText;
|
||||
js: typeof webdriver.By.js;
|
||||
name: typeof webdriver.By.name;
|
||||
partialLinkText: typeof webdriver.By.partialLinkText;
|
||||
tagName: typeof webdriver.By.tagName;
|
||||
xpath: typeof webdriver.By.xpath;
|
||||
|
||||
/**
|
||||
* Add a locator to this instance of ProtractorBy. This locator can then be
|
||||
* used with element(by.locatorName(args)).
|
||||
|
||||
@@ -135,7 +135,7 @@ testApp.config((
|
||||
popupDelay: 1000,
|
||||
appendToBody: true,
|
||||
trigger: 'mouseenter hover',
|
||||
useContentExp: true
|
||||
useContentExp: true,
|
||||
});
|
||||
$tooltipProvider.setTriggers({
|
||||
'customOpenTrigger': 'customCloseTrigger'
|
||||
|
||||
@@ -14,12 +14,28 @@ myApp.config((
|
||||
|
||||
var matcher: ng.ui.IUrlMatcher = $urlMatcherFactory.compile("/foo/:bar?param1");
|
||||
|
||||
$urlMatcherFactory.caseInsensitive(false);
|
||||
var isCaseInsensitive = $urlMatcherFactory.caseInsensitive();
|
||||
|
||||
$urlMatcherFactory.defaultSquashPolicy("nosquash");
|
||||
|
||||
$urlMatcherFactory.strictMode(true);
|
||||
var isStrictMode = $urlMatcherFactory.strictMode();
|
||||
|
||||
$urlMatcherFactory.type("myType2", {
|
||||
encode: function (item: any) { return item; },
|
||||
decode: function (item: any) { return item; },
|
||||
is: function (item: any) { return true; }
|
||||
});
|
||||
|
||||
$urlMatcherFactory.type("fullType", {
|
||||
decode: (val) => parseInt(val, 10),
|
||||
encode: (val) => val && val.toString(),
|
||||
equals: (a, b) => this.is(a) && a === b,
|
||||
is: (val) => angular.isNumber(val) && isFinite(val) && val % 1 === 0,
|
||||
pattern: /\d+/
|
||||
});
|
||||
|
||||
var obj: Object = matcher.exec('/user/bob', { x:'1', q:'hello' });
|
||||
var concat: ng.ui.IUrlMatcher = matcher.concat('/test');
|
||||
var str: string = matcher.format({ id:'bob', q:'yes' });
|
||||
@@ -177,3 +193,35 @@ module UiViewScrollProviderTests {
|
||||
$uiViewScrollProvider.useAnchorScroll();
|
||||
}]);
|
||||
}
|
||||
|
||||
interface ITestUserService {
|
||||
isLoggedIn: () => boolean;
|
||||
handleLogin: () => ng.IPromise<{}>;
|
||||
}
|
||||
|
||||
module UrlRouterProviderTests {
|
||||
var app = angular.module("urlRouterProviderTests", ["ui.router"]);
|
||||
|
||||
app.config(($urlRouterProvider: ng.ui.IUrlRouterProvider) => {
|
||||
// Prevent $urlRouter from automatically intercepting URL changes;
|
||||
// this allows you to configure custom behavior in between
|
||||
// location changes and route synchronization:
|
||||
$urlRouterProvider.deferIntercept();
|
||||
}).run(($rootScope: ng.IRootScopeService, $urlRouter: ng.ui.IUrlRouterService, UserService: ITestUserService) => {
|
||||
$rootScope.$on('$locationChangeSuccess', e => {
|
||||
// UserService is an example service for managing user state
|
||||
if (UserService.isLoggedIn()) return;
|
||||
|
||||
// Prevent $urlRouter's default handler from firing
|
||||
e.preventDefault();
|
||||
|
||||
UserService.handleLogin().then(() => {
|
||||
// Once the user has logged in, sync the current URL to the router:
|
||||
$urlRouter.sync();
|
||||
});
|
||||
});
|
||||
|
||||
// Configures $urlRouter's listener *after* your custom listener
|
||||
$urlRouter.listen();
|
||||
});
|
||||
}
|
||||
|
||||
+113
-3
@@ -91,12 +91,70 @@ declare module angular.ui {
|
||||
}
|
||||
|
||||
interface IUrlMatcherFactory {
|
||||
/**
|
||||
* Creates a UrlMatcher for the specified pattern.
|
||||
*
|
||||
* @param pattern {string} The URL pattern.
|
||||
*
|
||||
* @returns {IUrlMatcher} The UrlMatcher.
|
||||
*/
|
||||
compile(pattern: string): IUrlMatcher;
|
||||
/**
|
||||
* Returns true if the specified object is a UrlMatcher, or false otherwise.
|
||||
*
|
||||
* @param o {any} The object to perform the type check against.
|
||||
*
|
||||
* @returns {boolean} Returns true if the object matches the IUrlMatcher interface, by implementing all the same methods.
|
||||
*/
|
||||
isMatcher(o: any): boolean;
|
||||
type(name: string, definition: any, definitionFn?: any): any;
|
||||
caseInsensitive(value: boolean): void;
|
||||
/**
|
||||
* Returns a type definition for the specified name
|
||||
*
|
||||
* @param name {string} The type definition name
|
||||
*
|
||||
* @returns {IType} The type definition
|
||||
*/
|
||||
type(name: string): IType;
|
||||
/**
|
||||
* Registers a custom Type object that can be used to generate URLs with typed parameters.
|
||||
*
|
||||
* @param {IType} definition The type definition.
|
||||
* @param {any[]} inlineAnnotedDefinitionFn A function that is injected before the app runtime starts. The result of this function is merged into the existing definition.
|
||||
*
|
||||
* @returns {IUrlMatcherFactory} Returns $urlMatcherFactoryProvider.
|
||||
*/
|
||||
type(name: string, definition: IType, inlineAnnotedDefinitionFn?: any[]): IUrlMatcherFactory;
|
||||
/**
|
||||
* Registers a custom Type object that can be used to generate URLs with typed parameters.
|
||||
*
|
||||
* @param {IType} definition The type definition.
|
||||
* @param {any[]} inlineAnnotedDefinitionFn A function that is injected before the app runtime starts. The result of this function is merged into the existing definition.
|
||||
*
|
||||
* @returns {IUrlMatcherFactory} Returns $urlMatcherFactoryProvider.
|
||||
*/
|
||||
type(name: string, definition: IType, definitionFn?: (...args:any[]) => IType): IUrlMatcherFactory;
|
||||
/**
|
||||
* Defines whether URL matching should be case sensitive (the default behavior), or not.
|
||||
*
|
||||
* @param value {boolean} false to match URL in a case sensitive manner; otherwise true;
|
||||
*
|
||||
* @returns {boolean} the current value of caseInsensitive
|
||||
*/
|
||||
caseInsensitive(value?: boolean): boolean;
|
||||
/**
|
||||
* Sets the default behavior when generating or matching URLs with default parameter values
|
||||
*
|
||||
* @param value {string} A string that defines the default parameter URL squashing behavior. nosquash: When generating an href with a default parameter value, do not squash the parameter value from the URL slash: When generating an href with a default parameter value, squash (remove) the parameter value, and, if the parameter is surrounded by slashes, squash (remove) one slash from the URL any other string, e.g. "~": When generating an href with a default parameter value, squash (remove) the parameter value from the URL and replace it with this string.
|
||||
*/
|
||||
defaultSquashPolicy(value: string): void;
|
||||
strictMode(value: boolean): void;
|
||||
/**
|
||||
* Defines whether URLs should match trailing slashes, or not (the default behavior).
|
||||
*
|
||||
* @param value {boolean} false to match trailing slashes in URLs, otherwise true.
|
||||
*
|
||||
* @returns {boolean} the current value of strictMode
|
||||
*/
|
||||
strictMode(value?: boolean): boolean;
|
||||
}
|
||||
|
||||
interface IUrlRouterProvider extends angular.IServiceProvider {
|
||||
@@ -114,6 +172,14 @@ declare module angular.ui {
|
||||
otherwise(path: string): IUrlRouterProvider;
|
||||
rule(handler: Function): IUrlRouterProvider;
|
||||
rule(handler: any[]): IUrlRouterProvider;
|
||||
/**
|
||||
* Disables (or enables) deferring location change interception.
|
||||
*
|
||||
* If you wish to customize the behavior of syncing the URL (for example, if you wish to defer a transition but maintain the current URL), call this method at configuration time. Then, at run time, call $urlRouter.listen() after you have configured your own $locationChangeSuccess event handler.
|
||||
*
|
||||
* @param {boolean} defer Indicates whether to defer location change interception. Passing no parameter is equivalent to true.
|
||||
*/
|
||||
deferIntercept(defer?: boolean): void;
|
||||
}
|
||||
|
||||
interface IStateOptions {
|
||||
@@ -203,6 +269,7 @@ declare module angular.ui {
|
||||
*
|
||||
*/
|
||||
sync(): void;
|
||||
listen(): void;
|
||||
}
|
||||
|
||||
interface IUiViewScrollProvider {
|
||||
@@ -212,4 +279,47 @@ declare module angular.ui {
|
||||
*/
|
||||
useAnchorScroll(): void;
|
||||
}
|
||||
|
||||
interface IType {
|
||||
/**
|
||||
* Converts a parameter value (from URL string or transition param) to a custom/native value.
|
||||
*
|
||||
* @param val {string} The URL parameter value to decode.
|
||||
* @param key {string} The name of the parameter in which val is stored. Can be used for meta-programming of Type objects.
|
||||
*
|
||||
* @returns {any} Returns a custom representation of the URL parameter value.
|
||||
*/
|
||||
decode(val: string, key: string): any;
|
||||
/**
|
||||
* Encodes a custom/native type value to a string that can be embedded in a URL. Note that the return value does not need to be URL-safe (i.e. passed through encodeURIComponent()), it only needs to be a representation of val that has been coerced to a string.
|
||||
*
|
||||
* @param val {any} The value to encode.
|
||||
* @param key {string} The name of the parameter in which val is stored. Can be used for meta-programming of Type objects.
|
||||
*
|
||||
* @returns {string} Returns a string representation of val that can be encoded in a URL.
|
||||
*/
|
||||
encode(val: any, key: string): string;
|
||||
/**
|
||||
* Determines whether two decoded values are equivalent.
|
||||
*
|
||||
* @param a {any} A value to compare against.
|
||||
* @param b {any} A value to compare against.
|
||||
*
|
||||
* @returns {boolean} Returns true if the values are equivalent/equal, otherwise false.
|
||||
*/
|
||||
equals? (a: any, b: any): boolean;
|
||||
/**
|
||||
* Detects whether a value is of a particular type. Accepts a native (decoded) value and determines whether it matches the current Type object.
|
||||
*
|
||||
* @param val {any} The value to check.
|
||||
* @param key {any} Optional. If the type check is happening in the context of a specific UrlMatcher object, this is the name of the parameter in which val is stored. Can be used for meta-programming of Type objects.
|
||||
*
|
||||
* @returns {boolean} Returns true if the value matches the type, otherwise false.
|
||||
*/
|
||||
is(val: any, key: string): boolean;
|
||||
/**
|
||||
* The regular expression pattern used to match values of this type when coming from a substring of a URL.
|
||||
*/
|
||||
pattern?: RegExp;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
/// <reference path="angular-ui-scroll.d.ts" />
|
||||
var myApp = angular.module('application', ['ui.scroll', 'ui.scroll.jqlite']);
|
||||
|
||||
module application {
|
||||
interface IItem {
|
||||
id: number;
|
||||
content: string;
|
||||
}
|
||||
|
||||
class DatasourceTest implements ng.ui.IScrollDatasource<IItem> {
|
||||
get(index: number, count: number, success: (results: IItem[]) => void): void {
|
||||
var ret = new Array<IItem>();
|
||||
for (var i=0; i < count; i++) {
|
||||
ret.push({id: i, content: 'item ' + i.toString()});
|
||||
}
|
||||
success(ret);
|
||||
}
|
||||
}
|
||||
|
||||
function factory(): any {
|
||||
return DatasourceTest;
|
||||
}
|
||||
|
||||
myApp.factory('DatasourceTest', factory);
|
||||
|
||||
// demo/examples/adapter
|
||||
myApp.controller('mainController', ['$scope', 'DatasourceTest', function($scope: ng.IScope, datasource: DatasourceTest) {
|
||||
var firstListAdapter: ng.ui.IScrollAdapter, secondListAdapter: ng.ui.IScrollAdapter;
|
||||
$scope['datasource'] = datasource;
|
||||
|
||||
$scope['updateList1'] = (): void => {
|
||||
firstListAdapter.applyUpdates( (item: IItem, scope: ng.IRepeatScope) => {
|
||||
return item.content += ' *';
|
||||
})
|
||||
};
|
||||
|
||||
$scope['removeFromList1'] = (): void => {
|
||||
firstListAdapter.applyUpdates( (item: IItem, scope: ng.IRepeatScope) => {
|
||||
if (scope.$index % 2 === 0) {
|
||||
return []
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
var idList1: number = 1000;
|
||||
$scope['addToList1'] = (): void => {
|
||||
firstListAdapter.applyUpdates((item: IItem, scope: ng.IRepeatScope) => {
|
||||
var newItem: IItem;
|
||||
newItem = void 0;
|
||||
if (scope.$index === 2) {
|
||||
newItem = {
|
||||
id: idList1,
|
||||
content: 'a new one #' + idList1
|
||||
};
|
||||
idList1++;
|
||||
return [item, newItem];
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$scope['updateList2'] = (): void => {
|
||||
secondListAdapter.applyUpdates((item: IItem, scope: ng.IRepeatScope) => {
|
||||
return item.content += ' *';
|
||||
});
|
||||
};
|
||||
|
||||
$scope['removeFromList2'] = (): void => {
|
||||
secondListAdapter.applyUpdates((item: IItem, scope: ng.IRepeatScope) => {
|
||||
if (scope.$index % 2 !== 0) {
|
||||
return [];
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
var idList2: number = 2000;
|
||||
$scope['addToList2'] = (): void => {
|
||||
secondListAdapter.applyUpdates((item: IItem, scope: ng.IRepeatScope) => {
|
||||
var newItem: IItem;
|
||||
newItem = void 0;
|
||||
if (scope.$index === 4) {
|
||||
newItem = {
|
||||
id: idList2,
|
||||
content: 'a new one #' + idList1
|
||||
};
|
||||
idList2++;
|
||||
return [item, newItem];
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
}]);
|
||||
}
|
||||
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
// Type definitions for Angular JS 1.3.1+ (ui.scroll module)
|
||||
// Project: https://github.com/angular-ui/ui-scroll
|
||||
// Definitions by: Mark Nadig <https://github.com/marknadig>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../angularjs/angular.d.ts" />
|
||||
|
||||
declare module angular.ui {
|
||||
interface IScrollDatasource<T> {
|
||||
/**
|
||||
* The datasource object implements methods and properties to be used by the directive to access the data
|
||||
*
|
||||
* @param index indicates the first data row requested
|
||||
*
|
||||
* @param count indicates number of data rows requested
|
||||
*
|
||||
* @param success function to call when the data are retrieved. The implementation of the service has to call
|
||||
* this function when the data are retrieved and pass it an array of the items retrieved. If no items are
|
||||
* retrieved, an empty array has to be passed.
|
||||
*
|
||||
* Important: Make sure to respect the index and count parameters of the request. The array passed to the
|
||||
* success method should have exactly count elements unless it hit eof/bof
|
||||
*/
|
||||
get(index: number, count: number, success: (results: Array<T>) => any): void;
|
||||
}
|
||||
|
||||
interface IScrollAdapter {
|
||||
/**
|
||||
* a boolean value indicating whether there are any pending load requests.
|
||||
*/
|
||||
isLoading: boolean;
|
||||
/**
|
||||
* a reference to the item currently in the topmost visible position.
|
||||
*/
|
||||
topVisible: any;
|
||||
/**
|
||||
* a reference to the DOM element currently in the topmost visible position.
|
||||
*/
|
||||
topVisibleElement: ng.IAugmentedJQueryStatic;
|
||||
/**
|
||||
* a reference to the scope created for the item currently in the topmost visible position.
|
||||
*/
|
||||
topVisibleScope: ng.IRepeatScope;
|
||||
/**
|
||||
* calling this method reinitializes and reloads the scroller content.
|
||||
*/
|
||||
reload(): void;
|
||||
/**
|
||||
* Replaces the item in the buffer at the given index with the new items.
|
||||
*
|
||||
* @param index provides position of the item to be affected in the dataset (not in the buffer). If the item with
|
||||
* the given index currently is not in the buffer no updates will be applied. $index property of the item $scope
|
||||
* can be used to access the index value for a given item
|
||||
*
|
||||
* @param newItems is an array of items to replace the affected item. If the array is empty ([]) the item will
|
||||
* be deleted, otherwise the items in the array replace the item. If the newItem array contains the old item,
|
||||
* the old item stays in place.
|
||||
*/
|
||||
applyUpdates(index: number, newItems: any[]): void;
|
||||
/**
|
||||
* Replaces the item in the buffer at the given index with the new items.
|
||||
*
|
||||
* @param updater is a function to be applied to every item currently in the buffer. The function will receive
|
||||
* 3 parameters: item, scope, and element. Here item is the item to be affected, scope is the item $scope, and
|
||||
* element is the html element for the item. The return value of the function should be an array of items.
|
||||
* Similarly to the newItem parameter (see above), if the array is empty([]), the item is deleted, otherwise
|
||||
* the item is replaced by the items in the array. If the return value is not an array, the item remains
|
||||
* unaffected, unless some updates were made to the item in the updater function. This can be thought of as
|
||||
* in place update.
|
||||
*/
|
||||
applyUpdates(updater: (item: any, scope: ng.IRepeatScope) => any): void;
|
||||
/**
|
||||
* Adds new items after the last item in the buffer
|
||||
*
|
||||
* @param newItems provides an array of items to be appended.
|
||||
*/
|
||||
append(newItems: any[]): void;
|
||||
/**
|
||||
* Adds new items before the first item in the buffer
|
||||
*
|
||||
* @param newItems provides an array of items to be prepended.
|
||||
*/
|
||||
prepend(newItems: any[]): void;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
/// <reference path="angular-ui-tree.d.ts" />
|
||||
|
||||
var treeNode: AngularUITree.ITreeNode = {
|
||||
id: 0,
|
||||
nodes: [],
|
||||
title: "test"
|
||||
};
|
||||
|
||||
var treeNode2: AngularUITree.ITreeNode = {
|
||||
id: "0",
|
||||
nodes: [treeNode],
|
||||
title: "test2"
|
||||
};
|
||||
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
// Type definitions for angular-ui-tree v2.8.0
|
||||
// Project: https://github.com/angular-ui-tree/angular-ui-tree
|
||||
// Definitions by: Calvin Fernandez <https://github.com/CalvinFernandez>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
declare module AngularUITree {
|
||||
/**
|
||||
* Node in list
|
||||
*/
|
||||
interface ITreeNode {
|
||||
id: number | string;
|
||||
nodes: ITreeNode[];
|
||||
title: string;
|
||||
}
|
||||
}
|
||||
+5775
File diff suppressed because it is too large
Load Diff
+5920
File diff suppressed because it is too large
Load Diff
Vendored
+1103
-1747
File diff suppressed because it is too large
Load Diff
Vendored
+689
@@ -0,0 +1,689 @@
|
||||
// Type definitions for Angular v2.0.0-alpha.35
|
||||
// Project: http://angular.io/
|
||||
// Definitions by: angular team <https://github.com/angular/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
// ***********************************************************
|
||||
// This file is generated by the Angular build process.
|
||||
// Please do not create manual edits or send pull requests
|
||||
// modifying this file.
|
||||
// ***********************************************************
|
||||
|
||||
// angular2/router depends transitively on these libraries.
|
||||
// If you don't have them installed you can install them using TSD
|
||||
// https://github.com/DefinitelyTyped/tsd
|
||||
|
||||
///<reference path="./angular2.d.ts"/>
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @module
|
||||
* @description
|
||||
* Maps application URLs into application states, to support deep-linking and navigation.
|
||||
*/
|
||||
declare module ngRouter {
|
||||
|
||||
/**
|
||||
* # Router
|
||||
* The router is responsible for mapping URLs to components.
|
||||
*
|
||||
* You can see the state of the router by inspecting the read-only field `router.navigating`.
|
||||
* This may be useful for showing a spinner, for instance.
|
||||
*
|
||||
* ## Concepts
|
||||
* Routers and component instances have a 1:1 correspondence.
|
||||
*
|
||||
* The router holds reference to a number of "outlets." An outlet is a placeholder that the
|
||||
* router dynamically fills in depending on the current URL.
|
||||
*
|
||||
* When the router navigates from a URL, it must first recognizes it and serialize it into an
|
||||
* `Instruction`.
|
||||
* The router uses the `RouteRegistry` to get an `Instruction`.
|
||||
*/
|
||||
class Router {
|
||||
|
||||
navigating: boolean;
|
||||
|
||||
lastNavigationAttempt: string;
|
||||
|
||||
registry: RouteRegistry;
|
||||
|
||||
parent: Router;
|
||||
|
||||
hostComponent: any;
|
||||
|
||||
|
||||
/**
|
||||
* Constructs a child router. You probably don't need to use this unless you're writing a reusable
|
||||
* component.
|
||||
*/
|
||||
childRouter(hostComponent: any): Router;
|
||||
|
||||
|
||||
/**
|
||||
* Register an object to notify of route changes. You probably don't need to use this unless
|
||||
* you're writing a reusable component.
|
||||
*/
|
||||
registerOutlet(outlet: RouterOutlet): Promise<boolean>;
|
||||
|
||||
|
||||
/**
|
||||
* Dynamically update the routing configuration and trigger a navigation.
|
||||
*
|
||||
* # Usage
|
||||
*
|
||||
* ```
|
||||
* router.config([
|
||||
* { 'path': '/', 'component': IndexComp },
|
||||
* { 'path': '/user/:id', 'component': UserComp },
|
||||
* ]);
|
||||
* ```
|
||||
*/
|
||||
config(definitions: List<RouteDefinition>): Promise<any>;
|
||||
|
||||
|
||||
/**
|
||||
* Navigate to a URL. Returns a promise that resolves when navigation is complete.
|
||||
*
|
||||
* If the given URL begins with a `/`, router will navigate absolutely.
|
||||
* If the given URL does not begin with `/`, the router will navigate relative to this component.
|
||||
*/
|
||||
navigate(url: string, _skipLocationChange?: boolean): Promise<any>;
|
||||
|
||||
|
||||
/**
|
||||
* Navigate via the provided instruction. Returns a promise that resolves when navigation is
|
||||
* complete.
|
||||
*/
|
||||
navigateInstruction(instruction: Instruction, _skipLocationChange?: boolean): Promise<any>;
|
||||
|
||||
|
||||
/**
|
||||
* Updates this router and all descendant routers according to the given instruction
|
||||
*/
|
||||
commit(instruction: Instruction, _skipLocationChange?: boolean): Promise<any>;
|
||||
|
||||
|
||||
/**
|
||||
* Subscribe to URL updates from the router
|
||||
*/
|
||||
subscribe(onNext: (value: any) => void): void;
|
||||
|
||||
|
||||
/**
|
||||
* Removes the contents of this router's outlet and all descendant outlets
|
||||
*/
|
||||
deactivate(instruction: Instruction): Promise<any>;
|
||||
|
||||
|
||||
/**
|
||||
* Given a URL, returns an instruction representing the component graph
|
||||
*/
|
||||
recognize(url: string): Promise<Instruction>;
|
||||
|
||||
|
||||
/**
|
||||
* Navigates to either the last URL successfully navigated to, or the last URL requested if the
|
||||
* router has yet to successfully navigate.
|
||||
*/
|
||||
renavigate(): Promise<any>;
|
||||
|
||||
|
||||
/**
|
||||
* Generate a URL from a component name and optional map of parameters. The URL is relative to the
|
||||
* app's base href.
|
||||
*/
|
||||
generate(linkParams: List<any>): Instruction;
|
||||
}
|
||||
|
||||
class RootRouter extends Router {
|
||||
|
||||
commit(instruction: Instruction, _skipLocationChange?: boolean): Promise<any>;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* A router outlet is a placeholder that Angular dynamically fills based on the application's route.
|
||||
*
|
||||
* ## Use
|
||||
*
|
||||
* ```
|
||||
* <router-outlet></router-outlet>
|
||||
* ```
|
||||
*/
|
||||
class RouterOutlet {
|
||||
|
||||
childRouter: Router;
|
||||
|
||||
name: string;
|
||||
|
||||
|
||||
/**
|
||||
* Given an instruction, update the contents of this outlet.
|
||||
*/
|
||||
commit(instruction: Instruction): Promise<any>;
|
||||
|
||||
|
||||
/**
|
||||
* Called by Router during recognition phase
|
||||
*/
|
||||
canDeactivate(nextInstruction: Instruction): Promise<boolean>;
|
||||
|
||||
|
||||
/**
|
||||
* Called by Router during recognition phase
|
||||
*/
|
||||
canReuse(nextInstruction: Instruction): Promise<boolean>;
|
||||
|
||||
deactivate(nextInstruction: Instruction): Promise<any>;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The RouterLink directive lets you link to specific parts of your app.
|
||||
*
|
||||
* Consider the following route configuration:
|
||||
*
|
||||
* ```
|
||||
* @RouteConfig([
|
||||
* { path: '/user', component: UserCmp, as: 'user' }
|
||||
* ]);
|
||||
* class MyComp {}
|
||||
* ```
|
||||
*
|
||||
* When linking to this `user` route, you can write:
|
||||
*
|
||||
* ```
|
||||
* <a [router-link]="['./user']">link to user component</a>
|
||||
* ```
|
||||
*
|
||||
* RouterLink expects the value to be an array of route names, followed by the params
|
||||
* for that level of routing. For instance `['/team', {teamId: 1}, 'user', {userId: 2}]`
|
||||
* means that we want to generate a link for the `team` route with params `{teamId: 1}`,
|
||||
* and with a child route `user` with params `{userId: 2}`.
|
||||
*
|
||||
* The first route name should be prepended with `/`, `./`, or `../`.
|
||||
* If the route begins with `/`, the router will look up the route from the root of the app.
|
||||
* If the route begins with `./`, the router will instead look in the current component's
|
||||
* children for the route. And if the route begins with `../`, the router will look at the
|
||||
* current component's parent.
|
||||
*/
|
||||
class RouterLink {
|
||||
|
||||
visibleHref: string;
|
||||
|
||||
routeParams: void;
|
||||
|
||||
onClick(): boolean;
|
||||
}
|
||||
|
||||
class RouteParams {
|
||||
|
||||
params: StringMap<string, string>;
|
||||
|
||||
get(param: string): string;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The RouteRegistry holds route configurations for each component in an Angular app.
|
||||
* It is responsible for creating Instructions from URLs, and generating URLs based on route and
|
||||
* parameters.
|
||||
*/
|
||||
class RouteRegistry {
|
||||
|
||||
|
||||
/**
|
||||
* Given a component and a configuration object, add the route to this registry
|
||||
*/
|
||||
config(parentComponent: any, config: RouteDefinition): void;
|
||||
|
||||
|
||||
/**
|
||||
* Reads the annotations of a component and configures the registry based on them
|
||||
*/
|
||||
configFromComponent(component: any): void;
|
||||
|
||||
|
||||
/**
|
||||
* Given a URL and a parent component, return the most specific instruction for navigating
|
||||
* the application into the state specified by the url
|
||||
*/
|
||||
recognize(url: string, parentComponent: any): Promise<Instruction>;
|
||||
|
||||
|
||||
/**
|
||||
* Given a normalized list with component names and params like: `['user', {id: 3 }]`
|
||||
* generates a url with a leading slash relative to the provided `parentComponent`.
|
||||
*/
|
||||
generate(linkParams: List<any>, parentComponent: any): Instruction;
|
||||
}
|
||||
|
||||
class LocationStrategy {
|
||||
|
||||
path(): string;
|
||||
|
||||
pushState(ctx: any, title: string, url: string): void;
|
||||
|
||||
forward(): void;
|
||||
|
||||
back(): void;
|
||||
|
||||
onPopState(fn: (_: any) => any): void;
|
||||
|
||||
getBaseHref(): string;
|
||||
}
|
||||
|
||||
class HashLocationStrategy extends LocationStrategy {
|
||||
|
||||
onPopState(fn: EventListener): void;
|
||||
|
||||
getBaseHref(): string;
|
||||
|
||||
path(): string;
|
||||
|
||||
pushState(state: any, title: string, url: string): void;
|
||||
|
||||
forward(): void;
|
||||
|
||||
back(): void;
|
||||
}
|
||||
|
||||
class HTML5LocationStrategy extends LocationStrategy {
|
||||
|
||||
onPopState(fn: EventListener): void;
|
||||
|
||||
getBaseHref(): string;
|
||||
|
||||
path(): string;
|
||||
|
||||
pushState(state: any, title: string, url: string): void;
|
||||
|
||||
forward(): void;
|
||||
|
||||
back(): void;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This is the service that an application developer will directly interact with.
|
||||
*
|
||||
* Responsible for normalizing the URL against the application's base href.
|
||||
* A normalized URL is absolute from the URL host, includes the application's base href, and has no
|
||||
* trailing slash:
|
||||
* - `/my/app/user/123` is normalized
|
||||
* - `my/app/user/123` **is not** normalized
|
||||
* - `/my/app/user/123/` **is not** normalized
|
||||
*/
|
||||
class Location {
|
||||
|
||||
path(): string;
|
||||
|
||||
normalize(url: string): string;
|
||||
|
||||
normalizeAbsolutely(url: string): string;
|
||||
|
||||
go(url: string): void;
|
||||
|
||||
forward(): void;
|
||||
|
||||
back(): void;
|
||||
|
||||
subscribe(onNext: (value: any) => void, onThrow?: (exception: any) => void, onReturn?: () => void): void;
|
||||
}
|
||||
|
||||
const APP_BASE_HREF : OpaqueToken ;
|
||||
|
||||
|
||||
/**
|
||||
* Responsible for performing each step of navigation.
|
||||
* "Steps" are conceptually similar to "middleware"
|
||||
*/
|
||||
class Pipeline {
|
||||
|
||||
steps: List<Function>;
|
||||
|
||||
process(instruction: Instruction): Promise<any>;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Defines route lifecycle method [onActivate], which is called by the router at the end of a
|
||||
* successful route navigation.
|
||||
*
|
||||
* For a single component's navigation, only one of either [onActivate] or [onReuse] will be called,
|
||||
* depending on the result of [canReuse].
|
||||
*
|
||||
* If `onActivate` returns a promise, the route change will wait until the promise settles to
|
||||
* instantiate and activate child components.
|
||||
*
|
||||
* ## Example
|
||||
* ```
|
||||
* @Directive({
|
||||
* selector: 'my-cmp'
|
||||
* })
|
||||
* class MyCmp implements OnActivate {
|
||||
* onActivate(next, prev) {
|
||||
* this.log = 'Finished navigating from ' + prev.urlPath + ' to ' + next.urlPath;
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
interface OnActivate {
|
||||
|
||||
onActivate(nextInstruction: ComponentInstruction, prevInstruction: ComponentInstruction): any;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Defines route lifecycle method [onDeactivate], which is called by the router before destroying
|
||||
* a component as part of a route change.
|
||||
*
|
||||
* If `onDeactivate` returns a promise, the route change will wait until the promise settles.
|
||||
*
|
||||
* ## Example
|
||||
* ```
|
||||
* @Directive({
|
||||
* selector: 'my-cmp'
|
||||
* })
|
||||
* class MyCmp implements CanReuse, OnReuse {
|
||||
* canReuse() {
|
||||
* return true;
|
||||
* }
|
||||
*
|
||||
* onReuse(next, prev) {
|
||||
* this.params = next.params;
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
interface OnDeactivate {
|
||||
|
||||
onDeactivate(nextInstruction: ComponentInstruction, prevInstruction: ComponentInstruction): any;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Defines route lifecycle method [onReuse], which is called by the router at the end of a
|
||||
* successful route navigation when [canReuse] is implemented and returns or resolves to true.
|
||||
*
|
||||
* For a single component's navigation, only one of either [onActivate] or [onReuse] will be called,
|
||||
* depending on the result of [canReuse].
|
||||
*
|
||||
* ## Example
|
||||
* ```
|
||||
* @Directive({
|
||||
* selector: 'my-cmp'
|
||||
* })
|
||||
* class MyCmp implements CanReuse, OnReuse {
|
||||
* canReuse() {
|
||||
* return true;
|
||||
* }
|
||||
*
|
||||
* onReuse(next, prev) {
|
||||
* this.params = next.params;
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
interface OnReuse {
|
||||
|
||||
onReuse(nextInstruction: ComponentInstruction, prevInstruction: ComponentInstruction): any;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Defines route lifecycle method [canDeactivate], which is called by the router to determine
|
||||
* if a component can be removed as part of a navigation.
|
||||
*
|
||||
* If `canDeactivate` returns or resolves to `false`, the navigation is cancelled.
|
||||
*
|
||||
* If `canDeactivate` throws or rejects, the navigation is also cancelled.
|
||||
*
|
||||
* ## Example
|
||||
* ```
|
||||
* @Directive({
|
||||
* selector: 'my-cmp'
|
||||
* })
|
||||
* class MyCmp implements CanDeactivate {
|
||||
* canDeactivate(next, prev) {
|
||||
* return askUserIfTheyAreSureTheyWantToQuit();
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
interface CanDeactivate {
|
||||
|
||||
canDeactivate(nextInstruction: ComponentInstruction, prevInstruction: ComponentInstruction): any;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Defines route lifecycle method [canReuse], which is called by the router to determine whether a
|
||||
* component should be reused across routes, or whether to destroy and instantiate a new component.
|
||||
*
|
||||
* If `canReuse` returns or resolves to `true`, the component instance will be reused.
|
||||
*
|
||||
* If `canReuse` throws or rejects, the navigation will be cancelled.
|
||||
*
|
||||
* ## Example
|
||||
* ```
|
||||
* @Directive({
|
||||
* selector: 'my-cmp'
|
||||
* })
|
||||
* class MyCmp implements CanReuse, OnReuse {
|
||||
* canReuse(next, prev) {
|
||||
* return next.params.id == prev.params.id;
|
||||
* }
|
||||
*
|
||||
* onReuse(next, prev) {
|
||||
* this.id = next.params.id;
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
interface CanReuse {
|
||||
|
||||
canReuse(nextInstruction: ComponentInstruction, prevInstruction: ComponentInstruction): any;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Defines route lifecycle method [canActivate], which is called by the router to determine
|
||||
* if a component can be instantiated as part of a navigation.
|
||||
*
|
||||
* Note that unlike other lifecycle hooks, this one uses an annotation rather than an interface.
|
||||
* This is because [canActivate] is called before the component is instantiated.
|
||||
*
|
||||
* If `canActivate` returns or resolves to `false`, the navigation is cancelled.
|
||||
*
|
||||
* If `canActivate` throws or rejects, the navigation is also cancelled.
|
||||
*
|
||||
* ## Example
|
||||
* ```
|
||||
* @Directive({
|
||||
* selector: 'control-panel-cmp'
|
||||
* })
|
||||
* @CanActivate(() => checkIfUserIsLoggedIn())
|
||||
* class ControlPanelCmp {
|
||||
* // ...
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
var CanActivate : (hook: (next: ComponentInstruction, prev: ComponentInstruction) => Promise<boolean>| boolean) =>
|
||||
ClassDecorator ;
|
||||
|
||||
|
||||
/**
|
||||
* `Instruction` is a tree of `ComponentInstructions`, with all the information needed
|
||||
* to transition each component in the app to a given route, including all auxiliary routes.
|
||||
*
|
||||
* This is a public API.
|
||||
*/
|
||||
class Instruction {
|
||||
|
||||
component: ComponentInstruction;
|
||||
|
||||
child: Instruction;
|
||||
|
||||
auxInstruction: StringMap<string, Instruction>;
|
||||
|
||||
replaceChild(child: Instruction): Instruction;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* A `ComponentInstruction` represents the route state for a single component. An `Instruction` is
|
||||
* composed of a tree of these `ComponentInstruction`s.
|
||||
*
|
||||
* `ComponentInstructions` is a public API. Instances of `ComponentInstruction` are passed
|
||||
* to route lifecycle hooks, like {@link CanActivate}.
|
||||
*/
|
||||
class ComponentInstruction {
|
||||
|
||||
reuse: boolean;
|
||||
|
||||
urlPath: string;
|
||||
|
||||
urlParams: List<string>;
|
||||
|
||||
params: StringMap<string, any>;
|
||||
|
||||
componentType: void;
|
||||
|
||||
resolveComponentType(): Promise<Type>;
|
||||
|
||||
specificity: void;
|
||||
|
||||
terminal: void;
|
||||
|
||||
routeData(): Object;
|
||||
}
|
||||
|
||||
class Url {
|
||||
|
||||
path: string;
|
||||
|
||||
child: Url;
|
||||
|
||||
auxiliary: List<Url>;
|
||||
|
||||
params: StringMap<string, any>;
|
||||
|
||||
toString(): string;
|
||||
|
||||
segmentToString(): string;
|
||||
}
|
||||
|
||||
class OpaqueToken {
|
||||
|
||||
toString(): string;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Runtime representation of a type.
|
||||
*
|
||||
* In JavaScript a Type is a constructor function.
|
||||
*/
|
||||
interface Type extends Function {
|
||||
|
||||
new(args: any): any;
|
||||
|
||||
}
|
||||
|
||||
const routerDirectives : List<any> ;
|
||||
|
||||
var routerInjectables : List<any> ;
|
||||
|
||||
class Route implements RouteDefinition {
|
||||
|
||||
data: any;
|
||||
|
||||
path: string;
|
||||
|
||||
component: Type;
|
||||
|
||||
as: string;
|
||||
|
||||
loader: Function;
|
||||
|
||||
redirectTo: string;
|
||||
}
|
||||
|
||||
class Redirect implements RouteDefinition {
|
||||
|
||||
path: string;
|
||||
|
||||
redirectTo: string;
|
||||
|
||||
as: string;
|
||||
|
||||
loader: Function;
|
||||
|
||||
data: any;
|
||||
}
|
||||
|
||||
class AuxRoute implements RouteDefinition {
|
||||
|
||||
data: any;
|
||||
|
||||
path: string;
|
||||
|
||||
component: Type;
|
||||
|
||||
as: string;
|
||||
|
||||
loader: Function;
|
||||
|
||||
redirectTo: string;
|
||||
}
|
||||
|
||||
class AsyncRoute implements RouteDefinition {
|
||||
|
||||
data: any;
|
||||
|
||||
path: string;
|
||||
|
||||
loader: Function;
|
||||
|
||||
as: string;
|
||||
}
|
||||
|
||||
interface RouteDefinition {
|
||||
|
||||
path: string;
|
||||
|
||||
component?: Type | ComponentDefinition;
|
||||
|
||||
loader?: Function;
|
||||
|
||||
redirectTo?: string;
|
||||
|
||||
as?: string;
|
||||
|
||||
data?: any;
|
||||
}
|
||||
|
||||
const ROUTE_DATA : OpaqueToken ;
|
||||
|
||||
var RouteConfig : (configs: List<RouteDefinition>) => ClassDecorator ;
|
||||
|
||||
interface ComponentDefinition {
|
||||
|
||||
type: string;
|
||||
|
||||
loader?: Function;
|
||||
|
||||
component?: Type;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
declare module "angular2/router" {
|
||||
export = ngRouter;
|
||||
}
|
||||
|
||||
|
||||
Vendored
+689
@@ -0,0 +1,689 @@
|
||||
// Type definitions for Angular v2.0.0-alpha.36
|
||||
// Project: http://angular.io/
|
||||
// Definitions by: angular team <https://github.com/angular/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
// ***********************************************************
|
||||
// This file is generated by the Angular build process.
|
||||
// Please do not create manual edits or send pull requests
|
||||
// modifying this file.
|
||||
// ***********************************************************
|
||||
|
||||
// angular2/router depends transitively on these libraries.
|
||||
// If you don't have them installed you can install them using TSD
|
||||
// https://github.com/DefinitelyTyped/tsd
|
||||
|
||||
///<reference path="./angular2.d.ts"/>
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @module
|
||||
* @description
|
||||
* Maps application URLs into application states, to support deep-linking and navigation.
|
||||
*/
|
||||
declare module ngRouter {
|
||||
|
||||
/**
|
||||
* # Router
|
||||
* The router is responsible for mapping URLs to components.
|
||||
*
|
||||
* You can see the state of the router by inspecting the read-only field `router.navigating`.
|
||||
* This may be useful for showing a spinner, for instance.
|
||||
*
|
||||
* ## Concepts
|
||||
* Routers and component instances have a 1:1 correspondence.
|
||||
*
|
||||
* The router holds reference to a number of "outlets." An outlet is a placeholder that the
|
||||
* router dynamically fills in depending on the current URL.
|
||||
*
|
||||
* When the router navigates from a URL, it must first recognizes it and serialize it into an
|
||||
* `Instruction`.
|
||||
* The router uses the `RouteRegistry` to get an `Instruction`.
|
||||
*/
|
||||
class Router {
|
||||
|
||||
navigating: boolean;
|
||||
|
||||
lastNavigationAttempt: string;
|
||||
|
||||
registry: RouteRegistry;
|
||||
|
||||
parent: Router;
|
||||
|
||||
hostComponent: any;
|
||||
|
||||
|
||||
/**
|
||||
* Constructs a child router. You probably don't need to use this unless you're writing a reusable
|
||||
* component.
|
||||
*/
|
||||
childRouter(hostComponent: any): Router;
|
||||
|
||||
|
||||
/**
|
||||
* Register an object to notify of route changes. You probably don't need to use this unless
|
||||
* you're writing a reusable component.
|
||||
*/
|
||||
registerOutlet(outlet: RouterOutlet): Promise<boolean>;
|
||||
|
||||
|
||||
/**
|
||||
* Dynamically update the routing configuration and trigger a navigation.
|
||||
*
|
||||
* # Usage
|
||||
*
|
||||
* ```
|
||||
* router.config([
|
||||
* { 'path': '/', 'component': IndexComp },
|
||||
* { 'path': '/user/:id', 'component': UserComp },
|
||||
* ]);
|
||||
* ```
|
||||
*/
|
||||
config(definitions: List<RouteDefinition>): Promise<any>;
|
||||
|
||||
|
||||
/**
|
||||
* Navigate to a URL. Returns a promise that resolves when navigation is complete.
|
||||
*
|
||||
* If the given URL begins with a `/`, router will navigate absolutely.
|
||||
* If the given URL does not begin with `/`, the router will navigate relative to this component.
|
||||
*/
|
||||
navigate(url: string, _skipLocationChange?: boolean): Promise<any>;
|
||||
|
||||
|
||||
/**
|
||||
* Navigate via the provided instruction. Returns a promise that resolves when navigation is
|
||||
* complete.
|
||||
*/
|
||||
navigateInstruction(instruction: Instruction, _skipLocationChange?: boolean): Promise<any>;
|
||||
|
||||
|
||||
/**
|
||||
* Updates this router and all descendant routers according to the given instruction
|
||||
*/
|
||||
commit(instruction: Instruction, _skipLocationChange?: boolean): Promise<any>;
|
||||
|
||||
|
||||
/**
|
||||
* Subscribe to URL updates from the router
|
||||
*/
|
||||
subscribe(onNext: (value: any) => void): Object;
|
||||
|
||||
|
||||
/**
|
||||
* Removes the contents of this router's outlet and all descendant outlets
|
||||
*/
|
||||
deactivate(instruction: Instruction): Promise<any>;
|
||||
|
||||
|
||||
/**
|
||||
* Given a URL, returns an instruction representing the component graph
|
||||
*/
|
||||
recognize(url: string): Promise<Instruction>;
|
||||
|
||||
|
||||
/**
|
||||
* Navigates to either the last URL successfully navigated to, or the last URL requested if the
|
||||
* router has yet to successfully navigate.
|
||||
*/
|
||||
renavigate(): Promise<any>;
|
||||
|
||||
|
||||
/**
|
||||
* Generate a URL from a component name and optional map of parameters. The URL is relative to the
|
||||
* app's base href.
|
||||
*/
|
||||
generate(linkParams: List<any>): Instruction;
|
||||
}
|
||||
|
||||
class RootRouter extends Router {
|
||||
|
||||
commit(instruction: Instruction, _skipLocationChange?: boolean): Promise<any>;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* A router outlet is a placeholder that Angular dynamically fills based on the application's route.
|
||||
*
|
||||
* ## Use
|
||||
*
|
||||
* ```
|
||||
* <router-outlet></router-outlet>
|
||||
* ```
|
||||
*/
|
||||
class RouterOutlet {
|
||||
|
||||
childRouter: Router;
|
||||
|
||||
name: string;
|
||||
|
||||
|
||||
/**
|
||||
* Given an instruction, update the contents of this outlet.
|
||||
*/
|
||||
commit(instruction: Instruction): Promise<any>;
|
||||
|
||||
|
||||
/**
|
||||
* Called by Router during recognition phase
|
||||
*/
|
||||
canDeactivate(nextInstruction: Instruction): Promise<boolean>;
|
||||
|
||||
|
||||
/**
|
||||
* Called by Router during recognition phase
|
||||
*/
|
||||
canReuse(nextInstruction: Instruction): Promise<boolean>;
|
||||
|
||||
deactivate(nextInstruction: Instruction): Promise<any>;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The RouterLink directive lets you link to specific parts of your app.
|
||||
*
|
||||
* Consider the following route configuration:
|
||||
*
|
||||
* ```
|
||||
* @RouteConfig([
|
||||
* { path: '/user', component: UserCmp, as: 'user' }
|
||||
* ]);
|
||||
* class MyComp {}
|
||||
* ```
|
||||
*
|
||||
* When linking to this `user` route, you can write:
|
||||
*
|
||||
* ```
|
||||
* <a [router-link]="['./user']">link to user component</a>
|
||||
* ```
|
||||
*
|
||||
* RouterLink expects the value to be an array of route names, followed by the params
|
||||
* for that level of routing. For instance `['/team', {teamId: 1}, 'user', {userId: 2}]`
|
||||
* means that we want to generate a link for the `team` route with params `{teamId: 1}`,
|
||||
* and with a child route `user` with params `{userId: 2}`.
|
||||
*
|
||||
* The first route name should be prepended with `/`, `./`, or `../`.
|
||||
* If the route begins with `/`, the router will look up the route from the root of the app.
|
||||
* If the route begins with `./`, the router will instead look in the current component's
|
||||
* children for the route. And if the route begins with `../`, the router will look at the
|
||||
* current component's parent.
|
||||
*/
|
||||
class RouterLink {
|
||||
|
||||
visibleHref: string;
|
||||
|
||||
routeParams: any;
|
||||
|
||||
onClick(): boolean;
|
||||
}
|
||||
|
||||
class RouteParams {
|
||||
|
||||
params: StringMap<string, string>;
|
||||
|
||||
get(param: string): string;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The RouteRegistry holds route configurations for each component in an Angular app.
|
||||
* It is responsible for creating Instructions from URLs, and generating URLs based on route and
|
||||
* parameters.
|
||||
*/
|
||||
class RouteRegistry {
|
||||
|
||||
|
||||
/**
|
||||
* Given a component and a configuration object, add the route to this registry
|
||||
*/
|
||||
config(parentComponent: any, config: RouteDefinition): void;
|
||||
|
||||
|
||||
/**
|
||||
* Reads the annotations of a component and configures the registry based on them
|
||||
*/
|
||||
configFromComponent(component: any): void;
|
||||
|
||||
|
||||
/**
|
||||
* Given a URL and a parent component, return the most specific instruction for navigating
|
||||
* the application into the state specified by the url
|
||||
*/
|
||||
recognize(url: string, parentComponent: any): Promise<Instruction>;
|
||||
|
||||
|
||||
/**
|
||||
* Given a normalized list with component names and params like: `['user', {id: 3 }]`
|
||||
* generates a url with a leading slash relative to the provided `parentComponent`.
|
||||
*/
|
||||
generate(linkParams: List<any>, parentComponent: any): Instruction;
|
||||
}
|
||||
|
||||
class LocationStrategy {
|
||||
|
||||
path(): string;
|
||||
|
||||
pushState(ctx: any, title: string, url: string): void;
|
||||
|
||||
forward(): void;
|
||||
|
||||
back(): void;
|
||||
|
||||
onPopState(fn: (_: any) => any): void;
|
||||
|
||||
getBaseHref(): string;
|
||||
}
|
||||
|
||||
class HashLocationStrategy extends LocationStrategy {
|
||||
|
||||
onPopState(fn: EventListener): void;
|
||||
|
||||
getBaseHref(): string;
|
||||
|
||||
path(): string;
|
||||
|
||||
pushState(state: any, title: string, url: string): void;
|
||||
|
||||
forward(): void;
|
||||
|
||||
back(): void;
|
||||
}
|
||||
|
||||
class PathLocationStrategy extends LocationStrategy {
|
||||
|
||||
onPopState(fn: EventListener): void;
|
||||
|
||||
getBaseHref(): string;
|
||||
|
||||
path(): string;
|
||||
|
||||
pushState(state: any, title: string, url: string): void;
|
||||
|
||||
forward(): void;
|
||||
|
||||
back(): void;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This is the service that an application developer will directly interact with.
|
||||
*
|
||||
* Responsible for normalizing the URL against the application's base href.
|
||||
* A normalized URL is absolute from the URL host, includes the application's base href, and has no
|
||||
* trailing slash:
|
||||
* - `/my/app/user/123` is normalized
|
||||
* - `my/app/user/123` **is not** normalized
|
||||
* - `/my/app/user/123/` **is not** normalized
|
||||
*/
|
||||
class Location {
|
||||
|
||||
path(): string;
|
||||
|
||||
normalize(url: string): string;
|
||||
|
||||
normalizeAbsolutely(url: string): string;
|
||||
|
||||
go(url: string): void;
|
||||
|
||||
forward(): void;
|
||||
|
||||
back(): void;
|
||||
|
||||
subscribe(onNext: (value: any) => void, onThrow?: (exception: any) => void, onReturn?: () => void): void;
|
||||
}
|
||||
|
||||
const APP_BASE_HREF : OpaqueToken ;
|
||||
|
||||
|
||||
/**
|
||||
* Responsible for performing each step of navigation.
|
||||
* "Steps" are conceptually similar to "middleware"
|
||||
*/
|
||||
class Pipeline {
|
||||
|
||||
steps: List<Function>;
|
||||
|
||||
process(instruction: Instruction): Promise<any>;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Defines route lifecycle method [onActivate], which is called by the router at the end of a
|
||||
* successful route navigation.
|
||||
*
|
||||
* For a single component's navigation, only one of either [onActivate] or [onReuse] will be called,
|
||||
* depending on the result of [canReuse].
|
||||
*
|
||||
* If `onActivate` returns a promise, the route change will wait until the promise settles to
|
||||
* instantiate and activate child components.
|
||||
*
|
||||
* ## Example
|
||||
* ```
|
||||
* @Directive({
|
||||
* selector: 'my-cmp'
|
||||
* })
|
||||
* class MyCmp implements OnActivate {
|
||||
* onActivate(next, prev) {
|
||||
* this.log = 'Finished navigating from ' + prev.urlPath + ' to ' + next.urlPath;
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
interface OnActivate {
|
||||
|
||||
onActivate(nextInstruction: ComponentInstruction, prevInstruction: ComponentInstruction): any;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Defines route lifecycle method [onDeactivate], which is called by the router before destroying
|
||||
* a component as part of a route change.
|
||||
*
|
||||
* If `onDeactivate` returns a promise, the route change will wait until the promise settles.
|
||||
*
|
||||
* ## Example
|
||||
* ```
|
||||
* @Directive({
|
||||
* selector: 'my-cmp'
|
||||
* })
|
||||
* class MyCmp implements CanReuse, OnReuse {
|
||||
* canReuse() {
|
||||
* return true;
|
||||
* }
|
||||
*
|
||||
* onReuse(next, prev) {
|
||||
* this.params = next.params;
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
interface OnDeactivate {
|
||||
|
||||
onDeactivate(nextInstruction: ComponentInstruction, prevInstruction: ComponentInstruction): any;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Defines route lifecycle method [onReuse], which is called by the router at the end of a
|
||||
* successful route navigation when [canReuse] is implemented and returns or resolves to true.
|
||||
*
|
||||
* For a single component's navigation, only one of either [onActivate] or [onReuse] will be called,
|
||||
* depending on the result of [canReuse].
|
||||
*
|
||||
* ## Example
|
||||
* ```
|
||||
* @Directive({
|
||||
* selector: 'my-cmp'
|
||||
* })
|
||||
* class MyCmp implements CanReuse, OnReuse {
|
||||
* canReuse() {
|
||||
* return true;
|
||||
* }
|
||||
*
|
||||
* onReuse(next, prev) {
|
||||
* this.params = next.params;
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
interface OnReuse {
|
||||
|
||||
onReuse(nextInstruction: ComponentInstruction, prevInstruction: ComponentInstruction): any;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Defines route lifecycle method [canDeactivate], which is called by the router to determine
|
||||
* if a component can be removed as part of a navigation.
|
||||
*
|
||||
* If `canDeactivate` returns or resolves to `false`, the navigation is cancelled.
|
||||
*
|
||||
* If `canDeactivate` throws or rejects, the navigation is also cancelled.
|
||||
*
|
||||
* ## Example
|
||||
* ```
|
||||
* @Directive({
|
||||
* selector: 'my-cmp'
|
||||
* })
|
||||
* class MyCmp implements CanDeactivate {
|
||||
* canDeactivate(next, prev) {
|
||||
* return askUserIfTheyAreSureTheyWantToQuit();
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
interface CanDeactivate {
|
||||
|
||||
canDeactivate(nextInstruction: ComponentInstruction, prevInstruction: ComponentInstruction): any;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Defines route lifecycle method [canReuse], which is called by the router to determine whether a
|
||||
* component should be reused across routes, or whether to destroy and instantiate a new component.
|
||||
*
|
||||
* If `canReuse` returns or resolves to `true`, the component instance will be reused.
|
||||
*
|
||||
* If `canReuse` throws or rejects, the navigation will be cancelled.
|
||||
*
|
||||
* ## Example
|
||||
* ```
|
||||
* @Directive({
|
||||
* selector: 'my-cmp'
|
||||
* })
|
||||
* class MyCmp implements CanReuse, OnReuse {
|
||||
* canReuse(next, prev) {
|
||||
* return next.params.id == prev.params.id;
|
||||
* }
|
||||
*
|
||||
* onReuse(next, prev) {
|
||||
* this.id = next.params.id;
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
interface CanReuse {
|
||||
|
||||
canReuse(nextInstruction: ComponentInstruction, prevInstruction: ComponentInstruction): any;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Defines route lifecycle method [canActivate], which is called by the router to determine
|
||||
* if a component can be instantiated as part of a navigation.
|
||||
*
|
||||
* Note that unlike other lifecycle hooks, this one uses an annotation rather than an interface.
|
||||
* This is because [canActivate] is called before the component is instantiated.
|
||||
*
|
||||
* If `canActivate` returns or resolves to `false`, the navigation is cancelled.
|
||||
*
|
||||
* If `canActivate` throws or rejects, the navigation is also cancelled.
|
||||
*
|
||||
* ## Example
|
||||
* ```
|
||||
* @Directive({
|
||||
* selector: 'control-panel-cmp'
|
||||
* })
|
||||
* @CanActivate(() => checkIfUserIsLoggedIn())
|
||||
* class ControlPanelCmp {
|
||||
* // ...
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
var CanActivate : (hook: (next: ComponentInstruction, prev: ComponentInstruction) => Promise<boolean>| boolean) =>
|
||||
ClassDecorator ;
|
||||
|
||||
|
||||
/**
|
||||
* `Instruction` is a tree of `ComponentInstructions`, with all the information needed
|
||||
* to transition each component in the app to a given route, including all auxiliary routes.
|
||||
*
|
||||
* This is a public API.
|
||||
*/
|
||||
class Instruction {
|
||||
|
||||
component: ComponentInstruction;
|
||||
|
||||
child: Instruction;
|
||||
|
||||
auxInstruction: StringMap<string, Instruction>;
|
||||
|
||||
replaceChild(child: Instruction): Instruction;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* A `ComponentInstruction` represents the route state for a single component. An `Instruction` is
|
||||
* composed of a tree of these `ComponentInstruction`s.
|
||||
*
|
||||
* `ComponentInstructions` is a public API. Instances of `ComponentInstruction` are passed
|
||||
* to route lifecycle hooks, like {@link CanActivate}.
|
||||
*/
|
||||
class ComponentInstruction {
|
||||
|
||||
reuse: boolean;
|
||||
|
||||
urlPath: string;
|
||||
|
||||
urlParams: List<string>;
|
||||
|
||||
params: StringMap<string, any>;
|
||||
|
||||
componentType: any;
|
||||
|
||||
resolveComponentType(): Promise<Type>;
|
||||
|
||||
specificity: any;
|
||||
|
||||
terminal: any;
|
||||
|
||||
routeData(): Object;
|
||||
}
|
||||
|
||||
class Url {
|
||||
|
||||
path: string;
|
||||
|
||||
child: Url;
|
||||
|
||||
auxiliary: List<Url>;
|
||||
|
||||
params: StringMap<string, any>;
|
||||
|
||||
toString(): string;
|
||||
|
||||
segmentToString(): string;
|
||||
}
|
||||
|
||||
class OpaqueToken {
|
||||
|
||||
toString(): string;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Runtime representation of a type.
|
||||
*
|
||||
* In JavaScript a Type is a constructor function.
|
||||
*/
|
||||
interface Type extends Function {
|
||||
|
||||
new(args: any): any;
|
||||
|
||||
}
|
||||
|
||||
const ROUTE_DATA : OpaqueToken ;
|
||||
|
||||
const ROUTER_DIRECTIVES : List<any> ;
|
||||
|
||||
const ROUTER_BINDINGS : List<any> ;
|
||||
|
||||
class Route implements RouteDefinition {
|
||||
|
||||
data: any;
|
||||
|
||||
path: string;
|
||||
|
||||
component: Type;
|
||||
|
||||
as: string;
|
||||
|
||||
loader: Function;
|
||||
|
||||
redirectTo: string;
|
||||
}
|
||||
|
||||
class Redirect implements RouteDefinition {
|
||||
|
||||
path: string;
|
||||
|
||||
redirectTo: string;
|
||||
|
||||
as: string;
|
||||
|
||||
loader: Function;
|
||||
|
||||
data: any;
|
||||
}
|
||||
|
||||
class AuxRoute implements RouteDefinition {
|
||||
|
||||
data: any;
|
||||
|
||||
path: string;
|
||||
|
||||
component: Type;
|
||||
|
||||
as: string;
|
||||
|
||||
loader: Function;
|
||||
|
||||
redirectTo: string;
|
||||
}
|
||||
|
||||
class AsyncRoute implements RouteDefinition {
|
||||
|
||||
data: any;
|
||||
|
||||
path: string;
|
||||
|
||||
loader: Function;
|
||||
|
||||
as: string;
|
||||
}
|
||||
|
||||
interface RouteDefinition {
|
||||
|
||||
path: string;
|
||||
|
||||
component?: Type | ComponentDefinition;
|
||||
|
||||
loader?: Function;
|
||||
|
||||
redirectTo?: string;
|
||||
|
||||
as?: string;
|
||||
|
||||
data?: any;
|
||||
}
|
||||
|
||||
var RouteConfig : (configs: List<RouteDefinition>) => ClassDecorator ;
|
||||
|
||||
interface ComponentDefinition {
|
||||
|
||||
type: string;
|
||||
|
||||
loader?: Function;
|
||||
|
||||
component?: Type;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
declare module "angular2/router" {
|
||||
export = ngRouter;
|
||||
}
|
||||
|
||||
|
||||
Vendored
+256
-36
@@ -1,4 +1,4 @@
|
||||
// Type definitions for Angular v2.0.0-alpha.34
|
||||
// Type definitions for Angular v2.0.0-alpha.36
|
||||
// Project: http://angular.io/
|
||||
// Definitions by: angular team <https://github.com/angular/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
@@ -8,16 +8,22 @@
|
||||
// Please do not create manual edits or send pull requests
|
||||
// modifying this file.
|
||||
// ***********************************************************
|
||||
|
||||
// angular2/router depends transitively on these libraries.
|
||||
// If you don't have them installed you can install them using TSD
|
||||
// https://github.com/DefinitelyTyped/tsd
|
||||
|
||||
///<reference path="./angular2.d.ts"/>
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @module
|
||||
* @description
|
||||
* Maps application URLs into application states, to support deep-linking and navigation.
|
||||
*/
|
||||
declare module ng {
|
||||
declare module ngRouter {
|
||||
|
||||
/**
|
||||
* # Router
|
||||
@@ -87,6 +93,13 @@ declare module ng {
|
||||
navigate(url: string, _skipLocationChange?: boolean): Promise<any>;
|
||||
|
||||
|
||||
/**
|
||||
* Navigate via the provided instruction. Returns a promise that resolves when navigation is
|
||||
* complete.
|
||||
*/
|
||||
navigateInstruction(instruction: Instruction, _skipLocationChange?: boolean): Promise<any>;
|
||||
|
||||
|
||||
/**
|
||||
* Updates this router and all descendant routers according to the given instruction
|
||||
*/
|
||||
@@ -96,7 +109,7 @@ declare module ng {
|
||||
/**
|
||||
* Subscribe to URL updates from the router
|
||||
*/
|
||||
subscribe(onNext: (value: any) => void): void;
|
||||
subscribe(onNext: (value: any) => void): Object;
|
||||
|
||||
|
||||
/**
|
||||
@@ -122,7 +135,7 @@ declare module ng {
|
||||
* Generate a URL from a component name and optional map of parameters. The URL is relative to the
|
||||
* app's base href.
|
||||
*/
|
||||
generate(linkParams: List<any>): string;
|
||||
generate(linkParams: List<any>): Instruction;
|
||||
}
|
||||
|
||||
class RootRouter extends Router {
|
||||
@@ -144,6 +157,8 @@ declare module ng {
|
||||
|
||||
childRouter: Router;
|
||||
|
||||
name: string;
|
||||
|
||||
|
||||
/**
|
||||
* Given an instruction, update the contents of this outlet.
|
||||
@@ -199,7 +214,7 @@ declare module ng {
|
||||
|
||||
visibleHref: string;
|
||||
|
||||
routeParams: void;
|
||||
routeParams: any;
|
||||
|
||||
onClick(): boolean;
|
||||
}
|
||||
@@ -223,13 +238,13 @@ declare module ng {
|
||||
/**
|
||||
* Given a component and a configuration object, add the route to this registry
|
||||
*/
|
||||
config(parentComponent: any, config: RouteDefinition, isRootLevelRoute?: boolean): void;
|
||||
config(parentComponent: any, config: RouteDefinition): void;
|
||||
|
||||
|
||||
/**
|
||||
* Reads the annotations of a component and configures the registry based on them
|
||||
*/
|
||||
configFromComponent(component: any, isRootComponent?: boolean): void;
|
||||
configFromComponent(component: any): void;
|
||||
|
||||
|
||||
/**
|
||||
@@ -243,7 +258,7 @@ declare module ng {
|
||||
* Given a normalized list with component names and params like: `['user', {id: 3 }]`
|
||||
* generates a url with a leading slash relative to the provided `parentComponent`.
|
||||
*/
|
||||
generate(linkParams: List<any>, parentComponent: any): string;
|
||||
generate(linkParams: List<any>, parentComponent: any): Instruction;
|
||||
}
|
||||
|
||||
class LocationStrategy {
|
||||
@@ -276,7 +291,7 @@ declare module ng {
|
||||
back(): void;
|
||||
}
|
||||
|
||||
class HTML5LocationStrategy extends LocationStrategy {
|
||||
class PathLocationStrategy extends LocationStrategy {
|
||||
|
||||
onPopState(fn: EventListener): void;
|
||||
|
||||
@@ -319,7 +334,7 @@ declare module ng {
|
||||
subscribe(onNext: (value: any) => void, onThrow?: (exception: any) => void, onReturn?: () => void): void;
|
||||
}
|
||||
|
||||
const appBaseHrefToken : OpaqueToken ;
|
||||
const APP_BASE_HREF : OpaqueToken ;
|
||||
|
||||
|
||||
/**
|
||||
@@ -335,78 +350,260 @@ declare module ng {
|
||||
|
||||
|
||||
/**
|
||||
* Defines route lifecycle method [onActivate]
|
||||
* Defines route lifecycle method [onActivate], which is called by the router at the end of a
|
||||
* successful route navigation.
|
||||
*
|
||||
* For a single component's navigation, only one of either [onActivate] or [onReuse] will be called,
|
||||
* depending on the result of [canReuse].
|
||||
*
|
||||
* If `onActivate` returns a promise, the route change will wait until the promise settles to
|
||||
* instantiate and activate child components.
|
||||
*
|
||||
* ## Example
|
||||
* ```
|
||||
* @Directive({
|
||||
* selector: 'my-cmp'
|
||||
* })
|
||||
* class MyCmp implements OnActivate {
|
||||
* onActivate(next, prev) {
|
||||
* this.log = 'Finished navigating from ' + prev.urlPath + ' to ' + next.urlPath;
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
interface OnActivate {
|
||||
|
||||
onActivate(nextInstruction: Instruction, prevInstruction: Instruction): any;
|
||||
onActivate(nextInstruction: ComponentInstruction, prevInstruction: ComponentInstruction): any;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Defines route lifecycle method [onDeactivate]
|
||||
* Defines route lifecycle method [onDeactivate], which is called by the router before destroying
|
||||
* a component as part of a route change.
|
||||
*
|
||||
* If `onDeactivate` returns a promise, the route change will wait until the promise settles.
|
||||
*
|
||||
* ## Example
|
||||
* ```
|
||||
* @Directive({
|
||||
* selector: 'my-cmp'
|
||||
* })
|
||||
* class MyCmp implements CanReuse, OnReuse {
|
||||
* canReuse() {
|
||||
* return true;
|
||||
* }
|
||||
*
|
||||
* onReuse(next, prev) {
|
||||
* this.params = next.params;
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
interface OnDeactivate {
|
||||
|
||||
onDeactivate(nextInstruction: Instruction, prevInstruction: Instruction): any;
|
||||
onDeactivate(nextInstruction: ComponentInstruction, prevInstruction: ComponentInstruction): any;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Defines route lifecycle method [onReuse]
|
||||
* Defines route lifecycle method [onReuse], which is called by the router at the end of a
|
||||
* successful route navigation when [canReuse] is implemented and returns or resolves to true.
|
||||
*
|
||||
* For a single component's navigation, only one of either [onActivate] or [onReuse] will be called,
|
||||
* depending on the result of [canReuse].
|
||||
*
|
||||
* ## Example
|
||||
* ```
|
||||
* @Directive({
|
||||
* selector: 'my-cmp'
|
||||
* })
|
||||
* class MyCmp implements CanReuse, OnReuse {
|
||||
* canReuse() {
|
||||
* return true;
|
||||
* }
|
||||
*
|
||||
* onReuse(next, prev) {
|
||||
* this.params = next.params;
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
interface OnReuse {
|
||||
|
||||
onReuse(nextInstruction: Instruction, prevInstruction: Instruction): any;
|
||||
onReuse(nextInstruction: ComponentInstruction, prevInstruction: ComponentInstruction): any;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Defines route lifecycle method [canDeactivate]
|
||||
* Defines route lifecycle method [canDeactivate], which is called by the router to determine
|
||||
* if a component can be removed as part of a navigation.
|
||||
*
|
||||
* If `canDeactivate` returns or resolves to `false`, the navigation is cancelled.
|
||||
*
|
||||
* If `canDeactivate` throws or rejects, the navigation is also cancelled.
|
||||
*
|
||||
* ## Example
|
||||
* ```
|
||||
* @Directive({
|
||||
* selector: 'my-cmp'
|
||||
* })
|
||||
* class MyCmp implements CanDeactivate {
|
||||
* canDeactivate(next, prev) {
|
||||
* return askUserIfTheyAreSureTheyWantToQuit();
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
interface CanDeactivate {
|
||||
|
||||
canDeactivate(nextInstruction: Instruction, prevInstruction: Instruction): any;
|
||||
canDeactivate(nextInstruction: ComponentInstruction, prevInstruction: ComponentInstruction): any;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Defines route lifecycle method [canReuse]
|
||||
* Defines route lifecycle method [canReuse], which is called by the router to determine whether a
|
||||
* component should be reused across routes, or whether to destroy and instantiate a new component.
|
||||
*
|
||||
* If `canReuse` returns or resolves to `true`, the component instance will be reused.
|
||||
*
|
||||
* If `canReuse` throws or rejects, the navigation will be cancelled.
|
||||
*
|
||||
* ## Example
|
||||
* ```
|
||||
* @Directive({
|
||||
* selector: 'my-cmp'
|
||||
* })
|
||||
* class MyCmp implements CanReuse, OnReuse {
|
||||
* canReuse(next, prev) {
|
||||
* return next.params.id == prev.params.id;
|
||||
* }
|
||||
*
|
||||
* onReuse(next, prev) {
|
||||
* this.id = next.params.id;
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
interface CanReuse {
|
||||
|
||||
canReuse(nextInstruction: Instruction, prevInstruction: Instruction): any;
|
||||
canReuse(nextInstruction: ComponentInstruction, prevInstruction: ComponentInstruction): any;
|
||||
}
|
||||
|
||||
var CanActivate : (hook: (next: Instruction, prev: Instruction) => Promise<boolean>| boolean) => ClassDecorator ;
|
||||
|
||||
|
||||
/**
|
||||
* An `Instruction` represents the component hierarchy of the application based on a given route
|
||||
* Defines route lifecycle method [canActivate], which is called by the router to determine
|
||||
* if a component can be instantiated as part of a navigation.
|
||||
*
|
||||
* Note that unlike other lifecycle hooks, this one uses an annotation rather than an interface.
|
||||
* This is because [canActivate] is called before the component is instantiated.
|
||||
*
|
||||
* If `canActivate` returns or resolves to `false`, the navigation is cancelled.
|
||||
*
|
||||
* If `canActivate` throws or rejects, the navigation is also cancelled.
|
||||
*
|
||||
* ## Example
|
||||
* ```
|
||||
* @Directive({
|
||||
* selector: 'control-panel-cmp'
|
||||
* })
|
||||
* @CanActivate(() => checkIfUserIsLoggedIn())
|
||||
* class ControlPanelCmp {
|
||||
* // ...
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
var CanActivate : (hook: (next: ComponentInstruction, prev: ComponentInstruction) => Promise<boolean>| boolean) =>
|
||||
ClassDecorator ;
|
||||
|
||||
|
||||
/**
|
||||
* `Instruction` is a tree of `ComponentInstructions`, with all the information needed
|
||||
* to transition each component in the app to a given route, including all auxiliary routes.
|
||||
*
|
||||
* This is a public API.
|
||||
*/
|
||||
class Instruction {
|
||||
|
||||
accumulatedUrl: string;
|
||||
|
||||
reuse: boolean;
|
||||
|
||||
specificity: number;
|
||||
|
||||
component: any;
|
||||
|
||||
capturedUrl: string;
|
||||
component: ComponentInstruction;
|
||||
|
||||
child: Instruction;
|
||||
|
||||
params(): StringMap<string, string>;
|
||||
auxInstruction: StringMap<string, Instruction>;
|
||||
|
||||
replaceChild(child: Instruction): Instruction;
|
||||
}
|
||||
|
||||
const routerDirectives : List<any> ;
|
||||
|
||||
/**
|
||||
* A `ComponentInstruction` represents the route state for a single component. An `Instruction` is
|
||||
* composed of a tree of these `ComponentInstruction`s.
|
||||
*
|
||||
* `ComponentInstructions` is a public API. Instances of `ComponentInstruction` are passed
|
||||
* to route lifecycle hooks, like {@link CanActivate}.
|
||||
*/
|
||||
class ComponentInstruction {
|
||||
|
||||
reuse: boolean;
|
||||
|
||||
urlPath: string;
|
||||
|
||||
urlParams: List<string>;
|
||||
|
||||
params: StringMap<string, any>;
|
||||
|
||||
componentType: any;
|
||||
|
||||
resolveComponentType(): Promise<Type>;
|
||||
|
||||
specificity: any;
|
||||
|
||||
terminal: any;
|
||||
|
||||
routeData(): Object;
|
||||
}
|
||||
|
||||
var routerInjectables : List<any> ;
|
||||
class Url {
|
||||
|
||||
path: string;
|
||||
|
||||
child: Url;
|
||||
|
||||
auxiliary: List<Url>;
|
||||
|
||||
params: StringMap<string, any>;
|
||||
|
||||
toString(): string;
|
||||
|
||||
segmentToString(): string;
|
||||
}
|
||||
|
||||
class OpaqueToken {
|
||||
|
||||
toString(): string;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Runtime representation of a type.
|
||||
*
|
||||
* In JavaScript a Type is a constructor function.
|
||||
*/
|
||||
interface Type extends Function {
|
||||
|
||||
new(args: any): any;
|
||||
|
||||
}
|
||||
|
||||
const ROUTE_DATA : OpaqueToken ;
|
||||
|
||||
const ROUTER_DIRECTIVES : List<any> ;
|
||||
|
||||
const ROUTER_BINDINGS : List<any> ;
|
||||
|
||||
class Route implements RouteDefinition {
|
||||
|
||||
data: any;
|
||||
|
||||
path: string;
|
||||
|
||||
component: Type;
|
||||
@@ -425,10 +622,31 @@ declare module ng {
|
||||
redirectTo: string;
|
||||
|
||||
as: string;
|
||||
|
||||
loader: Function;
|
||||
|
||||
data: any;
|
||||
}
|
||||
|
||||
class AuxRoute implements RouteDefinition {
|
||||
|
||||
data: any;
|
||||
|
||||
path: string;
|
||||
|
||||
component: Type;
|
||||
|
||||
as: string;
|
||||
|
||||
loader: Function;
|
||||
|
||||
redirectTo: string;
|
||||
}
|
||||
|
||||
class AsyncRoute implements RouteDefinition {
|
||||
|
||||
data: any;
|
||||
|
||||
path: string;
|
||||
|
||||
loader: Function;
|
||||
@@ -447,6 +665,8 @@ declare module ng {
|
||||
redirectTo?: string;
|
||||
|
||||
as?: string;
|
||||
|
||||
data?: any;
|
||||
}
|
||||
|
||||
var RouteConfig : (configs: List<RouteDefinition>) => ClassDecorator ;
|
||||
@@ -463,7 +683,7 @@ declare module ng {
|
||||
}
|
||||
|
||||
declare module "angular2/router" {
|
||||
export = ng;
|
||||
export = ngRouter;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -126,18 +126,35 @@ requestHandler = httpBackendService.expect('GET', /test.local/, function (data:
|
||||
requestHandler = httpBackendService.expect('GET', /test.local/, { key: 'value' });
|
||||
requestHandler = httpBackendService.expect('GET', /test.local/, { key: 'value' }, { header: 'value' });
|
||||
requestHandler = httpBackendService.expect('GET', /test.local/, { key: 'value' }, function (headers: Object): boolean { return true; });
|
||||
requestHandler = httpBackendService.expect('GET', (url: string) => { return true; });
|
||||
requestHandler = httpBackendService.expect('GET', (url: string) => { return true; }, 'response data');
|
||||
requestHandler = httpBackendService.expect('GET', (url: string) => { return true; }, 'response data', { header: 'value' });
|
||||
requestHandler = httpBackendService.expect('GET', (url: string) => { return true; }, 'response data', function (headers: Object): boolean { return true; });
|
||||
requestHandler = httpBackendService.expect('GET', (url: string) => { return true; }, /response data/);
|
||||
requestHandler = httpBackendService.expect('GET', (url: string) => { return true; }, /response data/, { header: 'value' });
|
||||
requestHandler = httpBackendService.expect('GET', (url: string) => { return true; }, /response data/, function (headers: Object): boolean { return true; });
|
||||
requestHandler = httpBackendService.expect('GET', (url: string) => { return true; }, function (data: string): boolean { return true; });
|
||||
requestHandler = httpBackendService.expect('GET', (url: string) => { return true; }, function (data: string): boolean { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.expect('GET', (url: string) => { return true; }, function (data: string): boolean { return true; }, function (headers: Object): boolean { return true; });
|
||||
requestHandler = httpBackendService.expect('GET', (url: string) => { return true; }, { key: 'value' });
|
||||
requestHandler = httpBackendService.expect('GET', (url: string) => { return true; }, { key: 'value' }, { header: 'value' });
|
||||
requestHandler = httpBackendService.expect('GET', (url: string) => { return true; }, { key: 'value' }, function (headers: Object): boolean { return true; });
|
||||
|
||||
requestHandler = httpBackendService.expectDELETE('http://test.local');
|
||||
requestHandler = httpBackendService.expectDELETE('http://test.local', { header: 'value' });
|
||||
requestHandler = httpBackendService.expectDELETE(/test.local/, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectDELETE((url: string) => { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectGET('http://test.local');
|
||||
requestHandler = httpBackendService.expectGET('http://test.local', { header: 'value' });
|
||||
requestHandler = httpBackendService.expectGET(/test.local/, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectGET((url: string) => { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectHEAD('http://test.local');
|
||||
requestHandler = httpBackendService.expectHEAD('http://test.local', { header: 'value' });
|
||||
requestHandler = httpBackendService.expectHEAD(/test.local/, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectHEAD((url: string) => { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectJSONP('http://test.local');
|
||||
requestHandler = httpBackendService.expectJSONP(/test.local/);
|
||||
requestHandler = httpBackendService.expectJSONP((url: string) => { return true; });
|
||||
|
||||
requestHandler = httpBackendService.expectPATCH('http://test.local');
|
||||
requestHandler = httpBackendService.expectPATCH('http://test.local', 'response data');
|
||||
@@ -157,6 +174,15 @@ requestHandler = httpBackendService.expectPATCH(/test.local/, function (data: st
|
||||
requestHandler = httpBackendService.expectPATCH(/test.local/, function (data: string): boolean { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPATCH(/test.local/, { key: 'value' });
|
||||
requestHandler = httpBackendService.expectPATCH(/test.local/, { key: 'value' }, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPATCH((url: string) => { return true; });
|
||||
requestHandler = httpBackendService.expectPATCH((url: string) => { return true; }, 'response data');
|
||||
requestHandler = httpBackendService.expectPATCH((url: string) => { return true; }, 'response data', { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPATCH((url: string) => { return true; }, /response data/);
|
||||
requestHandler = httpBackendService.expectPATCH((url: string) => { return true; }, /response data/, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPATCH((url: string) => { return true; }, function (data: string): boolean { return true; });
|
||||
requestHandler = httpBackendService.expectPATCH((url: string) => { return true; }, function (data: string): boolean { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPATCH((url: string) => { return true; }, { key: 'value' });
|
||||
requestHandler = httpBackendService.expectPATCH((url: string) => { return true; }, { key: 'value' }, { header: 'value' });
|
||||
|
||||
requestHandler = httpBackendService.expectPOST('http://test.local');
|
||||
requestHandler = httpBackendService.expectPOST('http://test.local', 'response data');
|
||||
@@ -176,6 +202,15 @@ requestHandler = httpBackendService.expectPOST(/test.local/, function (data: str
|
||||
requestHandler = httpBackendService.expectPOST(/test.local/, function (data: string): boolean { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPOST(/test.local/, { key: 'value' });
|
||||
requestHandler = httpBackendService.expectPOST(/test.local/, { key: 'value' }, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPOST((url: string) => { return true; });
|
||||
requestHandler = httpBackendService.expectPOST((url: string) => { return true; }, 'response data');
|
||||
requestHandler = httpBackendService.expectPOST((url: string) => { return true; }, 'response data', { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPOST((url: string) => { return true; }, /response data/);
|
||||
requestHandler = httpBackendService.expectPOST((url: string) => { return true; }, /response data/, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPOST((url: string) => { return true; }, function (data: string): boolean { return true; });
|
||||
requestHandler = httpBackendService.expectPOST((url: string) => { return true; }, function (data: string): boolean { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPOST((url: string) => { return true; }, { key: 'value' });
|
||||
requestHandler = httpBackendService.expectPOST((url: string) => { return true; }, { key: 'value' }, { header: 'value' });
|
||||
|
||||
requestHandler = httpBackendService.expectPUT('http://test.local');
|
||||
requestHandler = httpBackendService.expectPUT('http://test.local', 'response data');
|
||||
@@ -195,6 +230,15 @@ requestHandler = httpBackendService.expectPUT(/test.local/, function (data: stri
|
||||
requestHandler = httpBackendService.expectPUT(/test.local/, function (data: string): boolean { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPUT(/test.local/, { key: 'value' });
|
||||
requestHandler = httpBackendService.expectPUT(/test.local/, { key: 'value' }, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPUT((url: string) => { return true; });
|
||||
requestHandler = httpBackendService.expectPUT((url: string) => { return true; }, 'response data');
|
||||
requestHandler = httpBackendService.expectPUT((url: string) => { return true; }, 'response data', { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPUT((url: string) => { return true; }, /response data/);
|
||||
requestHandler = httpBackendService.expectPUT((url: string) => { return true; }, /response data/, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPUT((url: string) => { return true; }, function (data: string): boolean { return true; });
|
||||
requestHandler = httpBackendService.expectPUT((url: string) => { return true; }, function (data: string): boolean { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPUT((url: string) => { return true; }, { key: 'value' });
|
||||
requestHandler = httpBackendService.expectPUT((url: string) => { return true; }, { key: 'value' }, { header: 'value' });
|
||||
|
||||
requestHandler = httpBackendService.when('GET', 'http://test.local');
|
||||
requestHandler = httpBackendService.when('GET', 'http://test.local', 'response data');
|
||||
@@ -222,18 +266,35 @@ requestHandler = httpBackendService.when('GET', /test.local/, function (data: st
|
||||
requestHandler = httpBackendService.when('GET', /test.local/, { key: 'value' });
|
||||
requestHandler = httpBackendService.when('GET', /test.local/, { key: 'value' }, { header: 'value' });
|
||||
requestHandler = httpBackendService.when('GET', /test.local/, { key: 'value' }, function (headers: Object): boolean { return true; });
|
||||
requestHandler = httpBackendService.when('GET', (url: string) => { return true; });
|
||||
requestHandler = httpBackendService.when('GET', (url: string) => { return true; }, 'response data');
|
||||
requestHandler = httpBackendService.when('GET', (url: string) => { return true; }, 'response data', { header: 'value' });
|
||||
requestHandler = httpBackendService.when('GET', (url: string) => { return true; }, 'response data', function (headers: Object): boolean { return true; });
|
||||
requestHandler = httpBackendService.when('GET', (url: string) => { return true; }, /response data/);
|
||||
requestHandler = httpBackendService.when('GET', (url: string) => { return true; }, /response data/, { header: 'value' });
|
||||
requestHandler = httpBackendService.when('GET', (url: string) => { return true; }, /response data/, function (headers: Object): boolean { return true; });
|
||||
requestHandler = httpBackendService.when('GET', (url: string) => { return true; }, function (data: string): boolean { return true; });
|
||||
requestHandler = httpBackendService.when('GET', (url: string) => { return true; }, function (data: string): boolean { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.when('GET', (url: string) => { return true; }, function (data: string): boolean { return true; }, function (headers: Object): boolean { return true; });
|
||||
requestHandler = httpBackendService.when('GET', (url: string) => { return true; }, { key: 'value' });
|
||||
requestHandler = httpBackendService.when('GET', (url: string) => { return true; }, { key: 'value' }, { header: 'value' });
|
||||
requestHandler = httpBackendService.when('GET', (url: string) => { return true; }, { key: 'value' }, function (headers: Object): boolean { return true; });
|
||||
|
||||
requestHandler = httpBackendService.whenDELETE('http://test.local');
|
||||
requestHandler = httpBackendService.whenDELETE('http://test.local', { header: 'value' });
|
||||
requestHandler = httpBackendService.whenDELETE(/test.local/, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenDELETE((url: string) => { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenGET('http://test.local');
|
||||
requestHandler = httpBackendService.whenGET('http://test.local', { header: 'value' });
|
||||
requestHandler = httpBackendService.whenGET(/test.local/, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenGET((url: string) => { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenHEAD('http://test.local');
|
||||
requestHandler = httpBackendService.whenHEAD('http://test.local', { header: 'value' });
|
||||
requestHandler = httpBackendService.whenHEAD(/test.local/, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenHEAD((url: string) => { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenJSONP('http://test.local');
|
||||
requestHandler = httpBackendService.whenJSONP(/test.local/);
|
||||
requestHandler = httpBackendService.whenJSONP((url: string) => { return true; });
|
||||
|
||||
requestHandler = httpBackendService.whenPATCH('http://test.local');
|
||||
requestHandler = httpBackendService.whenPATCH('http://test.local', 'response data');
|
||||
@@ -253,6 +314,15 @@ requestHandler = httpBackendService.whenPATCH(/test.local/, function (data: stri
|
||||
requestHandler = httpBackendService.whenPATCH(/test.local/, function (data: string): boolean { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPATCH(/test.local/, { key: 'value' });
|
||||
requestHandler = httpBackendService.whenPATCH(/test.local/, { key: 'value' }, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPATCH((url: string) => { return true; });
|
||||
requestHandler = httpBackendService.whenPATCH((url: string) => { return true; }, 'response data');
|
||||
requestHandler = httpBackendService.whenPATCH((url: string) => { return true; }, 'response data', { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPATCH((url: string) => { return true; }, /response data/);
|
||||
requestHandler = httpBackendService.whenPATCH((url: string) => { return true; }, /response data/, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPATCH((url: string) => { return true; }, function (data: string): boolean { return true; });
|
||||
requestHandler = httpBackendService.whenPATCH((url: string) => { return true; }, function (data: string): boolean { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPATCH((url: string) => { return true; }, { key: 'value' });
|
||||
requestHandler = httpBackendService.whenPATCH((url: string) => { return true; }, { key: 'value' }, { header: 'value' });
|
||||
|
||||
requestHandler = httpBackendService.whenPOST('http://test.local');
|
||||
requestHandler = httpBackendService.whenPOST('http://test.local', 'response data');
|
||||
@@ -272,6 +342,15 @@ requestHandler = httpBackendService.whenPOST(/test.local/, function (data: strin
|
||||
requestHandler = httpBackendService.whenPOST(/test.local/, function (data: string): boolean { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPOST(/test.local/, { key: 'value' });
|
||||
requestHandler = httpBackendService.whenPOST(/test.local/, { key: 'value' }, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPOST((url: string) => { return true; });
|
||||
requestHandler = httpBackendService.whenPOST((url: string) => { return true; }, 'response data');
|
||||
requestHandler = httpBackendService.whenPOST((url: string) => { return true; }, 'response data', { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPOST((url: string) => { return true; }, /response data/);
|
||||
requestHandler = httpBackendService.whenPOST((url: string) => { return true; }, /response data/, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPOST((url: string) => { return true; }, function (data: string): boolean { return true; });
|
||||
requestHandler = httpBackendService.whenPOST((url: string) => { return true; }, function (data: string): boolean { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPOST((url: string) => { return true; }, { key: 'value' });
|
||||
requestHandler = httpBackendService.whenPOST((url: string) => { return true; }, { key: 'value' }, { header: 'value' });
|
||||
|
||||
requestHandler = httpBackendService.whenPUT('http://test.local');
|
||||
requestHandler = httpBackendService.whenPUT('http://test.local', 'response data');
|
||||
@@ -291,15 +370,34 @@ requestHandler = httpBackendService.whenPUT(/test.local/, function (data: string
|
||||
requestHandler = httpBackendService.whenPUT(/test.local/, function (data: string): boolean { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPUT(/test.local/, { key: 'value' });
|
||||
requestHandler = httpBackendService.whenPUT(/test.local/, { key: 'value' }, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPUT((url: string) => { return true; });
|
||||
requestHandler = httpBackendService.whenPUT((url: string) => { return true; }, 'response data');
|
||||
requestHandler = httpBackendService.whenPUT((url: string) => { return true; }, 'response data', { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPUT((url: string) => { return true; }, /response data/);
|
||||
requestHandler = httpBackendService.whenPUT((url: string) => { return true; }, /response data/, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPUT((url: string) => { return true; }, function (data: string): boolean { return true; });
|
||||
requestHandler = httpBackendService.whenPUT((url: string) => { return true; }, function (data: string): boolean { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPUT((url: string) => { return true; }, { key: 'value' });
|
||||
requestHandler = httpBackendService.whenPUT((url: string) => { return true; }, { key: 'value' }, { header: 'value' });
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
// IRequestHandler
|
||||
///////////////////////////////////////
|
||||
var expectedData = { key: 'value'};
|
||||
requestHandler.passThrough();
|
||||
requestHandler.respond(function () { });
|
||||
requestHandler.passThrough().passThrough();
|
||||
requestHandler.respond((method, url, data, headers) => [404, 'data', { header: 'value' }, 'responseText']);
|
||||
requestHandler.respond((method, url, data, headers) => [404, 'data', { header: 'value' }, 'responseText']).respond({});
|
||||
requestHandler.respond((method, url, data, headers) => { return [404, { key: 'value' }, { header: 'value' }, 'responseText']; });
|
||||
requestHandler.respond('data');
|
||||
requestHandler.respond('data').respond({});
|
||||
requestHandler.respond(expectedData);
|
||||
requestHandler.respond({ key: 'value' });
|
||||
requestHandler.respond({ key: 'value' }, { header: 'value' });
|
||||
requestHandler.respond(404);
|
||||
requestHandler.respond({ key: 'value' }, { header: 'value' }, 'responseText');
|
||||
requestHandler.respond(404, 'data');
|
||||
requestHandler.respond(404, 'data').respond({});
|
||||
requestHandler.respond(404, { key: 'value' });
|
||||
requestHandler.respond(404, { key: 'value' }, { header: 'value' });
|
||||
requestHandler.respond(404, { key: 'value' }, { header: 'value' }, 'responseText');
|
||||
|
||||
Vendored
+182
-110
@@ -1,6 +1,6 @@
|
||||
// Type definitions for Angular JS 1.3 (ngMock, ngMockE2E module)
|
||||
// Project: http://angularjs.org
|
||||
// Definitions by: Diego Vilar <http://github.com/diegovilar>
|
||||
// Definitions by: Diego Vilar <http://github.com/diegovilar>, Tony Curtis <http://github.com/daltin>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="angular.d.ts" />
|
||||
@@ -97,137 +97,208 @@ declare module angular {
|
||||
// see https://docs.angularjs.org/api/ngMock/service/$httpBackend
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IHttpBackendService {
|
||||
/**
|
||||
* Flushes all pending requests using the trained responses.
|
||||
* @param count Number of responses to flush (in the order they arrived). If undefined, all pending requests will be flushed.
|
||||
*/
|
||||
flush(count?: number): void;
|
||||
|
||||
/**
|
||||
* Resets all request expectations, but preserves all backend definitions.
|
||||
*/
|
||||
resetExpectations(): void;
|
||||
|
||||
/**
|
||||
* Verifies that all of the requests defined via the expect api were made. If any of the requests were not made, verifyNoOutstandingExpectation throws an exception.
|
||||
*/
|
||||
verifyNoOutstandingExpectation(): void;
|
||||
|
||||
/**
|
||||
* Verifies that there are no outstanding requests that need to be flushed.
|
||||
*/
|
||||
verifyNoOutstandingRequest(): void;
|
||||
|
||||
expect(method: string, url: string, data?: string, headers?: Object): mock.IRequestHandler;
|
||||
expect(method: string, url: string, data?: string, headers?: (object: Object) => boolean): mock.IRequestHandler;
|
||||
expect(method: string, url: string, data?: RegExp, headers?: Object): mock.IRequestHandler;
|
||||
expect(method: string, url: string, data?: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler;
|
||||
expect(method: string, url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
|
||||
expect(method: string, url: string, data?: (data: string) => boolean, headers?: (object: Object) => boolean): mock.IRequestHandler;
|
||||
expect(method: string, url: string, data?: Object, headers?: Object): mock.IRequestHandler;
|
||||
expect(method: string, url: string, data?: Object, headers?: (object: Object) => boolean): mock.IRequestHandler;
|
||||
expect(method: string, url: RegExp, data?: string, headers?: Object): mock.IRequestHandler;
|
||||
expect(method: string, url: RegExp, data?: string, headers?: (object: Object) => boolean): mock.IRequestHandler;
|
||||
expect(method: string, url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler;
|
||||
expect(method: string, url: RegExp, data?: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler;
|
||||
expect(method: string, url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
|
||||
expect(method: string, url: RegExp, data?: (data: string) => boolean, headers?: (object: Object) => boolean): mock.IRequestHandler;
|
||||
expect(method: string, url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler;
|
||||
expect(method: string, url: RegExp, data?: Object, headers?: (object: Object) => boolean): mock.IRequestHandler;
|
||||
/**
|
||||
* Creates a new request expectation.
|
||||
* Throws a preformatted error if expectation(s) don't match supplied string, regular expression, object, or if function returns false.
|
||||
* Returns an object with respond method that controls how a matched request is handled.
|
||||
* @param method HTTP method.
|
||||
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
|
||||
* @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation.
|
||||
* @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
|
||||
*/
|
||||
expect(method: string, url: string | RegExp | ((url: string) => boolean), data?: string | RegExp | Object | ((data: string) => boolean), headers?: Object | ((object: Object) => boolean)) :mock.IRequestHandler;
|
||||
|
||||
expectDELETE(url: string, headers?: Object): mock.IRequestHandler;
|
||||
expectDELETE(url: RegExp, headers?: Object): mock.IRequestHandler;
|
||||
expectGET(url: string, headers?: Object): mock.IRequestHandler;
|
||||
expectGET(url: RegExp, headers?: Object): mock.IRequestHandler;
|
||||
expectHEAD(url: string, headers?: Object): mock.IRequestHandler;
|
||||
expectHEAD(url: RegExp, headers?: Object): mock.IRequestHandler;
|
||||
expectJSONP(url: string): mock.IRequestHandler;
|
||||
expectJSONP(url: RegExp): mock.IRequestHandler;
|
||||
/**
|
||||
* Creates a new request expectation for DELETE requests.
|
||||
* Throws a preformatted error if expectation(s) don't match supplied string, regular expression, object, or if function returns false.
|
||||
* Returns an object with respond method that controls how a matched request is handled.
|
||||
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url is as expected.
|
||||
* @param headers HTTP headers object to be compared with the HTTP headers in the request.
|
||||
*/
|
||||
expectDELETE(url: string | RegExp | ((url: string) => boolean), headers?: Object): mock.IRequestHandler;
|
||||
|
||||
expectPATCH(url: string, data?: string, headers?: Object): mock.IRequestHandler;
|
||||
expectPATCH(url: string, data?: RegExp, headers?: Object): mock.IRequestHandler;
|
||||
expectPATCH(url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
|
||||
expectPATCH(url: string, data?: Object, headers?: Object): mock.IRequestHandler;
|
||||
expectPATCH(url: RegExp, data?: string, headers?: Object): mock.IRequestHandler;
|
||||
expectPATCH(url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler;
|
||||
expectPATCH(url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
|
||||
expectPATCH(url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler;
|
||||
/**
|
||||
* Creates a new request expectation for GET requests.
|
||||
* Throws a preformatted error if expectation(s) don't match supplied string, regular expression, object, or if function returns false.
|
||||
* Returns an object with respond method that controls how a matched request is handled.
|
||||
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
|
||||
* @param headers HTTP headers object to be compared with the HTTP headers in the request.
|
||||
*/
|
||||
expectGET(url: string | RegExp | ((url: string) => boolean), headers?: Object): mock.IRequestHandler;
|
||||
|
||||
expectPOST(url: string, data?: string, headers?: Object): mock.IRequestHandler;
|
||||
expectPOST(url: string, data?: RegExp, headers?: Object): mock.IRequestHandler;
|
||||
expectPOST(url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
|
||||
expectPOST(url: string, data?: Object, headers?: Object): mock.IRequestHandler;
|
||||
expectPOST(url: RegExp, data?: string, headers?: Object): mock.IRequestHandler;
|
||||
expectPOST(url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler;
|
||||
expectPOST(url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
|
||||
expectPOST(url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler;
|
||||
/**
|
||||
* Creates a new request expectation for HEAD requests.
|
||||
* Throws a preformatted error if expectation(s) don't match supplied string, regular expression, object, or if function returns false.
|
||||
* Returns an object with respond method that controls how a matched request is handled.
|
||||
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
|
||||
* @param headers HTTP headers object to be compared with the HTTP headers in the request.
|
||||
*/
|
||||
expectHEAD(url: string | RegExp | ((url: string) => boolean), headers?: Object): mock.IRequestHandler;
|
||||
|
||||
/**
|
||||
* Creates a new request expectation for JSONP requests.
|
||||
* Throws a preformatted error if expectation(s) don't match supplied string, regular expression, or if function returns false.
|
||||
* Returns an object with respond method that controls how a matched request is handled.
|
||||
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
|
||||
*/
|
||||
expectJSONP(url: string | RegExp | ((url: string) => boolean)): mock.IRequestHandler;
|
||||
|
||||
expectPUT(url: string, data?: string, headers?: Object): mock.IRequestHandler;
|
||||
expectPUT(url: string, data?: RegExp, headers?: Object): mock.IRequestHandler;
|
||||
expectPUT(url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
|
||||
expectPUT(url: string, data?: Object, headers?: Object): mock.IRequestHandler;
|
||||
expectPUT(url: RegExp, data?: string, headers?: Object): mock.IRequestHandler;
|
||||
expectPUT(url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler;
|
||||
expectPUT(url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
|
||||
expectPUT(url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler;
|
||||
/**
|
||||
* Creates a new request expectation for PATCH requests.
|
||||
* Throws a preformatted error if expectation(s) don't match supplied string, regular expression, object, or if function returns false.
|
||||
* Returns an object with respond method that controls how a matched request is handled.
|
||||
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
|
||||
* @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation.
|
||||
* @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
|
||||
*/
|
||||
expectPATCH(url: string | RegExp | ((url: string) => boolean), data?: string | RegExp | Object | ((data: string) => boolean), headers?: Object): mock.IRequestHandler;
|
||||
|
||||
when(method: string, url: string, data?: string, headers?: Object): mock.IRequestHandler;
|
||||
when(method: string, url: string, data?: string, headers?: (object: Object) => boolean): mock.IRequestHandler;
|
||||
when(method: string, url: string, data?: RegExp, headers?: Object): mock.IRequestHandler;
|
||||
when(method: string, url: string, data?: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler;
|
||||
when(method: string, url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
|
||||
when(method: string, url: string, data?: (data: string) => boolean, headers?: (object: Object) => boolean): mock.IRequestHandler;
|
||||
when(method: string, url: string, data?: Object, headers?: Object): mock.IRequestHandler;
|
||||
when(method: string, url: string, data?: Object, headers?: (object: Object) => boolean): mock.IRequestHandler;
|
||||
when(method: string, url: RegExp, data?: string, headers?: Object): mock.IRequestHandler;
|
||||
when(method: string, url: RegExp, data?: string, headers?: (object: Object) => boolean): mock.IRequestHandler;
|
||||
when(method: string, url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler;
|
||||
when(method: string, url: RegExp, data?: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler;
|
||||
when(method: string, url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
|
||||
when(method: string, url: RegExp, data?: (data: string) => boolean, headers?: (object: Object) => boolean): mock.IRequestHandler;
|
||||
when(method: string, url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler;
|
||||
when(method: string, url: RegExp, data?: Object, headers?: (object: Object) => boolean): mock.IRequestHandler;
|
||||
/**
|
||||
* Creates a new request expectation for POST requests.
|
||||
* Throws a preformatted error if expectation(s) don't match supplied string, regular expression, object, or if function returns false.
|
||||
* Returns an object with respond method that controls how a matched request is handled.
|
||||
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
|
||||
* @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation.
|
||||
* @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
|
||||
*/
|
||||
expectPOST(url: string | RegExp | ((url: string) => boolean), data?: string | RegExp | Object | ((data: string) => boolean), headers?: Object): mock.IRequestHandler;
|
||||
|
||||
whenDELETE(url: string, headers?: Object): mock.IRequestHandler;
|
||||
whenDELETE(url: string, headers?: (object: Object) => boolean): mock.IRequestHandler;
|
||||
whenDELETE(url: RegExp, headers?: Object): mock.IRequestHandler;
|
||||
whenDELETE(url: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler;
|
||||
/**
|
||||
* Creates a new request expectation for PUT requests.
|
||||
* Throws a preformatted error if expectation(s) don't match supplied string, regular expression, object, or if function returns false.
|
||||
* Returns an object with respond method that controls how a matched request is handled.
|
||||
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
|
||||
* @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation.
|
||||
* @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
|
||||
*/
|
||||
expectPUT(url: string | RegExp | ((url: string) => boolean), data?: string | RegExp | Object | ((data: string) => boolean), headers?: Object): mock.IRequestHandler;
|
||||
|
||||
whenGET(url: string, headers?: Object): mock.IRequestHandler;
|
||||
whenGET(url: string, headers?: (object: Object) => boolean): mock.IRequestHandler;
|
||||
whenGET(url: RegExp, headers?: Object): mock.IRequestHandler;
|
||||
whenGET(url: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler;
|
||||
/**
|
||||
* Creates a new backend definition.
|
||||
* Returns an object with respond method that controls how a matched request is handled.
|
||||
* @param method HTTP method.
|
||||
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
|
||||
* @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation.
|
||||
* @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
|
||||
*/
|
||||
when(method: string, url: string | RegExp | ((url: string) => boolean), data?: string | RegExp | Object | ((data: string) => boolean), headers?: Object | ((object: Object) => boolean)): mock.IRequestHandler;
|
||||
|
||||
whenHEAD(url: string, headers?: Object): mock.IRequestHandler;
|
||||
whenHEAD(url: string, headers?: (object: Object) => boolean): mock.IRequestHandler;
|
||||
whenHEAD(url: RegExp, headers?: Object): mock.IRequestHandler;
|
||||
whenHEAD(url: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler;
|
||||
/**
|
||||
* Creates a new backend definition for DELETE requests.
|
||||
* Returns an object with respond method that controls how a matched request is handled.
|
||||
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
|
||||
* @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
|
||||
*/
|
||||
whenDELETE(url: string | RegExp | ((url: string) => boolean), headers?: Object | ((object: Object) => boolean)): mock.IRequestHandler;
|
||||
|
||||
whenJSONP(url: string): mock.IRequestHandler;
|
||||
whenJSONP(url: RegExp): mock.IRequestHandler;
|
||||
/**
|
||||
* Creates a new backend definition for GET requests.
|
||||
* Returns an object with respond method that controls how a matched request is handled.
|
||||
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
|
||||
* @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
|
||||
*/
|
||||
whenGET(url: string | RegExp | ((url: string) => boolean), headers?: Object | ((object: Object) => boolean)): mock.IRequestHandler;
|
||||
|
||||
whenPATCH(url: string, data?: string, headers?: Object): mock.IRequestHandler;
|
||||
whenPATCH(url: string, data?: RegExp, headers?: Object): mock.IRequestHandler;
|
||||
whenPATCH(url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
|
||||
whenPATCH(url: string, data?: Object, headers?: Object): mock.IRequestHandler;
|
||||
whenPATCH(url: RegExp, data?: string, headers?: Object): mock.IRequestHandler;
|
||||
whenPATCH(url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler;
|
||||
whenPATCH(url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
|
||||
whenPATCH(url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler;
|
||||
/**
|
||||
* Creates a new backend definition for HEAD requests.
|
||||
* Returns an object with respond method that controls how a matched request is handled.
|
||||
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
|
||||
* @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
|
||||
*/
|
||||
whenHEAD(url: string | RegExp | ((url: string) => boolean), headers?: Object | ((object: Object) => boolean)): mock.IRequestHandler;
|
||||
|
||||
whenPOST(url: string, data?: string, headers?: Object): mock.IRequestHandler;
|
||||
whenPOST(url: string, data?: RegExp, headers?: Object): mock.IRequestHandler;
|
||||
whenPOST(url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
|
||||
whenPOST(url: string, data?: Object, headers?: Object): mock.IRequestHandler;
|
||||
whenPOST(url: RegExp, data?: string, headers?: Object): mock.IRequestHandler;
|
||||
whenPOST(url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler;
|
||||
whenPOST(url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
|
||||
whenPOST(url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler;
|
||||
/**
|
||||
* Creates a new backend definition for JSONP requests.
|
||||
* Returns an object with respond method that controls how a matched request is handled.
|
||||
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
|
||||
* @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
|
||||
*/
|
||||
whenJSONP(url: string | RegExp | ((url: string) => boolean)): mock.IRequestHandler;
|
||||
|
||||
whenPUT(url: string, data?: string, headers?: Object): mock.IRequestHandler;
|
||||
whenPUT(url: string, data?: RegExp, headers?: Object): mock.IRequestHandler;
|
||||
whenPUT(url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
|
||||
whenPUT(url: string, data?: Object, headers?: Object): mock.IRequestHandler;
|
||||
whenPUT(url: RegExp, data?: string, headers?: Object): mock.IRequestHandler;
|
||||
whenPUT(url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler;
|
||||
whenPUT(url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
|
||||
whenPUT(url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler;
|
||||
/**
|
||||
* Creates a new backend definition for PATCH requests.
|
||||
* Returns an object with respond method that controls how a matched request is handled.
|
||||
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
|
||||
* @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation.
|
||||
* @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
|
||||
*/
|
||||
whenPATCH(url: string | RegExp | ((url: string) => boolean), data?: string | RegExp | Object | ((data: string) => boolean), headers?: Object | ((object: Object) => boolean)): mock.IRequestHandler;
|
||||
|
||||
/**
|
||||
* Creates a new backend definition for POST requests.
|
||||
* Returns an object with respond method that controls how a matched request is handled.
|
||||
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
|
||||
* @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation.
|
||||
* @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
|
||||
*/
|
||||
whenPOST(url: string | RegExp | ((url: string) => boolean), data?: string | RegExp | Object | ((data: string) => boolean), headers?: Object | ((object: Object) => boolean)): mock.IRequestHandler;
|
||||
|
||||
/**
|
||||
* Creates a new backend definition for PUT requests.
|
||||
* Returns an object with respond method that controls how a matched request is handled.
|
||||
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
|
||||
* @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation.
|
||||
* @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
|
||||
*/
|
||||
whenPUT(url: string | RegExp | ((url: string) => boolean), data?: string | RegExp | Object | ((data: string) => boolean), headers?: Object | ((object: Object) => boolean)): mock.IRequestHandler;
|
||||
}
|
||||
|
||||
export module mock {
|
||||
|
||||
// returned interface by the the mocked HttpBackendService expect/when methods
|
||||
interface IRequestHandler {
|
||||
respond(func: Function): void;
|
||||
respond(status: number, data?: any, headers?: any): void;
|
||||
respond(data: any, headers?: any): void;
|
||||
|
||||
/**
|
||||
* Controls the response for a matched request using a function to construct the response.
|
||||
* Returns the RequestHandler object for possible overrides.
|
||||
* @param func Function that receives the request HTTP method, url, data, and headers and returns an array containing response status (number), data, headers, and status text.
|
||||
*/
|
||||
respond(func: ((method: string, url: string, data: string | Object, headers: Object) => [number, string | Object, Object, string])): IRequestHandler;
|
||||
|
||||
// Available wehn ngMockE2E is loaded
|
||||
passThrough(): void;
|
||||
/**
|
||||
* Controls the response for a matched request using supplied static data to construct the response.
|
||||
* Returns the RequestHandler object for possible overrides.
|
||||
* @param status HTTP status code to add to the response.
|
||||
* @param data Data to add to the response.
|
||||
* @param headers Headers object to add to the response.
|
||||
* @param responseText Response text to add to the response.
|
||||
*/
|
||||
respond(status: number, data: string | Object, headers?: Object, responseText?: string): IRequestHandler;
|
||||
|
||||
/**
|
||||
* Controls the response for a matched request using the HTTP status code 200 and supplied static data to construct the response.
|
||||
* Returns the RequestHandler object for possible overrides.
|
||||
* @param data Data to add to the response.
|
||||
* @param headers Headers object to add to the response.
|
||||
* @param responseText Response text to add to the response.
|
||||
*/
|
||||
respond(data: string | Object, headers?: Object, responseText?: string): IRequestHandler;
|
||||
|
||||
// Available when ngMockE2E is loaded
|
||||
/**
|
||||
* Any request matching a backend definition or expectation with passThrough handler will be passed through to the real backend (an XHR request will be made to the server.)
|
||||
*/
|
||||
passThrough(): IRequestHandler;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -237,5 +308,6 @@ declare module angular {
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// functions attached to global object (window)
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
declare var module: (...modules: any[]) => any;
|
||||
//Use `angular.mock.module` instead of `module`, as `module` conflicts with commonjs.
|
||||
//declare var module: (...modules: any[]) => any;
|
||||
declare var inject: angular.IInjectStatic;
|
||||
|
||||
+118
-21
@@ -260,6 +260,8 @@ module TestQ {
|
||||
let result: angular.IPromise<TResult>;
|
||||
result = new $q<TResult>((resolve: (value: TResult) => any) => {});
|
||||
result = new $q<TResult>((resolve: (value: TResult) => any, reject: (value: any) => any) => {});
|
||||
result = $q<TResult>((resolve: (value: TResult) => any) => {});
|
||||
result = $q<TResult>((resolve: (value: TResult) => any, reject: (value: any) => any) => {});
|
||||
}
|
||||
|
||||
// $q.all
|
||||
@@ -325,6 +327,48 @@ httpFoo.success((data, status, headers, config) => {
|
||||
});
|
||||
|
||||
|
||||
// Deferred signature tests
|
||||
module TestDeferred {
|
||||
var any: any;
|
||||
|
||||
interface TResult {
|
||||
a: number;
|
||||
b: string;
|
||||
c: boolean;
|
||||
}
|
||||
var tResult: TResult;
|
||||
|
||||
var deferred: angular.IDeferred<TResult>;
|
||||
|
||||
// deferred.resolve
|
||||
{
|
||||
let result: void;
|
||||
result = <void>deferred.resolve();
|
||||
result = <void>deferred.resolve(tResult);
|
||||
}
|
||||
|
||||
// deferred.reject
|
||||
{
|
||||
let result: void;
|
||||
result = deferred.reject();
|
||||
result = deferred.reject(any);
|
||||
}
|
||||
|
||||
// deferred.notify
|
||||
{
|
||||
let result: void;
|
||||
result = deferred.notify();
|
||||
result = deferred.notify(any);
|
||||
}
|
||||
|
||||
// deferred.promise
|
||||
{
|
||||
let result: angular.IPromise<TResult>;
|
||||
result = deferred.promise;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Promise signature tests
|
||||
module TestPromise {
|
||||
var result: any;
|
||||
@@ -335,34 +379,48 @@ module TestPromise {
|
||||
b: string;
|
||||
c: boolean;
|
||||
}
|
||||
interface TOther {
|
||||
d: number;
|
||||
e: string;
|
||||
f: boolean;
|
||||
}
|
||||
|
||||
var tresult: TResult;
|
||||
var tresultPromise: ng.IPromise<TResult>;
|
||||
|
||||
var tother: TOther;
|
||||
var totherPromise: ng.IPromise<TOther>;
|
||||
|
||||
var promise: angular.IPromise<TResult>;
|
||||
interface IPromiseSuccessCallback<T, U> {
|
||||
(promiseValue: T): angular.IHttpPromise<U>|angular.IPromise<U>|U|angular.IPromise<void>;
|
||||
}
|
||||
var successCallbackAnyFn: IPromiseSuccessCallback<TResult, any>;
|
||||
var successCallbackTResultFn: IPromiseSuccessCallback<TResult, TResult>;
|
||||
interface IPromiseErrorCallback<T> {
|
||||
(error: any): angular.IHttpPromise<T>|angular.IPromise<T>|T;
|
||||
}
|
||||
var errorCallbackAnyFn: IPromiseErrorCallback<any>;
|
||||
var errorCallbackTResultFn: IPromiseErrorCallback<TResult>;
|
||||
|
||||
// promise.then
|
||||
result = <angular.IPromise<any>>promise.then(successCallbackAnyFn);
|
||||
result = <angular.IPromise<any>>promise.then(successCallbackAnyFn, (any) => any);
|
||||
result = <angular.IPromise<any>>promise.then(successCallbackAnyFn, (any) => any, (any) => any);
|
||||
result = <angular.IPromise<TResult>>promise.then<TResult>(successCallbackTResultFn);
|
||||
result = <angular.IPromise<TResult>>promise.then<TResult>(successCallbackTResultFn, (any) => any);
|
||||
result = <angular.IPromise<TResult>>promise.then<TResult>(successCallbackTResultFn, (any) => any, (any) => any);
|
||||
|
||||
result = <angular.IPromise<any>>promise.then((result) => any);
|
||||
result = <angular.IPromise<any>>promise.then((result) => any, (any) => any);
|
||||
result = <angular.IPromise<any>>promise.then((result) => any, (any) => any, (any) => any);
|
||||
|
||||
result = <angular.IPromise<TResult>>promise.then((result) => result);
|
||||
result = <angular.IPromise<TResult>>promise.then((result) => result, (any) => any);
|
||||
result = <angular.IPromise<TResult>>promise.then((result) => result, (any) => any, (any) => any);
|
||||
result = <angular.IPromise<TResult>>promise.then((result) => tresultPromise);
|
||||
result = <angular.IPromise<TResult>>promise.then((result) => tresultPromise, (any) => any);
|
||||
result = <angular.IPromise<TResult>>promise.then((result) => tresultPromise, (any) => any, (any) => any);
|
||||
|
||||
result = <angular.IPromise<TOther>>promise.then((result) => tother);
|
||||
result = <angular.IPromise<TOther>>promise.then((result) => tother, (any) => any);
|
||||
result = <angular.IPromise<TOther>>promise.then((result) => tother, (any) => any, (any) => any);
|
||||
result = <angular.IPromise<TOther>>promise.then((result) => totherPromise);
|
||||
result = <angular.IPromise<TOther>>promise.then((result) => totherPromise, (any) => any);
|
||||
result = <angular.IPromise<TOther>>promise.then((result) => totherPromise, (any) => any, (any) => any);
|
||||
|
||||
// promise.catch
|
||||
result = <angular.IPromise<any>>promise.catch(errorCallbackAnyFn);
|
||||
result = <angular.IPromise<TResult>>promise.catch<TResult>(errorCallbackTResultFn);
|
||||
result = <angular.IPromise<any>>promise.catch((err) => any);
|
||||
result = <angular.IPromise<TResult>>promise.catch((err) => tresult);
|
||||
result = <angular.IPromise<TOther>>promise.catch((err) => tother);
|
||||
|
||||
// promise.finally
|
||||
result = <angular.IPromise<any>>promise.finally(() => any);
|
||||
result = <angular.IPromise<TResult>>promise.finally<TResult>(() => any);
|
||||
result = <angular.IPromise<TResult>>promise.finally(() => any);
|
||||
result = <angular.IPromise<TResult>>promise.finally(() => tresult);
|
||||
result = <angular.IPromise<TResult>>promise.finally(() => tother);
|
||||
}
|
||||
|
||||
|
||||
@@ -381,6 +439,45 @@ var scope: ng.IScope = element.scope();
|
||||
var isolateScope: ng.IScope = element.isolateScope();
|
||||
|
||||
|
||||
// $timeout signature tests
|
||||
module TestTimeout {
|
||||
interface TResult {
|
||||
a: number;
|
||||
b: string;
|
||||
c: boolean;
|
||||
}
|
||||
var fnTResult: (...args: any[]) => TResult;
|
||||
var promiseAny: angular.IPromise<any>;
|
||||
var $timeout: angular.ITimeoutService;
|
||||
|
||||
// $timeout
|
||||
{
|
||||
let result: angular.IPromise<any>;
|
||||
result = $timeout();
|
||||
}
|
||||
{
|
||||
let result: angular.IPromise<void>;
|
||||
result = $timeout(1);
|
||||
result = $timeout(1, true);
|
||||
}
|
||||
{
|
||||
let result: angular.IPromise<TResult>;
|
||||
result = $timeout(fnTResult);
|
||||
result = $timeout(fnTResult, 1);
|
||||
result = $timeout(fnTResult, 1, true);
|
||||
result = $timeout(fnTResult, 1, true, 1);
|
||||
result = $timeout(fnTResult, 1, true, 1, '');
|
||||
result = $timeout(fnTResult, 1, true, 1, '', true);
|
||||
}
|
||||
|
||||
// $timeout.cancel
|
||||
{
|
||||
let result: boolean;
|
||||
result = $timeout.cancel();
|
||||
result = $timeout.cancel(promiseAny);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function test_IAttributes(attributes: ng.IAttributes){
|
||||
return attributes;
|
||||
|
||||
Vendored
+6
-3
@@ -725,8 +725,9 @@ declare module angular {
|
||||
// see http://docs.angularjs.org/api/ng.$timeout
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface ITimeoutService {
|
||||
<T>(func: (...args: any[]) => T, delay?: number, invokeApply?: boolean): IPromise<T>;
|
||||
cancel(promise: IPromise<any>): boolean;
|
||||
(delay?: number, invokeApply?: boolean): IPromise<void>;
|
||||
<T>(fn: (...args: any[]) => T, delay?: number, invokeApply?: boolean, ...args: any[]): IPromise<T>;
|
||||
cancel(promise?: IPromise<any>): boolean;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
@@ -998,6 +999,8 @@ declare module angular {
|
||||
interface IQService {
|
||||
new <T>(resolver: (resolve: IQResolveReject<T>) => any): IPromise<T>;
|
||||
new <T>(resolver: (resolve: IQResolveReject<T>, reject: IQResolveReject<any>) => any): IPromise<T>;
|
||||
<T>(resolver: (resolve: IQResolveReject<T>) => any): IPromise<T>;
|
||||
<T>(resolver: (resolve: IQResolveReject<T>, reject: IQResolveReject<any>) => any): IPromise<T>;
|
||||
|
||||
/**
|
||||
* Combines multiple promises into a single promise that is resolved when all of the input promises are resolved.
|
||||
@@ -1060,7 +1063,7 @@ declare module angular {
|
||||
*
|
||||
* Because finally is a reserved word in JavaScript and reserved keywords are not supported as property names by ES3, you'll need to invoke the method like promise['finally'](callback) to make your code IE8 and Android 2.x compatible.
|
||||
*/
|
||||
finally<TResult>(finallyCallback: () => any): IPromise<TResult>;
|
||||
finally(finallyCallback: () => any): IPromise<T>;
|
||||
}
|
||||
|
||||
interface IDeferred<T> {
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
///<reference path="apn.d.ts"/>
|
||||
import apn = require("apn");
|
||||
|
||||
//Hand made TypeScript tests
|
||||
//==========================
|
||||
|
||||
//Create with a hex string
|
||||
var device1 = new apn.Device("ca11ab1e");
|
||||
//Create with a Buffer
|
||||
var device2 = new apn.Device(new Buffer("ca55e77e"));
|
||||
|
||||
//Create the notification
|
||||
var notification = new apn.Notification();
|
||||
notification.alert = {
|
||||
title: "The Title",
|
||||
body: "This is the body",
|
||||
};
|
||||
notification.badge = 5;
|
||||
//Fluid api
|
||||
notification.setAlertTitle("The Title")
|
||||
.setAlertText("This is the body")
|
||||
.setLaunchImage("LaunchImage");
|
||||
|
||||
//Establish the connection
|
||||
var connection = new apn.Connection({
|
||||
cert: "path/to/cert.pem",
|
||||
key: "path/to/cert.pem"
|
||||
});
|
||||
//Testing some specialized event listeners
|
||||
connection.on("error", (error) => {
|
||||
console.log("push error", error.name, error.message);
|
||||
});
|
||||
connection.on("transmissionError", (errorCode, notification, device) => {
|
||||
console.log("push failed", errorCode, "notification", notification.alert, "device id: ", device.toString());
|
||||
});
|
||||
|
||||
//Send it using hex string
|
||||
connection.pushNotification(notification, "ba5eba11");
|
||||
//Send it using Buffer
|
||||
connection.pushNotification(notification, new Buffer("5ca1ab1e"));
|
||||
//Send it using Device
|
||||
connection.pushNotification(notification, device1);
|
||||
|
||||
//Connecting to feedback service
|
||||
var feedbackService = new apn.Feedback({
|
||||
cert: "path/to/cert.pem",
|
||||
key: "path/to/cert.pem",
|
||||
interval: 0
|
||||
});
|
||||
feedbackService.on("error", (error:Error) => {
|
||||
console.log("push feedback error", error.name, error.message);
|
||||
});
|
||||
function processFeedbackData(device:apn.Device, time:number) {
|
||||
}
|
||||
feedbackService.on("feedback", (feedbackData) => {
|
||||
feedbackData.forEach((data) => {
|
||||
processFeedbackData(data.device, data.time);
|
||||
})
|
||||
});
|
||||
feedbackService.start();
|
||||
|
||||
|
||||
//Original examples from apn package
|
||||
//==================================
|
||||
|
||||
//sending-to-multiple-devices.js
|
||||
//------------------------------
|
||||
|
||||
var tokens = ["<insert token here>", "<insert token here>"];
|
||||
|
||||
if(tokens[0] === "<insert token here>") {
|
||||
console.log("Please set token to a valid device token for the push notification service");
|
||||
process.exit();
|
||||
}
|
||||
|
||||
// Create a connection to the service using mostly default parameters.
|
||||
|
||||
var service = new apn.connection({ production: false });
|
||||
|
||||
service.on("connected", function() {
|
||||
console.log("Connected");
|
||||
});
|
||||
|
||||
service.on("transmitted", function(notification, device) {
|
||||
console.log("Notification transmitted to:" + device.token.toString("hex"));
|
||||
});
|
||||
|
||||
service.on("transmissionError", function(errCode, notification, device) {
|
||||
console.error("Notification caused error: " + errCode + " for device ", device, notification);
|
||||
if (errCode === 8) {
|
||||
console.log("A error code of 8 indicates that the device token is invalid. This could be for a number of reasons - are you using the correct environment? i.e. Production vs. Sandbox");
|
||||
}
|
||||
});
|
||||
|
||||
service.on("timeout", function () {
|
||||
console.log("Connection Timeout");
|
||||
});
|
||||
|
||||
service.on("disconnected", function() {
|
||||
console.log("Disconnected from APNS");
|
||||
});
|
||||
|
||||
service.on("socketError", console.error);
|
||||
|
||||
|
||||
// If you plan on sending identical paylods to many devices you can do something like this.
|
||||
function pushNotificationToMany() {
|
||||
console.log("Sending the same notification each of the devices with one call to pushNotification.");
|
||||
var note = new apn.notification();
|
||||
note.setAlertText("Hello, from node-apn!");
|
||||
note.badge = 1;
|
||||
|
||||
service.pushNotification(note, tokens);
|
||||
}
|
||||
|
||||
pushNotificationToMany();
|
||||
|
||||
|
||||
// If you have a list of devices for which you want to send a customised notification you can create one and send it to and individual device.
|
||||
function pushSomeNotifications() {
|
||||
console.log("Sending a tailored notification to %d devices", tokens.length);
|
||||
tokens.forEach(function(token, i) {
|
||||
var note = new apn.notification();
|
||||
note.setAlertText("Hello, from node-apn! You are number: " + i);
|
||||
note.badge = i;
|
||||
|
||||
service.pushNotification(note, token);
|
||||
});
|
||||
}
|
||||
|
||||
pushSomeNotifications();
|
||||
|
||||
//feedback.js
|
||||
//-----------
|
||||
|
||||
function handleFeedback(feedbackData:apn.FeedbackData[]) {
|
||||
feedbackData.forEach(function(feedbackItem) {
|
||||
console.log("Device: " + feedbackItem.device.toString() + " has been unreachable, since: " + feedbackItem.time);
|
||||
});
|
||||
}
|
||||
|
||||
// Setup a connection to the feedback service using a custom interval (10 seconds)
|
||||
var feedback = new apn.feedback({ production: false, interval: 10 });
|
||||
|
||||
feedback.on("feedback", handleFeedback);
|
||||
feedback.on("feedbackError", console.error);
|
||||
Vendored
+364
@@ -0,0 +1,364 @@
|
||||
// Type definitions for node-apn
|
||||
// Project: https://github.com/argon/node-apn
|
||||
// Definitions by: Zenorbi <https://github.com/zenorbi>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
///<reference path="../node/node.d.ts"/>
|
||||
declare module "apn" {
|
||||
import events = require("events");
|
||||
import net = require("net");
|
||||
export interface ConnectionOptions {
|
||||
/**
|
||||
* The filename of the connection certificate to load from disk, or a Buffer/String containing the certificate data. (Defaults to: `cert.pem`)
|
||||
*/
|
||||
cert?:string|Buffer;
|
||||
/**
|
||||
* The filename of the connection key to load from disk, or a Buffer/String containing the key data. (Defaults to: `key.pem`)
|
||||
*/
|
||||
key?:string|Buffer;
|
||||
/**
|
||||
* An array of trusted certificates. Each element should contain either a filename to load, or a Buffer/String (in PEM format) to be used directly. If this is omitted several well known "root" CAs will be used. - You may need to use this as some environments don't include the CA used by Apple (entrust_2048).
|
||||
*/
|
||||
ca?:(string|Buffer)[];
|
||||
/**
|
||||
* File path for private key, certificate and CA certs in PFX or PKCS12 format, or a Buffer containing the PFX data. If supplied will always be used instead of certificate and key above.
|
||||
*/
|
||||
pfx?:string|Buffer;
|
||||
/**
|
||||
* The passphrase for the connection key, if required
|
||||
*/
|
||||
passphrase?:string;
|
||||
/**
|
||||
* Specifies which environment to connect to: Production (if true) or Sandbox - The hostname will be set automatically. (Defaults to NODE_ENV == "production", i.e. false unless the NODE_ENV environment variable is set accordingly)
|
||||
*/
|
||||
production?:boolean;
|
||||
/**
|
||||
* Enable when you are using a VoIP certificate to enable paylods up to 4096 bytes.
|
||||
*/
|
||||
voip?:boolean;
|
||||
/**
|
||||
* Gateway port (Defaults to: `2195`)
|
||||
*/
|
||||
port?:number;
|
||||
/**
|
||||
* Reject Unauthorized property to be passed through to tls.connect() (Defaults to `true`)
|
||||
*/
|
||||
rejectUnauthorized?:boolean;
|
||||
/**
|
||||
* Number of notifications to cache for error purposes (See "Handling Errors" below, (Defaults to: `1000`)
|
||||
*/
|
||||
cacheLength?:number;
|
||||
/**
|
||||
* Whether the cache should grow in response to messages being lost after errors. (Will still emit a 'cacheTooSmall' event) (Defaults to: `true`)
|
||||
*/
|
||||
autoAdjustCache?:boolean;
|
||||
/**
|
||||
* The maximum number of connections to create for sending messages. (Defaults to: `1`)
|
||||
*/
|
||||
maxConnections?:number;
|
||||
/**
|
||||
* The duration of time the module should wait, in milliseconds, when trying to establish a connection to Apple before failing. 0 = Disabled. {Defaults to: `10000`}
|
||||
*/
|
||||
connectTimeout?:number;
|
||||
/**
|
||||
* The duration the socket should stay alive with no activity in milliseconds. 0 = Disabled. (Defaults to: `3600000` - 1h)
|
||||
*/
|
||||
connectionTimeout?:number;
|
||||
/**
|
||||
* The maximum number of connection failures that will be tolerated before `apn` will "terminate". (Defaults to: 10)
|
||||
*/
|
||||
connectionRetryLimit?:number;
|
||||
/**
|
||||
* Whether to buffer notifications and resend them after failure. (Defaults to: `true`)
|
||||
*/
|
||||
buffersNotifications?:number;
|
||||
/**
|
||||
* Whether to aggresively empty the notification buffer while connected - if set to true node-apn may enter a tight loop under heavy load while delivering notifications. (Defaults to: `false`)
|
||||
*/
|
||||
fastMode?:boolean;
|
||||
}
|
||||
export class Connection extends events.EventEmitter {
|
||||
constructor(options:ConnectionOptions);
|
||||
/**
|
||||
* This is the business end of the module. Create a `Notification` object and pass it in, along with a single recipient or an array of them and node-apn will take care of the rest, delivering the notification to each recipient.
|
||||
*
|
||||
* A "recipient" is either a `Device` object, a `String`, or a `Buffer` containing the device token. `Device` objects are used internally and will be created if necessary. Where applicable, all events will return a `Device` regardless of the type passed to this method.
|
||||
*/
|
||||
pushNotification(notification:Notification, recipient:Device|string|Buffer|(Device|string|Buffer)[]):void;
|
||||
/**
|
||||
* Used to manually adjust the "cacheLength" property in the options. This is ideal if you choose to use the `cacheTooSmall` event to tweak your environment. It is safe for increasing and reducing cache size.
|
||||
*/
|
||||
setCacheLength(newLength:number):void;
|
||||
/**
|
||||
* Indicate to node-apn that when the queue of pending notifications is fully drained that it should close all open connections. This will mean that if there are no other pending resources (open sockets, running timers, etc.) the application will terminate. If notifications are pushed after the connection has completely shutdown a new connection will be established and, if applicable, `shutdown` will need to be called again.
|
||||
*/
|
||||
shutdown():void;
|
||||
/**
|
||||
* Emitted when an error occurs during initialisation of the module, usually due to a problem with the keys and certificates.
|
||||
*/
|
||||
on(event: "error", listener: (error:Error) => void):Connection;
|
||||
/**
|
||||
* Emitted when the connection socket experiences an error. This may be useful for debugging but no action should be necessary.
|
||||
*/
|
||||
on(event: "socketError", listener: (error:Error) => void):Connection;
|
||||
/**
|
||||
* Emitted when a notification has been sent to Apple - not a guarantee that it has been accepted by Apple, an error relating to it may occur later on. A notification may also be "transmitted" several times if a preceding notification caused an error requiring retransmission.
|
||||
*/
|
||||
on(event: "transmitted", listener: (notification:Notification, decive:Device) => void):Connection;
|
||||
/**
|
||||
* Emitted when all pending notifications have been transmitted to Apple and the pending queue is empty. This may be called more than once if a notification error occurs and notifications must be re-sent.
|
||||
*/
|
||||
on(event: "completed", listener: () => void):Connection;
|
||||
/**
|
||||
* Emitted when Apple returns a notification as invalid but the notification has already been expunged from the cache - usually due to high throughput and indicates that notifications will be getting lost. The parameter is an estimate of how many notifications have been lost. You should experiment with increasing the cache size or enabling ```autoAdjustCache``` if you see this frequently.
|
||||
*
|
||||
* **Note**: With ```autoAdjustCache``` enabled this event will still be emitted when an adjustment is triggered.
|
||||
*/
|
||||
on(event: "cacheTooSmall", listener: (sizeDifference:number) => void):Connection;
|
||||
/**
|
||||
* Emitted when a connection to Apple is successfully established. The parameter indicates the number of open connections. No action is required as the connection is managed internally.
|
||||
*/
|
||||
on(event: "connected", listener: (openSockets:net.Socket[]) => void):Connection;
|
||||
/**
|
||||
* Emitted when the connection to Apple has been closed, this could be for numerous reasons, for example an error has occurred or the connection has timed out. The parameter is the same as for `connected` and again, no action is required.
|
||||
*/
|
||||
on(event: "disconnected", listener: (openSockets:net.Socket[]) => void):Connection;
|
||||
/**
|
||||
* Emitted when the connectionTimeout option has been specified and no activity has occurred on a socket for a specified duration. The socket will be closed immediately after this event and a `disconnected` event will also be emitted.
|
||||
*/
|
||||
on(event: "timeout", listener: () => void):Connection;
|
||||
/**
|
||||
* Emitted when a message has been received from Apple stating that a notification was invalid or if an internal error occurred before that notification could be pushed to Apple. If the notification is still in the cache it will be passed as the second argument, otherwise null. Where possible the associated `Device` object will be passed as a third parameter, however in cases where the token supplied to the module cannot be parsed into a `Buffer` the supplied value will be returned.
|
||||
|
||||
* Error codes smaller than 512 correspond to those returned by Apple as per their [docs][errors]. Other errors are applicable to `node-apn` itself. Definitions can be found in `lib/errors.js`.
|
||||
*/
|
||||
on(event: "transmissionError", listener: (errorCode:number, notification:Notification, device:Device|Buffer) => void):Connection;
|
||||
on(event: string, listener: Function):Connection;
|
||||
}
|
||||
export interface NotificationAlertOptions {
|
||||
title?:string;
|
||||
body:string;
|
||||
"title-loc-key"?:string;
|
||||
"title-loc-args"?:string[];
|
||||
"action-loc-key"?:string;
|
||||
"loc-key"?:string;
|
||||
"loc-args"?:string[];
|
||||
"launch-image"?:string;
|
||||
}
|
||||
export class Notification {
|
||||
/**
|
||||
* The maximum number of retries which should be performed when sending a notification if an error occurs. A value of 0 will only allow one attempt at sending (0 retries). Set to -1 to disable (default).
|
||||
*/
|
||||
public retryLimit:number;
|
||||
/**
|
||||
* The UNIX timestamp representing when the notification should expire. This does not contribute to the 2048 byte payload size limit. An expiry of 0 indicates that the notification expires immediately.
|
||||
*/
|
||||
public expiry:number;
|
||||
/**
|
||||
* From Apple's Documentation, Provide one of the following values:
|
||||
*
|
||||
* - 10 - The push message is sent immediately. (Default)
|
||||
* > The push notification must trigger an alert, sound, or badge on the device. It is an error use this priority for a push that contains only the content-available key.
|
||||
* - 5 - The push message is sent at a time that conserves power on the device receiving it.
|
||||
*/
|
||||
public priority:number;
|
||||
/**
|
||||
* The encoding to use when transmitting the notification to APNS, defaults to `utf8`. `utf16le` is also possible but as each character is represented by a minimum of 2 bytes, will at least halve the possible payload size. If in doubt leave as default.
|
||||
*/
|
||||
public encoding:string;
|
||||
/**
|
||||
* This object represents the root JSON object that you can add custom information for your application to. The properties below will only be added to the payload (under `aps`) when the notification is prepared for sending.
|
||||
*/
|
||||
public payload:any;
|
||||
/**
|
||||
* The value to specify for `payload.aps.badge`
|
||||
*/
|
||||
public badge:number;
|
||||
/**
|
||||
* The value to specify for `payload.aps.sound`
|
||||
*/
|
||||
public sound:string;
|
||||
/**
|
||||
* The value to specify for `payload.aps.alert` can be either a `String` or an `Object` as outlined by the payload documentation.
|
||||
*/
|
||||
public alert:string|NotificationAlertOptions;
|
||||
/**
|
||||
* Setting this to true will specify "content-available" in the payload when it is compiled.
|
||||
*/
|
||||
public newsstandAvailable:boolean;
|
||||
/**
|
||||
* Setting this to true will specify "content-available" in the payload when it is compiled.
|
||||
*/
|
||||
public contentAvailable:boolean;
|
||||
/**
|
||||
* The value to specify for the `mdm` field where applicable.
|
||||
*/
|
||||
public mdm:string|Object;
|
||||
/**
|
||||
* The value to specify for `payload.aps['url-args']`. This used for Safari Push NOtifications and should be an array of values in accordance with the Web Payload Documentation.
|
||||
*/
|
||||
public urlArgs:string[];
|
||||
/**
|
||||
* When this parameter is set and `notification#trim()` is called it will attempt to truncate the string at the nearest space.
|
||||
*/
|
||||
public truncateAtWordEnd:boolean;
|
||||
/**
|
||||
* You can optionally pass in an object representing the payload, or configure properties on the returned object.
|
||||
*/
|
||||
constructor(payload?:any);
|
||||
/**
|
||||
* Set the `aps.alert` text body. This will use the most space-efficient means.
|
||||
*/
|
||||
setAlertText(alertText:string):Notification;
|
||||
/**
|
||||
* Set the `title` property of the `aps.alert` object - used with Safari Push Notifications
|
||||
*/
|
||||
setAlertTitle(alertTitle:string):Notification;
|
||||
/**
|
||||
* Set the `action` property of the `aps.alert` object - used with Safari Push Notifications
|
||||
*/
|
||||
setAlertAction(alertAction:string):Notification;
|
||||
/**
|
||||
* Set the `action-loc-key` property of the `aps.alert` object.
|
||||
*/
|
||||
setActionLocKey(key:string):Notification;
|
||||
/**
|
||||
* Set the `loc-key` property of the `aps.alert` object.
|
||||
*/
|
||||
setLocKey(key:string):Notification;
|
||||
/**
|
||||
* Set the `loc-args` property of the `aps.alert` object.
|
||||
*/
|
||||
setLocArgs(args:string[]):Notification;
|
||||
/**
|
||||
* Set the `launch-image` property of the `aps.alert` object.
|
||||
*/
|
||||
setLaunchImage(image:string):Notification;
|
||||
/**
|
||||
* Set the `mdm` property on the payload.
|
||||
*/
|
||||
setMDM(mdm:string|Object):Notification;
|
||||
/**
|
||||
* Set the `content-available` property of the `aps` object.
|
||||
*/
|
||||
setNewsstandAvailable(available:boolean):Notification;
|
||||
/**
|
||||
* Set the `content-available` property of the `aps` object.
|
||||
*/
|
||||
setContentAvailable(available:boolean):Notification;
|
||||
/**
|
||||
* Set the `url-args` property of the `aps` object.
|
||||
*/
|
||||
setUrlArgs(urlArgs:string[]):Notification;
|
||||
/**
|
||||
* Attempt to automatically trim the notification alert text body to meet the payload size limit of 2048 bytes.
|
||||
*/
|
||||
trim():number;
|
||||
}
|
||||
export class Device {
|
||||
public token:Buffer;
|
||||
/**
|
||||
* `deviceToken` can be a `Buffer` or a `String` containing a "hex" representation of the token. Throws an error if the deviceToken supplied is invalid.
|
||||
*/
|
||||
constructor(deviceToken:string|Buffer);
|
||||
}
|
||||
|
||||
export interface FeedbackOptions {
|
||||
/**
|
||||
* The filename of the connection certificate to load from disk, or a Buffer/String containing the certificate data. (Defaults to: `cert.pem`)
|
||||
*/
|
||||
cert?:string|Buffer;
|
||||
/**
|
||||
* The filename of the connection key to load from disk, or a Buffer/String containing the key data. (Defaults to: `key.pem`)
|
||||
*/
|
||||
key?:string|Buffer;
|
||||
/**
|
||||
* An array of trusted certificates. Each element should contain either a filename to load, or a Buffer/String (in PEM format) to be used directly. If this is omitted several well known "root" CAs will be used. - You may need to use this as some environments don't include the CA used by Apple (entrust_2048).
|
||||
*/
|
||||
ca?:(string|Buffer)[];
|
||||
/**
|
||||
* File path for private key, certificate and CA certs in PFX or PKCS12 format, or a Buffer containing the PFX data. If supplied will be used instead of certificate and key above.
|
||||
*/
|
||||
pfx?:string|Buffer;
|
||||
/**
|
||||
* The passphrase for the connection key, if required
|
||||
*/
|
||||
passphrase?:string;
|
||||
/**
|
||||
* Specifies which environment to connect to: Production (if true) or Sandbox - The hostname will be set automatically. (Defaults to NODE_ENV == "production", i.e. false unless the NODE_ENV environment variable is set accordingly)
|
||||
*/
|
||||
production?:boolean;
|
||||
/**
|
||||
* Feedback server port (Defaults to: `2196`)
|
||||
*/
|
||||
port?:number;
|
||||
/**
|
||||
* Sets the behaviour for triggering the `feedback` event. When `true` the event will be triggered once per connection with an array of timestamp and device token tuples. Otherwise a `feedback` event will be emitted once per token received. (Defaults to: true)
|
||||
*/
|
||||
batchFeedback?:boolean;
|
||||
/**
|
||||
* The maximum number of tokens to pass when emitting the event - a value of 0 will cause all tokens to be passed after connection is reset. After this number of tokens are received the `feedback` event will be emitted. (Only applies when `batchFeedback` is enabled)
|
||||
*/
|
||||
batchSize?:number;
|
||||
/**
|
||||
* How often to automatically poll the feedback service. Set to `0` to disable. (Defaults to: `3600`)
|
||||
*/
|
||||
interval?:number;
|
||||
}
|
||||
export interface FeedbackData {
|
||||
time:number;
|
||||
device:Device;
|
||||
}
|
||||
/**
|
||||
* Connection to the Apple Push Notification Feedback Service and if `interval` isn't disabled automatically begins polling the service. Many of the options are the same as `apn.Connection()`
|
||||
*/
|
||||
export class Feedback {
|
||||
constructor(options:FeedbackOptions);
|
||||
/**
|
||||
* Trigger a query of the feedback service. If `interval` is non-zero then this method will be called automatically.
|
||||
*/
|
||||
start():void;
|
||||
/**
|
||||
* You can cancel the interval by calling `feedback.cancel()`. If you do not wish to have the service automatically queried then set `interval` to 0 and use `feedback.start()` to manually invoke it one time.
|
||||
*/
|
||||
cancel():void;
|
||||
/**
|
||||
* Emitted when an error occurs initialising the module. Usually caused by failing to load the certificates.
|
||||
*/
|
||||
on(event: "error", listener: (error:Error) => void):Feedback;
|
||||
/**
|
||||
* Emitted when an error occurs receiving or processing the feedback and in the case of a socket error occurring. These errors are usually informational and node-apn will automatically recover.
|
||||
*/
|
||||
on(event: "feedbackError", listener: (error:Error) => void):Feedback;
|
||||
/**
|
||||
* Emitted when data has been received from the feedback service, typically once per connection. `feedbackData` is an array of objects, each containing the `time` returned by the server (epoch time) and the `device` a `Buffer` containing the device token.
|
||||
*/
|
||||
on(event: "feedback", listener: (feedbackData:FeedbackData[]) => void):Feedback;
|
||||
on(event: string, listener: Function):Feedback;
|
||||
}
|
||||
|
||||
export enum Errors {
|
||||
"noErrorsEncountered"= 0,
|
||||
"processingError"= 1,
|
||||
"missingDeviceToken"= 2,
|
||||
"missingTopic"= 3,
|
||||
"missingPayload"= 4,
|
||||
"invalidTokenSize"= 5,
|
||||
"invalidTopicSize"= 6,
|
||||
"invalidPayloadSize"= 7,
|
||||
"invalidToken"= 8,
|
||||
"apnsShutdown"= 10,
|
||||
"none"= 255,
|
||||
"retryLimitExceeded"= 512,
|
||||
"moduleInitialisationFailed"= 513,
|
||||
"connectionRetryLimitExceeded"= 514, // When a connection is unable to be established. Usually because of a network / SSL error this will be emitted
|
||||
"connectionTerminated"= 515
|
||||
}
|
||||
|
||||
//Lowercase aliases
|
||||
export {Connection as connection};
|
||||
export {Device as device};
|
||||
export {Errors as error};
|
||||
export {Feedback as feedback};
|
||||
export {Notification as notification};
|
||||
}
|
||||
+36
-4
@@ -4,21 +4,25 @@
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
interface AutoCollectConsole {
|
||||
constructor(client: Client): AutoCollectConsole;
|
||||
enable(isEnabled: boolean): void;
|
||||
isInitialized(): boolean;
|
||||
}
|
||||
|
||||
interface AutoCollectExceptions {
|
||||
constructor(client:Client): AutoCollectExceptions;
|
||||
isInitialized(): boolean;
|
||||
enable(isEnabled:boolean): void;
|
||||
}
|
||||
|
||||
interface AutoCollectPerformance {
|
||||
constructor(client: Client): AutoCollectPerformance;
|
||||
enable(isEnabled: boolean): void;
|
||||
isInitialized(): boolean;
|
||||
}
|
||||
|
||||
interface AutoCollectRequests {
|
||||
constructor(client: Client): AutoCollectRequests;
|
||||
enable(isEnabled: boolean): void;
|
||||
isInitialized(): boolean;
|
||||
}
|
||||
@@ -85,14 +89,17 @@ declare module ContractsModule {
|
||||
sampleRate: string;
|
||||
internalSdkVersion: string;
|
||||
internalAgentVersion: string;
|
||||
constructor(): ContextTagKeys;
|
||||
}
|
||||
interface Domain {
|
||||
ver: number;
|
||||
properties: any;
|
||||
constructor(): Domain;
|
||||
}
|
||||
interface Data<TDomain extends ContractsModule.Domain> {
|
||||
baseType: string;
|
||||
baseData: TDomain;
|
||||
constructor(): Data<TDomain>;
|
||||
}
|
||||
interface Envelope {
|
||||
ver: number;
|
||||
@@ -112,18 +119,21 @@ declare module ContractsModule {
|
||||
[key: string]: string;
|
||||
};
|
||||
data: Data<Domain>;
|
||||
constructor(): Envelope;
|
||||
}
|
||||
interface EventData extends ContractsModule.Domain {
|
||||
ver: number;
|
||||
name: string;
|
||||
properties: any;
|
||||
measurements: any;
|
||||
constructor(): EventData;
|
||||
}
|
||||
interface MessageData extends ContractsModule.Domain {
|
||||
ver: number;
|
||||
message: string;
|
||||
severityLevel: ContractsModule.SeverityLevel;
|
||||
properties: any;
|
||||
constructor(): MessageData;
|
||||
}
|
||||
interface ExceptionData extends ContractsModule.Domain {
|
||||
ver: number;
|
||||
@@ -134,6 +144,7 @@ declare module ContractsModule {
|
||||
crashThreadId: number;
|
||||
properties: any;
|
||||
measurements: any;
|
||||
constructor(): ExceptionData;
|
||||
}
|
||||
interface StackFrame {
|
||||
level: number;
|
||||
@@ -141,6 +152,7 @@ declare module ContractsModule {
|
||||
assembly: string;
|
||||
fileName: string;
|
||||
line: number;
|
||||
constructor(): StackFrame;
|
||||
}
|
||||
interface ExceptionDetails {
|
||||
id: number;
|
||||
@@ -150,6 +162,7 @@ declare module ContractsModule {
|
||||
hasFullStack: boolean;
|
||||
stack: string;
|
||||
parsedStack: StackFrame[];
|
||||
constructor(): ExceptionDetails;
|
||||
}
|
||||
interface DataPoint {
|
||||
name: string;
|
||||
@@ -159,11 +172,13 @@ declare module ContractsModule {
|
||||
min: number;
|
||||
max: number;
|
||||
stdDev: number;
|
||||
constructor(): DataPoint;
|
||||
}
|
||||
interface MetricData extends ContractsModule.Domain {
|
||||
ver: number;
|
||||
metrics: DataPoint[];
|
||||
properties: any;
|
||||
constructor(): MetricData;
|
||||
}
|
||||
interface PageViewData extends ContractsModule.EventData {
|
||||
ver: number;
|
||||
@@ -172,6 +187,7 @@ declare module ContractsModule {
|
||||
duration: string;
|
||||
properties: any;
|
||||
measurements: any;
|
||||
constructor(): PageViewData;
|
||||
}
|
||||
interface PageViewPerfData extends ContractsModule.PageViewData {
|
||||
ver: number;
|
||||
@@ -185,6 +201,7 @@ declare module ContractsModule {
|
||||
domProcessing: string;
|
||||
properties: any;
|
||||
measurements: any;
|
||||
constructor(): PageViewPerfData;
|
||||
}
|
||||
interface RemoteDependencyData extends ContractsModule.Domain {
|
||||
ver: number;
|
||||
@@ -202,6 +219,7 @@ declare module ContractsModule {
|
||||
commandName: string;
|
||||
dependencyTypeName: string;
|
||||
properties: any;
|
||||
constructor(): RemoteDependencyData;
|
||||
}
|
||||
interface AjaxCallData extends ContractsModule.PageViewData {
|
||||
ver: number;
|
||||
@@ -218,6 +236,7 @@ declare module ContractsModule {
|
||||
success: boolean;
|
||||
properties: any;
|
||||
measurements: any;
|
||||
constructor(): AjaxCallData;
|
||||
}
|
||||
interface RequestData extends ContractsModule.Domain {
|
||||
ver: number;
|
||||
@@ -231,10 +250,12 @@ declare module ContractsModule {
|
||||
url: string;
|
||||
properties: any;
|
||||
measurements: any;
|
||||
constructor(): RequestData;
|
||||
}
|
||||
interface SessionStateData extends ContractsModule.Domain {
|
||||
ver: number;
|
||||
state: ContractsModule.SessionState;
|
||||
constructor(): SessionStateData;
|
||||
}
|
||||
interface PerformanceCounterData extends ContractsModule.Domain {
|
||||
ver: number;
|
||||
@@ -248,6 +269,7 @@ declare module ContractsModule {
|
||||
stdDev: number;
|
||||
value: number;
|
||||
properties: any;
|
||||
constructor(): PerformanceCounterData;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -309,10 +331,14 @@ interface Client {
|
||||
* Log a numeric value that is not associated with a specific event. Typically used to send regular reports of performance indicators.
|
||||
* To send a single measurement, use just the first two parameters. If you take measurements very frequently, you can reduce the
|
||||
* telemetry bandwidth by aggregating multiple measurements and sending the resulting average at intervals.
|
||||
* @param name A string that identifies the metric.
|
||||
* @param value The value of the metric
|
||||
* @param name A string that identifies the metric.
|
||||
* @param value The value of the metric
|
||||
* @param count the number of samples used to get this value
|
||||
* @param min the min sample for this set
|
||||
* @param max the max sample for this set
|
||||
* @param stdDev the standard deviation of the set
|
||||
*/
|
||||
trackMetric(name: string, value: number): void;
|
||||
trackMetric(name: string, value: number, count?:number, min?: number, max?: number, stdDev?: number): void;
|
||||
trackRequest(request: any /* http.ServerRequest */, response: any /* http.ServerResponse */, properties?: {
|
||||
[key: string]: string;
|
||||
}): void;
|
||||
@@ -381,10 +407,16 @@ declare class ApplicationInsights {
|
||||
private static _performance;
|
||||
private static _requests;
|
||||
private static _isStarted;
|
||||
/**
|
||||
* Initializes a client with the given instrumentation key, if this is not specified, the value will be
|
||||
* read from the environment variable APPINSIGHTS_INSTRUMENTATIONKEY
|
||||
* @returns {ApplicationInsights/Client} a new client
|
||||
*/
|
||||
static getClient(instrumentationKey?: string): Client;
|
||||
/**
|
||||
* Initializes the default client of the client and sets the default configuration
|
||||
* @param instrumentationKey the instrumentation key to use. Optional, if this is not specified, the value will be
|
||||
* read from the environment variable APPINSIGHTS_INSTRUMENTATION_KEY
|
||||
* read from the environment variable APPINSIGHTS_INSTRUMENTATIONKEY
|
||||
* @returns {ApplicationInsights} this interface
|
||||
*/
|
||||
static setup(instrumentationKey?: string): typeof ApplicationInsights;
|
||||
|
||||
+121
-16
@@ -5,8 +5,19 @@ var fs, path;
|
||||
function callback() {}
|
||||
|
||||
async.map(['file1', 'file2', 'file3'], fs.stat, function (err, results) { });
|
||||
async.mapSeries(['file1', 'file2', 'file3'], fs.stat, function (err, results) { });
|
||||
async.mapLimit(['file1', 'file2', 'file3'], 2, fs.stat, function (err, results) { });
|
||||
|
||||
async.filter(['file1', 'file2', 'file3'], path.exists, function (results) { });
|
||||
async.filterSeries(['file1', 'file2', 'file3'], path.exists, function (results) { });
|
||||
async.filterLimit(['file1', 'file2', 'file3'], 2, path.exists, function (results) { });
|
||||
async.select(['file1', 'file2', 'file3'], path.exists, function (results) { });
|
||||
async.selectSeries(['file1', 'file2', 'file3'], path.exists, function (results) { });
|
||||
async.selectLimit(['file1', 'file2', 'file3'], 2, path.exists, function (results) { });
|
||||
|
||||
async.reject(['file1', 'file2', 'file3'], path.exists, function (results) { });
|
||||
async.rejectSeries(['file1', 'file2', 'file3'], path.exists, function (results) { });
|
||||
async.rejectLimit(['file1', 'file2', 'file3'], 2, path.exists, function (results) { });
|
||||
|
||||
async.parallel([
|
||||
function () { },
|
||||
@@ -25,6 +36,11 @@ async.map(data, asyncProcess, function (err, results) {
|
||||
});
|
||||
|
||||
var openFiles = ['file1', 'file2'];
|
||||
var openFilesObj = {
|
||||
file1: "fileOne",
|
||||
file2: "fileTwo"
|
||||
}
|
||||
|
||||
var saveFile = function () { }
|
||||
async.each(openFiles, saveFile, function (err) { });
|
||||
async.eachSeries(openFiles, saveFile, function (err) { });
|
||||
@@ -32,18 +48,34 @@ async.eachSeries(openFiles, saveFile, function (err) { });
|
||||
var documents, requestApi;
|
||||
async.eachLimit(documents, 20, requestApi, function (err) { });
|
||||
|
||||
async.map(['file1', 'file2', 'file3'], fs.stat, function (err, results) { });
|
||||
|
||||
async.filter(['file1', 'file2', 'file3'], path.exists, function (results) { });
|
||||
// forEachOf* functions. May accept array or object.
|
||||
function forEachOfIterator(item, key, forEachOfIteratorCallback) {
|
||||
console.log("ForEach: item=" + item + ", key=" + key);
|
||||
forEachOfIteratorCallback();
|
||||
}
|
||||
async.forEachOf(openFiles, forEachOfIterator, function (err) { });
|
||||
async.forEachOf(openFilesObj, forEachOfIterator, function (err) { });
|
||||
async.forEachOfSeries(openFiles, forEachOfIterator, function (err) { });
|
||||
async.forEachOfSeries(openFilesObj, forEachOfIterator, function (err) { });
|
||||
async.forEachOfLimit(openFiles, 2, forEachOfIterator, function (err) { });
|
||||
async.forEachOfLimit(openFilesObj, 2, forEachOfIterator, function (err) { });
|
||||
|
||||
var process;
|
||||
async.reduce([1, 2, 3], 0, function (memo, item, callback) {
|
||||
var numArray = [1, 2, 3];
|
||||
function reducer(memo, item, callback) {
|
||||
process.nextTick(function () {
|
||||
callback(null, memo + item)
|
||||
});
|
||||
}, function (err, result) { });
|
||||
}
|
||||
async.reduce(numArray, 0, reducer, function (err, result) { });
|
||||
async.inject(numArray, 0, reducer, function (err, result) { });
|
||||
async.foldl(numArray, 0, reducer, function (err, result) { });
|
||||
async.reduceRight(numArray, 0, reducer, function (err, result) { });
|
||||
async.foldr(numArray, 0, reducer, function (err, result) { });
|
||||
|
||||
async.detect(['file1', 'file2', 'file3'], path.exists, function (result) { });
|
||||
async.detectSeries(['file1', 'file2', 'file3'], path.exists, function (result) { });
|
||||
async.detectLimit(['file1', 'file2', 'file3'], 2, path.exists, function (result) { });
|
||||
|
||||
async.sortBy(['file1', 'file2', 'file3'], function (file, callback) {
|
||||
fs.stat(file, function (err, stats) {
|
||||
@@ -52,10 +84,18 @@ async.sortBy(['file1', 'file2', 'file3'], function (file, callback) {
|
||||
}, function (err, results) { });
|
||||
|
||||
async.some(['file1', 'file2', 'file3'], path.exists, function (result) { });
|
||||
async.someLimit(['file1', 'file2', 'file3'], 2, path.exists, function (result) { });
|
||||
async.any(['file1', 'file2', 'file3'], path.exists, function (result) { });
|
||||
|
||||
async.every(['file1', 'file2', 'file3'], path.exists, function (result) { });
|
||||
async.everyLimit(['file1', 'file2', 'file3'], 2, path.exists, function (result) { });
|
||||
async.all(['file1', 'file2', 'file3'], path.exists, function (result) { });
|
||||
|
||||
async.concat(['dir1', 'dir2', 'dir3'], fs.readdir, function (err, files) { });
|
||||
async.concatSeries(['dir1', 'dir2', 'dir3'], fs.readdir, function (err, files) { });
|
||||
|
||||
|
||||
// Control Flow //
|
||||
|
||||
async.series([
|
||||
function (callback) {
|
||||
@@ -77,7 +117,6 @@ async.series<string>([
|
||||
],
|
||||
function (err, results) { });
|
||||
|
||||
|
||||
async.series({
|
||||
one: function (callback) {
|
||||
setTimeout(function () {
|
||||
@@ -173,21 +212,47 @@ async.parallel<number>({
|
||||
}, 100);
|
||||
},
|
||||
},
|
||||
function (err, results) { });
|
||||
function (err, results) { });
|
||||
|
||||
|
||||
var count = 0;
|
||||
|
||||
async.whilst(
|
||||
function () { return count < 5; },
|
||||
function (callback) {
|
||||
count++;
|
||||
setTimeout(callback, 1000);
|
||||
async.parallelLimit({
|
||||
one: function (callback) {
|
||||
setTimeout(function () {
|
||||
callback(null, 1);
|
||||
}, 200);
|
||||
},
|
||||
function (err) { }
|
||||
two: function (callback) {
|
||||
setTimeout(function () {
|
||||
callback(null, 2);
|
||||
}, 100);
|
||||
},
|
||||
},
|
||||
2,
|
||||
function (err, results) { }
|
||||
);
|
||||
|
||||
|
||||
function whileFn(callback) {
|
||||
count++;
|
||||
setTimeout(callback, 1000);
|
||||
}
|
||||
|
||||
function whileTest() { return count < 5; }
|
||||
var count = 0;
|
||||
async.whilst(whileTest, whileFn, function (err) { });
|
||||
async.until(whileTest, whileFn, function (err) { });
|
||||
async.doWhilst(whileFn, whileTest, function (err) { });
|
||||
async.doUntil(whileFn, whileTest, function (err) { });
|
||||
|
||||
async.during(function (testCallback) { testCallback(new Error(), false); }, function (callback) { callback() }, function (error) { console.log(error) });
|
||||
async.doDuring(function (callback) { callback() }, function (testCallback) { testCallback(new Error(), false); }, function (error) { console.log(error) });
|
||||
async.forever(function (errBack) {
|
||||
errBack(new Error("Not going on forever."));
|
||||
},
|
||||
function (error) {
|
||||
console.log(error);
|
||||
}
|
||||
);
|
||||
|
||||
async.waterfall([
|
||||
function (callback) {
|
||||
callback(null, 'one', 'two');
|
||||
@@ -279,6 +344,26 @@ q2.unshift(['task3', 'task4', 'task5'], function (error) {
|
||||
console.log('Finished tasks');
|
||||
});
|
||||
|
||||
// create a cargo object with payload 2
|
||||
var cargo = async.cargo(function (tasks, callback) {
|
||||
for (var i = 0; i < tasks.length; i++) {
|
||||
console.log('hello ' + tasks[i].name);
|
||||
}
|
||||
callback();
|
||||
}, 2);
|
||||
|
||||
|
||||
// add some items
|
||||
cargo.push({ name: 'foo' }, function (err) {
|
||||
console.log('finished processing foo');
|
||||
});
|
||||
cargo.push({ name: 'bar' }, function (err) {
|
||||
console.log('finished processing bar');
|
||||
});
|
||||
cargo.push({ name: 'baz' }, function (err) {
|
||||
console.log('finished processing baz');
|
||||
});
|
||||
|
||||
var filename = '';
|
||||
async.auto({
|
||||
get_data: function (callback) { },
|
||||
@@ -291,6 +376,9 @@ async.auto({
|
||||
email_link: ['write_file', <any>function (callback, results) { }]
|
||||
});
|
||||
|
||||
async.retry(3, function (callback, results) { }, function (err, result) { });
|
||||
async.retry({ times: 3, interval: 200 }, function (callback, results) { }, function (err, result) { });
|
||||
|
||||
|
||||
async.parallel([
|
||||
function (callback) { },
|
||||
@@ -336,3 +424,20 @@ var slow_fn = function (name, callback) {
|
||||
};
|
||||
var fn = async.memoize(slow_fn);
|
||||
fn('some name', function () {});
|
||||
async.unmemoize(fn);
|
||||
async.ensureAsync(function () { });
|
||||
async.constant(42);
|
||||
async.asyncify(function () { });
|
||||
|
||||
async.log(function (name, callback) {
|
||||
setTimeout(function () {
|
||||
callback(null, 'hello ' + name);
|
||||
}, 0);
|
||||
}, "world"
|
||||
);
|
||||
|
||||
async.dir(function (name, callback) {
|
||||
setTimeout(function () {
|
||||
callback(null, { hello: name });
|
||||
}, 1000);
|
||||
}, "world");
|
||||
|
||||
Vendored
+162
-129
@@ -1,132 +1,165 @@
|
||||
// Type definitions for Async 0.9.2
|
||||
// Project: https://github.com/caolan/async
|
||||
// Type definitions for Async 1.4.2
|
||||
// Project: https://github.com/caolan/async
|
||||
// Definitions by: Boris Yankov <https://github.com/borisyankov/>, Arseniy Maximov <https://github.com/kern0>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
interface Dictionary<T> { [key: string]: T; }
|
||||
|
||||
// Common interface between Arrays and Array-like objects
|
||||
interface List<T> {
|
||||
[index: number]: T;
|
||||
length: number;
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
interface Dictionary<T> { [key: string]: T; }
|
||||
|
||||
interface ErrorCallback { (err?: Error): void; }
|
||||
interface AsyncResultCallback<T> { (err: Error, result: T): void; }
|
||||
interface AsyncResultArrayCallback<T> { (err: Error, results: T[]): void; }
|
||||
interface AsyncResultObjectCallback<T> { (err: Error, results: Dictionary<T>): void; }
|
||||
|
||||
interface AsyncFunction<T> { (callback: (err: Error, result?: T) => void): void; }
|
||||
interface AsyncIterator<T> { (item: T, callback: ErrorCallback): void; }
|
||||
interface AsyncForEachOfIterator<T> { (item: T, key: number, callback: ErrorCallback): void; }
|
||||
interface AsyncResultIterator<T, R> { (item: T, callback: AsyncResultCallback<R>): void; }
|
||||
interface AsyncMemoIterator<T, R> { (memo: R, item: T, callback: AsyncResultCallback<R>): void; }
|
||||
interface AsyncBooleanIterator<T> { (item: T, callback: (truthValue: boolean) => void): void; }
|
||||
|
||||
interface AsyncWorker<T> { (task: T, callback: ErrorCallback): void; }
|
||||
interface AsyncVoidFunction { (callback: ErrorCallback): void; }
|
||||
|
||||
interface AsyncQueue<T> {
|
||||
length(): number;
|
||||
started: boolean;
|
||||
running(): number;
|
||||
idle(): boolean;
|
||||
concurrency: number;
|
||||
push(task: T, callback?: ErrorCallback): void;
|
||||
push(task: T[], callback?: ErrorCallback): void;
|
||||
unshift(task: T, callback?: ErrorCallback): void;
|
||||
unshift(task: T[], callback?: ErrorCallback): void;
|
||||
saturated: () => any;
|
||||
empty: () => any;
|
||||
drain: () => any;
|
||||
paused: boolean;
|
||||
pause(): void
|
||||
resume(): void;
|
||||
kill(): void;
|
||||
}
|
||||
|
||||
interface ErrorCallback { (err?: Error): void; }
|
||||
interface AsyncResultCallback<T> { (err: Error, result: T): void; }
|
||||
interface AsyncResultArrayCallback<T> { (err: Error, results: T[]): void; }
|
||||
interface AsyncResultObjectCallback<T> { (err: Error, results: Dictionary<T>): void; }
|
||||
|
||||
interface AsyncIterator<T> { (item: T, callback: ErrorCallback): void; }
|
||||
interface AsyncForEachOfIterator<T> { (item: T, index: number, callback: ErrorCallback): void; }
|
||||
interface AsyncResultIterator<T, R> { (item: T, callback: AsyncResultCallback<R>): void; }
|
||||
interface AsyncMemoIterator<T, R> { (memo: R, item: T, callback: AsyncResultCallback<R>): void; }
|
||||
|
||||
interface AsyncWorker<T> { (task: T, callback: ErrorCallback): void; }
|
||||
|
||||
interface AsyncFunction<T> { (callback: AsyncResultCallback<T>): void; }
|
||||
interface AsyncVoidFunction { (callback: ErrorCallback): void; }
|
||||
|
||||
interface AsyncQueue<T> {
|
||||
length(): number;
|
||||
concurrency: number;
|
||||
started: boolean;
|
||||
paused: boolean;
|
||||
push(task: T, callback?: ErrorCallback): void;
|
||||
push(task: T[], callback?: ErrorCallback): void;
|
||||
unshift(task: T, callback?: ErrorCallback): void;
|
||||
unshift(task: T[], callback?: ErrorCallback): void;
|
||||
saturated: () => any;
|
||||
empty: () => any;
|
||||
drain: () => any;
|
||||
running(): number;
|
||||
idle(): boolean;
|
||||
pause(): void;
|
||||
resume(): void;
|
||||
kill(): void;
|
||||
}
|
||||
|
||||
interface AsyncPriorityQueue<T> {
|
||||
length(): number;
|
||||
concurrency: number;
|
||||
started: boolean;
|
||||
paused: boolean;
|
||||
push(task: T, priority: number, callback?: AsyncResultArrayCallback<T>): void;
|
||||
push(task: T[], priority: number, callback?: AsyncResultArrayCallback<T>): void;
|
||||
saturated: () => any;
|
||||
empty: () => any;
|
||||
drain: () => any;
|
||||
running(): number;
|
||||
idle(): boolean;
|
||||
pause(): void;
|
||||
resume(): void;
|
||||
kill(): void;
|
||||
}
|
||||
|
||||
interface Async {
|
||||
|
||||
// Collections
|
||||
each<T>(arr: T[], iterator: AsyncIterator<T>, callback: ErrorCallback): void;
|
||||
eachSeries<T>(arr: T[], iterator: AsyncIterator<T>, callback: ErrorCallback): void;
|
||||
eachLimit<T>(arr: T[], limit: number, iterator: AsyncIterator<T>, callback: ErrorCallback): void;
|
||||
forEachOf<T>(obj: List<T>, iterator: AsyncForEachOfIterator<T>, callback: ErrorCallback): void;
|
||||
forEachOfSeries<T>(obj: List<T>, iterator: AsyncForEachOfIterator<T>, callback: ErrorCallback): void;
|
||||
forEachOfLimit<T>(obj: List<T>, limit: number, iterator: AsyncForEachOfIterator<T>, callback: ErrorCallback): void;
|
||||
map<T, R>(arr: T[], iterator: AsyncResultIterator<T, R>, callback: AsyncResultArrayCallback<R>): any;
|
||||
mapSeries<T, R>(arr: T[], iterator: AsyncResultIterator<T, R>, callback: AsyncResultArrayCallback<R>): any;
|
||||
mapLimit<T, R>(arr: T[], limit: number, iterator: AsyncResultIterator<T, R>, callback: AsyncResultArrayCallback<R>): any;
|
||||
filter<T>(arr: T[], iterator: AsyncResultIterator<T, boolean>, callback: (results: T[]) => any): any;
|
||||
select<T>(arr: T[], iterator: AsyncResultIterator<T, boolean>, callback: (results: T[]) => any): any;
|
||||
filterSeries<T>(arr: T[], iterator: AsyncResultIterator<T, boolean>, callback: (results: T[]) => any): any;
|
||||
selectSeries<T>(arr: T[], iterator: AsyncResultIterator<T, boolean>, callback: (results: T[]) => any): any;
|
||||
reject<T>(arr: T[], iterator: AsyncResultIterator<T, boolean>, callback: (results: T[]) => any): any;
|
||||
rejectSeries<T>(arr: T[], iterator: AsyncResultIterator<T, boolean>, callback: (results: T[]) => any): any;
|
||||
reduce<T, R>(arr: T[], memo: R, iterator: AsyncMemoIterator<T, R>, callback: AsyncResultCallback<R>): any;
|
||||
inject<T, R>(arr: T[], memo: R, iterator: AsyncMemoIterator<T, R>, callback: AsyncResultCallback<R>): any;
|
||||
foldl<T, R>(arr: T[], memo: R, iterator: AsyncMemoIterator<T, R>, callback: AsyncResultCallback<R>): any;
|
||||
reduceRight<T, R>(arr: T[], memo: R, iterator: AsyncMemoIterator<T, R>, callback: AsyncResultCallback<R>): any;
|
||||
foldr<T, R>(arr: T[], memo: R, iterator: AsyncMemoIterator<T, R>, callback: AsyncResultCallback<R>): any;
|
||||
detect<T>(arr: T[], iterator: AsyncResultIterator<T, boolean>, callback: AsyncResultArrayCallback<T>): any;
|
||||
detectSeries<T>(arr: T[], iterator: AsyncResultIterator<T, boolean>, callback: AsyncResultArrayCallback<T>): any;
|
||||
sortBy<T, V>(arr: T[], iterator: AsyncResultIterator<T, V>, callback: AsyncResultArrayCallback<T>): any;
|
||||
some<T>(arr: T[], iterator: AsyncResultIterator<T, boolean>, callback: AsyncResultArrayCallback<T>): any;
|
||||
any<T>(arr: T[], iterator: AsyncResultIterator<T, boolean>, callback: AsyncResultArrayCallback<T>): any;
|
||||
every<T>(arr: T[], iterator: AsyncResultIterator<T, boolean>, callback: (result: boolean) => any): any;
|
||||
all<T>(arr: T[], iterator: AsyncResultIterator<T, boolean>, callback: (result: boolean) => any): any;
|
||||
concat<T, R>(arr: T[], iterator: AsyncResultIterator<T, R[]>, callback: AsyncResultArrayCallback<R>): any;
|
||||
concatSeries<T, R>(arr: T[], iterator: AsyncResultIterator<T, R[]>, callback: AsyncResultArrayCallback<R>): any;
|
||||
|
||||
// Control Flow
|
||||
series<T>(tasks: Array<AsyncFunction<T>>, callback?: AsyncResultArrayCallback<T>): void;
|
||||
series<T>(tasks: Dictionary<AsyncFunction<T>>, callback?: AsyncResultObjectCallback<T>): void;
|
||||
parallel<T>(tasks: Array<AsyncFunction<T>>, callback?: AsyncResultArrayCallback<T>): void;
|
||||
parallel<T>(tasks: Dictionary<AsyncFunction<T>>, callback?: AsyncResultObjectCallback<T>): void;
|
||||
parallelLimit<T>(tasks: Array<AsyncFunction<T>>, limit: number, callback?: AsyncResultArrayCallback<T>): void;
|
||||
parallelLimit<T>(tasks: Dictionary<AsyncFunction<T>>, limit: number, callback?: AsyncResultObjectCallback<T>): void;
|
||||
whilst(test: () => boolean, fn: AsyncVoidFunction, callback: (err: any) => void): void;
|
||||
doWhilst(fn: AsyncVoidFunction, test: () => boolean, callback: (err: any) => void): void;
|
||||
until(test: () => boolean, fn: AsyncVoidFunction, callback: (err: any) => void): void;
|
||||
doUntil(fn: AsyncVoidFunction, test: () => boolean, callback: (err: any) => void): void;
|
||||
waterfall(tasks: Function[], callback?: (err: any, ...arguments: any[]) => void): void;
|
||||
queue<T>(worker: AsyncWorker<T>, concurrency: number): AsyncQueue<T>;
|
||||
priorityQueue<T>(worker: AsyncWorker<T>, concurrency: number): AsyncPriorityQueue<T>;
|
||||
auto(tasks: any, callback?: AsyncResultArrayCallback<any>): void;
|
||||
iterator(tasks: Function[]): Function;
|
||||
apply(fn: Function, ...arguments: any[]): AsyncFunction<any>;
|
||||
nextTick(callback: Function): void;
|
||||
|
||||
times<R> (n: number, iterator: AsyncResultIterator<number, R>, callback: AsyncResultArrayCallback<R>): void;
|
||||
timesSeries<R> (n: number, iterator: AsyncResultIterator<number, R>, callback: AsyncResultArrayCallback<R>): void;
|
||||
|
||||
// Utils
|
||||
memoize(fn: Function, hasher?: Function): Function;
|
||||
unmemoize(fn: Function): Function;
|
||||
log(fn: Function, ...arguments: any[]): void;
|
||||
dir(fn: Function, ...arguments: any[]): void;
|
||||
noConflict(): Async;
|
||||
}
|
||||
|
||||
declare var async: Async;
|
||||
|
||||
declare module "async" {
|
||||
export = async;
|
||||
}
|
||||
interface AsyncPriorityQueue<T> {
|
||||
length(): number;
|
||||
concurrency: number;
|
||||
started: boolean;
|
||||
paused: boolean;
|
||||
push(task: T, priority: number, callback?: AsyncResultArrayCallback<T>): void;
|
||||
push(task: T[], priority: number, callback?: AsyncResultArrayCallback<T>): void;
|
||||
saturated: () => any;
|
||||
empty: () => any;
|
||||
drain: () => any;
|
||||
running(): number;
|
||||
idle(): boolean;
|
||||
pause(): void;
|
||||
resume(): void;
|
||||
kill(): void;
|
||||
}
|
||||
|
||||
interface AsyncCargo {
|
||||
length(): number;
|
||||
payload: number;
|
||||
push(task: any, callback? : Function): void;
|
||||
push(task: any[], callback? : Function): void;
|
||||
saturated(): void;
|
||||
empty(): void;
|
||||
drain(): void;
|
||||
idle(): boolean;
|
||||
pause(): void;
|
||||
resume(): void;
|
||||
kill(): void;
|
||||
}
|
||||
|
||||
interface Async {
|
||||
|
||||
// Collections
|
||||
each<T>(arr: T[], iterator: AsyncIterator<T>, callback?: ErrorCallback): void;
|
||||
eachSeries<T>(arr: T[], iterator: AsyncIterator<T>, callback?: ErrorCallback): void;
|
||||
eachLimit<T>(arr: T[], limit: number, iterator: AsyncIterator<T>, callback?: ErrorCallback): void;
|
||||
forEachOf(obj: any, iterator: (item: any, key: [string|number], callback?: ErrorCallback) => void, callback: ErrorCallback): void;
|
||||
forEachOf<T>(obj: T[], iterator: AsyncForEachOfIterator<T>, callback?: ErrorCallback): void;
|
||||
forEachOfSeries(obj: any, iterator: (item: any, key: [string|number], callback?: ErrorCallback) => void, callback: ErrorCallback): void;
|
||||
forEachOfSeries<T>(obj: T[], iterator: AsyncForEachOfIterator<T>, callback?: ErrorCallback): void;
|
||||
forEachOfLimit(obj: any, limit: number, iterator: (item: any, key: [string|number], callback?: ErrorCallback) => void, callback: ErrorCallback): void;
|
||||
forEachOfLimit<T>(obj: T[], limit: number, iterator: AsyncForEachOfIterator<T>, callback?: ErrorCallback): void;
|
||||
map<T, R>(arr: T[], iterator: AsyncResultIterator<T, R>, callback?: AsyncResultArrayCallback<R>): any;
|
||||
mapSeries<T, R>(arr: T[], iterator: AsyncResultIterator<T, R>, callback?: AsyncResultArrayCallback<R>): any;
|
||||
mapLimit<T, R>(arr: T[], limit: number, iterator: AsyncResultIterator<T, R>, callback?: AsyncResultArrayCallback<R>): any;
|
||||
filter<T>(arr: T[], iterator: AsyncResultIterator<T, boolean>, callback?: (results: T[]) => any): any;
|
||||
select<T>(arr: T[], iterator: AsyncResultIterator<T, boolean>, callback?: (results: T[]) => any): any;
|
||||
filterSeries<T>(arr: T[], iterator: AsyncResultIterator<T, boolean>, callback?: (results: T[]) => any): any;
|
||||
selectSeries<T>(arr: T[], iterator: AsyncResultIterator<T, boolean>, callback?: (results: T[]) => any): any;
|
||||
filterLimit<T>(arr: T[], limit: number, iterator: AsyncResultIterator<T, boolean>, callback?: (results: T[]) => any): any;
|
||||
selectLimit<T>(arr: T[], limit: number, iterator: AsyncResultIterator<T, boolean>, callback?: (results: T[]) => any): any;
|
||||
reject<T>(arr: T[], iterator: AsyncResultIterator<T, boolean>, callback?: (results: T[]) => any): any;
|
||||
rejectSeries<T>(arr: T[], iterator: AsyncResultIterator<T, boolean>, callback?: (results: T[]) => any): any;
|
||||
rejectLimit<T>(arr: T[], limit: number, iterator: AsyncResultIterator<T, boolean>, callback?: (results: T[]) => any): any;
|
||||
reduce<T, R>(arr: T[], memo: R, iterator: AsyncMemoIterator<T, R>, callback?: AsyncResultCallback<R>): any;
|
||||
inject<T, R>(arr: T[], memo: R, iterator: AsyncMemoIterator<T, R>, callback?: AsyncResultCallback<R>): any;
|
||||
foldl<T, R>(arr: T[], memo: R, iterator: AsyncMemoIterator<T, R>, callback?: AsyncResultCallback<R>): any;
|
||||
reduceRight<T, R>(arr: T[], memo: R, iterator: AsyncMemoIterator<T, R>, callback: AsyncResultCallback<R>): any;
|
||||
foldr<T, R>(arr: T[], memo: R, iterator: AsyncMemoIterator<T, R>, callback: AsyncResultCallback<R>): any;
|
||||
detect<T>(arr: T[], iterator: AsyncBooleanIterator<T>, callback?: (result: T) => void): any;
|
||||
detectSeries<T>(arr: T[], iterator: AsyncBooleanIterator<T>, callback?: (result: T) => void): any;
|
||||
detectLimit<T>(arr: T[], limit: number, iterator: AsyncBooleanIterator<T>, callback?: (result: T) => void): any;
|
||||
sortBy<T, V>(arr: T[], iterator: AsyncResultIterator<T, V>, callback?: AsyncResultArrayCallback<T>): any;
|
||||
some<T>(arr: T[], iterator: AsyncBooleanIterator<T>, callback?: (result: boolean) => void): any;
|
||||
someLimit<T>(arr: T[], limit: number, iterator: AsyncBooleanIterator<T>, callback?: (result: boolean) => void): any;
|
||||
any<T>(arr: T[], iterator: AsyncBooleanIterator<T>, callback?: (result: boolean) => void): any;
|
||||
every<T>(arr: T[], iterator: AsyncBooleanIterator<T>, callback?: (result: boolean) => any): any;
|
||||
everyLimit<T>(arr: T[], limit: number, iterator: AsyncBooleanIterator<T>, callback?: (result: boolean) => any): any;
|
||||
all<T>(arr: T[], iterator: AsyncBooleanIterator<T>, callback?: (result: boolean) => any): any;
|
||||
concat<T, R>(arr: T[], iterator: AsyncResultIterator<T, R[]>, callback?: AsyncResultArrayCallback<R>): any;
|
||||
concatSeries<T, R>(arr: T[], iterator: AsyncResultIterator<T, R[]>, callback?: AsyncResultArrayCallback<R>): any;
|
||||
|
||||
// Control Flow
|
||||
series<T>(tasks: AsyncFunction<T>[], callback?: AsyncResultArrayCallback<T>): void;
|
||||
series<T>(tasks: Dictionary<AsyncFunction<T>>, callback?: AsyncResultObjectCallback<T>): void;
|
||||
parallel<T>(tasks: Array<AsyncFunction<T>>, callback?: AsyncResultArrayCallback<T>): void;
|
||||
parallel<T>(tasks: Dictionary<AsyncFunction<T>>, callback?: AsyncResultObjectCallback<T>): void;
|
||||
parallelLimit<T>(tasks: Array<AsyncFunction<T>>, limit: number, callback?: AsyncResultArrayCallback<T>): void;
|
||||
parallelLimit<T>(tasks: Dictionary<AsyncFunction<T>>, limit: number, callback?: AsyncResultObjectCallback<T>): void;
|
||||
whilst(test: () => boolean, fn: AsyncVoidFunction, callback: (err: any) => void): void;
|
||||
doWhilst(fn: AsyncVoidFunction, test: () => boolean, callback: (err: any) => void): void;
|
||||
until(test: () => boolean, fn: AsyncVoidFunction, callback: (err: any) => void): void;
|
||||
doUntil(fn: AsyncVoidFunction, test: () => boolean, callback: (err: any) => void): void;
|
||||
during(test: (testCallback : (error: Error, truth: boolean) => void) => void, fn: AsyncVoidFunction, callback: (err: any) => void): void;
|
||||
doDuring(fn: AsyncVoidFunction, test: (testCallback: (error: Error, truth: boolean) => void) => void, callback: (err: any) => void): void;
|
||||
forever(next: (errCallback : (err: Error) => void) => void, errBack: (err: Error) => void) : void;
|
||||
waterfall(tasks: Function[], callback?: (err: Error, result: any) => void): void;
|
||||
compose(...fns: Function[]): void;
|
||||
seq(...fns: Function[]): void;
|
||||
applyEach(fns: Function[], argsAndCallback: any[]): void; // applyEach(fns, args..., callback). TS does not support ... for a middle argument. Callback is optional.
|
||||
applyEachSeries(fns: Function[], argsAndCallback: any[]): void; // applyEachSeries(fns, args..., callback). TS does not support ... for a middle argument. Callback is optional.
|
||||
queue<T>(worker: AsyncWorker<T>, concurrency?: number): AsyncQueue<T>;
|
||||
priorityQueue<T>(worker: AsyncWorker<T>, concurrency: number): AsyncPriorityQueue<T>;
|
||||
cargo(worker : (tasks: any[], callback : ErrorCallback) => void, payload? : number) : AsyncCargo;
|
||||
auto(tasks: any, callback?: (error: Error, results: any) => void): void;
|
||||
retry<T>(opts: number, task: (callback : AsyncResultCallback<T>, results: any) => void, callback: (error: Error, results: any) => void): void;
|
||||
retry<T>(opts: { times: number, interval: number }, task: (callback: AsyncResultCallback<T>, results : any) => void, callback: (error: Error, results: any) => void): void;
|
||||
iterator(tasks: Function[]): Function;
|
||||
apply(fn: Function, ...arguments: any[]): AsyncFunction<any>;
|
||||
nextTick(callback: Function): void;
|
||||
setImmediate(callback: Function): void;
|
||||
|
||||
times<T> (n: number, iterator: AsyncResultIterator<number, T>, callback: AsyncResultArrayCallback<T>): void;
|
||||
timesSeries<T>(n: number, iterator: AsyncResultIterator<number, T>, callback: AsyncResultArrayCallback<T>): void;
|
||||
timesLimit<T>(n: number, limit: number, iterator: AsyncResultIterator<number, T>, callback: AsyncResultArrayCallback<T>): void;
|
||||
|
||||
// Utils
|
||||
memoize(fn: Function, hasher?: Function): Function;
|
||||
unmemoize(fn: Function): Function;
|
||||
ensureAsync(fn: (... argsAndCallback: any[]) => void): Function;
|
||||
constant(...values: any[]): Function;
|
||||
asyncify(fn: Function): Function;
|
||||
wrapSync(fn: Function): Function;
|
||||
log(fn: Function, ...arguments: any[]): void;
|
||||
dir(fn: Function, ...arguments: any[]): void;
|
||||
noConflict(): Async;
|
||||
}
|
||||
|
||||
declare var async: Async;
|
||||
|
||||
declare module "async" {
|
||||
export = async;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
/// <reference path="auto-launch.d.ts" />
|
||||
|
||||
import AutoLaunch = require('auto-launch');
|
||||
|
||||
var a1 = new AutoLaunch({
|
||||
name: 'Foo',
|
||||
});
|
||||
|
||||
var a2 = new AutoLaunch({
|
||||
name: 'Foo',
|
||||
path: '/Applications/Foo.app',
|
||||
isHidden: true,
|
||||
});
|
||||
|
||||
a1.enable();
|
||||
a2.disable();
|
||||
var enabled: boolean = a1.isEnabled();
|
||||
Vendored
+41
@@ -0,0 +1,41 @@
|
||||
// Type definitions for auto-launch 0.1.18
|
||||
// Project: https://github.com/Teamwork/node-auto-launch
|
||||
// Definitions by: rhysd <https://github.com/rhysd>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
interface AutoLaunchOption {
|
||||
/**
|
||||
* Application name.
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* Hidden on launch or not. Default is false.
|
||||
*/
|
||||
isHidden?: boolean;
|
||||
/**
|
||||
* Path to application directory.
|
||||
* Default is process.execPath.
|
||||
*/
|
||||
path?: string;
|
||||
}
|
||||
|
||||
declare class AutoLaunch {
|
||||
constructor(opts: AutoLaunchOption);
|
||||
/**
|
||||
* Enables to launch at start up
|
||||
*/
|
||||
enable(callback?: (err: Error) => void): void;
|
||||
/**
|
||||
* Disables to launch at start up
|
||||
*/
|
||||
disable(callback?: (err: Error) => void): void;
|
||||
/**
|
||||
* Returns if auto start up is enabled
|
||||
*/
|
||||
isEnabled(callback?: (err: Error) => void): boolean;
|
||||
}
|
||||
|
||||
declare module "auto-launch" {
|
||||
var al: typeof AutoLaunch;
|
||||
export = al;
|
||||
}
|
||||
@@ -11,6 +11,7 @@ declare module Backbone {
|
||||
|
||||
interface LayoutOptions<TModel extends Model> extends ViewOptions<TModel> {
|
||||
template?: string;
|
||||
views?: { [viewName: string]: View<TModel> };
|
||||
}
|
||||
|
||||
interface LayoutManagerOptions {
|
||||
|
||||
Vendored
+2
-1
@@ -309,7 +309,8 @@ declare module Backbone {
|
||||
|
||||
interface ViewOptions<TModel extends Model> {
|
||||
model?: TModel;
|
||||
collection?: Backbone.Collection<TModel>;
|
||||
// TODO: quickfix, this can't be fixed easy. The collection does not need to have the same model as the parent view.
|
||||
collection?: Backbone.Collection<any>;
|
||||
el?: any;
|
||||
id?: string;
|
||||
className?: string;
|
||||
|
||||
Vendored
+6
-4
@@ -10,10 +10,10 @@ declare module Backgrid {
|
||||
interface GridOptions {
|
||||
columns: Column[];
|
||||
collection: Backbone.Collection<Backbone.Model>;
|
||||
header: Header;
|
||||
body: Body;
|
||||
row: Row;
|
||||
footer: Footer;
|
||||
header?: Header;
|
||||
body?: Body;
|
||||
row?: Row;
|
||||
footer?: Footer;
|
||||
}
|
||||
|
||||
class Header extends Backbone.View<Backbone.Model> {
|
||||
@@ -109,6 +109,8 @@ declare module Backgrid {
|
||||
header: any;
|
||||
tagName: string;
|
||||
|
||||
constructor(options: GridOptions);
|
||||
|
||||
initialize(options: any);
|
||||
getSelectedModels(): Backbone.Model[];
|
||||
insertColumn(...options: any[]): Grid;
|
||||
|
||||
@@ -39,7 +39,7 @@ module bardTests {
|
||||
var myService: MyService;
|
||||
var $rootScope: angular.IRootScopeService;
|
||||
|
||||
beforeEach(module(bard.$httpBackend, 'myModule'));
|
||||
beforeEach(angular.mock.module(bard.$httpBackend, 'myModule'));
|
||||
|
||||
beforeEach(inject(function(_myService_: MyService, _$rootScope_: angular.IRootScopeService) {
|
||||
myService = _myService_;
|
||||
@@ -63,7 +63,7 @@ module bardTests {
|
||||
function test_$q() {
|
||||
var myService: MyService;
|
||||
|
||||
beforeEach(module(bard.$q, bard.$httpBackend, 'myModule'));
|
||||
beforeEach(angular.mock.module(bard.$q, bard.$httpBackend, 'myModule'));
|
||||
|
||||
beforeEach(inject(function(_myService_: MyService) {
|
||||
myService = _myService_;
|
||||
@@ -139,7 +139,7 @@ module bardTests {
|
||||
* bard.fakeLogger
|
||||
*/
|
||||
function test_fakeLogger() {
|
||||
beforeEach(module('myModule', bard.fakeLogger));
|
||||
beforeEach(angular.mock.module('myModule', bard.fakeLogger));
|
||||
////
|
||||
beforeEach(bard.appModule('myModule', bard.fakeLogger));
|
||||
////
|
||||
@@ -150,7 +150,7 @@ module bardTests {
|
||||
* bard.fakeRouteHelperProvider
|
||||
*/
|
||||
function test_fakeRouteHelperProvider() {
|
||||
beforeEach(module('myModule', bard.fakeRouteHelperProvider));
|
||||
beforeEach(angular.mock.module('myModule', bard.fakeRouteHelperProvider));
|
||||
////
|
||||
beforeEach(bard.appModule('myModule', bard.fakeRouteHelperProvider));
|
||||
////
|
||||
@@ -161,7 +161,7 @@ module bardTests {
|
||||
* bard.fakeRouteProvider
|
||||
*/
|
||||
function test_fakeRouteProvider() {
|
||||
beforeEach(module('myModule', bard.fakeRouteProvider));
|
||||
beforeEach(angular.mock.module('myModule', bard.fakeRouteProvider));
|
||||
////
|
||||
beforeEach(bard.appModule('myModule', bard.fakeRouteProvider));
|
||||
////
|
||||
@@ -172,7 +172,7 @@ module bardTests {
|
||||
* bard.fakeStateProvider
|
||||
*/
|
||||
function test_fakeStateProvider() {
|
||||
beforeEach(module('myModule', bard.fakeStateProvider));
|
||||
beforeEach(angular.mock.module('myModule', bard.fakeStateProvider));
|
||||
////
|
||||
beforeEach(bard.appModule('myModule', bard.fakeStateProvider));
|
||||
////
|
||||
@@ -183,7 +183,7 @@ module bardTests {
|
||||
* bard.fakeToastr
|
||||
*/
|
||||
function test_fakeToastr() {
|
||||
beforeEach(module('myModule', bard.fakeToastr));
|
||||
beforeEach(angular.mock.module('myModule', bard.fakeToastr));
|
||||
////
|
||||
beforeEach(bard.appModule('myModule', bard.fakeToastr));
|
||||
////
|
||||
|
||||
Vendored
+5
@@ -579,6 +579,8 @@ interface ViewPrototype {
|
||||
route?: any;
|
||||
url?: string
|
||||
};
|
||||
|
||||
[propertyName: string]: any;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////
|
||||
@@ -643,6 +645,8 @@ interface ModelPrototype {
|
||||
destroy?: { url?: string };
|
||||
update?: { url?: string };
|
||||
};
|
||||
|
||||
[propertyName: string]: string | boolean | Object | Validator;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////
|
||||
@@ -682,6 +686,7 @@ interface CollectionPrototype {
|
||||
destroy?: { url?: string };
|
||||
update?: { url?: string };
|
||||
};
|
||||
[propertyName: string]: any;
|
||||
}
|
||||
|
||||
interface Extendable<T> {
|
||||
|
||||
Vendored
+17
-10
@@ -1,4 +1,4 @@
|
||||
// Type definitions for Bootstrap 2.2
|
||||
// Type definitions for Bootstrap 3.3.5
|
||||
// Project: http://twitter.github.com/bootstrap/
|
||||
// Definitions by: Boris Yankov <https://github.com/borisyankov/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
@@ -27,24 +27,28 @@ interface ScrollSpyOptions {
|
||||
interface TooltipOptions {
|
||||
animation?: boolean;
|
||||
html?: boolean;
|
||||
placement?: any;
|
||||
placement?: string | Function;
|
||||
selector?: string;
|
||||
title?: any;
|
||||
title?: string | Function;
|
||||
trigger?: string;
|
||||
delay?: any;
|
||||
container?: any;
|
||||
template?: string;
|
||||
delay?: number | Object;
|
||||
container?: string | boolean;
|
||||
viewport?: string | Function | Object;
|
||||
}
|
||||
|
||||
interface PopoverOptions {
|
||||
animation?: boolean;
|
||||
html?: boolean;
|
||||
placement?: any;
|
||||
placement?: string | Function;
|
||||
selector?: string;
|
||||
trigger?: string;
|
||||
title?: any;
|
||||
title?: string | Function;
|
||||
template?: string;
|
||||
content?: any;
|
||||
delay?: any;
|
||||
container?: any;
|
||||
delay?: number | Object;
|
||||
container?: string | boolean;
|
||||
viewport?: string | Function | Object;
|
||||
}
|
||||
|
||||
interface CollapseOptions {
|
||||
@@ -55,6 +59,8 @@ interface CollapseOptions {
|
||||
interface CarouselOptions {
|
||||
interval?: number;
|
||||
pause?: string;
|
||||
wrap?: boolean;
|
||||
keybord?: boolean;
|
||||
}
|
||||
|
||||
interface TypeaheadOptions {
|
||||
@@ -68,7 +74,8 @@ interface TypeaheadOptions {
|
||||
}
|
||||
|
||||
interface AffixOptions {
|
||||
offset?: any;
|
||||
offset?: number | Function | Object;
|
||||
target?: any;
|
||||
}
|
||||
|
||||
interface JQuery {
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
import Bowser = require('bowser');
|
||||
|
||||
Bowser.msedge === true;
|
||||
Bowser.test(['msie']) === true;
|
||||
Bowser.a === Bowser.c;
|
||||
Bowser.osversion > 10;
|
||||
Bowser.osversion === '10.1A';
|
||||
Vendored
+54
@@ -0,0 +1,54 @@
|
||||
// Type definitions for Bowser 1.x
|
||||
// Project: https://github.com/ded/bowser
|
||||
// Definitions by: Paulo Cesar <https://github.com/pocesar>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
declare module 'bowser' {
|
||||
var def: BowserModule.IBowser;
|
||||
export = def;
|
||||
}
|
||||
|
||||
declare module BowserModule {
|
||||
|
||||
export interface IBowserUA {
|
||||
msie: boolean;
|
||||
chrome: boolean;
|
||||
webkit: boolean;
|
||||
phantom: boolean;
|
||||
opera: boolean;
|
||||
safari: boolean;
|
||||
android: boolean;
|
||||
ios: boolean;
|
||||
webos: boolean;
|
||||
msedge: boolean;
|
||||
seamonkey: boolean;
|
||||
firefox: boolean;
|
||||
yandexbrowser: boolean;
|
||||
blackberry: boolean;
|
||||
tablet: boolean;
|
||||
mobile: boolean;
|
||||
silk: boolean;
|
||||
bada: boolean;
|
||||
tizen: boolean;
|
||||
windowsphone: boolean;
|
||||
firefoxos: boolean;
|
||||
gecko: boolean;
|
||||
sailfish: boolean;
|
||||
chromeBook: boolean;
|
||||
/** Grade A browser */
|
||||
a: boolean;
|
||||
/** Grade C browser */
|
||||
c: boolean;
|
||||
/** Grade X browser */
|
||||
x: boolean;
|
||||
name: string;
|
||||
version: string;
|
||||
osversion: string|number;
|
||||
}
|
||||
|
||||
export interface IBowser extends IBowserUA {
|
||||
test(browserList: string[]): boolean;
|
||||
_detect(ua: string): IBowser;
|
||||
}
|
||||
|
||||
}
|
||||
Vendored
+1
@@ -459,6 +459,7 @@ declare module breeze {
|
||||
interface EntityManagerProperties {
|
||||
serviceName?: string;
|
||||
dataService?: DataService;
|
||||
metadataStore?: MetadataStore;
|
||||
queryOptions?: QueryOptions;
|
||||
saveOptions?: SaveOptions;
|
||||
validationOptions?: ValidationOptions;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/// <reference path="bunyan.d.ts" />
|
||||
|
||||
import bunyan = require('bunyan');
|
||||
import * as bunyan from 'bunyan';
|
||||
|
||||
var ringBufferOptions:bunyan.RingBufferOptions = {
|
||||
limit: 100
|
||||
|
||||
Vendored
+3
-5
@@ -6,9 +6,7 @@
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
|
||||
declare module "bunyan" {
|
||||
import events = require('events');
|
||||
import EventEmitter = events.EventEmitter;
|
||||
import WritableStream = NodeJS.WritableStream;
|
||||
import { EventEmitter } from 'events';
|
||||
|
||||
class Logger extends EventEmitter {
|
||||
constructor(options:LoggerOptions);
|
||||
@@ -52,7 +50,7 @@ declare module "bunyan" {
|
||||
name: string;
|
||||
streams?: Stream[];
|
||||
level?: string | number;
|
||||
stream?: WritableStream;
|
||||
stream?: NodeJS.WritableStream;
|
||||
serializers?: Serializers;
|
||||
src?: boolean;
|
||||
}
|
||||
@@ -65,7 +63,7 @@ declare module "bunyan" {
|
||||
type?: string;
|
||||
level?: number | string;
|
||||
path?: string;
|
||||
stream?: WritableStream | Stream;
|
||||
stream?: NodeJS.WritableStream | Stream;
|
||||
closeOnExit?: boolean;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,23 +1,54 @@
|
||||
/// <reference path="chai-as-promised.d.ts" />
|
||||
/// <reference path="../promises-a-plus/promises-a-plus.d.ts" />
|
||||
/// <reference path="../q/Q.d.ts" />
|
||||
|
||||
import chai = require('chai');
|
||||
import chaiAsPromised = require('chai-as-promised');
|
||||
import Q = require('q');
|
||||
|
||||
chai.use(chaiAsPromised);
|
||||
|
||||
// ReSharper disable WrongExpressionStatement
|
||||
var promise: any;
|
||||
chai.expect(promise).to.eventually.equal(3);
|
||||
chai.expect(promise).to.become(3);
|
||||
chai.expect(promise).to.be.fulfilled;
|
||||
chai.expect(promise).to.be.rejected;
|
||||
chai.expect(promise).to.be.rejectedWith(Error);
|
||||
chai.expect(promise).to.notify(() => console.log('done'));
|
||||
// BDD API (expect)
|
||||
var thenableNum: PromisesAPlus.Thenable<number>;
|
||||
thenableNum = chai.expect(thenableNum).to.eventually.equal(3);
|
||||
thenableNum = chai.expect(thenableNum).to.eventually.have.property('foo');
|
||||
thenableNum = chai.expect(thenableNum).to.become(3);
|
||||
thenableNum = chai.expect(thenableNum).to.be.fulfilled;
|
||||
thenableNum = chai.expect(thenableNum).to.be.rejected;
|
||||
thenableNum = chai.expect(thenableNum).to.be.rejectedWith(Error);
|
||||
thenableNum = chai.expect(thenableNum).to.notify(() => console.log('done'));
|
||||
|
||||
chai.assert.eventually.equal(promise, 4, 'Message');
|
||||
chai.assert.isFulfilled(promise, "optional message");
|
||||
chai.assert.becomes(promise, "foo", "optional message");
|
||||
chai.assert.doesNotBecome(promise, "foo", "optional message");
|
||||
chai.assert.isRejected(promise, "optional message");
|
||||
chai.assert.isRejected(promise, Error, "optional message");
|
||||
chai.assert.isRejected(promise, /error message matcher/, "optional message");
|
||||
// BDD API (should)
|
||||
thenableNum = thenableNum.should.be.fulfilled;
|
||||
thenableNum = thenableNum.should.eventually.deep.equal(3);
|
||||
thenableNum = thenableNum.should.become(3);
|
||||
thenableNum = thenableNum.should.be.rejected;
|
||||
thenableNum = thenableNum.should.be.rejectedWith(Error);
|
||||
thenableNum = thenableNum.should.eventually.equal(3).notify(() => console.log('done'));
|
||||
thenableNum = thenableNum.should.be.fulfilled.and.notify(() => console.log('done'));
|
||||
|
||||
// Complex examples on https://github.com/domenic/chai-as-promised#working-with-non-promisefriendly-test-runners
|
||||
thenableNum.should.be.fulfilled.then(function () {
|
||||
thenableNum.should.equal("after");
|
||||
}).should.notify(() => console.log('done'));
|
||||
|
||||
Q.all([
|
||||
thenableNum.should.become("happy"),
|
||||
thenableNum.should.eventually.have.property("fun times"),
|
||||
thenableNum.should.be.rejectedWith(TypeError, "only joyful types are allowed")
|
||||
]).should.notify(() => console.log('done'));
|
||||
|
||||
// Assert API
|
||||
var thenableVoid: PromisesAPlus.Thenable<void>;
|
||||
thenableVoid = chai.assert.eventually.equal(thenableNum, 4, 'Message');
|
||||
thenableVoid = chai.assert.isFulfilled(thenableNum, "optional message");
|
||||
thenableVoid = chai.assert.becomes(thenableNum, "foo", "optional message");
|
||||
thenableVoid = chai.assert.doesNotBecome(thenableNum, "foo", "optional message");
|
||||
thenableVoid = chai.assert.isRejected(thenableNum, "optional message");
|
||||
thenableVoid = chai.assert.isRejected(thenableNum, Error, "optional message");
|
||||
thenableVoid = chai.assert.isRejected(thenableNum, /error message matcher/, "optional message");
|
||||
|
||||
// Check that original chai assertions are not broken
|
||||
var undef: void;
|
||||
undef = chai.assert.equal(10, 4, 'Message');
|
||||
|
||||
+264
-16
@@ -1,9 +1,10 @@
|
||||
// Type definitions for chai-as-promised
|
||||
// Project: https://github.com/domenic/chai-as-promised/
|
||||
// Definitions by: jt000 <https://github.com/jt000>
|
||||
// Definitions by: jt000 <https://github.com/jt000>, Yuki Kokubun <https://github.com/Kuniwak>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../chai/chai.d.ts" />
|
||||
/// <reference path="../promises-a-plus/promises-a-plus.d.ts" />
|
||||
|
||||
declare module 'chai-as-promised' {
|
||||
function chaiAsPromised(chai: any, utils: any): void;
|
||||
@@ -12,25 +13,272 @@ declare module 'chai-as-promised' {
|
||||
|
||||
declare module Chai {
|
||||
|
||||
interface Assertion {
|
||||
become(expected: any): Assertion;
|
||||
fulfilled: Assertion;
|
||||
rejected: Assertion;
|
||||
rejectedWith(expected: any): Assertion;
|
||||
notify(fn: Function): Assertion;
|
||||
// For BDD API
|
||||
interface Assertion extends LanguageChains, NumericComparison, TypeComparison {
|
||||
eventually: PromisedAssertion;
|
||||
become(expected: any): PromisedAssertion;
|
||||
fulfilled: PromisedAssertion;
|
||||
rejected: PromisedAssertion;
|
||||
rejectedWith(expected: any, message?: string): PromisedAssertion;
|
||||
notify(fn: Function): PromisedAssertion;
|
||||
}
|
||||
|
||||
interface LanguageChains {
|
||||
eventually: Assertion;
|
||||
// Eventually does not have .then(), but PromisedAssertion have.
|
||||
interface Eventually extends PromisedLanguageChains, PromisedNumericComparison, PromisedTypeComparison {
|
||||
// From chai-as-promised
|
||||
become(expected: PromisesAPlus.Thenable<any>): PromisedAssertion;
|
||||
fulfilled: PromisedAssertion;
|
||||
rejected: PromisedAssertion;
|
||||
rejectedWith(expected: any): PromisedAssertion;
|
||||
notify(fn: Function): PromisedAssertion;
|
||||
|
||||
// From chai
|
||||
not: PromisedAssertion;
|
||||
deep: PromisedDeep;
|
||||
a: PromisedTypeComparison;
|
||||
an: PromisedTypeComparison;
|
||||
include: PromisedInclude;
|
||||
contain: PromisedInclude;
|
||||
ok: PromisedAssertion;
|
||||
true: PromisedAssertion;
|
||||
false: PromisedAssertion;
|
||||
null: PromisedAssertion;
|
||||
undefined: PromisedAssertion;
|
||||
exist: PromisedAssertion;
|
||||
empty: PromisedAssertion;
|
||||
arguments: PromisedAssertion;
|
||||
Arguments: PromisedAssertion;
|
||||
equal: PromisedEqual;
|
||||
equals: PromisedEqual;
|
||||
eq: PromisedEqual;
|
||||
eql: PromisedEqual;
|
||||
eqls: PromisedEqual;
|
||||
property: PromisedProperty;
|
||||
ownProperty: PromisedOwnProperty;
|
||||
haveOwnProperty: PromisedOwnProperty;
|
||||
length: PromisedLength;
|
||||
lengthOf: PromisedLength;
|
||||
match(regexp: RegExp|string, message?: string): PromisedAssertion;
|
||||
string(string: string, message?: string): PromisedAssertion;
|
||||
keys: PromisedKeys;
|
||||
key(string: string): PromisedAssertion;
|
||||
throw: PromisedThrow;
|
||||
throws: PromisedThrow;
|
||||
Throw: PromisedThrow;
|
||||
respondTo(method: string, message?: string): PromisedAssertion;
|
||||
itself: PromisedAssertion;
|
||||
satisfy(matcher: Function, message?: string): PromisedAssertion;
|
||||
closeTo(expected: number, delta: number, message?: string): PromisedAssertion;
|
||||
members: PromisedMembers;
|
||||
}
|
||||
|
||||
interface PromisedAssertion extends Eventually, PromisesAPlus.Thenable<any> {
|
||||
}
|
||||
|
||||
interface PromisedLanguageChains {
|
||||
eventually: Eventually;
|
||||
|
||||
// From chai
|
||||
to: PromisedAssertion;
|
||||
be: PromisedAssertion;
|
||||
been: PromisedAssertion;
|
||||
is: PromisedAssertion;
|
||||
that: PromisedAssertion;
|
||||
which: PromisedAssertion;
|
||||
and: PromisedAssertion;
|
||||
has: PromisedAssertion;
|
||||
have: PromisedAssertion;
|
||||
with: PromisedAssertion;
|
||||
at: PromisedAssertion;
|
||||
of: PromisedAssertion;
|
||||
same: PromisedAssertion;
|
||||
}
|
||||
|
||||
interface PromisedNumericComparison {
|
||||
above: PromisedNumberComparer;
|
||||
gt: PromisedNumberComparer;
|
||||
greaterThan: PromisedNumberComparer;
|
||||
least: PromisedNumberComparer;
|
||||
gte: PromisedNumberComparer;
|
||||
below: PromisedNumberComparer;
|
||||
lt: PromisedNumberComparer;
|
||||
lessThan: PromisedNumberComparer;
|
||||
most: PromisedNumberComparer;
|
||||
lte: PromisedNumberComparer;
|
||||
within(start: number, finish: number, message?: string): PromisedAssertion;
|
||||
}
|
||||
|
||||
interface PromisedNumberComparer {
|
||||
(value: number, message?: string): PromisedAssertion;
|
||||
}
|
||||
|
||||
interface PromisedTypeComparison {
|
||||
(type: string, message?: string): PromisedAssertion;
|
||||
instanceof: PromisedInstanceOf;
|
||||
instanceOf: PromisedInstanceOf;
|
||||
}
|
||||
|
||||
interface PromisedInstanceOf {
|
||||
(constructor: Object, message?: string): PromisedAssertion;
|
||||
}
|
||||
|
||||
interface PromisedDeep {
|
||||
equal: PromisedEqual;
|
||||
include: PromisedInclude;
|
||||
property: PromisedProperty;
|
||||
}
|
||||
|
||||
interface PromisedEqual {
|
||||
(value: any, message?: string): PromisedAssertion;
|
||||
}
|
||||
|
||||
interface PromisedProperty {
|
||||
(name: string, value?: any, message?: string): PromisedAssertion;
|
||||
}
|
||||
|
||||
interface PromisedOwnProperty {
|
||||
(name: string, message?: string): PromisedAssertion;
|
||||
}
|
||||
|
||||
interface PromisedLength extends PromisedLanguageChains, PromisedNumericComparison {
|
||||
(length: number, message?: string): PromisedAssertion;
|
||||
}
|
||||
|
||||
interface PromisedInclude {
|
||||
(value: Object, message?: string): PromisedAssertion;
|
||||
(value: string, message?: string): PromisedAssertion;
|
||||
(value: number, message?: string): PromisedAssertion;
|
||||
keys: PromisedKeys;
|
||||
members: PromisedMembers;
|
||||
}
|
||||
|
||||
interface PromisedKeys {
|
||||
(...keys: string[]): PromisedAssertion;
|
||||
(keys: any[]): PromisedAssertion;
|
||||
}
|
||||
|
||||
interface PromisedThrow {
|
||||
(): PromisedAssertion;
|
||||
(expected: string, message?: string): PromisedAssertion;
|
||||
(expected: RegExp, message?: string): PromisedAssertion;
|
||||
(constructor: Error, expected?: string, message?: string): PromisedAssertion;
|
||||
(constructor: Error, expected?: RegExp, message?: string): PromisedAssertion;
|
||||
(constructor: Function, expected?: string, message?: string): PromisedAssertion;
|
||||
(constructor: Function, expected?: RegExp, message?: string): PromisedAssertion;
|
||||
}
|
||||
|
||||
interface PromisedMembers {
|
||||
(set: any[], message?: string): PromisedAssertion;
|
||||
}
|
||||
|
||||
// For Assert API
|
||||
interface Assert {
|
||||
eventually: Assert;
|
||||
isFulfilled(promise: any, message?: string): void;
|
||||
becomes(promise: any, expected: any, message?: string): void;
|
||||
doesNotBecome(promise: any, expected: any, message?: string): void;
|
||||
isRejected(promise: any, message?: string): void;
|
||||
isRejected(promise: any, expected: any, message?: string): void;
|
||||
isRejected(promise: any, match: RegExp, message?: string): void;
|
||||
eventually: PromisedAssert;
|
||||
isFulfilled(promise: PromisesAPlus.Thenable<any>, message?: string): PromisesAPlus.Thenable<void>;
|
||||
becomes(promise: PromisesAPlus.Thenable<any>, expected: any, message?: string): PromisesAPlus.Thenable<void>;
|
||||
doesNotBecome(promise: PromisesAPlus.Thenable<any>, expected: any, message?: string): PromisesAPlus.Thenable<void>;
|
||||
isRejected(promise: PromisesAPlus.Thenable<any>, message?: string): PromisesAPlus.Thenable<void>;
|
||||
isRejected(promise: PromisesAPlus.Thenable<any>, expected: any, message?: string): PromisesAPlus.Thenable<void>;
|
||||
isRejected(promise: PromisesAPlus.Thenable<any>, match: RegExp, message?: string): PromisesAPlus.Thenable<void>;
|
||||
notify(fn: Function): PromisesAPlus.Thenable<void>;
|
||||
}
|
||||
|
||||
export interface PromisedAssert {
|
||||
fail(actual?: any, expected?: any, msg?: string, operator?: string): PromisesAPlus.Thenable<void>;
|
||||
|
||||
ok(val: any, msg?: string): PromisesAPlus.Thenable<void>;
|
||||
notOk(val: any, msg?: string): PromisesAPlus.Thenable<void>;
|
||||
|
||||
equal(act: any, exp: any, msg?: string): PromisesAPlus.Thenable<void>;
|
||||
notEqual(act: any, exp: any, msg?: string): PromisesAPlus.Thenable<void>;
|
||||
|
||||
strictEqual(act: any, exp: any, msg?: string): PromisesAPlus.Thenable<void>;
|
||||
notStrictEqual(act: any, exp: any, msg?: string): PromisesAPlus.Thenable<void>;
|
||||
|
||||
deepEqual(act: any, exp: any, msg?: string): PromisesAPlus.Thenable<void>;
|
||||
notDeepEqual(act: any, exp: any, msg?: string): PromisesAPlus.Thenable<void>;
|
||||
|
||||
isTrue(val: any, msg?: string): PromisesAPlus.Thenable<void>;
|
||||
isFalse(val: any, msg?: string): PromisesAPlus.Thenable<void>;
|
||||
|
||||
isNull(val: any, msg?: string): PromisesAPlus.Thenable<void>;
|
||||
isNotNull(val: any, msg?: string): PromisesAPlus.Thenable<void>;
|
||||
|
||||
isUndefined(val: any, msg?: string): PromisesAPlus.Thenable<void>;
|
||||
isDefined(val: any, msg?: string): PromisesAPlus.Thenable<void>;
|
||||
|
||||
isFunction(val: any, msg?: string): PromisesAPlus.Thenable<void>;
|
||||
isNotFunction(val: any, msg?: string): PromisesAPlus.Thenable<void>;
|
||||
|
||||
isObject(val: any, msg?: string): PromisesAPlus.Thenable<void>;
|
||||
isNotObject(val: any, msg?: string): PromisesAPlus.Thenable<void>;
|
||||
|
||||
isArray(val: any, msg?: string): PromisesAPlus.Thenable<void>;
|
||||
isNotArray(val: any, msg?: string): PromisesAPlus.Thenable<void>;
|
||||
|
||||
isString(val: any, msg?: string): PromisesAPlus.Thenable<void>;
|
||||
isNotString(val: any, msg?: string): PromisesAPlus.Thenable<void>;
|
||||
|
||||
isNumber(val: any, msg?: string): PromisesAPlus.Thenable<void>;
|
||||
isNotNumber(val: any, msg?: string): PromisesAPlus.Thenable<void>;
|
||||
|
||||
isBoolean(val: any, msg?: string): PromisesAPlus.Thenable<void>;
|
||||
isNotBoolean(val: any, msg?: string): PromisesAPlus.Thenable<void>;
|
||||
|
||||
typeOf(val: any, type: string, msg?: string): PromisesAPlus.Thenable<void>;
|
||||
notTypeOf(val: any, type: string, msg?: string): PromisesAPlus.Thenable<void>;
|
||||
|
||||
instanceOf(val: any, type: Function, msg?: string): PromisesAPlus.Thenable<void>;
|
||||
notInstanceOf(val: any, type: Function, msg?: string): PromisesAPlus.Thenable<void>;
|
||||
|
||||
include(exp: string, inc: any, msg?: string): PromisesAPlus.Thenable<void>;
|
||||
include(exp: any[], inc: any, msg?: string): PromisesAPlus.Thenable<void>;
|
||||
|
||||
notInclude(exp: string, inc: any, msg?: string): PromisesAPlus.Thenable<void>;
|
||||
notInclude(exp: any[], inc: any, msg?: string): PromisesAPlus.Thenable<void>;
|
||||
|
||||
match(exp: any, re: RegExp, msg?: string): PromisesAPlus.Thenable<void>;
|
||||
notMatch(exp: any, re: RegExp, msg?: string): PromisesAPlus.Thenable<void>;
|
||||
|
||||
property(obj: Object, prop: string, msg?: string): PromisesAPlus.Thenable<void>;
|
||||
notProperty(obj: Object, prop: string, msg?: string): PromisesAPlus.Thenable<void>;
|
||||
deepProperty(obj: Object, prop: string, msg?: string): PromisesAPlus.Thenable<void>;
|
||||
notDeepProperty(obj: Object, prop: string, msg?: string): PromisesAPlus.Thenable<void>;
|
||||
|
||||
propertyVal(obj: Object, prop: string, val: any, msg?: string): PromisesAPlus.Thenable<void>;
|
||||
propertyNotVal(obj: Object, prop: string, val: any, msg?: string): PromisesAPlus.Thenable<void>;
|
||||
|
||||
deepPropertyVal(obj: Object, prop: string, val: any, msg?: string): PromisesAPlus.Thenable<void>;
|
||||
deepPropertyNotVal(obj: Object, prop: string, val: any, msg?: string): PromisesAPlus.Thenable<void>;
|
||||
|
||||
lengthOf(exp: any, len: number, msg?: string): PromisesAPlus.Thenable<void>;
|
||||
//alias frenzy
|
||||
throw(fn: Function, msg?: string): PromisesAPlus.Thenable<void>;
|
||||
throw(fn: Function, regExp: RegExp): PromisesAPlus.Thenable<void>;
|
||||
throw(fn: Function, errType: Function, msg?: string): PromisesAPlus.Thenable<void>;
|
||||
throw(fn: Function, errType: Function, regExp: RegExp): PromisesAPlus.Thenable<void>;
|
||||
|
||||
throws(fn: Function, msg?: string): PromisesAPlus.Thenable<void>;
|
||||
throws(fn: Function, regExp: RegExp): PromisesAPlus.Thenable<void>;
|
||||
throws(fn: Function, errType: Function, msg?: string): PromisesAPlus.Thenable<void>;
|
||||
throws(fn: Function, errType: Function, regExp: RegExp): PromisesAPlus.Thenable<void>;
|
||||
|
||||
Throw(fn: Function, msg?: string): PromisesAPlus.Thenable<void>;
|
||||
Throw(fn: Function, regExp: RegExp): PromisesAPlus.Thenable<void>;
|
||||
Throw(fn: Function, errType: Function, msg?: string): PromisesAPlus.Thenable<void>;
|
||||
Throw(fn: Function, errType: Function, regExp: RegExp): PromisesAPlus.Thenable<void>;
|
||||
|
||||
doesNotThrow(fn: Function, msg?: string): PromisesAPlus.Thenable<void>;
|
||||
doesNotThrow(fn: Function, regExp: RegExp): PromisesAPlus.Thenable<void>;
|
||||
doesNotThrow(fn: Function, errType: Function, msg?: string): PromisesAPlus.Thenable<void>;
|
||||
doesNotThrow(fn: Function, errType: Function, regExp: RegExp): PromisesAPlus.Thenable<void>;
|
||||
|
||||
operator(val: any, operator: string, val2: any, msg?: string): PromisesAPlus.Thenable<void>;
|
||||
closeTo(act: number, exp: number, delta: number, msg?: string): PromisesAPlus.Thenable<void>;
|
||||
|
||||
sameMembers(set1: any[], set2: any[], msg?: string): PromisesAPlus.Thenable<void>;
|
||||
includeMembers(set1: any[], set2: any[], msg?: string): PromisesAPlus.Thenable<void>;
|
||||
|
||||
ifError(val: any, msg?: string): PromisesAPlus.Thenable<void>;
|
||||
}
|
||||
}
|
||||
|
||||
+281
-52
@@ -1,65 +1,294 @@
|
||||
/// <reference path="cheerio.d.ts" />
|
||||
|
||||
import cheerio = require("cheerio");
|
||||
import cheerio from 'cheerio';
|
||||
|
||||
var $ = cheerio.load("<html></html>");
|
||||
var $el = $('selector');
|
||||
var $multiEl = $('seletor', 'selector', 'selector');
|
||||
/*
|
||||
* LOADING
|
||||
*/
|
||||
let html =
|
||||
`<ul id="fruits">
|
||||
<li class="orange">Apple</li>
|
||||
<li class="class">Orange</li>
|
||||
<li class="pear">Pear</li>
|
||||
<input type="text" />
|
||||
</ul>`;
|
||||
|
||||
$el.addClass("class").addClass("test");
|
||||
$el.hasClass("test");
|
||||
$el.removeClass("class").removeClass("test");
|
||||
// Preferred Method
|
||||
var $ = cheerio.load(html);
|
||||
// Directly load element
|
||||
cheerio(html);
|
||||
cheerio('ul', html);
|
||||
cheerio('li', 'ul', html);
|
||||
|
||||
$el.attr('class');
|
||||
$el.attr('class', 'test');
|
||||
$el.removeAttr("class").removeAttr("test");
|
||||
|
||||
$el.find("ul").find("> li");
|
||||
|
||||
$el.parent().parent();
|
||||
$el.next().next();
|
||||
$el.prev().prev();
|
||||
$el.siblings().siblings();
|
||||
|
||||
$el.children().children();
|
||||
$el.children("li").children("a");
|
||||
|
||||
$el.children().each((index, element) => {
|
||||
return $(element).find('t');
|
||||
$ = cheerio.load(html, {
|
||||
normalizeWhitespace: true,
|
||||
xmlMode: true
|
||||
});
|
||||
|
||||
$el.children().map((index, element) => {
|
||||
return $(element).find('t');
|
||||
$ = cheerio.load(html, {
|
||||
normalizeWhitespace: true,
|
||||
xmlMode: true,
|
||||
decodeEntities: true,
|
||||
lowercaseTags: true,
|
||||
lowerCaseAttributeNames: true,
|
||||
recognizeCDATA: true,
|
||||
recognizeSelfClosing: true
|
||||
});
|
||||
|
||||
$el.children().filter((index) => {
|
||||
return $el.children().eq(index).find('t').length >= 0;
|
||||
});
|
||||
/**
|
||||
* Selectors
|
||||
*/
|
||||
var $el = $('.class');
|
||||
var $multiEl = $('selector', 'selector', 'selector');
|
||||
|
||||
$el.filter('span').filter('li');
|
||||
/**
|
||||
* Attributes
|
||||
*/
|
||||
|
||||
$el.first().last().find('t');
|
||||
|
||||
$('div').eq(0).find('b');
|
||||
|
||||
$('#id').append("test html", "other html").find('a');
|
||||
$('#id').prepend("test html", "other html").find('a');
|
||||
$('#id').after("test html", "other html").find('a');
|
||||
$('#id').before("test html", "other html").find('a');
|
||||
|
||||
$el.remove('div').remove('a');
|
||||
|
||||
$('#id').replaceWith('some html').parent();
|
||||
$('#id').empty().parent();
|
||||
|
||||
$el.html();
|
||||
$el.html("<html></html>").find('div');
|
||||
|
||||
$el.text();
|
||||
$el.text('some text');
|
||||
|
||||
$el.toArray();
|
||||
$el.clone().find('a').parent();
|
||||
$.root().find('a');
|
||||
// attr
|
||||
$el.attr('id');
|
||||
$el.attr('id', 'favorite').html();
|
||||
|
||||
// data
|
||||
$el.data();
|
||||
$el.data('apple-color');
|
||||
$el.data('kind', 'mac');
|
||||
|
||||
// val
|
||||
$('input[type="text"]').val();
|
||||
$('input[type="text"]').val('test').html();
|
||||
|
||||
// removeAttr
|
||||
$el.removeAttr('class').html();
|
||||
|
||||
// hasClass, addClass, removeClass, toggleClass
|
||||
$el.addClass('class').addClass('test');
|
||||
$el.hasClass('test');
|
||||
$el.removeClass('class').removeClass('test');
|
||||
$el.addClass('red').removeClass().html();
|
||||
$el.toggleClass('fruit green red').html();
|
||||
|
||||
// is
|
||||
$el.is('#id');
|
||||
$el.is($el);
|
||||
$el.is(() => {
|
||||
return true;
|
||||
});
|
||||
|
||||
/**
|
||||
* Forms
|
||||
*/
|
||||
// serializeArray
|
||||
$('<form><input name="foo" value="bar" /></form>').serializeArray();
|
||||
|
||||
/**
|
||||
* Traversing
|
||||
*/
|
||||
// find
|
||||
$el.find('li').length;
|
||||
$el.find($('.apple')).length;
|
||||
|
||||
// .parent([selector])
|
||||
$el.parent().attr('id');
|
||||
$el.parent('.class').attr('id');
|
||||
|
||||
// .parents([selector])
|
||||
$el.parents().length;
|
||||
$el.parents('.class').length;
|
||||
|
||||
// .parentsUntil([selector][,filter])
|
||||
$el.parentsUntil().length;
|
||||
$el.parentsUntil('.class').length;
|
||||
|
||||
// .closest(selector)
|
||||
$el.closest();
|
||||
$el.closest('.class');
|
||||
|
||||
// .next([selector])
|
||||
$el.next().hasClass('class');
|
||||
$el.next('.class').hasClass('class');
|
||||
|
||||
// .nextAll([selector])
|
||||
$el.nextAll().length;
|
||||
$el.nextAll('.class').length;
|
||||
|
||||
// .nextUntil([selector], [filter])
|
||||
$el.nextUntil();
|
||||
$el.nextUntil('.class');
|
||||
|
||||
// .prev([selector])
|
||||
$el.prev().hasClass('class');
|
||||
$el.prev('.class').hasClass('class');
|
||||
|
||||
// .prevAll([selector])
|
||||
$el.prevAll().length;
|
||||
$el.prevAll('.class').length;
|
||||
|
||||
// .prevUntil([selector], [filter])
|
||||
$el.prevUntil();
|
||||
$el.prevUntil('.class');
|
||||
|
||||
// .slice( start, [end] )
|
||||
$el.slice(1).eq(0).text();
|
||||
$el.slice(1, 2).length;
|
||||
|
||||
// .siblings([selector])
|
||||
$el.siblings().length;
|
||||
$el.siblings('.class').length;
|
||||
|
||||
// .children([selector])
|
||||
$el.children().length;
|
||||
$el.children('.class').text();
|
||||
|
||||
// .contents()
|
||||
$el.contents().length;
|
||||
|
||||
// .each( function(index, element) )
|
||||
$el.each((i, el) => {
|
||||
$(el).html();
|
||||
});
|
||||
|
||||
// .map( function(index, element) )
|
||||
$el.map((i, el) => {
|
||||
return $(el).text();
|
||||
}).get().join(' ');
|
||||
|
||||
// .filter
|
||||
$ = cheerio.load(html);
|
||||
$el.filter('.class').attr('class');
|
||||
$el.filter($('.class')).attr('class');
|
||||
$el.filter($('.class')[0]).attr('class');
|
||||
|
||||
$el.filter((i, el) => {
|
||||
return $(el).attr('class') === 'class';
|
||||
}).attr('class');
|
||||
|
||||
// .not
|
||||
$el.not('.class').length;
|
||||
$el.not($('.class')).length;
|
||||
$el.not($('.class')[0]).length;
|
||||
|
||||
$el.not((i, el) => {
|
||||
return $(el).attr('class') === 'class';
|
||||
}).length;
|
||||
|
||||
// .has
|
||||
$el.has('.class').attr('id');
|
||||
$el.has($el[0]).attr('id');
|
||||
|
||||
// .first()
|
||||
$el.children().first().text();
|
||||
|
||||
// .last()
|
||||
$el.children().last().text();
|
||||
|
||||
// .eq( i )
|
||||
$el.eq(0).text();
|
||||
$el.eq(-1).text();
|
||||
|
||||
// .get( [i] )
|
||||
$el.get(0).tagName;
|
||||
$el.get().length;
|
||||
|
||||
// .index()
|
||||
// .index( selector )
|
||||
// .index( nodeOrSelection )
|
||||
$el.index();
|
||||
$el.index('li');
|
||||
$el.index($('#fruit, li'));
|
||||
|
||||
// .end()
|
||||
$el.eq(0).end().length;
|
||||
|
||||
// .add
|
||||
$el.add('.class').length
|
||||
|
||||
// .addBack( [filter] )
|
||||
$el.eq(0).addBack().length
|
||||
$el.eq(0).addBack('.class').length
|
||||
|
||||
/**
|
||||
* Manipulation
|
||||
*/
|
||||
|
||||
// .append( content, [content, ...] )
|
||||
$el.append('<li class="plum">Plum</li>').html();
|
||||
$el.append('<li class="plum">Plum</li>', '<li class="plum">Plum</li>').html();
|
||||
|
||||
// .prepend( content, [content, ...] )
|
||||
$el.prepend('<li class="plum">Plum</li>').html();
|
||||
$el.prepend('<li class="plum">Plum</li>', '<li class="plum">Plum</li>').html();
|
||||
|
||||
// .after( content, [content, ...] )
|
||||
$el.after('<li class="plum">Plum</li>').html();
|
||||
$el.after('<li class="plum">Plum</li>', '<li class="plum">Plum</li>').html();
|
||||
|
||||
// .insertAfter( content )
|
||||
$('<li class="plum">Plum</li>').insertAfter('.class').html();
|
||||
|
||||
// .before( content, [content, ...] )
|
||||
$el.before('<li class="plum">Plum</li>').html();
|
||||
$el.before('<li class="plum">Plum</li>', '<li class="plum">Plum</li>').html();
|
||||
|
||||
// .insertBefore( content )
|
||||
$('<li class="plum">Plum</li>').insertBefore('.class').html();
|
||||
|
||||
// .remove( [selector] )
|
||||
$el.remove().html();
|
||||
$el.remove('.class').html();
|
||||
|
||||
// .replaceWith( content )
|
||||
$el.replaceWith($('<li class="plum">Plum</li>')).html();
|
||||
|
||||
// .empty()
|
||||
$el.empty().html();
|
||||
|
||||
// .html( [htmlString] )
|
||||
$el.html();
|
||||
$el.html('<li class="mango">Mango</li>').html();
|
||||
|
||||
// .text( [textString] )
|
||||
$el.text();
|
||||
$el.text('text');
|
||||
|
||||
// .wrap( content )
|
||||
// See https://github.com/cheeriojs/cheerio/issues/731
|
||||
// $el.wrap($('<div class="red-fruit"></div>')).html();
|
||||
|
||||
// .css
|
||||
$el.css('width');
|
||||
$el.css(['width', 'height']);
|
||||
$el.css('width', '50px');
|
||||
|
||||
/**
|
||||
* Rendering
|
||||
*/
|
||||
$.html();
|
||||
$.html('.class');
|
||||
$.xml();
|
||||
|
||||
/**
|
||||
* Miscellaneous
|
||||
*/
|
||||
|
||||
// .clone() ####
|
||||
$el.clone().html();
|
||||
|
||||
/**
|
||||
* Utilities
|
||||
*/
|
||||
|
||||
// $.root
|
||||
$.root().append('<ul id="vegetables"></ul>').html();
|
||||
|
||||
// $.contains( container, contained )
|
||||
$.contains($el[0], $el[0]);
|
||||
|
||||
// $.parseHTML( data [, context ] [, keepScripts ] )
|
||||
$.parseHTML(html);
|
||||
$.parseHTML(html, null, true);
|
||||
|
||||
/**
|
||||
* Not in doc
|
||||
*/
|
||||
$el.toArray();
|
||||
|
||||
Vendored
+59
-11
@@ -17,12 +17,17 @@ interface Cheerio {
|
||||
attr(name: string, value: any): Cheerio;
|
||||
|
||||
data(): any;
|
||||
data(name: string): any;
|
||||
data(name: string, value: any): any;
|
||||
|
||||
val(): string;
|
||||
val(value: string): Cheerio;
|
||||
|
||||
removeAttr(name: string): Cheerio;
|
||||
|
||||
has(selector: string): Cheerio;
|
||||
has(element: CheerioElement): Cheerio;
|
||||
|
||||
hasClass(className: string): boolean;
|
||||
addClass(classNames: string): Cheerio;
|
||||
|
||||
@@ -41,6 +46,9 @@ interface Cheerio {
|
||||
is(selection: Cheerio): boolean;
|
||||
is(func: (index: number, element: CheerioElement) => boolean): boolean;
|
||||
|
||||
// Form
|
||||
serializeArray(): {name: string, value: string}[];
|
||||
|
||||
// Traversing
|
||||
|
||||
find(selector: string): Cheerio;
|
||||
@@ -52,10 +60,12 @@ interface Cheerio {
|
||||
parentsUntil(element: CheerioElement, filter?: string): Cheerio;
|
||||
parentsUntil(element: Cheerio, filter?: string): Cheerio;
|
||||
|
||||
closest(): Cheerio;
|
||||
closest(selector: string): Cheerio;
|
||||
|
||||
next(selector?: string): Cheerio;
|
||||
nextAll(): Cheerio;
|
||||
nextAll(selector: string): Cheerio;
|
||||
|
||||
nextUntil(selector?: string, filter?: string): Cheerio;
|
||||
nextUntil(element: CheerioElement, filter?: string): Cheerio;
|
||||
@@ -63,6 +73,7 @@ interface Cheerio {
|
||||
|
||||
prev(selector?: string): Cheerio;
|
||||
prevAll(): Cheerio;
|
||||
prevAll(selector: string): Cheerio;
|
||||
|
||||
prevUntil(selector?: string, filter?: string): Cheerio;
|
||||
prevUntil(element: CheerioElement, filter?: string): Cheerio;
|
||||
@@ -83,15 +94,24 @@ interface Cheerio {
|
||||
filter(selection: Cheerio): Cheerio;
|
||||
filter(element: CheerioElement): Cheerio;
|
||||
filter(elements: CheerioElement[]): Cheerio;
|
||||
filter(func: (index: number) => boolean): Cheerio;
|
||||
filter(func: (index: number, element: CheerioElement) => boolean): Cheerio;
|
||||
|
||||
not(selector: string): Cheerio;
|
||||
not(selection: Cheerio): Cheerio;
|
||||
not(element: CheerioElement): Cheerio;
|
||||
not(func: (index: number, element: CheerioElement) => boolean): Cheerio;
|
||||
|
||||
first(): Cheerio;
|
||||
last(): Cheerio;
|
||||
|
||||
eq(index: number): Cheerio;
|
||||
|
||||
get(): Document[];
|
||||
get(index: number): Document;
|
||||
get(): CheerioElement[];
|
||||
get(index: number): CheerioElement;
|
||||
|
||||
index(): number;
|
||||
index(selector: string): number;
|
||||
index(selection: Cheerio): number;
|
||||
|
||||
end(): Cheerio;
|
||||
|
||||
@@ -101,6 +121,9 @@ interface Cheerio {
|
||||
add(elements: CheerioElement[]): Cheerio;
|
||||
add(selection: Cheerio): Cheerio;
|
||||
|
||||
addBack():Cheerio;
|
||||
addBack(filter: string):Cheerio;
|
||||
|
||||
// Manipulation
|
||||
|
||||
append(content: string, ...contents: any[]): Cheerio;
|
||||
@@ -118,11 +141,19 @@ interface Cheerio {
|
||||
after(content: Document[], ...contents: any[]): Cheerio;
|
||||
after(content: Cheerio, ...contents: any[]): Cheerio;
|
||||
|
||||
insertAfter(content: string): Cheerio;
|
||||
insertAfter(content: Document): Cheerio;
|
||||
insertAfter(content: Cheerio): Cheerio;
|
||||
|
||||
before(content: string, ...contents: any[]): Cheerio;
|
||||
before(content: Document, ...contents: any[]): Cheerio;
|
||||
before(content: Document[], ...contents: any[]): Cheerio;
|
||||
before(content: Cheerio, ...contents: any[]): Cheerio;
|
||||
|
||||
insertBefore(content: string): Cheerio;
|
||||
insertBefore(content: Document): Cheerio;
|
||||
insertBefore(content: Cheerio): Cheerio;
|
||||
|
||||
remove(selector?: string): Cheerio;
|
||||
|
||||
replaceWith(content: string): Cheerio;
|
||||
@@ -138,6 +169,11 @@ interface Cheerio {
|
||||
text(): string;
|
||||
text(text: string): Cheerio;
|
||||
|
||||
// See https://github.com/cheeriojs/cheerio/issues/731
|
||||
/*wrap(content: string): Cheerio;
|
||||
wrap(content: Document): Cheerio;
|
||||
wrap(content: Cheerio): Cheerio;*/
|
||||
|
||||
css(propertyName: string): string;
|
||||
css(propertyNames: string[]): string[];
|
||||
css(propertyName: string, value: string): Cheerio;
|
||||
@@ -172,11 +208,7 @@ interface CheerioOptionsInterface {
|
||||
normalizeWhitespace?: boolean;
|
||||
}
|
||||
|
||||
interface CheerioStatic {
|
||||
// Document References
|
||||
// Cheerio https://github.com/cheeriojs/cheerio
|
||||
// JQuery http://api.jquery.com
|
||||
|
||||
interface CheerioSelector {
|
||||
(selector: string): Cheerio;
|
||||
(selector: string, context: string): Cheerio;
|
||||
(selector: string, context: CheerioElement): Cheerio;
|
||||
@@ -187,7 +219,12 @@ interface CheerioStatic {
|
||||
(selector: string, context: CheerioElement[], root: string): Cheerio;
|
||||
(selector: string, context: Cheerio, root: string): Cheerio;
|
||||
(selector: any): Cheerio;
|
||||
}
|
||||
|
||||
interface CheerioStatic extends CheerioSelector {
|
||||
// Document References
|
||||
// Cheerio https://github.com/cheeriojs/cheerio
|
||||
// JQuery http://api.jquery.com
|
||||
xml(): string;
|
||||
root(): Cheerio;
|
||||
contains(container: CheerioElement, contained: CheerioElement): boolean;
|
||||
@@ -202,17 +239,28 @@ interface CheerioStatic {
|
||||
interface CheerioElement {
|
||||
// Document References
|
||||
// Node Console
|
||||
|
||||
tagName: string;
|
||||
type: string;
|
||||
name: string;
|
||||
attribs: Object;
|
||||
children: CheerioElement[];
|
||||
childNodes: CheerioElement[];
|
||||
lastChild: CheerioElement;
|
||||
next: CheerioElement;
|
||||
nextSibling: CheerioElement;
|
||||
prev: CheerioElement;
|
||||
previousSibling: CheerioElement;
|
||||
parent: CheerioElement;
|
||||
root: CheerioElement;
|
||||
parentNode: CheerioElement;
|
||||
nodeValue: string;
|
||||
}
|
||||
|
||||
interface CheerioAPI extends CheerioSelector {
|
||||
load(html: string, options?: CheerioOptionsInterface): CheerioStatic;
|
||||
}
|
||||
|
||||
declare var cheerio:CheerioAPI;
|
||||
|
||||
declare module "cheerio" {
|
||||
export function load(html: string, options?: CheerioOptionsInterface): CheerioStatic;
|
||||
export default cheerio;
|
||||
}
|
||||
|
||||
@@ -102,12 +102,14 @@ $('ul').insert("<li>1</li><li>2</li><li>3</li>", 3);
|
||||
$('ul').insert("<li>1</li><li>2</li><li>3</li>");
|
||||
$('ul').html('<li>1</li><li><2/li><li>3</li>');
|
||||
$('ul').html('');
|
||||
var listContent = $('ul').html();
|
||||
$('ul').prepend('<li class="title">The title</li>');
|
||||
$('ul').append('<li>The Last Item</li>');
|
||||
var inputName = $('input').attr('name');
|
||||
$('input').attr('name', 'wobba');
|
||||
var inputName = $('input').prop('name');
|
||||
$('input').prop('name', 'wobba');
|
||||
var inputProperty = $('input').prop('disabled');
|
||||
$('input[type=checked]').prop('checked', true);
|
||||
$('input').removeProp('disabled');
|
||||
$('input').hasAttr('disabled').css('border', 'solid 1px red');
|
||||
$('input').removeAttr('disabled');
|
||||
$('article').hasClass('current').css('display', 'block');
|
||||
|
||||
Vendored
+16
-9
@@ -1,4 +1,4 @@
|
||||
// Type definitions for chocolatechip v4.0.2
|
||||
// Type definitions for chocolatechip v4.0.3
|
||||
// Project: https://github.com/chocolatechipui/ChocolateChipJS
|
||||
// Definitions by: Robert Biggs <http://chocolatechip-ui.com>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
@@ -176,7 +176,8 @@ interface ChocolateChipStatic {
|
||||
* @param response The response from a Promise.
|
||||
* @result
|
||||
*/
|
||||
json(reponse: Response): JSON;
|
||||
json(reponse: Response): JSON;
|
||||
|
||||
/**
|
||||
* This method will defer the execution of a function until the call stack is clear.
|
||||
*
|
||||
@@ -198,7 +199,7 @@ interface ChocolateChipStatic {
|
||||
* This method makes sure a method always returns an array. If no values are available to return, it returns and empty array. This is to make sure that methods that expect a chainable array will not throw and exception.
|
||||
*
|
||||
* @param result The result of a method to test if it can be returned in an array.
|
||||
* @return An array hold the results of a method, otherwise an empty array.
|
||||
* @return An array holding the results of a method, otherwise an empty array.
|
||||
*/
|
||||
returnResult(result: HTMLElement[]): any[];
|
||||
|
||||
@@ -836,12 +837,12 @@ interface ChocolateChipElementArray extends Array<HTMLElement> {
|
||||
hasAttr(attributeName: string): ChocolateChipElementArray;
|
||||
|
||||
/**
|
||||
* Get the value of an attribute for the first element in the set of matched elements.
|
||||
* Test whether an attribute exists on the first element in the set of matched elements. The value returned is a boolean.
|
||||
*
|
||||
* @param attributeName The name of the attribute to get.
|
||||
* @return string
|
||||
* @return boolean
|
||||
*/
|
||||
prop(attributeName: string): string;
|
||||
prop(propertyName: string): boolean;
|
||||
|
||||
/**
|
||||
* Set an property for the set of matched elements.
|
||||
@@ -850,7 +851,15 @@ interface ChocolateChipElementArray extends Array<HTMLElement> {
|
||||
* @param value A string indicating the value to set the property to.
|
||||
* @return HTMLElement[]
|
||||
*/
|
||||
prop(propertyName: string, value: string): ChocolateChipElementArray;
|
||||
prop(propertyName: string, value: any | boolean): ChocolateChipElementArray;
|
||||
|
||||
/**
|
||||
* Remove an element property.
|
||||
*
|
||||
* @param property The property to remove.
|
||||
* @return HTMLElement[]
|
||||
*/
|
||||
removeProp(property: string): ChocolateChipElementArray;
|
||||
|
||||
/**
|
||||
* Adds the specified class(es) to each of the set of matched elements.
|
||||
@@ -1471,5 +1480,3 @@ interface Window {
|
||||
}
|
||||
declare var $: ChocolateChipStatic;
|
||||
declare var fetch: fetch;
|
||||
|
||||
declare var chocolatechipjs: ChocolateChipStatic;
|
||||
@@ -60,10 +60,6 @@ function bookmarksExample() {
|
||||
resizable: false,
|
||||
height: 140,
|
||||
modal: true,
|
||||
overlay: {
|
||||
backgroundColor: '#000',
|
||||
opacity: 0.5
|
||||
},
|
||||
buttons: {
|
||||
'Yes, Delete It!': function () {
|
||||
chrome.bookmarks.remove(String(bookmarkNode.id));
|
||||
|
||||
@@ -37,6 +37,7 @@ $(function() {
|
||||
$.UIGoToArticle("#main");
|
||||
$.UIGoBack();
|
||||
$.UIGoBackToArticle("#main");
|
||||
$.UIEnableBrowserHashModification();
|
||||
$.UIBlock();
|
||||
$.UIBlock(.5);
|
||||
$.UIUnblock();
|
||||
|
||||
Vendored
+72
-2
@@ -1,8 +1,8 @@
|
||||
// Type definitions for chui v3.9.0
|
||||
// Type definitions for chui v3.9.1
|
||||
// Project: https://github.com/chocolatechipui/chocolatechip-ui
|
||||
// Definitions by: Robert Biggs <http://chocolatechip-ui.com>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
// ChocolateChip-UI 3.9.0
|
||||
// ChocolateChip-UI 3.9.1
|
||||
/**
|
||||
These TypeScript delcarations for ChocolateChip-UI contain interfaces for both ChocolateChipJS and jQuery. Depending on which library you are using, you will get the type interfaces appropriate for it.
|
||||
*/
|
||||
@@ -89,6 +89,17 @@ interface ChocolateChipStatic {
|
||||
*/
|
||||
isNavigating: boolean;
|
||||
|
||||
/**
|
||||
* Tell ChocolateChip-UI to not modify window hash during navigation.
|
||||
* The default value is false.
|
||||
*/
|
||||
UIBrowserHashModification: boolean;
|
||||
|
||||
/**
|
||||
* Method to tell ChocolateChip-UI to register navigation history on Window hash.
|
||||
*/
|
||||
UIEnableBrowserHashModification(): void;
|
||||
|
||||
/**
|
||||
* Navigate to the article indicated by the provided destination ID. This enters the destination into the navigation history array.
|
||||
*
|
||||
@@ -784,6 +795,17 @@ interface JQueryStatic {
|
||||
*/
|
||||
isNavigating: boolean;
|
||||
|
||||
/**
|
||||
* Tell ChocolateChip-UI to not modify window hash during navigation.
|
||||
* The default value is false.
|
||||
*/
|
||||
UIBrowserHashModification: boolean;
|
||||
|
||||
/**
|
||||
* Method to tell ChocolateChip-UI to register navigation history on Window hash.
|
||||
*/
|
||||
UIEnableBrowserHashModification(): void;
|
||||
|
||||
/**
|
||||
* Navigate to the article indicated by the provided destination ID. This enters the destination into the navigation history array.
|
||||
*
|
||||
@@ -1014,6 +1036,54 @@ interface JQueryStatic {
|
||||
*/
|
||||
UIUnBindData(controller?: string): void;
|
||||
|
||||
/**
|
||||
* Object used to store string templates and parsed templates.
|
||||
*
|
||||
* @param string A string defining the template.
|
||||
* @param string A label used to access an object's properties in the template. If none is provided it defaults to "data": [[= data.name]].
|
||||
* @return void
|
||||
*/
|
||||
templates: Object;
|
||||
|
||||
/**
|
||||
* This method returns a parsed template.
|
||||
*
|
||||
*/
|
||||
template: {
|
||||
|
||||
/**
|
||||
* This method parses a string and an optoinal variable name and returns a parsed template in the form of a function. You can then pass this function data to get rendered nodes.
|
||||
*
|
||||
* @param template A string of markup to use as a template.
|
||||
* @param variable An option name to use in the template. If it were "myData": [[= myData.name]]. Otherwise it defaults to "data": [[= data.name]].
|
||||
* @return A function.
|
||||
*/
|
||||
(template: string, variable?: string): Function;
|
||||
|
||||
/**
|
||||
* A method to repeated output a template.
|
||||
*
|
||||
* @param element The target container into which the content will be inserted.
|
||||
* @param template A string of markup.
|
||||
* @param data The iterable data the template will consume.
|
||||
* @return void.
|
||||
*/
|
||||
repeater: (element: JQuery, template: string, data: any) => void;
|
||||
|
||||
/**
|
||||
* A object that holds the reference to the controller for a repeater.
|
||||
* This is used to cache the data that a repeater uses. After the repeater is rendered, the reference is deleted from this object.
|
||||
*
|
||||
*/
|
||||
data: {
|
||||
repeaterName?: any;
|
||||
};
|
||||
|
||||
/**
|
||||
* Use this value to output an index value in a template repeater.
|
||||
*/
|
||||
index: number;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -282,7 +282,6 @@ function test_adding_dialog_by_definition() {
|
||||
|
||||
function test_adding_plugin() {
|
||||
CKEDITOR.plugins.add( 'abbr', {
|
||||
icons: 'abbr',
|
||||
init: function( editor: CKEDITOR.editor ) {
|
||||
// empty logic
|
||||
}
|
||||
|
||||
Vendored
+9
-9
@@ -628,7 +628,7 @@ declare module CKEDITOR {
|
||||
data: Function;
|
||||
defaults: Object;
|
||||
dialog: String;
|
||||
downcast: any; // should be string | Function
|
||||
downcast: string | Function;
|
||||
downcasts: Object;
|
||||
draggable: boolean;
|
||||
editables: Object;
|
||||
@@ -643,16 +643,16 @@ declare module CKEDITOR {
|
||||
styleToAllowedContentRules: Function;
|
||||
styleableElements: string;
|
||||
template: string;
|
||||
upcast: any; // should be string | Function
|
||||
upcast: string | Function;
|
||||
upcasts: Object;
|
||||
|
||||
addClass(className: string): void;
|
||||
applyStyle(style: any): void; // any should be CKEDITOR.style
|
||||
capture(): void;
|
||||
checkStyleActive(style: any): boolean; // any should be CKEDITOR.style
|
||||
define(name: string, meta: {errorProof?: boolean}): void;
|
||||
define(name: string, meta: { errorProof?: boolean }): void;
|
||||
destroy(offline?: boolean): void;
|
||||
destroyEditable(editableName:string, offline?: boolean): void;
|
||||
destroyEditable(editableName: string, offline?: boolean): void;
|
||||
edit(): boolean;
|
||||
fire(eventName: string, data?: Object, editor?: editor): any; // should be boolean | Object
|
||||
fireOnce(eventName: string, data?: Object, editor?: editor): any; // should be boolean | Object
|
||||
@@ -670,7 +670,7 @@ declare module CKEDITOR {
|
||||
removeClass(className: string): void;
|
||||
removeListener(evnetName: string, listenerFunction: Function): void;
|
||||
removeStyle(style: any): void; // any should be CKEDITOR.style
|
||||
setData(keyOrData: any, value?: Object): IWidget; // any should be string | Object
|
||||
setData(keyOrData: string | {}, value?: Object): IWidget;
|
||||
setFocused(selected: boolean): IWidget;
|
||||
setSelected(selected: boolean): IWidget;
|
||||
toFeature(): any; // should be CKEDITOR.feature
|
||||
@@ -685,7 +685,7 @@ declare module CKEDITOR {
|
||||
data?: Function;
|
||||
defaults?: Object;
|
||||
dialog?: String;
|
||||
downcast?: any; // should be string | Function
|
||||
downcast?: string | Function;
|
||||
downcasts?: Object;
|
||||
draggable?: boolean;
|
||||
edit?: Function;
|
||||
@@ -701,7 +701,7 @@ declare module CKEDITOR {
|
||||
styleToAllowedContentRules?: Function;
|
||||
styleableElements?: string;
|
||||
template?: string;
|
||||
upcast?: any; // should be string | Function
|
||||
upcast?: string | Function;
|
||||
upcasts?: Object;
|
||||
toFeature?(): any; // should be CKEDITOR.feature
|
||||
}
|
||||
@@ -732,8 +732,8 @@ declare module CKEDITOR {
|
||||
|
||||
interface IPluginDefinition {
|
||||
hidpi?: boolean;
|
||||
lang?: any; // should be string | string[]
|
||||
requires?: any; // should be string | string[]a
|
||||
lang?: string | string[];
|
||||
requires?: string | string[];
|
||||
afterInit?(editor: editor): any;
|
||||
beforeInit?(editor: editor): any;
|
||||
init?(editor: editor): any;
|
||||
|
||||
Vendored
+1
-1
@@ -787,7 +787,7 @@ declare module CodeMirror {
|
||||
viewportMargin?: number;
|
||||
|
||||
/** Optional lint configuration to be used in conjunction with CodeMirror's linter addon. */
|
||||
lint?: LintOptions;
|
||||
lint?: boolean | LintOptions;
|
||||
}
|
||||
|
||||
interface TextMarkerOptions {
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
/// <reference path="codemirror.d.ts" />
|
||||
/// <reference path="showhint.d.ts" />
|
||||
var doc = new CodeMirror.Doc('text');
|
||||
var pos = new CodeMirror.Pos(2, 3);
|
||||
CodeMirror.showHint(doc);
|
||||
CodeMirror.showHint(doc, function (cm) {
|
||||
return {
|
||||
from: pos,
|
||||
list: ["one", "two"],
|
||||
to: pos
|
||||
};
|
||||
});
|
||||
CodeMirror.showHint(doc, function (cm) {
|
||||
return {
|
||||
from: pos,
|
||||
list: [
|
||||
{
|
||||
text: "disp1",
|
||||
render: function (el, self, data) {
|
||||
;
|
||||
}
|
||||
},
|
||||
{
|
||||
className: "class2",
|
||||
displayText: "disp2",
|
||||
from: pos,
|
||||
to: pos,
|
||||
text: "sometext"
|
||||
}
|
||||
],
|
||||
to: pos
|
||||
};
|
||||
});
|
||||
Vendored
+62
@@ -0,0 +1,62 @@
|
||||
// Type definitions for CodeMirror
|
||||
// Project: https://github.com/marijnh/CodeMirror
|
||||
// Definitions by: jacqt <https://github.com/jacqt>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
declare module CodeMirror {
|
||||
var commands : any;
|
||||
|
||||
/** Provides a framework for showing autocompletion hints. Defines editor.showHint, which takes an optional
|
||||
options object, and pops up a widget that allows the user to select a completion. Finding hints is done with
|
||||
a hinting functions (the hint option), which is a function that take an editor instance and options object,
|
||||
and return a {list, from, to} object, where list is an array of strings or objects (the completions), and
|
||||
from and to give the start and end of the token that is being completed as {line, ch} objects. An optional
|
||||
selectedHint property (an integer) can be added to the completion object to control the initially selected hint. */
|
||||
function showHint (cm: CodeMirror.Doc, hinter?: (doc : CodeMirror.Doc) => Hints, options?: IShowHintOptions) : void;
|
||||
|
||||
|
||||
interface Hints {
|
||||
from: Position;
|
||||
to: Position;
|
||||
list: Hint[] | string[];
|
||||
}
|
||||
|
||||
/** Interface used by showHint.js Codemirror add-on
|
||||
When completions aren't simple strings, they should be objects with the following properties: */
|
||||
interface Hint {
|
||||
text: string;
|
||||
className?: string;
|
||||
displayText?: string;
|
||||
from?: Position;
|
||||
render?: (element: any, self: any, data: any) => void;
|
||||
to?: Position;
|
||||
}
|
||||
|
||||
interface Editor {
|
||||
/** An extension of the existing CodeMirror typings for the Editor.on("keyup", func) syntax */
|
||||
on(eventName: string, handler: (doc: CodeMirror.Doc, event : any ) => void ): void;
|
||||
off(eventName: string, handler: (doc: CodeMirror.Doc, event : any) => void ): void;
|
||||
}
|
||||
|
||||
/** Extend CodeMirror.Doc with a state object, so that the Doc.state.completionActive property is reachable*/
|
||||
interface Doc {
|
||||
state: any;
|
||||
showHint: (options: IShowHintOptions) => void;
|
||||
}
|
||||
|
||||
interface IShowHintOptions {
|
||||
completeSingle: boolean;
|
||||
hint: (doc : CodeMirror.Doc) => Hints;
|
||||
}
|
||||
|
||||
/** The Handle used to interact with the autocomplete dialog box.*/
|
||||
interface Handle {
|
||||
moveFocus(n: number, avoidWrap: boolean): void;
|
||||
setFocus(n: number): void;
|
||||
menuSize(): number;
|
||||
length: number;
|
||||
close(): void;
|
||||
pick(): void;
|
||||
data: any;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
/// <reference path="coffeeify.d.ts" />
|
||||
|
||||
import coffeeify = require('coffeeify');
|
||||
|
||||
coffeeify.sourceMap = false;
|
||||
|
||||
var isCoffee = coffeeify.isCoffee('foo.coffee');
|
||||
var isLiterate = coffeeify.isLiterate('bar.coffee');
|
||||
coffeeify.compile('out.js', 'console.log 42', (err, compiled) => {
|
||||
console.log(err);
|
||||
console.log(compiled);
|
||||
});
|
||||
|
||||
coffeeify('test.coffee').end();
|
||||
|
||||
Vendored
+37
@@ -0,0 +1,37 @@
|
||||
// Type definitions for coffeeify
|
||||
// Project: https://github.com/jnordberg/coffeeify
|
||||
// Definitions by: Qubo <https://github.com/tkQubo>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../through/through.d.ts" />
|
||||
|
||||
declare module "coffeeify" {
|
||||
import through = require('through');
|
||||
|
||||
namespace coffeeify {
|
||||
interface Coffeeify {
|
||||
isCoffee(file: string): boolean;
|
||||
isLiterate(file: string): boolean;
|
||||
sourceMap: boolean;
|
||||
compile(file: string, data: string, callback: Callback): void;
|
||||
(file: string): through.ThroughStream;
|
||||
}
|
||||
|
||||
interface Callback {
|
||||
(error: ParseError, compiled: string): void;
|
||||
}
|
||||
|
||||
interface ParseError extends SyntaxError {
|
||||
new(error: any, src: string, file: string): ParseError;
|
||||
message: string;
|
||||
line: number;
|
||||
column: number;
|
||||
annotated: string;
|
||||
}
|
||||
}
|
||||
|
||||
var coffeeify: coffeeify.Coffeeify;
|
||||
|
||||
export = coffeeify;
|
||||
}
|
||||
|
||||
@@ -176,8 +176,12 @@ file.download('http://some.server.com/download.php',
|
||||
console.error('Failed with exception ' + err.exception);
|
||||
}
|
||||
},
|
||||
{ headers: null },
|
||||
true);
|
||||
true,
|
||||
{
|
||||
headers: {
|
||||
"Authorization": "Basic dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA=="
|
||||
}
|
||||
});
|
||||
|
||||
file.upload('cdvfile://localhost/persistent/path/to/downloads/',
|
||||
'http://some.server.com/download.php',
|
||||
|
||||
Vendored
+2
@@ -24,6 +24,8 @@ interface Device {
|
||||
uuid: string;
|
||||
/** Get the operating system version. */
|
||||
version: string;
|
||||
/** Get the device's manufacturer. */
|
||||
manufacturer: string;
|
||||
}
|
||||
|
||||
declare var device: Device;
|
||||
Vendored
+4
-4
@@ -53,8 +53,8 @@ interface FileTransfer {
|
||||
target: string,
|
||||
successCallback: (fileEntry: FileEntry) => void,
|
||||
errorCallback: (error: FileTransferError) => void,
|
||||
options?: FileDownloadOptions,
|
||||
trustAllHosts?: boolean): void;
|
||||
trustAllHosts?: boolean,
|
||||
options?: FileDownloadOptions): void;
|
||||
/**
|
||||
* Aborts an in-progress transfer. The onerror callback is passed a FileTransferError object
|
||||
* which has an error code of FileTransferError.ABORT_ERR.
|
||||
@@ -98,8 +98,8 @@ interface FileUploadOptions {
|
||||
|
||||
/** Optional parameters for download method. */
|
||||
interface FileDownloadOptions {
|
||||
/** A map of header name/header values. Use an array to specify more than one value. */
|
||||
headers?: Object[];
|
||||
/** A map of header name/header values. */
|
||||
headers?: {};
|
||||
}
|
||||
|
||||
/** A FileTransferError object is passed to an error callback when an error occurs. */
|
||||
|
||||
Vendored
+6
-1
@@ -41,12 +41,17 @@ interface Globalization {
|
||||
* @param onError Called on error with a GlobalizationError object.
|
||||
* The error's expected code is GlobalizationError.FORMATTING_ERROR.
|
||||
* @param options Optional format parameters. Default {formatLength:'short', selector:'date and time'}
|
||||
* - 'formatLength' can be "short", "medium", "long", or "full".
|
||||
* - 'selector' can be "date", "time", or "date and time".
|
||||
*/
|
||||
dateToString(
|
||||
date: Date,
|
||||
onSuccess: (date: { value: string; }) => void,
|
||||
onError: (error: GlobalizationError) => void,
|
||||
options?: { type?: string; item?: string; }): void;
|
||||
options?: {
|
||||
formatLength?: string; // "short" | "medium" | "long" | "full"
|
||||
selector?: string; // "date" | "time" | "date and time"
|
||||
}): void;
|
||||
/**
|
||||
* Parses a date formatted as a string, according to the client's user preferences
|
||||
* and calendar using the time zone of the client, and returns the corresponding date object.
|
||||
|
||||
Vendored
+4
-4
@@ -127,12 +127,12 @@ declare module CryptoJS{
|
||||
//BlockCipher has interface same as IStreamCipher
|
||||
interface BlockCipher extends IStreamCipher<IBlockCipherCfg>{}
|
||||
|
||||
interface IBlockCipherCfg{
|
||||
interface IBlockCipherCfg {
|
||||
mode?: mode.IBlockCipherModeImpl //default CBC
|
||||
padding?: pad.IPaddingImpl //default Pkcs7
|
||||
}
|
||||
|
||||
interface CipherParamsData{
|
||||
interface CipherParamsData {
|
||||
ciphertext?: lib.WordArray
|
||||
key?: lib.WordArray
|
||||
iv?: lib.WordArray
|
||||
@@ -277,8 +277,8 @@ declare module CryptoJS{
|
||||
encryptBlock(M: number[], offset: number): void
|
||||
decryptBlock(M: number[], offset: number): void
|
||||
|
||||
createEncryptor(key: lib.WordArray, cfg?: lib.IBlockCipherCfg): IBlockCipherImpl
|
||||
createDecryptor(key: lib.WordArray, cfg?: lib.IBlockCipherCfg): IBlockCipherImpl
|
||||
createEncryptor(key: lib.WordArray, cfg?: lib.CipherParamsData): IBlockCipherImpl
|
||||
createDecryptor(key: lib.WordArray, cfg?: lib.CipherParamsData): IBlockCipherImpl
|
||||
|
||||
create(xformMode?: number, key?: lib.WordArray, cfg?: lib.IBlockCipherCfg): IBlockCipherImpl
|
||||
}
|
||||
|
||||
+1
-1
@@ -922,7 +922,7 @@ module forcedBasedLabelPlacemant {
|
||||
|
||||
var nodes: Node[] = [];
|
||||
var labelAnchors: LabelAnchor[] = [];
|
||||
var labelAnchorLinks: { source: number; target: number }[] = [];
|
||||
var labelAnchorLinks: { source: number; target: number; weight: number }[] = [];
|
||||
var links: typeof labelAnchorLinks = [];
|
||||
|
||||
for (var i = 0; i < 30; i++) {
|
||||
|
||||
Vendored
+6497
File diff suppressed because it is too large
Load Diff
Vendored
+76
-15
@@ -1,4 +1,4 @@
|
||||
// Type definitions for DevExtreme 15.1.5
|
||||
// Type definitions for DevExtreme 15.1.6
|
||||
// Project: http://js.devexpress.com/
|
||||
// Definitions by: DevExpress Inc. <http://devexpress.com/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
@@ -63,7 +63,7 @@ declare module DevExpress {
|
||||
export function processHardwareBackButton(): void;
|
||||
/** Specifies whether or not the entire application/site supports right-to-left representation. */
|
||||
export var rtlEnabled: boolean;
|
||||
/** Registers a new component in the DevExpress.ui namespace, and a jQuery plugin and Knockout binding for the required component. */
|
||||
/** Registers a new component in the DevExpress.ui namespace as a jQuery plugin, Angular directive and Knockout binding. */
|
||||
export function registerComponent(name: string, componentClass: Object): void;
|
||||
/** Registers a new component in the specified namespace as a jQuery plugin, Angular directive and Knockout binding. */
|
||||
export function registerComponent(name: string, namespace: Object, componentClass: Object): void;
|
||||
@@ -323,7 +323,7 @@ declare module DevExpress {
|
||||
key(): any;
|
||||
/** Returns the key of the Store item that matches the specified object. */
|
||||
keyOf(obj: Object): any;
|
||||
/** Starts loading the data. */
|
||||
/** Starts loading data. */
|
||||
load(obj?: LoadOptions): JQueryPromise<any[]>;
|
||||
/** Removes the data item specified by the key. */
|
||||
remove(key: any): JQueryPromise<any>;
|
||||
@@ -427,6 +427,8 @@ declare module DevExpress {
|
||||
select?: Object;
|
||||
/** An array of the strings that represent the names of the navigation properties to be loaded simultaneously with the OData store's entity. */
|
||||
expand?: Object;
|
||||
/** Specifies whether or not the DataSource instance requests the total count of items available in the storage. */
|
||||
requireTotalCount?: boolean;
|
||||
/** Specifies the initial sort option value. */
|
||||
sort?: Object;
|
||||
/** Specifies the underlying Store instance used to access data. */
|
||||
@@ -496,6 +498,10 @@ declare module DevExpress {
|
||||
select(): Object;
|
||||
/** Sets the select option value. */
|
||||
select(expr: Object): void;
|
||||
/** Returns the current requireTotalCount option value. */
|
||||
requireTotalCount(): boolean;
|
||||
/** Sets the requireTotalCount option value. */
|
||||
requireTotalCount(value: boolean): void;
|
||||
/** Returns the current sort option value. */
|
||||
sort(): Object;
|
||||
/** Sets the sort option value. */
|
||||
@@ -817,11 +823,26 @@ declare module DevExpress {
|
||||
export function setTemplateEngine(name: string): void;
|
||||
/** Sets a custom template engine defined via custom compile and render functions. */
|
||||
export function setTemplateEngine(options: Object): void;
|
||||
/** An object that serves as a namespace for utility methods that can be helpful when working with the DevExtreme framework and UI widgets. */
|
||||
export var utils: {
|
||||
/** Sets parameters for the viewport meta tag. */
|
||||
initMobileViewport(options: { allowZoom?: boolean; allowPan?: boolean; allowSelection?: boolean }): void;
|
||||
};
|
||||
}
|
||||
/** An object that serves as a namespace for utility methods that can be helpful when working with the DevExtreme framework and UI widgets. */
|
||||
export var utils: {
|
||||
/** Sets parameters for the viewport meta tag. */
|
||||
initMobileViewport(options: { allowZoom?: boolean; allowPan?: boolean; allowSelection?: boolean }): void;
|
||||
};
|
||||
/** An object that serves as a namespace for DevExtreme Data Visualization Widgets. */
|
||||
export module viz {
|
||||
/** Applies a theme for the entire page with several DevExtreme visualization widgets. */
|
||||
export function currentTheme(theme: string): void;
|
||||
/** Applies a new theme (with the color scheme defined separately) for the entire page with several DevExtreme visualization widgets. */
|
||||
export function currentTheme(platform: string, colorScheme: string): void;
|
||||
/** Registers a new theme based on the existing one. */
|
||||
export function registerTheme(customTheme: Object, baseTheme: string): void;
|
||||
/** Applies a predefined or registered custom palette to all visualization widgets at once. */
|
||||
export function currentPalette(paletteName: string): void;
|
||||
/** Obtains the color sets of a predefined or registered palette. */
|
||||
export function getPalette(paletteName: string): Object;
|
||||
/** Registers a new palette. */
|
||||
export function registerPalette(paletteName: string, palette: Object): void;
|
||||
}
|
||||
}
|
||||
declare module DevExpress.ui {
|
||||
@@ -894,7 +915,7 @@ declare module DevExpress.ui {
|
||||
constructor(element: JQuery, options?: dxTooltipOptions);
|
||||
constructor(element: Element, options?: dxTooltipOptions);
|
||||
}
|
||||
export interface dxDropDownListOptions extends dxDropDownEditorOptions {
|
||||
export interface dxDropDownListOptions extends dxDropDownEditorOptions, DataExpressionMixinOptions {
|
||||
/** Returns the value currently displayed by the widget. */
|
||||
displayValue?: string;
|
||||
/** The minimum number of characters that must be entered into the text box to begin a search. */
|
||||
@@ -1191,7 +1212,7 @@ declare module DevExpress.ui {
|
||||
/** Updates the dimensions of the scrollable contents. */
|
||||
update(): void;
|
||||
}
|
||||
export interface dxRadioGroupOptions extends CollectionWidgetOptions {
|
||||
export interface dxRadioGroupOptions extends CollectionWidgetOptions, DataExpressionMixinOptions {
|
||||
/** Specifies the radio group layout. */
|
||||
layout?: string;
|
||||
}
|
||||
@@ -1747,9 +1768,9 @@ declare module DevExpress.ui {
|
||||
/** A Globalize format string specifying the date display format. */
|
||||
formatString?: string;
|
||||
/** The last date that can be selected within the widget. */
|
||||
max?: Date;
|
||||
max?: any;
|
||||
/** The minimum date that can be selected within the widget. */
|
||||
min?: Date;
|
||||
min?: any;
|
||||
/** The text displayed by the widget when the widget value is not yet specified. This text is also used as a title of the date picker. */
|
||||
placeholder?: string;
|
||||
/**
|
||||
@@ -1757,8 +1778,8 @@ declare module DevExpress.ui {
|
||||
* @deprecated Use 'pickerType' option instead.
|
||||
*/
|
||||
useCalendar?: boolean;
|
||||
/** A Date object specifying the date and time currently selected using the date box. */
|
||||
value?: Date;
|
||||
/** An object or a value, specifying the date and time currently selected using the date box. */
|
||||
value?: any;
|
||||
/**
|
||||
* Specifies whether or not the widget uses the native HTML input element.
|
||||
* @deprecated Use 'pickerType' option instead.
|
||||
@@ -2661,6 +2682,8 @@ declare module DevExpress.ui {
|
||||
updateAppointment(target: Object, appointment: Object): void;
|
||||
/** Deletes the appointment defined by the parameter from the the data associated with the widget. */
|
||||
deleteAppointment(appointment: Object): void;
|
||||
/** Scrolls the scheduler work space to the specified time. */
|
||||
scrollToTime(hours: number, minutes: number): void;
|
||||
}
|
||||
export interface dxColorBoxOptions extends dxDropDownEditorOptions {
|
||||
/** Specifies the text displayed on the button that applies changes and closes the drop-down editor. */
|
||||
@@ -2735,6 +2758,10 @@ declare module DevExpress.ui {
|
||||
onItemExpanded?: Function;
|
||||
/** A handler for the itemCollapsed event. */
|
||||
onItemCollapsed?: Function;
|
||||
onItemClick?: Function;
|
||||
onItemContextMenu?: Function;
|
||||
onItemRendered?: Function;
|
||||
onItemHold?: Function;
|
||||
hoverStateEnabled?: boolean;
|
||||
focusStateEnabled?: boolean;
|
||||
}
|
||||
@@ -3795,6 +3822,8 @@ declare module DevExpress.framework {
|
||||
onExecute?: any;
|
||||
/** Indicates whether or not the widget that displays this command is disabled. */
|
||||
disabled?: boolean;
|
||||
/** Specifies whether the current command should is rendered when a view is being rendered, or after a view has been shown. */
|
||||
renderStage?: string;
|
||||
/** Specifies the name of the icon shown inside the widget associated with this command. */
|
||||
icon?: string;
|
||||
iconSrc?: string;
|
||||
@@ -4042,6 +4071,36 @@ declare module DevExpress.framework {
|
||||
}
|
||||
}
|
||||
declare module DevExpress.viz.core {
|
||||
/**
|
||||
* Applies a theme for the entire page with several DevExtreme visualization widgets.
|
||||
* @deprecated Use the DevExpress.viz.currentTheme(theme) method instead.
|
||||
*/
|
||||
export function currentTheme(theme: string): void;
|
||||
/**
|
||||
* Applies a new theme (with the color scheme defined separately) for the entire page with several DevExtreme visualization widgets.
|
||||
* @deprecated Use the DevExpress.viz.currentTheme(platform, colorScheme) method instead.
|
||||
*/
|
||||
export function currentTheme(platform: string, colorScheme: string): void;
|
||||
/**
|
||||
* Registers a new theme based on the existing one.
|
||||
* @deprecated Use the DevExpress.viz.registerTheme(customTheme, baseTheme) method instead.
|
||||
*/
|
||||
export function registerTheme(customTheme: Object, baseTheme: string): void;
|
||||
/**
|
||||
* Applies a predefined or registered custom palette to all visualization widgets at once.
|
||||
* @deprecated Use the DevExpress.viz.currentPalette(paletteName) method instead.
|
||||
*/
|
||||
export function currentPalette(paletteName: string): void;
|
||||
/**
|
||||
* Obtains the color sets of a predefined or registered palette.
|
||||
* @deprecated Use the DevExpress.viz.getPalette(paletteName) method instead.
|
||||
*/
|
||||
export function getPalette(paletteName: string): Object;
|
||||
/**
|
||||
* Registers a new palette.
|
||||
* @deprecated Use the DevExpress.viz.registerPalette(paletteName, palette) method instead.
|
||||
*/
|
||||
export function registerPalette(paletteName: string, palette: Object): void;
|
||||
export interface Border {
|
||||
/** Sets a border color for a selected series. */
|
||||
color?: string;
|
||||
@@ -5270,7 +5329,7 @@ declare module DevExpress.viz.charts {
|
||||
position?: string;
|
||||
}
|
||||
export interface ChartTooltip extends BaseChartTooltip {
|
||||
/** Specifies whether the tooltip must be located in the center of a bar or on its edge. Applies only to the Bar series. */
|
||||
/** Specifies whether the tooltip must be located in the center of a bar or on its edge. Applies to the Bar and Bubble series. */
|
||||
location?: string;
|
||||
/** Specifies the kind of information to display in a tooltip. */
|
||||
shared?: boolean;
|
||||
@@ -5860,6 +5919,8 @@ Indicates whether or not animation is enabled.
|
||||
};
|
||||
/** Specifies a value indicating whether all bars in a series must have the same width, or may have different widths if any points in other series are missing. */
|
||||
equalBarWidth?: any;
|
||||
/** Sets the name of the palette to be used in the range selector's chart. Alternatively, an array of colors can be set as a custom palette to be used within this chart. */
|
||||
palette?: any;
|
||||
/** An object defining the chart’s series. */
|
||||
series?: Array<viz.charts.SeriesConfig>;
|
||||
/** Defines options for the series template. */
|
||||
|
||||
@@ -6,3 +6,52 @@ dompurify.sanitize('<script>alert("hi")</script>');
|
||||
dompurify.addHook('beforeSanitizeElements', (el, data, config) => {
|
||||
return el;
|
||||
});
|
||||
|
||||
//examples from the DOMPurify README
|
||||
let dirty = '<script>alert("hi")</script><p>Totally safe<p><p onerror="blowUp()">Totally not safe</p>';
|
||||
|
||||
// allow only <b>
|
||||
dompurify.sanitize(dirty, {ALLOWED_TAGS: ['b']});
|
||||
|
||||
// allow only <b> and <q> with style attributes (for whatever reason)
|
||||
dompurify.sanitize(dirty, {ALLOWED_TAGS: ['b', 'q'], ALLOWED_ATTR: ['style']});
|
||||
|
||||
// leave all as it is but forbid <style>
|
||||
dompurify.sanitize(dirty, {FORBID_TAGS: ['style']});
|
||||
|
||||
// leave all as it is but forbid style attributes
|
||||
dompurify.sanitize(dirty, {FORBID_ATTR: ['style']});
|
||||
|
||||
// extend the existing array of allowed tags
|
||||
dompurify.sanitize(dirty, {ADD_TAGS: ['my-tag']});
|
||||
|
||||
// extend the existing array of attributes
|
||||
dompurify.sanitize(dirty, {ADD_ATTR: ['my-attr']});
|
||||
|
||||
// prohibit HTML5 data attributes (default is true)
|
||||
dompurify.sanitize(dirty, {ALLOW_DATA_ATTR: false});
|
||||
|
||||
// return a DOM HTMLBodyElement instead of an HTML string (default is false)
|
||||
dompurify.sanitize(dirty, {RETURN_DOM: true});
|
||||
|
||||
// return a DOM DocumentFragment instead of an HTML string (default is false)
|
||||
dompurify.sanitize(dirty, {RETURN_DOM_FRAGMENT: true});
|
||||
|
||||
// return a DOM DocumentFragment instead of an HTML string (default is false)
|
||||
// also import it into the current document (default is false).
|
||||
// RETURN_DOM_IMPORT must be set if you would like to append
|
||||
// the returned node to the current document
|
||||
let clean = dompurify.sanitize(dirty, {RETURN_DOM_FRAGMENT: true, RETURN_DOM_IMPORT: true});
|
||||
document.body.appendChild(clean);
|
||||
|
||||
// return entire document including <html> tags (default is false)
|
||||
dompurify.sanitize(dirty, {WHOLE_DOCUMENT: true});
|
||||
|
||||
// make output safe for usage in jQuery's $()/html() method (default is false)
|
||||
dompurify.sanitize(dirty, {SAFE_FOR_JQUERY: true});
|
||||
|
||||
// disable DOM Clobbering protection on output (default is true, handle with care!)
|
||||
dompurify.sanitize(dirty, {SANITIZE_DOM: false});
|
||||
|
||||
// discard an element's content when the element is removed (default is true)
|
||||
dompurify.sanitize(dirty, {KEEP_CONTENT: false});
|
||||
|
||||
Vendored
+21
-2
@@ -1,11 +1,30 @@
|
||||
// Type definitions for DOM Purify
|
||||
// Project: https://github.com/cure53/DOMPurify
|
||||
// Definitions by: Dave Taylor <http://davetayls.me>
|
||||
// Definitions by: Dave Taylor <http://davetayls.me>, Samira Bazuzi <https://github.com/bazuzi>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
interface IDOMPurify {
|
||||
sanitize(s:string):string;
|
||||
addHook(hook:string, cb:(currentNode:Element, data:any, config:any) => Element):void;
|
||||
sanitize(s:string, config:IDOMPurifyConfig):any;
|
||||
|
||||
addHook(hook:string, cb:(currentNode:Element, data:any, config:IDOMPurifyConfig) => Element):void;
|
||||
}
|
||||
|
||||
interface IDOMPurifyConfig {
|
||||
ADD_ATTR?:string[];
|
||||
ADD_TAGS?:string[];
|
||||
ALLOW_DATA_ATTR?:boolean;
|
||||
ALLOWED_ATTR?:string[];
|
||||
ALLOWED_TAGS?:string[];
|
||||
FORBID_ATTR?:string[];
|
||||
FORBID_TAGS?:string[];
|
||||
KEEP_CONTENT?:boolean;
|
||||
RETURN_DOM?:boolean;
|
||||
RETURN_DOM_FRAGMENT?:boolean;
|
||||
RETURN_DOM_IMPORT?:boolean;
|
||||
SAFE_FOR_JQUERY?:boolean;
|
||||
SANITIZE_DOM?:boolean;
|
||||
WHOLE_DOCUMENT?:boolean;
|
||||
}
|
||||
|
||||
declare var DOMPurify:IDOMPurify;
|
||||
|
||||
Vendored
+1
@@ -25,6 +25,7 @@ declare module DonnaTypes {
|
||||
type: string;
|
||||
name: string;
|
||||
bindingType: string;
|
||||
paramNames?: string[];
|
||||
classProperties?: any[];
|
||||
prototypeProperties?: number[][];
|
||||
doc?: string;
|
||||
|
||||
Vendored
+1
@@ -22,6 +22,7 @@ declare module drop {
|
||||
content?: Element | string | ((drop?: Drop) => string) | ((drop?: Drop) => Element);
|
||||
position?: string;
|
||||
openOn?: string;
|
||||
classes?: string;
|
||||
constrainToWindow?: boolean;
|
||||
constrainToScrollParent?: boolean;
|
||||
remove?: boolean;
|
||||
|
||||
Vendored
+19
-19
@@ -33,7 +33,7 @@ interface DropzoneOptions {
|
||||
resize?: ( file?: any ) => any;
|
||||
init?: () => void;
|
||||
acceptedFiles?: string;
|
||||
accept?: ( file: DropzoneFile, doneCallback: ( ...args ) => void ) => void;
|
||||
accept?: ( file: DropzoneFile, doneCallback: ( ...args: any[] ) => void ) => void;
|
||||
autoProcessQueue?: boolean;
|
||||
previewTemplate?: string;
|
||||
forceFallback?: boolean;
|
||||
@@ -67,9 +67,9 @@ declare class Dropzone {
|
||||
disable(): void;
|
||||
destroy(): Dropzone;
|
||||
|
||||
on( eventName, callback: ( ...args ) => any );
|
||||
on( eventName: string, callback: ( ...args: any[] ) => any ): void;
|
||||
|
||||
off( eventName ): void;
|
||||
off( eventName: string ): void;
|
||||
|
||||
addFile( file: DropzoneFile ): void;
|
||||
|
||||
@@ -99,24 +99,24 @@ declare class Dropzone {
|
||||
getFilesWithStatus( status: string ): DropzoneFile[];
|
||||
enqueueFile( file: DropzoneFile ): void;
|
||||
enqueueFiles( file: DropzoneFile[] ): void;
|
||||
createThumbnail( file: DropzoneFile, callback?: (...any) => {}): any;
|
||||
createThumbnailFromUrl( file: DropzoneFile, url: string, callback?: ( ...any ) => any ): any;
|
||||
createThumbnail( file: DropzoneFile, callback?: (...any: any[]) => {}): any;
|
||||
createThumbnailFromUrl( file: DropzoneFile, url: string, callback?: ( ...any: any[] ) => any ): any;
|
||||
|
||||
emit( eventName: string, file: DropzoneFile, str?: string );
|
||||
emit( eventName: "thumbnail", file: DropzoneFile, path: string );
|
||||
emit( eventName: "addedfile", file: DropzoneFile );
|
||||
emit( eventName: "removedfile", file: DropzoneFile );
|
||||
emit( eventName: "processing", file: DropzoneFile );
|
||||
emit( eventName: "canceled", file: DropzoneFile );
|
||||
emit( eventName: "complete", file: DropzoneFile );
|
||||
emit( eventName: string, file: DropzoneFile, str?: string ): void;
|
||||
emit( eventName: "thumbnail", file: DropzoneFile, path: string ): void;
|
||||
emit( eventName: "addedfile", file: DropzoneFile ): void;
|
||||
emit( eventName: "removedfile", file: DropzoneFile ): void;
|
||||
emit( eventName: "processing", file: DropzoneFile ): void;
|
||||
emit( eventName: "canceled", file: DropzoneFile ): void;
|
||||
emit( eventName: "complete", file: DropzoneFile ): void;
|
||||
|
||||
emit( eventName: string, e: Event );
|
||||
emit( eventName: "drop", e: Event );
|
||||
emit( eventName: "dragstart", e: Event );
|
||||
emit( eventName: "dragend", e: Event );
|
||||
emit( eventName: "dragenter", e: Event );
|
||||
emit( eventName: "dragover", e: Event );
|
||||
emit( eventName: "dragleave", e: Event );
|
||||
emit( eventName: string, e: Event ): void;
|
||||
emit( eventName: "drop", e: Event ): void;
|
||||
emit( eventName: "dragstart", e: Event ): void;
|
||||
emit( eventName: "dragend", e: Event ): void;
|
||||
emit( eventName: "dragenter", e: Event ): void;
|
||||
emit( eventName: "dragover", e: Event ): void;
|
||||
emit( eventName: "dragleave", e: Event ): void;
|
||||
}
|
||||
|
||||
interface JQuery {
|
||||
|
||||
Vendored
+1
-1
@@ -925,7 +925,7 @@ declare module createjs {
|
||||
static framerate: number;
|
||||
static interval: number;
|
||||
static maxDelta: number;
|
||||
static paused: number;
|
||||
static paused: boolean;
|
||||
static RAF: string;
|
||||
static RAF_SYNCHED: string;
|
||||
static TIMEOUT: string;
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
* Created by karl on 14/07/15.
|
||||
*/
|
||||
|
||||
/// <reference path="../express/express.d.ts" />
|
||||
/// <reference path="../easy-xapi/easy-xapi.d.ts" />
|
||||
/// <reference path="./easy-xapi-utils.d.ts" />
|
||||
|
||||
import express = require('express');
|
||||
import eXapi = require('easy-xapi');
|
||||
import eUtils = require('easy-xapi-utils');
|
||||
|
||||
eXapi.init({
|
||||
jSend: {
|
||||
partial: true
|
||||
}
|
||||
});
|
||||
|
||||
var xApi = eXapi.create({
|
||||
root: __dirname,
|
||||
log: {
|
||||
name: 'Log',
|
||||
level: 'info'
|
||||
},
|
||||
port: 3000,
|
||||
name: 'test',
|
||||
mount: function (app) {
|
||||
app.get('/', eUtils.isLoggedIn(), function (req, res) {
|
||||
res.send('ok');
|
||||
});
|
||||
app.get('/role', eUtils.isLoggedIn('admin'), function (req, res) {
|
||||
res.send('ok');
|
||||
});
|
||||
app.get('/', eUtils.isLoggedOut(), function (req, res) {
|
||||
res.send('ok');
|
||||
});
|
||||
app.get('/role', eUtils.hasRole('guest'), function (req, res) {
|
||||
res.send('ok');
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
xApi.listen();
|
||||
Vendored
+16
@@ -0,0 +1,16 @@
|
||||
// Type definitions for easy-xapi-utils
|
||||
// Project: https://github.com/DeadAlready/easy-xapi-utils
|
||||
// Definitions by: Karl Düüna <https://github.com/DeadAlready/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../express/express.d.ts" />
|
||||
/// <reference path="../easy-jsend/easy-jsend.d.ts" />
|
||||
/// <reference path="../easy-x-headers/easy-x-headers.d.ts" />
|
||||
|
||||
declare module "easy-xapi-utils" {
|
||||
import express = require('express');
|
||||
|
||||
export function isLoggedIn(role?: string): express.RequestHandler;
|
||||
export function isLoggedOut(): express.RequestHandler;
|
||||
export function hasRole(role: string): express.RequestHandler;
|
||||
}
|
||||
Vendored
+3
-1
@@ -349,6 +349,8 @@ interface CoreObjectArguments {
|
||||
Override to implement teardown.
|
||||
**/
|
||||
willDestroy?: Function;
|
||||
|
||||
[propName: string]: any;
|
||||
}
|
||||
|
||||
interface EnumerableConfigurationOptions {
|
||||
@@ -998,7 +1000,7 @@ declare module Ember {
|
||||
@static
|
||||
@param {Object} [args] - Object containing values to use within the new class
|
||||
**/
|
||||
static extend<T>(args ?: CoreObjectArguments): T;
|
||||
static extend<T>(args?: CoreObjectArguments): T;
|
||||
/**
|
||||
Creates a new subclass.
|
||||
@method extend
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
/// <reference path="envify.d.ts" />
|
||||
/// <reference path="../browserify/browserify.d.ts" />
|
||||
|
||||
import browserify = require('browserify');
|
||||
import envify = require('envify/custom');
|
||||
import fs = require('fs');
|
||||
|
||||
|
||||
var b = browserify('main.js')
|
||||
, output = fs.createWriteStream('bundle.js');
|
||||
|
||||
b.transform(envify({
|
||||
NODE_ENV: 'development'
|
||||
}));
|
||||
b.bundle().pipe(output);
|
||||
|
||||
b.transform(envify({
|
||||
_: 'purge'
|
||||
, NODE_ENV: 'development'
|
||||
}));
|
||||
|
||||
Vendored
+14
@@ -0,0 +1,14 @@
|
||||
// Type definitions for envify
|
||||
// Project: https://github.com/hughsk/envify
|
||||
// Definitions by: Qubo <https://github.com/tkQubo>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
declare module "envify" {
|
||||
var envify: Function;
|
||||
export = envify;
|
||||
}
|
||||
|
||||
declare module "envify/custom" {
|
||||
function envify(environment: { [name: string]: any }): Function;
|
||||
export = envify;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
/// <reference path="./express-less.d.ts" />
|
||||
|
||||
import express = require('express');
|
||||
import expressLess = require('express-less');
|
||||
|
||||
var app = express();
|
||||
var lessOptions: expressLess.Options = {};
|
||||
lessOptions.compress = true;
|
||||
lessOptions.debug = true;
|
||||
|
||||
app.use('/less-css', expressLess(__dirname));
|
||||
app.use('/less-css-with-options', expressLess(__dirname + "/less", lessOptions));
|
||||
Vendored
+21
@@ -0,0 +1,21 @@
|
||||
// Type definitions for express-less
|
||||
// Project: https://www.npmjs.com/package/express-less
|
||||
// Definitions by: xyb <https://github.com/xieyubo>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../express/express.d.ts" />
|
||||
|
||||
declare module "express-less" {
|
||||
import express = require('express');
|
||||
|
||||
function less(root: string, options?: less.Options): express.RequestHandler;
|
||||
|
||||
module less {
|
||||
export interface Options {
|
||||
debug?: boolean;
|
||||
compress?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
export = less;
|
||||
}
|
||||
+19
-19
@@ -34,8 +34,8 @@ function sample1() {
|
||||
|
||||
function sample2() {
|
||||
|
||||
var dot, i,
|
||||
t1, t2,
|
||||
var dot: fabric.ICircle, i: number,
|
||||
t1: number, t2: number,
|
||||
startTimer = function() {
|
||||
t1 = new Date().getTime();
|
||||
return t1;
|
||||
@@ -89,16 +89,16 @@ function sample2() {
|
||||
|
||||
function sample3() {
|
||||
|
||||
var $ = function(id) { return document.getElementById(id) };
|
||||
var $: (id: string) => HTMLElement = function(id: string) { return document.getElementById(id) };
|
||||
|
||||
function applyFilter(index, filter) {
|
||||
var obj = <fabric.IImage>canvas.getActiveObject();
|
||||
function applyFilter(index: number, filter: any) {
|
||||
var obj: fabric.IImage = <fabric.IImage>canvas.getActiveObject();
|
||||
obj.filters[index] = filter;
|
||||
obj.applyFilters(canvas.renderAll.bind(canvas));
|
||||
}
|
||||
|
||||
function applyFilterValue(index, prop, value) {
|
||||
var obj = <fabric.IImage>canvas.getActiveObject();
|
||||
function applyFilterValue(index: number, prop: string, value: any) {
|
||||
var obj: fabric.IImage = <fabric.IImage>canvas.getActiveObject();
|
||||
if (obj.filters[index]) {
|
||||
obj.filters[index][prop] = value;
|
||||
obj.applyFilters(canvas.renderAll.bind(canvas));
|
||||
@@ -214,7 +214,7 @@ function sample3() {
|
||||
function sample4() {
|
||||
|
||||
var canvas = new fabric.Canvas('c');
|
||||
var $ = function(id) { return document.getElementById(id); };
|
||||
var $: (id: string) => HTMLElement = function(id: string) { return document.getElementById(id); };
|
||||
|
||||
var rect = new fabric.Rect({
|
||||
width: 100,
|
||||
@@ -339,10 +339,10 @@ function sample6() {
|
||||
canvas.centerObject(obj);
|
||||
canvas.add(obj);
|
||||
|
||||
canvas.add(obj.clone(() => {}).set({ left: 100, top: 100, angle: -15 }));
|
||||
canvas.add(obj.clone(() => {}).set({ left: 480, top: 100, angle: 15 }));
|
||||
canvas.add(obj.clone(() => {}).set({ left: 100, top: 400, angle: -15 }));
|
||||
canvas.add(obj.clone(() => {}).set({ left: 480, top: 400, angle: 15 }));
|
||||
canvas.add(obj.clone(() => { }).set({ left: 100, top: 100, angle: -15 }));
|
||||
canvas.add(obj.clone(() => { }).set({ left: 480, top: 100, angle: 15 }));
|
||||
canvas.add(obj.clone(() => { }).set({ left: 100, top: 400, angle: -15 }));
|
||||
canvas.add(obj.clone(() => { }).set({ left: 480, top: 400, angle: 15 }));
|
||||
|
||||
canvas.on('mouse:move', function(options) {
|
||||
var p = canvas.getPointer(options.e);
|
||||
@@ -456,7 +456,7 @@ function sample8() {
|
||||
top = fabric.util.getRandomInt(0 + offset, 500 - offset),
|
||||
angle = fabric.util.getRandomInt(-20, 40),
|
||||
width = fabric.util.getRandomInt(30, 50),
|
||||
opacity = (function(min, max) { return Math.random() * (max - min) + min; })(0.5, 1);
|
||||
opacity = (function(min: number, max: number) { return Math.random() * (max - min) + min; })(0.5, 1);
|
||||
|
||||
|
||||
switch (className) {
|
||||
@@ -522,7 +522,7 @@ function sample8() {
|
||||
break;
|
||||
|
||||
case 'shape':
|
||||
var id = element.id, match;
|
||||
var id: any = element.id, match: RegExpExecArray;
|
||||
if (match = /\d+$/.exec(id)) {
|
||||
fabric.loadSVGFromURL('../assets/' + match[0] + '.svg', function(objects, options) {
|
||||
var loadedObject = fabric.util.groupSVGElements(objects, options);
|
||||
@@ -586,7 +586,7 @@ function sample8() {
|
||||
}
|
||||
};
|
||||
|
||||
var supportsInputOfType = function(type) {
|
||||
var supportsInputOfType = function(type: string) {
|
||||
return function() {
|
||||
var el = <HTMLInputElement>document.createElement('input');
|
||||
try {
|
||||
@@ -746,7 +746,7 @@ function sample8() {
|
||||
canvas.on('object:selected', onObjectSelected);
|
||||
canvas.on('group:selected', onObjectSelected);
|
||||
|
||||
function onObjectSelected(e) {
|
||||
function onObjectSelected(e: fabric.IEvent) {
|
||||
var selectedObject = e.target;
|
||||
|
||||
for (var i = activeObjectButtons.length; i--;) {
|
||||
@@ -1033,7 +1033,7 @@ function sample8() {
|
||||
};
|
||||
|
||||
canvas.on('object:selected', function(e: fabric.IEvent) {
|
||||
slider.value = String((<fabric.IText>e.target).lineHeight );
|
||||
slider.value = String((<fabric.IText>e.target).lineHeight);
|
||||
});
|
||||
})();
|
||||
}
|
||||
@@ -1050,6 +1050,6 @@ function sample8() {
|
||||
|
||||
function sample9() {
|
||||
var canvas = new fabric.Canvas('c');
|
||||
canvas.setBackgroundImage('yolo.jpg',() => { "a" }, { opacity: 45 });
|
||||
canvas.setBackgroundImage('yolo.jpg',() => { "a" });
|
||||
canvas.setBackgroundImage('yolo.jpg', () => { "a" }, { opacity: 45 });
|
||||
canvas.setBackgroundImage('yolo.jpg', () => { "a" });
|
||||
}
|
||||
|
||||
Vendored
+58
-54
@@ -1,6 +1,6 @@
|
||||
// Type definitions for FabricJS v1.5.0
|
||||
// Project: http://fabricjs.com/
|
||||
// Definitions by: Oliver Klemencic <https://github.com/oklemencic/>, Joseph Livecchi <https://github.com/joewashear007/>
|
||||
// Definitions by: Oliver Klemencic <https://github.com/oklemencic/>, Joseph Livecchi <https://github.com/joewashear007/>, Michael Randolph <https://github.com/mrand01/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/* tslint:disable:no-unused-variable */
|
||||
@@ -41,7 +41,7 @@ declare module fabric {
|
||||
* @param {Function} callback
|
||||
* @param {Function} [reviver] Method for further parsing of SVG elements, called after each fabric object created.
|
||||
*/
|
||||
function loadSVGFromString(string: string, callback: (results: IObject[], options: any) => void, reviver?: Function);
|
||||
function loadSVGFromString(string: string, callback: (results: IObject[], options: any) => void, reviver?: Function): void;
|
||||
/**
|
||||
* Takes url corresponding to an SVG document, and parses it into a set of fabric objects.
|
||||
* Note that SVG is fetched via XMLHttpRequest, so it needs to conform to SOP (Same Origin Policy)
|
||||
@@ -49,14 +49,14 @@ declare module fabric {
|
||||
* @param {Function} callback
|
||||
* @param {Function} [reviver] Method for further parsing of SVG elements, called after each fabric object created.
|
||||
*/
|
||||
function loadSVGFromURL(url: string, callback: (results: IObject[], options: any) => void, reviver?: Function);
|
||||
function loadSVGFromURL(url: string, callback: (results: IObject[], options: any) => void, reviver?: Function): void;
|
||||
/**
|
||||
* Returns CSS rules for a given SVG document
|
||||
* @param {SVGDocument} doc SVG document to parse
|
||||
*/
|
||||
function getCSSRules(doc: SVGElement): any;
|
||||
|
||||
function parseElements(elements: any[], callback: Function, options: any, reviver?: Function);
|
||||
function parseElements(elements: any[], callback: Function, options: any, reviver?: Function): void;
|
||||
/**
|
||||
* Parses "points" attribute, returning an array of values
|
||||
* @param {String} points points attribute string
|
||||
@@ -99,7 +99,7 @@ declare module fabric {
|
||||
* @param {Function} callback Callback to call when parsing is finished; It's being passed an array of elements (parsed from a document).
|
||||
* @param {Function} [reviver] Method for further parsing of SVG elements, called after each fabric object created.
|
||||
*/
|
||||
function parseSVGDocument(doc: SVGElement, callback: (results: IObject[], options: any) => void, reviver?: Function);
|
||||
function parseSVGDocument(doc: SVGElement, callback: (results: IObject[], options: any) => void, reviver?: Function): void;
|
||||
/**
|
||||
* Parses "transform" attribute, returning an array of values
|
||||
* @param {String} attributeValue String containing attribute value
|
||||
@@ -111,11 +111,11 @@ declare module fabric {
|
||||
/**
|
||||
* Wrapper around `console.log` (when available)
|
||||
*/
|
||||
function log(...values: any[]);
|
||||
function log(...values: any[]): void;
|
||||
/**
|
||||
* Wrapper around `console.warn` (when available)
|
||||
*/
|
||||
function warn(...values: any[]);
|
||||
function warn(...values: any[]): void;
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
// Classes
|
||||
@@ -438,7 +438,7 @@ declare module fabric {
|
||||
/**
|
||||
* Sets source of this color (where source is an array representation; ex: [200, 200, 100, 1])
|
||||
*/
|
||||
setSource(source: number[]);
|
||||
setSource(source: number[]): void;
|
||||
|
||||
/**
|
||||
* Returns color represenation in RGB format ex: rgb(0-255,0-255,0-255)
|
||||
@@ -474,7 +474,7 @@ declare module fabric {
|
||||
* Sets value of alpha channel for this color
|
||||
* @param {Number} alpha Alpha value 0-1
|
||||
*/
|
||||
setAlpha(alpha: number);
|
||||
setAlpha(alpha: number): void;
|
||||
|
||||
/**
|
||||
* Transforms color to its grayscale representation
|
||||
@@ -627,17 +627,17 @@ declare module fabric {
|
||||
/**
|
||||
* Appends a point to intersection
|
||||
*/
|
||||
appendPoint(point: IPoint);
|
||||
appendPoint(point: IPoint): void;
|
||||
/**
|
||||
* Appends points to intersection
|
||||
*/
|
||||
appendPoints(points: IPoint[]);
|
||||
appendPoints(points: IPoint[]): void;
|
||||
}
|
||||
interface IIntersectionStatic {
|
||||
/**
|
||||
* Intersection class
|
||||
*/
|
||||
new (status?: string);
|
||||
new (status?: string): void;
|
||||
/**
|
||||
* Checks if polygon intersects another polygon
|
||||
*/
|
||||
@@ -1313,7 +1313,7 @@ declare module fabric {
|
||||
/**
|
||||
* Callback; invoked right before object is about to be scaled/rotated
|
||||
*/
|
||||
onBeforeScaleRotate(target: IObject);
|
||||
onBeforeScaleRotate(target: IObject): void;
|
||||
|
||||
// Functions from object straighten mixin
|
||||
// --------------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -1839,12 +1839,12 @@ declare module fabric {
|
||||
filters: IBaseFilter[];
|
||||
}
|
||||
interface IImage extends IObject, IImageOptions {
|
||||
initialize(element?: string|HTMLImageElement, options?: IImageOptions);
|
||||
initialize(element?: string|HTMLImageElement, options?: IImageOptions): void;
|
||||
/**
|
||||
* Applies filters assigned to this image (from "filters" array)
|
||||
* @param {Function} callback Callback is invoked when all filters have been applied and new image is generated
|
||||
*/
|
||||
applyFilters(callback: Function);
|
||||
applyFilters(callback: Function): void;
|
||||
/**
|
||||
* Returns a clone of an instance
|
||||
* @param {Function} callback Callback is invoked with a clone as a first argument
|
||||
@@ -1871,7 +1871,7 @@ declare module fabric {
|
||||
* @return {String} Source of an image
|
||||
*/
|
||||
getSrc(): string;
|
||||
render(ctx: CanvasRenderingContext2D, noTransform: boolean);
|
||||
render(ctx: CanvasRenderingContext2D, noTransform: boolean): void;
|
||||
|
||||
/**
|
||||
* Sets image element for this instance to a specified one.
|
||||
@@ -2539,7 +2539,7 @@ declare module fabric {
|
||||
* Sets object's properties from options
|
||||
* @param {Object} [options] Options object
|
||||
*/
|
||||
setOptions(options: any);
|
||||
setOptions(options: any): void;
|
||||
/**
|
||||
* Sets sourcePath of an object
|
||||
* @param {String} value Value to set sourcePath to
|
||||
@@ -2850,7 +2850,7 @@ declare module fabric {
|
||||
}
|
||||
|
||||
interface IPathGroup extends IObject {
|
||||
initialize(paths: IPath[], options?: IObjectOptions);
|
||||
initialize(paths: IPath[], options?: IObjectOptions): void;
|
||||
/**
|
||||
* Returns number representation of object's complexity
|
||||
* @return {Number} complexity
|
||||
@@ -2865,7 +2865,7 @@ declare module fabric {
|
||||
* Renders this group on a specified context
|
||||
* @param {CanvasRenderingContext2D} ctx Context to render this instance on
|
||||
*/
|
||||
render(ctx: CanvasRenderingContext2D);
|
||||
render(ctx: CanvasRenderingContext2D): void;
|
||||
/**
|
||||
* Returns dataless object representation of this path group
|
||||
* @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output
|
||||
@@ -2993,7 +2993,7 @@ declare module fabric {
|
||||
minY?: number;
|
||||
}
|
||||
interface IPolyline extends IObject, IPolylineOptions {
|
||||
initialize(points: IPoint[], options?: IPolylineOptions);
|
||||
initialize(points: IPoint[], options?: IPolylineOptions): void;
|
||||
/**
|
||||
* Returns complexity of an instance
|
||||
* @return {Number} complexity of this instance
|
||||
@@ -3158,7 +3158,7 @@ declare module fabric {
|
||||
* Renders text instance on a specified context
|
||||
* @param {CanvasRenderingContext2D} ctx Context to render on
|
||||
*/
|
||||
render(ctx: CanvasRenderingContext2D, noTransform: boolean);
|
||||
render(ctx: CanvasRenderingContext2D, noTransform: boolean): void;
|
||||
/**
|
||||
* Returns object representation of an instance
|
||||
* @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output
|
||||
@@ -3347,7 +3347,7 @@ declare module fabric {
|
||||
* Returns true if object has no styling
|
||||
*/
|
||||
isEmptyStyles(): boolean;
|
||||
render(ctx: CanvasRenderingContext2D, noTransform: boolean);
|
||||
render(ctx: CanvasRenderingContext2D, noTransform: boolean): void;
|
||||
/**
|
||||
* Returns object representation of an instance
|
||||
* @method toObject
|
||||
@@ -4149,37 +4149,41 @@ declare module fabric {
|
||||
requestAnimFrame(callback: Function): void;
|
||||
}
|
||||
|
||||
interface IUtilAminEaseFunction {
|
||||
(t: number, b: number, c: number, d: number): number;
|
||||
}
|
||||
|
||||
interface IUtilAnimEase {
|
||||
easeInBack(): Function;
|
||||
easeInBounce(): Function;
|
||||
easeInCirc(): Function;
|
||||
easeInCubic(): Function;
|
||||
easeInElastic(): Function;
|
||||
easeInExpo(): Function;
|
||||
easeInOutBack(): Function;
|
||||
easeInOutBounce(): Function;
|
||||
easeInOutCirc(): Function;
|
||||
easeInOutCubic(): Function;
|
||||
easeInOutElastic(): Function;
|
||||
easeInOutExpo(): Function;
|
||||
easeInOutQuad(): Function;
|
||||
easeInOutQuart(): Function;
|
||||
easeInOutQuint(): Function;
|
||||
easeInOutSine(): Function;
|
||||
easeInQuad(): Function;
|
||||
easeInQuart(): Function;
|
||||
easeInQuint(): Function;
|
||||
easeInSine(): Function;
|
||||
easeOutBack(): Function;
|
||||
easeOutBounce(): Function;
|
||||
easeOutCirc(): Function;
|
||||
easeOutCubic(): Function;
|
||||
easeOutElastic(): Function;
|
||||
easeOutExpo(): Function;
|
||||
easeOutQuad(): Function;
|
||||
easeOutQuart(): Function;
|
||||
easeOutQuint(): Function;
|
||||
easeOutSine(): Function;
|
||||
easeInBack: IUtilAminEaseFunction;
|
||||
easeInBounce: IUtilAminEaseFunction;
|
||||
easeInCirc: IUtilAminEaseFunction;
|
||||
easeInCubic: IUtilAminEaseFunction;
|
||||
easeInElastic: IUtilAminEaseFunction;
|
||||
easeInExpo: IUtilAminEaseFunction;
|
||||
easeInOutBack: IUtilAminEaseFunction;
|
||||
easeInOutBounce: IUtilAminEaseFunction;
|
||||
easeInOutCirc: IUtilAminEaseFunction;
|
||||
easeInOutCubic: IUtilAminEaseFunction;
|
||||
easeInOutElastic: IUtilAminEaseFunction;
|
||||
easeInOutExpo: IUtilAminEaseFunction;
|
||||
easeInOutQuad: IUtilAminEaseFunction;
|
||||
easeInOutQuart: IUtilAminEaseFunction;
|
||||
easeInOutQuint: IUtilAminEaseFunction;
|
||||
easeInOutSine: IUtilAminEaseFunction;
|
||||
easeInQuad: IUtilAminEaseFunction;
|
||||
easeInQuart: IUtilAminEaseFunction;
|
||||
easeInQuint: IUtilAminEaseFunction;
|
||||
easeInSine: IUtilAminEaseFunction;
|
||||
easeOutBack: IUtilAminEaseFunction;
|
||||
easeOutBounce: IUtilAminEaseFunction;
|
||||
easeOutCirc: IUtilAminEaseFunction;
|
||||
easeOutCubic: IUtilAminEaseFunction;
|
||||
easeOutElastic: IUtilAminEaseFunction;
|
||||
easeOutExpo: IUtilAminEaseFunction;
|
||||
easeOutQuad: IUtilAminEaseFunction;
|
||||
easeOutQuart: IUtilAminEaseFunction;
|
||||
easeOutQuint: IUtilAminEaseFunction;
|
||||
easeOutSine: IUtilAminEaseFunction;
|
||||
}
|
||||
|
||||
interface IUtilArc {
|
||||
@@ -4360,13 +4364,13 @@ declare module fabric {
|
||||
* @param {Object} [properties] Properties shared by all instances of this class
|
||||
* (be careful modifying objects defined here as this would affect all instances)
|
||||
*/
|
||||
createClass(parent: Function, properties?: any);
|
||||
createClass(parent: Function, properties?: any): void;
|
||||
/**
|
||||
* Helper for creation of "classes".
|
||||
* @param {Object} [properties] Properties shared by all instances of this class
|
||||
* (be careful modifying objects defined here as this would affect all instances)
|
||||
*/
|
||||
createClass(properties?: any);
|
||||
createClass(properties?: any): void;
|
||||
|
||||
}
|
||||
|
||||
|
||||
Vendored
+6
@@ -125,7 +125,13 @@ declare module "famous/dom-renderables" {
|
||||
}
|
||||
|
||||
export interface IDOMElementOptions {
|
||||
tagName?: string;
|
||||
classes?: string[];
|
||||
attributes?: { [attributeName: string]: string };
|
||||
properties?: { [attributeName: string]: string };
|
||||
id?: string;
|
||||
content?: string;
|
||||
cutout?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -116,7 +116,7 @@ $(".fancybox").fancybox({
|
||||
}
|
||||
});
|
||||
$(".fancybox").fancybox({
|
||||
beforeLoad: function () {
|
||||
beforeLoad: () => {
|
||||
this.title = 'Image ' + (this.index + 1) + ' of ' + this.group.length + (this.title ? ' - ' + this.title : '');
|
||||
}
|
||||
});
|
||||
|
||||
Vendored
+11
-11
@@ -6,7 +6,7 @@
|
||||
|
||||
/// <reference path="../jquery/jquery.d.ts" />
|
||||
|
||||
interface FancyboxOptions {
|
||||
interface FancyboxOptions extends FancyboxCallback {
|
||||
padding?: any; // number or []
|
||||
margin?: any; // number or []
|
||||
width?: any; // number or []
|
||||
@@ -96,16 +96,16 @@ interface FancyboxMethods {
|
||||
}
|
||||
|
||||
interface FancyboxCallback {
|
||||
onCancel;
|
||||
beforeLoad;
|
||||
afterLoad;
|
||||
beforeShow;
|
||||
afterShow;
|
||||
beforeClose;
|
||||
afterClose;
|
||||
onUpdate;
|
||||
onPlayStart;
|
||||
onPlayEnd;
|
||||
onCancel?: Function;
|
||||
beforeLoad?: Function;
|
||||
afterLoad?: Function;
|
||||
beforeShow?: Function;
|
||||
afterShow?: Function;
|
||||
beforeClose?: Function;
|
||||
afterClose?: Function;
|
||||
onUpdate?: Function;
|
||||
onPlayStart?: Function;
|
||||
onPlayEnd?: Function;
|
||||
}
|
||||
|
||||
interface FancyboxThumbnailHelperOptions {
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
/// <reference path="./favico.js.d.ts"/>
|
||||
|
||||
|
||||
// constructor options
|
||||
|
||||
var plain = (): favicojs.Favico => new Favico({
|
||||
});
|
||||
|
||||
var repositioned = (): favicojs.Favico => new Favico({
|
||||
position: 'upleft'
|
||||
});
|
||||
|
||||
var shaped = (): favicojs.Favico => new Favico({
|
||||
type: 'rectangle'
|
||||
});
|
||||
|
||||
var usingCustomFont = (): favicojs.Favico => new Favico({
|
||||
fontFamily: 'FontAwesome',
|
||||
elementId: 'badgefont'
|
||||
});
|
||||
|
||||
var colored = (): favicojs.Favico => new Favico({
|
||||
bgColor: '#5CB85C',
|
||||
textColor: '#ff0'
|
||||
});
|
||||
|
||||
var domBound = (): favicojs.Favico => new Favico({
|
||||
element: document.getElementById('favico')
|
||||
});
|
||||
|
||||
var iconUrlHandler = (url: string): void => {
|
||||
console.log(url);
|
||||
};
|
||||
var withDataUrl = (): favicojs.Favico => new Favico({
|
||||
dataUrl: iconUrlHandler
|
||||
});
|
||||
|
||||
|
||||
var favicons: favicojs.Favico[] = [
|
||||
plain(),
|
||||
repositioned(),
|
||||
shaped(),
|
||||
usingCustomFont(),
|
||||
colored(),
|
||||
domBound(),
|
||||
withDataUrl(),
|
||||
];
|
||||
|
||||
|
||||
// public methods
|
||||
|
||||
favicons.map(favico => {
|
||||
|
||||
// badge
|
||||
favico.badge(2);
|
||||
favico.badge(3, 'slide');
|
||||
favico.badge(3000, {animation: 'none', type: 'rectangle'});
|
||||
favico.reset();
|
||||
|
||||
// image
|
||||
favico.image(document.getElementById('image'));
|
||||
|
||||
// video
|
||||
favico.video(document.getElementById('video'));
|
||||
|
||||
// webcam
|
||||
favico.webcam();
|
||||
});
|
||||
Vendored
+43
@@ -0,0 +1,43 @@
|
||||
// Type definitions for favico.js
|
||||
// Project: http://lab.ejci.net/favico.js/
|
||||
// Definitions by: Yu Matsushita <https://github.com/drowse314-dev-ymat>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
|
||||
declare module favicojs {
|
||||
|
||||
interface FavicoJsStatic {
|
||||
new (opt?: FavicoJsOptions): Favico;
|
||||
}
|
||||
|
||||
interface FavicoJsOptions {
|
||||
bgColor?: string;
|
||||
textColor?: string;
|
||||
fontFamily?: string;
|
||||
fontStyle?: string;
|
||||
type?: string;
|
||||
position?: string;
|
||||
animation?: string;
|
||||
elementId?: string;
|
||||
element?: HTMLElement;
|
||||
dataUrl?: (url: string) => any;
|
||||
}
|
||||
|
||||
interface Favico {
|
||||
|
||||
badge(number: number): void;
|
||||
badge(number: number, animation: string): void;
|
||||
badge(number: number, opts: FavicoJsOptions): void;
|
||||
|
||||
reset(): void;
|
||||
|
||||
image(imageElement: HTMLElement): void;
|
||||
|
||||
video(imageElement: HTMLElement): void;
|
||||
|
||||
webcam(): void;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
declare var Favico: favicojs.FavicoJsStatic;
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
// Type definitions for freedom v0.6.26
|
||||
// Project: https://github.com/freedomjs/freedom
|
||||
// Definitions by: Jonathan Pevarnek <https://github.com/jpevarnek/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="./freedom.d.ts" />
|
||||
|
||||
declare var freedom :freedom.FreedomInCoreEnv;
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
// Type definitions for freedom v0.6.26
|
||||
// Project: https://github.com/freedomjs/freedom
|
||||
// Definitions by: Jonathan Pevarnek <https://github.com/jpevarnek/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="./freedom.d.ts" />
|
||||
|
||||
declare var freedom :freedom.FreedomInModuleEnv;
|
||||
@@ -0,0 +1,24 @@
|
||||
/// <reference path="../es6-promise/es6-promise.d.ts"/>
|
||||
/// <reference path="freedom.d.ts" />
|
||||
|
||||
var freedomModule :freedom.FreedomInModuleEnv;
|
||||
var freedomCore :freedom.FreedomInCoreEnv;
|
||||
|
||||
var parentModule :freedom.ParentModuleThing = freedomModule();
|
||||
parentModule.on('message', (x :string) => {
|
||||
});
|
||||
|
||||
var coreInModule :freedom.Core = freedomModule['core']();
|
||||
coreInModule.getLogger('tag').then((logger :freedom.Logger) => {
|
||||
logger.log('message');
|
||||
});
|
||||
|
||||
var freedomConsole :freedom.Console.Console = freedomModule['core.console']();
|
||||
var doneLogging :Promise<void> = freedomConsole.log('source', 'message');
|
||||
|
||||
freedomCore('freedom-module.json', {
|
||||
'logger': 'loggingprovider.json',
|
||||
'debug': 'log'
|
||||
}).then((moduleFactory) => {
|
||||
moduleFactory.close();
|
||||
});
|
||||
Vendored
+573
@@ -0,0 +1,573 @@
|
||||
// Type definitions for freedom v0.6.26
|
||||
// Project: https://github.com/freedomjs/freedom
|
||||
// Definitions by: Jonathan Pevarnek <https://github.com/jpevarnek/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../es6-promise/es6-promise.d.ts"/>
|
||||
|
||||
declare module freedom {
|
||||
// Common on/emit for message passing interfaces.
|
||||
interface EventDispatchFn<T> { (eventType: string, value?: T): void; }
|
||||
interface EventHandlerFn<T> {
|
||||
(eventType: string, handler: (eventData:T) => void): void;
|
||||
}
|
||||
|
||||
interface Error {
|
||||
errcode: string;
|
||||
message: string;
|
||||
}
|
||||
|
||||
// TODO: replace OnAndEmit with EventHandler and EventEmitter;
|
||||
interface OnAndEmit<T,T2> {
|
||||
on: EventHandlerFn<T>;
|
||||
emit: EventDispatchFn<T2>;
|
||||
}
|
||||
|
||||
interface EventHandler {
|
||||
// Adds |f| as an event handler for all subsiquent events of type |t|.
|
||||
on(t: string, f: Function): void;
|
||||
// Adds |f| as an event handler for only the next event of type |t|.
|
||||
once(t: string, f: Function): void;
|
||||
// The |off| function removes the event event handling function |f| from
|
||||
// both |on| and the |once| event handling.
|
||||
off(t: string, f: Function): void;
|
||||
}
|
||||
|
||||
interface PortModule<T, T2> extends OnAndEmit<T, T2> {
|
||||
controlChannel: string;
|
||||
}
|
||||
|
||||
interface ModuleSelfConstructor {
|
||||
// Identifies a named API's provider class.
|
||||
provideSynchronous: (classFn?: Function) => void;
|
||||
provideAsynchronous :(classFn?: Function) => void;
|
||||
providePromises: (classFn?: Function) => void;
|
||||
}
|
||||
|
||||
interface ParentModuleThing extends ModuleSelfConstructor, OnAndEmit<any, any> {
|
||||
}
|
||||
|
||||
interface Logger {
|
||||
debug(...args: any[]): void;
|
||||
info(...args: any[]): void;
|
||||
log(...args: any[]): void;
|
||||
warn(...args: any[]): void;
|
||||
error(...args: any[]): void;
|
||||
}
|
||||
|
||||
// See |Core_unprivileged| in |core.unprivileged.js|
|
||||
interface Core {
|
||||
// Create a new channel which which to communicate between modules.
|
||||
createChannel(): Promise<ChannelSpecifier>;
|
||||
// Given an ChannelEndpointIdentifier for a channel, create a proxy event
|
||||
// interface for it.
|
||||
bindChannel(channelIdentifier: string): Promise<Channel>;
|
||||
// Returns the list of identifiers describing the dependency path.
|
||||
getId(): Promise<string[]>;
|
||||
getLogger(tag: string): Promise<Logger>;
|
||||
}
|
||||
|
||||
// Channels are ways that freedom modules can send each other messages.
|
||||
interface Channel extends OnAndEmit<any,any> {
|
||||
close(): void;
|
||||
}
|
||||
|
||||
// Specification for a channel.
|
||||
interface ChannelSpecifier {
|
||||
channel: Channel; // How to communicate over this channel.
|
||||
// A freedom channel endpoint identifier. Can be passed over a freedom
|
||||
// message-passing boundary. It is used to create a channel to the freedom
|
||||
// module that called createChannel and created this ChannelSpecifier.
|
||||
identifier: string;
|
||||
}
|
||||
|
||||
// This is the first argument given to a core provider's constructor. It is an
|
||||
// object that describes the parent module the core provider instance has been
|
||||
// created for.
|
||||
interface CoreProviderParentApp {
|
||||
manifestId: string;
|
||||
config: {
|
||||
views: {[viewName: string]: Object};
|
||||
};
|
||||
global: {
|
||||
removeEventListener: (s: string, f: Function, b: boolean) => void;
|
||||
};
|
||||
}
|
||||
|
||||
// A Freedom module sub is both a function and an object with members. The
|
||||
// type |T| is the type of the module's stub interface.
|
||||
interface FreedomModuleFactoryManager<T> {
|
||||
// This is the factory constructor for a new instance of a stub/channel to a
|
||||
// module.
|
||||
(...args: any[]): T;
|
||||
// This is the call to close a particular stub's channel and resources. It
|
||||
// is assumed that the argument is a result of the factory constructor. If
|
||||
// no argument is supplied, all stubs are closed.
|
||||
close: (freedomModuleStubInstance?: T) => Promise<void>;
|
||||
api: string;
|
||||
}
|
||||
|
||||
interface FreedomInCoreEnvOptions {
|
||||
debug?: string; // debug level
|
||||
logger?: string; // string to json for logging provider.
|
||||
}
|
||||
|
||||
interface FreedomInCoreEnv extends OnAndEmit<any,any> {
|
||||
// Represents the call to freedom when you create a root module. Returns a
|
||||
// promise to a factory constructor for the freedom module. The
|
||||
// |manifestPath| should be a path to a json string that specifies the
|
||||
// freedom module.
|
||||
(manifestPath: string, options?: FreedomInCoreEnvOptions):
|
||||
Promise<FreedomModuleFactoryManager<any>>;
|
||||
}
|
||||
|
||||
interface FreedomInModuleEnv {
|
||||
// Represents the call to freedom(), which returns the parent module's
|
||||
// freedom stub interface in an on/emit style. This is a getter.
|
||||
(): ParentModuleThing;
|
||||
|
||||
// Creates an interface to the freedom core provider which can be used to
|
||||
// create loggers and channels.
|
||||
// Note: unlike other providers, core is a getter.
|
||||
'core': FreedomModuleFactoryManager<Core>;
|
||||
'core.console': FreedomModuleFactoryManager<Console.Console>;
|
||||
'core.rtcdatachannel': FreedomModuleFactoryManager<RTCDataChannel.RTCDataChannel>;
|
||||
'core.rtcpeerconnection': FreedomModuleFactoryManager<RTCPeerConnection.RTCPeerConnection>;
|
||||
'core.storage': FreedomModuleFactoryManager<Storage.Storage>;
|
||||
'core.tcpsocket': FreedomModuleFactoryManager<TcpSocket.Socket>;
|
||||
'core.udpsocket': FreedomModuleFactoryManager<UdpSocket.Socket>;
|
||||
'pgp': FreedomModuleFactoryManager<PgpProvider.PgpProvider>;
|
||||
'portControl': FreedomModuleFactoryManager<PortControl.PortControl>;
|
||||
|
||||
// We use this specification so that you can reference freedom sub-modules by
|
||||
// an array-lookup of its name. One day, maybe we'll have a nicer way to do
|
||||
// this.
|
||||
[moduleName: string]: FreedomModuleFactoryManager<any>;
|
||||
}
|
||||
|
||||
// This generic interface represents any freedom method. Its purpose is to extend
|
||||
// the basic definition to include the reckless call method, which does not
|
||||
// produce a reply message.
|
||||
interface Method0<R> {
|
||||
(): Promise<R>;
|
||||
reckless: () => void;
|
||||
}
|
||||
interface Method1<T, R> {
|
||||
(a: T): Promise<R>;
|
||||
reckless: (a: T) => void;
|
||||
}
|
||||
interface Method2<T, U, R> {
|
||||
(a: T, b: U) : Promise<R>;
|
||||
reckless: (a: T, b: U) => void;
|
||||
}
|
||||
interface Method3<T, U, V, R> {
|
||||
(a: T, b: U, c: V): Promise<R>;
|
||||
reckless: (a: T, b: U, c: V) => void;
|
||||
}
|
||||
}
|
||||
|
||||
declare module freedom.Console {
|
||||
interface Console {
|
||||
log(source: string, message: string): Promise<void>;
|
||||
debug(source: string, message: string): Promise<void>;
|
||||
info(source: string, message: string): Promise<void>;
|
||||
warn(source: string, message: string): Promise<void>;
|
||||
error(source: string, message: string): Promise<void>;
|
||||
}
|
||||
}
|
||||
|
||||
declare module freedom.RTCDataChannel {
|
||||
interface Message {
|
||||
// Exactly one of the below must be specified.
|
||||
text?: string;
|
||||
buffer?: ArrayBuffer;
|
||||
binary?: Blob; // Not yet supported in Chrome.
|
||||
}
|
||||
|
||||
// Constructed by |freedom['rtcdatachannel'](id)| where |id| is a string
|
||||
// representing the channel id created by an |rtcpeerconnection| object.
|
||||
interface RTCDataChannel {
|
||||
getLabel(): Promise<string>;
|
||||
getOrdered(): Promise<boolean>;
|
||||
getMaxPacketLifeTime(): Promise<number>;
|
||||
getMaxRetransmits(): Promise<number>;
|
||||
getProtocol(): Promise<string>;
|
||||
getNegotiated(): Promise<boolean>;
|
||||
getId(): Promise<number>;
|
||||
getReadyState(): Promise<string>;
|
||||
getBufferedAmount(): Promise<number>;
|
||||
|
||||
on(t: 'onopen', f: () => void): void;
|
||||
on(t: 'onerror', f: () => void): void;
|
||||
on(t: 'onclose', f: () => void): void;
|
||||
on(t: 'onmessage', f: (m: Message) => void): void;
|
||||
on(t: string, f: Function): void;
|
||||
|
||||
close(): Promise<void>;
|
||||
getBinaryType(): Promise<string>;
|
||||
setBinaryType(type: string): Promise<void>;
|
||||
send: freedom.Method1<string, void>;
|
||||
sendBuffer: freedom.Method1<ArrayBuffer, void>;
|
||||
}
|
||||
}
|
||||
|
||||
declare module freedom.RTCPeerConnection {
|
||||
interface RTCIceServer {
|
||||
urls: string[];
|
||||
username?: string;
|
||||
credential?: string;
|
||||
}
|
||||
|
||||
interface RTCConfiguration {
|
||||
iceServers: RTCIceServer[];
|
||||
iceTransports?: string;
|
||||
peerIdentity?: string;
|
||||
}
|
||||
|
||||
interface RTCOfferOptions {
|
||||
offerToReceiveVideo?: number;
|
||||
offerToReceiveAudio?: number;
|
||||
voiceActivityDetection?: boolean;
|
||||
iceRestart?: boolean;
|
||||
}
|
||||
|
||||
interface RTCSessionDescription {
|
||||
type: string;
|
||||
sdp: string;
|
||||
}
|
||||
|
||||
interface RTCIceCandidate {
|
||||
candidate: string;
|
||||
sdpMid?: string;
|
||||
sdpMLineIndex?: number;
|
||||
}
|
||||
|
||||
interface OnIceCandidateEvent {
|
||||
candidate: RTCIceCandidate
|
||||
}
|
||||
|
||||
interface RTCDataChannelInit {
|
||||
ordered?: boolean;
|
||||
maxPacketLifeTime?: number;
|
||||
maxRetransmits?: number;
|
||||
protocol?: string;
|
||||
negotiated?: boolean;
|
||||
id?: number;
|
||||
}
|
||||
|
||||
// Note: the freedom factory constructor
|
||||
// |freedom['rtcpeerconnection'](config)| to create an RTCPeerConnection has
|
||||
// |RTCConfiguration| as the type of its config its argument.
|
||||
interface RTCPeerConnection {
|
||||
createOffer(options?: RTCOfferOptions): Promise<RTCSessionDescription>;
|
||||
createAnswer(): Promise<RTCSessionDescription>;
|
||||
|
||||
setLocalDescription(desc: RTCSessionDescription): Promise<void>;
|
||||
getLocalDescription(): Promise<RTCSessionDescription>;
|
||||
setRemoteDescription(desc: RTCSessionDescription): Promise<void>;
|
||||
getRemoteDescription(): Promise<RTCSessionDescription>;
|
||||
|
||||
getSignalingState(): Promise<string>;
|
||||
|
||||
updateIce(configuration: RTCConfiguration): Promise<void>;
|
||||
|
||||
addIceCandidate(candidate: RTCIceCandidate): Promise<void>;
|
||||
|
||||
getIceGatheringState(): Promise<string>;
|
||||
getIceConnectionState(): Promise<string>;
|
||||
|
||||
getConfiguration(): Promise<RTCConfiguration>;
|
||||
|
||||
getLocalStreams(): Promise<string[]>;
|
||||
getRemoteStreams(): Promise<string[]>;
|
||||
getStreamById(id: string): Promise<string>;
|
||||
addStream(ref: string): Promise<void>;
|
||||
removeStream(ref: string): Promise<void>;
|
||||
|
||||
close(): Promise<void>;
|
||||
|
||||
createDataChannel(label: string, init: RTCDataChannelInit): Promise<string>;
|
||||
|
||||
getStats(selector?: string): Promise<any>;
|
||||
|
||||
on(t: 'ondatachannel', f: (d: {channel: string}) => void): void;
|
||||
on(t: 'onnegotiationneeded', f: () => void): void;
|
||||
on(t: 'onicecandidate', f: (d: OnIceCandidateEvent) => void): void;
|
||||
on(t: 'onsignalingstatechange', f: () => void): void;
|
||||
on(t: 'onaddstream', f: (d: {stream: number}) => void): void;
|
||||
on(t: 'onremovestream', f: (d: {stream: number}) => void): void;
|
||||
on(t: 'oniceconnectionstatechange', f: () => void): void;
|
||||
on(t: string, f: Function): void;
|
||||
}
|
||||
}
|
||||
|
||||
declare module freedom.Storage {
|
||||
interface Storage {
|
||||
// Fetch array of all keys.
|
||||
keys(): Promise<string[]>;
|
||||
// Fetch a value for a key.
|
||||
get(key: string): Promise<string>;
|
||||
// Sets a value to a key. Fulfills promise with the previous value, if it
|
||||
// exists.
|
||||
set(key: string, value: string): Promise<string>;
|
||||
// Remove a single key. Fulfills promise with previous value, if exists.
|
||||
remove(key: string): Promise<string>;
|
||||
// Remove all data from storage.
|
||||
clear(): Promise<void>;
|
||||
} // class Storage
|
||||
}
|
||||
|
||||
declare module freedom.TcpSocket {
|
||||
interface DisconnectInfo {
|
||||
errcode: string;
|
||||
message: string;
|
||||
}
|
||||
|
||||
interface ReadInfo {
|
||||
data: ArrayBuffer;
|
||||
}
|
||||
|
||||
interface WriteInfo {
|
||||
bytesWritten: number;
|
||||
}
|
||||
|
||||
interface SocketInfo {
|
||||
connected: boolean;
|
||||
localAddress?: string;
|
||||
localPort?: number;
|
||||
peerAddress?: string;
|
||||
peerPort?: number;
|
||||
}
|
||||
|
||||
interface ConnectInfo {
|
||||
socket: number;
|
||||
host: string;
|
||||
port: number;
|
||||
}
|
||||
|
||||
// The TcpSocket class (freedom['core.TcpSocket'])
|
||||
interface Socket {
|
||||
listen(address: string, port: number): Promise<void>;
|
||||
connect(hostname: string, port: number): Promise<void>;
|
||||
secure(): Promise<void>;
|
||||
write: freedom.Method1<ArrayBuffer, WriteInfo>;
|
||||
pause: freedom.Method0<void>;
|
||||
resume: freedom.Method0<void>;
|
||||
getInfo(): Promise<SocketInfo>;
|
||||
close(): Promise<void>;
|
||||
// TcpSockets have 3 types of events:
|
||||
on(type: 'onConnection', f: (i: ConnectInfo) => void): void;
|
||||
on(type: 'onData', f: (i:ReadInfo) => void): void;
|
||||
off(type: 'onData', f: (i: ReadInfo) => void): void;
|
||||
on(type: 'onDisconnect', f: (i: DisconnectInfo) => void): void;
|
||||
on(eventType: string, f: (i: Object) => void): void;
|
||||
off(eventType: string, f: (i: Object) => void): void;
|
||||
}
|
||||
}
|
||||
|
||||
declare module freedom.UdpSocket {
|
||||
// Type for the chrome.socket.getInfo callback:
|
||||
// https://developer.chrome.com/apps/sockets_udp#type-SocketInfo
|
||||
// This is also the type returned by getInfo().
|
||||
interface SocketInfo {
|
||||
// Note that there are other fields but these are the ones we care about.
|
||||
localAddress: string;
|
||||
localPort: number;
|
||||
}
|
||||
|
||||
// Type for the chrome.socket.recvFrom callback:
|
||||
// http://developer.chrome.com/apps/socket#method-recvFrom
|
||||
// This is also the type returned to onData callbacks.
|
||||
interface RecvFromInfo {
|
||||
resultCode: number;
|
||||
address: string;
|
||||
port: number;
|
||||
data: ArrayBuffer;
|
||||
}
|
||||
|
||||
interface Implementation {
|
||||
bind(address: string, port: number, continuation: () => void) : void;
|
||||
sendTo(data: ArrayBuffer, address: string, port: number,
|
||||
continuation: (bytesWritten: number) => void): void;
|
||||
destroy(continuation: () => void): void;
|
||||
getInfo(continuation: (socketInfo: SocketInfo) => void): void;
|
||||
}
|
||||
|
||||
interface Socket {
|
||||
bind: (address: string, port: number) => Promise<void>;
|
||||
sendTo: freedom.Method3<ArrayBuffer, string, number, number>;
|
||||
destroy: () => Promise<void>;
|
||||
on: (name: string, listener: Function) => void;
|
||||
getInfo: () => Promise<SocketInfo>;
|
||||
}
|
||||
}
|
||||
|
||||
declare module freedom.PgpProvider {
|
||||
interface PublicKey {
|
||||
key: string;
|
||||
fingerprint: string;
|
||||
}
|
||||
|
||||
interface VerifyDecryptResult {
|
||||
data: ArrayBuffer;
|
||||
signedBy: string[];
|
||||
}
|
||||
|
||||
interface PgpProvider {
|
||||
// Standard freedom crypto API
|
||||
setup(passphrase: string, userid: string): Promise<void>;
|
||||
clear(): Promise<void>;
|
||||
exportKey(): Promise<PublicKey>;
|
||||
signEncrypt(data: ArrayBuffer, encryptKey?: string,
|
||||
sign?: boolean): Promise<ArrayBuffer>;
|
||||
verifyDecrypt(data: ArrayBuffer,
|
||||
verifyKey?: string): Promise<VerifyDecryptResult>;
|
||||
armor(data: ArrayBuffer, type?: string): Promise<string>;
|
||||
dearmor(data: string): Promise<ArrayBuffer>;
|
||||
}
|
||||
}
|
||||
|
||||
declare module freedom.PortControl {
|
||||
interface Mapping {
|
||||
internalIp: string;
|
||||
internalPort: number;
|
||||
externalIp?: string;
|
||||
externalPort: number;
|
||||
lifetime: number;
|
||||
protocol: string;
|
||||
timeoutId?: number;
|
||||
nonce?: number[];
|
||||
errInfo?: string;
|
||||
}
|
||||
|
||||
// A collection of Mappings
|
||||
interface ActiveMappings {
|
||||
[extPort: string]: Mapping;
|
||||
}
|
||||
|
||||
// An object returned by probeProtocolSupport()
|
||||
interface ProtocolSupport {
|
||||
natPmp: boolean;
|
||||
pcp: boolean;
|
||||
upnp: boolean;
|
||||
}
|
||||
|
||||
// Main interface for the module
|
||||
interface PortControl {
|
||||
addMapping(intPort: number, extPort: number, lifetime: number): Promise<Mapping>;
|
||||
deleteMapping(extPort: number): Promise<boolean>;
|
||||
probeProtocolSupport(): Promise<ProtocolSupport>;
|
||||
|
||||
probePmpSupport(): Promise<boolean>;
|
||||
addMappingPmp(intPort: number, extPort: number, lifetime: number): Promise<Mapping>;
|
||||
deleteMappingPmp(extPort: number): Promise<boolean>;
|
||||
|
||||
probePcpSupport(): Promise<boolean>;
|
||||
addMappingPcp(intPort: number, extPort: number, lifetime: number): Promise<Mapping>;
|
||||
deleteMappingPcp(extPort: number): Promise<boolean>;
|
||||
|
||||
probeUpnpSupport(): Promise<boolean>;
|
||||
addMappingUpnp(intPort: number, extPort: number, lifetime: number,
|
||||
controlUrl?: string): Promise<Mapping>;
|
||||
deleteMappingUpnp(extPort: number): Promise<boolean>;
|
||||
|
||||
getActiveMappings(): Promise<ActiveMappings>;
|
||||
getPrivateIps(): Promise<string[]>;
|
||||
close(): Promise<void>;
|
||||
}
|
||||
}
|
||||
|
||||
declare module freedom.Social {
|
||||
// Status of a client connected to a social network.
|
||||
interface ClientState {
|
||||
userId: string;
|
||||
clientId: string;
|
||||
status: string; // Either ONLINE, OFFLINE, or ONLINE_WITH_OTHER_APP
|
||||
timestamp: number;
|
||||
}
|
||||
|
||||
// The profile of a user on a social network.
|
||||
interface UserProfile {
|
||||
userId: string;
|
||||
name: string;
|
||||
url?: string;
|
||||
// Image URI (e.g. data:image/png;base64,adkwe329...)
|
||||
imageData?: string;
|
||||
timestamp?: number;
|
||||
}
|
||||
|
||||
interface Users {
|
||||
[userId: string]: UserProfile;
|
||||
}
|
||||
|
||||
interface Clients {
|
||||
[clientId: string]: ClientState;
|
||||
}
|
||||
|
||||
// Event for an incoming messages
|
||||
interface IncomingMessage {
|
||||
// UserID/ClientID/status of user from whom the message comes from.
|
||||
from: ClientState;
|
||||
// Message contents.
|
||||
message: string;
|
||||
}
|
||||
|
||||
// A request to login to a specific network as a specific agent
|
||||
interface LoginRequest {
|
||||
// Name of the application connecting to the network. Other logins with
|
||||
// the same agent field will be listed as having status |ONLINE|, where
|
||||
// those with different agents will be listed as
|
||||
// |ONLINE_WITH_OTHER_CLIENT|
|
||||
agent: string;
|
||||
// Version of application
|
||||
version: string;
|
||||
// URL of application
|
||||
url: string;
|
||||
// When |interactive === true| social will always prompt user for login.
|
||||
// Promise fails if the user did not login or provided invalid
|
||||
// credentials. When |interactive === false|, promise fails unless the
|
||||
// social provider has cached tokens/credentials.
|
||||
interactive: boolean;
|
||||
// When true, social provider will remember the token/credentials.
|
||||
rememberLogin: boolean;
|
||||
}
|
||||
|
||||
interface Social {
|
||||
// Generic Freedom Event stuff. |on| binds an event handler to event type
|
||||
// |eventType|. Every time |eventType| event is raised, the function |f|
|
||||
// will be called.
|
||||
//
|
||||
// Message type |onMessage| happens when the user receives a message from
|
||||
// another contact.
|
||||
on(eventType: string, f: Function) : void;
|
||||
on(eventType: 'onMessage', f: (message: IncomingMessage) => void): void;
|
||||
// Message type |onRosterProfile| events are received when another user's
|
||||
// profile is received or when a client changes status.
|
||||
on(eventType: 'onUserProfile', f: (profile: UserProfile) => void): void;
|
||||
// Message type |onMyStatus| is received when the user's client's status
|
||||
// changes, e.g. when disconnected and online status becomes offline.
|
||||
on(eventType: 'onClientState', f: (status: ClientState) => void): void;
|
||||
|
||||
// Do a singleton event binding: |f| will only be called once, on the next
|
||||
// event of type |eventType|. Same events as above.
|
||||
once(eventType: string, f: Function): void;
|
||||
|
||||
login(loginRequest: LoginRequest): Promise<ClientState>;
|
||||
getUsers(): Promise<Users>;
|
||||
getClients(): Promise<Clients>;
|
||||
|
||||
// Send a message to user on your network
|
||||
// If the message is sent to a userId, it is sent to all clients
|
||||
// If the message is sent to a clientId, it is sent to just that one client
|
||||
// If the destination id is not specified or invalid, promise rejects.
|
||||
sendMessage(destinationId: string, message: string): Promise<void>;
|
||||
|
||||
// Logs the user out of the social network. After the logout promise, the
|
||||
// user status is OFFLINE.
|
||||
logout(): Promise<void>;
|
||||
|
||||
// Forget any tokens/credentials used for logging in with the last used
|
||||
// userId.
|
||||
clearCachedCredentials(): Promise<void>;
|
||||
}
|
||||
} // declare module Social
|
||||
@@ -0,0 +1,28 @@
|
||||
/// <reference path="fs-ext.d.ts" />
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
|
||||
import fs = require('fs-ext');
|
||||
|
||||
var num:number;
|
||||
var str:string;
|
||||
|
||||
//from node.js 'fs' module
|
||||
fs.appendFileSync(str, "data");
|
||||
|
||||
fs.flock(num, str, (err)=>{
|
||||
});
|
||||
fs.flockSync(num, str);
|
||||
|
||||
fs.fcntl(num, str, num, (err, res)=>{
|
||||
});
|
||||
fs.fcntl(num, str, (err, res)=>{
|
||||
});
|
||||
fs.fcntlSync(num, str, num);
|
||||
|
||||
fs.seek(num, num, num, (err, pos)=>{
|
||||
});
|
||||
fs.seekSync(num, num, num);
|
||||
|
||||
fs.utime(str, num, num, (err)=>{
|
||||
});
|
||||
fs.utimeSync(str, num, num);
|
||||
Vendored
+102
@@ -0,0 +1,102 @@
|
||||
// Type definitions for fs-ext
|
||||
// Project: https://github.com/baudehlo/node-fs-ext
|
||||
// Definitions by: Oguzhan Ergin <https://github.com/OguzhanE>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
///<reference path="../node/node.d.ts"/>
|
||||
|
||||
declare module "fs-ext" {
|
||||
export * from "fs";
|
||||
|
||||
/**
|
||||
* Asynchronous flock(2). No arguments other than a possible error are passed to the callback.
|
||||
* @param fd File Descriptor
|
||||
* @param flags Flags can be 'sh', 'ex', 'shnb', 'exnb', 'un' and correspond to the various LOCK_SH, LOCK_EX, LOCK_SH|LOCK_NB, etc.
|
||||
**/
|
||||
export function flock(fd: number, flags: string, callback: (err: Error) => void): void;
|
||||
|
||||
/**
|
||||
* Synchronous flock(2). Throws an exception on error.
|
||||
* @param fd File Descriptor
|
||||
* @param flags Flags can be 'sh', 'ex', 'shnb', 'exnb', 'un' and correspond to the various LOCK_SH, LOCK_EX, LOCK_SH|LOCK_NB, etc.
|
||||
**/
|
||||
export function flockSync(fd: number, flags: string):void;
|
||||
|
||||
/**
|
||||
* Asynchronous fcntl(2).
|
||||
* @param fd File Descriptor
|
||||
* @param cmd The supported commands are: 'getfd' ( F_GETFD ) , 'setfd' ( F_SETFD )
|
||||
* Requiring this module adds FD_CLOEXEC to the constants module, for use with F_SETFD.
|
||||
* @param arg arg
|
||||
**/
|
||||
export function fcntl(fd: number, cmd: string, arg: number, callback: (err: Error, result: number) => void):void;
|
||||
|
||||
/**
|
||||
* Asynchronous fcntl(2).
|
||||
* @param fd File Descriptor
|
||||
* @param cmd The supported commands are: 'getfd' ( F_GETFD ) , 'setfd' ( F_SETFD )
|
||||
* Requiring this module adds FD_CLOEXEC to the constants module, for use with F_SETFD.
|
||||
**/
|
||||
export function fcntl(fd: number, cmd: string, callback: (err: Error, result: number) => void):void;
|
||||
|
||||
/**
|
||||
* Synchronous fcntl(2). Throws an exception on error.
|
||||
* @param fd File Descriptor
|
||||
* @param cmd The supported commands are: 'getfd' ( F_GETFD ) , 'setfd' ( F_SETFD )
|
||||
* Requiring this module adds FD_CLOEXEC to the constants module, for use with F_SETFD.
|
||||
* @param arg arg
|
||||
* @return Returns flags
|
||||
**/
|
||||
export function fcntlSync(fd: number, cmd: string, arg?: number): number;
|
||||
|
||||
/**
|
||||
* Asynchronous lseek(2).
|
||||
* @param fd File Descriptor
|
||||
* @param offset Offset
|
||||
* @param whence
|
||||
* Whence can be 0 (SEEK_SET) to set the new position in bytes to offset, 1 (SEEK_CUR) to set the new
|
||||
* position to the current position plus offset bytes (can be negative), or 2 (SEEK_END) to set to the end
|
||||
* of the file plus offset bytes (usually negative or zero to seek to the end of the file).
|
||||
**/
|
||||
export function seek(fd: number, offset: number, whence: number, callback: (err: Error, currFilePos: number) => void): void;
|
||||
|
||||
/**
|
||||
* Synchronous lseek(2). Throws an exception on error. Returns current file position.
|
||||
* @param fd File Descriptor
|
||||
* @param offset Offset
|
||||
* @param whence
|
||||
* Whence can be 0 (SEEK_SET) to set the new position in bytes to offset, 1 (SEEK_CUR) to set the new
|
||||
* position to the current position plus offset bytes (can be negative), or 2 (SEEK_END) to set to the end
|
||||
* of the file plus offset bytes (usually negative or zero to seek to the end of the file).
|
||||
* @returns Returns current file position.
|
||||
**/
|
||||
export function seekSync(fd: number, offset: number, whence: number): number;
|
||||
|
||||
/**
|
||||
* Asynchronous utime(2).
|
||||
* @param path File path
|
||||
* @param atime
|
||||
* Arguments atime and mtime are in seconds as for the system call.Note that the number value of Date() is in milliseconds,
|
||||
* so to use the 'now' value with fs.utime() you would have to divide by 1000 first, e.g. Date.now()/1000
|
||||
* Just like for utime(2), the absence of the atime and mtime means 'now'.
|
||||
* @param mtime
|
||||
* Arguments atime and mtime are in seconds as for the system call.Note that the number value of Date() is in milliseconds,
|
||||
* so to use the 'now' value with fs.utime() you would have to divide by 1000 first, e.g. Date.now()/1000
|
||||
* Just like for utime(2), the absence of the atime and mtime means 'now'.
|
||||
**/
|
||||
export function utime(path: string, atime: number, mtime: number, callback: (err: Error) => void):void;
|
||||
|
||||
/**
|
||||
* Synchronous version of utime(). Throws an exception on error.
|
||||
* @param path File path
|
||||
* @param atime
|
||||
* Arguments atime and mtime are in seconds as for the system call.Note that the number value of Date() is in milliseconds,
|
||||
* so to use the 'now' value with fs.utime() you would have to divide by 1000 first, e.g. Date.now()/1000
|
||||
* Just like for utime(2), the absence of the atime and mtime means 'now'.
|
||||
* @param mtime
|
||||
* Arguments atime and mtime are in seconds as for the system call.Note that the number value of Date() is in milliseconds,
|
||||
* so to use the 'now' value with fs.utime() you would have to divide by 1000 first, e.g. Date.now()/1000
|
||||
* Just like for utime(2), the absence of the atime and mtime means 'now'.
|
||||
**/
|
||||
export function utimeSync(path: string, atime: number, mtime: number):void;
|
||||
}
|
||||
@@ -67,7 +67,7 @@ $('#calendar').fullCalendar({
|
||||
$('#calendar').fullCalendar('option', 'aspectRatio', 1.8);
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
viewDisplay: function (view) {
|
||||
viewRender: function(view) {
|
||||
alert('The new title of the view is ' + view.title);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -51,6 +51,35 @@ app.on('ready', () => {
|
||||
// when you should delete the corresponding element.
|
||||
mainWindow = null;
|
||||
});
|
||||
|
||||
mainWindow.print({silent: true, printBackground: false});
|
||||
mainWindow.webContents.print({silent: true, printBackground: false});
|
||||
mainWindow.print();
|
||||
mainWindow.webContents.print();
|
||||
|
||||
mainWindow.print({silent: true, printBackground: false});
|
||||
mainWindow.webContents.print({silent: true, printBackground: false});
|
||||
mainWindow.print();
|
||||
mainWindow.webContents.print();
|
||||
|
||||
mainWindow.printToPDF({
|
||||
marginsType: 1,
|
||||
pageSize: 'A3',
|
||||
printBackground: true,
|
||||
printSelectionOnly: true,
|
||||
landscape: true,
|
||||
}, (error: Error, data: Buffer) => {});
|
||||
|
||||
mainWindow.webContents.printToPDF({
|
||||
marginsType: 1,
|
||||
pageSize: 'A3',
|
||||
printBackground: true,
|
||||
printSelectionOnly: true,
|
||||
landscape: true,
|
||||
}, (error: Error, data: Buffer) => {});
|
||||
|
||||
mainWindow.printToPDF({}, (err, data) => {});
|
||||
mainWindow.webContents.printToPDF({}, (err, data) => {});
|
||||
});
|
||||
|
||||
// Desktop environment integration
|
||||
|
||||
Vendored
+67
-6
@@ -377,17 +377,22 @@ declare module GitHubElectron {
|
||||
capturePage(rect: Rectangle, callback: (image: NativeImage) => void): void;
|
||||
capturePage(callback: (image: NativeImage) => void): void;
|
||||
/**
|
||||
* Prints the window's web page. Calling window.print() in a web page is
|
||||
* equivalent to calling BrowserWindow.print({silent: false, printBackground: false}).
|
||||
* Same with webContents.print([options])
|
||||
*/
|
||||
print(options?: {
|
||||
/**
|
||||
* When false, Electron will pick up system's default printer and default
|
||||
* settings for printing.
|
||||
*/
|
||||
silent?: boolean;
|
||||
printBackground?: boolean;
|
||||
}): void;
|
||||
/**
|
||||
* Same with webContents.printToPDF([options])
|
||||
*/
|
||||
printToPDF(options: {
|
||||
marginsType?: number;
|
||||
pageSize?: string;
|
||||
printBackground?: boolean;
|
||||
printSelectionOnly?: boolean;
|
||||
landscape?: boolean;
|
||||
}, callback: (error: Error, data: Buffer) => void): void;
|
||||
/**
|
||||
* Same with webContents.loadUrl(url).
|
||||
*/
|
||||
@@ -659,6 +664,62 @@ declare module GitHubElectron {
|
||||
* @param isFulfilled Whether the JS promise is fulfilled.
|
||||
*/
|
||||
(isFulfilled: boolean) => void): void;
|
||||
/**
|
||||
*
|
||||
* Prints window's web page. When silent is set to false, Electron will pick up system's default printer and default settings for printing.
|
||||
* Calling window.print() in web page is equivalent to call WebContents.print({silent: false, printBackground: false}).
|
||||
* Note:
|
||||
* On Windows, the print API relies on pdf.dll. If your application doesn't need print feature, you can safely remove pdf.dll in saving binary size.
|
||||
*/
|
||||
print(options?: {
|
||||
/**
|
||||
* Don't ask user for print settings, defaults to false
|
||||
*/
|
||||
silent?: boolean;
|
||||
/**
|
||||
* Also prints the background color and image of the web page, defaults to false.
|
||||
*/
|
||||
printBackground: boolean;
|
||||
}): void;
|
||||
/**
|
||||
* Prints windows' web page as PDF with Chromium's preview printing custom settings.
|
||||
*/
|
||||
printToPDF(options: {
|
||||
/**
|
||||
* Specify the type of margins to use. Default is 0.
|
||||
* 0 - default
|
||||
* 1 - none
|
||||
* 2 - minimum
|
||||
*/
|
||||
marginsType?: number;
|
||||
/**
|
||||
* String - Specify page size of the generated PDF. Default is A4.
|
||||
* A4
|
||||
* A3
|
||||
* Legal
|
||||
* Letter
|
||||
* Tabloid
|
||||
*/
|
||||
pageSize?: string;
|
||||
/**
|
||||
* Whether to print CSS backgrounds. Default is false.
|
||||
*/
|
||||
printBackground?: boolean;
|
||||
/**
|
||||
* Whether to print selection only. Default is false.
|
||||
*/
|
||||
printSelectionOnly?: boolean;
|
||||
/**
|
||||
* true for landscape, false for portrait. Default is false.
|
||||
*/
|
||||
landscape?: boolean;
|
||||
},
|
||||
/**
|
||||
* Callback function on completed converting to PDF.
|
||||
* error Error
|
||||
* data Buffer - PDF file content
|
||||
*/
|
||||
callback: (error: Error, data: Buffer) => void): void;
|
||||
/**
|
||||
* Send args.. to the web page via channel in asynchronous message, the web page
|
||||
* can handle it by listening to the channel event of ipc module.
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
/// <reference path="../gulp/gulp.d.ts" />
|
||||
/// <reference path="./gulp-changed.d.ts" />
|
||||
/// <reference path="../gulp-minify-html/gulp-minify-html.d.ts" />
|
||||
|
||||
import * as gulp from "gulp";
|
||||
import changed = require("gulp-changed");
|
||||
import minifyHtml = require("gulp-minify-html");
|
||||
|
||||
// Without options
|
||||
gulp.src("*.html")
|
||||
.pipe(changed("build"))
|
||||
.pipe(minifyHtml())
|
||||
.pipe(gulp.dest("build"));
|
||||
|
||||
// With some options
|
||||
gulp.src("*.html")
|
||||
.pipe(changed("build", { hasChanged: changed.compareSha1Digest }))
|
||||
.pipe(minifyHtml())
|
||||
.pipe(gulp.dest("build"));
|
||||
Vendored
+60
@@ -0,0 +1,60 @@
|
||||
// Type definitions for gulp-changed
|
||||
// Project: https://github.com/sindresorhus/gulp-changed
|
||||
// Definitions by: Thomas Corbière <https://github.com/tomc974>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../node/node.d.ts"/>
|
||||
/// <reference path="../vinyl/vinyl.d.ts"/>
|
||||
|
||||
declare module "gulp-changed"
|
||||
{
|
||||
import { Transform } from "stream";
|
||||
import File = require("vinyl");
|
||||
|
||||
interface IComparator
|
||||
{
|
||||
/**
|
||||
* @param stream Should be used to queue sourceFile if it passes some comparison
|
||||
* @param callback Should be called when done
|
||||
* @param sourceFile File to operate on
|
||||
* @param destPath Destination for sourceFile as an absolute path
|
||||
*/
|
||||
(stream: Transform, callback: Function, sourceFile: File, destPath: string): void;
|
||||
}
|
||||
|
||||
interface IDestination
|
||||
{
|
||||
(file: string|Buffer): string;
|
||||
}
|
||||
|
||||
interface IOptions
|
||||
{
|
||||
/**
|
||||
* The working directory the folder is relative to.
|
||||
* @default process.cwd()
|
||||
*/
|
||||
cwd?: string;
|
||||
|
||||
/**
|
||||
* Extension of the destination files.
|
||||
*/
|
||||
extension?: string;
|
||||
|
||||
/**
|
||||
* Function that determines whether the source file is different from the destination file.
|
||||
* @default changed.compareLastModifiedTime
|
||||
*/
|
||||
hasChanged?: IComparator;
|
||||
}
|
||||
|
||||
interface IGulpChanged
|
||||
{
|
||||
(destination: string|IDestination, options?: IOptions): NodeJS.ReadWriteStream;
|
||||
|
||||
compareLastModifiedTime: IComparator;
|
||||
compareSha1Digest: IComparator;
|
||||
}
|
||||
|
||||
const changed: IGulpChanged;
|
||||
export = changed;
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/// <reference path="../gulp/gulp.d.ts" />
|
||||
/// <reference path="gulp-coffeeify.d.ts" />
|
||||
|
||||
import gulp = require('gulp');
|
||||
import coffeeify = require('gulp-coffeeify');
|
||||
|
||||
// Basic usage
|
||||
gulp.task('scripts', function() {
|
||||
gulp.src('src/coffee/**/*.coffee')
|
||||
.pipe(coffeeify())
|
||||
.pipe(gulp.dest('./build/js'));
|
||||
});
|
||||
|
||||
gulp.task('scripts', function() {
|
||||
gulp.src('src/coffee/**/*.coffee')
|
||||
.pipe(coffeeify({
|
||||
options: {
|
||||
debug: true, // source map
|
||||
paths: [__dirname + '/node_modules', __dirname + '/src/coffee']
|
||||
}
|
||||
}))
|
||||
.pipe(gulp.dest('./build/js'));
|
||||
});
|
||||
|
||||
gulp.task('scripts', function() {
|
||||
gulp.src('src/coffee/**/*.coffee')
|
||||
.pipe(coffeeify({
|
||||
aliases: [
|
||||
{
|
||||
cwd: 'src/coffee/app',
|
||||
base: 'app'
|
||||
}
|
||||
]
|
||||
}))
|
||||
.pipe(gulp.dest('./build/js'));
|
||||
});
|
||||
|
||||
var xform = function(data: string){
|
||||
return 'module.exports = "' + data + '"';
|
||||
};
|
||||
gulp.task('scripts', function() {
|
||||
gulp.src('src/coffee/**/*.coffee')
|
||||
.pipe(coffeeify({
|
||||
transforms: [
|
||||
{
|
||||
ext: '.extension',
|
||||
transform: xform
|
||||
}
|
||||
]
|
||||
}))
|
||||
.pipe(gulp.dest('./build/js'));
|
||||
});
|
||||
|
||||
Vendored
+44
@@ -0,0 +1,44 @@
|
||||
// Type definitions for gulp-coffeeify
|
||||
// Project: https://github.com/nariyu/gulp-coffeeify
|
||||
// Definitions by: Qubo <https://github.com/tkQubo>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
|
||||
declare module "gulp-coffeeify" {
|
||||
namespace coffeeify {
|
||||
interface Coffeeify {
|
||||
(option?: Option): NodeJS.ReadWriteStream;
|
||||
}
|
||||
|
||||
interface Option {
|
||||
options?: {
|
||||
debug?: boolean;
|
||||
paths?: string[];
|
||||
},
|
||||
/**
|
||||
* [DEPRECATED]: You should use a 'paths' options of browserify.
|
||||
*/
|
||||
aliases?: Aliases;
|
||||
/**
|
||||
* [DEPRECATED]
|
||||
*/
|
||||
transforms?: Transforms;
|
||||
}
|
||||
|
||||
interface Aliases {
|
||||
cwd?: string;
|
||||
base?: string;
|
||||
}
|
||||
|
||||
interface Transforms {
|
||||
ext?: string;
|
||||
transform?(data: string): string;
|
||||
}
|
||||
}
|
||||
|
||||
var coffeeify: coffeeify.Coffeeify;
|
||||
|
||||
export = coffeeify;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
/// <reference path="./gulp-dtsm.d.ts" />
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
/// <reference path="../gulp/gulp.d.ts" />
|
||||
|
||||
import dtsm = require('gulp-dtsm');
|
||||
import gulp = require('gulp');
|
||||
|
||||
var stream: NodeJS.WritableStream = dtsm();
|
||||
|
||||
gulp.task('dtsm', () => gulp.src('./dtsm.json').pipe(dtsm()));
|
||||
|
||||
Vendored
+13
@@ -0,0 +1,13 @@
|
||||
// Type definitions for gulp-dtsm 0.0.0
|
||||
// Project: https://github.com/9joneg/gulp-dtsm
|
||||
// Definitions by: Aya Morisawa <https://github.com/AyaMorisawa>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
|
||||
declare module "gulp-dtsm" {
|
||||
function dtsm(): NodeJS.WritableStream;
|
||||
|
||||
export = dtsm;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
/// <reference path="gulp-espower.d.ts" />
|
||||
/// <reference path="../gulp/gulp.d.ts" />
|
||||
|
||||
|
||||
import espower = require('gulp-espower');
|
||||
import * as gulp from 'gulp';
|
||||
|
||||
gulp.src('src/*.coffee')
|
||||
.pipe(espower())
|
||||
.pipe(gulp.dest('out'));
|
||||
|
||||
|
||||
gulp.src('src/*.coffee')
|
||||
.pipe(espower({ patterns: ['assert(value, [message])'] }))
|
||||
.pipe(gulp.dest('out'));
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user