• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

keplergl / kepler.gl / 20467822738

23 Dec 2025 05:50PM UTC coverage: 61.661% (-0.01%) from 61.672%
20467822738

Pull #3266

github

web-flow
Merge ca0d39554 into f468e3a51
Pull Request #3266: fix: fix image export for non-webpack bundlers

6353 of 12235 branches covered (51.92%)

Branch coverage included in aggregate %.

2 of 6 new or added lines in 2 files covered. (33.33%)

56 existing lines in 2 files now uncovered.

13048 of 19229 relevant lines covered (67.86%)

81.7 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

60.0
/src/utils/src/application-config.ts
1
// SPDX-License-Identifier: MIT
2
// Copyright contributors to the kepler.gl project
3

4
import {MapLib, MapRef} from 'react-map-gl';
5

6
import {KEPLER_UNFOLDED_BUCKET} from '@kepler.gl/constants';
7
import type {BaseMapLibraryType} from '@kepler.gl/constants';
8

9
import type {DatabaseAdapter} from './application-config-types';
10

11
/**
12
 * Detect if running with webpack build tool
13
 */
14
function isWebpackBuild(): boolean {
15
  try {
15✔
16
    // @ts-ignore - __webpack_require__ is injected by webpack at runtime
17
    return typeof __webpack_require__ !== 'undefined';
15✔
18
  } catch {
NEW
UNCOV
19
    return false;
×
20
  }
21
}
22

23
export type MapLibInstance = MapLib<any>;
24
export type GetMapRef = ReturnType<MapRef['getMap']>;
25

26
export type BaseMapLibraryConfig = {
27
  getMapLib: () => Promise<MapLibInstance>;
28
  mapLibAttributionCssClass: string;
29
  mapLibCssClass: string;
30
  mapLibName: string;
31
  mapLibUrl: string;
32
};
33

34
/**
35
 * A mechanism to override default Kepler values/settings so that we
36
 * without having to make application-specific changes to the kepler repo.
37
 */
38
export type KeplerApplicationConfig = {
39
  /** Default name of export HTML file, can be overridden by user */
40
  defaultHtmlName?: string;
41
  defaultImageName?: string;
42
  defaultJsonName?: string;
43
  defaultDataName?: string;
44
  defaultExportJsonSettings?: {
45
    hasData?: boolean;
46
  };
47
  baseMapLibraryConfig?: Record<BaseMapLibraryType, BaseMapLibraryConfig>;
48
  plugins?: any[];
49
  // KeplerTable alternative
50
  // TODO improve typing by exporting KeplerTable interface to @kepler.gl/types
51
  table?: any;
52
  database?: DatabaseAdapter | null;
53

54
  // Disable progressive loading for arrow files
55
  useArrowProgressiveLoading?: boolean;
56
  // Show built-in banner associated with the current version of Kepler.gl
57
  showReleaseBanner?: boolean;
58
  // Use the onFilteredItemsChange callback for DataFilterExtension.
59
  // Enabling this option may cause performance issues when dealing with a large number of layers or sublayers,
60
  // especially if large Arrow files are split into relatively small batches (should be fixed in the future).
61
  useOnFilteredItemsChange?: boolean;
62

63
  // A URL to the CDN where the kepler.gl assets are hosted.
64
  cdnUrl?: string;
65

66
  // Raster Tile layer config
67
  // Raster Tile layer is under development and not ready for production use. Disabled by default.
68
  enableRasterTileLayer?: boolean;
69
  /** Whether to use Titiler v0.21 API endpoints instead of v0.11 */
70
  rasterServerUseLatestTitiler?: boolean;
71
  /** An array of URLs to shards of the raster tile server to be used by the raster tile layer. */
72
  rasterServerUrls?: string[];
73
  /** If true then try to fetch quantized elevation meshes from raster servers */
74
  rasterServerSupportsElevation?: boolean;
75
  /** How many times to retry a request if case of rasterServerServerErrorsToRetry errors */
76
  rasterServerMaxRetries?: number;
77
  /** How long between retries */
78
  rasterServerRetryDelay?: number;
79
  /** An array of HTTP status codes that should be retried when encountered. */
80
  rasterServerServerErrorsToRetry?: number[];
81
  /** Maximum number of simultaneous requests per raster server. 0 - no limit */
82
  rasterServerMaxPerServerRequests?: number;
83
  /** Whether to show the server input field in the raster tile layer setup form */
84
  rasterServerShowServerInput?: boolean;
85

86
  // WMS layer config -- Experimental
87
  // WMS layer is under development and not ready for production use. Disabled by default.
88
  enableWMSLayer?: boolean;
89

90
  // Image export config
91
  /** Whether to apply fix for uglify error in dom-to-image (should be true for webpack builds, false for Vite) */
92
  escapeXhtmlForWebpack?: boolean;
93
};
94

95
const DEFAULT_APPLICATION_CONFIG: Required<KeplerApplicationConfig> = {
15✔
96
  defaultHtmlName: 'kepler.gl.html',
97
  defaultImageName: 'kepler.gl.png',
98
  defaultJsonName: 'kepler.gl.json',
99
  defaultDataName: 'kepler.gl',
100
  defaultExportJsonSettings: {
101
    hasData: true
102
  },
103

104
  baseMapLibraryConfig: {
105
    maplibre: {
106
      getMapLib: () => import('maplibre-gl'),
29✔
107
      mapLibCssClass: 'maplibregl',
108
      mapLibAttributionCssClass: 'maplibre-attribution-container',
109
      mapLibName: 'MapLibre',
110
      mapLibUrl: 'https://www.maplibre.org/'
111
    },
112
    mapbox: {
UNCOV
113
      getMapLib: () => import('mapbox-gl'),
×
114
      mapLibCssClass: 'mapboxgl',
115
      mapLibAttributionCssClass: 'mapbox-attribution-container',
116
      mapLibName: 'Mapbox',
117
      mapLibUrl: 'https://www.mapbox.com/'
118
    }
119
  },
120

121
  cdnUrl: KEPLER_UNFOLDED_BUCKET,
122

123
  plugins: [],
124
  // The default table class is KeplerTable.
125
  // TODO include KeplerTable here when the circular dependency with @kepler.gl/table and @kepler.gl/utils are resolved.
126
  table: null,
127
  database: null,
128

129
  useArrowProgressiveLoading: true,
130
  showReleaseBanner: true,
131
  useOnFilteredItemsChange: false,
132

133
  // Raster Tile layer config
134
  enableRasterTileLayer: true,
135
  rasterServerUseLatestTitiler: true,
136
  rasterServerShowServerInput: true,
137
  rasterServerUrls: [], // TODO: provide a default free server or leave blank
138
  rasterServerSupportsElevation: true,
139
  rasterServerMaxRetries: 1,
140
  rasterServerRetryDelay: 10000,
141
  rasterServerServerErrorsToRetry: [503],
142
  rasterServerMaxPerServerRequests: 0,
143

144
  // WMS layer config
145
  enableWMSLayer: true,
146

147
  // Image export config
148
  // Default to true for webpack builds, false for other build tools (e.g., Vite)
149
  escapeXhtmlForWebpack: isWebpackBuild()
150
};
151

152
const applicationConfig: Required<KeplerApplicationConfig> = DEFAULT_APPLICATION_CONFIG;
15✔
153

154
export const getApplicationConfig = (): Required<KeplerApplicationConfig> => applicationConfig;
353✔
155

156
export function initApplicationConfig(appConfig: KeplerApplicationConfig = {}) {
×
UNCOV
157
  Object.assign(applicationConfig, appConfig);
×
158
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc