ogm-viewer 0.5.0 → 0.6.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 (114) hide show
  1. package/dist/cjs/{lerc-Df0hDWkS.js → lerc-XQuzL9p2.js} +1 -1
  2. package/dist/cjs/loader.cjs.js +1 -1
  3. package/dist/cjs/{ogm-alerts.ogm-attributes.ogm-image.ogm-map.ogm-menubar.ogm-metadata.ogm-preview.ogm-previews.ogm-settings.ogm-sidebar.ogm-viewer-DMEfXquS.js → ogm-alerts.ogm-attributes.ogm-image.ogm-map.ogm-menubar.ogm-metadata.ogm-preview.ogm-previews.ogm-settings.ogm-sidebar.ogm-viewer-B4jkHqvr.js} +11313 -10658
  4. package/dist/cjs/ogm-alerts_11.cjs.entry.js +1 -1
  5. package/dist/cjs/ogm-viewer.cjs.js +1 -1
  6. package/dist/collection/components/ogm-image/ogm-image.js +14 -14
  7. package/dist/collection/components/ogm-map/ogm-map.js +144 -52
  8. package/dist/collection/components/ogm-menubar/ogm-menubar.js +23 -2
  9. package/dist/collection/components/ogm-menubar/ogm-menubar.test.js +34 -0
  10. package/dist/collection/components/ogm-preview/ogm-preview.js +13 -13
  11. package/dist/collection/components/ogm-preview/ogm-preview.test.js +5 -5
  12. package/dist/collection/components/ogm-previews/ogm-previews.js +30 -28
  13. package/dist/collection/components/ogm-previews/ogm-previews.test.js +3 -3
  14. package/dist/collection/components/ogm-viewer/ogm-viewer.css +6 -2
  15. package/dist/collection/components/ogm-viewer/ogm-viewer.js +29 -18
  16. package/dist/collection/lib/geometry.js +35 -1
  17. package/dist/collection/lib/geometry.test.js +90 -1
  18. package/dist/collection/lib/previewers/cog-deck.js +4 -4
  19. package/dist/collection/lib/previewers/cog.js +11 -11
  20. package/dist/collection/lib/previewers/geojson.js +10 -7
  21. package/dist/collection/lib/previewers/map.js +51 -0
  22. package/dist/collection/lib/previewers/openindexmap.js +2 -2
  23. package/dist/collection/lib/previewers/pmtiles-raster.js +9 -9
  24. package/dist/collection/lib/previewers/pmtiles-vector.js +12 -51
  25. package/dist/collection/lib/previewers/previewer.js +4 -3
  26. package/dist/collection/lib/previewers/raster.js +15 -11
  27. package/dist/collection/lib/previewers/tiled-vector.js +47 -0
  28. package/dist/collection/lib/previewers/tilejson-raster.js +27 -0
  29. package/dist/collection/lib/previewers/tilejson-vector.js +18 -0
  30. package/dist/collection/lib/previewers/tilejson.test.js +140 -0
  31. package/dist/collection/lib/previewers/vector.js +7 -4
  32. package/dist/collection/lib/previewers/wms.js +86 -6
  33. package/dist/collection/lib/previewers/wms.test.js +133 -0
  34. package/dist/collection/lib/previewers/wmts.js +31 -0
  35. package/dist/collection/lib/previewers/wmts.test.js +108 -0
  36. package/dist/collection/lib/{sources → resources}/cog.js +2 -2
  37. package/dist/collection/lib/{sources → resources}/geojson.js +3 -3
  38. package/dist/collection/lib/{sources → resources}/iiif-manifest.js +2 -2
  39. package/dist/collection/lib/{sources → resources}/iiif-manifest.test.js +3 -3
  40. package/dist/collection/lib/{sources → resources}/iiif.js +2 -2
  41. package/dist/collection/lib/{sources/maplibre.js → resources/map.js} +2 -2
  42. package/dist/collection/lib/{sources → resources}/openindexmap.js +2 -2
  43. package/dist/collection/lib/{sources → resources}/pmtiles.js +2 -2
  44. package/dist/collection/lib/{sources → resources}/raster.js +2 -2
  45. package/dist/collection/lib/{sources/source.js → resources/resource.js} +3 -3
  46. package/dist/collection/lib/{sources → resources}/tilejson.js +21 -4
  47. package/dist/collection/lib/{sources → resources}/tms.js +2 -2
  48. package/dist/collection/lib/{sources → resources}/vector.js +2 -2
  49. package/dist/collection/lib/{sources → resources}/wms.js +46 -6
  50. package/dist/collection/lib/resources/wms.test.js +63 -0
  51. package/dist/collection/lib/resources/wmts.js +317 -0
  52. package/dist/collection/lib/resources/wmts.test.js +235 -0
  53. package/dist/collection/lib/{sources → resources}/xyz.js +2 -2
  54. package/dist/esm/{lerc-CB_Jcu33.js → lerc-BxCv6y50.js} +1 -1
  55. package/dist/esm/loader.js +1 -1
  56. package/dist/esm/{ogm-alerts.ogm-attributes.ogm-image.ogm-map.ogm-menubar.ogm-metadata.ogm-preview.ogm-previews.ogm-settings.ogm-sidebar.ogm-viewer-Dlc6USWB.js → ogm-alerts.ogm-attributes.ogm-image.ogm-map.ogm-menubar.ogm-metadata.ogm-preview.ogm-previews.ogm-settings.ogm-sidebar.ogm-viewer-DtEO48bS.js} +11313 -10658
  57. package/dist/esm/ogm-alerts_11.entry.js +1 -1
  58. package/dist/esm/ogm-viewer.js +1 -1
  59. package/dist/ogm-viewer/ogm-viewer.esm.js +1 -1
  60. package/dist/ogm-viewer/p-7EhN80oi.js +2822 -0
  61. package/dist/ogm-viewer/{p-DqRDI3AC.js → p-BO_nFj5K.js} +1 -1
  62. package/dist/ogm-viewer/{p-7936ccc9.entry.js → p-c9af56a3.entry.js} +1 -1
  63. package/dist/types/components/ogm-image/ogm-image.d.ts +2 -2
  64. package/dist/types/components/ogm-map/ogm-map.d.ts +13 -9
  65. package/dist/types/components/ogm-menubar/ogm-menubar.d.ts +2 -1
  66. package/dist/types/components/ogm-preview/ogm-preview.d.ts +2 -2
  67. package/dist/types/components/ogm-previews/ogm-previews.d.ts +2 -2
  68. package/dist/types/components/ogm-viewer/ogm-viewer.d.ts +1 -0
  69. package/dist/types/components.d.ts +24 -6
  70. package/dist/types/lib/geometry.d.ts +5 -1
  71. package/dist/types/lib/previewers/cog-deck.d.ts +3 -3
  72. package/dist/types/lib/previewers/cog.d.ts +6 -6
  73. package/dist/types/lib/previewers/geojson.d.ts +7 -4
  74. package/dist/types/lib/previewers/{maplibre.d.ts → map.d.ts} +10 -7
  75. package/dist/types/lib/previewers/openindexmap.d.ts +2 -2
  76. package/dist/types/lib/previewers/pmtiles-raster.d.ts +2 -3
  77. package/dist/types/lib/previewers/pmtiles-vector.d.ts +4 -11
  78. package/dist/types/lib/previewers/previewer.d.ts +3 -3
  79. package/dist/types/lib/previewers/raster.d.ts +10 -7
  80. package/dist/types/lib/previewers/tiled-vector.d.ts +11 -0
  81. package/dist/types/lib/previewers/tilejson-raster.d.ts +8 -0
  82. package/dist/types/lib/previewers/tilejson-vector.d.ts +6 -0
  83. package/dist/types/lib/previewers/vector.d.ts +9 -5
  84. package/dist/types/lib/previewers/wms.d.ts +17 -5
  85. package/dist/types/lib/previewers/wms.test.d.ts +1 -0
  86. package/dist/types/lib/previewers/wmts.d.ts +11 -0
  87. package/dist/types/lib/previewers/wmts.test.d.ts +1 -0
  88. package/dist/types/lib/{sources → resources}/cog.d.ts +2 -2
  89. package/dist/types/lib/{sources → resources}/geojson.d.ts +2 -2
  90. package/dist/types/lib/{sources → resources}/iiif-manifest.d.ts +2 -2
  91. package/dist/types/lib/resources/iiif-manifest.test.d.ts +1 -0
  92. package/dist/types/lib/resources/iiif.d.ts +5 -0
  93. package/dist/types/lib/{sources/maplibre.d.ts → resources/map.d.ts} +2 -2
  94. package/dist/types/lib/resources/openindexmap.d.ts +5 -0
  95. package/dist/types/lib/{sources → resources}/pmtiles.d.ts +2 -2
  96. package/dist/types/lib/{sources → resources}/raster.d.ts +2 -2
  97. package/dist/types/lib/{sources/source.d.ts → resources/resource.d.ts} +1 -1
  98. package/dist/types/lib/{sources → resources}/tilejson.d.ts +5 -2
  99. package/dist/types/lib/resources/tms.d.ts +5 -0
  100. package/dist/types/lib/{sources → resources}/vector.d.ts +2 -2
  101. package/dist/types/lib/{sources → resources}/wms.d.ts +15 -5
  102. package/dist/types/lib/resources/wms.test.d.ts +1 -0
  103. package/dist/types/lib/resources/wmts.d.ts +59 -0
  104. package/dist/types/lib/resources/wmts.test.d.ts +1 -0
  105. package/dist/types/lib/resources/xyz.d.ts +5 -0
  106. package/package.json +1 -1
  107. package/readme.md +1 -0
  108. package/dist/collection/lib/previewers/maplibre.js +0 -56
  109. package/dist/ogm-viewer/p-CWtUrqsM.js +0 -2822
  110. package/dist/types/lib/sources/iiif.d.ts +0 -5
  111. package/dist/types/lib/sources/openindexmap.d.ts +0 -5
  112. package/dist/types/lib/sources/tms.d.ts +0 -5
  113. package/dist/types/lib/sources/xyz.d.ts +0 -5
  114. /package/dist/types/lib/{sources/iiif-manifest.test.d.ts → previewers/tilejson.test.d.ts} +0 -0
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var ogmAlerts_ogmAttributes_ogmImage_ogmMap_ogmMenubar_ogmMetadata_ogmPreview_ogmPreviews_ogmSettings_ogmSidebar_ogmViewer_entry = require('./ogm-alerts.ogm-attributes.ogm-image.ogm-map.ogm-menubar.ogm-metadata.ogm-preview.ogm-previews.ogm-settings.ogm-sidebar.ogm-viewer-DMEfXquS.js');
3
+ var ogmAlerts_ogmAttributes_ogmImage_ogmMap_ogmMenubar_ogmMetadata_ogmPreview_ogmPreviews_ogmSettings_ogmSidebar_ogmViewer_entry = require('./ogm-alerts.ogm-attributes.ogm-image.ogm-map.ogm-menubar.ogm-metadata.ogm-preview.ogm-previews.ogm-settings.ogm-sidebar.ogm-viewer-B4jkHqvr.js');
4
4
  require('./index-mu9UK_Fb.js');
5
5
 
6
6
 
@@ -19,7 +19,7 @@ var patchBrowser = () => {
19
19
 
20
20
  patchBrowser().then(async (options) => {
21
21
  await appGlobals.globalScripts();
22
- return index.bootstrapLazy([["ogm-alerts_11.cjs",[[513,"ogm-viewer",{"recordUrl":[1,"record-url"],"theme":[1],"record":[32],"error":[32],"previewOpacity":[32],"sidebarOpen":[32],"loading":[32],"loadRecord":[64]},[[0,"sidebarToggled","toggleSidebar"],[0,"opacityChange","adjustPreviewOpacity"],[0,"mapLoading","setLoadingStarted"],[0,"imageLoading","setLoadingStarted"],[0,"mapIdle","setLoadingFinished"],[0,"imageLoaded","setLoadingFinished"]],{"recordUrl":[{"updateRecord":0}],"record":[{"resetLoading":0}]}],[513,"ogm-previews",{"theme":[1],"record":[16],"previewOpacity":[2,"preview-opacity"],"sidebarPadding":[2,"sidebar-padding"],"sources":[32]},null,{"record":[{"getSources":0}]}],[513,"ogm-sidebar",{"record":[16],"theme":[1],"open":[4]}],[513,"ogm-menubar",{"record":[16],"theme":[1],"loading":[4]}],[513,"ogm-preview",{"theme":[1],"source":[16],"previewOpacity":[2,"preview-opacity"],"sidebarPadding":[2,"sidebar-padding"],"error":[32]},[[0,"previewError","handlePreviewError"]],{"source":[{"resetError":0}]}],[513,"ogm-metadata",{"record":[16],"theme":[1],"fieldNames":[16],"filteredRecord":[32]}],[513,"ogm-settings",{"record":[16]},[[0,"input","handleOpacityChange"]]],[513,"ogm-map",{"source":[16],"theme":[1],"padding":[2],"easeMapTo":[64]},[[16,"featureSelected","handleFeatureSelected"]],{"source":[{"previewSource":0}],"padding":[{"onPaddingChange":0}]}],[513,"ogm-alerts",{"theme":[1],"error":[16]}],[513,"ogm-image",{"source":[16],"theme":[1],"padding":[2]},null,{"source":[{"onSourceChange":0}],"padding":[{"onPaddingChange":0}]}],[513,"ogm-attributes",{"features":[16],"currentIndex":[32]},null,{"features":[{"onFeaturesChange":0}],"currentIndex":[{"onCurrentIndexChange":0}]}]]]], options);
22
+ return index.bootstrapLazy([["ogm-alerts_11.cjs",[[513,"ogm-viewer",{"recordUrl":[1,"record-url"],"theme":[1],"hideTitle":[4,"hide-title"],"record":[32],"error":[32],"previewOpacity":[32],"sidebarOpen":[32],"loading":[32],"loadRecord":[64]},[[0,"sidebarToggled","toggleSidebar"],[0,"opacityChange","adjustPreviewOpacity"],[0,"mapLoading","setLoadingStarted"],[0,"imageLoading","setLoadingStarted"],[0,"mapIdle","setLoadingFinished"],[0,"imageLoaded","setLoadingFinished"]],{"recordUrl":[{"updateRecord":0}],"record":[{"resetLoading":0}]}],[513,"ogm-previews",{"theme":[1],"record":[16],"previewOpacity":[2,"preview-opacity"],"sidebarPadding":[2,"sidebar-padding"],"resources":[32]},null,{"record":[{"getSources":0}]}],[513,"ogm-sidebar",{"record":[16],"theme":[1],"open":[4]}],[513,"ogm-menubar",{"record":[16],"theme":[1],"loading":[4],"hideTitle":[4,"hide-title"]}],[513,"ogm-preview",{"theme":[1],"previewResource":[16],"previewOpacity":[2,"preview-opacity"],"sidebarPadding":[2,"sidebar-padding"],"error":[32]},[[0,"previewError","handlePreviewError"]],{"previewResource":[{"resetError":0}]}],[513,"ogm-metadata",{"record":[16],"theme":[1],"fieldNames":[16],"filteredRecord":[32]}],[513,"ogm-settings",{"record":[16]},[[0,"input","handleOpacityChange"]]],[513,"ogm-map",{"previewResource":[16],"theme":[1],"padding":[2],"easeMapTo":[64]},[[16,"featureSelected","handleFeatureSelected"]],{"previewResource":[{"loadResource":0}],"theme":[{"onThemeChange":0}],"padding":[{"onPaddingChange":0}]}],[513,"ogm-alerts",{"theme":[1],"error":[16]}],[513,"ogm-image",{"previewResource":[16],"theme":[1],"padding":[2]},null,{"previewResource":[{"onSourceChange":0}],"padding":[{"onPaddingChange":0}]}],[513,"ogm-attributes",{"features":[16],"currentIndex":[32]},null,{"features":[{"onFeaturesChange":0}],"currentIndex":[{"onCurrentIndexChange":0}]}]]]], options);
23
23
  });
24
24
 
25
25
  exports.setNonce = index.setNonce;
@@ -4,7 +4,7 @@ import { getElement, findElement } from "../../lib/elements";
4
4
  import { referenceError } from "../../lib/errors";
5
5
  export class OgmImage {
6
6
  el;
7
- source;
7
+ previewResource;
8
8
  theme;
9
9
  padding = 0;
10
10
  imageLoaded;
@@ -38,7 +38,7 @@ export class OgmImage {
38
38
  this.reportError(new Error(event.message));
39
39
  });
40
40
  // If we do have a source, load the images
41
- if (this.source)
41
+ if (this.previewResource)
42
42
  await this.loadImages();
43
43
  }
44
44
  // Destroy the viewer when we are removed from the DOM
@@ -47,7 +47,7 @@ export class OgmImage {
47
47
  }
48
48
  // Update preview when source changes
49
49
  async onSourceChange() {
50
- if (this.source)
50
+ if (this.previewResource)
51
51
  await this.loadImages();
52
52
  }
53
53
  async onPaddingChange() {
@@ -64,26 +64,26 @@ export class OgmImage {
64
64
  this.errorReported = false;
65
65
  this.imageLoading.emit();
66
66
  try {
67
- const images = await this.source.getIIIFImageUrls();
67
+ const images = await this.previewResource.getIIIFImageUrls();
68
68
  if (!images)
69
69
  throw new Error('No IIIF images found for source');
70
70
  this.viewer.open(images);
71
71
  }
72
72
  catch (error) {
73
- console.error(`Error loading IIIF images for ${this.source.url}:`, error);
73
+ console.error(`Error loading IIIF images for ${this.previewResource.url}:`, error);
74
74
  this.imageLoaded.emit();
75
75
  this.reportError(error);
76
76
  }
77
77
  }
78
78
  // Emit a single preview error per load attempt
79
79
  reportError(error) {
80
- if (this.errorReported || !this.source)
80
+ if (this.errorReported || !this.previewResource)
81
81
  return;
82
82
  this.errorReported = true;
83
- this.previewError.emit(referenceError(error, this.source.label(), this.source.url));
83
+ this.previewError.emit(referenceError(error, this.previewResource.label(), this.previewResource.url));
84
84
  }
85
85
  render() {
86
- return (h(Host, { key: 'ebbebaddac72024a3b311e0e0e501267a83d1e95' }, h("div", { key: '4f171256535cfd11430e2269fda389ffae3cedae', id: "openseadragon" }, h("div", { key: 'c308186a13fd6b8e0b1fadbf1fd1e6924631f9d6', class: "controls" }, h("wa-button", { key: '1f9e0c4c6d881bf09d7ceb160f470992d71ebe07', class: "zoom-in", size: "s", appearance: "filled-outlined", pill: true }, h("wa-icon", { key: 'cbacb0a388de2c7f349e25172027874a0224a678', name: "zoom-in", label: "Zoom In", canvas: "auto" })), h("wa-button", { key: 'dd8d7e9c5584b124ae105b2187100964f5e3a02a', class: "zoom-out", size: "s", appearance: "filled-outlined", pill: true }, h("wa-icon", { key: '2b5acf2e07c99df9556692bf534bb3847506e4d4', name: "zoom-out", label: "Zoom Out", canvas: "auto" })), h("wa-button", { key: '5534a5c77ea20a1f77544e5acd99d4247dd3d287', class: "home", size: "s", appearance: "filled-outlined", pill: true }, h("wa-icon", { key: 'faadb8ea57bf1b831b292eaf66bcea39b7e215d1', name: "house", label: "Reset View", canvas: "auto" })), h("wa-button", { key: '8979cf58a94da89e0e2d132a92fe45323f07de01', class: "full-page", size: "s", appearance: "filled-outlined", pill: true }, h("wa-icon", { key: '12cb3224e7f14258376c1c0bf6ffc5abda5c2252', name: "arrows-fullscreen", label: "Full Screen", canvas: "auto" })), h("wa-button", { key: 'e79c37f27ff14d5c4991ff30ff88aada467214ec', class: "next", size: "s", appearance: "filled-outlined", pill: true }, h("wa-icon", { key: 'ee10870ace583257393c53ba12b73ab3b015371b', name: "arrow-right", label: "Next", canvas: "auto" })), h("wa-button", { key: '9d8999e199b7b6338261eb16a655d2199520cf22', class: "prev", size: "s", appearance: "filled-outlined", pill: true }, h("wa-icon", { key: 'fde1a9022b9e5f90e269c75ce87943808031e021', name: "arrow-left", label: "Previous", canvas: "auto" }))))));
86
+ return (h(Host, { key: 'e07b96ecb9eb9aba4f4e21a8bff4a997158afa67' }, h("div", { key: '3f8147685a9cf58023c52aeb19863235cfbee3d0', id: "openseadragon" }, h("div", { key: 'ced3713b0dff0dfb9ec0c9b7d7ec2a30e44da450', class: "controls" }, h("wa-button", { key: '2c8463949482dc421636231391bffe3d7007a540', class: "zoom-in", size: "s", appearance: "filled-outlined", pill: true }, h("wa-icon", { key: 'f6b8b16f2bb4702f443a6550bcb4fa3b2ee96fff', name: "zoom-in", label: "Zoom In", canvas: "auto" })), h("wa-button", { key: 'db4dd4dc34fbbb1730d0f65738a8dda14cdbd1e7', class: "zoom-out", size: "s", appearance: "filled-outlined", pill: true }, h("wa-icon", { key: '7226b94f0cdd071d0b1b6eb76a2102a7f2eaaff8', name: "zoom-out", label: "Zoom Out", canvas: "auto" })), h("wa-button", { key: 'ea03e501c4666cd37721776de8f8e9ddb21b0e54', class: "home", size: "s", appearance: "filled-outlined", pill: true }, h("wa-icon", { key: 'e6f9ae3ec07ad9123dbc1597798a9df2f38362f3', name: "house", label: "Reset View", canvas: "auto" })), h("wa-button", { key: 'ac38b067eb7f001430996ecfaf1e2570c3e99861', class: "full-page", size: "s", appearance: "filled-outlined", pill: true }, h("wa-icon", { key: '03d9e1d0e70f053b413cf116d1e70754b64ade40', name: "arrows-fullscreen", label: "Full Screen", canvas: "auto" })), h("wa-button", { key: 'e580f1b08944d541f7527f97183971b644112a72', class: "next", size: "s", appearance: "filled-outlined", pill: true }, h("wa-icon", { key: '6272934579ad6654a557dbc44d2f3021034acb81', name: "arrow-right", label: "Next", canvas: "auto" })), h("wa-button", { key: '80927b9c68dd16ac3ae8e68b405a11b2f8740843', class: "prev", size: "s", appearance: "filled-outlined", pill: true }, h("wa-icon", { key: 'd4f2fc257287be5d4f473328c8daf3e4b445cee8', name: "arrow-left", label: "Previous", canvas: "auto" }))))));
87
87
  }
88
88
  static get is() { return "ogm-image"; }
89
89
  static get encapsulation() { return "shadow"; }
@@ -99,16 +99,16 @@ export class OgmImage {
99
99
  }
100
100
  static get properties() {
101
101
  return {
102
- "source": {
102
+ "previewResource": {
103
103
  "type": "unknown",
104
104
  "mutable": false,
105
105
  "complexType": {
106
- "original": "IIIFSource",
107
- "resolved": "IIIFSource",
106
+ "original": "IIIFResource",
107
+ "resolved": "IIIFResource",
108
108
  "references": {
109
- "IIIFSource": {
109
+ "IIIFResource": {
110
110
  "location": "global",
111
- "id": "global::IIIFSource"
111
+ "id": "global::IIIFResource"
112
112
  }
113
113
  }
114
114
  },
@@ -220,7 +220,7 @@ export class OgmImage {
220
220
  static get elementRef() { return "el"; }
221
221
  static get watchers() {
222
222
  return [{
223
- "propName": "source",
223
+ "propName": "previewResource",
224
224
  "methodName": "onSourceChange"
225
225
  }, {
226
226
  "propName": "padding",
@@ -1,28 +1,41 @@
1
1
  import { h } from "@stencil/core";
2
2
  import maplibregl from "maplibre-gl";
3
3
  import { Protocol as PMTilesProtocol } from "pmtiles";
4
- import CogSource from "../../lib/sources/cog";
5
- import GeoJSONSource from "../../lib/sources/geojson";
6
- import OpenIndexMapSource from "../../lib/sources/openindexmap";
7
- import PMTilesSource from "../../lib/sources/pmtiles";
8
- import RasterSource from "../../lib/sources/raster";
9
- import WmsSource from "../../lib/sources/wms";
4
+ import CogResource from "../../lib/resources/cog";
5
+ import GeoJsonResource from "../../lib/resources/geojson";
6
+ import OpenIndexMapResource from "../../lib/resources/openindexmap";
7
+ import PMTilesResource from "../../lib/resources/pmtiles";
8
+ import RasterResource from "../../lib/resources/raster";
9
+ import TileJsonResource from "../../lib/resources/tilejson";
10
+ import WmsResource from "../../lib/resources/wms";
11
+ import WmtsResource from "../../lib/resources/wmts";
10
12
  import { getElement } from "../../lib/elements";
11
- import { referenceError } from "../../lib/errors";
13
+ import { referenceError, PreviewError } from "../../lib/errors";
14
+ import { mercatorBbox, mercatorGeomToLngLat } from "../../lib/geometry";
12
15
  import CogPreviewer from "../../lib/previewers/cog";
13
- import GeoJSONPreviewer from "../../lib/previewers/geojson";
16
+ import GeoJsonPreviewer from "../../lib/previewers/geojson";
14
17
  import OpenIndexMapPreviewer from "../../lib/previewers/openindexmap";
15
18
  import PMTilesRasterPreviewer from "../../lib/previewers/pmtiles-raster";
16
19
  import PMTilesVectorPreviewer from "../../lib/previewers/pmtiles-vector";
17
20
  import RasterPreviewer from "../../lib/previewers/raster";
21
+ import TileJsonRasterPreviewer from "../../lib/previewers/tilejson-raster";
22
+ import TileJsonVectorPreviewer from "../../lib/previewers/tilejson-vector";
23
+ import WmtsPreviewer from "../../lib/previewers/wmts";
18
24
  import WmsPreviewer from "../../lib/previewers/wms";
19
25
  import MapLibreTheme from "../../lib/themes/maplibre";
20
26
  // Register PMTiles protocol
21
27
  const protocol = new PMTilesProtocol();
22
28
  maplibregl.addProtocol('pmtiles', protocol.tile);
29
+ // Size in CSS pixels of the window we ask a WMS about when inspecting. GetFeatureInfo
30
+ // locates a click by mapping a pixel grid onto a bbox, which assumes the view is a
31
+ // flat, north-up rectangle - but ours can be rotated, pitched, or drawn as a globe. So
32
+ // we describe a small window around the click rather than the whole viewport, which
33
+ // keeps that assumption true to within a fraction of a pixel. Odd, so the clicked pixel
34
+ // is the exact center of the window.
35
+ const WMS_QUERY_WINDOW = 51;
23
36
  export class OgmMap {
24
37
  el;
25
- source;
38
+ previewResource;
26
39
  theme;
27
40
  padding = 0;
28
41
  mapIdle;
@@ -38,7 +51,7 @@ export class OgmMap {
38
51
  hoveredFeature = undefined;
39
52
  // Container element reference for fullscreen
40
53
  containerEl;
41
- // Previewer for the currently previewed source
54
+ // Previewer for the currently previewed resource
42
55
  previewer = undefined;
43
56
  // Set up the mapLibre map and event bindings on load
44
57
  componentDidLoad() {
@@ -54,7 +67,7 @@ export class OgmMap {
54
67
  });
55
68
  this.getContainer();
56
69
  this.addControls();
57
- this.map.on('load', () => this.previewSource(this.source));
70
+ this.map.on('load', () => this.loadResource(this.previewResource));
58
71
  this.map.on('mousemove', this.handleHover.bind(this));
59
72
  this.map.on('click', this.handleClick.bind(this));
60
73
  this.map.on('error', this.handleMapError.bind(this));
@@ -98,29 +111,37 @@ export class OgmMap {
98
111
  },
99
112
  }));
100
113
  }
101
- // Get the appropriate previewer for our source
114
+ // Get the appropriate previewer for our resource
102
115
  async getMapPreviewer(map) {
103
116
  const style = this.mapTheme.getStyle();
104
- if (this.source instanceof OpenIndexMapSource)
105
- return new OpenIndexMapPreviewer(this.source, map, style);
106
- else if (this.source instanceof GeoJSONSource)
107
- return new GeoJSONPreviewer(this.source, map, style);
108
- else if (this.source instanceof PMTilesSource) {
109
- if (await this.source.isVector())
110
- return new PMTilesVectorPreviewer(this.source, map, style);
117
+ if (this.previewResource instanceof OpenIndexMapResource)
118
+ return new OpenIndexMapPreviewer(this.previewResource, map, style);
119
+ else if (this.previewResource instanceof GeoJsonResource)
120
+ return new GeoJsonPreviewer(this.previewResource, map, style);
121
+ else if (this.previewResource instanceof PMTilesResource) {
122
+ if (await this.previewResource.isVector())
123
+ return new PMTilesVectorPreviewer(this.previewResource, map, style);
111
124
  else
112
- return new PMTilesRasterPreviewer(this.source, map, style);
125
+ return new PMTilesRasterPreviewer(this.previewResource, map, style);
113
126
  }
114
- else if (this.source instanceof WmsSource)
115
- return new WmsPreviewer(this.source, map, style);
116
- else if (this.source instanceof CogSource)
117
- return new CogPreviewer(this.source, map, style);
118
- else if (this.source instanceof RasterSource)
119
- return new RasterPreviewer(this.source, map, style);
127
+ else if (this.previewResource instanceof TileJsonResource) {
128
+ if (await this.previewResource.isVector())
129
+ return new TileJsonVectorPreviewer(this.previewResource, map, style);
130
+ else
131
+ return new TileJsonRasterPreviewer(this.previewResource, map, style);
132
+ }
133
+ else if (this.previewResource instanceof WmsResource)
134
+ return new WmsPreviewer(this.previewResource, map, style);
135
+ else if (this.previewResource instanceof CogResource)
136
+ return new CogPreviewer(this.previewResource, map, style);
137
+ else if (this.previewResource instanceof WmtsResource)
138
+ return new WmtsPreviewer(this.previewResource, map, style);
139
+ else if (this.previewResource instanceof RasterResource)
140
+ return new RasterPreviewer(this.previewResource, map, style);
120
141
  }
121
- async previewSource(source) {
122
- // Do nothing if we didn't get passed a source
123
- if (!source)
142
+ async loadResource(resource) {
143
+ // Do nothing if we didn't get passed a resource
144
+ if (!resource)
124
145
  return;
125
146
  // Fresh load attempt: allow one error to be reported again for this source
126
147
  this.errorReported = false;
@@ -135,36 +156,43 @@ export class OgmMap {
135
156
  await this.previewer.clearPreview();
136
157
  this.previewer = undefined;
137
158
  }
138
- // Get the appropriate previewer for our source and preview it
159
+ // Get the appropriate previewer for our resource and preview it
139
160
  this.previewer = await this.getMapPreviewer(this.map);
140
161
  if (!this.previewer)
141
- throw new Error(`No previewer found for source: ${source.constructor.name}`);
162
+ throw new Error(`No previewer found for resource: ${resource.constructor.name}`);
142
163
  await this.previewer.preview();
143
164
  // Fit to bounds from the record; the spinner stays up until the map finishes moving
144
- const bounds = await this.source.getBounds();
165
+ const bounds = await this.previewResource.getBounds();
145
166
  if (bounds)
146
167
  await this.fitMapBounds(bounds);
147
168
  }
148
169
  catch (error) {
149
- console.error(`Error previewing source ${source.url}:`, error);
170
+ console.error(`Error previewing resource ${resource.url}:`, error);
150
171
  if (!this.errorReported) {
151
172
  this.errorReported = true;
152
- this.previewError.emit(referenceError(error, source.label(), source.url));
173
+ this.previewError.emit(referenceError(error, resource.label(), resource.url));
153
174
  }
154
175
  }
155
176
  finally {
156
177
  this.mapIdle.emit();
157
178
  }
158
179
  }
159
- // Surface MapLibre errors tied to the current preview source, skipping the
180
+ // When the theme changes, swap the basemap to match.
181
+ onThemeChange() {
182
+ if (!this.map)
183
+ return;
184
+ this.map.setStyle(this.mapTheme.getBaseMapStyle());
185
+ this.map.once('style.load', async () => await this.loadResource(this.previewResource));
186
+ }
187
+ // Surface MapLibre errors tied to the current previewed resource, skipping the
160
188
  // noise from basemap/glyph/sprite loads, and deduped to a single alert per load attempt.
161
189
  handleMapError(event) {
162
- if (this.errorReported || !this.source || !this.previewer)
190
+ if (this.errorReported || !this.previewResource || !this.previewer)
163
191
  return;
164
- if (event.sourceId !== this.previewer.sourceId)
192
+ if (!this.previewer.sourceIds.includes(event.sourceId ?? ''))
165
193
  return;
166
194
  this.errorReported = true;
167
- this.previewError.emit(referenceError(event.error, this.source.label(), this.source.url));
195
+ this.previewError.emit(referenceError(event.error, this.previewResource.label(), this.previewResource.url));
168
196
  }
169
197
  // Fit the map to the given bounds; resolve once the move finishes. Guard the case where the bounds
170
198
  // can't produce a camera - e.g. sidebar padding wider than the viewport, or a hidden, zero-size
@@ -188,6 +216,11 @@ export class OgmMap {
188
216
  }
189
217
  // Use the crosshair cursor if there's something to inspect
190
218
  handleHover(event) {
219
+ // Always use it for WMS, since we don't know until we make the request
220
+ if (this.previewer instanceof WmsPreviewer) {
221
+ this.map.getCanvas().style.cursor = 'crosshair';
222
+ return;
223
+ }
191
224
  const features = this.map.queryRenderedFeatures(event.point, { layers: this.previewLayers });
192
225
  if (features.length > 0) {
193
226
  this.map.getCanvas().style.cursor = 'crosshair';
@@ -199,12 +232,12 @@ export class OgmMap {
199
232
  }
200
233
  }
201
234
  // Show the attributes popup on click
202
- handleClick(event) {
235
+ async handleClick(event) {
203
236
  // Clear any existing popup and feature selection
204
237
  this.clearFeatureSelection();
205
238
  this.destroyPopup();
206
- // Check if we have feature(s) to inspect at the clicked point
207
- const features = this.map.queryRenderedFeatures(event.point, { layers: this.previewLayers });
239
+ // Get the features, if any, at the clicked point. If none, do nothing.
240
+ const features = await this.handleInspection(event.point);
208
241
  if (features.length === 0)
209
242
  return;
210
243
  // Create and populate the attributes popup and select the first feature if multiple
@@ -212,6 +245,51 @@ export class OgmMap {
212
245
  this.createPopup(event.lngLat);
213
246
  this.selectFeature(features[0]);
214
247
  }
248
+ // Handle inspection of features, delegating to previewer if WMS
249
+ async handleInspection(point) {
250
+ if (!this.previewer)
251
+ return [];
252
+ let features = [];
253
+ if (this.previewer instanceof WmsPreviewer) {
254
+ features = await this.handleWmsInspection(point);
255
+ }
256
+ else {
257
+ features = this.map.queryRenderedFeatures(point, { layers: this.previewLayers });
258
+ }
259
+ return features;
260
+ }
261
+ // Special handling for WMS inspection, which requires a GetFeatureInfo request
262
+ async handleWmsInspection(point) {
263
+ if (!(this.previewer instanceof WmsPreviewer))
264
+ return [];
265
+ // Corners of the query window, in the same CSS pixel space as the click. Let
266
+ // MapLibre unproject them so the geography stays right under any projection, then
267
+ // take their EPSG:3857 envelope, since that is the CRS we request.
268
+ const half = (WMS_QUERY_WINDOW - 1) / 2;
269
+ const corners = [
270
+ [point.x - half, point.y - half],
271
+ [point.x + half, point.y - half],
272
+ [point.x + half, point.y + half],
273
+ [point.x - half, point.y + half],
274
+ ].map(([x, y]) => this.map.unproject([x, y]));
275
+ const response = await this.previewer.inspect({
276
+ bbox: mercatorBbox(corners),
277
+ width: WMS_QUERY_WINDOW,
278
+ height: WMS_QUERY_WINDOW,
279
+ x: half,
280
+ y: half,
281
+ });
282
+ if (!response.ok)
283
+ throw new PreviewError(`WMS GetFeatureInfo request failed with status ${response.status}`);
284
+ const data = await response.json();
285
+ if (!data || !data.features || !Array.isArray(data.features))
286
+ return [];
287
+ return data.features.map((feature) => ({
288
+ ...feature,
289
+ geometry: feature.geometry && mercatorGeomToLngLat(feature.geometry),
290
+ source: this.previewer.getSourceId(),
291
+ }));
292
+ }
215
293
  // Listen to selection events from the popup and highlight the selected feature
216
294
  handleFeatureSelected(event) {
217
295
  this.clearFeatureSelection();
@@ -220,13 +298,24 @@ export class OgmMap {
220
298
  }
221
299
  // Reset styling of all features to unselected state
222
300
  clearFeatureSelection() {
223
- this.attributesEl.features.forEach(feature => {
224
- this.map.setFeatureState({ source: feature.source, id: feature.id, sourceLayer: feature.sourceLayer }, { selected: false });
225
- });
301
+ if (this.previewer instanceof WmsPreviewer) {
302
+ this.previewer.clearHighlight();
303
+ }
304
+ else {
305
+ this.attributesEl.features.forEach(feature => {
306
+ this.map.setFeatureState({ source: feature.source, id: feature.id, sourceLayer: feature.sourceLayer }, { selected: false });
307
+ });
308
+ }
226
309
  this.attributesEl.features = [];
227
310
  }
228
311
  // Set styling of a single feature to selected state
229
312
  selectFeature(feature) {
313
+ // A WMS raster has no client-side features to restyle, so the previewer outlines the
314
+ // geometry that GetFeatureInfo returned instead
315
+ if (this.previewer instanceof WmsPreviewer) {
316
+ this.previewer.highlightFeatures([feature]);
317
+ return;
318
+ }
230
319
  this.map.setFeatureState({ source: feature.source, id: feature.id, sourceLayer: feature.sourceLayer }, { selected: true });
231
320
  }
232
321
  // Set styling of a single feature to hovered state
@@ -259,7 +348,7 @@ export class OgmMap {
259
348
  return this.previewer?.layerIds || [];
260
349
  }
261
350
  render() {
262
- return h("div", { key: '9519610af20287a4d7e28470c715accc5ffb8430', id: "map", class: `wa-${this.theme}` });
351
+ return h("div", { key: '9bcace1eb20c7f5e096c18b816b7810b1edad330', id: "map", class: `wa-${this.theme}` });
263
352
  }
264
353
  static get is() { return "ogm-map"; }
265
354
  static get encapsulation() { return "shadow"; }
@@ -275,16 +364,16 @@ export class OgmMap {
275
364
  }
276
365
  static get properties() {
277
366
  return {
278
- "source": {
367
+ "previewResource": {
279
368
  "type": "unknown",
280
369
  "mutable": false,
281
370
  "complexType": {
282
- "original": "Source",
283
- "resolved": "Source",
371
+ "original": "Resource",
372
+ "resolved": "Resource",
284
373
  "references": {
285
- "Source": {
374
+ "Resource": {
286
375
  "location": "global",
287
- "id": "global::Source"
376
+ "id": "global::Resource"
288
377
  }
289
378
  }
290
379
  },
@@ -425,8 +514,11 @@ export class OgmMap {
425
514
  static get elementRef() { return "el"; }
426
515
  static get watchers() {
427
516
  return [{
428
- "propName": "source",
429
- "methodName": "previewSource"
517
+ "propName": "previewResource",
518
+ "methodName": "loadResource"
519
+ }, {
520
+ "propName": "theme",
521
+ "methodName": "onThemeChange"
430
522
  }, {
431
523
  "propName": "padding",
432
524
  "methodName": "onPaddingChange"
@@ -2,10 +2,11 @@ import { h } from "@stencil/core";
2
2
  export class OgmMenubar {
3
3
  record;
4
4
  theme;
5
- sidebarToggled;
6
5
  loading = false;
6
+ hideTitle = false;
7
+ sidebarToggled;
7
8
  render() {
8
- return (h("div", { key: '437b8f1b6f44844f1db4460c6597c0a68479a8f7', class: `menubar ${this.theme && `wa-${this.theme}`}` }, h("wa-button", { key: 'baf0a0baa96fcf3f114fdf47b4446b90df862c6b', appearance: "plain", class: "menu-button", onclick: this.sidebarToggled.emit }, h("wa-icon", { key: 'b4e1c07bd7284dbd191997a4b270d12c1e1d5b63', name: "list", label: "Open sidebar", canvas: "auto" })), this.record?.restricted && (h(h.Fragment, null, h("wa-tooltip", { key: '4e8d318982e7bd8af99b320e4810b23d0c00b264', for: "restricted-icon" }, "Restricted access"), h("wa-icon", { key: '6da389ec7b55697d203dd2935af192ae64c0622b', id: "restricted-icon", name: "lock-fill", label: "Restricted access", class: "restricted-icon", canvas: "auto" }))), h("div", { key: 'd118cbb176a44ae761d82c7adff2b0fa31cbe87e', class: "title" }, this.record?.title), this.loading && h("wa-spinner", { key: '5bc6c254a1fa5b4b4bb82ec8fc1cc04ff1457a31', class: "loading-spinner" })));
9
+ return (h("div", { key: '470fcb6d5d31cc9a53142372e82c6b15563863d3', class: `menubar ${this.theme && `wa-${this.theme}`}` }, h("wa-button", { key: '22dec0e10b5b12a1481355d97cc61b6c85b7e612', appearance: "plain", class: "menu-button", onclick: this.sidebarToggled.emit }, h("wa-icon", { key: '48f29ad88af2d982392d946cf11fdc7e605b7aa6', name: "list", label: "Open sidebar", canvas: "auto" })), this.record?.restricted && (h(h.Fragment, null, h("wa-tooltip", { key: 'fa26b6d78dc07d0a009a941e6c2587342a8d6fe4', for: "restricted-icon" }, "Restricted access"), h("wa-icon", { key: '0aaece23cb54401ed62634c079cbfdca63926d69', id: "restricted-icon", name: "lock-fill", label: "Restricted access", class: "restricted-icon", canvas: "auto" }))), !this.hideTitle && h("div", { key: '89d30f43c7d84478dae1777a5be57136342d72f0', class: "title" }, this.record?.title), this.loading && h("wa-spinner", { key: '69a12e09d0b807e85000d63ee3fba8fb98c4ec33', class: "loading-spinner" })));
9
10
  }
10
11
  static get is() { return "ogm-menubar"; }
11
12
  static get encapsulation() { return "shadow"; }
@@ -81,6 +82,26 @@ export class OgmMenubar {
81
82
  "reflect": false,
82
83
  "attribute": "loading",
83
84
  "defaultValue": "false"
85
+ },
86
+ "hideTitle": {
87
+ "type": "boolean",
88
+ "mutable": false,
89
+ "complexType": {
90
+ "original": "boolean",
91
+ "resolved": "boolean",
92
+ "references": {}
93
+ },
94
+ "required": false,
95
+ "optional": false,
96
+ "docs": {
97
+ "tags": [],
98
+ "text": ""
99
+ },
100
+ "getter": false,
101
+ "setter": false,
102
+ "reflect": false,
103
+ "attribute": "hide-title",
104
+ "defaultValue": "false"
84
105
  }
85
106
  };
86
107
  }
@@ -46,6 +46,40 @@ describe('ogm-menubar', () => {
46
46
  `);
47
47
  });
48
48
  });
49
+ describe('when hideTitle is true', () => {
50
+ it('does not render the title', async () => {
51
+ const record = new OgmRecord({
52
+ id: 'stanford-ff359cr8805',
53
+ dct_title_s: 'Coho Salmon Watersheds: San Francisco Bay Area, California, 2011',
54
+ dct_description_sm: [],
55
+ gbl_resourceType_sm: ['Polygon data'],
56
+ gbl_resourceClass_sm: ['Datasets'],
57
+ dct_accessRights_s: 'Public',
58
+ gbl_mdVersion_s: 'Aardvark',
59
+ });
60
+ const { root } = await render(h("ogm-menubar", { record: record, hideTitle: true }));
61
+ const shadowRoot = root.shadowRoot;
62
+ expect(shadowRoot.querySelector('.title')).toBeNull();
63
+ });
64
+ it('toggles the title when the hideTitle prop changes', async () => {
65
+ const record = new OgmRecord({
66
+ id: 'stanford-ff359cr8805',
67
+ dct_title_s: 'Coho Salmon Watersheds: San Francisco Bay Area, California, 2011',
68
+ dct_description_sm: [],
69
+ gbl_resourceType_sm: ['Polygon data'],
70
+ gbl_resourceClass_sm: ['Datasets'],
71
+ dct_accessRights_s: 'Public',
72
+ gbl_mdVersion_s: 'Aardvark',
73
+ });
74
+ const { root, setProps } = await render(h("ogm-menubar", { record: record, hideTitle: false }));
75
+ const shadowRoot = root.shadowRoot;
76
+ expect(shadowRoot.querySelector('.title')?.textContent?.trim()).toBe('Coho Salmon Watersheds: San Francisco Bay Area, California, 2011');
77
+ await setProps({ hideTitle: true });
78
+ expect(shadowRoot.querySelector('.title')).toBeNull();
79
+ await setProps({ hideTitle: false });
80
+ expect(shadowRoot.querySelector('.title')?.textContent?.trim()).toBe('Coho Salmon Watersheds: San Francisco Bay Area, California, 2011');
81
+ });
82
+ });
49
83
  describe('loading indicator', () => {
50
84
  it('shows the spinner while loading', async () => {
51
85
  const { root } = await render(h("ogm-menubar", { loading: true }));
@@ -1,13 +1,13 @@
1
1
  import { h, Host } from "@stencil/core";
2
- import IIIFSource from "../../lib/sources/iiif";
2
+ import IIIFResource from "../../lib/resources/iiif";
3
3
  // Wraps a single source's preview and surfaces error(s) during the preview.
4
4
  export class OgmPreview {
5
5
  theme;
6
- source;
6
+ previewResource;
7
7
  previewOpacity;
8
8
  sidebarPadding;
9
9
  error;
10
- // A new source is a fresh load attempt, so clear any error left over from the previous one.
10
+ // A new resource is a fresh load attempt, so clear any error left over from the previous one.
11
11
  resetError() {
12
12
  this.error = undefined;
13
13
  }
@@ -18,13 +18,13 @@ export class OgmPreview {
18
18
  }
19
19
  // IIIF sources use the image viewer; every other source type is previewed on the map.
20
20
  renderPreview() {
21
- if (this.source instanceof IIIFSource) {
22
- return h("ogm-image", { theme: this.theme, source: this.source, padding: this.sidebarPadding });
21
+ if (this.previewResource instanceof IIIFResource) {
22
+ return h("ogm-image", { theme: this.theme, previewResource: this.previewResource, padding: this.sidebarPadding });
23
23
  }
24
- return h("ogm-map", { "preview-opacity": this.previewOpacity, theme: this.theme, source: this.source, padding: this.sidebarPadding });
24
+ return h("ogm-map", { "preview-opacity": this.previewOpacity, theme: this.theme, previewResource: this.previewResource, padding: this.sidebarPadding });
25
25
  }
26
26
  render() {
27
- return (h(Host, { key: 'c962bdcbebdebb1abde8900b0d0811be218fca46' }, this.renderPreview(), this.error && h("ogm-alerts", { key: '87b8217bbb7d5101d9f306f2492326d3f9f92429', theme: this.theme, error: this.error })));
27
+ return (h(Host, { key: '6105ad9ba75013fcbbdb69f37f2485a86e72f1a2' }, this.renderPreview(), this.error && h("ogm-alerts", { key: '6f5351cc5d06f95c5b5192c6918c0fb2904603c3', theme: this.theme, error: this.error })));
28
28
  }
29
29
  static get is() { return "ogm-preview"; }
30
30
  static get encapsulation() { return "shadow"; }
@@ -59,16 +59,16 @@ export class OgmPreview {
59
59
  "reflect": false,
60
60
  "attribute": "theme"
61
61
  },
62
- "source": {
62
+ "previewResource": {
63
63
  "type": "unknown",
64
64
  "mutable": false,
65
65
  "complexType": {
66
- "original": "Source",
67
- "resolved": "Source",
66
+ "original": "Resource",
67
+ "resolved": "Resource",
68
68
  "references": {
69
- "Source": {
69
+ "Resource": {
70
70
  "location": "global",
71
- "id": "global::Source"
71
+ "id": "global::Resource"
72
72
  }
73
73
  }
74
74
  },
@@ -128,7 +128,7 @@ export class OgmPreview {
128
128
  }
129
129
  static get watchers() {
130
130
  return [{
131
- "propName": "source",
131
+ "propName": "previewResource",
132
132
  "methodName": "resetError"
133
133
  }];
134
134
  }
@@ -3,15 +3,15 @@ import { describe, it, expect, h, vi } from "@stencil/vitest";
3
3
  // wrapper re-throws lifecycle errors, and the <ogm-map>/<ogm-image> mounted inside a preview throw
4
4
  // when they try to initialize WebGL/OpenSeadragon (unavailable in the test DOM).
5
5
  import { render as stencilRender } from "@stencil/core";
6
- import GeoJSONSource from "../../lib/sources/geojson";
6
+ import GeoJsonResource from "../../lib/resources/geojson";
7
7
  import { referenceError } from "../../lib/errors";
8
8
  // Let Stencil's RAF-based update cycle flush after a state change (mirrors the vitest waitForChanges).
9
9
  const flush = () => new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(() => resolve())));
10
- const renderPreview = async (source) => {
10
+ const renderPreview = async (resource) => {
11
11
  const container = document.createElement('div');
12
12
  document.body.appendChild(container);
13
13
  const consoleError = vi.spyOn(console, 'error').mockImplementation(() => { });
14
- await stencilRender(h("ogm-preview", { source: source }), container);
14
+ await stencilRender(h("ogm-preview", { previewResource: resource }), container);
15
15
  const el = container.firstElementChild;
16
16
  await el.componentOnReady?.();
17
17
  consoleError.mockRestore();
@@ -19,13 +19,13 @@ const renderPreview = async (source) => {
19
19
  };
20
20
  describe('ogm-preview', () => {
21
21
  it('renders a preview for a source', async () => {
22
- const el = await renderPreview(new GeoJSONSource('id', 'http://example.com/data.json'));
22
+ const el = await renderPreview(new GeoJsonResource('id', 'http://example.com/data.json'));
23
23
  const shadowRoot = el.shadowRoot;
24
24
  expect(shadowRoot.querySelector('ogm-map')).not.toBeNull();
25
25
  expect(shadowRoot.querySelector('ogm-alerts')).toBeNull();
26
26
  });
27
27
  it('shows the error over the preview when a previewError is reported', async () => {
28
- const el = await renderPreview(new GeoJSONSource('id', 'http://example.com/data.json'));
28
+ const el = await renderPreview(new GeoJsonResource('id', 'http://example.com/data.json'));
29
29
  const error = referenceError(new TypeError('Failed to fetch'), 'GeoJSON', 'http://example.com/data.json');
30
30
  el.dispatchEvent(new CustomEvent('previewError', { detail: error, bubbles: true }));
31
31
  await flush();