@mapwhit/tilerenderer 0.52.1 → 1.0.0
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/README.md +7 -0
- package/build/min/package.json +1 -1
- package/build/min/src/shaders/_prelude.fragment.glsl.js +2 -2
- package/build/min/src/shaders/_prelude.vertex.glsl.js +2 -2
- package/build/min/src/shaders/background.fragment.glsl.js +2 -2
- package/build/min/src/shaders/background.vertex.glsl.js +1 -1
- package/build/min/src/shaders/background_pattern.fragment.glsl.js +2 -2
- package/build/min/src/shaders/background_pattern.vertex.glsl.js +1 -1
- package/build/min/src/shaders/circle.fragment.glsl.js +2 -2
- package/build/min/src/shaders/circle.vertex.glsl.js +2 -2
- package/build/min/src/shaders/clipping_mask.fragment.glsl.js +1 -1
- package/build/min/src/shaders/clipping_mask.vertex.glsl.js +1 -1
- package/build/min/src/shaders/collision_box.fragment.glsl.js +1 -1
- package/build/min/src/shaders/collision_box.vertex.glsl.js +1 -1
- package/build/min/src/shaders/collision_circle.fragment.glsl.js +1 -1
- package/build/min/src/shaders/collision_circle.vertex.glsl.js +1 -1
- package/build/min/src/shaders/debug.fragment.glsl.js +1 -1
- package/build/min/src/shaders/debug.vertex.glsl.js +1 -1
- package/build/min/src/shaders/fill.fragment.glsl.js +2 -2
- package/build/min/src/shaders/fill.vertex.glsl.js +2 -2
- package/build/min/src/shaders/fill_extrusion.fragment.glsl.js +2 -2
- package/build/min/src/shaders/fill_extrusion.vertex.glsl.js +2 -2
- package/build/min/src/shaders/fill_extrusion_pattern.fragment.glsl.js +2 -2
- package/build/min/src/shaders/fill_extrusion_pattern.vertex.glsl.js +2 -2
- package/build/min/src/shaders/fill_outline.fragment.glsl.js +2 -2
- package/build/min/src/shaders/fill_outline.vertex.glsl.js +2 -2
- package/build/min/src/shaders/fill_outline_pattern.fragment.glsl.js +2 -2
- package/build/min/src/shaders/fill_outline_pattern.vertex.glsl.js +2 -2
- package/build/min/src/shaders/fill_pattern.fragment.glsl.js +2 -2
- package/build/min/src/shaders/fill_pattern.vertex.glsl.js +2 -2
- package/build/min/src/shaders/heatmap.fragment.glsl.js +2 -2
- package/build/min/src/shaders/heatmap.vertex.glsl.js +2 -2
- package/build/min/src/shaders/heatmap_texture.fragment.glsl.js +2 -2
- package/build/min/src/shaders/heatmap_texture.vertex.glsl.js +1 -1
- package/build/min/src/shaders/hillshade.fragment.glsl.js +2 -2
- package/build/min/src/shaders/hillshade.vertex.glsl.js +1 -1
- package/build/min/src/shaders/hillshade_prepare.fragment.glsl.js +2 -2
- package/build/min/src/shaders/hillshade_prepare.vertex.glsl.js +1 -1
- package/build/min/src/shaders/line.fragment.glsl.js +2 -2
- package/build/min/src/shaders/line.vertex.glsl.js +2 -2
- package/build/min/src/shaders/line_gradient.fragment.glsl.js +2 -2
- package/build/min/src/shaders/line_gradient.vertex.glsl.js +2 -2
- package/build/min/src/shaders/line_pattern.fragment.glsl.js +2 -2
- package/build/min/src/shaders/line_pattern.vertex.glsl.js +2 -2
- package/build/min/src/shaders/line_sdf.fragment.glsl.js +2 -2
- package/build/min/src/shaders/line_sdf.vertex.glsl.js +2 -2
- package/build/min/src/shaders/raster.fragment.glsl.js +2 -2
- package/build/min/src/shaders/raster.vertex.glsl.js +1 -1
- package/build/min/src/shaders/symbol_icon.fragment.glsl.js +2 -2
- package/build/min/src/shaders/symbol_icon.vertex.glsl.js +2 -2
- package/build/min/src/shaders/symbol_sdf.fragment.glsl.js +2 -2
- package/build/min/src/shaders/symbol_sdf.vertex.glsl.js +2 -2
- package/package.json +3 -3
- package/src/data/array_types.js +1 -36
- package/src/data/bucket/circle_bucket.js +0 -3
- package/src/data/bucket/fill_bucket.js +0 -3
- package/src/data/bucket/fill_extrusion_bucket.js +0 -3
- package/src/data/bucket/heatmap_bucket.js +0 -4
- package/src/data/bucket/line_bucket.js +1 -4
- package/src/data/bucket/pattern_bucket_features.js +2 -2
- package/src/data/bucket/symbol_bucket.js +87 -126
- package/src/data/bucket.js +26 -21
- package/src/data/dem_data.js +0 -3
- package/src/data/feature_index.js +3 -8
- package/src/data/program_configuration.js +3 -12
- package/src/data/segment.js +0 -4
- package/src/render/draw_background.js +3 -3
- package/src/render/draw_circle.js +4 -4
- package/src/render/draw_fill.js +8 -8
- package/src/render/draw_fill_extrusion.js +8 -8
- package/src/render/draw_heatmap.js +4 -4
- package/src/render/draw_line.js +6 -6
- package/src/render/draw_raster.js +6 -6
- package/src/render/draw_symbol.js +16 -16
- package/src/render/glyph_atlas.js +0 -3
- package/src/render/glyph_manager.js +1 -2
- package/src/render/image_atlas.js +0 -4
- package/src/render/image_manager.js +33 -19
- package/src/render/painter.js +13 -14
- package/src/render/program/circle_program.js +4 -4
- package/src/render/program/fill_extrusion_program.js +1 -1
- package/src/render/program/heatmap_program.js +1 -1
- package/src/render/program/hillshade_program.js +6 -6
- package/src/render/program/line_program.js +3 -3
- package/src/render/program/raster_program.js +6 -6
- package/src/source/geojson_source.js +15 -24
- package/src/source/geojson_worker_source.js +40 -68
- package/src/source/geojson_wrapper.js +9 -1
- package/src/source/image_source.js +6 -16
- package/src/source/query_features.js +4 -5
- package/src/source/raster_dem_tile_source.js +45 -64
- package/src/source/raster_tile_source.js +1 -6
- package/src/source/resources/glyphs.js +2 -2
- package/src/source/resources/index.js +3 -9
- package/src/source/rtl_text_plugin.js +58 -31
- package/src/source/source.js +11 -13
- package/src/source/source_cache.js +135 -151
- package/src/source/source_state.js +101 -12
- package/src/source/tile.js +32 -46
- package/src/source/tile_bounds.js +26 -26
- package/src/source/tile_id.js +2 -5
- package/src/source/vector_tile_source.js +14 -14
- package/src/source/vector_tile_worker_source.js +19 -23
- package/src/source/worker_tile.js +120 -117
- package/src/style/create_style_layer.js +1 -1
- package/src/style/pauseable_placement.js +4 -5
- package/src/style/properties.js +1 -8
- package/src/style/query_utils.js +3 -3
- package/src/style/style.js +263 -195
- package/src/style/style_layer/circle_style_layer.js +13 -11
- package/src/style/style_layer/fill_extrusion_style_layer.js +42 -27
- package/src/style/style_layer/fill_style_layer.js +5 -5
- package/src/style/style_layer/heatmap_style_layer.js +1 -1
- package/src/style/style_layer/hillshade_style_layer.js +1 -1
- package/src/style/style_layer/line_style_layer.js +23 -19
- package/src/style/style_layer/symbol_style_layer.js +13 -13
- package/src/style/style_layer.js +48 -30
- package/src/style/style_layer_index.js +16 -41
- package/src/symbol/anchor.js +0 -4
- package/src/symbol/cross_tile_symbol_index.js +2 -5
- package/src/symbol/opacity_state.js +0 -4
- package/src/symbol/placement.js +3 -3
- package/src/symbol/quads.js +4 -4
- package/src/symbol/symbol_layout.js +7 -7
- package/src/symbol/transform_text.js +1 -1
- package/src/ui/map.js +49 -11
- package/src/util/group_layers.js +41 -0
- package/src/util/image.js +0 -5
- package/src/util/key.js +21 -0
- package/src/util/object.js +8 -53
- package/src/worker.js +1 -4
- package/src/source/resources/images.js +0 -68
- package/src/source/worker.js +0 -110
- package/src/source/worker_source.js +0 -14
- package/src/style-spec/deref.js +0 -51
- package/src/style-spec/group_by_layout.js +0 -46
- package/src/util/actor.js +0 -108
- package/src/util/dispatcher.js +0 -65
- package/src/util/global_worker_pool.js +0 -15
- package/src/util/transfer_registry.js +0 -168
- package/src/util/web_worker_transfer.js +0 -43
- package/src/util/worker_pool.js +0 -41
|
@@ -1,35 +1,23 @@
|
|
|
1
1
|
const browser = require('../util/browser');
|
|
2
2
|
const loadImage = require('../util/loader/image');
|
|
3
|
-
const {
|
|
3
|
+
const { calculateKey } = require('./tile_id');
|
|
4
4
|
const RasterTileSource = require('./raster_tile_source');
|
|
5
|
-
|
|
6
|
-
require('../data/dem_data');
|
|
5
|
+
const DEMData = require('../data/dem_data');
|
|
7
6
|
|
|
8
7
|
class RasterDEMTileSource extends RasterTileSource {
|
|
9
|
-
constructor(id, options,
|
|
10
|
-
super(id, options,
|
|
8
|
+
constructor(id, options, eventedParent) {
|
|
9
|
+
super(id, options, eventedParent);
|
|
11
10
|
this.type = 'raster-dem';
|
|
12
11
|
this.maxzoom = 22;
|
|
13
12
|
this._options = Object.assign({}, options);
|
|
14
13
|
this.encoding = options.encoding || 'mapbox';
|
|
15
14
|
}
|
|
16
15
|
|
|
17
|
-
serialize() {
|
|
18
|
-
return {
|
|
19
|
-
type: 'raster-dem',
|
|
20
|
-
url: this.url,
|
|
21
|
-
tileSize: this.tileSize,
|
|
22
|
-
tiles: this.tiles,
|
|
23
|
-
bounds: this.bounds,
|
|
24
|
-
encoding: this.encoding
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
|
|
28
16
|
async loadTile(tile) {
|
|
29
17
|
try {
|
|
30
18
|
tile.abortController = new window.AbortController();
|
|
31
19
|
const data = await this.tiles(tile.tileID.canonical, tile.abortController).catch(() => {});
|
|
32
|
-
tile.neighboringTiles =
|
|
20
|
+
tile.neighboringTiles = getNeighboringTiles(tile.tileID);
|
|
33
21
|
if (!data) {
|
|
34
22
|
const err = new Error('Tile could not be loaded');
|
|
35
23
|
err.status = 404; // will try to use the parent/child tile
|
|
@@ -48,7 +36,7 @@ class RasterDEMTileSource extends RasterTileSource {
|
|
|
48
36
|
rawImageData,
|
|
49
37
|
encoding: this.encoding
|
|
50
38
|
};
|
|
51
|
-
const dem = await
|
|
39
|
+
const dem = await loadDEMTile(params);
|
|
52
40
|
if (dem) {
|
|
53
41
|
tile.dem = dem;
|
|
54
42
|
tile.needsHillshadePrepare = true;
|
|
@@ -65,52 +53,6 @@ class RasterDEMTileSource extends RasterTileSource {
|
|
|
65
53
|
}
|
|
66
54
|
}
|
|
67
55
|
|
|
68
|
-
_getNeighboringTiles(tileID) {
|
|
69
|
-
const canonical = tileID.canonical;
|
|
70
|
-
const dim = 2 ** canonical.z;
|
|
71
|
-
|
|
72
|
-
const px = (canonical.x - 1 + dim) % dim;
|
|
73
|
-
const pxw = canonical.x === 0 ? tileID.wrap - 1 : tileID.wrap;
|
|
74
|
-
const nx = (canonical.x + 1 + dim) % dim;
|
|
75
|
-
const nxw = canonical.x + 1 === dim ? tileID.wrap + 1 : tileID.wrap;
|
|
76
|
-
|
|
77
|
-
const neighboringTiles = {};
|
|
78
|
-
// add adjacent tiles
|
|
79
|
-
neighboringTiles[new OverscaledTileID(tileID.overscaledZ, pxw, canonical.z, px, canonical.y).key] = {
|
|
80
|
-
backfilled: false
|
|
81
|
-
};
|
|
82
|
-
neighboringTiles[new OverscaledTileID(tileID.overscaledZ, nxw, canonical.z, nx, canonical.y).key] = {
|
|
83
|
-
backfilled: false
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
// Add upper neighboringTiles
|
|
87
|
-
if (canonical.y > 0) {
|
|
88
|
-
neighboringTiles[new OverscaledTileID(tileID.overscaledZ, pxw, canonical.z, px, canonical.y - 1).key] = {
|
|
89
|
-
backfilled: false
|
|
90
|
-
};
|
|
91
|
-
neighboringTiles[
|
|
92
|
-
new OverscaledTileID(tileID.overscaledZ, tileID.wrap, canonical.z, canonical.x, canonical.y - 1).key
|
|
93
|
-
] = { backfilled: false };
|
|
94
|
-
neighboringTiles[new OverscaledTileID(tileID.overscaledZ, nxw, canonical.z, nx, canonical.y - 1).key] = {
|
|
95
|
-
backfilled: false
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
// Add lower neighboringTiles
|
|
99
|
-
if (canonical.y + 1 < dim) {
|
|
100
|
-
neighboringTiles[new OverscaledTileID(tileID.overscaledZ, pxw, canonical.z, px, canonical.y + 1).key] = {
|
|
101
|
-
backfilled: false
|
|
102
|
-
};
|
|
103
|
-
neighboringTiles[
|
|
104
|
-
new OverscaledTileID(tileID.overscaledZ, tileID.wrap, canonical.z, canonical.x, canonical.y + 1).key
|
|
105
|
-
] = { backfilled: false };
|
|
106
|
-
neighboringTiles[new OverscaledTileID(tileID.overscaledZ, nxw, canonical.z, nx, canonical.y + 1).key] = {
|
|
107
|
-
backfilled: false
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
return neighboringTiles;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
56
|
unloadTile(tile) {
|
|
115
57
|
if (tile.demTexture) this.map.painter.saveTileTexture(tile.demTexture);
|
|
116
58
|
if (tile.fbo) {
|
|
@@ -124,4 +66,43 @@ class RasterDEMTileSource extends RasterTileSource {
|
|
|
124
66
|
}
|
|
125
67
|
}
|
|
126
68
|
|
|
69
|
+
// biome-ignore lint/suspicious/useAwait: thread
|
|
70
|
+
async function loadDEMTile({ uid, rawImageData, encoding }) {
|
|
71
|
+
return new DEMData(uid, rawImageData, encoding);
|
|
72
|
+
}
|
|
73
|
+
|
|
127
74
|
module.exports = RasterDEMTileSource;
|
|
75
|
+
|
|
76
|
+
function getNeighboringTiles(tileID) {
|
|
77
|
+
const {
|
|
78
|
+
canonical: { x, y, z },
|
|
79
|
+
wrap,
|
|
80
|
+
overscaledZ
|
|
81
|
+
} = tileID;
|
|
82
|
+
const dim = 2 ** z;
|
|
83
|
+
const px = (x - 1 + dim) % dim;
|
|
84
|
+
const pxw = x === 0 ? wrap - 1 : wrap;
|
|
85
|
+
const nx = (x + 1 + dim) % dim;
|
|
86
|
+
const nxw = x + 1 === dim ? wrap + 1 : wrap;
|
|
87
|
+
|
|
88
|
+
const neighboringTiles = {
|
|
89
|
+
// add adjacent tiles
|
|
90
|
+
[calculateKey(pxw, overscaledZ, px, y)]: { backfilled: false },
|
|
91
|
+
[calculateKey(nxw, overscaledZ, nx, y)]: { backfilled: false }
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
// Add upper neighboringTiles
|
|
95
|
+
if (y > 0) {
|
|
96
|
+
neighboringTiles[calculateKey(pxw, overscaledZ, px, y - 1)] = { backfilled: false };
|
|
97
|
+
neighboringTiles[calculateKey(wrap, overscaledZ, x, y - 1)] = { backfilled: false };
|
|
98
|
+
neighboringTiles[calculateKey(nxw, overscaledZ, nx, y - 1)] = { backfilled: false };
|
|
99
|
+
}
|
|
100
|
+
// Add lower neighboringTiles
|
|
101
|
+
if (y + 1 < dim) {
|
|
102
|
+
neighboringTiles[calculateKey(pxw, overscaledZ, px, y + 1)] = { backfilled: false };
|
|
103
|
+
neighboringTiles[calculateKey(wrap, overscaledZ, x, y + 1)] = { backfilled: false };
|
|
104
|
+
neighboringTiles[calculateKey(nxw, overscaledZ, nx, y + 1)] = { backfilled: false };
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return neighboringTiles;
|
|
108
|
+
}
|
|
@@ -6,10 +6,9 @@ const TileBounds = require('./tile_bounds');
|
|
|
6
6
|
const Texture = require('../render/texture');
|
|
7
7
|
|
|
8
8
|
class RasterTileSource extends Evented {
|
|
9
|
-
constructor(id, options,
|
|
9
|
+
constructor(id, options, eventedParent) {
|
|
10
10
|
super();
|
|
11
11
|
this.id = id;
|
|
12
|
-
this.dispatcher = dispatcher;
|
|
13
12
|
this.setEventedParent(eventedParent);
|
|
14
13
|
|
|
15
14
|
this.type = 'raster';
|
|
@@ -46,10 +45,6 @@ class RasterTileSource extends Evented {
|
|
|
46
45
|
this.load();
|
|
47
46
|
}
|
|
48
47
|
|
|
49
|
-
serialize() {
|
|
50
|
-
return Object.assign({}, this._options);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
48
|
hasTile(tileID) {
|
|
54
49
|
return !this.tileBounds || this.tileBounds.contains(tileID.canonical);
|
|
55
50
|
}
|
|
@@ -4,7 +4,7 @@ module.exports = glyphCache;
|
|
|
4
4
|
|
|
5
5
|
const MAX_GLYPH_ID = 65535;
|
|
6
6
|
|
|
7
|
-
function glyphCache({
|
|
7
|
+
function glyphCache({ loadGlyphRange: loadGlyphRangeFromStyle, parseGlyphs = parseGlyphPBF }) {
|
|
8
8
|
const entries = {};
|
|
9
9
|
|
|
10
10
|
return {
|
|
@@ -56,7 +56,7 @@ function glyphCache({ actor, mapId, parseGlyphs = parseGlyphPBF }) {
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
async function loadGlyphRange(entry, stack, range) {
|
|
59
|
-
const promise = (entry.requests[range] ??=
|
|
59
|
+
const promise = (entry.requests[range] ??= loadGlyphRangeFromStyle({ stack, range }));
|
|
60
60
|
const data = await promise;
|
|
61
61
|
delete entry.requests[range];
|
|
62
62
|
entry.ranges[range] = true;
|
|
@@ -1,22 +1,16 @@
|
|
|
1
1
|
const makeGlyphs = require('./glyphs');
|
|
2
|
-
const makeImages = require('./images');
|
|
3
2
|
|
|
4
3
|
module.exports = { resources };
|
|
5
4
|
|
|
6
|
-
function resources(
|
|
7
|
-
const glyphs = makeGlyphs(
|
|
8
|
-
const images = makeImages({ actor, mapId });
|
|
5
|
+
function resources(opts) {
|
|
6
|
+
const glyphs = makeGlyphs(opts);
|
|
9
7
|
|
|
10
8
|
return {
|
|
11
9
|
getGlyphs,
|
|
12
|
-
getImages
|
|
10
|
+
getImages: opts.getImages
|
|
13
11
|
};
|
|
14
12
|
|
|
15
13
|
function getGlyphs(params) {
|
|
16
14
|
return glyphs.getGlyphs(params);
|
|
17
15
|
}
|
|
18
|
-
|
|
19
|
-
function getImages(params) {
|
|
20
|
-
return images.getImages(params);
|
|
21
|
-
}
|
|
22
16
|
}
|
|
@@ -1,26 +1,34 @@
|
|
|
1
|
-
const
|
|
1
|
+
const dynload = require('dynload');
|
|
2
2
|
const browser = require('../util/browser');
|
|
3
3
|
|
|
4
4
|
let pluginRequested = false;
|
|
5
|
-
let pluginURL
|
|
6
|
-
let
|
|
7
|
-
|
|
8
|
-
const evented = new Evented();
|
|
5
|
+
let pluginURL;
|
|
6
|
+
let loading = false;
|
|
9
7
|
|
|
10
8
|
let _completionCallback;
|
|
9
|
+
const _loadedCallbacks = [];
|
|
10
|
+
|
|
11
|
+
const rtlPlugin = {
|
|
12
|
+
clearRTLTextPlugin, // exported for testing
|
|
13
|
+
loadScript, // exported for testing
|
|
14
|
+
registerForPluginAvailability,
|
|
15
|
+
setRTLTextPlugin
|
|
16
|
+
};
|
|
11
17
|
|
|
12
18
|
function registerForPluginAvailability(callback) {
|
|
13
|
-
if (
|
|
14
|
-
callback(
|
|
15
|
-
|
|
16
|
-
evented.once('pluginAvailable', callback);
|
|
19
|
+
if (plugin.isLoaded()) {
|
|
20
|
+
callback();
|
|
21
|
+
return;
|
|
17
22
|
}
|
|
18
|
-
|
|
23
|
+
_loadedCallbacks.push(callback);
|
|
24
|
+
loadRTLTextPlugin();
|
|
25
|
+
return () => _loadedCallbacks.splice(_loadedCallbacks.indexOf(callback), 1);
|
|
19
26
|
}
|
|
20
27
|
|
|
21
28
|
function clearRTLTextPlugin() {
|
|
29
|
+
_loadedCallbacks.length = 0;
|
|
22
30
|
pluginRequested = false;
|
|
23
|
-
pluginURL =
|
|
31
|
+
pluginURL = undefined;
|
|
24
32
|
}
|
|
25
33
|
|
|
26
34
|
function setRTLTextPlugin(url, callback) {
|
|
@@ -31,35 +39,54 @@ function setRTLTextPlugin(url, callback) {
|
|
|
31
39
|
pluginURL = browser.resolveURL(url);
|
|
32
40
|
_completionCallback = error => {
|
|
33
41
|
if (error) {
|
|
42
|
+
const msg = `RTL Text Plugin failed to load scripts from ${pluginURL}`;
|
|
34
43
|
// Clear loaded state to allow retries
|
|
35
44
|
clearRTLTextPlugin();
|
|
36
45
|
if (callback) {
|
|
37
|
-
callback(
|
|
46
|
+
callback(new Error(msg));
|
|
38
47
|
}
|
|
39
|
-
} else {
|
|
40
|
-
// Called once for each worker
|
|
41
|
-
foregroundLoadComplete = true;
|
|
42
48
|
}
|
|
49
|
+
loading = false;
|
|
50
|
+
_completionCallback = undefined;
|
|
43
51
|
};
|
|
44
|
-
|
|
52
|
+
loadRTLTextPlugin();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function loadRTLTextPlugin() {
|
|
56
|
+
if (pluginURL && !plugin.isLoaded() && _loadedCallbacks.length > 0 && !loading) {
|
|
57
|
+
// needs to be called as exported method for mock testing
|
|
58
|
+
loading = rtlPlugin.loadScript(pluginURL).catch(_completionCallback);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function registerRTLTextPlugin(loadedPlugin) {
|
|
63
|
+
if (plugin.isLoaded()) {
|
|
64
|
+
throw new Error('RTL text plugin already registered.');
|
|
65
|
+
}
|
|
66
|
+
plugin['applyArabicShaping'] = loadedPlugin.applyArabicShaping;
|
|
67
|
+
plugin['processBidirectionalText'] = loadedPlugin.processBidirectionalText;
|
|
68
|
+
plugin['processStyledBidirectionalText'] = loadedPlugin.processStyledBidirectionalText;
|
|
69
|
+
|
|
70
|
+
_completionCallback();
|
|
71
|
+
_loadedCallbacks.forEach(callback => callback());
|
|
72
|
+
_loadedCallbacks.length = 0;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
globalThis.registerRTLTextPlugin ??= registerRTLTextPlugin;
|
|
76
|
+
|
|
77
|
+
async function loadScript(url) {
|
|
78
|
+
const { promise, resolve, reject } = Promise.withResolvers();
|
|
79
|
+
const s = dynload(url);
|
|
80
|
+
s.onload = () => resolve();
|
|
81
|
+
s.onerror = () => reject(true);
|
|
82
|
+
return promise;
|
|
45
83
|
}
|
|
46
84
|
|
|
47
|
-
const plugin = {
|
|
85
|
+
const plugin = (rtlPlugin.plugin = {
|
|
48
86
|
applyArabicShaping: null,
|
|
49
87
|
processBidirectionalText: null,
|
|
50
88
|
processStyledBidirectionalText: null,
|
|
51
|
-
isLoaded:
|
|
52
|
-
|
|
53
|
-
foregroundLoadComplete || // Foreground: loaded if the completion callback returned successfully
|
|
54
|
-
plugin.applyArabicShaping != null
|
|
55
|
-
); // Background: loaded if the plugin functions have been compiled
|
|
56
|
-
}
|
|
57
|
-
};
|
|
89
|
+
isLoaded: () => plugin.applyArabicShaping != null
|
|
90
|
+
});
|
|
58
91
|
|
|
59
|
-
module.exports =
|
|
60
|
-
registerForPluginAvailability,
|
|
61
|
-
clearRTLTextPlugin,
|
|
62
|
-
setRTLTextPlugin,
|
|
63
|
-
plugin,
|
|
64
|
-
evented
|
|
65
|
-
};
|
|
92
|
+
module.exports = rtlPlugin;
|
package/src/source/source.js
CHANGED
|
@@ -10,7 +10,6 @@ const { bindAll } = require('../util/object');
|
|
|
10
10
|
* @param {Object} options Source options, specific to the source type (except for `options.type`, which is always
|
|
11
11
|
* required).
|
|
12
12
|
* @param {string} options.type The source type, matching the value of `name` used in {@link Style#addSourceType}.
|
|
13
|
-
* @param {Dispatcher} dispatcher A {@link Dispatcher} instance, which can be used to send messages to the workers.
|
|
14
13
|
*
|
|
15
14
|
* @fires data with `{dataType: 'source', sourceDataType: 'metadata'}` to indicate that any necessary metadata
|
|
16
15
|
* has been loaded so that it's okay to call `loadTile`; and with `{dataType: 'source', sourceDataType: 'content'}`
|
|
@@ -25,11 +24,11 @@ const { bindAll } = require('../util/object');
|
|
|
25
24
|
* if they are floor-ed to the nearest integer.
|
|
26
25
|
*/
|
|
27
26
|
|
|
28
|
-
const vector = require('
|
|
29
|
-
const raster = require('
|
|
30
|
-
const rasterDem = require('
|
|
31
|
-
const geojson = require('
|
|
32
|
-
const image = require('
|
|
27
|
+
const vector = require('./vector_tile_source');
|
|
28
|
+
const raster = require('./raster_tile_source');
|
|
29
|
+
const rasterDem = require('./raster_dem_tile_source');
|
|
30
|
+
const geojson = require('./geojson_source');
|
|
31
|
+
const image = require('./image_source');
|
|
33
32
|
|
|
34
33
|
const sourceTypes = {
|
|
35
34
|
vector,
|
|
@@ -46,15 +45,14 @@ const sourceTypes = {
|
|
|
46
45
|
* @param {Object} source A source definition object compliant with
|
|
47
46
|
* [`mapbox-gl-style-spec`](https://www.mapbox.com/mapbox-gl-style-spec/#sources) or, for a third-party source type,
|
|
48
47
|
* with that type's requirements.
|
|
49
|
-
* @param {Dispatcher} dispatcher
|
|
50
48
|
* @returns {Source}
|
|
51
49
|
*/
|
|
52
|
-
function create(id, specification,
|
|
53
|
-
const source = new sourceTypes[specification.type](id, specification,
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
50
|
+
function create(id, specification, eventedParent, { resources, layerIndex, showTileBoundaries }) {
|
|
51
|
+
const source = new sourceTypes[specification.type](id, specification, eventedParent, {
|
|
52
|
+
resources,
|
|
53
|
+
layerIndex,
|
|
54
|
+
showTileBoundaries
|
|
55
|
+
});
|
|
58
56
|
|
|
59
57
|
bindAll(['load', 'abort', 'unload', 'serialize', 'prepare'], source);
|
|
60
58
|
return source;
|