@@ -10,7 +10,7 @@ let templates;
1010let lastGeneratedProject = null ;
1111
1212// var platforms = {
13- // "osx": "OS X (Xcode)",
13+ // "osx": "macOS (OSX) (Xcode)",
1414// "vs": "Windows (Visual Studio)",
1515// "ios": "iOS (Xcode)",
1616// "linux": "Linux 32-bit (Code::Blocks)",
@@ -68,7 +68,7 @@ function applyTranslations() {
6868 const rescanLink = '<a href="#rescanAddons" onclick="rescanAddons()">' + t ( 'msgBox.missingAddons.linkText' ) + '</a>' ;
6969 $ ( '#missingAddonBody2' ) . html ( t ( 'msgBox.missingAddons.body2Suffix' , { link : rescanLink } ) ) ;
7070
71- $ ( '#ofMenuDescription' ) . html ( t ( 'ofMenu.description' , { script : '<span class="monospace">scripts/of.sh</span>' } ) ) ;
71+ if ( libReleases ) renderModularLibs ( ) ;
7272
7373 $ ( '#ofPathSierraEasyFix' ) . html ( `<strong>${ t ( 'msgBox.sierra.easyFixLabel' ) } </strong> ${ t ( 'msgBox.sierra.easyFix' ) } ` ) ;
7474 $ ( '#ofPathSierraPermanentFix' ) . html ( `<strong>${ t ( 'msgBox.sierra.permanentFixLabel' ) } </strong> ${ t ( 'msgBox.sierra.permanentFix' ) } ` ) ;
@@ -669,6 +669,32 @@ function setup() {
669669 }
670670 } ) ;
671671
672+ $ ( '#coreReleaseDropdown, #corePlatformDropdown' ) . dropdown ( ) ;
673+ $ ( '#coreSourceDropdown' ) . dropdown ( { onChange : ( ) => fillCoreSource ( false ) } ) ;
674+ $ ( '#modularReleaseDropdown' ) . dropdown ( { onChange : ( ) => fillModularTargets ( ) } ) ;
675+ $ ( '#modularTargetDropdown' ) . dropdown ( { onChange : ( ) => renderModularLibs ( ) } ) ;
676+ $ ( '#modularSelectAll' ) . on ( 'change' , function ( ) {
677+ const release = currentModularRelease ( ) ;
678+ const target = $ ( '#modularTargetDropdown' ) . dropdown ( 'get value' ) ;
679+ modularSelection = new Set ( this . checked && release ? release . modular . filter ( ( l ) => l . target === target ) . map ( ( l ) => l . asset ) : [ ] ) ;
680+ renderModularLibs ( ) ;
681+ } ) ;
682+
683+ $ ( "#ofMenuButton" ) . tab ( {
684+ 'onVisible' : ( ) => {
685+ if ( isOfPathGood !== true ) {
686+ $ ( '#settingsMenuButton' ) . click ( ) ;
687+ $ ( '#ofPathError' ) . modal ( {
688+ onHide : ( ) => {
689+ $ ( '#settingsMenuButton' ) . click ( ) ;
690+ }
691+ } ) . modal ( "show" ) ;
692+ return ;
693+ }
694+ loadLibReleases ( false ) ;
695+ }
696+ } ) ;
697+
672698 $ ( "#settingsMenuButton" ) . tab ( {
673699 'onVisible' : ( ) => {
674700 console . log ( "settings!! " ) ;
@@ -856,6 +882,11 @@ function setup() {
856882 } ) ;
857883
858884 // the console dock is always present as a collapsed peek strip - only
885+ // keep the page scrollable past the console at any height
886+ new ResizeObserver ( ( [ entry ] ) => {
887+ document . documentElement . style . setProperty ( '--console-height' , entry . target . offsetHeight + 'px' ) ;
888+ } ) . observe ( document . getElementById ( 'consoleContainer' ) ) ;
889+
859890 // whether it's expanded (showConsole) is a persisted preference
860891 if ( defaultSettings [ 'showConsole' ] ) { $ ( "body" ) . addClass ( 'showConsole' ) ; }
861892 $ ( "#showConsole" ) . on ( 'click' , function ( ) {
@@ -1613,18 +1644,238 @@ ipcRenderer.on('buildEmscriptenDone', () => {
16131644 $ ( "#EmscriptenPreviewButton" ) . removeClass ( 'loading disabled' ) . text ( t ( 'button.buildPreview' ) ) ;
16141645} ) ;
16151646
1616- function ofMenuButtonFor ( command ) {
1617- return command === 'status' ? $ ( '#ofMenuStatusButton' ) : $ ( '#ofMenuUpdateLibsButton' ) ;
1618- }
1619-
16201647function runOfMenuCommand ( command ) {
1621- ofMenuButtonFor ( command ) . addClass ( 'loading disabled' ) ;
1648+ $ ( '#ofMenuStatusButton' ) . addClass ( 'loading disabled' ) ;
16221649 openConsoleForOperation ( ) ;
16231650 ipcRenderer . send ( 'runOfMenu' , { command, ofPath : $ ( "#ofPath" ) . val ( ) } ) ;
16241651}
16251652
1626- ipcRenderer . on ( 'ofMenuDone' , ( event , { command } ) => {
1627- ofMenuButtonFor ( command ) . removeClass ( 'loading disabled' ) ;
1653+ ipcRenderer . on ( 'ofMenuDone' , ( ) => {
1654+ $ ( '#ofMenuStatusButton' ) . removeClass ( 'loading disabled' ) ;
1655+ } ) ;
1656+
1657+ //----------------------------------------
1658+ // downloads tab
1659+ let libReleases = null ;
1660+ let modularSelection = new Set ( ) ;
1661+
1662+ function loadLibReleases ( refresh ) {
1663+ $ ( '#refreshLibReleasesButton' ) . addClass ( 'loading disabled' ) ;
1664+ $ ( '#libReleasesError' ) . hide ( ) ;
1665+ ipcRenderer . send ( 'getLibReleases' , { ofPath : $ ( "#ofPath" ) . val ( ) , refresh : ! ! refresh } ) ;
1666+ }
1667+
1668+ function formatSize ( bytes ) {
1669+ return bytes >= 1048576 ? ( bytes / 1048576 ) . toFixed ( 1 ) + ' MB' : Math . max ( 1 , Math . round ( bytes / 1024 ) ) + ' KB' ;
1670+ }
1671+
1672+ function releaseLabel ( r ) {
1673+ const date = r . published ? ' (' + r . published . slice ( 0 , 10 ) + ')' : '' ;
1674+ return r . tag + date + ( r . prerelease ? ' - ' + t ( 'downloads.prerelease' ) : '' ) ;
1675+ }
1676+
1677+ function fillDropdown ( selector , values , selected , labelFor ) {
1678+ const menu = $ ( selector + ' .menu' ) ;
1679+ menu . empty ( ) ;
1680+ for ( const v of values ) {
1681+ menu . append ( $ ( '<div class="item">' ) . attr ( 'data-value' , v ) . text ( labelFor ? labelFor ( v ) : v ) ) ;
1682+ }
1683+ $ ( selector ) . dropdown ( 'refresh' ) ;
1684+ if ( selected != null && values . includes ( selected ) ) {
1685+ $ ( selector ) . dropdown ( 'set selected' , selected ) ;
1686+ }
1687+ }
1688+
1689+ ipcRenderer . on ( 'libReleases' , ( event , data ) => {
1690+ $ ( '#refreshLibReleasesButton' ) . removeClass ( 'loading disabled' ) ;
1691+ if ( data . error ) {
1692+ $ ( '#libReleasesError' ) . text ( t ( 'downloads.releasesError' , { error : data . error } ) ) . show ( ) ;
1693+ return ;
1694+ }
1695+ const previous = libReleases ;
1696+ libReleases = data ;
1697+
1698+ const byTag = { } ;
1699+ for ( const r of data . releases ) byTag [ r . tag ] = r ;
1700+ const modularTags = data . releases . filter ( ( r ) => r . modular . length ) . map ( ( r ) => r . tag ) ;
1701+ const keep = ( sel , fallback , list ) => {
1702+ const cur = previous ? $ ( sel ) . dropdown ( 'get value' ) : '' ;
1703+ return list . includes ( cur ) ? cur : fallback ;
1704+ } ;
1705+
1706+ data . sources . apothecary = { releases : data . releases . filter ( ( r ) => r . hasCore ) , platforms : data . corePlatforms } ;
1707+ fillCoreSource ( previous ) ;
1708+ fillDropdown ( '#modularReleaseDropdown' , modularTags , keep ( '#modularReleaseDropdown' , 'latest-modular' , modularTags ) , ( tag ) => releaseLabel ( byTag [ tag ] ) ) ;
1709+ fillModularTargets ( ) ;
1710+ } ) ;
1711+
1712+ function coreSource ( ) {
1713+ return $ ( '#coreSourceDropdown' ) . dropdown ( 'get value' ) || 'apothecary' ;
1714+ }
1715+
1716+ function fillCoreSource ( keepSelection ) {
1717+ if ( ! libReleases ) return ;
1718+ const source = coreSource ( ) ;
1719+ const { releases, platforms, error } = libReleases . sources [ source ] ;
1720+ const tags = releases . map ( ( r ) => r . tag ) ;
1721+ const byTag = { } ;
1722+ for ( const r of releases ) byTag [ r . tag ] = r ;
1723+ const sorted = sortCorePlatforms ( platforms ) ;
1724+ const pick = ( sel , fallback , list ) => {
1725+ const cur = keepSelection ? $ ( sel ) . dropdown ( 'get value' ) : '' ;
1726+ return list . includes ( cur ) ? cur : ( list . includes ( fallback ) ? fallback : list [ 0 ] ) ;
1727+ } ;
1728+ $ ( '#coreReleaseDropdown' ) . dropdown ( 'clear' ) ;
1729+ fillDropdown ( '#coreReleaseDropdown' , tags , pick ( '#coreReleaseDropdown' , 'latest' , tags ) , ( tag ) => releaseLabel ( byTag [ tag ] ) ) ;
1730+ $ ( '#corePlatformDropdown' ) . dropdown ( 'clear' ) ;
1731+ fillDropdown ( '#corePlatformDropdown' , sorted , pick ( '#corePlatformDropdown' , libReleases . hostPlatform , sorted ) , corePlatformLabel ) ;
1732+ const note = error ? t ( 'downloads.releasesError' , { error } ) : t ( 'downloads.sourceNote.' + source ) ;
1733+ $ ( '#coreSourceNote' ) . text ( note ) ;
1734+ }
1735+
1736+ function currentModularRelease ( ) {
1737+ const tag = $ ( '#modularReleaseDropdown' ) . dropdown ( 'get value' ) ;
1738+ return libReleases && libReleases . releases . find ( ( r ) => r . tag === tag ) ;
1739+ }
1740+
1741+ // scripts/<platform>/download_libs.sh folder -> readable name, in dropdown order
1742+ const CORE_PLATFORM_LABELS = {
1743+ osx : 'macOS (OSX only)' ,
1744+ macos : 'macOS (including iOS, tvOS, catOS)' ,
1745+ ios : 'iOS' ,
1746+ tvos : 'tvOS' ,
1747+ vs : 'Windows (Visual Studio)' ,
1748+ msys2 : 'Windows (MSYS2)' ,
1749+ linux : 'Linux' ,
1750+ linux64 : 'Linux (x86_64)' ,
1751+ linuxaarch64 : 'Linux (arm64)' ,
1752+ linuxarmv6l : 'Linux (armv6l)' ,
1753+ linuxarmv7l : 'Linux (armv7l)' ,
1754+ android : 'Android' ,
1755+ emscripten : 'Emscripten (Web)' ,
1756+ } ;
1757+
1758+ function corePlatformLabel ( platform ) {
1759+ return CORE_PLATFORM_LABELS [ platform ] || platform ;
1760+ }
1761+
1762+ function sortCorePlatforms ( platforms ) {
1763+ const order = Object . keys ( CORE_PLATFORM_LABELS ) ;
1764+ const rank = ( p ) => ( order . includes ( p ) ? order . indexOf ( p ) : order . length ) ;
1765+ return [ ...platforms ] . sort ( ( a , b ) => rank ( a ) - rank ( b ) || a . localeCompare ( b ) ) ;
1766+ }
1767+
1768+ // osx_64 is one universal xcframework, so both archs share an entry
1769+ function modularTargetLabel ( target ) {
1770+ const named = {
1771+ osx_64 : 'macOS (OSX) (x86_64 / arm64)' ,
1772+ ios_64 : 'iOS (arm64)' ,
1773+ vs_64 : 'Windows (x64)' ,
1774+ vs_arm64 : 'Windows (arm64)' ,
1775+ vs_arm64ec : 'Windows (arm64ec)' ,
1776+ emscripten_64 : 'Emscripten (wasm64)' ,
1777+ emscripten_32 : 'Emscripten (wasm32)' ,
1778+ } ;
1779+ if ( named [ target ] ) return named [ target ] ;
1780+ const linux = / ^ l i n u x _ ( [ ^ _ ] + ) (?: _ ( g c c \d + ) ) ? $ / . exec ( target ) ;
1781+ if ( linux ) {
1782+ const arch = { '64' : 'x86_64' , aarch64 : 'arm64' , arm64 : 'arm64' } [ linux [ 1 ] ] || linux [ 1 ] ;
1783+ return 'Linux (' + arch + ')' + ( linux [ 2 ] ? ' ' + linux [ 2 ] : '' ) ;
1784+ }
1785+ return target ;
1786+ }
1787+
1788+ // which installedPlatforms() name a package target fills - matches LIB_DIR_PLATFORMS in index.js
1789+ function modularTargetPlatform ( target ) {
1790+ if ( target . startsWith ( 'osx' ) ) return 'macOS' ;
1791+ if ( target . startsWith ( 'ios' ) ) return 'iOS' ;
1792+ if ( target . startsWith ( 'tvos' ) ) return 'tvOS' ;
1793+ if ( target . startsWith ( 'emscripten' ) ) return 'Emscripten' ;
1794+ if ( target . startsWith ( 'vs' ) ) return 'Windows' ;
1795+ const linux = / ^ l i n u x _ ( [ ^ _ ] + ) / . exec ( target ) ;
1796+ if ( linux ) return { '64' : 'Linux' , aarch64 : 'Linux arm64' , arm64 : 'Linux arm64' } [ linux [ 1 ] ] || 'Linux ' + linux [ 1 ] ;
1797+ return target ;
1798+ }
1799+
1800+ function fillModularTargets ( ) {
1801+ const release = currentModularRelease ( ) ;
1802+ const targets = release ? [ ...new Set ( release . modular . map ( ( l ) => l . target ) ) ] . sort ( ) : [ ] ;
1803+ const current = $ ( '#modularTargetDropdown' ) . dropdown ( 'get value' ) ;
1804+ const host = libReleases ? libReleases . hostModularTarget : '' ;
1805+ const selected = targets . includes ( current ) ? current : ( targets . includes ( host ) ? host : targets [ 0 ] ) ;
1806+ fillDropdown ( '#modularTargetDropdown' , targets , selected , modularTargetLabel ) ;
1807+ renderModularLibs ( ) ;
1808+ }
1809+
1810+ function renderModularLibs ( ) {
1811+ const release = currentModularRelease ( ) ;
1812+ const target = $ ( '#modularTargetDropdown' ) . dropdown ( 'get value' ) ;
1813+ const libs = release ? release . modular . filter ( ( l ) => l . target === target ) : [ ] ;
1814+ libs . sort ( ( a , b ) => a . lib . toLowerCase ( ) . localeCompare ( b . lib . toLowerCase ( ) ) ) ;
1815+
1816+ const names = new Set ( libs . map ( ( l ) => l . asset ) ) ;
1817+ modularSelection = new Set ( [ ...modularSelection ] . filter ( ( n ) => names . has ( n ) ) ) ;
1818+
1819+ const body = $ ( '#modularLibTable tbody' ) ;
1820+ body . empty ( ) ;
1821+ if ( ! libs . length ) {
1822+ body . append ( $ ( '<tr>' ) . append ( $ ( '<td colspan="5">' ) . text ( release ? t ( 'downloads.noneForTarget' ) : t ( 'downloads.loading' ) ) ) ) ;
1823+ }
1824+ for ( const l of libs ) {
1825+ const checkbox = $ ( '<input type="checkbox">' ) . prop ( 'checked' , modularSelection . has ( l . asset ) ) . on ( 'change' , function ( ) {
1826+ if ( this . checked ) modularSelection . add ( l . asset ) ; else modularSelection . delete ( l . asset ) ;
1827+ updateModularButton ( ) ;
1828+ } ) ;
1829+ const current = modularTargetPlatform ( target ) ;
1830+ const status = l . platforms . length
1831+ ? l . platforms . map ( ( p ) => $ ( '<span class="ui tiny label">' ) . toggleClass ( 'green' , p === current ) . text ( p ) )
1832+ : $ ( '<span class="ui tiny basic label">' ) . text ( t ( 'downloads.notInstalled' ) ) ;
1833+ body . append ( $ ( '<tr>' ) . append (
1834+ $ ( '<td>' ) . append ( $ ( '<div class="ui fitted checkbox">' ) . append ( checkbox , $ ( '<label>' ) ) ) ,
1835+ $ ( '<td>' ) . append ( $ ( '<strong>' ) . text ( l . lib ) ) ,
1836+ $ ( '<td class="monospace">' ) . text ( l . installTo ) ,
1837+ $ ( '<td style="white-space: nowrap">' ) . text ( formatSize ( l . size ) + ( l . verifiable ? ' ✓' : '' ) ) . attr ( 'title' , l . verifiable ? 'SHA-256' : '' ) ,
1838+ $ ( '<td>' ) . append ( status ) ,
1839+ ) ) ;
1840+ }
1841+ $ ( '#modularSelectAll' ) . prop ( 'checked' , libs . length > 0 && modularSelection . size === libs . length ) ;
1842+ updateModularButton ( ) ;
1843+ }
1844+
1845+ function updateModularButton ( ) {
1846+ $ ( '#downloadModularLibsButton' )
1847+ . text ( t ( 'button.downloadSelected' , { count : modularSelection . size } ) )
1848+ . toggleClass ( 'disabled' , modularSelection . size === 0 ) ;
1849+ }
1850+
1851+ function downloadCoreLibs ( ) {
1852+ const source = coreSource ( ) ;
1853+ const tag = $ ( '#coreReleaseDropdown' ) . dropdown ( 'get value' ) ;
1854+ const platform = $ ( '#corePlatformDropdown' ) . dropdown ( 'get value' ) ;
1855+ if ( ! tag || ! platform ) return ;
1856+ if ( source === 'archive' && ! confirm ( t ( 'downloads.archiveConfirm' , { tag } ) ) ) return ;
1857+ $ ( '#downloadCoreLibsButton' ) . addClass ( 'loading disabled' ) ;
1858+ openConsoleForOperation ( ) ;
1859+ ipcRenderer . send ( 'downloadCoreLibs' , { ofPath : $ ( "#ofPath" ) . val ( ) , source, tag, platform } ) ;
1860+ }
1861+
1862+ ipcRenderer . on ( 'downloadCoreLibsDone' , ( ) => {
1863+ $ ( '#downloadCoreLibsButton' ) . removeClass ( 'loading disabled' ) ;
1864+ loadLibReleases ( false ) ;
1865+ } ) ;
1866+
1867+ function downloadModularLibs ( ) {
1868+ const release = currentModularRelease ( ) ;
1869+ if ( ! release || modularSelection . size === 0 ) return ;
1870+ $ ( '#downloadModularLibsButton' ) . addClass ( 'loading disabled' ) ;
1871+ openConsoleForOperation ( ) ;
1872+ ipcRenderer . send ( 'downloadModularLibs' , { ofPath : $ ( "#ofPath" ) . val ( ) , tag : release . tag , names : [ ...modularSelection ] } ) ;
1873+ }
1874+
1875+ ipcRenderer . on ( 'downloadModularLibsDone' , ( ) => {
1876+ $ ( '#downloadModularLibsButton' ) . removeClass ( 'loading' ) ;
1877+ modularSelection . clear ( ) ;
1878+ loadLibReleases ( false ) ;
16281879} ) ;
16291880
16301881function getOFVersion ( ) {
0 commit comments