Merge remote-tracking branch 'DefinitelyTyped/master'

This commit is contained in:
Samer Albahra
2017-10-03 11:02:56 -05:00
217 changed files with 25790 additions and 9361 deletions
+2 -3
View File
@@ -12,9 +12,8 @@ declare class sequence<T = any> {
private typekey: sequence<T>;
}
declare class SafeArray<T = any> {
private typekey: SafeArray<T>;
}
// tslint:disable-next-line no-empty-interface
interface SafeArray<T = any> {}
declare namespace com.sun.star {
namespace accessibility {
+1 -1
View File
@@ -90,7 +90,7 @@ export interface ConnectionOptions {
url?: string;
port?: number;
login?: string;
passowrd?: string;
password?: string;
connectionTimeout?: number;
authMechanism?: string;
vhost?: string;
@@ -0,0 +1,30 @@
import {
downloadSchema,
generate,
introspectSchema,
printSchema
} from "apollo-codegen";
async function main() {
await downloadSchema(
"http://example.com/graphql",
"schema.json",
{},
false,
"POST"
);
generate(["input.ts"], "schema.json", "types.ts", "typescript", "gql", {
passthroughCustomScalars: false,
customScalarsPrefix: "S",
addTypename: false,
namespace: "",
operationIdsPath: null,
generateOperationIds: false,
mergeInFieldsFromFragmentSpreads: false
});
await introspectSchema("schema.json", "schema.gql");
await printSchema("schema.in", "schema.out");
}
+40
View File
@@ -0,0 +1,40 @@
// Type definitions for apollo-codegen 0.16
// Project: https://github.com/apollographql/apollo-codegen
// Definitions by: Bradley Ayers <https://github.com/bradleyayers>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
export function downloadSchema(
url: string,
outputPath: string,
additionalHeaders: { [name: string]: string },
insecure: boolean,
method: string
): Promise<void>;
export function introspectSchema(
schemaPath: string,
outputPath: string
): Promise<void>;
export function printSchema(
schemaPath: string,
outputPath: string
): Promise<void>;
export function generate(
inputPaths: string[],
schemaPath: string,
outputPath: string,
target: "json" | "swift" | "ts" | "typescript" | "flow" | "scala",
tagName: string,
options: {
passthroughCustomScalars: boolean;
customScalarsPrefix: string;
addTypename: boolean;
namespace: string;
operationIdsPath: string | null;
generateOperationIds: boolean;
mergeInFieldsFromFragmentSpreads: boolean;
}
): void;
+22
View File
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"apollo-codegen-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+6964 -6220
View File
File diff suppressed because it is too large Load Diff
+96 -36
View File
@@ -1,4 +1,4 @@
// Type definitions for ArcGIS API for JavaScript 3.21
// Type definitions for ArcGIS API for JavaScript 3.22
// Project: https://developers.arcgis.com/javascript/3/
// Definitions by: Esri <https://github.com/Esri>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@@ -284,6 +284,8 @@ declare module "esri" {
columnDelimiter?: string;
/** Copyright information for the layer. */
copyright?: string;
/** Enables feature reduction (for example clustering) on point layers. */
featureReduction?: any;
/** The fields property contains objects with "name", "alias" and "type" String properties. */
fields?: any[];
/** The latitude field name. */
@@ -608,13 +610,13 @@ declare module "esri" {
locationProvider: LocationProviderBase;
}
export interface DataBrowserOptions {
/** Whether or not to display the hierarchy dropdown for countries with multiple hierarchies (e.g. */
/** Whether or not to display the hierarchy dropdown for countries with multiple hierarchies (for example USA has both Census and Landscape, Germany has both Census and Nexiga). */
allowHierarchies?: boolean;
/** Show/hide country drop down. */
countryBox?: boolean;
/** Two-digit country code selected in the country drop down. */
countryID?: string;
/** The hierarchy to load for a country (e.g. */
/** The hierarchy to load for a country (for example 'Census' or 'Landscape' for USA). */
hierarchyID?: string;
/** Text string to display on the back button on the second and third pages of the Data Browser. */
pageBackButton?: string;
@@ -896,6 +898,8 @@ declare module "esri" {
displayOnPan?: boolean;
/** Set a callback function that will be invoked by FeatureLayer.getEditSummary. */
editSummaryCallback?: Function;
/** Enables feature reduction (for example clustering) on point layers. */
featureReduction?: any;
/** Specify the geodatabase version to display. */
gdbVersion?: string;
/** Unique ID to assign to the layer. */
@@ -1172,7 +1176,7 @@ declare module "esri" {
remove(): void;
}
export interface HeatmapRendererOptions {
/** The radius (in pixels) of the circle over which the majority of each points value is spread out over. */
/** The radius (in pixels) of the circle over which the majority of each point's value is spread out. */
blurRadius?: number;
/** An array of CSS color strings (#RGB, #RRGGBB, rgb(r,g,b), rgba(r,g,b,a)). */
colors: string[];
@@ -1718,7 +1722,7 @@ declare module "esri" {
pixels: number[][];
/** Pixel type. */
pixelType?: string;
/** Array of objects containing numeric statistical properties (e.g. */
/** Array of objects containing numeric statistical properties (for example minValue, maxValue, noDataValue, etc.). */
statistics?: any[];
/** Number of columns. */
width: number;
@@ -1856,7 +1860,7 @@ declare module "esri" {
primaryHandle?: number;
/** Toggle for showing the black handle bars. */
showHandles?: boolean;
/** Flexible toggle for showing labels (e.g. */
/** Flexible toggle for showing labels (for example ["data", "handle"]). */
showLabels?: boolean | string[];
/** Toggle for showing the horizontal line indicators from the center of the handle. */
showTicks?: boolean;
@@ -2153,7 +2157,7 @@ declare module "esri" {
}
export interface TemplatePickerOptions {
/** Number of visible columns. */
columns?: number;
columns?: number | string;
/** Defines the text to be displayed when the template picker does not have any templates to display. */
emptyMessage?: string;
/** Array of input feature layers. */
@@ -2165,7 +2169,7 @@ declare module "esri" {
/** Length of label description. */
maxLabelLength?: number;
/** Number of visible rows. */
rows?: number;
rows?: number | string;
/** Tooltip content contains the template name and description. */
showTooltip?: boolean;
/** HTML style attributes for the widget. */
@@ -3488,7 +3492,7 @@ declare module "esri/dijit/BasemapGallery" {
basemaps: Basemap[];
/** This value is true after the BasemapGallery retrieves the ArcGIS.com basemaps. */
loaded: boolean;
/** Optional parameter to pass in a portal URL, including the instance name, used to access the group containing the basemap gallery items. */
/** Optional parameter to pass in a portal URL, including the instance name, used to access the group containing the basemap gallery items, for example www.myportal.com/myInstance or http://www.myportal.com/myInstance. */
portalUrl: string;
/**
* Creates a new BasemapGallery dijit.
@@ -4567,8 +4571,8 @@ declare module "esri/dijit/InfoWindow" {
/** Determines whether the InfoWindow is currently shown on the map. */
isShowing: boolean;
/**
* Create a new Info Window.
* @param params Optional parameters.
* Create a new InfoWindow.
* @param params Specify optional parameters used to create the InfoWindow.
* @param srcNodeRef Reference or id of the HTML element where the widget should be rendered.
*/
constructor(params: any, srcNodeRef: Node | string);
@@ -4633,6 +4637,12 @@ declare module "esri/dijit/InfoWindowLite" {
fixedAnchor: string;
/** Determines whether the InfoWindowLite is currently shown on the map. */
isShowing: boolean;
/**
* Create a new InfoWindowLite.
* @param params Specify optional parameters used to create the InfoWindowLite.
* @param srcNodeRef Reference or id of the HTML element where the widget should be rendered.
*/
constructor(params: any, srcNodeRef: Node | string);
/** Hides the InfoWindow. */
hide(): void;
/**
@@ -5117,8 +5127,8 @@ declare module "esri/dijit/OverviewMap" {
declare module "esri/dijit/Popup" {
import esri = require("esri");
import InfoWindowBase = require("esri/InfoWindowBase");
import Graphic = require("esri/graphic");
import FillSymbol = require("esri/symbols/FillSymbol");
import Graphic = require("esri/graphic");
import LineSymbol = require("esri/symbols/LineSymbol");
import Point = require("esri/geometry/Point");
import MarkerSymbol = require("esri/symbols/MarkerSymbol");
@@ -5127,6 +5137,8 @@ declare module "esri/dijit/Popup" {
class Popup extends InfoWindowBase {
/** Controls the placement of the popup window with respect to the geographic location. */
anchor: string;
/** Visualizes the extent of the points summarized by the cluster graphic when the user selects the "Browse Features" action in the cluster popup. */
clusterFillSymbol: FillSymbol;
/** The number of features associated with the info window. */
count: number;
/** An array of pending deferreds, null if there are not any pending deferreds. */
@@ -5179,16 +5191,28 @@ declare module "esri/dijit/Popup" {
* @param srcNodeRef Reference or id of the HTML element where the widget should be rendered.
*/
constructor(options: esri.PopupOptions, srcNodeRef: Node | string);
/**
* Creates links for the specified actions at the bottom of the popup window.
* @param actions An array of action objects that define the behavior for actions included in the popup.
*/
addActions(actions: any[]): any[];
/** Removes all features and destroys any pending deferreds. */
clearFeatures(): void;
/** Destroy the popup. */
destroy(): void;
/** Returns the current placement of the popup window. */
getCurrentAnchor(): string;
/** Get the currently selected feature. */
getSelectedFeature(): Graphic;
/** Hide the info window. */
hide(): void;
/** Maximize the info window. */
maximize(): void;
/**
* Removes the specified actions from the popup window.
* @param actionInfos An array of objects that describe actions created with addActions().
*/
removeActions(actionInfos: any[]): void;
/** Re-calculates the popup's position with respect to the map location it is pointing to. */
reposition(): void;
/**
@@ -5222,8 +5246,9 @@ declare module "esri/dijit/Popup" {
/**
* Associate an array of features or an array of deferreds that return features with the info window.
* @param features An array of features or deferreds.
* @param options Additional options for setting features in the popup.
*/
setFeatures(features: Graphic[] | any[]): void;
setFeatures(features: Graphic[] | any[], options?: any): void;
/**
* Sets the info window title.
* @param title The text for the title.
@@ -5332,8 +5357,6 @@ declare module "esri/dijit/PopupTemplate" {
/** The PopupTemplate class extends esri/InfoTemplate and provides support for defining a layout. */
class PopupTemplate extends InfoTemplate {
/** An array of objects that reference Arcade expressions. */
expressionInfos: any[];
/** The popup definition defined as a JavaScript object. */
info: any;
/**
@@ -5399,7 +5422,7 @@ declare module "esri/dijit/RendererSlider" {
precision: number;
/** Toggle for showing the black handle bars. */
showHandles: boolean;
/** Flexible toggle for showing labels e.g. */
/** Flexible toggle for showing labels, for example ["data","handle"]. */
showLabels: boolean | string[];
/** Toggle for showing the horizontal line indicators from the center of the handle. */
showTicks: boolean;
@@ -7991,10 +8014,10 @@ declare module "esri/geometry/geometryEngine" {
clip(geometry: Geometry, envelope: Extent): Geometry;
/**
* Indicates if one geometry contains another geometry.
* @param geometry1 The geometry that is tested for the contains relationship to the other geometry.
* @param geometry2 The geometry that is tested for within relationship to the other geometry.
* @param containerGeometry The geometry that is tested for the "contains" relationship to the other geometry.
* @param insideGeometry The geometry that is tested for the "within" relationship to the containerGeometry.
*/
contains(geometry1: Geometry, geometry2: Geometry): boolean;
contains(containerGeometry: Geometry, insideGeometry: Geometry): boolean;
/**
* Calculates the convex hull of the input geometry.
* @param geometry The input geometry.
@@ -8200,10 +8223,10 @@ declare module "esri/geometry/geometryEngine" {
union(geometries: Geometry[]): Geometry;
/**
* Indicates if one geometry is within another geometry.
* @param geometry1 The base geometry that is tested for within relationship to the other geometry.
* @param geometry2 The comparison geometry that is tested for the contains relationship to the other geometry.
* @param innerGeometry The base geometry that is tested for within relationship to the other geometry.
* @param outerGeometry The comparison geometry that is tested for the contains relationship to the other geometry.
*/
within(geometry1: Geometry, geometry2: Geometry): boolean;
within(innerGeometry: Geometry, outerGeometry: Geometry): boolean;
};
export = geometryEngine;
}
@@ -8234,10 +8257,10 @@ declare module "esri/geometry/geometryEngineAsync" {
clip(geometry: Geometry, envelope: Extent): any;
/**
* Indicates if one geometry contains another geometry.
* @param geometry1 The geometry that is tested for the contains relationship to the other geometry.
* @param geometry2 The geometry that is tested for within relationship to the other geometry.
* @param containerGeometry The geometry that is tested for the "contains" relationship to the other geometry.
* @param insideGeometry The geometry that is tested for the "within" relationship to the containerGeometry.
*/
contains(geometry1: Geometry, geometry2: Geometry): any;
contains(containerGeometry: Geometry, insideGeometry: Geometry): any;
/**
* Calculates the convex hull of the input geometry.
* @param geometry The input geometry.
@@ -8443,10 +8466,10 @@ declare module "esri/geometry/geometryEngineAsync" {
union(geometries: Geometry[]): any;
/**
* Indicates if one geometry is within another geometry.
* @param geometry1 The base geometry that is tested for within relationship to the other geometry.
* @param geometry2 The comparison geometry that is tested for the contains relationship to the other geometry.
* @param innerGeometry The base geometry that is tested for within relationship to the other geometry.
* @param outerGeometry The comparison geometry that is tested for the contains relationship to the other geometry.
*/
within(geometry1: Geometry, geometry2: Geometry): any;
within(innerGeometry: Geometry, outerGeometry: Geometry): any;
};
export = geometryEngineAsync;
}
@@ -8664,8 +8687,15 @@ declare module "esri/graphic" {
* @param value The value of the attribute.
*/
attr(name: string, value: string): Graphic;
/** Creates a deep clone of the graphic object. */
clone(): Graphic;
/** Draws the graphic. */
draw(): Graphic;
/**
* Returns the graphics summarized by the given aggregate graphic in a clustering or feature reduction visualization.
* @param aggregateGraphic A graphic representing the aggregation (or reduction) of several individual graphics in a layer.
*/
getChildGraphics(aggregateGraphic: Graphic): Graphic[];
/** Returns the content string based on attributes and infoTemplate values. */
getContent(): string;
/** Returns the dojo/gfx/shape.Shape of the Esri graphic. */
@@ -8688,6 +8718,8 @@ declare module "esri/graphic" {
getTitle(): string;
/** Hides the graphic. */
hide(): void;
/** Indicates if the graphic represents a cluster of features. */
isAggregate(): boolean;
/**
* Defines the attributes of the graphic.
* @param attributes The name value pairs of fields and field values associated with the graphic.
@@ -9055,7 +9087,7 @@ declare module "esri/layers/ArcGISImageServiceLayer" {
timeInfo: TimeInfo;
/** By default, images are exported in MIME format, and the image is streamed to the client. */
useMapImage: boolean;
/** The version of ArcGIS Server the image service is published to, e.g. */
/** The version of ArcGIS Server the image service is published to, such as 9.3, 9.31, 10, 10.41. */
version: number;
/**
* Creates a new ArcGISImageServiceLayer object.
@@ -9073,7 +9105,7 @@ declare module "esri/layers/ArcGISImageServiceLayer" {
getDefinitionExpression(): string;
/** Get key properties of an ImageService including information such as the band names associated with the imagery. */
getKeyProperties(): any;
/** Asynchronously returns the raster attribute table of an ImageService which returns categorical mapping of pixel values (e.g. */
/** Asynchronously returns the raster attribute table of an ImageService which returns categorical mapping of pixel values (for example a class, group, category, or membership). */
getRasterAttributeTable(): any;
/** Gets the currently visible rasters. */
getVisibleRasters(): Graphic[];
@@ -9651,6 +9683,12 @@ declare module "esri/layers/FeatureLayer" {
* @param errback An error object is returned if an error occurs.
*/
deleteAttachments(objectId: number, attachmentIds: number[], callback?: Function, errback?: Function): any;
/** Disables feature reduction (for example clustering) on the layer. */
disableFeatureReduction(): void;
/** Enables feature reduction (for example clustering) on the layer using the options set in setFeatureReduction(). */
enableFeatureReduction(): void;
/** Returns graphics representing the aggregation of several point features clustered together. */
getAggregateGraphics(): Graphic[];
/** Asynchrously returns custom data for the layer when available. */
getAttributionData(): any;
/** Returns the current definition expression. */
@@ -9678,6 +9716,8 @@ declare module "esri/layers/FeatureLayer" {
* @param options See the object specifications table below for the structure of the options object.
*/
getEditSummary(feature: Graphic, options?: any): string;
/** Returns the options used to reduce the number of features visualized by the layer (for example clustering). */
getFeatureReduction(): any;
/**
* Returns the Field given the specified field name.
* @param fieldName Name of the attribute field.
@@ -9691,6 +9731,8 @@ declare module "esri/layers/FeatureLayer" {
getSelectedFeatures(): Graphic[];
/** Gets the current selection symbol. */
getSelectionSymbol(): Symbol;
/** Returns graphics from the layer that are not represented by aggregate graphics when feature reduction (such as clustering) is enabled. */
getSingleGraphics(): Graphic[];
/** Get the current time definition applied to the feature layer. */
getTimeDefinition(): TimeExtent;
/**
@@ -9702,6 +9744,10 @@ declare module "esri/layers/FeatureLayer" {
hasXYFootprint(): boolean;
/** Returns true if the FeatureLayer is editable. */
isEditable(): boolean;
/** Indicates if feature reduction (for example clustering) is active in the view. */
isFeatureReductionActive(): boolean;
/** Indicates if feature reduction (for example clustering) is enabled. */
isFeatureReductionEnabled(): boolean;
/**
* Returns true if the layer is visible at the given scale.
* @param scale The scale at which to check if the layer is visible.
@@ -9778,6 +9824,11 @@ declare module "esri/layers/FeatureLayer" {
* @param editable When true, the layer will be set as editable.
*/
setEditable(editable: boolean): FeatureLayer;
/**
* Sets feature reduction options on the layer (for example clustering options).
* @param options Options for reducing (or aggregating) the features in the map.
*/
setFeatureReduction(options: any): void;
/**
* Set the layer's data source to the specified geodatabase version.
* @param versionName The name of the geodatabase version to use as the layer's data source.
@@ -10340,6 +10391,8 @@ declare module "esri/layers/KMLLayer" {
* @param isVisible The visibility of the folder and all kml features within the folder.
*/
setFolderVisibility(folder: KMLFolder, isVisible: boolean): void;
/** Fires when one or more of the layer's network link children fail to load. */
on(type: "network-link-error", listener: (event: { error: Error; target: KMLLayer }) => void): esri.Handle;
/** Fired after the layer is refreshed. */
on(type: "refresh", listener: (event: { target: KMLLayer }) => void): esri.Handle;
on(type: string, listener: (event: any) => void): esri.Handle;
@@ -10692,11 +10745,11 @@ declare module "esri/layers/PixelBlock" {
height: number;
/** An array of nodata mask. */
mask: any[];
/** A two dimensional array. */
/** A two dimensional array representing the pixels from the Image Service displayed on the client. */
pixels: number[][];
/** Pixel type. */
pixelType: string;
/** Array of objects containing numeric statistical properties (e.g. */
/** Array of objects containing numeric statistical properties (for example minValue, maxValue, noDataValue, etc.). */
statistics: any[];
/** Number of columns. */
width: number;
@@ -10710,7 +10763,7 @@ declare module "esri/layers/PixelBlock" {
* @param planeData Must have two properties set: pixels and statistics.
*/
addData(planeData: any): void;
/** Returns pixels and masks using a single array in bip format (e.g. */
/** Returns pixels and masks using a single array in bip format (for example [p_00_r, p_00_g, p_00_b, p_00_a, p_10_r, p_10_g, p_10_b, p_10_a, .....]). */
getAsRGBA(): any[];
/** Similar to getAsRGBA, but returns floating point data. */
getAsRGBAFloat(): any[];
@@ -12026,7 +12079,7 @@ declare module "esri/map" {
resize(immediate?: boolean): void;
/**
* Change the background color of the map.
* @param color Color specified using either a named string (e.g.
* @param color Color specified using either a named string (for example red), hex string (for example #FF0000), array of rgba values with "a" in the 0-1 range (for example [255,0,0,0.75]), or an instance of esri/Color.
*/
setBackgroundColor(color: Color | string): void;
/**
@@ -13023,7 +13076,7 @@ declare module "esri/renderers/HeatmapRenderer" {
/** The HeatmapRenderer renders feature layer point data into a raster visualization that emphasizes areas of higher density or weighted values. */
class HeatmapRenderer extends Renderer {
/** The radius (in pixels) of the circle over which the majority of each points value is spread out over. */
/** The radius (in pixels) of the circle over which the majority of each point's value is spread out. */
blurRadius: number;
/** An array of CSS color strings (#RGB, #RRGGBB, rgb(r,g,b), rgba(r,g,b,a)). */
colors: string[];
@@ -13336,6 +13389,7 @@ declare module "esri/renderers/TimeRampAger" {
declare module "esri/renderers/UniqueValueRenderer" {
import Renderer = require("esri/renderers/Renderer");
import FillSymbol = require("esri/symbols/FillSymbol");
import Symbol = require("esri/symbols/Symbol");
import Graphic = require("esri/graphic");
@@ -13347,6 +13401,8 @@ declare module "esri/renderers/UniqueValueRenderer" {
attributeField2: string;
/** If needed, specify an additional attribute field the renderer uses to match values. */
attributeField3: string;
/** A symbol used for polygon features as a background if the renderer uses point symbols, for example for bivariate types & size rendering. */
backgroundFillSymbol: FillSymbol;
/** Label for the default symbol used to draw unspecified values. */
defaultLabel: string;
/** Default symbol used when a value or break cannot be matched. */
@@ -13506,7 +13562,7 @@ declare module "esri/renderers/smartMapping" {
*/
createTypeRenderer(params: any): any;
/**
* Searches the fields of an input layer or array of field objects for field names commonly used in rendering based on usage (e.g.
* Searches the fields of an input layer or array of field objects for field names commonly used in rendering based on usage (e.g., RANK, TOTAL, AVERAGE, NAME, etc).
* @param params See the object specifications table below for details about the params object.
*/
getSuggestedField(params: any): any;
@@ -15247,8 +15303,12 @@ declare module "esri/tasks/IdentifyParameters" {
mapExtent: Extent;
/** The maximum allowable offset used for generalizing geometries returned by the identify operation. */
maxAllowableOffset: number;
/** If true, field names will be returned instead of field aliases. */
returnFieldName: boolean;
/** If "true", the result set includes the geometry associated with each result. */
returnGeometry: boolean;
/** If true, the values in the result will not be formatted i.e. */
returnUnformattedValues: boolean;
/** The spatial reference of the input and output geometries as well as of the mapExtent. */
spatialReference: SpatialReference;
/** Specify the time extent used by the identify task. */
+1 -1
View File
@@ -1,3 +1,3 @@
[*.ts]
indent_style = tab
indent_size = 4
indent_size = 2
+21
View File
@@ -0,0 +1,21 @@
## Atom Keymap Type Definitions
TypeScript type definitions for [Atom Keymap](https://github.com/atom/atom-keymap), which is published as "[atom-keymap](https://www.npmjs.com/package/atom-keymap)" on NPM.
### Usage Notes
#### Exports
This module has a single entity as its export: the [KeymapManager](https://github.com/atom/atom-keymap/blob/master/src/keymap-manager.coffee) class. The require syntax is typically used to import modules like this.
```ts
import KeymapManager = require("atom-keymap");
```
#### The AtomKeymap Namespace
Many of the types used by Atom Keymap can be referenced from the AtomKeymap namespace.
```ts
function example(keybind: AtomKeymap.KeyBinding) {}
```
+84 -13
View File
@@ -1,20 +1,91 @@
import KeymapManager = require("atom-keymap");
import * as ImportTest from "atom-keymap";
declare const element: HTMLElement;
declare let sub: EventKit.Disposable;
declare const event: KeyboardEvent;
import { KeymapManager, ICompleteMatchEvent } from "atom-keymap";
// NPM Examples ===============================================================
const keymaps = new KeymapManager();
keymaps.defaultTarget = document.body;
var manager = new KeymapManager();
manager.add('some/unique/path', {
'.workspace': {
'ctrl-x': 'package:do-something',
'ctrl-y': 'package:do-something-else'
},
'.mini.editor': {
'enter': 'core:confirm'
}
// Pass all the window's keydown events to the KeymapManager
document.addEventListener("keydown", (event): void => {
keymaps.handleKeyboardEvent(event);
});
manager.onDidMatchBinding((event: ICompleteMatchEvent): void => {
console.log(event.binding.command);
})
// Add some keymaps. It can also be a directory of json / cson files.
keymaps.loadKeymap("/path/to/keymap-file.json");
// OR
keymaps.add("/key/for/these/keymaps", {
body: {
up: "core:move-up",
down: "core:move-down",
},
});
// When a keybinding is triggered, it will dispatch it on the node that was focused
window.addEventListener("core:move-up", (event) => console.log("up", event));
window.addEventListener("core:move-down", (event) => console.log("down", event));
// General Usage ==============================================================
const manager = new KeymapManager();
manager.add("some/unique/path", {
".workspace": {
"ctrl-x": "package:do-something",
"ctrl-y": "package:do-something-else",
},
".test": {
enter: "core:confirm",
},
});
manager.onDidMatchBinding((event): void => {
console.log(event.binding.command);
});
manager.destroy();
// Atom API Testing ===========================================================
// Class Methods
KeymapManager.buildKeydownEvent("a");
KeymapManager.buildKeydownEvent("a", { alt: true });
// Construction and Destruction
new KeymapManager({ defaultTarget: element });
manager.clear();
manager.destroy();
// Event Subscription
sub = manager.onDidMatchBinding((event): void => { event.keystrokes; });
sub = manager.onDidPartiallyMatchBindings((event): void => { event.partiallyMatchedBindings; });
sub = manager.onDidFailToMatchBinding((event): void => { event.keystrokes; });
sub = manager.onDidFailToReadFile((event): void => { event.stack; });
// Adding and Removing Bindings
sub = manager.add("a", {}, 0);
// Accessing Bindings
let bindings: AtomKeymap.KeyBinding[] = manager.getKeyBindings();
bindings = manager.findKeyBindings();
bindings = manager.findKeyBindings({ command: "a" });
bindings = manager.findKeyBindings({ keystrokes: "a" });
bindings = manager.findKeyBindings({ target: element });
bindings = manager.findKeyBindings({ command: "a", keystrokes: "b"});
bindings = manager.findKeyBindings({ command: "a", keystrokes: "b", target: element });
// Managing Keymap Files
manager.loadKeymap("Test.file");
manager.loadKeymap("Test.file", { watch: true });
manager.loadKeymap("Test.file", { watch: true, priority: 0});
// Managing Keyboard Events
manager.handleKeyboardEvent(event);
manager.keystrokeForKeyboardEvent(event);
sub = manager.addKeystrokeResolver((event): string => {
event.layoutName;
return "Test";
});
const num: number = manager.getPartialMatchTimeout();
+208 -107
View File
@@ -1,135 +1,236 @@
// Type definitions for atom-keymap v5.1.5
// Project: https://github.com/atom/atom-keymap/
// Definitions by: Vadim Macagon <https://github.com/enlight>
// Type definitions for atom-keymap 8.x
// Project: https://github.com/atom/atom-keymap
// Definitions by: GlenCFL <https://github.com/GlenCFL>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
/// <reference types="event-kit" />
import * as AtomEventKit from 'event-kit';
declare global {
namespace AtomKeymap {
/** Objects that appear as parameters to callbacks. */
namespace Events {
interface FullKeybindingMatch {
/** The string of keystrokes that matched the binding. */
keystrokes: string;
export = AtomKeymap;
/** The KeyBinding that the keystrokes matched. */
binding: KeyBinding;
declare namespace AtomKeymap {
type Disposable = AtomEventKit.Disposable;
/** The DOM element that was the target of the most recent keyboard event. */
keyboardEventTarget: Element;
}
/** Instance side of KeyBinding class. */
interface KeyBinding {
enabled: boolean;
source: string;
command: string;
keystrokes: string;
keystrokeCount: number;
selector: string;
specificity: number;
interface PartialKeybindingMatch {
/** The string of keystrokes that matched the binding. */
keystrokes: string;
matches(keystroke: string): boolean;
compare(keyBinding: KeyBinding): number;
}
/** The KeyBindings that the keystrokes partially matched. */
partiallyMatchedBindings: KeyBinding[];
interface ICompleteMatchEvent {
/** Keystrokes that matched the binding. */
keystrokes: string;
/** Binding that was matched to the keystrokes. */
binding: KeyBinding;
/** DOM element that was the target of the most recent `KeyboardEvent`. */
keyboardEventTarget: Element;
}
/** DOM element that was the target of the most recent keyboard event. */
keyboardEventTarget: Element;
}
interface IPartialMatchEvent {
/** Keystrokes that matched the binding. */
keystrokes: string;
/** Bindings that were partially matched to the keystrokes. */
partiallyMatchedBindings: KeyBinding[];
/** DOM element that was the target of the most recent `KeyboardEvent`. */
keyboardEventTarget: Element;
}
interface FailedKeybindingMatch {
/** The string of keystrokes that failed to match the binding. */
keystrokes: string;
interface IFailedMatchEvent {
/** Keystrokes that failed to match a binding. */
keystrokes: string;
/** DOM element that was the target of the most recent `KeyboardEvent`. */
keyboardEventTarget: Element;
}
/** The DOM element that was the target of the most recent keyboard event. */
keyboardEventTarget: Element;
}
interface IKeymapLoadEvent {
/** Path to a keymap file. */
path: string;
}
interface FailedKeymapFileRead {
/** The error message. */
message: string;
/** Static side of KeymapManager class. */
interface KeymapManagerStatic {
prototype: KeymapManager;
new (options?: { defaultTarget?: Element }): KeymapManager;
}
/** The error stack trace. */
stack: string;
}
/** Instance side of KeymapManager class. */
interface KeymapManager {
constructor: KeymapManagerStatic;
/** Unwatches all watched paths. */
destroy(): void;
interface KeymapLoaded {
/** The path of the keymap file. */
path: string;
}
// Event Subscription
interface AddedKeystrokeResolver {
/** The currently resolved keystroke string. If your function returns a falsy
* value, this is how Atom will resolve your keystroke.
*/
keystroke: string;
/** Sets callback to invoke when one or more keystrokes completely match a key binding. */
onDidMatchBinding(callback: (event: ICompleteMatchEvent) => void): Disposable;
/** Sets callback to invoke when one or more keystrokes partially match a binding. */
onDidPartiallyMatchBindings(callback: (event: IPartialMatchEvent) => void): Disposable;
/** Sets callback to invoke when one or more keystrokes fail to match any bindings. */
onDidFailToMatchBinding(callback: (event: IFailedMatchEvent) => void): Disposable;
/** Sets callback to invoke when a keymap file is reloaded. */
onDidReloadKeymap(callback: (event: IKeymapLoadEvent) => void): Disposable;
/** Sets callback to invoke when a keymap file is unloaded. */
onDidUnloadKeymap(callback: (event: IKeymapLoadEvent) => void): Disposable;
/** Sets callback to invoke when a keymap file could not to be loaded. */
onDidFailToReadFile(callback: (error: Error) => void): Disposable;
/** The raw DOM 3 `KeyboardEvent` being resolved. See the DOM API documentation
* for more details.
*/
event: KeyboardEvent;
// Adding and Removing Bindings
/** The OS-specific name of the current keyboard layout. */
layoutName: string;
/** Adds sets of key bindings grouped by CSS selector. */
add(source: string, keyBindingsBySelector: any): Disposable;
/** 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.
*/
keymap: object;
}
}
// Accessing Bindings
/** Objects that appear as parameters to functions. */
namespace Options {
interface BuildKeyEvent {
ctrl?: boolean;
alt?: boolean;
shift?: boolean;
cmd?: boolean;
which?: number;
target?: Element;
}
}
getKeyBindings(): KeyBinding[];
findKeyBindings(params?: {
keystrokes: string; // e.g. 'ctrl-x ctrl-s'
command: string; // e.g. 'editor:backspace'
target?: Element;
}): KeyBinding[];
/** The static side to each exported class. Should generally only be used internally. */
namespace Statics {
/* tslint:disable:no-unnecessary-qualifier */
/** The static side to the KeymapManager class. */
interface KeymapManager {
/** Create a keydown DOM event. */
buildKeydownEvent(key: string, options?: AtomKeymap.Options.BuildKeyEvent): void;
// Managing Keymap Files
/** Create a keyup DOM event. */
buildKeyupEvent(key: string, options?: AtomKeymap.Options.BuildKeyEvent): void;
/**
* Loads the key bindings from the given path.
*
* @param bindingsPath A path to a file or a directory. If the path is a directory all files
* inside it will be loaded.
/** Create a new KeymapManager. */
new (options?: { defaultTarget?: HTMLElement }): AtomKeymap.KeymapManager;
}
/* tslint:enable:no-unnecessary-qualifier */
}
/** 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.
*/
loadKeymap(bindingsPath: string, options?: { watch: boolean }): void;
/**
* Starts watching the given file/directory for changes, reloading any keymaps at that location
* when changes are detected.
*
* @param filePath A path to a file or a directory.
*/
watchKeymap(filePath: string): void;
interface CommandEvent extends CustomEvent {
keyBindingAborted: boolean;
propagationStopped: boolean;
// Managing Keyboard Events
abortKeyBinding(): void;
stopPropagation(): CustomEvent;
stopImmediatePropagation(): CustomEvent;
}
/**
* Dispatches a custom event associated with the matching key binding for the given
* `KeyboardEvent` if one can be found.
interface KeyBinding {
// Properties
enabled: boolean;
source: string;
command: string;
keystrokes: string;
keystrokeArray: string[];
keystrokeCount: number;
selector: string;
specificity: number;
// Comparison
/** Determines whether the given keystroke matches any contained within this binding. */
matches(keystroke: string): boolean;
/** 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.
*/
compare(other: KeyBinding): number;
}
/** 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`.
*/
handleKeyboardEvent(event: KeyboardEvent): void;
/** Translates a keydown event to a keystroke string. */
keystrokeForKeyboardEvent(event: KeyboardEvent): string;
/**
* @return The number of milliseconds allowed before pending states caused by partial matches of
* multi-keystroke bindings are terminated.
*/
getPartialMatchTimeout(): number;
/** Instance side of KeymapManager class. */
interface KeymapManager {
defaultTarget: HTMLElement;
partialMatchTimeout: number;
/** Clear all registered key bindings and enqueued keystrokes. For use in tests. */
clear(): void;
/** Unwatch all watched paths. */
destroy(): void;
// Event Subscription
/** Invoke the given callback when one or more keystrokes completely match a key binding. */
onDidMatchBinding(callback: (event: Events.FullKeybindingMatch) => void):
EventKit.Disposable;
/** Invoke the given callback when one or more keystrokes partially match a binding. */
onDidPartiallyMatchBindings(callback: (event: Events.PartialKeybindingMatch) =>
void): EventKit.Disposable;
/** Invoke the given callback when one or more keystrokes fail to match any bindings. */
onDidFailToMatchBinding(callback: (event: Events.FailedKeybindingMatch) =>
void): EventKit.Disposable;
/** Invoke the given callback when a keymap file is reloaded. */
onDidReloadKeymap(callback: (event: Events.KeymapLoaded) => void):
EventKit.Disposable;
/** Invoke the given callback when a keymap file is unloaded. */
onDidUnloadKeymap(callback: (event: Events.KeymapLoaded) => void):
EventKit.Disposable;
/** Invoke the given callback when a keymap file not able to be loaded. */
onDidFailToReadFile(callback: (error: Events.FailedKeymapFileRead) => void):
EventKit.Disposable;
// Adding and Removing Bindings
/** Construct KeyBindings from an object grouping them by CSS selector. */
build(source: string, bindings: { [key: string]: { [key: string]: string }},
priority?: number): KeyBinding[];
/** Add sets of key bindings grouped by CSS selector. */
add(source: string, bindings: { [key: string]: { [key: string]: string }},
priority?: number): EventKit.Disposable;
// Accessing Bindings
/** Get all current key bindings. */
getKeyBindings(): KeyBinding[];
/** Get the key bindings for a given command and optional target. */
findKeyBindings(params?: {
keystrokes?: string, // e.g. 'ctrl-x ctrl-s'
command?: string, // e.g. 'editor:backspace'
target?: Element,
}): KeyBinding[];
// Managing Keymap Files
/** Load the key bindings from the given path. */
loadKeymap(bindingsPath: string, options?: { watch?: boolean, priority?: number }):
void;
/** 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
* given `KeyboardEvent` if one can be found.
*/
handleKeyboardEvent(event: KeyboardEvent): void;
/** Translates a keydown event to a keystroke string. */
keystrokeForKeyboardEvent(event: KeyboardEvent): string;
/** Customize translation of raw keyboard events to keystroke strings. */
addKeystrokeResolver(resolver: (event: Events.AddedKeystrokeResolver) => string):
EventKit.Disposable;
/** Get the number of milliseconds allowed before pending states caused by
* partial matches of multi-keystroke bindings are terminated.
*/
getPartialMatchTimeout(): number;
}
}
/** Allows commands to be associated with keystrokes in a context-sensitive way.*/
var KeymapManager: KeymapManagerStatic;
}
declare const KeymapManager: AtomKeymap.Statics.KeymapManager;
export = KeymapManager;
+2 -2
View File
@@ -7,7 +7,7 @@
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
@@ -20,4 +20,4 @@
"index.d.ts",
"atom-keymap-tests.ts"
]
}
}
+38
View File
@@ -0,0 +1,38 @@
{
"extends": "dtslint/dt.json",
"rules": {
// Custom rules.
"class-name": true,
"indent": [true, "tabs"],
"jsdoc-format": true,
"linebreak-style": [true, "LF"],
"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
}
}
+3
View File
@@ -0,0 +1,3 @@
[*.ts]
indent_style = tab
indent_size = 4
+20
View File
@@ -0,0 +1,20 @@
import { KeymapManager, ICompleteMatchEvent } from "atom-keymap";
var manager = new KeymapManager();
manager.add('some/unique/path', {
'.workspace': {
'ctrl-x': 'package:do-something',
'ctrl-y': 'package:do-something-else'
},
'.mini.editor': {
'enter': 'core:confirm'
}
});
manager.onDidMatchBinding((event: ICompleteMatchEvent): void => {
console.log(event.binding.command);
})
manager.destroy();
+133
View File
@@ -0,0 +1,133 @@
// Type definitions for atom-keymap v5.1.5
// Project: https://github.com/atom/atom-keymap/
// Definitions by: Vadim Macagon <https://github.com/enlight>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import * as AtomEventKit from 'event-kit';
export = AtomKeymap;
declare namespace AtomKeymap {
type Disposable = AtomEventKit.Disposable;
/** Instance side of KeyBinding class. */
interface KeyBinding {
enabled: boolean;
source: string;
command: string;
keystrokes: string;
keystrokeCount: number;
selector: string;
specificity: number;
matches(keystroke: string): boolean;
compare(keyBinding: KeyBinding): number;
}
interface ICompleteMatchEvent {
/** Keystrokes that matched the binding. */
keystrokes: string;
/** Binding that was matched to the keystrokes. */
binding: KeyBinding;
/** DOM element that was the target of the most recent `KeyboardEvent`. */
keyboardEventTarget: Element;
}
interface IPartialMatchEvent {
/** Keystrokes that matched the binding. */
keystrokes: string;
/** Bindings that were partially matched to the keystrokes. */
partiallyMatchedBindings: KeyBinding[];
/** DOM element that was the target of the most recent `KeyboardEvent`. */
keyboardEventTarget: Element;
}
interface IFailedMatchEvent {
/** Keystrokes that failed to match a binding. */
keystrokes: string;
/** DOM element that was the target of the most recent `KeyboardEvent`. */
keyboardEventTarget: Element;
}
interface IKeymapLoadEvent {
/** Path to a keymap file. */
path: string;
}
/** Static side of KeymapManager class. */
interface KeymapManagerStatic {
prototype: KeymapManager;
new (options?: { defaultTarget?: Element }): KeymapManager;
}
/** Instance side of KeymapManager class. */
interface KeymapManager {
constructor: KeymapManagerStatic;
/** Unwatches all watched paths. */
destroy(): void;
// Event Subscription
/** Sets callback to invoke when one or more keystrokes completely match a key binding. */
onDidMatchBinding(callback: (event: ICompleteMatchEvent) => void): Disposable;
/** Sets callback to invoke when one or more keystrokes partially match a binding. */
onDidPartiallyMatchBindings(callback: (event: IPartialMatchEvent) => void): Disposable;
/** Sets callback to invoke when one or more keystrokes fail to match any bindings. */
onDidFailToMatchBinding(callback: (event: IFailedMatchEvent) => void): Disposable;
/** Sets callback to invoke when a keymap file is reloaded. */
onDidReloadKeymap(callback: (event: IKeymapLoadEvent) => void): Disposable;
/** Sets callback to invoke when a keymap file is unloaded. */
onDidUnloadKeymap(callback: (event: IKeymapLoadEvent) => void): Disposable;
/** Sets callback to invoke when a keymap file could not to be loaded. */
onDidFailToReadFile(callback: (error: Error) => void): Disposable;
// Adding and Removing Bindings
/** Adds sets of key bindings grouped by CSS selector. */
add(source: string, keyBindingsBySelector: any): Disposable;
// Accessing Bindings
getKeyBindings(): KeyBinding[];
findKeyBindings(params?: {
keystrokes: string; // e.g. 'ctrl-x ctrl-s'
command: string; // e.g. 'editor:backspace'
target?: Element;
}): KeyBinding[];
// Managing Keymap Files
/**
* Loads the key bindings from the given path.
*
* @param bindingsPath A path to a file or a directory. If the path is a directory all files
* inside it will be loaded.
*/
loadKeymap(bindingsPath: string, options?: { watch: boolean }): void;
/**
* Starts watching the given file/directory for changes, reloading any keymaps at that location
* when changes are detected.
*
* @param filePath A path to a file or a directory.
*/
watchKeymap(filePath: string): void;
// Managing Keyboard Events
/**
* Dispatches a custom event associated with the matching key binding for the given
* `KeyboardEvent` if one can be found.
*/
handleKeyboardEvent(event: KeyboardEvent): void;
/** Translates a keydown event to a keystroke string. */
keystrokeForKeyboardEvent(event: KeyboardEvent): string;
/**
* @return The number of milliseconds allowed before pending states caused by partial matches of
* multi-keystroke bindings are terminated.
*/
getPartialMatchTimeout(): number;
}
/** Allows commands to be associated with keystrokes in a context-sensitive way.*/
var KeymapManager: KeymapManagerStatic;
}
+27
View File
@@ -0,0 +1,27 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"baseUrl": "../../",
"typeRoots": [
"../../"
],
"paths": {
"atom-keymap": [ "atom-keymap/v5" ],
"event-kit": [ "event-kit/v1" ]
},
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"atom-keymap-tests.ts"
]
}
+3
View File
@@ -0,0 +1,3 @@
[*.ts]
indent_style = tab
indent_size = 2
+42
View File
@@ -0,0 +1,42 @@
## 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.19.5/), though these type definitions include many types and class properties not mentioned within that documentation.
### 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.19.5/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.
```ts
/// <reference types="atom/services" />
let completionProvider: Atom.Services.Autocomplete.Provider;
```
The currently supported services are:
- [Autocomplete](https://github.com/atom/autocomplete-plus)
- [Status Bar](https://github.com/atom/status-bar)
+2068 -51
View File
File diff suppressed because it is too large Load Diff
+4037 -1867
View File
File diff suppressed because it is too large Load Diff
+6
View File
@@ -0,0 +1,6 @@
{
"private": true,
"dependencies": {
"electron": "1.6.9"
}
}
+190
View File
@@ -0,0 +1,190 @@
/* tslint:disable:no-unnecessary-qualifier */
declare namespace Atom {
namespace Services {
/** Type definitions for autocomplete+ 2 */
namespace Autocomplete {
/** Objects that appear as parameters to callbacks. */
namespace Events {
/** The parameters passed into getSuggestions by Autocomplete+. */
interface SuggestionsRequested {
/** The current TextEditor. */
editor: Atom.TextEditor;
/** The position of the cursor. */
bufferPosition: Atom.Point;
/** The scope descriptor for the current cursor position. */
scopeDescriptor: Atom.ScopeDescriptor;
/** The prefix for the word immediately preceding the current cursor position. */
prefix: string;
/** Whether the autocomplete request was initiated by the user. */
activatedManually: boolean;
}
/** The parameters passed into onDidInsertSuggestion by Autocomplete+. */
interface SuggestionInserted {
editor: Atom.TextEditor;
triggerPosition: Atom.Point;
suggestion: TextSuggestion|SnippetSuggestion;
}
}
/** An autocompletion suggestion for the user.
* Primary data type for the Atom Autocomplete+ service.
*/
interface 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.
* 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 suggestion. */
type?: string;
/** This is shown before the suggestion. Useful for return values. */
leftLabel?: 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 represents. */
rightLabel?: 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 suggestion
* via CSS, if desired.
*/
className?: string;
/** 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 will be
* displayed at the bottom of the suggestions list.
*/
description?: string;
/** 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;
}
interface TextSuggestion extends Suggestion {
/** The text which will be inserted into the editor, in place of the prefix. */
text: string;
}
interface SnippetSuggestion extends Suggestion {
/** A snippet string. This will allow users to tab through function arguments or other
* options.
*/
snippet: string;
}
type Suggestions = Array<TextSuggestion|SnippetSuggestion>;
interface 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 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: Events.SuggestionsRequested): Suggestions|Promise<Suggestions>;
/** 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.
* The default provider has an inclusion priority of 0. Higher priority providers
* can suppress lower priority providers with excludeLowerPriority.
*/
inclusionPriority?: number;
/** 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
* an suggestion priority of 1.
*/
suggestionPriority?: number;
/** Function that is called when a suggestion from your provider was inserted
* into the buffer.
*/
onDidInsertSuggestion?(params: Events.SuggestionInserted): void;
/** Will be called if your provider is being destroyed by autocomplete+ */
dispose?(): void;
}
}
/** Type definitions for status-bar 1.8 */
namespace StatusBar {
/** Objects that appear as parameters to functions. */
namespace Options {
interface AddTile {
/** 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
* will result in closer placement to the anchor.
*/
priority: number;
}
}
interface Tile {
/** Retrieve the priority that was assigned to the Tile when it was created. */
getPriority(): number;
/** Retrieve the Tile's item. */
getItem(): object;
/** Remove the Tile from the status bar. */
destroy(): void;
}
interface StatusBar {
/** Add a tile to the left side of the status bar. Lower priority tiles are placed
* further to the left.
*/
addLeftTile(options: Options.AddTile): Tile;
/** Add a tile to the right side of the status bar. Lower priority tiles are placed
* further to the right.
*/
addRightTile(options: Options.AddTile): Tile;
/** Retrieve all of the tiles on the left side of the status bar. */
getLeftTiles(): Tile[];
/** Retrieve all of the tiles on the right side of the status bar. */
getRightTiles(): Tile[];
}
type Consumer = (statusBar: StatusBar) => void;
}
}
}
/* tslint:enable:no-unnecessary-qualifier */
+4 -7
View File
@@ -7,21 +7,18 @@
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"paths": {
"q": [ "q/v0" ]
},
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"api-docs.d.ts",
"atom-tests.ts"
"atom-tests.ts",
"services/index.d.ts"
]
}
}
+39
View File
@@ -0,0 +1,39 @@
{
"extends": "dtslint/dt.json",
"rules": {
// Custom rules.
"await-promise": [true, "CancellablePromise"],
"class-name": true,
"indent": [true, "tabs"],
"jsdoc-format": true,
"linebreak-style": [true, "LF"],
"max-line-length": [true, 100],
"no-any": false,
"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-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
}
}
+70
View File
@@ -0,0 +1,70 @@
import path = require("path");
import _atom = require("atom");
import PathWatcher = require("pathwatcher");
var File = PathWatcher.File;
const jq: JQuery = $("selector");
class SampleView extends _atom.ScrollView {
editorId:string;
file:PathWatcher.IFile;
editor:AtomCore.IEditor;
static deserialize(state:any):SampleView {
return new SampleView(state);
}
static content():any {
return this.div({class: 'sample native-key-bindings', tabindex: -1});
}
constructor(params:{editorId?:string; filePath?:string;} = {}) {
super();
this.editorId = params.editorId;
if (this.editorId) {
this.resolveEditor(this.editorId);
} else {
this.file = new File(params.filePath);
}
}
serialize() {
return {
deserializer: 'SampleView',
editorId: this.editorId
};
}
destroy() {
this.unsubscribe();
}
resolveEditor(editorId:string) {
var resolve = ()=> {
if (this.editor) {
jq.trigger("title-changed");
} else {
var view = jq.parents('.pane').view();
if (view) {
view.destroyItem(this);
}
}
};
if (atom.workspace) {
resolve();
} else {
atom.packages.once("activated", ()=> {
resolve();
});
}
}
}
atom.deserializers.add(SampleView);
export = SampleView;
+1977
View File
File diff suppressed because it is too large Load Diff
+29
View File
@@ -0,0 +1,29 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"baseUrl": "../../",
"typeRoots": [
"../../"
],
"paths": {
"atom": [ "atom/v0" ],
"pathwatcher": [ "pathwatcher/v0" ],
"q": [ "q/v0" ]
},
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"api-docs.d.ts",
"atom-tests.ts"
]
}
+5
View File
@@ -8,6 +8,11 @@
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
+5 -3
View File
@@ -839,10 +839,12 @@ obj = Promise.promisifyAll(obj, {
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
//TODO enable generator
/*
func = Promise.coroutine(f);
const generator = function* (a: number, b: string) {return "string"}
const coroutine = Promise.coroutine<string, number, string>(generator);
coroutine(5, "foo").then((x: string) => {});
const coroutineCustomYield = Promise.coroutine(generator, { yieldHandler: (value) => "whatever" })
/*
barProm = Promise.spawn<number>(f);
*/
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+14 -3
View File
@@ -776,9 +776,17 @@ declare class Bluebird<R> implements PromiseLike<R>, Bluebird.Inspection<R> {
/**
* Returns a function that can use `yield` to run asynchronous code synchronously. This feature requires the support of generators which are drafted in the next version of the language. Node version greater than `0.11.2` is required and needs to be executed with the `--harmony-generators` (or `--harmony`) command-line switch.
*/
// TODO fix coroutine GeneratorFunction
static coroutine(generatorFunction: (...args: any[]) => IterableIterator<any>): (...args: any[]) => Bluebird<any>;
// TODO: After https://github.com/Microsoft/TypeScript/issues/2983 is implemented, we can use
// the return type propagation of generators to automatically infer the return type T.
static coroutine<T>(generatorFunction: () => IterableIterator<any>, options?: Bluebird.CoroutineOptions): () => Bluebird<T>;
static coroutine<T, A1>(generatorFunction: (a1: A1) => IterableIterator<any>, options?: Bluebird.CoroutineOptions): (a1: A1) => Bluebird<T>;
static coroutine<T, A1, A2>(generatorFunction: (a1: A1, a2: A2) => IterableIterator<any>, options?: Bluebird.CoroutineOptions): (a1: A1, a2: A2) => Bluebird<T>;
static coroutine<T, A1, A2, A3>(generatorFunction: (a1: A1, a2: A2, a3: A3) => IterableIterator<any>, options?: Bluebird.CoroutineOptions): (a1: A1, a2: A2, a3: A3) => Bluebird<T>;
static coroutine<T, A1, A2, A3, A4>(generatorFunction: (a1: A1, a2: A2, a3: A3, a4: A4) => IterableIterator<any>, options?: Bluebird.CoroutineOptions): (a1: A1, a2: A2, a3: A3, a4: A4) => Bluebird<T>;
static coroutine<T, A1, A2, A3, A4, A5>(generatorFunction: (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5) => IterableIterator<any>, options?: Bluebird.CoroutineOptions): (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5) => Bluebird<T>;
static coroutine<T, A1, A2, A3, A4, A5, A6>(generatorFunction: (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6) => IterableIterator<any>, options?: Bluebird.CoroutineOptions): (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6) => Bluebird<T>;
static coroutine<T, A1, A2, A3, A4, A5, A6, A7>(generatorFunction: (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7) => IterableIterator<any>, options?: Bluebird.CoroutineOptions): (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7) => Bluebird<T>;
static coroutine<T, A1, A2, A3, A4, A5, A6, A7, A8>(generatorFunction: (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7, a8: A8) => IterableIterator<any>, options?: Bluebird.CoroutineOptions): (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7, a8: A8) => Bluebird<T>;
/**
* Add `handler` as the handler to call when there is a possibly unhandled rejection. The default handler logs the error stack to stderr or `console.error` in browsers.
*
@@ -1021,6 +1029,9 @@ declare namespace Bluebird {
// The promisifier gets a reference to the original method and should return a function which returns a promise
promisifier?: (originalMethod: (...args: any[]) => any, defaultPromisifer: (...args: any[]) => (...args: any[]) => Bluebird<any>) => () => PromiseLike<any>;
}
export interface CoroutineOptions {
yieldHandler: (value: any) => any;
}
/**
* Represents an error is an explicit promise rejection as opposed to a thrown error.
+1 -1
View File
@@ -19,4 +19,4 @@
"noEmit": true,
"forceConsistentCasingInFileNames": true
}
}
}
+29
View File
@@ -0,0 +1,29 @@
{
"extends": "dtslint/dt.json",
"rules": {
"adjacent-overload-signatures": false,
"array-type": false,
"ban-types": false,
"comment-format": false,
"dt-header": false,
"max-line-length": false,
"member-access": false,
"no-consecutive-blank-lines": false,
"no-padding": false,
"no-unnecessary-callback-wrapper": false,
"no-unnecessary-generics": false,
"no-var-keyword": false,
"no-void-expression": false,
"one-line": false,
"only-arrow-functions": false,
"prefer-const": false,
"prefer-method-signature": false,
"semicolon": false,
"space-before-function-paren": false,
"strict-export-declare-modifiers": false,
"typedef-whitespace": false,
"unified-signatures": false,
"void-return": false,
"whitespace": false
}
}
+1 -1
View File
@@ -318,7 +318,7 @@ declare namespace Chart {
lineWidth?: number;
drawBorder?: boolean;
drawOnChartArea?: boolean;
drawticks?: boolean;
drawTicks?: boolean;
tickMarkLength?: number;
zeroLineWidth?: number;
zeroLineColor?: ChartColor;
+139 -122
View File
@@ -1,6 +1,6 @@
// Type definitions for Chartist v0.9.6
// Type definitions for Chartist v0.9.7
// Project: https://github.com/gionkunz/chartist-js
// Definitions by: Matt Gibbs <https://github.com/mtgibbs>, Simon Pfeifer <https://github.com/psimonski>
// Definitions by: Matt Gibbs <https://github.com/mtgibbs>, Simon Pfeifer <https://github.com/psimonski>, Cassey Lottman <https://github.com/clottman>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare namespace Chartist {
@@ -187,11 +187,17 @@ declare namespace Chartist {
* If specified the donut CSS classes will be used and strokes will be drawn instead of pie slices.
*/
donut?: boolean;
/**
* If specified the donut segments will be drawn as shapes instead of strokes.
*/
donutSolid?: boolean;
/**
* Specify the donut stroke width, currently done in javascript for convenience.
* Specify the donut stroke width, currently done in javascript for convenience. May move to CSS styles in the future.
* This option can be set as number or string to specify a relative width (i.e. 100 or '30%').
*/
donutWidth?: number;
donutWidth?: number | string;
/**
* Specify if a label should be shown or not
@@ -217,6 +223,16 @@ declare namespace Chartist {
* Label direction can be 'neutral', 'explode' or 'implode'. Default is 'neutral'. The labels anchor will be positioned based on those settings as well as the fact if the labels are on the right or left side of the center of the chart. Usually explode is useful when labels are positioned far away from the center.
*/
labelDirection?: string;
/**
* If true the whole data is reversed including labels, the series order as well as the whole series data arrays.
*/
reverseData?: boolean;
/**
* If true empty values will be ignored to avoid drawing unncessary slices and labels
*/
ignoreEmptyValues?: boolean;
}
interface IChartPadding {
@@ -357,123 +373,124 @@ declare namespace Chartist {
end?: string;
}
interface ICandleChartOptions extends IChartOptions {
/**
* Options for X-Axis
*/
axisX?: ICandleChartAxis;
/**
* Options for Y-Axis
*/
axisY?: ICandleChartAxis;
/**
* Specify a fixed width for the chart as a string (i.e. '100px' or '50%')
*/
width?: number | string;
/**
* Specify a fixed height for the chart as a string (i.e. '100px' or '50%')
*/
height?: number | string;
/**
* Overriding the natural high of the chart allows you to zoom in or limit the charts highest displayed value
*/
hight?: number | string;
/**
* Overriding the natural low of the chart allows you to zoom in or limit the charts lowest displayed value
*/
low?: number | string;
/**
* Width of candle body in pixel (IMO is 2 px best minimum value)
*/
candleWidth?: number | string;
/**
* Width of candle wick in pixel (IMO is 1 px best minimum value)
*/
candleWickWidth?: number | string;
/**
* Use calculated x-axis step length, depending on the number of quotes to display, as candle width. Otherwise the candleWidth is being used.
*/
useStepLengthAsCandleWidth?: boolean | string;
/**
* Use 1/3 of candle body width as width for the candle wick, otherwise the candleWickWidth is being used.
*/
useOneThirdAsCandleWickWidth?: boolean | string;
/**
* Padding of the chart drawing area to the container element and labels as a number or padding object {top: 5, right: 5, bottom: 5, left: 5}
*/
chartPadding?: IChartPadding | number;
/**
* When set to true, the last grid line on the x-axis is not drawn and the chart elements will expand to the full available width of the chart. For the last label to be drawn correctly you might need to add chart padding or offset the last label with a draw event handler.
*/
fullWidth?: boolean | string;
/**
* Override the class names that get used to generate the SVG structure of the chart
*/
classNames?: ICandleChartClasses;
}
interface ICandleChartAxis {
/**
* The offset of the chart drawing area to the border of the container
*/
offset?: number;
/**
* Position where labels are placed. Can be set to `start` or `end` where `start` is equivalent to left or top on vertical axis and `end` is equivalent to right or bottom on horizontal axis.
*/
position?: string;
/**
* Allows you to correct label positioning on this axis by positive or negative x and y offset.
*/
labelOffset?: {
x?: number;
y?: number;
};
/**
* If labels should be shown or not
*/
showLabel?: boolean;
/**
* If the axis grid should be drawn or not
*/
showGrid?: boolean;
/**
* Interpolation function that allows you to intercept the value from the axis label
*/
labelInterpolationFnc?: Function;
/**
* Set the axis type to be used to project values on this axis. If not defined, Chartist.StepAxis will be used for the X-Axis, where the ticks option will be set to the labels in the data and the stretch option will be set to the global fullWidth option. This type can be changed to any axis constructor available (e.g. Chartist.FixedScaleAxis), where all axis options should be present here.
*/
type?: any;
}
interface ICandleChartClasses {
chart?: string;
label?: string;
labelGroup?: string;
series?: string;
candlePositive?: string;
candleNegative?: string,
grid?: string,
gridGroup?: string,
gridBackground?: string,
vertical?: string,
horizontal?: string,
start?: string,
end?: string,
}
interface ICandleChartOptions extends IChartOptions {
/**
* Options for X-Axis
*/
axisX?: ICandleChartAxis;
/**
* Options for Y-Axis
*/
axisY?: ICandleChartAxis;
/**
* Specify a fixed width for the chart as a string (i.e. '100px' or '50%')
*/
width?: number | string;
/**
* Specify a fixed height for the chart as a string (i.e. '100px' or '50%')
*/
height?: number | string;
/**
* Overriding the natural high of the chart allows you to zoom in or limit the charts highest displayed value
*/
hight?: number | string;
/**
* Overriding the natural low of the chart allows you to zoom in or limit the charts lowest displayed value
*/
low?: number | string;
/**
* Width of candle body in pixel (IMO is 2 px best minimum value)
*/
candleWidth?: number | string;
/**
* Width of candle wick in pixel (IMO is 1 px best minimum value)
*/
candleWickWidth?: number | string;
/**
* Use calculated x-axis step length, depending on the number of quotes to display, as candle width. Otherwise the candleWidth is being used.
*/
useStepLengthAsCandleWidth?: boolean | string;
/**
* Use 1/3 of candle body width as width for the candle wick, otherwise the candleWickWidth is being used.
*/
useOneThirdAsCandleWickWidth?: boolean | string;
/**
* Padding of the chart drawing area to the container element and labels as a number or padding object {top: 5, right: 5, bottom: 5, left: 5}
*/
chartPadding?: IChartPadding | number;
/**
* When set to true, the last grid line on the x-axis is not drawn and the chart elements will expand to the full available width of the chart. For the last label to be drawncorrectly you might need to add chart padding or offset the last label with a draw event handler.
*/
fullWidth?: boolean | string;
/**
* Override the class names that get used to generate the SVG structure of the chart
*/
classNames?: ICandleChartClasses;
}
interface ICandleChartAxis {
/**
* The offset of the chart drawing area to the border of the container
*/
offset?: number;
/**
* Position where labels are placed. Can be set to `start` or `end` where `start` is equivalent to left or top on vertical axis and `end` is equivalent to right or bottom on horizontal axis.
*/
position?: string;
/**
* Allows you to correct label positioning on this axis by positive or negative x and y offset.
*/
labelOffset?: {
x?: number;
y?: number;
};
/**
* If labels should be shown or not
*/
showLabel?: boolean;
/**
* If the axis grid should be drawn or not
*/
showGrid?: boolean;
/**
* Interpolation function that allows you to intercept the value from the axis label
*/
labelInterpolationFnc?: Function;
/**
* Set the axis type to be used to project values on this axis. If not defined, Chartist.StepAxis will be used for the X-Axis, where the ticks option will be set to the labels in the data and the stretch option will be set to the global fullWidth option. This type can be changed to any axis constructor available (e.g. Chartist.FixedScaleAxis), where all axis options should be present here.
*/
type?: any;
}
interface ICandleChartClasses {
chart?: string;
label?: string;
labelGroup?: string;
series?: string;
candlePositive?: string;
candleNegative?: string,
grid?: string,
gridGroup?: string,
gridBackground?: string,
vertical?: string,
horizontal?: string,
start?: string,
end?: string,
}
interface ChartistSvgStatic {
new (name: HTMLElement | string, attributes: Object, className?: string, parent?: Object, insertFirst?: boolean): IChartistSvg;
@@ -682,4 +699,4 @@ declare namespace Chartist {
declare var Chartist: Chartist.ChartistStatic;
export = Chartist;
export as namespace Chartist;
export as namespace Chartist;
+4
View File
@@ -120,6 +120,10 @@ interface ChartScalesOptions {
interface ScaleTicksOptions {
min?: number;
max?: number;
maxTicksLimit?: number;
suggestedMin?: number;
suggestedMax?: number;
stepSize?: number;
}
interface ChartTitle {
+4
View File
@@ -11,6 +11,10 @@ wordArray = CryptoJS.SHA1('some message', 'some key', { any: true });
wordArray = CryptoJS.format.OpenSSL('some message');
wordArray = CryptoJS.format.OpenSSL('some message', 'some key');
var FR = new FileReader();
FR.onloadend = () => {
var hash = CryptoJS.SHA1(CryptoJS.lib.WordArray.create(FR.result)).toString()
}
// Ciphers
var encrypted: CryptoJS.WordArray;
+10 -1
View File
@@ -8,7 +8,7 @@ export as namespace CryptoJS;
declare var CryptoJS: CryptoJS.Hashes;
declare namespace CryptoJS {
type Hash = (message: string, key?: string, ...options: any[]) => WordArray;
type Hash = (message: string | LibWordArray, key?: string, ...options: any[]) => WordArray;
interface Cipher {
encrypt(message: string, secretPassphrase: string, option?: CipherOption): WordArray;
decrypt(encryptedMessage: string | WordArray, secretPassphrase: string, option?: CipherOption): DecryptedMessage;
@@ -25,6 +25,10 @@ declare namespace CryptoJS {
process(messagePart: string): string;
finalize(): string;
}
interface LibWordArray {
sigBytes: number,
words: number[],
}
export interface WordArray {
iv: string;
salt: string;
@@ -97,6 +101,11 @@ declare namespace CryptoJS {
Utf16LE: Encoder;
Base64: Encoder;
};
lib: {
WordArray: {
create: (v: any) => LibWordArray;
};
};
mode: {
CBC: Mode;
CFB: Mode;
+162
View File
@@ -370,6 +370,168 @@ simNodeNumberAccessor = forcePosY.y();
forcePosY.initialize(graph.nodes);
forcePosY(0.1); // alpha
// ForceRadial ==============================================================================
// create ForceRadial force --------------------------------------------------------------
let forceRadial: d3Force.ForceRadial<SimNode>;
// Radius set only
forceRadial = d3Force.forceRadial<SimNode>(50);
forceRadial = d3Force.forceRadial<SimNode>((node, index, nodes) => {
const n: SimNode = node;
const i: number = index;
const ns: SimNode[] = nodes;
return 50 * n.group;
});
// Radius and x-coordinate of center set only
forceRadial = d3Force.forceRadial<SimNode>(50, 10);
forceRadial = d3Force.forceRadial<SimNode>(
50, // radius
(node, index, nodes) => {
const n: SimNode = node;
const i: number = index;
const ns: SimNode[] = nodes;
return 10 * n.group;
} // center-x
);
// Radius and center set
forceRadial = d3Force.forceRadial<SimNode>(50, 10, 10);
forceRadial = d3Force.forceRadial<SimNode>(
50, // radius
10, // center-x
(node, index, nodes) => {
const n: SimNode = node;
const i: number = index;
const ns: SimNode[] = nodes;
return 10 * n.group;
} // center-y
);
forceRadial = d3Force.forceRadial<SimNode>(
(node, index, nodes) => {
const n: SimNode = node;
const i: number = index;
const ns: SimNode[] = nodes;
return 50 * n.group;
}, // radius
(node, index, nodes) => {
const n: SimNode = node;
const i: number = index;
const ns: SimNode[] = nodes;
return 10 * n.group;
}, // center-x
(node, index, nodes) => {
const n: SimNode = node;
const i: number = index;
const ns: SimNode[] = nodes;
return 10 * n.group;
} // center-y
);
// Configure ForceRadial force -----------------------------------------------------------
// strength
forceRadial = forceRadial.strength(0.2);
forceRadial = forceRadial.strength((node, index, nodes) => {
const n: SimNode = node;
const i: number = index;
const ns: SimNode[] = nodes;
return 0.1 * n.group;
});
simNodeNumberAccessor = forceRadial.strength();
// radius
forceRadial = forceRadial.radius(100);
forceRadial = forceRadial.radius((node, index, nodes) => {
const n: SimNode = node;
const i: number = index;
const ns: SimNode[] = nodes;
let target: number;
switch (n.group) {
case 1:
target = 100;
break;
case 2:
target = 200;
break;
case 3:
target = 300;
break;
default:
target = 0;
break;
}
return target;
});
simNodeNumberAccessor = forceRadial.radius();
// x
forceRadial = forceRadial.x(100);
forceRadial = forceRadial.x((node, index, nodes) => {
const n: SimNode = node;
const i: number = index;
const ns: SimNode[] = nodes;
let target: number;
switch (n.group) {
case 1:
target = 100;
break;
case 2:
target = 200;
break;
case 3:
target = 300;
break;
default:
target = 0;
break;
}
return target;
});
simNodeNumberAccessor = forceRadial.x();
// y
forceRadial = forceRadial.y(100);
forceRadial = forceRadial.y((node, index, nodes) => {
const n: SimNode = node;
const i: number = index;
const ns: SimNode[] = nodes;
let target: number;
switch (n.group) {
case 1:
target = 100;
break;
case 2:
target = 200;
break;
case 3:
target = 300;
break;
default:
target = 0;
break;
}
return target;
});
simNodeNumberAccessor = forceRadial.y();
// Use ForceRadial force -----------------------------------------------------------------
forceRadial.initialize(graph.nodes);
forceRadial(0.1); // alpha
// -------------------------------------------------------------------------------------
// Test Force Simulation
// -------------------------------------------------------------------------------------
+173 -5
View File
@@ -1,9 +1,9 @@
// Type definitions for D3JS d3-force module 1.0
// Type definitions for D3JS d3-force module 1.1
// Project: https://github.com/d3/d3-force/
// Definitions by: Tom Wanzek <https://github.com/tomwanzek>, Alex Ford <https://github.com/gustavderdrache>, Boris Yankov <https://github.com/borisyankov>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// Last module patch version validated against: 1.0.4
// Last module patch version validated against: 1.1.0
// -----------------------------------------------------------------------
// Force Simulation
@@ -66,14 +66,18 @@ export interface SimulationNodeDatum {
export interface SimulationLinkDatum<NodeDatum extends SimulationNodeDatum> {
/**
* Link’s source node.
* For convenience, a link’s source property may be initialized using numeric or string identifiers rather than object references; see link.id.
* For convenience, a link’s source and target properties may be initialized using numeric or string identifiers rather than object references; see link.id.
* When the link force is initialized (or re-initialized, as when the nodes or links change), any link.source or link.target property which is not an object
* is replaced by an object reference to the corresponding node with the given identifier.
* After initialization, the source property represents the source node object.
*/
source: NodeDatum | string | number;
/**
* Link’s source link
* For convenience, a link’s target property may be initialized using numeric or string identifiers rather than object references; see link.id.
* After initialization, the target property represents the source node object.
* For convenience, a link’s source and target properties may be initialized using numeric or string identifiers rather than object references; see link.id.
* When the link force is initialized (or re-initialized, as when the nodes or links change), any link.source or link.target property which is not an object
* is replaced by an object reference to the corresponding node with the given identifier.
* After initialization, the target property represents the target node object.
*/
target: NodeDatum | string | number;
/**
@@ -565,6 +569,8 @@ export interface ForceLink<NodeDatum extends SimulationNodeDatum, LinkDatum exte
* * index - the zero-based index into links, assigned by this method
*
* For convenience, a link’s source and target properties may be initialized using numeric or string identifiers rather than object references; see link.id.
* When the link force is initialized (or re-initialized, as when the nodes or links change), any link.source or link.target property which is not an object
* is replaced by an object reference to the corresponding node with the given identifier.
* If the specified array of links is modified, such as when links are added to or removed from the simulation,
* this method must be called again with the new (or changed) array to notify the force of the change;
* the force does not make a defensive copy of the specified array.
@@ -1072,3 +1078,165 @@ export function forceY<NodeDatum extends SimulationNodeDatum>(y: number): ForceY
* The function returns the y-coordinate.
*/
export function forceY<NodeDatum extends SimulationNodeDatum>(y: (d: NodeDatum, i: number, data: NodeDatum[]) => number): ForceY<NodeDatum>;
/**
* The radial force is similar to the x- and y-positioning forces, except it pushes nodes towards the closest point on a given circle.
* The circle is of the specified radius centered at ⟨x,y⟩. If x and y are not specified, they default to ⟨0,0⟩.
* The strength of the force is proportional to the one-dimensional distance between the node’s position and the target position.
* While this force can be used to position individual nodes, it is intended primarily for global forces that apply to all (or most) nodes.
*
* The generic refers to the type of data for a node.
*/
export interface ForceRadial<NodeDatum extends SimulationNodeDatum> extends Force<NodeDatum, any> {
/**
* Assign the array of nodes to this force. This method is called when a force is bound to a simulation via simulation.force
* and when the simulation’s nodes change via simulation.nodes.
*
* A force may perform necessary work during initialization, such as evaluating per-node parameters, to avoid repeatedly performing work during each application of the force.
*/
initialize(nodes: NodeDatum[]): void;
/**
* Returns the current strength accessor, which defaults to a constant strength for all nodes of 0.1.
*/
strength(): (d: NodeDatum, i: number, data: NodeDatum[]) => number;
/**
* Set the strength accessor to the specified constant strength for all nodes, re-evaluates the strength accessor for each node, and returns this force.
*
* The strength determines how much to increment the node’s x-velocity: (x - node.x) × strength.
*
* For example, a value of 0.1 indicates that the node should move a tenth of the way from its current x-position to the target x-position with each application.
* Higher values moves nodes more quickly to the target position, often at the expense of other forces or constraints.
*
* A value outside the range [0,1] is not recommended.
*
* The constant is internally wrapped into a strength accessor function.
*
* The strength accessor is invoked for each node in the simulation, being passed the node, its zero-based index and the complete array of nodes.
* The resulting number is then stored internally, such that the strength of each node is only recomputed when the force is initialized or
* when this method is called with a new strength, and not on every application of the force.
*
* @param strength Constant value of strength to be used for all nodes.
*/
strength(strength: number): this;
/**
* Set the strength accessor to the specified function, re-evaluates the strength accessor for each node, and returns this force.
*
* The strength determines how much to increment the node’s x-velocity: (x - node.x) × strength.
*
* For example, a value of 0.1 indicates that the node should move a tenth of the way from its current x-position to the target x-position with each application.
* Higher values moves nodes more quickly to the target position, often at the expense of other forces or constraints.
*
* A value outside the range [0,1] is not recommended.
*
* The strength accessor is invoked for each node in the simulation, being passed the node, its zero-based index and the complete array of nodes.
* The resulting number is then stored internally, such that the strength of each node is only recomputed when the force is initialized or
* when this method is called with a new strength, and not on every application of the force.
*
* @param strength A strength accessor function which is invoked for each node in the simulation, being passed the node, its zero-based index and the complete array of nodes.
* The function returns the strength.
*/
strength(strength: (d: NodeDatum, i: number, data: NodeDatum[]) => number): this;
/**
* Return the current radius accessor for the circle.
*/
radius(): (d: NodeDatum, i: number, data: NodeDatum[]) => number;
/**
* Set the radius accessor for the circle to the specified number, re-evaluates the radius accessor for each node,
* and returns this force.
*
* The constant is internally wrapped into a radius accessor function.
*
* The radius accessor is invoked for each node in the simulation, being passed the node, its zero-based index and the complete array of nodes.
* The resulting number is then stored internally, such that radius of the circle for each node is only recomputed when the force is initialized or
* when this method is called with a new radius, and not on every application of the force.
*
* @param radius Constant radius of the circle to be used for all nodes.
*/
radius(radius: number): this;
/**
* Set the radius accessor for the circle to the specified function, re-evaluates the radius accessor for each node,
* and returns this force.
*
* The radius accessor is invoked for each node in the simulation, being passed the node, its zero-based index and the complete array of nodes.
* The resulting number is then stored internally, such that radius of the circle for each node is only recomputed when the force is initialized or
* when this method is called with a new radius, and not on every application of the force.
*
* @param radius A radius accessor function for the circle which is invoked for each node in the simulation, being passed the node, its zero-based index and the complete array of nodes.
* The function returns the radius of the circle.
*/
radius(radius: (d: NodeDatum, i: number, data: NodeDatum[]) => number): this;
/**
* Return the current x-accessor for the circle center, which defaults to a function returning 0 for all nodes.
*/
x(): (d: NodeDatum, i: number, data: NodeDatum[]) => number;
/**
* Set the x-coordinate accessor for the circle center to the specified number, re-evaluates the x-accessor for each node,
* and returns this force.
*
* The constant is internally wrapped into an x-coordinate accessor function.
*
* The x-accessor is invoked for each node in the simulation, being passed the node, its zero-based index and the complete array of nodes.
* The resulting number is then stored internally, such that the x-coordinate of the circle center for each node is only recomputed when the force is initialized or
* when this method is called with a new x, and not on every application of the force.
*
* @param x Constant x-coordinate of the circle center to be used for all nodes.
*/
x(x: number): this;
/**
* Set the x-coordinate accessor to the specified function, re-evaluates the x-accessor for each node,
* and returns this force.
*
* The x-accessor is invoked for each node in the simulation, being passed the node, its zero-based index and the complete array of nodes.
* The resulting number is then stored internally, such that the x-coordinate of the circle center for each node is only recomputed when the force is initialized or
* when this method is called with a new x, and not on every application of the force.
*
* @param x A x-coordinate accessor function for the circle center which is invoked for each node in the simulation, being passed the node, its zero-based index and the complete array of nodes.
* The function returns the x-coordinate of the circle center.
*/
x(x: (d: NodeDatum, i: number, data: NodeDatum[]) => number): this;
/**
* Return the current y-accessor for the circle center, which defaults to a function returning 0 for all nodes.
*/
y(): (d: NodeDatum, i: number, data: NodeDatum[]) => number;
/**
* Set the y-coordinate accessor for the circle center to the specified number, re-evaluates the y-accessor for each node,
* and returns this force.
*
* The constant is internally wrapped into an y-coordinate accessor function.
*
* The y-accessor is invoked for each node in the simulation, being passed the node, its zero-based index and the complete array of nodes.
* The resulting number is then stored internally, such that the y-coordinate of the circle center for each node is only recomputed when the force is initialized or
* when this method is called with a new y, and not on every application of the force.
*
* @param y Constant y-coordinate of the circle center to be used for all nodes.
*/
y(y: number): this;
/**
* Set the y-coordinate accessor to the specified function, re-evaluates the y-accessor for each node,
* and returns this force.
*
* The y-accessor is invoked for each node in the simulation, being passed the node, its zero-based index and the complete array of nodes.
* The resulting number is then stored internally, such that the y-coordinate of the circle center for each node is only recomputed when the force is initialized or
* when this method is called with a new y, and not on every application of the force.
*
* @param y A y-coordinate accessor function for the circle center which is invoked for each node in the simulation, being passed the node, its zero-based index and the complete array of nodes.
* The function returns the y-coordinate of the circle center.
*/
y(y: (d: NodeDatum, i: number, data: NodeDatum[]) => number): this;
}
/**
* Create a new radial positioning force towards a circle of the specified radius centered at ⟨x,y⟩.
* If x and y are not specified, they default to ⟨0,0⟩.
*
* The strength of the force is proportional to the one-dimensional distance between the node’s position and the target position.
* While this force can be used to position individual nodes, it is intended primarily for global forces that apply to all (or most) nodes.
*
* The generic refers to the type of data for a node.
*/
export function forceRadial<NodeDatum extends SimulationNodeDatum>(radius: number | ((d: NodeDatum, i: number, data: NodeDatum[]) => number),
x?: number | ((d: NodeDatum, i: number, data: NodeDatum[]) => number), y?: number | ((d: NodeDatum, i: number, data: NodeDatum[]) => number)): ForceRadial<NodeDatum>;
+3
View File
@@ -4,6 +4,7 @@
// Nicolas Laplante <https://github.com/nlaplante>
// ByeongHun Yoo <https://github.com/isac322>
// Ray Fang <https://github.com/lazarusx>
// Marius Meisenzahl <https://github.com/meisenzahl>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
@@ -444,6 +445,7 @@ declare namespace Dockerode {
}
interface HostConfig {
AutoRemove: boolean;
Binds: string[];
ContainerIDFile: string;
LogConfig: {
@@ -593,6 +595,7 @@ declare namespace Dockerode {
ExposedPorts?: { [port: string]: {} };
StopSignal?: string;
HostConfig?: {
AutoRemove?: boolean;
Binds?: string[];
Links?: string[];
Memory?: number;
@@ -0,0 +1,3 @@
import dtsGenerator = require('dts-generator');
dtsGenerator({name: 'foo', out: 'bar'});
+86
View File
@@ -0,0 +1,86 @@
// Type definitions for dts-generator 2.1
// Project: https://github.com/SitePen/dts-generator#readme
// Definitions by: Matt Traynham <https://github.com/mtraynham>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
import ts = require('typescript');
import Bluebird = require('bluebird');
export = dtsGenerator;
declare function dtsGenerator(options: dtsGenerator.DtsGeneratorOptions): Bluebird<void>;
declare namespace dtsGenerator {
interface ResolveModuleIdParams {
/** The identifier of the module being declared in the generated d.ts */
currentModuleId: string;
}
interface ResolveModuleImportParams {
/** The identifier of the module currently being imported in the generated d.ts */
importedModuleId: string;
/** The identifier of the enclosing module currently being declared in the generated d.ts */
currentModuleId: string;
/** True if the imported module id is declared as a module in the input files. */
isDeclaredExternalModule: boolean;
}
interface DtsGeneratorOptions {
/**
* The base directory for the package being bundled. Any dependencies discovered outside this directory will be excluded
* from the bundle.
* Note this is no longer the preferred way to configure dts-generator, please see project.
*/
baseDir?: string;
/**
* A list of glob patterns, relative to baseDir, that should be excluded from the bundle.
* Use the --exclude flag one or more times on the command-line. Defaults to [ "node_modules\/**\/*.d.ts" ].
*/
exclude?: string[];
/**
* A list of external module reference paths that should be inserted as reference comments.
* Use the --extern flag one or more times on the command-line.
*/
externs?: string[];
/**
* A list of external @types package dependencies that should be inserted as reference comments.
* Use the --types flag one or more times on the command-line.
*/
types?: string[];
/** A list of files from the baseDir to bundle. */
files?: string[];
/** The end-of-line character that should be used when outputting code. Defaults to os.EOL. */
eol?: string;
/** The character(s) that should be used to indent the declarations in the output. Defaults to \t. */
indent?: string;
/** The module ID that should be used as the exported value of the package’s “main” module. */
main?: string;
/** The type of module resolution to use when generating the bundle. */
moduleResolution?: ts.ModuleResolutionKind;
/** The name of the package. Used to determine the correct exported package name for modules. */
name: string;
/** The filename where the generated bundle will be created. */
out: string;
/**
* The base directory for the project being bundled. It is assumed that this directory contains a
* tsconfig.json which will be parsed to determine the files that should be bundled as well as
* other configuration information like target
*/
project?: string;
/** The target environment for generated code. Defaults to ts.ScriptTarget.Latest. */
target?: ts.ScriptTarget;
/**
* An optional callback provided by the invoker to customize the declared module ids the output d.ts files.
* @see {@link https://github.com/SitePen/dts-generator/blob/master/docs/resolving-module-ids.md Resolving Module Ids}
*/
resolveModuleId?(params: ResolveModuleIdParams): string;
/**
* An optional callback provided by the invoker to customize the imported module ids in the output d.ts files.
* @see {@link https://github.com/SitePen/dts-generator/blob/master/docs/resolving-module-ids.md Resolving Module Ids}
*/
resolveModuleImport?(params: ResolveModuleImportParams): string;
}
}
+22
View File
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"dts-generator-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
@@ -0,0 +1,24 @@
import webpack = require('webpack');
import DuplicatePackageCheckerWebpackPlugin = require('duplicate-package-checker-webpack-plugin');
const a: webpack.Configuration = {
entry: 'test.js',
plugins: [
new DuplicatePackageCheckerWebpackPlugin()
]
};
const b: webpack.Configuration = {
entry: 'test.js',
plugins: [
new DuplicatePackageCheckerWebpackPlugin({})
]
};
const c: webpack.Configuration = {
entry: 'test.js',
plugins: [
new DuplicatePackageCheckerWebpackPlugin({
verbose: true,
emitError: true
})
]
};
@@ -0,0 +1,21 @@
// Type definitions for duplicate-package-checker-webpack-plugin 1.2
// Project: https://github.com/darrenscerri/duplicate-package-checker-webpack-plugin#readme
// Definitions by: Matt Traynham <https://github.com/mtraynham>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import webpack = require('webpack');
export = DuplicatePackageCheckerWebpackPlugin;
declare class DuplicatePackageCheckerWebpackPlugin extends webpack.Plugin {
constructor(options?: DuplicatePackageCheckerWebpackPlugin.Options);
}
declare namespace DuplicatePackageCheckerWebpackPlugin {
interface Options {
// Also show module that is requiring each duplicate package
verbose?: boolean;
// Emit errors instead of warnings
emitError?: boolean;
}
}
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"duplicate-package-checker-webpack-plugin-tests.ts"
]
}
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+16
View File
@@ -206,6 +206,14 @@ function ShallowWrapperTest() {
reactElements = shallowWrapper.getNodes();
}
function test_getElement() {
reactElement = shallowWrapper.getElement();
}
function test_getElements() {
reactElements = shallowWrapper.getElements();
}
function test_getDOMNode() {
domElement = shallowWrapper.getDOMNode();
}
@@ -545,6 +553,14 @@ function ReactWrapperTest() {
reactElements = reactWrapper.getNodes();
}
function test_getElement() {
reactElement = reactWrapper.getElement();
}
function test_getElements() {
reactElements = reactWrapper.getElements();
}
function test_getDOMNode() {
domElement = reactWrapper.getDOMNode();
}
+10
View File
@@ -148,6 +148,16 @@ export interface CommonWrapper<P = {}, S = {}> {
*/
getNodes(): Array<ReactElement<any>>;
/**
* Returns the wrapper's underlying node.
*/
getElement(): ReactElement<any>;
/**
* Returns the wrapper's underlying node.
*/
getElements(): Array<ReactElement<any>>;
/**
* Returns the outer most DOMComponent of the current wrapper.
*/
+1 -1
View File
@@ -1,3 +1,3 @@
[*.ts]
indent_style = tab
indent_size = 4
indent_size = 2
+22
View File
@@ -0,0 +1,22 @@
## 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) {}
```
+59 -33
View File
@@ -1,57 +1,83 @@
import { Disposable, CompositeDisposable, Emitter } from "event-kit";
// Emitter
declare let bool: boolean;
declare let subscription: EventKit.Disposable;
declare let subscriptions: EventKit.CompositeDisposable;
declare let emitter: EventKit.Emitter;
// NPM Usage Tests ============================================================
class User {
private emitter: Emitter;
private readonly emitter: EventKit.Emitter;
name: string;
constructor() {
this.emitter = new Emitter();
}
onDidChangeName(callback: (name: string) => void): Disposable {
return this.emitter.on('did-change-name', callback);
onDidChangeName(callback: (value: any) => void) {
return this.emitter.on("did-change-name", callback);
}
setName(name: string): void {
if (this.name != name) {
setName(name: string) {
if (name !== this.name) {
this.name = name;
this.emitter.emit('did-change-name', name);
this.emitter.emit("did-change-name", name);
}
return name;
}
destroy(): void {
this.emitter.clear();
destroy() {
this.emitter.dispose();
}
}
// Disposable
var disposable = new Disposable(() => {
// cleanup
});
disposable.dispose();
var user = new User();
var subscription = user.onDidChangeName((name: string) => {
console.log('User name change to: ' + name);
});
if(Disposable.isDisposable(subscription)) {}
const user = new User();
subscription = user.onDidChangeName(name => console.log("My name is #{name}"));
subscription.dispose();
// CompositeDisposable
// Disposable =================================================================
bool = subscription.disposed;
if (subscription.disposalAction) subscription.disposalAction();
subscription.dispose();
// CompositeDisposable ========================================================
// Properties
bool = subscriptions.disposed;
// Construction and Lifecycle
subscriptions = new CompositeDisposable();
new CompositeDisposable(subscription);
new CompositeDisposable(subscription, subscription);
new CompositeDisposable({ dispose() {} });
var subscriptions = new CompositeDisposable();
subscriptions.add(
user.onDidChangeName((name: string) => {
console.log('subscriber #1');
}),
user.onDidChangeName((name: string) => {
console.log('subscriber #2');
})
);
subscriptions.dispose();
// Managing Disposables
subscriptions.add(subscription);
subscriptions.add(
subscription,
{ dispose() {} }
);
subscriptions.remove(subscription);
subscriptions.remove({ dispose() {} });
subscriptions.delete(subscription);
subscriptions.delete({ dispose() {} });
subscriptions.clear();
// Emitter ====================================================================
bool = emitter.disposed;
emitter.clear();
emitter.dispose();
// Event Subscription
subscription = emitter.on("test-event", value => {});
emitter.once("test-event", value => {});
subscription = emitter.preempt("test-event", value => {});
// Event Emission
emitter.emit("test-event");
emitter.emit("test-event", 42);
+120 -85
View File
@@ -1,91 +1,126 @@
// Type definitions for event-kit v1.2.0
// Type definitions for event-kit 2.x
// Project: https://github.com/atom/event-kit
// Definitions by: Vadim Macagon <https://github.com/enlight>
// Definitions by: GlenCFL <https://github.com/GlenCFL>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
export = AtomEventKit;
declare global {
namespace EventKit {
/** The static side to each exported class. Should generally only be used internally. */
namespace Statics {
/* tslint:disable:no-unnecessary-qualifier */
/** The static side to the Disposable class. */
interface Disposable {
/** Ensure that Object correctly implements the Disposable contract. */
isDisposable(object: object): boolean;
declare namespace AtomEventKit {
interface IDisposable {
dispose(): void;
/** Construct a Disposable. */
new (disposableAction?: () => void): EventKit.Disposable;
}
/** The static side to the CompositeDisposable class. */
interface CompositeDisposable {
/** Construct an instance, optionally with one or more disposables. */
new (...disposables: DisposableLike[]): EventKit.CompositeDisposable;
}
/** The static side to the Emitter class. */
interface Emitter {
/** Construct an emitter. */
new (): EventKit.Emitter;
}
/* tslint:enable:no-unnecessary-qualifier */
}
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;
}
/** 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;
}
/** 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. */
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.
*/
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.
*/
preempt(eventName: string, handler: (value: any) => void): Disposable;
// Event Emission
/** Invoke handlers registered via ::on for the given event name. */
emit(eventName: string, value?: any): void;
}
}
/** Static side of the Disposable class. */
interface DisposableStatic {
prototype: Disposable;
new (disposalAction: Function): Disposable;
/**
* Ensure that Object correctly implements the Disposable.
*/
isDisposable(object: Object): boolean;
}
/** Instance side of the Disposable class. */
interface Disposable extends IDisposable {
disposed: boolean;
constructor: DisposableStatic;
}
/** A class that represent a handle to a resource that can be disposed. */
var Disposable: DisposableStatic;
/** Static side of the CompositeDisposable class. */
interface CompositeDisposableStatic {
prototype: CompositeDisposable;
new (...disposables: IDisposable[]): CompositeDisposable;
}
/** Instance side of the CompositeDisposable class. */
interface CompositeDisposable extends IDisposable {
disposed: boolean;
constructor: CompositeDisposableStatic;
add(...disposables: IDisposable[]): void;
remove(disposable: IDisposable): void;
clear(): void;
}
/**
* A class that aggregates multiple [[Disposable]] instances together into a single disposable,
* so that they can all be disposed as a group.
*/
var CompositeDisposable: CompositeDisposableStatic;
/** Static side of the Emitter class. */
interface EmitterStatic {
prototype: Emitter;
new (): Emitter;
}
/** Instance side of the Emitter class. */
interface Emitter {
isDisposed: boolean;
constructor: EmitterStatic;
/**
* Clear out any existing subscribers.
*/
clear(): void;
/**
* Unsubscribe all handlers.
*/
dispose(): void;
/**
* Registers a handler to be invoked whenever the given event is emitted.
* @return An object that will unregister the handler when disposed.
*/
on(eventName: string, handler: (value: any) => void, unshift?: boolean): Disposable;
/**
* Registers a handler to be invoked *before* all previously registered handlers for
* the given event.
* @return An object that will unregister the handler when disposed.
*/
preempt(eventName: string, handler: (value: any) => void): Disposable;
/** Invokes any registered handlers for the given event. */
emit(eventName: string, value: any): void;
}
/** A utility class for implementing event-based APIs. */
var Emitter: EmitterStatic;
}
/** A handle to a resource that can be disposed. */
export const Disposable: EventKit.Statics.Disposable;
/** 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.Statics.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.
*/
export const Emitter: EventKit.Statics.Emitter;
+2 -2
View File
@@ -7,7 +7,7 @@
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
@@ -20,4 +20,4 @@
"index.d.ts",
"event-kit-tests.ts"
]
}
}
+38
View File
@@ -0,0 +1,38 @@
{
"extends": "dtslint/dt.json",
"rules": {
// Custom rules.
"class-name": true,
"indent": [true, "tabs"],
"jsdoc-format": true,
"linebreak-style": [true, "LF"],
"max-line-length": [true, 100],
"no-any": false,
"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-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
}
}
+3
View File
@@ -0,0 +1,3 @@
[*.ts]
indent_style = tab
indent_size = 4
+57
View File
@@ -0,0 +1,57 @@
import { Disposable, CompositeDisposable, Emitter } from "event-kit";
// Emitter
class User {
private emitter: Emitter;
name: string;
constructor() {
this.emitter = new Emitter();
}
onDidChangeName(callback: (name: string) => void): Disposable {
return this.emitter.on('did-change-name', callback);
}
setName(name: string): void {
if (this.name != name) {
this.name = name;
this.emitter.emit('did-change-name', name);
}
}
destroy(): void {
this.emitter.clear();
this.emitter.dispose();
}
}
// Disposable
var disposable = new Disposable(() => {
// cleanup
});
disposable.dispose();
var user = new User();
var subscription = user.onDidChangeName((name: string) => {
console.log('User name change to: ' + name);
});
if(Disposable.isDisposable(subscription)) {}
subscription.dispose();
// CompositeDisposable
var subscriptions = new CompositeDisposable();
subscriptions.add(
user.onDidChangeName((name: string) => {
console.log('subscriber #1');
}),
user.onDidChangeName((name: string) => {
console.log('subscriber #2');
})
);
subscriptions.dispose();
+91
View File
@@ -0,0 +1,91 @@
// Type definitions for event-kit v1.2.0
// Project: https://github.com/atom/event-kit
// Definitions by: Vadim Macagon <https://github.com/enlight>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export = AtomEventKit;
declare namespace AtomEventKit {
interface IDisposable {
dispose(): void;
}
/** Static side of the Disposable class. */
interface DisposableStatic {
prototype: Disposable;
new (disposalAction: Function): Disposable;
/**
* Ensure that Object correctly implements the Disposable.
*/
isDisposable(object: Object): boolean;
}
/** Instance side of the Disposable class. */
interface Disposable extends IDisposable {
disposed: boolean;
constructor: DisposableStatic;
}
/** A class that represent a handle to a resource that can be disposed. */
var Disposable: DisposableStatic;
/** Static side of the CompositeDisposable class. */
interface CompositeDisposableStatic {
prototype: CompositeDisposable;
new (...disposables: IDisposable[]): CompositeDisposable;
}
/** Instance side of the CompositeDisposable class. */
interface CompositeDisposable extends IDisposable {
disposed: boolean;
constructor: CompositeDisposableStatic;
add(...disposables: IDisposable[]): void;
remove(disposable: IDisposable): void;
clear(): void;
}
/**
* A class that aggregates multiple [[Disposable]] instances together into a single disposable,
* so that they can all be disposed as a group.
*/
var CompositeDisposable: CompositeDisposableStatic;
/** Static side of the Emitter class. */
interface EmitterStatic {
prototype: Emitter;
new (): Emitter;
}
/** Instance side of the Emitter class. */
interface Emitter {
isDisposed: boolean;
constructor: EmitterStatic;
/**
* Clear out any existing subscribers.
*/
clear(): void;
/**
* Unsubscribe all handlers.
*/
dispose(): void;
/**
* Registers a handler to be invoked whenever the given event is emitted.
* @return An object that will unregister the handler when disposed.
*/
on(eventName: string, handler: (value: any) => void, unshift?: boolean): Disposable;
/**
* Registers a handler to be invoked *before* all previously registered handlers for
* the given event.
* @return An object that will unregister the handler when disposed.
*/
preempt(eventName: string, handler: (value: any) => void): Disposable;
/** Invokes any registered handlers for the given event. */
emit(eventName: string, value: any): void;
}
/** A utility class for implementing event-based APIs. */
var Emitter: EmitterStatic;
}
+26
View File
@@ -0,0 +1,26 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"baseUrl": "../../",
"typeRoots": [
"../../"
],
"paths": {
"event-kit": [ "event-kit/v1" ]
},
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"event-kit-tests.ts"
]
}
+2 -1
View File
@@ -2,8 +2,9 @@
// Project: https://www.npmjs.com/package/evernote
// Definitions by: Zachary Collins <https://github.com/corps>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
import * as Thrift from 'thrift';
import { Thrift } from 'thrift';
declare namespace Evernote {
interface Callback<T> {
+2 -1
View File
@@ -2,7 +2,8 @@
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
@@ -1,10 +1,7 @@
import { optimize, Configuration, Plugin } from 'webpack'
import * as ExtractTextPlugin from 'extract-text-webpack-plugin'
let configuration: Configuration
import webpack = require('webpack');
import ExtractTextPlugin = require('extract-text-webpack-plugin');
let configuration: webpack.Configuration;
configuration = {
// The standard entry point and output config
@@ -58,7 +55,7 @@ configuration = {
configuration = {
// ...
plugins: [
new optimize.CommonsChunkPlugin({
new webpack.optimize.CommonsChunkPlugin({
name: "commons",
filename: "commons.js",
}),
@@ -85,15 +82,15 @@ configuration = {
};
// multiple extract instances
let extractCSS = new ExtractTextPlugin('stylesheets/[name].css');
let extractLESS = new ExtractTextPlugin('stylesheets/[name].less');
const extractCSS: ExtractTextPlugin = new ExtractTextPlugin('stylesheets/[name].css');
const extractLESS: ExtractTextPlugin = new ExtractTextPlugin('stylesheets/[name].less');
configuration = {
// ...
module: {
rules: [
{ test: /\.scss$/i, use: extractCSS.extract(['css','sass']) },
{ test: /\.less$/i, use: extractLESS.extract(['css','less']) },
{ test: /\.scss$/i, use: extractCSS.extract(['css', 'sass']) },
{ test: /\.less$/i, use: extractLESS.extract(['css', 'less']) },
]
},
plugins: [
+36 -29
View File
@@ -1,49 +1,56 @@
// Type definitions for extract-text-webpack-plugin 2.1.0
// Type definitions for extract-text-webpack-plugin 3.0
// Project: https://github.com/webpack-contrib/extract-text-webpack-plugin
// Definitions by: flying-sheep <https://github.com/flying-sheep>, kayo <https://github.com/katyo>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import { Plugin, OldLoader, NewLoader } from 'webpack'
import webpack = require('webpack');
export = ExtractTextPlugin;
/**
* extract-text-webpack-plugin has no support for .options instead of .query yet.
* See https://github.com/webpack/extract-text-webpack-plugin/issues/281
*/
type Loader = string | OldLoader | NewLoader
interface ExtractPluginOptions {
/** the filename of the result file. May contain `[name]`, `[id]` and `[contenthash]` */
filename: string
/** extract from all additional chunks too (by default it extracts only from the initial chunk(s)) */
allChunks?: boolean
/** disables the plugin */
disable?: boolean
/** Unique ident for this plugin instance. (For advanced usage only, by default automatically generated) */
id?: string
}
interface ExtractOptions {
/** the loader(s) that should be used for converting the resource to a css exporting module */
use: Loader | Loader[]
/** the loader(s) that should be used when the css is not extracted (i.e. in an additional chunk when `allChunks: false`) */
fallback?: Loader | Loader[]
/** override the `publicPath` setting for this loader */
publicPath?: string
}
type Loader = string | webpack.OldLoader | webpack.NewLoader;
/**
* Use an `ExtractTextPlugin` instance and a loader returned by `extract` in concert to write files to disk instead of loading them into others.
* Usage example at https://github.com/webpack/extract-text-webpack-plugin#usage-example-with-css
*/
interface ExtractTextPlugin extends Plugin {
declare class ExtractTextPlugin extends webpack.Plugin {
/** Create a plugin instance defining the extraction target file(s) for the files loaded by `extract` */
new (options: string | ExtractPluginOptions): ExtractTextPlugin
constructor(options: string | ExtractTextPlugin.PluginOptions);
/**
* Creates an extracting loader from an existing loader.
* Creates an extracting loader from an existing loader (static).
* Use the resulting loader in `module.rules`/`module.loaders`.
* @see {@link https://www.npmjs.com/package/extract-text-webpack-plugin#extract}
*/
extract: (loader: Loader | Loader[] | ExtractOptions) => Loader[]
static extract: (loader: Loader | Loader[] | ExtractTextPlugin.LoaderOptions) => Loader[];
/**
* Creates an extracting loader from an existing loader (instance).
* Use the resulting loader in `module.rules`/`module.loaders`.
* @see {@link https://www.npmjs.com/package/extract-text-webpack-plugin#multiple-instances}
*/
extract: (loader: Loader | Loader[] | ExtractTextPlugin.LoaderOptions) => Loader[];
}
declare const extractTextPlugin: ExtractTextPlugin
export = extractTextPlugin
declare namespace ExtractTextPlugin {
interface PluginOptions {
/** the filename of the result file. May contain `[name]`, `[id]` and `[contenthash]` */
filename: string;
/** extract from all additional chunks too (by default it extracts only from the initial chunk(s)) */
allChunks?: boolean;
/** disables the plugin */
disable?: boolean;
/** Unique ident for this plugin instance. (For advanced usage only, by default automatically generated) */
id?: string;
}
interface LoaderOptions {
/** the loader(s) that should be used for converting the resource to a css exporting module */
use: Loader | Loader[];
/** the loader(s) that should be used when the css is not extracted (i.e. in an additional chunk when `allChunks: false`) */
fallback?: Loader | Loader[];
/** override the `publicPath` setting for this loader */
publicPath?: string;
}
}
@@ -19,4 +19,4 @@
"index.d.ts",
"extract-text-webpack-plugin-tests.ts"
]
}
}
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+1 -1
View File
@@ -1,3 +1,3 @@
[*.ts]
indent_style = tab
indent_size = 4
indent_size = 2
+22
View File
@@ -0,0 +1,22 @@
## 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(tokens: FirstMate.Tokens[]) {}
```
+88 -5
View File
@@ -1,10 +1,93 @@
import { GrammarRegistry, Grammar, ScopeSelector } from "first-mate";
declare let subscription: EventKit.Disposable;
declare let grammar: FirstMate.Grammar;
declare let grammars: FirstMate.Grammar[];
import { GrammarRegistry, Grammar, IToken } from "first-mate";
// NPM Examples ===============================================================
const selector = new ScopeSelector("a | b");
selector.matches(["c"]); // # false
selector.matches(["a"]); // # true
var registry = new GrammarRegistry({ maxTokensPerLine: 100 });
var grammar = registry.loadGrammarSync('javascript.json');
var result = grammar.tokenizeLine('var text = "hello world";');
const registry = new GrammarRegistry();
grammar = registry.loadGrammarSync("./spec/fixtures/javascript.json");
const { line, tags } = grammar.tokenizeLine("var offset = 3;");
// Convert compact tags representation into convenient, space-inefficient tokens.
const tokens = registry.decodeTokens(line, tags);
for (const { value, scopes } of tokens) {
console.log(`Token text: '${value}' with scopes: ${scopes}`);
}
// General Usage ==============================================================
let str: string;
new GrammarRegistry({ maxTokensPerLine: 100 });
registry.loadGrammarSync("javascript.json");
const result = grammar.tokenizeLine('var text = "hello world";');
result.tokens.forEach((token) => {
console.log("Token text: '" + token.value + "' with scopes: " + token.scopes);
console.log(`Token text: '${token.value}' with scopes: ${token.scopes}`);
});
new ScopeSelector("source.file");
let prefix = selector.getPrefix("test");
if (prefix) {
str = prefix.charAt(0);
}
prefix = selector.getPrefix(["test", "test"]);
str = selector.toCssSelector();
str = selector.toCssSyntaxSelector();
// Grammar ====================================================================
subscription = grammar.onDidUpdate(() => {});
const tokenizeLinesResult = grammar.tokenizeLines("Test String");
for (const tokenizedLine of tokenizeLinesResult) {
for (const token of tokenizedLine) {
token.scopes;
token.value;
}
}
grammar.tokenizeLine("Test String");
const tokenizeLineResult = grammar.tokenizeLine("Test String", null, false);
tokenizeLineResult.line;
tokenizeLineResult.tags;
tokenizeLineResult.tokens;
grammar.tokenizeLine("Test String", tokenizeLineResult.ruleStack);
grammar.tokenizeLine("Test String", tokenizeLineResult.ruleStack, false);
// Grammar Registry ===========================================================
// Event Subscription
subscription = registry.onDidAddGrammar(grammar => grammar.name);
subscription = registry.onDidUpdateGrammar(grammar => grammar.name);
// Managing Grammars
grammars = registry.getGrammars();
let potentialGrammar = registry.grammarForScopeName("scope.test");
if (potentialGrammar) grammar = potentialGrammar;
subscription = registry.addGrammar(grammar);
potentialGrammar = registry.removeGrammarForScopeName("scope.test");
grammar = registry.readGrammarSync("/test/path");
registry.readGrammar("/test/path", (error, grammar) => {
if (grammar) {
grammar.name;
} else {
if (error) error.name;
}
});
grammar = registry.loadGrammarSync("/test/path");
registry.loadGrammar("/test/path", (error, grammar) => {
if (grammar) {
grammar.name;
} else {
if (error) error.name;
}
});
+247 -96
View File
@@ -1,107 +1,258 @@
// Type definitions for first-mate v4.1.7
// Type definitions for first-mate 7.x
// Project: https://github.com/atom/first-mate/
// Definitions by: Vadim Macagon <https://github.com/enlight>
// Definitions by: GlenCFL <https://github.com/GlenCFL>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
/// <reference types="event-kit" />
import * as AtomEventKit from "event-kit";
export = AtomFirstMate;
declare global {
/** TextMate helpers. */
namespace FirstMate {
/** Objects that appear as parameters to functions. */
namespace Options {
interface Grammar {
name?: string;
fileTypes?: ReadonlyArray<string>;
scopeName?: string;
foldingStopMarker?: string;
maxTokensPerLine?: number;
maxLineLength?: number;
declare namespace AtomFirstMate {
type Disposable = AtomEventKit.Disposable;
injections?: any;
injectionSelector?: any;
patterns?: ReadonlyArray<object>;
repository?: object;
firstLineMatch?: any;
}
}
interface IToken {
value: string;
scopes: string[];
/** The static side to each exported class. Should generally only be used internally. */
namespace Statics {
/* tslint:disable:no-unnecessary-qualifier */
/** The static side to the Grammar class. */
interface Grammar {
new (registry: FirstMate.GrammarRegistry, options?: FirstMate.Options.Grammar):
FirstMate.Grammar;
}
/** The static side to the GrammarRegistry class. */
interface GrammarRegistry {
new (options?: { maxTokensPerLine?: number, maxLineLength?: number }):
FirstMate.GrammarRegistry;
}
/** The static side to the ScopeSelector class. */
interface ScopeSelector {
/** Create a new scope selector.
* @param source The string to parse as a scope selector.
* @return A newly constructed ScopeSelector.
*/
new (source: string): FirstMate.ScopeSelector;
}
/* tslint:enable:no-unnecessary-qualifier */
}
/** Data structures that are used within classes. */
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;
}
/** 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[];
}
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;
}
}
}
/** Result returned by `Grammar.tokenizeLine`. */
interface TokenizeLineResult {
/** Text that was tokenized. */
line: string;
tags: any[];
/**
* This is a dynamic property that will only be available if `Grammar.tokenizeLine` was called
* with `compatibilityMode` set to `true` (the default).
*/
tokens?: IToken[];
/**
* The tokenized state at the end of the line. This should be passed back into `tokenizeLine`
* when tokenizing the next line in the file/buffer.
*/
ruleStack: Rule[]
}
/** Registry containing one or more grammars. */
export const GrammarRegistry: FirstMate.Statics.GrammarRegistry;
/** Instance side of Rule class. */
interface Rule {
}
export const ScopeSelector: FirstMate.Statics.ScopeSelector;
/** Static side of Grammar class. */
interface GrammarStatic {
prototype: Grammar;
new (registry: GrammarRegistry, options?: any): Grammar;
}
/** Instance side of Grammar class. */
interface Grammar {
constructor: GrammarStatic;
onDidUpdate(callback: Function): Disposable;
/**
* Tokenizes all lines in a string.
*
* @param text A string containing one or more lines.
* @return An array of token arrays, one token array per line.
*/
tokenizeLines(text: string): Array<Array<IToken>>;
/**
* Tokenizes a line of text.
*
* @param line Text to be tokenized.
* @param firstLine Indicates whether `line` is the first line in the file/buffer,
* defaults to `false`.
* @param compatibilityMode `true` by default.
* @return An object containing tokens for the given line.
*/
tokenizeLine(
line: string, ruleStack?: Rule[], firstLine?: boolean, compatibilityMode?: boolean
): TokenizeLineResult;
}
/** Grammar that tokenizes lines of text. */
var Grammar: GrammarStatic;
/** Static side of GrammarRegistry class. */
interface GrammarRegistryStatic {
prototype: GrammarRegistry;
new (options?: { maxTokensPerLine: number }): GrammarRegistry;
}
/** Instance side of GrammarRegistry class. */
interface GrammarRegistry {
constructor: GrammarRegistryStatic;
// Event Subscription
onDidAddGrammar(callback: (grammar: Grammar) => void): Disposable;
onDidUpdateGrammar(callback: (grammar: Grammar) => void): Disposable;
// Managing Grammars
getGrammars(): Grammar[];
grammarForScopeName(scopeName: string): Grammar;
addGrammar(grammar: Grammar): Disposable;
removeGrammarForScopeName(scopeName: string): Grammar;
readGrammarSync(grammarPath: string): Grammar;
readGrammar(grammarPath: string, callback: (error: Error, grammar: Grammar) => void): void;
loadGrammarSync(grammarPath: string): Grammar;
loadGrammar(grammarPath: string, callback: (error: Error, grammar: Grammar) => void): void;
grammarOverrideForPath(filePath: string): Grammar;
setGrammarOverrideForPath(filePath: string, scopeName: string): Grammar;
clearGrammarOverrides(): void;
selectGrammar(filePath: string, fileContents: string): Grammar;
}
/** Registry containing one or more grammars. */
var GrammarRegistry: GrammarRegistryStatic;
}
/** Grammar that tokenizes lines of text. */
export const Grammar: FirstMate.Statics.Grammar;
+2 -2
View File
@@ -7,7 +7,7 @@
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
@@ -20,4 +20,4 @@
"index.d.ts",
"first-mate-tests.ts"
]
}
}
+39
View File
@@ -0,0 +1,39 @@
{
"extends": "dtslint/dt.json",
"rules": {
// Custom rules.
"class-name": true,
"indent": [true, "tabs"],
"jsdoc-format": true,
"linebreak-style": [true, "LF"],
"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"
],
// TODO
"no-any": false,
// Soon to be defaults.
"arrow-return-shorthand": [true, "multiline"],
"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
}
}
+3
View File
@@ -0,0 +1,3 @@
[*.ts]
indent_style = tab
indent_size = 4
+10
View File
@@ -0,0 +1,10 @@
import { GrammarRegistry, Grammar, IToken } from "first-mate";
var registry = new GrammarRegistry({ maxTokensPerLine: 100 });
var grammar = registry.loadGrammarSync('javascript.json');
var result = grammar.tokenizeLine('var text = "hello world";');
result.tokens.forEach((token) => {
console.log("Token text: '" + token.value + "' with scopes: " + token.scopes);
});
+105
View File
@@ -0,0 +1,105 @@
// Type definitions for first-mate v4.1.7
// Project: https://github.com/atom/first-mate/
// Definitions by: Vadim Macagon <https://github.com/enlight>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import * as AtomEventKit from "event-kit";
export = AtomFirstMate;
declare namespace AtomFirstMate {
type Disposable = AtomEventKit.Disposable;
interface IToken {
value: string;
scopes: string[];
}
/** Result returned by `Grammar.tokenizeLine`. */
interface TokenizeLineResult {
/** Text that was tokenized. */
line: string;
tags: any[];
/**
* This is a dynamic property that will only be available if `Grammar.tokenizeLine` was called
* with `compatibilityMode` set to `true` (the default).
*/
tokens?: IToken[];
/**
* The tokenized state at the end of the line. This should be passed back into `tokenizeLine`
* when tokenizing the next line in the file/buffer.
*/
ruleStack: Rule[]
}
/** Instance side of Rule class. */
interface Rule {
}
/** Static side of Grammar class. */
interface GrammarStatic {
prototype: Grammar;
new (registry: GrammarRegistry, options?: any): Grammar;
}
/** Instance side of Grammar class. */
interface Grammar {
constructor: GrammarStatic;
onDidUpdate(callback: Function): Disposable;
/**
* Tokenizes all lines in a string.
*
* @param text A string containing one or more lines.
* @return An array of token arrays, one token array per line.
*/
tokenizeLines(text: string): Array<Array<IToken>>;
/**
* Tokenizes a line of text.
*
* @param line Text to be tokenized.
* @param firstLine Indicates whether `line` is the first line in the file/buffer,
* defaults to `false`.
* @param compatibilityMode `true` by default.
* @return An object containing tokens for the given line.
*/
tokenizeLine(
line: string, ruleStack?: Rule[], firstLine?: boolean, compatibilityMode?: boolean
): TokenizeLineResult;
}
/** Grammar that tokenizes lines of text. */
var Grammar: GrammarStatic;
/** Static side of GrammarRegistry class. */
interface GrammarRegistryStatic {
prototype: GrammarRegistry;
new (options?: { maxTokensPerLine: number }): GrammarRegistry;
}
/** Instance side of GrammarRegistry class. */
interface GrammarRegistry {
constructor: GrammarRegistryStatic;
// Event Subscription
onDidAddGrammar(callback: (grammar: Grammar) => void): Disposable;
onDidUpdateGrammar(callback: (grammar: Grammar) => void): Disposable;
// Managing Grammars
getGrammars(): Grammar[];
grammarForScopeName(scopeName: string): Grammar;
addGrammar(grammar: Grammar): Disposable;
removeGrammarForScopeName(scopeName: string): Grammar;
readGrammarSync(grammarPath: string): Grammar;
readGrammar(grammarPath: string, callback: (error: Error, grammar: Grammar) => void): void;
loadGrammarSync(grammarPath: string): Grammar;
loadGrammar(grammarPath: string, callback: (error: Error, grammar: Grammar) => void): void;
grammarOverrideForPath(filePath: string): Grammar;
setGrammarOverrideForPath(filePath: string, scopeName: string): Grammar;
clearGrammarOverrides(): void;
selectGrammar(filePath: string, fileContents: string): Grammar;
}
/** Registry containing one or more grammars. */
var GrammarRegistry: GrammarRegistryStatic;
}
+27
View File
@@ -0,0 +1,27 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"baseUrl": "../../",
"typeRoots": [
"../../"
],
"paths": {
"event-kit": [ "event-kit/v1" ],
"first-mate": [ "first-mate/v4" ]
},
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"first-mate-tests.ts"
]
}
+9 -1
View File
@@ -1621,7 +1621,7 @@ interface GoogleApiYouTubePlaylistResource {
/**
* A map of thumbnail images associated with the playlist. For each object in the map, the key is the name of the thumbnail image, and the value is an object that contains other information about the thumbnail.
*/
thumbnails: GoogleApiYouTubeThumbnailItemResource[];
thumbnails: GoogleApiYouTubeThumbnailResource;
/**
* The channel title of the channel that the video belongs to.
*/
@@ -1813,6 +1813,14 @@ interface GoogleApiYouTubeThumbnailResource {
* A high resolution version of the thumbnail image. For a video (or a resource that refers to a video), this image is 480px wide and 360px tall. For a channel, this image is 800px wide and 800px tall.
*/
high: GoogleApiYouTubeThumbnailItemResource;
/**
* A standard resolution version of the thumbnail image. For a video (or a resource that refers to a video), this image is 480px wide and 360px tall. For a channel, this image is 800px wide and 800px tall.
*/
standard?: GoogleApiYouTubeThumbnailItemResource;
/**
* A very high resolution version of the thumbnail image. For a video (or a resource that refers to a video), this image is 480px wide and 360px tall. For a channel, this image is 800px wide and 800px tall.
*/
maxres?: GoogleApiYouTubeThumbnailItemResource;
}
interface GoogleApiYouTubeThumbnailItemResource {
+2 -2
View File
@@ -1591,10 +1591,10 @@ declare namespace google.maps {
avoidFerries?: boolean;
avoidHighways?: boolean;
avoidTolls?: boolean;
destinations?: string[]|LatLng[]|Place[];
destinations?: string[]|LatLng[]|LatLngLiteral[]|Place[];
drivingOptions?: DrivingOptions;
durationInTraffic?: boolean;
origins?: string[]|LatLng[]|Place[];
origins?: string[]|LatLng[]|LatLngLiteral[]|Place[];
region?: string;
transitOptions?: TransitOptions;
travelMode?: TravelMode;
+1 -1
View File
@@ -4221,7 +4221,7 @@ declare namespace Highcharts {
* @default true
* @since 4.1.9
*/
softTreshold?: boolean;
softThreshold?: boolean;
/**
* Whether to stack the values of each series on top of each other. Possible values are null to disable, 'normal' to
* stack by value or 'percent'.
+3 -3
View File
@@ -1,8 +1,8 @@
{
"extends": "dtslint/dt.json",
"rules": {
"interface-name": [
false
]
// TODOs
"interface-name": false,
"no-any-union": false
}
}
+6 -6
View File
@@ -4,7 +4,7 @@
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
interface ConnStr {
export interface ConnStr {
DATABASE: string;
HOSTNAME: string;
PORT: number | string;
@@ -13,7 +13,7 @@ interface ConnStr {
PWD: string;
}
interface Options {
export interface Options {
odbc?: ODBC;
queue?: SimpleQueue | any[];
fetchMode?: number | null;
@@ -22,7 +22,7 @@ interface Options {
systemNaming?: boolean;
}
interface DescribeObject {
export interface DescribeObject {
database: string;
schema?: string;
type?: string;
@@ -30,7 +30,7 @@ interface DescribeObject {
column?: string;
}
interface PoolOptions {
export interface PoolOptions {
idleTimeout?: number;
autoCleanIdle?: boolean;
maxPoolSize?: number;
@@ -38,7 +38,7 @@ interface PoolOptions {
systemNaming?: any;
}
declare class SimpleQueue {
export class SimpleQueue {
fifo: any[];
executing: boolean;
push(fn: (foo: any, bar: any) => void): void;
@@ -46,7 +46,7 @@ declare class SimpleQueue {
next(): void;
} // Class SimpleQueue
export default (options?: Options) => new Database(options);
export default function(options?: Options): Database;
export class Database implements Options {
odbc: ODBC;
+57
View File
@@ -0,0 +1,57 @@
// Type definitions for Intercom Web API 2.8
// Project: https://docs.intercom.io/
// configure-intercom-for-your-product-or-site/
// customize-the-intercom-messenger/the-intercom-javascript-api
// Definitions by: Andrew Fong <https://github.com/fongandrew>
// Samer Albahra <https://github.com/salbahra>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare namespace Intercom_ {
interface IntercomSettings {
app_id?: string;
email?: string;
created_at?: number;
name?: string;
user_id?: string;
user_hash?: string;
widget?: {
activator?: string;
};
company?: {
id: string|number,
name: string,
created_at: number,
plan?: string,
monthly_spend?: number,
[index: string]: any;
};
}
type IntercomCommand = 'boot'
|'shutdown'
|'update'
|'hide'
|'show'
|'showMessages'
|'showNewMessage'
|'onHide'
|'onShow'
|'onActivatorClick'
|'trackEvent';
interface IntercomStatic {
(command: 'boot', param: IntercomSettings): void;
(command: 'shutdown' | 'hide' | 'show' | 'showMessages'): void;
(command: 'update', param?: IntercomSettings): void;
(command: 'showNewMessage', param?: string): void;
(command: 'onHide' | 'onShow' | 'onActivatorClick', param?: () => void): void;
(command: 'trackEvent', tag?: string, metadata?: any): void;
(command: IntercomCommand, param1?: any, param2?: any): void;
}
}
declare var Intercom: Intercom_.IntercomStatic;
declare var intercomSettings: Intercom_.IntercomSettings;
interface Window {
intercomSettings: Intercom_.IntercomSettings;
}
+62
View File
@@ -0,0 +1,62 @@
/*
From https://docs.intercom.io/configure-intercom-for-your-product-or-site/
customize-the-intercom-messenger/the-intercom-javascript-api
*/
intercomSettings = {
email: "example@example.com",
name: "John Doe",
user_id: "123",
created_at: 1234567890,
app_id: "YOUR_APP_ID",
widget: {
activator: "#Intercom"
}
};
Intercom('boot', intercomSettings);
Intercom('shutdown');
Intercom('update');
Intercom('update', intercomSettings);
Intercom('hide');
Intercom('show');
Intercom('showMessages');
Intercom('showNewMessage');
Intercom('showNewMessage', 'pre-populated content');
Intercom('onHide', () => { /* Do stuff */ });
Intercom('onActivatorClick', () => { /* Do stuff */ });
Intercom('trackEvent', 'invited-friend');
const metadata = {
invitee_email: 'pi@example.org',
invite_code: 'ADDAFRIEND'
};
Intercom('trackEvent', 'invited-friend', metadata);
/*
From https://docs.intercom.io/configure-intercom-for-your-product-or-site/
customize-intercom-to-be-about-your-users/
group-your-users-by-company
*/
intercomSettings = {
email: "example@example.com",
created_at: 1457552104,
app_id: "pi3243fa",
company: {
id: '123',
name: 'Intercorp',
created_at: 1234567890,
plan: 'pro',
monthly_spend: 10,
upgraded_at: 1424941688
}
};
/*
From https://docs.intercom.io/configure-intercom-for-your-product-or-site/
staying-secure/enable-secure-mode-on-your-web-product
*/
intercomSettings = {
app_id: "pi3243fa",
user_id: "12345",
user_hash: "775c502lcc1087d12398571837c"
};
+22
View File
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"intercom-web-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+5
View File
@@ -7,6 +7,7 @@
// Alex Jover Morales <https://github.com/alexjoverm>
// Allan Lukwago <https://github.com/epicallan>
// Ika <https://github.com/ikatyang>
// Waseem Dahman <https://github.com/wsmd>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
@@ -327,6 +328,10 @@ declare namespace jest {
* Matches any string that contains the exact provided string
*/
stringMatching(str: string | RegExp): any;
/**
* Matches any received string that contains the exact expected string
*/
stringContaining(str: string): any;
}
interface Matchers<R> {
+6 -2
View File
@@ -199,10 +199,14 @@ describe('Assymetric matchers', () => {
it('works', () => {
expect({
timestamp: 1480807810388,
text: 'Some text content, but we care only about *this part*'
text: 'Some text content, but we care only about *this part*',
color: '#bada55',
greeting: 'hello, world!',
}).toEqual({
timestamp: expect.any(Number),
text: expect.stringMatching('*this part*')
text: expect.stringMatching('*this part*'),
color: expect.stringMatching(/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i),
greeting: expect.stringContaining('hello'),
});
const callback = jest.fn();
+38
View File
@@ -0,0 +1,38 @@
// Type definitions for karma-webpack 2.0
// Project: http://github.com/webpack/karma-webpack
// Definitions by: Matt Traynham <https://github.com/mtraynham>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import * as m from 'karma';
import webpack = require('webpack');
import webpackDevMiddleware = require('webpack-dev-middleware');
declare module 'karma' {
// Note: karma-webpack will set publicPath for us, so it is optional here.
// Unfortuantely, Typescript doesn't let you overload properties, so
// the entire definition is duplicated here.
interface KarmaWebpackMiddlewareOptions /** extends webpackDevMiddleware.Options */ {
noInfo?: boolean;
quiet?: boolean;
lazy?: boolean;
watchOptions?: webpack.Options.WatchOptions;
publicPath?: string;
index?: string;
headers?: {
[name: string]: string;
};
stats?: webpack.Options.Stats;
reporter?: webpackDevMiddleware.Reporter | null;
serverSideRender?: boolean;
log?: webpackDevMiddleware.Logger;
warn?: webpackDevMiddleware.Logger;
error?: webpackDevMiddleware.Logger;
filename?: string;
}
interface ConfigOptions {
webpack: webpack.Configuration;
webpackMiddlewareOptions: KarmaWebpackMiddlewareOptions;
}
}
@@ -0,0 +1,14 @@
import karma = require('karma');
export default function(config: karma.Config): void {
config.set({
files: ['src/index.spec.ts'],
browsers: ['ChromeHeadless'],
singleRun: true,
frameworks: ['jasmine'],
preprocessors: {'src/index.spec.ts': ['webpack', 'sourcemap']},
webpack: {entry: 'test.js'},
webpackMiddlewareOptions: {noInfo: true},
reporters: ['spec']
});
}
+25
View File
@@ -0,0 +1,25 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"paths": {
"q": [ "q/v0" ]
},
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"karma-webpack-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+225
View File
@@ -0,0 +1,225 @@
// Type definitions for LocalizeJS Library 1.0
// Project: https://help.localizejs.com/docs/library-api
// Definitions by: Samer Albahra <https://github.com/salbahra>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare namespace LocalizeJS.Context {
interface Options {
/**
* Required. Your project key.
*/
key: string;
/**
* Language to translate your website to.
*/
targetLanguage: string;
/**
* Defaults to false. If true, Localize will translate your website to the last selected language on subsequent page views.
*/
rememberLanguage: boolean;
/**
* Defaults to true. If true, translations will be fetched from Localize if not bootstrapped.
*/
fetchTranslations: boolean;
/**
* Defaults to true. If true, unrecognized phrases will be added to your Localize account. Disable this in development.
*/
saveNewPhrases: boolean;
/**
* Defaults to true. If true, "alt" attributes will be translated.
*/
translateAlt: boolean;
/**
* Defaults to false. Set to true to prefetch all active languages, or pass a language code or an array of codes to.
*/
prefetch: boolean;
/**
* Array of class names for which Localize will ignore.
*/
blockedClasses: string[];
/**
* Array of class names for which Localize will translate. If you use this option, Localize will only translate content
* contained in these classes and will ignore all other content in the body of the page.
*/
translateClasses: string[];
/**
* Defaults to true. Automatically default the page language to the user's preferred language. The first path segment
* in the URL is used to check to detect the language, ie. www.localize.com/fr. If no language dictionary exists for that
* segment then the language setting in their browser is used.
*/
autodetectLanguage: boolean;
/**
* Defaults to false. When true, Localize will attempt to translate the entire body of the page.
* If false, Localize will only translate content contained with a "localizejs" class name.
*/
translateBody: boolean;
/**
* The default language your website will be in when no language has been selected. Defaults to the source language of your website.
*/
defaultLanguage: string;
/**
* The base path will be stripped from the URL of the phrase as seen in the "Filter by pages" feature.
*/
basePath: string;
/**
* Defaults to true. If true, the <title> of the page will translate.
*/
translateTitle: boolean;
/**
* Defaults to false. Allows users to turn on meta tag translation. This optimizes your site for SEO.
*/
translateMetaTags: boolean;
/**
* Defaults to false. If true, Localize will detect phrases only when the page is not translated.
* Please contact support@localizejs.com prior to updating this option.
*/
saveNewPhrasesFromSource: boolean;
/**
* Defaults to false. Automatically translate content that is added dynamically to your webpage.
* For example, if your webpage dynamically adds html into the source of the page, our library
* will translate it once the translations have been generated. Behind the scenes this means the
* dictionary file with all your translated content is available for use with Localize.translate().
* However, translations are not generated instantly, so use with our library event updatedDictionary is recommended.
*/
retranslateOnNewPhrases: boolean;
/**
* Defaults to false. If true, the Localize library will not send additional metadata to our servers.
* This metadata includes the surrounding HTML of the phrases detected on your website.
*/
enhancedContentSecurity: boolean;
/**
* Defaults to false. If true, the Localize library will pick up phrases in the <time> elements.
*/
translateTimeElement: boolean;
/**
* Defaults to false. If true, the Localize library will pick up numbers as phrases.
*/
translateNumbers: boolean;
}
}
declare var Localize: {
/**
* Initializes LocalizeJS with the supplied options.
* @param options An object containing the supplied options.
*/
initialize(options: LocalizeJS.Context.Options): void;
/**
* Translates the page into the given language.
* @param language Required. Language codes can be found on your Languages page.
*/
setLanguage(language: string): void
/**
* Returns the current language of the page. If a language hasn't been set, source is returned.
*/
getLanguage(): string
/**
* Returns the visitor's list of preferred languages, based on the browser's "accept-language" header.
* @param callback Required.
*/
detectLanguage(callback: () => void): void
/**
* Returns all available languages for the project.
* @param callback Required.
*/
getAvailableLanguages(callback: () => void): void
/**
* Translates text or text within html.
*
* If the Localize.translate() input is a string, instances of %{variable} will be replaced with the given value in the variables object.
* You may also use HTML <var> tags in the string
*
* If the active language is the source language of the page, Localize.translate will return the untranslated phrase.
* Localize.translate can be used with or without a callback. We highly recommend using the callback approach if you're calling
* Localize.translate in the first 10 seconds of page load to ensure that the latest translations are available. The callback will
* allow the translation to delay until translations have been fully loaded into the browser. If the translations are already
* loaded, the callback is executed immediately.
*
* @param input Required. Can be text, html or native DOM elements
* @param variables Optional. Object of variables that will be replaced in the input, if it's a string
* @param callback Optional. Callback will trigger once translations have been fetched from Localize.
*/
translate(input: string, variables?: any, callback?: () => void): void
/**
* Translates all text on the page
*/
translatePage(): void
/**
* Untranslates all text on the page
*/
untranslatePage(): void
/**
* Untranslates a specified element on the page. Use Localize.untranslatePage() if untranslating the whole page.
* @param element Required. A DOM node to untranslate
*/
untranslate(element: string): void
/**
* Bootstrapping translations enables your app to translate without fetching translations remotely from Localizejs.com
* @param translations Required. Generate properly formatted translations on your Languages page
*/
bootstrap(translations: any): void
/**
* Speed up language switching by prefetching
* @param languages Required. Accepts a string or an array or languages (ex. 'zh-CN')
*/
prefetch(languages: string|string[]): void
/**
* Saves the phrase, if unrecognized, to your Localize project. Useful for ensuring rarely printed text
* (ie. an obscure error message) is translated. Returns the phrase it was passed.
* @param phrase Required. A string or an array of strings
*/
phrase(phrase: string|string[]): string|string[]
/**
* Attach an event handler to Localize events.
* @param eventName Required. Name of event to bind to. Can optionally be namespaced: "setLanguage.ns"
* @param fn Required. Event handler.
*/
on(eventName: "initialize" | "setLanguage" | "pluralize" | "translate" | "untranslatePage" | "updatedDictionary", fn: () => void): void
/**
* Remove an event handler.
* @param eventName Required. Name of event to unbind to. Can optionally be namespaced: "setLanguage.ns"
* @param fn Optional. The () => void to unbind from the event.
*/
on(eventName: "initialize" | "setLanguage" | "pluralize" | "translate" | "untranslatePage" | "updatedDictionary", fn?: () => void): void
/**
* Returns exchange rate for provided currencies.
*
* @param fromCurrency Required. The default source currency, to be converted from.
* @param toCurrency Required. The new currency, to be converted to.
* @param callback Required. Receives err and rateData arguments.
*/
getExchangeRate(fromCurrency: string, toCurrency: string, callback: () => void): void
};
@@ -0,0 +1,3 @@
const current = Localize.getLanguage();
Localize.setLanguage(current);
+22
View File
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"localizejs-library-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+3 -2
View File
@@ -3,7 +3,8 @@
// Definitions by: KentarouTakeda <https://github.com/KentarouTakeda>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export = class MersenneTwister {
export = MersenneTwister;
declare class MersenneTwister {
/**
* constructs mt with a number
* @params seed
@@ -44,4 +45,4 @@ export = class MersenneTwister {
* generates a random number on [0,1) with 53-bit resolution
*/
random_long(): number;
};
}
+3 -3
View File
@@ -506,9 +506,9 @@ export interface Collection<TSchema = Default> {
/** @deprecated */
find<T = TSchema>(query: Object, fields?: Object, skip?: number, limit?: number, timeout?: number): Cursor<T>;
//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#findOne
findOne<T = TSchema>(filter: Object, callback: MongoCallback<T>): void;
findOne<T = TSchema>(filter: Object, options?: FindOneOptions): Promise<T>;
findOne<T = TSchema>(filter: Object, options: FindOneOptions, callback: MongoCallback<T>): void;
findOne<T = TSchema>(filter: Object, callback: MongoCallback<T | null>): void;
findOne<T = TSchema>(filter: Object, options?: FindOneOptions): Promise<T | null>;
findOne<T = TSchema>(filter: Object, options: FindOneOptions, callback: MongoCallback<T | null>): void;
//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#findOneAndDelete
findOneAndDelete(filter: Object, callback: MongoCallback<FindAndModifyWriteOpResultObject<TSchema>>): void;
findOneAndDelete(filter: Object, options?: { projection?: Object, sort?: Object, maxTimeMS?: number }): Promise<FindAndModifyWriteOpResultObject<TSchema>>;

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