@tangram.gl/basemap-layers 0.0.0 → 10.0.0-alpha.3

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 (139) hide show
  1. package/README.md +12 -7
  2. package/THIRD-PARTY-NOTICES.md +7 -5
  3. package/dist/geojson-task-worker.js +3166 -0
  4. package/dist/geojson-task-worker.js.map +6 -0
  5. package/dist/geojson-worker.js +1089 -7
  6. package/dist/geojson-worker.js.map +3 -3
  7. package/dist/index.cjs +9588 -2093
  8. package/dist/index.cjs.map +3 -3
  9. package/dist/index.js +9599 -2090
  10. package/dist/index.js.map +3 -3
  11. package/dist/map-style.cjs +456 -20
  12. package/dist/map-style.cjs.map +3 -3
  13. package/dist/map-style.js +456 -19
  14. package/dist/map-style.js.map +2 -2
  15. package/dist/types/basemap-error.d.ts +52 -0
  16. package/dist/types/basemap-layer.d.ts +378 -25
  17. package/dist/types/basemap-protocol.d.ts +91 -0
  18. package/dist/types/basemap-request.d.ts +73 -0
  19. package/dist/types/circle-layer.d.ts +65 -8
  20. package/dist/types/color-relief-layer.d.ts +184 -0
  21. package/dist/types/dem-pixels.d.ts +40 -0
  22. package/dist/types/feature-state.d.ts +55 -0
  23. package/dist/types/fill-extrusion-lighting-extension.d.ts +1 -2
  24. package/dist/types/fill-outline-extension.d.ts +2 -3
  25. package/dist/types/fill-pattern.d.ts +35 -3
  26. package/dist/types/fill-style-extensions.d.ts +11 -59
  27. package/dist/types/geojson-resource.d.ts +18 -0
  28. package/dist/types/geojson-source.d.ts +13 -2
  29. package/dist/types/geojson-task-handler.d.ts +2 -0
  30. package/dist/types/geojson-task.d.ts +26 -0
  31. package/dist/types/geojson-tiler.d.ts +29 -2
  32. package/dist/types/geojson-worker.d.ts +5 -1
  33. package/dist/types/globe-horizon-extension.d.ts +2 -45
  34. package/dist/types/globe-layers.d.ts +141 -45
  35. package/dist/types/globe-line-angle-extension.d.ts +20 -17
  36. package/dist/types/glyph-store.d.ts +10 -1
  37. package/dist/types/heatmap-layer.d.ts +99 -0
  38. package/dist/types/hillshade-layer.d.ts +159 -27
  39. package/dist/types/icon-text-fit.d.ts +92 -0
  40. package/dist/types/image-source-layer.d.ts +142 -0
  41. package/dist/types/index.d.ts +25 -1
  42. package/dist/types/line-blur-extension.d.ts +3 -11
  43. package/dist/types/line-dash-extension.d.ts +53 -0
  44. package/dist/types/line-gradient-extension.d.ts +69 -0
  45. package/dist/types/line-metrics.d.ts +24 -0
  46. package/dist/types/line-pattern-extension.d.ts +50 -0
  47. package/dist/types/line-shape-extension.d.ts +76 -0
  48. package/dist/types/map-style-loader.d.ts +1 -1
  49. package/dist/types/map-style.d.ts +2 -2
  50. package/dist/types/mvt-label-layer.d.ts +111 -20
  51. package/dist/types/pmtiles-source.d.ts +38 -0
  52. package/dist/types/projected-background-layer.d.ts +63 -0
  53. package/dist/types/projected-bitmap-layer.d.ts +58 -0
  54. package/dist/types/projected-tile-data.d.ts +16 -0
  55. package/dist/types/projected-tile-selection.d.ts +72 -0
  56. package/dist/types/projected-tileset.d.ts +92 -0
  57. package/dist/types/projected-viewport.d.ts +76 -0
  58. package/dist/types/raster-color-extension.d.ts +4 -7
  59. package/dist/types/raster-fade.d.ts +155 -0
  60. package/dist/types/raster-tile-fingerprint.d.ts +11 -0
  61. package/dist/types/raster-tile-loader.d.ts +80 -0
  62. package/dist/types/shader-injection-plugin.d.ts +8 -0
  63. package/dist/types/source-features.d.ts +58 -0
  64. package/dist/types/source-tiles.d.ts +32 -0
  65. package/dist/types/sprite.d.ts +37 -3
  66. package/dist/types/stretch-icon-layer.d.ts +28 -0
  67. package/dist/types/style-accessor.d.ts +50 -12
  68. package/dist/types/style-expression.d.ts +22 -2
  69. package/dist/types/style-resolver.d.ts +47 -2
  70. package/dist/types/terrain-query.d.ts +39 -0
  71. package/dist/types/zoom-load-gate.d.ts +22 -0
  72. package/dist/types/zoom-paint-extension.d.ts +80 -11
  73. package/package.json +24 -21
  74. package/src/basemap-error.ts +82 -0
  75. package/src/basemap-layer.ts +1289 -101
  76. package/src/basemap-protocol.ts +353 -0
  77. package/src/basemap-request.ts +212 -0
  78. package/src/circle-layer.ts +430 -54
  79. package/src/color-relief-layer.ts +572 -0
  80. package/src/dem-pixels.ts +174 -0
  81. package/src/feature-state.ts +164 -0
  82. package/src/fill-extrusion-lighting-extension.ts +126 -9
  83. package/src/fill-outline-extension.ts +4 -4
  84. package/src/fill-pattern.ts +87 -9
  85. package/src/fill-style-extensions.ts +114 -44
  86. package/src/geojson-resource.ts +58 -0
  87. package/src/geojson-source.ts +106 -85
  88. package/src/geojson-task-handler.ts +11 -0
  89. package/src/geojson-task-worker.ts +8 -0
  90. package/src/geojson-task.ts +34 -0
  91. package/src/geojson-tiler.ts +270 -4
  92. package/src/geojson-worker.ts +36 -6
  93. package/src/globe-horizon-extension.ts +14 -4
  94. package/src/globe-layers.ts +1905 -406
  95. package/src/globe-line-angle-extension.ts +183 -23
  96. package/src/glyph-store.ts +28 -6
  97. package/src/heatmap-layer.ts +591 -0
  98. package/src/hillshade-layer.ts +309 -88
  99. package/src/icon-text-fit.ts +358 -0
  100. package/src/image-source-layer.ts +380 -0
  101. package/src/index.ts +58 -1
  102. package/src/line-blur-extension.ts +14 -12
  103. package/src/line-dash-extension.ts +303 -0
  104. package/src/line-gradient-extension.ts +191 -0
  105. package/src/line-metrics.ts +90 -0
  106. package/src/line-pattern-extension.ts +173 -0
  107. package/src/line-shape-extension.ts +272 -0
  108. package/src/map-style-loader.ts +5 -4
  109. package/src/map-style.ts +2 -1
  110. package/src/mvt-label-layer.ts +568 -144
  111. package/src/pmtiles-source.ts +276 -0
  112. package/src/projected-background-layer.ts +202 -0
  113. package/src/projected-bitmap-layer.ts +262 -0
  114. package/src/projected-tile-data.ts +132 -0
  115. package/src/projected-tile-selection.ts +605 -0
  116. package/src/projected-tileset.ts +183 -0
  117. package/src/projected-viewport.ts +254 -0
  118. package/src/raster-color-extension.ts +43 -18
  119. package/src/raster-fade.ts +319 -0
  120. package/src/raster-tile-fingerprint.ts +31 -0
  121. package/src/raster-tile-loader.ts +211 -0
  122. package/src/shader-injection-plugin.ts +25 -0
  123. package/src/source-features.ts +170 -0
  124. package/src/source-tiles.ts +102 -0
  125. package/src/sprite.ts +122 -15
  126. package/src/stretch-icon-layer.ts +87 -0
  127. package/src/style-accessor.ts +105 -17
  128. package/src/style-expression.ts +80 -3
  129. package/src/style-resolver.ts +200 -22
  130. package/src/terrain-query.ts +86 -0
  131. package/src/text-layout.ts +2 -3
  132. package/src/zoom-load-gate.ts +57 -0
  133. package/src/zoom-paint-extension.ts +245 -47
  134. package/dist/types/arabic-shaping.d.ts +0 -7
  135. package/dist/types/bidi.d.ts +0 -8
  136. package/dist/types/polylabel.d.ts +0 -17
  137. package/src/arabic-shaping.ts +0 -366
  138. package/src/bidi.ts +0 -199
  139. package/src/polylabel.ts +0 -312
@@ -1,4 +1,4 @@
1
- import { Color } from '@maplibre/maplibre-gl-style-spec';
1
+ import { Color, type InterpolationType } from '@maplibre/maplibre-gl-style-spec';
2
2
  /** A feature as seen by style expressions: a GeoJSON feature or a numeric-typed tile feature. */
3
3
  export type StyleFeature = {
4
4
  type?: number | string;
@@ -14,11 +14,16 @@ export type CompiledStyleProperty = {
14
14
  isZoomDependent: boolean;
15
15
  /** True when the value depends on feature data (`["get", ...]`, `match`, ...). */
16
16
  isFeatureDependent: boolean;
17
+ /** True when the value depends on the feature's state (`["feature-state", ...]`). */
18
+ isStateDependent: boolean;
19
+ /** Interpolation of the outer zoom curve, or null for discrete or zoom-independent values. */
20
+ zoomInterpolation: InterpolationType | null;
17
21
  /**
18
22
  * Evaluates the property. Colors are returned as `[r, g, b, a]`, with `a` in 0-1.
19
23
  * `availableImages` lists the loaded sprite image names, which `["image", ...]` checks.
24
+ * `featureState` is the feature's state, which `["feature-state", ...]` reads.
20
25
  */
21
- evaluate: (zoom: number, feature?: StyleFeature, availableImages?: string[]) => unknown;
26
+ evaluate: (zoom: number, feature?: StyleFeature, availableImages?: string[], featureState?: Record<string, unknown>) => unknown;
22
27
  /**
23
28
  * Evaluates the property with every global input, such as `heatmapDensity` or `lineProgress`
24
29
  * as well as `zoom`. Colors are returned as in `evaluate`.
@@ -55,6 +60,8 @@ export declare function getStylePropertyDefault(propertyName: string): unknown;
55
60
  * MapLibre skips invalid properties.
56
61
  */
57
62
  export declare function compileStylePropertyValue(propertyName: string, value: unknown): CompiledStyleProperty | null;
63
+ /** The clamped blend between two attribute zooms. A discrete zoom curve holds its lower value. */
64
+ export declare function getZoomInterpolationFactor(interpolation: InterpolationType | null, zoom: number, lower: number, upper: number): number;
58
65
  /**
59
66
  * Returns a compiled `paint` or `layout` property of a style layer, or `null` when the layer
60
67
  * does not set it. Compilation is cached per style layer object and property; the cached entry is
@@ -62,6 +69,19 @@ export declare function compileStylePropertyValue(propertyName: string, value: u
62
69
  * recompiles it.
63
70
  */
64
71
  export declare function getCompiledStyleProperty(styleLayer: StyleLayerLike, propertyName: string): CompiledStyleProperty | null;
72
+ /** The stops of an interpolated color ramp: each stop's input, and its color. */
73
+ export type ColorRampStops = {
74
+ inputs: number[];
75
+ /** Premultiplied RGBA in 0-1, as MapLibre GL JS's `Color` stores it. */
76
+ colors: [number, number, number, number][];
77
+ };
78
+ /**
79
+ * The stops of a color ramp property, such as `color-relief-color`, as MapLibre GL JS reads them:
80
+ * the inputs of an `interpolate` (or `interpolate-hcl`, `interpolate-lab`) expression, and the
81
+ * colors it evaluates to at each. `null` for any other value, such as a `step` expression or a
82
+ * constant color, which MapLibre draws transparent. An invalid value logs a warning once.
83
+ */
84
+ export declare function getColorRampStops(propertyName: string, value: unknown, inputName: string): ColorRampStops | null;
65
85
  /**
66
86
  * Compiles a style-spec filter into a feature predicate, cached per filter array. The cached
67
87
  * predicate is reused only while the array's contents are unchanged, so a filter edited in place
@@ -1,10 +1,15 @@
1
+ import { type BasemapLoadErrorHandler } from "./basemap-error.js";
2
+ import { type BasemapResourceType, type BasemapTransformRequest } from "./basemap-request.js";
1
3
  /**
2
4
  * A basemap source entry from a style document.
3
5
  */
4
6
  export type BasemapSource = {
5
7
  /** Source kind such as `vector` or `raster`. */
6
8
  type?: string;
7
- /** Optional TileJSON URL used to resolve the source metadata. */
9
+ /**
10
+ * Optional TileJSON URL used to resolve the source metadata, or a PMTiles archive,
11
+ * `pmtiles://<archive URL>`, whose header resolves it.
12
+ */
8
13
  url?: string;
9
14
  /** Inline tile templates for the source. */
10
15
  tiles?: string[];
@@ -84,11 +89,51 @@ export type BasemapLoadOptions = {
84
89
  fetch?: typeof fetch;
85
90
  /** Optional init object passed to the selected fetch implementation. */
86
91
  fetchOptions?: RequestInit;
92
+ /**
93
+ * Resolved sources by `getSourceKey` of their definition and base URL. A source whose key is in
94
+ * the cache is not fetched again. Each resolution replaces the entries with its own sources.
95
+ */
96
+ sourceCache?: Map<string, BasemapSource>;
97
+ /**
98
+ * Called for each source whose TileJSON or GeoJSON data cannot be loaded, in place of the
99
+ * warning that is logged without it.
100
+ */
101
+ onError?: BasemapLoadErrorHandler;
102
+ /**
103
+ * Changes each request before it is sent (see `BasemapTransformRequest`). `BasemapLayer` sets it
104
+ * from its `transformRequest` prop.
105
+ */
106
+ transformRequest?: BasemapTransformRequest | null;
87
107
  /** Additional loader options are accepted for forward compatibility. */
88
108
  [key: string]: unknown;
89
109
  } | null;
110
+ /**
111
+ * A key of a source's content: its JSON with sorted object keys. Two sources with the same key
112
+ * load the same tiles.
113
+ */
114
+ export declare function getSourceKey(value: unknown): string;
115
+ /**
116
+ * Fetches and parses a JSON resource with the `fetch`, `fetchOptions` and `transformRequest` of
117
+ * `loadOptions`.
118
+ */
119
+ export declare function fetchJson(url: string, loadOptions: BasemapLoadOptions | undefined, resourceType: BasemapResourceType): Promise<any>;
120
+ /**
121
+ * Fetches the GeoJSON of a `geojson` source's `data` URL, as MapLibre loads it. A relative URL
122
+ * resolves against `baseUrl`. Throws if the data cannot be fetched or is not a GeoJSON object.
123
+ */
124
+ export declare function loadGeoJsonData(url: string, baseUrl: string | undefined, loadOptions?: BasemapLoadOptions): Promise<object>;
125
+ /** Brands `style` as resolved, with the URL that its relative URLs resolve against. */
126
+ export declare function markResolvedBasemapStyle<T extends ResolvedBasemapStyle>(style: T, baseUrl: string | undefined): T;
127
+ /**
128
+ * Whether `style` is a style that `resolveBasemapStyle` or `MapStyleLoader` returned, and that
129
+ * `BasemapLayer` thus draws without resolving it again. A copy of a resolved style is not one.
130
+ */
131
+ export declare function isResolvedBasemapStyle(style: unknown): style is ResolvedBasemapStyle;
132
+ /** The URL that the relative URLs of a resolved style resolve against, if it has one. */
133
+ export declare function getResolvedBasemapStyleBaseUrl(style: ResolvedBasemapStyle): string | undefined;
90
134
  /**
91
135
  * Resolves a basemap style input into a style object whose sources contain
92
- * directly consumable tile templates and source metadata.
136
+ * directly consumable tile templates and source metadata. `BasemapLayer` draws the result
137
+ * without resolving it again (see `isResolvedBasemapStyle`).
93
138
  */
94
139
  export declare function resolveBasemapStyle(style: string | BasemapStyle, loadOptions?: BasemapLoadOptions): Promise<ResolvedBasemapStyle>;
@@ -0,0 +1,39 @@
1
+ import type { Viewport } from '@deck.gl/core';
2
+ /** Structural loaders.gl-compatible hit, separating displayed geometry from source elevation. */
3
+ export type TerrainSurfaceHit = {
4
+ /** Displayed content position, in the same units as the query ray. */
5
+ readonly position: readonly [number, number, number];
6
+ /** Longitude/latitude degrees and physical, unexaggerated source elevation meters. */
7
+ readonly coordinate: readonly [number, number, number];
8
+ /** Distance in content units, independent of direction length. */
9
+ readonly distance: number;
10
+ /** Unit normal following displayed triangle winding. */
11
+ readonly normal: readonly [number, number, number];
12
+ /** Original triangle identity, not a GPU feature index. */
13
+ readonly triangleIndex: number;
14
+ /** Weights in original vertex order. */
15
+ readonly barycentric: readonly [number, number, number];
16
+ };
17
+ /**
18
+ * Borrowed displayed terrain query owner. Structurally compatible with loaders.gl 5
19
+ * and Tangram without requiring either renderer or an alpha dependency upgrade.
20
+ */
21
+ export type TerrainSurface = {
22
+ /** Mercator XYZ meters or host-defined center-relative globe common units. */
23
+ readonly projection: 'web-mercator' | 'globe';
24
+ /** Nearest loaded hit inside the inclusive distance; a miss does not certify coverage. */
25
+ intersectRay(ray: {
26
+ /** Absolute content origin, before camera and room-placement transforms. */
27
+ readonly origin: readonly [number, number, number];
28
+ /** Nonzero finite direction, not necessarily normalized. */
29
+ readonly direction: readonly [number, number, number];
30
+ }, maxDistance?: number): TerrainSurfaceHit | null;
31
+ };
32
+ /**
33
+ * Route an absolute top-origin CSS pixel through one actual deck viewport/eye.
34
+ * commonToSurface must be a finite affine transform from that viewport's common
35
+ * coordinates to the provider's content coordinates, including units and offsets.
36
+ * No geographic projection, globe radius, exaggeration or datum conversion is guessed.
37
+ * The provider remains responsible for matching the currently displayed generation.
38
+ */
39
+ export declare function pickTerrainSurface(viewport: Pick<Viewport, 'x' | 'y' | 'width' | 'height' | 'viewProjectionMatrix'>, pixel: readonly [number, number], surface: TerrainSurface, commonToSurface: Readonly<ArrayLike<number>>): TerrainSurfaceHit | null;
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Holds the vector tile loads of a `BasemapLayer` while its views zoom. In a zoom gesture the
3
+ * tile selection passes through several tile zooms, each shown for a fraction of a second, and
4
+ * each tile loaded at one of them is decoded and triangulated on the main thread. A load that
5
+ * the caller holds waits until no view's zoom has changed for `delay` milliseconds. A pan does not
6
+ * change the zoom, and its loads do not wait.
7
+ */
8
+ export declare class ZoomLoadGate {
9
+ /** Milliseconds a load waits after the last zoom change; 0 loads at once. */
10
+ delay: number;
11
+ private zooms;
12
+ private lastChange;
13
+ /** Records the zoom of a view at a tile selection. The first zoom of a view is not a change. */
14
+ noteZoom(viewId: string, zoom: number, now?: number): void;
15
+ /** Milliseconds until a load may start: 0 when no view has zoomed for `delay`. */
16
+ getRemainingDelay(now?: number): number;
17
+ /**
18
+ * Resolves when no view has zoomed for `delay` milliseconds, when `signal` aborts, or when
19
+ * `isHeld` returns false. Returns whether the load was held at all.
20
+ */
21
+ wait(signal?: AbortSignal | null, isHeld?: () => boolean): Promise<boolean>;
22
+ }
@@ -1,5 +1,5 @@
1
1
  import { LayerExtension } from '@deck.gl/core';
2
- import type { Accessor, Layer, LayerContext } from '@deck.gl/core';
2
+ import type { Accessor, Layer, LayerContext, UpdateParameters } from '@deck.gl/core';
3
3
  import type { Device, Texture } from '@luma.gl/core';
4
4
  /** The most style layers whose paint one layer can take from `ZoomPaintExtension`. */
5
5
  export declare const MAX_ZOOM_PAINT_PARTS = 64;
@@ -7,15 +7,18 @@ export declare const MAX_ZOOM_PAINT_PARTS = 64;
7
7
  export declare const ZOOM_PAINT_WIDTH_ROW = 0;
8
8
  export declare const ZOOM_PAINT_LINE_COLOR_ROW = 1;
9
9
  export declare const ZOOM_PAINT_FILL_COLOR_ROW = 2;
10
+ /** The row of blend factors for composite width, line color and fill color. */
11
+ export declare const ZOOM_PAINT_INTERPOLATION_ROW = 3;
10
12
  /**
11
13
  * The paint of each style layer drawn by a layer, at one zoom: an RGBA texel per style layer
12
- * (column) and value (row), `MAX_ZOOM_PAINT_PARTS` by 3. Column `i` is the style layer that
14
+ * (column) and value (row), `MAX_ZOOM_PAINT_PARTS` by 4. Column `i` is the style layer that
13
15
  * `getStylePart` returns `i` for.
14
16
  *
15
17
  * - `ZOOM_PAINT_WIDTH_ROW`: in red, a factor of the layer's width attribute.
16
18
  * - `ZOOM_PAINT_LINE_COLOR_ROW`, `ZOOM_PAINT_FILL_COLOR_ROW`: a color in 0-1, which replaces the
17
19
  * layer's color attribute unless its alpha is negative: the attribute then holds the style
18
20
  * layer's per-feature colors.
21
+ * - `ZOOM_PAINT_INTERPOLATION_ROW`: blend factors for width, line color and fill color in RGB.
19
22
  */
20
23
  export type ZoomPaintValues = Float32Array;
21
24
  /** Creates values with every width factor 1 and every color taken from the attributes. */
@@ -27,46 +30,112 @@ export declare function getZoomPaintOffset(row: number, part: number): number;
27
30
  * which `destroy` releases.
28
31
  */
29
32
  export declare class ZoomPaint {
30
- readonly getValues: () => ZoomPaintValues;
33
+ private readonly evaluate;
34
+ private readonly partCount;
31
35
  private texture;
32
36
  private written;
33
- /** `getValues` returns the values at the current zoom, the same array while they are unchanged. */
34
- constructor(getValues: () => ZoomPaintValues);
35
- /** The texture of the current values, created on first use. */
36
- getTexture(device: Device): Texture;
37
+ /**
38
+ * `evaluate` returns the values at the viewport zoom and attribute bucket, the same array
39
+ * while they are unchanged. `partCount` is the number of style layers using the texture.
40
+ */
41
+ constructor(evaluate: (zoom: number, bucket: number) => ZoomPaintValues, partCount: number);
42
+ /** The values at a zoom, using the bucket at which the layer's attributes were generated. */
43
+ getValues(zoom: number, bucket?: number): ZoomPaintValues;
44
+ /** Whether a fill or line in this batch can draw at the current viewport zoom. */
45
+ isVisible(zoom: number, bucket: number | undefined, filled: boolean, stroked: boolean): boolean;
46
+ /**
47
+ * The texture of the current values, created on first use. The viewport zoom gives the
48
+ * layer-wide values, and the attributes' bucket gives the lower endpoint of each blend.
49
+ */
50
+ getTexture(device: Device, zoom: number, bucket?: number): Texture;
37
51
  destroy(): void;
38
52
  }
39
53
  export type ZoomPaintExtensionProps = {
40
54
  /** The paint to apply; the layer draws its attributes as they are without it. */
41
55
  zoomPaint?: ZoomPaint | null;
56
+ /** The zoom option used to build this sublayer, shared with its drawing layers. */
57
+ zoomPaintGeneration?: {
58
+ zoom: number;
59
+ } | null;
60
+ /** The lower endpoint of the composite paint attributes. */
61
+ zoomPaintBucket?: number;
42
62
  /** Which of `zoomPaint`'s style layers each object belongs to. */
43
63
  getStylePart?: Accessor<any, number>;
64
+ /** Width at the upper endpoint of the composite paint interval. */
65
+ getNextLineWidth?: Accessor<any, number>;
66
+ /** Line color at the upper endpoint of the composite paint interval. */
67
+ getNextLineColor?: Accessor<any, number[]>;
68
+ /** Fill color at the upper endpoint of the composite paint interval. */
69
+ getNextFillColor?: Accessor<any, number[]>;
70
+ /** Style part, next width and packed RGBA for a dashed path. */
71
+ getNextDashedPaint?: Accessor<any, number[]>;
44
72
  };
73
+ /** Packs two unorm8 color channels into each of two floats for a dashed path. */
74
+ export declare function packZoomPaintColor(color: number[]): [number, number];
45
75
  /**
46
76
  * Takes the zoom-dependent paint of the style layers a `PathLayer` or flat `SolidPolygonLayer`
47
77
  * draws from a texture instead of attributes: per style layer, its line width and, when they are
48
- * the same for all of its features, its colors. The values are read when the layer draws, so a
49
- * zoom step changes a small texture, shared by every layer with the same `zoomPaint`: the layers'
50
- * props, and so their attributes, stay the same. Each object's style layer is an attribute, which
78
+ * the same for all of its features, its colors. It also uses the texture's blend factors to
79
+ * interpolate per-feature paint between attributes evaluated at the enclosing zoom steps.
80
+ * The values are read when the layer draws, so zooming within a step changes a small texture,
81
+ * shared by every layer with the same `zoomPaint`. The layers' props, and so their attributes,
82
+ * stay the same. Each object's style layer is an attribute, which
51
83
  * changes only with the data.
52
84
  *
53
85
  * The width factor applies after `widthMinPixels` and `widthMaxPixels`, which must not clamp.
54
86
  * The owner of a `ZoomPaint` destroys its texture. WebGL only.
55
87
  */
56
- export declare class ZoomPaintExtension extends LayerExtension {
88
+ export declare class ZoomPaintExtension extends LayerExtension<{
89
+ composite: boolean;
90
+ packedPath: boolean;
91
+ }> {
57
92
  static extensionName: string;
58
93
  static defaultProps: {
59
94
  zoomPaint: {
60
95
  type: string;
61
96
  value: null;
62
97
  };
98
+ zoomPaintGeneration: {
99
+ type: string;
100
+ value: null;
101
+ };
102
+ zoomPaintBucket: {
103
+ type: string;
104
+ value: null;
105
+ optional: boolean;
106
+ };
63
107
  getStylePart: {
64
108
  type: string;
65
109
  value: number;
66
110
  };
111
+ getNextLineWidth: {
112
+ type: string;
113
+ value: number;
114
+ };
115
+ getNextLineColor: {
116
+ type: string;
117
+ value: number[];
118
+ };
119
+ getNextFillColor: {
120
+ type: string;
121
+ value: number[];
122
+ };
123
+ getNextDashedPaint: {
124
+ type: string;
125
+ value: number[];
126
+ };
67
127
  };
128
+ /** Selects the shader variant and the attributes it needs for the upper zoom endpoint. */
129
+ constructor({ composite, packedPath }?: {
130
+ composite?: boolean | undefined;
131
+ packedPath?: boolean | undefined;
132
+ });
68
133
  isEnabled(layer: Layer): boolean;
69
134
  getShaders(this: Layer<ZoomPaintExtensionProps>, extension: this): any;
135
+ /** Matches the layer's paint attributes to the selected shader variant. */
136
+ private synchronizeAttributes;
70
137
  initializeState(this: Layer<ZoomPaintExtensionProps>, context: LayerContext, extension: this): void;
138
+ /** Updates the paint attributes when the layer switches shader variants. */
139
+ updateState(this: Layer<ZoomPaintExtensionProps>, params: UpdateParameters<Layer<ZoomPaintExtensionProps>>, extension: this): void;
71
140
  draw(this: Layer<ZoomPaintExtensionProps>, params: any, extension: this): void;
72
141
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangram.gl/basemap-layers",
3
- "version": "0.0.0",
3
+ "version": "10.0.0-alpha.3",
4
4
  "description": "Basemap layer and map-style helpers for deck.gl.",
5
5
  "license": "MIT",
6
6
  "keywords": [
@@ -14,7 +14,8 @@
14
14
  "directory": "modules/basemap-layers"
15
15
  },
16
16
  "publishConfig": {
17
- "access": "public"
17
+ "access": "public",
18
+ "tag": "beta"
18
19
  },
19
20
  "type": "module",
20
21
  "sideEffects": false,
@@ -42,42 +43,44 @@
42
43
  ],
43
44
  "scripts": {
44
45
  "build": "yarn build:types && yarn build:bundle && yarn build:worker",
45
- "build:types": "node ../../scripts/build-package-types.mjs modules/basemap-layers index.ts map-style.ts",
46
- "build:bundle": "ocular-bundle src/index.ts --env=dev --format=esm --output=dist/index.js --externals=@loaders.gl/loader-utils,@loaders.gl/mvt,@mapbox/tiny-sdf,@maplibre/geojson-vt,@maplibre/maplibre-gl-style-spec,@turf/polygon-to-line,bidi-js,zod --sourcemap=true --sourcesContent=false && ocular-bundle src/map-style.ts --env=dev --format=esm --output=dist/map-style.js --externals=@loaders.gl/loader-utils,@loaders.gl/mvt,@mapbox/tiny-sdf,@maplibre/geojson-vt,@maplibre/maplibre-gl-style-spec,@turf/polygon-to-line,bidi-js,zod --sourcemap=true --sourcesContent=false && ocular-bundle src/index.ts --env=dev --format=cjs --output=dist/index.cjs --externals=@loaders.gl/loader-utils,@loaders.gl/mvt,@mapbox/tiny-sdf,@maplibre/geojson-vt,@maplibre/maplibre-gl-style-spec,@turf/polygon-to-line,bidi-js,zod --sourcemap=true --sourcesContent=false && ocular-bundle src/map-style.ts --env=dev --format=cjs --output=dist/map-style.cjs --externals=@loaders.gl/loader-utils,@loaders.gl/mvt,@mapbox/tiny-sdf,@maplibre/geojson-vt,@maplibre/maplibre-gl-style-spec,@turf/polygon-to-line,bidi-js,zod --sourcemap=true --sourcesContent=false",
47
- "build:worker": "ocular-bundle src/geojson-worker.ts --env=dev --format=iife --output=dist/geojson-worker.js --sourcemap=true --sourcesContent=false",
48
- "prepack": "yarn build",
49
- "test": "yarn --cwd ../.. vitest run --config modules/basemap-layers/vitest.config.ts",
50
- "test-watch": "yarn --cwd ../.. vitest --config modules/basemap-layers/vitest.config.ts"
46
+ "build:types": "yarn workspace @tangram.gl/map-utils build:types && node ../../scripts/build-package-types.mjs modules/basemap-layers index.ts map-style.ts",
47
+ "build:bundle": "ocular-bundle src/index.ts --env=dev --format=esm --output=dist/index.js --externals=@math.gl/tasks,@loaders.gl/core/loader-utils,@loaders.gl/tiles/mvt,@mapbox/tiny-sdf,@maplibre/geojson-vt,@maplibre/maplibre-gl-style-spec,@turf/polygon-to-line,bidi-js,pmtiles,zod --sourcemap=true --sourcesContent=false && ocular-bundle src/map-style.ts --env=dev --format=esm --output=dist/map-style.js --externals=@math.gl/tasks,@loaders.gl/core/loader-utils,@loaders.gl/tiles/mvt,@mapbox/tiny-sdf,@maplibre/geojson-vt,@maplibre/maplibre-gl-style-spec,@turf/polygon-to-line,bidi-js,pmtiles,zod --sourcemap=true --sourcesContent=false && ocular-bundle src/index.ts --env=dev --format=cjs --output=dist/index.cjs --externals=@math.gl/tasks,@loaders.gl/core/loader-utils,@loaders.gl/tiles/mvt,@mapbox/tiny-sdf,@maplibre/geojson-vt,@maplibre/maplibre-gl-style-spec,@turf/polygon-to-line,bidi-js,pmtiles,zod --sourcemap=true --sourcesContent=false && ocular-bundle src/map-style.ts --env=dev --format=cjs --output=dist/map-style.cjs --externals=@math.gl/tasks,@loaders.gl/core/loader-utils,@loaders.gl/tiles/mvt,@mapbox/tiny-sdf,@maplibre/geojson-vt,@maplibre/maplibre-gl-style-spec,@turf/polygon-to-line,bidi-js,pmtiles,zod --sourcemap=true --sourcesContent=false",
48
+ "build:worker": "ocular-bundle src/geojson-worker.ts --env=dev --format=iife --output=dist/geojson-worker.js --sourcemap=true --sourcesContent=false && ocular-bundle src/geojson-task-worker.ts --env=dev --format=iife --output=dist/geojson-task-worker.js --sourcemap=true --sourcesContent=false",
49
+ "prepack": "yarn build"
51
50
  },
52
51
  "devDependencies": {
53
- "@deck.gl-community/geo-layers": "~9.4.2",
54
- "@deck.gl/test-utils": "~9.4.0",
52
+ "@deck.gl-community/layers": "10.0.0-alpha.4",
53
+ "@deck.gl/test-utils": "10.0.0-alpha.3",
55
54
  "@fontsource/montserrat": "5.3.0",
56
55
  "@fontsource/noto-sans": "5.3.0",
57
56
  "@fontsource/open-sans": "5.3.0",
58
- "@loaders.gl/core": "^4.5.1",
57
+ "@loaders.gl/core": "5.0.3",
58
+ "@tangram.gl/map-utils": "0.0.0",
59
59
  "@vis.gl/dev-tools": "2.0.0-alpha.8",
60
60
  "maplibre-gl": "6.13.0",
61
61
  "vitest": "^4.0.18"
62
62
  },
63
63
  "dependencies": {
64
- "@loaders.gl/loader-utils": "^4.5.1",
65
- "@loaders.gl/mvt": "^4.5.1",
64
+ "@loaders.gl/tiles": "5.0.3",
66
65
  "@mapbox/tiny-sdf": "^2.0.5",
67
66
  "@maplibre/geojson-vt": "^6.1.2",
68
67
  "@maplibre/maplibre-gl-style-spec": "^24.8.1",
68
+ "@math.gl/core": "5.0.5",
69
+ "@math.gl/geometry": "5.0.5",
70
+ "@math.gl/tasks": "5.0.5",
69
71
  "@turf/polygon-to-line": "^6.0.3",
70
72
  "bidi-js": "^1.1.0",
73
+ "pmtiles": "^4.5.0",
71
74
  "zod": "^4.0.0"
72
75
  },
73
76
  "peerDependencies": {
74
- "@deck.gl-community/geo-layers": "~9.4.2",
75
- "@deck.gl/core": "~9.4.0",
76
- "@deck.gl/extensions": "~9.4.0",
77
- "@deck.gl/geo-layers": "~9.4.0",
78
- "@deck.gl/layers": "~9.4.0",
79
- "@loaders.gl/core": "^4.5.1",
80
- "@luma.gl/core": "~9.4.0",
81
- "@luma.gl/engine": "~9.4.0"
77
+ "@deck.gl-community/layers": "10.0.0-alpha.4",
78
+ "@deck.gl/core": "10.0.0-alpha.3",
79
+ "@deck.gl/extensions": "10.0.0-alpha.3",
80
+ "@deck.gl/geo-layers": "10.0.0-alpha.3",
81
+ "@deck.gl/layers": "10.0.0-alpha.3",
82
+ "@loaders.gl/core": "5.0.3",
83
+ "@luma.gl/core": "10.0.0",
84
+ "@luma.gl/engine": "10.0.0"
82
85
  }
83
86
  }
@@ -0,0 +1,82 @@
1
+ // tangram-layers
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ /** The resource of a style that failed to load (see {@link BasemapLoadError}). */
6
+ export type BasemapLoadErrorKind = 'style' | 'source' | 'tile' | 'sprite' | 'glyphs' | 'image';
7
+
8
+ /** What a {@link BasemapLoadError} tells about the resource that failed. */
9
+ export type BasemapLoadErrorDetails = {
10
+ /** The style source of a `source`, `tile` or `image` failure. */
11
+ sourceId?: string;
12
+ /** The URL that failed, when it is known. */
13
+ url?: string;
14
+ /** The HTTP status of the response, when the server answered. */
15
+ status?: number;
16
+ /** The index of the tile, for a `tile` failure. */
17
+ tile?: {x: number; y: number; z: number};
18
+ };
19
+
20
+ /**
21
+ * A resource of the style that failed to load. `BasemapLayer` gives it to deck.gl's `onError`
22
+ * layer prop, and then to the `onError` of the `Deck`. It carries the fields of MapLibre GL JS's
23
+ * `error` event (`sourceId`, `tile`), and the error the load failed with as `cause`.
24
+ */
25
+ export class BasemapLoadError extends Error implements BasemapLoadErrorDetails {
26
+ /** What failed to load. */
27
+ readonly kind: BasemapLoadErrorKind;
28
+ readonly sourceId?: string;
29
+ readonly url?: string;
30
+ readonly status?: number;
31
+ readonly tile?: {x: number; y: number; z: number};
32
+ /** The error the load failed with. */
33
+ declare readonly cause: Error;
34
+
35
+ constructor(kind: BasemapLoadErrorKind, cause: Error, details: BasemapLoadErrorDetails = {}) {
36
+ const source = details.sourceId ? ` of source "${details.sourceId}"` : '';
37
+ const url = details.url ? ` ${details.url}` : '';
38
+ super(`Failed to load ${kind}${source}${url}: ${cause.message}`, {cause});
39
+ this.name = 'BasemapLoadError';
40
+ this.kind = kind;
41
+ Object.assign(this, details);
42
+ }
43
+ }
44
+
45
+ /** Receives each resource of the style that fails to load. */
46
+ export type BasemapLoadErrorHandler = (error: BasemapLoadError) => void;
47
+
48
+ /** A response with an error status: keeps the URL and status for {@link BasemapLoadError}. */
49
+ export class BasemapFetchError extends Error {
50
+ constructor(
51
+ message: string,
52
+ readonly url: string,
53
+ readonly status: number
54
+ ) {
55
+ super(message);
56
+ this.name = 'BasemapFetchError';
57
+ }
58
+ }
59
+
60
+ /** Whether `error` is a cancelled request, which is not a load failure. */
61
+ export function isAbortError(error: unknown): boolean {
62
+ return (error as Error | null)?.name === 'AbortError';
63
+ }
64
+
65
+ /**
66
+ * The load error of a failure. The URL and status come from `error` when it has them, such as a
67
+ * {@link BasemapFetchError} or a loaders.gl `FetchError`.
68
+ */
69
+ export function getBasemapLoadError(
70
+ kind: BasemapLoadErrorKind,
71
+ error: unknown,
72
+ details: BasemapLoadErrorDetails = {}
73
+ ): BasemapLoadError {
74
+ const cause = error as {url?: unknown; status?: unknown; response?: {status?: unknown}} | null;
75
+ const url = typeof cause?.url === 'string' && cause.url ? cause.url : details.url;
76
+ const status = cause?.status ?? cause?.response?.status;
77
+ return new BasemapLoadError(kind, error instanceof Error ? error : new Error(String(error)), {
78
+ ...details,
79
+ ...(url ? {url} : {}),
80
+ ...(typeof status === 'number' ? {status} : {})
81
+ });
82
+ }