Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Socket
Sign inDemoInstall

@mapbox/mapbox-gl-style-spec

Package Overview
Dependencies
Maintainers
28
Versions
101
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mapbox/mapbox-gl-style-spec - npm Package Compare versions

Comparing version 14.5.0-beta.1 to 14.5.0

58

dist/index.d.ts

@@ -83,2 +83,21 @@ import Point from '@mapbox/point-geometry';

};
type PropertyFunctionStop<T> = [
number,
T
];
type ZoomAndPropertyFunctionStop<T> = [
{
zoom: number;
value: string | number | boolean;
},
T
];
type FunctionSpecification<T> = {
stops: Array<PropertyFunctionStop<T> | ZoomAndPropertyFunctionStop<T>>;
base?: number;
property?: string;
type?: "identity" | "exponential" | "interval" | "categorical";
colorSpace?: "rgb" | "lab" | "hcl";
default?: T;
};
type CameraFunctionSpecification<T> = {

@@ -165,3 +184,3 @@ type: "exponential";

type PropertyValueSpecification<T> = T | CameraFunctionSpecification<T> | ExpressionSpecification;
type DataDrivenPropertyValueSpecification<T> = T | CameraFunctionSpecification<T> | SourceFunctionSpecification<T> | CompositeFunctionSpecification<T> | ExpressionSpecification;
type DataDrivenPropertyValueSpecification<T> = T | FunctionSpecification<T> | CameraFunctionSpecification<T> | SourceFunctionSpecification<T> | CompositeFunctionSpecification<T> | ExpressionSpecification;
type StyleSpecification = {

@@ -548,2 +567,11 @@ "version": 8;

];
/**
* @experimental This property is experimental and subject to change in future versions.
*/
"line-trim-fade-range"?: PropertyValueSpecification<[
number,
number
]>;
"line-trim-color"?: PropertyValueSpecification<ColorSpecification>;
"line-trim-color-transition"?: TransitionSpecification;
"line-emissive-strength"?: PropertyValueSpecification<number>;

@@ -1331,3 +1359,3 @@ "line-emissive-strength-transition"?: TransitionSpecification;

};
declare function isExpressionFilter(filter: any): boolean;
declare function isExpressionFilter(filter: unknown): boolean;
/**

@@ -1343,3 +1371,3 @@ * Given a filter expressed as nested arrays, return a new function

*/
declare function createFilter(filter: any, layerType?: string): FeatureFilter;
declare function createFilter(filter?: FilterSpecification | ExpressionSpecification, layerType?: string): FeatureFilter;
type SerializedExpression = Array<unknown> | Array<string> | string | number | boolean | null;

@@ -1567,18 +1595,3 @@ interface Expression {

};
type Stop = [
{
zoom: number;
value: string | number | boolean;
},
unknown
];
type FunctionParameters = {
stops: Array<Stop>;
base: number;
property: string;
type: "identity" | "exponential" | "interval" | "categorical";
colorSpace: "rgb" | "lab" | "hcl";
default: unknown;
};
declare function convertFunction(parameters: FunctionParameters, propertySpec: StylePropertySpecification): ExpressionSpecification;
declare function convertFunction<T>(parameters: FunctionSpecification<T>, propertySpec: StylePropertySpecification): ExpressionSpecification;
declare function eachSource(style: StyleSpecification, callback: (_: SourceSpecification) => void): void;

@@ -1647,2 +1660,3 @@ declare function eachLayer(style: StyleSpecification, callback: (_: LayerSpecification) => void): void;

default?: number;
tokens: never;
} | {

@@ -1661,2 +1675,3 @@ type: "string";

default?: boolean;
tokens: never;
} | {

@@ -1671,2 +1686,3 @@ type: "enum";

default?: string;
tokens: never;
} | {

@@ -1678,2 +1694,3 @@ type: "color";

default?: string;
tokens: never;
overridable: boolean;

@@ -1688,2 +1705,3 @@ } | {

default?: Array<number>;
tokens: never;
} | {

@@ -1697,2 +1715,3 @@ type: "array";

default?: Array<string>;
tokens: never;
} | {

@@ -1704,2 +1723,3 @@ type: "resolvedImage";

default?: string;
tokens: never;
};

@@ -1706,0 +1726,0 @@ export declare const expression: {

@@ -0,8 +1,10 @@

import type Point from '@mapbox/point-geometry';
import latest from '../reference/latest';
import {deepUnbundle} from '../util/unbundle_jsonlint';
import {createExpression} from '../expression/index';
import {isFeatureConstant} from '../expression/is_constant';
import {deepUnbundle} from '../util/unbundle_jsonlint';
import latest from '../reference/latest';
import type {CanonicalTileID} from '../types/tile_id';
import type {GlobalProperties, Feature} from '../expression/index';
import type {CanonicalTileID} from '../types/tile_id';
import type Point from '@mapbox/point-geometry';
import type {FilterSpecification, ExpressionSpecification} from '../types';

@@ -31,3 +33,3 @@ export type FeatureDistanceData = {

function isExpressionFilter(filter: any): boolean {
function isExpressionFilter(filter: unknown): boolean {
if (filter === true || filter === false) {

@@ -84,3 +86,3 @@ return true;

*/
function createFilter(filter: any, layerType: string = 'fill'): FeatureFilter {
function createFilter(filter?: FilterSpecification | ExpressionSpecification, layerType: string = 'fill'): FeatureFilter {
if (filter === null || filter === undefined) {

@@ -91,4 +93,5 @@ return {filter: () => true, needGeometry: false, needFeature: false};

if (!isExpressionFilter(filter)) {
filter = convertFilter(filter);
filter = convertFilter(filter) as ExpressionSpecification;
}
const filterExp = (filter as string[] | string | boolean);

@@ -95,0 +98,0 @@

import assert from 'assert';
import type {StylePropertySpecification} from '../style-spec';
import type {ExpressionSpecification} from '../types';
import type {
FunctionSpecification,
PropertyFunctionStop,
ZoomAndPropertyFunctionStop,
ExpressionSpecification,
} from '../types';
type Stop = [{
zoom: number;
value: string | number | boolean;
}, unknown];
type FunctionParameters = {
stops: Array<Stop>;
base: number;
property: string;
type: 'identity' | 'exponential' | 'interval' | 'categorical';
colorSpace: 'rgb' | 'lab' | 'hcl';
default: unknown;
};
function convertLiteral(value: unknown) {

@@ -24,3 +15,3 @@ return typeof value === 'object' ? ['literal', value] : value;

export default function convertFunction(parameters: FunctionParameters, propertySpec: StylePropertySpecification): ExpressionSpecification {
export default function convertFunction<T>(parameters: FunctionSpecification<T>, propertySpec: StylePropertySpecification): ExpressionSpecification {
let stops = parameters.stops;

@@ -37,3 +28,2 @@ if (!stops) {

stops = stops.map((stop) => {
// @ts-expect-error - TS2339 - Property 'tokens' does not exist on type 'StylePropertySpecification'.
if (!featureDependent && propertySpec.tokens && typeof stop[1] === 'string') {

@@ -43,14 +33,14 @@ return [stop[0], convertTokenString(stop[1])];

return [stop[0], convertLiteral(stop[1])];
});
}) as FunctionSpecification<T>['stops'];
if (zoomAndFeatureDependent) {
return convertZoomAndPropertyFunction(parameters, propertySpec, stops);
return convertZoomAndPropertyFunction(parameters, propertySpec, stops as Array<ZoomAndPropertyFunctionStop<T>>);
} else if (zoomDependent) {
return convertZoomFunction(parameters, propertySpec, stops);
return convertZoomFunction(parameters, propertySpec, stops as PropertyFunctionStop<T>[]);
} else {
return convertPropertyFunction(parameters, propertySpec, stops);
return convertPropertyFunction(parameters, propertySpec, stops as PropertyFunctionStop<T>[]);
}
}
function convertIdentityFunction(parameters: FunctionParameters, propertySpec: StylePropertySpecification): ExpressionSpecification {
function convertIdentityFunction<T>(parameters: FunctionSpecification<T>, propertySpec: StylePropertySpecification): ExpressionSpecification {
const get: ExpressionSpecification = ['get', parameters.property];

@@ -79,3 +69,3 @@

function getInterpolateOperator(parameters: FunctionParameters) {
function getInterpolateOperator<T>(parameters: FunctionSpecification<T>) {
switch (parameters.colorSpace) {

@@ -88,6 +78,6 @@ case 'hcl': return 'interpolate-hcl';

function convertZoomAndPropertyFunction(
parameters: FunctionParameters,
function convertZoomAndPropertyFunction<T>(
parameters: FunctionSpecification<T>,
propertySpec: StylePropertySpecification,
stops: Array<Stop>,
stops: Array<ZoomAndPropertyFunctionStop<T>>,
): ExpressionSpecification {

@@ -117,4 +107,3 @@ const featureFunctionParameters: Record<string, any> = {};

// otherwise.
// @ts-expect-error - TS2345 - Argument of type '{}' is not assignable to parameter of type 'FunctionParameters'.
const functionType = getFunctionType({}, propertySpec);
const functionType = getFunctionType({} as FunctionSpecification<unknown>, propertySpec);
if (functionType === 'exponential') {

@@ -148,3 +137,3 @@ const expression: ExpressionSpecification = [getInterpolateOperator(parameters), ['linear'], ['zoom']];

function getFallback(parameters: FunctionParameters, propertySpec: StylePropertySpecification) {
function getFallback<T>(parameters: FunctionSpecification<T>, propertySpec: StylePropertySpecification) {
const defaultValue = convertLiteral(coalesce(parameters.default, propertySpec.default));

@@ -164,6 +153,6 @@

function convertPropertyFunction(
parameters: FunctionParameters,
function convertPropertyFunction<T>(
parameters: FunctionSpecification<T>,
propertySpec: StylePropertySpecification,
stops: Array<Stop>,
stops: Array<PropertyFunctionStop<T>>,
): ExpressionSpecification {

@@ -222,3 +211,3 @@ const type = getFunctionType(parameters, propertySpec);

function convertZoomFunction(parameters: FunctionParameters, propertySpec: StylePropertySpecification, stops: Array<Stop>, input: Array<string> = ['zoom']) {
function convertZoomFunction<T>(parameters: FunctionSpecification<T>, propertySpec: StylePropertySpecification, stops: Array<PropertyFunctionStop<T>>, input: Array<string> = ['zoom']) {
const type = getFunctionType(parameters, propertySpec);

@@ -268,3 +257,3 @@ let expression;

function getFunctionType(parameters: FunctionParameters, propertySpec: StylePropertySpecification): string {
function getFunctionType<T>(parameters: FunctionSpecification<T>, propertySpec: StylePropertySpecification): string {
if (parameters.type) {

@@ -271,0 +260,0 @@ return parameters.type;

@@ -6,3 +6,3 @@ import {eachLayer, eachProperty} from '../visit';

import type {StyleSpecification} from '../types';
import type {StyleSpecification, FunctionSpecification} from '../types';

@@ -26,6 +26,4 @@ /**

if (typeof value === 'object' && !Array.isArray(value)) {
// @ts-expect-error - TS2345 - Argument of type 'object' is not assignable to parameter of type 'FunctionParameters'.
set(convertFunction(value, reference));
set(convertFunction(value as FunctionSpecification<unknown>, reference));
converted.push(path.join('.'));
// @ts-expect-error - TS2339 - Property 'tokens' does not exist on type 'StylePropertySpecification'.
} else if (reference.tokens && typeof value === 'string') {

@@ -38,2 +36,1 @@ set(convertTokenString(value));

}
{
"name": "@mapbox/mapbox-gl-style-spec",
"version": "14.5.0-beta.1",
"version": "14.5.0",
"description": "a specification for mapbox gl styles",

@@ -49,3 +49,3 @@ "author": "Mapbox",

"@mapbox/unitbezier": "^0.0.1",
"cheap-ruler": "^3.0.1",
"cheap-ruler": "^4.0.0",
"csscolorparser": "~1.0.2",

@@ -56,5 +56,4 @@ "json-stringify-pretty-compact": "^4.0.0",

"rw": "^1.3.3",
"sort-object": "^3.0.3",
"tinyqueue": "^2.0.3"
}
}

@@ -15,3 +15,4 @@ type ExpressionType = 'data-driven' | 'color-ramp' | 'data-constant' | 'constant';

transition?: boolean,
default?: number
default?: number,
tokens: never
} | {

@@ -29,3 +30,4 @@ type: 'string',

transition?: boolean,
default?: boolean
default?: boolean,
tokens: never
} | {

@@ -37,3 +39,4 @@ type: 'enum',

transition?: boolean,
default?: string
default?: string,
tokens: never
} | {

@@ -45,2 +48,3 @@ type: 'color',

default?: string,
tokens: never,
overridable: boolean

@@ -54,3 +58,4 @@ } | {

transition?: boolean,
default?: Array<number>
default?: Array<number>,
tokens: never
} | {

@@ -63,3 +68,4 @@ type: 'array',

transition?: boolean,
default?: Array<string>
default?: Array<string>,
tokens: never
} | {

@@ -70,3 +76,4 @@ type: 'resolvedImage',

transition?: boolean,
default?: string
default?: string,
tokens: never
};

@@ -73,0 +80,0 @@

@@ -30,2 +30,17 @@ // Generated code; do not edit. Edit build/generate-typed-style-spec.ts instead.

export type PropertyFunctionStop<T> = [number, T];
export type ZoomAndPropertyFunctionStop<T> = [{zoom: number; value: string | number | boolean}, T];
/**
* @deprecated Use [Expressions](https://docs.mapbox.com/style-spec/reference/expressions/) syntax instead.
*/
export type FunctionSpecification<T> = {
stops: Array<PropertyFunctionStop<T> | ZoomAndPropertyFunctionStop<T>>;
base?: number;
property?: string;
type?: 'identity' | 'exponential' | 'interval' | 'categorical';
colorSpace?: 'rgb' | 'lab' | 'hcl';
default?: T;
};
export type CameraFunctionSpecification<T> =

@@ -55,2 +70,3 @@ | { type: 'exponential', stops: Array<[number, T]> }

| T
| FunctionSpecification<T>
| CameraFunctionSpecification<T>

@@ -408,2 +424,8 @@ | SourceFunctionSpecification<T>

"line-trim-offset"?: [number, number],
/**
* @experimental This property is experimental and subject to change in future versions.
*/
"line-trim-fade-range"?: PropertyValueSpecification<[number, number]>,
"line-trim-color"?: PropertyValueSpecification<ColorSpecification>,
"line-trim-color-transition"?: TransitionSpecification,
"line-emissive-strength"?: PropertyValueSpecification<number>,

@@ -410,0 +432,0 @@ "line-emissive-strength-transition"?: TransitionSpecification,

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 too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc