@jupyterlite/xeus 3.0.2 → 3.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/worker.js CHANGED
@@ -2,7 +2,7 @@
2
2
  // Copyright (c) JupyterLite Contributors
3
3
  // Distributed under the terms of the Modified BSD License.
4
4
  import { URLExt } from '@jupyterlab/coreutils';
5
- import { bootstrapFromEmpackPackedEnvironment } from '@emscripten-forge/mambajs';
5
+ import { bootstrapEmpackPackedEnvironment, bootstrapPython, getPythonVersion, loadShareLibs, waitRunDependencies } from '@emscripten-forge/mambajs';
6
6
  globalThis.Module = {};
7
7
  // when a toplevel cell uses an await, the cell is implicitly
8
8
  // wrapped in a async function. Since the webloop - eventloop
@@ -24,22 +24,15 @@ async function get_stdin() {
24
24
  });
25
25
  return replyPromise;
26
26
  }
27
- self.get_stdin = get_stdin;
28
- async function waitRunDependency() {
29
- const promise = new Promise(resolve => {
30
- globalThis.Module.monitorRunDependencies = (n) => {
31
- if (n === 0) {
32
- resolve();
33
- }
34
- };
35
- });
36
- // If there are no pending dependencies left, monitorRunDependencies will
37
- // never be called. Since we can't check the number of dependencies,
38
- // manually trigger a call.
39
- globalThis.Module.addRunDependency('dummy');
40
- globalThis.Module.removeRunDependency('dummy');
41
- return promise;
27
+ async function fetchJson(url) {
28
+ const response = await fetch(url);
29
+ if (!response.ok) {
30
+ throw new Error(`HTTP error! status: ${response.status}`);
31
+ }
32
+ const json = await response.json();
33
+ return json;
42
34
  }
35
+ self.get_stdin = get_stdin;
43
36
  globalThis.ready = new Promise(resolve => {
44
37
  kernelReady = resolve;
45
38
  });
@@ -109,17 +102,38 @@ export class XeusRemoteKernel {
109
102
  }
110
103
  });
111
104
  try {
112
- await waitRunDependency();
105
+ await waitRunDependencies(globalThis.Module);
113
106
  if (globalThis.Module.FS !== undefined &&
114
107
  globalThis.Module.loadDynamicLibrary !== undefined) {
115
108
  const empackEnvMetaLocation = empackEnvMetaLink || kernel_root_url;
116
- const verbose = true;
117
109
  const packagesJsonUrl = `${empackEnvMetaLocation}/empack_env_meta.json`;
118
110
  const pkgRootUrl = URLExt.join(baseUrl, 'xeus/kernel_packages');
119
- const bootstrapPython = kernelSpec.name === 'xpython';
120
- await bootstrapFromEmpackPackedEnvironment(packagesJsonUrl, verbose, false, globalThis.Module, pkgRootUrl, bootstrapPython);
111
+ const empackEnvMeta = (await fetchJson(packagesJsonUrl));
112
+ const sharedLibs = await bootstrapEmpackPackedEnvironment({
113
+ empackEnvMeta,
114
+ pkgRootUrl,
115
+ Module: globalThis.Module,
116
+ verbose: true
117
+ });
118
+ // Bootstrap Python, if it's xeus-python
119
+ if (kernelSpec.name === 'xpython') {
120
+ const pythonVersion = getPythonVersion(empackEnvMeta.packages);
121
+ if (!pythonVersion) {
122
+ throw new Error('Failed to load Python!');
123
+ }
124
+ await bootstrapPython({
125
+ prefix: empackEnvMeta.prefix,
126
+ pythonVersion: pythonVersion,
127
+ Module: globalThis.Module
128
+ });
129
+ }
130
+ // Load shared libs
131
+ await loadShareLibs({
132
+ sharedLibs,
133
+ prefix: empackEnvMeta.prefix,
134
+ Module: globalThis.Module
135
+ });
121
136
  }
122
- await waitRunDependency();
123
137
  rawXKernel = new globalThis.Module.xkernel();
124
138
  rawXServer = rawXKernel.get_server();
125
139
  if (!rawXServer) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jupyterlite/xeus",
3
- "version": "3.0.2",
3
+ "version": "3.0.3",
4
4
  "description": "JupyterLite Xeus kernels",
5
5
  "keywords": [
6
6
  "jupyter",
@@ -36,12 +36,12 @@
36
36
  "watch:src": "tsc -w --sourceMap"
37
37
  },
38
38
  "dependencies": {
39
- "@emscripten-forge/mambajs": "^0.2.2",
39
+ "@emscripten-forge/mambajs": "^0.3.1",
40
40
  "@jupyterlab/coreutils": "^6",
41
- "@jupyterlab/services": "~7.2.5",
42
- "@jupyterlite/contents": "^0.2.0 || ^0.3.0 || ^0.4.5",
43
- "@jupyterlite/kernel": "^0.2.0 || ^0.3.0 || ^0.4.5",
44
- "@jupyterlite/server": "^0.2.0 || ^0.3.0 || ^0.4.5",
41
+ "@jupyterlab/services": "^7.3.4",
42
+ "@jupyterlite/contents": "^0.2.0 || ^0.3.0 || ^0.4.5 || ^0.5.0",
43
+ "@jupyterlite/kernel": "^0.2.0 || ^0.3.0 || ^0.4.5 || ^0.5.0",
44
+ "@jupyterlite/server": "^0.2.0 || ^0.3.0 || ^0.4.5 || ^0.5.0",
45
45
  "@lumino/coreutils": "^2",
46
46
  "@lumino/signaling": "^2",
47
47
  "coincident": "^1.2.3",