Skip to content

Commit 94ab25c

Browse files
mofojedmattrunyon
andauthored
feat: web-client-ui changes required for deephaven.ui (#1567)
- Add some more shared packages to the `remote-component.config.ts` - Now plugins can externalize these packages in their build process, and share the same instance - Add Chart handling of model update - Add some more externalized packages - Add max-old-space-size flag to embed-chart - Noticed it was missing, and was causing a build issue with these changes --------- Co-authored-by: Matthew Runyon <mattrunyonstuff@gmail.com>
1 parent ed8f4b7 commit 94ab25c

8 files changed

Lines changed: 63 additions & 13 deletions

File tree

package-lock.json

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/app-utils/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,12 @@
2828
"redux": "^4.x"
2929
},
3030
"dependencies": {
31+
"@adobe/react-spectrum": "^3.29.0",
3132
"@deephaven/auth-plugins": "file:../auth-plugins",
33+
"@deephaven/chart": "file:../chart",
3234
"@deephaven/components": "file:../components",
35+
"@deephaven/icons": "file:../icons",
36+
"@deephaven/iris-grid": "file:../iris-grid",
3337
"@deephaven/jsapi-bootstrap": "file:../jsapi-bootstrap",
3438
"@deephaven/jsapi-components": "file:../jsapi-components",
3539
"@deephaven/jsapi-types": "file:../jsapi-types",

packages/app-utils/src/plugins/remote-component.config.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,16 @@ import react from 'react';
88
import * as redux from 'redux';
99
import * as reactRedux from 'react-redux';
1010
import ReactDOM from 'react-dom';
11+
import * as AdobeReactSpectrum from '@adobe/react-spectrum';
1112
import * as DeephavenAuthPlugins from '@deephaven/auth-plugins';
13+
import * as DeephavenChart from '@deephaven/chart';
1214
import * as DeephavenComponents from '@deephaven/components';
15+
import * as DeephavenIcons from '@deephaven/icons';
16+
import * as DeephavenIrisGrid from '@deephaven/iris-grid';
1317
import * as DeephavenJsapiBootstrap from '@deephaven/jsapi-bootstrap';
1418
import * as DeephavenJsapiComponents from '@deephaven/jsapi-components';
1519
import * as DeephavenJsapiUtils from '@deephaven/jsapi-utils';
16-
import * as DeephavenLog from '@deephaven/log';
20+
import DeephavenLog from '@deephaven/log';
1721
import * as DeephavenReactHooks from '@deephaven/react-hooks';
1822

1923
// eslint-disable-next-line import/prefer-default-export
@@ -22,8 +26,12 @@ export const resolve = {
2226
'react-dom': ReactDOM,
2327
redux,
2428
'react-redux': reactRedux,
29+
'@adobe/react-spectrum': AdobeReactSpectrum,
2530
'@deephaven/auth-plugins': DeephavenAuthPlugins,
31+
'@deephaven/chart': DeephavenChart,
2632
'@deephaven/components': DeephavenComponents,
33+
'@deephaven/icons': DeephavenIcons,
34+
'@deephaven/iris-grid': DeephavenIrisGrid,
2735
'@deephaven/jsapi-bootstrap': DeephavenJsapiBootstrap,
2836
'@deephaven/jsapi-components': DeephavenJsapiComponents,
2937
'@deephaven/jsapi-utils': DeephavenJsapiUtils,

packages/app-utils/tsconfig.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
"exclude": ["node_modules", "src/**/*.test.*", "src/**/__mocks__/*"],
99
"references": [
1010
{ "path": "../auth-plugins" },
11+
{ "path": "../chart" },
1112
{ "path": "../components" },
13+
{ "path": "../iris-grid" },
1214
{ "path": "../jsapi-bootstrap" },
1315
{ "path": "../jsapi-components" },
1416
{ "path": "../jsapi-types" },

packages/chart/src/Chart.tsx

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -166,27 +166,33 @@ export class Chart extends Component<ChartProps, ChartState> {
166166
this.initData();
167167
this.initFormatter();
168168

169-
const { isActive } = this.props;
169+
const { isActive, model } = this.props;
170170
if (isActive) {
171-
this.subscribe();
171+
this.subscribe(model);
172172
}
173173
}
174174

175175
componentDidUpdate(prevProps: ChartProps): void {
176-
const { isActive, settings } = this.props;
176+
const { isActive, model, settings } = this.props;
177177
this.updateFormatterSettings(settings as FormatterSettings);
178178

179+
if (model !== prevProps.model) {
180+
this.unsubscribe(prevProps.model);
181+
this.subscribe(model);
182+
}
183+
179184
if (isActive !== prevProps.isActive) {
180185
if (isActive) {
181-
this.subscribe();
186+
this.subscribe(model);
182187
} else {
183-
this.unsubscribe();
188+
this.unsubscribe(model);
184189
}
185190
}
186191
}
187192

188193
componentWillUnmount(): void {
189-
this.unsubscribe();
194+
const { model } = this.props;
195+
this.unsubscribe(model);
190196
}
191197

192198
currentSeries: number;
@@ -315,12 +321,11 @@ export class Chart extends Component<ChartProps, ChartState> {
315321
});
316322
}
317323

318-
subscribe(): void {
324+
subscribe(model: ChartModel): void {
319325
if (this.isSubscribed) {
320326
return;
321327
}
322328

323-
const { model } = this.props;
324329
if (!this.rect || this.rect.width === 0 || this.rect.height === 0) {
325330
log.debug2('Delaying subscription until model dimensions are set');
326331
return;
@@ -329,12 +334,11 @@ export class Chart extends Component<ChartProps, ChartState> {
329334
this.isSubscribed = true;
330335
}
331336

332-
unsubscribe(): void {
337+
unsubscribe(model: ChartModel): void {
333338
if (!this.isSubscribed) {
334339
return;
335340
}
336341

337-
const { model } = this.props;
338342
model.unsubscribe(this.handleModelEvent);
339343
this.isSubscribed = false;
340344
}
@@ -510,7 +514,7 @@ export class Chart extends Component<ChartProps, ChartState> {
510514
model.setDimensions(rect);
511515
// We may need to resubscribe if dimensions were too small before
512516
if (isActive) {
513-
this.subscribe();
517+
this.subscribe(model);
514518
}
515519
}
516520
}

packages/code-studio/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"directory": "packages/code-studio"
1212
},
1313
"dependencies": {
14+
"@adobe/react-spectrum": "^3.29.0",
1415
"@deephaven/app-utils": "file:../app-utils",
1516
"@deephaven/auth-plugins": "file:../auth-plugins",
1617
"@deephaven/chart": "file:../chart",

packages/embed-chart/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"scripts": {
3131
"analyze": "source-map-explorer build/assets/*.js --no-border-checks",
3232
"start": "vite",
33-
"build": "vite build",
33+
"build": "NODE_OPTIONS='--max-old-space-size=4096' vite build",
3434
"preview": "vite preview"
3535
},
3636
"devDependencies": {

packages/jsapi-types/src/dh.types.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export interface dh {
3535
FileContents: FileContentsStatic;
3636
};
3737
ValueType: typeof ValueType;
38+
Widget: Widget;
3839
}
3940

4041
const VariableType = {
@@ -335,6 +336,26 @@ export interface Figure extends Evented {
335336
close(): void;
336337
}
337338

339+
export type WidgetExportedObject = {
340+
type: string;
341+
fetch: () => Promise<unknown>;
342+
close: () => void;
343+
};
344+
345+
export interface Widget {
346+
readonly EVENT_MESSAGE: string;
347+
348+
addEventListener: (
349+
type: string,
350+
listener: (event: unknown) => void
351+
) => () => void;
352+
getDataAsBase64(): string;
353+
getDataAsString(): string;
354+
getDataAsU8(): Uint8Array;
355+
sendMessage: (message: string, references?: never[]) => void;
356+
exportedObjects: WidgetExportedObject[];
357+
}
358+
338359
export interface FigureDataUpdatedEvent {
339360
/**
340361
* The series instances which were affected by this event and need to be updated.

0 commit comments

Comments
 (0)