Merge branch 'master' of ssh://github.com/DefinitelyTyped/DefinitelyTyped into patch-1

This commit is contained in:
Christophe Hurpeau
2018-11-23 09:55:05 +01:00
626 changed files with 390440 additions and 6324 deletions
+1
View File
@@ -46,6 +46,7 @@ npm-debug.log
.settings/launch.json
.vs
.vscode
.history
# yarn
yarn.lock
+6
View File
@@ -636,6 +636,12 @@
"sourceRepoURL": "https://github.com/mikedeboer/node-github",
"asOfVersion": "7.1.0"
},
{
"libraryName": "gitlab",
"typingsPackageName": "gitlab",
"sourceRepoURL": "https://github.com/jdalrymple/node-gitlab",
"asOfVersion": "2.0.0"
},
{
"libraryName": "graphene-pk11",
"typingsPackageName": "graphene-pk11",
-63
View File
@@ -1,63 +0,0 @@
import {
ACLType,
CopyAndPutMetaResult,
CopyObjectOptions,
DeleteMultiOptions,
DeleteMultiResult,
GetObjectOptions,
GetObjectResult,
GetStreamOptions,
GetStreamResult,
HeadObjectOptions,
HeadObjectResult,
ListObjectResult,
ListObjectsQuery,
NormalSuccessResponse,
PutObjectOptions,
PutObjectResult,
PutStreamOptions,
RequestOptions,
SignatureUrlOptions,
UserMeta
} from "./index";
export interface ClusterType {
host: string;
accessKeyId: string;
accessKeySecret: string;
}
export interface ClusterOptions {
clusters: ClusterType[];
schedule?: string;
}
export class Cluster {
constructor(options: ClusterOptions)
list(query: ListObjectsQuery | null, options: RequestOptions): Promise<ListObjectResult>;
put(name: string, file: any, options?: PutObjectOptions): Promise<PutObjectResult>;
putStream(name: string, stream: any, options?: PutStreamOptions): Promise<{ name: string, res: NormalSuccessResponse }>;
head(name: string, options?: HeadObjectOptions): Promise<HeadObjectResult>;
get(name: string, file?: any, options?: GetObjectOptions): Promise<GetObjectResult>;
getStream(name?: string, options?: GetStreamOptions): Promise<GetStreamResult>;
delete(name: string, options?: RequestOptions): Promise<NormalSuccessResponse>;
copy(name: string, sourceName: string, options?: CopyObjectOptions): Promise<CopyAndPutMetaResult>;
putMeta(name: string, meta: UserMeta, options: RequestOptions): Promise<CopyAndPutMetaResult>;
deleteMulti(names: string[], options?: DeleteMultiOptions): Promise<DeleteMultiResult>;
signatureUrl(name: string, options?: SignatureUrlOptions): string;
putACL(name: string, acl: ACLType, options?: RequestOptions): Promise<NormalSuccessResponse>;
restore(name: string, options?: RequestOptions): Promise<NormalSuccessResponse>;
}
-71
View File
@@ -1,71 +0,0 @@
import { NormalSuccessResponse, RequestOptions } from "./index";
export interface ImageClientOptions {
imageHost: string; // your image service domain that binding to a OSS bucket
accessKeyId: string; // access key you create on aliyun console website
accessKeySecret: string; // access secret you create
bucket: string; // the default bucket you want to access If you don't have any bucket, please use putBucket() create one first.
region?: string; // the bucket data region location, please see Data Regions, default is oss-cn-hangzhou
internal?: boolean; // access OSS with aliyun internal network or not, default is false If your servers are running on aliyun too, you can set true to save lot of money.
timeout?: string | number; // instance level timeout for all operations, default is 60s
}
export interface ImageGetOptions {
timeout?: number;
headers?: object;
}
export interface StyleData {
Name: string; // style name
Content: string; // style content
CreateTime: string; // style create time
LastModifyTime: string; // style last modify time
}
export class ImageClient {
constructor(options: ImageClientOptions)
/**
* Get an image from the image channel.
*/
get(name: string, file?: any, options?: ImageGetOptions): Promise<{ content: any, res: NormalSuccessResponse }>;
/**
* Get an image read stream.
*/
getStream(name: string, options?: ImageGetOptions): Promise<{ stream: any, res: NormalSuccessResponse }>;
/**
* Get a image exif info by image object name from the image channel.
*/
getExif(name: string, options?: RequestOptions): Promise<{ data: object, res: NormalSuccessResponse }>;
/**
* Get a image info and exif info by image object name from the image channel.
*/
getInfo(name: string, options?: RequestOptions): Promise<{ data: object, res: NormalSuccessResponse }>;
/**
* todo
*/
putStyle(name: string, style: string, options?: RequestOptions): Promise<{ data: object, res: NormalSuccessResponse }>;
/**
* Get a style by name from the image channel.
*/
getStyle(name: string, options?: RequestOptions): Promise<{ data: StyleData, res: NormalSuccessResponse}>;
/**
* Get all styles from the image channel.
*/
listStyle(options?: RequestOptions): Promise<StyleData[]>;
/**
* todo
*/
deleteStyle(styleName: string, options?: RequestOptions): Promise<NormalSuccessResponse>;
/**
* Create a signature url for directly download.
*/
signatureUrl(name: string, options?: { expires?: string, timeout?: string }): string;
}
+18 -27
View File
@@ -1,34 +1,25 @@
import OSS from "ali-oss";
import * as OSS from 'ali-oss';
const client = new OSS({
const ossOptions: OSS.Options = {
accessKeyId: 'your access key',
accessKeySecret: 'your access secret',
bucket: 'your bucket name',
region: 'oss-cn-hangzhou'
});
};
const ImageClient = OSS.ImageClient({
imageHost: 'host',
accessKeySecret: "secret",
accessKeyId: 'id',
bucket: "",
internal: false,
region: "",
timeout: 2000
});
const client = new OSS(ossOptions);
const cluster = OSS.Cluster({
clusters: [
{
accessKeyId: 'id',
accessKeySecret: 'secret',
host: ""
},
{
accessKeyId: 'id',
accessKeySecret: 'secret',
host: ""
},
],
schedule: 'masterSlave',
});
const clusterOptions: OSS.ClusterOptions = {
clusters: [],
};
const clusterClient = new OSS.Cluster(clusterOptions);
const imageOptions: OSS.ImageClientOptions = {
imageHost: 'xxxx',
accessKeyId: 'xxxx',
accessKeySecret: 'xxxx',
bucket: 'xxxx'
};
const imageClient = new OSS.ImageClient(imageOptions);
+576 -463
View File
File diff suppressed because it is too large Load Diff
-2
View File
@@ -18,8 +18,6 @@
},
"files": [
"index.d.ts",
"ImageClient.d.ts",
"Cluster.d.ts",
"ali-oss-tests.ts"
]
}
+4 -1
View File
@@ -1,3 +1,6 @@
{
"extends": "dtslint/dt.json"
"extends": "dtslint/dt.json",
"rules": {
"no-mergeable-namespace": false
}
}
+1
View File
@@ -76,6 +76,7 @@ declare module 'angular' {
interface IConfirmDialog extends IPresetDialog<IConfirmDialog> {
cancel(cancel: string): IConfirmDialog;
multiple(multiple: boolean): IConfirmDialog;
}
interface IPromptDialog extends IPresetDialog<IPromptDialog> {
+1 -1
View File
@@ -22,7 +22,7 @@ Object.keys({
}).forEach((color) => {
const cname = color.replace(/([a-z])([A-Z])/g, (_: string, l: string, u: string): string => `${l} ${u.toLowerCase()}`);
((<(...anything: any[]) => ansi.Cursor> cursor[color])()
((cursor[color] as (...anything: any[]) => ansi.Cursor)()
.bold()
.bg)[color === 'blue' || color === 'brightBlue' ? 'black' : 'blue']()
.write(
@@ -0,0 +1,7 @@
import { addPath, enableForDir, removePath } from 'app-module-path';
addPath('/tmp');
enableForDir('/tmp');
removePath('/tmp');
+11
View File
@@ -0,0 +1,11 @@
// Type definitions for app-module-path 2.2
// Project: https://github.com/patrick-steele-idem/app-module-path-node
// Definitions by: Timur Manyanov <https://github.com/darkwebdev>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.6
export function addPath(path: string, parent?: any): void;
export function enableForDir(dir: string): void;
export function removePath(path: string): void;
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"app-module-path-tests.ts"
]
}
+3
View File
@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}
+9 -9
View File
@@ -390,22 +390,22 @@ async.auto({
get_data: function (callback: AsyncResultCallback<any>) { },
make_folder: function (callback: AsyncResultCallback<any>) { },
//arrays with different types are not accepted by TypeScript.
write_file: ['get_data', 'make_folder', <any>function (callback: AsyncResultCallback<any>) {
write_file: ['get_data', 'make_folder', function (callback: AsyncResultCallback<any>) {
callback(null, filename);
}],
} as any],
//arrays with different types are not accepted by TypeScript.
email_link: ['write_file', <any>function (callback: AsyncResultCallback<any>, results: any) { }]
email_link: ['write_file', function (callback: AsyncResultCallback<any>, results: any) { } as any]
});
async.auto({
get_data: function (callback: AsyncResultCallback<any>) { },
make_folder: function (callback: AsyncResultCallback<any>) { },
//arrays with different types are not accepted by TypeScript.
write_file: ['get_data', 'make_folder', <any>function (callback: AsyncResultCallback<any>) {
write_file: ['get_data', 'make_folder', function (callback: AsyncResultCallback<any>) {
callback(null, filename);
}],
} as any],
//arrays with different types are not accepted by TypeScript.
email_link: ['write_file', <any>function (callback: AsyncResultCallback<any>, results: any) { }]
email_link: ['write_file', function (callback: AsyncResultCallback<any>, results: any) { } as any]
}, function (err, results) {
console.log('finished auto');
});
@@ -421,11 +421,11 @@ async.auto<A>({
get_data: function (callback: AsyncResultCallback<any>) { },
make_folder: function (callback: AsyncResultCallback<any>) { },
//arrays with different types are not accepted by TypeScript.
write_file: ['get_data', 'make_folder', <any>function (callback: AsyncResultCallback<any>) {
write_file: ['get_data', 'make_folder', function (callback: AsyncResultCallback<any>) {
callback(null, filename);
}],
} as any],
//arrays with different types are not accepted by TypeScript.
email_link: ['write_file', <any>function (callback: AsyncResultCallback<any>, results: any) { }]
email_link: ['write_file', function (callback: AsyncResultCallback<any>, results: any) { } as any]
}, 1, function (err, results) {
console.log('finished auto');
});
+2 -2
View File
@@ -557,8 +557,8 @@ function testDesializerManager() {
}
function isStorableClass(o: object): o is StorableClass {
if (typeof o === "object" && (<StorableClass> o).name &&
(<StorableClass> o).name === "test") {
if (typeof o === "object" && (o as StorableClass).name &&
(o as StorableClass).name === "test") {
return true;
} else {
return false;
-2
View File
@@ -4,8 +4,6 @@
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
import * as Promise from 'bluebird';
export interface ManagementClientOptions {
token?: string;
domain: string;
+131
View File
@@ -0,0 +1,131 @@
import Timeout from "await-timeout";
/**
* This test is just a TS-friendly version of the await-timeout README:
* https://github.com/vitalets/await-timeout/blob/v0.3.0/README.md
*
* How to generate this file:
* 1. Paste the source code of README.md
* 2. Replace every code fence with async () => {}
* 3. Comment out all other lines
* 4. Add and remove import statements and repeated statements
* 5. Declare required globals
*/
// -- Globals --
declare const fetch: (url: string) => Promise<any>;
declare const console: any;
declare const MyTimeoutError: any;
// --- README ---
// ## Usage
// 1. Just wait some time:
async () => {
// wait 1000 ms and resolve
await Timeout.set(1000);
// wait 1000 ms and reject with 'Error'
await Timeout.set(1000, 'Error');
};
// 2. Use `Timeout` instance inside `try...finally` block to make proper cleanup:
async () => {
const timer = new Timeout();
try {
await Promise.race([
fetch('https://example.com'),
timer.set(1000)
.then(() => Promise.reject('Timeout'))
]);
} finally {
timer.clear();
}
};
// ## API
// ### new Timeout()
// Constructs new timeout instance. It does not start timer but creates variable for timer manipulation.
async () => {
const timer = new Timeout();
};
// > Note : having separate variable is useful for clearing timeout in `finally` block
// ### .set(ms, [message]) ⇒ `Promise`
// Starts new timer like `setTimeout()` and returns promise. The promise will be resolved after `ms` milliseconds:
async () => {
const timer = new Timeout();
timer.set(1000)
.then(() => console.log('1000 ms passed.'));
};
// If you need to reject after timeout:
async () => {
const timer = new Timeout();
timer.set(1000)
.then(() => {throw new Error('Timeout'); });
};
// Or reject with custom error:
async () => {
const timer = new Timeout();
timer.set(1000)
.then(() => {throw new MyTimeoutError(); });
};
// The second parameter `message` is just convenient way to reject with `new Error(message)`:
async () => {
const timer = new Timeout();
timer.set(1000, 'Timeout');
// is equivalent to
timer.set(1000).then(() => {throw new Error('Timeout'); });
};
// If you need to just wait some time - use static version of `.set()` :
async () => {
Timeout.set(1000).then(/*...*/);
};
// ### .wrap(promise, ms, [message]) ⇒ `Promise`
// Wraps existing promise with timeout:
// * promise automatically rejected after timeout
// * timeout automatically cleared if promise fulfills first
async () => {
const promise = fetch('https://example.com');
const timeoutedPromise = Timeout.wrap(promise, 1000, 'Timeout');
};
// Actually it is a shortcut for :
async () => {
const promise = fetch('https://example.com');
const timer = new Timeout();
try {
const timeoutedPromise = await Promise.race([
promise,
timer.set(1000, 'Timeout')
]);
} finally {
timer.clear();
}
};
// ### .clear()
// Clears existing timeout like `clearTimeout()`.
async () => {
const timer = new Timeout();
timer.set(1000)
.then(() => console.log('This will never be called, because timeout is cleared on the next line'));
timer.clear();
};
// With [ES7 async / await ] `.clear()` can be used in `finally` block:
async () => {
async function foo() {
const timer = new Timeout();
try {
// some async stuff
} finally {
timer.clear();
}
}
};
+18
View File
@@ -0,0 +1,18 @@
// Type definitions for await-timeout 0.3
// Project: https://github.com/vitalets/await-timeout
// Definitions by: Sean Zhu <https://github.com/szhu>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
export default Timeout;
declare class Timeout {
static set(delay: number): Promise<undefined>;
static set(delay: number, message: string): Promise<never>;
static wrap(promise: Promise<any>, delay: number, error?: string): Promise<any>;
set(delay: number): Promise<undefined>;
set(delay: number, message: string): Promise<never>;
clear(): void;
}
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"await-timeout-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+1 -1
View File
@@ -75,7 +75,7 @@ export namespace Azure.ServiceBus {
DefaultMessageTimeToLive: string;
DuplicateDetectionHistoryTimeWindow: string;
EnablePartitioning: boolean;
MaxSizeInMegaBytes: number;
MaxSizeInMegabytes: number;
RequiresDuplicateDetection: boolean;
}
@@ -64,7 +64,7 @@ const modelOpts: Backbone.ModelFetchWithCacheOptions = {
context: {},
};
const hoge = <Backbone.ModelWithCache> new Backbone.Model;
const hoge = new Backbone.Model() as Backbone.ModelWithCache;
hoge.fetch(modelOpts);
const collectionOpts: Backbone.CollectionFetchWithCacheOptions = {
@@ -76,5 +76,5 @@ const collectionOpts: Backbone.CollectionFetchWithCacheOptions = {
prefillSuccess: (self: any) => { },
};
const fuga = <Backbone.CollectionWithCache> new Backbone.Collection;
const fuga = new Backbone.Collection() as Backbone.CollectionWithCache;
fuga.fetch(collectionOpts);
+13 -1
View File
@@ -122,7 +122,19 @@ declare module 'backbone' {
}
export class Store extends Events {
export class Store implements Events {
on(eventName: string, callback?: (...args: any[]) => void, context?: any): any;
on(eventMap: EventsHash): any;
on(eventName: any, callback?: any, context?: any): any;
off(eventName?: string, callback?: (...args: any[]) => void, context?: any): any;
trigger(eventName: string, ...args: any[]): any;
bind(eventName: string, callback: (...args: any[]) => void, context?: any): any;
unbind(eventName?: string, callback?: (...args: any[]) => void, context?: any): any;
once(events: string, callback: (...args: any[]) => void, context?: any): any;
listenTo(object: any, events: string, callback: (...args: any[]) => void): any;
listenToOnce(object: any, events: string, callback: (...args: any[]) => void): any;
stopListening(object?: any, events?: string, callback?: (...args: any[]) => void): any;
initializeRelation(model, relation, options);
addModelScope(scope:any):void;
+142 -3
View File
@@ -4,13 +4,15 @@
// Natan Vivo <https://github.com/nvivo>,
// Sven Tschui <https://github.com/sventschui>,
// Volker Nauruhn <https://github.com/razorness>,
// Ard Timmerman <https://github.com/confususs>
// Ard Timmerman <https://github.com/confususs>,
// J. Joe Koullas <https://github.com/jjoekoullas>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
import * as Backbone from 'backbone';
import * as JQuery from 'jquery';
import * as Radio from 'backbone.radio';
import * as _ from 'underscore';
export as namespace Marionette;
@@ -179,6 +181,131 @@ export class Container<TView> {
* Find a view by it's cid.
*/
remove(view: TView): void;
/**
* @see _.forEach
*/
forEach(iterator: _.ListIterator<TView, void>, context?: any): Container<TView>;
/**
* @see _.each
*/
each(iterator: _.ListIterator<TView, void>, context?: any): Container<TView>;
/**
* @see _.map
*/
map<TResult>(iterator: _.ListIterator<TView, TResult>, context?: any): TResult[];
/**
* @see _.find
*/
find(iterator: _.ListIterator<TView, boolean>, context?: any): Container<TView> | undefined;
/**
* @see _.detect
*/
detect(iterator: _.ListIterator<TView, boolean>, context?: any): Container<TView> | undefined;
/**
* @see _.filter
*/
filter(iterator: _.ListIterator<TView, boolean>, context?: any): TView[];
/**
* @see _.select
*/
select(iterator: _.ListIterator<TView, boolean>, context?: any): TView[];
/**
* @see _.reject
*/
reject(iterator: _.ListIterator<TView, boolean>, context?: any): TView[];
/**
* @see _.every
*/
every(iterator: _.ListIterator<TView, boolean>, context?: any): boolean;
/**
* @see _.all
*/
all(iterator: _.ListIterator<TView, boolean>, context?: any): boolean;
/**
* @see _.some
*/
some(iterator: _.ListIterator<TView, boolean>, context?: any): boolean;
/**
* @see _.any
*/
any(iterator: _.ListIterator<TView, boolean>, context?: any): boolean;
/**
* @see _.include
*/
include(value: TView, fromIndex?: number): boolean;
/**
* @see _.contains
*/
contains(value: TView, fromIndex?: number): boolean;
/**
* @see _.invoke
*/
invoke(methodName: string, ...args: any[]): any;
/**
* @see _.toArray
*/
toArray(): TView[];
/**
* @see _.first
*/
first(): TView | undefined;
/**
* @see _.initial
*/
initial(n?: number): TView[];
/**
* @see _.rest
*/
rest(n?: number): TView[];
/**
* @see _.last
*/
last(n: number): TView[];
/**
* @see _.without
*/
without(...values: TView[]): TView[];
/**
* @see _.isEmpty
*/
isEmpty(): boolean;
/**
* @see _.pluck
*/
pluck(propertyName: string): any[];
/**
* @see _.reduce
*/
reduce<TResult>(iterator: _.MemoIterator<TView, TResult>, memo?: TResult, context?: any): TResult;
/**
* @see _.partition
*/
partition(iterator: _.ListIterator<TView, boolean>, context?: any): TView[][];
}
/**
@@ -280,9 +407,21 @@ export interface ObjectOptions extends RadioMixinOptions {
* A base class which other classes can extend from. Object incorporates many
* backbone conventions and utilities like initialize and Backbone.Events.
*/
export class Object extends Backbone.Events implements CommonMixin, RadioMixin {
export class Object implements CommonMixin, RadioMixin, Backbone.Events {
constructor(options?: ObjectOptions);
on(eventName: string, callback?: (...args: any[]) => void, context?: any): any;
on(eventMap: EventsHash): any;
on(eventName: any, callback?: any, context?: any): any;
off(eventName?: string, callback?: (...args: any[]) => void, context?: any): any;
trigger(eventName: string, ...args: any[]): any;
bind(eventName: string, callback: (...args: any[]) => void, context?: any): any;
unbind(eventName?: string, callback?: (...args: any[]) => void, context?: any): any;
once(events: string, callback: (...args: any[]) => void, context?: any): any;
listenTo(object: any, events: string, callback: (...args: any[]) => void): any;
listenToOnce(object: any, events: string, callback: (...args: any[]) => void): any;
stopListening(object?: any, events?: string, callback?: (...args: any[]) => void): any;
/**
* Receives a hash of event names and functions and/or function names,
* and returns the same hash with the function names replaced with the
@@ -1154,7 +1293,7 @@ export class View<TModel extends Backbone.Model> extends Backbone.View<TModel> i
export interface CollectionViewOptions<
TModel extends Backbone.Model,
TCollection extends Backbone.Collection<TModel> = Backbone.Collection<TModel>
> extends Backbone.ViewOptions<TModel>, ViewMixinOptions {
> extends Backbone.ViewOptions<TModel>, ViewMixinOptions {
/**
* Specify a child view to use.
*/
@@ -70,8 +70,8 @@ namespace InitializingWithOptions {
});
var testCollection6 = new TestCollection([
<TestModel>{},
<TestModel>{},
{} as TestModel,
{} as TestModel,
]);
}
+12 -1
View File
@@ -71,7 +71,18 @@ declare module "backbone" {
stopReplying(commandName?: string, callback?: (...args: any[]) => any, context?: any): Requests;
}
class Channel extends Backbone.Events implements Commands, Requests {
class Channel implements Commands, Requests, Backbone.Events {
on(eventName: string, callback?: (...args: any[]) => void, context?: any): any;
on(eventMap: EventsHash): any;
on(eventName: any, callback?: any, context?: any): any;
off(eventName?: string, callback?: (...args: any[]) => void, context?: any): any;
trigger(eventName: string, ...args: any[]): any;
bind(eventName: string, callback: (...args: any[]) => void, context?: any): any;
unbind(eventName?: string, callback?: (...args: any[]) => void, context?: any): any;
once(events: string, callback: (...args: any[]) => void, context?: any): any;
listenTo(object: any, events: string, callback: (...args: any[]) => void): any;
listenToOnce(object: any, events: string, callback: (...args: any[]) => void): any;
stopListening(object?: any, events?: string, callback?: (...args: any[]) => void): any;
channelName: string;
reset(): Channel;
+1 -1
View File
@@ -1,6 +1,6 @@
function test_events() {
var object = new Backbone.Events();
var object = Backbone.Events;
object.on("alert", (eventName: string) => alert("Triggered " + eventName));
object.trigger("alert", "an event");
+45 -13
View File
@@ -3,6 +3,7 @@
// Definitions by: Boris Yankov <https://github.com/borisyankov>
// Natan Vivo <https://github.com/nvivo>
// kenjiru <https://github.com/kenjiru>
// jjoekoullas <https://github.com/jjoekoullas>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
@@ -94,21 +95,34 @@ declare namespace Backbone {
[selector: string]: string | {(eventObject: JQueryEventObject): void};
}
class Events {
on(eventName: string, callback?: Function, context?: any): any;
export const Events: Events;
interface Events {
on(eventName: string, callback?: (...args: any[]) => void, context?: any): any;
on(eventMap: EventsHash): any;
off(eventName?: string, callback?: Function, context?: any): any;
off(eventName?: string, callback?: (...args: any[]) => void, context?: any): any;
trigger(eventName: string, ...args: any[]): any;
bind(eventName: string, callback: Function, context?: any): any;
unbind(eventName?: string, callback?: Function, context?: any): any;
bind(eventName: string, callback: (...args: any[]) => void, context?: any): any;
unbind(eventName?: string, callback?: (...args: any[]) => void, context?: any): any;
once(events: string, callback: Function, context?: any): any;
listenTo(object: any, events: string, callback: Function): any;
listenToOnce(object: any, events: string, callback: Function): any;
stopListening(object?: any, events?: string, callback?: Function): any;
once(events: string, callback: (...args: any[]) => void, context?: any): any;
listenTo(object: any, events: string, callback: (...args: any[]) => void): any;
listenToOnce(object: any, events: string, callback: (...args: any[]) => void): any;
stopListening(object?: any, events?: string, callback?: (...args: any[]) => void): any;
}
class ModelBase extends Events {
class ModelBase implements Events {
on(eventName: string, callback?: Function, context?: any): any;
on(eventMap: EventsHash): any;
on(eventName: any, callback?: any, context?: any): any
off(eventName?: string, callback?: Function, context?: any): any
trigger(eventName: string, ...args: any[]): any
bind(eventName: string, callback: Function, context?: any): any
unbind(eventName?: string, callback?: Function, context?: any): any
once(events: string, callback: Function, context?: any): any
listenTo(object: any, events: string, callback: Function):any
listenToOnce(object: any, events: string, callback: Function): any
stopListening(object?: any, events?: string, callback?: Function): any
parse(response: any, options?: any): any;
toJSON(options?: any): any;
sync(...arg: any[]): JQueryXHR;
@@ -353,7 +367,7 @@ declare namespace Backbone {
without(...values: TModel[]): TModel[];
}
class Router extends Events {
class Router extends EventSignatures {
/**
* Do not use, prefer TypeScript's extend functionality.
@@ -382,7 +396,7 @@ declare namespace Backbone {
var history: History;
class History extends Events {
class History extends EventSignatures {
handlers: any[];
interval: number;
@@ -419,7 +433,7 @@ declare namespace Backbone {
attributes?: {[id: string]: any};
}
class View<TModel extends Model> extends Events {
class View<TModel extends Model> extends EventSignatures {
/**
* Do not use, prefer TypeScript's extend functionality.
@@ -471,3 +485,21 @@ declare namespace Backbone {
function noConflict(): typeof Backbone;
var $: JQueryStatic;
}
/**
* This is not for external use and is only here as a convenient way to
* specify signatures for internal implementers of Backbone.Events
*/
declare abstract class EventSignatures implements Backbone.Events {
on(eventName: string, callback?: (...args: any[]) => void, context?: any): any;
on(eventMap: Backbone.EventsHash): any;
off(eventName?: string, callback?: (...args: any[]) => void, context?: any): any;
trigger(eventName: string, ...args: any[]): any;
bind(eventName: string, callback: (...args: any[]) => void, context?: any): any;
unbind(eventName?: string, callback?: (...args: any[]) => void, context?: any): any;
once(events: string, callback: (...args: any[]) => void, context?: any): any;
listenTo(object: any, events: string, callback: (...args: any[]) => void): any;
listenToOnce(object: any, events: string, callback: (...args: any[]) => void): any;
stopListening(object?: any, events?: string, callback?: (...args: any[]) => void): any;
}
+3 -3
View File
@@ -120,7 +120,7 @@ function CommonMethodsInEventStreamsAndProperties() {
Bacon.fromArray([1, 2, 3]).withStateMachine(0, (sum, event) => {
if (event.hasValue()) {
// had to cast to `number` because event:Bacon.Next<number>|Bacon.Error<{}>
return [sum + <number>event.value(), []];
return [sum + (event.value() as number), []];
}
else if (event.isEnd()) {
return [undefined, [new Bacon.Next(sum), event]];
@@ -140,8 +140,8 @@ function CommonMethodsInEventStreamsAndProperties() {
{
// This is handy for keeping track whether we are currently awaiting an AJAX response:
var ajaxRequest = <Bacon.Observable<Error, JQueryXHR>>{},
ajaxResponse = <Bacon.Observable<Error, JQueryXHR>>{},
var ajaxRequest = {} as Bacon.Observable<Error, JQueryXHR>,
ajaxResponse = {} as Bacon.Observable<Error, JQueryXHR>,
showAjaxIndicator = ajaxRequest.awaiting(ajaxResponse);
}
+1 -1
View File
@@ -16,7 +16,7 @@ async function run() {
clientSecret: '',
scope(request) {
const scopes = ['public_profile', 'email'];
if ((<RequestQuery> request.query).wantsSharePermission) {
if ((request.query as RequestQuery).wantsSharePermission) {
scopes.push('publish_actions');
}
return scopes;
+5 -3
View File
@@ -118,6 +118,8 @@ export interface ClientOptions {
export type PolicyOptionVariants<T> = PolicyOptions<T> | DecoratedPolicyOptions<T>;
export type Id = string | { id: string };
/**
* The Policy object provides a convenient cache interface by setting a
* global policy which is automatically applied to every storage action.
@@ -138,7 +140,7 @@ export class Policy<T, O extends PolicyOptionVariants<T>> {
* @param id the unique item identifier (within the policy segment).
* Can be a string or an object with the required 'id' key.
*/
get(id: string | { id: string }): Promise<O extends DecoratedPolicyOptions<T> ? DecoratedResult<T> : T | null>;
get(id: Id): Promise<O extends DecoratedPolicyOptions<T> ? DecoratedResult<T> : T | null>;
/**
* store an item in the cache where:
@@ -148,12 +150,12 @@ export class Policy<T, O extends PolicyOptionVariants<T>> {
* removed from the cache (or is marked invalid).
* This should be set to 0 in order to use the caching rules configured when creating the Policy object.
*/
set(id: string | { id: string }, value: T, ttl?: number): Promise<void>;
set(id: Id, value: T, ttl?: number): Promise<void>;
/**
* remove the item from cache where:
* @param id the unique item identifier (within the policy segment).
*/
drop(id: string | { id: string }): Promise<void>;
drop(id: Id): Promise<void>;
/**
* given a created timestamp in milliseconds, returns the time-to-live left
* based on the configured rules.
+1
View File
@@ -103,6 +103,7 @@ expect("abcd").to.have.length(4);
expect(5).to.equal(5);
expect({ a: 1 }).to.equal({ a: 1 });
expect([1, 2, 3]).to.equal([1, 2, 3]);
expect(Object.create(null)).to.equal({}, { prototype: false });
+2 -2
View File
@@ -125,9 +125,9 @@ export interface Values<T> {
/** Asserts that the reference value has a length property matching the provided size or an object with the specified number of keys. */
length(size: number): AssertionChain<T>;
/** Asserts that the reference value equals the provided value. */
equal(value: T, options?: any): AssertionChain<T>;
equal(value: T | T[], options?: any): AssertionChain<T>;
/** Asserts that the reference value equals the provided value. */
equals(value: T, options?: any): AssertionChain<T>;
equals(value: T | T[], options?: any): AssertionChain<T>;
/** Asserts that the reference value is greater than (>) the provided value. */
above(value: T): AssertionChain<T>;
/** Asserts that the reference value is greater than (>) the provided value. */
+26 -9
View File
@@ -1,17 +1,17 @@
import CombinedStream = require("combined-stream");
import { createReadStream, createWriteStream } from "fs";
import CombinedStream = require('combined-stream');
import { createReadStream, createWriteStream } from 'fs';
const stream1 = new CombinedStream();
stream1.append(createReadStream("tsconfig.json"));
stream1.append(createReadStream("tslint.json"));
stream1.append(createReadStream("index.d.ts"));
stream1.append(createReadStream('tsconfig.json'));
stream1.append(createReadStream('tslint.json'));
stream1.append(createReadStream('index.d.ts'));
stream1.pipe(createWriteStream("combined.txt"));
stream1.pipe(createWriteStream('combined.txt'));
const stream2 = CombinedStream.create({
maxDataSize: 1 << 32,
pauseStreams: false,
pauseStreams: false
});
stream1.destroy();
@@ -19,12 +19,29 @@ stream1.destroy();
// should log true
console.log(CombinedStream.isStreamLike(stream2));
stream2.on("data", (data) => {
stream2.on('data', data => {
console.log(data);
});
stream2.pipe(createWriteStream("combined.txt"));
stream2.pipe(createWriteStream('combined.txt'));
stream2.write(CombinedStream.name);
stream2.destroy();
const arrowFunction = (): CombinedStream => {
const stream3 = new CombinedStream();
// test next function
stream3.append(next => {
stream3.append('hello world');
next(createReadStream(''));
});
// next function with no next
stream3.append(() => {
stream3.append('hello again');
});
return stream3;
};
+20 -20
View File
@@ -1,19 +1,27 @@
// Type definitions for combined-stream 1.0
// Project: https://github.com/felixge/node-combined-stream
// Definitions by: Felix Geisendörfer <https://github.com/felixge>, Tomek Łaziuk <https://github.com/tlaziuk>
// Definitions by: Felix Geisendörfer <https://github.com/felixge>, Tomek Łaziuk <https://github.com/tlaziuk>, Kon Pik <https://github.com/konpikwastaken>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
import { Stream } from "stream";
import { Stream } from 'stream';
declare class CombinedStream extends Stream implements CombinedStream.Options {
type Appendable = NodeJS.ReadableStream | NodeJS.WritableStream | Buffer | string | NextFunction;
type NextFunction = (next: (stream: Appendable) => any) => any;
interface Options {
maxDataSize?: number;
pauseStreams?: boolean;
}
declare class CombinedStream extends Stream implements Options {
readonly writable: boolean;
readonly readable: boolean;
readonly dataSize: number;
maxDataSize: number;
pauseStreams: boolean;
append(stream: NodeJS.ReadableStream | NodeJS.WritableStream | Buffer | string): this;
append(stream: Appendable): this;
write(data: any): void;
pause(): void;
resume(): void;
@@ -34,23 +42,15 @@ declare class CombinedStream extends Stream implements CombinedStream.Options {
_emitError(error: Error): void;
// events
on(event: "close" | "end" | "resume" | "pause", cb: () => void): this;
on(event: "error", cb: (err: Error) => void): this;
on(event: "data", cb: (data: any) => void): this;
once(event: "close" | "end" | "resume" | "pause", cb: () => void): this;
once(event: "error", cb: (err: Error) => void): this;
once(event: "data", cb: (data: any) => void): this;
}
on(event: 'close' | 'end' | 'resume' | 'pause', cb: () => void): this;
on(event: 'error', cb: (err: Error) => void): this;
on(event: 'data', cb: (data: any) => void): this;
once(event: 'close' | 'end' | 'resume' | 'pause', cb: () => void): this;
once(event: 'error', cb: (err: Error) => void): this;
once(event: 'data', cb: (data: any) => void): this;
declare namespace CombinedStream {
interface Options {
maxDataSize?: number;
pauseStreams?: boolean;
}
function create(options?: Options): CombinedStream;
function isStreamLike(stream: any): stream is Stream;
static create(options?: Options): CombinedStream;
static isStreamLike(stream: any): stream is Stream;
}
export = CombinedStream;
+30
View File
@@ -0,0 +1,30 @@
import compareFunc = require("compare-func");
// This is taken from https://github.com/stevemao/compare-func/blob/master/README.md#usage and extended
// sort by an object property
[{ x: "b" }, { x: "a" }, { x: "c" }].sort(compareFunc("x"));
// => [{x: "a"}, {x: "b"}, {x: "c"}]
// sort by a nested object property
[{ x: { y: "b" } }, { x: { y: "a" } }].sort(compareFunc("x.y"));
// => [{x: {y: "a"}}, {x: {y: "b"}}]
// sort by the `x` property, then `y`
[{ x: "c", y: "c" }, { x: "b", y: "a" }, { x: "b", y: "b" }].sort(compareFunc(["x", "y"]));
// => [{x: "b", y: "a"}, {x: "b", y: "b"}, {x: "c", y: "c"}]
// sort by the returned value
[{ x: "b" }, { x: "a" }, { x: "c" }].sort(compareFunc((el) => el.x));
// => [{x: "a"}, {x: "b"}, {x: "c"}]
// sort by an array of functions
[{ x: "c", y: "c" }, { x: "b", y: "a" }, { x: "b", y: "b" }].sort(compareFunc([
(el) => el.x,
(el) => el.y,
]));
// => [{x: "a"}, {x: "b"}, {x: "c"}]
// sort by itself
[1, 3, 2].sort(compareFunc());
// => [1, 2, 3]
+12
View File
@@ -0,0 +1,12 @@
// Type definitions for compare-func 1.3
// Project: https://github.com/stevemao/compare-func
// Definitions by: Dogan Fennibay <https://github.com/fennibay>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.4
type extractFunc<T> = (e: T) => number | string;
declare function compare_func<T>(prop?: ReadonlyArray<string | extractFunc<T>> | string | extractFunc<T>):
(e1: T, e2: T) => number;
export = compare_func;
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"compare-func-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+1 -1
View File
@@ -1,6 +1,6 @@
// Type definitions for cookie 0.3
// Project: https://github.com/jshttp/cookie
// Definitions by: Pine Mizune <https://github.com/pine613>
// Definitions by: Pine Mizune <https://github.com/pine>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export interface CookieSerializeOptions {
+3 -2
View File
@@ -1,5 +1,4 @@
import countries from 'country-list';
const Countries = countries();
import * as Countries from 'country-list';
Countries.getCode('Barbados'); // BB
@@ -14,3 +13,5 @@ Countries.getName('BB'); // Barbados
Countries.getNameList();
Countries.getNames();
Countries.overwrite([{ code: 'TW', name: 'Taiwan' }]);
+35 -31
View File
@@ -1,41 +1,45 @@
// Type definitions for country-list 1.1
// Type definitions for country-list 2.1
// Project: https://github.com/fannarsh/country-list
// Definitions by: Kyle Roach <https://github.com/iRoachie>
// Adam Binford <https://github.com/Kimahriman>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export default function Countries(): {
/**
* Expects a two-digit country code. Returns the name for that country. If not found, it returns undefined.
*/
getName(code: string): string | undefined;
/**
* Expects an array of code and country name pairs to add to the list. Doesn't return anything.
*/
export function overwrite(countries: Array<{ code: string, name: string}>): void;
/**
* Expects the English country name. Returns the code for that country. If not found, it returns undefined.
*/
getCode(name: string): string | undefined;
/**
* Expects a two-digit country code. Returns the name for that country. If not found, it returns undefined.
*/
export function getName(code: string): string | undefined;
/**
* Returns an array of all country names.
*/
getNames(): string[];
/**
* Expects the English country name. Returns the code for that country. If not found, it returns undefined.
*/
export function getCode(name: string): string | undefined;
/**
* Returns an array of all country codes.
*/
getCodes(): string[];
/**
* Returns an array of all country names.
*/
export function getNames(): string[];
/**
* Returns a key-value object of all countries using the name as key.
*/
getNameList(): {[name: string]: string};
/**
* Returns an array of all country codes.
*/
export function getCodes(): string[];
/**
* Returns a key-value object of all countries using the code as key.
*/
getCodeList(): {[code: string]: string};
/**
* Returns a key-value object of all countries using the name as key.
*/
export function getNameList(): {[name: string]: string};
/**
* Returns an array of all country information, in the same format as it gets imported.
*/
getData(): Array<{ code: string, name: string }>;
};
/**
* Returns a key-value object of all countries using the code as key.
*/
export function getCodeList(): {[code: string]: string};
/**
* Returns an array of all country information, in the same format as it gets imported.
*/
export function getData(): Array<{ code: string, name: string }>;
@@ -0,0 +1,16 @@
import countries from 'country-list';
const Countries = countries();
Countries.getCode('Barbados'); // BB
Countries.getCodes();
Countries.getCodeList();
Countries.getData();
Countries.getName('BB'); // Barbados
Countries.getNameList();
Countries.getNames();
+41
View File
@@ -0,0 +1,41 @@
// Type definitions for country-list 1.1
// Project: https://github.com/fannarsh/country-list
// Definitions by: Kyle Roach <https://github.com/iRoachie>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export default function Countries(): {
/**
* Expects a two-digit country code. Returns the name for that country. If not found, it returns undefined.
*/
getName(code: string): string | undefined;
/**
* Expects the English country name. Returns the code for that country. If not found, it returns undefined.
*/
getCode(name: string): string | undefined;
/**
* Returns an array of all country names.
*/
getNames(): string[];
/**
* Returns an array of all country codes.
*/
getCodes(): string[];
/**
* Returns a key-value object of all countries using the name as key.
*/
getNameList(): {[name: string]: string};
/**
* Returns a key-value object of all countries using the code as key.
*/
getCodeList(): {[code: string]: string};
/**
* Returns an array of all country information, in the same format as it gets imported.
*/
getData(): Array<{ code: string, name: string }>;
};
+26
View File
@@ -0,0 +1,26 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../../",
"typeRoots": [
"../../"
],
"paths": {
"country-list": ["country-list/v1"]
},
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"country-list-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+612
View File
@@ -0,0 +1,612 @@
import * as csstree from "css-tree";
const ast = csstree.parse('.a { color: red; }');
ast; // $ExpectType CssNode
csstree.parse('.a { color: red; }', {}); // $ExpectType CssNode
csstree.parse('.a { color: red; }', {context: 'selector', positions: true}); // $ExpectType CssNode
csstree.walk(ast, (node, item, list) => {
node; // $ExpectType CssNode
item; // $ExpectType ListItem<CssNode>
list; // $ExpectType List<CssNode>
});
csstree.walk(ast, {});
csstree.walk(ast, {
enter(node, item, list) {
this.stylesheet; // $ExpectType StyleSheet
node; // $ExpectType CssNode
item; // $ExpectType ListItem<CssNode>
list; // $ExpectType List<CssNode>
},
leave(node, item, list) {
this.stylesheet; // $ExpectType StyleSheet
node; // $ExpectType CssNode
item; // $ExpectType ListItem<CssNode>
list; // $ExpectType List<CssNode>
},
visit: 'ClassSelector',
reverse: false,
});
csstree.generate(ast); // $ExpectType string
csstree.generate(ast, {}); // $ExpectType string
csstree.generate(ast, {
sourceMap: true,
decorator: handlers => ({
children(node, delimiter) {
node; // $ExpectType CssNode
delimiter; // $ExpectType ((node: CssNode) => void) | undefined
handlers.children.call(handlers, node, delimiter);
},
node(node) {
node; // $ExpectType CssNode
handlers.node.call(node);
},
chunk(chunk) {
chunk; // $ExpectType string
handlers.chunk.call(chunk);
},
result() {
return handlers.result.call(handlers);
}
}),
});
const property = csstree.property('*-vendor-property');
property.name = 'test'; // $ExpectError
const keyword = csstree.keyword('-vendor-keyword');
keyword.name = 'test'; // $ExpectError
csstree.clone(ast); // $ExpectType CssNode
const fromPlain = csstree.fromPlainObject({
type: 'SelectorList',
children: []
});
fromPlain; // $ExpectType CssNode
const toPlain = csstree.toPlainObject({
type: 'SelectorList',
children: new csstree.List<csstree.CssNode>(),
});
toPlain; // $ExpectType CssNodePlain
interface Test {
a: string;
}
const list = new csstree.List<Test>();
const anItem = list.createItem({a: 'c'});
anItem; // $ExpectType ListItem<Test>
list.fromArray([{a: 'b'}]);
list.toArray(); // $ExpectType Test[]
list.getSize(); // $ExpectType number
list.isEmpty(); // $ExpectType boolean
list.first(); // $ExpectType Test | null
list.last(); // $ExpectType Test | null
list.each(function(item, node, list) {
this.b; // $ExpectType string
item; // $ExpectType Test
node; // $ExpectType ListItem<Test>
list; // $ExpectType List<Test>
}, {b: 'c'});
list.each(function(item, node, list) {
this; // $ExpectType List<Test>
item; // $ExpectType Test
node; // $ExpectType ListItem<Test>
list; // $ExpectType List<Test>
});
list.forEach(function(item, node, list) {
this.b; // $ExpectType string
item; // $ExpectType Test
node; // $ExpectType ListItem<Test>
list; // $ExpectType List<Test>
}, {b: 'c'});
list.forEach(function(item, node, list) {
this; // $ExpectType List<Test>
item; // $ExpectType Test
node; // $ExpectType ListItem<Test>
list; // $ExpectType List<Test>
});
list.eachRight(function(item, node, list) {
this.b; // $ExpectType string
item; // $ExpectType Test
node; // $ExpectType ListItem<Test>
list; // $ExpectType List<Test>
}, {b: 'c'});
list.eachRight(function(item, node, list) {
this; // $ExpectType List<Test>
item; // $ExpectType Test
node; // $ExpectType ListItem<Test>
list; // $ExpectType List<Test>
});
list.forEachRight(function(item, node, list) {
this.b; // $ExpectType string
item; // $ExpectType Test
node; // $ExpectType ListItem<Test>
list; // $ExpectType List<Test>
}, {b: 'c'});
list.forEachRight(function(item, node, list) {
this; // $ExpectType List<Test>
item; // $ExpectType Test
node; // $ExpectType ListItem<Test>
list; // $ExpectType List<Test>
});
list.nextUntil(anItem, function(item, node, list) {
this.b; // $ExpectType string
item; // $ExpectType Test
node; // $ExpectType ListItem<Test>
list; // $ExpectType List<Test>
return true;
}, {b: 'c'});
list.nextUntil(anItem, function(item, node, list) {
this; // $ExpectType List<Test>
item; // $ExpectType Test
node; // $ExpectType ListItem<Test>
list; // $ExpectType List<Test>
return true;
});
list.prevUntil(anItem, function(item, node, list) {
this.b; // $ExpectType string
item; // $ExpectType Test
node; // $ExpectType ListItem<Test>
list; // $ExpectType List<Test>
return true;
}, {b: 'c'});
list.prevUntil(anItem, function(item, node, list) {
this; // $ExpectType List<Test>
item; // $ExpectType Test
node; // $ExpectType ListItem<Test>
list; // $ExpectType List<Test>
return true;
});
list.some(function(item, node, list) {
this.b; // $ExpectType string
item; // $ExpectType Test
node; // $ExpectType ListItem<Test>
list; // $ExpectType List<Test>
return true;
}, {b: 'c'});
list.some(function(item, node, list) {
this; // $ExpectType List<Test>
item; // $ExpectType Test
node; // $ExpectType ListItem<Test>
list; // $ExpectType List<Test>
return true;
});
const map1 = list.map(function(item, node, list) {
this.b; // $ExpectType string
item; // $ExpectType Test
node; // $ExpectType ListItem<Test>
list; // $ExpectType List<Test>
return { c: 'd' };
}, {b: 'c'});
map1; // $ExpectType List<{ c: string; }>
const map2 = list.map(function(item, node, list) {
this; // $ExpectType List<Test>
item; // $ExpectType Test
node; // $ExpectType ListItem<Test>
list; // $ExpectType List<Test>
return { c: 'd' };
});
map2; // $ExpectType List<{ c: string; }>
const list2 = new csstree.List<Test | null>();
const filter1 = list2.filter(function(item, node, list): item is Test {
this.b; // $ExpectType string
item; // $ExpectType Test | null
node; // $ExpectType ListItem<Test | null>
list; // $ExpectType List<Test | null>
return !!item;
}, {b: 'c'});
filter1; // $ExpectType List<Test>
const filter2 = list2.filter(function(item, node, list): item is Test {
this; // $ExpectType List<Test | null>
item; // $ExpectType Test | null
node; // $ExpectType ListItem<Test | null>
list; // $ExpectType List<Test | null>
return !!item;
});
filter2; // $ExpectType List<Test>
const filter3 = list2.filter(function(item, node, list) {
this.b; // $ExpectType string
item; // $ExpectType Test | null
node; // $ExpectType ListItem<Test | null>
list; // $ExpectType List<Test | null>
return true;
}, {b: 'c'});
filter3; // $ExpectType List<Test | null>
const filter4 = list2.filter(function(item, node, list) {
this; // $ExpectType List<Test | null>
item; // $ExpectType Test | null
node; // $ExpectType ListItem<Test | null>
list; // $ExpectType List<Test | null>
return true;
});
filter4; // $ExpectType List<Test | null>
list.clear();
list.copy(); // $ExpectType List<Test>
list.prepend(anItem); // $ExpectType List<Test>
list.prependData({a: 'b'}); // $ExpectType List<Test>
list.append(anItem); // $ExpectType List<Test>
list.appendData({a: 'b'}); // $ExpectType List<Test>
list.insert(anItem, anItem); // $ExpectType List<Test>
list.insertData({a: 'b'}, anItem); // $ExpectType List<Test>
list.remove(anItem); // $ExpectType ListItem<Test>
list.push({a: 'b'}); // $ExpectType void
list.pop(); // $ExpectType ListItem<Test> | undefined
list.unshift({a: 'b'}); // $ExpectType void
list.shift(); // $ExpectType ListItem<Test> | undefined
list.prependList(list); // $ExpectType List<Test>
list.appendList(list); // $ExpectType List<Test>
list.insertList(list, anItem); // $ExpectType List<Test>
list.replace(anItem, list); // $ExpectType List<Test>
list.replace(anItem, anItem); // $ExpectType List<Test>
switch (ast.type) {
case 'AnPlusB':
ast.a; // $ExpectType string | null
ast.b; // $ExpectType string | null
break;
case 'Atrule':
ast.name; // $ExpectType string
ast.prelude; // $ExpectType AtrulePrelude | Raw | null
ast.block; // $ExpectType Block | null
break;
case 'AtrulePrelude':
ast.children; // $ExpectType List<CssNode>
break;
case 'AttributeSelector':
ast.name; // $ExpectType Identifier
ast.matcher; // $ExpectType string | null
ast.value; // $ExpectType Identifier | StringNode | null
ast.flags; // $ExpectType string | null
break;
case 'Block':
ast.children; // $ExpectType List<CssNode>
break;
case 'Brackets':
ast.children; // $ExpectType List<CssNode>
break;
case 'CDC':
break;
case 'CDO':
break;
case 'ClassSelector':
ast.name; // $ExpectType string
break;
case 'Combinator':
ast.name; // $ExpectType string
break;
case 'Comment':
ast.value; // $ExpectType string
break;
case 'Declaration':
ast.important; // $ExpectType string | boolean
ast.property; // $ExpectType string
ast.value; // $ExpectType Raw | Value
break;
case 'DeclarationList':
ast.children; // $ExpectType List<CssNode>
break;
case 'Dimension':
ast.value; // $ExpectType string
ast.unit; // $ExpectType string
break;
case 'Function':
ast.name; // $ExpectType string
ast.children; // $ExpectType List<CssNode>
break;
case 'HexColor':
ast.value; // $ExpectType string
break;
case 'IdSelector':
ast.name; // $ExpectType string
break;
case 'Identifier':
ast.name; // $ExpectType string
break;
case 'MediaFeature':
ast.name; // $ExpectType string
ast.value; // $ExpectType Dimension | Identifier | NumberNode | Ratio | null
break;
case 'MediaQuery':
ast.children; // $ExpectType List<CssNode>
break;
case 'MediaQueryList':
ast.children; // $ExpectType List<CssNode>
break;
case 'Nth':
ast.nth; // $ExpectType AnPlusB | Identifier
ast.selector; // $ExpectType SelectorList | null
break;
case 'Number':
ast.value; // $ExpectType string
break;
case 'Operator':
ast.value; // $ExpectType string
break;
case 'Parentheses':
ast.children; // $ExpectType List<CssNode>
break;
case 'Percentage':
ast.value; // $ExpectType string
break;
case 'PseudoClassSelector':
ast.name; // $ExpectType string
ast.children; // $ExpectType List<CssNode> | null
break;
case 'PseudoElementSelector':
ast.name; // $ExpectType string
ast.children; // $ExpectType List<CssNode> | null
break;
case 'Ratio':
ast.left; // $ExpectType string
ast.right; // $ExpectType string
break;
case 'Raw':
ast.value; // $ExpectType string
break;
case 'Rule':
ast.prelude; // $ExpectType Raw | SelectorList
ast.block; // $ExpectType Block
break;
case 'Selector':
ast.children; // $ExpectType List<CssNode>
break;
case 'SelectorList':
ast.children; // $ExpectType List<CssNode>
break;
case 'String':
ast.value; // $ExpectType string
break;
case 'StyleSheet':
ast.children; // $ExpectType List<CssNode>
break;
case 'TypeSelector':
ast.name; // $ExpectType string
break;
case 'UnicodeRange':
ast.value; // $ExpectType string
break;
case 'Url':
ast.value; // $ExpectType Raw | StringNode
break;
case 'Value':
ast.children; // $ExpectType List<CssNode>
break;
case 'WhiteSpace':
ast.value; // $ExpectType string
break;
default:
ast; // $ExpectType never
}
switch (toPlain.type) {
case 'AnPlusB':
toPlain.a; // $ExpectType string | null
toPlain.b; // $ExpectType string | null
break;
case 'Atrule':
toPlain.name; // $ExpectType string
toPlain.prelude; // $ExpectType Raw | AtrulePreludePlain | null
toPlain.block; // $ExpectType BlockPlain | null
break;
case 'AtrulePrelude':
toPlain.children; // $ExpectType CssNodePlain[]
break;
case 'AttributeSelector':
toPlain.name; // $ExpectType Identifier
toPlain.matcher; // $ExpectType string | null
toPlain.value; // $ExpectType Identifier | StringNode | null
toPlain.flags; // $ExpectType string | null
break;
case 'Block':
toPlain.children; // $ExpectType CssNodePlain[]
break;
case 'Brackets':
toPlain.children; // $ExpectType CssNodePlain[]
break;
case 'CDC':
break;
case 'CDO':
break;
case 'ClassSelector':
toPlain.name; // $ExpectType string
break;
case 'Combinator':
toPlain.name; // $ExpectType string
break;
case 'Comment':
toPlain.value; // $ExpectType string
break;
case 'Declaration':
toPlain.important; // $ExpectType string | boolean
toPlain.property; // $ExpectType string
toPlain.value; // $ExpectType Raw | ValuePlain
break;
case 'DeclarationList':
toPlain.children; // $ExpectType CssNodePlain[]
break;
case 'Dimension':
toPlain.value; // $ExpectType string
toPlain.unit; // $ExpectType string
break;
case 'Function':
toPlain.name; // $ExpectType string
toPlain.children; // $ExpectType CssNodePlain[]
break;
case 'HexColor':
toPlain.value; // $ExpectType string
break;
case 'IdSelector':
toPlain.name; // $ExpectType string
break;
case 'Identifier':
toPlain.name; // $ExpectType string
break;
case 'MediaFeature':
toPlain.name; // $ExpectType string
toPlain.value; // $ExpectType Dimension | Identifier | NumberNode | Ratio | null
break;
case 'MediaQuery':
toPlain.children; // $ExpectType CssNodePlain[]
break;
case 'MediaQueryList':
toPlain.children; // $ExpectType CssNodePlain[]
break;
case 'Nth':
toPlain.nth; // $ExpectType AnPlusB | Identifier
toPlain.selector; // $ExpectType SelectorListPlain | null
break;
case 'Number':
toPlain.value; // $ExpectType string
break;
case 'Operator':
toPlain.value; // $ExpectType string
break;
case 'Parentheses':
toPlain.children; // $ExpectType CssNodePlain[]
break;
case 'Percentage':
toPlain.value; // $ExpectType string
break;
case 'PseudoClassSelector':
toPlain.name; // $ExpectType string
toPlain.children; // $ExpectType CssNodePlain[] | null
break;
case 'PseudoElementSelector':
toPlain.name; // $ExpectType string
toPlain.children; // $ExpectType CssNodePlain[] | null
break;
case 'Ratio':
toPlain.left; // $ExpectType string
toPlain.right; // $ExpectType string
break;
case 'Raw':
toPlain.value; // $ExpectType string
break;
case 'Rule':
toPlain.prelude; // $ExpectType Raw | SelectorListPlain
toPlain.block; // $ExpectType BlockPlain
break;
case 'Selector':
toPlain.children; // $ExpectType CssNodePlain[]
break;
case 'SelectorList':
toPlain.children; // $ExpectType CssNodePlain[]
break;
case 'String':
toPlain.value; // $ExpectType string
break;
case 'StyleSheet':
toPlain.children; // $ExpectType CssNodePlain[]
break;
case 'TypeSelector':
toPlain.name; // $ExpectType string
break;
case 'UnicodeRange':
toPlain.value; // $ExpectType string
break;
case 'Url':
toPlain.value; // $ExpectType Raw | StringNode
break;
case 'Value':
toPlain.children; // $ExpectType CssNodePlain[]
break;
case 'WhiteSpace':
toPlain.value; // $ExpectType string
break;
default:
toPlain; // $ExpectType never
}
+565
View File
@@ -0,0 +1,565 @@
// Type definitions for css-tree 1.0
// Project: https://github.com/csstree/csstree
// Definitions by: Erik Källén <https://github.com/erik-kallen>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.7
export interface CssLocation {
source: string;
start: {
offset: number;
line: number;
column: number
};
end: {
offset: number;
line: number;
column: number
};
}
export interface ListItem<TData> {
prev: ListItem<TData> | null;
next: ListItem<TData> | null;
data: TData;
}
export type IteratorFn<TData, TResult, TContext = List<TData>> = (this: TContext, item: TData, node: ListItem<TData>, list: List<TData>) => TResult;
export type FilterFn<TData, TResult extends TData, TContext = List<TData>> = (this: TContext, item: TData, node: ListItem<TData>, list: List<TData>) => item is TResult;
export class List<TData> {
constructor();
fromArray(array: TData[]): List<TData>;
createItem(data: TData): ListItem<TData>;
toArray(): TData[];
toJSON(): TData[];
getSize(): number;
isEmpty(): boolean;
first(): TData | null;
last(): TData | null;
each<TContext>(fn: IteratorFn<TData, void, TContext>, context: TContext): void;
each(fn: IteratorFn<TData, void>): void;
forEach<TContext>(fn: IteratorFn<TData, void, TContext>, context: TContext): void;
forEach(fn: IteratorFn<TData, void>): void;
eachRight<TContext>(fn: IteratorFn<TData, void, TContext>, context: TContext): void;
eachRight(fn: IteratorFn<TData, void>): void;
forEachRight<TContext>(fn: IteratorFn<TData, void, TContext>, context: TContext): void;
forEachRight(fn: IteratorFn<TData, void>): void;
nextUntil<TContext>(start: ListItem<TData>, fn: IteratorFn<TData, boolean, TContext>, context: TContext): void;
nextUntil(start: ListItem<TData>, fn: IteratorFn<TData, boolean>): void;
prevUntil<TContext>(start: ListItem<TData>, fn: IteratorFn<TData, boolean, TContext>, context: TContext): void;
prevUntil(start: ListItem<TData>, fn: IteratorFn<TData, boolean>): void;
some<TContext>(fn: IteratorFn<TData, boolean, TContext>, context: TContext): void;
some(fn: IteratorFn<TData, boolean>): void;
map<TContext, TResult>(fn: IteratorFn<TData, TResult, TContext>, context: TContext): List<TResult>;
map<TResult>(fn: IteratorFn<TData, TResult>): List<TResult>;
filter<TContext, TResult extends TData>(fn: FilterFn<TData, TResult, TContext>, context: TContext): List<TResult>;
filter<TResult extends TData>(fn: FilterFn<TData, TResult>): List<TResult>;
filter<TContext>(fn: IteratorFn<TData, boolean, TContext>, context: TContext): List<TData>;
filter(fn: IteratorFn<TData, boolean>): List<TData>;
clear(): void;
copy(): List<TData>;
prepend(item: ListItem<TData>): List<TData>;
prependData(data: TData): List<TData>;
append(item: ListItem<TData>): List<TData>;
appendData(data: TData): List<TData>;
insert(item: ListItem<TData>, before: ListItem<TData>): List<TData>;
insertData(data: TData, before: ListItem<TData>): List<TData>;
remove(item: ListItem<TData>): ListItem<TData>;
push(item: TData): void;
pop(): ListItem<TData> | undefined;
unshift(data: TData): void;
shift(): ListItem<TData> | undefined;
prependList(list: List<TData>): List<TData>;
appendList(list: List<TData>): List<TData>;
insertList(list: List<TData>, before: ListItem<TData>): List<TData>;
replace(oldItem: ListItem<TData>, newItemOrList: List<TData> | ListItem<TData>): List<TData>;
}
export interface CssNodeCommon {
type: string;
loc?: CssLocation;
}
export interface AnPlusB extends CssNodeCommon {
type: 'AnPlusB';
a: string | null;
b: string | null;
}
export interface Atrule extends CssNodeCommon {
type: 'Atrule';
name: string;
prelude: AtrulePrelude | Raw | null;
block: Block | null;
}
export interface AtrulePlain extends CssNodeCommon {
type: 'Atrule';
name: string;
prelude: AtrulePreludePlain | Raw | null;
block: BlockPlain | null;
}
export interface AtrulePrelude extends CssNodeCommon {
type: 'AtrulePrelude';
children: List<CssNode>;
}
export interface AtrulePreludePlain extends CssNodeCommon {
type: 'AtrulePrelude';
children: CssNodePlain[];
}
export interface AttributeSelector extends CssNodeCommon {
type: 'AttributeSelector';
name: Identifier;
matcher: string | null;
value: StringNode | Identifier | null;
flags: string | null;
}
export interface Block extends CssNodeCommon {
type: 'Block';
children: List<CssNode>;
}
export interface BlockPlain extends CssNodeCommon {
type: 'Block';
children: CssNodePlain[];
}
export interface Brackets extends CssNodeCommon {
type: 'Brackets';
children: List<CssNode>;
}
export interface BracketsPlain extends CssNodeCommon {
type: 'Brackets';
children: CssNodePlain[];
}
export interface CDC extends CssNodeCommon {
type: 'CDC';
}
export interface CDO extends CssNodeCommon {
type: 'CDO';
}
export interface ClassSelector extends CssNodeCommon {
type: 'ClassSelector';
name: string;
}
export interface Combinator extends CssNodeCommon {
type: 'Combinator';
name: string;
}
export interface Comment extends CssNodeCommon {
type: 'Comment';
value: string;
}
export interface Declaration extends CssNodeCommon {
type: 'Declaration';
important: boolean | string;
property: string;
value: Value | Raw;
}
export interface DeclarationPlain extends CssNodeCommon {
type: 'Declaration';
important: boolean | string;
property: string;
value: ValuePlain | Raw;
}
export interface DeclarationList extends CssNodeCommon {
type: 'DeclarationList';
children: List<CssNode>;
}
export interface DeclarationListPlain extends CssNodeCommon {
type: 'DeclarationList';
children: CssNodePlain[];
}
export interface Dimension extends CssNodeCommon {
type: 'Dimension';
value: string;
unit: string;
}
export interface FunctionNode extends CssNodeCommon {
type: 'Function';
name: string;
children: List<CssNode>;
}
export interface FunctionNodePlain extends CssNodeCommon {
type: 'Function';
name: string;
children: CssNodePlain[];
}
export interface HexColor extends CssNodeCommon {
type: 'HexColor';
value: string;
}
export interface IdSelector extends CssNodeCommon {
type: 'IdSelector';
name: string;
}
export interface Identifier extends CssNodeCommon {
type: 'Identifier';
name: string;
}
export interface MediaFeature extends CssNodeCommon {
type: 'MediaFeature';
name: string;
value: Identifier | NumberNode | Dimension | Ratio | null;
}
export interface MediaQuery extends CssNodeCommon {
type: 'MediaQuery';
children: List<CssNode>;
}
export interface MediaQueryPlain extends CssNodeCommon {
type: 'MediaQuery';
children: CssNodePlain[];
}
export interface MediaQueryList extends CssNodeCommon {
type: 'MediaQueryList';
children: List<CssNode>;
}
export interface MediaQueryListPlain extends CssNodeCommon {
type: 'MediaQueryList';
children: CssNodePlain[];
}
export interface Nth extends CssNodeCommon {
type: 'Nth';
nth: AnPlusB | Identifier;
selector: SelectorList | null;
}
export interface NthPlain extends CssNodeCommon {
type: 'Nth';
nth: AnPlusB | Identifier;
selector: SelectorListPlain | null;
}
export interface NumberNode extends CssNodeCommon {
type: 'Number';
value: string;
}
export interface Operator extends CssNodeCommon {
type: 'Operator';
value: string;
}
export interface Parentheses extends CssNodeCommon {
type: 'Parentheses';
children: List<CssNode>;
}
export interface ParenthesesPlain extends CssNodeCommon {
type: 'Parentheses';
children: CssNodePlain[];
}
export interface Percentage extends CssNodeCommon {
type: 'Percentage';
value: string;
}
export interface PseudoClassSelector extends CssNodeCommon {
type: 'PseudoClassSelector';
name: string;
children: List<CssNode> | null;
}
export interface PseudoClassSelectorPlain extends CssNodeCommon {
type: 'PseudoClassSelector';
name: string;
children: CssNodePlain[] | null;
}
export interface PseudoElementSelector extends CssNodeCommon {
type: 'PseudoElementSelector';
name: string;
children: List<CssNode> | null;
}
export interface PseudoElementSelectorPlain extends CssNodeCommon {
type: 'PseudoElementSelector';
name: string;
children: CssNodePlain[] | null;
}
export interface Ratio extends CssNodeCommon {
type: 'Ratio';
left: string;
right: string;
}
export interface Raw extends CssNodeCommon {
type: 'Raw';
value: string;
}
export interface Rule extends CssNodeCommon {
type: 'Rule';
prelude: SelectorList | Raw;
block: Block;
}
export interface RulePlain extends CssNodeCommon {
type: 'Rule';
prelude: SelectorListPlain | Raw;
block: BlockPlain;
}
export interface Selector extends CssNodeCommon {
type: 'Selector';
children: List<CssNode>;
}
export interface SelectorPlain extends CssNodeCommon {
type: 'Selector';
children: CssNodePlain[];
}
export interface SelectorList extends CssNodeCommon {
type: 'SelectorList';
children: List<CssNode>;
}
export interface SelectorListPlain extends CssNodeCommon {
type: 'SelectorList';
children: CssNodePlain[];
}
export interface StringNode extends CssNodeCommon {
type: 'String';
value: string;
}
export interface StyleSheet extends CssNodeCommon {
type: 'StyleSheet';
children: List<CssNode>;
}
export interface StyleSheetPlain extends CssNodeCommon {
type: 'StyleSheet';
children: CssNodePlain[];
}
export interface TypeSelector extends CssNodeCommon {
type: 'TypeSelector';
name: string;
}
export interface UnicodeRange extends CssNodeCommon {
type: 'UnicodeRange';
value: string;
}
export interface Url extends CssNodeCommon {
type: 'Url';
value: StringNode | Raw;
}
export interface Value extends CssNodeCommon {
type: 'Value';
children: List<CssNode>;
}
export interface ValuePlain extends CssNodeCommon {
type: 'Value';
children: CssNodePlain[];
}
export interface WhiteSpace extends CssNodeCommon {
type: 'WhiteSpace';
value: string;
}
export type CssNode =
AnPlusB
| Atrule
| AtrulePrelude
| AttributeSelector
| Block
| Brackets
| CDC
| CDO
| ClassSelector
| Combinator
| Comment
| Declaration
| DeclarationList
| Dimension
| FunctionNode
| HexColor
| IdSelector
| Identifier
| MediaFeature
| MediaQuery
| MediaQueryList
| Nth
| NumberNode
| Operator
| Parentheses
| Percentage
| PseudoClassSelector
| PseudoElementSelector
| Ratio
| Raw
| Rule
| Selector
| SelectorList
| StringNode
| StyleSheet
| TypeSelector
| UnicodeRange
| Url
| Value
| WhiteSpace;
export type CssNodePlain =
AnPlusB
| AtrulePlain
| AtrulePreludePlain
| AttributeSelector
| BlockPlain
| BracketsPlain
| CDC
| CDO
| ClassSelector
| Combinator
| Comment
| DeclarationPlain
| DeclarationListPlain
| Dimension
| FunctionNodePlain
| HexColor
| IdSelector
| Identifier
| MediaFeature
| MediaQueryPlain
| MediaQueryListPlain
| NthPlain
| NumberNode
| Operator
| ParenthesesPlain
| Percentage
| PseudoClassSelectorPlain
| PseudoElementSelectorPlain
| Ratio
| Raw
| RulePlain
| SelectorPlain
| SelectorListPlain
| StringNode
| StyleSheetPlain
| TypeSelector
| UnicodeRange
| Url
| ValuePlain
| WhiteSpace;
export interface SyntaxParseError extends SyntaxError {
input: string;
offset: number;
rawMessage: string;
}
export interface ParseOptions {
context?: string;
atrule?: string;
positions?: boolean;
onParseError?: (error: SyntaxParseError, fallbackNode: CssNode) => void;
filename?: string;
offset?: number;
line?: number;
column?: number;
parseAtrulePrelude?: boolean;
parseRulePrelude?: boolean;
parseValue?: boolean;
parseCustomProperty?: boolean;
}
export function parse(text: string, options?: ParseOptions): CssNode;
export interface GenerateHandlers {
children: (node: CssNode, delimiter?: (node: CssNode) => void) => void;
node: (node: CssNode) => void;
chunk: (chunk: string) => void;
result: () => string;
}
export interface GenerateOptions {
sourceMap?: boolean;
decorator?: (handlers: GenerateHandlers) => GenerateHandlers;
}
export function generate(ast: CssNode, options?: GenerateOptions): string;
export interface WalkContext {
root: CssNode;
stylesheet: StyleSheet;
atrule: Atrule;
atrulePrelude: AtrulePrelude;
rule: Rule;
selector: SelectorList;
block: Block;
declaration: Declaration;
function: FunctionNode | PseudoClassSelector | PseudoElementSelector;
}
export type EnterOrLeaveFn = (this: WalkContext, node: CssNode, item: ListItem<CssNode>, list: List<CssNode>) => void;
export interface WalkOptions {
enter?: EnterOrLeaveFn;
leave?: EnterOrLeaveFn;
visit?: string;
reverse?: boolean;
}
export function walk(ast: CssNode, options: EnterOrLeaveFn | WalkOptions): void;
export interface Property {
readonly basename: string;
readonly name: string;
readonly hack: string;
readonly vendor: string;
readonly prefix: string;
readonly custom: boolean;
}
export function property(value: string): Property;
export interface Keyword {
readonly basename: string;
readonly name: string;
readonly vendor: string;
readonly prefix: string;
readonly custom: boolean;
}
export function keyword(value: string): Keyword;
export function clone(node: CssNode): CssNode;
export function fromPlainObject(node: CssNodePlain): CssNode;
export function toPlainObject(node: CssNode): CssNodePlain;
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"css-tree-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+21 -5
View File
@@ -15,7 +15,7 @@ csso.minify('.test { color: #ff0000; }', {
logger: () => {}
});
csso.minifyBlock('color: rgba(255, 0, 0, 1); color: #ff0000').css;
csso.minifyBlock('color: rgba(255, 0, 0, 1); color: #ff0000').css; // $ExpectType string
csso.minifyBlock('color: rgba(255, 0, 0, 1); color: #ff0000').map;
csso.minifyBlock('color: rgba(255, 0, 0, 1); color: #ff0000', {
sourceMap: true,
@@ -27,14 +27,30 @@ csso.minifyBlock('color: rgba(255, 0, 0, 1); color: #ff0000', {
forceMediaMerge: true,
clone: false,
comments: '',
logger: () => {}
logger: () => {},
usage: {
tags: ['ul', 'li'],
ids: ['x'],
classes: ['a', 'b'],
blacklist: {
tags: ['body'],
ids: ['y'],
classes: ['c'],
},
scopes: [
['a', 'b', 'c'],
['d', 'e']
],
},
});
csso.compress({}).ast;
csso.compress({}, {
csso.compress({ type: 'CDC' }).ast; // $ExpectType CssNode
csso.compress({ type: 'CDC' }, {
restructure: false,
forceMediaMerge: true,
clone: false,
comments: '',
logger: () => {}
}).ast;
}).ast; // $ExpectType CssNode
csso.syntax.parse('.b {font-weight: bold}'); // $ExpectType CssNode
+20 -3
View File
@@ -1,8 +1,11 @@
// Type definitions for csso 3.5
// Project: https://github.com/css/csso
// Definitions by: Christian Rackerseder <https://github.com/screendriver>
// Erik Källén <https://github.com/erik-kallen>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.6
// TypeScript Version: 2.7
import * as csstree from 'css-tree';
declare namespace csso {
interface Result {
@@ -16,6 +19,18 @@ declare namespace csso {
map: object | null;
}
interface Usage {
tags?: string[];
ids?: string[];
classes?: string[];
scopes?: string[][];
blacklist?: {
tags?: string[];
ids?: string[];
classes?: string[];
};
}
interface CompressOptions {
/**
* Disable or enable a structure optimisations.
@@ -44,7 +59,7 @@ declare namespace csso {
/**
* Usage data for advanced optimisations.
*/
usage?: object;
usage?: Usage;
/**
* Function to track every step of transformation.
*/
@@ -100,7 +115,9 @@ interface Csso {
/**
* Does the main task – compress an AST.
*/
compress(ast: object, options?: csso.CompressOptions): { ast: object };
compress(ast: csstree.CssNode, options?: csso.CompressOptions): { ast: csstree.CssNode };
syntax: typeof csstree;
}
declare const csso: Csso;
+2 -2
View File
@@ -304,7 +304,7 @@ function test_svg_chart() {
* Test plate functions
*/
plate = new d3kit.SvgPlate();
plate = <d3kit.SvgPlate> chart.addPlate('a-plate', plate, true); // with doNotAppend
plate = chart.addPlate('a-plate', plate, true) as d3kit.SvgPlate; // with doNotAppend
chart = chart.addPlate('a-plate', plate); // without doNotAppend
chart = chart.removePlate('a-plate');
@@ -381,7 +381,7 @@ function test_hybrid_chart() {
* Test plate functions
*/
plate = new d3kit.SvgPlate();
plate = <d3kit.SvgPlate> chart.addPlate('a-plate', plate, true); // with doNotAppend
plate = chart.addPlate('a-plate', plate, true) as d3kit.SvgPlate; // with doNotAppend
chart = chart.addPlate('a-plate', plate); // without doNotAppend
chart = chart.removePlate('a-plate');
+13 -13
View File
@@ -380,8 +380,8 @@ describe('Skeleton', function(){
b: 2
});
expect(skeleton).to.include.keys(['a', 'b']);
expect((<any>skeleton).a).to.equal(1);
expect((<any>skeleton).b).to.equal(2);
expect((skeleton as any).a).to.equal(1);
expect((skeleton as any).b).to.equal(2);
});
it('should overwrite existing fields', function(){
skeleton.mixin({
@@ -391,7 +391,7 @@ describe('Skeleton', function(){
b: 3
});
expect(skeleton).to.include.keys(['b']);
expect((<any>skeleton).b).to.equal(3);
expect((skeleton as any).b).to.equal(3);
});
it('should keep original fields if not overwritten', function(){
skeleton.mixin({
@@ -403,9 +403,9 @@ describe('Skeleton', function(){
b: 3
});
expect(skeleton).to.include.keys(['a', 'b', 'c']);
expect((<any>skeleton).a).to.equal(1);
expect((<any>skeleton).b).to.equal(3);
expect((<any>skeleton).c).to.equal(20);
expect((skeleton as any).a).to.equal(1);
expect((skeleton as any).b).to.equal(3);
expect((skeleton as any).c).to.equal(20);
});
});
@@ -720,7 +720,7 @@ describe('Chartlet', function(){
beforeEach(function(done){
ChildChartlet = function() {
var chartlet = new d3kit.Chartlet(callback, callback, callback);
(<any>chartlet).runTest = function (testFunction: any) {
(chartlet as any).runTest = function (testFunction: any) {
testFunction(chartlet);
};
return chartlet;
@@ -730,7 +730,7 @@ describe('Chartlet', function(){
var chartlet = new d3kit.Chartlet(callback, callback, callback);
var child = ChildChartlet();
configureFunction(chartlet, child);
(<any>chartlet).runTest = (<any>child).runTest;
(chartlet as any).runTest = (child as any).runTest;
return chartlet;
};
@@ -850,7 +850,7 @@ describe('Chartlet', function(){
})
.property('foo', function(d:number) {return 2 * d;});
(<any>parent).runTest(function(child: d3kit.Chartlet) {
(parent as any).runTest(function(child: d3kit.Chartlet) {
expect(child.getPropertyValue('bar', 4, 0)).to.be.equal(8);
});
});
@@ -862,7 +862,7 @@ describe('Chartlet', function(){
})
.property('foo', function(d:number) {return 2 * d;});
(<any>parent).runTest(function(child: d3kit.Chartlet) {
(parent as any).runTest(function(child: d3kit.Chartlet) {
expect(child.getPropertyValue('foo', 4, 0)).to.be.equal(8);
});
});
@@ -878,7 +878,7 @@ describe('Chartlet', function(){
.property('bar', function(d:number) {return 3 * d;})
.property('baz', function(d:number) {return 4 * d;});
(<any>parent).runTest(function(child: d3kit.Chartlet) {
(parent as any).runTest(function(child: d3kit.Chartlet) {
expect(child.getPropertyValue('foo-x', 1, 0)).to.be.equal(2);
expect(child.getPropertyValue('bar-x', 1, 0)).to.be.equal(3);
expect(child.getPropertyValue('baz-x', 1, 0)).to.be.equal(4);
@@ -894,7 +894,7 @@ describe('Chartlet', function(){
.property('bar', function(d:number) {return 3 * d;})
.property('baz', function(d:number) {return 4 * d;});
(<any>parent).runTest(function(child: d3kit.Chartlet) {
(parent as any).runTest(function(child: d3kit.Chartlet) {
expect(child.getPropertyValue('foo', 1, 0)).to.be.equal(2);
expect(child.getPropertyValue('bar', 1, 0)).to.be.equal(3);
expect(child.getPropertyValue('baz', 1, 0)).to.be.equal(4);
@@ -914,7 +914,7 @@ describe('Chartlet', function(){
var child = new d3kit.Chartlet(callback, callback, callback, ['foo'])
.publishEventsTo(parent.getDispatcher());
(<any>child.getDispatcher()).foo(99);
(child.getDispatcher() as any).foo(99);
});
});
});
@@ -3,7 +3,7 @@
import * as DbMigrateBase from "db-migrate-base";
// Throw together a dummy driver
let db = <DbMigrateBase.Base>{};
let db = {} as DbMigrateBase.Base;
let callback = (err: any, response: any) => {
// Do nothing.
+1 -1
View File
@@ -3,7 +3,7 @@
import * as DbMigratePg from "db-migrate-pg";
// Throw together a dummy driver
let db = <DbMigratePg.PgDriver>{};
let db = {} as DbMigratePg.PgDriver;
let callback = (err: any, response: any) => {
// Do nothing.
+31
View File
@@ -0,0 +1,31 @@
import depsSort = require("deps-sort");
function browserifyTest(opts: depsSort.Options) {
const depsOpts: depsSort.Options = {
index: opts != null && opts.index,
dedupe: opts != null && opts.dedupe,
expose: opts.expose || { id: "file.txt" }
};
const res = depsSort(); // 'opts' are optional
res.pipe(depsSort(depsOpts));
res.once("error", (err: any) => {
console.error("module-deps error: ", err);
});
const inst: NodeJS.ReadWriteStream = depsSort({
index: true,
expose: { id: "file.txt" }
});
inst.on("file", (file, id) => {
console.log("file", file, id);
});
inst.on("package", (pkg) => {
console.log("package", pkg);
});
inst.on("transform", (tr, file) => {
console.log("transform", tr, file);
});
}
+85
View File
@@ -0,0 +1,85 @@
// Type definitions for deps-sort 2.0
// Project: https://github.com/browserify/deps-sort
// Definitions by: TeamworkGuy2 <https://github.com/TeamworkGuy2>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
import * as stream from "stream";
/**
* Return a new through stream that should get written module-deps objects and will output sorted objects.
*/
declare function depsSort(opts?: depsSort.Options): stream.Transform;
/**
* Sort module-deps output for deterministic browserify bundles.
*/
declare namespace depsSort {
/**
* module-deps constructor options
*/
interface Options {
/**
* When true, for each module-deps row, insert 'row.index' with the numeric index and
* 'row.indexDeps' like 'row.deps' but mapping require strings to row indices
*/
index?: boolean;
/**
* array of names or object mapping names to true not to mangle with integer indexes when 'index' is turned on.
* If 'expose' maps names to strings, those strings will be used to resolve the indexed references.
*/
expose?: string[] | { [name: string]: boolean | string };
/**
* Set 'row.dedupe' for files that match existing contents. Sets 'row.dedupeIndex' when 'index' is enabled.
* When 'row.dedupe' is set, 'row.sameDeps' will be set to a boolean of whether the dependencies at the dedupe target match (true) or just the source content (false).
*/
dedupe?: boolean;
[prop: string]: any;
}
/**
* Input objects are file objects in the module-deps shape. They must at least have these properties:
*/
interface InputRow {
/**
* a unique identifier for the file
*/
id: string;
/**
* the file contents
*/
source: string;
/**
* dependencies for this file, mapping strings as used in require() to row IDs
*/
deps: string[];
}
/**
* All the input properties, and:
*/
interface OutputRow {
/**
* when 'opts.index' is true, the sorted numeric index of the row
*/
index: number;
/**
* like 'row.deps', but mapping to 'row.index' instead of 'row.id'
*/
indexDeps: { [id: string]: number };
/**
* when 'opts.dedupe' is true, contains the row ID of a file with identical contents
*/
dedupe: string;
/**
* like 'row.dedupe', but contains the 'row.index' instead of 'row.id'
*/
dedupeIndex: number;
}
}
export = depsSort;
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"deps-sort-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+60 -3
View File
@@ -1,7 +1,64 @@
import { detect } from 'detect-browser';
import { BrowserName, BrowserInfo, detect } from 'detect-browser';
const browser = detect();
if (browser) {
const name: string = browser.name;
const version: string = browser.version;
const name: string | undefined = browser.name;
const version: string | undefined = browser.version;
const os: string | undefined | null = browser.os;
const bot: true | undefined = browser.bot;
}
const browserInfos: BrowserInfo[] = [];
// Those that can happen when 'detect' hits on a browser
browserInfos.push(
{
name: "chrome",
version: "1.2.3",
os: null
}
);
browserInfos.push(
{
name: "edge",
version: "24.5.3",
os: "Sun OS"
}
);
browserInfos.push(
{
name: "edge",
version: "13.0",
os: "Windows 10",
bot: true
}
);
// Those that could be returned when it's a bot
browserInfos.push(
{
name: "facebook",
version: "1.0.2",
os: "Linux",
bot: true
}
);
browserInfos.push(
{
name: "crios",
version: "2.9.4",
os: undefined,
bot: true
}
);
browserInfos.push(
{
bot: true
}
);
+20 -8
View File
@@ -1,30 +1,42 @@
// Type definitions for detect-browser 2.0
// Type definitions for detect-browser 3.0
// Project: https://github.com/DamonOehlman/detect-browser
// Definitions by: Rogier Schouten <https://github.com/rogierschouten>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
// Brian Caruso <https://github.com/carusology>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export {};
export type BrowserName =
"aol" |
"android" |
"bb10" |
"chrome" |
"crios" |
"edge" |
"facebook" |
"firefox" |
"fxios" |
"ie" |
"instagram" |
"ios" |
"ios-webview" |
"kakaotalk" |
"node" |
"opera" |
"phantomjs" |
"safari" |
"samsung" |
"vivaldi" |
"yandexbrowser" |
"node";
"yandexbrowser";
export interface BrowserInfo {
name: BrowserName;
version: string;
os: string;
name?: string;
version?: string;
os?: string | null;
bot?: true;
}
export function detect(): null | BrowserInfo;
export function detect(): null | false | BrowserInfo;
export function detectOS(userAgentString: string): null | string;
export function parseUserAgent(userAgentString: string): null | BrowserInfo;
export function getNodeVersion(): false | BrowserInfo;
@@ -0,0 +1,10 @@
import detectCharacterEncoding = require("detect-character-encoding");
const buf: Buffer = null as any;
const result: detectCharacterEncoding.Result | null = detectCharacterEncoding(buf);
if (result) {
const str: string = result.encoding;
const num: number = result.confidence;
}
+17
View File
@@ -0,0 +1,17 @@
// Type definitions for detect-character-encoding 0.7
// Project: https://github.com/sonicdoe/detect-character-encoding#readme
// Definitions by: BendingBender <https://github.com/BendingBender>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node"/>
export = detectCharacterEncoding;
declare function detectCharacterEncoding(buf: Buffer): detectCharacterEncoding.Result | null;
declare namespace detectCharacterEncoding {
interface Result {
encoding: string;
confidence: number;
}
}
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"detect-character-encoding-tests.ts"
]
}
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+10
View File
@@ -370,6 +370,11 @@ declare namespace Detox {
type Orientation = "portrait" | "landscape";
type Speed = "fast" | "slow";
interface LanguageAndLocale {
language?: string;
locale?: string;
}
interface DetoxInitOptions {
/**
* Detox exports device, expect, element, by and waitFor as globals by default, if you want to control their initialization manually, set init detox with initGlobals set to false.
@@ -416,5 +421,10 @@ declare namespace Detox {
* The added launchArgs will be passed through the launch command to the device and be accessible via [[NSProcessInfo processInfo] arguments]
*/
launchArgs?: any;
/**
* Launch config for specifying the native language and locale
*/
languageAndLocale?: LanguageAndLocale;
}
}
+3504 -1531
View File
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,418 @@
declare var hiddenField: ASPxClientHiddenField;
declare var mainCallbackPanel: ASPxClientCallbackPanel;
declare var loginPopup: ASPxClientPopupControl;
declare var searchButton: ASPxClientButton;
declare var searchComboBox: ASPxClientComboBox;
declare var roomsNumberSpinEdit: ASPxClientSpinEdit;
declare var adultsNumberSpinEdit: ASPxClientSpinEdit;
declare var childrenNumberSpinEdit: ASPxClientSpinEdit;
declare var checkInDateEdit: ASPxClientDateEdit;
declare var checkOutDateEdit: ASPxClientDateEdit;
declare var backSlider: ASPxClientImageSlider;
declare var locationComboBox: ASPxClientComboBox;
declare var nightyRateTrackBar: ASPxClientTrackBar;
declare var customerRatingTrackBar: ASPxClientTrackBar;
declare var ourRatingCheckBoxList: ASPxClientCheckBoxList;
declare var startFilterPopupControl: ASPxClientPopupControl;
declare var imagePopupControl: ASPxClientPopupControl;
declare var emailTextBox: ASPxClientTextBox;
declare var creditCardEmailTextBox: ASPxClientTextBox;
declare var accountEmailTextBox: ASPxClientTextBox;
declare var bookingPageControl: ASPxClientPageControl;
declare var paymentTypePageControl: ASPxClientPageControl;
declare var offerFormPopup: ASPxClientPopupControl;
declare var roomsSpinEdit: ASPxClientSpinEdit;
declare var adultsSpinEdit: ASPxClientSpinEdit;
declare var childrenSpinEdit: ASPxClientSpinEdit;
declare var hotelDetailsCallbackPanel: ASPxClientCallbackPanel;
declare var leftPanel: ASPxClientPanel;
declare var menuButton: ASPxClientButton;
declare var aboutWindow: ASPxClientPopupControl;
declare var offersZone: ASPxClientDockZone;
module DXDemo {
function showPage(page: string, params: { [key: string]: any }, skipHistory?: boolean): void {
var queryString = getQueryString(params || {});
hiddenField.Set("page", page);
hiddenField.Set("parameters", queryString);
hideMenu();
var uri = queryString.length ? (page + "?" + queryString) : page;
try {
if (!skipHistory && window.history && window.history.pushState)
window.history.pushState(uri, "", uri || "Default.aspx");
} catch (e) { }
mainCallbackPanel.PerformCallback(uri);
};
export function onMainMenuItemClick(s: ASPxClientMenu, e: ASPxClientMenuItemClickEventArgs): void {
switch (e.item.name) {
case "login":
hideMenu();
setTimeout(function () { loginPopup.ShowAtElementByID("MainCallbackPanel_ContentPane"); }, 300);
break;
case "offers":
showPage("SpecialOffers", {});
break;
default:
hideMenu();
setTimeout(function () { showAboutWindow(); }, 300);
break;
}
};
export function onLoginButtonClick(s: ASPxClientButton, e: ASPxClientButtonClickEventArgs): void {
loginPopup.Hide();
showAboutWindow();
};
export function onSearchButtonClick(): void {
if (ASPxClientEdit.ValidateGroup("DateEditors")) {
showPage("ShowHotels", {
location: searchComboBox.GetValue(),
checkin: getFormattedDate(<Date>checkInDateEdit.GetValue()),
checkout: getFormattedDate(<Date>checkOutDateEdit.GetValue()),
rooms: roomsNumberSpinEdit.GetValue() || 1,
adults: adultsNumberSpinEdit.GetValue() || 1,
children: childrenNumberSpinEdit.GetValue() || 0
});
}
};
export function onSearchComboBoxIndexChanged(s: ASPxClientComboBox, e: ASPxClientProcessingModeEventArgs): void {
hideMenu();
searchButton.AdjustControl();
};
export function onIndexOfferCloseClick(index: number): void {
var panel = <ASPxClientDockPanel>ASPxClientControl.GetControlCollection().GetByName("OfferDockPanel" + index);
var sibPanel = <ASPxClientDockPanel>ASPxClientControl.GetControlCollection().GetByName("OfferDockPanel" + (index == 1 ? 2 : 1));
panel.Hide();
sibPanel.MakeFloat();
sibPanel.SetWidth(offersZone.GetWidth());
sibPanel.Dock(offersZone);
};
export function onLogoClick(): void {
showPage("", null, false);
};
export function onMenuNavButtonCheckedChanged(s: ASPxClientCheckBox, e: ASPxClientProcessingModeEventArgs): void {
var mainContainer = mainCallbackPanel.GetMainElement();
if (s.GetChecked()) {
backSlider.Pause();
showMenu();
}
else {
hideMenu();
backSlider.Play();
}
};
export function onBackNavButtonClick(s: ASPxClientButton, e: ASPxClientButtonClickEventArgs): void {
var params = getCurrentQueryParams();
switch (getCurrentPage()) {
case "PrintInvoice":
showPage("Booking", params, false);
break;
case "Booking":
if (bookingPageControl.GetActiveTabIndex() > 0)
bookingPageControl.SetActiveTabIndex(bookingPageControl.GetActiveTabIndex() - 1);
else
showPage("ShowRooms", params, false);
break;
case "ShowRooms":
showPage("ShowHotels", params, false);
break;
case "ShowDetails":
showPage("ShowHotels", params, false);
break;
case "ShowHotels":
case "SpecialOffers":
showPage("", null, false);
break;
}
};
export function updateSearchResults(): void {
var params = getCurrentQueryParams();
params["location"] = locationComboBox.GetValue();
params["minprice"] = nightyRateTrackBar.GetPositionStart();
params["maxprice"] = nightyRateTrackBar.GetPositionEnd();
params["custrating"] = customerRatingTrackBar.GetPosition();
params["ourrating"] = ourRatingCheckBoxList.GetSelectedValues().join(",");
showPage("ShowHotels", params);
};
export function onBookHotelButtonClick(hotelID: string): void {
var queryParams = getCurrentQueryParams();
queryParams["hotelID"] = hotelID;
showPage("ShowRooms", queryParams);
};
export function onDetailsHotelButtonClick(hotelID: string): void {
var queryParams = getCurrentQueryParams();
queryParams["hotelID"] = hotelID;
showPage("ShowDetails", queryParams);
};
export function onShowStartFilterButtonClick(s: ASPxClientButton, e: ASPxClientButtonClickEventArgs): void {
startFilterPopupControl.ShowAtElementByID("MainCallbackPanel_ContentPane");
};
export function onChangeStartFilterButtonClick(s: ASPxClientButton, e: ASPxClientButtonClickEventArgs): void {
if (ASPxClientEdit.ValidateGroup("DateEditors")) {
var params = getCurrentQueryParams();
params["checkin"] = getFormattedDate(<Date>checkInDateEdit.GetValue());
params["checkout"] = getFormattedDate(<Date>checkOutDateEdit.GetValue());
params["rooms"] = roomsNumberSpinEdit.GetValue() || 1;
params["adults"] = adultsNumberSpinEdit.GetValue() || 1;
params["children"] = childrenNumberSpinEdit.GetValue() || 0;
startFilterPopupControl.Hide();
showPage(hiddenField.Get("page").toString(), params);
}
};
export function onBookRoomButtonClick(roomID: string): void {
var params = getCurrentQueryParams();
params["roomID"] = roomID;
showPage("Booking", params);
};
export function onShowRoomsButtonClick(): void {
var queryParams = getCurrentQueryParams();
showPage("ShowRooms", queryParams);
};
export function onShowDetailsButtonClick(): void {
var queryParams = getCurrentQueryParams();
showPage("ShowDetails", queryParams);
};
export function onRoomImageNavItemClick(roomID: string, pictureName: string): void {
setTimeout(function () {
imagePopupControl.PerformCallback(roomID + "|" + pictureName);
imagePopupControl.ShowAtElementByID("MainCallbackPanel_ContentPane");
}, 500);
};
export function onRoomsNavBarExpandedChanged(s: ASPxClientNavBar, e: ASPxClientNavBarGroupEventArgs): void {
ASPxClientControl.AdjustControls(s.GetMainElement());
};
export function onNextBookingStepButtonClick(step: number): void {
var valid = true;
var validationGroup = "";
if (step == 1)
validationGroup = "Account";
if (step == 2)
validationGroup = "RoomDetails";
if (step == 3)
validationGroup = "PaymentDetails";
switch (step) {
case 1:
valid = ASPxClientEdit.ValidateEditorsInContainer(bookingPageControl.GetMainElement(), "Account");
if (valid) {
emailTextBox.SetValue(accountEmailTextBox.GetValue());
creditCardEmailTextBox.SetValue(accountEmailTextBox.GetValue());
showPage("Booking", getCurrentQueryParams());
return;
}
break;
case 2:
valid = ASPxClientEdit.ValidateEditorsInContainer(bookingPageControl.GetMainElement(), "RoomDetails");
emailTextBox.SetValue(accountEmailTextBox.GetValue());
break;
case 3:
var paymentType = paymentTypePageControl.GetActiveTabIndex();
if (paymentType == 0)
valid = ASPxClientEdit.ValidateEditorsInContainer(bookingPageControl.GetMainElement(), "CreditCard");
else if (paymentType == 1)
valid = ASPxClientEdit.ValidateEditorsInContainer(bookingPageControl.GetMainElement(), "Cash");
else if (paymentType == 2)
valid = ASPxClientEdit.ValidateEditorsInContainer(bookingPageControl.GetMainElement(), "PayPal");
break;
}
if (valid) {
bookingPageControl.GetTab(step).SetEnabled(true);
bookingPageControl.SetActiveTabIndex(step);
}
};
export function onAccountCaptchaHiddenFieldInit(s: ASPxClientHiddenField, e: ASPxClientEventArgs): void {
if (s.Get("IsCaptchaValid")) {
bookingPageControl.GetTab(1).SetEnabled(true);
bookingPageControl.SetActiveTabIndex(1);
}
};
export function onFinishBookingStepButtonClick(): void {
showAboutWindow();
};
export function OnPrintInvoiceButtonClick(): void {
showPage("PrintInvoice", getCurrentQueryParams());
};
export function onOfferClick(offerID: string): void {
offerFormPopup.SetContentHtml("");
offerFormPopup.PerformCallback(offerID);
var panel = <ASPxClientDockPanel>ASPxClientControl.GetControlCollection().GetByName("DockPanel" + offerID);
var panelElement = <HTMLElement>panel.GetMainElement();
if (panelElement.offsetWidth < 330 || panelElement.offsetHeight < 250) {
offerFormPopup.SetWidth(400);
offerFormPopup.SetHeight(280);
offerFormPopup.ShowAtElementByID("SpecialOffersContainer");
}
else {
offerFormPopup.SetWidth(panelElement.offsetWidth);
offerFormPopup.SetHeight(panelElement.offsetHeight);
offerFormPopup.ShowAtElement(panelElement);
}
};
export function onSpecialOfferCheckButtonClick(hotelID: string, locationID: string): void {
if (ASPxClientEdit.ValidateGroup("DateEditors")) {
var queryParams: { [key: string]: any } = {
location: locationID,
hotelID: hotelID,
checkin: getFormattedDate(<Date>checkInDateEdit.GetValue()),
checkout: getFormattedDate(<Date>checkOutDateEdit.GetValue()),
rooms: roomsSpinEdit.GetValue() || 1,
adults: adultsSpinEdit.GetValue() || 1,
children: childrenSpinEdit.GetValue() || 0
};
showPage("ShowRooms", queryParams);
}
};
export function onIndexOfferClick(): void {
showPage("SpecialOffers", {});
};
export function onControlsInit(): void {
ASPxClientUtils.AttachEventToElement(window, 'popstate', onHistoryPopState);
var pathParts = document.location.href.split("/");
var url = pathParts[pathParts.length - 1];
try {
if (window.history)
window.history.replaceState(url, "");
} catch (e) { }
ASPxClientUtils.AttachEventToElement(window, "resize", onWindowResize);
if (ASPxClientUtils.iOSPlatform) {
// animate
}
};
export function updateRatingLabels(ratingControl: ASPxClientTrackBar) {
var start = ratingControl.GetPositionStart().toString();
var end = ratingControl.GetPositionEnd().toString();
document.getElementById("cpLeftLabelID").innerHTML = start + " " + end;
};
export function onRatingControlItemClick(s: ASPxClientRatingControl, e: ASPxClientRatingControlItemClickEventArgs): void {
hotelDetailsCallbackPanel.PerformCallback(s.GetValue().toString());
};
export function onInputKeyDown(s: ASPxClientTextBox, e: ASPxClientEditKeyEventArgs): void {
var keyCode = ASPxClientUtils.GetKeyCode(e.htmlEvent);
if (keyCode == 13)
(<HTMLElement>s.GetInputElement()).blur();
};
function getCurrentPage(): string {
var hfPage = <string>hiddenField.Get("page");
if (hfPage)
return hfPage;
var pathParts = document.location.pathname.split("/");
return pathParts[pathParts.length - 1];
};
function showAboutWindow(): void {
aboutWindow.ShowAtElementByID("MainCallbackPanel_ContentPane");
};
function hideMenu(): void {
leftPanel.Collapse();
if (menuButton.GetMainElement() && menuButton.GetChecked())
menuButton.SetChecked(false);
};
function showMenu(): void {
leftPanel.Expand();
};
var _resizeSpecialOffersTimeoutID = -1;
function onWindowResize(): void {
switch (<string>hiddenField.Get("page")) {
case "SpecialOffers":
if (_resizeSpecialOffersTimeoutID == -1)
_resizeSpecialOffersTimeoutID = setTimeout(resizeSpecialOffers, 200);
break;
}
hidePopups("AboutWindow", "StartFilterPopupControl", "LoginPopup", "OfferFormPopup", "ImagePopupControl");
};
function hidePopups(...names: string[]): void {
for (var i = 0; i < names.length; i++) {
var popupControl = <ASPxClientPopupControl>ASPxClientControl.GetControlCollection().GetByName(names[i]);
popupControl.Hide();
}
};
function resizeSpecialOffers(): void {
for (var i = 1; i <= 4; i++) {
var panel = <ASPxClientDockPanel>ASPxClientControl.GetControlCollection().GetByName("DockPanel" + i);
if (panel && panel.IsVisible()) {
var zone = panel.GetOwnerZone();
zone.SetWidth((<HTMLElement>(<HTMLElement>zone.GetMainElement()).parentNode).offsetWidth)
}
}
_resizeSpecialOffersTimeoutID = -1;
};
function getFormattedDate(date: Date): string {
return (date.getMonth() + 1) + "-" + date.getDate() + "-" + date.getFullYear();
};
function getCurrentQueryParams(): { [key:string]: any } {
var hfParams = <string>hiddenField.Get("parameters");
if (hfParams)
return getParamsByQueryString(hfParams);
var query = document.location.search;
if (query[0] === "?")
query = query.substr(1);
return getParamsByQueryString(query);
};
function getQueryString(params: { [key:string]: any }): string {
var queryItems: any[] = [];
for (var key in params) {
if (!params.hasOwnProperty(key)) continue;
queryItems.push(key + "=" + params[key]);
}
if (queryItems.length > 0)
return queryItems.join("&");
return "";
};
function getParamsByQueryString(queryString: string): { [key: string]: string } {
var result: { [key: string]: any } = {};
if (queryString) {
var queryStringArray = queryString.split("&");
for (var i = 0; i < queryStringArray.length; i++) {
var part = queryStringArray[i].split('=');
if (part.length != 2) continue;
result[part[0]] = decodeURIComponent(part[1].replace(/\+/g, " "));
}
}
return result;
};
function onHistoryPopState(evt: any): void {
if (evt.state !== null && evt.state !== undefined) {
var uriParts = evt.state.split("?");
showPage(uriParts[0], getParamsByQueryString(uriParts[1]), true);
}
};
}
File diff suppressed because it is too large Load Diff
+32
View File
@@ -0,0 +1,32 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"strictFunctionTypes": true,
"baseUrl": "../../",
"typeRoots": [
"../../"
],
"types": [],
"paths": {
"devexpress-web": [
"devexpress-web/v172"
],
"devexpress-web/*": [
"devexpress-web/v172/*"
]
},
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"devexpress-web-tests.ts"
]
}
+79
View File
@@ -0,0 +1,79 @@
{
"extends": "dtslint/dt.json",
"rules": {
"adjacent-overload-signatures": false,
"array-type": false,
"arrow-return-shorthand": false,
"ban-types": false,
"callable-types": false,
"comment-format": false,
"dt-header": false,
"eofline": false,
"export-just-namespace": false,
"import-spacing": false,
"interface-name": false,
"interface-over-type-literal": false,
"jsdoc-format": false,
"max-line-length": false,
"member-access": false,
"new-parens": false,
"no-any-union": false,
"no-boolean-literal-compare": false,
"no-conditional-assignment": false,
"no-consecutive-blank-lines": false,
"no-construct": false,
"no-declare-current-package": false,
"no-duplicate-imports": false,
"no-duplicate-variable": false,
"no-empty-interface": false,
"no-for-in-array": false,
"no-inferrable-types": false,
"no-internal-module": false,
"no-irregular-whitespace": false,
"no-mergeable-namespace": false,
"no-misused-new": false,
"no-namespace": false,
"no-object-literal-type-assertion": false,
"no-padding": false,
"no-redundant-jsdoc": false,
"no-redundant-jsdoc-2": false,
"no-redundant-undefined": false,
"no-reference-import": false,
"no-relative-import-in-test": false,
"no-self-import": false,
"no-single-declare-module": false,
"no-string-throw": false,
"no-unnecessary-callback-wrapper": false,
"no-unnecessary-class": false,
"no-unnecessary-generics": false,
"no-unnecessary-qualifier": false,
"no-unnecessary-type-assertion": false,
"no-useless-files": false,
"no-var-keyword": false,
"no-var-requires": false,
"no-void-expression": false,
"no-trailing-whitespace": false,
"object-literal-key-quotes": false,
"object-literal-shorthand": false,
"one-line": false,
"one-variable-per-declaration": false,
"only-arrow-functions": false,
"prefer-conditional-expression": false,
"prefer-const": false,
"prefer-declare-function": false,
"prefer-for-of": false,
"prefer-method-signature": false,
"prefer-template": false,
"radix": false,
"semicolon": false,
"space-before-function-paren": false,
"space-within-parens": false,
"strict-export-declare-modifiers": false,
"trim-file": false,
"triple-equals": false,
"typedef-whitespace": false,
"unified-signatures": false,
"void-return": false,
"whitespace": false
}
}
@@ -0,0 +1,418 @@
declare var hiddenField: ASPxClientHiddenField;
declare var mainCallbackPanel: ASPxClientCallbackPanel;
declare var loginPopup: ASPxClientPopupControl;
declare var searchButton: ASPxClientButton;
declare var searchComboBox: ASPxClientComboBox;
declare var roomsNumberSpinEdit: ASPxClientSpinEdit;
declare var adultsNumberSpinEdit: ASPxClientSpinEdit;
declare var childrenNumberSpinEdit: ASPxClientSpinEdit;
declare var checkInDateEdit: ASPxClientDateEdit;
declare var checkOutDateEdit: ASPxClientDateEdit;
declare var backSlider: ASPxClientImageSlider;
declare var locationComboBox: ASPxClientComboBox;
declare var nightyRateTrackBar: ASPxClientTrackBar;
declare var customerRatingTrackBar: ASPxClientTrackBar;
declare var ourRatingCheckBoxList: ASPxClientCheckBoxList;
declare var startFilterPopupControl: ASPxClientPopupControl;
declare var imagePopupControl: ASPxClientPopupControl;
declare var emailTextBox: ASPxClientTextBox;
declare var creditCardEmailTextBox: ASPxClientTextBox;
declare var accountEmailTextBox: ASPxClientTextBox;
declare var bookingPageControl: ASPxClientPageControl;
declare var paymentTypePageControl: ASPxClientPageControl;
declare var offerFormPopup: ASPxClientPopupControl;
declare var roomsSpinEdit: ASPxClientSpinEdit;
declare var adultsSpinEdit: ASPxClientSpinEdit;
declare var childrenSpinEdit: ASPxClientSpinEdit;
declare var hotelDetailsCallbackPanel: ASPxClientCallbackPanel;
declare var leftPanel: ASPxClientPanel;
declare var menuButton: ASPxClientButton;
declare var aboutWindow: ASPxClientPopupControl;
declare var offersZone: ASPxClientDockZone;
module DXDemo {
function showPage(page: string, params: { [key: string]: any }, skipHistory?: boolean): void {
var queryString = getQueryString(params || {});
hiddenField.Set("page", page);
hiddenField.Set("parameters", queryString);
hideMenu();
var uri = queryString.length ? (page + "?" + queryString) : page;
try {
if (!skipHistory && window.history && window.history.pushState)
window.history.pushState(uri, "", uri || "Default.aspx");
} catch (e) { }
mainCallbackPanel.PerformCallback(uri);
};
export function onMainMenuItemClick(s: ASPxClientMenu, e: ASPxClientMenuItemClickEventArgs): void {
switch (e.item.name) {
case "login":
hideMenu();
setTimeout(function () { loginPopup.ShowAtElementByID("MainCallbackPanel_ContentPane"); }, 300);
break;
case "offers":
showPage("SpecialOffers", {});
break;
default:
hideMenu();
setTimeout(function () { showAboutWindow(); }, 300);
break;
}
};
export function onLoginButtonClick(s: ASPxClientButton, e: ASPxClientButtonClickEventArgs): void {
loginPopup.Hide();
showAboutWindow();
};
export function onSearchButtonClick(): void {
if (ASPxClientEdit.ValidateGroup("DateEditors")) {
showPage("ShowHotels", {
location: searchComboBox.GetValue(),
checkin: getFormattedDate(<Date>checkInDateEdit.GetValue()),
checkout: getFormattedDate(<Date>checkOutDateEdit.GetValue()),
rooms: roomsNumberSpinEdit.GetValue() || 1,
adults: adultsNumberSpinEdit.GetValue() || 1,
children: childrenNumberSpinEdit.GetValue() || 0
});
}
};
export function onSearchComboBoxIndexChanged(s: ASPxClientComboBox, e: ASPxClientProcessingModeEventArgs): void {
hideMenu();
searchButton.AdjustControl();
};
export function onIndexOfferCloseClick(index: number): void {
var panel = <ASPxClientDockPanel>ASPxClientControl.GetControlCollection().GetByName("OfferDockPanel" + index);
var sibPanel = <ASPxClientDockPanel>ASPxClientControl.GetControlCollection().GetByName("OfferDockPanel" + (index == 1 ? 2 : 1));
panel.Hide();
sibPanel.MakeFloat();
sibPanel.SetWidth(offersZone.GetWidth());
sibPanel.Dock(offersZone);
};
export function onLogoClick(): void {
showPage("", null, false);
};
export function onMenuNavButtonCheckedChanged(s: ASPxClientCheckBox, e: ASPxClientProcessingModeEventArgs): void {
var mainContainer = mainCallbackPanel.GetMainElement();
if (s.GetChecked()) {
backSlider.Pause();
showMenu();
}
else {
hideMenu();
backSlider.Play();
}
};
export function onBackNavButtonClick(s: ASPxClientButton, e: ASPxClientButtonClickEventArgs): void {
var params = getCurrentQueryParams();
switch (getCurrentPage()) {
case "PrintInvoice":
showPage("Booking", params, false);
break;
case "Booking":
if (bookingPageControl.GetActiveTabIndex() > 0)
bookingPageControl.SetActiveTabIndex(bookingPageControl.GetActiveTabIndex() - 1);
else
showPage("ShowRooms", params, false);
break;
case "ShowRooms":
showPage("ShowHotels", params, false);
break;
case "ShowDetails":
showPage("ShowHotels", params, false);
break;
case "ShowHotels":
case "SpecialOffers":
showPage("", null, false);
break;
}
};
export function updateSearchResults(): void {
var params = getCurrentQueryParams();
params["location"] = locationComboBox.GetValue();
params["minprice"] = nightyRateTrackBar.GetPositionStart();
params["maxprice"] = nightyRateTrackBar.GetPositionEnd();
params["custrating"] = customerRatingTrackBar.GetPosition();
params["ourrating"] = ourRatingCheckBoxList.GetSelectedValues().join(",");
showPage("ShowHotels", params);
};
export function onBookHotelButtonClick(hotelID: string): void {
var queryParams = getCurrentQueryParams();
queryParams["hotelID"] = hotelID;
showPage("ShowRooms", queryParams);
};
export function onDetailsHotelButtonClick(hotelID: string): void {
var queryParams = getCurrentQueryParams();
queryParams["hotelID"] = hotelID;
showPage("ShowDetails", queryParams);
};
export function onShowStartFilterButtonClick(s: ASPxClientButton, e: ASPxClientButtonClickEventArgs): void {
startFilterPopupControl.ShowAtElementByID("MainCallbackPanel_ContentPane");
};
export function onChangeStartFilterButtonClick(s: ASPxClientButton, e: ASPxClientButtonClickEventArgs): void {
if (ASPxClientEdit.ValidateGroup("DateEditors")) {
var params = getCurrentQueryParams();
params["checkin"] = getFormattedDate(<Date>checkInDateEdit.GetValue());
params["checkout"] = getFormattedDate(<Date>checkOutDateEdit.GetValue());
params["rooms"] = roomsNumberSpinEdit.GetValue() || 1;
params["adults"] = adultsNumberSpinEdit.GetValue() || 1;
params["children"] = childrenNumberSpinEdit.GetValue() || 0;
startFilterPopupControl.Hide();
showPage(hiddenField.Get("page").toString(), params);
}
};
export function onBookRoomButtonClick(roomID: string): void {
var params = getCurrentQueryParams();
params["roomID"] = roomID;
showPage("Booking", params);
};
export function onShowRoomsButtonClick(): void {
var queryParams = getCurrentQueryParams();
showPage("ShowRooms", queryParams);
};
export function onShowDetailsButtonClick(): void {
var queryParams = getCurrentQueryParams();
showPage("ShowDetails", queryParams);
};
export function onRoomImageNavItemClick(roomID: string, pictureName: string): void {
setTimeout(function () {
imagePopupControl.PerformCallback(roomID + "|" + pictureName);
imagePopupControl.ShowAtElementByID("MainCallbackPanel_ContentPane");
}, 500);
};
export function onRoomsNavBarExpandedChanged(s: ASPxClientNavBar, e: ASPxClientNavBarGroupEventArgs): void {
ASPxClientControl.AdjustControls(s.GetMainElement());
};
export function onNextBookingStepButtonClick(step: number): void {
var valid = true;
var validationGroup = "";
if (step == 1)
validationGroup = "Account";
if (step == 2)
validationGroup = "RoomDetails";
if (step == 3)
validationGroup = "PaymentDetails";
switch (step) {
case 1:
valid = ASPxClientEdit.ValidateEditorsInContainer(bookingPageControl.GetMainElement(), "Account");
if (valid) {
emailTextBox.SetValue(accountEmailTextBox.GetValue());
creditCardEmailTextBox.SetValue(accountEmailTextBox.GetValue());
showPage("Booking", getCurrentQueryParams());
return;
}
break;
case 2:
valid = ASPxClientEdit.ValidateEditorsInContainer(bookingPageControl.GetMainElement(), "RoomDetails");
emailTextBox.SetValue(accountEmailTextBox.GetValue());
break;
case 3:
var paymentType = paymentTypePageControl.GetActiveTabIndex();
if (paymentType == 0)
valid = ASPxClientEdit.ValidateEditorsInContainer(bookingPageControl.GetMainElement(), "CreditCard");
else if (paymentType == 1)
valid = ASPxClientEdit.ValidateEditorsInContainer(bookingPageControl.GetMainElement(), "Cash");
else if (paymentType == 2)
valid = ASPxClientEdit.ValidateEditorsInContainer(bookingPageControl.GetMainElement(), "PayPal");
break;
}
if (valid) {
bookingPageControl.GetTab(step).SetEnabled(true);
bookingPageControl.SetActiveTabIndex(step);
}
};
export function onAccountCaptchaHiddenFieldInit(s: ASPxClientHiddenField, e: ASPxClientEventArgs): void {
if (s.Get("IsCaptchaValid")) {
bookingPageControl.GetTab(1).SetEnabled(true);
bookingPageControl.SetActiveTabIndex(1);
}
};
export function onFinishBookingStepButtonClick(): void {
showAboutWindow();
};
export function OnPrintInvoiceButtonClick(): void {
showPage("PrintInvoice", getCurrentQueryParams());
};
export function onOfferClick(offerID: string): void {
offerFormPopup.SetContentHtml("");
offerFormPopup.PerformCallback(offerID);
var panel = <ASPxClientDockPanel>ASPxClientControl.GetControlCollection().GetByName("DockPanel" + offerID);
var panelElement = <HTMLElement>panel.GetMainElement();
if (panelElement.offsetWidth < 330 || panelElement.offsetHeight < 250) {
offerFormPopup.SetWidth(400);
offerFormPopup.SetHeight(280);
offerFormPopup.ShowAtElementByID("SpecialOffersContainer");
}
else {
offerFormPopup.SetWidth(panelElement.offsetWidth);
offerFormPopup.SetHeight(panelElement.offsetHeight);
offerFormPopup.ShowAtElement(panelElement);
}
};
export function onSpecialOfferCheckButtonClick(hotelID: string, locationID: string): void {
if (ASPxClientEdit.ValidateGroup("DateEditors")) {
var queryParams: { [key: string]: any } = {
location: locationID,
hotelID: hotelID,
checkin: getFormattedDate(<Date>checkInDateEdit.GetValue()),
checkout: getFormattedDate(<Date>checkOutDateEdit.GetValue()),
rooms: roomsSpinEdit.GetValue() || 1,
adults: adultsSpinEdit.GetValue() || 1,
children: childrenSpinEdit.GetValue() || 0
};
showPage("ShowRooms", queryParams);
}
};
export function onIndexOfferClick(): void {
showPage("SpecialOffers", {});
};
export function onControlsInit(): void {
ASPxClientUtils.AttachEventToElement(window, 'popstate', onHistoryPopState);
var pathParts = document.location.href.split("/");
var url = pathParts[pathParts.length - 1];
try {
if (window.history)
window.history.replaceState(url, "");
} catch (e) { }
ASPxClientUtils.AttachEventToElement(window, "resize", onWindowResize);
if (ASPxClientUtils.iOSPlatform) {
// animate
}
};
export function updateRatingLabels(ratingControl: ASPxClientTrackBar) {
var start = ratingControl.GetPositionStart().toString();
var end = ratingControl.GetPositionEnd().toString();
document.getElementById("cpLeftLabelID").innerHTML = start + " " + end;
};
export function onRatingControlItemClick(s: ASPxClientRatingControl, e: ASPxClientRatingControlItemClickEventArgs): void {
hotelDetailsCallbackPanel.PerformCallback(s.GetValue().toString());
};
export function onInputKeyDown(s: ASPxClientTextBox, e: ASPxClientEditKeyEventArgs): void {
var keyCode = ASPxClientUtils.GetKeyCode(e.htmlEvent);
if (keyCode == 13)
(<HTMLElement>s.GetInputElement()).blur();
};
function getCurrentPage(): string {
var hfPage = <string>hiddenField.Get("page");
if (hfPage)
return hfPage;
var pathParts = document.location.pathname.split("/");
return pathParts[pathParts.length - 1];
};
function showAboutWindow(): void {
aboutWindow.ShowAtElementByID("MainCallbackPanel_ContentPane");
};
function hideMenu(): void {
leftPanel.Collapse();
if (menuButton.GetMainElement() && menuButton.GetChecked())
menuButton.SetChecked(false);
};
function showMenu(): void {
leftPanel.Expand();
};
var _resizeSpecialOffersTimeoutID = -1;
function onWindowResize(): void {
switch (<string>hiddenField.Get("page")) {
case "SpecialOffers":
if (_resizeSpecialOffersTimeoutID == -1)
_resizeSpecialOffersTimeoutID = setTimeout(resizeSpecialOffers, 200);
break;
}
hidePopups("AboutWindow", "StartFilterPopupControl", "LoginPopup", "OfferFormPopup", "ImagePopupControl");
};
function hidePopups(...names: string[]): void {
for (var i = 0; i < names.length; i++) {
var popupControl = <ASPxClientPopupControl>ASPxClientControl.GetControlCollection().GetByName(names[i]);
popupControl.Hide();
}
};
function resizeSpecialOffers(): void {
for (var i = 1; i <= 4; i++) {
var panel = <ASPxClientDockPanel>ASPxClientControl.GetControlCollection().GetByName("DockPanel" + i);
if (panel && panel.IsVisible()) {
var zone = panel.GetOwnerZone();
zone.SetWidth((<HTMLElement>(<HTMLElement>zone.GetMainElement()).parentNode).offsetWidth)
}
}
_resizeSpecialOffersTimeoutID = -1;
};
function getFormattedDate(date: Date): string {
return (date.getMonth() + 1) + "-" + date.getDate() + "-" + date.getFullYear();
};
function getCurrentQueryParams(): { [key:string]: any } {
var hfParams = <string>hiddenField.Get("parameters");
if (hfParams)
return getParamsByQueryString(hfParams);
var query = document.location.search;
if (query[0] === "?")
query = query.substr(1);
return getParamsByQueryString(query);
};
function getQueryString(params: { [key:string]: any }): string {
var queryItems: any[] = [];
for (var key in params) {
if (!params.hasOwnProperty(key)) continue;
queryItems.push(key + "=" + params[key]);
}
if (queryItems.length > 0)
return queryItems.join("&");
return "";
};
function getParamsByQueryString(queryString: string): { [key: string]: string } {
var result: { [key: string]: any } = {};
if (queryString) {
var queryStringArray = queryString.split("&");
for (var i = 0; i < queryStringArray.length; i++) {
var part = queryStringArray[i].split('=');
if (part.length != 2) continue;
result[part[0]] = decodeURIComponent(part[1].replace(/\+/g, " "));
}
}
return result;
};
function onHistoryPopState(evt: any): void {
if (evt.state !== null && evt.state !== undefined) {
var uriParts = evt.state.split("?");
showPage(uriParts[0], getParamsByQueryString(uriParts[1]), true);
}
};
}
File diff suppressed because it is too large Load Diff
+32
View File
@@ -0,0 +1,32 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"strictFunctionTypes": true,
"baseUrl": "../../",
"typeRoots": [
"../../"
],
"types": [],
"paths": {
"devexpress-web": [
"devexpress-web/v181"
],
"devexpress-web/*": [
"devexpress-web/v181/*"
]
},
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"devexpress-web-tests.ts"
]
}
+79
View File
@@ -0,0 +1,79 @@
{
"extends": "dtslint/dt.json",
"rules": {
"adjacent-overload-signatures": false,
"array-type": false,
"arrow-return-shorthand": false,
"ban-types": false,
"callable-types": false,
"comment-format": false,
"dt-header": false,
"eofline": false,
"export-just-namespace": false,
"import-spacing": false,
"interface-name": false,
"interface-over-type-literal": false,
"jsdoc-format": false,
"max-line-length": false,
"member-access": false,
"new-parens": false,
"no-any-union": false,
"no-boolean-literal-compare": false,
"no-conditional-assignment": false,
"no-consecutive-blank-lines": false,
"no-construct": false,
"no-declare-current-package": false,
"no-duplicate-imports": false,
"no-duplicate-variable": false,
"no-empty-interface": false,
"no-for-in-array": false,
"no-inferrable-types": false,
"no-internal-module": false,
"no-irregular-whitespace": false,
"no-mergeable-namespace": false,
"no-misused-new": false,
"no-namespace": false,
"no-object-literal-type-assertion": false,
"no-padding": false,
"no-redundant-jsdoc": false,
"no-redundant-jsdoc-2": false,
"no-redundant-undefined": false,
"no-reference-import": false,
"no-relative-import-in-test": false,
"no-self-import": false,
"no-single-declare-module": false,
"no-string-throw": false,
"no-unnecessary-callback-wrapper": false,
"no-unnecessary-class": false,
"no-unnecessary-generics": false,
"no-unnecessary-qualifier": false,
"no-unnecessary-type-assertion": false,
"no-useless-files": false,
"no-var-keyword": false,
"no-var-requires": false,
"no-void-expression": false,
"no-trailing-whitespace": false,
"object-literal-key-quotes": false,
"object-literal-shorthand": false,
"one-line": false,
"one-variable-per-declaration": false,
"only-arrow-functions": false,
"prefer-conditional-expression": false,
"prefer-const": false,
"prefer-declare-function": false,
"prefer-for-of": false,
"prefer-method-signature": false,
"prefer-template": false,
"radix": false,
"semicolon": false,
"space-before-function-paren": false,
"space-within-parens": false,
"strict-export-declare-modifiers": false,
"trim-file": false,
"triple-equals": false,
"typedef-whitespace": false,
"unified-signatures": false,
"void-return": false,
"whitespace": false
}
}
+8
View File
@@ -1731,3 +1731,11 @@ interface GanttStatic {
declare var gantt: GanttStatic;
declare var Gantt: GanttEnterprise;
declare module "gantt" {
export = gantt;
}
declare module "Gantt" {
export = GanttEnterprise;
}
+81
View File
@@ -0,0 +1,81 @@
import Dicer = require("dicer");
import * as fs from "fs";
import * as stream from "stream";
function testDicerSyntax() {
const opts: Dicer.Config = {
boundary: "testing",
};
const dicer = new Dicer(opts);
const opts2: Dicer.Config = {
headerFirst: true,
maxHeaderPairs: 1,
};
const opts3: Dicer.Config = {
boundary: "more-testing",
headerFirst: false,
maxHeaderPairs: 8,
};
dicer.setBoundary("new-testing-boundary");
dicer.on("part", handleDicerPartStream);
dicer.on("finish", () => {
console.log("dicer parsing finished");
});
dicer.on("preamble", part => {
console.log("dicer preamble to new part");
});
dicer.on("trailer", data => {
console.log(`dicer trailing data found: ${data.length} bytes`);
});
dicer.on("close", () => {
console.log("dicer close");
});
dicer.on("drain", () => {
console.log("dicer drain");
});
dicer.on("error", err => {
console.error(`dicer error: ${err.message || JSON.stringify(err)}`);
});
dicer.on("finish", () => {
console.log("dicer finish");
});
dicer.on("pipe", (src: stream.Readable) => {
console.log("dicer pipe");
});
dicer.on("unpipe", (src: stream.Readable) => {
console.log("dicer unpipe");
});
const inputFileStream = fs.createReadStream("in-test-file.txt");
inputFileStream.pipe(dicer);
}
/**
* Handle a part found by a Dicer parser
*
* @param part Part found
*/
function handleDicerPartStream(part: Dicer.PartStream) {
console.log("dicer part found");
const outputFileStream = fs.createWriteStream("out-test-file.txt");
part.on("readable", () => {
console.log("part readable");
});
part.on("header", header => {
console.log(`part header found:\n${JSON.stringify(header)}`);
});
part.on("data", () => {
console.log("part data");
});
part.on("finish", () => {
console.log("part finished");
});
part.on("error", err => {
console.error(`part error: ${err.message || JSON.stringify(err)}`);
});
part.on("end", () => {
console.log("part ended");
});
part.on("close", () => {
console.log("part closed");
});
part.pipe(outputFileStream);
}
+167
View File
@@ -0,0 +1,167 @@
// Type definitions for dicer 0.2
// Project: https://github.com/mscdex/dicer
// Definitions by: Robin Goupil <https://github.com/GoupilRobin>
// BendingBender <https://github.com/BendingBender>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
/// <reference types="node" />
export = Dicer;
import stream = require("stream");
// tslint:disable:unified-signatures
/**
* A very fast streaming multipart parser for node.js.
* Dicer is a WritableStream
*
* Dicer (special) events:
* - on('finish', ()) - Emitted when all parts have been parsed and the Dicer instance has been ended.
* - on('part', (stream: PartStream)) - Emitted when a new part has been found.
* - on('preamble', (stream: PartStream)) - Emitted for preamble if you should happen to need it (can usually be ignored).
* - on('trailer', (data: Buffer)) - Emitted when trailing data was found after the terminating boundary (as with the preamble, this can usually be ignored too).
*/
declare class Dicer extends stream.Writable {
/**
* Creates and returns a new Dicer instance with the following valid config settings:
*
* @param config The configuration to use
*/
constructor(config: Dicer.Config);
/**
* Sets the boundary to use for parsing and performs some initialization needed for parsing.
* You should only need to use this if you set headerFirst to true in the constructor and are parsing the boundary from the preamble header.
*
* @param boundary The boundary to use
*/
setBoundary(boundary: string): void;
addListener(event: "finish", listener: () => void): this;
addListener(event: "part", listener: (stream: Dicer.PartStream) => void): this;
addListener(event: "preamble", listener: (stream: Dicer.PartStream) => void): this;
addListener(event: "trailer", listener: (data: Buffer) => void): this;
addListener(event: "close", listener: () => void): this;
addListener(event: "drain", listener: () => void): this;
addListener(event: "error", listener: (err: Error) => void): this;
addListener(event: "pipe", listener: (src: stream.Readable) => void): this;
addListener(event: "unpipe", listener: (src: stream.Readable) => void): this;
addListener(event: string, listener: (...args: any[]) => void): this;
on(event: "finish", listener: () => void): this;
on(event: "part", listener: (stream: Dicer.PartStream) => void): this;
on(event: "preamble", listener: (stream: Dicer.PartStream) => void): this;
on(event: "trailer", listener: (data: Buffer) => void): this;
on(event: "close", listener: () => void): this;
on(event: "drain", listener: () => void): this;
on(event: "error", listener: (err: Error) => void): this;
on(event: "pipe", listener: (src: stream.Readable) => void): this;
on(event: "unpipe", listener: (src: stream.Readable) => void): this;
on(event: string, listener: (...args: any[]) => void): this;
once(event: "finish", listener: () => void): this;
once(event: "part", listener: (stream: Dicer.PartStream) => void): this;
once(event: "preamble", listener: (stream: Dicer.PartStream) => void): this;
once(event: "trailer", listener: (data: Buffer) => void): this;
once(event: "close", listener: () => void): this;
once(event: "drain", listener: () => void): this;
once(event: "error", listener: (err: Error) => void): this;
once(event: "pipe", listener: (src: stream.Readable) => void): this;
once(event: "unpipe", listener: (src: stream.Readable) => void): this;
once(event: string, listener: (...args: any[]) => void): this;
prependListener(event: "finish", listener: () => void): this;
prependListener(event: "part", listener: (stream: Dicer.PartStream) => void): this;
prependListener(event: "preamble", listener: (stream: Dicer.PartStream) => void): this;
prependListener(event: "trailer", listener: (data: Buffer) => void): this;
prependListener(event: "close", listener: () => void): this;
prependListener(event: "drain", listener: () => void): this;
prependListener(event: "error", listener: (err: Error) => void): this;
prependListener(event: "pipe", listener: (src: stream.Readable) => void): this;
prependListener(event: "unpipe", listener: (src: stream.Readable) => void): this;
prependListener(event: string, listener: (...args: any[]) => void): this;
prependOnceListener(event: "finish", listener: () => void): this;
prependOnceListener(event: "part", listener: (stream: Dicer.PartStream) => void): this;
prependOnceListener(event: "preamble", listener: (stream: Dicer.PartStream) => void): this;
prependOnceListener(event: "trailer", listener: (data: Buffer) => void): this;
prependOnceListener(event: "close", listener: () => void): this;
prependOnceListener(event: "drain", listener: () => void): this;
prependOnceListener(event: "error", listener: (err: Error) => void): this;
prependOnceListener(event: "pipe", listener: (src: stream.Readable) => void): this;
prependOnceListener(event: "unpipe", listener: (src: stream.Readable) => void): this;
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
removeListener(event: "finish", listener: () => void): this;
removeListener(event: "part", listener: (stream: Dicer.PartStream) => void): this;
removeListener(event: "preamble", listener: (stream: Dicer.PartStream) => void): this;
removeListener(event: "trailer", listener: (data: Buffer) => void): this;
removeListener(event: "close", listener: () => void): this;
removeListener(event: "drain", listener: () => void): this;
removeListener(event: "error", listener: (err: Error) => void): this;
removeListener(event: "pipe", listener: (src: stream.Readable) => void): this;
removeListener(event: "unpipe", listener: (src: stream.Readable) => void): this;
removeListener(event: string, listener: (...args: any[]) => void): this;
}
declare namespace Dicer {
interface Config {
/**
* This is the boundary used to detect the beginning of a new part.
*/
boundary?: string;
/**
* If true, preamble header parsing will be performed first.
*/
headerFirst?: boolean;
/**
* The maximum number of header key=>value pairs to parse Default: 2000 (same as node's http).
*/
maxHeaderPairs?: number;
}
/**
* PartStream is a _ReadableStream_
*
* PartStream (special) events:
* - on('header', (header: object)) - An object containing the header for this particular part. Each property value is an array of one or more string values.
*/
interface PartStream extends stream.Readable {
addListener(event: "header", listener: (header: object) => void): this;
addListener(event: "close", listener: () => void): this;
addListener(event: "data", listener: (chunk: Buffer | string) => void): this;
addListener(event: "end", listener: () => void): this;
addListener(event: "readable", listener: () => void): this;
addListener(event: "error", listener: (err: Error) => void): this;
addListener(event: string, listener: (...args: any[]) => void): this;
on(event: "header", listener: (header: object) => void): this;
on(event: "close", listener: () => void): this;
on(event: "data", listener: (chunk: Buffer | string) => void): this;
on(event: "end", listener: () => void): this;
on(event: "readable", listener: () => void): this;
on(event: "error", listener: (err: Error) => void): this;
on(event: string, listener: (...args: any[]) => void): this;
once(event: "header", listener: (header: object) => void): this;
once(event: "close", listener: () => void): this;
once(event: "data", listener: (chunk: Buffer | string) => void): this;
once(event: "end", listener: () => void): this;
once(event: "readable", listener: () => void): this;
once(event: "error", listener: (err: Error) => void): this;
once(event: string, listener: (...args: any[]) => void): this;
prependListener(event: "header", listener: (header: object) => void): this;
prependListener(event: "close", listener: () => void): this;
prependListener(event: "data", listener: (chunk: Buffer | string) => void): this;
prependListener(event: "end", listener: () => void): this;
prependListener(event: "readable", listener: () => void): this;
prependListener(event: "error", listener: (err: Error) => void): this;
prependListener(event: string, listener: (...args: any[]) => void): this;
prependOnceListener(event: "header", listener: (header: object) => void): this;
prependOnceListener(event: "close", listener: () => void): this;
prependOnceListener(event: "data", listener: (chunk: Buffer | string) => void): this;
prependOnceListener(event: "end", listener: () => void): this;
prependOnceListener(event: "readable", listener: () => void): this;
prependOnceListener(event: "error", listener: (err: Error) => void): this;
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
removeListener(event: "header", listener: (header: object) => void): this;
removeListener(event: "close", listener: () => void): this;
removeListener(event: "data", listener: (chunk: Buffer | string) => void): this;
removeListener(event: "end", listener: () => void): this;
removeListener(event: "readable", listener: () => void): this;
removeListener(event: "error", listener: (err: Error) => void): this;
removeListener(event: string, listener: (...args: any[]) => void): this;
}
}
@@ -18,6 +18,6 @@
},
"files": [
"index.d.ts",
"gitlab-tests.ts"
"dicer-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+71
View File
@@ -0,0 +1,71 @@
import Dinero = require("dinero.js");
Dinero.globalExchangeRatesApi = {
endpoint: "https://yourexchangerates.api/latest?base={{from}}",
propertyPath: "data.rates.{{to}}",
headers: {
"user-key": "xxxxxxxxx",
},
};
Dinero.globalExchangeRatesApi = {
endpoint: "https://yourexchangerates.api/latest?base={{from}}",
propertyPath: "data.rates.{{to}}",
roundingMode: "HALF_UP",
};
Dinero();
Dinero({ amount: 1 });
Dinero({ currency: "USD" });
Dinero({ precision: 2 });
let number: number;
let string: string;
let boolean: boolean;
let dinero: Dinero.Dinero = Dinero();
let dineroArr: Dinero.Dinero[];
let dineroObject: Dinero.DineroObject;
number = dinero.getAmount();
string = dinero.getCurrency();
string = dinero.setLocale("fr-FR").getLocale();
number = dinero.convertPrecision(4).getPrecision();
dinero = dinero.add(Dinero({ amount: 104545, precision: 4 }));
dinero = dinero.subtract(Dinero({ amount: 104545, precision: 4 }));
dinero = dinero.multiply(2.00125);
dinero = dinero.multiply(2.00125, "HALF_UP");
dinero = dinero.divide(2);
dinero = dinero.divide(2, "HALF_UP");
dinero = dinero.percentage(50);
dineroArr = dinero.allocate([50, 50]);
dinero.convert("EUR").then(d => (dinero = d));
dinero.convert("XBT", {
endpoint: "https://yourexchangerates.api/latest?base={{from}}",
propertyPath: "data.rates.{{to}}",
headers: {
"user-key": "xxxxxxxxx",
},
roundingMode: "HALF_UP",
});
boolean = dinero.equalsTo(Dinero({ amount: 500, currency: "EUR" }));
boolean = dinero.lessThan(Dinero({ amount: 800 }));
boolean = dinero.lessThanOrEqual(Dinero({ amount: 800 }));
boolean = dinero.greaterThan(Dinero({ amount: 800 }));
boolean = dinero.greaterThanOrEqual(Dinero({ amount: 800 }));
boolean = dinero.isZero();
boolean = dinero.isPositive();
boolean = dinero.isNegative();
boolean = dinero.hasSubUnits();
boolean = dinero.hasCents();
boolean = dinero.hasSameCurrency(Dinero({ amount: 1000, currency: "EUR" }));
boolean = dinero.hasSameAmount(Dinero({ amount: 1000, currency: "EUR" }));
string = dinero.toFormat("0,0 dollar");
string = dinero.toFormat("0,0 dollar", "HALF_EVEN");
number = dinero.toUnit();
number = dinero.toRoundedUnit(1);
number = dinero.toRoundedUnit(1, "HALF_EVEN");
dineroObject = dinero.toObject();
dineroArr = Dinero.normalizePrecision([
Dinero({ amount: 100, precision: 2 }),
Dinero({ amount: 1000, precision: 3 }),
]);
+78
View File
@@ -0,0 +1,78 @@
// Type definitions for dinero.js 1.4
// Project: https://sarahdayan.github.io/dinero.js
// Definitions by: BendingBender <https://github.com/BendingBender>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
export as namespace Dinero;
export = DineroFactory;
declare function DineroFactory(options?: Dinero.Options): DineroFactory.Dinero;
declare namespace DineroFactory {
let globalExchangeRatesApi: ExchangeRatesApiOptions;
function normalizePrecision(objects: Dinero[]): Dinero[];
interface Options {
amount?: number;
currency?: string;
precision?: number;
}
interface Dinero {
getAmount(): number;
getCurrency(): string;
getLocale(): string;
setLocale(newLocale: string): Dinero;
getPrecision(): number;
convertPrecision(newPrecision: number): Dinero;
add(addend: Dinero): Dinero;
subtract(subtrahend: Dinero): Dinero;
multiply(multiplier: number, roundingMode?: RoundingMode): Dinero;
divide(divisor: number, roundingMode?: RoundingMode): Dinero;
percentage(percentage: number): Dinero;
allocate(ratios: number[]): Dinero[];
convert(currency: string, options?: ExchangeRatesApiOptions): Promise<Dinero>;
equalsTo(comparator: Dinero): boolean;
lessThan(comparator: Dinero): boolean;
lessThanOrEqual(comparator: Dinero): boolean;
greaterThan(comparator: Dinero): boolean;
greaterThanOrEqual(comparator: Dinero): boolean;
isZero(): boolean;
isPositive(): boolean;
isNegative(): boolean;
hasSubUnits(): boolean;
/**
* @deprecated since version 2.0
*/
hasCents(): boolean;
hasSameCurrency(comparator: Dinero): boolean;
hasSameAmount(comparator: Dinero): boolean;
toFormat(format?: string, roundingMode?: RoundingMode): string;
toUnit(): number;
toRoundedUnit(digits: number, roundingMode?: RoundingMode): number;
toObject(): DineroObject;
}
type RoundingMode =
| "HALF_ODD"
| "HALF_EVEN"
| "HALF_UP"
| "HALF_DOWN"
| "HALF_TOWARDS_ZERO"
| "HALF_AWAY_FROM_ZERO";
interface ExchangeRatesApiOptions {
endpoint: string;
propertyPath: string;
headers?: { [header: string]: string };
roundingMode?: RoundingMode;
}
interface DineroObject {
amount: number;
currency: string;
precision: number;
}
}
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"dinero.js-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+6
View File
@@ -0,0 +1,6 @@
import * as discordrpc from "discord-rpc";
discordrpc.register('0'); // $ExpectType boolean
discordrpc.register(0); // $ExpectError
const client = new discordrpc.Client({ transport: 'ipc' });
+190
View File
@@ -0,0 +1,190 @@
// Type definitions for discord-rpc 3.0
// Project: https://github.com/discordjs/RPC#readme
// Definitions by: Jason Bothell <https://github.com/jasonhaxstuff>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import { EventEmitter } from 'events';
export function register(id: string): boolean;
export class Client extends EventEmitter {
constructor(options: RPCClientOptions)
application: {
description: string
icon: string
id: string
rpc_origins: string[]
name: string
};
user: {
username: string
discriminator: string
id: string
avatar: string
};
connect(clientId: string): Promise<Client>;
login(options?: RPCLoginOptions): Promise<this>;
getGuild(id: string, timeout?: number): Promise<Guild>;
getGuilds(timeout?: number): Promise<Guild[]>;
getChannel(id: string, timeout?: number): Promise<Channel>;
getChannels(id?: string, timeout?: number): Promise<Channel[]>;
setCertifiedDevices(devices: CertifiedDevice[]): Promise<null>;
setUserVoiceSettings(id: string, settings: UserVoiceSettings): Promise<any>;
selectVoiceChannel(id: string, options?: { timeout?: number, force?: boolean }): Promise<Channel>;
selectTextChannel(id: string, options?: { timeout: number, force: boolean }): Promise<Channel>;
getVoiceSettings(): Promise<VoiceSettings>;
setVoiceSettings(args: VoiceSettings): Promise<any>;
captureShortcut(callback: (shortcut: Array<{ type: number, code: number, name: string }>, stop: () => void) => void): Promise<() => void>;
setActivity(args?: Presence, pid?: number): Promise<any>;
clearActivity(pid?: number): Promise<any>;
sendJoinInvite(user: { id: string } | string): Promise<any>;
sendJoinRequest(user: { id: string } | string): Promise<any>;
closeJoinRequest(user: { id: string } | string): Promise<any>;
createLobby(type: string, capacity: number, metadata: any): Promise<any>;
updateLobby(lobby: { id: string } | string, options?: { type: string, owner: { id: string } | string, capacity: number, metadata: any }): Promise<any>;
deleteLobby(lobby: { id: string } | string): Promise<any>;
connectToLobby(id: string, secret: string): Promise<any>;
sendToLobby(lobby: { id: string } | string, data: any): Promise<any>;
disconnectFromLobby(lobby: { id: string } | string): Promise<any>;
updateLobbyMember(lobby: { id: string } | string, user: { id: string } | string, metadata: any): Promise<any>;
subscribe(event: string, callback: (data: any) => void): Promise<Subscription>;
subscribe(event: string, args: any, callback: (data: any) => void): Promise<Subscription>;
destroy(): Promise<void>;
}
export interface RPCClientOptions {
transport: 'ipc' | 'websocket';
}
export interface RPCLoginOptions {
clientId: string;
clientSecret?: string;
accessToken?: string;
rpcToken?: string;
tokenEndpoint?: string;
scopes?: string[];
}
export interface Guild {
id: string;
name: string;
icon_url?: string;
members?: any[];
}
export interface Subscription {
unsubscribe(): Promise<boolean>;
}
export interface Channel {
id: string;
name: string;
/**
* Guild text: 0, Guild voice: 2, DM: 1, Group DM: 3
*/
type: number;
guild_id?: string;
/**
* (text)
*/
topic?: string;
/**
* (voice)
*/
bitrate?: number;
/**
* (voice) 0 if none
*/
user_limit?: number;
/**
* (text)
*/
position?: number;
/**
* (voice) https://discordapp.com/developers/docs/resources/voice#voice-state-object
*/
voice_states?: any[];
/**
* (text) https://discordapp.com/developers/docs/resources/channel#message-object
*/
messages?: any[];
}
export interface CertifiedDevice {
type: 'audioinput' | 'audiooutput' | 'videoinput';
uuid: string;
vendor: { name: string, url: string };
model: { name: string, url: string };
related: string[];
echoCancellation?: boolean;
noiseSuppression?: boolean;
automaticGainControl?: boolean;
hardwareMute?: boolean;
}
export interface UserVoiceSettings {
id: string;
pan?: { left: number, right: number };
volume?: number;
mute?: boolean;
}
export interface VoiceSettings {
automaticGainControl: boolean;
echoCancellation: boolean;
noiseSuppression: boolean;
qos: boolean;
silenceWarning: boolean;
deaf: boolean;
mute: boolean;
input?: {
device: string,
volume: number
};
output?: {
device: string,
volume: number
};
mode?: {
autoThreshold: boolean,
threshold: number,
shortcut: Array<{ type: number, code: number, name: string }>,
delay: number
};
}
export interface Presence {
state?: string;
details?: string;
startTimestamp?: number;
endTimestamp?: number;
largeImageKey?: string;
largeImageText?: string;
smallImageKey?: string;
smallImageText?: string;
instance?: boolean;
}
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"discord-rpc-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
@@ -0,0 +1,53 @@
const isWebmSupported: boolean = window.MediaRecorder.isTypeSupported(
'video/webm'
);
const mediaStream = new MediaStream();
const mediaRecorderOptions: MediaRecorderOptions = {
mimeType: 'video/webm',
audioBitsPerSecond: 1000000,
videoBitsPerSecond: 4000000
};
const blobEvent = new BlobEvent('dataavailable', {
data: new Blob(),
bubbles: false
});
const errorEvent = new MediaRecorderErrorEvent('error', {
error: new DOMException(),
bubbles: false
});
const onDataAvailable = (event: BlobEvent) => {
const blobType = event.data.type;
};
const onError = (event: MediaRecorderErrorEvent) => {
const errorMessage = event.error.message;
};
const onEvent = (event: Event) => {};
let recorder = new window.MediaRecorder(mediaStream);
recorder = new MediaRecorder(mediaStream, mediaRecorderOptions);
recorder.start();
recorder.stop();
recorder.start(1000);
recorder.pause();
recorder.requestData();
const state: RecordingState = recorder.state;
const isRecording = state === 'recording';
recorder.addEventListener('start', onEvent);
recorder.removeEventListener('start', onEvent);
recorder.dispatchEvent(blobEvent);
recorder.ondataavailable = onDataAvailable;
recorder.ondataavailable = onEvent;
recorder.onerror = onError;
recorder.onpause = onEvent;
recorder.onresume = onEvent;
recorder.onstart = onEvent;
recorder.onstop = onEvent;
+64
View File
@@ -0,0 +1,64 @@
// Type definitions for w3c MediaStream Recording 1.0
// Project: https://w3c.github.io/mediacapture-record
// Definitions by: Elias Meire <https://github.com/eliasmeire>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
interface MediaRecorderErrorEventInit extends EventInit {
error: DOMException;
}
declare class MediaRecorderErrorEvent extends Event {
constructor(type: string, eventInitDict: MediaRecorderErrorEventInit);
readonly error: DOMException;
}
interface BlobEventInit extends EventInit {
data: Blob;
timecode?: number;
}
declare class BlobEvent extends Event {
constructor(type: string, eventInitDict: BlobEventInit);
readonly data: Blob;
readonly timecode: number;
}
interface MediaRecorderOptions {
mimeType?: string;
audioBitsPerSecond?: number;
videoBitsPerSecond?: number;
bitsPerSecond?: number;
}
type RecordingState = 'inactive' | 'recording' | 'paused';
declare class MediaRecorder extends EventTarget {
readonly stream: MediaStream;
readonly mimeType: string;
readonly state: RecordingState;
readonly videoBitsPerSecond: number;
readonly audioBitsPerSecond: number;
ondataavailable: (event: BlobEvent) => void;
onerror: (event: MediaRecorderErrorEvent) => void;
onpause: EventListener;
onresume: EventListener;
onstart: EventListener;
onstop: EventListener;
constructor(stream: MediaStream, options?: MediaRecorderOptions);
start(timeslice?: number): void;
stop(): void;
resume(): void;
pause(): void;
requestData(): void;
static isTypeSupported(type: string): boolean;
}
interface Window {
MediaRecorder: typeof MediaRecorder;
BlobEvent: typeof BlobEvent;
MediaRecorderErrorEvent: typeof MediaRecorderErrorEvent;
}
@@ -0,0 +1,16 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": ["es6", "dom"],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": ["../"],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": ["index.d.ts", "dom-mediacapture-record-tests.ts"]
}
@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}
+1 -1
View File
@@ -18,6 +18,6 @@ dotProp.has({foo: {bar: 'unicorn'}}, 'foo.bar');
dotProp.delete(obj, 'foo.bar');
console.log(obj);
(<any> obj).foo.bar = {x: 'y', y: 'x'};
(obj as any).foo.bar = {x: 'y', y: 'x'};
dotProp.delete(obj, 'foo.bar.x');
console.log(obj);
+33 -1
View File
@@ -1,4 +1,4 @@
// Type definitions for dplayer 1.24
// Type definitions for dplayer 1.25
// Project: https://github.com/DIYgod/DPlayer#readme
// Definitions by: Guanyunhan <https://github.com/Guanyunhan>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@@ -9,6 +9,7 @@ export type Preload = 'none' | 'metadata' | 'auto';
export type VideoType = 'auto' | 'hls' | 'flv' | 'dash' | 'webtorrent' | 'normal';
export type SubTitleType = 'webvtt' | 'ass';
export type DirectionType = 'top' | 'right' | 'bottom';
export type FullScreenType = 'web' | 'browser';
export enum DPlayerEvents {
abort = 'abort',
@@ -98,12 +99,20 @@ export interface DPlayerHighLightItem {
time: number;
}
export interface DPlayerVideoQuality {
name: string;
url: string;
type?: string;
}
export interface DPlayerVideo {
url: string;
pic?: string;
thumbnails?: string;
type?: VideoType | string;
customType?: any;
quality?: DPlayerVideoQuality[];
defaultQuality?: number;
}
export interface DPlayerSubTitle {
@@ -131,8 +140,31 @@ export interface DPlayerAPIBackend {
send(endpoint: any, danmakuData: DPlayerDanmakuItem, callback: () => void): void;
}
export interface Danmaku {
send(danmaku: DPlayerDanmakuItem, callback: () => void): void;
draw(danmaku: DPlayerDanmakuItem): void;
opacity(percentage: number): void;
clear(): void;
hide(): void;
show(): void;
}
export interface FullScreen {
request(type: FullScreenType): void;
cancel(type: FullScreenType): void;
}
export default class DPlayer {
events: any;
video: HTMLVideoElement;
danmaku: Danmaku;
fullScreen: FullScreen;
constructor(options: DPlayerOptions);
+11 -5
View File
@@ -8,15 +8,21 @@ interface Options {
name: string;
main: string;
baseDir?: string;
exclude?: RegExp;
externals?: boolean;
indent?: string;
newLine?: string;
out?: string;
prefix?: string;
externals?: boolean;
referenceExternals?: boolean;
exclude?: RegExp | ((file: string, external: boolean) => boolean);
removeSource?: boolean;
newLine?: string;
indent?: string;
prefix?: string;
separator?: string;
verbose?: boolean;
emitOnIncludedFileNotFound?: boolean;
emitOnNoIncludedFileNotFound?: boolean;
outputAsModuleFolder?: boolean;
headerPath?: string;
headerText?: string;
}
export declare function bundle(opts: Options): void;
+1 -1
View File
@@ -8,7 +8,7 @@ writable._write = (input, encoding, done) => {
if (readable.push(input)) {
done();
} else {
readable.once('drain', <(...args: any[]) => void> done);
readable.once('drain', done as (...args: any[]) => void);
}
};
@@ -17,7 +17,7 @@ APIRequest.create({
var app = express();
app.get('/', function (req:any, res:express.Response) {
var rMaker = <APIRequest.RequestMaker>req.testAPI;
var rMaker = req.testAPI as APIRequest.RequestMaker;
var r = rMaker();
r.get('/', function (err, resp) {
if(err) {
@@ -28,7 +28,7 @@ app.get('/', function (req:any, res:express.Response) {
});
app.get('/', function (req:any, res:express.Response) {
var rMaker = <APIRequest.RequestMaker>req.testAPI;
var rMaker = req.testAPI as APIRequest.RequestMaker;
var r = rMaker();
r.get('/')
.then(function (resp) {
+1021 -16
View File
File diff suppressed because it is too large Load Diff

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