@mapwhit/tilerenderer 0.52.1 → 1.1.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 +2 -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 +5 -4
- package/src/data/array_types.js +55 -117
- package/src/data/bucket/circle_attributes.js +2 -4
- package/src/data/bucket/circle_bucket.js +19 -16
- package/src/data/bucket/fill_attributes.js +2 -4
- package/src/data/bucket/fill_bucket.js +38 -27
- package/src/data/bucket/fill_extrusion_attributes.js +2 -4
- package/src/data/bucket/fill_extrusion_bucket.js +56 -37
- package/src/data/bucket/heatmap_bucket.js +2 -11
- package/src/data/bucket/line_attributes.js +2 -4
- package/src/data/bucket/line_bucket.js +208 -163
- package/src/data/bucket/pattern_attributes.js +2 -4
- package/src/data/bucket/pattern_bucket_features.js +7 -9
- package/src/data/bucket/symbol_attributes.js +12 -26
- package/src/data/bucket/symbol_bucket.js +174 -323
- package/src/data/bucket/symbol_buffers.js +62 -0
- package/src/data/bucket/symbol_collision_buffers.js +33 -0
- package/src/data/bucket.js +26 -25
- package/src/data/dem_data.js +11 -10
- package/src/data/extent.js +1 -1
- package/src/data/feature_index.js +38 -28
- package/src/data/index_array_type.js +1 -6
- package/src/data/load_geometry.js +6 -9
- package/src/data/pos_attributes.js +2 -3
- package/src/data/program_configuration.js +47 -38
- package/src/data/raster_bounds_attributes.js +2 -2
- package/src/data/segment.js +4 -7
- package/src/geo/coordinate.js +1 -1
- package/src/geo/lng_lat.js +3 -3
- package/src/geo/lng_lat_bounds.js +8 -4
- package/src/geo/transform.js +69 -30
- package/src/gl/color_mode.js +2 -2
- package/src/gl/context.js +28 -29
- package/src/gl/cull_face_mode.js +1 -1
- package/src/gl/depth_mode.js +1 -1
- package/src/gl/framebuffer.js +8 -4
- package/src/gl/index_buffer.js +2 -2
- package/src/gl/stencil_mode.js +1 -1
- package/src/gl/value.js +33 -68
- package/src/gl/vertex_buffer.js +2 -2
- package/src/index.js +49 -25
- package/src/render/draw_background.js +17 -12
- package/src/render/draw_circle.js +15 -12
- package/src/render/draw_collision_debug.js +11 -8
- package/src/render/draw_debug.js +16 -14
- package/src/render/draw_fill.js +27 -20
- package/src/render/draw_fill_extrusion.js +20 -17
- package/src/render/draw_heatmap.js +21 -16
- package/src/render/draw_hillshade.js +12 -9
- package/src/render/draw_line.js +36 -22
- package/src/render/draw_raster.js +22 -18
- package/src/render/draw_symbol.js +38 -33
- package/src/render/glyph_atlas.js +9 -8
- package/src/render/glyph_manager.js +2 -3
- package/src/render/image_atlas.js +4 -11
- package/src/render/image_manager.js +39 -28
- package/src/render/line_atlas.js +2 -2
- package/src/render/painter.js +78 -61
- package/src/render/program/background_program.js +6 -13
- package/src/render/program/circle_program.js +8 -10
- package/src/render/program/clipping_mask_program.js +3 -5
- package/src/render/program/collision_program.js +4 -6
- package/src/render/program/debug_program.js +3 -5
- package/src/render/program/fill_extrusion_program.js +9 -15
- package/src/render/program/fill_program.js +10 -21
- package/src/render/program/heatmap_program.js +9 -15
- package/src/render/program/hillshade_program.js +16 -22
- package/src/render/program/line_program.js +14 -25
- package/src/render/program/pattern.js +5 -7
- package/src/render/program/program_uniforms.js +13 -20
- package/src/render/program/raster_program.js +9 -11
- package/src/render/program/symbol_program.js +5 -7
- package/src/render/program.js +5 -6
- package/src/render/texture.js +1 -1
- package/src/render/tile_mask.js +6 -4
- package/src/render/uniform_binding.js +9 -20
- package/src/render/vertex_array_object.js +5 -3
- package/src/shaders/encode_attribute.js +2 -6
- package/src/shaders/index.js +103 -51
- package/src/source/geojson_source.js +25 -30
- package/src/source/geojson_worker_source.js +46 -74
- package/src/source/geojson_wrapper.js +13 -5
- package/src/source/image_source.js +17 -28
- package/src/source/load_tilejson.js +3 -3
- package/src/source/pixels_to_tile_units.js +3 -3
- package/src/source/query_features.js +17 -15
- package/src/source/raster_dem_tile_source.js +54 -71
- package/src/source/raster_tile_source.js +14 -15
- package/src/source/resources/glyphs.js +4 -5
- package/src/source/resources/index.js +4 -12
- package/src/source/rtl_text_plugin.js +62 -35
- package/src/source/source.js +14 -22
- package/src/source/source_cache.js +221 -179
- package/src/source/source_state.js +125 -13
- package/src/source/tile.js +67 -66
- package/src/source/tile_bounds.js +36 -29
- package/src/source/tile_cache.js +2 -2
- package/src/source/tile_id.js +30 -26
- package/src/source/vector_tile_source.js +23 -21
- package/src/source/vector_tile_worker_source.js +22 -26
- package/src/source/worker_tile.js +139 -134
- package/src/style/create_style_layer.js +11 -11
- package/src/style/evaluation_parameters.js +4 -6
- package/src/style/light.js +5 -5
- package/src/style/load_sprite.js +6 -6
- package/src/style/parse_glyph_pbf.js +21 -17
- package/src/style/pauseable_placement.js +7 -9
- package/src/style/properties.js +21 -51
- package/src/style/query_utils.js +7 -13
- package/src/style/style.js +314 -221
- package/src/style/style_layer/background_style_layer.js +3 -4
- package/src/style/style_layer/background_style_layer_properties.js +2 -2
- package/src/style/style_layer/circle_style_layer.js +25 -20
- package/src/style/style_layer/circle_style_layer_properties.js +2 -2
- package/src/style/style_layer/fill_extrusion_style_layer.js +55 -37
- package/src/style/style_layer/fill_extrusion_style_layer_properties.js +2 -2
- package/src/style/style_layer/fill_style_layer.js +11 -12
- package/src/style/style_layer/fill_style_layer_properties.js +2 -2
- package/src/style/style_layer/heatmap_style_layer.js +6 -7
- package/src/style/style_layer/heatmap_style_layer_properties.js +2 -2
- package/src/style/style_layer/hillshade_style_layer.js +4 -5
- package/src/style/style_layer/hillshade_style_layer_properties.js +2 -2
- package/src/style/style_layer/line_style_layer.js +33 -30
- package/src/style/style_layer/line_style_layer_properties.js +5 -5
- package/src/style/style_layer/raster_style_layer.js +3 -4
- package/src/style/style_layer/raster_style_layer_properties.js +2 -2
- package/src/style/style_layer/symbol_style_layer.js +20 -21
- package/src/style/style_layer/symbol_style_layer_properties.js +2 -2
- package/src/style/style_layer.js +66 -47
- package/src/style/style_layer_index.js +17 -42
- package/src/style/zoom_history.js +1 -1
- package/src/style-spec/error/parsing_error.js +1 -1
- package/src/style-spec/error/validation_error.js +5 -3
- package/src/style-spec/feature_filter/convert.js +17 -9
- package/src/style-spec/feature_filter/index.js +13 -9
- package/src/style-spec/util/eval_support.js +2 -2
- package/src/style-spec/util/ref_properties.js +1 -1
- package/src/symbol/anchor.js +2 -6
- package/src/symbol/check_max_angle.js +13 -5
- package/src/symbol/clip_line.js +2 -3
- package/src/symbol/collision_feature.js +8 -4
- package/src/symbol/collision_index.js +5 -7
- package/src/symbol/cross_tile_symbol_index.js +7 -10
- package/src/symbol/get_anchors.js +15 -8
- package/src/symbol/grid_index.js +5 -3
- package/src/symbol/mergelines.js +2 -2
- package/src/symbol/opacity_state.js +1 -5
- package/src/symbol/placement.js +28 -23
- package/src/symbol/projection.js +29 -28
- package/src/symbol/quads.js +14 -16
- package/src/symbol/shaping.js +27 -19
- package/src/symbol/symbol_layout.js +24 -28
- package/src/symbol/symbol_size.js +13 -12
- package/src/symbol/transform_text.js +4 -4
- package/src/ui/camera.js +34 -18
- package/src/ui/map.js +102 -44
- package/src/util/async.js +11 -5
- package/src/util/browser.js +1 -1
- package/src/util/callback.js +3 -9
- package/src/util/classify_rings.js +13 -8
- package/src/util/color_ramp.js +3 -3
- package/src/util/config.js +4 -4
- package/src/util/dictionary_coder.js +2 -3
- package/src/util/dom.js +7 -3
- package/src/util/find_pole_of_inaccessibility.js +29 -14
- package/src/util/group_layers.js +41 -0
- package/src/util/image.js +3 -13
- package/src/util/interpolate.js +1 -1
- package/src/util/intersection_tests.js +80 -42
- package/src/util/is_char_in_unicode_block.js +1 -1
- package/src/util/key.js +25 -0
- package/src/util/loader/image.js +1 -1
- package/src/util/object.js +33 -76
- package/src/util/script_detection.js +212 -91
- package/src/util/struct_array.js +8 -40
- package/src/util/task_queue.js +11 -7
- package/src/util/throttle.js +2 -2
- package/src/util/tile_cover.js +8 -5
- package/src/util/token.js +1 -1
- package/src/util/unique_id.js +2 -2
- package/src/util/util.js +21 -29
- package/src/util/vectortile_to_geojson.js +4 -2
- package/src/util/verticalize_punctuation.js +3 -7
- package/src/util/warn.js +4 -4
- package/src/util/web_worker.js +3 -3
- 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,168 +0,0 @@
|
|
|
1
|
-
const assert = require('assert');
|
|
2
|
-
|
|
3
|
-
module.exports = {
|
|
4
|
-
register,
|
|
5
|
-
serialize,
|
|
6
|
-
deserialize
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
const registry = new Map();
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Register the given class as serializable.
|
|
13
|
-
*
|
|
14
|
-
* @param options
|
|
15
|
-
* @param options.omit List of properties to omit from serialization (e.g., cached/computed properties)
|
|
16
|
-
* @param options.shallow List of properties that should be serialized by a simple shallow copy, rather than by a recursive call to serialize().
|
|
17
|
-
*
|
|
18
|
-
* @private
|
|
19
|
-
*/
|
|
20
|
-
function register(name, klass, { omit, shallow } = {}) {
|
|
21
|
-
assert(!registry.has(name), `${name} is already registered.`);
|
|
22
|
-
Object.defineProperty(klass, '_classRegistryKey', {
|
|
23
|
-
value: name,
|
|
24
|
-
writeable: false
|
|
25
|
-
});
|
|
26
|
-
registry.set(name, { klass, omit, shallow });
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
register('Object', Object);
|
|
30
|
-
register('Set', Set);
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Serialize the given object for transfer to or from a web worker.
|
|
34
|
-
*
|
|
35
|
-
* For non-builtin types, recursively serialize each property (possibly
|
|
36
|
-
* omitting certain properties - see register()), and package the result along
|
|
37
|
-
* with the constructor's `name` so that the appropriate constructor can be
|
|
38
|
-
* looked up in `deserialize()`.
|
|
39
|
-
*
|
|
40
|
-
* If a `transferables` array is provided, add any transferable objects (i.e.,
|
|
41
|
-
* any ArrayBuffers or ArrayBuffer views) to the list. (If a copy is needed,
|
|
42
|
-
* this should happen in the client code, before using serialize().)
|
|
43
|
-
*
|
|
44
|
-
* @private
|
|
45
|
-
*/
|
|
46
|
-
function serialize(input, transferables) {
|
|
47
|
-
if (isSerializablePrimitive(input)) {
|
|
48
|
-
return input;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if (input instanceof ArrayBuffer) {
|
|
52
|
-
transferables?.push(input);
|
|
53
|
-
return input;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
if (ArrayBuffer.isView(input)) {
|
|
57
|
-
transferables?.push(input.buffer);
|
|
58
|
-
return input;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
if (input instanceof ImageData) {
|
|
62
|
-
transferables?.push(input.data.buffer);
|
|
63
|
-
return input;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (Array.isArray(input)) {
|
|
67
|
-
return input.map(item => serialize(item, transferables));
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
if (typeof input === 'object') {
|
|
71
|
-
const klass = input.constructor;
|
|
72
|
-
const name = klass._classRegistryKey;
|
|
73
|
-
if (!name) {
|
|
74
|
-
throw new Error(`can't serialize object of unregistered class`);
|
|
75
|
-
}
|
|
76
|
-
assert(registry.has(name));
|
|
77
|
-
|
|
78
|
-
// (Temporary workaround) allow a class to provide static
|
|
79
|
-
// `serialize()` and `deserialize()` methods to bypass the generic
|
|
80
|
-
// approach.
|
|
81
|
-
// This temporary workaround lets us use the generic serialization
|
|
82
|
-
// approach for objects whose members include instances of dynamic
|
|
83
|
-
// StructArray types. Once we refactor StructArray to be static,
|
|
84
|
-
// we can remove this complexity.
|
|
85
|
-
const properties = klass.serialize ? klass.serialize(input, transferables) : {};
|
|
86
|
-
|
|
87
|
-
if (!klass.serialize) {
|
|
88
|
-
const { omit, shallow } = registry.get(name);
|
|
89
|
-
for (const key in input) {
|
|
90
|
-
if (!Object.hasOwn(input, key)) continue;
|
|
91
|
-
if (omit?.includes(key)) continue;
|
|
92
|
-
const value = input[key];
|
|
93
|
-
properties[key] = shallow?.includes(key) ? value : serialize(value, transferables);
|
|
94
|
-
}
|
|
95
|
-
if (input instanceof Error) {
|
|
96
|
-
properties.message = input.message;
|
|
97
|
-
}
|
|
98
|
-
} else {
|
|
99
|
-
// make sure statically serialized object survives transfer of $name property
|
|
100
|
-
assert(!transferables || properties !== transferables[transferables.length - 1]);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
if (properties.$name) {
|
|
104
|
-
throw new Error('$name property is reserved for worker serialization logic.');
|
|
105
|
-
}
|
|
106
|
-
if (name !== 'Object') {
|
|
107
|
-
properties.$name = name;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
return properties;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
throw new Error(`can't serialize object of type ${typeof input}`);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
function deserialize(input) {
|
|
117
|
-
if (
|
|
118
|
-
isSerializablePrimitive(input) ||
|
|
119
|
-
input instanceof ArrayBuffer ||
|
|
120
|
-
ArrayBuffer.isView(input) ||
|
|
121
|
-
input instanceof ImageData
|
|
122
|
-
) {
|
|
123
|
-
return input;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
if (Array.isArray(input)) {
|
|
127
|
-
return input.map(deserialize);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
if (typeof input === 'object') {
|
|
131
|
-
const name = input.$name ?? 'Object';
|
|
132
|
-
|
|
133
|
-
const { klass, shallow } = registry.get(name);
|
|
134
|
-
if (!klass) {
|
|
135
|
-
throw new Error(`can't deserialize unregistered class ${name}`);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
if (klass.deserialize) {
|
|
139
|
-
return klass.deserialize(input);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
const result = Object.create(klass.prototype);
|
|
143
|
-
|
|
144
|
-
for (const key of Object.keys(input)) {
|
|
145
|
-
if (key === '$name') continue;
|
|
146
|
-
const value = input[key];
|
|
147
|
-
result[key] = shallow?.includes(key) ? value : deserialize(value);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
return result;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
throw new Error(`can't deserialize object of type ${typeof input}`);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
function isSerializablePrimitive(input) {
|
|
157
|
-
return (
|
|
158
|
-
input == null ||
|
|
159
|
-
typeof input === 'boolean' ||
|
|
160
|
-
typeof input === 'number' ||
|
|
161
|
-
typeof input === 'string' ||
|
|
162
|
-
input instanceof Date ||
|
|
163
|
-
input instanceof RegExp ||
|
|
164
|
-
input instanceof Boolean ||
|
|
165
|
-
input instanceof Number ||
|
|
166
|
-
input instanceof String
|
|
167
|
-
);
|
|
168
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
const Grid = require('grid-index');
|
|
2
|
-
const { Color } = require('@mapwhit/style-expressions');
|
|
3
|
-
const {
|
|
4
|
-
CompoundExpression,
|
|
5
|
-
definitions: expressions,
|
|
6
|
-
StylePropertyFunction,
|
|
7
|
-
StyleExpression,
|
|
8
|
-
ZoomDependentExpression,
|
|
9
|
-
ZoomConstantExpression
|
|
10
|
-
} = require('@mapwhit/style-expressions');
|
|
11
|
-
|
|
12
|
-
const { register, serialize, deserialize } = require('./transfer_registry');
|
|
13
|
-
module.exports = {
|
|
14
|
-
serialize,
|
|
15
|
-
deserialize
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
Grid.serialize = function serializeGrid(grid, transferables) {
|
|
19
|
-
const buffer = grid.toArrayBuffer();
|
|
20
|
-
if (transferables) {
|
|
21
|
-
transferables.push(buffer);
|
|
22
|
-
}
|
|
23
|
-
return { buffer };
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
Grid.deserialize = function deserializeGrid(serialized) {
|
|
27
|
-
return new Grid(serialized.buffer);
|
|
28
|
-
};
|
|
29
|
-
register('Grid', Grid);
|
|
30
|
-
|
|
31
|
-
register('Color', Color);
|
|
32
|
-
register('Error', Error);
|
|
33
|
-
|
|
34
|
-
register('StylePropertyFunction', StylePropertyFunction);
|
|
35
|
-
register('StyleExpression', StyleExpression, { omit: ['_evaluator'] });
|
|
36
|
-
|
|
37
|
-
register('ZoomDependentExpression', ZoomDependentExpression);
|
|
38
|
-
register('ZoomConstantExpression', ZoomConstantExpression);
|
|
39
|
-
register('CompoundExpression', CompoundExpression, { omit: ['_evaluate'] });
|
|
40
|
-
for (const name in expressions) {
|
|
41
|
-
if (expressions[name]._classRegistryKey) continue;
|
|
42
|
-
register(`Expression_${name}`, expressions[name]);
|
|
43
|
-
}
|
package/src/util/worker_pool.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
const assert = require('assert');
|
|
2
|
-
const WebWorker = require('./web_worker');
|
|
3
|
-
const config = require('./config');
|
|
4
|
-
|
|
5
|
-
module.exports = workerPool;
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Constructs a worker pool.
|
|
9
|
-
* @private
|
|
10
|
-
*/
|
|
11
|
-
function workerPool(workerCount = config.WORKER_COUNT) {
|
|
12
|
-
const active = {};
|
|
13
|
-
let workers;
|
|
14
|
-
|
|
15
|
-
function acquire(mapId) {
|
|
16
|
-
if (!workers) {
|
|
17
|
-
assert(typeof workerCount === 'number' && workerCount < Number.POSITIVE_INFINITY);
|
|
18
|
-
|
|
19
|
-
workers = new Array(workerCount);
|
|
20
|
-
for (let i = 0; i < workerCount; i++) {
|
|
21
|
-
workers[i] = new WebWorker();
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
active[mapId] = true;
|
|
26
|
-
return workers.slice();
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function release(mapId) {
|
|
30
|
-
delete active[mapId];
|
|
31
|
-
if (Object.keys(active).length === 0) {
|
|
32
|
-
workers.forEach(w => w.terminate());
|
|
33
|
-
workers = undefined;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return {
|
|
38
|
-
acquire,
|
|
39
|
-
release
|
|
40
|
-
};
|
|
41
|
-
}
|