@honua/sdk-esri-compat 0.0.6-alpha.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 +5 -0
- package/contract/edit-session.d.ts +203 -0
- package/contract/edit-session.d.ts.map +1 -0
- package/contract/edit-session.js +717 -0
- package/contract/index.d.ts +20 -0
- package/contract/index.d.ts.map +1 -0
- package/contract/index.js +15 -0
- package/contract/jobs.d.ts +115 -0
- package/contract/jobs.d.ts.map +1 -0
- package/contract/jobs.js +22 -0
- package/contract/source.d.ts +138 -0
- package/contract/source.d.ts.map +1 -0
- package/contract/source.js +3364 -0
- package/contract/spatial-aggregation.d.ts +312 -0
- package/contract/spatial-aggregation.d.ts.map +1 -0
- package/contract/spatial-aggregation.js +196 -0
- package/contract/types.d.ts +542 -0
- package/contract/types.d.ts.map +1 -0
- package/contract/types.js +171 -0
- package/core/batch.d.ts +37 -0
- package/core/batch.d.ts.map +1 -0
- package/core/batch.js +78 -0
- package/core/cache-state.d.ts +76 -0
- package/core/cache-state.d.ts.map +1 -0
- package/core/cache-state.js +84 -0
- package/core/client.d.ts +289 -0
- package/core/client.d.ts.map +1 -0
- package/core/client.js +2625 -0
- package/core/errors.d.ts +68 -0
- package/core/errors.d.ts.map +1 -0
- package/core/errors.js +116 -0
- package/core/grpc-adapter.d.ts +23 -0
- package/core/grpc-adapter.d.ts.map +1 -0
- package/core/grpc-adapter.js +704 -0
- package/core/odata.d.ts +347 -0
- package/core/odata.d.ts.map +1 -0
- package/core/odata.js +837 -0
- package/core/ogc-conformance.d.ts +35 -0
- package/core/ogc-conformance.d.ts.map +1 -0
- package/core/ogc-conformance.js +121 -0
- package/core/ogc-maps.d.ts +45 -0
- package/core/ogc-maps.d.ts.map +1 -0
- package/core/ogc-maps.js +53 -0
- package/core/ogc-processes.d.ts +92 -0
- package/core/ogc-processes.d.ts.map +1 -0
- package/core/ogc-processes.js +325 -0
- package/core/ogc-tiles.d.ts +55 -0
- package/core/ogc-tiles.d.ts.map +1 -0
- package/core/ogc-tiles.js +81 -0
- package/core/pbf-decoder.d.ts +28 -0
- package/core/pbf-decoder.d.ts.map +1 -0
- package/core/pbf-decoder.js +627 -0
- package/core/query-builder.d.ts +261 -0
- package/core/query-builder.d.ts.map +1 -0
- package/core/query-builder.js +538 -0
- package/core/spatial-filter.d.ts +93 -0
- package/core/spatial-filter.d.ts.map +1 -0
- package/core/spatial-filter.js +153 -0
- package/core/stac.d.ts +43 -0
- package/core/stac.d.ts.map +1 -0
- package/core/stac.js +116 -0
- package/core/surfaces.d.ts +464 -0
- package/core/surfaces.d.ts.map +1 -0
- package/core/surfaces.js +1322 -0
- package/core/types.d.ts +1238 -0
- package/core/types.d.ts.map +1 -0
- package/core/types.js +13 -0
- package/core/wfs-capabilities.d.ts +143 -0
- package/core/wfs-capabilities.d.ts.map +1 -0
- package/core/wfs-capabilities.js +478 -0
- package/core/wfs-filter.d.ts +118 -0
- package/core/wfs-filter.d.ts.map +1 -0
- package/core/wfs-filter.js +586 -0
- package/core/wfs.d.ts +219 -0
- package/core/wfs.d.ts.map +1 -0
- package/core/wfs.js +406 -0
- package/core/wms-capabilities.d.ts +110 -0
- package/core/wms-capabilities.d.ts.map +1 -0
- package/core/wms-capabilities.js +566 -0
- package/core/wms-types.d.ts +128 -0
- package/core/wms-types.d.ts.map +1 -0
- package/core/wms-types.js +32 -0
- package/core/wms.d.ts +108 -0
- package/core/wms.d.ts.map +1 -0
- package/core/wms.js +182 -0
- package/core/wmts-capabilities.d.ts +82 -0
- package/core/wmts-capabilities.d.ts.map +1 -0
- package/core/wmts-capabilities.js +409 -0
- package/core/wmts.d.ts +80 -0
- package/core/wmts.d.ts.map +1 -0
- package/core/wmts.js +173 -0
- package/esri-compat/basemap-gallery.d.ts +38 -0
- package/esri-compat/basemap-gallery.d.ts.map +1 -0
- package/esri-compat/basemap-gallery.js +159 -0
- package/esri-compat/basemap-layer-list.d.ts +35 -0
- package/esri-compat/basemap-layer-list.d.ts.map +1 -0
- package/esri-compat/basemap-layer-list.js +139 -0
- package/esri-compat/basemap.d.ts +32 -0
- package/esri-compat/basemap.d.ts.map +1 -0
- package/esri-compat/basemap.js +84 -0
- package/esri-compat/bookmarks.d.ts +36 -0
- package/esri-compat/bookmarks.d.ts.map +1 -0
- package/esri-compat/bookmarks.js +108 -0
- package/esri-compat/class-breaks-renderer.d.ts +50 -0
- package/esri-compat/class-breaks-renderer.d.ts.map +1 -0
- package/esri-compat/class-breaks-renderer.js +164 -0
- package/esri-compat/color.d.ts +22 -0
- package/esri-compat/color.d.ts.map +1 -0
- package/esri-compat/color.js +106 -0
- package/esri-compat/controls.d.ts +174 -0
- package/esri-compat/controls.d.ts.map +1 -0
- package/esri-compat/controls.js +479 -0
- package/esri-compat/coordinate-conversion.d.ts +41 -0
- package/esri-compat/coordinate-conversion.d.ts.map +1 -0
- package/esri-compat/coordinate-conversion.js +125 -0
- package/esri-compat/directions.d.ts +45 -0
- package/esri-compat/directions.d.ts.map +1 -0
- package/esri-compat/directions.js +123 -0
- package/esri-compat/editor.d.ts +47 -0
- package/esri-compat/editor.d.ts.map +1 -0
- package/esri-compat/editor.js +170 -0
- package/esri-compat/esri-config.d.ts +16 -0
- package/esri-compat/esri-config.d.ts.map +1 -0
- package/esri-compat/esri-config.js +23 -0
- package/esri-compat/esri-request.d.ts +17 -0
- package/esri-compat/esri-request.d.ts.map +1 -0
- package/esri-compat/esri-request.js +66 -0
- package/esri-compat/event-bus.d.ts +106 -0
- package/esri-compat/event-bus.d.ts.map +1 -0
- package/esri-compat/event-bus.js +90 -0
- package/esri-compat/expand.d.ts +36 -0
- package/esri-compat/expand.d.ts.map +1 -0
- package/esri-compat/expand.js +97 -0
- package/esri-compat/extent.d.ts +43 -0
- package/esri-compat/extent.d.ts.map +1 -0
- package/esri-compat/extent.js +140 -0
- package/esri-compat/feature-form.d.ts +64 -0
- package/esri-compat/feature-form.d.ts.map +1 -0
- package/esri-compat/feature-form.js +137 -0
- package/esri-compat/feature-layer.d.ts +173 -0
- package/esri-compat/feature-layer.d.ts.map +1 -0
- package/esri-compat/feature-layer.js +655 -0
- package/esri-compat/feature-set.d.ts +32 -0
- package/esri-compat/feature-set.d.ts.map +1 -0
- package/esri-compat/feature-set.js +80 -0
- package/esri-compat/feature-table.d.ts +141 -0
- package/esri-compat/feature-table.d.ts.map +1 -0
- package/esri-compat/feature-table.js +500 -0
- package/esri-compat/feature-templates.d.ts +41 -0
- package/esri-compat/feature-templates.d.ts.map +1 -0
- package/esri-compat/feature-templates.js +97 -0
- package/esri-compat/feature.d.ts +33 -0
- package/esri-compat/feature.d.ts.map +1 -0
- package/esri-compat/feature.js +83 -0
- package/esri-compat/graphic.d.ts +46 -0
- package/esri-compat/graphic.d.ts.map +1 -0
- package/esri-compat/graphic.js +103 -0
- package/esri-compat/graphics-layer.d.ts +49 -0
- package/esri-compat/graphics-layer.d.ts.map +1 -0
- package/esri-compat/graphics-layer.js +185 -0
- package/esri-compat/group-layer.d.ts +48 -0
- package/esri-compat/group-layer.d.ts.map +1 -0
- package/esri-compat/group-layer.js +212 -0
- package/esri-compat/identify.d.ts +71 -0
- package/esri-compat/identify.d.ts.map +1 -0
- package/esri-compat/identify.js +299 -0
- package/esri-compat/identity-manager.d.ts +31 -0
- package/esri-compat/identity-manager.d.ts.map +1 -0
- package/esri-compat/identity-manager.js +115 -0
- package/esri-compat/label-class.d.ts +31 -0
- package/esri-compat/label-class.d.ts.map +1 -0
- package/esri-compat/label-class.js +102 -0
- package/esri-compat/layer-list.d.ts +77 -0
- package/esri-compat/layer-list.d.ts.map +1 -0
- package/esri-compat/layer-list.js +342 -0
- package/esri-compat/legend.d.ts +53 -0
- package/esri-compat/legend.d.ts.map +1 -0
- package/esri-compat/legend.js +254 -0
- package/esri-compat/map-image-layer.d.ts +162 -0
- package/esri-compat/map-image-layer.d.ts.map +1 -0
- package/esri-compat/map-image-layer.js +704 -0
- package/esri-compat/map-view.d.ts +315 -0
- package/esri-compat/map-view.d.ts.map +1 -0
- package/esri-compat/map-view.js +1110 -0
- package/esri-compat/map.d.ts +47 -0
- package/esri-compat/map.d.ts.map +1 -0
- package/esri-compat/map.js +209 -0
- package/esri-compat/measurement-2d.d.ts +61 -0
- package/esri-compat/measurement-2d.d.ts.map +1 -0
- package/esri-compat/measurement-2d.js +184 -0
- package/esri-compat/measurement.d.ts +45 -0
- package/esri-compat/measurement.d.ts.map +1 -0
- package/esri-compat/measurement.js +193 -0
- package/esri-compat/oauth-info.d.ts +35 -0
- package/esri-compat/oauth-info.d.ts.map +1 -0
- package/esri-compat/oauth-info.js +115 -0
- package/esri-compat/picture-marker-symbol.d.ts +35 -0
- package/esri-compat/picture-marker-symbol.d.ts.map +1 -0
- package/esri-compat/picture-marker-symbol.js +126 -0
- package/esri-compat/point.d.ts +31 -0
- package/esri-compat/point.d.ts.map +1 -0
- package/esri-compat/point.js +102 -0
- package/esri-compat/polygon.d.ts +31 -0
- package/esri-compat/polygon.d.ts.map +1 -0
- package/esri-compat/polygon.js +107 -0
- package/esri-compat/polyline.d.ts +31 -0
- package/esri-compat/polyline.d.ts.map +1 -0
- package/esri-compat/polyline.js +107 -0
- package/esri-compat/popup-template.d.ts +55 -0
- package/esri-compat/popup-template.d.ts.map +1 -0
- package/esri-compat/popup-template.js +128 -0
- package/esri-compat/popup.d.ts +54 -0
- package/esri-compat/popup.d.ts.map +1 -0
- package/esri-compat/popup.js +312 -0
- package/esri-compat/print.d.ts +47 -0
- package/esri-compat/print.d.ts.map +1 -0
- package/esri-compat/print.js +105 -0
- package/esri-compat/query.d.ts +46 -0
- package/esri-compat/query.d.ts.map +1 -0
- package/esri-compat/query.js +119 -0
- package/esri-compat/reactive-utils.d.ts +23 -0
- package/esri-compat/reactive-utils.d.ts.map +1 -0
- package/esri-compat/reactive-utils.js +178 -0
- package/esri-compat/request.d.ts +41 -0
- package/esri-compat/request.d.ts.map +1 -0
- package/esri-compat/request.js +253 -0
- package/esri-compat/route-layer.d.ts +59 -0
- package/esri-compat/route-layer.d.ts.map +1 -0
- package/esri-compat/route-layer.js +223 -0
- package/esri-compat/route-task.d.ts +88 -0
- package/esri-compat/route-task.d.ts.map +1 -0
- package/esri-compat/route-task.js +225 -0
- package/esri-compat/scene-view.d.ts +41 -0
- package/esri-compat/scene-view.d.ts.map +1 -0
- package/esri-compat/scene-view.js +68 -0
- package/esri-compat/search.d.ts +112 -0
- package/esri-compat/search.d.ts.map +1 -0
- package/esri-compat/search.js +820 -0
- package/esri-compat/simple-fill-symbol.d.ts +27 -0
- package/esri-compat/simple-fill-symbol.d.ts.map +1 -0
- package/esri-compat/simple-fill-symbol.js +85 -0
- package/esri-compat/simple-line-symbol.d.ts +27 -0
- package/esri-compat/simple-line-symbol.d.ts.map +1 -0
- package/esri-compat/simple-line-symbol.js +85 -0
- package/esri-compat/simple-marker-symbol.d.ts +29 -0
- package/esri-compat/simple-marker-symbol.d.ts.map +1 -0
- package/esri-compat/simple-marker-symbol.js +92 -0
- package/esri-compat/simple-renderer.d.ts +29 -0
- package/esri-compat/simple-renderer.d.ts.map +1 -0
- package/esri-compat/simple-renderer.js +92 -0
- package/esri-compat/sketch.d.ts +64 -0
- package/esri-compat/sketch.d.ts.map +1 -0
- package/esri-compat/sketch.js +227 -0
- package/esri-compat/spatial-reference.d.ts +31 -0
- package/esri-compat/spatial-reference.d.ts.map +1 -0
- package/esri-compat/spatial-reference.js +102 -0
- package/esri-compat/swipe.d.ts +34 -0
- package/esri-compat/swipe.d.ts.map +1 -0
- package/esri-compat/swipe.js +93 -0
- package/esri-compat/table-list.d.ts +36 -0
- package/esri-compat/table-list.d.ts.map +1 -0
- package/esri-compat/table-list.js +126 -0
- package/esri-compat/text-symbol.d.ts +37 -0
- package/esri-compat/text-symbol.d.ts.map +1 -0
- package/esri-compat/text-symbol.js +123 -0
- package/esri-compat/tile-layer.d.ts +52 -0
- package/esri-compat/tile-layer.d.ts.map +1 -0
- package/esri-compat/tile-layer.js +167 -0
- package/esri-compat/time-slider.d.ts +70 -0
- package/esri-compat/time-slider.d.ts.map +1 -0
- package/esri-compat/time-slider.js +208 -0
- package/esri-compat/track.d.ts +51 -0
- package/esri-compat/track.d.ts.map +1 -0
- package/esri-compat/track.js +174 -0
- package/esri-compat/unique-value-renderer.d.ts +41 -0
- package/esri-compat/unique-value-renderer.d.ts.map +1 -0
- package/esri-compat/unique-value-renderer.js +127 -0
- package/esri-compat/url.d.ts +12 -0
- package/esri-compat/url.d.ts.map +1 -0
- package/esri-compat/url.js +54 -0
- package/esri-compat/web-map.d.ts +14 -0
- package/esri-compat/web-map.d.ts.map +1 -0
- package/esri-compat/web-map.js +24 -0
- package/gen/honua/v1/feature_service_pb.d.ts +918 -0
- package/gen/honua/v1/feature_service_pb.d.ts.map +1 -0
- package/gen/honua/v1/feature_service_pb.js +375 -0
- package/index.d.ts +130 -0
- package/index.js +65 -0
- package/package.json +22 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { CompatEventBus, resolveCompatEventBus, safeInvokeCompatListener } from "./event-bus.js";
|
|
2
|
+
export class FeatureCompat {
|
|
3
|
+
view;
|
|
4
|
+
map;
|
|
5
|
+
container;
|
|
6
|
+
eventBus;
|
|
7
|
+
loaded;
|
|
8
|
+
loadStatus;
|
|
9
|
+
graphic;
|
|
10
|
+
title;
|
|
11
|
+
watchListeners;
|
|
12
|
+
constructor(options = {}) {
|
|
13
|
+
this.view = options.view;
|
|
14
|
+
this.map = options.map;
|
|
15
|
+
this.container = options.container;
|
|
16
|
+
this.eventBus = options.eventBus ?? resolveCompatEventBus(options.view, options.map) ?? new CompatEventBus();
|
|
17
|
+
this.loaded = false;
|
|
18
|
+
this.loadStatus = "not-loaded";
|
|
19
|
+
this.graphic = options.graphic;
|
|
20
|
+
this.title = options.title;
|
|
21
|
+
this.watchListeners = new Map();
|
|
22
|
+
}
|
|
23
|
+
async load() {
|
|
24
|
+
if (this.loaded) {
|
|
25
|
+
return this;
|
|
26
|
+
}
|
|
27
|
+
this.loadStatus = "loading";
|
|
28
|
+
this.notifyWatchers("loadStatus", this.loadStatus);
|
|
29
|
+
this.eventBus.emit("feature-widget.loading", undefined, this);
|
|
30
|
+
this.loaded = true;
|
|
31
|
+
this.notifyWatchers("loaded", this.loaded);
|
|
32
|
+
this.loadStatus = "loaded";
|
|
33
|
+
this.notifyWatchers("loadStatus", this.loadStatus);
|
|
34
|
+
this.eventBus.emit("feature-widget.loaded", undefined, this);
|
|
35
|
+
return this;
|
|
36
|
+
}
|
|
37
|
+
async when(callback) {
|
|
38
|
+
const widget = await this.load();
|
|
39
|
+
if (callback) {
|
|
40
|
+
callback(widget);
|
|
41
|
+
}
|
|
42
|
+
return widget;
|
|
43
|
+
}
|
|
44
|
+
watch(propertyName, listener) {
|
|
45
|
+
let listeners = this.watchListeners.get(propertyName);
|
|
46
|
+
if (!listeners) {
|
|
47
|
+
listeners = new Set();
|
|
48
|
+
this.watchListeners.set(propertyName, listeners);
|
|
49
|
+
}
|
|
50
|
+
listeners.add(listener);
|
|
51
|
+
return {
|
|
52
|
+
remove: () => {
|
|
53
|
+
listeners?.delete(listener);
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
setGraphic(graphic, title) {
|
|
58
|
+
this.graphic = graphic;
|
|
59
|
+
this.notifyWatchers("graphic", this.graphic);
|
|
60
|
+
if (title !== undefined) {
|
|
61
|
+
this.title = title;
|
|
62
|
+
this.notifyWatchers("title", this.title);
|
|
63
|
+
}
|
|
64
|
+
this.eventBus.emit("feature-widget.updated", { graphic: this.graphic, title: this.title }, this);
|
|
65
|
+
}
|
|
66
|
+
clear() {
|
|
67
|
+
this.graphic = undefined;
|
|
68
|
+
this.notifyWatchers("graphic", this.graphic);
|
|
69
|
+
this.eventBus.emit("feature-widget.cleared", undefined, this);
|
|
70
|
+
}
|
|
71
|
+
destroy() {
|
|
72
|
+
this.watchListeners.clear();
|
|
73
|
+
}
|
|
74
|
+
notifyWatchers(propertyName, value) {
|
|
75
|
+
const listeners = this.watchListeners.get(propertyName);
|
|
76
|
+
if (!listeners) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
for (const listener of listeners) {
|
|
80
|
+
safeInvokeCompatListener(listener, value);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/** Structural type for geometry-like objects (point, polyline, polygon, extent, etc.). */
|
|
2
|
+
export type CompatGeometryLike = Record<string, unknown>;
|
|
3
|
+
/** Structural type for symbol-like objects (marker, line, fill, text, etc.). */
|
|
4
|
+
export type CompatSymbolLike = Record<string, unknown>;
|
|
5
|
+
/** Structural type for popup template-like objects. */
|
|
6
|
+
export type CompatPopupTemplateLike = Record<string, unknown>;
|
|
7
|
+
export interface GraphicCompatOptions {
|
|
8
|
+
geometry?: CompatGeometryLike | null;
|
|
9
|
+
symbol?: CompatSymbolLike | null;
|
|
10
|
+
attributes?: Record<string, unknown>;
|
|
11
|
+
popupTemplate?: CompatPopupTemplateLike | null;
|
|
12
|
+
layer?: unknown;
|
|
13
|
+
}
|
|
14
|
+
export type GraphicLoadStatusCompat = "not-loaded" | "loading" | "loaded";
|
|
15
|
+
export interface GraphicHandleCompat {
|
|
16
|
+
remove(): void;
|
|
17
|
+
}
|
|
18
|
+
export declare class GraphicCompat {
|
|
19
|
+
loaded: boolean;
|
|
20
|
+
loadStatus: GraphicLoadStatusCompat;
|
|
21
|
+
geometry: CompatGeometryLike | null;
|
|
22
|
+
symbol: CompatSymbolLike | null;
|
|
23
|
+
attributes: Record<string, unknown>;
|
|
24
|
+
popupTemplate: CompatPopupTemplateLike | null;
|
|
25
|
+
layer: unknown;
|
|
26
|
+
private readonly watchListeners;
|
|
27
|
+
constructor(options?: GraphicCompatOptions);
|
|
28
|
+
load(): Promise<GraphicCompat>;
|
|
29
|
+
when(callback?: (graphic: GraphicCompat) => void): Promise<GraphicCompat>;
|
|
30
|
+
watch(propertyName: "loaded", listener: (value: boolean) => void): GraphicHandleCompat;
|
|
31
|
+
watch(propertyName: "loadStatus", listener: (value: GraphicLoadStatusCompat) => void): GraphicHandleCompat;
|
|
32
|
+
watch(propertyName: "geometry", listener: (value: CompatGeometryLike | null) => void): GraphicHandleCompat;
|
|
33
|
+
watch(propertyName: "symbol", listener: (value: CompatSymbolLike | null) => void): GraphicHandleCompat;
|
|
34
|
+
watch(propertyName: "attributes", listener: (value: Record<string, unknown>) => void): GraphicHandleCompat;
|
|
35
|
+
watch(propertyName: string, listener: (value: unknown) => void): GraphicHandleCompat;
|
|
36
|
+
setGeometry(geometry: CompatGeometryLike | null): void;
|
|
37
|
+
setSymbol(symbol: CompatSymbolLike | null): void;
|
|
38
|
+
setAttributes(attributes: Record<string, unknown>): void;
|
|
39
|
+
setPopupTemplate(popupTemplate: CompatPopupTemplateLike | null): void;
|
|
40
|
+
setLayer(layer: unknown): void;
|
|
41
|
+
clone(): GraphicCompat;
|
|
42
|
+
toJSON(): Record<string, unknown>;
|
|
43
|
+
destroy(): void;
|
|
44
|
+
private notifyWatchers;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=graphic.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphic.d.ts","sourceRoot":"","sources":["../../../src/esri-compat/graphic.ts"],"names":[],"mappings":"AAEA,0FAA0F;AAC1F,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEzD,gFAAgF;AAChF,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEvD,uDAAuD;AACvD,MAAM,MAAM,uBAAuB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE9D,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,EAAE,kBAAkB,GAAG,IAAI,CAAC;IACrC,MAAM,CAAC,EAAE,gBAAgB,GAAG,IAAI,CAAC;IACjC,UAAU,CAAC,EAAE,MAAM,CAAC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,GAAG,mBAAmB;IACtG,KAAK,CAAC,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,GAAG,mBAAmB;IAC1G,KAAK,CAAC,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,GAAG,mBAAmB;IAgBpF,WAAW,CAAC,QAAQ,EAAE,kBAAkB,GAAG,IAAI,GAAG,IAAI;IAKtD,SAAS,CAAC,MAAM,EAAE,gBAAgB,GAAG,IAAI,GAAG,IAAI;IAKhD,aAAa,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAKxD,gBAAgB,CAAC,aAAa,EAAE,uBAAuB,GAAG,IAAI,GAAG,IAAI;IAKrE,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IAK9B,KAAK,IAAI,aAAa;IAUtB,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAUjC,OAAO,IAAI,IAAI;IAItB,OAAO,CAAC,cAAc;CAUvB"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { safeInvokeCompatListener } from "./event-bus.js";
|
|
2
|
+
export class GraphicCompat {
|
|
3
|
+
loaded;
|
|
4
|
+
loadStatus;
|
|
5
|
+
geometry;
|
|
6
|
+
symbol;
|
|
7
|
+
attributes;
|
|
8
|
+
popupTemplate;
|
|
9
|
+
layer;
|
|
10
|
+
watchListeners;
|
|
11
|
+
constructor(options = {}) {
|
|
12
|
+
this.loaded = false;
|
|
13
|
+
this.loadStatus = "not-loaded";
|
|
14
|
+
this.geometry = options.geometry ?? null;
|
|
15
|
+
this.symbol = options.symbol ?? null;
|
|
16
|
+
this.attributes = options.attributes ? { ...options.attributes } : {};
|
|
17
|
+
this.popupTemplate = options.popupTemplate ?? null;
|
|
18
|
+
this.layer = options.layer;
|
|
19
|
+
this.watchListeners = new Map();
|
|
20
|
+
}
|
|
21
|
+
async load() {
|
|
22
|
+
if (this.loaded) {
|
|
23
|
+
return this;
|
|
24
|
+
}
|
|
25
|
+
this.loadStatus = "loading";
|
|
26
|
+
this.notifyWatchers("loadStatus", this.loadStatus);
|
|
27
|
+
this.loaded = true;
|
|
28
|
+
this.notifyWatchers("loaded", this.loaded);
|
|
29
|
+
this.loadStatus = "loaded";
|
|
30
|
+
this.notifyWatchers("loadStatus", this.loadStatus);
|
|
31
|
+
return this;
|
|
32
|
+
}
|
|
33
|
+
async when(callback) {
|
|
34
|
+
const graphic = await this.load();
|
|
35
|
+
if (callback) {
|
|
36
|
+
callback(graphic);
|
|
37
|
+
}
|
|
38
|
+
return graphic;
|
|
39
|
+
}
|
|
40
|
+
watch(propertyName, listener) {
|
|
41
|
+
let listeners = this.watchListeners.get(propertyName);
|
|
42
|
+
if (!listeners) {
|
|
43
|
+
listeners = new Set();
|
|
44
|
+
this.watchListeners.set(propertyName, listeners);
|
|
45
|
+
}
|
|
46
|
+
listeners.add(listener);
|
|
47
|
+
return {
|
|
48
|
+
remove: () => {
|
|
49
|
+
listeners?.delete(listener);
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
setGeometry(geometry) {
|
|
54
|
+
this.geometry = geometry;
|
|
55
|
+
this.notifyWatchers("geometry", this.geometry);
|
|
56
|
+
}
|
|
57
|
+
setSymbol(symbol) {
|
|
58
|
+
this.symbol = symbol;
|
|
59
|
+
this.notifyWatchers("symbol", this.symbol);
|
|
60
|
+
}
|
|
61
|
+
setAttributes(attributes) {
|
|
62
|
+
this.attributes = { ...attributes };
|
|
63
|
+
this.notifyWatchers("attributes", this.attributes);
|
|
64
|
+
}
|
|
65
|
+
setPopupTemplate(popupTemplate) {
|
|
66
|
+
this.popupTemplate = popupTemplate;
|
|
67
|
+
this.notifyWatchers("popupTemplate", this.popupTemplate);
|
|
68
|
+
}
|
|
69
|
+
setLayer(layer) {
|
|
70
|
+
this.layer = layer;
|
|
71
|
+
this.notifyWatchers("layer", this.layer);
|
|
72
|
+
}
|
|
73
|
+
clone() {
|
|
74
|
+
return new GraphicCompat({
|
|
75
|
+
geometry: this.geometry,
|
|
76
|
+
symbol: this.symbol,
|
|
77
|
+
attributes: this.attributes,
|
|
78
|
+
popupTemplate: this.popupTemplate,
|
|
79
|
+
layer: this.layer,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
toJSON() {
|
|
83
|
+
return {
|
|
84
|
+
geometry: this.geometry,
|
|
85
|
+
symbol: this.symbol,
|
|
86
|
+
attributes: { ...this.attributes },
|
|
87
|
+
popupTemplate: this.popupTemplate,
|
|
88
|
+
layer: this.layer,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
destroy() {
|
|
92
|
+
this.watchListeners.clear();
|
|
93
|
+
}
|
|
94
|
+
notifyWatchers(propertyName, value) {
|
|
95
|
+
const listeners = this.watchListeners.get(propertyName);
|
|
96
|
+
if (!listeners) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
for (const listener of listeners) {
|
|
100
|
+
safeInvokeCompatListener(listener, value);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { CompatEventBus } from "./event-bus.js";
|
|
2
|
+
export interface GraphicsLayerCompatOptions {
|
|
3
|
+
id?: string;
|
|
4
|
+
title?: string;
|
|
5
|
+
graphics?: unknown[];
|
|
6
|
+
visible?: boolean;
|
|
7
|
+
opacity?: number;
|
|
8
|
+
listMode?: "show" | "hide";
|
|
9
|
+
eventBus?: CompatEventBus;
|
|
10
|
+
}
|
|
11
|
+
export interface GraphicsLayerQueryResult {
|
|
12
|
+
features: unknown[];
|
|
13
|
+
}
|
|
14
|
+
export type GraphicsLayerLoadStatusCompat = "not-loaded" | "loading" | "loaded";
|
|
15
|
+
export interface GraphicsLayerHandleCompat {
|
|
16
|
+
remove(): void;
|
|
17
|
+
}
|
|
18
|
+
export declare class GraphicsLayerCompat {
|
|
19
|
+
readonly type: "graphics";
|
|
20
|
+
id: string | undefined;
|
|
21
|
+
title: string | undefined;
|
|
22
|
+
visible: boolean;
|
|
23
|
+
opacity: number;
|
|
24
|
+
listMode: "show" | "hide";
|
|
25
|
+
loaded: boolean;
|
|
26
|
+
loadStatus: GraphicsLayerLoadStatusCompat;
|
|
27
|
+
readonly eventBus: CompatEventBus;
|
|
28
|
+
private readonly graphicsInternal;
|
|
29
|
+
private readonly watchListeners;
|
|
30
|
+
private readonly eventListeners;
|
|
31
|
+
constructor(options?: GraphicsLayerCompatOptions);
|
|
32
|
+
load(): Promise<GraphicsLayerCompat>;
|
|
33
|
+
when(callback?: (layer: GraphicsLayerCompat) => void): Promise<GraphicsLayerCompat>;
|
|
34
|
+
watch(propertyName: string, listener: (value: unknown) => void): GraphicsLayerHandleCompat;
|
|
35
|
+
get graphics(): readonly unknown[];
|
|
36
|
+
add(graphic: unknown, index?: number): unknown;
|
|
37
|
+
addMany(graphics: readonly unknown[], index?: number): readonly unknown[];
|
|
38
|
+
remove(graphic: unknown): unknown | undefined;
|
|
39
|
+
removeMany(graphics: readonly unknown[]): unknown[];
|
|
40
|
+
removeAll(): void;
|
|
41
|
+
setVisibility(visible: boolean): void;
|
|
42
|
+
setOpacity(opacity: number): void;
|
|
43
|
+
queryFeatures(): Promise<GraphicsLayerQueryResult>;
|
|
44
|
+
queryFeatureCount(): Promise<number>;
|
|
45
|
+
on(eventName: string, listener: (event: unknown) => void): GraphicsLayerHandleCompat;
|
|
46
|
+
destroy(): void;
|
|
47
|
+
private notifyWatchers;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=graphics-layer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphics-layer.d.ts","sourceRoot":"","sources":["../../../src/esri-compat/graphics-layer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAmD,MAAM,gBAAgB,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,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,GAAG,yBAAyB;IAejG,IAAW,QAAQ,IAAI,SAAS,OAAO,EAAE,CAExC;IAEM,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO;IAmB9C,OAAO,CAAC,QAAQ,EAAE,SAAS,OAAO,EAAE,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,OAAO,EAAE;IA4BzE,MAAM,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,GAAG,SAAS;IAY7C,UAAU,CAAC,QAAQ,EAAE,SAAS,OAAO,EAAE,GAAG,OAAO,EAAE;IAWnD,SAAS,IAAI,IAAI;IAWjB,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAMrC,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAM3B,aAAa,IAAI,OAAO,CAAC,wBAAwB,CAAC;IAMlD,iBAAiB,IAAI,OAAO,CAAC,MAAM,CAAC;IAI1C,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,GAAG,yBAAyB;IAqBpF,OAAO,IAAI,IAAI;IAMtB,OAAO,CAAC,cAAc;CAUvB"}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { CompatEventBus, resolveCompatEventBus, safeInvokeCompatListener } from "./event-bus.js";
|
|
2
|
+
export class GraphicsLayerCompat {
|
|
3
|
+
type;
|
|
4
|
+
id;
|
|
5
|
+
title;
|
|
6
|
+
visible;
|
|
7
|
+
opacity;
|
|
8
|
+
listMode;
|
|
9
|
+
loaded;
|
|
10
|
+
loadStatus;
|
|
11
|
+
eventBus;
|
|
12
|
+
graphicsInternal;
|
|
13
|
+
watchListeners;
|
|
14
|
+
eventListeners;
|
|
15
|
+
constructor(options = {}) {
|
|
16
|
+
this.type = "graphics";
|
|
17
|
+
this.id = options.id;
|
|
18
|
+
this.title = options.title;
|
|
19
|
+
this.visible = options.visible ?? true;
|
|
20
|
+
this.opacity = options.opacity ?? 1;
|
|
21
|
+
this.listMode = options.listMode ?? "show";
|
|
22
|
+
this.loaded = false;
|
|
23
|
+
this.loadStatus = "not-loaded";
|
|
24
|
+
this.graphicsInternal = Array.isArray(options.graphics) ? [...options.graphics] : [];
|
|
25
|
+
this.eventBus = options.eventBus ?? resolveCompatEventBus(options.graphics) ?? new CompatEventBus();
|
|
26
|
+
this.watchListeners = new Map();
|
|
27
|
+
this.eventListeners = new Map();
|
|
28
|
+
}
|
|
29
|
+
async load() {
|
|
30
|
+
if (this.loaded) {
|
|
31
|
+
return this;
|
|
32
|
+
}
|
|
33
|
+
this.loadStatus = "loading";
|
|
34
|
+
this.notifyWatchers("loadStatus", this.loadStatus);
|
|
35
|
+
this.eventBus.emit("graphics-layer.loading", { layerId: this.id }, this);
|
|
36
|
+
this.loaded = true;
|
|
37
|
+
this.notifyWatchers("loaded", this.loaded);
|
|
38
|
+
this.loadStatus = "loaded";
|
|
39
|
+
this.notifyWatchers("loadStatus", this.loadStatus);
|
|
40
|
+
this.eventBus.emit("graphics-layer.loaded", { layerId: this.id }, this);
|
|
41
|
+
return this;
|
|
42
|
+
}
|
|
43
|
+
async when(callback) {
|
|
44
|
+
const layer = await this.load();
|
|
45
|
+
if (callback) {
|
|
46
|
+
callback(layer);
|
|
47
|
+
}
|
|
48
|
+
return layer;
|
|
49
|
+
}
|
|
50
|
+
watch(propertyName, listener) {
|
|
51
|
+
let listeners = this.watchListeners.get(propertyName);
|
|
52
|
+
if (!listeners) {
|
|
53
|
+
listeners = new Set();
|
|
54
|
+
this.watchListeners.set(propertyName, listeners);
|
|
55
|
+
}
|
|
56
|
+
listeners.add(listener);
|
|
57
|
+
return {
|
|
58
|
+
remove: () => {
|
|
59
|
+
listeners?.delete(listener);
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
get graphics() {
|
|
64
|
+
return this.graphicsInternal;
|
|
65
|
+
}
|
|
66
|
+
add(graphic, index) {
|
|
67
|
+
if (index === undefined) {
|
|
68
|
+
this.graphicsInternal.push(graphic);
|
|
69
|
+
this.notifyWatchers("graphics", this.graphics);
|
|
70
|
+
this.eventBus.emit("graphics-layer.graphic-added", { layerId: this.id, graphic, index: this.graphicsInternal.length - 1 }, this);
|
|
71
|
+
return graphic;
|
|
72
|
+
}
|
|
73
|
+
const insertAt = normalizeInsertIndex(index, this.graphicsInternal.length);
|
|
74
|
+
this.graphicsInternal.splice(insertAt, 0, graphic);
|
|
75
|
+
this.notifyWatchers("graphics", this.graphics);
|
|
76
|
+
this.eventBus.emit("graphics-layer.graphic-added", { layerId: this.id, graphic, index: insertAt }, this);
|
|
77
|
+
return graphic;
|
|
78
|
+
}
|
|
79
|
+
addMany(graphics, index) {
|
|
80
|
+
if (graphics.length === 0) {
|
|
81
|
+
return [];
|
|
82
|
+
}
|
|
83
|
+
if (index === undefined) {
|
|
84
|
+
const startIndex = this.graphicsInternal.length;
|
|
85
|
+
this.graphicsInternal.push(...graphics);
|
|
86
|
+
this.notifyWatchers("graphics", this.graphics);
|
|
87
|
+
this.eventBus.emit("graphics-layer.graphics-added", { layerId: this.id, graphics: [...graphics], index: startIndex }, this);
|
|
88
|
+
return graphics;
|
|
89
|
+
}
|
|
90
|
+
const insertAt = normalizeInsertIndex(index, this.graphicsInternal.length);
|
|
91
|
+
this.graphicsInternal.splice(insertAt, 0, ...graphics);
|
|
92
|
+
this.notifyWatchers("graphics", this.graphics);
|
|
93
|
+
this.eventBus.emit("graphics-layer.graphics-added", { layerId: this.id, graphics: [...graphics], index: insertAt }, this);
|
|
94
|
+
return graphics;
|
|
95
|
+
}
|
|
96
|
+
remove(graphic) {
|
|
97
|
+
const index = this.graphicsInternal.indexOf(graphic);
|
|
98
|
+
if (index < 0) {
|
|
99
|
+
return undefined;
|
|
100
|
+
}
|
|
101
|
+
const [removed] = this.graphicsInternal.splice(index, 1);
|
|
102
|
+
this.notifyWatchers("graphics", this.graphics);
|
|
103
|
+
this.eventBus.emit("graphics-layer.graphic-removed", { layerId: this.id, graphic: removed, index }, this);
|
|
104
|
+
return removed;
|
|
105
|
+
}
|
|
106
|
+
removeMany(graphics) {
|
|
107
|
+
const removed = [];
|
|
108
|
+
for (const graphic of graphics) {
|
|
109
|
+
const removedGraphic = this.remove(graphic);
|
|
110
|
+
if (removedGraphic !== undefined) {
|
|
111
|
+
removed.push(removedGraphic);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return removed;
|
|
115
|
+
}
|
|
116
|
+
removeAll() {
|
|
117
|
+
if (this.graphicsInternal.length === 0) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
const removed = [...this.graphicsInternal];
|
|
121
|
+
this.graphicsInternal.length = 0;
|
|
122
|
+
this.notifyWatchers("graphics", this.graphics);
|
|
123
|
+
this.eventBus.emit("graphics-layer.graphics-cleared", { layerId: this.id, graphics: removed }, this);
|
|
124
|
+
}
|
|
125
|
+
setVisibility(visible) {
|
|
126
|
+
this.visible = visible;
|
|
127
|
+
this.notifyWatchers("visible", this.visible);
|
|
128
|
+
this.eventBus.emit("layer.visibility-changed", { layerId: this.id, visible }, this);
|
|
129
|
+
}
|
|
130
|
+
setOpacity(opacity) {
|
|
131
|
+
this.opacity = normalizeOpacity(opacity);
|
|
132
|
+
this.notifyWatchers("opacity", this.opacity);
|
|
133
|
+
this.eventBus.emit("layer.opacity-changed", { layerId: this.id, opacity: this.opacity }, this);
|
|
134
|
+
}
|
|
135
|
+
async queryFeatures() {
|
|
136
|
+
return {
|
|
137
|
+
features: [...this.graphicsInternal],
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
async queryFeatureCount() {
|
|
141
|
+
return this.graphicsInternal.length;
|
|
142
|
+
}
|
|
143
|
+
on(eventName, listener) {
|
|
144
|
+
const namespacedEvent = `graphics-layer.${eventName}`;
|
|
145
|
+
let listeners = this.eventListeners.get(eventName);
|
|
146
|
+
if (!listeners) {
|
|
147
|
+
listeners = new Set();
|
|
148
|
+
this.eventListeners.set(eventName, listeners);
|
|
149
|
+
}
|
|
150
|
+
listeners.add(listener);
|
|
151
|
+
const subscription = this.eventBus.on(namespacedEvent, (event) => {
|
|
152
|
+
safeInvokeCompatListener(listener, event.payload);
|
|
153
|
+
});
|
|
154
|
+
return {
|
|
155
|
+
remove: () => {
|
|
156
|
+
listeners?.delete(listener);
|
|
157
|
+
subscription.remove();
|
|
158
|
+
},
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
destroy() {
|
|
162
|
+
this.watchListeners.clear();
|
|
163
|
+
this.eventListeners.clear();
|
|
164
|
+
this.eventBus.emit("graphics-layer.destroyed", { layerId: this.id }, this);
|
|
165
|
+
}
|
|
166
|
+
notifyWatchers(propertyName, value) {
|
|
167
|
+
const listeners = this.watchListeners.get(propertyName);
|
|
168
|
+
if (!listeners) {
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
for (const listener of listeners) {
|
|
172
|
+
safeInvokeCompatListener(listener, value);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
function normalizeInsertIndex(index, length) {
|
|
177
|
+
const sanitized = Number.isFinite(index) ? Math.trunc(index) : length;
|
|
178
|
+
return Math.min(Math.max(sanitized, 0), length);
|
|
179
|
+
}
|
|
180
|
+
function normalizeOpacity(opacity) {
|
|
181
|
+
if (!Number.isFinite(opacity)) {
|
|
182
|
+
return 1;
|
|
183
|
+
}
|
|
184
|
+
return Math.min(Math.max(opacity, 0), 1);
|
|
185
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { CompatEventBus } from "./event-bus.js";
|
|
2
|
+
export interface GroupLayerCompatOptions {
|
|
3
|
+
id?: string;
|
|
4
|
+
title?: string;
|
|
5
|
+
layers?: unknown[];
|
|
6
|
+
visible?: boolean;
|
|
7
|
+
opacity?: number;
|
|
8
|
+
listMode?: "show" | "hide";
|
|
9
|
+
visibilityMode?: "independent" | "inherited" | "exclusive";
|
|
10
|
+
eventBus?: CompatEventBus;
|
|
11
|
+
}
|
|
12
|
+
export type GroupLayerLoadStatusCompat = "not-loaded" | "loading" | "loaded";
|
|
13
|
+
export interface GroupLayerHandleCompat {
|
|
14
|
+
remove(): void;
|
|
15
|
+
}
|
|
16
|
+
export declare class GroupLayerCompat {
|
|
17
|
+
readonly type: "group";
|
|
18
|
+
id: string | undefined;
|
|
19
|
+
title: string | undefined;
|
|
20
|
+
visible: boolean;
|
|
21
|
+
opacity: number;
|
|
22
|
+
listMode: "show" | "hide";
|
|
23
|
+
visibilityMode: "independent" | "inherited" | "exclusive";
|
|
24
|
+
loaded: boolean;
|
|
25
|
+
loadStatus: GroupLayerLoadStatusCompat;
|
|
26
|
+
readonly eventBus: CompatEventBus;
|
|
27
|
+
private readonly layersInternal;
|
|
28
|
+
private readonly watchListeners;
|
|
29
|
+
private readonly eventListeners;
|
|
30
|
+
constructor(options?: GroupLayerCompatOptions);
|
|
31
|
+
load(): Promise<GroupLayerCompat>;
|
|
32
|
+
when(callback?: (layer: GroupLayerCompat) => void): Promise<GroupLayerCompat>;
|
|
33
|
+
watch(propertyName: string, listener: (value: unknown) => void): GroupLayerHandleCompat;
|
|
34
|
+
get layers(): readonly unknown[];
|
|
35
|
+
get allLayers(): readonly unknown[];
|
|
36
|
+
add(layer: unknown, index?: number): void;
|
|
37
|
+
addMany(layers: readonly unknown[], index?: number): void;
|
|
38
|
+
remove(layer: unknown): boolean;
|
|
39
|
+
removeMany(layers: readonly unknown[]): number;
|
|
40
|
+
removeAll(): void;
|
|
41
|
+
findLayerById(id: string): unknown;
|
|
42
|
+
setVisibility(visible: boolean): void;
|
|
43
|
+
setOpacity(opacity: number): void;
|
|
44
|
+
on(eventName: string, listener: (event: unknown) => void): GroupLayerHandleCompat;
|
|
45
|
+
destroy(): void;
|
|
46
|
+
private notifyWatchers;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=group-layer.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