@deephaven/embed-chart 0.54.1-styleguide-tests.21 → 0.54.1-ui.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.
- package/build/assets/{App-67402fee.js → App-b931df98.js} +2 -2
- package/build/assets/{App-67402fee.js.map → App-b931df98.js.map} +1 -1
- package/build/assets/index-99d502e5.js +17 -0
- package/build/assets/index-99d502e5.js.map +1 -0
- package/build/assets/{index-450c739d.css → index-c6d94f43.css} +1 -1
- package/build/assets/{index-96573edc.js → index-c78c637d.js} +2 -2
- package/build/assets/{index-96573edc.js.map → index-c78c637d.js.map} +1 -1
- package/build/assets/{useConnection-658140d0.js → useConnection-0ec76da2.js} +2 -2
- package/build/assets/{useConnection-658140d0.js.map → useConnection-0ec76da2.js.map} +1 -1
- package/build/index.html +1 -1
- package/package.json +14 -14
- package/build/assets/index-3d47ab45.js +0 -17
- package/build/assets/index-3d47ab45.js.map +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as o,C as n}from"./vendor-59aec175.js";import{L as C,a as b}from"./index-
|
|
2
|
-
//# sourceMappingURL=App-
|
|
1
|
+
import{r as o,C as n}from"./vendor-59aec175.js";import{L as C,a as b}from"./index-c78c637d.js";import{u as w,a as y,b as L,C as A,c as E,d as M}from"./useConnection-0ec76da2.js";import"./helpers-042e6b4d.js";import"./plotly-4a688a7b.js";const t=C.module("EmbedChart.App");async function j(a,r,s){t.info(`Fetching figure ${s}...`);const i={name:s,type:a.VariableType.FIGURE};return r.getObject(i)}function $(){const[a,r]=o.useState(),[s,i]=o.useState(),[m,g]=o.useState(!0),d=o.useMemo(()=>new URLSearchParams(window.location.search),[]),l=w(),c=y(),p=L();o.useEffect(function(){async function f(){try{const e=d.get("name");if(e==null)throw new Error("No name param provided");t.debug("Loading figure",e,"...");const h=await j(c,l,e);t.debug("Creating model...");const x=await M.makeModel(c,void 0,h,p);r(x),t.debug("Figure successfully loaded!")}catch(e){t.error("Unable to load figure",e),i(`${e}`)}g(!1)}f()},[c,l,d,p]);const u=a!=null;return n.jsxs("div",{className:"App",children:[u&&n.jsx(A,{model:a}),!u&&n.jsx(b,{isLoaded:u,isLoading:m,errorMessage:s??null}),n.jsx(E,{})]})}export{$ as default};
|
|
2
|
+
//# sourceMappingURL=App-b931df98.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"App-
|
|
1
|
+
{"version":3,"file":"App-b931df98.js","sources":["../../src/App.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useState } from 'react';\nimport {\n Chart,\n ChartModel,\n ChartModelFactory,\n useChartTheme,\n} from '@deephaven/chart'; // chart is used to display Deephaven charts\nimport { ContextMenuRoot, LoadingOverlay } from '@deephaven/components'; // Use the loading spinner from the Deephaven components package\nimport type {\n dh as DhType,\n Figure,\n IdeConnection,\n} from '@deephaven/jsapi-types';\nimport Log from '@deephaven/log';\nimport './App.scss'; // Styles for in this app\nimport { useApi } from '@deephaven/jsapi-bootstrap';\nimport { useConnection } from '@deephaven/jsapi-components';\n\nconst log = Log.module('EmbedChart.App');\n\n/**\n * Load an existing Deephaven figure with the connection provided\n * @param dh JSAPI instance\n * @param connection The Deephaven session object\n * @param name Name of the figure to load\n * @returns Deephaven figure\n */\nasync function loadFigure(\n dh: DhType,\n connection: IdeConnection,\n name: string\n): Promise<Figure> {\n log.info(`Fetching figure ${name}...`);\n\n const definition = { name, type: dh.VariableType.FIGURE };\n return connection.getObject(definition);\n}\n\n/**\n * A functional React component that displays a Deephaven figure using the @deephaven/chart package.\n * It will attempt to open and display the figure specified with the `name` parameter, expecting it to be present on the server.\n * E.g. http://localhost:3000/?name=myFigure will attempt to open a figure `myFigure`\n * If no query param is provided, it will display an error.\n * By default, tries to connect to the server defined in the VITE_CORE_API_URL variable, which is set to http://localhost:10000/jsapi\n * See create-react-app docs for how to update these env vars: https://create-react-app.dev/docs/adding-custom-environment-variables/\n */\nfunction App(): JSX.Element {\n const [model, setModel] = useState<ChartModel>();\n const [error, setError] = useState<string>();\n const [isLoading, setIsLoading] = useState(true);\n const searchParams = useMemo(\n () => new URLSearchParams(window.location.search),\n []\n );\n const connection = useConnection();\n const dh = useApi();\n const chartTheme = useChartTheme();\n\n useEffect(\n function initializeApp() {\n async function initApp(): Promise<void> {\n try {\n // Get the table name from the query param `name`.\n const name = searchParams.get('name');\n\n if (name == null) {\n throw new Error('No name param provided');\n }\n\n log.debug('Loading figure', name, '...');\n\n // Load the figure up.\n const figure = await loadFigure(dh, connection, name);\n\n // Create the `ChartModel` for use with the `Chart` component\n log.debug(`Creating model...`);\n\n const newModel = await ChartModelFactory.makeModel(\n dh,\n undefined,\n figure,\n chartTheme\n );\n\n setModel(newModel);\n\n log.debug('Figure successfully loaded!');\n } catch (e: unknown) {\n log.error('Unable to load figure', e);\n setError(`${e}`);\n }\n setIsLoading(false);\n }\n initApp();\n },\n [dh, connection, searchParams, chartTheme]\n );\n\n const isLoaded = model != null;\n\n return (\n <div className=\"App\">\n {isLoaded && <Chart model={model} />}\n {!isLoaded && (\n <LoadingOverlay\n isLoaded={isLoaded}\n isLoading={isLoading}\n errorMessage={error ?? null}\n />\n )}\n <ContextMenuRoot />\n </div>\n );\n}\n\nexport default App;\n"],"names":["log","Log","loadFigure","dh","connection","name","definition","App","model","setModel","useState","error","setError","isLoading","setIsLoading","searchParams","useMemo","useConnection","useApi","chartTheme","useChartTheme","useEffect","initApp","figure","newModel","ChartModelFactory","isLoaded","jsxs","jsx","Chart","LoadingOverlay","ContextMenuRoot"],"mappings":"6OAkBA,MAAMA,EAAMC,EAAI,OAAO,gBAAgB,EASvC,eAAeC,EACbC,EACAC,EACAC,EACiB,CACbL,EAAA,KAAK,mBAAmBK,MAAS,EAErC,MAAMC,EAAa,CAAE,KAAAD,EAAM,KAAMF,EAAG,aAAa,QAC1C,OAAAC,EAAW,UAAUE,CAAU,CACxC,CAUA,SAASC,GAAmB,CAC1B,KAAM,CAACC,EAAOC,CAAQ,EAAIC,EAAqB,SA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