|
1 | | -import { DotnetHostBuilder } from "./dotnetdefs"; |
| 1 | +import { DotnetHostBuilder, MonoConfig } from "./dotnetdefs"; |
2 | 2 | import { recursiveGetDirectory, rootFolder } from "../fs"; |
3 | 3 | import { SteamJS } from "../achievements"; |
4 | 4 | import { JsSplash } from "./loading"; |
@@ -85,18 +85,15 @@ useChange([gameState.playing, gameState.initting], () => { |
85 | 85 | }); |
86 | 86 |
|
87 | 87 | let nativefetch = window.fetch; |
88 | | -let wasm; |
| 88 | +let wasm: any; |
89 | 89 | let dotnet: DotnetHostBuilder; |
90 | 90 | let exports: any; |
91 | 91 |
|
92 | | -export async function getDlls(): Promise<(readonly [string, string])[]> { |
93 | | - const resources: any = await nativefetch("_framework/blazor.boot.json").then( |
94 | | - (r) => r.json() |
95 | | - ); |
96 | | - |
97 | | - return Object.entries(resources.resources.fingerprinting) |
98 | | - .map((x) => [x[0] as string, x[1] as string] as const) |
99 | | - .filter((x) => x[1].endsWith(".dll")); |
| 92 | +export function getDlls(): (readonly [string, string])[] { |
| 93 | + const config: MonoConfig = wasm.dotnet.instance.config; |
| 94 | + const resources = [...(config.resources?.coreAssembly || []), ...(config.resources?.assembly || [])]; |
| 95 | + return resources |
| 96 | + .map((x) => [x.name, x.virtualPath] as const) |
100 | 97 | } |
101 | 98 |
|
102 | 99 | // the funny custom rsa |
@@ -192,14 +189,17 @@ export const loadedLibcurlPromise = new Promise((r) => (libcurlresolver = r)); |
192 | 189 | export async function preInit() { |
193 | 190 | if (gameState.ready) return; |
194 | 191 |
|
195 | | - wasm = await eval(`import("../_framework/dotnet.js")`); |
| 192 | + let url = "../_framework/dotnet.js"; |
| 193 | + if (import.meta.env.DEV) { |
| 194 | + url = "/_framework/dotnet.js"; |
| 195 | + } |
| 196 | + |
| 197 | + wasm = await eval(`import("${url}")`); |
196 | 198 | dotnet = wasm.dotnet; |
197 | 199 |
|
198 | 200 | console.debug("initializing dotnet"); |
199 | 201 | const runtime = await dotnet |
200 | 202 | .withConfig({ |
201 | | - pthreadPoolInitialSize: 32, |
202 | | - pthreadPoolUnusedSize: 512, |
203 | 203 | }) |
204 | 204 | .withRuntimeOptions([ |
205 | 205 | // jit functions quickly and jit more functions |
@@ -317,7 +317,7 @@ export async function preInit() { |
317 | 317 | exports, |
318 | 318 | }; |
319 | 319 |
|
320 | | - const dlls = await getDlls(); |
| 320 | + const dlls = getDlls(); |
321 | 321 |
|
322 | 322 | const loc = location.pathname; |
323 | 323 |
|
|
0 commit comments