mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-03 22:37:03 +00:00
Merge branch 'master' of https://github.com/segayuu/DefinitelyTyped into bluebird-retry-cleanup-ignore-lint-errors
This commit is contained in:
+12
-17
@@ -1,13 +1,13 @@
|
||||
import acorn = require('acorn');
|
||||
import * as ESTree from 'estree';
|
||||
|
||||
declare var token: acorn.Token;
|
||||
declare var tokens: acorn.Token[];
|
||||
declare var comment: acorn.Comment;
|
||||
declare var comments: acorn.Comment[];
|
||||
declare var program: ESTree.Program;
|
||||
var any: any;
|
||||
var string: string;
|
||||
declare let token: acorn.Token;
|
||||
declare let tokens: acorn.Token[];
|
||||
declare let comment: acorn.Comment;
|
||||
declare let comments: acorn.Comment[];
|
||||
declare let program: ESTree.Program;
|
||||
let any: any;
|
||||
let string: string;
|
||||
|
||||
// acorn
|
||||
string = acorn.version;
|
||||
@@ -32,16 +32,12 @@ const parser = new acorn.Parser({}, 'export default ""', 0);
|
||||
const node = new acorn.Node(parser, 1, 1);
|
||||
|
||||
class LooseParser {
|
||||
constructor(input: string, options = {}) {
|
||||
|
||||
}
|
||||
constructor(input: string, options = {}) {}
|
||||
|
||||
// this means you can extend LooseParser
|
||||
test() {
|
||||
|
||||
}
|
||||
test() {}
|
||||
}
|
||||
acorn.addLooseExports(function () {
|
||||
acorn.addLooseExports(() => {
|
||||
return {
|
||||
type: 'Program',
|
||||
sourceType: 'script',
|
||||
@@ -50,7 +46,7 @@ acorn.addLooseExports(function () {
|
||||
type: 'EmptyStatement'
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
||||
}, LooseParser, {});
|
||||
|
||||
acorn.parseExpressionAt('string', 2);
|
||||
@@ -63,8 +59,7 @@ acorn.isIdentifierChar(56);
|
||||
|
||||
acorn.getLineInfo('string', 56);
|
||||
|
||||
acorn.plugins['test'] = function (p: acorn.Parser, config: any) {
|
||||
}
|
||||
acorn.plugins['test'] = (p: acorn.Parser, config: any) => {};
|
||||
|
||||
acorn.tokenizer('console.log("hello world)', {locations: true}).getToken();
|
||||
acorn.tokenizer('console.log("hello world)', {locations: true})[Symbol.iterator]().next();
|
||||
|
||||
Vendored
+9
-14
@@ -1,10 +1,8 @@
|
||||
// Type definitions for Acorn v4.0.3
|
||||
// Type definitions for Acorn 4.0
|
||||
// Project: https://github.com/marijnh/acorn
|
||||
// Definitions by: RReverser <https://github.com/RReverser>, e-cloud <https://github.com/e-cloud>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="estree" />
|
||||
|
||||
export as namespace acorn;
|
||||
export = acorn;
|
||||
import * as ESTree from 'estree';
|
||||
@@ -181,7 +179,7 @@ declare namespace acorn {
|
||||
_typeof: TokenType;
|
||||
_void: TokenType;
|
||||
_delete: TokenType;
|
||||
}
|
||||
};
|
||||
|
||||
class TokContext {
|
||||
constructor(token: string, isExpr: boolean, preserveSpace: boolean, override: (p: Parser) => void);
|
||||
@@ -230,19 +228,18 @@ declare namespace acorn {
|
||||
|
||||
const version: string;
|
||||
|
||||
interface IParse {
|
||||
(input: string, options?: Options): ESTree.Program;
|
||||
}
|
||||
// TODO: rename type.
|
||||
type IParse = (input: string, options?: Options) => ESTree.Program;
|
||||
|
||||
const parse: IParse;
|
||||
|
||||
function parseExpressionAt(input: string, pos?: number, options?: Options): ESTree.Expression;
|
||||
|
||||
interface ITokenizer {
|
||||
getToken() : Token,
|
||||
[Symbol.iterator](): Iterator<Token>
|
||||
getToken(): Token;
|
||||
[Symbol.iterator](): Iterator<Token>;
|
||||
}
|
||||
|
||||
|
||||
function tokenizer(input: string, options: Options): ITokenizer;
|
||||
|
||||
let parse_dammit: IParse | undefined;
|
||||
@@ -250,12 +247,10 @@ declare namespace acorn {
|
||||
let pluginsLoose: PluginsObject | undefined;
|
||||
|
||||
interface ILooseParserClass {
|
||||
new (input: string, options?: Options): ILooseParser
|
||||
new (input: string, options?: Options): ILooseParser;
|
||||
}
|
||||
|
||||
interface ILooseParser {
|
||||
|
||||
}
|
||||
interface ILooseParser {}
|
||||
|
||||
function addLooseExports(parse: IParse, parser: ILooseParserClass, plugins: PluginsObject): void;
|
||||
}
|
||||
|
||||
+1
-71
@@ -1,79 +1,9 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"adjacent-overload-signatures": false,
|
||||
"array-type": false,
|
||||
"arrow-return-shorthand": false,
|
||||
"ban-types": false,
|
||||
"callable-types": false,
|
||||
"comment-format": false,
|
||||
"dt-header": false,
|
||||
"eofline": false,
|
||||
"export-just-namespace": false,
|
||||
"import-spacing": false,
|
||||
"interface-name": false,
|
||||
"interface-over-type-literal": false,
|
||||
"jsdoc-format": false,
|
||||
"max-line-length": false,
|
||||
"member-access": false,
|
||||
"new-parens": false,
|
||||
"no-any-union": false,
|
||||
"no-boolean-literal-compare": false,
|
||||
"no-conditional-assignment": false,
|
||||
"no-consecutive-blank-lines": false,
|
||||
"no-construct": false,
|
||||
"no-declare-current-package": false,
|
||||
"no-duplicate-imports": false,
|
||||
"no-duplicate-variable": false,
|
||||
"no-empty-interface": false,
|
||||
"no-for-in-array": false,
|
||||
"no-inferrable-types": false,
|
||||
"no-internal-module": false,
|
||||
"no-irregular-whitespace": false,
|
||||
"no-mergeable-namespace": false,
|
||||
"no-misused-new": false,
|
||||
"no-namespace": false,
|
||||
"no-object-literal-type-assertion": false,
|
||||
"no-padding": false,
|
||||
"no-redundant-jsdoc": false,
|
||||
"no-redundant-jsdoc-2": false,
|
||||
"no-redundant-undefined": false,
|
||||
"no-reference-import": false,
|
||||
"no-relative-import-in-test": false,
|
||||
"no-self-import": false,
|
||||
"no-single-declare-module": false,
|
||||
"no-string-throw": false,
|
||||
"no-unnecessary-callback-wrapper": false,
|
||||
"no-unnecessary-class": false,
|
||||
"no-unnecessary-generics": false,
|
||||
"no-unnecessary-qualifier": false,
|
||||
"no-unnecessary-type-assertion": false,
|
||||
"no-useless-files": false,
|
||||
"no-var-keyword": false,
|
||||
"no-var-requires": false,
|
||||
"no-void-expression": false,
|
||||
"no-trailing-whitespace": false,
|
||||
"object-literal-key-quotes": false,
|
||||
"object-literal-shorthand": false,
|
||||
"one-line": false,
|
||||
"one-variable-per-declaration": false,
|
||||
"only-arrow-functions": false,
|
||||
"prefer-conditional-expression": false,
|
||||
"prefer-const": false,
|
||||
"prefer-declare-function": false,
|
||||
"prefer-for-of": false,
|
||||
"prefer-method-signature": false,
|
||||
"prefer-template": false,
|
||||
"radix": false,
|
||||
"semicolon": false,
|
||||
"space-before-function-paren": false,
|
||||
"space-within-parens": false,
|
||||
"strict-export-declare-modifiers": false,
|
||||
"trim-file": false,
|
||||
"triple-equals": false,
|
||||
"typedef-whitespace": false,
|
||||
"unified-signatures": false,
|
||||
"void-return": false,
|
||||
"whitespace": false
|
||||
"no-unnecessary-class": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1324,3 +1324,35 @@ function toPromise<T>(val: T): ng.IPromise<T> {
|
||||
const p: ng.IPromise<T> = null;
|
||||
return p;
|
||||
}
|
||||
|
||||
const directiveCompileFn: ng.IDirectiveCompileFn = (
|
||||
templateElement: JQLite,
|
||||
templateAttributes: ng.IAttributes,
|
||||
transclude: ng.ITranscludeFunction
|
||||
): ng.IDirectiveLinkFn => {
|
||||
return (
|
||||
scope: ng.IScope,
|
||||
instanceElement: JQLite,
|
||||
instanceAttributes: ng.IAttributes
|
||||
) => {
|
||||
return null;
|
||||
};
|
||||
};
|
||||
|
||||
interface MyScope extends ng.IScope {
|
||||
foo: string;
|
||||
}
|
||||
|
||||
const directiveCompileFnWithGeneric: ng.IDirectiveCompileFn<MyScope> = (
|
||||
templateElement: JQLite,
|
||||
templateAttributes: ng.IAttributes,
|
||||
transclude: ng.ITranscludeFunction
|
||||
): ng.IDirectiveLinkFn<MyScope> => {
|
||||
return (
|
||||
scope: MyScope,
|
||||
instanceElement: JQLite,
|
||||
instanceAttributes: ng.IAttributes
|
||||
) => {
|
||||
return null;
|
||||
};
|
||||
};
|
||||
|
||||
Vendored
+6
-6
@@ -229,8 +229,8 @@ declare namespace angular {
|
||||
* @param name Name of the directive in camel-case (i.e. ngBind which will match as ng-bind)
|
||||
* @param directiveFactory An injectable directive factory function.
|
||||
*/
|
||||
directive<TScope extends IScope>(name: string, directiveFactory: Injectable<IDirectiveFactory<TScope>>): IModule;
|
||||
directive<TScope extends IScope>(object: {[directiveName: string]: Injectable<IDirectiveFactory<TScope>>}): IModule;
|
||||
directive<TScope extends IScope = IScope>(name: string, directiveFactory: Injectable<IDirectiveFactory<TScope>>): IModule;
|
||||
directive<TScope extends IScope = IScope>(object: {[directiveName: string]: Injectable<IDirectiveFactory<TScope>>}): IModule;
|
||||
/**
|
||||
* Register a service factory, which will be called to return the service instance. This is short for registering a service where its provider consists of only a $get property, which is the given service factory function. You should use $provide.factory(getFn) if you do not need to configure your service in a provider.
|
||||
*
|
||||
@@ -1249,8 +1249,8 @@ declare namespace angular {
|
||||
}
|
||||
|
||||
interface ICompileProvider extends IServiceProvider {
|
||||
directive<TScope extends IScope>(name: string, directiveFactory: Injectable<IDirectiveFactory<TScope>>): ICompileProvider;
|
||||
directive<TScope extends IScope>(object: {[directiveName: string]: Injectable<IDirectiveFactory<TScope>>}): ICompileProvider;
|
||||
directive<TScope extends IScope = IScope>(name: string, directiveFactory: Injectable<IDirectiveFactory<TScope>>): ICompileProvider;
|
||||
directive<TScope extends IScope = IScope>(object: {[directiveName: string]: Injectable<IDirectiveFactory<TScope>>}): ICompileProvider;
|
||||
|
||||
component(name: string, options: IComponentOptions): ICompileProvider;
|
||||
|
||||
@@ -1983,12 +1983,12 @@ declare namespace angular {
|
||||
): void;
|
||||
}
|
||||
|
||||
interface IDirectivePrePost<TScope extends IScope> {
|
||||
interface IDirectivePrePost<TScope extends IScope = IScope> {
|
||||
pre?: IDirectiveLinkFn<TScope>;
|
||||
post?: IDirectiveLinkFn<TScope>;
|
||||
}
|
||||
|
||||
interface IDirectiveCompileFn<TScope extends IScope> {
|
||||
interface IDirectiveCompileFn<TScope extends IScope = IScope> {
|
||||
(
|
||||
templateElement: JQLite,
|
||||
templateAttributes: IAttributes,
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { Disposable } from "event-kit";
|
||||
import KeymapManager = require("atom-keymap");
|
||||
import * as ImportTest from "atom-keymap";
|
||||
|
||||
declare const element: HTMLElement;
|
||||
declare let sub: EventKit.Disposable;
|
||||
declare let sub: Disposable;
|
||||
declare const event: KeyboardEvent;
|
||||
|
||||
// NPM Examples ===============================================================
|
||||
|
||||
Vendored
+35
-23
@@ -4,15 +4,17 @@
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
/// <reference types="event-kit" />
|
||||
import { Disposable } from "event-kit";
|
||||
|
||||
declare global {
|
||||
namespace AtomKeymap {
|
||||
/** The event objects that are passed into the callbacks which the user provides to
|
||||
/**
|
||||
* The event objects that are passed into the callbacks which the user provides to
|
||||
* specific API calls.
|
||||
*/
|
||||
namespace Events {
|
||||
/** This custom subclass of CustomEvent exists to provide the ::abortKeyBinding
|
||||
/**
|
||||
* This custom subclass of CustomEvent exists to provide the ::abortKeyBinding
|
||||
* method, as well as versions of the ::stopPropagation methods that record the
|
||||
* intent to stop propagation so event bubbling can be properly simulated for
|
||||
* detached elements.
|
||||
@@ -70,12 +72,14 @@ declare global {
|
||||
}
|
||||
|
||||
interface AddedKeystrokeResolver {
|
||||
/** The currently resolved keystroke string. If your function returns a falsy
|
||||
/**
|
||||
* The currently resolved keystroke string. If your function returns a falsy
|
||||
* value, this is how Atom will resolve your keystroke.
|
||||
*/
|
||||
keystroke: string;
|
||||
|
||||
/** The raw DOM 3 `KeyboardEvent` being resolved. See the DOM API documentation
|
||||
/**
|
||||
* The raw DOM 3 `KeyboardEvent` being resolved. See the DOM API documentation
|
||||
* for more details.
|
||||
*/
|
||||
event: KeyboardEvent;
|
||||
@@ -83,7 +87,8 @@ declare global {
|
||||
/** The OS-specific name of the current keyboard layout. */
|
||||
layoutName: string;
|
||||
|
||||
/** An object mapping DOM 3 `KeyboardEvent.code` values to objects with the
|
||||
/**
|
||||
* An object mapping DOM 3 `KeyboardEvent.code` values to objects with the
|
||||
* typed character for that key in each modifier state, based on the current
|
||||
* operating system layout.
|
||||
*/
|
||||
@@ -91,7 +96,8 @@ declare global {
|
||||
}
|
||||
}
|
||||
|
||||
/** The option objects that the user is expected to fill out and provide to
|
||||
/**
|
||||
* The option objects that the user is expected to fill out and provide to
|
||||
* specific API calls.
|
||||
*/
|
||||
namespace Options {
|
||||
@@ -120,7 +126,8 @@ declare global {
|
||||
/** Determines whether the given keystroke matches any contained within this binding. */
|
||||
matches(keystroke: string): boolean;
|
||||
|
||||
/** Compare another KeyBinding to this instance.
|
||||
/**
|
||||
* Compare another KeyBinding to this instance.
|
||||
* Returns <= -1 if the argument is considered lesser or of lower priority.
|
||||
* Returns 0 if this binding is equivalent to the argument.
|
||||
* Returns >= 1 if the argument is considered greater or of higher priority.
|
||||
@@ -128,7 +135,8 @@ declare global {
|
||||
compare(other: KeyBinding): number;
|
||||
}
|
||||
|
||||
/** Allows commands to be associated with keystrokes in a context-sensitive way.
|
||||
/**
|
||||
* Allows commands to be associated with keystrokes in a context-sensitive way.
|
||||
* In Atom, you can access a global instance of this object via `atom.keymaps`.
|
||||
*/
|
||||
interface KeymapManager {
|
||||
@@ -143,29 +151,30 @@ declare global {
|
||||
destroy(): void;
|
||||
|
||||
// Event Subscription
|
||||
/** Invoke the given callback when one or more keystrokes completely match a key binding. */
|
||||
/**
|
||||
* Invoke the given callback when one or more keystrokes completely match a
|
||||
* key binding.
|
||||
*/
|
||||
onDidMatchBinding(callback: (event: Events.FullKeybindingMatch) => void):
|
||||
EventKit.Disposable;
|
||||
Disposable;
|
||||
|
||||
/** Invoke the given callback when one or more keystrokes partially match a binding. */
|
||||
onDidPartiallyMatchBindings(callback: (event: Events.PartialKeybindingMatch) =>
|
||||
void): EventKit.Disposable;
|
||||
void): Disposable;
|
||||
|
||||
/** Invoke the given callback when one or more keystrokes fail to match any bindings. */
|
||||
onDidFailToMatchBinding(callback: (event: Events.FailedKeybindingMatch) =>
|
||||
void): EventKit.Disposable;
|
||||
void): Disposable;
|
||||
|
||||
/** Invoke the given callback when a keymap file is reloaded. */
|
||||
onDidReloadKeymap(callback: (event: Events.KeymapLoaded) => void):
|
||||
EventKit.Disposable;
|
||||
onDidReloadKeymap(callback: (event: Events.KeymapLoaded) => void): Disposable;
|
||||
|
||||
/** Invoke the given callback when a keymap file is unloaded. */
|
||||
onDidUnloadKeymap(callback: (event: Events.KeymapLoaded) => void):
|
||||
EventKit.Disposable;
|
||||
onDidUnloadKeymap(callback: (event: Events.KeymapLoaded) => void): Disposable;
|
||||
|
||||
/** Invoke the given callback when a keymap file not able to be loaded. */
|
||||
onDidFailToReadFile(callback: (error: Events.FailedKeymapFileRead) => void):
|
||||
EventKit.Disposable;
|
||||
Disposable;
|
||||
|
||||
// Adding and Removing Bindings
|
||||
/** Construct KeyBindings from an object grouping them by CSS selector. */
|
||||
@@ -174,7 +183,7 @@ declare global {
|
||||
|
||||
/** Add sets of key bindings grouped by CSS selector. */
|
||||
add(source: string, bindings: { [key: string]: { [key: string]: string }},
|
||||
priority?: number): EventKit.Disposable;
|
||||
priority?: number): Disposable;
|
||||
|
||||
// Accessing Bindings
|
||||
/** Get all current key bindings. */
|
||||
@@ -192,13 +201,15 @@ declare global {
|
||||
loadKeymap(bindingsPath: string, options?: { watch?: boolean, priority?: number }):
|
||||
void;
|
||||
|
||||
/** Cause the keymap to reload the key bindings file at the given path whenever
|
||||
/**
|
||||
* Cause the keymap to reload the key bindings file at the given path whenever
|
||||
* it changes.
|
||||
*/
|
||||
watchKeymap(filePath: string, options?: { priority: number }): void;
|
||||
|
||||
// Managing Keyboard Events
|
||||
/** Dispatch a custom event associated with the matching key binding for the
|
||||
/**
|
||||
* Dispatch a custom event associated with the matching key binding for the
|
||||
* given `KeyboardEvent` if one can be found.
|
||||
*/
|
||||
handleKeyboardEvent(event: KeyboardEvent): void;
|
||||
@@ -208,9 +219,10 @@ declare global {
|
||||
|
||||
/** Customize translation of raw keyboard events to keystroke strings. */
|
||||
addKeystrokeResolver(resolver: (event: Events.AddedKeystrokeResolver) => string):
|
||||
EventKit.Disposable;
|
||||
Disposable;
|
||||
|
||||
/** Get the number of milliseconds allowed before pending states caused by
|
||||
/**
|
||||
* Get the number of milliseconds allowed before pending states caused by
|
||||
* partial matches of multi-keystroke bindings are terminated.
|
||||
*/
|
||||
getPartialMatchTimeout(): number;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": false,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
|
||||
@@ -1,36 +1,8 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"class-name": true,
|
||||
"indent": [true, "spaces", 4],
|
||||
"jsdoc-format": true,
|
||||
"max-line-length": [true, 110],
|
||||
"quotemark": [true, "double", "avoid-escape"],
|
||||
"trailing-comma": [true, {
|
||||
"multiline": { "objects": "always", "arrays": "always", "functions": "never" },
|
||||
"singleline": { "objects": "never", "arrays": "never", "functions": "never" }
|
||||
}],
|
||||
"whitespace": [
|
||||
true,
|
||||
"check-branch",
|
||||
"check-decl",
|
||||
"check-operator",
|
||||
"check-module",
|
||||
"check-separator",
|
||||
"check-type",
|
||||
"check-typecast",
|
||||
"check-rest-spread",
|
||||
"check-preblock"
|
||||
],
|
||||
// Soon to be defaults.
|
||||
"arrow-return-shorthand": [true, "multiline"],
|
||||
"no-any": true,
|
||||
"no-floating-promises": true,
|
||||
"no-unbound-method": true,
|
||||
"no-unsafe-any": true,
|
||||
"number-literal-format": true,
|
||||
"restrict-plus-operands": true,
|
||||
"return-undefined": true,
|
||||
"switch-final-break": true
|
||||
"max-line-length": [true, 100],
|
||||
"no-any": true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { AtomEnvironment, TestRunnerParams } from "atom";
|
||||
import { createRunner } from "atom-mocha-test-runner";
|
||||
import defaultMochaRunner = require("atom-mocha-test-runner");
|
||||
|
||||
@@ -20,12 +21,12 @@ testRunner = createRunner({
|
||||
testSuffixes: ["test.file"],
|
||||
});
|
||||
|
||||
declare const atom: AtomCore.AtomEnvironment;
|
||||
declare const atom: AtomEnvironment;
|
||||
declare const blob: object;
|
||||
declare let num: number;
|
||||
|
||||
async function runTests(): Promise<number> {
|
||||
const runnerArgs: AtomCore.Structures.TestRunnerArgs = {
|
||||
const runnerArgs: TestRunnerParams = {
|
||||
testPaths: ["/var/test"],
|
||||
logFile: "/var/log",
|
||||
headless: false,
|
||||
|
||||
+4
-3
@@ -5,7 +5,8 @@
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
/// <reference types="mocha" />
|
||||
/// <reference types="atom" />
|
||||
|
||||
import { TestRunner } from "atom";
|
||||
|
||||
interface AtomMochaOptions {
|
||||
/** Which reporter to use on the terminal. */
|
||||
@@ -30,9 +31,9 @@ interface AtomMochaOptions {
|
||||
// module.exports = createRunner()
|
||||
// module.exports.createRunner = createRunner
|
||||
// Which is what we're trying to model here.
|
||||
interface TestRunnerExport extends AtomCore.TestRunner {
|
||||
interface TestRunnerExport extends TestRunner {
|
||||
createRunner(options?: AtomMochaOptions, mochaConfigFunction?:
|
||||
(mocha: Mocha) => void): AtomCore.TestRunner;
|
||||
(mocha: Mocha) => void): TestRunner;
|
||||
}
|
||||
|
||||
declare const runner: TestRunnerExport;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": false,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
|
||||
@@ -1,36 +1,8 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"class-name": true,
|
||||
"indent": [true, "spaces", 4],
|
||||
"jsdoc-format": true,
|
||||
"max-line-length": [true, 100],
|
||||
"quotemark": [true, "double", "avoid-escape"],
|
||||
"trailing-comma": [true, {
|
||||
"multiline": { "objects": "always", "arrays": "always", "functions": "never" },
|
||||
"singleline": { "objects": "never", "arrays": "never", "functions": "never" }
|
||||
}],
|
||||
"whitespace": [
|
||||
true,
|
||||
"check-branch",
|
||||
"check-decl",
|
||||
"check-operator",
|
||||
"check-module",
|
||||
"check-separator",
|
||||
"check-type",
|
||||
"check-typecast",
|
||||
"check-rest-spread",
|
||||
"check-preblock"
|
||||
],
|
||||
// Soon to be defaults.
|
||||
"arrow-return-shorthand": [true, "multiline"],
|
||||
"no-any": true,
|
||||
"no-floating-promises": true,
|
||||
"no-unbound-method": true,
|
||||
"no-unsafe-any": true,
|
||||
"number-literal-format": true,
|
||||
"restrict-plus-operands": true,
|
||||
"return-undefined": true,
|
||||
"switch-final-break": true
|
||||
"no-any": true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
## Atom API Type Definitions
|
||||
|
||||
TypeScript type definitions for the [Atom Text Editor](https://atom.io/) public API, which is used to develop packages for the editor. Documentation for the public API can be found [here](https://atom.io/docs/api/v1.21.0/).
|
||||
|
||||
### Exports
|
||||
|
||||
#### The "atom" Variable
|
||||
|
||||
These definitions declare a global static variable named "atom" as ambient. Once these definitions have been referenced within your project, you will be able to access properties and member functions from the [AtomEnvironment](https://atom.io/docs/api/v1.21.0/AtomEnvironment) class off of this variable, as it is an instance of that class.
|
||||
|
||||
```ts
|
||||
if (atom.inDevMode()) {}
|
||||
```
|
||||
|
||||
#### The Atom Namespace
|
||||
|
||||
All of the types used by or referenced by the Atom public API have been pulled into the Atom namespace, providing a consistent and easy way to access each of them, without having to care about where that type actually lives within the Atom codebase.
|
||||
|
||||
```ts
|
||||
function example(buffer: Atom.TextBuffer) {}
|
||||
```
|
||||
|
||||
#### The AtomCore Namespace
|
||||
|
||||
All classes which are core to Atom itself have been provided under the AtomCore namespace.
|
||||
|
||||
```ts
|
||||
function example(cursor: AtomCore.Cursor) {}
|
||||
```
|
||||
|
||||
### Service Type Definitions
|
||||
|
||||
There are many services provided by other Atom packages that you may want to use within your own Atom package. We bundle type definitions for several of these services with these type definitions. All type definitions for services are available only through ES6 imports.
|
||||
|
||||
```ts
|
||||
import { AutocompleteProvider } from "atom/autocomplete-plus";
|
||||
let completionProvider: AutocompleteProvider;
|
||||
```
|
||||
|
||||
The currently supported services are:
|
||||
- [Autocomplete](https://github.com/atom/autocomplete-plus) (atom/autocomplete-plus)
|
||||
- [Linter](https://github.com/atom/linter) (atom/linter)
|
||||
- [Status Bar](https://github.com/atom/status-bar) (atom/status-bar)
|
||||
|
||||
### Exposing Private Methods and Properties
|
||||
|
||||
[Declaration Merging](https://www.typescriptlang.org/docs/handbook/declaration-merging.html) can be used to augment any of the types used within Atom. As an example, if we wanted to reveal the private ```triggerActivationHook``` method within the PackageManager class, then we would create a file with the following contents:
|
||||
|
||||
```ts
|
||||
// <<filename>>.d.ts
|
||||
|
||||
declare namespace AtomCore {
|
||||
interface PackageManager {
|
||||
triggerActivationHook(name: string): void;
|
||||
triggerDeferredActivationHooks(): void;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Once this file is either referenced or included within your project, then this new member function would be freely usable on instances of the PackageManager class without TypeScript reporting errors.
|
||||
+73
-77
@@ -12,59 +12,59 @@ declare let regExp: RegExp;
|
||||
declare let element: HTMLElement;
|
||||
declare let elements: HTMLElement[];
|
||||
declare const div: HTMLDivElement;
|
||||
declare const keyboardEvent: KeyboardEvent;
|
||||
declare const event: KeyboardEvent;
|
||||
|
||||
declare let buffer: TextBuffer.TextBuffer;
|
||||
declare const color: AtomCore.Color;
|
||||
declare let cursor: AtomCore.Cursor;
|
||||
declare let cursors: AtomCore.Cursor[];
|
||||
declare let decoration: AtomCore.Decoration;
|
||||
declare let decorations: AtomCore.Decoration[];
|
||||
declare let decorationLayerProps: AtomCore.Options.DecorationLayerProps;
|
||||
declare let dir: PathWatcher.Directory;
|
||||
declare let dirs: PathWatcher.Directory[];
|
||||
declare let displayMarker: TextBuffer.DisplayMarker;
|
||||
declare let displayMarkers: TextBuffer.DisplayMarker[];
|
||||
declare let displayMarkerLayer: TextBuffer.DisplayMarkerLayer;
|
||||
declare let dock: AtomCore.Dock;
|
||||
declare let editor: AtomCore.TextEditor;
|
||||
declare let editors: AtomCore.TextEditor[];
|
||||
declare let emitter: EventKit.Emitter;
|
||||
declare let file: PathWatcher.File;
|
||||
declare let grammar: FirstMate.Grammar;
|
||||
declare let grammars: FirstMate.Grammar[];
|
||||
declare let gutter: AtomCore.Gutter;
|
||||
declare let gutters: AtomCore.Gutter[];
|
||||
declare let historyPaths: AtomCore.Structures.HistoryProject[];
|
||||
declare let layerDecoration: AtomCore.LayerDecoration;
|
||||
declare let marker: TextBuffer.Marker;
|
||||
declare let markers: TextBuffer.Marker[];
|
||||
declare let markerLayer: TextBuffer.MarkerLayer;
|
||||
declare let notification: AtomCore.Notification;
|
||||
declare let notifications: AtomCore.Notification[];
|
||||
declare let pack: AtomCore.Package;
|
||||
declare let packs: AtomCore.Package[];
|
||||
declare let pane: AtomCore.Pane;
|
||||
declare let panes: AtomCore.Pane[];
|
||||
declare let paneContainer: AtomCore.Dock|AtomCore.WorkspaceCenter;
|
||||
declare let panel: AtomCore.Panel;
|
||||
declare let panels: AtomCore.Panel[];
|
||||
declare let pos: TextBuffer.Point;
|
||||
declare let posArr: TextBuffer.Point[];
|
||||
declare let project: AtomCore.Project;
|
||||
declare let range: TextBuffer.Range;
|
||||
declare let ranges: TextBuffer.Range[];
|
||||
declare let registry: FirstMate.GrammarRegistry;
|
||||
declare let repository: AtomCore.GitRepository;
|
||||
declare let repositories: AtomCore.GitRepository[];
|
||||
declare let scopeDescriptor: AtomCore.ScopeDescriptor;
|
||||
declare let selection: AtomCore.Selection;
|
||||
declare let selections: AtomCore.Selection[];
|
||||
declare let styleManager: AtomCore.StyleManager;
|
||||
declare let subscription: EventKit.Disposable;
|
||||
declare let subscriptions: EventKit.CompositeDisposable;
|
||||
declare let tooltips: AtomCore.Structures.Tooltip[];
|
||||
declare let workspaceCenter: AtomCore.WorkspaceCenter;
|
||||
declare let buffer: Atom.TextBuffer;
|
||||
declare const color: Atom.Color;
|
||||
declare let cursor: Atom.Cursor;
|
||||
declare let cursors: Atom.Cursor[];
|
||||
declare let decoration: Atom.Decoration;
|
||||
declare let decorations: Atom.Decoration[];
|
||||
declare let decorationLayerProps: Atom.DecorationLayerOptions;
|
||||
declare let dir: Atom.Directory;
|
||||
declare let dirs: Atom.Directory[];
|
||||
declare let displayMarker: Atom.DisplayMarker;
|
||||
declare let displayMarkers: Atom.DisplayMarker[];
|
||||
declare let displayMarkerLayer: Atom.DisplayMarkerLayer;
|
||||
declare let dock: Atom.Dock;
|
||||
declare let editor: Atom.TextEditor;
|
||||
declare let editors: Atom.TextEditor[];
|
||||
declare let emitter: Atom.Emitter;
|
||||
declare let file: Atom.File;
|
||||
declare let grammar: Atom.Grammar;
|
||||
declare let grammars: Atom.Grammar[];
|
||||
declare let gutter: Atom.Gutter;
|
||||
declare let gutters: Atom.Gutter[];
|
||||
declare let historyPaths: Atom.ProjectHistory[];
|
||||
declare let layerDecoration: Atom.LayerDecoration;
|
||||
declare let marker: Atom.Marker;
|
||||
declare let markers: Atom.Marker[];
|
||||
declare let markerLayer: Atom.MarkerLayer;
|
||||
declare let notification: Atom.Notification;
|
||||
declare let notifications: Atom.Notification[];
|
||||
declare let pack: Atom.Package;
|
||||
declare let packs: Atom.Package[];
|
||||
declare let pane: Atom.Pane;
|
||||
declare let panes: Atom.Pane[];
|
||||
declare let paneContainer: Atom.Dock|Atom.WorkspaceCenter;
|
||||
declare let panel: Atom.Panel;
|
||||
declare let panels: Atom.Panel[];
|
||||
declare let pos: Atom.Point;
|
||||
declare let posArr: Atom.Point[];
|
||||
declare let project: Atom.Project;
|
||||
declare let range: Atom.Range;
|
||||
declare let ranges: Atom.Range[];
|
||||
declare let registry: Atom.GrammarRegistry;
|
||||
declare let repository: Atom.GitRepository;
|
||||
declare let repositories: Atom.GitRepository[];
|
||||
declare let scopeDescriptor: Atom.ScopeDescriptor;
|
||||
declare let selection: Atom.Selection;
|
||||
declare let selections: Atom.Selection[];
|
||||
declare let styleManager: Atom.StyleManager;
|
||||
declare let subscription: Atom.Disposable;
|
||||
declare let subscriptions: Atom.CompositeDisposable;
|
||||
declare let tooltips: Atom.Tooltip[];
|
||||
declare let workspaceCenter: Atom.WorkspaceCenter;
|
||||
|
||||
// AtomEnvironment ============================================================
|
||||
function testAtomEnvironment() {
|
||||
@@ -125,8 +125,8 @@ function testAtomEnvironment() {
|
||||
});
|
||||
|
||||
subscription = atom.workspace.observeTextEditors((editor) => {
|
||||
subscription = editor.onDidStopChanging((keyboardEvent) => {
|
||||
for (const change of keyboardEvent.changes) {
|
||||
subscription = editor.onDidStopChanging((event) => {
|
||||
for (const change of event.changes) {
|
||||
change.newExtent;
|
||||
}
|
||||
});
|
||||
@@ -276,9 +276,6 @@ function testCommandRegistry() {
|
||||
|
||||
// CompositeDisposable ========================================================
|
||||
function testCompositeDisposable() {
|
||||
// Properties
|
||||
bool = subscriptions.disposed;
|
||||
|
||||
// Construction and Lifecycle
|
||||
subscriptions = new Atom.CompositeDisposable();
|
||||
new Atom.CompositeDisposable(subscription);
|
||||
@@ -482,7 +479,7 @@ function testCursor() {
|
||||
|
||||
// TestRunner =================================================================
|
||||
function testTestRunner() {
|
||||
const testRunner: AtomCore.TestRunner = (params) => {
|
||||
const testRunner: Atom.TestRunner = (params) => {
|
||||
const delegate = params.buildDefaultApplicationDelegate();
|
||||
const environment = params.buildAtomEnvironment({
|
||||
applicationDelegate: delegate,
|
||||
@@ -803,7 +800,6 @@ function testDisplayMarkerLayer() {
|
||||
|
||||
// Disposable =================================================================
|
||||
function testDisposable() {
|
||||
bool = subscription.disposed;
|
||||
if (subscription.disposalAction) subscription.disposalAction();
|
||||
subscription.dispose();
|
||||
}
|
||||
@@ -847,8 +843,6 @@ function testDock() {
|
||||
function testEmitter() {
|
||||
emitter = new Atom.Emitter();
|
||||
|
||||
bool = emitter.disposed;
|
||||
|
||||
emitter.clear();
|
||||
emitter.dispose();
|
||||
|
||||
@@ -1113,7 +1107,7 @@ function testKeymapManager() {
|
||||
subscription = manager.add("a", {}, 0);
|
||||
|
||||
// Accessing Bindings
|
||||
let bindings: AtomKeymap.KeyBinding[] = manager.getKeyBindings();
|
||||
let bindings: Atom.KeyBinding[] = manager.getKeyBindings();
|
||||
bindings = manager.findKeyBindings();
|
||||
bindings = manager.findKeyBindings({ command: "a" });
|
||||
bindings = manager.findKeyBindings({ keystrokes: "a" });
|
||||
@@ -1127,8 +1121,8 @@ function testKeymapManager() {
|
||||
manager.loadKeymap("Test.file", { watch: true, priority: 0});
|
||||
|
||||
// Managing Keyboard Events
|
||||
manager.handleKeyboardEvent(keyboardEvent);
|
||||
manager.keystrokeForKeyboardEvent(keyboardEvent);
|
||||
manager.handleKeyboardEvent(event);
|
||||
manager.keystrokeForKeyboardEvent(event);
|
||||
|
||||
subscription = manager.addKeystrokeResolver((event): string => {
|
||||
event.layoutName;
|
||||
@@ -1151,10 +1145,6 @@ function testLayerDecoration() {
|
||||
function testMarker() {
|
||||
// Properties
|
||||
num = marker.id;
|
||||
bool = marker.tailed;
|
||||
bool = marker.reversed;
|
||||
bool = marker.valid;
|
||||
str = marker.invalidate;
|
||||
|
||||
// Lifecycle
|
||||
marker = marker.copy({
|
||||
@@ -1301,8 +1291,8 @@ function testNotification() {
|
||||
});
|
||||
|
||||
// Event Subscription
|
||||
subscription = notification.onDidDismiss(notification => notification.dismissed);
|
||||
subscription = notification.onDidDisplay(notification => notification.timestamp);
|
||||
subscription = notification.onDidDismiss(notification => notification.getType());
|
||||
subscription = notification.onDidDisplay(notification => notification.getMessage());
|
||||
|
||||
// Methods
|
||||
str = notification.getType();
|
||||
@@ -1377,7 +1367,7 @@ function testPackageManager() {
|
||||
subscription = atom.packages.onDidActivatePackage(pack => pack.name);
|
||||
subscription = atom.packages.onDidDeactivatePackage(pack => pack.path);
|
||||
subscription = atom.packages.onDidLoadPackage(pack => pack.isCompatible());
|
||||
subscription = atom.packages.onDidUnloadPackage(pack => pack.bundledPackage);
|
||||
subscription = atom.packages.onDidUnloadPackage(pack => pack.name);
|
||||
|
||||
// Package system data
|
||||
str = atom.packages.getApmPath();
|
||||
@@ -1618,7 +1608,7 @@ function testPoint() {
|
||||
point.isGreaterThanOrEqual([0, 0]);
|
||||
|
||||
// Operations
|
||||
const frozenPoint: Readonly<TextBuffer.Point> = point.freeze();
|
||||
const frozenPoint: Readonly<Atom.Point> = point.freeze();
|
||||
|
||||
point = point.translate(point);
|
||||
point.translate([0, 0]);
|
||||
@@ -1644,7 +1634,7 @@ function testProject() {
|
||||
});
|
||||
|
||||
subscription = project.onDidAddBuffer(buffer => buffer.id);
|
||||
subscription = project.observeBuffers(buffer => buffer.file);
|
||||
subscription = project.observeBuffers(buffer => buffer.getUri());
|
||||
|
||||
// Accessing the git repository
|
||||
repositories = project.getRepositories();
|
||||
@@ -1707,7 +1697,7 @@ function testRange() {
|
||||
nums = range.getRows();
|
||||
|
||||
// Operations
|
||||
const frozenRange: Readonly<TextBuffer.Range> = range.freeze();
|
||||
const frozenRange: Readonly<Atom.Range> = range.freeze();
|
||||
range = range.union(range);
|
||||
|
||||
range = range.translate(pos);
|
||||
@@ -1923,7 +1913,7 @@ function testStyleManager() {
|
||||
|
||||
// Task =======================================================================
|
||||
function testTask() {
|
||||
let task: AtomCore.Task = Atom.Task.once("File.path", {}, () => {});
|
||||
let task: Atom.Task = Atom.Task.once("File.path", {}, () => {});
|
||||
task = new Atom.Task("File.path");
|
||||
|
||||
task.start({}, () => {});
|
||||
@@ -2282,7 +2272,7 @@ function testTextEditor() {
|
||||
subscription = editor.onDidChangeSoftWrapped(softWrapped => {});
|
||||
subscription = editor.onDidChangeEncoding(encoding => {});
|
||||
subscription = editor.observeGrammar(grammar => grammar.name);
|
||||
subscription = editor.onDidChangeGrammar(grammar => grammar.scopeName);
|
||||
subscription = editor.onDidChangeGrammar(grammar => grammar.name);
|
||||
subscription = editor.onDidChangeModified(modified => {});
|
||||
subscription = editor.onDidConflict(() => {});
|
||||
subscription = editor.onWillInsertText(event => event.cancel && event.text);
|
||||
@@ -3045,7 +3035,13 @@ function testWorkspace() {
|
||||
if (result) obj = result;
|
||||
}
|
||||
|
||||
atom.workspace.addOpener(() => element);
|
||||
atom.workspace.addOpener((uri) => {
|
||||
if (uri === "test://") {
|
||||
return {
|
||||
getTitle: () => "Test Title",
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
atom.workspace.buildTextEditor(obj);
|
||||
|
||||
|
||||
+128
@@ -0,0 +1,128 @@
|
||||
import "../index";
|
||||
|
||||
declare module "atom" {
|
||||
interface ConfigValues {
|
||||
/**
|
||||
* Suggestions will show as you type if this preference is enabled. If it is
|
||||
* disabled, you can still see suggestions by using the keymapping for
|
||||
* 'autocomplete-plus:activate' (shown below).
|
||||
*/
|
||||
"autocomplete-plus.enableAutoActivation": boolean;
|
||||
|
||||
/**
|
||||
* If you are experiencing performance issues when typing, you should try
|
||||
* increasing this value to a non-zero number (e.g. 100).
|
||||
*/
|
||||
"autocomplete-plus.autoActivationDelay": number;
|
||||
|
||||
/** The suggestion list will only show this many suggestions. */
|
||||
"autocomplete-plus.maxVisibleSuggestions": number;
|
||||
|
||||
/**
|
||||
* You should use the key(s) indicated here to confirm a suggestion from the
|
||||
* suggestion list and have it inserted into the file.
|
||||
*/
|
||||
"autocomplete-plus.confirmCompletion":
|
||||
| "tab"
|
||||
| "enter"
|
||||
| "tab and enter"
|
||||
| "tab always, enter when suggestion explicitly selected";
|
||||
|
||||
/**
|
||||
* Disable this if you want to bind your own keystrokes to move around the
|
||||
* suggestion list. You will also need to add definitions to your keymap.
|
||||
*/
|
||||
"autocomplete-plus.useCoreMovementCommands": boolean;
|
||||
|
||||
/**
|
||||
* Suggestions will not be provided for files matching this list, e.g. *.md
|
||||
* for Markdown files. To blacklist more than one file extension, use comma
|
||||
* as a separator, e.g. ["*.md", "*.txt"] (both Markdown and text files).
|
||||
*/
|
||||
"autocomplete-plus.fileBlacklist": string[];
|
||||
|
||||
/** Suggestions will not be provided for scopes matching this list. */
|
||||
"autocomplete-plus.scopeBlacklist": string[];
|
||||
|
||||
/**
|
||||
* For grammars with no registered provider(s), the default provider will
|
||||
* include completions from all buffers, instead of just the buffer you are
|
||||
* currently editing.
|
||||
*/
|
||||
"autocomplete-plus.includeCompletionsFromAllBuffers": boolean;
|
||||
|
||||
/**
|
||||
* Fuzzy searching is performed if this is disabled; if it is enabled, suggestions
|
||||
* must begin with the prefix from the current word.
|
||||
*/
|
||||
"autocomplete-plus.strictMatching": boolean;
|
||||
|
||||
/**
|
||||
* Only autocomplete when you've typed at least this many characters.
|
||||
* Note: May not affect external providers.
|
||||
*/
|
||||
"autocomplete-plus.minimumWordLength": number;
|
||||
|
||||
/**
|
||||
* The package comes with a built-in provider that will provide suggestions
|
||||
* using the words in your current buffer or all open buffers. You will get
|
||||
* better suggestions by installing additional autocomplete+ providers.
|
||||
* To stop using the built-in provider, disable this option.
|
||||
*/
|
||||
"autocomplete-plus.enableBuiltinProvider": boolean;
|
||||
|
||||
/** Don't use the built-in provider for these selector(s). */
|
||||
"autocomplete-plus.builtinProviderBlacklist": string;
|
||||
|
||||
/**
|
||||
* If enabled, typing `backspace` will show the suggestion list if suggestions
|
||||
* are available. If disabled, suggestions will not be shown while backspacing.
|
||||
*/
|
||||
"autocomplete-plus.backspaceTriggersAutocomplete": boolean;
|
||||
|
||||
/**
|
||||
* If enabled, automatically insert suggestion on manual activation with
|
||||
* 'autocomplete-plus:activate' when there is only one match.
|
||||
*/
|
||||
"autocomplete-plus.enableAutoConfirmSingleSuggestion": boolean;
|
||||
|
||||
/**
|
||||
* With 'Cursor' the suggestion list appears at the cursor's position.
|
||||
* With 'Word' it appears at the beginning of the word that's being completed.
|
||||
*/
|
||||
"autocomplete-plus.suggestionListFollows": "Word"|"Cursor";
|
||||
|
||||
/**
|
||||
* If you're having trouble with autocomplete, you may consider falling back
|
||||
* to the Symbol provider and filing an issue.
|
||||
*/
|
||||
"autocomplete-plus.defaultProvider": "Subsequence"|"Symbol";
|
||||
|
||||
/** Don't auto-activate when any of these classes are present in the editor. */
|
||||
"autocomplete-plus.suppressActivationForEditorClasses": string[];
|
||||
|
||||
/**
|
||||
* Completing a suggestion consumes text following the cursor matching the
|
||||
* suffix of the chosen suggestion.
|
||||
*/
|
||||
"autocomplete-plus.consumeSuffix": boolean;
|
||||
|
||||
/**
|
||||
* -EXPERIMENTAL- Prefers runs of consecutive characters, acronyms and start
|
||||
* of words.
|
||||
*/
|
||||
"autocomplete-plus.useAlternateScoring": boolean;
|
||||
|
||||
/** Gives words near the cursor position a higher score than those far away. */
|
||||
"autocomplete-plus.useLocalityBonus": boolean;
|
||||
|
||||
/** Identifies non-latin alphabet characters as letters. */
|
||||
"autocomplete-plus.enableExtendedUnicodeSupport": boolean;
|
||||
|
||||
/**
|
||||
* Should similar suggestions be removed from the list? If so how to determine
|
||||
* they are similar.
|
||||
*/
|
||||
"autocomplete-plus.similarSuggestionRemoval": "none"|"textOrSnippet";
|
||||
}
|
||||
}
|
||||
+41
-21
@@ -1,16 +1,20 @@
|
||||
// Autocomplete Plus 2.x
|
||||
// https://atom.io/packages/autocomplete-plus
|
||||
|
||||
/// <reference path="./config.d.ts" />
|
||||
|
||||
import { Point, ScopeDescriptor, TextEditor } from "../index";
|
||||
|
||||
/** The parameters passed into getSuggestions by Autocomplete+. */
|
||||
export interface SuggestionsRequestedEvent {
|
||||
/** The current TextEditor. */
|
||||
editor: AtomCore.TextEditor;
|
||||
editor: TextEditor;
|
||||
|
||||
/** The position of the cursor. */
|
||||
bufferPosition: TextBuffer.Point;
|
||||
bufferPosition: Point;
|
||||
|
||||
/** The scope descriptor for the current cursor position. */
|
||||
scopeDescriptor: AtomCore.ScopeDescriptor;
|
||||
scopeDescriptor: ScopeDescriptor;
|
||||
|
||||
/** The prefix for the word immediately preceding the current cursor position. */
|
||||
prefix: string;
|
||||
@@ -21,26 +25,30 @@ export interface SuggestionsRequestedEvent {
|
||||
|
||||
/** The parameters passed into onDidInsertSuggestion by Autocomplete+. */
|
||||
export interface SuggestionInsertedEvent {
|
||||
editor: AtomCore.TextEditor;
|
||||
triggerPosition: TextBuffer.Point;
|
||||
editor: TextEditor;
|
||||
triggerPosition: Point;
|
||||
suggestion: TextSuggestion|SnippetSuggestion;
|
||||
}
|
||||
|
||||
/** An autocompletion suggestion for the user.
|
||||
/**
|
||||
* An autocompletion suggestion for the user.
|
||||
* Primary data type for the Atom Autocomplete+ service.
|
||||
*/
|
||||
export interface Suggestion<T extends { text: string }|{ snippet: string }> {
|
||||
/** A string that will show in the UI for this suggestion.
|
||||
/**
|
||||
* A string that will show in the UI for this suggestion.
|
||||
* When not set, snippet || text is displayed.
|
||||
*/
|
||||
displayText?: string;
|
||||
|
||||
/** The text immediately preceding the cursor, which will be replaced by the text.
|
||||
/**
|
||||
* The text immediately preceding the cursor, which will be replaced by the text.
|
||||
* If not provided, the prefix passed into getSuggestions will be used.
|
||||
*/
|
||||
replacementPrefix?: string;
|
||||
|
||||
/** The suggestion type. It will be converted into an icon shown against the
|
||||
/**
|
||||
* The suggestion type. It will be converted into an icon shown against the
|
||||
* suggestion.
|
||||
*/
|
||||
type?: string;
|
||||
@@ -51,7 +59,8 @@ export interface Suggestion<T extends { text: string }|{ snippet: string }> {
|
||||
/** Use this instead of leftLabel if you want to use html for the left label. */
|
||||
leftLabelHTML?: string;
|
||||
|
||||
/** An indicator (e.g. function, variable) denoting the "kind" of suggestion this
|
||||
/**
|
||||
* An indicator (e.g. function, variable) denoting the "kind" of suggestion this
|
||||
* represents.
|
||||
*/
|
||||
rightLabel?: string;
|
||||
@@ -59,22 +68,26 @@ export interface Suggestion<T extends { text: string }|{ snippet: string }> {
|
||||
/** Use this instead of rightLabel if you want to use html for the right label. */
|
||||
rightLabelHTML?: string;
|
||||
|
||||
/** Class name for the suggestion in the suggestion list. Allows you to style your
|
||||
/**
|
||||
* Class name for the suggestion in the suggestion list. Allows you to style your
|
||||
* suggestion via CSS, if desired.
|
||||
*/
|
||||
className?: string;
|
||||
|
||||
/** If you want complete control over the icon shown against the suggestion.
|
||||
/**
|
||||
* If you want complete control over the icon shown against the suggestion.
|
||||
* e.g. iconHTML: <i class="icon-move-right"></i>
|
||||
*/
|
||||
iconHTML?: string;
|
||||
|
||||
/** A doc-string summary or short description of the suggestion. When specified, it
|
||||
/**
|
||||
* A doc-string summary or short description of the suggestion. When specified, it
|
||||
* will be displayed at the bottom of the suggestions list.
|
||||
*/
|
||||
description?: string;
|
||||
|
||||
/** A url to the documentation or more information about this suggestion.
|
||||
/**
|
||||
* A url to the documentation or more information about this suggestion.
|
||||
* When specified, a More.. link will be displayed in the description area.
|
||||
*/
|
||||
descriptionMoreURL?: string;
|
||||
@@ -86,7 +99,8 @@ export interface TextSuggestion extends Suggestion<TextSuggestion> {
|
||||
}
|
||||
|
||||
export interface SnippetSuggestion extends Suggestion<SnippetSuggestion> {
|
||||
/** A snippet string. This will allow users to tab through function arguments
|
||||
/**
|
||||
* A snippet string. This will allow users to tab through function arguments
|
||||
* or other options.
|
||||
*/
|
||||
snippet: string;
|
||||
@@ -96,24 +110,28 @@ export type Suggestions = Array<TextSuggestion|SnippetSuggestion>;
|
||||
|
||||
/** The interface that all Autocomplete+ providers must implement. */
|
||||
export interface AutocompleteProvider {
|
||||
/** Defines the scope selector(s) (can be comma-separated) for which your provider
|
||||
/**
|
||||
* Defines the scope selector(s) (can be comma-separated) for which your provider
|
||||
* should receive suggestion requests.
|
||||
*/
|
||||
selector: string;
|
||||
|
||||
/** Is called when a suggestion request has been dispatched by autocomplete+ to
|
||||
/**
|
||||
* Is called when a suggestion request has been dispatched by autocomplete+ to
|
||||
* your provider. Return an array of suggestions (if any) in the order you would
|
||||
* like them displayed to the user. Returning a Promise of an array of suggestions
|
||||
* is also supported.
|
||||
*/
|
||||
getSuggestions(params: SuggestionsRequestedEvent): Suggestions|Promise<Suggestions>;
|
||||
|
||||
/** Defines the scope selector(s) (can be comma-separated) for which your provider
|
||||
/**
|
||||
* Defines the scope selector(s) (can be comma-separated) for which your provider
|
||||
* should not be used.
|
||||
*/
|
||||
disableForSelector?: string;
|
||||
|
||||
/** A number to indicate its priority to be included in a suggestions request.
|
||||
/**
|
||||
* A number to indicate its priority to be included in a suggestions request.
|
||||
* The default provider has an inclusion priority of 0. Higher priority providers
|
||||
* can suppress lower priority providers with excludeLowerPriority.
|
||||
*/
|
||||
@@ -122,12 +140,14 @@ export interface AutocompleteProvider {
|
||||
/** Will not use lower priority providers when this provider is used. */
|
||||
excludeLowerPriority?: boolean;
|
||||
|
||||
/** A number to determine the sort order of suggestions. The default provider has
|
||||
/**
|
||||
* A number to determine the sort order of suggestions. The default provider has
|
||||
* an suggestion priority of 1.
|
||||
*/
|
||||
suggestionPriority?: number;
|
||||
|
||||
/** Function that is called when a suggestion from your provider was inserted
|
||||
/**
|
||||
* Function that is called when a suggestion from your provider was inserted
|
||||
* into the buffer.
|
||||
*/
|
||||
onDidInsertSuggestion?(params: SuggestionInsertedEvent): void;
|
||||
Vendored
+6469
-4085
File diff suppressed because it is too large
Load Diff
Vendored
+26
@@ -0,0 +1,26 @@
|
||||
import "../index";
|
||||
|
||||
declare module "atom" {
|
||||
interface ConfigValues {
|
||||
/** Lint tabs while they are still in preview status. */
|
||||
"linter.lintPreviewTabs": boolean;
|
||||
|
||||
/** Lint files automatically when they are opened. */
|
||||
"linter.lintOnOpen": boolean;
|
||||
|
||||
/**
|
||||
* Lint files while typing, without the need to save (only for supported
|
||||
* providers).
|
||||
*/
|
||||
"linter.lintOnChange": boolean;
|
||||
|
||||
/** Interval at which linting is done as you type (in ms). */
|
||||
"linter.lintOnChangeInterval": number;
|
||||
|
||||
/** Ignore files matching this Glob. */
|
||||
"linter.ignoreGlob": string;
|
||||
|
||||
/** Disabled providers. */
|
||||
"linter.disabledProviders": string[];
|
||||
}
|
||||
}
|
||||
+13
-8
@@ -1,9 +1,13 @@
|
||||
// Linter 2.x
|
||||
// https://atom.io/packages/linter
|
||||
|
||||
/// <reference path="./config.d.ts" />
|
||||
|
||||
import { Disposable, Point, Range, TextEditor } from "../index";
|
||||
|
||||
export interface ReplacementSolution {
|
||||
title?: string;
|
||||
position: TextBuffer.Range;
|
||||
position: Range;
|
||||
priority?: number;
|
||||
currentText?: string;
|
||||
replaceWith: string;
|
||||
@@ -11,7 +15,7 @@ export interface ReplacementSolution {
|
||||
|
||||
export interface CallbackSolution {
|
||||
title?: string;
|
||||
position: TextBuffer.Range;
|
||||
position: Range;
|
||||
priority?: number;
|
||||
// tslint:disable-next-line:no-any
|
||||
apply(): any;
|
||||
@@ -24,7 +28,7 @@ export interface Message {
|
||||
file: string;
|
||||
|
||||
/** The range of the message in the editor. */
|
||||
position: TextBuffer.Range;
|
||||
position: Range;
|
||||
};
|
||||
|
||||
/** A reference to a different location in the editor. */
|
||||
@@ -33,7 +37,7 @@ export interface Message {
|
||||
file: string;
|
||||
|
||||
/** The point being referenced in that file. */
|
||||
position?: TextBuffer.Point;
|
||||
position?: Point;
|
||||
};
|
||||
|
||||
/** An HTTP link to a resource explaining the issue. Default is a google search. */
|
||||
@@ -51,7 +55,8 @@ export interface Message {
|
||||
/** Possible solutions (which the user can invoke at will). */
|
||||
solutions?: Array<ReplacementSolution|CallbackSolution>;
|
||||
|
||||
/** Markdown long description of the error. Accepts a callback so that you can
|
||||
/**
|
||||
* Markdown long description of the error. Accepts a callback so that you can
|
||||
* do things like HTTP requests.
|
||||
*/
|
||||
description?: string|(() => Promise<string>|string);
|
||||
@@ -63,8 +68,8 @@ export interface IndieDelegate {
|
||||
clearMessages(): void;
|
||||
setMessages(filePath: string, messages: Message[]): void;
|
||||
setAllMessages(messages: Message[]): void;
|
||||
onDidUpdate(callback: () => void): EventKit.Disposable;
|
||||
onDidDestroy(callback: () => void): EventKit.Disposable;
|
||||
onDidUpdate(callback: () => void): Disposable;
|
||||
onDidDestroy(callback: () => void): Disposable;
|
||||
dispose(): void;
|
||||
}
|
||||
|
||||
@@ -73,5 +78,5 @@ export interface LinterProvider {
|
||||
scope: "file"|"project";
|
||||
lintsOnChange: boolean;
|
||||
grammarScopes: string[];
|
||||
lint(textEditor: AtomCore.TextEditor): Message[]|void|Promise<Message[]|undefined>;
|
||||
lint(textEditor: TextEditor): Message[]|void|Promise<Message[]|undefined>;
|
||||
}
|
||||
Vendored
+23
@@ -0,0 +1,23 @@
|
||||
import "../index";
|
||||
|
||||
declare module "atom" {
|
||||
interface ConfigValues {
|
||||
/** Show status bar at the bottom of the workspace. */
|
||||
"status-bar.isVisible": boolean;
|
||||
|
||||
/** Fit the status-bar to the window's full-width. */
|
||||
"status-bar.fullWidth": boolean;
|
||||
|
||||
/**
|
||||
* Format for the cursor position status bar element, where %L is the line
|
||||
* number and %C is the column number.
|
||||
*/
|
||||
"status-bar.cursorPositionFormat": string;
|
||||
|
||||
/**
|
||||
* Format for the selection count status bar element, where %L is the line
|
||||
* count and %C is the character count.
|
||||
*/
|
||||
"status-bar.selectionCountFormat": string;
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,17 @@
|
||||
// Status Bar 1.x
|
||||
// https://atom.io/packages/status-bar
|
||||
|
||||
/// <reference path="./config.d.ts" />
|
||||
|
||||
export interface AddTileOptions {
|
||||
/** A DOM element, a jQuery object, or a model object for which a view provider
|
||||
/**
|
||||
* A DOM element, a jQuery object, or a model object for which a view provider
|
||||
* has been registered in the the view registry.
|
||||
*/
|
||||
item: object;
|
||||
|
||||
/** Determines the placement of the tile within the status bar. Lower priority
|
||||
/**
|
||||
* Determines the placement of the tile within the status bar. Lower priority
|
||||
* will result in closer placement to the anchor.
|
||||
*/
|
||||
priority: number;
|
||||
@@ -25,12 +29,14 @@ export interface Tile {
|
||||
}
|
||||
|
||||
export interface StatusBar {
|
||||
/** Add a tile to the left side of the status bar. Lower priority tiles are placed
|
||||
/**
|
||||
* Add a tile to the left side of the status bar. Lower priority tiles are placed
|
||||
* further to the left.
|
||||
*/
|
||||
addLeftTile(options: AddTileOptions): Tile;
|
||||
|
||||
/** Add a tile to the right side of the status bar. Lower priority tiles are placed
|
||||
/**
|
||||
* Add a tile to the right side of the status bar. Lower priority tiles are placed
|
||||
* further to the right.
|
||||
*/
|
||||
addRightTile(options: AddTileOptions): Tile;
|
||||
@@ -8,7 +8,7 @@
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": false,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
@@ -20,8 +20,8 @@
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"atom-tests.ts",
|
||||
"autocomplete-plus.d.ts",
|
||||
"linter.d.ts",
|
||||
"status-bar.d.ts"
|
||||
"autocomplete-plus/index.d.ts",
|
||||
"linter/index.d.ts",
|
||||
"status-bar/index.d.ts"
|
||||
]
|
||||
}
|
||||
|
||||
+2
-30
@@ -2,36 +2,8 @@
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"await-promise": [true, "CancellablePromise"],
|
||||
"class-name": true,
|
||||
"indent": [true, "spaces", 4],
|
||||
"jsdoc-format": true,
|
||||
"max-line-length": [true, 110],
|
||||
"quotemark": [true, "double", "avoid-escape"],
|
||||
"trailing-comma": [true, {
|
||||
"multiline": { "objects": "always", "arrays": "always", "functions": "never" },
|
||||
"singleline": { "objects": "never", "arrays": "never", "functions": "never" }
|
||||
}],
|
||||
"whitespace": [
|
||||
true,
|
||||
"check-branch",
|
||||
"check-decl",
|
||||
"check-operator",
|
||||
"check-module",
|
||||
"check-separator",
|
||||
"check-type",
|
||||
"check-typecast",
|
||||
"check-rest-spread",
|
||||
"check-preblock"
|
||||
],
|
||||
// Soon to be defaults.
|
||||
"arrow-return-shorthand": [true, "multiline"],
|
||||
"no-any": true,
|
||||
"no-floating-promises": true,
|
||||
"no-unbound-method": true,
|
||||
"no-unsafe-any": true,
|
||||
"number-literal-format": true,
|
||||
"restrict-plus-operands": true,
|
||||
"return-undefined": true,
|
||||
"switch-final-break": true
|
||||
"max-line-length": [true, 100],
|
||||
"no-any": true
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -203,5 +203,5 @@ declare namespace BezierJs {
|
||||
}
|
||||
|
||||
declare module "bezier-js" {
|
||||
export = BezierJs;
|
||||
export = BezierJs.Bezier;
|
||||
}
|
||||
|
||||
Vendored
+1
-2
@@ -1,7 +1,6 @@
|
||||
// Type definitions for CKEditor
|
||||
// Project: http://ckeditor.com/
|
||||
// Definitions by: Ondrej Sevcik <https://github.com/ondrejsevcik>
|
||||
// Thomas Wittwer <https://github.com/wittwert>
|
||||
// Definitions by: Thomas Wittwer <https://github.com/wittwert>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
// WORK-IN-PROGRESS: Any contribution support welcomed.
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
import coverup = require("coverup");
|
||||
|
||||
coverup("4242-4242-4242-4242"); // $ExpectType string
|
||||
// => *******************
|
||||
|
||||
coverup("4242-4242-4242-4242", { char: "%" }); // $ExpectType string
|
||||
// => %%%%%%%%%%%%%%%%%%%
|
||||
|
||||
coverup("4242-4242-4242-4242", { keepSymbols: true }); // $ExpectType string
|
||||
// => ****-****-****-****
|
||||
|
||||
coverup("4242-4242-4242-4242", { keepLeft: 1, keepRight: 1, compactTo: 4 }); // $ExpectType string
|
||||
// => 4****2
|
||||
|
||||
coverup("4242-4242-4242-4242", { keepLeft: 4 }); // $ExpectType string
|
||||
// => 4242***************
|
||||
|
||||
coverup("4242-4242-4242-4242", { keepRight: 4 }); // $ExpectType string
|
||||
// => ***************4242
|
||||
|
||||
let options: coverup.Options = {
|
||||
char: "x",
|
||||
keepLeft: 3,
|
||||
keepRight: 3,
|
||||
};
|
||||
|
||||
coverup("4242-4242-4242-4242", options); // $ExpectType string
|
||||
// => 424xxxxxxxxxxxxx242
|
||||
|
||||
options = {
|
||||
keepLeft: 1,
|
||||
keepRight: 1,
|
||||
compactTo: 4,
|
||||
keepSymbols: true,
|
||||
};
|
||||
|
||||
coverup("4242-4242-4242-4242", options); // $ExpectError "you cannot define both compactTo and keepSymbols"
|
||||
// => Error: you cannot define both compactTo and keepSymbols
|
||||
Vendored
+20
@@ -0,0 +1,20 @@
|
||||
// Type definitions for coverup 0.1
|
||||
// Project: https://github.com/jsonmaur/coverup
|
||||
// Definitions by: Vadim Belorussov <https://github.com/bevalorous>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export as namespace Coverup;
|
||||
|
||||
export = coverup;
|
||||
|
||||
declare function coverup(value: string, options?: coverup.Options): string;
|
||||
|
||||
declare namespace coverup {
|
||||
interface Options {
|
||||
char?: string;
|
||||
keepLeft?: number;
|
||||
keepRight?: number;
|
||||
compactTo?: number;
|
||||
keepSymbols?: 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",
|
||||
"coverup-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Vendored
+2
-2
@@ -978,7 +978,7 @@ declare namespace cytoscape {
|
||||
* An analogue to run a layout on a subset of the graph exists as eles.layout().
|
||||
* http://js.cytoscape.org/#cy.layout
|
||||
*/
|
||||
layout(layout: LayoutOptions): void;
|
||||
layout(layout: LayoutOptions): LayoutManipulation;
|
||||
/**
|
||||
* Get a new layout, which can be used to algorithmically
|
||||
* position the nodes in the graph.
|
||||
@@ -991,7 +991,7 @@ declare namespace cytoscape {
|
||||
* Note that you must call layout.run() in order for it to affect the graph.
|
||||
* An analogue to make a layout on a subset of the graph exists as eles.makeLayout().
|
||||
*/
|
||||
makeLayout(options: LayoutOptions): void;
|
||||
makeLayout(options: LayoutOptions): LayoutManipulation;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Vendored
-2
@@ -3,8 +3,6 @@
|
||||
// Definitions by: Alex Ford <https://github.com/gustavderdrache>, Boris Yankov <https://github.com/borisyankov>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/* tslint:disable */
|
||||
|
||||
// Latest patch version of module validated against: 3.5.17
|
||||
|
||||
export = d3;
|
||||
|
||||
@@ -12,6 +12,7 @@ settings.setAll({foo: {bar: 'test'}}, {prettify: true}); // $ExpectType Settings
|
||||
|
||||
settings.get('foo.bar'); // $ExpectType JsonValue
|
||||
settings.get('foo.bar', 'test'); // $ExpectType JsonValue
|
||||
settings.get('foo.bar', 'test', {prettify: true}); // $ExpectType JsonValue
|
||||
|
||||
settings.getAll(); // $ExpectType JsonValue
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -57,7 +57,7 @@ interface Settings extends NodeJS.EventEmitter {
|
||||
* exist.
|
||||
* @see #getAll
|
||||
*/
|
||||
get(keyPath: string, defaultValue?: any): JsonValue;
|
||||
get(keyPath: string, defaultValue?: any, options?: SettingsOptions): JsonValue;
|
||||
|
||||
/**
|
||||
* Returns all settings.
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
## Event Kit Type Definitions
|
||||
|
||||
TypeScript type definitions for [event-kit](https://github.com/atom/event-kit), which is published [under the same name](https://www.npmjs.com/package/event-kit) on NPM.
|
||||
|
||||
### Usage Notes
|
||||
|
||||
#### Exports
|
||||
|
||||
The three classes exported from this module are: [CompositeDisposable](https://github.com/atom/event-kit/blob/master/src/composite-disposable.coffee), [Disposable](https://github.com/atom/event-kit/blob/master/src/disposable.coffee), and [Emitter](https://github.com/atom/event-kit/blob/master/src/emitter.coffee).
|
||||
|
||||
```ts
|
||||
import { CompositeDisposable, Disposable, Emitter } from "event-kit";
|
||||
let subscriptions = new CompositeDisposable();
|
||||
```
|
||||
|
||||
#### The EventKit Namespace
|
||||
|
||||
All types used by "event-kit" can be referenced from the EventKit namespace.
|
||||
|
||||
```ts
|
||||
function example(disposable: EventKit.DisposableLike) {}
|
||||
```
|
||||
|
||||
### Exposing Private Methods and Properties
|
||||
|
||||
[Declaration Merging](https://www.typescriptlang.org/docs/handbook/declaration-merging.html) can be used to augment any of the types used within Event Kit. As an example, if we wanted to reveal the private ```getEventNames``` method within the Emitter class, then we would create a file with the following contents:
|
||||
|
||||
```ts
|
||||
// <<filename>>.d.ts
|
||||
|
||||
declare namespace EventKit {
|
||||
interface Emitter {
|
||||
getEventNames(): string[];
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Once this file is either referenced or included within your project, then this new member function would be freely usable on instances of the Emitter class without TypeScript reporting errors.
|
||||
@@ -1,13 +1,13 @@
|
||||
import { Disposable, CompositeDisposable, Emitter } from "event-kit";
|
||||
|
||||
declare let bool: boolean;
|
||||
declare let subscription: EventKit.Disposable;
|
||||
declare let subscriptions: EventKit.CompositeDisposable;
|
||||
declare let emitter: EventKit.Emitter;
|
||||
declare let subscription: Disposable;
|
||||
declare let subscriptions: CompositeDisposable;
|
||||
declare let emitter: Emitter;
|
||||
|
||||
// NPM Usage Tests ============================================================
|
||||
class User {
|
||||
private readonly emitter: EventKit.Emitter;
|
||||
private readonly emitter: Emitter;
|
||||
name: string;
|
||||
|
||||
constructor() {
|
||||
@@ -81,3 +81,8 @@ subscription = emitter.preempt("test-event", value => {});
|
||||
// Event Emission
|
||||
emitter.emit("test-event");
|
||||
emitter.emit("test-event", 42);
|
||||
|
||||
async function testEmitAsync() {
|
||||
await emitter.emitAsync("test-event");
|
||||
await emitter.emitAsync("test-event", 42);
|
||||
}
|
||||
|
||||
Vendored
+107
-109
@@ -4,121 +4,119 @@
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
declare global {
|
||||
namespace EventKit {
|
||||
interface DisposableLike {
|
||||
dispose(): void;
|
||||
}
|
||||
|
||||
/** A handle to a resource that can be disposed. */
|
||||
interface Disposable extends DisposableLike {
|
||||
disposed: boolean;
|
||||
|
||||
/** A callback which will be called within dispose(). */
|
||||
disposalAction?(): void;
|
||||
|
||||
/** Perform the disposal action, indicating that the resource associated
|
||||
* with this disposable is no longer needed.
|
||||
*/
|
||||
dispose(): void;
|
||||
}
|
||||
|
||||
interface DisposableStatic {
|
||||
/** Ensure that Object correctly implements the Disposable contract. */
|
||||
isDisposable(object: object): boolean;
|
||||
|
||||
/** Construct a Disposable. */
|
||||
new (disposableAction?: () => void): Disposable;
|
||||
}
|
||||
|
||||
/** An object that aggregates multiple Disposable instances together into a
|
||||
* single disposable, so they can all be disposed as a group.
|
||||
*/
|
||||
interface CompositeDisposable extends DisposableLike {
|
||||
disposed: boolean;
|
||||
|
||||
/** Dispose all disposables added to this composite disposable.
|
||||
* If this object has already been disposed, this method has no effect.
|
||||
*/
|
||||
dispose(): void;
|
||||
|
||||
// Managing Disposables
|
||||
/** Add disposables to be disposed when the composite is disposed.
|
||||
* If this object has already been disposed, this method has no effect.
|
||||
*/
|
||||
add(...disposables: DisposableLike[]): void;
|
||||
|
||||
/** Remove a previously added disposable. */
|
||||
remove(disposable: DisposableLike): void;
|
||||
|
||||
/** Alias to CompositeDisposable::remove. */
|
||||
delete(disposable: DisposableLike): void;
|
||||
|
||||
/** Clear all disposables. They will not be disposed by the next call to
|
||||
* dispose.
|
||||
*/
|
||||
clear(): void;
|
||||
}
|
||||
|
||||
/** The static side to the CompositeDisposable class. */
|
||||
interface CompositeDisposableStatic {
|
||||
/** Construct an instance, optionally with one or more disposables. */
|
||||
new (...disposables: DisposableLike[]): CompositeDisposable;
|
||||
}
|
||||
|
||||
/** Utility class to be used when implementing event-based APIs that allows
|
||||
* for handlers registered via ::on to be invoked with calls to ::emit.
|
||||
*/
|
||||
interface Emitter extends DisposableLike {
|
||||
disposed: boolean;
|
||||
|
||||
/** Clear out any existing subscribers. */
|
||||
clear(): void;
|
||||
|
||||
/** Unsubscribe all handlers. */
|
||||
dispose(): boolean;
|
||||
|
||||
// Event Subscription
|
||||
/** Registers a handler to be invoked whenever the given event is emitted. */
|
||||
// tslint:disable-next-line:no-any
|
||||
on(eventName: string, handler: (value: any) => void): Disposable;
|
||||
|
||||
/** Register the given handler function to be invoked the next time an event
|
||||
* with the given name is emitted via ::emit.
|
||||
*/
|
||||
// tslint:disable-next-line:no-any
|
||||
once(eventName: string, handler: (value: any) => void): Disposable;
|
||||
|
||||
/** Register the given handler function to be invoked before all other
|
||||
* handlers existing at the time of subscription whenever events by the
|
||||
* given name are emitted via ::emit.
|
||||
*/
|
||||
// tslint:disable-next-line:no-any
|
||||
preempt(eventName: string, handler: (value: any) => void): Disposable;
|
||||
|
||||
// Event Emission
|
||||
/** Invoke handlers registered via ::on for the given event name. */
|
||||
// tslint:disable-next-line:no-any
|
||||
emit(eventName: string, value?: any): void;
|
||||
}
|
||||
|
||||
/** The static side to the Emitter class. */
|
||||
interface EmitterStatic {
|
||||
/** Construct an emitter. */
|
||||
new (): Emitter;
|
||||
}
|
||||
}
|
||||
export interface DisposableLike {
|
||||
dispose(): void;
|
||||
}
|
||||
|
||||
/** A handle to a resource that can be disposed. */
|
||||
export const Disposable: EventKit.DisposableStatic;
|
||||
export class Disposable implements DisposableLike {
|
||||
disposed: boolean;
|
||||
|
||||
/** An object that aggregates multiple Disposable instances together into a
|
||||
/** Ensure that Object correctly implements the Disposable contract. */
|
||||
static isDisposable(object: object): boolean;
|
||||
|
||||
/** Construct a Disposable. */
|
||||
constructor(disposableAction?: () => void);
|
||||
|
||||
/** A callback which will be called within dispose(). */
|
||||
disposalAction?: () => void;
|
||||
|
||||
/**
|
||||
* Perform the disposal action, indicating that the resource associated
|
||||
* with this disposable is no longer needed.
|
||||
*/
|
||||
dispose(): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* An object that aggregates multiple Disposable instances together into a
|
||||
* single disposable, so they can all be disposed as a group.
|
||||
*/
|
||||
export const CompositeDisposable: EventKit.CompositeDisposableStatic;
|
||||
export class CompositeDisposable implements DisposableLike {
|
||||
disposed: boolean;
|
||||
|
||||
/** Utility class to be used when implementing event-based APIs that allows
|
||||
/** Construct an instance, optionally with one or more disposables. */
|
||||
constructor(...disposables: DisposableLike[]);
|
||||
|
||||
/**
|
||||
* Dispose all disposables added to this composite disposable.
|
||||
* If this object has already been disposed, this method has no effect.
|
||||
*/
|
||||
dispose(): void;
|
||||
|
||||
// Managing Disposables
|
||||
/**
|
||||
* Add disposables to be disposed when the composite is disposed.
|
||||
* If this object has already been disposed, this method has no effect.
|
||||
*/
|
||||
add(...disposables: DisposableLike[]): void;
|
||||
|
||||
/** Remove a previously added disposable. */
|
||||
remove(disposable: DisposableLike): void;
|
||||
|
||||
/** Alias to CompositeDisposable::remove. */
|
||||
delete(disposable: DisposableLike): void;
|
||||
|
||||
/**
|
||||
* Clear all disposables. They will not be disposed by the next call to
|
||||
* dispose.
|
||||
*/
|
||||
clear(): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows you to strongly type event emissions across your codebase. Additional
|
||||
* key:value pairings merged into this interface will result in emissions under
|
||||
* the value of each key being templated by the type of the associated value.
|
||||
*/
|
||||
export interface Emissions {
|
||||
// tslint:disable-next-line:no-any
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility class to be used when implementing event-based APIs that allows
|
||||
* for handlers registered via ::on to be invoked with calls to ::emit.
|
||||
*/
|
||||
export const Emitter: EventKit.EmitterStatic;
|
||||
export class Emitter implements DisposableLike {
|
||||
disposed: boolean;
|
||||
|
||||
/** Construct an emitter. */
|
||||
constructor();
|
||||
|
||||
/** Clear out any existing subscribers. */
|
||||
clear(): void;
|
||||
|
||||
/** Unsubscribe all handlers. */
|
||||
dispose(): boolean;
|
||||
|
||||
// Event Subscription
|
||||
/** Registers a handler to be invoked whenever the given event is emitted. */
|
||||
on<T extends keyof Emissions>(eventName: T, handler: (value?: Emissions[T]) => void):
|
||||
Disposable;
|
||||
|
||||
/**
|
||||
* Register the given handler function to be invoked the next time an event
|
||||
* with the given name is emitted via ::emit.
|
||||
*/
|
||||
once<T extends keyof Emissions>(eventName: T, handler: (value?: Emissions[T]) => void):
|
||||
Disposable;
|
||||
|
||||
/**
|
||||
* Register the given handler function to be invoked before all other
|
||||
* handlers existing at the time of subscription whenever events by the
|
||||
* given name are emitted via ::emit.
|
||||
*/
|
||||
preempt<T extends keyof Emissions>(eventName: T, handler: (value?: Emissions[T]) => void):
|
||||
Disposable;
|
||||
|
||||
// Event Emission
|
||||
/** Invoke the handlers registered via ::on for the given event name. */
|
||||
emit<T extends keyof Emissions>(eventName: T, value?: Emissions[T]): void;
|
||||
|
||||
/**
|
||||
* Asynchronously invoke the handlers registered via ::on for the given event name.
|
||||
* @return A promise that will be fulfilled once all handlers have been invoked.
|
||||
*/
|
||||
emitAsync<T extends keyof Emissions>(eventName: T, value?: Emissions[T]): Promise<void>;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": false,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
@@ -21,4 +21,4 @@
|
||||
"index.d.ts",
|
||||
"event-kit-tests.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,36 +1,8 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"class-name": true,
|
||||
"indent": [true, "spaces", 4],
|
||||
"jsdoc-format": true,
|
||||
"max-line-length": [true, 110],
|
||||
"quotemark": [true, "double", "avoid-escape"],
|
||||
"trailing-comma": [true, {
|
||||
"multiline": { "objects": "always", "arrays": "always", "functions": "never" },
|
||||
"singleline": { "objects": "never", "arrays": "never", "functions": "never" }
|
||||
}],
|
||||
"whitespace": [
|
||||
true,
|
||||
"check-branch",
|
||||
"check-decl",
|
||||
"check-operator",
|
||||
"check-module",
|
||||
"check-separator",
|
||||
"check-type",
|
||||
"check-typecast",
|
||||
"check-rest-spread",
|
||||
"check-preblock"
|
||||
],
|
||||
// Soon to be defaults.
|
||||
"arrow-return-shorthand": [true, "multiline"],
|
||||
"no-any": true,
|
||||
"no-floating-promises": true,
|
||||
"no-unbound-method": true,
|
||||
"no-unsafe-any": true,
|
||||
"number-literal-format": true,
|
||||
"restrict-plus-operands": true,
|
||||
"return-undefined": true,
|
||||
"switch-final-break": true
|
||||
"max-line-length": [true, 100],
|
||||
"no-any": true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,30 +1,40 @@
|
||||
|
||||
|
||||
import { saveAs as importedSaveAs } from "file-saver";
|
||||
function testImportedSaveAs() {
|
||||
var data: Blob = new Blob(["Hello, world!"], {type: "text/plain;charset=utf-8"});
|
||||
var filename: string = 'hello world.txt';
|
||||
var disableAutoBOM = true;
|
||||
|
||||
importedSaveAs(data, filename, disableAutoBOM);
|
||||
}
|
||||
import "file-saver";
|
||||
|
||||
/**
|
||||
* @summary Test for "saveAs" function.
|
||||
*/
|
||||
function testSaveAs() {
|
||||
var data: Blob = new Blob(["Hello, world!"], {type: "text/plain;charset=utf-8"});
|
||||
var filename: string = 'hello world.txt';
|
||||
var disableAutoBOM = true;
|
||||
const data: Blob = new Blob(["Hello, world!"], {type: "text/plain;charset=utf-8"});
|
||||
const filename = 'hello world.txt';
|
||||
const disableAutoBOM = true;
|
||||
|
||||
saveAs(data, filename, disableAutoBOM);
|
||||
}
|
||||
|
||||
/**
|
||||
* @summary Test for "saveAs" function.
|
||||
* @summary Test for "saveAs" function on the window object.
|
||||
*/
|
||||
function testSaveAsFile() {
|
||||
const data = new File(["Hello, world!"], "hello world.txt" ,{type: "text/plain;charset=utf-8"});
|
||||
|
||||
function testWindowSaveAs() {
|
||||
const data: Blob = new Blob(["Hello, world!"], {type: "text/plain;charset=utf-8"});
|
||||
const filename = 'hello world.txt';
|
||||
const disableAutoBOM = true;
|
||||
|
||||
window.saveAs(data, filename, disableAutoBOM);
|
||||
}
|
||||
|
||||
/**
|
||||
* @summary Test for "saveAs" function with the 3rd parameter omitted
|
||||
*/
|
||||
function testOptionalOneParamSaveAs() {
|
||||
const data: Blob = new Blob(["Hello, world!"], {type: "text/plain;charset=utf-8"});
|
||||
const filename = 'hello world.txt';
|
||||
saveAs(data, filename);
|
||||
}
|
||||
|
||||
/**
|
||||
* @summary Test for "saveAs" function with the 2nd and 3rd parameters omitted
|
||||
*/
|
||||
function testOptionalTwoParamsSaveAs() {
|
||||
const data: Blob = new Blob(["Hello, world!"], {type: "text/plain;charset=utf-8"});
|
||||
saveAs(data);
|
||||
}
|
||||
|
||||
Vendored
+20
-40
@@ -1,46 +1,26 @@
|
||||
// Type definitions for FileSaver.js
|
||||
// Type definitions for FileSaver.js 1.3
|
||||
// Project: https://github.com/eligrey/FileSaver.js/
|
||||
// Definitions by: Cyril Schumacher <https://github.com/cyrilschumacher>, Daniel Roth <https://github.com/DaIgeb>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// Definitions by: Cyril Schumacher <https://github.com/cyrilschumacher>
|
||||
// Daniel Roth <https://github.com/DaIgeb>
|
||||
// Chris Barr <https://github.com/chrismbarr>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/file-saver
|
||||
|
||||
/**
|
||||
* @summary Interface for "saveAs" function.
|
||||
* @author Cyril Schumacher
|
||||
* @version 1.0
|
||||
*/
|
||||
interface FileSaver {
|
||||
(
|
||||
/**
|
||||
* @summary Data.
|
||||
* @type {Blob}
|
||||
*/
|
||||
data: Blob,
|
||||
|
||||
/**
|
||||
* @summary File name.
|
||||
* @type {DOMString}
|
||||
*/
|
||||
filename: string,
|
||||
|
||||
/**
|
||||
* @summary Disable Unicode text encoding hints or not.
|
||||
* @type {boolean}
|
||||
*/
|
||||
disableAutoBOM?: boolean
|
||||
): void
|
||||
|
||||
(
|
||||
/**
|
||||
* @summary File.
|
||||
* @type {File}
|
||||
*/
|
||||
data: File
|
||||
): void
|
||||
declare namespace FileSaver {
|
||||
/**
|
||||
* FileSaver.js implements the saveAs() FileSaver interface in browsers that do not natively support it.
|
||||
* @param data - The actual file data blob.
|
||||
* @param filename - The optional name of the file to be downloaded. If omitted, the name used in the file data will be used. If none is provided "download" will be used.
|
||||
* @param disableAutoBOM - Optional & defaults to `false`. Set to `true` if you don't want FileSaver.js to automatically provide Unicode text encoding hints
|
||||
*/
|
||||
function saveAs(data: Blob, filename?: string, disableAutoBOM?: boolean): void;
|
||||
}
|
||||
|
||||
declare var saveAs: FileSaver;
|
||||
declare global {
|
||||
const saveAs: typeof FileSaver.saveAs;
|
||||
|
||||
declare module "file-saver" {
|
||||
var fileSaver: { saveAs: typeof saveAs };
|
||||
export = fileSaver
|
||||
interface Window {
|
||||
saveAs: typeof FileSaver.saveAs;
|
||||
}
|
||||
}
|
||||
|
||||
export = FileSaver;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
@@ -21,4 +21,4 @@
|
||||
"index.d.ts",
|
||||
"file-saver-tests.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,79 +1,6 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"adjacent-overload-signatures": false,
|
||||
"array-type": false,
|
||||
"arrow-return-shorthand": false,
|
||||
"ban-types": false,
|
||||
"callable-types": false,
|
||||
"comment-format": false,
|
||||
"dt-header": false,
|
||||
"eofline": false,
|
||||
"export-just-namespace": false,
|
||||
"import-spacing": false,
|
||||
"interface-name": false,
|
||||
"interface-over-type-literal": false,
|
||||
"jsdoc-format": false,
|
||||
"max-line-length": false,
|
||||
"member-access": false,
|
||||
"new-parens": false,
|
||||
"no-any-union": false,
|
||||
"no-boolean-literal-compare": false,
|
||||
"no-conditional-assignment": false,
|
||||
"no-consecutive-blank-lines": false,
|
||||
"no-construct": false,
|
||||
"no-declare-current-package": false,
|
||||
"no-duplicate-imports": false,
|
||||
"no-duplicate-variable": false,
|
||||
"no-empty-interface": false,
|
||||
"no-for-in-array": false,
|
||||
"no-inferrable-types": false,
|
||||
"no-internal-module": false,
|
||||
"no-irregular-whitespace": false,
|
||||
"no-mergeable-namespace": false,
|
||||
"no-misused-new": false,
|
||||
"no-namespace": false,
|
||||
"no-object-literal-type-assertion": false,
|
||||
"no-padding": false,
|
||||
"no-redundant-jsdoc": false,
|
||||
"no-redundant-jsdoc-2": false,
|
||||
"no-redundant-undefined": false,
|
||||
"no-reference-import": false,
|
||||
"no-relative-import-in-test": false,
|
||||
"no-self-import": false,
|
||||
"no-single-declare-module": false,
|
||||
"no-string-throw": false,
|
||||
"no-unnecessary-callback-wrapper": false,
|
||||
"no-unnecessary-class": false,
|
||||
"no-unnecessary-generics": false,
|
||||
"no-unnecessary-qualifier": false,
|
||||
"no-unnecessary-type-assertion": false,
|
||||
"no-useless-files": false,
|
||||
"no-var-keyword": false,
|
||||
"no-var-requires": false,
|
||||
"no-void-expression": false,
|
||||
"no-trailing-whitespace": false,
|
||||
"object-literal-key-quotes": false,
|
||||
"object-literal-shorthand": false,
|
||||
"one-line": false,
|
||||
"one-variable-per-declaration": false,
|
||||
"only-arrow-functions": false,
|
||||
"prefer-conditional-expression": false,
|
||||
"prefer-const": false,
|
||||
"prefer-declare-function": false,
|
||||
"prefer-for-of": false,
|
||||
"prefer-method-signature": false,
|
||||
"prefer-template": false,
|
||||
"radix": false,
|
||||
"semicolon": false,
|
||||
"space-before-function-paren": false,
|
||||
"space-within-parens": false,
|
||||
"strict-export-declare-modifiers": false,
|
||||
"trim-file": false,
|
||||
"triple-equals": false,
|
||||
"typedef-whitespace": false,
|
||||
"unified-signatures": false,
|
||||
"void-return": false,
|
||||
"whitespace": false
|
||||
"export-just-namespace": false
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
-2
@@ -445,7 +445,6 @@ declare module 'firebird' {
|
||||
*/
|
||||
class Stream extends stream.Stream {
|
||||
constructor(blob: FBBlob);
|
||||
/* tslint:disable */
|
||||
|
||||
/* NodeJS.ReadStream */
|
||||
readable: boolean;
|
||||
@@ -462,7 +461,6 @@ declare module 'firebird' {
|
||||
end(str: string, encoding?: string, cb?: Function): void;
|
||||
destroy(error?: Error): void;
|
||||
|
||||
/* tslint:enable */
|
||||
check_destroyed(): void;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,11 @@
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
// TODO
|
||||
"ban-types": false,
|
||||
"no-boolean-literal-compare": false,
|
||||
"no-declare-current-package": false,
|
||||
"no-unnecessary-generics": false
|
||||
"no-single-declare-module": false,
|
||||
"no-unnecessary-generics": false,
|
||||
"unified-signatures": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
## First Mate Type Definitions
|
||||
|
||||
TypeScript type definitions for [First Mate](https://github.com/atom/first-mate), which is published as "[first-mate](https://www.npmjs.com/package/first-mate)" on NPM.
|
||||
|
||||
### Usage Notes
|
||||
|
||||
#### Exports
|
||||
|
||||
The three classes exported from this module are: [Grammar](https://github.com/atom/first-mate/blob/master/src/grammar.coffee), [GrammarRegistry](https://github.com/atom/first-mate/blob/master/src/grammar-registry.coffee), and [ScopeSelector](https://github.com/atom/first-mate/blob/master/src/scope-selector.coffee).
|
||||
|
||||
```ts
|
||||
import { Grammar, GrammarRegistry, ScopeSelector } from "first-mate";
|
||||
let selector = new ScopeSelector("a | b");
|
||||
```
|
||||
|
||||
#### The FirstMate Namespace
|
||||
|
||||
Many of the types used by First Mate can be referenced from the FirstMate namespace.
|
||||
|
||||
```ts
|
||||
function example(grammar: FirstMate.Grammar) {}
|
||||
```
|
||||
|
||||
### Exposing Private Methods and Properties
|
||||
|
||||
[Declaration Merging](https://www.typescriptlang.org/docs/handbook/declaration-merging.html) can be used to augment any of the types used within First Mate. As an example, if we wanted to reveal the private ```getMaxTokensPerLine``` method within the Grammar class, then we would create a file with the following contents:
|
||||
|
||||
```ts
|
||||
// <<filename>>.d.ts
|
||||
|
||||
declare namespace FirstMate {
|
||||
interface Grammar {
|
||||
getMaxTokensPerLine(): number;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Once this file is either referenced or included within your project, then this new member function would be freely usable on instances of the Grammar class without TypeScript reporting errors.
|
||||
@@ -1,8 +1,9 @@
|
||||
import { Disposable } from "event-kit";
|
||||
import { GrammarRegistry, Grammar, ScopeSelector } from "first-mate";
|
||||
|
||||
declare let subscription: EventKit.Disposable;
|
||||
declare let grammar: FirstMate.Grammar;
|
||||
declare let grammars: FirstMate.Grammar[];
|
||||
declare let subscription: Disposable;
|
||||
declare let grammar: Grammar;
|
||||
declare let grammars: Grammar[];
|
||||
|
||||
// NPM Examples ===============================================================
|
||||
const selector = new ScopeSelector("a | b");
|
||||
|
||||
Vendored
+244
-246
@@ -4,251 +4,249 @@
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
/// <reference types="event-kit" />
|
||||
|
||||
declare global {
|
||||
/** TextMate helpers. */
|
||||
namespace FirstMate {
|
||||
/** The option objects that the user is expected to fill out and provide to
|
||||
* specific API calls.
|
||||
*/
|
||||
namespace Options {
|
||||
interface Grammar {
|
||||
name?: string;
|
||||
fileTypes?: ReadonlyArray<string>;
|
||||
scopeName?: string;
|
||||
foldingStopMarker?: string;
|
||||
maxTokensPerLine?: number;
|
||||
maxLineLength?: number;
|
||||
|
||||
injections?: object;
|
||||
injectionSelector?: ScopeSelector;
|
||||
patterns?: ReadonlyArray<object>;
|
||||
repository?: object;
|
||||
firstLineMatch?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
/** The structures that are passed to the user by Atom following specific API calls. */
|
||||
namespace Structures {
|
||||
interface GrammarToken {
|
||||
value: string;
|
||||
scopes: string[];
|
||||
}
|
||||
|
||||
/** Result returned by `Grammar.tokenizeLine`. */
|
||||
interface TokenizeLineResult {
|
||||
/** The string of text that was tokenized. */
|
||||
line: string;
|
||||
|
||||
/** An array of integer scope ids and strings. Positive ids indicate the
|
||||
* beginning of a scope, and negative tags indicate the end. To resolve ids
|
||||
* to scope names, call GrammarRegistry::scopeForId with the absolute
|
||||
* value of the id.
|
||||
*/
|
||||
tags: Array<number|string>;
|
||||
|
||||
/** This is a dynamic property. Invoking it will incur additional overhead,
|
||||
* but will automatically translate the `tags` into token objects with `value`
|
||||
* and `scopes` properties.
|
||||
*/
|
||||
tokens: GrammarToken[];
|
||||
|
||||
/** An array of rules representing the tokenized state at the end of the line.
|
||||
* These should be passed back into this method when tokenizing the next line
|
||||
* in the file.
|
||||
*/
|
||||
ruleStack: GrammarRule[];
|
||||
}
|
||||
|
||||
interface GrammarRule {
|
||||
// https://github.com/atom/first-mate/blob/v7.0.7/src/rule.coffee
|
||||
// This is private. Don't go down the rabbit hole.
|
||||
rule: object;
|
||||
scopeName: string;
|
||||
contentScopeName: string;
|
||||
}
|
||||
}
|
||||
|
||||
/** Grammar that tokenizes lines of text. */
|
||||
interface Grammar {
|
||||
name: string;
|
||||
fileTypes: string[];
|
||||
scopeName: string;
|
||||
maxTokensPerLine: number;
|
||||
maxLineLength: number;
|
||||
|
||||
// Event Subscription
|
||||
onDidUpdate(callback: () => void): EventKit.Disposable;
|
||||
|
||||
// Tokenizing
|
||||
/** Tokenize all lines in the given text.
|
||||
* @param text A string containing one or more lines.
|
||||
* @return An array of token arrays for each line tokenized.
|
||||
*/
|
||||
tokenizeLines(text: string): Structures.GrammarToken[][];
|
||||
|
||||
/** Tokenizes the line of text.
|
||||
* @param line A string of text to tokenize.
|
||||
* @param ruleStack An optional array of rules previously returned from this
|
||||
* method. This should be null when tokenizing the first line in the file.
|
||||
* @param firstLine A optional boolean denoting whether this is the first line
|
||||
* in the file which defaults to `false`.
|
||||
* @return An object representing the result of the tokenize.
|
||||
*/
|
||||
tokenizeLine(line: string, ruleStack?: null, firstLine?: boolean):
|
||||
Structures.TokenizeLineResult;
|
||||
/** Tokenizes the line of text.
|
||||
* @param line A string of text to tokenize.
|
||||
* @param ruleStack An optional array of rules previously returned from this
|
||||
* method. This should be null when tokenizing the first line in the file.
|
||||
* @param firstLine A optional boolean denoting whether this is the first line
|
||||
* in the file which defaults to `false`.
|
||||
* @return An object representing the result of the tokenize.
|
||||
*/
|
||||
tokenizeLine(line: string, ruleStack: Structures.GrammarRule[], firstLine?: false):
|
||||
Structures.TokenizeLineResult;
|
||||
}
|
||||
|
||||
/** The static side to the Grammar class. */
|
||||
interface GrammarStatic {
|
||||
new (registry: GrammarRegistry, options?: Options.Grammar): Grammar;
|
||||
}
|
||||
|
||||
/** Instance side of GrammarRegistry class. */
|
||||
interface GrammarRegistry {
|
||||
maxTokensPerLine: number;
|
||||
maxLineLength: number;
|
||||
|
||||
// Event Subscription
|
||||
/** Invoke the given callback when a grammar is added to the registry.
|
||||
* @param callback The callback to be invoked whenever a grammar is added.
|
||||
* @return A Disposable on which `.dispose()` can be called to unsubscribe.
|
||||
*/
|
||||
onDidAddGrammar(callback: (grammar: Grammar) => void): EventKit.Disposable;
|
||||
|
||||
/** Invoke the given callback when a grammar is updated due to a grammar it
|
||||
* depends on being added or removed from the registry.
|
||||
* @param callback The callback to be invoked whenever a grammar is updated.
|
||||
* @return A Disposable on which `.dispose()` can be called to unsubscribe.
|
||||
*/
|
||||
onDidUpdateGrammar(callback: (grammar: Grammar) => void): EventKit.Disposable;
|
||||
|
||||
// Managing Grammars
|
||||
/** Get all the grammars in this registry.
|
||||
* @return A non-empty array of Grammar instances.
|
||||
*/
|
||||
getGrammars(): Grammar[];
|
||||
|
||||
/** Get a grammar with the given scope name.
|
||||
* @param scopeName A string such as `source.js`.
|
||||
* @return A Grammar or undefined.
|
||||
*/
|
||||
grammarForScopeName(scopeName: string): Grammar|undefined;
|
||||
|
||||
/** Add a grammar to this registry.
|
||||
* A 'grammar-added' event is emitted after the grammar is added.
|
||||
* @param grammar The Grammar to add. This should be a value previously returned
|
||||
* from ::readGrammar or ::readGrammarSync.
|
||||
* @return Returns a Disposable on which `.dispose()` can be called to remove
|
||||
* the grammar.
|
||||
*/
|
||||
addGrammar(grammar: Grammar): EventKit.Disposable;
|
||||
|
||||
/** Remove the given grammar from this registry.
|
||||
* @param grammar The grammar to remove. This should be a grammar previously
|
||||
* added to the registry from ::addGrammar.
|
||||
*/
|
||||
removeGrammar(grammar: Grammar): void;
|
||||
|
||||
/** Remove the grammar with the given scope name.
|
||||
* @param scopeName A string such as `source.js`.
|
||||
* @return Returns the removed Grammar or undefined.
|
||||
*/
|
||||
removeGrammarForScopeName(scopeName: string): Grammar|undefined;
|
||||
|
||||
/** Read a grammar synchronously but don't add it to the registry.
|
||||
* @param grammarPath The absolute file path to a grammar.
|
||||
* @return The newly loaded Grammar.
|
||||
*/
|
||||
readGrammarSync(grammarPath: string): Grammar;
|
||||
|
||||
/** Read a grammar asynchronously but don't add it to the registry.
|
||||
* @param grammarPath The absolute file path to the grammar.
|
||||
* @param callback The function to be invoked once the Grammar has been read in.
|
||||
*/
|
||||
readGrammar(grammarPath: string, callback: (error: Error|null, grammar?: Grammar) =>
|
||||
void): void;
|
||||
|
||||
/** Read a grammar synchronously and add it to this registry.
|
||||
* @param grammarPath The absolute file path to the grammar.
|
||||
* @return The newly loaded Grammar.
|
||||
*/
|
||||
loadGrammarSync(grammarPath: string): Grammar;
|
||||
|
||||
/** Read a grammar asynchronously and add it to the registry.
|
||||
* @param grammarPath The absolute file path to the grammar.
|
||||
* @param callback The function to be invoked once the Grammar has been read in
|
||||
* and added to the registry.
|
||||
*/
|
||||
loadGrammar(grammarPath: string, callback: (error: Error|null, grammar?: Grammar) =>
|
||||
void): void;
|
||||
|
||||
/** Convert compact tags representation into convenient, space-inefficient tokens.
|
||||
* @param lineText The text of the tokenized line.
|
||||
* @param tags The tags returned from a call to Grammar::tokenizeLine().
|
||||
* @return An array of Token instances decoded from the given tags.
|
||||
*/
|
||||
decodeTokens(lineText: string, tags: Array<number|string>): Structures.GrammarToken[];
|
||||
}
|
||||
|
||||
/** The static side to the GrammarRegistry class. */
|
||||
interface GrammarRegistryStatic {
|
||||
new (options?: { maxTokensPerLine?: number, maxLineLength?: number }):
|
||||
GrammarRegistry;
|
||||
}
|
||||
|
||||
interface ScopeSelector {
|
||||
/** Check if this scope selector matches the scopes.
|
||||
* @param scopes A single scope or an array of them to be compared against.
|
||||
* @return A boolean indicating whether or not this ScopeSelector matched.
|
||||
*/
|
||||
matches(scopes: string|ReadonlyArray<string>): boolean;
|
||||
|
||||
/** Gets the prefix of this scope selector.
|
||||
* @param scopes The scopes to match a prefix against.
|
||||
* @return The matching prefix, if there is one.
|
||||
*/
|
||||
getPrefix(scopes: string|ReadonlyArray<string>): string|undefined;
|
||||
|
||||
/** Convert this TextMate scope selector to a CSS selector.
|
||||
* @return A string with the CSSSelector representation of this ScopeSelector.
|
||||
*/
|
||||
toCssSelector(): string;
|
||||
|
||||
/** Convert this TextMate scope selector to a CSS selector, prefixing scopes
|
||||
* with `syntax--`.
|
||||
* @return A string with the syntax-specific CSSSelector representation of this
|
||||
* ScopeSelector.
|
||||
*/
|
||||
toCssSyntaxSelector(): string;
|
||||
}
|
||||
|
||||
/** The static side to the ScopeSelector class. */
|
||||
interface ScopeSelectorStatic {
|
||||
/** Create a new scope selector.
|
||||
* @param source The string to parse as a scope selector.
|
||||
* @return A newly constructed ScopeSelector.
|
||||
*/
|
||||
new (source: string): ScopeSelector;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Registry containing one or more grammars. */
|
||||
export const GrammarRegistry: FirstMate.GrammarRegistryStatic;
|
||||
|
||||
export const ScopeSelector: FirstMate.ScopeSelectorStatic;
|
||||
import { Disposable } from "event-kit";
|
||||
|
||||
/** Grammar that tokenizes lines of text. */
|
||||
export const Grammar: FirstMate.GrammarStatic;
|
||||
export class Grammar {
|
||||
name: string;
|
||||
fileTypes: string[];
|
||||
scopeName: string;
|
||||
maxTokensPerLine: number;
|
||||
maxLineLength: number;
|
||||
|
||||
constructor(registry: GrammarRegistry, options?: GrammarOptions);
|
||||
|
||||
// Event Subscription
|
||||
onDidUpdate(callback: () => void): Disposable;
|
||||
|
||||
// Tokenizing
|
||||
/**
|
||||
* Tokenize all lines in the given text.
|
||||
* @param text A string containing one or more lines.
|
||||
* @return An array of token arrays for each line tokenized.
|
||||
*/
|
||||
tokenizeLines(text: string): GrammarToken[][];
|
||||
|
||||
/**
|
||||
* Tokenizes the line of text.
|
||||
* @param line A string of text to tokenize.
|
||||
* @param ruleStack An optional array of rules previously returned from this
|
||||
* method. This should be null when tokenizing the first line in the file.
|
||||
* @param firstLine A optional boolean denoting whether this is the first line
|
||||
* in the file which defaults to `false`.
|
||||
* @return An object representing the result of the tokenize.
|
||||
*/
|
||||
tokenizeLine(line: string, ruleStack?: null, firstLine?: boolean): TokenizeLineResult;
|
||||
/**
|
||||
* Tokenizes the line of text.
|
||||
* @param line A string of text to tokenize.
|
||||
* @param ruleStack An optional array of rules previously returned from this
|
||||
* method. This should be null when tokenizing the first line in the file.
|
||||
* @param firstLine A optional boolean denoting whether this is the first line
|
||||
* in the file which defaults to `false`.
|
||||
* @return An object representing the result of the tokenize.
|
||||
*/
|
||||
tokenizeLine(line: string, ruleStack: GrammarRule[], firstLine?: false):
|
||||
TokenizeLineResult;
|
||||
}
|
||||
|
||||
/** Instance side of GrammarRegistry class. */
|
||||
export class GrammarRegistry {
|
||||
maxTokensPerLine: number;
|
||||
maxLineLength: number;
|
||||
|
||||
constructor(options?: { maxTokensPerLine?: number, maxLineLength?: number });
|
||||
|
||||
// Event Subscription
|
||||
/**
|
||||
* Invoke the given callback when a grammar is added to the registry.
|
||||
* @param callback The callback to be invoked whenever a grammar is added.
|
||||
* @return A Disposable on which `.dispose()` can be called to unsubscribe.
|
||||
*/
|
||||
onDidAddGrammar(callback: (grammar: Grammar) => void): Disposable;
|
||||
|
||||
/**
|
||||
* Invoke the given callback when a grammar is updated due to a grammar it
|
||||
* depends on being added or removed from the registry.
|
||||
* @param callback The callback to be invoked whenever a grammar is updated.
|
||||
* @return A Disposable on which `.dispose()` can be called to unsubscribe.
|
||||
*/
|
||||
onDidUpdateGrammar(callback: (grammar: Grammar) => void): Disposable;
|
||||
|
||||
// Managing Grammars
|
||||
/**
|
||||
* Get all the grammars in this registry.
|
||||
* @return A non-empty array of Grammar instances.
|
||||
*/
|
||||
getGrammars(): Grammar[];
|
||||
|
||||
/**
|
||||
* Get a grammar with the given scope name.
|
||||
* @param scopeName A string such as `source.js`.
|
||||
* @return A Grammar or undefined.
|
||||
*/
|
||||
grammarForScopeName(scopeName: string): Grammar|undefined;
|
||||
|
||||
/**
|
||||
* Add a grammar to this registry.
|
||||
* A 'grammar-added' event is emitted after the grammar is added.
|
||||
* @param grammar The Grammar to add. This should be a value previously returned
|
||||
* from ::readGrammar or ::readGrammarSync.
|
||||
* @return Returns a Disposable on which `.dispose()` can be called to remove
|
||||
* the grammar.
|
||||
*/
|
||||
addGrammar(grammar: Grammar): Disposable;
|
||||
|
||||
/**
|
||||
* Remove the given grammar from this registry.
|
||||
* @param grammar The grammar to remove. This should be a grammar previously
|
||||
* added to the registry from ::addGrammar.
|
||||
*/
|
||||
removeGrammar(grammar: Grammar): void;
|
||||
|
||||
/**
|
||||
* Remove the grammar with the given scope name.
|
||||
* @param scopeName A string such as `source.js`.
|
||||
* @return Returns the removed Grammar or undefined.
|
||||
*/
|
||||
removeGrammarForScopeName(scopeName: string): Grammar|undefined;
|
||||
|
||||
/**
|
||||
* Read a grammar synchronously but don't add it to the registry.
|
||||
* @param grammarPath The absolute file path to a grammar.
|
||||
* @return The newly loaded Grammar.
|
||||
*/
|
||||
readGrammarSync(grammarPath: string): Grammar;
|
||||
|
||||
/**
|
||||
* Read a grammar asynchronously but don't add it to the registry.
|
||||
* @param grammarPath The absolute file path to the grammar.
|
||||
* @param callback The function to be invoked once the Grammar has been read in.
|
||||
*/
|
||||
readGrammar(grammarPath: string, callback: (error: Error|null, grammar?: Grammar) =>
|
||||
void): void;
|
||||
|
||||
/**
|
||||
* Read a grammar synchronously and add it to this registry.
|
||||
* @param grammarPath The absolute file path to the grammar.
|
||||
* @return The newly loaded Grammar.
|
||||
*/
|
||||
loadGrammarSync(grammarPath: string): Grammar;
|
||||
|
||||
/**
|
||||
* Read a grammar asynchronously and add it to the registry.
|
||||
* @param grammarPath The absolute file path to the grammar.
|
||||
* @param callback The function to be invoked once the Grammar has been read in
|
||||
* and added to the registry.
|
||||
*/
|
||||
loadGrammar(grammarPath: string, callback: (error: Error|null, grammar?: Grammar) =>
|
||||
void): void;
|
||||
|
||||
/**
|
||||
* Convert compact tags representation into convenient, space-inefficient tokens.
|
||||
* @param lineText The text of the tokenized line.
|
||||
* @param tags The tags returned from a call to Grammar::tokenizeLine().
|
||||
* @return An array of Token instances decoded from the given tags.
|
||||
*/
|
||||
decodeTokens(lineText: string, tags: Array<number|string>): GrammarToken[];
|
||||
}
|
||||
|
||||
export class ScopeSelector {
|
||||
/**
|
||||
* Create a new scope selector.
|
||||
* @param source The string to parse as a scope selector.
|
||||
* @return A newly constructed ScopeSelector.
|
||||
*/
|
||||
constructor(source: string);
|
||||
|
||||
/**
|
||||
* Check if this scope selector matches the scopes.
|
||||
* @param scopes A single scope or an array of them to be compared against.
|
||||
* @return A boolean indicating whether or not this ScopeSelector matched.
|
||||
*/
|
||||
matches(scopes: string|ReadonlyArray<string>): boolean;
|
||||
|
||||
/**
|
||||
* Gets the prefix of this scope selector.
|
||||
* @param scopes The scopes to match a prefix against.
|
||||
* @return The matching prefix, if there is one.
|
||||
*/
|
||||
getPrefix(scopes: string|ReadonlyArray<string>): string|undefined;
|
||||
|
||||
/**
|
||||
* Convert this TextMate scope selector to a CSS selector.
|
||||
* @return A string with the CSSSelector representation of this ScopeSelector.
|
||||
*/
|
||||
toCssSelector(): string;
|
||||
|
||||
/**
|
||||
* Convert this TextMate scope selector to a CSS selector, prefixing scopes
|
||||
* with `syntax--`.
|
||||
* @return A string with the syntax-specific CSSSelector representation of this
|
||||
* ScopeSelector.
|
||||
*/
|
||||
toCssSyntaxSelector(): string;
|
||||
}
|
||||
|
||||
// Options ====================================================================
|
||||
// The option objects that the user is expected to fill out and provide to
|
||||
// specific API calls.
|
||||
|
||||
export interface GrammarOptions {
|
||||
name?: string;
|
||||
fileTypes?: ReadonlyArray<string>;
|
||||
scopeName?: string;
|
||||
foldingStopMarker?: string;
|
||||
maxTokensPerLine?: number;
|
||||
maxLineLength?: number;
|
||||
|
||||
injections?: object;
|
||||
injectionSelector?: ScopeSelector;
|
||||
patterns?: ReadonlyArray<object>;
|
||||
repository?: object;
|
||||
firstLineMatch?: boolean;
|
||||
}
|
||||
|
||||
// Structures =================================================================
|
||||
// The structures that are passed to the user by Atom following specific API calls.
|
||||
|
||||
export interface GrammarToken {
|
||||
value: string;
|
||||
scopes: string[];
|
||||
}
|
||||
|
||||
/** Result returned by `Grammar.tokenizeLine`. */
|
||||
export interface TokenizeLineResult {
|
||||
/** The string of text that was tokenized. */
|
||||
line: string;
|
||||
|
||||
/**
|
||||
* An array of integer scope ids and strings. Positive ids indicate the
|
||||
* beginning of a scope, and negative tags indicate the end. To resolve ids
|
||||
* to scope names, call GrammarRegistry::scopeForId with the absolute
|
||||
* value of the id.
|
||||
*/
|
||||
tags: Array<number|string>;
|
||||
|
||||
/**
|
||||
* This is a dynamic property. Invoking it will incur additional overhead,
|
||||
* but will automatically translate the `tags` into token objects with `value`
|
||||
* and `scopes` properties.
|
||||
*/
|
||||
tokens: GrammarToken[];
|
||||
|
||||
/**
|
||||
* An array of rules representing the tokenized state at the end of the line.
|
||||
* These should be passed back into this method when tokenizing the next line
|
||||
* in the file.
|
||||
*/
|
||||
ruleStack: GrammarRule[];
|
||||
}
|
||||
|
||||
export interface GrammarRule {
|
||||
// https://github.com/atom/first-mate/blob/v7.0.7/src/rule.coffee
|
||||
// This is private. Don't go down the rabbit hole.
|
||||
rule: object;
|
||||
scopeName: string;
|
||||
contentScopeName: string;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": false,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
@@ -21,4 +21,4 @@
|
||||
"index.d.ts",
|
||||
"first-mate-tests.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,36 +1,8 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"class-name": true,
|
||||
"indent": [true, "spaces", 4],
|
||||
"jsdoc-format": true,
|
||||
"max-line-length": [true, 110],
|
||||
"quotemark": [true, "double", "avoid-escape"],
|
||||
"trailing-comma": [true, {
|
||||
"multiline": { "objects": "always", "arrays": "always", "functions": "never" },
|
||||
"singleline": { "objects": "never", "arrays": "never", "functions": "never" }
|
||||
}],
|
||||
"whitespace": [
|
||||
true,
|
||||
"check-branch",
|
||||
"check-decl",
|
||||
"check-operator",
|
||||
"check-module",
|
||||
"check-separator",
|
||||
"check-type",
|
||||
"check-typecast",
|
||||
"check-rest-spread",
|
||||
"check-preblock"
|
||||
],
|
||||
// Soon to be defaults.
|
||||
"arrow-return-shorthand": [true, "multiline"],
|
||||
"no-any": true,
|
||||
"no-floating-promises": true,
|
||||
"no-unbound-method": true,
|
||||
"no-unsafe-any": true,
|
||||
"number-literal-format": true,
|
||||
"restrict-plus-operands": true,
|
||||
"return-undefined": true,
|
||||
"switch-final-break": true
|
||||
"max-line-length": [true, 100],
|
||||
"no-any": true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,9 @@ import {
|
||||
Dms,
|
||||
Vector3d,
|
||||
OsGridRef,
|
||||
LatLonEllipsoidal as LatLon, LatLonSpherical } from 'geodesy';
|
||||
LatLonEllipsoidal as LatLon, LatLonSpherical,
|
||||
LatLonVectors
|
||||
} from 'geodesy';
|
||||
|
||||
/**
|
||||
* Mgrs
|
||||
@@ -165,3 +167,38 @@ LatLonSpherical.crossingParallels(point1, point2, 30);
|
||||
const polygon = [new LatLonSpherical(0, 0), new LatLonSpherical(1, 0), new LatLonSpherical(0, 1)];
|
||||
LatLonSpherical.areaOf(polygon); // 6.18e9 m²
|
||||
LatLonSpherical.areaOf(polygon, 6371e3); // 6.18e9 m²
|
||||
|
||||
/**
|
||||
* LatLonVectors
|
||||
*/
|
||||
const point3 = new LatLonVectors(49.78846, -97.44306);
|
||||
const point4 = new LatLonVectors(49.79822, -97.4592);
|
||||
const point5 = new LatLonVectors(49.7981, -97.41371);
|
||||
const point6 = new LatLonVectors(49.76851, -97.41371);
|
||||
const point7 = new LatLonVectors(49.76873, -97.45954);
|
||||
const point8 = new LatLonVectors(49.78846, -97.44306);
|
||||
point3.toVector(); // Vector3d { x: -0.08363305717526297, y: -0.6401716454146233, z: 0.7636660108677438 }
|
||||
point3.greatCircle(45); // Vector3d { x: -0.6311975610221534, y: 0.6270426835846277, z: 0.45651627782881243 }
|
||||
point3.distanceTo(point4, 6371e3); // 1587.463492544562 m
|
||||
point3.bearingTo(point4); // 313.1353494923952 deg
|
||||
point3.midpointTo(point4); // LatLon { lat: 49.79334028019261, lon: -97.45112918683637 }
|
||||
point3.intermediatePointTo(point4, 0.25); // LatLon { lat: 49.79090021013134, lon: -97.44709439015365 }
|
||||
point3.intermediatePointOnChordTo(point4, 0.5); // LatLon { lat: 49.7933402801926, lon: -97.45112918683637 }
|
||||
point3.destinationPoint(100, 0, 6371e3); // LatLon { lat: 49.78935932160593, lon: -97.44306000000003 }
|
||||
point3.crossTrackDistanceTo(point4, point5, 6371e3); // 1080.7461902301488 m
|
||||
point3.crossTrackDistanceTo(point4, 60, 6371e3); // 1519.091945034438 m
|
||||
point3.alongTrackDistanceTo(point4, point5, 6371e3); // 1162.7673995854138 m
|
||||
point3.alongTrackDistanceTo(point4, 60, 6371e3); // 460.86875216457025 m
|
||||
point3.nearestPointOnSegment(point4, point5); // LatLon { lat: 49.79817930627353, lon: -97.44299978937423 }
|
||||
point3.isBetween(point4, point5); // true
|
||||
|
||||
const boundary = [point4, point5, point6, point7];
|
||||
point3.enclosedBy(boundary); // true
|
||||
point3.equals(point4); // false
|
||||
point3.equals(point8); // true
|
||||
point3.toString('dms', 3); // 49°47′18.456″N, 097°26′35.016″W
|
||||
|
||||
// Static functions
|
||||
LatLonVectors.intersection(point4, point5, point3, 1); // LatLon { lat: 49.7981787830497, lon: -97.44279718554108 }
|
||||
LatLonVectors.areaOf(boundary, 6371e3); // 10768180.94129682 m^2
|
||||
LatLonVectors.meanOf(boundary); // LatLon { lat: 49.783392242641824, lon: -97.43653998581752 }
|
||||
|
||||
Vendored
+26
-1
@@ -1,7 +1,8 @@
|
||||
// Type definitions for geodesy 1.1
|
||||
// Type definitions for geodesy 1.2
|
||||
// Project: https://github.com/chrisveness/geodesy
|
||||
// Definitions by: Denis Carriere <https://github.com/DenisCarriere>
|
||||
// Gilbert Handy <https://github.com/HandyG52>
|
||||
// Harry Nicholls <https://github.com/excelulous>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export type format = 'd' | 'dm' | 'dms';
|
||||
@@ -168,3 +169,27 @@ export class LatLonSpherical {
|
||||
static areaOf(polygon: LatLonSpherical[], radius?: number): number;
|
||||
toString(format?: string, dp?: number): string;
|
||||
}
|
||||
|
||||
export class LatLonVectors {
|
||||
lat: number;
|
||||
lon: number;
|
||||
constructor(lat: number, lon: number);
|
||||
toVector(): Vector3d;
|
||||
greatCircle(bearing: number): Vector3d;
|
||||
distanceTo(point: LatLonVectors, radius?: number): number;
|
||||
bearingTo(point: LatLonVectors): number;
|
||||
midpointTo(point: LatLonVectors): number;
|
||||
intermediatePointTo(point: LatLonVectors, fraction: number): LatLonVectors;
|
||||
intermediatePointOnChordTo(point: LatLonVectors, fraction: number): LatLonVectors;
|
||||
destinationPoint(distance: number, bearing: number, radius?: number): LatLonVectors;
|
||||
static intersection(path1start: LatLonVectors, path1brngEnd: LatLonVectors | number, path2start: LatLonVectors, path2brngEnd: LatLonVectors | number): LatLonVectors;
|
||||
crossTrackDistanceTo(pathStart: LatLonVectors, pathBrngEnd: LatLonVectors | number, radius?: number): number;
|
||||
alongTrackDistanceTo(pathStart: LatLonVectors, pathBrngEnd: LatLonVectors | number, radius?: number): number;
|
||||
nearestPointOnSegment(point1: LatLonVectors, point2: LatLonVectors): LatLonVectors;
|
||||
isBetween(point1: LatLonVectors, point2: LatLonVectors): boolean;
|
||||
enclosedBy(polygon: LatLonVectors[]): boolean;
|
||||
static areaOf(polygon: LatLonVectors[], radius?: number): number;
|
||||
static meanOf(points: ReadonlyArray<LatLonVectors>): LatLonVectors;
|
||||
equals(point: LatLonVectors): boolean;
|
||||
toString(format?: string, dp?: number): string;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
import guid = require('guid');
|
||||
|
||||
// $ExpectType object
|
||||
guid.create();
|
||||
|
||||
// $ExpectType string
|
||||
guid.raw();
|
||||
|
||||
const newRawGuid = guid.raw();
|
||||
|
||||
// $ExpectType boolean
|
||||
guid.isGuid(newRawGuid);
|
||||
|
||||
// $ExpectType string
|
||||
guid.EMPTY;
|
||||
|
||||
// $ExpectType object
|
||||
guid(guid.create());
|
||||
Vendored
+22
@@ -0,0 +1,22 @@
|
||||
// Type definitions for guid 1.0
|
||||
// Project: https://github.com/dandean/guid
|
||||
// Definitions by: Marc-Andre Roy <https://github.com/maroy1986>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
export = guid;
|
||||
|
||||
declare function guid(guid: object): object;
|
||||
|
||||
declare namespace guid {
|
||||
const EMPTY: string;
|
||||
|
||||
const prototype: {
|
||||
};
|
||||
|
||||
function create(): object;
|
||||
|
||||
function isGuid(value: string): boolean;
|
||||
|
||||
function raw(): string;
|
||||
}
|
||||
@@ -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",
|
||||
"guid-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
@@ -0,0 +1,73 @@
|
||||
import http = require('http');
|
||||
import httpContext = require('http-context');
|
||||
|
||||
const context: httpContext.Context = httpContext();
|
||||
const request: httpContext.Request = context.request;
|
||||
const response: httpContext.Response = context.response;
|
||||
|
||||
let header: http.IncomingHttpHeaders = context.header;
|
||||
header = context.headers;
|
||||
header = request.header;
|
||||
header = request.headers;
|
||||
const headerString: string | string[] = header['Content-Type'];
|
||||
|
||||
let url: string = context.url;
|
||||
url = request.url;
|
||||
context.accepts('html');
|
||||
|
||||
let href: string = context.href;
|
||||
href = request.href;
|
||||
|
||||
let method: string = context.method;
|
||||
method = request.method;
|
||||
|
||||
let path: string = context.path;
|
||||
path = request.path;
|
||||
|
||||
let query: {[param: string]: string | string[]} = context.query;
|
||||
query = request.query;
|
||||
const querySearch: string | string[] = query['search'];
|
||||
|
||||
let queryString: string = context.querystring;
|
||||
queryString = request.querystring;
|
||||
|
||||
let search: string = context.search;
|
||||
search = request.search;
|
||||
|
||||
let host: string = context.host;
|
||||
host = request.host;
|
||||
|
||||
let hostname: string = context.hostname;
|
||||
hostname = request.hostname;
|
||||
|
||||
let fresh: boolean = context.fresh;
|
||||
fresh = request.fresh;
|
||||
|
||||
let idempotent: boolean = context.idempotent;
|
||||
idempotent = request.idempotent;
|
||||
|
||||
let protocol: string = context.protocol;
|
||||
protocol = request.protocol;
|
||||
|
||||
let secure: boolean = context.secure;
|
||||
secure = request.secure;
|
||||
|
||||
let subdomains: string[] = context.subdomains;
|
||||
subdomains = request.subdomains;
|
||||
|
||||
let accepts: string[] | string | false = context.accepts('text/html');
|
||||
accepts = request.accepts('text/html');
|
||||
accepts = request.accepts('text/html', 'text/txt');
|
||||
accepts = request.accepts(['text/html', 'text/txt']);
|
||||
|
||||
let status: number = context.status;
|
||||
status = response.status;
|
||||
|
||||
let message: string = context.message;
|
||||
message = response.message;
|
||||
|
||||
let body: any = context.body;
|
||||
body = response.body;
|
||||
|
||||
let length: number = context.length;
|
||||
length = response.length;
|
||||
Vendored
+101
@@ -0,0 +1,101 @@
|
||||
// Type definitions for http-context 1.1
|
||||
// Project: https://github.com/lapwinglabs/http-context#readme
|
||||
// Definitions by: Matt Traynham <https://github.com/mtraynham>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
import accepts = require('accepts');
|
||||
import http = require('http');
|
||||
|
||||
export = HttpContext;
|
||||
|
||||
declare function HttpContext(): HttpContext.Context;
|
||||
|
||||
declare namespace HttpContext {
|
||||
interface RequestJSON {
|
||||
method: string;
|
||||
url: string;
|
||||
header: http.IncomingHttpHeaders;
|
||||
}
|
||||
|
||||
interface RequestDelegate {
|
||||
header: http.IncomingHttpHeaders;
|
||||
headers: http.IncomingHttpHeaders;
|
||||
url: string;
|
||||
href: string;
|
||||
method: string;
|
||||
path: string;
|
||||
query: {[param: string]: string | string[]};
|
||||
querystring: string;
|
||||
search: string;
|
||||
host: string;
|
||||
hostname: string;
|
||||
fresh: boolean;
|
||||
idempotent: boolean;
|
||||
protocol: string;
|
||||
secure: boolean;
|
||||
subdomains: string[];
|
||||
accepts(types: string[]): string[] | string | false;
|
||||
accepts(...types: string[]): string[] | string | false;
|
||||
acceptsCharsets(charsets: string[]): string | false;
|
||||
acceptsCharsets(...charsets: string[]): string | false;
|
||||
acceptsEncodings(encodings: string[]): string | false;
|
||||
acceptsEncodings(...encodings: string[]): string | false;
|
||||
acceptsLanguages(languages: string[]): string | false;
|
||||
acceptsLanguages(...languages: string[]): string | false;
|
||||
is(types: string[]): string | false;
|
||||
is(...types: string[]): string | false;
|
||||
get(field: string): string;
|
||||
}
|
||||
|
||||
interface Request extends RequestDelegate {
|
||||
request: http.IncomingMessage;
|
||||
charset: string;
|
||||
length: number;
|
||||
type: string;
|
||||
accept: accepts.Accepts;
|
||||
inspect(): RequestJSON;
|
||||
toJSON(): RequestJSON;
|
||||
}
|
||||
|
||||
interface ResponseJSON {
|
||||
status: number;
|
||||
message: string;
|
||||
header: http.OutgoingHttpHeaders;
|
||||
}
|
||||
|
||||
interface ResponseDelegate {
|
||||
status: number;
|
||||
message: string;
|
||||
body: any;
|
||||
length: number;
|
||||
headerSent: boolean;
|
||||
type: string;
|
||||
lastModified: string | Date;
|
||||
etag: string;
|
||||
writable: boolean;
|
||||
vary(field: string): void;
|
||||
redirect(url: string, alt: string): void;
|
||||
attachment(filename: string): void;
|
||||
set(field: string, val: string): void;
|
||||
append(field: string, val: string[]): void;
|
||||
append(field: string, ...val: string[]): void;
|
||||
remove(field: string): void;
|
||||
}
|
||||
|
||||
interface Response extends ResponseDelegate {
|
||||
response: http.OutgoingMessage;
|
||||
header: http.OutgoingHttpHeaders;
|
||||
is(types: string[]): string | false;
|
||||
is(...types: string[]): string | false;
|
||||
get(field: string): string;
|
||||
inspect(): ResponseJSON;
|
||||
toJSON(): ResponseJSON;
|
||||
}
|
||||
|
||||
interface Context extends RequestDelegate, ResponseDelegate {
|
||||
request: Request;
|
||||
response: Response;
|
||||
}
|
||||
}
|
||||
@@ -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",
|
||||
"http-context-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Vendored
+486
@@ -0,0 +1,486 @@
|
||||
// Type definitions for iota.lib.js 0.4
|
||||
// Project: https://github.com/iotaledger/iota.lib.js
|
||||
// Definitions by: Fogsh <https://github.com/fogsh>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare class IotaClass {
|
||||
constructor(settings: {
|
||||
provider: string;
|
||||
sandbox?: boolean;
|
||||
token?: boolean;
|
||||
} | {
|
||||
host: string;
|
||||
port: number;
|
||||
sandbox?: boolean;
|
||||
token?: boolean;
|
||||
});
|
||||
|
||||
api: IotaApi;
|
||||
utils: IotaUtils;
|
||||
multisig: IotaMultisig;
|
||||
valid: IotaValid;
|
||||
|
||||
version: string;
|
||||
}
|
||||
|
||||
export = IotaClass;
|
||||
|
||||
//
|
||||
// Types
|
||||
//
|
||||
|
||||
type Security = 1 | 2 | 3;
|
||||
type IOTAUnit = "i" | "Ki" | "Mi" | "Gi" | "Ti" | "Pi";
|
||||
|
||||
//
|
||||
// Objects
|
||||
//
|
||||
|
||||
interface TransactionObject {
|
||||
hash: string;
|
||||
signatureMessageFragment: string;
|
||||
address: string;
|
||||
value: number;
|
||||
tag: string;
|
||||
timestamp: number;
|
||||
currentIndex: number;
|
||||
lastIndex: number;
|
||||
bundle: number;
|
||||
trunkTransaction: string;
|
||||
branchTransaction: string;
|
||||
attachmentTimestamp: number;
|
||||
attachmentTimestampLowerBound: number;
|
||||
attachmentTimestampUpperBound: number;
|
||||
nonce: string;
|
||||
}
|
||||
|
||||
interface InputObject {
|
||||
address: string;
|
||||
balance: number;
|
||||
keyIndex: number;
|
||||
security: Security;
|
||||
}
|
||||
|
||||
interface TransferObject {
|
||||
address: string;
|
||||
value: number;
|
||||
message: string;
|
||||
tag: string;
|
||||
}
|
||||
|
||||
interface NodeInfo {
|
||||
appName: string;
|
||||
appVersion: string;
|
||||
duration: number;
|
||||
jreAvailableProcessors: number;
|
||||
jreFreeMemory: number;
|
||||
jreVersion: string;
|
||||
jreMaxMemory: number;
|
||||
jreTotalMemory: number;
|
||||
latestMilestone: string;
|
||||
latestMilestoneIndex: number;
|
||||
latestSolidSubtangleMilestone: string;
|
||||
latestSolidSubtangleMilestoneIndex: number;
|
||||
neighbors: number;
|
||||
packetsQueueSize: number;
|
||||
time: number;
|
||||
tips: number;
|
||||
transactionsToRequest: number;
|
||||
}
|
||||
|
||||
interface Neighbor {
|
||||
address: string;
|
||||
numberOfAllTransactions: number;
|
||||
numberOfRandomTransactionRequests: number;
|
||||
numberOfInvalidTransactions: number;
|
||||
numberOfSentTransactions: number;
|
||||
numberOfNewTransactions: number;
|
||||
connectionType: "udp" | "tcp";
|
||||
}
|
||||
|
||||
//
|
||||
// iota.api
|
||||
//
|
||||
|
||||
interface IriApi {
|
||||
getNodeInfo(
|
||||
callback: (error: Error, info: NodeInfo) => void
|
||||
): void;
|
||||
|
||||
getNeighbors(
|
||||
callback: (error: Error, neighbors: Neighbor[]) => void
|
||||
): void;
|
||||
|
||||
addNeighbors(
|
||||
uris: string[],
|
||||
callback: (error: Error, addedNeighbors: number) => void
|
||||
): void;
|
||||
|
||||
removeNeighbors(
|
||||
uris: string[],
|
||||
callback: (error: Error, removedNeighbors: number[]) => void
|
||||
): void;
|
||||
|
||||
getTips(
|
||||
callback: (error: Error, hashes: string[]) => void
|
||||
): void;
|
||||
|
||||
findTransactions(
|
||||
searchValues: {
|
||||
addresses?: string[]
|
||||
bundles?: string[]
|
||||
tags?: string[]
|
||||
approvees?: string[]
|
||||
},
|
||||
callback: (error: Error, hashes: string[]) => void
|
||||
): void;
|
||||
|
||||
getTrytes(
|
||||
hashes: string[],
|
||||
callback: (error: Error, trytes: string[]) => void
|
||||
): void;
|
||||
|
||||
getInclusionStates(
|
||||
transactions: string[],
|
||||
tips: string[],
|
||||
callback: (error: Error, states: boolean[]) => void
|
||||
): void;
|
||||
|
||||
getBalances(
|
||||
addresses: string[],
|
||||
treshold: number,
|
||||
callback: (error: Error, response: {
|
||||
balances: number[]
|
||||
milestone: string;
|
||||
milestoneIndex: number;
|
||||
duration: number;
|
||||
}) => void
|
||||
): void;
|
||||
|
||||
getTransactionsToApprove(
|
||||
depth: number,
|
||||
callback: (error: Error, response: {
|
||||
trunkTransaction: string;
|
||||
branchTransaction: string;
|
||||
duration: number;
|
||||
}) => void
|
||||
): void;
|
||||
|
||||
attachToTangle(
|
||||
trunkTransaction: string,
|
||||
branchTransaction: string,
|
||||
minWeightMagnitude: number,
|
||||
trytes: string[],
|
||||
callback: (error: Error, trytes: string[]) => void
|
||||
): void;
|
||||
|
||||
interruptAttachingToTangle(
|
||||
callback: (error: Error, response: {}) => void
|
||||
): void;
|
||||
|
||||
broadcastTransactions(
|
||||
trytes: string[],
|
||||
callback: (error: Error, response: {}) => void
|
||||
): void;
|
||||
|
||||
storeTransactions(
|
||||
trytes: string[],
|
||||
callback: (error: Error, response: {}) => void
|
||||
): void;
|
||||
}
|
||||
|
||||
//
|
||||
// iota.api
|
||||
//
|
||||
|
||||
interface IotaApi extends IriApi {
|
||||
getTransactionsObjects(
|
||||
hashes: string[],
|
||||
callback?: (error: Error, transactions: TransactionObject[]) => void
|
||||
): void;
|
||||
|
||||
findTransactionObjects(
|
||||
searchValues: {
|
||||
addresses?: string[]
|
||||
bundles?: string[]
|
||||
tags?: string[]
|
||||
approvees?: string[]
|
||||
},
|
||||
callback?: (error: Error, transactions: TransactionObject[]) => void
|
||||
): void;
|
||||
|
||||
getLatestInclusion(
|
||||
hashes: string[],
|
||||
callback?: (error: Error, states: boolean[]) => void
|
||||
): void;
|
||||
|
||||
broadcastAndStore(
|
||||
trytes: string[],
|
||||
callback?: (error: Error, response: {}) => void
|
||||
): void;
|
||||
|
||||
getNewAddress(
|
||||
seed: string,
|
||||
options?: {
|
||||
index?: number;
|
||||
checksum?: boolean;
|
||||
total?: number;
|
||||
security?: Security
|
||||
returnAll?: boolean;
|
||||
},
|
||||
callback?: (error: Error, response: string | string[]) => void
|
||||
): void;
|
||||
|
||||
getInputs(
|
||||
seed: string,
|
||||
options?: {
|
||||
start?: number;
|
||||
end?: number;
|
||||
security?: Security
|
||||
threshold?: boolean;
|
||||
},
|
||||
callback?: (error: Error, response: {
|
||||
inputs: InputObject[]
|
||||
}) => void
|
||||
): void;
|
||||
|
||||
prepareTransfers(
|
||||
seed: string,
|
||||
transfers: TransferObject[],
|
||||
options?: {
|
||||
inputs?: string[],
|
||||
address?: string,
|
||||
security?: Security
|
||||
},
|
||||
callback?: (error: Error, response: {
|
||||
trytes: string[]
|
||||
}) => void
|
||||
): void;
|
||||
|
||||
sendTrytes(
|
||||
trytes: string[],
|
||||
depth: number,
|
||||
minWeightMagnitude: number,
|
||||
callback?: (error: Error, response: {
|
||||
inputs: TransactionObject[]
|
||||
}) => void
|
||||
): void;
|
||||
|
||||
sendTransfer(
|
||||
seed: string,
|
||||
depth: number,
|
||||
minWeightMagnitude: number,
|
||||
transfers: TransferObject[],
|
||||
options?: {
|
||||
inputs: string[],
|
||||
address: string;
|
||||
},
|
||||
callback?: (error: Error, response: {
|
||||
inputs: TransactionObject[]
|
||||
}) => void
|
||||
): void;
|
||||
|
||||
replayBundle(
|
||||
transactionHash: string,
|
||||
depth: number,
|
||||
minWeightMagnitude: number,
|
||||
callback?: (error: Error, response: {}) => void
|
||||
): void;
|
||||
|
||||
broadcastBundle(
|
||||
transactionHash: string,
|
||||
callback?: (error: Error, response: {}) => void
|
||||
): void;
|
||||
|
||||
getBundle(
|
||||
transactionHash: string,
|
||||
callback?: (error: Error, bundle: TransactionObject[]) => void
|
||||
): void;
|
||||
|
||||
getTransfers(
|
||||
seed: string,
|
||||
options?: {
|
||||
start?: number;
|
||||
end?: number;
|
||||
security?: Security
|
||||
inclusionStates?: boolean;
|
||||
},
|
||||
callback?: (error: Error, transfers: TransactionObject[][]) => void
|
||||
): void;
|
||||
|
||||
getAccountData(
|
||||
seed: string,
|
||||
options?: {
|
||||
start: number;
|
||||
end: number;
|
||||
security?: Security
|
||||
},
|
||||
callback?: (error: Error, response: {
|
||||
latestAddress: string;
|
||||
addresses: string[]
|
||||
transfers: string[]
|
||||
inputs: InputObject[]
|
||||
balance: number;
|
||||
}) => void
|
||||
): void;
|
||||
|
||||
isReattachable(
|
||||
address: string | string[],
|
||||
callback?: (error: Error, response: boolean | boolean[]) => void
|
||||
): void;
|
||||
}
|
||||
|
||||
//
|
||||
// iota.utils
|
||||
//
|
||||
|
||||
interface IotaUtils {
|
||||
convertUnits(
|
||||
value: number,
|
||||
fromUnit: IOTAUnit,
|
||||
toUnit: IOTAUnit
|
||||
): number;
|
||||
|
||||
addChecksum(
|
||||
inputValue: string,
|
||||
checksumLength?: number,
|
||||
isAddress?: boolean
|
||||
): string;
|
||||
|
||||
addChecksum(
|
||||
inputValue: string[],
|
||||
checksumLength?: number,
|
||||
isAddress?: boolean
|
||||
): string[];
|
||||
|
||||
noChecksum(
|
||||
address: string
|
||||
): string;
|
||||
|
||||
isValidChecksum(
|
||||
addressWithChecksum: string
|
||||
): boolean;
|
||||
|
||||
transactionObject(
|
||||
trytes: string
|
||||
): TransactionObject;
|
||||
|
||||
transactionTrytes(
|
||||
transaction: TransactionObject
|
||||
): string;
|
||||
|
||||
categorizeTransfers(
|
||||
transfers: TransactionObject[],
|
||||
addresses: string[]
|
||||
): {
|
||||
sent: TransactionObject[]
|
||||
received: TransactionObject[]
|
||||
};
|
||||
|
||||
toTrytes(
|
||||
input: string
|
||||
): string;
|
||||
|
||||
fromTrytes(
|
||||
trytes: string
|
||||
): string;
|
||||
|
||||
extractJson(
|
||||
bundle: TransactionObject[]
|
||||
): string;
|
||||
|
||||
validateSignatures(
|
||||
signedBundle: string[],
|
||||
inputAddress: string
|
||||
): boolean;
|
||||
|
||||
isBundle(
|
||||
bundle: TransactionObject[]
|
||||
): boolean;
|
||||
}
|
||||
|
||||
//
|
||||
// iota.multisig
|
||||
//
|
||||
|
||||
interface IotaMultisig {
|
||||
getKey(
|
||||
seed: string,
|
||||
index: number,
|
||||
security: Security
|
||||
): string;
|
||||
|
||||
getDigest(
|
||||
seed: string,
|
||||
index: number,
|
||||
security: Security
|
||||
): string;
|
||||
|
||||
address(
|
||||
digestTrytes: string | string[]
|
||||
): MultisigAddress;
|
||||
|
||||
validateAddress(
|
||||
multisigAddress: string,
|
||||
digests: string[]
|
||||
): boolean;
|
||||
|
||||
initiateTransfer(
|
||||
securitySum: number,
|
||||
inputAddress: string,
|
||||
remainderAddress: string,
|
||||
transfers: TransferObject[],
|
||||
callback?: (error: Error, bundle: TransactionObject[]) => void
|
||||
): void;
|
||||
|
||||
addSignature(
|
||||
bundleToSign: TransactionObject[],
|
||||
inputAddress: string,
|
||||
key: string,
|
||||
callback?: (error: Error, bundle: TransactionObject[]) => void
|
||||
): void;
|
||||
}
|
||||
|
||||
interface MultisigAddress {
|
||||
absorb(
|
||||
digest: string | string[]
|
||||
): MultisigAddress;
|
||||
|
||||
finalize(): string;
|
||||
}
|
||||
|
||||
//
|
||||
// iota.valid
|
||||
//
|
||||
|
||||
interface IotaValid {
|
||||
isAddress(address: string): boolean;
|
||||
|
||||
isTrytes(trytes: string, length?: number): boolean;
|
||||
|
||||
isValue(value: any): boolean;
|
||||
|
||||
isNum(value: any): boolean;
|
||||
|
||||
isHash(hash: any): boolean;
|
||||
|
||||
isTransfersArray(transfers: any): boolean;
|
||||
|
||||
isArrayOfHashes(hashes: any): boolean;
|
||||
|
||||
isArrayOfTrytes(trytes: any): boolean;
|
||||
|
||||
isArrayOfAttachedTrytes(trytes: any): boolean;
|
||||
|
||||
isArrayOfTxObjects(transactions: any): boolean;
|
||||
|
||||
isInputs(inputs: any): boolean;
|
||||
|
||||
isString(string: any): boolean;
|
||||
|
||||
isArray(array: any): boolean;
|
||||
|
||||
isObject(object: any): boolean;
|
||||
|
||||
isUri(uri: any): boolean;
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
import IOTA = require("iota.lib.js");
|
||||
|
||||
const config = {
|
||||
node: "https://localhost:14265",
|
||||
address: "999999999999999999999999999999999999999999999999999999999999999999999999999999999",
|
||||
transaction: "999999999999999999999999999999999999999999999999999999999999999999999999999999999"
|
||||
};
|
||||
|
||||
const iota = new IOTA({
|
||||
provider: config.node
|
||||
});
|
||||
|
||||
//
|
||||
// iota.api
|
||||
//
|
||||
|
||||
iota.api.getNodeInfo((error, info) => {
|
||||
});
|
||||
|
||||
iota.api.getNeighbors((error, info) => {
|
||||
});
|
||||
|
||||
iota.api.addNeighbors(["udp://127.0.0.2:14600"], (error, count) => {
|
||||
});
|
||||
|
||||
iota.api.removeNeighbors(["udp://127.0.0.2:14600"], (error, count) => {
|
||||
});
|
||||
|
||||
iota.api.findTransactions({
|
||||
addresses: [config.address]
|
||||
}, (error, hashes) => {
|
||||
});
|
||||
|
||||
iota.api.getTrytes([config.address], (error, trytes) => {
|
||||
});
|
||||
|
||||
iota.api.getInclusionStates([config.address], [config.transaction], (error, states) => {
|
||||
});
|
||||
|
||||
iota.api.getBalances([config.address], 1, (error, states) => {
|
||||
});
|
||||
|
||||
iota.api.getTransactionsToApprove(1, (error, transactions) => {
|
||||
});
|
||||
|
||||
iota.api.getTransactionsObjects([config.transaction], (err, response) => {
|
||||
});
|
||||
|
||||
iota.api.findTransactionObjects({
|
||||
addresses: [config.address]
|
||||
}, (err, response) => {
|
||||
});
|
||||
|
||||
iota.api.getLatestInclusion([config.address], (err, response) => {
|
||||
});
|
||||
|
||||
//
|
||||
// iota.utils
|
||||
//
|
||||
|
||||
iota.utils.convertUnits(1000, "i", "Mi");
|
||||
|
||||
const checksum = iota.utils.addChecksum(config.address);
|
||||
iota.utils.noChecksum(checksum);
|
||||
iota.utils.isValidChecksum(checksum);
|
||||
|
||||
const transactionObj = iota.utils.transactionObject(new Array(2674).join("9"));
|
||||
iota.utils.transactionTrytes(transactionObj);
|
||||
|
||||
const trytes = iota.utils.toTrytes("HELLO TANGLE");
|
||||
iota.utils.fromTrytes(trytes);
|
||||
|
||||
//
|
||||
// iota.valid
|
||||
//
|
||||
|
||||
iota.valid.isAddress(config.address);
|
||||
|
||||
iota.valid.isTrytes(trytes);
|
||||
|
||||
iota.valid.isValue(0);
|
||||
|
||||
iota.valid.isNum(0);
|
||||
|
||||
iota.valid.isHash(config.address);
|
||||
|
||||
const transferObj = {
|
||||
address: config.address,
|
||||
message: "",
|
||||
value: 0,
|
||||
tag: ""
|
||||
};
|
||||
|
||||
iota.valid.isTransfersArray([transferObj]);
|
||||
@@ -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",
|
||||
"iota.lib.js-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Vendored
+58
@@ -0,0 +1,58 @@
|
||||
// Type definitions for json-query 2.2
|
||||
// Project: http://github.com/mmckegg/json-query#readme
|
||||
// Definitions by: Matt Traynham <https://github.com/mtraynham>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export = JsonQuery;
|
||||
|
||||
declare function JsonQuery(
|
||||
selector: JsonQuery.Selector | JsonQuery.SelectorWithQueryParams,
|
||||
options: JsonQuery.Options
|
||||
): JsonQuery.Result;
|
||||
|
||||
declare namespace JsonQuery {
|
||||
type Selector = string;
|
||||
|
||||
type QueryParam = any;
|
||||
// No way to support [Selector, ...QueryParam[]]?
|
||||
// 10 params should be more than enough, hopefully.
|
||||
type SelectorWithQueryParams =
|
||||
[Selector, QueryParam]
|
||||
| [Selector, QueryParam]
|
||||
| [Selector, QueryParam]
|
||||
| [Selector, QueryParam, QueryParam]
|
||||
| [Selector, QueryParam, QueryParam, QueryParam]
|
||||
| [Selector, QueryParam, QueryParam, QueryParam, QueryParam]
|
||||
| [Selector, QueryParam, QueryParam, QueryParam, QueryParam, QueryParam]
|
||||
| [Selector, QueryParam, QueryParam, QueryParam, QueryParam, QueryParam, QueryParam]
|
||||
| [Selector, QueryParam, QueryParam, QueryParam, QueryParam, QueryParam, QueryParam, QueryParam]
|
||||
| [Selector, QueryParam, QueryParam, QueryParam, QueryParam, QueryParam, QueryParam, QueryParam, QueryParam]
|
||||
| [Selector, QueryParam, QueryParam, QueryParam, QueryParam, QueryParam, QueryParam, QueryParam, QueryParam, QueryParam]
|
||||
| [Selector, QueryParam, QueryParam, QueryParam, QueryParam, QueryParam, QueryParam, QueryParam, QueryParam, QueryParam, QueryParam];
|
||||
|
||||
type Context = any;
|
||||
|
||||
type Filter = (input: Context, ...args: any[]) => Context;
|
||||
interface Locals {
|
||||
[filterName: string]: Filter;
|
||||
}
|
||||
|
||||
interface Options {
|
||||
data?: Context;
|
||||
rootContext?: Context;
|
||||
source?: Context;
|
||||
context?: Context;
|
||||
parent?: Context;
|
||||
locals?: Locals;
|
||||
globals?: boolean;
|
||||
force?: boolean;
|
||||
allowRegexp?: boolean;
|
||||
}
|
||||
|
||||
interface Result {
|
||||
value: any;
|
||||
key: string;
|
||||
references: any[];
|
||||
parents: string[];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
import jsonQuery = require('json-query');
|
||||
|
||||
// API
|
||||
let data: jsonQuery.Context = {
|
||||
people: [
|
||||
{name: 'Matt', country: 'NZ'},
|
||||
{name: 'Pete', country: 'AU'},
|
||||
{name: 'Mikey', country: 'NZ'}
|
||||
]
|
||||
};
|
||||
jsonQuery('people[country=NZ].name', {data}); // => {value: 'Matt', parents: [...], key: 0} ... etc
|
||||
|
||||
// Deep Queries
|
||||
data = {
|
||||
grouped_people: {
|
||||
friends: [
|
||||
{name: 'Steve', country: 'NZ'},
|
||||
{name: 'Jane', country: 'US'},
|
||||
{name: 'Mike', country: 'AU'},
|
||||
{name: 'Mary', country: 'NZ'}
|
||||
],
|
||||
enemies: [
|
||||
{name: 'Evil Steve', country: 'AU'},
|
||||
{name: 'Betty', country: 'NZ'}
|
||||
]
|
||||
}
|
||||
};
|
||||
const result: any = jsonQuery('grouped_people[**][*country=NZ]', {data}).value;
|
||||
|
||||
// Inner Queries
|
||||
data = {
|
||||
page: {
|
||||
id: 'page_1',
|
||||
title: 'Test'
|
||||
},
|
||||
comments_lookup: {
|
||||
page_1: [
|
||||
{id: 'comment_1', parent_id: 'page_1', content: "I am a comment"}
|
||||
]
|
||||
}
|
||||
};
|
||||
jsonQuery('comments_lookup[{page.id}]', {data});
|
||||
|
||||
// Local functions (helpers)
|
||||
const locals: jsonQuery.Locals = {
|
||||
greetingName: (input: jsonQuery.Context) => {
|
||||
if (input.known_as) {
|
||||
return input.known_as;
|
||||
} else {
|
||||
return input.name;
|
||||
}
|
||||
},
|
||||
and: (inputA: jsonQuery.Context, inputB: boolean) => {
|
||||
return inputA && inputB;
|
||||
},
|
||||
text: (input: jsonQuery.Context, text: string) => {
|
||||
return text;
|
||||
},
|
||||
then: (input: jsonQuery.Context, thenValue: string, elseValue: string) => {
|
||||
if (input) {
|
||||
return thenValue;
|
||||
} else {
|
||||
return elseValue;
|
||||
}
|
||||
}
|
||||
};
|
||||
data = {
|
||||
is_fullscreen: true,
|
||||
is_playing: false,
|
||||
user: {
|
||||
name: "Matthew McKegg",
|
||||
known_as: "Matt"
|
||||
}
|
||||
};
|
||||
jsonQuery('user:greetingName', {data, locals}).value; // => "Matt"
|
||||
jsonQuery(['is_fullscreen:and({is_playing}):then(?, ?)', "Playing big!", "Not so much"], {data, locals}).value; // => "Not so much"
|
||||
jsonQuery(':text(This displays text cos we made it so)', {locals}).value; // => "This displays text cos we made it so"
|
||||
jsonQuery('people:select(name, country)', {
|
||||
data,
|
||||
locals: {
|
||||
select: (input: jsonQuery.Context, ...keys: string[]) => {
|
||||
if (Array.isArray(input)) {
|
||||
return input.map((item: any) => {
|
||||
return Object.keys(item).reduce((result: {[p: string]: any}, key: string) => {
|
||||
if (~keys.indexOf(key)) {
|
||||
result[key] = item[key];
|
||||
}
|
||||
return result;
|
||||
}, {});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
jsonQuery('people[*:recentlyUpdated]', {
|
||||
data,
|
||||
locals: {
|
||||
recentlyUpdated: (item: {updatedAt: number}) => {
|
||||
return item.updatedAt < Date.now() - (30 * 24 * 60 * 60 * 1000);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Context
|
||||
data = {
|
||||
styles: {
|
||||
bold: 'font-weight:strong',
|
||||
red: 'color: red'
|
||||
},
|
||||
paragraphs: [
|
||||
{content: "I am a red paragraph", style: 'red'},
|
||||
{content: "I am a bold paragraph", style: 'bold'},
|
||||
],
|
||||
};
|
||||
let pageHtml = '';
|
||||
data.paragraphs.forEach((paragraph: {content: string, style: string}) => {
|
||||
const style = jsonQuery('styles[{.style}]', {data, source: paragraph}).value;
|
||||
const content = jsonQuery('.content', {data, source: paragraph}).value; // pretty pointless :)
|
||||
pageHtml += `<p style='${style}'>${content}</p>`;
|
||||
});
|
||||
|
||||
// Query Params
|
||||
jsonQuery(['people[country=?]', 'NZ'], {data});
|
||||
@@ -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",
|
||||
"json-query-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Vendored
+4
@@ -71,6 +71,10 @@ export interface Change {
|
||||
};
|
||||
}
|
||||
|
||||
export var Change: {
|
||||
new(change: Change): Change;
|
||||
}
|
||||
|
||||
export interface SearchCallBack {
|
||||
(error: Error, result: EventEmitter): void;
|
||||
}
|
||||
|
||||
@@ -18,3 +18,14 @@ let opts: ldap.SearchOptions = {
|
||||
client.search('o=example', opts, (err: Error, res: NodeJS.EventEmitter): void => {
|
||||
// nothing
|
||||
});
|
||||
|
||||
let change = new ldap.Change({
|
||||
operation: 'add',
|
||||
modification: {
|
||||
pets: ['cat', 'dog']
|
||||
}
|
||||
});
|
||||
|
||||
client.modify('cn=foo, o=example', change, function(err) {
|
||||
// nothing
|
||||
});
|
||||
|
||||
@@ -20,4 +20,4 @@
|
||||
"index.d.ts",
|
||||
"ldapjs-tests.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
// Type definitions for lil-uuid 0.1
|
||||
// Project: https://github.com/lil-js/uuid
|
||||
// Definitions by: Pr1st0n <https://github.com/Pr1st0n>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/**
|
||||
* Generate a random UUID
|
||||
*
|
||||
* @returns UUID string.
|
||||
*/
|
||||
export function uuid(): string;
|
||||
|
||||
/**
|
||||
* Check if a given string has a valid UUID format. It supports multiple version (3, 4 and 5).
|
||||
*
|
||||
* @param uuid UUID string.
|
||||
* @returns True if string is valid UUID, false otherwise.
|
||||
*/
|
||||
export function isUUID(uuid: string): boolean;
|
||||
@@ -0,0 +1,4 @@
|
||||
import * as lil from 'lil-uuid';
|
||||
|
||||
lil.uuid();
|
||||
lil.isUUID('f47ac10b-58cc-4372-a567-0e02b2c3d479');
|
||||
@@ -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",
|
||||
"lil-uuid-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Vendored
+1
@@ -947,6 +947,7 @@ declare namespace __MaterialUI {
|
||||
export interface ChipProps {
|
||||
backgroundColor?: string;
|
||||
className?: string;
|
||||
containerElement?: React.ReactNode | string;
|
||||
labelColor?: string;
|
||||
labelStyle?: React.CSSProperties;
|
||||
onRequestDelete?: React.TouchEventHandler<Chip>;
|
||||
|
||||
@@ -3030,6 +3030,8 @@ const ChipExampleSimple = () => (
|
||||
<Chip labelColor={blue500}>Blue Label Color</Chip>
|
||||
<Chip><Avatar size={32} color={blue300} backgroundColor={indigo900}>UI</Avatar> Avatar</Chip>
|
||||
<Chip style={styles.chip}>Styled</Chip>
|
||||
<Chip containerElement="span">String Container</Chip>
|
||||
<Chip containerElement={() => {}}>ReactNode Container</Chip>
|
||||
</div>
|
||||
);
|
||||
|
||||
|
||||
Vendored
+79
@@ -0,0 +1,79 @@
|
||||
// Type definitions for mock-knex 0.3
|
||||
// Project: https://github.com/colonyamerican/mock-knex
|
||||
// Definitions by: Jesse Zhang <https://github.com/jessezhang91>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
import * as Knex from "knex";
|
||||
import { EventEmitter } from "events";
|
||||
|
||||
/**
|
||||
* Attaches mocked client to knex instance
|
||||
*
|
||||
* @param knex initialized knex client
|
||||
*/
|
||||
export function mock(knex: Knex): void;
|
||||
|
||||
/**
|
||||
* Detaches mocked client from knex instance
|
||||
*
|
||||
* @param knex initialized knex client
|
||||
*/
|
||||
export function unmock(knex: Knex): void;
|
||||
|
||||
/**
|
||||
* Returns query Tracker instance
|
||||
*/
|
||||
export function getTracker(): Tracker;
|
||||
|
||||
/**
|
||||
* The tracker enables you to catch and respond to queries that occur during testing, see Test for more examples.
|
||||
*/
|
||||
export interface Tracker extends EventEmitter {
|
||||
/**
|
||||
* Enables query tracking mock on mocked knex client
|
||||
*/
|
||||
install(): void;
|
||||
|
||||
/**
|
||||
* Disables query tracking mock on mocked knex client. Also resets 'step' counter.
|
||||
*/
|
||||
uninstall(): void;
|
||||
|
||||
/**
|
||||
* Add event listener for 'query' event. It gets esecuted for each query that should end up in database.
|
||||
* Instead of this callback gets executed and its up to you to assert queries and mock database responses.
|
||||
*
|
||||
* @param callback A function that gets executed on 'query' event.
|
||||
*/
|
||||
on(event: 'query', callback: (query: QueryDetails, step: number) => void): this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The object containing query details that is being sent to knex database dialect on query execution.
|
||||
* Object properties signature matches with knex toSQL() output with additional method returns(values).
|
||||
*/
|
||||
export interface QueryDetails extends Knex.Sql {
|
||||
/**
|
||||
* Function that needs to be called to mock database query result for knex.
|
||||
*
|
||||
* @param error The Error, string or instance of Error, which represents why the result was rejected
|
||||
*/
|
||||
reject(error: Error | string): void;
|
||||
|
||||
/**
|
||||
* Function that needs to be called to mock database query result for knex.
|
||||
*
|
||||
* @param values An array of mock data to be returned by database. For Bookshelf this is mostly array of objects. Knex could return any type of data.
|
||||
*/
|
||||
response(values: any[], options?: QueryDetailsResponseOption): void;
|
||||
}
|
||||
|
||||
export interface QueryDetailsResponseOption {
|
||||
/**
|
||||
* Is this a stream response, defaults to false
|
||||
*/
|
||||
stream: boolean;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import * as knex from "knex";
|
||||
import * as mockDb from "mock-knex";
|
||||
|
||||
const db = knex({
|
||||
client: 'sqlite'
|
||||
});
|
||||
|
||||
mockDb.mock(db);
|
||||
|
||||
const tracker = mockDb.getTracker();
|
||||
tracker.install();
|
||||
tracker.on('query', (query, step) => {
|
||||
if (query.method === "first" || step === 1) {
|
||||
query.response([{
|
||||
a: 1
|
||||
}, {
|
||||
a: 2
|
||||
}, {
|
||||
a: 3
|
||||
}], {
|
||||
stream: false
|
||||
});
|
||||
} else {
|
||||
query.reject(new Error("bad query"));
|
||||
}
|
||||
});
|
||||
tracker.uninstall();
|
||||
|
||||
mockDb.unmock(db);
|
||||
@@ -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",
|
||||
"mock-knex-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Vendored
+71
@@ -0,0 +1,71 @@
|
||||
// Type definitions for moment-holiday 1.5
|
||||
// Project: https://github.com/kodie/moment-holiday
|
||||
// Definitions by: Robert Winslow Dalpe <https://github.com/rwdalpe>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
import * as moment from 'moment';
|
||||
|
||||
declare module 'moment' {
|
||||
interface Moment extends Object {
|
||||
holiday(
|
||||
holidays?: string[] | string,
|
||||
adjust?: boolean): Moment | false | { [holidayName: string]: Moment };
|
||||
|
||||
holidays(
|
||||
holidays?: string[] | string,
|
||||
adjust?: boolean): Moment | false | { [holidayName: string]: Moment };
|
||||
|
||||
isHoliday(
|
||||
holidays?: string[] | string | null,
|
||||
adjust?: boolean): boolean | string | string[];
|
||||
|
||||
previousHoliday(count?: number, adjust?: boolean): Moment[] | Moment;
|
||||
|
||||
previousHolidays(count?: number, adjust?: boolean): Moment[] | Moment;
|
||||
|
||||
nextHoliday(count?: number, adjust?: boolean): Moment[] | Moment;
|
||||
|
||||
nextHolidays(count?: number, adjust?: boolean): Moment[] | Moment;
|
||||
|
||||
holidaysBetween(m: Moment, adjust?: boolean): Moment[] | false;
|
||||
}
|
||||
|
||||
interface HolidayDefinition {
|
||||
date: string;
|
||||
keywords?: string[];
|
||||
keywords_y?: string[];
|
||||
keywords_n?: string[];
|
||||
regions?: string[];
|
||||
regions_n?: string[];
|
||||
}
|
||||
|
||||
interface HolidaysMapping {
|
||||
[holidayName: string]: HolidayDefinition;
|
||||
}
|
||||
|
||||
interface Holidays {
|
||||
active: HolidaysMapping;
|
||||
active_last: HolidaysMapping;
|
||||
}
|
||||
|
||||
interface HolidayModifier {
|
||||
set(
|
||||
holidays: HolidaysMapping | string | string[],
|
||||
specifics?: any): HolidayModifier;
|
||||
|
||||
add(
|
||||
holidays: HolidaysMapping | string,
|
||||
specifics?: any): HolidayModifier;
|
||||
|
||||
remove(holidays: string | string[]): HolidayModifier;
|
||||
|
||||
undo(): HolidayModifier;
|
||||
|
||||
load(locales: string | string[]): HolidayModifier;
|
||||
|
||||
extendParser(parserFunc: (m: Moment, date: string) => Moment | Moment[] | false | void): HolidayModifier;
|
||||
}
|
||||
|
||||
let holidays: Holidays;
|
||||
let modifyHolidays: HolidayModifier;
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
import moment = require('moment');
|
||||
import 'moment-holiday';
|
||||
|
||||
let holidayResult: moment.Moment | false | { [holidayName: string]: moment.Moment };
|
||||
holidayResult = moment().holiday([]);
|
||||
holidayResult = moment().holiday([], false);
|
||||
holidayResult = moment().holiday([], true);
|
||||
holidayResult = moment().holiday('string');
|
||||
holidayResult = moment().holiday('string', false);
|
||||
holidayResult = moment().holiday('string', true);
|
||||
holidayResult = moment().holiday(['array', 'of', 'strings']);
|
||||
holidayResult = moment().holiday(['array', 'of', 'strings'], false);
|
||||
holidayResult = moment().holiday(['array', 'of', 'strings'], true);
|
||||
|
||||
holidayResult = moment().holidays([]);
|
||||
holidayResult = moment().holidays([], false);
|
||||
holidayResult = moment().holidays([], true);
|
||||
holidayResult = moment().holidays('string');
|
||||
holidayResult = moment().holidays('string', false);
|
||||
holidayResult = moment().holidays('string', true);
|
||||
holidayResult = moment().holidays(['array', 'of', 'strings']);
|
||||
holidayResult = moment().holidays(['array', 'of', 'strings'], false);
|
||||
holidayResult = moment().holidays(['array', 'of', 'strings'], true);
|
||||
|
||||
let isHolidayResult: boolean | string | string[];
|
||||
isHolidayResult = moment().isHoliday();
|
||||
isHolidayResult = moment().isHoliday([]);
|
||||
isHolidayResult = moment().isHoliday([], false);
|
||||
isHolidayResult = moment().isHoliday([], true);
|
||||
isHolidayResult = moment().isHoliday(['array', 'of', 'strings']);
|
||||
isHolidayResult = moment().isHoliday(['array', 'of', 'strings'], false);
|
||||
isHolidayResult = moment().isHoliday(['array', 'of', 'strings'], true);
|
||||
isHolidayResult = moment().isHoliday('string');
|
||||
isHolidayResult = moment().isHoliday('string', false);
|
||||
isHolidayResult = moment().isHoliday('string', true);
|
||||
isHolidayResult = moment().isHoliday(null);
|
||||
isHolidayResult = moment().isHoliday(null, false);
|
||||
isHolidayResult = moment().isHoliday(null, true);
|
||||
|
||||
let previousHolidayResult: moment.Moment[] | moment.Moment;
|
||||
previousHolidayResult = moment().previousHoliday();
|
||||
previousHolidayResult = moment().previousHoliday(1);
|
||||
previousHolidayResult = moment().previousHoliday(1, false);
|
||||
previousHolidayResult = moment().previousHoliday(1, true);
|
||||
previousHolidayResult = moment().previousHolidays();
|
||||
previousHolidayResult = moment().previousHolidays(1);
|
||||
previousHolidayResult = moment().previousHolidays(1, false);
|
||||
previousHolidayResult = moment().previousHolidays(1, true);
|
||||
|
||||
let nextHolidayResult: moment.Moment[] | moment.Moment;
|
||||
nextHolidayResult = moment().nextHoliday();
|
||||
nextHolidayResult = moment().nextHoliday(1);
|
||||
nextHolidayResult = moment().nextHoliday(1, false);
|
||||
nextHolidayResult = moment().nextHoliday(1, true);
|
||||
nextHolidayResult = moment().nextHolidays();
|
||||
nextHolidayResult = moment().nextHolidays(1);
|
||||
nextHolidayResult = moment().nextHolidays(1, false);
|
||||
nextHolidayResult = moment().nextHolidays(1, true);
|
||||
|
||||
let holidaysBetweenResult: moment.Moment[] | false;
|
||||
holidaysBetweenResult = moment().holidaysBetween(moment());
|
||||
holidaysBetweenResult = moment().holidaysBetween(moment(), false);
|
||||
holidaysBetweenResult = moment().holidaysBetween(moment(), true);
|
||||
|
||||
let holidayDefinition: moment.HolidayDefinition = {
|
||||
date: 'string'
|
||||
};
|
||||
holidayDefinition = {
|
||||
date: 'string',
|
||||
keywords: ['array'],
|
||||
};
|
||||
holidayDefinition = {
|
||||
date: 'string',
|
||||
keywords: ['array'],
|
||||
keywords_n: ['array'],
|
||||
};
|
||||
holidayDefinition = {
|
||||
date: 'string',
|
||||
keywords: ['array'],
|
||||
keywords_n: ['array'],
|
||||
keywords_y: ['array'],
|
||||
};
|
||||
holidayDefinition = {
|
||||
date: 'string',
|
||||
keywords: ['array'],
|
||||
keywords_n: ['array'],
|
||||
keywords_y: ['array'],
|
||||
regions: ['array'],
|
||||
};
|
||||
holidayDefinition = {
|
||||
date: 'string',
|
||||
keywords: ['array'],
|
||||
keywords_n: ['array'],
|
||||
keywords_y: ['array'],
|
||||
regions: ['array'],
|
||||
regions_n: ['array']
|
||||
};
|
||||
|
||||
const holidays: moment.Holidays = moment.holidays;
|
||||
let activeHolidays: moment.HolidaysMapping = moment.holidays.active;
|
||||
activeHolidays = {
|
||||
'Some holiday name': holidayDefinition
|
||||
};
|
||||
|
||||
let lastActiveHolidays: moment.HolidaysMapping = moment.holidays.active_last;
|
||||
lastActiveHolidays = {
|
||||
'Some holiday name': holidayDefinition
|
||||
};
|
||||
|
||||
let holidayModifier: moment.HolidayModifier = moment.modifyHolidays;
|
||||
holidayModifier = holidayModifier.set('string');
|
||||
holidayModifier = holidayModifier.set(['array']);
|
||||
holidayModifier = holidayModifier.set(activeHolidays);
|
||||
holidayModifier = holidayModifier.set('string', {});
|
||||
holidayModifier = holidayModifier.set(['array'], {});
|
||||
holidayModifier = holidayModifier.set(activeHolidays, {});
|
||||
holidayModifier = holidayModifier.add(activeHolidays);
|
||||
holidayModifier = holidayModifier.add('string');
|
||||
holidayModifier = holidayModifier.add(activeHolidays, {});
|
||||
holidayModifier = holidayModifier.add('string', {});
|
||||
holidayModifier = holidayModifier.remove('string');
|
||||
holidayModifier = holidayModifier.remove(['array']);
|
||||
holidayModifier = holidayModifier.undo();
|
||||
holidayModifier = holidayModifier.load('string');
|
||||
holidayModifier = holidayModifier.load(['string']);
|
||||
holidayModifier = holidayModifier.extendParser((m: moment.Moment, d: string): moment.Moment | moment.Moment[] | false | void => {
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"moment": ">=2.0.0"
|
||||
}
|
||||
}
|
||||
@@ -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",
|
||||
"moment-holiday-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Vendored
+1
-1
@@ -42,7 +42,7 @@ export class Server {
|
||||
finish: (status: number, headers: Headers, req: http.ServerRequest, res: http.ServerResponse, promise: events.EventEmitter, callback: Callback) => void;
|
||||
servePath: (pathname: string, status: number, headers: Headers, req: http.ServerRequest, res: http.ServerResponse, finish: Finish) => events.EventEmitter;
|
||||
resolve: (pathname: string) => string;
|
||||
serve: (req: http.ServerRequest, res: http.ServerResponse, callback: Callback) => events.EventEmitter;
|
||||
serve: (req: http.ServerRequest, res: http.ServerResponse, callback?: Callback) => events.EventEmitter;
|
||||
gzipOk: (req: http.ServerRequest, contentType: string) => boolean;
|
||||
respondGzip: (pathname: string, status: number, contentType: string, _headers: Headers, files: string[], stat: fs.Stats, req: http.ServerRequest, res: http.ServerResponse, finish: Finish) => void;
|
||||
parseByteRange: (req: http.ServerRequest, stat: fs.Stats) => ByteRange;
|
||||
|
||||
Vendored
+9
@@ -690,6 +690,11 @@ declare module "inspector" {
|
||||
* Stack trace captured when the call was made.
|
||||
*/
|
||||
stackTrace?: Runtime.StackTrace;
|
||||
/**
|
||||
* Console context descriptor for calls on non-default console context (not console.*): 'anonymous#unique-logger-id' for call on unnamed context, 'name#unique-logger-id' for call on named context.
|
||||
* @experimental
|
||||
*/
|
||||
context?: string;
|
||||
}
|
||||
|
||||
export interface InspectRequestedEventDataType {
|
||||
@@ -1434,6 +1439,10 @@ declare module "inspector" {
|
||||
* Source ranges inside the function with coverage data.
|
||||
*/
|
||||
ranges: Profiler.CoverageRange[];
|
||||
/**
|
||||
* Whether coverage data for this function has block granularity.
|
||||
*/
|
||||
isBlockCoverage: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Vendored
+1
@@ -8,4 +8,5 @@ export class BlameOptions {
|
||||
oldestCommit?: Oid;
|
||||
minLine?: number;
|
||||
maxLine?: number;
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
Vendored
+1
@@ -23,4 +23,5 @@ export class CheckoutOptions {
|
||||
theirLabel?: string;
|
||||
perfdataCb?: any;
|
||||
perfdataPayload?: undefined;
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
Vendored
+4
-4
@@ -85,25 +85,25 @@ export class Commit {
|
||||
*
|
||||
*
|
||||
*/
|
||||
getParents(limit: number, callback: Function): Promise<Commit[]>;
|
||||
getParents(limit: number, callback?: Function): Promise<Commit[]>;
|
||||
/**
|
||||
* Retrieve the commit's parent shas.
|
||||
*
|
||||
*
|
||||
*/
|
||||
parents(callback: Function): Oid[];
|
||||
parents(): Oid[];
|
||||
/**
|
||||
* Generate an array of diff trees showing changes between this commit and its parent(s).
|
||||
*
|
||||
*
|
||||
*/
|
||||
getDiff(callback: Function): Promise<Diff[]>;
|
||||
getDiff(callback?: Function): Promise<Diff[]>;
|
||||
/**
|
||||
* Generate an array of diff trees showing changes between this commit and its parent(s).
|
||||
*
|
||||
*
|
||||
*/
|
||||
getDiffWithOptions(options: Object, callback: Function): Promise<Diff[]>;
|
||||
getDiffWithOptions(options: Object, callback?: Function): Promise<Diff[]>;
|
||||
/**
|
||||
* The sha of this commit
|
||||
*
|
||||
|
||||
Vendored
+37
@@ -0,0 +1,37 @@
|
||||
import { DiffLine } from './diff-line';
|
||||
|
||||
export class ConvenientHunk {
|
||||
/**
|
||||
* Diff header string that represents the context of this hunk
|
||||
* of the diff. Something like `@@ -169,14 +167,12 @@ ...`
|
||||
*/
|
||||
header(): string;
|
||||
/**
|
||||
* The length of the header
|
||||
*/
|
||||
headerLen(): number;
|
||||
/**
|
||||
* The lines in this hunk
|
||||
*/
|
||||
lines(): Promise<DiffLine[]>;
|
||||
/**
|
||||
* The number of new lines in the hunk
|
||||
*/
|
||||
newLines(): number;
|
||||
/**
|
||||
* The starting offset of the first new line in the file
|
||||
*/
|
||||
newStart(): number;
|
||||
/**
|
||||
* The number of old lines in the hunk
|
||||
*/
|
||||
oldLines(): number;
|
||||
/**
|
||||
* The starting offset of the first old line in the file
|
||||
*/
|
||||
oldStart(): number;
|
||||
/**
|
||||
* Number of lines in this hunk
|
||||
*/
|
||||
size(): number;
|
||||
}
|
||||
Vendored
+2
-1
@@ -1,3 +1,4 @@
|
||||
import { ConvenientHunk } from './convenient-hunk';
|
||||
import { DiffFile } from './diff-file';
|
||||
|
||||
export class ConvenientPatch {
|
||||
@@ -16,7 +17,7 @@ export class ConvenientPatch {
|
||||
/**
|
||||
* The hunks in this patch
|
||||
*/
|
||||
hunks(): Promise<any[]>;
|
||||
hunks(): Promise<ConvenientHunk[]>;
|
||||
/**
|
||||
* The status of this patch (unmodified, added, deleted)
|
||||
*/
|
||||
|
||||
+1
@@ -3,4 +3,5 @@ export class DescribeFormatOptions {
|
||||
abbreviatedSize?: number;
|
||||
alwaysUseLongFormat?: number;
|
||||
dirtySuffix?: string;
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
Vendored
+1
@@ -5,4 +5,5 @@ export class DescribeOptions {
|
||||
pattern?: string;
|
||||
onlyFollowFirstParent?: number;
|
||||
showCommitOidAsFallback?: number;
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
Vendored
-8
@@ -1,8 +0,0 @@
|
||||
export class DiffHunk {
|
||||
oldStart: number;
|
||||
oldLines: number;
|
||||
newStart: number;
|
||||
newLines: number;
|
||||
headerLen: number;
|
||||
header: string;
|
||||
}
|
||||
Vendored
+1
@@ -14,4 +14,5 @@ export interface DiffOptions {
|
||||
newPrefix?: string;
|
||||
payload?: any;
|
||||
progressCb?: any;
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
Vendored
+8
-7
@@ -7,6 +7,7 @@ import { DiffDelta } from './diff-delta';
|
||||
import { DiffPerfdata } from './diff-perf-data';
|
||||
import { DiffOptions } from './diff-options';
|
||||
import { Buf } from './buf';
|
||||
import { ConvenientPatch } from './convenient-patch';
|
||||
|
||||
export interface DiffFindOptions {
|
||||
version?: number;
|
||||
@@ -134,12 +135,12 @@ export class Diff {
|
||||
static blobToBuffer(oldBlob: Blob, oldAsPath: string,
|
||||
buffer: string, bufferAsPath: string, opts: DiffOptions, fileCb: Function, binaryCb: Function, hunkCb: Function, lineCb: Function): Promise<any>;
|
||||
static fromBuffer(content: string, contentLen: number): Promise<Diff>;
|
||||
static indexToWorkdir(repo: Repository, index: Index, opts: DiffOptions): Promise<Diff>;
|
||||
static indexToIndex(repo: Repository, oldIndex: Index, newIndex: Index, opts: DiffOptions): Promise<Diff>;
|
||||
static treeToIndex(repo: Repository, oldTree: Tree, index: Index, opts: DiffOptions): Promise<Diff>;
|
||||
static treeToTree(repo: Repository, oldTree: Tree, new_tree: Tree, opts: DiffOptions): Promise<Diff>;
|
||||
static treeToWorkdir(repo: Repository, oldTree: Tree, opts: DiffOptions): Promise<Diff>;
|
||||
static treeToWorkdirWithIndex(repo: Repository, oldTree: Tree, opts: DiffOptions): Promise<Diff>;
|
||||
static indexToWorkdir(repo: Repository, index: Index, opts?: DiffOptions): Promise<Diff>;
|
||||
static indexToIndex(repo: Repository, oldIndex: Index, newIndex: Index, opts?: DiffOptions): Promise<Diff>;
|
||||
static treeToIndex(repo: Repository, oldTree: Tree, index: Index, opts?: DiffOptions): Promise<Diff>;
|
||||
static treeToTree(repo: Repository, oldTree: Tree, new_tree: Tree, opts?: DiffOptions): Promise<Diff>;
|
||||
static treeToWorkdir(repo: Repository, oldTree: Tree, opts?: DiffOptions): Promise<Diff>;
|
||||
static treeToWorkdirWithIndex(repo: Repository, oldTree: Tree, opts?: DiffOptions): Promise<Diff>;
|
||||
|
||||
findSimilar(options: DiffFindOptions): Promise<number>;
|
||||
getDelta(idx: number): DiffDelta;
|
||||
@@ -150,7 +151,7 @@ export class Diff {
|
||||
*
|
||||
*
|
||||
*/
|
||||
patches(): Promise<any[]>;
|
||||
patches(): Promise<ConvenientPatch[]>;
|
||||
merge(from: Diff): Promise<number>;
|
||||
toBuf(format: Diff.FORMAT): Promise<Buf>;
|
||||
}
|
||||
|
||||
Vendored
+1
@@ -9,4 +9,5 @@ export interface FetchOptions {
|
||||
downloadTags?: number;
|
||||
customHeaders?: Strarray;
|
||||
proxyOpts?: any;
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
Vendored
+3
-1
@@ -22,6 +22,7 @@ export { CloneOptions } from './clone-options';
|
||||
export { Clone } from './clone';
|
||||
export { Commit } from './commit';
|
||||
export { Config } from './config';
|
||||
export { ConvenientHunk } from './convenient-hunk';
|
||||
export { ConvenientPatch } from './convenient-patch';
|
||||
export { CredUserpassPayload } from './cred-user-pass-payload';
|
||||
export { CredUsername } from './cred-username';
|
||||
@@ -33,7 +34,6 @@ export { DiffBinaryFile } from './diff-binary-file';
|
||||
export { DiffBinary } from './diff-binary';
|
||||
export { DiffDelta } from './diff-delta';
|
||||
export { DiffFile } from './diff-file';
|
||||
export { DiffHunk } from './diff-hunk';
|
||||
export { DiffLine } from './diff-line';
|
||||
export { DiffOptions } from './diff-options';
|
||||
export { DiffPerfdata } from './diff-perf-data';
|
||||
@@ -87,6 +87,8 @@ export { Revert } from './revert';
|
||||
export { Signature } from './signature';
|
||||
export { Stash } from './stash';
|
||||
export { StatusEntry } from './status-entry';
|
||||
export { StatusFileOptions } from './status-file-options';
|
||||
export { StatusFile } from './status-file';
|
||||
export { StatusList } from './status-list';
|
||||
export { StatusOptions } from './status-options';
|
||||
export { Status } from './status';
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user