@datalayer/core 0.0.3 → 0.0.4
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 +114 -3
- package/lib/App.css +2 -2
- package/lib/App.d.ts +1 -1
- package/lib/App.js +9 -9
- package/lib/__tests__/index.test.js +5 -5
- package/lib/api/DatalayerApi.d.ts +1 -1
- package/lib/api/DatalayerApi.js +3 -3
- package/lib/api/index.d.ts +3 -3
- package/lib/api/index.js +3 -3
- package/lib/api/runtimes/actions.js +22 -23
- package/lib/api/runtimes/settings.js +3 -3
- package/lib/api/runtimes/snapshots.d.ts +1 -1
- package/lib/api/runtimes/snapshots.js +8 -8
- package/lib/api/runtimes/utils.js +1 -4
- package/lib/collaboration/DatalayerCollaboration.d.ts +9 -0
- package/lib/collaboration/DatalayerCollaboration.js +28 -0
- package/lib/collaboration/DatalayerCollaborationProvider.d.ts +54 -0
- package/lib/collaboration/DatalayerCollaborationProvider.js +162 -0
- package/lib/collaboration/index.d.ts +2 -0
- package/lib/collaboration/index.js +6 -0
- package/lib/components/avatars/BoringAvatar.d.ts +1 -1
- package/lib/components/avatars/BoringAvatar.js +2 -2
- package/lib/components/avatars/UserProfileAvatar.js +2 -9
- package/lib/components/banners/NoAutomationBanner.js +4 -4
- package/lib/components/buttons/DownloadCSVButton.js +1 -1
- package/lib/components/buttons/UploadButton.js +1 -1
- package/lib/components/checkout/StripeCheckout.d.ts +1 -1
- package/lib/components/checkout/StripeCheckout.js +6 -6
- package/lib/components/confetti/ConfettiSuccess.js +1 -1
- package/lib/components/context/OrganizationSelect.js +5 -5
- package/lib/components/context/SpaceSelect.js +7 -7
- package/lib/components/display/AvatarSkeleton.js +1 -1
- package/lib/components/display/CenteredSpinner.js +4 -4
- package/lib/components/display/CodePreview.js +4 -4
- package/lib/components/display/DatalayerBox.js +13 -14
- package/lib/components/display/HorizontalCenter.d.ts +1 -1
- package/lib/components/display/HorizontalCenter.js +1 -1
- package/lib/components/display/JupyterDialog.js +17 -15
- package/lib/components/display/NavLink.d.ts +4 -2
- package/lib/components/display/NavLink.js +6 -4
- package/lib/components/display/NotebookSkeleton.js +2 -2
- package/lib/components/display/Placeholder.js +1 -1
- package/lib/components/display/ToTopBranded.js +1 -1
- package/lib/components/echarts/EChartsReact.d.ts +1 -1
- package/lib/components/echarts/EChartsReact.js +1 -1
- package/lib/components/flashes/FlashClosable.js +11 -11
- package/lib/components/flashes/FlashDisclaimer.js +2 -3
- package/lib/components/flashes/FlashGuest.js +3 -4
- package/lib/components/flashes/FlashSurveys.js +3 -4
- package/lib/components/flashes/FlashUnauthorized.js +2 -2
- package/lib/components/flashes/surveys/Survey2025_1.d.ts +1 -1
- package/lib/components/flashes/surveys/Survey2025_1.js +62 -85
- package/lib/components/iam/ExternalTokenSilentLogin.js +6 -4
- package/lib/components/icons/ArtifactIcon.d.ts +2 -2
- package/lib/components/icons/ArtifactIcon.js +39 -39
- package/lib/components/labels/VisibilityLabel.js +2 -5
- package/lib/components/landings/StepBlock.d.ts +1 -1
- package/lib/components/landings/StepBlock.js +1 -1
- package/lib/components/navbar/NavigationVisbilityObserver.js +2 -2
- package/lib/components/navbar/SubdomainNavBar.js +45 -23
- package/lib/components/navbar/SubdomainNavBar.module.css +33 -14
- package/lib/components/nbgrader/NbGradesDetails.d.ts +1 -1
- package/lib/components/nbgrader/NbGradesDetails.js +5 -8
- package/lib/components/notebooks/JupyterNotebook.js +5 -5
- package/lib/components/notebooks/JupyterNotebookToolbar.js +3 -3
- package/lib/components/primer/Helper.d.ts +1 -1
- package/lib/components/primer/Helper.js +5 -3
- package/lib/components/primer/Portals.d.ts +1 -1
- package/lib/components/primer/Portals.js +2 -2
- package/lib/components/primer/Styles.js +1 -1
- package/lib/components/progress/ConsumptionBar.js +2 -2
- package/lib/components/progress/CreditsIndicator.d.ts +1 -1
- package/lib/components/progress/CreditsIndicator.js +4 -7
- package/lib/components/progress/ProgressRing.js +2 -2
- package/lib/components/runtimes/RuntimeCellVariables.js +9 -9
- package/lib/components/runtimes/RuntimeCellVariablesDialog.js +3 -3
- package/lib/components/runtimes/RuntimeLauncherDialog.js +30 -34
- package/lib/components/runtimes/RuntimePickerBase.js +42 -31
- package/lib/components/runtimes/RuntimePickerCell.js +9 -12
- package/lib/components/runtimes/RuntimePickerNotebook.js +44 -44
- package/lib/components/runtimes/RuntimeReservationControl.js +10 -15
- package/lib/components/runtimes/RuntimeSimplePicker.js +9 -12
- package/lib/components/runtimes/RuntimeUtils.js +22 -12
- package/lib/components/runtimes/RuntimeVariables.js +7 -7
- package/lib/components/screenshot/ScreenCapture.js +9 -13
- package/lib/components/screenshot/ScreenCaptureButton.d.ts +1 -1
- package/lib/components/screenshot/ScreenCaptureButton.js +14 -8
- package/lib/components/snapshots/RuntimeSnapshotMenu.js +19 -17
- package/lib/components/snippets/SnippetDialog.js +5 -5
- package/lib/components/storage/ContentsBrowser.js +63 -56
- package/lib/components/storage/ContentsItems.js +10 -8
- package/lib/components/students/StudentItemStatus.d.ts +1 -1
- package/lib/components/students/StudentItemStatus.js +35 -16
- package/lib/components/subnav/SubNav.d.ts +1 -1
- package/lib/components/subnav/SubNav.js +30 -15
- package/lib/components/subnav/SubNav.module.css +55 -21
- package/lib/components/tables/DataTable.js +1 -4
- package/lib/components/text-reveal/TextRevealAnimation.js +7 -2
- package/lib/components/text-reveal/TextRevealAnimation.module.css +4 -2
- package/lib/components/tokens/SpaceVariantToken.d.ts +1 -1
- package/lib/components/tokens/SpaceVariantToken.js +5 -5
- package/lib/components/toolbars/AssignmentEditorToolbar.js +1 -3
- package/lib/components/users/PeerIndicator.d.ts +1 -1
- package/lib/components/users/PeerIndicator.js +5 -5
- package/lib/config/Configuration.d.ts +48 -0
- package/lib/config/Configuration.js +42 -0
- package/lib/config/integrations/Loom.js +3 -3
- package/lib/examples/CellExample.d.ts +2 -2
- package/lib/examples/CellExample.js +34 -3
- package/lib/examples/DatalayerNotebookExample.d.ts +16 -0
- package/lib/examples/DatalayerNotebookExample.js +75 -0
- package/lib/examples/NativeNavigationExample.d.ts +8 -0
- package/lib/examples/NativeNavigationExample.js +97 -0
- package/lib/examples/NotebookExample.d.ts +1 -3
- package/lib/examples/NotebookExample.js +9 -7
- package/lib/examples/NotebookMutationsKernel.d.ts +2 -0
- package/lib/examples/NotebookMutationsKernel.js +115 -0
- package/lib/examples/NotebookMutationsServiceManager.d.ts +2 -0
- package/lib/examples/NotebookMutationsServiceManager.js +107 -0
- package/lib/examples/ReactRouterExample.d.ts +6 -0
- package/lib/examples/ReactRouterExample.js +175 -0
- package/lib/examples/example-selector.d.ts +22 -0
- package/lib/examples/example-selector.js +45 -0
- package/lib/examples/index.d.ts +2 -0
- package/lib/examples/index.js +6 -0
- package/lib/examples/main.js +153 -0
- package/lib/examples/notebooks/IPyWidgetsExample.ipynb.json +101 -0
- package/lib/examples/notebooks/IPyWidgetsExampleWithState.ipynb.json +112 -0
- package/lib/examples/{NotebookExample1.ipynb.json → notebooks/Lite.ipynb.json} +45 -53
- package/lib/examples/notebooks/Matplotlib.ipynb.json +137 -0
- package/lib/examples/notebooks/NotebookExample1.ipynb.json +126 -0
- package/lib/examples/notebooks/NotebookExample2.ipynb.json +48 -0
- package/lib/examples/notebooks/NotebookOutputs.ipynb.json +49 -0
- package/lib/examples/notebooks/NotebookToCExample.ipynb.json +102 -0
- package/lib/examples/notebooks/OutputIPyWidgetsExample.d.ts +145 -0
- package/lib/examples/notebooks/OutputIPyWidgetsExample.js +153 -0
- package/lib/examples/notebooks/PyGWalker.ipynb.json +55 -0
- package/lib/hooks/assets/OutputshotPlaceholders.d.ts +10 -10
- package/lib/hooks/assets/OutputshotPlaceholders.js +10 -10
- package/lib/hooks/index.d.ts +29 -28
- package/lib/hooks/index.js +29 -28
- package/lib/hooks/layouts/LayoutBackdrop.js +3 -6
- package/lib/hooks/layouts/LayoutScreenshot.css +1 -1
- package/lib/hooks/layouts/LayoutScreenshot.js +6 -6
- package/lib/hooks/useAIAgents.d.ts +1 -1
- package/lib/hooks/useAIAgents.js +6 -6
- package/lib/hooks/useAuthorization.js +4 -4
- package/lib/hooks/useBackdrop.js +7 -7
- package/lib/hooks/useBackdropJupyterLab.d.ts +1 -1
- package/lib/hooks/useBackdropJupyterLab.js +4 -4
- package/lib/hooks/useCache.d.ts +6 -2
- package/lib/hooks/useCache.js +233 -179
- package/lib/hooks/useCellOutputshot.js +3 -6
- package/lib/hooks/useContainsFocus.js +2 -1
- package/lib/hooks/useDatalayer.js +5 -3
- package/lib/hooks/useError.d.ts +1 -1
- package/lib/hooks/useError.js +2 -2
- package/lib/hooks/useExternalScript.js +4 -4
- package/lib/hooks/useFocusTrap.js +2 -1
- package/lib/hooks/useIAM.js +4 -5
- package/lib/hooks/useId.js +3 -3
- package/lib/hooks/useJupyterLabTheme.js +3 -1
- package/lib/hooks/useLocation.d.ts +22 -0
- package/lib/hooks/useLocation.js +149 -0
- package/lib/hooks/useLocationHandles.d.ts +2 -2
- package/lib/hooks/useLocationHandles.js +6 -4
- package/lib/hooks/useNavigate.d.ts +5 -1
- package/lib/hooks/useNavigate.js +62 -7
- package/lib/hooks/useNotebookAIAgent.js +3 -1
- package/lib/hooks/useParams.d.ts +5 -0
- package/lib/hooks/useParams.js +152 -0
- package/lib/hooks/useRuntimes.js +2 -2
- package/lib/hooks/useScreenshot.js +5 -5
- package/lib/hooks/useToast.js +15 -13
- package/lib/hooks/useUpload.js +9 -9
- package/lib/hooks/useUser.js +1 -1
- package/lib/index.css +1 -1
- package/lib/index.d.ts +6 -3
- package/lib/index.js +7 -3
- package/lib/mocks/components/FlashMock.js +4 -4
- package/lib/mocks/hooks/rests/rests.js +15 -18
- package/lib/mocks/hooks/useDatalayerMock.d.ts +2 -2
- package/lib/mocks/hooks/useDatalayerMock.js +7 -7
- package/lib/mocks/models/CodeBlockMock.js +1 -1
- package/lib/mocks/models/CodelineMock.js +1 -1
- package/lib/mocks/models/CourseMock.d.ts +1 -1
- package/lib/mocks/models/CourseMock.js +10 -10
- package/lib/mocks/models/InviteMock.d.ts +1 -1
- package/lib/mocks/models/InviteMock.js +21 -6
- package/lib/mocks/models/JupyterLabUserMock.js +2 -2
- package/lib/mocks/models/OrganisationMock.d.ts +1 -1
- package/lib/mocks/models/OrganisationMock.js +11 -7
- package/lib/mocks/models/SchoolMock.d.ts +1 -1
- package/lib/mocks/models/SchoolMock.js +6 -6
- package/lib/mocks/models/SpaceMock.d.ts +1 -1
- package/lib/mocks/models/SpaceMock.js +9 -9
- package/lib/mocks/models/TeamMock.d.ts +1 -1
- package/lib/mocks/models/TeamMock.js +6 -6
- package/lib/mocks/models/UserMock.d.ts +1 -1
- package/lib/mocks/models/UserMock.js +4 -6
- package/lib/mocks/views/ActionMenuMock.js +1 -1
- package/lib/mocks/views/ChartMock.js +3 -3
- package/lib/mocks/views/ChartMockOptions.js +24 -24
- package/lib/mocks/views/DashboardMock.js +74 -74
- package/lib/mocks/views/FormMock.js +1 -1
- package/lib/mocks/views/TableMock.js +1 -1
- package/lib/models/Account.d.ts +2 -2
- package/lib/models/Assignment.d.ts +2 -2
- package/lib/models/Cell.d.ts +1 -1
- package/lib/models/CodeBlock.d.ts +1 -1
- package/lib/models/CodefeedBlocks.d.ts +2 -2
- package/lib/models/Contact.d.ts +1 -1
- package/lib/models/Contact.js +14 -14
- package/lib/models/ContactIAMProvider.js +2 -2
- package/lib/models/Course.d.ts +7 -7
- package/lib/models/Dataset.d.ts +1 -1
- package/lib/models/Dean.d.ts +1 -1
- package/lib/models/Document.d.ts +1 -1
- package/lib/models/Environment.d.ts +2 -2
- package/lib/models/Exercise.d.ts +1 -1
- package/lib/models/IAMProviderLinked.js +1 -1
- package/lib/models/Instructor.d.ts +1 -1
- package/lib/models/Invite.d.ts +2 -2
- package/lib/models/Invite.js +1 -1
- package/lib/models/Item.d.ts +5 -5
- package/lib/models/LandingRoles.js +18 -18
- package/lib/models/Lesson.d.ts +1 -1
- package/lib/models/Member.d.ts +1 -1
- package/lib/models/Notebook.d.ts +1 -1
- package/lib/models/Organization.d.ts +4 -4
- package/lib/models/Organization.js +2 -2
- package/lib/models/OrganizationMember.d.ts +2 -2
- package/lib/models/Page.js +4 -2
- package/lib/models/PageTag.d.ts +1 -1
- package/lib/models/PageTag.js +56 -9
- package/lib/models/Profile.d.ts +1 -1
- package/lib/models/RolesOrganization.d.ts +1 -1
- package/lib/models/RolesOrganization.js +4 -12
- package/lib/models/RolesPlatform.d.ts +1 -1
- package/lib/models/RolesPlatform.js +12 -34
- package/lib/models/RolesTeam.d.ts +1 -1
- package/lib/models/RolesTeam.js +3 -10
- package/lib/models/Runtime.js +4 -4
- package/lib/models/RuntimeSnapshot.js +1 -1
- package/lib/models/School.d.ts +4 -4
- package/lib/models/Space.d.ts +5 -5
- package/lib/models/Space.js +3 -3
- package/lib/models/SpaceItem.d.ts +8 -8
- package/lib/models/SpaceMember.d.ts +2 -2
- package/lib/models/Student.d.ts +2 -2
- package/lib/models/StudentItem.d.ts +3 -3
- package/lib/models/Team.d.ts +3 -3
- package/lib/models/Team.js +2 -2
- package/lib/models/TeamMember.d.ts +2 -2
- package/lib/models/URN.js +1 -1
- package/lib/models/User.d.ts +2 -2
- package/lib/models/User.js +5 -3
- package/lib/models/UserOnboarding.d.ts +1 -1
- package/lib/models/UserOnboarding.js +7 -7
- package/lib/models/UserSettings.js +2 -2
- package/lib/models/index.d.ts +2 -2
- package/lib/models/index.js +2 -2
- package/lib/navigation/adapters/native.d.ts +11 -0
- package/lib/navigation/adapters/native.js +48 -0
- package/lib/navigation/adapters/nextjs.d.ts +9 -0
- package/lib/navigation/adapters/nextjs.js +35 -0
- package/lib/navigation/adapters/react-router.d.ts +4 -0
- package/lib/navigation/adapters/react-router.js +12 -0
- package/lib/navigation/components.d.ts +20 -0
- package/lib/navigation/components.js +36 -0
- package/lib/navigation/index.d.ts +4 -0
- package/lib/navigation/index.js +12 -0
- package/lib/routes/index.d.ts +1 -1
- package/lib/routes/index.js +1 -1
- package/lib/services/DatalayerServiceManager.d.ts +22 -0
- package/lib/services/DatalayerServiceManager.js +79 -0
- package/lib/services/index.d.ts +4 -0
- package/lib/services/index.js +7 -0
- package/lib/services/reconnectToRuntime.d.ts +32 -0
- package/lib/services/reconnectToRuntime.js +59 -0
- package/lib/state/State.d.ts +1 -1
- package/lib/state/State.js +1 -1
- package/lib/state/index.d.ts +1 -1
- package/lib/state/index.js +1 -1
- package/lib/state/storage/IAMStorage.js +14 -2
- package/lib/state/storage/index.d.ts +1 -1
- package/lib/state/storage/index.js +1 -1
- package/lib/state/substates/AIAgentState.js +4 -2
- package/lib/state/substates/CellState.js +6 -5
- package/lib/state/substates/CoreState.d.ts +1 -1
- package/lib/state/substates/CoreState.js +23 -15
- package/lib/state/substates/DatasourceState.js +1 -1
- package/lib/state/substates/IAMState.d.ts +4 -0
- package/lib/state/substates/IAMState.js +75 -56
- package/lib/state/substates/JupyterLabState.js +1 -1
- package/lib/state/substates/LayoutState.d.ts +2 -2
- package/lib/state/substates/LayoutState.js +41 -28
- package/lib/state/substates/OrganizationState.js +1 -1
- package/lib/state/substates/RuntimesState.js +6 -5
- package/lib/state/substates/SpaceState.js +1 -1
- package/lib/state/substates/SurveysState.js +4 -4
- package/lib/state/substates/TeamState.js +1 -1
- package/lib/test-setup.js +25 -3
- package/lib/theme/DatalayerTheme.js +1 -1
- package/lib/theme/DatalayerThemeProvider.js +17 -14
- package/lib/theme/Palette.js +1 -1
- package/lib/utils/Avatar.js +2 -2
- package/lib/utils/Browser.js +6 -6
- package/lib/utils/Cells.d.ts +1 -1
- package/lib/utils/Cookie.js +1 -1
- package/lib/utils/Date.js +2 -2
- package/lib/utils/Download.js +5 -3
- package/lib/utils/DownloadFile.js +4 -2
- package/lib/utils/Env.js +2 -1
- package/lib/utils/Lazy.d.ts +1 -1
- package/lib/utils/Lazy.js +2 -2
- package/lib/utils/Name.js +10 -8
- package/lib/utils/Notebook.d.ts +1 -1
- package/lib/utils/Notebook.js +3 -3
- package/lib/utils/Number.js +13 -9
- package/lib/utils/Plots.js +4 -4
- package/lib/utils/Screenshot.js +1 -1
- package/lib/utils/Sleep.js +1 -1
- package/lib/utils/Snapshot.js +2 -2
- package/lib/utils/String.js +2 -2
- package/lib/utils/Uri.js +1 -1
- package/lib/utils/WithSuspense.js +3 -6
- package/package.json +41 -5
- package/lib/__tests__/App.test.js +0 -17
- /package/lib/{__tests__/App.test.d.ts → examples/main.d.ts} +0 -0
package/lib/utils/Download.js
CHANGED
|
@@ -9,10 +9,10 @@ export function jsonToCSVString(json) {
|
|
|
9
9
|
json.forEach(obj => {
|
|
10
10
|
const rowCells = headers.map(header => {
|
|
11
11
|
const val = obj[header];
|
|
12
|
-
if (typeof val ===
|
|
12
|
+
if (typeof val === 'number') {
|
|
13
13
|
return val;
|
|
14
14
|
}
|
|
15
|
-
if (typeof val ===
|
|
15
|
+
if (typeof val === 'string') {
|
|
16
16
|
return val;
|
|
17
17
|
}
|
|
18
18
|
if (val instanceof Date) {
|
|
@@ -26,7 +26,9 @@ export function jsonToCSVString(json) {
|
|
|
26
26
|
return csvString;
|
|
27
27
|
}
|
|
28
28
|
export const downloadJson = (data, fileName, extension) => {
|
|
29
|
-
const jsonData = new Blob([JSON.stringify(data)], {
|
|
29
|
+
const jsonData = new Blob([JSON.stringify(data)], {
|
|
30
|
+
type: 'application/json',
|
|
31
|
+
});
|
|
30
32
|
const jsonURL = URL.createObjectURL(jsonData);
|
|
31
33
|
const jsonLink = document.createElement('a');
|
|
32
34
|
jsonLink.href = jsonURL;
|
|
@@ -11,9 +11,11 @@
|
|
|
11
11
|
* .zip ZIP archive application/zip
|
|
12
12
|
*/
|
|
13
13
|
export const downloadFile = (data, filename, mime, bom) => {
|
|
14
|
-
const blobData =
|
|
14
|
+
const blobData = typeof bom !== 'undefined' ? [bom, data] : [data];
|
|
15
15
|
const blob = new Blob(blobData, { type: mime || 'application/octet-stream' });
|
|
16
|
-
const blobURL =
|
|
16
|
+
const blobURL = window.URL && window.URL.createObjectURL
|
|
17
|
+
? window.URL.createObjectURL(blob)
|
|
18
|
+
: window.webkitURL.createObjectURL(blob);
|
|
17
19
|
const tempLink = document.createElement('a');
|
|
18
20
|
tempLink.style.display = 'none';
|
|
19
21
|
tempLink.href = blobURL;
|
package/lib/utils/Env.js
CHANGED
|
@@ -3,5 +3,6 @@
|
|
|
3
3
|
* Distributed under the terms of the Modified BSD License.
|
|
4
4
|
*/
|
|
5
5
|
export const isDevDeployment = () => {
|
|
6
|
-
return location.hostname.startsWith('dev') ||
|
|
6
|
+
return (location.hostname.startsWith('dev') ||
|
|
7
|
+
location.hostname.startsWith('localhost'));
|
|
7
8
|
};
|
package/lib/utils/Lazy.d.ts
CHANGED
package/lib/utils/Lazy.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
3
|
* Distributed under the terms of the Modified BSD License.
|
|
4
4
|
*/
|
|
5
|
-
import { createElement, forwardRef, lazy as reactLazy } from
|
|
5
|
+
import { createElement, forwardRef, lazy as reactLazy, } from 'react';
|
|
6
6
|
export function lazyWithPreload(factory) {
|
|
7
7
|
const LazyComponent = reactLazy(factory);
|
|
8
8
|
let factoryPromise;
|
|
@@ -12,7 +12,7 @@ export function lazyWithPreload(factory) {
|
|
|
12
12
|
});
|
|
13
13
|
Component.preload = () => {
|
|
14
14
|
if (!factoryPromise) {
|
|
15
|
-
factoryPromise = factory().then(
|
|
15
|
+
factoryPromise = factory().then(module => {
|
|
16
16
|
LoadedComponent = module.default;
|
|
17
17
|
});
|
|
18
18
|
}
|
package/lib/utils/Name.js
CHANGED
|
@@ -3,22 +3,24 @@
|
|
|
3
3
|
* Distributed under the terms of the Modified BSD License.
|
|
4
4
|
*/
|
|
5
5
|
export const asDisplayName = (givenName, familyName) => {
|
|
6
|
-
return givenName
|
|
7
|
-
familyName
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
return givenName
|
|
7
|
+
? familyName
|
|
8
|
+
? givenName + ' ' + familyName
|
|
9
|
+
: givenName
|
|
10
|
+
: (familyName ?? '');
|
|
11
11
|
};
|
|
12
12
|
export const nameAsInitials = (name) => {
|
|
13
13
|
return name
|
|
14
14
|
.replace(/\s+/, ' ')
|
|
15
15
|
.split(' ')
|
|
16
16
|
.slice(0, 2)
|
|
17
|
-
.map(
|
|
17
|
+
.map(v => v && v[0].toUpperCase())
|
|
18
18
|
.join('');
|
|
19
19
|
};
|
|
20
20
|
export const namesAsInitials = (firstName, lastName) => {
|
|
21
|
-
return ((firstName || ' ').charAt(0) + (lastName || ' ').charAt(0))
|
|
21
|
+
return ((firstName || ' ').charAt(0) + (lastName || ' ').charAt(0))
|
|
22
|
+
.toLocaleUpperCase()
|
|
23
|
+
.trim();
|
|
22
24
|
};
|
|
23
25
|
/**
|
|
24
26
|
* Convert first and last names to a friendly name.
|
|
@@ -30,5 +32,5 @@ export const toFriendlyName = (firstName, lastName) => {
|
|
|
30
32
|
if (lastName) {
|
|
31
33
|
return lastName;
|
|
32
34
|
}
|
|
33
|
-
return
|
|
35
|
+
return '';
|
|
34
36
|
};
|
package/lib/utils/Notebook.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { JupyterLab } from '@jupyterlab/application';
|
|
|
6
6
|
* @param name Notebook name
|
|
7
7
|
* @param url Notebook content URL
|
|
8
8
|
*/
|
|
9
|
-
export declare const createNotebook: ({ app, name, url, options }: {
|
|
9
|
+
export declare const createNotebook: ({ app, name, url, options, }: {
|
|
10
10
|
app: JupyterLab;
|
|
11
11
|
name?: string;
|
|
12
12
|
url?: string;
|
package/lib/utils/Notebook.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* @param name Notebook name
|
|
10
10
|
* @param url Notebook content URL
|
|
11
11
|
*/
|
|
12
|
-
export const createNotebook = async ({ app, name, url, options }) => {
|
|
12
|
+
export const createNotebook = async ({ app, name, url, options, }) => {
|
|
13
13
|
const notebook = await app.commands.execute('notebook:create-new', options);
|
|
14
14
|
/*
|
|
15
15
|
if (name) {
|
|
@@ -22,7 +22,7 @@ export const createNotebook = async ({ app, name, url, options }) => {
|
|
|
22
22
|
const text = nbmodelText.replaceAll('\n', `
|
|
23
23
|
`);
|
|
24
24
|
notebook.context.model.fromJSON({
|
|
25
|
-
...JSON.parse(text)
|
|
25
|
+
...JSON.parse(text),
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
28
|
};
|
|
@@ -32,6 +32,6 @@ export const createNotebookVariant = async (app, name, url) => {
|
|
|
32
32
|
const nbmodel = await fetch(url);
|
|
33
33
|
const text = (await nbmodel.text()).replaceAll('\\n', '');
|
|
34
34
|
notebook.context.model.fromJSON({
|
|
35
|
-
...JSON.parse(text)
|
|
35
|
+
...JSON.parse(text),
|
|
36
36
|
});
|
|
37
37
|
};
|
package/lib/utils/Number.js
CHANGED
|
@@ -3,19 +3,23 @@
|
|
|
3
3
|
* Distributed under the terms of the Modified BSD License.
|
|
4
4
|
*/
|
|
5
5
|
const LOOKUP_VALUE_SYMBOL = [
|
|
6
|
-
{ value: 1, symbol:
|
|
7
|
-
{ value: 1e3, symbol:
|
|
8
|
-
{ value: 1e6, symbol:
|
|
9
|
-
{ value: 1e9, symbol:
|
|
10
|
-
{ value: 1e12, symbol:
|
|
11
|
-
{ value: 1e15, symbol:
|
|
12
|
-
{ value: 1e18, symbol:
|
|
6
|
+
{ value: 1, symbol: '' },
|
|
7
|
+
{ value: 1e3, symbol: 'K' },
|
|
8
|
+
{ value: 1e6, symbol: 'M' },
|
|
9
|
+
{ value: 1e9, symbol: 'G' },
|
|
10
|
+
{ value: 1e12, symbol: 'T' },
|
|
11
|
+
{ value: 1e15, symbol: 'P' },
|
|
12
|
+
{ value: 1e18, symbol: 'E' },
|
|
13
13
|
];
|
|
14
14
|
// https://stackoverflow.com/questions/9461621/format-a-number-as-2-5k-if-a-thousand-or-more-otherwise-900
|
|
15
15
|
export function numberFormatter(num, digits = 1) {
|
|
16
16
|
const rx = /\.0+$|(\.[0-9]*[1-9])0+$/;
|
|
17
|
-
const item = LOOKUP_VALUE_SYMBOL.slice()
|
|
17
|
+
const item = LOOKUP_VALUE_SYMBOL.slice()
|
|
18
|
+
.reverse()
|
|
19
|
+
.find(function (item) {
|
|
18
20
|
return num >= item.value;
|
|
19
21
|
});
|
|
20
|
-
return item
|
|
22
|
+
return item
|
|
23
|
+
? (num / item.value).toFixed(digits).replace(rx, '$1') + item.symbol
|
|
24
|
+
: '0';
|
|
21
25
|
}
|
package/lib/utils/Plots.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
3
|
* Distributed under the terms of the Modified BSD License.
|
|
4
4
|
*/
|
|
5
|
-
import { getDate, getDaysInMonth, getMonth, isSameMonth, isSameYear } from 'date-fns';
|
|
5
|
+
import { getDate, getDaysInMonth, getMonth, isSameMonth, isSameYear, } from 'date-fns';
|
|
6
6
|
/**
|
|
7
7
|
* Compute the data for plotting the usage histogram.
|
|
8
8
|
*
|
|
@@ -26,7 +26,7 @@ export function createHistogram(usages, interval, range) {
|
|
|
26
26
|
? c.credits
|
|
27
27
|
: ((end - start.getTime()) * c.burningRate) / 1000,
|
|
28
28
|
// getDate is 1-based but getMonth is 0-based
|
|
29
|
-
category: interval === 0 ? getDate(start) - 1 : getMonth(start)
|
|
29
|
+
category: interval === 0 ? getDate(start) - 1 : getMonth(start),
|
|
30
30
|
};
|
|
31
31
|
})
|
|
32
32
|
.reduce((agg, d) => {
|
|
@@ -49,8 +49,8 @@ export function createHistogram(usages, interval, range) {
|
|
|
49
49
|
'Sep',
|
|
50
50
|
'Oct',
|
|
51
51
|
'Nov',
|
|
52
|
-
'Dec'
|
|
52
|
+
'Dec',
|
|
53
53
|
],
|
|
54
|
-
y: credits
|
|
54
|
+
y: credits,
|
|
55
55
|
};
|
|
56
56
|
}
|
package/lib/utils/Screenshot.js
CHANGED
|
@@ -8,7 +8,7 @@ export const takeHTMLNodeScreenshot = async (node) => {
|
|
|
8
8
|
width: node.getBoundingClientRect().width,
|
|
9
9
|
height: node.getBoundingClientRect().height,
|
|
10
10
|
});
|
|
11
|
-
return sc.then(
|
|
11
|
+
return sc.then(canvas => {
|
|
12
12
|
const croppedCanvas = document.createElement('canvas');
|
|
13
13
|
const croppedCanvasContext = croppedCanvas.getContext('2d');
|
|
14
14
|
const top = 0;
|
package/lib/utils/Sleep.js
CHANGED
package/lib/utils/Snapshot.js
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
3
|
* Distributed under the terms of the Modified BSD License.
|
|
4
4
|
*/
|
|
5
|
-
import { adjectives, animals, uniqueNamesGenerator } from 'unique-names-generator';
|
|
5
|
+
import { adjectives, animals, uniqueNamesGenerator, } from 'unique-names-generator';
|
|
6
6
|
/**
|
|
7
7
|
* Kernel snapshot description configuration.
|
|
8
8
|
*/
|
|
9
9
|
const KERNEL_SNAPSHOT_DESCRIPTION_CONFIGURATION = {
|
|
10
10
|
dictionaries: [adjectives, animals],
|
|
11
|
-
separator: '-'
|
|
11
|
+
separator: '-',
|
|
12
12
|
};
|
|
13
13
|
/**
|
|
14
14
|
* Create an unique human readable kernel snapshot name.
|
package/lib/utils/String.js
CHANGED
package/lib/utils/Uri.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Distributed under the terms of the Modified BSD License.
|
|
4
4
|
*/
|
|
5
5
|
export const currentUri = () => {
|
|
6
|
-
return window.location.protocol +
|
|
6
|
+
return window.location.protocol + '//' + window.location.host;
|
|
7
7
|
};
|
|
8
8
|
// https://stackoverflow.com/questions/12168909/blob-from-dataurl
|
|
9
9
|
export const dataURItoBlob = (dataURI) => {
|
|
@@ -3,14 +3,11 @@ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
|
3
3
|
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
4
4
|
* Distributed under the terms of the Modified BSD License.
|
|
5
5
|
*/
|
|
6
|
-
import { Suspense } from
|
|
7
|
-
import { SkeletonBox } from
|
|
6
|
+
import { Suspense } from 'react';
|
|
7
|
+
import { SkeletonBox } from '@primer/react/experimental';
|
|
8
8
|
const Loading = (props) => {
|
|
9
9
|
const { skeleton } = props;
|
|
10
|
-
return
|
|
11
|
-
_jsx(_Fragment, { children: _jsx(SkeletonBox, { height: "100px" }) })
|
|
12
|
-
:
|
|
13
|
-
_jsx(_Fragment, {}));
|
|
10
|
+
return skeleton ? (_jsx(_Fragment, { children: _jsx(SkeletonBox, { height: "100px" }) })) : (_jsx(_Fragment, {}));
|
|
14
11
|
};
|
|
15
12
|
export const WithSuspense = (Component, preload = true, skeleton = false) => (props) => {
|
|
16
13
|
if (preload) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datalayer/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"type": "module",
|
|
5
|
+
"workspaces": [
|
|
6
|
+
".",
|
|
7
|
+
"examples/*"
|
|
8
|
+
],
|
|
5
9
|
"author": {
|
|
6
10
|
"name": "Datalayer",
|
|
7
11
|
"email": "info@datalayer.io"
|
|
@@ -43,7 +47,13 @@
|
|
|
43
47
|
"dev": "vite",
|
|
44
48
|
"build": "gulp resources-to-lib && tsc -b && vite build",
|
|
45
49
|
"build:lib": "gulp resources-to-lib && tsc -b",
|
|
46
|
-
"lint": "eslint .",
|
|
50
|
+
"lint": "eslint . --quiet && npm run lint --workspace=nextjs-notebook-example",
|
|
51
|
+
"lint:fix": "eslint . --fix && npm run lint:fix --workspace=nextjs-notebook-example",
|
|
52
|
+
"format": "prettier --write \"{src,examples}/**/*.{js,jsx,ts,tsx,css,json,md,mjs}\" && npm run format --workspace=nextjs-notebook-example",
|
|
53
|
+
"format:check": "prettier --check \"{src,examples}/**/*.{js,jsx,ts,tsx,css,json,md,mjs}\" && npm run format:check --workspace=nextjs-notebook-example",
|
|
54
|
+
"type-check": "tsc --noEmit && npm run type-check --workspace=nextjs-notebook-example",
|
|
55
|
+
"check": "npm run format:check && npm run lint && npm run type-check",
|
|
56
|
+
"check:fix": "npm run format && npm run lint:fix && npm run type-check",
|
|
47
57
|
"preview": "vite preview",
|
|
48
58
|
"start": "vite",
|
|
49
59
|
"clean": "rimraf lib tsconfig.tsbuildinfo",
|
|
@@ -57,11 +67,14 @@
|
|
|
57
67
|
"typedoc": "typedoc --options typedoc.json --out docs/docs/typescript_api",
|
|
58
68
|
"watch:lib": "run-p 'watch:lib:*'",
|
|
59
69
|
"watch:lib:res": "gulp resources-to-lib-watch",
|
|
60
|
-
"watch:lib:src": "tsc -b -w"
|
|
70
|
+
"watch:lib:src": "tsc -b -w",
|
|
71
|
+
"example": "vite --config vite.examples.config.ts",
|
|
72
|
+
"example:nextjs": "npm run dev --workspace=nextjs-notebook-example",
|
|
73
|
+
"prepare": "husky"
|
|
61
74
|
},
|
|
62
75
|
"dependencies": {
|
|
63
76
|
"@datalayer/icons-react": "^1.0.6",
|
|
64
|
-
"@datalayer/jupyter-react": "^1.0
|
|
77
|
+
"@datalayer/jupyter-react": "^1.1.0",
|
|
65
78
|
"@datalayer/primer-addons": "^1.0.3",
|
|
66
79
|
"@datalayer/primer-rjsf": "^1.0.1",
|
|
67
80
|
"@jupyterlab/coreutils": "^6.0.0",
|
|
@@ -89,7 +102,6 @@
|
|
|
89
102
|
"react": "18.3.1",
|
|
90
103
|
"react-confetti": "^6.4.0",
|
|
91
104
|
"react-dom": "18.3.1",
|
|
92
|
-
"react-router-dom": "^6.22.3",
|
|
93
105
|
"tus-js-client": "^4.2.3",
|
|
94
106
|
"ulid": "^2.3.0",
|
|
95
107
|
"unique-names-generator": "^4.7.1",
|
|
@@ -97,9 +109,18 @@
|
|
|
97
109
|
"validator": "^13.7.0",
|
|
98
110
|
"zustand": "^4.4.1"
|
|
99
111
|
},
|
|
112
|
+
"peerDependencies": {
|
|
113
|
+
"react-router-dom": "^6.0.0"
|
|
114
|
+
},
|
|
115
|
+
"peerDependenciesMeta": {
|
|
116
|
+
"react-router-dom": {
|
|
117
|
+
"optional": true
|
|
118
|
+
}
|
|
119
|
+
},
|
|
100
120
|
"devDependencies": {
|
|
101
121
|
"@chromatic-com/storybook": "^4.1.0",
|
|
102
122
|
"@eslint/js": "^9.29.0",
|
|
123
|
+
"react-router-dom": "^6.22.3",
|
|
103
124
|
"@storybook/addon-a11y": "^9.1.1",
|
|
104
125
|
"@storybook/addon-docs": "^9.1.1",
|
|
105
126
|
"@storybook/addon-onboarding": "^9.1.1",
|
|
@@ -114,6 +135,9 @@
|
|
|
114
135
|
"@vitest/coverage-v8": "^3.2.4",
|
|
115
136
|
"crypto-browserify": "^3.12.1",
|
|
116
137
|
"eslint": "^9.29.0",
|
|
138
|
+
"eslint-config-prettier": "^10.1.8",
|
|
139
|
+
"eslint-plugin-prettier": "^5.5.4",
|
|
140
|
+
"eslint-plugin-react": "^7.37.5",
|
|
117
141
|
"eslint-plugin-react-hooks": "^5.2.0",
|
|
118
142
|
"eslint-plugin-react-refresh": "^0.4.20",
|
|
119
143
|
"eslint-plugin-storybook": "^9.1.1",
|
|
@@ -122,9 +146,12 @@
|
|
|
122
146
|
"gulp-append-prepend": "^1.0.8",
|
|
123
147
|
"gulp-filter": "^6.0.0",
|
|
124
148
|
"gulp-watch": "^5.0.1",
|
|
149
|
+
"husky": "^9.1.7",
|
|
125
150
|
"jsdom": "^26.0.0",
|
|
151
|
+
"lint-staged": "^16.1.5",
|
|
126
152
|
"npm-run-all": "^4.1.5",
|
|
127
153
|
"playwright": "^1.53.2",
|
|
154
|
+
"prettier": "^3.6.2",
|
|
128
155
|
"rimraf": "^6.0.1",
|
|
129
156
|
"storybook": "^9.1.1",
|
|
130
157
|
"typedoc-plugin-markdown": "^4.0.0",
|
|
@@ -148,5 +175,14 @@
|
|
|
148
175
|
"react": "18.3.1",
|
|
149
176
|
"react-dom": "18.3.1",
|
|
150
177
|
"typescript": "^5.8.3"
|
|
178
|
+
},
|
|
179
|
+
"lint-staged": {
|
|
180
|
+
"src/**/*.{js,jsx,ts,tsx}": [
|
|
181
|
+
"prettier --write",
|
|
182
|
+
"eslint --fix"
|
|
183
|
+
],
|
|
184
|
+
"src/**/*.{css,json,md}": [
|
|
185
|
+
"prettier --write"
|
|
186
|
+
]
|
|
151
187
|
}
|
|
152
188
|
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
|
-
* Distributed under the terms of the Modified BSD License.
|
|
4
|
-
*/
|
|
5
|
-
import { describe, it, expect } from 'vitest';
|
|
6
|
-
import { App } from '../App';
|
|
7
|
-
describe('App Component', () => {
|
|
8
|
-
it('should be a function component', () => {
|
|
9
|
-
expect(typeof App).toBe('function');
|
|
10
|
-
});
|
|
11
|
-
it('should be defined', () => {
|
|
12
|
-
expect(App).toBeDefined();
|
|
13
|
-
});
|
|
14
|
-
it('component name should be App', () => {
|
|
15
|
-
expect(App.name).toBe('App');
|
|
16
|
-
});
|
|
17
|
-
});
|
|
File without changes
|