maplibre-gl 2.0.4 → 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} +12 -26
- package/dist/maplibre-gl-dev.js +54885 -0
- package/dist/maplibre-gl.css +1 -1
- package/dist/maplibre-gl.d.ts +1583 -1023
- package/dist/maplibre-gl.js +3 -3
- package/dist/maplibre-gl.js.map +1 -1
- package/package.json +99 -141
- package/src/css/maplibre-gl.css +36 -36
- 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 +56 -56
- 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 +47 -47
- 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_debug.ts +1 -1
- 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 +34 -33
- package/src/render/image_manager.ts +4 -4
- package/src/render/painter.ts +16 -14
- package/src/render/program/background_program.ts +29 -29
- package/src/render/program/circle_program.ts +11 -11
- 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 +41 -41
- package/src/render/program/pattern.ts +28 -28
- package/src/render/program/raster_program.ts +21 -21
- package/src/render/program/symbol_program.ts +97 -97
- 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_source.test.ts +2 -1
- package/src/source/geojson_source.ts +1 -1
- package/src/source/geojson_worker_source.ts +23 -23
- package/src/source/geojson_wrapper.ts +8 -8
- package/src/source/image_source.test.ts +153 -0
- 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 +4 -3
- package/src/source/raster_dem_tile_source.ts +1 -1
- package/src/source/raster_tile_source.test.ts +4 -3
- package/src/source/raster_tile_source.ts +1 -1
- package/src/source/rtl_text_plugin.ts +10 -10
- package/src/source/source.ts +29 -29
- package/src/source/source_cache.test.ts +33 -1
- 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.test.ts +6 -4
- package/src/source/tile_cache.ts +6 -6
- package/src/source/tile_id.test.ts +10 -13
- package/src/source/tile_id.ts +2 -2
- package/src/source/vector_tile_source.test.ts +17 -5
- package/src/source/vector_tile_source.ts +4 -5
- 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 -5
- package/src/style/load_glyph_range.ts +6 -6
- package/src/style/load_sprite.ts +5 -4
- package/src/style/pauseable_placement.ts +1 -1
- package/src/style/properties.ts +70 -70
- package/src/style/query_utils.ts +7 -7
- package/src/style/style.test.ts +26 -15
- package/src/style/style.ts +30 -30
- 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 +19 -19
- package/src/style/style_layer/fill_extrusion_style_layer.ts +11 -11
- 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 +26 -7
- package/src/style/style_layer/{symbol_style_layer_properties.ts → symbol_style_layer_properties.g.ts} +6 -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/CHANGELOG.md +6 -0
- 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/package.json +1 -1
- package/src/style-spec/reference/v8.json +68 -2
- package/src/style-spec/style-spec.ts +44 -44
- package/src/style-spec/types.ts +2 -0
- 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 +43 -43
- package/src/symbol/cross_tile_symbol_index.ts +17 -17
- package/src/symbol/get_anchors.ts +16 -16
- package/src/symbol/grid_index.test.ts +42 -19
- package/src/symbol/grid_index.ts +69 -40
- package/src/symbol/placement.ts +124 -95
- 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 +49 -2
- 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 +9 -9
- package/src/ui/camera.ts +26 -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 +5 -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 +3 -2
- 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 +87 -14
- package/src/ui/map.ts +138 -108
- 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 +214 -0
- 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/test/util.ts +14 -0
- 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
|
@@ -6,30 +6,31 @@ import {StylePropertyFunction, StyleExpression, ZoomDependentExpression, ZoomCon
|
|
|
6
6
|
import CompoundExpression from '../style-spec/expression/compound_expression';
|
|
7
7
|
import expressions from '../style-spec/expression/definitions';
|
|
8
8
|
import ResolvedImage from '../style-spec/expression/types/resolved_image';
|
|
9
|
+
import {AJAXError} from './ajax';
|
|
9
10
|
|
|
10
11
|
import type {Transferable} from '../types/transferable';
|
|
11
12
|
import {isImageBitmap} from './util';
|
|
12
13
|
|
|
13
14
|
type SerializedObject = {
|
|
14
|
-
|
|
15
|
+
[_: string]: Serialized;
|
|
15
16
|
}; // eslint-disable-line
|
|
16
17
|
|
|
17
|
-
export type Serialized = null | void | boolean | number | string | Boolean | Number | String | Date | RegExp | ArrayBuffer | ArrayBufferView | ImageData | ImageBitmap | Array<Serialized> | SerializedObject;
|
|
18
|
+
export type Serialized = null | void | boolean | number | string | Boolean | Number | String | Date | RegExp | ArrayBuffer | ArrayBufferView | ImageData | ImageBitmap | Blob | Array<Serialized> | SerializedObject;
|
|
18
19
|
|
|
19
20
|
type Registry = {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
[_: string]: {
|
|
22
|
+
klass: {
|
|
23
|
+
new (...args: any): any;
|
|
24
|
+
deserialize?: (input: Serialized) => unknown;
|
|
25
|
+
};
|
|
26
|
+
omit: ReadonlyArray<string>;
|
|
27
|
+
shallow: ReadonlyArray<string>;
|
|
24
28
|
};
|
|
25
|
-
omit: ReadonlyArray<string>;
|
|
26
|
-
shallow: ReadonlyArray<string>;
|
|
27
|
-
};
|
|
28
29
|
};
|
|
29
30
|
|
|
30
31
|
type RegisterOptions<T> = {
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
omit?: ReadonlyArray<keyof T>;
|
|
33
|
+
shallow?: ReadonlyArray<keyof T>;
|
|
33
34
|
};
|
|
34
35
|
|
|
35
36
|
const registry: Registry = {};
|
|
@@ -44,11 +45,11 @@ const registry: Registry = {};
|
|
|
44
45
|
* @private
|
|
45
46
|
*/
|
|
46
47
|
export function register<T extends any>(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
name: string,
|
|
49
|
+
klass: {
|
|
50
|
+
new (...args: any): T;
|
|
51
|
+
},
|
|
52
|
+
options: RegisterOptions<T> = {}
|
|
52
53
|
) {
|
|
53
54
|
assert(!registry[name], `${name} is already registered.`);
|
|
54
55
|
((Object.defineProperty as any))(klass, '_classRegistryKey', {
|
|
@@ -67,6 +68,7 @@ register('TransferableGridIndex', TransferableGridIndex);
|
|
|
67
68
|
|
|
68
69
|
register('Color', Color);
|
|
69
70
|
register('Error', Error);
|
|
71
|
+
register('AJAXError', AJAXError);
|
|
70
72
|
register('ResolvedImage', ResolvedImage);
|
|
71
73
|
|
|
72
74
|
register('StylePropertyFunction', StylePropertyFunction);
|
|
@@ -109,7 +111,8 @@ export function serialize(input: unknown, transferables?: Array<Transferable> |
|
|
|
109
111
|
input instanceof Number ||
|
|
110
112
|
input instanceof String ||
|
|
111
113
|
input instanceof Date ||
|
|
112
|
-
input instanceof RegExp
|
|
114
|
+
input instanceof RegExp ||
|
|
115
|
+
input instanceof Blob) {
|
|
113
116
|
return input;
|
|
114
117
|
}
|
|
115
118
|
|
|
@@ -210,6 +213,7 @@ export function deserialize(input: Serialized): unknown {
|
|
|
210
213
|
input instanceof String ||
|
|
211
214
|
input instanceof Date ||
|
|
212
215
|
input instanceof RegExp ||
|
|
216
|
+
input instanceof Blob ||
|
|
213
217
|
isArrayBuffer(input) ||
|
|
214
218
|
isImageBitmap(input) ||
|
|
215
219
|
ArrayBuffer.isView(input) ||
|
package/src/util/worker_pool.ts
CHANGED
package/build/.eslintrc
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
// TODO: most of these overrides should be removed,
|
|
3
|
-
// but for now this documents the exceptions used by the code in this dir
|
|
4
|
-
"rules": {
|
|
5
|
-
"import/no-commonjs": "off",
|
|
6
|
-
"flowtype/require-valid-file-annotation": [0],
|
|
7
|
-
"prefer-arrow-callback": "off",
|
|
8
|
-
"no-var": "off",
|
|
9
|
-
"strict": "off",
|
|
10
|
-
"no-restricted-properties": "off",
|
|
11
|
-
"no-unused-vars": "off",
|
|
12
|
-
"prefer-template": "off",
|
|
13
|
-
"camelcase": "off",
|
|
14
|
-
"prefer-const": "off",
|
|
15
|
-
"indent": "off",
|
|
16
|
-
"no-case-declarations": "off",
|
|
17
|
-
"semi": "off",
|
|
18
|
-
"object-curly-spacing": "off",
|
|
19
|
-
"no-undef": "off"
|
|
20
|
-
}
|
|
21
|
-
}
|
package/build/glsl_to_js.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export default function glsl_to_js(code, minify) {
|
|
2
|
-
if (minify) {
|
|
3
|
-
code = code.trim() // strip whitespace at the start/end
|
|
4
|
-
.replace(/\s*\/\/[^\n]*\n/g, '\n') // strip double-slash comments
|
|
5
|
-
.replace(/\n+/g, '\n') // collapse multi line breaks
|
|
6
|
-
.replace(/\n\s+/g, '\n') // strip identation
|
|
7
|
-
.replace(/\s?([+-\/*=,])\s?/g, '$1') // strip whitespace around operators
|
|
8
|
-
.replace(/([;\(\),\{\}])\n(?=[^#])/g, '$1'); // strip more line breaks
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
return `export default ${JSON.stringify(code)};`;
|
|
12
|
-
}
|
package/build/post-ts-build.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import glob from 'glob';
|
|
3
|
-
import child_process from 'child_process';
|
|
4
|
-
import glsl_to_js from './glsl_to_js.js';
|
|
5
|
-
|
|
6
|
-
let args = process.argv.slice(2);
|
|
7
|
-
let outputBaseDir = args[0];
|
|
8
|
-
let minify = args[1];
|
|
9
|
-
|
|
10
|
-
console.log(`Copying glsl files to ${outputBaseDir}, minify: ${minify}`);
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* This script is intended to copy the glsl file to the compilation output folder,
|
|
14
|
-
* change their extension to .js and export the shaders as strings in javascript.
|
|
15
|
-
* It will also minify them a bit if needed and change the extension to .js
|
|
16
|
-
* After that it will create a combined typescript definition file and manipulate it a bit
|
|
17
|
-
* It will also create a simple package.json file to allow importing this package in webpack
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
glob("./src/**/*.glsl", null, (err, files) => {
|
|
21
|
-
for (let file of files) {
|
|
22
|
-
let code = fs.readFileSync(file, 'utf8');
|
|
23
|
-
let content = glsl_to_js(code, minify);
|
|
24
|
-
let fileName = outputBaseDir + '/' + file.split('/').splice(-1) + ".js";
|
|
25
|
-
fs.writeFileSync(fileName, content);
|
|
26
|
-
}
|
|
27
|
-
console.log(`Finished converting ${files.length} glsl files`);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
if (!fs.existsSync("dist")) {
|
|
31
|
-
fs.mkdirSync("dist");
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
console.log(`Starting bundling types`);
|
|
35
|
-
const outputFile = "./dist/maplibre-gl.d.ts";
|
|
36
|
-
child_process.execSync(`dts-bundle-generator --no-check --umd-module-name=maplibregl -o ${outputFile} ./src/index.ts`);
|
|
37
|
-
let types = fs.readFileSync(outputFile, 'utf8');
|
|
38
|
-
// Classes are not exported but should be since this is exported as UMD - fixing...
|
|
39
|
-
types = types.replace(/declare class/g, "export declare class");
|
|
40
|
-
fs.writeFileSync(outputFile, types);
|
|
41
|
-
console.log(`Finished bundling types`);
|
|
42
|
-
|
|
43
|
-
fs.writeFileSync("./dist/package.json", '{ "type": "commonjs" }');
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
https://github.com/maplibre/maplibre-gl-js
|
|
2
|
-
[Changes](https://github.com/maplibre/maplibre-gl-js/compare/v<%-PREVIOUSVERSION%>...v<%-CURRENTVERSION%>) since [MapLibre GL JS v<%-PREVIOUSVERSION%>](https://github.com/maplibre/releases/tag/v<%-PREVIOUSVERSION%>):
|
|
3
|
-
|
|
4
|
-
<%-CHANGELOG-%>
|
|
5
|
-
|
|
6
|
-
<% if (isPrerelease) { %>
|
|
7
|
-
Pre-release version
|
|
8
|
-
<% } -%>
|
package/build/test/build-tape.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import browserify from 'browserify';
|
|
2
|
-
import fs from 'fs';
|
|
3
|
-
|
|
4
|
-
export default function() {
|
|
5
|
-
return new Promise((resolve, reject) => {
|
|
6
|
-
browserify('./test/util/tape_config.js', { standalone: 'tape' })
|
|
7
|
-
.transform('babelify', {presets: ['@babel/preset-env'], global: true})
|
|
8
|
-
.bundle((err, buff) => {
|
|
9
|
-
if (err) { throw err; }
|
|
10
|
-
|
|
11
|
-
fs.writeFile('test/integration/dist/tape.js', buff, { encoding: 'utf8'}, (err) => {
|
|
12
|
-
if (err) { reject(err); }
|
|
13
|
-
resolve();
|
|
14
|
-
});
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
}
|
package/dist/package.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{ "type": "commonjs" }
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import glob from 'glob';
|
|
2
|
-
import fs from 'fs';
|
|
3
|
-
import path from 'path';
|
|
4
|
-
import validate from '../style-spec/validate_style';
|
|
5
|
-
import reference from './reference/latest';
|
|
6
|
-
|
|
7
|
-
const UPDATE = !!process.env.UPDATE;
|
|
8
|
-
|
|
9
|
-
describe('validate_spec', () => {
|
|
10
|
-
glob.sync('test/unit/style-spec/fixture/*.input.json').forEach((file) => {
|
|
11
|
-
test(path.basename(file), () => {
|
|
12
|
-
const outputfile = file.replace('.input', '.output');
|
|
13
|
-
const style = fs.readFileSync(file);
|
|
14
|
-
const result = validate(style);
|
|
15
|
-
if (UPDATE) fs.writeFileSync(outputfile, JSON.stringify(result, null, 2));
|
|
16
|
-
const expectedOutput = JSON.parse(fs.readFileSync(outputfile).toString());
|
|
17
|
-
expect(result).toEqual(expectedOutput);
|
|
18
|
-
});
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
test('errors from validate do not contain line numbers', () => {
|
|
22
|
-
const fixtures = glob.sync('test/unit/style-spec/fixture/*.input.json');
|
|
23
|
-
const style = JSON.parse(fs.readFileSync(fixtures[0]).toString());
|
|
24
|
-
|
|
25
|
-
const result = validate(style, reference);
|
|
26
|
-
expect(result[0].line).toBeUndefined();
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
});
|
|
@@ -1,392 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import {WritingMode, shapeIcon, shapeText, fitIconToText, PositionedIcon, Shaping} from './shaping';
|
|
4
|
-
import Formatted, {FormattedSection} from '../style-spec/expression/types/formatted';
|
|
5
|
-
import ResolvedImage from '../style-spec/expression/types/resolved_image';
|
|
6
|
-
import expectedJson from '../../test/expected/text-shaping-linebreak.json';
|
|
7
|
-
import {ImagePosition} from '../render/image_atlas';
|
|
8
|
-
import {StyleImage} from '../style/style_image';
|
|
9
|
-
|
|
10
|
-
let UPDATE = false;
|
|
11
|
-
if (typeof process !== 'undefined' && process.env !== undefined) {
|
|
12
|
-
UPDATE = !!process.env.UPDATE;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
describe('shaping', () => {
|
|
16
|
-
const oneEm = 24;
|
|
17
|
-
const layoutTextSize = 16;
|
|
18
|
-
const layoutTextSizeThisZoom = 16;
|
|
19
|
-
const fontStack = 'Test';
|
|
20
|
-
const glyphs = {
|
|
21
|
-
'Test': require('../../test/fixtures/fontstack-glyphs.json')
|
|
22
|
-
};
|
|
23
|
-
const glyphPositions = glyphs;
|
|
24
|
-
|
|
25
|
-
const images = {
|
|
26
|
-
'square': new ImagePosition({x: 0, y: 0, w: 16, h: 16}, {pixelRatio: 1, version: 1} as StyleImage),
|
|
27
|
-
'tall': new ImagePosition({x: 0, y: 0, w: 16, h: 32}, {pixelRatio: 1, version: 1} as StyleImage),
|
|
28
|
-
'wide': new ImagePosition({x: 0, y: 0, w: 32, h: 16}, {pixelRatio: 1, version: 1} as StyleImage),
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
const sectionForImage = (name) => {
|
|
32
|
-
return new FormattedSection('', ResolvedImage.fromString(name), null, null, null);
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
const sectionForText = (name, scale?) => {
|
|
36
|
-
return new FormattedSection(name, null, scale, null, null);
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
let shaped;
|
|
40
|
-
|
|
41
|
-
JSON.parse('{}');
|
|
42
|
-
|
|
43
|
-
shaped = shapeText(Formatted.fromString(`hi${String.fromCharCode(0)}`), glyphs, glyphPositions, images, fontStack, 15 * oneEm, oneEm, 'center', 'center', 0 * oneEm, [0, 0], WritingMode.horizontal, false, 'point', layoutTextSize, layoutTextSizeThisZoom);
|
|
44
|
-
if (UPDATE) fs.writeFileSync(path.resolve(__dirname, '../../test/expected/text-shaping-null.json'), JSON.stringify(shaped, null, 2));
|
|
45
|
-
expect(shaped).toEqual(
|
|
46
|
-
require('../../test/expected/text-shaping-null.json')
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
// Default shaping.
|
|
50
|
-
shaped = shapeText(Formatted.fromString('abcde'), glyphs, glyphPositions, images, fontStack, 15 * oneEm, oneEm, 'center', 'center', 0 * oneEm, [0, 0], WritingMode.horizontal, false, 'point', layoutTextSize, layoutTextSizeThisZoom);
|
|
51
|
-
if (UPDATE) fs.writeFileSync(path.resolve(__dirname, '../../test/expected/text-shaping-default.json'), JSON.stringify(shaped, null, 2));
|
|
52
|
-
expect(shaped).toEqual(
|
|
53
|
-
require('../../test/expected/text-shaping-default.json')
|
|
54
|
-
);
|
|
55
|
-
|
|
56
|
-
// Letter spacing.
|
|
57
|
-
shaped = shapeText(Formatted.fromString('abcde'), glyphs, glyphPositions, images, fontStack, 15 * oneEm, oneEm, 'center', 'center', 0.125 * oneEm, [0, 0], WritingMode.horizontal, false, 'point', layoutTextSize, layoutTextSizeThisZoom);
|
|
58
|
-
if (UPDATE) fs.writeFileSync(path.resolve(__dirname, '../../test/expected/text-shaping-spacing.json'), JSON.stringify(shaped, null, 2));
|
|
59
|
-
expect(shaped).toEqual(
|
|
60
|
-
require('../../test/expected/text-shaping-spacing.json')
|
|
61
|
-
);
|
|
62
|
-
|
|
63
|
-
// Line break.
|
|
64
|
-
shaped = shapeText(Formatted.fromString('abcde abcde'), glyphs, glyphPositions, images, fontStack, 4 * oneEm, oneEm, 'center', 'center', 0 * oneEm, [0, 0], WritingMode.horizontal, false, 'point', layoutTextSize, layoutTextSizeThisZoom);
|
|
65
|
-
if (UPDATE) fs.writeFileSync(path.resolve(__dirname, '../../test/expected/text-shaping-linebreak.json'), JSON.stringify(shaped, null, 2));
|
|
66
|
-
expect(shaped).toEqual(expectedJson);
|
|
67
|
-
|
|
68
|
-
const expectedNewLine = require('../../test/expected/text-shaping-newline.json');
|
|
69
|
-
|
|
70
|
-
shaped = shapeText(Formatted.fromString('abcde\nabcde'), glyphs, glyphPositions, images, fontStack, 15 * oneEm, oneEm, 'center', 'center', 0, [0, 0], WritingMode.horizontal, false, 'point', layoutTextSize, layoutTextSizeThisZoom);
|
|
71
|
-
if (UPDATE) fs.writeFileSync(path.resolve(__dirname, '../../test/expected/text-shaping-newline.json'), JSON.stringify(shaped, null, 2));
|
|
72
|
-
expect(shaped).toEqual(expectedNewLine);
|
|
73
|
-
|
|
74
|
-
shaped = shapeText(Formatted.fromString('abcde\r\nabcde'), glyphs, glyphPositions, images, fontStack, 15 * oneEm, oneEm, 'center', 'center', 0, [0, 0], WritingMode.horizontal, false, 'point', layoutTextSize, layoutTextSizeThisZoom);
|
|
75
|
-
expect(shaped.positionedLines).toEqual(expectedNewLine.positionedLines);
|
|
76
|
-
|
|
77
|
-
const expectedNewLinesInMiddle = require('../../test/expected/text-shaping-newlines-in-middle.json');
|
|
78
|
-
|
|
79
|
-
shaped = shapeText(Formatted.fromString('abcde\n\nabcde'), glyphs, glyphPositions, images, fontStack, 15 * oneEm, oneEm, 'center', 'center', 0, [0, 0], WritingMode.horizontal, false, 'point', layoutTextSize, layoutTextSizeThisZoom);
|
|
80
|
-
if (UPDATE) fs.writeFileSync(path.resolve(__dirname, '../../test/expected/text-shaping-newlines-in-middle.json'), JSON.stringify(shaped, null, 2));
|
|
81
|
-
expect(shaped).toEqual(expectedNewLinesInMiddle);
|
|
82
|
-
|
|
83
|
-
// Prefer zero width spaces when breaking lines. Zero width spaces are used by MapLibre data sources as a hint that
|
|
84
|
-
// a position is ideal for breaking.
|
|
85
|
-
const expectedZeroWidthSpaceBreak = require('../../test/expected/text-shaping-zero-width-space.json');
|
|
86
|
-
|
|
87
|
-
shaped = shapeText(Formatted.fromString('三三\u200b三三\u200b三三\u200b三三三三三三\u200b三三'), glyphs, glyphPositions, images, fontStack, 5 * oneEm, oneEm, 'center', 'center', 0, [0, 0], WritingMode.horizontal, false, 'point', layoutTextSize, layoutTextSizeThisZoom);
|
|
88
|
-
if (UPDATE) fs.writeFileSync(path.resolve(__dirname, '../../test/expected/text-shaping-zero-width-space.json'), JSON.stringify(shaped, null, 2));
|
|
89
|
-
expect(shaped).toEqual(expectedZeroWidthSpaceBreak);
|
|
90
|
-
|
|
91
|
-
// Null shaping.
|
|
92
|
-
shaped = shapeText(Formatted.fromString(''), glyphs, glyphPositions, images, fontStack, 15 * oneEm, oneEm, 'center', 'center', 0 * oneEm, [0, 0], WritingMode.horizontal, false, 'point', layoutTextSize, layoutTextSizeThisZoom);
|
|
93
|
-
expect(false).toBe(shaped);
|
|
94
|
-
|
|
95
|
-
shaped = shapeText(Formatted.fromString(String.fromCharCode(0)), glyphs, glyphPositions, images, fontStack, 15 * oneEm, oneEm, 'center', 'center', 0 * oneEm, [0, 0], WritingMode.horizontal, false, 'point', layoutTextSize, layoutTextSizeThisZoom);
|
|
96
|
-
expect(false).toBe(shaped);
|
|
97
|
-
|
|
98
|
-
// https://github.com/mapbox/mapbox-gl-js/issues/3254
|
|
99
|
-
shaped = shapeText(Formatted.fromString(' foo bar\n'), glyphs, glyphPositions, images, fontStack, 15 * oneEm, oneEm, 'center', 'center', 0 * oneEm, [0, 0], WritingMode.horizontal, false, 'point', layoutTextSize, layoutTextSizeThisZoom);
|
|
100
|
-
const shaped2 = shapeText(Formatted.fromString('foo bar'), glyphs, glyphPositions, images, fontStack, 15 * oneEm, oneEm, 'center', 'center', 0 * oneEm, [0, 0], WritingMode.horizontal, false, 'point', layoutTextSize, layoutTextSizeThisZoom) as Shaping;
|
|
101
|
-
expect(shaped.positionedLines).toEqual(shaped2.positionedLines);
|
|
102
|
-
|
|
103
|
-
test('basic image shaping', () => {
|
|
104
|
-
const shaped = shapeText(new Formatted([sectionForImage('square')]), glyphs, glyphPositions, images, fontStack, 5 * oneEm, oneEm, 'center', 'center', 0, [0, 0], WritingMode.horizontal, false, 'point', layoutTextSize, layoutTextSizeThisZoom) as Shaping;
|
|
105
|
-
expect(shaped.top).toEqual(-12); // 1em line height
|
|
106
|
-
expect(shaped.left).toEqual(-10.5); // 16 - 2px border * 1.5 scale factor
|
|
107
|
-
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
test('images in horizontal layout', () => {
|
|
111
|
-
const expectedImagesHorizontal = require('../../test/expected/text-shaping-images-horizontal.json');
|
|
112
|
-
const horizontalFormatted = new Formatted([
|
|
113
|
-
sectionForText('Foo'),
|
|
114
|
-
sectionForImage('square'),
|
|
115
|
-
sectionForImage('wide'),
|
|
116
|
-
sectionForText('\n'),
|
|
117
|
-
sectionForImage('tall'),
|
|
118
|
-
sectionForImage('square'),
|
|
119
|
-
sectionForText(' bar'),
|
|
120
|
-
]);
|
|
121
|
-
const shaped = shapeText(horizontalFormatted, glyphs, glyphPositions, images, fontStack, 5 * oneEm, oneEm, 'center', 'center', 0, [0, 0], WritingMode.horizontal, false, 'point', layoutTextSize, layoutTextSizeThisZoom);
|
|
122
|
-
if (UPDATE) fs.writeFileSync(path.resolve(__dirname, '../../test/expected/text-shaping-images-horizontal.json'), JSON.stringify(shaped, null, 2));
|
|
123
|
-
expect(shaped).toEqual(expectedImagesHorizontal);
|
|
124
|
-
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
test('images in vertical layout', () => {
|
|
128
|
-
const expectedImagesVertical = require('../../test/expected/text-shaping-images-vertical.json');
|
|
129
|
-
const horizontalFormatted = new Formatted([
|
|
130
|
-
sectionForText('三'),
|
|
131
|
-
sectionForImage('square'),
|
|
132
|
-
sectionForImage('wide'),
|
|
133
|
-
sectionForText('\u200b'),
|
|
134
|
-
sectionForImage('tall'),
|
|
135
|
-
sectionForImage('square'),
|
|
136
|
-
sectionForText('三'),
|
|
137
|
-
]);
|
|
138
|
-
const shaped = shapeText(horizontalFormatted, glyphs, glyphPositions, images, fontStack, 5 * oneEm, oneEm, 'center', 'center', 0, [0, 0], WritingMode.vertical, true, 'point', layoutTextSize, layoutTextSizeThisZoom);
|
|
139
|
-
if (UPDATE) fs.writeFileSync(path.resolve(__dirname, '../../test/expected/text-shaping-images-vertical.json'), JSON.stringify(shaped, null, 2));
|
|
140
|
-
expect(shaped).toEqual(expectedImagesVertical);
|
|
141
|
-
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
describe('shapeIcon', () => {
|
|
147
|
-
const imagePosition = new ImagePosition({x: 0, y: 0, w: 22, h: 22}, {pixelRatio: 1, version: 1} as StyleImage);
|
|
148
|
-
const image = Object.freeze({
|
|
149
|
-
content: undefined,
|
|
150
|
-
stretchX: undefined,
|
|
151
|
-
stretchY: undefined,
|
|
152
|
-
paddedRect: Object.freeze({x: 0, y: 0, w: 22, h: 22}),
|
|
153
|
-
pixelRatio: 1,
|
|
154
|
-
version: 1
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
test('text-anchor: center', () => {
|
|
158
|
-
expect(shapeIcon(imagePosition, [ 0, 0 ], 'center')).toEqual({
|
|
159
|
-
top: -10,
|
|
160
|
-
bottom: 10,
|
|
161
|
-
left: -10,
|
|
162
|
-
right: 10,
|
|
163
|
-
image
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
expect(shapeIcon(imagePosition, [ 4, 7 ], 'center')).toEqual({
|
|
167
|
-
top: -3,
|
|
168
|
-
bottom: 17,
|
|
169
|
-
left: -6,
|
|
170
|
-
right: 14,
|
|
171
|
-
image
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
test('text-anchor: left', () => {
|
|
177
|
-
expect(shapeIcon(imagePosition, [ 0, 0 ], 'left')).toEqual({
|
|
178
|
-
top: -10,
|
|
179
|
-
bottom: 10,
|
|
180
|
-
left: 0,
|
|
181
|
-
right: 20,
|
|
182
|
-
image
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
expect(shapeIcon(imagePosition, [ 4, 7 ], 'left')).toEqual({
|
|
186
|
-
top: -3,
|
|
187
|
-
bottom: 17,
|
|
188
|
-
left: 4,
|
|
189
|
-
right: 24,
|
|
190
|
-
image
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
test('text-anchor: bottom-right', () => {
|
|
196
|
-
expect(shapeIcon(imagePosition, [ 0, 0 ], 'bottom-right')).toEqual({
|
|
197
|
-
top: -20,
|
|
198
|
-
bottom: 0,
|
|
199
|
-
left: -20,
|
|
200
|
-
right: 0,
|
|
201
|
-
image
|
|
202
|
-
});
|
|
203
|
-
|
|
204
|
-
expect(shapeIcon(imagePosition, [ 4, 7 ], 'bottom-right')).toEqual({
|
|
205
|
-
top: -13,
|
|
206
|
-
bottom: 7,
|
|
207
|
-
left: -16,
|
|
208
|
-
right: 4,
|
|
209
|
-
image
|
|
210
|
-
});
|
|
211
|
-
|
|
212
|
-
});
|
|
213
|
-
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
describe('fitIconToText', () => {
|
|
217
|
-
const glyphSize = 24;
|
|
218
|
-
const shapedIcon = Object.freeze({
|
|
219
|
-
top: -10,
|
|
220
|
-
bottom: 10,
|
|
221
|
-
left: -10,
|
|
222
|
-
right: 10,
|
|
223
|
-
collisionPadding: undefined,
|
|
224
|
-
image: Object.freeze({
|
|
225
|
-
pixelRatio: 1,
|
|
226
|
-
displaySize: [ 20, 20 ],
|
|
227
|
-
paddedRect: Object.freeze({x: 0, y: 0, w: 22, h: 22})
|
|
228
|
-
})
|
|
229
|
-
}) as PositionedIcon;
|
|
230
|
-
|
|
231
|
-
const shapedText = Object.freeze({
|
|
232
|
-
top: -10,
|
|
233
|
-
bottom: 30,
|
|
234
|
-
left: -60,
|
|
235
|
-
right: 20
|
|
236
|
-
}) as Shaping;
|
|
237
|
-
|
|
238
|
-
test('icon-text-fit: width', () => {
|
|
239
|
-
expect(
|
|
240
|
-
fitIconToText(shapedIcon, shapedText, 'width', [0, 0, 0, 0], [0, 0], 24 / glyphSize)
|
|
241
|
-
).toEqual({
|
|
242
|
-
image: shapedIcon.image,
|
|
243
|
-
collisionPadding: undefined,
|
|
244
|
-
top: 0,
|
|
245
|
-
right: 20,
|
|
246
|
-
bottom: 20,
|
|
247
|
-
left: -60
|
|
248
|
-
});
|
|
249
|
-
|
|
250
|
-
expect(
|
|
251
|
-
fitIconToText(shapedIcon, shapedText, 'width', [0, 0, 0, 0], [3, 7], 24 / glyphSize)
|
|
252
|
-
).toEqual({
|
|
253
|
-
image: shapedIcon.image,
|
|
254
|
-
collisionPadding: undefined,
|
|
255
|
-
top: 7,
|
|
256
|
-
right: 23,
|
|
257
|
-
bottom: 27,
|
|
258
|
-
left: -57
|
|
259
|
-
});
|
|
260
|
-
|
|
261
|
-
expect(
|
|
262
|
-
fitIconToText(shapedIcon, shapedText, 'width', [0, 0, 0, 0], [0, 0], 12 / glyphSize)
|
|
263
|
-
).toEqual({
|
|
264
|
-
image: shapedIcon.image,
|
|
265
|
-
collisionPadding: undefined,
|
|
266
|
-
top: -5,
|
|
267
|
-
right: 10,
|
|
268
|
-
bottom: 15,
|
|
269
|
-
left: -30
|
|
270
|
-
});
|
|
271
|
-
|
|
272
|
-
// Ignores padding for top/bottom, since the icon is only stretched to the text's width but not height
|
|
273
|
-
expect(
|
|
274
|
-
fitIconToText(shapedIcon, shapedText, 'width', [ 5, 10, 5, 10 ], [0, 0], 12 / glyphSize)
|
|
275
|
-
).toEqual({
|
|
276
|
-
image: shapedIcon.image,
|
|
277
|
-
collisionPadding: undefined,
|
|
278
|
-
top: -5,
|
|
279
|
-
right: 20,
|
|
280
|
-
bottom: 15,
|
|
281
|
-
left: -40
|
|
282
|
-
});
|
|
283
|
-
|
|
284
|
-
});
|
|
285
|
-
|
|
286
|
-
test('icon-text-fit: height', () => {
|
|
287
|
-
expect(
|
|
288
|
-
fitIconToText(shapedIcon, shapedText, 'height', [0, 0, 0, 0], [0, 0], 24 / glyphSize)
|
|
289
|
-
).toEqual({
|
|
290
|
-
image: shapedIcon.image,
|
|
291
|
-
collisionPadding: undefined,
|
|
292
|
-
top: -10,
|
|
293
|
-
right: -10,
|
|
294
|
-
bottom: 30,
|
|
295
|
-
left: -30
|
|
296
|
-
});
|
|
297
|
-
|
|
298
|
-
expect(
|
|
299
|
-
fitIconToText(shapedIcon, shapedText, 'height', [0, 0, 0, 0], [3, 7], 24 / glyphSize)
|
|
300
|
-
).toEqual({
|
|
301
|
-
image: shapedIcon.image,
|
|
302
|
-
collisionPadding: undefined,
|
|
303
|
-
top: -3,
|
|
304
|
-
right: -7,
|
|
305
|
-
bottom: 37,
|
|
306
|
-
left: -27
|
|
307
|
-
});
|
|
308
|
-
|
|
309
|
-
expect(
|
|
310
|
-
fitIconToText(shapedIcon, shapedText, 'height', [0, 0, 0, 0], [0, 0], 12 / glyphSize)
|
|
311
|
-
).toEqual({
|
|
312
|
-
image: shapedIcon.image,
|
|
313
|
-
collisionPadding: undefined,
|
|
314
|
-
top: -5,
|
|
315
|
-
right: 0,
|
|
316
|
-
bottom: 15,
|
|
317
|
-
left: -20
|
|
318
|
-
});
|
|
319
|
-
|
|
320
|
-
// Ignores padding for left/right, since the icon is only stretched to the text's height but not width
|
|
321
|
-
expect(
|
|
322
|
-
fitIconToText(shapedIcon, shapedText, 'height', [ 5, 10, 5, 10 ], [0, 0], 12 / glyphSize)
|
|
323
|
-
).toEqual({
|
|
324
|
-
image: shapedIcon.image,
|
|
325
|
-
collisionPadding: undefined,
|
|
326
|
-
top: -10,
|
|
327
|
-
right: 0,
|
|
328
|
-
bottom: 20,
|
|
329
|
-
left: -20
|
|
330
|
-
});
|
|
331
|
-
|
|
332
|
-
});
|
|
333
|
-
|
|
334
|
-
test('icon-text-fit: both', () => {
|
|
335
|
-
expect(
|
|
336
|
-
fitIconToText(shapedIcon, shapedText, 'both', [0, 0, 0, 0], [0, 0], 24 / glyphSize)
|
|
337
|
-
).toEqual({
|
|
338
|
-
image: shapedIcon.image,
|
|
339
|
-
collisionPadding: undefined,
|
|
340
|
-
top: -10,
|
|
341
|
-
right: 20,
|
|
342
|
-
bottom: 30,
|
|
343
|
-
left: -60
|
|
344
|
-
});
|
|
345
|
-
|
|
346
|
-
expect(
|
|
347
|
-
fitIconToText(shapedIcon, shapedText, 'both', [0, 0, 0, 0], [3, 7], 24 / glyphSize)
|
|
348
|
-
).toEqual({
|
|
349
|
-
image: shapedIcon.image,
|
|
350
|
-
collisionPadding: undefined,
|
|
351
|
-
top: -3,
|
|
352
|
-
right: 23,
|
|
353
|
-
bottom: 37,
|
|
354
|
-
left: -57
|
|
355
|
-
});
|
|
356
|
-
|
|
357
|
-
expect(
|
|
358
|
-
fitIconToText(shapedIcon, shapedText, 'both', [0, 0, 0, 0], [0, 0], 12 / glyphSize)
|
|
359
|
-
).toEqual({
|
|
360
|
-
image: shapedIcon.image,
|
|
361
|
-
collisionPadding: undefined,
|
|
362
|
-
top: -5,
|
|
363
|
-
right: 10,
|
|
364
|
-
bottom: 15,
|
|
365
|
-
left: -30
|
|
366
|
-
});
|
|
367
|
-
|
|
368
|
-
expect(
|
|
369
|
-
fitIconToText(shapedIcon, shapedText, 'both', [ 5, 10, 5, 10 ], [0, 0], 12 / glyphSize)
|
|
370
|
-
).toEqual({
|
|
371
|
-
image: shapedIcon.image,
|
|
372
|
-
collisionPadding: undefined,
|
|
373
|
-
top: -10,
|
|
374
|
-
right: 20,
|
|
375
|
-
bottom: 20,
|
|
376
|
-
left: -40
|
|
377
|
-
});
|
|
378
|
-
|
|
379
|
-
expect(
|
|
380
|
-
fitIconToText(shapedIcon, shapedText, 'both', [ 0, 5, 10, 15 ], [0, 0], 12 / glyphSize)
|
|
381
|
-
).toEqual({
|
|
382
|
-
image: shapedIcon.image,
|
|
383
|
-
collisionPadding: undefined,
|
|
384
|
-
top: -5,
|
|
385
|
-
right: 15,
|
|
386
|
-
bottom: 25,
|
|
387
|
-
left: -45
|
|
388
|
-
});
|
|
389
|
-
|
|
390
|
-
});
|
|
391
|
-
|
|
392
|
-
});
|
package/src/types/glsl.d.ts
DELETED