mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-18 15:33:12 +09:00
Make staticRoot include the static/ prefix and use it for plugin bundles
staticRoot was set to the same value as webRoot, so the static/ prefix
ended up scattered across consumers: index.html relied on the manifest
path containing it, the export stores hardcoded `${staticRoot}static/`,
and bootstrap loaded plugin bundles from webRoot instead. Now staticRoot
is `${webRoot}static/` and the controller strips the static/ prefix from
bundle paths before handing them to the page and to /api/plugins.
Plugins that fetch assets with `${staticRoot}static/...` need to drop the
static/ part.
Fixes #980
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
59cd193b65
commit
2f4e0c4418
8 files changed
+31
-7
No files matched your search
@@ -50,7 +50,7 @@ async function loadPluginInfos(): Promise<[lib.PluginWebpackEnvInfo[], string]>
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
await loadScript(`${webRoot}${meta.web.main}`);
|
||||
await loadScript(`${staticRoot}${meta.web.main}`);
|
||||
let container: any = (window as { [key: string]: any })[`plugin_${meta.name}`];
|
||||
if (!container) {
|
||||
throw new Error(`Plugin did not expose its container via plugin_${meta.name}`);
|
||||
|
||||
@@ -1102,7 +1102,7 @@ function useExportedAsset(modPack: lib.ModPack | undefined, asset: "settings"|"l
|
||||
return;
|
||||
}
|
||||
|
||||
let response = await fetch(`${staticRoot}static/${assetFilename}`);
|
||||
let response = await fetch(`${staticRoot}${assetFilename}`);
|
||||
if (response.ok) {
|
||||
let data = await response.json();
|
||||
setAssetData(asset === "locale" ? new Map(data) : data);
|
||||
|
||||
@@ -21,7 +21,7 @@ class ExportLocaleStore {
|
||||
return;
|
||||
}
|
||||
|
||||
let response = await fetch(`${staticRoot}static/${cacheEntry.localePath}`);
|
||||
let response = await fetch(`${staticRoot}${cacheEntry.localePath}`);
|
||||
if (response.ok) {
|
||||
cacheEntry.data = new Map(await response.json() as ExportLocale);
|
||||
for (const callback of cacheEntry.callbacks) {
|
||||
|
||||
@@ -26,7 +26,7 @@ class ExportPrototypeMetadataStore {
|
||||
return;
|
||||
}
|
||||
|
||||
const response = await fetch(`${staticRoot}static/${cacheEntry.metadataPath}`);
|
||||
const response = await fetch(`${staticRoot}${cacheEntry.metadataPath}`);
|
||||
if (!response.ok) {
|
||||
notify(
|
||||
`Failed to fetch prototype metadata for mod pack ${modPackId}, server returned: ` +
|
||||
@@ -43,7 +43,7 @@ class ExportPrototypeMetadataStore {
|
||||
|
||||
const metadata = await response.json() as ExportMetadata;
|
||||
|
||||
const spriteUrl = `${staticRoot}static/${cacheEntry.spritesheetPath}`;
|
||||
const spriteUrl = `${staticRoot}${cacheEntry.spritesheetPath}`;
|
||||
const styleContent: string[] = [];
|
||||
styleContent.push(`\
|
||||
.factorio-icon\
|
||||
|
||||
Reference in new issue
Block a user