This commit is contained in:
Jeongho Nam
2016-09-23 16:50:28 +09:00
34 changed files with 6833 additions and 131 deletions
@@ -0,0 +1,136 @@
/// <reference path="../node/node.d.ts" />
///<reference path="./algoliasearch-client-js.d.ts"/>
var algoliasearch = require('algoliasearch');
var _clientOptions: ClientOptions = {
timeout : 12,
protocol: "",
httpAgent: ""
};
var _synonymOption: SynonymOption = {
forwardToSlaves: false,
replaceExistingSynonyms: false
};
var _algoliaUserKeyOptions : AlgoliaUserKeyOptions = {
validity: 0,
maxQueriesPerIPPerHour: 0,
indexes: [""],
queryParameters: { attributesToRetrieve: ["algolia"] },
description: ""
};
var _searchSynonymOptions : SearchSynonymOptions = {
query: "",
page: 0,
type: "",
hitsPerPage: 0
};
var _algoliaSecuredApiOptions: AlgoliaSecuredApiOptions = {
filters: "",
validUntil: 0,
restrictIndices: "",
userToken: ""
};
var _algoliaIndexSettings : AlgoliaIndexSettings = {
attributesToIndex: [""],
attributesforFaceting: [""],
unretrievableAttributes: [""],
attributesToRetrieve: [""],
ranking: [""],
customRanking: [""],
slaves: [""],
maxValuesPerFacet: '',
attributesToHighlight: [""],
attributesToSnippet: [""],
highlightPreTag: '',
highlightPostTag: '',
snippetEllipsisText: '',
restrictHighlightAndSnippetArrays: false,
hitsPerPage: 0,
minWordSizefor1Typo: 0,
minWordSizefor2Typos: 0,
typoTolerance: false,
allowTyposOnNumericTokens: false,
ignorePlurals: false,
disableTypoToleranceOnAttributes: '',
separatorsToIndex: '',
queryType: '',
removeWordsIfNoResults: '',
advancedSyntax: false,
optionalWords: [""],
removeStopWords: [""],
disablePrefixOnAttributes: [""],
disableExactOnAttributes: [""],
exactOnSingleWordQuery: '',
alternativesAsExact: false,
attributeForDistinct: "",
distinct: false,
numericAttributesToIndex: [""],
allowCompressionOfIntegerArray: false,
altCorrections: [{}],
minProximity: 0,
placeholders: ''
};
var _algoliaQueryParameters : AlgoliaQueryParameters = {
query: '',
filters: '',
attributesToRetrieve: [""],
restrictSearchableAttributes: [""],
facets: '',
maxValuesPerFacet: '',
attributesToHighlight: [''],
attributesToSnippet: [''],
highlightPreTag: '',
highlightPostTag: '',
snippetEllipsisText: '',
restrictHighlightAndSnippetArrays: false,
hitsPerPage: 0,
page: 0,
offset: 0,
length: 0,
minWordSizefor1Typo: 0,
minWordSizefor2Typos: 0,
typoTolerance: false,
allowTyposOnNumericTokens: false,
ignorePlurals: false,
disableTypoToleranceOnAttributes: '',
aroundLatLng: '',
aroundLatLngViaIP: '',
aroundRadius: '',
aroundPrecision: 0,
minimumAroundRadius: 0,
insideBoundingBox: '',
queryType: '',
insidePolygon: '',
removeWordsIfNoResults: '',
advancedSyntax: false,
optionalWords: [''],
removeStopWords: [''],
disableExactOnAttributes: [''],
exactOnSingleWordQuery: '',
alternativesAsExact: true,
distinct: 0,
getRankingInfo: false,
numericAttributesToIndex: [''],
numericFilters: [''],
tagFilters: '',
facetFilters: '',
analytics: false,
analyticsTags: [''],
synonyms: true,
replaceSynonymsInHighlight: false,
minProximity: 0
};
var index: AlgoliaIndex = algoliasearch('', '').initIndex('');
var search = index.search({query: ""});
index.search({query: ""}, function(err, res){});
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -14,7 +14,7 @@ declare namespace angular.ui {
/**
* Override the parent state (only for the breadcrumb)
**/
parent?: string;
parent?: string|Function;
/**
* When defined to true, the state is never included in the chain of states and never appears in the breadcrumb
**/
@@ -76,4 +76,4 @@ declare namespace ncy {
**/
getLastStep(): angular.ui.IState;
}
}
}
@@ -20,6 +20,13 @@ myApp.config((
.warnPalette('red')
.dark(true);
var browserColors: ng.material.IBrowserColors = {
theme: 'default',
palette: 'neonRed',
hue: '500'
};
$mdThemingProvider.enableBrowserColor(browserColors);
$mdIconProvider
.defaultIconSet('my/app/icons.svg') // Register a default set of SVG icons
.iconSet('social', 'my/app/social.svg') // Register a named icon set of SVGs
@@ -41,6 +48,25 @@ myApp.controller('BottomSheetController', ($scope: ng.IScope, $mdBottomSheet: ng
$scope['cancelBottomSheet'] = $mdBottomSheet.cancel.bind($mdBottomSheet, 'cancel');
});
myApp.controller('ColorController', ($scope: ng.IScope, $mdColor: ng.material.IColorService) => {
var colorExpression : ng.material.IColorExpression;
var element : Element;
colorExpression = { color: '#FFFFFF' }
element = new Element();
$scope['applyThemeColors'] = () => {
$mdColor.applyThemeColors(element, colorExpression);
};
$scope['getThemeColor'] = () => {
$mdColor.getThemeColor('default-neonRed')
};
$scope['hasTheme'] = () => {
$mdColor.hasTheme();
};
});
myApp.controller('DialogController', ($scope: ng.IScope, $mdDialog: ng.material.IDialogService) => {
$scope['openDialog'] = () => {
$mdDialog.show({
+22 -4
View File
@@ -73,6 +73,16 @@ declare namespace angular.material {
initialValue(initialValue: string): IPromptDialog;
}
interface IColorExpression {
[cssPropertyName: string]: string
}
interface IColorService {
applyThemeColors(element: Element|JQuery, colorExpression: IColorExpression): void;
getThemeColor(expression: string): string;
hasTheme(): boolean;
}
interface IDialogOptions {
templateUrl?: string;
template?: string;
@@ -216,6 +226,12 @@ declare namespace angular.material {
hues: IThemeHues;
}
interface IBrowserColors{
theme: string;
palette: string;
hue: string;
}
interface IThemeColors {
accent: IThemePalette;
background: IThemePalette;
@@ -245,12 +261,14 @@ declare namespace angular.material {
}
interface IThemingProvider {
theme(name: string, inheritFrom?: string): ITheme;
definePalette(name: string, palette: IPalette): IThemingProvider;
extendPalette(name: string, palette: IPalette): IPalette;
setDefaultTheme(theme: string): void;
alwaysWatchTheme(alwaysWatch: boolean): void;
definePalette(name: string, palette: IPalette): IThemingProvider;
enableBrowserColor(browserColors: IBrowserColors): Function;
extendPalette(name: string, palette: IPalette): IPalette;
registerStyles(styles: String): void;
setDefaultTheme(theme: string): void;
setNonce(nonce: string): void;
theme(name: string, inheritFrom?: string): ITheme;
}
interface IDateLocaleProvider {
+35 -9
View File
@@ -180,25 +180,51 @@ namespace My.Namespace {
// IModule Registering Test
var mod = angular.module('tests', []);
mod.controller('name', function ($scope: ng.IScope) { })
mod.controller('name', ['$scope', <any>function ($scope: ng.IScope) { }])
mod.controller(My.Namespace);
mod.controller('name', function ($scope: ng.IScope) { });
mod.controller('name', ['$scope', function ($scope: ng.IScope) { }]);
mod.controller('name', class {
// Uncommenting the next line should lead to a type error because this signature isn't compatible
// with the signature of the `$onChanges` hook:
// $onChanges(x: number) { }
});
mod.controller({
MyCtrl: class{},
MyCtrl2: function() {},
MyCtrl3: ['$fooService', function($fooService: any) { }]
});
mod.directive('name', <any>function ($scope: ng.IScope) { })
mod.directive('name', ['$scope', <any>function ($scope: ng.IScope) { }])
mod.directive(My.Namespace);
mod.directive({
myFooDir: () => ({
template: 'my-foo-dir.tpl.html'
}),
myBarDir: ['$fooService', ($fooService: any) => ({
template: 'my-bar-dir.tpl.html'
})]
});
mod.factory('name', function ($scope: ng.IScope) { })
mod.factory('name', ['$scope', <any>function ($scope: ng.IScope) { }])
mod.factory(My.Namespace);
mod.factory('name', ['$scope', function ($scope: ng.IScope) { }])
mod.factory({
name1: function (foo: any) { },
name2: ['foo', function (foo: any) { }]
});
mod.filter('name', function ($scope: ng.IScope) { })
mod.filter('name', ['$scope', <any>function ($scope: ng.IScope) { }])
mod.filter(My.Namespace);
mod.filter('name', ['$scope', function ($scope: ng.IScope) { }])
mod.filter({
name1: function (foo: any) { },
name2: ['foo', function (foo: any) { }]
});
mod.provider('name', function ($scope: ng.IScope) { return { $get: () => { } } })
mod.provider('name', TestProvider);
mod.provider('name', ['$scope', <any>function ($scope: ng.IScope) { }])
mod.provider(My.Namespace);
mod.service('name', function ($scope: ng.IScope) { })
mod.service('name', ['$scope', <any>function ($scope: ng.IScope) { }])
mod.service(My.Namespace);
mod.service({
MyCtrl: class{},
MyCtrl2: function() {},
MyCtrl3: ['$fooService', function($fooService: any) { }]
});
mod.constant('name', 23);
mod.constant('name', "23");
mod.constant(My.Namespace);
+74 -104
View File
@@ -25,6 +25,8 @@ declare module 'angular' {
///////////////////////////////////////////////////////////////////////////////
declare namespace angular {
type Injectable<T extends Function> = T | (string | T)[];
// not directly implemented, but ensures that constructed class implements $get
interface IServiceProviderClass {
new (...args: any[]): IServiceProvider;
@@ -214,50 +216,26 @@ declare namespace angular {
* @param name Controller name, or an object map of controllers where the keys are the names and the values are the constructors.
* @param controllerConstructor Controller constructor fn (optionally decorated with DI annotations in the array notation).
*/
controller(name: string, controllerConstructor: Function): IModule;
/**
* The $controller service is used by Angular to create new controllers.
*
* This provider allows controller registration via the register method.
*
* @param name Controller name, or an object map of controllers where the keys are the names and the values are the constructors.
* @param controllerConstructor Controller constructor fn (optionally decorated with DI annotations in the array notation).
*/
controller(name: string, inlineAnnotatedConstructor: any[]): IModule;
controller(object: Object): IModule;
controller(name: string, controllerConstructor: Injectable<IControllerConstructor>): IModule;
controller(object: {[name: string]: Injectable<IControllerConstructor>}): IModule;
/**
* Register a new directive with the compiler.
*
* @param name Name of the directive in camel-case (i.e. ngBind which will match as ng-bind)
* @param directiveFactory An injectable directive factory function.
*/
directive(name: string, directiveFactory: IDirectiveFactory): IModule;
/**
* Register a new directive with the compiler.
*
* @param name Name of the directive in camel-case (i.e. ngBind which will match as ng-bind)
* @param directiveFactory An injectable directive factory function.
*/
directive(name: string, inlineAnnotatedFunction: any[]): IModule;
directive(object: Object): IModule;
directive(name: string, directiveFactory: Injectable<IDirectiveFactory>): IModule;
directive(object: {[directiveName: string]: Injectable<IDirectiveFactory>}): IModule;
/**
* Register a service factory, which will be called to return the service instance. This is short for registering a service where its provider consists of only a $get property, which is the given service factory function. You should use $provide.factory(getFn) if you do not need to configure your service in a provider.
*
* @param name The name of the instance.
* @param $getFn The $getFn for the instance creation. Internally this is a short hand for $provide.provider(name, {$get: $getFn}).
*/
factory(name: string, $getFn: Function): IModule;
/**
* Register a service factory, which will be called to return the service instance. This is short for registering a service where its provider consists of only a $get property, which is the given service factory function. You should use $provide.factory(getFn) if you do not need to configure your service in a provider.
*
* @param name The name of the instance.
* @param inlineAnnotatedFunction The $getFn for the instance creation. Internally this is a short hand for $provide.provider(name, {$get: $getFn}).
*/
factory(name: string, inlineAnnotatedFunction: any[]): IModule;
factory(object: Object): IModule;
filter(name: string, filterFactoryFunction: Function): IModule;
filter(name: string, inlineAnnotatedFunction: any[]): IModule;
filter(object: Object): IModule;
factory(name: string, $getFn: Injectable<Function>): IModule;
factory(object: {[name: string]: Injectable<Function>}): IModule;
filter(name: string, filterFactoryFunction: Injectable<Function>): IModule;
filter(object: {[name: string]: Injectable<Function>}): IModule;
provider(name: string, serviceProviderFactory: IServiceProviderFactory): IModule;
provider(name: string, serviceProviderConstructor: IServiceProviderClass): IModule;
provider(name: string, inlineAnnotatedConstructor: any[]): IModule;
@@ -266,26 +244,15 @@ declare namespace angular {
/**
* Run blocks are the closest thing in Angular to the main method. A run block is the code which needs to run to kickstart the application. It is executed after all of the service have been configured and the injector has been created. Run blocks typically contain code which is hard to unit-test, and for this reason should be declared in isolated modules, so that they can be ignored in the unit-tests.
*/
run(initializationFunction: Function): IModule;
/**
* Run blocks are the closest thing in Angular to the main method. A run block is the code which needs to run to kickstart the application. It is executed after all of the service have been configured and the injector has been created. Run blocks typically contain code which is hard to unit-test, and for this reason should be declared in isolated modules, so that they can be ignored in the unit-tests.
*/
run(inlineAnnotatedFunction: any[]): IModule;
run(initializationFunction: Injectable<Function>): IModule;
/**
* Register a service constructor, which will be invoked with new to create the service instance. This is short for registering a service where its provider's $get property is a factory function that returns an instance instantiated by the injector from the service constructor function.
*
* @param name The name of the instance.
* @param serviceConstructor An injectable class (constructor function) that will be instantiated.
*/
service(name: string, serviceConstructor: Function): IModule;
/**
* Register a service constructor, which will be invoked with new to create the service instance. This is short for registering a service where its provider's $get property is a factory function that returns an instance instantiated by the injector from the service constructor function.
*
* @param name The name of the instance.
* @param inlineAnnotatedConstructor An injectable class (constructor function) that will be instantiated.
*/
service(name: string, inlineAnnotatedConstructor: any[]): IModule;
service(object: Object): IModule;
service(name: string, serviceConstructor: Injectable<Function>): IModule;
service(object: {[name: string]: Injectable<Function>}): IModule;
/**
* Register a value service with the $injector, such as a string, a number, an array, an object or a function. This is short for registering a service where its provider's $get property is a factory function that takes no arguments and returns the value service.
@@ -302,8 +269,7 @@ declare namespace angular {
* @param name The name of the service to decorate
* @param decorator This function will be invoked when the service needs to be instantiated and should return the decorated service instance. The function is called using the injector.invoke method and is therefore fully injectable. Local injection arguments: $delegate - The original service instance, which can be monkey patched, configured, decorated or delegated to.
*/
decorator(name:string, decoratorConstructor: Function): IModule;
decorator(name:string, inlineAnnotatedConstructor: any[]): IModule;
decorator(name: string, decorator: Injectable<Function>): IModule;
// Properties
name: string;
@@ -613,11 +579,11 @@ declare namespace angular {
/**
* calling stopPropagation function will cancel further event propagation (available only for events that were $emit-ed).
*/
stopPropagation?: Function;
stopPropagation?(): void;
/**
* calling preventDefault sets defaultPrevented flag to true.
*/
preventDefault: Function;
preventDefault(): void;
/**
* true if preventDefault was called.
*/
@@ -1221,19 +1187,12 @@ declare namespace angular {
// see http://docs.angularjs.org/api/ng.$compileProvider
///////////////////////////////////////////////////////////////////////////
interface ICompileService {
(element: string, transclude?: ITranscludeFunction, maxPriority?: number): ITemplateLinkingFunction;
(element: Element, transclude?: ITranscludeFunction, maxPriority?: number): ITemplateLinkingFunction;
(element: JQuery, transclude?: ITranscludeFunction, maxPriority?: number): ITemplateLinkingFunction;
(element: string | Element | JQuery, transclude?: ITranscludeFunction, maxPriority?: number): ITemplateLinkingFunction;
}
interface ICompileProvider extends IServiceProvider {
directive(name: string, directiveFactory: Function): ICompileProvider;
directive(directivesMap: Object, directiveFactory: Function): ICompileProvider;
directive(name: string, inlineAnnotatedFunction: any[]): ICompileProvider;
directive(directivesMap: Object, inlineAnnotatedFunction: any[]): ICompileProvider;
// Undocumented, but it is there...
directive(directivesMap: any): ICompileProvider;
directive(name: string, directiveFactory: Injectable<IDirectiveFactory>): ICompileProvider;
directive(object: {[directiveName: string]: Injectable<IDirectiveFactory>}): ICompileProvider;
component(name: string, options: IComponentOptions): ICompileProvider;
@@ -1243,7 +1202,8 @@ declare namespace angular {
imgSrcSanitizationWhitelist(): RegExp;
imgSrcSanitizationWhitelist(regexp: RegExp): ICompileProvider;
debugInfoEnabled(enabled?: boolean): any;
debugInfoEnabled(): boolean;
debugInfoEnabled(enabled: boolean): ICompileProvider;
}
interface ICloneAttachFunction {
@@ -1256,12 +1216,16 @@ declare namespace angular {
(scope: IScope, cloneAttachFn?: ICloneAttachFunction): JQuery;
}
// This corresponds to $transclude (and also the transclude function passed to link).
/**
* This corresponds to $transclude passed to controllers and to the transclude function passed to link functions.
* https://docs.angularjs.org/api/ng/service/$compile#-controller-
* http://teropa.info/blog/2015/06/09/transclusion.html
*/
interface ITranscludeFunction {
// If the scope is provided, then the cloneAttachFn must be as well.
(scope: IScope, cloneAttachFn: ICloneAttachFunction, futureParentElement?: JQuery, slotName?: string): JQuery;
// If one argument is provided, then it's assumed to be the cloneAttachFn.
(cloneAttachFn?: ICloneAttachFunction): JQuery;
(cloneAttachFn?: ICloneAttachFunction, futureParentElement?: JQuery, slotName?: string): JQuery;
}
///////////////////////////////////////////////////////////////////////////
@@ -1413,12 +1377,12 @@ declare namespace angular {
*/
url: string;
/**
* Event listeners to be bound to the XMLHttpRequest object.
* Event listeners to be bound to the XMLHttpRequest object.
* To bind events to the XMLHttpRequest upload object, use uploadEventHandlers. The handler will be called in the context of a $apply block.
*/
eventHandlers?: { [type: string]: EventListenerOrEventListenerObject };
/**
* Event listeners to be bound to the XMLHttpRequest upload object.
* Event listeners to be bound to the XMLHttpRequest upload object.
* To bind events to the XMLHttpRequest object, use eventHandlers. The handler will be called in the context of a $apply block.
*/
uploadEventHandlers?: { [type: string]: EventListenerOrEventListenerObject };
@@ -1549,7 +1513,7 @@ declare namespace angular {
* Register service factories (names or implementations) for interceptors which are called before and after
* each request.
*/
interceptors: (string|IHttpInterceptorFactory|(string|IHttpInterceptorFactory)[])[];
interceptors: (string | Injectable<IHttpInterceptorFactory>)[];
useApplyAsync(): boolean;
useApplyAsync(value: boolean): IHttpProvider;
@@ -1697,11 +1661,10 @@ declare namespace angular {
* controller if passed as a string. Empty function by default.
* Use the array form to define dependencies (necessary if strictDi is enabled and you require dependency injection)
*/
controller?: string | Function | (string | Function)[] | IComponentController;
controller?: string | Injectable<IControllerConstructor>;
/**
* An identifier name for a reference to the controller. If present, the controller will be published to scope under
* the controllerAs name. If not present, this will default to be the same as the component name.
* @default "$ctrl"
* An identifier name for a reference to the controller. If present, the controller will be published to its scope under
* the specified name. If not present, this will default to '$ctrl'.
*/
controllerAs?: string;
/**
@@ -1712,24 +1675,24 @@ declare namespace angular {
* $attrs - Current attributes object for the element
* Use the array form to define dependencies (necessary if strictDi is enabled and you require dependency injection)
*/
template?: string | Function | (string | Function)[];
template?: string | Injectable<(...args: any[]) => string>;
/**
* path or function that returns a path to an html template that should be used as the contents of this component.
* Path or function that returns a path to an html template that should be used as the contents of this component.
* If templateUrl is a function, then it is injected with the following locals:
* $element - Current element
* $attrs - Current attributes object for the element
* Use the array form to define dependencies (necessary if strictDi is enabled and you require dependency injection)
*/
templateUrl?: string | Function | (string | Function)[];
templateUrl?: string | Injectable<(...args: any[]) => string>;
/**
* Define DOM attribute binding to component properties. Component properties are always bound to the component
* controller and not to the scope.
*/
bindings?: IComponentBindings;
bindings?: {[boundProperty: string]: string};
/**
* Whether transclusion is enabled. Enabled by default.
* Whether transclusion is enabled. Disabled by default.
*/
transclude?: boolean | string | {[slot: string]: string};
transclude?: boolean | {[slot: string]: string};
/**
* Requires the controllers of other directives and binds them to this component's controller.
* The object keys specify the property names under which the required controllers (object values) will be bound.
@@ -1739,26 +1702,33 @@ declare namespace angular {
require?: {[controller: string]: string};
}
interface IComponentBindings {
[binding: string]: string;
}
interface IComponentTemplateFn {
( $element?: JQuery, $attrs?: IAttributes ): string;
}
type IControllerConstructor =
(new (...args: any[]) => IController) |
// Instead of classes, plain functions are often used as controller constructors, especially in examples.
((...args: any[]) => (void | IController));
/**
* Components have a well-defined lifecycle Each component can implement "lifecycle hooks". These are methods that
* will be called at certain points in the life of the component.
* @url https://docs.angularjs.org/guide/component
* Directive controllers have a well-defined lifecycle. Each controller can implement "lifecycle hooks". These are methods that
* will be called by Angular at certain points in the life cycle of the directive.
* https://docs.angularjs.org/api/ng/service/$compile#life-cycle-hooks
* https://docs.angularjs.org/guide/component
*/
interface IComponentController {
interface IController {
/**
* Called on each controller after all the controllers on an element have been constructed and had their bindings
* initialized (and before the pre & post linking functions for the directives on this element). This is a good
* place to put initialization code for your controller.
*/
$onInit?(): void;
/**
* Called on each turn of the digest cycle. Provides an opportunity to detect and act on changes.
* Any actions that you wish to take in response to the changes that you detect must be invoked from this hook;
* implementing this has no effect on when `$onChanges` is called. For example, this hook could be useful if you wish
* to perform a deep equality check, or to check a `Dat`e object, changes to which would not be detected by Angular's
* change detector and thus not trigger `$onChanges`. This hook is invoked with no arguments; if detecting changes,
* you must store the previous value(s) for comparison to the current values.
*/
$doCheck?(): void;
/**
* Called whenever one-way bindings are updated. The onChangesObj is a hash whose keys are the names of the bound
* properties that have changed, and the values are an {@link IChangesObject} object of the form
@@ -1781,14 +1751,14 @@ declare namespace angular {
*/
$postLink?(): void;
}
interface IOnChangesObject {
[property: string]: IChangesObject;
[property: string]: IChangesObject<any>;
}
interface IChangesObject {
currentValue: any;
previousValue: any;
interface IChangesObject<T> {
currentValue: T;
previousValue: T;
isFirstChange(): boolean;
}
@@ -1828,16 +1798,12 @@ declare namespace angular {
* that is passed to the link function instead.
*/
transclude: ITranscludeFunction
): void | IDirectivePrePost;
}
interface IDirectiveScope {
[property: string]: string;
): void | IDirectiveLinkFn | IDirectivePrePost;
}
interface IDirective {
compile?: IDirectiveCompileFn;
controller?: any;
controller?: string | Injectable<IControllerConstructor>;
controllerAs?: string;
/**
* @deprecated
@@ -1845,10 +1811,9 @@ declare namespace angular {
* the controller constructor is called, this use is now deprecated. Please place initialization code that
* relies upon bindings inside a $onInit method on the controller, instead.
*/
bindToController?: boolean | Object;
bindToController?: boolean | {[boundProperty: string]: string};
link?: IDirectiveLinkFn | IDirectivePrePost;
multiElement?: boolean;
directiveName?: string;
priority?: number;
/**
* @deprecated
@@ -1856,12 +1821,12 @@ declare namespace angular {
replace?: boolean;
require?: string | string[] | {[controller: string]: string};
restrict?: string;
scope?: boolean | IDirectiveScope;
template?: string | Function;
scope?: boolean | {[boundProperty: string]: string};
template?: string | ((tElement: JQuery, tAttrs: IAttributes) => string);
templateNamespace?: string;
templateUrl?: string | Function;
templateUrl?: string | ((tElement: JQuery, tAttrs: IAttributes) => string);
terminal?: boolean;
transclude?: boolean | string | {[slot: string]: string};
transclude?: boolean | 'element' | {[slot: string]: string};
}
/**
@@ -1874,6 +1839,11 @@ declare namespace angular {
interface IAugmentedJQueryStatic extends JQueryStatic {}
interface IAugmentedJQuery extends JQuery {}
/**
* Same as IController. Keeping it for compatibility with older versions of these type definitions.
*/
interface IComponentController extends IController {}
///////////////////////////////////////////////////////////////////////////
// AUTO module (angular.js)
///////////////////////////////////////////////////////////////////////////
+239
View File
@@ -163,6 +163,37 @@ declare module "aws-sdk" {
region: string;
}
export class CloudFormation {
constructor(options?: CloudFormation.Options);
endpoint: Endpoint;
cancelUpdateStack(params: CloudFormation.CancelUpdateStackParams, callback: (err: AwsError, data: any) => void): void;
continueUpdateRollback(params: CloudFormation.ContinueUpdateRollbackParams, callback: (err: AwsError, data: any) => void): void;
createChangeSet(params: CloudFormation.CreateChangeSetParams, callback: (err: AwsError, data: any) => void): void;
createStack(params: CloudFormation.CreateStackParams, callback: (err: AwsError, data: any) => void): void;
deleteChangeSet(params: CloudFormation.DeleteChangeSetParams, callback: (err: AwsError, data: any) => void): void;
deleteStack(params: CloudFormation.DeleteStackParams, callback: (err: AwsError, data: any) => void): void;
describeAccountLimits(params: CloudFormation.DescribeAccountLimitsParams, callback: (err: AwsError, data: any) => void): void;
describeChangeSet(params: CloudFormation.DescribeChangeSetParams, callback: (err: AwsError, data: any) => void): void;
describeStackEvents(params: CloudFormation.DescribeStackEventsParams, callback: (err: AwsError, data: any) => void): void;
describeStackResource(params: CloudFormation.DescribeStackResourceParams, callback: (err: AwsError, data: any) => void): void;
describeStackResources(params: CloudFormation.DescribeStackResourcesParams, callback: (err: AwsError, data: any) => void): void;
describeStacks(params: CloudFormation.DescribeStacksParams, callback: (err: AwsError, data: any) => void): void;
estimateTemplateCost(params: CloudFormation.EstimateTemplateCostParams, callback: (err: AwsError, data: any) => void): void;
executeChangeSet(params: CloudFormation.ExecuteChangeSetParams, callback: (err: AwsError, data: any) => void): void;
getStackPolicy(params: CloudFormation.GetStackPolicyParams, callback: (err: AwsError, data: any) => void): void;
getTemplate(params: CloudFormation.GetTemplateParams, callback: (err: AwsError, data: any) => void): void;
getTemplateSummary(params: CloudFormation.GetTemplateSummaryParams, callback: (err: AwsError, data: any) => void): void;
listChangeSets(params: CloudFormation.ListChangeSetsParams, callback: (err: AwsError, data: any) => void): void;
listStackResources(params: CloudFormation.ListStackResourcesParams, callback: (err: AwsError, data: any) => void): void;
listStacks(params: CloudFormation.ListStacksParams, callback: (err: AwsError, data: any) => void): void;
setStackPolicy(params: CloudFormation.SetStackPolicyParams, callback: (err: AwsError, data: any) => void): void;
signalResource(params: CloudFormation.SignalResourceParams, callback: (err: AwsError, data: any) => void): void;
updateStack(params: CloudFormation.UpdateStackParams, callback: (err: AwsError, data: any) => void): void;
validateTemplate(params: CloudFormation.ValidateTemplateParams, callback: (err: AwsError, data: any) => void): void;
waitFor(state: string, params: CloudFormation.WaitForParams, callback: (err: AwsError, data: any) => void): void;
}
export class Lambda {
constructor(options?: any);
endpoint: Endpoint;
@@ -532,6 +563,214 @@ declare module "aws-sdk" {
// ===========================================================
export module CloudFormation {
export interface CancelUpdateStackParams {
StackName: string;
}
export interface ContinueUpdateRollbackParams {
StackName: string;
}
export interface CreateChangeSetParams {
StackName: string;
TemplateBody?: string; // specify either TemplateBody or TemplateURL
TemplateURL?: string; // specify either TemplateBody or TemplateURL
UsePreviousTemplate?: boolean;
Parameters?: CloudFormation.Parameter[];
Capabilities?: string[]; // CAPABILITY_IAM | CAPABILITY_NAMED_IAM
ResourceTypes?: string[];
NotificationARNs?: string[];
Tags?: CloudFormation.Tag[];
ChangeSetName: string;
ClientToken?: string;
Description?: string;
}
export interface CreateStackParams {
StackName: string;
TemplateBody?: string; // specify either TemplateBody or TemplateURL
TemplateURL?: string; // specify either TemplateBody or TemplateURL
Parameters?: CloudFormation.Parameter[];
DisableRollback?: boolean; // cannot specify both DisableRollback and OnFailure
TimeoutInMinutes?: number;
NotificationARNs?: string[];
Capabilities?: string[];
ResourceTypes?: string[];
OnFailure?: string[]; // cannot specify both DisableRollback and OnFailure
// DO_NOTHING | ROLLBACK | DELETE
StackPolicyBody?: string[]; // cannot specify both StackPolicyBody and StackPolicyURL
StackPolicyURL?: string[]; // cannot specify both StackPolicyBody and StackPolicyURL
Tags?: CloudFormation.Tag[];
}
export interface DeleteChangeSetParams {
ChangeSetName: string;
StackName?: string;
}
export interface DeleteStackParams {
StackName: string;
RetainResources?: string[];
}
export interface DescribeAccountLimitsParams {
NextToken?: string;
}
export interface DescribeChangeSetParams {
ChangeSetName: string;
StackName?: string;
NextToken?: string;
}
export interface DescribeStackEventsParams {
StackName?: string;
NextToken?: string;
}
export interface DescribeStackResourceParams {
StackName: string;
LogicalResourceId: string;
}
export interface DescribeStackResourcesParams {
StackName?: string; // must specify either StackName or PhysicalResourceId
LogicalResourceId?: string;
PhysicalResourceId?: string; // must specify either StackName or PhysicalResourceId
}
export interface DescribeStacksParams {
StackName?: string;
NextToken?: string;
}
export interface EstimateTemplateCostParams {
TemplateBody?: string; // must specify either TemplateBody or TemplateURL
// if both are passed, only TemplateBody is used
TemplateURL?: string; // must specify either TemplateBody or TemplateURL
Parameters?: CloudFormation.Parameter[];
}
export interface ExecuteChangeSetParams {
ChangeSetName: string;
StackName?: string;
}
export interface GetStackPolicyParams {
StackName: string;
}
export interface GetTemplateParams {
StackName: string;
}
export interface GetTemplateSummaryParams {
// must specify one of the three
TemplateBody?: string;
TemplateURL?: string;
StackName?: string;
}
export interface ListChangeSetsParams {
StackName: string;
NextToken?: string;
}
export interface ListStackResourcesParams {
StackName: string;
NextToken?: string;
}
export interface ListStacksParams {
NextToken?: string;
StackStatusFilter?: string[];
}
export interface SetStackPolicyParams {
StackName: string;
StackPolicyBody?: string; // cannot set both StackPolicyBody and StackPolicyURL
StackPolicyURL?: string; // cannot set both StackPolicyBody and StackPolicyURL
}
export interface SignalResourceParams {
StackName: string;
LogicalResourceId: string;
UniqueId: string;
Status: string; // SUCCESS | FAILURE
}
export interface UpdateStackParams {
StackName: string;
TemplateBody?: string; // specify either TemplateBody or TemplateURL, not both
TemplateURL?: string; // specify either TemplateBody or TemplateURL, not both
UsePreviousTemplate?: boolean;
StackPolicyDuringUpdateBody?: string; // cannot set both StackPolicyDuringUpdateBody and StackPolicyDuringUpdateURL
StackPolicyDuringUpdateURL?: string; // cannot set both StackPolicyDuringUpdateBody and StackPolicyDuringUpdateURL
Parameters?: CloudFormation.Parameter[];
Capabilities?: string[]; // CAPABILITY_IAM | CAPABILITY_NAMED_IAM
ResourceTypes?: string[];
StackPolicyBody?: string; // cannot set both StackPolicyBody and StackPolicyURL
StackPolicyURL?: string; // cannot set both StackPolicyBody and StackPolicyURL
NotificationARNs?: string[];
Tags?: CloudFormation.Tag[];
}
export interface ValidateTemplateParams {
TemplateBody?: string; // must pass either TemplateBody or TemplateURL
// if both are specified, only TemplateBody is used
TemplateURL?: string; // must pass either TemplateBody or TemplateURL
}
export interface WaitForParams {
StackName: string;
NextToken?: string;
}
export interface Options {
params?: any;
endpoint?: string;
accessKeyId?: string;
secretAccessKey?: string;
sessionToken?: any;
credentials?: any;
credentialProvider?: any;
region?: string;
maxRetries?: number;
maxRedirects?: number;
sslEnabled?: boolean;
paramValidation?: any;
computeChecksums?: boolean;
convertResponseTypes?: boolean;
correctClockSkew?: boolean;
s3ForcePathStyle?: boolean;
s3BucketEndpoint?: boolean;
s3DisableBodySigning?: boolean;
retryDelayOptions?: any;
httpOptions?: any;
apiVersion?: any;
apiVersions?: any;
logger?: any;
systemClockOffset?: number;
signatureVersion?: string;
signatureCache?: boolean;
}
export interface Parameter {
ParameterKey: string;
ParameterValue: string;
UsePreviousValue?: boolean; // if you specify true, do not specify ParameterValue
}
export interface Tag {
Key: string;
Value: string;
}
}
// ===========================================================
export module Lambda {
export interface AddPermissionParams {
+13
View File
@@ -5,6 +5,13 @@
declare module "diff-match-patch" {
type Diff = [number, string];
export class Patch {
diffs: Diff[];
start1: number;
start2: number;
length1: number;
length2: number;
}
export class diff_match_patch {
static new (): diff_match_patch;
@@ -31,6 +38,12 @@ declare module "diff-match-patch" {
diff_levenshtein(diffs: Diff[]): number;
diff_toDelta(diffs: Diff[]): string;
diff_fromDelta(text1: string, delta: string): Diff[];
patch_make(text1: any, text2?: string): Patch[];
patch_deepCopy(patches: Patch[]): Patch[];
patch_apply(patches: Patch[], text: string): [string, boolean[]];
patch_fromText(text: string): Patch[];
patch_toText(patches: Patch[]): string;
}
export var DIFF_DELETE: number;
+1 -1
View File
@@ -109,7 +109,7 @@ declare module Elasticsearch {
export interface CreateDocumentParams extends GenericParams {
consistency?: "one" | "quorum" | "all";
parent?: string;
refressh?: boolean;
refresh?: boolean;
routing?: string;
timeout?: number | Date;
timestamp?: number | Date;
@@ -0,0 +1,20 @@
/// <reference path="../github-electron/github-electron.d.ts" />
/// <reference path="electron-devtools-installer.d.ts" />
import installExtension, {
EMBER_INSPECTOR, REACT_DEVELOPER_TOOLS,
BACKBONE_DEBUGGER, JQUERY_DEBUGGER,
ANGULARJS_BATARANG, VUEJS_DEVTOOLS,
REDUX_DEVTOOLS, REACT_PERF,
} from 'electron-devtools-installer';
installExtension(EMBER_INSPECTOR);
installExtension(REACT_DEVELOPER_TOOLS);
installExtension(BACKBONE_DEBUGGER);
installExtension(JQUERY_DEBUGGER);
installExtension(ANGULARJS_BATARANG);
installExtension(VUEJS_DEVTOOLS);
installExtension(REDUX_DEVTOOLS);
installExtension(REACT_PERF);
installExtension('abcdefghijkl');
@@ -0,0 +1,24 @@
// Type definitions for electron-devtools-installer v2.0.1
// Project: https://github.com/MarshallOfSound/electron-devtools-installer
// Definitions by: Robin Van den Broeck <https://github.com/gamesmaxed>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare module "electron-devtools-installer" {
interface ExtensionReference {
id: string,
electron: string,
}
// Default installation function
export default function (extensionReference: ExtensionReference | string, forceDownload?: boolean): Promise<string>;
// Devtools themself
export const EMBER_INSPECTOR: ExtensionReference;
export const REACT_DEVELOPER_TOOLS: ExtensionReference;
export const BACKBONE_DEBUGGER: ExtensionReference;
export const JQUERY_DEBUGGER: ExtensionReference;
export const ANGULARJS_BATARANG: ExtensionReference;
export const VUEJS_DEVTOOLS: ExtensionReference;
export const REDUX_DEVTOOLS: ExtensionReference;
export const REACT_PERF: ExtensionReference;
}
+5 -1
View File
@@ -97,6 +97,10 @@ declare module "express-serve-static-core" {
use: IRouterHandler<this> & IRouterMatcher<this>;
route(prefix: PathParams): IRoute;
/**
* Stack of configured routes
*/
stack: any[];
}
interface IRoute {
@@ -1048,7 +1052,7 @@ declare module "express-serve-static-core" {
routes: any;
/**
* Using to all registered routes in Express Application
* Used to get all registered routes in Express Application
*/
_router: any;
}
+1
View File
@@ -123,6 +123,7 @@ resultStr = faker.internet.mac();
resultStr = faker.internet.password();
resultStr = faker.internet.password(0, false, '#', 'foo');
resultStr = faker.lorem.word();
resultStr = faker.lorem.words();
resultStr = faker.lorem.words(0);
resultStr = faker.lorem.sentence();
+2 -1
View File
@@ -1,4 +1,4 @@
// Type definitions for faker
// Type definitions for faker v3.1
// Project: http://marak.com/faker.js/
// Definitions by: Bas Pennings <https://github.com/basp/>, Yuki Kokubun <https://github.com/Kuniwak>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@@ -135,6 +135,7 @@ declare namespace Faker {
};
lorem: {
word(): string;
words(num?: number): string;
sentence(wordCount?: number, range?: number): string;
sentences(sentenceCount?: number): string;
@@ -0,0 +1,21 @@
/// <reference path="../i18next/i18next"/>
/// <reference path="i18next-xhr-backend.d.ts"/>
import * as i18next from 'i18next';
import XHR from 'i18next-xhr-backend';
let options = {
loadPath: '',
addPath: '',
allowMultiLoading: false,
parse: function(data:string) { return data.replace(/a/g, ''); },
crossDomain: false,
withCredentials: false,
ajax: function (url:string, options:Object, callback: Function, data: Object) {}
};
i18next.use(XHR).init({
backend: options
});
let xhr = new XHR(null, options);
+36
View File
@@ -0,0 +1,36 @@
// Type definitions for i18next-xhr-backend 1.2.0
// Project: https://github.com/i18next/i18next-xhr-backend
// Definitions by: Jan Mühlemann <https://github.com/jamuhl>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare module 'i18next-xhr-backend' {
interface Interpolator {
interpolate: () => string
}
interface Services {
interpolator: Interpolator
}
interface BackendOptions {
loadPath?: string | Function,
addPath?: string,
allowMultiLoading?: boolean,
parse?: Function,
crossDomain?: boolean,
withCredentials?: boolean,
ajax?: Function
}
export default class Backend {
type: 'backend';
services: Services;
options: BackendOptions;
constructor(services?: Services, options?: BackendOptions);
init(services?: Services, options?: BackendOptions): void;
readMulti(languages: any[], namespaces: any[], callback: Function): void;
read(language: {}, namespace: {}, callback: Function): void;
loadUrl(url: string, callback: Function): void;
create(languages: any[], namespace: string, key: string, fallbackValue: string): void;
}
}
+85
View File
@@ -0,0 +1,85 @@
/// <reference path="./imap-simple.d.ts" />
import * as imaps from "imap-simple";
let config = {
imap: {
user: "your@email.address",
password: "yourpassword",
host: "imap.gmail.com",
port: 993,
tls: true,
authTimeout: 3000
}
};
imaps.connect(config).then(function (connection) {
return connection.openBox("INBOX").then(function () {
let searchCriteria = [
"UNSEEN"
];
let fetchOptions = {
bodies: ["HEADER", "TEXT"],
markSeen: false
};
return connection.search(searchCriteria, fetchOptions).then(function (results) {
let subjects = results.map(function (res) {
return res.parts.filter(function (part) {
return part.which === "HEADER";
})[0].body.subject[0];
});
console.log(subjects);
// =>
// [ "Hey Chad, long time no see!",
// "Your amazon.com monthly statement",
// "Hacker Newsletter Issue #445" ]
});
});
});
imaps.connect(config).then(function (connection) {
connection.openBox("INBOX").then(function () {
// Fetch emails from the last 24h
let delay = 24 * 3600 * 1000;
let yesterday = new Date();
yesterday.setTime(Date.now() - delay);
let yesterdayString = yesterday.toISOString();
let searchCriteria = ["UNSEEN", ["SINCE", yesterdayString]];
let fetchOptions = { bodies: ["HEADER.FIELDS (FROM TO SUBJECT DATE)"], struct: true };
// retrieve only the headers of the messages
return connection.search(searchCriteria, fetchOptions);
}).then(function (messages) {
let attachments: Promise<{filename: string, data: any}>[] = [];
messages.forEach(function (message) {
let parts = imaps.getParts(message.attributes.struct);
attachments = attachments.concat(parts.filter(function (part) {
return part.disposition && part.disposition.type === "ATTACHMENT";
}).map(function (part) {
// retrieve the attachments only of the messages with attachments
return connection.getPartData(message, part)
.then(function (partData) {
return {
filename: part.disposition.params.filename,
data: partData
};
});
}));
});
return Promise.all<{filename: string, data: any}>(attachments);
}).then(function (attachments: {filename: string, data: any}[]) {
console.log(attachments);
// =>
// [ { filename: "cats.jpg", data: Buffer() },
// { filename: "pay-stub.pdf", data: Buffer() } ]
});
});
+75
View File
@@ -0,0 +1,75 @@
// Type definitions for imap-simple v1.6.3
// Project: https://github.com/chadxz/imap-simple
// Definitions by: Jeffery Grajkowski <https://github.com/pushplay/>
// Definitions: https://github.com/psnider/DefinitelyTyped/imap-simple
/// <reference path="../imap/imap.d.ts" />
declare namespace IMAPS {
export interface ImapSimpleOptions {
/** Options to pass to node-imap constructor. */
imap: IMAP.Config;
/** Time in milliseconds to wait before giving up on a connection attempt. (Deprecated: please use options.imap.authTimeout instead) */
connectTimeout?: number;
}
export interface MessageBodyPart extends IMAP.ImapMessageBodyInfo {
/** string type where which=='TEXT', complex Object where which=='HEADER' */
body: any;
}
export interface Message {
attributes: IMAP.ImapMessageAttributes;
parts: MessageBodyPart[];
}
export class ImapSimple {
constructor(imap: IMAP.Connection);
/** Open a mailbox, calling the provided callback with signature (err, boxName), or resolves the returned promise with boxName. */
openBox(boxName: string, callback: (err: Error, boxName: string) => void): void;
openBox(boxName: string): Promise<string>;
/** Search for and retrieve mail in the previously opened mailbox. */
search(searchCriteria: any[], fetchOptions: IMAP.FetchOptions, callback: (err: Error, messages: Message[]) => void): void;
search(searchCriteria: any[], fetchOptions: IMAP.FetchOptions): Promise<Message[]>;
/** Close the connection to the imap server. */
end(): void;
/** Downloads part data (which is either part of the message body, or an attachment). Upon success, either the provided callback will be called with signature (err, data), or the returned promise will be resolved with data. The data will be automatically decoded based on its encoding. If the encoding of the part is not supported, an error will occur. */
getPartData(message: Message, part: any, callback: (err: Error, data: any) => void): void;
getPartData(message: Message, part: any): Promise<any>;
/** Adds the provided label(s) to the specified message(s). source corresponds to a node-imap MessageSource which specifies the messages to be moved. label is either a string or array of strings indicating the labels to add. When completed, either calls the provided callback with signature (err), or resolves the returned promise. */
addMessageLabel(source: string | string[], label: string | string[], callback: (err: Error) => void): void;
addMessageLabel(source: string | string[], label: string | string[]): Promise<void>;
/** Moves the specified message(s) in the currently open mailbox to another mailbox. source corresponds to a node-imap MessageSource which specifies the messages to be moved. When completed, either calls the provided callback with signature (err), or resolves the returned promise. */
moveMessage(source: string | string[], boxName: string, callback: (err: Error) => void): void;
moveMessage(source: string | string[], boxName: string): Promise<void>;
}
/** Error thrown when a connection attempt has timed out. */
export class ConnectionTimeoutError extends Error {
timeout: number;
constructor(timeout: number);
}
}
declare module "imap-simple" {
/** Main entry point. Connect to an Imap server. */
export function connect(options: IMAPS.ImapSimpleOptions, callback: (err: Error, connection: IMAPS.ImapSimple) => void): void;
export function connect(options: IMAPS.ImapSimpleOptions): Promise<IMAPS.ImapSimple>;
export namespace errors {
export import ConnectionTimeoutError = IMAPS.ConnectionTimeoutError;
}
export import ImapSimple = IMAPS.ImapSimple;
/** Given the message.attributes.struct, retrieve a flattened array of parts objects that describe the structure of the different parts of the message's body. Useful for getting a simple list to iterate for the purposes of, for example, finding all attachments. */
export function getParts(struct: any[]): any[];
}
+374
View File
@@ -0,0 +1,374 @@
// These examples adapted from Mapbox's examples (https://www.mapbox.com/mapbox-gl-js/examples)
/// <reference path="./mapbox-gl.d.ts" />
/// <reference path="../geojson/geojson.d.ts" />
/**
* Set API Access Token
*/
mapboxgl.accessToken = 'foo';
/**
* Display a Map
*/
let map = new mapboxgl.Map({
container: 'map',
style: 'mapbox://styles/mapbox/streets-v8',
center: [-50, 50],
zoom: 10,
minZoom: 1,
maxZoom: 2,
interactive: true,
attributionControl: false,
bearingSnap: 7,
scrollZoom: true,
maxBounds: [[-100,-90],[100,90]],
boxZoom: true,
dragRotate: false,
dragPan: true,
});
/**
* Create and style marker clusters
*/
map.on('load', function(){
// Add a new source from our GeoJSON data and set the
// 'cluster' option to true.
map.addSource("data", {
type: "geojson",
data: "/data.geojson",
cluster: true,
clusterMaxZoom: 14, // Max zoom to cluster points on
clusterRadius: 50 // Radius of each cluster when clustering points (defaults to 50)
});
map.addLayer({
"id": "layer",
"type": "symbol",
"source": "data",
"layout": {
"icon-image": "marker-15"
}
});
var layers = [
[150, '#f28cb1'],
[20, '#f1f075'],
[0, '#51bbd6']
];
layers.forEach(function (layer, i) {
map.addLayer({
"id": "cluster-" + i,
"type": "circle",
"source": "data",
"paint": {
"circle-color": layer[1],
"circle-radius": 18
},
"filter": i == 0 ?
[">=", "point_count", layer[0]] :
["all",
[">=", "point_count", layer[0]],
["<", "point_count", layers[i - 1][0]]]
});
});
// Add a layer for the clusters' count labels
map.addLayer({
"id": "cluster-count",
"type": "symbol",
"source": "data",
"layout": {
"text-field": "{point_count}",
"text-font": [
"DIN Offc Pro Medium",
"Arial Unicode MS Bold"
],
"text-size": 12
}
});
/**
* Add a GeoJSON line
*/
map.addSource("route", {
"type": "geojson",
"data": {
"type": "Feature",
"properties": {},
"geometry": {
"type": "LineString",
"coordinates": [
[-122.48369693756104, 37.83381888486939],
[-122.48348236083984, 37.83317489144141],
[-122.48339653015138, 37.83270036637107],
[-122.48356819152832, 37.832056363179625],
[-122.48404026031496, 37.83114119107971],
[-122.48404026031496, 37.83049717427869],
[-122.48348236083984, 37.829920943955045],
[-122.48356819152832, 37.82954808664175],
[-122.48507022857666, 37.82944639795659],
[-122.48610019683838, 37.82880236636284],
[-122.48695850372314, 37.82931081282506],
[-122.48700141906738, 37.83080223556934],
[-122.48751640319824, 37.83168351665737],
[-122.48803138732912, 37.832158048267786],
[-122.48888969421387, 37.83297152392784],
[-122.48987674713133, 37.83263257682617],
[-122.49043464660643, 37.832937629287755],
[-122.49125003814696, 37.832429207817725],
[-122.49163627624512, 37.832564787218985],
[-122.49223709106445, 37.83337825839438],
[-122.49378204345702, 37.83368330777276]
]
}
}
});
map.addLayer({
"id": "route",
"type": "line",
"source": "route",
"layout": {
"line-join": "round",
"line-cap": "round"
},
"paint": {
"line-color": "#888",
"line-width": 8
}
});
});
// FlyTo
map.flyTo({
center: [0, 0],
zoom: 10,
speed: 0.5,
curve: 1,
screenSpeed: 1,
easing: function(t: any) {
return t;
}
});
/**
* GeoJSONSource
*/
var geoJSONSourceObj = new mapboxgl.GeoJSONSource({
data: {
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"properties": null,
"geometry": {
"type": "Point",
"coordinates": [-50, 0]
}
}]
}
});
map.addSource('some id', geoJSONSourceObj); // add
map.removeSource('some id'); // remove
/**
* ImageSource
*/
var imageSourceObj = new mapboxgl.ImageSource({
url: '/foo.png',
coordinates: [
[-76.54335737228394, 39.18579907229748],
[-76.52803659439087, 39.1838364847587],
[-76.5295386314392, 39.17683392507606],
[-76.54520273208618, 39.17876344106642]
]
});
map.addSource('some id', imageSourceObj); // add
map.removeSource('some id'); // remove
/**
* Video Source
*/
var videoSourceObj = new mapboxgl.VideoSource({
urls: [
'/blah.mp4',
'/blah.webm'
],
coordinates: [
[-76.54335737228394, 39.18579907229748],
[-76.52803659439087, 39.1838364847587],
[-76.5295386314392, 39.17683392507606],
[-76.54520273208618, 39.17876344106642]
]
});
map.addSource('some id', videoSourceObj); // add
map.removeSource('some id'); // remove
/**
* Popup
*/
var popup = new mapboxgl.Popup({closeOnClick: false, closeButton: true, anchor: 'top-right', offset: {'top': [0,0], 'bottom': [25,-50]} })
.setLngLat([-50, 50])
.setHTML('<h1>Hello World!</h1>')
.addTo(map);
/**
* Add an image
*/
var mapStyle = {
"version": 8,
"name": "Dark",
"sources": {
"mapbox": {
"type": "vector",
"url": "mapbox://mapbox.mapbox-streets-v6"
},
"overlay": {
"type": "image",
"url": "/mapbox-gl-js/assets/radar.gif",
"coordinates": [
[-50, 40],
[0, 40],
[0, 0],
[-50, 0]
]
}
},
"sprite": "mapbox://sprites/mapbox/dark-v8",
"glyphs": "mapbox://fonts/mapbox/{fontstack}/{range}.pbf",
"layers": [
{
"id": "background",
"type": "background",
"paint": {"background-color": "#111"}
},
{
"id": "water",
"source": "mapbox",
"source-layer": "water",
"type": "fill",
"paint": {"fill-color": "#2c2c2c"}
},
{
"id": "boundaries",
"source": "mapbox",
"source-layer": "admin",
"type": "line",
"paint": {"line-color": "#797979", "line-dasharray": [2, 2, 6, 2]},
"filter": ["all", ["==", "maritime", 0]],
},
{
"id": "overlay",
"source": "overlay",
"type": "raster",
"paint": {"raster-opacity": 0.85}
},
{
"id": "cities",
"source": "mapbox",
"source-layer": "place_label",
"type": "symbol",
"layout": {
"text-field": "{name_en}",
"text-font": ["DIN Offc Pro Bold", "Arial Unicode MS Bold"],
"text-size": {"stops": [[4, 9], [6, 12]]}
},
"paint": {
"text-color": "#969696",
"text-halo-width": 2,
"text-halo-color": "rgba(0, 0, 0, 0.85)"
}
},
{
"id": "states",
"source": "mapbox",
"source-layer": "state_label",
"type": "symbol",
"layout": {
"text-transform": "uppercase",
"text-field": "{name_en}",
"text-font": ["DIN Offc Pro Bold", "Arial Unicode MS Bold"],
"text-letter-spacing": 0.15,
"text-max-width": 7,
"text-size": {"stops": [[4, 10], [6, 14]]}
},
"filter": [">=", "area", 80000],
"paint": {
"text-color": "#969696",
"text-halo-width": 2,
"text-halo-color": "rgba(0, 0, 0, 0.85)"
}
}
]
};
map = new mapboxgl.Map({
container: 'map',
minZoom: 14,
zoom: 17,
center: [-122.514426, 37.562984],
bearing: -96,
style: videoStyle,
hash: false
});
/**
* Add video
*/
var videoStyle: mapboxgl.Style = {
"version": 8,
"sources": {
"satellite": {
"type": "raster",
"url": "mapbox://mapbox.satellite",
"tileSize": 256
},
"video": {
"type": "video",
"urls": ["drone.mp4", "drone.webm"],
"coordinates": [
[-122.51596391201019, 37.56238816766053],
[-122.51467645168304, 37.56410183312965],
[-122.51309394836426, 37.563391708549425],
[-122.51423120498657, 37.56161849366671]
]
}
},
"layers": [{
"id": "background",
"type": "background",
"paint": {
"background-color": "rgb(4,7,14)"
}
}, {
"id": "satellite",
"type": "raster",
"source": "satellite"
}, {
"id": "video",
"type": "raster",
"source": "video"
}]
};
map = new mapboxgl.Map({
container: 'map',
minZoom: 14,
zoom: 17,
center: [-122.514426, 37.562984],
bearing: -96,
style: videoStyle,
hash: false
});
/**
* Marker
*/
let marker = new mapboxgl.Marker(null,{offset: [10, 0]})
.setLngLat([-50,50])
.addTo(map);
marker.remove();
+936
View File
@@ -0,0 +1,936 @@
// Type definitions for Mapbox GL JS v0.24.0
// Project: https://github.com/mapbox/mapbox-gl-js
// Definitions by: Dominik Bruderer <https://github.com/dobrud>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../geojson/geojson.d.ts" />
declare namespace mapboxgl {
let accessToken: string;
let version: string;
export function supported(options?: {failIfMajorPerformanceCaveat?: boolean}): boolean;
/**
* Map
*/
export class Map extends Evented {
constructor(options?: MapboxOptions);
addControl(control: Control): this;
addClass(klass: string, options?: mapboxgl.StyleOptions): this;
removeClass(klass: string, options?: mapboxgl.StyleOptions): this;
setClasses(klasses: string[], options?: mapboxgl.StyleOptions): this;
hasClass(klass: string): boolean;
getClasses(): string[];
resize(): this;
getBounds(): mapboxgl.LngLatBounds;
setMaxBounds(lnglatbounds?: mapboxgl.LngLatBounds | number[][]): this;
setMinZoom(minZoom?: number): this;
setMaxZoom(maxZoom?: number): this;
project(lnglat: mapboxgl.LngLat | number[]): mapboxgl.Point;
unproject(point: mapboxgl.Point | number[]): mapboxgl.LngLat;
queryRenderedFeatures(pointOrBox?: mapboxgl.Point|number[]|mapboxgl.Point[]|number[][], parameters?: {layers?: string[], filter?: any[]}): GeoJSON.Feature<GeoJSON.GeometryObject>[];
querySourceFeatures(sourceID: string, parameters: {sourceLayer?: string, filter?: any[]}): GeoJSON.Feature<GeoJSON.GeometryObject>[];
setStyle(style: mapboxgl.Style | string): this;
getStyle(): mapboxgl.Style;
addSource(id: string, source: VectorSource | RasterSource | GeoJSONSource | ImageSource | VideoSource | GeoJSONSourceRaw): this;
removeSource(id: string): this;
getSource(id: string): VectorSource | RasterSource | GeoJSONSource | ImageSource | VideoSource;
addLayer(layer: mapboxgl.Layer, before?: string): this;
removeLayer(id: string): this;
getLayer(id: string): mapboxgl.Layer;
setFilter(layer: string, filter: any[]): this;
setLayerZoomRange(layerId: string, minzoom: number, maxzoom: number): this;
getFilter(layer: string): any[];
setPaintProperty(layer: string, name: string, value: any, klass?: string): this;
getPaintProperty(layer: string, name: string, klass?: string): any;
setLayoutProperty(layer: string, name: string, value: any): this;
getLayoutProperty(layer: string, name: string, klass?: string): any;
getContainer(): HTMLElement;
getCanvasContainer(): HTMLElement;
getCanvas(): HTMLCanvasElement;
loaded(): boolean;
remove(): void;
onError(): void;
showTileBoundaries: boolean;
showCollisionBoxes: boolean;
repaint: boolean;
getCenter(): mapboxgl.LngLat;
setCenter(center: LngLat|number[], eventData?: mapboxgl.EventData): this;
panBy(offset: number[], options?: mapboxgl.AnimationOptions, eventData?: mapboxgl.EventData): this;
panTo(lnglat: mapboxgl.LngLat, options?: mapboxgl.AnimationOptions, eventdata?: mapboxgl.EventData): this;
getZoom(): number;
setZoom(zoom: number, eventData?: mapboxgl.EventData): this;
zoomTo(zoom: number, options?: mapboxgl.AnimationOptions, eventData?: mapboxgl.EventData): this;
zoomIn(options?: mapboxgl.AnimationOptions, eventData?: mapboxgl.EventData): this;
zoomOut(options?: mapboxgl.AnimationOptions, eventData?: mapboxgl.EventData): this;
getBearing(): number;
setBearing(bearing: number, eventData?: mapboxgl.EventData): this;
rotateTo(bearing: number, options?: mapboxgl.AnimationOptions, eventData?: EventData): this;
resetNorth(options?: mapboxgl.AnimationOptions, eventData?: mapboxgl.EventData): this;
snapToNorth(options?: mapboxgl.AnimationOptions, eventData?: mapboxgl.EventData): this;
getPitch(): number;
setPitch(pitch: number, eventData?: EventData): this;
fitBounds(bounds: mapboxgl.LngLatBounds | number[][], options?: { linear?: boolean, easing?: Function, padding?: number, offset?: Point|number[],maxZoom?: number }): this;
jumpTo(options: mapboxgl.CameraOptions, eventData?: mapboxgl.EventData): this;
easeTo(options: mapboxgl.CameraOptions | mapboxgl.AnimationOptions, eventData?: mapboxgl.EventData): this;
flyTo(options: mapboxgl.FlyToOptions, eventData?: mapboxgl.EventData): this;
stop(): this;
scrollZoom: ScrollZoomHandler;
boxZoom: BoxZoomHandler;
dragRotate: DragRotateHandler;
dragPan: DragPanHandler;
keyboard: KeyboardHandler;
doublClickZoom: DoubleClickZoomHandler;
touchZoomRotate: TouchZoomRotateHandler;
}
export interface MapboxOptions {
/** If true, an attribution control will be added to the map. */
attributionControl?: boolean;
bearing?: number;
/** Snap to north threshold in degrees. */
bearingSnap?: number;
/** If true, enable the "box zoom" interaction (see BoxZoomHandler) */
boxZoom?: boolean;
/** initial map center */
center?: mapboxgl.LngLat | number[];
/** Style class names with which to initialize the map */
classes?: string[];
/** ID of the container element */
container?: string | Element;
/** If true, enable the "drag to pan" interaction (see DragPanHandler). */
dragPan?: boolean;
/** If true, enable the "drag to rotate" interaction (see DragRotateHandler). */
dragRotate?: boolean;
/** If true, enable the "double click to zoom" interaction (see DoubleClickZoomHandler). */
doubleClickZoom?: boolean;
/** If true, the map will track and update the page URL according to map position */
hash?: boolean;
/** If true, map creation will fail if the implementation determines that the performance of the created WebGL context would be dramatically lower than expected. */
failIfMayorPerformanceCaveat?: boolean;
/** If false, no mouse, touch, or keyboard listeners are attached to the map, so it will not respond to input */
interactive?: boolean;
/** If true, enable keyboard shortcuts (see KeyboardHandler). */
keyboard?: boolean;
/** If set, the map is constrained to the given bounds. */
maxBounds?: mapboxgl.LngLatBounds | number[][];
/** Maximum zoom of the map */
maxZoom?: number;
/** Minimum zoom of the map */
minZoom?: number;
/** If true, The maps canvas can be exported to a PNG using map.getCanvas().toDataURL();. This is false by default as a performance optimization. */
preserveDrawingBuffer?: boolean;
pitch?: number;
/** If true, enable the "scroll to zoom" interaction */
scrollZoom?: boolean;
/** stylesheet location */
style?: mapboxgl.Style | string;
/** If true, the map will automatically resize when the browser window resizes */
trackResize?: boolean;
/** If true, enable the "pinch to rotate and zoom" interaction (see TouchZoomRotateHandler). */
touchZoomRotate?: boolean;
/** Initial zoom level */
zoom?: number;
}
/**
* BoxZoomHandler
*/
export class BoxZoomHandler {
constructor(map: mapboxgl.Map);
isEnabled(): boolean;
isActive(): boolean;
enable(): void;
disable(): void;
}
/**
* ScrollZoomHandler
*/
export class ScrollZoomHandler {
constructor(map: mapboxgl.Map);
isEnabled(): boolean;
enable(): void;
disable(): void;
}
/**
* DragPenHandler
*/
export class DragPanHandler {
constructor(map: mapboxgl.Map);
isEnabled(): boolean;
isActive(): boolean;
enable(): void;
disable(): void;
}
/**
* DragRotateHandler
*/
export class DragRotateHandler {
constructor(map: mapboxgl.Map, options?: {bearingSnap?: number, pitchWithRotate?: boolean});
isEnabled(): boolean;
isActive(): boolean;
enable(): void;
disable(): void;
}
/**
* KeyboardHandler
*/
export class KeyboardHandler {
constructor(map: mapboxgl.Map);
isEnabled(): boolean;
enable(): void;
disable(): void;
}
/**
* DoubleClickZoomHandler
*/
export class DoubleClickZoomHandler {
constructor(map: mapboxgl.Map);
isEnabled(): boolean;
enable(): void;
disable(): void;
}
/**
* TouchZoomRotateHandler
*/
export class TouchZoomRotateHandler {
constructor(map: mapboxgl.Map);
isEnabled(): boolean;
enable(): void;
disable(): void;
disableRotation(): void;
enableRotation(): void;
}
/**
* Control
*/
export class Control extends Evented {
addTo(map: mapboxgl.Map): this;
remove(): this;
}
/**
* ControlOptions
*/
export interface ControlOptions {
position?: 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left';
}
/**
* Navigation
*/
export class Navigation extends Control {
constructor(options?: mapboxgl.ControlOptions);
}
/**
* Geolocate
*/
export class Geolocate extends Control {
constructor(options?: mapboxgl.ControlOptions);
}
/**
* Attribution
*/
export class Attribution extends Control {
constructor(options?: mapboxgl.ControlOptions);
}
/**
* Scale
*/
export class Scale extends Control {
constructor(options?: {position?: 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left', maxWidth?: number, unit?: string})
}
/**
* Popup
*/
export class Popup extends Evented {
constructor(options?: mapboxgl.PopupOptions);
addTo(map: mapboxgl.Map): this;
isOpen(): boolean;
remove(): this;
getLngLat(): mapboxgl.LngLat;
setLngLat(lnglat: mapboxgl.LngLat | number[]): this;
setText(text: string): this;
setHTML(html: string): this;
setDOMContent(htmlNode: Node): this;
}
export interface PopupOptions {
closeButton?: boolean;
closeOnClick?: boolean;
anchor?: 'top' | 'bottom' | 'left' | 'right' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
offset?: number | Point | number[] | { [key:string]: Point | number[];};
}
export interface Style {
bearing?: number;
center?: number[];
glyphs?: string;
layers?: Layer[];
metadata?: any;
name?: string;
pitch?: number;
sources?: any;
sprite?: string;
transition?: Transition;
version: number;
zoom?: number;
}
export interface Transition {
delay?: number;
duration?: number;
}
export interface Source {
type: "vector" | "raster" | "geojson" | "image" | "video";
}
/**
* GeoJSONSource
*/
export interface GeoJSONSourceRaw extends Source, GeoJSONSourceOptions {
type: "geojson";
}
export class GeoJSONSource implements GeoJSONSourceRaw {
type: "geojson";
constructor(options?: mapboxgl.GeoJSONSourceOptions);
setData(data: GeoJSON.Feature<GeoJSON.GeometryObject> | GeoJSON.FeatureCollection<GeoJSON.GeometryObject> | String): this;
}
export interface GeoJSONSourceOptions {
data?: GeoJSON.Feature<GeoJSON.GeometryObject> | GeoJSON.FeatureCollection<GeoJSON.GeometryObject> | string;
maxzoom?: number;
buffer?: number;
tolerance?: number;
cluster?: number | boolean;
clusterRadius?: number;
clusterMaxZoom?: number;
}
/**
* VideoSource
*/
export class VideoSource implements Source, VideoSourceOptions {
type: "video";
constructor(options?: mapboxgl.VideoSourceOptions);
getVideo(): HTMLVideoElement;
setCoordinates(coordinates: number[][]): this;
}
export interface VideoSourceOptions {
urls?: string[];
coordinates?: number[][];
}
/**
* ImageSource
*/
export class ImageSource implements Source, ImageSourceOptions {
type: "image";
constructor(options?: mapboxgl.ImageSourceOptions);
setCoordinates(coordinates: number[][]): this;
}
export interface ImageSourceOptions {
url?: string;
coordinates?: number[][];
}
interface VectorSource extends Source {
type: "vector";
url?: string;
tiles?: string[];
minzoom?: number;
maxzoom?: number;
}
interface RasterSource extends Source {
type: "raster";
url: string;
tiles?: string[];
minzoom?: number;
maxzoom?: number;
tileSize?: number;
}
/**
* LngLat
*/
export class LngLat {
lng: number;
lat: number;
constructor(lng: number, lat: number);
/** Return a new LngLat object whose longitude is wrapped to the range (-180, 180). */
wrap(): mapboxgl.LngLat;
/** Return a LngLat as an array */
toArray(): number[];
/** Return a LngLat as a string */
toString(): string;
static convert(input: number[]|mapboxgl.LngLat): mapboxgl.LngLat;
}
/**
* LngLatBounds
*/
export class LngLatBounds {
sw: LngLat | number[];
ne: LngLat | number[];
constructor(sw?: LngLat, ne?: LngLat);
/** Extend the bounds to include a given LngLat or LngLatBounds. */
extend(obj: mapboxgl.LngLat | mapboxgl.LngLatBounds): this;
/** Get the point equidistant from this box's corners */
getCenter(): mapboxgl.LngLat;
/** Get southwest corner */
getSouthWest(): mapboxgl.LngLat;
/** Get northeast corner */
getNorthEast(): mapboxgl.LngLat;
/** Get northwest corner */
getNorthWest(): mapboxgl.LngLat;
/** Get southeast corner */
getSouthEast(): mapboxgl.LngLat;
/** Get west edge longitude */
getWest(): number;
/** Get south edge latitude */
getSouth(): number;
/** Get east edge longitude */
getEast(): number;
/** Get north edge latitude */
getNorth(): number;
/** Returns a LngLatBounds as an array */
toArray(): number[][];
/** Return a LngLatBounds as a string */
toString(): string;
/** Convert an array to a LngLatBounds object, or return an existing LngLatBounds object unchanged. */
static convert(input: mapboxgl.LngLatBounds | number[] | number[][]): mapboxgl.LngLatBounds;
}
/**
* Point
*/
// Todo: Pull out class to seperate definition for Module "point-geometry"
export class Point {
constructor(options?: Object);
clone(): Point;
add(p: number): Point;
sub(p: number): Point;
mult(k: number): Point;
div(k: number): Point;
rotate(a: number): Point;
matMult(m: number): Point;
unit(): Point;
perp(): Point;
round(): Point;
mag(): number;
equals(): boolean;
dist(): number;
distSqr(): number;
angle(): number;
angleTo(): number;
angleWidth(): number;
angleWidthSep(): number;
}
export class Marker {
constructor(element?: HTMLElement, options?: { offset?: Point | number[] });
addTo(map: Map): this;
remove(): this;
getLngLat(): LngLat;
setLngLat(lngLat: LngLat | number[]): this;
setPopup(popup?: Popup): this;
getPopup(): Popup;
togglePopup(): this;
}
/**
* Evented
*/
export class Evented {
on(type: string, listener: Function): this;
off(type?: string | any, listener?: Function): this;
once(type: string, listener: Function): this;
fire(type: string, data?: mapboxgl.EventData | Object): this;
listens(type: string): boolean;
}
/**
* StyleOptions
*/
export interface StyleOptions {
transition?: boolean;
}
/**
* EventData
*/
export class EventData {
type: string;
target: Map;
originalEvent: Event;
point: mapboxgl.Point;
lngLat: mapboxgl.LngLat;
}
export class MapMouseEvent {
type: string;
target: Map;
originalEvent: MouseEvent;
point: mapboxgl.Point;
lngLat: mapboxgl.LngLat;
}
export class MapTouchEvent {
type: string;
target: Map;
originalEvent: TouchEvent;
point: mapboxgl.Point;
lngLat: mapboxgl.LngLat;
points: Point[];
lngLats: LngLat[];
}
export class MapBoxZoomEvent {
originalEvent: MouseEvent;
boxZoomBounds: LngLatBounds;
}
/**
* AnimationOptions
*/
export interface AnimationOptions {
/** Number in milliseconds */
duration?: number;
easing?: Function;
/** point, origin of movement relative to map center */
offset?: Point | number[];
/** When set to false, no animation happens */
animate?: boolean;
}
/**
* CameraOptions
*/
export interface CameraOptions {
/** Map center */
center?: mapboxgl.LngLat | number[];
/** Map zoom level */
zoom?: number;
/** Map rotation bearing in degrees counter-clockwise from north */
bearing?: number;
/** Map angle in degrees at which the camera is looking at the ground */
pitch?: number;
/** If zooming, the zoom center (defaults to map center) */
around?: mapboxgl.LngLat | number[];
}
/**
* FlyToOptions
*/
export interface FlyToOptions extends AnimationOptions, CameraOptions {
curve?: number;
minZoom?: number;
speed?: number;
screenSpeed?: number;
easing?: Function;
}
/**
* MapEvent
*/
export interface MapEvent {
webglcontextlost?: {originalEvent: WebGLContextEvent};
webglcontextrestored?: {originalEvent: WebGLContextEvent};
render?: void;
contextmenu?: {data: mapboxgl.MapMouseEvent};
dblclick?: {data: mapboxgl.MapMouseEvent};
click?: {data: mapboxgl.MapMouseEvent};
touchcancel?: {data: mapboxgl.MapTouchEvent};
touchmove?: {data: mapboxgl.MapTouchEvent};
touchend?: {data: mapboxgl.MapTouchEvent};
touchstart?: {data: mapboxgl.MapTouchEvent};
mousemove?: {data: mapboxgl.MapMouseEvent};
mouseup?: {data: mapboxgl.MapMouseEvent};
mousedown?: {data: mapboxgl.MapMouseEvent};
moveend?: {data: mapboxgl.MapMouseEvent | mapboxgl.MapTouchEvent};
move?: {data: mapboxgl.MapMouseEvent | mapboxgl.MapTouchEvent};
movestart?: {data: mapboxgl.MapMouseEvent | mapboxgl.MapTouchEvent};
mouseout?:{data: mapboxgl.MapMouseEvent};
load?: void;
zoomend?: {data: mapboxgl.MapMouseEvent | mapboxgl.MapTouchEvent};
zoom?: {data: mapboxgl.MapMouseEvent | mapboxgl.MapTouchEvent};
zoomstart?: {data: mapboxgl.MapMouseEvent | mapboxgl.MapTouchEvent};
boxzoomcancel?: {data: mapboxgl.MapBoxZoomEvent};
boxzoomstart?: {data: mapboxgl.MapBoxZoomEvent};
boxzoomend?: {data: mapboxgl.MapBoxZoomEvent};
rotate?: {data: mapboxgl.MapMouseEvent | mapboxgl.MapTouchEvent};
rotatestart?: {data: mapboxgl.MapMouseEvent | mapboxgl.MapTouchEvent};
rotateend?: {data: mapboxgl.MapMouseEvent | mapboxgl.MapTouchEvent};
drag?: {data: mapboxgl.MapMouseEvent | mapboxgl.MapTouchEvent};
dragend?: {data: mapboxgl.MapMouseEvent | mapboxgl.MapTouchEvent};
pitch?: {data: mapboxgl.EventData};
}
export interface Layer {
id: string;
type?: "fill" | "line" | "symbol" | "circle" | "raster" | "background" | string; //TODO: Ideally we wouldn't accept string here, just these specific strings
metadata?: any;
ref?: string;
source?: string;
"source-layer"?: string;
minzoom?: number;
maxzoom?: number;
interactive?: boolean;
filter?: any[];
layout?: BackgroundLayout | FillLayout | LineLayout | SymbolLayout | RasterLayout | CircleLayout;
paint?: BackgroundPaint | FillPaint | LinePaint | SymbolPaint | RasterPaint | CirclePaint;
}
export interface StyleFunction {
stops: any[][];
property?: string;
base?: number;
type?: "continuous" | "interval" | "categorical";
}
export interface BackgroundLayout {
visibility?: "visible" | "none";
}
export interface BackgroundPaint {
"background-color"?: string;
"background-pattern"?: string;
"background-opacity"?: number;
}
export interface FillLayout {
visibility?: "visible" | "none";
}
export interface FillPaint {
"fill-antialias"?: boolean;
"fill-opacity"?: number | StyleFunction;
"fill-color"?: string | StyleFunction;
"fill-outline-color": string | StyleFunction;
"fill-translate"?: number[];
"fill-translate-anchor"?: "map" | "viewport";
"fill-pattern"?: "string";
}
export interface LineLayout {
visibility?: "visible" | "none";
"line-cap"?: "butt" | "round" | "square";
"line-join"?: "bevel" | "round" | "miter";
"line-miter-limit"?: number;
"line-round-limit"?: number;
}
export interface LinePaint {
"line-opacity"?: number;
"line-color"?: string| StyleFunction;
"line-translate"?: number[];
"line-translate-anchor"?: "map" | "viewport";
"line-width"?: number;
"line-gap-width"?: number;
"line-offset"?: number;
"line-blur"?: number;
"line-dasharray"?: number[];
"line-dasharray-transition"?: Transition;
"line-pattern"?: string;
}
export interface SymbolLayout {
visibility?: "visible" | "none";
"symbol-placement"?: "point" | "line";
"symbol-spacing"?: number;
"symbol-avoid-edges"?: boolean;
"icon-allow-overlap"?: boolean;
"icon-ignore-placement"?: boolean;
"icon-optional"?: boolean;
"icon-rotation-alignment"?: "map" | "viewport" | "auto";
"icon-size"?: number;
"icon-text-fit"?: "none" | "both" | "width" | "height";
"icon-text-fit-padding"?: number[];
"icon-image"?: string;
"icon-rotate"?: number | StyleFunction;
"icon-padding"?: number;
"icon-keep-upright"?: boolean;
"icon-offset"?: number[];
"text-pitch-alignment"?: "map" | "viewport" | "auto";
"text-rotation-alignment"?: "map" | "viewport" | "auto";
"text-field"?: string;
"text-font"?: string | string[];
"text-size"?: number;
"text-max-width"?: number;
"text-line-height"?: number;
"text-letter-spacing"?: number;
"text-justify"?: "left" | "center" | "right";
"text-anchor"?: "center" | "left" | "right" | "top" | "bottom" | "top-left" | "top-right" | "bottom-left" | "bottom-right";
"text-max-angle"?: number;
"text-rotate"?: number;
"text-padding"?: number;
"text-keep-upright"?: boolean;
"text-transform"?: "none" | "uppercase" | "lowercase";
"text-offset"?: number[];
"text-allow-overlap"?: boolean;
"text-ignore-placement"?: boolean;
"text-optional"?: boolean;
}
export interface SymbolPaint {
"icon-opacity"?: number;
"icon-color"?: string;
"icon-halo-color"?: string;
"icon-halo-width"?: number;
"icon-halo-blur"?: number;
"icon-translate"?: number[];
"icon-translate-anchor"?: "map" | "viewport";
"text-opacity"?: number;
"text-color"?: "string";
"text-halo-color"?: "string";
"text-halo-width"?: number;
"text-halo-blur"?: number;
"text-translate"?: number[];
"text-translate-anchor"?: "map" | "viewport";
}
export interface RasterLayout {
visibility?: "visible" | "none";
}
export interface RasterPaint {
"raster-opacity"?: number;
"raster-hue-rotate"?: number;
"raster-brightness-min"?: number;
"raster-brightness-max"?: number;
"raster-saturation"?: number;
"raster-contrast"?: number;
"raster-fade-duration"?: number;
}
export interface CircleLayout {
visibility?: "visible" | "none";
}
export interface CirclePaint {
"circle-radius"?: number | StyleFunction;
"circle-radius-transition"?: Transition;
"circle-color"?: number | StyleFunction;
"circle-blur"?: number | StyleFunction;
"circle-opacity"?: number | StyleFunction;
"circle-translate"?: number[];
"circle-translate-anchor"?: "map" | "viewport";
"circle-pitch-scale"?: "map" | "viewport";
}
}
declare module 'mapbox-gl' {
export = mapboxgl;
}
+1
View File
@@ -961,6 +961,7 @@ schematype.unique(true).unique(true);
schematype.validate(/re/)
.validate({}, 'error')
.validate(cb, 'try', 'tri');
schematype.options.required;
/*
* section promise.js
+6
View File
@@ -2011,6 +2011,12 @@ declare module "mongoose" {
*/
validate(obj: RegExp | Function | Object, errorMsg?: string,
type?: string): this;
/**
* http://mongoosejs.com/docs/api.html#schematype_SchemaType
* Options for this schema type (required, index, etc.)
*/
options: any;
}
/*
+1 -1
View File
@@ -11,7 +11,7 @@ angular.module('app', ['oc.lazyLoad']).config(['$ocLazyLoadProvider', function (
})
}]);
angular.module('app').controller(['$ocLazyLoadProvider', function ($ocLazyLoad: oc.ILazyLoad) {
angular.module('app').controller('FooCtrl', ['$ocLazyLoad', function ($ocLazyLoad: oc.ILazyLoad) {
$ocLazyLoad.load('testModule.js');
$ocLazyLoad.load(['testModule.js', 'testModuleCtrl.js', 'testModuleService.js']);
+4 -3
View File
@@ -127,15 +127,16 @@ declare namespace polymer {
unlinkPaths?(path: string): void;
push?(path: string): number;
push?(path: string, ...item: any[]): number;
pop?(path: string): any;
splice?(path: string, start: number, deleteCount: number): number;
splice?(path: string, index: number, removeCount: number, ...item: any[]):
number;
shift?(path: string): any;
unshift?(path: string): number;
unshift?(path: string, ...item: any[]): number;
// ResolveUrl
+17
View File
@@ -38,6 +38,23 @@ namespace PouchDBCoreTests {
});
}
function testBulkDocs() {
const db = new PouchDB<MyModel>();
type MyModel = { property: 'someProperty '};
let model: PouchDB.Core.Document<MyModel>;
let model2: PouchDB.Core.Document<MyModel>;
db.bulkDocs([model, model2]).then((result) => {
result.forEach(({ ok, id, rev }) => {
isString(id);
isString(rev);
});
});
db.bulkDocs([model, model2], null, (error, response) => {
});
}
function testCompact() {
const db = new PouchDB<{}>();
// Promise version
+6
View File
@@ -268,6 +268,12 @@ declare namespace PouchDB {
allDocs(options?: Core.AllDocsOptions):
Promise<Core.AllDocsResponse<Content>>;
bulkDocs(docs: Core.Document<Content>[],
options: Core.PutOptions | void,
callback: Core.Callback<Core.Error, Core.Response[]>): void;
bulkDocs(docs: Core.Document<Content>[],
options?: Core.PutOptions): Promise<Core.Response[]>;
/** Compact the database */
compact(options?: Core.CompactOptions): Promise<Core.Response>;
compact(options: Core.CompactOptions,
+62
View File
@@ -0,0 +1,62 @@
/// <reference path="rrule.d.ts" />
import * as RRule from 'rrule';
// Create a rule:
let rule: RRule = new RRule({
freq: RRule.WEEKLY,
interval: 5,
byweekday: [RRule.MO, RRule.FR],
dtstart: new Date(2012, 1, 1, 10, 30),
until: new Date(2012, 12, 31)
});
let x: Date[];
let y: string[];
// Get all occurrence dates (Date instances):
x = rule.all();
// Get a slice:
x = rule.between(new Date(2012, 7, 1), new Date(2012, 8, 1))
// Get an iCalendar RRULE string representation:
// The output can be used with RRule.fromString().
y.push(rule.toString());
// Get a human-friendly text representation:
// The output can be used with RRule.fromText().
y.push(rule.toText());
// Get full a string representation of all options,
// including the default and inferred ones.
y.push(RRule.optionsToString(rule.options))
// Cherry-pick only some options from an rrule:
y.push(RRule.optionsToString({
freq: rule.options.freq,
dtstart: rule.options.dtstart,
}))
rule = RRule.fromString("FREQ=WEEKLY;DTSTART=20120201T093000Z")
// This is equivalent
rule = new RRule(RRule.parseString("FREQ=WEEKLY;DTSTART=20120201T093000Z"))
var options = RRule.parseString('FREQ=DAILY;INTERVAL=6')
options.dtstart = new Date(2000, 1, 1)
rule = new RRule(options)
rule = new RRule({
freq: RRule.WEEKLY,
count: 23
})
y.push(rule.toText())
rule = RRule.fromText('every day for 3 times')
options = RRule.parseText('every day for 3 times')
// {freq: 3, count: "3"}
options.dtstart = new Date(2000, 1, 1)
rule = new RRule(options)
+161
View File
@@ -0,0 +1,161 @@
// Type definitions for rrule 2.1.0
// Project: https://github.com/jkbrzt/rrule
// Definitions by: James Bracy <https://github.com/waratuman>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare module 'rrule' {
export = RRule;
}
declare namespace RRule {
/**
* see <http://labix.org/python-dateutil/#head-cf004ee9a75592797e076752b2a889c10f445418>
* The only required option is `freq`, one of RRule.YEARLY, RRule.MONTHLY, ...
*/
interface Options {
freq: RRule.Frequency;
dtstart?: Date;
interval?: number;
wkst?: number | Weekday
count?: number;
until?: Date;
bysetpos?: number;
bymonth?: number;
bymonthday?: number;
byyearday?: number;
byweekno?: number;
byweekday?: Weekday[];
byhour?: number;
byminute?: number;
bysecond?: number;
}
class Weekday {
constructor(weekday: number, n: number);
nth(n: number): Weekday;
equals(other: Weekday): boolean;
toString(): string;
getJsWeekday(): number;
}
}
declare class RRule {
/**
* @param {Object?} options - see <http://labix.org/python-dateutil/#head-cf004ee9a75592797e076752b2a889c10f445418>
* The only required option is `freq`, one of RRule.YEARLY, RRule.MONTHLY, ...
* @constructor
*/
constructor(options: RRule.Options, noCache?: boolean);
options: RRule.Options;
origOptions: RRule.Options;
/**
* Returns the first recurrence after the given datetime instance.
* The inc keyword defines what happens if dt is an occurrence.
* With inc == True, if dt itself is an occurrence, it will be returned.
* @return Date or null
*/
after(dt: Date, inc?: boolean): Date;
/**
* @param {Function} iterator - optional function that will be called
* on each date that is added. It can return false
* to stop the iteration.
* @return Array containing all recurrences.
*/
all(iterator?: (date: Date) => void): Date[];
/**
* Returns all the occurrences of the rrule between after and before.
* The inc keyword defines what happens if after and/or before are
* themselves occurrences. With inc == True, they will be included in the
* list, if they are found in the recurrence set.
* @return Array
*/
between(a: Date, b: Date, iterator?: (date: Date) => void): Date[];
/**
* Returns the last recurrence before the given datetime instance.
* The inc keyword defines what happens if dt is an occurrence.
* With inc == True, if dt itself is an occurrence, it will be returned.
* @return Date or null
*/
before(dt: Date, inc?: boolean): Date;
/**
* Returns the number of recurrences in this set. It will have go trough
* the whole recurrence, if this hasn't been done before.
*/
count(): number;
/**
* Converts the rrule into its string representation
* @see <http://www.ietf.org/rfc/rfc2445.txt>
* @return String
*/
toString(): string;
/**
* Will convert all rules described in nlp:ToText
* to text.
*/
toText(gettext?: (str: string) => string, language?: any): string;
isFullyConvertibleToText(): boolean;
clone(): RRule;
}
declare namespace RRule {
const FREQUENCIES: "YEARLY" | "MONTHLY" | "WEEKLY" | "DAILY" | "HOURLY" | "MINUTELY" | "SECONDLY";
enum Frequency {
YEARLY = 0,
MONTHLY = 1,
WEEKLY = 2,
DAILY = 3,
HOURLY = 4,
MINUTELY = 5,
SECONDLY = 6
}
const YEARLY: Frequency;
const MONTHLY: Frequency;
const WEEKLY: Frequency;
const DAILY: Frequency;
const HOURLY: Frequency;
const MINUTELY: Frequency;
const SECONDLY: Frequency;
const MO: Weekday;
const TU: Weekday;
const WE: Weekday;
const TH: Weekday;
const FR: Weekday;
const SA: Weekday;
const SU: Weekday;
const DEFAULT_OPTIONS: RRule.Options;
function parseText(text: string, language?: any): RRule.Options;
function fromText(text: string, language?: any): RRule;
function optionsToString(options: RRule.Options): string;
function parseString(rfcString: string): RRule.Options;
function fromString(value: string): RRule;
}
Vendored
+4 -4
View File
@@ -22,7 +22,7 @@ declare module "ws" {
protocolVersion: string;
url: string;
supports: any;
upgradeReq: http.ServerRequest;
upgradeReq: http.IncomingMessage;
protocol: string;
CONNECTING: number;
@@ -77,8 +77,8 @@ declare module "ws" {
namespace WebSocket {
type VerifyClientCallbackSync = (info: {origin: string; secure: boolean; req: http.ServerRequest}) => boolean;
type VerifyClientCallbackAsync = (info: {origin: string; secure: boolean; req: http.ServerRequest}
type VerifyClientCallbackSync = (info: {origin: string; secure: boolean; req: http.IncomingMessage}) => boolean;
type VerifyClientCallbackAsync = (info: {origin: string; secure: boolean; req: http.IncomingMessage}
, callback: (res: boolean) => void) => void;
export interface IClientOptions {
@@ -117,7 +117,7 @@ declare module "ws" {
constructor(options?: IServerOptions, callback?: Function);
close(cb?: () => {}): void;
handleUpgrade(request: http.ServerRequest, socket: net.Socket,
handleUpgrade(request: http.IncomingMessage, socket: net.Socket,
upgradeHead: Buffer, callback: (client: WebSocket) => void): void;
// Events
+2590
View File
File diff suppressed because it is too large Load Diff
+137
View File
@@ -0,0 +1,137 @@
/// <reference path="xrm.d.ts" />
/// <reference path="parature.d.ts" />
/// Demonstrate usage in the browser's window object
window.Xrm.Utility.alertDialog( "message", () => {} );
parent.Xrm.Page.context.getOrgLcid();
/// Demonstrate clientglobalcontext.d.ts
function _getContext()
{
var errorMessage = "Context is not available.";
if ( typeof GetGlobalContext != "undefined" )
{ return GetGlobalContext(); }
else
{
if ( typeof Xrm != "undefined" )
{
return Xrm.Page.context;
}
else { throw new Error( errorMessage ); }
}
}
var crmContext = _getContext();
/// Demonstrate iterator typing
var grids = Xrm.Page.getControl(( control ) =>
{
return control.getControlType() === "subgrid";
});
var selectedGridReferences: Xrm.Page.LookupValue[] = [];
/// Demonstrate iterator typing with v7.1 additions
grids.forEach(( gridControl: Xrm.Page.GridControl ) =>
{
gridControl.getGrid().getSelectedRows().forEach(( row ) =>
{
selectedGridReferences.push( row.getData().getEntity().getEntityReference() );
})
});
/// Demonstrate generic overload vs typecast
var lookupAttribute = <Xrm.Page.LookupControl>Xrm.Page.getControl( "customerid" );
var lookupAttribute2 = Xrm.Page.getControl<Xrm.Page.LookupControl>( "customerid" );
/// Demonstrate ES6 String literal syntax
lookupAttribute.addCustomFilter( `<filter type="and">
<condition attribute="address1_city" operator="eq" value="Redmond" />
</filter>`, "account" );
lookupAttribute.addPreSearch(() => { alert( "A search was performed." ); });
/// Demonstrate strong-typed attribute association with strong-typed control
var lookupValues = lookupAttribute.getAttribute().getValue();
if ( lookupValues !== null )
if ( !lookupValues[0].id || !lookupValues[0].entityType )
throw new Error("Invalid value in Lookup control.");
/// Demonstrate v7.0 BPF API
if (Xrm.Page.data.process != null)
Xrm.Page.data.process.moveNext(( status ) => { alert( `Process moved forward with status: ${status}` ) });
/// Demonstrate v7.1 Quick Create form
Xrm.Utility.openQuickCreate(( newRecord ) => { alert( `Newly created record Id: ${newRecord.id}` ); }, "account" );
/// Make all controls visible.
Xrm.Page.ui.controls.forEach(( control ) => { control.setVisible( true ); });
/// Make all tabs and sections visible.
Xrm.Page.ui.tabs.forEach(( tab ) =>
{
tab.setVisible( true );
tab.sections.forEach(( section ) =>
{
section.setVisible( true );
});
});
/// Demonstrate OnSave event context.
Xrm.Page.data.entity.addOnSave(( context ) =>
{
var eventArgs = context.getEventArgs();
if ( eventArgs.getSaveMode() === XrmEnum.SaveMode.AutoSave || eventArgs.getSaveMode() === XrmEnum.SaveMode.SaveAndClose )
eventArgs.preventDefault();
});
/// Demonstrate ES6 String literal with templates
alert( `The current form type is: ${Xrm.Page.ui.getFormType() }` );
alert( `The current entity type is: ${Xrm.Page.data.entity.getEntityName() }` );
/// Demonstrate Optionset Value as int in Turbo Forms
var optionSetAttribute = Xrm.Page.getAttribute<Xrm.Page.OptionSetAttribute>( "statuscode" );
const optionValue: number = optionSetAttribute.getOptions()[0].value;
/// Demonstrate Control.setFocus();
optionSetAttribute.controls.get(0).setFocus();
/// Demonstrate setFormNotification
var level: Xrm.Page.ui.FormNotificationLevel;
level = "ERROR";
Xrm.Page.ui.setFormNotification("Test", level, "uniqueId");
/// Demonstrate Requirement Level and Submit Mode both via string parameters and String Literal Types
let requirementLevel: Xrm.Page.RequirementLevel = "none";
let requirementLevelString = "none";
let submitMode: Xrm.Page.SubmitMode = "always";
let submitModeString = "always";
let attribute = Xrm.Page.getAttribute<Xrm.Page.LookupAttribute>("customerid");
attribute.setSubmitMode(submitMode);
attribute.setSubmitMode(submitMode);
attribute.setRequiredLevel(requirementLevel);
attribute.setRequiredLevel(requirementLevelString);
+35
View File
@@ -133,3 +133,38 @@ attribute.setSubmitMode(submitMode);
attribute.setSubmitMode(submitMode);
attribute.setRequiredLevel(requirementLevel);
attribute.setRequiredLevel(requirementLevelString);
/// Demonstrate v8 AutoComplete
let autoCompleteControl = Xrm.Page.getControl<Xrm.Page.AutoLookupControl>("name");
var userInput = autoCompleteControl.getValue();
const accountResult = { };
const resultSet: Xrm.Page.AutoCompleteResultSet = {
results: new Array() as Xrm.Page.AutoCompleteResult[],
commands: {
id: "sp_commands",
label: "Learn More",
action() {
// Specify what you want to do when the user
// clicks the "Learn More" link at the bottom
// of the auto-completion list.
// For this sample, we are just opening a page
// that provides information on working with
// accounts in CRM.
window.open("http://www.microsoft.com/en-us/dynamics/crm-customer-center/create-or-edit-an-account.aspx");
}
} as Xrm.Page.AutoCompleteCommand
};
resultSet.results.push({
id: 0,
fields: ["A. Datum Corporation"]
});
autoCompleteControl.addOnKeyPress(() => { });
autoCompleteControl.fireOnKeyPress();
autoCompleteControl.removeOnKeyPress(() => {});
autoCompleteControl.showAutoComplete(resultSet);
autoCompleteControl.hideAutoComplete();
+111 -1
View File
@@ -1,4 +1,4 @@
// Type definitions for Microsoft Dynamics xRM API v7.1
// Type definitions for Microsoft Dynamics xRM API v8.0
// Project: http://www.microsoft.com/en-us/download/details.aspx?id=44567
// Definitions by: David Berry <https://github.com/6ix4our/>, Matt Ngan <https://github.com/mattngan/>, Markus Mauch <https://github.com/markusmauch/>, Daryl LaBar <https://github.com/daryllabar>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@@ -865,6 +865,66 @@ declare namespace Xrm
setFocus(): void;
}
/**
* Interface for Result value of AutoCompleteResultSet
*/
export interface AutoCompleteResult {
/**
* The Identifier
*/
id: string|number;
/**
* Url of the icon to display
*/
icon?: string;
/**
* Display value(s) for this auto-complete option
*/
fields: string[];
}
/**
* Interface for command of AutoCompleteResultSet. This is displayed at the bottom of the auto complete view
*/
export interface AutoCompleteCommand {
/**
* The Identifier
*/
id: string;
/**
* Url of the icon to display
*/
icon?: string;
/**
* Label to display at the bottom of the auto complete view
*/
label: string;
/**
* Action to perform when user clicks on label
*/
action(): void;
}
/**
* Interface for showAutoComplete argument
*/
export interface AutoCompleteResultSet {
/**
* Results to show
*/
results: AutoCompleteResult[];
/**
* Command to show/execute at the bottom of the results displayed
*/
commands?: AutoCompleteCommand;
}
/**
* Interface for a Lookup value.
*/
@@ -1682,6 +1742,56 @@ declare namespace Xrm
getAttribute(): Attribute;
}
/**
* Interace for Auto Lookup Control
* This is not an Entity Lookup, but a control that supports AutoComplete/KeyPress Events (Text)
* NOTE * This interface is not supported for CRM mobile clients (phones or tablets) and the interactive service hub. It is only available for Updated entities.
*
* @sa StandardControl
*/
export interface AutoLookupControl extends StandardControl {
/**
* Use this to add a function as an event handler for the keypress event so that the function is called when you type a character in the specific text or number field.
* For a sample JavaScript code that uses the addOnKeyPress method to configure the auto-completion experience, see Sample: Auto-complete in CRM controls.
*
* @param {ContextSensitiveHandler} handler The function reference.
*/
addOnKeyPress(handler: ContextSensitiveHandler): void;
/**
* Use this to manually fire an event handler that you created for a specific text or number field to be executed on the keypress event.
*/
fireOnKeyPress(): void;
/**
* Gets the latest value in a control as the user types characters in a specific text or number field.
* This method helps you to build interactive experiences by validating data and alerting users as they type characters in a control.
* The getValue method is different from the attribute getValue method because the control method retrieves the value from the control
* as the user is typing in the control as opposed to the attribute getValue method that retrieves the value after the user commits (saves) the field.
*/
getValue(): string;
/**
* Hides the auto-completion drop-down list configured for a specific text field
*/
hideAutoComplete(): void;
/**
* Use this to remove an event handler for a text or number field that you added using addOnKeyPress.
*
* Remarks: If an anonymous function is set using addOnKeyPress, it can’t be removed using this method.
* @param {ContextSensitiveHandler} handler The function reference.
*/
removeOnKeyPress(handler: ContextSensitiveHandler): void;
/**
* Shows upt to 10 matching strings in a drop-down list as users press keys to type charactrer in a specific text field.
* On selecting an item in the drop-down list, the value in the text field changes to the selected item, the drop-down list disappears, and the OnChange event for the text field is invoked
* @param resultSet
*/
showAutoComplete(resultSet: AutoCompleteResultSet): void;
}
/**
* Interface for a Date control.
*