diff options
Diffstat (limited to 'chromium/third_party/node/node_modules/@types')
7 files changed, 4181 insertions, 0 deletions
diff --git a/chromium/third_party/node/node_modules/@types/d3-drag/index.d.ts b/chromium/third_party/node/node_modules/@types/d3-drag/index.d.ts new file mode 100644 index 00000000000..c10d0bacafc --- /dev/null +++ b/chromium/third_party/node/node_modules/@types/d3-drag/index.d.ts @@ -0,0 +1,406 @@ +// Type definitions for D3JS d3-drag module 1.2 +// Project: https://github.com/d3/d3-drag/, https://d3js.org/d3-drag +// Definitions by: Tom Wanzek <https://github.com/tomwanzek> +// Alex Ford <https://github.com/gustavderdrache> +// Boris Yankov <https://github.com/borisyankov> +// Nathan Bierema <https://github.com/Methuselah96> +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +// Last module patch version validated against: 1.2.5 + +import { Selection, ValueFn } from 'd3-selection'; + +// -------------------------------------------------------------------------- +// Shared Type Definitions and Interfaces +// -------------------------------------------------------------------------- + +/** + * DraggedElementBaseType serves as an alias for the 'minimal' data type which can be selected + * without 'd3-drag' (and related code in 'd3-selection') trying to use properties internally which would otherwise not + * be supported. + */ +export type DraggedElementBaseType = Element; + +/** + * Container element type usable for mouse/touch functions + */ +export type DragContainerElement = HTMLElement | SVGSVGElement | SVGGElement; // HTMLElement includes HTMLCanvasElement + +/** + * The subject datum should at a minimum expose x and y properties, so that the relative position + * of the subject and the pointer can be preserved during the drag gesture. + */ +export interface SubjectPosition { + /** + * x-coordinate + */ + x: number; + /** + * y-coordinate + */ + y: number; +} + +/** + * A D3 Drag Behavior + * + * The first generic refers to the type of element to be dragged. + * The second generic refers to the type of the datum of the dragged element. + * The third generic refers to the type of the drag behavior subject. + * + * The subject of a drag gesture represents the thing being dragged. + * It is computed when an initiating input event is received, + * such as a mousedown or touchstart, immediately before the drag gesture starts. + * The subject is then exposed as event.subject on subsequent drag events for this gesture. + * + * The default subject is the datum of the element in the originating selection (see drag) + * that received the initiating input event; if this datum is undefined, + * an object representing the coordinates of the pointer is created. + * When dragging circle elements in SVG, the default subject is thus the datum of the circle being dragged. + * With Canvas, the default subject is the canvas element’s datum (regardless of where on the canvas you click). + * In this case, a custom subject accessor would be more appropriate, + * such as one that picks the closest circle to the mouse within a given search radius. + */ +export interface DragBehavior<GElement extends DraggedElementBaseType, Datum, Subject> extends Function { + /** + * Applies the drag behavior to the selected elements. + * This function is typically not invoked directly, and is instead invoked via selection.call. + * + * For details see: {@link https://github.com/d3/d3-drag#_drag} + * + * @param selection A D3 selection of elements. + * @param args Optional arguments to be passed in. + */ + (selection: Selection<GElement, Datum, any, any>, ...args: any[]): void; + + /** + * Returns the current container accessor function. + */ + container(): ValueFn<GElement, Datum, DragContainerElement>; + /** + * Sets the container accessor to the specified function and returns the drag behavior. + * + * The container of a drag gesture determines the coordinate system of subsequent drag events, + * affecting event.x and event.y. The element returned by the container accessor is subsequently + * passed to d3.mouse or d3.touch, as appropriate, to determine the local coordinates of the pointer. + * + * The default container accessor returns the parent node of the element in the originating selection (see drag) + * that received the initiating input event. This is often appropriate when dragging SVG or HTML elements, + * since those elements are typically positioned relative to a parent. For dragging graphical elements with a Canvas, + * however, you may want to redefine the container as the initiating element itself, using "this" in the accessor + * function. + * + * @param accessor A container accessor function which is evaluated for each selected element, + * in order, being passed the current datum (d), the current index (i), and the current group (nodes), + * with this as the current DOM element. The function returns the container element. + */ + container(accessor: ValueFn<GElement, Datum, DragContainerElement>): this; + /** + * Sets the container accessor to the specified object and returns the drag behavior. + * + * The container of a drag gesture determines the coordinate system of subsequent drag events, + * affecting event.x and event.y. The element returned by the container accessor is subsequently + * passed to d3.mouse or d3.touch, as appropriate, to determine the local coordinates of the pointer. + * + * The default container accessor returns the parent node of the element in the originating selection (see drag) + * that received the initiating input event. This is often appropriate when dragging SVG or HTML elements, + * since those elements are typically positioned relative to a parent. For dragging graphical elements with a Canvas, + * however, you may want to redefine the container as the initiating element itself, such as drag.container(canvas). + * + * @param container Container element for the drag gesture. + */ + container(container: DragContainerElement): this; + + /** + * Returns the current filter function. + */ + filter(): ValueFn<GElement, Datum, boolean>; + + /** + * Sets the filter to the specified filter function and returns the drag behavior. + * + * If the filter returns falsey, the initiating event is ignored and no drag gesture is started. + * Thus, the filter determines which input events are ignored. The default filter ignores mousedown events on secondary buttons, + * since those buttons are typically intended for other purposes, such as the context menu. + * + * @param filterFn A filter function which is evaluated for each selected element, + * in order, being passed the current datum (d), the current index (i), and the current group (nodes), + * with this as the current DOM element. The function returns a boolean value. + */ + filter(filterFn: ValueFn<GElement, Datum, boolean>): this; + + /** + * Returns the current touch support detector, which defaults to a function returning true, + * if the "ontouchstart" event is supported on the current element. + */ + touchable(): ValueFn<GElement, Datum, boolean>; + /** + * Sets the touch support detector to the specified boolean value and returns the drag behavior. + * + * Touch event listeners are only registered if the detector returns truthy for the corresponding element when the drag behavior is applied. + * The default detector works well for most browsers that are capable of touch input, but not all; Chrome’s mobile device emulator, for example, + * fails detection. + * + * @param touchable A boolean value. true when touch event listeners should be applied to the corresponding element, otherwise false. + */ + touchable(touchable: boolean): this; + /** + * Sets the touch support detector to the specified function and returns the drag behavior. + * + * Touch event listeners are only registered if the detector returns truthy for the corresponding element when the drag behavior is applied. + * The default detector works well for most browsers that are capable of touch input, but not all; Chrome’s mobile device emulator, for example, + * fails detection. + * + * @param touchable A touch support detector function, which returns true when touch event listeners should be applied to the corresponding element. + * The function is evaluated for each selected element to which the drag behavior was applied, in order, being passed the current datum (d), + * the current index (i), and the current group (nodes), with this as the current DOM element. The function returns a boolean value. + */ + touchable(touchable: ValueFn<GElement, Datum, boolean>): this; + + /** + * Returns the current subject accessor functions. + */ + subject(): ValueFn<GElement, Datum, Subject>; + /** + * Sets the subject accessor to the specified function and returns the drag behavior. + * + * The subject of a drag gesture represents the thing being dragged. + * It is computed when an initiating input event is received, + * such as a mousedown or touchstart, immediately before the drag gesture starts. + * The subject is then exposed as event.subject on subsequent drag events for this gesture. + * + * The default subject is the datum of the element in the originating selection (see drag) + * that received the initiating input event; if this datum is undefined, + * an object representing the coordinates of the pointer is created. + * When dragging circle elements in SVG, the default subject is thus the datum of the circle being dragged. + * With Canvas, the default subject is the canvas element’s datum (regardless of where on the canvas you click). + * In this case, a custom subject accessor would be more appropriate, + * such as one that picks the closest circle to the mouse within a given search radius. + * + * + * + * The subject of a drag gesture may not be changed after the gesture starts. + * + * During the evaluation of the subject accessor, d3.event is a beforestart drag event. + * Use event.sourceEvent to access the initiating input event and event.identifier to + * access the touch identifier. The event.x and event.y are relative to the container, + * and are computed using d3.mouse or d3.touch as appropriate. + * + * @param accessor An extent accessor function which is evaluated for each selected element, + * in order, being passed the current datum (d), the current index (i), and the current group (nodes), + * with this as the current DOM element.The returned subject should be an object that exposes x and y properties, + * so that the relative position of the subject and the pointer can be preserved during the drag gesture. + * If the subject is null or undefined, no drag gesture is started for this pointer; + * however, other starting touches may yet start drag gestures. + */ + subject(accessor: ValueFn<GElement, Datum, Subject>): this; + + /** + * Return the current click distance threshold, which defaults to zero. + */ + clickDistance(): number; + /** + * Set the maximum distance that the mouse can move between mousedown and mouseup that will trigger + * a subsequent click event. If at any point between mousedown and mouseup the mouse is greater than or equal to + * distance from its position on mousedown, the click event following mouseup will be suppressed. + * + * @param distance The distance threshold between mousedown and mouseup measured in client coordinates (event.clientX and event.clientY). + * The default is zero. + */ + clickDistance(distance: number): this; + + /** + * Return the first currently-assigned listener matching the specified typenames, if any. + * + * @param typenames The typenames is a string containing one or more typename separated by whitespace. + * Each typename is a type, optionally followed by a period (.) and a name, such as "drag.foo"" and "drag.bar"; + * the name allows multiple listeners to be registered for the same type. The type must be one of the following: + * start (after a new pointer becomes active [on mousedown or touchstart]), drag (after an active pointer moves [on mousemove or touchmove], or + * end (after an active pointer becomes inactive [on mouseup, touchend or touchcancel].) + */ + on(typenames: string): ValueFn<GElement, Datum, void> | undefined; + /** + * Remove the current event listeners for the specified typenames, if any, return the drag behavior. + * + * @param typenames The typenames is a string containing one or more typename separated by whitespace. + * Each typename is a type, optionally followed by a period (.) and a name, such as "drag.foo"" and "drag.bar"; + * the name allows multiple listeners to be registered for the same type. The type must be one of the following: + * start (after a new pointer becomes active [on mousedown or touchstart]), drag (after an active pointer moves [on mousemove or touchmove], or + * end (after an active pointer becomes inactive [on mouseup, touchend or touchcancel].) + * @param listener Use null to remove the listener. + */ + on(typenames: string, listener: null): this; + /** + * Set the event listener for the specified typenames and return the drag behavior. + * If an event listener was already registered for the same type and name, + * the existing listener is removed before the new listener is added. + * When a specified event is dispatched, each listener will be invoked with the same context and arguments as selection.on listeners. + * + * Changes to registered listeners via drag.on during a drag gesture do not affect the current drag gesture. + * Instead, you must use event.on, which also allows you to register temporary event listeners for the current drag gesture. + * Separate events are dispatched for each active pointer during a drag gesture. + * For example, if simultaneously dragging multiple subjects with multiple fingers, a start event is dispatched for each finger, + * even if both fingers start touching simultaneously. + * + * @param typenames The typenames is a string containing one or more typename separated by whitespace. + * Each typename is a type, optionally followed by a period (.) and a name, such as "drag.foo"" and "drag.bar"; + * the name allows multiple listeners to be registered for the same type. The type must be one of the following: + * start (after a new pointer becomes active [on mousedown or touchstart]), drag (after an active pointer moves [on mousemove or touchmove], or + * end (after an active pointer becomes inactive [on mouseup, touchend or touchcancel].) + * @param listener An event listener function which is evaluated for each selected element, + * in order, being passed the current datum (d), the current index (i), and the current group (nodes), + * with this as the current DOM element. + */ + on(typenames: string, listener: ValueFn<GElement, Datum, void>): this; +} + +/** + * Creates a new drag behavior. The returned behavior, drag, is both an object and a function, and is + * typically applied to selected elements via selection.call. + * + * Use this signature when using the default subject accessor. + * + * The first generic refers to the type of element to be dragged. + * The second generic refers to the type of the datum of the dragged element. + */ +export function drag<GElement extends DraggedElementBaseType, Datum>(): DragBehavior<GElement, Datum, Datum | SubjectPosition>; +/** + * Creates a new drag behavior. The returned behavior, drag, is both an object and a function, and is + * typically applied to selected elements via selection.call. + * + * Use this signature when using a custom subject accessor. + * + * The first generic refers to the type of element to be dragged. + * The second generic refers to the type of the datum of the dragged element. + * The third generic refers to the type of the drag behavior subject. + */ +export function drag<GElement extends DraggedElementBaseType, Datum, Subject>(): DragBehavior<GElement, Datum, Subject>; + +/** + * D3 Drag event + * + * The first generic refers to the type of element to be dragged. + * The second generic refers to the type of the datum of the dragged element. + * The third generic refers to the type of the drag behavior subject. + */ +export interface D3DragEvent<GElement extends DraggedElementBaseType, Datum, Subject> { + /** + * The DragBehavior associated with the event + */ + target: DragBehavior<GElement, Datum, Subject>; + /** + * The event type for the DragEvent + */ + type: 'start' | 'drag' | 'end' | string; // Leave failsafe string type for cases like 'drag.foo' + /** + * The drag subject, defined by drag.subject. + */ + subject: Subject; + /** + * The new x-coordinate of the subject, relative to the container + */ + x: number; + /** + * The new y-coordinate of the subject, relative to the container + */ + y: number; + /** + * The change in x-coordinate since the previous drag event. + */ + dx: number; + /** + * The change in y-coordinate since the previous drag event. + */ + dy: number; + /** + * The string “mouse”, or a numeric touch identifier. + */ + identifier: 'mouse' | number; + /** + * The number of currently active drag gestures (on start and end, not including this one). + * + * The event.active field is useful for detecting the first start event and the last end event + * in a sequence of concurrent drag gestures: it is zero when the first drag gesture starts, + * and zero when the last drag gesture ends. + */ + active: number; + /** + * The underlying input event, such as mousemove or touchmove. + */ + sourceEvent: any; + /** + * Return the first currently-assigned listener matching the specified typenames, if any. + * + * Equivalent to drag.on, but only applies to the current drag gesture. Before the drag gesture starts, + * a copy of the current drag event listeners is made. This copy is bound to the current drag gesture + * and modified by event.on. This is useful for temporary listeners that only receive events for the current drag gesture. + * + * @param typenames The typenames is a string containing one or more typename separated by whitespace. + * Each typename is a type, optionally followed by a period (.) and a name, such as "drag.foo"" and "drag.bar"; + * the name allows multiple listeners to be registered for the same type. The type must be one of the following: + * start (after a new pointer becomes active [on mousedown or touchstart]), drag (after an active pointer moves [on mousemove or touchmove], or + * end (after an active pointer becomes inactive [on mouseup, touchend or touchcancel].) + */ + on(typenames: string): ValueFn<GElement, Datum, void> | undefined; + /** + * Remove the current event listeners for the specified typenames, if any, return the drag behavior. + * + * Equivalent to drag.on, but only applies to the current drag gesture. Before the drag gesture starts, + * a copy of the current drag event listeners is made. This copy is bound to the current drag gesture + * and modified by event.on. This is useful for temporary listeners that only receive events for the current drag gesture. + * + * @param typenames The typenames is a string containing one or more typename separated by whitespace. + * Each typename is a type, optionally followed by a period (.) and a name, such as "drag.foo"" and "drag.bar"; + * the name allows multiple listeners to be registered for the same type. The type must be one of the following: + * start (after a new pointer becomes active [on mousedown or touchstart]), drag (after an active pointer moves [on mousemove or touchmove], or + * end (after an active pointer becomes inactive [on mouseup, touchend or touchcancel].) + * @param listener Use null to remove the listener. + */ + on(typenames: string, listener: null): this; + /** + * Set the event listener for the specified typenames and return the drag behavior. + * If an event listener was already registered for the same type and name, + * the existing listener is removed before the new listener is added. + * When a specified event is dispatched, each listener will be invoked with the same context and arguments as selection.on listeners. + * + * Equivalent to drag.on, but only applies to the current drag gesture. Before the drag gesture starts, + * a copy of the current drag event listeners is made. This copy is bound to the current drag gesture + * and modified by event.on. This is useful for temporary listeners that only receive events for the current drag gesture. + * + * @param typenames The typenames is a string containing one or more typename separated by whitespace. + * Each typename is a type, optionally followed by a period (.) and a name, such as "drag.foo"" and "drag.bar"; + * the name allows multiple listeners to be registered for the same type. The type must be one of the following: + * start (after a new pointer becomes active [on mousedown or touchstart]), drag (after an active pointer moves [on mousemove or touchmove], or + * end (after an active pointer becomes inactive [on mouseup, touchend or touchcancel].) + * @param listener An event listener function which is evaluated for each selected element, + * in order, being passed the current datum (d), the current index (i), and the current group (nodes), + * with this as the current DOM element. + */ + on(typenames: string, listener: ValueFn<GElement, Datum, void>): this; +} + +/** + * Prevents native drag-and-drop and text selection on the specified window. + * As an alternative to preventing the default action of mousedown events, + * this method prevents undesirable default actions following mousedown. In supported browsers, + * this means capturing dragstart and selectstart events, preventing the associated default actions, + * and immediately stopping their propagation. In browsers that do not support selection events, + * the user-select CSS property is set to none on the document element. + * This method is intended to be called on mousedown, followed by d3.dragEnable on mouseup. + * + * @param window The window for which drag should be disabled. + */ +export function dragDisable(window: Window): void; + +/** + * Allows native drag-and-drop and text selection on the specified window; undoes the effect of d3.dragDisable. + * This method is intended to be called on mouseup, preceded by d3.dragDisable on mousedown. + * If noclick is true, this method also temporarily suppresses click events. + * The suppression of click events expires after a zero-millisecond timeout, + * such that it only suppress the click event that would immediately follow the current mouseup event, if any. + * + * @param window The window for which drag should be (re-)enabled. + * @param noClick An optional flag. If noclick is true, this method also temporarily suppresses click events. + */ +export function dragEnable(window: Window, noClick?: boolean): void; diff --git a/chromium/third_party/node/node_modules/@types/d3-force/index.d.ts b/chromium/third_party/node/node_modules/@types/d3-force/index.d.ts new file mode 100755 index 00000000000..a114693ab14 --- /dev/null +++ b/chromium/third_party/node/node_modules/@types/d3-force/index.d.ts @@ -0,0 +1,1249 @@ +// Type definitions for D3JS d3-force module 1.2 +// Project: https://github.com/d3/d3-force/, https://d3js.org/d3-force +// 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> +// Nathan Bierema <https://github.com/Methuselah96> +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +// Last module patch version validated against: 1.2.1 + +// ----------------------------------------------------------------------- +// Force Simulation +// ----------------------------------------------------------------------- + +/** + * The base data structure for the datum of a Simulation Node. + * The optional properties contained in this data structure are internally assigned + * by the Simulation upon (re-)initialization. + * + * When defining a data type to use for node data, it should be an extension of this interface + * and respect the already "earmarked" properties used by the simulation. + * + * IMPORTANT: Prior to initialization, the following properties are optional: index, x, y, vx, and vy. + * After initialization they will be defined. The optional properties fx and fy are ONLY defined, + * if the node's position has been fixed. + */ +export interface SimulationNodeDatum { + /** + * Node’s zero-based index into nodes array. This property is set during the initialization process of a simulation. + */ + index?: number | undefined; + /** + * Node’s current x-position + */ + x?: number | undefined; + /** + * Node’s current y-position + */ + y?: number | undefined; + /** + * Node’s current x-velocity + */ + vx?: number | undefined; + /** + * Node’s current y-velocity + */ + vy?: number | undefined; + /** + * Node’s fixed x-position (if position was fixed) + */ + fx?: number | null | undefined; + /** + * Node’s fixed y-position (if position was fixed) + */ + fy?: number | null | undefined; +} + +/** + * The base data structure for the datum of a Simulation Link, as used by ForceLink. + * The optional properties contained in this data structure are internally assigned + * by when initializing with ForceLink.links(...) + * + * + * IMPORTANT: The source and target properties may be internally mutated in type during the + * ForceLink initialization process (possibly being changed from a node index in the nodes array, + * or a node id string to the simulation node object which was mapped in using the current + * ForceLink.id(...) accessor function.) + */ +export interface SimulationLinkDatum<NodeDatum extends SimulationNodeDatum> { + /** + * Link’s source node. + * For convenience, a link’s source and target properties may be initialized using numeric or string identifiers rather than object references; see link.id. + * When the link force is initialized (or re-initialized, as when the nodes or links change), any link.source or link.target property which is not an object + * is replaced by an object reference to the corresponding node with the given identifier. + * After initialization, the source property represents the source node object. + */ + source: NodeDatum | string | number; + /** + * Link’s source link + * For convenience, a link’s source and target properties may be initialized using numeric or string identifiers rather than object references; see link.id. + * When the link force is initialized (or re-initialized, as when the nodes or links change), any link.source or link.target property which is not an object + * is replaced by an object reference to the corresponding node with the given identifier. + * After initialization, the target property represents the target node object. + */ + target: NodeDatum | string | number; + /** + * The zero-based index into the links array. Internally generated when calling ForceLink.links(...) + */ + index?: number | undefined; +} + +/** + * A Force Simulation + * + * The first generic refers to the type of the datum associated with a node in the simulation. + * The second generic refers to the type of the datum associated with a link in the simulation, if applicable. + * + */ +export interface Simulation<NodeDatum extends SimulationNodeDatum, LinkDatum extends SimulationLinkDatum<NodeDatum> | undefined> { + /** + * Restart the simulation’s internal timer and return the simulation. + * In conjunction with simulation.alphaTarget or simulation.alpha, this method can be used to “reheat” the simulation during interaction, + * such as when dragging a node, or to resume the simulation after temporarily pausing it with simulation.stop. + */ + restart(): this; + + /** + * Stop the simulation’s internal timer, if it is running, and return the simulation. If the timer is already stopped, this method does nothing. + * This method is useful for running the simulation manually; see simulation.tick. + */ + stop(): this; + + /** + * Manually steps the simulation by the specified number of *iterations*, and returns the simulation. If *iterations* is not specified, it defaults to 1 (single step). + * + * For each iteration, it increments the current alpha by (alphaTarget - alpha) × alphaDecay; then invokes each registered force, passing the new alpha; + * then decrements each node’s velocity by velocity × velocityDecay; lastly increments each node’s position by velocity. + * + * This method does not dispatch events; events are only dispatched by the internal timer when the simulation is started automatically upon + * creation or by calling simulation.restart. The natural number of ticks when the simulation is started is + * ⌈log(alphaMin) / log(1 - alphaDecay)⌉; by default, this is 300. + */ + tick(iterations?: number): this; + + /** + * Returns the simulation’s array of nodes as specified to the constructor. + */ + nodes(): NodeDatum[]; + /** + * Set the simulation’s nodes to the specified array of objects, initialize their positions and velocities if necessary, + * and then re-initialize any bound forces; Returns the simulation. + * + * Each node must be an object. The following properties are assigned by the simulation: + * - index (the node’s zero-based index into nodes) + * - x (the node’s current x-position) + * - y (the node’s current y-position) + * - vx (the node’s current x-velocity) + * - vy (the node’s current y-velocity) + * + * The position [x,y] and velocity [vx,vy] may be subsequently modified by forces and by the simulation. + * If either vx or vy is NaN, the velocity is initialized to [0,0]. If either x or y is NaN, the position is initialized in a phyllotaxis arrangement, + * so chosen to ensure a deterministic, uniform distribution around the origin. + * + * To fix a node in a given position, you may specify two additional properties: + * - fx (the node’s fixed x-position) + * - fy (the node’s fixed y-position) + * + * At the end of each tick, after the application of any forces, a node with a defined node.fx has node.x reset to this value and node.vx set to zero; + * likewise, a node with a defined node.fy has node.y reset to this value and node.vy set to zero. + * To unfix a node that was previously fixed, set node.fx and node.fy to null, or delete these properties. + * + * If the specified array of nodes is modified, such as when nodes are added to or removed from the simulation, + * this method must be called again with the new (or changed) array to notify the simulation and bound forces of the change; + * the simulation does not make a defensive copy of the specified array. + */ + nodes(nodesData: NodeDatum[]): this; + + /** + * Return the current alpha of the simulation, which defaults to 1. + */ + alpha(): number; + /** + * Set the current alpha to the specified number in the range [0,1] and return this simulation. + * The default is 1. + * + * @param alpha Current alpha of simulation. + */ + alpha(alpha: number): this; + + /** + * Return the current minimum alpha value, which defaults to 0.001. + */ + alphaMin(): number; + /** + * Set the minimum alpha to the specified number in the range [0,1] and return this simulation. + * The default is 0.001. The simulation’s internal timer stops when the current alpha is less than the minimum alpha. + * The default alpha decay rate of ~0.0228 corresponds to 300 iterations. + * + * @param min Minimum alpha of simulation. + */ + alphaMin(min: number): this; + + /** + * Return the current alpha decay rate, which defaults to 0.0228… = 1 - pow(0.001, 1 / 300) where 0.001 is the default minimum alpha. + */ + alphaDecay(): number; + /** + * Set the alpha decay rate to the specified number in the range [0,1] and return this simulation. + * The default is 0.0228… = 1 - pow(0.001, 1 / 300) where 0.001 is the default minimum alpha. + * + * The alpha decay rate determines how quickly the current alpha interpolates towards the desired target alpha; + * since the default target alpha is zero, by default this controls how quickly the simulation cools. + * Higher decay rates cause the simulation to stabilize more quickly, but risk getting stuck in a local minimum; + * lower values cause the simulation to take longer to run, but typically converge on a better layout. + * To have the simulation run forever at the current alpha, set the decay rate to zero; + * alternatively, set a target alpha greater than the minimum alpha. + * + * @param decay Alpha decay rate. + */ + alphaDecay(decay: number): this; + + /** + * Returns the current target alpha value, which defaults to 0. + */ + alphaTarget(): number; + /** + * Set the current target alpha to the specified number in the range [0,1] and return this simulation. + * The default is 0. + * + * @param target Alpha target value. + */ + alphaTarget(target: number): this; + + /** + * Return the current target alpha value, which defaults to 0.4. + */ + velocityDecay(): number; + /** + * Set the velocity decay factor to the specified number in the range [0,1] and return this simulation. + * The default is 0.4. + * + * The decay factor is akin to atmospheric friction; after the application of any forces during a tick, + * each node’s velocity is multiplied by 1 - decay. As with lowering the alpha decay rate, + * less velocity decay may converge on a better solution, but risks numerical instabilities and oscillation. + * + * @param decay Velocity Decay. + */ + velocityDecay(decay: number): this; + + /** + * Return the force with the specified name, or undefined if there is no such force. + * (By default, new simulations have no forces.) + * + * Given that it is in general not known, what type of force has been registered under + * a specified name, use the generic to cast the result to the appropriate type, if known. + * + * @param name Name of the registered force. + */ + force<F extends Force<NodeDatum, LinkDatum>>(name: string): F| undefined; + /** + * Remove a previously registered force. + * + * @param name Name of the registered force. + * @param force Use null to remove force. + */ + force(name: string, force: null): this; + /** + * Assign the force for the specified name and return this simulation. + * (By default, new simulations have no forces.) + * + * @param name Name to register the force under. + * @param force A force to use with the simulation. + */ + force(name: string, force: Force<NodeDatum, LinkDatum>): this; + + /** + * Return the node closest to the position [x,y] with the given search radius. + * If radius is not specified, it defaults to infinity. + * If there is no node within the search area, returns undefined. + * + * @param x x-coordinate + * @param y y-coordinate + * @param radius Optional search radius. Defaults to infinity. + */ + find(x: number, y: number, radius?: number): NodeDatum | undefined; + + /** + * Return the first currently-assigned listener matching the specified typenames, if any. + * + * @param typenames The typenames is a string containing one or more typename separated by whitespace. Each typename is a type, + * optionally followed by a period (.) and a name, such as "tick.foo" and "tick.bar"; the name allows multiple listeners to be registered for the same type. + * The type must be one of the following: "tick" (after each tick of the simulation’s internal timer) or + * "end" (after the simulation’s timer stops when alpha < alphaMin). + */ + on(typenames: 'tick' | 'end' | string): ((this: Simulation<NodeDatum, LinkDatum>) => void) | undefined; + /** + * Remove the current event listeners for the specified typenames, if any, return the simulation. + * + * @param typenames The typenames is a string containing one or more typename separated by whitespace. Each typename is a type, + * optionally followed by a period (.) and a name, such as "tick.foo" and "tick.bar"; the name allows multiple listeners to be registered for the same type. + * The type must be one of the following: "tick" (after each tick of the simulation’s internal timer) or + * "end" (after the simulation’s timer stops when alpha < alphaMin). + * @param listener Use null to remove the listener. + */ + on(typenames: 'tick' | 'end' | string, listener: null): this; + /** + * Set the event listener for the specified typenames and return this simulation. + * If an event listener was already registered for the same type and name, + * the existing listener is removed before the new listener is added. + * When a specified event is dispatched, each listener will be invoked with the this context as the simulation. + * + * The type must be one of the following: + * - tick [after each tick of the simulation’s internal timer] + * - end [after the simulation’s timer stops when alpha < alphaMin] + * + * Note that tick events are not dispatched when simulation.tick is called manually; + * events are only dispatched by the internal timer and are intended for interactive rendering of the simulation. + * To affect the simulation, register forces instead of modifying nodes’ positions or velocities inside a tick event listener. + * + * @param typenames The typenames is a string containing one or more typename separated by whitespace. Each typename is a type, + * optionally followed by a period (.) and a name, such as "tick.foo" and "tick.bar"; the name allows multiple listeners to be registered for the same type. + * The type must be one of the following: "tick" (after each tick of the simulation’s internal timer) or + * "end" (after the simulation’s timer stops when alpha < alphaMin). + * @param listener An event listener function which is invoked with the this context of the simulation. + */ + on(typenames: 'tick' | 'end' | string, listener: (this: this) => void): this; +} + +/** + * Create a new simulation with the specified array of nodes and no forces. + * If nodes is not specified, it defaults to the empty array. + * The simulator starts automatically; use simulation.on to listen for tick events as the simulation runs. + * If you wish to run the simulation manually instead, call simulation.stop, and then call simulation.tick as desired. + * + * Use this signature, when creating a simulation WITHOUT link force(s). + * + * The generic refers to the type of the data for a node. + * + * @param nodesData Optional array of nodes data, defaults to empty array. + */ +export function forceSimulation<NodeDatum extends SimulationNodeDatum>(nodesData?: NodeDatum[]): Simulation<NodeDatum, undefined>; +/** + * Create a new simulation with the specified array of nodes and no forces. + * If nodes is not specified, it defaults to the empty array. + * The simulator starts automatically; use simulation.on to listen for tick events as the simulation runs. + * If you wish to run the simulation manually instead, call simulation.stop, and then call simulation.tick as desired. + * + * Use this signature, when creating a simulation WITH link force(s). + * + * The first generic refers to the type of data for a node. + * The second generic refers to the type of data for a link. + * + * @param nodesData Optional array of nodes data, defaults to empty array. + */ +export function forceSimulation<NodeDatum extends SimulationNodeDatum, LinkDatum extends SimulationLinkDatum<NodeDatum>>(nodesData?: NodeDatum[]): Simulation<NodeDatum, LinkDatum>; + +// ---------------------------------------------------------------------- +// Forces +// ---------------------------------------------------------------------- + +/** + * A force is simply a function that modifies nodes’ positions or velocities; in this context, a force can apply a classical physical force such as electrical charge or gravity, + * or it can resolve a geometric constraint, such as keeping nodes within a bounding box or keeping linked nodes a fixed distance apart. + * + * Forces typically read the node’s current position [x,y] and then add to (or subtract from) the node’s velocity [vx,vy]. + * However, forces may also “peek ahead” to the anticipated next position of the node, [x + vx,y + vy]; this is necessary for resolving geometric constraints through iterative relaxation. + * Forces may also modify the position directly, which is sometimes useful to avoid adding energy to the simulation, such as when recentering the simulation in the viewport. + * + * Forces may optionally implement force.initialize to receive the simulation’s array of nodes. + */ +export interface Force<NodeDatum extends SimulationNodeDatum, LinkDatum extends SimulationLinkDatum<NodeDatum> | undefined> { + /** + * Apply this force, optionally observing the specified alpha. + * Typically, the force is applied to the array of nodes previously passed to force.initialize, + * however, some forces may apply to a subset of nodes, or behave differently. + * For example, d3.forceLink applies to the source and target of each link. + */ + (alpha: number): void; + /** + * Assign the array of nodes to this force. This method is called when a force is bound to a simulation via simulation.force + * and when the simulation’s nodes change via simulation.nodes. + * + * A force may perform necessary work during initialization, such as evaluating per-node parameters, to avoid repeatedly performing work during each application of the force. + */ + initialize?(nodes: NodeDatum[]): void; +} + +// Centering ------------------------------------------------------------ + +/** + * The centering force translates nodes uniformly so that the mean position of all nodes + * (the center of mass if all nodes have equal weight) is at the given position [x,y]. + * This force modifies the positions of nodes on each application; it does not modify velocities, + * as doing so would typically cause the nodes to overshoot and oscillate around the desired center. + * This force helps keeps nodes in the center of the viewport, and unlike the positioning force, + * it does not distort their relative positions. + * + * The generic refers to the type of data for a node. + */ +export interface ForceCenter<NodeDatum extends SimulationNodeDatum> extends Force<NodeDatum, any> { + /** + * Assign the array of nodes to this force. This method is called when a force is bound to a simulation via simulation.force + * and when the simulation’s nodes change via simulation.nodes. + * + * A force may perform necessary work during initialization, such as evaluating per-node parameters, to avoid repeatedly performing work during each application of the force. + */ + initialize(nodes: NodeDatum[]): void; + + /** + * Return the current x-coordinate of the centering position, which defaults to zero. + */ + x(): number; + /** + * Set the x-coordinate of the centering position. + * + * @param x x-coordinate. + */ + x(x: number): this; + + /** + * Return the current y-coordinate of the centering position, which defaults to zero. + */ + y(): number; + /** + * Set the y-coordinate of the centering position. + * + * @param y y-coordinate. + */ + y(y: number): this; +} + +/** + * Create a new centering force with the specified x- and y- coordinates. + * If x and y are not specified, they default to [0,0]. + * + * The centering force translates nodes uniformly so that the mean position of all nodes + * (the center of mass if all nodes have equal weight) is at the given position [x,y]. + * This force modifies the positions of nodes on each application; it does not modify velocities, + * as doing so would typically cause the nodes to overshoot and oscillate around the desired center. + * This force helps keeps nodes in the center of the viewport, and unlike the positioning force, + * it does not distort their relative positions. + * + * The generic refers to the type of data for a node. + * + * @param x An optional x-coordinate for the centering position, defaults to 0. + * @param y An optional y-coordinate for the centering position, defaults to 0. + */ +export function forceCenter<NodeDatum extends SimulationNodeDatum>(x?: number, y?: number): ForceCenter<NodeDatum>; + +// Collision ------------------------------------------------------------ + +/** + * The collision force treats nodes as circles with a given radius, rather than points, and prevents nodes from overlapping. + * More formally, two nodes a and b are separated so that the distance between a and b is at least radius(a) + radius(b). + * To reduce jitter, this is by default a “soft” constraint with a configurable strength and iteration count. + * + * The generic refers to the type of data for a node. + */ +export interface ForceCollide<NodeDatum extends SimulationNodeDatum> extends Force<NodeDatum, any> { + /** + * Assign the array of nodes to this force. This method is called when a force is bound to a simulation via simulation.force + * and when the simulation’s nodes change via simulation.nodes. + * + * A force may perform necessary work during initialization, such as evaluating per-node parameters, to avoid repeatedly performing work during each application of the force. + */ + initialize(nodes: NodeDatum[]): void; + + /** + * Returns the current radius accessor function. + */ + radius(): (node: NodeDatum, i: number, nodes: NodeDatum[]) => number; + /** + * Set the radius used in collision detection to a constant number for each node. + * + * The constant is internally wrapped into a radius accessor function. + * + * The radius accessor is invoked for each node in the simulation, being passed the node, its zero-based index and the complete array of nodes. + * The resulting number is then stored internally, such that the radius of each node is only recomputed + * when the force is initialized or when this method is called with a new radius, and not on every application of the force. + * + * @param radius A constant radius for each node. + */ + radius(radius: number): this; + /** + * Set the radius accessor function determining the radius for each node in collision detection. + * + * The radius accessor is invoked for each node in the simulation, being passed the node, its zero-based index and the complete array of nodes. + * The resulting number is then stored internally, such that the radius of each node is only recomputed + * when the force is initialized or when this method is called with a new radius, and not on every application of the force. + * + * @param radius A radius accessor function which is invoked for each node in the simulation, being passed the node, its zero-based index and the complete array of nodes. + * The function returns a radius. + */ + radius(radius: (node: NodeDatum, i: number, nodes: NodeDatum[]) => number): this; + + /** + * Return the current strength, which defaults to 0.7. + */ + strength(): number; + /** + * Set the force strength to the specified number in the range [0,1] and return this force. + * The default strength is 0.7. + * + * Overlapping nodes are resolved through iterative relaxation. + * For each node, the other nodes that are anticipated to overlap at the next tick (using the anticipated positions [x + vx,y + vy]) are determined; + * the node’s velocity is then modified to push the node out of each overlapping node. + * The change in velocity is dampened by the force’s strength such that the resolution of simultaneous overlaps can be blended together to find a stable solution. + * + * @param strength Strength. + */ + strength(strength: number): this; + + /** + * Return the current iteration count which defaults to 1. + */ + iterations(): number; + /** + * Sets the number of iterations per application to the specified number and return this force. + * + * Increasing the number of iterations greatly increases the rigidity of the constraint and avoids partial overlap of nodes, + * but also increases the runtime cost to evaluate the force. + * + * @param iterations Number of iterations. + */ + iterations(iterations: number): this; +} + +/** + * Creates a new circle collision force with the default radius one for all nodes. + * + * The collision force treats nodes as circles with a given radius, rather than points, and prevents nodes from overlapping. + * More formally, two nodes a and b are separated so that the distance between a and b is at least radius(a) + radius(b). + * To reduce jitter, this is by default a “soft” constraint with a configurable strength and iteration count. + * + * The generic refers to the type of data for a node. + */ +export function forceCollide<NodeDatum extends SimulationNodeDatum>(): ForceCollide<NodeDatum>; +/** + * Create a new circle collision force with the specified constant radius for all nodes. + * + * The collision force treats nodes as circles with a given radius, rather than points, and prevents nodes from overlapping. + * More formally, two nodes a and b are separated so that the distance between a and b is at least radius(a) + radius(b). + * To reduce jitter, this is by default a “soft” constraint with a configurable strength and iteration count. + * + * The generic refers to the type of data for a node. + * + * @param radius A constant radius for each node. + */ +export function forceCollide<NodeDatum extends SimulationNodeDatum>(radius: number): ForceCollide<NodeDatum>; +/** + * Creates a new circle collision force with the specified radius accessor function. + * + * The collision force treats nodes as circles with a given radius, rather than points, and prevents nodes from overlapping. + * More formally, two nodes a and b are separated so that the distance between a and b is at least radius(a) + radius(b). + * To reduce jitter, this is by default a “soft” constraint with a configurable strength and iteration count. + * + * The radius accessor is invoked for each node in the simulation, being passed the node, its zero-based index and the complete array of nodes. + * The resulting number is then stored internally, such that the radius of each node is only recomputed + * when the force is initialized or when this method is called with a new radius, and not on every application of the force. + * + * @param radius A radius accessor function which is invoked for each node in the simulation, being passed the node, its zero-based index and the complete array of nodes. + * The function returns a radius. + */ +export function forceCollide<NodeDatum extends SimulationNodeDatum>(radius: (node: NodeDatum, i: number, nodes: NodeDatum[]) => number): ForceCollide<NodeDatum>; + +// Link ---------------------------------------------------------------- + +/** + * The link force pushes linked nodes together or apart according to the desired link distance. + * The strength of the force is proportional to the difference between the linked nodes’ distance and the target distance, similar to a spring force. + * + * The first generic refers to the type of data for a node. + * The second generic refers to the type of data for a link. + */ +export interface ForceLink<NodeDatum extends SimulationNodeDatum, LinkDatum extends SimulationLinkDatum<NodeDatum>> extends Force<NodeDatum, LinkDatum> { + /** + * Assign the array of nodes to this force. This method is called when a force is bound to a simulation via simulation.force + * and when the simulation’s nodes change via simulation.nodes. + * + * A force may perform necessary work during initialization, such as evaluating per-node parameters, to avoid repeatedly performing work during each application of the force. + */ + initialize(nodes: NodeDatum[]): void; + + /** + * Return the current array of links, which defaults to the empty array. + * + */ + links(): LinkDatum[]; + /** + * Set the array of links associated with this force, recompute the distance and strength parameters for each link, and return this force. + * + * Each link is an object with the following properties: + * * source - the link’s source node; see simulation.nodes + * * target - the link’s target node; see simulation.nodes + * * index - the zero-based index into links, assigned by this method + * + * For convenience, a link’s source and target properties may be initialized using numeric or string identifiers rather than object references; see link.id. + * When the link force is initialized (or re-initialized, as when the nodes or links change), any link.source or link.target property which is not an object + * is replaced by an object reference to the corresponding node with the given identifier. + * If the specified array of links is modified, such as when links are added to or removed from the simulation, + * this method must be called again with the new (or changed) array to notify the force of the change; + * the force does not make a defensive copy of the specified array. + * + * @param links An array of link data. + */ + links(links: LinkDatum[]): this; + + /** + * Return the current node id accessor, which defaults to the numeric node.index. + */ + id(): (node: NodeDatum, i: number, nodesData: NodeDatum[]) => (string | number); + /** + * Set the node id accessor to the specified function and return this force. + * + * The default id accessor allows each link’s source and target to be specified as a zero-based index + * into the nodes array. + * + * The id accessor is invoked for each node whenever the force is initialized, + * as when the nodes or links change, being passed the node, the zero-based index of the node in the node array, and the node array. + * + * @param id A node id accessor function which is invoked for each node in the simulation, + * being passed the node, the zero-based index of the node in the node array, and the node array. It returns a string to represent the node id which can be used + * for matching link source and link target strings during the ForceLink initialization. + */ + id(id: (node: NodeDatum, i: number, nodesData: NodeDatum[]) => string): this; + + /** + * Return the current distance accessor, which defaults to implying a default distance of 30. + */ + distance(): (link: LinkDatum, i: number, links: LinkDatum[]) => number; + /** + * Set the distance accessor to use the specified constant number for all links, + * re-evaluates the distance accessor for each link, and returns this force. + * + * The constant is internally wrapped into a distance accessor function. + * + * The distance accessor is invoked for each link, being passed the link, its zero-based index and the complete array of links. + * The resulting number is then stored internally, such that the distance of each link is only recomputed when the force is initialized or + * when this method is called with a new distance, and not on every application of the force. + * + * @param distance The constant distance to be used for all links. + */ + distance(distance: number): this; + /** + * Set the distance accessor to use the specified function, + * re-evaluates the distance accessor for each link, and returns this force. + * + * The distance accessor is invoked for each link, being passed the link, its zero-based index and the complete array of links. + * The resulting number is then stored internally, such that the distance of each link is only recomputed when the force is initialized or + * when this method is called with a new distance, and not on every application of the force. + * + * @param distance A distance accessor function which is invoked for each link being passed the link, + * its zero-based index and the complete array of links. It returns the distance. + */ + distance(distance: (link: LinkDatum, i: number, links: LinkDatum[]) => number): this; + + /** + * Return the current strength accessor. + * For details regarding the default behavior see: {@link https://github.com/d3/d3-force#link_strength} + */ + strength(): (link: LinkDatum, i: number, links: LinkDatum[]) => number; + /** + * Set the strength accessor to use the specified constant number for all links, + * re-evaluates the strength accessor for each link, and returns this force. + * + * The constant is internally wrapped into a strength accessor function. + * + * The strength accessor is invoked for each link, being passed the link, its zero-based index and the complete array of links. + * The resulting number is then stored internally, such that the strength of each link is only recomputed + * when the force is initialized or when this method is called with a new strength, and not on every application of the force. + * + * @param strength The constant strength to be used for all links. + */ + strength(strength: number): this; + /** + * Set the strength accessor to use the specified function, + * re-evaluates the strength accessor for each link, and returns this force. + * + * The strength accessor is invoked for each link, being passed the link, its zero-based index and the complete array of links. + * The resulting number is then stored internally, such that the strength of each link is only recomputed + * when the force is initialized or when this method is called with a new strength, and not on every application of the force. + * + * @param strength A distance accessor function which is invoked for each link being passed the link, + * its zero-based index and the complete array of links. It returns the strength. + */ + strength(strength: (link: LinkDatum, i: number, links: LinkDatum[]) => number): this; + + /** + * Return the current iteration count which defaults to 1. + */ + iterations(): number; + /** + * Sets the number of iterations per application to the specified number and return this force. + * + * Increasing the number of iterations greatly increases the rigidity of the constraint and is useful for complex structures such as lattices, + * but also increases the runtime cost to evaluate the force. + * + * @param iterations Number of iterations. + */ + iterations(iterations: number): this; +} + +/** + * Creates a new link force with the defaulting links to an empty array. + * + * The link force pushes linked nodes together or apart according to the desired link distance. + * The strength of the force is proportional to the difference between the linked nodes’ distance and the target distance, similar to a spring force. + * + * The first generic refers to the type of data for a node. + * The second generic refers to the type of data for a link. + */ +export function forceLink<NodeDatum extends SimulationNodeDatum, LinksDatum extends SimulationLinkDatum<NodeDatum>>(): ForceLink<NodeDatum, LinksDatum>; +/** + * Creates a new link force with the specified links array. + * + * The link force pushes linked nodes together or apart according to the desired link distance. + * The strength of the force is proportional to the difference between the linked nodes’ distance and the target distance, similar to a spring force. + * + * The first generic refers to the type of data for a node. + * The second generic refers to the type of data for a link. + * + * @param links An array of link data. + */ +export function forceLink<NodeDatum extends SimulationNodeDatum, LinksDatum extends SimulationLinkDatum<NodeDatum>>(links: LinksDatum[]): ForceLink<NodeDatum, LinksDatum>; + +// Many Body ---------------------------------------------------------------- + +/** + * The many-body (or n-body) force applies mutually amongst all nodes. It can be used to simulate gravity (attraction) if the strength is positive, + * or electrostatic charge (repulsion) if the strength is negative. This implementation uses quadtrees and the Barnes–Hut approximation to greatly + * improve performance; the accuracy can be customized using the theta parameter. + * + * Unlike links, which only affect two linked nodes, the charge force is global: every node affects every other node, even if they are on disconnected subgraphs. + * + * The generic refers to the type of data for a node. + */ +export interface ForceManyBody<NodeDatum extends SimulationNodeDatum> extends Force<NodeDatum, any> { + /** + * Assign the array of nodes to this force. This method is called when a force is bound to a simulation via simulation.force + * and when the simulation’s nodes change via simulation.nodes. + * + * A force may perform necessary work during initialization, such as evaluating per-node parameters, to avoid repeatedly performing work during each application of the force. + */ + initialize(nodes: NodeDatum[]): void; + + /** + * Return the current strength accessor. + * + * For details regarding the default behavior see: {@link https://github.com/d3/d3-force#manyBody_strength} + */ + strength(): (d: NodeDatum, i: number, data: NodeDatum[]) => number; + /** + * Set the strength accessor to the specified constant strength for all nodes, re-evaluates the strength accessor for each node, and + * returns this force. + * + * A positive value causes nodes to attract each other, similar to gravity, while a negative value causes nodes to repel each other, + * similar to electrostatic charge. + * + * The default represents a constant value of -30. + * + * The constant is internally wrapped into a strength accessor function. + * + * The strength accessor is invoked for each node in the simulation, being passed the node, its zero-based index and the complete array of nodes. + * The resulting number is then stored internally, such that the strength of each node is only recomputed when the force is initialized or + * when this method is called with a new strength, and not on every application of the force. + * + * @param strength The constant strength to be used for all nodes. + */ + strength(strength: number): this; + /** + * Set the strength accessor to the specified function, re-evaluates the strength accessor for each node, and + * returns this force. + * + * A positive value causes nodes to attract each other, similar to gravity, while a negative value causes nodes to repel each other, + * similar to electrostatic charge. + * + * The default represents a constant value of -30. + * + * The strength accessor is invoked for each node in the simulation, being passed the node, its zero-based index and the complete array of nodes. + * The resulting number is then stored internally, such that the strength of each node is only recomputed when the force is initialized or + * when this method is called with a new strength, and not on every application of the force. + * + * @param strength A strength accessor function which is invoked for each node in the simulation, being passed the node, its zero-based index and the complete array of nodes. + * The function returns the strength. + */ + strength(strength: (d: NodeDatum, i: number, data: NodeDatum[]) => number): this; + + /** + * Return the current value of the Barnes–Hut approximation criterion , which defaults to 0.9 + */ + theta(): number; + /** + * Set the Barnes–Hut approximation criterion to the specified number and returns this force. + * + * To accelerate computation, this force implements the Barnes–Hut approximation which takes O(n log n) per application + * where n is the number of nodes. For each application, a quadtree stores the current node positions; + * then for each node, the combined force of all other nodes on the given node is computed. + * For a cluster of nodes that is far away, the charge force can be approximated by treating the cluster as a single, larger node. + * The theta parameter determines the accuracy of the approximation: + * if the ratio w / l of the width w of the quadtree cell to the distance l from the node to the cell’s center of mass is less than theta, + * all nodes in the given cell are treated as a single node rather than individually. + * + * The default value is 0.9. + * + * @param theta Value for the theta parameter. + */ + theta(theta: number): this; + + /** + * Returns the current minimum distance over which this force is considered, which defaults to 1. + */ + distanceMin(): number; + /** + * Sets the minimum distance between nodes over which this force is considered. + * + * A minimum distance establishes an upper bound on the strength of the force between two nearby nodes, avoiding instability. + * In particular, it avoids an infinitely-strong force if two nodes are exactly coincident; in this case, the direction of the force is random. + * + * The default value is 1. + * + * @param distance The minimum distance between nodes over which this force is considered. + */ + distanceMin(distance: number): this; + + /** + * Returns the current maximum distance over which this force is considered, which defaults to infinity. + */ + distanceMax(): number; + /** + * Sets the maximum distance between nodes over which this force is considered. + * + * Specifying a finite maximum distance improves performance and produces a more localized layout. + * + * The default value is infinity. + * + * @param distance The maximum distance between nodes over which this force is considered. + */ + distanceMax(distance: number): this; +} + +/** + * Creates a new many-body force with the default parameters. + * + * The many-body (or n-body) force applies mutually amongst all nodes. It can be used to simulate gravity (attraction) if the strength is positive, + * or electrostatic charge (repulsion) if the strength is negative. This implementation uses quadtrees and the Barnes–Hut approximation to greatly + * improve performance; the accuracy can be customized using the theta parameter. + * + * Unlike links, which only affect two linked nodes, the charge force is global: every node affects every other node, even if they are on disconnected subgraphs. + * + * The generic refers to the type of data for a node. + */ +export function forceManyBody<NodeDatum extends SimulationNodeDatum>(): ForceManyBody<NodeDatum>; + +// Positioning ---------------------------------------------------------------- + +/** + * The x-positioning force pushes nodes towards a desired position along the given dimension with a configurable strength. + * The strength of the force is proportional to the one-dimensional distance between the node’s position and the target position. + * While this force can be used to position individual nodes, it is intended primarily for global forces that apply to all (or most) nodes. + * + * The generic refers to the type of data for a node. + */ +export interface ForceX<NodeDatum extends SimulationNodeDatum> extends Force<NodeDatum, any> { + /** + * Assign the array of nodes to this force. This method is called when a force is bound to a simulation via simulation.force + * and when the simulation’s nodes change via simulation.nodes. + * + * A force may perform necessary work during initialization, such as evaluating per-node parameters, to avoid repeatedly performing work during each application of the force. + */ + initialize(nodes: NodeDatum[]): void; + + /** + * Returns the current strength accessor, which defaults to a constant strength for all nodes of 0.1. + */ + strength(): (d: NodeDatum, i: number, data: NodeDatum[]) => number; + /** + * Set the strength accessor to the specified constant strength for all nodes, re-evaluates the strength accessor for each node, and returns this force. + * + * The strength determines how much to increment the node’s x-velocity: (x - node.x) × strength. + * + * For example, a value of 0.1 indicates that the node should move a tenth of the way from its current x-position to the target x-position with each application. + * Higher values moves nodes more quickly to the target position, often at the expense of other forces or constraints. + * + * A value outside the range [0,1] is not recommended. + * + * The constant is internally wrapped into a strength accessor function. + * + * The strength accessor is invoked for each node in the simulation, being passed the node, its zero-based index and the complete array of nodes. + * The resulting number is then stored internally, such that the strength of each node is only recomputed when the force is initialized or + * when this method is called with a new strength, and not on every application of the force. + * + * @param strength Constant value of strength to be used for all nodes. + */ + strength(strength: number): this; + /** + * Set the strength accessor to the specified function, re-evaluates the strength accessor for each node, and returns this force. + * + * The strength determines how much to increment the node’s x-velocity: (x - node.x) × strength. + * + * For example, a value of 0.1 indicates that the node should move a tenth of the way from its current x-position to the target x-position with each application. + * Higher values moves nodes more quickly to the target position, often at the expense of other forces or constraints. + * + * A value outside the range [0,1] is not recommended. + * + * The strength accessor is invoked for each node in the simulation, being passed the node, its zero-based index and the complete array of nodes. + * The resulting number is then stored internally, such that the strength of each node is only recomputed when the force is initialized or + * when this method is called with a new strength, and not on every application of the force. + * + * @param strength A strength accessor function which is invoked for each node in the simulation, being passed the node, its zero-based index and the complete array of nodes. + * The function returns the strength. + */ + strength(strength: (d: NodeDatum, i: number, data: NodeDatum[]) => number): this; + + /** + * Return the current x-accessor, which defaults to a function returning 0 for all nodes. + */ + x(): (d: NodeDatum, i: number, data: NodeDatum[]) => number; + /** + * Set the x-coordinate accessor to the specified number, re-evaluates the x-accessor for each node, + * and returns this force. + * + * The constant is internally wrapped into an x-coordinate accessor function. + * + * The x-accessor is invoked for each node in the simulation, being passed the node, its zero-based index and the complete array of nodes. + * The resulting number is then stored internally, such that the target x-coordinate of each node is only recomputed when the force is initialized or + * when this method is called with a new x, and not on every application of the force. + * + * @param x Constant x-coordinate to be used for all nodes. + */ + x(x: number): this; + /** + * Set the x-coordinate accessor to the specified function, re-evaluates the x-accessor for each node, + * and returns this force. + * + * The x-accessor is invoked for each node in the simulation, being passed the node, its zero-based index and the complete array of nodes. + * The resulting number is then stored internally, such that the target x-coordinate of each node is only recomputed when the force is initialized or + * when this method is called with a new x, and not on every application of the force. + * + * @param x A x-coordinate accessor function which is invoked for each node in the simulation, being passed the node, its zero-based index and the complete array of nodes. + * The function returns the x-coordinate. + */ + x(x: (d: NodeDatum, i: number, data: NodeDatum[]) => number): this; +} + +/** + * Create a new positioning force along the x-axis towards the given position x which is defaulted to a constant 0 for all nodes. + * + * The x-positioning force pushes nodes towards a desired position along the given dimension with a configurable strength. + * The strength of the force is proportional to the one-dimensional distance between the node’s position and the target position. + * While this force can be used to position individual nodes, it is intended primarily for global forces that apply to all (or most) nodes. + * + * The generic refers to the type of data for a node. + */ +export function forceX<NodeDatum extends SimulationNodeDatum>(): ForceX<NodeDatum>; +/** + * Create a new positioning force along the x-axis towards the given position x which is constant for all nodes. + * + * The x-positioning force pushes nodes towards a desired position along the given dimension with a configurable strength. + * The strength of the force is proportional to the one-dimensional distance between the node’s position and the target position. + * While this force can be used to position individual nodes, it is intended primarily for global forces that apply to all (or most) nodes. + * + * The generic refers to the type of data for a node. + * + * @param x Constant x-coordinate to be used for all nodes. + */ +export function forceX<NodeDatum extends SimulationNodeDatum>(x: number): ForceX<NodeDatum>; +/** + * Create a new positioning force along the x-axis towards the position x given by evaluating the specified x-coordinate accessor + * for each node. + * + * The x-positioning force pushes nodes towards a desired position along the given dimension with a configurable strength. + * The strength of the force is proportional to the one-dimensional distance between the node’s position and the target position. + * While this force can be used to position individual nodes, it is intended primarily for global forces that apply to all (or most) nodes. + * + * The generic refers to the type of data for a node. + * + * @param x A x-coordinate accessor function which is invoked for each node in the simulation, being passed the node and its zero-based index. + * The function returns the x-coordinate. + */ +export function forceX<NodeDatum extends SimulationNodeDatum>(x: (d: NodeDatum, i: number, data: NodeDatum[]) => number): ForceX<NodeDatum>; + +/** + * The y-positioning force pushes nodes towards a desired position along the given dimension with a configurable strength. + * The strength of the force is proportional to the one-dimensional distance between the node’s position and the target position. + * While this force can be used to position individual nodes, it is intended primarily for global forces that apply to all (or most) nodes. + * + * The generic refers to the type of data for a node. + */ +export interface ForceY<NodeDatum extends SimulationNodeDatum> extends Force<NodeDatum, any> { + /** + * Assign the array of nodes to this force. This method is called when a force is bound to a simulation via simulation.force + * and when the simulation’s nodes change via simulation.nodes. + * + * A force may perform necessary work during initialization, such as evaluating per-node parameters, to avoid repeatedly performing work during each application of the force. + */ + initialize(nodes: NodeDatum[]): void; + + /** + * Returns the current strength accessor, which defaults to a constant strength for all nodes of 0.1. + */ + strength(): (d: NodeDatum, i: number, data: NodeDatum[]) => number; + /** + * Set the strength accessor to the specified constant strength for all nodes, re-evaluates the strength accessor for each node, and returns this force. + * + * The strength determines how much to increment the node’s y-velocity: (y - node.y) × strength. + * + * For example, a value of 0.1 indicates that the node should move a tenth of the way from its current y-position to the target y-position with each application. + * Higher values moves nodes more quickly to the target position, often at the expense of other forces or constraints. + * + * A value outside the range [0,1] is not recommended. + * + * The constant is internally wrapped into a strength accessor function. + * + * The strength accessor is invoked for each node in the simulation, being passed the node, its zero-based index and the complete array of nodes. + * The resulting number is then stored internally, such that the strength of each node is only recomputed when the force is initialized or + * when this method is called with a new strength, and not on every application of the force. + * + * @param strength Constant value of strength to be used for all nodes. + */ + strength(strength: number): this; + /** + * Set the strength accessor to the specified function, re-evaluates the strength accessor for each node, and returns this force. + * + * The strength determines how much to increment the node’s y-velocity: (y - node.y) × strength. + * + * For example, a value of 0.1 indicates that the node should move a tenth of the way from its current y-position to the target y-position with each application. + * Higher values moves nodes more quickly to the target position, often at the expense of other forces or constraints. + * + * A value outside the range [0,1] is not recommended. + * + * The strength accessor is invoked for each node in the simulation, being passed the node, its zero-based index and the complete array of nodes. + * The resulting number is then stored internally, such that the strength of each node is only recomputed when the force is initialized or + * when this method is called with a new strength, and not on every application of the force. + * + * @param strength A strength accessor function which is invoked for each node in the simulation, being passed the node, its zero-based index and the complete array of nodes. + * The function returns the strength. + */ + strength(strength: (d: NodeDatum, i: number, data: NodeDatum[]) => number): this; + + /** + * Return the current y-accessor, which defaults to a function returning 0 for all nodes. + */ + y(): (d: NodeDatum, i: number, data: NodeDatum[]) => number; + /** + * Set the y-coordinate accessor to the specified number, re-evaluates the y-accessor for each node, + * and returns this force. + * + * The constant is internally wrapped into a y-coordinate accessor function. + * + * The y-accessor is invoked for each node in the simulation, being passed the node, its zero-based index and the complete array of nodes. + * The resulting number is then stored internally, such that the target y-coordinate of each node is only recomputed when the force is initialized or + * when this method is called with a new y, and not on every application of the force. + * + * @param y Constant y-coordinate to be used for all nodes. + */ + y(y: number): this; + /** + * Set the y-coordinate accessor to the specified function, re-evaluates the y-accessor for each node, + * and returns this force. + * + * The y-accessor is invoked for each node in the simulation, being passed the node, its zero-based index and the complete array of nodes. + * The resulting number is then stored internally, such that the target y-coordinate of each node is only recomputed when the force is initialized or + * when this method is called with a new y, and not on every application of the force. + * + * @param y A y-coordinate accessor function which is invoked for each node in the simulation, being passed the node, its zero-based index and the complete array of nodes. + * The function returns the y-coordinate. + */ + y(y: (d: NodeDatum, i: number, data: NodeDatum[]) => number): this; +} + +/** + * Create a new positioning force along the y-axis towards the given position y which is defaulted to a constant 0 for all nodes. + * + * The y-positioning force pushes nodes towards a desired position along the given dimension with a configurable strength. + * The strength of the force is proportional to the one-dimensional distance between the node’s position and the target position. + * While this force can be used to position individual nodes, it is intended primarily for global forces that apply to all (or most) nodes. + * + * The generic refers to the type of data for a node. + */ +export function forceY<NodeDatum extends SimulationNodeDatum>(): ForceY<NodeDatum>; +/** + * Create a new positioning force along the y-axis towards the given position y which is constant for all nodes. + * + * The y-positioning force pushes nodes towards a desired position along the given dimension with a configurable strength. + * The strength of the force is proportional to the one-dimensional distance between the node’s position and the target position. + * While this force can be used to position individual nodes, it is intended primarily for global forces that apply to all (or most) nodes. + * + * The generic refers to the type of data for a node. + * + * @param y Constant y-coordinate to be used for all nodes. + */ +export function forceY<NodeDatum extends SimulationNodeDatum>(y: number): ForceY<NodeDatum>; +/** + * Create a new positioning force along the y-axis towards the position y given by evaluating the specified y-coordinate accessor + * for each node. + * + * The y-positioning force pushes nodes towards a desired position along the given dimension with a configurable strength. + * The strength of the force is proportional to the one-dimensional distance between the node’s position and the target position. + * While this force can be used to position individual nodes, it is intended primarily for global forces that apply to all (or most) nodes. + * + * The generic refers to the type of data for a node. + * + * @param y A y-coordinate accessor function which is invoked for each node in the simulation, being passed the node and its zero-based index. + * The function returns the y-coordinate. + */ +export function forceY<NodeDatum extends SimulationNodeDatum>(y: (d: NodeDatum, i: number, data: NodeDatum[]) => number): ForceY<NodeDatum>; + +/** + * The radial force is similar to the x- and y-positioning forces, except it pushes nodes towards the closest point on a given circle. + * The circle is of the specified radius centered at ⟨x,y⟩. If x and y are not specified, they default to ⟨0,0⟩. + * The strength of the force is proportional to the one-dimensional distance between the node’s position and the target position. + * While this force can be used to position individual nodes, it is intended primarily for global forces that apply to all (or most) nodes. + * + * The generic refers to the type of data for a node. + */ +export interface ForceRadial<NodeDatum extends SimulationNodeDatum> extends Force<NodeDatum, any> { + /** + * Assign the array of nodes to this force. This method is called when a force is bound to a simulation via simulation.force + * and when the simulation’s nodes change via simulation.nodes. + * + * A force may perform necessary work during initialization, such as evaluating per-node parameters, to avoid repeatedly performing work during each application of the force. + */ + initialize(nodes: NodeDatum[]): void; + + /** + * Returns the current strength accessor, which defaults to a constant strength for all nodes of 0.1. + */ + strength(): (d: NodeDatum, i: number, data: NodeDatum[]) => number; + /** + * Set the strength accessor to the specified constant strength for all nodes, re-evaluates the strength accessor for each node, and returns this force. + * + * The strength determines how much to increment the node’s x-velocity: (x - node.x) × strength. + * + * For example, a value of 0.1 indicates that the node should move a tenth of the way from its current x-position to the target x-position with each application. + * Higher values moves nodes more quickly to the target position, often at the expense of other forces or constraints. + * + * A value outside the range [0,1] is not recommended. + * + * The constant is internally wrapped into a strength accessor function. + * + * The strength accessor is invoked for each node in the simulation, being passed the node, its zero-based index and the complete array of nodes. + * The resulting number is then stored internally, such that the strength of each node is only recomputed when the force is initialized or + * when this method is called with a new strength, and not on every application of the force. + * + * @param strength Constant value of strength to be used for all nodes. + */ + strength(strength: number): this; + /** + * Set the strength accessor to the specified function, re-evaluates the strength accessor for each node, and returns this force. + * + * The strength determines how much to increment the node’s x-velocity: (x - node.x) × strength. + * + * For example, a value of 0.1 indicates that the node should move a tenth of the way from its current x-position to the target x-position with each application. + * Higher values moves nodes more quickly to the target position, often at the expense of other forces or constraints. + * + * A value outside the range [0,1] is not recommended. + * + * The strength accessor is invoked for each node in the simulation, being passed the node, its zero-based index and the complete array of nodes. + * The resulting number is then stored internally, such that the strength of each node is only recomputed when the force is initialized or + * when this method is called with a new strength, and not on every application of the force. + * + * @param strength A strength accessor function which is invoked for each node in the simulation, being passed the node, its zero-based index and the complete array of nodes. + * The function returns the strength. + */ + strength(strength: (d: NodeDatum, i: number, data: NodeDatum[]) => number): this; + + /** + * Return the current radius accessor for the circle. + */ + radius(): (d: NodeDatum, i: number, data: NodeDatum[]) => number; + /** + * Set the radius accessor for the circle to the specified number, re-evaluates the radius accessor for each node, + * and returns this force. + * + * The constant is internally wrapped into a radius accessor function. + * + * The radius accessor is invoked for each node in the simulation, being passed the node, its zero-based index and the complete array of nodes. + * The resulting number is then stored internally, such that radius of the circle for each node is only recomputed when the force is initialized or + * when this method is called with a new radius, and not on every application of the force. + * + * @param radius Constant radius of the circle to be used for all nodes. + */ + radius(radius: number): this; + /** + * Set the radius accessor for the circle to the specified function, re-evaluates the radius accessor for each node, + * and returns this force. + * + * The radius accessor is invoked for each node in the simulation, being passed the node, its zero-based index and the complete array of nodes. + * The resulting number is then stored internally, such that radius of the circle for each node is only recomputed when the force is initialized or + * when this method is called with a new radius, and not on every application of the force. + * + * @param radius A radius accessor function for the circle which is invoked for each node in the simulation, being passed the node, its zero-based index and the complete array of nodes. + * The function returns the radius of the circle. + */ + radius(radius: (d: NodeDatum, i: number, data: NodeDatum[]) => number): this; + + /** + * Return the current x-accessor for the circle center, which defaults to a function returning 0 for all nodes. + */ + x(): (d: NodeDatum, i: number, data: NodeDatum[]) => number; + /** + * Set the x-coordinate accessor for the circle center to the specified number, re-evaluates the x-accessor for each node, + * and returns this force. + * + * The constant is internally wrapped into an x-coordinate accessor function. + * + * The x-accessor is invoked for each node in the simulation, being passed the node, its zero-based index and the complete array of nodes. + * The resulting number is then stored internally, such that the x-coordinate of the circle center for each node is only recomputed when the force is initialized or + * when this method is called with a new x, and not on every application of the force. + * + * @param x Constant x-coordinate of the circle center to be used for all nodes. + */ + x(x: number): this; + /** + * Set the x-coordinate accessor to the specified function, re-evaluates the x-accessor for each node, + * and returns this force. + * + * The x-accessor is invoked for each node in the simulation, being passed the node, its zero-based index and the complete array of nodes. + * The resulting number is then stored internally, such that the x-coordinate of the circle center for each node is only recomputed when the force is initialized or + * when this method is called with a new x, and not on every application of the force. + * + * @param x A x-coordinate accessor function for the circle center which is invoked for each node in the simulation, being passed the node, its zero-based index and the complete array of nodes. + * The function returns the x-coordinate of the circle center. + */ + x(x: (d: NodeDatum, i: number, data: NodeDatum[]) => number): this; + + /** + * Return the current y-accessor for the circle center, which defaults to a function returning 0 for all nodes. + */ + y(): (d: NodeDatum, i: number, data: NodeDatum[]) => number; + /** + * Set the y-coordinate accessor for the circle center to the specified number, re-evaluates the y-accessor for each node, + * and returns this force. + * + * The constant is internally wrapped into an y-coordinate accessor function. + * + * The y-accessor is invoked for each node in the simulation, being passed the node, its zero-based index and the complete array of nodes. + * The resulting number is then stored internally, such that the y-coordinate of the circle center for each node is only recomputed when the force is initialized or + * when this method is called with a new y, and not on every application of the force. + * + * @param y Constant y-coordinate of the circle center to be used for all nodes. + */ + y(y: number): this; + /** + * Set the y-coordinate accessor to the specified function, re-evaluates the y-accessor for each node, + * and returns this force. + * + * The y-accessor is invoked for each node in the simulation, being passed the node, its zero-based index and the complete array of nodes. + * The resulting number is then stored internally, such that the y-coordinate of the circle center for each node is only recomputed when the force is initialized or + * when this method is called with a new y, and not on every application of the force. + * + * @param y A y-coordinate accessor function for the circle center which is invoked for each node in the simulation, being passed the node, its zero-based index and the complete array of nodes. + * The function returns the y-coordinate of the circle center. + */ + y(y: (d: NodeDatum, i: number, data: NodeDatum[]) => number): this; +} + +/** + * Create a new radial positioning force towards a circle of the specified radius centered at ⟨x,y⟩. + * If x and y are not specified, they default to ⟨0,0⟩. + * + * The strength of the force is proportional to the one-dimensional distance between the node’s position and the target position. + * While this force can be used to position individual nodes, it is intended primarily for global forces that apply to all (or most) nodes. + * + * The generic refers to the type of data for a node. + */ +export function forceRadial<NodeDatum extends SimulationNodeDatum>(radius: number | ((d: NodeDatum, i: number, data: NodeDatum[]) => number), + x?: number | ((d: NodeDatum, i: number, data: NodeDatum[]) => number), y?: number | ((d: NodeDatum, i: number, data: NodeDatum[]) => number)): ForceRadial<NodeDatum>; diff --git a/chromium/third_party/node/node_modules/@types/d3-scale-chromatic/index.d.ts b/chromium/third_party/node/node_modules/@types/d3-scale-chromatic/index.d.ts new file mode 100644 index 00000000000..2095710d473 --- /dev/null +++ b/chromium/third_party/node/node_modules/@types/d3-scale-chromatic/index.d.ts @@ -0,0 +1,525 @@ +// Type definitions for D3JS d3-scale-chromatic module 1.5 +// Project: https://github.com/d3/d3-scale-chromatic/, https://d3js.org/d3-scale-chromatic +// Definitions by: Hugues Stefanski <https://github.com/Ledragon> +// Alex Ford <https://github.com/gustavderdrache> +// Boris Yankov <https://github.com/borisyankov> +// Henrique Machado <https://github.com/henriquefm> +// Nathan Bierema <https://github.com/Methuselah96> +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +// Last module patch version validated against: 1.5.0 + +// ----------------------------------------------------------------------- +// Categorical +// ----------------------------------------------------------------------- +/** + * An array of ten categorical colors represented as RGB hexadecimal strings. + */ +export const schemeCategory10: ReadonlyArray<string>; +/** + * An array of eight categorical colors represented as RGB hexadecimal strings. + */ +export const schemeAccent: ReadonlyArray<string>; +/** + * An array of eight categorical colors represented as RGB hexadecimal strings. + */ +export const schemeDark2: ReadonlyArray<string>; +/** + * An array of twelve categorical colors represented as RGB hexadecimal strings. + */ +export const schemePaired: ReadonlyArray<string>; +/** + * An array of nine categorical colors represented as RGB hexadecimal strings. + */ +export const schemePastel1: ReadonlyArray<string>; +/** + * An array of eight categorical colors represented as RGB hexadecimal strings. + */ +export const schemePastel2: ReadonlyArray<string>; +/** + * An array of nine categorical colors represented as RGB hexadecimal strings. + */ +export const schemeSet1: ReadonlyArray<string>; +/** + * An array of eight categorical colors represented as RGB hexadecimal strings. + */ +export const schemeSet2: ReadonlyArray<string>; +/** + * An array of twelve categorical colors represented as RGB hexadecimal strings. + */ +export const schemeSet3: ReadonlyArray<string>; +/** + * An array of ten categorical colors authored by Tableau as part of Tableau 10 represented as RGB hexadecimal strings. + */ +export const schemeTableau10: ReadonlyArray<string>; + +// ----------------------------------------------------------------------- +// Diverging +// ----------------------------------------------------------------------- +/** + * Given a number t in the range [0,1], returns the corresponding color from the “BrBG” diverging color scheme represented as an RGB string. + * + * @param t Number in the range [0, 1]. + */ +export function interpolateBrBG(t: number): string; + +/** + * An array of arrays of hexadecimal color strings from the “BrBG” diverging color scheme. The kth element of this array contains + * the color scheme of size k; for example, d3.schemeBrBG[9] contains an array of nine strings representing the nine colors of the + * brown-blue-green diverging color scheme. Diverging color schemes support a size k ranging from 3 to 11. + */ +export const schemeBrBG: ReadonlyArray<ReadonlyArray<string>>; + +/** + * Given a number t in the range [0,1], returns the corresponding color from the “PRGn” diverging color scheme represented as an RGB string. + * + * @param t Number in the range [0, 1]. + */ +export function interpolatePRGn(t: number): string; + +/** + * An array of arrays of hexadecimal color strings from the “PRGn” diverging color scheme. The kth element of this array contains + * the color scheme of size k; for example, d3.schemePRGn[9] contains an array of nine strings representing the nine colors of the + * purple-green diverging color scheme. Diverging color schemes support a size k ranging from 3 to 11. + */ +export const schemePRGn: ReadonlyArray<ReadonlyArray<string>>; + +/** + * Given a number t in the range [0,1], returns the corresponding color from the “PiYG” diverging color scheme represented as an RGB string. + * + * @param t Number in the range [0, 1]. + */ +export function interpolatePiYG(t: number): string; + +/** + * An array of arrays of hexadecimal color strings from the “PiYG” diverging color scheme. The kth element of this array contains + * the color scheme of size k; for example, d3.schemePiYG[9] contains an array of nine strings representing the nine colors of the + * pink-yellow-green diverging color scheme. Diverging color schemes support a size k ranging from 3 to 11. + */ +export const schemePiYG: ReadonlyArray<ReadonlyArray<string>>; + +/** + * Given a number t in the range [0,1], returns the corresponding color from the “PuOr” diverging color scheme represented as an RGB string. + * + * @param t Number in the range [0, 1]. + */ +export function interpolatePuOr(t: number): string; + +/** + * An array of arrays of hexadecimal color strings from the “PuOr” diverging color scheme. The kth element of this array contains + * the color scheme of size k; for example, d3.schemePuOr[9] contains an array of nine strings representing the nine colors of the + * purple-orange diverging color scheme. Diverging color schemes support a size k ranging from 3 to 11. + */ +export const schemePuOr: ReadonlyArray<ReadonlyArray<string>>; + +/** + * Given a number t in the range [0,1], returns the corresponding color from the “RdBu” diverging color scheme represented as an RGB string. + * + * @param t Number in the range [0, 1]. + */ +export function interpolateRdBu(t: number): string; + +/** + * An array of arrays of hexadecimal color strings from the “RdBu” diverging color scheme. The kth element of this array contains + * the color scheme of size k; for example, d3.schemeRdBu[9] contains an array of nine strings representing the nine colors of the + * red-blue diverging color scheme. Diverging color schemes support a size k ranging from 3 to 11. + */ +export const schemeRdBu: ReadonlyArray<ReadonlyArray<string>>; + +/** + * Given a number t in the range [0,1], returns the corresponding color from the “RdGy” diverging color scheme represented as an RGB string. + * + * @param t Number in the range [0, 1]. + */ +export function interpolateRdGy(t: number): string; + +/** + * An array of arrays of hexadecimal color strings from the “RdGy” diverging color scheme. The kth element of this array contains + * the color scheme of size k; for example, d3.schemeRdGy[9] contains an array of nine strings representing the nine colors of the + * red-grey diverging color scheme. Diverging color schemes support a size k ranging from 3 to 11. + */ +export const schemeRdGy: ReadonlyArray<ReadonlyArray<string>>; + +/** + * Given a number t in the range [0,1], returns the corresponding color from the “RdYlBu” diverging color scheme represented as an RGB string. + * + * @param t Number in the range [0, 1]. + */ +export function interpolateRdYlBu(t: number): string; + +/** + * An array of arrays of hexadecimal color strings from the “RdYlBu” diverging color scheme. The kth element of this array contains + * the color scheme of size k; for example, d3.schemeRdYlBu[9] contains an array of nine strings representing the nine colors of the + * red-yellow-blue diverging color scheme. Diverging color schemes support a size k ranging from 3 to 11. + */ +export const schemeRdYlBu: ReadonlyArray<ReadonlyArray<string>>; + +/** + * Given a number t in the range [0,1], returns the corresponding color from the “RdYlGn” diverging color scheme represented as an RGB string. + * + * @param t Number in the range [0, 1]. + */ +export function interpolateRdYlGn(t: number): string; + +/** + * An array of arrays of hexadecimal color strings from the “RdYlGn” diverging color scheme. The kth element of this array contains + * the color scheme of size k; for example, d3.schemeRdYlGn[9] contains an array of nine strings representing the nine colors of the + * red-yellow-green diverging color scheme. Diverging color schemes support a size k ranging from 3 to 11. + */ +export const schemeRdYlGn: ReadonlyArray<ReadonlyArray<string>>; + +/** + * Given a number t in the range [0,1], returns the corresponding color from the “Spectral” diverging color scheme represented as an RGB string. + * + * @param t Number in the range [0, 1]. + */ +export function interpolateSpectral(t: number): string; + +/** + * An array of arrays of hexadecimal color strings from the “Spectral” diverging color scheme. The kth element of this array contains + * the color scheme of size k; for example, d3.schemeSpectral[9] contains an array of nine strings representing the nine colors of the + * spectral diverging color scheme. Diverging color schemes support a size k ranging from 3 to 11. + */ +export const schemeSpectral: ReadonlyArray<ReadonlyArray<string>>; + +// ----------------------------------------------------------------------- +// Sequential +// ----------------------------------------------------------------------- +/** + * Given a number t in the range [0,1], returns the corresponding color from the “Blues” sequential color scheme represented as an RGB string. + * + * @param t Number in the range [0, 1]. + */ +export function interpolateBlues(t: number): string; + +/** + * An array of arrays of hexadecimal color strings from the “Blues” sequential color scheme. The kth element of this array contains + * the color scheme of size k; for example, d3.schemeBlues[9] contains an array of nine strings representing the nine colors of the + * blue sequential color scheme. Sequential, single-hue color schemes support a size k ranging from 3 to 9. + */ +export const schemeBlues: ReadonlyArray<ReadonlyArray<string>>; + +/** + * Given a number t in the range [0,1], returns the corresponding color from the “Greens” sequential color scheme represented as an RGB string. + * + * @param t Number in the range [0, 1]. + */ +export function interpolateGreens(t: number): string; + +/** + * An array of arrays of hexadecimal color strings from the “Greens” sequential color scheme. The kth element of this array contains + * the color scheme of size k; for example, d3.schemeGreens[9] contains an array of nine strings representing the nine colors of the + * green sequential color scheme. Sequential, single-hue color schemes support a size k ranging from 3 to 9. + */ +export const schemeGreens: ReadonlyArray<ReadonlyArray<string>>; + +/** + * Given a number t in the range [0,1], returns the corresponding color from the “Greys” sequential color scheme represented as an RGB string. + * + * @param t Number in the range [0, 1]. + */ +export function interpolateGreys(t: number): string; + +/** + * An array of arrays of hexadecimal color strings from the “Greys” sequential color scheme. The kth element of this array contains + * the color scheme of size k; for example, d3.schemeGreys[9] contains an array of nine strings representing the nine colors of the + * grey sequential color scheme. Sequential, single-hue color schemes support a size k ranging from 3 to 9. + */ +export const schemeGreys: ReadonlyArray<ReadonlyArray<string>>; + +/** + * Given a number t in the range [0,1], returns the corresponding color from the “Oranges” sequential color scheme represented as an RGB string. + * + * @param t Number in the range [0, 1]. + */ +export function interpolateOranges(t: number): string; + +/** + * An array of arrays of hexadecimal color strings from the “Oranges” sequential color scheme. The kth element of this array contains + * the color scheme of size k; for example, d3.schemeOranges[9] contains an array of nine strings representing the nine colors of the + * orange sequential color scheme. Sequential, single-hue color schemes support a size k ranging from 3 to 9. + */ +export const schemeOranges: ReadonlyArray<ReadonlyArray<string>>; + +/** + * Given a number t in the range [0,1], returns the corresponding color from the “Purples” sequential color scheme represented as an RGB string. + * + * @param t Number in the range [0, 1]. + */ +export function interpolatePurples(t: number): string; + +/** + * An array of arrays of hexadecimal color strings from the “Purples” sequential color scheme. The kth element of this array contains + * the color scheme of size k; for example, d3.schemePurples[9] contains an array of nine strings representing the nine colors of the + * purple sequential color scheme. Sequential, single-hue color schemes support a size k ranging from 3 to 9. + */ +export const schemePurples: ReadonlyArray<ReadonlyArray<string>>; + +/** + * Given a number t in the range [0,1], returns the corresponding color from the “Reds” sequential color scheme represented as an RGB string. + * + * @param t Number in the range [0, 1]. + */ +export function interpolateReds(t: number): string; + +/** + * An array of arrays of hexadecimal color strings from the “Reds” sequential color scheme. The kth element of this array contains + * the color scheme of size k; for example, d3.schemeReds[9] contains an array of nine strings representing the nine colors of the + * red sequential color scheme. Sequential, single-hue color schemes support a size k ranging from 3 to 9. + */ +export const schemeReds: ReadonlyArray<ReadonlyArray<string>>; + +// ----------------------------------------------------------------------- +// Sequential(Multi-Hue) +// ----------------------------------------------------------------------- + +/** + * Given a number t in the range [0,1], returns the corresponding color from the “turbo” color scheme by Anton Mikhailov. + * + * @param t A number in the interval [0, 1]. + */ +export function interpolateTurbo(t: number): string; + +/** + * Given a number t in the range [0,1], returns the corresponding color from the “viridis” perceptually-uniform color scheme designed by van der Walt, Smith and Firing for matplotlib, + * represented as an RGB string. + * + * @param t A number in the interval [0, 1]. + */ +export function interpolateViridis(t: number): string; + +/** + * Given a number t in the range [0,1], returns the corresponding color from the “inferno” perceptually-uniform color scheme designed by van der Walt and Smith for matplotlib, + * represented as an RGB string. + * + * @param t A number in the interval [0, 1]. + */ +export function interpolateInferno(t: number): string; + +/** + * Given a number t in the range [0,1], returns the corresponding color from the “magma” perceptually-uniform color scheme designed by van der Walt and Smith for matplotlib, + * represented as an RGB string. + * + * @param t A number in the interval [0, 1]. + */ +export function interpolateMagma(t: number): string; + +/** + * Given a number t in the range [0,1], returns the corresponding color from the “plasma” perceptually-uniform color scheme designed by van der Walt and Smith for matplotlib, + * represented as an RGB string. + * + * @param t A number in the interval [0, 1]. + */ +export function interpolatePlasma(t: number): string; + +/** + * Given a number t in the range [0,1], returns the corresponding color from the “plasma” perceptually-uniform color scheme designed by van der Walt and Smith for matplotlib, + * represented as an RGB string. + * + * @param t A number in the interval [0, 1]. + */ +export function interpolateCividis(t: number): string; + +/** + * Given a number t in the range [0,1], returns the corresponding color from a 180° rotation of Niccoli’s perceptual rainbow, represented as an RGB string. + * + * @param t A number in the interval [0, 1]. + */ +export function interpolateWarm(t: number): string; + +/** + * Given a number t in the range [0,1], returns the corresponding color from Niccoli’s perceptual rainbow, represented as an RGB string. + * + * @param t A number in the interval [0, 1]. + */ +export function interpolateCool(t: number): string; + +/** + * Given a number t in the range [0,1], returns the corresponding color from d3.interpolateWarm scale from [0.0, 0.5] followed by the d3.interpolateCool scale from [0.5, 1.0], + * thus implementing the cyclical less-angry rainbow color scheme. + * + * @param t A number in the interval [0, 1]. + */ +export function interpolateRainbow(t: number): string; + +/** + * Given a number t in the range [0,1], returns the corresponding color from the “sinebow” color scheme by Jim Bumgardner and Charlie Loyd. + * + * @param t A number in the interval [0, 1]. + */ +export function interpolateSinebow(t: number): string; + +/** + * Given a number t in the range [0,1], returns the corresponding color from Green’s default Cubehelix represented as an RGB string. + * + * @param t A number in the interval [0, 1]. + */ +export function interpolateCubehelixDefault(t: number): string; + +/** + * Given a number t in the range [0,1], returns the corresponding color from the “BuGn” sequential color scheme represented as an RGB string. + * + * @param t Number in the range [0, 1]. + */ +export function interpolateBuGn(t: number): string; + +/** + * An array of arrays of hexadecimal color strings from the “BuGn” sequential color scheme. The kth element of this array contains + * the color scheme of size k; for example, d3.schemeBuGn[9] contains an array of nine strings representing the nine colors of the + * blue-green sequential color scheme. Sequential, multi-hue color schemes support a size k ranging from 3 to 9. + */ +export const schemeBuGn: ReadonlyArray<ReadonlyArray<string>>; + +/** + * Given a number t in the range [0,1], returns the corresponding color from the “BuPu” sequential color scheme represented as an RGB string. + * + * @param t Number in the range [0, 1]. + */ +export function interpolateBuPu(t: number): string; + +/** + * An array of arrays of hexadecimal color strings from the “BuPu” sequential color scheme. The kth element of this array contains + * the color scheme of size k; for example, d3.schemeBuPu[9] contains an array of nine strings representing the nine colors of the + * blue-purple sequential color scheme. Sequential, multi-hue color schemes support a size k ranging from 3 to 9. + */ +export const schemeBuPu: ReadonlyArray<ReadonlyArray<string>>; + +/** + * Given a number t in the range [0,1], returns the corresponding color from the “GnBu” sequential color scheme represented as an RGB string. + * + * @param t Number in the range [0, 1]. + */ +export function interpolateGnBu(t: number): string; + +/** + * An array of arrays of hexadecimal color strings from the “GnBu” sequential color scheme. The kth element of this array contains + * the color scheme of size k; for example, d3.schemeGnBu[9] contains an array of nine strings representing the nine colors of the + * green-blue sequential color scheme. Sequential, multi-hue color schemes support a size k ranging from 3 to 9. + */ +export const schemeGnBu: ReadonlyArray<ReadonlyArray<string>>; + +/** + * Given a number t in the range [0,1], returns the corresponding color from the “OrRd” sequential color scheme represented as an RGB string. + * + * @param t Number in the range [0, 1]. + */ +export function interpolateOrRd(t: number): string; + +/** + * An array of arrays of hexadecimal color strings from the “OrRd” sequential color scheme. The kth element of this array contains + * the color scheme of size k; for example, d3.schemeOrRd[9] contains an array of nine strings representing the nine colors of the + * orange-red sequential color scheme. Sequential, multi-hue color schemes support a size k ranging from 3 to 9. + */ +export const schemeOrRd: ReadonlyArray<ReadonlyArray<string>>; + +/** + * Given a number t in the range [0,1], returns the corresponding color from the “PuBuGn” sequential color scheme represented as an RGB string. + * + * @param t Number in the range [0, 1]. + */ +export function interpolatePuBuGn(t: number): string; + +/** + * An array of arrays of hexadecimal color strings from the “PuBuGn” sequential color scheme. The kth element of this array contains + * the color scheme of size k; for example, d3.schemePuBuGn[9] contains an array of nine strings representing the nine colors of the + * purple-blue-green sequential color scheme. Sequential, multi-hue color schemes support a size k ranging from 3 to 9. + */ +export const schemePuBuGn: ReadonlyArray<ReadonlyArray<string>>; + +/** + * Given a number t in the range [0,1], returns the corresponding color from the “PuBu” sequential color scheme represented as an RGB string. + * + * @param t Number in the range [0, 1]. + */ +export function interpolatePuBu(t: number): string; + +/** + * An array of arrays of hexadecimal color strings from the “PuBu” sequential color scheme. The kth element of this array contains + * the color scheme of size k; for example, d3.schemePuBu[9] contains an array of nine strings representing the nine colors of the + * purple-blue sequential color scheme. Sequential, multi-hue color schemes support a size k ranging from 3 to 9. + */ +export const schemePuBu: ReadonlyArray<ReadonlyArray<string>>; + +/** + * Given a number t in the range [0,1], returns the corresponding color from the “PuRd” sequential color scheme represented as an RGB string. + * + * @param t Number in the range [0, 1]. + */ +export function interpolatePuRd(t: number): string; + +/** + * An array of arrays of hexadecimal color strings from the “PuRd” sequential color scheme. The kth element of this array contains + * the color scheme of size k; for example, d3.schemePuRd[9] contains an array of nine strings representing the nine colors of the + * purple-red sequential color scheme. Sequential, multi-hue color schemes support a size k ranging from 3 to 9. + */ +export const schemePuRd: ReadonlyArray<ReadonlyArray<string>>; + +/** + * Given a number t in the range [0,1], returns the corresponding color from the “RdPu” sequential color scheme represented as an RGB string. + * + * @param t Number in the range [0, 1]. + */ +export function interpolateRdPu(t: number): string; + +/** + * An array of arrays of hexadecimal color strings from the “RdPu” sequential color scheme. The kth element of this array contains + * the color scheme of size k; for example, d3.schemeRdPu[9] contains an array of nine strings representing the nine colors of the + * red-purple sequential color scheme. Sequential, multi-hue color schemes support a size k ranging from 3 to 9. + */ +export const schemeRdPu: ReadonlyArray<ReadonlyArray<string>>; + +/** + * Given a number t in the range [0,1], returns the corresponding color from the “YlGnBu” sequential color scheme represented as an RGB string. + * + * @param t Number in the range [0, 1]. + */ +export function interpolateYlGnBu(t: number): string; + +/** + * An array of arrays of hexadecimal color strings from the “YlGnBu” sequential color scheme. The kth element of this array contains + * the color scheme of size k; for example, d3.schemeYlGnBu[9] contains an array of nine strings representing the nine colors of the + * yellow-green-blue sequential color scheme. Sequential, multi-hue color schemes support a size k ranging from 3 to 9. + */ +export const schemeYlGnBu: ReadonlyArray<ReadonlyArray<string>>; + +/** + * Given a number t in the range [0,1], returns the corresponding color from the “YlGn” sequential color scheme represented as an RGB string. + * + * @param t Number in the range [0, 1]. + */ +export function interpolateYlGn(t: number): string; + +/** + * An array of arrays of hexadecimal color strings from the “YlGn” sequential color scheme. The kth element of this array contains + * the color scheme of size k; for example, d3.schemeYlGn[9] contains an array of nine strings representing the nine colors of the + * yellow-green sequential color scheme. Sequential, multi-hue color schemes support a size k ranging from 3 to 9. + */ +export const schemeYlGn: ReadonlyArray<ReadonlyArray<string>>; + +/** + * Given a number t in the range [0,1], returns the corresponding color from the “YlOrBr” sequential color scheme represented as an RGB string. + * + * @param t Number in the range [0, 1]. + */ +export function interpolateYlOrBr(t: number): string; + +/** + * An array of arrays of hexadecimal color strings from the “YlOrBr” sequential color scheme. The kth element of this array contains + * the color scheme of size k; for example, d3.schemeYlOrBr[9] contains an array of nine strings representing the nine colors of the + * yellow-orange-brown sequential color scheme. Sequential, multi-hue color schemes support a size k ranging from 3 to 9. + */ +export const schemeYlOrBr: ReadonlyArray<ReadonlyArray<string>>; + +/** + * Given a number t in the range [0,1], returns the corresponding color from the “YlOrRd” sequential color scheme represented as an RGB string. + * + * @param t Number in the range [0, 1]. + */ +export function interpolateYlOrRd(t: number): string; + +/** + * An array of arrays of hexadecimal color strings from the “YlOrRd” sequential color scheme. The kth element of this array contains + * the color scheme of size k; for example, d3.schemeYlOrRd[9] contains an array of nine strings representing the nine colors of the + * yellow-orange-red sequential color scheme. Sequential, multi-hue color schemes support a size k ranging from 3 to 9. + */ +export const schemeYlOrRd: ReadonlyArray<ReadonlyArray<string>>; diff --git a/chromium/third_party/node/node_modules/@types/d3-selection/index.d.ts b/chromium/third_party/node/node_modules/@types/d3-selection/index.d.ts new file mode 100644 index 00000000000..e72ce071eb8 --- /dev/null +++ b/chromium/third_party/node/node_modules/@types/d3-selection/index.d.ts @@ -0,0 +1,1256 @@ +// Type definitions for D3JS d3-selection module 1.4 +// Project: https://github.com/d3/d3-selection/, https://d3js.org/d3-selection +// 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> +// Nathan Bierema <https://github.com/Methuselah96> +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +// Last module patch version validated against: 1.4.1 + +// -------------------------------------------------------------------------- +// Shared Type Definitions and Interfaces +// -------------------------------------------------------------------------- + +/** + * BaseType serves as an alias for the 'minimal' data type which can be selected + * without 'd3-selection' trying to use properties internally which would otherwise not + * be supported. + */ +export type BaseType = Element | EnterElement | Document | Window | null; + +/** + * KeyType serves as alias for valid types that d3 supports as key for data binding + */ +export type KeyType = string | number; + +/** + * A helper interface which covers arguments like NodeListOf<T> or HTMLCollectionOf<T> + * argument types + */ +export interface ArrayLike<T> { + length: number; + item(index: number): T | null; + [index: number]: T; +} + +/** + * An interface describing the element type of the Enter Selection group elements + * created when invoking selection.enter(). + */ +export interface EnterElement { + ownerDocument: Document; + namespaceURI: string; + appendChild(newChild: Node): Node; + insertBefore(newChild: Node, refChild: Node): Node; + querySelector(selectors: string): Element; + querySelectorAll(selectors: string): NodeListOf<Element>; +} + +/** + * Container element type usable for mouse/touch functions + */ +export type ContainerElement = HTMLElement | SVGSVGElement | SVGGElement; + +/** + * A User interface event (e.g. mouse event, touch or MSGestureEvent) with captured clientX and clientY properties. + */ +export interface ClientPointEvent { + clientX: number; + clientY: number; +} + +/** + * Interface for optional parameters map, when dispatching custom events + * on a selection + */ +export interface CustomEventParameters { + /** + * If true, the event is dispatched to ancestors in reverse tree order + */ + bubbles: boolean; + /** + * If true, event.preventDefault is allowed + */ + cancelable: boolean; + /** + * Any custom data associated with the event + */ + detail: any; +} + +/** + * Callback type for selections and transitions + */ +export type ValueFn<T extends BaseType, Datum, Result> = (this: T, datum: Datum, index: number, groups: T[] | ArrayLike<T>) => Result; + +/** + * TransitionLike is a helper interface to represent a quasi-Transition, without specifying the full Transition interface in this file. + * For example, wherever d3-zoom allows a Transition to be passed in as an argument, it internally immediately invokes its `selection()` + * method to retrieve the underlying Selection object before proceeding. + * d3-brush uses a subset of Transition methods internally. + * The use of this interface instead of the full imported Transition interface is [referred] to achieve + * two things: + * (1) the d3-transition module may not be required by a projects use case, + * (2) it avoids possible complications from 'module augmentation' from d3-transition to Selection. + */ +export interface TransitionLike<GElement extends BaseType, Datum> { + selection(): Selection<GElement, Datum, any, any>; + on(type: string, listener: null): TransitionLike<GElement, Datum>; + on(type: string, listener: ValueFn<GElement, Datum, void>): TransitionLike<GElement, Datum>; + tween(name: string, tweenFn: null): TransitionLike<GElement, Datum>; + tween(name: string, tweenFn: ValueFn<GElement, Datum, ((t: number) => void)>): TransitionLike<GElement, Datum>; +} + +// -------------------------------------------------------------------------- +// All Selection related interfaces and function +// -------------------------------------------------------------------------- + +/** + * Select the first element that matches the specified selector string. If no elements match the selector, returns an empty selection. + * If multiple elements match the selector, only the first matching element (in document order) will be selected. + * + * The first generic "GElement" refers to the type of element to be selected. The second generic "OldDatum" refers to the type of the + * datum, on the selected element. This is useful when re-selecting an element with a previously set, know datum type. + * + * @param selector CSS selector string + */ +export function select<GElement extends BaseType, OldDatum>(selector: string): Selection<GElement, OldDatum, HTMLElement, any>; +/** + * Select the specified node element. + * + * The first generic "GElement" refers to the type of element to be selected. The second generic "OldDatum" refers to the type of the + * datum, on the selected element. This is useful when re-selecting an element with a previously set, know datum type. + * + * @param node An element to be selected + */ +export function select<GElement extends BaseType, OldDatum>(node: GElement): Selection<GElement, OldDatum, null, undefined>; + +/** + * Create an empty selection. + */ +export function selectAll(): Selection<null, undefined, null, undefined>; +/** + * Create an empty selection. + */ +export function selectAll(selector: null): Selection<null, undefined, null, undefined>; +/** + * Create an empty selection. + */ +export function selectAll(selector: undefined): Selection<null, undefined, null, undefined>; +/** + * Select all elements that match the specified selector string. The elements will be selected in document order (top-to-bottom). + * If no elements in the document match the selector, returns an empty selection. + * + * The first generic "GElement" refers to the type of element to be selected. The second generic "OldDatum" refers to the type of the + * datum, of a selected element. This is useful when re-selecting elements with a previously set, know datum type. + * + * @param selector CSS selector string + */ +export function selectAll<GElement extends BaseType, OldDatum>(selector: string): Selection<GElement, OldDatum, HTMLElement, any>; +/** + * Select the specified array of nodes. + * + * The first generic "GElement" refers to the type of element to be selected. The second generic "OldDatum" refers to the type of the + * datum, of a selected element. This is useful when re-selecting elements with a previously set, know datum type. + * + * @param nodes An Array of nodes + */ +export function selectAll<GElement extends BaseType, OldDatum>(nodes: GElement[]): Selection<GElement, OldDatum, null, undefined>; +/** + * Select the specified nodes. This signature allows the selection of nodes contained in a NodeList, HTMLCollection or similar data structure. + * + * The first generic "GElement" refers to the type of element to be selected. The second generic "OldDatum" refers to the type of the + * datum, of a selected element. This is useful when re-selecting elements with a previously set, know datum type. + * + * @param nodes An Array-like collection of nodes + */ +export function selectAll<GElement extends BaseType, OldDatum>(nodes: ArrayLike<GElement>): Selection<GElement, OldDatum, null, undefined>; + +/** + * A D3 Selection of elements. + * + * The first generic "GElement" refers to the type of the selected element(s). + * The second generic "Datum" refers to the type of the datum of a selected element(s). + * The third generic "PElement" refers to the type of the parent element(s) in the D3 selection. + * The fourth generic "PDatum" refers to the type of the datum of the parent element(s). + */ +export interface Selection<GElement extends BaseType, Datum, PElement extends BaseType, PDatum> { + // Sub-selection ------------------------- + + /** + * For each selected element, select the first descendant element that matches the specified selector string. + * If no element matches the specified selector for the current element, the element at the current index will + * be null in the returned selection. If multiple elements match the selector, only the first matching element + * in document order is selected. Selection.select does not affect grouping: it preserves the existing group + * structure and indexes, and propagates data (if any) to selected children. + * + * If the current element has associated data, this data is propagated to the + * corresponding selected element. + * + * The generic represents the type of the descendant element to be selected. + * + * @param selector CSS selector string + */ + select<DescElement extends BaseType>(selector: string): Selection<DescElement, Datum, PElement, PDatum>; + /** + * Create an empty sub-selection. Selection.select does not affect grouping: it preserves the existing group + * structure and indexes. + */ + select<DescElement extends BaseType>(selector: null): Selection<null, undefined, PElement, PDatum>; + /** + * For each selected element, select the descendant element returned by the selector function. + * If no element is returned by the selector function for the current element, the element at the + * current index will be null in the returned selection. Selection.select does not affect grouping: + * it preserves the existing group structure and indexes, and propagates data (if any) to selected children. + * + * If the current element has associated data, this data is propagated to the + * corresponding selected element. + * + * The generic represents the type of the descendant element to be selected. + * + * @param selector A selector function, which is evaluated for each selected element, in order, being passed the current datum (d), + * the current index (i), and the current group (nodes), with this as the current DOM element (nodes[i]). + * It must return an element, or null if there is no matching element. + */ + select<DescElement extends BaseType>(selector: ValueFn<GElement, Datum, DescElement>): Selection<DescElement, Datum, PElement, PDatum>; + + /** + * Create an empty sub-selection. Selection.selectAll does affect grouping: The elements in the returned + * selection are grouped by their corresponding parent node in this selection, the group at the current index will be empty. + */ + selectAll(): Selection<null, undefined, GElement, Datum>; + /** + * Create an empty sub-selection. Selection.selectAll does affect grouping: The elements in the returned + * selection are grouped by their corresponding parent node in this selection, the group at the current index will be empty. + */ + selectAll(selector: null): Selection<null, undefined, GElement, Datum>; + /** + * Create an empty sub-selection. Selection.selectAll does affect grouping: The elements in the returned + * selection are grouped by their corresponding parent node in this selection, the group at the current index will be empty. + */ + selectAll(selector: undefined): Selection<null, undefined, GElement, Datum>; + /** + * For each selected element, selects the descendant elements that match the specified selector string. The elements in the returned + * selection are grouped by their corresponding parent node in this selection. If no element matches the specified selector + * for the current element, the group at the current index will be empty. Selection.selectAll does affect grouping: each selected descendant + * is grouped by the parent element in the originating selection. + * + * The selected elements do not inherit data from this selection; use selection.data to propagate data to children. + * + * The first generic "DescElement" refers to the type of descendant element to be selected. The second generic "OldDatum" refers to the type of the + * datum, of a selected element. This is useful when re-selecting elements with a previously set, know datum type. + * + * @param selector CSS selector string + */ + selectAll<DescElement extends BaseType, OldDatum>(selector: string): Selection<DescElement, OldDatum, GElement, Datum>; + + /** + * For each selected element, selects the descendant elements returned by the selector function. The elements in the returned + * selection are grouped by their corresponding parent node in this selection. If no element matches the specified selector + * for the current element, the group at the current index will be empty. Selection.selectAll does affect grouping: each selected descendant + * is grouped by the parent element in the originating selection. + * + * The selected elements do not inherit data from this selection; use selection.data to propagate data to children. + * + * The first generic "DescElement" refers to the type of descendant element to be selected. The second generic "OldDatum" refers to the type of the + * datum, of a selected element. This is useful when re-selecting elements with a previously set, know datum type. + * + * @param selector A selector function which is evaluated for each selected element, in order, being passed the current datum (d), + * the current index (i), and the current group (nodes), with this as the current DOM element (nodes[i]). It must return an array of elements + * (or a pseudo-array, such as a NodeList), or the empty array if there are no matching elements. + */ + selectAll<DescElement extends BaseType, OldDatum>(selector: ValueFn<GElement, Datum, DescElement[] | ArrayLike<DescElement>>): Selection<DescElement, OldDatum, GElement, Datum>; + + // Modifying ------------------------------- + + /** + * Return the current value of the specified attribute for the first (non-null) element in the selection. + * This is generally useful only if you know that the selection contains exactly one element. + * + * @param name Name of the attribute + */ + attr(name: string): string; + /** + * Clear the attribute with the specified name for the selected elements and returns this selection. + * + * @param name Name of the attribute + * @param value null,to clear the attribute + */ + attr(name: string, value: null): this; + /** + * Sets the value of the attribute with the specified name for the selected elements and returns this selection. + * All elements are given the same attribute value. + * + * @param name Name of the attribute + * @param value Constant value for the attribute + */ + attr(name: string, value: string | number | boolean): this; + /** + * Sets the value of the attribute with the specified name for the selected elements and returns this selection. + * The value for the individual selected elements is determined by the value function. + * + * @param name Name of the attribute + * @param value A value function which is evaluated for each selected element, in order, being passed the current datum (d), + * the current index (i), and the current group (nodes), with this as the current DOM element (nodes[i]). A null value will clear the attribute. + */ + attr(name: string, value: ValueFn<GElement, Datum, string | number | boolean | null>): this; + + /** + * Returns true if and only if the first (non-null) selected element has the specified classes. + * This is generally useful only if you know the selection contains exactly one element. + * + * @param name A string of space-separated class names. + */ + classed(names: string): boolean; + /** + * Assigns or unassigns the specified CSS class names on the selected elements by setting + * the class attribute or modifying the classList property and returns this selection. + * If the constant value is truthy, then all elements are assigned the specified classes; otherwise, the classes are unassigned. + * + * @param names A string of space-separated class names. + * @param value A boolean flag (true = assign / false = unassign) + */ + classed(names: string, value: boolean): this; + /** + * Assigns or unassigns the specified CSS class names on the selected elements by setting + * the class attribute or modifying the classList property and returns this selection. + * The assign/unassign status for the individual selected elements is determined by the boolean return + * value of the value function. + * + * @param names A string of space-separated class names. + * @param value A value function which is evaluated for each selected element, in order, + * being passed the current datum (d), the current index (i), and the current group (nodes), with this as the current DOM element (nodes[i]). + * The function’s return value is then used to assign or unassign classes on each element. + */ + classed(names: string, value: ValueFn<GElement, Datum, boolean>): this; + + /** + * Returns the current value of the specified style property for the first (non-null) element in the selection. + * The current value is defined as the element’s inline value, if present, and otherwise its computed value. + * Accessing the current style value is generally useful only if you know the selection contains exactly one element. + * + * @param name Name of the style + */ + style(name: string): string; + /** + * Clear the style with the specified name for the selected elements and returns this selection. + * + * @param name Name of the style + * @param value null,to clear the style + */ + style(name: string, value: null): this; + /** + * Sets the value of the style with the specified name for the selected elements and returns this selection. + * All elements are given the same style value. + * + * @param name Name of the style + * @param value Constant value for the style + * @param priority An optional priority flag, either null or the string important (without the exclamation point) + */ + style(name: string, value: string | number | boolean, priority?: null | 'important'): this; + /** + * Sets the value of the style with the specified name for the selected elements and returns this selection. + * The value for the individual selected elements is determined by the value function. + * + * @param name Name of the style + * @param value A value function which is evaluated for each selected element, in order, being passed the current datum (d), + * the current index (i), and the current group (nodes), with this as the current DOM element (nodes[i]). A null value will clear the style. + * @param priority An optional priority flag, either null or the string important (without the exclamation point) + */ + style(name: string, value: ValueFn<GElement, Datum, string | number | boolean | null>, priority?: null | 'important'): this; + + /** + * Return the current value of the specified property for the first (non-null) element in the selection. + * This is generally useful only if you know that the selection contains exactly one element. + * + * @param name Name of the property + */ + property(name: string): any; + /** + * Look up a local variable on the first node of this selection. Note that this is not equivalent to `local.get(selection.node())` in that it will not look up locals set on the parent node(s). + * + * @param name The `d3.local` variable to look up. + */ + property<T>(name: Local<T>): T | undefined; + /** + * Sets the value of the property with the specified name for the selected elements and returns this selection. + * The value for the individual selected elements is determined by the value function. + * + * Some HTML elements have special properties that are not addressable using attributes or styles, + * such as a form field’s text value and a checkbox’s checked boolean. Use this method to get or set these properties. + * + * @param name Name of the property + * @param value A value function which is evaluated for each selected element, in order, being passed the current datum (d), + * the current index (i), and the current group (nodes), with this as the current DOM element (nodes[i]). A null value will clear the property. + */ + property(name: string, value: ValueFn<GElement, Datum, any>): this; + /** + * Clears the property with the specified name for the selected elements and returns this selection. + * + * @param name Name of the property + * @param value null,to clear the property + */ + property(name: string, value: null): this; + /** + * Sets the value of the property with the specified name for the selected elements and returns this selection. + * All elements are given the same property value. + * + * @param name Name of the property + * @param value Constant value for the property + */ + property(name: string, value: any): this; + /** + * Store a value in a `d3.local` variable. + * This is equivalent to `selection.each(function (d, i, g) { name.set(this, value.call(this, d, i, g)); })` but more concise. + * + * @param name A `d3.local` variable + * @param value A callback that returns the value to store + */ + property<T>(name: Local<T>, value: ValueFn<GElement, Datum, T>): this; + /** + * Store a value in a `d3.local` variable for each node in the selection. + * This is equivalent to `selection.each(function () { name.set(this, value); })` but more concise. + * + * @param name A `d3.local` variable + * @param value A callback that returns the value to store + */ + property<T>(name: Local<T>, value: T): this; + + /** + * Returns the text content for the first (non-null) element in the selection. + * This is generally useful only if you know the selection contains exactly one element. + */ + text(): string; + /** + * Clear the text content of the selected elements and return the selection. + */ + text(value: null): this; + /** + * Sets the text content to the specified value on all selected elements, replacing any existing child elements. + * All elements are given the same text content. + * + * @param value Text content value for the elements. + */ + text(value: string | number | boolean): this; + /** + * Sets the text content to the specified value on all selected elements, replacing any existing child elements. + * All elements are given the same text content. + * + * @param value A value unction which is evaluated for each selected element, in order, being passed the current datum (d), + * the current index (i), and the current group (nodes), with this as the current DOM element (nodes[i]). + * The function’s return value is then used to set each element’s text content. A null value will clear the content. + */ + text(value: ValueFn<GElement, Datum, string | number | boolean | null>): this; + + /** + * Returns a string representation of the inner HTML for the first (non-null) element in the selection. + * This is generally useful only if you know the selection contains exactly one element. + */ + html(): string; + /** + * Clear the html content of the selected elements and return the selection. + */ + html(value: null): this; + /** + * Sets the inner HTML to the specified value on all selected elements, replacing any existing child elements. + * All elements are given the same inner HTML + * + * @param value String representation of inner HTML. + */ + html(value: string): this; + /** + * Sets the inner HTML to the specified value on all selected elements, replacing any existing child elements. + * The inner HTML is determined for each individual element using a value function. + * + * @param value A value function which is evaluated for each selected element, in order, being passed the current + * datum (d), the current index (i), and the current group (nodes), with this as the current DOM element (nodes[i]). + * The function’s return value is then used to set each element’s inner HTML. A null value will clear the content. + */ + html(value: ValueFn<GElement, Datum, string | null>): this; + + /** + * Appends a new element of this type (tag name) as the last child of each selected element, + * or before the next following sibling in the update selection if this is an enter selection. + * The latter behavior for enter selections allows you to insert elements into the DOM in an order consistent with the new bound data; + * however, note that selection.order may still be required if updating elements change order + * (i.e., if the order of new data is inconsistent with old data). + * + * This method returns a new selection containing the appended elements. + * Each new element inherits the data of the current elements, if any. + * + * @param type A string representing the tag name. + */ + append<K extends keyof ElementTagNameMap>(type: K): Selection<ElementTagNameMap[K], Datum, PElement, PDatum>; + /** + * Appends a new element of this type (tag name) as the last child of each selected element, + * or before the next following sibling in the update selection if this is an enter selection. + * The latter behavior for enter selections allows you to insert elements into the DOM in an order consistent with the new bound data; + * however, note that selection.order may still be required if updating elements change order + * (i.e., if the order of new data is inconsistent with old data). + * + * This method returns a new selection containing the appended elements. + * Each new element inherits the data of the current elements, if any. + * + * The generic refers to the type of the child element to be appended. + * + * @param type A string representing the tag name. The specified name may have a namespace prefix, such as svg:text + * to specify a text attribute in the SVG namespace. If no namespace is specified, the namespace will be inherited + * from the parent element; or, if the name is one of the known prefixes, the corresponding namespace will be used + * (for example, svg implies svg:svg) + */ + append<ChildElement extends BaseType>(type: string): Selection<ChildElement, Datum, PElement, PDatum>; + + /** + * Appends a new element of the type provided by the element creator function as the last child of each selected element, + * or before the next following sibling in the update selection if this is an enter selection. + * The latter behavior for enter selections allows you to insert elements into the DOM in an order consistent with the new bound data; + * however, note that selection.order may still be required if updating elements change order + * (i.e., if the order of new data is inconsistent with old data). + * + * This method returns a new selection containing the appended elements. + * Each new element inherits the data of the current elements, if any. + * + * The generic refers to the type of the child element to be appended. + * + * @param type A creator function which is evaluated for each selected element, in order, being passed the current datum (d), + * the current index (i), and the current group (nodes), with this as the current DOM element (nodes[i]). This function should return + * an element to be appended. (The function typically creates a new element, but it may instead return an existing element.) + */ + append<ChildElement extends BaseType>(type: ValueFn<GElement, Datum, ChildElement>): Selection<ChildElement, Datum, PElement, PDatum>; + + /** + * Inserts a new element of the specified type (tag name) before the first element matching the specified + * before selector for each selected element. For example, a before selector :first-child will prepend nodes before the first child. + * If before is not specified, it defaults to null. (To append elements in an order consistent with bound data, use selection.append.) + * + * This method returns a new selection containing the appended elements. + * Each new element inherits the data of the current elements, if any. + * + * The generic refers to the type of the child element to be appended. + * + * @param type A string representing the tag name for the element type to be inserted. + * @param before One of: + * * A CSS selector string for the element before which the insertion should occur. + * * A child selector function which is evaluated for each selected element, in order, being passed the current datum (d), + * the current index (i), and the current group (nodes), with this as the current DOM element (nodes[i]). This function should return the child element + * before which the element should be inserted. + */ + insert<K extends keyof ElementTagNameMap>( + type: K, + before?: string | ValueFn<GElement, Datum, BaseType> + ): Selection<ElementTagNameMap[K], Datum, PElement, PDatum>; + /** + * Inserts a new element of the specified type (tag name) before the first element matching the specified + * before selector for each selected element. For example, a before selector :first-child will prepend nodes before the first child. + * If before is not specified, it defaults to null. (To append elements in an order consistent with bound data, use selection.append.) + * + * This method returns a new selection containing the appended elements. + * Each new element inherits the data of the current elements, if any. + * + * The generic refers to the type of the child element to be appended. + * + * @param type One of: + * * A string representing the tag name for the element type to be inserted. The specified name may have a namespace prefix, + * such as svg:text to specify a text attribute in the SVG namespace. If no namespace is specified, the namespace will be inherited + * from the parent element; or, if the name is one of the known prefixes, the corresponding namespace will be used + * (for example, svg implies svg:svg) + * * A creator function which is evaluated for each selected element, in order, being passed the current datum (d), + * the current index (i), and the current group (nodes), with this as the current DOM element (nodes[i]). This function should return + * an element to be inserted. (The function typically creates a new element, but it may instead return an existing element.) + * @param before One of: + * * A CSS selector string for the element before which the insertion should occur. + * * A child selector function which is evaluated for each selected element, in order, being passed the current datum (d), + * the current index (i), and the current group (nodes), with this as the current DOM element (nodes[i]). This function should return the child element + * before which the element should be inserted. + */ + insert<ChildElement extends BaseType>( + type: string | ValueFn<GElement, Datum, ChildElement>, + before?: string | ValueFn<GElement, Datum, BaseType> + ): Selection<ChildElement, Datum, PElement, PDatum>; + + /** + * Removes the selected elements from the document. + * Returns this selection (the removed elements) which are now detached from the DOM. + */ + remove(): this; + + /** + * Inserts clones of the selected elements immediately following the selected elements and returns a selection of the newly + * added clones. If deep is true, the descendant nodes of the selected elements will be cloned as well. Otherwise, only the elements + * themselves will be cloned. + * + * @param deep Perform deep cloning if this flag is set to true. + */ + clone(deep?: boolean): Selection<GElement, Datum, PElement, PDatum>; + + /** + * Returns a new selection merging this selection with the specified other selection. + * The returned selection has the same number of groups and the same parents as this selection. + * Any missing (null) elements in this selection are filled with the corresponding element, + * if present (not null), from the specified selection. (If the other selection has additional groups or parents, + * they are ignored.) + * + * This method is commonly used to merge the enter and update selections after a data-join. + * After modifying the entering and updating elements separately, you can merge the two selections and + * perform operations on both without duplicate code. + * + * This method is not intended for concatenating arbitrary selections, however: if both this selection + * and the specified other selection have (non-null) elements at the same index, this selection’s element + * is returned in the merge and the other selection’s element is ignored. + * + * @param other Selection to be merged. + */ + merge(other: Selection<GElement, Datum, PElement, PDatum>): Selection<GElement, Datum, PElement, PDatum>; + + /** + * Filters the selection, returning a new selection that contains only the elements for + * which the specified filter is true. + * + * The returned filtered selection preserves the parents of this selection, but like array.filter, + * it does not preserve indexes as some elements may be removed; use selection.select to preserve the index, if needed. + * + * @param selector A CSS selector string to match when filtering. + */ + filter(selector: string): Selection<GElement, Datum, PElement, PDatum>; + /** + * Filters the selection, returning a new selection that contains only the elements for + * which the specified filter is true. + * + * The returned filtered selection preserves the parents of this selection, but like array.filter, + * it does not preserve indexes as some elements may be removed; use selection.select to preserve the index, if needed. + * + * The generic refers to the type of element which will be selected after applying the filter, i.e. if the element types + * contained in a pre-filter selection are narrowed to a subset as part of the filtering. + * + * @param selector A CSS selector string to match when filtering. + */ + filter<FilteredElement extends BaseType>(selector: string): Selection<FilteredElement, Datum, PElement, PDatum>; + /** + * Filter the selection, returning a new selection that contains only the elements for + * which the specified filter is true. + * + * The returned filtered selection preserves the parents of this selection, but like array.filter, + * it does not preserve indexes as some elements may be removed; use selection.select to preserve the index, if needed. + * + * @param selector A value function which is evaluated for each selected element, in order, being passed the current datum (d), + * the current index (i), and the current group (nodes), with this as the current DOM element (nodes[i]). This function should return true + * for an element to be included, and false otherwise. + */ + filter(selector: ValueFn<GElement, Datum, boolean>): Selection<GElement, Datum, PElement, PDatum>; + /** + * Filter the selection, returning a new selection that contains only the elements for + * which the specified filter is true. + * + * The returned filtered selection preserves the parents of this selection, but like array.filter, + * it does not preserve indexes as some elements may be removed; use selection.select to preserve the index, if needed. + * + * @param selector A value function which is evaluated for each selected element, in order, being passed the current datum (d), + * the current index (i), and the current group (nodes), with this as the current DOM element (nodes[i]). This function should return true + * for an element to be included, and false otherwise. + */ + filter<FilteredElement extends BaseType>(selector: ValueFn<GElement, Datum, boolean>): Selection<FilteredElement, Datum, PElement, PDatum>; + + /** + * Return a new selection that contains a copy of each group in this selection sorted according + * to the compare function. After sorting, re-inserts elements to match the resulting order (per selection.order). + * + * Note that sorting is not guaranteed to be stable; however, it is guaranteed to have the same + * behavior as your browser’s built-in sort method on arrays. + * + * @param comparator An optional comparator function, which defaults to "ascending". The function is passed + * two elements’ data a and b to compare. It should return either a negative, positive, or zero value. + * If negative, then a should be before b; if positive, then a should be after b; otherwise, a and b are + * considered equal and the order is arbitrary. + */ + sort(comparator?: (a: Datum, b: Datum) => number): this; + + /** + * Re-insert elements into the document such that the document order of each group matches the selection order. + * This is equivalent to calling selection.sort if the data is already sorted, but much faster. + */ + order(): this; + + /** + * Re-insert each selected element, in order, as the last child of its parent. + */ + raise(): this; + + /** + * Re-insert each selected element, in order, as the first child of its parent. + */ + lower(): this; + + // Data Join --------------------------------- + + /** + * Returns the bound datum for the first (non-null) element in the selection. + * This is generally useful only if you know the selection contains exactly one element. + */ + datum(): Datum; + /** + * Delete the bound data for each element in the selection. + */ + datum(value: null): Selection<GElement, undefined, PElement, PDatum>; + /** + * Sets the element’s bound data using the specified value function on all selected elements. + * Unlike selection.data, this method does not compute a join and does not affect + * indexes or the enter and exit selections. + * + * The generic refers to the type of the new datum to be used for the selected elements. + * + * @param value A value function which is evaluated for each selected element, in order, + * being passed the current datum (d), the current index (i), and the current group (nodes), + * with this as the current DOM element (nodes[i]). The function is then used to set each element’s new data. + * A null value will delete the bound data. + */ + datum<NewDatum>(value: ValueFn<GElement, Datum, NewDatum>): Selection<GElement, NewDatum, PElement, PDatum>; + /** + * Sets the element’s bound data to the specified value on all selected elements. + * Unlike selection.data, this method does not compute a join and does not affect + * indexes or the enter and exit selections. + * + * The generic refers to the type of the new datum to be used for the selected elements. + * + * @param value A value object to be used as the datum for each element. + */ + datum<NewDatum>(value: NewDatum): Selection<GElement, NewDatum, PElement, PDatum>; + + /** + * Returns the array of data for the selected elements. + */ + data(): Datum[]; + /** + * Joins the specified array of data with the selected elements, returning a new selection that represents + * the update selection: the elements successfully bound to data. Also defines the enter and exit selections on + * the returned selection, which can be used to add or remove elements to correspond to the new data. + * + * The data is specified for each group in the selection. If the selection has multiple groups + * (such as d3.selectAll followed by selection.selectAll), then data should typically be specified as a function. + * + * If a key function is not specified, then the first datum in data is assigned to the first selected element, + * the second datum to the second selected element, and so on. + * A key function may be specified to control which datum is assigned to which element, replacing the default join-by-index, + * by computing a string identifier for each datum and element. + * + * The update and enter selections are returned in data order, while the exit selection preserves the selection + * order prior to the join. If a key function is specified, the order of elements in the selection may not match + * their order in the document; use selection.order or selection.sort as needed. + * + * This method cannot be used to clear bound data; use selection.datum instead. + * + * For details see: {@link https://github.com/d3/d3-selection#joining-data } + * + * The generic refers to the type of the new datum to be used for the selected elements. + * + * @param data The specified data is an array of arbitrary values (e.g., numbers or objects). + * @param key An optional key function which is evaluated for each selected element, in order, being passed the + * current datum (d), the current index (i), and the current group (nodes), with this as the current DOM element (nodes[i]); the returned string is the element’s key. + * The key function is then also evaluated for each new datum in data, being passed the current datum (d), + * the current index (i), and the group’s new data, with this as the group’s parent DOM element (nodes[i]); the returned string is the datum’s key. + * The datum for a given key is assigned to the element with the matching key. If multiple elements have the same key, + * the duplicate elements are put into the exit selection; if multiple data have the same key, the duplicate data are put into the enter selection. + */ + data<NewDatum>(data: NewDatum[], key?: ValueFn<GElement | PElement, Datum | NewDatum, KeyType>): Selection<GElement, NewDatum, PElement, PDatum>; + /** + * Joins the data returned by the specified value function with the selected elements, returning a new selection that it represents + * the update selection: the elements successfully bound to data. Also defines the enter and exit selections on + * the returned selection, which can be used to add or remove elements to correspond to the new data. + * + * The data is specified for each group in the selection. + * + * If a key function is not specified, then the first datum in data is assigned to the first selected element, + * the second datum to the second selected element, and so on. + * A key function may be specified to control which datum is assigned to which element, replacing the default join-by-index, + * by computing a string identifier for each datum and element. + * + * The update and enter selections are returned in data order, while the exit selection preserves the selection + * order prior to the join. If a key function is specified, the order of elements in the selection may not match + * their order in the document; use selection.order or selection.sort as needed. + * + * This method cannot be used to clear bound data; use selection.datum instead. + * + * For details see: {@link https://github.com/d3/d3-selection#joining-data } + * + * The generic refers to the type of the new datum to be used for the selected elements. + * + * @param data A value function which will be evaluated for each group in order, being passed the group’s parent datum + * (d, which may be undefined), the group index (i), and the selection’s parent nodes (nodes), + * with this as the group’s parent element. The function returns an array of values for each group. + * @param key An optional key function which is evaluated for each selected element, in order, being passed the + * current datum (d), the current index (i), and the current group (nodes), with this as the current DOM element (nodes[i]); the returned string is the element’s key. + * The key function is then also evaluated for each new datum in data, being passed the current datum (d), + * the current index (i), and the group’s new data, with this as the group’s parent DOM element (nodes[i]); the returned string is the datum’s key. + * The datum for a given key is assigned to the element with the matching key. If multiple elements have the same key, + * the duplicate elements are put into the exit selection; if multiple data have the same key, the duplicate data are put into the enter selection. + */ + data<NewDatum>(data: ValueFn<PElement, PDatum, NewDatum[]>, key?: ValueFn<GElement | PElement, Datum | NewDatum, KeyType>): Selection<GElement, NewDatum, PElement, PDatum>; + + /** + * Appends, removes and reorders elements as necessary to match the data that was previously bound by `selection.data`, returning the merged enter and update selection. + * This method is a convenient alternative to the more explicit `selection.enter`, `selection.exit`, `selection.append` and `selection.remove`. + * + * The "matching" logic is determined by the key function passed to `selection.data`. + */ + join<K extends keyof ElementTagNameMap, OldDatum = Datum>( + enter: K, + update?: (elem: Selection<GElement, Datum, PElement, PDatum>) => Selection<GElement, Datum, PElement, PDatum> | undefined, + exit?: (elem: Selection<GElement, OldDatum, PElement, PDatum>) => void + ): Selection<GElement | ElementTagNameMap[K], Datum, PElement, PDatum>; + /** + * Appends, removes and reorders elements as necessary to match the data that was previously bound by `selection.data`, returning the merged enter and update selection. + * This method is a convenient alternative to the more explicit `selection.enter`, `selection.exit`, `selection.append` and `selection.remove`. + * + * The "matching" logic is determined by the key function passed to `selection.data`. + */ + join<ChildElement extends BaseType, OldDatum = Datum>( + enter: string, + update?: (elem: Selection<GElement, Datum, PElement, PDatum>) => Selection<GElement, Datum, PElement, PDatum> | undefined, + exit?: (elem: Selection<GElement, OldDatum, PElement, PDatum>) => void + ): Selection<ChildElement | GElement, Datum, PElement, PDatum>; + /** + * Appends, removes and reorders elements as necessary to match the data that was previously bound by `selection.data`, returning the merged enter and update selection. + * This method is a convenient alternative to the more explicit `selection.enter`, `selection.exit`, `selection.append` and `selection.remove`. + * + * The "matching" logic is determined by the key function passed to `selection.data`. + */ + join<ChildElement extends BaseType, OldDatum = Datum>( + enter: (elem: Selection<EnterElement, Datum, PElement, PDatum>) => Selection<ChildElement, Datum, PElement, PDatum>, + update?: (elem: Selection<GElement, Datum, PElement, PDatum>) => Selection<GElement, Datum, PElement, PDatum> | undefined, + exit?: (elem: Selection<GElement, OldDatum, PElement, PDatum>) => void + ): Selection<ChildElement | GElement, Datum, PElement, PDatum>; + + /** + * Return the enter selection: placeholder nodes for each datum that had no corresponding DOM element + * in the selection. (The enter selection is empty for selections not returned by selection.data.) + */ + enter(): Selection<EnterElement, Datum, PElement, PDatum>; + + /** + * Returns the exit selection: existing DOM elements in the selection for which no new datum was found. + * (The exit selection is empty for selections not returned by selection.data.) + * + * IMPORTANT: The generic refers to the type of the old datum associated with the exit selection elements. + * Ensure you set the generic to the correct type, if you need to access the data on the exit selection in + * follow-up steps, e.g. to set styles as part of an exit transition before removing them. + */ + exit<OldDatum>(): Selection<GElement, OldDatum, PElement, PDatum>; + + // Event Handling ------------------- + + /** + * Return the currently-assigned listener for the specified event typename on the first (non-null) selected element, + * if any, If multiple typenames are specified, the first matching listener is returned. + * + * @param typenames The typenames is a string event type, such as click, mouseover, or submit; any DOM event type supported by your browser may be used. + * The type may be optionally followed by a period (.) and a name; the optional name allows multiple callbacks to be registered + * to receive events of the same type, such as click.foo and click.bar. To specify multiple typenames, separate typenames with spaces, + * such as "input change"" or "click.foo click.bar". + */ + on(typenames: string): ValueFn<GElement, Datum, void> | undefined; + /** + * Remove a listener for the specified event type names. To remove all listeners for a given name, + * pass null as the listener and ".foo" as the typename, where foo is the name; to remove all listeners with no name, specify "." as the typename. + * + * @param typenames The typenames is a string event type, such as click, mouseover, or submit; any DOM event type supported by your browser may be used. + * The type may be optionally followed by a period (.) and a name; the optional name allows multiple callbacks to be registered + * to receive events of the same type, such as click.foo and click.bar. To specify multiple typenames, separate typenames with spaces, + * such as "input change"" or "click.foo click.bar". + * @param listener null to indicate removal of listener + */ + on(typenames: string, listener: null): this; + /** + * Add an event listener for the specified event type names. If an event listener was previously registered for the same typename + * on a selected element, the old listener is removed before the new listener is added. + * + * When a specified event is dispatched on a selected node, the specified listener will be evaluated for each selected element. + * + * An optional capture flag may be specified which corresponds to the W3C useCapture flag: + * "After initiating capture, all events of the specified type will be dispatched to the registered EventListener before being + * dispatched to any EventTargets beneath them in the tree. Events which are bubbling upward through the tree will not + * trigger an EventListener designated to use capture." + * + * @param typenames The typenames is a string event type, such as click, mouseover, or submit; any DOM event type supported by your browser may be used. + * The type may be optionally followed by a period (.) and a name; the optional name allows multiple callbacks to be registered + * to receive events of the same type, such as click.foo and click.bar. To specify multiple typenames, separate typenames with spaces, + * such as "input change"" or "click.foo click.bar". + * @param listener A listener function which will be evaluated for each selected element, being passed the current datum (d), the current index (i), + * and the current group (nodes), with this as the current DOM element (nodes[i]). Listeners always see the latest datum for their element, + * but the index is a property of the selection and is fixed when the listener is assigned; to update the index, re-assign the listener. + * To access the current event within a listener, use d3.event. + * @param capture An optional capture flag which corresponds to the W3C useCapture flag. + */ + on(typenames: string, listener: ValueFn<GElement, Datum, void>, capture?: boolean): this; + + /** + * Dispatches a custom event of the specified type to each selected element, in order. + * An optional parameters map may be specified to set additional properties of the event. + * + * @param type Name of event to dispatch + * @param parameters An optional value map with custom event parameters + */ + dispatch(type: string, parameters?: CustomEventParameters): this; + /** + * Dispatches a custom event of the specified type to each selected element, in order. + * An optional value function returning a parameters map for each element in the selection may be specified to set additional properties of the event. + * + * @param type Name of event to dispatch + * @param parameters A value function which is evaluated for each selected element, in order, + * being passed the current datum (d), the current index (i), and the current group (nodes), + * with this as the current DOM element (nodes[i]). It must return the parameters map for the current element. + */ + dispatch(type: string, parameters?: ValueFn<GElement, Datum, CustomEventParameters>): this; + + // Control Flow ---------------------- + + /** + * Invoke the specified function for each selected element, passing in the current datum (d), + * the current index (i), and the current group (nodes), with this of the current DOM element (nodes[i]). + * This method can be used to invoke arbitrary code for each selected element, and is useful for creating a context to access parent and child data simultaneously. + * + * @param func A function which is invoked for each selected element, + * being passed the current datum (d), the current index (i), and the current group (nodes), with this of the current DOM element (nodes[i]). + */ + each(func: ValueFn<GElement, Datum, void>): this; + + /** + * Invoke the specified function exactly once, passing in this selection along with any optional arguments. + * Returns this selection. + * + * @param func A function which is passed this selection as the first argument along with any optional arguments. + * @param args List of optional arguments to be passed to the callback function. + */ + call(func: (selection: Selection<GElement, Datum, PElement, PDatum>, ...args: any[]) => void, ...args: any[]): this; + + /** + * Return true if this selection contains no (non-null) elements. + */ + empty(): boolean; + + /** + * Return the first (non-null) element in this selection. If the selection is empty, returns null. + */ + node(): GElement | null; + + /** + * Return an array of all (non-null) elements in this selection. + */ + nodes(): GElement[]; + + /** + * Returns the total number of elements in this selection. + */ + size(): number; +} + +/** + * Selects the root element, document.documentElement. This function can also be used to test for selections + * (instanceof d3.selection) or to extend the selection prototype. + */ +export type SelectionFn = () => Selection<HTMLElement, any, null, undefined>; + +/** + * Selects the root element, document.documentElement. This function can also be used to test for selections + * (instanceof d3.selection) or to extend the selection prototype. + */ +export const selection: SelectionFn; + +// --------------------------------------------------------------------------- +// on.js event and customEvent related +// --------------------------------------------------------------------------- + +/** + * A D3 Base Event + */ +export interface BaseEvent { + /** + * Event type + */ + type: string; + /** + * The prior value of d3.event, allowing custom events to retain a reference to the originating native event. + */ + sourceEvent?: any; // Could be of all sorts of types, too general: BaseEvent | Event | MouseEvent | TouchEvent | ... | OwnCustomEventType; +} + +/** + * The current event, if any. This is set during the invocation of an event listener, and is reset after the listener terminates. + * Use this to access standard event fields such as event.timeStamp and methods such as event.preventDefault. + * While you can use the native event.pageX and event.pageY, it is often more convenient to transform the event position to + * the local coordinate system of the container that received the event using d3.mouse, d3.touch or d3.touches. + * + * If you use Babel, Webpack, or another ES6-to-ES5 bundler, be aware that the value of d3.event changes during an event! + * An import of d3.event must be a live binding, so you may need to configure the bundler to import from D3’s ES6 modules + * rather than from the generated UMD bundle; not all bundlers observe jsnext:main. + * Also beware of conflicts with the window.event global. + */ +export const event: any; // Could be of all sorts of types, too general: BaseEvent | Event | MouseEvent | TouchEvent | ... | OwnCustomEventType; + +/** + * Invokes the specified listener, using the specified "that" as "this" context and passing the specified arguments, if any. + * During the invocation, d3.event is set to the specified event; after the listener returns (or throws an error), + * d3.event is restored to its previous value. + * In addition, sets event.sourceEvent to the prior value of d3.event, allowing custom events to retain a reference to the originating native event. + * Returns the value returned by the listener. + * + * The first generic "Context" refers to the "this" context type in which the listener will be invoked. + * The second generic "Result" specifies the return type of the listener. + * + * @param event The event to which d3.event will be set during the listener invocation. + * @param listener The event listener function to be invoked. This function will be invoked with the "this" context, provided + * by the "that" argument of customEvent(...). It will be passed all optional arguments passed to customEvent(...). The function returns + * a value corresponding to the type of the second generic type. + * @param that The "this"" context which will be used for the invocation of listener. + * @param args A list of optional arguments, which will be passed to listener. + */ +export function customEvent<Context, Result>(event: BaseEvent, listener: (this: Context, ...args: any[]) => Result, that: Context, ...args: any[]): Result; + +// --------------------------------------------------------------------------- +// mouse.js related +// --------------------------------------------------------------------------- + +/** + * Get (x, y)-coordinates of the current event relative to the specified container element. + * The container may be an HTML or SVG container element, such as a G element or an SVG element. + * The coordinates are returned as a two-element array of numbers [x, y]. + * + * @param container Container element relative to which coordinates are calculated. + */ +export function mouse(container: ContainerElement): [number, number]; + +// --------------------------------------------------------------------------- +// touch.js and touches.js related +// --------------------------------------------------------------------------- + +/** + * Returns the x and y coordinates of the touch with the specified identifier associated + * with the current event relative to the specified container. + * The container may be an HTML or SVG container element, such as a G element or an SVG element. + * The coordinates are returned as a two-element array of numbers [x, y] or null if there is no touch with + * the specified identifier in touches, returns null; this can be useful for ignoring touchmove events + * where the only some touches have moved. + * + * If touches is not specified, it defaults to the current event’s changedTouches property. + * + * @param container Container element relative to which coordinates are calculated. + * @param identifier Touch Identifier associated with the current event. + */ +export function touch(container: ContainerElement, identifier: number): [number, number] | null; + +/** + * Return the x and y coordinates of the touch with the specified identifier associated + * with the current event relative to the specified container. + * The container may be an HTML or SVG container element, such as a G element or an SVG element. + * The coordinates are returned as a two-element array of numbers [x, y] or null if there is no touch with + * the specified identifier in touches, returns null; this can be useful for ignoring touchmove events + * where the only some touches have moved. + * + * If touches is not specified, it defaults to the current event’s changedTouches property. + * + * @param container Container element relative to which coordinates are calculated. + * @param touches TouchList to be used when identifying the touch. + * @param identifier Touch Identifier associated with the current event. + */ +export function touch(container: ContainerElement, touches: TouchList, identifier: number): [number, number] | null; + +/** + * Return the x and y coordinates of the touches associated with the current event relative to the specified container. + * The container may be an HTML or SVG container element, such as a G element or an SVG element. + * The coordinates are returned as an array of two-element arrays of numbers [[x1, y1], [x2, y2], …]. + * + * If touches is not specified, it defaults to the current event’s touches property. + * + * @param container Container element relative to which coordinates are calculated. + * @param touches TouchList to be used. + */ +export function touches(container: ContainerElement, touches?: TouchList): Array<[number, number]>; + +/** + * Returns the x and y coordinates of the specified event relative to the specified container. + * (The event may also be a touch.) The container may be an HTML or SVG container element, such as a G element or an SVG element. + * The coordinates are returned as a two-element array of numbers [x, y]. + * + * @param container Container element relative to which coordinates are calculated. + * @param event A User interface event (e.g. mouse event, touch or MSGestureEvent) with captured clientX and clientY properties. + */ +export function clientPoint(container: ContainerElement, event: ClientPointEvent): [number, number]; + +// --------------------------------------------------------------------------- +// style +// --------------------------------------------------------------------------- + +/** + * Returns the value of the style property with the specified name for the specified node. + * If the node has an inline style with the specified name, its value is returned; otherwise, the computed property value is returned. + * See also selection.style. + * + * @param node A DOM node (e.g. HTMLElement, SVGElement) for which to retrieve the style property. + * @param name Style property name. + */ +export function style(node: Element, name: string): string; + +// --------------------------------------------------------------------------- +// local.js related +// --------------------------------------------------------------------------- + +export interface Local<T> { + /** + * Retrieves a local variable stored on the node (or one of its parents). + * + * @param node A node element. + */ + get(node: Element): T | undefined; + /** + * Deletes the value associated with the given node. Values stored on ancestors are not affected, meaning that child nodes will still see inherited values. + * + * This function returns true if there was a value stored directly on the node, and false otherwise. + * + * @param node A node element. + */ + remove(node: Element): boolean; + /** + * Store a value for this local variable. Calling `.get()` on children of this node will also retrieve the variable's value. + * + * @param node A node element. + * @param value Value to store locally + */ + set(node: Element, value: T): Element; + /** + * Obtain a string with the internally assigned property name for the local + * which is used to store the value on a node + */ + toString(): string; +} + +/** + * Obtain a new local variable + * + * The generic refers to the type of the variable to store locally. + */ +export function local<T>(): Local<T>; + +// --------------------------------------------------------------------------- +// namespace.js related +// --------------------------------------------------------------------------- + +/** + * Interface for object literal containing local name with related fully qualified namespace + */ +export interface NamespaceLocalObject { + /** + * Fully qualified namespace + */ + space: string; + /** + * Name of the local to be namespaced. + */ + local: string; +} + +/** + * Obtain an object with properties of fully qualified namespace string and + * name of local by parsing a shorthand string "prefix:local". If the prefix + * does not exist in the "namespaces" object provided by d3-selection, then + * the local name is returned as a simple string. + * + * @param prefixedLocal A string composed of the namespace prefix and local + * name separated by colon, e.g. "svg:text". + */ +export function namespace(prefixedLocal: string): NamespaceLocalObject | string; + +// --------------------------------------------------------------------------- +// namespaces.js related +// --------------------------------------------------------------------------- + +/** + * Interface for maps of namespace prefixes to corresponding fully qualified namespace strings + */ +export interface NamespaceMap { [prefix: string]: string; } + +/** + * Map of namespace prefixes to corresponding fully qualified namespace strings + */ +export const namespaces: NamespaceMap; + +// --------------------------------------------------------------------------- +// window.js related +// --------------------------------------------------------------------------- + +/** + * Returns the owner window for the specified node. If node is a node, returns the owner document’s default view; + * if node is a document, returns its default view; otherwise returns the node. + * + * @param DOMNode A DOM element + */ +export function window(DOMNode: Window | Document | Element): Window; + +// --------------------------------------------------------------------------- +// creator.js and matcher.js Complex helper closure generating functions +// for explicit bound-context dependent use +// --------------------------------------------------------------------------- + +/** + * Given the specified element name, returns a single-element selection containing + * a detached element of the given name in the current document. + * + * @param name tag name of the element to be added. + */ +export function create<K extends keyof ElementTagNameMap>(name: K): Selection<ElementTagNameMap[K], undefined, null, undefined>; +/** + * Given the specified element name, returns a single-element selection containing + * a detached element of the given name in the current document. + * + * @param name Tag name of the element to be added. See "namespace" for details on supported namespace prefixes, + * such as for SVG elements. + */ +export function create<NewGElement extends Element>(name: string): Selection<NewGElement, undefined, null, undefined>; + +/** + * Given the specified element name, returns a function which creates an element of the given name, + * assuming that "this" is the parent element. + * + * @param name Tag name of the element to be added. + */ +export function creator<K extends keyof ElementTagNameMap>(name: K): (this: BaseType) => ElementTagNameMap[K]; +/** + * Given the specified element name, returns a function which creates an element of the given name, + * assuming that "this" is the parent element. + * + * The generic refers to the type of the new element to be returned by the creator function. + * + * @param name Tag name of the element to be added. See "namespace" for details on supported namespace prefixes, + * such as for SVG elements. + */ +export function creator<NewGElement extends Element>(name: string): (this: BaseType) => NewGElement; + +/** + * Given the specified selector, returns a function which returns true if "this" element matches the specified selector. + * + * @param selector A CSS selector string. + */ +export function matcher(selector: string): (this: BaseType) => boolean; + +// ---------------------------------------------------------------------------- +// selector.js and selectorAll.js related functions +// ---------------------------------------------------------------------------- + +/** + * Given the specified selector, returns a function which returns the first descendant of "this" element + * that matches the specified selector. + * + * The generic refers to the type of the returned descendant element. + * + * @param selector A CSS selector string. + */ +export function selector<DescElement extends Element>(selector: string): (this: BaseType) => DescElement; + +/** + * Given the specified selector, returns a function which returns all descendants of "this" element that match the specified selector. + * + * The generic refers to the type of the returned descendant element. + * + * @param selector A CSS selector string. + */ +export function selectorAll<DescElement extends Element>(selector: string): (this: BaseType) => NodeListOf<DescElement>; diff --git a/chromium/third_party/node/node_modules/@types/d3-transition/index.d.ts b/chromium/third_party/node/node_modules/@types/d3-transition/index.d.ts new file mode 100755 index 00000000000..41e2b1c9340 --- /dev/null +++ b/chromium/third_party/node/node_modules/@types/d3-transition/index.d.ts @@ -0,0 +1,643 @@ +// Type definitions for D3JS d3-transition module 3.0 +// Project: https://github.com/d3/d3-transition/, https://d3js.org/d3-transition +// Definitions by: Tom Wanzek <https://github.com/tomwanzek> +// Alex Ford <https://github.com/gustavderdrache> +// Boris Yankov <https://github.com/borisyankov> +// Robert Moura <https://github.com/robertmoura> +// Nathan Bierema <https://github.com/Methuselah96> +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +// Last module patch version validated against: 3.0.1 + +import { ArrayLike, BaseType, Selection, ValueFn } from 'd3-selection'; + +/** + * Extend interface 'Selection' by declaration merging with 'd3-selection' + */ +declare module 'd3-selection' { + /** + * A D3 Selection of elements. + * + * The first generic "GElement" refers to the type of the selected element(s). + * The second generic "Datum" refers to the type of the datum of a selected element(s). + * The third generic "PElement" refers to the type of the parent element(s) in the D3 selection. + * The fourth generic "PDatum" refers to the type of the datum of the parent element(s). + */ + interface Selection<GElement extends BaseType, Datum, PElement extends BaseType, PDatum> { + /** + * Interrupts the active transition of the specified name on the selected elements, and cancels any pending transitions with the specified name, if any. + * If a name is not specified, null is used. + * + * IMPORTANT: Interrupting a transition on an element has no effect on any transitions on any descendant elements. + * For example, an axis transition consists of multiple independent, synchronized transitions on the descendants of the axis G element + * (the tick lines, the tick labels, the domain path, etc.). To interrupt the axis transition, you must therefore interrupt the descendants. + * + * @param name Name of the transition. + */ + interrupt(name?: string): this; + /** + * Returns a new transition on the given selection with the specified name. If a name is not specified, null is used. + * The new transition is only exclusive with other transitions of the same name. + * + * @param name Name of the transition. + */ + transition(name?: string): Transition<GElement, Datum, PElement, PDatum>; + /** + * Returns a new transition on the given selection. + * + * When using a transition instance, the returned transition has the same id and name as the specified transition. + * If a transition with the same id already exists on a selected element, the existing transition is returned for that element. + * Otherwise, the timing of the returned transition is inherited from the existing transition of the same id on the nearest ancestor of each selected element. + * Thus, this method can be used to synchronize a transition across multiple selections, + * or to re-select a transition for specific elements and modify its configuration. + * + * If the specified transition is not found on a selected node or its ancestors (such as if the transition already ended), + * the default timing parameters are used; however, in a future release, this will likely be changed to throw an error. + * + * @param transition A transition instance. + */ + transition(transition: Transition<BaseType, any, any, any>): Transition<GElement, Datum, PElement, PDatum>; + } +} + +/** + * Return the active transition on the specified node with the specified name, if any. + * If no name is specified, null is used. Returns null if there is no such active transition on the specified node. + * This method is useful for creating chained transitions. + * + * The first generic "GElement" refers to the type of element on which the returned active transition was defined. The second generic "Datum" refers to the type of the + * datum, of a selected element on which the transition is defined. The third generic refers to the type of the parent elements in the returned Transition. + * The fourth generic refers to the type of the datum defined on the parent elements in the returned Transition. + * + * @param node Element for which the active transition should be returned. + * @param name Name of the transition. + */ +// tslint:disable-next-line:no-unnecessary-generics +export function active<GElement extends BaseType, Datum, PElement extends BaseType, PDatum>(node: GElement, name?: string): Transition<GElement, Datum, PElement, PDatum> | null; + +/** + * Interrupts the active transition of the specified name on the specified node, and cancels any pending transitions with the specified name, if any. + * If a name is not specified, null is used. + * + * @param node Element for which the transition should be interrupted. + * @param name Name of the transition to be interrupted. If a name is not specified, null is used. + */ +export function interrupt(node: BaseType, name?: string): void; + +/** + * A D3 Transition. + * + * The first generic "GElement" refers to the type of the selected element(s) in the Transition. + * The second generic "Datum" refers to the type of the datum of a selected element(s) in the Transition. + * The third generic "PElement" refers to the type of the parent element(s) in the D3 selection in the Transition. + * The fourth generic "PDatum" refers to the type of the datum of the parent element(s) in the Transition. + */ +export interface Transition<GElement extends BaseType, Datum, PElement extends BaseType, PDatum> { + // Sub-selection ------------------------- + + /** + * For each selected element, select the first descendant element that matches the specified selector string, if any, + * and returns a transition on the resulting selection. The new transition has the same id, name and timing as this transition; + * however, if a transition with the same id already exists on a selected element, + * the existing transition is returned for that element. + * + * The generic represents the type of the descendant element to be selected. + * + * @param selector CSS selector string + */ + // tslint:disable-next-line:no-unnecessary-generics + select<DescElement extends BaseType>(selector: string): Transition<DescElement, Datum, PElement, PDatum>; + /** + * For each selected element, select the descendant element returned by the selector function, if any, + * and returns a transition on the resulting selection. The new transition has the same id, name and timing as this transition; + * however, if a transition with the same id already exists on a selected element, + * the existing transition is returned for that element. + * + * The generic represents the type of the descendant element to be selected. + * + * @param selector A selector function, which is evaluated for each selected element, in order, being passed the current datum (d), + * the current index (i), and the current group (nodes), with this as the current DOM element (nodes[i]). + * It must return an element, or null if there is no matching element. + */ + select<DescElement extends BaseType>(selector: ValueFn<GElement, Datum, DescElement>): Transition<DescElement, Datum, PElement, PDatum>; + + /** + * For each selected element, select all descendant elements that match the specified selector string, if any, + * and returns a transition on the resulting selection. The new transition has the same id, name and timing as this transition; + * however, if a transition with the same id already exists on a selected element, the existing transition is returned for that element. + * + * The first generic "DescElement" refers to the type of descendant element to be selected. The second generic "OldDatum" refers to the type of the + * datum, of a selected element. This is useful when re-selecting elements with a previously set, know datum type. + * + * @param selector CSS selector string + */ + // tslint:disable-next-line:no-unnecessary-generics + selectAll<DescElement extends BaseType, OldDatum>(selector: string): Transition<DescElement, OldDatum, GElement, Datum>; + /** + * For each selected element, select all descendant elements returned by the selector function, if any, + * and returns a transition on the resulting selection. The new transition has the same id, name and timing as this transition; + * however, if a transition with the same id already exists on a selected element, the existing transition is returned for that element. + * + * The first generic "DescElement" refers to the type of descendant element to be selected. The second generic "OldDatum" refers to the type of the + * datum, of a selected element. This is useful when re-selecting elements with a previously set, know datum type. + * + * @param selector A selector function which is evaluated for each selected element, in order, being passed the current datum (d), + * the current index (i), and the current group (nodes), with this as the current DOM element (nodes[i]). It must return an array of elements + * (or a pseudo-array, such as a NodeList), or the empty array if there are no matching elements. + */ + // tslint:disable-next-line:no-unnecessary-generics + selectAll<DescElement extends BaseType, OldDatum>(selector: ValueFn<GElement, Datum, DescElement[] | ArrayLike<DescElement>>): Transition<DescElement, OldDatum, GElement, Datum>; + + /** + * For each selected element, selects the first child element that matches the specified selector string, if any, and returns a transition on the resulting selection. + * The selector may be specified either as a selector string or a function. + * If a function, it is evaluated for each selected element, in order, being passed the current datum (d), + * the current index (i), and the current group (nodes), with this as the current DOM element. + * The new transition has the same id, name and timing as this transition; + * however, if a transition with the same id already exists on a selected element, the existing transition is returned for that element. + * This method is equivalent to deriving the selection for this transition via transition.selection, + * creating a subselection via selection.selectChild, and then creating a new transition via selection.transition. + */ + // tslint:disable-next-line:no-unnecessary-generics + selectChild<DescElement extends BaseType, OldDatum>(selector?: string | ValueFn<GElement, Datum, DescElement>): Transition<DescElement, OldDatum, GElement, Datum>; + + /** + * For each selected element, selects all children that match the specified selector string, if any, and returns a transition on the resulting selection. + * The selector may be specified either as a selector string or a function. + * If a function, it is evaluated for each selected element, in order, being passed the current datum (d), + * the current index (i), and the current group (nodes), with this as the current DOM element. + * The new transition has the same id, name and timing as this transition; + * however, if a transition with the same id already exists on a selected element, the existing transition is returned for that element. + * This method is equivalent to deriving the selection for this transition via transition.selection, + * creating a subselection via selection.selectChildren, and then creating a new transition via selection.transition. + */ + // tslint:disable-next-line:no-unnecessary-generics + selectChildren<DescElement extends BaseType, OldDatum>(selector?: string | ValueFn<GElement, Datum, DescElement>): Transition<DescElement, OldDatum, GElement, Datum>; + + /** + * Return the selection corresponding to this transition. + */ + selection(): Selection<GElement, Datum, PElement, PDatum>; + + /** + * Returns a new transition on the same selected elements as this transition, scheduled to start when this transition ends. + * The new transition inherits a reference time equal to this transition’s time plus its delay and duration. + * The new transition also inherits this transition’s name, duration, and easing. + * This method can be used to schedule a sequence of chained transitions. + * + * A delay configured for the new transition will be relative to the previous transition. + */ + transition(): Transition<GElement, Datum, PElement, PDatum>; + + // Modifying ------------------------------- + + /** + * For each selected element, assigns the attribute tween for the attribute with the specified name to the specified target value. + * The starting value of the tween is the attribute’s value when the transition starts. + * If the target value is null, the attribute is removed when the transition starts. + */ + attr(name: string, value: null | string | number | boolean): this; + /** + * For each selected element, assigns the attribute tween for the attribute with the specified name to the specified target value. + * The starting value of the tween is the attribute’s value when the transition starts. + * The target value is return value of the value function evaluated for the selected element. + * + * An interpolator is chosen based on the type of the target value, using the following algorithm: + * 1.) If value is a number, use interpolateNumber. + * 2.) If value is a color or a string coercible to a color, use interpolateRgb. + * 3.) Use interpolateString. + * + * To apply a different interpolator, use transition.attrTween. + * + * @param name Name of the attribute. + * @param value A value function which is evaluated for each selected element, in order, being passed the current datum (d), + * the current index (i), and the current group (nodes), with this as the current DOM element (nodes[i]). + * A null value will clear the attribute at the start of the transition. + */ + attr(name: string, value: ValueFn<GElement, Datum, string | number | boolean | null>): this; + + /** + * Return the current interpolator factory for attribute with the specified name, or undefined if no such tween exists. + * + * @param name Name of attribute. + */ + attrTween(name: string): ValueFn<GElement, Datum, (this: GElement, t: number) => string> | undefined; + /** + * Remove the previously-assigned attribute tween of the specified name, if any. + * + * @param name Name of attribute. + * @param factory Use null to remove previously-assigned attribute tween. + */ + attrTween(name: string, factory: null): this; + /** + * Assign the attribute tween for the attribute with the specified name to the specified interpolator factory. + * An interpolator factory is a function that returns an interpolator; when the transition starts, the factory is evaluated for each selected element. + * The returned interpolator will then be invoked for each frame of the transition, in order, + * being passed the eased time t, typically in the range [0, 1]. Lastly, the return value of the interpolator will be used to set the attribute value. + * The interpolator must return a string. + * + * @param name Name of attribute. + * @param factory An interpolator factory which is evaluated for each selected element, in order, being passed the current datum (d), + * the current index (i), and the current group (nodes), with this as the current DOM element (nodes[i]). The interpolator factory returns a string interpolator, + * which takes as its argument eased time t, typically in the range [0, 1] and returns the interpolated string. + */ + attrTween(name: string, factory: ValueFn<GElement, Datum, (this: GElement, t: number) => string>): this; + + /** + * For each selected element, the style with the specified name will be cleared at the start of the transition. + * + * @param name Name of the style. + * @param value Use null to clear the style. + */ + style(name: string, value: null): this; + /** + * For each selected element, assigns the style tween for the style with the specified name to the specified target value with the + * specified priority. + * The starting value of the tween is the style’s inline value if present, and otherwise its computed value. + * The target value is the specified constant value for all elements. + * + * An interpolator is chosen based on the type of the target value, using the following algorithm: + * 1.) If value is a number, use interpolateNumber. + * 2.) If value is a color or a string coercible to a color, use interpolateRgb. + * 3.) Use interpolateString. + * + * To apply a different interpolator, use transition.attrTween. + * + * @param name Name of the style. + * @param value Target value for the style. + * @param priority An optional priority flag, either null or the string important (without the exclamation point) + */ + style(name: string, value: string | number | boolean, priority?: null | 'important'): this; + /** + * For each selected element, assigns the style tween for the style with the specified name to the specified target value with the + * specified priority. + * The starting value of the tween is the style's inline value if present, and otherwise its computed value. + * The target value is return value of the value function evaluated for the selected element. + * + * An interpolator is chosen based on the type of the target value, using the following algorithm: + * 1.) If value is a number, use interpolateNumber. + * 2.) If value is a color or a string coercible to a color, use interpolateRgb. + * 3.) Use interpolateString. + * + * To apply a different interpolator, use transition.attrTween. + * + * @param name Name of the style. + * @param value A value function which is evaluated for each selected element, in order, being passed the current datum (d), + * the current index (i), and the current group (nodes), with this as the current DOM element (nodes[i]). + * A null value will clear the style at the start of the transition. + * @param priority An optional priority flag, either null or the string important (without the exclamation point) + */ + style(name: string, value: ValueFn<GElement, Datum, string | number | boolean | null>, priority?: null | 'important'): this; + + /** + * Return the current interpolator factory for style with the specified name, or undefined if no such tween exists. + * + * @param name Name of style. + */ + styleTween(name: string): ValueFn<GElement, Datum, (this: GElement, t: number) => string> | undefined; + /** + * Remove the previously-assigned style tween of the specified name, if any. + * + * @param name Name of style. + * @param factory Use null to remove previously-assigned style tween. + */ + styleTween(name: string, factory: null): this; + /** + * Assign the style tween for the style with the specified name to the specified interpolator factory. + * An interpolator factory is a function that returns an interpolator; when the transition starts, the factory is evaluated for each selected element. + * The returned interpolator will then be invoked for each frame of the transition, in order, + * being passed the eased time t, typically in the range [0, 1]. Lastly, the return value of the interpolator will be used to set the style value. + * The interpolator must return a string. + * + * @param name Name of style. + * @param factory An interpolator factory which is evaluated for each selected element, in order, being passed the current datum (d), + * the current index (i), and the current group (nodes), with this as the current DOM element (nodes[i]). The interpolator factory returns a string interpolator, + * which takes as its argument eased time t, typically in the range [0, 1] and returns the interpolated string. + * @param priority An optional priority flag, either null or the string important (without the exclamation point) + */ + styleTween(name: string, factory: ValueFn<GElement, Datum, (this: GElement, t: number) => string>, priority?: null | 'important'): this; + + /** + * For each selected element, sets the text content to the specified target value when the transition starts. + * A null value will clear the content. + */ + text(value: null | string | number | boolean): this; + /** + * For each selected element, sets the text content returned by the value function for each selected element when the transition starts. + * + * To interpolate text rather than to set it on start, use transition.textTween (for example) or append a replacement element and cross-fade opacity (for example). + * Text is not interpolated by default because it is usually undesirable. + * + * @param value A value function which is evaluated for each selected element, in order, being passed the current datum (d), + * the current index (i), and the current group (nodes), with this as the current DOM element (nodes[i]). + * A null value will clear the text content at the start of the transition. + */ + text(value: ValueFn<GElement, Datum, string | number | boolean>): this; + + /** + * Returns the current interpolator factory for text, or undefined if no such tween exists. + */ + textTween(): ValueFn<GElement, Datum, (this: GElement, t: number) => string> | undefined; + /** + * Removes the previously-assigned text tween, if any + * + * @param factory Use null to remove previously-assigned text tween. + */ + textTween(factory: null): this; + /** + * Assigns the text tween to the specified interpolator factory. + * An interpolator factory is a function that returns an interpolator; when the transition starts, the factory is evaluated for each selected element, + * in order, being passed the current datum d and index i, with the this context as the current DOM element. + * The returned interpolator will then be invoked for each frame of the transition, in order, being passed the eased time t, typically in the range [0, 1]. + * Lastly, the return value of the interpolator will be used to set the text. + * The interpolator must return a string. + * + * @param factory An interpolator factory is a function that returns an interpolator; when the transition starts, the factory is evaluated for each selected element, + * in order, being passed the current datum d and index i, with the this context as the current DOM element. + * The returned interpolator will then be invoked for each frame of the transition, in order, being passed the eased time t, typically in the range [0, 1]. + * Lastly, the return value of the interpolator will be used to set the text. + * The interpolator must return a string. + */ + textTween(factory: ValueFn<GElement, Datum, (this: GElement, t: number) => string>): this; + + /** + * For each selected element, removes the element when the transition ends, as long as the element has no other active or pending transitions. + * If the element has other active or pending transitions, does nothing. + */ + remove(): this; + + /** + * Returns the tween with the specified name, or undefined, if no tween was previously assigned to + * that name. + * + * @param name Name of tween. + */ + tween(name: string): ValueFn<GElement, Datum, (this: GElement, t: number) => void> | undefined; + /** + * Removes the tween with the specified name, if a tween was previously assigned to + * that name. + * + * @param name Name of tween. + * @param tweenFn Use null to remove a previously-assigned tween. + */ + tween(name: string, tweenFn: null): this; + /** + * For each selected element, assigns the tween with the specified name with the specified value function. + * The value must be specified as a function that returns a function. + * When the transition starts, the value function is evaluated for each selected element. + * The returned function is then invoked for each frame of the transition, in order, + * being passed the eased time t, typically in the range [0, 1]. + * + * @param name Name of tween. + * @param tweenFn A tween function which is evaluated for each selected element, in order, being passed the current datum (d), + * the current index (i), and the current group (nodes), with this as the current DOM element (nodes[i]). The tween function returns a function + * which takes as its argument eased time t, typically in the range [0, 1] and performs the tweening activities for each transition frame. + */ + tween(name: string, tweenFn: ValueFn<GElement, Datum, (this: GElement, t: number) => void>): this; + + /** + * Returns a new transition merging this transition with the specified other transition, + * which must have the same id as this transition. The returned transition has the same number of groups, + * the same parents, the same name and the same id as this transition. + * Any missing (null) elements in this transition are filled with the corresponding element, if present (not null), from the other transition. + * + * @param other The transition to be merged. + */ + merge(other: Transition<GElement, Datum, PElement, PDatum>): Transition<GElement, Datum, PElement, PDatum>; + + /** + * For each selected element, selects only the elements that match the specified filter, and returns a transition on the resulting selection. + * + * The new transition has the same id, name and timing as this transition; however, if a transition with the same id already exists on a selected element, + * the existing transition is returned for that element. + * + * @param filter A CSS selector string. + */ + filter(filter: string): Transition<GElement, Datum, PElement, PDatum>; + /** + * For each selected element, selects only the elements that match the specified filter, and returns a transition on the resulting selection. + * + * The new transition has the same id, name and timing as this transition; however, if a transition with the same id already exists on a selected element, + * the existing transition is returned for that element. + * + * The generic refers to the type of element which will be selected after applying the filter, i.e. if the element types + * contained in a pre-filter selection are narrowed to a subset as part of the filtering. + * + * @param filter A CSS selector string. + */ + // tslint:disable-next-line:no-unnecessary-generics + filter<FilteredElement extends BaseType>(filter: string): Transition<FilteredElement, Datum, PElement, PDatum>; + /** + * For each selected element, selects only the elements that match the specified filter, and returns a transition on the resulting selection. + * + * The new transition has the same id, name and timing as this transition; however, if a transition with the same id already exists on a selected element, + * the existing transition is returned for that element. + * + * @param filter A filter function which is evaluated for each selected element, in order, being passed the current datum (d), + * the current index (i), and the current group (nodes), with this as the current DOM element (nodes[i]). The filter function returns a boolean indicating, + * whether the selected element matches. + */ + filter(filter: ValueFn<GElement, Datum, boolean>): Transition<GElement, Datum, PElement, PDatum>; + /** + * For each selected element, selects only the elements that match the specified filter, and returns a transition on the resulting selection. + * + * The new transition has the same id, name and timing as this transition; however, if a transition with the same id already exists on a selected element, + * the existing transition is returned for that element. + * + * The generic refers to the type of element which will be selected after applying the filter, i.e. if the element types + * contained in a pre-filter selection are narrowed to a subset as part of the filtering. + * + * @param filter A filter function which is evaluated for each selected element, in order, being passed the current datum (d), + * the current index (i), and the current group (nodes), with this as the current DOM element (nodes[i]). The filter function returns a boolean indicating, + * whether the selected element matches. + */ + // tslint:disable-next-line:no-unnecessary-generics + filter<FilteredElement extends BaseType>(filter: ValueFn<GElement, Datum, boolean>): Transition<FilteredElement, Datum, PElement, PDatum>; + + // Event Handling ------------------- + + /** + * Return the currently-assigned listener for the specified event typename on the first (non-null) selected element, if any. + * If multiple typenames are specified, the first matching listener is returned. + * + * @param typenames The typenames is one of the following string event types: start (when the transition starts), end (when the transition ends), + * interrupt (when the transition is interrupted), cancel(when the transition is cancelled). + * Note that these are not native DOM events. The type may be optionally followed by a period (.) and a name; + * the optional name allows multiple callbacks to be registered to receive events of the same type, such as "start.foo"" and "start.bar". + * To specify multiple typenames, separate typenames with spaces, such as "interrupt end"" or "start.foo start.bar". + */ + on(typenames: string): ValueFn<GElement, Datum, void> | undefined; + /** + * Remove all listeners for a given name. + * + * @param typenames Name of the event type for which the listener should be removed. To remove all listeners for a given name use ".foo" + * as the typename, where foo is the name; to remove all listeners with no name, specify "." as the typename. + * @param listener Use null to remove listeners. + */ + on(typenames: string, listener: null): this; + /** + * Add a listener to each selected element for the specified event typenames. + * + * When a specified transition event is dispatched on a selected node, the specified listener will be invoked for each transitioning element. + * Listeners always see the latest datum for their element, but the index is a property of the selection and is fixed when the listener is assigned; + * to update the index, re-assign the listener. + * + * @param typenames The typenames is one of the following string event types: start (when the transition starts), end (when the transition ends), + * interrupt (when the transition is interrupted), cancel(when the transition is cancelled). + * Note that these are not native DOM events. The type may be optionally followed by a period (.) and a name; + * the optional name allows multiple callbacks to be registered to receive events of the same type, such as "start.foo"" and "start.bar". + * To specify multiple typenames, separate typenames with spaces, such as "interrupt end"" or "start.foo start.bar". + * @param listener A listener function which will be evaluated for each selected element, being passed the current datum (d), the current index (i), + * and the current group (nodes), with this as the current DOM element (nodes[i]). Listeners always see the latest datum for their element, + * but the index is a property of the selection and is fixed when the listener is assigned; to update the index, re-assign the listener. + */ + on(typenames: string, listener: ValueFn<GElement, Datum, void>): this; + + /** + * Returns a promise that resolves when every selected element finishes transitioning. If any element’s transition is cancelled or interrupted, the promise rejects. + */ + end(): Promise<void>; + + // Control Flow ---------------------- + + /** + * Invoke the specified function for each selected element, passing the current datum (d), + * the current index (i), and the current group (nodes), with this of the current DOM element (nodes[i]). + * This method can be used to invoke arbitrary code for each selected element, and is useful for creating a context to access parent and child data simultaneously. + * + * @param func A function which is invoked for each selected element, + * being passed the current datum (d), the current index (i), and the current group (nodes), with this of the current DOM element (nodes[i]). + */ + each(func: ValueFn<GElement, Datum, void>): this; + + /** + * Invoke the specified function exactly once, passing in this transition along with any optional arguments. + * Returns this transition. + * + * @param func A function which is passed this transition as the first argument along with any optional arguments. + * @param args List of optional arguments to be passed to the callback function. + */ + call(func: (transition: Transition<GElement, Datum, PElement, PDatum>, ...args: any[]) => any, ...args: any[]): this; + + /** + * Return true if this transition contains no (non-null) elements. + */ + empty(): boolean; + + /** + * Return the first (non-null) element in this transition. If the transition is empty, returns null. + */ + node(): GElement | null; + + /** + * Return an array of all (non-null) elements in this transition. + */ + nodes(): GElement[]; + + /** + * Returns the total number of elements in this transition. + */ + size(): number; + + // Transition Configuration ---------------------- + + /** + * Returns the current value of the delay for the first (non-null) element in the transition. + * This is generally useful only if you know that the transition contains exactly one element. + */ + delay(): number; + /** + * For each selected element, sets the transition delay to the specified value in milliseconds. + * If a delay is not specified, it defaults to zero. + * + * @param milliseconds Number of milliseconds for the delay. + */ + delay(milliseconds: number): this; + /** + * For each selected element, sets the transition delay to the value in milliseconds returned by the + * value function. + * + * @param milliseconds A value function which is evaluated for each selected element, being passed the current datum (d), + * the current index (i), and the current group (nodes), with this of the current DOM element (nodes[i]). The return value is a number + * specifying the delay in milliseconds. + */ + delay(milliseconds: ValueFn<GElement, Datum, number>): this; + + /** + * Returns the current value of the duration for the first (non-null) element in the transition. + * This is generally useful only if you know that the transition contains exactly one element. + */ + duration(): number; + /** + * For each selected element, sets the transition duration to the specified value in milliseconds. + * If a duration is not specified, it defaults to 250ms. + * + * @param duration Number of milliseconds for the duration. + */ + duration(milliseconds: number): this; + /** + * For each selected element, sets the transition duration to the value in milliseconds returned by the + * value function. + * + * @param milliseconds A value function which is evaluated for each selected element, being passed the current datum (d), + * the current index (i), and the current group (nodes), with this of the current DOM element (nodes[i]). The return value is a number + * specifying the duration in milliseconds. + */ + duration(milliseconds: ValueFn<GElement, Datum, number>): this; + + /** + * Returns the current easing function for the first (non-null) element in the transition. + * This is generally useful only if you know that the transition contains exactly one element. + */ + ease(): (normalizedTime: number) => number; + /** + * Specifies the transition easing function for all selected elements. The value must be specified as a function. + * The easing function is invoked for each frame of the animation, being passed the normalized time t in the range [0, 1]; + * it must then return the eased time tʹ which is typically also in the range [0, 1]. + * A good easing function should return 0 if t = 0 and 1 if t = 1. If an easing function is not specified, + * it defaults to d3.easeCubic. + * + * @param easingFn An easing function which is passed the normalized time t in the range [0, 1]; + * it must then return the eased time tʹ which is typically also in the range [0, 1]. + * A good easing function should return 0 if t = 0 and 1 if t = 1. + */ + ease(easingFn: (normalizedTime: number) => number): this; + + /** + * Specifies a factory for the transition easing function. + * + * @param factory The factory must be a function. + * It is invoked for each node of the selection, being passed the current datum (d), the current index (i), and the current group (nodes), with this as the current DOM element. + * It must return an easing function. + */ + easeVarying(factory: ValueFn<GElement, Datum, (normalizedTime: number) => number>): this; +} + +/** + * Represents the union of the Selection and Transition types for any usages that operate on both. + * Typically used for functions which take in either a selection or transition and set or update attributes. + */ +export type SelectionOrTransition<GElement extends BaseType, Datum, PElement extends BaseType, PDatum> = Selection<GElement, Datum, PElement, PDatum> | Transition<GElement, Datum, PElement, PDatum>; + +/** + * Returns a new transition with the specified name. If a name is not specified, null is used. + * The new transition is only exclusive with other transitions of the same name. + * + * The generic "OldDatum" refers to the type of a previously-set datum of the selected HTML element in the Transition. + * + * @param name Name of the transition. + */ +// tslint:disable-next-line:no-unnecessary-generics +export function transition<OldDatum>(name?: string): Transition<HTMLElement, OldDatum, null, undefined>; + +/** + * Returns a new transition from an existing transition. + * + * When using a transition instance, the returned transition has the same id and name as the specified transition. + * + * The generic "OldDatum" refers to the type of a previously-set datum of the selected HTML element in the Transition. + * + * @param transition A transition instance. + */ +// tslint:disable-next-line:no-unnecessary-generics +export function transition<OldDatum>(transition: Transition<BaseType, any, BaseType, any>): Transition<HTMLElement, OldDatum, null, undefined>; diff --git a/chromium/third_party/node/node_modules/@types/d3/index.d.ts b/chromium/third_party/node/node_modules/@types/d3/index.d.ts new file mode 100644 index 00000000000..bba9cde4c24 --- /dev/null +++ b/chromium/third_party/node/node_modules/@types/d3/index.d.ts @@ -0,0 +1,27 @@ +// Type definitions for D3JS d3 standard bundle 5.16 +// Project: https://github.com/d3/d3, https://d3js.org +// 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> +// Nathan Bierema <https://github.com/Methuselah96> +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +// Last module patch version validated against: 5.16.0 + +// NOTE TO MAINTAINERS: Review D3 v4.x module dependencies (see v4 sub-folder) and update its path-mappings in tsconfig (v4 folder), +// if new MAJOR version of D3 v4 modules are released!!! + +export as namespace d3; + +/** + * Version number in format _Major.Minor.BugFix_, like 5.0.0. + */ +export const version: string; + +export * from 'd3-drag'; +export * from 'd3-force'; +export * from 'd3-scale-chromatic'; +export * from 'd3-selection'; +export * from 'd3-transition'; diff --git a/chromium/third_party/node/node_modules/@types/trusted-types/index.d.ts b/chromium/third_party/node/node_modules/@types/trusted-types/index.d.ts new file mode 100644 index 00000000000..a2d9fecf318 --- /dev/null +++ b/chromium/third_party/node/node_modules/@types/trusted-types/index.d.ts @@ -0,0 +1,75 @@ +// Type definitions for trusted-types 1.0 +// Project: https://github.com/WICG/trusted-types +// Definitions by: Jakub Vrana <https://github.com/vrana> +// Damien Engels <https://github.com/engelsdamien> +// Emanuel Tesar <https://github.com/siegrift> +// Bjarki <https://github.com/bjarkler> +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 3.1 + +type FnNames = keyof TrustedTypePolicyOptions; +type Args<Options extends TrustedTypePolicyOptions, K extends FnNames> = + Parameters<NonNullable<Options[K]>>; + +declare global { + class TrustedHTML { + private constructor(); // To prevent instantiting with 'new'. + private brand: true; // To prevent structural typing. + } + + class TrustedScript { + private constructor(); // To prevent instantiting with 'new'. + private brand: true; // To prevent structural typing. + } + + class TrustedScriptURL { + private constructor(); // To prevent instantiting with 'new'. + private brand: true; // To prevent structural typing. + } + + interface TrustedTypePolicyFactory { + createPolicy<Options extends TrustedTypePolicyOptions>( + policyName: string, + policyOptions?: Options, + ): Pick<TrustedTypePolicy<Options>, 'name'|Extract<keyof Options, FnNames>>; + isHTML(value: unknown): value is TrustedHTML; + isScript(value: unknown): value is TrustedScript; + isScriptURL(value: unknown): value is TrustedScriptURL; + readonly emptyHTML: TrustedHTML; + readonly emptyScript: TrustedScript; + getAttributeType(tagName: string, attribute: string, elementNs?: string, attrNs?: string): string | null; + getPropertyType(tagName: string, property: string, elementNs?: string): string | null; + readonly defaultPolicy: TrustedTypePolicy | null; + } + + interface TrustedTypePolicy<Options extends TrustedTypePolicyOptions = TrustedTypePolicyOptions> { + readonly name: string; + createHTML(...args: Args<Options, 'createHTML'>): TrustedHTML; + createScript(...args: Args<Options, 'createScript'>): TrustedScript; + createScriptURL(...args: Args<Options, 'createScriptURL'>): TrustedScriptURL; + } + + interface TrustedTypePolicyOptions { + createHTML?: (input: string, ...arguments: any[]) => string; + createScript?: (input: string, ...arguments: any[]) => string; + createScriptURL?: (input: string, ...arguments: any[]) => string; + } + + interface Window { + // `trustedTypes` is left intentionally optional to make sure that + // people handle the case when their code is running in a browser not + // supporting trustedTypes. + trustedTypes?: TrustedTypePolicyFactory; + TrustedHTML: TrustedHTML; + TrustedScript: TrustedScript; + TrustedScriptURL: TrustedScriptURL; + TrustedTypePolicyFactory: TrustedTypePolicyFactory; + TrustedTypePolicy: TrustedTypePolicy; + } +} + +// This is not available in global scope. It's only used for the export. This is +// necessary to be able to use these types from nodejs (for SSR). +declare const trustedTypes: TrustedTypePolicyFactory; + +export default trustedTypes; |