@@ -1727,14 +1727,52 @@ function previewdataurl(url, idx) {
17271727 console . warn ( "⚠️ Unsupported file format for preview:" , url ) ;
17281728 return ;
17291729 }
1730- // disable cache
1730+ // cached
1731+ // if (urldata.hasOwnProperty(url)) {
1732+ // if (
1733+ // urldata[url] instanceof nj.NdArray ||
1734+ // urldata[url].hasOwnProperty("MeshNode")
1735+ // ) {
1736+ // previewdata(urldata[url], idx, false);
1737+ // }
1738+ // return;
1739+ // }
1740+
17311741 if ( urldata . hasOwnProperty ( url ) ) {
1732- if (
1733- urldata [ url ] instanceof nj . NdArray ||
1734- urldata [ url ] . hasOwnProperty ( "MeshNode" )
1735- ) {
1736- previewdata ( urldata [ url ] , idx , false ) ;
1742+ const cached = urldata [ url ] ;
1743+
1744+ // ✅ fNIRS / time-series (cached)
1745+ if ( cached ?. data ?. dataTimeSeries ) {
1746+ let serieslabel = true ;
1747+ if ( cached . data . measurementList ) {
1748+ serieslabel = Array ( cached . data . measurementList . length )
1749+ . fill ( "" )
1750+ . map (
1751+ ( _ , i ) =>
1752+ "S" +
1753+ cached . data . measurementList [ i ] . sourceIndex +
1754+ "D" +
1755+ cached . data . measurementList [ i ] . detectorIndex
1756+ ) ;
1757+ }
1758+
1759+ const plotData2D = nj . concatenate (
1760+ cached . data . time . reshape ( cached . data . time . size , 1 ) ,
1761+ cached . data . dataTimeSeries
1762+ ) . T ;
1763+
1764+ previewdata ( plotData2D , idx , false , serieslabel ) ; // 🔔 triggers __onPreviewReady
1765+ return ;
17371766 }
1767+
1768+ // ✅ Mesh/volume (cached)
1769+ if ( cached instanceof nj . NdArray || cached ?. MeshNode ) {
1770+ previewdata ( cached , idx , false ) ; // 🔔 triggers __onPreviewReady
1771+ return ;
1772+ }
1773+
1774+ // 🔂 Fallback: still try to preview whatever it is
1775+ previewdata ( cached , idx , false ) ;
17381776 return ;
17391777 }
17401778
0 commit comments