@basthon/console-react 0.1.2 → 0.2.0
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/README.md +6 -0
- package/lib/components/app.d.ts +1 -1
- package/lib/components/app.js +1 -1
- package/lib/hooks/gui.js +1 -1
- package/package.json +24 -4
- package/lib/hooks/basthon.d.ts +0 -16
- package/lib/hooks/basthon.js +0 -55
package/README.md
CHANGED
package/lib/components/app.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FC, PropsWithChildren } from "react";
|
|
2
|
-
import { type BasthonContextProps } from "
|
|
2
|
+
import { type BasthonContextProps } from "@basthon/gui-react";
|
|
3
3
|
import { type Theme } from "../state-manager";
|
|
4
4
|
interface InnerAppProps {
|
|
5
5
|
forceTheme?: Theme;
|
package/lib/components/app.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect } from "react";
|
|
3
|
-
import { BasthonContext } from "
|
|
3
|
+
import { BasthonContext } from "@basthon/gui-react";
|
|
4
4
|
import GUI from "../gui/gui";
|
|
5
5
|
import { useGUI } from "../hooks/gui";
|
|
6
6
|
import stateManager from "../state-manager";
|
package/lib/hooks/gui.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@basthon/console-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Basthon - Console React Component",
|
|
5
5
|
"homepage": "https://basthon.fr",
|
|
6
6
|
"bugs": {
|
|
@@ -20,6 +20,24 @@
|
|
|
20
20
|
"files": [
|
|
21
21
|
"lib"
|
|
22
22
|
],
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"types": "./lib/index.d.ts",
|
|
26
|
+
"default": "./lib/index.js"
|
|
27
|
+
},
|
|
28
|
+
"./components/*": {
|
|
29
|
+
"types": "./lib/components/*.d.ts",
|
|
30
|
+
"default": "./lib/components/*.js"
|
|
31
|
+
},
|
|
32
|
+
"./gui/*": {
|
|
33
|
+
"types": "./lib/gui/*.d.ts",
|
|
34
|
+
"default": "./lib/gui/*.js"
|
|
35
|
+
},
|
|
36
|
+
"./hooks/*": {
|
|
37
|
+
"types": "./lib/hooks/*.d.ts",
|
|
38
|
+
"default": "./lib/hooks/*.js"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
23
41
|
"devDependencies": {
|
|
24
42
|
"@types/react": "^18.0.30",
|
|
25
43
|
"@types/react-dom": "^18.0.11",
|
|
@@ -34,7 +52,7 @@
|
|
|
34
52
|
"clean": "rimraf lib/"
|
|
35
53
|
},
|
|
36
54
|
"dependencies": {
|
|
37
|
-
"@basthon/gui-
|
|
55
|
+
"@basthon/gui-react": "0.73.0",
|
|
38
56
|
"@fontsource/open-sans": "^5.1.0",
|
|
39
57
|
"@fortawesome/fontawesome-svg-core": "^6.7.1",
|
|
40
58
|
"@fortawesome/free-regular-svg-icons": "^6.7.1",
|
|
@@ -45,13 +63,15 @@
|
|
|
45
63
|
"jquery": "^3.6.4",
|
|
46
64
|
"jquery.terminal": "^2.44.1",
|
|
47
65
|
"notie": "^4.3.1",
|
|
48
|
-
"react": "^18.2.0",
|
|
49
66
|
"react-ace": "^13.0.0",
|
|
50
|
-
"react-dom": "^18.2.0",
|
|
51
67
|
"tty-browserify": "^0.0.1",
|
|
52
68
|
"use-immer": "^0.11.0",
|
|
53
69
|
"vm-browserify": "^1.1.2"
|
|
54
70
|
},
|
|
71
|
+
"peerDependencies": {
|
|
72
|
+
"react": "^18.2.0",
|
|
73
|
+
"react-dom": "^18.2.0"
|
|
74
|
+
},
|
|
55
75
|
"publishConfig": {
|
|
56
76
|
"access": "public"
|
|
57
77
|
}
|
package/lib/hooks/basthon.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { FC, PropsWithChildren } from "react";
|
|
2
|
-
import { GUIBase } from "@basthon/gui-base";
|
|
3
|
-
declare const useGUI: () => GUIBase;
|
|
4
|
-
interface BasthonContextProps {
|
|
5
|
-
GUI?: typeof GUIBase;
|
|
6
|
-
rootPath?: string;
|
|
7
|
-
kernel?: string;
|
|
8
|
-
pyodideURLs?: string[];
|
|
9
|
-
noCheckpointsInit?: boolean;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* This (pseudo) context is in charge of basthon
|
|
13
|
-
* kernel loading.
|
|
14
|
-
*/
|
|
15
|
-
declare const BasthonContext: FC<PropsWithChildren<BasthonContextProps>>;
|
|
16
|
-
export { BasthonContext, useGUI, type BasthonContextProps };
|
package/lib/hooks/basthon.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { createContext, useContext } from "react";
|
|
3
|
-
const GUIContext = createContext(null);
|
|
4
|
-
const useGUI = () => useContext(GUIContext);
|
|
5
|
-
let gui;
|
|
6
|
-
/**
|
|
7
|
-
* This (pseudo) context is in charge of basthon
|
|
8
|
-
* kernel loading.
|
|
9
|
-
*/
|
|
10
|
-
const BasthonContext = (props) => {
|
|
11
|
-
if (props.GUI == null)
|
|
12
|
-
throw Error("Basthon GUI class not set");
|
|
13
|
-
const rootPath = props.rootPath ?? "assets";
|
|
14
|
-
const pyodideURLs = props.pyodideURLs;
|
|
15
|
-
const noCheckpointsInit = props.noCheckpointsInit ?? false;
|
|
16
|
-
let kernel = props.kernel;
|
|
17
|
-
// set kernel
|
|
18
|
-
if (kernel == null) {
|
|
19
|
-
const url = new URL(window.location.href);
|
|
20
|
-
const params = url.searchParams;
|
|
21
|
-
kernel = params.get("kernel")?.toLowerCase() ?? "python3";
|
|
22
|
-
}
|
|
23
|
-
// set legacy
|
|
24
|
-
let legacy = false;
|
|
25
|
-
if (kernel.endsWith("-legacy")) {
|
|
26
|
-
kernel = kernel.slice(0, -"-legacy".length);
|
|
27
|
-
legacy = true;
|
|
28
|
-
}
|
|
29
|
-
// set language
|
|
30
|
-
kernel =
|
|
31
|
-
{
|
|
32
|
-
// shortcuts
|
|
33
|
-
py: "python3",
|
|
34
|
-
python: "python3",
|
|
35
|
-
"python3-old": "python3", // for backward compatibility
|
|
36
|
-
js: "javascript",
|
|
37
|
-
}[kernel] ?? kernel;
|
|
38
|
-
const language = kernel;
|
|
39
|
-
// transition phase: we force legacy mode for pyhton3 kernel
|
|
40
|
-
legacy = legacy === true || language === "python3";
|
|
41
|
-
if (gui == null) {
|
|
42
|
-
gui = new props.GUI({
|
|
43
|
-
kernelOptions: {
|
|
44
|
-
rootPath,
|
|
45
|
-
language,
|
|
46
|
-
legacy,
|
|
47
|
-
pyodideURLs,
|
|
48
|
-
},
|
|
49
|
-
noCheckpointsInit,
|
|
50
|
-
});
|
|
51
|
-
gui.init();
|
|
52
|
-
}
|
|
53
|
-
return (_jsx(GUIContext.Provider, { value: gui, children: props.children }));
|
|
54
|
-
};
|
|
55
|
-
export { BasthonContext, useGUI };
|