@basthon/console-react 0.1.3 → 0.2.1

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.
@@ -1,5 +1,5 @@
1
1
  import { FC, PropsWithChildren } from "react";
2
- import { type BasthonContextProps } from "../hooks/basthon";
2
+ import { type BasthonContextProps } from "@basthon/gui-react";
3
3
  import { type Theme } from "../state-manager";
4
4
  interface InnerAppProps {
5
5
  forceTheme?: Theme;
@@ -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 "../hooks/basthon";
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
@@ -1,3 +1,3 @@
1
- import { useGUI as useGUIBase } from "./basthon";
1
+ import { useGUI as useGUIBase } from "@basthon/gui-react";
2
2
  const useGUI = () => useGUIBase();
3
3
  export { useGUI };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@basthon/console-react",
3
- "version": "0.1.3",
3
+ "version": "0.2.1",
4
4
  "description": "Basthon - Console React Component",
5
5
  "homepage": "https://basthon.fr",
6
6
  "bugs": {
@@ -52,7 +52,7 @@
52
52
  "clean": "rimraf lib/"
53
53
  },
54
54
  "dependencies": {
55
- "@basthon/gui-base": "0.72.8",
55
+ "@basthon/gui-react": "0.73.1",
56
56
  "@fontsource/open-sans": "^5.1.0",
57
57
  "@fortawesome/fontawesome-svg-core": "^6.7.1",
58
58
  "@fortawesome/free-regular-svg-icons": "^6.7.1",
@@ -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 };
@@ -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 };