Newer
Older
import('../assets/jsutils/wasm_exec.js');
const xxdkWasm: URL = require('../assets/wasm/xxdk.wasm');
}
}
var xxdk_base_path: string = "";
export function setPath(newPath: string) {
xxdk_base_path = newPath;
export const loadWasm = () => new Promise<void>(async () => {
const xxdk_wasm_path = xxdk_base_path + xxdkWasm;
// if (typeof window == "undefined") {
const go = new window!.Go();
let isReady = new Promise((resolve) => {
window!.onWasmInitialized = resolve;
});
console.log(go);
console.log(xxdk_wasm_path);
console.log("IMPORT");
console.log(go.importObject);
let stream = await WebAssembly.instantiateStreaming(fetch(xxdk_wasm_path), go.importObject);
go.run(stream.instance);
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
export const loadUtils = () => new Promise<XXDKUtils>(async (res) => {
const {
Base64ToUint8Array,
Crash,
ConstructIdentity,
DecodePrivateURL,
DecodePublicURL,
GenerateChannelIdentity,
GetChannelInfo,
GetChannelJSON,
GetClientVersion,
getCrashedLogFile,
GetDefaultCMixParams,
GetLogger,
GetOrInitPassword,
GetPublicChannelIdentityFromPrivate,
GetShareUrlType,
GetVersion,
GetWasmSemanticVersion,
ImportPrivateIdentity,
IsNicknameValid,
LoadChannelsManagerWithIndexedDb,
LoadCmix,
LogLevel,
NewChannelsDatabaseCipher,
NewChannelsManagerWithIndexedDb,
NewCmix,
NewDMClientWithIndexedDb,
NewDMsDatabaseCipher,
NewDummyTrafficManager,
Purge,
ValidForever,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} = (window) || {};
res({
Base64ToUint8Array,
Crash,
ConstructIdentity,
DecodePrivateURL,
DecodePublicURL,
GenerateChannelIdentity,
GetChannelInfo,
GetChannelJSON,
GetClientVersion,
getCrashedLogFile,
GetDefaultCMixParams,
GetLogger,
GetOrInitPassword,
GetPublicChannelIdentityFromPrivate,
GetShareUrlType,
GetVersion,
GetWasmSemanticVersion,
ImportPrivateIdentity,
IsNicknameValid,
LoadChannelsManagerWithIndexedDb,
LoadCmix,
LogLevel,
NewChannelsDatabaseCipher,
NewChannelsManagerWithIndexedDb,
NewCmix,
NewDMClientWithIndexedDb,
NewDMsDatabaseCipher,
NewDummyTrafficManager,
Purge,
ValidForever,
})
})
export * from './types';