maplibre-gl 2.1.1 → 2.1.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/build/{banner.js → banner.ts} +1 -1
- package/build/generate-query-test-fixtures.ts +123 -0
- package/build/generate-shaders.ts +35 -0
- package/build/generate-struct-arrays.ts +7 -7
- package/build/generate-style-code.ts +8 -8
- package/build/generate-style-spec.ts +5 -4
- package/build/generate-typings.ts +16 -0
- package/build/readme.md +8 -18
- package/build/release-notes.js +9 -13
- package/build/{rollup_plugin_minify_style_spec.js → rollup_plugin_minify_style_spec.ts} +4 -3
- package/build/{rollup_plugins.js → rollup_plugins.ts} +11 -26
- package/dist/maplibre-gl-dev.js +522 -226
- package/dist/maplibre-gl.css +1 -1
- package/dist/maplibre-gl.d.ts +1536 -1010
- package/dist/maplibre-gl.js +3 -3
- package/dist/maplibre-gl.js.map +1 -1
- package/package.json +40 -61
- package/src/data/{array_types.ts → array_types.g.ts} +0 -0
- package/src/data/bucket/circle_bucket.ts +1 -1
- package/src/data/bucket/fill_bucket.test.ts +1 -1
- package/src/data/bucket/fill_bucket.ts +4 -4
- package/src/data/bucket/fill_extrusion_bucket.ts +1 -1
- package/src/data/bucket/line_bucket.test.ts +1 -1
- package/src/data/bucket/line_bucket.ts +6 -6
- package/src/data/bucket/symbol_bucket.test.ts +16 -16
- package/src/data/bucket/symbol_bucket.ts +53 -53
- package/src/data/bucket.ts +43 -43
- package/src/data/dem_data.ts +12 -12
- package/src/data/evaluation_feature.ts +10 -10
- package/src/data/feature_index.ts +37 -37
- package/src/data/feature_position_map.ts +5 -5
- package/src/data/index_array_type.ts +1 -1
- package/src/data/load_geometry.test.ts +1 -1
- package/src/data/program_configuration.ts +46 -46
- package/src/data/segment.ts +14 -14
- package/src/geo/edge_insets.ts +2 -2
- package/src/geo/lng_lat.ts +4 -4
- package/src/geo/lng_lat_bounds.ts +35 -35
- package/src/geo/mercator_coordinate.ts +5 -5
- package/src/geo/transform.test.ts +1 -1
- package/src/geo/transform.ts +14 -14
- package/src/gl/context.ts +3 -3
- package/src/gl/types.ts +19 -19
- package/src/gl/value.ts +6 -6
- package/src/gl/vertex_buffer.test.ts +1 -1
- package/src/index.ts +24 -9
- package/src/render/draw_circle.ts +8 -8
- package/src/render/draw_collision_debug.ts +5 -5
- package/src/render/draw_line.ts +4 -4
- package/src/render/draw_symbol.ts +21 -21
- package/src/render/glyph_atlas.ts +12 -12
- package/src/render/glyph_manager.test.ts +10 -21
- package/src/render/glyph_manager.ts +33 -32
- package/src/render/image_manager.ts +4 -4
- package/src/render/painter.ts +11 -11
- package/src/render/program/background_program.ts +29 -29
- package/src/render/program/circle_program.ts +10 -10
- package/src/render/program/clipping_mask_program.ts +1 -1
- package/src/render/program/collision_program.ts +9 -9
- package/src/render/program/debug_program.ts +4 -4
- package/src/render/program/fill_extrusion_program.ts +31 -31
- package/src/render/program/fill_program.ts +29 -29
- package/src/render/program/heatmap_program.ts +12 -12
- package/src/render/program/hillshade_program.ts +12 -12
- package/src/render/program/line_program.ts +38 -38
- package/src/render/program/pattern.ts +28 -28
- package/src/render/program/raster_program.ts +21 -21
- package/src/render/program/symbol_program.ts +96 -96
- package/src/render/program.ts +25 -25
- package/src/render/texture.ts +9 -9
- package/src/render/uniform_binding.ts +1 -1
- package/src/render/vertex_array_object.ts +13 -13
- package/src/shaders/_prelude.fragment.glsl.g.ts +2 -0
- package/src/shaders/_prelude.vertex.glsl.g.ts +2 -0
- package/src/shaders/background.fragment.glsl.g.ts +2 -0
- package/src/shaders/background.vertex.glsl.g.ts +2 -0
- package/src/shaders/background_pattern.fragment.glsl.g.ts +2 -0
- package/src/shaders/background_pattern.vertex.glsl.g.ts +2 -0
- package/src/shaders/circle.fragment.glsl.g.ts +2 -0
- package/src/shaders/circle.vertex.glsl.g.ts +2 -0
- package/src/shaders/clipping_mask.fragment.glsl.g.ts +2 -0
- package/src/shaders/clipping_mask.vertex.glsl.g.ts +2 -0
- package/src/shaders/collision_box.fragment.glsl.g.ts +2 -0
- package/src/shaders/collision_box.vertex.glsl.g.ts +2 -0
- package/src/shaders/collision_circle.fragment.glsl.g.ts +2 -0
- package/src/shaders/collision_circle.vertex.glsl.g.ts +2 -0
- package/src/shaders/debug.fragment.glsl.g.ts +2 -0
- package/src/shaders/debug.vertex.glsl.g.ts +2 -0
- package/src/shaders/fill.fragment.glsl.g.ts +2 -0
- package/src/shaders/fill.vertex.glsl.g.ts +2 -0
- package/src/shaders/fill_extrusion.fragment.glsl.g.ts +2 -0
- package/src/shaders/fill_extrusion.vertex.glsl.g.ts +2 -0
- package/src/shaders/fill_extrusion_pattern.fragment.glsl.g.ts +2 -0
- package/src/shaders/fill_extrusion_pattern.vertex.glsl.g.ts +2 -0
- package/src/shaders/fill_outline.fragment.glsl.g.ts +2 -0
- package/src/shaders/fill_outline.vertex.glsl.g.ts +2 -0
- package/src/shaders/fill_outline_pattern.fragment.glsl.g.ts +2 -0
- package/src/shaders/fill_outline_pattern.vertex.glsl.g.ts +2 -0
- package/src/shaders/fill_pattern.fragment.glsl.g.ts +2 -0
- package/src/shaders/fill_pattern.vertex.glsl.g.ts +2 -0
- package/src/shaders/heatmap.fragment.glsl.g.ts +2 -0
- package/src/shaders/heatmap.vertex.glsl.g.ts +2 -0
- package/src/shaders/heatmap_texture.fragment.glsl.g.ts +2 -0
- package/src/shaders/heatmap_texture.vertex.glsl.g.ts +2 -0
- package/src/shaders/hillshade.fragment.glsl.g.ts +2 -0
- package/src/shaders/hillshade.vertex.glsl.g.ts +2 -0
- package/src/shaders/hillshade_prepare.fragment.glsl.g.ts +2 -0
- package/src/shaders/hillshade_prepare.vertex.glsl.g.ts +2 -0
- package/src/shaders/line.fragment.glsl.g.ts +2 -0
- package/src/shaders/line.vertex.glsl.g.ts +2 -0
- package/src/shaders/line_gradient.fragment.glsl.g.ts +2 -0
- package/src/shaders/line_gradient.vertex.glsl.g.ts +2 -0
- package/src/shaders/line_pattern.fragment.glsl.g.ts +2 -0
- package/src/shaders/line_pattern.vertex.glsl.g.ts +2 -0
- package/src/shaders/line_sdf.fragment.glsl.g.ts +2 -0
- package/src/shaders/line_sdf.vertex.glsl.g.ts +2 -0
- package/src/shaders/raster.fragment.glsl.g.ts +2 -0
- package/src/shaders/raster.vertex.glsl.g.ts +2 -0
- package/src/shaders/shaders.ts +52 -55
- package/src/shaders/symbol_icon.fragment.glsl.g.ts +2 -0
- package/src/shaders/symbol_icon.vertex.glsl.g.ts +2 -0
- package/src/shaders/symbol_sdf.fragment.glsl.g.ts +2 -0
- package/src/shaders/symbol_sdf.vertex.glsl.g.ts +2 -0
- package/src/shaders/symbol_text_and_icon.fragment.glsl.g.ts +2 -0
- package/src/shaders/symbol_text_and_icon.vertex.glsl.g.ts +2 -0
- package/src/source/canvas_source.test.ts +11 -12
- package/src/source/canvas_source.ts +4 -4
- package/src/source/geojson_worker_source.ts +23 -23
- package/src/source/geojson_wrapper.ts +8 -8
- package/src/source/image_source.test.ts +2 -2
- package/src/source/image_source.ts +6 -6
- package/src/source/pixels_to_tile_units.ts +6 -6
- package/src/source/query_features.ts +20 -20
- package/src/source/raster_dem_tile_source.test.ts +2 -2
- package/src/source/raster_tile_source.test.ts +2 -2
- package/src/source/rtl_text_plugin.ts +10 -10
- package/src/source/source.ts +29 -29
- package/src/source/source_cache.test.ts +32 -0
- package/src/source/source_cache.ts +7 -5
- package/src/source/source_state.ts +1 -1
- package/src/source/tile.test.ts +3 -3
- package/src/source/tile.ts +15 -15
- package/src/source/tile_cache.ts +6 -6
- package/src/source/tile_id.test.ts +0 -1
- package/src/source/vector_tile_source.test.ts +3 -3
- package/src/source/vector_tile_source.ts +1 -1
- package/src/source/vector_tile_worker_source.test.ts +4 -4
- package/src/source/vector_tile_worker_source.ts +5 -5
- package/src/source/worker.test.ts +1 -1
- package/src/source/worker.ts +22 -22
- package/src/source/worker_source.ts +56 -56
- package/src/source/worker_tile.ts +4 -4
- package/src/style/evaluation_parameters.ts +3 -3
- package/src/style/format_section_override.test.ts +1 -1
- package/src/style/light.ts +10 -10
- package/src/style/load_glyph_range.test.ts +3 -3
- package/src/style/load_glyph_range.ts +6 -6
- package/src/style/load_sprite.ts +4 -4
- package/src/style/pauseable_placement.ts +1 -1
- package/src/style/properties.ts +69 -69
- package/src/style/query_utils.ts +7 -7
- package/src/style/style.test.ts +2 -2
- package/src/style/style.ts +29 -29
- package/src/style/style_glyph.ts +8 -8
- package/src/style/style_image.ts +58 -58
- package/src/style/style_layer/background_style_layer.ts +2 -2
- package/src/style/style_layer/{background_style_layer_properties.ts → background_style_layer_properties.g.ts} +0 -0
- package/src/style/style_layer/circle_style_layer.ts +10 -10
- package/src/style/style_layer/{circle_style_layer_properties.ts → circle_style_layer_properties.g.ts} +0 -0
- package/src/style/style_layer/custom_style_layer.ts +17 -17
- package/src/style/style_layer/fill_extrusion_style_layer.ts +10 -10
- package/src/style/style_layer/{fill_extrusion_style_layer_properties.ts → fill_extrusion_style_layer_properties.g.ts} +0 -0
- package/src/style/style_layer/fill_style_layer.ts +9 -9
- package/src/style/style_layer/{fill_style_layer_properties.ts → fill_style_layer_properties.g.ts} +0 -0
- package/src/style/style_layer/heatmap_style_layer.ts +2 -2
- package/src/style/style_layer/{heatmap_style_layer_properties.ts → heatmap_style_layer_properties.g.ts} +0 -0
- package/src/style/style_layer/hillshade_style_layer.ts +2 -2
- package/src/style/style_layer/{hillshade_style_layer_properties.ts → hillshade_style_layer_properties.g.ts} +0 -0
- package/src/style/style_layer/line_style_layer.ts +9 -9
- package/src/style/style_layer/{line_style_layer_properties.ts → line_style_layer_properties.g.ts} +0 -0
- package/src/style/style_layer/raster_style_layer.ts +2 -2
- package/src/style/style_layer/{raster_style_layer_properties.ts → raster_style_layer_properties.g.ts} +0 -0
- package/src/style/style_layer/symbol_style_layer.ts +7 -7
- package/src/style/style_layer/{symbol_style_layer_properties.ts → symbol_style_layer_properties.g.ts} +0 -0
- package/src/style/style_layer.ts +10 -10
- package/src/style/style_layer_index.ts +3 -3
- package/src/style/validate_style.ts +15 -15
- package/src/style-spec/error/validation_error.ts +1 -1
- package/src/style-spec/expression/compound_expression.ts +3 -3
- package/src/style-spec/expression/definitions/format.ts +11 -11
- package/src/style-spec/expression/definitions/interpolate.ts +5 -5
- package/src/style-spec/expression/definitions/match.ts +2 -2
- package/src/style-spec/expression/definitions/number_format.ts +11 -11
- package/src/style-spec/expression/expression.ts +8 -8
- package/src/style-spec/expression/index.ts +97 -97
- package/src/style-spec/expression/parsing_context.ts +11 -11
- package/src/style-spec/expression/types/collator.ts +9 -9
- package/src/style-spec/expression/types/resolved_image.ts +2 -2
- package/src/style-spec/expression/types.ts +14 -14
- package/src/style-spec/expression/values.ts +1 -1
- package/src/style-spec/feature_filter/index.ts +66 -66
- package/src/style-spec/function/convert.ts +3 -3
- package/src/style-spec/style-spec.ts +44 -44
- package/src/style-spec/util/color_spaces.ts +8 -8
- package/src/style-spec/util/result.ts +4 -4
- package/src/style-spec/validate/validate_filter.ts +58 -58
- package/src/style-spec/validate/validate_source.ts +63 -63
- package/src/style-spec/visit.ts +11 -11
- package/src/symbol/collision_feature.test.ts +1 -1
- package/src/symbol/collision_feature.ts +10 -10
- package/src/symbol/collision_index.ts +26 -26
- package/src/symbol/cross_tile_symbol_index.ts +17 -17
- package/src/symbol/get_anchors.ts +16 -16
- package/src/symbol/grid_index.ts +7 -7
- package/src/symbol/placement.ts +72 -72
- package/src/symbol/projection.ts +30 -30
- package/src/symbol/quads.ts +30 -30
- package/src/symbol/shaping.ts +160 -160
- package/src/symbol/symbol_layout.ts +119 -119
- package/src/symbol/symbol_size.ts +29 -29
- package/src/symbol/symbol_style_layer.test.ts +1 -1
- package/src/types/cancelable.ts +1 -1
- package/src/types/tilejson.ts +13 -13
- package/src/ui/anchor.ts +1 -1
- package/src/ui/camera.test.ts +5 -5
- package/src/ui/camera.ts +18 -18
- package/src/ui/control/attribution_control.test.ts +51 -16
- package/src/ui/control/attribution_control.ts +35 -16
- package/src/ui/control/control.ts +40 -40
- package/src/ui/control/fullscreen_control.ts +1 -1
- package/src/ui/control/geolocate_control.test.ts +1 -1
- package/src/ui/control/geolocate_control.ts +102 -102
- package/src/ui/control/logo_control.test.ts +4 -4
- package/src/ui/control/navigation_control.ts +3 -3
- package/src/ui/control/scale_control.test.ts +2 -2
- package/src/ui/control/scale_control.ts +5 -5
- package/src/ui/events.ts +289 -200
- package/src/ui/handler/box_zoom.test.ts +1 -1
- package/src/ui/handler/box_zoom.ts +1 -1
- package/src/ui/handler/dblclick_zoom.test.ts +1 -1
- package/src/ui/handler/drag_pan.test.ts +1 -1
- package/src/ui/handler/drag_rotate.test.ts +1 -1
- package/src/ui/handler/keyboard.test.ts +1 -1
- package/src/ui/handler/keyboard.ts +51 -51
- package/src/ui/handler/map_event.test.ts +1 -1
- package/src/ui/handler/map_event.ts +1 -1
- package/src/ui/handler/mouse.ts +1 -1
- package/src/ui/handler/mouse_rotate.test.ts +1 -1
- package/src/ui/handler/scroll_zoom.test.ts +1 -1
- package/src/ui/handler/scroll_zoom.ts +9 -9
- package/src/ui/handler/shim/drag_pan.ts +4 -4
- package/src/ui/handler/shim/drag_rotate.ts +1 -1
- package/src/ui/handler/shim/touch_zoom_rotate.ts +1 -1
- package/src/ui/handler/tap_recognizer.ts +4 -4
- package/src/ui/handler/touch_pan.ts +2 -2
- package/src/ui/handler/touch_zoom_rotate.test.ts +1 -1
- package/src/ui/handler/touch_zoom_rotate.ts +1 -1
- package/src/ui/handler_inertia.ts +6 -6
- package/src/ui/handler_manager.ts +44 -44
- package/src/ui/map/isMoving.test.ts +1 -1
- package/src/ui/map/isRotating.test.ts +1 -1
- package/src/ui/map/isZooming.test.ts +1 -1
- package/src/ui/map.test.ts +10 -4
- package/src/ui/map.ts +106 -101
- package/src/ui/map_events.test.ts +1 -1
- package/src/ui/marker.test.ts +12 -12
- package/src/ui/marker.ts +37 -37
- package/src/ui/popup.test.ts +7 -7
- package/src/ui/popup.ts +9 -9
- package/src/util/actor.test.ts +41 -10
- package/src/util/actor.ts +8 -8
- package/src/util/ajax.test.ts +29 -21
- package/src/util/ajax.ts +51 -30
- package/src/util/browser.ts +1 -1
- package/src/util/classify_rings.test.ts +1 -1
- package/src/util/color_ramp.ts +5 -5
- package/src/util/config.ts +2 -2
- package/src/util/dispatcher.ts +1 -1
- package/src/util/dom.ts +2 -2
- package/src/util/evented.ts +1 -1
- package/src/util/find_pole_of_inaccessibility.ts +3 -3
- package/src/util/image.ts +5 -5
- package/src/util/performance.ts +7 -7
- package/src/util/request_manager.ts +4 -4
- package/src/util/resolve_tokens.ts +4 -4
- package/src/util/struct_array.test.ts +1 -1
- package/src/util/struct_array.ts +15 -15
- package/src/util/task_queue.ts +3 -3
- package/src/util/tile_request_cache.ts +3 -3
- package/src/util/transferable_grid_index.ts +4 -4
- package/src/util/util.ts +8 -8
- package/src/util/web_worker.ts +4 -68
- package/src/util/web_worker_transfer.test.ts +3 -0
- package/src/util/web_worker_transfer.ts +21 -17
- package/src/util/worker_pool.ts +1 -1
- package/build/.eslintrc +0 -21
- package/build/glsl_to_js.js +0 -12
- package/build/post-ts-build.js +0 -43
- package/build/release-notes.md.ejs +0 -8
- package/build/test/build-tape.js +0 -17
- package/build/web_worker_replacement.js +0 -5
- package/dist/package.json +0 -1
- package/src/style-spec/validate_spec.test.ts +0 -29
- package/src/symbol/shaping.test.ts +0 -392
- package/src/types/glsl.d.ts +0 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
|
|
3
|
-
const version = JSON.parse(fs.readFileSync('package.json')).version;
|
|
3
|
+
const version = JSON.parse(fs.readFileSync('package.json').toString()).version;
|
|
4
4
|
export default `/* MapLibre GL JS is licensed under the 3-Clause BSD License. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v${version}/LICENSE.txt */`;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import glob from 'glob';
|
|
4
|
+
import localizeURLs from '../test/integration/lib/localize-urls';
|
|
5
|
+
|
|
6
|
+
const OUTPUT_FILE = 'fixtures.json';
|
|
7
|
+
const rootFixturePath = 'test/integration/query/';
|
|
8
|
+
const suitePath = 'tests';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Analyzes the contents of the specified `path.join(rootDirectory, suiteDirectory)`, and inlines
|
|
12
|
+
* the contents into a single json file which can then be imported and built into a bundle
|
|
13
|
+
* to be shipped to the browser.
|
|
14
|
+
* @param rootDirectory - The root directory
|
|
15
|
+
* @param suiteDirectory - The suite directory
|
|
16
|
+
* @param outputDirectory - The output directory
|
|
17
|
+
* @param includeImages - Flag to include images
|
|
18
|
+
*/
|
|
19
|
+
function generateFixtureJson(rootDirectory: string, suiteDirectory: string, outputDirectory: string = 'test/integration/query/dist', includeImages:boolean = false) {
|
|
20
|
+
const globs = getAllFixtureGlobs(rootDirectory, suiteDirectory);
|
|
21
|
+
const jsonPaths = globs[0];
|
|
22
|
+
const imagePaths = globs[1];
|
|
23
|
+
//Extract the filedata into a flat dictionary
|
|
24
|
+
const allFiles = {};
|
|
25
|
+
let allPaths = glob.sync(jsonPaths);
|
|
26
|
+
if (includeImages) {
|
|
27
|
+
allPaths = allPaths.concat(glob.sync(imagePaths));
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
//A Set that stores test names that are malformed so they can be removed later
|
|
31
|
+
const malformedTests = {};
|
|
32
|
+
|
|
33
|
+
for (const fixturePath of allPaths) {
|
|
34
|
+
const testName = path.dirname(fixturePath);
|
|
35
|
+
const fileName = path.basename(fixturePath);
|
|
36
|
+
const extension = path.extname(fixturePath);
|
|
37
|
+
try {
|
|
38
|
+
if (extension === '.json') {
|
|
39
|
+
let json = parseJsonFromFile(fixturePath);
|
|
40
|
+
|
|
41
|
+
//Special case for style json which needs some preprocessing
|
|
42
|
+
if (fileName === 'style.json') {
|
|
43
|
+
json = processStyle(testName, json);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
allFiles[fixturePath] = json;
|
|
47
|
+
} else if (extension === '.png') {
|
|
48
|
+
allFiles[fixturePath] = pngToBase64Str(fixturePath);
|
|
49
|
+
} else {
|
|
50
|
+
throw new Error(`${extension} is incompatible , file path ${fixturePath}`);
|
|
51
|
+
}
|
|
52
|
+
} catch (e) {
|
|
53
|
+
console.log(`Error parsing file: ${fixturePath}`);
|
|
54
|
+
malformedTests[testName] = true;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Re-nest by directory path, each directory path defines a testcase.
|
|
59
|
+
const result = {};
|
|
60
|
+
for (const fullPath in allFiles) {
|
|
61
|
+
const testName = path.dirname(fullPath).replace(rootDirectory, '');
|
|
62
|
+
//Skip if test is malformed
|
|
63
|
+
if (malformedTests[testName]) { continue; }
|
|
64
|
+
|
|
65
|
+
//Lazily initaialize an object to store each file wihin a particular testName
|
|
66
|
+
if (result[testName] == null) {
|
|
67
|
+
result[testName] = {};
|
|
68
|
+
}
|
|
69
|
+
//Trim extension from filename
|
|
70
|
+
const fileName = path.basename(fullPath, path.extname(fullPath));
|
|
71
|
+
result[testName][fileName] = allFiles[fullPath];
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const outputStr = JSON.stringify(result, null, 4);
|
|
75
|
+
const outputPath = path.join(outputDirectory, OUTPUT_FILE);
|
|
76
|
+
|
|
77
|
+
return new Promise<void>((resolve, reject) => {
|
|
78
|
+
fs.writeFile(outputPath, outputStr, {encoding: 'utf8'}, (err) => {
|
|
79
|
+
if (err) { reject(err); }
|
|
80
|
+
|
|
81
|
+
resolve();
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function getAllFixtureGlobs(rootDirectory, suiteDirectory) {
|
|
87
|
+
const basePath = path.join(rootDirectory, suiteDirectory);
|
|
88
|
+
const jsonPaths = path.join(basePath, '/**/*.json');
|
|
89
|
+
const imagePaths = path.join(basePath, '/**/*.png');
|
|
90
|
+
|
|
91
|
+
return [jsonPaths, imagePaths];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function parseJsonFromFile(filePath) {
|
|
95
|
+
return JSON.parse(fs.readFileSync(filePath, {encoding: 'utf8'}));
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function pngToBase64Str(filePath) {
|
|
99
|
+
return fs.readFileSync(filePath).toString('base64');
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function processStyle(testName, style) {
|
|
103
|
+
const clone = JSON.parse(JSON.stringify(style));
|
|
104
|
+
|
|
105
|
+
localizeURLs(clone, 7357);
|
|
106
|
+
|
|
107
|
+
clone.metadata = clone.metadata || {};
|
|
108
|
+
|
|
109
|
+
// eslint-disable-next-line no-restricted-properties
|
|
110
|
+
clone.metadata.test = Object.assign({
|
|
111
|
+
testName,
|
|
112
|
+
width: 512,
|
|
113
|
+
height: 512,
|
|
114
|
+
pixelRatio: 1,
|
|
115
|
+
recycleMap: false,
|
|
116
|
+
allowed: 0.00015
|
|
117
|
+
}, clone.metadata.test);
|
|
118
|
+
|
|
119
|
+
return clone;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// @ts-ignore
|
|
123
|
+
await generateFixtureJson(rootFixturePath, suitePath);
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import glob from 'glob';
|
|
3
|
+
|
|
4
|
+
console.log('Generating shaders');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* This script is intended to copy the glsl file to the compilation output folder,
|
|
8
|
+
* change their extension to .js and export the shaders as strings in javascript.
|
|
9
|
+
* It will also minify them a bit if needed and change the extension to .js
|
|
10
|
+
* After that it will create a combined typescript definition file and manipulate it a bit
|
|
11
|
+
* It will also create a simple package.json file to allow importing this package in webpack
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
glob('./src/shaders/*.glsl', null, (_err, files) => {
|
|
15
|
+
for (const file of files) {
|
|
16
|
+
const code = fs.readFileSync(file, 'utf8');
|
|
17
|
+
const content = glslToTs(code);
|
|
18
|
+
const fileName = `./src/shaders/${file.split('/').splice(-1)}.g.ts`;
|
|
19
|
+
fs.writeFileSync(fileName, content);
|
|
20
|
+
}
|
|
21
|
+
console.log(`Finished converting ${files.length} glsl files`);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
function glslToTs(code: string): string {
|
|
25
|
+
code = code
|
|
26
|
+
.trim() // strip whitespace at the start/end
|
|
27
|
+
.replace(/\s*\/\/[^\n]*\n/g, '\n') // strip double-slash comments
|
|
28
|
+
.replace(/\n+/g, '\n') // collapse multi line breaks
|
|
29
|
+
.replace(/\n\s+/g, '\n') // strip identation
|
|
30
|
+
.replace(/\s?([+-\/*=,])\s?/g, '$1') // strip whitespace around operators
|
|
31
|
+
.replace(/([;\(\),\{\}])\n(?=[^#])/g, '$1'); // strip more line breaks
|
|
32
|
+
|
|
33
|
+
return `// This file is generated. Edit build/generate-shaders.ts, then run \`npm run codegen\`.
|
|
34
|
+
export default ${JSON.stringify(code).replaceAll('"', '\'')};\n`;
|
|
35
|
+
}
|
|
@@ -166,26 +166,26 @@ createStructArrayType('symbol_line_vertex', lineVertex, true);
|
|
|
166
166
|
// feature index array
|
|
167
167
|
createStructArrayType('feature_index', createLayout([
|
|
168
168
|
// the index of the feature in the original vectortile
|
|
169
|
-
{
|
|
169
|
+
{type: 'Uint32', name: 'featureIndex'},
|
|
170
170
|
// the source layer the feature appears in
|
|
171
|
-
{
|
|
171
|
+
{type: 'Uint16', name: 'sourceLayerIndex'},
|
|
172
172
|
// the bucket the feature appears in
|
|
173
|
-
{
|
|
173
|
+
{type: 'Uint16', name: 'bucketIndex'}
|
|
174
174
|
]), true);
|
|
175
175
|
|
|
176
176
|
// triangle index array
|
|
177
177
|
createStructArrayType('triangle_index', createLayout([
|
|
178
|
-
{
|
|
178
|
+
{type: 'Uint16', name: 'vertices', components: 3}
|
|
179
179
|
]));
|
|
180
180
|
|
|
181
181
|
// line index array
|
|
182
182
|
createStructArrayType('line_index', createLayout([
|
|
183
|
-
{
|
|
183
|
+
{type: 'Uint16', name: 'vertices', components: 2}
|
|
184
184
|
]));
|
|
185
185
|
|
|
186
186
|
// line strip index array
|
|
187
187
|
createStructArrayType('line_strip_index', createLayout([
|
|
188
|
-
{
|
|
188
|
+
{type: 'Uint16', name: 'vertices', components: 1}
|
|
189
189
|
]));
|
|
190
190
|
|
|
191
191
|
// paint vertex arrays
|
|
@@ -422,7 +422,7 @@ register('${structArrayClass}', ${structArrayClass});
|
|
|
422
422
|
return output.join('\n');
|
|
423
423
|
}
|
|
424
424
|
|
|
425
|
-
fs.writeFileSync('src/data/array_types.ts',
|
|
425
|
+
fs.writeFileSync('src/data/array_types.g.ts',
|
|
426
426
|
`// This file is generated. Edit build/generate-struct-arrays.ts, then run \`npm run codegen\`.
|
|
427
427
|
|
|
428
428
|
import assert from 'assert';
|
|
@@ -5,13 +5,13 @@ import * as fs from 'fs';
|
|
|
5
5
|
import spec from '../src/style-spec/reference/v8.json';
|
|
6
6
|
|
|
7
7
|
function camelCase(str: string): string {
|
|
8
|
-
return str.replace(/-(.)/g,
|
|
9
|
-
|
|
8
|
+
return str.replace(/-(.)/g, (_, x) => {
|
|
9
|
+
return x.toUpperCase();
|
|
10
10
|
});
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
function pascalCase(str: string): string {
|
|
14
|
-
|
|
14
|
+
const almostCamelized = camelCase(str);
|
|
15
15
|
return almostCamelized[0].toUpperCase() + almostCamelized.slice(1);
|
|
16
16
|
}
|
|
17
17
|
|
|
@@ -37,7 +37,7 @@ function nativeType(property) {
|
|
|
37
37
|
} else {
|
|
38
38
|
return `Array<${nativeType({type: property.value, values: property.values})}>`;
|
|
39
39
|
}
|
|
40
|
-
default: throw new Error(`unknown type for ${property.name}`)
|
|
40
|
+
default: throw new Error(`unknown type for ${property.name}`);
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
|
|
@@ -97,7 +97,7 @@ function runtimeType(property) {
|
|
|
97
97
|
} else {
|
|
98
98
|
return `array(${runtimeType({type: property.value})})`;
|
|
99
99
|
}
|
|
100
|
-
default: throw new Error(`unknown type for ${property.name}`)
|
|
100
|
+
default: throw new Error(`unknown type for ${property.name}`);
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
|
|
@@ -146,7 +146,7 @@ const layers = Object.keys(spec.layer.type.values).map((type) => {
|
|
|
146
146
|
return memo;
|
|
147
147
|
}, []);
|
|
148
148
|
|
|
149
|
-
return {
|
|
149
|
+
return {type, layoutProperties, paintProperties};
|
|
150
150
|
});
|
|
151
151
|
|
|
152
152
|
function emitlayerProperties(locals) {
|
|
@@ -264,12 +264,12 @@ const paint: Properties<${layerType}PaintProps> = new Properties({`);
|
|
|
264
264
|
`});
|
|
265
265
|
|
|
266
266
|
export default ({ paint${layoutProperties.length ? ', layout' : ''} } as {
|
|
267
|
-
paint: Properties<${layerType}PaintProps>${layoutProperties.length ?
|
|
267
|
+
paint: Properties<${layerType}PaintProps>${layoutProperties.length ? `,\n layout: Properties<${layerType}LayoutProps>` : ''}
|
|
268
268
|
});`);
|
|
269
269
|
|
|
270
270
|
return output.join('\n');
|
|
271
271
|
}
|
|
272
272
|
|
|
273
273
|
for (const layer of layers) {
|
|
274
|
-
fs.writeFileSync(`src/style/style_layer/${layer.type.replace('-', '_')}_style_layer_properties.ts`, emitlayerProperties(layer))
|
|
274
|
+
fs.writeFileSync(`src/style/style_layer/${layer.type.replace('-', '_')}_style_layer_properties.g.ts`, emitlayerProperties(layer));
|
|
275
275
|
}
|
|
@@ -24,13 +24,14 @@ function propertyType(property) {
|
|
|
24
24
|
return property.type;
|
|
25
25
|
case 'enum':
|
|
26
26
|
return unionType(property.values);
|
|
27
|
-
case 'array':
|
|
28
|
-
const elementType = propertyType(typeof property.value === 'string' ? {type: property.value, values: property.values} : property.value)
|
|
27
|
+
case 'array': {
|
|
28
|
+
const elementType = propertyType(typeof property.value === 'string' ? {type: property.value, values: property.values} : property.value);
|
|
29
29
|
if (property.length) {
|
|
30
30
|
return `[${Array(property.length).fill(elementType).join(', ')}]`;
|
|
31
31
|
} else {
|
|
32
32
|
return `Array<${elementType}>`;
|
|
33
33
|
}
|
|
34
|
+
}
|
|
34
35
|
case 'light':
|
|
35
36
|
return 'LightSpecification';
|
|
36
37
|
case 'sources':
|
|
@@ -67,7 +68,7 @@ ${Object.keys(properties)
|
|
|
67
68
|
.filter(k => k !== '*')
|
|
68
69
|
.map(k => ` ${indent}${propertyDeclaration(k, properties[k])}`)
|
|
69
70
|
.join(',\n')}
|
|
70
|
-
${indent}}
|
|
71
|
+
${indent}}`;
|
|
71
72
|
}
|
|
72
73
|
|
|
73
74
|
function sourceTypeName(key) {
|
|
@@ -114,7 +115,7 @@ function layerType(key) {
|
|
|
114
115
|
const layerTypes = Object.keys(spec.layer.type.values);
|
|
115
116
|
|
|
116
117
|
fs.writeFileSync('src/style-spec/types.ts',
|
|
117
|
-
`// Generated code; do not edit. Edit build/generate-style-spec.ts instead.
|
|
118
|
+
`// Generated code; do not edit. Edit build/generate-style-spec.ts instead.
|
|
118
119
|
/* eslint-disable */
|
|
119
120
|
|
|
120
121
|
export type ColorSpecification = string;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import childProcess from 'child_process';
|
|
4
|
+
|
|
5
|
+
if (!fs.existsSync('dist')) {
|
|
6
|
+
fs.mkdirSync('dist');
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
console.log('Starting bundling types');
|
|
10
|
+
const outputFile = './dist/maplibre-gl.d.ts';
|
|
11
|
+
childProcess.execSync(`dts-bundle-generator --no-check --umd-module-name=maplibregl -o ${outputFile} ./src/index.ts`);
|
|
12
|
+
let types = fs.readFileSync(outputFile, 'utf8');
|
|
13
|
+
// Classes are not exported but should be since this is exported as UMD - fixing...
|
|
14
|
+
types = types.replace(/declare class/g, 'export declare class');
|
|
15
|
+
fs.writeFileSync(outputFile, types);
|
|
16
|
+
console.log('Finished bundling types');
|
package/build/readme.md
CHANGED
|
@@ -1,38 +1,31 @@
|
|
|
1
1
|
# Build Scripts
|
|
2
2
|
This folder holds common build scripts accessed via the various `npm run` commands.
|
|
3
|
-
|
|
3
|
+
Codegen is executed when calling `npm install` in order to generate all artifacts needed for the build to pass
|
|
4
4
|
## Bundeling all the code
|
|
5
5
|
|
|
6
6
|
The bundeling process can be split into several steps:
|
|
7
7
|
|
|
8
|
-
`npx run tsc`
|
|
9
|
-
This command will transpile all the typescript files into javascript files and place them in the `rollup/build` folder.
|
|
10
|
-
|
|
11
|
-
`npm run build-glsl`
|
|
12
|
-
This command will copy all the shader files to the build output and convert the shaders into strings that can be imported to javascript.
|
|
13
|
-
|
|
14
8
|
`npm run build-css`
|
|
15
9
|
This command will compile the css code and create the css file.
|
|
16
10
|
|
|
17
11
|
`npm run build-prod` or `npm run build-prod-min` or `npm run build-dev`
|
|
18
12
|
These commands will use rollup to bundle the code. This is where the magic happens and uses some files in this folder.
|
|
19
13
|
|
|
20
|
-
`banner.
|
|
14
|
+
`banner.ts` is used to create a banner at the beginning of the output file
|
|
21
15
|
|
|
22
|
-
`rollup_plugins.
|
|
16
|
+
`rollup_plugins.ts` is used to define common plugins for rollup configurations
|
|
23
17
|
|
|
24
|
-
`rollup_plugin_minify_style_spec.
|
|
18
|
+
`rollup_plugin_minify_style_spec.ts` is used to specify the plugin used in style spec bundeling
|
|
25
19
|
|
|
26
20
|
In the `rollup` folder there are some files that are used as linking files as they link to other files for rollup to pick when bundling.
|
|
27
|
-
Rollup also has a configuration in the `package.json` file to signal which files it needs to replace when bundling for the browser, this is where `web_worker_replacement.js` is used - as it replaces the node mocking of web worker that is present in the source code.
|
|
28
21
|
|
|
29
22
|
Rollup is generating 3 files throughout the process of bundling:
|
|
30
23
|
|
|
31
|
-
`index.
|
|
24
|
+
`index.ts` a file containing all the code that will run in the main thread.
|
|
32
25
|
|
|
33
|
-
`shared.
|
|
26
|
+
`shared.ts` a file containing all the code shared between the main and worker code.
|
|
34
27
|
|
|
35
|
-
`worker.
|
|
28
|
+
`worker.ts` a file containing all the code the will run in the worker threads.
|
|
36
29
|
|
|
37
30
|
These 3 files are then referenced and used by the `bundle_prelude.js` file. It allows loading the web wroker code automatically in web workers without any extra effort from someone who would like to use the library, i.e. it simply works.
|
|
38
31
|
|
|
@@ -55,8 +48,5 @@ Generates `style-spec/types.ts` based on the content of `v8.json`. This provides
|
|
|
55
48
|
<hr>
|
|
56
49
|
|
|
57
50
|
### Generate Release Nodes
|
|
58
|
-
The following files are being used to generate release notes:
|
|
59
|
-
|
|
60
|
-
`release-notes.js` Used to generate release notes when releasing a new version
|
|
61
51
|
|
|
62
|
-
`release-notes.
|
|
52
|
+
`release-notes.js` Used to generate release notes when releasing a new version
|
package/build/release-notes.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
import * as fs from 'fs';
|
|
4
|
-
import * as ejs from 'ejs';
|
|
5
4
|
import semver from 'semver';
|
|
6
5
|
|
|
7
6
|
const changelogPath = 'CHANGELOG.md';
|
|
@@ -32,18 +31,15 @@ while (match = regex.exec(changelog)) {
|
|
|
32
31
|
const latest = releaseNotes[0];
|
|
33
32
|
const previous = releaseNotes[1];
|
|
34
33
|
|
|
35
|
-
/*
|
|
36
|
-
Fill and print the release notes template.
|
|
37
|
-
*/
|
|
38
|
-
let templatedReleaseNotes;
|
|
39
34
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
|
|
35
|
+
// Print the release notes template.
|
|
36
|
+
|
|
37
|
+
const templatedReleaseNotes = `https://github.com/maplibre/maplibre-gl-js
|
|
38
|
+
[Changes](https://github.com/maplibre/maplibre-gl-js/compare/v${previous.version}...v${latest.version}) since [MapLibre GL JS v${previous.version}](https://github.com/maplibre/releases/tag/v${previous.version}):
|
|
39
|
+
|
|
40
|
+
${latest.changelog}
|
|
41
|
+
|
|
42
|
+
${semver.prerelease(latest.version) ? 'Pre-release version' : ''}`;
|
|
47
43
|
|
|
48
44
|
// eslint-disable-next-line eol-last
|
|
49
|
-
process.stdout.write(templatedReleaseNotes);
|
|
45
|
+
process.stdout.write(templatedReleaseNotes.trimEnd());
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import {Plugin} from 'rollup';
|
|
1
2
|
|
|
2
|
-
function replacer(
|
|
3
|
-
return (
|
|
3
|
+
function replacer(key: string, value: any) {
|
|
4
|
+
return (key === 'doc' || key === 'example' || key === 'sdk-support') ? undefined : value;
|
|
4
5
|
}
|
|
5
6
|
|
|
6
|
-
export default function minifyStyleSpec() {
|
|
7
|
+
export default function minifyStyleSpec(): Plugin {
|
|
7
8
|
return {
|
|
8
9
|
name: 'minify-style-spec',
|
|
9
10
|
transform: (source, id) => {
|
|
@@ -6,15 +6,18 @@ import commonjs from '@rollup/plugin-commonjs';
|
|
|
6
6
|
import unassert from 'rollup-plugin-unassert';
|
|
7
7
|
import json from '@rollup/plugin-json';
|
|
8
8
|
import {terser} from 'rollup-plugin-terser';
|
|
9
|
-
import minifyStyleSpec from './rollup_plugin_minify_style_spec
|
|
10
|
-
import {createFilter} from 'rollup-pluginutils';
|
|
9
|
+
import minifyStyleSpec from './rollup_plugin_minify_style_spec';
|
|
11
10
|
import strip from '@rollup/plugin-strip';
|
|
12
|
-
import
|
|
13
|
-
|
|
11
|
+
import {Plugin} from 'rollup';
|
|
14
12
|
// Common set of plugins/transformations shared across different rollup
|
|
15
13
|
// builds (main maplibre bundle, style-spec package, benchmarks bundle)
|
|
16
14
|
|
|
17
|
-
export const
|
|
15
|
+
export const nodeResolve = resolve({
|
|
16
|
+
browser: true,
|
|
17
|
+
preferBuiltins: false
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
export const plugins = (minified: boolean, production: boolean): Plugin[] => [
|
|
18
21
|
minifyStyleSpec(),
|
|
19
22
|
json(),
|
|
20
23
|
// https://github.com/zaach/jison/issues/351
|
|
@@ -30,9 +33,9 @@ export const plugins = (minified, production, watch) => [
|
|
|
30
33
|
sourceMap: true,
|
|
31
34
|
functions: ['PerformanceUtils.*', 'Debug.*']
|
|
32
35
|
}) : false,
|
|
33
|
-
glsl('**/*.glsl', production),
|
|
34
36
|
minified ? terser({
|
|
35
37
|
compress: {
|
|
38
|
+
// eslint-disable-next-line camelcase
|
|
36
39
|
pure_getters: true,
|
|
37
40
|
passes: 3
|
|
38
41
|
}
|
|
@@ -40,29 +43,11 @@ export const plugins = (minified, production, watch) => [
|
|
|
40
43
|
production ? unassert({
|
|
41
44
|
include: ['**/*'], // by default, unassert only includes .js files
|
|
42
45
|
}) : false,
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
preferBuiltins: false
|
|
46
|
-
}),
|
|
47
|
-
watch ? typescript() : false,
|
|
46
|
+
nodeResolve,
|
|
47
|
+
typescript(),
|
|
48
48
|
commonjs({
|
|
49
49
|
// global keyword handling causes Webpack compatibility issues, so we disabled it:
|
|
50
50
|
// https://github.com/mapbox/mapbox-gl-js/pull/6956
|
|
51
51
|
ignoreGlobal: true
|
|
52
52
|
})
|
|
53
53
|
].filter(Boolean);
|
|
54
|
-
|
|
55
|
-
// Using this instead of rollup-plugin-string to add minification
|
|
56
|
-
function glsl(include, minify) {
|
|
57
|
-
const filter = createFilter(include);
|
|
58
|
-
return {
|
|
59
|
-
name: 'glsl',
|
|
60
|
-
transform(code, id) {
|
|
61
|
-
if (!filter(id)) return;
|
|
62
|
-
return {
|
|
63
|
-
code: glsl_to_js(code, minify),
|
|
64
|
-
map: {mappings: ''}
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
}
|