@datalayer/core 0.0.16 → 0.0.18
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 +9 -13
- package/lib/client/auth/AuthenticationManager.d.ts +95 -0
- package/lib/client/auth/AuthenticationManager.js +214 -0
- package/lib/client/auth/index.d.ts +8 -0
- package/lib/client/auth/index.js +17 -0
- package/lib/client/auth/storage.d.ts +154 -0
- package/lib/client/auth/storage.js +447 -0
- package/lib/client/auth/strategies.d.ts +54 -0
- package/lib/client/auth/strategies.js +238 -0
- package/lib/client/auth/types.d.ts +151 -0
- package/lib/{examples/index.js → client/auth/types.js} +4 -2
- package/lib/client/base.d.ts +3 -0
- package/lib/client/base.js +9 -0
- package/lib/client/index.d.ts +1 -0
- package/lib/client/index.js +2 -0
- package/lib/components/auth/Login.d.ts +40 -0
- package/lib/components/auth/Login.js +173 -0
- package/lib/components/auth/Login.stories.d.ts +54 -0
- package/lib/components/auth/Login.stories.js +104 -0
- package/lib/components/auth/LoginToken.d.ts +16 -0
- package/lib/components/auth/LoginToken.js +63 -0
- package/lib/components/auth/index.d.ts +5 -0
- package/lib/components/auth/index.js +16 -0
- package/lib/components/avatars/BoringAvatar.d.ts +6 -15
- package/lib/components/avatars/BoringAvatar.js +30 -34
- package/lib/components/avatars/BoringAvatar.stories.d.ts +7 -16
- package/lib/components/avatars/UserProfileAvatar.d.ts +1 -6
- package/lib/components/avatars/UserProfileAvatar.js +3 -8
- package/lib/components/buttons/DownloadCSVButton.d.ts +2 -7
- package/lib/components/buttons/DownloadCSVButton.js +1 -5
- package/lib/components/buttons/DownloadJsonButton.d.ts +3 -10
- package/lib/components/buttons/DownloadJsonButton.js +1 -7
- package/lib/components/buttons/UploadButton.d.ts +1 -4
- package/lib/components/buttons/UploadButton.js +3 -7
- package/lib/components/chat/ChatComponent.d.ts +4 -0
- package/lib/components/chat/ChatComponent.js +143 -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 +58 -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 +148 -0
- package/lib/components/chat/display/index.d.ts +4 -0
- package/lib/components/chat/display/index.js +13 -0
- package/lib/components/chat/handler.d.ts +8 -0
- package/lib/components/chat/handler.js +43 -0
- package/lib/components/chat/index.d.ts +4 -0
- package/lib/components/chat/index.js +13 -0
- package/lib/components/display/CenteredSpinner.d.ts +1 -4
- package/lib/components/display/CenteredSpinner.js +1 -5
- package/lib/components/display/HorizontalCenter.d.ts +1 -4
- package/lib/components/display/HorizontalCenter.js +1 -5
- package/lib/components/flashes/FlashClosable.d.ts +1 -4
- package/lib/components/flashes/FlashClosable.js +1 -5
- package/lib/components/flashes/FlashDisclaimer.js +1 -1
- package/lib/components/index.d.ts +2 -1
- package/lib/components/index.js +2 -1
- package/lib/components/notebooks/JupyterNotebook.d.ts +1 -6
- package/lib/components/notebooks/JupyterNotebook.js +1 -5
- package/lib/components/runtimes/RuntimeSimplePicker.d.ts +4 -0
- package/lib/components/runtimes/RuntimeSimplePicker.js +3 -3
- package/lib/components/snapshots/RuntimeSnapshotMenu.d.ts +1 -4
- package/lib/components/snapshots/RuntimeSnapshotMenu.js +1 -5
- package/lib/config/Configuration.js +1 -1
- package/lib/examples/CellExample.js +11 -47
- package/lib/examples/lexical-theme.css +436 -0
- package/lib/examples/notebooks/Matplotlib.ipynb.json +1 -1
- package/lib/examples/notebooks/NotebookExample1.ipynb.json +1 -1
- package/lib/hooks/useAIJupyterChat.d.ts +36 -0
- package/lib/hooks/useAIJupyterChat.js +53 -0
- package/lib/hooks/useBackdrop.d.ts +4 -4
- package/lib/hooks/useBackdrop.js +5 -9
- package/lib/hooks/useCache.d.ts +5 -1
- package/lib/hooks/useCache.js +126 -58
- package/lib/hooks/useMobile.d.ts +1 -0
- package/lib/hooks/useMobile.js +26 -0
- package/lib/hooks/useScreenshot.d.ts +3 -5
- package/lib/hooks/useScreenshot.js +1 -8
- package/lib/hooks/useUpload.js +29 -21
- package/lib/index.d.ts +1 -0
- package/lib/index.js +8 -4
- package/lib/models/Outbound.d.ts +2 -0
- package/lib/models/Outbound.js +3 -1
- package/lib/state/substates/CoreState.js +1 -1
- package/lib/state/substates/IAMState.js +15 -6
- 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/tools/adapters/agui/AgUIToolAdapter.d.ts +75 -0
- package/lib/tools/adapters/agui/AgUIToolAdapter.js +244 -0
- package/lib/tools/adapters/agui/index.d.ts +10 -0
- package/lib/tools/adapters/agui/index.js +19 -0
- package/lib/tools/adapters/agui/lexicalHooks.d.ts +27 -0
- package/lib/tools/adapters/agui/lexicalHooks.js +64 -0
- package/lib/tools/adapters/agui/notebookHooks.d.ts +27 -0
- package/lib/tools/adapters/agui/notebookHooks.js +61 -0
- package/lib/tools/index.d.ts +6 -0
- package/lib/tools/index.js +18 -0
- package/lib/types.d.ts +5 -0
- package/lib/types.js +5 -0
- package/lib/utils/cli/index.d.ts +4 -0
- package/lib/utils/cli/index.js +13 -0
- package/lib/utils/cli/query.d.ts +6 -0
- package/lib/utils/cli/query.js +26 -0
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.js +1 -0
- package/package.json +62 -5
- package/style/base.css +4 -0
- package/lib/examples/DatalayerNotebookExample.d.ts +0 -16
- package/lib/examples/DatalayerNotebookExample.js +0 -75
- package/lib/examples/NativeNavigationExample.d.ts +0 -8
- package/lib/examples/NativeNavigationExample.js +0 -97
- package/lib/examples/NotebookMutationsKernel.d.ts +0 -2
- package/lib/examples/NotebookMutationsKernel.js +0 -115
- package/lib/examples/NotebookMutationsServiceManager.d.ts +0 -2
- package/lib/examples/NotebookMutationsServiceManager.js +0 -107
- package/lib/examples/ReactRouterExample.d.ts +0 -6
- package/lib/examples/ReactRouterExample.js +0 -175
- package/lib/examples/example-selector.d.ts +0 -22
- package/lib/examples/example-selector.js +0 -45
- package/lib/examples/index.d.ts +0 -2
- package/lib/examples/main.d.ts +0 -1
- package/lib/examples/main.js +0 -153
- package/lib/examples/notebooks/OutputIPyWidgetsExample.d.ts +0 -145
- package/lib/examples/notebooks/OutputIPyWidgetsExample.js +0 -153
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
|
+
* Distributed under the terms of the Modified BSD License.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* React hooks and components for ag-ui (CopilotKit) notebook tool registration.
|
|
7
|
+
* Provides: useNotebookToolActions, ActionRegistrar, UseFrontendToolFn.
|
|
8
|
+
*
|
|
9
|
+
* @module tools/adapters/agui/notebookHooks
|
|
10
|
+
*/
|
|
11
|
+
import { useMemo } from 'react';
|
|
12
|
+
// TODO: Re-enable when @datalayer/jupyter-react exports these
|
|
13
|
+
// import type { ToolExecutionContext } from '@datalayer/jupyter-react';
|
|
14
|
+
import { createAllCopilotKitActions, ActionRegistrar, } from './AgUIToolAdapter';
|
|
15
|
+
// Import from patched @datalayer/jupyter-react package
|
|
16
|
+
import { notebookStore2, DefaultExecutor, notebookToolDefinitions, notebookToolOperations, } from '@datalayer/jupyter-react';
|
|
17
|
+
// Hook wrapper to get notebook store state
|
|
18
|
+
const useNotebookStore2 = () => notebookStore2.getState();
|
|
19
|
+
// Re-export shared types and components for convenience
|
|
20
|
+
export { ActionRegistrar };
|
|
21
|
+
/**
|
|
22
|
+
* Hook that creates CopilotKit actions for notebook tools.
|
|
23
|
+
* Returns stable actions array that won't cause re-renders.
|
|
24
|
+
*
|
|
25
|
+
* @param documentId - Document ID (notebook identifier)
|
|
26
|
+
* @param contextOverrides - Optional context overrides (format, extras, etc.)
|
|
27
|
+
* @returns CopilotKit actions
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* // Default context (toon format for AI)
|
|
32
|
+
* const actions = useNotebookToolActions("my-notebook-id");
|
|
33
|
+
*
|
|
34
|
+
* // Custom format
|
|
35
|
+
* const actions = useNotebookToolActions("my-notebook-id", { format: 'json' });
|
|
36
|
+
*
|
|
37
|
+
* // With extras
|
|
38
|
+
* const actions = useNotebookToolActions("my-notebook-id", {
|
|
39
|
+
* format: 'toon',
|
|
40
|
+
* extras: { userId: '123', theme: 'dark' }
|
|
41
|
+
* });
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export function useNotebookToolActions(documentId, contextOverrides) {
|
|
45
|
+
const notebookStore = useNotebookStore2();
|
|
46
|
+
// Create DefaultExecutor (stable reference)
|
|
47
|
+
// Only recreate when documentId changes, not on every state update
|
|
48
|
+
// The executor holds a reference to the store which is always current
|
|
49
|
+
const executor = useMemo(() => new DefaultExecutor(documentId, notebookStore), [documentId]);
|
|
50
|
+
// Create stable context object with useMemo
|
|
51
|
+
// Defaults: format='toon' for conversational AI responses
|
|
52
|
+
// Can be overridden with contextOverrides parameter
|
|
53
|
+
const context = useMemo(() => ({
|
|
54
|
+
documentId,
|
|
55
|
+
executor,
|
|
56
|
+
format: 'toon', // Default format
|
|
57
|
+
...contextOverrides, // Override with user-provided values
|
|
58
|
+
}), [documentId, executor, contextOverrides]);
|
|
59
|
+
// Create and return CopilotKit actions (stable reference)
|
|
60
|
+
return useMemo(() => createAllCopilotKitActions(notebookToolDefinitions, notebookToolOperations, context), [context]);
|
|
61
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
|
+
* Distributed under the terms of the Modified BSD License.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Platform-agnostic tools for notebook and lexical integration with AI frameworks
|
|
7
|
+
*
|
|
8
|
+
* @module tools
|
|
9
|
+
*/
|
|
10
|
+
// Export adapters
|
|
11
|
+
export * from './adapters/agui';
|
|
12
|
+
// TODO: Re-export tool types from jupyter-react when available
|
|
13
|
+
// export type {
|
|
14
|
+
// ToolDefinition,
|
|
15
|
+
// ToolConfig,
|
|
16
|
+
// ToolOperation,
|
|
17
|
+
// ToolExecutionContext,
|
|
18
|
+
// } from '@datalayer/jupyter-react';
|
package/lib/types.d.ts
ADDED
package/lib/types.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
|
+
* Distributed under the terms of the Modified BSD License.
|
|
4
|
+
*/
|
|
5
|
+
/*
|
|
6
|
+
* Copyright (c) 2021-2024 Datalayer, Inc.
|
|
7
|
+
*
|
|
8
|
+
* Datalayer License
|
|
9
|
+
*/
|
|
10
|
+
import { QueryClient } from '@tanstack/react-query';
|
|
11
|
+
/**
|
|
12
|
+
* Shared QueryClient instance for TanStack Query
|
|
13
|
+
* Used across the application for consistent cache management
|
|
14
|
+
*/
|
|
15
|
+
export const queryClient = new QueryClient({
|
|
16
|
+
defaultOptions: {
|
|
17
|
+
queries: {
|
|
18
|
+
staleTime: 1000 * 60 * 5, // 5 minutes
|
|
19
|
+
refetchOnMount: false, // Don't refetch on mount if data is still fresh
|
|
20
|
+
refetchOnWindowFocus: false,
|
|
21
|
+
retry: 1,
|
|
22
|
+
// Ensure queries prioritize cache over network when data is fresh
|
|
23
|
+
networkMode: 'online',
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
});
|
package/lib/utils/index.d.ts
CHANGED
package/lib/utils/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datalayer/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.18",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"workspaces": [
|
|
6
6
|
".",
|
|
@@ -48,6 +48,7 @@
|
|
|
48
48
|
"clean": "rimraf lib dist build tsconfig.tsbuildinfo",
|
|
49
49
|
"clean:lib": "rimraf lib tsconfig.tsbuildinfo",
|
|
50
50
|
"clean:dist": "rimraf dist",
|
|
51
|
+
"clean:cache": "rimraf node_modules/.vite",
|
|
51
52
|
"build": "npm run clean && gulp resources-to-lib && tsc -b && vite build",
|
|
52
53
|
"build:lib": "npm run clean:lib && gulp resources-to-lib && tsc -b",
|
|
53
54
|
"build:types": "npm run clean:lib && tsc -b",
|
|
@@ -84,18 +85,50 @@
|
|
|
84
85
|
"watch:lib:res": "gulp resources-to-lib-watch",
|
|
85
86
|
"watch:lib:src": "tsc -b -w",
|
|
86
87
|
"type-check:watch": "tsc -b -w --noEmit",
|
|
87
|
-
"
|
|
88
|
-
"
|
|
89
|
-
"
|
|
88
|
+
"examples": "vite --config vite.examples.config.ts",
|
|
89
|
+
"examples:chat": "run-p jupyter:start example:chat:vite",
|
|
90
|
+
"examples:chat:vite": "EXAMPLE=ChatExample vite --config vite.examples.config.ts",
|
|
91
|
+
"examples:nextjs": "npm run dev --workspace=nextjs-notebook-example",
|
|
92
|
+
"jupyter:start": "./dev/sh/start-jupyter-server.sh",
|
|
93
|
+
"prepare": "husky",
|
|
94
|
+
"postinstall": "bash scripts/apply-patches.sh",
|
|
95
|
+
"kill": "./dev/sh/kill.sh || true",
|
|
96
|
+
"sync:jupyter": "bash scripts/sync-jupyter.sh",
|
|
97
|
+
"sync:jupyter:watch": "bash scripts/sync-jupyter.sh --watch",
|
|
98
|
+
"create:patches": "bash scripts/create-patches.sh",
|
|
99
|
+
"apply:patches": "bash scripts/apply-patches.sh",
|
|
100
|
+
"examples:fresh": "npm run clean:cache && npm run examples",
|
|
101
|
+
"rebuild:fresh": "npm run create:patches && npm install && npm run build && npm run clean:cache"
|
|
90
102
|
},
|
|
91
103
|
"dependencies": {
|
|
104
|
+
"@ai-sdk/react": "^2.0.34",
|
|
105
|
+
"@copilotkit/react-core": "^1.10.6",
|
|
106
|
+
"@copilotkit/react-ui": "^1.10.6",
|
|
92
107
|
"@datalayer/icons-react": "^1.0.6",
|
|
93
|
-
"@datalayer/jupyter-
|
|
108
|
+
"@datalayer/jupyter-lexical": "^1.0.6",
|
|
109
|
+
"@datalayer/jupyter-react": "^1.1.8",
|
|
94
110
|
"@datalayer/primer-addons": "^1.0.4",
|
|
95
111
|
"@datalayer/primer-rjsf": "^1.0.1",
|
|
112
|
+
"@jupyter-widgets/base-manager": "^1.0.12",
|
|
113
|
+
"@jupyter-widgets/schema": "^0.5.6",
|
|
114
|
+
"@jupyterlab/apputils": "^4.6.0",
|
|
115
|
+
"@jupyterlab/cells": "^4.5.0",
|
|
116
|
+
"@jupyterlab/codeeditor": "^4.5.0",
|
|
96
117
|
"@jupyterlab/coreutils": "^6.0.0",
|
|
118
|
+
"@jupyterlab/documentsearch": "^4.5.0",
|
|
119
|
+
"@jupyterlab/rendermime": "^4.5.0",
|
|
97
120
|
"@jupyterlab/services": "^7.0.0",
|
|
121
|
+
"@jupyterlab/translation": "^4.5.0",
|
|
122
|
+
"@jupyterlab/ui-components": "^4.5.0",
|
|
98
123
|
"@jupyterlite/javascript-kernel-extension": "^0.3.0",
|
|
124
|
+
"@lumino/commands": "^2.3.3",
|
|
125
|
+
"@lumino/coreutils": "^2.2.2",
|
|
126
|
+
"@lumino/datagrid": "^2.5.3",
|
|
127
|
+
"@lumino/disposable": "^2.1.5",
|
|
128
|
+
"@lumino/polling": "^2.1.5",
|
|
129
|
+
"@lumino/signaling": "^2.1.5",
|
|
130
|
+
"@lumino/widgets": "^2.7.2",
|
|
131
|
+
"@primer/behaviors": "^1.8.4",
|
|
99
132
|
"@primer/brand-primitives": "^0.51.0",
|
|
100
133
|
"@primer/css": "^21.5.1",
|
|
101
134
|
"@primer/octicons-react": "^19.15.1",
|
|
@@ -103,29 +136,45 @@
|
|
|
103
136
|
"@primer/react": "^37.19.0",
|
|
104
137
|
"@primer/react-brand": "^0.58.0",
|
|
105
138
|
"@stripe/react-stripe-js": "^2.7.1",
|
|
139
|
+
"@stripe/stripe-js": "^4.0.0",
|
|
140
|
+
"@styled-system/css": "^5.1.5",
|
|
141
|
+
"@tailwindcss/vite": "^4.1.13",
|
|
106
142
|
"@tanstack/react-query": "^5.90.6",
|
|
143
|
+
"@toon-format/toon": "^1.3.0",
|
|
144
|
+
"ai": "^5.0.78",
|
|
145
|
+
"ansi-to-html": "^0.7.2",
|
|
107
146
|
"axios": "^1.7.7",
|
|
108
147
|
"boring-avatars": "^2.0.1",
|
|
109
148
|
"buffer": "^6.0.3",
|
|
110
149
|
"date-fns": "^2.29.3",
|
|
150
|
+
"deepmerge": "^4.3.1",
|
|
111
151
|
"echarts": "^5.5.0",
|
|
112
152
|
"echarts-for-react": "^3.0.2",
|
|
113
153
|
"fuse.js": "^7.0.0",
|
|
114
154
|
"html2canvas": "^1.4.1",
|
|
115
155
|
"jwt-decode": "^2.2.0",
|
|
116
156
|
"localforage": "^1.10.0",
|
|
157
|
+
"lucide-react": "^0.542.0",
|
|
117
158
|
"marked": "^4.0.10",
|
|
118
159
|
"mock-socket": "^9.3.1",
|
|
119
160
|
"react": "18.3.1",
|
|
120
161
|
"react-confetti": "^6.4.0",
|
|
121
162
|
"react-dom": "18.3.1",
|
|
163
|
+
"react-is": "^19.2.0",
|
|
122
164
|
"react-toastify": "^11.0.5",
|
|
165
|
+
"streamdown": "^1.6.6",
|
|
166
|
+
"styled-system": "^5.1.5",
|
|
167
|
+
"tailwind-merge": "^3.3.1",
|
|
168
|
+
"tailwindcss": "^4.1.13",
|
|
169
|
+
"tslib": "^2.8.1",
|
|
123
170
|
"tus-js-client": "^4.2.3",
|
|
171
|
+
"tw-animate-css": "^1.4.0",
|
|
124
172
|
"ulid": "^2.3.0",
|
|
125
173
|
"unique-names-generator": "^4.7.1",
|
|
126
174
|
"usehooks-ts": "^2.9.1",
|
|
127
175
|
"uuid": "^13.0.0",
|
|
128
176
|
"validator": "^13.7.0",
|
|
177
|
+
"zod": "^4.1.13",
|
|
129
178
|
"zustand": "^4.4.1"
|
|
130
179
|
},
|
|
131
180
|
"peerDependencies": {
|
|
@@ -145,13 +194,17 @@
|
|
|
145
194
|
"@storybook/addon-vitest": "^9.1.1",
|
|
146
195
|
"@storybook/builder-vite": "^9.1.1",
|
|
147
196
|
"@storybook/react-vite": "^9.1.1",
|
|
197
|
+
"@tailwindcss/postcss": "^4.1.16",
|
|
148
198
|
"@types/node": "^20.11.0",
|
|
149
199
|
"@types/react": "18.3.20",
|
|
150
200
|
"@types/react-dom": "18.3.6",
|
|
201
|
+
"@types/react-syntax-highlighter": "^15.5.13",
|
|
151
202
|
"@vitejs/plugin-react": "^4.5.2",
|
|
152
203
|
"@vitest/browser": "^3.2.4",
|
|
153
204
|
"@vitest/coverage-v8": "^3.2.4",
|
|
154
205
|
"abort-controller": "^3.0.0",
|
|
206
|
+
"autoprefixer": "^10.4.21",
|
|
207
|
+
"buffer": "^6.0.3",
|
|
155
208
|
"crypto-browserify": "^3.12.1",
|
|
156
209
|
"dotenv": "^17.2.2",
|
|
157
210
|
"eslint": "^9.29.0",
|
|
@@ -170,6 +223,7 @@
|
|
|
170
223
|
"jsdom": "^26.0.0",
|
|
171
224
|
"lint-staged": "^16.1.5",
|
|
172
225
|
"npm-run-all": "^4.1.5",
|
|
226
|
+
"patch-package": "^8.0.0",
|
|
173
227
|
"playwright": "^1.53.2",
|
|
174
228
|
"prettier": "^3.6.2",
|
|
175
229
|
"react-router-dom": "^6.22.3",
|
|
@@ -205,5 +259,8 @@
|
|
|
205
259
|
"src/**/*.{css,json,md}": [
|
|
206
260
|
"prettier --write"
|
|
207
261
|
]
|
|
262
|
+
},
|
|
263
|
+
"optionalDependencies": {
|
|
264
|
+
"keytar": "^7.9.0"
|
|
208
265
|
}
|
|
209
266
|
}
|
package/style/base.css
CHANGED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { ServiceManager } from '@jupyterlab/services';
|
|
2
|
-
/**
|
|
3
|
-
* Example demonstrating how to use Datalayer services with Notebook
|
|
4
|
-
*
|
|
5
|
-
* This example shows:
|
|
6
|
-
* 1. How to create and use DatalayerServiceManager for kernel management
|
|
7
|
-
* 2. How to create and use DatalayerCollaborationProvider for real-time collaboration
|
|
8
|
-
* 3. How to enable/disable Datalayer collaboration
|
|
9
|
-
* 4. How to pass these to the base Notebook component
|
|
10
|
-
* 5. Graceful fallback when Datalayer credentials are not available
|
|
11
|
-
*/
|
|
12
|
-
type IDatalayerNotebookExampleProps = {
|
|
13
|
-
serviceManager?: ServiceManager.IManager;
|
|
14
|
-
};
|
|
15
|
-
declare const DatalayerNotebookExample: (props: IDatalayerNotebookExampleProps) => import("react/jsx-runtime").JSX.Element;
|
|
16
|
-
export default DatalayerNotebookExample;
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } 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 { useState, useEffect, useMemo } from 'react';
|
|
7
|
-
import { Box, Checkbox, FormControl, Heading } from '@primer/react';
|
|
8
|
-
import { loadJupyterConfig, JupyterReactTheme, Notebook2, } from '@datalayer/jupyter-react';
|
|
9
|
-
import { DatalayerCollaborationProvider } from '../collaboration/DatalayerCollaborationProvider';
|
|
10
|
-
import { createDatalayerServiceManager } from '../services/DatalayerServiceManager';
|
|
11
|
-
import { useCoreStore } from '../state/substates/CoreState';
|
|
12
|
-
import nbformatExample from './notebooks/NotebookExample1.ipynb.json';
|
|
13
|
-
// This corresponds to the notebook ID in the URL when you open an existing notbook in your library
|
|
14
|
-
const NOTEBOOK_ID = '01JZQRQ35GG871QQCZW9TB1A8J';
|
|
15
|
-
const DatalayerNotebookExample = (props) => {
|
|
16
|
-
// Load config on component mount
|
|
17
|
-
loadJupyterConfig();
|
|
18
|
-
const [nbformat] = useState(nbformatExample);
|
|
19
|
-
const [enableCollaboration, setEnableCollaboration] = useState(false);
|
|
20
|
-
const [readonly] = useState(false);
|
|
21
|
-
const [serviceManager, setServiceManager] = useState(props.serviceManager);
|
|
22
|
-
const { configuration } = useCoreStore();
|
|
23
|
-
useEffect(() => {
|
|
24
|
-
// Create DatalayerServiceManager if not provided
|
|
25
|
-
const createManager = async () => {
|
|
26
|
-
if (props.serviceManager) {
|
|
27
|
-
// Use provided service manager (should be DatalayerServiceManager from main.tsx)
|
|
28
|
-
// Wait for it to be ready
|
|
29
|
-
await props.serviceManager.ready;
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
// Create DatalayerServiceManager if we have credentials
|
|
33
|
-
if (configuration?.token && configuration?.runUrl) {
|
|
34
|
-
try {
|
|
35
|
-
console.log('Creating DatalayerServiceManager for Datalayer infrastructure');
|
|
36
|
-
// Now we can pass undefined to use config/defaults
|
|
37
|
-
const manager = await createDatalayerServiceManager(configuration?.cpuEnvironment, configuration?.credits);
|
|
38
|
-
await manager.ready;
|
|
39
|
-
setServiceManager(manager);
|
|
40
|
-
}
|
|
41
|
-
catch (error) {
|
|
42
|
-
console.error('Failed to create DatalayerServiceManager:', error);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
console.warn('Datalayer credentials not configured. Please set runUrl and token.');
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
createManager();
|
|
50
|
-
}, [props.serviceManager, configuration]);
|
|
51
|
-
// Create the collaboration provider when enabled
|
|
52
|
-
const collaborationProvider = useMemo(() => {
|
|
53
|
-
if (!enableCollaboration) {
|
|
54
|
-
return undefined;
|
|
55
|
-
}
|
|
56
|
-
const runUrl = configuration?.runUrl;
|
|
57
|
-
const token = configuration?.token;
|
|
58
|
-
if (!runUrl || !token) {
|
|
59
|
-
console.warn('Datalayer collaboration enabled but runUrl or token not configured. ' +
|
|
60
|
-
'Please configure them in the Datalayer store or environment.');
|
|
61
|
-
return undefined;
|
|
62
|
-
}
|
|
63
|
-
// Create and return the Datalayer collaboration provider
|
|
64
|
-
return new DatalayerCollaborationProvider({
|
|
65
|
-
runUrl,
|
|
66
|
-
token,
|
|
67
|
-
});
|
|
68
|
-
}, [enableCollaboration, configuration]);
|
|
69
|
-
return (_jsx(JupyterReactTheme, { children: _jsxs(Box, { p: 3, children: [_jsx(Heading, { as: "h2", sx: { mb: 3 }, children: "DatalayerNotebook Collaboration Example" }), _jsx(Box, { sx: { mb: 3 }, children: _jsxs(FormControl, { children: [_jsx(Checkbox, { checked: enableCollaboration, onChange: e => setEnableCollaboration(e.target.checked) }), _jsx(FormControl.Label, { children: "Enable Datalayer Collaboration" })] }) }), (!configuration?.runUrl || !configuration?.token) && (_jsx(Box, { sx: { mb: 2, p: 2, bg: 'danger.subtle' }, children: "Warning: Datalayer configuration is missing. Please configure runUrl and token to use DatalayerServiceManager and collaboration features." })), !serviceManager && (_jsx(Box, { sx: { mb: 2, p: 2, bg: 'attention.subtle' }, children: "Note: DatalayerServiceManager is not available. Notebook functionality will be limited." })), _jsx(Box, { sx: {
|
|
70
|
-
border: '1px solid',
|
|
71
|
-
borderColor: 'border.default',
|
|
72
|
-
borderRadius: 2,
|
|
73
|
-
}, children: serviceManager ? (_jsx(Notebook2, { id: NOTEBOOK_ID, height: "calc(100vh - 200px)", nbformat: nbformat, readonly: readonly, serviceManager: serviceManager, startDefaultKernel: true, collaborationProvider: collaborationProvider })) : (_jsx(Box, { sx: { p: 4, textAlign: 'center' }, children: "Loading ServiceManager..." })) }), _jsxs(Box, { sx: { mt: 2, fontSize: 1, color: 'fg.subtle' }, children: [_jsx("p", { children: "This example demonstrates how to use Datalayer services with Notebook:" }), _jsxs("ul", { children: [_jsxs("li", { children: [_jsx("strong", { children: "DatalayerServiceManager:" }), " Connects to Datalayer infrastructure for kernel management"] }), _jsxs("li", { children: [_jsx("strong", { children: "DatalayerCollaborationProvider:" }), " Enables real-time collaboration"] }), _jsx("li", { children: "Both require Datalayer credentials (runUrl and token)" }), _jsx("li", { children: "Pass them directly to the base Notebook component" }), _jsx("li", { children: "No wrapper components needed - just create the services and pass them as props" }), _jsx("li", { children: "This shows the explicit, composable pattern for Datalayer integration" })] })] })] }) }));
|
|
74
|
-
};
|
|
75
|
-
export default DatalayerNotebookExample;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
/**
|
|
3
|
-
* Native Navigation Example
|
|
4
|
-
* This example demonstrates the navigation hooks WITHOUT React Router.
|
|
5
|
-
* The hooks should automatically detect the absence of React Router and fall back to native browser navigation.
|
|
6
|
-
*/
|
|
7
|
-
export declare const NativeNavigationExample: React.FC;
|
|
8
|
-
export default NativeNavigationExample;
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } 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 { useState, useEffect } from 'react';
|
|
7
|
-
import { Box, Button, Heading, Text, Link as PrimerLink } from '@primer/react';
|
|
8
|
-
import { useNavigate, useLocation, useParams, useHistory } from '../hooks';
|
|
9
|
-
/**
|
|
10
|
-
* Native Navigation Example
|
|
11
|
-
* This example demonstrates the navigation hooks WITHOUT React Router.
|
|
12
|
-
* The hooks should automatically detect the absence of React Router and fall back to native browser navigation.
|
|
13
|
-
*/
|
|
14
|
-
export const NativeNavigationExample = () => {
|
|
15
|
-
const navigate = useNavigate();
|
|
16
|
-
const location = useLocation();
|
|
17
|
-
const params = useParams();
|
|
18
|
-
const history = useHistory();
|
|
19
|
-
const [navigationType, setNavigationType] = useState('detecting...');
|
|
20
|
-
const [navigationCount, setNavigationCount] = useState(0);
|
|
21
|
-
const [currentView, setCurrentView] = useState('home');
|
|
22
|
-
// Track navigation type detection
|
|
23
|
-
useEffect(() => {
|
|
24
|
-
// Since we're not using React Router, this should detect as 'native'
|
|
25
|
-
setNavigationType('native');
|
|
26
|
-
}, []);
|
|
27
|
-
// Track navigation events
|
|
28
|
-
useEffect(() => {
|
|
29
|
-
setNavigationCount(prev => prev + 1);
|
|
30
|
-
// Parse the path to determine which view to show
|
|
31
|
-
const path = location.pathname;
|
|
32
|
-
if (path.includes('page1')) {
|
|
33
|
-
setCurrentView('page1');
|
|
34
|
-
}
|
|
35
|
-
else if (path.includes('page2')) {
|
|
36
|
-
setCurrentView('page2');
|
|
37
|
-
}
|
|
38
|
-
else if (path.includes('page3')) {
|
|
39
|
-
setCurrentView('page3');
|
|
40
|
-
}
|
|
41
|
-
else if (path.includes('user')) {
|
|
42
|
-
setCurrentView('user');
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
setCurrentView('home');
|
|
46
|
-
}
|
|
47
|
-
}, [location]);
|
|
48
|
-
const handleProgrammaticNavigation = () => {
|
|
49
|
-
navigate('/page3', undefined, true);
|
|
50
|
-
};
|
|
51
|
-
const handleNavigateWithQuery = () => {
|
|
52
|
-
navigate('/page2?test=456&native=true', undefined, true);
|
|
53
|
-
};
|
|
54
|
-
const handleNavigateWithHash = () => {
|
|
55
|
-
navigate('/page3#native-section', undefined, true);
|
|
56
|
-
};
|
|
57
|
-
const handleBackNavigation = () => {
|
|
58
|
-
history.back();
|
|
59
|
-
};
|
|
60
|
-
const handleForwardNavigation = () => {
|
|
61
|
-
history.forward();
|
|
62
|
-
};
|
|
63
|
-
const handleReplaceNavigation = () => {
|
|
64
|
-
history.replace('/replaced-page', { replaced: true });
|
|
65
|
-
};
|
|
66
|
-
// Simple link handler for native navigation
|
|
67
|
-
const handleLinkClick = (e, path) => {
|
|
68
|
-
e.preventDefault();
|
|
69
|
-
navigate(path, e, true);
|
|
70
|
-
};
|
|
71
|
-
// Render different content based on current view
|
|
72
|
-
const renderContent = () => {
|
|
73
|
-
switch (currentView) {
|
|
74
|
-
case 'page1':
|
|
75
|
-
return (_jsxs(_Fragment, { children: [_jsx(Heading, { as: "h1", sx: { mb: 3 }, children: "Page 1 (Native)" }), _jsx(Text, { as: "p", children: "You've navigated to Page 1 using native browser navigation." })] }));
|
|
76
|
-
case 'page2':
|
|
77
|
-
return (_jsxs(_Fragment, { children: [_jsx(Heading, { as: "h1", sx: { mb: 3 }, children: "Page 2 (Native)" }), _jsx(Text, { as: "p", children: "This is Page 2 with native navigation. Check the query parameters!" })] }));
|
|
78
|
-
case 'page3':
|
|
79
|
-
return (_jsxs(_Fragment, { children: [_jsx(Heading, { as: "h1", sx: { mb: 3 }, children: "Page 3 (Native)" }), _jsx(Text, { as: "p", children: "Welcome to Page 3 using native browser APIs. Notice the hash in the URL!" })] }));
|
|
80
|
-
case 'user':
|
|
81
|
-
return (_jsxs(_Fragment, { children: [_jsx(Heading, { as: "h1", sx: { mb: 3 }, children: "User Page (Native)" }), _jsxs(Text, { as: "p", children: ["User pages with native navigation. Path: ", location.pathname] })] }));
|
|
82
|
-
default:
|
|
83
|
-
return (_jsxs(_Fragment, { children: [_jsx(Heading, { as: "h1", sx: { mb: 3 }, children: "Home Page (Native)" }), _jsx(Text, { as: "p", children: "This is the home page of the Native navigation example." })] }));
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
return (_jsxs(Box, { sx: { minHeight: '100vh', p: 4 }, children: [_jsxs(Box, { sx: { mb: 4, p: 3, bg: 'canvas.subtle', borderRadius: 2 }, children: [_jsx(Heading, { as: "h1", sx: { mb: 2 }, children: "Native Browser Navigation Example" }), _jsx(Text, { as: "p", sx: { mb: 2 }, children: "This example demonstrates the navigation hooks WITHOUT React Router context. The hooks automatically fall back to native browser navigation (history API)." }), _jsx(Text, { as: "p", sx: { color: 'attention.fg', fontWeight: 'bold' }, children: "\u26A0\uFE0F No React Router is loaded in this example - using native browser APIs only!" })] }), renderContent(), _jsxs(Box, { sx: { mt: 4 }, children: [_jsx(Heading, { as: "h2", sx: { mb: 3 }, children: "Navigation Information" }), _jsxs(Box, { sx: {
|
|
87
|
-
mb: 4,
|
|
88
|
-
p: 3,
|
|
89
|
-
borderWidth: 1,
|
|
90
|
-
borderStyle: 'solid',
|
|
91
|
-
borderColor: 'border.default',
|
|
92
|
-
borderRadius: 2,
|
|
93
|
-
}, children: [_jsxs(Text, { as: "p", sx: { mb: 2 }, children: [_jsx("strong", { children: "Navigation Type Detected:" }), ' ', _jsx(Text, { as: "span", sx: {
|
|
94
|
-
color: navigationType === 'native' ? 'success.fg' : 'danger.fg',
|
|
95
|
-
}, children: navigationType })] }), _jsxs(Text, { as: "p", sx: { mb: 2 }, children: [_jsx("strong", { children: "Current Path:" }), " ", location.pathname] }), _jsxs(Text, { as: "p", sx: { mb: 2 }, children: [_jsx("strong", { children: "Search Params:" }), " ", location.search || '(none)'] }), _jsxs(Text, { as: "p", sx: { mb: 2 }, children: [_jsx("strong", { children: "Hash:" }), " ", location.hash || '(none)'] }), _jsxs(Text, { as: "p", sx: { mb: 2 }, children: [_jsx("strong", { children: "Location Key:" }), " ", location.key] }), _jsxs(Text, { as: "p", sx: { mb: 2 }, children: [_jsx("strong", { children: "State:" }), " ", JSON.stringify(location.state) || '(none)'] }), _jsxs(Text, { as: "p", sx: { mb: 2 }, children: [_jsx("strong", { children: "URL Params (parsed from search):" }), ' ', JSON.stringify(params)] }), _jsxs(Text, { as: "p", children: [_jsx("strong", { children: "Navigation Count:" }), " ", navigationCount] })] }), _jsxs(Box, { sx: { mb: 3 }, children: [_jsx(Heading, { as: "h3", sx: { mb: 2 }, children: "Test Programmatic Navigation" }), _jsxs(Box, { sx: { display: 'flex', gap: 2, flexWrap: 'wrap' }, children: [_jsx(Button, { onClick: handleProgrammaticNavigation, children: "Navigate to /page3" }), _jsx(Button, { onClick: handleNavigateWithQuery, variant: "default", children: "Navigate with Query Params" }), _jsx(Button, { onClick: handleNavigateWithHash, variant: "default", children: "Navigate with Hash" }), _jsx(Button, { onClick: handleReplaceNavigation, variant: "default", children: "Replace Current Entry" })] })] }), _jsxs(Box, { sx: { mb: 3 }, children: [_jsx(Heading, { as: "h3", sx: { mb: 2 }, children: "Test History API" }), _jsxs(Box, { sx: { display: 'flex', gap: 2, flexWrap: 'wrap' }, children: [_jsx(Button, { onClick: handleBackNavigation, variant: "default", children: "History Back" }), _jsx(Button, { onClick: handleForwardNavigation, variant: "default", children: "History Forward" })] })] }), _jsxs(Box, { sx: { mb: 3 }, children: [_jsx(Heading, { as: "h3", sx: { mb: 2 }, children: "Test Link Navigation" }), _jsxs(Box, { sx: { display: 'flex', gap: 3, flexWrap: 'wrap' }, children: [_jsx(PrimerLink, { href: "/", onClick: e => handleLinkClick(e, '/'), sx: { cursor: 'pointer' }, children: "Home" }), _jsx(PrimerLink, { href: "/page1", onClick: e => handleLinkClick(e, '/page1'), sx: { cursor: 'pointer' }, children: "Page 1" }), _jsx(PrimerLink, { href: "/page2?test=123", onClick: e => handleLinkClick(e, '/page2?test=123'), sx: { cursor: 'pointer' }, children: "Page 2 with Query" }), _jsx(PrimerLink, { href: "/page3#section", onClick: e => handleLinkClick(e, '/page3#section'), sx: { cursor: 'pointer' }, children: "Page 3 with Hash" }), _jsx(PrimerLink, { href: "/user/456", onClick: e => handleLinkClick(e, '/user/456'), sx: { cursor: 'pointer' }, children: "User 456" })] })] }), _jsxs(Box, { sx: { mt: 4, p: 3, bg: 'attention.subtle', borderRadius: 2 }, children: [_jsx(Heading, { as: "h3", sx: { mb: 2 }, children: "How This Works" }), _jsx(Text, { as: "p", sx: { mb: 2 }, children: "This example does NOT include React Router. The navigation hooks automatically detect this and:" }), _jsxs(Box, { as: "ul", sx: { pl: 4 }, children: [_jsxs(Text, { as: "li", children: ["Use ", _jsx("code", { children: "window.history.pushState()" }), " for navigation"] }), _jsxs(Text, { as: "li", children: ["Listen to ", _jsx("code", { children: "popstate" }), " events for browser back/forward"] }), _jsxs(Text, { as: "li", children: ["Parse ", _jsx("code", { children: "window.location" }), " for current path and params"] }), _jsx(Text, { as: "li", children: "Provide the same API as when React Router is present" })] }), _jsx(Text, { as: "p", sx: { mt: 2 }, children: "The beauty is that the same hooks work in both scenarios without any code changes!" })] })] })] }));
|
|
96
|
-
};
|
|
97
|
-
export default NativeNavigationExample;
|