@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.cjs +215 -124
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +49 -36
- package/dist/index.es.js +215 -124
- package/dist/index.es.js.map +1 -1
- package/expression/definitions/image.ts +125 -71
- package/expression/evaluation_context.ts +2 -1
- package/expression/index.ts +11 -10
- package/expression/types/formatted.ts +7 -3
- package/expression/types/image_id.ts +61 -0
- package/expression/types/image_variant.ts +79 -0
- package/expression/types/resolved_image.ts +44 -53
- package/package.json +1 -1
- package/reference/v8.json +1 -1
- package/types/brand.ts +4 -0
- package/expression/types/image_id_with_options.ts +0 -58
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
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
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
|
|
1522
|
+
params?: Record<string, Color>;
|
|
1512
1523
|
transform?: DOMMatrix;
|
|
1513
1524
|
};
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
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
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1534
|
+
primaryId: ImageId;
|
|
1535
|
+
primaryOptions?: RasterizationOptions;
|
|
1536
|
+
secondaryId?: ImageId;
|
|
1537
|
+
secondaryOptions?: RasterizationOptions;
|
|
1526
1538
|
available: boolean;
|
|
1527
|
-
constructor(
|
|
1539
|
+
constructor(primaryId: string | ImageIdSpec, primaryOptions?: RasterizationOptions, secondaryId?: string | ImageIdSpec, secondaryOptions?: RasterizationOptions, available?: boolean);
|
|
1528
1540
|
toString(): string;
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1541
|
+
hasPrimary(): boolean;
|
|
1542
|
+
getPrimary(): ImageVariant;
|
|
1543
|
+
hasSecondary(): boolean;
|
|
1544
|
+
getSecondary(): ImageVariant | null;
|
|
1532
1545
|
static from(image: string | ResolvedImage): ResolvedImage;
|
|
1533
|
-
static build(
|
|
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:
|
|
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?:
|
|
1741
|
-
evaluate(globals: GlobalProperties, feature?: Feature, featureState?: FeatureState, canonical?: CanonicalTileID, availableImages?:
|
|
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?:
|
|
1754
|
-
evaluate(globals: GlobalProperties, feature?: Feature, featureState?: FeatureState, canonical?: CanonicalTileID, availableImages?:
|
|
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?:
|
|
1767
|
-
evaluate(globals: GlobalProperties, feature?: Feature, featureState?: FeatureState, canonical?: CanonicalTileID, availableImages?:
|
|
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?:
|
|
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?:
|
|
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?:
|
|
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?:
|
|
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 =>
|
|
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
|
-
|
|
12471
|
+
primaryId
|
|
12465
12472
|
]);
|
|
12466
12473
|
continue;
|
|
12467
12474
|
}
|
|
@@ -12485,11 +12492,57 @@ class Formatted {
|
|
|
12485
12492
|
}
|
|
12486
12493
|
}
|
|
12487
12494
|
|
|
12488
|
-
class
|
|
12489
|
-
constructor(id
|
|
12490
|
-
|
|
12491
|
-
|
|
12492
|
-
|
|
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} =
|
|
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
|
-
|
|
12514
|
-
|
|
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
|
|
12517
|
-
|
|
12518
|
-
|
|
12519
|
-
|
|
12520
|
-
|
|
12521
|
-
|
|
12522
|
-
|
|
12523
|
-
|
|
12524
|
-
|
|
12525
|
-
|
|
12526
|
-
|
|
12527
|
-
|
|
12528
|
-
|
|
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
|
|
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(
|
|
12554
|
-
this.
|
|
12555
|
-
|
|
12556
|
-
|
|
12557
|
-
|
|
12558
|
-
|
|
12559
|
-
|
|
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.
|
|
12568
|
-
|
|
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.
|
|
12629
|
+
return this.primaryId.name;
|
|
12630
|
+
}
|
|
12631
|
+
hasPrimary() {
|
|
12632
|
+
return !!this.primaryId;
|
|
12571
12633
|
}
|
|
12572
12634
|
getPrimary() {
|
|
12573
|
-
return new
|
|
12635
|
+
return new ImageVariant(this.primaryId, this.primaryOptions);
|
|
12574
12636
|
}
|
|
12575
|
-
|
|
12576
|
-
return this.
|
|
12637
|
+
hasSecondary() {
|
|
12638
|
+
return !!this.secondaryId;
|
|
12577
12639
|
}
|
|
12578
12640
|
getSecondary() {
|
|
12579
|
-
if (this.
|
|
12580
|
-
return
|
|
12641
|
+
if (!this.secondaryId) {
|
|
12642
|
+
return null;
|
|
12581
12643
|
}
|
|
12582
|
-
return
|
|
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(
|
|
12588
|
-
if (!
|
|
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
|
-
|
|
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,
|
|
13049
|
+
constructor(inputPrimary, inputSecondary, inputPrimaryOptions, inputSecondaryOptions) {
|
|
12997
13050
|
this._imageWarnHistory = {};
|
|
12998
13051
|
this.type = ResolvedImageType;
|
|
12999
|
-
this.
|
|
13000
|
-
this.
|
|
13001
|
-
|
|
13002
|
-
|
|
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:
|
|
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
|
-
|
|
13086
|
+
const options = args[nextArgId];
|
|
13087
|
+
if (!isImageOptions(options)) {
|
|
13028
13088
|
return true;
|
|
13029
13089
|
}
|
|
13030
|
-
const 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 (
|
|
13037
|
-
|
|
13038
|
-
|
|
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
|
-
|
|
13041
|
-
|
|
13042
|
-
|
|
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
|
-
|
|
13048
|
-
|
|
13122
|
+
if (!iconset.id) {
|
|
13123
|
+
optionsContext.error(`Image options "iconset" should have an "id" property`);
|
|
13049
13124
|
return false;
|
|
13050
13125
|
}
|
|
13051
|
-
|
|
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
|
|
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
|
-
|
|
13099
|
-
|
|
13100
|
-
|
|
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.
|
|
13107
|
-
if (this.
|
|
13108
|
-
for (const key in this.
|
|
13109
|
-
if (this.
|
|
13110
|
-
fn(this.
|
|
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.
|
|
13115
|
-
fn(this.
|
|
13116
|
-
if (this.
|
|
13117
|
-
for (const key in this.
|
|
13118
|
-
if (this.
|
|
13119
|
-
fn(this.
|
|
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
|
-
|
|
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
|
|
13226
|
+
return Object.keys(result).length > 0 ? result : void 0;
|
|
13140
13227
|
}
|
|
13141
13228
|
serialize() {
|
|
13142
13229
|
const serialized = [
|
|
13143
13230
|
'image',
|
|
13144
|
-
this.
|
|
13231
|
+
this.namePrimary.serialize()
|
|
13145
13232
|
];
|
|
13146
|
-
if (this.
|
|
13147
|
-
|
|
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.
|
|
13150
|
-
serialized.push(this.
|
|
13151
|
-
if (this.
|
|
13152
|
-
|
|
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;
|