col-browser 2.6.4 → 2.6.6

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.
@@ -4,7 +4,7 @@ import { useState as a, useEffect as D } from "react";
4
4
  import { s as T, c as s, R as g, b as k } from "./chunks/router-CssZk5qZ.js";
5
5
  import { c as l } from "./chunks/config--bs_09I6.js";
6
6
  import { Row as v, Col as w, Spin as A } from "antd";
7
- import { D as C } from "./chunks/Distributions-CvS4r1hC.js";
7
+ import { D as C } from "./chunks/Distributions-CHjEIZ3F.js";
8
8
  const E = ({
9
9
  taxonId: o,
10
10
  datasetKey: i,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "col-browser",
3
- "version": "2.6.4",
3
+ "version": "2.6.6",
4
4
  "description": "Catalogue of Life browse and search React components",
5
5
  "main": "umd/col-browser.js",
6
6
  "module": "es/index.js",
@@ -13397,7 +13397,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
13397
13397
  */
13398
13398
  WIN_KEY: 224
13399
13399
  };
13400
- let cached;
13400
+ let cached$1;
13401
13401
  function measureScrollbarSize(ele) {
13402
13402
  const randomId = `rc-scrollbar-measure-${Math.random().toString(36).substring(7)}`;
13403
13403
  const measureEle = document.createElement("div");
@@ -13446,10 +13446,10 @@ ${heightStyle}
13446
13446
  if (typeof document === "undefined") {
13447
13447
  return 0;
13448
13448
  }
13449
- if (cached === void 0) {
13450
- cached = measureScrollbarSize();
13449
+ if (cached$1 === void 0) {
13450
+ cached$1 = measureScrollbarSize();
13451
13451
  }
13452
- return cached.width;
13452
+ return cached$1.width;
13453
13453
  }
13454
13454
  function getTargetScrollBarSize(target) {
13455
13455
  if (typeof document === "undefined" || !target || !(target instanceof Element)) {
@@ -78210,6 +78210,26 @@ html body {
78210
78210
  ] })
78211
78211
  ] });
78212
78212
  };
78213
+ let cached = null;
78214
+ const probe = () => {
78215
+ var _a2, _b2;
78216
+ if (typeof window === "undefined" || !window.WebGLRenderingContext) {
78217
+ return false;
78218
+ }
78219
+ try {
78220
+ const canvas = document.createElement("canvas");
78221
+ const ctx = canvas.getContext("webgl2") || canvas.getContext("webgl");
78222
+ if (!ctx || typeof ctx.getParameter !== "function") return false;
78223
+ (_b2 = (_a2 = ctx.getExtension) == null ? void 0 : _a2.call(ctx, "WEBGL_lose_context")) == null ? void 0 : _b2.loseContext();
78224
+ return true;
78225
+ } catch (e2) {
78226
+ return false;
78227
+ }
78228
+ };
78229
+ const isWebglSupported = () => {
78230
+ if (cached === null) cached = probe();
78231
+ return cached;
78232
+ };
78213
78233
  const POPUP_FIELDS = [
78214
78234
  "establishmentMeans",
78215
78235
  "degreeOfEstablishment",
@@ -78344,10 +78364,6 @@ html body {
78344
78364
  if (geojson.type === "FeatureCollection") return geojson.features || [];
78345
78365
  return [geojson];
78346
78366
  };
78347
- const supported = () => {
78348
- if (typeof (maplibregl == null ? void 0 : maplibregl.supported) === "function") return maplibregl.supported();
78349
- return typeof WebGLRenderingContext !== "undefined";
78350
- };
78351
78367
  const DistributionsMap = ({
78352
78368
  records,
78353
78369
  onUnmappable,
@@ -78361,7 +78377,9 @@ html body {
78361
78377
  gbifAvailable = true,
78362
78378
  // MapLibre style URL or inline style object; falls back to the global
78363
78379
  // `configure({ basemapStyle })` value. Changing it rebuilds the map.
78364
- basemapStyle
78380
+ basemapStyle,
78381
+ // Called from the no-WebGL notice to switch the host to its list view.
78382
+ onShowList
78365
78383
  }) => {
78366
78384
  var _a2;
78367
78385
  const containerRef = reactExports.useRef(null);
@@ -78374,6 +78392,7 @@ html body {
78374
78392
  const focalAttachedRef = reactExports.useRef(false);
78375
78393
  const gbifAttachedRef = reactExports.useRef(false);
78376
78394
  const descendantLayersRef = reactExports.useRef(/* @__PURE__ */ new Set());
78395
+ const [webglFailed, setWebglFailed] = reactExports.useState(false);
78377
78396
  const [readyMap, setReadyMap] = reactExports.useState(null);
78378
78397
  const [focalReady, setFocalReady] = reactExports.useState(false);
78379
78398
  const [descendantState, setDescendantState] = reactExports.useState({
@@ -78452,17 +78471,24 @@ html body {
78452
78471
  const styleKey = `${typeof styleSpec === "string" ? styleSpec : JSON.stringify(styleSpec)}|${cartoKey || ""}`;
78453
78472
  reactExports.useEffect(() => {
78454
78473
  if (!containerRef.current || mapRef.current) return;
78455
- if (!supported()) return;
78456
- const map = new maplibregl.Map({
78457
- container: containerRef.current,
78458
- style: styleSpec,
78459
- transformRequest: cartoTransformRequest(cartoKey),
78460
- center: [0, 20],
78461
- zoom: 1,
78462
- minZoom: 0,
78463
- attributionControl: false,
78464
- renderWorldCopies: true
78465
- });
78474
+ if (!isWebglSupported()) return;
78475
+ let map;
78476
+ try {
78477
+ map = new maplibregl.Map({
78478
+ container: containerRef.current,
78479
+ style: styleSpec,
78480
+ transformRequest: cartoTransformRequest(cartoKey),
78481
+ center: [0, 20],
78482
+ zoom: 1,
78483
+ minZoom: 0,
78484
+ attributionControl: false,
78485
+ renderWorldCopies: true
78486
+ });
78487
+ } catch (e2) {
78488
+ console.warn("Distribution map disabled:", e2);
78489
+ setWebglFailed(true);
78490
+ return;
78491
+ }
78466
78492
  map.addControl(
78467
78493
  new maplibregl.AttributionControl({ compact: true }),
78468
78494
  "bottom-right"
@@ -78807,8 +78833,8 @@ html body {
78807
78833
  return next2;
78808
78834
  });
78809
78835
  };
78810
- if (!supported()) {
78811
- return /* @__PURE__ */ jsxRuntimeExports.jsx(
78836
+ if (webglFailed || !isWebglSupported()) {
78837
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs(
78812
78838
  "div",
78813
78839
  {
78814
78840
  style: {
@@ -78819,7 +78845,15 @@ html body {
78819
78845
  color: "#666",
78820
78846
  fontSize: 12
78821
78847
  },
78822
- children: "Maps require WebGL, which your browser doesn't support."
78848
+ children: [
78849
+ /* @__PURE__ */ jsxRuntimeExports.jsx("strong", { children: "The distribution map can't be shown because WebGL is not available in your browser." }),
78850
+ " ",
78851
+ "This usually means hardware acceleration is turned off or the graphics drivers aren't set up for WebGL.",
78852
+ typeof onShowList === "function" && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
78853
+ " ",
78854
+ /* @__PURE__ */ jsxRuntimeExports.jsx("a", { onClick: onShowList, style: { cursor: "pointer" }, children: "Show distributions as a list" })
78855
+ ] })
78856
+ ]
78823
78857
  }
78824
78858
  );
78825
78859
  }
@@ -79201,7 +79235,9 @@ html body {
79201
79235
  const baseUnmappable = data.length - mappable.length;
79202
79236
  const hasGbifConfigured = !!gbifChecklistKey;
79203
79237
  const hasAnyRecords = data.length > 0;
79204
- const [view, setView] = reactExports.useState("map");
79238
+ const [view, setView] = reactExports.useState(
79239
+ () => isWebglSupported() ? "map" : "list"
79240
+ );
79205
79241
  const [fetchFailures, setFetchFailures] = reactExports.useState(0);
79206
79242
  const [gbifCount, setGbifCount] = reactExports.useState(null);
79207
79243
  reactExports.useEffect(() => {
@@ -79273,7 +79309,8 @@ html body {
79273
79309
  rankOrder,
79274
79310
  gbifChecklistKey,
79275
79311
  gbifAvailable,
79276
- basemapStyle
79312
+ basemapStyle,
79313
+ onShowList: showToggle ? () => setView("list") : void 0
79277
79314
  }
79278
79315
  ),
79279
79316
  showToggle && unmappable > 0 && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: { marginTop: 6 }, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("a", { onClick: () => setView("list"), style: { cursor: "pointer" }, children: [
@@ -88803,7 +88840,19 @@ Please report this to https://github.com/markedjs/marked.`, e2) {
88803
88840
  sourceId: get(info, "source.secondarySources['published in'].id")
88804
88841
  }
88805
88842
  ),
88806
- get(taxon, "name.publishedIn.citation")
88843
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "col-published-in", children: [
88844
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
88845
+ "span",
88846
+ {
88847
+ dangerouslySetInnerHTML: {
88848
+ __html: linkifyHtml(
88849
+ purify.sanitize(get(taxon, "name.publishedIn.citation"))
88850
+ )
88851
+ }
88852
+ }
88853
+ ),
88854
+ /* @__PURE__ */ jsxRuntimeExports.jsx(ReferenceLink, { reference: get(taxon, "name.publishedIn") })
88855
+ ] })
88807
88856
  ] }),
88808
88857
  get(taxon, "status") && /* @__PURE__ */ jsxRuntimeExports.jsxs(PresentationItem$1, { md, label: "Checklist status", children: [
88809
88858
  `${get(taxon, "status")} ${get(taxon, "name.rank")}`,