@datalayer/core 0.0.15 → 0.0.17
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/components/chat/ChatComponent.d.ts +4 -0
- package/lib/components/chat/ChatComponent.js +139 -0
- package/lib/components/chat/MessagePart.d.ts +11 -0
- package/lib/components/chat/MessagePart.js +23 -0
- package/lib/components/chat/display/DynamicToolPart.d.ts +6 -0
- package/lib/components/chat/display/DynamicToolPart.js +5 -0
- package/lib/components/chat/display/ReasoningPart.d.ts +6 -0
- package/lib/components/chat/display/ReasoningPart.js +54 -0
- package/lib/components/chat/display/TextPart.d.ts +9 -0
- package/lib/components/chat/display/TextPart.js +93 -0
- package/lib/components/chat/display/ToolPart.d.ts +6 -0
- package/lib/components/chat/display/ToolPart.js +144 -0
- package/lib/components/chat/display/index.d.ts +4 -0
- package/lib/components/chat/display/index.js +9 -0
- package/lib/components/chat/handler.d.ts +8 -0
- package/lib/components/chat/handler.js +39 -0
- package/lib/components/chat/index.d.ts +4 -0
- package/lib/components/chat/index.js +9 -0
- package/lib/components/index.d.ts +1 -1
- package/lib/components/index.js +1 -1
- package/lib/components/runtimes/RuntimeSimplePicker.d.ts +4 -0
- package/lib/components/runtimes/RuntimeSimplePicker.js +3 -3
- package/lib/examples/ChatExample.d.ts +8 -0
- package/lib/examples/ChatExample.js +51 -0
- package/lib/examples/example-selector.js +1 -0
- package/lib/hooks/useAIJupyterChat.d.ts +36 -0
- package/lib/hooks/useAIJupyterChat.js +49 -0
- package/lib/hooks/useCache.js +105 -45
- package/lib/hooks/useMobile.d.ts +1 -0
- package/lib/hooks/useMobile.js +22 -0
- package/lib/hooks/useUpload.js +29 -21
- package/lib/index.d.ts +1 -0
- package/lib/index.js +8 -4
- package/lib/stateful/index.d.ts +0 -1
- package/lib/stateful/index.js +0 -1
- package/lib/stateful/runtimes/actions.d.ts +1 -1
- package/lib/stateful/runtimes/actions.js +1 -1
- package/lib/theme/DatalayerTheme.d.ts +2 -2
- package/lib/theme/DatalayerTheme.js +4 -4
- package/lib/theme/DatalayerThemeProvider.js +2 -2
- package/lib/types.d.ts +5 -0
- package/lib/types.js +6 -0
- package/package.json +16 -2
- package/style/base.css +4 -0
- package/lib/sdk/index.d.ts +0 -27
- package/lib/sdk/index.js +0 -33
package/lib/hooks/useUpload.js
CHANGED
|
@@ -20,27 +20,35 @@ export const useUploadForm = (url) => {
|
|
|
20
20
|
};
|
|
21
21
|
const uploadAndSubmit = async (formData) => {
|
|
22
22
|
setIsLoading(true);
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
23
|
+
try {
|
|
24
|
+
const { data } = await axios.post(url, formData, {
|
|
25
|
+
headers: {
|
|
26
|
+
'Content-Type': 'multipart/form-data',
|
|
27
|
+
Authorization: `Bearer ${token}`,
|
|
28
|
+
},
|
|
29
|
+
onUploadProgress: progressEvent => {
|
|
30
|
+
const progress = (progressEvent.loaded / progressEvent.total) * 50;
|
|
31
|
+
setProgress(progress);
|
|
32
|
+
},
|
|
33
|
+
onDownloadProgress: progressEvent => {
|
|
34
|
+
const progress = 50 + (progressEvent.loaded / progressEvent.total) * 50;
|
|
35
|
+
setProgress(progress);
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
setProgress(100);
|
|
39
|
+
await new Promise(resolve => {
|
|
40
|
+
setTimeout(() => resolve('success'), 500);
|
|
41
|
+
});
|
|
42
|
+
setIsSuccess(true);
|
|
43
|
+
setIsLoading(false);
|
|
44
|
+
setProgress(0);
|
|
45
|
+
return data;
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
setIsLoading(false);
|
|
49
|
+
setProgress(0);
|
|
50
|
+
throw error;
|
|
51
|
+
}
|
|
44
52
|
};
|
|
45
53
|
return { uploadAndSubmit, isSuccess, isLoading, progress, reset };
|
|
46
54
|
};
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
3
|
* Distributed under the terms of the Modified BSD License.
|
|
4
4
|
*/
|
|
5
|
+
// Export core components and utilities
|
|
6
|
+
export * from './components';
|
|
5
7
|
export * from './utils';
|
|
6
8
|
export * from './state';
|
|
7
9
|
export * from './collaboration';
|
|
@@ -9,14 +11,16 @@ export * from './services';
|
|
|
9
11
|
// Export navigation before hooks to avoid conflicts
|
|
10
12
|
export * from './navigation';
|
|
11
13
|
export * from './hooks';
|
|
12
|
-
// Export API
|
|
14
|
+
// Export API.
|
|
13
15
|
export { requestDatalayerAPI, RunResponseError, NetworkError, } from './api/DatalayerApi';
|
|
14
16
|
export { API_BASE_PATHS } from './api/constants';
|
|
15
17
|
export * as runtimesApi from './api/runtimes';
|
|
16
18
|
export * as iamApi from './api/iam';
|
|
17
19
|
export * as spacerApi from './api/spacer';
|
|
18
|
-
export {
|
|
19
|
-
// Export
|
|
20
|
+
export {
|
|
21
|
+
// Export client and config types
|
|
22
|
+
DatalayerClient,
|
|
23
|
+
// Export domain models
|
|
20
24
|
User, Runtime, Environment, Snapshot, Space, Notebook, LexicalDTO, Credits, Item, } from './client';
|
|
21
|
-
// Export commonly used
|
|
25
|
+
// Export commonly used functions directly for convenience
|
|
22
26
|
export { getEnvironments, createRuntime, getRuntimes, deleteRuntime, snapshotRuntime, getRuntimeSnapshots, loadRuntimeSnapshot, } from './stateful/runtimes/actions';
|
package/lib/stateful/index.d.ts
CHANGED
package/lib/stateful/index.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import { URLExt } from '@jupyterlab/coreutils';
|
|
9
9
|
import { PromiseDelegate } from '@lumino/coreutils';
|
|
10
10
|
import { Upload } from 'tus-js-client';
|
|
11
|
-
import { requestDatalayerAPI, } from '
|
|
11
|
+
import { requestDatalayerAPI, } from '../../api';
|
|
12
12
|
import { asRuntimeSnapshot } from '../../models';
|
|
13
13
|
import { iamStore, runtimesStore } from '../../state';
|
|
14
14
|
import { sleep } from '../../utils';
|
|
@@ -48,15 +48,15 @@ const datalayerThemeDefs = {
|
|
|
48
48
|
const { colorSchemes: primerSchemes, ...primerOthers } = cloneDeep(primerTheme);
|
|
49
49
|
const { colorSchemes: jupyterSchemes, ...datalayerOthers } = datalayerThemeDefs;
|
|
50
50
|
// Merge with the light theme to ensure all variables are defined (although the style may be ugly).
|
|
51
|
-
const
|
|
51
|
+
const datalayerTheme = merge(primerOthers, datalayerOthers, {
|
|
52
52
|
colorSchemes: { light: {}, dark: {} },
|
|
53
53
|
});
|
|
54
|
-
|
|
54
|
+
datalayerTheme.colorSchemes.light = {
|
|
55
55
|
colors: merge(primerSchemes.light.colors, jupyterSchemes.light.colors),
|
|
56
56
|
shadows: merge(primerSchemes.light.shadows, jupyterSchemes.light.shadows),
|
|
57
57
|
};
|
|
58
|
-
|
|
58
|
+
datalayerTheme.colorSchemes.dark = {
|
|
59
59
|
colors: merge(primerSchemes.dark.colors, jupyterSchemes.dark.colors),
|
|
60
60
|
shadows: merge(primerSchemes.dark.shadows, jupyterSchemes.dark.shadows),
|
|
61
61
|
};
|
|
62
|
-
export {
|
|
62
|
+
export { datalayerTheme };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { BaseStyles, ThemeProvider
|
|
2
|
+
import { BaseStyles, ThemeProvider } from '@primer/react';
|
|
3
3
|
export function DatalayerThemeProvider(props) {
|
|
4
4
|
const { children, colorMode, baseStyles, ...rest } = props;
|
|
5
|
-
return (_jsx(
|
|
5
|
+
return (_jsx(ThemeProvider, { colorMode: colorMode, ...rest, children: _jsx(BaseStyles, { style: {
|
|
6
6
|
backgroundColor: 'var(--bgColor-default)',
|
|
7
7
|
color: 'var(--fgColor-default)',
|
|
8
8
|
fontSize: 'var(--text-body-size-medium)',
|
package/lib/types.d.ts
ADDED
package/lib/types.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datalayer/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.17",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"workspaces": [
|
|
6
6
|
".",
|
|
@@ -85,10 +85,15 @@
|
|
|
85
85
|
"watch:lib:src": "tsc -b -w",
|
|
86
86
|
"type-check:watch": "tsc -b -w --noEmit",
|
|
87
87
|
"example": "vite --config vite.examples.config.ts",
|
|
88
|
+
"example:chat": "run-p jupyter:start example:chat:vite",
|
|
89
|
+
"example:chat:vite": "EXAMPLE=ChatExample vite --config vite.examples.config.ts",
|
|
88
90
|
"example:nextjs": "npm run dev --workspace=nextjs-notebook-example",
|
|
89
|
-
"
|
|
91
|
+
"jupyter:start": "./dev/sh/start-jupyter-server.sh",
|
|
92
|
+
"prepare": "husky",
|
|
93
|
+
"kill": "./dev/sh/kill.sh || true"
|
|
90
94
|
},
|
|
91
95
|
"dependencies": {
|
|
96
|
+
"@ai-sdk/react": "^2.0.34",
|
|
92
97
|
"@datalayer/icons-react": "^1.0.6",
|
|
93
98
|
"@datalayer/jupyter-react": "^1.1.0",
|
|
94
99
|
"@datalayer/primer-addons": "^1.0.4",
|
|
@@ -103,7 +108,9 @@
|
|
|
103
108
|
"@primer/react": "^37.19.0",
|
|
104
109
|
"@primer/react-brand": "^0.58.0",
|
|
105
110
|
"@stripe/react-stripe-js": "^2.7.1",
|
|
111
|
+
"@tailwindcss/vite": "^4.1.13",
|
|
106
112
|
"@tanstack/react-query": "^5.90.6",
|
|
113
|
+
"ai": "^5.0.78",
|
|
107
114
|
"axios": "^1.7.7",
|
|
108
115
|
"boring-avatars": "^2.0.1",
|
|
109
116
|
"buffer": "^6.0.3",
|
|
@@ -114,13 +121,18 @@
|
|
|
114
121
|
"html2canvas": "^1.4.1",
|
|
115
122
|
"jwt-decode": "^2.2.0",
|
|
116
123
|
"localforage": "^1.10.0",
|
|
124
|
+
"lucide-react": "^0.542.0",
|
|
117
125
|
"marked": "^4.0.10",
|
|
118
126
|
"mock-socket": "^9.3.1",
|
|
119
127
|
"react": "18.3.1",
|
|
120
128
|
"react-confetti": "^6.4.0",
|
|
121
129
|
"react-dom": "18.3.1",
|
|
122
130
|
"react-toastify": "^11.0.5",
|
|
131
|
+
"streamdown": "^1.6.6",
|
|
132
|
+
"tailwind-merge": "^3.3.1",
|
|
133
|
+
"tailwindcss": "^4.1.13",
|
|
123
134
|
"tus-js-client": "^4.2.3",
|
|
135
|
+
"tw-animate-css": "^1.4.0",
|
|
124
136
|
"ulid": "^2.3.0",
|
|
125
137
|
"unique-names-generator": "^4.7.1",
|
|
126
138
|
"usehooks-ts": "^2.9.1",
|
|
@@ -145,9 +157,11 @@
|
|
|
145
157
|
"@storybook/addon-vitest": "^9.1.1",
|
|
146
158
|
"@storybook/builder-vite": "^9.1.1",
|
|
147
159
|
"@storybook/react-vite": "^9.1.1",
|
|
160
|
+
"@tailwindcss/postcss": "^4.1.16",
|
|
148
161
|
"@types/node": "^20.11.0",
|
|
149
162
|
"@types/react": "18.3.20",
|
|
150
163
|
"@types/react-dom": "18.3.6",
|
|
164
|
+
"@types/react-syntax-highlighter": "^15.5.13",
|
|
151
165
|
"@vitejs/plugin-react": "^4.5.2",
|
|
152
166
|
"@vitest/browser": "^3.2.4",
|
|
153
167
|
"@vitest/coverage-v8": "^3.2.4",
|
package/style/base.css
CHANGED
package/lib/sdk/index.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Main SDK entry point for the Datalayer platform.
|
|
3
|
-
*
|
|
4
|
-
* This module provides the unified DatalayerSDK class with a flat, intuitive API
|
|
5
|
-
* for all Datalayer platform services. The SDK uses TypeScript mixins to provide
|
|
6
|
-
* excellent discoverability and ease of use.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```typescript
|
|
10
|
-
* import { DatalayerSDK } from '@datalayer/core/sdk';
|
|
11
|
-
*
|
|
12
|
-
* const sdk = new DatalayerSDK({
|
|
13
|
-
* token: 'your-api-token',
|
|
14
|
-
* baseUrl: 'https://prod1.datalayer.run'
|
|
15
|
-
* });
|
|
16
|
-
*
|
|
17
|
-
* // Flat, intuitive API - all methods directly accessible
|
|
18
|
-
* const user = await sdk.whoami();
|
|
19
|
-
* const environments = await sdk.listEnvironments();
|
|
20
|
-
* const runtime = await sdk.createRuntime(config);
|
|
21
|
-
* const notebook = await sdk.createNotebook(data);
|
|
22
|
-
* ```
|
|
23
|
-
*
|
|
24
|
-
* @module sdk
|
|
25
|
-
*/
|
|
26
|
-
export { DatalayerClient, type DatalayerClientConfig } from '../client';
|
|
27
|
-
export * from '../stateful';
|
package/lib/sdk/index.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
|
-
* Distributed under the terms of the Modified BSD License.
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Main SDK entry point for the Datalayer platform.
|
|
7
|
-
*
|
|
8
|
-
* This module provides the unified DatalayerSDK class with a flat, intuitive API
|
|
9
|
-
* for all Datalayer platform services. The SDK uses TypeScript mixins to provide
|
|
10
|
-
* excellent discoverability and ease of use.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```typescript
|
|
14
|
-
* import { DatalayerSDK } from '@datalayer/core/sdk';
|
|
15
|
-
*
|
|
16
|
-
* const sdk = new DatalayerSDK({
|
|
17
|
-
* token: 'your-api-token',
|
|
18
|
-
* baseUrl: 'https://prod1.datalayer.run'
|
|
19
|
-
* });
|
|
20
|
-
*
|
|
21
|
-
* // Flat, intuitive API - all methods directly accessible
|
|
22
|
-
* const user = await sdk.whoami();
|
|
23
|
-
* const environments = await sdk.listEnvironments();
|
|
24
|
-
* const runtime = await sdk.createRuntime(config);
|
|
25
|
-
* const notebook = await sdk.createNotebook(data);
|
|
26
|
-
* ```
|
|
27
|
-
*
|
|
28
|
-
* @module sdk
|
|
29
|
-
*/
|
|
30
|
-
// Export the main Client class with flat API
|
|
31
|
-
export { DatalayerClient } from '../client';
|
|
32
|
-
// Export stateful modules for advanced use cases
|
|
33
|
-
export * from '../stateful';
|