# Frontend asset management
#
# Vendored JS libs live in assets/vendor/ and are served by the daemon
# at /assets/vendor/<file>. Pin versions explicitly; bump manually.
#
# Pattern guide: reflection/templates/vendor-frontend-assets-prompt.md

CYTOSCAPE_NAVIGATOR_VERSION := "2.0.1"
HTMX_VERSION := "2.0.7"

# Export this daemon's API catalog to api-catalog.json.
# Run after any #[onto_api] annotation is added or changed.
# The file is read by the ontoref UI when this project is registered as a
# non-primary slug — consumer projects that run as separate binaries use this
# to expose their API surface in the ontoref UI.
[doc("Export #[onto_api] routes to artifacts/api-catalog-ontoref-daemon.ncl")]
export-api-catalog:
    mkdir -p artifacts
    cargo run -p ontoref-daemon --no-default-features -- --dump-api-catalog > artifacts/api-catalog-ontoref-daemon.ncl
    @echo "exported routes to artifacts/api-catalog-ontoref-daemon.ncl"

# Download/update all vendored frontend JS dependencies
[doc("Vendor all frontend JS dependencies")]
vendor-js: vendor-cytoscape-navigator vendor-htmx

# cytoscape-navigator — minimap extension for Cytoscape.js
[doc("Vendor cytoscape-navigator (minimap)")]
vendor-cytoscape-navigator:
    mkdir -p assets/vendor
    curl -fsSL \
        "https://cdn.jsdelivr.net/npm/cytoscape-navigator@{{CYTOSCAPE_NAVIGATOR_VERSION}}/cytoscape-navigator.js" \
        -o assets/vendor/cytoscape-navigator.js
    @echo "vendored cytoscape-navigator@{{CYTOSCAPE_NAVIGATOR_VERSION}}"

# htmx — HTML-first hypermedia library (goes to public/vendor — served via /public/)
[doc("Vendor htmx")]
vendor-htmx:
    mkdir -p crates/ontoref-daemon/public/vendor
    curl -fsSL \
        "https://cdn.jsdelivr.net/npm/htmx.org@{{HTMX_VERSION}}/dist/htmx.min.js" \
        -o crates/ontoref-daemon/public/vendor/htmx.min.js
    @echo "vendored htmx@{{HTMX_VERSION}}"
