surge refill

This commit is contained in:
Mateusz Gruszczyński
2026-05-31 23:09:24 +02:00
parent 91e91e7e47
commit 68d8ddc8d7
8 changed files with 217 additions and 198 deletions
+109 -175
View File
@@ -1,186 +1,120 @@
import { stateCoreSource } from './stateCore.js';
import { columnStateSource } from './columnState.js';
import { runtimeStateSource } from './runtimeState.js';
import { sharedUiSource } from './sharedUi.js';
import { torrentFilterHelpersSource } from './torrentFilterHelpers.js';
import { torrentFilterUiSource } from './torrentFilterUi.js';
import { torrentTrackerFiltersSource } from './torrentTrackerFilters.js';
import { torrentTableStateSource } from './torrentTableState.js';
import { torrentActionStateSource } from './torrentActionState.js';
import { torrentRowRendererSource } from './torrentRowRenderer.js';
import { torrentTableRendererSource } from './torrentTableRenderer.js';
import { mobileSource } from './mobile.js';
import { messagesSource } from './messages.js';
import { torrentAddSource } from './torrentAdd.js';
import { apiSource } from './api.js';
import { createTorrentSource } from './createTorrent.js';
import { torrentGeneralDetailsSource } from './torrentGeneralDetails.js';
import { torrentFileDetailsSource } from './torrentFileDetails.js';
import { torrentChunkDetailsSource } from './torrentChunkDetails.js';
import { torrentPeerDetailsSource } from './torrentPeerDetails.js';
import { torrentTrackerDetailsSource } from './torrentTrackerDetails.js';
import { mobileTorrentDetailsSource } from './mobileTorrentDetails.js';
import { torrentDetailsLoaderSource } from './torrentDetailsLoader.js';
import { pathPickerToolsSource } from './pathPickerTools.js';
import { columnManagerSource } from './columnManager.js';
import { jobToolsSource } from './jobTools.js';
import { labelToolsSource } from './labelTools.js';
import { ratioToolsSource } from './ratioTools.js';
import { rssToolsSource } from './rssTools.js';
import { backupToolsSource } from './backupTools.js';
import { smartQueueSource } from './smartQueue.js';
import { rtorrentConfigSource } from './rtorrentConfig.js';
import { appearancePreferencesSource } from './appearancePreferences.js';
import { peerRefreshSource } from './peerRefresh.js';
import { automationRulesSource } from './automationRules.js';
import { cleanupToolsSource } from './cleanupTools.js';
import { appDiagnosticsSource } from './appDiagnostics.js';
import { footerPreferencesSource } from './footerPreferences.js';
import { liveSpeedStatsSource } from './liveSpeedStats.js';
import { statusBarSource } from './statusBar.js';
import { preferencesToolsSource } from './preferencesTools.js';
import { diskMonitorSource } from './diskMonitor.js';
import { portCheckActionsSource } from './portCheckActions.js';
import { appStatusSource } from './appStatus.js';
import { torrentStatsSource } from './torrentStats.js';
import { toolUiHelpersSource } from './toolUiHelpers.js';
import { authUsersSource } from './authUsers.js';
import { plannerToolsUiSource } from './plannerToolsUi.js';
import { plannerSpeedControlsSource } from './plannerSpeedControls.js';
import { plannerSettingsSource } from './plannerSettings.js';
import { plannerPreviewHistorySource } from './plannerPreviewHistory.js';
import { plannerActionsSource } from './plannerActions.js';
import { smartViewsSource } from './smartViews.js';
import { notificationCenterSource } from './notificationCenter.js';
import { diagnosticsDashboardSource } from './diagnosticsDashboard.js';
import { dashboardToolsSource } from './dashboardTools.js';
import { operationLogsSource } from './operationLogs.js';
import { pollerSettingsSource } from './pollerSettings.js';
import { toolsModalSource } from './toolsModal.js';
import { toolPaneEventsSource } from './toolPaneEvents.js';
import { rssEventsSource } from './rssEvents.js';
import { smartQueueEventsSource } from './smartQueueEvents.js';
import { backupCleanupRtconfigEventsSource } from './backupCleanupRtconfigEvents.js';
import { automationEventsSource } from './automationEvents.js';
import { labelSmartEventsSource } from './labelSmartEvents.js';
import { torrentSelectionEventsSource } from './torrentSelectionEvents.js';
import { torrentTableEventsSource } from './torrentTableEvents.js';
import { preferenceEventsSource } from './preferenceEvents.js';
import { keyboardEventsSource } from './keyboardEvents.js';
import { speedLimitControlsSource } from './speedLimitControls.js';
import { themeMobileControlsSource } from './themeMobileControls.js';
import { jobSettingsSource } from './jobSettings.js';
import { profileListSource } from './profileList.js';
import { profileFormSource } from './profileForm.js';
import { profileActionsSource } from './profileActions.js';
import { profileSelectionSource } from './profileSelection.js';
import { realtimeChartsSource } from './realtimeCharts.js';
import { trafficHistoryDataSource } from './trafficHistoryData.js';
import { trafficChartRendererSource } from './trafficChartRenderer.js';
import { initialSnapshotSource } from './initialSnapshot.js';
import { footerStatusRefreshSource } from './footerStatusRefresh.js';
import { systemStatsSocketSource } from './systemStatsSocket.js';
import { mobileSelectEventsSource } from './mobileSelectEvents.js';
import { bootstrapRuntimeSource } from './bootstrapRuntime.js';
export const moduleSources = [
stateCoreSource,
columnStateSource,
runtimeStateSource,
sharedUiSource,
torrentFilterHelpersSource,
torrentFilterUiSource,
torrentTrackerFiltersSource,
torrentTableStateSource,
torrentActionStateSource,
torrentRowRendererSource,
torrentTableRendererSource,
mobileSource,
messagesSource,
torrentAddSource,
apiSource,
createTorrentSource,
torrentGeneralDetailsSource,
torrentFileDetailsSource,
torrentChunkDetailsSource,
torrentPeerDetailsSource,
torrentTrackerDetailsSource,
mobileTorrentDetailsSource,
torrentDetailsLoaderSource,
pathPickerToolsSource,
columnManagerSource,
jobToolsSource,
labelToolsSource,
ratioToolsSource,
rssToolsSource,
backupToolsSource,
smartQueueSource,
rtorrentConfigSource,
appearancePreferencesSource,
peerRefreshSource,
automationRulesSource,
cleanupToolsSource,
appDiagnosticsSource,
footerPreferencesSource,
liveSpeedStatsSource,
statusBarSource,
preferencesToolsSource,
diskMonitorSource,
portCheckActionsSource,
appStatusSource,
torrentStatsSource,
toolUiHelpersSource,
authUsersSource,
plannerToolsUiSource,
plannerSpeedControlsSource,
plannerSettingsSource,
plannerPreviewHistorySource,
plannerActionsSource,
smartViewsSource,
notificationCenterSource,
diagnosticsDashboardSource,
dashboardToolsSource,
operationLogsSource,
pollerSettingsSource,
toolsModalSource,
toolPaneEventsSource,
rssEventsSource,
smartQueueEventsSource,
backupCleanupRtconfigEventsSource,
automationEventsSource,
labelSmartEventsSource,
torrentSelectionEventsSource,
torrentTableEventsSource,
preferenceEventsSource,
keyboardEventsSource,
speedLimitControlsSource,
themeMobileControlsSource,
jobSettingsSource,
profileListSource,
profileFormSource,
profileActionsSource,
profileSelectionSource,
realtimeChartsSource,
trafficHistoryDataSource,
trafficChartRendererSource,
initialSnapshotSource,
footerStatusRefreshSource,
systemStatsSocketSource,
mobileSelectEventsSource,
bootstrapRuntimeSource,
const staticImportVersion = encodeURIComponent(String(window.PYTORRENT?.staticHash || 'dev'));
const versionedImport = (path) => import(`${path}?v=${staticImportVersion}`);
const moduleImportSpecs = [
['./stateCore.js', 'stateCoreSource'],
['./columnState.js', 'columnStateSource'],
['./runtimeState.js', 'runtimeStateSource'],
['./sharedUi.js', 'sharedUiSource'],
['./torrentFilterHelpers.js', 'torrentFilterHelpersSource'],
['./torrentFilterUi.js', 'torrentFilterUiSource'],
['./torrentTrackerFilters.js', 'torrentTrackerFiltersSource'],
['./torrentTableState.js', 'torrentTableStateSource'],
['./torrentActionState.js', 'torrentActionStateSource'],
['./torrentRowRenderer.js', 'torrentRowRendererSource'],
['./torrentTableRenderer.js', 'torrentTableRendererSource'],
['./mobile.js', 'mobileSource'],
['./messages.js', 'messagesSource'],
['./torrentAdd.js', 'torrentAddSource'],
['./api.js', 'apiSource'],
['./createTorrent.js', 'createTorrentSource'],
['./torrentGeneralDetails.js', 'torrentGeneralDetailsSource'],
['./torrentFileDetails.js', 'torrentFileDetailsSource'],
['./torrentChunkDetails.js', 'torrentChunkDetailsSource'],
['./torrentPeerDetails.js', 'torrentPeerDetailsSource'],
['./torrentTrackerDetails.js', 'torrentTrackerDetailsSource'],
['./mobileTorrentDetails.js', 'mobileTorrentDetailsSource'],
['./torrentDetailsLoader.js', 'torrentDetailsLoaderSource'],
['./pathPickerTools.js', 'pathPickerToolsSource'],
['./columnManager.js', 'columnManagerSource'],
['./jobTools.js', 'jobToolsSource'],
['./labelTools.js', 'labelToolsSource'],
['./ratioTools.js', 'ratioToolsSource'],
['./rssTools.js', 'rssToolsSource'],
['./backupTools.js', 'backupToolsSource'],
['./smartQueue.js', 'smartQueueSource'],
['./rtorrentConfig.js', 'rtorrentConfigSource'],
['./appearancePreferences.js', 'appearancePreferencesSource'],
['./peerRefresh.js', 'peerRefreshSource'],
['./automationRules.js', 'automationRulesSource'],
['./cleanupTools.js', 'cleanupToolsSource'],
['./appDiagnostics.js', 'appDiagnosticsSource'],
['./footerPreferences.js', 'footerPreferencesSource'],
['./liveSpeedStats.js', 'liveSpeedStatsSource'],
['./statusBar.js', 'statusBarSource'],
['./preferencesTools.js', 'preferencesToolsSource'],
['./diskMonitor.js', 'diskMonitorSource'],
['./portCheckActions.js', 'portCheckActionsSource'],
['./appStatus.js', 'appStatusSource'],
['./torrentStats.js', 'torrentStatsSource'],
['./toolUiHelpers.js', 'toolUiHelpersSource'],
['./authUsers.js', 'authUsersSource'],
['./plannerToolsUi.js', 'plannerToolsUiSource'],
['./plannerSpeedControls.js', 'plannerSpeedControlsSource'],
['./plannerSettings.js', 'plannerSettingsSource'],
['./plannerPreviewHistory.js', 'plannerPreviewHistorySource'],
['./plannerActions.js', 'plannerActionsSource'],
['./smartViews.js', 'smartViewsSource'],
['./notificationCenter.js', 'notificationCenterSource'],
['./diagnosticsDashboard.js', 'diagnosticsDashboardSource'],
['./dashboardTools.js', 'dashboardToolsSource'],
['./operationLogs.js', 'operationLogsSource'],
['./pollerSettings.js', 'pollerSettingsSource'],
['./toolsModal.js', 'toolsModalSource'],
['./toolPaneEvents.js', 'toolPaneEventsSource'],
['./rssEvents.js', 'rssEventsSource'],
['./smartQueueEvents.js', 'smartQueueEventsSource'],
['./backupCleanupRtconfigEvents.js', 'backupCleanupRtconfigEventsSource'],
['./automationEvents.js', 'automationEventsSource'],
['./labelSmartEvents.js', 'labelSmartEventsSource'],
['./torrentSelectionEvents.js', 'torrentSelectionEventsSource'],
['./torrentTableEvents.js', 'torrentTableEventsSource'],
['./preferenceEvents.js', 'preferenceEventsSource'],
['./keyboardEvents.js', 'keyboardEventsSource'],
['./speedLimitControls.js', 'speedLimitControlsSource'],
['./themeMobileControls.js', 'themeMobileControlsSource'],
['./jobSettings.js', 'jobSettingsSource'],
['./profileList.js', 'profileListSource'],
['./profileForm.js', 'profileFormSource'],
['./profileActions.js', 'profileActionsSource'],
['./profileSelection.js', 'profileSelectionSource'],
['./realtimeCharts.js', 'realtimeChartsSource'],
['./trafficHistoryData.js', 'trafficHistoryDataSource'],
['./trafficChartRenderer.js', 'trafficChartRendererSource'],
['./initialSnapshot.js', 'initialSnapshotSource'],
['./footerStatusRefresh.js', 'footerStatusRefreshSource'],
['./systemStatsSocket.js', 'systemStatsSocketSource'],
['./mobileSelectEvents.js', 'mobileSelectEventsSource'],
['./bootstrapRuntime.js', 'bootstrapRuntimeSource'],
];
export function buildRuntimeSource(){
return `(() => {\n${moduleSources.join('\n')}\n})();\n`;
export let moduleSources = [];
let moduleSourcesPromise = null;
async function loadModuleSources(){
if(moduleSourcesPromise) return moduleSourcesPromise;
moduleSourcesPromise = Promise.all(moduleImportSpecs.map(([path]) => versionedImport(path))).then((modules) => {
moduleSources = modules.map((mod, index) => mod[moduleImportSpecs[index][1]]);
return moduleSources;
});
return moduleSourcesPromise;
}
export function startApp(){
const runtimeSource = buildRuntimeSource();
export async function buildRuntimeSource(){
const sources = await loadModuleSources();
return `(() => {\n${sources.join('\n')}\n})();\n`;
}
export async function startApp(){
const runtimeSource = await buildRuntimeSource();
// Keep the original shared lexical scope while loading the source from smaller ES modules.
// `io` is passed explicitly so Socket.IO remains available inside the generated runtime.
return Function('io', runtimeSource)(window.io);
}
if(typeof window !== 'undefined' && !window.PYTORRENT_DISABLE_AUTOSTART){
startApp();
startApp().catch((error) => {
console.error('pyTorrent frontend failed to start', error);
const loaderText = document.getElementById('initialLoaderText');
if(loaderText) loaderText.textContent = 'Frontend failed to start. Reload the page or clear browser cache.';
});
}