@tangram.gl/basemap-layers 0.0.0-stage → 0.0.1

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 (105) hide show
  1. package/README.md +34 -2
  2. package/THIRD-PARTY-NOTICES.md +205 -0
  3. package/dist/geojson-worker.js +2160 -0
  4. package/dist/geojson-worker.js.map +6 -0
  5. package/dist/index.cjs +11388 -0
  6. package/dist/index.cjs.map +6 -0
  7. package/dist/index.js +11369 -0
  8. package/dist/index.js.map +6 -0
  9. package/dist/map-style.cjs +445 -0
  10. package/dist/map-style.cjs.map +6 -0
  11. package/dist/map-style.js +431 -0
  12. package/dist/map-style.js.map +6 -0
  13. package/dist/types/arabic-shaping.d.ts +7 -0
  14. package/dist/types/atmosphere-layer.d.ts +10 -0
  15. package/dist/types/basemap-layer.d.ts +150 -0
  16. package/dist/types/bidi.d.ts +8 -0
  17. package/dist/types/circle-layer.d.ts +49 -0
  18. package/dist/types/fill-extrusion-lighting-extension.d.ts +49 -0
  19. package/dist/types/fill-outline-extension.d.ts +22 -0
  20. package/dist/types/fill-pattern.d.ts +99 -0
  21. package/dist/types/fill-style-extensions.d.ts +100 -0
  22. package/dist/types/geojson-source.d.ts +29 -0
  23. package/dist/types/geojson-tiler.d.ts +48 -0
  24. package/dist/types/geojson-worker.d.ts +40 -0
  25. package/dist/types/globe-horizon-extension.d.ts +61 -0
  26. package/dist/types/globe-layers.d.ts +239 -0
  27. package/dist/types/globe-line-angle-extension.d.ts +37 -0
  28. package/dist/types/glyph-font-renderer.d.ts +37 -0
  29. package/dist/types/glyph-pbf.d.ts +37 -0
  30. package/dist/types/glyph-store.d.ts +103 -0
  31. package/dist/types/grid-index.d.ts +47 -0
  32. package/dist/types/hillshade-layer.d.ts +154 -0
  33. package/dist/types/index.d.ts +9 -0
  34. package/dist/types/is-globe-viewport.d.ts +2 -0
  35. package/dist/types/label-font-renderer.d.ts +18 -0
  36. package/dist/types/label-placement.d.ts +247 -0
  37. package/dist/types/label-text-layer.d.ts +231 -0
  38. package/dist/types/line-blur-extension.d.ts +73 -0
  39. package/dist/types/line-glyphs.d.ts +60 -0
  40. package/dist/types/line-placement.d.ts +93 -0
  41. package/dist/types/map-style-loader.d.ts +48 -0
  42. package/dist/types/map-style-schema.d.ts +72 -0
  43. package/dist/types/map-style.d.ts +6 -0
  44. package/dist/types/mapbox-style.d.ts +40 -0
  45. package/dist/types/mvt-label-layer.d.ts +923 -0
  46. package/dist/types/polylabel.d.ts +17 -0
  47. package/dist/types/raster-color-extension.d.ts +146 -0
  48. package/dist/types/shared-texture.d.ts +34 -0
  49. package/dist/types/sort-key.d.ts +10 -0
  50. package/dist/types/sprite.d.ts +82 -0
  51. package/dist/types/style-accessor.d.ts +45 -0
  52. package/dist/types/style-expression.d.ts +83 -0
  53. package/dist/types/style-resolver.d.ts +94 -0
  54. package/dist/types/text-font.d.ts +36 -0
  55. package/dist/types/text-halo-blur-extension.d.ts +55 -0
  56. package/dist/types/text-layout.d.ts +71 -0
  57. package/dist/types/util.d.ts +22 -0
  58. package/dist/types/zoom-paint-extension.d.ts +72 -0
  59. package/package.json +80 -3
  60. package/src/arabic-shaping.ts +366 -0
  61. package/src/atmosphere-layer.ts +19 -0
  62. package/src/basemap-layer.ts +533 -0
  63. package/src/bidi.ts +199 -0
  64. package/src/circle-layer.ts +191 -0
  65. package/src/fill-extrusion-lighting-extension.ts +206 -0
  66. package/src/fill-outline-extension.ts +70 -0
  67. package/src/fill-pattern.ts +400 -0
  68. package/src/fill-style-extensions.ts +177 -0
  69. package/src/geojson-source.ts +318 -0
  70. package/src/geojson-tiler.ts +185 -0
  71. package/src/geojson-worker.ts +98 -0
  72. package/src/globe-horizon-extension.ts +64 -0
  73. package/src/globe-layers.ts +3487 -0
  74. package/src/globe-line-angle-extension.ts +131 -0
  75. package/src/glyph-font-renderer.ts +173 -0
  76. package/src/glyph-pbf.ts +164 -0
  77. package/src/glyph-store.ts +326 -0
  78. package/src/grid-index.ts +177 -0
  79. package/src/hillshade-layer.ts +775 -0
  80. package/src/index.ts +18 -0
  81. package/src/is-globe-viewport.ts +24 -0
  82. package/src/label-font-renderer.ts +159 -0
  83. package/src/label-placement.ts +727 -0
  84. package/src/label-text-layer.ts +913 -0
  85. package/src/line-blur-extension.ts +237 -0
  86. package/src/line-glyphs.ts +364 -0
  87. package/src/line-placement.ts +446 -0
  88. package/src/map-style-loader.ts +56 -0
  89. package/src/map-style-schema.ts +83 -0
  90. package/src/map-style.ts +23 -0
  91. package/src/mapbox-style.ts +168 -0
  92. package/src/mvt-label-layer.ts +3744 -0
  93. package/src/polylabel.ts +312 -0
  94. package/src/raster-color-extension.ts +245 -0
  95. package/src/shared-texture.ts +153 -0
  96. package/src/sort-key.ts +63 -0
  97. package/src/sprite.ts +244 -0
  98. package/src/style-accessor.ts +95 -0
  99. package/src/style-expression.ts +327 -0
  100. package/src/style-resolver.ts +301 -0
  101. package/src/text-font.ts +150 -0
  102. package/src/text-halo-blur-extension.ts +115 -0
  103. package/src/text-layout.ts +441 -0
  104. package/src/util.ts +47 -0
  105. package/src/zoom-paint-extension.ts +207 -0
@@ -0,0 +1,17 @@
1
+ /** Default budget for one search: point-to-segment distance tests. */
2
+ export declare const DEFAULT_POLE_SEARCH_SEGMENT_TESTS = 5000000;
3
+ /** Remaining work, in point-to-segment distance tests, shared by the searches that use it. */
4
+ export type PoleSearchBudget = {
5
+ segmentTests: number;
6
+ };
7
+ /**
8
+ * Returns the point inside a polygon farthest from its outline, to within `precision` in the
9
+ * polygon's units. `polygon` is GeoJSON-style: an outer ring followed by hole rings. Coordinates
10
+ * must be planar.
11
+ *
12
+ * The search spends at most `budget.segmentTests` point-to-segment distance tests and deducts
13
+ * what it spends, so one budget can bound several searches. When the budget runs out the best
14
+ * point found so far is returned. Returns null for a polygon without vertices, with a non-finite
15
+ * coordinate, or when the budget cannot pay for the first scored point.
16
+ */
17
+ export declare function getPoleOfInaccessibility(polygon: number[][][], precision: number, budget?: PoleSearchBudget): [number, number] | null;
@@ -0,0 +1,146 @@
1
+ /**
2
+ * @license
3
+ * Portions of this file are adapted from MapLibre GL JS v6.13.0,
4
+ * src/shaders/glsl/raster.fragment.glsl,
5
+ * under these licenses (see also THIRD-PARTY-NOTICES.md):
6
+ *
7
+ * Copyright (c) 2023, MapLibre contributors
8
+ *
9
+ * All rights reserved.
10
+ *
11
+ * Redistribution and use in source and binary forms, with or without modification,
12
+ * are permitted provided that the following conditions are met:
13
+ *
14
+ * * Redistributions of source code must retain the above copyright notice,
15
+ * this list of conditions and the following disclaimer.
16
+ * * Redistributions in binary form must reproduce the above copyright notice,
17
+ * this list of conditions and the following disclaimer in the documentation
18
+ * and/or other materials provided with the distribution.
19
+ * * Neither the name of MapLibre GL JS nor the names of its contributors
20
+ * may be used to endorse or promote products derived from this software
21
+ * without specific prior written permission.
22
+ *
23
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
27
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
28
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
29
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+ *
35
+ * MapLibre GL JS contains code from mapbox-gl-js v1.13 and earlier, licensed under a
36
+ * BSD-3-Clause license:
37
+ *
38
+ * Copyright (c) 2020, Mapbox
39
+ * Redistribution and use in source and binary forms, with or without modification,
40
+ * are permitted provided that the following conditions are met:
41
+ *
42
+ * * Redistributions of source code must retain the above copyright notice,
43
+ * this list of conditions and the following disclaimer.
44
+ * * Redistributions in binary form must reproduce the above copyright notice,
45
+ * this list of conditions and the following disclaimer in the documentation
46
+ * and/or other materials provided with the distribution.
47
+ * * Neither the name of Mapbox GL JS nor the names of its contributors
48
+ * may be used to endorse or promote products derived from this software
49
+ * without specific prior written permission.
50
+ *
51
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
52
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
53
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
54
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
55
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
56
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
57
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
58
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
59
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
60
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
61
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
62
+ */
63
+ import { LayerExtension } from '@deck.gl/core';
64
+ import type { CompositeLayer, Layer } from '@deck.gl/core';
65
+ /** The style values of a raster layer's color adjustments, as evaluated from its paint. */
66
+ export type RasterColorAdjustments = {
67
+ /** `raster-brightness-min`, 0 to 1. */
68
+ brightnessMin: number;
69
+ /** `raster-brightness-max`, 0 to 1. */
70
+ brightnessMax: number;
71
+ /** `raster-saturation`, -1 to 1. */
72
+ saturation: number;
73
+ /** `raster-contrast`, -1 to 1. */
74
+ contrast: number;
75
+ /** `raster-hue-rotate`, in degrees. */
76
+ hueRotate: number;
77
+ };
78
+ /** The style specification's defaults, which leave colors unchanged. */
79
+ export declare const DEFAULT_RASTER_COLOR_ADJUSTMENTS: RasterColorAdjustments;
80
+ /** The shader uniforms of a set of color adjustments, computed as MapLibre GL JS does. */
81
+ export type RasterColorUniforms = {
82
+ brightnessLow: number;
83
+ brightnessHigh: number;
84
+ saturationFactor: number;
85
+ contrastFactor: number;
86
+ spinWeights: [number, number, number];
87
+ };
88
+ /** Converts color adjustments to shader uniforms, with MapLibre GL JS's `raster` program math. */
89
+ export declare function getRasterColorUniforms(adjustments: RasterColorAdjustments): RasterColorUniforms;
90
+ /** Whether a set of color adjustments changes any color. */
91
+ export declare function hasRasterColorAdjustments(adjustments: RasterColorAdjustments): boolean;
92
+ /** The blending of layers using `RasterColorExtension`, whose shader outputs premultiplied colors. */
93
+ export declare const RASTER_COLOR_BLEND_PARAMETERS: {
94
+ readonly blendColorOperation: "add";
95
+ readonly blendColorSrcFactor: "one";
96
+ readonly blendColorDstFactor: "one-minus-src-alpha";
97
+ readonly blendAlphaOperation: "add";
98
+ readonly blendAlphaSrcFactor: "one";
99
+ readonly blendAlphaDstFactor: "one-minus-src-alpha";
100
+ };
101
+ type RasterColorExtensionProps = {
102
+ /** The color adjustments of the raster style layer. */
103
+ rasterColorAdjustments?: RasterColorAdjustments;
104
+ };
105
+ /**
106
+ * Applies a raster style layer's `raster-brightness-min`, `raster-brightness-max`,
107
+ * `raster-saturation`, `raster-contrast` and `raster-hue-rotate` to a `BitmapLayer`, with the
108
+ * formulas of MapLibre GL JS's raster shader. WebGL only.
109
+ *
110
+ * The adjusted colors are premultiplied, so the layer must blend with
111
+ * `RASTER_COLOR_BLEND_PARAMETERS` exactly where the shader runs. Added to a composite layer, the
112
+ * extension passes them to its sublayers as `rasterColorBlendParameters`, decided by the same
113
+ * device check as the shader; on WebGPU they are `null` and the sublayers keep their blending.
114
+ */
115
+ export declare class RasterColorExtension extends LayerExtension {
116
+ static extensionName: string;
117
+ static defaultProps: {
118
+ rasterColorAdjustments: {
119
+ type: string;
120
+ value: RasterColorAdjustments;
121
+ compare: number;
122
+ };
123
+ };
124
+ getShaders(this: Layer<RasterColorExtensionProps>): {
125
+ modules?: undefined;
126
+ inject?: undefined;
127
+ } | {
128
+ modules: {
129
+ readonly name: "rasterColor";
130
+ readonly fs: "layout(std140) uniform rasterColorUniforms {\n float brightnessLow;\n float brightnessHigh;\n float saturationFactor;\n float contrastFactor;\n vec3 spinWeights;\n} rasterColor;\n\n// MapLibre GL JS's raster fragment shader, applied to an unpremultiplied color.\nvec3 rasterColor_adjust(vec3 color) {\n vec3 rgb = vec3(\n dot(color, rasterColor.spinWeights.xyz),\n dot(color, rasterColor.spinWeights.zxy),\n dot(color, rasterColor.spinWeights.yzx)\n );\n float average = (color.r + color.g + color.b) / 3.0;\n rgb += (average - rgb) * rasterColor.saturationFactor;\n rgb = (rgb - 0.5) * rasterColor.contrastFactor + 0.5;\n return mix(vec3(rasterColor.brightnessLow), vec3(rasterColor.brightnessHigh), rgb);\n}\n";
131
+ readonly uniformTypes: {
132
+ readonly brightnessLow: "f32";
133
+ readonly brightnessHigh: "f32";
134
+ readonly saturationFactor: "f32";
135
+ readonly contrastFactor: "f32";
136
+ readonly spinWeights: "vec3<f32>";
137
+ };
138
+ }[];
139
+ inject: {
140
+ 'fs:DECKGL_FILTER_COLOR': string;
141
+ };
142
+ };
143
+ getSubLayerProps(this: CompositeLayer<RasterColorExtensionProps>, extension: this): any;
144
+ draw(this: Layer<RasterColorExtensionProps>): void;
145
+ }
146
+ export {};
@@ -0,0 +1,34 @@
1
+ import type { Device, Texture } from '@luma.gl/core';
2
+ /** Options of a `SharedTextureSet`. Sets with different options share no textures. */
3
+ export type SharedTextureOptions = {
4
+ /**
5
+ * Most mip levels of a texture, the full image included: 1 for none. Default: the full chain.
6
+ * Fewer levels keep a minified texture sharper, at the cost of aliasing beyond the last level.
7
+ */
8
+ maxMipLevels?: number;
9
+ };
10
+ /**
11
+ * The textures one layer uses, shared with every other layer that uses the same image on the
12
+ * same device. deck.gl creates a texture, and uploads the image, for each layer that is handed an
13
+ * image: every label sublayer of every tile would upload the same font atlas and sprite sheet. A
14
+ * shared texture is created on first use and destroyed when its last user releases it.
15
+ */
16
+ export declare class SharedTextureSet {
17
+ private device;
18
+ private images;
19
+ /** The options, as given at construction: they are part of the cache key. */
20
+ readonly options: Readonly<SharedTextureOptions>;
21
+ private optionsKey;
22
+ constructor(device: Device, { maxMipLevels }?: SharedTextureOptions);
23
+ /** The textures shared by the sets with this set's options on its device. */
24
+ private getTextures;
25
+ /** Returns the shared texture of `image`, which this set uses until `retainOnly` drops it. */
26
+ get(image: object): Texture;
27
+ /** Releases the textures of every image this set uses that is not in `images`. */
28
+ retainOnly(images: Iterable<object>): void;
29
+ /** Releases every texture this set uses. */
30
+ releaseAll(): void;
31
+ private release;
32
+ }
33
+ /** The number of shared textures alive on a device, for tests. */
34
+ export declare function getSharedTextureCount(device: Device): number;
@@ -0,0 +1,10 @@
1
+ import type { ResolvedBasemapStyleLayer as BasemapStyleLayer } from "./style-resolver.js";
2
+ /**
3
+ * A tile's features of a style layer in the order of their sort key (`circle-sort-key`,
4
+ * `line-sort-key`), ascending, as MapLibre GL JS orders a bucket: features with a higher key draw
5
+ * over those with a lower one, and features with the same key keep their tile order. Without a
6
+ * per-feature key, the features are returned as they are. The sorted array is reused while the
7
+ * features, the key and (for a key that depends on zoom) the style zoom are unchanged, so deck.gl
8
+ * does not re-tessellate the features at every zoom step.
9
+ */
10
+ export declare function sortFeaturesByKey(features: any[], styleLayer: BasemapStyleLayer, propertyName: 'circle-sort-key' | 'line-sort-key', zoom: number): any[];
@@ -0,0 +1,82 @@
1
+ import type { BasemapLoadOptions } from "./style-resolver.js";
2
+ /** One image in a style sprite, as listed in the sprite's JSON index. */
3
+ export type SpriteImage = {
4
+ x: number;
5
+ y: number;
6
+ width: number;
7
+ height: number;
8
+ /** Device pixels per CSS pixel of the image. Default 1. */
9
+ pixelRatio?: number;
10
+ /** `true` for signed-distance-field images, which are tinted with `icon-color`. */
11
+ sdf?: boolean;
12
+ };
13
+ /** A deck.gl `IconLayer` mapping entry for one sprite image. */
14
+ export type SpriteIconMappingEntry = {
15
+ x: number;
16
+ y: number;
17
+ width: number;
18
+ height: number;
19
+ /** `true` for SDF images: deck.gl tints masked icons with `getColor`. */
20
+ mask: boolean;
21
+ /** Device pixels per CSS pixel; `icon-size` scales `height / pixelRatio`. */
22
+ pixelRatio: number;
23
+ };
24
+ /** A loaded sprite: the atlas image and its deck.gl icon mapping. */
25
+ export type SpriteAtlas = {
26
+ /**
27
+ * Sprite id. `'default'` for a style whose `sprite` is a single URL; otherwise the id from the
28
+ * style's sprite array, which prefixes its image names as `id:name`.
29
+ */
30
+ id: string;
31
+ /**
32
+ * The atlas image, decoded once and shared by every icon layer, or its URL where
33
+ * `createImageBitmap` is unavailable (each `IconLayer` then loads the URL itself).
34
+ */
35
+ image: ImageBitmap | string;
36
+ /** Icon mapping keyed by image name, without the `id:` prefix. */
37
+ mapping: Record<string, SpriteIconMappingEntry>;
38
+ };
39
+ /** A style's `sprite` value: a URL, or the array form with one `{id, url}` per sprite. */
40
+ export type StyleSprite = string | Array<{
41
+ id: string;
42
+ url: string;
43
+ }>;
44
+ /** A sprite source after relative URLs are resolved. */
45
+ export type SpriteSource = {
46
+ id: string;
47
+ url: string;
48
+ };
49
+ /** Options for {@link loadSpriteAtlases}. */
50
+ export type SpriteLoadOptions = {
51
+ /** Base URL that relative sprite URLs resolve against, normally the style URL. */
52
+ baseUrl?: string;
53
+ /** Device pixel ratio. At 2 or more, the `@2x` sprite is requested first. Default 1. */
54
+ pixelRatio?: number;
55
+ } & Pick<NonNullable<BasemapLoadOptions>, 'fetch' | 'fetchOptions'>;
56
+ /** Resolves a style's `sprite` value into sprite sources with absolute URLs. */
57
+ export declare function getSpriteSources(sprite: unknown, baseUrl?: string): SpriteSource[];
58
+ /** Converts a sprite JSON index into a deck.gl `IconLayer` mapping. */
59
+ export declare function getSpriteIconMapping(index: Record<string, SpriteImage>): Record<string, SpriteIconMappingEntry>;
60
+ /**
61
+ * Loads every sprite a style references. A sprite that fails to load is skipped with a warning,
62
+ * so its icons are not drawn and the rest of the style still renders.
63
+ */
64
+ export declare function loadSpriteAtlases(sprite: unknown, options?: SpriteLoadOptions): Promise<SpriteAtlas[]>;
65
+ /**
66
+ * The image names `icon-image` can reference: unprefixed for the `'default'` sprite and `id:name`
67
+ * for the others. Passed to expression evaluation so `["image", ...]` sees which images exist.
68
+ */
69
+ export declare function getSpriteImageNames(atlases: readonly SpriteAtlas[] | null | undefined): string[];
70
+ /** An icon resolved against the loaded sprites. */
71
+ export type ResolvedSpriteIcon = {
72
+ atlas: SpriteAtlas;
73
+ name: string;
74
+ entry: SpriteIconMappingEntry;
75
+ };
76
+ /**
77
+ * Finds the sprite and mapping entry for an `icon-image` name. Names from the `'default'` sprite
78
+ * are unprefixed; names from other sprites are written `id:name`, as in MapLibre.
79
+ */
80
+ export declare function resolveSpriteIcon(atlases: readonly SpriteAtlas[] | undefined, iconImage: string): ResolvedSpriteIcon | null;
81
+ /** Warns once per icon name that a style references an image no loaded sprite contains. */
82
+ export declare function warnMissingIcon(iconImage: string): void;
@@ -0,0 +1,45 @@
1
+ import { type StyleFeature } from "./style-expression.js";
2
+ type StyleLayerLike = {
3
+ paint?: Record<string, unknown>;
4
+ layout?: Record<string, unknown>;
5
+ };
6
+ /**
7
+ * Zoom step at which style values are evaluated. Paint and layout values step every
8
+ * `STYLE_ZOOM_STEP` zoom levels instead of following the zoom continuously.
9
+ */
10
+ export declare const STYLE_ZOOM_STEP = 0.25;
11
+ /**
12
+ * Zoom at which paint and layout values are evaluated: the zoom rounded down to a
13
+ * `STYLE_ZOOM_STEP`.
14
+ *
15
+ * This is a temporary simplification, not MapLibre's behaviour. MapLibre evaluates zoom-dependent
16
+ * expressions at the integer zooms on either side of the current zoom and interpolates between
17
+ * them on the GPU, which remains the long-term plan here. Stepping keeps every tile on the same
18
+ * evaluation zoom, so neighbouring tiles agree at their seams.
19
+ */
20
+ export declare function getZoomBucket(zoom: number): number;
21
+ /** Zoom at which filters are evaluated: the integer zoom, as the style spec specifies. */
22
+ export declare function getFilterZoom(zoom: number): number;
23
+ /**
24
+ * A key that changes whenever style evaluation or layer visibility changes: at every
25
+ * `STYLE_ZOOM_STEP` (which includes every integer zoom, where filters change), and at every
26
+ * fractional `minzoom`/`maxzoom` in `zoomLimits`. Layer visibility uses the exact zoom, as in
27
+ * MapLibre, so crossing a fractional limit must regenerate sublayers too.
28
+ */
29
+ export declare function getStyleZoomKey(zoom: number, zoomLimits: readonly (number | undefined)[]): string;
30
+ /** A deck.gl accessor built from one or more style properties. */
31
+ export type StyleAccessor<T> = {
32
+ /** A constant when no property depends on feature data, otherwise a per-feature function. */
33
+ value: T | ((feature: StyleFeature) => T);
34
+ /** Set to the evaluation zoom (`getZoomBucket`) when a per-feature value also depends on zoom. */
35
+ updateTrigger?: number;
36
+ };
37
+ /**
38
+ * Builds a deck.gl accessor from style properties, evaluated at the stepped zoom
39
+ * (`getZoomBucket`). Feature-independent values become constants. Data-driven values become
40
+ * per-feature functions, with an update trigger when they also depend on zoom.
41
+ */
42
+ export declare function getStyleAccessor<T>(styleLayer: StyleLayerLike, propertyNames: string[], zoom: number, combine: (values: any[]) => T): StyleAccessor<T>;
43
+ /** Converts a style color (alpha 0-1 or 0-255) and opacity into a deck.gl RGBA color. */
44
+ export declare function withOpacity(color: number[] | null | undefined, opacity?: number): [number, number, number, number];
45
+ export {};
@@ -0,0 +1,83 @@
1
+ import { Color } from '@maplibre/maplibre-gl-style-spec';
2
+ /** A feature as seen by style expressions: a GeoJSON feature or a numeric-typed tile feature. */
3
+ export type StyleFeature = {
4
+ type?: number | string;
5
+ id?: unknown;
6
+ geometry?: {
7
+ type: string;
8
+ };
9
+ properties?: Record<string, unknown>;
10
+ };
11
+ /** A style property compiled once and evaluated per zoom and feature. */
12
+ export type CompiledStyleProperty = {
13
+ /** True when the value depends on `["zoom"]`. */
14
+ isZoomDependent: boolean;
15
+ /** True when the value depends on feature data (`["get", ...]`, `match`, ...). */
16
+ isFeatureDependent: boolean;
17
+ /**
18
+ * Evaluates the property. Colors are returned as `[r, g, b, a]`, with `a` in 0-1.
19
+ * `availableImages` lists the loaded sprite image names, which `["image", ...]` checks.
20
+ */
21
+ evaluate: (zoom: number, feature?: StyleFeature, availableImages?: string[]) => unknown;
22
+ /**
23
+ * Evaluates the property with every global input, such as `heatmapDensity` or `lineProgress`
24
+ * as well as `zoom`. Colors are returned as in `evaluate`.
25
+ */
26
+ evaluateWithGlobals: (globals: Record<string, unknown>, feature?: StyleFeature) => unknown;
27
+ };
28
+ type StyleLayerLike = {
29
+ paint?: Record<string, unknown>;
30
+ layout?: Record<string, unknown>;
31
+ };
32
+ type PropertyReference = Record<string, unknown> | null;
33
+ type StyleFilter = (globalProperties: Record<string, unknown>, feature: StyleFeature) => boolean;
34
+ /** Returns whether a style property is a `layout` or a `paint` property. */
35
+ export declare function getStylePropertyType(propertyName: string): 'layout' | 'paint';
36
+ /** Resolves the style-spec reference metadata for a layout or paint property name. */
37
+ export declare function getStylePropertyReference(propertyName: string): PropertyReference;
38
+ /** Returns the style-spec geometry type code (1 point, 2 line, 3 polygon) of a feature. */
39
+ export declare function getStyleGeometryType(feature: StyleFeature): number | undefined;
40
+ /**
41
+ * Converts a style-spec color to `[r, g, b, a]` with RGB in 0-255 and alpha in 0-1, the shape
42
+ * `@mapbox/mapbox-gl-style-spec`'s `Color#toArray()` returned. MapLibre's `Color` stores
43
+ * premultiplied components; its `rgb` getter returns them un-premultiplied in 0-1.
44
+ */
45
+ export declare function colorToArray(color: Color): [number, number, number, number];
46
+ /**
47
+ * Returns the style specification's default for a property, in the shape `evaluate` returns:
48
+ * colors as `[r, g, b, a]`, paddings as `[top, right, bottom, left]`. Undefined for a property
49
+ * without a default.
50
+ */
51
+ export declare function getStylePropertyDefault(propertyName: string): unknown;
52
+ /**
53
+ * Compiles a single property value against its style-spec reference. Returns `null` and logs a
54
+ * warning once for a value the style spec rejects, so the property is treated as unset, as
55
+ * MapLibre skips invalid properties.
56
+ */
57
+ export declare function compileStylePropertyValue(propertyName: string, value: unknown): CompiledStyleProperty | null;
58
+ /**
59
+ * Returns a compiled `paint` or `layout` property of a style layer, or `null` when the layer
60
+ * does not set it. Compilation is cached per style layer object and property; the cached entry is
61
+ * reused only while the layer still holds the same value, so editing a property in place
62
+ * recompiles it.
63
+ */
64
+ export declare function getCompiledStyleProperty(styleLayer: StyleLayerLike, propertyName: string): CompiledStyleProperty | null;
65
+ /**
66
+ * Compiles a style-spec filter into a feature predicate, cached per filter array. The cached
67
+ * predicate is reused only while the array's contents are unchanged, so a filter edited in place
68
+ * is recompiled. A filter the style spec rejects logs a warning once and matches no features.
69
+ */
70
+ export declare function compileStyleFilter(filter: unknown): StyleFilter;
71
+ /** A style's `light`, evaluated at one zoom. Colors are `[r, g, b, a]`, RGB in 0-255. */
72
+ export type EvaluatedStyleLight = {
73
+ anchor: unknown;
74
+ position: unknown;
75
+ color: unknown;
76
+ intensity: unknown;
77
+ };
78
+ /**
79
+ * Evaluates a style's `light` at a zoom, property by property. A property the style does not set,
80
+ * or sets to a value the style spec rejects (logged once), takes the spec's default.
81
+ */
82
+ export declare function evaluateStyleLight(light: unknown, zoom: number): EvaluatedStyleLight;
83
+ export {};
@@ -0,0 +1,94 @@
1
+ /**
2
+ * A basemap source entry from a style document.
3
+ */
4
+ export type BasemapSource = {
5
+ /** Source kind such as `vector` or `raster`. */
6
+ type?: string;
7
+ /** Optional TileJSON URL used to resolve the source metadata. */
8
+ url?: string;
9
+ /** Inline tile templates for the source. */
10
+ tiles?: string[];
11
+ /** Minimum source zoom, when supplied by the style or TileJSON. */
12
+ minzoom?: number;
13
+ /** Maximum source zoom, when supplied by the style or TileJSON. */
14
+ maxzoom?: number;
15
+ /** Tile size in pixels. */
16
+ tileSize?: number;
17
+ /** Additional source properties are preserved verbatim. */
18
+ [key: string]: unknown;
19
+ };
20
+ /**
21
+ * A style layer entry used by the basemap runtime.
22
+ */
23
+ export type BasemapStyleLayer = {
24
+ /** Unique layer identifier. */
25
+ id: string;
26
+ /** Optional concrete style layer type such as `background`, `fill`, `line`, or `raster`. */
27
+ type?: string;
28
+ /** Legacy style layer id whose structural render properties are inherited. */
29
+ ref?: string;
30
+ /** Referenced source identifier. */
31
+ source?: string;
32
+ /** Referenced vector source-layer identifier. */
33
+ 'source-layer'?: string;
34
+ /** Optional minimum zoom. */
35
+ minzoom?: number;
36
+ /** Optional maximum zoom. */
37
+ maxzoom?: number;
38
+ /** Optional style-spec filter expression. */
39
+ filter?: unknown[];
40
+ /** Paint properties from the source style layer. */
41
+ paint?: Record<string, unknown>;
42
+ /** Layout properties from the source style layer. */
43
+ layout?: Record<string, unknown>;
44
+ /** Additional layer properties are preserved verbatim. */
45
+ [key: string]: unknown;
46
+ };
47
+ /** A style layer after legacy `ref` inheritance has been resolved. */
48
+ export type ResolvedBasemapStyleLayer = BasemapStyleLayer & {
49
+ /** Concrete style layer type after optional `ref` inheritance. */
50
+ type: string;
51
+ };
52
+ /**
53
+ * A MapLibre or Mapbox style document consumed by the basemap runtime.
54
+ */
55
+ export type BasemapStyle = {
56
+ /** Style-spec version number. */
57
+ version?: number;
58
+ /** Optional style metadata bag. */
59
+ metadata?: Record<string, unknown>;
60
+ /** Named source definitions used by the style. */
61
+ sources?: Record<string, BasemapSource>;
62
+ /** Ordered list of style layers. */
63
+ layers?: BasemapStyleLayer[];
64
+ /** Additional style properties are preserved verbatim. */
65
+ [key: string]: unknown;
66
+ };
67
+ /**
68
+ * A style document after all sources have been normalized and TileJSON-backed
69
+ * sources have been resolved.
70
+ */
71
+ export type ResolvedBasemapStyle = Omit<BasemapStyle, 'sources' | 'layers'> & {
72
+ /** Fully resolved source definitions. */
73
+ sources: Record<string, BasemapSource>;
74
+ /** Style layers copied into a mutable array. */
75
+ layers: ResolvedBasemapStyleLayer[];
76
+ };
77
+ /**
78
+ * Load options accepted by {@link resolveBasemapStyle}.
79
+ */
80
+ export type BasemapLoadOptions = {
81
+ /** Base URL used to resolve relative source or tile URLs for in-memory styles. */
82
+ baseUrl?: string;
83
+ /** Optional custom fetch implementation. */
84
+ fetch?: typeof fetch;
85
+ /** Optional init object passed to the selected fetch implementation. */
86
+ fetchOptions?: RequestInit;
87
+ /** Additional loader options are accepted for forward compatibility. */
88
+ [key: string]: unknown;
89
+ } | null;
90
+ /**
91
+ * Resolves a basemap style input into a style object whose sources contain
92
+ * directly consumable tile templates and source metadata.
93
+ */
94
+ export declare function resolveBasemapStyle(style: string | BasemapStyle, loadOptions?: BasemapLoadOptions): Promise<ResolvedBasemapStyle>;
@@ -0,0 +1,36 @@
1
+ /**
2
+ * A label font as CSS: a family list ending with a generic family, a numeric weight and a style.
3
+ */
4
+ export type LabelFont = {
5
+ /** CSS `font-family` list, e.g. `"Noto Sans", sans-serif`. */
6
+ fontFamily: string;
7
+ /** CSS numeric `font-weight`, 100-900. */
8
+ fontWeight: number;
9
+ /** CSS `font-style`. */
10
+ fontStyle: 'normal' | 'italic';
11
+ };
12
+ /**
13
+ * Overrides the label font derived from `text-font`. A string is the CSS family list for every
14
+ * label; the weight and style still come from `text-font`. A function receives the evaluated
15
+ * `text-font` names and returns a CSS family list, or any of the {@link LabelFont} fields; fields
16
+ * it leaves out, or a `null` result, keep the mapped values.
17
+ */
18
+ export type LabelFontFamily = string | ((fontStack: string[]) => string | Partial<LabelFont> | null | undefined);
19
+ /** The style specification's default `text-font`. */
20
+ export declare const DEFAULT_TEXT_FONT: string[];
21
+ /**
22
+ * Maps a style's `text-font` stack to a CSS font. Each name's trailing weight and style words
23
+ * (`Regular`, `Bold`, `Semibold Italic`, ...) are stripped to give its family; the families are
24
+ * listed in stack order and end with a generic family, so labels still draw when none of the
25
+ * fonts is installed. `TextLayer` takes one weight per layer, so the weight and style come from
26
+ * the first font of the stack.
27
+ */
28
+ export declare function getLabelFont(fontStack: string[]): LabelFont;
29
+ /** {@link getLabelFont}, with the caller's {@link LabelFontFamily} override applied. */
30
+ export declare function resolveLabelFont(fontStack: string[], fontFamily?: LabelFontFamily | null): LabelFont;
31
+ /**
32
+ * `TextLayer`'s `fontWeight` prop for a font. `TextLayer` has no `fontStyle` prop and writes
33
+ * `fontWeight` in front of the size in the canvas font string, so an italic font puts its style
34
+ * in front of the weight there (`italic 400`), which is valid CSS font shorthand.
35
+ */
36
+ export declare function getTextLayerFontWeight(font: LabelFont): number | string;
@@ -0,0 +1,55 @@
1
+ import { LayerExtension } from '@deck.gl/core';
2
+ import type { Layer } from '@deck.gl/core';
3
+ /**
4
+ * Converts a `text-halo-blur`, in pixels, to the signed distance by which `TextLayer`'s halo edge
5
+ * fades on each side, beyond the edge's own smoothing, for text of `textSize` pixels drawn from a
6
+ * font atlas of `fontSize` pixels whose distance field reaches `radius` atlas pixels. As in
7
+ * MapLibre, the fade is `1.19 * blur` screen pixels on each side of the halo edge; an atlas pixel
8
+ * is `textSize / fontSize` screen pixels and `1 / radius` of the distance field.
9
+ */
10
+ export declare function getHaloBlurGamma(haloBlur: number, textSize: number, { fontSize, radius }: {
11
+ fontSize: number;
12
+ radius: number;
13
+ }): number;
14
+ type TextHaloBlurExtensionProps = {
15
+ /** Distance by which the halo edge fades on each side, see {@link getHaloBlurGamma}. */
16
+ textHaloBlurGamma?: number;
17
+ /**
18
+ * Whether the fade ends where the distance field does (default), or reaches past it and is cut
19
+ * at the glyph's quad, as MapLibre GL JS draws its glyphs.
20
+ */
21
+ textHaloBlurCapped?: boolean;
22
+ };
23
+ /**
24
+ * Blurs the halo of a `LabelTextLayer`, as MapLibre GL JS draws `text-halo-blur`: the halo edge
25
+ * fades over `textHaloBlurGamma` more distance on each side, beyond its own antialiasing of 0.84
26
+ * device pixels (see `LabelCharactersLayer`), as MapLibre's. Labels that lie on a pitched map fade
27
+ * over 1 / cos(pitch) times that distance, blur and antialiasing alike, as MapLibre's (see
28
+ * `getLabelForeshortening`). The glyphs stay as sharp as without the extension. WebGL only; on
29
+ * WebGPU the halo draws without blur.
30
+ */
31
+ export declare class TextHaloBlurExtension extends LayerExtension {
32
+ static extensionName: string;
33
+ static defaultProps: {
34
+ textHaloBlurGamma: number;
35
+ textHaloBlurCapped: boolean;
36
+ };
37
+ getShaders(this: Layer<TextHaloBlurExtensionProps>): {
38
+ modules?: undefined;
39
+ inject?: undefined;
40
+ } | {
41
+ modules: {
42
+ readonly name: "textHaloBlur";
43
+ readonly fs: "layout(std140) uniform textHaloBlurUniforms {\n float gamma;\n float capped;\n} textHaloBlur;\n";
44
+ readonly uniformTypes: {
45
+ readonly gamma: "f32";
46
+ readonly capped: "f32";
47
+ };
48
+ }[];
49
+ inject: {
50
+ "alpha = inBorder;": string;
51
+ };
52
+ };
53
+ draw(this: Layer<TextHaloBlurExtensionProps>): void;
54
+ }
55
+ export {};