Fix global declaration of staticRoot and webRoot

These variables were intended to be globals declare in the global
namespace. That this ends up on the window object is an implementation
detail of JavaScript. Remove the window. prefix put in front of
staticRoot and webRoot and include the global declaration in the
TypeScript module.
This commit is contained in:
Hornwitser committed 2023-11-28 15:35:40 +01:00
1 parent 9df6717364
commit ceb7e48c99
14 files changed
+27 -23

No files matched your search

+1 -1
View File
@@ -109,7 +109,7 @@ export default function App(props: AppProps) {
theme={{ algorithm: theme.darkAlgorithm }}
>
<ControlContext.Provider value={props.control}>
<BrowserRouter basename={window.webRoot}>
<BrowserRouter basename={webRoot}>
{page}
</BrowserRouter>
</ControlContext.Provider>
+1 -1
View File
@@ -25,7 +25,7 @@ function GenerateHostTokenButton() {
let [pluginList, setPluginList] = useState<lib.PluginWebApi[]>([]);
useEffect(() => {
(async () => {
let response = await fetch(`${window.webRoot}api/plugins`);
let response = await fetch(`${webRoot}api/plugins`);
if (response.ok) {
const plugins = await response.json();
setPluginList(plugins);
@@ -623,7 +623,7 @@ function useExportedAsset(modPack: lib.ModPack, asset: "settings"|"locale"): Map
return;
}
let response = await fetch(`${window.staticRoot}static/${assetFilename}`);
let response = await fetch(`${staticRoot}static/${assetFilename}`);
if (response.ok) {
let data = await response.json();
setAssetData(asset === "locale" ? new Map(data) : data);
+2 -2
View File
@@ -140,7 +140,7 @@ export default function ModsPage() {
control.send(
new lib.ModDownloadRequest(mod.name, mod.version)
).then((streamId: string) => {
let url = new URL(window.webRoot, document.location.origin);
let url = new URL(webRoot, document.location.origin);
url.pathname += `api/stream/${streamId}`;
document.location = url.href;
}).catch(
@@ -175,7 +175,7 @@ export default function ModsPage() {
headers={{
"X-Access-Token": control.connector.token||"",
}}
action={`${window.webRoot}api/upload-mod`}
action={`${webRoot}api/upload-mod`}
>
<Button icon={<UploadOutlined/>}>Upload</Button>
</Upload>;
@@ -16,7 +16,7 @@ export default function PluginViewPage() {
useEffect(() => {
(async () => {
let response = await fetch(`${window.webRoot}api/plugins`);
let response = await fetch(`${webRoot}api/plugins`);
if (response.ok) {
setPluginList(await response.json());
} else {
@@ -18,7 +18,7 @@ export default function PluginsPage() {
useEffect(() => {
(async () => {
let response = await fetch(`${window.webRoot}api/plugins`);
let response = await fetch(`${webRoot}api/plugins`);
if (response.ok) {
setPluginList(await response.json());
} else {
+2 -2
View File
@@ -268,7 +268,7 @@ export default function SavesList(props: { instance: InstanceState }) {
control.send(
new lib.InstanceDownloadSaveRequest(props.instance.id!, save.name)
).then(streamId => {
let url = new URL(window.webRoot, document.location.href);
let url = new URL(webRoot, document.location.href);
url.pathname += `api/stream/${streamId}`;
document.location.assign(url);
}).catch(
@@ -339,7 +339,7 @@ export default function SavesList(props: { instance: InstanceState }) {
instance_id: props.instance.id,
},
showUploadList: false,
action: `${window.webRoot}api/upload-save`,
action: `${webRoot}api/upload-save`,
onChange,
};