Skip to content

Commit 0c292c0

Browse files
committed
Adjust window.versions to include virtual packages
1 parent 94f215a commit 0c292c0

1 file changed

Lines changed: 13 additions & 10 deletions

File tree

packages/runtime/src/fixes/ccloader2-polyfill.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,18 +76,21 @@ Object.assign(window, {
7676
simplify,
7777
Plugin,
7878
semver,
79-
80-
versions: Array.from(modloader.installedMods.values()).reduce<Record<string, string>>(
81-
(acc, mod) => {
79+
versions: [
80+
...Array.from(modloader.installedMods.values()).flatMap((mod) => {
8281
if (!mod.version) {
83-
console.debug('Mod without a version detected in construction of window.versions');
84-
return acc;
82+
console.debug(
83+
`${mod.id} was found to have no version defined during construction of window.versions`,
84+
);
85+
return [];
8586
}
86-
acc[mod.id] = mod.version.toString();
87-
return acc;
88-
},
89-
{},
90-
),
87+
return [[mod.id, mod.version.toString()] as const];
88+
}),
89+
...Array.from(modloader.virtualPackages).map(([id, ver]) => [id, ver.toString()] as const),
90+
].reduce<Record<string, string>>((acc, [id, ver]) => {
91+
acc[id] = ver;
92+
return acc;
93+
}, {}),
9194
activeMods: [...modloader.loadedMods.values()],
9295
inactiveMods: [...modloader.installedMods.values()].filter(
9396
(mod) => !modloader.modDataStorage.isModEnabled(mod.id),

0 commit comments

Comments
 (0)