@datalayer/jupyter-react 0.10.1 → 0.12.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.
Files changed (170) hide show
  1. package/lib/components/cell/Cell.d.ts +1 -1
  2. package/lib/components/cell/Cell.js +11 -17
  3. package/lib/components/cell/Cell.js.map +1 -1
  4. package/lib/components/cell/CellAdapter.js +1 -1
  5. package/lib/components/cell/CellAdapter.js.map +1 -1
  6. package/lib/components/cell/CellState.d.ts +18 -0
  7. package/lib/components/cell/CellState.js +23 -0
  8. package/lib/components/cell/CellState.js.map +1 -0
  9. package/lib/components/codemirror/CodeMirrorEditor.js +10 -11
  10. package/lib/components/codemirror/CodeMirrorEditor.js.map +1 -1
  11. package/lib/components/console/Console.js +3 -0
  12. package/lib/components/console/Console.js.map +1 -1
  13. package/lib/components/console/ConsoleState.d.ts +15 -0
  14. package/lib/components/console/ConsoleState.js +19 -0
  15. package/lib/components/console/ConsoleState.js.map +1 -0
  16. package/lib/components/jupyterlab/JupyterLabApp.d.ts +9 -13
  17. package/lib/components/jupyterlab/JupyterLabApp.js +11 -10
  18. package/lib/components/jupyterlab/JupyterLabApp.js.map +1 -1
  19. package/lib/components/jupyterlab/JupyterLabAppAdapter.js +20 -5
  20. package/lib/components/jupyterlab/JupyterLabAppAdapter.js.map +1 -1
  21. package/lib/components/jupyterlab/JupyterLabAppPlugins.js +5 -25
  22. package/lib/components/jupyterlab/JupyterLabAppPlugins.js.map +1 -1
  23. package/lib/components/notebook/Notebook.js +23 -28
  24. package/lib/components/notebook/Notebook.js.map +1 -1
  25. package/lib/components/notebook/NotebookAdapter.d.ts +2 -2
  26. package/lib/components/notebook/NotebookAdapter.js +7 -7
  27. package/lib/components/notebook/NotebookAdapter.js.map +1 -1
  28. package/lib/components/notebook/NotebookState.d.ts +102 -0
  29. package/lib/components/notebook/NotebookState.js +153 -0
  30. package/lib/components/notebook/NotebookState.js.map +1 -0
  31. package/lib/components/notebook/cell/sidebar/CellSidebar.js +19 -20
  32. package/lib/components/notebook/cell/sidebar/CellSidebar.js.map +1 -1
  33. package/lib/components/notebook/cell/sidebar/CellSidebarButton.js +17 -18
  34. package/lib/components/notebook/cell/sidebar/CellSidebarButton.js.map +1 -1
  35. package/lib/components/notebook/cell/sidebar/CellSidebarRun.js +4 -5
  36. package/lib/components/notebook/cell/sidebar/CellSidebarRun.js.map +1 -1
  37. package/lib/components/notebook/cell/sidebar/CellSidebarWidget.d.ts +1 -2
  38. package/lib/components/notebook/cell/sidebar/CellSidebarWidget.js +4 -4
  39. package/lib/components/notebook/cell/sidebar/CellSidebarWidget.js.map +1 -1
  40. package/lib/components/notebook/content/JupyterReactContentFactory.d.ts +1 -3
  41. package/lib/components/notebook/content/JupyterReactContentFactory.js +2 -4
  42. package/lib/components/notebook/content/JupyterReactContentFactory.js.map +1 -1
  43. package/lib/components/output/Output.js +8 -11
  44. package/lib/components/output/Output.js.map +1 -1
  45. package/lib/components/output/OutputAdapter.js +1 -1
  46. package/lib/components/output/OutputAdapter.js.map +1 -1
  47. package/lib/components/output/OutputState.d.ts +51 -0
  48. package/lib/components/output/OutputState.js +90 -0
  49. package/lib/components/output/OutputState.js.map +1 -0
  50. package/lib/components/terminal/Terminal.js +12 -12
  51. package/lib/components/terminal/Terminal.js.map +1 -1
  52. package/lib/components/terminal/TerminalState.d.ts +14 -0
  53. package/lib/components/terminal/TerminalState.js +18 -0
  54. package/lib/components/terminal/TerminalState.js.map +1 -0
  55. package/lib/examples/All.js +11 -13
  56. package/lib/examples/All.js.map +1 -1
  57. package/lib/examples/Cell.js +12 -2
  58. package/lib/examples/Cell.js.map +1 -1
  59. package/lib/examples/JupyterLabApp.js +11 -11
  60. package/lib/examples/JupyterLabApp.js.map +1 -1
  61. package/lib/examples/JupyterLabHeadlessApp.js +13 -11
  62. package/lib/examples/JupyterLabHeadlessApp.js.map +1 -1
  63. package/lib/examples/NotebookExternalContent.js +2 -2
  64. package/lib/examples/NotebookExternalContent.js.map +1 -1
  65. package/lib/examples/NotebookInit.js +7 -10
  66. package/lib/examples/NotebookInit.js.map +1 -1
  67. package/lib/examples/NotebookKernelChange.js +3 -4
  68. package/lib/examples/NotebookKernelChange.js.map +1 -1
  69. package/lib/examples/NotebookNbFormatChange.js +3 -9
  70. package/lib/examples/NotebookNbFormatChange.js.map +1 -1
  71. package/lib/examples/NotebookNoContext.js +20 -0
  72. package/lib/examples/NotebookNoContext.js.map +1 -0
  73. package/lib/examples/NotebookNoContextNoPrimer.d.ts +1 -0
  74. package/lib/examples/NotebookNoContextNoPrimer.js +18 -0
  75. package/lib/examples/NotebookNoContextNoPrimer.js.map +1 -0
  76. package/lib/examples/Output.js +22 -4
  77. package/lib/examples/Output.js.map +1 -1
  78. package/lib/examples/RunningSessions.js +7 -7
  79. package/lib/examples/RunningSessions.js.map +1 -1
  80. package/lib/examples/sidebars/CellSidebarSource.js +17 -18
  81. package/lib/examples/sidebars/CellSidebarSource.js.map +1 -1
  82. package/lib/examples/toolbars/NotebookToolbar.js +15 -16
  83. package/lib/examples/toolbars/NotebookToolbar.js.map +1 -1
  84. package/lib/examples/toolbars/NotebookToolbarAutoSave.js +13 -16
  85. package/lib/examples/toolbars/NotebookToolbarAutoSave.js.map +1 -1
  86. package/lib/examples/toolbars/NotebookToolbarStatus.js +3 -2
  87. package/lib/examples/toolbars/NotebookToolbarStatus.js.map +1 -1
  88. package/lib/index.d.ts +6 -12
  89. package/lib/index.js +6 -13
  90. package/lib/index.js.map +1 -1
  91. package/lib/jupyter/Jupyter.js +2 -6
  92. package/lib/jupyter/Jupyter.js.map +1 -1
  93. package/lib/jupyter/JupyterConfig.js +4 -4
  94. package/lib/jupyter/JupyterConfig.js.map +1 -1
  95. package/lib/jupyter/JupyterContext.d.ts +11 -8
  96. package/lib/jupyter/JupyterContext.js +36 -150
  97. package/lib/jupyter/JupyterContext.js.map +1 -1
  98. package/lib/jupyter/ipywidgets/classic/manager.js +27 -18
  99. package/lib/jupyter/ipywidgets/classic/manager.js.map +1 -1
  100. package/lib/jupyter/ipywidgets/lab/manager.js +23 -14
  101. package/lib/jupyter/ipywidgets/lab/manager.js.map +1 -1
  102. package/lib/jupyter/ipywidgets/libembed-amd.d.ts +21 -0
  103. package/lib/jupyter/ipywidgets/libembed-amd.js +102 -0
  104. package/lib/jupyter/ipywidgets/libembed-amd.js.map +1 -0
  105. package/lib/state/IState.d.ts +6 -0
  106. package/lib/{components/console/ConsoleZustand.js → state/IState.js} +2 -1
  107. package/lib/state/IState.js.map +1 -0
  108. package/lib/state/State.d.ts +30 -0
  109. package/lib/state/State.js +191 -0
  110. package/lib/state/State.js.map +1 -0
  111. package/lib/state/index.d.ts +2 -0
  112. package/lib/state/index.js +2 -0
  113. package/lib/state/index.js.map +1 -1
  114. package/package.json +17 -35
  115. package/lib/components/cell/CellRedux.d.ts +0 -22
  116. package/lib/components/cell/CellRedux.js +0 -62
  117. package/lib/components/cell/CellRedux.js.map +0 -1
  118. package/lib/components/cell/CellZustand.d.ts +0 -5
  119. package/lib/components/cell/CellZustand.js +0 -11
  120. package/lib/components/cell/CellZustand.js.map +0 -1
  121. package/lib/components/commands/CommandsState.d.ts +0 -15
  122. package/lib/components/commands/CommandsState.js +0 -37
  123. package/lib/components/commands/CommandsState.js.map +0 -1
  124. package/lib/components/console/ConsoleRedux.d.ts +0 -15
  125. package/lib/components/console/ConsoleRedux.js +0 -37
  126. package/lib/components/console/ConsoleRedux.js.map +0 -1
  127. package/lib/components/console/ConsoleZustand.d.ts +0 -0
  128. package/lib/components/console/ConsoleZustand.js.map +0 -1
  129. package/lib/components/filemanager/FileManagerState.d.ts +0 -15
  130. package/lib/components/filemanager/FileManagerState.js +0 -37
  131. package/lib/components/filemanager/FileManagerState.js.map +0 -1
  132. package/lib/components/notebook/NotebookRedux.d.ts +0 -122
  133. package/lib/components/notebook/NotebookRedux.js +0 -313
  134. package/lib/components/notebook/NotebookRedux.js.map +0 -1
  135. package/lib/components/notebook/NotebookZustand.d.ts +0 -0
  136. package/lib/components/notebook/NotebookZustand.js +0 -6
  137. package/lib/components/notebook/NotebookZustand.js.map +0 -1
  138. package/lib/components/output/OutputRedux.d.ts +0 -54
  139. package/lib/components/output/OutputRedux.js +0 -137
  140. package/lib/components/output/OutputRedux.js.map +0 -1
  141. package/lib/components/output/OutputZustand.d.ts +0 -5
  142. package/lib/components/output/OutputZustand.js +0 -11
  143. package/lib/components/output/OutputZustand.js.map +0 -1
  144. package/lib/components/settings/SettingsRedux.d.ts +0 -15
  145. package/lib/components/settings/SettingsRedux.js +0 -37
  146. package/lib/components/settings/SettingsRedux.js.map +0 -1
  147. package/lib/components/settings/SettingsZustand.d.ts +0 -0
  148. package/lib/components/settings/SettingsZustand.js +0 -6
  149. package/lib/components/settings/SettingsZustand.js.map +0 -1
  150. package/lib/components/terminal/TerminalRedux.d.ts +0 -15
  151. package/lib/components/terminal/TerminalRedux.js +0 -45
  152. package/lib/components/terminal/TerminalRedux.js.map +0 -1
  153. package/lib/components/terminal/TerminalZustand.d.ts +0 -0
  154. package/lib/components/terminal/TerminalZustand.js +0 -6
  155. package/lib/components/terminal/TerminalZustand.js.map +0 -1
  156. package/lib/examples/NotebookInjectableReduxStore.js +0 -37
  157. package/lib/examples/NotebookInjectableReduxStore.js.map +0 -1
  158. package/lib/examples/state/ExampleReduxState.d.ts +0 -12
  159. package/lib/examples/state/ExampleReduxState.js +0 -35
  160. package/lib/examples/state/ExampleReduxState.js.map +0 -1
  161. package/lib/state/redux/InitState.d.ts +0 -12
  162. package/lib/state/redux/InitState.js +0 -35
  163. package/lib/state/redux/InitState.js.map +0 -1
  164. package/lib/state/redux/State.d.ts +0 -15
  165. package/lib/state/redux/State.js +0 -40
  166. package/lib/state/redux/State.js.map +0 -1
  167. package/lib/state/redux/Store.d.ts +0 -13
  168. package/lib/state/redux/Store.js +0 -45
  169. package/lib/state/redux/Store.js.map +0 -1
  170. /package/lib/examples/{NotebookInjectableReduxStore.d.ts → NotebookNoContext.d.ts} +0 -0
@@ -0,0 +1,102 @@
1
+ /*
2
+ * Copyright (c) 2021-2023 Datalayer, Inc.
3
+ *
4
+ * MIT License
5
+ */
6
+ // Copyright (c) Jupyter Development Team.
7
+ // Distributed under the terms of the Modified BSD License.
8
+ import * as libembed from '@jupyter-widgets/html-manager/lib/libembed';
9
+ let cdn = 'https://cdn.jsdelivr.net/npm/';
10
+ let onlyCDN = true;
11
+ // find the data-cdn for any script tag, assuming it is only used for embed-amd.js
12
+ const scripts = document.getElementsByTagName('script');
13
+ Array.prototype.forEach.call(scripts, (script) => {
14
+ cdn = script.getAttribute('data-jupyter-widgets-cdn') || cdn;
15
+ onlyCDN = onlyCDN || script.hasAttribute('data-jupyter-widgets-cdn-only');
16
+ });
17
+ /**
18
+ * Load a package using requirejs and return a promise
19
+ *
20
+ * @param pkg Package name or names to load
21
+ */
22
+ const requirePromise = function (pkg) {
23
+ return new Promise((resolve, reject) => {
24
+ const require = window.requirejs;
25
+ if (require === undefined) {
26
+ reject('Requirejs is needed, please ensure it is loaded on the page.');
27
+ }
28
+ else {
29
+ require(pkg, resolve, reject);
30
+ }
31
+ });
32
+ };
33
+ function moduleNameToCDNUrl(moduleName, moduleVersion) {
34
+ let packageName = moduleName;
35
+ let fileName = 'index'; // default filename
36
+ // if a '/' is present, like 'foo/bar', packageName is changed to 'foo', and path to 'bar'
37
+ // We first find the first '/'
38
+ let index = moduleName.indexOf('/');
39
+ if (index != -1 && moduleName[0] == '@') {
40
+ // if we have a namespace, it's a different story
41
+ // @foo/bar/baz should translate to @foo/bar and baz
42
+ // so we find the 2nd '/'
43
+ index = moduleName.indexOf('/', index + 1);
44
+ }
45
+ if (index != -1) {
46
+ fileName = moduleName.substr(index + 1);
47
+ packageName = moduleName.substr(0, index);
48
+ }
49
+ return `${cdn}${packageName}@${moduleVersion}/dist/${fileName}`;
50
+ }
51
+ /**
52
+ * Load an amd module locally and fall back to specified CDN if unavailable.
53
+ *
54
+ * @param moduleName The name of the module to load..
55
+ * @param version The semver range for the module, if loaded from a CDN.
56
+ *
57
+ * By default, the CDN service used is jsDelivr. However, this default can be
58
+ * overridden by specifying another URL via the HTML attribute
59
+ * "data-jupyter-widgets-cdn" on a script tag of the page.
60
+ *
61
+ * The semver range is only used with the CDN.
62
+ */
63
+ export function requireLoader(moduleName, moduleVersion) {
64
+ const require = window.requirejs;
65
+ if (require === undefined) {
66
+ throw new Error('Requirejs is needed, please ensure it is loaded on the page.');
67
+ }
68
+ function loadFromCDN() {
69
+ const conf = { paths: {} };
70
+ conf.paths[moduleName] = moduleNameToCDNUrl(moduleName, moduleVersion);
71
+ require.config(conf);
72
+ return requirePromise([`${moduleName}`]);
73
+ }
74
+ if (onlyCDN) {
75
+ console.log(`Loading from ${cdn} for ${moduleName}@${moduleVersion}`);
76
+ return loadFromCDN();
77
+ }
78
+ return requirePromise([`${moduleName}`]).catch((err) => {
79
+ const failedId = err.requireModules && err.requireModules[0];
80
+ if (failedId) {
81
+ require.undef(failedId);
82
+ console.log(`Falling back to ${cdn} for ${moduleName}@${moduleVersion}`);
83
+ return loadFromCDN();
84
+ }
85
+ });
86
+ }
87
+ /**
88
+ * Render widgets in a given element.
89
+ *
90
+ * @param element (default document.documentElement) The element containing widget state and views.
91
+ * @param loader (default requireLoader) The function used to look up the modules containing
92
+ * the widgets' models and views classes. (The default loader looks them up on jsDelivr)
93
+ */
94
+ export function renderWidgets(element = document.documentElement, loader = requireLoader) {
95
+ requirePromise(['@jupyter-widgets/html-manager']).then((htmlmanager) => {
96
+ const managerFactory = () => {
97
+ return new htmlmanager.HTMLManager({ loader: loader });
98
+ };
99
+ libembed.renderWidgets(managerFactory, element);
100
+ });
101
+ }
102
+ //# sourceMappingURL=libembed-amd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"libembed-amd.js","sourceRoot":"","sources":["../../../src/jupyter/ipywidgets/libembed-amd.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,0CAA0C;AAC1C,2DAA2D;AAE3D,OAAO,KAAK,QAAQ,MAA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YACxB,OAAO,CAAC,GAAG,CAAC,mBAAmB,GAAG,QAAQ,UAAU,IAAI,aAAa,EAAE,CAAC,CAAC;YACzE,OAAO,WAAW,EAAE,CAAC;SACtB;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAC3B,OAAO,GAAG,QAAQ,CAAC,eAAe,EAClC,SAGoB,aAAa;IAEjC,cAAc,CAAC,CAAC,+BAA+B,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,EAAE;QACrE,MAAM,cAAc,GAAG,GAAQ,EAAE;YAC/B,OAAO,IAAI,WAAW,CAAC,WAAW,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;QACzD,CAAC,CAAC;QACF,QAAQ,CAAC,aAAa,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,6 @@
1
+ export type IDatalayerConfig = {
2
+ /**
3
+ * Cloud API URL
4
+ */
5
+ apiServerUrl: string;
6
+ };
@@ -3,4 +3,5 @@
3
3
  *
4
4
  * MIT License
5
5
  */
6
- //# sourceMappingURL=ConsoleZustand.js.map
6
+ export {};
7
+ //# sourceMappingURL=IState.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IState.js","sourceRoot":"","sources":["../../src/state/IState.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
@@ -0,0 +1,30 @@
1
+ import { ServiceManager } from '@jupyterlab/services';
2
+ import type { IDatalayerConfig } from './IState';
3
+ import { IJupyterConfig } from '../jupyter/JupyterConfig';
4
+ import useCellStore from '../components/cell/CellState';
5
+ import useConsoleStore from '../components/console/ConsoleState';
6
+ import useNotebookStore from '../components/notebook/NotebookState';
7
+ import useOutputStore from '../components/output/OutputState';
8
+ import useTerminalStore from '../components/terminal/TerminalState';
9
+ import { JupyterContextProps } from '../jupyter/JupyterContext';
10
+ import Kernel from '../jupyter/kernel/Kernel';
11
+ export type JupyterState = {
12
+ datalayerConfig?: IDatalayerConfig;
13
+ setDatalayerConfig: (configuration?: IDatalayerConfig) => void;
14
+ version: string;
15
+ setVersion: (version: string) => void;
16
+ jupyterConfig?: IJupyterConfig;
17
+ kernelIsLoading: boolean;
18
+ kernel?: Kernel;
19
+ serviceManager?: ServiceManager;
20
+ cellStore: typeof useCellStore;
21
+ consoleStore: typeof useConsoleStore;
22
+ notebookStore: typeof useNotebookStore;
23
+ outputStore: typeof useOutputStore;
24
+ terminalStore: typeof useTerminalStore;
25
+ };
26
+ export declare const jupyterStore: import("zustand").StoreApi<JupyterState>;
27
+ export declare function useJupyterStore(): JupyterState;
28
+ export declare function useJupyterStore<T>(selector: (state: JupyterState) => T): T;
29
+ export declare function useJupyterStoreFromContext(props: JupyterContextProps): JupyterState;
30
+ export default useJupyterStore;
@@ -0,0 +1,191 @@
1
+ /*
2
+ * Copyright (c) 2021-2023 Datalayer, Inc.
3
+ *
4
+ * MIT License
5
+ */
6
+ import { useEffect, useState, useMemo } from 'react';
7
+ import { createStore } from 'zustand/vanilla';
8
+ import { useStore } from 'zustand';
9
+ import { ServiceManager } from '@jupyterlab/services';
10
+ import { loadJupyterConfig } from '../jupyter/JupyterConfig';
11
+ import useCellStore from '../components/cell/CellState';
12
+ import useConsoleStore from '../components/console/ConsoleState';
13
+ import useNotebookStore from '../components/notebook/NotebookState';
14
+ import useOutputStore from '../components/output/OutputState';
15
+ import useTerminalStore from '../components/terminal/TerminalState';
16
+ import { createLiteServer } from '../jupyter/lite/LiteServer';
17
+ import { getJupyterServerHttpUrl } from '../jupyter/JupyterConfig';
18
+ import { ensureJupyterAuth, createServerSettings } from '../jupyter/JupyterContext';
19
+ import Kernel from '../jupyter/kernel/Kernel';
20
+ let initialConfiguration = undefined;
21
+ try {
22
+ const rawConfig = document.getElementById('datalayer-config-data');
23
+ if (rawConfig?.innerText) {
24
+ initialConfiguration = JSON.parse(rawConfig?.innerText);
25
+ }
26
+ }
27
+ catch (error) {
28
+ console.debug('No configuration found in the webpage.', error);
29
+ }
30
+ export const jupyterStore = createStore((set, get) => ({
31
+ datalayerConfig: initialConfiguration,
32
+ setDatalayerConfig: (configuration) => {
33
+ set(state => ({ datalayerConfig: configuration }));
34
+ },
35
+ version: '',
36
+ setVersion: version => {
37
+ if (version && !get().version) {
38
+ set(state => ({ version }));
39
+ }
40
+ },
41
+ jupyterConfig: undefined,
42
+ kernelIsLoading: true,
43
+ kernel: undefined,
44
+ serviceManager: undefined,
45
+ serverSettings: undefined,
46
+ cellStore: useCellStore,
47
+ consoleStore: useConsoleStore,
48
+ notebookStore: useNotebookStore,
49
+ outputStore: useOutputStore,
50
+ terminalStore: useTerminalStore,
51
+ }));
52
+ export function useJupyterStore(selector) {
53
+ return useStore(jupyterStore, selector);
54
+ }
55
+ export function useJupyterStoreFromContext(props) {
56
+ const { defaultKernelName = 'python', initCode = '', lite = false, startDefaultKernel = true, useRunningKernelId, useRunningKernelIndex = -1, serverUrls, } = props;
57
+ useMemo(() => {
58
+ const config = loadJupyterConfig({});
59
+ jupyterStore.getState().jupyterConfig = config;
60
+ return config;
61
+ }, []);
62
+ const { baseUrl, wsUrl } = serverUrls ?? {};
63
+ const [serviceManager, setServiceManager] = useState();
64
+ const [_, setKernel] = useState();
65
+ const [__, setIsLoading] = useState(startDefaultKernel || useRunningKernelIndex > -1);
66
+ // Create a service manager.
67
+ useEffect(() => {
68
+ if (lite) {
69
+ createLiteServer().then(async (liteServer) => {
70
+ // Load the browser kernel
71
+ const mod = typeof lite === 'boolean'
72
+ ? await import('@jupyterlite/pyodide-kernel-extension')
73
+ : await lite;
74
+ // Load the module manually to get the list of plugin IDs
75
+ let data = mod.default;
76
+ // Handle commonjs exports.
77
+ if (!Object.prototype.hasOwnProperty.call(mod, '__esModule')) {
78
+ data = mod;
79
+ }
80
+ if (!Array.isArray(data)) {
81
+ data = [data];
82
+ }
83
+ const pluginIDs = data.map(item => {
84
+ try {
85
+ liteServer.registerPlugin(item);
86
+ return item.id;
87
+ }
88
+ catch (error) {
89
+ console.error(error);
90
+ return null;
91
+ }
92
+ });
93
+ // Activate the loaded plugins
94
+ await Promise.all(pluginIDs.filter(id => id).map(id => liteServer.activatePlugin(id)));
95
+ setServiceManager(liteServer.serviceManager);
96
+ jupyterStore.getState().serviceManager = liteServer.serviceManager;
97
+ });
98
+ }
99
+ else {
100
+ const serverSettings = createServerSettings(baseUrl ?? '', wsUrl ?? '');
101
+ ensureJupyterAuth(serverSettings).then(isAuth => {
102
+ if (!isAuth) {
103
+ const loginUrl = getJupyterServerHttpUrl() + '/login?next=' + window.location;
104
+ console.warn('Redirecting to Jupyter Server login URL', loginUrl);
105
+ window.location.replace(loginUrl);
106
+ }
107
+ if (useRunningKernelId && useRunningKernelIndex > -1) {
108
+ throw new Error('You can not ask for useRunningKernelId and useRunningKernelIndex at the same time.');
109
+ }
110
+ if (startDefaultKernel &&
111
+ (useRunningKernelId || useRunningKernelIndex > -1)) {
112
+ throw new Error('You can not ask for startDefaultKernel and (useRunningKernelId or useRunningKernelIndex) at the same time.');
113
+ }
114
+ const serviceManager = new ServiceManager({ serverSettings });
115
+ setServiceManager(serviceManager);
116
+ jupyterStore.getState().serviceManager = serviceManager;
117
+ });
118
+ }
119
+ }, [baseUrl, wsUrl, lite]);
120
+ // Create a kernel
121
+ useEffect(() => {
122
+ serviceManager?.kernels.ready.then(async () => {
123
+ const kernelManager = serviceManager.kernels;
124
+ console.log('Kernel Manager is Ready', kernelManager);
125
+ if (useRunningKernelIndex > -1) {
126
+ const running = kernelManager.running();
127
+ let kernel = running.next();
128
+ let i = 0;
129
+ while (!kernel.done) {
130
+ if (i === useRunningKernelIndex) {
131
+ const wrappedKernel = new Kernel({
132
+ kernelManager,
133
+ kernelName: defaultKernelName,
134
+ kernelSpecName: defaultKernelName,
135
+ kernelModel: kernel.value,
136
+ kernelType: 'notebook',
137
+ kernelspecsManager: serviceManager.kernelspecs,
138
+ sessionManager: serviceManager.sessions,
139
+ });
140
+ if (initCode) {
141
+ try {
142
+ await wrappedKernel.execute(initCode)?.done;
143
+ }
144
+ catch (error) {
145
+ console.error('Failed to execute the initial code', error);
146
+ }
147
+ }
148
+ setKernel(wrappedKernel);
149
+ jupyterStore.getState().kernel = wrappedKernel;
150
+ setIsLoading(false);
151
+ jupyterStore.getState().kernelIsLoading = false;
152
+ break;
153
+ }
154
+ kernel = running.next();
155
+ i++;
156
+ }
157
+ setIsLoading(false);
158
+ jupyterStore.getState().kernelIsLoading = false;
159
+ }
160
+ else if (startDefaultKernel) {
161
+ console.log('Starting Kernel Name:', defaultKernelName);
162
+ const defaultKernel = new Kernel({
163
+ kernelManager,
164
+ kernelName: defaultKernelName,
165
+ kernelSpecName: defaultKernelName,
166
+ kernelType: 'notebook',
167
+ kernelspecsManager: serviceManager.kernelspecs,
168
+ sessionManager: serviceManager.sessions,
169
+ });
170
+ defaultKernel.ready.then(async () => {
171
+ if (initCode) {
172
+ try {
173
+ await defaultKernel.execute(initCode)?.done;
174
+ }
175
+ catch (error) {
176
+ console.error('Failed to execute the initial code', error);
177
+ }
178
+ }
179
+ console.log('Kernel is Ready', defaultKernel);
180
+ setKernel(defaultKernel);
181
+ jupyterStore.getState().kernel = defaultKernel;
182
+ setIsLoading(false);
183
+ jupyterStore.getState().kernelIsLoading = false;
184
+ });
185
+ }
186
+ });
187
+ }, [lite, serviceManager]);
188
+ return useStore(jupyterStore);
189
+ }
190
+ export default useJupyterStore;
191
+ //# sourceMappingURL=State.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"State.js","sourceRoot":"","sources":["../../src/state/State.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,cAAc,EAAE,MAA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AAG,CAAC,uBAAuB,EAAE,iBAAiB,CAAC,CAAC;gBACxD,MAAM,aAAa,GAAG,IAAI,MAAM,CAAC;oBAC/B,aAAa;oBACb,UAAU,EAAE,iBAAiB;oBAC7B,cAAc,EAAE,iBAAiB;oBACjC,UAAU,EAAE,UAAU;oBACtB,kBAAkB,EAAE,cAAc,CAAC,WAAW;oBAC9C,cAAc,EAAE,cAAc,CAAC,QAAQ;iBACxC,CAAC,CAAC;gBACH,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE;oBAClC,IAAI,QAAQ,EAAE;wBACZ,IAAI;4BACF,MAAM,aAAa,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC;yBAC7C;wBAAC,OAAO,KAAK,EAAE;4BACd,OAAO,CAAC,KAAK,CAAC,oCAAoC,EAAE,KAAK,CAAC,CAAC;yBAC5D;qBACF;oBACD,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE,aAAa,CAAC,CAAC;oBAC9C,SAAS,CAAC,aAAa,CAAC,CAAC;oBACzB,YAAY,CAAC,QAAQ,EAAE,CAAC,MAAM,GAAG,aAAa,CAAC;oBAC/C,YAAY,CAAC,KAAK,CAAC,CAAC;oBACpB,YAAY,CAAC,QAAQ,EAAE,CAAC,eAAe,GAAG,KAAK,CAAC;gBAClD,CAAC,CAAC,CAAC;aACJ;QACH,CAAC,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC;IAC3B,OAAO,QAAQ,CAAC,YAAY,CAAC,CAAC;AAChC,CAAC;AAED,eAAe,eAAe,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./IState";
2
+ export * from "./State";
@@ -3,4 +3,6 @@
3
3
  *
4
4
  * MIT License
5
5
  */
6
+ export * from "./IState";
7
+ export * from "./State";
6
8
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/state/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/state/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datalayer/jupyter-react",
3
- "version": "0.10.1",
3
+ "version": "0.12.0",
4
4
  "description": "Jupyter React - React.js components 100% compatible with Jupyter.",
5
5
  "license": "MIT",
6
6
  "main": "lib/index.js",
@@ -66,7 +66,6 @@
66
66
  "dependencies": {
67
67
  "@codemirror/lang-python": "^6.0.1",
68
68
  "@datalayer/primer-addons": "0.3.0",
69
- "@datalayer/typescript-fsa-redux-observable": "0.18.0",
70
69
  "@jupyter-widgets/base": "^6.0.0",
71
70
  "@jupyter-widgets/controls": "^5.0.0",
72
71
  "@jupyter-widgets/html-manager": "^1.0.0",
@@ -109,6 +108,7 @@
109
108
  "@jupyterlab/mathjax-extension": "^4.0.0",
110
109
  "@jupyterlab/metadataform": "^4.0.0",
111
110
  "@jupyterlab/nbconvert-css": "^4.0.0",
111
+ "@jupyterlab/nbformat": "^4.0.0",
112
112
  "@jupyterlab/notebook": "^4.0.0",
113
113
  "@jupyterlab/notebook-extension": "^4.0.0",
114
114
  "@jupyterlab/observables": "^5.0.0",
@@ -143,14 +143,9 @@
143
143
  "react-dom": "^18.2.0",
144
144
  "react-error-boundary": "^3.1.3",
145
145
  "react-inspector": "^5.1.1",
146
- "react-redux": "^8.1.2",
147
146
  "react-sparklines": "^1.7.0",
148
- "redux": "^4.2.1",
149
- "redux-observable": "^1.2.0",
150
147
  "rxjs": "^6.6.0",
151
148
  "styled-components": "^5.3.10",
152
- "typescript-fsa": "^2.5.0",
153
- "typescript-fsa-reducers": "^1.2.2",
154
149
  "usehooks-ts": "^2.9.1",
155
150
  "utf-8-validate": "^6.0.3",
156
151
  "wildcard-match": "^5.1.2",
@@ -170,17 +165,19 @@
170
165
  "@jupyterlab/testutils": "^4.0.0",
171
166
  "@jupyterlab/vega3-extension": "^3.3.0",
172
167
  "@jupyterlite/javascript-kernel-extension": "^0.2.2",
168
+ "@mermaid-js/mermaid-zenuml": "0.2.0",
173
169
  "@playwright/test": "^1.40.1",
174
170
  "@primer/octicons-react": "^19.8.0",
175
- "@storybook/addon-essentials": "^7.6.5",
176
- "@storybook/addon-interactions": "^7.6.5",
177
- "@storybook/addon-links": "^7.6.5",
178
- "@storybook/addon-onboarding": "^1.0.10",
179
- "@storybook/addon-themes": "^7.6.6",
180
- "@storybook/blocks": "^7.6.5",
181
- "@storybook/react": "^7.6.5",
182
- "@storybook/react-webpack5": "^7.6.5",
183
- "@storybook/test": "^7.6.5",
171
+ "@storybook/addon-essentials": "^8.0.10",
172
+ "@storybook/addon-interactions": "^8.0.10",
173
+ "@storybook/addon-links": "^8.0.10",
174
+ "@storybook/addon-onboarding": "^8.0.10",
175
+ "@storybook/addon-themes": "^8.0.10",
176
+ "@storybook/blocks": "^8.0.10",
177
+ "@storybook/manager-api": "^8.0.10",
178
+ "@storybook/react": "^8.0.10",
179
+ "@storybook/react-webpack5": "^8.0.10",
180
+ "@storybook/test": "^8.0.10",
184
181
  "@types/codemirror": "^5.60.4",
185
182
  "@types/jest": "^29.4.0",
186
183
  "@types/marked": "^4.0.1",
@@ -211,12 +208,14 @@
211
208
  "html-webpack-tags-plugin": "^2.0.17",
212
209
  "jest": "^29.4.3",
213
210
  "jupyterlab-plotly": "^5.17.0",
211
+ "mdx-mermaid": "^2.0.0",
212
+ "mermaid": "^10.9.0",
214
213
  "mkdirp": "^1.0.3",
215
214
  "npm-run-all": "^4.1.5",
216
215
  "prettier": "^3.0.0",
217
216
  "process": "^0.11.10",
218
217
  "rimraf": "^3.0.2",
219
- "storybook": "^7.6.5",
218
+ "storybook": "^8.0.10",
220
219
  "stream": "^0.0.2",
221
220
  "stream-browserify": "^2.0.2",
222
221
  "style-loader": "^2.0.0",
@@ -263,24 +262,7 @@
263
262
  "extension": "./lib/jupyter/lab/index.js",
264
263
  "outputDir": "jupyter_react/labextension",
265
264
  "schemaDir": "schema",
266
- "webpackConfig": "./webpack.lab-config.js",
267
- "sharedPackages": {
268
- "@jupyter/web-components": {
269
- "bundled": true,
270
- "singleton": true
271
- },
272
- "@jupyter-notebook/tree": {
273
- "singleton": true
274
- },
275
- "@microsoft/fast-element": {
276
- "bundled": true,
277
- "singleton": true
278
- },
279
- "@microsoft/fast-foundation": {
280
- "bundled": true,
281
- "singleton": true
282
- }
283
- }
265
+ "webpackConfig": "./webpack.lab-config.js"
284
266
  },
285
267
  "jupyter-releaser": {
286
268
  "hooks": {
@@ -1,22 +0,0 @@
1
- import CellAdapter from './CellAdapter';
2
- export interface ICellState {
3
- source: string;
4
- outputsCount: number;
5
- kernelAvailable: boolean;
6
- adapter?: CellAdapter;
7
- }
8
- export declare const cellInitialState: ICellState;
9
- export declare const selectCell: () => ICellState;
10
- export declare enum CellActionType {
11
- SOURCE = "cell/SOURCE",
12
- OUTPUTS_COUNT = "cell/OUTPUTS_COUNT",
13
- EXECUTE = "cell/EXECUTE",
14
- UPDATE = "cell/UPDATE"
15
- }
16
- export declare const cellActions: {
17
- source: import("typescript-fsa").ActionCreator<string>;
18
- outputsCount: import("typescript-fsa").ActionCreator<number>;
19
- execute: import("typescript-fsa").ActionCreator<void>;
20
- update: import("typescript-fsa").ActionCreator<Partial<ICellState>>;
21
- };
22
- export declare const cellReducer: import("typescript-fsa-reducers").ReducerBuilder<ICellState, ICellState>;
@@ -1,62 +0,0 @@
1
- /*
2
- * Copyright (c) 2021-2023 Datalayer, Inc.
3
- *
4
- * MIT License
5
- */
6
- import actionCreatorFactory from 'typescript-fsa';
7
- import { useSelector } from 'react-redux';
8
- import { reducerWithInitialState } from 'typescript-fsa-reducers';
9
- export const cellInitialState = {
10
- source: '',
11
- outputsCount: -1,
12
- kernelAvailable: false,
13
- };
14
- /* Selectors */
15
- export const selectCell = () => useSelector((state) => {
16
- if (state.cell) {
17
- return state.cell;
18
- }
19
- return cellInitialState;
20
- });
21
- /* Actions */
22
- export var CellActionType;
23
- (function (CellActionType) {
24
- CellActionType["SOURCE"] = "cell/SOURCE";
25
- CellActionType["OUTPUTS_COUNT"] = "cell/OUTPUTS_COUNT";
26
- CellActionType["EXECUTE"] = "cell/EXECUTE";
27
- CellActionType["UPDATE"] = "cell/UPDATE";
28
- })(CellActionType || (CellActionType = {}));
29
- const actionCreator = actionCreatorFactory('jupyterReact');
30
- export const cellActions = {
31
- source: actionCreator(CellActionType.SOURCE),
32
- outputsCount: actionCreator(CellActionType.OUTPUTS_COUNT),
33
- execute: actionCreator(CellActionType.EXECUTE),
34
- update: actionCreator(CellActionType.UPDATE),
35
- };
36
- /* Reducers */
37
- export const cellReducer = reducerWithInitialState(cellInitialState)
38
- .case(cellActions.execute, (state, payload) => {
39
- if (state.adapter) {
40
- state.adapter.execute();
41
- }
42
- return {
43
- ...state,
44
- };
45
- })
46
- .case(cellActions.source, (state, source) => {
47
- return {
48
- ...state,
49
- source,
50
- };
51
- })
52
- .case(cellActions.update, (state, partial) => ({
53
- ...state,
54
- ...partial,
55
- }))
56
- .case(cellActions.outputsCount, (state, outputsCount) => {
57
- return {
58
- ...state,
59
- outputsCount,
60
- };
61
- });
62
- //# sourceMappingURL=CellRedux.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CellRedux.js","sourceRoot":"","sources":["../../../src/components/cell/CellRedux.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,oBAAoB,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAYlE,MAAM,CAAC,MAAM,gBAAgB,GAAe;IAC1C,MAAM,EAAE,EAAE;IACV,YAAY,EAAE,CAAC,CAAC;IAChB,eAAe,EAAE,KAAK;CACvB,CAAC;AAEF,eAAe;AAEf,MA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AA4B,EAAE,EAAE,CAAC,CAAC;IACpD,GAAG,KAAK;IACR,GAAG,OAAO;CACX,CAAC,CACH;KACA,IAAI,CAAC,WAAW,CAAC,YAAY,EAAE,CAAC,KAAiB,EAAE,YAAoB,EAAE,EAAE;IAC1E,OAAO;QACL,GAAG,KAAK;QACR,YAAY;KACb,CAAC;AACJ,CAAC,CAAC,CAAC"}
@@ -1,5 +0,0 @@
1
- export type CellZustandState = {
2
- id: number;
3
- };
4
- export declare const useCellStore: import("zustand").UseBoundStore<import("zustand").StoreApi<CellZustandState>>;
5
- export default useCellStore;
@@ -1,11 +0,0 @@
1
- /*
2
- * Copyright (c) 2021-2023 Datalayer, Inc.
3
- *
4
- * MIT License
5
- */
6
- import { create } from 'zustand';
7
- export const useCellStore = create((set, get) => ({
8
- id: 0,
9
- }));
10
- export default useCellStore;
11
- //# sourceMappingURL=CellZustand.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CellZustand.js","sourceRoot":"","sources":["../../../src/components/cell/CellZustand.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAMjC,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAmB,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;IAClE,EAAE,EAAE,CAAC;CACN,CAAC,CAAC,CAAC;AAEJ,eAAe,YAAY,CAAC"}
@@ -1,15 +0,0 @@
1
- export type ICommand = number;
2
- export interface ICommandState {
3
- outputs: ICommand;
4
- }
5
- export declare const commandsInitialState: ICommandState;
6
- export declare const selectCommands: () => ICommandState;
7
- export declare enum CommandsActionType {
8
- OUTPUTS = "commands/OUTPUTS",
9
- EXECUTE = "commands/EXECUTE"
10
- }
11
- export declare const commandsActions: {
12
- outputs: import("typescript-fsa").ActionCreator<number>;
13
- execute: import("typescript-fsa").ActionCreator<void>;
14
- };
15
- export declare const commandsReducer: import("typescript-fsa-reducers").ReducerBuilder<ICommandState, ICommandState>;