@basthon/kernel-python3 0.62.21 → 0.62.22

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/kernel.d.ts CHANGED
@@ -8,7 +8,7 @@ declare global {
8
8
  /**
9
9
  * A Python kernel that satisfies Basthon's API.
10
10
  */
11
- export declare class KernelPython3 extends KernelBase {
11
+ export declare class Python3Kernel extends KernelBase {
12
12
  /**
13
13
  * Where to find pyodide.js (private).
14
14
  */
@@ -30,7 +30,7 @@ export declare class KernelPython3 extends KernelBase {
30
30
  /**
31
31
  * Start the Basthon kernel asynchronously.
32
32
  */
33
- launch(): Promise<void>;
33
+ _init(): Promise<void>;
34
34
  /**
35
35
  * Execution count getter overload.
36
36
  */
@@ -40,9 +40,13 @@ export declare class KernelPython3 extends KernelBase {
40
40
  */
41
41
  evalAsync(code: string, outCallback: (_: string) => void, errCallback: (_: string) => void, data?: any): Promise<any>;
42
42
  /**
43
- * Restart the kernel.
43
+ * Start the kernel.
44
44
  */
45
- restart(): any;
45
+ _start(): Promise<void>;
46
+ /**
47
+ * Stop the kernel.
48
+ */
49
+ _stop(): Promise<void>;
46
50
  /**
47
51
  * Put a file on the local (emulated) filesystem.
48
52
  */
@@ -68,7 +72,7 @@ export declare class KernelPython3 extends KernelBase {
68
72
  * Is the source ready to be evaluated or want we more?
69
73
  * Usefull to set ps1/ps2 for teminal prompt.
70
74
  */
71
- more(source: string): any;
75
+ more(source: string): Promise<boolean>;
72
76
  /**
73
77
  * Mimic the CPython's REPL banner.
74
78
  */
@@ -79,7 +83,7 @@ export declare class KernelPython3 extends KernelBase {
79
83
  * Returns an array of two elements: the list of completions
80
84
  * and the start index.
81
85
  */
82
- complete(code: string): any;
86
+ complete(code: string): Promise<[string[], number] | []>;
83
87
  /**
84
88
  * Change current directory (Python's virtual FS).
85
89
  */
package/lib/kernel.js CHANGED
@@ -3,9 +3,8 @@ const PYODIDE_VERSION = "0.23.2";
3
3
  /**
4
4
  * A Python kernel that satisfies Basthon's API.
5
5
  */
6
- export class KernelPython3 extends KernelBase {
6
+ export class Python3Kernel extends KernelBase {
7
7
  constructor(options) {
8
- var _a;
9
8
  super(options);
10
9
  /**
11
10
  * Where to find pyodide.js (private).
@@ -17,7 +16,7 @@ export class KernelPython3 extends KernelBase {
17
16
  this.pythonVersion = "";
18
17
  // for locally installed Pyodide
19
18
  this._pyodideURLs.unshift(`${this.basthonRoot()}/pyodide/pyodide.js`);
20
- this._pyodideURLs = (_a = options === null || options === void 0 ? void 0 : options.pyodideURLs) !== null && _a !== void 0 ? _a : this._pyodideURLs;
19
+ this._pyodideURLs = options?.pyodideURLs ?? this._pyodideURLs;
21
20
  }
22
21
  /**
23
22
  * Get the URL of Basthon modules dir.
@@ -54,7 +53,8 @@ export class KernelPython3 extends KernelBase {
54
53
  /**
55
54
  * Start the Basthon kernel asynchronously.
56
55
  */
57
- async launch() {
56
+ async _init() {
57
+ await super._init();
58
58
  let pyodideURL = this._pyodideURLs[0];
59
59
  for (let url of this._pyodideURLs) {
60
60
  url = url.replace("{PYODIDE_VERSION}", PYODIDE_VERSION);
@@ -68,7 +68,7 @@ export class KernelPython3 extends KernelBase {
68
68
  catch (e) { }
69
69
  }
70
70
  try {
71
- await KernelPython3.loadScript(pyodideURL);
71
+ await Python3Kernel.loadScript(pyodideURL);
72
72
  }
73
73
  catch (error) {
74
74
  console.log(error);
@@ -125,10 +125,18 @@ export class KernelPython3 extends KernelBase {
125
125
  return res;
126
126
  }
127
127
  /**
128
- * Restart the kernel.
128
+ * Start the kernel.
129
129
  */
130
- restart() {
131
- return this.__kernel__.restart();
130
+ async _start() {
131
+ await super._start();
132
+ this.__kernel__.start();
133
+ }
134
+ /**
135
+ * Stop the kernel.
136
+ */
137
+ async _stop() {
138
+ this.__kernel__.stop();
139
+ await super._stop();
132
140
  }
133
141
  /**
134
142
  * Put a file on the local (emulated) filesystem.
@@ -170,7 +178,7 @@ export class KernelPython3 extends KernelBase {
170
178
  * Is the source ready to be evaluated or want we more?
171
179
  * Usefull to set ps1/ps2 for teminal prompt.
172
180
  */
173
- more(source) {
181
+ async more(source) {
174
182
  return this.__kernel__.more(source);
175
183
  }
176
184
  /**
@@ -189,7 +197,7 @@ export class KernelPython3 extends KernelBase {
189
197
  * Returns an array of two elements: the list of completions
190
198
  * and the start index.
191
199
  */
192
- complete(code) {
200
+ async complete(code) {
193
201
  const proxy = this.__kernel__.complete(code);
194
202
  if (!(proxy instanceof window.pyodide.ffi.PyProxy))
195
203
  return proxy;
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@basthon/kernel-python3",
3
- "version": "0.62.21",
3
+ "version": "0.62.22",
4
4
  "description": "Basthon - Python 3 Kernel",
5
5
  "homepage": "https://basthon.fr",
6
6
  "bugs": {
7
- "url": "https://framagit.org/basthon/basthon-kernel/issues"
7
+ "url": "https://forge.apps.education.fr/basthon/basthon-kernel/issues"
8
8
  },
9
9
  "repository": {
10
10
  "type": "git",
11
- "url": "https://framagit.org/basthon/basthon-kernel.git"
11
+ "url": "https://forge.apps.education.fr/basthon/basthon-kernel.git"
12
12
  },
13
13
  "license": "GPL-3.0-or-later",
14
14
  "author": "Romain Casati",
@@ -22,7 +22,7 @@
22
22
  ],
23
23
  "scripts": {
24
24
  "build": "run-s build:package build:archive build:modules build:lockfile",
25
- "build:package": "gulp all",
25
+ "build:package": "tsc",
26
26
  "build:archive": "mkdir -p lib/dist && cd src/ && tar --exclude '*__pycache__*' -cf ../lib/dist/basthon.tar basthon && cd -",
27
27
  "build:modules": "BASTHON_MODULES='lib/dist/modules' ; for d in $(find src/modules/ -mindepth 1 -maxdepth 1 -type d); do cd $d ; make build ; cd - ; done && mkdir -p $BASTHON_MODULES/extern && cp $(find src/modules/ -type f -name '*.whl') $BASTHON_MODULES && cp $(find src/modules/ -path '*/extern/*' -type f) $BASTHON_MODULES/extern",
28
28
  "build:lockfile": "python3 build-lockfile.py",
@@ -33,21 +33,16 @@
33
33
  "_prepublishOnly": "rm -rf lib/dist/pyodide/"
34
34
  },
35
35
  "dependencies": {
36
- "@basthon/kernel-base": "0.62.21"
36
+ "@basthon/kernel-base": "0.62.22"
37
37
  },
38
38
  "devDependencies": {
39
- "gulp": "^4.0.2",
40
- "gulp-concat": "^2.6.1",
41
- "gulp-cssmin": "^0.2.0",
42
- "gulp-less": "^5.0.0",
43
- "gulp-sourcemaps": "^3.0.0",
44
- "gulp-typescript": "^6.0.0-alpha.1",
45
- "gulp-uglify": "^3.0.2",
39
+ "clean-css-cli": "^5.6.3",
46
40
  "npm-run-all": "^4.1.5",
47
- "typescript": "~4.9.4"
41
+ "terser": "^5.30.3",
42
+ "typescript": "~5.4.5"
48
43
  },
49
44
  "publishConfig": {
50
45
  "access": "public"
51
46
  },
52
- "gitHead": "59343558e9ae17fbb08eda1e81a36b182e572d05"
47
+ "gitHead": "1dd6225a7caf14cbee203687cac611495f5b18d4"
53
48
  }