Merge remote-tracking branch 'upstream/master'

This commit is contained in:
marc
2016-06-23 13:02:50 -05:00
36 changed files with 3359 additions and 425 deletions
+2 -2
View File
@@ -43,7 +43,7 @@ declare namespace angular.animate {
* @param container the container element that will capture each of the animation events that are fired on itself as well as among its children
* @param callback the callback function that will be fired when the listener is triggered
*/
on(event: string, container: JQuery, callback: Function): void;
on(event: string, container: JQuery, callback: (element?: JQuery, phase?: string) => any): void;
/**
* Deregisters an event listener based on the event which has been associated with the provided element.
@@ -52,7 +52,7 @@ declare namespace angular.animate {
* @param container the container element the event listener was placed on
* @param callback the callback function that was registered as the listener
*/
off(event: string, container?: JQuery, callback?: Function): void;
off(event: string, container?: JQuery, callback?: (element?: JQuery, phase?: string) => any): void;
/**
* Associates the provided element with a host parent element to allow the element to be animated even if it exists outside of the DOM structure of the Angular application.
-2
View File
@@ -147,7 +147,6 @@ declare namespace Backbone {
/*private*/ set(attributeName: string, value: any, options?: ModelSetOptions): Model;
set(obj: any, options?: ModelSetOptions): Model;
change(): any;
changedAttributes(attributes?: any): any[];
clear(options?: Silenceable): any;
clone(): Model;
@@ -388,7 +387,6 @@ declare namespace Backbone {
$(selector: any): JQuery;
render(): View<TModel>;
remove(): View<TModel>;
make(tagName: any, attributes?: any, content?: any): any;
delegateEvents(events?: EventsHash): any;
delegate(eventName: string, selector: string, listener: Function): View<TModel>;
undelegateEvents(): any;
File diff suppressed because it is too large Load Diff
+5 -3
View File
@@ -39,7 +39,7 @@ interface HammerStatic
DIRECTION_VERTICAL: number;
DIRECTION_ALL: number;
Manager: HammerManager;
Manager: HammerManagerConstructor;
Input: HammerInput;
TouchAction: TouchAction;
@@ -95,10 +95,12 @@ interface HammerOptions extends HammerDefaults
}
interface HammerManagerConstructor {
new( element:HTMLElement, options?:any ):HammerManager;
}
interface HammerManager
{
new( element:HTMLElement, options?:any ):HammerManager;
add( recogniser:Recognizer ):Recognizer;
add( recogniser:Recognizer ):HammerManager;
add( recogniser:Recognizer[] ):Recognizer;
@@ -0,0 +1,159 @@
/// <reference path="./inversify-binding-decorators.d.ts" />
import { inject, Kernel } from "inversify";
import { autoProvide, makeProvideDecorator, makeFluentProvideDecorator } from "inversify-binding-decorators";
module decorator {
let kernel = new Kernel();
let provide = makeProvideDecorator(kernel);
interface INinja {
fight(): string;
sneak(): string;
}
interface IKatana {
hit(): string;
}
interface IShuriken {
throw(): string;
}
let TYPE = {
IKatana: "IKatana",
INinja: "INinja",
IShuriken: "IShuriken"
};
@provide(TYPE.IKatana)
class Katana implements IKatana {
public hit() {
return "cut!";
}
}
@provide(TYPE.IShuriken)
class Shuriken implements IShuriken {
public throw() {
return "hit!";
}
}
@provide(TYPE.INinja)
class Ninja implements INinja {
private _katana: IKatana;
private _shuriken: IShuriken;
public constructor(
@inject("IKatana") katana: IKatana,
@inject("IShuriken") shuriken: IShuriken
) {
this._katana = katana;
this._shuriken = shuriken;
}
public fight() { return this._katana.hit(); };
public sneak() { return this._shuriken.throw(); };
}
let ninja = kernel.get<INinja>(TYPE.INinja);
console.log(ninja);
}
module fluent_decorator {
let kernel = new Kernel();
let provide = makeFluentProvideDecorator(kernel);
let provideSingleton = function(identifier: string) {
return provide(identifier).inSingletonScope().done();
};
let provideTransient = function(identifier: string) {
return provide(identifier).done();
};
interface INinja {
fight(): string;
sneak(): string;
}
interface IKatana {
hit(): string;
}
interface IShuriken {
throw(): string;
}
let TYPE = {
IKatana: "IKatana",
INinja: "INinja",
IShuriken: "IShuriken"
};
@provideSingleton(TYPE.IKatana)
class Katana implements IKatana {
private _mark: any;
public constructor() {
this._mark = Math.random();
}
public hit() {
return "cut! " + this._mark;
}
}
@provideTransient(TYPE.IShuriken)
class Shuriken implements IShuriken {
private _mark: any;
public constructor() {
this._mark = Math.random();
}
public throw() {
return "hit! " + this._mark;
}
}
@provideTransient(TYPE.INinja)
class Ninja implements INinja {
private _katana: IKatana;
private _shuriken: IShuriken;
public constructor(
@inject("IKatana") katana: IKatana,
@inject("IShuriken") shuriken: IShuriken
) {
this._katana = katana;
this._shuriken = shuriken;
}
public fight() { return this._katana.hit(); };
public sneak() { return this._shuriken.throw(); };
}
let ninja = kernel.get<INinja>(TYPE.INinja);
console.log(ninja);
}
module auto_provide {
let warriors = {
Ninja: class Ninja {},
Samurai: class Samurai {}
};
let weapons = {
Katana: class Katana {},
Shuriken: class Shuriken {},
};
let kernel = new Kernel();
autoProvide(kernel, warriors, weapons);
}
@@ -0,0 +1,55 @@
// Type definitions for inversify 1.0.0-beta.5
// Project: https://github.com/inversify/inversify-binding-decorators
// Definitions by: inversify <https://github.com/inversify/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../inversify/inversify.d.ts" />
declare namespace inversifyBindingDecorators {
interface IProvideInSyntax<T> extends IProvideDoneSyntax<T> {
inSingletonScope(): IProvideWhenOnSyntax<T>;
}
interface IProvideDoneSyntax<T> {
done(): (target: any) => any;
}
interface IProvideOnSyntax<T> extends IProvideDoneSyntax<T> {
onActivation(fn: (context: inversify.interfaces.Context, injectable: T) => T): IProvideWhenSyntax<T>;
}
interface IProvideInWhenOnSyntax<T> extends IProvideInSyntax<T>, IProvideWhenSyntax<T>, IProvideOnSyntax<T> {}
interface IProvideWhenOnSyntax<T> extends IProvideWhenSyntax<T>, IProvideOnSyntax<T> {}
interface IProvideWhenSyntax<T> extends IProvideDoneSyntax<T> {
when(constraint: (request: inversify.interfaces.Request) => boolean): IProvideOnSyntax<T>;
whenTargetNamed(name: string): IProvideOnSyntax<T>;
whenTargetTagged(tag: string, value: any): IProvideOnSyntax<T>;
whenInjectedInto(parent: (Function|string)): IProvideOnSyntax<T>;
whenParentNamed(name: string): IProvideOnSyntax<T>;
whenParentTagged(tag: string, value: any): IProvideOnSyntax<T>;
whenAnyAncestorIs(ancestor: (Function|string)): IProvideOnSyntax<T>;
whenNoAncestorIs(ancestor: (Function|string)): IProvideOnSyntax<T>;
whenAnyAncestorNamed(name: string): IProvideOnSyntax<T>;
whenAnyAncestorTagged(tag: string, value: any): IProvideOnSyntax<T>;
whenNoAncestorNamed(name: string): IProvideOnSyntax<T>;
whenNoAncestorTagged(tag: string, value: any): IProvideOnSyntax<T>;
whenAnyAncestorMatches(constraint: (request: inversify.interfaces.Request) => boolean): IProvideOnSyntax<T>;
whenNoAncestorMatches(constraint: (request: inversify.interfaces.Request) => boolean): IProvideOnSyntax<T>;
}
export function autoProvide(kernel: inversify.interfaces.Kernel, ...modules: any[]): void;
export function makeProvideDecorator(kernel: inversify.interfaces.Kernel):
(serviceIdentifier: (string|Symbol|inversify.interfaces.Newable<any>)) => (target: any) => any;
export function makeFluentProvideDecorator(kernel: inversify.interfaces.Kernel):
(serviceIdentifier: (string|Symbol|inversify.interfaces.Newable<any>)) => IProvideInWhenOnSyntax<any>;
}
declare module "inversify-binding-decorators" {
export = inversifyBindingDecorators;
}
@@ -0,0 +1,89 @@
/// <reference path="./inversify-express-utils.d.ts" />
import { InversifyExpressServer, Controller, Get, All, Delete, Head, Put, Patch, Post, Method } from "inversify-express-utils";
import * as express from "express";
import { Kernel } from "inversify";
module server {
let kernel = new Kernel();
let server = new InversifyExpressServer(kernel);
server
.setConfig((app) => {
app.use((req: express.Request, res: express.Response, next: express.NextFunction) => {
console.log("hello world");
next();
});
})
.setErrorConfig((app) => {
app.use((err: any, req: express.Request, res: express.Response, next: express.NextFunction) => {
console.error(err.stack);
res.status(500).send("Something broke!");
});
})
.build()
.listen(3000, "localhost");
}
module decorators {
@Controller("/")
class TestController {
@Get("/")
public testGet() { return "GET"; }
@All("/")
public testAll() { return "ALL"; }
@Delete("/")
public testDelete() { return "DELETE"; }
@Head("/")
public testHead() { return "HEAD"; }
@Put("/")
public testPut() { return "PUT"; }
@Patch("/")
public testPatch() { return "PATCH"; }
@Post("/")
public testPost() { return "POST"; }
@Method("foo", "/")
public testMethod() { return "METHOD:FOO"; }
}
function m1(req: express.Request, res: express.Response, next: express.NextFunction) { next(); }
function m2(req: express.Request, res: express.Response, next: express.NextFunction) { next(); }
function m3(req: express.Request, res: express.Response, next: express.NextFunction) { next(); }
@Controller("/", m1, m2, m3)
class TestMiddlewareController {
@Get("/", m1, m2, m3)
public testGet() { return "GET"; }
@All("/", m1, m2, m3)
public testAll() { return "ALL"; }
@Delete("/", m1, m2, m3)
public testDelete() { return "DELETE"; }
@Head("/", m1, m2, m3)
public testHead() { return "HEAD"; }
@Put("/", m1, m2, m3)
public testPut() { return "PUT"; }
@Patch("/", m1, m2, m3)
public testPatch() { return "PATCH"; }
@Post("/", m1, m2, m3)
public testPost() { return "POST"; }
@Method("foo", "/", m1, m2, m3)
public testMethod() { return "METHOD:FOO"; }
}
}
+50
View File
@@ -0,0 +1,50 @@
// Type definitions for inversify 1.0.0-alpha.4
// Project: https://github.com/inversify/inversify-express-utils
// Definitions by: inversify <https://github.com/inversify/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../inversify/inversify.d.ts" />
/// <reference path="../express/express.d.ts" />
declare module "inversify-express-utils" {
import * as express from "express";
import * as inversify from "inversify";
interface IInversifyExpressServerConstructor {
new(kernel: inversify.interfaces.Kernel): IInversifyExpressServer;
}
interface IInversifyExpressServer {
setConfig(fn: IConfigFunction): IInversifyExpressServer;
setErrorConfig(fn: IConfigFunction): IInversifyExpressServer;
build(): express.Application;
}
interface IConfigFunction {
(app: express.Application): void;
}
interface IHandlerDecoratorFactory {
(path: string, ...middleware: express.RequestHandler[]): IHandlerDecorator;
}
interface IHandlerDecorator {
(target: any, key: string, value: any): void;
}
export interface IController {}
export var InversifyExpressServer: IInversifyExpressServerConstructor;
export var Controller: (path: string, ...middleware: express.RequestHandler[]) => (target: any) => void;
export var All: IHandlerDecoratorFactory;
export var Get: IHandlerDecoratorFactory;
export var Post: IHandlerDecoratorFactory;
export var Put: IHandlerDecoratorFactory;
export var Patch: IHandlerDecoratorFactory;
export var Head: IHandlerDecoratorFactory;
export var Delete: IHandlerDecoratorFactory;
export var Method: (method: string, path: string, ...middleware: express.RequestHandler[]) => IHandlerDecorator;
}
@@ -0,0 +1,59 @@
/// <reference path="./inversify-logger-middleware.d.ts" />
declare var kernel: inversify.interfaces.Kernel;
import { makeLoggerMiddleware, textSerializer } from "inversify-logger-middleware";
interface ILoggerOutput<T> {
entry: T;
}
let makeStringRenderer = function (loggerOutput: ILoggerOutput<string>) {
return function (entry: inversifyLoggerMiddleware.ILogEntry) {
loggerOutput.entry = textSerializer(entry);
};
};
let makeObjRenderer = function (loggerOutput: ILoggerOutput<any>) {
return function (entry: inversifyLoggerMiddleware.ILogEntry) {
loggerOutput.entry = entry;
};
};
let options: inversifyLoggerMiddleware.ILoggerSettings = {
request: {
bindings: {
activated: true,
cache: true,
constraint: true,
dynamicValue: true,
factory: true,
implementationType: true,
onActivation: true,
provider: true,
scope: true,
serviceIdentifier: true,
type: true
},
serviceIdentifier: true,
target: {
metadata: true,
name: true,
serviceIdentifier: true
}
},
time: true
};
let logger = makeLoggerMiddleware();
kernel.applyMiddleware(logger);
let loggerOutput1: ILoggerOutput<string> = { entry: null };
let stringRenderer1 = makeStringRenderer(loggerOutput1);
let logger1 = makeLoggerMiddleware(options, stringRenderer1);
kernel.applyMiddleware(logger1);
let loggerOutput2: ILoggerOutput<inversifyLoggerMiddleware.ILogEntry> = { entry: null };
let objRenderer2 = makeObjRenderer(loggerOutput2);
let logger2 = makeLoggerMiddleware(options, objRenderer2);
kernel.applyMiddleware(logger2);
@@ -0,0 +1,59 @@
// Type definitions for inversify 1.0.0-beta.6
// Project: https://github.com/inversify/inversify-logger-middleware
// Definitions by: inversify <https://github.com/inversify/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../inversify/inversify.d.ts"/>
declare namespace inversifyLoggerMiddleware {
export interface ILoggerSettings {
request?: IRequestLoggerSettings;
time?: boolean;
}
export interface IRequestLoggerSettings {
serviceIdentifier?: boolean;
bindings?: IBindingLoggerSettings;
target?: ITargetLoggerSettings;
}
export interface IBindingLoggerSettings {
activated?: boolean;
serviceIdentifier?: boolean;
implementationType?: boolean;
factory?: boolean;
provider?: boolean;
constraint?: boolean;
onActivation?: boolean;
cache?: boolean;
dynamicValue?: boolean;
scope?: boolean;
type?: boolean;
}
export interface ITargetLoggerSettings {
serviceIdentifier?: boolean;
name?: boolean;
metadata?: boolean;
}
export interface ILogEntry {
error: boolean;
exception: any;
multiInject: boolean;
results: any[];
rootRequest: inversify.interfaces.Request;
serviceIdentifier: any;
target: any;
time: string;
}
export function makeLoggerMiddleware(settings?: ILoggerSettings, renderer?: (out: ILogEntry) => void): inversify.interfaces.Middleware;
export function textSerializer(entry: ILogEntry): string;
}
declare module "inversify-logger-middleware" {
export = inversifyLoggerMiddleware;
}
+335 -85
View File
@@ -1,39 +1,65 @@
/// <reference path="inversify.d.ts" />
/// <reference path="./inversify.d.ts" />
/// <reference path="../harmony-proxy/harmony-proxy.d.ts" />
namespace global_module_test {
let injectable = inversify.injectable;
let inject = inversify.inject;
let tagged = inversify.tagged;
let named = inversify.named;
let Kernel = inversify.Kernel;
let KernelModule = inversify.KernelModule;
let targetName = inversify.targetName;
let multiInject = inversify.multiInject;
let traverseAncerstors = inversify.traverseAncerstors;
let taggedConstraint = inversify.taggedConstraint;
let namedConstraint = inversify.namedConstraint;
let typeConstraint = inversify.typeConstraint;
let makePropertyMultiInjectDecorator = inversify.makePropertyMultiInjectDecorator;
let makePropertyInjectTaggedDecorator = inversify.makePropertyInjectTaggedDecorator;
let makePropertyInjectNamedDecorator = inversify.makePropertyInjectNamedDecorator;
let makePropertyInjectDecorator = inversify.makePropertyInjectDecorator;
interface INinja {
module external_module_test {
interface Warrior {
fight(): string;
sneak(): string;
}
interface IKatana {
interface Weapon {
hit(): string;
}
interface IShuriken {
interface ThrowableWeapon extends Weapon {
throw(): string;
}
class Katana implements IKatana {
@injectable()
class Katana implements Weapon {
public hit() {
return "cut!";
}
}
class Shuriken implements IShuriken {
@injectable()
class Shuriken implements ThrowableWeapon {
public throw() {
return "hit!";
}
public hit() {
return "hit!";
}
}
@inversify.inject("IKatana", "IShuriken")
class Ninja implements INinja {
@injectable()
class Ninja implements Warrior {
private _katana: IKatana;
private _shuriken: IShuriken;
private _katana: Weapon;
private _shuriken: ThrowableWeapon;
public constructor(katana: IKatana, shuriken: IShuriken) {
public constructor(
@inject("Weapon") katana: Weapon,
@inject("ThrowableWeapon") shuriken: ThrowableWeapon
) {
this._katana = katana;
this._shuriken = shuriken;
}
@@ -43,62 +69,73 @@ namespace global_module_test {
}
let kernel = new inversify.Kernel();
kernel.bind<INinja>("INinja").to(Ninja);
kernel.bind<IKatana>("IKatana").to(Katana);
kernel.bind<IShuriken>("IShuriken").to(Shuriken).inSingletonScope();
let kernel: inversify.interfaces.Kernel = new Kernel();
kernel.bind<Warrior>("Warrior").to(Ninja);
kernel.bind<Weapon>("Weapon").to(Katana);
kernel.bind<ThrowableWeapon>("ThrowableWeapon").to(Shuriken).inSingletonScope();
let ninja = kernel.get<INinja>("INinja");
let ninja = kernel.get<Warrior>("Warrior");
console.log(ninja);
// Unbind
kernel.unbind("INinja");
kernel.unbind("Warrior");
kernel.unbindAll();
// Kernel modules
let module: inversify.IKernelModule = (k: inversify.IKernel) => {
k.bind<INinja>("INinja").to(Ninja);
k.bind<IKatana>("IKatana").to(Katana).inTransientScope();
k.bind<IShuriken>("IShuriken").to(Shuriken).inSingletonScope();
};
let warriors: inversify.interfaces.KernelModule = new KernelModule((bind: inversify.interfaces.Bind) => {
bind<Warrior>("Warrior").to(Ninja);
});
let options: inversify.IKernelOptions = {
middleware: [],
modules: [module]
};
let weapons: inversify.interfaces.KernelModule = new KernelModule((bind: inversify.interfaces.Bind) => {
bind<Weapon>("Weapon").to(Katana);
bind<ThrowableWeapon>("ThrowableWeapon").to(Shuriken);
});
kernel = new inversify.Kernel(options);
let ninja2 = kernel.get<INinja>("INinja");
kernel = new Kernel();
kernel.load(warriors, weapons);
let ninja2 = kernel.get<Warrior>("Warrior");
console.log(ninja2);
// middleware
function logger(planAndResolve: inversify.interfaces.PlanAndResolve<any>): inversify.interfaces.PlanAndResolve<any> {
return (args: inversify.interfaces.PlanAndResolveArgs) => {
let start = new Date().getTime();
let result = planAndResolve(args);
let end = new Date().getTime();
console.log(end - start);
return result;
};
}
kernel.applyMiddleware(logger, logger);
// binding types
kernel.bind<IKatana>("IKatana").to(Katana);
kernel.bind<IKatana>("IKatana").toValue(new Katana());
kernel.bind<Weapon>("Weapon").to(Katana);
kernel.bind<Weapon>("Weapon").toConstantValue(new Katana());
kernel.bind<Weapon>("Weapon").toDynamicValue(() => { return new Katana(); });
kernel.bind<inversify.INewable<IKatana>>("IKatana").toConstructor<IKatana>(Katana);
kernel.bind<inversify.interfaces.Newable<Weapon>>("Weapon").toConstructor<Weapon>(Katana);
kernel.bind<inversify.IFactory<IKatana>>("IKatana").toFactory<IKatana>((context) => {
kernel.bind<inversify.interfaces.Factory<Weapon>>("Weapon").toFactory<Weapon>((context) => {
return () => {
return kernel.get<IKatana>("IKatana");
return kernel.get<Weapon>("Weapon");
};
});
kernel.bind<inversify.IFactory<IKatana>>("IKatana").toAutoFactory<IKatana>();
kernel.bind<inversify.interfaces.Factory<Weapon>>("Weapon").toAutoFactory<Weapon>("Weapon");
kernel.bind<inversify.IProvider<IKatana>>("IKatana").toProvider<IKatana>((context) => {
kernel.bind<inversify.interfaces.Provider<Weapon>>("Weapon").toProvider<Weapon>((context) => {
return () => {
return new Promise<IKatana>((resolve) => {
let katana = kernel.get<IKatana>("IKatana");
return new Promise<Weapon>((resolve) => {
let katana = kernel.get<Weapon>("Weapon");
resolve(katana);
});
};
});
kernel.bind<IKatana>("IKatana").to(Katana).proxy((katanaToBeInjected: IKatana) => {
// BLOCK http://stackoverflow.com/questions/35906938/how-to-enable-harmony-proxies-in-gulp-mocha
/*
kernel.bind<Weapon>("Weapon").to(Katana).onActivation((context: inversify.interfaces.Context, katanaToBeInjected: Weapon) => {
let handler = {
apply: function(target, thisArgument, argumentsList) {
apply: function(target: any, thisArgument: any, argumentsList: any[]) {
console.log(`Starting: ${performance.now()}`);
let result = target.apply(thisArgument, argumentsList);
console.log(`Finished: ${performance.now()}`);
@@ -106,88 +143,301 @@ namespace global_module_test {
}
};
return new Proxy(katanaToBeInjected, handler);
*/
return katanaToBeInjected;
});
interface IWeapon {}
interface ISamurai {
katana: IWeapon;
shuriken: IWeapon;
}
@inversify.inject("IWeapon", "IWeapon")
class Samurai implements ISamurai {
public katana: IWeapon;
public shuriken: IWeapon;
@injectable()
class Samurai implements Warrior {
public katana: Weapon;
public shuriken: ThrowableWeapon;
public constructor(
@inversify.tagged("canThrow", false) katana: IWeapon,
@inversify.tagged("canThrow", true) shuriken: IWeapon
@inject("Weapon") @tagged("canThrow", false) katana: Weapon,
@inject("ThrowableWeapon") @tagged("canThrow", true) shuriken: ThrowableWeapon
) {
this.katana = katana;
this.shuriken = shuriken;
}
public fight() { return this.katana.hit(); };
public sneak() { return this.shuriken.throw(); };
}
kernel.bind<Samurai>("Samurai").to(Samurai);
kernel.bind<IWeapon>("IWeapon").to(Katana).whenTargetTagged("canThrow", false);
kernel.bind<IWeapon>("IWeapon").to(Shuriken).whenTargetTagged("canThrow", true);
kernel.bind<Weapon>("IWeapon").to(Katana).whenTargetTagged("canThrow", false);
kernel.bind<ThrowableWeapon>("ThrowableWeapon").to(Shuriken).whenTargetTagged("canThrow", true);
let throwable = inversify.tagged("canThrow", true);
let notThrowable = inversify.tagged("canThrow", false);
let throwable = tagged("canThrow", true);
let notThrowable = tagged("canThrow", false);
@inversify.inject("IWeapon", "IWeapon")
class Samurai2 implements ISamurai {
public katana: IWeapon;
public shuriken: IWeapon;
@injectable()
class Samurai2 implements Samurai {
public katana: Weapon;
public shuriken: ThrowableWeapon;
public constructor(
@throwable("canThrow", false) katana: IWeapon,
@notThrowable("canThrow", true) shuriken: IWeapon
@inject("Weapon") @throwable katana: Weapon,
@inject("ThrowableWeapon") @notThrowable shuriken: ThrowableWeapon
) {
this.katana = katana;
this.shuriken = shuriken;
}
public fight() { return this.katana.hit(); };
public sneak() { return this.shuriken.throw(); };
}
@inversify.inject("IWeapon", "IWeapon")
class Samurai3 implements ISamurai {
public katana: IWeapon;
public shuriken: IWeapon;
@injectable()
class Samurai3 implements Samurai {
public katana: Weapon;
public shuriken: ThrowableWeapon;
public constructor(
@inversify.named("strong") katana: IWeapon,
@inversify.named("weak") shuriken: IWeapon
@inject("Weapon") @named("strong") katana: Weapon,
@inject("ThrowableWeapon") @named("weak") shuriken: ThrowableWeapon
) {
this.katana = katana;
this.shuriken = shuriken;
}
public fight() { return this.katana.hit(); };
public sneak() { return this.shuriken.throw(); };
}
kernel.bind<ISamurai>("ISamurai").to(Samurai3);
kernel.bind<IWeapon>("IWeapon").to(Katana).whenTargetNamed("strong");
kernel.bind<IWeapon>("IWeapon").to(Shuriken).whenTargetNamed("weak");
kernel.bind<Warrior>("Warrior").to(Samurai3);
kernel.bind<Weapon>("Weapon").to(Katana).whenTargetNamed("strong");
kernel.bind<Weapon>("Weapon").to(Shuriken).whenTargetNamed("weak");
@inversify.inject("IWeapon", "IWeapon")
@inversify.paramNames("katana", "shuriken")
class Samurai4 implements ISamurai {
public katana: IWeapon;
public shuriken: IWeapon;
@injectable()
class Samurai4 implements Samurai {
public katana: Weapon;
public shuriken: ThrowableWeapon;
public constructor(
katana: IWeapon,
shuriken: IWeapon
@inject("Weapon") @targetName("katana") katana: Weapon,
@inject("ThrowableWeapon") @targetName("shuriken") shuriken: ThrowableWeapon
) {
this.katana = katana;
this.shuriken = shuriken;
}
public fight() { return this.katana.hit(); };
public sneak() { return this.shuriken.throw(); };
}
kernel.bind<ISamurai>("ISamurai").to(Samurai4);
kernel.bind<Warrior>("Warrior").to(Samurai4);
kernel.bind<IWeapon>("IWeapon").to(Katana).when((request: inversify.IRequest) => {
kernel.bind<Weapon>("Weapon").to(Katana).when((request: inversify.interfaces.Request) => {
return request.target.name.equals("katana");
});
kernel.bind<IWeapon>("IWeapon").to(Shuriken).when((request: inversify.IRequest) => {
kernel.bind<Weapon>("Weapon").to(Shuriken).when((request: inversify.interfaces.Request) => {
return request.target.name.equals("shuriken");
});
// custom constraints
let whenParentNamedCanThrowConstraint = (request: inversify.interfaces.Request) => {
return namedConstraint("canThrow")(request.parentRequest);
};
let whenAnyAncestorIsConstraint = (request: inversify.interfaces.Request) => {
return traverseAncerstors(request, typeConstraint(Ninja));
};
let whenAnyAncestorTaggedConstraint = (request: inversify.interfaces.Request) => {
return traverseAncerstors(request, taggedConstraint("canThrow")(true));
};
kernel.bind<Weapon>("Weapon").to(Shuriken).when(whenParentNamedCanThrowConstraint);
kernel.bind<Weapon>("Weapon").to(Shuriken).when(whenAnyAncestorIsConstraint);
kernel.bind<Weapon>("Weapon").to(Shuriken).when(whenAnyAncestorTaggedConstraint);
// Constraint helpers
kernel.bind<Weapon>("Weapon").to(Shuriken).whenInjectedInto(Ninja);
kernel.bind<Weapon>("Weapon").to(Shuriken).whenInjectedInto("INinja");
kernel.bind<Weapon>("Weapon").to(Shuriken).whenParentNamed("chinese");
kernel.bind<Weapon>("Weapon").to(Shuriken).whenParentTagged("canThrow", true);
kernel.bind<Weapon>("Weapon").to(Shuriken).whenTargetNamed("strong");
kernel.bind<Weapon>("Weapon").to(Shuriken).whenTargetTagged("canThrow", true);
kernel.bind<Weapon>("Weapon").to(Shuriken).whenAnyAncestorIs(Ninja);
kernel.bind<Weapon>("Weapon").to(Shuriken).whenAnyAncestorIs("INinja");
kernel.bind<Weapon>("Weapon").to(Shuriken).whenAnyAncestorNamed("strong");
kernel.bind<Weapon>("Weapon").to(Shuriken).whenAnyAncestorTagged("canThrow", true);
kernel.bind<Weapon>("Weapon").to(Shuriken).whenAnyAncestorMatches(whenParentNamedCanThrowConstraint);
kernel.bind<Weapon>("Weapon").to(Shuriken).whenNoAncestorIs(Ninja);
kernel.bind<Weapon>("Weapon").to(Shuriken).whenNoAncestorIs("INinja");
kernel.bind<Weapon>("Weapon").to(Shuriken).whenNoAncestorNamed("strong");
kernel.bind<Weapon>("Weapon").to(Shuriken).whenNoAncestorTagged("canThrow", true);
kernel.bind<Weapon>("Weapon").to(Shuriken).whenNoAncestorMatches(whenParentNamedCanThrowConstraint);
// multi-injection
@injectable()
class Samurai5 implements Warrior {
public katana: Weapon;
public shuriken: Weapon;
public constructor(
@multiInject("Weapon") wpns: Weapon[]
) {
this.katana = wpns[0];
this.shuriken = wpns[1];
}
public fight() { return this.katana.hit(); };
public sneak() { return this.shuriken.hit(); };
}
// symbols
let SYMBOLS = {
ThrowableWeapon: Symbol("ThrowableWeapon"),
Warrior: Symbol("Warrior"),
Weapon: Symbol("Weapon"),
};
@injectable()
class Ninja1 implements Warrior {
private _katana: Weapon;
private _shuriken: ThrowableWeapon;
public constructor(
@inject(SYMBOLS.Weapon) katana: Weapon,
@inject(SYMBOLS.ThrowableWeapon) shuriken: ThrowableWeapon
) {
this._katana = katana;
this._shuriken = shuriken;
}
public fight() { return this._katana.hit(); };
public sneak() { return this._shuriken.throw(); };
}
let kernel3 = new Kernel();
kernel3.bind<Warrior>(SYMBOLS.Warrior).to(Ninja);
kernel3.bind<Weapon>(SYMBOLS.Weapon).to(Katana);
kernel3.bind<ThrowableWeapon>(SYMBOLS.ThrowableWeapon).to(Shuriken).inSingletonScope();
let ninja4 = kernel3.get<Warrior>("Warrior");
console.log(ninja4);
// classes
@injectable()
class Ninja2 implements Warrior {
private _katana: Katana;
private _shuriken: Shuriken;
public constructor(
katana: Katana,
shuriken: Shuriken
) {
this._katana = katana;
this._shuriken = shuriken;
}
public fight() { return this._katana.hit(); };
public sneak() { return this._shuriken.throw(); };
}
let kernel4 = new Kernel();
kernel4.bind<Ninja>(Ninja).to(Ninja);
kernel4.bind<Katana>(Katana).to(Katana);
kernel4.bind<Shuriken>(Shuriken).to(Shuriken).inSingletonScope();
let ninja5 = kernel4.get<Ninja>(Ninja);
console.log(ninja5);
}
module property_injection {
let kernel = new Kernel();
let TYPES = { Weapon: "Weapon" };
interface Weapon {
durability: number;
use(): void;
}
@injectable()
class Sword implements Weapon {
public durability: number;
public constructor() {
this.durability = 100;
}
public use() {
this.durability = this.durability - 10;
}
}
@injectable()
class WarHammer implements Weapon {
public durability: number;
public constructor() {
this.durability = 100;
}
public use() {
this.durability = this.durability - 10;
}
}
let propertyMultiInject = makePropertyMultiInjectDecorator(kernel);
class Warrior1 {
@propertyMultiInject(TYPES.Weapon)
public weapons: Weapon[];
}
let propertyInject = makePropertyInjectDecorator(kernel);
interface Service {
count: number;
increment(): void;
}
@injectable()
class SomeService implements Service {
public count: number;
public constructor() {
this.count = 0;
}
public increment() {
this.count = this.count + 1;
}
}
class SomeWebComponent {
@propertyInject("Service")
private _service: Service;
public doSomething() {
let count = this._service.count;
this._service.increment();
return count;
}
}
let propertyInjectNammed = makePropertyInjectNamedDecorator(kernel);
class Warrior2 {
@propertyInjectNammed(TYPES.Weapon, "not-throwwable")
@named("not-throwwable")
public primaryWeapon: Weapon;
@propertyInjectNammed(TYPES.Weapon, "throwwable")
@named("throwwable")
public secondaryWeapon: Weapon;
}
let propertyInjectTagged = makePropertyInjectTaggedDecorator(kernel);
class Warrior3 {
@propertyInjectTagged(TYPES.Weapon, "throwwable", false)
@tagged("throwwable", false)
public primaryWeapon: Weapon;
@propertyInjectTagged(TYPES.Weapon, "throwwable", true)
@tagged("throwwable", true)
public secondaryWeapon: Weapon;
}
kernel.snapshot();
kernel.restore();
}
+326 -85
View File
@@ -1,46 +1,62 @@
/// <reference path="inversify.d.ts" />
/// <reference path="./inversify.d.ts" />
/// <reference path="../harmony-proxy/harmony-proxy.d.ts" />
import {
Kernel,
inject, tagged, named, paramNames,
IKernel, IKernelOptions, INewable,
IKernelModule, IFactory, IProvider, IRequest
injectable, tagged, named, targetName,
inject, multiInject, traverseAncerstors,
taggedConstraint, namedConstraint, typeConstraint,
makePropertyMultiInjectDecorator,
makePropertyInjectTaggedDecorator,
makePropertyInjectNamedDecorator,
makePropertyInjectDecorator,
KernelModule, interfaces
} from "inversify";
namespace external_module_test {
import * as Proxy from "harmony-proxy";
interface INinja {
module external_module_test {
interface Warrior {
fight(): string;
sneak(): string;
}
interface IKatana {
interface Weapon {
hit(): string;
}
interface IShuriken {
interface ThrowableWeapon extends Weapon {
throw(): string;
}
class Katana implements IKatana {
@injectable()
class Katana implements Weapon {
public hit() {
return "cut!";
}
}
class Shuriken implements IShuriken {
@injectable()
class Shuriken implements ThrowableWeapon {
public throw() {
return "hit!";
}
public hit() {
return "hit!";
}
}
@inject("IKatana", "IShuriken")
class Ninja implements INinja {
@injectable()
class Ninja implements Warrior {
private _katana: IKatana;
private _shuriken: IShuriken;
private _katana: Weapon;
private _shuriken: ThrowableWeapon;
public constructor(katana: IKatana, shuriken: IShuriken) {
public constructor(
@inject("Weapon") katana: Weapon,
@inject("ThrowableWeapon") shuriken: ThrowableWeapon
) {
this._katana = katana;
this._shuriken = shuriken;
}
@@ -50,62 +66,73 @@ namespace external_module_test {
}
let kernel = new Kernel();
kernel.bind<INinja>("INinja").to(Ninja);
kernel.bind<IKatana>("IKatana").to(Katana);
kernel.bind<IShuriken>("IShuriken").to(Shuriken).inSingletonScope();
let kernel: interfaces.Kernel = new Kernel();
kernel.bind<Warrior>("Warrior").to(Ninja);
kernel.bind<Weapon>("Weapon").to(Katana);
kernel.bind<ThrowableWeapon>("ThrowableWeapon").to(Shuriken).inSingletonScope();
let ninja = kernel.get<INinja>("INinja");
let ninja = kernel.get<Warrior>("Warrior");
console.log(ninja);
// Unbind
kernel.unbind("INinja");
kernel.unbind("Warrior");
kernel.unbindAll();
// Kernel modules
let module: IKernelModule = (k: IKernel) => {
k.bind<INinja>("INinja").to(Ninja);
k.bind<IKatana>("IKatana").to(Katana).inTransientScope();
k.bind<IShuriken>("IShuriken").to(Shuriken).inSingletonScope();
};
let warriors: interfaces.KernelModule = new KernelModule((bind: interfaces.Bind) => {
bind<Warrior>("Warrior").to(Ninja);
});
let options: IKernelOptions = {
middleware: [],
modules: [module]
};
let weapons: interfaces.KernelModule = new KernelModule((bind: interfaces.Bind) => {
bind<Weapon>("Weapon").to(Katana);
bind<ThrowableWeapon>("ThrowableWeapon").to(Shuriken);
});
kernel = new Kernel(options);
let ninja2 = kernel.get<INinja>("INinja");
kernel = new Kernel();
kernel.load(warriors, weapons);
let ninja2 = kernel.get<Warrior>("Warrior");
console.log(ninja2);
// middleware
function logger(planAndResolve: interfaces.PlanAndResolve<any>): interfaces.PlanAndResolve<any> {
return (args: interfaces.PlanAndResolveArgs) => {
let start = new Date().getTime();
let result = planAndResolve(args);
let end = new Date().getTime();
console.log(end - start);
return result;
};
}
kernel.applyMiddleware(logger, logger);
// binding types
kernel.bind<IKatana>("IKatana").to(Katana);
kernel.bind<IKatana>("IKatana").toValue(new Katana());
kernel.bind<Weapon>("Weapon").to(Katana);
kernel.bind<Weapon>("Weapon").toConstantValue(new Katana());
kernel.bind<Weapon>("Weapon").toDynamicValue(() => { return new Katana(); });
kernel.bind<INewable<IKatana>>("IKatana").toConstructor<IKatana>(Katana);
kernel.bind<interfaces.Newable<Weapon>>("Weapon").toConstructor<Weapon>(Katana);
kernel.bind<IFactory<IKatana>>("IKatana").toFactory<IKatana>((context) => {
kernel.bind<interfaces.Factory<Weapon>>("Weapon").toFactory<Weapon>((context) => {
return () => {
return kernel.get<IKatana>("IKatana");
return kernel.get<Weapon>("Weapon");
};
});
kernel.bind<IFactory<IKatana>>("IKatana").toAutoFactory<IKatana>();
kernel.bind<interfaces.Factory<Weapon>>("Weapon").toAutoFactory<Weapon>("Weapon");
kernel.bind<IProvider<IKatana>>("IKatana").toProvider<IKatana>((context) => {
kernel.bind<interfaces.Provider<Weapon>>("Weapon").toProvider<Weapon>((context) => {
return () => {
return new Promise<IKatana>((resolve) => {
let katana = kernel.get<IKatana>("IKatana");
return new Promise<Weapon>((resolve) => {
let katana = kernel.get<Weapon>("Weapon");
resolve(katana);
});
};
});
kernel.bind<IKatana>("IKatana").to(Katana).proxy((katanaToBeInjected: IKatana) => {
// BLOCK http://stackoverflow.com/questions/35906938/how-to-enable-harmony-proxies-in-gulp-mocha
/*
kernel.bind<Weapon>("Weapon").to(Katana).onActivation((context: interfaces.Context, katanaToBeInjected: Weapon) => {
let handler = {
apply: function(target, thisArgument, argumentsList) {
apply: function(target: any, thisArgument: any, argumentsList: any[]) {
console.log(`Starting: ${performance.now()}`);
let result = target.apply(thisArgument, argumentsList);
console.log(`Finished: ${performance.now()}`);
@@ -113,88 +140,302 @@ namespace external_module_test {
}
};
return new Proxy(katanaToBeInjected, handler);
*/
return katanaToBeInjected;
});
interface IWeapon {}
interface ISamurai {
katana: IWeapon;
shuriken: IWeapon;
}
@inject("IWeapon", "IWeapon")
class Samurai implements ISamurai {
public katana: IWeapon;
public shuriken: IWeapon;
@injectable()
class Samurai implements Warrior {
public katana: Weapon;
public shuriken: ThrowableWeapon;
public constructor(
@tagged("canThrow", false) katana: IWeapon,
@tagged("canThrow", true) shuriken: IWeapon
@inject("Weapon") @tagged("canThrow", false) katana: Weapon,
@inject("ThrowableWeapon") @tagged("canThrow", true) shuriken: ThrowableWeapon
) {
this.katana = katana;
this.shuriken = shuriken;
}
public fight() { return this.katana.hit(); };
public sneak() { return this.shuriken.throw(); };
}
kernel.bind<Samurai>("Samurai").to(Samurai);
kernel.bind<IWeapon>("IWeapon").to(Katana).whenTargetTagged("canThrow", false);
kernel.bind<IWeapon>("IWeapon").to(Shuriken).whenTargetTagged("canThrow", true);
kernel.bind<Weapon>("IWeapon").to(Katana).whenTargetTagged("canThrow", false);
kernel.bind<ThrowableWeapon>("ThrowableWeapon").to(Shuriken).whenTargetTagged("canThrow", true);
let throwable = tagged("canThrow", true);
let notThrowable = tagged("canThrow", false);
@inject("IWeapon", "IWeapon")
class Samurai2 implements ISamurai {
public katana: IWeapon;
public shuriken: IWeapon;
@injectable()
class Samurai2 implements Samurai {
public katana: Weapon;
public shuriken: ThrowableWeapon;
public constructor(
@throwable("canThrow", false) katana: IWeapon,
@notThrowable("canThrow", true) shuriken: IWeapon
@inject("Weapon") @throwable katana: Weapon,
@inject("ThrowableWeapon") @notThrowable shuriken: ThrowableWeapon
) {
this.katana = katana;
this.shuriken = shuriken;
}
public fight() { return this.katana.hit(); };
public sneak() { return this.shuriken.throw(); };
}
@inject("IWeapon", "IWeapon")
class Samurai3 implements ISamurai {
public katana: IWeapon;
public shuriken: IWeapon;
@injectable()
class Samurai3 implements Samurai {
public katana: Weapon;
public shuriken: ThrowableWeapon;
public constructor(
@named("strong") katana: IWeapon,
@named("weak") shuriken: IWeapon
@inject("Weapon") @named("strong") katana: Weapon,
@inject("ThrowableWeapon") @named("weak") shuriken: ThrowableWeapon
) {
this.katana = katana;
this.shuriken = shuriken;
}
public fight() { return this.katana.hit(); };
public sneak() { return this.shuriken.throw(); };
}
kernel.bind<ISamurai>("ISamurai").to(Samurai3);
kernel.bind<IWeapon>("IWeapon").to(Katana).whenTargetNamed("strong");
kernel.bind<IWeapon>("IWeapon").to(Shuriken).whenTargetNamed("weak");
kernel.bind<Warrior>("Warrior").to(Samurai3);
kernel.bind<Weapon>("Weapon").to(Katana).whenTargetNamed("strong");
kernel.bind<Weapon>("Weapon").to(Shuriken).whenTargetNamed("weak");
@inject("IWeapon", "IWeapon")
@paramNames("katana", "shuriken")
class Samurai4 implements ISamurai {
public katana: IWeapon;
public shuriken: IWeapon;
@injectable()
class Samurai4 implements Samurai {
public katana: Weapon;
public shuriken: ThrowableWeapon;
public constructor(
katana: IWeapon,
shuriken: IWeapon
@inject("Weapon") @targetName("katana") katana: Weapon,
@inject("ThrowableWeapon") @targetName("shuriken") shuriken: ThrowableWeapon
) {
this.katana = katana;
this.shuriken = shuriken;
}
public fight() { return this.katana.hit(); };
public sneak() { return this.shuriken.throw(); };
}
kernel.bind<ISamurai>("ISamurai").to(Samurai4);
kernel.bind<Warrior>("Warrior").to(Samurai4);
kernel.bind<IWeapon>("IWeapon").to(Katana).when((request: IRequest) => {
kernel.bind<Weapon>("Weapon").to(Katana).when((request: interfaces.Request) => {
return request.target.name.equals("katana");
});
kernel.bind<IWeapon>("IWeapon").to(Shuriken).when((request: IRequest) => {
kernel.bind<Weapon>("Weapon").to(Shuriken).when((request: interfaces.Request) => {
return request.target.name.equals("shuriken");
});
// custom constraints
let whenParentNamedCanThrowConstraint = (request: interfaces.Request) => {
return namedConstraint("canThrow")(request.parentRequest);
};
let whenAnyAncestorIsConstraint = (request: interfaces.Request) => {
return traverseAncerstors(request, typeConstraint(Ninja));
};
let whenAnyAncestorTaggedConstraint = (request: interfaces.Request) => {
return traverseAncerstors(request, taggedConstraint("canThrow")(true));
};
kernel.bind<Weapon>("Weapon").to(Shuriken).when(whenParentNamedCanThrowConstraint);
kernel.bind<Weapon>("Weapon").to(Shuriken).when(whenAnyAncestorIsConstraint);
kernel.bind<Weapon>("Weapon").to(Shuriken).when(whenAnyAncestorTaggedConstraint);
// Constraint helpers
kernel.bind<Weapon>("Weapon").to(Shuriken).whenInjectedInto(Ninja);
kernel.bind<Weapon>("Weapon").to(Shuriken).whenInjectedInto("INinja");
kernel.bind<Weapon>("Weapon").to(Shuriken).whenParentNamed("chinese");
kernel.bind<Weapon>("Weapon").to(Shuriken).whenParentTagged("canThrow", true);
kernel.bind<Weapon>("Weapon").to(Shuriken).whenTargetNamed("strong");
kernel.bind<Weapon>("Weapon").to(Shuriken).whenTargetTagged("canThrow", true);
kernel.bind<Weapon>("Weapon").to(Shuriken).whenAnyAncestorIs(Ninja);
kernel.bind<Weapon>("Weapon").to(Shuriken).whenAnyAncestorIs("INinja");
kernel.bind<Weapon>("Weapon").to(Shuriken).whenAnyAncestorNamed("strong");
kernel.bind<Weapon>("Weapon").to(Shuriken).whenAnyAncestorTagged("canThrow", true);
kernel.bind<Weapon>("Weapon").to(Shuriken).whenAnyAncestorMatches(whenParentNamedCanThrowConstraint);
kernel.bind<Weapon>("Weapon").to(Shuriken).whenNoAncestorIs(Ninja);
kernel.bind<Weapon>("Weapon").to(Shuriken).whenNoAncestorIs("INinja");
kernel.bind<Weapon>("Weapon").to(Shuriken).whenNoAncestorNamed("strong");
kernel.bind<Weapon>("Weapon").to(Shuriken).whenNoAncestorTagged("canThrow", true);
kernel.bind<Weapon>("Weapon").to(Shuriken).whenNoAncestorMatches(whenParentNamedCanThrowConstraint);
// multi-injection
@injectable()
class Samurai5 implements Warrior {
public katana: Weapon;
public shuriken: Weapon;
public constructor(
@multiInject("Weapon") wpns: Weapon[]
) {
this.katana = wpns[0];
this.shuriken = wpns[1];
}
public fight() { return this.katana.hit(); };
public sneak() { return this.shuriken.hit(); };
}
// symbols
let SYMBOLS = {
ThrowableWeapon: Symbol("ThrowableWeapon"),
Warrior: Symbol("Warrior"),
Weapon: Symbol("Weapon"),
};
@injectable()
class Ninja1 implements Warrior {
private _katana: Weapon;
private _shuriken: ThrowableWeapon;
public constructor(
@inject(SYMBOLS.Weapon) katana: Weapon,
@inject(SYMBOLS.ThrowableWeapon) shuriken: ThrowableWeapon
) {
this._katana = katana;
this._shuriken = shuriken;
}
public fight() { return this._katana.hit(); };
public sneak() { return this._shuriken.throw(); };
}
let kernel3 = new Kernel();
kernel3.bind<Warrior>(SYMBOLS.Warrior).to(Ninja);
kernel3.bind<Weapon>(SYMBOLS.Weapon).to(Katana);
kernel3.bind<ThrowableWeapon>(SYMBOLS.ThrowableWeapon).to(Shuriken).inSingletonScope();
let ninja4 = kernel3.get<Warrior>("Warrior");
console.log(ninja4);
// classes
@injectable()
class Ninja2 implements Warrior {
private _katana: Katana;
private _shuriken: Shuriken;
public constructor(
katana: Katana,
shuriken: Shuriken
) {
this._katana = katana;
this._shuriken = shuriken;
}
public fight() { return this._katana.hit(); };
public sneak() { return this._shuriken.throw(); };
}
let kernel4 = new Kernel();
kernel4.bind<Ninja>(Ninja).to(Ninja);
kernel4.bind<Katana>(Katana).to(Katana);
kernel4.bind<Shuriken>(Shuriken).to(Shuriken).inSingletonScope();
let ninja5 = kernel4.get<Ninja>(Ninja);
console.log(ninja5);
}
module property_injection {
let kernel = new Kernel();
let TYPES = { Weapon: "Weapon" };
interface Weapon {
durability: number;
use(): void;
}
@injectable()
class Sword implements Weapon {
public durability: number;
public constructor() {
this.durability = 100;
}
public use() {
this.durability = this.durability - 10;
}
}
@injectable()
class WarHammer implements Weapon {
public durability: number;
public constructor() {
this.durability = 100;
}
public use() {
this.durability = this.durability - 10;
}
}
let propertyMultiInject = makePropertyMultiInjectDecorator(kernel);
class Warrior1 {
@propertyMultiInject(TYPES.Weapon)
public weapons: Weapon[];
}
let propertyInject = makePropertyInjectDecorator(kernel);
interface Service {
count: number;
increment(): void;
}
@injectable()
class SomeService implements Service {
public count: number;
public constructor() {
this.count = 0;
}
public increment() {
this.count = this.count + 1;
}
}
class SomeWebComponent {
@propertyInject("Service")
private _service: Service;
public doSomething() {
let count = this._service.count;
this._service.increment();
return count;
}
}
let propertyInjectNammed = makePropertyInjectNamedDecorator(kernel);
class Warrior2 {
@propertyInjectNammed(TYPES.Weapon, "not-throwwable")
@named("not-throwwable")
public primaryWeapon: Weapon;
@propertyInjectNammed(TYPES.Weapon, "throwwable")
@named("throwwable")
public secondaryWeapon: Weapon;
}
let propertyInjectTagged = makePropertyInjectTaggedDecorator(kernel);
class Warrior3 {
@propertyInjectTagged(TYPES.Weapon, "throwwable", false)
@tagged("throwwable", false)
public primaryWeapon: Weapon;
@propertyInjectTagged(TYPES.Weapon, "throwwable", true)
@tagged("throwwable", true)
public secondaryWeapon: Weapon;
}
kernel.snapshot();
kernel.restore();
}
+258 -122
View File
@@ -1,141 +1,277 @@
// Type definitions for inversify 2.0.0-alpha.3
// Type definitions for inversify 2.0.0-beta.9
// Project: https://github.com/inversify/InversifyJS
// Definitions by: inversify <https://github.com/inversify>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../bluebird/bluebird.d.ts" />
interface Symbol {
toString(): string;
valueOf(): Object;
}
interface SymbolConstructor {
(description?: string|number): Symbol;
}
declare var Symbol: SymbolConstructor;
declare namespace inversify {
interface IKernelConstructor {
new(options?: IKernelOptions): IKernel;
namespace interfaces {
export interface KernelConstructor {
new(): Kernel;
}
export interface KernelModuleConstructor {
new(registry: (bind: Bind) => void): KernelModule;
}
export interface Newable<T> {
new(...args: any[]): T;
}
export type ServiceIdentifier<T> = (string|Symbol|Newable<T>);
export interface Binding<T> extends Clonable<Binding<T>> {
guid: string;
moduleId: string;
activated: boolean;
serviceIdentifier: ServiceIdentifier<T>;
implementationType: Newable<T>;
factory: FactoryCreator<any>;
provider: ProviderCreator<any>;
constraint: (request: Request) => boolean;
onActivation: (context: Context, injectable: T) => T;
cache: T;
dynamicValue: () => T;
scope: number; // BindingScope
type: number; // BindingType
}
export interface Factory<T> extends Function {
(...args: any[]): (((...args: any[]) => T)|T);
}
export interface FactoryCreator<T> extends Function {
(context: Context): Factory<T>;
}
export interface Provider<T> extends Function {
(): Promise<T>;
}
export interface ProviderCreator<T> extends Function {
(context: Context): Provider<T>;
}
export interface PlanAndResolve<T> {
(args: PlanAndResolveArgs): T[];
}
export interface PlanAndResolveArgs {
multiInject: boolean;
serviceIdentifier: ServiceIdentifier<any>;
target: Target;
contextInterceptor: (contexts: Context) => Context;
}
export interface Middleware extends Function {
(next: PlanAndResolve<any>): PlanAndResolve<any>;
}
export interface Context {
guid: string;
kernel: Kernel;
plan: Plan;
addPlan(plan: Plan): void;
}
export interface ReflectResult {
[key: string]: Metadata[];
}
export interface Metadata {
key: string;
value: any;
}
export interface Plan {
parentContext: Context;
rootRequest: Request;
}
export interface Planner {
createContext(kernel: Kernel): Context;
createPlan(parentContext: Context, binding: Binding<any>, target: Target): Plan;
getBindings<T>(kernel: Kernel, serviceIdentifier: ServiceIdentifier<T>): Binding<T>[];
getActiveBindings(parentRequest: Request, target: Target): Binding<any>[];
}
export interface QueryableString {
startsWith(searchString: string): boolean;
endsWith(searchString: string): boolean;
contains(searchString: string): boolean;
equals(compareString: string): boolean;
value(): string;
}
export interface Request {
guid: string;
serviceIdentifier: ServiceIdentifier<any>;
parentContext: Context;
parentRequest: Request;
childRequests: Request[];
target: Target;
bindings: Binding<any>[];
addChildRequest(
serviceIdentifier: ServiceIdentifier<any>,
bindings: (Binding<any>|Binding<any>[]),
target: Target
): Request;
}
export interface Target {
guid: string;
serviceIdentifier: ServiceIdentifier<any>;
name: QueryableString;
metadata: Array<Metadata>;
hasTag(key: string): boolean;
isArray(): boolean;
matchesArray(name: string|Symbol|Newable<any>): boolean;
isNamed(): boolean;
isTagged(): boolean;
matchesNamedTag(name: string): boolean;
matchesTag(key: string): (value: any) => boolean;
}
export interface Resolver {
resolve<T>(context: Context): T;
}
export interface Kernel {
guid: string;
bind<T>(serviceIdentifier: ServiceIdentifier<T>): BindingToSyntax<T>;
unbind(serviceIdentifier: ServiceIdentifier<any>): void;
unbindAll(): void;
isBound(serviceIdentifier: ServiceIdentifier<any>): boolean;
get<T>(serviceIdentifier: ServiceIdentifier<T>): T;
getNamed<T>(serviceIdentifier: ServiceIdentifier<T>, named: string): T;
getTagged<T>(serviceIdentifier: ServiceIdentifier<T>, key: string, value: any): T;
getAll<T>(serviceIdentifier: ServiceIdentifier<T>): T[];
load(...modules: KernelModule[]): void;
unload(...modules: KernelModule[]): void;
applyMiddleware(...middleware: Middleware[]): void;
getServiceIdentifierAsString(serviceIdentifier: ServiceIdentifier<any>): string;
snapshot(): void;
restore(): void;
}
export interface Bind extends Function {
<T>(serviceIdentifier: ServiceIdentifier<T>): BindingToSyntax<T>;
}
export interface KernelModule {
guid: string;
registry: (bind: Bind) => void;
}
export interface KernelSnapshot {
bindings: Lookup<Binding<any>>;
middleware: PlanAndResolve<any>;
}
export interface Clonable<T> {
clone(): T;
}
export interface Lookup<T> extends Clonable<Lookup<T>> {
add(serviceIdentifier: ServiceIdentifier<any>, value: T): void;
get(serviceIdentifier: ServiceIdentifier<any>): Array<T>;
remove(serviceIdentifier: ServiceIdentifier<any>): void;
removeByModuleId(moduleId: string): void;
hasKey(serviceIdentifier: ServiceIdentifier<any>): boolean;
}
export interface KeyValuePair<T> {
serviceIdentifier: ServiceIdentifier<any>;
value: Array<T>;
}
export interface BindingInSyntax<T> {
inSingletonScope(): BindingWhenOnSyntax<T>;
}
export interface BindingInWhenOnSyntax<T> extends BindingInSyntax<T>, BindingWhenOnSyntax<T> {}
export interface BindingOnSyntax<T> {
onActivation(fn: (context: Context, injectable: T) => T): BindingWhenSyntax<T>;
}
export interface BindingToSyntax<T> {
to(constructor: { new(...args: any[]): T; }): BindingInWhenOnSyntax<T>;
toConstantValue(value: T): BindingWhenOnSyntax<T>;
toDynamicValue(func: () => T): BindingWhenOnSyntax<T>;
toConstructor<T2>(constructor: Newable<T2>): BindingWhenOnSyntax<T>;
toFactory<T2>(factory: FactoryCreator<T2>): BindingWhenOnSyntax<T>;
toFunction(func: T): BindingWhenOnSyntax<T>;
toAutoFactory<T2>(serviceIdentifier: ServiceIdentifier<T2>): BindingWhenOnSyntax<T>;
toProvider<T2>(provider: ProviderCreator<T2>): BindingWhenOnSyntax<T>;
}
export interface BindingWhenOnSyntax<T> extends BindingWhenSyntax<T>, BindingOnSyntax<T> {}
export interface BindingWhenSyntax<T> {
when(constraint: (request: Request) => boolean): BindingOnSyntax<T>;
whenTargetNamed(name: string): BindingOnSyntax<T>;
whenTargetTagged(tag: string, value: any): BindingOnSyntax<T>;
whenInjectedInto(parent: (Function|string)): BindingOnSyntax<T>;
whenParentNamed(name: string): BindingOnSyntax<T>;
whenParentTagged(tag: string, value: any): BindingOnSyntax<T>;
whenAnyAncestorIs(ancestor: (Function|string)): BindingOnSyntax<T>;
whenNoAncestorIs(ancestor: (Function|string)): BindingOnSyntax<T>;
whenAnyAncestorNamed(name: string): BindingOnSyntax<T>;
whenAnyAncestorTagged(tag: string, value: any): BindingOnSyntax<T>;
whenNoAncestorNamed(name: string): BindingOnSyntax<T>;
whenNoAncestorTagged(tag: string, value: any): BindingOnSyntax<T>;
whenAnyAncestorMatches(constraint: (request: Request) => boolean): BindingOnSyntax<T>;
whenNoAncestorMatches(constraint: (request: Request) => boolean): BindingOnSyntax<T>;
}
}
export interface IKernel {
bind<T>(runtimeIdentifier: string): IBindingToSyntax<T>;
unbind(runtimeIdentifier: string): void;
unbindAll(): void;
get<T>(runtimeIdentifier: string): T;
getAll<T>(runtimeIdentifier: string): T[];
}
export var Kernel: interfaces.KernelConstructor;
export var KernelModule: interfaces.KernelModuleConstructor;
export var decorate: (decorator: (ClassDecorator|ParameterDecorator), target: any, parameterIndex?: number) => void;
export function injectable(): (typeConstructor: any) => void;
export function tagged(metadataKey: string, metadataValue: any): (target: any, targetKey: string, index?: number) => any;
export function named(name: string): (target: any, targetKey: string, index?: number) => any;
export function targetName(name: string): (target: any, targetKey: string, index: number) => any;
export function inject(serviceIdentifier: interfaces.ServiceIdentifier<any>): (target: any, targetKey: string, index?: number) => any;
export interface IKernelOptions {
middleware?: IMiddleware[];
modules?: IKernelModule[];
}
export function multiInject(
serviceIdentifier: interfaces.ServiceIdentifier<any>
): (target: any, targetKey: string, index?: number) => any;
interface IMiddleware extends Function {
(...args: any[]): any;
}
export function makePropertyInjectDecorator(kernel: interfaces.Kernel):
(serviceIdentifier: (string|Symbol|interfaces.Newable<any>)) => (proto: any, key: string) => void;
export interface IKernelModule extends Function {
(kernel: IKernel): void;
}
export function makePropertyInjectNamedDecorator(kernel: interfaces.Kernel):
(serviceIdentifier: (string|Symbol|interfaces.Newable<any>), named: string) => (proto: any, key: string) => void;
interface IBindingToSyntax<T> {
to(constructor: { new(...args: any[]): T; }): IBindingInWhenProxySyntax<T>;
toValue(value: T): IBindingInWhenProxySyntax<T>;
toConstructor<T2>(constructor: INewable<T2>): IBindingInWhenProxySyntax<T>;
toFactory<T2>(factory: IFactoryCreator<T2>): IBindingInWhenProxySyntax<T>;
toAutoFactory<T2>(): IBindingInWhenProxySyntax<T>;
toProvider<T2>(provider: IProviderCreator<T2>): IBindingInWhenProxySyntax<T>;
}
export function makePropertyInjectTaggedDecorator(kernel: interfaces.Kernel):
(serviceIdentifier: (string|Symbol|interfaces.Newable<any>), key: string, value: any) => (proto: any, propertyName: string) => void;
interface IBindingInWhenProxySyntax<T> {
inTransientScope(): IBindingInWhenProxySyntax<T>;
inSingletonScope(): IBindingInWhenProxySyntax<T>;
when(constraint: (request: IRequest) => boolean): IBindingInWhenProxySyntax<T>;
whenTargetNamed(name: string): IBindingInWhenProxySyntax<T>;
whenTargetTagged(tag: string, value: any): IBindingInWhenProxySyntax<T>;
proxy(fn: (injectable: T) => T): IBindingInWhenProxySyntax<T>;
}
export function makePropertyMultiInjectDecorator(kernel: interfaces.Kernel):
(serviceIdentifier: (string|Symbol|interfaces.Newable<any>)) => (proto: any, key: string) => void;
export interface IFactory<T> extends Function {
(): T;
}
// constraint helpers
export var traverseAncerstors: (request: interfaces.Request, constraint: (request: interfaces.Request) => boolean) => boolean;
export var taggedConstraint: (tag: string) => (value: any) => (request: interfaces.Request) => boolean;
export var namedConstraint: (value: any) => (request: interfaces.Request) => boolean;
export var typeConstraint: (type: (Function|string)) => (request: interfaces.Request) => boolean;
interface IFactoryCreator<T> extends Function {
(context: IContext): IFactory<T>;
}
export interface INewable<T> {
new(...args: any[]): T;
}
export interface IProvider<T> extends Function {
(): Promise<T>;
}
interface IProviderCreator<T> extends Function {
(context: IContext): IProvider<T>;
}
export interface IContext {
kernel: IKernel;
plan: IPlan;
addPlan(plan: IPlan): void;
}
export interface IPlan {
parentContext: IContext;
rootRequest: IRequest;
}
export interface IRequest {
service: string;
parentContext: IContext;
parentRequest: IRequest;
childRequests: IRequest[];
target: ITarget;
bindings: IBinding<any>[];
addChildRequest(
service: string,
bindings: (IBinding<any>|IBinding<any>[]),
target: ITarget): IRequest;
}
export interface IBinding<T> {
runtimeIdentifier: string;
implementationType: INewable<T>;
factory: IFactoryCreator<any>;
provider: IProviderCreator<any>;
constraint: (request: IRequest) => boolean;
proxyMaker: (injectable: T) => T;
cache: T;
scope: number; // BindingScope
type: number; // BindingType
}
export interface ITarget {
service: IQueryableString;
name: IQueryableString;
metadata: Array<IMetadata>;
isArray(): boolean;
isNamed(): boolean;
isTagged(): boolean;
matchesName(name: string): boolean;
matchesTag(name: IMetadata): boolean;
}
export interface IQueryableString {
startsWith(searchString: string): boolean;
endsWith(searchString: string): boolean;
contains(searchString: string): boolean;
equals(compareString: string): boolean;
value(): string;
}
export interface IMetadata {
key: string;
value: any;
}
export var Kernel: IKernelConstructor;
export var decorate: any;
export function inject(...typeIdentifiers: string[]): (typeConstructor: any) => void;
export var tagged: any;
export var named: any;
export var paramNames: any;
}
declare module "inversify" {
@@ -0,0 +1,14 @@
/// <reference path="./jquery-truncate-html.d.ts" />
function truncateHtmlString(): string {
return $.truncate('<p>Stuff and <i>Nonsense</i></p>', {
length: 13
});
}
function truncateVirtualElement (): JQuery {
return $('<p>Stuff and <i>Nonsense</i></p>').truncate({
length: 13
});
}
+22
View File
@@ -0,0 +1,22 @@
// Type definitions for jQuery-truncate-html.js
// Project: https://github.com/kbwood/timeentry
// Definitions by: Abraão Alves <https://github.com/abraaoalves>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../jquery/jquery.d.ts"/>
interface TruncateOptions{
length?: number;
stripTags?: boolean;
words?: boolean;
noBreaks?: boolean;
ellipsis?: string;
}
interface JQuery{
truncate(options: TruncateOptions) : JQuery;
}
interface JQueryStatic {
truncate(html: string, options: TruncateOptions) : string;
}
+12
View File
@@ -0,0 +1,12 @@
/// <reference path='jwt-simple.d.ts' />
import jwt = require('jwt-simple');
var payload = { foo: 'bar' };
var secret:string = 'xxx';
// encode
var token = jwt.encode(payload, secret);
// decode
var decoded = jwt.decode(token, secret);
console.log(decoded); //=> { foo: 'bar' }
+22
View File
@@ -0,0 +1,22 @@
// Type definitions for jwt-simple v0.2.0
// Project: https://github.com/hokaccha/node-jwt-simple
// Definitions by: Ken Fukuyama <https://github.com/kenfdev>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module "jwt-simple" {
/**
* Decode jwt
* @param token
* @param key
* @param noVerify
* @api public
*/
export function decode(token:any, key:string, noVerify?:boolean):any;
/**
* Encode jwt
* @param payload
* @param key
* @param algorithm default is HS256
* @api public
*/
export function encode(payload:any, key:string, algorithm?:string):string;
}
+6 -4
View File
@@ -1,6 +1,6 @@
// Type definitions for jwt-simple v0.2.0
// Type definitions for jwt-simple v0.5.0
// Project: https://github.com/hokaccha/node-jwt-simple
// Definitions by: Ken Fukuyama <https://github.com/kenfdev>
// Definitions by: Ken Fukuyama <https://github.com/kenfdev>, Gael Magnan <https://github.com/GaelMagnan>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare module "jwt-simple" {
/**
@@ -8,15 +8,17 @@ declare module "jwt-simple" {
* @param token
* @param key
* @param noVerify
* @param algorithm default is HS256
* @api public
*/
export function decode(token:any, key:string, noVerify?:boolean):any;
export function decode(token:any, key:string, noVerify?:boolean, algorithm?:string):any;
/**
* Encode jwt
* @param payload
* @param key
* @param algorithm default is HS256
* @param options
* @api public
*/
export function encode(payload:any, key:string, algorithm?:string):string;
export function encode(payload:any, key:string, algorithm?:string, options?:any):string;
}
+16
View File
@@ -0,0 +1,16 @@
/// <reference path="../koa/koa.d.ts" />
/// <reference path="koa-compress.d.ts" />
import * as Koa from "koa";
import compress = require("koa-compress");
const app = new Koa();
app.use(compress({
filter: (ctype) => {
return /text/i.test(ctype)
},
threshold: 2048
}));
app.listen(80)
+41
View File
@@ -0,0 +1,41 @@
// Type definitions for koa-compress v2.x
// Project: https://github.com/koajs/compress
// Definitions by: Jerry Chin <https://github.com/hellopao/>
// Definitions: https://github.com/hellopao/DefinitelyTyped
/* =================== USAGE ===================
import compress = require("koa-compress");
var Koa = require('koa');
var app = new Koa();
app.use(compress());
=============================================== */
/// <reference path="../node/node.d.ts" />
/// <reference path="../koa/koa.d.ts" />
declare module "koa-compress" {
import * as Koa from "koa";
import * as zlib from "zlib";
interface CompressOptions extends zlib.ZlibOptions {
/**
* An optional function that checks the response content type to decide whether to compress. By default, it uses compressible.
*/
filter?: (content_type: string) => boolean;
/**
* Minimum response size in bytes to compress. Default 1024 bytes or 1kb.
*/
threshold?: number
}
/**
* Compress middleware for Koa
*/
function compress(options?: CompressOptions): { (ctx: Koa.Context, next?: () => any): any };
export = compress;
}
+15
View File
@@ -358,6 +358,14 @@ var imageWMS: ol.source.ImageWMS = new ol.source.ImageWMS({
serverType: stringValue,
url:stringValue
});
//
// ol.source.Source
//
const source = imageWMS as ol.source.Source;
voidValue = source.refresh();
projection = source.getProjection();
//
// ol.source.TileWMS
//
@@ -367,6 +375,9 @@ var tileWMS: ol.source.TileWMS = new ol.source.TileWMS({
url:stringValue
});
tileWMS.updateParams(tileWMS.getParams());
stringValue = tileWMS.getGetFeatureInfoUrl([0, 0], 1, "EPSG:4326", {});
//
// ol.source.WMTS
//
@@ -546,3 +557,7 @@ var modify: ol.interaction.Modify = new ol.interaction.Modify({
var draw: ol.interaction.Draw = new ol.interaction.Draw({
type: "Point"
})
const select: ol.interaction.Select = new ol.interaction.Select({
layers: (layer: ol.layer.Layer) => true,
});
+72 -28
View File
@@ -552,12 +552,12 @@ declare namespace olx {
interface SelectOptions {
addCondition?: ol.events.ConditionType;
condition?: ol.events.ConditionType;
layers?: Array<ol.layer.Layer>;
layers?: Array<ol.layer.Layer> | ((layer: ol.layer.Layer) => boolean);
style?: ol.style.Style | Array<ol.style.Style> | ol.style.StyleFunction;
removeCondition?: ol.events.ConditionType;
toggleCondition?: ol.events.ConditionType;
multi?: boolean;
features?: ol.Collection<ol.Feature>
features?: ol.Collection<ol.Feature>;
filter?: ol.interaction.SelectFilterFunction;
wrapX?: boolean;
}
@@ -4085,76 +4085,117 @@ declare namespace ol {
namespace source {
class BingMaps {
class BingMaps extends TileImage {
}
class Cluster {
class CartoDB extends XYZ {
}
class Image {
class Cluster extends Vector {
}
class ImageCanvas {
class Image extends Source {
}
class ImageArcGISRest extends Image {
}
class ImageCanvas extends Image {
}
class ImageEvent {
}
class ImageMapGuide {
class ImageMapGuide extends Image {
}
class ImageStatic {
class ImageStatic extends Image {
}
class ImageVector {
class ImageVector extends ImageCanvas {
}
class ImageWMS {
class ImageWMS extends Image {
constructor(options: olx.ImageWMSOptions);
}
class MapQuest {
class MapQuest extends XYZ {
constructor(options: any);
}
class OSM {
class OSM extends XYZ {
}
class Source {
class Source extends ol.Object {
/**
* Get the projection of the source.
* @return Projection.
*/
getProjection(): ol.proj.Projection;
/**
* Refreshes the source and finally dispatches a 'change' event.
*/
refresh(): void;
}
class Stamen {
class Stamen extends XYZ {
}
class Tile {
class Tile extends Source {
}
class TileArcGISRest {
class TileArcGISRest extends TileImage {
}
class TileDebug {
class TileDebug extends Tile {
}
class TileEvent {
}
class TileImage {
class TileImage extends UrlTile {
}
class TileJSON {
class TileJSON extends TileImage {
}
class TileUTFGrid {
class TileUTFGrid extends Tile {
}
class TileVector {
}
class TileWMS {
class TileWMS extends TileImage {
constructor(options: olx.TileWMSOptions);
/**
* Update the user-provided (WMS request) parameters.
*/
updateParams(params: any): void;
/**
* Get the user-provided (WMS request) params, i.e. those passed to the constructor through the "params" option, and possibly updated using the updateParams method.
*/
getParams(): any;
/**
* Return the GetFeatureInfo URL for the passed coordinate, resolution, and
* projection. Return `undefined` if the GetFeatureInfo URL cannot be
* constructed.
* @param coordinate Coordinate.
* @param resolution Resolution.
* @param rojection Projection.
* @param params GetFeatureInfo params. `INFO_FORMAT` at least should
* be provided. If `QUERY_LAYERS` is not provided then the layers specified
* in the `LAYERS` parameter will be used. `VERSION` should not be
* specified here.
* @return GetFeatureInfo URL.
*/
getGetFeatureInfoUrl(coordinate: ol.Coordinate, resolution: number, projection: ol.proj.ProjectionLike, params: {}): string;
}
class Vector {
class UrlTile extends Tile {
}
class Vector extends Source {
constructor(opts?: olx.source.VectorOptions)
/**
* Add a single feature to the source. If you want to add a batch of features at once,
@@ -4198,14 +4239,17 @@ declare namespace ol {
class VectorEvent {
}
class WMTS {
class VectorTile extends UrlTile {
}
class WMTS extends TileImage {
constructor(options: olx.source.WMTSOptions);
}
class XYZ {
class XYZ extends TileImage {
}
class Zoomify {
class Zoomify extends TileImage {
}
// Namespaces
+31
View File
@@ -0,0 +1,31 @@
/// <reference path="../react/react.d.ts" />
/// <reference path="../react/react-dom.d.ts" />
/// <reference path="./react-slick.d.ts" />
import * as React from "react"
import * as ReactDOM from "react-dom"
import * as Slider from "react-slick"
class SliderTest extends React.Component<React.Props<{}>, {}> {
render() {
let settings = {
speed: 500,
slidesToShow: 8,
slidesToScroll: 1,
draggable: false,
infinite: false
};
return (
<div>
<Slider {...settings} >
<div><h1>Slide1</h1></div>
<div><h1>Slide2</h1></div>
</Slider>
</div>
)
}
}
ReactDOM.render(<SliderTest />, document.body);
+50
View File
@@ -0,0 +1,50 @@
// Type definitions for react-slick
// Project: https://github.com/akiran/react-slick
// Definitions by: Andrey Balokha <https://github.com/andrewBalekha>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../react/react.d.ts"/>
interface __config {
className?: string
adaptiveHeight?: boolean
arrows?: boolean
autoplay?: boolean
autoplaySpeed?: number // integer
centerMode?: boolean
centerPadding?: string | any
cssEase?: string | any
dots?: boolean
dotsClass?: string
draggable?: boolean
easing?: string
fade?: boolean
focusOnSelect?: boolean
infinite?: boolean // should the gallery wrap around it's contents
initialSlide?: number // int
lazyLoad?: boolean
rtl?: boolean
slide?: string
slidesToShow?: number // int
slidesToScroll?: number // int
speed?: number //int
swipe?: boolean
swipeToSlide?: boolean
touchMove?: boolean
touchThreshold?: number // int
variableWidth?: boolean
useCSS?: boolean
vertical?: boolean
afterChange?: (() => void)
beforeChange?: (() => void)
slickGoTo?: number // int
}
interface Slider extends __config {
responsive?: { breakpoint: number; settings: __config}[]
}
declare module "react-slick" {
var Slider: __React.ClassicComponentClass<Slider>;
export = Slider;
}
+33
View File
@@ -0,0 +1,33 @@
/// <reference path="resumablejs.d.ts" />
import { Resumable, ResumableFile } from 'resumablejs';
let resumable: Resumable = new Resumable({chunkSize: 123});
let resumableDefaultOpts: Resumable = new Resumable({});
resumable.addFile(null, null);
resumable.assignBrowse(document.getElementById("test"), true);
resumable.assignBrowse([document.getElementById("test")], true);
resumable.assignDrop(document.getElementById("test"));
resumable.assignDrop([document.getElementById("test")]);
resumable.unAssignDrop(document.getElementById("test"));
resumable.unAssignDrop([document.getElementById("test")]);
resumable.cancel();
let defaults: Object = resumable.defaults;
let events: any[] = resumable.events;
let files: any[] = resumable.files;
resumable.fire();
let {} = resumable.getFromUniqueIdentifier('test');
let {} = resumable.getOpt('test');
let size: number = resumable.getSize();
resumable.handleChangeEvent(null);
resumable.handleDropEvent(null);
let isUploading: boolean = resumable.isUploading();
resumable.on('test', function() {});
let opts: Object = resumable.opts;
resumable.pause();
let progress:number = resumable.progress();
resumable.removeFile(null);
let support: boolean = resumable.support;
resumable.upload();
resumable.uploadNextChunk();
let version:number = resumable.version;
+374
View File
@@ -0,0 +1,374 @@
// Type definitions for Resumable.js v1.0.2
// Project: https://github.com/23/resumable.js
// Definitions by: Daniel McAssey <https://github.com/DanielMcAssey>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare namespace Resumable {
interface ConfigurationHash {
/**
* The target URL for the multipart POST request. This can be a string or a function that allows you you to construct and return a value, based on supplied params. (Default: /)
**/
target?: string;
/**
* The size in bytes of each uploaded chunk of data. The last uploaded chunk will be at least this size and up to two the size, see Issue #51 for details and reasons. (Default: 1*1024*1024)
**/
chunkSize?: number;
/**
* Force all chunks to be less or equal than chunkSize. Otherwise, the last chunk will be greater than or equal to chunkSize. (Default: false)
**/
forceChunkSize?: boolean;
/**
* Number of simultaneous uploads (Default: 3)
**/
simultaneousUploads?: number;
/**
* The name of the multipart POST parameter to use for the file chunk (Default: file)
**/
fileParameterName?: string;
/**
* The name of the chunk index (base-1) in the current upload POST parameter to use for the file chunk (Default: resumableChunkNumber)
*/
chunkNumberParameterName?: string;
/**
* The name of the total number of chunks POST parameter to use for the file chunk (Default: resumableTotalChunks)
*/
totalChunksParameterName?: string;
/**
* The name of the general chunk size POST parameter to use for the file chunk (Default: resumableChunkSize)
*/
chunkSizeParameterName?: string;
/**
* The name of the total file size number POST parameter to use for the file chunk (Default: resumableTotalSize)
*/
totalSizeParameterName?: string;
/**
* The name of the unique identifier POST parameter to use for the file chunk (Default: resumableIdentifier)
*/
identifierParameterName?: string;
/**
* The name of the original file name POST parameter to use for the file chunk (Default: resumableFilename)
*/
fileNameParameterName?: string;
/**
* The name of the file's relative path POST parameter to use for the file chunk (Default: resumableRelativePath)
*/
relativePathParameterName?: string;
/**
* The name of the current chunk size POST parameter to use for the file chunk (Default: resumableCurrentChunkSize)
*/
currentChunkSizeParameterName?: string;
/**
* The name of the file type POST parameter to use for the file chunk (Default: resumableType)
*/
typeParameterName?: string;
/**
* Extra parameters to include in the multipart POST with data. This can be an object or a function. If a function, it will be passed a ResumableFile and a ResumableChunk object (Default: {})
**/
query?: Object;
/**
* Method for chunk test request. (Default: 'GET')
**/
testMethod?: string;
/**
* Method for chunk upload request. (Default: 'POST')
**/
uploadMethod?: string;
/**
* Extra prefix added before the name of each parameter included in the multipart POST or in the test GET. (Default: '')
**/
parameterNamespace?: string;
/**
* Extra headers to include in the multipart POST with data. This can be an object or a function that allows you to construct and return a value, based on supplied file (Default: {})
**/
headers?: Object | ((file: ResumableFile) => Object);
/**
* Method to use when POSTing chunks to the server (multipart or octet) (Default: multipart)
**/
method?: string;
/**
* Prioritize first and last chunks of all files. This can be handy if you can determine if a file is valid for your service from only the first or last chunk. For example, photo or video meta data is usually located in the first part of a file, making it easy to test support from only the first chunk. (Default: false)
**/
prioritizeFirstAndLastChunk?: boolean;
/**
* Make a GET request to the server for each chunks to see if it already exists. If implemented on the server-side, this will allow for upload resumes even after a browser crash or even a computer restart. (Default: true)
**/
testChunks?: boolean;
/**
* Optional function to process each chunk before testing & sending. Function is passed the chunk as parameter, and should call the preprocessFinished method on the chunk when finished. (Default: null)
**/
preprocess?: (chunk: ResumableChunk) => ResumableChunk;
/**
* Override the function that generates unique identifiers for each file. (Default: null)
**/
generateUniqueIdentifier?: () => string;
/**
* Indicates how many files can be uploaded in a single session. Valid values are any positive integer and undefined for no limit. (Default: undefined)
**/
maxFiles?: number;
/**
* A function which displays the please upload n file(s) at a time message. (Default: displays an alert box with the message Please n one file(s) at a time.)
**/
maxFilesErrorCallback?: (files: ResumableFile, errorCount: number) => void;
/**
* The minimum allowed file size. (Default: undefined)
**/
minFileSize?: boolean;
/**
* A function which displays an error a selected file is smaller than allowed. (Default: displays an alert for every bad file.)
**/
minFileSizeErrorCallback?:(file: ResumableFile, errorCount: number) => void;
/**
* The maximum allowed file size. (Default: undefined)
**/
maxFileSize?: boolean;
/**
* A function which displays an error a selected file is larger than allowed. (Default: displays an alert for every bad file.)
**/
maxFileSizeErrorCallback?: (file: ResumableFile, errorCount: number) => void;
/**
* The file types allowed to upload. An empty array allow any file type. (Default: [])
**/
fileType?: string[];
/**
* A function which displays an error a selected file has type not allowed. (Default: displays an alert for every bad file.)
**/
fileTypeErrorCallback?: (file: ResumableFile, errorCount: number) => void;
/**
* The maximum number of retries for a chunk before the upload is failed. Valid values are any positive integer and undefined for no limit. (Default: undefined)
**/
maxChunkRetries?: number;
/**
* The number of milliseconds to wait before retrying a chunk on a non-permanent error. Valid values are any positive integer and undefined for immediate retry. (Default: undefined)
**/
chunkRetryInterval?: number;
/**
* Standard CORS requests do not send or set any cookies by default. In order to include cookies as part of the request, you need to set the withCredentials property to true. (Default: false)
**/
withCredentials?: boolean;
}
class Resumable {
constructor(options:ConfigurationHash);
/**
* A boolean value indicator whether or not Resumable.js is supported by the current browser.
**/
support: boolean;
/**
* A hash object of the configuration of the Resumable.js instance.
**/
opts: ConfigurationHash;
/**
* An array of ResumableFile file objects added by the user (see full docs for this object type below).
**/
files: ResumableFile[];
defaults: ConfigurationHash;
events: Event[];
version: number;
/**
* Assign a browse action to one or more DOM nodes. Pass in true to allow directories to be selected (Chrome only).
**/
assignBrowse(domNode: Element, isDirectory: boolean): void;
assignBrowse(domNodes: Element[], isDirectory: boolean): void;
/**
* Assign one or more DOM nodes as a drop target.
**/
assignDrop(domNode: Element): void;
assignDrop(domNodes: Element[]): void;
unAssignDrop(domNode: Element): void;
unAssignDrop(domNodes: Element[]): void;
/**
* Start or resume uploading.
**/
upload(): void;
uploadNextChunk(): void;
/**
* Pause uploading.
**/
pause(): void;
/**
* Cancel upload of all ResumableFile objects and remove them from the list.
**/
cancel(): void;
fire(): void;
/**
* Returns a float between 0 and 1 indicating the current upload progress of all files.
**/
progress(): number;
/**
* Returns a boolean indicating whether or not the instance is currently uploading anything.
**/
isUploading(): boolean;
/**
* Add a HTML5 File object to the list of files.
**/
addFile(file: File, event: Event): void;
/**
* Cancel upload of a specific ResumableFile object on the list from the list.
**/
removeFile(file: ResumableFile): void;
/**
* Look up a ResumableFile object by its unique identifier.
**/
getFromUniqueIdentifier(uniqueIdentifier: string): void;
/**
* Returns the total size of the upload in bytes.
**/
getSize(): number;
getOpt(o: string): any;
// Events
/**
* Change event handler
**/
handleChangeEvent(e: Event): void;
/**
* Drop event handler
**/
handleDropEvent(e: Event): void;
/**
* A specific file was completed.
**/
on(event: 'fileSuccess', callback: (file: ResumableFile) => void): void;
/**
* Uploading progressed for a specific file.
**/
on(event: 'fileProgress', callback: (file: ResumableFile) => void): void;
/**
* A new file was added. Optionally, you can use the browser event object from when the file was added.
**/
on(event: 'fileAdded', callback: (file: ResumableFile, event: DragEvent) => void): void;
/**
* New files were added.
**/
on(event: 'filesAdded', callback: (files: ResumableFile[]) => void): void;
/**
* Something went wrong during upload of a specific file, uploading is being retried.
**/
on(event: 'fileRetry', callback: (file: ResumableFile) => void): void;
/**
* An error occurred during upload of a specific file.
**/
on(event: 'fileError', callback: (file: ResumableFile, message: string) => void): void;
/**
* Upload has been started on the Resumable object.
**/
on(event: 'uploadStart', callback: () => void): void;
/**
* Uploading completed.
**/
on(event: 'complete', callback: () => void): void;
/**
* Uploading progress.
**/
on(event: 'progress', callback: () => void): void;
/**
* An error, including fileError, occurred.
**/
on(event: 'error', callback: (message: string, file: ResumableFile) => void): void;
/**
* Uploading was paused.
**/
on(event: 'pause', callback: () => void): void;
/**
* Triggers before the items are cancelled allowing to do any processing on uploading files.
**/
on(event: 'beforeCancel', callback: () => void): void;
/**
* Uploading was canceled.
**/
on(event: 'cancel', callback: () => void): void;
/**
* Started preparing file for upload
**/
on(event: 'chunkingStart', callback: (file: ResumableFile) => void): void;
/**
* Show progress in file preparation
**/
on(event: 'chunkingProgress', callback: (file: ResumableFile, ratio: number) => void): void;
/**
* File is ready for upload
**/
on(event: 'chunkingComplete', callback: (file: ResumableFile) => void): void;
/**
* Listen to all the events listed above with the same callback function.
**/
on(event: 'catchAll', callback: () => void): void;
/**
* Listen for event from Resumable.js (see below)
**/
on(event: string, callback: Function): void;
}
interface ResumableFile {
/**
* A back-reference to the parent Resumable object.
**/
resumableObj: Resumable;
/**
* The correlating HTML5 File object.
**/
file: File;
/**
* The name of the file.
**/
fileName: string;
/**
* The relative path to the file (defaults to file name if relative path doesn't exist)
**/
relativePath: string;
/**
* Size in bytes of the file.
**/
size: number;
/**
* A unique identifier assigned to this file object. This value is included in uploads to the server for reference, but can also be used in CSS classes etc when building your upload UI.
**/
uniqueIdentifier: string;
/**
* An array of ResumableChunk items. You shouldn't need to dig into these.
**/
chunks: ResumableChunk[];
/**
* Returns a float between 0 and 1 indicating the current upload progress of the file. If relative is true, the value is returned relative to all files in the Resumable.js instance.
**/
progress: (relative: boolean) => number;
/**
* Abort uploading the file.
**/
abort: () => void;
/**
* Abort uploading the file and delete it from the list of files to upload.
**/
cancel: () => void;
/**
* Retry uploading the file.
**/
retry: () => void;
/**
* Rebuild the state of a ResumableFile object, including reassigning chunks and XMLHttpRequest instances.
**/
bootstrap: () => void;
/**
* Returns a boolean indicating whether file chunks is uploading.
**/
isUploading: () => boolean;
/**
* Returns a boolean indicating whether the file has completed uploading and received a server response.
**/
isComplete: () => boolean;
}
interface ResumableChunk {}
}
declare module 'resumablejs' {
export = Resumable;
}
+3
View File
@@ -0,0 +1,3 @@
/// <reference path="./revalidator.d.ts" />
revalidator.validate(null, null, null);
+48
View File
@@ -0,0 +1,48 @@
// Type definitions for revalidator 0.3.1
// Project: https://github.com/flatiron/revalidator
// Definitions by: Jason Turner <https://github.com/brewsoftware>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare module Revalidator {
interface RevalidatorStatic {
validate(object: any, schema: ISchema, options: any): IReturnMessage;
}
interface IErrrorProperty {
property: string;
message: string;
}
interface IReturnMessage {
valid: boolean;
errors: IErrrorProperty[];
}
interface ISchema {
required?: boolean;
type: string;
pattern?: any;
maxLength?: number;
minLength?: number;
minimum?: number;
maximum?: number;
allowEmpty: boolean;
exclusiveMinimum: number;
exclusiveMaximum?: number;
divisibleBy?: number;
minItems?: number;
maxItems?: number;
uniqueItems?: boolean;
enum?: any;
format?: string;
conform?: (data:any) => boolean;
depdendencies?: string;
}
}
declare var revalidator: Revalidator.RevalidatorStatic;
declare module "revalidator" {
export = revalidator;
}
+3
View File
@@ -11,7 +11,10 @@ const wsdlOptions = { name: 'value' };
soap.createClient(url, wsdlOptions, function(err: any, client: soap.Client) {
let securityOptions = { 'hasTimeStamp': false };
client.setSecurity(new soap.WSSecurity('user', 'password', securityOptions));
let defaults = {'rejectUnauthorized': false};
client.setSecurity(new soap.ClientSSLSecurity('/path/to/key', '/path/to/cert', '/path/to/ca',defaults));
client.addSoapHeader({});
client.setEndpoint('http://localhost');
client['create']({ name: 'value' }, function(err, result) {
// result is an object
});
+8 -2
View File
@@ -8,13 +8,19 @@
declare module 'soap' {
import * as events from 'events';
class WSSecurity {
interface Security {
}
class WSSecurity implements Security {
constructor(username: string, password: string, options: any);
}
class ClientSSLSecurity implements Security {
constructor(key: string, cert: string, ca: string, defaults: any);
}
interface Client extends events.EventEmitter {
setSecurity(s: WSSecurity): void;
setSecurity(s: Security): void;
[method: string]: (args: any, fn: (err: any, result: any) => void, options?: any, extraHeaders?: any) => void;
addSoapHeader(headJSON: any): void;
setEndpoint(endpoint: string): void;
}
function createClient(wsdlPath: string, options: any, fn: (err: any, client: Client) => void): void;
+4
View File
@@ -494,6 +494,10 @@ declare namespace umbraco.services {
width?: number;
/*strips the modal from any animation and wrappers, used when you want to inject a dialog into an existing container*/
inline?: boolean;
/**
* It will set this value as a property on the dialog controller's scope as $scope.dialogData
*/
dialogData?: any;
}
/**
+22 -2
View File
@@ -3,8 +3,28 @@
let voidpromise: Promise<void>;
var config: RTCConfiguration =
{ iceServers: [{ urls: "stun.l.google.com:19302" }] };
var minimalConfig: RTCConfiguration = {};
var config: RTCConfiguration = {
iceServers: [
{
// Single url
urls: "stun.l.google.com:19302"
},
{
// List of urls and credentials
urls: ["another-stun.example.com"],
username: "dude",
credential: "pass",
credentialType: "token"
},
],
iceTransportPolicy: "relay",
bundlePolicy: "max-compat",
rtcpMuxPolicy: "negotiate",
peerIdentity: "dude",
certificates: [{expires: 1337}],
iceCandidatePoolSize: 5
};
var constraints: RTCMediaConstraints =
{ mandatory: { offerToReceiveAudio: true, offerToReceiveVideo: true } };
+35 -12
View File
@@ -3,13 +3,7 @@
// Definitions by: Ken Smith <https://github.com/smithkl42/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
//
// Definitions taken from http://dev.w3.org/2011/webrtc/editor/webrtc.html
//
// For example code see:
// https://code.google.com/p/webrtc/source/browse/stable/samples/js/apprtc/js/main.js
//
// For a generic implementation see that deals with browser differences, see:
// https://code.google.com/p/webrtc/source/browse/stable/samples/js/base/adapter.js
// W3 Spec: https://www.w3.org/TR/webrtc/#idl-def-RTCIceServer
/// <reference path='MediaStream.d.ts' />
@@ -20,17 +14,46 @@
// TODO(2): get Typescript to have union types as WebRtc uses them.
// https://typescript.codeplex.com/workitem/1364
interface RTCConfiguration {
iceServers: RTCIceServer[];
// https://www.w3.org/TR/webrtc/#idl-def-RTCIceTransportPolicy
type RTCIceTransportPolicy = 'public' | 'relay' | 'all';
// https://www.w3.org/TR/webrtc/#idl-def-RTCBundlePolicy
type RTCBundlePolicy = 'balanced' | 'max-compat' | 'max-bundle';
// https://www.w3.org/TR/webrtc/#idl-def-RTCRtcpMuxPolicy
type RTCRtcpMuxPolicy = 'negotiate' | 'require';
// https://www.w3.org/TR/webrtc/#idl-def-RTCCertificate
interface RTCCertificate {
expires: number;
}
// https://www.w3.org/TR/webrtc/#idl-def-RTCConfiguration
// https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/RTCPeerConnection#RTCConfiguration_dictionary
interface RTCConfiguration {
iceServers ?: RTCIceServer[]; // optional according to mozilla docs
iceTransportPolicy ?: RTCIceTransportPolicy; // default = 'all'
bundlePolicy ?: RTCBundlePolicy; // default = 'balanced'
rtcpMuxPolicy ?: RTCRtcpMuxPolicy; // default = 'require'
peerIdentity ?: string; // default = null
certificates ?: RTCCertificate[]; // default is auto-generated
iceCandidatePoolSize ?: number; // default = 0
}
declare var RTCConfiguration: {
prototype: RTCConfiguration;
new (): RTCConfiguration;
};
// https://www.w3.org/TR/webrtc/#idl-def-RTCIceCredentialType
type RTCIceCredentialType = 'password' | 'token';
// https://www.w3.org/TR/webrtc/#idl-def-RTCIceServer
interface RTCIceServer {
urls: string;
urls: string | string[];
username?: string;
credential?: string;
credentialType?: RTCIceCredentialType; // default = 'password'
}
declare var RTCIceServer: {
prototype: RTCIceServer;
@@ -42,7 +65,7 @@ interface mozRTCPeerConnection extends RTCPeerConnection {
}
declare var mozRTCPeerConnection: {
prototype: mozRTCPeerConnection;
new (settings: RTCPeerConnectionConfig,
new (settings?: RTCConfiguration,
constraints?:RTCMediaConstraints): mozRTCPeerConnection;
};
// webkit (Chrome) specific prefixes.
@@ -50,7 +73,7 @@ interface webkitRTCPeerConnection extends RTCPeerConnection {
}
declare var webkitRTCPeerConnection: {
prototype: webkitRTCPeerConnection;
new (settings: RTCPeerConnectionConfig,
new (settings?: RTCConfiguration,
constraints?:RTCMediaConstraints): webkitRTCPeerConnection;
};
+89 -75
View File
@@ -8201,6 +8201,7 @@ declare namespace Windows {
getDataPlanStatus(): Windows.Networking.Connectivity.DataPlanStatus;
getLocalUsage(StartTime: Date, EndTime: Date): Windows.Networking.Connectivity.DataUsage;
getLocalUsage(StartTime: Date, EndTime: Date, States: Windows.Networking.Connectivity.RoamingStates): Windows.Networking.Connectivity.DataUsage;
getSignalBars(): Windows.Foundation.IReference<number>;
}
export class ConnectionCost implements Windows.Networking.Connectivity.IConnectionCost {
approachingDataLimit: boolean;
@@ -8267,6 +8268,7 @@ declare namespace Windows {
getDataPlanStatus(): Windows.Networking.Connectivity.DataPlanStatus;
getLocalUsage(StartTime: Date, EndTime: Date): Windows.Networking.Connectivity.DataUsage;
getLocalUsage(StartTime: Date, EndTime: Date, States: Windows.Networking.Connectivity.RoamingStates): Windows.Networking.Connectivity.DataUsage;
getSignalBars(): Windows.Foundation.IReference<number>;
}
export class LanIdentifier implements Windows.Networking.Connectivity.ILanIdentifier {
infrastructureId: Windows.Networking.Connectivity.LanIdentifierData;
@@ -11344,15 +11346,18 @@ declare namespace Windows {
}
export interface ILauncherOptions {
contentType: string;
desiredRemainingView: Windows.UI.ViewManagement.ViewSizePreference;
displayApplicationPicker: boolean;
fallbackUri: Windows.Foundation.Uri;
preferredApplicationDisplayName: string;
preferredApplicationPackageFamilyName: string;
treatAsUntrusted: boolean;
uI: Windows.System.LauncherUIOptions;
}
export class LauncherOptions implements Windows.System.ILauncherOptions {
contentType: string;
desiredRemainingView: Windows.UI.ViewManagement.ViewSizePreference;
displayApplicationPicker: boolean;
fallbackUri: Windows.Foundation.Uri;
preferredApplicationDisplayName: string;
@@ -11594,87 +11599,96 @@ declare namespace Windows {
}
declare namespace Windows {
export module UI {
export module ViewManagement {
export enum ApplicationViewState {
fullScreenLandscape,
filled,
snapped,
fullScreenPortrait,
}
export module ViewManagement {
export enum ViewSizePreference {
default = 0,
useLess = 1,
useHalf = 2,
useMore = 3,
useMinimum = 4,
useNone = 5
}
export enum ApplicationViewState {
fullScreenLandscape,
filled,
snapped,
fullScreenPortrait,
}
/**
* Defines an instance of a window (app view) and the information that describes it.
**/
export class ApplicationView {
/**
* Gets the window (app view) for the current app.
**/
static getForCurrentView(): ApplicationView;
/**
* Defines an instance of a window (app view) and the information that describes it.
* Attempts to unsnap a previously snapped app. This call will only succeed when the app is running in the foreground.
**/
export class ApplicationView {
/**
* Gets the window (app view) for the current app.
**/
static getForCurrentView(): ApplicationView;
/**
* Attempts to unsnap a previously snapped app. This call will only succeed when the app is running in the foreground.
**/
static tryUnsnap(): boolean;
/**
* Gets the state of the current app view.
**/
static value: Windows.UI.ViewManagement.ApplicationViewState;
/**
* Indicates whether the app terminates when the last window is closed.
**/
static terminateAppOnFinalViewClose: boolean;
/**
* Gets the current orientation of the window (app view) with respect to the display.
**/
orientation: ApplicationViewOrientation;
/**
* Gets or sets the displayed title of the window.
**/
title: string;
/**
* Gets or sets whether screen capture is enabled for the window (app view).
**/
isScreenCaptureEnabled: boolean;
/**
* Gets whether the window (app view) is on the Windows lock screen.
**/
isOnLockScreen: boolean;
/**
* Gets whether the window(app view) is full screen or not.
**/
isFullScreen: boolean;
/**
* Gets the current ID of the window (app view) .
**/
id: number;
/**
* Gets whether the current window (app view) is adjacent to the right edge of the screen.
**/
adjacentToRightDisplayEdge: boolean;
/**
* Gets whether the current window (app view) is adjacent to the left edge of the screen.
**/
adjacentToLeftDisplayEdge: number;
/**
* Gets the title bar of the app.
**/
titleBar: ApplicationViewTitleBar;
}
static tryUnsnap(): boolean;
/**
* Defines the set of display orientation modes for a window (app view).
* Gets the state of the current app view.
**/
static value: Windows.UI.ViewManagement.ApplicationViewState;
/**
* Indicates whether the app terminates when the last window is closed.
**/
static terminateAppOnFinalViewClose: boolean;
/**
* Gets the current orientation of the window (app view) with respect to the display.
**/
orientation: ApplicationViewOrientation;
/**
* Gets or sets the displayed title of the window.
**/
title: string;
/**
* Gets or sets whether screen capture is enabled for the window (app view).
**/
isScreenCaptureEnabled: boolean;
/**
* Gets whether the window (app view) is on the Windows lock screen.
**/
isOnLockScreen: boolean;
/**
* Gets whether the window(app view) is full screen or not.
**/
isFullScreen: boolean;
/**
* Gets the current ID of the window (app view) .
**/
id: number;
/**
* Gets whether the current window (app view) is adjacent to the right edge of the screen.
**/
adjacentToRightDisplayEdge: boolean;
/**
* Gets whether the current window (app view) is adjacent to the left edge of the screen.
**/
adjacentToLeftDisplayEdge: number;
/**
* Gets the title bar of the app.
**/
titleBar: ApplicationViewTitleBar;
}
/**
* Defines the set of display orientation modes for a window (app view).
**/
export enum ApplicationViewOrientation {
landscape,
portrait
Vendored
+1 -1
View File
@@ -110,7 +110,7 @@ declare module "ws" {
constructor(options?: IServerOptions, callback?: Function);
close(): void;
close(cb?: () => {}): void;
handleUpgrade(request: http.ServerRequest, socket: net.Socket,
upgradeHead: Buffer, callback: (client: WebSocket) => void): void;
Vendored
+2 -2
View File
@@ -50,7 +50,7 @@ declare namespace Wu {
slice<T>(iter: Iterable<T>): WuIterable<T>;
slice<T>(start: number, iter: Iterable<T>): WuIterable<T>;
slice<T>(start: number, stop: number, iter: Iterable<T>): WuIterable<T>;
some<T>(fn: Filter<T>, iter: Iterable<T>): WuIterable<T>;
some<T>(fn: Filter<T>, iter: Iterable<T>): boolean;
spreadMap<T>(fn: (...x: any[]) => T, iter: Iterable<any[]>): WuIterable<T>;
take<T>(n: number, iter: Iterable<T>): WuIterable<T>;
takeWhile<T>(fn: Filter<T>, iter: Iterable<T>): WuIterable<T>;
@@ -100,7 +100,7 @@ declare namespace Wu {
slice(): WuIterable<T>;
slice(start: number): WuIterable<T>;
slice(start: number, stop: number): WuIterable<T>;
some(fn: Filter<T>): WuIterable<T>;
some(fn: Filter<T>): boolean;
spreadMap(fn: (...x: any[]) => T, iter: Iterable<any[]>): WuIterable<T>;
take(n: number): WuIterable<T>;
takeWhile(fn: Filter<T>): WuIterable<T>;