feat: extend FITS viewer to support PNG and additional FITS extensions#132
Merged
ppp-one merged 1 commit intoppp-one:mainfrom Mar 28, 2026
Merged
feat: extend FITS viewer to support PNG and additional FITS extensions#132ppp-one merged 1 commit intoppp-one:mainfrom
ppp-one merged 1 commit intoppp-one:mainfrom
Conversation
- Add .fit, .fts, and .png to allowed file extensions in the backend - Add shared fileTypes.js for extension detection used by both explorer and viewer; viewer/fileTypes.js bridges it with a safe fallback - Implement PNG display mode: dedicated layout hides FITS-specific controls and shows an <img> element instead of the canvas - Introduce load generation + AbortController session management to cancel in-flight requests when a new file is opened - Expose openViewerFile() on window so the explorer modal delegates file-type routing to the viewer module - Add fits_url parameter to create_router() and inject __ASTRA_FITS_FILES_BASE_PATH so the viewer resolves raw file URLs correctly when mounted at a non-default prefix - Move encodePathSegments to basePath.js so rawFitsUrl reuses it - Extract setFitsControlsEnabled() to unify toolbar enable/disable
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request
Description
Extends the FITS file viewer to support PNG files and additional FITS filename extensions (
.fit,.fts). When a PNG is opened, the viewer switches to an image-only layout — hiding FITS-specific controls (stretch, log scale, HDU selector) — and displays the file via a native<img>element. Switching between files cancels any in-flight requests viaAbortControllersession management to prevent stale renders.Changes Made
.fit,.fts,.pngto allowed extensions infile_explorer.pyshared/fileTypes.jsfor extension detection shared between the explorer file list and the viewerviewer/fileTypes.jsbridgingwindow.__astraFileTypeswith a safe fallback; exportsisPngFileandisFitsFileviewer/index.js:applyPngLayout()hides FITS controls, shows<img>;applyFitsLayout()restores the canvas/header layoutAbortControllersession tracking (beginNewSession,createSessionController) to abort stale requests on file switchopenViewerFile()onwindowso the explorer modal delegates file-type routing to the viewer module instead of callingloadPreviewdirectlyfits_urlparameter tocreate_router()and injectwindow.__ASTRA_FITS_FILES_BASE_PATHfor correct raw file URL resolution at non-default mount prefixesencodePathSegmentstobasePath.js; addrawFitsUrl()for encoding raw file pathsrenderer.js: addcancelPending()/enableRender()and a render token to drop stale FITS renders when switching to PNGHow to Test
.fitsand.pngfiles.fitor.ftsfile — verify it loads correctly as FITSChecklist