tdweb: temporary fix to access Module.FS before promise is completed
GitOrigin-RevId: 32af58ee1994919c75d50f8a2da2643a20bf166c
This commit is contained in:
parent
8fcf7740d2
commit
00049a842a
@ -113,6 +113,7 @@ if (EMSCRIPTEN)
|
|||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s WASM=1")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s WASM=1")
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -s WASM=1")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -s WASM=1")
|
||||||
endif()
|
endif()
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --post-js ${CMAKE_CURRENT_SOURCE_DIR}/post.js")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (NOT OPENSSL_FOUND)
|
if (NOT OPENSSL_FOUND)
|
||||||
|
@ -169,7 +169,7 @@ class TdClient {
|
|||||||
'receive from worker: ',
|
'receive from worker: ',
|
||||||
JSON.parse(
|
JSON.parse(
|
||||||
JSON.stringify(response, (key, value) => {
|
JSON.stringify(response, (key, value) => {
|
||||||
if (key === 'arr' || key == 'data') {
|
if (key === 'arr' || key === 'data') {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
@ -233,7 +233,12 @@ class TdClient {
|
|||||||
}
|
}
|
||||||
for (const key in response) {
|
for (const key in response) {
|
||||||
const field = response[key];
|
const field = response[key];
|
||||||
if (field && typeof field === 'object' && key != 'data' && key != 'arr') {
|
if (
|
||||||
|
field &&
|
||||||
|
typeof field === 'object' &&
|
||||||
|
key !== 'data' &&
|
||||||
|
key !== 'arr'
|
||||||
|
) {
|
||||||
response[key] = this.prepareResponse(field);
|
response[key] = this.prepareResponse(field);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ async function loadTdlibWasm(onFS, wasmUrl) {
|
|||||||
if (wasmUrl) {
|
if (wasmUrl) {
|
||||||
td_wasm = wasmUrl;
|
td_wasm = wasmUrl;
|
||||||
}
|
}
|
||||||
const module = await createTdwebModule({
|
let module = createTdwebModule({
|
||||||
onRuntimeInitialized: () => {
|
onRuntimeInitialized: () => {
|
||||||
log.info('runtime intialized');
|
log.info('runtime intialized');
|
||||||
},
|
},
|
||||||
@ -85,8 +85,11 @@ async function loadTdlibWasm(onFS, wasmUrl) {
|
|||||||
},
|
},
|
||||||
ENVIROMENT: 'WORKER'
|
ENVIROMENT: 'WORKER'
|
||||||
});
|
});
|
||||||
|
onFS(module.FS); // hack
|
||||||
|
log.info('Wait module');
|
||||||
|
module = await module;
|
||||||
log.info('Got module', module);
|
log.info('Got module', module);
|
||||||
onFS(module.FS);
|
//onFS(module.FS);
|
||||||
return module;
|
return module;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,7 +100,7 @@ async function loadTdlibAsmjs(onFS) {
|
|||||||
console.log('got td_asm.js', createTdwebModule);
|
console.log('got td_asm.js', createTdwebModule);
|
||||||
const fromFile = 'td_asmjs.js.mem';
|
const fromFile = 'td_asmjs.js.mem';
|
||||||
const toFile = td_asmjs_mem_release;
|
const toFile = td_asmjs_mem_release;
|
||||||
const module = await createTdwebModule({
|
let module = createTdwebModule({
|
||||||
onRuntimeInitialized: () => {
|
onRuntimeInitialized: () => {
|
||||||
console.log('runtime intialized');
|
console.log('runtime intialized');
|
||||||
},
|
},
|
||||||
@ -109,7 +112,11 @@ async function loadTdlibAsmjs(onFS) {
|
|||||||
},
|
},
|
||||||
ENVIROMENT: 'WORKER'
|
ENVIROMENT: 'WORKER'
|
||||||
});
|
});
|
||||||
onFS(module.FS);
|
onFS(module.FS); // hack
|
||||||
|
log.info('Wait module');
|
||||||
|
module = await module;
|
||||||
|
log.info('Got module', module);
|
||||||
|
//onFS(module.FS);
|
||||||
return module;
|
return module;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -608,7 +615,10 @@ class TdClient {
|
|||||||
log.info('got TdModule');
|
log.info('got TdModule');
|
||||||
this.td_functions = {
|
this.td_functions = {
|
||||||
td_create: this.TdModule.cwrap('td_emscripten_create', 'number', []),
|
td_create: this.TdModule.cwrap('td_emscripten_create', 'number', []),
|
||||||
td_send: this.TdModule.cwrap('td_emscripten_send', null, ['number', 'string']),
|
td_send: this.TdModule.cwrap('td_emscripten_send', null, [
|
||||||
|
'number',
|
||||||
|
'string'
|
||||||
|
]),
|
||||||
td_execute: this.TdModule.cwrap('td_emscripten_execute', 'string', [
|
td_execute: this.TdModule.cwrap('td_emscripten_execute', 'string', [
|
||||||
'string'
|
'string'
|
||||||
]),
|
]),
|
||||||
@ -621,7 +631,11 @@ class TdClient {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
td_get_timeout: this.TdModule.cwrap('td_emscripten_get_timeout', 'number', [])
|
td_get_timeout: this.TdModule.cwrap(
|
||||||
|
'td_emscripten_get_timeout',
|
||||||
|
'number',
|
||||||
|
[]
|
||||||
|
)
|
||||||
};
|
};
|
||||||
//this.onFS(this.TdModule.FS);
|
//this.onFS(this.TdModule.FS);
|
||||||
this.FS = this.TdModule.FS;
|
this.FS = this.TdModule.FS;
|
||||||
|
Loading…
Reference in New Issue
Block a user