mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 06:47:03 +00:00
Merge branch 'master' of https://github.com/DefinitelyTyped/DefinitelyTyped into graphql-v0.13.2
This commit is contained in:
@@ -11,6 +11,9 @@ const collectionToArray = <T>(col: { Item(key: any): T }): T[] => {
|
||||
return results;
|
||||
};
|
||||
|
||||
WScript.Echo('Hello, world');
|
||||
WScript.Quit();
|
||||
|
||||
// source -- https://msdn.microsoft.com/en-us/library/windows/desktop/ms630826(v=vs.85).aspx
|
||||
{
|
||||
const cd = new ActiveXObject('WIA.CommonDialog');
|
||||
@@ -51,7 +54,7 @@ const collectionToArray = <T>(col: { Item(key: any): T }): T[] => {
|
||||
{
|
||||
const dev = cd.ShowSelectDevice();
|
||||
if (dev) {
|
||||
collectionToArray(dev.Properties).forEach(p => {
|
||||
for (const p of collectionToArray(dev.Properties)) {
|
||||
let s = `${p.Name} (${p.PropertyID}) = `;
|
||||
if (p.IsVector) {
|
||||
s += '[vector of data]';
|
||||
@@ -84,7 +87,7 @@ const collectionToArray = <T>(col: { Item(key: any): T }): T[] => {
|
||||
}
|
||||
|
||||
WScript.Echo(s);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,7 +115,7 @@ const collectionToArray = <T>(col: { Item(key: any): T }): T[] => {
|
||||
{
|
||||
const img = cd.ShowAcquireImage();
|
||||
if (img) {
|
||||
collectionToArray(img.Properties).forEach(p => {
|
||||
for (const p of collectionToArray(img.Properties)) {
|
||||
let contents = '';
|
||||
if (p.IsVector) {
|
||||
contents = '[vector data not emitted]';
|
||||
@@ -124,7 +127,7 @@ const collectionToArray = <T>(col: { Item(key: any): T }): T[] => {
|
||||
contents = p.Value;
|
||||
}
|
||||
WScript.Echo(`${p.Name} (${p.PropertyID}) = ${contents}`);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,12 +136,12 @@ const collectionToArray = <T>(col: { Item(key: any): T }): T[] => {
|
||||
const dev = cd.ShowSelectDevice();
|
||||
if (dev) {
|
||||
const actionEvent = WIA.WiaEventFlag.ActionEvent;
|
||||
collectionToArray(dev.Events).forEach(e => {
|
||||
for (const e of collectionToArray(dev.Events)) {
|
||||
const msg = (e.Type & actionEvent) === actionEvent ?
|
||||
`${e.Name} is an Action event` :
|
||||
`${e.Name} is not an Action event`;
|
||||
WScript.Echo(msg);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -208,14 +211,14 @@ Frame count = ${img.FrameCount}}
|
||||
// Create an imageprocess object and enumerate filters
|
||||
{
|
||||
const ip = new ActiveXObject('WIA.ImageProcess');
|
||||
collectionToArray(ip.FilterInfos).forEach(fi => {
|
||||
for (const fi of collectionToArray(ip.FilterInfos)) {
|
||||
const s = [
|
||||
fi.Name,
|
||||
new Array(51).join('='),
|
||||
fi.Description
|
||||
].join('\n');
|
||||
WScript.Echo(s);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Create an imageprocess object and create one of each available filter
|
||||
@@ -269,11 +272,11 @@ Frame count = ${img.FrameCount}}
|
||||
WScript.Echo(s);
|
||||
};
|
||||
|
||||
collectionToArray(ip.FilterInfos).forEach(fi => {
|
||||
for (const fi of collectionToArray(ip.FilterInfos)) {
|
||||
ip.Filters.Add(fi.FilterID);
|
||||
listProperties(ip.Filters(1));
|
||||
ip.Filters.Remove(1);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// List the supported transfer formats
|
||||
@@ -308,14 +311,14 @@ Frame count = ${img.FrameCount}}
|
||||
{
|
||||
const dev = cd.ShowSelectDevice();
|
||||
if (dev) {
|
||||
collectionToArray(dev.Items).forEach(item => {
|
||||
for (const item of collectionToArray(dev.Items)) {
|
||||
let s: string = item.Properties("Item Name").Value;
|
||||
if (item.Properties.Exists("Item Time Stamp")) {
|
||||
const v: WIA.Vector = item.Properties("Item Time Stamp").Value;
|
||||
if (v.Count === 8) { s += ` (${v.Date})`; }
|
||||
}
|
||||
WScript.Echo(s);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -340,16 +343,16 @@ Frame count = ${img.FrameCount}}
|
||||
}
|
||||
|
||||
// List all available devices by name and deviceid
|
||||
collectionToArray(dm.DeviceInfos).forEach(di => {
|
||||
for (const di of collectionToArray(dm.DeviceInfos)) {
|
||||
const name: string = di.Properties("Name").Value;
|
||||
WScript.Echo(`${name} (${di.DeviceID})`);
|
||||
});
|
||||
}
|
||||
|
||||
// Display all the properties for the selected device
|
||||
{
|
||||
const dev = cd.ShowSelectDevice();
|
||||
if (dev) {
|
||||
collectionToArray(dev.Properties).forEach(p => {
|
||||
for (const p of collectionToArray(dev.Properties)) {
|
||||
const name = `${p.Name} (${p.PropertyID})`;
|
||||
let contents: string;
|
||||
if (p.IsVector) {
|
||||
@@ -360,7 +363,7 @@ Frame count = ${img.FrameCount}}
|
||||
contents = p.Value;
|
||||
}
|
||||
WScript.Echo(`${name} = ${contents}`);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -430,7 +433,7 @@ Frame count = ${img.FrameCount}}
|
||||
if (args[0] === 'connect') {
|
||||
const deviceID = args[1].substr(12);
|
||||
const device = dm.DeviceInfos(deviceID).Connect();
|
||||
collectionToArray(device.Items).forEach(item => {
|
||||
for (const item of collectionToArray(device.Items)) {
|
||||
const img = item.Transfer();
|
||||
img.SaveFile(`C:\\${item.Properties('Item Name').Value}.${img.FileExtension}`);
|
||||
|
||||
@@ -445,7 +448,7 @@ Frame count = ${img.FrameCount}}
|
||||
WScript.Echo(error);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
WScript.Quit();
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
import { decode, encode, Stream } from 'amp';
|
||||
|
||||
// $ExpectType Buffer[]
|
||||
decode(new Buffer('something'));
|
||||
|
||||
// $ExpectType Buffer
|
||||
encode([new Buffer('something'), new Buffer('something')]);
|
||||
|
||||
// $ExpectError
|
||||
decode('');
|
||||
|
||||
// $ExpectError
|
||||
decode(1);
|
||||
|
||||
// $ExpectError
|
||||
decode();
|
||||
|
||||
// $ExpectError
|
||||
encode('');
|
||||
|
||||
// $ExpectError
|
||||
encode(1);
|
||||
|
||||
// $ExpectError
|
||||
encode();
|
||||
|
||||
// $ExpectType Stream
|
||||
new Stream({});
|
||||
|
||||
// $ExpectType Stream
|
||||
new Stream({
|
||||
highWaterMark: 1,
|
||||
decodeStrings: true,
|
||||
objectMode: true,
|
||||
destroy: (error?: Error) => {
|
||||
return 'handle error';
|
||||
},
|
||||
final: (callback: (error?: Error) => void) => {
|
||||
// do nothing
|
||||
}
|
||||
});
|
||||
|
||||
// $ExpectError
|
||||
new Stream({somethingNoneExisting: true});
|
||||
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
// Type definitions for amp 0.3
|
||||
// Project: https://github.com/visionmedia/node-amp
|
||||
// Definitions by: Vilim Stubičan <https://github.com/jewbre>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.4
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
import * as stream from 'stream';
|
||||
|
||||
export function decode(buf: Buffer): Buffer[];
|
||||
|
||||
export function encode(args: Buffer[]): Buffer;
|
||||
|
||||
export class Stream extends stream.Writable {
|
||||
constructor(opts: stream.WritableOptions);
|
||||
|
||||
_write(chunk: any, encoding: string, fn: () => void): void;
|
||||
}
|
||||
@@ -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",
|
||||
"amp-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
@@ -0,0 +1,106 @@
|
||||
import { RequestQuery, Server } from 'hapi';
|
||||
import * as bell from 'bell';
|
||||
|
||||
async function run() {
|
||||
const server = new Server({ port: 8000 });
|
||||
await server.register(bell);
|
||||
|
||||
server.auth.strategy('arcgisonline', 'bell', {
|
||||
provider: 'twitter',
|
||||
password: 'some cookie password',
|
||||
location: 'http://example.com/oauth',
|
||||
clientId: '',
|
||||
clientSecret: '',
|
||||
scope(request) {
|
||||
const scopes = ['public_profile', 'email'];
|
||||
if ((<RequestQuery> request.query).wantsSharePermission) {
|
||||
scopes.push('publish_actions');
|
||||
}
|
||||
return scopes;
|
||||
}
|
||||
});
|
||||
|
||||
const providers: bell.BellOptions[] = [{
|
||||
provider: 'discord',
|
||||
password: 'cookie_encryption_password_secure',
|
||||
isSecure: false,
|
||||
clientId: '',
|
||||
clientSecret: '',
|
||||
location: () => '',
|
||||
},
|
||||
{
|
||||
provider: 'facebook',
|
||||
password: 'cookie_encryption_password_secure',
|
||||
isSecure: false,
|
||||
clientId: '',
|
||||
clientSecret: '',
|
||||
location: server.info.uri
|
||||
},
|
||||
{
|
||||
provider: 'google',
|
||||
password: 'cookie_encryption_password_secure',
|
||||
isSecure: false,
|
||||
clientId: '',
|
||||
clientSecret: '',
|
||||
location: server.info.uri
|
||||
},
|
||||
{
|
||||
provider: 'linkedin',
|
||||
password: 'cookie_encryption_password_secure',
|
||||
isSecure: false,
|
||||
clientId: '',
|
||||
clientSecret: '',
|
||||
providerParams: {
|
||||
redirect_uri: server.info.uri + '/bell/door'
|
||||
}
|
||||
},
|
||||
{
|
||||
provider: 'meetup',
|
||||
password: 'cookie_encryption_password_secure',
|
||||
isSecure: false,
|
||||
clientId: '',
|
||||
clientSecret: '',
|
||||
scope: ['basic', 'ageless', 'group_edit', 'reporting'],
|
||||
},
|
||||
{
|
||||
provider: 'nest',
|
||||
password: 'cookie_encryption_password_secure',
|
||||
isSecure: false,
|
||||
clientId: '',
|
||||
clientSecret: ''
|
||||
},
|
||||
{
|
||||
provider: 'office365',
|
||||
clientId: '',
|
||||
clientSecret: '',
|
||||
password: 'cookie_encryption_password_secure',
|
||||
providerParams: {
|
||||
response_type: 'code'
|
||||
},
|
||||
scope: ['openid', 'offline_access', 'profile']
|
||||
},
|
||||
{
|
||||
provider: 'okta',
|
||||
config: { uri: 'https://your-organization.okta.com' },
|
||||
password: 'cookie_encryption_password_secure',
|
||||
isSecure: false,
|
||||
location: 'http://127.0.0.1:8000',
|
||||
clientId: '',
|
||||
clientSecret: ''
|
||||
},
|
||||
{
|
||||
provider: 'slack',
|
||||
password: 'cookie_encryption_password_secure',
|
||||
isSecure: false,
|
||||
clientId: '',
|
||||
clientSecret: ''
|
||||
},
|
||||
{
|
||||
provider: 'twitch',
|
||||
password: 'cookie_encryption_password_secure',
|
||||
isSecure: false,
|
||||
clientId: '',
|
||||
clientSecret: '',
|
||||
scope: ['user_read', 'channel_read']
|
||||
}];
|
||||
}
|
||||
Vendored
+269
@@ -0,0 +1,269 @@
|
||||
// Type definitions for bell 9.1
|
||||
// Project: https://github.com/hapijs/bell
|
||||
// Definitions by: Simon Schick <https://github.com/SimonSchick>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.7
|
||||
|
||||
import { Server, Request, Plugin, AuthCredentials } from 'hapi';
|
||||
|
||||
declare module 'hapi' {
|
||||
interface ServerAuth {
|
||||
strategy(name: string, scheme: 'bell', options: BellOptions): void;
|
||||
strategy(
|
||||
name: string,
|
||||
scheme: 'bell',
|
||||
mode: boolean | 'required' | 'optional' | 'try',
|
||||
options: BellOptions,
|
||||
): void;
|
||||
}
|
||||
}
|
||||
|
||||
export interface StringLikeMap {
|
||||
[key: string]: string | number;
|
||||
}
|
||||
export type Provider =
|
||||
'arcgisonline' |
|
||||
'auth0' |
|
||||
'azuread' |
|
||||
'bitbucket' |
|
||||
'digitalocean' |
|
||||
'discord' |
|
||||
'dropbox' |
|
||||
'dropboxV2' |
|
||||
'facebook' |
|
||||
'fitbit' |
|
||||
'foursquare' |
|
||||
'github' |
|
||||
'gitlab' |
|
||||
'google' |
|
||||
'googleplus' |
|
||||
'instagram' |
|
||||
'linkedin' |
|
||||
'live' |
|
||||
'medium' |
|
||||
'meetup' |
|
||||
'mixer' |
|
||||
'nest' |
|
||||
'office365' |
|
||||
'okta' |
|
||||
'phabricator' |
|
||||
'pingfed' |
|
||||
'pinterest' |
|
||||
'reddit' |
|
||||
'salesforce' |
|
||||
'slack' |
|
||||
'spotify' |
|
||||
'stripe' |
|
||||
'trakt' |
|
||||
'tumblr' |
|
||||
'twitch' |
|
||||
'twitter' |
|
||||
'vk' |
|
||||
'wordpress' |
|
||||
'yahoo';
|
||||
|
||||
export type RequestPassThrough = (
|
||||
request: Request,
|
||||
next: (err: Error | null, credentials: AuthCredentials) => void,
|
||||
) => void;
|
||||
|
||||
export interface OptionalOptions {
|
||||
/**
|
||||
* the name of the cookie used to manage the temporary state.
|
||||
* Defaults to 'bell-provider' where 'provider' is the provider name (or 'custom' for custom providers).
|
||||
* For example, the Twitter cookie name defaults to 'bell-twitter'.
|
||||
*/
|
||||
cookie?: string;
|
||||
/**
|
||||
* sets the cookie secure flag.
|
||||
* Defaults to true.
|
||||
*/
|
||||
isSecure?: boolean;
|
||||
/**
|
||||
* sets the cookie HTTP only flag.
|
||||
* Defaults to true.
|
||||
*/
|
||||
isHttpOnly?: boolean;
|
||||
/**
|
||||
* cookie time-to-live in milliseconds.
|
||||
* Defaults to null (session time-life - cookies are deleted when the browser is closed).
|
||||
*/
|
||||
ttl?: number;
|
||||
/**
|
||||
* the domain scope.
|
||||
* Defaults to null (no domain).
|
||||
*/
|
||||
domain?: string;
|
||||
/**
|
||||
* provider-specific query parameters for the authentication endpoint.
|
||||
* It may be passed either as an object to merge into the query string,
|
||||
* or a function which takes the client's request and returns an object.
|
||||
* Each provider supports its own set of parameters which customize the user's login experience.
|
||||
* For example:
|
||||
* * Facebook supports `display` ('page', 'popup', or 'touch'), `auth_type`, `auth_nonce`.
|
||||
* * Google supports `access_type`, `approval_prompt`, `prompt`, `login_hint`, `user_id`, `hd`.
|
||||
* * Twitter supports `force_login`, `screen_name`.
|
||||
* * Linkedin supports `fields`.
|
||||
*/
|
||||
providerParams?: StringLikeMap | ((request: Request) => StringLikeMap);
|
||||
/**
|
||||
* allows passing query parameters from a bell protected endpoint to the auth request.
|
||||
* It will merge the query params you pass along with the providerParams and any other predefined ones.
|
||||
* Be aware that this will override predefined query parameters!
|
||||
* Default to false.
|
||||
*/
|
||||
allowRuntimeProviderParams?: StringLikeMap | boolean;
|
||||
/**
|
||||
* Each built-in vendor comes with the required scope for basic profile information.
|
||||
* Use scope to specify a different scope as required by your application.
|
||||
* It may be passed either as an object to merge into the query string,
|
||||
* or a function which takes the client's request and returns an object.
|
||||
* Consult the provider for their specific supported scopes.
|
||||
*/
|
||||
scope?: string[] | ((request: Request) => string[]);
|
||||
/**
|
||||
* skips obtaining a user profile from the provider.
|
||||
* Useful if you need specific scopes,
|
||||
* but not the user profile.
|
||||
* Defaults to false.
|
||||
*/
|
||||
skipProfile?: boolean;
|
||||
/**
|
||||
* a configuration object used to customize the provider settings.
|
||||
* The built-in 'twitter' provider accepts the `extendedProfile` & `getMethod` options.
|
||||
* option which allows disabling the extra profile request when the provider
|
||||
* returns the user information in the callback (defaults to true).
|
||||
* The built-in 'github' and 'phabricator' providers accept the uri
|
||||
* option which allows pointing to a private enterprise installation (e.g. 'https://vpn.example.com').
|
||||
* See Providers documentation for more information.
|
||||
*/
|
||||
config?: { extendedProfile?: boolean; getMethod?: string } | { uri?: string };
|
||||
/**
|
||||
* an object of key-value pairs that specify additional
|
||||
* URL query parameters to send with the profile request to the provider.
|
||||
* The built-in facebook provider,
|
||||
* for example, could have fields specified to determine the fields returned from the user's graph,
|
||||
* which would then be available to you in the auth.credentials.profile.raw object.
|
||||
*/
|
||||
profileParams?: StringLikeMap;
|
||||
/**
|
||||
* allows passing additional OAuth state from initial request.
|
||||
* This must be a function returning a string,
|
||||
* which will be appended to the bell internal state parameter for OAuth code flow.
|
||||
*/
|
||||
runtimeStateCallback?(req: Request): string;
|
||||
|
||||
// THESE ARE IN THE *REQUIRED* section but are actually not...
|
||||
/**
|
||||
* A boolean indicating whether or not you want the redirect_uri to be forced to https.
|
||||
* Useful if your hapi application runs as http, but is accessed through https.
|
||||
*/
|
||||
forceHttps?: boolean;
|
||||
/**
|
||||
* Set the base redirect_uri manually if it cannot be inferred properly from server settings.
|
||||
* Useful to override port, protocol, and host if proxied or forwarded.
|
||||
*/
|
||||
location?: string | ((req: Request) => string);
|
||||
}
|
||||
|
||||
export interface RequiredProviderOptions {
|
||||
/**
|
||||
* the cookie encryption password.
|
||||
* Used to encrypt the temporary state cookie used by the module in
|
||||
* between the authorization protocol steps.
|
||||
*/
|
||||
password: string;
|
||||
/**
|
||||
* the OAuth client identifier (consumer key).
|
||||
*/
|
||||
clientId: string;
|
||||
/**
|
||||
* the OAuth client secret (consumer secret)
|
||||
*/
|
||||
clientSecret: string;
|
||||
}
|
||||
|
||||
export interface KnownProviderOptions extends RequiredProviderOptions, OptionalOptions {
|
||||
provider: Provider;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param uri the requested resource URI (bell will add the token or authentication header as needed).
|
||||
* @param params any URI query parameters (cannot include them in the URI due to signature requirements).
|
||||
*/
|
||||
export type AuthedRequest = (uri: string, params: { [key: string]: string } | null) => Promise<any>;
|
||||
|
||||
export interface CustomProtocol {
|
||||
/**
|
||||
* the authorization protocol used.
|
||||
*/
|
||||
protocol: 'oauth' | 'oauth2';
|
||||
/**
|
||||
* the OAuth signature method (OAuth 1.0a only). Must be one of:
|
||||
* * 'HMAC-SHA1' - default
|
||||
* * 'RSA-SHA1' - in that case, the clientSecret is your RSA private key
|
||||
*/
|
||||
signatureMethod?: 'HMAC-SHA1' | 'RSA-SHA1';
|
||||
/**
|
||||
* the temporary credentials (request token) endpoint (OAuth 1.0a only).
|
||||
*/
|
||||
temporary?: string;
|
||||
/**
|
||||
* boolean that determines if OAuth client id and client secret will be sent
|
||||
* as parameters as opposed to an Authorization header (OAuth 2.0 only).
|
||||
* Defaults to false.
|
||||
*/
|
||||
useParamsAuth?: boolean;
|
||||
/**
|
||||
* the authorization endpoint URI.
|
||||
*/
|
||||
auth: string;
|
||||
/**
|
||||
* the access token endpoint URI.
|
||||
*/
|
||||
token: string;
|
||||
/**
|
||||
* the OAuth version.
|
||||
*/
|
||||
version?: string;
|
||||
/**
|
||||
* an array of scope strings (OAuth 2.0 only).
|
||||
*/
|
||||
scope?: string[] | ((query: StringLikeMap) => string[]);
|
||||
/**
|
||||
* the scope separator character (OAuth 2.0 only). Only required when a provider has a broken OAuth 2.0 implementation. Defaults to space (Facebook and GitHub default to comma).
|
||||
*/
|
||||
scopeSeparator?: string;
|
||||
/**
|
||||
* a headers object with additional headers required by the provider
|
||||
* (e.g. GitHub required the 'User-Agent' header which is set by default).
|
||||
*/
|
||||
headers?: {
|
||||
[key: string]: string;
|
||||
};
|
||||
/**
|
||||
* a function used to obtain user profile information and normalize it.
|
||||
* @param credentials the credentials object.
|
||||
* Change the object directly within the function (profile information is typically stored under credentials.profile).
|
||||
* @param params the parsed information received from the provider (e.g. token, secret, and other custom fields).
|
||||
* @param get an OAuth helper function to make authenticated requests using the credentials received.
|
||||
*/
|
||||
profile(credentials: any, params: { [key: string]: string }, get: AuthedRequest): Promise<void>;
|
||||
}
|
||||
|
||||
export interface CustomProviderOptions extends RequiredProviderOptions, OptionalOptions {
|
||||
provider: CustomProtocol;
|
||||
}
|
||||
|
||||
export type BellOptions = CustomProviderOptions | KnownProviderOptions;
|
||||
|
||||
export const plugin: Plugin<CustomProviderOptions | KnownProviderOptions>;
|
||||
/**
|
||||
* Enables simulation mode.
|
||||
*/
|
||||
export function simulate(credentialsFunc: RequestPassThrough): void;
|
||||
/**
|
||||
* [See docs](https://github.com/hapijs/bell/blob/master/API.md#simulated-authentication)
|
||||
* Disables simulation mode
|
||||
*/
|
||||
export function simulate(state: false): void;
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"bell-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"unified-signatures": false // Disabling as it prevents me from using overloaded doctags
|
||||
}
|
||||
}
|
||||
Vendored
+1
-1
@@ -42,7 +42,7 @@ declare namespace Bull {
|
||||
* When specified, the `Queue` will use this function to create new `ioredis` client connections.
|
||||
* This is useful if you want to re-use connections.
|
||||
*/
|
||||
createClient?(type: 'client' | 'subscriber', redisOpts?: Redis.RedisOptions): Redis.Redis;
|
||||
createClient?(type: 'client' | 'subscriber' | 'bclient', redisOpts?: Redis.RedisOptions): Redis.Redis;
|
||||
|
||||
/**
|
||||
* Prefix to use for all redis keys
|
||||
|
||||
@@ -10,3 +10,11 @@ status = CircuitBreaker.OPEN;
|
||||
|
||||
breaker.forceOpen();
|
||||
breaker.forceClose();
|
||||
|
||||
breaker.run((success, failure) => {
|
||||
if (Math.random() > 0.5) {
|
||||
success();
|
||||
} else {
|
||||
failure();
|
||||
}
|
||||
});
|
||||
|
||||
Vendored
+7
-1
@@ -30,7 +30,13 @@ declare class CircuitBreaker {
|
||||
static CLOSED: 2;
|
||||
|
||||
constructor(options?: CircuitBreaker.Options);
|
||||
run(command: () => void, fallback?: () => void): void;
|
||||
run(
|
||||
command: (
|
||||
success: () => void,
|
||||
failure: () => void,
|
||||
) => void,
|
||||
fallback?: () => void
|
||||
): void;
|
||||
forceClose(): void;
|
||||
forceOpen(): void;
|
||||
unforce(): void;
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
import commandLineUsage = require("command-line-usage");
|
||||
|
||||
const sections = [
|
||||
{
|
||||
header: 'A typical app',
|
||||
content: 'Generates something {italic very} important.'
|
||||
},
|
||||
{
|
||||
header: 'Options',
|
||||
optionList: [
|
||||
{
|
||||
name: 'input',
|
||||
typeLabel: '{underline file}',
|
||||
description: 'The input to process.'
|
||||
},
|
||||
{
|
||||
name: 'help',
|
||||
description: 'Print this usage guide.'
|
||||
}
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
const usage = commandLineUsage(sections);
|
||||
Vendored
+48
@@ -0,0 +1,48 @@
|
||||
// Type definitions for command-line-usage 5.0
|
||||
// Project: https://github.com/75lb/command-line-usage#readme
|
||||
// Definitions by: Andrija Dvorski <https://github.com/Dvorsky>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
declare namespace commandLineUsage {
|
||||
interface Section {
|
||||
list: string[];
|
||||
|
||||
add(content: object): void;
|
||||
emptyLine(): void;
|
||||
header(text: string): void;
|
||||
toString(): string;
|
||||
}
|
||||
|
||||
interface SectionData {
|
||||
optionList?: OptionListData[];
|
||||
hide?: string[];
|
||||
group?: string[];
|
||||
header?: string;
|
||||
reverseNameOrder?: boolean;
|
||||
tableOptions?: any;
|
||||
}
|
||||
|
||||
interface OptionListData extends SectionData {
|
||||
name: string;
|
||||
typeLabel?: string;
|
||||
description?: string;
|
||||
}
|
||||
|
||||
interface ContentSectionData extends SectionData {
|
||||
content: string;
|
||||
raw?: boolean;
|
||||
}
|
||||
|
||||
type CommandLineUsageInput =
|
||||
SectionData
|
||||
| SectionData[]
|
||||
| OptionListData
|
||||
| OptionListData[]
|
||||
| ContentSectionData
|
||||
| ContentSectionData[];
|
||||
}
|
||||
|
||||
declare function commandLineUsage(sections: commandLineUsage.CommandLineUsageInput): string | undefined | commandLineUsage.Section;
|
||||
|
||||
export = commandLineUsage;
|
||||
@@ -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",
|
||||
"command-line-usage-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
@@ -4,9 +4,11 @@ import CryptoJS = require('crypto-js');
|
||||
var wordArray: CryptoJS.WordArray;
|
||||
wordArray = CryptoJS.MD5('some message');
|
||||
wordArray = CryptoJS.MD5('some message', 'some key');
|
||||
wordArray = CryptoJS.MD5('some message', { any: true });
|
||||
|
||||
wordArray = CryptoJS.SHA1('some message');
|
||||
wordArray = CryptoJS.SHA1('some message', 'some key', { any: true });
|
||||
wordArray = CryptoJS.SHA1('some message', { any: true });
|
||||
|
||||
wordArray = CryptoJS.format.OpenSSL('some message');
|
||||
wordArray = CryptoJS.format.OpenSSL('some message', 'some key');
|
||||
|
||||
Vendored
+34
-18
@@ -8,7 +8,6 @@ export as namespace CryptoJS;
|
||||
|
||||
declare var CryptoJS: CryptoJS.Hashes;
|
||||
declare namespace CryptoJS {
|
||||
type Hash = (message: string | LibWordArray, key?: string | WordArray, ...options: any[]) => WordArray;
|
||||
interface Cipher {
|
||||
encrypt(message: string, secretPassphrase: string | WordArray, option?: CipherOption): WordArray;
|
||||
decrypt(encryptedMessage: string | WordArray, secretPassphrase: string | WordArray, option?: CipherOption): DecryptedMessage;
|
||||
@@ -54,23 +53,40 @@ declare namespace CryptoJS {
|
||||
interface Padding {}
|
||||
|
||||
export interface Hashes {
|
||||
MD5: Hash;
|
||||
SHA1: Hash;
|
||||
SHA256: Hash;
|
||||
SHA224: Hash;
|
||||
SHA512: Hash;
|
||||
SHA384: Hash;
|
||||
SHA3: Hash;
|
||||
RIPEMD160: Hash;
|
||||
HmacMD5: Hash;
|
||||
HmacSHA1: Hash;
|
||||
HmacSHA256: Hash;
|
||||
HmacSHA224: Hash;
|
||||
HmacSHA512: Hash;
|
||||
HmacSHA384: Hash;
|
||||
HmacSHA3: Hash;
|
||||
HmacRIPEMD160: Hash;
|
||||
PBKDF2: Hash;
|
||||
MD5(message: string | LibWordArray, key?: string | WordArray, ...options: any[]): WordArray;
|
||||
MD5(message: string | LibWordArray, ...options: any[]): WordArray;
|
||||
SHA1(message: string | LibWordArray, key?: string | WordArray, ...options: any[]): WordArray;
|
||||
SHA1(message: string | LibWordArray, ...options: any[]): WordArray;
|
||||
SHA256(message: string | LibWordArray, key?: string | WordArray, ...options: any[]): WordArray;
|
||||
SHA256(message: string | LibWordArray, ...options: any[]): WordArray;
|
||||
SHA224(message: string | LibWordArray, key?: string | WordArray, ...options: any[]): WordArray;
|
||||
SHA224(message: string | LibWordArray, ...options: any[]): WordArray;
|
||||
SHA512(message: string | LibWordArray, key?: string | WordArray, ...options: any[]): WordArray;
|
||||
SHA512(message: string | LibWordArray, ...options: any[]): WordArray;
|
||||
SHA384(message: string | LibWordArray, key?: string | WordArray, ...options: any[]): WordArray;
|
||||
SHA384(message: string | LibWordArray, ...options: any[]): WordArray;
|
||||
SHA3(message: string | LibWordArray, key?: string | WordArray, ...options: any[]): WordArray;
|
||||
SHA3(message: string | LibWordArray, ...options: any[]): WordArray;
|
||||
RIPEMD160(message: string | LibWordArray, key?: string | WordArray, ...options: any[]): WordArray;
|
||||
RIPEMD160(message: string | LibWordArray, ...options: any[]): WordArray;
|
||||
HmacMD5(message: string | LibWordArray, key?: string | WordArray, ...options: any[]): WordArray;
|
||||
HmacMD5(message: string | LibWordArray, ...options: any[]): WordArray;
|
||||
HmacSHA1(message: string | LibWordArray, key?: string | WordArray, ...options: any[]): WordArray;
|
||||
HmacSHA1(message: string | LibWordArray, ...options: any[]): WordArray;
|
||||
HmacSHA256(message: string | LibWordArray, key?: string | WordArray, ...options: any[]): WordArray;
|
||||
HmacSHA256(message: string | LibWordArray, ...options: any[]): WordArray;
|
||||
HmacSHA224(message: string | LibWordArray, key?: string | WordArray, ...options: any[]): WordArray;
|
||||
HmacSHA224(message: string | LibWordArray, ...options: any[]): WordArray;
|
||||
HmacSHA512(message: string | LibWordArray, key?: string | WordArray, ...options: any[]): WordArray;
|
||||
HmacSHA512(message: string | LibWordArray, ...options: any[]): WordArray;
|
||||
HmacSHA384(message: string | LibWordArray, key?: string | WordArray, ...options: any[]): WordArray;
|
||||
HmacSHA384(message: string | LibWordArray, ...options: any[]): WordArray;
|
||||
HmacSHA3(message: string | LibWordArray, key?: string | WordArray, ...options: any[]): WordArray;
|
||||
HmacSHA3(message: string | LibWordArray, ...options: any[]): WordArray;
|
||||
HmacRIPEMD160(message: string | LibWordArray, key?: string | WordArray, ...options: any[]): WordArray;
|
||||
HmacRIPEMD160(message: string | LibWordArray, ...options: any[]): WordArray;
|
||||
PBKDF2(message: string | LibWordArray, key?: string | WordArray, ...options: any[]): WordArray;
|
||||
PBKDF2(message: string | LibWordArray, ...options: any[]): WordArray;
|
||||
AES: Cipher;
|
||||
DES: Cipher;
|
||||
TripleDES: Cipher;
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
const config: DataTables.Settings = {
|
||||
// AutoFill extension options
|
||||
autoFill: {
|
||||
alwaysAsk: true,
|
||||
enable: true,
|
||||
columns: [1, 2]
|
||||
}
|
||||
};
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
// Type definitions for datatables.net-autofill 2.2
|
||||
// Project: https://datatables.net
|
||||
// Definitions by: Andy Ma <https://github.com/andy-maca>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.4
|
||||
|
||||
/// <reference types="jquery" />
|
||||
/// <reference types="datatables.net"/>
|
||||
|
||||
declare namespace DataTables {
|
||||
interface Settings {
|
||||
/*
|
||||
* autoFill extension options
|
||||
*/
|
||||
autoFill?: boolean | AutoFillSettings;
|
||||
}
|
||||
|
||||
interface AutoFillSettings {
|
||||
/*
|
||||
* Always ask the end user if an action should be taken or not
|
||||
*/
|
||||
alwaysAsk?: boolean;
|
||||
/*
|
||||
* Select the columns that can be auto filled
|
||||
*/
|
||||
columns: string | number[];
|
||||
/*
|
||||
*
|
||||
* Initial enablement state of AutoFill
|
||||
*/
|
||||
enable?: boolean;
|
||||
}
|
||||
}
|
||||
@@ -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",
|
||||
"datatables.net-autofill-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
@@ -0,0 +1,12 @@
|
||||
$(document).ready(() => {
|
||||
const config: DataTables.Settings = {
|
||||
// ColReorder extension options
|
||||
colReorder: {
|
||||
fixedColumnsLeft: 0,
|
||||
fixedColumnsRight: 0,
|
||||
order: [1, 2, 3],
|
||||
realtime: true,
|
||||
reorderCallback: () => {},
|
||||
}
|
||||
};
|
||||
});
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
// Type definitions for datatables.net-colReorder 1.4
|
||||
// Project: https://datatables.net/extensions/colreorder/
|
||||
// Definitions by: Andy Ma <https://github.com/andy-maca>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.4
|
||||
|
||||
/// <reference types="jquery" />
|
||||
/// <reference types="datatables.net"/>
|
||||
|
||||
declare namespace DataTables {
|
||||
interface Settings {
|
||||
/*
|
||||
* colReorder extension options
|
||||
*/
|
||||
colReorder?: boolean | ColReorderSettings;
|
||||
}
|
||||
|
||||
interface ColReorderSettings {
|
||||
/*
|
||||
* Number of columns (counting from the left) to disallow reordering of, '0' in default
|
||||
*/
|
||||
fixedColumnsLeft?: number;
|
||||
|
||||
/*
|
||||
* Number of columns (counting from the right) to disallow reordering of, '0' in default
|
||||
*/
|
||||
fixedColumnsRight?: number;
|
||||
|
||||
/*
|
||||
* Set a default order for the columns in the table
|
||||
*/
|
||||
order?: number[];
|
||||
|
||||
/*
|
||||
* Enable / disable live reordering of columns during a drag, 'true' in default
|
||||
*/
|
||||
realtime?: boolean;
|
||||
/*
|
||||
* Callback after reorder
|
||||
*/
|
||||
reorderCallback: () => void;
|
||||
}
|
||||
|
||||
interface Api {
|
||||
colReorder: {
|
||||
/*
|
||||
* Programmatically reorder columns
|
||||
*/
|
||||
move(from: number, to: number, drop: boolean, invalidate: boolean): Api;
|
||||
/*
|
||||
* Get / set column order
|
||||
*/
|
||||
order(newOrder?: number[], originalIndexes?: boolean): Api;
|
||||
/*
|
||||
* Restore the loaded column order
|
||||
*/
|
||||
reset(): Api;
|
||||
/*
|
||||
* Convert one or more column indexes to and from current and original indexes
|
||||
*/
|
||||
transpose(idx?: number | number[], direction?: "toCurrent" | "toOriginal" | "fromOriginal" | "fromCurrent"): Api;
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"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",
|
||||
"datatables.net-colreorder-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
+36
-1
@@ -44,6 +44,41 @@ declare namespace DataTables {
|
||||
/*
|
||||
* Set the selection style for end user interaction with the table
|
||||
*/
|
||||
style?: string;
|
||||
style?: "api" | "single" | "multi" | "os" | "multi+shift";
|
||||
}
|
||||
|
||||
interface Api {
|
||||
select: {
|
||||
/*
|
||||
* Get the current selection style applied to the table
|
||||
*/
|
||||
style(): string;
|
||||
/*
|
||||
* Set the table's selection style
|
||||
*/
|
||||
style(s: "api" | "single" | "multi" | "os"): Api;
|
||||
};
|
||||
}
|
||||
|
||||
interface RowMethods {
|
||||
/**
|
||||
* Select a row
|
||||
*/
|
||||
select(): Api;
|
||||
/**
|
||||
* Deselect a row
|
||||
*/
|
||||
deselect(): Api;
|
||||
}
|
||||
|
||||
interface RowsMethods {
|
||||
/**
|
||||
* Select multiple rows
|
||||
*/
|
||||
select(): Api;
|
||||
/**
|
||||
* Deselect a row
|
||||
*/
|
||||
deselect(): Api;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -225,7 +225,7 @@ let config: DataTables.Settings = {
|
||||
],
|
||||
// Data
|
||||
ajax: "url",
|
||||
data: {},
|
||||
data: [],
|
||||
// Features
|
||||
autoWidth: true,
|
||||
deferRender: true,
|
||||
|
||||
Vendored
+9
-4
@@ -28,6 +28,10 @@ declare namespace DataTables {
|
||||
}
|
||||
|
||||
interface Api extends CoreMethods {
|
||||
/**
|
||||
* API should be array-like
|
||||
*/
|
||||
[key: number]: any;
|
||||
/**
|
||||
* Returns DataTables API instance
|
||||
*
|
||||
@@ -221,7 +225,7 @@ declare namespace DataTables {
|
||||
* @param event Event name to remove.
|
||||
* @param callback Specific callback function to remove if you want to unbind a single event listener.
|
||||
*/
|
||||
off(event: string, callback?: ((e: Event, settings: Settings, json: any) => void)): Api;
|
||||
off(event: string, callback?: ((e: Event, ...args: any[]) => void)): Api;
|
||||
|
||||
/**
|
||||
* Table events listener.
|
||||
@@ -229,7 +233,7 @@ declare namespace DataTables {
|
||||
* @param event Event to listen for.
|
||||
* @param callback Specific callback function to remove if you want to unbind a single event listener.
|
||||
*/
|
||||
on(event: string, callback: ((e: Event, settings: Settings, json: any) => void)): Api;
|
||||
on(event: string, callback: ((e: Event, ...args: any[]) => void)): Api;
|
||||
|
||||
/**
|
||||
* Listen for a table event once and then remove the listener.
|
||||
@@ -237,7 +241,7 @@ declare namespace DataTables {
|
||||
* @param event Event to listen for.
|
||||
* @param callback Specific callback function to remove if you want to unbind a single event listener.
|
||||
*/
|
||||
one(event: string, callback: ((e: Event, settings: Settings, json: any) => void)): Api;
|
||||
one(event: string, callback: ((e: Event, ...args: any[]) => void)): Api;
|
||||
|
||||
/**
|
||||
* Page Methods / object
|
||||
@@ -1297,7 +1301,7 @@ declare namespace DataTables {
|
||||
/**
|
||||
* Data to use as the display data for the table. Since: 1.10
|
||||
*/
|
||||
data?: object;
|
||||
data?: any[];
|
||||
|
||||
//#endregion "Data"
|
||||
|
||||
@@ -1931,6 +1935,7 @@ declare namespace DataTables {
|
||||
}
|
||||
|
||||
interface ColumnLegacy {
|
||||
idx: number;
|
||||
aDataSort: any;
|
||||
asSorting: string[];
|
||||
bSearchable: boolean;
|
||||
|
||||
Vendored
+5
-4
@@ -1,4 +1,5 @@
|
||||
/*!
|
||||
* Dynamsoft WebTwain PDF Addon
|
||||
* Based on Dynamsoft WebTwain JavaScript Intellisense
|
||||
* Product: Dynamsoft Web Twain
|
||||
* Web Site: http://www.dynamsoft.com
|
||||
@@ -8,9 +9,9 @@
|
||||
* Version: 13.4
|
||||
*/
|
||||
|
||||
declare enum EnumDWT_ConverMode {
|
||||
declare enum EnumDWT_ConvertMode {
|
||||
CM_DEFAULT = 0,
|
||||
TWPT_CM_RENDERALLGRAY = 1
|
||||
CM_RENDERALL = 1
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -42,10 +43,10 @@ interface PDF {
|
||||
/**
|
||||
* Set the image convert mode for PDF Rasterizer in Dynamic Web TWAIN.
|
||||
* @method Dynamsoft.WebTwain#SetConvertMode
|
||||
* @param {EnumDWT_ConverMode} convertMode Specifies the image convert mode.
|
||||
* @param {EnumDWT_ConvertMode} convertMode Specifies the image convert mode.
|
||||
* @return {boolean}
|
||||
*/
|
||||
SetConvertMode(convertMode: EnumDWT_ConverMode): boolean;
|
||||
SetConvertMode(convertMode: EnumDWT_ConvertMode): boolean;
|
||||
|
||||
/**
|
||||
* Set the output resolution for the PDF Rasterizer in Dynamic Web TWAIN.
|
||||
|
||||
Vendored
+57
-37
@@ -27,7 +27,19 @@ declare namespace Dynamsoft {
|
||||
Errors Events IntToColorStr LS OnGetImageByURL OnGetImageFromServer Path ProgressBar UI Uri
|
||||
addEventListener ajax all appendMessage appendRichMessage aryControlLoadImage attachAddon attachProperty
|
||||
base64 bio cancelFrome clearMessage closeAll closeProgress colorStrToInt config css currentStyle
|
||||
debug detect detectButton dialog dialogShowStatus dlgProgress dlgRef drawBoxBorder drawImageWithHermite
|
||||
debug*/
|
||||
|
||||
let detect: {
|
||||
/*ignored
|
||||
OnCreatWS OnDetectNext OnWebTwainPostExecute OnWebTwainPreExecute StartWSByIPTimeoutId StartWSTimeoutId
|
||||
aryReconnectSTwains arySTwains arySTwainsByIP bFirst bNeedUpgradeEvent bNoControlEvent bOK bPromptJSOrServerOutdated
|
||||
cUrlIndex dcpCallbackType dcpStatus detectType getVersionArray global_dlg hideMask isDWTVersionLatest onNoControl
|
||||
onNotAllowedForChrome ports scriptLoaded showMask starting tryTimes*/
|
||||
ssl: boolean;
|
||||
};
|
||||
|
||||
/*ignored
|
||||
detectButton dialog dialogShowStatus dlgProgress dlgRef drawBoxBorder drawImageWithHermite
|
||||
each empty endsWith
|
||||
*/
|
||||
|
||||
@@ -53,44 +65,47 @@ declare namespace Dynamsoft {
|
||||
*/
|
||||
}
|
||||
namespace WebTwainEnv {
|
||||
let JSVersion: string;
|
||||
let PluginVersion: string;
|
||||
let ActiveXVersion: string;
|
||||
let ServerVersionInfo: string;
|
||||
|
||||
let Trial: boolean;
|
||||
let AutoLoad: boolean;
|
||||
let ProductKey: string;
|
||||
let ResourcesPath: string;
|
||||
|
||||
let IfUpdateService: boolean;
|
||||
let IfUseActiveXForIE10Plus: boolean;
|
||||
let UseDefaultInstallUI: string;
|
||||
let ActiveXInstallWithCAB: boolean;
|
||||
let Debug: boolean;
|
||||
|
||||
let ActiveXVersion: string;
|
||||
let AutoLoad: boolean;
|
||||
function CloseDialog(): void;
|
||||
let ContainerMap: {};
|
||||
let Containers: Container[];
|
||||
function CreateDWTObject(newObjID: string, successFn: (dwtObject: WebTwain) => void, failurefn: (...args: any[]) => void): void;
|
||||
function CreateDWTObject(newObjID: string, ip: number | string, port: number | string, portSSL: number | string, successFn: (dwtObject: WebTwain) => void, failurefn: (...args: any[]) => void): void;
|
||||
let Debug: boolean;
|
||||
function DeleteDWTObject(objID: string): void;
|
||||
let DynamicContainers: string[];
|
||||
let DynamicDWTMap: {};
|
||||
|
||||
function CreateDWTObject(newObjID: string, successFn: (dwtObject: WebTwain) => void, failurefn: (...args: any[]) => void): void;
|
||||
function GetWebTwain(cid: string): WebTwain;
|
||||
function DeleteDWTObject(objID: string): void;
|
||||
let IfUpdateService: boolean;
|
||||
let IfUseActiveXForIE10Plus: boolean;
|
||||
let JSVersion: string;
|
||||
function Load(): void;
|
||||
function Unload(): void;
|
||||
function RegisterEvent(event: string, fn: (...args: any[]) => void): void;
|
||||
|
||||
/*ignored
|
||||
initQueue inited UseDefaultInstallUI
|
||||
OnWebTwainInitMessage OnWebTwainNeedUpgrade OnWebTwainNeedUpgradeWebJavascript OnWebTwainNotFound OnWebTwainOldPluginNotAllowed OnWebTwainReady
|
||||
OnWebTwainInitMessage OnWebTwainNeedUpgrade OnWebTwainNeedUpgradeWebJavascript OnWebTwainNotFound OnWebTwainOldPluginNotAllowed
|
||||
*/
|
||||
|
||||
function OnWebTwainPostExecute(): void;
|
||||
function OnWebTwainPreExecute(): void;
|
||||
|
||||
/*ignored
|
||||
OnWebTwainReady
|
||||
*/
|
||||
|
||||
let PluginVersion: string;
|
||||
let ProductKey: string;
|
||||
function RegisterEvent(event: string, fn: (...args: any[]) => void): void;
|
||||
function RemoveAllAuthorizations(): void;
|
||||
let ResourcesPath: string;
|
||||
let ServerVersionInfo: string;
|
||||
function ShowDialog(_dialogWidth: number, _dialogHeight: number, _strDialogMessageWithHtmlFormat: string, _bChangeImage: boolean, bHideCloseButton: boolean): void;
|
||||
function CloseDialog(): void;
|
||||
let Trial: boolean;
|
||||
function Unload(): void;
|
||||
let UseDefaultInstallUI: string;
|
||||
let initQueue: number[];
|
||||
let inited: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2244,10 +2259,15 @@ interface WebTwain {
|
||||
*/
|
||||
Zoom: number;
|
||||
|
||||
/** ignored
|
||||
/* ignored
|
||||
style
|
||||
_AutoCropMethod
|
||||
*/
|
||||
|
||||
/*
|
||||
*Methods
|
||||
*/
|
||||
|
||||
/**
|
||||
* Displays the source's built-in interface to acquire image.
|
||||
* @method WebTwain#AcquireImage
|
||||
@@ -2916,7 +2936,7 @@ interface WebTwain {
|
||||
* @param {function} optionalAsyncFailureFunc optional. The function to call when the download fails. Please refer to the function prototype OnFailure.
|
||||
* @return {boolean}
|
||||
*/
|
||||
HTTPDownloadThroughPost(HTTPServer: string, HTTPRemoteFile: string, lImageType: EnumDWT_ImageType, optionalAsyncSuccessFunc?: () => void, optionalAsyncFailureFunc?: (errorCode: number, errorString: string) => void): boolean;
|
||||
HTTPDownloadThroughPost(HTTPServer: string, HTTPRemoteFile: string, lImageType: EnumDWT_ImageType, optionalAsyncSuccessFunc?: () => void, optionalAsyncFailureFunc?: (errorCode: number, errorString: string, httppostresponsestring: string) => void): boolean;
|
||||
|
||||
/**
|
||||
* Uploads the images specified by the indices to the HTTP server.
|
||||
@@ -2929,7 +2949,7 @@ interface WebTwain {
|
||||
* @param {function} asyncFailureFunc the function to call when the upload fails. Please refer to the function prototype OnFailure.
|
||||
* @return {boolean}
|
||||
*/
|
||||
HTTPUpload(url: string, indices: number[], enumImageType: EnumDWT_ImageType, dataFormat: EnumDWT_UploadDataFormat, optionalAsyncSuccessFunc?: () => void, optionalAsyncFailureFunc?: (errorCode: number, errorString: string) => void): boolean;
|
||||
HTTPUpload(url: string, indices: number[], enumImageType: EnumDWT_ImageType, dataFormat: EnumDWT_UploadDataFormat, optionalAsyncSuccessFunc?: () => void, optionalAsyncFailureFunc?: (errorCode: number, errorString: string, httppostresponsestring: string) => void): boolean;
|
||||
|
||||
/**
|
||||
* Uploads all images in the buffer to the HTTP server through the HTTP Post method as a Multi-Page TIFF.
|
||||
@@ -2941,7 +2961,7 @@ interface WebTwain {
|
||||
* @param {function} optionalAsyncFailureFunc optional. The function to call when the upload fails. Please refer to the function prototype OnHttpUploadFailure.
|
||||
* @return {boolean}
|
||||
*/
|
||||
HTTPUploadAllThroughPostAsMultiPageTIFF(HTTPServer: string, ActionPage: string, fileName: string, optionalAsyncSuccessFunc?: () => void, optionalAsyncFailureFunc?: (errorCode: number, errorString: string) => void): boolean;
|
||||
HTTPUploadAllThroughPostAsMultiPageTIFF(HTTPServer: string, ActionPage: string, fileName: string, optionalAsyncSuccessFunc?: () => void, optionalAsyncFailureFunc?: (errorCode: number, errorString: string, httppostresponsestring: string) => void): boolean;
|
||||
|
||||
/**
|
||||
* Uploads all images in the buffer to the HTTP server through HTTP Post method as a Multi-Page PDF.
|
||||
@@ -2953,7 +2973,7 @@ interface WebTwain {
|
||||
* @param {function} optionalAsyncFailureFunc optional. The function to call when the upload fails. Please refer to the function prototype OnHttpUploadFailure.
|
||||
* @return {boolean}
|
||||
*/
|
||||
HTTPUploadAllThroughPostAsPDF(HTTPServer: string, ActionPage: string, fileName: string, optionalAsyncSuccessFunc?: () => void, optionalAsyncFailureFunc?: (errorCode: number, errorString: string) => void): boolean;
|
||||
HTTPUploadAllThroughPostAsPDF(HTTPServer: string, ActionPage: string, fileName: string, optionalAsyncSuccessFunc?: () => void, optionalAsyncFailureFunc?: (errorCode: number, errorString: string, httppostresponsestring: string) => void): boolean;
|
||||
|
||||
/**
|
||||
* [Deprecated.] Uploads all images in the buffer to the HTTP server through the HTTP Put method as a Multi-Page TIFF.
|
||||
@@ -2992,7 +3012,7 @@ interface WebTwain {
|
||||
* @param {function} optionalAsyncFailureFunc optional. The function to call when the upload fails. Please refer to the function prototype OnHttpUploadFailure.
|
||||
* @return {boolean}
|
||||
*/
|
||||
HTTPUploadThroughPost(HTTPServer: string, sImageIndex: number, ActionPage: string, fileName: string, optionalAsyncSuccessFunc?: () => void, optionalAsyncFailureFunc?: (errorCode: number, errorString: string) => void): boolean;
|
||||
HTTPUploadThroughPost(HTTPServer: string, sImageIndex: number, ActionPage: string, fileName: string, optionalAsyncSuccessFunc?: () => void, optionalAsyncFailureFunc?: (errorCode: number, errorString: string, httppostresponsestring: string) => void): boolean;
|
||||
|
||||
/**
|
||||
* Uploads the selected images in the buffer to the HTTP server through the HTTP Post method as a Multi-Page TIFF.
|
||||
@@ -3004,7 +3024,7 @@ interface WebTwain {
|
||||
* @param {function} optionalAsyncFailureFunc optional. The function to call when the upload fails. Please refer to the function prototype OnHttpUploadFailure.
|
||||
* @return {boolean}
|
||||
*/
|
||||
HTTPUploadThroughPostAsMultiPageTIFF(HTTPServer: string, ActionPage: string, fileName: string, optionalAsyncSuccessFunc?: () => void, optionalAsyncFailureFunc?: (errorCode: number, errorString: string) => void): boolean;
|
||||
HTTPUploadThroughPostAsMultiPageTIFF(HTTPServer: string, ActionPage: string, fileName: string, optionalAsyncSuccessFunc?: () => void, optionalAsyncFailureFunc?: (errorCode: number, errorString: string, httppostresponsestring: string) => void): boolean;
|
||||
|
||||
/**
|
||||
* Uploads the selected images in the buffer to the HTTP server through the HTTP Post method as a Multi-Page PDF.
|
||||
@@ -3016,7 +3036,7 @@ interface WebTwain {
|
||||
* @param {function} optionalAsyncFailureFunc optional. The function to call when the upload fails. Please refer to the function prototype OnHttpUploadFailure.
|
||||
* @return {boolean}
|
||||
*/
|
||||
HTTPUploadThroughPostAsMultiPagePDF(HTTPServer: string, ActionPage: string, fileName: string, optionalAsyncSuccessFunc?: () => void, optionalAsyncFailureFunc?: (errorCode: number, errorString: string) => void): boolean;
|
||||
HTTPUploadThroughPostAsMultiPagePDF(HTTPServer: string, ActionPage: string, fileName: string, optionalAsyncSuccessFunc?: () => void, optionalAsyncFailureFunc?: (errorCode: number, errorString: string, httppostresponsestring: string) => void): boolean;
|
||||
|
||||
/**
|
||||
* Directly upload a specific local file to the HTTP server through the HTTP POST method without loading it into Dynamic Web TWAIN.
|
||||
@@ -3029,7 +3049,7 @@ interface WebTwain {
|
||||
* @param {function} optionalAsyncFailureFunc optional. The function to call when the upload fails. Please refer to the function prototype OnHttpUploadFailure.
|
||||
* @return {boolean}
|
||||
*/
|
||||
HTTPUploadThroughPostDirectly(HTTPServer: string, localFile: string, ActionPage: string, fileName: string, optionalAsyncSuccessFunc?: () => void, optionalAsyncFailureFunc?: (errorCode: number, errorString: string) => void): boolean;
|
||||
HTTPUploadThroughPostDirectly(HTTPServer: string, localFile: string, ActionPage: string, fileName: string, optionalAsyncSuccessFunc?: () => void, optionalAsyncFailureFunc?: (errorCode: number, errorString: string, httppostresponsestring: string) => void): boolean;
|
||||
|
||||
/**
|
||||
* Uploads the image of a specified index in the buffer to the HTTP server as a specified image format through the HTTP POST method.
|
||||
@@ -3043,7 +3063,7 @@ interface WebTwain {
|
||||
* @param {function} optionalAsyncFailureFunc optional. The function to call when the upload succeeds. Please refer to the function prototype OnHttpUploadFailure.
|
||||
* @return {boolean}
|
||||
*/
|
||||
HTTPUploadThroughPostEx(HTTPServer: string, sImageIndex: number, ActionPage: string, fileName: string, lImageType: EnumDWT_ImageType, optionalAsyncSuccessFunc?: () => void, optionalAsyncFailureFunc?: (errorCode: number, errorString: string) => void): boolean;
|
||||
HTTPUploadThroughPostEx(HTTPServer: string, sImageIndex: number, ActionPage: string, fileName: string, lImageType: EnumDWT_ImageType, optionalAsyncSuccessFunc?: () => void, optionalAsyncFailureFunc?: (errorCode: number, errorString: string, httppostresponsestring: string) => void): boolean;
|
||||
|
||||
/**
|
||||
* [Deprecated.] Uploads the image of a specified index in the buffer to the HTTP server through the HTTP PUT method.
|
||||
@@ -3244,10 +3264,10 @@ interface WebTwain {
|
||||
* Binds a specified function to an event, so that the function gets called whenever the event fires.
|
||||
* @method WebTwain#RegisterEvent
|
||||
* @param {string} name the name of the event that the function is bound to.
|
||||
* @param {object} evt specifies the function to call when event fires.
|
||||
* @param {any} evt specifies the function to call when event fires.
|
||||
* @return {boolean}
|
||||
*/
|
||||
RegisterEvent(name: string, evt: object): boolean;
|
||||
RegisterEvent(name: string, evt: any): boolean;
|
||||
|
||||
/**
|
||||
* Removes all images in buffer.
|
||||
@@ -3415,7 +3435,7 @@ interface WebTwain {
|
||||
/**
|
||||
* Saves the selected images in buffer to base64 string.
|
||||
* @method WebTwain#SaveSelectedImagesToBase64Binary
|
||||
* @return {string|bool}
|
||||
* @return {string|boolean}
|
||||
*/
|
||||
SaveSelectedImagesToBase64Binary(optionalAsyncSuccessFunc?: (result: string[]) => void, optionalAsyncFailureFunc?: (errorCode: number, errorString: string) => void): string | boolean;
|
||||
|
||||
|
||||
Vendored
+18
-3
@@ -44,6 +44,20 @@ declare module 'ember-qunit' {
|
||||
*/
|
||||
export function setResolver(resolver: Ember.Resolver): void;
|
||||
|
||||
/**
|
||||
* Sets up acceptance tests.
|
||||
*
|
||||
* The `setupApplicationTest` function is used for all acceptance tests. It
|
||||
* is invoked in the callback scope of a QUnit module (aka "nested module").
|
||||
*
|
||||
* Once invoked, all subsequent hooks.beforeEach and test invocations will
|
||||
* have access to the following:
|
||||
* * `this.owner` - the owner object that been set on the test context.
|
||||
* * `this.pauseTest` and `this.resumeTest` - allow easy pausing/resuming of tests.
|
||||
* * `this.element` which returns the DOM element representing the application's root element.
|
||||
*/
|
||||
export function setupApplicationTest(hooks: NestedHooks): void;
|
||||
|
||||
/**
|
||||
* Sets up tests that need to render snippets of templates.
|
||||
*
|
||||
@@ -80,7 +94,7 @@ declare module 'ember-qunit' {
|
||||
*/
|
||||
export function setupTest(hooks: NestedHooks): void;
|
||||
|
||||
export class QUnitAdapter extends Ember.Test.Adapter {}
|
||||
export class QUnitAdapter extends Ember.Test.Adapter { }
|
||||
|
||||
export { module, test, skip, only, todo } from 'qunit';
|
||||
}
|
||||
@@ -147,9 +161,10 @@ declare module 'qunit' {
|
||||
* ignoring the callback argument and the respective global and module's
|
||||
* hooks.
|
||||
*
|
||||
* @param Title of unit being tested
|
||||
* @param name Title of unit being tested
|
||||
* @param callback Function to close over assertions
|
||||
*/
|
||||
export const skip: typeof QUnit.skip;
|
||||
export function skip(name: string, callback?: (this: TestContext, assert: Assert) => void): void;
|
||||
|
||||
export default QUnit;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
import enquire = require('enquire.js');
|
||||
|
||||
enquire
|
||||
.register('(min-width: 300px) and (max-width: 600px)', {
|
||||
deferSetup: true,
|
||||
match: () => {},
|
||||
unmatch: () => {},
|
||||
setup: () => {},
|
||||
destroy: () => {}
|
||||
})
|
||||
.register('(min-width: 300px) and (max-width: 600px)', {});
|
||||
|
||||
enquire.register('(min-width: 300px) and (max-width: 600px)', [{}, {}], true);
|
||||
|
||||
enquire.register('(min-width: 300px) and (max-width: 600px)', () => {}, true);
|
||||
|
||||
enquire.unregister('(min-width: 300px) and (max-width: 600px)');
|
||||
Vendored
+43
@@ -0,0 +1,43 @@
|
||||
// Type definitions for enquire.js 2.1
|
||||
// Project: https://github.com/WickyNilliams/enquire.js/
|
||||
// Definitions by: Christian Rackerseder <https://github.com/screendriver>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.6
|
||||
|
||||
interface Options {
|
||||
/**
|
||||
* If set to true, defers execution of the setup function until the first time the media query is matched
|
||||
*/
|
||||
deferSetup?: boolean;
|
||||
/**
|
||||
* If supplied, triggered when a media query matches.
|
||||
*/
|
||||
match?(): void;
|
||||
/**
|
||||
* If supplied, triggered when the media query transitions from a matched state to an unmatched state.
|
||||
*/
|
||||
unmatch?(): void;
|
||||
/**
|
||||
* If supplied, triggered once, when the handler is registered.
|
||||
*/
|
||||
setup?(): void;
|
||||
|
||||
/**
|
||||
* If supplied, triggered when handler is unregistered. Place cleanup code here
|
||||
*/
|
||||
destroy?(): void;
|
||||
}
|
||||
|
||||
type Callback = () => void;
|
||||
|
||||
interface EnquireJs {
|
||||
register(
|
||||
mediaQuery: string,
|
||||
options: Options | Options[] | Callback,
|
||||
shouldDegrade?: boolean,
|
||||
): EnquireJs;
|
||||
unregister(mediaQuery: string, handler?: Callback | Options): void;
|
||||
}
|
||||
|
||||
declare const enquire: EnquireJs;
|
||||
export = enquire;
|
||||
@@ -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",
|
||||
"enquire.js-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Vendored
+27
-27
@@ -20,64 +20,64 @@ export function addHexPrefix(str: string): string;
|
||||
|
||||
export function arrayContainsArray(superset: any, subset: any, some: any): any;
|
||||
|
||||
export function baToJSON(ba: Buffer | string[]): Buffer | string[];
|
||||
export function baToJSON(ba: Buffer | Uint8Array | string[]): Buffer | Uint8Array | string[];
|
||||
|
||||
export function bufferToHex(buf: Buffer): string;
|
||||
export function bufferToHex(buf: Buffer | Uint8Array): string;
|
||||
|
||||
export function bufferToInt(buf: Buffer): string;
|
||||
export function bufferToInt(buf: Buffer | Uint8Array): string;
|
||||
|
||||
export function defineProperties(self: {[k: string]: any}, fields: string[], data: {[k: string]: any}): {[k: string]: any};
|
||||
|
||||
export function ecrecover(msgHash: Buffer, v: number, r: Buffer, s: Buffer): Buffer;
|
||||
export function ecrecover(msgHash: Buffer | Uint8Array, v: number, r: Buffer | Uint8Array, s: Buffer | Uint8Array): Buffer | Uint8Array;
|
||||
|
||||
export function ecsign(msgHash: Buffer, privateKey: Buffer): {[k: string]: any};
|
||||
export function ecsign(msgHash: Buffer | Uint8Array, privateKey: Buffer | Uint8Array): {[k: string]: any};
|
||||
|
||||
export function fromRpcSig(sig: string): {[k: string]: any};
|
||||
|
||||
export function fromSigned(num: Buffer): any;
|
||||
export function fromSigned(num: Buffer | Uint8Array): any;
|
||||
|
||||
export function generateAddress(from: Buffer, nonce: Buffer): Buffer;
|
||||
export function generateAddress(from: Buffer | Uint8Array, nonce: Buffer | Uint8Array): Buffer | Uint8Array;
|
||||
|
||||
export function hashPersonalMessage(message: string): Buffer;
|
||||
export function hashPersonalMessage(message: string): Buffer | Uint8Array;
|
||||
|
||||
export function importPublic(publicKey: Buffer): Buffer;
|
||||
export function importPublic(publicKey: Buffer | Uint8Array): Buffer | Uint8Array;
|
||||
|
||||
export function isValidAddress(address: string): boolean;
|
||||
|
||||
export function isValidChecksumAddress(address: Buffer): boolean;
|
||||
export function isValidChecksumAddress(address: Buffer | Uint8Array): boolean;
|
||||
|
||||
export function isValidPrivate(privateKey: Buffer): boolean;
|
||||
export function isValidPrivate(privateKey: Buffer | Uint8Array): boolean;
|
||||
|
||||
export function isValidPublic(publicKey: Buffer, sanitize?: boolean): any;
|
||||
export function isValidPublic(publicKey: Buffer | Uint8Array, sanitize?: boolean): any;
|
||||
|
||||
export function isValidSignature(v: Buffer, r: Buffer, s: Buffer, homestead?: boolean): boolean;
|
||||
export function isValidSignature(v: Buffer | Uint8Array, r: Buffer | Uint8Array, s: Buffer | Uint8Array, homestead?: boolean): boolean;
|
||||
|
||||
export function privateToAddress(privateKey: Buffer): Buffer;
|
||||
export function privateToAddress(privateKey: Buffer | Uint8Array): Buffer | Uint8Array;
|
||||
|
||||
export function privateToPublic(privateKey: Buffer): Buffer;
|
||||
export function privateToPublic(privateKey: Buffer | Uint8Array): Buffer | Uint8Array;
|
||||
|
||||
export function pubToAddress(pubKey: Buffer, sanitize: boolean): Buffer;
|
||||
export function pubToAddress(pubKey: Buffer | Uint8Array, sanitize: boolean): Buffer | Uint8Array;
|
||||
|
||||
export function ripemd160(a: Buffer | any[] | string | number, padded: boolean): Buffer;
|
||||
export function ripemd160(a: Buffer | Uint8Array | any[] | string | number, padded: boolean): Buffer | Uint8Array;
|
||||
|
||||
export function rlphash(a: Buffer | any[] | string | number): Buffer;
|
||||
export function rlphash(a: Buffer | Uint8Array | any[] | string | number): Buffer | Uint8Array;
|
||||
|
||||
export function setLengthLeft(msg: Buffer | any[], length: number, right?: boolean): Buffer | any[];
|
||||
export function setLengthLeft(msg: Buffer | Uint8Array | any[], length: number, right?: boolean): Buffer | Uint8Array | any[];
|
||||
|
||||
export function setLengthRight(msg: Buffer | any[], length: number): Buffer | any[];
|
||||
export function setLengthRight(msg: Buffer | Uint8Array | any[], length: number): Buffer | Uint8Array | any[];
|
||||
|
||||
export function sha256(a: Buffer | any[] | string | number): Buffer;
|
||||
export function sha256(a: Buffer | Uint8Array | any[] | string | number): Buffer | Uint8Array;
|
||||
|
||||
export function sha3(a: Buffer | any[] | string | number, bits?: number): Buffer;
|
||||
export function sha3(a: Buffer | Uint8Array | any[] | string | number, bits?: number): Buffer | Uint8Array;
|
||||
|
||||
export function toBuffer(v: any): Buffer;
|
||||
export function toBuffer(v: any): Buffer | Uint8Array;
|
||||
|
||||
export function toChecksumAddress(address: string): string;
|
||||
|
||||
export function toRpcSig(v: number, r: Buffer, s: Buffer): string;
|
||||
export function toRpcSig(v: number, r: Buffer | Uint8Array, s: Buffer | Uint8Array): string;
|
||||
|
||||
export function toUnsigned(num: any): Buffer;
|
||||
export function toUnsigned(num: any): Buffer | Uint8Array;
|
||||
|
||||
export function unpad<T extends Buffer | any[] | string>(a: T): T;
|
||||
export function unpad<T extends Buffer | Uint8Array | any[] | string>(a: T): T;
|
||||
|
||||
export function zeros(bytes: number): Buffer;
|
||||
export function zeros(bytes: number): Buffer | Uint8Array;
|
||||
|
||||
Vendored
+2
-1
@@ -1701,7 +1701,7 @@ export namespace Pedometer {
|
||||
*/
|
||||
export namespace Permissions {
|
||||
type PermissionType = 'remoteNotifications' | 'location' |
|
||||
'camera' | 'contacts' | 'audioRecording';
|
||||
'camera' | 'contacts' | 'audioRecording' | 'calendar';
|
||||
type PermissionStatus = 'undetermined' | 'granted' | 'denied';
|
||||
type PermissionExpires = 'never';
|
||||
|
||||
@@ -1733,6 +1733,7 @@ export namespace Permissions {
|
||||
const NOTIFICATIONS: RemoteNotificationPermission;
|
||||
const CONTACTS: 'contacts';
|
||||
const SYSTEM_BRIGHTNESS: 'systemBrightness';
|
||||
const CALENDAR: 'calendar';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,29 +1,19 @@
|
||||
import express = require('express');
|
||||
import 'express-session';
|
||||
import graphqlHTTP = require('express-graphql');
|
||||
import { GraphQLSchema } from 'graphql/type/schema';
|
||||
import express = require("express");
|
||||
import "express-session";
|
||||
import graphqlHTTP = require("express-graphql");
|
||||
import { buildSchema } from "graphql";
|
||||
|
||||
const app = express();
|
||||
const schema: GraphQLSchema = {
|
||||
getQueryType: null,
|
||||
getMutationType: null,
|
||||
getSubscriptionType: null,
|
||||
getTypeMap: null,
|
||||
getType: null,
|
||||
getPossibleTypes: null,
|
||||
isPossibleType: null,
|
||||
getDirective: null,
|
||||
getDirectives: null,
|
||||
};
|
||||
const schema = buildSchema(`type Query { hello: String }`);
|
||||
|
||||
const graphqlOption: graphqlHTTP.OptionsData = {
|
||||
graphiql: true,
|
||||
schema,
|
||||
formatError: (error: Error) => ({
|
||||
message: error.message
|
||||
message: error.message,
|
||||
}),
|
||||
validationRules: [() => false, () => true],
|
||||
extensions: ({ document, variables, operationName, result }) => ({ key: "value", key2: "value"}),
|
||||
extensions: ({ document, variables, operationName, result }) => ({ key: "value", key2: "value" }),
|
||||
};
|
||||
|
||||
const graphqlOptionRequest = (request: express.Request): graphqlHTTP.OptionsData => ({
|
||||
@@ -38,15 +28,15 @@ const graphqlOptionRequestAsync = async (request: express.Request): Promise<grap
|
||||
graphiql: true,
|
||||
schema: await Promise.resolve(schema),
|
||||
context: request.session,
|
||||
extensions: async (args) => { },
|
||||
extensions: async args => {},
|
||||
validationRules: [() => false, () => true],
|
||||
};
|
||||
};
|
||||
|
||||
app.use('/graphql1', graphqlHTTP(graphqlOption));
|
||||
app.use("/graphql1", graphqlHTTP(graphqlOption));
|
||||
|
||||
app.use('/graphql2', graphqlHTTP(graphqlOptionRequest));
|
||||
app.use("/graphql2", graphqlHTTP(graphqlOptionRequest));
|
||||
|
||||
app.use('/graphqlasync', graphqlHTTP(graphqlOptionRequestAsync));
|
||||
app.use("/graphqlasync", graphqlHTTP(graphqlOptionRequestAsync));
|
||||
|
||||
app.listen(8080, () => console.log('GraphQL Server running on localhost:8080'));
|
||||
app.listen(8080, () => console.log("GraphQL Server running on localhost:8080"));
|
||||
|
||||
Vendored
+23
-19
@@ -5,21 +5,25 @@
|
||||
// Daniel Fader <https://github.com/hubel>
|
||||
// Ehsan Ziya <https://github.com/zya>
|
||||
// Margus Lamp <https://github.com/mlamp>
|
||||
// Firede <https://github.com/firede>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
import { Request, Response } from "express";
|
||||
import { DocumentNode, GraphQLSchema, GraphQLError } from 'graphql';
|
||||
import { DocumentNode, GraphQLSchema, GraphQLError } from "graphql";
|
||||
export = graphqlHTTP;
|
||||
|
||||
declare namespace graphqlHTTP {
|
||||
/**
|
||||
* Used to configure the graphQLHTTP middleware by providing a schema
|
||||
* Used to configure the graphqlHTTP middleware by providing a schema
|
||||
* and other configuration options.
|
||||
*
|
||||
* Options can be provided as an Object, a Promise for an Object, or a Function
|
||||
* that returns an Object or a Promise for an Object.
|
||||
*/
|
||||
export type Options = ((request: Request,
|
||||
response: Response,
|
||||
params?: GraphQLParams) => OptionsResult) | OptionsResult;
|
||||
export type Options =
|
||||
| ((request: Request, response: Response, params?: GraphQLParams) => OptionsResult)
|
||||
| OptionsResult;
|
||||
export type OptionsResult = OptionsData | Promise<OptionsData>;
|
||||
export interface OptionsData {
|
||||
/**
|
||||
@@ -40,20 +44,20 @@ declare namespace graphqlHTTP {
|
||||
/**
|
||||
* A boolean to configure whether the output should be pretty-printed.
|
||||
*/
|
||||
pretty?: boolean;
|
||||
pretty?: boolean | null;
|
||||
|
||||
/**
|
||||
* An optional function which will be used to format any errors produced by
|
||||
* fulfilling a GraphQL operation. If no function is provided, GraphQL's
|
||||
* default spec-compliant `formatError` function will be used.
|
||||
*/
|
||||
formatError?: (error: GraphQLError) => any;
|
||||
formatError?: ((error: GraphQLError) => any) | null;
|
||||
|
||||
/**
|
||||
* An optional array of validation rules that will be applied on the document
|
||||
* in additional to those defined by the GraphQL spec.
|
||||
*/
|
||||
validationRules?: any[];
|
||||
validationRules?: any[] | null;
|
||||
|
||||
/**
|
||||
* An optional function for adding additional metadata to the GraphQL response
|
||||
@@ -65,12 +69,12 @@ declare namespace graphqlHTTP {
|
||||
*
|
||||
* This function may be async.
|
||||
*/
|
||||
extensions?: (info: RequestInfo) => { [key: string]: any };
|
||||
extensions?: ((info: RequestInfo) => { [key: string]: any }) | null;
|
||||
|
||||
/**
|
||||
* A boolean to optionally enable GraphiQL mode.
|
||||
*/
|
||||
graphiql?: boolean;
|
||||
graphiql?: boolean | null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -80,32 +84,32 @@ declare namespace graphqlHTTP {
|
||||
/**
|
||||
* The parsed GraphQL document.
|
||||
*/
|
||||
document?: DocumentNode;
|
||||
document: DocumentNode | null | undefined;
|
||||
|
||||
/**
|
||||
* The variable values used at runtime.
|
||||
*/
|
||||
variables?: { [name: string]: any };
|
||||
variables: { [name: string]: any } | null | undefined;
|
||||
|
||||
/**
|
||||
* The (optional) operation name requested.
|
||||
*/
|
||||
operationName?: string;
|
||||
operationName: string | null | undefined;
|
||||
|
||||
/**
|
||||
* The result of executing the operation.
|
||||
*/
|
||||
result?: any;
|
||||
result: any;
|
||||
}
|
||||
|
||||
export interface GraphQLParams {
|
||||
query?: string;
|
||||
variables?: { [name: string]: any };
|
||||
operationName?: string;
|
||||
raw?: boolean;
|
||||
query: string | null | undefined;
|
||||
variables: { [name: string]: any } | null | undefined;
|
||||
operationName: string | null | undefined;
|
||||
raw: boolean | null | undefined;
|
||||
}
|
||||
|
||||
type Middleware = (request: Request, response: Response) => void;
|
||||
type Middleware = (request: Request, response: Response) => Promise<undefined>;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Vendored
+5
@@ -1427,6 +1427,11 @@ export class Canvas {
|
||||
* @return active object
|
||||
*/
|
||||
getActiveObject(): Object;
|
||||
/**
|
||||
* Returns an array with the current selected objects
|
||||
* @return {Object[]} array of active objects
|
||||
*/
|
||||
getActiveObjects(): Object[];
|
||||
/**
|
||||
* Returns pointer coordinates relative to canvas.
|
||||
* @return object with "x" and "y" number values
|
||||
|
||||
Vendored
+1
@@ -4,6 +4,7 @@
|
||||
// Joseph Livecchi <https://github.com/joewashear007>
|
||||
// Michael Randolph <https://github.com/mrand01>
|
||||
// Tiger Oakes <https://github.com/NotWoods>
|
||||
// Brian Martinson <https://github.com/bmartinson>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.1
|
||||
export import fabric = require("./fabric-impl");
|
||||
|
||||
@@ -1032,3 +1032,32 @@ function sample9() {
|
||||
canvas.setBackgroundImage('yolo.jpg', () => { "a"; }, { opacity: 45 });
|
||||
canvas.setBackgroundImage('yolo.jpg', () => { "a"; });
|
||||
}
|
||||
|
||||
function sample10() {
|
||||
const canvas = new fabric.Canvas('c');
|
||||
const objR = new fabric.Rect({
|
||||
top: 10,
|
||||
left: 10,
|
||||
width: 10,
|
||||
height: 10,
|
||||
fill: "#FF0000",
|
||||
});
|
||||
const objG = new fabric.Rect({
|
||||
top: 15,
|
||||
left: 15,
|
||||
width: 10,
|
||||
height: 10,
|
||||
fill: "#00FF00",
|
||||
});
|
||||
const objB = new fabric.Rect({
|
||||
top: 20,
|
||||
left: 20,
|
||||
width: 10,
|
||||
height: 10,
|
||||
fill: "#0000FF",
|
||||
});
|
||||
canvas.add(objR);
|
||||
canvas.add(objG);
|
||||
canvas.add(objB);
|
||||
const objArray = canvas.getActiveObjects();
|
||||
}
|
||||
|
||||
@@ -1,41 +1,31 @@
|
||||
import getFieldNames = require("graphql-list-fields");
|
||||
|
||||
import {
|
||||
GraphQLID,
|
||||
GraphQLObjectType,
|
||||
GraphQLResolveInfo,
|
||||
GraphQLSchema,
|
||||
GraphQLString
|
||||
} from "graphql";
|
||||
import { GraphQLID, GraphQLObjectType, GraphQLSchema, GraphQLString } from "graphql";
|
||||
|
||||
const sampleGraphQLResolveInfo: GraphQLResolveInfo = {
|
||||
fieldName: "",
|
||||
fieldNodes: [],
|
||||
returnType: GraphQLString,
|
||||
parentType: new GraphQLObjectType({
|
||||
name: "Sample",
|
||||
const schema = new GraphQLSchema({
|
||||
query: new GraphQLObjectType({
|
||||
name: "SampleType",
|
||||
fields: {
|
||||
name: { type: GraphQLString }
|
||||
}
|
||||
scalarField: {
|
||||
type: GraphQLString,
|
||||
resolve(source, args, context, info) {
|
||||
const fieldNames: string[] = getFieldNames(info);
|
||||
},
|
||||
},
|
||||
someType: {
|
||||
type: new GraphQLObjectType({
|
||||
name: "SomeType",
|
||||
fields: {
|
||||
a: { type: GraphQLID },
|
||||
b: { type: GraphQLString },
|
||||
c: { type: GraphQLString },
|
||||
d: { type: GraphQLString },
|
||||
},
|
||||
}),
|
||||
resolve(source, args, context, info) {
|
||||
const fieldNames: string[] = getFieldNames(info);
|
||||
},
|
||||
},
|
||||
},
|
||||
}),
|
||||
path: undefined,
|
||||
schema: new GraphQLSchema({
|
||||
query: new GraphQLObjectType({
|
||||
name: "SampleType",
|
||||
fields: {}
|
||||
})
|
||||
}),
|
||||
fragments: {},
|
||||
rootValue: null,
|
||||
operation: {
|
||||
kind: "OperationDefinition",
|
||||
operation: "query",
|
||||
selectionSet: {
|
||||
kind: "SelectionSet",
|
||||
selections: []
|
||||
}
|
||||
},
|
||||
variableValues: {}
|
||||
};
|
||||
|
||||
const fieldNames: string[] = getFieldNames(sampleGraphQLResolveInfo);
|
||||
});
|
||||
|
||||
@@ -44,7 +44,7 @@ backwardConnectionArgs.before = "b";
|
||||
backwardConnectionArgs.last = 10;
|
||||
// connectionDefinitions returns a connectionType and its associated edgeType, given a node type.
|
||||
const resolve: GraphQLFieldResolver<any, any> = (source, args, context, info) => {
|
||||
info.fieldName = "f";
|
||||
context.flag = "f";
|
||||
};
|
||||
const fields: GraphQLFieldConfigMap<any, any> = {};
|
||||
let t: GraphQLObjectType;
|
||||
@@ -118,10 +118,10 @@ const resolver: GraphQLTypeResolver<any, any> = () => {
|
||||
fields: {},
|
||||
});
|
||||
};
|
||||
const idFetcher = (id: string, context: number, info: GraphQLResolveInfo) => {
|
||||
info.fieldName = "f";
|
||||
const idFetcher = (id: string, context: any, info: GraphQLResolveInfo) => {
|
||||
context.flag = "f";
|
||||
};
|
||||
const nodeDef = nodeDefinitions<number>(idFetcher, resolver);
|
||||
const nodeDef = nodeDefinitions<any>(idFetcher, resolver);
|
||||
const nodeFieldConfig: GraphQLFieldConfig<any, any> = nodeDef.nodeField;
|
||||
const nodesFieldConfig: GraphQLFieldConfig<any, any> = nodeDef.nodesField;
|
||||
const interfaceType: GraphQLInterfaceType = nodeDef.nodeInterface;
|
||||
@@ -183,10 +183,10 @@ mutationWithClientMutationId({
|
||||
inputFields: gifcm,
|
||||
mutateAndGetPayload: (
|
||||
object: any,
|
||||
ctx: any,
|
||||
context: any,
|
||||
info: GraphQLResolveInfo) => {
|
||||
return new Promise<string>((resolve) => {
|
||||
resolve(info.fieldName);
|
||||
resolve(context.flag);
|
||||
});
|
||||
},
|
||||
outputFields: gfcm,
|
||||
|
||||
@@ -337,6 +337,8 @@ fooStream.toCallback((err: Error) => {});
|
||||
// UTILS
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
bool = _.isNil(x);
|
||||
|
||||
bool = _.isStream(x);
|
||||
bool = _.isStream(fooStream);
|
||||
|
||||
|
||||
Vendored
+11
@@ -89,6 +89,17 @@ interface HighlandStatic {
|
||||
// UTILS
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
/**
|
||||
* Returns true if `x` is the end of stream marker.
|
||||
*
|
||||
* @id isNil
|
||||
* @section Streams
|
||||
* @name _.isNil(x)
|
||||
* @param x - the object to test
|
||||
* @api public
|
||||
*/
|
||||
isNil<R>(x: R | Highland.Nil): x is Highland.Nil;
|
||||
|
||||
/**
|
||||
* Returns true if `x` is a Highland Stream.
|
||||
*
|
||||
|
||||
Vendored
+2
@@ -4,6 +4,8 @@
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
export as namespace jsyaml;
|
||||
|
||||
export type DocumentLoadResult = object | undefined;
|
||||
|
||||
export function safeLoad(str: string, opts?: LoadOptions): DocumentLoadResult;
|
||||
|
||||
Vendored
+1
-1
@@ -166,7 +166,7 @@ declare namespace session {
|
||||
* ContextStore must be a class which claims three instance methods demonstrated above.
|
||||
* new ContextStore(ctx) will be executed on every request.
|
||||
*/
|
||||
ContextStore?: { new(): stores };
|
||||
ContextStore?: { new(ctx: Koa.Context): stores };
|
||||
|
||||
/**
|
||||
* If you want to add prefix for all external session id, you can use options.prefix, it will not work if options.genid present.
|
||||
|
||||
Vendored
+1
-1
@@ -610,7 +610,7 @@ declare namespace mapboxgl {
|
||||
|
||||
interface RasterSource extends Source {
|
||||
type: 'raster';
|
||||
url: string;
|
||||
url?: string;
|
||||
tiles?: string[];
|
||||
minzoom?: number;
|
||||
maxzoom?: number;
|
||||
|
||||
@@ -205,6 +205,22 @@ var videoSourceObj = new mapboxgl.VideoSource({
|
||||
map.addSource('some id', videoSourceObj); // add
|
||||
map.removeSource('some id'); // remove
|
||||
|
||||
/**
|
||||
* Add Raster Source /// made URL optional to allow only tiles.
|
||||
*/
|
||||
map.addSource('radar', {
|
||||
type: 'raster',
|
||||
tiles: ['https://nowcoast.noaa.gov/arcgis/services/nowcoast/radar_meteo_imagery_nexrad_time/MapServer/WmsServer?bbox={bbox-epsg-3857}&service=WMS&request=GetMap&version=1.3.0&layers=1&styles=&format=image/png&transparent=true&height=256&width=256&crs=EPSG:3857'],
|
||||
tileSize: 256
|
||||
})
|
||||
|
||||
map.addLayer({
|
||||
id: 'radar',
|
||||
type: 'raster',
|
||||
source: 'radar',
|
||||
paint: {}
|
||||
})
|
||||
|
||||
/**
|
||||
* Popup
|
||||
*/
|
||||
|
||||
Vendored
+254
@@ -1,6 +1,7 @@
|
||||
// Type definitions for Meteor Roles 1.2.14
|
||||
// Project: https://github.com/alanning/meteor-roles/
|
||||
// Definitions by: Robbie Van Gorkom <https://github.com/vangorra>
|
||||
// Matthew Zartman <https://github.com/mattmm3d>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="meteor" />
|
||||
@@ -262,3 +263,256 @@ declare namespace Roles {
|
||||
declare namespace Meteor {
|
||||
var roles : Mongo.Collection<Roles.Role>;
|
||||
}
|
||||
|
||||
|
||||
/* Declaring in the format prescribed by Meteor */
|
||||
declare module "meteor/alanning:roles" {
|
||||
namespace Roles {
|
||||
/**
|
||||
* Constant used to reference the special 'global' group that
|
||||
* can be used to apply blanket permissions across all groups.
|
||||
*
|
||||
* @example
|
||||
* Roles.addUsersToRoles(user, 'admin', Roles.GLOBAL_GROUP)
|
||||
* Roles.userIsInRole(user, 'admin') // => true
|
||||
*
|
||||
* Roles.setUserRoles(user, 'support-staff', Roles.GLOBAL_GROUP)
|
||||
* Roles.userIsInRole(user, 'support-staff') // => true
|
||||
* Roles.userIsInRole(user, 'admin') // => false
|
||||
*
|
||||
* @property GLOBAL_GROUP
|
||||
* @type String
|
||||
* @static
|
||||
* @final
|
||||
*/
|
||||
var GLOBAL_GROUP : string;
|
||||
|
||||
/**
|
||||
* Subscription handle for the currently logged in user's permissions.
|
||||
*
|
||||
* NOTE: The corresponding publish function, `_roles`, depends on
|
||||
* `this.userId` so it will automatically re-run when the currently
|
||||
* logged-in user changes.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* `Roles.subscription.ready()` // => `true` if user roles have been loaded
|
||||
*
|
||||
* @property subscription
|
||||
* @type Object
|
||||
* @for Roles
|
||||
*/
|
||||
var subscription : Subscription;
|
||||
|
||||
/**
|
||||
* Add users to roles. Will create roles as needed.
|
||||
*
|
||||
* NOTE: Mixing grouped and non-grouped roles for the same user
|
||||
* is not supported and will throw an error.
|
||||
*
|
||||
* Makes 2 calls to database:
|
||||
* 1. retrieve list of all existing roles
|
||||
* 2. update users' roles
|
||||
*
|
||||
* @example
|
||||
* Roles.addUsersToRoles(userId, 'admin')
|
||||
* Roles.addUsersToRoles(userId, ['view-secrets'], 'example.com')
|
||||
* Roles.addUsersToRoles([user1, user2], ['user','editor'])
|
||||
* Roles.addUsersToRoles([user1, user2], ['glorious-admin', 'perform-action'], 'example.org')
|
||||
* Roles.addUsersToRoles(userId, 'admin', Roles.GLOBAL_GROUP)
|
||||
*
|
||||
* @method addUsersToRoles
|
||||
* @param {Array|String} users User id(s) or object(s) with an _id field
|
||||
* @param {Array|String} roles Name(s) of roles/permissions to add users to
|
||||
* @param {String} [group] Optional group name. If supplied, roles will be
|
||||
* specific to that group.
|
||||
* Group names can not start with '$' or numbers.
|
||||
* Periods in names '.' are automatically converted
|
||||
* to underscores.
|
||||
* The special group Roles.GLOBAL_GROUP provides
|
||||
* a convenient way to assign blanket roles/permissions
|
||||
* across all groups. The roles/permissions in the
|
||||
* Roles.GLOBAL_GROUP group will be automatically
|
||||
* included in checks for any group.
|
||||
*/
|
||||
function addUsersToRoles(
|
||||
user : string|string[]|Object|Object[],
|
||||
roles : string|string[],
|
||||
group? : string
|
||||
) : void;
|
||||
|
||||
/**
|
||||
* Create a new role. Whitespace will be trimmed.
|
||||
*
|
||||
* @method createRole
|
||||
* @param {String} role Name of role
|
||||
* @return {String} id of new role
|
||||
*/
|
||||
function createRole(role : string) : string;
|
||||
|
||||
/**
|
||||
* Delete an existing role. Will throw "Role in use" error if any users
|
||||
* are currently assigned to the target role.
|
||||
*
|
||||
* @method deleteRole
|
||||
* @param {String} role Name of role
|
||||
*/
|
||||
function deleteRole (role : string) : void;
|
||||
|
||||
/**
|
||||
* Retrieve set of all existing roles
|
||||
*
|
||||
* @method getAllRoles
|
||||
* @return {Cursor} cursor of existing roles
|
||||
*/
|
||||
function getAllRoles() : Mongo.Cursor<Role>;
|
||||
|
||||
/**
|
||||
* Retrieve users groups, if any
|
||||
*
|
||||
* @method getGroupsForUser
|
||||
* @param {String|Object} user User Id or actual user object
|
||||
* @param {String} [role] Optional name of roles to restrict groups to.
|
||||
*
|
||||
* @return {Array} Array of user's groups, unsorted. Roles.GLOBAL_GROUP will be omitted
|
||||
*/
|
||||
function getGroupsForUser(
|
||||
user : string|Object,
|
||||
role? : string
|
||||
) : string[];
|
||||
|
||||
/**
|
||||
* Retrieve users roles
|
||||
*
|
||||
* @method getRolesForUser
|
||||
* @param {String|Object} user User Id or actual user object
|
||||
* @param {String} [group] Optional name of group to restrict roles to.
|
||||
* User's Roles.GLOBAL_GROUP will also be included.
|
||||
* @return {Array} Array of user's roles, unsorted.
|
||||
*/
|
||||
function getRolesForUser(
|
||||
user : string|Object,
|
||||
group? : string
|
||||
) : string[];
|
||||
|
||||
/**
|
||||
* Retrieve all users who are in target role.
|
||||
*
|
||||
* NOTE: This is an expensive query; it performs a full collection scan
|
||||
* on the users collection since there is no index set on the 'roles' field.
|
||||
* This is by design as most queries will specify an _id so the _id index is
|
||||
* used automatically.
|
||||
*
|
||||
* @method getUsersInRole
|
||||
* @param {Array|String} role Name of role/permission. If array, users
|
||||
* returned will have at least one of the roles
|
||||
* specified but need not have _all_ roles.
|
||||
* @param {String} [group] Optional name of group to restrict roles to.
|
||||
* User's Roles.GLOBAL_GROUP will also be checked.
|
||||
* @param {Object} [options] Optional options which are passed directly
|
||||
* through to `Meteor.users.find(query, options)`
|
||||
* @return {Cursor} cursor of users in role
|
||||
*/
|
||||
function getUsersInRole(
|
||||
role : string|string[],
|
||||
group? : string,
|
||||
options? : {
|
||||
sort?: Mongo.SortSpecifier;
|
||||
skip?: number;
|
||||
limit?: number;
|
||||
fields?: Mongo.FieldSpecifier;
|
||||
reactive?: boolean;
|
||||
transform?: Function;
|
||||
}) : Mongo.Cursor<Meteor.User>;
|
||||
|
||||
/**
|
||||
* Remove users from roles
|
||||
*
|
||||
* @example
|
||||
* Roles.removeUsersFromRoles(users.bob, 'admin')
|
||||
* Roles.removeUsersFromRoles([users.bob, users.joe], ['editor'])
|
||||
* Roles.removeUsersFromRoles([users.bob, users.joe], ['editor', 'user'])
|
||||
* Roles.removeUsersFromRoles(users.eve, ['user'], 'group1')
|
||||
*
|
||||
* @method removeUsersFromRoles
|
||||
* @param {Array|String} users User id(s) or object(s) with an _id field
|
||||
* @param {Array|String} roles Name(s) of roles to add users to
|
||||
* @param {String} [group] Optional. Group name. If supplied, only that
|
||||
* group will have roles removed.
|
||||
*/
|
||||
function removeUsersFromRoles(
|
||||
user : string|string[]|Object|Object[],
|
||||
roles? : string[],
|
||||
group? : string
|
||||
) : void;
|
||||
|
||||
/**
|
||||
* Set a users roles/permissions.
|
||||
*
|
||||
* @example
|
||||
* Roles.setUserRoles(userId, 'admin')
|
||||
* Roles.setUserRoles(userId, ['view-secrets'], 'example.com')
|
||||
* Roles.setUserRoles([user1, user2], ['user','editor'])
|
||||
* Roles.setUserRoles([user1, user2], ['glorious-admin', 'perform-action'], 'example.org')
|
||||
* Roles.setUserRoles(userId, 'admin', Roles.GLOBAL_GROUP)
|
||||
*
|
||||
* @method setUserRoles
|
||||
* @param {Array|String} users User id(s) or object(s) with an _id field
|
||||
* @param {Array|String} roles Name(s) of roles/permissions to add users to
|
||||
* @param {String} [group] Optional group name. If supplied, roles will be
|
||||
* specific to that group.
|
||||
* Group names can not start with '$'.
|
||||
* Periods in names '.' are automatically converted
|
||||
* to underscores.
|
||||
* The special group Roles.GLOBAL_GROUP provides
|
||||
* a convenient way to assign blanket roles/permissions
|
||||
* across all groups. The roles/permissions in the
|
||||
* Roles.GLOBAL_GROUP group will be automatically
|
||||
* included in checks for any group.
|
||||
*/
|
||||
function setUserRoles (
|
||||
user : string|string[]|Object|Object[],
|
||||
roles : string|string[],
|
||||
group? : string
|
||||
) : void;
|
||||
|
||||
/**
|
||||
* Check if user has specified permissions/roles
|
||||
*
|
||||
* @example
|
||||
* // non-group usage
|
||||
* Roles.userIsInRole(user, 'admin')
|
||||
* Roles.userIsInRole(user, ['admin','editor'])
|
||||
* Roles.userIsInRole(userId, 'admin')
|
||||
* Roles.userIsInRole(userId, ['admin','editor'])
|
||||
*
|
||||
* // per-group usage
|
||||
* Roles.userIsInRole(user, ['admin','editor'], 'group1')
|
||||
* Roles.userIsInRole(userId, ['admin','editor'], 'group1')
|
||||
* Roles.userIsInRole(userId, ['admin','editor'], Roles.GLOBAL_GROUP)
|
||||
*
|
||||
* // this format can also be used as short-hand for Roles.GLOBAL_GROUP
|
||||
* Roles.userIsInRole(user, 'admin')
|
||||
*
|
||||
* @method userIsInRole
|
||||
* @param {String|Object} user User Id or actual user object
|
||||
* @param {String|Array} roles Name of role/permission or Array of
|
||||
* roles/permissions to check against. If array,
|
||||
* will return true if user is in _any_ role.
|
||||
* @param {String} [group] Optional. Name of group. If supplied, limits check
|
||||
* to just that group.
|
||||
* The user's Roles.GLOBAL_GROUP will always be checked
|
||||
* whether group is specified or not.
|
||||
* @return {Boolean} true if user is in _any_ of the target roles
|
||||
*/
|
||||
function userIsInRole(
|
||||
user : string|string[]|Object|Object[],
|
||||
roles : string|string[],
|
||||
group? : string
|
||||
) : boolean;
|
||||
|
||||
interface Role {
|
||||
name : string;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -448,6 +448,6 @@ interface ModernizrAPI {
|
||||
interface ModernizrStatic extends ModernizrAPI, FeatureDetects { }
|
||||
|
||||
declare var Modernizr: ModernizrStatic;
|
||||
declare module "Modernizr" {
|
||||
declare module "modernizr" {
|
||||
export = Modernizr;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"no-single-declare-module": false,
|
||||
"no-empty-interface": false
|
||||
"no-empty-interface": false,
|
||||
"no-declare-current-package": false
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+38
@@ -0,0 +1,38 @@
|
||||
// Type definitions for named-regexp-groups 1.0
|
||||
// Project: https://github.com/commenthol/named-regexp-groups/
|
||||
// Definitions by: Vilim Stubičan <https://github.com/jewbre>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.4
|
||||
|
||||
interface NamedRegExpExecArray extends RegExpExecArray {
|
||||
groups: { [propName: string]: string };
|
||||
}
|
||||
|
||||
declare class NamedRegExp {
|
||||
constructor(pattern?: string | RegExp, flags?: string);
|
||||
|
||||
/**
|
||||
* Executes a search on a string using a regular expression pattern, and returns an array containing the results of that search.
|
||||
* @param string The String object or string literal on which to perform the search.
|
||||
*/
|
||||
exec(string: string): NamedRegExpExecArray | null;
|
||||
|
||||
/**
|
||||
* Returns a Boolean value that indicates whether or not a pattern exists in a searched string.
|
||||
* @param string String on which to perform the search.
|
||||
*/
|
||||
test(string: string): boolean;
|
||||
|
||||
// Non-standard extensions
|
||||
toString(): string;
|
||||
|
||||
[Symbol.replace](str: string, replacement: string | ((match: string, ...capturedGroups: string[]) => string)): string;
|
||||
|
||||
[Symbol.match](str: string): NamedRegExpExecArray;
|
||||
|
||||
[Symbol.split](str: string): string[];
|
||||
|
||||
[Symbol.search](str: string): number;
|
||||
}
|
||||
|
||||
export = NamedRegExp;
|
||||
@@ -0,0 +1,19 @@
|
||||
import NamedRegExp = require("named-regexp-groups");
|
||||
|
||||
// $ExpectType NamedRegExp
|
||||
new NamedRegExp('aaa', 'gi');
|
||||
|
||||
// $ExpectType NamedRegExp
|
||||
new NamedRegExp(/aaa/gi);
|
||||
|
||||
// $ExpectType NamedRegExp
|
||||
new NamedRegExp();
|
||||
|
||||
// $ExpectError
|
||||
new NamedRegExp(1);
|
||||
|
||||
// $ExpectError
|
||||
new NamedRegExp({});
|
||||
|
||||
// $ExpectError
|
||||
new NamedRegExp([]);
|
||||
@@ -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",
|
||||
"named-regexp-groups-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Vendored
+20
@@ -1082,6 +1082,7 @@ declare namespace naver.maps {
|
||||
}
|
||||
|
||||
// Sub module: drawing
|
||||
function drawing(): void;
|
||||
namespace drawing {
|
||||
interface DrawingOptions {
|
||||
map?: Map;
|
||||
@@ -1149,6 +1150,7 @@ declare namespace naver.maps {
|
||||
}
|
||||
|
||||
// Sub module: visualization
|
||||
function visualization(): void;
|
||||
namespace visualization {
|
||||
interface DotMapOptions {
|
||||
map: Map;
|
||||
@@ -1218,6 +1220,7 @@ declare namespace naver.maps {
|
||||
}
|
||||
|
||||
// Sub module: geocoder
|
||||
function Service(): void;
|
||||
namespace Service {
|
||||
interface ServiceOptions {
|
||||
encoding?: any;
|
||||
@@ -1274,6 +1277,7 @@ declare namespace naver.maps {
|
||||
callback?: (status: Status, response: ReverseGeocodeResponse) => void): void;
|
||||
}
|
||||
|
||||
function TransCoord(): void;
|
||||
namespace TransCoord {
|
||||
function fromEPSG3857ToLatLng(coord: Point): LatLng;
|
||||
function fromEPSG3857ToNaver(coord: Point): Point;
|
||||
@@ -1297,6 +1301,7 @@ declare namespace naver.maps {
|
||||
function fromUTMKToTM128(utmk: Point): Point;
|
||||
}
|
||||
|
||||
function Event(): void;
|
||||
namespace Event {
|
||||
function addDOMListener(element: HTMLElement, eventName: string, listener: () => any): void;
|
||||
function addListener(target: any, eventName: string, listener: () => any): MapEventListener;
|
||||
@@ -1314,6 +1319,7 @@ declare namespace naver.maps {
|
||||
}
|
||||
|
||||
// Projection
|
||||
function EPSG3857(): void;
|
||||
namespace EPSG3857 { // implements Projection
|
||||
function fromCoordToPoint(coord: Coord): Point;
|
||||
function fromLatLngToPoint(latlng: LatLng): Point;
|
||||
@@ -1322,6 +1328,8 @@ declare namespace naver.maps {
|
||||
function getDestinationCoord(fromLatLng: LatLng, angle: number, meter: number): LatLng;
|
||||
function getDistance(latlng1: LatLng, latlng2: LatLng): number;
|
||||
}
|
||||
|
||||
function UTMK(): void;
|
||||
namespace UTMK {
|
||||
let name: string;
|
||||
let pointPerMeter: number;
|
||||
@@ -1338,6 +1346,8 @@ declare namespace naver.maps {
|
||||
function getDestinationCoord(fromLatLng: LatLng, angle: number, meter: number): LatLng;
|
||||
function getDistance(latlng1: LatLng, latlng2: LatLng): number;
|
||||
}
|
||||
|
||||
function UTMK_NAVER(): void;
|
||||
namespace UTMK_NAVER { // extends UTMK
|
||||
let name: string;
|
||||
let pointPerMeter: number;
|
||||
@@ -1350,6 +1360,8 @@ declare namespace naver.maps {
|
||||
function fromPointToNaver(point: Point): Point;
|
||||
function fromUTMKToNaver(utmk: Point): Point;
|
||||
}
|
||||
|
||||
function EPSG3857Coord(): void;
|
||||
namespace EPSG3857Coord {
|
||||
function fromCoordToLatLng(coord: Point): LatLng;
|
||||
function fromCoordToPoint(coord: Point): Point;
|
||||
@@ -1360,10 +1372,14 @@ declare namespace naver.maps {
|
||||
function fromPointToCoord(point: Point): Point;
|
||||
function fromPointToEPSG3857(point: Point): Point;
|
||||
}
|
||||
|
||||
function TM128(): void;
|
||||
namespace TM128 { // extends TM128Coord
|
||||
function fromCoordToPoint(latlng: Coord): Point;
|
||||
function fromPointToCoord(point: Point): LatLng;
|
||||
}
|
||||
|
||||
function TM128Coord(): void;
|
||||
namespace TM128Coord { // extends UTMK
|
||||
function fromCoordToLatLng(tm128: Point): LatLng;
|
||||
function fromCoordToPoint(tm128: Point): Point;
|
||||
@@ -1376,12 +1392,16 @@ declare namespace naver.maps {
|
||||
function fromTM128ToUTMK(tm128: Point): Point;
|
||||
function fromUTMKToTM128(utmk: Point): Point;
|
||||
}
|
||||
|
||||
function UTMK_NAVERCoord(): void;
|
||||
namespace UTMK_NAVERCoord { // extends UTMK_NAVER
|
||||
function fromCoordToLatLng(n: Point): LatLng;
|
||||
function fromCoordToPoint(n: Point): Point;
|
||||
function fromLatLngToCoord(latlng: Coord): Point;
|
||||
function fromPointToCoord(point: Point): Point;
|
||||
}
|
||||
|
||||
function UTMKCoord(): void;
|
||||
namespace UTMKCoord { // extends UTMK
|
||||
function fromCoordToLatLng(utmk: Point): LatLng;
|
||||
function fromCoordToPoint(utmk: Point): Point;
|
||||
|
||||
Vendored
+21
-1
@@ -1,4 +1,4 @@
|
||||
// Type definitions for newrelic 2.7
|
||||
// Type definitions for newrelic 3.3
|
||||
// Project: http://github.com/newrelic/node-newrelic
|
||||
// Definitions by: Matt R. Wilson <https://github.com/mastermatt>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
@@ -147,6 +147,23 @@ declare namespace newrelic {
|
||||
*/
|
||||
getBrowserTimingHeader(): string;
|
||||
|
||||
/**
|
||||
* Instrument a particular method to improve visibility into a transaction,
|
||||
* or optionally turn it into a metric.
|
||||
*
|
||||
* The name defines a name for the segment. This name will be visible in transaction traces and
|
||||
* as a new metric in the New Relic UI.
|
||||
* The record flag defines whether the segment should be recorded as a metric.
|
||||
* The handler is the function you want to track as a segment.
|
||||
* The optional callback is a function passed to the handler to fire after its work is done.
|
||||
*
|
||||
* The agent begins timing the segment when startSegment is called.
|
||||
* The segment is ended when either the handler finishes executing, or callback is fired, if it is provided.
|
||||
* If a promise is returned from the handler, the segment's ending will be tied to that promise resolving or rejecting.
|
||||
*/
|
||||
startSegment<T extends PromiseLike<any>>(name: string, record: boolean, handler: T): T;
|
||||
startSegment<T, C extends (...args: any[]) => any>(name: string, record: boolean, handler: (cb?: C) => T, callback?: C): T;
|
||||
|
||||
/**
|
||||
* Instrument a particular callback to improve visibility into a transaction.
|
||||
*
|
||||
@@ -157,6 +174,9 @@ declare namespace newrelic {
|
||||
*
|
||||
* The agent begins timing the segment when createTracer is called, and ends the segment when the callback
|
||||
* defined by the callback argument finishes executing.
|
||||
*
|
||||
* @deprecated
|
||||
* This method has been deprecated in favor of newrelic.startSegment()
|
||||
*/
|
||||
createTracer<T extends (...args: any[]) => any>(name: string, handle: T): T;
|
||||
|
||||
|
||||
@@ -29,6 +29,12 @@ newrelic.addIgnoringRule(/^[0-9]+$/); // $ExpectType void
|
||||
|
||||
newrelic.getBrowserTimingHeader(); // $ExpectType string
|
||||
|
||||
newrelic.startSegment('foo', false, () => "bar"); // $ExpectType string
|
||||
newrelic.startSegment('foo', false, () => "bar", () => "baz"); // $ExpectType string
|
||||
newrelic.startSegment('foo', false, Promise.all([5, 7])).then(([a, b]: [number, number]) => {
|
||||
console.log(a, b);
|
||||
});
|
||||
|
||||
const wrappedFn = newrelic.createTracer("foo", (x: number) => {
|
||||
return x * x;
|
||||
});
|
||||
|
||||
Vendored
+3
@@ -2361,6 +2361,9 @@ declare module "url" {
|
||||
export function format(urlObject: UrlObject | string): string;
|
||||
export function resolve(from: string, to: string): string;
|
||||
|
||||
export function domainToASCII(domain: string): string;
|
||||
export function domainToUnicode(domain: string): string;
|
||||
|
||||
export interface URLFormatOptions {
|
||||
auth?: boolean;
|
||||
fragment?: boolean;
|
||||
|
||||
@@ -635,6 +635,11 @@ namespace url_tests {
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
const ascii: string = url.domainToASCII('español.com');
|
||||
const unicode: string = url.domainToUnicode('xn--espaol-zwa.com');
|
||||
}
|
||||
|
||||
{
|
||||
let myURL = new url.URL('https://theuser:thepwd@example.org:81/foo/path?query=string#bar');
|
||||
assert.equal(myURL.hash, '#bar');
|
||||
|
||||
Vendored
+3
@@ -2024,6 +2024,9 @@ declare module "url" {
|
||||
export function format(urlObject: UrlObject | string): string;
|
||||
export function resolve(from: string, to: string): string;
|
||||
|
||||
export function domainToASCII(domain: string): string;
|
||||
export function domainToUnicode(domain: string): string;
|
||||
|
||||
export interface URLFormatOptions {
|
||||
auth?: boolean;
|
||||
fragment?: boolean;
|
||||
|
||||
@@ -475,6 +475,11 @@ namespace url_tests {
|
||||
assert.equal(helloUrl.query.hello, 'world');
|
||||
}
|
||||
|
||||
{
|
||||
const ascii: string = url.domainToASCII('español.com');
|
||||
const unicode: string = url.domainToUnicode('xn--espaol-zwa.com');
|
||||
}
|
||||
|
||||
{
|
||||
let myURL = new url.URL('https://theuser:thepwd@example.org:81/foo/path?query=string#bar');
|
||||
assert.equal(myURL.hash, '#bar');
|
||||
|
||||
Vendored
+3
@@ -2350,6 +2350,9 @@ declare module "url" {
|
||||
export function format(urlObject: UrlObject | string): string;
|
||||
export function resolve(from: string, to: string): string;
|
||||
|
||||
export function domainToASCII(domain: string): string;
|
||||
export function domainToUnicode(domain: string): string;
|
||||
|
||||
export interface URLFormatOptions {
|
||||
auth?: boolean;
|
||||
fragment?: boolean;
|
||||
|
||||
@@ -609,6 +609,11 @@ namespace url_tests {
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
const ascii: string = url.domainToASCII('español.com');
|
||||
const unicode: string = url.domainToUnicode('xn--espaol-zwa.com');
|
||||
}
|
||||
|
||||
{
|
||||
let myURL = new url.URL('https://theuser:thepwd@example.org:81/foo/path?query=string#bar');
|
||||
assert.equal(myURL.hash, '#bar');
|
||||
|
||||
Vendored
+1
-1
@@ -14,7 +14,7 @@ export class CheckoutOptions {
|
||||
notifyPayload?: undefined;
|
||||
progressCb?: any;
|
||||
progressPayload?: undefined;
|
||||
paths?: Strarray;
|
||||
paths?: Strarray | string | string[];
|
||||
baseline?: Tree;
|
||||
baselineIndex?: Index;
|
||||
targetDirectory?: string;
|
||||
|
||||
Vendored
+1
-1
@@ -4,7 +4,7 @@ export interface DiffOptions {
|
||||
version?: number;
|
||||
flags?: number;
|
||||
ignoreSubmodules?: number;
|
||||
pathspec?: Strarray;
|
||||
pathspec?: Strarray | string | string[];
|
||||
notifyCb?: Function;
|
||||
contextLines?: number;
|
||||
interhunkLines?: number;
|
||||
|
||||
Vendored
+1
-1
@@ -7,7 +7,7 @@ export interface FetchOptions {
|
||||
prune?: number;
|
||||
updateFetchhead?: number;
|
||||
downloadTags?: number;
|
||||
customHeaders?: Strarray;
|
||||
customHeaders?: Strarray | string | string[];
|
||||
proxyOpts?: any;
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
Vendored
+3
-3
@@ -26,7 +26,7 @@ export class Index {
|
||||
static open(indexPath: string): Promise<Index>;
|
||||
|
||||
add(sourceEntry: IndexEntry): number;
|
||||
addAll(pathspec: Strarray, flags: number, callback?: Function): Promise<number>;
|
||||
addAll(pathspec: Strarray | string | string[], flags: number, callback?: Function): Promise<number>;
|
||||
addByPath(path: string): Promise<number>;
|
||||
caps(): number;
|
||||
checksum(): Oid;
|
||||
@@ -44,11 +44,11 @@ export class Index {
|
||||
read(force: number): number;
|
||||
readTree(tree: Tree): number;
|
||||
remove(path: string, stage: number): number;
|
||||
removeAll(pathspec: Strarray, callback?: Function): Promise<number>;
|
||||
removeAll(pathspec: Strarray | string | string[], callback?: Function): Promise<number>;
|
||||
removeByPath(path: string): Promise<number>;
|
||||
removeDirectory(dir: string, stage: number): number;
|
||||
setCaps(caps: number): number;
|
||||
updateAll(pathspec: Strarray, callback?: Function): Promise<number>;
|
||||
updateAll(pathspec: Strarray | string | string[], callback?: Function): Promise<number>;
|
||||
write(): number;
|
||||
writeTree(): Promise<Oid>;
|
||||
writeTreeTo(repo: Repository): Promise<Oid>;
|
||||
|
||||
Vendored
+1
-1
@@ -23,7 +23,7 @@ export class Pathspec {
|
||||
static matchListEntrycount(m: any): number;
|
||||
static matchListFailedEntry(m: any, pos: number): string;
|
||||
static matchListFailedEntrycount(m: any): number;
|
||||
static create(pathspec: Strarray): Pathspec;
|
||||
static create(pathspec: Strarray | string | string[]): Pathspec;
|
||||
|
||||
free(): void;
|
||||
matchDiff(diff: Diff, flags: number): Promise<any>;
|
||||
|
||||
Vendored
+1
-1
@@ -6,7 +6,7 @@ export interface PushOptions {
|
||||
version?: number;
|
||||
pbParallelism?: number;
|
||||
callbacks?: RemoteCallbacks;
|
||||
customHeaders?: Strarray;
|
||||
customHeaders?: Strarray | string | string[];
|
||||
proxyOpts?: ProxyOptions;
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -62,7 +62,7 @@ export class Remote {
|
||||
|
||||
stop(): void;
|
||||
updateTips(callbacks: RemoteCallbacks, updateFetchhead: number, downloadTags: number, reflogMessage: string): number;
|
||||
upload(refspecs: Strarray, opts?: PushOptions): number;
|
||||
upload(refspecs: Strarray | string | string[], opts?: PushOptions): number;
|
||||
url(): string;
|
||||
/**
|
||||
* Lists advertised references from a remote. You must connect to the remote before using referenceList.
|
||||
|
||||
Vendored
+1
-1
@@ -20,7 +20,7 @@ export class Reset {
|
||||
/**
|
||||
* Look up a refs's commit.
|
||||
*/
|
||||
static default(repo: Repository, target: Object, pathspecs: Strarray): Promise<number>;
|
||||
static default(repo: Repository, target: Object, pathspecs: Strarray | string | string[]): Promise<number>;
|
||||
/**
|
||||
* Sets the current head to the specified commit oid and optionally resets the index and working tree to match.
|
||||
* This behaves like reset but takes an annotated commit, which lets you specify which extended sha syntax string was specified by a user, allowing for more exact reflog messages.
|
||||
|
||||
Vendored
+1
-1
@@ -4,6 +4,6 @@ export interface StatusOptions {
|
||||
version?: number;
|
||||
show?: number;
|
||||
flags?: number;
|
||||
pathspec?: Strarray;
|
||||
pathspec?: Strarray | string | string[];
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -10,7 +10,7 @@ export class Tag {
|
||||
static createLightweight(repo: Repository, tagName: string, target: Object, force: number): Promise<Oid>;
|
||||
static delete(repo: Repository, tagName: string): Promise<number>;
|
||||
static list(repo: Repository): Promise<any[]>;
|
||||
static listMatch(tagNames: Strarray, pattern: string, repo: Repository): number;
|
||||
static listMatch(tagNames: Strarray | string | string[], pattern: string, repo: Repository): number;
|
||||
/**
|
||||
* Retrieves the tag pointed to by the oid
|
||||
*
|
||||
|
||||
Vendored
+1
-1
@@ -9,7 +9,7 @@ export namespace Transport {
|
||||
}
|
||||
|
||||
export class Transport {
|
||||
static sshWithPaths(owner: Remote, payload: Strarray): Promise<Transport>;
|
||||
static sshWithPaths(owner: Remote, payload: Strarray | string | string[]): Promise<Transport>;
|
||||
static unregister(prefix: string): number;
|
||||
init(version: number): number;
|
||||
smartCertificateCheck(cert: Cert, valid: number, hostName: string): number;
|
||||
|
||||
Vendored
+1830
-1671
File diff suppressed because it is too large
Load Diff
+775
-696
File diff suppressed because it is too large
Load Diff
@@ -8,7 +8,7 @@
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": false,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
@@ -21,4 +21,4 @@
|
||||
"index.d.ts",
|
||||
"openfin-tests.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"max-line-length": false
|
||||
}
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
|
||||
Vendored
+1732
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,721 @@
|
||||
function test_application() {
|
||||
let application: fin.OpenFinApplication;
|
||||
// constructor
|
||||
application = new fin.desktop.Application({
|
||||
url: "application.html",
|
||||
uuid: "74BED629-2D8E-4141-8582-73E364BDFA74",
|
||||
name: "Application Name",
|
||||
plugins: false,
|
||||
mainWindowOptions: {
|
||||
defaultHeight: 600,
|
||||
defaultWidth: 800,
|
||||
defaultTop: 300,
|
||||
defaultLeft: 300,
|
||||
autoShow: true
|
||||
}
|
||||
}, (successObj) => {
|
||||
console.log("Application successfully created, HTTP response code:", successObj);
|
||||
application.run();
|
||||
}, (error) => {
|
||||
console.log("Error creating application:", error);
|
||||
});
|
||||
// getCurrent
|
||||
application = fin.desktop.Application.getCurrent();
|
||||
// wrap
|
||||
application = fin.desktop.Application.wrap("454C7F31-A915-4EA2-83F2-CFA655453C52");
|
||||
// getWindow
|
||||
application.getWindow();
|
||||
// addEventListener
|
||||
application.addEventListener("closed", (event) => {
|
||||
console.log("The application has closed");
|
||||
}, () => {
|
||||
console.log("The registration was successful");
|
||||
}, reason => {
|
||||
console.log("failure: " + reason);
|
||||
});
|
||||
// close
|
||||
application.close();
|
||||
// getChildWindows
|
||||
application.getChildWindows(children => {
|
||||
children.forEach(childWindow => {
|
||||
console.log("Showing child: " + childWindow.name);
|
||||
childWindow.show();
|
||||
});
|
||||
});
|
||||
// getGroups
|
||||
application.getGroups(allGroups => {
|
||||
console.log(`There are a total of ${allGroups.length} groups.`);
|
||||
|
||||
let groupCounter = 1;
|
||||
allGroups.forEach(windowGroup => {
|
||||
console.log(`Group ${groupCounter} contains ${windowGroup.length} windows.`);
|
||||
++groupCounter;
|
||||
});
|
||||
});
|
||||
// getManifest
|
||||
application.getManifest(manifest => {
|
||||
console.log("Application manifest:");
|
||||
console.log(manifest);
|
||||
});
|
||||
// getParentUuid
|
||||
application.getParentUuid(parentUuid => {
|
||||
console.log("UUID of parent application:");
|
||||
console.log(parentUuid);
|
||||
});
|
||||
// getShortcuts
|
||||
application.getShortcuts(config => {
|
||||
console.log("Desktop shortcut is enabled: ", config.desktop);
|
||||
console.log("Start Menu shortcut is enabled: ", config.startMenu);
|
||||
console.log("System Startup shortcut is enabled: ", config.systemStartup);
|
||||
});
|
||||
// getInfo
|
||||
application.getInfo(info => {
|
||||
console.log(`Launch mode: ${info.launchMode}`);
|
||||
});
|
||||
// isRunning
|
||||
application.isRunning(running => {
|
||||
console.log("the application is", running ? "running" : "not running");
|
||||
});
|
||||
// registerCustomData
|
||||
application.registerCustomData({
|
||||
someData: "this is custom"
|
||||
}, () => {
|
||||
console.log("You will not read this.");
|
||||
}, err => {
|
||||
console.log("failure:", err);
|
||||
});
|
||||
// removeEventListener
|
||||
const previousCallback = (event: fin.WindowEvent) => { };
|
||||
application.removeEventListener("closed", previousCallback, () => {
|
||||
console.log("The unregistration was successful");
|
||||
}, err => {
|
||||
console.log("failure:", err);
|
||||
});
|
||||
// removeTrayIcon
|
||||
application.removeTrayIcon(() => {
|
||||
console.log("Removed the tray icon.");
|
||||
}, err => {
|
||||
console.log("failure:", err);
|
||||
});
|
||||
// restart
|
||||
application.restart(() => {
|
||||
console.log("You will not read this.");
|
||||
}, err => {
|
||||
console.log("failure:", err);
|
||||
});
|
||||
// schedule restart
|
||||
application.scheduleRestart(() => {
|
||||
console.log("You will not read this.");
|
||||
}, err => {
|
||||
console.log("failure:", err);
|
||||
});
|
||||
// setShortcuts
|
||||
application.setShortcuts({
|
||||
desktop: true,
|
||||
startMenu: false,
|
||||
systemStartup: true
|
||||
}, () => {
|
||||
console.log("Successfully set new shortcut states");
|
||||
}, error => {
|
||||
console.log("Failed to set new shortcut states. Error: ", error);
|
||||
});
|
||||
// setTrayIcon
|
||||
application.setTrayIcon("https://developer.openf.in/download/openfin.png", clickInfo => {
|
||||
console.log(`The mouse has clicked at (${clickInfo.x}, ${clickInfo.y})`);
|
||||
});
|
||||
// terminate
|
||||
application.terminate();
|
||||
// wait
|
||||
application.addEventListener("not-responding", () => {
|
||||
console.log("waiting for hung application");
|
||||
application.wait();
|
||||
});
|
||||
}
|
||||
|
||||
function test_external_application() {
|
||||
let externalApp: fin.OpenFinExternalApplication;
|
||||
// wrap
|
||||
externalApp = fin.desktop.ExternalApp.wrap('my-uuid');
|
||||
// addEventListener
|
||||
externalApp.addEventListener('connected', () => {
|
||||
console.log('external app connected');
|
||||
}, () => {
|
||||
console.log('The registration was successful');
|
||||
}, (reason, err) => {
|
||||
console.log(`Error Message: ${err.message} Error Stack: ${err.stack}`);
|
||||
});
|
||||
// removeEventListener
|
||||
const previousCallback = () => { };
|
||||
externalApp.removeEventListener('connected', previousCallback, () => {
|
||||
console.log('The unregistration was successful');
|
||||
}, (reason, err) => {
|
||||
console.log(`Error Message: ${err.message} Error Stack: ${err.stack}`);
|
||||
});
|
||||
}
|
||||
|
||||
function test_inter_application_bus() {
|
||||
// addSubscribeListener
|
||||
fin.desktop.InterApplicationBus.addSubscribeListener((uuid, topic, name) => {
|
||||
console.log(`The application ${uuid} has subscribed to ${topic}`);
|
||||
});
|
||||
// addUnsubscribeListener
|
||||
fin.desktop.InterApplicationBus.addUnsubscribeListener((uuid, topic, name) => {
|
||||
console.log(`The application ${uuid} has unsubscribed to ${topic}`);
|
||||
});
|
||||
// removeSubscribeListener
|
||||
const aRegisteredListener = (uuid: string, topic: string, name: string) => { };
|
||||
fin.desktop.InterApplicationBus.removeSubscribeListener(aRegisteredListener);
|
||||
// removeUnsubscribeListener
|
||||
fin.desktop.InterApplicationBus.removeUnsubscribeListener(aRegisteredListener);
|
||||
// publish
|
||||
fin.desktop.InterApplicationBus.publish("a topic", {
|
||||
field1: "value1",
|
||||
field2: "value2"
|
||||
});
|
||||
// send
|
||||
fin.desktop.InterApplicationBus.send("an application's uuid", "a topic", {
|
||||
field1: "value1",
|
||||
field2: "value2"
|
||||
});
|
||||
// subscribe
|
||||
fin.desktop.InterApplicationBus.subscribe("*", "a topic", (message, uuid, name) => {
|
||||
console.log(`The application ${uuid} sent this message: ${message}`);
|
||||
});
|
||||
// unsubscribe
|
||||
const aRegisteredMessageListener = (message: any, senderUuid: string) => {
|
||||
console.log(message, senderUuid);
|
||||
};
|
||||
fin.desktop.InterApplicationBus.unsubscribe("*", "a topic", aRegisteredMessageListener);
|
||||
}
|
||||
|
||||
function test_notification() {
|
||||
let notification: fin.OpenFinNotification;
|
||||
// getCurrent
|
||||
notification = fin.desktop.Notification.getCurrent();
|
||||
// close
|
||||
notification.close();
|
||||
// sendMessage
|
||||
notification = new fin.desktop.Notification({
|
||||
duration: 10,
|
||||
url: "http://localhost:5000/Account/Register",
|
||||
message: "Hello",
|
||||
onShow: () => { },
|
||||
// onClose: () => { },
|
||||
onDismiss: () => { },
|
||||
// onClick: () => { },
|
||||
onMessage: () => { },
|
||||
onError: () => { }
|
||||
});
|
||||
// sendMessageToApplication
|
||||
notification.sendMessageToApplication("some message");
|
||||
}
|
||||
|
||||
function test_system() {
|
||||
// addEventListener
|
||||
fin.desktop.System.addEventListener('monitor-info-changed', event => {
|
||||
console.log("The monitor information has changed to: ", event);
|
||||
}, () => {
|
||||
console.log("The registration was successful");
|
||||
}, err => {
|
||||
console.log("failure: " + err);
|
||||
});
|
||||
// clearCache
|
||||
fin.desktop.System.clearCache({
|
||||
cache: true,
|
||||
cookies: true,
|
||||
localStorage: true,
|
||||
appcache: true,
|
||||
userData: true
|
||||
});
|
||||
// deleteCacheOnExit
|
||||
fin.desktop.System.deleteCacheOnExit(() => {
|
||||
console.log("successful");
|
||||
}, err => {
|
||||
console.log("failure: " + err);
|
||||
});
|
||||
// downloadAsset
|
||||
const dirAppAsset = {
|
||||
src: 'http://local:8000/dir.zip',
|
||||
alias: 'dirApp',
|
||||
version: '1.23.24',
|
||||
target: 'dir.bat',
|
||||
args: ''
|
||||
};
|
||||
fin.desktop.System.downloadAsset(dirAppAsset, progress => {
|
||||
const downloadedPercent = Math.floor((progress.downloadedBytes / progress.totalBytes) * 100);
|
||||
console.log(`Downloaded ${downloadedPercent}%`);
|
||||
}, p => {
|
||||
console.log(`Downlod complete, can be found on ${p.path}`);
|
||||
// lets launch our application asset.
|
||||
// launchDirApp();
|
||||
}, (reason, err) => {
|
||||
console.log(reason, err);
|
||||
});
|
||||
// exit
|
||||
fin.desktop.System.exit(() => {
|
||||
console.log("successful");
|
||||
}, err => {
|
||||
console.log("failure: " + err);
|
||||
});
|
||||
// getAllApplications
|
||||
fin.desktop.System.getAllApplications(applicationInfoList => {
|
||||
applicationInfoList.forEach(applicationInfo => {
|
||||
console.log("Showing information for application with uuid: "
|
||||
+ applicationInfo.uuid);
|
||||
console.log("isRunning: ", applicationInfo.isRunning);
|
||||
});
|
||||
});
|
||||
// getAllExternalApplications
|
||||
fin.desktop.System.getAllExternalApplications(externalAppsInfoList => {
|
||||
externalAppsInfoList.forEach(appInfo => {
|
||||
console.log(`External app connected to the runtime with UUID ${appInfo.uuid}`);
|
||||
});
|
||||
});
|
||||
// getAllWindows
|
||||
fin.desktop.System.getAllWindows(windowInfoList => {
|
||||
windowInfoList.forEach(windowInfo => {
|
||||
console.log("Showing information for application with uuid: ", windowInfo.uuid);
|
||||
console.log("Main window: ", windowInfo.mainWindow);
|
||||
console.log("Child windows: ", windowInfo.childWindows);
|
||||
});
|
||||
});
|
||||
// getCommandLineArguments
|
||||
fin.desktop.System.getCommandLineArguments(args => {
|
||||
console.log("The command line arguments are " + args);
|
||||
});
|
||||
// getDeviceId
|
||||
fin.desktop.System.getDeviceId(id => {
|
||||
console.log("The id of the device is: " + id);
|
||||
});
|
||||
// getEnvironmentVariable
|
||||
fin.desktop.System.getEnvironmentVariable("APPDATA", variable => {
|
||||
console.log("this is the APPDATA value", variable);
|
||||
});
|
||||
// getHostSpecs
|
||||
fin.desktop.System.getHostSpecs(info => {
|
||||
console.log(info);
|
||||
}, error => {
|
||||
console.log('There was an error:', error);
|
||||
});
|
||||
// getLog
|
||||
fin.desktop.System.getLog('debug-2015-01-08-22-27-53.log', log => {
|
||||
console.log(log);
|
||||
});
|
||||
// getLogList
|
||||
fin.desktop.System.getLogList(logList => {
|
||||
logList.forEach(logInfo => {
|
||||
console.log(`The filename of the log is ${logInfo.name}, the size is ${logInfo.size}, and the date of creation is ${logInfo.date}`);
|
||||
});
|
||||
});
|
||||
// getMonitorInfo
|
||||
fin.desktop.System.getMonitorInfo(monitorInfo => {
|
||||
console.log("This object contains information about all monitors: ", monitorInfo);
|
||||
});
|
||||
// getMousePosition
|
||||
fin.desktop.System.getMousePosition(mousePosition => {
|
||||
console.log(`The mouse is located at left: ${mousePosition.left}, top: ${mousePosition.top}`);
|
||||
});
|
||||
// getProcessList
|
||||
fin.desktop.System.getProcessList(list => {
|
||||
list.forEach(process => {
|
||||
console.log(`UUID: ${process.uuid}, Application Name: ${process.name}`);
|
||||
});
|
||||
});
|
||||
// getProxySettings
|
||||
fin.desktop.System.getProxySettings(proxy => {
|
||||
console.log(proxy);
|
||||
});
|
||||
// getRvmInfo
|
||||
fin.desktop.System.getRvmInfo(rvmInfoObject => {
|
||||
console.log("RVM version:", rvmInfoObject.version);
|
||||
console.log("RVM has been running since:", rvmInfoObject["start-time"]);
|
||||
}, err => {
|
||||
console.log("Failed to get rvm info, error message:", err);
|
||||
});
|
||||
// getVersion
|
||||
fin.desktop.System.getVersion(version => {
|
||||
console.log("The version is " + version);
|
||||
});
|
||||
// launchExternalProcess
|
||||
fin.desktop.System.launchExternalProcess({
|
||||
path: "notepad",
|
||||
arguments: "",
|
||||
listener(result) {
|
||||
console.log('the exit code', result.exitCode);
|
||||
}
|
||||
}, payload => {
|
||||
console.log('Success:', payload.uuid);
|
||||
}, error => {
|
||||
console.log('Error:', error);
|
||||
});
|
||||
//
|
||||
fin.desktop.System.launchExternalProcess({
|
||||
// Additionally note that the executable found in the zip file specified in appAssets
|
||||
// will default to the one mentioned by appAssets.target
|
||||
// If the the path below refers to a specific path it will override this default
|
||||
alias: "myApp",
|
||||
listener(result) {
|
||||
console.log('the exit code', result.exitCode);
|
||||
}
|
||||
}, payload => {
|
||||
console.log('Success:', payload.uuid);
|
||||
}, error => {
|
||||
console.log('Error:', error);
|
||||
});
|
||||
//
|
||||
fin.desktop.System.launchExternalProcess({
|
||||
alias: "myApp",
|
||||
arguments: "e f g",
|
||||
listener(result) {
|
||||
console.log('the exit code', result.exitCode);
|
||||
}
|
||||
}, payload => {
|
||||
console.log('Success:', payload.uuid);
|
||||
}, error => {
|
||||
console.log('Error:', error);
|
||||
});
|
||||
//
|
||||
fin.desktop.System.launchExternalProcess({
|
||||
path: "C:\Users\ExampleUser\AppData\Local\OpenFin\OpenFinRVM.exe",
|
||||
arguments: "--version",
|
||||
certificate: {
|
||||
trusted: true,
|
||||
subject: 'O=OpenFin INC., L=New York, S=NY, C=US',
|
||||
thumbprint: '3c a5 28 19 83 05 fe 69 88 e6 8f 4b 3a af c5 c5 1b 07 80 5b'
|
||||
},
|
||||
listener(result) {
|
||||
console.log('the exit code', result.exitCode);
|
||||
}
|
||||
}, payload => {
|
||||
console.log('Success:', payload.uuid);
|
||||
}, error => {
|
||||
console.log('Error:', error);
|
||||
});
|
||||
// log
|
||||
fin.desktop.System.log("info", "An example log message", () => {
|
||||
console.log("message successfully logged");
|
||||
}, err => {
|
||||
console.log(err);
|
||||
});
|
||||
// monitorExternalProcess
|
||||
fin.desktop.System.monitorExternalProcess({
|
||||
pid: 2508,
|
||||
listener(result) {
|
||||
console.log('the exit code', result.exitCode);
|
||||
}
|
||||
}, payload => {
|
||||
console.log("The process is now being monitored: ", payload.uuid);
|
||||
}, error => {
|
||||
console.log("Error:", error);
|
||||
});
|
||||
// openUrlWithBrowser
|
||||
fin.desktop.System.openUrlWithBrowser("https://developer.openf.in/", () => {
|
||||
console.log("successful");
|
||||
}, err => {
|
||||
console.log("failure: " + err);
|
||||
});
|
||||
// registerExternalConnection
|
||||
fin.desktop.System.registerExternalConnection("remote-connection-uuid", (...args: any[]) => {
|
||||
console.log(args);
|
||||
});
|
||||
// releaseExternalProcess
|
||||
fin.desktop.System.launchExternalProcess({
|
||||
path: "notepad",
|
||||
arguments: "",
|
||||
listener(result) {
|
||||
console.log("The exit code", result.exitCode);
|
||||
}
|
||||
}, result => {
|
||||
console.log("Result UUID is " + result.uuid);
|
||||
|
||||
// release it.
|
||||
fin.desktop.System.releaseExternalProcess(result.uuid, () => {
|
||||
console.log("Process has been unmapped!");
|
||||
}, reason => {
|
||||
console.log("failure: " + reason);
|
||||
});
|
||||
});
|
||||
// removeEventListener
|
||||
const aRegisteredListener = (event: fin.SystemBaseEvent) => { };
|
||||
fin.desktop.System.removeEventListener("monitor-info-changed", aRegisteredListener, () => {
|
||||
console.log("successful");
|
||||
}, err => {
|
||||
console.log("failure: " + err);
|
||||
});
|
||||
// showDeveloperTools
|
||||
fin.desktop.System.showDeveloperTools("uuid", "name", () => {
|
||||
console.log("successful");
|
||||
}, err => {
|
||||
console.log("failure: " + err);
|
||||
});
|
||||
// terminateExternalProcess
|
||||
fin.desktop.System.launchExternalProcess({
|
||||
// notepad is in the system's PATH
|
||||
path: "notepad",
|
||||
arguments: "",
|
||||
listener(result) {
|
||||
console.log("The exit code", result.exitCode);
|
||||
}
|
||||
}, result => {
|
||||
console.log("Result UUID is " + result.uuid);
|
||||
|
||||
// Attempt to close the process. Terminate after 4 seconds if it
|
||||
// has not done so.
|
||||
fin.desktop.System.terminateExternalProcess(result.uuid, 4000, info => {
|
||||
console.log("Termination result " + info.result);
|
||||
}, reason => {
|
||||
console.log("failure: " + reason);
|
||||
});
|
||||
});
|
||||
// updateProxySettings
|
||||
fin.desktop.System.updateProxySettings("type", "proxyAddress", 8080, () => {
|
||||
console.log('success');
|
||||
}, err => {
|
||||
console.log(err);
|
||||
});
|
||||
}
|
||||
|
||||
function test_system_clipboard() {
|
||||
// availableFormats
|
||||
fin.desktop.System.Clipboard.availableFormats(null, formats => {
|
||||
formats.forEach(format => console.log(`The format ${format} is available to read`));
|
||||
}, (reason, err) => {
|
||||
console.log(`Error while reading the clipboard Message: ${err.message}, Stack: ${err.stack}`);
|
||||
});
|
||||
// readHtml
|
||||
fin.desktop.System.Clipboard.readHtml(null, html => {
|
||||
console.log(`This is the html from the clipboard: ${html}`);
|
||||
}, (reason, err) => {
|
||||
console.log(`Error while reading the clipboard Message: ${err.message}, Stack: ${err.stack}`);
|
||||
});
|
||||
// readRtf
|
||||
fin.desktop.System.Clipboard.readRtf(null, rtf => {
|
||||
console.log(`This is the rtf from the clipboard: ${rtf}`);
|
||||
}, (reason, err) => {
|
||||
console.log(`Error while reading the clipboard Message: ${err.message}, Stack: ${err.stack}`);
|
||||
});
|
||||
// readText
|
||||
fin.desktop.System.Clipboard.readText(null, text => {
|
||||
console.log(`This is the text from the clipboard: ${text}`);
|
||||
}, (reason, err) => {
|
||||
console.log(`Error while reading the clipboard Message: ${err.message}, Stack: ${err.stack}`);
|
||||
});
|
||||
// write
|
||||
fin.desktop.System.Clipboard.write({
|
||||
text: 'Hello Text!',
|
||||
html: '<h1>Hello Html</h1>',
|
||||
rtf: 'Hello Rtf'
|
||||
}, null, () => {
|
||||
console.log('Success!!');
|
||||
}, (reason, err) => {
|
||||
console.log(`Error while reading the clipboard Message: ${err.message}, Stack: ${err.stack}`);
|
||||
});
|
||||
// writeHtml
|
||||
fin.desktop.System.Clipboard.writeHtml('<h1>Hello World</h1>', null, () => {
|
||||
console.log('Success!!');
|
||||
}, (reason, err) => {
|
||||
console.log(`Error while reading the clipboard Message: ${err.message}, Stack: ${err.stack}`);
|
||||
});
|
||||
// writeRtf
|
||||
fin.desktop.System.Clipboard.writeRtf('Hello World!', null, () => {
|
||||
console.log('Success!!');
|
||||
}, (reason, err) => {
|
||||
console.log(`Error while reading the clipboard Message: ${err.message}, Stack: ${err.stack}`);
|
||||
});
|
||||
// writeText
|
||||
fin.desktop.System.Clipboard.writeText('Hello World', null, () => {
|
||||
console.log('Success!!');
|
||||
}, (reason, err) => {
|
||||
console.log(`Error while reading the clipboard Message: ${err.message}, Stack: ${err.stack}`);
|
||||
});
|
||||
}
|
||||
|
||||
function test_window() {
|
||||
let finWindow: fin.OpenFinWindow;
|
||||
// constructor
|
||||
finWindow = new fin.desktop.Window({
|
||||
name: "childWindow",
|
||||
url: "child.html",
|
||||
defaultWidth: 320,
|
||||
defaultHeight: 320,
|
||||
defaultTop: 10,
|
||||
defaultLeft: 300,
|
||||
frame: false,
|
||||
resizable: false,
|
||||
state: "normal"
|
||||
}, () => {
|
||||
const _win = finWindow.getNativeWindow();
|
||||
_win.addEventListener("DOMContentLoaded", () => { finWindow.show(); });
|
||||
}, error => {
|
||||
console.log("Error creating window:", error);
|
||||
});
|
||||
// getCurrent
|
||||
finWindow = fin.desktop.Window.getCurrent();
|
||||
// getNativeWindow
|
||||
let nativeWindow: Window;
|
||||
nativeWindow = finWindow.getNativeWindow();
|
||||
// getParentApplication
|
||||
let parentApp: fin.OpenFinApplication;
|
||||
parentApp = finWindow.getParentApplication();
|
||||
// getParentWindow
|
||||
let parentFinWindow: fin.OpenFinWindow;
|
||||
parentFinWindow = finWindow.getParentWindow();
|
||||
// wrap
|
||||
finWindow = fin.desktop.Window.wrap("uuid", "name");
|
||||
// addEventListener
|
||||
finWindow.addEventListener("bounds-changed", event => {
|
||||
console.log("The window has been moved or resized");
|
||||
}, () => {
|
||||
console.log("The registration was successful");
|
||||
}, reason => {
|
||||
console.log("failure:" + reason);
|
||||
});
|
||||
// animate
|
||||
finWindow.animate({
|
||||
opacity: {
|
||||
opacity: 0.15,
|
||||
duration: 1000
|
||||
},
|
||||
position: {
|
||||
left: 10,
|
||||
top: 10,
|
||||
duration: 3000
|
||||
}
|
||||
}, {
|
||||
interrupt: false
|
||||
}, evt => {
|
||||
// Callback will only fire after both "opacity" and "position" have finished animating.
|
||||
});
|
||||
// authenticate
|
||||
finWindow.addEventListener('auth-requested', evt => {
|
||||
finWindow.authenticate('userName', 'P@assw0rd', () => { }, (reason, err) => {
|
||||
console.log("failure:", err);
|
||||
});
|
||||
});
|
||||
// blur
|
||||
finWindow.blur();
|
||||
// bringToFront
|
||||
finWindow.bringToFront();
|
||||
// close
|
||||
finWindow.close();
|
||||
// disableFrame
|
||||
finWindow.disableFrame();
|
||||
// enableFrame
|
||||
finWindow.enableFrame();
|
||||
// flash
|
||||
finWindow.flash();
|
||||
// focus
|
||||
finWindow.focus();
|
||||
// getBounds
|
||||
finWindow.getBounds(bounds => {
|
||||
console.log(`top: ${bounds.top} left: ${bounds.left} height: ${bounds.height} width: ${bounds.width}`);
|
||||
});
|
||||
// getOptions
|
||||
finWindow.getOptions(options => {
|
||||
console.log(options);
|
||||
});
|
||||
// getSnapshot
|
||||
finWindow.getSnapshot(base64Snapshot => {
|
||||
console.log("data:image/png;base64," + base64Snapshot);
|
||||
});
|
||||
// getState
|
||||
finWindow.getState(state => {
|
||||
console.log("state: " + state);
|
||||
});
|
||||
// getZoomLevel
|
||||
finWindow.getZoomLevel(level => {
|
||||
console.log("zoom level: " + level);
|
||||
}, error => {
|
||||
console.log('error:', error);
|
||||
});
|
||||
// hide
|
||||
finWindow.hide();
|
||||
// isShowing
|
||||
finWindow.isShowing(showing => {
|
||||
console.log("the window is " + (showing ? "showing" : "hidden"));
|
||||
});
|
||||
// joinGroup
|
||||
let secondWindow = new fin.desktop.Window({
|
||||
url: "http://www.openfin.co",
|
||||
name: "secondWindow",
|
||||
autoShow: true
|
||||
}, () => {
|
||||
// When mainWindow moves or is moved, secondWindow moves by the same amount
|
||||
secondWindow.joinGroup(finWindow);
|
||||
});
|
||||
// leaveGroup
|
||||
secondWindow = new fin.desktop.Window({
|
||||
url: "http://www.openfin.co",
|
||||
name: "secondWindow",
|
||||
autoShow: true
|
||||
}, () => {
|
||||
// When finWindow moves or is moved, secondWindow moves by the same amount
|
||||
secondWindow.joinGroup(finWindow, () => {
|
||||
// once we are in the group, lets leave it.
|
||||
secondWindow.leaveGroup();
|
||||
});
|
||||
});
|
||||
// maximize
|
||||
finWindow.maximize();
|
||||
// mergeGroups
|
||||
{
|
||||
const finWindowOne = new fin.desktop.Window({
|
||||
url: "http://www.openfin.co",
|
||||
name: "finWindowOne",
|
||||
autoShow: true
|
||||
});
|
||||
const finWindowTwo = new fin.desktop.Window({
|
||||
url: "http://www.openfin.co",
|
||||
name: "finWindowTwo",
|
||||
autoShow: true
|
||||
});
|
||||
const finWindowThree = new fin.desktop.Window({
|
||||
url: "http://www.openfin.co",
|
||||
name: "finWindowThree",
|
||||
autoShow: true
|
||||
});
|
||||
const finWindowFour = new fin.desktop.Window({
|
||||
url: "http://www.openfin.co",
|
||||
name: "finWindowFour",
|
||||
autoShow: true
|
||||
});
|
||||
// When finWindowOne moves or is moved, finWindowTwo moves by the same amount
|
||||
finWindowOne.joinGroup(finWindowTwo);
|
||||
// When finWindowThree moves or is moved, finWindowFour moves by the same amount
|
||||
finWindowThree.joinGroup(finWindowFour);
|
||||
// finWindowOne, finWindowTwo, finWindowThree, and finWindowFour now move together in the same group
|
||||
finWindowOne.mergeGroups(finWindowThree);
|
||||
}
|
||||
// minimize
|
||||
finWindow.minimize();
|
||||
// moveBy
|
||||
finWindow.moveBy(10, 10);
|
||||
// moveTo
|
||||
finWindow.moveTo(100, 200);
|
||||
// removeEventListener
|
||||
const aRegisteredListener = (event: fin.WindowBaseEvent) => { };
|
||||
finWindow.removeEventListener("bounds-changed", aRegisteredListener);
|
||||
// resizeBy
|
||||
finWindow.resizeBy(10, 10, "top-right");
|
||||
// resizeTo
|
||||
finWindow.resizeTo(10, 10, "top-right");
|
||||
// restore
|
||||
finWindow.restore();
|
||||
// setAsForeground
|
||||
finWindow.setAsForeground();
|
||||
// setBounds
|
||||
finWindow.setBounds(100, 200, 400, 400);
|
||||
// setZoomLevel
|
||||
finWindow.setZoomLevel(10);
|
||||
// show
|
||||
finWindow.show();
|
||||
// showAt
|
||||
finWindow.showAt(10, 10, false);
|
||||
// stopFlashing
|
||||
finWindow.stopFlashing();
|
||||
// updateOptions
|
||||
finWindow.updateOptions({
|
||||
frame: false,
|
||||
maxWidth: 500
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": false,
|
||||
"baseUrl": "../../",
|
||||
"typeRoots": [
|
||||
"../../"
|
||||
],
|
||||
"types": [],
|
||||
"paths": {
|
||||
"openfin": [
|
||||
"openfin/v17"
|
||||
]
|
||||
},
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"openfin-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"max-line-length": false
|
||||
}
|
||||
}
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
// Type definitions for path-is-inside 1.0
|
||||
// Project: https://github.com/domenic/path-is-inside#readme
|
||||
// Definitions by: Alexander Marks <https://github.com/aomarks>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare function pathIsInside(thePath: string,
|
||||
potentialParent: string): boolean;
|
||||
export = pathIsInside;
|
||||
@@ -0,0 +1,3 @@
|
||||
import pathIsInside = require('path-is-inside');
|
||||
|
||||
pathIsInside('path', 'parent'); // $ExpectType boolean
|
||||
@@ -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",
|
||||
"path-is-inside-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Vendored
+303
-93
@@ -1,9 +1,10 @@
|
||||
// Type definitions for Q 1.0
|
||||
// Type definitions for Q 1.5
|
||||
// Project: https://github.com/kriskowal/q
|
||||
// Definitions by: Barrie Nemetchek <https://github.com/bnemetchek>
|
||||
// Andrew Gaspar <https://github.com/AndrewGaspar>
|
||||
// John Reilly <https://github.com/johnnyreilly>
|
||||
// Michel Boudreau <https://github.com/mboudreau>
|
||||
// TeamworkGuy2 <https://github.com/TeamworkGuy2>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
@@ -28,74 +29,99 @@ declare namespace Q {
|
||||
export interface Deferred<T> {
|
||||
promise: Promise<T>;
|
||||
|
||||
/**
|
||||
* Calling resolve with a pending promise causes promise to wait on the passed promise, becoming fulfilled with its
|
||||
* fulfillment value or rejected with its rejection reason (or staying pending forever, if the passed promise does).
|
||||
* Calling resolve with a rejected promise causes promise to be rejected with the passed promise's rejection reason.
|
||||
* Calling resolve with a fulfilled promise causes promise to be fulfilled with the passed promise's fulfillment value.
|
||||
* Calling resolve with a non-promise value causes promise to be fulfilled with that value.
|
||||
*/
|
||||
resolve(value?: IWhenable<T>): void;
|
||||
|
||||
/**
|
||||
* Calling reject with a reason causes promise to be rejected with that reason.
|
||||
*/
|
||||
reject(reason?: any): void;
|
||||
|
||||
/**
|
||||
* Calling notify with a value causes promise to be notified of progress with that value. That is, any onProgress
|
||||
* handlers registered with promise or promises derived from promise will be called with the progress value.
|
||||
*/
|
||||
notify(value: any): void;
|
||||
|
||||
/**
|
||||
* Returns a function suitable for passing to a Node.js API. That is, it has a signature (err, result) and will
|
||||
* reject deferred.promise with err if err is given, or fulfill it with result if that is given.
|
||||
*/
|
||||
makeNodeResolver(): (reason: any, value: T) => void;
|
||||
}
|
||||
|
||||
export interface Promise<T> {
|
||||
/**
|
||||
* Like a finally clause, allows you to observe either the fulfillment or rejection of a promise, but to do so without modifying the final value. This is useful for collecting resources
|
||||
* regardless of whether a job succeeded, like closing a database connection, shutting a server down, or deleting an unneeded key from an object. finally returns a promise, which will become
|
||||
* resolved with the same fulfillment value or rejection reason as promise. However, if callback returns a promise, the resolution of the returned promise will be delayed until the promise
|
||||
* returned from callback is finished.
|
||||
* The then method from the Promises/A+ specification, with an additional progress handler.
|
||||
*/
|
||||
fin(finallyCallback: () => any): Promise<T>;
|
||||
then<U>(onFulfill?: ((value: T) => IWhenable<U>) | null, onReject?: ((error: any) => IWhenable<U>) | null, onProgress?: ((progress: any) => any) | null): Promise<U>;
|
||||
|
||||
/**
|
||||
* Like a finally clause, allows you to observe either the fulfillment or rejection of a promise, but to do so without modifying the final value. This is useful for collecting resources
|
||||
* regardless of whether a job succeeded, like closing a database connection, shutting a server down, or deleting an unneeded key from an object. finally returns a promise, which will become
|
||||
* resolved with the same fulfillment value or rejection reason as promise. However, if callback returns a promise, the resolution of the returned promise will be delayed until the promise
|
||||
* returned from callback is finished.
|
||||
* Like a finally clause, allows you to observe either the fulfillment or rejection of a promise, but to do so
|
||||
* without modifying the final value. This is useful for collecting resources regardless of whether a job succeeded,
|
||||
* like closing a database connection, shutting a server down, or deleting an unneeded key from an object.
|
||||
* finally returns a promise, which will become resolved with the same fulfillment value or rejection reason
|
||||
* as promise. However, if callback returns a promise, the resolution of the returned promise will be delayed
|
||||
* until the promise returned from callback is finished. Furthermore, if the returned promise rejects, that
|
||||
* rejection will be passed down the chain instead of the previous result.
|
||||
*/
|
||||
finally(finallyCallback: () => any): Promise<T>;
|
||||
|
||||
/**
|
||||
* The then method from the Promises/A+ specification, with an additional progress handler.
|
||||
* Alias for finally() (for non-ES5 browsers)
|
||||
*/
|
||||
then<U>(onFulfill?: (value: T) => IWhenable<U>, onReject?: (error: any) => IWhenable<U>, onProgress?: (progress: any) => any): Promise<U>;
|
||||
fin(finallyCallback: () => any): Promise<T>;
|
||||
|
||||
/**
|
||||
* Like then, but "spreads" the array into a variadic fulfillment handler. If any of the promises in the array are rejected, instead calls onRejected with the first rejected promise's
|
||||
* rejection reason.
|
||||
*
|
||||
* Like then, but "spreads" the array into a variadic fulfillment handler. If any of the promises in the array are
|
||||
* rejected, instead calls onRejected with the first rejected promise's rejection reason.
|
||||
* This is especially useful in conjunction with all
|
||||
*/
|
||||
spread<U>(onFulfill: (...args: any[]) => IWhenable<U>, onReject?: (reason: any) => IWhenable<U>): Promise<U>;
|
||||
|
||||
fail<U>(onRejected: (reason: any) => IWhenable<U>): Promise<U>;
|
||||
|
||||
/**
|
||||
* A sugar method, equivalent to promise.then(undefined, onRejected).
|
||||
*/
|
||||
catch<U>(onRejected: (reason: any) => IWhenable<U>): Promise<U>;
|
||||
|
||||
/**
|
||||
* Alias for catch() (for non-ES5 browsers)
|
||||
*/
|
||||
fail<U>(onRejected: (reason: any) => IWhenable<U>): Promise<U>;
|
||||
|
||||
/**
|
||||
* A sugar method, equivalent to promise.then(undefined, undefined, onProgress).
|
||||
*/
|
||||
progress(onProgress: (progress: any) => any): Promise<T>;
|
||||
|
||||
/**
|
||||
* Much like then, but with different behavior around unhandled rejection. If there is an unhandled rejection, either because promise is rejected and no onRejected callback was provided, or
|
||||
* because onFulfilled or onRejected threw an error or returned a rejected promise, the resulting rejection reason is thrown as an exception in a future turn of the event loop.
|
||||
*
|
||||
* This method should be used to terminate chains of promises that will not be passed elsewhere. Since exceptions thrown in then callbacks are consumed and transformed into rejections,
|
||||
* exceptions at the end of the chain are easy to accidentally, silently ignore. By arranging for the exception to be thrown in a future turn of the event loop, so that it won't be caught, it
|
||||
* causes an onerror event on the browser window, or an uncaughtException event on Node.js's process object.
|
||||
*
|
||||
* Exceptions thrown by done will have long stack traces, if Q.longStackSupport is set to true. If Q.onerror is set, exceptions will be delivered there instead of thrown in a future turn.
|
||||
*
|
||||
* The Golden Rule of done vs. then usage is: either return your promise to someone else, or if the chain ends with you, call done to terminate it.
|
||||
* Much like then, but with different behavior around unhandled rejection. If there is an unhandled rejection,
|
||||
* either because promise is rejected and no onRejected callback was provided, or because onFulfilled or onRejected
|
||||
* threw an error or returned a rejected promise, the resulting rejection reason is thrown as an exception in a
|
||||
* future turn of the event loop.
|
||||
* This method should be used to terminate chains of promises that will not be passed elsewhere. Since exceptions
|
||||
* thrown in then callbacks are consumed and transformed into rejections, exceptions at the end of the chain are
|
||||
* easy to accidentally, silently ignore. By arranging for the exception to be thrown in a future turn of the
|
||||
* event loop, so that it won't be caught, it causes an onerror event on the browser window, or an uncaughtException
|
||||
* event on Node.js's process object.
|
||||
* Exceptions thrown by done will have long stack traces, if Q.longStackSupport is set to true. If Q.onerror is set,
|
||||
* exceptions will be delivered there instead of thrown in a future turn.
|
||||
* The Golden Rule of done vs. then usage is: either return your promise to someone else, or if the chain ends
|
||||
* with you, call done to terminate it. Terminating with catch is not sufficient because the catch handler may
|
||||
* itself throw an error.
|
||||
*/
|
||||
done(onFulfilled?: (value: T) => any, onRejected?: (reason: any) => any, onProgress?: (progress: any) => any): void;
|
||||
done(onFulfilled?: ((value: T) => any) | null, onRejected?: ((reason: any) => any) | null, onProgress?: ((progress: any) => any) | null): void;
|
||||
|
||||
/**
|
||||
* If callback is a function, assumes it's a Node.js-style callback, and calls it as either callback(rejectionReason) when/if promise becomes rejected, or as callback(null, fulfillmentValue)
|
||||
* when/if promise becomes fulfilled. If callback is not a function, simply returns promise.
|
||||
* If callback is a function, assumes it's a Node.js-style callback, and calls it as either callback(rejectionReason)
|
||||
* when/if promise becomes rejected, or as callback(null, fulfillmentValue) when/if promise becomes fulfilled.
|
||||
* If callback is not a function, simply returns promise.
|
||||
*/
|
||||
nodeify(callback: (reason: any, value: any) => void): Promise<T>;
|
||||
|
||||
@@ -112,8 +138,8 @@ declare namespace Q {
|
||||
delete<U>(propertyName: string): Promise<U>;
|
||||
|
||||
/**
|
||||
* Returns a promise for the result of calling the named method of an object with the given array of arguments. The object itself is this in the function, just like a synchronous method call.
|
||||
* Essentially equivalent to
|
||||
* Returns a promise for the result of calling the named method of an object with the given array of arguments.
|
||||
* The object itself is this in the function, just like a synchronous method call. Essentially equivalent to
|
||||
*
|
||||
* @example
|
||||
* promise.then(function (o) { return o[methodName].apply(o, args); });
|
||||
@@ -121,14 +147,11 @@ declare namespace Q {
|
||||
post<U>(methodName: string, args: any[]): Promise<U>;
|
||||
|
||||
/**
|
||||
* Returns a promise for the result of calling the named method of an object with the given variadic arguments. The object itself is this in the function, just like a synchronous method call.
|
||||
* Returns a promise for the result of calling the named method of an object with the given variadic arguments.
|
||||
* The object itself is this in the function, just like a synchronous method call.
|
||||
*/
|
||||
invoke<U>(methodName: string, ...args: any[]): Promise<U>;
|
||||
|
||||
fapply<U>(args: any[]): Promise<U>;
|
||||
|
||||
fcall<U>(...args: any[]): Promise<U>;
|
||||
|
||||
/**
|
||||
* Returns a promise for an array of the property names of an object. Essentially equivalent to
|
||||
*
|
||||
@@ -137,6 +160,35 @@ declare namespace Q {
|
||||
*/
|
||||
keys(): Promise<string[]>;
|
||||
|
||||
/**
|
||||
* Returns a promise for the result of calling a function, with the given array of arguments. Essentially equivalent to
|
||||
*
|
||||
* @example
|
||||
* promise.then(function (f) {
|
||||
* return f.apply(undefined, args);
|
||||
* });
|
||||
*/
|
||||
fapply<U>(args: any[]): Promise<U>;
|
||||
|
||||
/**
|
||||
* Returns a promise for the result of calling a function, with the given variadic arguments. Has the same return
|
||||
* value/thrown exception translation as explained above for fbind.
|
||||
* In its static form, it is aliased as Q.try, since it has semantics similar to a try block (but handling both
|
||||
* synchronous exceptions and asynchronous rejections). This allows code like
|
||||
*
|
||||
* @example
|
||||
* Q.try(function () {
|
||||
* if (!isConnectedToCloud()) {
|
||||
* throw new Error("The cloud is down!");
|
||||
* }
|
||||
* return syncToCloud();
|
||||
* })
|
||||
* .catch(function (error) {
|
||||
* console.error("Couldn't sync to the cloud", error);
|
||||
* });
|
||||
*/
|
||||
fcall<U>(...args: any[]): Promise<U>;
|
||||
|
||||
/**
|
||||
* A sugar method, equivalent to promise.then(function () { return value; }).
|
||||
*/
|
||||
@@ -148,30 +200,39 @@ declare namespace Q {
|
||||
thenReject<U = T>(reason?: any): Promise<U>;
|
||||
|
||||
/**
|
||||
* Attaches a handler that will observe the value of the promise when it becomes fulfilled, returning a promise for that same value, perhaps deferred but not replaced by the promise returned
|
||||
* by the onFulfilled handler.
|
||||
* Attaches a handler that will observe the value of the promise when it becomes fulfilled, returning a promise for
|
||||
* that same value, perhaps deferred but not replaced by the promise returned by the onFulfilled handler.
|
||||
*/
|
||||
tap(onFulfilled: (value: T) => any): Promise<T>;
|
||||
|
||||
/**
|
||||
* Returns a promise that will have the same result as promise, except that if promise is not fulfilled or rejected
|
||||
* before ms milliseconds, the returned promise will be rejected with an Error with the given message. If message
|
||||
* is not supplied, the message will be "Timed out after " + ms + " ms".
|
||||
*/
|
||||
timeout(ms: number, message?: string): Promise<T>;
|
||||
|
||||
/**
|
||||
* Returns a promise that will have the same result as promise, but will only be fulfilled or rejected after at least ms milliseconds have passed.
|
||||
* Returns a promise that will have the same result as promise, but will only be fulfilled or rejected after at least
|
||||
* ms milliseconds have passed.
|
||||
*/
|
||||
delay(ms: number): Promise<T>;
|
||||
|
||||
/**
|
||||
* Returns whether a given promise is in the fulfilled state. When the static version is used on non-promises, the result is always true.
|
||||
* Returns whether a given promise is in the fulfilled state. When the static version is used on non-promises, the
|
||||
* result is always true.
|
||||
*/
|
||||
isFulfilled(): boolean;
|
||||
|
||||
/**
|
||||
* Returns whether a given promise is in the rejected state. When the static version is used on non-promises, the result is always false.
|
||||
* Returns whether a given promise is in the rejected state. When the static version is used on non-promises, the
|
||||
* result is always false.
|
||||
*/
|
||||
isRejected(): boolean;
|
||||
|
||||
/**
|
||||
* Returns whether a given promise is in the pending state. When the static version is used on non-promises, the result is always false.
|
||||
* Returns whether a given promise is in the pending state. When the static version is used on non-promises, the
|
||||
* result is always false.
|
||||
*/
|
||||
isPending(): boolean;
|
||||
|
||||
@@ -193,6 +254,30 @@ declare namespace Q {
|
||||
reason?: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a "deferred" object with a:
|
||||
* promise property
|
||||
* resolve(value) method
|
||||
* reject(reason) method
|
||||
* notify(value) method
|
||||
* makeNodeResolver() method
|
||||
*/
|
||||
export function defer<T>(): Deferred<T>;
|
||||
|
||||
/**
|
||||
* Calling resolve with a pending promise causes promise to wait on the passed promise, becoming fulfilled with its
|
||||
* fulfillment value or rejected with its rejection reason (or staying pending forever, if the passed promise does).
|
||||
* Calling resolve with a rejected promise causes promise to be rejected with the passed promise's rejection reason.
|
||||
* Calling resolve with a fulfilled promise causes promise to be fulfilled with the passed promise's fulfillment value.
|
||||
* Calling resolve with a non-promise value causes promise to be fulfilled with that value.
|
||||
*/
|
||||
export function resolve<T>(object?: IWhenable<T>): Promise<T>;
|
||||
|
||||
/**
|
||||
* Returns a promise that is rejected with reason.
|
||||
*/
|
||||
export function reject<T>(reason?: any): Promise<T>;
|
||||
|
||||
// If no value provided, returned promise will be of void type
|
||||
export function when(): Promise<void>;
|
||||
|
||||
@@ -200,38 +285,168 @@ declare namespace Q {
|
||||
export function when<T>(value: IWhenable<T>): Promise<T>;
|
||||
|
||||
// If a non-promise value is provided, it will not reject or progress
|
||||
export function when<T, U>(value: IWhenable<T>, onFulfilled: (val: T) => IWhenable<U>, onRejected?: (reason: any) => IWhenable<U>, onProgress?: (progress: any) => any): Promise<U>;
|
||||
export function when<T, U>(value: IWhenable<T>, onFulfilled: (val: T) => IWhenable<U>, onRejected?: ((reason: any) => IWhenable<U>) | null, onProgress?: ((progress: any) => any) | null): Promise<U>;
|
||||
|
||||
/**
|
||||
* (Deprecated) Returns a new function that calls a function asynchronously with the given variadic arguments, and returns a promise.
|
||||
* Notably, any synchronous return values or thrown exceptions are transformed, respectively, into fulfillment values
|
||||
* or rejection reasons for the promise returned by this new function.
|
||||
* This method is especially useful in its static form for wrapping functions to ensure that they are always
|
||||
* asynchronous, and that any thrown exceptions (intentional or accidental) are appropriately transformed into a
|
||||
* returned rejected promise. For example:
|
||||
*
|
||||
* @example
|
||||
* var getUserData = Q.fbind(function (userName) {
|
||||
* if (!userName) {
|
||||
* throw new Error("userName must be truthy!");
|
||||
* }
|
||||
* if (localCache.has(userName)) {
|
||||
* return localCache.get(userName);
|
||||
* }
|
||||
* return getUserFromCloud(userName);
|
||||
* });
|
||||
*/
|
||||
export function fbind<T>(method: (...args: any[]) => IWhenable<T>, ...args: any[]): (...args: any[]) => Promise<T>;
|
||||
|
||||
/**
|
||||
* Returns a promise for the result of calling a function, with the given variadic arguments. Has the same return
|
||||
* value/thrown exception translation as explained above for fbind.
|
||||
* In its static form, it is aliased as Q.try, since it has semantics similar to a try block (but handling both synchronous
|
||||
* exceptions and asynchronous rejections). This allows code like
|
||||
*
|
||||
* @example
|
||||
* Q.try(function () {
|
||||
* if (!isConnectedToCloud()) {
|
||||
* throw new Error("The cloud is down!");
|
||||
* }
|
||||
* return syncToCloud();
|
||||
* })
|
||||
* .catch(function (error) {
|
||||
* console.error("Couldn't sync to the cloud", error);
|
||||
* });
|
||||
*/
|
||||
export function fcall<T>(method: (...args: any[]) => T, ...args: any[]): Promise<T>;
|
||||
|
||||
// Try is an alias for fcall, but 'try' is a reserved word. This is the only way to get around this
|
||||
// but 'try' is a reserved word. This is the only way to get around this
|
||||
/**
|
||||
* Alias for fcall()
|
||||
*/
|
||||
export {fcall as try};
|
||||
|
||||
export function send<T>(obj: any, functionName: string, ...args: any[]): Promise<T>;
|
||||
|
||||
/**
|
||||
* Returns a promise for the result of calling the named method of an object with the given variadic arguments.
|
||||
* The object itself is this in the function, just like a synchronous method call.
|
||||
*/
|
||||
export function invoke<T>(obj: any, functionName: string, ...args: any[]): Promise<T>;
|
||||
|
||||
/**
|
||||
* Alias for invoke()
|
||||
*/
|
||||
export function send<T>(obj: any, functionName: string, ...args: any[]): Promise<T>;
|
||||
|
||||
/**
|
||||
* Alias for invoke()
|
||||
*/
|
||||
export function mcall<T>(obj: any, functionName: string, ...args: any[]): Promise<T>;
|
||||
|
||||
export function denodeify<T>(nodeFunction: (...args: any[]) => any, ...args: any[]): (...args: any[]) => Promise<T>;
|
||||
|
||||
export function nbind<T>(nodeFunction: (...args: any[]) => any, thisArg: any, ...args: any[]): (...args: any[]) => Promise<T>;
|
||||
|
||||
/**
|
||||
* Creates a promise-returning function from a Node.js-style function, optionally binding it with the given
|
||||
* variadic arguments. An example:
|
||||
*
|
||||
* @example
|
||||
* var readFile = Q.nfbind(FS.readFile);
|
||||
* readFile("foo.txt", "utf-8").done(function (text) {
|
||||
* //...
|
||||
* });
|
||||
*
|
||||
* Note that if you have a method that uses the Node.js callback pattern, as opposed to just a function, you will
|
||||
* need to bind its this value before passing it to nfbind, like so:
|
||||
*
|
||||
* @example
|
||||
* var Kitty = mongoose.model("Kitty");
|
||||
* var findKitties = Q.nfbind(Kitty.find.bind(Kitty));
|
||||
*
|
||||
* The better strategy for methods would be to use Q.nbind, as shown below.
|
||||
*/
|
||||
export function nfbind<T>(nodeFunction: (...args: any[]) => any, ...args: any[]): (...args: any[]) => Promise<T>;
|
||||
|
||||
export function nfcall<T>(nodeFunction: (...args: any[]) => any, ...args: any[]): Promise<T>;
|
||||
/**
|
||||
* Alias for nfbind()
|
||||
*/
|
||||
export function denodeify<T>(nodeFunction: (...args: any[]) => any, ...args: any[]): (...args: any[]) => Promise<T>;
|
||||
|
||||
/**
|
||||
* Creates a promise-returning function from a Node.js-style method, optionally binding it with the given
|
||||
* variadic arguments. An example:
|
||||
*
|
||||
* @example
|
||||
* var Kitty = mongoose.model("Kitty");
|
||||
* var findKitties = Q.nbind(Kitty.find, Kitty);
|
||||
* findKitties({ cute: true }).done(function (theKitties) {
|
||||
* //...
|
||||
* });
|
||||
*/
|
||||
export function nbind<T>(nodeFunction: (...args: any[]) => any, thisArg: any, ...args: any[]): (...args: any[]) => Promise<T>;
|
||||
|
||||
/**
|
||||
* Calls a Node.js-style function with the given array of arguments, returning a promise that is fulfilled if the
|
||||
* Node.js function calls back with a result, or rejected if it calls back with an error
|
||||
* (or throws one synchronously). An example:
|
||||
*
|
||||
* @example
|
||||
* Q.nfapply(FS.readFile, ["foo.txt", "utf-8"]).done(function (text) {
|
||||
* });
|
||||
*
|
||||
* Note that this example only works because FS.readFile is a function exported from a module, not a method on
|
||||
* an object. For methods, e.g. redisClient.get, you must bind the method to an instance before passing it to
|
||||
* Q.nfapply (or, generally, as an argument to any function call):
|
||||
*
|
||||
* @example
|
||||
* Q.nfapply(redisClient.get.bind(redisClient), ["user:1:id"]).done(function (user) {
|
||||
* });
|
||||
*
|
||||
* The better strategy for methods would be to use Q.npost, as shown below.
|
||||
*/
|
||||
export function nfapply<T>(nodeFunction: (...args: any[]) => any, args: any[]): Promise<T>;
|
||||
|
||||
export function ninvoke<T>(nodeModule: any, functionName: string, ...args: any[]): Promise<T>;
|
||||
/**
|
||||
* Calls a Node.js-style function with the given variadic arguments, returning a promise that is fulfilled if the
|
||||
* Node.js function calls back with a result, or rejected if it calls back with an error
|
||||
* (or throws one synchronously). An example:
|
||||
*
|
||||
* @example
|
||||
* Q.nfcall(FS.readFile, "foo.txt", "utf-8").done(function (text) {
|
||||
* });
|
||||
*
|
||||
* The same warning about functions vs. methods applies for nfcall as it does for nfapply. In this case, the better
|
||||
* strategy would be to use Q.ninvoke.
|
||||
*/
|
||||
export function nfcall<T>(nodeFunction: (...args: any[]) => any, ...args: any[]): Promise<T>;
|
||||
|
||||
/**
|
||||
* Calls a Node.js-style method with the given arguments array, returning a promise that is fulfilled if the method
|
||||
* calls back with a result, or rejected if it calls back with an error (or throws one synchronously). An example:
|
||||
*
|
||||
* @example
|
||||
* Q.npost(redisClient, "get", ["user:1:id"]).done(function (user) {
|
||||
* });
|
||||
*/
|
||||
export function npost<T>(nodeModule: any, functionName: string, args: any[]): Promise<T>;
|
||||
|
||||
export function nsend<T>(nodeModule: any, functionName: string, ...args: any[]): Promise<T>;
|
||||
/**
|
||||
* Calls a Node.js-style method with the given variadic arguments, returning a promise that is fulfilled if the
|
||||
* method calls back with a result, or rejected if it calls back with an error (or throws one synchronously). An example:
|
||||
*
|
||||
* @example
|
||||
* Q.ninvoke(redisClient, "get", "user:1:id").done(function (user) {
|
||||
* });
|
||||
*/
|
||||
export function ninvoke<T>(nodeModule: any, functionName: string, ...args: any[]): Promise<T>;
|
||||
|
||||
export function nmcall<T>(nodeModule: any, functionName: string, ...args: any[]): Promise<T>;
|
||||
/**
|
||||
* Alias for ninvoke()
|
||||
*/
|
||||
export function nsend<T>(nodeModule: any, functionName: string, ...args: any[]): Promise<T>;
|
||||
|
||||
/**
|
||||
* Returns a promise that is fulfilled with an array containing the fulfillment value of each promise, or is rejected with the same rejection reason as the first promise to be rejected.
|
||||
@@ -267,21 +482,27 @@ declare namespace Q {
|
||||
export function race<T>(promises: Array<IWhenable<T>>): Promise<T>;
|
||||
|
||||
/**
|
||||
* Returns a promise that is fulfilled with an array of promise state snapshots, but only after all the original promises have settled, i.e. become either fulfilled or rejected.
|
||||
* Returns a promise that is fulfilled with an array of promise state snapshots, but only after all the original promises
|
||||
* have settled, i.e. become either fulfilled or rejected.
|
||||
*/
|
||||
export function allSettled<T>(promises: IWhenable<Array<IWhenable<T>>>): Promise<Array<PromiseState<T>>>;
|
||||
|
||||
/**
|
||||
* Deprecated Alias for allSettled()
|
||||
*/
|
||||
export function allResolved<T>(promises: IWhenable<Array<IWhenable<T>>>): Promise<Array<Promise<T>>>;
|
||||
|
||||
/**
|
||||
* Like then, but "spreads" the array into a variadic fulfillment handler. If any of the promises in the array are rejected, instead calls onRejected with the first rejected promise's rejection
|
||||
* reason. This is especially useful in conjunction with all.
|
||||
* Like then, but "spreads" the array into a variadic fulfillment handler. If any of the promises in the array are
|
||||
* rejected, instead calls onRejected with the first rejected promise's rejection reason. This is especially useful
|
||||
* in conjunction with all.
|
||||
*/
|
||||
export function spread<T, U>(promises: Array<IWhenable<T>>, onFulfilled: (...args: T[]) => IWhenable<U>, onRejected?: (reason: any) => IWhenable<U>): Promise<U>;
|
||||
|
||||
/**
|
||||
* Returns a promise that will have the same result as promise, except that if promise is not fulfilled or rejected before ms milliseconds, the returned promise will be rejected with an Error
|
||||
* with the given message. If message is not supplied, the message will be "Timed out after " + ms + " ms".
|
||||
* Returns a promise that will have the same result as promise, except that if promise is not fulfilled or rejected
|
||||
* before ms milliseconds, the returned promise will be rejected with an Error with the given message. If message
|
||||
* is not supplied, the message will be "Timed out after " + ms + " ms".
|
||||
*/
|
||||
export function timeout<T>(promise: Promise<T>, ms: number, message?: string): Promise<T>;
|
||||
|
||||
@@ -310,75 +531,64 @@ declare namespace Q {
|
||||
export function isPending(promiseOrObject: Promise<any> | any): boolean;
|
||||
|
||||
/**
|
||||
* Returns a "deferred" object with a:
|
||||
* promise property
|
||||
* resolve(value) method
|
||||
* reject(reason) method
|
||||
* notify(value) method
|
||||
* makeNodeResolver() method
|
||||
* Synchronously calls resolver(resolve, reject, notify) and returns a promise whose state is controlled by the
|
||||
* functions passed to resolver. This is an alternative promise-creation API that has the same power as the deferred
|
||||
* concept, but without introducing another conceptual entity.
|
||||
* If resolver throws an exception, the returned promise will be rejected with that thrown exception as the rejection reason.
|
||||
* note: In the latest github, this method is called Q.Promise, but if you are using the npm package version 0.9.7
|
||||
* or below, the method is called Q.promise (lowercase vs uppercase p).
|
||||
*/
|
||||
export function defer<T>(): Deferred<T>;
|
||||
|
||||
/**
|
||||
* Returns a promise that is rejected with reason.
|
||||
*/
|
||||
export function reject<T>(reason?: any): Promise<T>;
|
||||
|
||||
export function Promise<T>(resolver: (resolve: (val?: IWhenable<T>) => void, reject: (reason?: any) => void, notify: (progress: any) => void) => void): Promise<T>;
|
||||
|
||||
/**
|
||||
* Creates a new version of func that accepts any combination of promise and non-promise values, converting them to their fulfillment values before calling the original func. The returned version
|
||||
* also always returns a promise: if func does a return or throw, then Q.promised(func) will return fulfilled or rejected promise, respectively.
|
||||
*
|
||||
* This can be useful for creating functions that accept either promises or non-promise values, and for ensuring that the function always returns a promise even in the face of unintentional
|
||||
* thrown exceptions.
|
||||
* Creates a new version of func that accepts any combination of promise and non-promise values, converting them to their
|
||||
* fulfillment values before calling the original func. The returned version also always returns a promise: if func does
|
||||
* a return or throw, then Q.promised(func) will return fulfilled or rejected promise, respectively.
|
||||
* This can be useful for creating functions that accept either promises or non-promise values, and for ensuring that
|
||||
* the function always returns a promise even in the face of unintentional thrown exceptions.
|
||||
*/
|
||||
export function promised<T>(callback: (...args: any[]) => T): (...args: any[]) => Promise<T>;
|
||||
|
||||
/**
|
||||
* Returns whether the given value is a Q promise.
|
||||
*/
|
||||
export function isPromise(object: any): boolean;
|
||||
export function isPromise(object: any): object is Promise<any>;
|
||||
|
||||
/**
|
||||
* Returns whether the given value is a promise (i.e. it's an object with a then function).
|
||||
*/
|
||||
export function isPromiseAlike(object: any): boolean;
|
||||
export function isPromiseAlike(object: any): object is IPromise<any>;
|
||||
|
||||
/**
|
||||
* If an object is not a promise, it is as "near" as possible.
|
||||
* If a promise is rejected, it is as "near" as possible too.
|
||||
* If it’s a fulfilled promise, the fulfillment value is nearer.
|
||||
* If it’s a deferred promise and the deferred has been resolved, the
|
||||
* If it's a fulfilled promise, the fulfillment value is nearer.
|
||||
* If it's a deferred promise and the deferred has been resolved, the
|
||||
* resolution is "nearer".
|
||||
*/
|
||||
export function nearer<T>(promise: Promise<T>): T;
|
||||
|
||||
/**
|
||||
* This is an experimental tool for converting a generator function into a deferred function. This has the potential of reducing nested callbacks in engines that support yield.
|
||||
* This is an experimental tool for converting a generator function into a deferred function. This has the potential
|
||||
* of reducing nested callbacks in engines that support yield.
|
||||
*/
|
||||
export function async<T>(generatorFunction: any): (...args: any[]) => Promise<T>;
|
||||
|
||||
export function nextTick(callback: (...args: any[]) => any): void;
|
||||
|
||||
/**
|
||||
* A settable property that will intercept any uncaught errors that would otherwise be thrown in the next tick of the event loop, usually as a result of done. Can be useful for getting the full
|
||||
* A settable property that will intercept any uncaught errors that would otherwise be thrown in the next tick of the
|
||||
* event loop, usually as a result of done. Can be useful for getting the full
|
||||
* stack trace of an error in browsers, which is not usually possible with window.onerror.
|
||||
*/
|
||||
export let onerror: (reason: any) => void;
|
||||
/**
|
||||
* A settable property that lets you turn on long stack trace support. If turned on, "stack jumps" will be tracked across asynchronous promise operations, so that if an uncaught error is thrown
|
||||
* by done or a rejection reason's stack property is inspected in a rejection callback, a long stack trace is produced.
|
||||
* A settable property that lets you turn on long stack trace support. If turned on, "stack jumps" will be tracked
|
||||
* across asynchronous promise operations, so that if an uncaught error is thrown by done or a rejection reason's stack
|
||||
* property is inspected in a rejection callback, a long stack trace is produced.
|
||||
*/
|
||||
export let longStackSupport: boolean;
|
||||
|
||||
/**
|
||||
* Calling resolve with a pending promise causes promise to wait on the passed promise, becoming fulfilled with its fulfillment value or rejected with its rejection reason (or staying pending
|
||||
* forever, if the passed promise does). Calling resolve with a rejected promise causes promise to be rejected with the passed promise's rejection reason. Calling resolve with a fulfilled promise
|
||||
* causes promise to be fulfilled with the passed promise's fulfillment value. Calling resolve with a non-promise value causes promise to be fulfilled with that value.
|
||||
*/
|
||||
export function resolve<T>(object?: IWhenable<T>): Promise<T>;
|
||||
|
||||
/**
|
||||
* Resets the global "Q" variable to the value it has before Q was loaded.
|
||||
* This will either be undefined if there was no version or the version of Q which was already loaded before.
|
||||
|
||||
+60
-50
@@ -1,18 +1,20 @@
|
||||
/// <reference types="jquery" />
|
||||
|
||||
import Q = require('q');
|
||||
import Q = require("q");
|
||||
|
||||
Q(8).then(x => console.log(x.toExponential()));
|
||||
const _when: Q.IWhenable<number> = Q.resolve(0); // was an issue when strictFunctionTypes were enforced on all of DefinitelyTyped
|
||||
|
||||
Q(8).then((x) => console.log(x.toExponential()));
|
||||
Q().then(() => console.log("nothing"));
|
||||
|
||||
const delay = (delay: number) => {
|
||||
function delay(delay: number): Q.Promise<void> {
|
||||
const d = Q.defer<void>();
|
||||
setTimeout(d.resolve, delay);
|
||||
return d.promise;
|
||||
};
|
||||
}
|
||||
|
||||
Q.when(delay(1000), (val) => {
|
||||
console.log('Hello, World!');
|
||||
console.log("Hello, World!");
|
||||
return;
|
||||
});
|
||||
|
||||
@@ -20,15 +22,15 @@ Q.when(delay(1000), (val) => {
|
||||
const otherPromise = Q.defer<string>().promise;
|
||||
Q.defer<string>().resolve(otherPromise);
|
||||
|
||||
Q.timeout(Q(new Date()), 1000, "My dates never arrived. :(").then(d => d.toJSON());
|
||||
Q.timeout(Q(new Date()), 1000, "My dates never arrived. :(").then((d) => d.toJSON());
|
||||
|
||||
Q.delay(Q(8), 1000).then(x => x.toExponential());
|
||||
Q.delay(8, 1000).then(x => x.toExponential());
|
||||
Q.delay(Q("asdf"), 1000).then(x => x.length);
|
||||
Q.delay("asdf", 1000).then(x => x.length);
|
||||
Q.delay(Q(8), 1000).then((x) => x.toExponential());
|
||||
Q.delay(8, 1000).then((x) => x.toExponential());
|
||||
Q.delay(Q("asdf"), 1000).then((x) => x.length);
|
||||
Q.delay("asdf", 1000).then((x) => x.length);
|
||||
|
||||
const eventualAdd = Q.promised((a?: number, b?: number) => a + b);
|
||||
eventualAdd(Q(1), Q(2)).then(x => x.toExponential());
|
||||
const eventualAdd = Q.promised((a?: number, b?: number) => <number> a + <number> b);
|
||||
eventualAdd(Q(1), Q(2)).then((x) => x.toExponential());
|
||||
|
||||
function eventually<T>(eventually: T) {
|
||||
return Q.delay(eventually, 1000);
|
||||
@@ -36,6 +38,7 @@ function eventually<T>(eventually: T) {
|
||||
|
||||
const x = Q.all([1, 2, 3].map(eventually));
|
||||
Q.when(x, (x) => {
|
||||
const _x: number[] = x;
|
||||
console.log(x);
|
||||
});
|
||||
|
||||
@@ -81,10 +84,11 @@ Q.allResolved([])
|
||||
|
||||
Q(42)
|
||||
.tap(() => "hello")
|
||||
.tap(x => {
|
||||
.tap((x) => {
|
||||
console.log(x);
|
||||
})
|
||||
.then(x => {
|
||||
.then((x) => {
|
||||
const _x: number = x;
|
||||
console.log("42 == " + x);
|
||||
});
|
||||
|
||||
@@ -94,34 +98,34 @@ declare let stringPromise: Q.IPromise<string>;
|
||||
declare function returnsNumPromise(text: string): Q.Promise<number>;
|
||||
declare function returnsNumPromise(text: string): JQueryPromise<number>;
|
||||
|
||||
Q<number[]>(arrayPromise) // type specification required
|
||||
.then(arr => arr.join(','))
|
||||
.then<number>(returnsNumPromise) // requires specification
|
||||
.then(num => num.toFixed());
|
||||
Q(arrayPromise)
|
||||
.then((arr) => arr.join(','))
|
||||
.then(returnsNumPromise) // requires specification
|
||||
.then((num) => num.toFixed());
|
||||
|
||||
declare let jPromise: JQueryPromise<string>;
|
||||
|
||||
// if jQuery promises definition supported generics, this could be more interesting example
|
||||
Q<string>(jPromise).then(str => str.split(','));
|
||||
Q<string>(jPromise).then((str) => str.split(','));
|
||||
jPromise.then(returnsNumPromise);
|
||||
|
||||
// watch the typing flow through from jQueryPromise to Q.Promise
|
||||
Q(jPromise).then(str => str.split(','));
|
||||
Q(jPromise).then((str) => str.split(','));
|
||||
|
||||
declare let promiseArray: Array<Q.IPromise<number>>;
|
||||
const qPromiseArray = promiseArray.map(p => {
|
||||
const qPromiseArray = promiseArray.map((p) => {
|
||||
return Q<number>(p);
|
||||
});
|
||||
const myNums: any[] = [2, 3, Q(4), 5, Q(6), Q(7)];
|
||||
|
||||
Q.all(promiseArray).then(nums => nums.map(num => num.toPrecision(2)).join(','));
|
||||
Q.all(promiseArray).then((nums) => nums.map((num) => num.toPrecision(2)).join(','));
|
||||
|
||||
Q.all<number>(myNums).then(nums => nums.map(Math.round));
|
||||
Q.all<number>(myNums).then((nums) => nums.map(Math.round));
|
||||
|
||||
Q.fbind((dateString?: string) => new Date(dateString), "11/11/1991")().then(d => d.toLocaleDateString());
|
||||
Q.fbind((dateString?: string) => new Date(<string> dateString), "11/11/1991")().then((d) => d.toLocaleDateString());
|
||||
|
||||
Q.when(8, num => num + "!");
|
||||
Q.when(Q(8), num => num + "!").then(str => str.split(','));
|
||||
Q.when(8, (num) => num + "!");
|
||||
Q.when(Q(8), (num) => num + "!").then((str) => str.split(','));
|
||||
const voidPromise: Q.Promise<void> = Q.when();
|
||||
|
||||
declare function saveToDisk(): Q.Promise<any>;
|
||||
@@ -147,22 +151,27 @@ Q.nfapply<string>(nodeStyle, ["foo"]).done((result: string) => {
|
||||
});
|
||||
Q.nfcall<string>(nodeStyle, "foo").done((result: string) => {
|
||||
});
|
||||
Q.denodeify<string>(nodeStyle)('foo').done((result: string) => {
|
||||
Q.denodeify<string>(nodeStyle)("foo").done((result: string) => {
|
||||
});
|
||||
Q.nfbind<string>(nodeStyle)('foo').done((result: string) => {
|
||||
Q.nfbind<string>(nodeStyle)("foo").done((result: string) => {
|
||||
});
|
||||
|
||||
interface Kitty {
|
||||
name: string;
|
||||
cute: boolean;
|
||||
}
|
||||
|
||||
class Repo {
|
||||
private readonly items: any[] = [
|
||||
{name: 'Max', cute: false},
|
||||
{name: 'Annie', cute: true}
|
||||
private readonly items: Kitty[] = [
|
||||
{name: "Max", cute: false},
|
||||
{name: "Annie", cute: true}
|
||||
];
|
||||
|
||||
find(options: any): Q.Promise<any[]> {
|
||||
find(options: {[K in keyof Kitty]: Kitty[K] }): Q.Promise<Kitty[]> {
|
||||
let result = this.items;
|
||||
|
||||
for (const key in options) {
|
||||
result = result.filter(i => i[key] === options[key]);
|
||||
result = result.filter((i) => i[<keyof Kitty> key] === options[<keyof Kitty> key]);
|
||||
}
|
||||
|
||||
return Q(result);
|
||||
@@ -170,7 +179,8 @@ class Repo {
|
||||
}
|
||||
|
||||
const kitty = new Repo();
|
||||
Q.nbind<any[]>(kitty.find, kitty)({cute: true}).done((kitties: any[]) => {
|
||||
Q.nbind<Kitty[]>(kitty.find, kitty)({ cute: true }).done((kitties) => {
|
||||
const _kitties: Kitty[] = kitties;
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -194,10 +204,6 @@ function TestCanRethrowRejectedPromises() {
|
||||
.fail((error) => {
|
||||
console.log("Intermediate error handling");
|
||||
|
||||
/*
|
||||
* Cannot do this, because:
|
||||
* error TS2322: Type 'Promise<void>' is not assignable to type 'Promise<Foo>'
|
||||
*/
|
||||
return Q.reject<Foo>(error);
|
||||
});
|
||||
}
|
||||
@@ -206,10 +212,14 @@ function TestCanRethrowRejectedPromises() {
|
||||
.finally(() => {
|
||||
console.log("Cleanup");
|
||||
})
|
||||
.done();
|
||||
.done((foo) => {
|
||||
const _foo: Foo = foo;
|
||||
});
|
||||
}
|
||||
|
||||
// test Q.Promise.all
|
||||
/**
|
||||
* test Q.Promise.all
|
||||
*/
|
||||
const y1 = Q().then(() => {
|
||||
const s = Q("hello");
|
||||
const n = Q(1);
|
||||
@@ -222,9 +232,9 @@ const y2 = Q().then(() => {
|
||||
return <[typeof s, typeof n]> [s, n];
|
||||
});
|
||||
|
||||
const p2: Q.Promise<[string, number]> = y1.then(val => Q.all(val));
|
||||
const p2: Q.Promise<[string, number]> = y1.then((val) => Q.all(val));
|
||||
const p3: Q.Promise<[string, number]> = Q.all(y1);
|
||||
const p5: Q.Promise<[string, number]> = y2.then(val => Q.all(val));
|
||||
const p5: Q.Promise<[string, number]> = y2.then((val) => Q.all(val));
|
||||
const p6: Q.Promise<[string, number]> = Q.all(y2);
|
||||
|
||||
Q.try(() => {
|
||||
@@ -238,8 +248,8 @@ Q.try(() => {
|
||||
// thenReject, returning a Promise of the same type as the Promise it is called on
|
||||
function thenRejectSameType(arg: any): Q.Promise<number> {
|
||||
if (!arg) {
|
||||
return returnsNumPromise('')
|
||||
.thenReject(new Error('failed'));
|
||||
return returnsNumPromise("")
|
||||
.thenReject(new Error("failed"));
|
||||
}
|
||||
return Q.resolve(2);
|
||||
}
|
||||
@@ -248,10 +258,10 @@ function thenRejectSameType(arg: any): Q.Promise<number> {
|
||||
// The generic type argument is specified.
|
||||
function thenRejectSpecificOtherType(arg: any): Q.Promise<string> {
|
||||
if (!arg) {
|
||||
return returnsNumPromise('')
|
||||
.thenReject<string>(new Error('failed'));
|
||||
return returnsNumPromise("")
|
||||
.thenReject<string>(new Error("failed"));
|
||||
}
|
||||
return Q.resolve('');
|
||||
return Q.resolve("");
|
||||
}
|
||||
|
||||
// thenReject, returning a Promise of a different type to the Promise it is called on.
|
||||
@@ -262,9 +272,9 @@ function thenRejectSpecificOtherType(arg: any): Q.Promise<string> {
|
||||
/*
|
||||
function thenRejectInferredOtherType(arg: any): Q.Promise<string> {
|
||||
if (!arg) {
|
||||
return returnsNumPromise('')
|
||||
.thenReject(new Error('failed'));
|
||||
return returnsNumPromise("")
|
||||
.thenReject(new Error("failed"));
|
||||
}
|
||||
return Q.resolve('');
|
||||
return Q.resolve("");
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"strictFunctionTypes": false,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
|
||||
Vendored
+3
-3
@@ -5,12 +5,12 @@
|
||||
// TypeScript Version: 2.6
|
||||
|
||||
import { Component } from 'react';
|
||||
import { Options } from 'flatpickr';
|
||||
import flatpickr from 'flatpickr';
|
||||
|
||||
export interface DateTimePickerProps {
|
||||
defaultValue?: string;
|
||||
options?: Options.Options;
|
||||
onChange?: Options.Hook;
|
||||
options?: flatpickr.Options.Options;
|
||||
onChange?: flatpickr.Options.Hook;
|
||||
value?: string;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Instance } from 'flatpickr';
|
||||
import flatpickr from 'flatpickr';
|
||||
import * as React from 'react';
|
||||
import DatePicker from 'react-flatpickr';
|
||||
|
||||
@@ -12,7 +12,7 @@ const options = {
|
||||
const optionsElement = <DatePicker options={ options }/>;
|
||||
|
||||
const onChange = (
|
||||
selectedDates: Date[], dateStr: string, instance: Instance,
|
||||
selectedDates: Date[], dateStr: string, instance: flatpickr.Instance,
|
||||
elem: HTMLElement
|
||||
) => null;
|
||||
const onChangeElement = <DatePicker onChange={ onChange }/>;
|
||||
|
||||
Vendored
+7
-4
@@ -1044,10 +1044,12 @@ export type KeyboardTypeIOS =
|
||||
| "twitter"
|
||||
| "web-search";
|
||||
export type KeyboardTypeAndroid = "visible-password";
|
||||
export type KeyboardTypeOptions = KeyboardType | KeyboardTypeAndroid | KeyboardTypeIOS
|
||||
|
||||
export type ReturnKeyType = "done" | "go" | "next" | "search" | "send";
|
||||
export type ReturnKeyTypeAndroid = "none" | "previous";
|
||||
export type ReturnKeyTypeIOS = "default" | "google" | "join" | "route" | "yahoo" | "emergency-call";
|
||||
export type ReturnKeyTypeOptions = ReturnKeyType | ReturnKeyTypeAndroid | ReturnKeyTypeIOS
|
||||
|
||||
/**
|
||||
* @see https://facebook.github.io/react-native/docs/textinput.html#props
|
||||
@@ -1103,7 +1105,7 @@ export interface TextInputProperties
|
||||
* The following values work on iOS: - ascii-capable - numbers-and-punctuation - url - number-pad - name-phone-pad - decimal-pad - twitter - web-search
|
||||
* The following values work on Android: - visible-password
|
||||
*/
|
||||
keyboardType?: KeyboardType | KeyboardTypeIOS | KeyboardTypeAndroid;
|
||||
keyboardType?: KeyboardTypeOptions;
|
||||
|
||||
/**
|
||||
* Limits the maximum number of characters that can be entered.
|
||||
@@ -1184,7 +1186,7 @@ export interface TextInputProperties
|
||||
* enum('default', 'go', 'google', 'join', 'next', 'route', 'search', 'send', 'yahoo', 'done', 'emergency-call')
|
||||
* Determines how the return key should look.
|
||||
*/
|
||||
returnKeyType?: ReturnKeyType | ReturnKeyTypeAndroid | ReturnKeyTypeIOS;
|
||||
returnKeyType?: ReturnKeyTypeOptions;
|
||||
|
||||
/**
|
||||
* If true, the text input obscures the text entered so that sensitive text like passwords stay secure.
|
||||
@@ -1524,7 +1526,7 @@ export interface GestureResponderHandlers {
|
||||
* So if a parent View wants to prevent the child from becoming responder on a touch start,
|
||||
* it should have a onStartShouldSetResponderCapture handler which returns true.
|
||||
*/
|
||||
onMoveShouldSetResponderCapture?: () => void;
|
||||
onMoveShouldSetResponderCapture?: (event: GestureResponderEvent) => boolean;
|
||||
}
|
||||
|
||||
// @see https://facebook.github.io/react-native/docs/view.html#style
|
||||
@@ -3292,6 +3294,7 @@ interface ImagePropertiesAndroid {
|
||||
/**
|
||||
* @see https://facebook.github.io/react-native/docs/image.html
|
||||
*/
|
||||
export type ImagePropertiesSourceOptions = ImageURISource | ImageURISource[] | ImageRequireSource;
|
||||
export interface ImageProperties extends ImagePropertiesIOS, ImagePropertiesAndroid, AccessibilityProperties {
|
||||
/**
|
||||
* onLayout function
|
||||
@@ -3387,7 +3390,7 @@ export interface ImageProperties extends ImagePropertiesIOS, ImagePropertiesAndr
|
||||
* their width and height. The native side will then choose the best `uri` to display
|
||||
* based on the measured size of the image container.
|
||||
*/
|
||||
source: ImageURISource | ImageURISource[] | ImageRequireSource;
|
||||
source: ImagePropertiesSourceOptions;
|
||||
|
||||
/**
|
||||
* similarly to `source`, this property represents the resource used to render
|
||||
|
||||
Vendored
+11
-9
@@ -173,14 +173,15 @@ export type NavigationScreenConfig<Options> =
|
||||
}) => Options);
|
||||
|
||||
export type NavigationComponent =
|
||||
NavigationScreenComponent<any, any>
|
||||
NavigationScreenComponent<any, any, any>
|
||||
| NavigationNavigator<any, any, any>;
|
||||
|
||||
export type NavigationScreenComponent<
|
||||
Params = NavigationParams,
|
||||
Options = {},
|
||||
Props = {}
|
||||
> = React.ComponentType<NavigationNavigatorProps<Options, NavigationState> & Props> &
|
||||
({} | { navigationOptions: NavigationScreenConfig<Options> });
|
||||
> = React.ComponentType<NavigationScreenProps<Params, Options> & Props> &
|
||||
{ navigationOptions?: NavigationScreenConfig<Options> };
|
||||
|
||||
export type NavigationNavigator<
|
||||
State = NavigationState,
|
||||
@@ -429,16 +430,17 @@ export interface NavigationScreenProp<S, P = NavigationParams> {
|
||||
goBack: (routeKey?: string | null) => boolean;
|
||||
navigate(options: {
|
||||
routeName: string;
|
||||
params?: P;
|
||||
params?: NavigationParams;
|
||||
action?: NavigationAction;
|
||||
key?: string;
|
||||
}): boolean;
|
||||
navigate(
|
||||
routeNameOrOptions: string,
|
||||
params?: P,
|
||||
params?: NavigationParams,
|
||||
action?: NavigationAction,
|
||||
): boolean;
|
||||
setParams: (newParams: NavigationParams) => boolean;
|
||||
getParam: <T extends keyof P>(param: T, fallback?: P[T]) => P[T];
|
||||
setParams: (newParams: P) => boolean;
|
||||
addListener: (
|
||||
eventName: string,
|
||||
callback: NavigationEventCallback
|
||||
@@ -858,10 +860,10 @@ export function createNavigationContainer(
|
||||
* BEGIN CUSTOM CONVENIENCE INTERFACES
|
||||
*/
|
||||
|
||||
export interface NavigationScreenProps<Params = NavigationParams> {
|
||||
navigation: NavigationScreenProp<NavigationRoute<Params>>;
|
||||
export interface NavigationScreenProps<Params = NavigationParams, Options = any> {
|
||||
navigation: NavigationScreenProp<NavigationRoute<Params>, Params>;
|
||||
screenProps?: { [key: string]: any };
|
||||
navigationOptions?: NavigationScreenConfig<any>;
|
||||
navigationOptions?: NavigationScreenConfig<Options>;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -100,7 +100,7 @@ class NextScreen extends React.Component<NavigationScreenProps<NextScreenNavigat
|
||||
// Implicit type checks.
|
||||
const navigationStateParams: NextScreenNavigationParams | undefined = this.props.navigation.state.params;
|
||||
const id = this.props.navigation.state.params && this.props.navigation.state.params.id;
|
||||
const name = this.props.navigation.state.params && this.props.navigation.state.params.name;
|
||||
const name = this.props.navigation.getParam('name', 'Peter');
|
||||
|
||||
return (
|
||||
<View />
|
||||
@@ -134,7 +134,14 @@ export const AppNavigator = StackNavigator(
|
||||
},
|
||||
);
|
||||
|
||||
const StatelessScreen: NavigationScreenComponent = () => <View />;
|
||||
interface StatelessScreenParams {
|
||||
testID: string;
|
||||
}
|
||||
|
||||
const StatelessScreen: NavigationScreenComponent<StatelessScreenParams> = (props) =>
|
||||
<View testID={props.navigation.getParam('testID', 'fallback')}/>;
|
||||
|
||||
StatelessScreen.navigationOptions = { title: 'Stateless' };
|
||||
|
||||
const SimpleStackNavigator = StackNavigator(
|
||||
{
|
||||
|
||||
Vendored
+4
@@ -2,6 +2,7 @@
|
||||
// Project: https://github.com/ReactTraining/react-router/tree/master/packages/react-router-redux
|
||||
// Definitions by: Huy Nguyen <https://github.com/huy-nguyen>
|
||||
// Shoya Tanaka <https://github.com/8398a7>
|
||||
// Mykolas <https://github.com/mykolas>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.6
|
||||
|
||||
@@ -19,6 +20,7 @@ import {
|
||||
LocationDescriptor
|
||||
} from 'history';
|
||||
import * as React from 'react';
|
||||
import { match } from 'react-router';
|
||||
|
||||
export interface ConnectedRouterProps<State> {
|
||||
store?: Store<State>;
|
||||
@@ -77,3 +79,5 @@ export interface LocationChangeAction {
|
||||
}
|
||||
|
||||
export function routerMiddleware(history: History): Middleware;
|
||||
|
||||
export function createMatchSelector(path: string): (state: { router: RouterState }) => match<{}> | null;
|
||||
|
||||
@@ -7,7 +7,7 @@ import { Provider } from 'react-redux';
|
||||
import createHistory from 'history/createBrowserHistory';
|
||||
import { Route } from 'react-router';
|
||||
|
||||
import { ConnectedRouter, routerReducer, routerMiddleware, push, RouterState } from 'react-router-redux';
|
||||
import { ConnectedRouter, routerReducer, routerMiddleware, push, RouterState, createMatchSelector } from 'react-router-redux';
|
||||
|
||||
// Create a history of your choosing (we're using a browser history in this case)
|
||||
const history = createHistory();
|
||||
@@ -44,3 +44,7 @@ ReactDOM.render(
|
||||
|
||||
// Now you can dispatch navigation actions from anywhere!
|
||||
store.dispatch(push('/foo'));
|
||||
|
||||
// And match location path using createMatchSelector
|
||||
const matchSelector = createMatchSelector('/:foo');
|
||||
const match = matchSelector(store.getState());
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user