@maplibre/maplibre-gl-style-spec
Advanced tools
Comparing version 18.0.0 to 18.0.1-pre.1
@@ -962,2 +962,23 @@ // Generated by dts-bundle-generator v7.2.0 | ||
export declare function derefLayers(layers: any): any; | ||
export declare const operations: { | ||
setStyle: string; | ||
addLayer: string; | ||
removeLayer: string; | ||
setPaintProperty: string; | ||
setLayoutProperty: string; | ||
setFilter: string; | ||
addSource: string; | ||
removeSource: string; | ||
setGeoJSONSourceData: string; | ||
setLayerZoomRange: string; | ||
setLayerProperty: string; | ||
setCenter: string; | ||
setZoom: string; | ||
setBearing: string; | ||
setPitch: string; | ||
setSprite: string; | ||
setGlyphs: string; | ||
setTransition: string; | ||
setLight: string; | ||
}; | ||
declare function diffStyles(before: any, after: any): any[]; | ||
@@ -1006,3 +1027,3 @@ export declare class ValidationError { | ||
* Parses valid CSS color strings and returns a `Color` instance. | ||
* @param input | ||
* @param input A valid CSS color string. | ||
* @returns A `Color` instance, or `undefined` if the input is not a valid color string. | ||
@@ -1054,3 +1075,3 @@ */ | ||
}; | ||
declare class ResolvedImage { | ||
export declare class ResolvedImage { | ||
name: string; | ||
@@ -1062,3 +1083,3 @@ available: boolean; | ||
} | ||
declare class FormattedSection { | ||
export declare class FormattedSection { | ||
text: string; | ||
@@ -1071,3 +1092,3 @@ image: ResolvedImage | null; | ||
} | ||
declare class Formatted { | ||
export declare class Formatted { | ||
sections: Array<FormattedSection>; | ||
@@ -1150,5 +1171,9 @@ constructor(sections: Array<FormattedSection>); | ||
}; | ||
export declare const NullType: NullTypeT; | ||
export declare const FormattedType: FormattedTypeT; | ||
export declare function toString(type: Type): string; | ||
export type Value = null | string | boolean | number | Color | Collator | Formatted | Padding | ResolvedImage | ReadonlyArray<Value> | { | ||
readonly [x: string]: Value; | ||
}; | ||
export declare function typeOf(value: Value): Type; | ||
export interface ICanonicalTileID { | ||
@@ -1172,3 +1197,20 @@ z: number; | ||
} | ||
declare class EvaluationContext { | ||
export interface ILngLat { | ||
wrap(): {}; | ||
toArray(): {}; | ||
toString(): {}; | ||
distanceTo(lngLat: ILngLat): {}; | ||
convert(input: ILngLatLike): ILngLat; | ||
} | ||
export type ILngLatLike = ILngLat | { | ||
lng: number; | ||
lat: number; | ||
} | { | ||
lon: number; | ||
lat: number; | ||
} | [ | ||
number, | ||
number | ||
]; | ||
export declare class EvaluationContext { | ||
globals: GlobalProperties; | ||
@@ -1193,2 +1235,75 @@ feature: Feature; | ||
} | ||
declare class Scope { | ||
parent: Scope; | ||
bindings: { | ||
[_: string]: Expression; | ||
}; | ||
constructor(parent?: Scope, bindings?: Array<[ | ||
string, | ||
Expression | ||
]>); | ||
concat(bindings: Array<[ | ||
string, | ||
Expression | ||
]>): Scope; | ||
get(name: string): Expression; | ||
has(name: string): boolean; | ||
} | ||
declare class ParsingContext { | ||
registry: ExpressionRegistry; | ||
path: Array<number>; | ||
key: string; | ||
scope: Scope; | ||
errors: Array<ExpressionParsingError>; | ||
expectedType: Type; | ||
/** | ||
* Internal delegate to inConstant function to avoid circular dependency to CompoundExpression | ||
*/ | ||
private _isConstant; | ||
constructor(registry: ExpressionRegistry, isConstantFunc: (expression: Expression) => boolean, path?: Array<number>, expectedType?: Type | null, scope?: Scope, errors?: Array<ExpressionParsingError>); | ||
/** | ||
* @param expr the JSON expression to parse | ||
* @param index the optional argument index if this expression is an argument of a parent expression that's being parsed | ||
* @param options | ||
* @param options.omitTypeAnnotations set true to omit inferred type annotations. Caller beware: with this option set, the parsed expression's type will NOT satisfy `expectedType` if it would normally be wrapped in an inferred annotation. | ||
* @private | ||
*/ | ||
parse(expr: unknown, index?: number, expectedType?: Type | null, bindings?: Array<[ | ||
string, | ||
Expression | ||
]>, options?: { | ||
typeAnnotation?: "assert" | "coerce" | "omit"; | ||
}): Expression; | ||
_parse(expr: unknown, options: { | ||
typeAnnotation?: "assert" | "coerce" | "omit"; | ||
}): Expression; | ||
/** | ||
* Returns a copy of this context suitable for parsing the subexpression at | ||
* index `index`, optionally appending to 'let' binding map. | ||
* | ||
* Note that `errors` property, intended for collecting errors while | ||
* parsing, is copied by reference rather than cloned. | ||
* @private | ||
*/ | ||
concat(index: number, expectedType?: Type | null, bindings?: Array<[ | ||
string, | ||
Expression | ||
]>): ParsingContext; | ||
/** | ||
* Push a parsing (or type checking) error into the `this.errors` | ||
* @param error The message | ||
* @param keys Optionally specify the source of the error at a child | ||
* of the current expression at `this.key`. | ||
* @private | ||
*/ | ||
error(error: string, ...keys: Array<number>): void; | ||
/** | ||
* Returns null if `t` is a subtype of `expected`; otherwise returns an | ||
* error message and also pushes it to `this.errors`. | ||
* @param expected The expected type | ||
* @param t The actual type | ||
* @returns null if `t` is a subtype of `expected`; otherwise returns an error message | ||
*/ | ||
checkSubtype(expected: Type, t: Type): string; | ||
} | ||
/** | ||
@@ -1207,2 +1322,11 @@ * Expression | ||
} | ||
export type ExpressionParser = (args: ReadonlyArray<unknown>, context: ParsingContext) => Expression; | ||
export type ExpressionRegistration = { | ||
new (...args: any): Expression; | ||
} & { | ||
readonly parse: ExpressionParser; | ||
}; | ||
export type ExpressionRegistry = { | ||
[_: string]: ExpressionRegistration; | ||
}; | ||
/** | ||
@@ -1221,2 +1345,6 @@ * A type used for returning and propagating errors. The first element of the union | ||
}; | ||
export type Stops = Array<[ | ||
number, | ||
Expression | ||
]>; | ||
export type InterpolationType = { | ||
@@ -1236,2 +1364,16 @@ name: "linear"; | ||
}; | ||
export declare class Interpolate implements Expression { | ||
type: Type; | ||
operator: "interpolate" | "interpolate-hcl" | "interpolate-lab"; | ||
interpolation: InterpolationType; | ||
input: Expression; | ||
labels: Array<number>; | ||
outputs: Array<Expression>; | ||
constructor(type: Type, operator: "interpolate" | "interpolate-hcl" | "interpolate-lab", interpolation: InterpolationType, input: Expression, stops: Stops); | ||
static interpolationFactor(interpolation: InterpolationType, input: number, lower: number, upper: number): number; | ||
static parse(args: ReadonlyArray<unknown>, context: ParsingContext): Expression; | ||
evaluate(ctx: EvaluationContext): any; | ||
eachChild(fn: (_: Expression) => void): void; | ||
outputDefined(): boolean; | ||
} | ||
export type Feature = { | ||
@@ -1262,3 +1404,3 @@ readonly type: 1 | 2 | 3 | "Unknown" | "Point" | "MultiPoint" | "LineString" | "MultiLineString" | "Polygon" | "MultiPolygon"; | ||
}>; | ||
declare class StyleExpression { | ||
export declare class StyleExpression { | ||
expression: Expression; | ||
@@ -1277,5 +1419,14 @@ _evaluator: EvaluationContext; | ||
} | ||
declare function isExpression(expression: unknown): boolean; | ||
declare function createExpression(expression: unknown, propertySpec?: StylePropertySpecification | null): Result<StyleExpression, Array<ExpressionParsingError>>; | ||
declare class ZoomConstantExpression<Kind extends EvaluationKind> { | ||
export declare function isExpression(expression: unknown): boolean; | ||
/** | ||
* Parse and typecheck the given style spec JSON expression. If | ||
* options.defaultValue is provided, then the resulting StyleExpression's | ||
* `evaluate()` method will handle errors by logging a warning (once per | ||
* message) and returning the default value. Otherwise, it will throw | ||
* evaluation errors. | ||
* | ||
* @private | ||
*/ | ||
export declare function createExpression(expression: unknown, propertySpec?: StylePropertySpecification | null): Result<StyleExpression, Array<ExpressionParsingError>>; | ||
export declare class ZoomConstantExpression<Kind extends EvaluationKind> { | ||
kind: Kind; | ||
@@ -1288,3 +1439,3 @@ isStateDependent: boolean; | ||
} | ||
declare class ZoomDependentExpression<Kind extends EvaluationKind> { | ||
export declare class ZoomDependentExpression<Kind extends EvaluationKind> { | ||
kind: Kind; | ||
@@ -1325,4 +1476,4 @@ zoomStops: Array<number>; | ||
export type StylePropertyExpression = ConstantExpression | SourceExpression | CameraExpression | CompositeExpression; | ||
declare function createPropertyExpression(expressionInput: unknown, propertySpec: StylePropertySpecification): Result<StylePropertyExpression, Array<ExpressionParsingError>>; | ||
declare class StylePropertyFunction<T> { | ||
export declare function createPropertyExpression(expressionInput: unknown, propertySpec: StylePropertySpecification): Result<StylePropertyExpression, Array<ExpressionParsingError>>; | ||
export declare class StylePropertyFunction<T> { | ||
_parameters: PropertyValueSpecification<T>; | ||
@@ -1344,3 +1495,3 @@ _specification: StylePropertySpecification; | ||
} | ||
declare function normalizePropertyExpression<T>(value: PropertyValueSpecification<T>, specification: StylePropertySpecification): StylePropertyExpression; | ||
export declare function normalizePropertyExpression<T>(value: PropertyValueSpecification<T>, specification: StylePropertySpecification): StylePropertyExpression; | ||
export type FilterExpression = (globalProperties: GlobalProperties, feature: Feature, canonical?: ICanonicalTileID) => boolean; | ||
@@ -1357,4 +1508,4 @@ export type FeatureFilter = { | ||
export function convertFilter(filter: FilterSpecification, expectedTypes?: ExpectedTypes): ExpressionFilterSpecification; | ||
declare function isFunction(value: any): boolean; | ||
declare function createFunction(parameters: any, propertySpec: any): { | ||
export declare function isFunction(value: any): boolean; | ||
export declare function createFunction(parameters: any, propertySpec: any): { | ||
kind: string; | ||
@@ -1387,3 +1538,3 @@ interpolationType: { | ||
}; | ||
declare function convertFunction(parameters: any, propertySpec: StylePropertySpecification): any; | ||
export declare function convertFunction(parameters: any, propertySpec: StylePropertySpecification): any; | ||
declare function eachSource(style: StyleSpecification, callback: (_: SourceSpecification) => void): void; | ||
@@ -1407,2 +1558,127 @@ declare function eachLayer(style: StyleSpecification, callback: (_: LayerSpecification) => void): void; | ||
declare function validateStyle(style: StyleSpecification | string | Buffer, styleSpec?: any): Array<ValidationError>; | ||
export declare function supportsPropertyExpression(spec: StylePropertySpecification): boolean; | ||
export declare const interpolateFactory: (interpolationType: "number" | "color" | "array" | "padding") => typeof number | typeof color | typeof array | typeof padding; | ||
declare function number(a: number, b: number, t: number): number; | ||
declare function color(from: Color, to: Color, t: number): Color; | ||
declare function array(from: Array<number>, to: Array<number>, t: number): Array<number>; | ||
declare function padding(from: Padding, to: Padding, t: number): Padding; | ||
export declare const interpolates: { | ||
number: typeof number; | ||
color: typeof color; | ||
array: typeof array; | ||
padding: typeof padding; | ||
}; | ||
export declare const expressions: ExpressionRegistry; | ||
/** | ||
* Given an array of layers, return an array of arrays of layers where all | ||
* layers in each group have identical layout-affecting properties. These | ||
* are the properties that were formerly used by explicit `ref` mechanism | ||
* for layers: 'type', 'source', 'source-layer', 'minzoom', 'maxzoom', | ||
* 'filter', and 'layout'. | ||
* | ||
* The input is not modified. The output layers are references to the | ||
* input layers. | ||
* | ||
* @private | ||
* @param {Array<Layer>} layers | ||
* @param {Object} [cachedKeys] - an object to keep already calculated keys. | ||
* @returns {Array<Array<Layer>>} | ||
*/ | ||
export declare function groupByLayout(layers: any, cachedKeys: any): any[]; | ||
export function emptyStyle(): StyleSpecification; | ||
/** | ||
* Validate a MapLibre GL style against the style specification. This entrypoint, | ||
* `maplibre-gl-style-spec/lib/validate_style.min`, is designed to produce as | ||
* small a browserify bundle as possible by omitting unnecessary functionality | ||
* and legacy style specifications. | ||
* | ||
* @private | ||
* @param {Object} style The style to be validated. | ||
* @param {Object} [styleSpec] The style specification to validate against. | ||
* If omitted, the latest style spec is used. | ||
* @returns {Array<ValidationError>} | ||
* @example | ||
* var validate = require('maplibre-gl-style-spec/lib/validate_style.min'); | ||
* var errors = validate(style); | ||
*/ | ||
export declare function validateStyleMin(style: StyleSpecification, styleSpec?: any): any[]; | ||
export declare namespace validateStyleMin { | ||
var source: (...args: any[]) => any[]; | ||
var sprite: (...args: any[]) => any[]; | ||
var glyphs: (...args: any[]) => any[]; | ||
var light: (...args: any[]) => any[]; | ||
var terrain: (...args: any[]) => any[]; | ||
var layer: (...args: any[]) => any[]; | ||
var filter: (...args: any[]) => any[]; | ||
var paintProperty: (...args: any[]) => any[]; | ||
var layoutProperty: (...args: any[]) => any[]; | ||
} | ||
export declare class Step implements Expression { | ||
type: Type; | ||
input: Expression; | ||
labels: Array<number>; | ||
outputs: Array<Expression>; | ||
constructor(type: Type, input: Expression, stops: Stops); | ||
static parse(args: ReadonlyArray<unknown>, context: ParsingContext): Expression; | ||
evaluate(ctx: EvaluationContext): any; | ||
eachChild(fn: (_: Expression) => void): void; | ||
outputDefined(): boolean; | ||
} | ||
export type FormattedSectionExpression = { | ||
content: Expression; | ||
scale: Expression | null; | ||
font: Expression | null; | ||
textColor: Expression | null; | ||
}; | ||
export declare class FormatExpression implements Expression { | ||
type: Type; | ||
sections: Array<FormattedSectionExpression>; | ||
constructor(sections: Array<FormattedSectionExpression>); | ||
static parse(args: ReadonlyArray<unknown>, context: ParsingContext): Expression; | ||
evaluate(ctx: EvaluationContext): Formatted; | ||
eachChild(fn: (_: Expression) => void): void; | ||
outputDefined(): boolean; | ||
} | ||
export declare class Literal implements Expression { | ||
type: Type; | ||
value: Value; | ||
constructor(type: Type, value: Value); | ||
static parse(args: ReadonlyArray<unknown>, context: ParsingContext): Expression; | ||
evaluate(): Value; | ||
eachChild(): void; | ||
outputDefined(): boolean; | ||
} | ||
export type Varargs = { | ||
type: Type; | ||
}; | ||
export type Signature = Array<Type> | Varargs; | ||
export type Evaluate = (b: EvaluationContext, a: Array<Expression>) => Value; | ||
export type Definition = [ | ||
Type, | ||
Signature, | ||
Evaluate | ||
] | { | ||
type: Type; | ||
overloads: Array<[ | ||
Signature, | ||
Evaluate | ||
]>; | ||
}; | ||
export declare class CompoundExpression implements Expression { | ||
name: string; | ||
type: Type; | ||
_evaluate: Evaluate; | ||
args: Array<Expression>; | ||
static definitions: { | ||
[_: string]: Definition; | ||
}; | ||
constructor(name: string, type: Type, evaluate: Evaluate, args: Array<Expression>); | ||
evaluate(ctx: EvaluationContext): Value; | ||
eachChild(fn: (_: Expression) => void): void; | ||
outputDefined(): boolean; | ||
static parse(args: ReadonlyArray<unknown>, context: ParsingContext): Expression; | ||
static register(registry: ExpressionRegistry, definitions: { | ||
[_: string]: Definition; | ||
}): void; | ||
} | ||
export type ExpressionType = "data-driven" | "cross-faded" | "cross-faded-data-driven" | "color-ramp" | "data-constant" | "constant"; | ||
@@ -1475,10 +1751,10 @@ export type ExpressionParameters = Array<"zoom" | "feature" | "feature-state" | "heatmap-density" | "line-progress">; | ||
StyleExpression: typeof StyleExpression; | ||
StylePropertyFunction: typeof StylePropertyFunction; | ||
ZoomConstantExpression: typeof ZoomConstantExpression; | ||
ZoomDependentExpression: typeof ZoomDependentExpression; | ||
createExpression: typeof createExpression; | ||
createPropertyExpression: typeof createPropertyExpression; | ||
isExpression: typeof isExpression; | ||
isExpressionFilter: typeof isExpressionFilter; | ||
createExpression: typeof createExpression; | ||
createPropertyExpression: typeof createPropertyExpression; | ||
normalizePropertyExpression: typeof normalizePropertyExpression; | ||
ZoomConstantExpression: typeof ZoomConstantExpression; | ||
ZoomDependentExpression: typeof ZoomDependentExpression; | ||
StylePropertyFunction: typeof StylePropertyFunction; | ||
}; | ||
@@ -1491,5 +1767,5 @@ declare const styleFunction: { | ||
export declare const visit: { | ||
eachSource: typeof eachSource; | ||
eachLayer: typeof eachLayer; | ||
eachProperty: typeof eachProperty; | ||
eachSource: typeof eachSource; | ||
}; | ||
@@ -1496,0 +1772,0 @@ |
{ | ||
"name": "@maplibre/maplibre-gl-style-spec", | ||
"description": "a specification for maplibre gl styles", | ||
"version": "18.0.0", | ||
"version": "18.0.1-pre.1", | ||
"author": "MapLibre", | ||
@@ -6,0 +6,0 @@ "keywords": [ |
@@ -195,4 +195,5 @@ import Scope from './scope'; | ||
* error message and also pushes it to `this.errors`. | ||
* @param expected | ||
* @param t | ||
* @param expected The expected type | ||
* @param t The actual type | ||
* @returns null if `t` is a subtype of `expected`; otherwise returns an error message | ||
*/ | ||
@@ -199,0 +200,0 @@ checkSubtype(expected: Type, t: Type): string { |
@@ -12,3 +12,4 @@ import {eachLayer, eachProperty} from '../visit'; | ||
* expression equivalents. | ||
* @param style | ||
* @param style The style object to migrate. | ||
* @returns The migrated style object. | ||
*/ | ||
@@ -15,0 +16,0 @@ export default function expressions(style: StyleSpecification) { |
@@ -72,6 +72,6 @@ type ExpressionType = 'data-driven' | 'cross-faded' | 'cross-faded-data-driven' | 'color-ramp' | 'data-constant' | 'constant'; | ||
import derefLayers from './deref'; | ||
import diff from './diff'; | ||
import diff, {operations} from './diff'; | ||
import ValidationError from './error/validation_error'; | ||
import ParsingError from './error/parsing_error'; | ||
import {StyleExpression, isExpression, createExpression, createPropertyExpression, normalizePropertyExpression, ZoomConstantExpression, ZoomDependentExpression, StylePropertyFunction} from './expression'; | ||
import {FeatureState, StyleExpression, isExpression, createExpression, createPropertyExpression, normalizePropertyExpression, ZoomConstantExpression, ZoomDependentExpression, StylePropertyFunction, Feature, GlobalProperties, SourceExpression, CompositeExpression, StylePropertyExpression} from './expression'; | ||
import featureFilter, {isExpressionFilter} from './feature_filter'; | ||
@@ -82,18 +82,37 @@ | ||
import Padding from './util/padding'; | ||
import Formatted, {FormattedSection} from './expression/types/formatted'; | ||
import {createFunction, isFunction} from './function'; | ||
import convertFunction from './function/convert'; | ||
import {eachSource, eachLayer, eachProperty} from './visit'; | ||
import ResolvedImage from './expression/types/resolved_image'; | ||
import validate from './validate_style'; | ||
import {supportsPropertyExpression} from './util/properties'; | ||
import {IMercatorCoordinate, ICanonicalTileID, ILngLat, ILngLatLike} from './tiles_and_coordinates'; | ||
import EvaluationContext from './expression/evaluation_context'; | ||
import {FormattedType, NullType, Type, toString} from './expression/types'; | ||
import interpolates, {interpolateFactory} from './util/interpolate'; | ||
import expressions from './expression/definitions'; | ||
import Interpolate from './expression/definitions/interpolate'; | ||
import type {InterpolationType} from './expression/definitions/interpolate'; | ||
import groupByLayout from './group_by_layout'; | ||
import emptyStyle from './empty'; | ||
import validateStyleMin from './validate_style.min'; | ||
import Step from './expression/definitions/step'; | ||
import {typeOf} from './expression/values'; | ||
import FormatExpression from './expression/definitions/format'; | ||
import Literal from './expression/definitions/literal'; | ||
import CompoundExpression from './expression/compound_expression'; | ||
const expression = { | ||
StyleExpression, | ||
StylePropertyFunction, | ||
ZoomConstantExpression, | ||
ZoomDependentExpression, | ||
createExpression, | ||
createPropertyExpression, | ||
isExpression, | ||
isExpressionFilter, | ||
createExpression, | ||
createPropertyExpression, | ||
normalizePropertyExpression, | ||
ZoomConstantExpression, | ||
ZoomDependentExpression, | ||
StylePropertyFunction | ||
}; | ||
@@ -107,21 +126,67 @@ | ||
const visit = {eachSource, eachLayer, eachProperty}; | ||
const visit = {eachLayer, eachProperty, eachSource}; | ||
export { | ||
v8, | ||
Interpolate, | ||
InterpolationType, | ||
ValidationError, | ||
ParsingError, | ||
FeatureState, | ||
Color, | ||
Step, | ||
CompoundExpression, | ||
Padding, | ||
Formatted, | ||
ResolvedImage, | ||
Feature, | ||
EvaluationContext, | ||
GlobalProperties, | ||
SourceExpression, | ||
CompositeExpression, | ||
FormattedSection, | ||
IMercatorCoordinate, | ||
ICanonicalTileID, | ||
ILngLat, | ||
ILngLatLike, | ||
StyleExpression, | ||
ZoomConstantExpression, | ||
Literal, | ||
Type, | ||
StylePropertyFunction, | ||
StylePropertyExpression, | ||
ZoomDependentExpression, | ||
FormatExpression, | ||
latest, | ||
interpolateFactory, | ||
interpolates, | ||
validate, | ||
validateStyleMin, | ||
groupByLayout, | ||
emptyStyle, | ||
format, | ||
migrate, | ||
derefLayers, | ||
normalizePropertyExpression, | ||
isExpression, | ||
diff, | ||
ValidationError, | ||
ParsingError, | ||
expression, | ||
supportsPropertyExpression, | ||
convertFunction, | ||
createExpression, | ||
isFunction, createFunction, | ||
createPropertyExpression, | ||
convertFilter, | ||
featureFilter, | ||
convertFilter, | ||
Color, | ||
Padding, | ||
typeOf, | ||
toString, | ||
v8, | ||
NullType, | ||
styleFunction as function, | ||
validate, | ||
visit | ||
visit, | ||
operations, | ||
expressions, | ||
expression, | ||
FormattedType, | ||
}; |
@@ -34,3 +34,3 @@ import {parseCSSColor} from 'csscolorparser'; | ||
* Parses valid CSS color strings and returns a `Color` instance. | ||
* @param input | ||
* @param input A valid CSS color string. | ||
* @returns A `Color` instance, or `undefined` if the input is not a valid color string. | ||
@@ -37,0 +37,0 @@ */ |
import Color from './color'; | ||
import Padding from './padding'; | ||
export const interpolateFactory = (interpolationType: 'number'|'color'|'array'|'padding') => { | ||
switch (interpolationType) { | ||
case 'number': return number; | ||
case 'color': return color; | ||
case 'array': return array; | ||
case 'padding': return padding; | ||
} | ||
}; | ||
export function number(a: number, b: number, t: number) { | ||
@@ -33,1 +42,10 @@ return (a * (1 - t)) + (b * t); | ||
} | ||
const interpolates = { | ||
number, | ||
color, | ||
array, | ||
padding | ||
}; | ||
export default interpolates; |
@@ -54,4 +54,5 @@ import Scope from './scope'; | ||
* error message and also pushes it to `this.errors`. | ||
* @param expected | ||
* @param t | ||
* @param expected The expected type | ||
* @param t The actual type | ||
* @returns null if `t` is a subtype of `expected`; otherwise returns an error message | ||
*/ | ||
@@ -58,0 +59,0 @@ checkSubtype(expected: Type, t: Type): string; |
@@ -143,4 +143,5 @@ import Scope from './scope'; | ||
* error message and also pushes it to `this.errors`. | ||
* @param expected | ||
* @param t | ||
* @param expected The expected type | ||
* @param t The actual type | ||
* @returns null if `t` is a subtype of `expected`; otherwise returns an error message | ||
*/ | ||
@@ -147,0 +148,0 @@ checkSubtype(expected, t) { |
@@ -6,4 +6,5 @@ import type { StyleSpecification } from '../types.g'; | ||
* expression equivalents. | ||
* @param style | ||
* @param style The style object to migrate. | ||
* @returns The migrated style object. | ||
*/ | ||
export default function expressions(style: StyleSpecification): StyleSpecification; |
@@ -9,3 +9,4 @@ import { eachLayer, eachProperty } from '../visit'; | ||
* expression equivalents. | ||
* @param style | ||
* @param style The style object to migrate. | ||
* @returns The migrated style object. | ||
*/ | ||
@@ -12,0 +13,0 @@ export default function expressions(style) { |
@@ -70,6 +70,6 @@ type ExpressionType = 'data-driven' | 'cross-faded' | 'cross-faded-data-driven' | 'color-ramp' | 'data-constant' | 'constant'; | ||
import derefLayers from './deref'; | ||
import diff from './diff'; | ||
import diff, { operations } from './diff'; | ||
import ValidationError from './error/validation_error'; | ||
import ParsingError from './error/parsing_error'; | ||
import { StyleExpression, isExpression, createExpression, createPropertyExpression, normalizePropertyExpression, ZoomConstantExpression, ZoomDependentExpression, StylePropertyFunction } from './expression'; | ||
import { FeatureState, StyleExpression, isExpression, createExpression, createPropertyExpression, normalizePropertyExpression, ZoomConstantExpression, ZoomDependentExpression, StylePropertyFunction, Feature, GlobalProperties, SourceExpression, CompositeExpression, StylePropertyExpression } from './expression'; | ||
import featureFilter, { isExpressionFilter } from './feature_filter'; | ||
@@ -79,16 +79,34 @@ import convertFilter from './feature_filter/convert'; | ||
import Padding from './util/padding'; | ||
import Formatted, { FormattedSection } from './expression/types/formatted'; | ||
import { createFunction, isFunction } from './function'; | ||
import convertFunction from './function/convert'; | ||
import { eachSource, eachLayer, eachProperty } from './visit'; | ||
import ResolvedImage from './expression/types/resolved_image'; | ||
import validate from './validate_style'; | ||
import { supportsPropertyExpression } from './util/properties'; | ||
import { IMercatorCoordinate, ICanonicalTileID, ILngLat, ILngLatLike } from './tiles_and_coordinates'; | ||
import EvaluationContext from './expression/evaluation_context'; | ||
import { FormattedType, NullType, Type, toString } from './expression/types'; | ||
import interpolates, { interpolateFactory } from './util/interpolate'; | ||
import expressions from './expression/definitions'; | ||
import Interpolate from './expression/definitions/interpolate'; | ||
import type { InterpolationType } from './expression/definitions/interpolate'; | ||
import groupByLayout from './group_by_layout'; | ||
import emptyStyle from './empty'; | ||
import validateStyleMin from './validate_style.min'; | ||
import Step from './expression/definitions/step'; | ||
import { typeOf } from './expression/values'; | ||
import FormatExpression from './expression/definitions/format'; | ||
import Literal from './expression/definitions/literal'; | ||
import CompoundExpression from './expression/compound_expression'; | ||
declare const expression: { | ||
StyleExpression: typeof StyleExpression; | ||
StylePropertyFunction: typeof StylePropertyFunction; | ||
ZoomConstantExpression: typeof ZoomConstantExpression; | ||
ZoomDependentExpression: typeof ZoomDependentExpression; | ||
createExpression: typeof createExpression; | ||
createPropertyExpression: typeof createPropertyExpression; | ||
isExpression: typeof isExpression; | ||
isExpressionFilter: typeof isExpressionFilter; | ||
createExpression: typeof createExpression; | ||
createPropertyExpression: typeof createPropertyExpression; | ||
normalizePropertyExpression: typeof normalizePropertyExpression; | ||
ZoomConstantExpression: typeof ZoomConstantExpression; | ||
ZoomDependentExpression: typeof ZoomDependentExpression; | ||
StylePropertyFunction: typeof StylePropertyFunction; | ||
}; | ||
@@ -101,6 +119,6 @@ declare const styleFunction: { | ||
declare const visit: { | ||
eachSource: typeof eachSource; | ||
eachLayer: typeof eachLayer; | ||
eachProperty: typeof eachProperty; | ||
eachSource: typeof eachSource; | ||
}; | ||
export { v8, latest, format, migrate, derefLayers, diff, ValidationError, ParsingError, expression, featureFilter, convertFilter, Color, Padding, styleFunction as function, validate, visit }; | ||
export { Interpolate, InterpolationType, ValidationError, ParsingError, FeatureState, Color, Step, CompoundExpression, Padding, Formatted, ResolvedImage, Feature, EvaluationContext, GlobalProperties, SourceExpression, CompositeExpression, FormattedSection, IMercatorCoordinate, ICanonicalTileID, ILngLat, ILngLatLike, StyleExpression, ZoomConstantExpression, Literal, Type, StylePropertyFunction, StylePropertyExpression, ZoomDependentExpression, FormatExpression, latest, interpolateFactory, interpolates, validate, validateStyleMin, groupByLayout, emptyStyle, format, migrate, derefLayers, normalizePropertyExpression, isExpression, diff, supportsPropertyExpression, convertFunction, createExpression, isFunction, createFunction, createPropertyExpression, convertFilter, featureFilter, typeOf, toString, v8, NullType, styleFunction as function, visit, operations, expressions, expression, FormattedType, }; |
@@ -7,3 +7,3 @@ import v8Spec from './reference/v8.json' assert { type: 'json' }; | ||
import derefLayers from './deref'; | ||
import diff from './diff'; | ||
import diff, { operations } from './diff'; | ||
import ValidationError from './error/validation_error'; | ||
@@ -16,16 +16,32 @@ import ParsingError from './error/parsing_error'; | ||
import Padding from './util/padding'; | ||
import Formatted, { FormattedSection } from './expression/types/formatted'; | ||
import { createFunction, isFunction } from './function'; | ||
import convertFunction from './function/convert'; | ||
import { eachSource, eachLayer, eachProperty } from './visit'; | ||
import ResolvedImage from './expression/types/resolved_image'; | ||
import validate from './validate_style'; | ||
import { supportsPropertyExpression } from './util/properties'; | ||
import EvaluationContext from './expression/evaluation_context'; | ||
import { FormattedType, NullType, toString } from './expression/types'; | ||
import interpolates, { interpolateFactory } from './util/interpolate'; | ||
import expressions from './expression/definitions'; | ||
import Interpolate from './expression/definitions/interpolate'; | ||
import groupByLayout from './group_by_layout'; | ||
import emptyStyle from './empty'; | ||
import validateStyleMin from './validate_style.min'; | ||
import Step from './expression/definitions/step'; | ||
import { typeOf } from './expression/values'; | ||
import FormatExpression from './expression/definitions/format'; | ||
import Literal from './expression/definitions/literal'; | ||
import CompoundExpression from './expression/compound_expression'; | ||
const expression = { | ||
StyleExpression, | ||
StylePropertyFunction, | ||
ZoomConstantExpression, | ||
ZoomDependentExpression, | ||
createExpression, | ||
createPropertyExpression, | ||
isExpression, | ||
isExpressionFilter, | ||
createExpression, | ||
createPropertyExpression, | ||
normalizePropertyExpression, | ||
ZoomConstantExpression, | ||
ZoomDependentExpression, | ||
StylePropertyFunction | ||
}; | ||
@@ -37,4 +53,4 @@ const styleFunction = { | ||
}; | ||
const visit = { eachSource, eachLayer, eachProperty }; | ||
export { v8, latest, format, migrate, derefLayers, diff, ValidationError, ParsingError, expression, featureFilter, convertFilter, Color, Padding, styleFunction as function, validate, visit }; | ||
const visit = { eachLayer, eachProperty, eachSource }; | ||
export { Interpolate, ValidationError, ParsingError, Color, Step, CompoundExpression, Padding, Formatted, ResolvedImage, EvaluationContext, FormattedSection, StyleExpression, ZoomConstantExpression, Literal, StylePropertyFunction, ZoomDependentExpression, FormatExpression, latest, interpolateFactory, interpolates, validate, validateStyleMin, groupByLayout, emptyStyle, format, migrate, derefLayers, normalizePropertyExpression, isExpression, diff, supportsPropertyExpression, convertFunction, createExpression, isFunction, createFunction, createPropertyExpression, convertFilter, featureFilter, typeOf, toString, v8, NullType, styleFunction as function, visit, operations, expressions, expression, FormattedType, }; | ||
//# sourceMappingURL=style-spec.js.map |
@@ -24,3 +24,3 @@ /** | ||
* Parses valid CSS color strings and returns a `Color` instance. | ||
* @param input | ||
* @param input A valid CSS color string. | ||
* @returns A `Color` instance, or `undefined` if the input is not a valid color string. | ||
@@ -27,0 +27,0 @@ */ |
@@ -22,3 +22,3 @@ import { parseCSSColor } from 'csscolorparser'; | ||
* Parses valid CSS color strings and returns a `Color` instance. | ||
* @param input | ||
* @param input A valid CSS color string. | ||
* @returns A `Color` instance, or `undefined` if the input is not a valid color string. | ||
@@ -25,0 +25,0 @@ */ |
import Color from './color'; | ||
import Padding from './padding'; | ||
export declare const interpolateFactory: (interpolationType: 'number' | 'color' | 'array' | 'padding') => typeof number | typeof color | typeof array | typeof padding; | ||
export declare function number(a: number, b: number, t: number): number; | ||
@@ -7,1 +8,8 @@ export declare function color(from: Color, to: Color, t: number): Color; | ||
export declare function padding(from: Padding, to: Padding, t: number): Padding; | ||
declare const interpolates: { | ||
number: typeof number; | ||
color: typeof color; | ||
array: typeof array; | ||
padding: typeof padding; | ||
}; | ||
export default interpolates; |
import Color from './color'; | ||
import Padding from './padding'; | ||
export const interpolateFactory = (interpolationType) => { | ||
switch (interpolationType) { | ||
case 'number': return number; | ||
case 'color': return color; | ||
case 'array': return array; | ||
case 'padding': return padding; | ||
} | ||
}; | ||
export function number(a, b, t) { | ||
@@ -24,2 +32,9 @@ return (a * (1 - t)) + (b * t); | ||
} | ||
const interpolates = { | ||
number, | ||
color, | ||
array, | ||
padding | ||
}; | ||
export default interpolates; | ||
//# sourceMappingURL=interpolate.js.map |
@@ -6,3 +6,3 @@ { | ||
"checkJs": true, | ||
"isolatedModules": true, | ||
"isolatedModules": false, | ||
"noEmit": false, | ||
@@ -9,0 +9,0 @@ "declaration": true, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
3245724
609
67252
2
6