@datalayer/core 0.0.25 → 0.0.27
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 +11 -11
- package/lib/api/index.d.ts +1 -1
- package/lib/api/index.js +1 -1
- package/lib/api/spacer/agentSpaces.d.ts +193 -0
- package/lib/api/spacer/agentSpaces.js +127 -0
- package/lib/api/spacer/index.d.ts +2 -1
- package/lib/api/spacer/index.js +2 -1
- package/lib/api/utils/validation.d.ts +1 -1
- package/lib/api/utils/validation.js +1 -1
- package/lib/client/auth/AuthenticationManager.d.ts +2 -2
- package/lib/client/auth/AuthenticationManager.js +2 -2
- package/lib/client/auth/index.d.ts +1 -1
- package/lib/client/auth/index.js +1 -1
- package/lib/client/auth/types.d.ts +1 -1
- package/lib/client/auth/types.js +1 -1
- package/lib/client/base.d.ts +9 -9
- package/lib/client/base.js +3 -3
- package/lib/client/constants.d.ts +2 -2
- package/lib/client/constants.js +2 -2
- package/lib/client/index.d.ts +2 -2
- package/lib/client/mixins/IAMMixin.js +1 -1
- package/lib/client/utils/spacerUtils.d.ts +1 -1
- package/lib/client/utils/spacerUtils.js +1 -1
- package/lib/components/auth/Login.d.ts +4 -0
- package/lib/components/auth/Login.js +8 -2
- package/lib/components/auth/Login.stories.d.ts +1 -0
- package/lib/components/progress/ConsumptionBar.js +26 -8
- package/lib/components/progress/CreditsIndicator.d.ts +7 -1
- package/lib/components/progress/CreditsIndicator.js +4 -2
- package/lib/components/{screenshot/ScreenCapture.d.ts → screencapture/Screencapture.d.ts} +5 -5
- package/lib/components/{screenshot/ScreenCapture.js → screencapture/Screencapture.js} +2 -2
- package/lib/components/screencapture/ScreencaptureButton.d.ts +3 -0
- package/lib/components/{screenshot/ScreenCaptureButton.js → screencapture/ScreencaptureButton.js} +8 -8
- package/lib/components/screencapture/index.d.ts +2 -0
- package/lib/components/{screenshot → screencapture}/index.js +2 -2
- package/lib/hooks/index.d.ts +1 -1
- package/lib/hooks/index.js +1 -1
- package/lib/hooks/layouts/{LayoutScreenshot.css → LayoutScreencapture.css} +2 -2
- package/lib/hooks/layouts/LayoutScreencapture.d.ts +3 -0
- package/lib/hooks/layouts/{LayoutScreenshot.js → LayoutScreencapture.js} +14 -14
- package/lib/hooks/layouts/index.d.ts +1 -1
- package/lib/hooks/layouts/index.js +1 -1
- package/lib/hooks/useCache.d.ts +91 -1
- package/lib/hooks/useCache.js +523 -59
- package/lib/hooks/useCellOutputshot.js +2 -2
- package/lib/hooks/useScreencapture.d.ts +18 -0
- package/lib/hooks/useScreencapture.js +53 -0
- package/lib/index.d.ts +1 -1
- package/lib/models/CreditsDTO.js +1 -1
- package/lib/models/Datasource.d.ts +2 -2
- package/lib/models/Datasource.js +2 -2
- package/lib/models/EnvironmentDTO.d.ts +3 -3
- package/lib/models/EnvironmentDTO.js +2 -2
- package/lib/models/HealthCheck.d.ts +1 -1
- package/lib/models/HealthCheck.js +1 -1
- package/lib/models/IAMProviderUsers.d.ts +11 -0
- package/lib/models/IAMProvidersSpecs.d.ts +2 -1
- package/lib/models/IAMProvidersSpecs.js +14 -0
- package/lib/models/ItemDTO.d.ts +2 -2
- package/lib/models/ItemDTO.js +2 -2
- package/lib/models/LexicalDTO.d.ts +2 -2
- package/lib/models/LexicalDTO.js +2 -2
- package/lib/models/NotebookDTO.d.ts +2 -2
- package/lib/models/NotebookDTO.js +1 -1
- package/lib/models/Page.js +1 -1
- package/lib/models/PageTag.d.ts +1 -1
- package/lib/models/PageTag.js +21 -0
- package/lib/models/RuntimeDTO.d.ts +2 -2
- package/lib/models/RuntimeDTO.js +2 -2
- package/lib/models/RuntimeSnapshotDTO.d.ts +3 -3
- package/lib/models/RuntimeSnapshotDTO.js +1 -1
- package/lib/models/Secret.d.ts +3 -3
- package/lib/models/Secret.js +2 -2
- package/lib/models/SpaceDTO.d.ts +2 -2
- package/lib/models/SpaceDTO.js +3 -3
- package/lib/models/UserDTO.d.ts +2 -2
- package/lib/models/UserDTO.js +1 -1
- package/lib/models/index.d.ts +1 -1
- package/lib/models/index.js +1 -1
- package/lib/state/substates/CoreState.js +1 -1
- package/lib/state/substates/LayoutState.d.ts +5 -5
- package/lib/state/substates/LayoutState.js +3 -3
- package/lib/theme/DatalayerThemeProvider.d.ts +22 -2
- package/lib/theme/DatalayerThemeProvider.js +17 -9
- package/lib/theme/index.d.ts +1 -0
- package/lib/theme/index.js +1 -0
- package/lib/theme/useSystemColorMode.d.ts +9 -0
- package/lib/theme/useSystemColorMode.js +26 -0
- package/lib/utils/Screencapture.d.ts +1 -0
- package/lib/utils/{Screenshot.js → Screencapture.js} +1 -1
- package/lib/utils/index.js +1 -1
- package/lib/views/datasources/DatasourceNew.d.ts +7 -1
- package/lib/views/datasources/DatasourceNew.js +3 -3
- package/lib/views/datasources/Datasources.d.ts +7 -1
- package/lib/views/datasources/Datasources.js +6 -4
- package/lib/views/iam-tokens/IAMTokenNew.d.ts +5 -1
- package/lib/views/iam-tokens/IAMTokenNew.js +2 -2
- package/lib/views/iam-tokens/IAMTokens.d.ts +7 -1
- package/lib/views/iam-tokens/IAMTokens.js +6 -4
- package/package.json +1 -1
- package/style/screencapture/index.css +58 -0
- package/lib/components/screenshot/ScreenCaptureButton.d.ts +0 -3
- package/lib/components/screenshot/index.d.ts +0 -2
- package/lib/hooks/layouts/LayoutScreenshot.d.ts +0 -3
- package/lib/hooks/useCache0.d.ts +0 -312
- package/lib/hooks/useCache0.js +0 -3189
- package/lib/hooks/useScreenshot.d.ts +0 -18
- package/lib/hooks/useScreenshot.js +0 -53
- package/lib/utils/Screenshot.d.ts +0 -1
|
@@ -12,7 +12,7 @@ import { LexicalDTO } from '../../models/LexicalDTO';
|
|
|
12
12
|
* to avoid code duplication.
|
|
13
13
|
*
|
|
14
14
|
* @param response - Raw API response containing space items
|
|
15
|
-
* @param sdk -
|
|
15
|
+
* @param sdk - Client instance to pass to model constructors
|
|
16
16
|
* @returns Array of Notebook and Lexical model instances
|
|
17
17
|
*/
|
|
18
18
|
export declare function convertSpaceItemsToModels(items: GetSpaceItemsResponse['items'], sdk: DatalayerClient): (NotebookDTO | LexicalDTO)[];
|
|
@@ -11,7 +11,7 @@ import { ItemTypes } from '../constants';
|
|
|
11
11
|
* to avoid code duplication.
|
|
12
12
|
*
|
|
13
13
|
* @param response - Raw API response containing space items
|
|
14
|
-
* @param sdk -
|
|
14
|
+
* @param sdk - Client instance to pass to model constructors
|
|
15
15
|
* @returns Array of Notebook and Lexical model instances
|
|
16
16
|
*/
|
|
17
17
|
export function convertSpaceItemsToModels(items, sdk) {
|
|
@@ -14,8 +14,10 @@ import { CenteredSpinner } from '../display';
|
|
|
14
14
|
import { isInsideJupyterLab, validateLength } from '../../utils';
|
|
15
15
|
import { useNavigate, useCache, useToast, useIAM } from '../../hooks';
|
|
16
16
|
import { LoginToken } from './LoginToken';
|
|
17
|
+
/** Inline Google "G" icon for the login button. */
|
|
18
|
+
const GoogleIcon = () => (_jsxs("svg", { width: "16", height: "16", viewBox: "0 0 48 48", children: [_jsx("path", { fill: "#EA4335", d: "M24 9.5c3.54 0 6.71 1.22 9.21 3.6l6.85-6.85C35.9 2.38 30.47 0 24 0 14.62 0 6.51 5.38 2.56 13.22l7.98 6.19C12.43 13.72 17.74 9.5 24 9.5z" }), _jsx("path", { fill: "#4285F4", d: "M46.98 24.55c0-1.57-.15-3.09-.38-4.55H24v9.02h12.94c-.58 2.96-2.26 5.48-4.78 7.18l7.73 6c4.51-4.18 7.09-10.36 7.09-17.65z" }), _jsx("path", { fill: "#FBBC05", d: "M10.53 28.59a14.5 14.5 0 0 1 0-9.18l-7.98-6.19a24.1 24.1 0 0 0 0 21.56l7.98-6.19z" }), _jsx("path", { fill: "#34A853", d: "M24 48c6.48 0 11.93-2.13 15.89-5.81l-7.73-6c-2.15 1.45-4.92 2.3-8.16 2.3-6.26 0-11.57-4.22-13.47-9.91l-7.98 6.19C6.51 42.62 14.62 48 24 48z" })] }));
|
|
17
19
|
export const Login = (props) => {
|
|
18
|
-
const { heading, homeRoute, loginRoute, showEmailLogin = true, showGitHubLogin = true, showTokenLogin = true, } = props;
|
|
20
|
+
const { heading, homeRoute, loginRoute, showEmailLogin = true, showGitHubLogin = true, showGoogleLogin = true, showTokenLogin = true, } = props;
|
|
19
21
|
const { useLogin, useOAuth2AuthorizationURL } = useCache({ loginRoute });
|
|
20
22
|
const loginMutation = useLogin();
|
|
21
23
|
const getOAuth2URLMutation = useOAuth2AuthorizationURL();
|
|
@@ -68,6 +70,9 @@ export const Login = (props) => {
|
|
|
68
70
|
if (!iamProvidersAuthorizationURL[IAMProvidersSpecs.GitHub.name]) {
|
|
69
71
|
initIAMProvider(IAMProvidersSpecs.GitHub);
|
|
70
72
|
}
|
|
73
|
+
if (!iamProvidersAuthorizationURL[IAMProvidersSpecs.Google.name]) {
|
|
74
|
+
initIAMProvider(IAMProvidersSpecs.Google);
|
|
75
|
+
}
|
|
71
76
|
if (!iamProvidersAuthorizationURL[IAMProvidersSpecs.LinkedIn.name]) {
|
|
72
77
|
initIAMProvider(IAMProvidersSpecs.LinkedIn);
|
|
73
78
|
}
|
|
@@ -163,6 +168,7 @@ export const Login = (props) => {
|
|
|
163
168
|
: heading
|
|
164
169
|
? 'Login with Datalayer'
|
|
165
170
|
: 'Login' }), _jsx(Box, { pt: 6 }), _jsx(Link, { href: "https://datalayer.app/password", target: "_blank", children: "Forgot password?" })] })] })), _jsx(Box, { children: _jsxs(Box, { display: "flex", flexDirection: "column", sx: { margin: 'auto' }, children: [showGitHubLogin &&
|
|
166
|
-
iamProvidersAuthorizationURL[IAMProvidersSpecs.GitHub.name] && (_jsx(Button, { leadingVisual: MarkGithubIcon, href: iamProvidersAuthorizationURL[IAMProvidersSpecs.GitHub.name], as: "a", style: { margin: '10px 0' }, children: "Login with GitHub" })),
|
|
171
|
+
iamProvidersAuthorizationURL[IAMProvidersSpecs.GitHub.name] && (_jsx(Button, { leadingVisual: MarkGithubIcon, href: iamProvidersAuthorizationURL[IAMProvidersSpecs.GitHub.name], as: "a", style: { margin: '10px 0' }, children: "Login with GitHub" })), showGoogleLogin &&
|
|
172
|
+
iamProvidersAuthorizationURL[IAMProvidersSpecs.Google.name] && (_jsx(Button, { leadingVisual: GoogleIcon, href: iamProvidersAuthorizationURL[IAMProvidersSpecs.Google.name], as: "a", style: { margin: '10px 0' }, children: "Login with Google" })), showTokenLogin && (_jsx(LoginToken, { homeRoute: homeRoute, style: { margin: '10px 0' } }))] }) })] }) })) : loadingWithToken ? (_jsx(CenteredSpinner, { message: "Checking authentication\u2026" })) : (_jsx(_Fragment, {})) })] }));
|
|
167
173
|
};
|
|
168
174
|
export default Login;
|
|
@@ -22,6 +22,7 @@ declare const meta: {
|
|
|
22
22
|
passwordRoute?: string | undefined;
|
|
23
23
|
showEmailLogin?: boolean | undefined;
|
|
24
24
|
showGitHubLogin?: boolean | undefined;
|
|
25
|
+
showGoogleLogin?: boolean | undefined;
|
|
25
26
|
showTokenLogin?: boolean | undefined;
|
|
26
27
|
}>) => import("react/jsx-runtime").JSX.Element)[];
|
|
27
28
|
tags: string[];
|
|
@@ -9,6 +9,23 @@ import { Box } from '@datalayer/primer-addons';
|
|
|
9
9
|
import { useInterval } from 'usehooks-ts';
|
|
10
10
|
const CRITICAL_LEVEL = 90;
|
|
11
11
|
const WARNING_LEVEL = 75;
|
|
12
|
+
/**
|
|
13
|
+
* Format seconds into a human-friendly string (e.g., "2h 15m", "45m", "30s")
|
|
14
|
+
*/
|
|
15
|
+
function formatTimeRemaining(seconds) {
|
|
16
|
+
if (seconds < 0)
|
|
17
|
+
return '0s';
|
|
18
|
+
const hours = Math.floor(seconds / 3600);
|
|
19
|
+
const minutes = Math.floor((seconds % 3600) / 60);
|
|
20
|
+
const secs = Math.floor(seconds % 60);
|
|
21
|
+
if (hours > 0) {
|
|
22
|
+
return minutes > 0 ? `${hours}h ${minutes}m` : `${hours}h`;
|
|
23
|
+
}
|
|
24
|
+
if (minutes > 0) {
|
|
25
|
+
return secs > 0 && minutes < 5 ? `${minutes}m ${secs}s` : `${minutes}m`;
|
|
26
|
+
}
|
|
27
|
+
return `${secs}s`;
|
|
28
|
+
}
|
|
12
29
|
/**
|
|
13
30
|
* Consumption progress bar
|
|
14
31
|
*/
|
|
@@ -36,14 +53,15 @@ export function ConsumptionBar(props) {
|
|
|
36
53
|
: 'success.emphasis'
|
|
37
54
|
: 'neutral.emphasis';
|
|
38
55
|
const burntCredits = duration * burningRate;
|
|
56
|
+
const secondsRemaining = (1 - progress / 100) * duration;
|
|
39
57
|
const title = duration
|
|
40
|
-
? `${(
|
|
58
|
+
? `${formatTimeRemaining(secondsRemaining)} left - ${((progress / 100) * burntCredits).toFixed(2)} / ${burntCredits.toFixed(2)} credits`
|
|
41
59
|
: `Started at ${new Date(startedAt * 1000).toISOString()} - ${burntCredits.toFixed(2)} credits consumed`;
|
|
42
|
-
return (_jsx(_Fragment, { children: _jsx(Tooltip, { text: title, direction: "w", children: _jsx(Button, { variant: "invisible",
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
60
|
+
return (_jsx(_Fragment, { children: _jsx(Tooltip, { text: title, direction: "w", children: _jsx(Button, { variant: "invisible", onClick: onClick, onKeyDown: onClick
|
|
61
|
+
? event => {
|
|
62
|
+
if (event.key === 'Enter' || event.key === 'Space') {
|
|
63
|
+
onClick();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
: undefined, tabIndex: onClick ? 0 : -1, sx: { cursor: onClick ? 'pointer' : 'default' }, children: _jsx(Box, { sx: { width: '70px' }, children: _jsx(ProgressBar, { style: style, animated: expiredAt ? false : true, bg: bg, progress: progress }) }) }) }) }));
|
|
49
67
|
}
|
|
@@ -9,7 +9,13 @@ type ICreditsIndicatorProps = {
|
|
|
9
9
|
*/
|
|
10
10
|
kernelId: string;
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
12
|
+
* Route to navigate to when the indicator is clicked.
|
|
13
|
+
* Ignored if `onClick` is provided.
|
|
14
|
+
*/
|
|
15
|
+
navigateTo?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Callback on progress bar click event.
|
|
18
|
+
* Takes precedence over `navigateTo`.
|
|
13
19
|
*/
|
|
14
20
|
onClick?: () => void;
|
|
15
21
|
/**
|
|
@@ -6,16 +6,18 @@ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
|
6
6
|
import { useState, useEffect } from 'react';
|
|
7
7
|
import { Box } from '@datalayer/primer-addons';
|
|
8
8
|
import { ConsumptionBar } from '../../components/progress';
|
|
9
|
+
import useNavigate from '../../hooks/useNavigate';
|
|
9
10
|
/**
|
|
10
11
|
* Credits indicator component.
|
|
11
12
|
*/
|
|
12
13
|
export function CreditsIndicator(props) {
|
|
13
|
-
const { serviceManager, kernelId, onClick, onUpdate } = props;
|
|
14
|
+
const { serviceManager, kernelId, navigateTo, onClick, onUpdate } = props;
|
|
15
|
+
const navigate = useNavigate();
|
|
14
16
|
const [model, setModel] = useState();
|
|
15
17
|
useEffect(() => {
|
|
16
18
|
serviceManager.runtimesManager.findById(kernelId).then(model => {
|
|
17
19
|
setModel(model);
|
|
18
20
|
});
|
|
19
21
|
}, [kernelId, serviceManager]);
|
|
20
|
-
return model ? (_jsx(Box, { display: "flex", style: { alignItems: 'center' }, children: _jsx(ConsumptionBar, { startedAt: parseFloat(model.started_at), expiredAt: model.expired_at ? parseFloat(model.expired_at) : undefined, burningRate: model.burning_rate, onClick: onClick, onUpdate: onUpdate, style: { cursor: 'pointer' } }) })) : (_jsx(_Fragment, {}));
|
|
22
|
+
return model ? (_jsx(Box, { display: "flex", style: { alignItems: 'center' }, children: _jsx(ConsumptionBar, { startedAt: parseFloat(model.started_at), expiredAt: model.expired_at ? parseFloat(model.expired_at) : undefined, burningRate: model.burning_rate, onClick: onClick ?? (navigateTo ? () => navigate(navigateTo) : undefined), onUpdate: onUpdate, style: { cursor: 'pointer' } }) })) : (_jsx(_Fragment, {}));
|
|
21
23
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Component, CSSProperties } from 'react';
|
|
2
|
-
type
|
|
2
|
+
type ScreencaptureProps = {
|
|
3
3
|
children: any;
|
|
4
4
|
onStartCapture?: () => void;
|
|
5
5
|
onEndCapture: (url: string) => void;
|
|
6
6
|
};
|
|
7
|
-
type
|
|
7
|
+
type ScreencaptureState = {
|
|
8
8
|
on: boolean;
|
|
9
9
|
startX: number;
|
|
10
10
|
startY: number;
|
|
@@ -22,8 +22,8 @@ type ScreenCaptureState = {
|
|
|
22
22
|
cropHeigth: number;
|
|
23
23
|
imageURL: string;
|
|
24
24
|
};
|
|
25
|
-
export declare class
|
|
26
|
-
state:
|
|
25
|
+
export declare class Screencapture extends Component<ScreencaptureProps, ScreencaptureState> {
|
|
26
|
+
state: ScreencaptureState;
|
|
27
27
|
handleWindowResize: () => void;
|
|
28
28
|
componentDidMount: () => void;
|
|
29
29
|
componentWillUnmount: () => void;
|
|
@@ -35,4 +35,4 @@ export declare class ScreenCapture extends Component<ScreenCaptureProps, ScreenC
|
|
|
35
35
|
renderChild: () => any;
|
|
36
36
|
render(): any;
|
|
37
37
|
}
|
|
38
|
-
export default
|
|
38
|
+
export default Screencapture;
|
|
@@ -5,7 +5,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
5
5
|
*/
|
|
6
6
|
import { Component } from 'react';
|
|
7
7
|
import html2canvas from 'html2canvas';
|
|
8
|
-
export class
|
|
8
|
+
export class Screencapture extends Component {
|
|
9
9
|
state = {
|
|
10
10
|
on: false,
|
|
11
11
|
startX: 0,
|
|
@@ -167,4 +167,4 @@ export class ScreenCapture extends Component {
|
|
|
167
167
|
return (_jsxs("div", { onMouseMove: this.handleMouseMove, onMouseDown: this.handleMouseDown, onMouseUp: this.handleMouseUp, children: [this.renderChild(), _jsx("div", { className: `overlay ${isMouseDown && 'highlighting'}`, style: { borderWidth: `${borderWidth}` } }), _jsx("div", { className: "crosshairs", style: { left: crossHairsLeft + 'px', top: crossHairsTop + 'px' } })] }));
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
|
-
export default
|
|
170
|
+
export default Screencapture;
|
package/lib/components/{screenshot/ScreenCaptureButton.js → screencapture/ScreencaptureButton.js}
RENAMED
|
@@ -4,16 +4,16 @@ import { ScreenFullIcon } from '@primer/octicons-react';
|
|
|
4
4
|
import { lazyWithPreload, WithSuspense } from '../../utils';
|
|
5
5
|
import { useToast } from '../../hooks';
|
|
6
6
|
import { useLayoutStore } from '../../state';
|
|
7
|
-
const
|
|
8
|
-
export const
|
|
7
|
+
const Screencapture = WithSuspense(lazyWithPreload(() => import('./Screencapture')));
|
|
8
|
+
export const ScreencaptureButton = (props) => {
|
|
9
9
|
const { enqueueToast } = useToast();
|
|
10
|
-
const {
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
const { setScreencapture, hideScreencapture } = useLayoutStore();
|
|
11
|
+
const handleScreencapture = (screenCapture) => {
|
|
12
|
+
setScreencapture(screenCapture);
|
|
13
|
+
hideScreencapture();
|
|
14
14
|
enqueueToast('Screen is captured.', { variant: 'success' });
|
|
15
15
|
};
|
|
16
|
-
return (_jsx(
|
|
16
|
+
return (_jsx(Screencapture, { onEndCapture: handleScreencapture, children: ({ onStartCapture }) => (_jsx(Tooltip, { text: "Take a screen capture", direction: "s", children: _jsx(Button, { variant: "invisible", children: _jsx(Link, { href: "javascript: return false;", sx: {
|
|
17
17
|
color: 'fg.muted',
|
|
18
18
|
':hover, :focus, &[aria-expanded=true]': {
|
|
19
19
|
background: 'none !important',
|
|
@@ -24,4 +24,4 @@ export const ScreenCaptureButton = (props) => {
|
|
|
24
24
|
onStartCapture();
|
|
25
25
|
}, children: _jsx(ScreenFullIcon, {}) }) }) })) }));
|
|
26
26
|
};
|
|
27
|
-
export default
|
|
27
|
+
export default ScreencaptureButton;
|
package/lib/hooks/index.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ export * from './useParams';
|
|
|
19
19
|
export * from './useOnClickOutside';
|
|
20
20
|
export * from './useRef';
|
|
21
21
|
export * from './useRuntimes';
|
|
22
|
-
export * from './
|
|
22
|
+
export * from './useScreencapture';
|
|
23
23
|
export * from './useToast';
|
|
24
24
|
export * from './useUpload';
|
|
25
25
|
export * from './useUser';
|
package/lib/hooks/index.js
CHANGED
|
@@ -24,7 +24,7 @@ export * from './useParams';
|
|
|
24
24
|
export * from './useOnClickOutside';
|
|
25
25
|
export * from './useRef';
|
|
26
26
|
export * from './useRuntimes';
|
|
27
|
-
export * from './
|
|
27
|
+
export * from './useScreencapture';
|
|
28
28
|
export * from './useToast';
|
|
29
29
|
export * from './useUpload';
|
|
30
30
|
export * from './useUser';
|
|
@@ -22,14 +22,14 @@
|
|
|
22
22
|
.crosshairs::before {
|
|
23
23
|
height: 24px;
|
|
24
24
|
width: 2px;
|
|
25
|
-
background: #
|
|
25
|
+
background: #fff;
|
|
26
26
|
top: -11px;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
.crosshairs::after {
|
|
30
30
|
width: 24px;
|
|
31
31
|
height: 2px;
|
|
32
|
-
background: #
|
|
32
|
+
background: #fff;
|
|
33
33
|
left: -11px;
|
|
34
34
|
}
|
|
35
35
|
|
|
@@ -5,11 +5,11 @@ import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
|
5
5
|
*/
|
|
6
6
|
import { useEffect } from 'react';
|
|
7
7
|
import { Box } from '@primer/react';
|
|
8
|
-
import {
|
|
8
|
+
import { useScreencapture, useToast } from '..';
|
|
9
9
|
import { lazyWithPreload, WithSuspense } from '../../utils';
|
|
10
10
|
import { useLayoutStore } from '../../state';
|
|
11
|
-
import '
|
|
12
|
-
const
|
|
11
|
+
import '../../../style/screencapture/index.css';
|
|
12
|
+
const Screencapture = WithSuspense(lazyWithPreload(() => import('../../components/screencapture/Screencapture')));
|
|
13
13
|
const Capture = (props) => {
|
|
14
14
|
const { onStartCapture } = props;
|
|
15
15
|
useEffect(() => {
|
|
@@ -17,28 +17,28 @@ const Capture = (props) => {
|
|
|
17
17
|
}, []);
|
|
18
18
|
return _jsx(_Fragment, {});
|
|
19
19
|
};
|
|
20
|
-
const
|
|
20
|
+
const ScreencaptureContent = (props) => {
|
|
21
21
|
// const { screenshotDisplay } = props;
|
|
22
22
|
const { enqueueToast } = useToast();
|
|
23
|
-
const {
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
const { setScreencapture, hideScreencapture } = useLayoutStore();
|
|
24
|
+
const handleScreencapture = (screenCapture) => {
|
|
25
|
+
setScreencapture(screenCapture);
|
|
26
|
+
hideScreencapture();
|
|
27
27
|
enqueueToast('Screen is captured.', { variant: 'success' });
|
|
28
28
|
};
|
|
29
|
-
return (_jsx(Box, { children: _jsx(
|
|
29
|
+
return (_jsx(Box, { children: _jsx(Screencapture, { onEndCapture: handleScreencapture, children: ({ onStartCapture }) => _jsx(Capture, { onStartCapture: onStartCapture }) }) }));
|
|
30
30
|
};
|
|
31
|
-
export const
|
|
31
|
+
export const LayoutScreencapture = () => {
|
|
32
32
|
const { screenshot } = useLayoutStore();
|
|
33
|
-
const {
|
|
33
|
+
const { displayScreencapture, closeScreencapture } = useScreencapture();
|
|
34
34
|
useEffect(() => {
|
|
35
35
|
if (screenshot && screenshot.open) {
|
|
36
|
-
|
|
36
|
+
displayScreencapture(() => (_jsx(ScreencaptureContent, { screenshotDisplay: screenshot })));
|
|
37
37
|
}
|
|
38
38
|
else {
|
|
39
|
-
|
|
39
|
+
closeScreencapture();
|
|
40
40
|
}
|
|
41
41
|
}, [screenshot]);
|
|
42
42
|
return _jsx(_Fragment, {});
|
|
43
43
|
};
|
|
44
|
-
export default
|
|
44
|
+
export default LayoutScreencapture;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from './LayoutBackdrop';
|
|
2
|
-
export * from './
|
|
2
|
+
export * from './LayoutScreencapture';
|
package/lib/hooks/useCache.d.ts
CHANGED
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
*/
|
|
37
37
|
import { UseQueryOptions, UseMutationOptions } from '@tanstack/react-query';
|
|
38
38
|
import { IAnyOrganization, IAnySpace, IAssignment, ICell, IContact, ICourse, IDataset, IDatasource, IDocument, IEnvironment, IExercise, IIAMToken, ILesson, INotebook, IOrganization, IPage, ISchool, ISecret, ITeam, IUser, IUserOnboarding, IUserSettings } from '../models';
|
|
39
|
+
import type { AgentSpaceData, CreateAgentSpaceRequest, UpdateAgentSpaceRequest } from '../api/spacer/agentSpaces';
|
|
39
40
|
export type CacheProps = {
|
|
40
41
|
loginRoute?: string;
|
|
41
42
|
};
|
|
@@ -212,6 +213,19 @@ export declare const queryKeys: {
|
|
|
212
213
|
readonly bySpace: (spaceId: string) => readonly ["items", "space", string];
|
|
213
214
|
readonly search: (opts: ISearchOpts) => readonly ["items", "search", ISearchOpts];
|
|
214
215
|
};
|
|
216
|
+
readonly agentSpaces: {
|
|
217
|
+
readonly all: () => readonly ["agentSpaces"];
|
|
218
|
+
readonly lists: () => readonly ["agentSpaces", "list"];
|
|
219
|
+
readonly details: () => readonly ["agentSpaces", "detail"];
|
|
220
|
+
readonly detail: (id: string) => readonly ["agentSpaces", "detail", string];
|
|
221
|
+
readonly public: () => readonly ["agentSpaces", "public"];
|
|
222
|
+
};
|
|
223
|
+
readonly agentRuntimes: {
|
|
224
|
+
readonly all: () => readonly ["agentRuntimes"];
|
|
225
|
+
readonly lists: () => readonly ["agentRuntimes", "list"];
|
|
226
|
+
readonly details: () => readonly ["agentRuntimes", "detail"];
|
|
227
|
+
readonly detail: (podName: string) => readonly ["agentRuntimes", "detail", string];
|
|
228
|
+
};
|
|
215
229
|
readonly layout: {
|
|
216
230
|
readonly byAccount: (accountHandle: string, spaceHandle?: string) => readonly ["layout", string, string] | readonly ["layout", string];
|
|
217
231
|
};
|
|
@@ -302,6 +316,7 @@ export declare const useCache: ({ loginRoute }?: CacheProps) => {
|
|
|
302
316
|
autorization_url: string;
|
|
303
317
|
}, Error, Record<string, string>, unknown>;
|
|
304
318
|
useGetGitHubProfile: () => import("@tanstack/react-query").UseMutationResult<any, Error, string, unknown>;
|
|
319
|
+
useGetGoogleProfile: () => import("@tanstack/react-query").UseMutationResult<any, Error, string, unknown>;
|
|
305
320
|
useGetLinkedinProfile: () => import("@tanstack/react-query").UseMutationResult<any, Error, string, unknown>;
|
|
306
321
|
usePostLinkedinShare: () => import("@tanstack/react-query").UseMutationResult<any, Error, {
|
|
307
322
|
linkedinUserUrn: string;
|
|
@@ -311,7 +326,7 @@ export declare const useCache: ({ loginRoute }?: CacheProps) => {
|
|
|
311
326
|
usePostLinkedinShareWithUpload: () => import("@tanstack/react-query").UseMutationResult<any, Error, {
|
|
312
327
|
linkedinUserUrn: string;
|
|
313
328
|
postText: string;
|
|
314
|
-
uploadObject
|
|
329
|
+
uploadObject?: string;
|
|
315
330
|
accessToken: string;
|
|
316
331
|
}, unknown>;
|
|
317
332
|
useRegisterToWaitingList: () => import("@tanstack/react-query").UseMutationResult<any, Error, {
|
|
@@ -472,6 +487,68 @@ export declare const useCache: ({ loginRoute }?: CacheProps) => {
|
|
|
472
487
|
spaceHandle?: string;
|
|
473
488
|
}, unknown>;
|
|
474
489
|
useExportSpace: () => import("@tanstack/react-query").UseMutationResult<any, Error, string, unknown>;
|
|
490
|
+
useAgentSpace: (uid: string | undefined) => import("@tanstack/react-query").UseQueryResult<AgentSpaceData, Error>;
|
|
491
|
+
useAgentSpaces: () => import("@tanstack/react-query").UseQueryResult<AgentSpaceData[], Error>;
|
|
492
|
+
usePublicAgentSpaces: () => import("@tanstack/react-query").UseQueryResult<AgentSpaceData[], Error>;
|
|
493
|
+
useCreateAgentSpace: () => import("@tanstack/react-query").UseMutationResult<any, Error, CreateAgentSpaceRequest, unknown>;
|
|
494
|
+
useUpdateAgentSpace: () => import("@tanstack/react-query").UseMutationResult<any, Error, {
|
|
495
|
+
uid: string;
|
|
496
|
+
data: UpdateAgentSpaceRequest;
|
|
497
|
+
}, unknown>;
|
|
498
|
+
useDeleteAgentSpace: () => import("@tanstack/react-query").UseMutationResult<any, Error, string, unknown>;
|
|
499
|
+
useMakeAgentSpacePublic: () => import("@tanstack/react-query").UseMutationResult<any, Error, string, unknown>;
|
|
500
|
+
useMakeAgentSpacePrivate: () => import("@tanstack/react-query").UseMutationResult<any, Error, string, unknown>;
|
|
501
|
+
useRefreshAgentSpace: () => (uid: string) => void;
|
|
502
|
+
useRefreshAgentSpaces: () => () => void;
|
|
503
|
+
useRefreshPublicAgentSpaces: () => () => void;
|
|
504
|
+
useAgentRuntime: (podName: string | undefined) => import("@tanstack/react-query").UseQueryResult<{
|
|
505
|
+
status: "running" | "paused" | "starting" | "terminated" | "archived";
|
|
506
|
+
name: string;
|
|
507
|
+
id: string;
|
|
508
|
+
url: string | undefined;
|
|
509
|
+
messageCount: number;
|
|
510
|
+
pod_name: string;
|
|
511
|
+
environment_name: string;
|
|
512
|
+
environment_title?: string;
|
|
513
|
+
given_name: string;
|
|
514
|
+
phase?: string;
|
|
515
|
+
type: string;
|
|
516
|
+
started_at?: string;
|
|
517
|
+
expired_at?: string;
|
|
518
|
+
burning_rate?: number;
|
|
519
|
+
ingress?: string;
|
|
520
|
+
token?: string;
|
|
521
|
+
agentSpec?: AgentSpaceData["agentSpec"];
|
|
522
|
+
}, Error>;
|
|
523
|
+
useAgentRuntimes: () => import("@tanstack/react-query").UseQueryResult<{
|
|
524
|
+
status: "running" | "paused" | "starting" | "terminated" | "archived";
|
|
525
|
+
name: string;
|
|
526
|
+
id: string;
|
|
527
|
+
url: string | undefined;
|
|
528
|
+
messageCount: number;
|
|
529
|
+
pod_name: string;
|
|
530
|
+
environment_name: string;
|
|
531
|
+
environment_title?: string;
|
|
532
|
+
given_name: string;
|
|
533
|
+
phase?: string;
|
|
534
|
+
type: string;
|
|
535
|
+
started_at?: string;
|
|
536
|
+
expired_at?: string;
|
|
537
|
+
burning_rate?: number;
|
|
538
|
+
ingress?: string;
|
|
539
|
+
token?: string;
|
|
540
|
+
agentSpec?: AgentSpaceData["agentSpec"];
|
|
541
|
+
}[], Error>;
|
|
542
|
+
useCreateAgentRuntime: () => import("@tanstack/react-query").UseMutationResult<any, Error, {
|
|
543
|
+
environmentName?: string;
|
|
544
|
+
givenName?: string;
|
|
545
|
+
creditsLimit?: number;
|
|
546
|
+
type?: string;
|
|
547
|
+
editorVariant?: string;
|
|
548
|
+
enableCodemode?: boolean;
|
|
549
|
+
}, unknown>;
|
|
550
|
+
useDeleteAgentRuntime: () => import("@tanstack/react-query").UseMutationResult<any, Error, string, unknown>;
|
|
551
|
+
useRefreshAgentRuntimes: () => () => void;
|
|
475
552
|
useCourse: (courseId: string) => import("@tanstack/react-query").UseQueryResult<ICourse | undefined, Error>;
|
|
476
553
|
useUpdateCourse: () => import("@tanstack/react-query").UseMutationResult<any, Error, {
|
|
477
554
|
courseId: string;
|
|
@@ -951,6 +1028,19 @@ export declare const useCache: ({ loginRoute }?: CacheProps) => {
|
|
|
951
1028
|
readonly bySpace: (spaceId: string) => readonly ["items", "space", string];
|
|
952
1029
|
readonly search: (opts: ISearchOpts) => readonly ["items", "search", ISearchOpts];
|
|
953
1030
|
};
|
|
1031
|
+
readonly agentSpaces: {
|
|
1032
|
+
readonly all: () => readonly ["agentSpaces"];
|
|
1033
|
+
readonly lists: () => readonly ["agentSpaces", "list"];
|
|
1034
|
+
readonly details: () => readonly ["agentSpaces", "detail"];
|
|
1035
|
+
readonly detail: (id: string) => readonly ["agentSpaces", "detail", string];
|
|
1036
|
+
readonly public: () => readonly ["agentSpaces", "public"];
|
|
1037
|
+
};
|
|
1038
|
+
readonly agentRuntimes: {
|
|
1039
|
+
readonly all: () => readonly ["agentRuntimes"];
|
|
1040
|
+
readonly lists: () => readonly ["agentRuntimes", "list"];
|
|
1041
|
+
readonly details: () => readonly ["agentRuntimes", "detail"];
|
|
1042
|
+
readonly detail: (podName: string) => readonly ["agentRuntimes", "detail", string];
|
|
1043
|
+
};
|
|
954
1044
|
readonly layout: {
|
|
955
1045
|
readonly byAccount: (accountHandle: string, spaceHandle?: string) => readonly ["layout", string, string] | readonly ["layout", string];
|
|
956
1046
|
};
|