From 93be4ce9d8f2a72f17556dc159c01740ca2e0620 Mon Sep 17 00:00:00 2001 From: Alan Grainger <16197738+alangrainger@users.noreply.github.com> Date: Sun, 14 Jun 2026 10:33:10 +1200 Subject: [PATCH] Add typing for Photoswipe options --- app/package-lock.json | 11 +++++++++++ app/package.json | 1 + app/src/client/lightbox.ts | 7 +++++-- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/app/package-lock.json b/app/package-lock.json index 24aadf8..165e8d8 100644 --- a/app/package-lock.json +++ b/app/package-lock.json @@ -31,6 +31,7 @@ "concurrently": "^10.0.3", "eslint": "^8.57.0", "eslint-config-standard": "^17.1.0", + "photoswipe": "^5.4.4", "tsx": "^4", "typescript": "^5.6.2", "vitest": "^4" @@ -5561,6 +5562,16 @@ "dev": true, "license": "MIT" }, + "node_modules/photoswipe": { + "version": "5.4.4", + "resolved": "https://registry.npmjs.org/photoswipe/-/photoswipe-5.4.4.tgz", + "integrity": "sha512-WNFHoKrkZNnvFFhbHL93WDkW3ifwVOXSW3w1UuZZelSmgXpIGiZSNlZJq37rR8YejqME2rHs9EhH9ZvlvFH2NA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.12.0" + } + }, "node_modules/picocolors": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", diff --git a/app/package.json b/app/package.json index 5057222..64ece5b 100644 --- a/app/package.json +++ b/app/package.json @@ -40,6 +40,7 @@ "concurrently": "^10.0.3", "eslint": "^8.57.0", "eslint-config-standard": "^17.1.0", + "photoswipe": "^5.4.4", "tsx": "^4", "typescript": "^5.6.2", "vitest": "^4" diff --git a/app/src/client/lightbox.ts b/app/src/client/lightbox.ts index 1fd52c5..a780d3d 100644 --- a/app/src/client/lightbox.ts +++ b/app/src/client/lightbox.ts @@ -6,6 +6,7 @@ // @ts-expect-error - browser-only ESM URL import PhotoSwipeLightbox from '/share/static/photoswipe/photoswipe-lightbox.esm.js' // eslint-disable-line import/no-absolute-path +import type { PhotoSwipeOptions } from 'photoswipe' import { state, SIDEBAR_WIDTH, MOBILE_BREAKPOINT } from './state.js' import type { GalleryItem } from '../shared/types.js' import { @@ -95,7 +96,7 @@ export function initLightbox () { ...configPadding } - state.lightbox = new PhotoSwipeLightbox({ + const lightboxOptions: PhotoSwipeOptions = { bgOpacity: 1, showHideAnimationType: 'fade', closeOnVerticalDrag: true, @@ -122,7 +123,9 @@ export function initLightbox () { dataSource: buildDataSource(), // @ts-expect-error - runtime URL resolved by Express static pswpModule: () => import('/share/static/photoswipe/photoswipe.esm.js') // eslint-disable-line import/no-absolute-path - }) + } + + state.lightbox = new PhotoSwipeLightbox(lightboxOptions) registerBackButton(state.lightbox) if (state.lightboxConfig.showDownload) registerDownloadButton(state.lightbox)