@deephaven/js-plugin-matplotlib 0.4.1 → 0.5.1-alpha-pivots.0

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 (2) hide show
  1. package/dist/index.js +83 -27
  2. package/package.json +13 -14
package/dist/index.js CHANGED
@@ -1,18 +1,12 @@
1
1
  "use strict";
2
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
2
3
  const plugin = require("@deephaven/plugin");
3
4
  const icons = require("@deephaven/icons");
4
5
  const require$$1 = require("react");
5
6
  const jsapiBootstrap = require("@deephaven/jsapi-bootstrap");
6
7
  const Log = require("@deephaven/log");
7
- var jsxRuntimeExports = {};
8
- var jsxRuntime = {
9
- get exports() {
10
- return jsxRuntimeExports;
11
- },
12
- set exports(v) {
13
- jsxRuntimeExports = v;
14
- }
15
- };
8
+ const dashboard = require("@deephaven/dashboard");
9
+ var jsxRuntime = { exports: {} };
16
10
  var reactJsxRuntime_production_min = {};
17
11
  /*
18
12
  object-assign
@@ -103,21 +97,17 @@ function q(c, a, k) {
103
97
  void 0 !== k && (e = "" + k);
104
98
  void 0 !== a.key && (e = "" + a.key);
105
99
  void 0 !== a.ref && (l = a.ref);
106
- for (b in a)
107
- n.call(a, b) && !p.hasOwnProperty(b) && (d[b] = a[b]);
108
- if (c && c.defaultProps)
109
- for (b in a = c.defaultProps, a)
110
- void 0 === d[b] && (d[b] = a[b]);
100
+ for (b in a) n.call(a, b) && !p.hasOwnProperty(b) && (d[b] = a[b]);
101
+ if (c && c.defaultProps) for (b in a = c.defaultProps, a) void 0 === d[b] && (d[b] = a[b]);
111
102
  return { $$typeof: g, type: c, key: e, ref: l, props: d, _owner: m.current };
112
103
  }
113
104
  reactJsxRuntime_production_min.jsx = q;
114
105
  reactJsxRuntime_production_min.jsxs = q;
115
- (function(module2) {
116
- {
117
- module2.exports = reactJsxRuntime_production_min;
118
- }
119
- })(jsxRuntime);
120
- const log = Log.module("@deephaven/js-plugin-matplotlib.MatplotlibView");
106
+ {
107
+ jsxRuntime.exports = reactJsxRuntime_production_min;
108
+ }
109
+ var jsxRuntimeExports = jsxRuntime.exports;
110
+ const log$1 = Log.module("@deephaven/js-plugin-matplotlib.MatplotlibView");
121
111
  const MatplotlibViewStyle = {
122
112
  height: "100%",
123
113
  width: "100%",
@@ -136,12 +126,12 @@ function MatplotlibView(props) {
136
126
  const dh = jsapiBootstrap.useApi();
137
127
  require$$1.useEffect(
138
128
  function initInputTable() {
139
- if (!inputTable) {
129
+ if (inputTable == null) {
140
130
  return;
141
131
  }
142
132
  const table = inputTable;
143
133
  async function openTable() {
144
- log.debug("openTable");
134
+ log$1.debug("openTable");
145
135
  const keyColumn = table.findColumn(
146
136
  "key"
147
137
  /* key */
@@ -160,7 +150,7 @@ function MatplotlibView(props) {
160
150
  dh.Table.EVENT_UPDATED,
161
151
  ({ detail: data }) => {
162
152
  const newRevision = data.rows[0].get(valueColumn);
163
- log.debug("New revision", newRevision);
153
+ log$1.debug("New revision", newRevision);
164
154
  setRevision(newRevision);
165
155
  }
166
156
  );
@@ -168,7 +158,7 @@ function MatplotlibView(props) {
168
158
  }
169
159
  openTable();
170
160
  return function closeTable() {
171
- log.debug("closeTable");
161
+ log$1.debug("closeTable");
172
162
  table.close();
173
163
  };
174
164
  },
@@ -177,12 +167,12 @@ function MatplotlibView(props) {
177
167
  require$$1.useEffect(
178
168
  function updateData() {
179
169
  async function fetchData() {
180
- log.debug("fetchData");
170
+ log$1.debug("fetchData");
181
171
  const widget = await fetch();
182
172
  const imageData = widget.getDataAsBase64();
183
173
  setImageSrc(`data:image/png;base64,${imageData}`);
184
174
  if (revision <= 0) {
185
- log.debug("Getting new input table");
175
+ log$1.debug("Getting new input table");
186
176
  const newInputTable = await widget.exportedObjects[0].fetch();
187
177
  setInputTable(newInputTable);
188
178
  }
@@ -202,9 +192,75 @@ function MatplotlibView(props) {
202
192
  }
203
193
  const MatplotlibPlugin = {
204
194
  name: "@deephaven/js-plugin-matplotlib",
195
+ title: "Matplotlib Figure",
205
196
  type: plugin.PluginType.WIDGET_PLUGIN,
206
197
  supportedTypes: "matplotlib.figure.Figure",
207
198
  component: MatplotlibView,
208
199
  icon: icons.vsGraph
209
200
  };
210
- module.exports = MatplotlibPlugin;
201
+ const urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
202
+ let nanoid = (size = 21) => {
203
+ let id = "";
204
+ let bytes = crypto.getRandomValues(new Uint8Array(size |= 0));
205
+ while (size--) {
206
+ id += urlAlphabet[bytes[size] & 63];
207
+ }
208
+ return id;
209
+ };
210
+ function MatplotlibPanel(props) {
211
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(MatplotlibView, { ...props });
212
+ }
213
+ MatplotlibPanel.COMPONENT = "MatPlotLibPanel";
214
+ const VARIABLE_TYPE = "matplotlib.figure.Figure";
215
+ const log = Log.module("@deephaven/js-plugin-matplotlib.DashboardPlugin");
216
+ function DashboardPlugin({
217
+ id,
218
+ layout,
219
+ registerComponent
220
+ }) {
221
+ const handlePanelOpen = require$$1.useCallback(
222
+ ({
223
+ dragEvent,
224
+ fetch,
225
+ metadata = {},
226
+ panelId = nanoid(),
227
+ widget
228
+ }) => {
229
+ const { name, type } = widget;
230
+ if (type !== VARIABLE_TYPE) {
231
+ return;
232
+ }
233
+ log.info("Panel opened of type", type);
234
+ const config = {
235
+ type: "react-component",
236
+ component: MatplotlibPanel.COMPONENT,
237
+ props: {
238
+ localDashboardId: id,
239
+ id: panelId,
240
+ metadata: {
241
+ ...metadata,
242
+ ...widget
243
+ },
244
+ fetch
245
+ },
246
+ title: name ?? void 0,
247
+ id: panelId
248
+ };
249
+ const { root } = layout;
250
+ dashboard.LayoutUtils.openComponent({ root, config, dragEvent });
251
+ },
252
+ [id, layout]
253
+ );
254
+ require$$1.useEffect(() => {
255
+ const cleanups = [
256
+ registerComponent(MatplotlibPanel.COMPONENT, MatplotlibPanel)
257
+ ];
258
+ return () => {
259
+ cleanups.forEach((cleanup) => cleanup());
260
+ };
261
+ }, [registerComponent]);
262
+ dashboard.useListener(layout.eventHub, "PanelEvent.OPEN", handlePanelOpen);
263
+ return null;
264
+ }
265
+ exports.DashboardPlugin = DashboardPlugin;
266
+ exports.default = MatplotlibPlugin;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deephaven/js-plugin-matplotlib",
3
- "version": "0.4.1",
3
+ "version": "0.5.1-alpha-pivots.0+3672c45",
4
4
  "description": "Deephaven Matplotlib plugin",
5
5
  "keywords": [
6
6
  "Deephaven",
@@ -28,23 +28,22 @@
28
28
  "devDependencies": {
29
29
  "@types/react": "^17.0.2",
30
30
  "@types/react-dom": "^17.0.2",
31
- "@vitejs/plugin-react-swc": "^3.0.0",
32
31
  "react": "^17.0.2",
33
- "typescript": "^4.5.4",
34
- "vite": "~4.1.4"
32
+ "react-dom": "^17.0.2"
35
33
  },
36
34
  "peerDependencies": {
37
- "react": "^17.0.2"
35
+ "react": "^17.0.2",
36
+ "react-dom": "^17.0.2"
38
37
  },
39
38
  "dependencies": {
40
- "@deephaven/components": "^0.58.0",
41
- "@deephaven/dashboard": "^0.58.0",
42
- "@deephaven/icons": "^0.58.0",
43
- "@deephaven/jsapi-bootstrap": "^0.58.0",
44
- "@deephaven/jsapi-types": "^0.58.0",
45
- "@deephaven/log": "^0.58.0",
46
- "@deephaven/plugin": "^0.58.0",
47
- "shortid": "^2.2.16"
39
+ "@deephaven/components": "^0.87.0",
40
+ "@deephaven/dashboard": "^0.86.0",
41
+ "@deephaven/icons": "^0.87.0",
42
+ "@deephaven/jsapi-bootstrap": "^0.87.0",
43
+ "@deephaven/jsapi-types": "1.0.0-dev0.35.2",
44
+ "@deephaven/log": "^0.87.0",
45
+ "@deephaven/plugin": "^0.86.0",
46
+ "nanoid": "^5.0.7"
48
47
  },
49
48
  "publishConfig": {
50
49
  "access": "public"
@@ -52,5 +51,5 @@
52
51
  "files": [
53
52
  "dist/index.js"
54
53
  ],
55
- "gitHead": "416f64e064e3e501099f5fda66c1d7d1b27c2722"
54
+ "gitHead": "3672c455111ffff5975520efd83e89f0f0476d2e"
56
55
  }