@honua/react 0.1.9-beta.0 → 0.1.11-beta.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.
Files changed (156) hide show
  1. package/control-plane/admin-client.d.ts +2 -0
  2. package/control-plane/admin-client.d.ts.map +1 -1
  3. package/control-plane/admin-client.js +32 -1
  4. package/control-plane/client.d.ts +1 -1
  5. package/control-plane/client.d.ts.map +1 -1
  6. package/control-plane/client.js +124 -8
  7. package/control-plane/commands/catalog.d.ts +7 -7
  8. package/control-plane/commands/catalog.d.ts.map +1 -1
  9. package/control-plane/commands/catalog.js +27 -15
  10. package/control-plane/commands/runtime.d.ts +6 -6
  11. package/control-plane/commands/runtime.d.ts.map +1 -1
  12. package/control-plane/commands/runtime.js +26 -14
  13. package/control-plane/commands/types.d.ts +4 -2
  14. package/control-plane/commands/types.d.ts.map +1 -1
  15. package/control-plane/generated/admin-api.d.ts +6 -4
  16. package/control-plane/generated/admin-api.d.ts.map +1 -1
  17. package/control-plane/generated/admin-api.js +2 -2
  18. package/control-plane/generated/admin-operations.d.ts +7 -7
  19. package/control-plane/generated/admin-operations.d.ts.map +1 -1
  20. package/control-plane/generated/admin-operations.js +9 -9
  21. package/control-plane/index.d.ts +1 -1
  22. package/control-plane/index.d.ts.map +1 -1
  23. package/control-plane/index.js +1 -1
  24. package/core/client.d.ts.map +1 -1
  25. package/core/client.js +28 -30
  26. package/core/error-envelope.d.ts +31 -0
  27. package/core/error-envelope.d.ts.map +1 -1
  28. package/core/error-envelope.js +11 -0
  29. package/core/errors.d.ts +15 -3
  30. package/core/errors.d.ts.map +1 -1
  31. package/core/errors.js +254 -2
  32. package/core/geometry-input-sr.d.ts +3 -0
  33. package/core/geometry-input-sr.d.ts.map +1 -0
  34. package/core/geometry-input-sr.js +28 -0
  35. package/core/geoservices.d.ts.map +1 -1
  36. package/core/geoservices.js +33 -6
  37. package/core/grpc-adapter.d.ts.map +1 -1
  38. package/core/grpc-adapter.js +11 -3
  39. package/core/pbf-decoder.d.ts.map +1 -1
  40. package/core/pbf-decoder.js +16 -4
  41. package/core/protocol-transport.d.ts +6 -1
  42. package/core/protocol-transport.d.ts.map +1 -1
  43. package/core/request-pipeline.d.ts +6 -3
  44. package/core/request-pipeline.d.ts.map +1 -1
  45. package/core/request-pipeline.js +28 -11
  46. package/core/spatial-filter.d.ts +4 -4
  47. package/core/spatial-filter.d.ts.map +1 -1
  48. package/core/spatial-filter.js +7 -7
  49. package/core/types.d.ts +14 -3
  50. package/core/types.d.ts.map +1 -1
  51. package/esri-compat/class-breaks-renderer.d.ts +2 -0
  52. package/esri-compat/class-breaks-renderer.d.ts.map +1 -1
  53. package/esri-compat/class-breaks-renderer.js +7 -0
  54. package/esri-compat/controls.d.ts +10 -1
  55. package/esri-compat/controls.d.ts.map +1 -1
  56. package/esri-compat/controls.js +86 -2
  57. package/esri-compat/directions.d.ts +35 -0
  58. package/esri-compat/directions.d.ts.map +1 -1
  59. package/esri-compat/directions.js +153 -2
  60. package/esri-compat/expand.d.ts +1 -0
  61. package/esri-compat/expand.d.ts.map +1 -1
  62. package/esri-compat/expand.js +61 -0
  63. package/esri-compat/feature-layer.d.ts +29 -4
  64. package/esri-compat/feature-layer.d.ts.map +1 -1
  65. package/esri-compat/feature-layer.js +335 -13
  66. package/esri-compat/geometry-engine.d.ts +4 -0
  67. package/esri-compat/geometry-engine.d.ts.map +1 -1
  68. package/esri-compat/geometry-engine.js +8 -1
  69. package/esri-compat/graphic.d.ts +7 -4
  70. package/esri-compat/graphic.d.ts.map +1 -1
  71. package/esri-compat/legend.d.ts +2 -1
  72. package/esri-compat/legend.d.ts.map +1 -1
  73. package/esri-compat/legend.js +15 -0
  74. package/esri-compat/map-view-mount.d.ts +48 -0
  75. package/esri-compat/map-view-mount.d.ts.map +1 -0
  76. package/esri-compat/map-view-mount.js +344 -0
  77. package/esri-compat/map-view.d.ts +38 -6
  78. package/esri-compat/map-view.d.ts.map +1 -1
  79. package/esri-compat/map-view.js +471 -33
  80. package/esri-compat/portal.d.ts +2 -0
  81. package/esri-compat/portal.d.ts.map +1 -1
  82. package/esri-compat/portal.js +7 -2
  83. package/esri-compat/renderer-objects.d.ts +7 -2
  84. package/esri-compat/renderer-objects.d.ts.map +1 -1
  85. package/esri-compat/renderer-objects.js +16 -5
  86. package/esri-compat/route-layer.d.ts +8 -0
  87. package/esri-compat/route-layer.d.ts.map +1 -1
  88. package/esri-compat/route-layer.js +24 -4
  89. package/esri-compat/route-task.d.ts +5 -1
  90. package/esri-compat/route-task.d.ts.map +1 -1
  91. package/esri-compat/route-task.js +119 -7
  92. package/esri-compat/scene-view.d.ts.map +1 -1
  93. package/esri-compat/scene-view.js +1 -0
  94. package/esri-compat/search.d.ts +2 -1
  95. package/esri-compat/search.d.ts.map +1 -1
  96. package/esri-compat/search.js +52 -2
  97. package/esri-compat/unique-value-renderer.d.ts +2 -0
  98. package/esri-compat/unique-value-renderer.d.ts.map +1 -1
  99. package/esri-compat/unique-value-renderer.js +7 -0
  100. package/esri-compat/web-map.d.ts +10 -0
  101. package/esri-compat/web-map.d.ts.map +1 -1
  102. package/esri-compat/web-map.js +102 -0
  103. package/map/webmap-maplibre.d.ts +2 -1
  104. package/map/webmap-maplibre.d.ts.map +1 -1
  105. package/map/webmap-maplibre.js +3 -0
  106. package/package.json +3 -3
  107. package/query-planner/geoservices.d.ts.map +1 -1
  108. package/query-planner/geoservices.js +2 -0
  109. package/query-planner/types.d.ts +2 -0
  110. package/query-planner/types.d.ts.map +1 -1
  111. package/realtime/honua-server.d.ts +4 -0
  112. package/realtime/honua-server.d.ts.map +1 -1
  113. package/realtime/honua-server.js +10 -0
  114. package/realtime/resumable.js +9 -0
  115. package/realtime/types.d.ts +8 -0
  116. package/realtime/types.d.ts.map +1 -1
  117. package/studio/capability-manifest.d.ts +10 -0
  118. package/studio/capability-manifest.d.ts.map +1 -1
  119. package/studio/capability-manifest.js +38 -0
  120. package/studio/command-adapter.d.ts +35 -0
  121. package/studio/command-adapter.d.ts.map +1 -0
  122. package/studio/command-adapter.js +36 -0
  123. package/studio/generated/studio-api.d.ts +1062 -0
  124. package/studio/generated/studio-api.d.ts.map +1 -0
  125. package/studio/generated/studio-api.js +4 -0
  126. package/studio/index.d.ts +8 -6
  127. package/studio/index.d.ts.map +1 -1
  128. package/studio/index.js +6 -5
  129. package/studio/lifecycle-client.d.ts +3 -3
  130. package/studio/lifecycle-client.d.ts.map +1 -1
  131. package/studio/lifecycle-client.js +41 -22
  132. package/studio/lifecycle-types.d.ts +56 -77
  133. package/studio/lifecycle-types.d.ts.map +1 -1
  134. package/studio/lifecycle-types.js +5 -12
  135. package/studio/types.d.ts +37 -7
  136. package/studio/types.d.ts.map +1 -1
  137. package/studio/types.js +5 -3
  138. package/studio/validate.d.ts.map +1 -1
  139. package/studio/validate.js +104 -7
  140. package/style/renderers.d.ts +6 -1
  141. package/style/renderers.d.ts.map +1 -1
  142. package/style/renderers.js +11 -6
  143. package/style/visual-variables.d.ts +43 -0
  144. package/style/visual-variables.d.ts.map +1 -0
  145. package/style/visual-variables.js +183 -0
  146. package/webmap/convert-layer.d.ts +2 -1
  147. package/webmap/convert-layer.d.ts.map +1 -1
  148. package/webmap/convert-layer.js +20 -3
  149. package/webmap/convert-renderer.d.ts +10 -3
  150. package/webmap/convert-renderer.d.ts.map +1 -1
  151. package/webmap/convert-renderer.js +190 -36
  152. package/webmap/index.d.ts +1 -0
  153. package/webmap/index.d.ts.map +1 -1
  154. package/webmap/parse.d.ts +2 -1
  155. package/webmap/parse.d.ts.map +1 -1
  156. package/webmap/parse.js +1 -1
@@ -1,5 +1,7 @@
1
1
  import { CompatEventBus, resolveCompatEventBus } from "./event-bus.js";
2
2
  import { FeatureFilterCompat } from "./feature-filter.js";
3
+ import { GraphicsLayerCompat } from "./graphics-layer.js";
4
+ import { coordinateToLonLat, lonLatFromUnknown, mountCompatMap, resolveViewContainer, } from "./map-view-mount.js";
3
5
  export class MapViewPopupCompat {
4
6
  visible;
5
7
  location;
@@ -444,11 +446,13 @@ export class MapViewCompat {
444
446
  container;
445
447
  loaded;
446
448
  loadStatus;
447
- center;
448
- zoom;
449
+ /** SceneView turns this off so a 2D canvas is not presented as a scene. */
450
+ mountRenderer = true;
451
+ centerValue;
452
+ zoomValue;
453
+ extentValue;
449
454
  scale;
450
455
  rotation;
451
- extent;
452
456
  constraints;
453
457
  padding;
454
458
  highlightOptions;
@@ -456,20 +460,25 @@ export class MapViewCompat {
456
460
  eventBus;
457
461
  popup;
458
462
  ui;
463
+ /** Esri `MapView.graphics`, the overlay collection `view.graphics.add` writes. */
464
+ graphics;
459
465
  eventListeners;
460
466
  watchListeners;
461
467
  layerViews;
462
- readyPromise;
468
+ loadPromise;
469
+ mapSurface;
470
+ painted = [];
471
+ watchedLayers = new Set();
463
472
  constructor(options = {}) {
464
473
  this.map = options.map;
465
474
  this.container = options.container;
466
475
  this.loaded = false;
467
476
  this.loadStatus = "not-loaded";
468
- this.center = options.center;
469
- this.zoom = options.zoom;
477
+ this.centerValue = options.center;
478
+ this.zoomValue = options.zoom;
470
479
  this.scale = options.scale;
471
480
  this.rotation = options.rotation;
472
- this.extent = options.extent;
481
+ this.extentValue = options.extent;
473
482
  this.constraints = options.constraints;
474
483
  this.padding = options.padding;
475
484
  this.highlightOptions = options.highlightOptions;
@@ -503,35 +512,338 @@ export class MapViewCompat {
503
512
  }, extractPopupOptions(options.popup));
504
513
  this.ui = new MapViewUiCompat(this.eventBus, (components) => {
505
514
  this.notifyWatchers("ui.components", components);
515
+ this.placeUi(components);
516
+ });
517
+ this.graphics = new GraphicsLayerCompat({ id: "view-graphics", title: "Graphics", eventBus: this.eventBus });
518
+ this.graphics.eventBus.onAny((event) => {
519
+ if (event.type.startsWith("graphics-layer.")) {
520
+ void this.refreshOverlays();
521
+ }
506
522
  });
507
523
  this.eventListeners = new Map();
508
524
  this.watchListeners = new Map();
509
525
  this.layerViews = new Map();
510
- this.readyPromise = Promise.resolve(this);
526
+ const mapBus = options.map?.eventBus;
527
+ mapBus?.on("map.layer-added", (event) => {
528
+ this.watchLayerPaint(event.payload?.layer);
529
+ void this.refreshOverlays();
530
+ });
531
+ mapBus?.on("map.layers-added", (event) => {
532
+ const layers = event.payload?.layers ?? [];
533
+ for (const layer of layers) {
534
+ this.watchLayerPaint(layer);
535
+ }
536
+ void this.refreshOverlays();
537
+ });
538
+ queueMicrotask(() => {
539
+ if (this.mountRenderer && this.loadStatus === "not-loaded") {
540
+ void this.load();
541
+ }
542
+ });
543
+ }
544
+ get center() {
545
+ return this.centerValue;
546
+ }
547
+ set center(value) {
548
+ this.setCenter(value);
549
+ }
550
+ get zoom() {
551
+ return this.zoomValue;
552
+ }
553
+ set zoom(value) {
554
+ this.setZoom(value);
555
+ }
556
+ get extent() {
557
+ return this.extentValue;
558
+ }
559
+ set extent(value) {
560
+ if (value) {
561
+ this.setExtent(value);
562
+ }
563
+ }
564
+ /** Esri `view.ready`. True once {@link load} has finished. */
565
+ get ready() {
566
+ return this.loaded;
567
+ }
568
+ load() {
569
+ if (!this.loadPromise) {
570
+ const pending = this.performLoad();
571
+ // `void view.when()` starts this promise and does not await it.
572
+ // Awaiters still receive the rejection. This handler only keeps a
573
+ // background start from becoming an uncaught page error.
574
+ void pending.catch(() => undefined);
575
+ this.loadPromise = pending;
576
+ }
577
+ return this.loadPromise;
511
578
  }
512
- async load() {
579
+ async performLoad() {
513
580
  if (this.loaded) {
514
581
  return this;
515
582
  }
516
583
  this.loadStatus = "loading";
517
584
  this.notifyWatchers("loadStatus", this.loadStatus);
518
585
  this.eventBus.emit("view.loading", undefined, this);
519
- await this.readyPromise;
520
- this.loaded = true;
521
- this.notifyWatchers("loaded", this.loaded);
522
- this.loadStatus = "loaded";
523
- this.notifyWatchers("loadStatus", this.loadStatus);
524
- this.eventBus.emit("view.loaded", undefined, this);
525
- return this;
586
+ try {
587
+ const mapWithLoad = this.map;
588
+ if (mapWithLoad && typeof mapWithLoad.load === "function") {
589
+ await mapWithLoad.load();
590
+ }
591
+ this.applyWebMapViewpoint();
592
+ await this.mountSurface();
593
+ await this.ensureLayerViews();
594
+ await this.refreshOverlays();
595
+ this.placeUi(this.ui.components);
596
+ this.loaded = true;
597
+ this.notifyWatchers("loaded", this.loaded);
598
+ this.loadStatus = "loaded";
599
+ this.notifyWatchers("loadStatus", this.loadStatus);
600
+ this.eventBus.emit("view.loaded", undefined, this);
601
+ this.emit("arcgisViewReadyChange", { target: this });
602
+ return this;
603
+ }
604
+ catch (error) {
605
+ this.loaded = false;
606
+ this.loadStatus = "failed";
607
+ this.notifyWatchers("loadStatus", this.loadStatus);
608
+ this.loadPromise = undefined;
609
+ this.eventBus.emit("view.load-error", { error }, this);
610
+ throw error;
611
+ }
612
+ }
613
+ addEventListener(type, listener) {
614
+ const callback = typeof listener === "function" ? listener : (event) => listener.handleEvent(event);
615
+ this.on(type, callback);
616
+ }
617
+ removeEventListener(type, listener) {
618
+ this.eventListeners.get(type)?.delete(listener);
619
+ }
620
+ async mountSurface() {
621
+ if (!this.mountRenderer) {
622
+ return;
623
+ }
624
+ const container = resolveViewContainer(this.container);
625
+ if (!container) {
626
+ return;
627
+ }
628
+ const basemap = this.map?.basemap;
629
+ const surface = await mountCompatMap(container, lonLatFromUnknown(this.centerValue), this.zoomValue, basemap);
630
+ if (!surface) {
631
+ throw new Error("The map renderer did not start. Install maplibre-gl in a browser view container.");
632
+ }
633
+ this.mapSurface = surface;
634
+ surface.onClick((event) => {
635
+ void this.handleMapClick(event);
636
+ });
637
+ if (this.extentValue && this.centerValue === undefined) {
638
+ surface.fitExtent(this.extentValue);
639
+ }
640
+ }
641
+ applyWebMapViewpoint() {
642
+ if (this.centerValue !== undefined || this.extentValue !== undefined) {
643
+ return;
644
+ }
645
+ const initialExtent = this.map?.initialExtent;
646
+ if (initialExtent) {
647
+ this.extentValue = initialExtent;
648
+ }
649
+ }
650
+ async ensureLayerViews() {
651
+ const layers = this.map?.layers ?? [];
652
+ for (const layer of layers) {
653
+ this.watchLayerPaint(layer);
654
+ await this.whenLayerView(layer);
655
+ }
656
+ }
657
+ watchLayerPaint(layer) {
658
+ if (!layer || typeof layer !== "object" || this.watchedLayers.has(layer)) {
659
+ return;
660
+ }
661
+ this.watchedLayers.add(layer);
662
+ const bus = layer.eventBus;
663
+ if (!bus || typeof bus.on !== "function") {
664
+ return;
665
+ }
666
+ for (const type of [
667
+ "graphics-layer.graphic-added",
668
+ "graphics-layer.graphics-added",
669
+ "graphics-layer.graphic-removed",
670
+ "graphics-layer.graphics-cleared",
671
+ "feature-layer.edits",
672
+ ]) {
673
+ bus.on(type, () => {
674
+ void this.refreshOverlays();
675
+ });
676
+ }
677
+ }
678
+ async refreshOverlays() {
679
+ if (!this.mapSurface) {
680
+ return;
681
+ }
682
+ const drawn = [...this.graphics.graphics];
683
+ const layers = this.map?.layers ?? [];
684
+ for (const layer of layers) {
685
+ if (!layer || typeof layer !== "object") {
686
+ continue;
687
+ }
688
+ const record = layer;
689
+ if (record.visible === false) {
690
+ continue;
691
+ }
692
+ if (Array.isArray(record.graphics)) {
693
+ drawn.push(...record.graphics);
694
+ if (record.type === "graphics" ||
695
+ record.type === "graphics-layer" ||
696
+ typeof record.queryFeatures !== "function") {
697
+ continue;
698
+ }
699
+ }
700
+ if (typeof record.queryFeatures !== "function") {
701
+ continue;
702
+ }
703
+ try {
704
+ const result = await record.queryFeatures({
705
+ where: record.definitionExpression ?? "1=1",
706
+ outFields: ["*"],
707
+ returnGeometry: true,
708
+ extraParams: { resultRecordCount: 2000 },
709
+ });
710
+ drawn.push(...(result?.features ?? []));
711
+ }
712
+ catch {
713
+ // An unsupported where or a service error leaves that layer off the canvas.
714
+ }
715
+ }
716
+ this.painted = drawn;
717
+ this.mapSurface.setOverlays(drawn);
526
718
  }
527
- async when(callback) {
528
- const view = await this.load();
529
- if (callback) {
530
- callback(view);
719
+ async handleMapClick(event) {
720
+ const mapPoint = {
721
+ x: event.longitude,
722
+ y: event.latitude,
723
+ longitude: event.longitude,
724
+ latitude: event.latitude,
725
+ spatialReference: { wkid: 4326 },
726
+ };
727
+ this.emit("click", { ...event, mapPoint });
728
+ const hit = await this.hitTest({ x: event.x, y: event.y, mapPoint });
729
+ const graphic = hit.results[0]?.graphic;
730
+ if (!graphic || typeof graphic !== "object") {
731
+ return;
531
732
  }
532
- return view;
733
+ const record = graphic;
734
+ const title = record.popupTemplate?.title ??
735
+ (typeof record.attributes?.name === "string" ? record.attributes.name : undefined) ??
736
+ "Feature";
737
+ this.openPopup({ location: mapPoint, features: [graphic], title });
738
+ this.renderPopup(event.x, event.y, title, record.attributes);
739
+ }
740
+ renderPopup(x, y, title, attributes) {
741
+ const container = resolveViewContainer(this.container);
742
+ if (!container || typeof document === "undefined") {
743
+ return;
744
+ }
745
+ container.querySelector(":scope > .honua-popup")?.remove();
746
+ const popup = document.createElement("div");
747
+ popup.className = "honua-popup";
748
+ popup.style.position = "absolute";
749
+ popup.style.left = `${x}px`;
750
+ popup.style.top = `${y}px`;
751
+ popup.style.transform = "translate(-50%, -100%)";
752
+ popup.style.background = "#fff";
753
+ popup.style.padding = "8px";
754
+ popup.style.maxWidth = "240px";
755
+ const heading = document.createElement("strong");
756
+ heading.textContent = title;
757
+ popup.append(heading);
758
+ if (attributes) {
759
+ const list = document.createElement("ul");
760
+ for (const [key, value] of Object.entries(attributes)) {
761
+ if (key === "color" || key === "radius" || key === "width") {
762
+ continue;
763
+ }
764
+ const item = document.createElement("li");
765
+ item.textContent = `${key}: ${String(value)}`;
766
+ list.append(item);
767
+ }
768
+ popup.append(list);
769
+ }
770
+ container.append(popup);
771
+ }
772
+ placeUi(components) {
773
+ const container = resolveViewContainer(this.container);
774
+ if (!container || typeof document === "undefined") {
775
+ return;
776
+ }
777
+ const existing = container.querySelector(":scope > .honua-view-ui");
778
+ const host = typeof HTMLElement !== "undefined" && existing instanceof HTMLElement ? existing : document.createElement("div");
779
+ if (host.parentElement !== container) {
780
+ host.className = "honua-view-ui";
781
+ host.style.position = "absolute";
782
+ host.style.inset = "0";
783
+ host.style.pointerEvents = "none";
784
+ container.append(host);
785
+ }
786
+ host.replaceChildren();
787
+ for (const record of components) {
788
+ const slot = document.createElement("div");
789
+ slot.style.position = "absolute";
790
+ slot.style.pointerEvents = "auto";
791
+ const position = record.position;
792
+ if (position.includes("bottom")) {
793
+ slot.style.bottom = "12px";
794
+ }
795
+ else {
796
+ slot.style.top = "12px";
797
+ }
798
+ if (position.includes("right")) {
799
+ slot.style.right = "12px";
800
+ }
801
+ else if (!position.includes("bottom") || position.includes("left") || position === "manual") {
802
+ slot.style.left = "12px";
803
+ }
804
+ const widget = record.component;
805
+ if (widget && typeof widget === "object" && "attachContainer" in widget) {
806
+ const attach = widget.attachContainer;
807
+ if (typeof attach === "function") {
808
+ attach.call(widget, slot);
809
+ }
810
+ }
811
+ else if (typeof HTMLElement !== "undefined" && widget instanceof HTMLElement) {
812
+ slot.append(widget);
813
+ }
814
+ const load = widget?.load;
815
+ if (typeof load === "function") {
816
+ // Placing a widget starts its load but nothing awaits it. A widget
817
+ // records its own failure (a FeatureTable whose query fails moves to
818
+ // loadStatus "failed" and emits feature-table.failed), so the
819
+ // discarded promise must not also surface as an unhandled rejection.
820
+ void Promise.resolve(load.call(widget)).catch(() => undefined);
821
+ }
822
+ host.append(slot);
823
+ }
824
+ }
825
+ when(callback) {
826
+ const pending = this.load().then((view) => {
827
+ if (callback) {
828
+ callback(view);
829
+ }
830
+ return view;
831
+ });
832
+ // Same as load(): a discarded `void view.when()` must not become a page error.
833
+ void pending.catch(() => undefined);
834
+ return pending;
533
835
  }
534
836
  toMap(screenPoint) {
837
+ const geographic = this.mapSurface?.unproject(screenPoint.x, screenPoint.y);
838
+ if (geographic) {
839
+ return {
840
+ x: geographic.longitude,
841
+ y: geographic.latitude,
842
+ longitude: geographic.longitude,
843
+ latitude: geographic.latitude,
844
+ spatialReference: { wkid: 4326 },
845
+ };
846
+ }
535
847
  const mapPoint = {
536
848
  x: screenPoint.x,
537
849
  y: screenPoint.y,
@@ -542,6 +854,14 @@ export class MapViewCompat {
542
854
  return mapPoint;
543
855
  }
544
856
  toScreen(mapPoint) {
857
+ const longitude = mapPoint.longitude ?? mapPoint.x;
858
+ const latitude = mapPoint.latitude ?? mapPoint.y;
859
+ const projected = typeof longitude === "number" && typeof latitude === "number"
860
+ ? this.mapSurface?.project(longitude, latitude)
861
+ : undefined;
862
+ if (projected) {
863
+ return projected;
864
+ }
545
865
  return {
546
866
  x: mapPoint.x,
547
867
  y: mapPoint.y,
@@ -550,6 +870,10 @@ export class MapViewCompat {
550
870
  async hitTest(event = {}) {
551
871
  const mapPoint = event.mapPoint ??
552
872
  (typeof event.x === "number" && typeof event.y === "number" ? this.toMap({ x: event.x, y: event.y }) : undefined);
873
+ const graphicHits = this.graphicsNear(mapPoint, event);
874
+ if (graphicHits.length > 0) {
875
+ return { results: graphicHits };
876
+ }
553
877
  return {
554
878
  results: this.popup.features.map((feature) => ({
555
879
  type: "graphic",
@@ -559,6 +883,41 @@ export class MapViewCompat {
559
883
  })),
560
884
  };
561
885
  }
886
+ graphicsNear(mapPoint, event) {
887
+ if (!mapPoint) {
888
+ return [];
889
+ }
890
+ const target = lonLatFromUnknown(mapPoint);
891
+ if (!target) {
892
+ return [];
893
+ }
894
+ const candidates = [...this.painted, ...this.graphics.graphics];
895
+ for (const layer of this.map?.layers ?? []) {
896
+ const record = layer;
897
+ if (Array.isArray(record?.graphics)) {
898
+ candidates.push(...record.graphics);
899
+ }
900
+ if (Array.isArray(record?.source)) {
901
+ candidates.push(...record.source);
902
+ }
903
+ }
904
+ const hits = [];
905
+ for (const graphic of candidates) {
906
+ if (!graphic || typeof graphic !== "object") {
907
+ continue;
908
+ }
909
+ if (!graphicHitsTarget(graphic, target, event, this.mapSurface)) {
910
+ continue;
911
+ }
912
+ hits.push({
913
+ type: "graphic",
914
+ graphic: graphic,
915
+ layer: extractGraphicLayer(graphic),
916
+ mapPoint,
917
+ });
918
+ }
919
+ return hits;
920
+ }
562
921
  async goTo(target, options = {}) {
563
922
  const normalizedTarget = normalizeGoToTarget(target);
564
923
  if (normalizedTarget.center !== undefined) {
@@ -611,14 +970,18 @@ export class MapViewCompat {
611
970
  this.popup.close();
612
971
  }
613
972
  setCenter(center) {
614
- this.center = center;
615
- this.notifyWatchers("center", this.center);
973
+ this.centerValue = center;
974
+ this.notifyWatchers("center", this.centerValue);
616
975
  this.eventBus.emit("view.center-changed", { center }, this);
976
+ if (center) {
977
+ this.mapSurface?.setView(lonLatFromUnknown(center), this.zoomValue);
978
+ }
617
979
  }
618
980
  setZoom(zoom) {
619
- this.zoom = zoom;
620
- this.notifyWatchers("zoom", this.zoom);
981
+ this.zoomValue = zoom;
982
+ this.notifyWatchers("zoom", this.zoomValue);
621
983
  this.eventBus.emit("view.zoom-changed", { zoom }, this);
984
+ this.mapSurface?.setView(lonLatFromUnknown(this.centerValue), zoom);
622
985
  }
623
986
  setScale(scale) {
624
987
  this.scale = scale;
@@ -631,9 +994,10 @@ export class MapViewCompat {
631
994
  this.eventBus.emit("view.rotation-changed", { rotation }, this);
632
995
  }
633
996
  setExtent(extent) {
634
- this.extent = extent;
635
- this.notifyWatchers("extent", this.extent);
997
+ this.extentValue = extent;
998
+ this.notifyWatchers("extent", this.extentValue);
636
999
  this.eventBus.emit("view.extent-changed", { extent }, this);
1000
+ this.mapSurface?.fitExtent(extent);
637
1001
  }
638
1002
  setPadding(padding) {
639
1003
  this.padding = padding;
@@ -706,6 +1070,8 @@ export class MapViewCompat {
706
1070
  };
707
1071
  }
708
1072
  destroy() {
1073
+ this.mapSurface?.destroy();
1074
+ this.mapSurface = undefined;
709
1075
  this.eventBus.emit("view.destroy", undefined, this);
710
1076
  this.emit("destroy", undefined);
711
1077
  this.ui.removeAll();
@@ -719,16 +1085,16 @@ export class MapViewCompat {
719
1085
  this.notifyWatchers("map", this.map);
720
1086
  this.container = undefined;
721
1087
  this.notifyWatchers("container", this.container);
722
- this.center = undefined;
723
- this.notifyWatchers("center", this.center);
724
- this.zoom = undefined;
725
- this.notifyWatchers("zoom", this.zoom);
1088
+ this.centerValue = undefined;
1089
+ this.notifyWatchers("center", this.centerValue);
1090
+ this.zoomValue = undefined;
1091
+ this.notifyWatchers("zoom", this.zoomValue);
726
1092
  this.scale = undefined;
727
1093
  this.notifyWatchers("scale", this.scale);
728
1094
  this.rotation = undefined;
729
1095
  this.notifyWatchers("rotation", this.rotation);
730
- this.extent = undefined;
731
- this.notifyWatchers("extent", this.extent);
1096
+ this.extentValue = undefined;
1097
+ this.notifyWatchers("extent", this.extentValue);
732
1098
  this.constraints = undefined;
733
1099
  this.notifyWatchers("constraints", this.constraints);
734
1100
  this.padding = undefined;
@@ -1137,6 +1503,78 @@ function extractObjectId(feature) {
1137
1503
  function normalizeCount(value) {
1138
1504
  return typeof value === "number" && Number.isFinite(value) ? value : 0;
1139
1505
  }
1506
+ function graphicHitsTarget(graphic, target, event, surface) {
1507
+ const geometry = graphic.geometry;
1508
+ if (!geometry || typeof geometry !== "object") {
1509
+ return false;
1510
+ }
1511
+ const record = geometry;
1512
+ const point = record.rings === undefined && record.paths === undefined ? lonLatFromUnknown(geometry) : undefined;
1513
+ if (point && nearLonLat(point, target, event, surface)) {
1514
+ return true;
1515
+ }
1516
+ const wkid = record.spatialReference?.wkid;
1517
+ if (Array.isArray(record.rings)) {
1518
+ return record.rings.some((ring) => Array.isArray(ring) && pointInRing(target, ring, wkid));
1519
+ }
1520
+ if (Array.isArray(record.paths)) {
1521
+ for (const path of record.paths) {
1522
+ if (!Array.isArray(path)) {
1523
+ continue;
1524
+ }
1525
+ for (const pair of path) {
1526
+ if (!Array.isArray(pair)) {
1527
+ continue;
1528
+ }
1529
+ const vertex = coordinateToLonLat(pair, wkid);
1530
+ if (vertex && nearLonLat(vertex, target, event, surface)) {
1531
+ return true;
1532
+ }
1533
+ }
1534
+ }
1535
+ }
1536
+ return false;
1537
+ }
1538
+ function nearLonLat(point, target, event, surface) {
1539
+ const geographicNear = Math.abs(point[0] - target[0]) <= 0.0005 && Math.abs(point[1] - target[1]) <= 0.0005;
1540
+ const projected = surface?.project(point[0], point[1]);
1541
+ const pixelNear = projected !== undefined &&
1542
+ typeof event.x === "number" &&
1543
+ typeof event.y === "number" &&
1544
+ Math.hypot(projected.x - event.x, projected.y - event.y) <= 12;
1545
+ return geographicNear || pixelNear;
1546
+ }
1547
+ function pointInRing(target, ring, wkid) {
1548
+ const polygon = [];
1549
+ for (const pair of ring) {
1550
+ if (!Array.isArray(pair)) {
1551
+ continue;
1552
+ }
1553
+ const lonLat = coordinateToLonLat(pair, wkid);
1554
+ if (lonLat) {
1555
+ polygon.push(lonLat);
1556
+ }
1557
+ }
1558
+ if (polygon.length < 3) {
1559
+ return false;
1560
+ }
1561
+ let inside = false;
1562
+ for (let index = 0, previous = polygon.length - 1; index < polygon.length; previous = index, index += 1) {
1563
+ const current = polygon[index];
1564
+ const earlier = polygon[previous];
1565
+ if (!current || !earlier) {
1566
+ continue;
1567
+ }
1568
+ const crosses = current[1] > target[1] !== earlier[1] > target[1] &&
1569
+ target[0] <
1570
+ ((earlier[0] - current[0]) * (target[1] - current[1])) / (earlier[1] - current[1] + Number.EPSILON) +
1571
+ current[0];
1572
+ if (crosses) {
1573
+ inside = !inside;
1574
+ }
1575
+ }
1576
+ return inside;
1577
+ }
1140
1578
  function extractGraphicLayer(value) {
1141
1579
  if (!("layer" in value) || value.layer === undefined || value.layer === null) {
1142
1580
  return undefined;
@@ -177,6 +177,8 @@ export declare class PortalCompat {
177
177
  search(options?: PortalSearchOptions): Promise<PortalSearchResult>;
178
178
  /** `GET /sharing/rest/content/items/{id}`. */
179
179
  getItem(itemId: string, options?: PortalGetItemOptions): Promise<PortalItem>;
180
+ /** `GET /sharing/rest/content/items/{id}/data`. Web maps return their operational layers here. */
181
+ getItemData(itemId: string, options?: PortalGetItemOptions): Promise<unknown>;
180
182
  /**
181
183
  * Resolve an item (fetching it when given an id), parse its service `url`, and
182
184
  * return an authenticated handle. Feature Service items yield a
@@ -1 +1 @@
1
- {"version":3,"file":"portal.d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AC,UAAU,CAAC;IAI3C,0EAA0E;IAC7D,aAAa,IAAI,OAAO,CAAC,UAAU,CAAC;IAIjD,kCAAkC;IACrB,MAAM,CAAC,OAAO,GAAE,mBAAwB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAiBnF,8CAA8C;IACjC,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,oBAAyB,GAAG,OAAO,CAAC,UAAU,CAAC;IAI7F,kGAAkG;IACrF,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,oBAAyB,GAAG,OAAO,CAAC,OAAO,CAAC;IAI9F;;;;;OAKG;IACU,gBAAgB,CAC3B,QAAQ,EAAE,MAAM,GAAG,UAAU,EAC7B,OAAO,GAAE,iBAAsB,GAC9B,OAAO,CAAC,gBAAgB,CAAC;IAiD5B;;;;OAIG;IACI,2BAA2B,IAAI,IAAI;IAW1C,OAAO,CAAC,wBAAwB;YAalB,OAAO;CAqBtB"}
@@ -116,6 +116,10 @@ export class PortalCompat {
116
116
  async getItem(itemId, options = {}) {
117
117
  return this.getJson(`/content/items/${encodeURIComponent(itemId)}`, {}, options.token ?? this.token);
118
118
  }
119
+ /** `GET /sharing/rest/content/items/{id}/data`. Web maps return their operational layers here. */
120
+ async getItemData(itemId, options = {}) {
121
+ return this.getJson(`/content/items/${encodeURIComponent(itemId)}/data`, {}, options.token ?? this.token);
122
+ }
119
123
  /**
120
124
  * Resolve an item (fetching it when given an id), parse its service `url`, and
121
125
  * return an authenticated handle. Feature Service items yield a
@@ -203,8 +207,9 @@ export class PortalCompat {
203
207
  query.set(key, String(value));
204
208
  }
205
209
  }
206
- if (token) {
207
- query.set("token", token);
210
+ const authToken = token ?? this.apiKey ?? identityManager.findCredential(this.sharingRestBase)?.token;
211
+ if (authToken) {
212
+ query.set("token", authToken);
208
213
  }
209
214
  const response = await this.fetchFn(`${this.sharingRestBase}${path}?${query.toString()}`);
210
215
  const json = (await response.json());