mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-07 00:07:07 +00:00
Resolve merge conflicts by adding comments and reporter args
Details:
Merge branch 'master' into fix-element-resize-detector-options
Conflicts with 28a8ad8439:
types/element-resize-detector/index.d.ts
This commit is contained in:
+389
-171
File diff suppressed because it is too large
Load Diff
@@ -144,6 +144,12 @@
|
||||
"sourceRepoURL": "https://github.com/Azure/azure-mobile-apps-node/",
|
||||
"asOfVersion": "3.0.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "@babel/parser",
|
||||
"typingsPackageName": "babel__parser",
|
||||
"sourceRepoURL": "https://github.com/babel/babel",
|
||||
"asOfVersion": "7.1.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "BabylonJS",
|
||||
"typingsPackageName": "babylonjs",
|
||||
@@ -540,6 +546,12 @@
|
||||
"sourceRepoURL": "https://github.com/code-chris/extended-listbox",
|
||||
"asOfVersion": "4.0.1"
|
||||
},
|
||||
{
|
||||
"libraryName": "fast-diff",
|
||||
"typingsPackageName": "fast-diff",
|
||||
"sourceRepoURL": "https://github.com/jhchen/fast-diff",
|
||||
"asOfVersion": "1.2.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "JSON-Patch",
|
||||
"typingsPackageName": "fast-json-patch",
|
||||
@@ -942,6 +954,12 @@
|
||||
"sourceRepoURL": "http://maquettejs.org/",
|
||||
"asOfVersion": "2.1.6"
|
||||
},
|
||||
{
|
||||
"libraryName": "maxmind",
|
||||
"typingsPackageName": "maxmind",
|
||||
"sourceRepoURL": "https://github.com/runk/node-maxmind",
|
||||
"asOfVersion": "2.0.5"
|
||||
},
|
||||
{
|
||||
"libraryName": "mendixmodelsdk",
|
||||
"typingsPackageName": "mendixmodelsdk",
|
||||
@@ -978,6 +996,12 @@
|
||||
"sourceRepoURL": "https://github.com/mweststrate/mobservable-react",
|
||||
"asOfVersion": "1.0.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "Mobx Cookie",
|
||||
"typingsPackageName": "mobx-cookie",
|
||||
"sourceRepoURL": "https://github.com/will-stone/mobx-cookie",
|
||||
"asOfVersion": "1.1.1"
|
||||
},
|
||||
{
|
||||
"libraryName": "Moment",
|
||||
"typingsPackageName": "moment",
|
||||
|
||||
Vendored
+2
-2
@@ -64,7 +64,7 @@ declare class Agenda extends EventEmitter {
|
||||
defaultConcurrency(value: number): this;
|
||||
|
||||
/**
|
||||
* Takes a number shich specifies the max number jobs that can be locked at any given moment. By default it is
|
||||
* Takes a number which specifies the max number jobs that can be locked at any given moment. By default it is
|
||||
* 0 for no max.
|
||||
* @param value The value to set.
|
||||
*/
|
||||
@@ -189,7 +189,7 @@ declare namespace Agenda {
|
||||
defaultLockLimit?: number;
|
||||
|
||||
/**
|
||||
* Takes a number shich specifies the max number jobs that can be locked at any given moment. By default it is
|
||||
* Takes a number which specifies the max number jobs that can be locked at any given moment. By default it is
|
||||
* 0 for no max.
|
||||
*/
|
||||
lockLimit?: number;
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
"max-line-length": false,
|
||||
"member-access": false,
|
||||
"new-parens": false,
|
||||
"no-angle-bracket-type-assertion": false,
|
||||
"no-any-union": false,
|
||||
"no-boolean-literal-compare": false,
|
||||
"no-conditional-assignment": false,
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
"max-line-length": false,
|
||||
"member-access": false,
|
||||
"new-parens": false,
|
||||
"no-angle-bracket-type-assertion": false,
|
||||
"no-any-union": false,
|
||||
"no-boolean-literal-compare": false,
|
||||
"no-conditional-assignment": false,
|
||||
|
||||
Vendored
+1
@@ -76,6 +76,7 @@ declare module 'angular' {
|
||||
|
||||
interface IConfirmDialog extends IPresetDialog<IConfirmDialog> {
|
||||
cancel(cancel: string): IConfirmDialog;
|
||||
multiple(multiple: boolean): IConfirmDialog;
|
||||
}
|
||||
|
||||
interface IPromptDialog extends IPresetDialog<IPromptDialog> {
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
"max-line-length": false,
|
||||
"member-access": false,
|
||||
"new-parens": false,
|
||||
"no-angle-bracket-type-assertion": false,
|
||||
"no-any-union": false,
|
||||
"no-boolean-literal-compare": false,
|
||||
"no-conditional-assignment": false,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
angular.module('promise-tracker-tests', []).run(['$q', 'promiseTracker',
|
||||
($q: angular.IQService, promiseTracker: angular.promisetracker.PromiseTrackerService) => {
|
||||
angular.module('promise-tracker-tests', []).run(['$q', '$http', 'promiseTracker',
|
||||
($q: angular.IQService, $http: angular.IHttpService, promiseTracker: angular.promisetracker.PromiseTrackerService) => {
|
||||
const trackerWithoutOptions = promiseTracker();
|
||||
|
||||
const options = {
|
||||
@@ -19,4 +19,8 @@ angular.module('promise-tracker-tests', []).run(['$q', 'promiseTracker',
|
||||
const addedPromise: angular.IDeferred<void> = trackerWithOptions.addPromise(promiseToAdd);
|
||||
|
||||
const trackerWithSomeOptions = promiseTracker({activationDelay: 500});
|
||||
|
||||
$http.post('/foo', {}, { });
|
||||
$http.post('/foo', {}, { tracker: trackerWithOptions });
|
||||
$http.post('/foo', {}, { tracker: [trackerWithoutOptions, trackerWithOptions] });
|
||||
}]);
|
||||
|
||||
+4
@@ -28,4 +28,8 @@ declare module 'angular' {
|
||||
(options?: PromiseTrackerOptions): PromiseTracker;
|
||||
}
|
||||
}
|
||||
|
||||
interface IRequestShortcutConfig {
|
||||
tracker?: angular.promisetracker.PromiseTracker | angular.promisetracker.PromiseTracker[];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,10 @@ angular
|
||||
closeButton: false,
|
||||
closeHtml: '<button>×</button>',
|
||||
extendedTimeOut: 1000,
|
||||
extraData: {
|
||||
txt: "sample text",
|
||||
action: () => {/* Do action */},
|
||||
},
|
||||
iconClasses: {
|
||||
error: 'toast-error',
|
||||
info: 'toast-info',
|
||||
@@ -29,7 +33,6 @@ angular
|
||||
progressBar: false,
|
||||
tapToDismiss: true,
|
||||
templates: {
|
||||
|
||||
toast: 'directives/toast/toast.html',
|
||||
progressbar: 'directives/progressbar/progressbar.html'
|
||||
},
|
||||
|
||||
Vendored
+1
@@ -24,6 +24,7 @@ declare module 'angular' {
|
||||
closeButton?: boolean;
|
||||
closeHtml?: string;
|
||||
extendedTimeOut?: number;
|
||||
extraData?: any,
|
||||
messageClass?: string;
|
||||
onHidden?: (wasClicked: boolean, toast: angular.toastr.IToast) => void;
|
||||
onShown?: (toast: angular.toastr.IToast) => void;
|
||||
|
||||
Vendored
+1
-1
@@ -2,7 +2,7 @@
|
||||
// Project: https://github.com/mgonto/angular-wizard
|
||||
// Definitions by: Marko Jurisic <https://github.com/mjurisic>, Ronald Wildenberg <https://github.com/rwwilden>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import * as angular from 'angular';
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
"max-line-length": false,
|
||||
"member-access": false,
|
||||
"new-parens": false,
|
||||
"no-angle-bracket-type-assertion": false,
|
||||
"no-any-union": false,
|
||||
"no-boolean-literal-compare": false,
|
||||
"no-conditional-assignment": false,
|
||||
|
||||
@@ -20,5 +20,13 @@ Object.keys({
|
||||
, brightCyan: 96
|
||||
, brightWhite: 97
|
||||
}).forEach((color) => {
|
||||
cursor[color]().bold().write(`Hello, bold ${color.replace(/([a-z])([A-Z])/g, (_: string, l: string, u: string): string => `${l} ${u.toLowerCase()}`)} world!\n`).reset();
|
||||
const cname = color.replace(/([a-z])([A-Z])/g, (_: string, l: string, u: string): string => `${l} ${u.toLowerCase()}`);
|
||||
|
||||
((<(...anything: any[]) => ansi.Cursor> cursor[color])()
|
||||
.bold()
|
||||
.bg)[color === 'blue' || color === 'brightBlue' ? 'black' : 'blue']()
|
||||
.write(
|
||||
`Hello, bold ${cname} world!\n`
|
||||
)
|
||||
.reset();
|
||||
});
|
||||
|
||||
Vendored
+16
-3
@@ -2,6 +2,7 @@
|
||||
// Project: https://www.npmjs.com/package/ansi
|
||||
// Definitions by: Gustavo6046 <https://github.com/Gustavo6046>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.1
|
||||
|
||||
/**
|
||||
* References:
|
||||
@@ -14,11 +15,19 @@
|
||||
/// <reference types="node" />
|
||||
import { Stream } from "stream";
|
||||
|
||||
declare function ansi(stream: Stream, options?: any): ansi.Cursor;
|
||||
interface CursorOptions {
|
||||
enabled: boolean;
|
||||
buffering: boolean;
|
||||
}
|
||||
|
||||
declare function ansi(stream: Stream, options?: CursorOptions): ansi.Cursor;
|
||||
|
||||
declare namespace ansi {
|
||||
class Cursor {
|
||||
constructor(stream: Stream, options?: any);
|
||||
bg: Colorer;
|
||||
fg: Colorer;
|
||||
|
||||
constructor(stream: Stream, options?: CursorOptions);
|
||||
|
||||
/**
|
||||
* Helper function that calls `write()` on the underlying Stream.
|
||||
@@ -161,7 +170,11 @@ declare namespace ansi {
|
||||
}
|
||||
|
||||
interface Cursor {
|
||||
[key: string]: (...anything: any[]) => Cursor;
|
||||
[key: string]: ((...anything: any[]) => Cursor) | Colorer;
|
||||
}
|
||||
|
||||
interface Colorer {
|
||||
[key: string]: (...anything: any[]) => (Cursor | Colorer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
import { addPath, enableForDir, removePath } from 'app-module-path';
|
||||
|
||||
addPath('/tmp');
|
||||
|
||||
enableForDir('/tmp');
|
||||
|
||||
removePath('/tmp');
|
||||
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
// Type definitions for app-module-path 2.2
|
||||
// Project: https://github.com/patrick-steele-idem/app-module-path-node
|
||||
// Definitions by: Timur Manyanov <https://github.com/darkwebdev>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.6
|
||||
|
||||
export function addPath(path: string, parent?: any): void;
|
||||
|
||||
export function enableForDir(dir: string): void;
|
||||
|
||||
export function removePath(path: string): void;
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"app-module-path-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
Vendored
+75
@@ -1440,6 +1440,81 @@ declare module "@arangodb/foxx/router" {
|
||||
export = createRouter;
|
||||
}
|
||||
|
||||
declare module "@arangodb/foxx/queues" {
|
||||
interface QueueItem {
|
||||
name: string;
|
||||
mount: string;
|
||||
backOff?: ((failureCount: number) => number) | number;
|
||||
maxFailures?: number;
|
||||
schema?: Foxx.Schema;
|
||||
preprocess?: (data: any) => any;
|
||||
}
|
||||
|
||||
interface Script {
|
||||
name: string;
|
||||
mount: string;
|
||||
}
|
||||
|
||||
type JobCallback = (result: any, jobData: any, job: ArangoDB.Document<Job>) => void;
|
||||
|
||||
interface Job {
|
||||
status: string;
|
||||
queue: string;
|
||||
type: Script;
|
||||
failures: object[];
|
||||
runs: number;
|
||||
data: any;
|
||||
created: number;
|
||||
modified: number;
|
||||
delayUntil: number;
|
||||
maxFailures: number;
|
||||
repeatDelay: number;
|
||||
repeatTimes: number;
|
||||
repeatUntil: number;
|
||||
success?: string;
|
||||
failure?: string;
|
||||
runFailures: number;
|
||||
abort(): void;
|
||||
}
|
||||
|
||||
interface JobOptions {
|
||||
success?: JobCallback;
|
||||
failure?: JobCallback;
|
||||
delayUntil?: number | Date;
|
||||
backOff?: ((failureCount: number) => number) | number;
|
||||
maxFailures?: number;
|
||||
repeatTimes?: number;
|
||||
repeatUntil?: number | Date;
|
||||
repeatDelay?: number;
|
||||
}
|
||||
|
||||
interface Queue {
|
||||
push(item: QueueItem, data: any, opts?: JobOptions): void;
|
||||
get(jobId: string): ArangoDB.Document<Job>;
|
||||
delete(jobId: string): boolean;
|
||||
pending(script?: Script): string[];
|
||||
progress(script?: Script): string[];
|
||||
complete(script?: Script): string[];
|
||||
failed(script?: Script): string[];
|
||||
all(script?: Script): string[];
|
||||
}
|
||||
|
||||
function createQueue(name: string, maxWorkers?: number): Queue;
|
||||
function deleteQueue(name: string): boolean;
|
||||
function get(name: string): Queue;
|
||||
|
||||
export {
|
||||
createQueue as create,
|
||||
deleteQueue as delete,
|
||||
get,
|
||||
JobOptions,
|
||||
Job,
|
||||
Queue,
|
||||
QueueItem,
|
||||
Script,
|
||||
};
|
||||
}
|
||||
|
||||
declare module "@arangodb/foxx/graphql" {
|
||||
import { formatError, GraphQLSchema } from "graphql";
|
||||
type GraphQLModule = object;
|
||||
|
||||
@@ -1 +1,6 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"no-angle-bracket-type-assertion": false
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+1
@@ -2,6 +2,7 @@
|
||||
// Project: https://github.com/postcss/autoprefixer
|
||||
// Definitions by: Armando Meziat <https://github.com/odnamrataizem>, murt <https://github.com/murt>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
import { Plugin } from "postcss";
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -75,7 +75,7 @@ export namespace Azure.ServiceBus {
|
||||
DefaultMessageTimeToLive: string;
|
||||
DuplicateDetectionHistoryTimeWindow: string;
|
||||
EnablePartitioning: boolean;
|
||||
MaxSizeInMegaBytes: number;
|
||||
MaxSizeInMegabytes: number;
|
||||
RequiresDuplicateDetection: boolean;
|
||||
}
|
||||
|
||||
|
||||
Vendored
+4
-4
@@ -4,16 +4,16 @@
|
||||
// Marvin Hagemeister <https://github.com/marvinhagemeister>
|
||||
// Melvin Groenhoff <https://github.com/mgroenhoff>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
// TypeScript Version: 2.9
|
||||
|
||||
import { GeneratorOptions } from "@babel/generator";
|
||||
import traverse, { Visitor, NodePath } from "@babel/traverse";
|
||||
import template from "@babel/template";
|
||||
import * as t from "@babel/types";
|
||||
import { ParseOptions } from "@babel/parser";
|
||||
import { ParserOptions } from "@babel/parser";
|
||||
|
||||
export {
|
||||
ParseOptions,
|
||||
ParserOptions,
|
||||
GeneratorOptions,
|
||||
t as types,
|
||||
template,
|
||||
@@ -217,7 +217,7 @@ export interface TransformOptions {
|
||||
*
|
||||
* Default: `{}`
|
||||
*/
|
||||
parserOpts?: ParseOptions | null;
|
||||
parserOpts?: ParserOptions | null;
|
||||
|
||||
/**
|
||||
* List of plugins to load and use
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@babel/types": "^7.0.0-beta.54"
|
||||
"@babel/parser": "^7.1.0",
|
||||
"@babel/types": "^7.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,9 +22,6 @@
|
||||
"@babel/generator": [
|
||||
"babel__generator"
|
||||
],
|
||||
"@babel/parser": [
|
||||
"babel__parser"
|
||||
],
|
||||
"@babel/template": [
|
||||
"babel__template"
|
||||
],
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// Example from https://github.com/babel/babel/tree/master/packages/babel-generator
|
||||
import generate from "@babel/generator";
|
||||
import { parse } from "@babel/parser";
|
||||
import * as t from "@babel/types";
|
||||
|
||||
const code = "class Example {}";
|
||||
const ast = parse(code);
|
||||
declare const ast: t.Node;
|
||||
|
||||
ast.type;
|
||||
ast.loc!.start;
|
||||
|
||||
Vendored
+1
-1
@@ -4,7 +4,7 @@
|
||||
// Johnny Estilles <https://github.com/johnnyestilles>
|
||||
// Melvin Groenhoff <https://github.com/mgroenhoff>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
// TypeScript Version: 2.9
|
||||
|
||||
import * as t from "@babel/types";
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@babel/types": "^7.0.0-beta.54"
|
||||
"@babel/types": "^7.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,9 +18,6 @@
|
||||
"paths": {
|
||||
"@babel/generator": [
|
||||
"babel__generator"
|
||||
],
|
||||
"@babel/parser": [
|
||||
"babel__parser"
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
import { parse, parseExpression } from "@babel/parser";
|
||||
|
||||
declare function assert(expr: boolean): void;
|
||||
|
||||
const code = `function square(n) {
|
||||
return n * n;
|
||||
}`;
|
||||
|
||||
const node = parse(code);
|
||||
assert(node.type === "File");
|
||||
assert(node.start === 0);
|
||||
assert(node.end === 38);
|
||||
assert(!!node.loc && node.loc.start > node.loc.end);
|
||||
|
||||
parse(code, {
|
||||
sourceType: "module", // default: "script"
|
||||
plugins: ["jsx"] // default: []
|
||||
});
|
||||
Vendored
-107
@@ -1,107 +0,0 @@
|
||||
// Type definitions for @babel/parser 7.0
|
||||
// Project: https://github.com/babel/babel/tree/master/packages/babel-parser
|
||||
// Definitions by: Troy Gerwien <https://github.com/yortus>
|
||||
// Marvin Hagemeister <https://github.com/marvinhagemeister>
|
||||
// Melvin Groenhoff <https://github.com/mgroenhoff>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import { File, Expression } from "@babel/types";
|
||||
|
||||
export function parse(code: string, opts?: ParseOptions): File;
|
||||
|
||||
export function parseExpression(input: string, options?: ParseOptions): Expression;
|
||||
|
||||
export interface ParseOptions {
|
||||
/**
|
||||
* By default, import and export declarations can only appear at a program's top level.
|
||||
* Setting this option to true allows them anywhere where a statement is allowed.
|
||||
*/
|
||||
allowImportExportEverywhere?: boolean;
|
||||
|
||||
/**
|
||||
* By default, await use is not allowed outside of an async function. Set this to true to accept such code.
|
||||
*/
|
||||
allowAwaitOutsideFunction?: boolean;
|
||||
|
||||
/**
|
||||
* By default, a return statement at the top level raises an error. Set this to true to accept such code.
|
||||
*/
|
||||
allowReturnOutsideFunction?: boolean;
|
||||
|
||||
allowSuperOutsideMethod?: boolean;
|
||||
|
||||
/**
|
||||
* Indicate the mode the code should be parsed in. Can be one of "script", "module", or "unambiguous".
|
||||
* Defaults to "script". "unambiguous" will make @babel/parser attempt to guess, based on the presence of ES6 import or export
|
||||
* statements. Files with ES6 imports and exports are considered "module" and are otherwise "script".
|
||||
*/
|
||||
sourceType?: "script" | "module" | "unambiguous";
|
||||
|
||||
/**
|
||||
* Correlate output AST nodes with their source filename. Useful when
|
||||
* generating code and source maps from the ASTs of multiple input files.
|
||||
*/
|
||||
sourceFilename?: string;
|
||||
|
||||
/**
|
||||
* By default, the first line of code parsed is treated as line 1. You can provide a line number to alternatively start with. Useful
|
||||
* for integration with other source tools.
|
||||
*/
|
||||
startLine?: number;
|
||||
|
||||
/**
|
||||
* Array containing the plugins that you want to enable.
|
||||
*/
|
||||
plugins?: PluginList;
|
||||
|
||||
strictMode?: boolean;
|
||||
|
||||
/**
|
||||
* Adds a `ranges` property to each node: `[node.start, node.end]`
|
||||
*/
|
||||
ranges?: boolean;
|
||||
|
||||
/**
|
||||
* Adds all parsed tokens to a `tokens` property on the `File` node
|
||||
*/
|
||||
tokens?: boolean;
|
||||
}
|
||||
|
||||
export type PluginList = Array<PluginName | [PluginName, PluginOptions]>;
|
||||
|
||||
export type PluginName =
|
||||
"asyncGenerators" |
|
||||
"bigInt" |
|
||||
"classPrivateMethods" |
|
||||
"classPrivateProperties" |
|
||||
"classProperties" |
|
||||
"decorators" |
|
||||
"doExpressions" |
|
||||
"dynamicImport" |
|
||||
"estree" |
|
||||
"exportDefaultFrom" |
|
||||
"exportNamespaceFrom" |
|
||||
"flow" |
|
||||
"flowComments" |
|
||||
"functionBind" |
|
||||
"functionSent" |
|
||||
"importMeta" |
|
||||
"jsx" |
|
||||
"nullishCoalescingOperator" |
|
||||
"numericSeparator" |
|
||||
"objectRestSpread" |
|
||||
"optionalCatchBinding" |
|
||||
"optionalChaining" |
|
||||
"pipelineOperator" |
|
||||
"throwExpressions" |
|
||||
"typescript";
|
||||
|
||||
export interface PluginOptions {
|
||||
decorators?: {
|
||||
decoratorsBeforeExport?: boolean;
|
||||
};
|
||||
flow?: {
|
||||
all?: boolean;
|
||||
};
|
||||
}
|
||||
Vendored
+3
-3
@@ -4,12 +4,12 @@
|
||||
// Marvin Hagemeister <https://github.com/marvinhagemeister>
|
||||
// Melvin Groenhoff <https://github.com/mgroenhoff>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
// TypeScript Version: 2.9
|
||||
|
||||
import { ParseOptions } from "@babel/parser";
|
||||
import { ParserOptions } from "@babel/parser";
|
||||
import { Expression, File, Program, Statement } from "@babel/types";
|
||||
|
||||
export interface TemplateBuilderOptions extends ParseOptions {
|
||||
export interface TemplateBuilderOptions extends ParserOptions {
|
||||
/**
|
||||
* A set of placeholder names to automatically accept. Items in this list do not need to match the given placeholder pattern.
|
||||
*/
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@babel/types": "^7.0.0-beta.54"
|
||||
"@babel/parser": "^7.1.0",
|
||||
"@babel/types": "^7.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,9 +20,6 @@
|
||||
"@babel/generator": [
|
||||
"babel__generator"
|
||||
],
|
||||
"@babel/parser": [
|
||||
"babel__parser"
|
||||
],
|
||||
"@babel/template": [
|
||||
"babel__template"
|
||||
]
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { parse } from "@babel/parser";
|
||||
import traverse, { Visitor } from "@babel/traverse";
|
||||
import * as t from "@babel/types";
|
||||
|
||||
@@ -21,11 +20,7 @@ const MyVisitor2: Visitor = {
|
||||
};
|
||||
|
||||
// Example from https://github.com/thejameskyle/babel-handbook/blob/master/translations/en/plugin-handbook.md#babel-traverse
|
||||
const code = `function square(n) {
|
||||
return n * n;
|
||||
}`;
|
||||
|
||||
const ast = parse(code);
|
||||
declare const ast: t.Node;
|
||||
|
||||
traverse(ast, {
|
||||
enter(path) {
|
||||
|
||||
Vendored
+1
-1
@@ -5,7 +5,7 @@
|
||||
// Ryan Petrich <https://github.com/rpetrich>
|
||||
// Melvin Groenhoff <https://github.com/mgroenhoff>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
// TypeScript Version: 2.9
|
||||
|
||||
import * as t from "@babel/types";
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@babel/types": "^7.0.0-beta.54"
|
||||
"@babel/types": "^7.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,9 +17,6 @@
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"paths": {
|
||||
"@babel/parser": [
|
||||
"babel__parser"
|
||||
],
|
||||
"@babel/traverse": [
|
||||
"babel__traverse"
|
||||
]
|
||||
|
||||
Vendored
+1
@@ -46,6 +46,7 @@ export type PluginName =
|
||||
'estree' |
|
||||
'jsx' |
|
||||
'flow' |
|
||||
'typescript' |
|
||||
'classConstructorCall' |
|
||||
'doExpressions' |
|
||||
'objectRestSpread' |
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
"max-line-length": false,
|
||||
"member-access": false,
|
||||
"new-parens": false,
|
||||
"no-angle-bracket-type-assertion": false,
|
||||
"no-any-union": false,
|
||||
"no-boolean-literal-compare": false,
|
||||
"no-conditional-assignment": false,
|
||||
|
||||
Vendored
+129
-2
@@ -4,13 +4,15 @@
|
||||
// Natan Vivo <https://github.com/nvivo>,
|
||||
// Sven Tschui <https://github.com/sventschui>,
|
||||
// Volker Nauruhn <https://github.com/razorness>,
|
||||
// Ard Timmerman <https://github.com/confususs>
|
||||
// Ard Timmerman <https://github.com/confususs>,
|
||||
// J. Joe Koullas <https://github.com/jjoekoullas>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
import * as Backbone from 'backbone';
|
||||
import * as JQuery from 'jquery';
|
||||
import * as Radio from 'backbone.radio';
|
||||
import * as _ from 'underscore';
|
||||
|
||||
export as namespace Marionette;
|
||||
|
||||
@@ -179,6 +181,131 @@ export class Container<TView> {
|
||||
* Find a view by it's cid.
|
||||
*/
|
||||
remove(view: TView): void;
|
||||
|
||||
/**
|
||||
* @see _.forEach
|
||||
*/
|
||||
forEach(iterator: _.ListIterator<TView, void>, context?: any): Container<TView>;
|
||||
|
||||
/**
|
||||
* @see _.each
|
||||
*/
|
||||
each(iterator: _.ListIterator<TView, void>, context?: any): Container<TView>;
|
||||
|
||||
/**
|
||||
* @see _.map
|
||||
*/
|
||||
map<TResult>(iterator: _.ListIterator<TView, TResult>, context?: any): TResult[];
|
||||
|
||||
/**
|
||||
* @see _.find
|
||||
*/
|
||||
find(iterator: _.ListIterator<TView, boolean>, context?: any): Container<TView> | undefined;
|
||||
|
||||
/**
|
||||
* @see _.detect
|
||||
*/
|
||||
detect(iterator: _.ListIterator<TView, boolean>, context?: any): Container<TView> | undefined;
|
||||
|
||||
/**
|
||||
* @see _.filter
|
||||
*/
|
||||
filter(iterator: _.ListIterator<TView, boolean>, context?: any): TView[];
|
||||
|
||||
/**
|
||||
* @see _.select
|
||||
*/
|
||||
select(iterator: _.ListIterator<TView, boolean>, context?: any): TView[];
|
||||
|
||||
/**
|
||||
* @see _.reject
|
||||
*/
|
||||
reject(iterator: _.ListIterator<TView, boolean>, context?: any): TView[];
|
||||
|
||||
/**
|
||||
* @see _.every
|
||||
*/
|
||||
every(iterator: _.ListIterator<TView, boolean>, context?: any): boolean;
|
||||
|
||||
/**
|
||||
* @see _.all
|
||||
*/
|
||||
all(iterator: _.ListIterator<TView, boolean>, context?: any): boolean;
|
||||
|
||||
/**
|
||||
* @see _.some
|
||||
*/
|
||||
some(iterator: _.ListIterator<TView, boolean>, context?: any): boolean;
|
||||
|
||||
/**
|
||||
* @see _.any
|
||||
*/
|
||||
any(iterator: _.ListIterator<TView, boolean>, context?: any): boolean;
|
||||
|
||||
/**
|
||||
* @see _.include
|
||||
*/
|
||||
include(value: TView, fromIndex?: number): boolean;
|
||||
|
||||
/**
|
||||
* @see _.contains
|
||||
*/
|
||||
contains(value: TView, fromIndex?: number): boolean;
|
||||
|
||||
/**
|
||||
* @see _.invoke
|
||||
*/
|
||||
invoke(methodName: string, ...args: any[]): any;
|
||||
|
||||
/**
|
||||
* @see _.toArray
|
||||
*/
|
||||
toArray(): TView[];
|
||||
|
||||
/**
|
||||
* @see _.first
|
||||
*/
|
||||
first(): TView | undefined;
|
||||
|
||||
/**
|
||||
* @see _.initial
|
||||
*/
|
||||
initial(n?: number): TView[];
|
||||
|
||||
/**
|
||||
* @see _.rest
|
||||
*/
|
||||
rest(n?: number): TView[];
|
||||
|
||||
/**
|
||||
* @see _.last
|
||||
*/
|
||||
last(n: number): TView[];
|
||||
|
||||
/**
|
||||
* @see _.without
|
||||
*/
|
||||
without(...values: TView[]): TView[];
|
||||
|
||||
/**
|
||||
* @see _.isEmpty
|
||||
*/
|
||||
isEmpty(): boolean;
|
||||
|
||||
/**
|
||||
* @see _.pluck
|
||||
*/
|
||||
pluck(propertyName: string): any[];
|
||||
|
||||
/**
|
||||
* @see _.reduce
|
||||
*/
|
||||
reduce<TResult>(iterator: _.MemoIterator<TView, TResult>, memo?: TResult, context?: any): TResult;
|
||||
|
||||
/**
|
||||
* @see _.partition
|
||||
*/
|
||||
partition(iterator: _.ListIterator<TView, boolean>, context?: any): TView[][];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1154,7 +1281,7 @@ export class View<TModel extends Backbone.Model> extends Backbone.View<TModel> i
|
||||
export interface CollectionViewOptions<
|
||||
TModel extends Backbone.Model,
|
||||
TCollection extends Backbone.Collection<TModel> = Backbone.Collection<TModel>
|
||||
> extends Backbone.ViewOptions<TModel>, ViewMixinOptions {
|
||||
> extends Backbone.ViewOptions<TModel>, ViewMixinOptions {
|
||||
/**
|
||||
* Specify a child view to use.
|
||||
*/
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
"max-line-length": false,
|
||||
"member-access": false,
|
||||
"new-parens": false,
|
||||
"no-angle-bracket-type-assertion": false,
|
||||
"no-any-union": false,
|
||||
"no-boolean-literal-compare": false,
|
||||
"no-conditional-assignment": false,
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
"max-line-length": false,
|
||||
"member-access": false,
|
||||
"new-parens": false,
|
||||
"no-angle-bracket-type-assertion": false,
|
||||
"no-any-union": false,
|
||||
"no-boolean-literal-compare": false,
|
||||
"no-conditional-assignment": false,
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"no-angle-bracket-type-assertion": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
import browserslist from "browserslist";
|
||||
|
||||
browserslist(); // $ExpectType string[]
|
||||
browserslist(""); // $ExpectType string[]
|
||||
browserslist([""]); // $ExpectType string[]
|
||||
|
||||
const opts: browserslist.Options[] = [
|
||||
{},
|
||||
{ path: "" },
|
||||
{ env: "" },
|
||||
{ stats: { "": { "": 0 } } },
|
||||
{ config: "" },
|
||||
{ ignoreUnknownVersions: false },
|
||||
{ dangerousExtend: false }
|
||||
];
|
||||
for (const opt of opts) {
|
||||
browserslist("", opt); // $ExpectType string[]
|
||||
browserslist([""], opt); // $ExpectType string[]
|
||||
}
|
||||
|
||||
browserslist.coverage([""]); // $ExpectType number
|
||||
browserslist.coverage([""], { "": { "": 0 } }); // $ExpectType number
|
||||
Vendored
+34
@@ -0,0 +1,34 @@
|
||||
// Type definitions for browserslist 4.3
|
||||
// Project: https://github.com/browserslist/browserslist#readme
|
||||
// Definitions by: Dave Cardwell <https://github.com/davecardwell>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.7
|
||||
|
||||
declare namespace browserslist {
|
||||
interface Browserslist {
|
||||
(queries?: string | ReadonlyArray<string>, opts?: Options): string[];
|
||||
|
||||
coverage: (browsers: ReadonlyArray<string>, stats?: Stats) => number;
|
||||
|
||||
clearCaches: () => void;
|
||||
}
|
||||
|
||||
interface Stats {
|
||||
[browser: string]: {
|
||||
[version: string]: number;
|
||||
};
|
||||
}
|
||||
|
||||
interface Options {
|
||||
path?: string;
|
||||
env?: string;
|
||||
stats?: Stats;
|
||||
config?: string;
|
||||
ignoreUnknownVersions?: boolean;
|
||||
dangerousExtend?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
declare var browserslist: browserslist.Browserslist;
|
||||
|
||||
export = browserslist;
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": ["es6"],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": ["../"],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"esModuleInterop": true
|
||||
},
|
||||
"files": ["index.d.ts", "browserslist-tests.ts"]
|
||||
}
|
||||
@@ -133,7 +133,7 @@ pdfQueue
|
||||
.on('failed', (job: Queue.Job) => undefined)
|
||||
.on('paused', () => undefined)
|
||||
.on('resumed', () => undefined)
|
||||
.on('cleaned', (jobs: Queue.Job[], status: Queue.JobStatus) => undefined)
|
||||
.on('cleaned', (jobs: Queue.Job[], status: Queue.JobStatusClean) => undefined)
|
||||
.on('drained', () => undefined)
|
||||
.on('removed', (job: Queue.Job) => undefined);
|
||||
|
||||
|
||||
Vendored
+5
-3
@@ -11,6 +11,7 @@
|
||||
// Wuha Team <https://github.com/wuha-team>
|
||||
// Alec Brunelle <https://github.com/aleccool213>
|
||||
// Dan Manastireanu <https://github.com/danmana>
|
||||
// Kjell-Morten Bratsberg Thorsen <https://github.com/kjellmorten>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
@@ -194,6 +195,7 @@ declare namespace Bull {
|
||||
}
|
||||
|
||||
type JobStatus = 'completed' | 'waiting' | 'active' | 'delayed' | 'failed';
|
||||
type JobStatusClean = 'completed' | 'wait' | 'active' | 'delayed' | 'failed';
|
||||
|
||||
interface BackoffOptions {
|
||||
/**
|
||||
@@ -635,12 +637,12 @@ declare namespace Bull {
|
||||
|
||||
/**
|
||||
* Tells the queue remove all jobs created outside of a grace period in milliseconds.
|
||||
* You can clean the jobs with the following states: completed, waiting, active, delayed, and failed.
|
||||
* You can clean the jobs with the following states: completed, wait (typo for waiting), active, delayed, and failed.
|
||||
* @param grace Grace period in milliseconds.
|
||||
* @param status Status of the job to clean. Values are completed, wait, active, delayed, and failed. Defaults to completed.
|
||||
* @param limit Maximum amount of jobs to clean per call. If not provided will clean all matching jobs.
|
||||
*/
|
||||
clean(grace: number, status?: JobStatus, limit?: number): Promise<Array<Job<T>>>;
|
||||
clean(grace: number, status?: JobStatusClean, limit?: number): Promise<Array<Job<T>>>;
|
||||
|
||||
/**
|
||||
* Listens to queue events
|
||||
@@ -734,7 +736,7 @@ declare namespace Bull {
|
||||
|
||||
type FailedEventCallback<T = any> = (job: Job<T>, error: Error) => void;
|
||||
|
||||
type CleanedEventCallback<T = any> = (jobs: Array<Job<T>>, status: JobStatus) => void;
|
||||
type CleanedEventCallback<T = any> = (jobs: Array<Job<T>>, status: JobStatusClean) => void;
|
||||
|
||||
type RemovedEventCallback<T = any> = (job: Job<T>) => void;
|
||||
|
||||
|
||||
-238
@@ -1,239 +1 @@
|
||||
// Type definitions for business-rules-engine - v1.0.20
|
||||
// Project: https://github.com/rsamec/form
|
||||
// Definitions by: Roman Samec <https://github.com/rsamec>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare namespace Validation {
|
||||
interface IErrorCustomMessage {
|
||||
(config: any, args: any): string;
|
||||
}
|
||||
interface IPropertyValidator {
|
||||
isAcceptable(s: any): boolean;
|
||||
customMessage?: IErrorCustomMessage;
|
||||
tagName?: string;
|
||||
}
|
||||
interface IStringValidator extends IPropertyValidator {
|
||||
isAcceptable(s: string): boolean;
|
||||
}
|
||||
interface IAsyncPropertyValidator {
|
||||
isAcceptable(s: any): Q.Promise<boolean>;
|
||||
customMessage?: IErrorCustomMessage;
|
||||
isAsync: boolean;
|
||||
tagName?: string;
|
||||
}
|
||||
interface IAsyncStringPropertyValidator extends IAsyncPropertyValidator {
|
||||
isAcceptable(s: string): Q.Promise<boolean>;
|
||||
}
|
||||
enum CompareOperator {
|
||||
LessThan = 0,
|
||||
LessThanEqual = 1,
|
||||
Equal = 2,
|
||||
NotEqual = 3,
|
||||
GreaterThanEqual = 4,
|
||||
GreaterThan = 5,
|
||||
}
|
||||
interface IError {
|
||||
HasError: boolean;
|
||||
ErrorMessage: string;
|
||||
TranslateArgs?: IErrorTranslateArgs;
|
||||
}
|
||||
interface IErrorTranslateArgs {
|
||||
TranslateId: string;
|
||||
MessageArgs: any;
|
||||
CustomMessage?: IErrorCustomMessage;
|
||||
}
|
||||
interface IOptional {
|
||||
(): boolean;
|
||||
}
|
||||
interface IValidationFailure extends IError {
|
||||
IsAsync: boolean;
|
||||
Error: IError;
|
||||
}
|
||||
interface IValidationResult {
|
||||
Name: string;
|
||||
Add(validationResult: IValidationResult): void;
|
||||
Remove(index: number): void;
|
||||
Children: IValidationResult[];
|
||||
HasErrors: boolean;
|
||||
HasErrorsDirty: boolean;
|
||||
ErrorMessage: string;
|
||||
ErrorCount: number;
|
||||
Optional?: IOptional;
|
||||
TranslateArgs?: IErrorTranslateArgs[];
|
||||
}
|
||||
interface IValidate {
|
||||
(args: IError): void;
|
||||
}
|
||||
interface IAsyncValidate {
|
||||
(args: IError): Q.Promise<any>;
|
||||
}
|
||||
interface IValidatorFce {
|
||||
Name: string;
|
||||
ValidationFce?: IValidate;
|
||||
AsyncValidationFce?: IAsyncValidate;
|
||||
}
|
||||
interface IValidator {
|
||||
Validate(context: any): IValidationFailure;
|
||||
ValidateAsync(context: any): Q.Promise<IValidationFailure>;
|
||||
Error: IError;
|
||||
}
|
||||
interface IAbstractValidator<T> {
|
||||
RuleFor(prop: string, validator: IPropertyValidator): any;
|
||||
ValidationFor(prop: string, validatorFce: IValidatorFce): any;
|
||||
Validation(validatorFce: IValidatorFce): any;
|
||||
ValidatorFor<K>(prop: string, validator: IAbstractValidator<K>): any;
|
||||
CreateRule(name: string): IAbstractValidationRule<any>;
|
||||
CreateAbstractRule(name: string): IAbstractValidationRule<any>;
|
||||
CreateAbstractListRule(name: string): IAbstractValidationRule<any>;
|
||||
ForList: boolean;
|
||||
}
|
||||
interface IAbstractValidationRule<T> {
|
||||
Validate(context: T): IValidationResult;
|
||||
ValidateAsync(context: T): Q.Promise<IValidationResult>;
|
||||
ValidateAll(context: T): Q.Promise<IValidationResult>;
|
||||
ValidateProperty(context: T, propName: string): void;
|
||||
ValidationResult: IValidationResult;
|
||||
Rules: {
|
||||
[name: string]: IPropertyValidationRule<T>;
|
||||
};
|
||||
Validators: {
|
||||
[name: string]: IValidator;
|
||||
};
|
||||
Children: {
|
||||
[name: string]: IAbstractValidationRule<any>;
|
||||
};
|
||||
}
|
||||
interface IPropertyValidationRule<T> {
|
||||
Validators: {
|
||||
[name: string]: any;
|
||||
};
|
||||
Validate(context: IValidationContext<T>): IValidationFailure[];
|
||||
ValidateAsync(context: IValidationContext<T>): Q.Promise<IValidationFailure[]>;
|
||||
}
|
||||
interface IValidationContext<T> {
|
||||
Value: string;
|
||||
Key: string;
|
||||
Data: T;
|
||||
}
|
||||
class Error implements IError {
|
||||
public HasError: boolean;
|
||||
public ErrorMessage: string;
|
||||
constructor();
|
||||
}
|
||||
class ValidationFailure implements IError {
|
||||
public Error: IError;
|
||||
public IsAsync: boolean;
|
||||
constructor(Error: IError, IsAsync: boolean);
|
||||
public HasError : boolean;
|
||||
public ErrorMessage : string;
|
||||
public TranslateArgs : IErrorTranslateArgs;
|
||||
}
|
||||
class ValidationResult implements IValidationResult {
|
||||
public Name: string;
|
||||
constructor(Name: string);
|
||||
public IsDirty: boolean;
|
||||
public Children : IValidationResult[];
|
||||
public Add(error: IValidationResult): void;
|
||||
public Remove(index: number): void;
|
||||
public Optional: IOptional;
|
||||
public TranslateArgs: IErrorTranslateArgs[];
|
||||
public HasErrorsDirty : boolean;
|
||||
public HasErrors : boolean;
|
||||
public ErrorCount : number;
|
||||
public ErrorMessage : string;
|
||||
}
|
||||
class CompositeValidationResult implements IValidationResult {
|
||||
public Name: string;
|
||||
public Children: IValidationResult[];
|
||||
constructor(Name: string);
|
||||
public Optional: IOptional;
|
||||
public AddFirst(error: IValidationResult): void;
|
||||
public Add(error: IValidationResult): void;
|
||||
public Remove(index: number): void;
|
||||
public HasErrorsDirty : boolean;
|
||||
public HasErrors : boolean;
|
||||
public ErrorCount : number;
|
||||
public ErrorMessage : string;
|
||||
public TranslateArgs : IErrorTranslateArgs[];
|
||||
public LogErrors(headerMessage?: string): void;
|
||||
public Errors : {
|
||||
[name: string]: IValidationResult;
|
||||
};
|
||||
private FlattenErros;
|
||||
public SetDirty(): void;
|
||||
public SetPristine(): void;
|
||||
private SetDirtyEx(node, dirty);
|
||||
private flattenErrors(node, errorCollection);
|
||||
private traverse(node, indent);
|
||||
}
|
||||
class AbstractValidator<T> implements IAbstractValidator<T> {
|
||||
public Validators: {
|
||||
[name: string]: IPropertyValidator[];
|
||||
};
|
||||
public AbstractValidators: {
|
||||
[name: string]: IAbstractValidator<any>;
|
||||
};
|
||||
public ValidationFunctions: {
|
||||
[name: string]: IValidatorFce[];
|
||||
};
|
||||
public RuleFor(prop: string, validator: IPropertyValidator): void;
|
||||
public ValidationFor(prop: string, fce: IValidatorFce): void;
|
||||
public Validation(fce: IValidatorFce): void;
|
||||
public ValidatorFor<K>(prop: string, validator: IAbstractValidator<K>, forList?: boolean): void;
|
||||
public CreateAbstractRule(name: string): IAbstractValidationRule<T>;
|
||||
public CreateAbstractListRule(name: string): IAbstractValidationRule<T>;
|
||||
public CreateRule(name: string): IAbstractValidationRule<T>;
|
||||
public ForList: boolean;
|
||||
}
|
||||
class MessageLocalization {
|
||||
static customMsg: string;
|
||||
static defaultMessages: {
|
||||
"required": string;
|
||||
"remote": string;
|
||||
"email": string;
|
||||
"url": string;
|
||||
"date": string;
|
||||
"dateISO": string;
|
||||
"number": string;
|
||||
"digits": string;
|
||||
"signedDigits": string;
|
||||
"creditcard": string;
|
||||
"equalTo": string;
|
||||
"maxlength": string;
|
||||
"minlength": string;
|
||||
"rangelength": string;
|
||||
"range": string;
|
||||
"max": string;
|
||||
"min": string;
|
||||
"step": string;
|
||||
"contains": string;
|
||||
"mask": string;
|
||||
"custom": string;
|
||||
};
|
||||
static ValidationMessages: {
|
||||
"required": string;
|
||||
"remote": string;
|
||||
"email": string;
|
||||
"url": string;
|
||||
"date": string;
|
||||
"dateISO": string;
|
||||
"number": string;
|
||||
"digits": string;
|
||||
"signedDigits": string;
|
||||
"creditcard": string;
|
||||
"equalTo": string;
|
||||
"maxlength": string;
|
||||
"minlength": string;
|
||||
"rangelength": string;
|
||||
"range": string;
|
||||
"max": string;
|
||||
"min": string;
|
||||
"step": string;
|
||||
"contains": string;
|
||||
"mask": string;
|
||||
"custom": string;
|
||||
};
|
||||
static GetValidationMessage(validator: any): string;
|
||||
}
|
||||
}
|
||||
declare module "node-validation" {export = Validation;}
|
||||
|
||||
+230
-235
@@ -4,242 +4,237 @@
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
// Source: typings/business-rules-engine/Validation.d.ts
|
||||
|
||||
import * as Q from "q";
|
||||
|
||||
declare namespace Validation {
|
||||
interface IErrorCustomMessage {
|
||||
(config: any, args: any): string;
|
||||
}
|
||||
interface IPropertyValidator {
|
||||
isAcceptable(s: any): boolean;
|
||||
customMessage?: IErrorCustomMessage;
|
||||
tagName?: string;
|
||||
}
|
||||
interface IStringValidator extends IPropertyValidator {
|
||||
isAcceptable(s: string): boolean;
|
||||
}
|
||||
interface IAsyncPropertyValidator {
|
||||
isAcceptable(s: any): Q.Promise<boolean>;
|
||||
customMessage?: IErrorCustomMessage;
|
||||
isAsync: boolean;
|
||||
tagName?: string;
|
||||
}
|
||||
interface IAsyncStringPropertyValidator extends IAsyncPropertyValidator {
|
||||
isAcceptable(s: string): Q.Promise<boolean>;
|
||||
}
|
||||
enum CompareOperator {
|
||||
LessThan = 0,
|
||||
LessThanEqual = 1,
|
||||
Equal = 2,
|
||||
NotEqual = 3,
|
||||
GreaterThanEqual = 4,
|
||||
GreaterThan = 5,
|
||||
}
|
||||
interface IError {
|
||||
HasError: boolean;
|
||||
ErrorMessage: string;
|
||||
TranslateArgs?: IErrorTranslateArgs;
|
||||
}
|
||||
interface IErrorTranslateArgs {
|
||||
TranslateId: string;
|
||||
MessageArgs: any;
|
||||
CustomMessage?: IErrorCustomMessage;
|
||||
}
|
||||
interface IOptional {
|
||||
(): boolean;
|
||||
}
|
||||
interface IValidationFailure extends IError {
|
||||
IsAsync: boolean;
|
||||
Error: IError;
|
||||
}
|
||||
interface IValidationResult {
|
||||
Name: string;
|
||||
Add(validationResult: IValidationResult): void;
|
||||
Remove(index: number): void;
|
||||
Children: IValidationResult[];
|
||||
HasErrors: boolean;
|
||||
HasErrorsDirty: boolean;
|
||||
ErrorMessage: string;
|
||||
ErrorCount: number;
|
||||
Optional?: IOptional;
|
||||
TranslateArgs?: IErrorTranslateArgs[];
|
||||
}
|
||||
interface IValidate {
|
||||
(args: IError): void;
|
||||
}
|
||||
interface IAsyncValidate {
|
||||
(args: IError): Q.Promise<any>;
|
||||
}
|
||||
interface IValidatorFce {
|
||||
Name: string;
|
||||
ValidationFce?: IValidate;
|
||||
AsyncValidationFce?: IAsyncValidate;
|
||||
}
|
||||
interface IValidator {
|
||||
Validate(context: any): IValidationFailure;
|
||||
ValidateAsync(context: any): Q.Promise<IValidationFailure>;
|
||||
Error: IError;
|
||||
}
|
||||
interface IAbstractValidator<T> {
|
||||
RuleFor(prop: string, validator: IPropertyValidator): any;
|
||||
ValidationFor(prop: string, validatorFce: IValidatorFce): any;
|
||||
Validation(validatorFce: IValidatorFce): any;
|
||||
ValidatorFor<K>(prop: string, validator: IAbstractValidator<K>): any;
|
||||
CreateRule(name: string): IAbstractValidationRule<any>;
|
||||
CreateAbstractRule(name: string): IAbstractValidationRule<any>;
|
||||
CreateAbstractListRule(name: string): IAbstractValidationRule<any>;
|
||||
ForList: boolean;
|
||||
}
|
||||
interface IAbstractValidationRule<T> {
|
||||
Validate(context: T): IValidationResult;
|
||||
ValidateAsync(context: T): Q.Promise<IValidationResult>;
|
||||
ValidateAll(context: T): Q.Promise<IValidationResult>;
|
||||
ValidateProperty(context: T, propName: string): void;
|
||||
ValidationResult: IValidationResult;
|
||||
Rules: {
|
||||
[name: string]: IPropertyValidationRule<T>;
|
||||
};
|
||||
Validators: {
|
||||
[name: string]: IValidator;
|
||||
};
|
||||
Children: {
|
||||
[name: string]: IAbstractValidationRule<any>;
|
||||
};
|
||||
}
|
||||
interface IPropertyValidationRule<T> {
|
||||
Validators: {
|
||||
[name: string]: any;
|
||||
};
|
||||
Validate(context: IValidationContext<T>): IValidationFailure[];
|
||||
ValidateAsync(context: IValidationContext<T>): Q.Promise<IValidationFailure[]>;
|
||||
}
|
||||
interface IValidationContext<T> {
|
||||
Value: string;
|
||||
Key: string;
|
||||
Data: T;
|
||||
}
|
||||
class Error implements IError {
|
||||
public HasError: boolean;
|
||||
public ErrorMessage: string;
|
||||
constructor();
|
||||
}
|
||||
class ValidationFailure implements IError {
|
||||
public Error: IError;
|
||||
public IsAsync: boolean;
|
||||
constructor(Error: IError, IsAsync: boolean);
|
||||
public HasError : boolean;
|
||||
public ErrorMessage : string;
|
||||
public TranslateArgs : IErrorTranslateArgs;
|
||||
}
|
||||
class ValidationResult implements IValidationResult {
|
||||
public Name: string;
|
||||
constructor(Name: string);
|
||||
public IsDirty: boolean;
|
||||
public Children : IValidationResult[];
|
||||
public Add(error: IValidationResult): void;
|
||||
public Remove(index: number): void;
|
||||
public Optional: IOptional;
|
||||
public TranslateArgs: IErrorTranslateArgs[];
|
||||
public HasErrorsDirty : boolean;
|
||||
public HasErrors : boolean;
|
||||
public ErrorCount : number;
|
||||
public ErrorMessage : string;
|
||||
}
|
||||
class CompositeValidationResult implements IValidationResult {
|
||||
public Name: string;
|
||||
public Children: IValidationResult[];
|
||||
constructor(Name: string);
|
||||
public Optional: IOptional;
|
||||
public AddFirst(error: IValidationResult): void;
|
||||
public Add(error: IValidationResult): void;
|
||||
public Remove(index: number): void;
|
||||
public HasErrorsDirty : boolean;
|
||||
public HasErrors : boolean;
|
||||
public ErrorCount : number;
|
||||
public ErrorMessage : string;
|
||||
public TranslateArgs : IErrorTranslateArgs[];
|
||||
public LogErrors(headerMessage?: string): void;
|
||||
public Errors : {
|
||||
[name: string]: IValidationResult;
|
||||
};
|
||||
private FlattenErros;
|
||||
public SetDirty(): void;
|
||||
public SetPristine(): void;
|
||||
private SetDirtyEx(node, dirty);
|
||||
private flattenErrors(node, errorCollection);
|
||||
private traverse(node, indent);
|
||||
}
|
||||
class AbstractValidator<T> implements IAbstractValidator<T> {
|
||||
public Validators: {
|
||||
[name: string]: IPropertyValidator[];
|
||||
};
|
||||
public AbstractValidators: {
|
||||
[name: string]: IAbstractValidator<any>;
|
||||
};
|
||||
public ValidationFunctions: {
|
||||
[name: string]: IValidatorFce[];
|
||||
};
|
||||
public RuleFor(prop: string, validator: IPropertyValidator): void;
|
||||
public ValidationFor(prop: string, fce: IValidatorFce): void;
|
||||
public Validation(fce: IValidatorFce): void;
|
||||
public ValidatorFor<K>(prop: string, validator: IAbstractValidator<K>, forList?: boolean): void;
|
||||
public CreateAbstractRule(name: string): IAbstractValidationRule<T>;
|
||||
public CreateAbstractListRule(name: string): IAbstractValidationRule<T>;
|
||||
public CreateRule(name: string): IAbstractValidationRule<T>;
|
||||
public ForList: boolean;
|
||||
}
|
||||
class MessageLocalization {
|
||||
static customMsg: string;
|
||||
static defaultMessages: {
|
||||
"required": string;
|
||||
"remote": string;
|
||||
"email": string;
|
||||
"url": string;
|
||||
"date": string;
|
||||
"dateISO": string;
|
||||
"number": string;
|
||||
"digits": string;
|
||||
"signedDigits": string;
|
||||
"creditcard": string;
|
||||
"equalTo": string;
|
||||
"maxlength": string;
|
||||
"minlength": string;
|
||||
"rangelength": string;
|
||||
"range": string;
|
||||
"max": string;
|
||||
"min": string;
|
||||
"step": string;
|
||||
"contains": string;
|
||||
"mask": string;
|
||||
"custom": string;
|
||||
};
|
||||
static ValidationMessages: {
|
||||
"required": string;
|
||||
"remote": string;
|
||||
"email": string;
|
||||
"url": string;
|
||||
"date": string;
|
||||
"dateISO": string;
|
||||
"number": string;
|
||||
"digits": string;
|
||||
"signedDigits": string;
|
||||
"creditcard": string;
|
||||
"equalTo": string;
|
||||
"maxlength": string;
|
||||
"minlength": string;
|
||||
"rangelength": string;
|
||||
"range": string;
|
||||
"max": string;
|
||||
"min": string;
|
||||
"step": string;
|
||||
"contains": string;
|
||||
"mask": string;
|
||||
"custom": string;
|
||||
};
|
||||
static GetValidationMessage(validator: any): string;
|
||||
}
|
||||
export interface IErrorCustomMessage {
|
||||
(config: any, args: any): string;
|
||||
}
|
||||
export interface IPropertyValidator {
|
||||
isAcceptable(s: any): boolean;
|
||||
customMessage?: IErrorCustomMessage;
|
||||
tagName?: string;
|
||||
}
|
||||
export interface IStringValidator extends IPropertyValidator {
|
||||
isAcceptable(s: string): boolean;
|
||||
}
|
||||
export interface IAsyncPropertyValidator {
|
||||
isAcceptable(s: any): Q.Promise<boolean>;
|
||||
customMessage?: IErrorCustomMessage;
|
||||
isAsync: boolean;
|
||||
tagName?: string;
|
||||
}
|
||||
export interface IAsyncStringPropertyValidator extends IAsyncPropertyValidator {
|
||||
isAcceptable(s: string): Q.Promise<boolean>;
|
||||
}
|
||||
export enum CompareOperator {
|
||||
LessThan = 0,
|
||||
LessThanEqual = 1,
|
||||
Equal = 2,
|
||||
NotEqual = 3,
|
||||
GreaterThanEqual = 4,
|
||||
GreaterThan = 5,
|
||||
}
|
||||
export interface IError {
|
||||
HasError: boolean;
|
||||
ErrorMessage: string;
|
||||
TranslateArgs?: IErrorTranslateArgs;
|
||||
}
|
||||
export interface IErrorTranslateArgs {
|
||||
TranslateId: string;
|
||||
MessageArgs: any;
|
||||
CustomMessage?: IErrorCustomMessage;
|
||||
}
|
||||
export interface IOptional {
|
||||
(): boolean;
|
||||
}
|
||||
export interface IValidationFailure extends IError {
|
||||
IsAsync: boolean;
|
||||
Error: IError;
|
||||
}
|
||||
export interface IValidationResult {
|
||||
Name: string;
|
||||
Add(validationResult: IValidationResult): void;
|
||||
Remove(index: number): void;
|
||||
Children: IValidationResult[];
|
||||
HasErrors: boolean;
|
||||
HasErrorsDirty: boolean;
|
||||
ErrorMessage: string;
|
||||
ErrorCount: number;
|
||||
Optional?: IOptional;
|
||||
TranslateArgs?: IErrorTranslateArgs[];
|
||||
}
|
||||
export interface IValidate {
|
||||
(args: IError): void;
|
||||
}
|
||||
export interface IAsyncValidate {
|
||||
(args: IError): Q.Promise<any>;
|
||||
}
|
||||
export interface IValidatorFce {
|
||||
Name: string;
|
||||
ValidationFce?: IValidate;
|
||||
AsyncValidationFce?: IAsyncValidate;
|
||||
}
|
||||
export interface IValidator {
|
||||
Validate(context: any): IValidationFailure;
|
||||
ValidateAsync(context: any): Q.Promise<IValidationFailure>;
|
||||
Error: IError;
|
||||
}
|
||||
export interface IAbstractValidator<T> {
|
||||
RuleFor(prop: string, validator: IPropertyValidator): any;
|
||||
ValidationFor(prop: string, validatorFce: IValidatorFce): any;
|
||||
Validation(validatorFce: IValidatorFce): any;
|
||||
ValidatorFor<K>(prop: string, validator: IAbstractValidator<K>): any;
|
||||
CreateRule(name: string): IAbstractValidationRule<any>;
|
||||
CreateAbstractRule(name: string): IAbstractValidationRule<any>;
|
||||
CreateAbstractListRule(name: string): IAbstractValidationRule<any>;
|
||||
ForList: boolean;
|
||||
}
|
||||
export interface IAbstractValidationRule<T> {
|
||||
Validate(context: T): IValidationResult;
|
||||
ValidateAsync(context: T): Q.Promise<IValidationResult>;
|
||||
ValidateAll(context: T): Q.Promise<IValidationResult>;
|
||||
ValidateProperty(context: T, propName: string): void;
|
||||
ValidationResult: IValidationResult;
|
||||
Rules: {
|
||||
[name: string]: IPropertyValidationRule<T>;
|
||||
};
|
||||
Validators: {
|
||||
[name: string]: IValidator;
|
||||
};
|
||||
Children: {
|
||||
[name: string]: IAbstractValidationRule<any>;
|
||||
};
|
||||
}
|
||||
export interface IPropertyValidationRule<T> {
|
||||
Validators: {
|
||||
[name: string]: any;
|
||||
};
|
||||
Validate(context: IValidationContext<T>): IValidationFailure[];
|
||||
ValidateAsync(context: IValidationContext<T>): Q.Promise<IValidationFailure[]>;
|
||||
}
|
||||
export interface IValidationContext<T> {
|
||||
Value: string;
|
||||
Key: string;
|
||||
Data: T;
|
||||
}
|
||||
export class Error implements IError {
|
||||
public HasError: boolean;
|
||||
public ErrorMessage: string;
|
||||
constructor();
|
||||
}
|
||||
export class ValidationFailure implements IError {
|
||||
public Error: IError;
|
||||
public IsAsync: boolean;
|
||||
constructor(Error: IError, IsAsync: boolean);
|
||||
public HasError : boolean;
|
||||
public ErrorMessage : string;
|
||||
public TranslateArgs : IErrorTranslateArgs;
|
||||
}
|
||||
export class ValidationResult implements IValidationResult {
|
||||
public Name: string;
|
||||
constructor(Name: string);
|
||||
public IsDirty: boolean;
|
||||
public Children : IValidationResult[];
|
||||
public Add(error: IValidationResult): void;
|
||||
public Remove(index: number): void;
|
||||
public Optional: IOptional;
|
||||
public TranslateArgs: IErrorTranslateArgs[];
|
||||
public HasErrorsDirty : boolean;
|
||||
public HasErrors : boolean;
|
||||
public ErrorCount : number;
|
||||
public ErrorMessage : string;
|
||||
}
|
||||
export class CompositeValidationResult implements IValidationResult {
|
||||
public Name: string;
|
||||
public Children: IValidationResult[];
|
||||
constructor(Name: string);
|
||||
public Optional: IOptional;
|
||||
public AddFirst(error: IValidationResult): void;
|
||||
public Add(error: IValidationResult): void;
|
||||
public Remove(index: number): void;
|
||||
public HasErrorsDirty : boolean;
|
||||
public HasErrors : boolean;
|
||||
public ErrorCount : number;
|
||||
public ErrorMessage : string;
|
||||
public TranslateArgs : IErrorTranslateArgs[];
|
||||
public LogErrors(headerMessage?: string): void;
|
||||
public Errors : {
|
||||
[name: string]: IValidationResult;
|
||||
};
|
||||
private FlattenErros;
|
||||
public SetDirty(): void;
|
||||
public SetPristine(): void;
|
||||
private SetDirtyEx(node, dirty);
|
||||
private flattenErrors(node, errorCollection);
|
||||
private traverse(node, indent);
|
||||
}
|
||||
export class AbstractValidator<T> implements IAbstractValidator<T> {
|
||||
public Validators: {
|
||||
[name: string]: IPropertyValidator[];
|
||||
};
|
||||
public AbstractValidators: {
|
||||
[name: string]: IAbstractValidator<any>;
|
||||
};
|
||||
public ValidationFunctions: {
|
||||
[name: string]: IValidatorFce[];
|
||||
};
|
||||
public RuleFor(prop: string, validator: IPropertyValidator): void;
|
||||
public ValidationFor(prop: string, fce: IValidatorFce): void;
|
||||
public Validation(fce: IValidatorFce): void;
|
||||
public ValidatorFor<K>(prop: string, validator: IAbstractValidator<K>, forList?: boolean): void;
|
||||
public CreateAbstractRule(name: string): IAbstractValidationRule<T>;
|
||||
public CreateAbstractListRule(name: string): IAbstractValidationRule<T>;
|
||||
public CreateRule(name: string): IAbstractValidationRule<T>;
|
||||
public ForList: boolean;
|
||||
}
|
||||
export class MessageLocalization {
|
||||
static customMsg: string;
|
||||
static defaultMessages: {
|
||||
"required": string;
|
||||
"remote": string;
|
||||
"email": string;
|
||||
"url": string;
|
||||
"date": string;
|
||||
"dateISO": string;
|
||||
"number": string;
|
||||
"digits": string;
|
||||
"signedDigits": string;
|
||||
"creditcard": string;
|
||||
"equalTo": string;
|
||||
"maxlength": string;
|
||||
"minlength": string;
|
||||
"rangelength": string;
|
||||
"range": string;
|
||||
"max": string;
|
||||
"min": string;
|
||||
"step": string;
|
||||
"contains": string;
|
||||
"mask": string;
|
||||
"custom": string;
|
||||
};
|
||||
static ValidationMessages: {
|
||||
"required": string;
|
||||
"remote": string;
|
||||
"email": string;
|
||||
"url": string;
|
||||
"date": string;
|
||||
"dateISO": string;
|
||||
"number": string;
|
||||
"digits": string;
|
||||
"signedDigits": string;
|
||||
"creditcard": string;
|
||||
"equalTo": string;
|
||||
"maxlength": string;
|
||||
"minlength": string;
|
||||
"rangelength": string;
|
||||
"range": string;
|
||||
"max": string;
|
||||
"min": string;
|
||||
"step": string;
|
||||
"contains": string;
|
||||
"mask": string;
|
||||
"custom": string;
|
||||
};
|
||||
static GetValidationMessage(validator: any): string;
|
||||
}
|
||||
export = Validation;
|
||||
export as namespace Validation;
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
import * as CatboxMemory from 'catbox-memory';
|
||||
|
||||
const client = new CatboxMemory<string>({
|
||||
allowMixedContent: true,
|
||||
cloneBuffersOnGet: false,
|
||||
maxByteSize: 1024,
|
||||
minCleanupIntervalMsec: 1000,
|
||||
});
|
||||
Vendored
+47
@@ -0,0 +1,47 @@
|
||||
// Type definitions for catbox-memory 4.0
|
||||
// Project: https://github.com/hapijs/catbox-memory#readme
|
||||
// Definitions by: Simon Schick <https://github.com/SimonSchick>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import { ClientApi } from 'catbox';
|
||||
|
||||
interface CatboxMemory<T> extends ClientApi<T> {}
|
||||
|
||||
// tslint:disable-next-line:no-unnecessary-class
|
||||
declare class CatboxMemory<T> implements ClientApi<T> {
|
||||
constructor(options?: CatboxMemory.Options);
|
||||
}
|
||||
|
||||
declare namespace CatboxMemory {
|
||||
interface Options {
|
||||
/**
|
||||
* Sets an upper limit on the number of bytes that can be stored in the cache.
|
||||
* Once this limit is reached no additional items will be added to the cache until some expire.
|
||||
* The utilized memory calculation is a rough approximation and must not be relied on.
|
||||
* @default 104857600 (100MB).
|
||||
*/
|
||||
maxByteSize?: number;
|
||||
/**
|
||||
* The minimum number of milliseconds in between each cache cleanup.
|
||||
* @default 1000 (1 second)
|
||||
*/
|
||||
minCleanupIntervalMsec?: number;
|
||||
/**
|
||||
* by default, all data is cached as JSON strings, and converted to an object using JSON.parse() on retrieval.
|
||||
* By setting this option to true, Buffer data can be stored alongside the stringified data.
|
||||
* Buffers are not stringified, and are copied before storage to prevent the value from changing while in the cache.
|
||||
* @default false
|
||||
*/
|
||||
allowMixedContent?: boolean;
|
||||
/**
|
||||
* by default, buffers stored in the cache with allowMixedContent set to true are copied when they are set but not when they are retrieved.
|
||||
* This means a change to the buffer returned by a get() will change the value in the cache. To prevent this,
|
||||
* set cloneBuffersOnGet to true to always return a copy of the cached buffer.
|
||||
* @default false
|
||||
*/
|
||||
cloneBuffersOnGet?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
export = CatboxMemory;
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"catbox-memory-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
@@ -1 +1,6 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"no-angle-bracket-type-assertion": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,6 +67,10 @@ function test_disabled() {
|
||||
expect($('#foo')).to.be.disabled;
|
||||
}
|
||||
|
||||
function test_enabled() {
|
||||
expect($('#foo')).to.be.enabled;
|
||||
}
|
||||
|
||||
function test_empty() {
|
||||
$('.empty').should.be.empty;
|
||||
expect($('body')).not.to.be.empty;
|
||||
|
||||
Vendored
+1
@@ -25,6 +25,7 @@ declare namespace Chai {
|
||||
selected(): Assertion;
|
||||
checked(): Assertion;
|
||||
disabled(): Assertion;
|
||||
enabled(): Assertion;
|
||||
(selector: string): Assertion;
|
||||
}
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -3369,7 +3369,7 @@ declare namespace chrome {
|
||||
function chooseEntry(options: ChooseEntryOptionsBase, callback: FileEntryCallback<ChooseEntryOptionsBase>): void;
|
||||
function chooseEntry(options: ChooseFileEntryOptions, callback: FileEntryCallback<ChooseFileEntryOptions>): void;
|
||||
function chooseEntry(options: ChooseSaveFileEntryOptions, callback: FileEntryCallback<ChooseSaveFileEntryOptions>): void;
|
||||
function chooseEntry(options: ChooseMultipleFilesEntryOptions, callback: FileEntryCallback<ChooseFileEntryOptions>): void;
|
||||
function chooseEntry(options: ChooseMultipleFilesEntryOptions, callback: FileEntryCallback<ChooseMultipleFilesEntryOptions>): void;
|
||||
function chooseEntry(options: ChooseDirectoryEntryOptions, callback: FileEntryCallback<ChooseDirectoryEntryOptions>): void;
|
||||
/** Returns the file entry with the given id if it can be restored. This call will fail with a runtime error otherwise. */
|
||||
function restoreEntry(id: string, callback: (entry: FileEntry) => void): void;
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
"max-line-length": false,
|
||||
"member-access": false,
|
||||
"new-parens": false,
|
||||
"no-angle-bracket-type-assertion": false,
|
||||
"no-any-union": false,
|
||||
"no-boolean-literal-compare": false,
|
||||
"no-conditional-assignment": false,
|
||||
|
||||
@@ -914,6 +914,9 @@ function test_skin() {
|
||||
CKEDITOR.skin.loadPart('part', () => console.log('load'));
|
||||
|
||||
var path2: string = CKEDITOR.skin.path();
|
||||
|
||||
CKEDITOR.skin.ua_dialog = 'ie,iequirks,ie8,gecko';
|
||||
CKEDITOR.skin.ua_editor = 'ie,gecko';
|
||||
}
|
||||
|
||||
function test_style() {
|
||||
|
||||
Vendored
+3
@@ -2,6 +2,7 @@
|
||||
// Project: https://ckeditor.com/ckeditor-4/
|
||||
// Definitions by: Thomas Wittwer <https://github.com/wittwert>
|
||||
// Stuart Long <https://github.com/stuartlong>
|
||||
// Viktor Pegy <https://github.com/viktorpegy>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
// WORK-IN-PROGRESS: Any contribution support welcomed.
|
||||
@@ -2168,6 +2169,8 @@ declare namespace CKEDITOR {
|
||||
// tslint:disable-next-line:no-duplicate-variable
|
||||
var name: string;
|
||||
var ua: { [name: string]: any };
|
||||
var ua_dialog: string;
|
||||
var ua_editor: string;
|
||||
|
||||
function addIcon(name: string, path: string, offset?: number, bgsize?: string): void;
|
||||
function chameleon(editor: string, part: string): void;
|
||||
|
||||
@@ -0,0 +1,594 @@
|
||||
import * as utils from "ckeditor__ckeditor5-utils";
|
||||
|
||||
declare const document: Document;
|
||||
declare const locale: utils.Locale;
|
||||
declare let bool: boolean;
|
||||
declare let changes: utils.Change[];
|
||||
declare let emitter: utils.Emitter;
|
||||
declare let htmlElement: HTMLElement;
|
||||
declare let map: Map<string, number>;
|
||||
declare let num: number;
|
||||
declare let rect: utils.Rect;
|
||||
declare let rectOrNull: utils.Rect | null;
|
||||
declare let str: string;
|
||||
|
||||
// utils/dom
|
||||
|
||||
utils.createElement(document, "p");
|
||||
utils.createElement(document, "p", {class: "foo"});
|
||||
utils.createElement(document, "p", null, "foo");
|
||||
utils.createElement(document, "p", null, ["foo", utils.createElement(document, "img")]);
|
||||
|
||||
// TODO? utils/dom/emittermixin
|
||||
|
||||
utils.getAncestors(htmlElement);
|
||||
|
||||
utils.getBorderWidths(htmlElement);
|
||||
|
||||
utils.getCommonAncestor(htmlElement, htmlElement);
|
||||
|
||||
str = utils.getDataFromElement(htmlElement);
|
||||
|
||||
let strNull: HTMLElement | null = utils.getPositionedAncestor();
|
||||
strNull = utils.getPositionedAncestor(htmlElement);
|
||||
|
||||
num = utils.indexOf(htmlElement);
|
||||
|
||||
utils.insertAt(htmlElement, 2, htmlElement);
|
||||
|
||||
bool = utils.isNode(htmlElement);
|
||||
bool = utils.isNode(new Date());
|
||||
|
||||
bool = utils.isRange(new Range());
|
||||
bool = utils.isRange(new Date());
|
||||
|
||||
bool = utils.isText(new Text("foo"));
|
||||
bool = utils.isText(new Date());
|
||||
|
||||
bool = utils.isWindow(window);
|
||||
bool = utils.isWindow(new Date());
|
||||
|
||||
let position: utils.Position;
|
||||
|
||||
position = utils.getOptimalPosition({
|
||||
element: htmlElement,
|
||||
target: () => htmlElement,
|
||||
positions: [(targetRect, elementRect) => ({
|
||||
top: targetRect.top,
|
||||
left: targetRect.left + elementRect.width,
|
||||
name: "right"
|
||||
})]
|
||||
});
|
||||
|
||||
position = utils.getOptimalPosition({
|
||||
element: htmlElement,
|
||||
target: htmlElement,
|
||||
positions: [
|
||||
(targetRect) => ({
|
||||
top: targetRect.bottom,
|
||||
left: targetRect.left,
|
||||
name: "mySouthEastPosition"
|
||||
}),
|
||||
(targetRect, elementRect) => ({
|
||||
top: targetRect.top - elementRect.height,
|
||||
left: targetRect.left,
|
||||
name: "myNorthEastPosition"
|
||||
})
|
||||
],
|
||||
limiter: document.body,
|
||||
fitInViewport: true,
|
||||
});
|
||||
|
||||
rect = new utils.Rect(document.body);
|
||||
rect = new utils.Rect(document.getSelection()!.getRangeAt(0));
|
||||
rect = new utils.Rect(window);
|
||||
rect = new utils.Rect({top: 0, right: 10, bottom: 10, left: 0, width: 10, height: 10});
|
||||
rect = new utils.Rect(rect);
|
||||
rect = new utils.Rect(document.body.getClientRects().item(0)!);
|
||||
|
||||
rect = rect.clone();
|
||||
bool = rect.contains(rect);
|
||||
rect = rect.excludeScrollbarsAndBorders();
|
||||
num = rect.getArea();
|
||||
rect = rect.getIntersection(rect);
|
||||
num = rect.getIntersectionArea(rect);
|
||||
rectOrNull = rect.getVisible();
|
||||
bool = rect.isEqual(rect);
|
||||
rect = rect.moveBy(1, 1);
|
||||
rect = rect.moveTo(1, 1);
|
||||
|
||||
utils.remove(htmlElement);
|
||||
|
||||
utils.scrollAncestorsToShowTarget(new Range());
|
||||
utils.scrollAncestorsToShowTarget(htmlElement);
|
||||
|
||||
utils.scrollViewportToShowTarget({target: new Range()});
|
||||
utils.scrollViewportToShowTarget({target: htmlElement});
|
||||
utils.scrollViewportToShowTarget({target: new Range(), viewportOffset: 30});
|
||||
utils.scrollViewportToShowTarget({target: htmlElement, viewportOffset: 30});
|
||||
|
||||
utils.setDataInElement(htmlElement, "<b>foo</b>");
|
||||
|
||||
str = utils.toUnit("rem")(10);
|
||||
|
||||
// utils/ckeditorerror ========================================================
|
||||
|
||||
const regularError = new Error("foo");
|
||||
let ckeditorError: utils.CKEditorError;
|
||||
|
||||
const data = {bar: 1};
|
||||
ckeditorError = new utils.CKEditorError("foo");
|
||||
ckeditorError = new utils.CKEditorError("foo", data);
|
||||
|
||||
utils.CKEditorError.isCKEditorError(ckeditorError);
|
||||
utils.CKEditorError.isCKEditorError(regularError);
|
||||
|
||||
// utils/collection ===========================================================
|
||||
|
||||
interface Foo {
|
||||
foo: number;
|
||||
}
|
||||
|
||||
interface Props {
|
||||
id: string;
|
||||
}
|
||||
|
||||
interface PropsStr {
|
||||
id: string;
|
||||
name: string;
|
||||
}
|
||||
|
||||
declare let foo: Foo;
|
||||
let items: PropsStr[];
|
||||
let itemOrNull: Props | null;
|
||||
let itemOrUndef: Props | undefined;
|
||||
|
||||
const item1 = {id: "id1"};
|
||||
const item2 = {id: "id2"};
|
||||
const itemStr1 = {id: "foo", name: "yy"};
|
||||
const itemStr2 = {id: "foo", name: "xx"};
|
||||
|
||||
const coll = new utils.Collection<Props>();
|
||||
const collStr = new utils.Collection<PropsStr>({idProperty: "name"});
|
||||
|
||||
coll.add(item1);
|
||||
coll.add(item2);
|
||||
collStr.add(itemStr1);
|
||||
collStr.add(itemStr2);
|
||||
|
||||
coll.add(item1, 0);
|
||||
coll.add(item1).add(item2);
|
||||
|
||||
coll.clear();
|
||||
|
||||
items = collStr.filter((item) => item.name === "yy");
|
||||
items = collStr.filter((_, idx) => idx > 0);
|
||||
items = collStr.filter(function(this: Foo, _, idx) {return this.foo > 0 && idx === 0; }, foo);
|
||||
|
||||
itemOrUndef = collStr.find((item) => item.name === "yy");
|
||||
itemOrUndef = collStr.find((_, idx) => idx === 3);
|
||||
itemOrUndef = collStr.find(function(this: Foo, _, idx) {return this.foo > 0 && idx === 0; }, foo);
|
||||
|
||||
itemOrNull = coll.get(0);
|
||||
itemOrNull = coll.get("id1");
|
||||
|
||||
num = coll.getIndex("id1");
|
||||
num = coll.getIndex(item1);
|
||||
|
||||
coll.remove(0);
|
||||
coll.remove("id1");
|
||||
coll.remove(item1);
|
||||
|
||||
const strings: string[] = collStr.map((item) => item.name);
|
||||
const nums: number[] = collStr.map((_, idx) => idx);
|
||||
const bools: boolean[] = collStr.map(function(this: Foo, _, idx) {return this.foo === idx; }, foo);
|
||||
|
||||
// collection#bindTo
|
||||
|
||||
interface LabelObj {
|
||||
label: string;
|
||||
}
|
||||
|
||||
interface LabelValueObj {
|
||||
label: {value: string};
|
||||
}
|
||||
|
||||
interface HiddenObj {
|
||||
hidden: boolean;
|
||||
}
|
||||
|
||||
class FactoryClass {
|
||||
factoryLabel: string;
|
||||
constructor(data: LabelObj) {
|
||||
this.factoryLabel = data.label;
|
||||
}
|
||||
}
|
||||
|
||||
const source1 = new utils.Collection<LabelObj>({idProperty: "label"});
|
||||
const target1 = new utils.Collection<FactoryClass>();
|
||||
|
||||
target1.bindTo(source1).as(FactoryClass);
|
||||
|
||||
source1.add({label: "foo"});
|
||||
source1.add({label: "bar"});
|
||||
|
||||
source1.remove(0);
|
||||
console.log(target1.length);
|
||||
console.log(target1.get(0)!.factoryLabel);
|
||||
|
||||
class FooClass {
|
||||
fooLabel: string;
|
||||
constructor(data: LabelObj) {
|
||||
this.fooLabel = data.label;
|
||||
}
|
||||
}
|
||||
|
||||
class BarClass {
|
||||
barLabel: string;
|
||||
constructor(data: LabelObj) {
|
||||
this.barLabel = data.label;
|
||||
}
|
||||
}
|
||||
|
||||
const source2 = new utils.Collection<LabelObj>({idProperty: "label"});
|
||||
const target2 = new utils.Collection<FooClass | BarClass>();
|
||||
|
||||
target2.bindTo(source2).using((item) => {
|
||||
if (item.label === "foo") {
|
||||
return new FooClass(item);
|
||||
} else {
|
||||
return new BarClass(item);
|
||||
}
|
||||
});
|
||||
|
||||
source2.add({label: "foo"});
|
||||
source2.add({label: "bar"});
|
||||
|
||||
console.log(target2.length);
|
||||
console.log(target2.get(0)! instanceof FooClass);
|
||||
console.log(target2.get(1)! instanceof BarClass);
|
||||
|
||||
const source3 = new utils.Collection<LabelValueObj>({idProperty: "label"});
|
||||
const target3 = new utils.Collection<LabelValueObj["label"]>();
|
||||
|
||||
target3.bindTo(source2).using("label");
|
||||
|
||||
source3.add({label: {value: "foo"}});
|
||||
source3.add({label: {value: "bar"}});
|
||||
|
||||
console.log(target3.length);
|
||||
console.log(target3.get(0)!.value);
|
||||
console.log(target3.get(1)!.value);
|
||||
|
||||
const source4 = new utils.Collection<HiddenObj>();
|
||||
const target4 = new utils.Collection<HiddenObj | null>();
|
||||
|
||||
target4.bindTo(source4).using(item => {
|
||||
if (item.hidden) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return item;
|
||||
});
|
||||
|
||||
source4.add({hidden: true});
|
||||
source4.add({hidden: false});
|
||||
|
||||
// utils/comparearrays ========================================================
|
||||
|
||||
utils.compareArrays([0, 2], [0, 2, 1]);
|
||||
utils.compareArrays(["abc", 0 ], ["abc", 0, 3]);
|
||||
|
||||
// utils/config ===============================================================
|
||||
|
||||
let strOrUndef: string | undefined;
|
||||
let config: utils.Config;
|
||||
const defaultConfig = {
|
||||
foo: 1, bar: 2,
|
||||
};
|
||||
|
||||
config = new utils.Config();
|
||||
config = new utils.Config({foo: 10});
|
||||
config = new utils.Config({}, defaultConfig);
|
||||
config = new utils.Config({foo: 10}, defaultConfig);
|
||||
|
||||
config.define({
|
||||
resize: {
|
||||
minHeight: 400,
|
||||
hidden: true
|
||||
}
|
||||
});
|
||||
|
||||
config.define("resize", {minHeight: 400, hidden: true});
|
||||
config.define("language", "en");
|
||||
config.define("resize.minHeight", 400);
|
||||
|
||||
str = config.get("language");
|
||||
num = config.get("resize.minHeight");
|
||||
|
||||
config.define("language", undefined);
|
||||
strOrUndef = config.get("language");
|
||||
|
||||
// utils/count ================================================================
|
||||
|
||||
num = utils.count([1, 2, 3, 4, 5]);
|
||||
|
||||
// utils/diff =================================================================
|
||||
|
||||
changes = utils.diff("aba", "acca");
|
||||
changes = utils.diff(Array.from("aba"), Array.from("acca"));
|
||||
|
||||
// utils/difftochanges ========================================================
|
||||
|
||||
const input = Array.from("abc");
|
||||
const output = Array.from("xaby");
|
||||
const allChanges = utils.diffToChanges(utils.diff(input, output), output);
|
||||
allChanges.forEach(change => {
|
||||
if (change.type === "insert") {
|
||||
input.splice(change.index, 0, ...change.values);
|
||||
} else if (change.type === "delete") {
|
||||
input.splice(change.index, change.howMany);
|
||||
}
|
||||
});
|
||||
|
||||
// utils/elementreplacer ======================================================
|
||||
|
||||
const replacer = new utils.ElementReplacer();
|
||||
|
||||
replacer.replace(htmlElement, htmlElement);
|
||||
replacer.replace(htmlElement);
|
||||
|
||||
replacer.restore();
|
||||
|
||||
// utils/emittermixin
|
||||
|
||||
emitter = utils.EmitterMixin;
|
||||
emitter = Object.create(utils.EmitterMixin);
|
||||
|
||||
emitter.delegate("foo") ;
|
||||
emitter.delegate("foo", "bar");
|
||||
emitter.delegate("foo").to(emitter);
|
||||
emitter.delegate("foo").to(emitter, "bar");
|
||||
emitter.delegate("foo").to(emitter, name => name + "-delegated");
|
||||
|
||||
emitter.fire("foo");
|
||||
emitter.fire("foo", 1, "b", true);
|
||||
emitter.fire("getSelectedContent", (evt: utils.EventInfo<any>) => {
|
||||
evt.return = new DocumentFragment();
|
||||
evt.stop();
|
||||
});
|
||||
|
||||
emitter.listenTo(emitter, "foo", () => {});
|
||||
emitter.listenTo(emitter, "foo", () => {}, {priority: 10});
|
||||
emitter.listenTo(emitter, "foo", () => {}, {priority: "highest"});
|
||||
|
||||
emitter.off("foo");
|
||||
emitter.off("foo", () => {});
|
||||
|
||||
emitter.on("foo", () => {});
|
||||
emitter.on("foo", () => {}, {priority: 10});
|
||||
emitter.on("foo", () => {}, {priority: "normal"});
|
||||
|
||||
emitter.once("foo", () => {});
|
||||
emitter.once("foo", () => {}, {priority: 10});
|
||||
emitter.once("foo", () => {}, {priority: "lowest"});
|
||||
|
||||
emitter.stopDelegating();
|
||||
emitter.stopDelegating("foo");
|
||||
emitter.stopDelegating("foo", emitter);
|
||||
|
||||
emitter.stopListening();
|
||||
emitter.stopListening(emitter);
|
||||
emitter.stopListening(emitter, "foo");
|
||||
emitter.stopListening(emitter, "foo", () => {});
|
||||
|
||||
// utils/env ==================================================================
|
||||
|
||||
bool = utils.env.isEdge;
|
||||
bool = utils.env.isMac;
|
||||
|
||||
// utils/eventinfo ============================================================
|
||||
|
||||
const event = new utils.EventInfo({a: 1}, "test");
|
||||
num = event.source.a;
|
||||
str = event.name;
|
||||
|
||||
event.path[0];
|
||||
|
||||
event.stop();
|
||||
event.off();
|
||||
|
||||
bool = event.stop.called;
|
||||
bool = event.off.called;
|
||||
|
||||
// utils/fastdiff =============================================================
|
||||
|
||||
utils.fastDiff(str, "2ab").forEach(change => {
|
||||
if (change.type === "insert") {
|
||||
str = str.substring(0, change.index) + change.values.join("") + str.substring(change.index);
|
||||
} else if (change.type === "delete") {
|
||||
str = str.substring(0, change.index) + str.substring(change.index + change.howMany);
|
||||
}
|
||||
});
|
||||
|
||||
// utils/first ================================================================
|
||||
|
||||
const collection = [ 11, 22 ];
|
||||
const iterator = collection[Symbol.iterator]();
|
||||
|
||||
utils.first(iterator);
|
||||
|
||||
// utils/focustracker =========================================================
|
||||
|
||||
const focusTracker = new utils.FocusTracker();
|
||||
htmlElement = focusTracker.focusedElement;
|
||||
bool = focusTracker.isFocused;
|
||||
focusTracker.add(htmlElement);
|
||||
focusTracker.remove(htmlElement);
|
||||
|
||||
// utils/isiterable ===========================================================
|
||||
|
||||
bool = utils.isIterable(str);
|
||||
bool = utils.isIterable([1, 2, 3]);
|
||||
|
||||
// utils/keyboard =============================================================
|
||||
|
||||
num = utils.keyCodes.a;
|
||||
num = utils.keyCodes["a"];
|
||||
|
||||
num = utils.getCode("0");
|
||||
num = utils.getCode({keyCode: 48}) ;
|
||||
num = utils.getCode({keyCode: 48, altKey: true, ctrlKey: true, shiftKey: true});
|
||||
|
||||
str = utils.getEnvKeystrokeText("alt+A");
|
||||
|
||||
num = utils.parseKeystroke("Ctrl+A");
|
||||
num = utils.parseKeystroke(["ctrl", "a"]);
|
||||
num = utils.parseKeystroke(["shift", 33]);
|
||||
|
||||
// utils/keystrokehandler =====================================================
|
||||
|
||||
declare const keystroke: utils.KeystrokeInfo;
|
||||
const keystrokes = new utils.KeystrokeHandler();
|
||||
|
||||
const spy = utils.spy();
|
||||
keystrokes.set("Ctrl+A", spy);
|
||||
keystrokes.set(["Ctrl", "A"], spy);
|
||||
keystrokes.set(["Ctrl", "A"], spy, {priority: "high"});
|
||||
keystrokes.set(["Ctrl", 33], spy, {priority: 10});
|
||||
|
||||
const emitterMixxin = Object.create(utils.EmitterMixin) as utils.Emitter;
|
||||
keystrokes.listenTo(emitterMixxin);
|
||||
|
||||
bool = keystrokes.press(keystroke);
|
||||
|
||||
keystrokes.destroy();
|
||||
|
||||
// utils/locale ===============================================================
|
||||
|
||||
locale.t("Label");
|
||||
locale.t('Created file "%0" in %1ms.', ["fileName", "100"]);
|
||||
|
||||
// utils/log ==================================================================
|
||||
|
||||
utils.log.warn("message");
|
||||
utils.log.warn('plugin-load: It was not possible to load the "{$pluginName}" plugin in module "{$moduleName}', {
|
||||
pluginName: "foo",
|
||||
moduleName: "bar"
|
||||
});
|
||||
|
||||
utils.log.error("message");
|
||||
utils.log.error('plugin-load: It was not possible to load the "{$pluginName}" plugin in module "{$moduleName}', {
|
||||
pluginName: "foo",
|
||||
moduleName: "bar"
|
||||
});
|
||||
|
||||
// utils/mapsequal ============================================================
|
||||
|
||||
utils.mapsEqual(map, map);
|
||||
|
||||
// utils/mix ==================================================================
|
||||
|
||||
class Editor {
|
||||
b: () => number;
|
||||
}
|
||||
|
||||
interface SomeMixin {
|
||||
a: () => string;
|
||||
}
|
||||
|
||||
const SomeMixin = {
|
||||
a() {
|
||||
return "a";
|
||||
}
|
||||
};
|
||||
|
||||
utils.mix(Editor, SomeMixin);
|
||||
const mixEditor = new Editor() as Editor & SomeMixin;
|
||||
mixEditor.a();
|
||||
mixEditor.b();
|
||||
|
||||
// utils/nth ==================================================================
|
||||
|
||||
function* getGenerator() {
|
||||
yield 11;
|
||||
yield 22;
|
||||
yield 33;
|
||||
}
|
||||
|
||||
utils.nth(2, getGenerator());
|
||||
|
||||
// utils/objecttomap ==========================================================
|
||||
|
||||
const objMap: Map<string, number> = utils.objectToMap({foo: 1, bar: 2});
|
||||
num = objMap.get("foo")!;
|
||||
|
||||
// utils/observablemixin ======================================================
|
||||
|
||||
const observable: utils.Observable = utils.ObservableMixin;
|
||||
|
||||
const vehicle = Object.create(utils.ObservableMixin) as utils.Observable;
|
||||
const car = Object.create(utils.ObservableMixin) as utils.Observable;
|
||||
|
||||
vehicle.bind("color");
|
||||
vehicle.bind("color", "year");
|
||||
vehicle.bind("color", "year").to(car);
|
||||
vehicle.bind("color", "year").to(car, "color");
|
||||
vehicle.bind("color", "year").to(car, "color", car, "year");
|
||||
vehicle.bind("year").to(car, "color", car, "year", (a: string, b: number) => a + b);
|
||||
vehicle.bind("custom").to(car, "color", car, "year", car, "hue", (...args: Array<string | number>) => args.join("/")); // TS 3.0: [string, number, string]
|
||||
vehicle.bind("color").toMany([car, car], "color", () => {});
|
||||
|
||||
vehicle.decorate("method");
|
||||
|
||||
car.set("color", "red");
|
||||
car.set("seats", undefined);
|
||||
car.set({
|
||||
color: "blue",
|
||||
wheels: 4,
|
||||
seats: 5,
|
||||
});
|
||||
|
||||
vehicle.unbind();
|
||||
vehicle.unbind("color");
|
||||
vehicle.unbind("color", "year");
|
||||
|
||||
// utils/priorities ===========================================================
|
||||
|
||||
num = utils.priorities.get(2);
|
||||
num = utils.priorities.get("normal");
|
||||
|
||||
// utils/spy
|
||||
|
||||
const fn1 = utils.spy();
|
||||
fn1();
|
||||
bool = fn1.called;
|
||||
|
||||
// utils/tomap
|
||||
|
||||
map = utils.toMap({foo: 1, bar: 2});
|
||||
map = utils.toMap([["foo", 1], ["bar", 2]]);
|
||||
map = utils.toMap(map);
|
||||
|
||||
// utils/translation-service ==================================================
|
||||
|
||||
utils.add("pl", {
|
||||
OK: "OK",
|
||||
"Cancel [context: reject]": "Anuluj"
|
||||
});
|
||||
|
||||
utils.translate("pl", "Cancel [context: reject]");
|
||||
|
||||
// utils/uid ==================================================================
|
||||
|
||||
str = utils.uid();
|
||||
|
||||
// utils/unicode ==============================================================
|
||||
|
||||
bool = utils.isCombiningMark("a");
|
||||
bool = utils.isHighSurrogateHalf("a");
|
||||
bool = utils.isInsideCombinedSymbol(str, 2);
|
||||
bool = utils.isInsideSurrogatePair(str, 2);
|
||||
bool = utils.isLowSurrogateHalf(String.fromCharCode(57166));
|
||||
|
||||
// utils/version ==============================================================
|
||||
+471
@@ -0,0 +1,471 @@
|
||||
// Type definitions for @ckeditor/ckeditor5-utils 10.2
|
||||
// Project: https://github.com/ckeditor/ckeditor5-utils
|
||||
// Definitions by: denisname <https://github.com/denisname>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
// Helpers
|
||||
|
||||
export interface DeleteChange {
|
||||
index: number;
|
||||
type: "delete";
|
||||
howMany: number;
|
||||
}
|
||||
|
||||
export interface InsertChange {
|
||||
index: number;
|
||||
type: "insert";
|
||||
values: string[];
|
||||
}
|
||||
|
||||
export interface BindChain {
|
||||
to(observable: Observable, ...bindProperties: Array<Observable | string | Function>): void;
|
||||
toMany(observable: Observable[], ...bindProperties: Array<Observable | string | Function>): void;
|
||||
}
|
||||
|
||||
export interface CollectionBindTo<T, K> {
|
||||
as: (Class: {new(item: T): K}) => void;
|
||||
using: (callbackOrProperty: keyof T | ((item: T) => K)) => void;
|
||||
}
|
||||
|
||||
// utils/dom
|
||||
|
||||
export function createElement(doc: Document, name: string, attributes?: object | null, children?: Node | string | Array<Node | string>): Element;
|
||||
|
||||
// TODO? utils/dom/emittermixin
|
||||
|
||||
export function getAncestors(node: Node): Array<Node | DocumentFragment>;
|
||||
|
||||
export function getBorderWidths(element: HTMLElement): {top: number, right: number, bottom: number, left: number};
|
||||
|
||||
export function getCommonAncestor(nodeA: Node, nodeB: Node): Node | DocumentFragment | Document | null;
|
||||
|
||||
export function getDataFromElement(el: HTMLElement): string;
|
||||
|
||||
export function getPositionedAncestor(element?: HTMLElement): HTMLElement | null;
|
||||
|
||||
export function indexOf(node: Node): number;
|
||||
|
||||
export function insertAt(parentElement: Element, index: number, nodeToInsert: Node): void;
|
||||
|
||||
export function isNode(obj: any): obj is Node;
|
||||
|
||||
export function isRange(obj: any): obj is Range;
|
||||
|
||||
export function isText(obj: any): obj is Text;
|
||||
|
||||
export function isWindow(obj: any): obj is Window;
|
||||
|
||||
export interface Options {
|
||||
element: HTMLElement;
|
||||
fitInViewport?: boolean;
|
||||
limiter?: HTMLElement | Range | ClientRect | Rect | (() => HTMLElement | Range | ClientRect | Rect);
|
||||
positions: Array<(targetRect: Rect, elementRect: Rect) => Position>;
|
||||
target: HTMLElement | Range | ClientRect | Rect | (() => HTMLElement | Range | ClientRect | Rect);
|
||||
}
|
||||
|
||||
export interface Position {
|
||||
left: number;
|
||||
name: string;
|
||||
top: number;
|
||||
}
|
||||
|
||||
export function getOptimalPosition(options: Options): Position;
|
||||
|
||||
export class Rect {
|
||||
readonly bottom: number;
|
||||
readonly height: number;
|
||||
readonly left: number;
|
||||
readonly right: number;
|
||||
readonly top: number;
|
||||
readonly width: number;
|
||||
|
||||
constructor(source: HTMLElement | Range | Window | ClientRect | Rect | object);
|
||||
clone(): Rect;
|
||||
contains(anotherRect: Rect): boolean;
|
||||
excludeScrollbarsAndBorders(): Rect;
|
||||
getArea(): number;
|
||||
getIntersection(anotherRect: Rect): Rect;
|
||||
getIntersectionArea(anotherRect: Rect): number;
|
||||
getVisible(): Rect | null;
|
||||
isEqual(rect: Rect): boolean;
|
||||
moveBy(x: number, y: number): Rect;
|
||||
moveTo(x: number, y: number): Rect;
|
||||
|
||||
static getDomRangeRects(range: Range): Rect[];
|
||||
}
|
||||
|
||||
export function remove(node: Node): void;
|
||||
|
||||
export function scrollAncestorsToShowTarget(target: HTMLElement | Range): void;
|
||||
|
||||
export function scrollViewportToShowTarget(options: {target: HTMLElement | Range, viewportOffset?: number}): void;
|
||||
|
||||
export function setDataInElement(el: HTMLElement, data: string): void;
|
||||
|
||||
export function toUnit(unit: string): (value: number) => string;
|
||||
|
||||
// utils/ckeditorerror
|
||||
|
||||
export const DOCUMENTATION_URL: string;
|
||||
|
||||
export class CKEditorError extends Error {
|
||||
data: object | undefined;
|
||||
name: string;
|
||||
|
||||
constructor(message: string, data?: object);
|
||||
|
||||
static isCKEditorError(error: Error): boolean;
|
||||
}
|
||||
|
||||
export function attachLinkToDocumentation(message: string): string;
|
||||
|
||||
// utils/collection
|
||||
|
||||
export function as(Class: Function): void;
|
||||
export function using(callbackOrProperty: Function | string): void;
|
||||
|
||||
export class Collection<T> implements Iterable<T>, Emitter {
|
||||
first: T | null;
|
||||
last: T | null;
|
||||
length: number;
|
||||
|
||||
constructor(options?: {idProperty?: keyof T});
|
||||
add(item: T, index?: number): this;
|
||||
bindTo<S>(externalCollection: Collection<S>): CollectionBindTo<S, T>;
|
||||
clear(): void;
|
||||
filter(callbackfn: (item: T, index: number) => boolean, thisArg?: any): T[];
|
||||
find(predicate: (item: T, index: number) => boolean, thisArg?: any): T | undefined;
|
||||
get(idOrIndex: string | number): T | null;
|
||||
getIndex(idOrItem: string | T): number;
|
||||
map<U>(callbackfn: (item: T, index: number) => U, thisArg?: any): U[];
|
||||
remove(subject: T | number | string): T;
|
||||
|
||||
// Iterable<T>
|
||||
[Symbol.iterator](): Iterator<T>;
|
||||
|
||||
// Emitter
|
||||
delegate(...events: string[]): EmitterMixinDelegateChain;
|
||||
fire(eventOrInfo: string | EventInfo<Emitter>, ...args: any[]): any;
|
||||
listenTo(emitter: Emitter, event: string, callback: Function, options?: {priority?: PriorityString | number }): void;
|
||||
off(event: string, callback?: Function): void;
|
||||
on(event: string, callback: Function, options?: {priority: PriorityString | number}): void;
|
||||
once(event: string, callback: Function, options?: {priority: PriorityString | number}): void;
|
||||
stopDelegating(event?: string, emitter?: Emitter): void;
|
||||
stopListening(emitter?: Emitter, event?: string, callback?: Function): void;
|
||||
}
|
||||
|
||||
// utils/comparearrays
|
||||
|
||||
export type ArrayRelation = "extension" | "same" | "prefix";
|
||||
|
||||
export function compareArrays<T>(a: ReadonlyArray<T>, b: ReadonlyArray<T>): number | ArrayRelation;
|
||||
|
||||
// utils/config
|
||||
|
||||
export class Config {
|
||||
constructor(configurations?: object, defaultConfigurations?: object);
|
||||
define(name: object): void;
|
||||
define(name: string, value: any): void;
|
||||
get(name: string): any /*| undefined*/;
|
||||
set(name: string, value: any /*| undefined*/): void;
|
||||
}
|
||||
|
||||
// utils/count
|
||||
|
||||
export function count(iterator: Iterable<any>): number;
|
||||
|
||||
// utils/diff
|
||||
|
||||
export type Change = "equal" | "insert" | "delete";
|
||||
|
||||
export function diff(a: string, b: string, cmp?: (a: string, b: string) => boolean): Change[];
|
||||
export function diff(a: ReadonlyArray<string>, b: ReadonlyArray<string>, cmp?: (a: string, b: string) => boolean): Change[];
|
||||
|
||||
// utils/difftochanges
|
||||
|
||||
export function diffToChanges(diff: Change[], output: string | string[]): Array<DeleteChange | InsertChange>;
|
||||
|
||||
// utils/elementreplacer
|
||||
|
||||
export class ElementReplacer {
|
||||
replace(element: HTMLElement, newElement?: HTMLElement): void;
|
||||
restore(): void;
|
||||
}
|
||||
|
||||
// utils/emittermixin
|
||||
|
||||
export const EmitterMixin: Emitter;
|
||||
|
||||
export interface Emitter {
|
||||
delegate(...events: string[]): EmitterMixinDelegateChain;
|
||||
fire(eventOrInfo: string | EventInfo<Emitter>, ...args: any[]): any;
|
||||
listenTo(emitter: Emitter, event: string, callback: Function, options?: {priority?: PriorityString | number }): void;
|
||||
off(event: string, callback?: Function): void;
|
||||
on(event: string, callback: Function, options?: {priority: PriorityString | number}): void;
|
||||
once(event: string, callback: Function, options?: {priority: PriorityString | number}): void;
|
||||
stopDelegating(event?: string, emitter?: Emitter): void;
|
||||
stopListening(emitter?: Emitter, event?: string, callback?: Function): void;
|
||||
}
|
||||
|
||||
export interface EmitterMixinDelegateChain {
|
||||
to(emitter: Emitter, nameOrFunction?: string | ((name: string) => string)): void;
|
||||
}
|
||||
|
||||
// utils/env
|
||||
|
||||
export namespace env {
|
||||
const isEdge: boolean;
|
||||
const isMac: boolean;
|
||||
}
|
||||
|
||||
// utils/eventinfo
|
||||
|
||||
export class EventInfo<T> {
|
||||
readonly name: string;
|
||||
readonly path: object[];
|
||||
return: any /*| undefined*/;
|
||||
readonly source: T;
|
||||
|
||||
constructor(source: T, name: string);
|
||||
off: {
|
||||
(): void;
|
||||
called: boolean;
|
||||
};
|
||||
stop: {
|
||||
(): void;
|
||||
called: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
// utils/fastdiff
|
||||
|
||||
export function fastDiff(oldText: string, newText: string): Array<DeleteChange | InsertChange>;
|
||||
|
||||
// utils/first
|
||||
|
||||
export function first<T>(iterable: Iterable<T>): T;
|
||||
|
||||
// utils/focustracker
|
||||
|
||||
export class FocusTracker implements Observable {
|
||||
readonly focusedElement: HTMLElement;
|
||||
readonly isFocused: boolean;
|
||||
|
||||
add(element: HTMLElement): void;
|
||||
remove(element: HTMLElement): void;
|
||||
|
||||
// Observable
|
||||
bind(...bindProperties: string[]): BindChain;
|
||||
decorate(methodName: string): void;
|
||||
set(name: object): void;
|
||||
set(name: string, value: any): void;
|
||||
unbind(...unbindProperties: string[]): void;
|
||||
|
||||
// Observable (Emitter)
|
||||
delegate(...events: string[]): EmitterMixinDelegateChain;
|
||||
fire(eventOrInfo: string | EventInfo<Emitter>, ...args: any[]): any;
|
||||
listenTo(emitter: Emitter, event: string, callback: Function, options?: {priority?: PriorityString | number }): void;
|
||||
off(event: string, callback?: Function): void;
|
||||
on(event: string, callback: Function, options?: {priority: PriorityString | number}): void;
|
||||
once(event: string, callback: Function, options?: {priority: PriorityString | number}): void;
|
||||
stopDelegating(event?: string, emitter?: Emitter): void;
|
||||
stopListening(emitter?: Emitter, event?: string, callback?: Function): void;
|
||||
}
|
||||
|
||||
// utils/isiterable
|
||||
|
||||
export function isIterable(value: any): value is Iterable<any>;
|
||||
|
||||
// utils/keyboard
|
||||
|
||||
export const keyCodes: {
|
||||
a: 65,
|
||||
b: 66,
|
||||
c: 67;
|
||||
d: 68;
|
||||
e: 69;
|
||||
f: 70;
|
||||
g: 71;
|
||||
h: 72;
|
||||
i: 73;
|
||||
j: 74;
|
||||
k: 75;
|
||||
l: 76;
|
||||
m: 77;
|
||||
n: 78;
|
||||
o: 79;
|
||||
p: 80;
|
||||
q: 81;
|
||||
r: 82;
|
||||
s: 83;
|
||||
t: 84;
|
||||
u: 85;
|
||||
v: 86;
|
||||
w: 87;
|
||||
x: 88;
|
||||
y: 89;
|
||||
z: 90;
|
||||
|
||||
0: 48;
|
||||
1: 49;
|
||||
2: 50;
|
||||
3: 51;
|
||||
4: 52;
|
||||
5: 53;
|
||||
6: 54;
|
||||
7: 55;
|
||||
8: 56;
|
||||
9: 57;
|
||||
|
||||
f1: 112;
|
||||
f2: 113;
|
||||
f3: 114;
|
||||
f4: 115;
|
||||
f5: 116;
|
||||
f6: 117;
|
||||
f7: 118;
|
||||
f8: 118;
|
||||
f9: 120;
|
||||
f10: 121;
|
||||
f11: 122;
|
||||
f12: 123;
|
||||
|
||||
arrowleft: 37,
|
||||
arrowup: 38,
|
||||
arrowright: 39,
|
||||
arrowdown: 40,
|
||||
backspace: 8,
|
||||
"delete": 46,
|
||||
enter: 13,
|
||||
space: 32,
|
||||
esc: 27,
|
||||
tab: 9,
|
||||
ctrl: 0x110000,
|
||||
cmd: 0x110000,
|
||||
shift: 0x220000,
|
||||
alt: 0x440000
|
||||
};
|
||||
|
||||
export interface KeystrokeInfo {
|
||||
altKey?: boolean;
|
||||
ctrlKey?: boolean;
|
||||
keyCode: number;
|
||||
shiftKey?: boolean;
|
||||
}
|
||||
|
||||
export function getCode(key: string | KeystrokeInfo): number;
|
||||
|
||||
export function getEnvKeystrokeText(keystroke: string): string;
|
||||
|
||||
export function parseKeystroke(keystroke: string | Array<number | string>): number;
|
||||
|
||||
// utils/keystrokehandler
|
||||
|
||||
export class KeystrokeHandler {
|
||||
constructor();
|
||||
destroy(): void;
|
||||
listenTo(emitter: Emitter): void;
|
||||
press(keyEvtData: KeystrokeInfo): boolean;
|
||||
set(keystroke: string | Array<string | number>, callback: Function, options?: {priority?: PriorityString | number}): void;
|
||||
}
|
||||
|
||||
// utils/locale
|
||||
|
||||
export class Locale {
|
||||
readonly language: string;
|
||||
|
||||
constructor(language?: string);
|
||||
t(str: string, values?: string[]): string;
|
||||
}
|
||||
|
||||
// utils/log
|
||||
|
||||
export namespace log {
|
||||
function error(message: string, data?: object): void;
|
||||
function warn(message: string, data?: object): void;
|
||||
}
|
||||
|
||||
// utils/mapsequal
|
||||
|
||||
export function mapsEqual<K, V>(mapsA: Map<K, V>, mapsB: Map<K, V>): boolean;
|
||||
|
||||
// utils/mix
|
||||
|
||||
export function mix(baseClass: {new(): any}, ...mixins: any[]): void;
|
||||
|
||||
// utils/nth
|
||||
|
||||
export function nth<T>(index: number, iterable: Iterable<T>): T;
|
||||
|
||||
// utils/objecttomap
|
||||
|
||||
export function objectToMap<T extends object>(obj: T): Map<keyof T, T[keyof T]>;
|
||||
|
||||
// utils/observablemixin
|
||||
|
||||
export const ObservableMixin: Observable;
|
||||
|
||||
export interface Observable extends Emitter {
|
||||
bind(...bindProperties: string[]): BindChain;
|
||||
decorate(methodName: string): void;
|
||||
set(name: object): void;
|
||||
set(name: string, value: any): void;
|
||||
unbind(...unbindProperties: string[]): void;
|
||||
|
||||
// Emitter
|
||||
delegate(...events: string[]): EmitterMixinDelegateChain;
|
||||
fire(eventOrInfo: string | EventInfo<Emitter>, ...args: any[]): any;
|
||||
listenTo(emitter: Emitter, event: string, callback: Function, options?: {priority?: PriorityString | number }): void;
|
||||
off(event: string, callback?: Function): void;
|
||||
on(event: string, callback: Function, options?: {priority: PriorityString | number}): void;
|
||||
once(event: string, callback: Function, options?: {priority: PriorityString | number}): void;
|
||||
stopDelegating(event?: string, emitter?: Emitter): void;
|
||||
stopListening(emitter?: Emitter, event?: string, callback?: Function): void;
|
||||
}
|
||||
|
||||
// utils/priorities
|
||||
|
||||
export namespace priorities {
|
||||
function get(priority: PriorityString | number): number;
|
||||
}
|
||||
|
||||
export type PriorityString = "highest" | "high" | "normal" | "low" | "lowest";
|
||||
|
||||
// utils/spy
|
||||
|
||||
export function spy(): {(): void; called: boolean};
|
||||
|
||||
// utils/tomap
|
||||
|
||||
export function toMap<K, V>(data: Map<K, V>): Map<K, V>;
|
||||
export function toMap<K extends string, V = any>(data: ReadonlyArray<[K, V]>): Map<K, V>;
|
||||
export function toMap<T extends object>(data: T): Map<keyof T, T[keyof T]>;
|
||||
|
||||
// utils/translation-service
|
||||
|
||||
export function add(language: string, translations: {[key: string]: string}): void;
|
||||
|
||||
export function translate(language: string, translationKey: string): string;
|
||||
|
||||
// TODO: CKEDITOR_TRANSLATIONS
|
||||
|
||||
// utils/uid
|
||||
|
||||
export function uid(): string;
|
||||
|
||||
// utils/unicode
|
||||
|
||||
export function isCombiningMark(character: string): boolean;
|
||||
|
||||
export function isHighSurrogateHalf(character: string): boolean;
|
||||
|
||||
export function isInsideCombinedSymbol(string: string, offset: number): boolean;
|
||||
|
||||
export function isInsideSurrogatePair(string: string, offset: number): boolean;
|
||||
|
||||
export function isLowSurrogateHalf(character: string): boolean;
|
||||
|
||||
// utils/version
|
||||
|
||||
// TODO: CKEDITOR_VERSION;
|
||||
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"ckeditor__ckeditor5-utils-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"ban-types": {
|
||||
"options": [
|
||||
["Object", "Avoid using the `Object` type. Did you mean `object`?"],
|
||||
["Boolean", "Avoid using the `Boolean` type. Did you mean `boolean`?"],
|
||||
["Number", "Avoid using the `Number` type. Did you mean `number`?"],
|
||||
["String", "Avoid using the `String` type. Did you mean `string`?"],
|
||||
["Symbol", "Avoid using the `Symbol` type. Did you mean `symbol`?"]
|
||||
]
|
||||
},
|
||||
"quotemark": [
|
||||
true,
|
||||
"double",
|
||||
"avoid-escape",
|
||||
"avoid-template"
|
||||
]
|
||||
}
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
// Type definitions for CodeMirror
|
||||
// Project: https://github.com/marijnh/CodeMirror
|
||||
// Definitions by: Nikolaj Kappler <https://github.com/nkappler>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
// See docs https://codemirror.net/doc/manual.html#addon_comment
|
||||
|
||||
// Todo: add 'toggleComment' command, once command type definitions exist in main definitions
|
||||
|
||||
import * as CodeMirror from "codemirror";
|
||||
|
||||
declare module "codemirror" {
|
||||
|
||||
interface Editor {
|
||||
/** Tries to uncomment the current selection, and if that fails, line-comments it. */
|
||||
toggleComment(options?: CommentOptions): void;
|
||||
/** Set the lines in the given range to be line comments. Will fall back to `blockComment` when no line comment style is defined for the mode. */
|
||||
lineComment(from: Position, to: Position, options?: CommentOptions): void;
|
||||
/** Wrap the code in the given range in a block comment. Will fall back to `lineComment` when no block comment style is defined for the mode. */
|
||||
blockComment(from: Position, to: Position, options?: CommentOptions): void;
|
||||
/** Try to uncomment the given range. Returns `true` if a comment range was found and removed, `false` otherwise. */
|
||||
uncomment(from: Position, to: Position, options?: CommentOptions): boolean;
|
||||
}
|
||||
|
||||
interface CommentOptions {
|
||||
/** Override the [comment string properties](https://codemirror.net/doc/manual.html#mode_comment) of the mode with custom comment strings. */
|
||||
blockCommentStart?: string;
|
||||
/** Override the [comment string properties](https://codemirror.net/doc/manual.html#mode_comment) of the mode with custom comment strings. */
|
||||
blockCommentEnd?: string;
|
||||
/** Override the [comment string properties](https://codemirror.net/doc/manual.html#mode_comment) of the mode with custom comment strings. */
|
||||
blockCommentLead?: string;
|
||||
/** Override the [comment string properties](https://codemirror.net/doc/manual.html#mode_comment) of the mode with custom comment strings. */
|
||||
lineComment?: string;
|
||||
/** A string that will be inserted after opening and leading markers, and before closing comment markers. Defaults to a single space. */
|
||||
padding?: string;
|
||||
/** Whether, when adding line comments, to also comment lines that contain only whitespace. */
|
||||
commentBlankLines?: boolean;
|
||||
/** When adding line comments and this is turned on, it will align the comment block to the current indentation of the first line of the block. */
|
||||
indent?: boolean;
|
||||
/** When block commenting, this controls whether the whole lines are indented, or only the precise range that is given. Defaults to `true`. */
|
||||
fullLines?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
declare module "codemirror/addon/comment/comment" {
|
||||
export = CodeMirror;
|
||||
}
|
||||
Vendored
+25
@@ -4,6 +4,7 @@
|
||||
// nrbernard <https://github.com/nrbernard>
|
||||
// Pr1st0n <https://github.com/Pr1st0n>
|
||||
// rileymiller <https://github.com/rileymiller>
|
||||
// toddself <https://github.com/toddself>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export = CodeMirror;
|
||||
@@ -669,6 +670,11 @@ declare namespace CodeMirror {
|
||||
/** Returns an array containing all marked ranges in the document. */
|
||||
getAllMarks(): CodeMirror.TextMarker[];
|
||||
|
||||
/** Adds a line widget, an element shown below a line, spanning the whole of the editor's width, and moving the lines below it downwards.
|
||||
line should be either an integer or a line handle, and node should be a DOM node, which will be displayed below the given line.
|
||||
options, when given, should be an object that configures the behavior of the widget.
|
||||
Note that the widget node will become a descendant of nodes with CodeMirror-specific CSS classes, and those classes might in some cases affect it. */
|
||||
addLineWidget(line: any, node: HTMLElement, options?: CodeMirror.LineWidgetOptions): CodeMirror.LineWidget;
|
||||
|
||||
/** Gets the mode object for the editor. Note that this is distinct from getOption("mode"), which gives you the mode specification,
|
||||
rather than the resolved, instantiated mode object. */
|
||||
@@ -706,8 +712,27 @@ declare namespace CodeMirror {
|
||||
or undefined if the marker is no longer in the document. */
|
||||
find(): {from: CodeMirror.Position, to: CodeMirror.Position};
|
||||
|
||||
/** Called when you've done something that might change the size of the marker and want to cheaply update the display*/
|
||||
changed(): void;
|
||||
|
||||
/** Returns an object representing the options for the marker. If copyWidget is given true, it will clone the value of the replacedWith option, if any. */
|
||||
getOptions(copyWidget: boolean): CodeMirror.TextMarkerOptions;
|
||||
|
||||
/** Fired when the cursor enters the marked range */
|
||||
on(eventName: 'beforeCursorEnter', handler: () => void) : void;
|
||||
off(eventName: 'beforeCursorEnter', handler: () => void) : void;
|
||||
|
||||
/** Fired when the range is cleared, either through cursor movement in combination with clearOnEnter or through a call to its clear() method */
|
||||
on(eventName: 'clear', handler: (from: Position, to: Position) => void) : void;
|
||||
off(eventName: 'clear', handler: () => void) : void;
|
||||
|
||||
/** Fired when the last part of the marker is removed from the document by editing operations */
|
||||
on(eventName: 'hide', handler: () => void) : void;
|
||||
off(eventname: 'hide', handler: () => void) : void;
|
||||
|
||||
/** Fired when, after the marker was removed by editing, a undo operation brough the marker back */
|
||||
on(eventName: 'unhide', handler: () => void) : void;
|
||||
off(eventname: 'unhide', handler: () => void) : void;
|
||||
}
|
||||
|
||||
interface LineWidget {
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
const editor = CodeMirror(document.body);
|
||||
const position: CodeMirror.Position = { ch: 0, line: 0 };
|
||||
const opt: CodeMirror.CommentOptions = {
|
||||
blockCommentEnd: "*/",
|
||||
blockCommentStart: "/*",
|
||||
blockCommentLead: "*",
|
||||
commentBlankLines: true,
|
||||
fullLines: true,
|
||||
indent: true,
|
||||
lineComment: "//",
|
||||
padding: " "
|
||||
};
|
||||
editor.toggleComment(opt);
|
||||
editor.blockComment(position, position, opt);
|
||||
editor.lineComment(position, position, opt);
|
||||
const b: boolean = editor.uncomment(position, position, opt);
|
||||
@@ -91,3 +91,12 @@ CodeMirror.registerHelper("lint", "javascript", {});
|
||||
|
||||
myCodeMirror.isReadOnly();
|
||||
myCodeMirror.execCommand('selectAll');
|
||||
|
||||
let htmlElement1 = document.createElement('div');
|
||||
let htmlElement2 = document.createElement('div');
|
||||
let widget1 = myCodeMirror.addLineWidget(1, htmlElement1, {});
|
||||
let widget2 = doc.addLineWidget(1, htmlElement2, {});
|
||||
widget1.clear();
|
||||
widget2.clear();
|
||||
htmlElement1.remove();
|
||||
htmlElement2.remove();
|
||||
|
||||
@@ -23,12 +23,14 @@
|
||||
"codemirror-panel.d.ts",
|
||||
"codemirror-runmode.d.ts",
|
||||
"codemirror-showhint.d.ts",
|
||||
"codemirror-comment.d.ts",
|
||||
"searchcursor.d.ts",
|
||||
"test/index.ts",
|
||||
"test/matchbrackets.ts",
|
||||
"test/panel.ts",
|
||||
"test/runmode.ts",
|
||||
"test/searchcursor.ts",
|
||||
"test/showhint.ts"
|
||||
"test/showhint.ts",
|
||||
"test/comment.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
import compareFunc = require("compare-func");
|
||||
|
||||
// This is taken from https://github.com/stevemao/compare-func/blob/master/README.md#usage and extended
|
||||
|
||||
// sort by an object property
|
||||
[{ x: "b" }, { x: "a" }, { x: "c" }].sort(compareFunc("x"));
|
||||
// => [{x: "a"}, {x: "b"}, {x: "c"}]
|
||||
|
||||
// sort by a nested object property
|
||||
[{ x: { y: "b" } }, { x: { y: "a" } }].sort(compareFunc("x.y"));
|
||||
// => [{x: {y: "a"}}, {x: {y: "b"}}]
|
||||
|
||||
// sort by the `x` property, then `y`
|
||||
[{ x: "c", y: "c" }, { x: "b", y: "a" }, { x: "b", y: "b" }].sort(compareFunc(["x", "y"]));
|
||||
// => [{x: "b", y: "a"}, {x: "b", y: "b"}, {x: "c", y: "c"}]
|
||||
|
||||
// sort by the returned value
|
||||
[{ x: "b" }, { x: "a" }, { x: "c" }].sort(compareFunc((el) => el.x));
|
||||
// => [{x: "a"}, {x: "b"}, {x: "c"}]
|
||||
|
||||
// sort by an array of functions
|
||||
[{ x: "c", y: "c" }, { x: "b", y: "a" }, { x: "b", y: "b" }].sort(compareFunc([
|
||||
(el) => el.x,
|
||||
(el) => el.y,
|
||||
]));
|
||||
// => [{x: "a"}, {x: "b"}, {x: "c"}]
|
||||
|
||||
// sort by itself
|
||||
[1, 3, 2].sort(compareFunc());
|
||||
// => [1, 2, 3]
|
||||
Vendored
+12
@@ -0,0 +1,12 @@
|
||||
// Type definitions for compare-func 1.3
|
||||
// Project: https://github.com/stevemao/compare-func
|
||||
// Definitions by: Dogan Fennibay <https://github.com/fennibay>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.4
|
||||
|
||||
type extractFunc<T> = (e: T) => number | string;
|
||||
|
||||
declare function compare_func<T>(prop?: ReadonlyArray<string | extractFunc<T>> | string | extractFunc<T>):
|
||||
(e1: T, e2: T) => number;
|
||||
|
||||
export = compare_func;
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"compare-func-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -1 +1,6 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"no-angle-bracket-type-assertion": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
"max-line-length": false,
|
||||
"member-access": false,
|
||||
"new-parens": false,
|
||||
"no-angle-bracket-type-assertion": false,
|
||||
"no-any-union": false,
|
||||
"no-boolean-literal-compare": false,
|
||||
"no-conditional-assignment": false,
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
"max-line-length": false,
|
||||
"member-access": false,
|
||||
"new-parens": false,
|
||||
"no-angle-bracket-type-assertion": false,
|
||||
"no-any-union": false,
|
||||
"no-boolean-literal-compare": false,
|
||||
"no-conditional-assignment": false,
|
||||
|
||||
@@ -7,4 +7,8 @@ new Critters({
|
||||
preloadFonts: true,
|
||||
keyframes: 'critical',
|
||||
noscriptFallback: true,
|
||||
inlineThreshold: 0,
|
||||
mergeStylesheets: true,
|
||||
pruneSource: true,
|
||||
minimumExternalSize: 0,
|
||||
});
|
||||
|
||||
+21
-1
@@ -1,4 +1,4 @@
|
||||
// Type definitions for critters-webpack-plugin 1.3
|
||||
// Type definitions for critters-webpack-plugin 2.0
|
||||
// Project: https://github.com/GoogleChromeLabs/critters
|
||||
// Definitions by: Juan José González Giraldo <https://github.com/JuanJoseGonGi>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
@@ -18,6 +18,26 @@ declare namespace Critters {
|
||||
* @default true
|
||||
*/
|
||||
external?: boolean;
|
||||
/**
|
||||
* Inline external stylesheets smaller than a given size.
|
||||
* @default 0
|
||||
*/
|
||||
inlineThreshold?: number;
|
||||
/**
|
||||
* If the non-critical external stylesheet would be below this size, just inline it.
|
||||
* @default 0
|
||||
*/
|
||||
minimumExternalSize?: number;
|
||||
/**
|
||||
* Remove inlined rules from the external stylesheet.
|
||||
* @default true
|
||||
*/
|
||||
pruneSource?: boolean;
|
||||
/**
|
||||
* Merged inlined stylesheets into a single <style> tag.
|
||||
* @default true
|
||||
*/
|
||||
mergeStylesheets?: boolean;
|
||||
/**
|
||||
* The mechanism to use for lazy-loading stylesheets. [JS] indicates that a strategy requires JavaScript (falls back to <noscript>).
|
||||
* - default: Move stylesheet links to the end of the document and insert preload meta tags in their place.
|
||||
|
||||
@@ -1 +1,6 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"no-angle-bracket-type-assertion": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,612 @@
|
||||
import * as csstree from "css-tree";
|
||||
|
||||
const ast = csstree.parse('.a { color: red; }');
|
||||
ast; // $ExpectType CssNode
|
||||
|
||||
csstree.parse('.a { color: red; }', {}); // $ExpectType CssNode
|
||||
csstree.parse('.a { color: red; }', {context: 'selector', positions: true}); // $ExpectType CssNode
|
||||
|
||||
csstree.walk(ast, (node, item, list) => {
|
||||
node; // $ExpectType CssNode
|
||||
item; // $ExpectType ListItem<CssNode>
|
||||
list; // $ExpectType List<CssNode>
|
||||
});
|
||||
|
||||
csstree.walk(ast, {});
|
||||
|
||||
csstree.walk(ast, {
|
||||
enter(node, item, list) {
|
||||
this.stylesheet; // $ExpectType StyleSheet
|
||||
node; // $ExpectType CssNode
|
||||
item; // $ExpectType ListItem<CssNode>
|
||||
list; // $ExpectType List<CssNode>
|
||||
},
|
||||
leave(node, item, list) {
|
||||
this.stylesheet; // $ExpectType StyleSheet
|
||||
node; // $ExpectType CssNode
|
||||
item; // $ExpectType ListItem<CssNode>
|
||||
list; // $ExpectType List<CssNode>
|
||||
},
|
||||
visit: 'ClassSelector',
|
||||
reverse: false,
|
||||
});
|
||||
|
||||
csstree.generate(ast); // $ExpectType string
|
||||
|
||||
csstree.generate(ast, {}); // $ExpectType string
|
||||
|
||||
csstree.generate(ast, {
|
||||
sourceMap: true,
|
||||
decorator: handlers => ({
|
||||
children(node, delimiter) {
|
||||
node; // $ExpectType CssNode
|
||||
delimiter; // $ExpectType ((node: CssNode) => void) | undefined
|
||||
handlers.children.call(handlers, node, delimiter);
|
||||
},
|
||||
node(node) {
|
||||
node; // $ExpectType CssNode
|
||||
handlers.node.call(node);
|
||||
},
|
||||
chunk(chunk) {
|
||||
chunk; // $ExpectType string
|
||||
handlers.chunk.call(chunk);
|
||||
},
|
||||
result() {
|
||||
return handlers.result.call(handlers);
|
||||
}
|
||||
}),
|
||||
});
|
||||
|
||||
const property = csstree.property('*-vendor-property');
|
||||
property.name = 'test'; // $ExpectError
|
||||
|
||||
const keyword = csstree.keyword('-vendor-keyword');
|
||||
keyword.name = 'test'; // $ExpectError
|
||||
|
||||
csstree.clone(ast); // $ExpectType CssNode
|
||||
|
||||
const fromPlain = csstree.fromPlainObject({
|
||||
type: 'SelectorList',
|
||||
children: []
|
||||
});
|
||||
fromPlain; // $ExpectType CssNode
|
||||
|
||||
const toPlain = csstree.toPlainObject({
|
||||
type: 'SelectorList',
|
||||
children: new csstree.List<csstree.CssNode>(),
|
||||
});
|
||||
toPlain; // $ExpectType CssNodePlain
|
||||
|
||||
interface Test {
|
||||
a: string;
|
||||
}
|
||||
|
||||
const list = new csstree.List<Test>();
|
||||
|
||||
const anItem = list.createItem({a: 'c'});
|
||||
anItem; // $ExpectType ListItem<Test>
|
||||
|
||||
list.fromArray([{a: 'b'}]);
|
||||
list.toArray(); // $ExpectType Test[]
|
||||
list.getSize(); // $ExpectType number
|
||||
list.isEmpty(); // $ExpectType boolean
|
||||
list.first(); // $ExpectType Test | null
|
||||
list.last(); // $ExpectType Test | null
|
||||
list.each(function(item, node, list) {
|
||||
this.b; // $ExpectType string
|
||||
item; // $ExpectType Test
|
||||
node; // $ExpectType ListItem<Test>
|
||||
list; // $ExpectType List<Test>
|
||||
}, {b: 'c'});
|
||||
list.each(function(item, node, list) {
|
||||
this; // $ExpectType List<Test>
|
||||
item; // $ExpectType Test
|
||||
node; // $ExpectType ListItem<Test>
|
||||
list; // $ExpectType List<Test>
|
||||
});
|
||||
list.forEach(function(item, node, list) {
|
||||
this.b; // $ExpectType string
|
||||
item; // $ExpectType Test
|
||||
node; // $ExpectType ListItem<Test>
|
||||
list; // $ExpectType List<Test>
|
||||
}, {b: 'c'});
|
||||
list.forEach(function(item, node, list) {
|
||||
this; // $ExpectType List<Test>
|
||||
item; // $ExpectType Test
|
||||
node; // $ExpectType ListItem<Test>
|
||||
list; // $ExpectType List<Test>
|
||||
});
|
||||
list.eachRight(function(item, node, list) {
|
||||
this.b; // $ExpectType string
|
||||
item; // $ExpectType Test
|
||||
node; // $ExpectType ListItem<Test>
|
||||
list; // $ExpectType List<Test>
|
||||
}, {b: 'c'});
|
||||
list.eachRight(function(item, node, list) {
|
||||
this; // $ExpectType List<Test>
|
||||
item; // $ExpectType Test
|
||||
node; // $ExpectType ListItem<Test>
|
||||
list; // $ExpectType List<Test>
|
||||
});
|
||||
list.forEachRight(function(item, node, list) {
|
||||
this.b; // $ExpectType string
|
||||
item; // $ExpectType Test
|
||||
node; // $ExpectType ListItem<Test>
|
||||
list; // $ExpectType List<Test>
|
||||
}, {b: 'c'});
|
||||
list.forEachRight(function(item, node, list) {
|
||||
this; // $ExpectType List<Test>
|
||||
item; // $ExpectType Test
|
||||
node; // $ExpectType ListItem<Test>
|
||||
list; // $ExpectType List<Test>
|
||||
});
|
||||
list.nextUntil(anItem, function(item, node, list) {
|
||||
this.b; // $ExpectType string
|
||||
item; // $ExpectType Test
|
||||
node; // $ExpectType ListItem<Test>
|
||||
list; // $ExpectType List<Test>
|
||||
return true;
|
||||
}, {b: 'c'});
|
||||
list.nextUntil(anItem, function(item, node, list) {
|
||||
this; // $ExpectType List<Test>
|
||||
item; // $ExpectType Test
|
||||
node; // $ExpectType ListItem<Test>
|
||||
list; // $ExpectType List<Test>
|
||||
return true;
|
||||
});
|
||||
list.prevUntil(anItem, function(item, node, list) {
|
||||
this.b; // $ExpectType string
|
||||
item; // $ExpectType Test
|
||||
node; // $ExpectType ListItem<Test>
|
||||
list; // $ExpectType List<Test>
|
||||
return true;
|
||||
}, {b: 'c'});
|
||||
list.prevUntil(anItem, function(item, node, list) {
|
||||
this; // $ExpectType List<Test>
|
||||
item; // $ExpectType Test
|
||||
node; // $ExpectType ListItem<Test>
|
||||
list; // $ExpectType List<Test>
|
||||
return true;
|
||||
});
|
||||
list.some(function(item, node, list) {
|
||||
this.b; // $ExpectType string
|
||||
item; // $ExpectType Test
|
||||
node; // $ExpectType ListItem<Test>
|
||||
list; // $ExpectType List<Test>
|
||||
return true;
|
||||
}, {b: 'c'});
|
||||
list.some(function(item, node, list) {
|
||||
this; // $ExpectType List<Test>
|
||||
item; // $ExpectType Test
|
||||
node; // $ExpectType ListItem<Test>
|
||||
list; // $ExpectType List<Test>
|
||||
return true;
|
||||
});
|
||||
const map1 = list.map(function(item, node, list) {
|
||||
this.b; // $ExpectType string
|
||||
item; // $ExpectType Test
|
||||
node; // $ExpectType ListItem<Test>
|
||||
list; // $ExpectType List<Test>
|
||||
return { c: 'd' };
|
||||
}, {b: 'c'});
|
||||
map1; // $ExpectType List<{ c: string; }>
|
||||
const map2 = list.map(function(item, node, list) {
|
||||
this; // $ExpectType List<Test>
|
||||
item; // $ExpectType Test
|
||||
node; // $ExpectType ListItem<Test>
|
||||
list; // $ExpectType List<Test>
|
||||
return { c: 'd' };
|
||||
});
|
||||
map2; // $ExpectType List<{ c: string; }>
|
||||
|
||||
const list2 = new csstree.List<Test | null>();
|
||||
|
||||
const filter1 = list2.filter(function(item, node, list): item is Test {
|
||||
this.b; // $ExpectType string
|
||||
item; // $ExpectType Test | null
|
||||
node; // $ExpectType ListItem<Test | null>
|
||||
list; // $ExpectType List<Test | null>
|
||||
return !!item;
|
||||
}, {b: 'c'});
|
||||
filter1; // $ExpectType List<Test>
|
||||
const filter2 = list2.filter(function(item, node, list): item is Test {
|
||||
this; // $ExpectType List<Test | null>
|
||||
item; // $ExpectType Test | null
|
||||
node; // $ExpectType ListItem<Test | null>
|
||||
list; // $ExpectType List<Test | null>
|
||||
return !!item;
|
||||
});
|
||||
filter2; // $ExpectType List<Test>
|
||||
const filter3 = list2.filter(function(item, node, list) {
|
||||
this.b; // $ExpectType string
|
||||
item; // $ExpectType Test | null
|
||||
node; // $ExpectType ListItem<Test | null>
|
||||
list; // $ExpectType List<Test | null>
|
||||
return true;
|
||||
}, {b: 'c'});
|
||||
filter3; // $ExpectType List<Test | null>
|
||||
const filter4 = list2.filter(function(item, node, list) {
|
||||
this; // $ExpectType List<Test | null>
|
||||
item; // $ExpectType Test | null
|
||||
node; // $ExpectType ListItem<Test | null>
|
||||
list; // $ExpectType List<Test | null>
|
||||
return true;
|
||||
});
|
||||
filter4; // $ExpectType List<Test | null>
|
||||
|
||||
list.clear();
|
||||
list.copy(); // $ExpectType List<Test>
|
||||
list.prepend(anItem); // $ExpectType List<Test>
|
||||
list.prependData({a: 'b'}); // $ExpectType List<Test>
|
||||
list.append(anItem); // $ExpectType List<Test>
|
||||
list.appendData({a: 'b'}); // $ExpectType List<Test>
|
||||
list.insert(anItem, anItem); // $ExpectType List<Test>
|
||||
list.insertData({a: 'b'}, anItem); // $ExpectType List<Test>
|
||||
list.remove(anItem); // $ExpectType ListItem<Test>
|
||||
list.push({a: 'b'}); // $ExpectType void
|
||||
list.pop(); // $ExpectType ListItem<Test> | undefined
|
||||
list.unshift({a: 'b'}); // $ExpectType void
|
||||
list.shift(); // $ExpectType ListItem<Test> | undefined
|
||||
list.prependList(list); // $ExpectType List<Test>
|
||||
list.appendList(list); // $ExpectType List<Test>
|
||||
list.insertList(list, anItem); // $ExpectType List<Test>
|
||||
list.replace(anItem, list); // $ExpectType List<Test>
|
||||
list.replace(anItem, anItem); // $ExpectType List<Test>
|
||||
|
||||
switch (ast.type) {
|
||||
case 'AnPlusB':
|
||||
ast.a; // $ExpectType string | null
|
||||
ast.b; // $ExpectType string | null
|
||||
break;
|
||||
|
||||
case 'Atrule':
|
||||
ast.name; // $ExpectType string
|
||||
ast.prelude; // $ExpectType AtrulePrelude | Raw | null
|
||||
ast.block; // $ExpectType Block | null
|
||||
break;
|
||||
|
||||
case 'AtrulePrelude':
|
||||
ast.children; // $ExpectType List<CssNode>
|
||||
break;
|
||||
|
||||
case 'AttributeSelector':
|
||||
ast.name; // $ExpectType Identifier
|
||||
ast.matcher; // $ExpectType string | null
|
||||
ast.value; // $ExpectType Identifier | StringNode | null
|
||||
ast.flags; // $ExpectType string | null
|
||||
break;
|
||||
|
||||
case 'Block':
|
||||
ast.children; // $ExpectType List<CssNode>
|
||||
break;
|
||||
|
||||
case 'Brackets':
|
||||
ast.children; // $ExpectType List<CssNode>
|
||||
break;
|
||||
|
||||
case 'CDC':
|
||||
break;
|
||||
|
||||
case 'CDO':
|
||||
break;
|
||||
|
||||
case 'ClassSelector':
|
||||
ast.name; // $ExpectType string
|
||||
break;
|
||||
|
||||
case 'Combinator':
|
||||
ast.name; // $ExpectType string
|
||||
break;
|
||||
|
||||
case 'Comment':
|
||||
ast.value; // $ExpectType string
|
||||
break;
|
||||
|
||||
case 'Declaration':
|
||||
ast.important; // $ExpectType string | boolean
|
||||
ast.property; // $ExpectType string
|
||||
ast.value; // $ExpectType Raw | Value
|
||||
break;
|
||||
|
||||
case 'DeclarationList':
|
||||
ast.children; // $ExpectType List<CssNode>
|
||||
break;
|
||||
|
||||
case 'Dimension':
|
||||
ast.value; // $ExpectType string
|
||||
ast.unit; // $ExpectType string
|
||||
break;
|
||||
|
||||
case 'Function':
|
||||
ast.name; // $ExpectType string
|
||||
ast.children; // $ExpectType List<CssNode>
|
||||
break;
|
||||
|
||||
case 'HexColor':
|
||||
ast.value; // $ExpectType string
|
||||
break;
|
||||
|
||||
case 'IdSelector':
|
||||
ast.name; // $ExpectType string
|
||||
break;
|
||||
|
||||
case 'Identifier':
|
||||
ast.name; // $ExpectType string
|
||||
break;
|
||||
|
||||
case 'MediaFeature':
|
||||
ast.name; // $ExpectType string
|
||||
ast.value; // $ExpectType Dimension | Identifier | NumberNode | Ratio | null
|
||||
break;
|
||||
|
||||
case 'MediaQuery':
|
||||
ast.children; // $ExpectType List<CssNode>
|
||||
break;
|
||||
|
||||
case 'MediaQueryList':
|
||||
ast.children; // $ExpectType List<CssNode>
|
||||
break;
|
||||
|
||||
case 'Nth':
|
||||
ast.nth; // $ExpectType AnPlusB | Identifier
|
||||
ast.selector; // $ExpectType SelectorList | null
|
||||
break;
|
||||
|
||||
case 'Number':
|
||||
ast.value; // $ExpectType string
|
||||
break;
|
||||
|
||||
case 'Operator':
|
||||
ast.value; // $ExpectType string
|
||||
break;
|
||||
|
||||
case 'Parentheses':
|
||||
ast.children; // $ExpectType List<CssNode>
|
||||
break;
|
||||
|
||||
case 'Percentage':
|
||||
ast.value; // $ExpectType string
|
||||
break;
|
||||
|
||||
case 'PseudoClassSelector':
|
||||
ast.name; // $ExpectType string
|
||||
ast.children; // $ExpectType List<CssNode> | null
|
||||
break;
|
||||
|
||||
case 'PseudoElementSelector':
|
||||
ast.name; // $ExpectType string
|
||||
ast.children; // $ExpectType List<CssNode> | null
|
||||
break;
|
||||
|
||||
case 'Ratio':
|
||||
ast.left; // $ExpectType string
|
||||
ast.right; // $ExpectType string
|
||||
break;
|
||||
|
||||
case 'Raw':
|
||||
ast.value; // $ExpectType string
|
||||
break;
|
||||
|
||||
case 'Rule':
|
||||
ast.prelude; // $ExpectType Raw | SelectorList
|
||||
ast.block; // $ExpectType Block
|
||||
break;
|
||||
|
||||
case 'Selector':
|
||||
ast.children; // $ExpectType List<CssNode>
|
||||
break;
|
||||
|
||||
case 'SelectorList':
|
||||
ast.children; // $ExpectType List<CssNode>
|
||||
break;
|
||||
|
||||
case 'String':
|
||||
ast.value; // $ExpectType string
|
||||
break;
|
||||
|
||||
case 'StyleSheet':
|
||||
ast.children; // $ExpectType List<CssNode>
|
||||
break;
|
||||
|
||||
case 'TypeSelector':
|
||||
ast.name; // $ExpectType string
|
||||
break;
|
||||
|
||||
case 'UnicodeRange':
|
||||
ast.value; // $ExpectType string
|
||||
break;
|
||||
|
||||
case 'Url':
|
||||
ast.value; // $ExpectType Raw | StringNode
|
||||
break;
|
||||
|
||||
case 'Value':
|
||||
ast.children; // $ExpectType List<CssNode>
|
||||
break;
|
||||
|
||||
case 'WhiteSpace':
|
||||
ast.value; // $ExpectType string
|
||||
break;
|
||||
|
||||
default:
|
||||
ast; // $ExpectType never
|
||||
}
|
||||
|
||||
switch (toPlain.type) {
|
||||
case 'AnPlusB':
|
||||
toPlain.a; // $ExpectType string | null
|
||||
toPlain.b; // $ExpectType string | null
|
||||
break;
|
||||
|
||||
case 'Atrule':
|
||||
toPlain.name; // $ExpectType string
|
||||
toPlain.prelude; // $ExpectType Raw | AtrulePreludePlain | null
|
||||
toPlain.block; // $ExpectType BlockPlain | null
|
||||
break;
|
||||
|
||||
case 'AtrulePrelude':
|
||||
toPlain.children; // $ExpectType CssNodePlain[]
|
||||
break;
|
||||
|
||||
case 'AttributeSelector':
|
||||
toPlain.name; // $ExpectType Identifier
|
||||
toPlain.matcher; // $ExpectType string | null
|
||||
toPlain.value; // $ExpectType Identifier | StringNode | null
|
||||
toPlain.flags; // $ExpectType string | null
|
||||
break;
|
||||
|
||||
case 'Block':
|
||||
toPlain.children; // $ExpectType CssNodePlain[]
|
||||
break;
|
||||
|
||||
case 'Brackets':
|
||||
toPlain.children; // $ExpectType CssNodePlain[]
|
||||
break;
|
||||
|
||||
case 'CDC':
|
||||
break;
|
||||
|
||||
case 'CDO':
|
||||
break;
|
||||
|
||||
case 'ClassSelector':
|
||||
toPlain.name; // $ExpectType string
|
||||
break;
|
||||
|
||||
case 'Combinator':
|
||||
toPlain.name; // $ExpectType string
|
||||
break;
|
||||
|
||||
case 'Comment':
|
||||
toPlain.value; // $ExpectType string
|
||||
break;
|
||||
|
||||
case 'Declaration':
|
||||
toPlain.important; // $ExpectType string | boolean
|
||||
toPlain.property; // $ExpectType string
|
||||
toPlain.value; // $ExpectType Raw | ValuePlain
|
||||
break;
|
||||
|
||||
case 'DeclarationList':
|
||||
toPlain.children; // $ExpectType CssNodePlain[]
|
||||
break;
|
||||
|
||||
case 'Dimension':
|
||||
toPlain.value; // $ExpectType string
|
||||
toPlain.unit; // $ExpectType string
|
||||
break;
|
||||
|
||||
case 'Function':
|
||||
toPlain.name; // $ExpectType string
|
||||
toPlain.children; // $ExpectType CssNodePlain[]
|
||||
break;
|
||||
|
||||
case 'HexColor':
|
||||
toPlain.value; // $ExpectType string
|
||||
break;
|
||||
|
||||
case 'IdSelector':
|
||||
toPlain.name; // $ExpectType string
|
||||
break;
|
||||
|
||||
case 'Identifier':
|
||||
toPlain.name; // $ExpectType string
|
||||
break;
|
||||
|
||||
case 'MediaFeature':
|
||||
toPlain.name; // $ExpectType string
|
||||
toPlain.value; // $ExpectType Dimension | Identifier | NumberNode | Ratio | null
|
||||
break;
|
||||
|
||||
case 'MediaQuery':
|
||||
toPlain.children; // $ExpectType CssNodePlain[]
|
||||
break;
|
||||
|
||||
case 'MediaQueryList':
|
||||
toPlain.children; // $ExpectType CssNodePlain[]
|
||||
break;
|
||||
|
||||
case 'Nth':
|
||||
toPlain.nth; // $ExpectType AnPlusB | Identifier
|
||||
toPlain.selector; // $ExpectType SelectorListPlain | null
|
||||
break;
|
||||
|
||||
case 'Number':
|
||||
toPlain.value; // $ExpectType string
|
||||
break;
|
||||
|
||||
case 'Operator':
|
||||
toPlain.value; // $ExpectType string
|
||||
break;
|
||||
|
||||
case 'Parentheses':
|
||||
toPlain.children; // $ExpectType CssNodePlain[]
|
||||
break;
|
||||
|
||||
case 'Percentage':
|
||||
toPlain.value; // $ExpectType string
|
||||
break;
|
||||
|
||||
case 'PseudoClassSelector':
|
||||
toPlain.name; // $ExpectType string
|
||||
toPlain.children; // $ExpectType CssNodePlain[] | null
|
||||
break;
|
||||
|
||||
case 'PseudoElementSelector':
|
||||
toPlain.name; // $ExpectType string
|
||||
toPlain.children; // $ExpectType CssNodePlain[] | null
|
||||
break;
|
||||
|
||||
case 'Ratio':
|
||||
toPlain.left; // $ExpectType string
|
||||
toPlain.right; // $ExpectType string
|
||||
break;
|
||||
|
||||
case 'Raw':
|
||||
toPlain.value; // $ExpectType string
|
||||
break;
|
||||
|
||||
case 'Rule':
|
||||
toPlain.prelude; // $ExpectType Raw | SelectorListPlain
|
||||
toPlain.block; // $ExpectType BlockPlain
|
||||
break;
|
||||
|
||||
case 'Selector':
|
||||
toPlain.children; // $ExpectType CssNodePlain[]
|
||||
break;
|
||||
|
||||
case 'SelectorList':
|
||||
toPlain.children; // $ExpectType CssNodePlain[]
|
||||
break;
|
||||
|
||||
case 'String':
|
||||
toPlain.value; // $ExpectType string
|
||||
break;
|
||||
|
||||
case 'StyleSheet':
|
||||
toPlain.children; // $ExpectType CssNodePlain[]
|
||||
break;
|
||||
|
||||
case 'TypeSelector':
|
||||
toPlain.name; // $ExpectType string
|
||||
break;
|
||||
|
||||
case 'UnicodeRange':
|
||||
toPlain.value; // $ExpectType string
|
||||
break;
|
||||
|
||||
case 'Url':
|
||||
toPlain.value; // $ExpectType Raw | StringNode
|
||||
break;
|
||||
|
||||
case 'Value':
|
||||
toPlain.children; // $ExpectType CssNodePlain[]
|
||||
break;
|
||||
|
||||
case 'WhiteSpace':
|
||||
toPlain.value; // $ExpectType string
|
||||
break;
|
||||
|
||||
default:
|
||||
toPlain; // $ExpectType never
|
||||
}
|
||||
Vendored
+565
@@ -0,0 +1,565 @@
|
||||
// Type definitions for css-tree 1.0
|
||||
// Project: https://github.com/csstree/csstree
|
||||
// Definitions by: Erik Källén <https://github.com/erik-kallen>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.7
|
||||
|
||||
export interface CssLocation {
|
||||
source: string;
|
||||
start: {
|
||||
offset: number;
|
||||
line: number;
|
||||
column: number
|
||||
};
|
||||
end: {
|
||||
offset: number;
|
||||
line: number;
|
||||
column: number
|
||||
};
|
||||
}
|
||||
|
||||
export interface ListItem<TData> {
|
||||
prev: ListItem<TData> | null;
|
||||
next: ListItem<TData> | null;
|
||||
data: TData;
|
||||
}
|
||||
|
||||
export type IteratorFn<TData, TResult, TContext = List<TData>> = (this: TContext, item: TData, node: ListItem<TData>, list: List<TData>) => TResult;
|
||||
export type FilterFn<TData, TResult extends TData, TContext = List<TData>> = (this: TContext, item: TData, node: ListItem<TData>, list: List<TData>) => item is TResult;
|
||||
|
||||
export class List<TData> {
|
||||
constructor();
|
||||
fromArray(array: TData[]): List<TData>;
|
||||
createItem(data: TData): ListItem<TData>;
|
||||
toArray(): TData[];
|
||||
toJSON(): TData[];
|
||||
getSize(): number;
|
||||
isEmpty(): boolean;
|
||||
first(): TData | null;
|
||||
last(): TData | null;
|
||||
each<TContext>(fn: IteratorFn<TData, void, TContext>, context: TContext): void;
|
||||
each(fn: IteratorFn<TData, void>): void;
|
||||
forEach<TContext>(fn: IteratorFn<TData, void, TContext>, context: TContext): void;
|
||||
forEach(fn: IteratorFn<TData, void>): void;
|
||||
eachRight<TContext>(fn: IteratorFn<TData, void, TContext>, context: TContext): void;
|
||||
eachRight(fn: IteratorFn<TData, void>): void;
|
||||
forEachRight<TContext>(fn: IteratorFn<TData, void, TContext>, context: TContext): void;
|
||||
forEachRight(fn: IteratorFn<TData, void>): void;
|
||||
nextUntil<TContext>(start: ListItem<TData>, fn: IteratorFn<TData, boolean, TContext>, context: TContext): void;
|
||||
nextUntil(start: ListItem<TData>, fn: IteratorFn<TData, boolean>): void;
|
||||
prevUntil<TContext>(start: ListItem<TData>, fn: IteratorFn<TData, boolean, TContext>, context: TContext): void;
|
||||
prevUntil(start: ListItem<TData>, fn: IteratorFn<TData, boolean>): void;
|
||||
some<TContext>(fn: IteratorFn<TData, boolean, TContext>, context: TContext): void;
|
||||
some(fn: IteratorFn<TData, boolean>): void;
|
||||
map<TContext, TResult>(fn: IteratorFn<TData, TResult, TContext>, context: TContext): List<TResult>;
|
||||
map<TResult>(fn: IteratorFn<TData, TResult>): List<TResult>;
|
||||
filter<TContext, TResult extends TData>(fn: FilterFn<TData, TResult, TContext>, context: TContext): List<TResult>;
|
||||
filter<TResult extends TData>(fn: FilterFn<TData, TResult>): List<TResult>;
|
||||
filter<TContext>(fn: IteratorFn<TData, boolean, TContext>, context: TContext): List<TData>;
|
||||
filter(fn: IteratorFn<TData, boolean>): List<TData>;
|
||||
clear(): void;
|
||||
copy(): List<TData>;
|
||||
prepend(item: ListItem<TData>): List<TData>;
|
||||
prependData(data: TData): List<TData>;
|
||||
append(item: ListItem<TData>): List<TData>;
|
||||
appendData(data: TData): List<TData>;
|
||||
insert(item: ListItem<TData>, before: ListItem<TData>): List<TData>;
|
||||
insertData(data: TData, before: ListItem<TData>): List<TData>;
|
||||
remove(item: ListItem<TData>): ListItem<TData>;
|
||||
push(item: TData): void;
|
||||
pop(): ListItem<TData> | undefined;
|
||||
unshift(data: TData): void;
|
||||
shift(): ListItem<TData> | undefined;
|
||||
prependList(list: List<TData>): List<TData>;
|
||||
appendList(list: List<TData>): List<TData>;
|
||||
insertList(list: List<TData>, before: ListItem<TData>): List<TData>;
|
||||
replace(oldItem: ListItem<TData>, newItemOrList: List<TData> | ListItem<TData>): List<TData>;
|
||||
}
|
||||
|
||||
export interface CssNodeCommon {
|
||||
type: string;
|
||||
loc?: CssLocation;
|
||||
}
|
||||
|
||||
export interface AnPlusB extends CssNodeCommon {
|
||||
type: 'AnPlusB';
|
||||
a: string | null;
|
||||
b: string | null;
|
||||
}
|
||||
|
||||
export interface Atrule extends CssNodeCommon {
|
||||
type: 'Atrule';
|
||||
name: string;
|
||||
prelude: AtrulePrelude | Raw | null;
|
||||
block: Block | null;
|
||||
}
|
||||
|
||||
export interface AtrulePlain extends CssNodeCommon {
|
||||
type: 'Atrule';
|
||||
name: string;
|
||||
prelude: AtrulePreludePlain | Raw | null;
|
||||
block: BlockPlain | null;
|
||||
}
|
||||
|
||||
export interface AtrulePrelude extends CssNodeCommon {
|
||||
type: 'AtrulePrelude';
|
||||
children: List<CssNode>;
|
||||
}
|
||||
|
||||
export interface AtrulePreludePlain extends CssNodeCommon {
|
||||
type: 'AtrulePrelude';
|
||||
children: CssNodePlain[];
|
||||
}
|
||||
|
||||
export interface AttributeSelector extends CssNodeCommon {
|
||||
type: 'AttributeSelector';
|
||||
name: Identifier;
|
||||
matcher: string | null;
|
||||
value: StringNode | Identifier | null;
|
||||
flags: string | null;
|
||||
}
|
||||
|
||||
export interface Block extends CssNodeCommon {
|
||||
type: 'Block';
|
||||
children: List<CssNode>;
|
||||
}
|
||||
|
||||
export interface BlockPlain extends CssNodeCommon {
|
||||
type: 'Block';
|
||||
children: CssNodePlain[];
|
||||
}
|
||||
|
||||
export interface Brackets extends CssNodeCommon {
|
||||
type: 'Brackets';
|
||||
children: List<CssNode>;
|
||||
}
|
||||
|
||||
export interface BracketsPlain extends CssNodeCommon {
|
||||
type: 'Brackets';
|
||||
children: CssNodePlain[];
|
||||
}
|
||||
|
||||
export interface CDC extends CssNodeCommon {
|
||||
type: 'CDC';
|
||||
}
|
||||
|
||||
export interface CDO extends CssNodeCommon {
|
||||
type: 'CDO';
|
||||
}
|
||||
|
||||
export interface ClassSelector extends CssNodeCommon {
|
||||
type: 'ClassSelector';
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface Combinator extends CssNodeCommon {
|
||||
type: 'Combinator';
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface Comment extends CssNodeCommon {
|
||||
type: 'Comment';
|
||||
value: string;
|
||||
}
|
||||
|
||||
export interface Declaration extends CssNodeCommon {
|
||||
type: 'Declaration';
|
||||
important: boolean | string;
|
||||
property: string;
|
||||
value: Value | Raw;
|
||||
}
|
||||
|
||||
export interface DeclarationPlain extends CssNodeCommon {
|
||||
type: 'Declaration';
|
||||
important: boolean | string;
|
||||
property: string;
|
||||
value: ValuePlain | Raw;
|
||||
}
|
||||
|
||||
export interface DeclarationList extends CssNodeCommon {
|
||||
type: 'DeclarationList';
|
||||
children: List<CssNode>;
|
||||
}
|
||||
|
||||
export interface DeclarationListPlain extends CssNodeCommon {
|
||||
type: 'DeclarationList';
|
||||
children: CssNodePlain[];
|
||||
}
|
||||
|
||||
export interface Dimension extends CssNodeCommon {
|
||||
type: 'Dimension';
|
||||
value: string;
|
||||
unit: string;
|
||||
}
|
||||
|
||||
export interface FunctionNode extends CssNodeCommon {
|
||||
type: 'Function';
|
||||
name: string;
|
||||
children: List<CssNode>;
|
||||
}
|
||||
|
||||
export interface FunctionNodePlain extends CssNodeCommon {
|
||||
type: 'Function';
|
||||
name: string;
|
||||
children: CssNodePlain[];
|
||||
}
|
||||
|
||||
export interface HexColor extends CssNodeCommon {
|
||||
type: 'HexColor';
|
||||
value: string;
|
||||
}
|
||||
|
||||
export interface IdSelector extends CssNodeCommon {
|
||||
type: 'IdSelector';
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface Identifier extends CssNodeCommon {
|
||||
type: 'Identifier';
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface MediaFeature extends CssNodeCommon {
|
||||
type: 'MediaFeature';
|
||||
name: string;
|
||||
value: Identifier | NumberNode | Dimension | Ratio | null;
|
||||
}
|
||||
|
||||
export interface MediaQuery extends CssNodeCommon {
|
||||
type: 'MediaQuery';
|
||||
children: List<CssNode>;
|
||||
}
|
||||
|
||||
export interface MediaQueryPlain extends CssNodeCommon {
|
||||
type: 'MediaQuery';
|
||||
children: CssNodePlain[];
|
||||
}
|
||||
|
||||
export interface MediaQueryList extends CssNodeCommon {
|
||||
type: 'MediaQueryList';
|
||||
children: List<CssNode>;
|
||||
}
|
||||
|
||||
export interface MediaQueryListPlain extends CssNodeCommon {
|
||||
type: 'MediaQueryList';
|
||||
children: CssNodePlain[];
|
||||
}
|
||||
|
||||
export interface Nth extends CssNodeCommon {
|
||||
type: 'Nth';
|
||||
nth: AnPlusB | Identifier;
|
||||
selector: SelectorList | null;
|
||||
}
|
||||
|
||||
export interface NthPlain extends CssNodeCommon {
|
||||
type: 'Nth';
|
||||
nth: AnPlusB | Identifier;
|
||||
selector: SelectorListPlain | null;
|
||||
}
|
||||
|
||||
export interface NumberNode extends CssNodeCommon {
|
||||
type: 'Number';
|
||||
value: string;
|
||||
}
|
||||
|
||||
export interface Operator extends CssNodeCommon {
|
||||
type: 'Operator';
|
||||
value: string;
|
||||
}
|
||||
|
||||
export interface Parentheses extends CssNodeCommon {
|
||||
type: 'Parentheses';
|
||||
children: List<CssNode>;
|
||||
}
|
||||
|
||||
export interface ParenthesesPlain extends CssNodeCommon {
|
||||
type: 'Parentheses';
|
||||
children: CssNodePlain[];
|
||||
}
|
||||
|
||||
export interface Percentage extends CssNodeCommon {
|
||||
type: 'Percentage';
|
||||
value: string;
|
||||
}
|
||||
|
||||
export interface PseudoClassSelector extends CssNodeCommon {
|
||||
type: 'PseudoClassSelector';
|
||||
name: string;
|
||||
children: List<CssNode> | null;
|
||||
}
|
||||
|
||||
export interface PseudoClassSelectorPlain extends CssNodeCommon {
|
||||
type: 'PseudoClassSelector';
|
||||
name: string;
|
||||
children: CssNodePlain[] | null;
|
||||
}
|
||||
|
||||
export interface PseudoElementSelector extends CssNodeCommon {
|
||||
type: 'PseudoElementSelector';
|
||||
name: string;
|
||||
children: List<CssNode> | null;
|
||||
}
|
||||
|
||||
export interface PseudoElementSelectorPlain extends CssNodeCommon {
|
||||
type: 'PseudoElementSelector';
|
||||
name: string;
|
||||
children: CssNodePlain[] | null;
|
||||
}
|
||||
|
||||
export interface Ratio extends CssNodeCommon {
|
||||
type: 'Ratio';
|
||||
left: string;
|
||||
right: string;
|
||||
}
|
||||
|
||||
export interface Raw extends CssNodeCommon {
|
||||
type: 'Raw';
|
||||
value: string;
|
||||
}
|
||||
|
||||
export interface Rule extends CssNodeCommon {
|
||||
type: 'Rule';
|
||||
prelude: SelectorList | Raw;
|
||||
block: Block;
|
||||
}
|
||||
|
||||
export interface RulePlain extends CssNodeCommon {
|
||||
type: 'Rule';
|
||||
prelude: SelectorListPlain | Raw;
|
||||
block: BlockPlain;
|
||||
}
|
||||
|
||||
export interface Selector extends CssNodeCommon {
|
||||
type: 'Selector';
|
||||
children: List<CssNode>;
|
||||
}
|
||||
|
||||
export interface SelectorPlain extends CssNodeCommon {
|
||||
type: 'Selector';
|
||||
children: CssNodePlain[];
|
||||
}
|
||||
|
||||
export interface SelectorList extends CssNodeCommon {
|
||||
type: 'SelectorList';
|
||||
children: List<CssNode>;
|
||||
}
|
||||
|
||||
export interface SelectorListPlain extends CssNodeCommon {
|
||||
type: 'SelectorList';
|
||||
children: CssNodePlain[];
|
||||
}
|
||||
|
||||
export interface StringNode extends CssNodeCommon {
|
||||
type: 'String';
|
||||
value: string;
|
||||
}
|
||||
|
||||
export interface StyleSheet extends CssNodeCommon {
|
||||
type: 'StyleSheet';
|
||||
children: List<CssNode>;
|
||||
}
|
||||
|
||||
export interface StyleSheetPlain extends CssNodeCommon {
|
||||
type: 'StyleSheet';
|
||||
children: CssNodePlain[];
|
||||
}
|
||||
|
||||
export interface TypeSelector extends CssNodeCommon {
|
||||
type: 'TypeSelector';
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface UnicodeRange extends CssNodeCommon {
|
||||
type: 'UnicodeRange';
|
||||
value: string;
|
||||
}
|
||||
|
||||
export interface Url extends CssNodeCommon {
|
||||
type: 'Url';
|
||||
value: StringNode | Raw;
|
||||
}
|
||||
|
||||
export interface Value extends CssNodeCommon {
|
||||
type: 'Value';
|
||||
children: List<CssNode>;
|
||||
}
|
||||
|
||||
export interface ValuePlain extends CssNodeCommon {
|
||||
type: 'Value';
|
||||
children: CssNodePlain[];
|
||||
}
|
||||
|
||||
export interface WhiteSpace extends CssNodeCommon {
|
||||
type: 'WhiteSpace';
|
||||
value: string;
|
||||
}
|
||||
|
||||
export type CssNode =
|
||||
AnPlusB
|
||||
| Atrule
|
||||
| AtrulePrelude
|
||||
| AttributeSelector
|
||||
| Block
|
||||
| Brackets
|
||||
| CDC
|
||||
| CDO
|
||||
| ClassSelector
|
||||
| Combinator
|
||||
| Comment
|
||||
| Declaration
|
||||
| DeclarationList
|
||||
| Dimension
|
||||
| FunctionNode
|
||||
| HexColor
|
||||
| IdSelector
|
||||
| Identifier
|
||||
| MediaFeature
|
||||
| MediaQuery
|
||||
| MediaQueryList
|
||||
| Nth
|
||||
| NumberNode
|
||||
| Operator
|
||||
| Parentheses
|
||||
| Percentage
|
||||
| PseudoClassSelector
|
||||
| PseudoElementSelector
|
||||
| Ratio
|
||||
| Raw
|
||||
| Rule
|
||||
| Selector
|
||||
| SelectorList
|
||||
| StringNode
|
||||
| StyleSheet
|
||||
| TypeSelector
|
||||
| UnicodeRange
|
||||
| Url
|
||||
| Value
|
||||
| WhiteSpace;
|
||||
|
||||
export type CssNodePlain =
|
||||
AnPlusB
|
||||
| AtrulePlain
|
||||
| AtrulePreludePlain
|
||||
| AttributeSelector
|
||||
| BlockPlain
|
||||
| BracketsPlain
|
||||
| CDC
|
||||
| CDO
|
||||
| ClassSelector
|
||||
| Combinator
|
||||
| Comment
|
||||
| DeclarationPlain
|
||||
| DeclarationListPlain
|
||||
| Dimension
|
||||
| FunctionNodePlain
|
||||
| HexColor
|
||||
| IdSelector
|
||||
| Identifier
|
||||
| MediaFeature
|
||||
| MediaQueryPlain
|
||||
| MediaQueryListPlain
|
||||
| NthPlain
|
||||
| NumberNode
|
||||
| Operator
|
||||
| ParenthesesPlain
|
||||
| Percentage
|
||||
| PseudoClassSelectorPlain
|
||||
| PseudoElementSelectorPlain
|
||||
| Ratio
|
||||
| Raw
|
||||
| RulePlain
|
||||
| SelectorPlain
|
||||
| SelectorListPlain
|
||||
| StringNode
|
||||
| StyleSheetPlain
|
||||
| TypeSelector
|
||||
| UnicodeRange
|
||||
| Url
|
||||
| ValuePlain
|
||||
| WhiteSpace;
|
||||
|
||||
export interface SyntaxParseError extends SyntaxError {
|
||||
input: string;
|
||||
offset: number;
|
||||
rawMessage: string;
|
||||
}
|
||||
|
||||
export interface ParseOptions {
|
||||
context?: string;
|
||||
atrule?: string;
|
||||
positions?: boolean;
|
||||
onParseError?: (error: SyntaxParseError, fallbackNode: CssNode) => void;
|
||||
filename?: string;
|
||||
offset?: number;
|
||||
line?: number;
|
||||
column?: number;
|
||||
parseAtrulePrelude?: boolean;
|
||||
parseRulePrelude?: boolean;
|
||||
parseValue?: boolean;
|
||||
parseCustomProperty?: boolean;
|
||||
}
|
||||
|
||||
export function parse(text: string, options?: ParseOptions): CssNode;
|
||||
|
||||
export interface GenerateHandlers {
|
||||
children: (node: CssNode, delimiter?: (node: CssNode) => void) => void;
|
||||
node: (node: CssNode) => void;
|
||||
chunk: (chunk: string) => void;
|
||||
result: () => string;
|
||||
}
|
||||
|
||||
export interface GenerateOptions {
|
||||
sourceMap?: boolean;
|
||||
decorator?: (handlers: GenerateHandlers) => GenerateHandlers;
|
||||
}
|
||||
|
||||
export function generate(ast: CssNode, options?: GenerateOptions): string;
|
||||
|
||||
export interface WalkContext {
|
||||
root: CssNode;
|
||||
stylesheet: StyleSheet;
|
||||
atrule: Atrule;
|
||||
atrulePrelude: AtrulePrelude;
|
||||
rule: Rule;
|
||||
selector: SelectorList;
|
||||
block: Block;
|
||||
declaration: Declaration;
|
||||
function: FunctionNode | PseudoClassSelector | PseudoElementSelector;
|
||||
}
|
||||
|
||||
export type EnterOrLeaveFn = (this: WalkContext, node: CssNode, item: ListItem<CssNode>, list: List<CssNode>) => void;
|
||||
|
||||
export interface WalkOptions {
|
||||
enter?: EnterOrLeaveFn;
|
||||
leave?: EnterOrLeaveFn;
|
||||
visit?: string;
|
||||
reverse?: boolean;
|
||||
}
|
||||
|
||||
export function walk(ast: CssNode, options: EnterOrLeaveFn | WalkOptions): void;
|
||||
|
||||
export interface Property {
|
||||
readonly basename: string;
|
||||
readonly name: string;
|
||||
readonly hack: string;
|
||||
readonly vendor: string;
|
||||
readonly prefix: string;
|
||||
readonly custom: boolean;
|
||||
}
|
||||
|
||||
export function property(value: string): Property;
|
||||
|
||||
export interface Keyword {
|
||||
readonly basename: string;
|
||||
readonly name: string;
|
||||
readonly vendor: string;
|
||||
readonly prefix: string;
|
||||
readonly custom: boolean;
|
||||
}
|
||||
|
||||
export function keyword(value: string): Keyword;
|
||||
|
||||
export function clone(node: CssNode): CssNode;
|
||||
|
||||
export function fromPlainObject(node: CssNodePlain): CssNode;
|
||||
export function toPlainObject(node: CssNode): CssNodePlain;
|
||||
@@ -18,6 +18,6 @@
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"fast-diff-tests.ts"
|
||||
"css-tree-tests.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@ csso.minify('.test { color: #ff0000; }', {
|
||||
logger: () => {}
|
||||
});
|
||||
|
||||
csso.minifyBlock('color: rgba(255, 0, 0, 1); color: #ff0000').css;
|
||||
csso.minifyBlock('color: rgba(255, 0, 0, 1); color: #ff0000').css; // $ExpectType string
|
||||
csso.minifyBlock('color: rgba(255, 0, 0, 1); color: #ff0000').map;
|
||||
csso.minifyBlock('color: rgba(255, 0, 0, 1); color: #ff0000', {
|
||||
sourceMap: true,
|
||||
@@ -27,14 +27,30 @@ csso.minifyBlock('color: rgba(255, 0, 0, 1); color: #ff0000', {
|
||||
forceMediaMerge: true,
|
||||
clone: false,
|
||||
comments: '',
|
||||
logger: () => {}
|
||||
logger: () => {},
|
||||
usage: {
|
||||
tags: ['ul', 'li'],
|
||||
ids: ['x'],
|
||||
classes: ['a', 'b'],
|
||||
blacklist: {
|
||||
tags: ['body'],
|
||||
ids: ['y'],
|
||||
classes: ['c'],
|
||||
},
|
||||
scopes: [
|
||||
['a', 'b', 'c'],
|
||||
['d', 'e']
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
csso.compress({}).ast;
|
||||
csso.compress({}, {
|
||||
csso.compress({ type: 'CDC' }).ast; // $ExpectType CssNode
|
||||
csso.compress({ type: 'CDC' }, {
|
||||
restructure: false,
|
||||
forceMediaMerge: true,
|
||||
clone: false,
|
||||
comments: '',
|
||||
logger: () => {}
|
||||
}).ast;
|
||||
}).ast; // $ExpectType CssNode
|
||||
|
||||
csso.syntax.parse('.b {font-weight: bold}'); // $ExpectType CssNode
|
||||
|
||||
Vendored
+20
-3
@@ -1,8 +1,11 @@
|
||||
// Type definitions for csso 3.5
|
||||
// Project: https://github.com/css/csso
|
||||
// Definitions by: Christian Rackerseder <https://github.com/screendriver>
|
||||
// Erik Källén <https://github.com/erik-kallen>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.6
|
||||
// TypeScript Version: 2.7
|
||||
|
||||
import * as csstree from 'css-tree';
|
||||
|
||||
declare namespace csso {
|
||||
interface Result {
|
||||
@@ -16,6 +19,18 @@ declare namespace csso {
|
||||
map: object | null;
|
||||
}
|
||||
|
||||
interface Usage {
|
||||
tags?: string[];
|
||||
ids?: string[];
|
||||
classes?: string[];
|
||||
scopes?: string[][];
|
||||
blacklist?: {
|
||||
tags?: string[];
|
||||
ids?: string[];
|
||||
classes?: string[];
|
||||
};
|
||||
}
|
||||
|
||||
interface CompressOptions {
|
||||
/**
|
||||
* Disable or enable a structure optimisations.
|
||||
@@ -44,7 +59,7 @@ declare namespace csso {
|
||||
/**
|
||||
* Usage data for advanced optimisations.
|
||||
*/
|
||||
usage?: object;
|
||||
usage?: Usage;
|
||||
/**
|
||||
* Function to track every step of transformation.
|
||||
*/
|
||||
@@ -100,7 +115,9 @@ interface Csso {
|
||||
/**
|
||||
* Does the main task – compress an AST.
|
||||
*/
|
||||
compress(ast: object, options?: csso.CompressOptions): { ast: object };
|
||||
compress(ast: csstree.CssNode, options?: csso.CompressOptions): { ast: csstree.CssNode };
|
||||
|
||||
syntax: typeof csstree;
|
||||
}
|
||||
|
||||
declare const csso: Csso;
|
||||
|
||||
@@ -98,7 +98,7 @@ brush.on('end', function(d, i, g) {
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
const g = select<SVGSVGElement, any>('svg')
|
||||
.append<SVGGElement>('g')
|
||||
.append('g')
|
||||
.classed('brush', true)
|
||||
.datum<BrushDatum>({
|
||||
extent: [[0, 0], [300, 200]],
|
||||
@@ -108,7 +108,7 @@ const g = select<SVGSVGElement, any>('svg')
|
||||
g.call(brush);
|
||||
|
||||
const gX = select<SVGSVGElement, any>('svg')
|
||||
.append<SVGGElement>('g')
|
||||
.append('g')
|
||||
.classed('brush', true)
|
||||
.datum<BrushDatum>({
|
||||
extent: [[0, 0], [300, 200]],
|
||||
|
||||
@@ -193,5 +193,5 @@ ribbonPaths = select<SVGGElement, any>('g')
|
||||
.datum(chords)
|
||||
.selectAll()
|
||||
.data(chords => chords)
|
||||
.enter().append<SVGPathElement>('path')
|
||||
.enter().append('path')
|
||||
.attr('d', svgRibbon);
|
||||
|
||||
@@ -144,6 +144,13 @@ contDensCustom = contDensCustom.y((datum) => {
|
||||
// get
|
||||
const yAcc: (d: CustomDatum) => number = contDensCustom.y();
|
||||
|
||||
// weight(...) -----------------------------------------------------------------
|
||||
contDensCustom = contDensCustom.weight((datum) => {
|
||||
return 5;
|
||||
});
|
||||
|
||||
// get
|
||||
const weightAcc: (d: CustomDatum) => number = contDensCustom.weight();
|
||||
// size(...) -------------------------------------------------------------------
|
||||
|
||||
// set with chainability
|
||||
|
||||
Vendored
+14
-2
@@ -1,10 +1,10 @@
|
||||
// Type definitions for d3-contour 1.2
|
||||
// Type definitions for d3-contour 1.3
|
||||
// Project: https://d3js.org/d3-contour/
|
||||
// Definitions by: Tom Wanzek <https://github.com/tomwanzek>, Hugues Stefanski <https://github.com/Ledragon>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
// Last module patch version validated against: 1.2.0
|
||||
// Last module patch version validated against: 1.3.2
|
||||
|
||||
import { MultiPolygon } from 'geojson';
|
||||
import { ThresholdNumberArrayGenerator, ThresholdCountGenerator } from 'd3-array';
|
||||
@@ -169,6 +169,18 @@ export interface ContourDensity<Datum = [number, number]> {
|
||||
*/
|
||||
y(y: (d: Datum) => number): this;
|
||||
|
||||
/**
|
||||
* Returns the current point weight accessor.
|
||||
*/
|
||||
weight(): (d: Datum) => number;
|
||||
|
||||
/**
|
||||
* Sets the point weight accessor and returns the density contour estimator.
|
||||
*
|
||||
* @param weight A point weight accessor function.
|
||||
*/
|
||||
weight(weight: (d: Datum) => number): this;
|
||||
|
||||
/**
|
||||
* Returns the current size, which defaults to [960, 500].
|
||||
*/
|
||||
|
||||
Vendored
+1
@@ -2,6 +2,7 @@
|
||||
// Project: https://github.com/d3/d3-drag/
|
||||
// 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
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
// Last module patch version validated against: 1.2.1
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
* in the sense of typing and call signature consistency. They
|
||||
* are not intended as functional tests.
|
||||
*/
|
||||
/* tslint:disable:no-unnecessary-type-assertion */
|
||||
|
||||
import * as d3Dsv from 'd3-dsv';
|
||||
|
||||
@@ -16,9 +17,9 @@ const csvTestString = '1997,Ford,E350,2.34\n2000,Mercury,Cougar,2.38';
|
||||
const tsvTestString = '1997\tFord\tE350\t2.34\n2000\tMercury\tCougar\t2.38';
|
||||
const pipedTestString = '1997|Ford|E350|2.34\n2000|Mercury|Cougar|2.38';
|
||||
|
||||
const csvTestStringWithHeader = 'Year,Make,Model,Length\n1997,Ford,E350,2.34\n2000,Mercury,Cougar,2.38';
|
||||
const tsvTestStringWithHeader = 'Year\tMake\tModel\tLength\n1997\tFord\tE350\t2.34\n2000\tMercury\tCougar\t2.38';
|
||||
const pipedTestStringWithHeader = 'Year|Make|Model|Length\n1997|Ford|E350|2.34\n2000|Mercury|Cougar|2.38';
|
||||
const csvTestStringWithHeader = `Year,Make,Model,Length\n${csvTestString}`;
|
||||
const tsvTestStringWithHeader = `Year\tMake\tModel\tLength\n${tsvTestString}`;
|
||||
const pipedTestStringWithHeader = `Year|Make|Model|Length\n${pipedTestString}`;
|
||||
|
||||
interface ParsedTestObject {
|
||||
year: Date | null;
|
||||
@@ -33,9 +34,8 @@ let parseMappedArray: d3Dsv.DSVParsedArray<ParsedTestObject>;
|
||||
let parseRowsArray: string[][];
|
||||
let parseRowsMappedArray: ParsedTestObject[];
|
||||
|
||||
let parsedTestObject: ParsedTestObject;
|
||||
let columns: string[];
|
||||
let num: number;
|
||||
let dateNull: Date | null;
|
||||
let str: string;
|
||||
let strMaybe: string | undefined;
|
||||
|
||||
@@ -48,12 +48,8 @@ let strMaybe: string | undefined;
|
||||
// without row mapper -----------------------------------------------------------------------
|
||||
|
||||
parseArray = d3Dsv.csvParse(csvTestStringWithHeader);
|
||||
|
||||
columns = parseArray.columns;
|
||||
|
||||
strMaybe = parseArray[0]['Year'];
|
||||
// $ExpectError
|
||||
date = parseArray[0]['Year']; // fails, return value is string
|
||||
strMaybe = parseArray[0].Year;
|
||||
|
||||
// with row mapper ---------------------------------------------------------------------------
|
||||
|
||||
@@ -61,28 +57,15 @@ parseMappedArray = d3Dsv.csvParse(csvTestStringWithHeader, (rawRow, index, colum
|
||||
const rr: d3Dsv.DSVRowString = rawRow;
|
||||
const i: number = index;
|
||||
const c: string[] = columns;
|
||||
const pr: ParsedTestObject = {
|
||||
year: rr['Year'] ? new Date(+rr['Year']!, 0, 1) : null,
|
||||
make: rr['Make'] ? rr['Make']! : "Missing Value",
|
||||
model: rr['Model'] ? rr['Model']! : "Missing Value",
|
||||
length: rr['Length'] ? +rr['Length']! : NaN
|
||||
};
|
||||
return pr;
|
||||
});
|
||||
|
||||
parseMappedArray = d3Dsv.csvParse(csvTestStringWithHeader, (rawRow, index, columns) => {
|
||||
const rr: d3Dsv.DSVRowString = rawRow;
|
||||
const i: number = index;
|
||||
const c: string[] = columns;
|
||||
const d: number | null = rr['Year'] ? +rr['Year']! : null;
|
||||
const d: number | null = rr.Year ? +rr.Year! : null;
|
||||
const pr: ParsedTestObject | null | undefined = d !== null
|
||||
? (
|
||||
d > 1997
|
||||
? {
|
||||
year: new Date(d, 0, 1),
|
||||
make: rr['Make'] ? rr['Make']! : "Missing Value",
|
||||
model: rr['Model'] ? rr['Model']! : "Missing Value",
|
||||
length: rr['Length'] ? +rr['Length']! : NaN
|
||||
make: rr.Make ? rr.Make! : "Missing Value",
|
||||
model: rr.Model ? rr.Model! : "Missing Value",
|
||||
length: rr.Length ? +rr.Length! : NaN
|
||||
}
|
||||
: undefined
|
||||
)
|
||||
@@ -91,21 +74,14 @@ parseMappedArray = d3Dsv.csvParse(csvTestStringWithHeader, (rawRow, index, colum
|
||||
});
|
||||
|
||||
columns = parseMappedArray.columns;
|
||||
|
||||
dateNull = parseMappedArray[0].year;
|
||||
strMaybe = parseMappedArray[0].make;
|
||||
strMaybe = parseMappedArray[0].model;
|
||||
num = parseMappedArray[0].length;
|
||||
parsedTestObject = parseMappedArray[0];
|
||||
|
||||
// csvParseRows(...) ============================================================================
|
||||
|
||||
// without row mapper -----------------------------------------------------------------------
|
||||
|
||||
parseRowsArray = d3Dsv.csvParseRows(csvTestString);
|
||||
|
||||
strMaybe = parseRowsArray[0][0]; // 'Year' of first row
|
||||
// $ExpectError
|
||||
date = parseRowsArray[0][0]; // fails, return value is string
|
||||
|
||||
// with row mapper ---------------------------------------------------------------------------
|
||||
|
||||
@@ -128,15 +104,12 @@ parseRowsMappedArray = d3Dsv.csvParseRows(csvTestString, (rawRow, index) => {
|
||||
return pr;
|
||||
});
|
||||
|
||||
dateNull = parseRowsMappedArray[0].year;
|
||||
strMaybe = parseRowsMappedArray[0].make;
|
||||
strMaybe = parseRowsMappedArray[0].model;
|
||||
num = parseRowsMappedArray[0].length;
|
||||
|
||||
// csvFormat(...) ============================================================================
|
||||
|
||||
str = d3Dsv.csvFormat(parseRowsMappedArray);
|
||||
str = d3Dsv.csvFormat(parseRowsMappedArray, columns);
|
||||
str = d3Dsv.csvFormat(parseRowsMappedArray, ["year", "length"]);
|
||||
// $ExpectError
|
||||
str = d3Dsv.csvFormat(parseRowsMappedArray, ["year", "unknown"]);
|
||||
|
||||
// csvFormatRows(...) ========================================================================
|
||||
|
||||
@@ -156,12 +129,8 @@ str = d3Dsv.csvFormatRows(parseRowsMappedArray.map((d, i) => [
|
||||
// without row mapper -----------------------------------------------------------------------
|
||||
|
||||
parseArray = d3Dsv.tsvParse(tsvTestStringWithHeader);
|
||||
|
||||
columns = parseArray.columns;
|
||||
|
||||
strMaybe = parseArray[0]['Year'];
|
||||
// $ExpectError
|
||||
date = parseArray[0]['Year']; // fails, return value is string
|
||||
strMaybe = parseArray[0].Year;
|
||||
|
||||
// with row mapper ---------------------------------------------------------------------------
|
||||
|
||||
@@ -169,15 +138,15 @@ parseMappedArray = d3Dsv.tsvParse(tsvTestStringWithHeader, (rawRow, index, colum
|
||||
const rr: d3Dsv.DSVRowString = rawRow;
|
||||
const i: number = index;
|
||||
const c: string[] = columns;
|
||||
const d: number | null = rr['Year'] ? +rr['Year']! : null;
|
||||
const d: number | null = rr.Year ? +rr.Year! : null;
|
||||
const pr: ParsedTestObject | null | undefined = d !== null
|
||||
? (
|
||||
d > 1997
|
||||
? {
|
||||
year: new Date(d, 0, 1),
|
||||
make: rr['Make'] ? rr['Make']! : "Missing Value",
|
||||
model: rr['Model'] ? rr['Model']! : "Missing Value",
|
||||
length: rr['Length'] ? +rr['Length']! : NaN
|
||||
make: rr.Make ? rr.Make! : "Missing Value",
|
||||
model: rr.Model ? rr.Model! : "Missing Value",
|
||||
length: rr.Length ? +rr.Length! : NaN
|
||||
}
|
||||
: undefined
|
||||
)
|
||||
@@ -186,21 +155,14 @@ parseMappedArray = d3Dsv.tsvParse(tsvTestStringWithHeader, (rawRow, index, colum
|
||||
});
|
||||
|
||||
columns = parseMappedArray.columns;
|
||||
|
||||
dateNull = parseMappedArray[0].year;
|
||||
strMaybe = parseMappedArray[0].make;
|
||||
strMaybe = parseMappedArray[0].model;
|
||||
num = parseMappedArray[0].length;
|
||||
parsedTestObject = parseMappedArray[0];
|
||||
|
||||
// tsvParseRows(...) ============================================================================
|
||||
|
||||
// without row mapper -----------------------------------------------------------------------
|
||||
|
||||
parseRowsArray = d3Dsv.tsvParseRows(tsvTestString);
|
||||
|
||||
strMaybe = parseRowsArray[0][0]; // 'Year' of first row
|
||||
// $ExpectError
|
||||
date = parseRowsArray[0][0]; // fails, return value is string
|
||||
|
||||
// with row mapper ---------------------------------------------------------------------------
|
||||
|
||||
@@ -223,15 +185,12 @@ parseRowsMappedArray = d3Dsv.tsvParseRows(tsvTestString, (rawRow, index) => {
|
||||
return pr;
|
||||
});
|
||||
|
||||
dateNull = parseRowsMappedArray[0].year;
|
||||
strMaybe = parseRowsMappedArray[0].make;
|
||||
strMaybe = parseRowsMappedArray[0].model;
|
||||
num = parseRowsMappedArray[0].length;
|
||||
|
||||
// tsvFormat(...) ============================================================================
|
||||
|
||||
str = d3Dsv.tsvFormat(parseRowsMappedArray);
|
||||
str = d3Dsv.tsvFormat(parseRowsMappedArray, columns);
|
||||
str = d3Dsv.tsvFormat(parseRowsMappedArray, ["year", "length"]);
|
||||
// $ExpectError
|
||||
str = d3Dsv.tsvFormat(parseRowsMappedArray, ["year", "unknown"]);
|
||||
|
||||
// tsvFormatRows(...) ========================================================================
|
||||
|
||||
@@ -256,12 +215,8 @@ dsv = d3Dsv.dsvFormat('|');
|
||||
// without row mapper -----------------------------------------------------------------------
|
||||
|
||||
parseArray = dsv.parse(pipedTestStringWithHeader);
|
||||
|
||||
columns = parseArray.columns;
|
||||
|
||||
strMaybe = parseArray[0]['Year'];
|
||||
// $ExpectError
|
||||
date = parseArray[0]['Year']; // fails, return value is string
|
||||
strMaybe = parseArray[0].Year;
|
||||
|
||||
// with row mapper ---------------------------------------------------------------------------
|
||||
|
||||
@@ -269,15 +224,15 @@ parseMappedArray = dsv.parse(pipedTestStringWithHeader, (rawRow, index, columns)
|
||||
const rr: d3Dsv.DSVRowString = rawRow;
|
||||
const i: number = index;
|
||||
const c: string[] = columns;
|
||||
const d: number | null = rr['Year'] ? +rr['Year']! : null;
|
||||
const d: number | null = rr.Year ? +rr.Year! : null;
|
||||
const pr: ParsedTestObject | null | undefined = d !== null
|
||||
? (
|
||||
d > 1997
|
||||
? {
|
||||
year: new Date(d, 0, 1),
|
||||
make: rr['Make'] ? rr['Make']! : "Missing Value",
|
||||
model: rr['Model'] ? rr['Model']! : "Missing Value",
|
||||
length: rr['Length'] ? +rr['Length']! : NaN
|
||||
make: rr.Make ? rr.Make! : "Missing Value",
|
||||
model: rr.Model ? rr.Model! : "Missing Value",
|
||||
length: rr.Length ? +rr.Length! : NaN
|
||||
}
|
||||
: undefined
|
||||
)
|
||||
@@ -286,21 +241,14 @@ parseMappedArray = dsv.parse(pipedTestStringWithHeader, (rawRow, index, columns)
|
||||
});
|
||||
|
||||
columns = parseMappedArray.columns;
|
||||
|
||||
dateNull = parseMappedArray[0].year;
|
||||
strMaybe = parseMappedArray[0].make;
|
||||
strMaybe = parseMappedArray[0].model;
|
||||
num = parseMappedArray[0].length;
|
||||
parsedTestObject = parseMappedArray[0];
|
||||
|
||||
// parseRows(...) ============================================================================
|
||||
|
||||
// without row mapper -----------------------------------------------------------------------
|
||||
|
||||
parseRowsArray = dsv.parseRows(pipedTestString);
|
||||
|
||||
strMaybe = parseRowsArray[0][0]; // 'Year' of first row
|
||||
// $ExpectError
|
||||
date = parseRowsArray[0][0]; // fails, return value is string
|
||||
|
||||
// with row mapper ---------------------------------------------------------------------------
|
||||
|
||||
@@ -323,15 +271,12 @@ parseRowsMappedArray = dsv.parseRows(pipedTestString, (rawRow, index) => {
|
||||
return pr;
|
||||
});
|
||||
|
||||
dateNull = parseRowsMappedArray[0].year;
|
||||
strMaybe = parseRowsMappedArray[0].make;
|
||||
strMaybe = parseRowsMappedArray[0].model;
|
||||
num = parseRowsMappedArray[0].length;
|
||||
|
||||
// format(...) ============================================================================
|
||||
|
||||
str = dsv.format(parseRowsMappedArray);
|
||||
str = dsv.format(parseRowsMappedArray, columns);
|
||||
str = dsv.format(parseRowsMappedArray, ["year", "length"]);
|
||||
// $ExpectError
|
||||
str = dsv.format(parseRowsMappedArray, ["year", "unknown"]);
|
||||
|
||||
// formatRows(...) ========================================================================
|
||||
|
||||
|
||||
Vendored
+17
-11
@@ -1,9 +1,13 @@
|
||||
// Type definitions for D3JS d3-dsv module 1.0
|
||||
// Project: https://github.com/d3/d3-dsv/
|
||||
// Definitions by: Tom Wanzek <https://github.com/tomwanzek>, Alex Ford <https://github.com/gustavderdrache>, Boris Yankov <https://github.com/borisyankov>
|
||||
// Definitions by: Tom Wanzek <https://github.com/tomwanzek>
|
||||
// Alex Ford <https://github.com/gustavderdrache>
|
||||
// Boris Yankov <https://github.com/borisyankov>
|
||||
// denisname <https://github.com/denisname>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
// Last module patch version validated against: 1.0.8
|
||||
// Last module patch version validated against: 1.0.10
|
||||
|
||||
// ------------------------------------------------------------------------------------------
|
||||
// Shared Types and Interfaces
|
||||
@@ -19,6 +23,8 @@ export interface DSVRowString {
|
||||
/**
|
||||
* An object representing a DSV parsed row with values represented as an arbitrary datatype, depending
|
||||
* on the performed parsed row mapping.
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
export interface DSVRowAny {
|
||||
[key: string]: any;
|
||||
@@ -70,7 +76,7 @@ export function csvParse(csvString: string): DSVParsedArray<DSVRowString>;
|
||||
* the row is skipped and will be omitted from the array returned by dsv.parse; otherwise, the returned value defines the corresponding row object.
|
||||
* In effect, row is similar to applying a map and filter operator to the returned rows.
|
||||
*/
|
||||
export function csvParse<ParsedRow extends DSVRowAny>(
|
||||
export function csvParse<ParsedRow extends object>(
|
||||
csvString: string,
|
||||
row: (rawRow: DSVRowString, index: number, columns: string[]) => ParsedRow | undefined | null
|
||||
): DSVParsedArray<ParsedRow>;
|
||||
@@ -105,7 +111,7 @@ export function csvParseRows(csvString: string): string[][];
|
||||
* the row is skipped and will be omitted from the array returned by dsv.parse; otherwise, the returned value defines the corresponding row object.
|
||||
* In effect, row is similar to applying a map and filter operator to the returned rows.
|
||||
*/
|
||||
export function csvParseRows<ParsedRow extends DSVRowAny>(
|
||||
export function csvParseRows<ParsedRow extends object>(
|
||||
csvString: string,
|
||||
row: (rawRow: string[], index: number) => ParsedRow | undefined | null
|
||||
): ParsedRow[];
|
||||
@@ -126,7 +132,7 @@ export function csvParseRows<ParsedRow extends DSVRowAny>(
|
||||
* @param rows Array of object rows.
|
||||
* @param columns An array of strings representing the column names.
|
||||
*/
|
||||
export function csvFormat(rows: DSVRowAny[], columns?: string[]): string;
|
||||
export function csvFormat<T extends object>(rows: T[], columns?: Array<keyof T>): string;
|
||||
|
||||
// csvFormatRows(...) ========================================================================
|
||||
|
||||
@@ -180,7 +186,7 @@ export function tsvParse(tsvString: string): DSVParsedArray<DSVRowString>;
|
||||
* the row is skipped and will be omitted from the array returned by dsv.parse; otherwise, the returned value defines the corresponding row object.
|
||||
* In effect, row is similar to applying a map and filter operator to the returned rows.
|
||||
*/
|
||||
export function tsvParse<MappedRow extends DSVRowAny>(
|
||||
export function tsvParse<MappedRow extends object>(
|
||||
tsvString: string,
|
||||
row: (rawRow: DSVRowString, index: number, columns: string[]) => MappedRow | undefined | null
|
||||
): DSVParsedArray<MappedRow>;
|
||||
@@ -215,7 +221,7 @@ export function tsvParseRows(tsvString: string): string[][];
|
||||
* the row is skipped and will be omitted from the array returned by dsv.parse; otherwise, the returned value defines the corresponding row object.
|
||||
* In effect, row is similar to applying a map and filter operator to the returned rows.
|
||||
*/
|
||||
export function tsvParseRows<MappedRow extends DSVRowAny>(
|
||||
export function tsvParseRows<MappedRow extends object>(
|
||||
tsvString: string,
|
||||
row: (rawRow: string[], index: number) => MappedRow | undefined | null
|
||||
): MappedRow[];
|
||||
@@ -236,7 +242,7 @@ export function tsvParseRows<MappedRow extends DSVRowAny>(
|
||||
* @param rows Array of object rows.
|
||||
* @param columns An array of strings representing the column names.
|
||||
*/
|
||||
export function tsvFormat(rows: DSVRowAny[], columns?: string[]): string;
|
||||
export function tsvFormat<T extends object>(rows: T[], columns?: Array<keyof T>): string;
|
||||
|
||||
// tsvFormatRows(...) ========================================================================
|
||||
|
||||
@@ -288,7 +294,7 @@ export interface DSV {
|
||||
* the row is skipped and will be omitted from the array returned by dsv.parse; otherwise, the returned value defines the corresponding row object.
|
||||
* In effect, row is similar to applying a map and filter operator to the returned rows.
|
||||
*/
|
||||
parse<ParsedRow extends DSVRowAny>(
|
||||
parse<ParsedRow extends object>(
|
||||
dsvString: string,
|
||||
row: (rawRow: DSVRowString, index: number, columns: string[]) => ParsedRow | undefined | null
|
||||
): DSVParsedArray<ParsedRow>;
|
||||
@@ -317,7 +323,7 @@ export interface DSV {
|
||||
* the row is skipped and will be omitted from the array returned by dsv.parse; otherwise, the returned value defines the corresponding row object.
|
||||
* In effect, row is similar to applying a map and filter operator to the returned rows.
|
||||
*/
|
||||
parseRows<ParsedRow extends DSVRowAny>(
|
||||
parseRows<ParsedRow extends object>(
|
||||
dsvString: string,
|
||||
row: (rawRow: string[], index: number) => ParsedRow | undefined | null
|
||||
): ParsedRow[];
|
||||
@@ -334,7 +340,7 @@ export interface DSV {
|
||||
* @param rows Array of object rows.
|
||||
* @param columns An array of strings representing the column names.
|
||||
*/
|
||||
format(rows: DSVRowAny[], columns?: string[]): string;
|
||||
format<T extends object>(rows: T[], columns?: Array<keyof T>): string;
|
||||
|
||||
/**
|
||||
* Formats the specified array of array of string rows as delimiter-separated values, returning a string.
|
||||
|
||||
Vendored
+1
-1
@@ -2,7 +2,7 @@
|
||||
// Project: https://d3js.org/d3-fetch/
|
||||
// Definitions by: Hugues Stefanski <https://github.com/ledragon>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
// Last module patch version validated against: 1.1.0
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -407,7 +407,7 @@ export type Engine = 'circo' | 'dot' | 'fdp' | 'neato' | 'osage' | 'patchwork' |
|
||||
export type TypeNames = 'initEnd' | 'start' | 'layoutStart' | 'layoutEnd' | 'dataExtractEnd' |
|
||||
'dataProcessPass1End' | 'dataProcessPass2End' | 'dataProcessEnd' |
|
||||
'renderStart' | 'renderEnd' | 'transitionStart' | 'transitionEnd' |
|
||||
'resotreEnd' | 'end' | string; // string included to allow for optional addition of a name, e.g. initEnd.foo
|
||||
'restoreEnd' | 'end' | string; // string included to allow for optional addition of a name, e.g. initEnd.foo
|
||||
|
||||
/**
|
||||
* Enum defining the valid strings that can be passed as KeyModes
|
||||
|
||||
Vendored
+1
@@ -2,6 +2,7 @@
|
||||
// Project: https://github.com/d3/d3-sankey/
|
||||
// Definitions by: Tom Wanzek <https://github.com/tomwanzek>, Alex Ford <https://github.com/gustavderdrache>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
// Last module patch version validated against: 0.7.1
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user