support newest emsdk version

This commit is contained in:
Arseny Smirnov 2022-01-25 15:59:50 +03:00
parent fa8feefed7
commit c485b77b5e
2 changed files with 8 additions and 4 deletions

View File

@ -6,7 +6,7 @@ You need a Unix shell with `sed`, `tar` and `wget` utilities to run the provided
## Building tdweb NPM package
* Install the 2.0.6 [emsdk](https://kripken.github.io/emscripten-site/docs/getting_started/downloads.html), which is known to work. Do not use the system-provided `emscripten` package, because it contains a too old emsdk version.
* Install the 3.1.1 [emsdk](https://kripken.github.io/emscripten-site/docs/getting_started/downloads.html), which is known to work. Do not use the system-provided `emscripten` package, because it contains a too old emsdk version.
* Install all `TDLib` build dependencies described in [Building](https://github.com/tdlib/td#building) and `sed`, `tar` and `wget` utilities.
* Run `source ./emsdk_env.sh` from `emsdk` directory to set up the correct build environment.
* On `macOS`, install the `coreutils` [Homebrew](https://brew.sh) package and replace `realpath` in scripts with `grealpath`:

View File

@ -73,6 +73,7 @@ async function loadTdlibWasm(onFS, wasmUrl) {
let module = createTdwebModule({
onRuntimeInitialized: () => {
log.info('runtime intialized');
onFS(module.FS);
},
instantiateWasm: (imports, successCallback) => {
log.info('start instantiateWasm', td_wasm, imports);
@ -85,7 +86,6 @@ async function loadTdlibWasm(onFS, wasmUrl) {
},
ENVIROMENT: 'WORKER'
});
onFS(module.FS); // hack
log.info('Wait module');
module = await module;
log.info('Got module', module);
@ -103,6 +103,7 @@ async function loadTdlibAsmjs(onFS) {
let module = createTdwebModule({
onRuntimeInitialized: () => {
console.log('runtime intialized');
onFS(module.FS);
},
locateFile: name => {
if (name === fromFile) {
@ -112,7 +113,6 @@ async function loadTdlibAsmjs(onFS) {
},
ENVIROMENT: 'WORKER'
});
onFS(module.FS); // hack
log.info('Wait module');
module = await module;
log.info('Got module', module);
@ -614,7 +614,11 @@ class TdClient {
this.TdModule = await loadTdlib(mode, this.onFS, options.wasmUrl);
log.info('got TdModule');
this.td_functions = {
td_create: this.TdModule.cwrap('td_emscripten_create_client_id', 'number', []),
td_create: this.TdModule.cwrap(
'td_emscripten_create_client_id',
'number',
[]
),
td_send: this.TdModule.cwrap('td_emscripten_send', null, [
'number',
'string'