@deephaven/app-utils 0.82.0 → 0.82.1-alpha-combobox.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/components/ConnectionBootstrap.d.ts.map +1 -1
  2. package/dist/components/ConnectionBootstrap.js +82 -6
  3. package/dist/components/ConnectionBootstrap.js.map +1 -1
  4. package/dist/index.d.ts +1 -0
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +1 -0
  7. package/dist/index.js.map +1 -1
  8. package/dist/storage/LayoutStorage.d.ts +35 -0
  9. package/dist/storage/LayoutStorage.d.ts.map +1 -0
  10. package/dist/storage/LayoutStorage.js +15 -0
  11. package/dist/storage/LayoutStorage.js.map +1 -0
  12. package/dist/storage/LocalWorkspaceStorage.d.ts +18 -0
  13. package/dist/storage/LocalWorkspaceStorage.d.ts.map +1 -0
  14. package/dist/storage/LocalWorkspaceStorage.js +131 -0
  15. package/dist/storage/LocalWorkspaceStorage.js.map +1 -0
  16. package/dist/storage/UserLayoutUtils.d.ts +20 -0
  17. package/dist/storage/UserLayoutUtils.d.ts.map +1 -0
  18. package/dist/storage/UserLayoutUtils.js +131 -0
  19. package/dist/storage/UserLayoutUtils.js.map +1 -0
  20. package/dist/storage/grpc/GrpcFileStorage.d.ts +28 -0
  21. package/dist/storage/grpc/GrpcFileStorage.d.ts.map +1 -0
  22. package/dist/storage/grpc/GrpcFileStorage.js +126 -0
  23. package/dist/storage/grpc/GrpcFileStorage.js.map +1 -0
  24. package/dist/storage/grpc/GrpcFileStorageTable.d.ts +52 -0
  25. package/dist/storage/grpc/GrpcFileStorageTable.d.ts.map +1 -0
  26. package/dist/storage/grpc/GrpcFileStorageTable.js +245 -0
  27. package/dist/storage/grpc/GrpcFileStorageTable.js.map +1 -0
  28. package/dist/storage/grpc/GrpcLayoutStorage.d.ts +16 -0
  29. package/dist/storage/grpc/GrpcLayoutStorage.d.ts.map +1 -0
  30. package/dist/storage/grpc/GrpcLayoutStorage.js +36 -0
  31. package/dist/storage/grpc/GrpcLayoutStorage.js.map +1 -0
  32. package/dist/storage/grpc/index.d.ts +4 -0
  33. package/dist/storage/grpc/index.d.ts.map +1 -0
  34. package/dist/storage/grpc/index.js +4 -0
  35. package/dist/storage/grpc/index.js.map +1 -0
  36. package/dist/storage/index.d.ts +6 -0
  37. package/dist/storage/index.d.ts.map +1 -0
  38. package/dist/storage/index.js +6 -0
  39. package/dist/storage/index.js.map +1 -0
  40. package/package.json +24 -20
@@ -1 +1 @@
1
- {"version":3,"file":"ConnectionBootstrap.d.ts","sourceRoot":"","sources":["../../src/components/ConnectionBootstrap.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoD,MAAM,OAAO,CAAC;AAiBzE,MAAM,MAAM,wBAAwB,GAAG;IACrC;;;OAGG;IACH,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,CAAC;AAEF;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,EAClC,QAAQ,GACT,EAAE,wBAAwB,GAAG,GAAG,CAAC,OAAO,CA+FxC;AAED,eAAe,mBAAmB,CAAC"}
1
+ {"version":3,"file":"ConnectionBootstrap.d.ts","sourceRoot":"","sources":["../../src/components/ConnectionBootstrap.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoD,MAAM,OAAO,CAAC;AAwBzE,MAAM,MAAM,wBAAwB,GAAG;IACrC;;;OAGG;IACH,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,CAAC;AAEF;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,EAClC,QAAQ,GACT,EAAE,wBAAwB,GAAG,GAAG,CAAC,OAAO,CAwMxC;AAED,eAAe,mBAAmB,CAAC"}
@@ -1,12 +1,15 @@
1
1
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
2
2
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
3
3
  import React, { useCallback, useEffect, useMemo, useState } from 'react';
4
- import { LoadingOverlay } from '@deephaven/components';
4
+ import { BasicModal, DebouncedModal, InfoModal, LoadingOverlay, LoadingSpinner } from '@deephaven/components';
5
5
  import { ObjectFetcherContext, ObjectFetchManagerContext, sanitizeVariableDescriptor, useApi, useClient } from '@deephaven/jsapi-bootstrap';
6
6
  import Log from '@deephaven/log';
7
7
  import { assertNotNull } from '@deephaven/utils';
8
+ import { vsDebugDisconnect } from '@deephaven/icons';
8
9
  import ConnectionContext from "./ConnectionContext.js";
9
10
  import { jsx as _jsx } from "react/jsx-runtime";
11
+ import { Fragment as _Fragment } from "react/jsx-runtime";
12
+ import { jsxs as _jsxs } from "react/jsx-runtime";
10
13
  var log = Log.module('@deephaven/app-utils.ConnectionBootstrap');
11
14
  /**
12
15
  * ConnectionBootstrap component. Handles initializing the connection.
@@ -19,6 +22,11 @@ export function ConnectionBootstrap(_ref) {
19
22
  var client = useClient();
20
23
  var [error, setError] = useState();
21
24
  var [connection, setConnection] = useState();
25
+ var [connectionState, setConnectionState] = useState('connecting');
26
+ var isAuthFailed = connectionState === 'failed';
27
+ var isShutdown = connectionState === 'shutdown';
28
+ var isReconnecting = connectionState === 'reconnecting';
29
+ var isNotConnecting = connectionState === 'not_connecting';
22
30
  useEffect(function initConnection() {
23
31
  var isCanceled = false;
24
32
  function loadConnection() {
@@ -32,11 +40,13 @@ export function ConnectionBootstrap(_ref) {
32
40
  return;
33
41
  }
34
42
  setConnection(newConnection);
43
+ setConnectionState('connected');
35
44
  } catch (e) {
36
45
  if (isCanceled) {
37
46
  return;
38
47
  }
39
48
  setError(e);
49
+ setConnectionState('not_connecting');
40
50
  }
41
51
  });
42
52
  return _loadConnection.apply(this, arguments);
@@ -46,18 +56,64 @@ export function ConnectionBootstrap(_ref) {
46
56
  isCanceled = true;
47
57
  };
48
58
  }, [api, client]);
59
+ useEffect(function listenForDisconnect() {
60
+ if (connection == null || isShutdown) return;
61
+
62
+ // handles the disconnect event
63
+ function handleDisconnect(event) {
64
+ var {
65
+ detail
66
+ } = event;
67
+ log.info('Disconnect', "".concat(JSON.stringify(detail)));
68
+ setConnectionState('reconnecting');
69
+ }
70
+ var removerFn = connection.addEventListener(api.IdeConnection.EVENT_DISCONNECT, handleDisconnect);
71
+ return removerFn;
72
+ }, [api, connection, isShutdown]);
73
+ useEffect(function listenForReconnect() {
74
+ if (connection == null || isShutdown) return;
75
+
76
+ // handles the reconnect event
77
+ function handleReconnect(event) {
78
+ var {
79
+ detail
80
+ } = event;
81
+ log.info('Reconnect', "".concat(JSON.stringify(detail)));
82
+ setConnectionState('connected');
83
+ }
84
+ var removerFn = connection.addEventListener(api.CoreClient.EVENT_RECONNECT, handleReconnect);
85
+ return removerFn;
86
+ }, [api, connection, isShutdown]);
49
87
  useEffect(function listenForShutdown() {
50
88
  if (connection == null) return;
89
+
90
+ // handles the shutdown event
51
91
  function handleShutdown(event) {
52
92
  var {
53
93
  detail
54
94
  } = event;
55
95
  log.info('Shutdown', "".concat(JSON.stringify(detail)));
56
96
  setError("Server shutdown: ".concat(detail !== null && detail !== void 0 ? detail : 'Unknown reason'));
97
+ setConnectionState('shutdown');
57
98
  }
58
99
  var removerFn = connection.addEventListener(api.IdeConnection.EVENT_SHUTDOWN, handleShutdown);
59
100
  return removerFn;
60
101
  }, [api, connection]);
102
+ useEffect(function listenForAuthFailed() {
103
+ if (connection == null || isShutdown) return;
104
+
105
+ // handles the auth failed event
106
+ function handleAuthFailed(event) {
107
+ var {
108
+ detail
109
+ } = event;
110
+ log.warn('Reconnect authentication failed', "".concat(JSON.stringify(detail)));
111
+ setError("Reconnect authentication failed: ".concat(detail !== null && detail !== void 0 ? detail : 'Unknown reason'));
112
+ setConnectionState('failed');
113
+ }
114
+ var removerFn = connection.addEventListener(api.CoreClient.EVENT_RECONNECT_AUTH_FAILED, handleAuthFailed);
115
+ return removerFn;
116
+ }, [api, connection, isShutdown]);
61
117
  var objectFetcher = useCallback( /*#__PURE__*/function () {
62
118
  var _ref2 = _asyncToGenerator(function* (descriptor) {
63
119
  assertNotNull(connection, 'No connection available to fetch object with');
@@ -82,20 +138,40 @@ export function ConnectionBootstrap(_ref) {
82
138
  };
83
139
  }
84
140
  }), [objectFetcher]);
85
- if (connection == null || error != null) {
141
+ function handleRefresh() {
142
+ log.info('Refreshing application');
143
+ window.location.reload();
144
+ }
145
+ if (isShutdown || connectionState === 'connecting' || isNotConnecting) {
86
146
  return /*#__PURE__*/_jsx(LoadingOverlay, {
87
147
  "data-testid": "connection-bootstrap-loading",
88
- isLoading: connection == null,
148
+ isLoading: false,
89
149
  errorMessage: error != null ? "".concat(error) : undefined
90
150
  });
91
151
  }
92
152
  return /*#__PURE__*/_jsx(ConnectionContext.Provider, {
93
- value: connection,
153
+ value: connection !== null && connection !== void 0 ? connection : null,
94
154
  children: /*#__PURE__*/_jsx(ObjectFetcherContext.Provider, {
95
155
  value: objectFetcher,
96
- children: /*#__PURE__*/_jsx(ObjectFetchManagerContext.Provider, {
156
+ children: /*#__PURE__*/_jsxs(ObjectFetchManagerContext.Provider, {
97
157
  value: objectManager,
98
- children: children
158
+ children: [children, /*#__PURE__*/_jsx(DebouncedModal, {
159
+ isOpen: isReconnecting,
160
+ debounceMs: 1000,
161
+ children: /*#__PURE__*/_jsx(InfoModal, {
162
+ icon: vsDebugDisconnect,
163
+ title: /*#__PURE__*/_jsxs(_Fragment, {
164
+ children: [/*#__PURE__*/_jsx(LoadingSpinner, {}), " Attempting to reconnect..."]
165
+ }),
166
+ subtitle: "Please check your network connection."
167
+ })
168
+ }), /*#__PURE__*/_jsx(BasicModal, {
169
+ confirmButtonText: "Refresh",
170
+ onConfirm: handleRefresh,
171
+ isOpen: isAuthFailed,
172
+ headerText: "Authentication failed",
173
+ bodyText: "Credentials are invalid. Please refresh your browser to try and reconnect."
174
+ })]
99
175
  })
100
176
  })
101
177
  });
@@ -1 +1 @@
1
- {"version":3,"file":"ConnectionBootstrap.js","names":["React","useCallback","useEffect","useMemo","useState","LoadingOverlay","ObjectFetcherContext","ObjectFetchManagerContext","sanitizeVariableDescriptor","useApi","useClient","Log","assertNotNull","ConnectionContext","jsx","_jsx","log","module","ConnectionBootstrap","_ref","children","api","client","error","setError","connection","setConnection","initConnection","isCanceled","loadConnection","_loadConnection","apply","arguments","_asyncToGenerator","newConnection","getAsIdeConnection","e","listenForShutdown","handleShutdown","event","detail","info","concat","JSON","stringify","removerFn","addEventListener","IdeConnection","EVENT_SHUTDOWN","objectFetcher","_ref2","descriptor","getObject","_x","objectManager","subscribe","onUpdate","fetch","status","isLoading","errorMessage","undefined","Provider","value"],"sources":["../../src/components/ConnectionBootstrap.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useMemo, useState } from 'react';\nimport { LoadingOverlay } from '@deephaven/components';\nimport {\n ObjectFetcherContext,\n ObjectFetchManager,\n ObjectFetchManagerContext,\n sanitizeVariableDescriptor,\n useApi,\n useClient,\n} from '@deephaven/jsapi-bootstrap';\nimport type { dh } from '@deephaven/jsapi-types';\nimport Log from '@deephaven/log';\nimport { assertNotNull } from '@deephaven/utils';\nimport ConnectionContext from './ConnectionContext';\n\nconst log = Log.module('@deephaven/app-utils.ConnectionBootstrap');\n\nexport type ConnectionBootstrapProps = {\n /**\n * The children to render wrapped with the ConnectionContext.\n * Will not render children until the connection is created.\n */\n children: React.ReactNode;\n};\n\n/**\n * ConnectionBootstrap component. Handles initializing the connection.\n */\nexport function ConnectionBootstrap({\n children,\n}: ConnectionBootstrapProps): JSX.Element {\n const api = useApi();\n const client = useClient();\n const [error, setError] = useState<unknown>();\n const [connection, setConnection] = useState<dh.IdeConnection>();\n\n useEffect(\n function initConnection() {\n let isCanceled = false;\n async function loadConnection(): Promise<void> {\n try {\n const newConnection = await client.getAsIdeConnection();\n if (isCanceled) {\n return;\n }\n setConnection(newConnection);\n } catch (e) {\n if (isCanceled) {\n return;\n }\n setError(e);\n }\n }\n loadConnection();\n return () => {\n isCanceled = true;\n };\n },\n [api, client]\n );\n\n useEffect(\n function listenForShutdown() {\n if (connection == null) return;\n\n function handleShutdown(event: CustomEvent): void {\n const { detail } = event;\n log.info('Shutdown', `${JSON.stringify(detail)}`);\n setError(`Server shutdown: ${detail ?? 'Unknown reason'}`);\n }\n\n const removerFn = connection.addEventListener(\n api.IdeConnection.EVENT_SHUTDOWN,\n handleShutdown\n );\n return removerFn;\n },\n [api, connection]\n );\n\n const objectFetcher = useCallback(\n async (descriptor: dh.ide.VariableDescriptor) => {\n assertNotNull(connection, 'No connection available to fetch object with');\n return connection.getObject(sanitizeVariableDescriptor(descriptor));\n },\n [connection]\n );\n\n /** We don't really need to do anything fancy in Core to manage an object, just fetch it */\n const objectManager: ObjectFetchManager = useMemo(\n () => ({\n subscribe: (descriptor, onUpdate) => {\n // We send an update with the fetch right away\n onUpdate({\n fetch: () => objectFetcher(descriptor),\n status: 'ready',\n });\n return () => {\n // no-op\n // For Core, if the server dies then we can't reconnect anyway, so no need to bother listening for subscription or cleaning up\n };\n },\n }),\n [objectFetcher]\n );\n\n if (connection == null || error != null) {\n return (\n <LoadingOverlay\n data-testid=\"connection-bootstrap-loading\"\n isLoading={connection == null}\n errorMessage={error != null ? `${error}` : undefined}\n />\n );\n }\n\n return (\n <ConnectionContext.Provider value={connection}>\n <ObjectFetcherContext.Provider value={objectFetcher}>\n <ObjectFetchManagerContext.Provider value={objectManager}>\n {children}\n </ObjectFetchManagerContext.Provider>\n </ObjectFetcherContext.Provider>\n </ConnectionContext.Provider>\n );\n}\n\nexport default ConnectionBootstrap;\n"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,OAAO;AAC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AAM;QACX;QACA;MAAA,CACD;IACH;EACF,CAAC,CAAC,EACF,CAACT,aAAa,CAChB,CAAC;EAED,IAAIxB,UAAU,IAAI,IAAI,IAAIF,KAAK,IAAI,IAAI,EAAE;IACvC,oBACER,IAAA,CAACV,cAAc;MACb,eAAY,8BAA8B;MAC1CsD,SAAS,EAAElC,UAAU,IAAI,IAAK;MAC9BmC,YAAY,EAAErC,KAAK,IAAI,IAAI,MAAAmB,MAAA,CAAMnB,KAAK,IAAKsC;IAAU,CACtD,CAAC;EAEN;EAEA,oBACE9C,IAAA,CAACF,iBAAiB,CAACiD,QAAQ;IAACC,KAAK,EAAEtC,UAAW;IAAAL,QAAA,eAC5CL,IAAA,CAACT,oBAAoB,CAACwD,QAAQ;MAACC,KAAK,EAAEd,aAAc;MAAA7B,QAAA,eAClDL,IAAA,CAACR,yBAAyB,CAACuD,QAAQ;QAACC,KAAK,EAAET,aAAc;QAAAlC,QAAA,EACtDA;MAAQ,CACyB;IAAC,CACR;EAAC,CACN,CAAC;AAEjC;AAEA,eAAeF,mBAAmB"}
1
+ {"version":3,"file":"ConnectionBootstrap.js","names":["React","useCallback","useEffect","useMemo","useState","BasicModal","DebouncedModal","InfoModal","LoadingOverlay","LoadingSpinner","ObjectFetcherContext","ObjectFetchManagerContext","sanitizeVariableDescriptor","useApi","useClient","Log","assertNotNull","vsDebugDisconnect","ConnectionContext","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","log","module","ConnectionBootstrap","_ref","children","api","client","error","setError","connection","setConnection","connectionState","setConnectionState","isAuthFailed","isShutdown","isReconnecting","isNotConnecting","initConnection","isCanceled","loadConnection","_loadConnection","apply","arguments","_asyncToGenerator","newConnection","getAsIdeConnection","e","listenForDisconnect","handleDisconnect","event","detail","info","concat","JSON","stringify","removerFn","addEventListener","IdeConnection","EVENT_DISCONNECT","listenForReconnect","handleReconnect","CoreClient","EVENT_RECONNECT","listenForShutdown","handleShutdown","EVENT_SHUTDOWN","listenForAuthFailed","handleAuthFailed","warn","EVENT_RECONNECT_AUTH_FAILED","objectFetcher","_ref2","descriptor","getObject","_x","objectManager","subscribe","onUpdate","fetch","status","handleRefresh","window","location","reload","isLoading","errorMessage","undefined","Provider","value","isOpen","debounceMs","icon","title","subtitle","confirmButtonText","onConfirm","headerText","bodyText"],"sources":["../../src/components/ConnectionBootstrap.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useMemo, useState } from 'react';\nimport {\n BasicModal,\n DebouncedModal,\n InfoModal,\n LoadingOverlay,\n LoadingSpinner,\n} from '@deephaven/components';\nimport {\n ObjectFetcherContext,\n ObjectFetchManager,\n ObjectFetchManagerContext,\n sanitizeVariableDescriptor,\n useApi,\n useClient,\n} from '@deephaven/jsapi-bootstrap';\nimport type { dh } from '@deephaven/jsapi-types';\nimport Log from '@deephaven/log';\nimport { assertNotNull } from '@deephaven/utils';\nimport { vsDebugDisconnect } from '@deephaven/icons';\nimport ConnectionContext from './ConnectionContext';\n\nconst log = Log.module('@deephaven/app-utils.ConnectionBootstrap');\n\nexport type ConnectionBootstrapProps = {\n /**\n * The children to render wrapped with the ConnectionContext.\n * Will not render children until the connection is created.\n */\n children: React.ReactNode;\n};\n\n/**\n * ConnectionBootstrap component. Handles initializing the connection.\n */\nexport function ConnectionBootstrap({\n children,\n}: ConnectionBootstrapProps): JSX.Element {\n const api = useApi();\n const client = useClient();\n const [error, setError] = useState<unknown>();\n const [connection, setConnection] = useState<dh.IdeConnection>();\n const [connectionState, setConnectionState] = useState<\n | 'not_connecting'\n | 'connecting'\n | 'connected'\n | 'reconnecting'\n | 'failed'\n | 'shutdown'\n >('connecting');\n const isAuthFailed = connectionState === 'failed';\n const isShutdown = connectionState === 'shutdown';\n const isReconnecting = connectionState === 'reconnecting';\n const isNotConnecting = connectionState === 'not_connecting';\n\n useEffect(\n function initConnection() {\n let isCanceled = false;\n async function loadConnection(): Promise<void> {\n try {\n const newConnection = await client.getAsIdeConnection();\n if (isCanceled) {\n return;\n }\n setConnection(newConnection);\n setConnectionState('connected');\n } catch (e) {\n if (isCanceled) {\n return;\n }\n setError(e);\n setConnectionState('not_connecting');\n }\n }\n loadConnection();\n return () => {\n isCanceled = true;\n };\n },\n [api, client]\n );\n\n useEffect(\n function listenForDisconnect() {\n if (connection == null || isShutdown) return;\n\n // handles the disconnect event\n function handleDisconnect(event: CustomEvent): void {\n const { detail } = event;\n log.info('Disconnect', `${JSON.stringify(detail)}`);\n setConnectionState('reconnecting');\n }\n const removerFn = connection.addEventListener(\n api.IdeConnection.EVENT_DISCONNECT,\n handleDisconnect\n );\n\n return removerFn;\n },\n [api, connection, isShutdown]\n );\n\n useEffect(\n function listenForReconnect() {\n if (connection == null || isShutdown) return;\n\n // handles the reconnect event\n function handleReconnect(event: CustomEvent): void {\n const { detail } = event;\n log.info('Reconnect', `${JSON.stringify(detail)}`);\n setConnectionState('connected');\n }\n const removerFn = connection.addEventListener(\n api.CoreClient.EVENT_RECONNECT,\n handleReconnect\n );\n\n return removerFn;\n },\n [api, connection, isShutdown]\n );\n\n useEffect(\n function listenForShutdown() {\n if (connection == null) return;\n\n // handles the shutdown event\n function handleShutdown(event: CustomEvent): void {\n const { detail } = event;\n log.info('Shutdown', `${JSON.stringify(detail)}`);\n setError(`Server shutdown: ${detail ?? 'Unknown reason'}`);\n setConnectionState('shutdown');\n }\n const removerFn = connection.addEventListener(\n api.IdeConnection.EVENT_SHUTDOWN,\n handleShutdown\n );\n\n return removerFn;\n },\n [api, connection]\n );\n\n useEffect(\n function listenForAuthFailed() {\n if (connection == null || isShutdown) return;\n\n // handles the auth failed event\n function handleAuthFailed(event: CustomEvent): void {\n const { detail } = event;\n log.warn(\n 'Reconnect authentication failed',\n `${JSON.stringify(detail)}`\n );\n setError(\n `Reconnect authentication failed: ${detail ?? 'Unknown reason'}`\n );\n setConnectionState('failed');\n }\n const removerFn = connection.addEventListener(\n api.CoreClient.EVENT_RECONNECT_AUTH_FAILED,\n handleAuthFailed\n );\n\n return removerFn;\n },\n [api, connection, isShutdown]\n );\n\n const objectFetcher = useCallback(\n async (descriptor: dh.ide.VariableDescriptor) => {\n assertNotNull(connection, 'No connection available to fetch object with');\n return connection.getObject(sanitizeVariableDescriptor(descriptor));\n },\n [connection]\n );\n\n /** We don't really need to do anything fancy in Core to manage an object, just fetch it */\n const objectManager: ObjectFetchManager = useMemo(\n () => ({\n subscribe: (descriptor, onUpdate) => {\n // We send an update with the fetch right away\n onUpdate({\n fetch: () => objectFetcher(descriptor),\n status: 'ready',\n });\n return () => {\n // no-op\n // For Core, if the server dies then we can't reconnect anyway, so no need to bother listening for subscription or cleaning up\n };\n },\n }),\n [objectFetcher]\n );\n\n function handleRefresh(): void {\n log.info('Refreshing application');\n window.location.reload();\n }\n\n if (isShutdown || connectionState === 'connecting' || isNotConnecting) {\n return (\n <LoadingOverlay\n data-testid=\"connection-bootstrap-loading\"\n isLoading={false}\n errorMessage={error != null ? `${error}` : undefined}\n />\n );\n }\n\n return (\n <ConnectionContext.Provider value={connection ?? null}>\n <ObjectFetcherContext.Provider value={objectFetcher}>\n <ObjectFetchManagerContext.Provider value={objectManager}>\n {children}\n <DebouncedModal isOpen={isReconnecting} debounceMs={1000}>\n <InfoModal\n icon={vsDebugDisconnect}\n title={\n <>\n <LoadingSpinner /> Attempting to reconnect...\n </>\n }\n subtitle=\"Please check your network connection.\"\n />\n </DebouncedModal>\n <BasicModal\n confirmButtonText=\"Refresh\"\n onConfirm={handleRefresh}\n isOpen={isAuthFailed}\n headerText=\"Authentication failed\"\n bodyText=\"Credentials are invalid. Please refresh your browser to try and reconnect.\"\n />\n </ObjectFetchManagerContext.Provider>\n </ObjectFetcherContext.Provider>\n </ConnectionContext.Provider>\n );\n}\n\nexport default ConnectionBootstrap;\n"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,OAAO;AACxE,SACEC,UAAU,EACVC,cAAc,EACdC,SAAS,EACTC,cAAc,EACdC,cAAc,QACT,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KAAK,YAAY,IAAIK,eAAe,EAAE;IACrE,oBACErB,IAAA,CAACZ,cAAc;MACb,eAAY,8BAA8B;MAC1CiF,SAAS,EAAE,KAAM;MACjBC,YAAY,EAAE1D,KAAK,IAAI,IAAI,MAAAyB,MAAA,CAAMzB,KAAK,IAAK2D;IAAU,CACtD,CAAC;EAEN;EAEA,oBACEvE,IAAA,CAACF,iBAAiB,CAAC0E,QAAQ;IAACC,KAAK,EAAE3D,UAAU,aAAVA,UAAU,cAAVA,UAAU,GAAI,IAAK;IAAAL,QAAA,eACpDT,IAAA,CAACV,oBAAoB,CAACkF,QAAQ;MAACC,KAAK,EAAElB,aAAc;MAAA9C,QAAA,eAClDL,KAAA,CAACb,yBAAyB,CAACiF,QAAQ;QAACC,KAAK,EAAEb,aAAc;QAAAnD,QAAA,GACtDA,QAAQ,eACTT,IAAA,CAACd,cAAc;UAACwF,MAAM,EAAEtD,cAAe;UAACuD,UAAU,EAAE,IAAK;UAAAlE,QAAA,eACvDT,IAAA,CAACb,SAAS;YACRyF,IAAI,EAAE/E,iBAAkB;YACxBgF,KAAK,eACHzE,KAAA,CAAAF,SAAA;cAAAO,QAAA,gBACET,IAAA,CAACX,cAAc,IAAE,CAAC,+BACpB;YAAA,CAAE,CACH;YACDyF,QAAQ,EAAC;UAAuC,CACjD;QAAC,CACY,CAAC,eACjB9E,IAAA,CAACf,UAAU;UACT8F,iBAAiB,EAAC,SAAS;UAC3BC,SAAS,EAAEf,aAAc;UACzBS,MAAM,EAAExD,YAAa;UACrB+D,UAAU,EAAC,uBAAuB;UAClCC,QAAQ,EAAC;QAA4E,CACtF,CAAC;MAAA,CACgC;IAAC,CACR;EAAC,CACN,CAAC;AAEjC;AAEA,eAAe3E,mBAAmB"}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from './components';
2
2
  export * from './plugins';
3
+ export * from './storage';
3
4
  export * from './utils';
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC"}
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from "./components/index.js";
2
2
  export * from "./plugins/index.js";
3
+ export * from "./storage/index.js";
3
4
  export * from "./utils/index.js";
4
5
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["export * from './components';\nexport * from './plugins';\nexport * from './utils';\n"],"mappings":""}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["export * from './components';\nexport * from './plugins';\nexport * from './storage';\nexport * from './utils';\n"],"mappings":""}
@@ -0,0 +1,35 @@
1
+ import type { ItemConfigType } from '@deephaven/golden-layout';
2
+ import { FilterSet, Link } from '@deephaven/dashboard-core-plugins';
3
+ import { PluginDataMap } from '@deephaven/redux';
4
+ /**
5
+ * Have a different version to support legacy layout exports
6
+ */
7
+ export type ExportedLayoutV1 = ItemConfigType[];
8
+ export type ExportedLayoutV2 = {
9
+ filterSets: FilterSet[];
10
+ links: Link[];
11
+ layoutConfig: ItemConfigType[];
12
+ pluginDataMap?: PluginDataMap;
13
+ version: 2;
14
+ };
15
+ export type ExportedLayout = ExportedLayoutV1 | ExportedLayoutV2;
16
+ export declare function isLayoutV2(layout: ExportedLayout): layout is ExportedLayoutV2;
17
+ export declare function isLayoutV1(layout: ExportedLayout): layout is ExportedLayoutV1;
18
+ /**
19
+ * Interface for accessing layouts from wherever they are stored.
20
+ */
21
+ export interface LayoutStorage {
22
+ /**
23
+ * Get the name of the layouts available
24
+ * @returns The string array of layout names
25
+ */
26
+ getLayouts: () => Promise<string[]>;
27
+ /**
28
+ * Get the layout with the specified name
29
+ * @param name The name of the layout to fetch
30
+ * @returns GoldenLayout layout config
31
+ */
32
+ getLayout: (name: string) => Promise<ExportedLayout>;
33
+ }
34
+ export default LayoutStorage;
35
+ //# sourceMappingURL=LayoutStorage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LayoutStorage.d.ts","sourceRoot":"","sources":["../../src/storage/LayoutStorage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,mCAAmC,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,cAAc,EAAE,CAAC;AAEhD,MAAM,MAAM,gBAAgB,GAAG;IAC7B,UAAU,EAAE,SAAS,EAAE,CAAC;IACxB,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,YAAY,EAAE,cAAc,EAAE,CAAC;IAC/B,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,OAAO,EAAE,CAAC,CAAC;CACZ,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,gBAAgB,GAAG,gBAAgB,CAAC;AAEjE,wBAAgB,UAAU,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM,IAAI,gBAAgB,CAE7E;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM,IAAI,gBAAgB,CAE7E;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;;OAGG;IACH,UAAU,EAAE,MAAM,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAEpC;;;;OAIG;IACH,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,cAAc,CAAC,CAAC;CACtD;AAED,eAAe,aAAa,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Have a different version to support legacy layout exports
3
+ */
4
+
5
+ export function isLayoutV2(layout) {
6
+ return layout.version === 2;
7
+ }
8
+ export function isLayoutV1(layout) {
9
+ return Array.isArray(layout);
10
+ }
11
+
12
+ /**
13
+ * Interface for accessing layouts from wherever they are stored.
14
+ */
15
+ //# sourceMappingURL=LayoutStorage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LayoutStorage.js","names":["isLayoutV2","layout","version","isLayoutV1","Array","isArray"],"sources":["../../src/storage/LayoutStorage.ts"],"sourcesContent":["import type { ItemConfigType } from '@deephaven/golden-layout';\nimport { FilterSet, Link } from '@deephaven/dashboard-core-plugins';\nimport { PluginDataMap } from '@deephaven/redux';\n\n/**\n * Have a different version to support legacy layout exports\n */\nexport type ExportedLayoutV1 = ItemConfigType[];\n\nexport type ExportedLayoutV2 = {\n filterSets: FilterSet[];\n links: Link[];\n layoutConfig: ItemConfigType[];\n pluginDataMap?: PluginDataMap;\n version: 2;\n};\n\nexport type ExportedLayout = ExportedLayoutV1 | ExportedLayoutV2;\n\nexport function isLayoutV2(layout: ExportedLayout): layout is ExportedLayoutV2 {\n return (layout as ExportedLayoutV2).version === 2;\n}\n\nexport function isLayoutV1(layout: ExportedLayout): layout is ExportedLayoutV1 {\n return Array.isArray(layout);\n}\n\n/**\n * Interface for accessing layouts from wherever they are stored.\n */\nexport interface LayoutStorage {\n /**\n * Get the name of the layouts available\n * @returns The string array of layout names\n */\n getLayouts: () => Promise<string[]>;\n\n /**\n * Get the layout with the specified name\n * @param name The name of the layout to fetch\n * @returns GoldenLayout layout config\n */\n getLayout: (name: string) => Promise<ExportedLayout>;\n}\n\nexport default LayoutStorage;\n"],"mappings":"AAIA;AACA;AACA;;AAaA,OAAO,SAASA,UAAUA,CAACC,MAAsB,EAA8B;EAC7E,OAAQA,MAAM,CAAsBC,OAAO,KAAK,CAAC;AACnD;AAEA,OAAO,SAASC,UAAUA,CAACF,MAAsB,EAA8B;EAC7E,OAAOG,KAAK,CAACC,OAAO,CAACJ,MAAM,CAAC;AAC9B;;AAEA;AACA;AACA"}
@@ -0,0 +1,18 @@
1
+ import { WorkspaceStorage, WorkspaceStorageLoadOptions, CustomizableWorkspaceData, CustomizableWorkspace, WorkspaceSettings, ServerConfigValues } from '@deephaven/redux';
2
+ import LayoutStorage from './LayoutStorage';
3
+ /**
4
+ * Implementation of WorkspaceStorage that just stores the workspace data in localStorage
5
+ */
6
+ export declare class LocalWorkspaceStorage implements WorkspaceStorage {
7
+ static readonly STORAGE_KEY = "deephaven.WorkspaceStorage";
8
+ static getBooleanServerConfig(serverConfigValues: Map<string, string> | undefined, key: string): boolean | undefined;
9
+ static makeDefaultWorkspaceSettings(serverConfigValues: ServerConfigValues): WorkspaceSettings;
10
+ static makeWorkspaceData(layoutStorage: LayoutStorage, options?: WorkspaceStorageLoadOptions): Promise<CustomizableWorkspaceData>;
11
+ static makeDefaultWorkspace(layoutStorage: LayoutStorage, options?: WorkspaceStorageLoadOptions): Promise<CustomizableWorkspace>;
12
+ private layoutStorage;
13
+ constructor(layoutStorage: LayoutStorage);
14
+ load(options?: WorkspaceStorageLoadOptions): Promise<CustomizableWorkspace>;
15
+ save(workspace: CustomizableWorkspace): Promise<CustomizableWorkspace>;
16
+ }
17
+ export default LocalWorkspaceStorage;
18
+ //# sourceMappingURL=LocalWorkspaceStorage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LocalWorkspaceStorage.d.ts","sourceRoot":"","sources":["../../src/storage/LocalWorkspaceStorage.ts"],"names":[],"mappings":"AACA,OAAO,EACL,gBAAgB,EAChB,2BAA2B,EAC3B,yBAAyB,EACzB,qBAAqB,EACrB,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,kBAAkB,CAAC;AAO1B,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAI5C;;GAEG;AACH,qBAAa,qBAAsB,YAAW,gBAAgB;IAC5D,MAAM,CAAC,QAAQ,CAAC,WAAW,gCAAgC;IAE3D,MAAM,CAAC,sBAAsB,CAC3B,kBAAkB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,EACnD,GAAG,EAAE,MAAM,GACV,OAAO,GAAG,SAAS;IAUtB,MAAM,CAAC,4BAA4B,CACjC,kBAAkB,EAAE,kBAAkB,GACrC,iBAAiB;WAoFP,iBAAiB,CAC5B,aAAa,EAAE,aAAa,EAC5B,OAAO,CAAC,EAAE,2BAA2B,GACpC,OAAO,CAAC,yBAAyB,CAAC;WAoBxB,oBAAoB,CAC/B,aAAa,EAAE,aAAa,EAC5B,OAAO,CAAC,EAAE,2BAA2B,GACpC,OAAO,CAAC,qBAAqB,CAAC;IASjC,OAAO,CAAC,aAAa,CAAgB;gBAEzB,aAAa,EAAE,aAAa;IAKlC,IAAI,CACR,OAAO,CAAC,EAAE,2BAA2B,GACpC,OAAO,CAAC,qBAAqB,CAAC;IAiB3B,IAAI,CAAC,SAAS,EAAE,qBAAqB,GAAG,OAAO,CAAC,qBAAqB,CAAC;CAO7E;AAED,eAAe,qBAAqB,CAAC"}
@@ -0,0 +1,131 @@
1
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
2
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
3
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
5
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
6
+ import Log from '@deephaven/log';
7
+ import { DateTimeColumnFormatter, DecimalColumnFormatter, IntegerColumnFormatter } from '@deephaven/jsapi-utils';
8
+ import UserLayoutUtils from "./UserLayoutUtils.js";
9
+ var log = Log.module('LocalWorkspaceStorage');
10
+
11
+ /**
12
+ * Implementation of WorkspaceStorage that just stores the workspace data in localStorage
13
+ */
14
+ export class LocalWorkspaceStorage {
15
+ static getBooleanServerConfig(serverConfigValues, key) {
16
+ var _serverConfigValues$g, _serverConfigValues$g2;
17
+ if ((serverConfigValues === null || serverConfigValues === void 0 ? void 0 : (_serverConfigValues$g = serverConfigValues.get(key)) === null || _serverConfigValues$g === void 0 ? void 0 : _serverConfigValues$g.toLowerCase()) === 'true') {
18
+ return true;
19
+ }
20
+ if ((serverConfigValues === null || serverConfigValues === void 0 ? void 0 : (_serverConfigValues$g2 = serverConfigValues.get(key)) === null || _serverConfigValues$g2 === void 0 ? void 0 : _serverConfigValues$g2.toLowerCase()) === 'false') {
21
+ return false;
22
+ }
23
+ return undefined;
24
+ }
25
+ static makeDefaultWorkspaceSettings(serverConfigValues) {
26
+ var settings = {
27
+ defaultDateTimeFormat: DateTimeColumnFormatter.DEFAULT_DATETIME_FORMAT_STRING,
28
+ formatter: [],
29
+ timeZone: DateTimeColumnFormatter.DEFAULT_TIME_ZONE_ID,
30
+ showTimeZone: false,
31
+ showTSeparator: true,
32
+ disableMoveConfirmation: false,
33
+ defaultDecimalFormatOptions: {
34
+ defaultFormatString: DecimalColumnFormatter.DEFAULT_FORMAT_STRING
35
+ },
36
+ defaultIntegerFormatOptions: {
37
+ defaultFormatString: IntegerColumnFormatter.DEFAULT_FORMAT_STRING
38
+ },
39
+ truncateNumbersWithPound: false,
40
+ showEmptyStrings: true,
41
+ showNullStrings: true,
42
+ defaultNotebookSettings: {
43
+ isMinimapEnabled: false
44
+ }
45
+ };
46
+ var serverSettings = {
47
+ defaultDateTimeFormat: serverConfigValues === null || serverConfigValues === void 0 ? void 0 : serverConfigValues.get('dateTimeFormat'),
48
+ formatter: [],
49
+ timeZone: serverConfigValues === null || serverConfigValues === void 0 ? void 0 : serverConfigValues.get('timeZone'),
50
+ showTimeZone: LocalWorkspaceStorage.getBooleanServerConfig(serverConfigValues, 'showTimeZone'),
51
+ showTSeparator: LocalWorkspaceStorage.getBooleanServerConfig(serverConfigValues, 'showTSeparator'),
52
+ disableMoveConfirmation: LocalWorkspaceStorage.getBooleanServerConfig(serverConfigValues, 'disableMoveConfirmation'),
53
+ defaultDecimalFormatOptions: (serverConfigValues === null || serverConfigValues === void 0 ? void 0 : serverConfigValues.get('decimalFormat')) !== undefined ? {
54
+ defaultFormatString: serverConfigValues === null || serverConfigValues === void 0 ? void 0 : serverConfigValues.get('decimalFormat')
55
+ } : undefined,
56
+ defaultIntegerFormatOptions: (serverConfigValues === null || serverConfigValues === void 0 ? void 0 : serverConfigValues.get('integerFormat')) !== undefined ? {
57
+ defaultFormatString: serverConfigValues === null || serverConfigValues === void 0 ? void 0 : serverConfigValues.get('integerFormat')
58
+ } : undefined,
59
+ truncateNumbersWithPound: LocalWorkspaceStorage.getBooleanServerConfig(serverConfigValues, 'truncateNumbersWithPound'),
60
+ showEmptyStrings: LocalWorkspaceStorage.getBooleanServerConfig(serverConfigValues, 'showEmptyStrings'),
61
+ showNullStrings: LocalWorkspaceStorage.getBooleanServerConfig(serverConfigValues, 'showNullStrings'),
62
+ defaultNotebookSettings: (serverConfigValues === null || serverConfigValues === void 0 ? void 0 : serverConfigValues.get('isMinimapEnabled')) !== undefined ? {
63
+ isMinimapEnabled: LocalWorkspaceStorage.getBooleanServerConfig(serverConfigValues, 'isMinimapEnabled')
64
+ } : undefined
65
+ };
66
+ var keys = Object.keys(serverSettings);
67
+ for (var i = 0; i < keys.length; i += 1) {
68
+ var key = keys[i];
69
+ if (serverSettings[key] !== undefined) {
70
+ // @ts-expect-error override default for defined server settings
71
+ settings[key] = serverSettings[key];
72
+ }
73
+ }
74
+ return settings;
75
+ }
76
+ static makeWorkspaceData(layoutStorage, options) {
77
+ return _asyncToGenerator(function* () {
78
+ var {
79
+ filterSets,
80
+ links,
81
+ layoutConfig,
82
+ pluginDataMap = {}
83
+ } = yield UserLayoutUtils.getDefaultLayout(layoutStorage, options === null || options === void 0 ? void 0 : options.isConsoleAvailable);
84
+ return {
85
+ settings: {},
86
+ layoutConfig,
87
+ closed: [{}],
88
+ links,
89
+ filterSets,
90
+ pluginDataMap
91
+ };
92
+ })();
93
+ }
94
+ static makeDefaultWorkspace(layoutStorage, options) {
95
+ return _asyncToGenerator(function* () {
96
+ return {
97
+ data: yield LocalWorkspaceStorage.makeWorkspaceData(layoutStorage, options)
98
+ };
99
+ })();
100
+ }
101
+ constructor(layoutStorage) {
102
+ _defineProperty(this, "layoutStorage", void 0);
103
+ this.layoutStorage = layoutStorage;
104
+ }
105
+
106
+ // eslint-disable-next-line class-methods-use-this
107
+ load(options) {
108
+ var _this = this;
109
+ return _asyncToGenerator(function* () {
110
+ try {
111
+ var _localStorage$getItem;
112
+ var workspace = JSON.parse((_localStorage$getItem = localStorage.getItem(LocalWorkspaceStorage.STORAGE_KEY)) !== null && _localStorage$getItem !== void 0 ? _localStorage$getItem : '');
113
+ return workspace;
114
+ } catch (e) {
115
+ log.info('Unable to load workspace data, initializing to default data');
116
+ return LocalWorkspaceStorage.makeDefaultWorkspace(_this.layoutStorage, options);
117
+ }
118
+ })();
119
+ }
120
+
121
+ // eslint-disable-next-line class-methods-use-this
122
+ save(workspace) {
123
+ return _asyncToGenerator(function* () {
124
+ localStorage.setItem(LocalWorkspaceStorage.STORAGE_KEY, JSON.stringify(workspace));
125
+ return workspace;
126
+ })();
127
+ }
128
+ }
129
+ _defineProperty(LocalWorkspaceStorage, "STORAGE_KEY", 'deephaven.WorkspaceStorage');
130
+ export default LocalWorkspaceStorage;
131
+ //# sourceMappingURL=LocalWorkspaceStorage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LocalWorkspaceStorage.js","names":["Log","DateTimeColumnFormatter","DecimalColumnFormatter","IntegerColumnFormatter","UserLayoutUtils","log","module","LocalWorkspaceStorage","getBooleanServerConfig","serverConfigValues","key","_serverConfigValues$g","_serverConfigValues$g2","get","toLowerCase","undefined","makeDefaultWorkspaceSettings","settings","defaultDateTimeFormat","DEFAULT_DATETIME_FORMAT_STRING","formatter","timeZone","DEFAULT_TIME_ZONE_ID","showTimeZone","showTSeparator","disableMoveConfirmation","defaultDecimalFormatOptions","defaultFormatString","DEFAULT_FORMAT_STRING","defaultIntegerFormatOptions","truncateNumbersWithPound","showEmptyStrings","showNullStrings","defaultNotebookSettings","isMinimapEnabled","serverSettings","keys","Object","i","length","makeWorkspaceData","layoutStorage","options","_asyncToGenerator","filterSets","links","layoutConfig","pluginDataMap","getDefaultLayout","isConsoleAvailable","closed","makeDefaultWorkspace","data","constructor","_defineProperty","load","_this","_localStorage$getItem","workspace","JSON","parse","localStorage","getItem","STORAGE_KEY","e","info","save","setItem","stringify"],"sources":["../../src/storage/LocalWorkspaceStorage.ts"],"sourcesContent":["import Log from '@deephaven/log';\nimport {\n WorkspaceStorage,\n WorkspaceStorageLoadOptions,\n CustomizableWorkspaceData,\n CustomizableWorkspace,\n WorkspaceSettings,\n ServerConfigValues,\n} from '@deephaven/redux';\nimport {\n DateTimeColumnFormatter,\n DecimalColumnFormatter,\n IntegerColumnFormatter,\n} from '@deephaven/jsapi-utils';\nimport UserLayoutUtils from './UserLayoutUtils';\nimport LayoutStorage from './LayoutStorage';\n\nconst log = Log.module('LocalWorkspaceStorage');\n\n/**\n * Implementation of WorkspaceStorage that just stores the workspace data in localStorage\n */\nexport class LocalWorkspaceStorage implements WorkspaceStorage {\n static readonly STORAGE_KEY = 'deephaven.WorkspaceStorage';\n\n static getBooleanServerConfig(\n serverConfigValues: Map<string, string> | undefined,\n key: string\n ): boolean | undefined {\n if (serverConfigValues?.get(key)?.toLowerCase() === 'true') {\n return true;\n }\n if (serverConfigValues?.get(key)?.toLowerCase() === 'false') {\n return false;\n }\n return undefined;\n }\n\n static makeDefaultWorkspaceSettings(\n serverConfigValues: ServerConfigValues\n ): WorkspaceSettings {\n const settings = {\n defaultDateTimeFormat:\n DateTimeColumnFormatter.DEFAULT_DATETIME_FORMAT_STRING,\n formatter: [],\n timeZone: DateTimeColumnFormatter.DEFAULT_TIME_ZONE_ID,\n showTimeZone: false,\n showTSeparator: true,\n disableMoveConfirmation: false,\n defaultDecimalFormatOptions: {\n defaultFormatString: DecimalColumnFormatter.DEFAULT_FORMAT_STRING,\n },\n defaultIntegerFormatOptions: {\n defaultFormatString: IntegerColumnFormatter.DEFAULT_FORMAT_STRING,\n },\n truncateNumbersWithPound: false,\n showEmptyStrings: true,\n showNullStrings: true,\n defaultNotebookSettings: {\n isMinimapEnabled: false,\n },\n };\n const serverSettings = {\n defaultDateTimeFormat: serverConfigValues?.get('dateTimeFormat'),\n formatter: [],\n timeZone: serverConfigValues?.get('timeZone'),\n showTimeZone: LocalWorkspaceStorage.getBooleanServerConfig(\n serverConfigValues,\n 'showTimeZone'\n ),\n showTSeparator: LocalWorkspaceStorage.getBooleanServerConfig(\n serverConfigValues,\n 'showTSeparator'\n ),\n disableMoveConfirmation: LocalWorkspaceStorage.getBooleanServerConfig(\n serverConfigValues,\n 'disableMoveConfirmation'\n ),\n defaultDecimalFormatOptions:\n serverConfigValues?.get('decimalFormat') !== undefined\n ? {\n defaultFormatString: serverConfigValues?.get('decimalFormat'),\n }\n : undefined,\n defaultIntegerFormatOptions:\n serverConfigValues?.get('integerFormat') !== undefined\n ? {\n defaultFormatString: serverConfigValues?.get('integerFormat'),\n }\n : undefined,\n truncateNumbersWithPound: LocalWorkspaceStorage.getBooleanServerConfig(\n serverConfigValues,\n 'truncateNumbersWithPound'\n ),\n showEmptyStrings: LocalWorkspaceStorage.getBooleanServerConfig(\n serverConfigValues,\n 'showEmptyStrings'\n ),\n showNullStrings: LocalWorkspaceStorage.getBooleanServerConfig(\n serverConfigValues,\n 'showNullStrings'\n ),\n defaultNotebookSettings:\n serverConfigValues?.get('isMinimapEnabled') !== undefined\n ? {\n isMinimapEnabled: LocalWorkspaceStorage.getBooleanServerConfig(\n serverConfigValues,\n 'isMinimapEnabled'\n ) as boolean,\n }\n : undefined,\n };\n\n const keys = Object.keys(serverSettings) as Array<keyof typeof settings>;\n for (let i = 0; i < keys.length; i += 1) {\n const key = keys[i];\n if (serverSettings[key] !== undefined) {\n // @ts-expect-error override default for defined server settings\n settings[key] = serverSettings[key];\n }\n }\n return settings;\n }\n\n static async makeWorkspaceData(\n layoutStorage: LayoutStorage,\n options?: WorkspaceStorageLoadOptions\n ): Promise<CustomizableWorkspaceData> {\n const {\n filterSets,\n links,\n layoutConfig,\n pluginDataMap = {},\n } = await UserLayoutUtils.getDefaultLayout(\n layoutStorage,\n options?.isConsoleAvailable\n );\n return {\n settings: {},\n layoutConfig,\n closed: [{}],\n links,\n filterSets,\n pluginDataMap,\n };\n }\n\n static async makeDefaultWorkspace(\n layoutStorage: LayoutStorage,\n options?: WorkspaceStorageLoadOptions\n ): Promise<CustomizableWorkspace> {\n return {\n data: await LocalWorkspaceStorage.makeWorkspaceData(\n layoutStorage,\n options\n ),\n };\n }\n\n private layoutStorage: LayoutStorage;\n\n constructor(layoutStorage: LayoutStorage) {\n this.layoutStorage = layoutStorage;\n }\n\n // eslint-disable-next-line class-methods-use-this\n async load(\n options?: WorkspaceStorageLoadOptions\n ): Promise<CustomizableWorkspace> {\n try {\n const workspace = JSON.parse(\n localStorage.getItem(LocalWorkspaceStorage.STORAGE_KEY) ?? ''\n );\n return workspace;\n } catch (e) {\n log.info('Unable to load workspace data, initializing to default data');\n\n return LocalWorkspaceStorage.makeDefaultWorkspace(\n this.layoutStorage,\n options\n );\n }\n }\n\n // eslint-disable-next-line class-methods-use-this\n async save(workspace: CustomizableWorkspace): Promise<CustomizableWorkspace> {\n localStorage.setItem(\n LocalWorkspaceStorage.STORAGE_KEY,\n JSON.stringify(workspace)\n );\n return workspace;\n }\n}\n\nexport default LocalWorkspaceStorage;\n"],"mappings":";;;;;AAAA,OAAOA,GAAG,MAAM,gBAAgB;AAShC,SACEC,uBAAuB,EACvBC,sBAAsB,EACtBC,sBAAsB,QACjB,wBAAwB;AAAC,OACzBC,eAAe;AAGtB,IAAMC,GAAG,GAAGL,GAAG,CAACM,MAAM,CAAC,uBAAuB,CAAC;;AAE/C;AACA;AACA;AACA,OAAO,MAAMC,qBAAqB,CAA6B;EAG7D,OAAOC,sBAAsBA,CAC3BC,kBAAmD,EACnDC,GAAW,EACU;IAAA,IAAAC,qBAAA,EAAAC,sBAAA;IACrB,IAAI,CAAAH,kBAAkB,aAAlBA,kBAAkB,wBAAAE,qBAAA,GAAlBF,kBAAkB,CAAEI,GAAG,CAACH,GAAG,CAAC,cAAAC,qBAAA,uBAA5BA,qBAAA,CAA8BG,WAAW,CAAC,CAAC,MAAK,MAAM,EAAE;MAC1D,OAAO,IAAI;IACb;IACA,IAAI,CAAAL,kBAAkB,aAAlBA,kBAAkB,wBAAAG,sBAAA,GAAlBH,kBAAkB,CAAEI,GAAG,CAACH,GAAG,CAAC,cAAAE,sBAAA,uBAA5BA,sBAAA,CAA8BE,WAAW,CAAC,CAAC,MAAK,OAAO,EAAE;MAC3D,OAAO,KAAK;IACd;IACA,OAAOC,SAAS;EAClB;EAEA,OAAOC,4BAA4BA,CACjCP,kBAAsC,EACnB;IACnB,IAAMQ,QAAQ,GAAG;MACfC,qBAAqB,EACnBjB,uBAAuB,CAACkB,8BAA8B;MACxDC,SAAS,EAAE,EAAE;MACbC,QAAQ,EAAEpB,uBAAuB,CAACqB,oBAAoB;MACtDC,YAAY,EAAE,KAAK;MACnBC,cAAc,EAAE,IAAI;MACpBC,u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AAE,CAAC,CAAC,CAAC,CAAC;QACZL,KAAK;QACLD,UAAU;QACVG;MACF,CAAC;IAAC;EACJ;EAEA,OAAaI,oBAAoBA,CAC/BV,aAA4B,EAC5BC,OAAqC,EACL;IAAA,OAAAC,iBAAA;MAChC,OAAO;QACLS,IAAI,QAAQ7C,qBAAqB,CAACiC,iBAAiB,CACjDC,aAAa,EACbC,OACF;MACF,CAAC;IAAC;EACJ;EAIAW,WAAWA,CAACZ,aAA4B,EAAE;IAAAa,eAAA;IACxC,IAAI,CAACb,aAAa,GAAGA,aAAa;EACpC;;EAEA;EACMc,IAAIA,CACRb,OAAqC,EACL;IAAA,IAAAc,KAAA;IAAA,OAAAb,iBAAA;MAChC,IAAI;QAAA,IAAAc,qBAAA;QACF,IAAMC,SAAS,GAAGC,IAAI,CAACC,KAAK,EAAAH,qBAAA,GAC1BI,YAAY,CAACC,OAAO,CAACvD,qBAAqB,CAACwD,WAAW,CAAC,cAAAN,qBAAA,cAAAA,qBAAA,GAAI,EAC7D,CAAC;QACD,OAAOC,SAAS;MAClB,CAAC,CAAC,OAAOM,CAAC,EAAE;QACV3D,GAAG,CAAC4D,IAAI,CAAC,6DAA6D,CAAC;QAEvE,OAAO1D,qBAAqB,CAAC4C,oBAAoB,CAC/CK,KAAI,CAACf,aAAa,EAClBC,OACF,CAAC;MACH;IAAC;EACH;;EAEA;EACMwB,IAAIA,CAACR,SAAgC,EAAkC;IAAA,OAAAf,iBAAA;MAC3EkB,YAAY,CAACM,OAAO,CAClB5D,qBAAqB,CAACwD,WAAW,EACjCJ,IAAI,CAACS,SAAS,CAACV,SAAS,CAC1B,CAAC;MACD,OAAOA,SAAS;IAAC;EACnB;AACF;AAACJ,eAAA,CA1KY/C,qBAAqB,iBACF,4BAA4B;AA2K5D,eAAeA,qBAAqB"}
@@ -0,0 +1,20 @@
1
+ import { CustomizableWorkspaceData } from '@deephaven/redux';
2
+ import LayoutStorage, { ExportedLayout, ExportedLayoutV2 } from './LayoutStorage';
3
+ export declare const DEFAULT_LAYOUT_CONFIG: ExportedLayoutV2;
4
+ export declare const DEFAULT_LAYOUT_CONFIG_NO_CONSOLE: ExportedLayoutV2;
5
+ export declare function normalizeLayout(layout: ExportedLayout): ExportedLayoutV2;
6
+ /**
7
+ * Get the default layout for the user to use. Checks layout storage for any layouts, and uses the first one if found.
8
+ * @param layoutStorage The layout storage to get the default layouts from
9
+ * @param isConsoleAvailable Whether console sessions are available.
10
+ * @returns The default layout config to use
11
+ */
12
+ export declare function getDefaultLayout(layoutStorage: LayoutStorage, isConsoleAvailable?: boolean): Promise<ExportedLayoutV2>;
13
+ export declare function exportLayout(data: CustomizableWorkspaceData): ExportedLayoutV2;
14
+ declare const _default: {
15
+ exportLayout: typeof exportLayout;
16
+ getDefaultLayout: typeof getDefaultLayout;
17
+ normalizeLayout: typeof normalizeLayout;
18
+ };
19
+ export default _default;
20
+ //# sourceMappingURL=UserLayoutUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UserLayoutUtils.d.ts","sourceRoot":"","sources":["../../src/storage/UserLayoutUtils.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,aAAa,EAAE,EACpB,cAAc,EACd,gBAAgB,EAGjB,MAAM,iBAAiB,CAAC;AAIzB,eAAO,MAAM,qBAAqB,EAAE,gBA8DnC,CAAC;AAEF,eAAO,MAAM,gCAAgC,EAAE,gBAK9C,CAAC;AAEF,wBAAgB,eAAe,CAAC,MAAM,EAAE,cAAc,GAAG,gBAAgB,CAexE;AAED;;;;;GAKG;AACH,wBAAsB,gBAAgB,CACpC,aAAa,EAAE,aAAa,EAC5B,kBAAkB,UAAO,GACxB,OAAO,CAAC,gBAAgB,CAAC,CAqB3B;AAED,wBAAgB,YAAY,CAC1B,IAAI,EAAE,yBAAyB,GAC9B,gBAAgB,CAalB;;;;;;AAED,wBAAmE"}
@@ -0,0 +1,131 @@
1
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
2
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
3
+ import { CommandHistoryPanel, ConsolePanel, FileExplorerPanel, LogPanel } from '@deephaven/dashboard-core-plugins';
4
+ import Log from '@deephaven/log';
5
+ import { isLayoutV1, isLayoutV2 } from "./LayoutStorage.js";
6
+ var log = Log.module('UserLayoutUtils');
7
+ export var DEFAULT_LAYOUT_CONFIG = {
8
+ layoutConfig: [{
9
+ type: 'column',
10
+ content: [{
11
+ type: 'row',
12
+ height: 40,
13
+ // slightly smaller than 50-50 to allow more space for tables below
14
+ content: [{
15
+ type: 'stack',
16
+ content: [{
17
+ type: 'react-component',
18
+ component: ConsolePanel.COMPONENT,
19
+ title: ConsolePanel.TITLE,
20
+ isClosable: false
21
+ }, {
22
+ type: 'react-component',
23
+ component: LogPanel.COMPONENT,
24
+ title: LogPanel.TITLE,
25
+ isClosable: false
26
+ }]
27
+ }, {
28
+ type: 'stack',
29
+ width: 25,
30
+ content: [{
31
+ type: 'react-component',
32
+ component: CommandHistoryPanel.COMPONENT,
33
+ title: CommandHistoryPanel.TITLE,
34
+ isClosable: false
35
+ }, {
36
+ type: 'react-component',
37
+ component: FileExplorerPanel.COMPONENT,
38
+ title: FileExplorerPanel.TITLE,
39
+ isClosable: false
40
+ }]
41
+ }]
42
+ }, {
43
+ type: 'row',
44
+ content: [{
45
+ type: 'stack',
46
+ title: 'Notebooks',
47
+ content: []
48
+ }]
49
+ }]
50
+ }],
51
+ links: [],
52
+ filterSets: [],
53
+ version: 2
54
+ };
55
+ export var DEFAULT_LAYOUT_CONFIG_NO_CONSOLE = {
56
+ layoutConfig: [],
57
+ links: [],
58
+ filterSets: [],
59
+ version: 2
60
+ };
61
+ export function normalizeLayout(layout) {
62
+ if (isLayoutV2(layout)) {
63
+ return layout;
64
+ }
65
+ if (isLayoutV1(layout)) {
66
+ var layoutConfig = layout;
67
+ return {
68
+ layoutConfig,
69
+ links: [],
70
+ filterSets: [],
71
+ version: 2
72
+ };
73
+ }
74
+ throw new Error("Unexpected layout import format: ".concat(layout));
75
+ }
76
+
77
+ /**
78
+ * Get the default layout for the user to use. Checks layout storage for any layouts, and uses the first one if found.
79
+ * @param layoutStorage The layout storage to get the default layouts from
80
+ * @param isConsoleAvailable Whether console sessions are available.
81
+ * @returns The default layout config to use
82
+ */
83
+ export function getDefaultLayout(_x) {
84
+ return _getDefaultLayout.apply(this, arguments);
85
+ }
86
+ function _getDefaultLayout() {
87
+ _getDefaultLayout = _asyncToGenerator(function* (layoutStorage) {
88
+ var isConsoleAvailable = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
89
+ try {
90
+ var layouts = yield layoutStorage.getLayouts();
91
+ if (layouts.length > 0) {
92
+ try {
93
+ // We found a layout on the server, use it. It could be an empty layout if they want user to build their own
94
+ var layout = yield layoutStorage.getLayout(layouts[0]);
95
+ return normalizeLayout(layout);
96
+ } catch (err) {
97
+ log.error('Unable to load layout', layouts[0], ':', err);
98
+ log.warn('No valid layouts found, falling back to default layout');
99
+ }
100
+ }
101
+ } catch (err) {
102
+ log.error('Unable to fetch layout list', err);
103
+ log.warn('Falling back to default layout');
104
+ }
105
+ // Otherwise, do the default layout
106
+ return isConsoleAvailable ? DEFAULT_LAYOUT_CONFIG : DEFAULT_LAYOUT_CONFIG_NO_CONSOLE;
107
+ });
108
+ return _getDefaultLayout.apply(this, arguments);
109
+ }
110
+ export function exportLayout(data) {
111
+ var {
112
+ filterSets,
113
+ layoutConfig,
114
+ links,
115
+ pluginDataMap
116
+ } = data;
117
+ var exportedLayout = {
118
+ filterSets,
119
+ layoutConfig,
120
+ links,
121
+ pluginDataMap,
122
+ version: 2
123
+ };
124
+ return exportedLayout;
125
+ }
126
+ export default {
127
+ exportLayout,
128
+ getDefaultLayout,
129
+ normalizeLayout
130
+ };
131
+ //# sourceMappingURL=UserLayoutUtils.js.map