@mapbox/mapbox-gl-style-spec 14.10.0 → 14.11.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/composite.ts +1 -0
  2. package/dist/index.cjs +467 -191
  3. package/dist/index.cjs.map +1 -1
  4. package/dist/index.d.ts +76 -39
  5. package/dist/index.es.js +467 -191
  6. package/dist/index.es.js.map +1 -1
  7. package/expression/compound_expression.ts +5 -7
  8. package/expression/definitions/at.ts +5 -19
  9. package/expression/definitions/at_interpolated.ts +80 -0
  10. package/expression/definitions/coercion.ts +1 -5
  11. package/expression/definitions/comparison.ts +2 -8
  12. package/expression/definitions/config.ts +1 -4
  13. package/expression/definitions/distance.ts +28 -43
  14. package/expression/definitions/format.ts +4 -9
  15. package/expression/definitions/image.ts +126 -73
  16. package/expression/definitions/index.ts +3 -2
  17. package/expression/definitions/interpolate.ts +28 -80
  18. package/expression/definitions/let.ts +2 -7
  19. package/expression/definitions/literal.ts +1 -2
  20. package/expression/definitions/match.ts +3 -12
  21. package/expression/definitions/step.ts +1 -5
  22. package/expression/evaluation_context.ts +3 -3
  23. package/expression/index.ts +12 -18
  24. package/expression/parsing_context.ts +3 -7
  25. package/expression/types/formatted.ts +7 -3
  26. package/expression/types/image_id.ts +61 -0
  27. package/expression/types/image_variant.ts +79 -0
  28. package/expression/types/resolved_image.ts +44 -53
  29. package/format.ts +1 -0
  30. package/function/index.ts +1 -0
  31. package/migrate/v8.ts +1 -0
  32. package/migrate/v9.ts +1 -0
  33. package/migrate.ts +1 -0
  34. package/package.json +1 -1
  35. package/read_style.ts +1 -0
  36. package/reference/v8.json +154 -7
  37. package/types/brand.ts +4 -0
  38. package/types.ts +30 -2
  39. package/util/color.ts +1 -1
  40. package/validate/validate.ts +6 -1
  41. package/validate/validate_iconset.ts +40 -0
  42. package/validate/validate_layer.ts +1 -5
  43. package/validate/validate_lights.ts +3 -2
  44. package/validate/validate_object.ts +2 -0
  45. package/validate/validate_style.ts +0 -1
  46. package/expression/types/image_id_with_options.ts +0 -58
package/dist/index.d.ts CHANGED
@@ -209,6 +209,10 @@ type StyleSpecification = {
209
209
  */
210
210
  "indoor"?: IndoorSpecification;
211
211
  "imports"?: Array<ImportSpecification>;
212
+ /**
213
+ * @experimental This property is experimental and subject to change in future versions.
214
+ */
215
+ "iconsets"?: IconsetsSpecification;
212
216
  "schema"?: SchemaSpecification;
213
217
  "sources": SourcesSpecification;
214
218
  "sprite"?: string;
@@ -228,6 +232,9 @@ type SourcesSpecification = {
228
232
  type ModelsSpecification = {
229
233
  [_: string]: ModelSpecification;
230
234
  };
235
+ type IconsetsSpecification = {
236
+ [_: string]: IconsetSpecification;
237
+ };
231
238
  type LightSpecification = {
232
239
  "anchor"?: PropertyValueSpecification<"map" | "viewport">;
233
240
  "position"?: PropertyValueSpecification<[
@@ -557,6 +564,13 @@ type ModelSourceSpecification = {
557
564
  "tiles"?: Array<string>;
558
565
  };
559
566
  type SourceSpecification = VectorSourceSpecification | RasterSourceSpecification | RasterDEMSourceSpecification | RasterArraySourceSpecification | GeoJSONSourceSpecification | VideoSourceSpecification | ImageSourceSpecification | ModelSourceSpecification;
567
+ type IconsetSpecification = {
568
+ "type": "sprite";
569
+ "url": string;
570
+ } | {
571
+ "type": "source";
572
+ "source": string;
573
+ };
560
574
  type ModelSpecification = string;
561
575
  type AmbientLightSpecification = {
562
576
  "id": string;
@@ -628,6 +642,10 @@ type FillLayerSpecification = {
628
642
  * @experimental This property is experimental and subject to change in future versions.
629
643
  */
630
644
  "fill-elevation-reference"?: "none" | "hd-road-base" | "hd-road-markup" | ExpressionSpecification;
645
+ /**
646
+ * @experimental This property is experimental and subject to change in future versions.
647
+ */
648
+ "fill-construct-bridge-guard-rail"?: DataDrivenPropertyValueSpecification<boolean>;
631
649
  };
632
650
  "paint"?: {
633
651
  "fill-antialias"?: PropertyValueSpecification<boolean>;
@@ -650,6 +668,12 @@ type FillLayerSpecification = {
650
668
  "fill-emissive-strength-transition"?: TransitionSpecification;
651
669
  "fill-z-offset"?: DataDrivenPropertyValueSpecification<number>;
652
670
  "fill-z-offset-transition"?: TransitionSpecification;
671
+ "fill-bridge-guard-rail-color"?: DataDrivenPropertyValueSpecification<ColorSpecification>;
672
+ "fill-bridge-guard-rail-color-transition"?: TransitionSpecification;
673
+ "fill-bridge-guard-rail-color-use-theme"?: PropertyValueSpecification<string>;
674
+ "fill-tunnel-structure-color"?: DataDrivenPropertyValueSpecification<ColorSpecification>;
675
+ "fill-tunnel-structure-color-transition"?: TransitionSpecification;
676
+ "fill-tunnel-structure-color-use-theme"?: PropertyValueSpecification<string>;
653
677
  };
654
678
  };
655
679
  type LineLayerSpecification = {
@@ -1376,7 +1400,7 @@ export declare class Color {
1376
1400
  * Parses valid CSS color strings and returns a `Color` instance.
1377
1401
  * @returns A `Color` instance, or `undefined` if the input is not a valid color string.
1378
1402
  */
1379
- static parse(input?: string | Color | null): Color | void;
1403
+ static parse(input?: string | Color | null): Color | undefined;
1380
1404
  /**
1381
1405
  * Returns an RGBA string representing the color value.
1382
1406
  *
@@ -1474,39 +1498,52 @@ declare class Collator {
1474
1498
  compare(lhs: string, rhs: string): number;
1475
1499
  resolvedLocale(): string;
1476
1500
  }
1477
- declare class ImageIdWithOptions {
1478
- id: string;
1479
- options: RasterizationOptions;
1480
- constructor(id: string, options?: RasterizationOptions);
1481
- static deserializeId(serialized: string): string;
1482
- static deserializeFromString(serialized: string): ImageIdWithOptions;
1483
- scaleSelf(factor: number): this;
1484
- serialize(): string;
1501
+ type Brand<T, U> = T & {
1502
+ __brand: U;
1503
+ };
1504
+ type ImageIdSpec = {
1505
+ name: string;
1506
+ iconsetId?: string;
1507
+ };
1508
+ type StringifiedImageId = Brand<string, "ImageId">;
1509
+ declare class ImageId {
1510
+ name: string;
1511
+ iconsetId?: string;
1512
+ constructor(id: string | ImageId | ImageIdSpec);
1513
+ static from(id: string | ImageId | ImageIdSpec): ImageId;
1514
+ static toString(id: ImageId | ImageIdSpec): StringifiedImageId;
1515
+ static parse(str: StringifiedImageId): ImageId | null;
1516
+ static isEqual(a: ImageId | ImageIdSpec, b: ImageId | ImageIdSpec): boolean;
1517
+ toString(): StringifiedImageId;
1518
+ serialize(): ImageIdSpec;
1485
1519
  }
1520
+ type StringifiedImageVariant = Brand<string, "ImageVariant">;
1486
1521
  type RasterizationOptions = {
1487
- params: Record<string, Color>;
1522
+ params?: Record<string, Color>;
1488
1523
  transform?: DOMMatrix;
1489
1524
  };
1490
- type ResolvedImageOptions = {
1491
- namePrimary: string;
1492
- optionsPrimary: RasterizationOptions | null | undefined;
1493
- nameSecondary: string | null | undefined;
1494
- optionsSecondary: RasterizationOptions | null | undefined;
1495
- available: boolean;
1496
- };
1525
+ declare class ImageVariant {
1526
+ id: ImageId;
1527
+ options: RasterizationOptions;
1528
+ constructor(id: string | ImageIdSpec, options?: RasterizationOptions);
1529
+ toString(): StringifiedImageVariant;
1530
+ static parse(str: StringifiedImageVariant): ImageVariant | null;
1531
+ scaleSelf(factor: number): this;
1532
+ }
1497
1533
  declare class ResolvedImage {
1498
- namePrimary: string;
1499
- optionsPrimary: RasterizationOptions | null | undefined;
1500
- nameSecondary: string | null | undefined;
1501
- optionsSecondary: RasterizationOptions | null | undefined;
1534
+ primaryId: ImageId;
1535
+ primaryOptions?: RasterizationOptions;
1536
+ secondaryId?: ImageId;
1537
+ secondaryOptions?: RasterizationOptions;
1502
1538
  available: boolean;
1503
- constructor(options: ResolvedImageOptions);
1539
+ constructor(primaryId: string | ImageIdSpec, primaryOptions?: RasterizationOptions, secondaryId?: string | ImageIdSpec, secondaryOptions?: RasterizationOptions, available?: boolean);
1504
1540
  toString(): string;
1505
- getPrimary(): ImageIdWithOptions;
1506
- getSerializedPrimary(): string;
1507
- getSecondary(): ImageIdWithOptions | null;
1541
+ hasPrimary(): boolean;
1542
+ getPrimary(): ImageVariant;
1543
+ hasSecondary(): boolean;
1544
+ getSecondary(): ImageVariant | null;
1508
1545
  static from(image: string | ResolvedImage): ResolvedImage;
1509
- static build(namePrimary: string, nameSecondary?: string | null, optionsPrimary?: RasterizationOptions | null, optionsSecondary?: RasterizationOptions | null): ResolvedImage | null;
1546
+ static build(primaryId: string | ImageIdSpec, secondaryId?: string | ImageIdSpec, primaryOptions?: RasterizationOptions, secondaryOptions?: RasterizationOptions): ResolvedImage | null;
1510
1547
  }
1511
1548
  declare class FormattedSection {
1512
1549
  text: string;
@@ -1632,7 +1669,7 @@ declare class EvaluationContext {
1632
1669
  feature: Feature | null | undefined;
1633
1670
  featureState: FeatureState | null | undefined;
1634
1671
  formattedSection: FormattedSection | null | undefined;
1635
- availableImages: Array<string> | null | undefined;
1672
+ availableImages: ImageId[] | null | undefined;
1636
1673
  canonical: null | CanonicalTileID;
1637
1674
  featureTileCoord: Point | null | undefined;
1638
1675
  featureDistanceData: FeatureDistanceData | null | undefined;
@@ -1651,7 +1688,7 @@ declare class EvaluationContext {
1651
1688
  };
1652
1689
  measureLight(_: string): number;
1653
1690
  distanceFromCenter(): number;
1654
- parseColor(input: string): Color | null | undefined;
1691
+ parseColor(input: string): Color | undefined;
1655
1692
  getConfig(id: string): ConfigOptionValue | null | undefined;
1656
1693
  }
1657
1694
  type Result<T, E> = {
@@ -1713,8 +1750,8 @@ declare class StyleExpression {
1713
1750
  };
1714
1751
  configDependencies: Set<string>;
1715
1752
  constructor(expression: Expression, propertySpec?: StylePropertySpecification, scope?: string, options?: ConfigOptions);
1716
- evaluateWithoutErrorHandling(globals: GlobalProperties, feature?: Feature, featureState?: FeatureState, canonical?: CanonicalTileID, availableImages?: Array<string>, formattedSection?: FormattedSection, featureTileCoord?: Point, featureDistanceData?: FeatureDistanceData): any;
1717
- evaluate(globals: GlobalProperties, feature?: Feature, featureState?: FeatureState, canonical?: CanonicalTileID, availableImages?: Array<string>, formattedSection?: FormattedSection, featureTileCoord?: Point, featureDistanceData?: FeatureDistanceData): any;
1753
+ evaluateWithoutErrorHandling(globals: GlobalProperties, feature?: Feature, featureState?: FeatureState, canonical?: CanonicalTileID, availableImages?: ImageId[], formattedSection?: FormattedSection, featureTileCoord?: Point, featureDistanceData?: FeatureDistanceData): any;
1754
+ evaluate(globals: GlobalProperties, feature?: Feature, featureState?: FeatureState, canonical?: CanonicalTileID, availableImages?: ImageId[], formattedSection?: FormattedSection, featureTileCoord?: Point, featureDistanceData?: FeatureDistanceData): any;
1718
1755
  }
1719
1756
  declare function isExpression(expression: unknown): boolean;
1720
1757
  declare function createExpression(expression: unknown, propertySpec?: StylePropertySpecification | null, scope?: string | null, options?: ConfigOptions | null): Result<StyleExpression, Array<ParsingError$1>>;
@@ -1726,8 +1763,8 @@ declare class ZoomConstantExpression<Kind extends EvaluationKind> {
1726
1763
  isLightConstant: boolean | null | undefined;
1727
1764
  isLineProgressConstant: boolean | null | undefined;
1728
1765
  constructor(kind: Kind, expression: StyleExpression, isLightConstant?: boolean | null, isLineProgressConstant?: boolean | null);
1729
- evaluateWithoutErrorHandling(globals: GlobalProperties, feature?: Feature, featureState?: FeatureState, canonical?: CanonicalTileID, availableImages?: Array<string>, formattedSection?: FormattedSection): any;
1730
- evaluate(globals: GlobalProperties, feature?: Feature, featureState?: FeatureState, canonical?: CanonicalTileID, availableImages?: Array<string>, formattedSection?: FormattedSection): any;
1766
+ evaluateWithoutErrorHandling(globals: GlobalProperties, feature?: Feature, featureState?: FeatureState, canonical?: CanonicalTileID, availableImages?: ImageId[], formattedSection?: FormattedSection): any;
1767
+ evaluate(globals: GlobalProperties, feature?: Feature, featureState?: FeatureState, canonical?: CanonicalTileID, availableImages?: ImageId[], formattedSection?: FormattedSection): any;
1731
1768
  }
1732
1769
  declare class ZoomDependentExpression<Kind extends EvaluationKind> {
1733
1770
  kind: Kind;
@@ -1739,14 +1776,14 @@ declare class ZoomDependentExpression<Kind extends EvaluationKind> {
1739
1776
  _styleExpression: StyleExpression;
1740
1777
  interpolationType: InterpolationType | null | undefined;
1741
1778
  constructor(kind: Kind, expression: StyleExpression, zoomStops: Array<number>, interpolationType?: InterpolationType, isLightConstant?: boolean | null, isLineProgressConstant?: boolean | null);
1742
- evaluateWithoutErrorHandling(globals: GlobalProperties, feature?: Feature, featureState?: FeatureState, canonical?: CanonicalTileID, availableImages?: Array<string>, formattedSection?: FormattedSection): any;
1743
- evaluate(globals: GlobalProperties, feature?: Feature, featureState?: FeatureState, canonical?: CanonicalTileID, availableImages?: Array<string>, formattedSection?: FormattedSection): any;
1779
+ evaluateWithoutErrorHandling(globals: GlobalProperties, feature?: Feature, featureState?: FeatureState, canonical?: CanonicalTileID, availableImages?: ImageId[], formattedSection?: FormattedSection): any;
1780
+ evaluate(globals: GlobalProperties, feature?: Feature, featureState?: FeatureState, canonical?: CanonicalTileID, availableImages?: ImageId[], formattedSection?: FormattedSection): any;
1744
1781
  interpolationFactor(input: number, lower: number, upper: number): number;
1745
1782
  }
1746
1783
  type ConstantExpression = {
1747
1784
  kind: "constant";
1748
1785
  configDependencies: Set<string>;
1749
- readonly evaluate: (globals: GlobalProperties, feature?: Feature, featureState?: FeatureState, canonical?: CanonicalTileID, availableImages?: Array<string>) => any;
1786
+ readonly evaluate: (globals: GlobalProperties, feature?: Feature, featureState?: FeatureState, canonical?: CanonicalTileID, availableImages?: ImageId[]) => any;
1750
1787
  };
1751
1788
  type SourceExpression = {
1752
1789
  kind: "source";
@@ -1754,13 +1791,13 @@ type SourceExpression = {
1754
1791
  isLightConstant: boolean | null | undefined;
1755
1792
  isLineProgressConstant: boolean | null | undefined;
1756
1793
  configDependencies: Set<string>;
1757
- readonly evaluate: (globals: GlobalProperties, feature?: Feature, featureState?: FeatureState, canonical?: CanonicalTileID, availableImages?: Array<string>, formattedSection?: FormattedSection) => any;
1794
+ readonly evaluate: (globals: GlobalProperties, feature?: Feature, featureState?: FeatureState, canonical?: CanonicalTileID, availableImages?: ImageId[], formattedSection?: FormattedSection) => any;
1758
1795
  };
1759
1796
  type CameraExpression = {
1760
1797
  kind: "camera";
1761
1798
  isStateDependent: boolean;
1762
1799
  configDependencies: Set<string>;
1763
- readonly evaluate: (globals: GlobalProperties, feature?: Feature, featureState?: FeatureState, canonical?: CanonicalTileID, availableImages?: Array<string>) => any;
1800
+ readonly evaluate: (globals: GlobalProperties, feature?: Feature, featureState?: FeatureState, canonical?: CanonicalTileID, availableImages?: ImageId[]) => any;
1764
1801
  readonly interpolationFactor: (input: number, lower: number, upper: number) => number;
1765
1802
  zoomStops: Array<number>;
1766
1803
  interpolationType: InterpolationType | null | undefined;
@@ -1771,13 +1808,13 @@ interface CompositeExpression {
1771
1808
  isLightConstant: boolean | null | undefined;
1772
1809
  isLineProgressConstant: boolean | null | undefined;
1773
1810
  configDependencies: Set<string>;
1774
- readonly evaluate: (globals: GlobalProperties, feature?: Feature, featureState?: FeatureState, canonical?: CanonicalTileID, availableImages?: Array<string>, formattedSection?: FormattedSection) => any;
1811
+ readonly evaluate: (globals: GlobalProperties, feature?: Feature, featureState?: FeatureState, canonical?: CanonicalTileID, availableImages?: ImageId[], formattedSection?: FormattedSection) => any;
1775
1812
  readonly interpolationFactor: (input: number, lower: number, upper: number) => number;
1776
1813
  zoomStops: Array<number>;
1777
1814
  interpolationType: InterpolationType | null | undefined;
1778
1815
  }
1779
1816
  type StylePropertyExpression = ConstantExpression | SourceExpression | CameraExpression | CompositeExpression;
1780
- declare function createPropertyExpression(expression: unknown, propertySpec: StylePropertySpecification, scope?: string | null, options?: ConfigOptions | null): Result<StylePropertyExpression, Array<ParsingError$1>>;
1817
+ declare function createPropertyExpression(expression: any, propertySpec: StylePropertySpecification, scope?: string | null, options?: ConfigOptions | null): Result<StylePropertyExpression, Array<ParsingError$1>>;
1781
1818
  declare class StylePropertyFunction<T> {
1782
1819
  _parameters: PropertyValueSpecification<T>;
1783
1820
  _specification: StylePropertySpecification;