diff --git a/.dockerignore b/.dockerignore index 503e77f1..fe018eea 100644 --- a/.dockerignore +++ b/.dockerignore @@ -113,3 +113,7 @@ frontend/dist/ # --- Optional: keep small in-repo samples available to builds --- #!samples/** + +**/.viewer-browser-build/ +**/test-results/ +**/playwright-report/ diff --git a/.env.example b/.env.example index cd608d1f..24df13a8 100644 --- a/.env.example +++ b/.env.example @@ -258,3 +258,8 @@ ANALYTICS_PASSWORD= # Catalog relevance: v2 requires a completed source reindex; legacy is the default. SEARCH_RELEVANCE_VERSION=legacy + +# Local private MapLibre Native renderer (no public port required). +STATIC_MAP_RENDERER_URL=http://map_renderer:8080 +STATIC_MAP_RENDER_REVISION=openfreemap-positron-native-v1 +STATIC_MAP_STYLE_URL=https://tiles.openfreemap.org/styles/positron diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1d2c7b15..29ecdbe4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -104,7 +104,7 @@ jobs: - uses: actions/setup-python@v5 with: - python-version: "3.11" + python-version: "3.12" cache: pip cache-dependency-path: | backend/pyproject.toml @@ -112,8 +112,9 @@ jobs: - name: Install backend dependencies run: | - python -m pip install --upgrade pip - python -m pip install -e "backend[dev]" + python -m pip install uv + uv sync --project backend --locked --extra dev --python 3.12 + echo "$GITHUB_WORKSPACE/backend/.venv/bin" >> "$GITHUB_PATH" - name: Prepare backend test database working-directory: backend @@ -166,7 +167,7 @@ jobs: run: | python scripts/run_with_timeout.py \ python -X faulthandler -m pytest \ - -n 2 \ + -n 2 --dist=loadgroup \ -m "not network" \ --cov=app \ --cov-report=term-missing \ @@ -209,12 +210,41 @@ jobs: - name: Install frontend dependencies run: npm ci + - name: Check frontend lint and formatting + run: | + npm run lint + npm run format:check + - name: Run frontend tests run: npm test -- --run - name: Build frontend run: npm run build + viewer-browser: + name: Viewer browser contracts + # Keep the runner compatible with the pinned Playwright browser binaries. + runs-on: ubuntu-24.04 + timeout-minutes: 15 + defaults: + run: + working-directory: frontend + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: "22" + cache: npm + cache-dependency-path: frontend/package-lock.json + - run: npm ci + - run: npx playwright install --with-deps chromium + - run: npm run test:viewer:browser + - uses: actions/upload-artifact@v4 + if: failure() + with: + name: viewer-browser-failures + path: frontend/test-results/ + cli: name: CLI runs-on: ubuntu-latest diff --git a/Dockerfile b/Dockerfile index 40cc6d4c..8d541777 100644 --- a/Dockerfile +++ b/Dockerfile @@ -32,8 +32,10 @@ ENV PATH="/root/.local/bin:$PATH" # Copy backend pyproject.toml and uv.lock first to leverage Docker cache COPY backend/pyproject.toml backend/uv.lock ./ -## Frontend assets are served by the dedicated `frontend` container. -## The API container no longer bundles or serves frontend static files. +# API-only images also serve the browser module used by the standalone viewer. +COPY frontend/package-lock.json /tmp/frontend-package-lock.json +COPY backend/scripts/install_viewer_assets.py /tmp/install_viewer_assets.py +RUN python /tmp/install_viewer_assets.py /tmp/frontend-package-lock.json /opt/ogm-viewer # Ensure operational scripts are present in the runtime image (for kamal exec) COPY backend/scripts ./scripts diff --git a/Dockerfile.kamal b/Dockerfile.kamal index c6ed1774..9d219c7a 100644 --- a/Dockerfile.kamal +++ b/Dockerfile.kamal @@ -14,14 +14,12 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-ins g++ \ && rm -rf /var/lib/apt/lists/* COPY frontend/package.json frontend/package-lock.json* ./ -# Remove lockfile first to avoid npm optional deps edge-cases (mirrors frontend/Dockerfile). -RUN rm -f package-lock.json 2>/dev/null || true FROM frontend_npm_base AS frontend_deps -RUN npm install --legacy-peer-deps +RUN npm ci --legacy-peer-deps FROM frontend_npm_base AS frontend_prod_deps -RUN npm install --omit=dev --legacy-peer-deps +RUN npm ci --omit=dev --legacy-peer-deps FROM node:22-bookworm-slim AS frontend_builder WORKDIR /frontend diff --git a/Makefile b/Makefile index 3370db40..e525d748 100644 --- a/Makefile +++ b/Makefile @@ -1958,3 +1958,10 @@ analytics-evidence-check: ## Reproduce and verify evidence packets without chang SEARCH_RELEVANCE_TEST_URL ?= http://localhost:19283 test-search-relevance: ## Run isolated Elasticsearch 9 relevance contracts and unit tests cd backend && SEARCH_RELEVANCE_TEST_URL="$(SEARCH_RELEVANCE_TEST_URL)" BTAA_SKIP_TEST_DB=1 ENDPOINT_CACHE=false REDIS_DB=15 python -m pytest tests/elasticsearch/test_relevance.py tests/elasticsearch/test_relevance_integration.py tests/elasticsearch/test_relevance_postgres.py tests/scripts/test_reindex_relevance.py tests/services/test_bridge_search_index.py -q + +.PHONY: native-map-test native-map-start +native-map-start: ## Build and start the local MapLibre Native renderer + docker compose up -d --build map_renderer + +native-map-test: ## Run renderer camera tests in its compatible Linux image + docker compose exec -T map_renderer npm test diff --git a/backend/app/api/schemas.py b/backend/app/api/schemas.py index 01712a0f..0d72ae56 100644 --- a/backend/app/api/schemas.py +++ b/backend/app/api/schemas.py @@ -198,11 +198,15 @@ class DownloadOption(PublicAPIModel): generated: bool | None = None download_type: str | None = None generation_path: str | None = None + source: str | None = None + canvas_id: str | None = None + canvas_label: str | None = None class ResourceDownloadsResponse(PublicAPIModel): id: str downloads: list[DownloadOption] = Field(default_factory=list) + iiif_error: bool = False class GeneratedDownloadResponse(PublicAPIModel): diff --git a/backend/app/api/v1/endpoint_modules/resources/downloads.py b/backend/app/api/v1/endpoint_modules/resources/downloads.py index bdcd689a..4a7292b9 100644 --- a/backend/app/api/v1/endpoint_modules/resources/downloads.py +++ b/backend/app/api/v1/endpoint_modules/resources/downloads.py @@ -38,9 +38,23 @@ async def get_resource_downloads( download_service = DownloadService(resource_dict, distribution_context=distribution_context) downloads = await download_service.get_download_options_with_bridge_asset_downloads() + iiif_error = False + try: + iiif_downloads = await download_service.resolve_iiif_downloads() + if iiif_downloads: + # Replace provisional image links, retaining all non-IIIF downloads. + downloads = [d for d in downloads if d.get("source") != "iiif"] + existing_urls = {d["url"] for d in downloads} + downloads.extend( + d for d in iiif_downloads if d.get("canvas_id") or d["url"] not in existing_urls + ) + except ValueError: + iiif_error = True + response_payload = { "id": id, "downloads": downloads, + "iiif_error": iiif_error, } return create_response(response_payload, callback) diff --git a/backend/app/api/v1/endpoint_modules/resources/ogm_viewer.py b/backend/app/api/v1/endpoint_modules/resources/ogm_viewer.py index 72f50734..a046e2d1 100644 --- a/backend/app/api/v1/endpoint_modules/resources/ogm_viewer.py +++ b/backend/app/api/v1/endpoint_modules/resources/ogm_viewer.py @@ -1,11 +1,10 @@ -import html import os -from urllib.parse import quote from fastapi import HTTPException, Query from fastapi.responses import HTMLResponse from sqlalchemy.sql import select +from app.services.viewer_html import resource_viewer_html from db.models import resources from . import get_async_session, logger, router @@ -27,46 +26,8 @@ async def get_resource_viewer( if not row: raise HTTPException(status_code=404, detail="Resource not found") - # Build the record URL for the viewer base_url = os.getenv("APPLICATION_URL", "http://localhost:8000") - record_url = f"{base_url}/api/v1/resources/{quote(id, safe='')}/metadata/ogm" - escaped_record_url = html.escape(record_url, quote=True) - escaped_id = html.escape(id) - - # Create the HTML content - html_content = f""" - - - - - - OGM Viewer - Resource {escaped_id} - - - -
- - -
- - - - - -""" + html_content = resource_viewer_html(base_url, id, embed) # Create response with iframe-friendly headers response = HTMLResponse(content=html_content) diff --git a/backend/app/api/v1/endpoint_modules/static_maps.py b/backend/app/api/v1/endpoint_modules/static_maps.py index ca5e6da4..8d55af28 100644 --- a/backend/app/api/v1/endpoint_modules/static_maps.py +++ b/backend/app/api/v1/endpoint_modules/static_maps.py @@ -2,7 +2,7 @@ import logging import os -from fastapi import APIRouter, HTTPException, Request +from fastapi import APIRouter, HTTPException, Query, Request from fastapi.responses import Response from PIL import Image from sqlalchemy.sql import select @@ -207,9 +207,9 @@ async def _get_or_generate_map_data( async def get_institution_static_map( map_id: str, request: Request, - lat: float, - lon: float, - zoom: int = 15, + lat: float = Query(..., ge=-85.05112878, le=85.05112878, allow_inf_nan=False), + lon: float = Query(..., ge=-180, le=180, allow_inf_nan=False), + zoom: int = Query(15, ge=1, le=20), ): """Serve or generate a cached campus-centered static basemap image.""" cache_id = f"institution:{map_id}" diff --git a/backend/app/main.py b/backend/app/main.py index b844258c..a2a8c5e5 100644 --- a/backend/app/main.py +++ b/backend/app/main.py @@ -2,6 +2,7 @@ import os import sys from contextlib import asynccontextmanager +from pathlib import Path try: import appsignal @@ -319,6 +320,16 @@ async def private_analytics_responses(request: Request, call_next): return response +# The combined image and local frontend share the npm installation. API-only +# images keep the same locked browser distribution outside the source mount. +viewer_assets = Path("/opt/ogm-viewer") +if not viewer_assets.is_dir(): + viewer_assets = ( + Path(__file__).resolve().parents[2] / "frontend/node_modules/ogm-viewer/dist/components" + ) +if viewer_assets.is_dir(): + app.mount("/api/v1/viewer-assets", StaticFiles(directory=viewer_assets), name="viewer-assets") + app.include_router(public_router, prefix="/api/v1") app.include_router(ogc_router, prefix="/api/v1/ogc") diff --git a/backend/app/middleware/rate_limit_middleware.py b/backend/app/middleware/rate_limit_middleware.py index e390c161..6b95641b 100644 --- a/backend/app/middleware/rate_limit_middleware.py +++ b/backend/app/middleware/rate_limit_middleware.py @@ -32,6 +32,7 @@ def _bypass_rate_limit_for_tests() -> bool: r"^/api/v1/static-map-assets/[0-9a-f]{64}$", re.IGNORECASE, ) +VIEWER_MODULE_PATH_RE = re.compile(r"/api/v1/viewer-assets/[a-zA-Z0-9_-]+(?:\.[a-zA-Z0-9_-]+)*\.js") DOCUMENTATION_PATHS = { "/api/docs", "/api/docs/oauth2-redirect", @@ -71,6 +72,11 @@ def __init__(self, app): async def dispatch(self, request: Request, call_next): """Process request, optionally enforce rate limiting, and log usage.""" + # Loading the static ES module graph is a single viewer bootstrap. Its + # metadata and data requests still use the normal API quota. + if request.method in {"GET", "HEAD"} and VIEWER_MODULE_PATH_RE.fullmatch(request.url.path): + return await call_next(request) + # Skip rate limiting when test bypass flag is set, unless explicitly forced if _bypass_rate_limit_for_tests() and not request.headers.get("X-Force-RateLimit"): logger.debug("Rate limiting bypassed for tests (DISABLE_RATE_LIMIT_FOR_TESTS=true)") diff --git a/backend/app/services/download_service.py b/backend/app/services/download_service.py index 1fd5e7aa..07b60acc 100644 --- a/backend/app/services/download_service.py +++ b/backend/app/services/download_service.py @@ -118,34 +118,9 @@ def get_download_options(self) -> List[Dict]: if not self.image_api_endpoint: return [] - # Remove /info.json from endpoint if present - base_url = self.image_api_endpoint.replace("/info.json", "") + from app.services.iiif_downloads import image_downloads - downloads = [] - - # Add standard size options - for size_name, dimensions in self.SIZES.items(): - downloads.append( - { - "label": f"{size_name.title()} Image", - "url": ( - f"{base_url}/full/{dimensions['width']}," - f"{dimensions['height']}/0/default.jpg" - ), - "type": "image/jpeg", - } - ) - - # Add full size option - downloads.append( - { - "label": "Full Resolution Image", - "url": f"{base_url}/full/full/0/default.jpg", - "type": "image/jpeg", - } - ) - - return downloads + return image_downloads(self.image_api_endpoint) class DownloadService: @@ -359,7 +334,7 @@ def get_download_options(self) -> List[Dict]: downloads = [] # Check for IIIF image API - iiif_image_url = self._first_url("http://iiif.io/api/image") + iiif_image_url = self._iiif_url("image") if iiif_image_url: iiif_service = IIIFDownloadService(iiif_image_url) downloads.extend(iiif_service.get_download_options()) @@ -370,6 +345,49 @@ def get_download_options(self) -> List[Dict]: return downloads + def _iiif_url(self, kind: str) -> Optional[str]: + return self._first_url(f"http://iiif.io/api/{kind}") or self._first_url( + f"https://iiif.io/api/{kind}" + ) + + async def resolve_iiif_downloads(self) -> List[Dict]: + """Resolve remote IIIF only on the downloads endpoint, outside hot resource/search paths.""" + from urllib.parse import urlsplit, urlunsplit + + from app.services.iiif_downloads import ( + http_url, + image_downloads, + manifest_downloads, + service_base, + ) + from app.services.image_service import ImageService + + manifest_url = self._iiif_url("presentation#manifest") + image_url = self._iiif_url("image") + if not manifest_url and not image_url: + return [] + image_service = ImageService(self.document, distribution_context=self.distribution_context) + downloads = [] + resolved = False + if http_url(manifest_url): + manifest = await asyncio.to_thread(image_service._get_manifest, manifest_url) + if isinstance(manifest, dict): + resolved = True + downloads.extend(manifest_downloads(manifest, manifest_url)) + if http_url(image_url): + base = urlsplit(service_base(image_url)) + info_url = urlunsplit(base._replace(path=f"{base.path}/info.json")) + info = await asyncio.to_thread(image_service._get_manifest, info_url) + if isinstance(info, dict): + resolved = True + downloads.extend( + {**item, "iiif_resource_url": image_url} + for item in image_downloads(image_url, info) + ) + if resolved: + return downloads + raise ValueError("IIIF downloads are currently unavailable") + def get_generated_download_options(self) -> List[Dict]: """ Return generated download links that mirror GeoBlacklight behavior. diff --git a/backend/app/services/iiif_downloads.py b/backend/app/services/iiif_downloads.py new file mode 100644 index 00000000..12c31a9f --- /dev/null +++ b/backend/app/services/iiif_downloads.py @@ -0,0 +1,231 @@ +"""Pure IIIF download extraction; never fetch individual canvases or image services.""" + +import math +import re +from urllib.parse import urlsplit, urlunsplit + + +def objects(value): + return [ + item for item in (value if isinstance(value, list) else [value]) if isinstance(item, dict) + ] + + +def http_url(value): + if not isinstance(value, str): + return None + try: + parsed = urlsplit(value) + if parsed.scheme in ("http", "https") and parsed.hostname and not parsed.username: + return value + except ValueError: + # Skip malformed image identifiers while processing the rest of the manifest. + return None + return None + + +def identifier(value): + return http_url(value.get("id") or value.get("@id")) + + +def label(value, fallback): + if isinstance(value, str) and value.strip(): + return re.sub(r"<[^>]+>", "", value).strip() or fallback + if isinstance(value, list): + return next((label(item, "") for item in value if label(item, "")), fallback) + if isinstance(value, dict): + if "@value" in value: + return label(value["@value"], fallback) + for language in ("en", "none", *value): + text = label(value.get(language), "") + if text: + return text + return fallback + + +def positive(value): + return ( + isinstance(value, (int, float)) + and not isinstance(value, bool) + and math.isfinite(value) + and value > 0 + ) + + +def service_base(url): + """Normalize info.json and image requests without losing encoded identifiers/query strings.""" + parsed = urlsplit(url) + path = parsed.path.rstrip("/") + path = re.sub(r"/info\.json$", "", path) + path = re.sub( + r"/(?:full|square|pct:[\d.,]+|\d+,\d+,\d+,\d+)/[^/]+/!?[\d.]+/[^/]+\.[a-zA-Z0-9]+$", + "", + path, + ) + return urlunsplit(parsed._replace(path=path, fragment="")) + + +def image_request(base, size, quality="default"): + parsed = urlsplit(base) + return urlunsplit(parsed._replace(path=f"{parsed.path}/full/{size}/0/{quality}.jpg")) + + +def option(name, url, mime="image/jpeg", **metadata): + return {"label": name, "url": url, "type": mime, "format": mime, "source": "iiif", **metadata} + + +def image_downloads(url, service=None, body=None): + """Use declared version, compliance and limits; width-only sizes preserve aspect ratio.""" + if not http_url(url): + return [] + service = service or {} + body = body or {} + base = service_base(url) + signature = str([service.get("type"), service.get("@context"), service.get("profile")]) + version = 3 if "ImageService3" in signature or "/image/3/" in signature else 2 + if "/image/1" in signature or "/image-api/1" in signature or "ImageService1" in signature: + version = 1 + quality = "native" if version == 1 else "default" + limits = {**service} + for profile in objects(service.get("profile")): + limits.update(profile) + width = service.get("width") or body.get("width") + height = service.get("height") or body.get("height") + scale = 1.0 + if positive(width) and positive(height): + max_width = limits.get("maxWidth") + max_height = limits.get("maxHeight") or max_width + max_area = limits.get("maxArea") + if positive(max_width): + scale = min(scale, max_width / width) + if positive(max_height): + scale = min(scale, max_height / height) + if positive(max_area): + scale = min(scale, math.sqrt(max_area / (width * height))) + + downloads = [] + seen = set() + + def add(name, size): + link = image_request(base, size, quality) + if link not in seen: + downloads.append(option(name, link, image_source=base)) + seen.add(link) + elif name == "Largest Available Image": + next(download for download in downloads if download["url"] == link)["label"] = name + + if "level0" in signature: + for size in objects(service.get("sizes")): + if positive(size.get("width")) and positive(size.get("height")): + w, h = int(size["width"]), int(size["height"]) + add(f"Image ({w} × {h})", f"{w},{h}" if version == 3 else f"{w},") + else: + for name, bound in (("Thumb", 150), ("Small", 800), ("Medium", 1200), ("Large", 2000)): + # Width syntax is required at level 1; !w,h is only required at level 2. + w = bound + if positive(width) and positive(height): + w = max(1, int(width * min(scale, bound / max(width, height)))) + add(f"{name} Image", f"{w},") + + if version == 3 or (version == 2 and "level0" in signature and scale < 1): + add("Largest Available Image", "max") + elif scale < 1 and positive(width): + add("Largest Available Image", f"{max(1, int(width * scale))},") + else: + add("Full Resolution Image", "full") + return downloads + + +def renderings(node, **metadata): + result = [] + for rendering in objects(node.get("rendering")): + url = identifier(rendering) + if url: + mime = rendering.get("format") or "application/octet-stream" + result.append( + option(label(rendering.get("label"), "Download file"), url, mime, **metadata) + ) + return result + + +def image_bodies(value): + for body in objects(value): + kind = body.get("type") or body.get("@type") + if kind in ("Choice", "oa:Choice"): + yield from image_bodies(body.get("default")) + yield from image_bodies(body.get("items") or body.get("item")) + elif kind == "SpecificResource": + yield from image_bodies(body.get("source")) + elif kind in ("Image", "dctypes:Image") or str(body.get("format", "")).startswith("image/"): + yield body + + +def manifest_downloads(manifest, manifest_url): + """Read v2's sequences or v3's ordered canvases and their painting images.""" + if not isinstance(manifest, dict): + return [] + downloads = renderings(manifest) + sequences = objects(manifest.get("sequences")) + canvases = ( + [canvas for sequence in sequences for canvas in objects(sequence.get("canvases"))] + if sequences + else objects(manifest.get("items")) + ) + occurrences = {} + for index, canvas in enumerate(canvases, 1): + metadata = { + "canvas_id": identifier(canvas) or f"{manifest_url}#canvas-{index}", + "canvas_label": label(canvas.get("label"), f"Page {index}"), + } + downloads.extend(renderings(canvas, **metadata)) + annotations = objects(canvas.get("images")) + for page in objects(canvas.get("items")): + annotations.extend(objects(page.get("items"))) + bodies = [] + for annotation in annotations: + motivation = annotation.get("motivation", "painting") + motivations = motivation if isinstance(motivation, list) else [motivation] + if not any(m in ("painting", "sc:painting") for m in motivations): + continue + bodies.extend(image_bodies(annotation.get("body") or annotation.get("resource"))) + for number, body in enumerate(bodies, 1): + services = objects(body.get("service")) + images = [] + for service in services: + signature = str( + [service.get("type"), service.get("@context"), service.get("profile")] + ) + if "ImageService" not in signature and "/image/" not in signature: + continue + url = identifier(service) + if url: + images = image_downloads(url, service, body) + break + if not images and identifier(body): + images = [ + option( + "Download Image", + identifier(body), + body.get("format") or "image/jpeg", + image_source=identifier(body), + ) + ] + source = images[0]["image_source"] if images else None + occurrence = occurrences.get(source, 0) + if source: + occurrences[source] = occurrence + 1 + for image in images: + image["image_occurrences"] = [occurrence] + if len(bodies) > 1: + image["label"] = f"Image {number}: {image['label']}" + downloads.append({**image, **metadata}) + seen = {} + unique = [] + for download in downloads: + key = (download.get("canvas_id"), download["url"]) + if key not in seen: + unique.append({**download, "iiif_resource_url": manifest_url}) + seen[key] = unique[-1] + elif download.get("image_occurrences"): + seen[key].setdefault("image_occurrences", []).extend(download["image_occurrences"]) + return unique diff --git a/backend/app/services/mcp_service.py b/backend/app/services/mcp_service.py index 610ed45a..9a17831f 100644 --- a/backend/app/services/mcp_service.py +++ b/backend/app/services/mcp_service.py @@ -20,6 +20,7 @@ from sqlalchemy import func, select from app.services.search_service import SearchService +from app.services.viewer_html import resource_viewer_html from app.version import APP_VERSION from db.models import resources from db.session import async_session as app_async_session @@ -678,44 +679,7 @@ async def _get_resource_viewer(self, arguments: Dict[str, Any]) -> CallToolResul resource_id = arguments["id"] embed = arguments.get("embed", False) - # Build the record URL for the viewer - base_url = self._public_api_base() - record_url = f"{base_url}/api/v1/resources/{resource_id}/metadata" - - # Create the HTML content - html_content = f""" - - - - - - OGM Viewer - Resource {resource_id} - - - -
- - -
- - - - - -""" + html_content = resource_viewer_html(self._public_api_base(), resource_id, embed) return CallToolResult( content=[ diff --git a/backend/app/services/native_static_maps.py b/backend/app/services/native_static_maps.py new file mode 100644 index 00000000..54a8aca3 --- /dev/null +++ b/backend/app/services/native_static_maps.py @@ -0,0 +1,216 @@ +"""Optional private MapLibre renderer; storage remains in StaticMapService.""" + +import hashlib +import io +import json +import os +import time +import uuid + +import requests +from PIL import Image + +from app.services.visual_asset_cache import ( + cache_visual_asset, + durable_visual_asset_enabled, + get_durable_visual_asset, + get_durable_visual_asset_hash_for_resource, + get_durable_visual_asset_hash_for_signature, +) + + +def renderer_url(): + return os.getenv("STATIC_MAP_RENDERER_URL", "http://map_renderer:8080").rstrip("/") + + +def revision(): + # Bump when styles, tiles, fonts, or renderer settings change. + return os.getenv("STATIC_MAP_RENDER_REVISION", "openfreemap-positron-native-v1") + + +def signature(value): + return hashlib.sha256( + json.dumps( + [ + revision(), + os.getenv("STATIC_MAP_STYLE_URL", "https://tiles.openfreemap.org/styles/positron"), + "maplibre-native-6.4.1", + value, + ], + sort_keys=True, + ).encode() + ).hexdigest() + + +def _generate_uncached( + service, + resource_id, + geometry=None, + *, + overlay=True, + center=None, + zoom=None, + source_signature=None, + hydrate_asset=True, +): + spec = {"width": service.map_width, "height": service.map_height} + no_geometry = False + if center is not None: + spec.update(center=center, leafletZoom=zoom) + else: + bounds = service._parse_geometry_to_bbox(geometry) + # Preserve dateline-crossing envelopes rather than interpreting them as missing data. + import re + + if isinstance(geometry, str) and geometry.strip().upper().startswith("ENVELOPE"): + values = re.findall(r"[-+]?(?:\d*\.)?\d+(?:[eE][-+]?\d+)?", geometry) + if len(values) == 4: + west, east, north, south = map(float, values) + if -180 <= east < west <= 180: + bounds = (west, south, east + 360, north) + no_geometry = not bounds or service._is_global_bbox(bounds) + if no_geometry: + spec.update(center=[0, 0], leafletZoom=1) + elif bounds[0] == bounds[2] and bounds[1] == bounds[3]: + spec.update( + center=[bounds[0], max(-85.05112878, min(85.05112878, bounds[1]))], leafletZoom=12 + ) + else: + west, south, east, north = bounds + south = max(-85.05112878, min(85.05112878, south)) + north = max(-85.05112878, min(85.05112878, north)) + # Flat lines and polar extents still need an area for camera fitting. + if east - west < 0.001: + west, east = west - 0.001, east + 0.001 + if north - south < 0.001: + south, north = max(-85.05112878, south - 0.001), min(85.05112878, north + 0.001) + bounds = (west, south, east, north) + spec["bounds"] = list(bounds) + if overlay and not no_geometry: + geojson = service._geometry_to_geojson_dict(geometry) + if geojson is None: + w, s, e, n = bounds + geojson = { + "type": "Polygon", + "coordinates": [[[w, s], [e, s], [e, n], [w, n], [w, s]]], + } + spec["geometry"] = geojson + for attempt in range(3): + response = requests.post(renderer_url() + "/render", json=spec, timeout=(5, 75)) + if response.status_code not in (429, 503) or attempt == 2: + break + time.sleep(3 * (attempt + 1)) + response.raise_for_status() + data = response.content + if not data.startswith(b"\x89PNG\r\n\x1a\n"): + raise ValueError("Renderer did not return PNG") + with Image.open(io.BytesIO(data)) as image: + if image.size != (service.map_width, service.map_height): + raise ValueError("Renderer returned incorrect dimensions") + image.verify() + if overlay and no_geometry: + image = service._overlay_no_data_symbol(Image.open(io.BytesIO(data))) + output = io.BytesIO() + image.save(output, "PNG") + data = output.getvalue() + variant = service.geometry_variant() if overlay else service.basemap_variant() + source_signature = source_signature or service.geometry_signature(geometry) + digest = service.materialize_asset_sync( + resource_id, + variant=variant, + map_bytes=data, + source_signature=source_signature, + hydrate_asset=hydrate_asset, + ) + if not digest or ( + durable_visual_asset_enabled() and get_durable_visual_asset(digest) != (data, "image/png") + ): + raise RuntimeError("Could not persist rendered asset") + if ( + durable_visual_asset_enabled() + and not resource_id.startswith("institution:") + and ( + get_durable_visual_asset_hash_for_resource( + resource_id, asset_kind=variant, source_signature=source_signature + ) + != digest + ) + ): + raise RuntimeError("Could not link rendered asset") + if hydrate_asset: + # materialize_asset_sync already guarantees durable storage or a usable + # hot asset. Mutable-key hydration must not hide a committed image. + cache_visual_asset( + service.map_cache, + service._cache_key(resource_id, variant=variant, source_signature=source_signature), + data, + ) + return data + + +def reuse_geometry( + service, resource_id, geometry, *, overlay=True, source_signature=None, hydrate_asset=True +): + variant = service.geometry_variant() if overlay else service.basemap_variant() + source_signature = source_signature or service.geometry_signature(geometry) + digest = get_durable_visual_asset_hash_for_signature(variant, source_signature) + if not digest: + return None + data = service.get_cached_asset_sync(digest) + if not data: + return None + linked = service.materialize_asset_sync( + resource_id, + variant=variant, + map_bytes=data, + source_signature=source_signature, + hydrate_asset=hydrate_asset, + ) + if ( + linked != digest + or get_durable_visual_asset_hash_for_resource( + resource_id, asset_kind=variant, source_signature=source_signature + ) + != digest + ): + raise RuntimeError("Could not link reusable map") + return data + + +def generate(service, resource_id, geometry=None, **kwargs): + # Campus cameras use a separate identity and do not have resource foreign keys. + if resource_id.startswith("institution:") or kwargs.get("center") is not None: + return _generate_uncached(service, resource_id, geometry, **kwargs) + reuse_args = { + key: kwargs[key] + for key in ("overlay", "source_signature", "hydrate_asset") + if key in kwargs + } + data = reuse_geometry(service, resource_id, geometry, **reuse_args) + if data: + return data + sig = kwargs.get("source_signature") or service.geometry_signature(geometry) + kind = service.geometry_variant() if kwargs.get("overlay", True) else service.basemap_variant() + lock = f"native-render:{kind}:{sig}" + token = uuid.uuid4().hex + if not service.map_cache.set(lock, token, nx=True, ex=120): + raise RuntimeError("Identical geometry is already rendering; retry") + try: + # Another worker may have finished between the first lookup and locking. + data = reuse_geometry(service, resource_id, geometry, **reuse_args) + return data or _generate_uncached(service, resource_id, geometry, **kwargs) + finally: + service.map_cache.eval( + "if redis.call('get',KEYS[1]) == ARGV[1] then " + "return redis.call('del',KEYS[1]) else return 0 end", + 1, + lock, + token, + ) + + +def pregenerate_thumbnail(resource_id, geometry, *, hydrate_asset=True): + from app.services.static_map_service import StaticMapService + + service = StaticMapService(384, 288) + return generate(service, resource_id, geometry, hydrate_asset=hydrate_asset) diff --git a/backend/app/services/static_map_service.py b/backend/app/services/static_map_service.py index ace7b98a..51c5e60a 100644 --- a/backend/app/services/static_map_service.py +++ b/backend/app/services/static_map_service.py @@ -1,7 +1,7 @@ """ Service for generating static maps from resource geometries. -This service uses py-staticmaps to generate static map images from locn_geometry values. +This service uses the private MapLibre Native renderer for geographic PNGs. Maps are stored in Redis (like thumbnails) for sharing between containers. """ @@ -13,20 +13,22 @@ import math import os import re -from typing import Any, Callable, Dict, List, Optional, Tuple +from typing import Any, Dict, Optional, Tuple import cairo import redis -import staticmaps from dotenv import load_dotenv from PIL import Image from shapely import wkt as shapely_wkt from shapely.geometry import shape +from app.services import native_static_maps from app.services.visual_asset_cache import ( cache_visual_asset, + durable_visual_asset_enabled, get_durable_visual_asset, get_durable_visual_asset_hash_for_resource, + has_durable_visual_asset, redis_operation_with_loading_retry, store_durable_visual_asset, store_durable_visual_asset_link, @@ -39,35 +41,6 @@ WEB_MERCATOR_MAX_LATITUDE = 85.05112878 -OPENSTREETMAP_TILE_PROVIDER = staticmaps.TileProvider( - "openstreetmap-standard", - url_pattern="https://tile.openstreetmap.org/$z/$x/$y.png", - attribution=("(C) OpenStreetMap contributors - https://www.openstreetmap.org/copyright"), - max_zoom=19, -) -STATIC_MAP_TILE_USER_AGENT = "BTAA-Geospatial-Data-API/1.0 (+https://geo.btaa.org/)" - - -class _WebMercatorLine(staticmaps.Line): - """Render source segments directly instead of replacing them with geodesics. - - py-staticmaps projects tiles and coordinates with Web Mercator, but its Line - implementation first interpolates segments of at least one degree longitude - along WGS84 geodesics. Leaflet projects the supplied GeoJSON vertices and - connects them directly, so the interpolation makes the same geometry appear - bowed or loop around the antimeridian in static maps. - """ - - def interpolate(self) -> List[Any]: - return self._latlngs - - -class _WebMercatorArea(staticmaps.Area): - """Area counterpart to _WebMercatorLine with direct projected segments.""" - - def interpolate(self) -> List[Any]: - return self._latlngs - class StaticMapService: """Service for generating static maps from bounding boxes.""" @@ -239,7 +212,7 @@ def _bbox_within_web_mercator( self, bbox_coords: Tuple[float, float, float, float], ) -> bool: - """Return True when full geometry can be handed to staticmaps safely.""" + """Return True when full geometry can be projected safely.""" _xmin, ymin, _xmax, ymax = bbox_coords return ymin >= -WEB_MERCATOR_MAX_LATITUDE and ymax <= WEB_MERCATOR_MAX_LATITUDE @@ -314,17 +287,8 @@ def _extract_bbox_from_geojson( logger.error(f"Error extracting bbox from GeoJSON: {e}") return None - # Match show page (LocationMap) styling: #2563eb, fill ~3%, stroke 0.6, weight 2 - _FILL_COLOR = staticmaps.Color(37, 99, 235, 13) # ~3% opacity (lighter than original 10%) - _STROKE_COLOR = staticmaps.Color(37, 99, 235, 217) # ~85% opacity - _STROKE_GLOW_COLOR = staticmaps.Color( - 37, 99, 235, 51 - ) # ~20% so inward bleed doesn't darken fill - _STROKE_GLOW_WIDTH = 5 - _LINE_WIDTH = 3 - _TRANSPARENT_COLOR = staticmaps.Color(0, 0, 0, 0) - _MAP_VARIANT = "static_map_v10" - _BASEMAP_VARIANT = "static_basemap_v8" + _MAP_VARIANT = "native_geometry_v1" + _BASEMAP_VARIANT = "native_basemap_v1" _ASSET_KEY_PREFIX = "static_map_asset" _ALIAS_KEY_PREFIX = "static_map_alias" _HASH_RE = re.compile(r"^[0-9a-f]{64}$", re.IGNORECASE) @@ -376,48 +340,6 @@ def _overlay_no_data_symbol(self, image: Image.Image) -> Image.Image: overlay.alpha_composite(icon, (icon_x, icon_y)) return Image.alpha_composite(rendered, overlay) - def _map_context(self) -> staticmaps.Context: - """Build a map context using the same OpenStreetMap layer as the frontend.""" - context = staticmaps.Context() - context.set_tile_provider(OPENSTREETMAP_TILE_PROVIDER) - # py-staticmaps has no public Context setter for its downloader user agent. - context._tile_downloader.set_user_agent(STATIC_MAP_TILE_USER_AGENT) - return context - - def _global_map_context(self) -> staticmaps.Context: - """Build the shared world-view context for all no-geometry map variants.""" - context = self._map_context() - context.set_center(staticmaps.create_latlng(0, 0)) - context.set_zoom(1) - return context - - def _bbox_points(self, bbox_coords: Tuple[float, float, float, float]) -> list: - """Convert bbox coords into a closed polygon usable by py-staticmaps.""" - xmin, ymin, xmax, ymax = bbox_coords - return [ - staticmaps.create_latlng(ymin, xmin), - staticmaps.create_latlng(ymax, xmin), - staticmaps.create_latlng(ymax, xmax), - staticmaps.create_latlng(ymin, xmax), - staticmaps.create_latlng(ymin, xmin), - ] - - def _bbox_area( - self, - bbox_coords: Tuple[float, float, float, float], - *, - fill_color: Any, - color: Any, - width: int, - ) -> Any: - """Create a py-staticmaps polygon for the bbox.""" - return _WebMercatorArea( - self._bbox_points(bbox_coords), - fill_color=fill_color, - color=color, - width=width, - ) - def _cache_key( self, resource_id: str, @@ -426,9 +348,8 @@ def _cache_key( source_signature: str | None = None, ) -> str: """Build Redis key for a map variant.""" - if source_signature: - return f"{variant}:{source_signature}:{resource_id}" - return f"{variant}:{resource_id}" + signature = source_signature or self.current_render_signature() + return f"{variant}:{signature}:{resource_id}" def _asset_key(self, map_hash: str) -> str: return f"{self._ASSET_KEY_PREFIX}:{map_hash}" @@ -440,9 +361,13 @@ def _alias_key( variant: str, source_signature: str | None = None, ) -> str: - if source_signature: - return f"{self._ALIAS_KEY_PREFIX}:{variant}:{source_signature}:{resource_id}" - return f"{self._ALIAS_KEY_PREFIX}:{variant}:{resource_id}" + signature = source_signature or self.current_render_signature() + return f"{self._ALIAS_KEY_PREFIX}:{variant}:{signature}:{resource_id}" + + @staticmethod + def current_render_signature() -> str: + # Resource-only redirects must also expire when the basemap style changes. + return native_static_maps.signature("current-resource-render") def _is_asset_hash(self, value: str | None) -> bool: return bool(value and self._HASH_RE.fullmatch(value)) @@ -473,6 +398,12 @@ def _alias_cache(self): logger.warning(f"Failed to initialize Redis alias cache for static maps: {e}") return None + @staticmethod + def campus_asset_hash(resource_id: str, variant: str, source_signature: str | None) -> str: + """Stable campus camera identity without a resource-table foreign key.""" + value = json.dumps([resource_id, variant, source_signature], separators=(",", ":")) + return hashlib.sha256(value.encode()).hexdigest() + def geometry_variant(self) -> str: return self._MAP_VARIANT @@ -496,7 +427,14 @@ def geometry_signature(self, geometry: Any) -> str: separators=(",", ":"), default=str, ) - return hashlib.sha256(normalized.encode("utf-8")).hexdigest() + return ( + native_static_maps.signature( + [normalized, self.map_width, self.map_height] + + (["compact-credits-v1"] if self.map_width < 500 else []) + ) + if native_static_maps.renderer_url() + else hashlib.sha256(normalized.encode("utf-8")).hexdigest() + ) def centered_basemap_signature(self, *, latitude: float, longitude: float, zoom: int) -> str: """Return a stable content signature for a campus-centered basemap request.""" @@ -509,7 +447,11 @@ def centered_basemap_signature(self, *, latitude: float, longitude: float, zoom: sort_keys=True, separators=(",", ":"), ) - return hashlib.sha256(payload.encode("utf-8")).hexdigest() + return ( + native_static_maps.signature([payload, self.map_width, self.map_height]) + if native_static_maps.renderer_url() + else hashlib.sha256(payload.encode("utf-8")).hexdigest() + ) def get_asset_hash_sync( self, @@ -527,10 +469,13 @@ def get_asset_hash_sync( if hot_hash: return hot_hash + if resource_id.startswith("institution:"): + return None + value = get_durable_visual_asset_hash_for_resource( resource_id, asset_kind=variant, - source_signature=source_signature, + source_signature=source_signature or self.current_render_signature(), ) if value and self._is_asset_hash(value): if not hydrate_asset: @@ -695,20 +640,19 @@ async def delete_asset_hash( ) def has_cached_asset_sync(self, map_hash: str) -> bool: - if not self.map_cache or not self._is_asset_hash(map_hash): + if not self._is_asset_hash(map_hash): return False - - try: - asset_key = self._asset_key(map_hash) - return bool( - redis_operation_with_loading_retry( + if self.map_cache: + try: + asset_key = self._asset_key(map_hash) + if redis_operation_with_loading_retry( lambda: self.map_cache.exists(asset_key), operation_name=f"check static map asset {asset_key}", - ) - ) - except Exception as e: - logger.error(f"Error checking cached static map asset {map_hash}: {e}") - return False + ): + return True + except Exception as exc: + logger.warning("Redis asset check failed: %s", type(exc).__name__) + return has_durable_visual_asset(map_hash) async def has_cached_asset(self, map_hash: str) -> bool: return await asyncio.to_thread(self.has_cached_asset_sync, map_hash) @@ -761,28 +705,35 @@ def materialize_asset_sync( if not map_bytes: return None + is_campus = resource_id.startswith("institution:") map_hash = self._asset_hash(map_bytes) - if hydrate_asset: - self.cache_asset_sync(map_hash, map_bytes) - store_durable_visual_asset( + stored = store_durable_visual_asset( map_hash, asset_kind=variant, content_type=self._asset_content_type(map_bytes), body=map_bytes, ) - store_durable_visual_asset_link( - resource_id, - asset_hash=map_hash, - asset_kind=variant, - source_signature=source_signature, - ) - if source_signature: - store_durable_visual_asset_link( + if durable_visual_asset_enabled() and not stored: + return None + if stored and not is_campus: + if not store_durable_visual_asset_link( resource_id, asset_hash=map_hash, asset_kind=variant, - source_signature=None, - ) + source_signature=source_signature or self.current_render_signature(), + ): + return None + if source_signature and not store_durable_visual_asset_link( + resource_id, + asset_hash=map_hash, + asset_kind=variant, + source_signature=self.current_render_signature(), + ): + return None + if hydrate_asset: + cached = self.cache_asset_sync(map_hash, map_bytes) + if not stored and not cached: + return None self.set_asset_hash_sync( resource_id, variant=variant, @@ -888,165 +839,6 @@ async def materialize_cached_variant( hydrate_asset=hydrate_asset, ) - def _geojson_to_staticmaps_objects( - self, - geojson: Dict[str, Any], - *, - fill_color: Any | None = None, - stroke_color: Any | None = None, - width: int | None = None, - include_glow: bool = True, - ) -> Optional[List[Any]]: - """ - Convert GeoJSON geometry to py-staticmaps Area/Line objects (best geometry). - Matches show page style: polygon fill + stroke, line stroke. - When include_glow=False (e.g. basemap variant), skip glow layers so no bbox/border is drawn. - Returns None if geometry is not a supported GeoJSON type or parsing fails. - """ - if not isinstance(geojson, dict): - return None - geom_type = geojson.get("type") - coordinates = geojson.get("coordinates") - if not coordinates: - return None - - objects: List[Any] = [] - fill_color = self._FILL_COLOR if fill_color is None else fill_color - stroke_color = self._STROKE_COLOR if stroke_color is None else stroke_color - width = self._LINE_WIDTH if width is None else width - - def coord_to_latlngs(coord_list: list) -> list: - """GeoJSON coords are [lon, lat]; create_latlng(lat, lon).""" - return [staticmaps.create_latlng(float(lat), float(lon)) for lon, lat in coord_list] - - try: - if geom_type == "Point": - if len(coordinates) < 2: - return None - lon, lat = float(coordinates[0]), float(coordinates[1]) - marker_size = 10 if include_glow else 0 - objects.append( - staticmaps.Marker( - staticmaps.create_latlng(lat, lon), - color=stroke_color, - size=marker_size, - ) - ) - - elif geom_type == "Polygon": - # coordinates: [ exterior_ring, hole1, ... ]; ring is [ [lon,lat], ... ] - for ring in coordinates: - if len(ring) < 3: - continue - points = coord_to_latlngs(ring) - # Close ring (GeoJSON may list first point once at end; ensure closed) - if len(points) > 1: - points.append(points[0]) - # Glow layer first (when requested), then main area - if include_glow: - glow_area = _WebMercatorArea( - points, - fill_color=self._TRANSPARENT_COLOR, - color=self._STROKE_GLOW_COLOR, - width=self._STROKE_GLOW_WIDTH, - ) - objects.append(glow_area) - area = _WebMercatorArea( - points, - fill_color=fill_color, - color=stroke_color, - width=width, - ) - objects.append(area) - - elif geom_type == "MultiPolygon": - # coordinates: [ polygon1, ... ]; each polygon is [ ring1, ring2, ... ] - for polygon_rings in coordinates: - for ring in polygon_rings: - if len(ring) < 3: - continue - points = coord_to_latlngs(ring) - if len(points) > 1: - points.append(points[0]) - if include_glow: - glow_area = _WebMercatorArea( - points, - fill_color=self._TRANSPARENT_COLOR, - color=self._STROKE_GLOW_COLOR, - width=self._STROKE_GLOW_WIDTH, - ) - objects.append(glow_area) - area = _WebMercatorArea( - points, - fill_color=fill_color, - color=stroke_color, - width=width, - ) - objects.append(area) - # Show full extent with a bbox rectangle (show page uses dashed; py-staticmaps - # has no dashed stroke, so we draw it solid) - bbox = self._extract_bbox_from_geojson(geojson) - if bbox: - extent_points = self._bbox_points(bbox) - if include_glow: - glow_line = _WebMercatorLine( - extent_points, - color=self._STROKE_GLOW_COLOR, - width=self._STROKE_GLOW_WIDTH, - ) - objects.append(glow_line) - extent_line = _WebMercatorLine( - extent_points, - color=stroke_color, - width=width, - ) - objects.append(extent_line) - - elif geom_type == "LineString": - if len(coordinates) < 2: - return None - points = coord_to_latlngs(coordinates) - if include_glow: - glow_line = _WebMercatorLine( - points, - color=self._STROKE_GLOW_COLOR, - width=self._STROKE_GLOW_WIDTH, - ) - objects.append(glow_line) - line = _WebMercatorLine( - points, - color=stroke_color, - width=width, - ) - objects.append(line) - - elif geom_type == "MultiLineString": - for line_coords in coordinates: - if len(line_coords) < 2: - continue - points = coord_to_latlngs(line_coords) - if include_glow: - glow_line = _WebMercatorLine( - points, - color=self._STROKE_GLOW_COLOR, - width=self._STROKE_GLOW_WIDTH, - ) - objects.append(glow_line) - line = _WebMercatorLine( - points, - color=stroke_color, - width=width, - ) - objects.append(line) - - else: - return None - - return objects if objects else None - except (IndexError, TypeError, ValueError) as e: - logger.debug(f"Could not convert GeoJSON to staticmaps objects: {e}") - return None - def _geometry_to_geojson_dict(self, geometry: Any) -> Optional[Dict[str, Any]]: """If geometry is or parses to a GeoJSON geometry dict, return it; else None.""" if ( @@ -1084,110 +876,6 @@ def _geometry_to_geojson_dict(self, geometry: Any) -> Optional[Dict[str, Any]]: ) return None - def _render_and_cache( - self, - context: Any, - resource_id: str, - *, - variant: str = "static_map", - source_signature: str | None = None, - post_process: Callable[[Image.Image], Image.Image] | None = None, - render_width: int | None = None, - render_height: int | None = None, - hydrate_asset: bool = True, - ) -> Optional[bytes]: - """Render context to PNG bytes and persist it. Returns bytes or None.""" - render_width = render_width or self.map_width - render_height = render_height or self.map_height - try: - logger.debug(f"Rendering map for resource {resource_id} (this requires tile downloads)") - cairo_surface = context.render_cairo(render_width, render_height) - buf = io.BytesIO() - cairo_surface.write_to_png(buf) - buf.seek(0) - image = Image.open(buf) - except Exception as e: - error_msg = str(e).lower() - if any( - keyword in error_msg - for keyword in ["connection", "timeout", "network", "unreachable", "refused"] - ): - logger.error( - f"Network error rendering map for resource {resource_id}: {e}\n" - "This may indicate that outbound HTTP traffic is blocked by a firewall.\n" - "The static map service requires outbound access to tile servers.\n" - "Run scripts/debug_static_map.py on the server to diagnose network issues." - ) - else: - logger.warning(f"Failed to render with cairo, trying pillow: {e}") - try: - image = context.render_pillow(render_width, render_height) - except Exception as pillow_error: - error_msg = str(pillow_error).lower() - if any( - keyword in error_msg - for keyword in [ - "connection", - "timeout", - "network", - "unreachable", - "refused", - ] - ): - logger.error( - f"Network error rendering map with pillow for resource " - f"{resource_id}: {pillow_error}\n" - "This may indicate that outbound HTTP traffic is blocked " - "by a firewall.\n" - "The static map service requires outbound access to " - "tile servers.\n" - "Run scripts/debug_static_map.py on the server to " - "diagnose network issues." - ) - else: - logger.error(f"Both cairo and pillow rendering failed: {pillow_error}") - raise - if image.size != (self.map_width, self.map_height): - image = image.resize((self.map_width, self.map_height), Image.Resampling.LANCZOS) - if post_process is not None: - image = post_process(image) - buf = io.BytesIO() - image.save(buf, "PNG") - map_bytes = buf.getvalue() - if self.map_cache and hydrate_asset: - try: - map_key = self._cache_key( - resource_id, - variant=variant, - source_signature=source_signature, - ) - cache_visual_asset(self.map_cache, map_key, map_bytes) - except Exception as e: - logger.error(f"Failed to cache mutable {variant} key for {resource_id}: {e}") - return None - elif hydrate_asset: - logger.warning("Redis not available, cannot cache mutable static map key") - - if not self.materialize_asset_sync( - resource_id, - variant=variant, - map_bytes=map_bytes, - source_signature=source_signature, - hydrate_asset=hydrate_asset, - ): - logger.error("Failed to persist %s for resource %s", variant, resource_id) - return None - - action = "cached" if hydrate_asset else "persisted without Redis asset hydration" - logger.info( - "Generated and %s %s for resource %s (size: %s bytes)", - action, - variant, - resource_id, - len(map_bytes), - ) - return map_bytes - def generate_map( self, resource_id: str, @@ -1208,97 +896,14 @@ def generate_map( Returns: PNG image bytes if successful, None if generation failed """ - try: - # Parse bbox for skip-global check and for fallback rectangle - bbox_coords = self._parse_geometry_to_bbox(geometry) - if not bbox_coords: - logger.warning(f"Could not parse geometry for resource {resource_id}") - return self.generate_global_map( - resource_id, - source_signature=source_signature or self.geometry_signature(None), - hydrate_asset=hydrate_asset, - ) - - # Skip global datasets (they don't make good static maps) - if self._is_global_bbox(bbox_coords): - logger.debug(f"Skipping global dataset for resource {resource_id}") - return self.generate_global_map( - resource_id, - source_signature=source_signature or self.geometry_signature(None), - hydrate_asset=hydrate_asset, - ) - - # Prefer best geometry only when every coordinate is inside the - # renderable Web Mercator latitude range. Staticmaps' center/zoom - # math raises at/near the poles, so polar records use the clamped - # bbox fallback below. - geojson_dict = self._geometry_to_geojson_dict(geometry) - if ( - geojson_dict is None - and bbox_coords[0] == bbox_coords[2] - and bbox_coords[1] == bbox_coords[3] - ): - geojson_dict = { - "type": "Point", - "coordinates": [bbox_coords[0], bbox_coords[1]], - } - map_objects = ( - self._geojson_to_staticmaps_objects(geojson_dict) - if geojson_dict and self._bbox_within_web_mercator(bbox_coords) - else None - ) - render_bbox = self._renderable_bbox(bbox_coords) - if not render_bbox and not map_objects: - logger.debug( - "Using global map for unrenderable Web-Mercator bbox on %s: %s", - resource_id, - bbox_coords, - ) - return self.generate_global_map( - resource_id, - source_signature=source_signature or self.geometry_signature(None), - hydrate_asset=hydrate_asset, - ) - - # Create a context for the map - context = self._map_context() - - if map_objects: - # Use best geometry: actual polygons/lines (same style as show page) - for obj in map_objects: - context.add_object(obj) - else: - # Fallback: bbox rectangle only (e.g. ENVELOPE or dcat_bbox string) - # Glow layer first, then main rectangle - glow_rect = self._bbox_area( - render_bbox, - fill_color=self._TRANSPARENT_COLOR, - color=self._STROKE_GLOW_COLOR, - width=self._STROKE_GLOW_WIDTH, - ) - rectangle = self._bbox_area( - render_bbox, - fill_color=self._FILL_COLOR, - color=self._STROKE_COLOR, - width=self._LINE_WIDTH, - ) - context.add_object(glow_rect) - context.add_object(rectangle) - - # Render and cache (requires outbound HTTP for tiles) - return self._render_and_cache( - context, - resource_id, - variant=self._MAP_VARIANT, - source_signature=source_signature or self.geometry_signature(geometry), - hydrate_asset=hydrate_asset, - ) - - except Exception as e: - logger.error( - f"Error generating static map for resource {resource_id}: {e}", exc_info=True - ) - return None + return native_static_maps.generate( + self, + resource_id, + geometry, + overlay=True, + source_signature=source_signature, + hydrate_asset=hydrate_asset, + ) def generate_global_map( self, @@ -1311,24 +916,14 @@ def generate_global_map( Generate a world-view static map (no bbox) for resources with no geometry. Uses the same tile layer and cache key as generate_map. """ - try: - context = self._global_map_context() - return self._render_and_cache( - context, - resource_id, - variant=self._MAP_VARIANT, - source_signature=source_signature or self.geometry_signature(None), - post_process=self._overlay_no_data_symbol, - render_width=512, - render_height=512, - hydrate_asset=hydrate_asset, - ) - except Exception as e: - logger.error( - f"Error generating global static map for resource {resource_id}: {e}", - exc_info=True, - ) - return None + return native_static_maps.generate( + self, + resource_id, + None, + overlay=True, + source_signature=source_signature, + hydrate_asset=hydrate_asset, + ) def generate_basemap( self, @@ -1341,79 +936,14 @@ def generate_basemap( """ Generate a basemap-only image using the resource extent with no visible geometry overlay. """ - try: - bbox_coords = self._parse_geometry_to_bbox(geometry) - if not bbox_coords: - logger.warning(f"Could not parse geometry for basemap {resource_id}") - return self.generate_global_basemap( - resource_id, - source_signature=source_signature or self.geometry_signature(None), - hydrate_asset=hydrate_asset, - ) - - if self._is_global_bbox(bbox_coords): - return self.generate_global_basemap( - resource_id, - source_signature=source_signature or self.geometry_signature(None), - hydrate_asset=hydrate_asset, - ) - - geojson_dict = self._geometry_to_geojson_dict(geometry) - if ( - geojson_dict is None - and bbox_coords[0] == bbox_coords[2] - and bbox_coords[1] == bbox_coords[3] - ): - geojson_dict = { - "type": "Point", - "coordinates": [bbox_coords[0], bbox_coords[1]], - } - extent_objects = ( - self._geojson_to_staticmaps_objects( - geojson_dict, - fill_color=self._TRANSPARENT_COLOR, - stroke_color=self._TRANSPARENT_COLOR, - width=self._LINE_WIDTH, - include_glow=False, - ) - if geojson_dict and self._bbox_within_web_mercator(bbox_coords) - else None - ) - render_bbox = self._renderable_bbox(bbox_coords) - if not render_bbox and not extent_objects: - logger.debug( - "Using global basemap for unrenderable Web-Mercator bbox on %s: %s", - resource_id, - bbox_coords, - ) - return self.generate_global_basemap( - resource_id, - source_signature=source_signature or self.geometry_signature(None), - hydrate_asset=hydrate_asset, - ) - - context = self._map_context() - if extent_objects: - for obj in extent_objects: - context.add_object(obj) - else: - invisible_extent = self._bbox_area( - render_bbox, - fill_color=self._TRANSPARENT_COLOR, - color=self._TRANSPARENT_COLOR, - width=self._LINE_WIDTH, - ) - context.add_object(invisible_extent) - return self._render_and_cache( - context, - resource_id, - variant=self._BASEMAP_VARIANT, - source_signature=source_signature or self.geometry_signature(geometry), - hydrate_asset=hydrate_asset, - ) - except Exception as e: - logger.error(f"Error generating basemap for resource {resource_id}: {e}", exc_info=True) - return None + return native_static_maps.generate( + self, + resource_id, + geometry, + overlay=False, + source_signature=source_signature, + hydrate_asset=hydrate_asset, + ) def generate_global_basemap( self, @@ -1423,23 +953,14 @@ def generate_global_basemap( hydrate_asset: bool = True, ) -> Optional[bytes]: """Generate a world-view basemap image with no geometry overlay.""" - try: - context = self._global_map_context() - return self._render_and_cache( - context, - resource_id, - variant=self._BASEMAP_VARIANT, - source_signature=source_signature or self.geometry_signature(None), - render_width=512, - render_height=512, - hydrate_asset=hydrate_asset, - ) - except Exception as e: - logger.error( - f"Error generating global basemap for resource {resource_id}: {e}", - exc_info=True, - ) - return None + return native_static_maps.generate( + self, + resource_id, + None, + overlay=False, + source_signature=source_signature, + hydrate_asset=hydrate_asset, + ) def generate_centered_basemap( self, @@ -1451,34 +972,15 @@ def generate_centered_basemap( source_signature: str | None = None, ) -> Optional[bytes]: """Generate a basemap centered on a specific lat/lon at a fixed zoom.""" - try: - if not (-90 <= latitude <= 90) or not (-180 <= longitude <= 180): - logger.warning( - "Invalid campus basemap coordinates for %s", - resource_id, - ) - return None - - context = self._map_context() - context.set_center(staticmaps.create_latlng(latitude, longitude)) - context.set_zoom(max(1, min(int(zoom), OPENSTREETMAP_TILE_PROVIDER.max_zoom()))) - return self._render_and_cache( - context, - resource_id, - variant=self._BASEMAP_VARIANT, - source_signature=source_signature - or self.centered_basemap_signature( - latitude=latitude, - longitude=longitude, - zoom=zoom, - ), - ) - except Exception as e: - logger.error( - f"Error generating centered basemap for resource {resource_id}: {e}", - exc_info=True, - ) - return None + return native_static_maps.generate( + self, + resource_id, + overlay=False, + center=[longitude, latitude], + zoom=zoom, + source_signature=source_signature + or self.centered_basemap_signature(latitude=latitude, longitude=longitude, zoom=zoom), + ) async def get_cached_map( self, diff --git a/backend/app/services/viewer_html.py b/backend/app/services/viewer_html.py new file mode 100644 index 00000000..eaa93177 --- /dev/null +++ b/backend/app/services/viewer_html.py @@ -0,0 +1,45 @@ +import html +from urllib.parse import quote + + +def resource_viewer_html(base_url: str, resource_id: str, embed: bool) -> str: + base_url = base_url.rstrip("/").removesuffix("/api/v1") + record_url = f"{base_url}/api/v1/resources/{quote(resource_id, safe='')}/metadata/ogm" + escaped_record_url = html.escape(record_url, quote=True) + escaped_id = html.escape(resource_id) + + script_url = html.escape(f"{base_url}/api/v1/viewer-assets/ogm-viewer.js", quote=True) + + return f""" + + + + + + OGM Viewer - Resource {escaped_id} + + + +
+ + +
+ + + + + +""" diff --git a/backend/app/services/visual_asset_cache.py b/backend/app/services/visual_asset_cache.py index 6ea91390..a3eeed54 100644 --- a/backend/app/services/visual_asset_cache.py +++ b/backend/app/services/visual_asset_cache.py @@ -288,3 +288,25 @@ def get_legacy_thumbnail(resource_id: str, source_url: str) -> tuple[bytes, str] except Exception as exc: logger.warning("Failed to read legacy thumbnail for %s: %s", resource_id, exc) return None + + +def get_durable_visual_asset_hash_for_signature( + asset_kind: str, source_signature: str +) -> str | None: + """Find reusable render bytes without tying identity to a catalog record.""" + if not durable_visual_asset_enabled() or not source_signature: + return None + stmt = ( + select(generated_visual_asset_links.c.asset_hash) + .where( + generated_visual_asset_links.c.asset_kind == asset_kind, + generated_visual_asset_links.c.source_signature == source_signature, + ) + .limit(1) + ) + with _sync_engine().connect() as conn: + return conn.execute(stmt).scalar_one_or_none() + + +def has_durable_visual_asset(asset_hash: str) -> bool: + return get_durable_visual_asset(asset_hash) is not None diff --git a/backend/app/tasks/static_maps.py b/backend/app/tasks/static_maps.py index fbde16a9..1b9692a8 100644 --- a/backend/app/tasks/static_maps.py +++ b/backend/app/tasks/static_maps.py @@ -2,7 +2,7 @@ Celery tasks for generating static maps from resource bounding boxes. This module contains background tasks for generating static map images -from dcat_bbox values using py-staticmaps. +from resource geometries using MapLibre Native. """ import asyncio diff --git a/backend/pyproject.toml b/backend/pyproject.toml index 4c44b53f..1201a403 100644 --- a/backend/pyproject.toml +++ b/backend/pyproject.toml @@ -55,7 +55,6 @@ dependencies = [ "pandas>=2.3.0", "mcp>=1.28.1", "user-agents>=2.2.0", - "py-staticmaps[cairo]>=0.4.0", "rio-tiler>=8.0.0", "pmtiles>=3.0.0", "mapbox-vector-tile>=2.0.0", diff --git a/backend/scripts/install_viewer_assets.py b/backend/scripts/install_viewer_assets.py new file mode 100644 index 00000000..e385b2a5 --- /dev/null +++ b/backend/scripts/install_viewer_assets.py @@ -0,0 +1,31 @@ +"""Install the locked OGM Viewer browser modules for an API-only image.""" + +import base64 +import hashlib +import io +import json +import sys +import tarfile +from pathlib import Path, PurePosixPath +from urllib.request import urlopen + + +def install(lockfile: Path, destination: Path) -> None: + package = json.loads(lockfile.read_text())["packages"]["node_modules/ogm-viewer"] + with urlopen(package["resolved"], timeout=90) as response: + archive = response.read() + integrity = base64.b64encode(hashlib.sha512(archive).digest()).decode("ascii") + if package["integrity"] != f"sha512-{integrity}": + raise ValueError("OGM Viewer archive does not match the frontend lockfile") + + destination.mkdir(parents=True, exist_ok=True) + with tarfile.open(fileobj=io.BytesIO(archive), mode="r:gz") as tar: + for member in tar.getmembers(): + path = PurePosixPath(member.name) + if member.isfile() and path.parent == PurePosixPath("package/dist/components"): + with tar.extractfile(member) as source: + (destination / path.name).write_bytes(source.read()) + + +if __name__ == "__main__": + install(Path(sys.argv[1]), Path(sys.argv[2])) diff --git a/backend/tests/api/v1/test_endpoint_modules_resources_extra.py b/backend/tests/api/v1/test_endpoint_modules_resources_extra.py index f97c52bc..3f4843bb 100644 --- a/backend/tests/api/v1/test_endpoint_modules_resources_extra.py +++ b/backend/tests/api/v1/test_endpoint_modules_resources_extra.py @@ -50,7 +50,7 @@ async def test_list_resources_success(monkeypatch): # Two fake rows rows = [make_row({"id": "r1"}), make_row({"id": "r2"})] - res.async_session = lambda: DummySession(fetchall_rows=rows) + monkeypatch.setattr(res, "async_session", lambda: DummySession(fetchall_rows=rows)) async def fake_process_resource(resource_dict, session): return {"id": resource_dict["id"], "type": "resource", "attributes": resource_dict} @@ -87,7 +87,7 @@ async def test_get_resource_found(monkeypatch): from app.api.v1.endpoint_modules import resources as res row = make_row({"id": "r1"}) - res.async_session = lambda: DummySession(fetchone_row=row) + monkeypatch.setattr(res, "async_session", lambda: DummySession(fetchone_row=row)) async def fake_process_resource(resource_dict, session): return {"id": resource_dict["id"], "type": "resource", "attributes": resource_dict} @@ -120,7 +120,7 @@ async def test_get_resource_homepage_profile_uses_lightweight_processor(monkeypa from app.api.v1.endpoint_modules import resources as res row = make_row({"id": "r1"}) - res.async_session = lambda: DummySession(fetchone_row=row) + monkeypatch.setattr(res, "async_session", lambda: DummySession(fetchone_row=row)) async def unexpected_full_process(resource_dict, session): raise AssertionError("full resource processor should not run for homepage profile") @@ -162,7 +162,7 @@ async def test_get_resource_not_found(monkeypatch): from app.api.v1.endpoint_modules import resources as res - res.async_session = lambda: DummySession(fetchone_row=None) + monkeypatch.setattr(res, "async_session", lambda: DummySession(fetchone_row=None)) class DummyRequest: def __init__(self): @@ -186,7 +186,7 @@ async def test_get_resource_error(monkeypatch): from app.api.v1.endpoint_modules import resources as res row = make_row({"id": "r1"}) - res.async_session = lambda: DummySession(fetchone_row=row) + monkeypatch.setattr(res, "async_session", lambda: DummySession(fetchone_row=row)) async def raise_process(resource_dict, session): raise Exception("processing") @@ -213,7 +213,7 @@ async def test_get_resource_ogm_success(monkeypatch): from app.api.v1.endpoint_modules import resources as res row = make_row({"id": "r1", "empty": "", "arr": [None, ""], "ok": ["x"]}) - res.async_session = lambda: DummySession(fetchone_row=row) + monkeypatch.setattr(res, "async_session", lambda: DummySession(fetchone_row=row)) class FakeMapper: @staticmethod @@ -232,7 +232,7 @@ async def test_get_resource_ogm_not_found(monkeypatch): from app.api.v1.endpoint_modules import resources as res - res.async_session = lambda: DummySession(fetchone_row=None) + monkeypatch.setattr(res, "async_session", lambda: DummySession(fetchone_row=None)) with pytest.raises(HTTPException) as exc: await res.get_resource_ogm("x", callback=None) assert exc.value.status_code == 404 @@ -247,18 +247,18 @@ async def test_get_resource_viewer_found(monkeypatch): from app.api.v1.endpoint_modules import resources as res row = make_row({"id": "r1"}) - res.async_session = lambda: DummySession(fetchone_row=row) + monkeypatch.setattr(res, "async_session", lambda: DummySession(fetchone_row=row)) resp = await res.get_resource_viewer("r1", embed=False) # HTMLResponse assert hasattr(resp, "body") - assert b"ogm-viewer" in resp.body + assert b'/api/v1/viewer-assets/ogm-viewer.js"' in resp.body @pytest.mark.asyncio async def test_get_resource_viewer_not_found(monkeypatch): from app.api.v1.endpoint_modules import resources as res - res.async_session = lambda: DummySession(fetchone_row=None) + monkeypatch.setattr(res, "async_session", lambda: DummySession(fetchone_row=None)) from fastapi import HTTPException with pytest.raises(HTTPException) as exc: @@ -272,7 +272,7 @@ async def test_get_resource_viewer_error(monkeypatch): from app.api.v1.endpoint_modules import resources as res - res.async_session = lambda: DummySession(raise_on="execute") + monkeypatch.setattr(res, "async_session", lambda: DummySession(raise_on="execute")) with pytest.raises(HTTPException) as exc: await res.get_resource_viewer("r1", embed=False) assert exc.value.status_code == 500 @@ -283,7 +283,7 @@ async def test_get_resource_spatial_facets_exists(monkeypatch): from app.api.v1.endpoint_modules import resources as res row = make_row({"id": "r1", "dcat_bbox": "BOX(0 0,1 1)"}) - res.async_session = lambda: DummySession(fetchone_row=row) + monkeypatch.setattr(res, "async_session", lambda: DummySession(fetchone_row=row)) class FakeSpatial: def __init__(self, rd): @@ -320,7 +320,7 @@ def url(self): async def test_get_resource_spatial_facets_missing(monkeypatch): from app.api.v1.endpoint_modules import resources as res - res.async_session = lambda: DummySession(fetchone_row=None) + monkeypatch.setattr(res, "async_session", lambda: DummySession(fetchone_row=None)) class DummyRequest: def __init__(self): @@ -350,7 +350,7 @@ def url(self): async def test_get_resource_spatial_facets_error(monkeypatch): from app.api.v1.endpoint_modules import resources as res - res.async_session = lambda: DummySession(raise_on="execute") + monkeypatch.setattr(res, "async_session", lambda: DummySession(raise_on="execute")) from fastapi import HTTPException class DummyRequest: diff --git a/backend/tests/api/v1/test_endpoint_modules_search_extra.py b/backend/tests/api/v1/test_endpoint_modules_search_extra.py index 7696ca61..045d18b7 100644 --- a/backend/tests/api/v1/test_endpoint_modules_search_extra.py +++ b/backend/tests/api/v1/test_endpoint_modules_search_extra.py @@ -102,7 +102,7 @@ async def __aenter__(self): async def __aexit__(self, exc_type, exc, tb): pass - se.async_session = lambda: DummySession() + monkeypatch.setattr(se, "async_session", lambda: DummySession()) resp = await se.search(DummyRequest(), q="a", page=1, per_page=10, sort=None, callback=None) assert hasattr(resp, "body") diff --git a/backend/tests/api/v1/test_resource_endpoints.py b/backend/tests/api/v1/test_resource_endpoints.py index 295c042d..1ba30cc7 100644 --- a/backend/tests/api/v1/test_resource_endpoints.py +++ b/backend/tests/api/v1/test_resource_endpoints.py @@ -247,7 +247,7 @@ def test_viewer_endpoint_success_response(): assert "/api/v1/resources/stanford-wt473hz7153/metadata/ogm" in content # Should load the OGM viewer script - assert "https://unpkg.com/ogm-viewer" in content + assert "/api/v1/viewer-assets/ogm-viewer.js" in content elif response.status_code == 500: # Database connection issues are acceptable in test environment diff --git a/backend/tests/elasticsearch/test_client.py b/backend/tests/elasticsearch/test_client.py index c7d1b088..47375165 100644 --- a/backend/tests/elasticsearch/test_client.py +++ b/backend/tests/elasticsearch/test_client.py @@ -15,7 +15,11 @@ load_dotenv(".env.test") # Get the test index name from environment variables -TEST_INDEX_NAME = os.getenv("ELASTICSEARCH_INDEX", "data_api_test") +TEST_INDEX_NAME = ( + os.getenv("ELASTICSEARCH_INDEX", "data_api_test") + + "_client_" + + os.getenv("PYTEST_XDIST_WORKER", "serial") +) # Use the ELASTICSEARCH_URL from .env file or default to localhost ELASTICSEARCH_URL = os.getenv("ELASTICSEARCH_URL", "http://localhost:9200") @@ -114,6 +118,7 @@ async def test_init_elasticsearch_success(es_client, monkeypatch): """Test successful initialization of Elasticsearch.""" # Monkeypatch the global ES client to use our test client monkeypatch.setattr(es_client_mod, "es", es_client) + monkeypatch.setenv("ELASTICSEARCH_INDEX", TEST_INDEX_NAME) try: # Call the function @@ -136,6 +141,7 @@ async def test_init_elasticsearch_index_exists(es_client, monkeypatch): """Test initialization when index already exists.""" # Monkeypatch the global ES client to use our test client monkeypatch.setattr(es_client_mod, "es", es_client) + monkeypatch.setenv("ELASTICSEARCH_INDEX", TEST_INDEX_NAME) try: # Delete the index if it exists diff --git a/backend/tests/fixtures/iiif_atlas_463.json b/backend/tests/fixtures/iiif_atlas_463.json new file mode 100644 index 00000000..635e9b81 --- /dev/null +++ b/backend/tests/fixtures/iiif_atlas_463.json @@ -0,0 +1,136 @@ +{ + "@context": "http://iiif.io/api/presentation/2/context.json", + "@id": "https://cdm16022.contentdm.oclc.org/iiif/p16022coll231:13073/manifest.json", + "sequences": [ + { + "canvases": [ + { + "@id": "https://cdm16022.contentdm.oclc.org/iiif/p16022coll231:13006/canvas/c0", + "@type": "sc:Canvas", + "label": "Page 1", + "images": [ + { + "@id": "https://cdm16022.contentdm.oclc.org/iiif/p16022coll231:13006/annotation/a0", + "@type": "oa:Annotation", + "motivation": "sc:painting", + "resource": { + "@id": "https://cdm16022.contentdm.oclc.org/iiif/2/p16022coll231:13006/full/full/0/default.jpg", + "@type": "dctypes:Image", + "service": { + "@context": "http://iiif.io/api/image/2/context.json", + "@id": "https://cdm16022.contentdm.oclc.org/iiif/2/p16022coll231:13006", + "width": 3542, + "height": 3971, + "tiles": [ + { + "width": 3542, + "scaleFactors": [ + 1, + 2, + 4, + 8, + 16 + ] + } + ], + "profile": "http://iiif.io/api/image/2/level1.json", + "protocol": "http://iiif.io/api/image" + }, + "format": "image/jpeg", + "width": 3542, + "height": 3971 + }, + "on": "https://cdm16022.contentdm.oclc.org/iiif/p16022coll231:13006/canvas/c0" + } + ], + "width": 3542, + "height": 3971 + }, + { + "@id": "https://cdm16022.contentdm.oclc.org/iiif/p16022coll231:13007/canvas/c1", + "@type": "sc:Canvas", + "label": "Page 2", + "images": [ + { + "@id": "https://cdm16022.contentdm.oclc.org/iiif/p16022coll231:13007/annotation/a1", + "@type": "oa:Annotation", + "motivation": "sc:painting", + "resource": { + "@id": "https://cdm16022.contentdm.oclc.org/iiif/2/p16022coll231:13007/full/full/0/default.jpg", + "@type": "dctypes:Image", + "service": { + "@context": "http://iiif.io/api/image/2/context.json", + "@id": "https://cdm16022.contentdm.oclc.org/iiif/2/p16022coll231:13007", + "width": 2833, + "height": 3966, + "tiles": [ + { + "width": 2833, + "scaleFactors": [ + 1, + 2, + 4, + 8, + 16 + ] + } + ], + "profile": "http://iiif.io/api/image/2/level1.json", + "protocol": "http://iiif.io/api/image" + }, + "format": "image/jpeg", + "width": 2833, + "height": 3966 + }, + "on": "https://cdm16022.contentdm.oclc.org/iiif/p16022coll231:13007/canvas/c1" + } + ], + "width": 2833, + "height": 3966 + }, + { + "@id": "https://cdm16022.contentdm.oclc.org/iiif/p16022coll231:13072/canvas/c66", + "@type": "sc:Canvas", + "label": "Page 67", + "images": [ + { + "@id": "https://cdm16022.contentdm.oclc.org/iiif/p16022coll231:13072/annotation/a66", + "@type": "oa:Annotation", + "motivation": "sc:painting", + "resource": { + "@id": "https://cdm16022.contentdm.oclc.org/iiif/2/p16022coll231:13072/full/full/0/default.jpg", + "@type": "dctypes:Image", + "service": { + "@context": "http://iiif.io/api/image/2/context.json", + "@id": "https://cdm16022.contentdm.oclc.org/iiif/2/p16022coll231:13072", + "width": 2836, + "height": 3966, + "tiles": [ + { + "width": 2836, + "scaleFactors": [ + 1, + 2, + 4, + 8, + 16 + ] + } + ], + "profile": "http://iiif.io/api/image/2/level1.json", + "protocol": "http://iiif.io/api/image" + }, + "format": "image/jpeg", + "width": 2836, + "height": 3966 + }, + "on": "https://cdm16022.contentdm.oclc.org/iiif/p16022coll231:13072/canvas/c66" + } + ], + "width": 2836, + "height": 3966 + } + ] + } + ] +} diff --git a/backend/tests/fixtures/iiif_peace_463.json b/backend/tests/fixtures/iiif_peace_463.json new file mode 100644 index 00000000..187f2658 --- /dev/null +++ b/backend/tests/fixtures/iiif_peace_463.json @@ -0,0 +1,52 @@ +{ + "@context": "http://iiif.io/api/presentation/2/context.json", + "@id": "https://cdm16022.contentdm.oclc.org/iiif/p16022coll230:2973/manifest.json", + "sequences": [ + { + "canvases": [ + { + "@id": "https://cdm16022.contentdm.oclc.org/iiif/p16022coll230:2973/canvas/c0", + "@type": "sc:Canvas", + "label": "Peace map of Europe : July 4, 1918", + "images": [ + { + "@id": "https://cdm16022.contentdm.oclc.org/iiif/p16022coll230:2973/annotation/a0", + "@type": "oa:Annotation", + "motivation": "sc:painting", + "resource": { + "@id": "https://cdm16022.contentdm.oclc.org/iiif/2/p16022coll230:2973/full/full/0/default.jpg", + "@type": "dctypes:Image", + "service": { + "@context": "http://iiif.io/api/image/2/context.json", + "@id": "https://cdm16022.contentdm.oclc.org/iiif/2/p16022coll230:2973", + "width": 8318, + "height": 7460, + "tiles": [ + { + "width": 8318, + "scaleFactors": [ + 1, + 2, + 4, + 8, + 16 + ] + } + ], + "profile": "http://iiif.io/api/image/2/level1.json", + "protocol": "http://iiif.io/api/image" + }, + "format": "image/jpeg", + "width": 8318, + "height": 7460 + }, + "on": "https://cdm16022.contentdm.oclc.org/iiif/p16022coll230:2973/canvas/c0" + } + ], + "width": 8318, + "height": 7460 + } + ] + } + ] +} diff --git a/backend/tests/middleware/test_rate_limit_integration.py b/backend/tests/middleware/test_rate_limit_integration.py index 78bf8f39..d43c134e 100644 --- a/backend/tests/middleware/test_rate_limit_integration.py +++ b/backend/tests/middleware/test_rate_limit_integration.py @@ -6,7 +6,7 @@ import pytest from fastapi import FastAPI -from fastapi.responses import JSONResponse +from fastapi.responses import JSONResponse, Response from fastapi.testclient import TestClient from app.middleware.rate_limit_middleware import RateLimitMiddleware @@ -24,6 +24,10 @@ async def test_endpoint(): async def thumbnail_asset(image_hash: str): return JSONResponse({"image_hash": image_hash}) + @app.get("/api/v1/viewer-assets/{name}") + async def viewer_asset(name: str): + return Response("export {};", media_type="text/javascript") + @app.get("/api/docs") async def docs(): return JSONResponse({"docs": True}) @@ -196,6 +200,12 @@ def test_immutable_thumbnail_asset_bypasses_rate_limit(self, rate_limited_client assert second.status_code == 200 assert "X-RateLimit-Limit" not in first.headers + def test_viewer_modules_do_not_consume_data_quota(self, rate_limited_client): + for name in ("ogm-viewer.js", "p-BcGs8Z_L.js", "LercDecode.es.js"): + assert rate_limited_client.get(f"/api/v1/viewer-assets/{name}").status_code == 200 + assert rate_limited_client.get("/api/v1/test-endpoint").status_code == 200 + assert rate_limited_client.get("/api/v1/test-endpoint").status_code == 429 + def test_documentation_routes_bypass_rate_limit(self, rate_limited_client): """Docs and OpenAPI schema should not consume the interactive API quota.""" diff --git a/backend/tests/services/test_cache_service.py b/backend/tests/services/test_cache_service.py index 88c321b0..4e94cf60 100644 --- a/backend/tests/services/test_cache_service.py +++ b/backend/tests/services/test_cache_service.py @@ -585,6 +585,7 @@ def test_generate_cache_key_with_special_characters(self): self._assert_cache_key_shape(key, namespace="test_prefix") +@pytest.mark.xdist_group(name="cache_service_edge_cases") class TestCacheServiceEdgeCases: """Test cases for edge cases and error conditions.""" @@ -594,6 +595,8 @@ async def test_get_with_empty_key(self): service = CacheService() try: + if service._redis_client: + await service._redis_client.delete("") result = await service.get("") assert result is None except Exception as e: @@ -612,6 +615,8 @@ async def test_set_with_empty_key(self): try: result = await service.set("", {"data": "test"}) assert isinstance(result, bool) + if result and service._redis_client: + await service._redis_client.delete("") except Exception as e: # Handle Redis connection errors gracefully assert ( diff --git a/backend/tests/services/test_download_service.py b/backend/tests/services/test_download_service.py index c1a9592f..cd7fa835 100644 --- a/backend/tests/services/test_download_service.py +++ b/backend/tests/services/test_download_service.py @@ -113,7 +113,7 @@ def test_get_download_options(self): # Verify thumb option thumb = next(opt for opt in options if opt["label"] == "Thumb Image") - assert thumb["url"] == "https://example.com/iiif/image/full/150,150/0/default.jpg" + assert thumb["url"] == "https://example.com/iiif/image/full/150,/0/default.jpg" assert thumb["type"] == "image/jpeg" # Verify full option diff --git a/backend/tests/services/test_iiif_downloads.py b/backend/tests/services/test_iiif_downloads.py new file mode 100644 index 00000000..02cd9e26 --- /dev/null +++ b/backend/tests/services/test_iiif_downloads.py @@ -0,0 +1,318 @@ +"""IIIF shapes and regressions from public examples in issue #463.""" + +import json +from pathlib import Path +from unittest.mock import patch + +import pytest + +from app.services.download_service import DownloadService +from app.services.iiif_downloads import image_downloads, manifest_downloads, service_base + +BASE = "https://example.org/iiif/image" +MANIFEST = "https://example.org/manifest" + + +def v3_manifest(body, **canvas_fields): + return { + "items": [ + { + "id": f"{MANIFEST}/canvas/1", + "label": {"fr": ["Carte"], "en": ["Map"]}, + "items": [{"items": [{"motivation": "painting", "body": body}]}], + **canvas_fields, + } + ] + } + + +def image_body(**extra): + return { + "type": "Image", + "id": f"{BASE}/full/max/0/default.jpg", + "width": 3000, + "height": 6000, + "service": [{"id": BASE, "type": "ImageService3", "profile": "level1"}], + **extra, + } + + +@pytest.mark.parametrize("name,count", [("peace", 1), ("atlas", 3)]) +def test_issue_463_contentdm_fixtures(name, count): + path = Path(__file__).parents[1] / "fixtures" / f"iiif_{name}_463.json" + downloads = manifest_downloads(json.loads(path.read_text()), MANIFEST) + assert len(downloads) == count * 5 + assert len({d["canvas_id"] for d in downloads}) == count + assert all(d["source"] == "iiif" for d in downloads) + assert all("/full/" in d["url"] for d in downloads) + if name == "atlas": + assert list(dict.fromkeys(d["canvas_label"] for d in downloads)) == [ + "Page 1", + "Page 2", + "Page 67", + ] + + +def test_v3_language_map_and_portrait_sizes(): + downloads = manifest_downloads(v3_manifest(image_body()), MANIFEST) + assert downloads[0]["canvas_label"] == "Map" + assert downloads[0]["url"] == f"{BASE}/full/75,/0/default.jpg" + assert downloads[-1]["url"] == f"{BASE}/full/max/0/default.jpg" + assert downloads[-1]["label"] == "Largest Available Image" + + +def test_service_array_ignores_auth_service(): + body = image_body() + body["service"].insert(0, {"id": "https://example.org/login", "type": "AuthCookieService1"}) + assert manifest_downloads(v3_manifest(body), MANIFEST)[0]["url"].startswith(BASE) + + +def test_plain_images_choices_renderings_and_nonpainting_annotations(): + body = { + "type": "Choice", + "items": [ + {"type": "Image", "id": "https://example.org/a.png", "format": "image/png"}, + {"type": "Image", "id": "https://example.org/b.jpg", "format": "image/jpeg"}, + ], + } + manifest = v3_manifest( + body, rendering={"id": "https://example.org/page.pdf", "label": {"none": ["Page PDF"]}} + ) + manifest["rendering"] = [ + {"id": "https://example.org/atlas.pdf", "label": "Atlas PDF", "format": "application/pdf"} + ] + manifest["items"][0]["items"][0]["items"].append( + {"motivation": "commenting", "body": image_body()} + ) + downloads = manifest_downloads(manifest, MANIFEST) + assert len(downloads) == 4 + assert "canvas_id" not in downloads[0] + assert downloads[1]["canvas_label"] == "Map" + assert downloads[2]["label"] == "Image 1: Download Image" + assert downloads[2]["type"] == "image/png" + assert downloads[3]["url"] == "https://example.org/b.jpg" + + +def test_level_zero_uses_only_advertised_sizes_and_max(): + service = { + "type": "ImageService3", + "profile": "level0", + "sizes": [{"width": 100, "height": 200}], + } + assert [d["url"] for d in image_downloads(BASE, service)] == [ + f"{BASE}/full/100,200/0/default.jpg", + f"{BASE}/full/max/0/default.jpg", + ] + + +def test_v2_limits_and_no_upscaling(): + service = { + "width": 4000, + "height": 2000, + "profile": [ + "http://iiif.io/api/image/2/level1.json", + {"maxWidth": 1000, "maxArea": 125000}, + ], + } + downloads = image_downloads(BASE, service) + widths = [int(d["url"].split("/full/")[1].split(",")[0]) for d in downloads] + assert max(widths) <= 500 + small = image_downloads(BASE, {"width": 50, "height": 100}) + assert small[0]["url"] == f"{BASE}/full/50,/0/default.jpg" + + +@pytest.mark.parametrize("suffix", ["/", "/info.json", "/full/800,/0/default.jpg"]) +def test_normalize_service_urls_preserves_encoded_identifier_and_query(suffix): + url = f"https://example.org/iiif/a%2Fb{suffix}?token=public" + assert service_base(url) == "https://example.org/iiif/a%2Fb?token=public" + assert ( + image_downloads(url)[0]["url"] + == "https://example.org/iiif/a%2Fb/full/150,/0/default.jpg?token=public" + ) + + +def test_image_api_one_native_quality(): + downloads = image_downloads( + BASE, + { + "@context": "http://library.stanford.edu/iiif/image-api/1.1/context.json", + "profile": "http://iiif.io/api/image/1/level1.json", + }, + ) + assert downloads[-1]["url"].endswith("/full/full/0/native.jpg") + + +@pytest.mark.parametrize( + "manifest", + [None, [], {}, {"items": [None, "remote", {"items": [None]}]}, {"sequences": [None]}], +) +def test_malformed_or_external_only_manifests_are_safe(manifest): + assert manifest_downloads(manifest, MANIFEST) == [] + + +@pytest.mark.parametrize( + "url", + [ + "javascript:alert(1)", + "data:image/png;base64,x", + "file:///tmp/x", + "https://user:pass@example.org/image", + ], +) +def test_unsafe_links_are_not_emitted(url): + assert image_downloads(url) == [] + assert manifest_downloads(v3_manifest({"type": "Image", "id": url}), MANIFEST) == [] + + +def test_repeated_urls_deduplicate_within_page_but_keep_distinct_pages(): + manifest = v3_manifest([image_body(), image_body()]) + manifest["items"].append({**manifest["items"][0], "id": f"{MANIFEST}/canvas/2"}) + downloads = manifest_downloads(manifest, MANIFEST) + assert len(downloads) == 10 + assert downloads[0]["image_occurrences"] == [0, 1] + assert downloads[-1]["image_occurrences"] == [2, 3] + + +@pytest.mark.asyncio +async def test_manifest_resolution_uses_cache_fetch_once_and_supports_https_reference_key(): + service = DownloadService( + {"dct_references_s": {"https://iiif.io/api/presentation#manifest": {"url": MANIFEST}}} + ) + with patch( + "app.services.image_service.ImageService._get_manifest", + return_value=v3_manifest(image_body()), + ) as fetch: + downloads = await service.resolve_iiif_downloads() + fetch.assert_called_once_with(MANIFEST) + assert len(downloads) == 5 + + +@pytest.mark.asyncio +async def test_image_info_version_and_manifest_failure_fallback(): + service = DownloadService( + { + "dct_references_s": { + "http://iiif.io/api/presentation#manifest": MANIFEST, + "http://iiif.io/api/image": BASE + "/info.json", + } + } + ) + with patch( + "app.services.image_service.ImageService._get_manifest", + side_effect=[None, {"type": "ImageService3"}], + ): + downloads = await service.resolve_iiif_downloads() + assert downloads[-1]["url"] == f"{BASE}/full/max/0/default.jpg" + + +@pytest.mark.asyncio +async def test_unavailable_manifest_signals_retry_without_losing_direct_downloads(): + service = DownloadService( + { + "dct_references_s": { + "http://iiif.io/api/presentation#manifest": MANIFEST, + "http://schema.org/downloadUrl": "https://example.org/map.pdf", + } + } + ) + with patch("app.services.image_service.ImageService._get_manifest", return_value=None): + with pytest.raises(ValueError, match="unavailable"): + await service.resolve_iiif_downloads() + assert service.get_download_options()[0]["url"] == "https://example.org/map.pdf" + + +@pytest.mark.asyncio +@pytest.mark.parametrize("unavailable", [False, True]) +async def test_download_endpoint_merges_iiif_and_preserves_other_downloads(unavailable): + from types import SimpleNamespace + from unittest.mock import AsyncMock, MagicMock + + from app.api.v1.endpoint_modules.resources import downloads as endpoint + + row = SimpleNamespace(_mapping={"id": "atlas"}) + session = AsyncMock() + session.execute.return_value = MagicMock(fetchone=lambda: row) + direct = {"label": "Source PDF", "url": "https://example.org/source.pdf"} + provisional = {"label": "Small Image", "url": "https://example.org/old.jpg", "source": "iiif"} + resolved = manifest_downloads(v3_manifest(image_body()), MANIFEST) + with ( + patch.object(endpoint, "async_session") as session_factory, + patch.object(endpoint, "fetch_distribution_context", new_callable=AsyncMock) as context, + patch.object( + endpoint.DownloadService, + "get_download_options_with_bridge_asset_downloads", + new_callable=AsyncMock, + return_value=[direct, provisional], + ), + patch.object( + endpoint.DownloadService, "resolve_iiif_downloads", new_callable=AsyncMock + ) as resolve, + ): + session_factory.return_value.__aenter__.return_value = session + context.return_value = SimpleNamespace(by_uri={}) + if unavailable: + resolve.side_effect = ValueError("unavailable") + else: + resolve.return_value = resolved + response = await endpoint.get_resource_downloads(None, "atlas", callback=None) + payload = json.loads(response.body) + assert payload["iiif_error"] is unavailable + assert payload["downloads"] == ([direct, provisional] if unavailable else [direct, *resolved]) + + +@pytest.mark.asyncio +async def test_both_preview_sources_have_downloads_and_stable_image_identity(): + image_url = "https://example.org/standalone/info.json" + service = DownloadService( + { + "dct_references_s": { + "http://iiif.io/api/presentation#manifest": MANIFEST, + "http://iiif.io/api/image": image_url, + } + } + ) + with patch( + "app.services.image_service.ImageService._get_manifest", + side_effect=[v3_manifest(image_body()), {"type": "ImageService3"}], + ) as fetch: + downloads = await service.resolve_iiif_downloads() + assert fetch.call_count == 2 + assert len(downloads) == 10 + assert {item["iiif_resource_url"] for item in downloads} == {MANIFEST, image_url} + assert downloads[0]["image_source"] == BASE + assert downloads[-1]["image_source"] == "https://example.org/standalone" + + +def test_multiple_images_in_a_canvas_keep_individual_source_identity(): + second = image_body() + second["service"][0]["id"] = "https://example.org/second" + downloads = manifest_downloads(v3_manifest([image_body(), second]), MANIFEST) + assert len(downloads) == 10 + assert len({item["canvas_id"] for item in downloads}) == 1 + assert {item["image_source"] for item in downloads} == {BASE, "https://example.org/second"} + + +def test_v2_multiple_sequences_follow_viewer_order(): + body = {"@type": "dctypes:Image", "@id": "https://example.org/one.jpg"} + manifest = { + "sequences": [ + { + "canvases": [ + {"@id": "https://example.org/canvas/one", "images": [{"resource": body}]} + ] + }, + { + "canvases": [ + { + "@id": "https://example.org/canvas/two", + "images": [{"resource": {**body, "@id": "https://example.org/two.jpg"}}], + } + ] + }, + ] + } + downloads = manifest_downloads(manifest, MANIFEST) + assert [item["image_source"] for item in downloads] == [ + "https://example.org/one.jpg", + "https://example.org/two.jpg", + ] diff --git a/backend/tests/services/test_image_service.py b/backend/tests/services/test_image_service.py index f6d42880..270b29ea 100644 --- a/backend/tests/services/test_image_service.py +++ b/backend/tests/services/test_image_service.py @@ -8,11 +8,25 @@ import pytest -from app.services.image_service import ( - ImageService, -) +from app.services import image_service from app.services.thumbnail_policy import source_signature +ImageService = image_service.ImageService + + +@pytest.fixture(autouse=True) +def isolate_redis_pools(monkeypatch): + # Initialization tests mock Redis credentials. Do not retain those pools in + # later tests that exercise the real server. + names = ("_redis_connection_pool", "_redis_image_connection_pool") + for name in names: + monkeypatch.setattr(image_service, name, None) + yield + for name in names: + pool = getattr(image_service, name) + if pool is not None: + pool.disconnect() + @pytest.fixture(autouse=True) def isolate_task_broker(): diff --git a/backend/tests/services/test_mcp_service.py b/backend/tests/services/test_mcp_service.py index ef68c349..613f6617 100644 --- a/backend/tests/services/test_mcp_service.py +++ b/backend/tests/services/test_mcp_service.py @@ -261,7 +261,7 @@ async def test_get_resource_viewer_tool(self): assert len(result.content) == 1 assert "stanford-wt473hz7153" in result.content[0].text assert "" in result.content[0].text - assert "ogm-viewer" in result.content[0].text + assert "/api/v1/viewer-assets/ogm-viewer.js" in result.content[0].text @pytest.mark.asyncio async def test_validate_aardvark_record_tool(self): diff --git a/backend/tests/services/test_native_static_maps.py b/backend/tests/services/test_native_static_maps.py new file mode 100644 index 00000000..f9f1fdda --- /dev/null +++ b/backend/tests/services/test_native_static_maps.py @@ -0,0 +1,130 @@ +import io +from unittest.mock import MagicMock, patch + +import pytest +from fastapi import FastAPI +from fastapi.testclient import TestClient +from PIL import Image + +from app.api.v1.endpoint_modules.static_maps import router +from app.services import native_static_maps +from app.services.static_map_service import StaticMapService + + +def test_native_signatures_change_with_revision_and_dimensions(monkeypatch): + monkeypatch.setenv("STATIC_MAP_RENDERER_URL", "http://renderer:8080") + small = StaticMapService(640, 320) + first = small.centered_basemap_signature(latitude=39, longitude=-86, zoom=15) + assert first != StaticMapService(800, 600).centered_basemap_signature( + latitude=39, longitude=-86, zoom=15 + ) + monkeypatch.setenv("STATIC_MAP_RENDER_REVISION", "new-style") + assert first != small.centered_basemap_signature(latitude=39, longitude=-86, zoom=15) + assert small.basemap_variant() == "native_basemap_v1" + + +def test_current_thumbnail_links_follow_the_renderer_style(monkeypatch): + monkeypatch.delenv("STATIC_MAP_STYLE_URL", raising=False) + service = StaticMapService() + variant = service.basemap_variant() + positron = service._alias_key("record", variant=variant) + monkeypatch.setenv("STATIC_MAP_STYLE_URL", "https://tiles.openfreemap.org/styles/positron") + assert service._alias_key("record", variant=variant) == positron + monkeypatch.setenv("STATIC_MAP_STYLE_URL", "https://tiles.openfreemap.org/styles/liberty") + assert service._alias_key("record", variant=variant) != positron + + +@pytest.mark.parametrize( + "query", ["lat=nan&lon=0", "lat=90&lon=0", "lat=0&lon=181", "lat=0&lon=0&zoom=30"] +) +def test_campus_rejects_bad_camera(query): + app = FastAPI() + app.include_router(router) + assert TestClient(app).get("/static-maps/institutions/test?" + query).status_code == 422 + + +def test_remote_failure_does_not_publish_or_use_carto(monkeypatch): + monkeypatch.setenv("STATIC_MAP_RENDERER_URL", "http://renderer:8080") + service = StaticMapService() + service.map_cache = MagicMock() + with ( + patch.object(native_static_maps, "reuse_geometry", return_value=None), + patch.object(native_static_maps.requests, "post", side_effect=RuntimeError("unavailable")), + patch.object(service, "materialize_asset_sync") as persist, + ): + with pytest.raises(RuntimeError, match="unavailable"): + service.generate_map("record", "ENVELOPE(-90,-89,40,39)") + persist.assert_not_called() + + +def test_wrong_size_png_is_not_published(monkeypatch): + monkeypatch.setenv("STATIC_MAP_RENDERER_URL", "http://renderer:8080") + output = io.BytesIO() + Image.new("RGB", (2, 2)).save(output, "PNG") + response = MagicMock(content=output.getvalue()) + service = StaticMapService() + service.map_cache = MagicMock() + with ( + patch.object(native_static_maps, "reuse_geometry", return_value=None), + patch.object(native_static_maps.requests, "post", return_value=response), + patch.object(service, "materialize_asset_sync") as persist, + ): + with pytest.raises(ValueError, match="dimensions"): + service.generate_map("record", "ENVELOPE(-90,-89,40,39)") + persist.assert_not_called() + + +def test_identical_geometry_reuses_bytes_without_rendering(): + service = MagicMock() + service.geometry_signature.return_value = "geometry-and-dimensions" + service.geometry_variant.return_value = "native_geometry_v1" + service.get_cached_asset_sync.return_value = b"existing PNG" + service.materialize_asset_sync.return_value = "digest" + with ( + patch.object( + native_static_maps, "get_durable_visual_asset_hash_for_signature", return_value="digest" + ), + patch.object( + native_static_maps, "get_durable_visual_asset_hash_for_resource", return_value="digest" + ), + patch.object(native_static_maps, "_generate_uncached") as render, + ): + assert ( + native_static_maps.generate(service, "different-record", "POINT(1 2)") + == b"existing PNG" + ) + render.assert_not_called() + assert service.materialize_asset_sync.call_args.args[0] == "different-record" + + +def test_concurrent_identical_geometry_is_not_rendered_twice(): + service = MagicMock() + service.map_cache.set.return_value = False + with ( + patch.object(native_static_maps, "reuse_geometry", return_value=None), + patch.object(native_static_maps, "_generate_uncached") as render, + ): + with pytest.raises(RuntimeError, match="already rendering"): + native_static_maps.generate(service, "record", "POINT(1 2)") + render.assert_not_called() + service.map_cache.eval.assert_not_called() + + +def test_cache_only_storage_does_not_require_a_database_body(): + output = io.BytesIO() + Image.new("RGB", (400, 300)).save(output, "PNG") + data = output.getvalue() + service = StaticMapService(400, 300) + service.map_cache = MagicMock() + response = MagicMock(content=data, status_code=200) + with ( + patch.object(native_static_maps.requests, "post", return_value=response), + patch.object(native_static_maps, "durable_visual_asset_enabled", return_value=False), + patch.object(native_static_maps, "get_durable_visual_asset") as durable_read, + patch.object(native_static_maps, "cache_visual_asset", return_value=False), + patch.object(service, "materialize_asset_sync", return_value="a" * 64), + ): + assert ( + native_static_maps.generate(service, "institution:test", center=[0, 0], zoom=3) == data + ) + durable_read.assert_not_called() diff --git a/backend/tests/services/test_static_map_service.py b/backend/tests/services/test_static_map_service.py index 04928139..30c1bf09 100644 --- a/backend/tests/services/test_static_map_service.py +++ b/backend/tests/services/test_static_map_service.py @@ -1,55 +1,9 @@ from unittest.mock import MagicMock, call, patch -import staticmaps - -from app.services.static_map_service import ( - OPENSTREETMAP_TILE_PROVIDER, - STATIC_MAP_TILE_USER_AGENT, - StaticMapService, -) +from app.services.static_map_service import StaticMapService from app.services.visual_asset_cache import cache_visual_asset -def test_map_context_uses_canonical_openstreetmap_tiles_and_application_user_agent(): - service = StaticMapService() - - with patch("app.services.static_map_service.staticmaps.Context") as context_type: - context = context_type.return_value - result = service._map_context() - - assert result is context - assert OPENSTREETMAP_TILE_PROVIDER.url(4, 3, 6) == ("https://tile.openstreetmap.org/4/3/6.png") - assert "OpenStreetMap" in OPENSTREETMAP_TILE_PROVIDER.attribution() - context.set_tile_provider.assert_called_once_with(OPENSTREETMAP_TILE_PROVIDER) - context._tile_downloader.set_user_agent.assert_called_once_with(STATIC_MAP_TILE_USER_AGENT) - - -def test_static_map_variants_change_with_openstreetmap_provider(): - service = StaticMapService() - - assert service.geometry_variant() == "static_map_v10" - assert service.basemap_variant() == "static_basemap_v8" - - -def test_centered_basemap_respects_openstreetmap_max_zoom(): - service = StaticMapService() - context = MagicMock() - - with ( - patch.object(service, "_map_context", return_value=context), - patch.object(service, "_render_and_cache", return_value=b"map"), - ): - result = service.generate_centered_basemap( - "campus", - latitude=44.9778, - longitude=-93.2650, - zoom=20, - ) - - assert result == b"map" - context.set_zoom.assert_called_once_with(19) - - def test_get_asset_hash_recovers_alias_from_durable_link(): asset_hash = "a" * 64 service = StaticMapService() @@ -92,7 +46,9 @@ def test_materialize_asset_persists_resource_link(): with ( patch.object(service, "set_asset_hash_sync") as mock_set_hash, patch("app.services.static_map_service.store_durable_visual_asset"), - patch("app.services.static_map_service.store_durable_visual_asset_link") as mock_link, + patch( + "app.services.static_map_service.store_durable_visual_asset_link", return_value=True + ) as mock_link, ): asset_hash = service.materialize_asset_sync( "resource-1", @@ -114,7 +70,7 @@ def test_materialize_asset_persists_resource_link(): "resource-1", asset_hash=asset_hash, asset_kind="resource-class-icon", - source_signature=None, + source_signature=service.current_render_signature(), ), ] ) @@ -228,148 +184,3 @@ def set(self, _key, _value): assert cache.calls == 2 mock_sleep.assert_called_once() - - -def test_generate_map_uses_global_fallback_for_unrenderable_polar_extent(): - service = StaticMapService() - geometry = { - "type": "Polygon", - "coordinates": [[[-10, 89], [10, 89], [10, 90], [-10, 90], [-10, 89]]], - } - - with ( - patch.object(service, "generate_global_map", return_value=b"global-map") as mock_global, - patch.object(service, "_render_and_cache") as mock_render, - ): - result = service.generate_map("polar-resource", geometry) - - assert result == b"global-map" - mock_global.assert_called_once() - mock_render.assert_not_called() - - -def test_generate_map_clamps_partially_renderable_polar_extent(): - service = StaticMapService() - geometry = "ENVELOPE(-10, 10, 90, 80)" - - with ( - patch.object(service, "generate_global_map") as mock_global, - patch.object(service, "_render_and_cache", return_value=b"rendered") as mock_render, - ): - result = service.generate_map("near-polar-resource", geometry) - - assert result == b"rendered" - mock_global.assert_not_called() - mock_render.assert_called_once() - - -def test_generate_basemap_uses_global_fallback_for_unrenderable_polar_extent(): - service = StaticMapService() - geometry = { - "type": "Polygon", - "coordinates": [[[-10, -90], [10, -90], [10, -89], [-10, -89], [-10, -90]]], - } - - with ( - patch.object( - service, - "generate_global_basemap", - return_value=b"global-basemap", - ) as mock_global, - patch.object(service, "_render_and_cache") as mock_render, - ): - result = service.generate_basemap("south-polar-resource", geometry) - - assert result == b"global-basemap" - mock_global.assert_called_once() - mock_render.assert_not_called() - - -def test_polygon_segments_are_not_replaced_with_geodesic_arcs(): - service = StaticMapService() - geometry = { - "type": "Polygon", - "coordinates": [[[-115, 55], [-65, 55], [-65, 30], [-115, 30], [-115, 55]]], - } - - objects = service._geojson_to_staticmaps_objects(geometry) - - assert objects is not None - assert len(objects[-1].interpolate()) == 6 - assert {round(point.lat().degrees, 6) for point in objects[-1].interpolate()} == { - 30.0, - 55.0, - } - - -def test_multipolygon_extent_does_not_take_short_path_across_antimeridian(): - service = StaticMapService() - geometry = { - "type": "MultiPolygon", - "coordinates": [ - [[[170, 20], [179, 20], [179, 30], [170, 30], [170, 20]]], - [[[-179, -30], [-170, -30], [-170, -20], [-179, -20], [-179, -30]]], - ], - } - - objects = service._geojson_to_staticmaps_objects(geometry) - - assert objects is not None - extent_points = objects[-1].interpolate() - assert len(extent_points) == 5 - assert [point.lng().degrees for point in extent_points] == [ - -179.0, - -179.0, - 179.0, - 179.0, - -179.0, - ] - - -def test_point_geometry_creates_visible_static_map_marker(): - service = StaticMapService() - - objects = service._geojson_to_staticmaps_objects( - {"type": "Point", "coordinates": [-87.62, 43.08]} - ) - - assert objects is not None - assert len(objects) == 1 - assert isinstance(objects[0], staticmaps.Marker) - assert objects[0].latlng().lng().degrees == -87.62 - assert objects[0].latlng().lat().degrees == 43.08 - assert objects[0].size() == 10 - - -def test_generate_map_renders_zero_area_bbox_as_point(): - service = StaticMapService() - - with ( - patch.object(service, "generate_global_map") as mock_global, - patch.object(service, "_render_and_cache", return_value=b"point-map") as mock_render, - ): - result = service.generate_map( - "bike-elevator", - "ENVELOPE(-87.62, -87.62, 43.08, 43.08)", - ) - - assert result == b"point-map" - mock_global.assert_not_called() - mock_render.assert_called_once() - - -def test_generate_basemap_uses_point_to_set_extent(): - service = StaticMapService() - - with ( - patch.object(service, "generate_global_basemap") as mock_global, - patch.object(service, "_render_and_cache", return_value=b"point-basemap") as mock_render, - ): - result = service.generate_basemap( - "bike-elevator", - "POINT(-87.62 43.08)", - ) - - assert result == b"point-basemap" - mock_global.assert_not_called() - mock_render.assert_called_once() diff --git a/backend/tools/maplibre-static-prototype/.gitignore b/backend/tools/maplibre-static-prototype/.gitignore new file mode 100644 index 00000000..e0e6e611 --- /dev/null +++ b/backend/tools/maplibre-static-prototype/.gitignore @@ -0,0 +1,2 @@ +node_modules/ +output/ diff --git a/backend/tools/maplibre-static-prototype/Dockerfile.worker b/backend/tools/maplibre-static-prototype/Dockerfile.worker new file mode 100644 index 00000000..99c92fdd --- /dev/null +++ b/backend/tools/maplibre-static-prototype/Dockerfile.worker @@ -0,0 +1,16 @@ +FROM node:22-bookworm-slim AS node +FROM ubuntu:24.04 +RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + ca-certificates fonts-dejavu-core libegl1 libgles2 libopengl0 libgl1-mesa-dri libglx-mesa0 libcurl4t64 \ + libjpeg-turbo8 libuv1t64 libicu74 libpng16-16t64 libwebp7 xvfb xauth mesa-utils \ + && rm -rf /var/lib/apt/lists/* +COPY --from=node /usr/local/bin/node /usr/local/bin/node +COPY --from=node /usr/local/lib/node_modules /usr/local/lib/node_modules +RUN ln -s /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm +WORKDIR /opt/map-prototype +COPY backend/tools/maplibre-static-prototype/package*.json ./ +RUN npm ci +COPY backend/tools/maplibre-static-prototype/*.mjs backend/tools/maplibre-static-prototype/*.json ./ +ENV LIBGL_ALWAYS_SOFTWARE=1 GALLIUM_DRIVER=llvmpipe DISPLAY=:99 +# Explicit display startup avoids xvfb-run's signal wait in this container runtime. +CMD ["sh", "-c", "rm -f /tmp/.X99-lock /tmp/.X11-unix/X99; Xvfb :99 -screen 0 1280x1024x24 -ac -nolisten tcp & sleep 2; glxinfo -B && mkdir -p output && npm run demo"] diff --git a/backend/tools/maplibre-static-prototype/campus.json b/backend/tools/maplibre-static-prototype/campus.json new file mode 100644 index 00000000..d163f47a --- /dev/null +++ b/backend/tools/maplibre-static-prototype/campus.json @@ -0,0 +1,12 @@ +{ + "style": "https://tiles.openfreemap.org/styles/positron", + "id": "institution:indiana-university", + "title": "Indiana University campus", + "width": 640, + "height": 320, + "center": [ + -86.5235, + 39.1702 + ], + "leafletZoom": 15 +} \ No newline at end of file diff --git a/backend/tools/maplibre-static-prototype/package-lock.json b/backend/tools/maplibre-static-prototype/package-lock.json new file mode 100644 index 00000000..69e3defb --- /dev/null +++ b/backend/tools/maplibre-static-prototype/package-lock.json @@ -0,0 +1,3058 @@ +{ + "name": "ogm-maplibre-static-prototype", + "version": "0.1.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "ogm-maplibre-static-prototype", + "version": "0.1.0", + "dependencies": { + "@maplibre/maplibre-gl-native": "6.4.1", + "sharp": "0.35.5" + } + }, + "node_modules/@acalcutt/node-pre-gyp": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/@acalcutt/node-pre-gyp/-/node-pre-gyp-2.0.4.tgz", + "integrity": "sha512-oPSZBuqSh1AWuPMsQKMtlcb4hisU4DWtuIo8OlQtMH4F7k1w+gd1Be4dTTZdh8qoG8LfmauTBJraU8DWxub0RA==", + "license": "BSD-3-Clause", + "dependencies": { + "consola": "^3.2.3", + "detect-libc": "^2.0.0", + "https-proxy-agent": "^7.0.5", + "node-fetch": "^2.6.7", + "nopt": "^8.0.0", + "semver": "^7.5.3", + "tar": "^7.5.7" + }, + "bin": { + "node-pre-gyp": "bin/node-pre-gyp" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@acalcutt/node-pre-gyp-github": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/@acalcutt/node-pre-gyp-github/-/node-pre-gyp-github-2.0.2.tgz", + "integrity": "sha512-XESr6F1llJ7sU87vti5noR6Xnq00g7wo5Jr4GnAJ42spO69atXCjCJb9MYLYMQQpXn2Ts/T1uYaG+gWMb/69ug==", + "license": "MIT", + "dependencies": { + "@octokit/rest": "22.0.1", + "commander": "14.0.3", + "semver": "^7.7.4" + }, + "bin": { + "node-pre-gyp-github": "bin/node-pre-gyp-github.js" + } + }, + "node_modules/@emnapi/runtime": { + "version": "1.11.3", + "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.11.3.tgz", + "integrity": "sha512-Xz4Tpyki7XyrpbUK1jR1AhdAdaXyhhY4lZ3neLodmhpuWfy2PAQN5B46sAiU4liOXGLkHypn/qU+jvfWSCYYLA==", + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@img/colour": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@img/colour/-/colour-1.1.0.tgz", + "integrity": "sha512-Td76q7j57o/tLVdgS746cYARfSyxk8iEfRxewL9h4OMzYhbW4TAcppl0mT4eyqXddh6L/jwoM75mo7ixa/pCeQ==", + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/@img/sharp-darwin-arm64": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-darwin-arm64/-/sharp-darwin-arm64-0.35.5.tgz", + "integrity": "sha512-QRUlFQ0WxvdWyqqG/WtI3iupfD5rBzmCHXSdPsY91sAtVtTo7Q4cb6zOccZ3gqEqkr0f1As1ehLqmEpDsRf+lg==", + "cpu": [ + "arm64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-darwin-arm64": "1.3.4" + } + }, + "node_modules/@img/sharp-darwin-x64": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-darwin-x64/-/sharp-darwin-x64-0.35.5.tgz", + "integrity": "sha512-+BR255RhDlpygUpOc/Jdt1nT6DQ3XG/ERo5wbcdOf5Q320dKtPCKPLR1LJs9VGXRaMa8l1uUa0tkCNOXiAxZUw==", + "cpu": [ + "x64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-darwin-x64": "1.3.4" + } + }, + "node_modules/@img/sharp-freebsd-wasm32": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-freebsd-wasm32/-/sharp-freebsd-wasm32-0.35.5.tgz", + "integrity": "sha512-Y/z91nEZ4uIBX5X3nfTovjU9lHNKFYbL2lpHCLVNmXQK03VIZvXBBt0KxbPGp2SdGSF+2mQU4e+hQaWOt86iAw==", + "license": "Apache-2.0", + "optional": true, + "os": [ + "freebsd" + ], + "dependencies": { + "@img/sharp-wasm32": "0.35.5" + }, + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-darwin-arm64": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-arm64/-/sharp-libvips-darwin-arm64-1.3.4.tgz", + "integrity": "sha512-5R89nBYiRdUlSWJxPhO+GVtaXzXSxKnRu/xqMn3KTA3L9EB9Oy/P+Nn2f2vlhPuUdy/Zusb2DarbyTpGCfEDuw==", + "cpu": [ + "arm64" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "darwin" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-darwin-x64": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-x64/-/sharp-libvips-darwin-x64-1.3.4.tgz", + "integrity": "sha512-iR2OKH80yi0U+dUplyh3/xdpFvps6YkCwsXenIJxqxR1v9o+xtKTGbS9H7cps+2Vxjc8B1j96p75NmTGjIhtpQ==", + "cpu": [ + "x64" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "darwin" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-arm": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm/-/sharp-libvips-linux-arm-1.3.4.tgz", + "integrity": "sha512-LmRtTsOHuvM2+wlO2Db37dx5MiZhB0FvSunciw48YjdOkZz9KAiRbm8ujeMOA1INqmei5NapFxYEK1D1ZSidmw==", + "cpu": [ + "arm" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-arm64": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm64/-/sharp-libvips-linux-arm64-1.3.4.tgz", + "integrity": "sha512-Y3dgX/6lE2QhQb+Gxy0WZxfg9MEm/JBjamZpS2IklP7xIQoKN4hzAm7KcMVGtaVDt3neE9OKBC7vAfonA/Lr1A==", + "cpu": [ + "arm64" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-ppc64": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-ppc64/-/sharp-libvips-linux-ppc64-1.3.4.tgz", + "integrity": "sha512-Le6boB8Tai0Nis+gIxIpKx68UDVVIqdR8Tin5Yf1z2LJJQLDJvCDRqRu+jC2qCoD+eIomonmOwB4smBRxfVpYQ==", + "cpu": [ + "ppc64" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-riscv64": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-riscv64/-/sharp-libvips-linux-riscv64-1.3.4.tgz", + "integrity": "sha512-aHkkIEHPRdQEegJN20MLmGtxYD9R2wQr3Cwpddnu5+YKMt6Uzax7S9h5gpZTo8wyrGuZSlfQ63OevL5mTyOC7Q==", + "cpu": [ + "riscv64" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-s390x": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-s390x/-/sharp-libvips-linux-s390x-1.3.4.tgz", + "integrity": "sha512-ra/mB6MikESDUO7Yg+Mi95bFBb9GsObURuhnOv3OqknjGe9sZrG8tCe9q0xSIGrtLgvgw0gKnFWcK4blSgQOuQ==", + "cpu": [ + "s390x" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-x64": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-x64/-/sharp-libvips-linux-x64-1.3.4.tgz", + "integrity": "sha512-GJ//SSXbnwSDes02umB3nDJLFcQzw8a18V8fyhqr6tV515tOEMdImjjxj1AoafMRz56F3PHgftnj1QEKSU1zkw==", + "cpu": [ + "x64" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linuxmusl-arm64": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-arm64/-/sharp-libvips-linuxmusl-arm64-1.3.4.tgz", + "integrity": "sha512-hvulFwtjUcagsis6BBxHwGFwWoNZjgYmULGVrZcyfNbjA8hKILbRxGg15/7w5HDyXHXUos/j6baAWqnCyQ2DWA==", + "cpu": [ + "arm64" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linuxmusl-x64": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-x64/-/sharp-libvips-linuxmusl-x64-1.3.4.tgz", + "integrity": "sha512-6zXKeE/p39I1AmA3cJG35eyBGNqNddLnUXjhwBnsGjFPWqf5VKkDBEqaEkPDoTEtkxwi2vv8Tcr2mDyP4So7Fg==", + "cpu": [ + "x64" + ], + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-linux-arm": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm/-/sharp-linux-arm-0.35.5.tgz", + "integrity": "sha512-LEaXK2WdXVK5ykcw0buWyPMsmLLL2vpHLD6yrNSW+JGEL3BZPA4tpKN6iaMc4AxTTAoaX/sU1rOL51lcIz48ZQ==", + "cpu": [ + "arm" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-arm": "1.3.4" + } + }, + "node_modules/@img/sharp-linux-arm64": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm64/-/sharp-linux-arm64-0.35.5.tgz", + "integrity": "sha512-LYVx5JTsOM2CBzmxreh+nl64/3H6Xb09iSLknqH47z2T2DFFxDeFLP5y4dJwe6H7uGQlHPyEEtIqyo3DYsRwdQ==", + "cpu": [ + "arm64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-arm64": "1.3.4" + } + }, + "node_modules/@img/sharp-linux-ppc64": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-ppc64/-/sharp-linux-ppc64-0.35.5.tgz", + "integrity": "sha512-QVxAAq8evVRI9ia2vqgwrmWucn5Dfv+JdWzj75pD8omHLPSP7f8p20O8jxzjCcuCEQEOtYOZUmX1hkiZ0kdevA==", + "cpu": [ + "ppc64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-ppc64": "1.3.4" + } + }, + "node_modules/@img/sharp-linux-riscv64": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-riscv64/-/sharp-linux-riscv64-0.35.5.tgz", + "integrity": "sha512-LtdreXguaavKODPIfzJ4kffx7UNt1omwtK0rch4EBbbSTXPnxWmYSayXdLJw0fJzQ97kHt1gL/yh4tvU+nCyRQ==", + "cpu": [ + "riscv64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-riscv64": "1.3.4" + } + }, + "node_modules/@img/sharp-linux-s390x": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-s390x/-/sharp-linux-s390x-0.35.5.tgz", + "integrity": "sha512-UZasTOFiYzotTsGOCu42BfUzP6Tu6Do/947iRm1RsLKvlllxwGcn4RN27LibGWceix4Y+Pmw3jsnTcCQIgWjqA==", + "cpu": [ + "s390x" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-s390x": "1.3.4" + } + }, + "node_modules/@img/sharp-linux-x64": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-x64/-/sharp-linux-x64-0.35.5.tgz", + "integrity": "sha512-SxFtLTeJInhAA9Q836kux2vZNeOBQEx658qvbboZScr0wIARym3IcGmW7KpVD5sbVg0Ojy+udFQdayYIZyoNog==", + "cpu": [ + "x64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-x64": "1.3.4" + } + }, + "node_modules/@img/sharp-linuxmusl-arm64": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-arm64/-/sharp-linuxmusl-arm64-0.35.5.tgz", + "integrity": "sha512-9HbMclmI1zlNkFRs3z9/eBtDjfD0sGlrX1z6b1qwmiFY5ElDLh4BC0LPBdVp7z1DXFiKlIcznf+ZlsuZzLxQqg==", + "cpu": [ + "arm64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linuxmusl-arm64": "1.3.4" + } + }, + "node_modules/@img/sharp-linuxmusl-x64": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-x64/-/sharp-linuxmusl-x64-0.35.5.tgz", + "integrity": "sha512-4KOphqB035HrVdqLZfCgMzzERrQkkzOwRhl4OAkRO1YCldbaFjySXMaK534Mo0V+LndnlJk+sbUyLeU0ULyD1A==", + "cpu": [ + "x64" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linuxmusl-x64": "1.3.4" + } + }, + "node_modules/@img/sharp-wasm32": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-wasm32/-/sharp-wasm32-0.35.5.tgz", + "integrity": "sha512-Ptsga1su4tQx+LLF1ECS9U6nz5kmrXKo6XVbtR48Ke3ZRxxgaWBu7IDtEe1quo8hiupwm6WFqxVlXaSf7IINGQ==", + "license": "Apache-2.0 AND LGPL-3.0-or-later AND MIT", + "optional": true, + "dependencies": { + "@emnapi/runtime": "^1.11.3" + }, + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-webcontainers-wasm32": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-webcontainers-wasm32/-/sharp-webcontainers-wasm32-0.35.5.tgz", + "integrity": "sha512-hfhF/FmoQyTUkA0bIKFOtw536BQSeBMe6BF6QyWlrPxT754+TFLaZ7sKKTfvvM0yJgKgaYTwnFCIZ/GuDw5SUA==", + "cpu": [ + "wasm32" + ], + "license": "Apache-2.0", + "optional": true, + "dependencies": { + "@img/sharp-wasm32": "0.35.5" + }, + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-win32-arm64": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-win32-arm64/-/sharp-win32-arm64-0.35.5.tgz", + "integrity": "sha512-X4t7g+7ZA5DKblCBEXGjUqqemj4vczING/5viFwAL8h4N3qYeyjwdCvRLHi4EdOUI+2Z7UFlp1VM+p/AuEtm6Q==", + "cpu": [ + "arm64" + ], + "license": "Apache-2.0 AND LGPL-3.0-or-later", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-win32-ia32": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-win32-ia32/-/sharp-win32-ia32-0.35.5.tgz", + "integrity": "sha512-5Zm82LoBc43nhwNybZlG7Y1KO//Zhsn306fQl29ZOuStHLGTo3BWL83q3cznX0poxSAMuYL1On/BHBxkBeKr6A==", + "cpu": [ + "ia32" + ], + "license": "Apache-2.0 AND LGPL-3.0-or-later", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-win32-x64": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/@img/sharp-win32-x64/-/sharp-win32-x64-0.35.5.tgz", + "integrity": "sha512-x76eH0vEiHlcMQu8Y8IenntaACtddpT6W0wmXtWrnKcnKI7ME5DdgqhAD6SEWOEl1v2zDvkZDhFA9KnURwpfqg==", + "cpu": [ + "x64" + ], + "license": "Apache-2.0 AND LGPL-3.0-or-later", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@isaacs/fs-minipass": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@isaacs/fs-minipass/-/fs-minipass-4.0.1.tgz", + "integrity": "sha512-wgm9Ehl2jpeqP3zw/7mo3kRHFp5MEDhqAdwy1fTGkHAwnkGOVsgpvQhL8B5n1qlb01jV3n/bI0ZfZp5lWA1k4w==", + "license": "ISC", + "dependencies": { + "minipass": "^7.0.4" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@maplibre/maplibre-gl-native": { + "version": "6.4.1", + "resolved": "https://registry.npmjs.org/@maplibre/maplibre-gl-native/-/maplibre-gl-native-6.4.1.tgz", + "integrity": "sha512-eiJnCOIea2PrGmxZnocP61kEJO4IAhNS/yvkdNh+PR50qdR4khAGU/dBA0IV+uXEQCu33Fux//J1wOQ5srYVGQ==", + "hasInstallScript": true, + "license": "BSD-2-Clause", + "dependencies": { + "@acalcutt/node-pre-gyp": "2.0.4", + "@acalcutt/node-pre-gyp-github": "2.0.2", + "minimatch": "^10.2.2", + "npm-run-all": "4.1.5" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/@octokit/auth-token": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-6.0.0.tgz", + "integrity": "sha512-P4YJBPdPSpWTQ1NU4XYdvHvXJJDxM6YwpS0FZHRgP7YFkdVxsWcpWGy/NVqlAA7PcPCnMacXlRm1y2PFZRWL/w==", + "license": "MIT", + "engines": { + "node": ">= 20" + } + }, + "node_modules/@octokit/core": { + "version": "7.0.8", + "resolved": "https://registry.npmjs.org/@octokit/core/-/core-7.0.8.tgz", + "integrity": "sha512-L7y8eYc+AwxGr2PWI4WFt1VG4TiJ66c26BD16mXpYIlXxG0SMigM1+m4aTSlYyBr5BlQsGAlz8uDCoZN4SEMcg==", + "license": "MIT", + "dependencies": { + "@octokit/auth-token": "^6.0.0", + "@octokit/graphql": "^9.0.5", + "@octokit/request": "^10.0.16", + "@octokit/request-error": "^7.1.2", + "@octokit/types": "^18.0.0", + "before-after-hook": "^4.0.0", + "universal-user-agent": "^7.0.0" + }, + "engines": { + "node": ">= 20" + } + }, + "node_modules/@octokit/endpoint": { + "version": "11.0.5", + "resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-11.0.5.tgz", + "integrity": "sha512-iXa654H3yFafF/ieHkukfbgWo2rmXD2ceD0ZOtrPhw1bc3FDch1d9N/TNs0FQ1/cIbwb7kspUX8jzIs8nzb9DQ==", + "license": "MIT", + "dependencies": { + "@octokit/types": "^18.0.0", + "universal-user-agent": "^7.0.2" + }, + "engines": { + "node": ">= 20" + } + }, + "node_modules/@octokit/graphql": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/@octokit/graphql/-/graphql-9.0.5.tgz", + "integrity": "sha512-bt/hm03LeU6Vy7FwTrkkC9p3XGT/lBwClglMqxBSe5/q0E5CdJTXeAqEI0vlw89/LF/G6tryTIH8HirZ3prMVg==", + "license": "MIT", + "dependencies": { + "@octokit/request": "^10.0.16", + "@octokit/types": "^18.0.0", + "universal-user-agent": "^7.0.0" + }, + "engines": { + "node": ">= 20" + } + }, + "node_modules/@octokit/openapi-types": { + "version": "29.0.1", + "resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-29.0.1.tgz", + "integrity": "sha512-9qWOMFNxxLokERcms42rU0PTLqQmVs7g5E41TI4mCOxmpFayD1rfC7XxOL55cG9MBZLFlC31BrR37myMKardwg==", + "license": "MIT" + }, + "node_modules/@octokit/plugin-paginate-rest": { + "version": "14.0.0", + "resolved": "https://registry.npmjs.org/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-14.0.0.tgz", + "integrity": "sha512-fNVRE7ufJiAA3XUrha2omTA39M6IXIc6GIZLvlbsm8QOQCYvpq/LkMNGyFlB1d8hTDzsAXa3OKtybdMAYsV/fw==", + "license": "MIT", + "dependencies": { + "@octokit/types": "^16.0.0" + }, + "engines": { + "node": ">= 20" + }, + "peerDependencies": { + "@octokit/core": ">=6" + } + }, + "node_modules/@octokit/plugin-paginate-rest/node_modules/@octokit/openapi-types": { + "version": "27.0.0", + "resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-27.0.0.tgz", + "integrity": "sha512-whrdktVs1h6gtR+09+QsNk2+FO+49j6ga1c55YZudfEG+oKJVvJLQi3zkOm5JjiUXAagWK2tI2kTGKJ2Ys7MGA==", + "license": "MIT" + }, + "node_modules/@octokit/plugin-paginate-rest/node_modules/@octokit/types": { + "version": "16.0.0", + "resolved": "https://registry.npmjs.org/@octokit/types/-/types-16.0.0.tgz", + "integrity": "sha512-sKq+9r1Mm4efXW1FCk7hFSeJo4QKreL/tTbR0rz/qx/r1Oa2VV83LTA/H/MuCOX7uCIJmQVRKBcbmWoySjAnSg==", + "license": "MIT", + "dependencies": { + "@octokit/openapi-types": "^27.0.0" + } + }, + "node_modules/@octokit/plugin-request-log": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/@octokit/plugin-request-log/-/plugin-request-log-6.0.0.tgz", + "integrity": "sha512-UkOzeEN3W91/eBq9sPZNQ7sUBvYCqYbrrD8gTbBuGtHEuycE4/awMXcYvx6sVYo7LypPhmQwwpUe4Yyu4QZN5Q==", + "license": "MIT", + "engines": { + "node": ">= 20" + }, + "peerDependencies": { + "@octokit/core": ">=6" + } + }, + "node_modules/@octokit/plugin-rest-endpoint-methods": { + "version": "17.0.0", + "resolved": "https://registry.npmjs.org/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-17.0.0.tgz", + "integrity": "sha512-B5yCyIlOJFPqUUeiD0cnBJwWJO8lkJs5d8+ze9QDP6SvfiXSz1BF+91+0MeI1d2yxgOhU/O+CvtiZ9jSkHhFAw==", + "license": "MIT", + "dependencies": { + "@octokit/types": "^16.0.0" + }, + "engines": { + "node": ">= 20" + }, + "peerDependencies": { + "@octokit/core": ">=6" + } + }, + "node_modules/@octokit/plugin-rest-endpoint-methods/node_modules/@octokit/openapi-types": { + "version": "27.0.0", + "resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-27.0.0.tgz", + "integrity": "sha512-whrdktVs1h6gtR+09+QsNk2+FO+49j6ga1c55YZudfEG+oKJVvJLQi3zkOm5JjiUXAagWK2tI2kTGKJ2Ys7MGA==", + "license": "MIT" + }, + "node_modules/@octokit/plugin-rest-endpoint-methods/node_modules/@octokit/types": { + "version": "16.0.0", + "resolved": "https://registry.npmjs.org/@octokit/types/-/types-16.0.0.tgz", + "integrity": "sha512-sKq+9r1Mm4efXW1FCk7hFSeJo4QKreL/tTbR0rz/qx/r1Oa2VV83LTA/H/MuCOX7uCIJmQVRKBcbmWoySjAnSg==", + "license": "MIT", + "dependencies": { + "@octokit/openapi-types": "^27.0.0" + } + }, + "node_modules/@octokit/request": { + "version": "10.0.16", + "resolved": "https://registry.npmjs.org/@octokit/request/-/request-10.0.16.tgz", + "integrity": "sha512-A0zWGjHzISIb+9ccG8s0dq7LKO5zVpJLRICjgUb+sJxEWqn8RUHB1rD3AE51+PECvXHIxqZ1VVvs4fHTSD9nUQ==", + "license": "MIT", + "dependencies": { + "@octokit/endpoint": "^11.0.5", + "@octokit/request-error": "^7.1.2", + "@octokit/types": "^18.0.0", + "content-type": "^3.0.0", + "json-with-bigint": "^3.5.12", + "universal-user-agent": "^7.0.2" + }, + "engines": { + "node": ">= 20" + } + }, + "node_modules/@octokit/request-error": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-7.1.2.tgz", + "integrity": "sha512-XZRuT3xZ84D3gYErI1DZvhJ33dCWVV6uzBtWkaBB4TvA/L6eOeTZodxLFVB44bBEEo3vEx7y00UfX1tBLrtLRg==", + "license": "MIT", + "dependencies": { + "@octokit/types": "^18.0.0" + }, + "engines": { + "node": ">= 20" + } + }, + "node_modules/@octokit/rest": { + "version": "22.0.1", + "resolved": "https://registry.npmjs.org/@octokit/rest/-/rest-22.0.1.tgz", + "integrity": "sha512-Jzbhzl3CEexhnivb1iQ0KJ7s5vvjMWcmRtq5aUsKmKDrRW6z3r84ngmiFKFvpZjpiU/9/S6ITPFRpn5s/3uQJw==", + "license": "MIT", + "dependencies": { + "@octokit/core": "^7.0.6", + "@octokit/plugin-paginate-rest": "^14.0.0", + "@octokit/plugin-request-log": "^6.0.0", + "@octokit/plugin-rest-endpoint-methods": "^17.0.0" + }, + "engines": { + "node": ">= 20" + } + }, + "node_modules/@octokit/types": { + "version": "18.0.0", + "resolved": "https://registry.npmjs.org/@octokit/types/-/types-18.0.0.tgz", + "integrity": "sha512-l6bAF43PNxkJp6g+W4PjoUSSkxHomXw2nOum5CTftJz1NlV3vu93NImgOYtLf6CbBUb5j+fiuzW0PPQ5JTSvZA==", + "license": "MIT", + "dependencies": { + "@octokit/openapi-types": "^29.0.1" + } + }, + "node_modules/abbrev": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-3.0.1.tgz", + "integrity": "sha512-AO2ac6pjRB3SJmGJo+v5/aK6Omggp6fsLrs6wN9bd35ulu4cCwaAU9+7ZhXjeqHVkaHThLuzH0nZr0YpCDhygg==", + "license": "ISC", + "engines": { + "node": "^18.17.0 || >=20.5.0" + } + }, + "node_modules/agent-base": { + "version": "7.1.4", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.4.tgz", + "integrity": "sha512-MnA+YT8fwfJPgBx3m60MNqakm30XOkyIoH1y6huTQvC0PwZG7ki8NacLBcrPbNoo8vEZy7Jpuk7+jMO+CUovTQ==", + "license": "MIT", + "engines": { + "node": ">= 14" + } + }, + "node_modules/ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "license": "MIT", + "dependencies": { + "color-convert": "^1.9.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/array-buffer-byte-length": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/array-buffer-byte-length/-/array-buffer-byte-length-1.0.2.tgz", + "integrity": "sha512-LHE+8BuR7RYGDKvnrmcuSq3tDcKv9OFEXQt/HpbZhY7V6h0zlUXutnAD82GiFx9rdieCMjkvtcsPqBwgUl1Iiw==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3", + "is-array-buffer": "^3.0.5" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/arraybuffer.prototype.slice": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/arraybuffer.prototype.slice/-/arraybuffer.prototype.slice-1.0.4.tgz", + "integrity": "sha512-BNoCY6SXXPQ7gF2opIP4GBE+Xw7U+pHMYKuzjgCN3GwiaIR09UUeKfheyIry77QtrCBlC0KK0q5/TER/tYh3PQ==", + "license": "MIT", + "dependencies": { + "array-buffer-byte-length": "^1.0.1", + "call-bind": "^1.0.8", + "define-properties": "^1.2.1", + "es-abstract": "^1.23.5", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.6", + "is-array-buffer": "^3.0.4" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/async-function": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/async-function/-/async-function-1.0.0.tgz", + "integrity": "sha512-hsU18Ae8CDTR6Kgu9DYf0EbCr/a5iGL0rytQDobUcdpYOKokk8LEjVphnXkDkgpi0wYVsqrXuP0bZxJaTqdgoA==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/available-typed-arrays": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.7.tgz", + "integrity": "sha512-wvUjBtSGN7+7SjNpq/9M2Tg350UZD3q62IFZLbRAR1bSMlCo1ZaeW+BJ+D090e4hIIZLBcTDWe4Mh4jvUDajzQ==", + "license": "MIT", + "dependencies": { + "possible-typed-array-names": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/balanced-match": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz", + "integrity": "sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==", + "license": "MIT", + "engines": { + "node": "18 || 20 || >=22" + } + }, + "node_modules/before-after-hook": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-4.0.0.tgz", + "integrity": "sha512-q6tR3RPqIB1pMiTRMFcZwuG5T8vwp+vUvEG0vuI6B+Rikh5BfPp2fQ82c925FOs+b0lcFQ8CFrL+KbilfZFhOQ==", + "license": "Apache-2.0" + }, + "node_modules/brace-expansion": { + "version": "5.0.12", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.12.tgz", + "integrity": "sha512-YovQ3rzhaLMIrDjNDMkNS01tea93qhEhG5xy8f6+R0l+dw3Ki+5sCoIoI942iuLZTHWogWktgwVDhU09iNEimQ==", + "license": "MIT", + "dependencies": { + "balanced-match": "^4.0.2" + }, + "engines": { + "node": "20 || >=22" + } + }, + "node_modules/call-bind": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.9.tgz", + "integrity": "sha512-a/hy+pNsFUTR+Iz8TCJvXudKVLAnz/DyeSUo10I5yvFDQJBFU2s9uqQpoSrJlroHUKoKqzg+epxyP9lqFdzfBQ==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "es-define-property": "^1.0.1", + "get-intrinsic": "^1.3.0", + "set-function-length": "^1.2.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/call-bind-apply-helpers": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz", + "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/call-bound": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz", + "integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "get-intrinsic": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "license": "MIT", + "dependencies": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/chownr": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-3.0.0.tgz", + "integrity": "sha512-+IxzY9BZOQd/XuYPRmrvEVjF/nqj5kgT4kEq7VofrDoM1MxoRjEWkrCC3EtLi59TVawxTAn+orJwFQcrqEN1+g==", + "license": "BlueOak-1.0.0", + "engines": { + "node": ">=18" + } + }, + "node_modules/color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "license": "MIT", + "dependencies": { + "color-name": "1.1.3" + } + }, + "node_modules/color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", + "license": "MIT" + }, + "node_modules/commander": { + "version": "14.0.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-14.0.3.tgz", + "integrity": "sha512-H+y0Jo/T1RZ9qPP4Eh1pkcQcLRglraJaSLoyOtHxu6AapkjWVCy2Sit1QQ4x3Dng8qDlSsZEet7g5Pq06MvTgw==", + "license": "MIT", + "engines": { + "node": ">=20" + } + }, + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", + "license": "MIT" + }, + "node_modules/consola": { + "version": "3.4.2", + "resolved": "https://registry.npmjs.org/consola/-/consola-3.4.2.tgz", + "integrity": "sha512-5IKcdX0nnYavi6G7TtOhwkYzyjfJlatbjMjuLSfE2kYT5pMDOilZ4OvMhi637CcDICTmz3wARPoyhqyX1Y+XvA==", + "license": "MIT", + "engines": { + "node": "^14.18.0 || >=16.10.0" + } + }, + "node_modules/content-type": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-3.1.1.tgz", + "integrity": "sha512-GW4qUsfFo59d0HbUibDlWv5wPz+vAAcaTWbKIuKCf0JkC7wWkSyf8f13IpXn5JkeMlB2P8iTSSIjwXljorg2vA==", + "license": "MIT", + "engines": { + "node": ">=22" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/cross-spawn": { + "version": "6.0.6", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.6.tgz", + "integrity": "sha512-VqCUuhcd1iB+dsv8gxPttb5iZh/D0iubSP21g36KXdEuf6I5JiioesUVjpCdHV9MZRUfVFlvwtIUyPfxo5trtw==", + "license": "MIT", + "dependencies": { + "nice-try": "^1.0.4", + "path-key": "^2.0.1", + "semver": "^5.5.0", + "shebang-command": "^1.2.0", + "which": "^1.2.9" + }, + "engines": { + "node": ">=4.8" + } + }, + "node_modules/cross-spawn/node_modules/semver": { + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz", + "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==", + "license": "ISC", + "bin": { + "semver": "bin/semver" + } + }, + "node_modules/data-view-buffer": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/data-view-buffer/-/data-view-buffer-1.0.2.tgz", + "integrity": "sha512-EmKO5V3OLXh1rtK2wgXRansaK1/mtVdTUEiEI0W8RkvgT05kfxaH29PliLnpLP73yYO6142Q72QNa8Wx/A5CqQ==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3", + "es-errors": "^1.3.0", + "is-data-view": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/data-view-byte-length": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/data-view-byte-length/-/data-view-byte-length-1.0.2.tgz", + "integrity": "sha512-tuhGbE6CfTM9+5ANGf+oQb72Ky/0+s3xKUpHvShfiz2RxMFgFPjsXuRLBVMtvMs15awe45SRb83D6wH4ew6wlQ==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3", + "es-errors": "^1.3.0", + "is-data-view": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/inspect-js" + } + }, + "node_modules/data-view-byte-offset": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/data-view-byte-offset/-/data-view-byte-offset-1.0.1.tgz", + "integrity": "sha512-BS8PfmtDGnrgYdOonGZQdLZslWIeCGFP9tpan0hi1Co2Zr2NKADsvGYA8XxuG/4UWgJ6Cjtv+YJnB6MM69QGlQ==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "is-data-view": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/debug": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/define-data-property": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz", + "integrity": "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==", + "license": "MIT", + "dependencies": { + "es-define-property": "^1.0.0", + "es-errors": "^1.3.0", + "gopd": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/define-properties": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.2.1.tgz", + "integrity": "sha512-8QmQKqEASLd5nx0U1B1okLElbUuuttJ/AnYmRXbbbGDWh6uS208EjD4Xqq/I9wK7u0v6O08XhTWnt5XtEbR6Dg==", + "license": "MIT", + "dependencies": { + "define-data-property": "^1.0.1", + "has-property-descriptors": "^1.0.0", + "object-keys": "^1.1.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/detect-libc": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz", + "integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==", + "license": "Apache-2.0", + "engines": { + "node": ">=8" + } + }, + "node_modules/dunder-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", + "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.1", + "es-errors": "^1.3.0", + "gopd": "^1.2.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/error-ex": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.4.tgz", + "integrity": "sha512-sqQamAnR14VgCr1A618A3sGrygcpK+HEbenA/HiEAkkUwcZIIB/tgWqHFxWgOyDh4nB4JCRimh79dR5Ywc9MDQ==", + "license": "MIT", + "dependencies": { + "is-arrayish": "^0.2.1" + } + }, + "node_modules/es-abstract": { + "version": "1.24.2", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.24.2.tgz", + "integrity": "sha512-2FpH9Q5i2RRwyEP1AylXe6nYLR5OhaJTZwmlcP0dL/+JCbgg7yyEo/sEK6HeGZRf3dFpWwThaRHVApXSkW3xeg==", + "license": "MIT", + "dependencies": { + "array-buffer-byte-length": "^1.0.2", + "arraybuffer.prototype.slice": "^1.0.4", + "available-typed-arrays": "^1.0.7", + "call-bind": "^1.0.8", + "call-bound": "^1.0.4", + "data-view-buffer": "^1.0.2", + "data-view-byte-length": "^1.0.2", + "data-view-byte-offset": "^1.0.1", + "es-define-property": "^1.0.1", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.1.1", + "es-set-tostringtag": "^2.1.0", + "es-to-primitive": "^1.3.0", + "function.prototype.name": "^1.1.8", + "get-intrinsic": "^1.3.0", + "get-proto": "^1.0.1", + "get-symbol-description": "^1.1.0", + "globalthis": "^1.0.4", + "gopd": "^1.2.0", + "has-property-descriptors": "^1.0.2", + "has-proto": "^1.2.0", + "has-symbols": "^1.1.0", + "hasown": "^2.0.2", + "internal-slot": "^1.1.0", + "is-array-buffer": "^3.0.5", + "is-callable": "^1.2.7", + "is-data-view": "^1.0.2", + "is-negative-zero": "^2.0.3", + "is-regex": "^1.2.1", + "is-set": "^2.0.3", + "is-shared-array-buffer": "^1.0.4", + "is-string": "^1.1.1", + "is-typed-array": "^1.1.15", + "is-weakref": "^1.1.1", + "math-intrinsics": "^1.1.0", + "object-inspect": "^1.13.4", + "object-keys": "^1.1.1", + "object.assign": "^4.1.7", + "own-keys": "^1.0.1", + "regexp.prototype.flags": "^1.5.4", + "safe-array-concat": "^1.1.3", + "safe-push-apply": "^1.0.0", + "safe-regex-test": "^1.1.0", + "set-proto": "^1.0.0", + "stop-iteration-iterator": "^1.1.0", + "string.prototype.trim": "^1.2.10", + "string.prototype.trimend": "^1.0.9", + "string.prototype.trimstart": "^1.0.8", + "typed-array-buffer": "^1.0.3", + "typed-array-byte-length": "^1.0.3", + "typed-array-byte-offset": "^1.0.4", + "typed-array-length": "^1.0.7", + "unbox-primitive": "^1.1.0", + "which-typed-array": "^1.1.19" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/es-abstract-get": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/es-abstract-get/-/es-abstract-get-1.0.0.tgz", + "integrity": "sha512-6PMWXpdhshVvFp+FoWYs1EvG1Nj0tvk0dZM+XcK0xMEM1czRVcP6ohqPWHy6qPagSpC8j4+p89WXlT+xXJs/fg==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "es-object-atoms": "^1.1.2", + "is-callable": "^1.2.7", + "object-inspect": "^1.13.4" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/es-define-property": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", + "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-object-atoms": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.2.tgz", + "integrity": "sha512-HWcBoN6NileqtSydK2FqHbS/LoDd2pqrnQHLyJzBj4kOp/ky2MWMN694xOfkK8/SnUsW2DH7EfyVlydKCsm1Zw==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-set-tostringtag": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.1.0.tgz", + "integrity": "sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.6", + "has-tostringtag": "^1.0.2", + "hasown": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-to-primitive": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.3.4.tgz", + "integrity": "sha512-yPDz7wqpg1/mmHLmS3tcfTfbw5f1eryXvyghYBffGdERwe+mV7ZcWzTR8LR17Kvqt3qfPurjlonmnq3MKXIOXw==", + "license": "MIT", + "dependencies": { + "es-abstract-get": "^1.0.0", + "es-define-property": "^1.0.1", + "es-errors": "^1.3.0", + "is-callable": "^1.2.7", + "is-date-object": "^1.1.0", + "is-symbol": "^1.1.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", + "license": "MIT", + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/for-each": { + "version": "0.3.5", + "resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.5.tgz", + "integrity": "sha512-dKx12eRCVIzqCxFGplyFKJMPvLEWgmNtUrpTiJIR5u97zEhRG8ySrtboPHZXx7daLxQVrl643cTzbab2tkQjxg==", + "license": "MIT", + "dependencies": { + "is-callable": "^1.2.7" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/function.prototype.name": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/function.prototype.name/-/function.prototype.name-1.2.0.tgz", + "integrity": "sha512-jObKIik1P2QjPHP5nz5BaOtUlfgS0fWo8IUByNXkM+o+02sJOi94em77GwJKQSJ3gfPHdgzLNrHc1uokV4P/ew==", + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.9", + "call-bound": "^1.0.4", + "es-define-property": "^1.0.1", + "es-errors": "^1.3.0", + "functions-have-names": "^1.2.3", + "has-property-descriptors": "^1.0.2", + "hasown": "^2.0.4", + "is-callable": "^1.2.7", + "is-document.all": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/functions-have-names": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/functions-have-names/-/functions-have-names-1.2.3.tgz", + "integrity": "sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/generator-function": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/generator-function/-/generator-function-2.0.1.tgz", + "integrity": "sha512-SFdFmIJi+ybC0vjlHN0ZGVGHc3lgE0DxPAT0djjVg+kjOnSqclqmj0KQ7ykTOLP6YxoqOvuAODGdcHJn+43q3g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/get-intrinsic": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz", + "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "es-define-property": "^1.0.1", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.1.1", + "function-bind": "^1.1.2", + "get-proto": "^1.0.1", + "gopd": "^1.2.0", + "has-symbols": "^1.1.0", + "hasown": "^2.0.2", + "math-intrinsics": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz", + "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==", + "license": "MIT", + "dependencies": { + "dunder-proto": "^1.0.1", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/get-symbol-description": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/get-symbol-description/-/get-symbol-description-1.1.0.tgz", + "integrity": "sha512-w9UMqWwJxHNOvoNzSJ2oPF5wvYcvP7jUvYzhp67yEhTi17ZDBBC1z9pTdGuzjD+EFIqLSYRweZjqfiPzQ06Ebg==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.6" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/globalthis": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/globalthis/-/globalthis-1.0.4.tgz", + "integrity": "sha512-DpLKbNU4WylpxJykQujfCcwYWiV/Jhm50Goo0wrVILAv5jOr9d+H+UR3PhSCD2rCCEIg0uc+G+muBTwD54JhDQ==", + "license": "MIT", + "dependencies": { + "define-properties": "^1.2.1", + "gopd": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/gopd": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", + "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/graceful-fs": { + "version": "4.2.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", + "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", + "license": "ISC" + }, + "node_modules/has-bigints": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/has-bigints/-/has-bigints-1.1.0.tgz", + "integrity": "sha512-R3pbpkcIqv2Pm3dUwgjclDRVmWpTJW2DcMzcIhEXEx1oh/CEMObMm3KLmRJOdvhM7o4uQBnwr8pzRK2sJWIqfg==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/has-property-descriptors": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz", + "integrity": "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==", + "license": "MIT", + "dependencies": { + "es-define-property": "^1.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-proto": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/has-proto/-/has-proto-1.2.0.tgz", + "integrity": "sha512-KIL7eQPfHQRC8+XluaIw7BHUwwqL19bQn4hzNgdr+1wXoU0KKj6rufu47lhY7KbJR2C6T6+PfyN0Ea7wkSS+qQ==", + "license": "MIT", + "dependencies": { + "dunder-proto": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-symbols": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", + "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-tostringtag": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.2.tgz", + "integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==", + "license": "MIT", + "dependencies": { + "has-symbols": "^1.0.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/hasown": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.4.tgz", + "integrity": "sha512-T2UbfbBEF32wiepXIsMlTW9+dDYC6wMh/t/vYA4tuOMKqWz/n3vr1NFSxQiyP+zk2mXsoMA/i/7qV6LKut1t1A==", + "license": "MIT", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/hosted-git-info": { + "version": "2.8.9", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.9.tgz", + "integrity": "sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==", + "license": "ISC" + }, + "node_modules/https-proxy-agent": { + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.6.tgz", + "integrity": "sha512-vK9P5/iUfdl95AI+JVyUuIcVtd4ofvtrOr3HNtM2yxC9bnMbEdp3x01OhQNnjb8IJYi38VlTE3mBXwcfvywuSw==", + "license": "MIT", + "dependencies": { + "agent-base": "^7.1.2", + "debug": "4" + }, + "engines": { + "node": ">= 14" + } + }, + "node_modules/internal-slot": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/internal-slot/-/internal-slot-1.1.0.tgz", + "integrity": "sha512-4gd7VpWNQNB4UKKCFFVcp1AVv+FMOgs9NKzjHKusc8jTMhd5eL1NqQqOpE0KzMds804/yHlglp3uxgluOqAPLw==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "hasown": "^2.0.2", + "side-channel": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/is-array-buffer": { + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/is-array-buffer/-/is-array-buffer-3.0.5.tgz", + "integrity": "sha512-DDfANUiiG2wC1qawP66qlTugJeL5HyzMpfr8lLK+jMQirGzNod0B12cFB/9q838Ru27sBwfw78/rdoU7RERz6A==", + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.8", + "call-bound": "^1.0.3", + "get-intrinsic": "^1.2.6" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-arrayish": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", + "integrity": "sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==", + "license": "MIT" + }, + "node_modules/is-async-function": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-async-function/-/is-async-function-2.1.1.tgz", + "integrity": "sha512-9dgM/cZBnNvjzaMYHVoxxfPj2QXt22Ev7SuuPrs+xav0ukGB0S6d4ydZdEiM48kLx5kDV+QBPrpVnFyefL8kkQ==", + "license": "MIT", + "dependencies": { + "async-function": "^1.0.0", + "call-bound": "^1.0.3", + "get-proto": "^1.0.1", + "has-tostringtag": "^1.0.2", + "safe-regex-test": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-bigint": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-bigint/-/is-bigint-1.1.0.tgz", + "integrity": "sha512-n4ZT37wG78iz03xPRKJrHTdZbe3IicyucEtdRsV5yglwc3GyUfbAfpSeD0FJ41NbUNSt5wbhqfp1fS+BgnvDFQ==", + "license": "MIT", + "dependencies": { + "has-bigints": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-boolean-object": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/is-boolean-object/-/is-boolean-object-1.2.2.tgz", + "integrity": "sha512-wa56o2/ElJMYqjCjGkXri7it5FbebW5usLw/nPmCMs5DeZ7eziSYZhSmPRn0txqeW4LnAmQQU7FgqLpsEFKM4A==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3", + "has-tostringtag": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-callable": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.7.tgz", + "integrity": "sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-core-module": { + "version": "2.17.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.17.0.tgz", + "integrity": "sha512-J/vG0zBCbIKOQFfufSwyXdMrsohyJIUNkrnmo6WZGzoM7tr/lsbfW5b2BvisL6zsyMzK9UxV9L6c7AoFbyXHOA==", + "license": "MIT", + "dependencies": { + "hasown": "^2.0.4" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-data-view": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-data-view/-/is-data-view-1.0.2.tgz", + "integrity": "sha512-RKtWF8pGmS87i2D6gqQu/l7EYRlVdfzemCJN/P3UOs//x1QE7mfhvzHIApBTRf7axvT6DMGwSwBXYCT0nfB9xw==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "get-intrinsic": "^1.2.6", + "is-typed-array": "^1.1.13" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-date-object": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.1.0.tgz", + "integrity": "sha512-PwwhEakHVKTdRNVOw+/Gyh0+MzlCl4R6qKvkhuvLtPMggI1WAHt9sOwZxQLSGpUaDnrdyDsomoRgNnCfKNSXXg==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "has-tostringtag": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-document.all": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-document.all/-/is-document.all-1.0.0.tgz", + "integrity": "sha512-+XSoyS05OdBbhFuELhgTCpFNHkpBOJqtsZfUFFpe5QTw+9Sjbh8zitxhQkYAo6wV7e1Vb8cAPvpCk9jGam/82g==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.4" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-finalizationregistry": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/is-finalizationregistry/-/is-finalizationregistry-1.1.1.tgz", + "integrity": "sha512-1pC6N8qWJbWoPtEjgcL2xyhQOP491EQjeUo3qTKcmV8YSDDJrOepfG8pcC7h/QgnQHYSv0mJ3Z/ZWxmatVrysg==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-generator-function": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/is-generator-function/-/is-generator-function-1.1.2.tgz", + "integrity": "sha512-upqt1SkGkODW9tsGNG5mtXTXtECizwtS2kA161M+gJPc1xdb/Ax629af6YrTwcOeQHbewrPNlE5Dx7kzvXTizA==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.4", + "generator-function": "^2.0.0", + "get-proto": "^1.0.1", + "has-tostringtag": "^1.0.2", + "safe-regex-test": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-map": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/is-map/-/is-map-2.0.3.tgz", + "integrity": "sha512-1Qed0/Hr2m+YqxnM09CjA2d/i6YZNfF6R2oRAOj36eUdS6qIV/huPJNSEpKbupewFs+ZsJlxsjjPbc0/afW6Lw==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-negative-zero": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/is-negative-zero/-/is-negative-zero-2.0.3.tgz", + "integrity": "sha512-5KoIu2Ngpyek75jXodFvnafB6DJgr3u8uuK0LEZJjrU19DrMD3EVERaR8sjz8CCGgpZvxPl9SuE1GMVPFHx1mw==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-number-object": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/is-number-object/-/is-number-object-1.1.1.tgz", + "integrity": "sha512-lZhclumE1G6VYD8VHe35wFaIif+CTy5SJIi5+3y4psDgWu4wPDoBhF8NxUOinEc7pHgiTsT6MaBb92rKhhD+Xw==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3", + "has-tostringtag": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-regex": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.2.1.tgz", + "integrity": "sha512-MjYsKHO5O7mCsmRGxWcLWheFqN9DJ/2TmngvjKXihe6efViPqc274+Fx/4fYj/r03+ESvBdTXK0V6tA3rgez1g==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "gopd": "^1.2.0", + "has-tostringtag": "^1.0.2", + "hasown": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-set": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/is-set/-/is-set-2.0.3.tgz", + "integrity": "sha512-iPAjerrse27/ygGLxw+EBR9agv9Y6uLeYVJMu+QNCoouJ1/1ri0mGrcWpfCqFZuzzx3WjtwxG098X+n4OuRkPg==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-shared-array-buffer": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/is-shared-array-buffer/-/is-shared-array-buffer-1.0.4.tgz", + "integrity": "sha512-ISWac8drv4ZGfwKl5slpHG9OwPNty4jOWPRIhBpxOoD+hqITiwuipOQ2bNthAzwA3B4fIjO4Nln74N0S9byq8A==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-string": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/is-string/-/is-string-1.1.1.tgz", + "integrity": "sha512-BtEeSsoaQjlSPBemMQIrY1MY0uM6vnS1g5fmufYOtnxLGUZM2178PKbhsk7Ffv58IX+ZtcvoGwccYsh0PglkAA==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3", + "has-tostringtag": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-symbol": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.1.1.tgz", + "integrity": "sha512-9gGx6GTtCQM73BgmHQXfDmLtfjjTUDSyoxTCbp5WtoixAhfgsDirWIcVQ/IHpvI5Vgd5i/J5F7B9cN/WlVbC/w==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "has-symbols": "^1.1.0", + "safe-regex-test": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-typed-array": { + "version": "1.1.15", + "resolved": "https://registry.npmjs.org/is-typed-array/-/is-typed-array-1.1.15.tgz", + "integrity": "sha512-p3EcsicXjit7SaskXHs1hA91QxgTw46Fv6EFKKGS5DRFLD8yKnohjF3hxoju94b/OcMZoQukzpPpBE9uLVKzgQ==", + "license": "MIT", + "dependencies": { + "which-typed-array": "^1.1.16" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-weakmap": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/is-weakmap/-/is-weakmap-2.0.2.tgz", + "integrity": "sha512-K5pXYOm9wqY1RgjpL3YTkF39tni1XajUIkawTLUo9EZEVUFga5gSQJF8nNS7ZwJQ02y+1YCNYcMh+HIf1ZqE+w==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-weakref": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/is-weakref/-/is-weakref-1.1.1.tgz", + "integrity": "sha512-6i9mGWSlqzNMEqpCp93KwRS1uUOodk2OJ6b+sq7ZPDSy2WuI5NFIxp/254TytR8ftefexkWn5xNiHUNpPOfSew==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-weakset": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/is-weakset/-/is-weakset-2.0.4.tgz", + "integrity": "sha512-mfcwb6IzQyOKTs84CQMrOwW4gQcaTOAWJ0zzJCl2WSPDrWk/OzDaImWFH3djXhb24g4eudZfLRozAvPGw4d9hQ==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3", + "get-intrinsic": "^1.2.6" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/isarray": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.5.tgz", + "integrity": "sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw==", + "license": "MIT" + }, + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "license": "ISC" + }, + "node_modules/json-parse-better-errors": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz", + "integrity": "sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw==", + "license": "MIT" + }, + "node_modules/json-with-bigint": { + "version": "3.5.12", + "resolved": "https://registry.npmjs.org/json-with-bigint/-/json-with-bigint-3.5.12.tgz", + "integrity": "sha512-uwbF/wSSuOgC7qqlq27Xp5B6a2MHVug3t0idZdTqu0JnlFvgJuH7ju+KAk/J06C7GfhoYy2gnb9wz2INqcne7w==", + "license": "MIT" + }, + "node_modules/load-json-file": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-4.0.0.tgz", + "integrity": "sha512-Kx8hMakjX03tiGTLAIdJ+lL0htKnXjEZN6hk/tozf/WOuYGdZBJrZ+rCJRbVCugsjB3jMLn9746NsQIf5VjBMw==", + "license": "MIT", + "dependencies": { + "graceful-fs": "^4.1.2", + "parse-json": "^4.0.0", + "pify": "^3.0.0", + "strip-bom": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/math-intrinsics": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", + "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/memorystream": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/memorystream/-/memorystream-0.3.1.tgz", + "integrity": "sha512-S3UwM3yj5mtUSEfP41UZmt/0SCoVYUcU1rkXv+BQ5Ig8ndL4sPoJNBUJERafdPb5jjHJGuMgytgKvKIf58XNBw==", + "engines": { + "node": ">= 0.10.0" + } + }, + "node_modules/minimatch": { + "version": "10.2.6", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.6.tgz", + "integrity": "sha512-vpLQEs+VLCr1nU0BXS07maYoFwlDAH0gngQuuttxIwutDFEMHq2blX+8vpgxDdK3J1PwjCJiep77OitTZ4Ll1A==", + "license": "BlueOak-1.0.0", + "dependencies": { + "brace-expansion": "^5.0.8" + }, + "engines": { + "node": "18 || 20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/minipass": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.3.tgz", + "integrity": "sha512-tEBHqDnIoM/1rXME1zgka9g6Q2lcoCkxHLuc7ODJ5BxbP5d4c2Z5cGgtXAku59200Cx7diuHTOYfSBD8n6mm8A==", + "license": "BlueOak-1.0.0", + "engines": { + "node": ">=16 || 14 >=14.17" + } + }, + "node_modules/minizlib": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-3.1.0.tgz", + "integrity": "sha512-KZxYo1BUkWD2TVFLr0MQoM8vUUigWD3LlD83a/75BqC+4qE0Hb1Vo5v1FgcfaNXvfXzr+5EhQ6ing/CaBijTlw==", + "license": "MIT", + "dependencies": { + "minipass": "^7.1.2" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "license": "MIT" + }, + "node_modules/nice-try": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz", + "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==", + "license": "MIT" + }, + "node_modules/node-fetch": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", + "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", + "license": "MIT", + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } + } + }, + "node_modules/nopt": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-8.1.0.tgz", + "integrity": "sha512-ieGu42u/Qsa4TFktmaKEwM6MQH0pOWnaB3htzh0JRtx84+Mebc0cbZYN5bC+6WTZ4+77xrL9Pn5m7CV6VIkV7A==", + "license": "ISC", + "dependencies": { + "abbrev": "^3.0.0" + }, + "bin": { + "nopt": "bin/nopt.js" + }, + "engines": { + "node": "^18.17.0 || >=20.5.0" + } + }, + "node_modules/normalize-package-data": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", + "integrity": "sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==", + "license": "BSD-2-Clause", + "dependencies": { + "hosted-git-info": "^2.1.4", + "resolve": "^1.10.0", + "semver": "2 || 3 || 4 || 5", + "validate-npm-package-license": "^3.0.1" + } + }, + "node_modules/normalize-package-data/node_modules/semver": { + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz", + "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==", + "license": "ISC", + "bin": { + "semver": "bin/semver" + } + }, + "node_modules/npm-run-all": { + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/npm-run-all/-/npm-run-all-4.1.5.tgz", + "integrity": "sha512-Oo82gJDAVcaMdi3nuoKFavkIHBRVqQ1qvMb+9LHk/cF4P6B2m8aP04hGf7oL6wZ9BuGwX1onlLhpuoofSyoQDQ==", + "license": "MIT", + "dependencies": { + "ansi-styles": "^3.2.1", + "chalk": "^2.4.1", + "cross-spawn": "^6.0.5", + "memorystream": "^0.3.1", + "minimatch": "^3.0.4", + "pidtree": "^0.3.0", + "read-pkg": "^3.0.0", + "shell-quote": "^1.6.1", + "string.prototype.padend": "^3.0.0" + }, + "bin": { + "npm-run-all": "bin/npm-run-all/index.js", + "run-p": "bin/run-p/index.js", + "run-s": "bin/run-s/index.js" + }, + "engines": { + "node": ">= 4" + } + }, + "node_modules/npm-run-all/node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "license": "MIT" + }, + "node_modules/npm-run-all/node_modules/brace-expansion": { + "version": "1.1.21", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.21.tgz", + "integrity": "sha512-9zeA+KLZNNzglF2TPKRQEDyx6Yby7daAkuy8MiPzpXPsYDWi/DRM8jmwUDxokQjYqBpv5DgPiwD4h4ZZSy1Ujw==", + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/npm-run-all/node_modules/minimatch": { + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.5.tgz", + "integrity": "sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==", + "license": "ISC", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/object-inspect": { + "version": "1.13.4", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz", + "integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/object-keys": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", + "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/object.assign": { + "version": "4.1.7", + "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.7.tgz", + "integrity": "sha512-nK28WOo+QIjBkDduTINE4JkF/UJJKyf2EJxvJKfblDpyg0Q+pkOHNTL0Qwy6NP6FhE/EnzV73BxxqcJaXY9anw==", + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.8", + "call-bound": "^1.0.3", + "define-properties": "^1.2.1", + "es-object-atoms": "^1.0.0", + "has-symbols": "^1.1.0", + "object-keys": "^1.1.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/own-keys": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/own-keys/-/own-keys-1.0.2.tgz", + "integrity": "sha512-19YVAg7T+WTrxggPukVq7DjTv6+PJ867TmhCvBsYwmbFCsZd344rq2Ld1p0wo8f8Qrrhgp82c6FJRqdXWtSEhg==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.4", + "get-intrinsic": "^1.3.0", + "object-keys": "^1.1.1", + "safe-push-apply": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/parse-json": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-4.0.0.tgz", + "integrity": "sha512-aOIos8bujGN93/8Ox/jPLh7RwVnPEysynVFE+fQZyg6jKELEHwzgKdLRFHUgXJL6kylijVSBC4BvN9OmsB48Rw==", + "license": "MIT", + "dependencies": { + "error-ex": "^1.3.1", + "json-parse-better-errors": "^1.0.1" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/path-key": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", + "integrity": "sha512-fEHGKCSmUSDPv4uoj8AlD+joPlq3peND+HRYyxFz4KPw4z926S/b8rIuFs2FYJg3BwsxJf6A9/3eIdLaYC+9Dw==", + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/path-parse": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", + "license": "MIT" + }, + "node_modules/path-type": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-3.0.0.tgz", + "integrity": "sha512-T2ZUsdZFHgA3u4e5PfPbjd7HDDpxPnQb5jN0SrDsjNSuVXHJqtwTnWqG0B1jZrgmJ/7lj1EmVIByWt1gxGkWvg==", + "license": "MIT", + "dependencies": { + "pify": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/pidtree": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/pidtree/-/pidtree-0.3.1.tgz", + "integrity": "sha512-qQbW94hLHEqCg7nhby4yRC7G2+jYHY4Rguc2bjw7Uug4GIJuu1tvf2uHaZv5Q8zdt+WKJ6qK1FOI6amaWUo5FA==", + "license": "MIT", + "bin": { + "pidtree": "bin/pidtree.js" + }, + "engines": { + "node": ">=0.10" + } + }, + "node_modules/pify": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", + "integrity": "sha512-C3FsVNH1udSEX48gGX1xfvwTWfsYWj5U+8/uK15BGzIGrKoUpghX8hWZwa/OFnakBiiVNmBvemTJR5mcy7iPcg==", + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/possible-typed-array-names": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/possible-typed-array-names/-/possible-typed-array-names-1.1.0.tgz", + "integrity": "sha512-/+5VFTchJDoVj3bhoqi6UeymcD00DAwb1nJwamzPvHEszJ4FpF6SNNbUbOS8yI56qHzdV8eK0qEfOSiodkTdxg==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/read-pkg": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-3.0.0.tgz", + "integrity": "sha512-BLq/cCO9two+lBgiTYNqD6GdtK8s4NpaWrl6/rCO9w0TUS8oJl7cmToOZfRYllKTISY6nt1U7jQ53brmKqY6BA==", + "license": "MIT", + "dependencies": { + "load-json-file": "^4.0.0", + "normalize-package-data": "^2.3.2", + "path-type": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/reflect.getprototypeof": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/reflect.getprototypeof/-/reflect.getprototypeof-1.0.10.tgz", + "integrity": "sha512-00o4I+DVrefhv+nX0ulyi3biSHCPDe+yLv5o/p6d/UVlirijB8E16FtfwSAi4g3tcqrQ4lRAqQSoFEZJehYEcw==", + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.8", + "define-properties": "^1.2.1", + "es-abstract": "^1.23.9", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.0.0", + "get-intrinsic": "^1.2.7", + "get-proto": "^1.0.1", + "which-builtin-type": "^1.2.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/regexp.prototype.flags": { + "version": "1.5.4", + "resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.5.4.tgz", + "integrity": "sha512-dYqgNSZbDwkaJ2ceRd9ojCGjBq+mOm9LmtXnAnEGyHhN/5R7iDW2TRw3h+o/jCFxus3P2LfWIIiwowAjANm7IA==", + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.8", + "define-properties": "^1.2.1", + "es-errors": "^1.3.0", + "get-proto": "^1.0.1", + "gopd": "^1.2.0", + "set-function-name": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/resolve": { + "version": "1.22.13", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.13.tgz", + "integrity": "sha512-Dj/cW9zBV2aRj6XzCxuGIs3ESZKv02jixne3q6jFZYZ3/Tg09gHHviSMDL4kObh9pqSahdRHEnDoaP2gn8YLhA==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "is-core-module": "^2.17.0", + "path-parse": "^1.0.7", + "supports-preserve-symlinks-flag": "^1.0.0" + }, + "bin": { + "resolve": "bin/resolve" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/safe-array-concat": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/safe-array-concat/-/safe-array-concat-1.1.4.tgz", + "integrity": "sha512-wtZlHyOje6OZTGqAoaDKxFkgRtkF9CnHAVnCHKfuj200wAgL+bSJhdsCD2l0Qx/2ekEXjPWcyKkfGb5CPboslg==", + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.9", + "call-bound": "^1.0.4", + "get-intrinsic": "^1.3.0", + "has-symbols": "^1.1.0", + "isarray": "^2.0.5" + }, + "engines": { + "node": ">=0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/safe-push-apply": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/safe-push-apply/-/safe-push-apply-1.0.0.tgz", + "integrity": "sha512-iKE9w/Z7xCzUMIZqdBsp6pEQvwuEebH4vdpjcDWnyzaI6yl6O9FHvVpmGelvEHNsoY6wGblkxR6Zty/h00WiSA==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "isarray": "^2.0.5" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/safe-regex-test": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/safe-regex-test/-/safe-regex-test-1.1.0.tgz", + "integrity": "sha512-x/+Cz4YrimQxQccJf5mKEbIa1NzeCRNI5Ecl/ekmlYaampdNLPalVyIcCZNNH3MvmqBugV5TMYZXv0ljslUlaw==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "is-regex": "^1.2.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/semver": { + "version": "7.8.5", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz", + "integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==", + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/set-function-length": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.2.tgz", + "integrity": "sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg==", + "license": "MIT", + "dependencies": { + "define-data-property": "^1.1.4", + "es-errors": "^1.3.0", + "function-bind": "^1.1.2", + "get-intrinsic": "^1.2.4", + "gopd": "^1.0.1", + "has-property-descriptors": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/set-function-name": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/set-function-name/-/set-function-name-2.0.2.tgz", + "integrity": "sha512-7PGFlmtwsEADb0WYyvCMa1t+yke6daIG4Wirafur5kcf+MhUnPms1UeR0CKQdTZD81yESwMHbtn+TR+dMviakQ==", + "license": "MIT", + "dependencies": { + "define-data-property": "^1.1.4", + "es-errors": "^1.3.0", + "functions-have-names": "^1.2.3", + "has-property-descriptors": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/set-proto": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/set-proto/-/set-proto-1.0.0.tgz", + "integrity": "sha512-RJRdvCo6IAnPdsvP/7m6bsQqNnn1FCBX5ZNtFL98MmFF/4xAIJTIg1YbHW5DC2W5SKZanrC6i4HsJqlajw/dZw==", + "license": "MIT", + "dependencies": { + "dunder-proto": "^1.0.1", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/sharp": { + "version": "0.35.5", + "resolved": "https://registry.npmjs.org/sharp/-/sharp-0.35.5.tgz", + "integrity": "sha512-Ywn4OnzGukp7CDMrp08RQ50YKmuwG47brZgIVPTvBaaAfQlRlygrRqSrxdCiL9M+LlzLBiJ68IR1QqvzHyjC7g==", + "license": "Apache-2.0", + "dependencies": { + "@img/colour": "^1.1.0", + "detect-libc": "^2.1.2", + "semver": "^7.8.5" + }, + "engines": { + "node": ">=20.9.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-darwin-arm64": "0.35.5", + "@img/sharp-darwin-x64": "0.35.5", + "@img/sharp-freebsd-wasm32": "0.35.5", + "@img/sharp-libvips-darwin-arm64": "1.3.4", + "@img/sharp-libvips-darwin-x64": "1.3.4", + "@img/sharp-libvips-linux-arm": "1.3.4", + "@img/sharp-libvips-linux-arm64": "1.3.4", + "@img/sharp-libvips-linux-ppc64": "1.3.4", + "@img/sharp-libvips-linux-riscv64": "1.3.4", + "@img/sharp-libvips-linux-s390x": "1.3.4", + "@img/sharp-libvips-linux-x64": "1.3.4", + "@img/sharp-libvips-linuxmusl-arm64": "1.3.4", + "@img/sharp-libvips-linuxmusl-x64": "1.3.4", + "@img/sharp-linux-arm": "0.35.5", + "@img/sharp-linux-arm64": "0.35.5", + "@img/sharp-linux-ppc64": "0.35.5", + "@img/sharp-linux-riscv64": "0.35.5", + "@img/sharp-linux-s390x": "0.35.5", + "@img/sharp-linux-x64": "0.35.5", + "@img/sharp-linuxmusl-arm64": "0.35.5", + "@img/sharp-linuxmusl-x64": "0.35.5", + "@img/sharp-webcontainers-wasm32": "0.35.5", + "@img/sharp-win32-arm64": "0.35.5", + "@img/sharp-win32-ia32": "0.35.5", + "@img/sharp-win32-x64": "0.35.5" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + } + } + }, + "node_modules/shebang-command": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", + "integrity": "sha512-EV3L1+UQWGor21OmnvojK36mhg+TyIKDh3iFBKBohr5xeXIhNBcx8oWdgkTEEQ+BEFFYdLRuqMfd5L84N1V5Vg==", + "license": "MIT", + "dependencies": { + "shebang-regex": "^1.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/shebang-regex": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", + "integrity": "sha512-wpoSFAxys6b2a2wHZ1XpDSgD7N9iVjg29Ph9uV/uaP9Ex/KXlkTZTeddxDPSYQpgvzKLGJke2UU0AzoGCjNIvQ==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/shell-quote": { + "version": "1.12.0", + "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.12.0.tgz", + "integrity": "sha512-PcByqNyT/38F2kDNi006HAMRJaULuBzq/FOsw3qdZvX/GA9W/jamDaRskgHjubHiftXK5sIFxLNkvrXUwcof6Q==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.1.tgz", + "integrity": "sha512-6x6dK6zJdpTzF4sQeNYxwtvBzf6Eg4GtlesS94HOvTudUeyK2WXAaIfmDgsyslYrRBeFIlsi54AYsFGUuhmvrQ==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.4", + "side-channel-list": "^1.0.1", + "side-channel-map": "^1.0.1", + "side-channel-weakmap": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-list": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.1.tgz", + "integrity": "sha512-mjn/0bi/oUURjc5Xl7IaWi/OJJJumuoJFQJfDDyO46+hBWsfaVM65TBHq2eoZBhzl9EchxOijpkbRC8SVBQU0w==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.4" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-map": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz", + "integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-weakmap": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz", + "integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3", + "side-channel-map": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/spdx-correct": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.2.0.tgz", + "integrity": "sha512-kN9dJbvnySHULIluDHy32WHRUu3Og7B9sbY7tsFLctQkIqnMh3hErYgdMjTYuqmcXX+lK5T1lnUt3G7zNswmZA==", + "license": "Apache-2.0", + "dependencies": { + "spdx-expression-parse": "^3.0.0", + "spdx-license-ids": "^3.0.0" + } + }, + "node_modules/spdx-exceptions": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.5.0.tgz", + "integrity": "sha512-PiU42r+xO4UbUS1buo3LPJkjlO7430Xn5SVAhdpzzsPHsjbYVflnnFdATgabnLude+Cqu25p6N+g2lw/PFsa4w==", + "license": "CC-BY-3.0" + }, + "node_modules/spdx-expression-parse": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.1.tgz", + "integrity": "sha512-cbqHunsQWnJNE6KhVSMsMeH5H/L9EpymbzqTQ3uLwNCLZ1Q481oWaofqH7nO6V07xlXwY6PhQdQ2IedWx/ZK4Q==", + "license": "MIT", + "dependencies": { + "spdx-exceptions": "^2.1.0", + "spdx-license-ids": "^3.0.0" + } + }, + "node_modules/spdx-license-ids": { + "version": "3.0.24", + "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.24.tgz", + "integrity": "sha512-cLS9TtWkIQFyLkJ3/5aFQAOHOSKTlOs/7WDut/XPSdjom1fJhUdkepeJAKXa9Y05+FabHd0sti+Et559vDtkpQ==", + "license": "CC0-1.0" + }, + "node_modules/stop-iteration-iterator": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/stop-iteration-iterator/-/stop-iteration-iterator-1.1.0.tgz", + "integrity": "sha512-eLoXW/DHyl62zxY4SCaIgnRhuMr6ri4juEYARS8E6sCEqzKpOiE521Ucofdx+KnDZl5xmvGYaaKCk5FEOxJCoQ==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "internal-slot": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/string.prototype.padend": { + "version": "3.1.6", + "resolved": "https://registry.npmjs.org/string.prototype.padend/-/string.prototype.padend-3.1.6.tgz", + "integrity": "sha512-XZpspuSB7vJWhvJc9DLSlrXl1mcA2BdoY5jjnS135ydXqLoqhs96JjDtCkjJEQHvfqZIp9hBuBMgI589peyx9Q==", + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.7", + "define-properties": "^1.2.1", + "es-abstract": "^1.23.2", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/string.prototype.trim": { + "version": "1.2.11", + "resolved": "https://registry.npmjs.org/string.prototype.trim/-/string.prototype.trim-1.2.11.tgz", + "integrity": "sha512-PwvK7BU+CMTJGYQCTZb5RWXIML92lftJLhQz1tBzgKiqGxJaMlBAa48POXaNAC2s4y8jr3EFqrkF9+44neS46w==", + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.9", + "call-bound": "^1.0.4", + "define-data-property": "^1.1.4", + "define-properties": "^1.2.1", + "es-abstract": "^1.24.2", + "es-object-atoms": "^1.1.2", + "has-property-descriptors": "^1.0.2", + "safe-regex-test": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/string.prototype.trimend": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/string.prototype.trimend/-/string.prototype.trimend-1.0.10.tgz", + "integrity": "sha512-2+3aDAOmPTmuFwjDnmJG2ctEkQKVki7vOSqaxkv42Mowj1V6PnvuwFCRrR5lChUux1TBskPjfkeTOhqczDMxTw==", + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.9", + "call-bound": "^1.0.4", + "define-properties": "^1.2.1", + "es-object-atoms": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/string.prototype.trimstart": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/string.prototype.trimstart/-/string.prototype.trimstart-1.0.8.tgz", + "integrity": "sha512-UXSH262CSZY1tfu3G3Secr6uGLCFVPMhIqHjlgCUtCCcgihYc/xKs9djMTMUOb2j1mVSeU8EU6NWc/iQKU6Gfg==", + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.7", + "define-properties": "^1.2.1", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/strip-bom": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", + "integrity": "sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==", + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "license": "MIT", + "dependencies": { + "has-flag": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/supports-preserve-symlinks-flag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", + "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/tar": { + "version": "7.5.22", + "resolved": "https://registry.npmjs.org/tar/-/tar-7.5.22.tgz", + "integrity": "sha512-MFO/QzvtAOmJbkhOaCTvbGcFN9L9b+JunIsDwaKljSOdcLMea3NJ1k9Usz/rjdfSXTq4dfzfeS7W4p4YOAAHeA==", + "license": "BlueOak-1.0.0", + "dependencies": { + "@isaacs/fs-minipass": "^4.0.0", + "chownr": "^3.0.0", + "minipass": "^7.1.2", + "minizlib": "^3.1.0", + "yallist": "^5.0.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", + "license": "MIT" + }, + "node_modules/tslib": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", + "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", + "license": "0BSD", + "optional": true + }, + "node_modules/typed-array-buffer": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/typed-array-buffer/-/typed-array-buffer-1.0.3.tgz", + "integrity": "sha512-nAYYwfY3qnzX30IkA6AQZjVbtK6duGontcQm1WSG1MD94YLqK0515GNApXkoxKOWMusVssAHWLh9SeaoefYFGw==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3", + "es-errors": "^1.3.0", + "is-typed-array": "^1.1.14" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/typed-array-byte-length": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/typed-array-byte-length/-/typed-array-byte-length-1.0.3.tgz", + "integrity": "sha512-BaXgOuIxz8n8pIq3e7Atg/7s+DpiYrxn4vdot3w9KbnBhcRQq6o3xemQdIfynqSeXeDrF32x+WvfzmOjPiY9lg==", + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.8", + "for-each": "^0.3.3", + "gopd": "^1.2.0", + "has-proto": "^1.2.0", + "is-typed-array": "^1.1.14" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/typed-array-byte-offset": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/typed-array-byte-offset/-/typed-array-byte-offset-1.0.5.tgz", + "integrity": "sha512-0FHJvLPqZ7KJzp17O13jfsAjsqazgrxBu2zEK95PmUz8lv2+GjRuxUInCr2Rk9Dms3ihN21zJ929ZO43yJ95QQ==", + "license": "MIT", + "dependencies": { + "available-typed-arrays": "^1.0.7", + "call-bind": "^1.0.9", + "for-each": "^0.3.5", + "gopd": "^1.2.0", + "is-typed-array": "^1.1.15", + "reflect.getprototypeof": "^1.0.10" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/typed-array-length": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/typed-array-length/-/typed-array-length-1.0.8.tgz", + "integrity": "sha512-phPGCwqr2+Qo0fwniCE8e4pKnGu/yFb5nD5Y8bf0EEeiI5GklnACYA9GFy/DrAeRrKHXvHn+1SUsOWgJp6RO+g==", + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.9", + "for-each": "^0.3.5", + "gopd": "^1.2.0", + "is-typed-array": "^1.1.15", + "possible-typed-array-names": "^1.1.0", + "reflect.getprototypeof": "^1.0.10" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/unbox-primitive": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.1.0.tgz", + "integrity": "sha512-nWJ91DjeOkej/TA8pXQ3myruKpKEYgqvpw9lz4OPHj/NWFNluYrjbz9j01CJ8yKQd2g4jFoOkINCTW2I5LEEyw==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3", + "has-bigints": "^1.0.2", + "has-symbols": "^1.1.0", + "which-boxed-primitive": "^1.1.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/universal-user-agent": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-7.0.3.tgz", + "integrity": "sha512-TmnEAEAsBJVZM/AADELsK76llnwcf9vMKuPz8JflO1frO8Lchitr0fNaN9d+Ap0BjKtqWqd/J17qeDnXh8CL2A==", + "license": "ISC" + }, + "node_modules/validate-npm-package-license": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz", + "integrity": "sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==", + "license": "Apache-2.0", + "dependencies": { + "spdx-correct": "^3.0.0", + "spdx-expression-parse": "^3.0.0" + } + }, + "node_modules/webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==", + "license": "BSD-2-Clause" + }, + "node_modules/whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "license": "MIT", + "dependencies": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + }, + "node_modules/which": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", + "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", + "license": "ISC", + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "which": "bin/which" + } + }, + "node_modules/which-boxed-primitive": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/which-boxed-primitive/-/which-boxed-primitive-1.1.1.tgz", + "integrity": "sha512-TbX3mj8n0odCBFVlY8AxkqcHASw3L60jIuF8jFP78az3C2YhmGvqbHBpAjTRH2/xqYunrJ9g1jSyjCjpoWzIAA==", + "license": "MIT", + "dependencies": { + "is-bigint": "^1.1.0", + "is-boolean-object": "^1.2.1", + "is-number-object": "^1.1.1", + "is-string": "^1.1.1", + "is-symbol": "^1.1.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/which-builtin-type": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/which-builtin-type/-/which-builtin-type-1.2.1.tgz", + "integrity": "sha512-6iBczoX+kDQ7a3+YJBnh3T+KZRxM/iYNPXicqk66/Qfm1b93iu+yOImkg0zHbj5LNOcNv1TEADiZ0xa34B4q6Q==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "function.prototype.name": "^1.1.6", + "has-tostringtag": "^1.0.2", + "is-async-function": "^2.0.0", + "is-date-object": "^1.1.0", + "is-finalizationregistry": "^1.1.0", + "is-generator-function": "^1.0.10", + "is-regex": "^1.2.1", + "is-weakref": "^1.0.2", + "isarray": "^2.0.5", + "which-boxed-primitive": "^1.1.0", + "which-collection": "^1.0.2", + "which-typed-array": "^1.1.16" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/which-collection": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/which-collection/-/which-collection-1.0.2.tgz", + "integrity": "sha512-K4jVyjnBdgvc86Y6BkaLZEN933SwYOuBFkdmBu9ZfkcAbdVbpITnDmjvZ/aQjRXQrv5EPkTnD1s39GiiqbngCw==", + "license": "MIT", + "dependencies": { + "is-map": "^2.0.3", + "is-set": "^2.0.3", + "is-weakmap": "^2.0.2", + "is-weakset": "^2.0.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/which-typed-array": { + "version": "1.1.24", + "resolved": "https://registry.npmjs.org/which-typed-array/-/which-typed-array-1.1.24.tgz", + "integrity": "sha512-wk4Mf4pR5mRP7eYuuTBCIQ9d0ud2Fv2jRLQpfgnRjbOxAFHmjKFValgTpitVKzJJS8ajnYQV2Du1SZ8j6b/EUQ==", + "license": "MIT", + "dependencies": { + "available-typed-arrays": "^1.0.7", + "call-bind": "^1.0.9", + "call-bound": "^1.0.4", + "for-each": "^0.3.5", + "get-proto": "^1.0.1", + "gopd": "^1.2.0", + "has-tostringtag": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/yallist": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-5.0.0.tgz", + "integrity": "sha512-YgvUTfwqyc7UXVMrB+SImsVYSmTS8X/tSrtdNZMImM+n7+QTriRXyXim0mBrTXNeqzVF0KWGgHPeiyViFFrNDw==", + "license": "BlueOak-1.0.0", + "engines": { + "node": ">=18" + } + } + } +} diff --git a/backend/tools/maplibre-static-prototype/package.json b/backend/tools/maplibre-static-prototype/package.json new file mode 100644 index 00000000..99d9b688 --- /dev/null +++ b/backend/tools/maplibre-static-prototype/package.json @@ -0,0 +1,14 @@ +{ + "name": "ogm-maplibre-static-prototype", + "version": "0.1.0", + "private": true, + "type": "module", + "scripts": { + "test": "node --test", + "demo": "node render.mjs campus.json output/campus.png && node render.mjs resource.json output/resource.png" + }, + "dependencies": { + "@maplibre/maplibre-gl-native": "6.4.1", + "sharp": "0.35.5" + } +} diff --git a/backend/tools/maplibre-static-prototype/render.mjs b/backend/tools/maplibre-static-prototype/render.mjs new file mode 100644 index 00000000..31e0a6f4 --- /dev/null +++ b/backend/tools/maplibre-static-prototype/render.mjs @@ -0,0 +1,198 @@ +import mbgl from "@maplibre/maplibre-gl-native"; +import sharp from "sharp"; +import { readFile, writeFile } from "node:fs/promises"; +import { createHash } from "node:crypto"; +import { pathToFileURL } from "node:url"; + +export function fitBounds( + [west, south, east, north], + width, + height, + padding = 48, +) { + if ( + ![west, south, east, north].every(Number.isFinite) || + west >= east || + south >= north || + south < -85.05112878 || + north > 85.05112878 + ) + throw new Error("Invalid or crossing bounds: normalize before rendering"); + const y = (lat) => + (1 - Math.log(Math.tan(Math.PI / 4 + (lat * Math.PI) / 360)) / Math.PI) / 2; + const middleY = (y(south) + y(north)) / 2; + return { + center: [ + (west + east) / 2, + (Math.atan(Math.sinh(Math.PI * (1 - 2 * middleY))) * 180) / Math.PI, + ], + zoom: Math.min( + 20, + Math.log2((width - 2 * padding) / ((512 * (east - west)) / 360)), + Math.log2((height - 2 * padding) / (512 * (y(south) - y(north)))), + ), + }; +} + +export async function render(spec, output) { + const started = Date.now(); + const errors = []; + let requests = 0, + bytes = 0, + active = 0; + const queue = []; + const controller = new AbortController(); + const timer = setTimeout( + () => controller.abort(new Error("Render exceeded 60 seconds")), + 60000, + ); + const download = async (url) => { + const response = await fetch(url, { + headers: { "User-Agent": "OpenGeoMetadata-API-StaticMaps/1.0 (https://opengeometadata.org/)" }, + signal: controller.signal, + }); + if (!response.ok) throw new Error(`HTTP ${response.status}: ${url}`); + const data = Buffer.from(await response.arrayBuffer()); + requests++; + bytes += data.length; + if (requests > 3000 || bytes > 50 * 1024 * 1024) + throw new Error("Prototype download budget exceeded"); + return data; + }; + const pump = () => { + while (active < 4 && queue.length) { + const { req, callback } = queue.shift(); + active++; + download(req.url) + .then( + (data) => callback(null, { data }), + (error) => { + errors.push(error.message); + callback(error); + }, + ) + .finally(() => { + active--; + pump(); + }); + } + }; + let map; + const onMessage = (message) => { + if (message.severity === "ERROR") errors.push(message.text); + }; + mbgl.on("message", onMessage); + try { + const style = JSON.parse(await download(spec.style)); + if (spec.geometry) { + style.sources["ogm-geometry"] = { + type: "geojson", + data: { type: "Feature", properties: {}, geometry: spec.geometry }, + }; + style.layers.push( + { + id: "ogm-fill", + type: "fill", + source: "ogm-geometry", + paint: { "fill-color": "#2563eb", "fill-opacity": 0.06 }, + }, + { + id: "ogm-line", + type: "line", + source: "ogm-geometry", + paint: { + "line-color": "#2563eb", + "line-width": 3, + "line-opacity": 0.85, + }, + }, + ); + } + if (spec.geometry) + style.layers.push({ + id: "ogm-point", + type: "circle", + source: "ogm-geometry", + filter: ["==", "$type", "Point"], + paint: { + "circle-radius": 5, + "circle-color": "#2563eb", + "circle-stroke-color": "#ffffff", + "circle-stroke-width": 2, + }, + }); + map = new mbgl.Map({ + ratio: 1, + request(req, callback) { + queue.push({ req, callback }); + pump(); + }, + }); + map.load(style); + const camera = spec.bounds + ? fitBounds(spec.bounds, spec.width, spec.height) + : { center: spec.center, zoom: spec.leafletZoom - 1 }; + const pixels = await new Promise((resolve, reject) => + map.render( + { ...camera, width: spec.width, height: spec.height }, + (error, data) => (error ? reject(error) : resolve(data)), + ), + ); + if (errors.length) throw new Error(errors.join("\n")); + // Native rendering has no DOM attribution control; burn credits into the asset. + const compact = spec.width < 500; + const footer = Buffer.from( + `${compact + ? `OpenFreeMap · © OpenMapTiles© OpenStreetMap contributors` + : `OpenFreeMap · © OpenMapTiles · © OpenStreetMap contributors`}`, + ); + const png = await sharp(pixels, { + raw: { width: spec.width, height: spec.height, channels: 4 }, + }) + .composite([{ input: footer, gravity: "south" }]) + .png() + .toBuffer(); + await writeFile(output, png); + const manifest = { + renderer: "maplibre-native-6.4.1-prototype-v1", + spec, + camera, + requests, + downloadedBytes: bytes, + durationMs: Date.now() - started, + sha256: createHash("sha256").update(png).digest("hex"), + sourceSignature: createHash("sha256") + .update( + JSON.stringify({ + renderer: "maplibre-native-6.4.1-prototype-v1", + spec, + style, + }), + ) + .digest("hex"), + }; + await writeFile(`${output}.json`, JSON.stringify(manifest, null, 2)); + return manifest; + } finally { + clearTimeout(timer); + controller.abort(); + map?.release(); + mbgl.off("message", onMessage); + } +} + +if ( + process.argv[1] && + import.meta.url === pathToFileURL(process.argv[1]).href +) { + const [input, output] = process.argv.slice(2); + if (!input || !output) + throw new Error("Usage: node render.mjs spec.json output.png"); + console.log( + JSON.stringify( + await render(JSON.parse(await readFile(input, "utf8")), output), + null, + 2, + ), + ); +} diff --git a/backend/tools/maplibre-static-prototype/render.test.mjs b/backend/tools/maplibre-static-prototype/render.test.mjs new file mode 100644 index 00000000..319fd8af --- /dev/null +++ b/backend/tools/maplibre-static-prototype/render.test.mjs @@ -0,0 +1,13 @@ +import { test } from 'node:test'; +import assert from 'node:assert/strict'; +import { fitBounds } from './render.mjs'; +test('Mercator bounds fit respects padding and centers projected latitude', () => { + const result = fitBounds([-10, -10, 10, 10], 800, 600); + assert.ok(Math.abs(result.center[0]) < 1e-10); + assert.ok(Math.abs(result.center[1]) < 1e-10); + assert.ok(result.zoom > 4 && result.zoom < 5); +}); +test('invalid and dateline-crossing bounds fail explicitly', () => { + assert.throws(() => fitBounds([170, -10, -170, 10], 800, 600)); + assert.throws(() => fitBounds([-10, -90, 10, 90], 800, 600)); +}); diff --git a/backend/tools/maplibre-static-prototype/resource.json b/backend/tools/maplibre-static-prototype/resource.json new file mode 100644 index 00000000..ebcb8428 --- /dev/null +++ b/backend/tools/maplibre-static-prototype/resource.json @@ -0,0 +1,42 @@ +{ + "style": "https://tiles.openfreemap.org/styles/positron", + "id": "0efeae5d-6e6c-513c-ab45-01c5fc0cb16c", + "title": "Madison Structure", + "sourceUrl": "https://ogm.geo4lib.app/api/v1/resources/0efeae5d-6e6c-513c-ab45-01c5fc0cb16c", + "sourceGeometry": "ENVELOPE(-109.9876, -101.1135, 52.1614, 48.8912)", + "width": 800, + "height": 600, + "bounds": [ + -109.9876, + 48.8912, + -101.1135, + 52.1614 + ], + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + -109.9876, + 48.8912 + ], + [ + -101.1135, + 48.8912 + ], + [ + -101.1135, + 52.1614 + ], + [ + -109.9876, + 52.1614 + ], + [ + -109.9876, + 48.8912 + ] + ] + ] + } +} \ No newline at end of file diff --git a/backend/tools/maplibre-static-prototype/server.mjs b/backend/tools/maplibre-static-prototype/server.mjs new file mode 100644 index 00000000..3fe32302 --- /dev/null +++ b/backend/tools/maplibre-static-prototype/server.mjs @@ -0,0 +1,122 @@ +// Private service. Do not expose this port publicly. Celery owns scheduling/retries. +import http from "node:http"; +import { spawn } from "node:child_process"; +import { mkdtemp, writeFile, readFile, rm } from "node:fs/promises"; +import { tmpdir } from "node:os"; +import { join } from "node:path"; +const style = + process.env.STATIC_MAP_STYLE_URL || + "https://tiles.openfreemap.org/styles/positron"; +if (new URL(style).hostname !== "tiles.openfreemap.org") + throw new Error( + "This renderer currently supports OpenFreeMap styles/attribution only", + ); +let busy = false; +http + .createServer(async (req, res) => { + if (req.method === "GET" && req.url === "/health") { + res.end("ok"); + return; + } + if (req.method !== "POST" || req.url !== "/render") { + res.writeHead(404).end(); + return; + } + if (busy) { + res.writeHead(503, { "Retry-After": "3" }).end("Renderer busy"); + return; + } + busy = true; + let dir; + try { + const chunks = []; + let size = 0; + for await (const chunk of req) { + size += chunk.length; + if (size > 2 * 1024 * 1024) throw new Error("Request too large"); + chunks.push(chunk); + } + const input = JSON.parse(Buffer.concat(chunks)); + if ( + ![input.width, input.height].every( + (n) => Number.isInteger(n) && n >= 64 && n <= 1600, + ) + ) + throw new Error("Invalid dimensions"); + if ( + !input.bounds && + (!Array.isArray(input.center) || + input.center.length !== 2 || + !input.center.every(Number.isFinite) || + Math.abs(input.center[0]) > 180 || + Math.abs(input.center[1]) > 85.05112878 || + !Number.isFinite(input.leafletZoom) || + input.leafletZoom < 1 || + input.leafletZoom > 20) + ) + throw new Error("Invalid camera"); + if ( + input.geometry && + ![ + "Polygon", + "MultiPolygon", + "LineString", + "MultiLineString", + "Point", + "MultiPoint", + "GeometryCollection", + ].includes(input.geometry.type) + ) + throw new Error("Invalid geometry"); + // Only accept data/camera; clients cannot choose remote style/source URLs. + const spec = { + style, + width: input.width, + height: input.height, + bounds: input.bounds, + center: input.center, + leafletZoom: input.leafletZoom, + geometry: input.geometry, + }; + dir = await mkdtemp(join(tmpdir(), "ogm-render-")); + await writeFile(join(dir, "spec.json"), JSON.stringify(spec)); + await new Promise((resolve, reject) => { + const child = spawn( + process.execPath, + ["render.mjs", join(dir, "spec.json"), join(dir, "map.png")], + { stdio: ["ignore", "ignore", "pipe"] }, + ); + let error = ""; + child.stderr.on("data", (b) => { + error = (error + b).slice(-4000); + }); + const timer = setTimeout(() => child.kill("SIGKILL"), 65000); + child.on("error", (e) => { + clearTimeout(timer); + reject(e); + }); + child.on("close", (code) => { + clearTimeout(timer); + code === 0 + ? resolve() + : reject(new Error(error || `Renderer exit ${code}`)); + }); + }); + const png = await readFile(join(dir, "map.png")); + res + .writeHead(200, { + "Content-Type": "image/png", + "Cache-Control": "no-store", + }) + .end(png); + } catch (error) { + console.error(error.message); + res + .writeHead(502, { "Cache-Control": "no-store" }) + .end("Map rendering failed"); + } finally { + if (dir) await rm(dir, { recursive: true, force: true }); + busy = false; + } + }) + .listen(8080, "0.0.0.0"); diff --git a/backend/uv.lock b/backend/uv.lock index a6c23ea5..40440e96 100644 --- a/backend/uv.lock +++ b/backend/uv.lock @@ -241,15 +241,6 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/da/35/f2287558c17e29fafc8ef3daf819bb9834061cfa43bff8014f7df7f63bdc/anyio-4.14.2-py3-none-any.whl", hash = "sha256:9f505dda5ac9f0c8309b5e8bd445a8c2bf7246f3ce950121e45ea15bc41d1494", size = 125813, upload-time = "2026-07-12T20:29:05.763Z" }, ] -[[package]] -name = "appdirs" -version = "1.4.4" -source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/d7/d8/05696357e0311f5b5c316d7b95f46c669dd9c15aaeecbb48c7d0aeb88c40/appdirs-1.4.4.tar.gz", hash = "sha256:7d5d0167b2b1ba821647616af46a749d1c653740dd0d2415100fe26e27afdf41", size = 13470, upload-time = "2020-05-11T07:59:51.037Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/3b/00/2344469e2084fb287c2e0b57b72910309874c3245463acd6cf5e3db69324/appdirs-1.4.4-py2.py3-none-any.whl", hash = "sha256:a841dacd6b99318a741b166adb07e19ee71a274450e68237b4650ca1055ab128", size = 9566, upload-time = "2020-05-11T07:59:49.499Z" }, -] - [[package]] name = "appsignal" version = "1.9.4" @@ -785,7 +776,6 @@ dependencies = [ { name = "platformdirs" }, { name = "pmtiles" }, { name = "psycopg2-binary" }, - { name = "py-staticmaps", extra = ["cairo"] }, { name = "pycairo" }, { name = "pydantic" }, { name = "pydantic-core" }, @@ -864,7 +854,6 @@ requires-dist = [ { name = "platformdirs", specifier = "==4.3.6" }, { name = "pmtiles", specifier = ">=3.0.0" }, { name = "psycopg2-binary", specifier = "==2.9.10" }, - { name = "py-staticmaps", extras = ["cairo"], specifier = ">=0.4.0" }, { name = "pycairo", specifier = ">=1.29.0" }, { name = "pydantic", specifier = "==2.12.5" }, { name = "pydantic-core", specifier = "==2.41.5" }, @@ -1140,24 +1129,6 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/ee/45/b82e3c16be2182bff01179db177fe144d58b5dc787a7d4492c6ed8b9317f/frozenlist-1.7.0-py3-none-any.whl", hash = "sha256:9a5af342e34f7e97caf8c995864c7a396418ae2859cc6fdf1b1073020d516a7e", size = 13106, upload-time = "2025-06-09T23:02:34.204Z" }, ] -[[package]] -name = "future" -version = "1.0.0" -source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/a7/b2/4140c69c6a66432916b26158687e821ba631a4c9273c474343badf84d3ba/future-1.0.0.tar.gz", hash = "sha256:bd2968309307861edae1458a4f8a4f3598c03be43b97521076aebf5d94c07b05", size = 1228490, upload-time = "2024-02-21T11:52:38.461Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/da/71/ae30dadffc90b9006d77af76b393cb9dfbfc9629f339fc1574a1c52e6806/future-1.0.0-py3-none-any.whl", hash = "sha256:929292d34f5872e70396626ef385ec22355a1fae8ad29e1a734c3e43f9fbc216", size = 491326, upload-time = "2024-02-21T11:52:35.956Z" }, -] - -[[package]] -name = "geographiclib" -version = "2.1" -source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/df/78/4892343230a9d29faa1364564e525307a37e54ad776ea62c12129dbba704/geographiclib-2.1.tar.gz", hash = "sha256:6a6545e6262d0ed3522e13c515713718797e37ed8c672c31ad7b249f372ef108", size = 37004, upload-time = "2025-08-21T21:34:26Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/31/b3/802576f2ea5dcb48501bb162e4c7b7b3ca5654a42b2c968ef98a797a4c79/geographiclib-2.1-py3-none-any.whl", hash = "sha256:e2a873b9b9e7fc38721ad73d5f4e6c9ed140d428a339970f505c07056997d40b", size = 40740, upload-time = "2025-08-21T21:34:24.955Z" }, -] - [[package]] name = "geopandas" version = "1.1.2" @@ -2475,26 +2446,6 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/08/50/d13ea0a054189ae1bc21af1d85b6f8bb9bbc5572991055d70ad9006fe2d6/psycopg2_binary-2.9.10-cp313-cp313-win_amd64.whl", hash = "sha256:27422aa5f11fbcd9b18da48373eb67081243662f9b46e6fd07c3eb46e4535142", size = 2569224, upload-time = "2025-01-04T20:09:19.234Z" }, ] -[[package]] -name = "py-staticmaps" -version = "0.4.0" -source = { registry = "https://pypi.org/simple" } -dependencies = [ - { name = "appdirs" }, - { name = "geographiclib" }, - { name = "pillow" }, - { name = "python-slugify" }, - { name = "requests" }, - { name = "s2sphere" }, - { name = "svgwrite" }, -] -sdist = { url = "https://files.pythonhosted.org/packages/f9/22/efa565521b37c3cf8b64c6a2c7a3631efae15724231e23c9fd37623df7ef/py-staticmaps-0.4.0.tar.gz", hash = "sha256:5aba5ad59f30a63f860e76ed99407a6efb24eaad5c8997aa8617363989f17389", size = 21972, upload-time = "2021-03-27T09:41:24.304Z" } - -[package.optional-dependencies] -cairo = [ - { name = "pycairo" }, -] - [[package]] name = "pycairo" version = "1.29.0" @@ -2915,18 +2866,6 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/5e/1e/7f7f299527a5a8ad90acd5f2f78dfa6c8495c6301a3205106ea68a84de96/python_multipart-0.0.31-py3-none-any.whl", hash = "sha256:8408153d68a9773291fc1da39a8b85a50044bddbabd2dd72e9229776b7b15e28", size = 29996, upload-time = "2026-06-04T08:27:47.804Z" }, ] -[[package]] -name = "python-slugify" -version = "8.0.4" -source = { registry = "https://pypi.org/simple" } -dependencies = [ - { name = "text-unidecode" }, -] -sdist = { url = "https://files.pythonhosted.org/packages/87/c7/5e1547c44e31da50a460df93af11a535ace568ef89d7a811069ead340c4a/python-slugify-8.0.4.tar.gz", hash = "sha256:59202371d1d05b54a9e7720c5e038f928f45daaffe41dd10822f3907b937c856", size = 10921, upload-time = "2024-02-08T18:32:45.488Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/a4/62/02da182e544a51a5c3ccf4b03ab79df279f9c60c5e82d5e8bec7ca26ac11/python_slugify-8.0.4-py2.py3-none-any.whl", hash = "sha256:276540b79961052b66b7d116620b36518847f52d5fd9e3a70164fc8c50faa6b8", size = 10051, upload-time = "2024-02-08T18:32:43.911Z" }, -] - [[package]] name = "pytz" version = "2025.2" @@ -3307,18 +3246,6 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/d7/6a/65fecd51a9ca19e1477c3879a7fda24f8904174d1275b419422ac00f6eee/ruff-0.11.6-py3-none-win_arm64.whl", hash = "sha256:3567ba0d07fb170b1b48d944715e3294b77f5b7679e8ba258199a250383ccb79", size = 10682766, upload-time = "2025-04-17T13:35:52.014Z" }, ] -[[package]] -name = "s2sphere" -version = "0.2.5" -source = { registry = "https://pypi.org/simple" } -dependencies = [ - { name = "future" }, -] -sdist = { url = "https://files.pythonhosted.org/packages/01/8e/08260a5f03c642d3f6f040756425dc3f466842c4d5e978f6c2be960dde2f/s2sphere-0.2.5.tar.gz", hash = "sha256:c2478c1ff7c601a59a7151a57b605435897514578fa6bdb8730721c182adbbaf", size = 51789, upload-time = "2017-11-16T17:47:46.202Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/49/fc/be2251ac7ee75e725027b107ab14d161d829aaac22362f75eaabc859bfba/s2sphere-0.2.5-py2.py3-none-any.whl", hash = "sha256:d2340c9cf458ddc9a89afd1d8048a4195ce6fa6b0095ab900d4be5271e537401", size = 23540, upload-time = "2017-11-16T17:47:48.139Z" }, -] - [[package]] name = "s3transfer" version = "0.19.2" @@ -3454,24 +3381,6 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/ec/bb/2799cc2ede3ed41131f8975621e7213dfc7ef4acbbaadfa440f32500c370/starlette-1.3.1-py3-none-any.whl", hash = "sha256:c7372aae11c3c3f26a42df7bd626cec2f47d03483d261d369516a615a53714c6", size = 73632, upload-time = "2026-06-12T09:23:10.017Z" }, ] -[[package]] -name = "svgwrite" -version = "1.4.3" -source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/16/c1/263d4e93b543390d86d8eb4fc23d9ce8a8d6efd146f9427364109004fa9b/svgwrite-1.4.3.zip", hash = "sha256:a8fbdfd4443302a6619a7f76bc937fc683daf2628d9b737c891ec08b8ce524c3", size = 189516, upload-time = "2022-07-14T14:05:26.107Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/84/15/640e399579024a6875918839454025bb1d5f850bb70d96a11eabb644d11c/svgwrite-1.4.3-py3-none-any.whl", hash = "sha256:bb6b2b5450f1edbfa597d924f9ac2dd099e625562e492021d7dd614f65f8a22d", size = 67122, upload-time = "2022-07-14T14:05:24.459Z" }, -] - -[[package]] -name = "text-unidecode" -version = "1.3" -source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/ab/e2/e9a00f0ccb71718418230718b3d900e71a5d16e701a3dae079a21e9cd8f8/text-unidecode-1.3.tar.gz", hash = "sha256:bad6603bb14d279193107714b288be206cac565dfa49aa5b105294dd5c4aab93", size = 76885, upload-time = "2019-08-30T21:36:45.405Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/a6/a5/c0b6468d3824fe3fde30dbb5e1f687b291608f9473681bbf7dabbf5a87d7/text_unidecode-1.3-py2.py3-none-any.whl", hash = "sha256:1311f10e8b895935241623731c2ba64f4c455287888b18189350b67134a822e8", size = 78154, upload-time = "2019-08-30T21:37:03.543Z" }, -] - [[package]] name = "tomli" version = "2.2.1" diff --git a/config/nginx-kamal-singlehost.conf b/config/nginx-kamal-singlehost.conf index e98023ef..9e1dbb3f 100644 --- a/config/nginx-kamal-singlehost.conf +++ b/config/nginx-kamal-singlehost.conf @@ -12,6 +12,12 @@ server { server_name _; root /app/frontend/build/client; + # Module workers must have a JavaScript MIME type (Debian nginx omits mjs). + include /etc/nginx/mime.types; + types { + application/javascript mjs; + } + sendfile on; tcp_nopush on; etag on; diff --git a/docker-compose.native-maps.yml b/docker-compose.native-maps.yml new file mode 100644 index 00000000..390aca77 --- /dev/null +++ b/docker-compose.native-maps.yml @@ -0,0 +1,29 @@ +# Opt in with: docker compose -f docker-compose.yml -f docker-compose.native-maps.yml up -d --build +# Only the private renderer uses Ubuntu. API/Celery keep their existing image. +services: + api: + environment: + STATIC_MAP_RENDERER_URL: http://map_renderer:8080 + STATIC_MAP_RENDER_REVISION: ${STATIC_MAP_RENDER_REVISION:-openfreemap-positron-native-v1} + celery_worker: + environment: + STATIC_MAP_RENDERER_URL: http://map_renderer:8080 + STATIC_MAP_RENDER_REVISION: ${STATIC_MAP_RENDER_REVISION:-openfreemap-positron-native-v1} + map_renderer: + build: + context: . + dockerfile: backend/tools/maplibre-static-prototype/Dockerfile.worker + command: + [ + "sh", + "-c", + "rm -f /tmp/.X99-lock /tmp/.X11-unix/X99; Xvfb :99 -screen 0 1280x1024x24 -ac -nolisten tcp & sleep 2; exec node server.mjs", + ] + environment: + STATIC_MAP_STYLE_URL: ${STATIC_MAP_STYLE_URL:-https://tiles.openfreemap.org/styles/positron} + init: true + restart: unless-stopped + mem_limit: 1g + cpus: 2 + networks: + - elastic diff --git a/docker-compose.yml b/docker-compose.yml index d346c7f8..91c7b0ee 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,23 @@ services: + map_renderer: + build: + context: . + dockerfile: backend/tools/maplibre-static-prototype/Dockerfile.worker + command: + [ + "sh", + "-c", + "rm -f /tmp/.X99-lock /tmp/.X11-unix/X99; Xvfb :99 -screen 0 1280x1024x24 -ac -nolisten tcp & sleep 2; exec node server.mjs", + ] + environment: + STATIC_MAP_STYLE_URL: ${STATIC_MAP_STYLE_URL:-https://tiles.openfreemap.org/styles/positron} + init: true + restart: unless-stopped + mem_limit: 1g + cpus: 2 + networks: + - elastic + api: build: context: . @@ -13,6 +32,7 @@ services: - ELASTICSEARCH_INDEX=btaa_geospatial_api - LOG_PATH=/app/logs - APPLICATION_URL=http://localhost:8000 + - BTAA_GEOSPATIAL_API_KEY=${BTAA_GEOSPATIAL_API_KEY:-} - ANALYTICS_PASSWORD=${ANALYTICS_PASSWORD:-} - ANALYTICS_BASE_URL=${ANALYTICS_BASE_URL:-http://localhost:${FRONTEND_PORT:-5173}} - APP_ENV=development @@ -48,6 +68,9 @@ services: - GAZETTEER_CACHE_TTL=3600 - ADMIN_USERNAME=admin - ADMIN_PASSWORD=changeme + - STATIC_MAP_RENDERER_URL=${STATIC_MAP_RENDERER_URL:-http://map_renderer:8080} + - STATIC_MAP_RENDER_REVISION=${STATIC_MAP_RENDER_REVISION:-openfreemap-positron-native-v1} + - STATIC_MAP_STYLE_URL=${STATIC_MAP_STYLE_URL:-https://tiles.openfreemap.org/styles/positron} - IS_DOCKER=true - PYTHONPATH=/app/backend ports: @@ -102,6 +125,7 @@ services: - ./frontend/private-analytics-reports:/app/private-analytics-reports:ro - ./frontend/public:/app/public - ./frontend/scripts:/app/scripts + - ./frontend/vendor:/app/vendor - ./frontend/server:/app/server - ./frontend/index.html:/app/index.html - ./frontend/package.json:/app/package.json @@ -226,6 +250,9 @@ services: - PYTHONPATH=/app/backend - LOG_PATH=/app/logs - LOG_LEVEL=DEBUG + - STATIC_MAP_RENDERER_URL=${STATIC_MAP_RENDERER_URL:-http://map_renderer:8080} + - STATIC_MAP_RENDER_REVISION=${STATIC_MAP_RENDER_REVISION:-openfreemap-positron-native-v1} + - STATIC_MAP_STYLE_URL=${STATIC_MAP_STYLE_URL:-https://tiles.openfreemap.org/styles/positron} - IS_DOCKER=true - OPENAI_API_KEY=${OPENAI_API_KEY} - OPENAI_MODEL=${OPENAI_MODEL:-gpt-3.5-turbo} @@ -262,6 +289,9 @@ services: - PYTHONPATH=/app/backend - LOG_PATH=/app/logs - LOG_LEVEL=DEBUG + - STATIC_MAP_RENDERER_URL=${STATIC_MAP_RENDERER_URL:-http://map_renderer:8080} + - STATIC_MAP_RENDER_REVISION=${STATIC_MAP_RENDER_REVISION:-openfreemap-positron-native-v1} + - STATIC_MAP_STYLE_URL=${STATIC_MAP_STYLE_URL:-https://tiles.openfreemap.org/styles/positron} - IS_DOCKER=true volumes: - ./logs:/app/logs diff --git a/docs/README.md b/docs/README.md index 3eca2a49..e925a251 100644 --- a/docs/README.md +++ b/docs/README.md @@ -63,7 +63,7 @@ Core runtime technologies: | Layer | Current implementation | | --- | --- | | API | FastAPI app mounted at `/api/v1`, with Swagger at `/api/docs` and OpenAPI JSON at `/api/openapi.json`. | -| Public web app | React, React Router, TypeScript, Vite, MUI, Leaflet, GeoBlacklight frontend components, and H3 map visualization. | +| Public web app | React, React Router, TypeScript, Vite, MUI, Leaflet, `ogm-viewer` resource previews, GeoBlacklight Leaflet layers for homepage previews, and H3 map visualization. | | Search | Elasticsearch with versioned index builds and alias swaps through `scripts/reindex_atomic.py`. | | Database | ParadeDB/PostgreSQL, SQLAlchemy table metadata in `backend/db/models.py`, script-based migrations in `backend/db/migrations/`. | | Cache | Redis plus durable database caches for generated API responses, resource representations, and visual assets. | diff --git a/docs/backend/caching.md b/docs/backend/caching.md index a2dbedeb..7e9ea8f1 100644 --- a/docs/backend/caching.md +++ b/docs/backend/caching.md @@ -248,8 +248,6 @@ are retried within the same bound. The frontend proxy preserves these response h - **Priming for hot paths**: - `make prime-thumbnail-cache`, `make prime-static-map-cache`, and `make prime-visual-caches` generate assets ahead of user traffic. - - Static-map tile-provider or style changes must bump the generated-map variants so old durable assets are not reused. The OpenStreetMap transition uses `static_map_v10` and `static_basemap_v8`; rerun the static-map primer after upgrading an environment. - - The public `tile.openstreetmap.org` service permits normal interactive viewing but [prohibits bulk prefetching](https://operations.osmfoundation.org/policies/tiles/). Do not run a full-corpus static-map primer against that public endpoint; release-wide warming requires an OSM-derived or self-hosted tile source whose terms permit automated static generation. Keep deployed provider and priming details in the restricted operations docs. - Run `make resource-aux-init` before first local priming so `generated_visual_assets` and `generated_visual_asset_links` exist. - After a Redis reset, priming first tries to rehydrate from durable visual storage before regenerating remote thumbnails or static maps. - Full static-map priming defaults to durable assets/links plus small Redis aliases only. Use `PRIME_STATIC_MAP_HYDRATE_ASSETS=1` only for small hotsets when Redis DB 1 should hold the PNG bodies. Full-corpus static-map body hydration is refused unless `PRIME_ALLOW_FULL_HYDRATION=1` is also set. @@ -426,3 +424,24 @@ the `map` cache tag if any older responses have already been cached. - **Redis latency**: - tune `REDIS_TIMEOUT_SECONDS` - keep Redis close to the API network-wise + +### MapLibre Native static maps + +Generated geometry and basemap variants are `native_geometry_v1` and +`native_basemap_v1`. Their signatures include geometry/camera, dimensions, style +URL, Native version, and `STATIC_MAP_RENDER_REVISION`. Bump the revision when +style content, source datasets, glyphs, or rendering settings change. Existing +immutable PNGs remain available; current aliases resolve only the new variants. +Database storage and public asset routes retain their existing contracts. + +Local Compose includes a private Ubuntu software renderer. Run +`make native-map-start` to build/start it and `make native-map-test` for its camera +tests. Python requests the private `/render` endpoint; clients cannot supply +style or remote-source URLs. Requests have dimension, byte, download, concurrency, +and time limits. Busy responses receive bounded retries. PNG signature, +dimensions, and integrity are validated before durable publication. + +No raster-provider fallback is used. Renderer failures leave successful assets +intact. Campus maps retain content hashes and use cache aliases without creating +fake resource rows. Local regeneration uses the existing primer workflows. +Deployment configuration belongs in restricted operations documentation. diff --git a/docs/backend/iiif_downloads.md b/docs/backend/iiif_downloads.md new file mode 100644 index 00000000..8df90627 --- /dev/null +++ b/docs/backend/iiif_downloads.md @@ -0,0 +1,96 @@ +# IIIF downloads + +The resource page's Downloads component supports IIIF Image API references and +Presentation 2 or 3 manifests. It loads `/api/v1/resources/{id}/downloads` +separately, so remote IIIF requests do not delay the resource page or search. +The initial resource/search `meta.ui.downloads` remains a local, provisional +list; clients that need manifest-derived downloads should use the downloads +endpoint. + +For a multi-part manifest, Downloads follows the image currently open in OGM +Viewer. Moving forward/backward or switching preview tabs updates the links. +The **Page or sheet** picker also moves OGM Viewer to the selected image. Its +options come from the viewer sequence, using manifest labels where available. +Links are cleared while an image opens or when a map preview is selected. +Matching uses the preview URL and image service URL, rather than page position: +one canvas can contain several images, and some canvases have no image. + +Images are downloaded individually; the API does not synthesize a ZIP, PDF, or +composite atlas image. Publisher-supplied whole-item renderings and ordinary +files remain available. Canvas renderings appear with their matching image. +The component retains its manual page selector for callers without viewer events. + +## Download extraction + +- Image API references may be service bases, `info.json` URLs, or image request + URLs. The downloads endpoint reads image information to determine the version + and advertised capabilities. Query strings and encoded identifiers survive + URL normalization. +- Presentation 2 traverses all sequences' canvases, matching OGM Viewer's ordering, `images`, and + `resource`. Presentation 3 uses canvases, annotation pages, painting + annotations, and image bodies. Canvas labels support strings, Presentation 2 + language values, and Presentation 3 language maps, with page-number fallbacks. +- Image services produce aspect-preserving JPEG sizes and a full-size (Image API + 1/2) or largest-available (Image API 3) link. Version 1 uses `native` quality; + later versions use `default`. Declared dimensions and maximum size limits + constrain generated sizes. Level 0 services get only advertised sizes plus + the full/largest option. +- Plain image bodies without a recognized image service use their supplied URL + and media type. Non-painting annotations and non-HTTP(S) download URLs are + ignored. Duplicate URLs within a canvas are removed; the same image used on + different canvases remains available for each page. + +IIIF entries have `source: "iiif"`. Entries belonging to a page also include +`canvas_id` and `canvas_label`. `iiif_resource_url` identifies the originating +manifest or standalone Image API reference; `image_source` identifies the image +service (or plain image body). `image_occurrences` records repeated uses of that +source in viewer order, distinguishing a scan reused on several canvases. Canvas rendering files have no `image_source`. +These fields are supplied in addition to `label`, `url`, `type`, and `format`. +The downloads endpoint preserves direct, generated GIS, and bridge-asset files. +If a remote provider cannot be read, those existing options remain available and +`iiif_error: true` lets the component offer a retry. + +## Fetching and limits + +Resolution reuses the image service's cached JSON fetch and five-second upstream +timeout, running blocking work outside the async event loop. It reads the +manifest once and resolves a separately supplied Image API reference too, so both +viewer tabs have options. It does not fetch `info.json` for every page in a large atlas. +Consequently, page-image options use the capabilities and dimensions embedded +in the manifest. Provider restrictions omitted from that metadata may still +cause a download to fail. + +Only embedded canvases and annotation pages are traversed. External-only canvas +or annotation-page references and IIIF Collections are not recursively fetched. +Images the viewer cannot open have no active-image downloads. Image links open the +publisher's file in a new tab; the publisher's response determines whether the +browser displays or saves it. + +## Local verification + +The fixtures `backend/tests/fixtures/iiif_peace_463.json` and +`backend/tests/fixtures/iiif_atlas_463.json` are reduced public CONTENTdm manifests +from the Peace map and Standard atlas of Norman County examples in +[issue #463](https://github.com/geobtaa/api/issues/463). The atlas fixture retains +pages 1, 2, and 67 to test ordering without including the entire manifest. + +Run the focused backend tests without database setup: + +```bash +BTAA_SKIP_TEST_DB=1 python -m pytest backend/tests/services/test_iiif_downloads.py backend/tests/services/test_download_service.py +``` + +From `frontend/`, run: + +```bash +npm test -- --run src/__tests__/components/resource/DownloadsTable.test.tsx src/__tests__/components/resource/ResourceViewer.test.tsx src/__tests__/components/ResourceView.test.tsx +``` + +Reference specifications: [Image API 2](https://iiif.io/api/image/2.1/), +[Image API 3](https://iiif.io/api/image/3.0/), +[Presentation 2](https://iiif.io/api/presentation/2.1/), and the +[Presentation 3 multi-page recipe](https://iiif.io/api/cookbook/recipe/0009-book-1/). + + +See [the OGM Viewer source fork](../frontend/ogm-viewer.md) +for the event contract, browser checks, and upgrade/removal instructions. diff --git a/docs/frontend/README.md b/docs/frontend/README.md index 9acc59b8..fafeb94f 100644 --- a/docs/frontend/README.md +++ b/docs/frontend/README.md @@ -24,6 +24,10 @@ Features: - [Homepage Map Visualization](homepage-map.md) - H3 hex map, featured carousel, preview layers, and Allmaps behavior. +- Resource-page item previews use the `ogm-viewer` web components with the + Aardvark record already returned by the resource API. Vite leaves the + components un-prebundled and resolves their runtime theme and icon assets in + development, then emits those assets during production builds. Configuration: @@ -39,8 +43,8 @@ The frontend stack currently uses: - TypeScript, Vite 7, and React Router dev tooling. - Vitest 4, Testing Library, `happy-dom`, axe, and pa11y for tests and accessibility checks. -- Material UI 7, Tailwind, Leaflet, GeoBlacklight frontend components, Allmaps, - H3, Recharts, and Lucide icons. +- Material UI 7, Tailwind, MapLibre, `ogm-viewer`, Allmaps MapLibre layers + for homepage previews, Allmaps, H3, Recharts, and Lucide icons. ## Unfiltered Search @@ -145,7 +149,7 @@ instead of invalidating dependency URLs while the page loads. PMTiles previews require Ctrl or Command plus scroll to zoom, leaving ordinary scrolling available for the page. Unmodified scrolling briefly displays a centered -Leaflet-style instruction over a dimmed map (Command on Mac, Ctrl elsewhere); zoom buttons, +MapLibre cooperative-gesture instruction (Command on Mac, Ctrl elsewhere); zoom buttons, dragging, and touch interactions remain available. Resource source links are native anchors, supporting URL previews, copy-link, @@ -159,3 +163,66 @@ include a number and any available layer name. WFS and OGC API Features links op at the end of the Links section, after Documentation when present. See the [distribution eligibility rules and example datasets](../backend/distribution_tables.md#open-in-geolibre). + +### OGM Viewer basemaps + +The resource viewer uses a pinned source build of the [BTAA OGM Viewer fork](ogm-viewer.md), based on upstream 1.7.0, with OpenFreeMap Positron as the default style. Version 1.x bundles its theme and icons; the application no longer +copies viewer assets or imports private hashed asset-loader modules. Vite retains +ES module worker output for COG decoding. The legacy standalone backend viewer separately pins upstream 1.6.0 and uses Positron. Application geographic maps use the +shared MapLibre primitives in `frontend/src/mapping`. The resource-page Allmaps +viewer remains the official embedded viewer; specialist IIIF viewers are retained. +They preserve the existing latitude/longitude and legacy 256-pixel zoom contracts +at the application boundary, converting once to MapLibre longitude/latitude and +512-pixel zoom. GeoJSON collections share a source and use feature state for hover. +Homepage protocol previews use OGM Viewer previewers and Allmaps MapLibre layers. + +The frontend Docker image and the combined application image use Node 22 and installs the committed lockfile with +`npm ci --legacy-peer-deps`, matching the MapLibre dependency runtime requirements. The lockfile pins the fork tarball and its integrity in both images. No OGM postinstall patch, compiled-source substitution, or custom worker alias is needed. + +Search map controls: + +- The Location filter, results, and resource Location maps start with compact attribution collapsed behind the native MapLibre information button. Users can open or close it with mouse or keyboard. The shared `collapsedAttribution` map option applies only the initial state; attribution remains available and later user choices are preserved. + +Resource pages hide OGM Viewer's internal menubar and repeated title, so the +canvas starts directly below the page-level viewer controls. + +The resource page omits OGM Viewer's metadata-only Location preview because the +sidebar already shows that map. Records without a supported content reference +skip the viewer and its controls entirely. Image, manifest, and actual map-layer +previews remain available; WMS/WMTS references require a layer identifier. + +For records with both IIIF references, the viewer opens the manifest's **Images** +tab before the **Single image** tab. Failed inactive image previews become +unavailable; **Single image** tabs are hidden from the first render while the manifest +loads and after it succeeds. They are revealed if its initial load fails. A lone +preview displays its canvas without a tab bar, including during initial loading. An initial preview failure switches to another IIIF image preview +only after it has loaded; later page failures keep the reader in the book. + +IIIF image downloads use the active image service already loaded by OGM Viewer. +The resource page does not make a separate manifest-derived download request, +so collections that the viewer can open do not show a second resolver's error. +Links respect the service's Image API version, advertised sizes and limits. +Paging and preview-tab changes update individual image downloads. The Downloads +page/sheet picker navigates the viewer too; publisher-provided downloads remain +available. The download heading only appears when image links are available. +The independent API endpoint remains available to other clients; see +[IIIF downloads](../backend/iiif_downloads.md) for its supported manifest shapes +and endpoint fields. + +### Standalone OGM Viewer + +“Open in new tab” opens `/ogm-viewer?resource=` with +the complete catalog record and a viewport-height OGM Viewer. Its native +menubar remains available in this standalone view. The resource-page viewer +continues to omit the repeated title. Both omit the Location preview. + +Existing `/mirador?manifest=` links permanently redirect +to `/ogm-viewer` with their query string preserved. Manifest-only links create +a minimal Aardvark record in the browser viewer; the server does not fetch the +user-supplied manifest URL. Missing or invalid inputs show an accessible message. + +### Resource viewer opening camera + +Embedded and standalone resource viewers share `utils/mapFraming.ts`. Valid record bounds narrower than 350 degrees retain their existing framing. Missing, invalid, or near-global record bounds can fall back to source-reported extents through OGM Viewer's resource adapters. GeoJSON and index maps use connected geometry and circular longitude intervals to preserve antimeridian coverage. Truly global geometry stays global; the algorithm does not select a preferred country or discard outlying features. + +Extent discovery is limited to four content sources and five seconds of initial waiting. If any source has unknown coverage, the viewer retains its normal fallback rather than fitting an incomplete union. Late results never move an already opened map. Only the in-memory viewer camera accessor changes: record JSON, coverage geometry, Location sidebar, search indexing, and downloadable metadata remain unchanged. diff --git a/docs/frontend/homepage-map.md b/docs/frontend/homepage-map.md index d3b06910..f6e84d1a 100644 --- a/docs/frontend/homepage-map.md +++ b/docs/frontend/homepage-map.md @@ -2,13 +2,13 @@ ## Overview -The homepage features an interactive Leaflet map that combines three main elements: +The homepage features an interactive MapLibre map that combines three main elements: 1. **H3 Hex Map** — Resource density visualization using Uber's H3 hexagonal grid 2. **Featured Resources Carousel** — Curated examples that showcase different resource types and previews 3. **Search Here** — Button to search within the current map extent (appears after user pan/zoom) -The map defaults to an OpenStreetMap basemap and is centered south of the continental US so North America appears beneath the search form. Chicago (a dense hex cluster) is positioned for visual prominence via an initial programmatic pan. Interactive basemap pickers also offer Esri World Imagery. +The map defaults to OpenFreeMap Positron and matches the production camera: latitude 44, longitude -80, offset 400 pixels east at legacy zoom 3. This resolves to an initial center of (44, -9.6875), keeping the US cluster left of center. The offset is applied to the initial camera rather than generating a startup pan. Interactive basemap pickers offer OpenFreeMap Positron, Bright, Positron, Dark, and Fiord (excluding 3D). The layers button expands in place into a continuous hover area, matching production. Loading, resizing, and basemap changes do not reveal the Search Here button or orange outline; the first user pan, zoom, or keyboard camera movement does. Returning Home clears the prompt. --- @@ -20,16 +20,18 @@ The hex map aggregates geospatial resource counts into H3 cells and renders them ### How It Works -- **Resolution mapping**: Leaflet zoom level maps to H3 resolution (2–8). Lower zoom = coarser hexes; higher zoom = finer hexes. +- **Resolution mapping**: Application zoom level (legacy 256-pixel camera units) maps to H3 resolution (2–8). Lower zoom = coarser hexes; higher zoom = finer hexes. - **API**: `MapUpdaterHex` uses `useMapH3`, which calls `fetchMapH3` with the viewport bbox and resolution. The backend `/api/v1/map/h3` endpoint returns hex indexes and counts. - **Cache versioning**: `fetchMapH3` sends a `_v` request parameter. Bump `MAP_H3_REQUEST_VERSION` when H3 query/filter semantics change so browser, SSR, and backend endpoint caches do not reuse older hex aggregates. - **Data flow**: On map move/zoom, the component sends the visible bounds to the API. Hexes are fetched, then rendered as GeoJSON polygons using `cellToBoundary` from `h3-js`. - **Dateline geometry**: Both hex map views use `h3CellGeometry` to split cells crossing ±180° into a single GeoJSON MultiPolygon, retaining one H3 identifier and count for hover and clicks. Homepage click bounds use a short wrapped interval (`west > east`); the API splits it into two envelopes instead of searching a nearly global band. +- **Refresh failures**: Zoom changes are coalesced and obsolete requests aborted. Keep the last successful viewport and its H3 resolution during loading or temporary errors; never reuse it across query/filter changes. Retry transient failures at most twice, honoring upstream retry guidance. Loading/error updates do not rebuild the existing map source. +- **Local authentication**: Compose passes the configured server-only API credential to both the API and SSR services. This keeps ordinary map navigation on the intended authenticated tier. A separately started SSR preview must receive the same configured credential. - **Color ramp**: 10-step blue ramp; each hex color is chosen by its count relative to the max count in the current view. ### Zoom-to-Resolution -| Leaflet Zoom | H3 Resolution | Typical Use | +| Application Zoom | H3 Resolution | Typical Use | |--------------|---------------|-------------| | ≤3 | 2 | Large country / multi-country | | 4 | 3 | Country / state | @@ -79,21 +81,23 @@ Featured items are defined in `frontend/src/config/featured.ts`. Each ID corresp - **Map fly**: The map flies to the active item's `dcat_bbox`. Allmaps items use tighter zoom (maxZoom 12, padding 20); others use maxZoom 10, padding 60. - **Bounds rectangle**: A blue outline and semi-transparent fill show the resource extent. - **Preview layer**: - - **GeoBlacklight** (WMS, WMTS, ArcGIS, XYZ, etc.): Renders the layer via GeoBlacklight Leaflet layers. - - **Allmaps**: Uses `@allmaps/leaflet` `WarpedMapLayer` to display georeferenced IIIF maps from the Allmaps annotation URL. + - **OGM Viewer** (WMS, WMTS, ArcGIS, XYZ, etc.): Attaches OGM Viewer MapLibre previewers to the shared map. + - **Allmaps**: Uses `@allmaps/maplibre` `WarpedMapLayer` to display georeferenced IIIF maps from the Allmaps annotation URL. +- **Layer order**: MapLibre pane anchors keep density hexes (400), bounds (410), selection (415), and featured previews (420) in order regardless of fetch completion or hex visibility toggles. Featured ArcGIS point layers use overlapping blue pins; routes use the production blue stroke. Pin layers are removed with the preview on slide changes and Home. +- **Readiness**: Overlay installation waits for the style document, not tile completion or idle; animated Allmaps previews must not block hex restoration. Carousel progress ticks leave map layers unchanged, and H3 requests use settled bounds/zoom. The Home camera is captured from configuration before previews can move the map. - **Popup card**: Title, description, year, resource class, thumbnail, and "View resource" link. ### User Engagement -The map tracks whether the user has panned or zoomed. If they do before the 10-second timer, the featured carousel does **not** auto-start (user engagement takes precedence). Programmatic moves (initial pan, flyToBounds for featured items) are ignored. The carousel remains visible; the user can still click a thumbnail to trigger the featured experience. +The map tracks whether the user has panned or zoomed. If they do before the 10-second timer, the featured carousel does **not** auto-start (user engagement takes precedence). Programmatic flights for featured items and passive layout/style events are ignored. The carousel remains visible; the user can still click a thumbnail to trigger the featured experience. --- ## Preview Layer Types -### GeoBlacklight (Leaflet) Resources +### OGM Viewer Resources -Supported protocols: WMS, WMTS, ArcGIS (dynamic, feature, tiled, image), Tile JSON, Open Index Map, TMS, XYZ. The `FeaturedItemPreviewLayer` uses `meta.ui.viewer` (protocol, endpoint, geometry) and dynamically loads the appropriate GeoBlacklight layer. +Supported protocols: WMS, WMTS, ArcGIS (dynamic, feature, tiled, image), Tile JSON, Open Index Map, TMS, XYZ. The `FeaturedItemPreviewLayer` normalizes the Aardvark record, derives resources and previewers through `ogm-viewer/lib`, and attaches the first geographic preview to the shared MapLibre map. ### Allmaps Georeferenced Maps @@ -103,7 +107,7 @@ Resources with entries in the `resource_allmaps` table (where `annotated = true` - `allmaps_annotated` — Whether georeferencing exists - `allmaps_manifest_uri` — IIIF manifest URL -The frontend creates a `WarpedMapLayer` from `@allmaps/leaflet` using the annotation URL. Allmaps uses WebGL to warp IIIF images onto their geographic position. See [Allmaps Leaflet docs](https://allmaps.org/docs/packages/leaflet/). +The frontend creates a `WarpedMapLayer` from `@allmaps/maplibre` using the annotation URL. Allmaps uses WebGL to warp IIIF images onto their geographic position. See [Allmaps MapLibre docs](https://allmaps.org/docs/packages/maplibre/). --- @@ -116,7 +120,7 @@ The frontend creates a `WarpedMapLayer` from `@allmaps/leaflet` using the annota | `FeaturedMapController` | Flies map to active featured item's bbox | | `FeaturedItemPreviewLayer` | Renders GeoBlacklight or Allmaps preview layer | | `FeaturedItemBoundsLayer` | Draws bounds rectangle for active item | -| `MapPanner` | One-time initial pan (Chicago positioning) | +| `HomeMapInitialView` | Captures the production-offset initial camera without moving it | | `MapUserEngagementTracker` | Detects user pan/zoom for engagement logic | | `SearchHereControl` | "Search here" button after user interaction | diff --git a/docs/frontend/ogm-viewer.md b/docs/frontend/ogm-viewer.md new file mode 100644 index 00000000..f79c65b7 --- /dev/null +++ b/docs/frontend/ogm-viewer.md @@ -0,0 +1,113 @@ +# OGM Viewer integration + +The application consumes a source-built prerelease of +[geobtaa/ogm-viewer](https://github.com/geobtaa/ogm-viewer/tree/feature/viewer-integration), +based on upstream v1.7.0. The dependency key remains `ogm-viewer`; the tarball +contains `@geobtaa/ogm-viewer` version `1.7.0-btaa.1.5`. `package.json` names an +exact release asset URL and `package-lock.json` pins its integrity. +`fork-build.json` inside the installed package identifies its source commit, +upstream baseline, build Node version, and lockfile hash. No upstream PRs have +been opened for this work. + +The fork retains support for comma-separated resource bounding boxes, fixing the +initial map extent for records such as `cugir-007910`. The fork includes a WMS +browser regression covering delayed capabilities loading. + +UW–Madison Image API records use an encoded slash (`%2F`) in the identifier. +When the publisher's `info.json` expands that slash, the viewer keeps the +requested encoding for image tiles and Downloads links. See +[viewer issue #3](https://github.com/geobtaa/ogm-viewer/issues/3) for a live example. + +Records with multiple PMTiles archives show one preview tab per archive, in metadata order. See [viewer issue #7](https://github.com/geobtaa/ogm-viewer/issues/7). + +Upstream 1.7.0 adds COG index-map mosaics, FGDC-derived legends, layer ordering +controls, and improved handling of blocked requests. Our selection/navigation +contracts and embedding options remain available. + +## Ownership and contracts + +The fork contains separate changes for selection/navigation events, optional +embedding controls, optional manifest presentation, and browser regression tests. +The [fork maintenance guide](https://github.com/geobtaa/ogm-viewer/blob/feature/viewer-integration/FORK.md) +describes their packaging and upgrade process. These changes live in TypeScript +source; there are no application postinstall edits to compiled viewer bundles. + +`ResourceViewer.tsx` is the React adapter. It listens for public `previewChange` +and `imageChange` events, caches each preview's image, rejects old-record events, +and publishes only the active image preview. The event types are imported from +`ogm-viewer/lib`, rather than copied into the application. + +`imageChange` identifies the preview and record and supplies `sequence`, +`pageIndex`, and the opened `image`. Sequence indices are viewer image indices, +not IIIF canvas indices; `occurrence` distinguishes repeated image URLs. +`image: null` clears downloads during loading, page transitions, or failure. +Optional `image.service` contains already-loaded Image API capabilities. +`viewerImageDownloads.ts` derives links from those capabilities without a +second manifest request. Publisher-provided downloads remain application-owned. + +The Downloads picker dispatches `imageNavigationRequest` with the selected +record/preview identity, URL, and index. Both the adapter and viewer validate +the request; the viewer's resulting events remain authoritative. Application +code does not inspect private OpenSeadragon objects or viewer shadow DOM. + +The resource page opts into `external-preview-tabs` and renders the viewer's +`previewTabsChange` choices beside Fullscreen and Open in new tab. A single +preview keeps its selected tab. Map Overlay joins the same list when available. +Selecting a preview calls `selectPreviewTab`. As previews load or recover, OGM +Viewer updates the list of visible tabs and their active and disabled states. +[Viewer issue #6](https://github.com/geobtaa/ogm-viewer/issues/6) documents the +Ann Arbor example. Standalone mode uses its built-in +navigation. Both modes use `omit-location`, `prefer-manifest` and +`hide-single-tab`. The resource page also sets `hide-menubar`. The fork's defaults preserve +upstream behavior. Location-only records do not mount a viewer. Presentation +uses Stencil state and initial-render attributes rather than DOM patching. + +The application fullscreen toolbar shares its expanded state with `ResourceViewer` +through React context. The viewer fills the frame below the toolbar while expanded, +and returns to its embedded height on exit. Browser tests cover map and image +canvases, native fullscreen, and the viewport fallback. + +## Basemap controls + +The top-right controls start with zoom and compass, then fullscreen, then the +basemap picker. View-specific tools follow. In resource previews these are +layer opacity and globe projection. Keyboard focus follows the same order. + +API and MCP embeds load the browser modules at `/api/v1/viewer-assets/`. +Docker images include these modules. A local API can use the frontend’s +`npm ci --legacy-peer-deps` installation or install just the viewer from the +repository root. + +```sh +python backend/scripts/install_viewer_assets.py frontend/package-lock.json frontend/node_modules/ogm-viewer/dist/components +``` + +OpenFreeMap Positron is the default for interactive maps and for newly rendered +location and bounding-box thumbnails. On resource map previews, the droplet +opens layer controls, including opacity. The stacked-layers button opens the +same basemap picker as the sidebar map. A selected style is remembered on this +site. Static thumbnails use the configured renderer style regardless of that +browser preference. The externally hosted Allmaps iframe controls its own basemap. + +## Verification and upgrades + +1. Review the fork's focused source commits against the candidate upstream release. +2. Build and run its source/component tests and local-fixture browser suite. +3. Package a new prerelease from committed source; never replace an existing asset. +4. Update the application's exact asset URL and lockfile together. Run clean `npm ci`, + focused component tests, `npm run test:viewer:browser`, and `npm run build`. +5. Use `make frontend-reset` after dependency/config changes and hard-refresh. + Check representative live IIIF, ArcGIS, COG, and Allmaps records before deployment. + +The browser suite runs actual components in development and production builds. +It is separate from Vitest's mocked component tests; both are useful. Fixtures +are local and network-independent. Ports 4180 and 4181 must be free. + +The viewer source build bundles its decoder and MapLibre workers and WASM assets. +The application no longer substitutes worker paths, WASM paths, or basemap URLs +in compiled JavaScript; it supplies basemap URLs through public component props. + +When an upstream release supplies equivalent contracts, replace the dependency, +adjust the thin adapter if necessary, and retain the browser tests. Review +`hasOgmContentPreview` at each upgrade because its supported-reference list +currently mirrors the pinned viewer's capabilities. diff --git a/docs/frontend/testing.md b/docs/frontend/testing.md index 9a52cccf..ab9e0def 100644 --- a/docs/frontend/testing.md +++ b/docs/frontend/testing.md @@ -600,3 +600,42 @@ Allmaps page-load checks are covered by `useAllmapsAvailability.test.tsx` (mocked HTTP responses, real annotation parser), including discovery after a reload, empty/invalid results, timeout, and stale-response cancellation. The resource-page suite verifies that live discovery reveals the overlay tab. + +The suite uses the shared happy-dom environment, including analytics dashboards, +and bounds workers to two so exhaustive DOM/accessibility audits have consistent +CPU availability. Run the full suite with `npm test -- --run` and coverage with +`npm run test:coverage -- --run`; no analytics test exclusion is required. + +Generated analytics JSON snapshots remain in their generator's compact format. +Prettier checks hand-maintained sources; snapshot generators and evidence checks +validate those generated files without reformatting their bytes. + +Accessibility audits evaluate all WCAG-tagged rules and keep full violation and +incomplete results. The shared axe helper limits detailed passing-node output, +following axe's `resultTypes` performance guidance, to avoid generating unused +selectors for thousands of passing report cells. Report behavior and exhaustive +report/period audits use separate test files; real navigation layout accessibility +is covered by its component suite. No report/period case is excluded. + +Exhaustive full-report WCAG audits have a bounded 120-second per-report budget +because all-time tables can exceed 60 seconds under coverage on shared CPUs. +Interaction tests retain their 30-second budget. These time limits do not exclude +records, periods, nodes, or WCAG rules from evaluation. + +## OGM Viewer browser contracts + +Run `npx playwright install chromium` once, then `npm run test:viewer:browser` +from `frontend/`. This runs the actual installed viewer with our React +`ResourceViewer` and `DownloadsTable` in both Vite development and production +builds, using local IIIF and ArcGIS fixtures. It needs no API server, database, +external image service, or basemap. The dedicated fixture entry is outside the +application route tree and is never included in the deployed application. + +Coverage includes v2/v3 manifests, multiple images per canvas, repeated image +URLs, bidirectional paging, download clearing during loading/failure, initial +fallback, record replacement, map selection, feature inspection, publisher +download preservation, and location-only records. Unexpected API or external +requests fail the suite. Failed CI runs retain Playwright traces and screenshots. +The browser CI job pins Ubuntu 24.04 to match Playwright 1.60 browser support; +update the runner and Playwright together when upgrading this suite. +See [the viewer integration](ogm-viewer.md) for dependency and upgrade policy. diff --git a/docs/make_tasks.md b/docs/make_tasks.md index 75c4d1a2..7fdf75f3 100644 --- a/docs/make_tasks.md +++ b/docs/make_tasks.md @@ -351,3 +351,15 @@ path and `SEARCH_RELEVANCE_BENCHMARK_WORKLOAD=results`. Report separate runs wit disabled in both. `SEARCH_RELEVANCE_BENCHMARK_COPIES` optionally scales the corpus with synthetic fixture copies. See the search documentation for methodology and limitations. + +Local Native map rendering: `make native-map-start` starts its compatible Linux +renderer; `make native-map-test` runs camera tests inside that container. + +For reproducible backend checks, use the locked Python 3.12 development +environment (matching CI), rather than globally installed test packages: + +```bash +uv sync --project backend --locked --extra dev --python 3.12 +uv run --project backend --extra dev --locked make lint-check +uv run --project backend --extra dev --locked make test +``` diff --git a/frontend/.dockerignore b/frontend/.dockerignore index 69ff8dca..7e2e118f 100644 --- a/frontend/.dockerignore +++ b/frontend/.dockerignore @@ -12,3 +12,7 @@ yarn-debug.log* yarn-error.log* .env .env.* + +**/.viewer-browser-build/ +**/test-results/ +**/playwright-report/ diff --git a/frontend/.gitignore b/frontend/.gitignore index 059d693b..91f97c7e 100644 --- a/frontend/.gitignore +++ b/frontend/.gitignore @@ -132,3 +132,8 @@ dist .env.production .env.development .env.production + +# Deterministic viewer browser tests +.viewer-browser-build/ +test-results/ +playwright-report/ diff --git a/frontend/.prettierignore b/frontend/.prettierignore new file mode 100644 index 00000000..ceb46b7c --- /dev/null +++ b/frontend/.prettierignore @@ -0,0 +1,3 @@ +# Generated analytics snapshots are intentionally serialized as compact JSON. +# Their generators and evidence checks own byte-level reproducibility. +src/data/analytics/*.json diff --git a/frontend/Dockerfile b/frontend/Dockerfile index b3a3f990..9ba5cc07 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -8,11 +8,8 @@ WORKDIR /app # Copy package files COPY package.json package-lock.json* ./ -# Install dependencies -# Remove package-lock.json first to fix npm optional dependencies bug -# This ensures Rollup's optional native modules are installed correctly -RUN rm -f package-lock.json 2>/dev/null || true -RUN npm install --legacy-peer-deps +# Install the same dependency graph verified locally and in CI. +RUN npm ci --legacy-peer-deps # Rebuild the source code only when needed FROM base AS builder diff --git a/frontend/app/entry.client.tsx b/frontend/app/entry.client.tsx index 55263bae..50f93ea8 100644 --- a/frontend/app/entry.client.tsx +++ b/frontend/app/entry.client.tsx @@ -2,7 +2,6 @@ import React from "react"; import { startTransition, StrictMode } from "react"; import { hydrateRoot } from "react-dom/client"; import { HydratedRouter } from "react-router/dom"; -import "../src/config/fixLeafletDefaultIcon"; function removeInvalidDocumentElementChildren() { for (const child of Array.from(document.documentElement.children)) { diff --git a/frontend/app/lib/__tests__/server-api-retry.test.ts b/frontend/app/lib/__tests__/server-api-retry.test.ts new file mode 100644 index 00000000..0be021dc --- /dev/null +++ b/frontend/app/lib/__tests__/server-api-retry.test.ts @@ -0,0 +1,31 @@ +import { expect, it, vi } from 'vitest'; +import { serverFetchJson, serverFetchJsonWithTheme } from '../server-api'; +vi.mock('../theme.server', () => ({ getThemeConfigFromRequest: () => ({}) })); +it.each(['plain', 'theme'])( + 'preserves upstream retry guidance for %s API errors', + async (mode) => { + vi.stubGlobal( + 'fetch', + vi + .fn() + .mockResolvedValue( + new Response('throttled', { + status: 429, + headers: { 'Retry-After': '30' }, + }) + ) + ); + const error = await ( + mode === 'plain' + ? serverFetchJson('/map/h3') + : serverFetchJsonWithTheme( + new Request('https://example.com/map/h3'), + '/map/h3' + ) + ).catch((error) => error); + expect(error).toBeInstanceOf(Response); + expect(error.status).toBe(429); + expect(error.headers.get('Retry-After')).toBe('30'); + expect(error.headers.get('Cache-Control')).toBe('no-store'); + } +); diff --git a/frontend/app/lib/iiif.ts b/frontend/app/lib/iiif.ts index fe3c9750..9ec490ce 100644 --- a/frontend/app/lib/iiif.ts +++ b/frontend/app/lib/iiif.ts @@ -25,7 +25,7 @@ function inferImageUrl(serviceId: string): string { /** * Build a minimal IIIF Presentation 3 manifest for an IIIF Image Service. - * This lets Mirador render `iiif_image` references by converting them into a manifest. + * This lets Presentation API clients render image references as a manifest. */ export function buildPresentation3ManifestFromImageInfo(args: { manifestId: string; diff --git a/frontend/app/lib/server-api.ts b/frontend/app/lib/server-api.ts index 105f6609..f3cf8bbd 100644 --- a/frontend/app/lib/server-api.ts +++ b/frontend/app/lib/server-api.ts @@ -102,7 +102,15 @@ export async function serverFetchJson( if (!response.ok) { throw new Response( `API request failed: ${response.status} ${response.statusText}`, - { status: response.status } + { + status: response.status, + headers: { + 'Cache-Control': 'no-store', + ...(response.headers.get('Retry-After') + ? { 'Retry-After': response.headers.get('Retry-After')! } + : {}), + }, + } ); } return response.json(); @@ -117,7 +125,15 @@ export async function serverFetchJsonWithTheme( if (!response.ok) { throw new Response( `API request failed: ${response.status} ${response.statusText}`, - { status: response.status } + { + status: response.status, + headers: { + 'Cache-Control': 'no-store', + ...(response.headers.get('Retry-After') + ? { 'Retry-After': response.headers.get('Retry-After')! } + : {}), + }, + } ); } return response.json(); diff --git a/frontend/app/providers.tsx b/frontend/app/providers.tsx index 6eacbed5..d97f9722 100644 --- a/frontend/app/providers.tsx +++ b/frontend/app/providers.tsx @@ -1,4 +1,4 @@ -import React, { useEffect } from 'react'; +import React from 'react'; import { ApiProvider } from '../src/context/ApiContext'; import { BookmarkProvider } from '../src/context/BookmarkContext'; import { DebugProvider } from '../src/context/DebugContext'; @@ -7,88 +7,15 @@ import { ThemeProvider } from '../src/context/ThemeContext'; import type { ThemeId } from '../src/config/institution'; import { TurnstileGate } from '../src/components/security/TurnstileGate'; -/** - * App providers + client-side boot for GeoBlacklight (Stimulus). - * - * We keep this intentionally simple: - * - Start Stimulus once - * - Import GeoBlacklight core once (it registers its own controllers/listeners) - * - Trigger GeoBlacklight activation on initial load and on route changes - */ export function Providers({ children, initialThemeId, - locationKey, turnstilePreview = false, }: { children: React.ReactNode; initialThemeId?: ThemeId; - locationKey?: string; turnstilePreview?: boolean; }) { - useEffect(() => { - // Only runs in the browser - if (typeof window === 'undefined') return; - - let cancelled = false; - - async function boot() { - if (cancelled) return; - try { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const g = globalThis as any; - - // Start Stimulus once and expose it globally (GeoBlacklight expects `Stimulus`). - if (!g.Stimulus) { - const { Application } = await import('@hotwired/stimulus'); - g.Stimulus = Application.start(); - (window as any).Stimulus = g.Stimulus; - } - - // Mirador is embedded via an iframe (see ResourceViewer) so we intentionally do NOT - // register a Stimulus controller for it. This avoids any possibility of Mirador code - // affecting the parent page. - - // Import GeoBlacklight core once; it registers its own controllers and listeners. - if (!g.GeoblacklightCore) { - const mod = - await import('@geoblacklight/frontend/app/javascript/geoblacklight/core'); - g.GeoblacklightCore = (mod as any).default ?? mod; - } - - // GeoBlacklight uses DOMContentLoaded / Turbo events; in our SSR+SPA environment, - // those may not fire at the right time. Trigger activation on initial load + navigation. - if (typeof g.GeoblacklightCore?.activate === 'function') { - // Some initializers assume specific DOM nodes exist and can throw if they don't. - // Never let that take down the app or interfere with the viewer. - // Defer one tick so the new route's DOM is committed before initializers run. - setTimeout(() => { - try { - g.GeoblacklightCore.activate( - new Event('react-router:navigation') - ); - } catch (err) { - // eslint-disable-next-line no-console - console.warn('GeoBlacklight activation failed:', err); - } - }, 0); - } - } catch (err) { - // eslint-disable-next-line no-console - console.warn('GeoBlacklight boot failed:', err); - } - } - - boot().catch((err) => { - // eslint-disable-next-line no-console - console.warn('GeoBlacklight boot failed:', err); - }); - - return () => { - cancelled = true; - }; - }, [locationKey]); - return ( diff --git a/frontend/app/root.tsx b/frontend/app/root.tsx index 0e619689..edaa1178 100644 --- a/frontend/app/root.tsx +++ b/frontend/app/root.tsx @@ -16,7 +16,7 @@ import { getDefaultThemeId, type ThemeId } from '../src/config/institution'; import { GoogleTagManager } from '../src/components/analytics/GoogleTagManager'; import { GeoportalRouteErrorBoundary } from '../src/pages/ErrorPage'; import '../src/index.css'; -import '../src/styles/leaflet.css'; +import '../src/styles/maps.css'; const GOOGLE_TAG_MANAGER_ID = (import.meta.env.VITE_GTM_ID || '').trim(); const KAMAL_DESTINATION = (import.meta.env.VITE_KAMAL_DEST || '').trim(); @@ -32,11 +32,11 @@ export async function loader({ request }: LoaderFunctionArgs) { function RootDocument({ children, - isMiradorRoute = false, + isStandaloneViewerRoute = false, themeId, }: { children: ReactNode; - isMiradorRoute?: boolean; + isStandaloneViewerRoute?: boolean; themeId: ThemeId; }) { return ( @@ -56,7 +56,7 @@ function RootDocument({ {/* GeoBlacklight expects a Blacklight modal container (#blacklight-modal). Without it, the metadata_download initializer throws and prevents all other GeoBlacklight initializers from running (tooltips/truncation/etc). */} - {!isMiradorRoute && ( + {!isStandaloneViewerRoute && (