Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | /**
* Application Runtime State
*
* Replaces global.currentSiteKey, global.currentWorkspaceKey, etc.
* Manages runtime state that is not persisted to disk.
*/
/**
* AppState manages runtime application state (non-persistent)
* This is state that changes during runtime but is not saved to config
*/
export class AppState {
/**
* Currently active site key
*/
currentSiteKey;
/**
* Currently active workspace key
*/
currentWorkspaceKey;
/**
* Current site path (mounted workspace path)
*/
currentSitePath;
/**
* Current Hugo server process (if running)
*/
currentServerProcess;
/**
* Whether a Hugo server is currently running
*/
isServerRunning;
/**
* Current Hugo server port
*/
serverPort;
/**
* Current build directory
*/
currentBuildDir;
/**
* Current base URL for the site
*/
currentBaseUrl;
/**
* Current form node path (for form state management)
*/
currentFormNodePath;
/**
* Current form accordion index (for form state management)
*/
currentFormAccordionIndex;
/**
* Path of form that should be reloaded
*/
currentFormShouldReload;
constructor() {
this.currentSiteKey = undefined;
this.currentWorkspaceKey = undefined;
this.currentSitePath = undefined;
this.currentServerProcess = undefined;
this.isServerRunning = false;
this.serverPort = undefined;
this.currentBuildDir = undefined;
this.currentBaseUrl = undefined;
this.currentFormNodePath = undefined;
this.currentFormAccordionIndex = undefined;
this.currentFormShouldReload = undefined;
}
/**
* Set the current site and workspace
*/
setCurrentSite(siteKey, workspaceKey, sitePath) {
this.currentSiteKey = siteKey;
this.currentWorkspaceKey = workspaceKey;
this.currentSitePath = sitePath;
}
/**
* Clear the current site
*/
clearCurrentSite() {
this.currentSiteKey = undefined;
this.currentWorkspaceKey = undefined;
this.currentSitePath = undefined;
}
/**
* Set the Hugo server process
*/
setServerProcess(process, port) {
this.currentServerProcess = process;
this.isServerRunning = true;
this.serverPort = port;
}
/**
* Clear the Hugo server process
*/
clearServerProcess() {
this.currentServerProcess = undefined;
this.isServerRunning = false;
this.serverPort = undefined;
}
/**
* Set the current build directory
*/
setBuildDir(dir) {
this.currentBuildDir = dir;
}
/**
* Get a snapshot of current state (for debugging)
*/
getSnapshot() {
return {
currentSiteKey: this.currentSiteKey,
currentWorkspaceKey: this.currentWorkspaceKey,
currentSitePath: this.currentSitePath,
isServerRunning: this.isServerRunning,
serverPort: this.serverPort,
currentBuildDir: this.currentBuildDir,
currentBaseUrl: this.currentBaseUrl,
currentFormNodePath: this.currentFormNodePath,
currentFormAccordionIndex: this.currentFormAccordionIndex,
currentFormShouldReload: this.currentFormShouldReload,
};
}
}
|