@datalayer/core 0.0.17 → 0.0.19

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 (107) hide show
  1. package/README.md +9 -13
  2. package/lib/client/auth/AuthenticationManager.d.ts +95 -0
  3. package/lib/client/auth/AuthenticationManager.js +214 -0
  4. package/lib/client/auth/index.d.ts +8 -0
  5. package/lib/client/auth/index.js +17 -0
  6. package/lib/client/auth/storage.d.ts +154 -0
  7. package/lib/client/auth/storage.js +447 -0
  8. package/lib/client/auth/strategies.d.ts +54 -0
  9. package/lib/client/auth/strategies.js +238 -0
  10. package/lib/client/auth/types.d.ts +151 -0
  11. package/lib/{examples/index.js → client/auth/types.js} +4 -2
  12. package/lib/client/base.d.ts +3 -0
  13. package/lib/client/base.js +9 -0
  14. package/lib/client/index.d.ts +1 -0
  15. package/lib/client/index.js +2 -0
  16. package/lib/components/auth/Login.d.ts +40 -0
  17. package/lib/components/auth/Login.js +173 -0
  18. package/lib/components/auth/Login.stories.d.ts +54 -0
  19. package/lib/components/auth/Login.stories.js +104 -0
  20. package/lib/components/auth/LoginToken.d.ts +16 -0
  21. package/lib/components/auth/LoginToken.js +63 -0
  22. package/lib/components/auth/index.d.ts +5 -0
  23. package/lib/components/auth/index.js +16 -0
  24. package/lib/components/avatars/BoringAvatar.d.ts +6 -15
  25. package/lib/components/avatars/BoringAvatar.js +30 -34
  26. package/lib/components/avatars/BoringAvatar.stories.d.ts +7 -16
  27. package/lib/components/avatars/UserProfileAvatar.d.ts +1 -6
  28. package/lib/components/avatars/UserProfileAvatar.js +3 -8
  29. package/lib/components/buttons/DownloadCSVButton.d.ts +2 -7
  30. package/lib/components/buttons/DownloadCSVButton.js +1 -5
  31. package/lib/components/buttons/DownloadJsonButton.d.ts +3 -10
  32. package/lib/components/buttons/DownloadJsonButton.js +1 -7
  33. package/lib/components/buttons/UploadButton.d.ts +1 -4
  34. package/lib/components/buttons/UploadButton.js +3 -7
  35. package/lib/components/chat/ChatComponent.js +4 -0
  36. package/lib/components/chat/display/ReasoningPart.js +4 -0
  37. package/lib/components/chat/display/ToolPart.js +4 -0
  38. package/lib/components/chat/display/index.js +4 -0
  39. package/lib/components/chat/handler.js +4 -0
  40. package/lib/components/chat/index.js +4 -0
  41. package/lib/components/display/CenteredSpinner.d.ts +1 -4
  42. package/lib/components/display/CenteredSpinner.js +1 -5
  43. package/lib/components/display/HorizontalCenter.d.ts +1 -4
  44. package/lib/components/display/HorizontalCenter.js +1 -5
  45. package/lib/components/flashes/FlashClosable.d.ts +1 -4
  46. package/lib/components/flashes/FlashClosable.js +1 -5
  47. package/lib/components/flashes/FlashDisclaimer.js +1 -1
  48. package/lib/components/index.d.ts +1 -0
  49. package/lib/components/index.js +1 -0
  50. package/lib/components/notebooks/JupyterNotebook.d.ts +1 -6
  51. package/lib/components/notebooks/JupyterNotebook.js +1 -5
  52. package/lib/components/snapshots/RuntimeSnapshotMenu.d.ts +1 -4
  53. package/lib/components/snapshots/RuntimeSnapshotMenu.js +1 -5
  54. package/lib/config/Configuration.js +1 -1
  55. package/lib/examples/CellExample.js +11 -47
  56. package/lib/examples/lexical-theme.css +436 -0
  57. package/lib/examples/notebooks/Matplotlib.ipynb.json +1 -1
  58. package/lib/examples/notebooks/NotebookExample1.ipynb.json +1 -1
  59. package/lib/hooks/useAIJupyterChat.js +4 -0
  60. package/lib/hooks/useBackdrop.d.ts +4 -4
  61. package/lib/hooks/useBackdrop.js +5 -9
  62. package/lib/hooks/useCache.d.ts +5 -1
  63. package/lib/hooks/useCache.js +27 -14
  64. package/lib/hooks/useMobile.js +4 -0
  65. package/lib/hooks/useScreenshot.d.ts +3 -5
  66. package/lib/hooks/useScreenshot.js +1 -8
  67. package/lib/models/Outbound.d.ts +2 -0
  68. package/lib/models/Outbound.js +3 -1
  69. package/lib/state/substates/CoreState.js +1 -1
  70. package/lib/state/substates/IAMState.js +15 -6
  71. package/lib/tools/adapters/agui/AgUIToolAdapter.d.ts +75 -0
  72. package/lib/tools/adapters/agui/AgUIToolAdapter.js +244 -0
  73. package/lib/tools/adapters/agui/index.d.ts +10 -0
  74. package/lib/tools/adapters/agui/index.js +19 -0
  75. package/lib/tools/adapters/agui/lexicalHooks.d.ts +27 -0
  76. package/lib/tools/adapters/agui/lexicalHooks.js +64 -0
  77. package/lib/tools/adapters/agui/notebookHooks.d.ts +27 -0
  78. package/lib/tools/adapters/agui/notebookHooks.js +61 -0
  79. package/lib/tools/index.d.ts +6 -0
  80. package/lib/tools/index.js +18 -0
  81. package/lib/types.js +2 -3
  82. package/lib/utils/cli/index.d.ts +4 -0
  83. package/lib/utils/cli/index.js +13 -0
  84. package/lib/utils/cli/query.d.ts +6 -0
  85. package/lib/utils/cli/query.js +26 -0
  86. package/lib/utils/index.d.ts +1 -0
  87. package/lib/utils/index.js +1 -0
  88. package/package.json +49 -7
  89. package/lib/examples/ChatExample.d.ts +0 -8
  90. package/lib/examples/ChatExample.js +0 -51
  91. package/lib/examples/DatalayerNotebookExample.d.ts +0 -16
  92. package/lib/examples/DatalayerNotebookExample.js +0 -75
  93. package/lib/examples/NativeNavigationExample.d.ts +0 -8
  94. package/lib/examples/NativeNavigationExample.js +0 -97
  95. package/lib/examples/NotebookMutationsKernel.d.ts +0 -2
  96. package/lib/examples/NotebookMutationsKernel.js +0 -115
  97. package/lib/examples/NotebookMutationsServiceManager.d.ts +0 -2
  98. package/lib/examples/NotebookMutationsServiceManager.js +0 -107
  99. package/lib/examples/ReactRouterExample.d.ts +0 -6
  100. package/lib/examples/ReactRouterExample.js +0 -175
  101. package/lib/examples/example-selector.d.ts +0 -22
  102. package/lib/examples/example-selector.js +0 -46
  103. package/lib/examples/index.d.ts +0 -2
  104. package/lib/examples/main.d.ts +0 -1
  105. package/lib/examples/main.js +0 -153
  106. package/lib/examples/notebooks/OutputIPyWidgetsExample.d.ts +0 -145
  107. package/lib/examples/notebooks/OutputIPyWidgetsExample.js +0 -153
@@ -1,153 +0,0 @@
1
- import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
- /*
3
- * Copyright (c) 2023-2025 Datalayer, Inc.
4
- * Distributed under the terms of the Modified BSD License.
5
- */
6
- import { useEffect, useState } from 'react';
7
- import { createRoot } from 'react-dom/client';
8
- import { loadJupyterConfig, JupyterReactTheme, createServerSettings, setJupyterServerUrl, setJupyterServerToken, getJupyterServerUrl, getJupyterServerToken, } from '@datalayer/jupyter-react';
9
- import { ServiceManager } from '@jupyterlab/services';
10
- import { coreStore } from '../state/substates/CoreState';
11
- import { iamStore } from '../state';
12
- import { getSelectedExample, getSelectedExampleName } from './example-selector';
13
- import { createDatalayerServiceManager } from '../services/DatalayerServiceManager';
14
- // Load configurations from DOM
15
- const loadConfigurations = () => {
16
- // Load Datalayer configuration
17
- const datalayerConfigElement = document.getElementById('datalayer-config-data');
18
- if (datalayerConfigElement?.textContent) {
19
- try {
20
- const datalayerConfig = JSON.parse(datalayerConfigElement.textContent);
21
- if (datalayerConfig.runUrl) {
22
- console.log('Setting Datalayer config:', datalayerConfig);
23
- coreStore.getState().setConfiguration(datalayerConfig);
24
- // Also set the token in the IAM store for API authentication
25
- if (datalayerConfig.token) {
26
- // Use the setLogin method to set the token in IAM store
27
- // For now, we'll just set a minimal user object since we don't have full user data
28
- iamStore.getState().setLogin({
29
- id: 'example-id',
30
- handle: 'example-user',
31
- email: 'example@datalayer.com',
32
- firstName: 'Example',
33
- lastName: 'User',
34
- initials: 'EU',
35
- displayName: 'Example User',
36
- avatarUrl: '',
37
- roles: [],
38
- setRoles: () => { },
39
- iamProviders: [],
40
- settings: {},
41
- unsubscribedFromOutbounds: false,
42
- onboarding: {},
43
- events: [],
44
- }, datalayerConfig.token);
45
- }
46
- }
47
- }
48
- catch (e) {
49
- console.error('Failed to parse Datalayer config:', e);
50
- }
51
- }
52
- // Load Jupyter configuration
53
- loadJupyterConfig();
54
- // Also set Jupyter server URL and token if available in jupyter-config-data
55
- const jupyterConfigElement = document.getElementById('jupyter-config-data');
56
- if (jupyterConfigElement?.textContent) {
57
- try {
58
- const jupyterConfig = JSON.parse(jupyterConfigElement.textContent);
59
- if (jupyterConfig.baseUrl) {
60
- setJupyterServerUrl(jupyterConfig.baseUrl);
61
- }
62
- if (jupyterConfig.token) {
63
- setJupyterServerToken(jupyterConfig.token);
64
- }
65
- }
66
- catch (e) {
67
- console.error('Failed to parse Jupyter config:', e);
68
- }
69
- }
70
- };
71
- // Main App component that loads and renders the selected example
72
- const ExampleApp = () => {
73
- const [ExampleComponent, setExampleComponent] = useState(null);
74
- const [loading, setLoading] = useState(true);
75
- const [error, setError] = useState(null);
76
- const [serviceManager, setServiceManager] = useState(null);
77
- useEffect(() => {
78
- // Load configurations
79
- loadConfigurations();
80
- // Create service manager
81
- const createManager = async () => {
82
- const { configuration } = coreStore.getState();
83
- // Try to use DatalayerServiceManager if we have a token
84
- if (configuration?.token) {
85
- console.log('Using DatalayerServiceManager with token');
86
- try {
87
- const manager = await createDatalayerServiceManager(configuration.cpuEnvironment || 'python-3.11', configuration.credits || 100);
88
- await manager.ready;
89
- console.log('DatalayerServiceManager is ready');
90
- setServiceManager(manager);
91
- return;
92
- }
93
- catch (error) {
94
- console.error('Failed to create DatalayerServiceManager:', error);
95
- console.log('Falling back to regular ServiceManager');
96
- }
97
- }
98
- // Fall back to regular ServiceManager
99
- console.log('Using regular ServiceManager (no Datalayer token)');
100
- const serverSettings = createServerSettings(getJupyterServerUrl(), getJupyterServerToken());
101
- const manager = new ServiceManager({ serverSettings });
102
- await manager.ready;
103
- console.log('Regular ServiceManager is ready');
104
- setServiceManager(manager);
105
- };
106
- createManager();
107
- // Load the selected example
108
- const loadExample = async () => {
109
- try {
110
- const exampleLoader = getSelectedExample();
111
- const module = await exampleLoader();
112
- setExampleComponent(() => module.default);
113
- setLoading(false);
114
- }
115
- catch (e) {
116
- console.error('Failed to load example:', e);
117
- setError(`Failed to load example: ${e}`);
118
- setLoading(false);
119
- }
120
- };
121
- loadExample();
122
- }, []);
123
- if (loading) {
124
- return (_jsxs("div", { style: { padding: '20px', textAlign: 'center' }, children: [_jsxs("h2", { children: ["Loading Example: ", getSelectedExampleName()] }), _jsx("p", { children: "Please wait..." })] }));
125
- }
126
- if (error) {
127
- return (_jsxs("div", { style: { padding: '20px', color: 'red' }, children: [_jsx("h2", { children: "Error Loading Example" }), _jsx("pre", { children: error })] }));
128
- }
129
- if (!ExampleComponent) {
130
- return (_jsxs("div", { style: { padding: '20px' }, children: [_jsx("h2", { children: "Example Not Found" }), _jsx("p", { children: "The selected example could not be loaded." })] }));
131
- }
132
- // Check if the example component expects props
133
- // Most examples will need serviceManager
134
- const exampleProps = {};
135
- if (serviceManager) {
136
- exampleProps.serviceManager = serviceManager;
137
- }
138
- return (_jsx(JupyterReactTheme, { children: _jsxs("div", { style: { width: '100vw', height: '100vh', overflow: 'hidden' }, children: [_jsxs("div", { style: {
139
- padding: '10px',
140
- background: '#f0f0f0',
141
- borderBottom: '1px solid #ccc',
142
- fontSize: '14px',
143
- fontFamily: 'monospace',
144
- }, children: ["Running Example: ", _jsx("strong", { children: getSelectedExampleName() })] }), _jsx("div", { style: { height: 'calc(100vh - 40px)', overflow: 'auto' }, children: _jsx(ExampleComponent, { ...exampleProps }) })] }) }));
145
- };
146
- // Mount the app
147
- const root = document.getElementById('root');
148
- if (root) {
149
- createRoot(root).render(_jsx(ExampleApp, {}));
150
- }
151
- else {
152
- console.error('Root element not found');
153
- }
@@ -1,145 +0,0 @@
1
- export declare const view: {
2
- version_major: number;
3
- version_minor: number;
4
- model_id: string;
5
- };
6
- export declare const state: {
7
- version_major: number;
8
- version_minor: number;
9
- state: {
10
- '8621699ecc804983a612f09b7dfe806b': {
11
- model_name: string;
12
- model_module: string;
13
- model_module_version: string;
14
- state: {
15
- _view_module_version: string;
16
- children: string[];
17
- _model_module_version: string;
18
- layout: string;
19
- _view_count: number;
20
- };
21
- };
22
- '961d612211fe4c64a70f48942d885c14': {
23
- model_name: string;
24
- model_module: string;
25
- model_module_version: string;
26
- state: {
27
- _model_module_version: string;
28
- _view_module_version: string;
29
- _view_count: number;
30
- };
31
- };
32
- '564e75ddea4c4ea0a32c4bd39ed0ed6d': {
33
- model_name: string;
34
- model_module: string;
35
- model_module_version: string;
36
- state: {
37
- _model_module_version: string;
38
- _view_module_version: string;
39
- _view_count: number;
40
- };
41
- };
42
- a8b1ae50aada4d929397b907115bfc2c: {
43
- model_name: string;
44
- model_module: string;
45
- model_module_version: string;
46
- state: {
47
- style: string;
48
- _view_module_version: string;
49
- max: number;
50
- value: number;
51
- _model_module_version: string;
52
- layout: string;
53
- _view_count: number;
54
- };
55
- };
56
- b63481ca8b7943aa85d097a114a931f5: {
57
- model_name: string;
58
- model_module: string;
59
- model_module_version: string;
60
- state: {
61
- _model_module_version: string;
62
- _view_module_version: string;
63
- _view_count: number;
64
- };
65
- };
66
- d86e0cb348eb48bf97f14906a9406731: {
67
- model_name: string;
68
- model_module: string;
69
- model_module_version: string;
70
- state: {
71
- _model_module_version: string;
72
- _view_module_version: string;
73
- _view_count: number;
74
- };
75
- };
76
- '289e54d14b7c4c6d8ac18b4c86ab514c': {
77
- model_name: string;
78
- model_module: string;
79
- model_module_version: string;
80
- state: {
81
- style: string;
82
- _view_module_version: string;
83
- value: number;
84
- _model_module_version: string;
85
- layout: string;
86
- _view_count: number;
87
- };
88
- };
89
- bb589d8dc365404b94e73a153407128f: {
90
- model_name: string;
91
- model_module: string;
92
- model_module_version: string;
93
- state: {
94
- _model_module_version: string;
95
- _view_module_version: string;
96
- _view_count: number;
97
- };
98
- };
99
- '19a24d8ea5a248be8db79790290ae2a1': {
100
- model_name: string;
101
- model_module: string;
102
- model_module_version: string;
103
- state: {
104
- _model_module_version: string;
105
- _view_module_version: string;
106
- _view_count: number;
107
- };
108
- };
109
- '965bbfeaddd74b9baa488c7f6ac13027': {
110
- model_name: string;
111
- model_module: string;
112
- model_module_version: string;
113
- state: {
114
- style: string;
115
- _view_module_version: string;
116
- icon: string;
117
- _model_module_version: string;
118
- layout: string;
119
- _view_count: number;
120
- };
121
- };
122
- '6edd9d3360cc47c8aceff0ba11edeca9': {
123
- model_name: string;
124
- model_module: string;
125
- model_module_version: string;
126
- state: {
127
- _model_module_version: string;
128
- target: string[];
129
- source: string[];
130
- _view_module_version: string;
131
- _view_name: string;
132
- };
133
- };
134
- d7d14e74f61f4b3bb5f53a713bcadced: {
135
- model_name: string;
136
- model_module: string;
137
- model_module_version: string;
138
- state: {
139
- _model_module_version: string;
140
- _view_module_version: string;
141
- _view_count: number;
142
- };
143
- };
144
- };
145
- };
@@ -1,153 +0,0 @@
1
- /*
2
- * Copyright (c) 2023-2025 Datalayer, Inc.
3
- * Distributed under the terms of the Modified BSD License.
4
- */
5
- export const view = {
6
- version_major: 2,
7
- version_minor: 0,
8
- model_id: '8621699ecc804983a612f09b7dfe806b',
9
- };
10
- export const state = {
11
- version_major: 2,
12
- version_minor: 0,
13
- state: {
14
- '8621699ecc804983a612f09b7dfe806b': {
15
- model_name: 'VBoxModel',
16
- model_module: '@jupyter-widgets/controls',
17
- model_module_version: '1.0.0',
18
- state: {
19
- _view_module_version: '1.0.0',
20
- children: [
21
- 'IPY_MODEL_a8b1ae50aada4d929397b907115bfc2c',
22
- 'IPY_MODEL_289e54d14b7c4c6d8ac18b4c86ab514c',
23
- 'IPY_MODEL_965bbfeaddd74b9baa488c7f6ac13027',
24
- ],
25
- _model_module_version: '1.0.0',
26
- layout: 'IPY_MODEL_d7d14e74f61f4b3bb5f53a713bcadced',
27
- _view_count: 1,
28
- },
29
- },
30
- '961d612211fe4c64a70f48942d885c14': {
31
- model_name: 'LayoutModel',
32
- model_module: '@jupyter-widgets/base',
33
- model_module_version: '1.0.0',
34
- state: {
35
- _model_module_version: '1.0.0',
36
- _view_module_version: '1.0.0',
37
- _view_count: 1,
38
- },
39
- },
40
- '564e75ddea4c4ea0a32c4bd39ed0ed6d': {
41
- model_name: 'SliderStyleModel',
42
- model_module: '@jupyter-widgets/controls',
43
- model_module_version: '1.0.0',
44
- state: {
45
- _model_module_version: '1.0.0',
46
- _view_module_version: '1.0.0',
47
- _view_count: 1,
48
- },
49
- },
50
- a8b1ae50aada4d929397b907115bfc2c: {
51
- model_name: 'IntSliderModel',
52
- model_module: '@jupyter-widgets/controls',
53
- model_module_version: '1.0.0',
54
- state: {
55
- style: 'IPY_MODEL_564e75ddea4c4ea0a32c4bd39ed0ed6d',
56
- _view_module_version: '1.0.0',
57
- max: 200,
58
- value: 100,
59
- _model_module_version: '1.0.0',
60
- layout: 'IPY_MODEL_961d612211fe4c64a70f48942d885c14',
61
- _view_count: 1,
62
- },
63
- },
64
- b63481ca8b7943aa85d097a114a931f5: {
65
- model_name: 'LayoutModel',
66
- model_module: '@jupyter-widgets/base',
67
- model_module_version: '1.0.0',
68
- state: {
69
- _model_module_version: '1.0.0',
70
- _view_module_version: '1.0.0',
71
- _view_count: 1,
72
- },
73
- },
74
- d86e0cb348eb48bf97f14906a9406731: {
75
- model_name: 'SliderStyleModel',
76
- model_module: '@jupyter-widgets/controls',
77
- model_module_version: '1.0.0',
78
- state: {
79
- _model_module_version: '1.0.0',
80
- _view_module_version: '1.0.0',
81
- _view_count: 1,
82
- },
83
- },
84
- '289e54d14b7c4c6d8ac18b4c86ab514c': {
85
- model_name: 'IntSliderModel',
86
- model_module: '@jupyter-widgets/controls',
87
- model_module_version: '1.0.0',
88
- state: {
89
- style: 'IPY_MODEL_d86e0cb348eb48bf97f14906a9406731',
90
- _view_module_version: '1.0.0',
91
- value: 40,
92
- _model_module_version: '1.0.0',
93
- layout: 'IPY_MODEL_b63481ca8b7943aa85d097a114a931f5',
94
- _view_count: 1,
95
- },
96
- },
97
- bb589d8dc365404b94e73a153407128f: {
98
- model_name: 'LayoutModel',
99
- model_module: '@jupyter-widgets/base',
100
- model_module_version: '1.0.0',
101
- state: {
102
- _model_module_version: '1.0.0',
103
- _view_module_version: '1.0.0',
104
- _view_count: 1,
105
- },
106
- },
107
- '19a24d8ea5a248be8db79790290ae2a1': {
108
- model_name: 'ButtonStyleModel',
109
- model_module: '@jupyter-widgets/controls',
110
- model_module_version: '1.0.0',
111
- state: {
112
- _model_module_version: '1.0.0',
113
- _view_module_version: '1.0.0',
114
- _view_count: 1,
115
- },
116
- },
117
- '965bbfeaddd74b9baa488c7f6ac13027': {
118
- model_name: 'ButtonModel',
119
- model_module: '@jupyter-widgets/controls',
120
- model_module_version: '1.0.0',
121
- state: {
122
- style: 'IPY_MODEL_19a24d8ea5a248be8db79790290ae2a1',
123
- _view_module_version: '1.0.0',
124
- icon: 'legal',
125
- _model_module_version: '1.0.0',
126
- layout: 'IPY_MODEL_bb589d8dc365404b94e73a153407128f',
127
- _view_count: 1,
128
- },
129
- },
130
- '6edd9d3360cc47c8aceff0ba11edeca9': {
131
- model_name: 'DirectionalLinkModel',
132
- model_module: '@jupyter-widgets/controls',
133
- model_module_version: '1.0.0',
134
- state: {
135
- _model_module_version: '1.0.0',
136
- target: ['IPY_MODEL_289e54d14b7c4c6d8ac18b4c86ab514c', 'max'],
137
- source: ['IPY_MODEL_a8b1ae50aada4d929397b907115bfc2c', 'value'],
138
- _view_module_version: '1.0.0',
139
- _view_name: '',
140
- },
141
- },
142
- d7d14e74f61f4b3bb5f53a713bcadced: {
143
- model_name: 'LayoutModel',
144
- model_module: '@jupyter-widgets/base',
145
- model_module_version: '1.0.0',
146
- state: {
147
- _model_module_version: '1.0.0',
148
- _view_module_version: '1.0.0',
149
- _view_count: 1,
150
- },
151
- },
152
- },
153
- };