-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.js
37 lines (33 loc) · 1.12 KB
/
main.js
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
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
import {dotnet} from './_framework/dotnet.js'
// Temporary fix until https://github.com/dotnet/runtime/issues/91528 is resovled
globalThis.window = globalThis;
let dotnetRuntimePromise = undefined;
let exports = undefined;
async function createRuntime() {
try {
return dotnet
.withDiagnosticTracing(false)
.withModuleConfig({
locateFile: (path, prefix) => {
return '/' + path;
}
})
.create();
} catch (err) {
console.error(err);
throw err;
}
}
export async function initializeRuntimeExports(){
if (!dotnetRuntimePromise) {
dotnetRuntimePromise = createRuntime();
const { getAssemblyExports, getConfig } = await dotnetRuntimePromise;
const config = getConfig();
exports = await getAssemblyExports(config.mainAssemblyName)
}
}
export async function nativeCompress(data) {
return exports.Compressy.Compressor.GzipCompress(data);
}