@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,38 @@
|
|
|
1
|
+
import { CompatEventBus } from "./event-bus.js";
|
|
2
|
+
export interface BasemapGalleryCompatOptions {
|
|
3
|
+
view?: unknown;
|
|
4
|
+
map?: unknown;
|
|
5
|
+
container?: unknown;
|
|
6
|
+
source?: readonly unknown[];
|
|
7
|
+
eventBus?: CompatEventBus;
|
|
8
|
+
autoRefresh?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export type BasemapGalleryLoadStatusCompat = "not-loaded" | "loading" | "loaded";
|
|
11
|
+
export interface BasemapGalleryHandleCompat {
|
|
12
|
+
remove(): void;
|
|
13
|
+
}
|
|
14
|
+
export declare class BasemapGalleryCompat {
|
|
15
|
+
readonly view: unknown;
|
|
16
|
+
readonly map: unknown;
|
|
17
|
+
readonly container: unknown;
|
|
18
|
+
readonly eventBus: CompatEventBus;
|
|
19
|
+
readonly autoRefresh: boolean;
|
|
20
|
+
loaded: boolean;
|
|
21
|
+
loadStatus: BasemapGalleryLoadStatusCompat;
|
|
22
|
+
source: unknown[];
|
|
23
|
+
activeBasemap: unknown;
|
|
24
|
+
private readonly subscriptions;
|
|
25
|
+
private readonly watchListeners;
|
|
26
|
+
constructor(options?: BasemapGalleryCompatOptions);
|
|
27
|
+
load(): Promise<BasemapGalleryCompat>;
|
|
28
|
+
when(callback?: (widget: BasemapGalleryCompat) => void): Promise<BasemapGalleryCompat>;
|
|
29
|
+
watch(propertyName: string, listener: (value: unknown) => void): BasemapGalleryHandleCompat;
|
|
30
|
+
get basemaps(): readonly unknown[];
|
|
31
|
+
setBasemaps(basemaps: readonly unknown[]): void;
|
|
32
|
+
select(basemapOrId: unknown): unknown;
|
|
33
|
+
refresh(): unknown;
|
|
34
|
+
destroy(): void;
|
|
35
|
+
private resolveBasemap;
|
|
36
|
+
private notifyWatchers;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=basemap-gallery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"basemap-gallery.d.ts","sourceRoot":"","sources":["../../../src/esri-compat/basemap-gallery.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EAIf,MAAM,gBAAgB,CAAC;AAExB,MAAM,WAAW,2BAA2B;IAC1C,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,MAAM,CAAC,EAAE,SAAS,OAAO,EAAE,CAAC;IAC5B,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,MAAM,8BAA8B,GAAG,YAAY,GAAG,SAAS,GAAG,QAAQ,CAAC;AAEjF,MAAM,WAAW,0BAA0B;IACzC,MAAM,IAAI,IAAI,CAAC;CAChB;AAED,qBAAa,oBAAoB;IAC/B,SAAgB,IAAI,EAAE,OAAO,CAAC;IAC9B,SAAgB,GAAG,EAAE,OAAO,CAAC;IAC7B,SAAgB,SAAS,EAAE,OAAO,CAAC;IACnC,SAAgB,QAAQ,EAAE,cAAc,CAAC;IACzC,SAAgB,WAAW,EAAE,OAAO,CAAC;IAC9B,MAAM,EAAE,OAAO,CAAC;IAChB,UAAU,EAAE,8BAA8B,CAAC;IAC3C,MAAM,EAAE,OAAO,EAAE,CAAC;IAClB,aAAa,EAAE,OAAO,CAAC;IAE9B,OAAO,CAAC,QAAQ,CAAC,aAAa,CAA4B;IAC1D,OAAO,CAAC,QAAQ,CAAC,cAAc,CAA6C;gBAEzD,OAAO,GAAE,2BAAgC;IAwB/C,IAAI,IAAI,OAAO,CAAC,oBAAoB,CAAC;IAiBrC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,oBAAoB,KAAK,IAAI,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAQ5F,KAAK,CAAC,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,GAAG,0BAA0B;IAelG,IAAW,QAAQ,IAAI,SAAS,OAAO,EAAE,CAExC;IAEM,WAAW,CAAC,QAAQ,EAAE,SAAS,OAAO,EAAE,GAAG,IAAI;IAM/C,MAAM,CAAC,WAAW,EAAE,OAAO,GAAG,OAAO;IAcrC,OAAO,IAAI,OAAO;IAOlB,OAAO,IAAI,IAAI;IAOtB,OAAO,CAAC,cAAc;IAiBtB,OAAO,CAAC,cAAc;CAUvB"}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { CompatEventBus, resolveCompatEventBus, safeInvokeCompatListener, } from "./event-bus.js";
|
|
2
|
+
export class BasemapGalleryCompat {
|
|
3
|
+
view;
|
|
4
|
+
map;
|
|
5
|
+
container;
|
|
6
|
+
eventBus;
|
|
7
|
+
autoRefresh;
|
|
8
|
+
loaded;
|
|
9
|
+
loadStatus;
|
|
10
|
+
source;
|
|
11
|
+
activeBasemap;
|
|
12
|
+
subscriptions;
|
|
13
|
+
watchListeners;
|
|
14
|
+
constructor(options = {}) {
|
|
15
|
+
this.view = options.view;
|
|
16
|
+
this.map = options.map ?? extractViewMap(options.view);
|
|
17
|
+
this.container = options.container;
|
|
18
|
+
this.eventBus = options.eventBus ?? resolveCompatEventBus(options.view, this.map) ?? new CompatEventBus();
|
|
19
|
+
this.autoRefresh = options.autoRefresh ?? true;
|
|
20
|
+
this.loaded = false;
|
|
21
|
+
this.loadStatus = "not-loaded";
|
|
22
|
+
this.source = Array.isArray(options.source) ? [...options.source] : [];
|
|
23
|
+
this.activeBasemap = extractMapBasemap(this.map);
|
|
24
|
+
this.subscriptions = [];
|
|
25
|
+
this.watchListeners = new Map();
|
|
26
|
+
if (this.autoRefresh) {
|
|
27
|
+
this.subscriptions.push(this.eventBus.on("map.basemap-changed", (event) => {
|
|
28
|
+
this.activeBasemap = extractPayloadBasemap(event.payload);
|
|
29
|
+
this.notifyWatchers("activeBasemap", this.activeBasemap);
|
|
30
|
+
this.eventBus.emit("basemap-gallery.active-basemap-changed", { basemap: this.activeBasemap }, this);
|
|
31
|
+
}));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
async load() {
|
|
35
|
+
if (this.loaded) {
|
|
36
|
+
return this;
|
|
37
|
+
}
|
|
38
|
+
this.loadStatus = "loading";
|
|
39
|
+
this.notifyWatchers("loadStatus", this.loadStatus);
|
|
40
|
+
this.eventBus.emit("basemap-gallery.loading", undefined, this);
|
|
41
|
+
this.refresh();
|
|
42
|
+
this.loaded = true;
|
|
43
|
+
this.notifyWatchers("loaded", this.loaded);
|
|
44
|
+
this.loadStatus = "loaded";
|
|
45
|
+
this.notifyWatchers("loadStatus", this.loadStatus);
|
|
46
|
+
this.eventBus.emit("basemap-gallery.loaded", { basemapCount: this.source.length }, this);
|
|
47
|
+
return this;
|
|
48
|
+
}
|
|
49
|
+
async when(callback) {
|
|
50
|
+
const widget = await this.load();
|
|
51
|
+
if (callback) {
|
|
52
|
+
callback(widget);
|
|
53
|
+
}
|
|
54
|
+
return widget;
|
|
55
|
+
}
|
|
56
|
+
watch(propertyName, listener) {
|
|
57
|
+
let listeners = this.watchListeners.get(propertyName);
|
|
58
|
+
if (!listeners) {
|
|
59
|
+
listeners = new Set();
|
|
60
|
+
this.watchListeners.set(propertyName, listeners);
|
|
61
|
+
}
|
|
62
|
+
listeners.add(listener);
|
|
63
|
+
return {
|
|
64
|
+
remove: () => {
|
|
65
|
+
listeners?.delete(listener);
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
get basemaps() {
|
|
70
|
+
return this.source;
|
|
71
|
+
}
|
|
72
|
+
setBasemaps(basemaps) {
|
|
73
|
+
this.source = [...basemaps];
|
|
74
|
+
this.notifyWatchers("source", this.source);
|
|
75
|
+
this.eventBus.emit("basemap-gallery.updated", { basemapCount: this.source.length }, this);
|
|
76
|
+
}
|
|
77
|
+
select(basemapOrId) {
|
|
78
|
+
const basemap = this.resolveBasemap(basemapOrId);
|
|
79
|
+
if (basemap === undefined) {
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
setMapBasemap(this.map, basemap, this.eventBus, this);
|
|
83
|
+
this.activeBasemap = basemap;
|
|
84
|
+
this.notifyWatchers("activeBasemap", this.activeBasemap);
|
|
85
|
+
this.eventBus.emit("basemap-gallery.selected", { basemap }, this);
|
|
86
|
+
this.eventBus.emit("basemap.toggle", { activeBasemap: basemap }, this);
|
|
87
|
+
return basemap;
|
|
88
|
+
}
|
|
89
|
+
refresh() {
|
|
90
|
+
this.activeBasemap = extractMapBasemap(this.map);
|
|
91
|
+
this.notifyWatchers("activeBasemap", this.activeBasemap);
|
|
92
|
+
this.eventBus.emit("basemap-gallery.active-basemap-changed", { basemap: this.activeBasemap }, this);
|
|
93
|
+
return this.activeBasemap;
|
|
94
|
+
}
|
|
95
|
+
destroy() {
|
|
96
|
+
for (const subscription of this.subscriptions.splice(0)) {
|
|
97
|
+
subscription.remove();
|
|
98
|
+
}
|
|
99
|
+
this.watchListeners.clear();
|
|
100
|
+
}
|
|
101
|
+
resolveBasemap(basemapOrId) {
|
|
102
|
+
if (typeof basemapOrId !== "string") {
|
|
103
|
+
return basemapOrId;
|
|
104
|
+
}
|
|
105
|
+
for (const candidate of this.source) {
|
|
106
|
+
if (!isRecord(candidate)) {
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
if (candidate.id === basemapOrId || candidate.title === basemapOrId) {
|
|
110
|
+
return candidate;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return undefined;
|
|
114
|
+
}
|
|
115
|
+
notifyWatchers(propertyName, value) {
|
|
116
|
+
const listeners = this.watchListeners.get(propertyName);
|
|
117
|
+
if (!listeners) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
for (const listener of listeners) {
|
|
121
|
+
safeInvokeCompatListener(listener, value);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
function setMapBasemap(map, basemap, eventBus, source) {
|
|
126
|
+
if (!isRecord(map)) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
if (isMapBasemapSetter(map)) {
|
|
130
|
+
map.setBasemap(basemap);
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
map.basemap = basemap;
|
|
134
|
+
eventBus.emit("map.basemap-changed", { basemap }, source);
|
|
135
|
+
}
|
|
136
|
+
function extractViewMap(view) {
|
|
137
|
+
if (!isRecord(view)) {
|
|
138
|
+
return undefined;
|
|
139
|
+
}
|
|
140
|
+
return view.map;
|
|
141
|
+
}
|
|
142
|
+
function extractMapBasemap(map) {
|
|
143
|
+
if (!isRecord(map)) {
|
|
144
|
+
return undefined;
|
|
145
|
+
}
|
|
146
|
+
return map.basemap;
|
|
147
|
+
}
|
|
148
|
+
function extractPayloadBasemap(payload) {
|
|
149
|
+
if (!isRecord(payload)) {
|
|
150
|
+
return undefined;
|
|
151
|
+
}
|
|
152
|
+
return payload.basemap;
|
|
153
|
+
}
|
|
154
|
+
function isMapBasemapSetter(value) {
|
|
155
|
+
return isRecord(value) && typeof value.setBasemap === "function";
|
|
156
|
+
}
|
|
157
|
+
function isRecord(value) {
|
|
158
|
+
return typeof value === "object" && value !== null;
|
|
159
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { CompatEventBus } from "./event-bus.js";
|
|
2
|
+
export interface BasemapLayerListCompatOptions {
|
|
3
|
+
view?: unknown;
|
|
4
|
+
map?: unknown;
|
|
5
|
+
container?: unknown;
|
|
6
|
+
eventBus?: CompatEventBus;
|
|
7
|
+
autoRefresh?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export type BasemapLayerListLoadStatusCompat = "not-loaded" | "loading" | "loaded";
|
|
10
|
+
export interface BasemapLayerListHandleCompat {
|
|
11
|
+
remove(): void;
|
|
12
|
+
}
|
|
13
|
+
export declare class BasemapLayerListCompat {
|
|
14
|
+
readonly view: unknown;
|
|
15
|
+
readonly map: unknown;
|
|
16
|
+
readonly container: unknown;
|
|
17
|
+
readonly eventBus: CompatEventBus;
|
|
18
|
+
readonly autoRefresh: boolean;
|
|
19
|
+
loaded: boolean;
|
|
20
|
+
loadStatus: BasemapLayerListLoadStatusCompat;
|
|
21
|
+
basemap: unknown;
|
|
22
|
+
baseLayers: unknown[];
|
|
23
|
+
referenceLayers: unknown[];
|
|
24
|
+
private readonly subscriptions;
|
|
25
|
+
private readonly watchListeners;
|
|
26
|
+
constructor(options?: BasemapLayerListCompatOptions);
|
|
27
|
+
load(): Promise<BasemapLayerListCompat>;
|
|
28
|
+
when(callback?: (widget: BasemapLayerListCompat) => void): Promise<BasemapLayerListCompat>;
|
|
29
|
+
watch(propertyName: string, listener: (value: unknown) => void): BasemapLayerListHandleCompat;
|
|
30
|
+
refresh(): readonly unknown[];
|
|
31
|
+
setBasemap(basemap: unknown): void;
|
|
32
|
+
destroy(): void;
|
|
33
|
+
private notifyWatchers;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=basemap-layer-list.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"basemap-layer-list.d.ts","sourceRoot":"","sources":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,EAAE;IAoB7B,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAKlC,OAAO,IAAI,IAAI;IAOtB,OAAO,CAAC,cAAc;CAUvB"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { CompatEventBus, resolveCompatEventBus, safeInvokeCompatListener, } from "./event-bus.js";
|
|
2
|
+
export class BasemapLayerListCompat {
|
|
3
|
+
view;
|
|
4
|
+
map;
|
|
5
|
+
container;
|
|
6
|
+
eventBus;
|
|
7
|
+
autoRefresh;
|
|
8
|
+
loaded;
|
|
9
|
+
loadStatus;
|
|
10
|
+
basemap;
|
|
11
|
+
baseLayers;
|
|
12
|
+
referenceLayers;
|
|
13
|
+
subscriptions;
|
|
14
|
+
watchListeners;
|
|
15
|
+
constructor(options = {}) {
|
|
16
|
+
this.view = options.view;
|
|
17
|
+
this.map = options.map ?? extractViewMap(options.view);
|
|
18
|
+
this.container = options.container;
|
|
19
|
+
this.eventBus = options.eventBus ?? resolveCompatEventBus(options.view, options.map) ?? new CompatEventBus();
|
|
20
|
+
this.autoRefresh = options.autoRefresh ?? true;
|
|
21
|
+
this.loaded = false;
|
|
22
|
+
this.loadStatus = "not-loaded";
|
|
23
|
+
this.basemap = undefined;
|
|
24
|
+
this.baseLayers = [];
|
|
25
|
+
this.referenceLayers = [];
|
|
26
|
+
this.subscriptions = [];
|
|
27
|
+
this.watchListeners = new Map();
|
|
28
|
+
this.refresh();
|
|
29
|
+
if (this.autoRefresh) {
|
|
30
|
+
this.subscriptions.push(this.eventBus.on("map.basemap-changed", () => this.refresh()));
|
|
31
|
+
this.subscriptions.push(this.eventBus.on("basemap.toggle", () => this.refresh()));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
async load() {
|
|
35
|
+
if (this.loaded) {
|
|
36
|
+
return this;
|
|
37
|
+
}
|
|
38
|
+
this.loadStatus = "loading";
|
|
39
|
+
this.notifyWatchers("loadStatus", this.loadStatus);
|
|
40
|
+
this.eventBus.emit("basemap-layer-list.loading", undefined, this);
|
|
41
|
+
this.refresh();
|
|
42
|
+
this.loaded = true;
|
|
43
|
+
this.notifyWatchers("loaded", this.loaded);
|
|
44
|
+
this.loadStatus = "loaded";
|
|
45
|
+
this.notifyWatchers("loadStatus", this.loadStatus);
|
|
46
|
+
this.eventBus.emit("basemap-layer-list.loaded", undefined, this);
|
|
47
|
+
return this;
|
|
48
|
+
}
|
|
49
|
+
async when(callback) {
|
|
50
|
+
const widget = await this.load();
|
|
51
|
+
if (callback) {
|
|
52
|
+
callback(widget);
|
|
53
|
+
}
|
|
54
|
+
return widget;
|
|
55
|
+
}
|
|
56
|
+
watch(propertyName, listener) {
|
|
57
|
+
let listeners = this.watchListeners.get(propertyName);
|
|
58
|
+
if (!listeners) {
|
|
59
|
+
listeners = new Set();
|
|
60
|
+
this.watchListeners.set(propertyName, listeners);
|
|
61
|
+
}
|
|
62
|
+
listeners.add(listener);
|
|
63
|
+
return {
|
|
64
|
+
remove: () => {
|
|
65
|
+
listeners?.delete(listener);
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
refresh() {
|
|
70
|
+
const basemap = extractMapBasemap(this.map);
|
|
71
|
+
this.basemap = basemap;
|
|
72
|
+
this.notifyWatchers("basemap", this.basemap);
|
|
73
|
+
this.baseLayers = extractBasemapLayerCollection(basemap, "baseLayers");
|
|
74
|
+
this.notifyWatchers("baseLayers", this.baseLayers);
|
|
75
|
+
this.referenceLayers = extractBasemapLayerCollection(basemap, "referenceLayers");
|
|
76
|
+
this.notifyWatchers("referenceLayers", this.referenceLayers);
|
|
77
|
+
this.eventBus.emit("basemap-layer-list.refreshed", {
|
|
78
|
+
basemap: this.basemap,
|
|
79
|
+
baseLayerCount: this.baseLayers.length,
|
|
80
|
+
referenceLayerCount: this.referenceLayers.length,
|
|
81
|
+
}, this);
|
|
82
|
+
return [...this.baseLayers, ...this.referenceLayers];
|
|
83
|
+
}
|
|
84
|
+
setBasemap(basemap) {
|
|
85
|
+
setMapBasemap(this.map, basemap, this.eventBus, this);
|
|
86
|
+
this.refresh();
|
|
87
|
+
}
|
|
88
|
+
destroy() {
|
|
89
|
+
for (const subscription of this.subscriptions.splice(0)) {
|
|
90
|
+
subscription.remove();
|
|
91
|
+
}
|
|
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
|
+
}
|
|
104
|
+
function setMapBasemap(map, basemap, eventBus, source) {
|
|
105
|
+
if (!isRecord(map)) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
if (isMapBasemapSetter(map)) {
|
|
109
|
+
map.setBasemap(basemap);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
map.basemap = basemap;
|
|
113
|
+
eventBus.emit("map.basemap-changed", { basemap }, source);
|
|
114
|
+
}
|
|
115
|
+
function extractMapBasemap(map) {
|
|
116
|
+
if (!isRecord(map)) {
|
|
117
|
+
return undefined;
|
|
118
|
+
}
|
|
119
|
+
return map.basemap;
|
|
120
|
+
}
|
|
121
|
+
function extractBasemapLayerCollection(basemap, key) {
|
|
122
|
+
if (!isRecord(basemap)) {
|
|
123
|
+
return [];
|
|
124
|
+
}
|
|
125
|
+
const value = basemap[key];
|
|
126
|
+
return Array.isArray(value) ? [...value] : [];
|
|
127
|
+
}
|
|
128
|
+
function extractViewMap(view) {
|
|
129
|
+
if (!isRecord(view)) {
|
|
130
|
+
return undefined;
|
|
131
|
+
}
|
|
132
|
+
return view.map;
|
|
133
|
+
}
|
|
134
|
+
function isMapBasemapSetter(value) {
|
|
135
|
+
return isRecord(value) && typeof value.setBasemap === "function";
|
|
136
|
+
}
|
|
137
|
+
function isRecord(value) {
|
|
138
|
+
return typeof value === "object" && value !== null;
|
|
139
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { CompatEventBus } from "./event-bus.js";
|
|
2
|
+
export interface BasemapCompatOptions {
|
|
3
|
+
id?: string;
|
|
4
|
+
title?: string;
|
|
5
|
+
baseLayers?: readonly unknown[];
|
|
6
|
+
referenceLayers?: readonly unknown[];
|
|
7
|
+
eventBus?: CompatEventBus;
|
|
8
|
+
}
|
|
9
|
+
export type BasemapLoadStatusCompat = "not-loaded" | "loading" | "loaded";
|
|
10
|
+
export interface BasemapHandleCompat {
|
|
11
|
+
remove(): void;
|
|
12
|
+
}
|
|
13
|
+
export declare class BasemapCompat {
|
|
14
|
+
readonly eventBus: CompatEventBus;
|
|
15
|
+
id: string | undefined;
|
|
16
|
+
title: string | undefined;
|
|
17
|
+
baseLayers: unknown[];
|
|
18
|
+
referenceLayers: unknown[];
|
|
19
|
+
loaded: boolean;
|
|
20
|
+
loadStatus: BasemapLoadStatusCompat;
|
|
21
|
+
private readonly watchListeners;
|
|
22
|
+
constructor(options?: BasemapCompatOptions);
|
|
23
|
+
static fromId(id: string): BasemapCompat;
|
|
24
|
+
setBaseLayers(layers: readonly unknown[]): void;
|
|
25
|
+
setReferenceLayers(layers: readonly unknown[]): void;
|
|
26
|
+
load(): Promise<BasemapCompat>;
|
|
27
|
+
when(callback?: (basemap: BasemapCompat) => void): Promise<BasemapCompat>;
|
|
28
|
+
watch(propertyName: string, listener: (value: unknown) => void): BasemapHandleCompat;
|
|
29
|
+
destroy(): void;
|
|
30
|
+
private notifyWatchers;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=basemap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"basemap.d.ts","sourceRoot":"","sources":["../../../src/esri-compat/basemap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAmD,MAAM,gBAAgB,CAAC;AAEjG,MAAM,WAAW,oB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{ CompatEventBus, resolveCompatEventBus, safeInvokeCompatListener } from "./event-bus.js";
|
|
2
|
+
export class BasemapCompat {
|
|
3
|
+
eventBus;
|
|
4
|
+
id;
|
|
5
|
+
title;
|
|
6
|
+
baseLayers;
|
|
7
|
+
referenceLayers;
|
|
8
|
+
loaded;
|
|
9
|
+
loadStatus;
|
|
10
|
+
watchListeners;
|
|
11
|
+
constructor(options = {}) {
|
|
12
|
+
this.eventBus =
|
|
13
|
+
options.eventBus ?? resolveCompatEventBus(options.baseLayers, options.referenceLayers) ?? new CompatEventBus();
|
|
14
|
+
this.id = options.id;
|
|
15
|
+
this.title = options.title ?? options.id;
|
|
16
|
+
this.baseLayers = options.baseLayers ? [...options.baseLayers] : [];
|
|
17
|
+
this.referenceLayers = options.referenceLayers ? [...options.referenceLayers] : [];
|
|
18
|
+
this.loaded = false;
|
|
19
|
+
this.loadStatus = "not-loaded";
|
|
20
|
+
this.watchListeners = new Map();
|
|
21
|
+
}
|
|
22
|
+
static fromId(id) {
|
|
23
|
+
return new BasemapCompat({
|
|
24
|
+
id,
|
|
25
|
+
title: id,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
setBaseLayers(layers) {
|
|
29
|
+
this.baseLayers = [...layers];
|
|
30
|
+
this.notifyWatchers("baseLayers", this.baseLayers);
|
|
31
|
+
this.eventBus.emit("basemap.base-layers-changed", { count: this.baseLayers.length }, this);
|
|
32
|
+
}
|
|
33
|
+
setReferenceLayers(layers) {
|
|
34
|
+
this.referenceLayers = [...layers];
|
|
35
|
+
this.notifyWatchers("referenceLayers", this.referenceLayers);
|
|
36
|
+
this.eventBus.emit("basemap.reference-layers-changed", { count: this.referenceLayers.length }, this);
|
|
37
|
+
}
|
|
38
|
+
async load() {
|
|
39
|
+
if (this.loaded) {
|
|
40
|
+
return this;
|
|
41
|
+
}
|
|
42
|
+
this.loadStatus = "loading";
|
|
43
|
+
this.notifyWatchers("loadStatus", this.loadStatus);
|
|
44
|
+
this.eventBus.emit("basemap.loading", { id: this.id }, this);
|
|
45
|
+
this.loaded = true;
|
|
46
|
+
this.notifyWatchers("loaded", this.loaded);
|
|
47
|
+
this.loadStatus = "loaded";
|
|
48
|
+
this.notifyWatchers("loadStatus", this.loadStatus);
|
|
49
|
+
this.eventBus.emit("basemap.loaded", { id: this.id }, this);
|
|
50
|
+
return this;
|
|
51
|
+
}
|
|
52
|
+
async when(callback) {
|
|
53
|
+
const basemap = await this.load();
|
|
54
|
+
if (callback) {
|
|
55
|
+
callback(basemap);
|
|
56
|
+
}
|
|
57
|
+
return basemap;
|
|
58
|
+
}
|
|
59
|
+
watch(propertyName, listener) {
|
|
60
|
+
let listeners = this.watchListeners.get(propertyName);
|
|
61
|
+
if (!listeners) {
|
|
62
|
+
listeners = new Set();
|
|
63
|
+
this.watchListeners.set(propertyName, listeners);
|
|
64
|
+
}
|
|
65
|
+
listeners.add(listener);
|
|
66
|
+
return {
|
|
67
|
+
remove: () => {
|
|
68
|
+
listeners?.delete(listener);
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
destroy() {
|
|
73
|
+
this.watchListeners.clear();
|
|
74
|
+
}
|
|
75
|
+
notifyWatchers(propertyName, value) {
|
|
76
|
+
const listeners = this.watchListeners.get(propertyName);
|
|
77
|
+
if (!listeners) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
for (const listener of listeners) {
|
|
81
|
+
safeInvokeCompatListener(listener, value);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { CompatEventBus } from "./event-bus.js";
|
|
2
|
+
export interface BookmarkCompatItem {
|
|
3
|
+
name: string;
|
|
4
|
+
viewpoint?: unknown;
|
|
5
|
+
target?: unknown;
|
|
6
|
+
}
|
|
7
|
+
export interface BookmarksCompatOptions {
|
|
8
|
+
view?: unknown;
|
|
9
|
+
container?: unknown;
|
|
10
|
+
bookmarks?: readonly BookmarkCompatItem[];
|
|
11
|
+
eventBus?: CompatEventBus;
|
|
12
|
+
}
|
|
13
|
+
export type BookmarksLoadStatusCompat = "not-loaded" | "loading" | "loaded";
|
|
14
|
+
export interface BookmarksHandleCompat {
|
|
15
|
+
remove(): void;
|
|
16
|
+
}
|
|
17
|
+
export declare class BookmarksCompat {
|
|
18
|
+
readonly view: unknown;
|
|
19
|
+
readonly container: unknown;
|
|
20
|
+
readonly eventBus: CompatEventBus;
|
|
21
|
+
loaded: boolean;
|
|
22
|
+
loadStatus: BookmarksLoadStatusCompat;
|
|
23
|
+
bookmarks: BookmarkCompatItem[];
|
|
24
|
+
activeBookmark: BookmarkCompatItem | undefined;
|
|
25
|
+
private readonly watchListeners;
|
|
26
|
+
constructor(options?: BookmarksCompatOptions);
|
|
27
|
+
load(): Promise<BookmarksCompat>;
|
|
28
|
+
when(callback?: (widget: BookmarksCompat) => void): Promise<BookmarksCompat>;
|
|
29
|
+
watch(propertyName: string, listener: (value: unknown) => void): BookmarksHandleCompat;
|
|
30
|
+
add(bookmark: BookmarkCompatItem): void;
|
|
31
|
+
remove(nameOrBookmark: string | BookmarkCompatItem): boolean;
|
|
32
|
+
goTo(nameOrBookmark: string | BookmarkCompatItem): Promise<BookmarkCompatItem | undefined>;
|
|
33
|
+
destroy(): void;
|
|
34
|
+
private notifyWatchers;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=bookmarks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bookmarks.d.ts","sourceRoot":"","sources":["../../../src/esri-compat/bookmarks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAmD,MAAM,gBAAgB,CAAC;AAEjG,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,sBAAsB;IACrC,IAAI,CAAC,EAAE,OAAO,CA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-bus.js";
|
|
2
|
+
export class BookmarksCompat {
|
|
3
|
+
view;
|
|
4
|
+
container;
|
|
5
|
+
eventBus;
|
|
6
|
+
loaded;
|
|
7
|
+
loadStatus;
|
|
8
|
+
bookmarks;
|
|
9
|
+
activeBookmark;
|
|
10
|
+
watchListeners;
|
|
11
|
+
constructor(options = {}) {
|
|
12
|
+
this.view = options.view;
|
|
13
|
+
this.container = options.container;
|
|
14
|
+
this.eventBus = options.eventBus ?? resolveCompatEventBus(options.view) ?? new CompatEventBus();
|
|
15
|
+
this.loaded = false;
|
|
16
|
+
this.loadStatus = "not-loaded";
|
|
17
|
+
this.bookmarks = options.bookmarks ? [...options.bookmarks] : [];
|
|
18
|
+
this.activeBookmark = undefined;
|
|
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.eventBus.emit("bookmarks.loading", undefined, this);
|
|
28
|
+
this.loaded = true;
|
|
29
|
+
this.notifyWatchers("loaded", this.loaded);
|
|
30
|
+
this.loadStatus = "loaded";
|
|
31
|
+
this.notifyWatchers("loadStatus", this.loadStatus);
|
|
32
|
+
this.eventBus.emit("bookmarks.loaded", { bookmarkCount: this.bookmarks.length }, this);
|
|
33
|
+
return this;
|
|
34
|
+
}
|
|
35
|
+
async when(callback) {
|
|
36
|
+
const widget = await this.load();
|
|
37
|
+
if (callback) {
|
|
38
|
+
callback(widget);
|
|
39
|
+
}
|
|
40
|
+
return widget;
|
|
41
|
+
}
|
|
42
|
+
watch(propertyName, listener) {
|
|
43
|
+
let listeners = this.watchListeners.get(propertyName);
|
|
44
|
+
if (!listeners) {
|
|
45
|
+
listeners = new Set();
|
|
46
|
+
this.watchListeners.set(propertyName, listeners);
|
|
47
|
+
}
|
|
48
|
+
listeners.add(listener);
|
|
49
|
+
return {
|
|
50
|
+
remove: () => {
|
|
51
|
+
listeners?.delete(listener);
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
add(bookmark) {
|
|
56
|
+
this.bookmarks.push(bookmark);
|
|
57
|
+
this.notifyWatchers("bookmarks", this.bookmarks);
|
|
58
|
+
this.eventBus.emit("bookmarks.updated", { bookmarkCount: this.bookmarks.length }, this);
|
|
59
|
+
}
|
|
60
|
+
remove(nameOrBookmark) {
|
|
61
|
+
const index = typeof nameOrBookmark === "string"
|
|
62
|
+
? this.bookmarks.findIndex((bookmark) => bookmark.name === nameOrBookmark)
|
|
63
|
+
: this.bookmarks.indexOf(nameOrBookmark);
|
|
64
|
+
if (index < 0) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
const [removed] = this.bookmarks.splice(index, 1);
|
|
68
|
+
this.notifyWatchers("bookmarks", this.bookmarks);
|
|
69
|
+
if (this.activeBookmark === removed) {
|
|
70
|
+
this.activeBookmark = undefined;
|
|
71
|
+
this.notifyWatchers("activeBookmark", this.activeBookmark);
|
|
72
|
+
}
|
|
73
|
+
this.eventBus.emit("bookmarks.updated", { bookmarkCount: this.bookmarks.length }, this);
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
async goTo(nameOrBookmark) {
|
|
77
|
+
const bookmark = typeof nameOrBookmark === "string" ? this.bookmarks.find((item) => item.name === nameOrBookmark) : nameOrBookmark;
|
|
78
|
+
if (!bookmark) {
|
|
79
|
+
return undefined;
|
|
80
|
+
}
|
|
81
|
+
this.activeBookmark = bookmark;
|
|
82
|
+
this.notifyWatchers("activeBookmark", this.activeBookmark);
|
|
83
|
+
const target = bookmark.viewpoint ?? bookmark.target;
|
|
84
|
+
if (target !== undefined && isGoToProvider(this.view)) {
|
|
85
|
+
await this.view.goTo(target);
|
|
86
|
+
}
|
|
87
|
+
this.eventBus.emit("bookmarks.go-to", { bookmark }, this);
|
|
88
|
+
return bookmark;
|
|
89
|
+
}
|
|
90
|
+
destroy() {
|
|
91
|
+
this.watchListeners.clear();
|
|
92
|
+
}
|
|
93
|
+
notifyWatchers(propertyName, value) {
|
|
94
|
+
const listeners = this.watchListeners.get(propertyName);
|
|
95
|
+
if (!listeners) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
for (const listener of listeners) {
|
|
99
|
+
safeInvokeCompatListener(listener, value);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
function isGoToProvider(value) {
|
|
104
|
+
return isRecord(value) && typeof value.goTo === "function";
|
|
105
|
+
}
|
|
106
|
+
function isRecord(value) {
|
|
107
|
+
return typeof value === "object" && value !== null;
|
|
108
|
+
}
|