@mapbox/mapbox-gl-style-spec 14.11.0-beta.1 → 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.
package/dist/index.d.ts CHANGED
@@ -1498,39 +1498,52 @@ declare class Collator {
1498
1498
  compare(lhs: string, rhs: string): number;
1499
1499
  resolvedLocale(): string;
1500
1500
  }
1501
- declare class ImageIdWithOptions {
1502
- id: string;
1503
- options: RasterizationOptions;
1504
- constructor(id: string, options?: RasterizationOptions);
1505
- static deserializeId(serialized: string): string;
1506
- static deserializeFromString(serialized: string): ImageIdWithOptions;
1507
- scaleSelf(factor: number): this;
1508
- 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;
1509
1519
  }
1520
+ type StringifiedImageVariant = Brand<string, "ImageVariant">;
1510
1521
  type RasterizationOptions = {
1511
- params: Record<string, Color>;
1522
+ params?: Record<string, Color>;
1512
1523
  transform?: DOMMatrix;
1513
1524
  };
1514
- type ResolvedImageOptions = {
1515
- namePrimary: string;
1516
- optionsPrimary: RasterizationOptions | null | undefined;
1517
- nameSecondary: string | null | undefined;
1518
- optionsSecondary: RasterizationOptions | null | undefined;
1519
- available: boolean;
1520
- };
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
+ }
1521
1533
  declare class ResolvedImage {
1522
- namePrimary: string;
1523
- optionsPrimary: RasterizationOptions | null | undefined;
1524
- nameSecondary: string | null | undefined;
1525
- optionsSecondary: RasterizationOptions | null | undefined;
1534
+ primaryId: ImageId;
1535
+ primaryOptions?: RasterizationOptions;
1536
+ secondaryId?: ImageId;
1537
+ secondaryOptions?: RasterizationOptions;
1526
1538
  available: boolean;
1527
- constructor(options: ResolvedImageOptions);
1539
+ constructor(primaryId: string | ImageIdSpec, primaryOptions?: RasterizationOptions, secondaryId?: string | ImageIdSpec, secondaryOptions?: RasterizationOptions, available?: boolean);
1528
1540
  toString(): string;
1529
- getPrimary(): ImageIdWithOptions;
1530
- getSerializedPrimary(): string;
1531
- getSecondary(): ImageIdWithOptions | null;
1541
+ hasPrimary(): boolean;
1542
+ getPrimary(): ImageVariant;
1543
+ hasSecondary(): boolean;
1544
+ getSecondary(): ImageVariant | null;
1532
1545
  static from(image: string | ResolvedImage): ResolvedImage;
1533
- 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;
1534
1547
  }
1535
1548
  declare class FormattedSection {
1536
1549
  text: string;
@@ -1656,7 +1669,7 @@ declare class EvaluationContext {
1656
1669
  feature: Feature | null | undefined;
1657
1670
  featureState: FeatureState | null | undefined;
1658
1671
  formattedSection: FormattedSection | null | undefined;
1659
- availableImages: Array<string> | null | undefined;
1672
+ availableImages: ImageId[] | null | undefined;
1660
1673
  canonical: null | CanonicalTileID;
1661
1674
  featureTileCoord: Point | null | undefined;
1662
1675
  featureDistanceData: FeatureDistanceData | null | undefined;
@@ -1737,8 +1750,8 @@ declare class StyleExpression {
1737
1750
  };
1738
1751
  configDependencies: Set<string>;
1739
1752
  constructor(expression: Expression, propertySpec?: StylePropertySpecification, scope?: string, options?: ConfigOptions);
1740
- evaluateWithoutErrorHandling(globals: GlobalProperties, feature?: Feature, featureState?: FeatureState, canonical?: CanonicalTileID, availableImages?: Array<string>, formattedSection?: FormattedSection, featureTileCoord?: Point, featureDistanceData?: FeatureDistanceData): any;
1741
- 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;
1742
1755
  }
1743
1756
  declare function isExpression(expression: unknown): boolean;
1744
1757
  declare function createExpression(expression: unknown, propertySpec?: StylePropertySpecification | null, scope?: string | null, options?: ConfigOptions | null): Result<StyleExpression, Array<ParsingError$1>>;
@@ -1750,8 +1763,8 @@ declare class ZoomConstantExpression<Kind extends EvaluationKind> {
1750
1763
  isLightConstant: boolean | null | undefined;
1751
1764
  isLineProgressConstant: boolean | null | undefined;
1752
1765
  constructor(kind: Kind, expression: StyleExpression, isLightConstant?: boolean | null, isLineProgressConstant?: boolean | null);
1753
- evaluateWithoutErrorHandling(globals: GlobalProperties, feature?: Feature, featureState?: FeatureState, canonical?: CanonicalTileID, availableImages?: Array<string>, formattedSection?: FormattedSection): any;
1754
- 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;
1755
1768
  }
1756
1769
  declare class ZoomDependentExpression<Kind extends EvaluationKind> {
1757
1770
  kind: Kind;
@@ -1763,14 +1776,14 @@ declare class ZoomDependentExpression<Kind extends EvaluationKind> {
1763
1776
  _styleExpression: StyleExpression;
1764
1777
  interpolationType: InterpolationType | null | undefined;
1765
1778
  constructor(kind: Kind, expression: StyleExpression, zoomStops: Array<number>, interpolationType?: InterpolationType, isLightConstant?: boolean | null, isLineProgressConstant?: boolean | null);
1766
- evaluateWithoutErrorHandling(globals: GlobalProperties, feature?: Feature, featureState?: FeatureState, canonical?: CanonicalTileID, availableImages?: Array<string>, formattedSection?: FormattedSection): any;
1767
- 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;
1768
1781
  interpolationFactor(input: number, lower: number, upper: number): number;
1769
1782
  }
1770
1783
  type ConstantExpression = {
1771
1784
  kind: "constant";
1772
1785
  configDependencies: Set<string>;
1773
- 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;
1774
1787
  };
1775
1788
  type SourceExpression = {
1776
1789
  kind: "source";
@@ -1778,13 +1791,13 @@ type SourceExpression = {
1778
1791
  isLightConstant: boolean | null | undefined;
1779
1792
  isLineProgressConstant: boolean | null | undefined;
1780
1793
  configDependencies: Set<string>;
1781
- 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;
1782
1795
  };
1783
1796
  type CameraExpression = {
1784
1797
  kind: "camera";
1785
1798
  isStateDependent: boolean;
1786
1799
  configDependencies: Set<string>;
1787
- 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;
1788
1801
  readonly interpolationFactor: (input: number, lower: number, upper: number) => number;
1789
1802
  zoomStops: Array<number>;
1790
1803
  interpolationType: InterpolationType | null | undefined;
@@ -1795,7 +1808,7 @@ interface CompositeExpression {
1795
1808
  isLightConstant: boolean | null | undefined;
1796
1809
  isLineProgressConstant: boolean | null | undefined;
1797
1810
  configDependencies: Set<string>;
1798
- 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;
1799
1812
  readonly interpolationFactor: (input: number, lower: number, upper: number) => number;
1800
1813
  zoomStops: Array<number>;
1801
1814
  interpolationType: InterpolationType | null | undefined;
package/dist/index.es.js CHANGED
@@ -3917,7 +3917,7 @@ var expression_name = {
3917
3917
  }
3918
3918
  },
3919
3919
  config: {
3920
- doc: "Retrieves the configuration value for the given option.",
3920
+ doc: "Retrieves the configuration value for the given option. Returns null if the requested option is missing.",
3921
3921
  group: "Lookup",
3922
3922
  "sdk-support": {
3923
3923
  "basic functionality": {
@@ -12441,7 +12441,13 @@ class Formatted {
12441
12441
  isEmpty() {
12442
12442
  if (this.sections.length === 0)
12443
12443
  return true;
12444
- return !this.sections.some(section => section.text.length !== 0 || section.image && section.image.namePrimary);
12444
+ return !this.sections.some(section => {
12445
+ if (section.text.length !== 0)
12446
+ return true;
12447
+ if (!section.image)
12448
+ return false;
12449
+ return section.image.hasPrimary();
12450
+ });
12445
12451
  }
12446
12452
  static factory(text) {
12447
12453
  if (text instanceof Formatted) {
@@ -12459,9 +12465,10 @@ class Formatted {
12459
12465
  const serialized = ['format'];
12460
12466
  for (const section of this.sections) {
12461
12467
  if (section.image) {
12468
+ const primaryId = section.image.getPrimary().id.toString();
12462
12469
  serialized.push([
12463
12470
  'image',
12464
- section.image.namePrimary
12471
+ primaryId
12465
12472
  ]);
12466
12473
  continue;
12467
12474
  }
@@ -12485,11 +12492,57 @@ class Formatted {
12485
12492
  }
12486
12493
  }
12487
12494
 
12488
- class ImageIdWithOptions {
12489
- constructor(id, options) {
12490
- this.id = id;
12491
- this.options = options || { params: {} };
12492
- if (!this.options.transform) {
12495
+ class ImageId {
12496
+ constructor(id) {
12497
+ if (typeof id === 'string') {
12498
+ this.name = id;
12499
+ } else {
12500
+ this.name = id.name;
12501
+ this.iconsetId = id.iconsetId;
12502
+ }
12503
+ }
12504
+ static from(id) {
12505
+ return new ImageId(id);
12506
+ }
12507
+ static toString(id) {
12508
+ return JSON.stringify({
12509
+ name: id.name,
12510
+ iconsetId: id.iconsetId
12511
+ });
12512
+ }
12513
+ static parse(str) {
12514
+ try {
12515
+ const {name, iconsetId} = JSON.parse(str);
12516
+ return new ImageId({
12517
+ name,
12518
+ iconsetId
12519
+ });
12520
+ } catch (e) {
12521
+ return null;
12522
+ }
12523
+ }
12524
+ static isEqual(a, b) {
12525
+ return a.name === b.name && a.iconsetId === b.iconsetId;
12526
+ }
12527
+ toString() {
12528
+ return JSON.stringify({
12529
+ name: this.name,
12530
+ iconsetId: this.iconsetId
12531
+ });
12532
+ }
12533
+ serialize() {
12534
+ return {
12535
+ name: this.name,
12536
+ iconsetId: this.iconsetId
12537
+ };
12538
+ }
12539
+ }
12540
+
12541
+ class ImageVariant {
12542
+ constructor(id, options = {}) {
12543
+ this.id = ImageId.from(id);
12544
+ this.options = Object.assign({}, options);
12545
+ if (!options.transform) {
12493
12546
  this.options.transform = new DOMMatrix([
12494
12547
  1,
12495
12548
  0,
@@ -12499,7 +12552,7 @@ class ImageIdWithOptions {
12499
12552
  0
12500
12553
  ]);
12501
12554
  } else {
12502
- const {a, b, c, d, e, f} = this.options.transform;
12555
+ const {a, b, c, d, e, f} = options.transform;
12503
12556
  this.options.transform = new DOMMatrix([
12504
12557
  a,
12505
12558
  b,
@@ -12510,90 +12563,93 @@ class ImageIdWithOptions {
12510
12563
  ]);
12511
12564
  }
12512
12565
  }
12513
- static deserializeId(serialized) {
12514
- return JSON.parse(serialized).id;
12566
+ toString() {
12567
+ const {a, b, c, d, e, f} = this.options.transform;
12568
+ const serialized = {
12569
+ name: this.id.name,
12570
+ iconsetId: this.id.iconsetId,
12571
+ params: this.options.params,
12572
+ transform: {
12573
+ a,
12574
+ b,
12575
+ c,
12576
+ d,
12577
+ e,
12578
+ f
12579
+ }
12580
+ };
12581
+ return JSON.stringify(serialized);
12515
12582
  }
12516
- static deserializeFromString(serialized) {
12517
- const deserializedObject = JSON.parse(serialized);
12518
- ({ params: deserializedObject.options.params });
12519
- const {a, b, c, d, e, f} = deserializedObject.options.transform;
12520
- new DOMMatrix([
12521
- a,
12522
- b,
12523
- c,
12524
- d,
12525
- e,
12526
- f
12527
- ]);
12528
- return new ImageIdWithOptions(deserializedObject.id, deserializedObject.options);
12583
+ static parse(str) {
12584
+ let name, iconsetId, params, transform;
12585
+ try {
12586
+ ({name, iconsetId, params, transform} = JSON.parse(str) || {});
12587
+ } catch (e2) {
12588
+ return null;
12589
+ }
12590
+ if (!name)
12591
+ return null;
12592
+ const {a, b, c, d, e, f} = transform || {};
12593
+ return new ImageVariant({
12594
+ name,
12595
+ iconsetId
12596
+ }, {
12597
+ params,
12598
+ transform: new DOMMatrix([
12599
+ a,
12600
+ b,
12601
+ c,
12602
+ d,
12603
+ e,
12604
+ f
12605
+ ])
12606
+ });
12529
12607
  }
12530
12608
  scaleSelf(factor) {
12531
- this.options.transform = this.options.transform.scale(factor);
12609
+ this.options.transform.scaleSelf(factor);
12532
12610
  return this;
12533
12611
  }
12534
- serialize() {
12535
- const serialisedObject = { id: this.id };
12536
- if (this.options) {
12537
- serialisedObject.options = this.options;
12538
- }
12539
- const {a, b, c, d, e, f} = this.options.transform;
12540
- serialisedObject.options.transform = {
12541
- a,
12542
- b,
12543
- c,
12544
- d,
12545
- e,
12546
- f
12547
- };
12548
- return JSON.stringify(serialisedObject);
12549
- }
12550
12612
  }
12551
12613
 
12552
12614
  class ResolvedImage {
12553
- constructor(options) {
12554
- this.namePrimary = options.namePrimary;
12555
- if (options.nameSecondary) {
12556
- this.nameSecondary = options.nameSecondary;
12557
- }
12558
- if (options.optionsPrimary) {
12559
- this.optionsPrimary = options.optionsPrimary;
12560
- }
12561
- if (options.optionsSecondary) {
12562
- this.optionsSecondary = options.optionsSecondary;
12563
- }
12564
- this.available = options.available;
12615
+ constructor(primaryId, primaryOptions, secondaryId, secondaryOptions, available = false) {
12616
+ this.primaryId = ImageId.from(primaryId);
12617
+ this.primaryOptions = primaryOptions;
12618
+ if (secondaryId)
12619
+ this.secondaryId = ImageId.from(secondaryId);
12620
+ this.secondaryOptions = secondaryOptions;
12621
+ this.available = available;
12565
12622
  }
12566
12623
  toString() {
12567
- if (this.namePrimary && this.nameSecondary) {
12568
- return `[${ this.namePrimary },${ this.nameSecondary }]`;
12624
+ if (this.primaryId && this.secondaryId) {
12625
+ const primaryName = this.primaryId.name;
12626
+ const secondaryName = this.secondaryId.name;
12627
+ return `[${ primaryName },${ secondaryName }]`;
12569
12628
  }
12570
- return this.namePrimary;
12629
+ return this.primaryId.name;
12630
+ }
12631
+ hasPrimary() {
12632
+ return !!this.primaryId;
12571
12633
  }
12572
12634
  getPrimary() {
12573
- return new ImageIdWithOptions(this.namePrimary, { params: this.optionsPrimary ? this.optionsPrimary.params || {} : {} });
12635
+ return new ImageVariant(this.primaryId, this.primaryOptions);
12574
12636
  }
12575
- getSerializedPrimary() {
12576
- return this.getPrimary().serialize();
12637
+ hasSecondary() {
12638
+ return !!this.secondaryId;
12577
12639
  }
12578
12640
  getSecondary() {
12579
- if (this.nameSecondary) {
12580
- return new ImageIdWithOptions(this.nameSecondary, { params: this.optionsSecondary ? this.optionsSecondary.params || {} : {} });
12641
+ if (!this.secondaryId) {
12642
+ return null;
12581
12643
  }
12582
- return null;
12644
+ return new ImageVariant(this.secondaryId, this.secondaryOptions);
12583
12645
  }
12584
12646
  static from(image) {
12585
- return typeof image === 'string' ? ResolvedImage.build(image) : image;
12647
+ return typeof image === 'string' ? ResolvedImage.build({ name: image }) : image;
12586
12648
  }
12587
- static build(namePrimary, nameSecondary, optionsPrimary, optionsSecondary) {
12588
- if (!namePrimary)
12649
+ static build(primaryId, secondaryId, primaryOptions, secondaryOptions) {
12650
+ if (!primaryId || typeof primaryId === 'object' && !('name' in primaryId))
12589
12651
  return null;
12590
- return new ResolvedImage({
12591
- namePrimary,
12592
- nameSecondary,
12593
- optionsPrimary,
12594
- optionsSecondary,
12595
- available: false
12596
- });
12652
+ return new ResolvedImage(primaryId, primaryOptions, secondaryId, secondaryOptions);
12597
12653
  }
12598
12654
  }
12599
12655
 
@@ -12987,19 +13043,22 @@ class FormatExpression {
12987
13043
  }
12988
13044
 
12989
13045
  function isImageOptions(value) {
12990
- if (value !== null && typeof value === 'object' && !Array.isArray(value)) {
12991
- return true;
12992
- }
12993
- return false;
13046
+ return value !== null && typeof value === 'object' && !Array.isArray(value);
12994
13047
  }
12995
13048
  class ImageExpression {
12996
- constructor(inputPrimary, inputSecondary, inputPrimaryParams, inputSecondaryParams) {
13049
+ constructor(inputPrimary, inputSecondary, inputPrimaryOptions, inputSecondaryOptions) {
12997
13050
  this._imageWarnHistory = {};
12998
13051
  this.type = ResolvedImageType;
12999
- this.inputPrimary = inputPrimary;
13000
- this.inputSecondary = inputSecondary;
13001
- this.inputPrimaryParams = inputPrimaryParams;
13002
- this.inputSecondaryParams = inputSecondaryParams;
13052
+ this.namePrimary = inputPrimary;
13053
+ this.nameSecondary = inputSecondary;
13054
+ if (inputPrimaryOptions) {
13055
+ this.paramsPrimary = inputPrimaryOptions.params;
13056
+ this.iconsetIdPrimary = inputPrimaryOptions.iconset ? inputPrimaryOptions.iconset.id : void 0;
13057
+ }
13058
+ if (inputSecondaryOptions) {
13059
+ this.paramsSecondary = inputSecondaryOptions.params;
13060
+ this.iconsetIdSecondary = inputSecondaryOptions.iconset ? inputSecondaryOptions.iconset.id : void 0;
13061
+ }
13003
13062
  }
13004
13063
  static parse(args, context) {
13005
13064
  if (args.length < 2) {
@@ -13016,7 +13075,7 @@ class ImageExpression {
13016
13075
  }
13017
13076
  imageExpression.push({
13018
13077
  image: imageName,
13019
- options: void 0
13078
+ options: {}
13020
13079
  });
13021
13080
  return true;
13022
13081
  }
@@ -13024,33 +13083,48 @@ class ImageExpression {
13024
13083
  }
13025
13084
  function tryParseOptions() {
13026
13085
  if (nextArgId < args.length) {
13027
- if (!isImageOptions(args[nextArgId])) {
13086
+ const options = args[nextArgId];
13087
+ if (!isImageOptions(options)) {
13028
13088
  return true;
13029
13089
  }
13030
- const params = args[nextArgId].params;
13090
+ const params = options.params;
13091
+ const iconset = options.iconset;
13031
13092
  const optionsContext = context.concat(nextArgId);
13032
- if (!params) {
13093
+ if (!params && !iconset) {
13033
13094
  nextArgId++;
13034
13095
  return true;
13035
13096
  }
13036
- if (typeof params !== 'object' || params.constructor !== Object) {
13037
- optionsContext.error(`Image options "params" should be an object`);
13038
- return false;
13097
+ if (params) {
13098
+ if (typeof params !== 'object' || params.constructor !== Object) {
13099
+ optionsContext.error(`Image options "params" should be an object`);
13100
+ return false;
13101
+ }
13102
+ const parsedParams = {};
13103
+ const childContext = optionsContext.concat(void 0, 'params');
13104
+ for (const key in params) {
13105
+ if (!key) {
13106
+ childContext.error(`Image parameter name should be non-empty`);
13107
+ return false;
13108
+ }
13109
+ const value = childContext.concat(void 0, key).parse(params[key], void 0, ColorType, void 0, { typeAnnotation: 'coerce' });
13110
+ if (!value) {
13111
+ return false;
13112
+ }
13113
+ parsedParams[key] = value;
13114
+ }
13115
+ imageExpression[imageExpression.length - 1].options.params = parsedParams;
13039
13116
  }
13040
- const parsed = {};
13041
- const childContext = optionsContext.concat(void 0, 'params');
13042
- for (const key in params) {
13043
- if (!key) {
13044
- childContext.error(`Image parameter name should be non-empty`);
13117
+ if (iconset) {
13118
+ if (typeof iconset !== 'object' || iconset.constructor !== Object) {
13119
+ optionsContext.error(`Image options "iconset" should be an object`);
13045
13120
  return false;
13046
13121
  }
13047
- const value = childContext.concat(void 0, key).parse(params[key], void 0, ColorType, void 0, { typeAnnotation: 'coerce' });
13048
- if (!value) {
13122
+ if (!iconset.id) {
13123
+ optionsContext.error(`Image options "iconset" should have an "id" property`);
13049
13124
  return false;
13050
13125
  }
13051
- parsed[key] = value;
13126
+ imageExpression[imageExpression.length - 1].options.iconset = iconset;
13052
13127
  }
13053
- imageExpression[imageExpression.length - 1].options = parsed;
13054
13128
  nextArgId++;
13055
13129
  return true;
13056
13130
  }
@@ -13093,30 +13167,41 @@ class ImageExpression {
13093
13167
  return { params: result };
13094
13168
  }
13095
13169
  evaluate(ctx) {
13096
- const value = ResolvedImage.build(this.inputPrimary.evaluate(ctx), this.inputSecondary ? this.inputSecondary.evaluate(ctx) : void 0, this.inputPrimaryParams ? this.evaluateParams(ctx, this.inputPrimaryParams) : void 0, this.inputSecondaryParams ? this.evaluateParams(ctx, this.inputSecondaryParams) : void 0);
13170
+ const primaryId = {
13171
+ name: this.namePrimary.evaluate(ctx),
13172
+ iconsetId: this.iconsetIdPrimary
13173
+ };
13174
+ const secondaryId = this.nameSecondary ? {
13175
+ name: this.nameSecondary.evaluate(ctx),
13176
+ iconsetId: this.iconsetIdSecondary
13177
+ } : void 0;
13178
+ const value = ResolvedImage.build(primaryId, secondaryId, this.paramsPrimary ? this.evaluateParams(ctx, this.paramsPrimary) : void 0, this.paramsSecondary ? this.evaluateParams(ctx, this.paramsSecondary) : void 0);
13097
13179
  if (value && ctx.availableImages) {
13098
- value.available = ctx.availableImages.indexOf(value.namePrimary) > -1;
13099
- if (value.nameSecondary && value.available && ctx.availableImages) {
13100
- value.available = ctx.availableImages.indexOf(value.nameSecondary) > -1;
13180
+ const primaryId2 = value.getPrimary().id;
13181
+ value.available = ctx.availableImages.some(id => ImageId.isEqual(id, primaryId2));
13182
+ if (value.available) {
13183
+ const secondaryId2 = value.getSecondary() ? value.getSecondary().id : null;
13184
+ if (secondaryId2)
13185
+ value.available = ctx.availableImages.some(id => ImageId.isEqual(id, secondaryId2));
13101
13186
  }
13102
13187
  }
13103
13188
  return value;
13104
13189
  }
13105
13190
  eachChild(fn) {
13106
- fn(this.inputPrimary);
13107
- if (this.inputPrimaryParams) {
13108
- for (const key in this.inputPrimaryParams) {
13109
- if (this.inputPrimaryParams[key]) {
13110
- fn(this.inputPrimaryParams[key]);
13191
+ fn(this.namePrimary);
13192
+ if (this.paramsPrimary) {
13193
+ for (const key in this.paramsPrimary) {
13194
+ if (this.paramsPrimary[key]) {
13195
+ fn(this.paramsPrimary[key]);
13111
13196
  }
13112
13197
  }
13113
13198
  }
13114
- if (this.inputSecondary) {
13115
- fn(this.inputSecondary);
13116
- if (this.inputSecondaryParams) {
13117
- for (const key in this.inputSecondaryParams) {
13118
- if (this.inputSecondaryParams[key]) {
13119
- fn(this.inputSecondaryParams[key]);
13199
+ if (this.nameSecondary) {
13200
+ fn(this.nameSecondary);
13201
+ if (this.paramsSecondary) {
13202
+ for (const key in this.paramsSecondary) {
13203
+ if (this.paramsSecondary[key]) {
13204
+ fn(this.paramsSecondary[key]);
13120
13205
  }
13121
13206
  }
13122
13207
  }
@@ -13125,31 +13210,37 @@ class ImageExpression {
13125
13210
  outputDefined() {
13126
13211
  return false;
13127
13212
  }
13128
- serializeParams(params) {
13213
+ serializeOptions(params, iconsetId) {
13129
13214
  const result = {};
13215
+ if (iconsetId) {
13216
+ result.iconset = { id: iconsetId };
13217
+ }
13130
13218
  if (params) {
13219
+ result.params = {};
13131
13220
  for (const key in params) {
13132
13221
  if (params[key]) {
13133
- result[key] = params[key].serialize();
13222
+ result.params[key] = params[key].serialize();
13134
13223
  }
13135
13224
  }
13136
- } else {
13137
- return void 0;
13138
13225
  }
13139
- return { params: result };
13226
+ return Object.keys(result).length > 0 ? result : void 0;
13140
13227
  }
13141
13228
  serialize() {
13142
13229
  const serialized = [
13143
13230
  'image',
13144
- this.inputPrimary.serialize()
13231
+ this.namePrimary.serialize()
13145
13232
  ];
13146
- if (this.inputPrimaryParams) {
13147
- serialized.push(this.serializeParams(this.inputPrimaryParams));
13233
+ if (this.paramsPrimary || this.iconsetIdPrimary) {
13234
+ const options = this.serializeOptions(this.paramsPrimary, this.iconsetIdPrimary);
13235
+ if (options)
13236
+ serialized.push(options);
13148
13237
  }
13149
- if (this.inputSecondary) {
13150
- serialized.push(this.inputSecondary.serialize());
13151
- if (this.inputSecondaryParams) {
13152
- serialized.push(this.serializeParams(this.inputSecondaryParams));
13238
+ if (this.nameSecondary) {
13239
+ serialized.push(this.nameSecondary.serialize());
13240
+ if (this.paramsSecondary || this.iconsetIdSecondary) {
13241
+ const options = this.serializeOptions(this.paramsSecondary, this.iconsetIdSecondary);
13242
+ if (options)
13243
+ serialized.push(options);
13153
13244
  }
13154
13245
  }
13155
13246
  return serialized;