From b13ef95d38d16b9dcc23490ee3361fff21cf41f2 Mon Sep 17 00:00:00 2001 From: Anastasiia Sliusar Date: Tue, 17 Dec 2024 14:27:36 +0100 Subject: [PATCH] Fix eslint, add condifition whethere loading sharing libs is available --- packages/xeus-extension/lab.webpack.config.js | 20 ++++---- packages/xeus/src/worker.ts | 48 +++++++++++-------- 2 files changed, 38 insertions(+), 30 deletions(-) diff --git a/packages/xeus-extension/lab.webpack.config.js b/packages/xeus-extension/lab.webpack.config.js index fa4e326..e64c35c 100644 --- a/packages/xeus-extension/lab.webpack.config.js +++ b/packages/xeus-extension/lab.webpack.config.js @@ -22,14 +22,14 @@ const staticPath = [ ]; module.exports = { - plugins: [ - new CopyPlugin({ - patterns: [ - { - from: path.resolve(...wasmPath), - to: path.join(...staticPath) - } - ] - }) - ] + plugins: [ + new CopyPlugin({ + patterns: [ + { + from: path.resolve(...wasmPath), + to: path.join(...staticPath) + } + ] + }) + ] }; diff --git a/packages/xeus/src/worker.ts b/packages/xeus/src/worker.ts index f90f37b..986b1f7 100644 --- a/packages/xeus/src/worker.ts +++ b/packages/xeus/src/worker.ts @@ -5,7 +5,10 @@ import { URLExt } from '@jupyterlab/coreutils'; import { IXeusWorkerKernel } from './interfaces'; -import { bootstrapFromEmpackPackedEnvironment, IPackagesInfo} from "@emscripten-forge/mambajs" +import { + bootstrapFromEmpackPackedEnvironment, + IPackagesInfo +} from '@emscripten-forge/mambajs'; globalThis.Module = {}; // when a toplevel cell uses an await, the cell is implicitly @@ -118,38 +121,43 @@ export class XeusRemoteKernel { }); try { await waitRunDependency(); - if (globalThis.Module.FS !== undefined) { - // each kernel can have a `async_init` function - // which can do kernel specific **async** initialization - // This function is usually implemented in the pre/post.js - // in the emscripten build of that kernel - - const kernel_root_url = empackEnvMetaLink + if ( + globalThis.Module.FS !== undefined && + globalThis.Module.loadDynamicLibrary !== undefined + ) { + // each kernel can have a `async_init` function + // which can do kernel specific **async** initialization + // This function is usually implemented in the pre/post.js + // in the emscripten build of that kernel + + const kernel_root_url = empackEnvMetaLink ? empackEnvMetaLink : URLExt.join(baseUrl, `xeus/kernels/${kernelSpec.dir}`); - const verbose = true; - - //if the kernel is not xeus-python than we have to avoid using pyjs - + const verbose = true; const packagesJsonUrl = `${kernel_root_url}/empack_env_meta.json`; const pkgRootUrl = URLExt.join(baseUrl, 'xeus/kernel_packages'); let packageData: IPackagesInfo = {}; - try{ - packageData = await bootstrapFromEmpackPackedEnvironment(packagesJsonUrl, verbose, false, globalThis.Module, pkgRootUrl); - } catch(error: any) { - + try { + packageData = await bootstrapFromEmpackPackedEnvironment( + packagesJsonUrl, + verbose, + false, + globalThis.Module, + pkgRootUrl + ); + } catch (error: any) { throw new Error(error.message); } if (kernelSpec.name === 'xpython') { - if (Object.keys(packageData).length) { - let {pythonVersion, prefix} = packageData; + if (Object.keys(packageData).length) { + const { pythonVersion, prefix } = packageData; if (pythonVersion) { globalThis.Module.init_phase_2(prefix, pythonVersion, verbose); } + } } - } - } + } await waitRunDependency();