@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.
Files changed (289) hide show
  1. package/README.md +5 -0
  2. package/contract/edit-session.d.ts +203 -0
  3. package/contract/edit-session.d.ts.map +1 -0
  4. package/contract/edit-session.js +717 -0
  5. package/contract/index.d.ts +20 -0
  6. package/contract/index.d.ts.map +1 -0
  7. package/contract/index.js +15 -0
  8. package/contract/jobs.d.ts +115 -0
  9. package/contract/jobs.d.ts.map +1 -0
  10. package/contract/jobs.js +22 -0
  11. package/contract/source.d.ts +138 -0
  12. package/contract/source.d.ts.map +1 -0
  13. package/contract/source.js +3364 -0
  14. package/contract/spatial-aggregation.d.ts +312 -0
  15. package/contract/spatial-aggregation.d.ts.map +1 -0
  16. package/contract/spatial-aggregation.js +196 -0
  17. package/contract/types.d.ts +542 -0
  18. package/contract/types.d.ts.map +1 -0
  19. package/contract/types.js +171 -0
  20. package/core/batch.d.ts +37 -0
  21. package/core/batch.d.ts.map +1 -0
  22. package/core/batch.js +78 -0
  23. package/core/cache-state.d.ts +76 -0
  24. package/core/cache-state.d.ts.map +1 -0
  25. package/core/cache-state.js +84 -0
  26. package/core/client.d.ts +289 -0
  27. package/core/client.d.ts.map +1 -0
  28. package/core/client.js +2625 -0
  29. package/core/errors.d.ts +68 -0
  30. package/core/errors.d.ts.map +1 -0
  31. package/core/errors.js +116 -0
  32. package/core/grpc-adapter.d.ts +23 -0
  33. package/core/grpc-adapter.d.ts.map +1 -0
  34. package/core/grpc-adapter.js +704 -0
  35. package/core/odata.d.ts +347 -0
  36. package/core/odata.d.ts.map +1 -0
  37. package/core/odata.js +837 -0
  38. package/core/ogc-conformance.d.ts +35 -0
  39. package/core/ogc-conformance.d.ts.map +1 -0
  40. package/core/ogc-conformance.js +121 -0
  41. package/core/ogc-maps.d.ts +45 -0
  42. package/core/ogc-maps.d.ts.map +1 -0
  43. package/core/ogc-maps.js +53 -0
  44. package/core/ogc-processes.d.ts +92 -0
  45. package/core/ogc-processes.d.ts.map +1 -0
  46. package/core/ogc-processes.js +325 -0
  47. package/core/ogc-tiles.d.ts +55 -0
  48. package/core/ogc-tiles.d.ts.map +1 -0
  49. package/core/ogc-tiles.js +81 -0
  50. package/core/pbf-decoder.d.ts +28 -0
  51. package/core/pbf-decoder.d.ts.map +1 -0
  52. package/core/pbf-decoder.js +627 -0
  53. package/core/query-builder.d.ts +261 -0
  54. package/core/query-builder.d.ts.map +1 -0
  55. package/core/query-builder.js +538 -0
  56. package/core/spatial-filter.d.ts +93 -0
  57. package/core/spatial-filter.d.ts.map +1 -0
  58. package/core/spatial-filter.js +153 -0
  59. package/core/stac.d.ts +43 -0
  60. package/core/stac.d.ts.map +1 -0
  61. package/core/stac.js +116 -0
  62. package/core/surfaces.d.ts +464 -0
  63. package/core/surfaces.d.ts.map +1 -0
  64. package/core/surfaces.js +1322 -0
  65. package/core/types.d.ts +1238 -0
  66. package/core/types.d.ts.map +1 -0
  67. package/core/types.js +13 -0
  68. package/core/wfs-capabilities.d.ts +143 -0
  69. package/core/wfs-capabilities.d.ts.map +1 -0
  70. package/core/wfs-capabilities.js +478 -0
  71. package/core/wfs-filter.d.ts +118 -0
  72. package/core/wfs-filter.d.ts.map +1 -0
  73. package/core/wfs-filter.js +586 -0
  74. package/core/wfs.d.ts +219 -0
  75. package/core/wfs.d.ts.map +1 -0
  76. package/core/wfs.js +406 -0
  77. package/core/wms-capabilities.d.ts +110 -0
  78. package/core/wms-capabilities.d.ts.map +1 -0
  79. package/core/wms-capabilities.js +566 -0
  80. package/core/wms-types.d.ts +128 -0
  81. package/core/wms-types.d.ts.map +1 -0
  82. package/core/wms-types.js +32 -0
  83. package/core/wms.d.ts +108 -0
  84. package/core/wms.d.ts.map +1 -0
  85. package/core/wms.js +182 -0
  86. package/core/wmts-capabilities.d.ts +82 -0
  87. package/core/wmts-capabilities.d.ts.map +1 -0
  88. package/core/wmts-capabilities.js +409 -0
  89. package/core/wmts.d.ts +80 -0
  90. package/core/wmts.d.ts.map +1 -0
  91. package/core/wmts.js +173 -0
  92. package/esri-compat/basemap-gallery.d.ts +38 -0
  93. package/esri-compat/basemap-gallery.d.ts.map +1 -0
  94. package/esri-compat/basemap-gallery.js +159 -0
  95. package/esri-compat/basemap-layer-list.d.ts +35 -0
  96. package/esri-compat/basemap-layer-list.d.ts.map +1 -0
  97. package/esri-compat/basemap-layer-list.js +139 -0
  98. package/esri-compat/basemap.d.ts +32 -0
  99. package/esri-compat/basemap.d.ts.map +1 -0
  100. package/esri-compat/basemap.js +84 -0
  101. package/esri-compat/bookmarks.d.ts +36 -0
  102. package/esri-compat/bookmarks.d.ts.map +1 -0
  103. package/esri-compat/bookmarks.js +108 -0
  104. package/esri-compat/class-breaks-renderer.d.ts +50 -0
  105. package/esri-compat/class-breaks-renderer.d.ts.map +1 -0
  106. package/esri-compat/class-breaks-renderer.js +164 -0
  107. package/esri-compat/color.d.ts +22 -0
  108. package/esri-compat/color.d.ts.map +1 -0
  109. package/esri-compat/color.js +106 -0
  110. package/esri-compat/controls.d.ts +174 -0
  111. package/esri-compat/controls.d.ts.map +1 -0
  112. package/esri-compat/controls.js +479 -0
  113. package/esri-compat/coordinate-conversion.d.ts +41 -0
  114. package/esri-compat/coordinate-conversion.d.ts.map +1 -0
  115. package/esri-compat/coordinate-conversion.js +125 -0
  116. package/esri-compat/directions.d.ts +45 -0
  117. package/esri-compat/directions.d.ts.map +1 -0
  118. package/esri-compat/directions.js +123 -0
  119. package/esri-compat/editor.d.ts +47 -0
  120. package/esri-compat/editor.d.ts.map +1 -0
  121. package/esri-compat/editor.js +170 -0
  122. package/esri-compat/esri-config.d.ts +16 -0
  123. package/esri-compat/esri-config.d.ts.map +1 -0
  124. package/esri-compat/esri-config.js +23 -0
  125. package/esri-compat/esri-request.d.ts +17 -0
  126. package/esri-compat/esri-request.d.ts.map +1 -0
  127. package/esri-compat/esri-request.js +66 -0
  128. package/esri-compat/event-bus.d.ts +106 -0
  129. package/esri-compat/event-bus.d.ts.map +1 -0
  130. package/esri-compat/event-bus.js +90 -0
  131. package/esri-compat/expand.d.ts +36 -0
  132. package/esri-compat/expand.d.ts.map +1 -0
  133. package/esri-compat/expand.js +97 -0
  134. package/esri-compat/extent.d.ts +43 -0
  135. package/esri-compat/extent.d.ts.map +1 -0
  136. package/esri-compat/extent.js +140 -0
  137. package/esri-compat/feature-form.d.ts +64 -0
  138. package/esri-compat/feature-form.d.ts.map +1 -0
  139. package/esri-compat/feature-form.js +137 -0
  140. package/esri-compat/feature-layer.d.ts +173 -0
  141. package/esri-compat/feature-layer.d.ts.map +1 -0
  142. package/esri-compat/feature-layer.js +655 -0
  143. package/esri-compat/feature-set.d.ts +32 -0
  144. package/esri-compat/feature-set.d.ts.map +1 -0
  145. package/esri-compat/feature-set.js +80 -0
  146. package/esri-compat/feature-table.d.ts +141 -0
  147. package/esri-compat/feature-table.d.ts.map +1 -0
  148. package/esri-compat/feature-table.js +500 -0
  149. package/esri-compat/feature-templates.d.ts +41 -0
  150. package/esri-compat/feature-templates.d.ts.map +1 -0
  151. package/esri-compat/feature-templates.js +97 -0
  152. package/esri-compat/feature.d.ts +33 -0
  153. package/esri-compat/feature.d.ts.map +1 -0
  154. package/esri-compat/feature.js +83 -0
  155. package/esri-compat/graphic.d.ts +46 -0
  156. package/esri-compat/graphic.d.ts.map +1 -0
  157. package/esri-compat/graphic.js +103 -0
  158. package/esri-compat/graphics-layer.d.ts +49 -0
  159. package/esri-compat/graphics-layer.d.ts.map +1 -0
  160. package/esri-compat/graphics-layer.js +185 -0
  161. package/esri-compat/group-layer.d.ts +48 -0
  162. package/esri-compat/group-layer.d.ts.map +1 -0
  163. package/esri-compat/group-layer.js +212 -0
  164. package/esri-compat/identify.d.ts +71 -0
  165. package/esri-compat/identify.d.ts.map +1 -0
  166. package/esri-compat/identify.js +299 -0
  167. package/esri-compat/identity-manager.d.ts +31 -0
  168. package/esri-compat/identity-manager.d.ts.map +1 -0
  169. package/esri-compat/identity-manager.js +115 -0
  170. package/esri-compat/label-class.d.ts +31 -0
  171. package/esri-compat/label-class.d.ts.map +1 -0
  172. package/esri-compat/label-class.js +102 -0
  173. package/esri-compat/layer-list.d.ts +77 -0
  174. package/esri-compat/layer-list.d.ts.map +1 -0
  175. package/esri-compat/layer-list.js +342 -0
  176. package/esri-compat/legend.d.ts +53 -0
  177. package/esri-compat/legend.d.ts.map +1 -0
  178. package/esri-compat/legend.js +254 -0
  179. package/esri-compat/map-image-layer.d.ts +162 -0
  180. package/esri-compat/map-image-layer.d.ts.map +1 -0
  181. package/esri-compat/map-image-layer.js +704 -0
  182. package/esri-compat/map-view.d.ts +315 -0
  183. package/esri-compat/map-view.d.ts.map +1 -0
  184. package/esri-compat/map-view.js +1110 -0
  185. package/esri-compat/map.d.ts +47 -0
  186. package/esri-compat/map.d.ts.map +1 -0
  187. package/esri-compat/map.js +209 -0
  188. package/esri-compat/measurement-2d.d.ts +61 -0
  189. package/esri-compat/measurement-2d.d.ts.map +1 -0
  190. package/esri-compat/measurement-2d.js +184 -0
  191. package/esri-compat/measurement.d.ts +45 -0
  192. package/esri-compat/measurement.d.ts.map +1 -0
  193. package/esri-compat/measurement.js +193 -0
  194. package/esri-compat/oauth-info.d.ts +35 -0
  195. package/esri-compat/oauth-info.d.ts.map +1 -0
  196. package/esri-compat/oauth-info.js +115 -0
  197. package/esri-compat/picture-marker-symbol.d.ts +35 -0
  198. package/esri-compat/picture-marker-symbol.d.ts.map +1 -0
  199. package/esri-compat/picture-marker-symbol.js +126 -0
  200. package/esri-compat/point.d.ts +31 -0
  201. package/esri-compat/point.d.ts.map +1 -0
  202. package/esri-compat/point.js +102 -0
  203. package/esri-compat/polygon.d.ts +31 -0
  204. package/esri-compat/polygon.d.ts.map +1 -0
  205. package/esri-compat/polygon.js +107 -0
  206. package/esri-compat/polyline.d.ts +31 -0
  207. package/esri-compat/polyline.d.ts.map +1 -0
  208. package/esri-compat/polyline.js +107 -0
  209. package/esri-compat/popup-template.d.ts +55 -0
  210. package/esri-compat/popup-template.d.ts.map +1 -0
  211. package/esri-compat/popup-template.js +128 -0
  212. package/esri-compat/popup.d.ts +54 -0
  213. package/esri-compat/popup.d.ts.map +1 -0
  214. package/esri-compat/popup.js +312 -0
  215. package/esri-compat/print.d.ts +47 -0
  216. package/esri-compat/print.d.ts.map +1 -0
  217. package/esri-compat/print.js +105 -0
  218. package/esri-compat/query.d.ts +46 -0
  219. package/esri-compat/query.d.ts.map +1 -0
  220. package/esri-compat/query.js +119 -0
  221. package/esri-compat/reactive-utils.d.ts +23 -0
  222. package/esri-compat/reactive-utils.d.ts.map +1 -0
  223. package/esri-compat/reactive-utils.js +178 -0
  224. package/esri-compat/request.d.ts +41 -0
  225. package/esri-compat/request.d.ts.map +1 -0
  226. package/esri-compat/request.js +253 -0
  227. package/esri-compat/route-layer.d.ts +59 -0
  228. package/esri-compat/route-layer.d.ts.map +1 -0
  229. package/esri-compat/route-layer.js +223 -0
  230. package/esri-compat/route-task.d.ts +88 -0
  231. package/esri-compat/route-task.d.ts.map +1 -0
  232. package/esri-compat/route-task.js +225 -0
  233. package/esri-compat/scene-view.d.ts +41 -0
  234. package/esri-compat/scene-view.d.ts.map +1 -0
  235. package/esri-compat/scene-view.js +68 -0
  236. package/esri-compat/search.d.ts +112 -0
  237. package/esri-compat/search.d.ts.map +1 -0
  238. package/esri-compat/search.js +820 -0
  239. package/esri-compat/simple-fill-symbol.d.ts +27 -0
  240. package/esri-compat/simple-fill-symbol.d.ts.map +1 -0
  241. package/esri-compat/simple-fill-symbol.js +85 -0
  242. package/esri-compat/simple-line-symbol.d.ts +27 -0
  243. package/esri-compat/simple-line-symbol.d.ts.map +1 -0
  244. package/esri-compat/simple-line-symbol.js +85 -0
  245. package/esri-compat/simple-marker-symbol.d.ts +29 -0
  246. package/esri-compat/simple-marker-symbol.d.ts.map +1 -0
  247. package/esri-compat/simple-marker-symbol.js +92 -0
  248. package/esri-compat/simple-renderer.d.ts +29 -0
  249. package/esri-compat/simple-renderer.d.ts.map +1 -0
  250. package/esri-compat/simple-renderer.js +92 -0
  251. package/esri-compat/sketch.d.ts +64 -0
  252. package/esri-compat/sketch.d.ts.map +1 -0
  253. package/esri-compat/sketch.js +227 -0
  254. package/esri-compat/spatial-reference.d.ts +31 -0
  255. package/esri-compat/spatial-reference.d.ts.map +1 -0
  256. package/esri-compat/spatial-reference.js +102 -0
  257. package/esri-compat/swipe.d.ts +34 -0
  258. package/esri-compat/swipe.d.ts.map +1 -0
  259. package/esri-compat/swipe.js +93 -0
  260. package/esri-compat/table-list.d.ts +36 -0
  261. package/esri-compat/table-list.d.ts.map +1 -0
  262. package/esri-compat/table-list.js +126 -0
  263. package/esri-compat/text-symbol.d.ts +37 -0
  264. package/esri-compat/text-symbol.d.ts.map +1 -0
  265. package/esri-compat/text-symbol.js +123 -0
  266. package/esri-compat/tile-layer.d.ts +52 -0
  267. package/esri-compat/tile-layer.d.ts.map +1 -0
  268. package/esri-compat/tile-layer.js +167 -0
  269. package/esri-compat/time-slider.d.ts +70 -0
  270. package/esri-compat/time-slider.d.ts.map +1 -0
  271. package/esri-compat/time-slider.js +208 -0
  272. package/esri-compat/track.d.ts +51 -0
  273. package/esri-compat/track.d.ts.map +1 -0
  274. package/esri-compat/track.js +174 -0
  275. package/esri-compat/unique-value-renderer.d.ts +41 -0
  276. package/esri-compat/unique-value-renderer.d.ts.map +1 -0
  277. package/esri-compat/unique-value-renderer.js +127 -0
  278. package/esri-compat/url.d.ts +12 -0
  279. package/esri-compat/url.d.ts.map +1 -0
  280. package/esri-compat/url.js +54 -0
  281. package/esri-compat/web-map.d.ts +14 -0
  282. package/esri-compat/web-map.d.ts.map +1 -0
  283. package/esri-compat/web-map.js +24 -0
  284. package/gen/honua/v1/feature_service_pb.d.ts +918 -0
  285. package/gen/honua/v1/feature_service_pb.d.ts.map +1 -0
  286. package/gen/honua/v1/feature_service_pb.js +375 -0
  287. package/index.d.ts +130 -0
  288. package/index.js +65 -0
  289. package/package.json +22 -0
@@ -0,0 +1,227 @@
1
+ import { CompatEventBus, resolveCompatEventBus, safeInvokeCompatListener } from "./event-bus.js";
2
+ export class SketchCompat {
3
+ view;
4
+ layer;
5
+ container;
6
+ eventBus;
7
+ updateOnGraphicClick;
8
+ creationMode;
9
+ defaultCreateOptions;
10
+ defaultUpdateOptions;
11
+ loaded;
12
+ loadStatus;
13
+ state;
14
+ activeTool;
15
+ activeCreateOptions;
16
+ activeUpdateGraphics;
17
+ activeUpdateOptions;
18
+ watchListeners;
19
+ constructor(options = {}) {
20
+ this.view = options.view;
21
+ this.layer = options.layer;
22
+ this.container = options.container;
23
+ this.eventBus = options.eventBus ?? resolveCompatEventBus(options.view, options.layer) ?? new CompatEventBus();
24
+ this.updateOnGraphicClick = options.updateOnGraphicClick ?? true;
25
+ this.creationMode = options.creationMode ?? "single";
26
+ this.defaultCreateOptions = { ...(options.defaultCreateOptions ?? {}) };
27
+ this.defaultUpdateOptions = { ...(options.defaultUpdateOptions ?? {}) };
28
+ this.loaded = false;
29
+ this.loadStatus = "not-loaded";
30
+ this.state = "ready";
31
+ this.activeTool = undefined;
32
+ this.activeCreateOptions = undefined;
33
+ this.activeUpdateGraphics = [];
34
+ this.activeUpdateOptions = undefined;
35
+ this.watchListeners = new Map();
36
+ }
37
+ async load() {
38
+ if (this.loaded) {
39
+ return this;
40
+ }
41
+ this.loadStatus = "loading";
42
+ this.notifyWatchers("loadStatus", this.loadStatus);
43
+ this.eventBus.emit("sketch.loading", undefined, this);
44
+ this.loaded = true;
45
+ this.notifyWatchers("loaded", this.loaded);
46
+ this.loadStatus = "loaded";
47
+ this.notifyWatchers("loadStatus", this.loadStatus);
48
+ this.eventBus.emit("sketch.loaded", undefined, this);
49
+ return this;
50
+ }
51
+ async when(callback) {
52
+ const widget = await this.load();
53
+ if (callback) {
54
+ callback(widget);
55
+ }
56
+ return widget;
57
+ }
58
+ watch(propertyName, listener) {
59
+ let listeners = this.watchListeners.get(propertyName);
60
+ if (!listeners) {
61
+ listeners = new Set();
62
+ this.watchListeners.set(propertyName, listeners);
63
+ }
64
+ listeners.add(listener);
65
+ return {
66
+ remove: () => {
67
+ listeners?.delete(listener);
68
+ },
69
+ };
70
+ }
71
+ create(tool, options) {
72
+ this.state = "active";
73
+ this.notifyWatchers("state", this.state);
74
+ this.activeTool = tool;
75
+ this.notifyWatchers("activeTool", this.activeTool);
76
+ this.activeCreateOptions = {
77
+ ...this.defaultCreateOptions,
78
+ ...(options ?? {}),
79
+ };
80
+ this.notifyWatchers("activeCreateOptions", this.activeCreateOptions);
81
+ this.eventBus.emit("sketch.create-started", {
82
+ tool,
83
+ creationMode: this.creationMode,
84
+ options: this.activeCreateOptions,
85
+ }, this);
86
+ }
87
+ complete(graphic) {
88
+ if (this.state !== "active" || !this.activeTool) {
89
+ return undefined;
90
+ }
91
+ const tool = this.activeTool;
92
+ const createdGraphic = graphic ?? {};
93
+ appendGraphic(this.layer, createdGraphic);
94
+ this.clearActiveState();
95
+ this.eventBus.emit("sketch.create-completed", {
96
+ tool,
97
+ graphic: createdGraphic,
98
+ layerGraphicCount: getLayerGraphics(this.layer).length,
99
+ }, this);
100
+ return {
101
+ state: "complete",
102
+ tool,
103
+ graphic: createdGraphic,
104
+ };
105
+ }
106
+ cancel() {
107
+ if (this.state !== "active" || !this.activeTool) {
108
+ return undefined;
109
+ }
110
+ const tool = this.activeTool;
111
+ this.clearActiveState();
112
+ this.eventBus.emit("sketch.create-cancelled", { tool }, this);
113
+ return {
114
+ state: "cancel",
115
+ tool,
116
+ };
117
+ }
118
+ update(graphics, options) {
119
+ const normalizedGraphics = normalizeGraphicsInput(graphics);
120
+ this.activeUpdateGraphics = [...normalizedGraphics];
121
+ this.notifyWatchers("activeUpdateGraphics", this.activeUpdateGraphics);
122
+ this.activeUpdateOptions = {
123
+ ...this.defaultUpdateOptions,
124
+ ...(options ?? {}),
125
+ };
126
+ this.notifyWatchers("activeUpdateOptions", this.activeUpdateOptions);
127
+ this.eventBus.emit("sketch.update-started", {
128
+ count: normalizedGraphics.length,
129
+ options: this.activeUpdateOptions,
130
+ }, this);
131
+ return this.activeUpdateGraphics;
132
+ }
133
+ delete(graphics) {
134
+ const targets = graphics !== undefined ? normalizeGraphicsInput(graphics) : [...this.activeUpdateGraphics];
135
+ let removed = 0;
136
+ for (const target of targets) {
137
+ if (removeGraphic(this.layer, target)) {
138
+ removed += 1;
139
+ }
140
+ }
141
+ if (removed > 0) {
142
+ this.eventBus.emit("sketch.graphics-deleted", {
143
+ count: removed,
144
+ layerGraphicCount: getLayerGraphics(this.layer).length,
145
+ }, this);
146
+ }
147
+ if (this.activeUpdateGraphics.length > 0) {
148
+ this.activeUpdateGraphics = this.activeUpdateGraphics.filter((graphic) => !targets.some((target) => target === graphic));
149
+ this.notifyWatchers("activeUpdateGraphics", this.activeUpdateGraphics);
150
+ }
151
+ return removed;
152
+ }
153
+ reset() {
154
+ this.clearActiveState();
155
+ this.activeUpdateGraphics = [];
156
+ this.notifyWatchers("activeUpdateGraphics", this.activeUpdateGraphics);
157
+ this.activeUpdateOptions = undefined;
158
+ this.notifyWatchers("activeUpdateOptions", this.activeUpdateOptions);
159
+ this.eventBus.emit("sketch.reset", undefined, this);
160
+ }
161
+ clearActiveState() {
162
+ this.state = "ready";
163
+ this.notifyWatchers("state", this.state);
164
+ this.activeTool = undefined;
165
+ this.notifyWatchers("activeTool", this.activeTool);
166
+ this.activeCreateOptions = undefined;
167
+ this.notifyWatchers("activeCreateOptions", this.activeCreateOptions);
168
+ }
169
+ destroy() {
170
+ this.watchListeners.clear();
171
+ }
172
+ notifyWatchers(propertyName, value) {
173
+ const listeners = this.watchListeners.get(propertyName);
174
+ if (!listeners) {
175
+ return;
176
+ }
177
+ for (const listener of listeners) {
178
+ safeInvokeCompatListener(listener, value);
179
+ }
180
+ }
181
+ }
182
+ function normalizeGraphicsInput(graphics) {
183
+ return Array.isArray(graphics) ? [...graphics] : [graphics];
184
+ }
185
+ function appendGraphic(layer, graphic) {
186
+ if (!isGraphicsLayerLike(layer)) {
187
+ return;
188
+ }
189
+ if (typeof layer.add === "function") {
190
+ layer.add(graphic);
191
+ return;
192
+ }
193
+ if (Array.isArray(layer.graphics)) {
194
+ layer.graphics.push(graphic);
195
+ }
196
+ }
197
+ function removeGraphic(layer, graphic) {
198
+ if (!isGraphicsLayerLike(layer)) {
199
+ return false;
200
+ }
201
+ if (typeof layer.remove === "function") {
202
+ const beforeCount = getLayerGraphics(layer).length;
203
+ const result = layer.remove(graphic);
204
+ if (result !== undefined) {
205
+ return true;
206
+ }
207
+ return getLayerGraphics(layer).length < beforeCount;
208
+ }
209
+ if (!Array.isArray(layer.graphics)) {
210
+ return false;
211
+ }
212
+ const index = layer.graphics.findIndex((candidate) => candidate === graphic);
213
+ if (index < 0) {
214
+ return false;
215
+ }
216
+ layer.graphics.splice(index, 1);
217
+ return true;
218
+ }
219
+ function getLayerGraphics(layer) {
220
+ if (!isGraphicsLayerLike(layer) || !Array.isArray(layer.graphics)) {
221
+ return [];
222
+ }
223
+ return layer.graphics;
224
+ }
225
+ function isGraphicsLayerLike(value) {
226
+ return typeof value === "object" && value !== null;
227
+ }
@@ -0,0 +1,31 @@
1
+ export interface SpatialReferenceCompatOptions {
2
+ wkid?: number;
3
+ latestWkid?: number;
4
+ wkt?: string;
5
+ vcsWkid?: number;
6
+ latestVcsWkid?: number;
7
+ }
8
+ export type SpatialReferenceLoadStatusCompat = "not-loaded" | "loading" | "loaded";
9
+ export interface SpatialReferenceHandleCompat {
10
+ remove(): void;
11
+ }
12
+ export declare class SpatialReferenceCompat {
13
+ loaded: boolean;
14
+ loadStatus: SpatialReferenceLoadStatusCompat;
15
+ wkid: number | undefined;
16
+ latestWkid: number | undefined;
17
+ wkt: string | undefined;
18
+ vcsWkid: number | undefined;
19
+ latestVcsWkid: number | undefined;
20
+ private readonly watchListeners;
21
+ constructor(options?: SpatialReferenceCompatOptions);
22
+ load(): Promise<SpatialReferenceCompat>;
23
+ when(callback?: (spatialReference: SpatialReferenceCompat) => void): Promise<SpatialReferenceCompat>;
24
+ watch(propertyName: string, listener: (value: unknown) => void): SpatialReferenceHandleCompat;
25
+ update(options: SpatialReferenceCompatOptions): void;
26
+ clone(): SpatialReferenceCompat;
27
+ toJSON(): SpatialReferenceCompatOptions;
28
+ destroy(): void;
29
+ private notifyWatchers;
30
+ }
31
+ //# sourceMappingURL=spatial-reference.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spatial-reference.d.ts","sourceRoot":"","sources":["../../../src/esri-compat/spatial-reference.ts"],"names":[],"mappings":"AACA,MAAM,WAAW,6BAA6B;IAC5C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,MAAM,gCAAgC,GAAG,YAAY,GAAG,SAAS,GAAG,QAAQ,CAAC;AAEnF,MAAM,WAAW,4BAA4B;IAC3C,MAAM,IAAI,IAAI,CAAC;CAChB;AAED,qBAAa,sBAAsB;IAC1B,MAAM,EAAE,OAAO,CAAC;IAChB,UAAU,EAAE,gCAAgC,CAAC;IAC7C,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;IACzC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAA6C;gBAEzD,OAAO,GAAE,6BAAkC;IAWjD,IAAI,IAAI,OAAO,CAAC,sBAAsB,CAAC;IAcvC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,gBAAgB,EAAE,sBAAsB,KAAK,IAAI,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAQ1G,KAAK,CAAC,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,GAAG,4BAA4B;IAe7F,MAAM,CAAC,OAAO,EAAE,6BAA6B,GAAG,IAAI;IAuBpD,KAAK,IAAI,sBAAsB;IAI/B,MAAM,IAAI,6BAA6B;IAUvC,OAAO,IAAI,IAAI;IAItB,OAAO,CAAC,cAAc;CAUvB"}
@@ -0,0 +1,102 @@
1
+ import { safeInvokeCompatListener } from "./event-bus.js";
2
+ export class SpatialReferenceCompat {
3
+ loaded;
4
+ loadStatus;
5
+ wkid;
6
+ latestWkid;
7
+ wkt;
8
+ vcsWkid;
9
+ latestVcsWkid;
10
+ watchListeners;
11
+ constructor(options = {}) {
12
+ this.loaded = false;
13
+ this.loadStatus = "not-loaded";
14
+ this.wkid = finiteNumberOrUndefined(options.wkid);
15
+ this.latestWkid = finiteNumberOrUndefined(options.latestWkid);
16
+ this.wkt = options.wkt;
17
+ this.vcsWkid = finiteNumberOrUndefined(options.vcsWkid);
18
+ this.latestVcsWkid = finiteNumberOrUndefined(options.latestVcsWkid);
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 spatialReference = await this.load();
35
+ if (callback) {
36
+ callback(spatialReference);
37
+ }
38
+ return spatialReference;
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
+ update(options) {
54
+ if (options.wkid !== undefined) {
55
+ this.wkid = finiteNumberOrUndefined(options.wkid);
56
+ this.notifyWatchers("wkid", this.wkid);
57
+ }
58
+ if (options.latestWkid !== undefined) {
59
+ this.latestWkid = finiteNumberOrUndefined(options.latestWkid);
60
+ this.notifyWatchers("latestWkid", this.latestWkid);
61
+ }
62
+ if (options.wkt !== undefined) {
63
+ this.wkt = options.wkt;
64
+ this.notifyWatchers("wkt", this.wkt);
65
+ }
66
+ if (options.vcsWkid !== undefined) {
67
+ this.vcsWkid = finiteNumberOrUndefined(options.vcsWkid);
68
+ this.notifyWatchers("vcsWkid", this.vcsWkid);
69
+ }
70
+ if (options.latestVcsWkid !== undefined) {
71
+ this.latestVcsWkid = finiteNumberOrUndefined(options.latestVcsWkid);
72
+ this.notifyWatchers("latestVcsWkid", this.latestVcsWkid);
73
+ }
74
+ }
75
+ clone() {
76
+ return new SpatialReferenceCompat(this.toJSON());
77
+ }
78
+ toJSON() {
79
+ return {
80
+ wkid: this.wkid,
81
+ latestWkid: this.latestWkid,
82
+ wkt: this.wkt,
83
+ vcsWkid: this.vcsWkid,
84
+ latestVcsWkid: this.latestVcsWkid,
85
+ };
86
+ }
87
+ destroy() {
88
+ this.watchListeners.clear();
89
+ }
90
+ notifyWatchers(propertyName, value) {
91
+ const listeners = this.watchListeners.get(propertyName);
92
+ if (!listeners) {
93
+ return;
94
+ }
95
+ for (const listener of listeners) {
96
+ safeInvokeCompatListener(listener, value);
97
+ }
98
+ }
99
+ }
100
+ function finiteNumberOrUndefined(value) {
101
+ return typeof value === "number" && Number.isFinite(value) ? value : undefined;
102
+ }
@@ -0,0 +1,34 @@
1
+ import { CompatEventBus } from "./event-bus.js";
2
+ export interface SwipeCompatOptions {
3
+ view?: unknown;
4
+ container?: unknown;
5
+ leadingLayers?: readonly unknown[];
6
+ trailingLayers?: readonly unknown[];
7
+ position?: number;
8
+ eventBus?: CompatEventBus;
9
+ }
10
+ export type SwipeLoadStatusCompat = "not-loaded" | "loading" | "loaded";
11
+ export interface SwipeHandleCompat {
12
+ remove(): void;
13
+ }
14
+ export declare class SwipeCompat {
15
+ readonly view: unknown;
16
+ readonly container: unknown;
17
+ readonly eventBus: CompatEventBus;
18
+ loaded: boolean;
19
+ loadStatus: SwipeLoadStatusCompat;
20
+ leadingLayers: unknown[];
21
+ trailingLayers: unknown[];
22
+ position: number;
23
+ private readonly watchListeners;
24
+ constructor(options?: SwipeCompatOptions);
25
+ load(): Promise<SwipeCompat>;
26
+ when(callback?: (widget: SwipeCompat) => void): Promise<SwipeCompat>;
27
+ watch(propertyName: string, listener: (value: unknown) => void): SwipeHandleCompat;
28
+ setPosition(position: number): void;
29
+ setLeadingLayers(layers: readonly unknown[]): void;
30
+ setTrailingLayers(layers: readonly unknown[]): void;
31
+ destroy(): void;
32
+ private notifyWatchers;
33
+ }
34
+ //# sourceMappingURL=swipe.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"swipe.d.ts","sourceRoot":"","sources":["../../../src/esri-compat/swipe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAmD,MAAM,gBAAgB,CAAC;AAEjG,MAAM,WAAW,kBAAkB;IACjC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,aAAa,CAAC,EAAE,SAAS,OAAO,EAAE,CAAC;IACnC,cAAc,CAAC,EAAE,SAAS,OAAO,EAAE,CAAC;IACpC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,cAAc,CAAC;CAC3B;AAED,MAAM,MAAM,qBAAqB,GAAG,YAAY,GAAG,SAAS,GAAG,QAAQ,CAAC;AAExE,MAAM,WAAW,iBAAiB;IAChC,MAAM,IAAI,IAAI,CAAC;CAChB;AAED,qBAAa,WAAW;IACtB,SAAgB,IAAI,EAAE,OAAO,CAAC;IAC9B,SAAgB,SAAS,EAAE,OAAO,CAAC;IACnC,SAAgB,QAAQ,EAAE,cAAc,CAAC;IAClC,MAAM,EAAE,OAAO,CAAC;IAChB,UAAU,EAAE,qBAAqB,CAAC;IAClC,aAAa,EAAE,OAAO,EAAE,CAAC;IACzB,cAAc,EAAE,OAAO,EAAE,CAAC;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACxB,OAAO,CAAC,QAAQ,CAAC,cAAc,CAA6C;gBAEzD,OAAO,GAAE,kBAAuB;IAetC,IAAI,IAAI,OAAO,CAAC,WAAW,CAAC;IAgB5B,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,GAAG,OAAO,CAAC,WAAW,CAAC;IAQ1E,KAAK,CAAC,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,GAAG,iBAAiB;IAelF,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAMnC,gBAAgB,CAAC,MAAM,EAAE,SAAS,OAAO,EAAE,GAAG,IAAI;IAMlD,iBAAiB,CAAC,MAAM,EAAE,SAAS,OAAO,EAAE,GAAG,IAAI;IAMnD,OAAO,IAAI,IAAI;IAItB,OAAO,CAAC,cAAc;CAUvB"}
@@ -0,0 +1,93 @@
1
+ import { CompatEventBus, resolveCompatEventBus, safeInvokeCompatListener } from "./event-bus.js";
2
+ export class SwipeCompat {
3
+ view;
4
+ container;
5
+ eventBus;
6
+ loaded;
7
+ loadStatus;
8
+ leadingLayers;
9
+ trailingLayers;
10
+ position;
11
+ watchListeners;
12
+ constructor(options = {}) {
13
+ this.view = options.view;
14
+ this.container = options.container;
15
+ this.eventBus =
16
+ options.eventBus ??
17
+ resolveCompatEventBus(options.view, options.leadingLayers, options.trailingLayers) ??
18
+ new CompatEventBus();
19
+ this.loaded = false;
20
+ this.loadStatus = "not-loaded";
21
+ this.leadingLayers = options.leadingLayers ? [...options.leadingLayers] : [];
22
+ this.trailingLayers = options.trailingLayers ? [...options.trailingLayers] : [];
23
+ this.position = normalizePosition(options.position ?? 50);
24
+ this.watchListeners = new Map();
25
+ }
26
+ async load() {
27
+ if (this.loaded) {
28
+ return this;
29
+ }
30
+ this.loadStatus = "loading";
31
+ this.notifyWatchers("loadStatus", this.loadStatus);
32
+ this.eventBus.emit("swipe.loading", undefined, this);
33
+ this.loaded = true;
34
+ this.notifyWatchers("loaded", this.loaded);
35
+ this.loadStatus = "loaded";
36
+ this.notifyWatchers("loadStatus", this.loadStatus);
37
+ this.eventBus.emit("swipe.loaded", undefined, this);
38
+ return this;
39
+ }
40
+ async when(callback) {
41
+ const widget = await this.load();
42
+ if (callback) {
43
+ callback(widget);
44
+ }
45
+ return widget;
46
+ }
47
+ watch(propertyName, listener) {
48
+ let listeners = this.watchListeners.get(propertyName);
49
+ if (!listeners) {
50
+ listeners = new Set();
51
+ this.watchListeners.set(propertyName, listeners);
52
+ }
53
+ listeners.add(listener);
54
+ return {
55
+ remove: () => {
56
+ listeners?.delete(listener);
57
+ },
58
+ };
59
+ }
60
+ setPosition(position) {
61
+ this.position = normalizePosition(position);
62
+ this.notifyWatchers("position", this.position);
63
+ this.eventBus.emit("swipe.position-changed", { position: this.position }, this);
64
+ }
65
+ setLeadingLayers(layers) {
66
+ this.leadingLayers = [...layers];
67
+ this.notifyWatchers("leadingLayers", this.leadingLayers);
68
+ this.eventBus.emit("swipe.layers-changed", { side: "leading", count: this.leadingLayers.length }, this);
69
+ }
70
+ setTrailingLayers(layers) {
71
+ this.trailingLayers = [...layers];
72
+ this.notifyWatchers("trailingLayers", this.trailingLayers);
73
+ this.eventBus.emit("swipe.layers-changed", { side: "trailing", count: this.trailingLayers.length }, this);
74
+ }
75
+ destroy() {
76
+ this.watchListeners.clear();
77
+ }
78
+ notifyWatchers(propertyName, value) {
79
+ const listeners = this.watchListeners.get(propertyName);
80
+ if (!listeners) {
81
+ return;
82
+ }
83
+ for (const listener of listeners) {
84
+ safeInvokeCompatListener(listener, value);
85
+ }
86
+ }
87
+ }
88
+ function normalizePosition(value) {
89
+ if (!Number.isFinite(value)) {
90
+ return 50;
91
+ }
92
+ return Math.min(100, Math.max(0, Math.trunc(value)));
93
+ }
@@ -0,0 +1,36 @@
1
+ import { CompatEventBus } from "./event-bus.js";
2
+ export interface TableListCompatOptions {
3
+ view?: unknown;
4
+ map?: unknown;
5
+ container?: unknown;
6
+ tables?: readonly unknown[];
7
+ eventBus?: CompatEventBus;
8
+ autoRefresh?: boolean;
9
+ }
10
+ export type TableListLoadStatusCompat = "not-loaded" | "loading" | "loaded";
11
+ export interface TableListHandleCompat {
12
+ remove(): void;
13
+ }
14
+ export declare class TableListCompat {
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: TableListLoadStatusCompat;
22
+ tables: unknown[];
23
+ private readonly subscriptions;
24
+ private readonly watchListeners;
25
+ private explicitTables;
26
+ constructor(options?: TableListCompatOptions);
27
+ load(): Promise<TableListCompat>;
28
+ when(callback?: (widget: TableListCompat) => void): Promise<TableListCompat>;
29
+ watch(propertyName: string, listener: (value: unknown) => void): TableListHandleCompat;
30
+ setTables(tables: readonly unknown[]): void;
31
+ useMapTables(): readonly unknown[];
32
+ refresh(): readonly unknown[];
33
+ destroy(): void;
34
+ private notifyWatchers;
35
+ }
36
+ //# sourceMappingURL=table-list.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"table-list.d.ts","sourceRoot":"","sources":["../../../src/esri-compat/table-list.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EAIf,MAAM,gBAAgB,CAAC;AAExB,MAAM,WAAW,sBAAsB;IACrC,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,yBAAyB,GAAG,YAAY,GAAG,SAAS,GAAG,QAAQ,CAAC;AAE5E,MAAM,WAAW,qBAAqB;IACpC,MAAM,IAAI,IAAI,CAAC;CAChB;AAED,qBAAa,eAAe;IAC1B,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,yBAAyB,CAAC;IACtC,MAAM,EAAE,OAAO,EAAE,CAAC;IAEzB,OAAO,CAAC,QAAQ,CAAC,aAAa,CAA4B;IAC1D,OAAO,CAAC,QAAQ,CAAC,cAAc,CAA6C;IAC5E,OAAO,CAAC,cAAc,CAAwB;gBAE3B,OAAO,GAAE,sBAA2B;IAwB1C,IAAI,IAAI,OAAO,CAAC,eAAe,CAAC;IAiBhC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,eAAe,KAAK,IAAI,GAAG,OAAO,CAAC,eAAe,CAAC;IAQlF,KAAK,CAAC,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,GAAG,qBAAqB;IAetF,SAAS,CAAC,MAAM,EAAE,SAAS,OAAO,EAAE,GAAG,IAAI;IAO3C,YAAY,IAAI,SAAS,OAAO,EAAE;IAKlC,OAAO,IAAI,SAAS,OAAO,EAAE;IAY7B,OAAO,IAAI,IAAI;IAOtB,OAAO,CAAC,cAAc;CAUvB"}
@@ -0,0 +1,126 @@
1
+ import { CompatEventBus, resolveCompatEventBus, safeInvokeCompatListener, } from "./event-bus.js";
2
+ export class TableListCompat {
3
+ view;
4
+ map;
5
+ container;
6
+ eventBus;
7
+ autoRefresh;
8
+ loaded;
9
+ loadStatus;
10
+ tables;
11
+ subscriptions;
12
+ watchListeners;
13
+ explicitTables;
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, options.map) ?? new CompatEventBus();
19
+ this.autoRefresh = options.autoRefresh ?? true;
20
+ this.loaded = false;
21
+ this.loadStatus = "not-loaded";
22
+ this.explicitTables = options.tables ? [...options.tables] : undefined;
23
+ this.tables = this.explicitTables ? [...this.explicitTables] : extractTablesFromMap(this.map);
24
+ this.subscriptions = [];
25
+ this.watchListeners = new Map();
26
+ if (this.autoRefresh) {
27
+ this.subscriptions.push(this.eventBus.on("map.tables-changed", () => {
28
+ if (this.explicitTables === undefined) {
29
+ this.refresh();
30
+ }
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("table-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("table-list.loaded", { count: this.tables.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
+ setTables(tables) {
70
+ this.explicitTables = [...tables];
71
+ this.tables = [...this.explicitTables];
72
+ this.notifyWatchers("tables", this.tables);
73
+ this.eventBus.emit("table-list.tables-changed", { count: this.tables.length }, this);
74
+ }
75
+ useMapTables() {
76
+ this.explicitTables = undefined;
77
+ return this.refresh();
78
+ }
79
+ refresh() {
80
+ if (this.explicitTables) {
81
+ this.tables = [...this.explicitTables];
82
+ }
83
+ else {
84
+ this.tables = extractTablesFromMap(this.map);
85
+ }
86
+ this.notifyWatchers("tables", this.tables);
87
+ this.eventBus.emit("table-list.refreshed", { count: this.tables.length }, this);
88
+ return this.tables;
89
+ }
90
+ destroy() {
91
+ for (const subscription of this.subscriptions.splice(0)) {
92
+ subscription.remove();
93
+ }
94
+ this.watchListeners.clear();
95
+ }
96
+ notifyWatchers(propertyName, value) {
97
+ const listeners = this.watchListeners.get(propertyName);
98
+ if (!listeners) {
99
+ return;
100
+ }
101
+ for (const listener of listeners) {
102
+ safeInvokeCompatListener(listener, value);
103
+ }
104
+ }
105
+ }
106
+ function extractViewMap(view) {
107
+ if (!isRecord(view)) {
108
+ return undefined;
109
+ }
110
+ return view.map;
111
+ }
112
+ function extractTablesFromMap(map) {
113
+ if (!isRecord(map)) {
114
+ return [];
115
+ }
116
+ if (Array.isArray(map.allTables)) {
117
+ return [...map.allTables];
118
+ }
119
+ if (Array.isArray(map.tables)) {
120
+ return [...map.tables];
121
+ }
122
+ return [];
123
+ }
124
+ function isRecord(value) {
125
+ return typeof value === "object" && value !== null;
126
+ }