tdweb works with newest emsdk

GitOrigin-RevId: b52ab5d9e182e1a689933d7a44d3306f0c9151e5
This commit is contained in:
Arseny Smirnov 2020-10-08 14:02:53 +03:00
parent 958b16b8a3
commit 5926e00320
5 changed files with 893 additions and 1292 deletions

View File

@ -97,8 +97,10 @@ if (EMSCRIPTEN)
set(ZLIB_LIBRARIES)
set(ZLIB_INCLUDE_DIR)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s ALLOW_MEMORY_GROWTH=1 -s MEMFS_APPEND_TO_TYPED_ARRAYS=1 -s USE_ZLIB=1 -s MODULARIZE=1 -s WEBSOCKET_URL=\"'wss:#'\" -s EXTRA_EXPORTED_RUNTIME_METHODS=\"['FS','cwrap']\" -lidbfs.js -lworkerfs.js")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -s ALLOW_MEMORY_GROWTH=1 -s MEMFS_APPEND_TO_TYPED_ARRAYS=1 -s USE_ZLIB=1 -s MODULARIZE=1 -s WEBSOCKET_URL=\"'wss:#'\" -s EXTRA_EXPORTED_RUNTIME_METHODS=\"['FS','cwrap']\" -lidbfs.js -lworkerfs.js")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s ALLOW_MEMORY_GROWTH=1 -s MEMFS_APPEND_TO_TYPED_ARRAYS=1 -s USE_ZLIB=1 -s MODULARIZE=1 \
-s EXPORT_NAME=\"'createTdwebModule'\" -s WEBSOCKET_URL=\"'wss:#'\" -s EXTRA_EXPORTED_RUNTIME_METHODS=\"['FS','cwrap']\" -lidbfs.js -lworkerfs.js")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -s ALLOW_MEMORY_GROWTH=1 -s MEMFS_APPEND_TO_TYPED_ARRAYS=1 -s USE_ZLIB=1 -s \
MODULARIZE=1 -s EXPORT_NAME=\"'createTdwebModule'\" -s WEBSOCKET_URL=\"'wss:#'\" -s EXTRA_EXPORTED_RUNTIME_METHODS=\"['FS','cwrap']\" -lidbfs.js -lworkerfs.js")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -s DEMANGLE_SUPPORT=1 -s ASSERTIONS=1")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -s DEMANGLE_SUPPORT=1 -s ASSERTIONS=1")

File diff suppressed because it is too large Load Diff

View File

@ -26,7 +26,7 @@
"@babel/plugin-transform-runtime": "^7.4.3",
"@babel/preset-env": "^7.4.3",
"@typescript-eslint/eslint-plugin": "^1.7.0",
"acorn": "^6.1.1",
"acorn": "^6.4.1",
"babel-eslint": "^10.0.1",
"babel-loader": "^8.0.5",
"clean-webpack-plugin": "^2.0.1",
@ -43,8 +43,8 @@
"lint-staged": "^8.1.5",
"prettier": "^1.17.0",
"typescript": "^3.4.5",
"webpack": "4.28.2",
"webpack-cli": "^3.3.1",
"webpack": "^4.44.1",
"webpack-cli": "^3.3.12",
"worker-loader": "^2.0.0"
},
"husky": {

View File

@ -63,18 +63,19 @@ async function initLocalForage() {
async function loadTdlibWasm(onFS, wasmUrl) {
console.log('loadTdlibWasm');
const Module = await import('./prebuilt/release/td_wasm.js');
log.info('got td_wasm.js');
const td_module = await import('./prebuilt/release/td_wasm.js');
const createTdwebModule = td_module.default;
log.info('got td_wasm.js', td_module, createTdwebModule);
let td_wasm = td_wasm_release;
if (wasmUrl) {
td_wasm = wasmUrl;
}
const module = Module.default({
const module = await createTdwebModule({
onRuntimeInitialized: () => {
log.info('runtime intialized');
},
instantiateWasm: (imports, successCallback) => {
log.info('start instantiateWasm', td_wasm);
log.info('start instantiateWasm', td_wasm, imports);
const next = instance => {
log.info('finish instantiateWasm');
successCallback(instance);
@ -86,23 +87,17 @@ async function loadTdlibWasm(onFS, wasmUrl) {
});
log.info('Got module', module);
onFS(module.FS);
const TdModule = new Promise((resolve, reject) =>
module.then(m => {
delete m.then;
resolve(m);
})
);
return TdModule;
return module;
}
async function loadTdlibAsmjs(onFS) {
console.log('loadTdlibAsmjs');
const Module = await import('./prebuilt/release/td_asmjs.js');
console.log('got td_asm.js');
const createTdwebModule = (await import('./prebuilt/release/td_asmjs.js'))
.default;
console.log('got td_asm.js', createTdwebModule);
const fromFile = 'td_asmjs.js.mem';
const toFile = td_asmjs_mem_release;
const module = Module.default({
const module = await createTdwebModule({
onRuntimeInitialized: () => {
console.log('runtime intialized');
},
@ -115,14 +110,7 @@ async function loadTdlibAsmjs(onFS) {
ENVIROMENT: 'WORKER'
});
onFS(module.FS);
const TdModule = new Promise((resolve, reject) =>
module.then(m => {
delete m.then;
resolve(m);
})
);
return TdModule;
return module;
}
async function loadTdlib(mode, onFS, wasmUrl) {

View File

@ -133,6 +133,7 @@ class DelayedClosure {
do_clone(const DelayedClosure<FromActorT, FromFunctionT, FromArgsT...> &value) const {
static_assert(std::is_same<FromActorT, FromActorT>::value,
"Trying to clone DelayedClosure that contains noncopyable elements");
UNREACHABLE();
}
template <class FromActorT, class FromFunctionT, class... FromArgsT>